aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2011-10-10 17:43:39 +0200
committerReinhard Tartler <siretart@tauware.de>2011-10-10 17:43:39 +0200
commitf4092abdf94af6a99aff944d6264bc1284e8bdd4 (patch)
tree2ac1c9cc16ceb93edb2c4382c088dac5aeafdf0f /nx-X11/programs/Xserver
parenta840692edc9c6d19cd7c057f68e39c7d95eb767d (diff)
downloadnx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.tar.gz
nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.tar.bz2
nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.zip
Imported nx-X11-3.1.0-1.tar.gznx-X11/3.1.0-1
Summary: Imported nx-X11-3.1.0-1.tar.gz Keywords: Imported nx-X11-3.1.0-1.tar.gz into Git repository
Diffstat (limited to 'nx-X11/programs/Xserver')
-rw-r--r--nx-X11/programs/Xserver/GL/Imakefile66
-rw-r--r--nx-X11/programs/Xserver/GL/apple/Imakefile49
-rw-r--r--nx-X11/programs/Xserver/GL/apple/aglGlx.c1355
-rw-r--r--nx-X11/programs/Xserver/GL/apple/indirect.c1380
-rw-r--r--nx-X11/programs/Xserver/GL/dri/Imakefile35
-rw-r--r--nx-X11/programs/Xserver/GL/dri/Imakefile.NX.reference35
-rw-r--r--nx-X11/programs/Xserver/GL/dri/Imakefile.XF86.reference34
-rw-r--r--nx-X11/programs/Xserver/GL/dri/dri-def.cpp50
-rw-r--r--nx-X11/programs/Xserver/GL/dri/dri.c2109
-rw-r--r--nx-X11/programs/Xserver/GL/dri/dri.h345
-rw-r--r--nx-X11/programs/Xserver/GL/dri/drimodule.c127
-rw-r--r--nx-X11/programs/Xserver/GL/dri/dristruct.h105
-rw-r--r--nx-X11/programs/Xserver/GL/dri/sarea.h94
-rw-r--r--nx-X11/programs/Xserver/GL/dri/xf86dri.c649
-rw-r--r--nx-X11/programs/Xserver/GL/glx/Imakefile118
-rw-r--r--nx-X11/programs/Xserver/GL/glx/g_disptab.c839
-rw-r--r--nx-X11/programs/Xserver/GL/glx/g_disptab.h652
-rw-r--r--nx-X11/programs/Xserver/GL/glx/g_disptab_EXT.c4447
-rw-r--r--nx-X11/programs/Xserver/GL/glx/g_disptab_EXT.h159
-rw-r--r--nx-X11/programs/Xserver/GL/glx/g_render.c2282
-rw-r--r--nx-X11/programs/Xserver/GL/glx/g_renderswap.c3387
-rw-r--r--nx-X11/programs/Xserver/GL/glx/g_single.c1787
-rw-r--r--nx-X11/programs/Xserver/GL/glx/g_singleswap.c2208
-rw-r--r--nx-X11/programs/Xserver/GL/glx/global.c76
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glx-def.cpp662
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxbuf.c296
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxbuf.h57
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxcmds.c2156
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxcmdsswap.c871
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxcontext.h164
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxdrawable.h112
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxerror.h58
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxext.c505
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxext.h131
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxfb.c183
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxfb.h52
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glximports.c184
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glximports.h66
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxmem.c151
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxmem.h48
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxpix.c132
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxpix.h48
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxscreens.c378
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxscreens.h103
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxserver.h287
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxutil.c507
-rw-r--r--nx-X11/programs/Xserver/GL/glx/glxutil.h84
-rw-r--r--nx-X11/programs/Xserver/GL/glx/impsize.h56
-rw-r--r--nx-X11/programs/Xserver/GL/glx/module/Imakefile4
-rw-r--r--nx-X11/programs/Xserver/GL/glx/render2.c271
-rw-r--r--nx-X11/programs/Xserver/GL/glx/render2swap.c393
-rw-r--r--nx-X11/programs/Xserver/GL/glx/renderpix.c312
-rw-r--r--nx-X11/programs/Xserver/GL/glx/renderpixswap.c555
-rw-r--r--nx-X11/programs/Xserver/GL/glx/rensize.c987
-rw-r--r--nx-X11/programs/Xserver/GL/glx/rensizetab.c2448
-rw-r--r--nx-X11/programs/Xserver/GL/glx/single2.c411
-rw-r--r--nx-X11/programs/Xserver/GL/glx/single2swap.c303
-rw-r--r--nx-X11/programs/Xserver/GL/glx/singlepix.c462
-rw-r--r--nx-X11/programs/Xserver/GL/glx/singlepixswap.c518
-rw-r--r--nx-X11/programs/Xserver/GL/glx/singlesize.c1222
-rw-r--r--nx-X11/programs/Xserver/GL/glx/singlesize.h87
-rw-r--r--nx-X11/programs/Xserver/GL/glx/unpack.h240
-rw-r--r--nx-X11/programs/Xserver/GL/glx/xfont.c195
-rw-r--r--nx-X11/programs/Xserver/GL/glxmodule.c1270
-rw-r--r--nx-X11/programs/Xserver/GL/include/GL/glx_ansic.h115
-rw-r--r--nx-X11/programs/Xserver/GL/include/GL/xf86glx.h43
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/GLcore/GLcore-def.cpp1462
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/GLcore/GLcoremodule.c64
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/GLcore/Imakefile77
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/GLcore/module/Imakefile53
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/Imakefile47
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/X/Imakefile93
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/X/module/Imakefile6
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/X/xf86glx.c914
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/X/xf86glx_util.c151
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/X/xf86glx_util.h106
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/X/xf86glxint.h102
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/array_cache/Imakefile56
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/array_cache/module/Imakefile6
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/main/Imakefile61
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/main/module/Imakefile6
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/math/Imakefile55
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/math/module/Imakefile6
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/shader/Imakefile59
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/shader/grammar/Imakefile54
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/shader/slang/Imakefile59
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/shader/slang/library/Imakefile46
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/swrast/Imakefile63
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/swrast/module/Imakefile6
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/swrast_setup/Imakefile55
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/swrast_setup/module/Imakefile6
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/tnl/Imakefile66
-rw-r--r--nx-X11/programs/Xserver/GL/mesa/tnl/module/Imakefile6
-rw-r--r--nx-X11/programs/Xserver/GL/opengl/Imakefile140
-rw-r--r--nx-X11/programs/Xserver/GL/windows/ChangeLog64
-rwxr-xr-xnx-X11/programs/Xserver/GL/windows/Imakefile36
-rw-r--r--nx-X11/programs/Xserver/GL/windows/glwindows.h64
-rwxr-xr-xnx-X11/programs/Xserver/GL/windows/glwrap.c583
-rwxr-xr-xnx-X11/programs/Xserver/GL/windows/indirect.c1605
-rw-r--r--nx-X11/programs/Xserver/Imakefile1579
-rw-r--r--nx-X11/programs/Xserver/Imakefile.NX.original1579
-rw-r--r--nx-X11/programs/Xserver/Imakefile.X.original1242
-rw-r--r--nx-X11/programs/Xserver/XFree86.def5
-rw-r--r--nx-X11/programs/Xserver/XTrap/Imakefile27
-rw-r--r--nx-X11/programs/Xserver/XTrap/module/Imakefile26
-rw-r--r--nx-X11/programs/Xserver/XTrap/xf86XTrapModule.c51
-rw-r--r--nx-X11/programs/Xserver/XTrap/xtrapddmi.c188
-rw-r--r--nx-X11/programs/Xserver/XTrap/xtrapdi.c2157
-rw-r--r--nx-X11/programs/Xserver/XTrap/xtrapdiswp.c1010
-rw-r--r--nx-X11/programs/Xserver/XTrap/xtrapditbl.c242
-rw-r--r--nx-X11/programs/Xserver/Xext/EVI.c202
-rw-r--r--nx-X11/programs/Xserver/Xext/EVIstruct.h60
-rw-r--r--nx-X11/programs/Xserver/Xext/Imakefile226
-rw-r--r--nx-X11/programs/Xserver/Xext/Imakefile.NX.original226
-rw-r--r--nx-X11/programs/Xserver/Xext/Imakefile.X.original200
-rw-r--r--nx-X11/programs/Xserver/Xext/SecurityPolicy88
-rw-r--r--nx-X11/programs/Xserver/Xext/appgroup.c829
-rw-r--r--nx-X11/programs/Xserver/Xext/appgroup.h10
-rw-r--r--nx-X11/programs/Xserver/Xext/bigreq.c107
-rw-r--r--nx-X11/programs/Xserver/Xext/cup.c364
-rw-r--r--nx-X11/programs/Xserver/Xext/dgaproc.h144
-rw-r--r--nx-X11/programs/Xserver/Xext/dmx.c1133
-rw-r--r--nx-X11/programs/Xserver/Xext/dpms.c450
-rw-r--r--nx-X11/programs/Xserver/Xext/dpmsproc.h16
-rw-r--r--nx-X11/programs/Xserver/Xext/dpmsstubs.c54
-rw-r--r--nx-X11/programs/Xserver/Xext/extmod/Imakefile127
-rw-r--r--nx-X11/programs/Xserver/Xext/extmod/modinit.c264
-rw-r--r--nx-X11/programs/Xserver/Xext/extmod/modinit.h149
-rw-r--r--nx-X11/programs/Xserver/Xext/fontcache.c333
-rw-r--r--nx-X11/programs/Xserver/Xext/mbuf.c1787
-rw-r--r--nx-X11/programs/Xserver/Xext/mbufbf.c1030
-rw-r--r--nx-X11/programs/Xserver/Xext/mbufpx.c651
-rw-r--r--nx-X11/programs/Xserver/Xext/mitmisc.c176
-rw-r--r--nx-X11/programs/Xserver/Xext/panoramiX.c1308
-rw-r--r--nx-X11/programs/Xserver/Xext/panoramiX.h115
-rw-r--r--nx-X11/programs/Xserver/Xext/panoramiXSwap.c144
-rw-r--r--nx-X11/programs/Xserver/Xext/panoramiXh.h78
-rw-r--r--nx-X11/programs/Xserver/Xext/panoramiXprocs.c2372
-rw-r--r--nx-X11/programs/Xserver/Xext/panoramiXsrv.h50
-rw-r--r--nx-X11/programs/Xserver/Xext/sampleEVI.c106
-rw-r--r--nx-X11/programs/Xserver/Xext/saver.c1415
-rw-r--r--nx-X11/programs/Xserver/Xext/security.c2241
-rw-r--r--nx-X11/programs/Xserver/Xext/security.c.NX.original2241
-rw-r--r--nx-X11/programs/Xserver/Xext/security.c.X.original2004
-rw-r--r--nx-X11/programs/Xserver/Xext/shape.c1335
-rw-r--r--nx-X11/programs/Xserver/Xext/shm.c1267
-rw-r--r--nx-X11/programs/Xserver/Xext/sleepuntil.c239
-rw-r--r--nx-X11/programs/Xserver/Xext/sleepuntil.h47
-rw-r--r--nx-X11/programs/Xserver/Xext/sync.c2513
-rw-r--r--nx-X11/programs/Xserver/Xext/vidmodeproc.h78
-rw-r--r--nx-X11/programs/Xserver/Xext/xcmisc.c253
-rw-r--r--nx-X11/programs/Xserver/Xext/xevie.c719
-rw-r--r--nx-X11/programs/Xserver/Xext/xf86bigfont.c790
-rw-r--r--nx-X11/programs/Xserver/Xext/xf86dga.c307
-rw-r--r--nx-X11/programs/Xserver/Xext/xf86dga2.c775
-rw-r--r--nx-X11/programs/Xserver/Xext/xf86dgaext.h12
-rw-r--r--nx-X11/programs/Xserver/Xext/xf86misc.c854
-rw-r--r--nx-X11/programs/Xserver/Xext/xf86miscproc.h70
-rw-r--r--nx-X11/programs/Xserver/Xext/xf86vmode.c2206
-rw-r--r--nx-X11/programs/Xserver/Xext/xprint.c2760
-rw-r--r--nx-X11/programs/Xserver/Xext/xres.c339
-rw-r--r--nx-X11/programs/Xserver/Xext/xtest.c608
-rw-r--r--nx-X11/programs/Xserver/Xext/xtest1.frags90
-rw-r--r--nx-X11/programs/Xserver/Xext/xtest1dd.c1617
-rw-r--r--nx-X11/programs/Xserver/Xext/xtest1dd.h127
-rw-r--r--nx-X11/programs/Xserver/Xext/xtest1di.c954
-rw-r--r--nx-X11/programs/Xserver/Xext/xvdisp.c2217
-rw-r--r--nx-X11/programs/Xserver/Xext/xvdisp.h3
-rw-r--r--nx-X11/programs/Xserver/Xext/xvdix.h291
-rw-r--r--nx-X11/programs/Xserver/Xext/xvmain.c1203
-rw-r--r--nx-X11/programs/Xserver/Xext/xvmc.c796
-rw-r--r--nx-X11/programs/Xserver/Xext/xvmcext.h116
-rw-r--r--nx-X11/programs/Xserver/Xext/xvmod.c24
-rw-r--r--nx-X11/programs/Xserver/Xext/xvmodproc.h14
-rw-r--r--nx-X11/programs/Xserver/Xi/Imakefile94
-rw-r--r--nx-X11/programs/Xserver/Xi/allowev.c145
-rw-r--r--nx-X11/programs/Xserver/Xi/allowev.h44
-rw-r--r--nx-X11/programs/Xserver/Xi/chgdctl.c219
-rw-r--r--nx-X11/programs/Xserver/Xi/chgdctl.h51
-rw-r--r--nx-X11/programs/Xserver/Xi/chgfctl.c663
-rw-r--r--nx-X11/programs/Xserver/Xi/chgfctl.h98
-rw-r--r--nx-X11/programs/Xserver/Xi/chgkbd.c216
-rw-r--r--nx-X11/programs/Xserver/Xi/chgkbd.h52
-rw-r--r--nx-X11/programs/Xserver/Xi/chgkmap.c136
-rw-r--r--nx-X11/programs/Xserver/Xi/chgkmap.h44
-rw-r--r--nx-X11/programs/Xserver/Xi/chgprop.c174
-rw-r--r--nx-X11/programs/Xserver/Xi/chgprop.h44
-rw-r--r--nx-X11/programs/Xserver/Xi/chgptr.c262
-rw-r--r--nx-X11/programs/Xserver/Xi/chgptr.h73
-rw-r--r--nx-X11/programs/Xserver/Xi/closedev.c191
-rw-r--r--nx-X11/programs/Xserver/Xi/closedev.h58
-rw-r--r--nx-X11/programs/Xserver/Xi/devbell.c173
-rw-r--r--nx-X11/programs/Xserver/Xi/devbell.h44
-rw-r--r--nx-X11/programs/Xserver/Xi/exevents.c1366
-rw-r--r--nx-X11/programs/Xserver/Xi/exglobals.h80
-rw-r--r--nx-X11/programs/Xserver/Xi/extinit.c1016
-rw-r--r--nx-X11/programs/Xserver/Xi/getbmap.c154
-rw-r--r--nx-X11/programs/Xserver/Xi/getbmap.h51
-rw-r--r--nx-X11/programs/Xserver/Xi/getdctl.c230
-rw-r--r--nx-X11/programs/Xserver/Xi/getdctl.h59
-rw-r--r--nx-X11/programs/Xserver/Xi/getfctl.c422
-rw-r--r--nx-X11/programs/Xserver/Xi/getfctl.h93
-rw-r--r--nx-X11/programs/Xserver/Xi/getfocus.c157
-rw-r--r--nx-X11/programs/Xserver/Xi/getfocus.h51
-rw-r--r--nx-X11/programs/Xserver/Xi/getkmap.c178
-rw-r--r--nx-X11/programs/Xserver/Xi/getkmap.h51
-rw-r--r--nx-X11/programs/Xserver/Xi/getmmap.c158
-rw-r--r--nx-X11/programs/Xserver/Xi/getmmap.h51
-rw-r--r--nx-X11/programs/Xserver/Xi/getprop.c215
-rw-r--r--nx-X11/programs/Xserver/Xi/getprop.h60
-rw-r--r--nx-X11/programs/Xserver/Xi/getselev.c196
-rw-r--r--nx-X11/programs/Xserver/Xi/getselev.h51
-rw-r--r--nx-X11/programs/Xserver/Xi/getvers.c157
-rw-r--r--nx-X11/programs/Xserver/Xi/getvers.h51
-rw-r--r--nx-X11/programs/Xserver/Xi/grabdev.c232
-rw-r--r--nx-X11/programs/Xserver/Xi/grabdev.h61
-rw-r--r--nx-X11/programs/Xserver/Xi/grabdevb.c170
-rw-r--r--nx-X11/programs/Xserver/Xi/grabdevb.h44
-rw-r--r--nx-X11/programs/Xserver/Xi/grabdevk.c174
-rw-r--r--nx-X11/programs/Xserver/Xi/grabdevk.h44
-rw-r--r--nx-X11/programs/Xserver/Xi/gtmotion.c213
-rw-r--r--nx-X11/programs/Xserver/Xi/gtmotion.h51
-rw-r--r--nx-X11/programs/Xserver/Xi/listdev.c407
-rw-r--r--nx-X11/programs/Xserver/Xi/listdev.h103
-rw-r--r--nx-X11/programs/Xserver/Xi/opendev.c205
-rw-r--r--nx-X11/programs/Xserver/Xi/opendev.h51
-rw-r--r--nx-X11/programs/Xserver/Xi/queryst.c215
-rw-r--r--nx-X11/programs/Xserver/Xi/queryst.h51
-rw-r--r--nx-X11/programs/Xserver/Xi/selectev.c159
-rw-r--r--nx-X11/programs/Xserver/Xi/selectev.h44
-rw-r--r--nx-X11/programs/Xserver/Xi/sendexev.c181
-rw-r--r--nx-X11/programs/Xserver/Xi/sendexev.h44
-rw-r--r--nx-X11/programs/Xserver/Xi/setbmap.c170
-rw-r--r--nx-X11/programs/Xserver/Xi/setbmap.h51
-rw-r--r--nx-X11/programs/Xserver/Xi/setdval.c174
-rw-r--r--nx-X11/programs/Xserver/Xi/setdval.h51
-rw-r--r--nx-X11/programs/Xserver/Xi/setfocus.c126
-rw-r--r--nx-X11/programs/Xserver/Xi/setfocus.h44
-rw-r--r--nx-X11/programs/Xserver/Xi/setmmap.c164
-rw-r--r--nx-X11/programs/Xserver/Xi/setmmap.h51
-rw-r--r--nx-X11/programs/Xserver/Xi/setmode.c158
-rw-r--r--nx-X11/programs/Xserver/Xi/setmode.h51
-rw-r--r--nx-X11/programs/Xserver/Xi/stubs.c317
-rw-r--r--nx-X11/programs/Xserver/Xi/ungrdev.c123
-rw-r--r--nx-X11/programs/Xserver/Xi/ungrdev.h44
-rw-r--r--nx-X11/programs/Xserver/Xi/ungrdevb.c178
-rw-r--r--nx-X11/programs/Xserver/Xi/ungrdevb.h44
-rw-r--r--nx-X11/programs/Xserver/Xi/ungrdevk.c184
-rw-r--r--nx-X11/programs/Xserver/Xi/ungrdevk.h44
-rw-r--r--nx-X11/programs/Xserver/Xnest.def4
-rw-r--r--nx-X11/programs/Xserver/Xorg.def5
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/Imakefile8
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/Imakefile23
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/Xprinters49
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/attributes/Imakefile8
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/attributes/document49
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/attributes/job25
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/attributes/printer96
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/Imakefile8
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/raster/Imakefile6
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/raster/pcl39
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/raster/postscript0
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/Imakefile15
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/model-config23
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/CANONC3200-PS/Imakefile15
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/CANONC3200-PS/fonts/Imakefile45
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/CANONC3200-PS/model-config40
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/GSdefault/Imakefile14
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/GSdefault/model-config137
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/Imakefile14
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00051.pmfbin0 -> 5740 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00052.pmfbin0 -> 5736 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00053.pmfbin0 -> 5740 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00054.pmfbin0 -> 5744 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00055.pmfbin0 -> 5740 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00056.pmfbin0 -> 5724 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00057.pmfbin0 -> 5632 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00058.pmfbin0 -> 5740 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00059.pmfbin0 -> 5720 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00060.pmfbin0 -> 5740 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00061.pmfbin0 -> 5720 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00062.pmfbin0 -> 5728 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00063.pmfbin0 -> 5728 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00064.pmfbin0 -> 5720 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00065.pmfbin0 -> 5728 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00066.pmfbin0 -> 5732 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00067.pmfbin0 -> 5736 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00068.pmfbin0 -> 5732 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00069.pmfbin0 -> 5740 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00070.pmfbin0 -> 5744 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00071.pmfbin0 -> 5740 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00072.pmfbin0 -> 5724 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00073.pmfbin0 -> 5720 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00074.pmfbin0 -> 5724 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00075.pmfbin0 -> 5724 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00076.pmfbin0 -> 5716 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00077.pmfbin0 -> 5720 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00079.pmfbin0 -> 5656 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00080.pmfbin0 -> 5664 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00081.pmfbin0 -> 5672 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00082.pmfbin0 -> 5660 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00083.pmfbin0 -> 5720 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00084.pmfbin0 -> 5724 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00085.pmfbin0 -> 5724 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00086.pmfbin0 -> 5716 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00087.pmfbin0 -> 5752 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00088.pmfbin0 -> 5720 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00089.pmfbin0 -> 5744 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00090.pmfbin0 -> 5736 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00091.pmfbin0 -> 5744 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00092.pmfbin0 -> 5736 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00093.pmfbin0 -> 5728 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00094.pmfbin0 -> 5728 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/Imakefile57
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/README197
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias0
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.dir45
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/lpr0ye1a.pmfbin0 -> 4296 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/model-config40
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/Imakefile15
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/fonts/Imakefile45
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/model-config36
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/Imakefile14
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00051.pmfbin0 -> 5740 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00052.pmfbin0 -> 5736 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00053.pmfbin0 -> 5740 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00054.pmfbin0 -> 5744 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00055.pmfbin0 -> 5740 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00056.pmfbin0 -> 5724 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00057.pmfbin0 -> 5632 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00058.pmfbin0 -> 5740 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00059.pmfbin0 -> 5720 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00060.pmfbin0 -> 5740 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00061.pmfbin0 -> 5720 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00062.pmfbin0 -> 5728 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00063.pmfbin0 -> 5728 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00064.pmfbin0 -> 5720 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00065.pmfbin0 -> 5728 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00066.pmfbin0 -> 5732 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00067.pmfbin0 -> 5736 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00068.pmfbin0 -> 5732 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00069.pmfbin0 -> 5740 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00070.pmfbin0 -> 5744 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00071.pmfbin0 -> 5740 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00072.pmfbin0 -> 5724 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00073.pmfbin0 -> 5720 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00074.pmfbin0 -> 5724 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00075.pmfbin0 -> 5724 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00076.pmfbin0 -> 5716 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00077.pmfbin0 -> 5720 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00079.pmfbin0 -> 5656 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00080.pmfbin0 -> 5664 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00081.pmfbin0 -> 5672 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00082.pmfbin0 -> 5660 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00083.pmfbin0 -> 5720 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00084.pmfbin0 -> 5724 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00085.pmfbin0 -> 5724 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00086.pmfbin0 -> 5716 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00087.pmfbin0 -> 5752 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00088.pmfbin0 -> 5720 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00089.pmfbin0 -> 5744 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00090.pmfbin0 -> 5736 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00091.pmfbin0 -> 5744 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00092.pmfbin0 -> 5736 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00093.pmfbin0 -> 5728 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00094.pmfbin0 -> 5728 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/Imakefile56
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/README203
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias0
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/fonts.dir45
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/lpr0ye1a.pmfbin0 -> 4296 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/model-config39
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/Imakefile45
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/Imakefile35
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/model-config72
-rwxr-xr-xnx-X11/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/ps2pdf_spooltodir.sh130
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/Imakefile14
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Book.pmfbin0 -> 6716 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-BookOblique.pmfbin0 -> 6728 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Demi.pmfbin0 -> 6712 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-DemiOblique.pmfbin0 -> 6724 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Bold.pmfbin0 -> 6612 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-BoldOblique.pmfbin0 -> 6636 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Oblique.pmfbin0 -> 6608 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier.pmfbin0 -> 6592 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Bold.pmfbin0 -> 6680 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-BoldOblique.pmfbin0 -> 6692 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Oblique.pmfbin0 -> 6688 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica.pmfbin0 -> 6672 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Imakefile41
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Book.pmfbin0 -> 6628 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-BookOblique.pmfbin0 -> 6640 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Demi.pmfbin0 -> 6624 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-DemiOblique.pmfbin0 -> 6636 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Bold.pmfbin0 -> 6644 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-BoldItalic.pmfbin0 -> 6656 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Italic.pmfbin0 -> 6652 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Roman.pmfbin0 -> 6648 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Demi.pmfbin0 -> 6680 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-DemiItalic.pmfbin0 -> 6692 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Light.pmfbin0 -> 6684 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-LightItalic.pmfbin0 -> 6696 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Symbol.pmfbin0 -> 6556 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Bold.pmfbin0 -> 6660 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-BoldItalic.pmfbin0 -> 6672 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Italic.pmfbin0 -> 6668 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Roman.pmfbin0 -> 6664 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/ZapfDingbats.pmfbin0 -> 6676 bytes
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/model-config136
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSspooldir/Imakefile34
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/PSspooldir/model-config71
-rwxr-xr-xnx-X11/programs/Xserver/XpConfig/C/print/models/PSspooldir/spooltodir.sh127
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/SPSPARC2/Imakefile15
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Imakefile28
-rw-r--r--nx-X11/programs/Xserver/XpConfig/C/print/models/SPSPARC2/model-config18
-rw-r--r--nx-X11/programs/Xserver/XpConfig/Imakefile761
-rw-r--r--nx-X11/programs/Xserver/XpConfig/README318
-rw-r--r--nx-X11/programs/Xserver/XpConfig/en_US/Imakefile8
-rw-r--r--nx-X11/programs/Xserver/XpConfig/en_US/print/Imakefile26
-rw-r--r--nx-X11/programs/Xserver/XpConfig/en_US/print/attributes/Imakefile18
-rw-r--r--nx-X11/programs/Xserver/XpConfig/en_US/print/attributes/document13
-rw-r--r--nx-X11/programs/Xserver/Xprint/AttrValid.c702
-rw-r--r--nx-X11/programs/Xserver/Xprint/AttrValid.h216
-rw-r--r--nx-X11/programs/Xserver/Xprint/DiPrint.h81
-rw-r--r--nx-X11/programs/Xserver/Xprint/Imakefile135
-rw-r--r--nx-X11/programs/Xserver/Xprint/Init.c1934
-rw-r--r--nx-X11/programs/Xserver/Xprint/Oid.c3184
-rw-r--r--nx-X11/programs/Xserver/Xprint/Oid.h294
-rw-r--r--nx-X11/programs/Xserver/Xprint/OidDefs.h171
-rw-r--r--nx-X11/programs/Xserver/Xprint/OidStrs.h173
-rw-r--r--nx-X11/programs/Xserver/Xprint/Util.c372
-rw-r--r--nx-X11/programs/Xserver/Xprint/ValTree.c193
-rw-r--r--nx-X11/programs/Xserver/Xprint/Xprt.html115
-rw-r--r--nx-X11/programs/Xserver/Xprint/Xprt.man196
-rw-r--r--nx-X11/programs/Xserver/Xprint/Xprt.sgml371
-rw-r--r--nx-X11/programs/Xserver/Xprint/attributes.c1740
-rw-r--r--nx-X11/programs/Xserver/Xprint/attributes.h131
-rw-r--r--nx-X11/programs/Xserver/Xprint/ddxInit.c397
-rw-r--r--nx-X11/programs/Xserver/Xprint/etc/Imakefile24
-rw-r--r--nx-X11/programs/Xserver/Xprint/etc/Xsession.d/Imakefile24
-rw-r--r--nx-X11/programs/Xserver/Xprint/etc/Xsession.d/cde_xsessiond_xprint.sh30
-rw-r--r--nx-X11/programs/Xserver/Xprint/etc/init.d/Imakefile97
-rw-r--r--nx-X11/programs/Xserver/Xprint/etc/init.d/xprint.cpp1277
-rw-r--r--nx-X11/programs/Xserver/Xprint/etc/profile.d/Imakefile14
-rw-r--r--nx-X11/programs/Xserver/Xprint/etc/profile.d/xprint.csh16
-rw-r--r--nx-X11/programs/Xserver/Xprint/etc/profile.d/xprint.sh16
-rw-r--r--nx-X11/programs/Xserver/Xprint/mediaSizes.c783
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl-mono/Imakefile6
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/Imakefile76
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/Pcl.h625
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclArc.c270
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclArea.c486
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclAttVal.c207
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclAttr.c87
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclColor.c851
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclCursor.c115
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclDef.h68
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclFonts.c74
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclGC.c1046
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclInit.c631
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclLine.c316
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclMisc.c306
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclPixel.c159
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclPixmap.c85
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclPolygon.c353
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclPrint.c711
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.c429
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.h116
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclSpans.c139
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclText.c936
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclWindow.c452
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/Pclmap.h213
-rw-r--r--nx-X11/programs/Xserver/Xprint/pdf/README1
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/Imakefile89
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/Ps.h590
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsArc.c182
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsArea.c393
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsAttVal.c290
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsAttr.c117
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsCache.c328
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsColor.c258
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsDef.h97
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsFTFonts.c85
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsFonts.c876
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsGC.c419
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsImageUtil.c329
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsInit.c667
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsLine.c192
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsMisc.c324
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsPixel.c157
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsPixmap.c617
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsPolygon.c262
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsPrint.c462
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsSpans.c166
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsText.c586
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/PsWindow.c462
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/psout.c1792
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/psout.h335
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/psout_ft.c335
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/psout_ftpstype1.c185
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/psout_ftpstype3.c468
-rw-r--r--nx-X11/programs/Xserver/Xprint/ps/ttf2pt1wrap.c14
-rw-r--r--nx-X11/programs/Xserver/Xprint/raster/Imakefile28
-rw-r--r--nx-X11/programs/Xserver/Xprint/raster/Raster.c1580
-rw-r--r--nx-X11/programs/Xserver/Xprint/raster/Raster.h118
-rw-r--r--nx-X11/programs/Xserver/Xprint/raster/RasterAttVal.c269
-rw-r--r--nx-X11/programs/Xserver/Xprint/spooler.c204
-rw-r--r--nx-X11/programs/Xserver/Xprint/spooler.h76
-rw-r--r--nx-X11/programs/Xserver/Xprint/svg/README1
-rw-r--r--nx-X11/programs/Xserver/Xprint/windows/README1
-rw-r--r--nx-X11/programs/Xserver/Xserver.man790
-rw-r--r--nx-X11/programs/Xserver/Xvfb.def4
-rw-r--r--nx-X11/programs/Xserver/afb/Imakefile67
-rw-r--r--nx-X11/programs/Xserver/afb/README10
-rw-r--r--nx-X11/programs/Xserver/afb/Xdaniver.doc218
-rw-r--r--nx-X11/programs/Xserver/afb/afb.h1132
-rw-r--r--nx-X11/programs/Xserver/afb/afbbitblt.c477
-rw-r--r--nx-X11/programs/Xserver/afb/afbblt.c563
-rw-r--r--nx-X11/programs/Xserver/afb/afbbres.c325
-rw-r--r--nx-X11/programs/Xserver/afb/afbbresd.c216
-rw-r--r--nx-X11/programs/Xserver/afb/afbbstore.c156
-rw-r--r--nx-X11/programs/Xserver/afb/afbclip.c248
-rw-r--r--nx-X11/programs/Xserver/afb/afbcmap.c125
-rw-r--r--nx-X11/programs/Xserver/afb/afbfillarc.c359
-rw-r--r--nx-X11/programs/Xserver/afb/afbfillrct.c294
-rw-r--r--nx-X11/programs/Xserver/afb/afbfillsp.c1131
-rw-r--r--nx-X11/programs/Xserver/afb/afbfont.c79
-rw-r--r--nx-X11/programs/Xserver/afb/afbgc.c711
-rw-r--r--nx-X11/programs/Xserver/afb/afbgetsp.c167
-rw-r--r--nx-X11/programs/Xserver/afb/afbhrzvert.c211
-rw-r--r--nx-X11/programs/Xserver/afb/afbimage.c301
-rw-r--r--nx-X11/programs/Xserver/afb/afbimggblt.c474
-rw-r--r--nx-X11/programs/Xserver/afb/afbline.c706
-rw-r--r--nx-X11/programs/Xserver/afb/afbmisc.c96
-rw-r--r--nx-X11/programs/Xserver/afb/afbmodule.c63
-rw-r--r--nx-X11/programs/Xserver/afb/afbpixmap.c300
-rw-r--r--nx-X11/programs/Xserver/afb/afbply1rct.c300
-rw-r--r--nx-X11/programs/Xserver/afb/afbplygblt.c465
-rw-r--r--nx-X11/programs/Xserver/afb/afbpntarea.c657
-rw-r--r--nx-X11/programs/Xserver/afb/afbpntwin.c128
-rw-r--r--nx-X11/programs/Xserver/afb/afbpolypnt.c148
-rw-r--r--nx-X11/programs/Xserver/afb/afbpushpxl.c259
-rw-r--r--nx-X11/programs/Xserver/afb/afbscrinit.c248
-rw-r--r--nx-X11/programs/Xserver/afb/afbsetsp.c269
-rw-r--r--nx-X11/programs/Xserver/afb/afbtegblt.c588
-rw-r--r--nx-X11/programs/Xserver/afb/afbtile.c859
-rw-r--r--nx-X11/programs/Xserver/afb/afbwindow.c318
-rw-r--r--nx-X11/programs/Xserver/afb/afbzerarc.c210
-rw-r--r--nx-X11/programs/Xserver/cfb/Imakefile6
-rw-r--r--nx-X11/programs/Xserver/cfb/Imakefile.inc303
-rw-r--r--nx-X11/programs/Xserver/cfb/cfb.h1327
-rw-r--r--nx-X11/programs/Xserver/cfb/cfb16.h94
-rw-r--r--nx-X11/programs/Xserver/cfb/cfb24.h98
-rw-r--r--nx-X11/programs/Xserver/cfb/cfb32.h94
-rw-r--r--nx-X11/programs/Xserver/cfb/cfb8bit.c471
-rw-r--r--nx-X11/programs/Xserver/cfb/cfb8bit.h1572
-rw-r--r--nx-X11/programs/Xserver/cfb/cfb8line.c1504
-rw-r--r--nx-X11/programs/Xserver/cfb/cfballpriv.c94
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbbitblt.c1454
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbblt.c933
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbbres.c342
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbbresd.c406
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbbstore.c145
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbcmap.c121
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbcppl.c490
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbfillarc.c374
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbfillrct.c307
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbfillsp.c1006
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbgc.c811
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbgetsp.c215
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbglblt8.c479
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbhrzvert.c556
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbigblt8.c108
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbimage.c206
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbline.c757
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbmap.h344
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbmodule.c65
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbmskbits.c1402
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbmskbits.h897
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbpixmap.c376
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbply1rct.c363
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbpntwin.c771
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbpolypnt.c204
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbpush8.c186
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbrctstp8.c595
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbrrop.c229
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbrrop.h343
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbscrinit.c232
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbsetsp.c318
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbsolid.c1367
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbtab.h16
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbteblt8.c591
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbtegblt.c220
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbtile32.c519
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbtileodd.c1247
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbunmap.h165
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbwindow.c337
-rw-r--r--nx-X11/programs/Xserver/cfb/cfbzerarc.c322
-rw-r--r--nx-X11/programs/Xserver/cfb/module/Imakefile11
-rw-r--r--nx-X11/programs/Xserver/cfb/stip68kgnu.h123
-rw-r--r--nx-X11/programs/Xserver/cfb/stipmips.s281
-rw-r--r--nx-X11/programs/Xserver/cfb/stipple68k.s231
-rw-r--r--nx-X11/programs/Xserver/cfb/stipsparc.s290
-rw-r--r--nx-X11/programs/Xserver/cfb/stipsprc32.s291
-rw-r--r--nx-X11/programs/Xserver/cfb16/Imakefile10
-rw-r--r--nx-X11/programs/Xserver/cfb16/cfbmodule.c65
-rw-r--r--nx-X11/programs/Xserver/cfb16/module/Imakefile12
-rw-r--r--nx-X11/programs/Xserver/cfb24/Imakefile6
-rw-r--r--nx-X11/programs/Xserver/cfb24/cfbmodule.c65
-rw-r--r--nx-X11/programs/Xserver/cfb24/cfbrrop24.h54
-rw-r--r--nx-X11/programs/Xserver/cfb24/module/Imakefile12
-rw-r--r--nx-X11/programs/Xserver/cfb32/Imakefile10
-rw-r--r--nx-X11/programs/Xserver/cfb32/cfbmodule.c65
-rw-r--r--nx-X11/programs/Xserver/cfb32/module/Imakefile12
-rw-r--r--nx-X11/programs/Xserver/composite/Imakefile18
-rw-r--r--nx-X11/programs/Xserver/composite/compalloc.c553
-rw-r--r--nx-X11/programs/Xserver/composite/compext.c409
-rw-r--r--nx-X11/programs/Xserver/composite/compinit.c390
-rw-r--r--nx-X11/programs/Xserver/composite/compint.h260
-rw-r--r--nx-X11/programs/Xserver/composite/compwindow.c755
-rw-r--r--nx-X11/programs/Xserver/damageext/Imakefile17
-rwxr-xr-xnx-X11/programs/Xserver/damageext/damageext.c481
-rw-r--r--nx-X11/programs/Xserver/damageext/damageext.h35
-rw-r--r--nx-X11/programs/Xserver/damageext/damageextint.h88
-rw-r--r--nx-X11/programs/Xserver/dbe/Imakefile36
-rw-r--r--nx-X11/programs/Xserver/dbe/dbe.c1999
-rw-r--r--nx-X11/programs/Xserver/dbe/dbemodule.c48
-rw-r--r--nx-X11/programs/Xserver/dbe/dbestruct.h237
-rw-r--r--nx-X11/programs/Xserver/dbe/midbe.c855
-rw-r--r--nx-X11/programs/Xserver/dbe/midbe.h51
-rw-r--r--nx-X11/programs/Xserver/dbe/midbestr.h100
-rw-r--r--nx-X11/programs/Xserver/dbe/module/Imakefile34
-rw-r--r--nx-X11/programs/Xserver/dix/BuiltInAtoms329
-rw-r--r--nx-X11/programs/Xserver/dix/CHANGES17
-rw-r--r--nx-X11/programs/Xserver/dix/Imakefile101
-rw-r--r--nx-X11/programs/Xserver/dix/atom.c213
-rw-r--r--nx-X11/programs/Xserver/dix/buildatoms43
-rw-r--r--nx-X11/programs/Xserver/dix/colormap.c2793
-rw-r--r--nx-X11/programs/Xserver/dix/cursor.c459
-rw-r--r--nx-X11/programs/Xserver/dix/devices.c1665
-rw-r--r--nx-X11/programs/Xserver/dix/dispatch.c4035
-rw-r--r--nx-X11/programs/Xserver/dix/dispatch.h147
-rw-r--r--nx-X11/programs/Xserver/dix/dixfonts.c2208
-rw-r--r--nx-X11/programs/Xserver/dix/dixfonts.c.NX.original2208
-rw-r--r--nx-X11/programs/Xserver/dix/dixfonts.c.X.original2143
-rw-r--r--nx-X11/programs/Xserver/dix/dixutils.c962
-rw-r--r--nx-X11/programs/Xserver/dix/events.c4670
-rw-r--r--nx-X11/programs/Xserver/dix/extension.c474
-rw-r--r--nx-X11/programs/Xserver/dix/ffs.c37
-rw-r--r--nx-X11/programs/Xserver/dix/gc.c1288
-rw-r--r--nx-X11/programs/Xserver/dix/globals.c163
-rw-r--r--nx-X11/programs/Xserver/dix/glyphcurs.c194
-rw-r--r--nx-X11/programs/Xserver/dix/grabs.c438
-rw-r--r--nx-X11/programs/Xserver/dix/initatoms.c84
-rw-r--r--nx-X11/programs/Xserver/dix/main.c800
-rw-r--r--nx-X11/programs/Xserver/dix/pixmap.c152
-rw-r--r--nx-X11/programs/Xserver/dix/pixmap.c.NX.original152
-rw-r--r--nx-X11/programs/Xserver/dix/pixmap.c.X.original145
-rw-r--r--nx-X11/programs/Xserver/dix/privates.c401
-rw-r--r--nx-X11/programs/Xserver/dix/property.c729
-rw-r--r--nx-X11/programs/Xserver/dix/resource.c954
-rw-r--r--nx-X11/programs/Xserver/dix/swaprep.c1309
-rw-r--r--nx-X11/programs/Xserver/dix/swapreq.c1104
-rw-r--r--nx-X11/programs/Xserver/dix/tables.c529
-rw-r--r--nx-X11/programs/Xserver/dix/window.c3853
-rw-r--r--nx-X11/programs/Xserver/dix/xpstubs.c77
-rw-r--r--nx-X11/programs/Xserver/fb/Imakefile194
-rw-r--r--nx-X11/programs/Xserver/fb/Imakefile.NX.original194
-rw-r--r--nx-X11/programs/Xserver/fb/Imakefile.X.original188
-rw-r--r--nx-X11/programs/Xserver/fb/fb.h2054
-rw-r--r--nx-X11/programs/Xserver/fb/fb24_32.c627
-rw-r--r--nx-X11/programs/Xserver/fb/fb24_32.h53
-rw-r--r--nx-X11/programs/Xserver/fb/fballpriv.c93
-rw-r--r--nx-X11/programs/Xserver/fb/fbarc.c122
-rw-r--r--nx-X11/programs/Xserver/fb/fbbits.c179
-rw-r--r--nx-X11/programs/Xserver/fb/fbbits.h964
-rw-r--r--nx-X11/programs/Xserver/fb/fbblt.c933
-rw-r--r--nx-X11/programs/Xserver/fb/fbbltone.c880
-rw-r--r--nx-X11/programs/Xserver/fb/fbbstore.c66
-rw-r--r--nx-X11/programs/Xserver/fb/fbcmap.c672
-rw-r--r--nx-X11/programs/Xserver/fb/fbcompose.c3627
-rw-r--r--nx-X11/programs/Xserver/fb/fbcopy.c663
-rw-r--r--nx-X11/programs/Xserver/fb/fbedge.c314
-rw-r--r--nx-X11/programs/Xserver/fb/fbedgeimp.h143
-rw-r--r--nx-X11/programs/Xserver/fb/fbfill.c222
-rw-r--r--nx-X11/programs/Xserver/fb/fbfillrect.c115
-rw-r--r--nx-X11/programs/Xserver/fb/fbfillsp.c103
-rw-r--r--nx-X11/programs/Xserver/fb/fbgc.c317
-rw-r--r--nx-X11/programs/Xserver/fb/fbgetsp.c88
-rw-r--r--nx-X11/programs/Xserver/fb/fbglyph.c479
-rw-r--r--nx-X11/programs/Xserver/fb/fbimage.c368
-rw-r--r--nx-X11/programs/Xserver/fb/fbline.c177
-rw-r--r--nx-X11/programs/Xserver/fb/fbmmx.c2276
-rw-r--r--nx-X11/programs/Xserver/fb/fbmmx.h220
-rw-r--r--nx-X11/programs/Xserver/fb/fbmodule.c53
-rw-r--r--nx-X11/programs/Xserver/fb/fboverlay.c457
-rw-r--r--nx-X11/programs/Xserver/fb/fboverlay.h129
-rw-r--r--nx-X11/programs/Xserver/fb/fbpict.c1456
-rw-r--r--nx-X11/programs/Xserver/fb/fbpict.h612
-rw-r--r--nx-X11/programs/Xserver/fb/fbpixmap.c389
-rw-r--r--nx-X11/programs/Xserver/fb/fbpoint.c164
-rw-r--r--nx-X11/programs/Xserver/fb/fbpseudocolor.c2335
-rw-r--r--nx-X11/programs/Xserver/fb/fbpseudocolor.h20
-rw-r--r--nx-X11/programs/Xserver/fb/fbpush.c247
-rw-r--r--nx-X11/programs/Xserver/fb/fbrop.h139
-rw-r--r--nx-X11/programs/Xserver/fb/fbscreen.c301
-rw-r--r--nx-X11/programs/Xserver/fb/fbseg.c727
-rw-r--r--nx-X11/programs/Xserver/fb/fbsetsp.c104
-rw-r--r--nx-X11/programs/Xserver/fb/fbsolid.c215
-rw-r--r--nx-X11/programs/Xserver/fb/fbstipple.c316
-rw-r--r--nx-X11/programs/Xserver/fb/fbtile.c204
-rw-r--r--nx-X11/programs/Xserver/fb/fbtrap.c239
-rw-r--r--nx-X11/programs/Xserver/fb/fbutil.c365
-rw-r--r--nx-X11/programs/Xserver/fb/fbwindow.c352
-rw-r--r--nx-X11/programs/Xserver/fb/module/Imakefile6
-rw-r--r--nx-X11/programs/Xserver/hw/Imakefile26
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/Imakefile92
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/XDarwin.man205
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/Credits.rtf168
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/Imakefile36
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/Localizable.stringsbin0 -> 1426 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/classes.nib72
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/objects.nibbin0 -> 22024 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp103
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/Credits.rtf168
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/Imakefile34
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/InfoPlist.strings.cpp5
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/Localizable.strings23
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/MainMenu.nib/classes.nib72
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/MainMenu.nib/objects.nibbin0 -> 20829 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp96
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/Credits.rtf166
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/Imakefile36
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/Localizable.stringsbin0 -> 1492 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/MainMenu.nib/classes.nib72
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/MainMenu.nib/objects.nibbin0 -> 21114 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/XDarwinHelp.html.cpp101
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/Credits.rtf168
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/Imakefile36
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/Localizable.stringsbin0 -> 1458 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/MainMenu.nib/classes.nib72
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/MainMenu.nib/objects.nibbin0 -> 21182 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/XDarwinHelp.html.cpp96
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Imakefile15
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/Credits.rtf193
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/Imakefile36
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/Localizable.stringsbin0 -> 1152 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/classes.nib72
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/objects.nibbin0 -> 21854 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/XDarwinHelp.html.cpp141
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/Credits.rtf171
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/Imakefile36
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/Localizable.stringsbin0 -> 1504 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/classes.nib72
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/objects.nibbin0 -> 21112 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/XDarwinHelp.html.cpp211
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/Credits.rtf168
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/Imakefile36
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/Localizable.stringsbin0 -> 1480 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/classes.nib72
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/objects.nibbin0 -> 20952 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/XDarwinHelp.html.cpp111
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/Credits.rtf168
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/Imakefile36
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/Localizable.stringsbin0 -> 1464 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/classes.nib72
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/objects.nibbin0 -> 20858 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/XDarwinHelp.html.cpp103
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/XDarwin.icnsbin0 -> 69465 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/Credits.rtf168
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/Imakefile36
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/Localizable.stringsbin0 -> 1332 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/MainMenu.nib/classes.nib72
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/MainMenu.nib/objects.nibbin0 -> 21433 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/XDarwinHelp.html.cpp96
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/bundle/startXClients.cpp24
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/darwin.c1108
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/darwin.h153
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/darwinClut8.h532
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/darwinEvents.c481
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/darwinKeyboard.c1027
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/darwinKeyboard.h52
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/darwinXinput.c310
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/iokit/Imakefile25
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKit.c772
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKit.h57
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKitCursor.c735
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKitStartup.c126
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/Imakefile113
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/Preferences.h138
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/Preferences.m597
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/XApplication.h47
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/XApplication.m47
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj2519
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/XDarwinStartup.c164
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/XDarwinStartup.man75
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/XServer.h138
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/XServer.m1539
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/applewm.c722
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/applewmExt.h85
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/cr/Imakefile35
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/cr/XView.h42
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/cr/XView.m74
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/cr/cr.h62
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/cr/crAppleWM.m157
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/cr/crFrame.m439
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/cr/crScreen.m381
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/Imakefile19
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/fullscreen.c569
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/quartzCursor.c653
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/quartzCursor.h44
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/keysym2ucs.c909
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/keysym2ucs.h37
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/pseudoramiX.c430
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/pseudoramiX.h10
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/quartz.c426
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/quartz.h131
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/quartzAudio.c342
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/quartzAudio.h41
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/quartzCocoa.m205
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/quartzCommon.h108
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/quartzCursor.c653
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/quartzCursor.h43
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/quartzKeyboard.c388
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/quartzPasteboard.c150
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/quartzPasteboard.h45
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/quartzStartup.c291
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/Imakefile35
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/Xplugin.h591
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/appledri.c350
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dri.c757
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dri.h129
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dristruct.h82
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hash.c341
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hash.h62
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hook.c106
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hook.h44
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-list.c335
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-list.h79
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xpr.h49
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprAppleWM.c99
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprCursor.c420
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c495
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c417
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/utils/Imakefile10
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/utils/README.txt111
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/utils/dumpkeymap.c1454
-rw-r--r--nx-X11/programs/Xserver/hw/darwin/utils/dumpkeymap.man1004
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/Imakefile125
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/Xdmx.man741
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/Canvas.c160
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/Canvas.h56
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/CanvasP.h66
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/Imakefile101
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/TODO7
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/dmxcompat.c237
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/dmxcompat.h45
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/dmxconfig.c499
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/dmxconfig.h65
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/dmxparse.c611
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/dmxparse.h298
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/dmxprint.c456
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/dmxprint.h44
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/dmxtodmx.c50
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/dmxtodmx.man41
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/parser.y226
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/scanner.l183
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-a.in1
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-a.out2
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-b.in1
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-b.out1
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-c.in1
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-c.out2
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-d.in1
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-d.out2
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-e.in1
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-e.out2
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-f.in2
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-f.outbin0 -> 69 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-g.in4
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-g.out4
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-h.in7
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-h.out7
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-i.in3
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-i.out3
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-j.in13
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-j.out11
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-k.in3
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-k.out3
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-l.in12
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/test-l.out12
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/vdltodmx.c58
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/vdltodmx.man95
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/xdmxconfig.c1192
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/config/xdmxconfig.man63
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmx.h374
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmx_glxvisuals.c606
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmx_glxvisuals.h64
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxcb.c224
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxcb.h54
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxclient.h152
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxcmap.c220
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxcmap.h71
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxcursor.c926
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxcursor.h70
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxdpms.c213
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxdpms.h43
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxextension.c1497
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxextension.h119
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxfont.c559
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxfont.h60
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxgc.c424
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxgc.h90
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxgcops.c602
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxgcops.h96
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxinit.c1062
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxinit.h51
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxinput.c105
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxinput.h163
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxlog.c351
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxlog.h79
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxpict.c1298
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxpict.h133
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxpixmap.c252
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxpixmap.h67
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxprop.c348
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxprop.h47
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxscrinit.c566
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxscrinit.h52
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxshadow.c72
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxshadow.h47
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxstat.c223
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxstat.h56
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxsync.c194
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxsync.h44
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxvisual.c141
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxvisual.h48
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxwindow.c1085
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/dmxwindow.h149
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/DMXSpec-v1.txt458
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/DMXSpec.txt875
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/Imakefile10
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/Makefile.linux42
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/dmx.sgml2778
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/dmx.txt2989
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/doxygen.conf1090
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/doxygen.css49
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/doxygen.foot12
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/doxygen.head8
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/ChkNotMaskEv_8c.html76
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/ChkNotMaskEv_8h-source.html60
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/ChkNotMaskEv_8h.html77
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/annotated.html98
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/classes.html26
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmx_8h-source.html276
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmx_8h.html532
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmx__glxvisuals_8h-source.html85
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxarg_8c.html239
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxarg_8h-source.html69
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxarg_8h.html235
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxbackend_8c.html427
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxbackend_8h-source.html75
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxbackend_8h.html411
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcb_8c.html184
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcb_8h-source.html70
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcb_8h.html209
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxclient_8h-source.html168
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxclient_8h.html48
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcmap_8c.html265
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcmap_8h-source.html86
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcmap_8h.html408
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcommon_8c.html701
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcommon_8h-source.html151
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcommon_8h.html665
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcompat_8c.html68
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcompat_8h-source.html61
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcompat_8h.html62
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconfig_8c.html402
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconfig_8h-source.html84
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconfig_8h.html248
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconsole_8c.html498
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconsole_8h-source.html79
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconsole_8h.html488
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcursor_8c.html471
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcursor_8h-source.html86
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcursor_8h.html498
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdetach_8c.html70
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdpms_8c.html128
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdpms_8h-source.html62
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdpms_8h.html124
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdummy_8c.html111
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdummy_8h-source.html63
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdummy_8h.html111
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxeq_8c.html269
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxeq_8h-source.html61
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxeq_8h.html63
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxevents_8c.html284
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxevents_8h-source.html66
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxevents_8h.html233
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxext_8h-source.html197
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxext_8h.html926
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxextension_8c.html433
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxextension_8h-source.html131
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxextension_8h.html426
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxfont_8c.html257
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxfont_8h-source.html78
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxfont_8h.html333
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgc_8c.html456
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgc_8h-source.html106
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgc_8h.html561
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgcops_8c.html1476
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgcops_8h-source.html115
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgcops_8h.html1469
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinit_8c.html709
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinit_8h-source.html70
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinit_8h.html30
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinput_8c.html185
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinput_8h-source.html146
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinput_8h.html534
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinputinit_8c.html477
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinputinit_8h-source.html259
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinputinit_8h.html406
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxlog_8c.html602
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxlog_8h-source.html91
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxlog_8h.html616
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmap_8c.html150
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmap_8h-source.html62
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmap_8h.html148
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmotion_8c.html181
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmotion_8h-source.html69
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmotion_8h.html180
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxparse_8c.html74
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxparse_8h-source.html303
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxparse_8h.html775
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpict_8c.html1184
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpict_8h-source.html141
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpict_8h.html1418
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpixmap_8c.html240
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpixmap_8h-source.html83
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpixmap_8h.html351
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprint_8c.html119
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprint_8h-source.html63
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprint_8h.html111
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprop_8c.html235
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprop_8h-source.html66
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprop_8h.html136
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxproto_8h-source.html431
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxproto_8h.html89
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxscrinit_8c.html378
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxscrinit_8h-source.html70
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxscrinit_8h.html181
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxshadow_8c.html71
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxshadow_8h-source.html66
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxshadow_8h.html73
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsigio_8c.html230
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsigio_8h-source.html65
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsigio_8h.html226
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxstat_8c.html274
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxstat_8h-source.html74
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxstat_8h.html364
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsync_8c.html139
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsync_8h-source.html63
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsync_8h.html136
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxvisual_8c.html151
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxvisual_8h-source.html67
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxvisual_8h.html152
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxwindow_8c.html865
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxwindow_8h-source.html165
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxwindow_8h.html969
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/dmxxinput_8c.html396
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/doxygen.css49
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/doxygen.pngbin0 -> 2352 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/files.html120
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2blank.pngbin0 -> 174 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2doc.pngbin0 -> 255 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2folderclosed.pngbin0 -> 259 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2folderopen.pngbin0 -> 261 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2lastnode.pngbin0 -> 233 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2link.pngbin0 -> 358 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2mlastnode.pngbin0 -> 160 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2mnode.pngbin0 -> 194 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2node.pngbin0 -> 235 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2plastnode.pngbin0 -> 165 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2pnode.pngbin0 -> 200 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2vertline.pngbin0 -> 229 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/functions.html237
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/functions_vars.html237
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/globals.html522
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/globals_defs.html47
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/globals_enum.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/globals_eval.html41
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/globals_func.html388
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/globals_type.html96
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/globals_vars.html56
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/index.html8
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/lib_2dmx_2dmx_8c.html894
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-keyboard_8c.html511
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-keyboard_8h-source.html83
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-keyboard_8h.html388
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ms_8c.html352
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ms_8h-source.html75
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ms_8h.html288
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ps2_8c.html352
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ps2_8h-source.html75
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ps2_8h.html288
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/main.html26
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/programs_2Xserver_2Xext_2dmx_8c.html71
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXConfigCmdStruct.html30
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXConfigListStruct.html30
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXDesktopAttributes.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXDesktopAttributesRec.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXInputAttributes.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXInputAttributesRec.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXScreenAttributes.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXScreenAttributesRec.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXWindowAttributes.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXWindowAttributesRec.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigComment.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigDisplay.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigEntry.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigFullDim.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigNumber.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigOption.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigPair.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigParam.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigPartDim.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigString.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigSub.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigToken.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigVirtual.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigWall.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXEventMap.html82
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXInputInfo.html490
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXLocalInitInfo.html778
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXLocalInputInfo.html996
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXScreenInfo.html1330
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXStatAvg.html30
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXStatInfo.html30
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__Event.html104
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__EventQueue.html224
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxArg.html104
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxColormapPriv.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxCursorPriv.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxFontPriv.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxGCPriv.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxGlyphPriv.html58
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxPictPriv.html82
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxPixPriv.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxWinPriv.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/struct__myPrivate.html272
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structdmxGlxVisualPrivate.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddInputReply.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddInputReq.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddScreenReply.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddScreenReq.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeDesktopAttributesReply.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeDesktopAttributesReq.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeScreensAttributesReply.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeScreensAttributesReq.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXForceWindowCreationReply.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXForceWindowCreationReq.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetDesktopAttributesReply.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetDesktopAttributesReq.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputAttributesReply.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputAttributesReq.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputCountReply.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputCountReq.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenAttributesReply.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenAttributesReq.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenCountReply.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenCountReq.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetWindowAttributesReply.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetWindowAttributesReq.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXQueryVersionReply.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXQueryVersionReq.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveInputReply.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveInputReq.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveScreenReply.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveScreenReq.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXSyncReply.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXSyncReq.html32
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/tree.html295
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/usb-common_8c.html222
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/usb-common_8h-source.html74
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/usb-common_8h.html167
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/usb-keyboard_8c.html231
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/usb-keyboard_8h-source.html68
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/usb-keyboard_8h.html174
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/usb-mouse_8c.html190
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/usb-mouse_8h-source.html68
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/usb-mouse_8h.html134
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/usb-other_8c.html191
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/usb-other_8h-source.html68
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/usb-other_8h.html134
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/usb-private_8h-source.html131
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/html/usb-private_8h.html41
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/scaled.sgml707
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/doc/scaled.txt579
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/examples/Imakefile56
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/examples/dmxaddinput.c84
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/examples/dmxaddscreen.c106
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/examples/dmxreconfig.c163
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/examples/dmxresize.c105
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/examples/dmxrminput.c79
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/examples/dmxrmscreen.c81
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/examples/dmxwininfo.c497
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/examples/ev.c183
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/examples/evi.c87
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/examples/res.c100
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/examples/xbell.c102
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/examples/xdmx.c240
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/examples/xinput.c319
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/examples/xled.c125
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/examples/xtest.c76
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/Imakefile52
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/compsize.c564
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/g_disptab.c612
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/g_disptab.h676
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/g_renderswap.c2360
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/global.c77
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxcmds.c3636
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxcmdsswap.c1059
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxcontext.h117
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxdrawable.h124
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxerror.h58
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxext.c512
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxext.h98
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxfbconfig.c111
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxfbconfig.h43
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxscreens.c390
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxscreens.h63
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxserver.h327
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxsingle.c1013
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxsingle.h59
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxswap.c539
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxswap.h47
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxutil.c121
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxutil.h54
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvendor.c583
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvendor.h55
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvisuals.c542
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvisuals.h55
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/render2swap.c348
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/renderpixswap.c390
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/glxProxy/unpack.h234
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/ChkNotMaskEv.c108
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/ChkNotMaskEv.h41
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/Imakefile46
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxarg.c176
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxarg.h50
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxbackend.c608
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxbackend.h57
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxcommon.c674
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxcommon.h133
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxconsole.c1023
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxconsole.h60
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxdetach.c59
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxdummy.c87
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxdummy.h44
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxeq.c309
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxeq.h44
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxevents.c716
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxevents.h47
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxinputinit.c1298
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxinputinit.h294
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxmap.c122
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxmap.h43
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxmotion.c144
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxmotion.h50
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxsigio.c234
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxsigio.h46
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/dmxxinput.c156
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/lnx-keyboard.c975
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/lnx-keyboard.h64
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/lnx-ms.c323
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/lnx-ms.h56
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/lnx-ps2.c291
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/lnx-ps2.h56
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/usb-common.c383
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/usb-common.h56
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/usb-keyboard.c442
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/usb-keyboard.h49
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/usb-mouse.c127
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/usb-mouse.h49
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/usb-other.c162
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/usb-other.h49
-rw-r--r--nx-X11/programs/Xserver/hw/dmx/input/usb-private.h118
-rw-r--r--nx-X11/programs/Xserver/hw/kdrive/README7
-rw-r--r--nx-X11/programs/Xserver/hw/sun/Imakefile90
-rw-r--r--nx-X11/programs/Xserver/hw/sun/README118
-rw-r--r--nx-X11/programs/Xserver/hw/sun/Xsun.man176
-rw-r--r--nx-X11/programs/Xserver/hw/sun/circleset.h136
-rw-r--r--nx-X11/programs/Xserver/hw/sun/constype.c216
-rw-r--r--nx-X11/programs/Xserver/hw/sun/constype.man80
-rw-r--r--nx-X11/programs/Xserver/hw/sun/kbd_mode.c155
-rw-r--r--nx-X11/programs/Xserver/hw/sun/kbd_mode.man53
-rw-r--r--nx-X11/programs/Xserver/hw/sun/sun.h446
-rw-r--r--nx-X11/programs/Xserver/hw/sun/sunCfb.c517
-rw-r--r--nx-X11/programs/Xserver/hw/sun/sunCfb24.c139
-rw-r--r--nx-X11/programs/Xserver/hw/sun/sunCursor.c281
-rw-r--r--nx-X11/programs/Xserver/hw/sun/sunFbs.c259
-rw-r--r--nx-X11/programs/Xserver/hw/sun/sunGX.c2906
-rw-r--r--nx-X11/programs/Xserver/hw/sun/sunGX.h238
-rw-r--r--nx-X11/programs/Xserver/hw/sun/sunInit.c960
-rw-r--r--nx-X11/programs/Xserver/hw/sun/sunIo.c305
-rw-r--r--nx-X11/programs/Xserver/hw/sun/sunKbd.c1071
-rw-r--r--nx-X11/programs/Xserver/hw/sun/sunKeyMap.c5797
-rw-r--r--nx-X11/programs/Xserver/hw/sun/sunMfb.c108
-rw-r--r--nx-X11/programs/Xserver/hw/sun/sunMouse.c399
-rw-r--r--nx-X11/programs/Xserver/hw/sun/sunMultiDepth.c277
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/Imakefile78
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/btreg.h81
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/btvar.h74
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/cgsixreg.h206
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/fbio.h186
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/patch.Console428
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/patch.Console-2.4.0493
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/sun.h486
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/sunLyCfb.c372
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/sunLyFbs.c292
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/sunLyInit.c648
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/sunLyIo.c389
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/sunLyKbd.c1080
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/sunLyMouse.c649
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/sunLyUtil.c509
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/vuid_event.h88
-rw-r--r--nx-X11/programs/Xserver/hw/vfb/Imakefile71
-rw-r--r--nx-X11/programs/Xserver/hw/vfb/InitInput.c344
-rw-r--r--nx-X11/programs/Xserver/hw/vfb/InitOutput.c1046
-rw-r--r--nx-X11/programs/Xserver/hw/vfb/Xvfb.man132
-rw-r--r--nx-X11/programs/Xserver/hw/vfb/lk201kbd.h159
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/Imakefile275
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/atKeynames.h298
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/compiler.h1863
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/fourcc.h161
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/modeline2c.pl110
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/scoasm.h143
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86.h447
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86AutoConfig.c368
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Bus.c3317
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Bus.h162
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Config.c2740
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Config.h63
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Configure.c1049
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Cursor.c788
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86DGA.c1267
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86DPMS.c222
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Debug.c197
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86DefModes.c160
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86DoProbe.c129
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86DoScanPci.c130
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Events.c1865
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Globals.c254
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Helper.c2983
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86InPriv.h48
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Init.c2035
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Io.c507
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Kbd.c395
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c1266
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86KbdLnx.c651
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86KbdMach.c317
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Keymap.h455
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86MiscExt.c656
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Mode.c2185
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Module.h226
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Opt.h114
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Option.c884
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86PM.c225
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86PciInfo.h726
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Priv.h228
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Privstr.h234
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86RandR.c438
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Resources.h140
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Versions.c81
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86VidMode.c722
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86XKB.c82
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Xinput.c1513
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86Xinput.h220
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86cmap.c1123
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86cmap.h76
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86fbBus.c97
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86fbman.c1445
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86fbman.h227
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86isaBus.c142
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86noBus.c75
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86pciBus.c3506
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86pciBus.h99
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86sbusBus.c709
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86sbusBus.h98
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86str.h1140
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86xv.c2050
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86xv.h271
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86xvmc.c243
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86xvmc.h164
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xf86xvpriv.h86
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xisb.c180
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xisb.h64
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/common/xorgHelper.c24
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/Imakefile130
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/README.OS-lib506
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/assyntax.h753
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile242
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/alpha_video.c735
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/arm_video.c690
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c194
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_KbdMap.c1087
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_VTsw.c96
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_apm.c141
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_axp.c73
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_ev56.c91
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c738
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c294
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_jstk.c189
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kbd.c573
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kbd.h5
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kmod.c31
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c203
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_mouse.c792
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile63
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/i386_video.c999
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/Imakefile10
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/data.c95
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/descr.c76
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/parse.c404
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usage.c199
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb.3191
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb.h95
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb_hid_usages1079
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usbvar.h34
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/memrange.h72
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/ppc_video.c141
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/sparc64_video.c113
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile46
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_init.c156
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_io.c110
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_mouse.c34
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_video.c182
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/460gxPCI.c470
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/460gxPCI.h42
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Imakefile165
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Pci.c1453
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Pci.h449
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Sbus.c637
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/altixPCI.c120
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/altixPCI.h20
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/axpPci.c478
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/e8870PCI.c64
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/e8870PCI.h42
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c171
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/ix86Pci.c704
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/linuxPci.c894
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/netbsdPci.c132
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/ppcPci.c311
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c1052
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h807
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/xf86Sbus.h70
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/zx1PCI.c1133
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/bus/zx1PCI.h40
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile35
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/bios_DGmmap.c70
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_init.c182
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_io.c96
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_kbd.c120
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_kbdEv.c47
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_tty.c175
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c441
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile40
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/bios_mmap.c95
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_init.c90
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_io.c139
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_mouse.c300
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_video.c181
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/int10Defines.h90
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/Imakefile142
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile64
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/drm/drmmodule.c60
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile77
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c649
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/vm86/Imakefile55
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c302
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/x86emu/Imakefile86
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx.h55
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c291
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_KbdMap.c606
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_acpi.c170
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c371
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c192
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_axp.c200
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_ev56.c151
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_font.c291
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_ia64.c74
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c415
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c275
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_jstk.c188
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c559
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.h5
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_kmod.c113
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_mouse.c206
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_pci.c230
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c1169
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile62
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_init.c193
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_io.c166
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_mmap.c73
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_mouse.c34
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_noinline.c178
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_ppc.S70
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_ppc.c52
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c711
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/misc/BUSmemcpy.S153
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/misc/BUSmemcpy.c413
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/misc/Delay.c44
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/misc/IODelay.S53
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/misc/IODelay.c28
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/misc/Imakefile54
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/misc/PortIO.S57
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/misc/SlowBcopy.S108
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/misc/SlowBcopy.c114
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/misc/xf86_IlHack.c19
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/misc/xf86_Util.c96
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/nto/Imakefile37
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/nto/README29
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_init.c104
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_io.c118
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_ioperm.c48
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_kbdEv.c53
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_mouse.c210
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_video.c170
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/Imakefile45
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/README78
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/int10/Imakefile110
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c452
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_VTsw.c340
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_bios.c143
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_diag.c263
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_init.c244
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_io.c257
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_ioperm.c140
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_kbd.c158
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_kbdEv.c511
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_mouse.c653
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_select.c497
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_select.h62
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_serial.c517
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_stubs.c403
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c241
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile48
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_devs.c126
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_init.c473
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c239
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_mouse.c60
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_pci.c1072
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_ppc.c251
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile37
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_VTsw.c116
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_init.c175
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_io.c110
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_kbd.c104
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_mouse.c267
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_select.c75
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_utils.c30
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_video.c183
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sco/Imakefile56
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sco/VTsw_sco.c119
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_KbdMap.c304
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_init.c296
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_io.c269
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_iop.c136
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_kbd.c530
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_kbd.h20
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_mouse.c261
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_video.c296
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/VTsw_noop.c56
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c92
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/agp_noop.c107
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/at_scancode.c132
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c77
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/bios_mmap.c164
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/ia64Pci.c244
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/ia64Pci.h46
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/inout.S111
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/ioperm_noop.c51
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/kbd.c39
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/kmod_noop.c39
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c2153
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/pm_noop.c48
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c689
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/sigio.c312
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/sigiostubs.c86
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/stdPci.c52
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/stdResource.c182
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c50
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/sysv_kbd.c106
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c300
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.c50
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.h36
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile119
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/agpgart.h109
-rwxr-xr-xnx-X11/programs/Xserver/hw/xfree86/os-support/sunos/find_deps.pl150
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-amd64.S73
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-ia32.S73
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-sparcv8plus.S144
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_agp.c339
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_bios.c104
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c393
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_inout.s124
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c160
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c662
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.h72
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c892
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c719
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c237
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile58
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_init.c254
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_io.c78
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_mouse.c64
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c369
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/xqueue.c543
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/xqueue.h12
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/usl/Imakefile40
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_KbdMap.c304
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_init.c359
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_io.c172
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_iop.c108
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_kbd.c456
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_kbd.h14
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_mouse.c181
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_video.c111
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_vtsw.c97
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_xqueue.c360
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_xqueue.h9
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/xf86OSKbd.h133
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h295
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h57
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h759
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h277
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h354
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_libc.h726
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/Configint.h226
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/DRI.c187
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/Device.c403
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/Extensions.c111
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/Files.c295
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/Flags.c525
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/Imakefile51
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/Input.c215
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/Keyboard.c306
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/Layout.c513
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/Module.c261
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/Monitor.c907
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/Pointer.c236
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/Screen.c578
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/Vendor.c258
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/Video.c297
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/configProcs.h132
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/cpconfig.c123
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/read.c321
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/scan.c949
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/write.c220
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/xf86Optrec.h113
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/xf86Parser.h483
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/parser/xf86tokens.h280
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/xf86Date.h38
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/xf86Version.h62
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Args.c197
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Args.h40
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Color.c497
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Color.h58
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Cursor.c159
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Display.c195
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Display.h46
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Drawable.h28
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Events.c226
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Events.h31
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Font.c91
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/GC.c340
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/GCOps.c329
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/GCOps.h70
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/GetTime.c51
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Handlers.c47
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Handlers.h24
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Imakefile90
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Init.c164
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Init.h21
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Keyboard.c339
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Keyboard.h30
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Pixmap.c141
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Pointer.c79
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Pointer.h31
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Screen.c458
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Screen.h27
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/TestExt.c69
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Visual.c72
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Visual.h27
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Window.c558
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/XNCursor.h35
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/XNFont.h37
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/XNGC.h44
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/XNPixmap.h45
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/XNWindow.h80
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Xnest.h96
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/Xnest.man264
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/icon14
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/os2Stub.c388
-rw-r--r--nx-X11/programs/Xserver/hw/xnest/screensaver686
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/ChangeLog663
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/Imakefile310
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/InitInput.c204
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/InitOutput.c1172
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/README141
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/X-boxed.icobin0 -> 12902 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/X.icobin0 -> 20870 bytes
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/XWin.man287
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/XWin.rc110
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/XWinrc.man180
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/_usr_X11R6_lib_X11_system.XWinrc125
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/ddraw.h2108
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/win.h1466
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winallpriv.c185
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winauth.c132
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winblock.c106
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winclip.c42
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winclipboard.h164
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winclipboardinit.c143
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winclipboardtextconv.c159
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winclipboardthread.c477
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winclipboardunicode.c69
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winclipboardwndproc.c585
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winclipboardwrappers.c544
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winclipboardxevents.c796
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/wincmap.c675
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winconfig.c1185
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winconfig.h345
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/wincreatewnd.c642
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/wincursor.c615
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/windialogs.c788
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winengine.c336
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winerror.c143
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winfillsp.c876
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winfont.c80
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/wingc.c259
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/wingetsp.c193
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winglobals.c138
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winkeybd.c650
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winkeybd.h310
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winkeyhook.c194
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winkeymap.h138
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winkeynames.h204
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winlayouts.h257
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winmessages.h1030
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winmisc.c152
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winmouse.c341
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winms.h46
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winmsg.c180
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winmsg.h52
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winmultiwindowclass.c326
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winmultiwindowclass.h116
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winmultiwindowicons.c478
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winmultiwindowshape.c212
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winmultiwindowwindow.c1056
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winmultiwindowwm.c1444
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winmultiwindowwndproc.c1035
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winnativegdi.c547
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winpfbdd.c685
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winpixmap.c242
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winpntwin.c47
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winpolyline.c57
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winprefs.c799
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winprefs.h163
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winprefslex.l116
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winprefsyacc.y353
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winpriv.c134
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winpriv.h15
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winprocarg.c1561
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winpushpxl.c226
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winrandr.c141
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winregistry.c71
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winresource.h56
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winrop.c145
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winscrinit.c794
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winsetsp.c196
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winshaddd.c1443
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winshadddnl.c1455
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winshadgdi.c1323
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/wintrayicon.c211
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winvalargs.c188
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winvideo.c210
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winwakeup.c72
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winwin32rootless.c1092
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winwin32rootlesswindow.c476
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winwin32rootlesswndproc.c1324
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winwindow.c650
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winwindow.h151
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/winwindowswm.c666
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/winwndproc.c1273
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/COPYING25
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/Makefile79
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/xlaunch/config.cc282
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/xlaunch/config.h60
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/main.cc700
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/resources/dialog.rc118
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/resources/fullscreen.bmpbin0 -> 22554 bytes
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/resources/images.rc29
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/resources/multiwindow.bmpbin0 -> 22554 bytes
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/resources/nodecoration.bmpbin0 -> 22554 bytes
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/resources/resources.h99
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/resources/resources.rc30
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/strings.rc108
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/resources/windowed.bmpbin0 -> 22554 bytes
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/window/dialog.cc86
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/window/dialog.h54
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/xlaunch/window/util.cc1112
-rw-r--r--nx-X11/programs/Xserver/hw/xwin/xlaunch/window/util.h53
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/window/window.cc284
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/window/window.h114
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/window/wizard.cc244
-rwxr-xr-xnx-X11/programs/Xserver/hw/xwin/xlaunch/window/wizard.h59
-rw-r--r--nx-X11/programs/Xserver/ilbm/Imakefile63
-rw-r--r--nx-X11/programs/Xserver/ilbm/README17
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbm.h1051
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmbitblt.c483
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmblt.c573
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmbres.c328
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmbresd.c219
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmbstore.c159
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmclip.c246
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmcmap.c128
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmfillarc.c377
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmfillrct.c299
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmfillsp.c1149
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmfont.c82
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmgc.c715
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmgetsp.c170
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmhrzvert.c213
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmimage.c441
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmimggblt.c474
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmline.c705
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmmisc.c99
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmpixmap.c295
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmply1rct.c303
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmplygblt.c469
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmpntarea.c656
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmpntwin.c131
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmpolypnt.c152
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmpushpxl.c263
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmscrinit.c251
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmsetsp.c269
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmtegblt.c599
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmtile.c857
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmwindow.c323
-rw-r--r--nx-X11/programs/Xserver/ilbm/ilbmzerarc.c214
-rw-r--r--nx-X11/programs/Xserver/include/Imakefile67
-rw-r--r--nx-X11/programs/Xserver/include/XIstubs.h76
-rw-r--r--nx-X11/programs/Xserver/include/bstore.h23
-rw-r--r--nx-X11/programs/Xserver/include/bstorestr.h58
-rw-r--r--nx-X11/programs/Xserver/include/closestr.h159
-rw-r--r--nx-X11/programs/Xserver/include/closure.h58
-rw-r--r--nx-X11/programs/Xserver/include/colormap.h184
-rw-r--r--nx-X11/programs/Xserver/include/colormapst.h121
-rw-r--r--nx-X11/programs/Xserver/include/cursor.h149
-rw-r--r--nx-X11/programs/Xserver/include/cursorstr.h98
-rw-r--r--nx-X11/programs/Xserver/include/dix.h817
-rw-r--r--nx-X11/programs/Xserver/include/dixevents.h106
-rw-r--r--nx-X11/programs/Xserver/include/dixfont.h155
-rw-r--r--nx-X11/programs/Xserver/include/dixfontstr.h95
-rw-r--r--nx-X11/programs/Xserver/include/dixgrabs.h59
-rw-r--r--nx-X11/programs/Xserver/include/dixstruct.h236
-rw-r--r--nx-X11/programs/Xserver/include/dixstruct.h.NX.original236
-rw-r--r--nx-X11/programs/Xserver/include/dixstruct.h.X.original233
-rw-r--r--nx-X11/programs/Xserver/include/exevents.h183
-rw-r--r--nx-X11/programs/Xserver/include/extension.h67
-rw-r--r--nx-X11/programs/Xserver/include/extinit.h166
-rw-r--r--nx-X11/programs/Xserver/include/extnsionst.h152
-rw-r--r--nx-X11/programs/Xserver/include/gc.h178
-rw-r--r--nx-X11/programs/Xserver/include/gcstruct.h328
-rw-r--r--nx-X11/programs/Xserver/include/globals.h192
-rw-r--r--nx-X11/programs/Xserver/include/input.h391
-rw-r--r--nx-X11/programs/Xserver/include/inputstr.h314
-rw-r--r--nx-X11/programs/Xserver/include/misc.h269
-rw-r--r--nx-X11/programs/Xserver/include/miscstruct.h80
-rw-r--r--nx-X11/programs/Xserver/include/opaque.h83
-rw-r--r--nx-X11/programs/Xserver/include/os.h546
-rw-r--r--nx-X11/programs/Xserver/include/pixmap.h110
-rw-r--r--nx-X11/programs/Xserver/include/pixmapstr.h88
-rw-r--r--nx-X11/programs/Xserver/include/property.h74
-rw-r--r--nx-X11/programs/Xserver/include/propertyst.h76
-rw-r--r--nx-X11/programs/Xserver/include/region.h54
-rw-r--r--nx-X11/programs/Xserver/include/regionstr.h412
-rw-r--r--nx-X11/programs/Xserver/include/resource.h274
-rw-r--r--nx-X11/programs/Xserver/include/rgb.h54
-rw-r--r--nx-X11/programs/Xserver/include/screenint.h113
-rw-r--r--nx-X11/programs/Xserver/include/scrnintstr.h733
-rw-r--r--nx-X11/programs/Xserver/include/selection.h69
-rw-r--r--nx-X11/programs/Xserver/include/servermd.h583
-rw-r--r--nx-X11/programs/Xserver/include/site.h139
-rw-r--r--nx-X11/programs/Xserver/include/swaprep.h322
-rw-r--r--nx-X11/programs/Xserver/include/swapreq.h120
-rw-r--r--nx-X11/programs/Xserver/include/validate.h42
-rw-r--r--nx-X11/programs/Xserver/include/window.h265
-rw-r--r--nx-X11/programs/Xserver/include/windowstr.h234
-rw-r--r--nx-X11/programs/Xserver/iplan2p2/Imakefile6
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/Imakefile119
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/ipl.h1254
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplallpriv.c93
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplbitblt.c388
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplblt.c431
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplbres.c186
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplbresd.c212
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplbstore.c159
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplcmap.c126
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplfillarc.c271
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplfillrct.c281
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplfillsp.c384
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplgc.c786
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplgetsp.c166
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplhrzvert.c128
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplimage.c87
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplline.c758
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplmap.h176
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplmergerop.h146
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplmskbits.c108
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplmskbits.h500
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplpack.c316
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplpack.h10
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplpixmap.c386
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplply1rct.c310
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplpntwin.c341
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplpolypnt.c123
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplrrop.c219
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplrrop.h80
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplscrinit.c233
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplsetsp.c304
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplsolid.c221
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/ipltegblt.c221
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/ipltile32.c272
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/ipltileodd.c869
-rw-r--r--nx-X11/programs/Xserver/iplan2p4/iplwindow.c343
-rw-r--r--nx-X11/programs/Xserver/iplan2p8/Imakefile6
-rw-r--r--nx-X11/programs/Xserver/lbx/Imakefile56
-rw-r--r--nx-X11/programs/Xserver/lbx/lbxcmap.c1156
-rw-r--r--nx-X11/programs/Xserver/lbx/lbxdata.h48
-rw-r--r--nx-X11/programs/Xserver/lbx/lbxdix.c869
-rw-r--r--nx-X11/programs/Xserver/lbx/lbxexts.c275
-rw-r--r--nx-X11/programs/Xserver/lbx/lbxgfx.c854
-rw-r--r--nx-X11/programs/Xserver/lbx/lbxmain.c1760
-rw-r--r--nx-X11/programs/Xserver/lbx/lbxopts.c806
-rw-r--r--nx-X11/programs/Xserver/lbx/lbxprop.c549
-rw-r--r--nx-X11/programs/Xserver/lbx/lbxserve.h289
-rw-r--r--nx-X11/programs/Xserver/lbx/lbxsquish.c158
-rw-r--r--nx-X11/programs/Xserver/lbx/lbxsrvopts.h67
-rw-r--r--nx-X11/programs/Xserver/lbx/lbxswap.c828
-rw-r--r--nx-X11/programs/Xserver/lbx/lbxtables.c39
-rw-r--r--nx-X11/programs/Xserver/lbx/lbxtags.c237
-rw-r--r--nx-X11/programs/Xserver/lbx/lbxtags.h86
-rw-r--r--nx-X11/programs/Xserver/lbx/lbxzerorep.c420
-rw-r--r--nx-X11/programs/Xserver/mfb/Imakefile168
-rw-r--r--nx-X11/programs/Xserver/mfb/fastblt.h98
-rw-r--r--nx-X11/programs/Xserver/mfb/maskbits.c1061
-rw-r--r--nx-X11/programs/Xserver/mfb/maskbits.h691
-rw-r--r--nx-X11/programs/Xserver/mfb/mergerop.h400
-rw-r--r--nx-X11/programs/Xserver/mfb/mfb.h1158
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbbitblt.c510
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbblt.c589
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbbres.c370
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbbresd.c209
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbbstore.c155
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbclip.c280
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbcmap.c164
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbfillarc.c333
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbfillrct.c228
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbfillsp.c1028
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbfont.c88
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbgc.c1151
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbgetsp.c159
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbhrzvert.c179
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbimage.c177
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbimggblt.c445
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbline.c757
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbmisc.c100
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbmodule.c52
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbpixmap.c298
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbply1rct.c261
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbplygblt.c399
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbpntarea.c300
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbpntwin.c127
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbpolypnt.c145
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbpushpxl.c287
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbscrclse.c66
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbscrinit.c210
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbsetsp.c283
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbtegblt.c368
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbtile.c240
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbwindow.c341
-rw-r--r--nx-X11/programs/Xserver/mfb/mfbzerarc.c258
-rw-r--r--nx-X11/programs/Xserver/mfb/module/Imakefile6
-rw-r--r--nx-X11/programs/Xserver/mi/Imakefile128
-rw-r--r--nx-X11/programs/Xserver/mi/Imakefile.NX.original128
-rw-r--r--nx-X11/programs/Xserver/mi/Imakefile.X.original94
-rw-r--r--nx-X11/programs/Xserver/mi/cbrt.c48
-rw-r--r--nx-X11/programs/Xserver/mi/mi.h645
-rw-r--r--nx-X11/programs/Xserver/mi/miarc.c3723
-rw-r--r--nx-X11/programs/Xserver/mi/mibank.c2577
-rw-r--r--nx-X11/programs/Xserver/mi/mibank.h119
-rw-r--r--nx-X11/programs/Xserver/mi/mibitblt.c845
-rw-r--r--nx-X11/programs/Xserver/mi/mibstore.c3905
-rw-r--r--nx-X11/programs/Xserver/mi/mibstore.h30
-rw-r--r--nx-X11/programs/Xserver/mi/mibstorest.h93
-rw-r--r--nx-X11/programs/Xserver/mi/miclipn.c84
-rw-r--r--nx-X11/programs/Xserver/mi/micmap.c697
-rw-r--r--nx-X11/programs/Xserver/mi/micmap.h65
-rw-r--r--nx-X11/programs/Xserver/mi/micoord.h71
-rw-r--r--nx-X11/programs/Xserver/mi/micursor.c77
-rw-r--r--nx-X11/programs/Xserver/mi/midash.c315
-rw-r--r--nx-X11/programs/Xserver/mi/midispcur.c816
-rw-r--r--nx-X11/programs/Xserver/mi/mieq.c192
-rw-r--r--nx-X11/programs/Xserver/mi/miexpose.c905
-rw-r--r--nx-X11/programs/Xserver/mi/mifillarc.c817
-rw-r--r--nx-X11/programs/Xserver/mi/mifillarc.h216
-rw-r--r--nx-X11/programs/Xserver/mi/mifillrct.c144
-rw-r--r--nx-X11/programs/Xserver/mi/mifpoly.h111
-rw-r--r--nx-X11/programs/Xserver/mi/mifpolycon.c284
-rw-r--r--nx-X11/programs/Xserver/mi/migc.c301
-rw-r--r--nx-X11/programs/Xserver/mi/migc.h74
-rw-r--r--nx-X11/programs/Xserver/mi/miglblt.c255
-rw-r--r--nx-X11/programs/Xserver/mi/miinitext.c799
-rw-r--r--nx-X11/programs/Xserver/mi/miline.h174
-rw-r--r--nx-X11/programs/Xserver/mi/mioverlay.c2079
-rw-r--r--nx-X11/programs/Xserver/mi/mioverlay.h33
-rw-r--r--nx-X11/programs/Xserver/mi/mipointer.c544
-rw-r--r--nx-X11/programs/Xserver/mi/mipointer.h162
-rw-r--r--nx-X11/programs/Xserver/mi/mipointrst.h64
-rw-r--r--nx-X11/programs/Xserver/mi/mipoly.c129
-rw-r--r--nx-X11/programs/Xserver/mi/mipoly.h217
-rw-r--r--nx-X11/programs/Xserver/mi/mipolycon.c248
-rw-r--r--nx-X11/programs/Xserver/mi/mipolygen.c232
-rw-r--r--nx-X11/programs/Xserver/mi/mipolypnt.c125
-rw-r--r--nx-X11/programs/Xserver/mi/mipolyrect.c193
-rw-r--r--nx-X11/programs/Xserver/mi/mipolyseg.c85
-rw-r--r--nx-X11/programs/Xserver/mi/mipolytext.c202
-rw-r--r--nx-X11/programs/Xserver/mi/mipolyutil.c401
-rw-r--r--nx-X11/programs/Xserver/mi/mipushpxl.c261
-rw-r--r--nx-X11/programs/Xserver/mi/miregion.c2563
-rw-r--r--nx-X11/programs/Xserver/mi/miscanfill.h148
-rw-r--r--nx-X11/programs/Xserver/mi/miscrinit.c372
-rw-r--r--nx-X11/programs/Xserver/mi/mispans.c563
-rw-r--r--nx-X11/programs/Xserver/mi/mispans.h117
-rw-r--r--nx-X11/programs/Xserver/mi/misprite.c831
-rw-r--r--nx-X11/programs/Xserver/mi/misprite.h96
-rw-r--r--nx-X11/programs/Xserver/mi/mispritest.h134
-rw-r--r--nx-X11/programs/Xserver/mi/mistruct.h65
-rw-r--r--nx-X11/programs/Xserver/mi/mivalidate.h55
-rw-r--r--nx-X11/programs/Xserver/mi/mivaltree.c826
-rw-r--r--nx-X11/programs/Xserver/mi/miwideline.c2242
-rw-r--r--nx-X11/programs/Xserver/mi/miwideline.h224
-rw-r--r--nx-X11/programs/Xserver/mi/miwindow.c1184
-rw-r--r--nx-X11/programs/Xserver/mi/mizerarc.c855
-rw-r--r--nx-X11/programs/Xserver/mi/mizerarc.h134
-rw-r--r--nx-X11/programs/Xserver/mi/mizerclip.c636
-rw-r--r--nx-X11/programs/Xserver/mi/mizerline.c380
-rwxr-xr-xnx-X11/programs/Xserver/miext/cw/Imakefile22
-rw-r--r--nx-X11/programs/Xserver/miext/cw/cw.c699
-rw-r--r--nx-X11/programs/Xserver/miext/cw/cw.h174
-rw-r--r--nx-X11/programs/Xserver/miext/cw/cw_ops.c470
-rw-r--r--nx-X11/programs/Xserver/miext/cw/cw_render.c501
-rwxr-xr-xnx-X11/programs/Xserver/miext/damage/Imakefile26
-rwxr-xr-xnx-X11/programs/Xserver/miext/damage/damage.c1966
-rwxr-xr-xnx-X11/programs/Xserver/miext/damage/damage.h84
-rwxr-xr-xnx-X11/programs/Xserver/miext/damage/damagestr.h113
-rw-r--r--nx-X11/programs/Xserver/miext/layer/Imakefile49
-rw-r--r--nx-X11/programs/Xserver/miext/layer/layer.h149
-rw-r--r--nx-X11/programs/Xserver/miext/layer/layergc.c194
-rw-r--r--nx-X11/programs/Xserver/miext/layer/layerinit.c363
-rw-r--r--nx-X11/programs/Xserver/miext/layer/layerpict.c149
-rw-r--r--nx-X11/programs/Xserver/miext/layer/layerstr.h425
-rw-r--r--nx-X11/programs/Xserver/miext/layer/layerwin.c487
-rw-r--r--nx-X11/programs/Xserver/miext/layer/laymodule.c60
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/Imakefile54
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/Imakefile.NX.original54
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/Imakefile.X.original54
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/README.txt403
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/accel/Imakefile30
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/accel/rlAccel.c155
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/accel/rlAccel.h141
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/accel/rlBlt.c370
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/accel/rlCopy.c107
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/accel/rlFill.c221
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/accel/rlFillRect.c118
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/accel/rlFillSpans.c106
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/accel/rlGlyph.c170
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/accel/rlSolid.c112
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/rootless.h436
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/rootlessCommon.c405
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/rootlessCommon.h261
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/rootlessConfig.h68
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/rootlessGC.c1508
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/rootlessScreen.c670
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/rootlessValTree.c648
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/rootlessWindow.c1468
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/rootlessWindow.h64
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/safeAlpha/Imakefile18
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/safeAlpha/safeAlpha.h45
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/safeAlpha/safeAlphaPicture.c643
-rw-r--r--nx-X11/programs/Xserver/miext/rootless/safeAlpha/safeAlphaWindow.c175
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/Imakefile66
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shadow.c1544
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shadow.h179
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shalloc.c52
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shmodule.c60
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shpacked.c114
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shplanar.c179
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shplanar8.c174
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shrot16pack.c32
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shrot16pack_180.c33
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shrot16pack_270.c33
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shrot16pack_90.c33
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shrot32pack.c32
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shrot32pack_180.c33
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shrot32pack_270.c33
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shrot32pack_90.c33
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shrot8pack.c32
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shrot8pack_180.c33
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shrot8pack_270.c33
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shrot8pack_90.c33
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shrotate.c314
-rw-r--r--nx-X11/programs/Xserver/miext/shadow/shrotpack.h186
-rw-r--r--nx-X11/programs/Xserver/os/Imakefile235
-rw-r--r--nx-X11/programs/Xserver/os/Imakefile.NX.original235
-rw-r--r--nx-X11/programs/Xserver/os/Imakefile.X.original200
-rw-r--r--nx-X11/programs/Xserver/os/WaitFor.c882
-rw-r--r--nx-X11/programs/Xserver/os/WaitFor.c.NX.original882
-rw-r--r--nx-X11/programs/Xserver/os/WaitFor.c.X.original701
-rw-r--r--nx-X11/programs/Xserver/os/access.c2429
-rw-r--r--nx-X11/programs/Xserver/os/auth.c608
-rw-r--r--nx-X11/programs/Xserver/os/auth.c.NX.original608
-rw-r--r--nx-X11/programs/Xserver/os/auth.c.X.original400
-rw-r--r--nx-X11/programs/Xserver/os/connection.c1424
-rw-r--r--nx-X11/programs/Xserver/os/connection.c.NX.original1424
-rw-r--r--nx-X11/programs/Xserver/os/connection.c.X.original1385
-rw-r--r--nx-X11/programs/Xserver/os/io.c1347
-rw-r--r--nx-X11/programs/Xserver/os/k5auth.c801
-rw-r--r--nx-X11/programs/Xserver/os/lbxio.c555
-rw-r--r--nx-X11/programs/Xserver/os/log.c716
-rw-r--r--nx-X11/programs/Xserver/os/log.c.NX.original716
-rw-r--r--nx-X11/programs/Xserver/os/log.c.X.original633
-rw-r--r--nx-X11/programs/Xserver/os/mitauth.c199
-rw-r--r--nx-X11/programs/Xserver/os/oscolor.c483
-rw-r--r--nx-X11/programs/Xserver/os/oscolor.c.NX.original483
-rw-r--r--nx-X11/programs/Xserver/os/oscolor.c.X.original303
-rw-r--r--nx-X11/programs/Xserver/os/osdep.h358
-rw-r--r--nx-X11/programs/Xserver/os/osinit.c246
-rw-r--r--nx-X11/programs/Xserver/os/rpcauth.c204
-rw-r--r--nx-X11/programs/Xserver/os/secauth.c205
-rw-r--r--nx-X11/programs/Xserver/os/utils.c2427
-rw-r--r--nx-X11/programs/Xserver/os/utils.c.NX.original2427
-rw-r--r--nx-X11/programs/Xserver/os/utils.c.X.original2296
-rw-r--r--nx-X11/programs/Xserver/os/xalloc.c817
-rw-r--r--nx-X11/programs/Xserver/os/xdmauth.c502
-rw-r--r--nx-X11/programs/Xserver/os/xdmcp.c1710
-rw-r--r--nx-X11/programs/Xserver/os/xdmcp.c.NX.original1710
-rw-r--r--nx-X11/programs/Xserver/os/xdmcp.c.X.original1681
-rw-r--r--nx-X11/programs/Xserver/os/xprintf.c104
-rw-r--r--nx-X11/programs/Xserver/randr/Imakefile18
-rw-r--r--nx-X11/programs/Xserver/randr/mirandr.c102
-rw-r--r--nx-X11/programs/Xserver/randr/randr.c1319
-rw-r--r--nx-X11/programs/Xserver/randr/randrstr.h142
-rw-r--r--nx-X11/programs/Xserver/record/Imakefile33
-rw-r--r--nx-X11/programs/Xserver/record/module/Imakefile34
-rw-r--r--nx-X11/programs/Xserver/record/record.c3053
-rw-r--r--nx-X11/programs/Xserver/record/recordmod.c46
-rw-r--r--nx-X11/programs/Xserver/record/set.c710
-rw-r--r--nx-X11/programs/Xserver/record/set.h150
-rw-r--r--nx-X11/programs/Xserver/render/Imakefile46
-rw-r--r--nx-X11/programs/Xserver/render/animcur.c402
-rw-r--r--nx-X11/programs/Xserver/render/filter.c303
-rw-r--r--nx-X11/programs/Xserver/render/glyph.c478
-rw-r--r--nx-X11/programs/Xserver/render/glyphstr.h148
-rw-r--r--nx-X11/programs/Xserver/render/miglyph.c243
-rw-r--r--nx-X11/programs/Xserver/render/miindex.c357
-rw-r--r--nx-X11/programs/Xserver/render/mipict.c629
-rw-r--r--nx-X11/programs/Xserver/render/mipict.h213
-rw-r--r--nx-X11/programs/Xserver/render/mirect.c186
-rw-r--r--nx-X11/programs/Xserver/render/mitrap.c190
-rw-r--r--nx-X11/programs/Xserver/render/mitri.c192
-rw-r--r--nx-X11/programs/Xserver/render/picture.c1864
-rw-r--r--nx-X11/programs/Xserver/render/picture.h238
-rw-r--r--nx-X11/programs/Xserver/render/picturestr.h654
-rw-r--r--nx-X11/programs/Xserver/render/render.c3306
-rw-r--r--nx-X11/programs/Xserver/render/renderedge.c201
-rw-r--r--nx-X11/programs/Xserver/render/renderedge.h120
-rwxr-xr-xnx-X11/programs/Xserver/xfixes/Imakefile17
-rwxr-xr-xnx-X11/programs/Xserver/xfixes/cursor.c754
-rwxr-xr-xnx-X11/programs/Xserver/xfixes/cursor.c.NX.original754
-rwxr-xr-xnx-X11/programs/Xserver/xfixes/cursor.c.X.original753
-rwxr-xr-xnx-X11/programs/Xserver/xfixes/region.c864
-rwxr-xr-xnx-X11/programs/Xserver/xfixes/saveset.c79
-rwxr-xr-xnx-X11/programs/Xserver/xfixes/select.c281
-rwxr-xr-xnx-X11/programs/Xserver/xfixes/select.c.NX.original281
-rwxr-xr-xnx-X11/programs/Xserver/xfixes/select.c.X.original279
-rwxr-xr-xnx-X11/programs/Xserver/xfixes/xfixes.c231
-rwxr-xr-xnx-X11/programs/Xserver/xfixes/xfixes.h54
-rwxr-xr-xnx-X11/programs/Xserver/xfixes/xfixesint.h243
-rw-r--r--nx-X11/programs/Xserver/xkb/Imakefile106
-rw-r--r--nx-X11/programs/Xserver/xkb/Imakefile.NX.original106
-rw-r--r--nx-X11/programs/Xserver/xkb/Imakefile.X.original102
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxBeep.c370
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxConfig.c215
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxCtrls.c131
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxDevBtn.c102
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxFakeBtn.c61
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxFakeMtn.c122
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxInit.c48
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxKeyClick.c52
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxKillSrv.c61
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxLEDs.c74
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxList.c304
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxLoad.c965
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxLoad.c.NX.original965
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxLoad.c.X.original604
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxPrivate.c46
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxVT.c72
-rw-r--r--nx-X11/programs/Xserver/xkb/xkb.c6233
-rw-r--r--nx-X11/programs/Xserver/xkb/xkb.h72
-rw-r--r--nx-X11/programs/Xserver/xkb/xkbAccessX.c754
-rw-r--r--nx-X11/programs/Xserver/xkb/xkbActions.c1432
-rw-r--r--nx-X11/programs/Xserver/xkb/xkbDflts.h524
-rw-r--r--nx-X11/programs/Xserver/xkb/xkbDflts.h.NX.original524
-rw-r--r--nx-X11/programs/Xserver/xkb/xkbDflts.h.X.original513
-rw-r--r--nx-X11/programs/Xserver/xkb/xkbEvents.c1057
-rw-r--r--nx-X11/programs/Xserver/xkb/xkbInit.c1037
-rw-r--r--nx-X11/programs/Xserver/xkb/xkbLEDs.c1067
-rw-r--r--nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c188
-rw-r--r--nx-X11/programs/Xserver/xkb/xkbPrOtherEv.c84
-rw-r--r--nx-X11/programs/Xserver/xkb/xkbSwap.c597
-rw-r--r--nx-X11/programs/Xserver/xkb/xkbUtils.c987
2234 files changed, 753904 insertions, 0 deletions
diff --git a/nx-X11/programs/Xserver/GL/Imakefile b/nx-X11/programs/Xserver/GL/Imakefile
new file mode 100644
index 000000000..47134e0a1
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/Imakefile
@@ -0,0 +1,66 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/Imakefile,v 1.12 2003/08/06 14:04:01 eich Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#define IHaveSubdirs
+
+#if GlxUseSGISI
+ CORE_SUBDIR = /* opengl */
+#elif defined(DarwinArchitecture) && DarwinQuartzSupport
+ CORE_SUBDIR = apple mesa
+#elif defined(cygwinArchitecture) && GlxUseWindows
+ CORE_SUBDIR = windows mesa
+#elif defined(Win32Architecture) && GlxUseWindows
+ CORE_SUBDIR = windows
+#else
+ CORE_SUBDIR = mesa
+#endif
+
+#if BuildXF86DRI && ((defined(XF86Server) && XF86Server) \
+ || (defined(XorgServer) && XorgServer))
+DRI_SUBDIR = dri
+#endif
+
+SUBDIRS = glx $(DRI_SUBDIR) $(CORE_SUBDIR)
+
+#if DoLoadableServer
+MSRCS = glxmodule.c
+MOBJS = glxmodule.o
+#endif
+
+#if BuildModuleInSubdir
+SRCS = glx/module/?*.c $(MSRCS)
+OBJS = glx/module/?*.o $(MOBJS)
+#else
+SRCS = glx/?*.c $(MSRCS)
+OBJS = glx/?*.o $(MOBJS)
+#endif
+
+DONES = glx/DONE
+
+INCLUDES = -Iinclude -Idri -I$(SERVERSRC)/include -I$(SERVERSRC)/mi \
+ -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(XF86OSSRC)
+DEPEND_DEFINES = $(EXT_DEFINES) DependDefines
+DEFINES = $(GLX_DEFINES)
+
+#if HasParallelMake
+MakeMutex($(SUBDIRS) $(OBJS) $(DONES))
+#endif
+
+#if HasGnuMake || HasBsdMake
+$(DONES): $(SUBDIRS)
+#endif
+
+ModuleObjectRule()
+
+DepLibraryModuleTarget(glx,$(SUBDIRS) $(DONES) $(MOBJS),$(OBJS))
+
+InstallLibraryModule(glx,$(MODULEDIR),extensions)
+ForceSubdirs($(SUBDIRS))
+
+DependSubdirs($(SUBDIRS))
+MakeLintLibSubdirs($(SUBDIRS))
+LintSubdirs($(SUBDIRS))
+
+InstallDriverSDKLibraryModule(glx,$(DRIVERSDKMODULEDIR),extensions)
diff --git a/nx-X11/programs/Xserver/GL/apple/Imakefile b/nx-X11/programs/Xserver/GL/apple/Imakefile
new file mode 100644
index 000000000..36b780c73
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/apple/Imakefile
@@ -0,0 +1,49 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/apple/Imakefile,v 1.2 2003/09/16 00:36:11 torrey Exp $
+
+#include <Server.tmpl>
+
+ XPRDIR = $(SERVERSRC)/hw/darwin/quartz/xpr
+
+LinkSourceFile(x-list.c,$(XPRDIR))
+LinkSourceFile(x-list.h,$(XPRDIR))
+LinkSourceFile(x-hash.c,$(XPRDIR))
+LinkSourceFile(x-hash.h,$(XPRDIR))
+LinkSourceFile(compsize.c,$(MESASRCDIR)/src/glx/x11)
+
+ BASE_SRCS = compsize.c
+ BASE_OBJS = compsize.o
+
+ AGL_SRCS = aglGlx.c
+ AGL_OBJS = aglGlx.o
+
+#if HasXplugin
+ GL_SRCS = indirect.c x-hash.c x-list.c
+ GL_OBJS = indirect.o x-hash.o x-list.o
+
+ AS = /System/Library/Frameworks/ApplicationServices.framework
+
+ GL_INCLUDES = -I$(LIBSRC)/GL/apple -I$(XPRDIR) -I$(XPINCDIR) \
+ -F$(AS)/Frameworks
+#endif
+
+ SRCS = $(BASE_SRCS) $(AGL_SRCS) $(GL_SRCS)
+ OBJS = $(BASE_OBJS) $(AGL_OBJS) $(GL_OBJS)
+
+ INCLUDES = -I. -I$(INCLUDESRC) -I$(XINCLUDESRC) -I$(EXTINCSRC) \
+ -I$(LIBSRC)/GL/glx -I$(LIBSRC)/GL/include \
+ -I$(SERVERSRC)/mi -I$(SERVERSRC)/include -I$(FONTINCSRC) \
+ -I$(SERVERSRC)/render -I$(SERVERSRC)/GL/include \
+ -I$(SERVERSRC)/GL/glx -I$(SERVERSRC)/hw/darwin/quartz/cr \
+ -I$(SERVERSRC)/hw/darwin/quartz $(GL_INCLUDES) \
+ -I$(MESASRCDIR)/include -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(XF86OSSRC)
+
+ DEFINES = $(GLX_DEFINES)
+
+NormalLibraryTarget(AGLcore,$(AGL_OBJS) $(BASE_OBJS))
+#if HasXplugin
+NormalLibraryTarget(CGLcore,$(GL_OBJS) $(BASE_OBJS))
+#endif
+NormalLibraryObjectRule()
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/GL/apple/aglGlx.c b/nx-X11/programs/Xserver/GL/apple/aglGlx.c
new file mode 100644
index 000000000..be846be83
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/apple/aglGlx.c
@@ -0,0 +1,1355 @@
+/*
+ * GLX implementation that uses Apple's AGL.framework for OpenGL
+ *
+ * FIXME: This file and indirect.c are very similar. The two should be
+ * merged by introducing suitable abstractions.
+ */
+/*
+ * Copyright (c) 2002 Greg Parker. All Rights Reserved.
+ * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Large portions of this file are copied from Mesa's xf86glx.c,
+ * which contains the following copyright:
+ *
+ * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/GL/apple/aglGlx.c,v 1.2 2003/09/16 00:36:11 torrey Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "quartzCommon.h"
+#include <AGL/agl.h>
+#include "cr.h"
+
+// X11 and X11's glx
+#undef BOOL
+#define BOOL xBOOL
+#include "quartz.h"
+#include <miscstruct.h>
+#include <windowstr.h>
+#include <resource.h>
+#include <GL/glxint.h>
+#include <GL/glxtokens.h>
+#include <scrnintstr.h>
+#include <glxserver.h>
+#include <glxscreens.h>
+#include <glxdrawable.h>
+#include <glxcontext.h>
+#include <glxext.h>
+#include <glxutil.h>
+#include <glxscreens.h>
+#include <GL/internal/glcore.h>
+#undef BOOL
+
+#include "glcontextmodes.h"
+
+// ggs: needed to call back to glx with visual configs
+extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs);
+
+// Write debugging output, or not
+#ifdef GLAQUA_DEBUG
+#define GLAQUA_DEBUG_MSG ErrorF
+#else
+#define GLAQUA_DEBUG_MSG(a, ...)
+#endif
+
+
+// The following GL functions don't have an EXT suffix in OpenGL.framework.
+GLboolean glAreTexturesResidentEXT (GLsizei a, const GLuint *b, GLboolean *c) {
+ return glAreTexturesResident(a, b, c);
+}
+void glDeleteTexturesEXT (GLsizei d, const GLuint *e) {
+ glDeleteTextures(d, e);
+}
+void glGenTexturesEXT (GLsizei f, GLuint *g) {
+ glGenTextures(f, g);
+}
+GLboolean glIsTextureEXT (GLuint h) {
+ return glIsTexture(h);
+}
+
+
+// some prototypes
+static Bool glAquaScreenProbe(int screen);
+static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
+ int *nvisualp, int *ndepthp,
+ int *rootDepthp, VisualID *defaultVisp,
+ unsigned long sizes, int bitsPerRGB);
+static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
+ void **privates);
+static __GLinterface *glAquaCreateContext(__GLimports *imports,
+ __GLcontextModes *mode,
+ __GLinterface *shareGC);
+static void glAquaCreateBuffer(__GLXdrawablePrivate *glxPriv);
+static void glAquaResetExtension(void);
+
+
+/*
+ * This structure is statically allocated in the __glXScreens[]
+ * structure. This struct is not used anywhere other than in
+ * __glXScreenInit to initialize each of the active screens
+ * (__glXActiveScreens[]). Several of the fields must be initialized by
+ * the screenProbe routine before they are copied to the active screens
+ * struct. In particular, the contextCreate, modes, numVisuals,
+ * and numUsableVisuals fields must be initialized.
+ */
+static __GLXscreenInfo __glDDXScreenInfo = {
+ glAquaScreenProbe, /* Must be generic and handle all screens */
+ glAquaCreateContext, /* Substitute screen's createContext routine */
+ glAquaCreateBuffer, /* Substitute screen's createBuffer routine */
+ NULL, /* Set up modes in probe */
+ NULL, /* Set up pVisualPriv in probe */
+ 0, /* Set up numVisuals in probe */
+ 0, /* Set up numUsableVisuals in probe */
+ "Vendor String", /* GLXvendor is overwritten by __glXScreenInit */
+ "Version String", /* GLXversion is overwritten by __glXScreenInit */
+ "Extensions String", /* GLXextensions is overwritten by __glXScreenInit */
+ NULL /* WrappedPositionWindow is overwritten */
+};
+
+void *__glXglDDXScreenInfo(void) {
+ return &__glDDXScreenInfo;
+}
+
+static __GLXextensionInfo __glDDXExtensionInfo = {
+ GL_CORE_APPLE,
+ glAquaResetExtension,
+ glAquaInitVisuals,
+ glAquaSetVisualConfigs
+};
+
+void *__glXglDDXExtensionInfo(void) {
+ return &__glDDXExtensionInfo;
+}
+
+// prototypes
+
+static GLboolean glAquaDestroyContext(__GLcontext *gc);
+static GLboolean glAquaLoseCurrent(__GLcontext *gc);
+static GLboolean glAquaMakeCurrent(__GLcontext *gc);
+static GLboolean glAquaShareContext(__GLcontext *gc, __GLcontext *gcShare);
+static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src,
+ GLuint mask);
+static GLboolean glAquaForceCurrent(__GLcontext *gc);
+
+/* Drawing surface notification callbacks */
+static GLboolean glAquaNotifyResize(__GLcontext *gc);
+static void glAquaNotifyDestroy(__GLcontext *gc);
+static void glAquaNotifySwapBuffers(__GLcontext *gc);
+
+/* Dispatch table override control for external agents like libGLS */
+static struct __GLdispatchStateRec* glAquaDispatchExec(__GLcontext *gc);
+static void glAquaBeginDispatchOverride(__GLcontext *gc);
+static void glAquaEndDispatchOverride(__GLcontext *gc);
+
+
+static __GLexports glAquaExports = {
+ glAquaDestroyContext,
+ glAquaLoseCurrent,
+ glAquaMakeCurrent,
+ glAquaShareContext,
+ glAquaCopyContext,
+ glAquaForceCurrent,
+
+ glAquaNotifyResize,
+ glAquaNotifyDestroy,
+ glAquaNotifySwapBuffers,
+
+ glAquaDispatchExec,
+ glAquaBeginDispatchOverride,
+ glAquaEndDispatchOverride
+};
+
+
+typedef struct {
+ int num_vis;
+ __GLcontextModes *modes;
+ void **priv;
+
+ // wrapped screen functions
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+} glAquaScreenRec;
+
+static glAquaScreenRec glAquaScreens[MAXSCREENS];
+
+
+// __GLdrawablePrivate->private
+typedef struct {
+ GLboolean (*resize)(__GLdrawableBuffer *buf, GLint x, GLint y,
+ GLuint width, GLuint height,
+ __GLdrawablePrivate *glPriv,
+ GLuint bufferMask);
+} GLAquaDrawableRec;
+
+struct __GLcontextRec {
+ struct __GLinterfaceRec interface; // required to be first
+
+ AGLContext ctx;
+ AGLPixelFormat pixelFormat;
+
+ Bool isAttached; // TRUE if ctx is really attached to a window
+};
+
+
+// Context manipulation; return GL_FALSE on failure
+static GLboolean glAquaDestroyContext(__GLcontext *gc)
+{
+ GLAQUA_DEBUG_MSG("glAquaDestroyContext (ctx 0x%x)\n", gc->ctx);
+
+ if (gc) {
+ if (gc->ctx) aglDestroyContext(gc->ctx);
+ if (gc->pixelFormat) aglDestroyPixelFormat(gc->pixelFormat);
+ free(gc);
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLboolean glAquaLoseCurrent(__GLcontext *gc)
+{
+ GLAQUA_DEBUG_MSG("glAquaLoseCurrent (ctx 0x%x)\n", gc->ctx);
+
+ aglSetCurrentContext(NULL);
+ __glXLastContext = NULL; // Mesa does this; why?
+ gc->isAttached = FALSE;
+
+ return GL_TRUE;
+}
+
+
+/*
+ * Attach a GL context to a GL drawable
+ * If glPriv is NULL, the context is detached.
+ */
+static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv)
+{
+ __GLXdrawablePrivate *glxPriv;
+
+ if (glPriv == NULL) {
+ // attaching to nothing
+ GLAQUA_DEBUG_MSG("unattaching\n");
+ aglSetDrawable(gc->ctx, NULL);
+ gc->isAttached = FALSE;
+ return;
+ }
+
+ // Note that when resizing, the X11 WindowPtr already has its
+ // new size and position, but the Aqua window does not.
+
+ glxPriv = (__GLXdrawablePrivate *)glPriv->other;
+
+ if (glxPriv->type == DRAWABLE_WINDOW) {
+ WindowPtr pWin = (WindowPtr) glxPriv->pDraw;
+ WindowPtr topWin = quartzProcs->TopLevelParent(pWin);
+ CRWindowPtr crWinPtr;
+ AGLDrawable newPort;
+
+ if (glPriv->width <= 0 || glPriv->height <= 0) {
+ // attach to zero size drawable - will really attach later
+ GLAQUA_DEBUG_MSG("couldn't attach to zero size drawable\n");
+ aglSetDrawable(gc->ctx, NULL);
+ gc->isAttached = FALSE;
+ return;
+ }
+
+ crWinPtr = (CRWindowPtr) quartzProcs->FrameForWindow(pWin, FALSE);
+
+ if (crWinPtr) {
+ newPort = (AGLDrawable) crWinPtr->port;
+ } else {
+ newPort = NULL;
+ }
+
+ if (newPort) {
+ // FIXME: won't be a CGrafPtr if currently offscreen or fullscreen
+ AGLDrawable oldPort = aglGetDrawable(gc->ctx);
+ // AGLDrawable newPort = GetWindowPort(window);
+
+ // Frame is GLdrawable in X11 global coordinates
+ // FIXME: Does this work for multiple screens?
+ GLint frame[4] = {glPriv->xOrigin, glPriv->yOrigin, glPriv->width, glPriv->height};
+ GLAQUA_DEBUG_MSG("global size %d %d %d %d\n",
+ frame[0], frame[1], frame[2], frame[3]);
+
+ // Convert to window-local coordinates
+ frame[0] -= topWin->drawable.x - topWin->borderWidth;
+ frame[1] -= topWin->drawable.y - topWin->borderWidth;
+
+ // AGL uses flipped coordinates
+ frame[1] = topWin->drawable.height + 2*topWin->borderWidth -
+ frame[1] - frame[3];
+
+ GLAQUA_DEBUG_MSG("local size %d %d %d %d\n",
+ frame[0], frame[1], frame[2], frame[3]);
+
+ if (oldPort != newPort) {
+ // FIXME: retain/release windows
+ if (!aglSetDrawable(gc->ctx, newPort)) return;
+ }
+ if (!aglSetInteger(gc->ctx, AGL_BUFFER_RECT, frame)) return;
+ if (!aglEnable(gc->ctx, AGL_BUFFER_RECT)) return;
+ if (!aglSetInteger(gc->ctx, AGL_SWAP_RECT, frame)) return;
+ if (!aglEnable(gc->ctx, AGL_SWAP_RECT)) return;
+ if (!aglUpdateContext(gc->ctx)) return;
+
+ gc->isAttached = TRUE;
+ GLAQUA_DEBUG_MSG("attached context 0x%x to window 0x%x\n", gc->ctx,
+ pWin->drawable.id);
+ } else {
+ // attach to not-yet-realized window - will really attach later
+ GLAQUA_DEBUG_MSG("couldn't attach to unrealized window\n");
+ aglSetDrawable(gc->ctx, NULL);
+ gc->isAttached = FALSE;
+ }
+ } else {
+ GLAQUA_DEBUG_MSG("attach: attach to non-window unimplemented\n");
+ aglSetDrawable(gc->ctx, NULL);
+ gc->isAttached = FALSE;
+ }
+}
+
+static GLboolean glAquaMakeCurrent(__GLcontext *gc)
+{
+ __GLdrawablePrivate *glPriv = gc->interface.imports.getDrawablePrivate(gc);
+
+ GLAQUA_DEBUG_MSG("glAquaMakeCurrent (ctx 0x%x)\n", gc->ctx);
+
+ if (!gc->isAttached) {
+ attach(gc, glPriv);
+ }
+
+ return aglSetCurrentContext(gc->ctx);
+}
+
+static GLboolean glAquaShareContext(__GLcontext *gc, __GLcontext *gcShare)
+{
+ GLAQUA_DEBUG_MSG("glAquaShareContext unimplemented\n");
+
+ return GL_TRUE;
+}
+
+
+static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src,
+ GLuint mask)
+{
+ GLAQUA_DEBUG_MSG("glAquaCopyContext\n");
+
+ return aglCopyContext(src->ctx, dst->ctx, mask);
+}
+
+static GLboolean glAquaForceCurrent(__GLcontext *gc)
+{
+ // GLAQUA_DEBUG_MSG("glAquaForceCurrent (ctx 0x%x)\n", gc->ctx);
+ return aglSetCurrentContext(gc->ctx);
+}
+
+/* Drawing surface notification callbacks */
+
+static GLboolean glAquaNotifyResize(__GLcontext *gc)
+{
+ GLAQUA_DEBUG_MSG("unimplemented glAquaNotifyResize");
+ return GL_TRUE;
+}
+
+static void glAquaNotifyDestroy(__GLcontext *gc)
+{
+ GLAQUA_DEBUG_MSG("unimplemented glAquaNotifyDestroy");
+}
+
+static void glAquaNotifySwapBuffers(__GLcontext *gc)
+{
+ GLAQUA_DEBUG_MSG("unimplemented glAquaNotifySwapBuffers");
+}
+
+/* Dispatch table override control for external agents like libGLS */
+static struct __GLdispatchStateRec* glAquaDispatchExec(__GLcontext *gc)
+{
+ GLAQUA_DEBUG_MSG("unimplemented glAquaDispatchExec");
+ return NULL;
+}
+
+static void glAquaBeginDispatchOverride(__GLcontext *gc)
+{
+ GLAQUA_DEBUG_MSG("unimplemented glAquaBeginDispatchOverride");
+}
+
+static void glAquaEndDispatchOverride(__GLcontext *gc)
+{
+ GLAQUA_DEBUG_MSG("unimplemented glAquaEndDispatchOverride");
+}
+
+
+static AGLPixelFormat makeFormat(__GLcontextModes *mode)
+{
+ int i;
+ GLint attr[64]; // currently uses max of 30
+ AGLPixelFormat result;
+
+ GLAQUA_DEBUG_MSG("makeFormat\n");
+
+ i = 0;
+
+ // attr [i++] = AGL_ACCELERATED; // require hwaccel - BAD for multiscreen
+ // attr [i++] = AGL_NO_RECOVERY; // disable fallback renderers - BAD
+
+ if (mode->stereoMode) {
+ attr[i++] = AGL_STEREO;
+ }
+ if (mode->doubleBufferMode) {
+ attr[i++] = AGL_DOUBLEBUFFER;
+ }
+
+ if (mode->colorIndexMode) {
+ attr[i++] = AGL_BUFFER_SIZE;
+ attr[i++] = mode->indexBits;
+ }
+
+ if (mode->rgbMode) {
+ attr[i++] = AGL_RGBA;
+ attr[i++] = AGL_RED_SIZE;
+ attr[i++] = mode->redBits;
+ attr[i++] = AGL_GREEN_SIZE;
+ attr[i++] = mode->greenBits;
+ attr[i++] = AGL_BLUE_SIZE;
+ attr[i++] = mode->blueBits;
+ attr[i++] = AGL_ALPHA_SIZE;
+ attr[i++] = mode->alphaBits;
+ }
+
+ if (mode->haveAccumBuffer) {
+ attr[i++] = AGL_ACCUM_RED_SIZE;
+ attr[i++] = mode->accumRedBits;
+ attr[i++] = AGL_ACCUM_GREEN_SIZE;
+ attr[i++] = mode->accumGreenBits;
+ attr[i++] = AGL_ACCUM_BLUE_SIZE;
+ attr[i++] = mode->accumBlueBits;
+ attr[i++] = AGL_ACCUM_ALPHA_SIZE;
+ attr[i++] = mode->accumAlphaBits;
+ }
+ if (mode->haveDepthBuffer) {
+ attr[i++] = AGL_DEPTH_SIZE;
+ attr[i++] = mode->depthBits;
+ }
+ if (mode->haveStencilBuffer) {
+ attr[i++] = AGL_STENCIL_SIZE;
+ attr[i++] = mode->stencilBits;
+ }
+
+ attr[i++] = AGL_AUX_BUFFERS;
+ attr[i++] = mode->numAuxBuffers;
+
+ attr[i++] = AGL_LEVEL;
+ attr[i++] = mode->level;
+
+ // mode->pixmapMode ?
+
+ attr[i++] = AGL_NONE; // end of option list
+
+ GLAQUA_DEBUG_MSG("makeFormat almost done\n");
+ result = aglChoosePixelFormat(NULL, 0, attr);
+ GLAQUA_DEBUG_MSG("makeFormat done (0x%x)\n", result);
+ return result;
+}
+
+static __GLinterface *glAquaCreateContext(__GLimports *imports,
+ __GLcontextModes *mode,
+ __GLinterface *shareGC)
+{
+ __GLcontext *result;
+ __GLcontext *sharectx = (__GLcontext *)shareGC;
+
+ GLAQUA_DEBUG_MSG("glAquaCreateContext\n");
+
+ result = (__GLcontext *)calloc(1, sizeof(__GLcontext));
+ if (!result) return NULL;
+
+ result->interface.imports = *imports;
+ result->interface.exports = glAquaExports;
+
+ result->pixelFormat = makeFormat(mode);
+ if (!result->pixelFormat) {
+ free(result);
+ return NULL;
+ }
+
+ result->ctx = aglCreateContext(result->pixelFormat,
+ (sharectx && sharectx->ctx) ? sharectx->ctx : NULL);
+
+ if (!result->ctx) {
+ aglDestroyPixelFormat(result->pixelFormat);
+ free(result);
+ return NULL;
+ }
+
+ result->isAttached = FALSE;
+
+ GLAQUA_DEBUG_MSG("glAquaCreateContext done\n");
+ return (__GLinterface *)result;
+}
+
+
+Bool
+glAquaRealizeWindow(WindowPtr pWin)
+{
+ // If this window has GL contexts, tell them to reattach
+ Bool result;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ glAquaScreenRec *screenPriv = &glAquaScreens[pScreen->myNum];
+ __GLXdrawablePrivate *glxPriv;
+
+ GLAQUA_DEBUG_MSG("glAquaRealizeWindow\n");
+
+ // Allow the window to be created (RootlessRealizeWindow is inside our wrap)
+ pScreen->RealizeWindow = screenPriv->RealizeWindow;
+ result = pScreen->RealizeWindow(pWin);
+ pScreen->RealizeWindow = glAquaRealizeWindow;
+
+ // The Aqua window will already have been created (windows are
+ // realized from top down)
+
+ // Re-attach this window's GL contexts, if any.
+ glxPriv = __glXFindDrawablePrivate(pWin->drawable.id);
+ if (glxPriv) {
+ __GLXcontext *gx;
+ __GLcontext *gc;
+ __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
+ GLAQUA_DEBUG_MSG("glAquaRealizeWindow is GL drawable!\n");
+
+ // GL contexts bound to this window for drawing
+ for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->nextDrawPriv) {
+ gc = (__GLcontext *)gx->gc;
+ attach(gc, glPriv);
+ }
+
+ // GL contexts bound to this window for reading
+ for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->nextReadPriv) {
+ gc = (__GLcontext *)gx->gc;
+ attach(gc, glPriv);
+ }
+ }
+
+ return result;
+}
+
+Bool
+glAquaUnrealizeWindow(WindowPtr pWin)
+{
+ // If this window has GL contexts, tell them to unattach
+ Bool result;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ glAquaScreenRec *screenPriv = &glAquaScreens[pScreen->myNum];
+ __GLXdrawablePrivate *glxPriv;
+
+ GLAQUA_DEBUG_MSG("glAquaUnrealizeWindow\n");
+
+ // The Aqua window may have already been destroyed (windows
+ // are unrealized from top down)
+
+ // Unattach this window's GL contexts, if any.
+ glxPriv = __glXFindDrawablePrivate(pWin->drawable.id);
+ if (glxPriv) {
+ __GLXcontext *gx;
+ __GLcontext *gc;
+ GLAQUA_DEBUG_MSG("glAquaUnealizeWindow is GL drawable!\n");
+
+ // GL contexts bound to this window for drawing
+ for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->nextDrawPriv) {
+ gc = (__GLcontext *)gx->gc;
+ attach(gc, NULL);
+ }
+
+ // GL contexts bound to this window for reading
+ for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->nextReadPriv) {
+ gc = (__GLcontext *)gx->gc;
+ attach(gc, NULL);
+ }
+ }
+
+ pScreen->UnrealizeWindow = screenPriv->UnrealizeWindow;
+ result = pScreen->UnrealizeWindow(pWin);
+ pScreen->UnrealizeWindow = glAquaUnrealizeWindow;
+
+ return result;
+}
+
+
+// Originally copied from Mesa
+
+static int numConfigs = 0;
+static __GLXvisualConfig *visualConfigs = NULL;
+static void **visualPrivates = NULL;
+
+/*
+ * In the case the driver defines no GLX visuals we'll use these.
+ * Note that for TrueColor and DirectColor visuals, bufferSize is the
+ * sum of redSize, greenSize, blueSize and alphaSize, which may be larger
+ * than the nplanes/rootDepth of the server's X11 visuals
+ */
+#define NUM_FALLBACK_CONFIGS 5
+static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
+ /* [0] = RGB, double buffered, Z */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 0, 0, 0, 0, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 0, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [1] = RGB, double buffered, Z, stencil, accum */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 16, 16, 16, 0, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [2] = RGB+Alpha, double buffered, Z, stencil, accum */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 8, /* rgba sizes */
+ -1, -1, -1, -1, /* rgba masks */
+ 16, 16, 16, 16, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [3] = RGB+Alpha, single buffered, Z, stencil, accum */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 8, /* rgba sizes */
+ -1, -1, -1, -1, /* rgba masks */
+ 16, 16, 16, 16, /* rgba accum sizes */
+ False, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [4] = CI, double buffered, Z */
+ {
+ -1, /* vid */
+ -1, /* class */
+ False, /* rgba? (false = color index) */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 0, 0, 0, 0, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 0, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+};
+
+static __GLXvisualConfig NullConfig = {
+ -1, /* vid */
+ -1, /* class */
+ False, /* rgba */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 0, 0, 0, 0, /* rgba accum sizes */
+ False, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 0, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE_EXT, /* visualRating */
+ 0, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+};
+
+
+static int count_bits(unsigned int n)
+{
+ int bits = 0;
+
+ while (n > 0) {
+ if (n & 1) bits++;
+ n >>= 1;
+ }
+ return bits;
+}
+
+
+static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
+ VisualID *defaultVisp,
+ int ndepth, DepthPtr pdepth,
+ int rootDepth)
+{
+ int numRGBconfigs;
+ int numCIconfigs;
+ int numVisuals = *nvisualp;
+ int numNewVisuals;
+ int numNewConfigs;
+ VisualPtr pVisual = *visualp;
+ VisualPtr pVisualNew = NULL;
+ VisualID *orig_vid = NULL;
+ __GLcontextModes *modes;
+ __GLXvisualConfig *pNewVisualConfigs = NULL;
+ void **glXVisualPriv;
+ void **pNewVisualPriv;
+ int found_default;
+ int i, j, k;
+
+ GLAQUA_DEBUG_MSG("init_visuals\n");
+
+ if (numConfigs > 0)
+ numNewConfigs = numConfigs;
+ else
+ numNewConfigs = NUM_FALLBACK_CONFIGS;
+
+ /* Alloc space for the list of new GLX visuals */
+ pNewVisualConfigs = (__GLXvisualConfig *)
+ __glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig));
+ if (!pNewVisualConfigs) {
+ return FALSE;
+ }
+
+ /* Alloc space for the list of new GLX visual privates */
+ pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *));
+ if (!pNewVisualPriv) {
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /*
+ ** If SetVisualConfigs was not called, then use default GLX
+ ** visual configs.
+ */
+ if (numConfigs == 0) {
+ memcpy(pNewVisualConfigs, FallbackConfigs,
+ NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig));
+ memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *));
+ }
+ else {
+ /* copy driver's visual config info */
+ for (i = 0; i < numConfigs; i++) {
+ pNewVisualConfigs[i] = visualConfigs[i];
+ pNewVisualPriv[i] = visualPrivates[i];
+ }
+ }
+
+ /* Count the number of RGB and CI visual configs */
+ numRGBconfigs = 0;
+ numCIconfigs = 0;
+ for (i = 0; i < numNewConfigs; i++) {
+ if (pNewVisualConfigs[i].rgba)
+ numRGBconfigs++;
+ else
+ numCIconfigs++;
+ }
+
+ /* Count the total number of visuals to compute */
+ numNewVisuals = 0;
+ for (i = 0; i < numVisuals; i++) {
+ int count;
+
+ count = ((pVisual[i].class == TrueColor ||
+ pVisual[i].class == DirectColor)
+ ? numRGBconfigs : numCIconfigs);
+ if (count == 0)
+ count = 1; /* preserve the existing visual */
+
+ numNewVisuals += count;
+ }
+
+ /* Reset variables for use with the next screen/driver's visual configs */
+ visualConfigs = NULL;
+ numConfigs = 0;
+
+ /* Alloc temp space for the list of orig VisualIDs for each new visual */
+ orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID));
+ if (!orig_vid) {
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the list of glXVisuals */
+ modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes));
+ if (modes == NULL) {
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the list of glXVisualPrivates */
+ glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *));
+ if (!glXVisualPriv) {
+ _gl_context_modes_destroy( modes );
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the new list of the X server's visuals */
+ pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec));
+ if (!pVisualNew) {
+ __glXFree(glXVisualPriv);
+ _gl_context_modes_destroy( modes );
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Initialize the new visuals */
+ found_default = FALSE;
+ glAquaScreens[screenInfo.numScreens-1].modes = modes;
+ for (i = j = 0; i < numVisuals; i++) {
+ int is_rgb = (pVisual[i].class == TrueColor ||
+ pVisual[i].class == DirectColor);
+
+ if (!is_rgb)
+ {
+ /* We don't support non-rgb visuals for GL. But we don't
+ want to remove them either, so just pass them through
+ with null glX configs */
+
+ pVisualNew[j] = pVisual[i];
+ pVisualNew[j].vid = FakeClientID(0);
+
+ /* Check for the default visual */
+ if (!found_default && pVisual[i].vid == *defaultVisp) {
+ *defaultVisp = pVisualNew[j].vid;
+ found_default = TRUE;
+ }
+
+ /* Save the old VisualID */
+ orig_vid[j] = pVisual[i].vid;
+
+ /* Initialize the glXVisual */
+ _gl_copy_visual_to_context_mode( modes, & NullConfig );
+ modes->visualID = pVisualNew[j].vid;
+
+ j++;
+
+ continue;
+ }
+
+ for (k = 0; k < numNewConfigs; k++) {
+ if (pNewVisualConfigs[k].rgba != is_rgb)
+ continue;
+
+ assert( modes != NULL );
+
+ /* Initialize the new visual */
+ pVisualNew[j] = pVisual[i];
+ pVisualNew[j].vid = FakeClientID(0);
+
+ /* Check for the default visual */
+ if (!found_default && pVisual[i].vid == *defaultVisp) {
+ *defaultVisp = pVisualNew[j].vid;
+ found_default = TRUE;
+ }
+
+ /* Save the old VisualID */
+ orig_vid[j] = pVisual[i].vid;
+
+ /* Initialize the glXVisual */
+ _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] );
+ modes->visualID = pVisualNew[j].vid;
+
+ /*
+ * If the class is -1, then assume the X visual information
+ * is identical to what GLX needs, and take them from the X
+ * visual. NOTE: if class != -1, then all other fields MUST
+ * be initialized.
+ */
+ if (modes->visualType == GLX_NONE) {
+ modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class );
+ modes->redBits = count_bits(pVisual[i].redMask);
+ modes->greenBits = count_bits(pVisual[i].greenMask);
+ modes->blueBits = count_bits(pVisual[i].blueMask);
+ modes->alphaBits = modes->alphaBits;
+ modes->redMask = pVisual[i].redMask;
+ modes->greenMask = pVisual[i].greenMask;
+ modes->blueMask = pVisual[i].blueMask;
+ modes->alphaMask = modes->alphaMask;
+ modes->rgbBits = (is_rgb)
+ ? (modes->redBits + modes->greenBits +
+ modes->blueBits + modes->alphaBits)
+ : rootDepth;
+ }
+
+ /* Save the device-dependent private for this visual */
+ glXVisualPriv[j] = pNewVisualPriv[k];
+
+ j++;
+ modes = modes->next;
+ }
+ }
+
+ assert(j <= numNewVisuals);
+
+ /* Save the GLX visuals in the screen structure */
+ glAquaScreens[screenInfo.numScreens-1].num_vis = numNewVisuals;
+ glAquaScreens[screenInfo.numScreens-1].priv = glXVisualPriv;
+
+ /* Set up depth's VisualIDs */
+ for (i = 0; i < ndepth; i++) {
+ int numVids = 0;
+ VisualID *pVids = NULL;
+ int k, n = 0;
+
+ /* Count the new number of VisualIDs at this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numNewVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ numVids++;
+
+ /* Allocate a new list of VisualIDs for this depth */
+ pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID));
+
+ /* Initialize the new list of VisualIDs for this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numNewVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ pVids[n++] = pVisualNew[k].vid;
+
+ /* Update this depth's list of VisualIDs */
+ __glXFree(pdepth[i].vids);
+ pdepth[i].vids = pVids;
+ pdepth[i].numVids = numVids;
+ }
+
+ /* Update the X server's visuals */
+ *nvisualp = numNewVisuals;
+ *visualp = pVisualNew;
+
+ /* Free the old list of the X server's visuals */
+ __glXFree(pVisual);
+
+ /* Clean up temporary allocations */
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+
+ /* Free the private list created by DDX HW driver */
+ if (visualPrivates)
+ xfree(visualPrivates);
+ visualPrivates = NULL;
+
+ return TRUE;
+}
+
+/* based on code in i830_dri.c
+ This ends calling glAquaSetVisualConfigs to set the static
+ numconfigs, etc. */
+static void
+glAquaInitVisualConfigs(void)
+{
+ int lclNumConfigs = 0;
+ __GLXvisualConfig *lclVisualConfigs = NULL;
+ void **lclVisualPrivates = NULL;
+
+ int depth, aux, buffers, stencil, accum;
+ int i = 0;
+
+ GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs ");
+
+ /* count num configs:
+ 2 Z buffer (0, 24 bit)
+ 2 AUX buffer (0, 2)
+ 2 buffers (single, double)
+ 2 stencil (0, 8 bit)
+ 2 accum (0, 64 bit)
+ = 32 configs */
+
+ lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */
+
+ /* alloc */
+ lclVisualConfigs = xcalloc(sizeof(__GLXvisualConfig), lclNumConfigs);
+ lclVisualPrivates = xcalloc(sizeof(void *), lclNumConfigs);
+
+ /* fill in configs */
+ if (NULL != lclVisualConfigs) {
+ i = 0; /* current buffer */
+ for (depth = 0; depth < 2; depth++) {
+ for (aux = 0; aux < 2; aux++) {
+ for (buffers = 0; buffers < 2; buffers++) {
+ for (stencil = 0; stencil < 2; stencil++) {
+ for (accum = 0; accum < 2; accum++) {
+ lclVisualConfigs[i].vid = -1;
+ lclVisualConfigs[i].class = -1;
+ lclVisualConfigs[i].rgba = TRUE;
+ lclVisualConfigs[i].redSize = -1;
+ lclVisualConfigs[i].greenSize = -1;
+ lclVisualConfigs[i].blueSize = -1;
+ lclVisualConfigs[i].redMask = -1;
+ lclVisualConfigs[i].greenMask = -1;
+ lclVisualConfigs[i].blueMask = -1;
+ lclVisualConfigs[i].alphaMask = 0;
+ if (accum) {
+ lclVisualConfigs[i].accumRedSize = 16;
+ lclVisualConfigs[i].accumGreenSize = 16;
+ lclVisualConfigs[i].accumBlueSize = 16;
+ lclVisualConfigs[i].accumAlphaSize = 16;
+ }
+ else {
+ lclVisualConfigs[i].accumRedSize = 0;
+ lclVisualConfigs[i].accumGreenSize = 0;
+ lclVisualConfigs[i].accumBlueSize = 0;
+ lclVisualConfigs[i].accumAlphaSize = 0;
+ }
+ lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE;
+ lclVisualConfigs[i].stereo = FALSE;
+ lclVisualConfigs[i].bufferSize = -1;
+
+ lclVisualConfigs[i].depthSize = depth? 24 : 0;
+ lclVisualConfigs[i].stencilSize = stencil ? 8 : 0;
+ lclVisualConfigs[i].auxBuffers = aux ? 2 : 0;
+ lclVisualConfigs[i].level = 0;
+ lclVisualConfigs[i].visualRating = GLX_NONE_EXT;
+ lclVisualConfigs[i].transparentPixel = 0;
+ lclVisualConfigs[i].transparentRed = 0;
+ lclVisualConfigs[i].transparentGreen = 0;
+ lclVisualConfigs[i].transparentBlue = 0;
+ lclVisualConfigs[i].transparentAlpha = 0;
+ lclVisualConfigs[i].transparentIndex = 0;
+ i++;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (i != lclNumConfigs)
+ GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs failed to alloc visual configs");
+
+ GlxSetVisualConfigs(lclNumConfigs, lclVisualConfigs, lclVisualPrivates);
+}
+
+
+static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
+ void **privates)
+{
+ GLAQUA_DEBUG_MSG("glAquaSetVisualConfigs\n");
+
+ numConfigs = nconfigs;
+ visualConfigs = configs;
+ visualPrivates = privates;
+}
+
+static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
+ int *nvisualp, int *ndepthp,
+ int *rootDepthp, VisualID *defaultVisp,
+ unsigned long sizes, int bitsPerRGB)
+{
+ GLAQUA_DEBUG_MSG("glAquaInitVisuals\n");
+
+ if (numConfigs == 0) /* if no configs */
+ glAquaInitVisualConfigs(); /* ensure the visual configs are setup */
+
+ /*
+ * Setup the visuals supported by this particular screen.
+ */
+ return init_visuals(nvisualp, visualp, defaultVisp,
+ *ndepthp, *depthp, *rootDepthp);
+}
+
+
+static void fixup_visuals(int screen)
+{
+ ScreenPtr pScreen = screenInfo.screens[screen];
+ glAquaScreenRec *pScr = &glAquaScreens[screen];
+ int j;
+ __GLcontextModes *modes;
+
+ GLAQUA_DEBUG_MSG("fixup_visuals\n");
+
+ for ( modes = pScr->modes ; modes != NULL ; modes = modes->next ) {
+ const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+ const int nplanes = (modes->rgbBits - modes->alphaBits);
+ const VisualPtr pVis = pScreen->visuals;
+
+ /* Find a visual that matches the GLX visual's class and size */
+ for (j = 0; j < pScreen->numVisuals; j++) {
+ if (pVis[j].class == vis_class &&
+ pVis[j].nplanes == nplanes) {
+
+ /* Fixup the masks */
+ modes->redMask = pVis[j].redMask;
+ modes->greenMask = pVis[j].greenMask;
+ modes->blueMask = pVis[j].blueMask;
+
+ /* Recalc the sizes */
+ modes->redBits = count_bits(modes->redMask);
+ modes->greenBits = count_bits(modes->greenMask);
+ modes->blueBits = count_bits(modes->blueMask);
+ }
+ }
+ }
+}
+
+static void init_screen_visuals(int screen)
+{
+ ScreenPtr pScreen = screenInfo.screens[screen];
+ __GLcontextModes *modes;
+ int *used;
+ int i, j;
+
+ GLAQUA_DEBUG_MSG("init_screen_visuals\n");
+
+ /* FIXME: Change 'used' to be a array of bits (rather than of ints),
+ * FIXME: create a stack array of 8 or 16 bytes. If 'numVisuals' is less
+ * FIXME: than 64 or 128 the stack array can be used instead of calling
+ * FIXME: __glXMalloc / __glXFree. If nothing else, convert 'used' to
+ * FIXME: array of bytes instead of ints!
+ */
+ used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int));
+ __glXMemset(used, 0, pScreen->numVisuals * sizeof(int));
+
+ i = 0;
+ for ( modes = glAquaScreens[screen].modes
+ ; modes != NULL
+ ; modes = modes->next ) {
+ const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+ const int nplanes = (modes->rgbBits - modes->alphaBits);
+ const VisualPtr pVis = pScreen->visuals;
+
+ for (j = 0; j < pScreen->numVisuals; j++) {
+ if (pVis[j].class == vis_class &&
+ pVis[j].nplanes == nplanes &&
+ pVis[j].redMask == modes->redMask &&
+ pVis[j].greenMask == modes->greenMask &&
+ pVis[j].blueMask == modes->blueMask &&
+ !used[j]) {
+
+ /* Set the VisualID */
+ modes->visualID = pVis[j].vid;
+
+ /* Mark this visual used */
+ used[j] = 1;
+ break;
+ }
+ }
+ if ( j == pScreen->numVisuals ) {
+ ErrorF("No matching visual for __GLcontextMode with "
+ "visual class = %d (%d), nplanes = %u\n",
+ vis_class,
+ (int)modes->visualType,
+ (unsigned int)(modes->rgbBits - modes->alphaBits) );
+ }
+ else if ( modes->visualID == -1 ) {
+ FatalError( "Matching visual found, but visualID still -1!\n" );
+ }
+
+ i++;
+ }
+
+ __glXFree(used);
+}
+
+static Bool glAquaScreenProbe(int screen)
+{
+ ScreenPtr pScreen;
+ glAquaScreenRec *screenPriv;
+
+ GLAQUA_DEBUG_MSG("glAquaScreenProbe\n");
+
+ /*
+ * Set up the current screen's visuals.
+ */
+ __glDDXScreenInfo.modes = glAquaScreens[screen].modes;
+ __glDDXScreenInfo.pVisualPriv = glAquaScreens[screen].priv;
+ __glDDXScreenInfo.numVisuals =
+ __glDDXScreenInfo.numUsableVisuals = glAquaScreens[screen].num_vis;
+
+ /*
+ * Set the current screen's createContext routine. This could be
+ * wrapped by a DDX GLX context creation routine.
+ */
+ __glDDXScreenInfo.createContext = glAquaCreateContext;
+
+ /*
+ * The ordering of the rgb compenents might have been changed by the
+ * driver after mi initialized them.
+ */
+ fixup_visuals(screen);
+
+ /*
+ * Find the GLX visuals that are supported by this screen and create
+ * XMesa's visuals.
+ */
+ init_screen_visuals(screen);
+
+ /*
+ * Wrap RealizeWindow and UnrealizeWindow on this screen
+ */
+ pScreen = screenInfo.screens[screen];
+ screenPriv = &glAquaScreens[screen];
+ screenPriv->RealizeWindow = pScreen->RealizeWindow;
+ pScreen->RealizeWindow = glAquaRealizeWindow;
+ screenPriv->UnrealizeWindow = pScreen->UnrealizeWindow;
+ pScreen->UnrealizeWindow = glAquaUnrealizeWindow;
+
+ return TRUE;
+}
+
+
+static GLboolean glAquaResizeBuffers(__GLdrawableBuffer *buffer,
+ GLint x, GLint y,
+ GLuint width, GLuint height,
+ __GLdrawablePrivate *glPriv,
+ GLuint bufferMask)
+{
+ GLAquaDrawableRec *aquaPriv = (GLAquaDrawableRec *)glPriv->private;
+ __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other;
+ __GLXcontext *gx;
+ __GLcontext *gc;
+
+ GLAQUA_DEBUG_MSG("glAquaResizeBuffers to (%d %d %d %d)\n", x, y, width, height);
+
+ // update all contexts that point at this drawable for drawing (hack?)
+ for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->nextDrawPriv) {
+ gc = (__GLcontext *)gx->gc;
+ attach(gc, glPriv);
+ }
+
+ // update all contexts that point at this drawable for reading (hack?)
+ for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->nextReadPriv) {
+ gc = (__GLcontext *)gx->gc;
+ attach(gc, glPriv);
+ }
+
+ return aquaPriv->resize(buffer, x, y, width, height, glPriv, bufferMask);
+}
+
+
+static GLboolean glAquaSwapBuffers(__GLXdrawablePrivate *glxPriv)
+{
+ // fixme AGL software renderer will use properties of current QD port (bad)
+
+ // swap buffers on only *one* of the contexts
+ // (e.g. the last one for drawing)
+ __GLcontext *gc = (__GLcontext *)glxPriv->drawGlxc->gc;
+ if (gc && gc->ctx) aglSwapBuffers(gc->ctx);
+
+ return GL_TRUE;
+}
+
+static void glAquaDestroyDrawablePrivate(__GLdrawablePrivate *glPriv)
+{
+ GLAQUA_DEBUG_MSG("glAquaDestroyDrawablePrivate\n");
+
+ free(glPriv->private);
+ glPriv->private = NULL;
+}
+
+static void glAquaCreateBuffer(__GLXdrawablePrivate *glxPriv)
+{
+ GLAquaDrawableRec *aquaPriv = malloc(sizeof(GLAquaDrawableRec));
+ __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
+
+ GLAQUA_DEBUG_MSG("glAquaCreateBuffer\n");
+
+ // replace swapBuffers (original is never called)
+ glxPriv->swapBuffers = glAquaSwapBuffers;
+
+ // wrap front buffer resize
+ aquaPriv->resize = glPriv->frontBuffer.resize;
+ glPriv->frontBuffer.resize = glAquaResizeBuffers;
+
+ // stash private data
+ glPriv->private = aquaPriv;
+ glPriv->freePrivate = glAquaDestroyDrawablePrivate;
+}
+
+
+static void glAquaResetExtension(void)
+{
+ GLAQUA_DEBUG_MSG("glAquaResetExtension\n");
+ aglResetLibrary();
+}
+
+
+
+// Extra goodies for glx
+
+GLuint __glFloorLog2(GLuint val)
+{
+ int c = 0;
+
+ while (val > 1) {
+ c++;
+ val >>= 1;
+ }
+ return c;
+}
diff --git a/nx-X11/programs/Xserver/GL/apple/indirect.c b/nx-X11/programs/Xserver/GL/apple/indirect.c
new file mode 100644
index 000000000..448b1f76a
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/apple/indirect.c
@@ -0,0 +1,1380 @@
+/*
+ * GLX implementation that uses Apple's OpenGL.framework
+ * (Indirect rendering path)
+ */
+/*
+ * Copyright (c) 2002 Greg Parker. All Rights Reserved.
+ * Copyright (c) 2002 Apple Computer, Inc.
+ * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Portions of this file are copied from Mesa's xf86glx.c,
+ * which contains the following copyright:
+ *
+ * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/GL/apple/indirect.c,v 1.2 2003/09/16 00:36:11 torrey Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "dri.h"
+#include "quartz.h"
+
+#include <CoreGraphics/CoreGraphics.h>
+#include <OpenGL/OpenGL.h>
+#include <OpenGL/CGLContext.h>
+
+// X11 and X11's glx
+#include <miscstruct.h>
+#include <windowstr.h>
+#include <resource.h>
+#include <GL/glxint.h>
+#include <GL/glxtokens.h>
+#include <scrnintstr.h>
+#include <glxserver.h>
+#include <glxscreens.h>
+#include <glxdrawable.h>
+#include <glxcontext.h>
+#include <glxext.h>
+#include <glxutil.h>
+#include <glxscreens.h>
+#include <GL/internal/glcore.h>
+#include "x-hash.h"
+#include "x-list.h"
+
+#include "glcontextmodes.h"
+
+// ggs: needed to call back to glx with visual configs
+extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs);
+
+
+// Write debugging output, or not
+#ifdef GLAQUA_DEBUG
+#define GLAQUA_DEBUG_MSG ErrorF
+#else
+#define GLAQUA_DEBUG_MSG(a, ...)
+#endif
+
+
+// The following GL functions don't have an EXT suffix in OpenGL.framework.
+GLboolean glAreTexturesResidentEXT(GLsizei a, const GLuint *b, GLboolean *c) {
+ return glAreTexturesResident(a, b, c);
+}
+void glDeleteTexturesEXT(GLsizei d, const GLuint *e) {
+ glDeleteTextures(d, e);
+}
+void glGenTexturesEXT(GLsizei f, GLuint *g) {
+ glGenTextures(f, g);
+}
+GLboolean glIsTextureEXT(GLuint h) {
+ return glIsTexture(h);
+}
+
+// some prototypes
+static Bool glAquaScreenProbe(int screen);
+static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
+ int *nvisualp, int *ndepthp,
+ int *rootDepthp, VisualID *defaultVisp,
+ unsigned long sizes, int bitsPerRGB);
+static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
+ void **privates);
+static __GLinterface *glAquaCreateContext(__GLimports *imports,
+ __GLcontextModes *mode,
+ __GLinterface *shareGC);
+static void glAquaCreateBuffer(__GLXdrawablePrivate *glxPriv);
+static void glAquaResetExtension(void);
+
+/*
+ * This structure is statically allocated in the __glXScreens[]
+ * structure. This struct is not used anywhere other than in
+ * __glXScreenInit to initialize each of the active screens
+ * (__glXActiveScreens[]). Several of the fields must be initialized by
+ * the screenProbe routine before they are copied to the active screens
+ * struct. In particular, the contextCreate, modes, numVisuals,
+ * and numUsableVisuals fields must be initialized.
+ */
+static __GLXscreenInfo __glDDXScreenInfo = {
+ glAquaScreenProbe, /* Must be generic and handle all screens */
+ glAquaCreateContext, /* Substitute screen's createContext routine */
+ glAquaCreateBuffer, /* Substitute screen's createBuffer routine */
+ NULL, /* Set up modes in probe */
+ NULL, /* Set up pVisualPriv in probe */
+ 0, /* Set up numVisuals in probe */
+ 0, /* Set up numUsableVisuals in probe */
+ "Vendor String", /* GLXvendor is overwritten by __glXScreenInit */
+ "Version String", /* GLXversion is overwritten by __glXScreenInit */
+ "Extensions String", /* GLXextensions is overwritten by __glXScreenInit */
+ NULL /* WrappedPositionWindow is overwritten */
+};
+
+void *__glXglDDXScreenInfo(void) {
+ return &__glDDXScreenInfo;
+}
+
+static __GLXextensionInfo __glDDXExtensionInfo = {
+ GL_CORE_APPLE,
+ glAquaResetExtension,
+ glAquaInitVisuals,
+ glAquaSetVisualConfigs
+};
+
+void *__glXglDDXExtensionInfo(void) {
+ return &__glDDXExtensionInfo;
+}
+
+// prototypes
+
+static GLboolean glAquaDestroyContext(__GLcontext *gc);
+static GLboolean glAquaLoseCurrent(__GLcontext *gc);
+static GLboolean glAquaMakeCurrent(__GLcontext *gc);
+static GLboolean glAquaShareContext(__GLcontext *gc, __GLcontext *gcShare);
+static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src,
+ GLuint mask);
+static GLboolean glAquaForceCurrent(__GLcontext *gc);
+
+/* Drawing surface notification callbacks */
+static GLboolean glAquaNotifyResize(__GLcontext *gc);
+static void glAquaNotifyDestroy(__GLcontext *gc);
+static void glAquaNotifySwapBuffers(__GLcontext *gc);
+
+/* Dispatch table override control for external agents like libGLS */
+static struct __GLdispatchStateRec* glAquaDispatchExec(__GLcontext *gc);
+static void glAquaBeginDispatchOverride(__GLcontext *gc);
+static void glAquaEndDispatchOverride(__GLcontext *gc);
+
+static __GLexports glAquaExports = {
+ glAquaDestroyContext,
+ glAquaLoseCurrent,
+ glAquaMakeCurrent,
+ glAquaShareContext,
+ glAquaCopyContext,
+ glAquaForceCurrent,
+
+ glAquaNotifyResize,
+ glAquaNotifyDestroy,
+ glAquaNotifySwapBuffers,
+
+ glAquaDispatchExec,
+ glAquaBeginDispatchOverride,
+ glAquaEndDispatchOverride
+};
+
+typedef struct {
+ int num_vis;
+ __GLcontextModes *modes;
+ void **priv;
+
+ // wrapped screen functions
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+} glAquaScreenRec;
+
+static glAquaScreenRec glAquaScreens[MAXSCREENS];
+
+// __GLdrawablePrivate->private
+typedef struct {
+ DrawablePtr pDraw;
+ xp_surface_id sid;
+} GLAquaDrawableRec;
+
+struct __GLcontextRec {
+ struct __GLinterfaceRec interface; // required to be first
+
+ CGLContextObj ctx;
+ CGLPixelFormatObj pixelFormat;
+
+ /* set when attached */
+ xp_surface_id sid;
+
+ unsigned isAttached :1;
+};
+
+/* maps from surface id -> list of __GLcontext */
+static x_hash_table *surface_hash;
+
+
+// Context manipulation; return GL_FALSE on failure
+static GLboolean glAquaDestroyContext(__GLcontext *gc)
+{
+ x_list *lst;
+
+ GLAQUA_DEBUG_MSG("glAquaDestroyContext (ctx 0x%x)\n",
+ (unsigned int) gc->ctx);
+
+ if (gc != NULL)
+ {
+ if (gc->sid != 0 && surface_hash != NULL)
+ {
+ lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL);
+ lst = x_list_remove(lst, gc);
+ x_hash_table_insert(surface_hash, (void *) gc->sid, lst);
+ }
+
+ if (gc->ctx != NULL)
+ CGLDestroyContext(gc->ctx);
+
+ if (gc->pixelFormat != NULL)
+ CGLDestroyPixelFormat(gc->pixelFormat);
+
+ free(gc);
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean glAquaLoseCurrent(__GLcontext *gc)
+{
+ CGLError gl_err;
+
+ GLAQUA_DEBUG_MSG("glAquaLoseCurrent (ctx 0x%x)\n", (unsigned int) gc->ctx);
+
+ gl_err = CGLSetCurrentContext(NULL);
+ if (gl_err != 0)
+ ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
+
+ __glXLastContext = NULL; // Mesa does this; why?
+
+ return GL_TRUE;
+}
+
+/* Called when a surface is destroyed as a side effect of destroying
+ the window it's attached to. */
+static void surface_notify(void *_arg, void *data)
+{
+ DRISurfaceNotifyArg *arg = _arg;
+ GLAquaDrawableRec *aquaPriv = data;
+ __GLcontext *gc;
+ x_list *lst;
+
+ switch (arg->kind)
+ {
+ case AppleDRISurfaceNotifyDestroyed:
+ if (surface_hash != NULL)
+ x_hash_table_remove(surface_hash, (void *) arg->id);
+
+ aquaPriv->pDraw = NULL;
+ aquaPriv->sid = 0;
+ break;
+
+ case AppleDRISurfaceNotifyChanged:
+ if (surface_hash != NULL)
+ {
+ lst = x_hash_table_lookup(surface_hash, (void *) arg->id, NULL);
+ for (; lst != NULL; lst = lst->next)
+ {
+ gc = lst->data;
+ xp_update_gl_context(gc->ctx);
+ }
+ }
+ break;
+ }
+}
+
+static void unattach(__GLcontext *gc)
+{
+ x_list *lst;
+
+ if (gc->isAttached)
+ {
+ GLAQUA_DEBUG_MSG("unattaching\n");
+
+ if (surface_hash != NULL)
+ {
+ lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL);
+ lst = x_list_remove(lst, gc);
+ x_hash_table_insert(surface_hash, (void *) gc->sid, lst);
+ }
+
+ CGLClearDrawable(gc->ctx);
+ gc->isAttached = FALSE;
+ gc->sid = 0;
+ }
+}
+
+static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv)
+{
+ __GLXdrawablePrivate *glxPriv;
+ GLAquaDrawableRec *aquaPriv;
+ DrawablePtr pDraw;
+
+ glxPriv = (__GLXdrawablePrivate *)glPriv->other;
+ aquaPriv = (GLAquaDrawableRec *)glPriv->private;
+ pDraw = glxPriv->pDraw;
+
+ if (aquaPriv->sid == 0)
+ {
+ if (!quartzProcs->CreateSurface(pDraw->pScreen, pDraw->id, pDraw,
+ 0, &aquaPriv->sid, NULL,
+ surface_notify, aquaPriv))
+ {
+ return;
+ }
+ aquaPriv->pDraw = pDraw;
+ }
+
+ if (!gc->isAttached || gc->sid != aquaPriv->sid)
+ {
+ x_list *lst;
+
+ if (xp_attach_gl_context(gc->ctx, aquaPriv->sid) != Success)
+ {
+ quartzProcs->DestroySurface(pDraw->pScreen, pDraw->id, pDraw,
+ surface_notify, aquaPriv);
+ if (surface_hash != NULL)
+ x_hash_table_remove(surface_hash, (void *) aquaPriv->sid);
+
+ aquaPriv->sid = 0;
+ return;
+ }
+
+ gc->isAttached = TRUE;
+ gc->sid = aquaPriv->sid;
+
+ if (surface_hash == NULL)
+ surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
+
+ lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL);
+ if (x_list_find(lst, gc) == NULL)
+ {
+ lst = x_list_prepend(lst, gc);
+ x_hash_table_insert(surface_hash, (void *) gc->sid, lst);
+ }
+
+ GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", (unsigned int) pDraw->id,
+ (unsigned int) aquaPriv->sid);
+ }
+}
+
+static GLboolean glAquaMakeCurrent(__GLcontext *gc)
+{
+ __GLdrawablePrivate *glPriv = gc->interface.imports.getDrawablePrivate(gc);
+ CGLError gl_err;
+
+ GLAQUA_DEBUG_MSG("glAquaMakeCurrent (ctx 0x%x)\n", (unsigned int) gc->ctx);
+
+ attach(gc, glPriv);
+
+ gl_err = CGLSetCurrentContext(gc->ctx);
+ if (gl_err != 0)
+ ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
+
+ return gl_err == 0;
+}
+
+static GLboolean glAquaShareContext(__GLcontext *gc, __GLcontext *gcShare)
+{
+ GLAQUA_DEBUG_MSG("glAquaShareContext unimplemented\n");
+
+ return GL_TRUE;
+}
+
+static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src,
+ GLuint mask)
+{
+ CGLError gl_err;
+
+ GLAQUA_DEBUG_MSG("glAquaCopyContext\n");
+
+ gl_err = CGLCopyContext(src->ctx, dst->ctx, mask);
+ if (gl_err != 0)
+ ErrorF("CGLCopyContext error: %s\n", CGLErrorString(gl_err));
+
+ return gl_err == 0;
+}
+
+static GLboolean glAquaForceCurrent(__GLcontext *gc)
+{
+ CGLError gl_err;
+
+ GLAQUA_DEBUG_MSG("glAquaForceCurrent (ctx 0x%x)\n",
+ (unsigned int) gc->ctx);
+
+ gl_err = CGLSetCurrentContext(gc->ctx);
+ if (gl_err != 0)
+ ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
+
+ return gl_err == 0;
+}
+
+/* Drawing surface notification callbacks */
+
+static GLboolean glAquaNotifyResize(__GLcontext *gc)
+{
+ GLAQUA_DEBUG_MSG("unimplemented glAquaNotifyResize");
+ return GL_TRUE;
+}
+
+static void glAquaNotifyDestroy(__GLcontext *gc)
+{
+ GLAQUA_DEBUG_MSG("unimplemented glAquaNotifyDestroy");
+}
+
+static void glAquaNotifySwapBuffers(__GLcontext *gc)
+{
+ GLAQUA_DEBUG_MSG("unimplemented glAquaNotifySwapBuffers");
+}
+
+/* Dispatch table override control for external agents like libGLS */
+static struct __GLdispatchStateRec* glAquaDispatchExec(__GLcontext *gc)
+{
+ GLAQUA_DEBUG_MSG("unimplemented glAquaDispatchExec");
+ return NULL;
+}
+
+static void glAquaBeginDispatchOverride(__GLcontext *gc)
+{
+ GLAQUA_DEBUG_MSG("unimplemented glAquaBeginDispatchOverride");
+}
+
+static void glAquaEndDispatchOverride(__GLcontext *gc)
+{
+ GLAQUA_DEBUG_MSG("unimplemented glAquaEndDispatchOverride");
+}
+
+static CGLPixelFormatObj makeFormat(__GLcontextModes *mode)
+{
+ int i;
+ CGLPixelFormatAttribute attr[64]; // currently uses max of 30
+ CGLPixelFormatObj result;
+ long n_formats;
+ CGLError gl_err;
+
+ GLAQUA_DEBUG_MSG("makeFormat\n");
+
+ if (!mode->rgbMode)
+ return NULL;
+
+ i = 0;
+
+ // attr [i++] = kCGLPFAAcelerated; // require hwaccel - BAD for multiscreen
+ // attr [i++] = kCGLPFANoRecovery; // disable fallback renderers - BAD
+
+ if (mode->stereoMode) {
+ attr[i++] = kCGLPFAStereo;
+ }
+ if (mode->doubleBufferMode) {
+ attr[i++] = kCGLPFADoubleBuffer;
+ }
+
+ if (mode->colorIndexMode) {
+ /* ignored */
+ }
+
+ if (mode->rgbMode) {
+ attr[i++] = kCGLPFAColorSize;
+ attr[i++] = mode->redBits + mode->greenBits + mode->blueBits;
+ attr[i++] = kCGLPFAAlphaSize;
+ attr[i++] = 1; /* FIXME: ignoring mode->alphaBits which is always 0 */
+ }
+
+ if (mode->haveAccumBuffer) {
+ attr[i++] = kCGLPFAAccumSize;
+ attr[i++] = mode->accumRedBits + mode->accumGreenBits
+ + mode->accumBlueBits + mode->accumAlphaBits;
+ }
+ if (mode->haveDepthBuffer) {
+ attr[i++] = kCGLPFADepthSize;
+ attr[i++] = mode->depthBits;
+ }
+ if (mode->haveStencilBuffer) {
+ attr[i++] = kCGLPFAStencilSize;
+ attr[i++] = mode->stencilBits;
+ }
+
+ attr[i++] = kCGLPFAAuxBuffers;
+ attr[i++] = mode->numAuxBuffers;
+
+ /* mode->level ignored */
+
+ /* mode->pixmapMode ? */
+
+ attr[i++] = 0;
+
+ GLAQUA_DEBUG_MSG("makeFormat almost done\n");
+
+ result = NULL;
+ gl_err = CGLChoosePixelFormat(attr, &result, &n_formats);
+ if (gl_err != 0)
+ ErrorF("CGLChoosePixelFormat error: %s\n", CGLErrorString(gl_err));
+
+ GLAQUA_DEBUG_MSG("makeFormat done (0x%x)\n", (unsigned int) result);
+
+ return result;
+}
+
+static __GLinterface *glAquaCreateContext(__GLimports *imports,
+ __GLcontextModes *mode,
+ __GLinterface *shareGC)
+{
+ __GLcontext *result;
+ __GLcontext *sharectx = (__GLcontext *)shareGC;
+ CGLError gl_err;
+
+ GLAQUA_DEBUG_MSG("glAquaCreateContext\n");
+
+ result = (__GLcontext *)calloc(1, sizeof(__GLcontext));
+ if (!result) return NULL;
+
+ result->interface.imports = *imports;
+ result->interface.exports = glAquaExports;
+
+ result->pixelFormat = makeFormat(mode);
+ if (!result->pixelFormat) {
+ free(result);
+ return NULL;
+ }
+
+ result->ctx = NULL;
+ gl_err = CGLCreateContext(result->pixelFormat,
+ sharectx ? sharectx->ctx : NULL,
+ &result->ctx);
+
+ if (gl_err != 0) {
+ ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err));
+ CGLDestroyPixelFormat(result->pixelFormat);
+ free(result);
+ return NULL;
+ }
+
+ GLAQUA_DEBUG_MSG("glAquaCreateContext done\n");
+ return (__GLinterface *)result;
+}
+
+Bool
+glAquaRealizeWindow(WindowPtr pWin)
+{
+ // If this window has GL contexts, tell them to reattach
+ Bool result;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ glAquaScreenRec *screenPriv = &glAquaScreens[pScreen->myNum];
+ __GLXdrawablePrivate *glxPriv;
+
+ GLAQUA_DEBUG_MSG("glAquaRealizeWindow\n");
+
+ // Allow the window to be created (RootlessRealizeWindow is inside our wrap)
+ pScreen->RealizeWindow = screenPriv->RealizeWindow;
+ result = pScreen->RealizeWindow(pWin);
+ pScreen->RealizeWindow = glAquaRealizeWindow;
+
+ // The Aqua window will already have been created (windows are
+ // realized from top down)
+
+ // Re-attach this window's GL contexts, if any.
+ glxPriv = __glXFindDrawablePrivate(pWin->drawable.id);
+ if (glxPriv) {
+ __GLXcontext *gx;
+ __GLcontext *gc;
+ __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
+ GLAQUA_DEBUG_MSG("glAquaRealizeWindow is GL drawable!\n");
+
+ // GL contexts bound to this window for drawing
+ for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) {
+ gc = (__GLcontext *)gx->gc;
+ attach(gc, glPriv);
+ }
+
+ // GL contexts bound to this window for reading
+ for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) {
+ gc = (__GLcontext *)gx->gc;
+ attach(gc, glPriv);
+ }
+ }
+
+ return result;
+}
+
+Bool
+glAquaUnrealizeWindow(WindowPtr pWin)
+{
+ // If this window has GL contexts, tell them to unattach
+ Bool result;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ glAquaScreenRec *screenPriv = &glAquaScreens[pScreen->myNum];
+ __GLXdrawablePrivate *glxPriv;
+
+ GLAQUA_DEBUG_MSG("glAquaUnrealizeWindow\n");
+
+ // The Aqua window may have already been destroyed (windows
+ // are unrealized from top down)
+
+ // Unattach this window's GL contexts, if any.
+ glxPriv = __glXFindDrawablePrivate(pWin->drawable.id);
+ if (glxPriv) {
+ __GLXcontext *gx;
+ __GLcontext *gc;
+ GLAQUA_DEBUG_MSG("glAquaUnealizeWindow is GL drawable!\n");
+
+ // GL contexts bound to this window for drawing
+ for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) {
+ gc = (__GLcontext *)gx->gc;
+ unattach(gc);
+ }
+
+ // GL contexts bound to this window for reading
+ for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) {
+ gc = (__GLcontext *)gx->gc;
+ unattach(gc);
+ }
+ }
+
+ pScreen->UnrealizeWindow = screenPriv->UnrealizeWindow;
+ result = pScreen->UnrealizeWindow(pWin);
+ pScreen->UnrealizeWindow = glAquaUnrealizeWindow;
+
+ return result;
+}
+
+
+// Originally copied from Mesa
+
+static int numConfigs = 0;
+static __GLXvisualConfig *visualConfigs = NULL;
+static void **visualPrivates = NULL;
+
+/*
+ * In the case the driver defines no GLX visuals we'll use these.
+ * Note that for TrueColor and DirectColor visuals, bufferSize is the
+ * sum of redSize, greenSize, blueSize and alphaSize, which may be larger
+ * than the nplanes/rootDepth of the server's X11 visuals
+ */
+#define NUM_FALLBACK_CONFIGS 5
+static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
+ /* [0] = RGB, double buffered, Z */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 0, 0, 0, 0, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 0, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [1] = RGB, double buffered, Z, stencil, accum */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 16, 16, 16, 0, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [2] = RGB+Alpha, double buffered, Z, stencil, accum */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 8, /* rgba sizes */
+ -1, -1, -1, -1, /* rgba masks */
+ 16, 16, 16, 16, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [3] = RGB+Alpha, single buffered, Z, stencil, accum */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 8, /* rgba sizes */
+ -1, -1, -1, -1, /* rgba masks */
+ 16, 16, 16, 16, /* rgba accum sizes */
+ False, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [4] = CI, double buffered, Z */
+ {
+ -1, /* vid */
+ -1, /* class */
+ False, /* rgba? (false = color index) */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 0, 0, 0, 0, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 0, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+};
+
+static __GLXvisualConfig NullConfig = {
+ -1, /* vid */
+ -1, /* class */
+ False, /* rgba */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 0, 0, 0, 0, /* rgba accum sizes */
+ False, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 0, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE_EXT, /* visualRating */
+ 0, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+};
+
+
+static inline int count_bits(uint32_t x)
+{
+ x = x - ((x >> 1) & 0x55555555);
+ x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
+ x = (x + (x >> 4)) & 0x0f0f0f0f;
+ x = x + (x >> 8);
+ x = x + (x >> 16);
+ return x & 63;
+}
+
+
+static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
+ VisualID *defaultVisp,
+ int ndepth, DepthPtr pdepth,
+ int rootDepth)
+{
+ int numRGBconfigs;
+ int numCIconfigs;
+ int numVisuals = *nvisualp;
+ int numNewVisuals;
+ int numNewConfigs;
+ VisualPtr pVisual = *visualp;
+ VisualPtr pVisualNew = NULL;
+ VisualID *orig_vid = NULL;
+ __GLcontextModes *modes;
+ __GLXvisualConfig *pNewVisualConfigs = NULL;
+ void **glXVisualPriv;
+ void **pNewVisualPriv;
+ int found_default;
+ int i, j, k;
+
+ GLAQUA_DEBUG_MSG("init_visuals\n");
+
+ if (numConfigs > 0)
+ numNewConfigs = numConfigs;
+ else
+ numNewConfigs = NUM_FALLBACK_CONFIGS;
+
+ /* Alloc space for the list of new GLX visuals */
+ pNewVisualConfigs = (__GLXvisualConfig *)
+ __glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig));
+ if (!pNewVisualConfigs) {
+ return FALSE;
+ }
+
+ /* Alloc space for the list of new GLX visual privates */
+ pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *));
+ if (!pNewVisualPriv) {
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /*
+ ** If SetVisualConfigs was not called, then use default GLX
+ ** visual configs.
+ */
+ if (numConfigs == 0) {
+ memcpy(pNewVisualConfigs, FallbackConfigs,
+ NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig));
+ memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *));
+ }
+ else {
+ /* copy driver's visual config info */
+ for (i = 0; i < numConfigs; i++) {
+ pNewVisualConfigs[i] = visualConfigs[i];
+ pNewVisualPriv[i] = visualPrivates[i];
+ }
+ }
+
+ /* Count the number of RGB and CI visual configs */
+ numRGBconfigs = 0;
+ numCIconfigs = 0;
+ for (i = 0; i < numNewConfigs; i++) {
+ if (pNewVisualConfigs[i].rgba)
+ numRGBconfigs++;
+ else
+ numCIconfigs++;
+ }
+
+ /* Count the total number of visuals to compute */
+ numNewVisuals = 0;
+ for (i = 0; i < numVisuals; i++) {
+ int count;
+
+ count = ((pVisual[i].class == TrueColor ||
+ pVisual[i].class == DirectColor)
+ ? numRGBconfigs : numCIconfigs);
+ if (count == 0)
+ count = 1; /* preserve the existing visual */
+
+ numNewVisuals += count;
+ }
+
+ /* Reset variables for use with the next screen/driver's visual configs */
+ visualConfigs = NULL;
+ numConfigs = 0;
+
+ /* Alloc temp space for the list of orig VisualIDs for each new visual */
+ orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID));
+ if (!orig_vid) {
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the list of glXVisuals */
+ modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes));
+ if (modes == NULL) {
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the list of glXVisualPrivates */
+ glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *));
+ if (!glXVisualPriv) {
+ _gl_context_modes_destroy( modes );
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the new list of the X server's visuals */
+ pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec));
+ if (!pVisualNew) {
+ __glXFree(glXVisualPriv);
+ _gl_context_modes_destroy( modes );
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Initialize the new visuals */
+ found_default = FALSE;
+ glAquaScreens[screenInfo.numScreens-1].modes = modes;
+ for (i = j = 0; i < numVisuals; i++) {
+ int is_rgb = (pVisual[i].class == TrueColor ||
+ pVisual[i].class == DirectColor);
+
+ if (!is_rgb)
+ {
+ /* We don't support non-rgb visuals for GL. But we don't
+ want to remove them either, so just pass them through
+ with null glX configs */
+
+ pVisualNew[j] = pVisual[i];
+ pVisualNew[j].vid = FakeClientID(0);
+
+ /* Check for the default visual */
+ if (!found_default && pVisual[i].vid == *defaultVisp) {
+ *defaultVisp = pVisualNew[j].vid;
+ found_default = TRUE;
+ }
+
+ /* Save the old VisualID */
+ orig_vid[j] = pVisual[i].vid;
+
+ /* Initialize the glXVisual */
+ _gl_copy_visual_to_context_mode( modes, & NullConfig );
+ modes->visualID = pVisualNew[j].vid;
+
+ j++;
+
+ continue;
+ }
+
+ for (k = 0; k < numNewConfigs; k++) {
+ if (pNewVisualConfigs[k].rgba != is_rgb)
+ continue;
+
+ assert( modes != NULL );
+
+ /* Initialize the new visual */
+ pVisualNew[j] = pVisual[i];
+ pVisualNew[j].vid = FakeClientID(0);
+
+ /* Check for the default visual */
+ if (!found_default && pVisual[i].vid == *defaultVisp) {
+ *defaultVisp = pVisualNew[j].vid;
+ found_default = TRUE;
+ }
+
+ /* Save the old VisualID */
+ orig_vid[j] = pVisual[i].vid;
+
+ /* Initialize the glXVisual */
+ _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] );
+ modes->visualID = pVisualNew[j].vid;
+
+ /*
+ * If the class is -1, then assume the X visual information
+ * is identical to what GLX needs, and take them from the X
+ * visual. NOTE: if class != -1, then all other fields MUST
+ * be initialized.
+ */
+ if (modes->visualType == GLX_NONE) {
+ modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class );
+ modes->redBits = count_bits(pVisual[i].redMask);
+ modes->greenBits = count_bits(pVisual[i].greenMask);
+ modes->blueBits = count_bits(pVisual[i].blueMask);
+ modes->alphaBits = modes->alphaBits;
+ modes->redMask = pVisual[i].redMask;
+ modes->greenMask = pVisual[i].greenMask;
+ modes->blueMask = pVisual[i].blueMask;
+ modes->alphaMask = modes->alphaMask;
+ modes->rgbBits = (is_rgb)
+ ? (modes->redBits + modes->greenBits +
+ modes->blueBits + modes->alphaBits)
+ : rootDepth;
+ }
+
+ /* Save the device-dependent private for this visual */
+ glXVisualPriv[j] = pNewVisualPriv[k];
+
+ j++;
+ modes = modes->next;
+ }
+ }
+
+ assert(j <= numNewVisuals);
+
+ /* Save the GLX visuals in the screen structure */
+ glAquaScreens[screenInfo.numScreens-1].num_vis = numNewVisuals;
+ glAquaScreens[screenInfo.numScreens-1].priv = glXVisualPriv;
+
+ /* Set up depth's VisualIDs */
+ for (i = 0; i < ndepth; i++) {
+ int numVids = 0;
+ VisualID *pVids = NULL;
+ int k, n = 0;
+
+ /* Count the new number of VisualIDs at this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numNewVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ numVids++;
+
+ /* Allocate a new list of VisualIDs for this depth */
+ pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID));
+
+ /* Initialize the new list of VisualIDs for this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numNewVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ pVids[n++] = pVisualNew[k].vid;
+
+ /* Update this depth's list of VisualIDs */
+ __glXFree(pdepth[i].vids);
+ pdepth[i].vids = pVids;
+ pdepth[i].numVids = numVids;
+ }
+
+ /* Update the X server's visuals */
+ *nvisualp = numNewVisuals;
+ *visualp = pVisualNew;
+
+ /* Free the old list of the X server's visuals */
+ __glXFree(pVisual);
+
+ /* Clean up temporary allocations */
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+
+ /* Free the private list created by DDX HW driver */
+ if (visualPrivates)
+ xfree(visualPrivates);
+ visualPrivates = NULL;
+
+ return TRUE;
+}
+
+/* based on code in i830_dri.c
+ This ends calling glAquaSetVisualConfigs to set the static
+ numconfigs, etc. */
+static void
+glAquaInitVisualConfigs(void)
+{
+ int lclNumConfigs = 0;
+ __GLXvisualConfig *lclVisualConfigs = NULL;
+ void **lclVisualPrivates = NULL;
+
+ int depth, aux, buffers, stencil, accum;
+ int i = 0;
+
+ GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs ");
+
+ /* count num configs:
+ 2 Z buffer (0, 24 bit)
+ 2 AUX buffer (0, 2)
+ 2 buffers (single, double)
+ 2 stencil (0, 8 bit)
+ 2 accum (0, 64 bit)
+ = 32 configs */
+
+ lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */
+
+ /* alloc */
+ lclVisualConfigs = xcalloc(sizeof(__GLXvisualConfig), lclNumConfigs);
+ lclVisualPrivates = xcalloc(sizeof(void *), lclNumConfigs);
+
+ /* fill in configs */
+ if (NULL != lclVisualConfigs) {
+ i = 0; /* current buffer */
+ for (depth = 0; depth < 2; depth++) {
+ for (aux = 0; aux < 2; aux++) {
+ for (buffers = 0; buffers < 2; buffers++) {
+ for (stencil = 0; stencil < 2; stencil++) {
+ for (accum = 0; accum < 2; accum++) {
+ lclVisualConfigs[i].vid = -1;
+ lclVisualConfigs[i].class = -1;
+ lclVisualConfigs[i].rgba = TRUE;
+ lclVisualConfigs[i].redSize = -1;
+ lclVisualConfigs[i].greenSize = -1;
+ lclVisualConfigs[i].blueSize = -1;
+ lclVisualConfigs[i].redMask = -1;
+ lclVisualConfigs[i].greenMask = -1;
+ lclVisualConfigs[i].blueMask = -1;
+ lclVisualConfigs[i].alphaMask = 0;
+ if (accum) {
+ lclVisualConfigs[i].accumRedSize = 16;
+ lclVisualConfigs[i].accumGreenSize = 16;
+ lclVisualConfigs[i].accumBlueSize = 16;
+ lclVisualConfigs[i].accumAlphaSize = 16;
+ }
+ else {
+ lclVisualConfigs[i].accumRedSize = 0;
+ lclVisualConfigs[i].accumGreenSize = 0;
+ lclVisualConfigs[i].accumBlueSize = 0;
+ lclVisualConfigs[i].accumAlphaSize = 0;
+ }
+ lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE;
+ lclVisualConfigs[i].stereo = FALSE;
+ lclVisualConfigs[i].bufferSize = -1;
+
+ lclVisualConfigs[i].depthSize = depth? 24 : 0;
+ lclVisualConfigs[i].stencilSize = stencil ? 8 : 0;
+ lclVisualConfigs[i].auxBuffers = aux ? 2 : 0;
+ lclVisualConfigs[i].level = 0;
+ lclVisualConfigs[i].visualRating = GLX_NONE_EXT;
+ lclVisualConfigs[i].transparentPixel = 0;
+ lclVisualConfigs[i].transparentRed = 0;
+ lclVisualConfigs[i].transparentGreen = 0;
+ lclVisualConfigs[i].transparentBlue = 0;
+ lclVisualConfigs[i].transparentAlpha = 0;
+ lclVisualConfigs[i].transparentIndex = 0;
+ i++;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (i != lclNumConfigs)
+ GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs failed to alloc visual configs");
+
+ GlxSetVisualConfigs(lclNumConfigs, lclVisualConfigs, lclVisualPrivates);
+}
+
+
+static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
+ void **privates)
+{
+ GLAQUA_DEBUG_MSG("glAquaSetVisualConfigs\n");
+
+ numConfigs = nconfigs;
+ visualConfigs = configs;
+ visualPrivates = privates;
+}
+
+static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
+ int *nvisualp, int *ndepthp,
+ int *rootDepthp, VisualID *defaultVisp,
+ unsigned long sizes, int bitsPerRGB)
+{
+ GLAQUA_DEBUG_MSG("glAquaInitVisuals\n");
+
+ if (numConfigs == 0) /* if no configs */
+ glAquaInitVisualConfigs(); /* ensure the visual configs are setup */
+
+ /*
+ * Setup the visuals supported by this particular screen.
+ */
+ return init_visuals(nvisualp, visualp, defaultVisp,
+ *ndepthp, *depthp, *rootDepthp);
+}
+
+
+static void fixup_visuals(int screen)
+{
+ ScreenPtr pScreen = screenInfo.screens[screen];
+ glAquaScreenRec *pScr = &glAquaScreens[screen];
+ int j;
+ __GLcontextModes *modes;
+
+ GLAQUA_DEBUG_MSG("fixup_visuals\n");
+
+ for ( modes = pScr->modes ; modes != NULL ; modes = modes->next ) {
+ const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+ const int nplanes = (modes->rgbBits - modes->alphaBits);
+ const VisualPtr pVis = pScreen->visuals;
+
+ /* Find a visual that matches the GLX visual's class and size */
+ for (j = 0; j < pScreen->numVisuals; j++) {
+ if (pVis[j].class == vis_class &&
+ pVis[j].nplanes == nplanes) {
+
+ /* Fixup the masks */
+ modes->redMask = pVis[j].redMask;
+ modes->greenMask = pVis[j].greenMask;
+ modes->blueMask = pVis[j].blueMask;
+
+ /* Recalc the sizes */
+ modes->redBits = count_bits(modes->redMask);
+ modes->greenBits = count_bits(modes->greenMask);
+ modes->blueBits = count_bits(modes->blueMask);
+ }
+ }
+ }
+}
+
+static void init_screen_visuals(int screen)
+{
+ ScreenPtr pScreen = screenInfo.screens[screen];
+ __GLcontextModes *modes;
+ int *used;
+ int i, j;
+
+ GLAQUA_DEBUG_MSG("init_screen_visuals\n");
+
+ /* FIXME: Change 'used' to be a array of bits (rather than of ints),
+ * FIXME: create a stack array of 8 or 16 bytes. If 'numVisuals' is less
+ * FIXME: than 64 or 128 the stack array can be used instead of calling
+ * FIXME: __glXMalloc / __glXFree. If nothing else, convert 'used' to
+ * FIXME: array of bytes instead of ints!
+ */
+ used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int));
+ __glXMemset(used, 0, pScreen->numVisuals * sizeof(int));
+
+ i = 0;
+ for ( modes = glAquaScreens[screen].modes
+ ; modes != NULL
+ ; modes = modes->next ) {
+ const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+ const int nplanes = (modes->rgbBits - modes->alphaBits);
+ const VisualPtr pVis = pScreen->visuals;
+
+ for (j = 0; j < pScreen->numVisuals; j++) {
+ if (pVis[j].class == vis_class &&
+ pVis[j].nplanes == nplanes &&
+ pVis[j].redMask == modes->redMask &&
+ pVis[j].greenMask == modes->greenMask &&
+ pVis[j].blueMask == modes->blueMask &&
+ !used[j]) {
+
+ /* Set the VisualID */
+ modes->visualID = pVis[j].vid;
+
+ /* Mark this visual used */
+ used[j] = 1;
+ break;
+ }
+ }
+ if ( j == pScreen->numVisuals ) {
+ ErrorF("No matching visual for __GLcontextMode with "
+ "visual class = %d (%d), nplanes = %u\n",
+ vis_class,
+ (int)modes->visualType,
+ (unsigned int)(modes->rgbBits - modes->alphaBits) );
+ }
+ else if ( modes->visualID == -1 ) {
+ FatalError( "Matching visual found, but visualID still -1!\n" );
+ }
+
+ i++;
+ }
+
+ __glXFree(used);
+}
+
+static Bool glAquaScreenProbe(int screen)
+{
+ ScreenPtr pScreen;
+ glAquaScreenRec *screenPriv;
+
+ GLAQUA_DEBUG_MSG("glAquaScreenProbe\n");
+
+ /*
+ * Set up the current screen's visuals.
+ */
+ __glDDXScreenInfo.modes = glAquaScreens[screen].modes;
+ __glDDXScreenInfo.pVisualPriv = glAquaScreens[screen].priv;
+ __glDDXScreenInfo.numVisuals =
+ __glDDXScreenInfo.numUsableVisuals = glAquaScreens[screen].num_vis;
+
+ /*
+ * Set the current screen's createContext routine. This could be
+ * wrapped by a DDX GLX context creation routine.
+ */
+ __glDDXScreenInfo.createContext = glAquaCreateContext;
+
+ /*
+ * The ordering of the rgb compenents might have been changed by the
+ * driver after mi initialized them.
+ */
+ fixup_visuals(screen);
+
+ /*
+ * Find the GLX visuals that are supported by this screen and create
+ * XMesa's visuals.
+ */
+ init_screen_visuals(screen);
+
+ /*
+ * Wrap RealizeWindow and UnrealizeWindow on this screen
+ */
+ pScreen = screenInfo.screens[screen];
+ screenPriv = &glAquaScreens[screen];
+ screenPriv->RealizeWindow = pScreen->RealizeWindow;
+ pScreen->RealizeWindow = glAquaRealizeWindow;
+ screenPriv->UnrealizeWindow = pScreen->UnrealizeWindow;
+ pScreen->UnrealizeWindow = glAquaUnrealizeWindow;
+
+ return TRUE;
+}
+
+static GLboolean glAquaSwapBuffers(__GLXdrawablePrivate *glxPriv)
+{
+ // swap buffers on only *one* of the contexts
+ // (e.g. the last one for drawing)
+ __GLcontext *gc = (__GLcontext *)glxPriv->drawGlxc->gc;
+ CGLError gl_err;
+
+ GLAQUA_DEBUG_MSG("glAquaSwapBuffers\n");
+
+ if (gc != NULL && gc->ctx != NULL)
+ {
+ gl_err = CGLFlushDrawable(gc->ctx);
+ if (gl_err != 0)
+ ErrorF("CGLFlushDrawable error: %s\n", CGLErrorString(gl_err));
+ }
+
+ return GL_TRUE;
+}
+
+static void glAquaDestroyDrawablePrivate(__GLdrawablePrivate *glPriv)
+{
+ GLAQUA_DEBUG_MSG("glAquaDestroyDrawablePrivate\n");
+
+ /* It doesn't work to call DRIDestroySurface here, the drawable's
+ already gone.. But dri.c notices the window destruction and
+ frees the surface itself. */
+
+ free(glPriv->private);
+ glPriv->private = NULL;
+}
+
+static void glAquaCreateBuffer(__GLXdrawablePrivate *glxPriv)
+{
+ GLAquaDrawableRec *aquaPriv = malloc(sizeof(GLAquaDrawableRec));
+ __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
+
+ aquaPriv->sid = 0;
+ aquaPriv->pDraw = NULL;
+
+ GLAQUA_DEBUG_MSG("glAquaCreateBuffer\n");
+
+ // replace swapBuffers (original is never called)
+ glxPriv->swapBuffers = glAquaSwapBuffers;
+
+ // stash private data
+ glPriv->private = aquaPriv;
+ glPriv->freePrivate = glAquaDestroyDrawablePrivate;
+}
+
+static void glAquaResetExtension(void)
+{
+ GLAQUA_DEBUG_MSG("glAquaResetExtension\n");
+ CGLSetOption(kCGLGOResetLibrary, GL_TRUE);
+}
+
+// Extra goodies for glx
+
+GLuint __glFloorLog2(GLuint val)
+{
+ int c = 0;
+
+ while (val > 1) {
+ c++;
+ val >>= 1;
+ }
+ return c;
+}
diff --git a/nx-X11/programs/Xserver/GL/dri/Imakefile b/nx-X11/programs/Xserver/GL/dri/Imakefile
new file mode 100644
index 000000000..8ea938f8c
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/dri/Imakefile
@@ -0,0 +1,35 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/dri/Imakefile,v 1.6 2001/04/28 13:55:36 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#if DoLoadableServer
+MSRC = drimodule.c
+MOBJ = drimodule.o
+#endif
+
+ SRCS = xf86dri.c dri.c $(MSRC)
+ OBJS = xf86dri.o dri.o $(MOBJ)
+
+ INCLUDES = -I$(SERVERSRC)/include -I$(INCLUDESRC) -I$(XINCLUDESRC) \
+ -I$(EXTINCSRC) -I$(MESASRCDIR)/include \
+ -I$(XF86OSSRC) -I$(XF86COMSRC) \
+ -I../include -I../glx -I$(LIBSRC)/GL/include \
+ -I$(DRMSRCDIR)/shared-core \
+ -I$(SERVERSRC)/mi -I$(FONTINCSRC)
+ DEFINES = $(GLX_DEFINES)
+
+LinkSourceFile(xf86dri.h,$(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(xf86dristr.h,$(MESASRCDIR)/src/glx/x11)
+
+ModuleObjectRule()
+LibraryModuleTarget(dri,$(OBJS))
+InstallLibraryModule(dri,$(MODULEDIR),extensions)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(dri,$(DRIVERSDKMODULEDIR),extensions)
+
+InstallDriverSDKNonExecFile(dri.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(sarea.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86dri.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/GL/dri/Imakefile.NX.reference b/nx-X11/programs/Xserver/GL/dri/Imakefile.NX.reference
new file mode 100644
index 000000000..59fb0af84
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/dri/Imakefile.NX.reference
@@ -0,0 +1,35 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/dri/Imakefile,v 1.7 2003/02/11 21:34:04 tsi Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#if DoLoadableServer
+MSRC = drimodule.c
+MOBJ = drimodule.o
+#endif
+
+ SRCS = xf86dri.c dri.c $(MSRC)
+ OBJS = xf86dri.o dri.o $(MOBJ)
+
+ INCLUDES = -I$(SERVERSRC)/include -I$(INCLUDESRC) -I$(XINCLUDESRC) \
+ -I$(EXTINCSRC) \
+ -I$(XF86OSSRC) -I$(XF86COMSRC) \
+ -I../include -I../glx -I$(LIBSRC)/GL/include \
+ -I$(SERVERSRC)/mi -I$(FONTINCSRC) \
+ -I../../hw/xfree86/os-support/bus
+ DEFINES = $(GLX_DEFINES)
+
+LinkSourceFile(xf86dri.h,$(LIBSRC)/GL/dri)
+LinkSourceFile(xf86dristr.h,$(LIBSRC)/GL/dri)
+
+ModuleObjectRule()
+LibraryModuleTarget(dri,$(OBJS))
+InstallLibraryModule(dri,$(MODULEDIR),extensions)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(dri,$(DRIVERSDKMODULEDIR),extensions)
+
+InstallDriverSDKNonExecFile(dri.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(sarea.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86dri.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/GL/dri/Imakefile.XF86.reference b/nx-X11/programs/Xserver/GL/dri/Imakefile.XF86.reference
new file mode 100644
index 000000000..c8770f6d8
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/dri/Imakefile.XF86.reference
@@ -0,0 +1,34 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/dri/Imakefile,v 1.7 2003/02/11 21:34:04 tsi Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#if DoLoadableServer
+MSRC = drimodule.c
+MOBJ = drimodule.o
+#endif
+
+ SRCS = xf86dri.c dri.c $(MSRC)
+ OBJS = xf86dri.o dri.o $(MOBJ)
+
+ INCLUDES = -I$(SERVERSRC)/include -I$(INCLUDESRC) -I$(XINCLUDESRC) \
+ -I$(EXTINCSRC) \
+ -I$(XF86OSSRC) -I$(XF86COMSRC) \
+ -I../include -I../glx -I$(LIBSRC)/GL/include \
+ -I$(SERVERSRC)/mi -I$(FONTINCSRC)
+ DEFINES = $(GLX_DEFINES)
+
+LinkSourceFile(xf86dri.h,$(LIBSRC)/GL/dri)
+LinkSourceFile(xf86dristr.h,$(LIBSRC)/GL/dri)
+
+ModuleObjectRule()
+LibraryModuleTarget(dri,$(OBJS))
+InstallLibraryModule(dri,$(MODULEDIR),extensions)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(dri,$(DRIVERSDKMODULEDIR),extensions)
+
+InstallDriverSDKNonExecFile(dri.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(sarea.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86dri.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/GL/dri/dri-def.cpp b/nx-X11/programs/Xserver/GL/dri/dri-def.cpp
new file mode 100644
index 000000000..0d1ab6872
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/dri/dri-def.cpp
@@ -0,0 +1,50 @@
+LIBRARY DRI
+VERSION LIBRARY_VERSION
+EXPORTS
+
+XFree86DRIExtensionInit
+DRIAuthConnection
+DRIBlockHandler
+DRIClipNotify
+DRICloseConnection
+DRICloseScreen
+DRIContextPrivDelete
+DRICopyWindow
+DRICreateContext
+DRICreateContextPriv
+DRICreateContextPrivFromHandle
+DRICreateDrawable
+DRICreateInfoRec
+DRIDestroyContext
+DRIDestroyContextPriv
+DRIDestroyDrawable
+DRIDestroyInfoRec
+DRIDoBlockHandler
+DRIDoWakeupHandler
+DRIDrawablePrivDelete
+DRIExtensionInit
+DRIFinishScreenInit
+DRIGetClientDriverName
+DRIGetContext
+DRIGetContextStore
+DRIGetDeviceInfo
+DRIGetDrawableIndex
+DRIGetDrawableInfo
+DRIGetDrawableStamp
+DRIGetSAREAPrivate
+DRIGetWrappedFuncs
+DRILock
+DRIOpenConnection
+DRIPaintWindow
+DRIPostValidateTree
+DRIPrintDrawableLock
+DRIQueryDirectRenderingCapable
+DRIQueryVersion
+DRIReset
+DRIScreenInit
+DRISwapContext
+DRIUnlock
+DRIValidateTree
+DRIWakeupHandler
+
+/* $XFree86$ */
diff --git a/nx-X11/programs/Xserver/GL/dri/dri.c b/nx-X11/programs/Xserver/GL/dri/dri.c
new file mode 100644
index 000000000..424a21c68
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/dri/dri.c
@@ -0,0 +1,2109 @@
+/* $XFree86: xc/programs/Xserver/GL/dri/dri.c,v 1.39 2003/11/10 18:21:41 tsi Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Jens Owen <jens@tungstengraphics.com>
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#ifdef XFree86LOADER
+#include "xf86_ansic.h"
+#else
+#include <sys/time.h>
+#include <unistd.h>
+#endif
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#define _XF86DRI_SERVER_
+#include "xf86dristr.h"
+#include "swaprep.h"
+#include "xf86str.h"
+#include "dri.h"
+#include "sarea.h"
+#include "dristruct.h"
+#include "xf86.h"
+#include "xf86drm.h"
+#include "glxserver.h"
+#include "mi.h"
+#include "mipointer.h"
+
+#if defined(XFree86LOADER) && !defined(PANORAMIX)
+extern Bool noPanoramiXExtension;
+#endif
+
+static int DRIScreenPrivIndex = -1;
+static int DRIWindowPrivIndex = -1;
+static unsigned long DRIGeneration = 0;
+static unsigned int DRIDrawableValidationStamp = 0;
+
+static RESTYPE DRIDrawablePrivResType;
+static RESTYPE DRIContextPrivResType;
+static void DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv);
+
+ /* Wrapper just like xf86DrvMsg, but
+ without the verbosity level checking.
+ This will make it easy to turn off some
+ messages later, based on verbosity
+ level. */
+
+/*
+ * Since we're already referencing things from the XFree86 common layer in
+ * this file, we'd might as well just call xf86VDrvMsgVerb, and have
+ * consistent message formatting. The verbosity of these messages can be
+ * easily changed here.
+ */
+#define DRI_MSG_VERBOSITY 1
+static void
+DRIDrvMsg(int scrnIndex, MessageType type, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ xf86VDrvMsgVerb(scrnIndex, type, DRI_MSG_VERBOSITY, format, ap);
+ va_end(ap);
+}
+
+Bool
+DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
+{
+ DRIScreenPrivPtr pDRIPriv;
+ drm_context_t * reserved;
+ int reserved_count;
+ int i, fd, drmWasAvailable;
+ Bool xineramaInCore = FALSE;
+ int err = 0;
+ char *openbusid;
+ drmVersionPtr drmlibv;
+ int drmlibmajor, drmlibminor, drmdimajor, drmdiminor;
+
+ if (DRIGeneration != serverGeneration) {
+ if ((DRIScreenPrivIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+ DRIGeneration = serverGeneration;
+ }
+
+ /* If the DRI extension is disabled, do not initialize the DRI */
+ if (noXFree86DRIExtension) {
+ DRIDrvMsg(pScreen->myNum, X_WARNING,
+ "Direct rendering has been disabled.\n");
+ return FALSE;
+ }
+
+ /*
+ * If Xinerama is on, don't allow DRI to initialise. It won't be usable
+ * anyway.
+ */
+#if defined(PANORAMIX) && !defined(XFree86LOADER)
+ xineramaInCore = TRUE;
+#elif defined(XFree86LOADER)
+ if (xf86LoaderCheckSymbol("noPanoramiXExtension"))
+ xineramaInCore = TRUE;
+#endif
+
+#if defined(PANORAMIX) || defined(XFree86LOADER)
+ if (xineramaInCore) {
+ if (!noPanoramiXExtension) {
+ DRIDrvMsg(pScreen->myNum, X_WARNING,
+ "Direct rendering is not supported when Xinerama is enabled\n");
+ return FALSE;
+ }
+ }
+#endif
+
+ drmWasAvailable = drmAvailable();
+
+ /* Check the DRM lib version.
+ * drmGetLibVersion was not supported in version 1.0, so check for
+ * symbol first to avoid possible crash or hang.
+ */
+ drmlibmajor = 1;
+ drmlibminor = 0;
+ if (xf86LoaderCheckSymbol("drmGetLibVersion")) {
+ drmlibv = drmGetLibVersion(-1);
+ if (drmlibv != NULL) {
+ drmlibmajor = drmlibv->version_major;
+ drmlibminor = drmlibv->version_minor;
+ drmFreeVersion(drmlibv);
+ }
+ }
+
+ /* Check if the libdrm can handle falling back to loading based on name
+ * if a busid string is passed.
+ */
+ if (drmlibmajor == 1 && drmlibminor >= 2)
+ openbusid = pDRIInfo->busIdString;
+ else
+ openbusid = NULL;
+
+ /* Note that drmOpen will try to load the kernel module, if needed. */
+ fd = drmOpen(pDRIInfo->drmDriverName, openbusid);
+ if (fd < 0) {
+ /* failed to open DRM */
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] drmOpen failed\n");
+ return FALSE;
+ }
+
+ if (!drmWasAvailable) {
+ /* drmOpen loaded the kernel module, print a message to say so */
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] loaded kernel module for \"%s\" driver\n",
+ pDRIInfo->drmDriverName);
+ }
+
+ pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec));
+ if (!pDRIPriv) {
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ return FALSE;
+ }
+
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = (pointer) pDRIPriv;
+ pDRIPriv->drmFD = fd;
+ pDRIPriv->directRenderingSupport = TRUE;
+ pDRIPriv->pDriverInfo = pDRIInfo;
+ pDRIPriv->nrWindows = 0;
+ pDRIPriv->fullscreen = NULL;
+
+ pDRIPriv->createDummyCtx = pDRIInfo->createDummyCtx;
+ pDRIPriv->createDummyCtxPriv = pDRIInfo->createDummyCtxPriv;
+
+ pDRIPriv->grabbedDRILock = FALSE;
+ pDRIPriv->drmSIGIOHandlerInstalled = FALSE;
+
+ if (drmlibmajor == 1 && drmlibminor >= 2) {
+ drmSetVersion sv;
+
+ /* Get the interface version, asking for 1.1. */
+ sv.drm_di_major = 1;
+ sv.drm_di_minor = 1;
+ sv.drm_dd_major = -1;
+ err = drmSetInterfaceVersion(pDRIPriv->drmFD, &sv);
+ if (err == 0) {
+ drmdimajor = sv.drm_di_major;
+ drmdiminor = sv.drm_di_minor;
+ } else {
+ /* failure, so set it to 1.0.0. */
+ drmdimajor = 1;
+ drmdiminor = 0;
+ }
+ }
+ else {
+ /* We can't check the DI DRM interface version, so set it to 1.0.0. */
+ drmdimajor = 1;
+ drmdiminor = 0;
+ }
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] DRM interface version %d.%d\n", drmdimajor, drmdiminor);
+
+ /* If the interface minor number is 1.1, then we've opened a DRM device
+ * that already had the busid set through drmOpen.
+ */
+ if (drmdimajor == 1 && drmdiminor >= 1)
+ err = 0;
+ else
+ err = drmSetBusid(pDRIPriv->drmFD, pDRIPriv->pDriverInfo->busIdString);
+
+ if (err < 0) {
+ pDRIPriv->directRenderingSupport = FALSE;
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ drmClose(pDRIPriv->drmFD);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] drmSetBusid failed (%d, %s), %s\n",
+ pDRIPriv->drmFD, pDRIPriv->pDriverInfo->busIdString, strerror(-err));
+ return FALSE;
+ }
+
+ *pDRMFD = pDRIPriv->drmFD;
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] created \"%s\" driver at busid \"%s\"\n",
+ pDRIPriv->pDriverInfo->drmDriverName,
+ pDRIPriv->pDriverInfo->busIdString);
+
+ if (drmAddMap( pDRIPriv->drmFD,
+ 0,
+ pDRIPriv->pDriverInfo->SAREASize,
+ DRM_SHM,
+ DRM_CONTAINS_LOCK,
+ &pDRIPriv->hSAREA) < 0)
+ {
+ pDRIPriv->directRenderingSupport = FALSE;
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ drmClose(pDRIPriv->drmFD);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] drmAddMap failed\n");
+ return FALSE;
+ }
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] added %d byte SAREA at %p\n",
+ pDRIPriv->pDriverInfo->SAREASize, pDRIPriv->hSAREA);
+
+ if (drmMap( pDRIPriv->drmFD,
+ pDRIPriv->hSAREA,
+ pDRIPriv->pDriverInfo->SAREASize,
+ (drmAddressPtr)(&pDRIPriv->pSAREA)) < 0)
+ {
+ pDRIPriv->directRenderingSupport = FALSE;
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ drmClose(pDRIPriv->drmFD);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] drmMap failed\n");
+ return FALSE;
+ }
+ memset(pDRIPriv->pSAREA, 0, pDRIPriv->pDriverInfo->SAREASize);
+ DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] mapped SAREA %p to %p\n",
+ pDRIPriv->hSAREA, pDRIPriv->pSAREA);
+
+ if (drmAddMap( pDRIPriv->drmFD,
+ (drm_handle_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress,
+ pDRIPriv->pDriverInfo->frameBufferSize,
+ DRM_FRAME_BUFFER,
+ 0,
+ &pDRIPriv->hFrameBuffer) < 0)
+ {
+ pDRIPriv->directRenderingSupport = FALSE;
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize);
+ drmClose(pDRIPriv->drmFD);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] drmAddMap failed\n");
+ return FALSE;
+ }
+ DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] framebuffer handle = %p\n",
+ pDRIPriv->hFrameBuffer);
+
+ /* Add tags for reserved contexts */
+ if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
+ &reserved_count))) {
+ int i;
+ void *tag;
+
+ for (i = 0; i < reserved_count; i++) {
+ tag = DRICreateContextPrivFromHandle(pScreen,
+ reserved[i],
+ DRI_CONTEXT_RESERVED);
+ drmAddContextTag(pDRIPriv->drmFD, reserved[i], tag);
+ }
+ drmFreeReservedContextList(reserved);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] added %d reserved context%s for kernel\n",
+ reserved_count, reserved_count > 1 ? "s" : "");
+ }
+
+ /* validate max drawable table entry set by driver */
+ if ((pDRIPriv->pDriverInfo->maxDrawableTableEntry <= 0) ||
+ (pDRIPriv->pDriverInfo->maxDrawableTableEntry > SAREA_MAX_DRAWABLES)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "Invalid max drawable table size set by driver: %d\n",
+ pDRIPriv->pDriverInfo->maxDrawableTableEntry);
+ }
+
+ /* Initialize drawable tables (screen private and SAREA) */
+ for( i=0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) {
+ pDRIPriv->DRIDrawables[i] = NULL;
+ pDRIPriv->pSAREA->drawableTable[i].stamp = 0;
+ pDRIPriv->pSAREA->drawableTable[i].flags = 0;
+ }
+
+ return TRUE;
+}
+
+Bool
+DRIFinishScreenInit(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
+ DRIContextFlags flags = 0;
+ DRIContextPrivPtr pDRIContextPriv;
+
+ /* Set up flags for DRICreateContextPriv */
+ switch (pDRIInfo->driverSwapMethod) {
+ case DRI_KERNEL_SWAP: flags = DRI_CONTEXT_2DONLY; break;
+ case DRI_HIDE_X_CONTEXT: flags = DRI_CONTEXT_PRESERVED; break;
+ }
+
+ if (!(pDRIContextPriv = DRICreateContextPriv(pScreen,
+ &pDRIPriv->myContext,
+ flags))) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "failed to create server context\n");
+ return FALSE;
+ }
+ pDRIPriv->myContextPriv = pDRIContextPriv;
+
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "X context handle = %p\n", pDRIPriv->myContext);
+
+ /* Now that we have created the X server's context, we can grab the
+ * hardware lock for the X server.
+ */
+ DRILock(pScreen, 0);
+ pDRIPriv->grabbedDRILock = TRUE;
+
+ /* pointers so that we can prevent memory leaks later */
+ pDRIPriv->hiddenContextStore = NULL;
+ pDRIPriv->partial3DContextStore = NULL;
+
+ switch(pDRIInfo->driverSwapMethod) {
+ case DRI_HIDE_X_CONTEXT:
+ /* Server will handle 3D swaps, and hide 2D swaps from kernel.
+ * Register server context as a preserved context.
+ */
+
+ /* allocate memory for hidden context store */
+ pDRIPriv->hiddenContextStore
+ = (void *)xcalloc(1, pDRIInfo->contextSize);
+ if (!pDRIPriv->hiddenContextStore) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "failed to allocate hidden context\n");
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return FALSE;
+ }
+
+ /* allocate memory for partial 3D context store */
+ pDRIPriv->partial3DContextStore
+ = (void *)xcalloc(1, pDRIInfo->contextSize);
+ if (!pDRIPriv->partial3DContextStore) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI] failed to allocate partial 3D context\n");
+ xfree(pDRIPriv->hiddenContextStore);
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return FALSE;
+ }
+
+ /* save initial context store */
+ if (pDRIInfo->SwapContext) {
+ (*pDRIInfo->SwapContext)(
+ pScreen,
+ DRI_NO_SYNC,
+ DRI_2D_CONTEXT,
+ pDRIPriv->hiddenContextStore,
+ DRI_NO_CONTEXT,
+ NULL);
+ }
+ /* fall through */
+
+ case DRI_SERVER_SWAP:
+ /* For swap methods of DRI_SERVER_SWAP and DRI_HIDE_X_CONTEXT
+ * setup signal handler for receiving swap requests from kernel
+ */
+ if (!(pDRIPriv->drmSIGIOHandlerInstalled =
+ drmInstallSIGIOHandler(pDRIPriv->drmFD, DRISwapContext))) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] failed to setup DRM signal handler\n");
+ if (pDRIPriv->hiddenContextStore)
+ xfree(pDRIPriv->hiddenContextStore);
+ if (pDRIPriv->partial3DContextStore)
+ xfree(pDRIPriv->partial3DContextStore);
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return FALSE;
+ } else {
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] installed DRM signal handler\n");
+ }
+
+ default:
+ break;
+ }
+
+ /* Wrap DRI support */
+ if (pDRIInfo->wrap.ValidateTree) {
+ pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
+ pScreen->ValidateTree = pDRIInfo->wrap.ValidateTree;
+ }
+ if (pDRIInfo->wrap.PostValidateTree) {
+ pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
+ pScreen->PostValidateTree = pDRIInfo->wrap.PostValidateTree;
+ }
+ if (pDRIInfo->wrap.WindowExposures) {
+ pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
+ pScreen->WindowExposures = pDRIInfo->wrap.WindowExposures;
+ }
+ if (pDRIInfo->wrap.CopyWindow) {
+ pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = pDRIInfo->wrap.CopyWindow;
+ }
+ if (pDRIInfo->wrap.ClipNotify) {
+ pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
+ pScreen->ClipNotify = pDRIInfo->wrap.ClipNotify;
+ }
+ if (pDRIInfo->wrap.AdjustFrame) {
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame;
+ pScrn->AdjustFrame = pDRIInfo->wrap.AdjustFrame;
+ }
+ pDRIPriv->wrapped = TRUE;
+
+ DRIDrvMsg(pScreen->myNum, X_INFO, "[DRI] installation complete\n");
+
+ return TRUE;
+}
+
+void
+DRICloseScreen(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIInfoPtr pDRIInfo;
+ drm_context_t * reserved;
+ int reserved_count;
+
+ if (pDRIPriv && pDRIPriv->directRenderingSupport) {
+
+ pDRIInfo = pDRIPriv->pDriverInfo;
+
+ if (pDRIPriv->wrapped) {
+ /* Unwrap DRI Functions */
+ if (pDRIInfo->wrap.ValidateTree) {
+ pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
+ pDRIPriv->wrap.ValidateTree = NULL;
+ }
+ if (pDRIInfo->wrap.PostValidateTree) {
+ pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
+ pDRIPriv->wrap.PostValidateTree = NULL;
+ }
+ if (pDRIInfo->wrap.WindowExposures) {
+ pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
+ pDRIPriv->wrap.WindowExposures = NULL;
+ }
+ if (pDRIInfo->wrap.CopyWindow) {
+ pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
+ pDRIPriv->wrap.CopyWindow = NULL;
+ }
+ if (pDRIInfo->wrap.ClipNotify) {
+ pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
+ pDRIPriv->wrap.ClipNotify = NULL;
+ }
+ if (pDRIInfo->wrap.AdjustFrame) {
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
+ pDRIPriv->wrap.AdjustFrame = NULL;
+ }
+ pDRIPriv->wrapped = FALSE;
+ }
+
+ if (pDRIPriv->drmSIGIOHandlerInstalled) {
+ if (!drmRemoveSIGIOHandler(pDRIPriv->drmFD)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] failed to remove DRM signal handler\n");
+ }
+ }
+
+ if (pDRIPriv->dummyCtxPriv && pDRIPriv->createDummyCtx) {
+ DRIDestroyDummyContext(pScreen, pDRIPriv->createDummyCtxPriv);
+ }
+
+ if (!DRIDestroyContextPriv(pDRIPriv->myContextPriv)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "failed to destroy server context\n");
+ }
+
+ /* Remove tags for reserved contexts */
+ if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
+ &reserved_count))) {
+ int i;
+
+ for (i = 0; i < reserved_count; i++) {
+ DRIDestroyContextPriv(drmGetContextTag(pDRIPriv->drmFD,
+ reserved[i]));
+ }
+ drmFreeReservedContextList(reserved);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] removed %d reserved context%s for kernel\n",
+ reserved_count, reserved_count > 1 ? "s" : "");
+ }
+
+ /* Make sure signals get unblocked etc. */
+ drmUnlock(pDRIPriv->drmFD, pDRIPriv->myContext);
+ pDRIPriv->lockRefCount = 0;
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] unmapping %d bytes of SAREA %p at %p\n",
+ pDRIInfo->SAREASize,
+ pDRIPriv->hSAREA,
+ pDRIPriv->pSAREA);
+ if (drmUnmap(pDRIPriv->pSAREA, pDRIInfo->SAREASize)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] unable to unmap %d bytes"
+ " of SAREA %p at %p\n",
+ pDRIInfo->SAREASize,
+ pDRIPriv->hSAREA,
+ pDRIPriv->pSAREA);
+ }
+
+ drmClose(pDRIPriv->drmFD);
+
+ xfree(pDRIPriv);
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ }
+}
+
+Bool
+DRIExtensionInit(void)
+{
+ int i;
+ ScreenPtr pScreen;
+
+ if (DRIScreenPrivIndex < 0) {
+ return FALSE;
+ }
+
+ /* Allocate a window private index with a zero sized private area for
+ * each window, then should a window become a DRI window, we'll hang
+ * a DRIWindowPrivateRec off of this private index.
+ */
+ if ((DRIWindowPrivIndex = AllocateWindowPrivateIndex()) < 0)
+ return FALSE;
+
+ DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete);
+ DRIContextPrivResType = CreateNewResourceType(DRIContextPrivDelete);
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ pScreen = screenInfo.screens[i];
+ if (!AllocateWindowPrivate(pScreen, DRIWindowPrivIndex, 0))
+ return FALSE;
+ }
+
+ RegisterBlockAndWakeupHandlers(DRIBlockHandler, DRIWakeupHandler, NULL);
+
+ return TRUE;
+}
+
+void
+DRIReset(void)
+{
+ /*
+ * This stub routine is called when the X Server recycles, resources
+ * allocated by DRIExtensionInit need to be managed here.
+ *
+ * Currently this routine is a stub because all the interesting resources
+ * are managed via the screen init process.
+ */
+}
+
+Bool
+DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (pDRIPriv)
+ *isCapable = pDRIPriv->directRenderingSupport;
+ else
+ *isCapable = FALSE;
+
+ return TRUE;
+}
+
+Bool
+DRIOpenConnection(ScreenPtr pScreen, drm_handle_t * hSAREA, char **busIdString)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ *hSAREA = pDRIPriv->hSAREA;
+ *busIdString = pDRIPriv->pDriverInfo->busIdString;
+
+ return TRUE;
+}
+
+Bool
+DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE;
+ return TRUE;
+}
+
+Bool
+DRICloseConnection(ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+Bool
+DRIGetClientDriverName(ScreenPtr pScreen,
+ int *ddxDriverMajorVersion,
+ int *ddxDriverMinorVersion,
+ int *ddxDriverPatchVersion,
+ char **clientDriverName)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ *ddxDriverMajorVersion = pDRIPriv->pDriverInfo->ddxDriverMajorVersion;
+ *ddxDriverMinorVersion = pDRIPriv->pDriverInfo->ddxDriverMinorVersion;
+ *ddxDriverPatchVersion = pDRIPriv->pDriverInfo->ddxDriverPatchVersion;
+ *clientDriverName = pDRIPriv->pDriverInfo->clientDriverName;
+
+ return TRUE;
+}
+
+/* DRICreateContextPriv and DRICreateContextPrivFromHandle are helper
+ functions that layer on drmCreateContext and drmAddContextTag.
+
+ DRICreateContextPriv always creates a kernel drm_context_t and then calls
+ DRICreateContextPrivFromHandle to create a DRIContextPriv structure for
+ DRI tracking. For the SIGIO handler, the drm_context_t is associated with
+ DRIContextPrivPtr. Any special flags are stored in the DRIContextPriv
+ area and are passed to the kernel (if necessary).
+
+ DRICreateContextPriv returns a pointer to newly allocated
+ DRIContextPriv, and returns the kernel drm_context_t in pHWContext. */
+
+DRIContextPrivPtr
+DRICreateContextPriv(ScreenPtr pScreen,
+ drm_context_t * pHWContext,
+ DRIContextFlags flags)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (drmCreateContext(pDRIPriv->drmFD, pHWContext)) {
+ return NULL;
+ }
+
+ return DRICreateContextPrivFromHandle(pScreen, *pHWContext, flags);
+}
+
+DRIContextPrivPtr
+DRICreateContextPrivFromHandle(ScreenPtr pScreen,
+ drm_context_t hHWContext,
+ DRIContextFlags flags)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIContextPrivPtr pDRIContextPriv;
+ int contextPrivSize;
+
+ contextPrivSize = sizeof(DRIContextPrivRec) +
+ pDRIPriv->pDriverInfo->contextSize;
+ if (!(pDRIContextPriv = xcalloc(1, contextPrivSize))) {
+ return NULL;
+ }
+ pDRIContextPriv->pContextStore = (void *)(pDRIContextPriv + 1);
+
+ drmAddContextTag(pDRIPriv->drmFD, hHWContext, pDRIContextPriv);
+
+ pDRIContextPriv->hwContext = hHWContext;
+ pDRIContextPriv->pScreen = pScreen;
+ pDRIContextPriv->flags = flags;
+ pDRIContextPriv->valid3D = FALSE;
+
+ if (flags & DRI_CONTEXT_2DONLY) {
+ if (drmSetContextFlags(pDRIPriv->drmFD,
+ hHWContext,
+ DRM_CONTEXT_2DONLY)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] failed to set 2D context flag\n");
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return NULL;
+ }
+ }
+ if (flags & DRI_CONTEXT_PRESERVED) {
+ if (drmSetContextFlags(pDRIPriv->drmFD,
+ hHWContext,
+ DRM_CONTEXT_PRESERVED)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] failed to set preserved flag\n");
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return NULL;
+ }
+ }
+ return pDRIContextPriv;
+}
+
+Bool
+DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv)
+{
+ DRIScreenPrivPtr pDRIPriv;
+
+ if (!pDRIContextPriv) return TRUE;
+
+ pDRIPriv = DRI_SCREEN_PRIV(pDRIContextPriv->pScreen);
+
+ if (!(pDRIContextPriv->flags & DRI_CONTEXT_RESERVED)) {
+ /* Don't delete reserved contexts from
+ kernel area -- the kernel manages its
+ reserved contexts itself. */
+ if (drmDestroyContext(pDRIPriv->drmFD, pDRIContextPriv->hwContext))
+ return FALSE;
+ }
+
+ /* Remove the tag last to prevent a race
+ condition where the context has pending
+ buffers. The context can't be re-used
+ while in this thread, but buffers can be
+ dispatched asynchronously. */
+ drmDelContextTag(pDRIPriv->drmFD, pDRIContextPriv->hwContext);
+ xfree(pDRIContextPriv);
+ return TRUE;
+}
+
+static Bool
+DRICreateDummyContext(ScreenPtr pScreen, Bool needCtxPriv)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ __GLXscreenInfo *pGLXScreen = __glXgetActiveScreen(pScreen->myNum);
+ __GLcontextModes *modes = pGLXScreen->modes;
+ void **pVisualConfigPriv = pGLXScreen->pVisualPriv;
+ DRIContextPrivPtr pDRIContextPriv;
+ void *contextStore;
+ VisualPtr visual;
+ int visNum;
+
+ visual = pScreen->visuals;
+
+ /* Find the X visual that corresponds the the first GLX visual */
+ for (visNum = 0;
+ visNum < pScreen->numVisuals;
+ visNum++, visual++) {
+ if (modes->visualID == visual->vid)
+ break;
+ }
+ if (visNum == pScreen->numVisuals) return FALSE;
+
+ if (!(pDRIContextPriv =
+ DRICreateContextPriv(pScreen,
+ &pDRIPriv->pSAREA->dummy_context, 0))) {
+ return FALSE;
+ }
+
+ contextStore = DRIGetContextStore(pDRIContextPriv);
+ if (pDRIPriv->pDriverInfo->CreateContext && needCtxPriv) {
+ if (!pDRIPriv->pDriverInfo->CreateContext(pScreen, visual,
+ pDRIPriv->pSAREA->dummy_context,
+ *pVisualConfigPriv,
+ (DRIContextType)(long)contextStore)) {
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return FALSE;
+ }
+ }
+
+ pDRIPriv->dummyCtxPriv = pDRIContextPriv;
+ return TRUE;
+}
+
+static void
+DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIContextPrivPtr pDRIContextPriv = pDRIPriv->dummyCtxPriv;
+ void *contextStore;
+
+ if (!pDRIContextPriv) return;
+ if (pDRIPriv->pDriverInfo->DestroyContext && hasCtxPriv) {
+ contextStore = DRIGetContextStore(pDRIContextPriv);
+ pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen,
+ pDRIContextPriv->hwContext,
+ (DRIContextType)(long)contextStore);
+ }
+
+ DRIDestroyContextPriv(pDRIPriv->dummyCtxPriv);
+ pDRIPriv->dummyCtxPriv = NULL;
+}
+
+Bool
+DRICreateContext(ScreenPtr pScreen, VisualPtr visual,
+ XID context, drm_context_t * pHWContext)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ __GLXscreenInfo *pGLXScreen = __glXgetActiveScreen(pScreen->myNum);
+ __GLcontextModes *modes = pGLXScreen->modes;
+ void **pVisualConfigPriv = pGLXScreen->pVisualPriv;
+ DRIContextPrivPtr pDRIContextPriv;
+ void *contextStore;
+
+ if (pDRIPriv->createDummyCtx && !pDRIPriv->dummyCtxPriv) {
+ if (!DRICreateDummyContext(pScreen, pDRIPriv->createDummyCtxPriv)) {
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] Could not create dummy context\n");
+ return FALSE;
+ }
+ }
+
+ /* Find the GLX visual associated with the one requested */
+ for (modes = pGLXScreen->modes; modes != NULL; modes = modes->next) {
+ if (modes->visualID == visual->vid)
+ break;
+ pVisualConfigPriv++;
+ }
+
+ if (modes == NULL) {
+ /* No matching GLX visual found */
+ return FALSE;
+ }
+
+ if (!(pDRIContextPriv = DRICreateContextPriv(pScreen, pHWContext, 0))) {
+ return FALSE;
+ }
+
+ contextStore = DRIGetContextStore(pDRIContextPriv);
+ if (pDRIPriv->pDriverInfo->CreateContext) {
+ if (!((*pDRIPriv->pDriverInfo->CreateContext)(pScreen, visual,
+ *pHWContext, *pVisualConfigPriv,
+ (DRIContextType)(long)contextStore))) {
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return FALSE;
+ }
+ }
+
+ /* track this in case the client dies before cleanup */
+ AddResource(context, DRIContextPrivResType, (pointer)pDRIContextPriv);
+
+ return TRUE;
+}
+
+Bool
+DRIDestroyContext(ScreenPtr pScreen, XID context)
+{
+ FreeResourceByType(context, DRIContextPrivResType, FALSE);
+
+ return TRUE;
+}
+
+/* DRIContextPrivDelete is called by the resource manager. */
+Bool
+DRIContextPrivDelete(pointer pResource, XID id)
+{
+ DRIContextPrivPtr pDRIContextPriv = (DRIContextPrivPtr)pResource;
+ DRIScreenPrivPtr pDRIPriv;
+ void *contextStore;
+
+ pDRIPriv = DRI_SCREEN_PRIV(pDRIContextPriv->pScreen);
+ if (pDRIPriv->pDriverInfo->DestroyContext) {
+ contextStore = DRIGetContextStore(pDRIContextPriv);
+ pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen,
+ pDRIContextPriv->hwContext,
+ (DRIContextType)(long)contextStore);
+ }
+ return DRIDestroyContextPriv(pDRIContextPriv);
+}
+
+
+/* This walks the drawable timestamp array and invalidates all of them
+ * in the case of transition from private to shared backbuffers. It's
+ * not necessary for correctness, because DRIClipNotify gets called in
+ * time to prevent any conflict, but the transition from
+ * shared->private is sometimes missed if we don't do this.
+ */
+static void
+DRIClipNotifyAllDrawables(ScreenPtr pScreen)
+{
+ int i;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ for( i=0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) {
+ pDRIPriv->pSAREA->drawableTable[i].stamp = DRIDrawableValidationStamp++;
+ }
+}
+
+
+static void
+DRITransitionToSharedBuffers(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
+
+ DRIClipNotifyAllDrawables( pScreen );
+
+ if (pDRIInfo->TransitionSingleToMulti3D)
+ pDRIInfo->TransitionSingleToMulti3D( pScreen );
+}
+
+
+static void
+DRITransitionToPrivateBuffers(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
+
+ DRIClipNotifyAllDrawables( pScreen );
+
+ if (pDRIInfo->TransitionMultiToSingle3D)
+ pDRIInfo->TransitionMultiToSingle3D( pScreen );
+}
+
+
+static void
+DRITransitionTo3d(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
+
+ DRIClipNotifyAllDrawables( pScreen );
+
+ if (pDRIInfo->TransitionTo3d)
+ pDRIInfo->TransitionTo3d( pScreen );
+}
+
+static void
+DRITransitionTo2d(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
+
+ DRIClipNotifyAllDrawables( pScreen );
+
+ if (pDRIInfo->TransitionTo2d)
+ pDRIInfo->TransitionTo2d( pScreen );
+}
+
+
+Bool
+DRICreateDrawable(ScreenPtr pScreen, Drawable id,
+ DrawablePtr pDrawable, drm_drawable_t * hHWDrawable)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+ WindowPtr pWin;
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ pWin = (WindowPtr)pDrawable;
+ if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
+ pDRIDrawablePriv->refCount++;
+ }
+ else {
+ /* allocate a DRI Window Private record */
+ if (!(pDRIDrawablePriv = xalloc(sizeof(DRIDrawablePrivRec)))) {
+ return FALSE;
+ }
+
+ /* Only create a drm_drawable_t once */
+ if (drmCreateDrawable(pDRIPriv->drmFD, hHWDrawable)) {
+ xfree(pDRIDrawablePriv);
+ return FALSE;
+ }
+
+ /* add it to the list of DRI drawables for this screen */
+ pDRIDrawablePriv->hwDrawable = *hHWDrawable;
+ pDRIDrawablePriv->pScreen = pScreen;
+ pDRIDrawablePriv->refCount = 1;
+ pDRIDrawablePriv->drawableIndex = -1;
+
+ /* save private off of preallocated index */
+ pWin->devPrivates[DRIWindowPrivIndex].ptr =
+ (pointer)pDRIDrawablePriv;
+
+ switch (++pDRIPriv->nrWindows) {
+ case 1:
+ DRITransitionTo3d( pScreen );
+ break;
+ case 2:
+ DRITransitionToSharedBuffers( pScreen );
+ break;
+ default:
+ break;
+ }
+
+ /* track this in case this window is destroyed */
+ AddResource(id, DRIDrawablePrivResType, (pointer)pWin);
+ }
+ }
+ else { /* pixmap (or for GLX 1.3, a PBuffer) */
+ /* NOT_DONE */
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool
+DRIDestroyDrawable(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable)
+{
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+ WindowPtr pWin;
+
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ pWin = (WindowPtr)pDrawable;
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+ pDRIDrawablePriv->refCount--;
+ if (pDRIDrawablePriv->refCount <= 0) {
+ /* This calls back DRIDrawablePrivDelete which frees private area */
+ FreeResourceByType(id, DRIDrawablePrivResType, FALSE);
+ }
+ }
+ else { /* pixmap (or for GLX 1.3, a PBuffer) */
+ /* NOT_DONE */
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool
+DRIDrawablePrivDelete(pointer pResource, XID id)
+{
+ DrawablePtr pDrawable = (DrawablePtr)pResource;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pDrawable->pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+ WindowPtr pWin;
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ pWin = (WindowPtr)pDrawable;
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+
+ if (pDRIDrawablePriv->drawableIndex != -1) {
+ /* bump stamp to force outstanding 3D requests to resync */
+ pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp
+ = DRIDrawableValidationStamp++;
+
+ /* release drawable table entry */
+ pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL;
+ }
+
+ if (drmDestroyDrawable(pDRIPriv->drmFD,
+ pDRIDrawablePriv->hwDrawable)) {
+ return FALSE;
+ }
+ xfree(pDRIDrawablePriv);
+ pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL;
+
+ switch (--pDRIPriv->nrWindows) {
+ case 0:
+ DRITransitionTo2d( pDrawable->pScreen );
+ break;
+ case 1:
+ DRITransitionToPrivateBuffers( pDrawable->pScreen );
+ break;
+ default:
+ break;
+ }
+ }
+ else { /* pixmap (or for GLX 1.3, a PBuffer) */
+ /* NOT_DONE */
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool
+DRIGetDrawableInfo(ScreenPtr pScreen,
+ DrawablePtr pDrawable,
+ unsigned int* index,
+ unsigned int* stamp,
+ int* X,
+ int* Y,
+ int* W,
+ int* H,
+ int* numClipRects,
+ drm_clip_rect_t ** pClipRects,
+ int* backX,
+ int* backY,
+ int* numBackClipRects,
+ drm_clip_rect_t ** pBackClipRects)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv, pOldDrawPriv;
+ WindowPtr pWin, pOldWin;
+ int i;
+
+ printf("maxDrawableTableEntry = %d\n", pDRIPriv->pDriverInfo->maxDrawableTableEntry);
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ pWin = (WindowPtr)pDrawable;
+ if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
+
+ /* Manage drawable table */
+ if (pDRIDrawablePriv->drawableIndex == -1) { /* load SAREA table */
+
+ /* Search table for empty entry */
+ i = 0;
+ while (i < pDRIPriv->pDriverInfo->maxDrawableTableEntry) {
+ if (!(pDRIPriv->DRIDrawables[i])) {
+ pDRIPriv->DRIDrawables[i] = pDrawable;
+ pDRIDrawablePriv->drawableIndex = i;
+ pDRIPriv->pSAREA->drawableTable[i].stamp =
+ DRIDrawableValidationStamp++;
+ break;
+ }
+ i++;
+ }
+
+ /* Search table for oldest entry */
+ if (i == pDRIPriv->pDriverInfo->maxDrawableTableEntry) {
+ unsigned int oldestStamp = ~0;
+ int oldestIndex = 0;
+ i = pDRIPriv->pDriverInfo->maxDrawableTableEntry;
+ while (i--) {
+ if (pDRIPriv->pSAREA->drawableTable[i].stamp <
+ oldestStamp) {
+ oldestIndex = i;
+ oldestStamp =
+ pDRIPriv->pSAREA->drawableTable[i].stamp;
+ }
+ }
+ pDRIDrawablePriv->drawableIndex = oldestIndex;
+
+ /* release oldest drawable table entry */
+ pOldWin = (WindowPtr)pDRIPriv->DRIDrawables[oldestIndex];
+ pOldDrawPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pOldWin);
+ pOldDrawPriv->drawableIndex = -1;
+
+ /* claim drawable table entry */
+ pDRIPriv->DRIDrawables[oldestIndex] = pDrawable;
+
+ /* validate SAREA entry */
+ pDRIPriv->pSAREA->drawableTable[oldestIndex].stamp =
+ DRIDrawableValidationStamp++;
+
+ /* check for stamp wrap around */
+ if (oldestStamp > DRIDrawableValidationStamp) {
+
+ /* walk SAREA table and invalidate all drawables */
+ for( i=0;
+ i < pDRIPriv->pDriverInfo->maxDrawableTableEntry;
+ i++) {
+ pDRIPriv->pSAREA->drawableTable[i].stamp =
+ DRIDrawableValidationStamp++;
+ }
+ }
+ }
+
+ /* If the driver wants to be notified when the index is
+ * set for a drawable, let it know now.
+ */
+ if (pDRIPriv->pDriverInfo->SetDrawableIndex)
+ pDRIPriv->pDriverInfo->SetDrawableIndex(pWin,
+ pDRIDrawablePriv->drawableIndex);
+
+ /* reinit drawable ID if window is visible */
+ if ((pWin->viewable) &&
+ (pDRIPriv->pDriverInfo->bufferRequests != DRI_NO_WINDOWS))
+ {
+ (*pDRIPriv->pDriverInfo->InitBuffers)(pWin,
+ &pWin->clipList, pDRIDrawablePriv->drawableIndex);
+ }
+ }
+
+ *index = pDRIDrawablePriv->drawableIndex;
+ *stamp = pDRIPriv->pSAREA->drawableTable[*index].stamp;
+ *X = (int)(pWin->drawable.x);
+ *Y = (int)(pWin->drawable.y);
+#if 0
+ *W = (int)(pWin->winSize.extents.x2 - pWin->winSize.extents.x1);
+ *H = (int)(pWin->winSize.extents.y2 - pWin->winSize.extents.y1);
+#endif
+ *W = (int)(pWin->drawable.width);
+ *H = (int)(pWin->drawable.height);
+ *numClipRects = REGION_NUM_RECTS(&pWin->clipList);
+ *pClipRects = (drm_clip_rect_t *)REGION_RECTS(&pWin->clipList);
+
+ if (!*numClipRects && pDRIPriv->fullscreen) {
+ /* use fake full-screen clip rect */
+ pDRIPriv->fullscreen_rect.x1 = *X;
+ pDRIPriv->fullscreen_rect.y1 = *Y;
+ pDRIPriv->fullscreen_rect.x2 = *X + *W;
+ pDRIPriv->fullscreen_rect.y2 = *Y + *H;
+
+ *numClipRects = 1;
+ *pClipRects = &pDRIPriv->fullscreen_rect;
+ }
+
+ *backX = *X;
+ *backY = *Y;
+
+ if (pDRIPriv->nrWindows == 1 && *numClipRects) {
+ /* Use a single cliprect. */
+
+ int x0 = *X;
+ int y0 = *Y;
+ int x1 = x0 + *W;
+ int y1 = y0 + *H;
+
+ if (x0 < 0) x0 = 0;
+ if (y0 < 0) y0 = 0;
+ if (x1 > pScreen->width) x1 = pScreen->width;
+ if (y1 > pScreen->height) y1 = pScreen->height;
+
+ pDRIPriv->private_buffer_rect.x1 = x0;
+ pDRIPriv->private_buffer_rect.y1 = y0;
+ pDRIPriv->private_buffer_rect.x2 = x1;
+ pDRIPriv->private_buffer_rect.y2 = y1;
+
+ *numBackClipRects = 1;
+ *pBackClipRects = &(pDRIPriv->private_buffer_rect);
+ } else {
+ /* Use the frontbuffer cliprects for back buffers. */
+ *numBackClipRects = 0;
+ *pBackClipRects = 0;
+ }
+ }
+ else {
+ /* Not a DRIDrawable */
+ return FALSE;
+ }
+ }
+ else { /* pixmap (or for GLX 1.3, a PBuffer) */
+ /* NOT_DONE */
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool
+DRIGetDeviceInfo(ScreenPtr pScreen,
+ drm_handle_t * hFrameBuffer,
+ int* fbOrigin,
+ int* fbSize,
+ int* fbStride,
+ int* devPrivateSize,
+ void** pDevPrivate)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ *hFrameBuffer = pDRIPriv->hFrameBuffer;
+ *fbOrigin = 0;
+ *fbSize = pDRIPriv->pDriverInfo->frameBufferSize;
+ *fbStride = pDRIPriv->pDriverInfo->frameBufferStride;
+ *devPrivateSize = pDRIPriv->pDriverInfo->devPrivateSize;
+ *pDevPrivate = pDRIPriv->pDriverInfo->devPrivate;
+
+ return TRUE;
+}
+
+DRIInfoPtr
+DRICreateInfoRec(void)
+{
+ DRIInfoPtr inforec = (DRIInfoPtr)xcalloc(1, sizeof(DRIInfoRec));
+ if (!inforec) return NULL;
+
+ /* Initialize defaults */
+ inforec->busIdString = NULL;
+
+ /* Wrapped function defaults */
+ inforec->wrap.WakeupHandler = DRIDoWakeupHandler;
+ inforec->wrap.BlockHandler = DRIDoBlockHandler;
+ inforec->wrap.WindowExposures = DRIWindowExposures;
+ inforec->wrap.CopyWindow = DRICopyWindow;
+ inforec->wrap.ValidateTree = DRIValidateTree;
+ inforec->wrap.PostValidateTree = DRIPostValidateTree;
+ inforec->wrap.ClipNotify = DRIClipNotify;
+ inforec->wrap.AdjustFrame = DRIAdjustFrame;
+
+ inforec->TransitionTo2d = 0;
+ inforec->TransitionTo3d = 0;
+ inforec->SetDrawableIndex = 0;
+
+ return inforec;
+}
+
+void
+DRIDestroyInfoRec(DRIInfoPtr DRIInfo)
+{
+ if (DRIInfo->busIdString) xfree(DRIInfo->busIdString);
+ xfree((char*)DRIInfo);
+}
+
+
+void
+DRIWakeupHandler(pointer wakeupData, int result, pointer pReadmask)
+{
+ int i;
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (pDRIPriv &&
+ pDRIPriv->pDriverInfo->wrap.WakeupHandler)
+ (*pDRIPriv->pDriverInfo->wrap.WakeupHandler)(i, wakeupData,
+ result, pReadmask);
+ }
+}
+
+void
+DRIBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
+{
+ int i;
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (pDRIPriv &&
+ pDRIPriv->pDriverInfo->wrap.BlockHandler)
+ (*pDRIPriv->pDriverInfo->wrap.BlockHandler)(i, blockData,
+ pTimeout, pReadmask);
+ }
+}
+
+void
+DRIDoWakeupHandler(int screenNum, pointer wakeupData,
+ unsigned long result, pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ DRILock(pScreen, 0);
+ if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
+ /* hide X context by swapping 2D component here */
+ (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
+ DRI_3D_SYNC,
+ DRI_2D_CONTEXT,
+ pDRIPriv->partial3DContextStore,
+ DRI_2D_CONTEXT,
+ pDRIPriv->hiddenContextStore);
+ }
+}
+
+void
+DRIDoBlockHandler(int screenNum, pointer blockData,
+ pointer pTimeout, pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
+ /* hide X context by swapping 2D component here */
+ (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
+ DRI_2D_SYNC,
+ DRI_NO_CONTEXT,
+ NULL,
+ DRI_2D_CONTEXT,
+ pDRIPriv->partial3DContextStore);
+ }
+ DRIUnlock(pScreen);
+}
+
+void
+DRISwapContext(int drmFD, void *oldctx, void *newctx)
+{
+ DRIContextPrivPtr oldContext = (DRIContextPrivPtr)oldctx;
+ DRIContextPrivPtr newContext = (DRIContextPrivPtr)newctx;
+ ScreenPtr pScreen = newContext->pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ void* oldContextStore = NULL;
+ DRIContextType oldContextType;
+ void* newContextStore = NULL;
+ DRIContextType newContextType;
+ DRISyncType syncType;
+#ifdef DEBUG
+ static int count = 0;
+#endif
+
+ if (!newContext) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI] Context Switch Error: oldContext=%x, newContext=%x\n",
+ oldContext, newContext);
+ return;
+ }
+
+#ifdef DEBUG
+ /* usefull for debugging, just print out after n context switches */
+ if (!count || !(count % 1)) {
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[DRI] Context switch %5d from %p/0x%08x (%d)\n",
+ count,
+ oldContext,
+ oldContext ? oldContext->flags : 0,
+ oldContext ? oldContext->hwContext : -1);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[DRI] Context switch %5d to %p/0x%08x (%d)\n",
+ count,
+ newContext,
+ newContext ? newContext->flags : 0,
+ newContext ? newContext->hwContext : -1);
+ }
+ ++count;
+#endif
+
+ if (!pDRIPriv->pDriverInfo->SwapContext) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI] DDX driver missing context swap call back\n");
+ return;
+ }
+
+ if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
+
+ /* only 3D contexts are swapped in this case */
+ if (oldContext) {
+ oldContextStore = DRIGetContextStore(oldContext);
+ oldContext->valid3D = TRUE;
+ oldContextType = DRI_3D_CONTEXT;
+ } else {
+ oldContextType = DRI_NO_CONTEXT;
+ }
+ newContextStore = DRIGetContextStore(newContext);
+ if ((newContext->valid3D) &&
+ (newContext->hwContext != pDRIPriv->myContext)) {
+ newContextType = DRI_3D_CONTEXT;
+ }
+ else {
+ newContextType = DRI_2D_CONTEXT;
+ }
+ syncType = DRI_3D_SYNC;
+ }
+ else /* default: driverSwapMethod == DRI_SERVER_SWAP */ {
+
+ /* optimize 2D context swaps */
+
+ if (newContext->flags & DRI_CONTEXT_2DONLY) {
+ /* go from 3D context to 2D context and only save 2D
+ * subset of 3D state
+ */
+ oldContextStore = DRIGetContextStore(oldContext);
+ oldContextType = DRI_2D_CONTEXT;
+ newContextStore = DRIGetContextStore(newContext);
+ newContextType = DRI_2D_CONTEXT;
+ syncType = DRI_3D_SYNC;
+ pDRIPriv->lastPartial3DContext = oldContext;
+ }
+ else if (oldContext->flags & DRI_CONTEXT_2DONLY) {
+ if (pDRIPriv->lastPartial3DContext == newContext) {
+ /* go from 2D context back to previous 3D context and
+ * only restore 2D subset of previous 3D state
+ */
+ oldContextStore = DRIGetContextStore(oldContext);
+ oldContextType = DRI_2D_CONTEXT;
+ newContextStore = DRIGetContextStore(newContext);
+ newContextType = DRI_2D_CONTEXT;
+ syncType = DRI_2D_SYNC;
+ }
+ else {
+ /* go from 2D context to a different 3D context */
+
+ /* call DDX driver to do partial restore */
+ oldContextStore = DRIGetContextStore(oldContext);
+ newContextStore =
+ DRIGetContextStore(pDRIPriv->lastPartial3DContext);
+ (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
+ DRI_2D_SYNC,
+ DRI_2D_CONTEXT,
+ oldContextStore,
+ DRI_2D_CONTEXT,
+ newContextStore);
+
+ /* now setup for a complete 3D swap */
+ oldContextStore = newContextStore;
+ oldContext->valid3D = TRUE;
+ oldContextType = DRI_3D_CONTEXT;
+ newContextStore = DRIGetContextStore(newContext);
+ if ((newContext->valid3D) &&
+ (newContext->hwContext != pDRIPriv->myContext)) {
+ newContextType = DRI_3D_CONTEXT;
+ }
+ else {
+ newContextType = DRI_2D_CONTEXT;
+ }
+ syncType = DRI_NO_SYNC;
+ }
+ }
+ else {
+ /* now setup for a complete 3D swap */
+ oldContextStore = newContextStore;
+ oldContext->valid3D = TRUE;
+ oldContextType = DRI_3D_CONTEXT;
+ newContextStore = DRIGetContextStore(newContext);
+ if ((newContext->valid3D) &&
+ (newContext->hwContext != pDRIPriv->myContext)) {
+ newContextType = DRI_3D_CONTEXT;
+ }
+ else {
+ newContextType = DRI_2D_CONTEXT;
+ }
+ syncType = DRI_3D_SYNC;
+ }
+ }
+
+ /* call DDX driver to perform the swap */
+ (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
+ syncType,
+ oldContextType,
+ oldContextStore,
+ newContextType,
+ newContextStore);
+}
+
+void*
+DRIGetContextStore(DRIContextPrivPtr context)
+{
+ return((void *)context->pContextStore);
+}
+
+void
+DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+
+ if(pDRIDrawablePriv) {
+ (*pDRIPriv->pDriverInfo->InitBuffers)(pWin, prgn,
+ pDRIDrawablePriv->drawableIndex);
+ }
+
+ /* call lower wrapped functions */
+ if (pDRIPriv && pDRIPriv->wrap.WindowExposures) {
+
+ /* unwrap */
+ pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
+
+ /* call lower layers */
+ (*pScreen->WindowExposures)(pWin, prgn, bsreg);
+
+ /* rewrap */
+ pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
+ pScreen->WindowExposures = DRIWindowExposures;
+ }
+}
+
+
+static int
+DRITreeTraversal(WindowPtr pWin, pointer data)
+{
+ DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+
+ if(pDRIDrawablePriv) {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ RegionPtr reg = (RegionPtr)data;
+
+ REGION_UNION(pScreen, reg, reg, &(pWin->clipList));
+
+ if(pDRIPriv->nrWindows == 1)
+ return WT_STOPWALKING;
+ }
+ return WT_WALKCHILDREN;
+}
+
+void
+DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if(!pDRIPriv) return;
+
+ if(pDRIPriv->nrWindows > 0) {
+ RegionRec reg;
+
+ REGION_NULL(pScreen, &reg);
+ TraverseTree(pWin, DRITreeTraversal, (pointer)(&reg));
+
+ if(REGION_NOTEMPTY(pScreen, &reg)) {
+ REGION_TRANSLATE(pScreen, &reg, ptOldOrg.x - pWin->drawable.x,
+ ptOldOrg.y - pWin->drawable.y);
+ REGION_INTERSECT(pScreen, &reg, &reg, prgnSrc);
+
+ /* The MoveBuffers interface is not ideal */
+ (*pDRIPriv->pDriverInfo->MoveBuffers)(pWin, ptOldOrg, &reg,
+ pDRIPriv->pDriverInfo->ddxDrawableTableEntry);
+ }
+
+ REGION_UNINIT(pScreen, &reg);
+ }
+
+ /* call lower wrapped functions */
+ if(pDRIPriv->wrap.CopyWindow) {
+ /* unwrap */
+ pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
+
+ /* call lower layers */
+ (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
+
+ /* rewrap */
+ pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = DRICopyWindow;
+ }
+}
+
+static void
+DRIGetSecs(long *secs, long *usecs)
+{
+#ifdef XFree86LOADER
+ getsecs(secs,usecs);
+#else
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+
+ *secs = tv.tv_sec;
+ *usecs = tv.tv_usec;
+#endif
+}
+
+static unsigned long
+DRIComputeMilliSeconds(unsigned long s_secs, unsigned long s_usecs,
+ unsigned long f_secs, unsigned long f_usecs)
+{
+ if (f_usecs < s_usecs) {
+ --f_secs;
+ f_usecs += 1000000;
+ }
+ return (f_secs - s_secs) * 1000 + (f_usecs - s_usecs) / 1000;
+}
+
+static void
+DRISpinLockTimeout(drmLock *lock, int val, unsigned long timeout /* in mS */)
+{
+ int count = 10000;
+#if !defined(__alpha__) && !defined(__powerpc__)
+ char ret;
+#else
+ int ret;
+#endif
+ long s_secs, s_usecs;
+ long f_secs, f_usecs;
+ long msecs;
+ long prev = 0;
+
+ DRIGetSecs(&s_secs, &s_usecs);
+
+ do {
+ DRM_SPINLOCK_COUNT(lock, val, count, ret);
+ if (!ret) return; /* Got lock */
+ DRIGetSecs(&f_secs, &f_usecs);
+ msecs = DRIComputeMilliSeconds(s_secs, s_usecs, f_secs, f_usecs);
+ if (msecs - prev < 250) count *= 2; /* Not more than 0.5S */
+ } while (msecs < timeout);
+
+ /* Didn't get lock, so take it. The worst
+ that can happen is that there is some
+ garbage written to the wrong part of the
+ framebuffer that a refresh will repair.
+ That's undesirable, but better than
+ locking the server. This should be a
+ very rare event. */
+ DRM_SPINLOCK_TAKE(lock, val);
+}
+
+static void
+DRILockTree(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if(!pDRIPriv) return;
+
+ /* Restore the last known 3D context if the X context is hidden */
+ if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
+ (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
+ DRI_2D_SYNC,
+ DRI_NO_CONTEXT,
+ NULL,
+ DRI_2D_CONTEXT,
+ pDRIPriv->partial3DContextStore);
+ }
+
+ /* Call kernel to release lock */
+ DRIUnlock(pScreen);
+
+ /* Grab drawable spin lock: a time out between 10 and 30 seconds is
+ appropriate, since this should never time out except in the case of
+ client death while the lock is being held. The timeout must be
+ greater than any reasonable rendering time. */
+ DRISpinLockTimeout(&pDRIPriv->pSAREA->drawable_lock, 1, 10000); /*10 secs*/
+
+ /* Call kernel flush outstanding buffers and relock */
+ DRILock(pScreen, DRM_LOCK_QUIESCENT|DRM_LOCK_FLUSH_ALL);
+
+ /* Switch back to our 2D context if the X context is hidden */
+ if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
+ /* hide X context by swapping 2D component here */
+ (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
+ DRI_3D_SYNC,
+ DRI_2D_CONTEXT,
+ pDRIPriv->partial3DContextStore,
+ DRI_2D_CONTEXT,
+ pDRIPriv->hiddenContextStore);
+ }
+}
+
+/* It appears that somebody is relying on the lock being set even
+ if we aren't touching 3D windows */
+
+#define DRI_BROKEN
+
+static Bool DRIWindowsTouched = FALSE;
+
+int
+DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
+{
+ ScreenPtr pScreen = pParent->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ int returnValue = 1; /* always return 1, not checked by dix/window.c */
+
+ if(!pDRIPriv) return returnValue;
+
+ DRIWindowsTouched = FALSE;
+
+#ifdef DRI_BROKEN
+ if(!DRIWindowsTouched) {
+ DRILockTree(pScreen);
+ DRIWindowsTouched = TRUE;
+ }
+#endif
+
+ /* call lower wrapped functions */
+ if(pDRIPriv->wrap.ValidateTree) {
+ /* unwrap */
+ pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
+
+ /* call lower layers */
+ returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind);
+
+ /* rewrap */
+ pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
+ pScreen->ValidateTree = DRIValidateTree;
+ }
+
+ return returnValue;
+}
+
+void
+DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
+{
+ ScreenPtr pScreen;
+ DRIScreenPrivPtr pDRIPriv;
+
+ if (pParent) {
+ pScreen = pParent->drawable.pScreen;
+ } else {
+ pScreen = pChild->drawable.pScreen;
+ }
+ if(!(pDRIPriv = DRI_SCREEN_PRIV(pScreen))) return;
+
+ if (pDRIPriv->wrap.PostValidateTree) {
+ /* unwrap */
+ pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
+
+ /* call lower layers */
+ (*pScreen->PostValidateTree)(pParent, pChild, kind);
+
+ /* rewrap */
+ pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
+ pScreen->PostValidateTree = DRIPostValidateTree;
+ }
+
+ if (DRIWindowsTouched) {
+ /* Release spin lock */
+ DRM_SPINUNLOCK(&pDRIPriv->pSAREA->drawable_lock, 1);
+ DRIWindowsTouched = FALSE;
+ }
+}
+
+void
+DRIClipNotify(WindowPtr pWin, int dx, int dy)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+
+ if(!pDRIPriv) return;
+
+ if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
+
+#ifndef DRI_BROKEN
+ if(!DRIWindowsTouched) {
+ DRILockTree(pScreen);
+ DRIWindowsTouched = TRUE;
+ }
+#endif
+
+ pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp
+ = DRIDrawableValidationStamp++;
+ }
+
+ /* call lower wrapped functions */
+ if(pDRIPriv->wrap.ClipNotify) {
+
+ /* unwrap */
+ pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
+
+ /* call lower layers */
+ (*pScreen->ClipNotify)(pWin, dx, dy);
+
+ /* rewrap */
+ pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
+ pScreen->ClipNotify = DRIClipNotify;
+ }
+}
+
+CARD32
+DRIGetDrawableIndex(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+ CARD32 index;
+
+ if (pDRIDrawablePriv) {
+ index = pDRIDrawablePriv->drawableIndex;
+ }
+ else {
+ index = pDRIPriv->pDriverInfo->ddxDrawableTableEntry;
+ }
+
+ return index;
+}
+
+unsigned int
+DRIGetDrawableStamp(ScreenPtr pScreen, CARD32 drawable_index)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ return pDRIPriv->pSAREA->drawableTable[drawable_index].stamp;
+}
+
+
+void
+DRIPrintDrawableLock(ScreenPtr pScreen, char *msg)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ ErrorF("%s: %d\n", msg, pDRIPriv->pSAREA->drawable_lock.lock);
+}
+
+void
+DRILock(ScreenPtr pScreen, int flags)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ if(!pDRIPriv) return;
+
+ if (!pDRIPriv->lockRefCount)
+ DRM_LOCK(pDRIPriv->drmFD, pDRIPriv->pSAREA, pDRIPriv->myContext, flags);
+ pDRIPriv->lockRefCount++;
+}
+
+void
+DRIUnlock(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ if(!pDRIPriv) return;
+
+ if (pDRIPriv->lockRefCount > 0) {
+ pDRIPriv->lockRefCount--;
+ }
+ else {
+ ErrorF("DRIUnlock called when not locked\n");
+ return;
+ }
+ if (!pDRIPriv->lockRefCount)
+ DRM_UNLOCK(pDRIPriv->drmFD, pDRIPriv->pSAREA, pDRIPriv->myContext);
+}
+
+void *
+DRIGetSAREAPrivate(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ if (!pDRIPriv) return 0;
+
+ return (void *)(((char*)pDRIPriv->pSAREA)+sizeof(XF86DRISAREARec));
+}
+
+drm_context_t
+DRIGetContext(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ if (!pDRIPriv) return 0;
+
+ return pDRIPriv->myContext;
+}
+
+/* This lets get at the unwrapped functions so that they can correctly
+ * call the lowerlevel functions, and choose whether they will be
+ * called at every level of recursion (eg in validatetree).
+ */
+DRIWrappedFuncsRec *
+DRIGetWrappedFuncs(ScreenPtr pScreen)
+{
+ return &(DRI_SCREEN_PRIV(pScreen)->wrap);
+}
+
+/* note that this returns the library version, not the protocol version */
+void
+DRIQueryVersion(int *majorVersion,
+ int *minorVersion,
+ int *patchVersion)
+{
+ *majorVersion = DRIINFO_MAJOR_VERSION;
+ *minorVersion = DRIINFO_MINOR_VERSION;
+ *patchVersion = DRIINFO_PATCH_VERSION;
+}
+
+static void
+_DRIAdjustFrame(ScrnInfoPtr pScrn, DRIScreenPrivPtr pDRIPriv, int x, int y)
+{
+ pDRIPriv->pSAREA->frame.x = x;
+ pDRIPriv->pSAREA->frame.y = y;
+ pDRIPriv->pSAREA->frame.width = pScrn->frameX1 - x + 1;
+ pDRIPriv->pSAREA->frame.height = pScrn->frameY1 - y + 1;
+}
+
+void
+DRIAdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+ ScreenPtr pScreen = screenInfo.screens[scrnIndex];
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ int px, py;
+
+ if (!pDRIPriv || !pDRIPriv->pSAREA) {
+ DRIDrvMsg(scrnIndex, X_ERROR, "[DRI] No SAREA (%p %p)\n",
+ pDRIPriv, pDRIPriv ? pDRIPriv->pSAREA : NULL);
+ return;
+ }
+
+ if (pDRIPriv->fullscreen) {
+ /* Fix up frame */
+ pScrn->frameX0 = pDRIPriv->pSAREA->frame.x;
+ pScrn->frameY0 = pDRIPriv->pSAREA->frame.y;
+ pScrn->frameX1 = pScrn->frameX0 + pDRIPriv->pSAREA->frame.width - 1;
+ pScrn->frameY1 = pScrn->frameY0 + pDRIPriv->pSAREA->frame.height - 1;
+
+ /* Fix up cursor */
+ miPointerPosition(&px, &py);
+ if (px < pScrn->frameX0) px = pScrn->frameX0;
+ if (px > pScrn->frameX1) px = pScrn->frameX1;
+ if (py < pScrn->frameY0) py = pScrn->frameY0;
+ if (py > pScrn->frameY1) py = pScrn->frameY1;
+ pScreen->SetCursorPosition(pScreen, px, py, TRUE);
+ return;
+ }
+
+ if (pDRIPriv->wrap.AdjustFrame) {
+ /* unwrap */
+ pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
+ /* call lower layers */
+ (*pScrn->AdjustFrame)(scrnIndex, x, y, flags);
+ /* rewrap */
+ pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame;
+ pScrn->AdjustFrame = DRIAdjustFrame;
+ }
+
+ _DRIAdjustFrame(pScrn, pDRIPriv, x, y);
+}
+
+/*
+ * DRIMoveBuffersHelper swaps the regions rects in place leaving you
+ * a region with the rects in the order that you need to blit them,
+ * but it is possibly (likely) an invalid region afterwards. If you
+ * need to use the region again for anything you have to call
+ * REGION_VALIDATE on it, or better yet, save a copy first.
+ */
+
+void
+DRIMoveBuffersHelper(
+ ScreenPtr pScreen,
+ int dx,
+ int dy,
+ int *xdir,
+ int *ydir,
+ RegionPtr reg
+)
+{
+ BoxPtr extents, pbox, firstBox, lastBox;
+ BoxRec tmpBox;
+ int y, nbox;
+
+ extents = REGION_EXTENTS(pScreen, reg);
+ nbox = REGION_NUM_RECTS(reg);
+ pbox = REGION_RECTS(reg);
+
+ if((dy > 0) && (dy < (extents->y2 - extents->y1))) {
+ *ydir = -1;
+ if(nbox > 1) {
+ firstBox = pbox;
+ lastBox = pbox + nbox - 1;
+ while((unsigned long)firstBox < (unsigned long)lastBox) {
+ tmpBox = *firstBox;
+ *firstBox = *lastBox;
+ *lastBox = tmpBox;
+ firstBox++;
+ lastBox--;
+ }
+ }
+ } else *ydir = 1;
+
+ if((dx > 0) && (dx < (extents->x2 - extents->x1))) {
+ *xdir = -1;
+ if(nbox > 1) {
+ firstBox = lastBox = pbox;
+ y = pbox->y1;
+ while(--nbox) {
+ pbox++;
+ if(pbox->y1 == y) lastBox++;
+ else {
+ while((unsigned long)firstBox < (unsigned long)lastBox) {
+ tmpBox = *firstBox;
+ *firstBox = *lastBox;
+ *lastBox = tmpBox;
+ firstBox++;
+ lastBox--;
+ }
+
+ firstBox = lastBox = pbox;
+ y = pbox->y1;
+ }
+ }
+ while((unsigned long)firstBox < (unsigned long)lastBox) {
+ tmpBox = *firstBox;
+ *firstBox = *lastBox;
+ *lastBox = tmpBox;
+ firstBox++;
+ lastBox--;
+ }
+ }
+ } else *xdir = 1;
+
+}
+
+char *
+DRICreatePCIBusID(pciVideoPtr PciInfo)
+{
+ char *busID;
+ int domain;
+ PCITAG tag;
+
+ busID = xalloc(20);
+ if (busID == NULL)
+ return NULL;
+
+ tag = pciTag(PciInfo->bus, PciInfo->device, PciInfo->func);
+ domain = xf86GetPciDomain(tag);
+ snprintf(busID, 20, "pci:%04x:%02x:%02x.%d", domain, PciInfo->bus,
+ PciInfo->device, PciInfo->func);
+ return busID;
+}
diff --git a/nx-X11/programs/Xserver/GL/dri/dri.h b/nx-X11/programs/Xserver/GL/dri/dri.h
new file mode 100644
index 000000000..312e8a8bb
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/dri/dri.h
@@ -0,0 +1,345 @@
+/* $XFree86: xc/programs/Xserver/GL/dri/dri.h,v 1.18 2001/03/21 16:21:40 dawes Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Jens Owen <jens@tungstengraphics.com>
+ *
+ */
+
+/* Prototypes for DRI functions */
+
+#ifndef _DRI_H_
+
+#include "scrnintstr.h"
+#include "xf86dri.h"
+
+typedef int DRISyncType;
+
+#define DRI_NO_SYNC 0
+#define DRI_2D_SYNC 1
+#define DRI_3D_SYNC 2
+
+typedef int DRIContextType;
+
+typedef struct _DRIContextPrivRec DRIContextPrivRec, *DRIContextPrivPtr;
+
+typedef enum _DRIContextFlags
+{
+ DRI_CONTEXT_2DONLY = 0x01,
+ DRI_CONTEXT_PRESERVED = 0x02,
+ DRI_CONTEXT_RESERVED = 0x04 /* DRI Only -- no kernel equivalent */
+} DRIContextFlags;
+
+#define DRI_NO_CONTEXT 0
+#define DRI_2D_CONTEXT 1
+#define DRI_3D_CONTEXT 2
+
+typedef int DRISwapMethod;
+
+#define DRI_HIDE_X_CONTEXT 0
+#define DRI_SERVER_SWAP 1
+#define DRI_KERNEL_SWAP 2
+
+typedef int DRIWindowRequests;
+
+#define DRI_NO_WINDOWS 0
+#define DRI_3D_WINDOWS_ONLY 1
+#define DRI_ALL_WINDOWS 2
+
+
+typedef void (*ClipNotifyPtr)( WindowPtr, int, int );
+typedef void (*AdjustFramePtr)(int scrnIndex, int x, int y, int flags);
+
+
+/*
+ * These functions can be wrapped by the DRI. Each of these have
+ * generic default funcs (initialized in DRICreateInfoRec) and can be
+ * overridden by the driver in its [driver]DRIScreenInit function.
+ */
+typedef struct {
+ ScreenWakeupHandlerProcPtr WakeupHandler;
+ ScreenBlockHandlerProcPtr BlockHandler;
+ WindowExposuresProcPtr WindowExposures;
+ CopyWindowProcPtr CopyWindow;
+ ValidateTreeProcPtr ValidateTree;
+ PostValidateTreeProcPtr PostValidateTree;
+ ClipNotifyProcPtr ClipNotify;
+ AdjustFramePtr AdjustFrame;
+} DRIWrappedFuncsRec, *DRIWrappedFuncsPtr;
+
+
+/*
+ * Prior to Xorg 6.8.99.8, the DRIInfoRec structure was implicitly versioned
+ * by the XF86DRI_*_VERSION defines in xf86dristr.h. These numbers were also
+ * being used to version the XFree86-DRI protocol. Bugs #3066 and #3163
+ * showed that this was inadequate. The DRIInfoRec structure is now versioned
+ * by the DRIINFO_*_VERSION defines in this file. - ajax, 2005-05-18.
+ *
+ * Revision history:
+ * 4.1.0 and earlier: DRIQueryVersion returns XF86DRI_*_VERSION.
+ * 4.2.0: DRIQueryVersion begins returning DRIINFO_*_VERSION.
+ * 5.0.0: frameBufferPhysicalAddress changed from CARD32 to pointer.
+ */
+
+#define DRIINFO_MAJOR_VERSION 5
+#define DRIINFO_MINOR_VERSION 0
+#define DRIINFO_PATCH_VERSION 0
+
+typedef struct {
+ /* driver call back functions
+ *
+ * New fields should be added at the end for backwards compatibility.
+ * Bump the DRIINFO patch number to indicate bugfixes.
+ * Bump the DRIINFO minor number to indicate new fields.
+ * Bump the DRIINFO major number to indicate binary-incompatible changes.
+ */
+ Bool (*CreateContext)(ScreenPtr pScreen,
+ VisualPtr visual,
+ drm_context_t hHWContext,
+ void* pVisualConfigPriv,
+ DRIContextType context);
+ void (*DestroyContext)(ScreenPtr pScreen,
+ drm_context_t hHWContext,
+ DRIContextType context);
+ void (*SwapContext)(ScreenPtr pScreen,
+ DRISyncType syncType,
+ DRIContextType readContextType,
+ void* readContextStore,
+ DRIContextType writeContextType,
+ void* writeContextStore);
+ void (*InitBuffers)(WindowPtr pWin,
+ RegionPtr prgn,
+ CARD32 indx);
+ void (*MoveBuffers)(WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc,
+ CARD32 indx);
+ void (*TransitionTo3d)(ScreenPtr pScreen);
+ void (*TransitionTo2d)(ScreenPtr pScreen);
+
+ void (*SetDrawableIndex)(WindowPtr pWin, CARD32 indx);
+ Bool (*OpenFullScreen)(ScreenPtr pScreen);
+ Bool (*CloseFullScreen)(ScreenPtr pScreen);
+
+ /* wrapped functions */
+ DRIWrappedFuncsRec wrap;
+
+ /* device info */
+ char* drmDriverName;
+ char* clientDriverName;
+ char* busIdString;
+ int ddxDriverMajorVersion;
+ int ddxDriverMinorVersion;
+ int ddxDriverPatchVersion;
+ pointer frameBufferPhysicalAddress;
+ long frameBufferSize;
+ long frameBufferStride;
+ long SAREASize;
+ int maxDrawableTableEntry;
+ int ddxDrawableTableEntry;
+ long contextSize;
+ DRISwapMethod driverSwapMethod;
+ DRIWindowRequests bufferRequests;
+ int devPrivateSize;
+ void* devPrivate;
+ Bool createDummyCtx;
+ Bool createDummyCtxPriv;
+
+ /* New with DRI version 4.1.0 */
+ void (*TransitionSingleToMulti3D)(ScreenPtr pScreen);
+ void (*TransitionMultiToSingle3D)(ScreenPtr pScreen);
+} DRIInfoRec, *DRIInfoPtr;
+
+
+extern Bool DRIScreenInit(ScreenPtr pScreen,
+ DRIInfoPtr pDRIInfo,
+ int *pDRMFD);
+
+extern void DRICloseScreen(ScreenPtr pScreen);
+
+extern Bool DRIExtensionInit(void);
+
+extern void DRIReset(void);
+
+extern Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen,
+ Bool *isCapable);
+
+extern Bool DRIOpenConnection(ScreenPtr pScreen,
+ drm_handle_t * hSAREA,
+ char **busIdString);
+
+extern Bool DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic);
+
+extern Bool DRICloseConnection(ScreenPtr pScreen);
+
+extern Bool DRIGetClientDriverName(ScreenPtr pScreen,
+ int* ddxDriverMajorVersion,
+ int* ddxDriverMinorVersion,
+ int* ddxDriverPatchVersion,
+ char** clientDriverName);
+
+extern Bool DRICreateContext(ScreenPtr pScreen,
+ VisualPtr visual,
+ XID context,
+ drm_context_t * pHWContext);
+
+extern Bool DRIDestroyContext(ScreenPtr pScreen, XID context);
+
+extern Bool DRIContextPrivDelete(pointer pResource, XID id);
+
+extern Bool DRICreateDrawable(ScreenPtr pScreen,
+ Drawable id,
+ DrawablePtr pDrawable,
+ drm_drawable_t * hHWDrawable);
+
+extern Bool DRIDestroyDrawable(ScreenPtr pScreen,
+ Drawable id,
+ DrawablePtr pDrawable);
+
+extern Bool DRIDrawablePrivDelete(pointer pResource,
+ XID id);
+
+extern Bool DRIGetDrawableInfo(ScreenPtr pScreen,
+ DrawablePtr pDrawable,
+ unsigned int* indx,
+ unsigned int* stamp,
+ int* X,
+ int* Y,
+ int* W,
+ int* H,
+ int* numClipRects,
+ drm_clip_rect_t ** pClipRects,
+ int* backX,
+ int* backY,
+ int* numBackClipRects,
+ drm_clip_rect_t ** pBackClipRects);
+
+extern Bool DRIGetDeviceInfo(ScreenPtr pScreen,
+ drm_handle_t * hFrameBuffer,
+ int* fbOrigin,
+ int* fbSize,
+ int* fbStride,
+ int* devPrivateSize,
+ void** pDevPrivate);
+
+extern DRIInfoPtr DRICreateInfoRec(void);
+
+extern void DRIDestroyInfoRec(DRIInfoPtr DRIInfo);
+
+extern Bool DRIFinishScreenInit(ScreenPtr pScreen);
+
+extern void DRIWakeupHandler(pointer wakeupData,
+ int result,
+ pointer pReadmask);
+
+extern void DRIBlockHandler(pointer blockData,
+ OSTimePtr pTimeout,
+ pointer pReadmask);
+
+extern void DRIDoWakeupHandler(int screenNum,
+ pointer wakeupData,
+ unsigned long result,
+ pointer pReadmask);
+
+extern void DRIDoBlockHandler(int screenNum,
+ pointer blockData,
+ pointer pTimeout,
+ pointer pReadmask);
+
+extern void DRISwapContext(int drmFD,
+ void *oldctx,
+ void *newctx);
+
+extern void *DRIGetContextStore(DRIContextPrivPtr context);
+
+extern void DRIWindowExposures(WindowPtr pWin,
+ RegionPtr prgn,
+ RegionPtr bsreg);
+
+extern void DRICopyWindow(WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc);
+
+extern int DRIValidateTree(WindowPtr pParent,
+ WindowPtr pChild,
+ VTKind kind);
+
+extern void DRIPostValidateTree(WindowPtr pParent,
+ WindowPtr pChild,
+ VTKind kind);
+
+extern void DRIClipNotify(WindowPtr pWin,
+ int dx,
+ int dy);
+
+extern CARD32 DRIGetDrawableIndex(WindowPtr pWin);
+
+extern void DRIPrintDrawableLock(ScreenPtr pScreen, char *msg);
+
+extern void DRILock(ScreenPtr pScreen, int flags);
+
+extern void DRIUnlock(ScreenPtr pScreen);
+
+extern DRIWrappedFuncsRec *DRIGetWrappedFuncs(ScreenPtr pScreen);
+
+extern void *DRIGetSAREAPrivate(ScreenPtr pScreen);
+
+extern unsigned int DRIGetDrawableStamp(ScreenPtr pScreen,
+ CARD32 drawable_index);
+
+extern DRIContextPrivPtr DRICreateContextPriv(ScreenPtr pScreen,
+ drm_context_t * pHWContext,
+ DRIContextFlags flags);
+
+extern DRIContextPrivPtr DRICreateContextPrivFromHandle(ScreenPtr pScreen,
+ drm_context_t hHWContext,
+ DRIContextFlags flags);
+
+extern Bool DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv);
+
+extern drm_context_t DRIGetContext(ScreenPtr pScreen);
+
+extern void DRIQueryVersion(int *majorVersion,
+ int *minorVersion,
+ int *patchVersion);
+
+extern void DRIAdjustFrame(int scrnIndex, int x, int y, int flags);
+
+extern void DRIMoveBuffersHelper(ScreenPtr pScreen,
+ int dx,
+ int dy,
+ int *xdir,
+ int *ydir,
+ RegionPtr reg);
+
+extern char *DRICreatePCIBusID(pciVideoPtr PciInfo);
+
+#define _DRI_H_
+
+#endif
diff --git a/nx-X11/programs/Xserver/GL/dri/drimodule.c b/nx-X11/programs/Xserver/GL/dri/drimodule.c
new file mode 100644
index 000000000..922c6f40e
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/dri/drimodule.c
@@ -0,0 +1,127 @@
+/* $XdotOrg: xc/programs/Xserver/GL/dri/drimodule.c,v 1.6 2005/11/02 15:53:57 kem Exp $ */
+/**************************************************************************
+
+Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/programs/Xserver/GL/dri/drimodule.c,v 1.5 2001/06/15 21:22:39 dawes Exp $ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ * Rickard E. Faith <faith@precisioninsight.com>
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Module.h"
+#include "globals.h"
+
+static MODULESETUPPROTO(driSetup);
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "dri",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_EXTENSION,
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_NONE,
+ {0,0,0,0}
+};
+
+extern void XFree86DRIExtensionInit(INITARGS);
+#define _XF86DRI_SERVER_
+#include "xf86dristr.h"
+
+ExtensionModule XF86DRIExt =
+{
+ XFree86DRIExtensionInit,
+ XF86DRINAME,
+ &noXFree86DRIExtension,
+ NULL,
+ NULL
+};
+
+static const char *drmSymbols[] = {
+ "drmAddContextTag",
+ "drmAddMap",
+ "drmAuthMagic",
+ "drmAvailable",
+ "drmClose",
+ "drmCreateContext",
+ "drmCreateDrawable",
+ "drmDelContextTag",
+ "drmDestroyContext",
+ "drmDestroyDrawable",
+ "drmFreeReservedContextList",
+ "drmGetContextTag",
+ "drmGetLock",
+ "drmGetReservedContextList",
+ "drmInstallSIGIOHandler",
+ "drmMap",
+ "drmOpen",
+ "drmRemoveSIGIOHandler",
+ "drmSetBusid",
+ "drmSetContextFlags",
+ "drmUnlock",
+ "drmUnmap",
+ NULL
+};
+
+XF86ModuleData driModuleData = { &VersRec, driSetup, NULL };
+
+static pointer
+driSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+ pointer drm = NULL;
+
+ if (!setupDone) {
+ setupDone = TRUE;
+
+ drm =
+ LoadSubModule(module, "drm", NULL, NULL, NULL, NULL, errmaj, errmin);
+
+ if (!drm) {
+ if (errmaj) *errmaj = LDR_NOSUBENT;
+ }
+ else {
+ LoaderReqSymLists(drmSymbols, NULL);
+ LoaderRefSymbols("noPanoramiXExtension", NULL);
+ LoadExtension(&XF86DRIExt, FALSE);
+ }
+ } else {
+ if (errmaj) *errmaj = LDR_ONCEONLY;
+ }
+ /* Need a non-NULL return value to indicate success */
+ return drm;
+}
+
diff --git a/nx-X11/programs/Xserver/GL/dri/dristruct.h b/nx-X11/programs/Xserver/GL/dri/dristruct.h
new file mode 100644
index 000000000..b47afba3a
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/dri/dristruct.h
@@ -0,0 +1,105 @@
+/* $XFree86: xc/programs/Xserver/GL/dri/dristruct.h,v 1.12 2002/10/30 12:52:03 alanh Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Jens Owen <jens@tungstengraphics.com>
+ *
+ */
+
+#ifndef DRI_STRUCT_H
+#define DRI_STRUCT_H
+
+#include "xf86drm.h"
+
+
+#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) \
+ ((DRIWindowPrivIndex < 0) ? \
+ NULL : \
+ ((DRIDrawablePrivPtr)((pWin)->devPrivates[DRIWindowPrivIndex].ptr)))
+
+#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) \
+ ((DRIPixmapPrivIndex < 0) ? \
+ NULL : \
+ ((DRIDrawablePrivPtr)((pPix)->devPrivates[DRIWindowPrivIndex].ptr)))
+
+typedef struct _DRIDrawablePrivRec
+{
+ drm_drawable_t hwDrawable;
+ int drawableIndex;
+ ScreenPtr pScreen;
+ int refCount;
+} DRIDrawablePrivRec, *DRIDrawablePrivPtr;
+
+struct _DRIContextPrivRec
+{
+ drm_context_t hwContext;
+ ScreenPtr pScreen;
+ Bool valid3D;
+ DRIContextFlags flags;
+ void** pContextStore;
+};
+
+#define DRI_SCREEN_PRIV(pScreen) \
+ ((DRIScreenPrivIndex < 0) ? \
+ NULL : \
+ ((DRIScreenPrivPtr)((pScreen)->devPrivates[DRIScreenPrivIndex].ptr)))
+
+#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
+ (screenInfo.screens[screenIndex]->devPrivates[DRIScreenPrivIndex].ptr))
+
+
+typedef struct _DRIScreenPrivRec
+{
+ Bool directRenderingSupport;
+ int drmFD; /* File descriptor for /dev/video/? */
+ drm_handle_t hSAREA; /* Handle to SAREA, for mapping */
+ XF86DRISAREAPtr pSAREA; /* Mapped pointer to SAREA */
+ drm_handle_t hFrameBuffer; /* Handle to framebuffer, for mapping */
+ drm_context_t myContext; /* DDX Driver's context */
+ DRIContextPrivPtr myContextPriv;/* Pointer to server's private area */
+ DRIContextPrivPtr lastPartial3DContext; /* last one partially saved */
+ void** hiddenContextStore; /* hidden X context */
+ void** partial3DContextStore; /* parital 3D context */
+ DRIInfoPtr pDriverInfo;
+ int nrWindows;
+ drm_clip_rect_t private_buffer_rect; /* management of private buffers */
+ DrawablePtr fullscreen; /* pointer to fullscreen drawable */
+ drm_clip_rect_t fullscreen_rect; /* fake rect for fullscreen mode */
+ DRIWrappedFuncsRec wrap;
+ DrawablePtr DRIDrawables[SAREA_MAX_DRAWABLES];
+ DRIContextPrivPtr dummyCtxPriv; /* Pointer to dummy context */
+ Bool createDummyCtx;
+ Bool createDummyCtxPriv;
+ Bool grabbedDRILock;
+ Bool drmSIGIOHandlerInstalled;
+ Bool wrapped;
+ int lockRefCount;
+} DRIScreenPrivRec, *DRIScreenPrivPtr;
+
+#endif /* DRI_STRUCT_H */
diff --git a/nx-X11/programs/Xserver/GL/dri/sarea.h b/nx-X11/programs/Xserver/GL/dri/sarea.h
new file mode 100644
index 000000000..77c16e0ef
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/dri/sarea.h
@@ -0,0 +1,94 @@
+/* $XFree86: xc/programs/Xserver/GL/dri/sarea.h,v 1.11 2002/10/30 12:52:03 alanh Exp $ */
+/**
+ * \file sarea.h
+ * SAREA definitions.
+ *
+ * \author Kevin E. Martin <kevin@precisioninsight.com>
+ * \author Jens Owen <jens@tungstengraphics.com>
+ * \author Rickard E. (Rik) Faith <faith@valinux.com>
+ */
+
+/*
+ * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/* $XFree86: xc/programs/Xserver/GL/dri/sarea.h,v 1.11 2002/10/30 12:52:03 alanh Exp $ */
+
+#ifndef _SAREA_H_
+#define _SAREA_H_
+
+#include "xf86drm.h"
+
+/* SAREA area needs to be at least a page */
+#if defined(__alpha__)
+#define SAREA_MAX 0x2000
+#elif defined(__ia64__)
+#define SAREA_MAX 0x10000 /* 64kB */
+#else
+/* Intel 830M driver needs at least 8k SAREA */
+#define SAREA_MAX 0x2000
+#endif
+
+#define SAREA_MAX_DRAWABLES 256
+
+#define SAREA_DRAWABLE_CLAIMED_ENTRY 0x80000000
+
+/**
+ * SAREA per drawable information.
+ *
+ * \sa _XF86DRISAREA.
+ */
+typedef struct _XF86DRISAREADrawable {
+ unsigned int stamp;
+ unsigned int flags;
+} XF86DRISAREADrawableRec, *XF86DRISAREADrawablePtr;
+
+/**
+ * SAREA frame information.
+ *
+ * \sa _XF86DRISAREA.
+ */
+typedef struct _XF86DRISAREAFrame {
+ unsigned int x;
+ unsigned int y;
+ unsigned int width;
+ unsigned int height;
+ unsigned int fullscreen;
+} XF86DRISAREAFrameRec, *XF86DRISAREAFramePtr;
+
+/**
+ * SAREA definition.
+ */
+typedef struct _XF86DRISAREA {
+ /** first thing is always the DRM locking structure */
+ drmLock lock;
+ /** \todo Use readers/writer lock for drawable_lock */
+ drmLock drawable_lock;
+ XF86DRISAREADrawableRec drawableTable[SAREA_MAX_DRAWABLES];
+ XF86DRISAREAFrameRec frame;
+ drm_context_t dummy_context;
+} XF86DRISAREARec, *XF86DRISAREAPtr;
+
+#endif
diff --git a/nx-X11/programs/Xserver/GL/dri/xf86dri.c b/nx-X11/programs/Xserver/GL/dri/xf86dri.c
new file mode 100644
index 000000000..273ccda1b
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/dri/xf86dri.c
@@ -0,0 +1,649 @@
+/* $XFree86: xc/programs/Xserver/GL/dri/xf86dri.c,v 1.12 2002/12/14 01:36:08 dawes Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <martin@valinux.com>
+ * Jens Owen <jens@tungstengraphics.com>
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#ifdef XFree86LOADER
+#include "xf86_ansic.h"
+#endif
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#define _XF86DRI_SERVER_
+#include "xf86dristr.h"
+#include "swaprep.h"
+#include "xf86str.h"
+#include "dri.h"
+#include "sarea.h"
+#include "dristruct.h"
+#include "xf86.h"
+#include "xf86drm.h"
+
+static int DRIErrorBase;
+
+static DISPATCH_PROC(ProcXF86DRIQueryVersion);
+static DISPATCH_PROC(ProcXF86DRIQueryDirectRenderingCapable);
+static DISPATCH_PROC(ProcXF86DRIOpenConnection);
+static DISPATCH_PROC(ProcXF86DRICloseConnection);
+static DISPATCH_PROC(ProcXF86DRIGetClientDriverName);
+static DISPATCH_PROC(ProcXF86DRICreateContext);
+static DISPATCH_PROC(ProcXF86DRIDestroyContext);
+static DISPATCH_PROC(ProcXF86DRICreateDrawable);
+static DISPATCH_PROC(ProcXF86DRIDestroyDrawable);
+static DISPATCH_PROC(ProcXF86DRIGetDrawableInfo);
+static DISPATCH_PROC(ProcXF86DRIGetDeviceInfo);
+static DISPATCH_PROC(ProcXF86DRIDispatch);
+static DISPATCH_PROC(ProcXF86DRIAuthConnection);
+
+static DISPATCH_PROC(SProcXF86DRIQueryVersion);
+static DISPATCH_PROC(SProcXF86DRIDispatch);
+
+static void XF86DRIResetProc(ExtensionEntry* extEntry);
+
+static unsigned char DRIReqCode = 0;
+
+extern void XFree86DRIExtensionInit(void);
+
+void
+XFree86DRIExtensionInit(void)
+{
+ ExtensionEntry* extEntry;
+
+#ifdef XF86DRI_EVENTS
+ EventType = CreateNewResourceType(XF86DRIFreeEvents);
+#endif
+
+ if (
+ DRIExtensionInit() &&
+#ifdef XF86DRI_EVENTS
+ EventType && ScreenPrivateIndex != -1 &&
+#endif
+ (extEntry = AddExtension(XF86DRINAME,
+ XF86DRINumberEvents,
+ XF86DRINumberErrors,
+ ProcXF86DRIDispatch,
+ SProcXF86DRIDispatch,
+ XF86DRIResetProc,
+ StandardMinorOpcode))) {
+ DRIReqCode = (unsigned char)extEntry->base;
+ DRIErrorBase = extEntry->errorBase;
+ }
+}
+
+/*ARGSUSED*/
+static void
+XF86DRIResetProc (
+ ExtensionEntry* extEntry
+)
+{
+ DRIReset();
+}
+
+static int
+ProcXF86DRIQueryVersion(
+ register ClientPtr client
+)
+{
+ xXF86DRIQueryVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xXF86DRIQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = XF86DRI_MAJOR_VERSION;
+ rep.minorVersion = XF86DRI_MINOR_VERSION;
+ rep.patchVersion = XF86DRI_PATCH_VERSION;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ }
+ WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIQueryDirectRenderingCapable(
+ register ClientPtr client
+)
+{
+ xXF86DRIQueryDirectRenderingCapableReply rep;
+ Bool isCapable;
+
+ REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
+ REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!DRIQueryDirectRenderingCapable( screenInfo.screens[stuff->screen],
+ &isCapable)) {
+ return BadValue;
+ }
+ rep.isCapable = isCapable;
+
+ if (!LocalClient(client))
+ rep.isCapable = 0;
+
+ WriteToClient(client,
+ sizeof(xXF86DRIQueryDirectRenderingCapableReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIOpenConnection(
+ register ClientPtr client
+)
+{
+ xXF86DRIOpenConnectionReply rep;
+ drm_handle_t hSAREA;
+ char* busIdString;
+
+ REQUEST(xXF86DRIOpenConnectionReq);
+ REQUEST_SIZE_MATCH(xXF86DRIOpenConnectionReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ if (!DRIOpenConnection( screenInfo.screens[stuff->screen],
+ &hSAREA,
+ &busIdString)) {
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.busIdStringLength = 0;
+ if (busIdString)
+ rep.busIdStringLength = strlen(busIdString);
+ rep.length = (SIZEOF(xXF86DRIOpenConnectionReply) - SIZEOF(xGenericReply) +
+ ((rep.busIdStringLength + 3) & ~3)) >> 2;
+
+ rep.hSAREALow = (CARD32)(hSAREA & 0xffffffff);
+#if defined(LONG64) && !defined(__linux__)
+ rep.hSAREAHigh = (CARD32)(hSAREA >> 32);
+#else
+ rep.hSAREAHigh = 0;
+#endif
+
+ WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), (char *)&rep);
+ if (rep.busIdStringLength)
+ WriteToClient(client, rep.busIdStringLength, busIdString);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIAuthConnection(
+ register ClientPtr client
+)
+{
+ xXF86DRIAuthConnectionReply rep;
+
+ REQUEST(xXF86DRIAuthConnectionReq);
+ REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.authenticated = 1;
+
+ if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) {
+ ErrorF("Failed to authenticate %lu\n", (unsigned long)stuff->magic);
+ rep.authenticated = 0;
+ }
+ WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRICloseConnection(
+ register ClientPtr client
+)
+{
+ REQUEST(xXF86DRICloseConnectionReq);
+ REQUEST_SIZE_MATCH(xXF86DRICloseConnectionReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ DRICloseConnection( screenInfo.screens[stuff->screen]);
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIGetClientDriverName(
+ register ClientPtr client
+)
+{
+ xXF86DRIGetClientDriverNameReply rep;
+ char* clientDriverName;
+
+ REQUEST(xXF86DRIGetClientDriverNameReq);
+ REQUEST_SIZE_MATCH(xXF86DRIGetClientDriverNameReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ DRIGetClientDriverName( screenInfo.screens[stuff->screen],
+ (int *)&rep.ddxDriverMajorVersion,
+ (int *)&rep.ddxDriverMinorVersion,
+ (int *)&rep.ddxDriverPatchVersion,
+ &clientDriverName);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.clientDriverNameLength = 0;
+ if (clientDriverName)
+ rep.clientDriverNameLength = strlen(clientDriverName);
+ rep.length = (SIZEOF(xXF86DRIGetClientDriverNameReply) -
+ SIZEOF(xGenericReply) +
+ ((rep.clientDriverNameLength + 3) & ~3)) >> 2;
+
+ WriteToClient(client,
+ sizeof(xXF86DRIGetClientDriverNameReply), (char *)&rep);
+ if (rep.clientDriverNameLength)
+ WriteToClient(client,
+ rep.clientDriverNameLength,
+ clientDriverName);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRICreateContext(
+ register ClientPtr client
+)
+{
+ xXF86DRICreateContextReply rep;
+ ScreenPtr pScreen;
+ VisualPtr visual;
+ int i;
+
+ REQUEST(xXF86DRICreateContextReq);
+ REQUEST_SIZE_MATCH(xXF86DRICreateContextReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ pScreen = screenInfo.screens[stuff->screen];
+ visual = pScreen->visuals;
+
+ /* Find the requested X visual */
+ for (i = 0; i < pScreen->numVisuals; i++, visual++)
+ if (visual->vid == stuff->visual)
+ break;
+ if (i == pScreen->numVisuals) {
+ /* No visual found */
+ return BadValue;
+ }
+
+ if (!DRICreateContext( pScreen,
+ visual,
+ stuff->context,
+ (drm_context_t *)&rep.hHWContext)) {
+ return BadValue;
+ }
+
+ WriteToClient(client, sizeof(xXF86DRICreateContextReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIDestroyContext(
+ register ClientPtr client
+)
+{
+ REQUEST(xXF86DRIDestroyContextReq);
+ REQUEST_SIZE_MATCH(xXF86DRIDestroyContextReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ if (!DRIDestroyContext( screenInfo.screens[stuff->screen],
+ stuff->context)) {
+ return BadValue;
+ }
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRICreateDrawable(
+ ClientPtr client
+)
+{
+ xXF86DRICreateDrawableReply rep;
+ DrawablePtr pDrawable;
+
+ REQUEST(xXF86DRICreateDrawableReq);
+ REQUEST_SIZE_MATCH(xXF86DRICreateDrawableReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable(
+ (Drawable)stuff->drawable,
+ client,
+ SecurityReadAccess))) {
+ return BadValue;
+ }
+
+ if (!DRICreateDrawable( screenInfo.screens[stuff->screen],
+ (Drawable)stuff->drawable,
+ pDrawable,
+ (drm_drawable_t *)&rep.hHWDrawable)) {
+ return BadValue;
+ }
+
+ WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIDestroyDrawable(
+ register ClientPtr client
+)
+{
+ REQUEST(xXF86DRIDestroyDrawableReq);
+ DrawablePtr pDrawable;
+ REQUEST_SIZE_MATCH(xXF86DRIDestroyDrawableReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable(
+ (Drawable)stuff->drawable,
+ client,
+ SecurityReadAccess))) {
+ return BadValue;
+ }
+
+ if (!DRIDestroyDrawable( screenInfo.screens[stuff->screen],
+ (Drawable)stuff->drawable,
+ pDrawable)) {
+ return BadValue;
+ }
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIGetDrawableInfo(
+ register ClientPtr client
+)
+{
+ xXF86DRIGetDrawableInfoReply rep;
+ DrawablePtr pDrawable;
+ int X, Y, W, H;
+ drm_clip_rect_t * pClipRects;
+ drm_clip_rect_t * pBackClipRects;
+ int backX, backY;
+
+ REQUEST(xXF86DRIGetDrawableInfoReq);
+ REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable(
+ (Drawable)stuff->drawable,
+ client,
+ SecurityReadAccess))) {
+ return BadValue;
+ }
+
+ if (!DRIGetDrawableInfo( screenInfo.screens[stuff->screen],
+ pDrawable,
+ (unsigned int*)&rep.drawableTableIndex,
+ (unsigned int*)&rep.drawableTableStamp,
+ (int*)&X,
+ (int*)&Y,
+ (int*)&W,
+ (int*)&H,
+ (int*)&rep.numClipRects,
+ &pClipRects,
+ &backX,
+ &backY,
+ (int*)&rep.numBackClipRects,
+ &pBackClipRects)) {
+ return BadValue;
+ }
+
+ rep.drawableX = X;
+ rep.drawableY = Y;
+ rep.drawableWidth = W;
+ rep.drawableHeight = H;
+ rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) -
+ SIZEOF(xGenericReply));
+
+ rep.backX = backX;
+ rep.backY = backY;
+
+ if (rep.numBackClipRects)
+ rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects;
+
+ if (rep.numClipRects)
+ rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects;
+
+ rep.length = ((rep.length + 3) & ~3) >> 2;
+
+ WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *)&rep);
+
+ if (rep.numClipRects) {
+ WriteToClient(client,
+ sizeof(drm_clip_rect_t) * rep.numClipRects,
+ (char *)pClipRects);
+ }
+
+ if (rep.numBackClipRects) {
+ WriteToClient(client,
+ sizeof(drm_clip_rect_t) * rep.numBackClipRects,
+ (char *)pBackClipRects);
+ }
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIGetDeviceInfo(
+ register ClientPtr client
+)
+{
+ xXF86DRIGetDeviceInfoReply rep;
+ drm_handle_t hFrameBuffer;
+ void *pDevPrivate;
+
+ REQUEST(xXF86DRIGetDeviceInfoReq);
+ REQUEST_SIZE_MATCH(xXF86DRIGetDeviceInfoReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!DRIGetDeviceInfo( screenInfo.screens[stuff->screen],
+ &hFrameBuffer,
+ (int*)&rep.framebufferOrigin,
+ (int*)&rep.framebufferSize,
+ (int*)&rep.framebufferStride,
+ (int*)&rep.devPrivateSize,
+ &pDevPrivate)) {
+ return BadValue;
+ }
+
+ rep.hFrameBufferLow = (CARD32)(hFrameBuffer & 0xffffffff);
+#if defined(LONG64) && !defined(__linux__)
+ rep.hFrameBufferHigh = (CARD32)(hFrameBuffer >> 32);
+#else
+ rep.hFrameBufferHigh = 0;
+#endif
+
+ rep.length = 0;
+ if (rep.devPrivateSize) {
+ rep.length = (SIZEOF(xXF86DRIGetDeviceInfoReply) -
+ SIZEOF(xGenericReply) +
+ ((rep.devPrivateSize + 3) & ~3)) >> 2;
+ }
+
+ WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *)&rep);
+ if (rep.length) {
+ WriteToClient(client, rep.devPrivateSize, (char *)pDevPrivate);
+ }
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIDispatch (
+ register ClientPtr client
+)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_XF86DRIQueryVersion:
+ return ProcXF86DRIQueryVersion(client);
+ case X_XF86DRIQueryDirectRenderingCapable:
+ return ProcXF86DRIQueryDirectRenderingCapable(client);
+ }
+
+ if (!LocalClient(client))
+ return DRIErrorBase + XF86DRIClientNotLocal;
+
+ switch (stuff->data)
+ {
+ case X_XF86DRIOpenConnection:
+ return ProcXF86DRIOpenConnection(client);
+ case X_XF86DRICloseConnection:
+ return ProcXF86DRICloseConnection(client);
+ case X_XF86DRIGetClientDriverName:
+ return ProcXF86DRIGetClientDriverName(client);
+ case X_XF86DRICreateContext:
+ return ProcXF86DRICreateContext(client);
+ case X_XF86DRIDestroyContext:
+ return ProcXF86DRIDestroyContext(client);
+ case X_XF86DRICreateDrawable:
+ return ProcXF86DRICreateDrawable(client);
+ case X_XF86DRIDestroyDrawable:
+ return ProcXF86DRIDestroyDrawable(client);
+ case X_XF86DRIGetDrawableInfo:
+ return ProcXF86DRIGetDrawableInfo(client);
+ case X_XF86DRIGetDeviceInfo:
+ return ProcXF86DRIGetDeviceInfo(client);
+ case X_XF86DRIAuthConnection:
+ return ProcXF86DRIAuthConnection(client);
+ /* {Open,Close}FullScreen are deprecated now */
+ default:
+ return BadRequest;
+ }
+}
+
+static int
+SProcXF86DRIQueryVersion(
+ register ClientPtr client
+)
+{
+ register int n;
+ REQUEST(xXF86DRIQueryVersionReq);
+ swaps(&stuff->length, n);
+ return ProcXF86DRIQueryVersion(client);
+}
+
+static int
+SProcXF86DRIDispatch (
+ register ClientPtr client
+)
+{
+ REQUEST(xReq);
+
+ /* It is bound to be non-local when there is byte swapping */
+ if (!LocalClient(client))
+ return DRIErrorBase + XF86DRIClientNotLocal;
+
+ /* only local clients are allowed DRI access */
+ switch (stuff->data)
+ {
+ case X_XF86DRIQueryVersion:
+ return SProcXF86DRIQueryVersion(client);
+ default:
+ return BadRequest;
+ }
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/Imakefile b/nx-X11/programs/Xserver/GL/glx/Imakefile
new file mode 100644
index 000000000..5283e2286
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/Imakefile
@@ -0,0 +1,118 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/glx/Imakefile,v 1.11 2004/01/28 18:11:50 alanh Exp $
+
+#if DoLoadableServer
+# if !BuildModuleInSubdir
+# define IHaveModules
+# elif !defined(IHaveModules)
+# define IHaveSubdirs
+SUBDIRS = module
+# endif
+#endif
+
+/* Large PIC tables needed for SPARC builds */
+#if defined(sparc) || defined(SparcArchitecture)
+# define LargePICTable YES
+ PICFLAGS = LargePositionIndependentCFlags
+#endif
+
+#include <Server.tmpl>
+
+LinkSourceFile(glcontextmodes.c, $(MESASRCDIR)/src/mesa/drivers/dri/common)
+LinkSourceFile(glcontextmodes.h, $(MESASRCDIR)/src/mesa/drivers/dri/common)
+LinkSourceFile(indirect_size.c, $(MESASRCDIR)/src/glx/x11)
+LinkSourceFile(indirect_size.h, $(MESASRCDIR)/src/glx/x11)
+
+ SRCS = global.c glxbuf.c glxcmds.c glxcmdsswap.c glxext.c \
+ glxfb.c glximports.c glxmem.c glxpix.c glxscreens.c \
+ glxutil.c render2.c render2swap.c renderpix.c \
+ renderpixswap.c rensize.c rensizetab.c single2.c \
+ single2swap.c singlepix.c singlepixswap.c \
+ singlesize.c xfont.c g_disptab.c g_disptab_EXT.c \
+ g_render.c g_renderswap.c g_single.c g_singleswap.c \
+ glcontextmodes.c indirect_size.c $(MSRCS)
+
+ OBJS = global.o glxbuf.o glxcmds.o glxcmdsswap.o glxext.o \
+ glxfb.o glximports.o glxmem.o glxpix.o glxscreens.o \
+ glxutil.o render2.o render2swap.o renderpix.o \
+ renderpixswap.o rensize.o rensizetab.o single2.o \
+ single2swap.o singlepix.o singlepixswap.o \
+ singlesize.o xfont.o g_disptab.o g_disptab_EXT.o \
+ g_render.o g_renderswap.o g_single.o g_singleswap.o \
+ glcontextmodes.o indirect_size.o $(MOBJS)
+
+ INCLUDES = -I$(SERVERSRC)/GL/glx -I$(SERVERSRC)/GL/include -I$(SERVERSRC)/include -I$(INCLUDESRC) -I$(MESASRCDIR)/include \
+ -I$(XINCLUDESRC) -I$(SERVERSRC)/mi \
+ -I$(EXTINCSRC) -I$(FONTINCSRC) -I$(LIBSRC)/GL/include \
+ -I$(XF86SRC)
+
+#if defined(DarwinArchitecture) && ((OSMajorVersion == 6 && OSMinorVersion < 3) || OSMajorVersion < 6)
+ NO_EXT_DEFS = -DMISSING_GL_EXTS
+#endif
+#if defined(Win32Architecture)
+# undef __stdcall
+ APIENTRY_DEFS = -DAPIENTRY=__stdcall
+#endif
+
+XCOMM If you add "-DDEBUG" in DEFINES, then make sure you also
+XCOMM add DEBUG to the define in ../mesa/src/X/xf86glx.c
+ DEFINES = $(GLX_DEFINES) $(NO_EXT_DEFS) $(APIENTRY_DEFS)
+
+
+#ifdef IHaveModules
+ModuleObjectRule()
+LibraryModuleTarget(glx,$(OBJS))
+#else
+NormalLibraryObjectRule()
+NormalLibraryTarget(glx,$(OBJS))
+#if defined(GlxUseWindows) && GlxUseWindows
+clean::
+ RemoveFiles($(foreach obj,$(OBJS), stdcall/$(obj)))
+includes::
+ MakeDir(stdcall)
+SpecialObjectRule(stdcall/%.o,%.c,-DUSE_OPENGL32 -o $@)
+NormalLibraryTarget(glx_stdcall,$(foreach obj,$(OBJS), stdcall/$(obj)))
+#endif
+#endif
+SubdirLibraryRule($(OBJS))
+
+LintLibraryTarget(glx,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+#ifdef LinkDirectory
+LinkSourceFile(global.c,LinkDirectory)
+LinkSourceFile(glxbuf.c,LinkDirectory)
+LinkSourceFile(glxcmds.c,LinkDirectory)
+LinkSourceFile(glxcmdsswap.c,LinkDirectory)
+LinkSourceFile(glxext.c,LinkDirectory)
+LinkSourceFile(glxfb.c,LinkDirectory)
+LinkSourceFile(glximports.c,LinkDirectory)
+LinkSourceFile(glxmem.c,LinkDirectory)
+LinkSourceFile(glxpix.c,LinkDirectory)
+LinkSourceFile(glxscreens.c,LinkDirectory)
+LinkSourceFile(glxutil.c,LinkDirectory)
+LinkSourceFile(render2.c,LinkDirectory)
+LinkSourceFile(render2swap.c,LinkDirectory)
+LinkSourceFile(renderpix.c,LinkDirectory)
+LinkSourceFile(renderpixswap.c,LinkDirectory)
+LinkSourceFile(rensize.c,LinkDirectory)
+LinkSourceFile(rensizetab.c,LinkDirectory)
+LinkSourceFile(single2.c,LinkDirectory)
+LinkSourceFile(single2swap.c,LinkDirectory)
+LinkSourceFile(singlepix.c,LinkDirectory)
+LinkSourceFile(singlepixswap.c,LinkDirectory)
+LinkSourceFile(singlesize.c,LinkDirectory)
+LinkSourceFile(xfont.c,LinkDirectory)
+LinkSourceFile(g_disptab.c,LinkDirectory)
+LinkSourceFile(g_disptab_EXT.c,LinkDirectory)
+LinkSourceFile(g_render.c,LinkDirectory)
+LinkSourceFile(g_renderswap.c,LinkDirectory)
+LinkSourceFile(g_single.c,LinkDirectory)
+LinkSourceFile(g_singleswap.c,LinkDirectory)
+#endif
diff --git a/nx-X11/programs/Xserver/GL/glx/g_disptab.c b/nx-X11/programs/Xserver/GL/glx/g_disptab.c
new file mode 100644
index 000000000..93a9d628d
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/g_disptab.c
@@ -0,0 +1,839 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/g_disptab.c,v 1.5 2004/01/28 18:11:50 alanh Exp $ */
+/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxext.h"
+#include "g_disptab.h"
+__GLXdispatchSingleProcPtr __glXSingleTable[__GLX_SINGLE_TABLE_SIZE] = {
+ __glXNoSuchSingleOpcode,
+ __glXRender,
+ __glXRenderLarge,
+ __glXCreateContext,
+ __glXDestroyContext,
+ __glXMakeCurrent,
+ __glXIsDirect,
+ __glXQueryVersion,
+ __glXWaitGL,
+ __glXWaitX,
+ __glXCopyContext,
+ __glXSwapBuffers,
+ __glXUseXFont,
+ __glXCreateGLXPixmap,
+ __glXGetVisualConfigs,
+ __glXDestroyGLXPixmap,
+ __glXVendorPrivate,
+ __glXVendorPrivateWithReply,
+ __glXQueryExtensionsString,
+ __glXQueryServerString,
+ __glXClientInfo,
+ __glXGetFBConfigs,
+ __glXCreatePixmap,
+ __glXDestroyGLXPixmap, /* glXDestroyPixmap */
+ __glXCreateNewContext,
+ __glXNoSuchSingleOpcode, /* glXQueryContext */
+ __glXMakeContextCurrent,
+ __glXNoSuchSingleOpcode, /* glXCreatePbuffer */
+ __glXNoSuchSingleOpcode, /* glXDestroyPbuffer */
+ __glXNoSuchSingleOpcode, /* glXGetDrawableAttributes */
+ __glXNoSuchSingleOpcode, /* glXChangeDrawableAttributes */
+ __glXNoSuchSingleOpcode, /* glXCreateWindow */
+ __glXNoSuchSingleOpcode, /* glXDestroyWindow */
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXDisp_NewList,
+ __glXDisp_EndList,
+ __glXDisp_DeleteLists,
+ __glXDisp_GenLists,
+ __glXDisp_FeedbackBuffer,
+ __glXDisp_SelectBuffer,
+ __glXDisp_RenderMode,
+ __glXDisp_Finish,
+ __glXDisp_PixelStoref,
+ __glXDisp_PixelStorei,
+ __glXDisp_ReadPixels,
+ __glXDisp_GetBooleanv,
+ __glXDisp_GetClipPlane,
+ __glXDisp_GetDoublev,
+ __glXDisp_GetError,
+ __glXDisp_GetFloatv,
+ __glXDisp_GetIntegerv,
+ __glXDisp_GetLightfv,
+ __glXDisp_GetLightiv,
+ __glXDisp_GetMapdv,
+ __glXDisp_GetMapfv,
+ __glXDisp_GetMapiv,
+ __glXDisp_GetMaterialfv,
+ __glXDisp_GetMaterialiv,
+ __glXDisp_GetPixelMapfv,
+ __glXDisp_GetPixelMapuiv,
+ __glXDisp_GetPixelMapusv,
+ __glXDisp_GetPolygonStipple,
+ __glXDisp_GetString,
+ __glXDisp_GetTexEnvfv,
+ __glXDisp_GetTexEnviv,
+ __glXDisp_GetTexGendv,
+ __glXDisp_GetTexGenfv,
+ __glXDisp_GetTexGeniv,
+ __glXDisp_GetTexImage,
+ __glXDisp_GetTexParameterfv,
+ __glXDisp_GetTexParameteriv,
+ __glXDisp_GetTexLevelParameterfv,
+ __glXDisp_GetTexLevelParameteriv,
+ __glXDisp_IsEnabled,
+ __glXDisp_IsList,
+ __glXDisp_Flush,
+ __glXDisp_AreTexturesResident,
+ __glXDisp_DeleteTextures,
+ __glXDisp_GenTextures,
+ __glXDisp_IsTexture,
+ __glXDisp_GetColorTable,
+ __glXDisp_GetColorTableParameterfv,
+ __glXDisp_GetColorTableParameteriv,
+ __glXDisp_GetConvolutionFilter,
+ __glXDisp_GetConvolutionParameterfv,
+ __glXDisp_GetConvolutionParameteriv,
+ __glXDisp_GetSeparableFilter,
+ __glXDisp_GetHistogram,
+ __glXDisp_GetHistogramParameterfv,
+ __glXDisp_GetHistogramParameteriv,
+ __glXDisp_GetMinmax,
+ __glXDisp_GetMinmaxParameterfv,
+ __glXDisp_GetMinmaxParameteriv,
+};
+
+__GLXdispatchRenderProcPtr __glXRenderTable[] = {
+ __glXNoSuchRenderOpcode,
+ __glXDisp_CallList,
+ __glXDisp_CallLists,
+ __glXDisp_ListBase,
+ __glXDisp_Begin,
+ __glXDisp_Bitmap,
+ __glXDisp_Color3bv,
+ __glXDisp_Color3dv,
+ __glXDisp_Color3fv,
+ __glXDisp_Color3iv,
+ __glXDisp_Color3sv,
+ __glXDisp_Color3ubv,
+ __glXDisp_Color3uiv,
+ __glXDisp_Color3usv,
+ __glXDisp_Color4bv,
+ __glXDisp_Color4dv,
+ __glXDisp_Color4fv,
+ __glXDisp_Color4iv,
+ __glXDisp_Color4sv,
+ __glXDisp_Color4ubv,
+ __glXDisp_Color4uiv,
+ __glXDisp_Color4usv,
+ __glXDisp_EdgeFlagv,
+ __glXDisp_End,
+ __glXDisp_Indexdv,
+ __glXDisp_Indexfv,
+ __glXDisp_Indexiv,
+ __glXDisp_Indexsv,
+ __glXDisp_Normal3bv,
+ __glXDisp_Normal3dv,
+ __glXDisp_Normal3fv,
+ __glXDisp_Normal3iv,
+ __glXDisp_Normal3sv,
+ __glXDisp_RasterPos2dv,
+ __glXDisp_RasterPos2fv,
+ __glXDisp_RasterPos2iv,
+ __glXDisp_RasterPos2sv,
+ __glXDisp_RasterPos3dv,
+ __glXDisp_RasterPos3fv,
+ __glXDisp_RasterPos3iv,
+ __glXDisp_RasterPos3sv,
+ __glXDisp_RasterPos4dv,
+ __glXDisp_RasterPos4fv,
+ __glXDisp_RasterPos4iv,
+ __glXDisp_RasterPos4sv,
+ __glXDisp_Rectdv,
+ __glXDisp_Rectfv,
+ __glXDisp_Rectiv,
+ __glXDisp_Rectsv,
+ __glXDisp_TexCoord1dv,
+ __glXDisp_TexCoord1fv,
+ __glXDisp_TexCoord1iv,
+ __glXDisp_TexCoord1sv,
+ __glXDisp_TexCoord2dv,
+ __glXDisp_TexCoord2fv,
+ __glXDisp_TexCoord2iv,
+ __glXDisp_TexCoord2sv,
+ __glXDisp_TexCoord3dv,
+ __glXDisp_TexCoord3fv,
+ __glXDisp_TexCoord3iv,
+ __glXDisp_TexCoord3sv,
+ __glXDisp_TexCoord4dv,
+ __glXDisp_TexCoord4fv,
+ __glXDisp_TexCoord4iv,
+ __glXDisp_TexCoord4sv,
+ __glXDisp_Vertex2dv,
+ __glXDisp_Vertex2fv,
+ __glXDisp_Vertex2iv,
+ __glXDisp_Vertex2sv,
+ __glXDisp_Vertex3dv,
+ __glXDisp_Vertex3fv,
+ __glXDisp_Vertex3iv,
+ __glXDisp_Vertex3sv,
+ __glXDisp_Vertex4dv,
+ __glXDisp_Vertex4fv,
+ __glXDisp_Vertex4iv,
+ __glXDisp_Vertex4sv,
+ __glXDisp_ClipPlane,
+ __glXDisp_ColorMaterial,
+ __glXDisp_CullFace,
+ __glXDisp_Fogf,
+ __glXDisp_Fogfv,
+ __glXDisp_Fogi,
+ __glXDisp_Fogiv,
+ __glXDisp_FrontFace,
+ __glXDisp_Hint,
+ __glXDisp_Lightf,
+ __glXDisp_Lightfv,
+ __glXDisp_Lighti,
+ __glXDisp_Lightiv,
+ __glXDisp_LightModelf,
+ __glXDisp_LightModelfv,
+ __glXDisp_LightModeli,
+ __glXDisp_LightModeliv,
+ __glXDisp_LineStipple,
+ __glXDisp_LineWidth,
+ __glXDisp_Materialf,
+ __glXDisp_Materialfv,
+ __glXDisp_Materiali,
+ __glXDisp_Materialiv,
+ __glXDisp_PointSize,
+ __glXDisp_PolygonMode,
+ __glXDisp_PolygonStipple,
+ __glXDisp_Scissor,
+ __glXDisp_ShadeModel,
+ __glXDisp_TexParameterf,
+ __glXDisp_TexParameterfv,
+ __glXDisp_TexParameteri,
+ __glXDisp_TexParameteriv,
+ __glXDisp_TexImage1D,
+ __glXDisp_TexImage2D,
+ __glXDisp_TexEnvf,
+ __glXDisp_TexEnvfv,
+ __glXDisp_TexEnvi,
+ __glXDisp_TexEnviv,
+ __glXDisp_TexGend,
+ __glXDisp_TexGendv,
+ __glXDisp_TexGenf,
+ __glXDisp_TexGenfv,
+ __glXDisp_TexGeni,
+ __glXDisp_TexGeniv,
+ __glXDisp_InitNames,
+ __glXDisp_LoadName,
+ __glXDisp_PassThrough,
+ __glXDisp_PopName,
+ __glXDisp_PushName,
+ __glXDisp_DrawBuffer,
+ __glXDisp_Clear,
+ __glXDisp_ClearAccum,
+ __glXDisp_ClearIndex,
+ __glXDisp_ClearColor,
+ __glXDisp_ClearStencil,
+ __glXDisp_ClearDepth,
+ __glXDisp_StencilMask,
+ __glXDisp_ColorMask,
+ __glXDisp_DepthMask,
+ __glXDisp_IndexMask,
+ __glXDisp_Accum,
+ __glXDisp_Disable,
+ __glXDisp_Enable,
+ __glXNoSuchRenderOpcode,
+ __glXDisp_PopAttrib,
+ __glXDisp_PushAttrib,
+ __glXDisp_Map1d,
+ __glXDisp_Map1f,
+ __glXDisp_Map2d,
+ __glXDisp_Map2f,
+ __glXDisp_MapGrid1d,
+ __glXDisp_MapGrid1f,
+ __glXDisp_MapGrid2d,
+ __glXDisp_MapGrid2f,
+ __glXDisp_EvalCoord1dv,
+ __glXDisp_EvalCoord1fv,
+ __glXDisp_EvalCoord2dv,
+ __glXDisp_EvalCoord2fv,
+ __glXDisp_EvalMesh1,
+ __glXDisp_EvalPoint1,
+ __glXDisp_EvalMesh2,
+ __glXDisp_EvalPoint2,
+ __glXDisp_AlphaFunc,
+ __glXDisp_BlendFunc,
+ __glXDisp_LogicOp,
+ __glXDisp_StencilFunc,
+ __glXDisp_StencilOp,
+ __glXDisp_DepthFunc,
+ __glXDisp_PixelZoom,
+ __glXDisp_PixelTransferf,
+ __glXDisp_PixelTransferi,
+ __glXDisp_PixelMapfv,
+ __glXDisp_PixelMapuiv,
+ __glXDisp_PixelMapusv,
+ __glXDisp_ReadBuffer,
+ __glXDisp_CopyPixels,
+ __glXDisp_DrawPixels,
+ __glXDisp_DepthRange,
+ __glXDisp_Frustum,
+ __glXDisp_LoadIdentity,
+ __glXDisp_LoadMatrixf,
+ __glXDisp_LoadMatrixd,
+ __glXDisp_MatrixMode,
+ __glXDisp_MultMatrixf,
+ __glXDisp_MultMatrixd,
+ __glXDisp_Ortho,
+ __glXDisp_PopMatrix,
+ __glXDisp_PushMatrix,
+ __glXDisp_Rotated,
+ __glXDisp_Rotatef,
+ __glXDisp_Scaled,
+ __glXDisp_Scalef,
+ __glXDisp_Translated,
+ __glXDisp_Translatef,
+ __glXDisp_Viewport,
+ __glXDisp_PolygonOffset,
+ __glXDisp_DrawArrays,
+ __glXDisp_Indexubv,
+ __glXDisp_ColorSubTable,
+ __glXDisp_CopyColorSubTable,
+ __glXDisp_ActiveTextureARB,
+ __glXDisp_MultiTexCoord1dvARB,
+ __glXDisp_MultiTexCoord1fvARB,
+ __glXDisp_MultiTexCoord1ivARB,
+ __glXDisp_MultiTexCoord1svARB,
+ __glXDisp_MultiTexCoord2dvARB,
+ __glXDisp_MultiTexCoord2fvARB,
+ __glXDisp_MultiTexCoord2ivARB,
+ __glXDisp_MultiTexCoord2svARB,
+ __glXDisp_MultiTexCoord3dvARB,
+ __glXDisp_MultiTexCoord3fvARB,
+ __glXDisp_MultiTexCoord3ivARB,
+ __glXDisp_MultiTexCoord3svARB,
+ __glXDisp_MultiTexCoord4dvARB,
+ __glXDisp_MultiTexCoord4fvARB,
+ __glXDisp_MultiTexCoord4ivARB,
+ __glXDisp_MultiTexCoord4svARB, /* 213 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 220 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXDisp_SampleCoverageARB,
+#ifndef MISSING_GL_EXTS
+ __glXDisp_WindowPos3fARB /* 230 */
+#else
+ __glXNoSuchRenderOpcode
+#endif
+};
+
+__GLXdispatchSingleProcPtr __glXSwapSingleTable[__GLX_SINGLE_TABLE_SIZE] = {
+ __glXNoSuchSingleOpcode,
+ __glXSwapRender,
+ __glXSwapRenderLarge,
+ __glXSwapCreateContext,
+ __glXSwapDestroyContext,
+ __glXSwapMakeCurrent,
+ __glXSwapIsDirect,
+ __glXSwapQueryVersion,
+ __glXSwapWaitGL,
+ __glXSwapWaitX,
+ __glXSwapCopyContext,
+ __glXSwapSwapBuffers,
+ __glXSwapUseXFont,
+ __glXSwapCreateGLXPixmap,
+ __glXSwapGetVisualConfigs,
+ __glXSwapDestroyGLXPixmap,
+ __glXSwapVendorPrivate,
+ __glXSwapVendorPrivateWithReply,
+ __glXSwapQueryExtensionsString,
+ __glXSwapQueryServerString,
+ __glXSwapClientInfo,
+ __glXSwapGetFBConfigs,
+ __glXSwapCreatePixmap,
+ __glXSwapDestroyGLXPixmap, /* glXDestroyPixmap */
+ __glXSwapCreateNewContext,
+ __glXNoSuchSingleOpcode, /* glXQueryContext */
+ __glXSwapMakeContextCurrent,
+ __glXNoSuchSingleOpcode, /* glXCreatePbuffer */
+ __glXNoSuchSingleOpcode, /* glXDestroyPbuffer */
+ __glXNoSuchSingleOpcode, /* glXGetDrawableAttributes */
+ __glXNoSuchSingleOpcode, /* glXChangeDrawableAttributes */
+ __glXNoSuchSingleOpcode, /* glXCreateWindow */
+ __glXNoSuchSingleOpcode, /* glXDestroyWindow */
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXDispSwap_NewList,
+ __glXDispSwap_EndList,
+ __glXDispSwap_DeleteLists,
+ __glXDispSwap_GenLists,
+ __glXDispSwap_FeedbackBuffer,
+ __glXDispSwap_SelectBuffer,
+ __glXDispSwap_RenderMode,
+ __glXDispSwap_Finish,
+ __glXDispSwap_PixelStoref,
+ __glXDispSwap_PixelStorei,
+ __glXDispSwap_ReadPixels,
+ __glXDispSwap_GetBooleanv,
+ __glXDispSwap_GetClipPlane,
+ __glXDispSwap_GetDoublev,
+ __glXDispSwap_GetError,
+ __glXDispSwap_GetFloatv,
+ __glXDispSwap_GetIntegerv,
+ __glXDispSwap_GetLightfv,
+ __glXDispSwap_GetLightiv,
+ __glXDispSwap_GetMapdv,
+ __glXDispSwap_GetMapfv,
+ __glXDispSwap_GetMapiv,
+ __glXDispSwap_GetMaterialfv,
+ __glXDispSwap_GetMaterialiv,
+ __glXDispSwap_GetPixelMapfv,
+ __glXDispSwap_GetPixelMapuiv,
+ __glXDispSwap_GetPixelMapusv,
+ __glXDispSwap_GetPolygonStipple,
+ __glXDispSwap_GetString,
+ __glXDispSwap_GetTexEnvfv,
+ __glXDispSwap_GetTexEnviv,
+ __glXDispSwap_GetTexGendv,
+ __glXDispSwap_GetTexGenfv,
+ __glXDispSwap_GetTexGeniv,
+ __glXDispSwap_GetTexImage,
+ __glXDispSwap_GetTexParameterfv,
+ __glXDispSwap_GetTexParameteriv,
+ __glXDispSwap_GetTexLevelParameterfv,
+ __glXDispSwap_GetTexLevelParameteriv,
+ __glXDispSwap_IsEnabled,
+ __glXDispSwap_IsList,
+ __glXDispSwap_Flush,
+ __glXDispSwap_AreTexturesResident,
+ __glXDispSwap_DeleteTextures,
+ __glXDispSwap_GenTextures,
+ __glXDispSwap_IsTexture,
+ __glXDispSwap_GetColorTable,
+ __glXDispSwap_GetColorTableParameterfv,
+ __glXDispSwap_GetColorTableParameteriv,
+ __glXDispSwap_GetConvolutionFilter,
+ __glXDispSwap_GetConvolutionParameterfv,
+ __glXDispSwap_GetConvolutionParameteriv,
+ __glXDispSwap_GetSeparableFilter,
+ __glXDispSwap_GetHistogram,
+ __glXDispSwap_GetHistogramParameterfv,
+ __glXDispSwap_GetHistogramParameteriv,
+ __glXDispSwap_GetMinmax,
+ __glXDispSwap_GetMinmaxParameterfv,
+ __glXDispSwap_GetMinmaxParameteriv,
+};
+
+__GLXdispatchRenderProcPtr __glXSwapRenderTable[__GLX_RENDER_TABLE_SIZE] = {
+ __glXNoSuchRenderOpcode,
+ __glXDispSwap_CallList,
+ __glXDispSwap_CallLists,
+ __glXDispSwap_ListBase,
+ __glXDispSwap_Begin,
+ __glXDispSwap_Bitmap,
+ __glXDispSwap_Color3bv,
+ __glXDispSwap_Color3dv,
+ __glXDispSwap_Color3fv,
+ __glXDispSwap_Color3iv,
+ __glXDispSwap_Color3sv,
+ __glXDispSwap_Color3ubv,
+ __glXDispSwap_Color3uiv,
+ __glXDispSwap_Color3usv,
+ __glXDispSwap_Color4bv,
+ __glXDispSwap_Color4dv,
+ __glXDispSwap_Color4fv,
+ __glXDispSwap_Color4iv,
+ __glXDispSwap_Color4sv,
+ __glXDispSwap_Color4ubv,
+ __glXDispSwap_Color4uiv,
+ __glXDispSwap_Color4usv,
+ __glXDispSwap_EdgeFlagv,
+ __glXDispSwap_End,
+ __glXDispSwap_Indexdv,
+ __glXDispSwap_Indexfv,
+ __glXDispSwap_Indexiv,
+ __glXDispSwap_Indexsv,
+ __glXDispSwap_Normal3bv,
+ __glXDispSwap_Normal3dv,
+ __glXDispSwap_Normal3fv,
+ __glXDispSwap_Normal3iv,
+ __glXDispSwap_Normal3sv,
+ __glXDispSwap_RasterPos2dv,
+ __glXDispSwap_RasterPos2fv,
+ __glXDispSwap_RasterPos2iv,
+ __glXDispSwap_RasterPos2sv,
+ __glXDispSwap_RasterPos3dv,
+ __glXDispSwap_RasterPos3fv,
+ __glXDispSwap_RasterPos3iv,
+ __glXDispSwap_RasterPos3sv,
+ __glXDispSwap_RasterPos4dv,
+ __glXDispSwap_RasterPos4fv,
+ __glXDispSwap_RasterPos4iv,
+ __glXDispSwap_RasterPos4sv,
+ __glXDispSwap_Rectdv,
+ __glXDispSwap_Rectfv,
+ __glXDispSwap_Rectiv,
+ __glXDispSwap_Rectsv,
+ __glXDispSwap_TexCoord1dv,
+ __glXDispSwap_TexCoord1fv,
+ __glXDispSwap_TexCoord1iv,
+ __glXDispSwap_TexCoord1sv,
+ __glXDispSwap_TexCoord2dv,
+ __glXDispSwap_TexCoord2fv,
+ __glXDispSwap_TexCoord2iv,
+ __glXDispSwap_TexCoord2sv,
+ __glXDispSwap_TexCoord3dv,
+ __glXDispSwap_TexCoord3fv,
+ __glXDispSwap_TexCoord3iv,
+ __glXDispSwap_TexCoord3sv,
+ __glXDispSwap_TexCoord4dv,
+ __glXDispSwap_TexCoord4fv,
+ __glXDispSwap_TexCoord4iv,
+ __glXDispSwap_TexCoord4sv,
+ __glXDispSwap_Vertex2dv,
+ __glXDispSwap_Vertex2fv,
+ __glXDispSwap_Vertex2iv,
+ __glXDispSwap_Vertex2sv,
+ __glXDispSwap_Vertex3dv,
+ __glXDispSwap_Vertex3fv,
+ __glXDispSwap_Vertex3iv,
+ __glXDispSwap_Vertex3sv,
+ __glXDispSwap_Vertex4dv,
+ __glXDispSwap_Vertex4fv,
+ __glXDispSwap_Vertex4iv,
+ __glXDispSwap_Vertex4sv,
+ __glXDispSwap_ClipPlane,
+ __glXDispSwap_ColorMaterial,
+ __glXDispSwap_CullFace,
+ __glXDispSwap_Fogf,
+ __glXDispSwap_Fogfv,
+ __glXDispSwap_Fogi,
+ __glXDispSwap_Fogiv,
+ __glXDispSwap_FrontFace,
+ __glXDispSwap_Hint,
+ __glXDispSwap_Lightf,
+ __glXDispSwap_Lightfv,
+ __glXDispSwap_Lighti,
+ __glXDispSwap_Lightiv,
+ __glXDispSwap_LightModelf,
+ __glXDispSwap_LightModelfv,
+ __glXDispSwap_LightModeli,
+ __glXDispSwap_LightModeliv,
+ __glXDispSwap_LineStipple,
+ __glXDispSwap_LineWidth,
+ __glXDispSwap_Materialf,
+ __glXDispSwap_Materialfv,
+ __glXDispSwap_Materiali,
+ __glXDispSwap_Materialiv,
+ __glXDispSwap_PointSize,
+ __glXDispSwap_PolygonMode,
+ __glXDispSwap_PolygonStipple,
+ __glXDispSwap_Scissor,
+ __glXDispSwap_ShadeModel,
+ __glXDispSwap_TexParameterf,
+ __glXDispSwap_TexParameterfv,
+ __glXDispSwap_TexParameteri,
+ __glXDispSwap_TexParameteriv,
+ __glXDispSwap_TexImage1D,
+ __glXDispSwap_TexImage2D,
+ __glXDispSwap_TexEnvf,
+ __glXDispSwap_TexEnvfv,
+ __glXDispSwap_TexEnvi,
+ __glXDispSwap_TexEnviv,
+ __glXDispSwap_TexGend,
+ __glXDispSwap_TexGendv,
+ __glXDispSwap_TexGenf,
+ __glXDispSwap_TexGenfv,
+ __glXDispSwap_TexGeni,
+ __glXDispSwap_TexGeniv,
+ __glXDispSwap_InitNames,
+ __glXDispSwap_LoadName,
+ __glXDispSwap_PassThrough,
+ __glXDispSwap_PopName,
+ __glXDispSwap_PushName,
+ __glXDispSwap_DrawBuffer,
+ __glXDispSwap_Clear,
+ __glXDispSwap_ClearAccum,
+ __glXDispSwap_ClearIndex,
+ __glXDispSwap_ClearColor,
+ __glXDispSwap_ClearStencil,
+ __glXDispSwap_ClearDepth,
+ __glXDispSwap_StencilMask,
+ __glXDispSwap_ColorMask,
+ __glXDispSwap_DepthMask,
+ __glXDispSwap_IndexMask,
+ __glXDispSwap_Accum,
+ __glXDispSwap_Disable,
+ __glXDispSwap_Enable,
+ __glXNoSuchRenderOpcode,
+ __glXDispSwap_PopAttrib,
+ __glXDispSwap_PushAttrib,
+ __glXDispSwap_Map1d,
+ __glXDispSwap_Map1f,
+ __glXDispSwap_Map2d,
+ __glXDispSwap_Map2f,
+ __glXDispSwap_MapGrid1d,
+ __glXDispSwap_MapGrid1f,
+ __glXDispSwap_MapGrid2d,
+ __glXDispSwap_MapGrid2f,
+ __glXDispSwap_EvalCoord1dv,
+ __glXDispSwap_EvalCoord1fv,
+ __glXDispSwap_EvalCoord2dv,
+ __glXDispSwap_EvalCoord2fv,
+ __glXDispSwap_EvalMesh1,
+ __glXDispSwap_EvalPoint1,
+ __glXDispSwap_EvalMesh2,
+ __glXDispSwap_EvalPoint2,
+ __glXDispSwap_AlphaFunc,
+ __glXDispSwap_BlendFunc,
+ __glXDispSwap_LogicOp,
+ __glXDispSwap_StencilFunc,
+ __glXDispSwap_StencilOp,
+ __glXDispSwap_DepthFunc,
+ __glXDispSwap_PixelZoom,
+ __glXDispSwap_PixelTransferf,
+ __glXDispSwap_PixelTransferi,
+ __glXDispSwap_PixelMapfv,
+ __glXDispSwap_PixelMapuiv,
+ __glXDispSwap_PixelMapusv,
+ __glXDispSwap_ReadBuffer,
+ __glXDispSwap_CopyPixels,
+ __glXDispSwap_DrawPixels,
+ __glXDispSwap_DepthRange,
+ __glXDispSwap_Frustum,
+ __glXDispSwap_LoadIdentity,
+ __glXDispSwap_LoadMatrixf,
+ __glXDispSwap_LoadMatrixd,
+ __glXDispSwap_MatrixMode,
+ __glXDispSwap_MultMatrixf,
+ __glXDispSwap_MultMatrixd,
+ __glXDispSwap_Ortho,
+ __glXDispSwap_PopMatrix,
+ __glXDispSwap_PushMatrix,
+ __glXDispSwap_Rotated,
+ __glXDispSwap_Rotatef,
+ __glXDispSwap_Scaled,
+ __glXDispSwap_Scalef,
+ __glXDispSwap_Translated,
+ __glXDispSwap_Translatef,
+ __glXDispSwap_Viewport,
+ __glXDispSwap_PolygonOffset,
+ __glXDispSwap_DrawArrays,
+ __glXDispSwap_Indexubv,
+ __glXDispSwap_ColorSubTable,
+ __glXDispSwap_CopyColorSubTable,
+ __glXDispSwap_ActiveTextureARB,
+ __glXDispSwap_MultiTexCoord1dvARB,
+ __glXDispSwap_MultiTexCoord1fvARB,
+ __glXDispSwap_MultiTexCoord1ivARB,
+ __glXDispSwap_MultiTexCoord1svARB,
+ __glXDispSwap_MultiTexCoord2dvARB,
+ __glXDispSwap_MultiTexCoord2fvARB,
+ __glXDispSwap_MultiTexCoord2ivARB,
+ __glXDispSwap_MultiTexCoord2svARB,
+ __glXDispSwap_MultiTexCoord3dvARB,
+ __glXDispSwap_MultiTexCoord3fvARB,
+ __glXDispSwap_MultiTexCoord3ivARB,
+ __glXDispSwap_MultiTexCoord3svARB,
+ __glXDispSwap_MultiTexCoord4dvARB,
+ __glXDispSwap_MultiTexCoord4fvARB,
+ __glXDispSwap_MultiTexCoord4ivARB,
+ __glXDispSwap_MultiTexCoord4svARB, /* 213 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 220 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXDispSwap_SampleCoverageARB,
+#ifndef MISSING_GL_EXTS
+ __glXDispSwap_WindowPos3fARB /* 230 */
+#else
+ __glXNoSuchRenderOpcode
+#endif
+};
diff --git a/nx-X11/programs/Xserver/GL/glx/g_disptab.h b/nx-X11/programs/Xserver/GL/glx/g_disptab.h
new file mode 100644
index 000000000..0580b5529
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/g_disptab.h
@@ -0,0 +1,652 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/g_disptab.h,v 1.4 2003/09/28 20:15:42 alanh Exp $ */
+/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _GLX_g_disptab_h_
+#define _GLX_g_disptab_h_
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+extern int __glXRender(__GLXclientState*, GLbyte*);
+extern int __glXRenderLarge(__GLXclientState*, GLbyte*);
+extern int __glXCreateContext(__GLXclientState*, GLbyte*);
+extern int __glXDestroyContext(__GLXclientState*, GLbyte*);
+extern int __glXMakeCurrent(__GLXclientState*, GLbyte*);
+extern int __glXIsDirect(__GLXclientState*, GLbyte*);
+extern int __glXQueryVersion(__GLXclientState*, GLbyte*);
+extern int __glXWaitGL(__GLXclientState*, GLbyte*);
+extern int __glXWaitX(__GLXclientState*, GLbyte*);
+extern int __glXCopyContext(__GLXclientState*, GLbyte*);
+extern int __glXSwapBuffers(__GLXclientState*, GLbyte*);
+extern int __glXUseXFont(__GLXclientState*, GLbyte*);
+extern int __glXCreateGLXPixmap(__GLXclientState*, GLbyte*);
+extern int __glXGetVisualConfigs(__GLXclientState*, GLbyte*);
+extern int __glXDestroyGLXPixmap(__GLXclientState*, GLbyte*);
+extern int __glXVendorPrivate(__GLXclientState*, GLbyte*);
+extern int __glXVendorPrivateWithReply(__GLXclientState*, GLbyte*);
+extern int __glXQueryExtensionsString(__GLXclientState*, GLbyte*);
+extern int __glXQueryServerString(__GLXclientState*, GLbyte*);
+extern int __glXClientInfo(__GLXclientState*, GLbyte*);
+extern int __glXMakeContextCurrent(__GLXclientState*, GLbyte*);
+extern int __glXGetFBConfigs(__GLXclientState*, GLbyte*);
+extern int __glXCreateNewContext(__GLXclientState*, GLbyte*);
+extern int __glXCreatePixmap(__GLXclientState*, GLbyte*);
+
+extern int __glXDisp_NewList(__GLXclientState*, GLbyte*);
+extern int __glXDisp_EndList(__GLXclientState*, GLbyte*);
+extern int __glXDisp_DeleteLists(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GenLists(__GLXclientState*, GLbyte*);
+extern int __glXDisp_FeedbackBuffer(__GLXclientState*, GLbyte*);
+extern int __glXDisp_SelectBuffer(__GLXclientState*, GLbyte*);
+extern int __glXDisp_RenderMode(__GLXclientState*, GLbyte*);
+extern int __glXDisp_Finish(__GLXclientState*, GLbyte*);
+extern int __glXDisp_PixelStoref(__GLXclientState*, GLbyte*);
+extern int __glXDisp_PixelStorei(__GLXclientState*, GLbyte*);
+extern int __glXDisp_ReadPixels(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetBooleanv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetClipPlane(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetDoublev(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetError(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetFloatv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetIntegerv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetLightfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetLightiv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetMapdv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetMapfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetMapiv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetMaterialfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetMaterialiv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetPixelMapfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetPixelMapuiv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetPixelMapusv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetPolygonStipple(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetString(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexEnvfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexEnviv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexGendv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexGenfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexGeniv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexImage(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexLevelParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexLevelParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_IsEnabled(__GLXclientState*, GLbyte*);
+extern int __glXDisp_IsList(__GLXclientState*, GLbyte*);
+extern int __glXDisp_Flush(__GLXclientState*, GLbyte*);
+extern int __glXDisp_AreTexturesResident(__GLXclientState*, GLbyte*);
+extern int __glXDisp_DeleteTextures(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GenTextures(__GLXclientState*, GLbyte*);
+extern int __glXDisp_IsTexture(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetColorTable(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetColorTableParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetColorTableParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetConvolutionFilter(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetConvolutionParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetConvolutionParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetSeparableFilter(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetHistogram(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetHistogramParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetHistogramParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetMinmax(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetMinmaxParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetMinmaxParameteriv(__GLXclientState*, GLbyte*);
+
+extern void __glXDisp_CallList(GLbyte*);
+extern void __glXDisp_CallLists(GLbyte*);
+extern void __glXDisp_ListBase(GLbyte*);
+extern void __glXDisp_Begin(GLbyte*);
+extern void __glXDisp_Bitmap(GLbyte*);
+extern void __glXDisp_Color3bv(GLbyte*);
+extern void __glXDisp_Color3dv(GLbyte*);
+extern void __glXDisp_Color3fv(GLbyte*);
+extern void __glXDisp_Color3iv(GLbyte*);
+extern void __glXDisp_Color3sv(GLbyte*);
+extern void __glXDisp_Color3ubv(GLbyte*);
+extern void __glXDisp_Color3uiv(GLbyte*);
+extern void __glXDisp_Color3usv(GLbyte*);
+extern void __glXDisp_Color4bv(GLbyte*);
+extern void __glXDisp_Color4dv(GLbyte*);
+extern void __glXDisp_Color4fv(GLbyte*);
+extern void __glXDisp_Color4iv(GLbyte*);
+extern void __glXDisp_Color4sv(GLbyte*);
+extern void __glXDisp_Color4ubv(GLbyte*);
+extern void __glXDisp_Color4uiv(GLbyte*);
+extern void __glXDisp_Color4usv(GLbyte*);
+extern void __glXDisp_EdgeFlagv(GLbyte*);
+extern void __glXDisp_End(GLbyte*);
+extern void __glXDisp_Indexdv(GLbyte*);
+extern void __glXDisp_Indexfv(GLbyte*);
+extern void __glXDisp_Indexiv(GLbyte*);
+extern void __glXDisp_Indexsv(GLbyte*);
+extern void __glXDisp_Normal3bv(GLbyte*);
+extern void __glXDisp_Normal3dv(GLbyte*);
+extern void __glXDisp_Normal3fv(GLbyte*);
+extern void __glXDisp_Normal3iv(GLbyte*);
+extern void __glXDisp_Normal3sv(GLbyte*);
+extern void __glXDisp_RasterPos2dv(GLbyte*);
+extern void __glXDisp_RasterPos2fv(GLbyte*);
+extern void __glXDisp_RasterPos2iv(GLbyte*);
+extern void __glXDisp_RasterPos2sv(GLbyte*);
+extern void __glXDisp_RasterPos3dv(GLbyte*);
+extern void __glXDisp_RasterPos3fv(GLbyte*);
+extern void __glXDisp_RasterPos3iv(GLbyte*);
+extern void __glXDisp_RasterPos3sv(GLbyte*);
+extern void __glXDisp_RasterPos4dv(GLbyte*);
+extern void __glXDisp_RasterPos4fv(GLbyte*);
+extern void __glXDisp_RasterPos4iv(GLbyte*);
+extern void __glXDisp_RasterPos4sv(GLbyte*);
+extern void __glXDisp_Rectdv(GLbyte*);
+extern void __glXDisp_Rectfv(GLbyte*);
+extern void __glXDisp_Rectiv(GLbyte*);
+extern void __glXDisp_Rectsv(GLbyte*);
+extern void __glXDisp_TexCoord1dv(GLbyte*);
+extern void __glXDisp_TexCoord1fv(GLbyte*);
+extern void __glXDisp_TexCoord1iv(GLbyte*);
+extern void __glXDisp_TexCoord1sv(GLbyte*);
+extern void __glXDisp_TexCoord2dv(GLbyte*);
+extern void __glXDisp_TexCoord2fv(GLbyte*);
+extern void __glXDisp_TexCoord2iv(GLbyte*);
+extern void __glXDisp_TexCoord2sv(GLbyte*);
+extern void __glXDisp_TexCoord3dv(GLbyte*);
+extern void __glXDisp_TexCoord3fv(GLbyte*);
+extern void __glXDisp_TexCoord3iv(GLbyte*);
+extern void __glXDisp_TexCoord3sv(GLbyte*);
+extern void __glXDisp_TexCoord4dv(GLbyte*);
+extern void __glXDisp_TexCoord4fv(GLbyte*);
+extern void __glXDisp_TexCoord4iv(GLbyte*);
+extern void __glXDisp_TexCoord4sv(GLbyte*);
+extern void __glXDisp_Vertex2dv(GLbyte*);
+extern void __glXDisp_Vertex2fv(GLbyte*);
+extern void __glXDisp_Vertex2iv(GLbyte*);
+extern void __glXDisp_Vertex2sv(GLbyte*);
+extern void __glXDisp_Vertex3dv(GLbyte*);
+extern void __glXDisp_Vertex3fv(GLbyte*);
+extern void __glXDisp_Vertex3iv(GLbyte*);
+extern void __glXDisp_Vertex3sv(GLbyte*);
+extern void __glXDisp_Vertex4dv(GLbyte*);
+extern void __glXDisp_Vertex4fv(GLbyte*);
+extern void __glXDisp_Vertex4iv(GLbyte*);
+extern void __glXDisp_Vertex4sv(GLbyte*);
+extern void __glXDisp_ClipPlane(GLbyte*);
+extern void __glXDisp_ColorMaterial(GLbyte*);
+extern void __glXDisp_CullFace(GLbyte*);
+extern void __glXDisp_Fogf(GLbyte*);
+extern void __glXDisp_Fogfv(GLbyte*);
+extern void __glXDisp_Fogi(GLbyte*);
+extern void __glXDisp_Fogiv(GLbyte*);
+extern void __glXDisp_FrontFace(GLbyte*);
+extern void __glXDisp_Hint(GLbyte*);
+extern void __glXDisp_Lightf(GLbyte*);
+extern void __glXDisp_Lightfv(GLbyte*);
+extern void __glXDisp_Lighti(GLbyte*);
+extern void __glXDisp_Lightiv(GLbyte*);
+extern void __glXDisp_LightModelf(GLbyte*);
+extern void __glXDisp_LightModelfv(GLbyte*);
+extern void __glXDisp_LightModeli(GLbyte*);
+extern void __glXDisp_LightModeliv(GLbyte*);
+extern void __glXDisp_LineStipple(GLbyte*);
+extern void __glXDisp_LineWidth(GLbyte*);
+extern void __glXDisp_Materialf(GLbyte*);
+extern void __glXDisp_Materialfv(GLbyte*);
+extern void __glXDisp_Materiali(GLbyte*);
+extern void __glXDisp_Materialiv(GLbyte*);
+extern void __glXDisp_PointSize(GLbyte*);
+extern void __glXDisp_PolygonMode(GLbyte*);
+extern void __glXDisp_PolygonStipple(GLbyte*);
+extern void __glXDisp_Scissor(GLbyte*);
+extern void __glXDisp_ShadeModel(GLbyte*);
+extern void __glXDisp_TexParameterf(GLbyte*);
+extern void __glXDisp_TexParameterfv(GLbyte*);
+extern void __glXDisp_TexParameteri(GLbyte*);
+extern void __glXDisp_TexParameteriv(GLbyte*);
+extern void __glXDisp_TexImage1D(GLbyte*);
+extern void __glXDisp_TexImage2D(GLbyte*);
+extern void __glXDisp_TexEnvf(GLbyte*);
+extern void __glXDisp_TexEnvfv(GLbyte*);
+extern void __glXDisp_TexEnvi(GLbyte*);
+extern void __glXDisp_TexEnviv(GLbyte*);
+extern void __glXDisp_TexGend(GLbyte*);
+extern void __glXDisp_TexGendv(GLbyte*);
+extern void __glXDisp_TexGenf(GLbyte*);
+extern void __glXDisp_TexGenfv(GLbyte*);
+extern void __glXDisp_TexGeni(GLbyte*);
+extern void __glXDisp_TexGeniv(GLbyte*);
+extern void __glXDisp_InitNames(GLbyte*);
+extern void __glXDisp_LoadName(GLbyte*);
+extern void __glXDisp_PassThrough(GLbyte*);
+extern void __glXDisp_PopName(GLbyte*);
+extern void __glXDisp_PushName(GLbyte*);
+extern void __glXDisp_DrawBuffer(GLbyte*);
+extern void __glXDisp_Clear(GLbyte*);
+extern void __glXDisp_ClearAccum(GLbyte*);
+extern void __glXDisp_ClearIndex(GLbyte*);
+extern void __glXDisp_ClearColor(GLbyte*);
+extern void __glXDisp_ClearStencil(GLbyte*);
+extern void __glXDisp_ClearDepth(GLbyte*);
+extern void __glXDisp_StencilMask(GLbyte*);
+extern void __glXDisp_ColorMask(GLbyte*);
+extern void __glXDisp_DepthMask(GLbyte*);
+extern void __glXDisp_IndexMask(GLbyte*);
+extern void __glXDisp_Accum(GLbyte*);
+extern void __glXDisp_Disable(GLbyte*);
+extern void __glXDisp_Enable(GLbyte*);
+extern void __glXDisp_PopAttrib(GLbyte*);
+extern void __glXDisp_PushAttrib(GLbyte*);
+extern void __glXDisp_Map1d(GLbyte*);
+extern void __glXDisp_Map1f(GLbyte*);
+extern void __glXDisp_Map2d(GLbyte*);
+extern void __glXDisp_Map2f(GLbyte*);
+extern void __glXDisp_MapGrid1d(GLbyte*);
+extern void __glXDisp_MapGrid1f(GLbyte*);
+extern void __glXDisp_MapGrid2d(GLbyte*);
+extern void __glXDisp_MapGrid2f(GLbyte*);
+extern void __glXDisp_EvalCoord1dv(GLbyte*);
+extern void __glXDisp_EvalCoord1fv(GLbyte*);
+extern void __glXDisp_EvalCoord2dv(GLbyte*);
+extern void __glXDisp_EvalCoord2fv(GLbyte*);
+extern void __glXDisp_EvalMesh1(GLbyte*);
+extern void __glXDisp_EvalPoint1(GLbyte*);
+extern void __glXDisp_EvalMesh2(GLbyte*);
+extern void __glXDisp_EvalPoint2(GLbyte*);
+extern void __glXDisp_AlphaFunc(GLbyte*);
+extern void __glXDisp_BlendFunc(GLbyte*);
+extern void __glXDisp_LogicOp(GLbyte*);
+extern void __glXDisp_StencilFunc(GLbyte*);
+extern void __glXDisp_StencilOp(GLbyte*);
+extern void __glXDisp_DepthFunc(GLbyte*);
+extern void __glXDisp_PixelZoom(GLbyte*);
+extern void __glXDisp_PixelTransferf(GLbyte*);
+extern void __glXDisp_PixelTransferi(GLbyte*);
+extern void __glXDisp_PixelMapfv(GLbyte*);
+extern void __glXDisp_PixelMapuiv(GLbyte*);
+extern void __glXDisp_PixelMapusv(GLbyte*);
+extern void __glXDisp_ReadBuffer(GLbyte*);
+extern void __glXDisp_CopyPixels(GLbyte*);
+extern void __glXDisp_DrawPixels(GLbyte*);
+extern void __glXDisp_DepthRange(GLbyte*);
+extern void __glXDisp_Frustum(GLbyte*);
+extern void __glXDisp_LoadIdentity(GLbyte*);
+extern void __glXDisp_LoadMatrixf(GLbyte*);
+extern void __glXDisp_LoadMatrixd(GLbyte*);
+extern void __glXDisp_MatrixMode(GLbyte*);
+extern void __glXDisp_MultMatrixf(GLbyte*);
+extern void __glXDisp_MultMatrixd(GLbyte*);
+extern void __glXDisp_Ortho(GLbyte*);
+extern void __glXDisp_PopMatrix(GLbyte*);
+extern void __glXDisp_PushMatrix(GLbyte*);
+extern void __glXDisp_Rotated(GLbyte*);
+extern void __glXDisp_Rotatef(GLbyte*);
+extern void __glXDisp_Scaled(GLbyte*);
+extern void __glXDisp_Scalef(GLbyte*);
+extern void __glXDisp_Translated(GLbyte*);
+extern void __glXDisp_Translatef(GLbyte*);
+extern void __glXDisp_Viewport(GLbyte*);
+extern void __glXDisp_PolygonOffset(GLbyte*);
+extern void __glXDisp_DrawArrays(GLbyte*);
+extern void __glXDisp_Indexubv(GLbyte*);
+extern void __glXDisp_ColorSubTable(GLbyte*);
+extern void __glXDisp_CopyColorSubTable(GLbyte*);
+extern void __glXDisp_ActiveTextureARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord1dvARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord1fvARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord1ivARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord1svARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord2dvARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord2fvARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord2ivARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord2svARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord3dvARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord3fvARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord3ivARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord3svARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord4dvARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord4fvARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord4ivARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord4svARB(GLbyte*);
+extern void __glXDisp_SampleCoverageARB(GLbyte *);
+extern void __glXDisp_WindowPos3fARB(GLbyte *);
+
+extern int __glXSwapRender(__GLXclientState*, GLbyte*);
+extern int __glXSwapRenderLarge(__GLXclientState*, GLbyte*);
+extern int __glXSwapCreateContext(__GLXclientState*, GLbyte*);
+extern int __glXSwapDestroyContext(__GLXclientState*, GLbyte*);
+extern int __glXSwapMakeCurrent(__GLXclientState*, GLbyte*);
+extern int __glXSwapIsDirect(__GLXclientState*, GLbyte*);
+extern int __glXSwapQueryVersion(__GLXclientState*, GLbyte*);
+extern int __glXSwapWaitGL(__GLXclientState*, GLbyte*);
+extern int __glXSwapWaitX(__GLXclientState*, GLbyte*);
+extern int __glXSwapCopyContext(__GLXclientState*, GLbyte*);
+extern int __glXSwapSwapBuffers(__GLXclientState*, GLbyte*);
+extern int __glXSwapUseXFont(__GLXclientState*, GLbyte*);
+extern int __glXSwapCreateGLXPixmap(__GLXclientState*, GLbyte*);
+extern int __glXSwapGetVisualConfigs(__GLXclientState*, GLbyte*);
+extern int __glXSwapDestroyGLXPixmap(__GLXclientState*, GLbyte*);
+extern int __glXSwapVendorPrivate(__GLXclientState*, GLbyte*);
+extern int __glXSwapVendorPrivateWithReply(__GLXclientState*, GLbyte*);
+extern int __glXSwapQueryExtensionsString(__GLXclientState*, GLbyte*);
+extern int __glXSwapQueryServerString(__GLXclientState*, GLbyte*);
+extern int __glXSwapClientInfo(__GLXclientState*, GLbyte*);
+extern int __glXSwapMakeContextCurrent(__GLXclientState*, GLbyte*);
+extern int __glXSwapGetFBConfigs(__GLXclientState*, GLbyte*);
+extern int __glXSwapCreateNewContext(__GLXclientState*, GLbyte*);
+extern int __glXSwapCreatePixmap(__GLXclientState*, GLbyte*);
+
+extern int __glXDispSwap_NewList(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_EndList(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_DeleteLists(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GenLists(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_FeedbackBuffer(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_SelectBuffer(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_RenderMode(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_Finish(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_PixelStoref(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_PixelStorei(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_ReadPixels(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetBooleanv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetClipPlane(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetDoublev(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetError(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetFloatv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetIntegerv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetLightfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetLightiv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetMapdv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetMapfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetMapiv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetMaterialfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetMaterialiv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetPixelMapfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetPixelMapuiv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetPixelMapusv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetPolygonStipple(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetString(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexEnvfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexEnviv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexGendv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexGenfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexGeniv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexImage(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexLevelParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexLevelParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_IsEnabled(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_IsList(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_Flush(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_AreTexturesResident(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_DeleteTextures(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GenTextures(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_IsTexture(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetColorTable(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetColorTableParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetColorTableParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetConvolutionFilter(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetConvolutionParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetConvolutionParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetSeparableFilter(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetHistogram(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetHistogramParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetHistogramParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetMinmax(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetMinmaxParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetMinmaxParameteriv(__GLXclientState*, GLbyte*);
+
+extern void __glXDispSwap_CallList(GLbyte*);
+extern void __glXDispSwap_CallLists(GLbyte*);
+extern void __glXDispSwap_ListBase(GLbyte*);
+extern void __glXDispSwap_Begin(GLbyte*);
+extern void __glXDispSwap_Bitmap(GLbyte*);
+extern void __glXDispSwap_Color3bv(GLbyte*);
+extern void __glXDispSwap_Color3dv(GLbyte*);
+extern void __glXDispSwap_Color3fv(GLbyte*);
+extern void __glXDispSwap_Color3iv(GLbyte*);
+extern void __glXDispSwap_Color3sv(GLbyte*);
+extern void __glXDispSwap_Color3ubv(GLbyte*);
+extern void __glXDispSwap_Color3uiv(GLbyte*);
+extern void __glXDispSwap_Color3usv(GLbyte*);
+extern void __glXDispSwap_Color4bv(GLbyte*);
+extern void __glXDispSwap_Color4dv(GLbyte*);
+extern void __glXDispSwap_Color4fv(GLbyte*);
+extern void __glXDispSwap_Color4iv(GLbyte*);
+extern void __glXDispSwap_Color4sv(GLbyte*);
+extern void __glXDispSwap_Color4ubv(GLbyte*);
+extern void __glXDispSwap_Color4uiv(GLbyte*);
+extern void __glXDispSwap_Color4usv(GLbyte*);
+extern void __glXDispSwap_EdgeFlagv(GLbyte*);
+extern void __glXDispSwap_End(GLbyte*);
+extern void __glXDispSwap_Indexdv(GLbyte*);
+extern void __glXDispSwap_Indexfv(GLbyte*);
+extern void __glXDispSwap_Indexiv(GLbyte*);
+extern void __glXDispSwap_Indexsv(GLbyte*);
+extern void __glXDispSwap_Normal3bv(GLbyte*);
+extern void __glXDispSwap_Normal3dv(GLbyte*);
+extern void __glXDispSwap_Normal3fv(GLbyte*);
+extern void __glXDispSwap_Normal3iv(GLbyte*);
+extern void __glXDispSwap_Normal3sv(GLbyte*);
+extern void __glXDispSwap_RasterPos2dv(GLbyte*);
+extern void __glXDispSwap_RasterPos2fv(GLbyte*);
+extern void __glXDispSwap_RasterPos2iv(GLbyte*);
+extern void __glXDispSwap_RasterPos2sv(GLbyte*);
+extern void __glXDispSwap_RasterPos3dv(GLbyte*);
+extern void __glXDispSwap_RasterPos3fv(GLbyte*);
+extern void __glXDispSwap_RasterPos3iv(GLbyte*);
+extern void __glXDispSwap_RasterPos3sv(GLbyte*);
+extern void __glXDispSwap_RasterPos4dv(GLbyte*);
+extern void __glXDispSwap_RasterPos4fv(GLbyte*);
+extern void __glXDispSwap_RasterPos4iv(GLbyte*);
+extern void __glXDispSwap_RasterPos4sv(GLbyte*);
+extern void __glXDispSwap_Rectdv(GLbyte*);
+extern void __glXDispSwap_Rectfv(GLbyte*);
+extern void __glXDispSwap_Rectiv(GLbyte*);
+extern void __glXDispSwap_Rectsv(GLbyte*);
+extern void __glXDispSwap_TexCoord1dv(GLbyte*);
+extern void __glXDispSwap_TexCoord1fv(GLbyte*);
+extern void __glXDispSwap_TexCoord1iv(GLbyte*);
+extern void __glXDispSwap_TexCoord1sv(GLbyte*);
+extern void __glXDispSwap_TexCoord2dv(GLbyte*);
+extern void __glXDispSwap_TexCoord2fv(GLbyte*);
+extern void __glXDispSwap_TexCoord2iv(GLbyte*);
+extern void __glXDispSwap_TexCoord2sv(GLbyte*);
+extern void __glXDispSwap_TexCoord3dv(GLbyte*);
+extern void __glXDispSwap_TexCoord3fv(GLbyte*);
+extern void __glXDispSwap_TexCoord3iv(GLbyte*);
+extern void __glXDispSwap_TexCoord3sv(GLbyte*);
+extern void __glXDispSwap_TexCoord4dv(GLbyte*);
+extern void __glXDispSwap_TexCoord4fv(GLbyte*);
+extern void __glXDispSwap_TexCoord4iv(GLbyte*);
+extern void __glXDispSwap_TexCoord4sv(GLbyte*);
+extern void __glXDispSwap_Vertex2dv(GLbyte*);
+extern void __glXDispSwap_Vertex2fv(GLbyte*);
+extern void __glXDispSwap_Vertex2iv(GLbyte*);
+extern void __glXDispSwap_Vertex2sv(GLbyte*);
+extern void __glXDispSwap_Vertex3dv(GLbyte*);
+extern void __glXDispSwap_Vertex3fv(GLbyte*);
+extern void __glXDispSwap_Vertex3iv(GLbyte*);
+extern void __glXDispSwap_Vertex3sv(GLbyte*);
+extern void __glXDispSwap_Vertex4dv(GLbyte*);
+extern void __glXDispSwap_Vertex4fv(GLbyte*);
+extern void __glXDispSwap_Vertex4iv(GLbyte*);
+extern void __glXDispSwap_Vertex4sv(GLbyte*);
+extern void __glXDispSwap_ClipPlane(GLbyte*);
+extern void __glXDispSwap_ColorMaterial(GLbyte*);
+extern void __glXDispSwap_CullFace(GLbyte*);
+extern void __glXDispSwap_Fogf(GLbyte*);
+extern void __glXDispSwap_Fogfv(GLbyte*);
+extern void __glXDispSwap_Fogi(GLbyte*);
+extern void __glXDispSwap_Fogiv(GLbyte*);
+extern void __glXDispSwap_FrontFace(GLbyte*);
+extern void __glXDispSwap_Hint(GLbyte*);
+extern void __glXDispSwap_Lightf(GLbyte*);
+extern void __glXDispSwap_Lightfv(GLbyte*);
+extern void __glXDispSwap_Lighti(GLbyte*);
+extern void __glXDispSwap_Lightiv(GLbyte*);
+extern void __glXDispSwap_LightModelf(GLbyte*);
+extern void __glXDispSwap_LightModelfv(GLbyte*);
+extern void __glXDispSwap_LightModeli(GLbyte*);
+extern void __glXDispSwap_LightModeliv(GLbyte*);
+extern void __glXDispSwap_LineStipple(GLbyte*);
+extern void __glXDispSwap_LineWidth(GLbyte*);
+extern void __glXDispSwap_Materialf(GLbyte*);
+extern void __glXDispSwap_Materialfv(GLbyte*);
+extern void __glXDispSwap_Materiali(GLbyte*);
+extern void __glXDispSwap_Materialiv(GLbyte*);
+extern void __glXDispSwap_PointSize(GLbyte*);
+extern void __glXDispSwap_PolygonMode(GLbyte*);
+extern void __glXDispSwap_PolygonStipple(GLbyte*);
+extern void __glXDispSwap_Scissor(GLbyte*);
+extern void __glXDispSwap_ShadeModel(GLbyte*);
+extern void __glXDispSwap_TexParameterf(GLbyte*);
+extern void __glXDispSwap_TexParameterfv(GLbyte*);
+extern void __glXDispSwap_TexParameteri(GLbyte*);
+extern void __glXDispSwap_TexParameteriv(GLbyte*);
+extern void __glXDispSwap_TexImage1D(GLbyte*);
+extern void __glXDispSwap_TexImage2D(GLbyte*);
+extern void __glXDispSwap_TexEnvf(GLbyte*);
+extern void __glXDispSwap_TexEnvfv(GLbyte*);
+extern void __glXDispSwap_TexEnvi(GLbyte*);
+extern void __glXDispSwap_TexEnviv(GLbyte*);
+extern void __glXDispSwap_TexGend(GLbyte*);
+extern void __glXDispSwap_TexGendv(GLbyte*);
+extern void __glXDispSwap_TexGenf(GLbyte*);
+extern void __glXDispSwap_TexGenfv(GLbyte*);
+extern void __glXDispSwap_TexGeni(GLbyte*);
+extern void __glXDispSwap_TexGeniv(GLbyte*);
+extern void __glXDispSwap_InitNames(GLbyte*);
+extern void __glXDispSwap_LoadName(GLbyte*);
+extern void __glXDispSwap_PassThrough(GLbyte*);
+extern void __glXDispSwap_PopName(GLbyte*);
+extern void __glXDispSwap_PushName(GLbyte*);
+extern void __glXDispSwap_DrawBuffer(GLbyte*);
+extern void __glXDispSwap_Clear(GLbyte*);
+extern void __glXDispSwap_ClearAccum(GLbyte*);
+extern void __glXDispSwap_ClearIndex(GLbyte*);
+extern void __glXDispSwap_ClearColor(GLbyte*);
+extern void __glXDispSwap_ClearStencil(GLbyte*);
+extern void __glXDispSwap_ClearDepth(GLbyte*);
+extern void __glXDispSwap_StencilMask(GLbyte*);
+extern void __glXDispSwap_ColorMask(GLbyte*);
+extern void __glXDispSwap_DepthMask(GLbyte*);
+extern void __glXDispSwap_IndexMask(GLbyte*);
+extern void __glXDispSwap_Accum(GLbyte*);
+extern void __glXDispSwap_Disable(GLbyte*);
+extern void __glXDispSwap_Enable(GLbyte*);
+extern void __glXDispSwap_PopAttrib(GLbyte*);
+extern void __glXDispSwap_PushAttrib(GLbyte*);
+extern void __glXDispSwap_Map1d(GLbyte*);
+extern void __glXDispSwap_Map1f(GLbyte*);
+extern void __glXDispSwap_Map2d(GLbyte*);
+extern void __glXDispSwap_Map2f(GLbyte*);
+extern void __glXDispSwap_MapGrid1d(GLbyte*);
+extern void __glXDispSwap_MapGrid1f(GLbyte*);
+extern void __glXDispSwap_MapGrid2d(GLbyte*);
+extern void __glXDispSwap_MapGrid2f(GLbyte*);
+extern void __glXDispSwap_EvalCoord1dv(GLbyte*);
+extern void __glXDispSwap_EvalCoord1fv(GLbyte*);
+extern void __glXDispSwap_EvalCoord2dv(GLbyte*);
+extern void __glXDispSwap_EvalCoord2fv(GLbyte*);
+extern void __glXDispSwap_EvalMesh1(GLbyte*);
+extern void __glXDispSwap_EvalPoint1(GLbyte*);
+extern void __glXDispSwap_EvalMesh2(GLbyte*);
+extern void __glXDispSwap_EvalPoint2(GLbyte*);
+extern void __glXDispSwap_AlphaFunc(GLbyte*);
+extern void __glXDispSwap_BlendFunc(GLbyte*);
+extern void __glXDispSwap_LogicOp(GLbyte*);
+extern void __glXDispSwap_StencilFunc(GLbyte*);
+extern void __glXDispSwap_StencilOp(GLbyte*);
+extern void __glXDispSwap_DepthFunc(GLbyte*);
+extern void __glXDispSwap_PixelZoom(GLbyte*);
+extern void __glXDispSwap_PixelTransferf(GLbyte*);
+extern void __glXDispSwap_PixelTransferi(GLbyte*);
+extern void __glXDispSwap_PixelMapfv(GLbyte*);
+extern void __glXDispSwap_PixelMapuiv(GLbyte*);
+extern void __glXDispSwap_PixelMapusv(GLbyte*);
+extern void __glXDispSwap_ReadBuffer(GLbyte*);
+extern void __glXDispSwap_CopyPixels(GLbyte*);
+extern void __glXDispSwap_DrawPixels(GLbyte*);
+extern void __glXDispSwap_DepthRange(GLbyte*);
+extern void __glXDispSwap_Frustum(GLbyte*);
+extern void __glXDispSwap_LoadIdentity(GLbyte*);
+extern void __glXDispSwap_LoadMatrixf(GLbyte*);
+extern void __glXDispSwap_LoadMatrixd(GLbyte*);
+extern void __glXDispSwap_MatrixMode(GLbyte*);
+extern void __glXDispSwap_MultMatrixf(GLbyte*);
+extern void __glXDispSwap_MultMatrixd(GLbyte*);
+extern void __glXDispSwap_Ortho(GLbyte*);
+extern void __glXDispSwap_PopMatrix(GLbyte*);
+extern void __glXDispSwap_PushMatrix(GLbyte*);
+extern void __glXDispSwap_Rotated(GLbyte*);
+extern void __glXDispSwap_Rotatef(GLbyte*);
+extern void __glXDispSwap_Scaled(GLbyte*);
+extern void __glXDispSwap_Scalef(GLbyte*);
+extern void __glXDispSwap_Translated(GLbyte*);
+extern void __glXDispSwap_Translatef(GLbyte*);
+extern void __glXDispSwap_Viewport(GLbyte*);
+extern void __glXDispSwap_PolygonOffset(GLbyte*);
+extern void __glXDispSwap_DrawArrays(GLbyte*);
+extern void __glXDispSwap_Indexubv(GLbyte*);
+extern void __glXDispSwap_ColorSubTable(GLbyte*);
+extern void __glXDispSwap_CopyColorSubTable(GLbyte*);
+extern void __glXDispSwap_ActiveTextureARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord1dvARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord1fvARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord1ivARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord1svARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord2dvARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord2fvARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord2ivARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord2svARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord3dvARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord3fvARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord3ivARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord3svARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord4dvARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord4fvARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord4ivARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord4svARB(GLbyte*);
+extern void __glXDispSwap_SampleCoverageARB(GLbyte *);
+extern void __glXDispSwap_WindowPos3fARB(GLbyte *);
+
+#define __GLX_MIN_GLXCMD_OPCODE 1
+#define __GLX_MAX_GLXCMD_OPCODE 20
+#define __GLX_MIN_RENDER_OPCODE 1
+/*#define __GLX_MAX_RENDER_OPCODE 213*/
+#define __GLX_MAX_RENDER_OPCODE 230
+#define __GLX_MIN_SINGLE_OPCODE 1
+#define __GLX_MAX_SINGLE_OPCODE 159
+#define __GLX_SINGLE_TABLE_SIZE 160
+/*#define __GLX_RENDER_TABLE_SIZE 214*/
+#define __GLX_RENDER_TABLE_SIZE 231
+extern __GLXdispatchRenderProcPtr __glXRenderTable[__GLX_RENDER_TABLE_SIZE];
+extern __GLXdispatchSingleProcPtr __glXSingleTable[__GLX_SINGLE_TABLE_SIZE];
+extern __GLXdispatchRenderProcPtr __glXSwapRenderTable[__GLX_RENDER_TABLE_SIZE];
+extern __GLXdispatchSingleProcPtr __glXSwapSingleTable[__GLX_SINGLE_TABLE_SIZE];
+#endif /* _GLX_g_disptab_h_ */
diff --git a/nx-X11/programs/Xserver/GL/glx/g_disptab_EXT.c b/nx-X11/programs/Xserver/GL/glx/g_disptab_EXT.c
new file mode 100644
index 000000000..d837c64d9
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/g_disptab_EXT.c
@@ -0,0 +1,4447 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/g_disptab_EXT.c,v 1.5 2004/01/28 18:11:50 alanh Exp $ */
+/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxext.h"
+#include "g_disptab_EXT.h"
+__GLXdispatchRenderProcPtr __glXRenderTable_EXT[__GLX_MAX_RENDER_OPCODE_EXT - __GLX_MIN_RENDER_OPCODE_EXT + 1] = {
+ __glXDisp_ColorTable, /* 2053 */
+ __glXDisp_ColorTableParameterfv, /* 2054 */
+ __glXDisp_ColorTableParameteriv,
+ __glXDisp_CopyColorTable,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 2060 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+#ifndef MISSING_GL_EXTS
+ __glXDisp_PointParameterfARB, /* 2065 */
+ __glXDisp_PointParameterfvARB, /* 2066 */
+#else
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+#endif
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 2070 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXDisp_BlendColor, /* 4096 */
+ __glXDisp_BlendEquation, /* 4097 */
+ __glXNoSuchRenderOpcode, /* 4098 */
+ __glXDisp_TexSubImage1D, /* 4099 */
+ __glXDisp_TexSubImage2D, /* 4100 */
+ __glXDisp_ConvolutionFilter1D,
+ __glXDisp_ConvolutionFilter2D,
+ __glXDisp_ConvolutionParameterf,
+ __glXDisp_ConvolutionParameterfv,
+ __glXDisp_ConvolutionParameteri,
+ __glXDisp_ConvolutionParameteriv,
+ __glXDisp_CopyConvolutionFilter1D,
+ __glXDisp_CopyConvolutionFilter2D,
+ __glXDisp_SeparableFilter2D,
+ __glXDisp_Histogram, /* 4110 */
+ __glXDisp_Minmax,
+ __glXDisp_ResetHistogram,
+ __glXDisp_ResetMinmax,
+ __glXDisp_TexImage3D,
+ __glXDisp_TexSubImage3D,
+ __glXDisp_DrawArraysEXT,
+ __glXDisp_BindTexture,
+ __glXDisp_PrioritizeTextures,
+ __glXDisp_CopyTexImage1D,
+ __glXDisp_CopyTexImage2D, /* 4120 */
+ __glXDisp_CopyTexSubImage1D, /* 4121 */
+ __glXDisp_CopyTexSubImage2D, /* 4122 */
+ __glXDisp_CopyTexSubImage3D, /* 4123 */
+#ifndef MISSING_GL_EXTS
+ __glXDisp_FogCoordfv, /* 4124 */
+ __glXDisp_FogCoorddv, /* 4125 */
+ __glXDisp_SecondaryColor3bv, /* 4126 */
+ __glXDisp_SecondaryColor3sv, /* 4127 */
+ __glXDisp_SecondaryColor3iv, /* 4128 */
+ __glXDisp_SecondaryColor3fv, /* 4129 */
+ __glXDisp_SecondaryColor3dv, /* 4130 */
+ __glXDisp_SecondaryColor3ubv, /* 4131 */
+ __glXDisp_SecondaryColor3usv, /* 4132 */
+ __glXDisp_SecondaryColor3uiv, /* 4133 */
+ __glXDisp_BlendFuncSeparate, /* 4134 */
+#else
+ __glXNoSuchRenderOpcode, /* 4124 */
+ __glXNoSuchRenderOpcode, /* 4125 */
+ __glXNoSuchRenderOpcode, /* 4126 */
+ __glXNoSuchRenderOpcode, /* 4127 */
+ __glXNoSuchRenderOpcode, /* 4128 */
+ __glXNoSuchRenderOpcode, /* 4129 */
+ __glXNoSuchRenderOpcode, /* 4130 */
+ __glXNoSuchRenderOpcode, /* 4131 */
+ __glXNoSuchRenderOpcode, /* 4132 */
+ __glXNoSuchRenderOpcode, /* 4133 */
+ __glXNoSuchRenderOpcode, /* 4134 */
+#endif
+ __glXNoSuchRenderOpcode, /* 4135 */
+ __glXNoSuchRenderOpcode, /* 4136 */
+ __glXNoSuchRenderOpcode, /* 4137 */
+ __glXNoSuchRenderOpcode, /* 4138 */
+ __glXNoSuchRenderOpcode, /* 4139 */
+ __glXNoSuchRenderOpcode, /* 4140 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 4150 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 4160 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 4170 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 4180 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 4190 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 4200 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 4210 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 4219 */
+#ifndef MISSING_GL_EXTS
+ __glXDisp_ActiveStencilFaceEXT, /* 4220 */
+ __glXDisp_PointParameteriNV, /* 4221 */
+ __glXDisp_PointParameterivNV, /* 4222 */
+#else
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+#endif
+};
+__GLXdispatchVendorPrivProcPtr __glXVendorPrivTable_EXT[__GLX_MAX_VENDPRIV_OPCODE_EXT - __GLX_MIN_VENDPRIV_OPCODE_EXT + 1] = {
+ __glXDisp_AreTexturesResidentEXT, /* 11 */
+ __glXDisp_DeleteTexturesEXT, /* 12 */
+ __glXDisp_GenTexturesEXT, /* 13 */
+ __glXDisp_IsTextureEXT, /* 14 */
+};
+
+
+__GLXdispatchRenderProcPtr __glXSwapRenderTable_EXT[__GLX_MAX_RENDER_OPCODE_EXT - __GLX_MIN_RENDER_OPCODE_EXT + 1] = {
+ __glXDispSwap_ColorTable, /* 2053 */
+ __glXDispSwap_ColorTableParameterfv, /* 2054 */
+ __glXDispSwap_ColorTableParameteriv,
+ __glXDispSwap_CopyColorTable,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 2060 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+#ifndef MISSING_GL_EXTS
+ __glXDispSwap_PointParameterfARB, /* 2065 */
+ __glXDispSwap_PointParameterfvARB, /* 2066 */
+#else
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+#endif
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 2070 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXDispSwap_BlendColor,
+ __glXDispSwap_BlendEquation,
+ __glXNoSuchRenderOpcode,
+ __glXDispSwap_TexSubImage1D,
+ __glXDispSwap_TexSubImage2D,
+ __glXDispSwap_ConvolutionFilter1D,
+ __glXDispSwap_ConvolutionFilter2D,
+ __glXDispSwap_ConvolutionParameterf,
+ __glXDispSwap_ConvolutionParameterfv,
+ __glXDispSwap_ConvolutionParameteri,
+ __glXDispSwap_ConvolutionParameteriv,
+ __glXDispSwap_CopyConvolutionFilter1D,
+ __glXDispSwap_CopyConvolutionFilter2D,
+ __glXDispSwap_SeparableFilter2D,
+ __glXDispSwap_Histogram,
+ __glXDispSwap_Minmax,
+ __glXDispSwap_ResetHistogram,
+ __glXDispSwap_ResetMinmax,
+ __glXDispSwap_TexImage3D,
+ __glXDispSwap_TexSubImage3D,
+ __glXDispSwap_DrawArraysEXT,
+ __glXDispSwap_BindTexture,
+ __glXDispSwap_PrioritizeTextures,
+ __glXDispSwap_CopyTexImage1D,
+ __glXDispSwap_CopyTexImage2D, /* 4120 */
+ __glXDispSwap_CopyTexSubImage1D, /* 4121 */
+ __glXDispSwap_CopyTexSubImage2D, /* 4122 */
+ __glXDispSwap_CopyTexSubImage3D, /* 4123 */
+#ifndef MISSING_GL_EXTS
+ __glXDispSwap_FogCoordfv, /* 4124 */
+ __glXDispSwap_FogCoorddv, /* 4125 */
+ __glXDispSwap_SecondaryColor3bv, /* 4126 */
+ __glXDispSwap_SecondaryColor3sv, /* 4127 */
+ __glXDispSwap_SecondaryColor3iv, /* 4128 */
+ __glXDispSwap_SecondaryColor3fv, /* 4129 */
+ __glXDispSwap_SecondaryColor3dv, /* 4130 */
+ __glXDispSwap_SecondaryColor3ubv, /* 4131 */
+ __glXDispSwap_SecondaryColor3usv, /* 4132 */
+ __glXDispSwap_SecondaryColor3uiv, /* 4133 */
+ __glXDisp_BlendFuncSeparate, /* 4134 */
+#else
+ __glXNoSuchRenderOpcode, /* 4124 */
+ __glXNoSuchRenderOpcode, /* 4125 */
+ __glXNoSuchRenderOpcode, /* 4126 */
+ __glXNoSuchRenderOpcode, /* 4127 */
+ __glXNoSuchRenderOpcode, /* 4128 */
+ __glXNoSuchRenderOpcode, /* 4129 */
+ __glXNoSuchRenderOpcode, /* 4130 */
+ __glXNoSuchRenderOpcode, /* 4131 */
+ __glXNoSuchRenderOpcode, /* 4132 */
+ __glXNoSuchRenderOpcode, /* 4133 */
+ __glXNoSuchRenderOpcode, /* 4134 */
+#endif
+ __glXNoSuchRenderOpcode, /* 4135 */
+ __glXNoSuchRenderOpcode, /* 4136 */
+ __glXNoSuchRenderOpcode, /* 4137 */
+ __glXNoSuchRenderOpcode, /* 4138 */
+ __glXNoSuchRenderOpcode, /* 4139 */
+ __glXNoSuchRenderOpcode, /* 4140 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 4150 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 4160 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 4170 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 4180 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 4190 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 4200 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 4210 */
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode, /* 4219 */
+#ifndef MISSING_GL_EXTS
+ __glXDispSwap_ActiveStencilFaceEXT, /* 4220 */
+ __glXDispSwap_PointParameteriNV, /* 4221 */
+ __glXDispSwap_PointParameterivNV, /* 4222 */
+#else
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+ __glXNoSuchRenderOpcode,
+#endif
+};
+__GLXdispatchVendorPrivProcPtr __glXSwapVendorPrivTable_EXT[__GLX_MAX_VENDPRIV_OPCODE_EXT - __GLX_MIN_VENDPRIV_OPCODE_EXT + 1] = {
+ __glXDispSwap_AreTexturesResidentEXT, /* 11 */
+ __glXDispSwap_DeleteTexturesEXT, /* 12 */
+ __glXDispSwap_GenTexturesEXT, /* 13 */
+ __glXDispSwap_IsTextureEXT, /* 14 */
+};
+
diff --git a/nx-X11/programs/Xserver/GL/glx/g_disptab_EXT.h b/nx-X11/programs/Xserver/GL/glx/g_disptab_EXT.h
new file mode 100644
index 000000000..3def7f1c5
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/g_disptab_EXT.h
@@ -0,0 +1,159 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/g_disptab_EXT.h,v 1.5 2004/01/28 18:11:50 alanh Exp $ */
+/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _GLX_g_disptab_EXT_h_
+#define _GLX_g_disptab_EXT_h_
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+extern int __glXDisp_AreTexturesResidentEXT(__GLXclientState*, GLbyte*);
+extern int __glXDisp_DeleteTexturesEXT(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GenTexturesEXT(__GLXclientState*, GLbyte*);
+extern int __glXDisp_IsTextureEXT(__GLXclientState*, GLbyte*);
+
+extern void __glXDisp_ColorTable(GLbyte*);
+extern void __glXDisp_ColorTableParameterfv(GLbyte*);
+extern void __glXDisp_ColorTableParameteriv(GLbyte*);
+extern void __glXDisp_CopyColorTable(GLbyte*);
+extern void __glXDisp_BlendColor(GLbyte*);
+extern void __glXDisp_BlendEquation(GLbyte*);
+extern void __glXDisp_TexSubImage1D(GLbyte*);
+extern void __glXDisp_TexSubImage2D(GLbyte*);
+extern void __glXDisp_ConvolutionFilter1D(GLbyte*);
+extern void __glXDisp_ConvolutionFilter2D(GLbyte*);
+extern void __glXDisp_ConvolutionParameterf(GLbyte*);
+extern void __glXDisp_ConvolutionParameterfv(GLbyte*);
+extern void __glXDisp_ConvolutionParameteri(GLbyte*);
+extern void __glXDisp_ConvolutionParameteriv(GLbyte*);
+extern void __glXDisp_CopyConvolutionFilter1D(GLbyte*);
+extern void __glXDisp_CopyConvolutionFilter2D(GLbyte*);
+extern void __glXDisp_SeparableFilter2D(GLbyte*);
+extern void __glXDisp_Histogram(GLbyte*);
+extern void __glXDisp_Minmax(GLbyte*);
+extern void __glXDisp_ResetHistogram(GLbyte*);
+extern void __glXDisp_ResetMinmax(GLbyte*);
+extern void __glXDisp_TexImage3D(GLbyte*);
+extern void __glXDisp_TexSubImage3D(GLbyte*);
+extern void __glXDisp_DrawArraysEXT(GLbyte*);
+extern void __glXDisp_BindTexture(GLbyte*);
+extern void __glXDisp_PrioritizeTextures(GLbyte*);
+extern void __glXDisp_CopyTexImage1D(GLbyte*);
+extern void __glXDisp_CopyTexImage2D(GLbyte*);
+extern void __glXDisp_CopyTexSubImage1D(GLbyte*);
+extern void __glXDisp_CopyTexSubImage2D(GLbyte*);
+extern void __glXDisp_CopyTexSubImage3D(GLbyte*);
+extern void __glXDisp_PointParameterfARB(GLbyte*);
+extern void __glXDisp_PointParameterfvARB(GLbyte*);
+
+extern void __glXDisp_FogCoordfv(GLbyte *);
+extern void __glXDisp_FogCoorddv(GLbyte *);
+extern void __glXDispSwap_FogCoordfv(GLbyte *);
+extern void __glXDispSwap_FogCoorddv(GLbyte *);
+
+extern void __glXDisp_SecondaryColor3bv(GLbyte *);
+extern void __glXDisp_SecondaryColor3sv(GLbyte *);
+extern void __glXDisp_SecondaryColor3iv(GLbyte *);
+extern void __glXDisp_SecondaryColor3ubv(GLbyte *);
+extern void __glXDisp_SecondaryColor3usv(GLbyte *);
+extern void __glXDisp_SecondaryColor3uiv(GLbyte *);
+extern void __glXDisp_SecondaryColor3fv(GLbyte *);
+extern void __glXDisp_SecondaryColor3dv(GLbyte *);
+extern void __glXDispSwap_SecondaryColor3bv(GLbyte *);
+extern void __glXDispSwap_SecondaryColor3sv(GLbyte *);
+extern void __glXDispSwap_SecondaryColor3iv(GLbyte *);
+extern void __glXDispSwap_SecondaryColor3ubv(GLbyte *);
+extern void __glXDispSwap_SecondaryColor3usv(GLbyte *);
+extern void __glXDispSwap_SecondaryColor3uiv(GLbyte *);
+extern void __glXDispSwap_SecondaryColor3fv(GLbyte *);
+extern void __glXDispSwap_SecondaryColor3dv(GLbyte *);
+
+extern void __glXDisp_BlendFuncSeparate(GLbyte *);
+extern void __glXDispSwap_BlendFuncSeparate(GLbyte *);
+
+extern void __glXDisp_PointParameteriNV(GLbyte *);
+extern void __glXDisp_PointParameterivNV(GLbyte *);
+extern void __glXDispSwap_PointParameteriNV(GLbyte *);
+extern void __glXDispSwap_PointParameterivNV(GLbyte *);
+
+extern void __glXDisp_ActiveStencilFaceEXT(GLbyte*);
+
+extern int __glXDispSwap_AreTexturesResidentEXT(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_DeleteTexturesEXT(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GenTexturesEXT(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_IsTextureEXT(__GLXclientState*, GLbyte*);
+
+extern void __glXDispSwap_ColorTable(GLbyte*);
+extern void __glXDispSwap_ColorTableParameterfv(GLbyte*);
+extern void __glXDispSwap_ColorTableParameteriv(GLbyte*);
+extern void __glXDispSwap_CopyColorTable(GLbyte*);
+extern void __glXDispSwap_BlendColor(GLbyte*);
+extern void __glXDispSwap_BlendEquation(GLbyte*);
+extern void __glXDispSwap_TexSubImage1D(GLbyte*);
+extern void __glXDispSwap_TexSubImage2D(GLbyte*);
+extern void __glXDispSwap_ConvolutionFilter1D(GLbyte*);
+extern void __glXDispSwap_ConvolutionFilter2D(GLbyte*);
+extern void __glXDispSwap_ConvolutionParameterf(GLbyte*);
+extern void __glXDispSwap_ConvolutionParameterfv(GLbyte*);
+extern void __glXDispSwap_ConvolutionParameteri(GLbyte*);
+extern void __glXDispSwap_ConvolutionParameteriv(GLbyte*);
+extern void __glXDispSwap_CopyConvolutionFilter1D(GLbyte*);
+extern void __glXDispSwap_CopyConvolutionFilter2D(GLbyte*);
+extern void __glXDispSwap_SeparableFilter2D(GLbyte*);
+extern void __glXDispSwap_Histogram(GLbyte*);
+extern void __glXDispSwap_Minmax(GLbyte*);
+extern void __glXDispSwap_ResetHistogram(GLbyte*);
+extern void __glXDispSwap_ResetMinmax(GLbyte*);
+extern void __glXDispSwap_TexImage3D(GLbyte*);
+extern void __glXDispSwap_TexSubImage3D(GLbyte*);
+extern void __glXDispSwap_DrawArraysEXT(GLbyte*);
+extern void __glXDispSwap_BindTexture(GLbyte*);
+extern void __glXDispSwap_PrioritizeTextures(GLbyte*);
+extern void __glXDispSwap_CopyTexImage1D(GLbyte*);
+extern void __glXDispSwap_CopyTexImage2D(GLbyte*);
+extern void __glXDispSwap_CopyTexSubImage1D(GLbyte*);
+extern void __glXDispSwap_CopyTexSubImage2D(GLbyte*);
+extern void __glXDispSwap_CopyTexSubImage3D(GLbyte*);
+extern void __glXDispSwap_PointParameterfARB(GLbyte*);
+extern void __glXDispSwap_PointParameterfvARB(GLbyte*);
+extern void __glXDispSwap_ActiveStencilFaceEXT(GLbyte*);
+
+#define __GLX_MIN_RENDER_OPCODE_EXT 2053
+#define __GLX_MAX_RENDER_OPCODE_EXT 4222
+#define __GLX_MIN_VENDPRIV_OPCODE_EXT 11
+#define __GLX_MAX_VENDPRIV_OPCODE_EXT 14
+#define __GLX_VENDPRIV_TABLE_SIZE_EXT (__GLX_MAX_VENDPRIV_OPCODE_EXT - __GLX_MIN_VENDPRIV_OPCODE_EXT + 1)
+#define __GLX_RENDER_TABLE_SIZE_EXT (__GLX_MAX_RENDER_OPCODE_EXT - __GLX_MIN_RENDER_OPCODE_EXT + 1)
+extern __GLXdispatchRenderProcPtr __glXRenderTable_EXT[__GLX_RENDER_TABLE_SIZE_EXT];
+extern __GLXdispatchVendorPrivProcPtr __glXVendorPrivTable_EXT[__GLX_VENDPRIV_TABLE_SIZE_EXT];
+extern __GLXdispatchRenderProcPtr __glXSwapRenderTable_EXT[__GLX_RENDER_TABLE_SIZE_EXT];
+extern __GLXdispatchVendorPrivProcPtr __glXSwapVendorPrivTable_EXT[__GLX_VENDPRIV_TABLE_SIZE_EXT];
+#endif /* _GLX_g_disptab_EXT_h_ */
diff --git a/nx-X11/programs/Xserver/GL/glx/g_render.c b/nx-X11/programs/Xserver/GL/glx/g_render.c
new file mode 100644
index 000000000..24c64897e
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/g_render.c
@@ -0,0 +1,2282 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/g_render.c,v 1.8 2004/02/03 21:34:36 alanh Exp $ */
+/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxext.h"
+#include "g_disptab.h"
+#include "g_disptab_EXT.h"
+#include "unpack.h"
+#include "impsize.h"
+#include "singlesize.h"
+
+void __glXDisp_CallList(GLbyte *pc)
+{
+ glCallList(
+ *(GLuint *)(pc + 0)
+ );
+}
+
+void __glXDisp_ListBase(GLbyte *pc)
+{
+ glListBase(
+ *(GLuint *)(pc + 0)
+ );
+}
+
+void __glXDisp_Begin(GLbyte *pc)
+{
+ glBegin(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+#define __GLX_SWAP_GLbyte(ptr)
+#define __GLX_SWAP_GLshort(ptr) __GLX_SWAP_SHORT(ptr)
+#define __GLX_SWAP_GLint(ptr) __GLX_SWAP_INT(ptr)
+#define __GLX_SWAP_GLubyte(ptr)
+#define __GLX_SWAP_GLushort(ptr) __GLX_SWAP_SHORT(ptr)
+#define __GLX_SWAP_GLuint(ptr) __GLX_SWAP_INT(ptr)
+#define __GLX_SWAP_GLdouble(ptr) __GLX_SWAP_DOUBLE(ptr)
+#define __GLX_SWAP_GLfloat(ptr) __GLX_SWAP_FLOAT(ptr)
+
+#define __GLX_SWAP_GLbyte_ARRAY(ptr,count) (void) swapEnd; (void) swapPC; (void) sw;
+#define __GLX_SWAP_GLshort_ARRAY(ptr,count) __GLX_SWAP_SHORT_ARRAY(ptr,count)
+#define __GLX_SWAP_GLint_ARRAY(ptr,count) __GLX_SWAP_INT_ARRAY(ptr,count)
+#define __GLX_SWAP_GLenum_ARRAY(ptr,count) __GLX_SWAP_INT_ARRAY(ptr,count)
+#define __GLX_SWAP_GLubyte_ARRAY(ptr,count) (void) swapEnd; (void) swapPC; (void) sw;
+#define __GLX_SWAP_GLushort_ARRAY(ptr,count) __GLX_SWAP_SHORT_ARRAY(ptr,count)
+#define __GLX_SWAP_GLuint_ARRAY(ptr,count) __GLX_SWAP_INT_ARRAY(ptr,count)
+#define __GLX_SWAP_GLdouble_ARRAY(ptr,count) __GLX_SWAP_DOUBLE_ARRAY(ptr,count)
+#define __GLX_SWAP_GLfloat_ARRAY(ptr,count) __GLX_SWAP_FLOAT_ARRAY(ptr,count)
+
+#ifdef __GLX_ALIGN64
+/* If type is not GLdouble, the compiler should optimize this away.
+ */
+# define GLX_DO_ALIGN_MAGIC(count, type) \
+ do { \
+ if ( (sizeof(type) == 8) && ((unsigned long)(pc) & 7)) \
+ { \
+ __GLX_MEM_COPY(pc-4, pc, (count * sizeof( type ) )); \
+ pc -= 4; \
+ } \
+ } while( 0 )
+#else
+# define GLX_DO_ALIGN_MAGIC(count, type)
+#endif
+
+#define dispatch_template_1( name, type ) \
+ void __glXDisp_ ## name ( GLbyte * pc ) \
+ { \
+ GLX_DO_ALIGN_MAGIC( 1, type ); \
+ gl ## name ( (type *) pc ); \
+ } \
+ void __glXDispSwap_ ## name ( GLbyte * pc ) \
+ { \
+ __GLX_DECLARE_SWAP_VARIABLES; \
+ GLX_DO_ALIGN_MAGIC( 1, type ); \
+ __GLX_SWAP_ ## type ( pc ); \
+ gl ## name ( (type *) pc ); \
+ }
+
+#define dispatch_template_3( name, type ) \
+ void __glXDisp_ ## name ( GLbyte * pc ) \
+ { \
+ GLX_DO_ALIGN_MAGIC( 3, type ); \
+ gl ## name ( (type *) pc ); \
+ } \
+ void __glXDispSwap_ ## name ( GLbyte * pc ) \
+ { \
+ __GLX_DECLARE_SWAP_VARIABLES; \
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES; \
+ GLX_DO_ALIGN_MAGIC( 3, type ); \
+ __GLX_SWAP_ ## type ## _ARRAY(pc, 3); \
+ gl ## name ( (type *) pc ); \
+ }
+
+#define dispatch_template_4( name, type ) \
+ void __glXDisp_ ## name ( GLbyte * pc ) \
+ { \
+ GLX_DO_ALIGN_MAGIC( 4, type ); \
+ gl ## name ( (type *) pc ); \
+ } \
+ void __glXDispSwap_ ## name ( GLbyte * pc ) \
+ { \
+ __GLX_DECLARE_SWAP_VARIABLES; \
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES; \
+ GLX_DO_ALIGN_MAGIC( 4, type ); \
+ __GLX_SWAP_ ## type ## _ARRAY(pc, 4); \
+ gl ## name ( (type *) pc ); \
+ }
+
+#define dispatch_template_4s( name, type ) \
+ void __glXDisp_ ## name ( GLbyte * pc ) \
+ { \
+ GLX_DO_ALIGN_MAGIC( 4, type ); \
+ gl ## name ( ((type *) pc)[0], ((type *) pc)[1], \
+ ((type *) pc)[2], ((type *) pc)[3] ); \
+ } \
+ void __glXDispSwap_ ## name ( GLbyte * pc ) \
+ { \
+ __GLX_DECLARE_SWAP_VARIABLES; \
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES; \
+ GLX_DO_ALIGN_MAGIC( 4, type ); \
+ __GLX_SWAP_ ## type ## _ARRAY(pc, 4); \
+ gl ## name ( ((type *) pc)[0], ((type *) pc)[1], \
+ ((type *) pc)[2], ((type *) pc)[3] ); \
+ }
+
+/**
+ * \bug All of the enum1 templates need to be updated to handle the case where
+ * \c type is \c GLdouble. When the type is a double, the data comes before
+ * the enum. This is also the reason the invocation of the
+ * \c GLX_DO_ALIGN_MAGIC macro was removed.
+ */
+#define dispatch_template_enum1_1s( name, type ) \
+ void __glXDisp_ ## name ( GLbyte * pc ) \
+ { \
+ gl ## name ( *(GLenum *) (pc + 0), \
+ *(type *) (pc + 4) ); \
+ } \
+ void __glXDispSwap_ ## name ( GLbyte * pc ) \
+ { \
+ __GLX_DECLARE_SWAP_VARIABLES; \
+ __GLX_SWAP_INT (pc + 0); \
+ __GLX_SWAP_ ## type (pc + 4); \
+ gl ## name ( *(GLenum *) (pc + 0), \
+ *(type *) (pc + 4) ); \
+ }
+
+#define dispatch_template_enum1_Vv( name, type ) \
+ void __glXDisp_ ## name ( GLbyte * pc ) \
+ { \
+ gl ## name ( *(GLenum *) (pc + 0), \
+ (type *) (pc + 4) ); \
+ } \
+ void __glXDispSwap_ ## name ( GLbyte * pc ) \
+ { \
+ GLenum pname; GLint compsize; \
+ __GLX_DECLARE_SWAP_VARIABLES; \
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES; \
+ __GLX_SWAP_INT(pc + 0); \
+ pname = *(GLenum *)(pc + 0); \
+ compsize = __gl ## name ## _size(pname); \
+ if (compsize < 0) compsize = 0; \
+ __GLX_SWAP_ ## type ## _ARRAY(pc + 4, compsize); \
+ gl ## name ( *(GLenum *) (pc + 0), \
+ (type *) (pc + 4) ); \
+ }
+
+#ifndef MISSING_GL_EXTS
+dispatch_template_1( FogCoordfv, GLfloat )
+dispatch_template_1( FogCoorddv, GLdouble )
+dispatch_template_3( SecondaryColor3bv, GLbyte )
+dispatch_template_3( SecondaryColor3sv, GLshort )
+dispatch_template_3( SecondaryColor3iv, GLint )
+dispatch_template_3( SecondaryColor3ubv, GLubyte )
+dispatch_template_3( SecondaryColor3usv, GLushort )
+dispatch_template_3( SecondaryColor3uiv, GLuint )
+dispatch_template_3( SecondaryColor3fv, GLfloat )
+dispatch_template_3( SecondaryColor3dv, GLdouble )
+
+dispatch_template_4s( BlendFuncSeparate, GLenum )
+#endif /* !MISSING_GL_EXTS */
+
+void __glXDisp_Color3bv(GLbyte *pc)
+{
+ glColor3bv(
+ (GLbyte *)(pc + 0)
+ );
+}
+
+void __glXDisp_Color3dv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ glColor3dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_Color3fv(GLbyte *pc)
+{
+ glColor3fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_Color3iv(GLbyte *pc)
+{
+ glColor3iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDisp_Color3sv(GLbyte *pc)
+{
+ glColor3sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDisp_Color3ubv(GLbyte *pc)
+{
+ glColor3ubv(
+ (GLubyte *)(pc + 0)
+ );
+}
+
+void __glXDisp_Color3uiv(GLbyte *pc)
+{
+ glColor3uiv(
+ (GLuint *)(pc + 0)
+ );
+}
+
+void __glXDisp_Color3usv(GLbyte *pc)
+{
+ glColor3usv(
+ (GLushort *)(pc + 0)
+ );
+}
+
+void __glXDisp_Color4bv(GLbyte *pc)
+{
+ glColor4bv(
+ (GLbyte *)(pc + 0)
+ );
+}
+
+void __glXDisp_Color4dv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ glColor4dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_Color4fv(GLbyte *pc)
+{
+ glColor4fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_Color4iv(GLbyte *pc)
+{
+ glColor4iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDisp_Color4sv(GLbyte *pc)
+{
+ glColor4sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDisp_Color4ubv(GLbyte *pc)
+{
+ glColor4ubv(
+ (GLubyte *)(pc + 0)
+ );
+}
+
+void __glXDisp_Color4uiv(GLbyte *pc)
+{
+ glColor4uiv(
+ (GLuint *)(pc + 0)
+ );
+}
+
+void __glXDisp_Color4usv(GLbyte *pc)
+{
+ glColor4usv(
+ (GLushort *)(pc + 0)
+ );
+}
+
+void __glXDisp_EdgeFlagv(GLbyte *pc)
+{
+ glEdgeFlagv(
+ (GLboolean *)(pc + 0)
+ );
+}
+
+void __glXDisp_End(GLbyte *pc)
+{
+ glEnd(
+ );
+}
+
+void __glXDisp_Indexdv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 8);
+ pc -= 4;
+ }
+#endif
+ glIndexdv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_Indexfv(GLbyte *pc)
+{
+ glIndexfv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_Indexiv(GLbyte *pc)
+{
+ glIndexiv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDisp_Indexsv(GLbyte *pc)
+{
+ glIndexsv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDisp_Normal3bv(GLbyte *pc)
+{
+ glNormal3bv(
+ (GLbyte *)(pc + 0)
+ );
+}
+
+void __glXDisp_Normal3dv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ glNormal3dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_Normal3fv(GLbyte *pc)
+{
+ glNormal3fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_Normal3iv(GLbyte *pc)
+{
+ glNormal3iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDisp_Normal3sv(GLbyte *pc)
+{
+ glNormal3sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDisp_RasterPos2dv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ glRasterPos2dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_RasterPos2fv(GLbyte *pc)
+{
+ glRasterPos2fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_RasterPos2iv(GLbyte *pc)
+{
+ glRasterPos2iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDisp_RasterPos2sv(GLbyte *pc)
+{
+ glRasterPos2sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDisp_RasterPos3dv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ glRasterPos3dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_RasterPos3fv(GLbyte *pc)
+{
+ glRasterPos3fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_RasterPos3iv(GLbyte *pc)
+{
+ glRasterPos3iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDisp_RasterPos3sv(GLbyte *pc)
+{
+ glRasterPos3sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDisp_RasterPos4dv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ glRasterPos4dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_RasterPos4fv(GLbyte *pc)
+{
+ glRasterPos4fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_RasterPos4iv(GLbyte *pc)
+{
+ glRasterPos4iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDisp_RasterPos4sv(GLbyte *pc)
+{
+ glRasterPos4sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDisp_Rectdv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ glRectdv(
+ (GLdouble *)(pc + 0),
+ (GLdouble *)(pc + 16)
+ );
+}
+
+void __glXDisp_Rectfv(GLbyte *pc)
+{
+ glRectfv(
+ (GLfloat *)(pc + 0),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_Rectiv(GLbyte *pc)
+{
+ glRectiv(
+ (GLint *)(pc + 0),
+ (GLint *)(pc + 8)
+ );
+}
+
+void __glXDisp_Rectsv(GLbyte *pc)
+{
+ glRectsv(
+ (GLshort *)(pc + 0),
+ (GLshort *)(pc + 4)
+ );
+}
+
+void __glXDisp_TexCoord1dv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 8);
+ pc -= 4;
+ }
+#endif
+ glTexCoord1dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexCoord1fv(GLbyte *pc)
+{
+ glTexCoord1fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexCoord1iv(GLbyte *pc)
+{
+ glTexCoord1iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexCoord1sv(GLbyte *pc)
+{
+ glTexCoord1sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexCoord2dv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ glTexCoord2dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexCoord2fv(GLbyte *pc)
+{
+ glTexCoord2fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexCoord2iv(GLbyte *pc)
+{
+ glTexCoord2iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexCoord2sv(GLbyte *pc)
+{
+ glTexCoord2sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexCoord3dv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ glTexCoord3dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexCoord3fv(GLbyte *pc)
+{
+ glTexCoord3fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexCoord3iv(GLbyte *pc)
+{
+ glTexCoord3iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexCoord3sv(GLbyte *pc)
+{
+ glTexCoord3sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexCoord4dv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ glTexCoord4dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexCoord4fv(GLbyte *pc)
+{
+ glTexCoord4fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexCoord4iv(GLbyte *pc)
+{
+ glTexCoord4iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexCoord4sv(GLbyte *pc)
+{
+ glTexCoord4sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDisp_Vertex2dv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ glVertex2dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_Vertex2fv(GLbyte *pc)
+{
+ glVertex2fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_Vertex2iv(GLbyte *pc)
+{
+ glVertex2iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDisp_Vertex2sv(GLbyte *pc)
+{
+ glVertex2sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDisp_Vertex3dv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ glVertex3dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_Vertex3fv(GLbyte *pc)
+{
+ glVertex3fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_Vertex3iv(GLbyte *pc)
+{
+ glVertex3iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDisp_Vertex3sv(GLbyte *pc)
+{
+ glVertex3sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDisp_Vertex4dv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ glVertex4dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_Vertex4fv(GLbyte *pc)
+{
+ glVertex4fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_Vertex4iv(GLbyte *pc)
+{
+ glVertex4iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDisp_Vertex4sv(GLbyte *pc)
+{
+ glVertex4sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDisp_ClipPlane(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 36);
+ pc -= 4;
+ }
+#endif
+ glClipPlane(
+ *(GLenum *)(pc + 32),
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_ColorMaterial(GLbyte *pc)
+{
+ glColorMaterial(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4)
+ );
+}
+
+void __glXDisp_CullFace(GLbyte *pc)
+{
+ glCullFace(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDisp_Fogf(GLbyte *pc)
+{
+ glFogf(
+ *(GLenum *)(pc + 0),
+ *(GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDisp_Fogfv(GLbyte *pc)
+{
+ glFogfv(
+ *(GLenum *)(pc + 0),
+ (GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDisp_Fogi(GLbyte *pc)
+{
+ glFogi(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4)
+ );
+}
+
+void __glXDisp_Fogiv(GLbyte *pc)
+{
+ glFogiv(
+ *(GLenum *)(pc + 0),
+ (GLint *)(pc + 4)
+ );
+}
+
+void __glXDisp_FrontFace(GLbyte *pc)
+{
+ glFrontFace(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDisp_Hint(GLbyte *pc)
+{
+ glHint(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4)
+ );
+}
+
+void __glXDisp_Lightf(GLbyte *pc)
+{
+ glLightf(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_Lightfv(GLbyte *pc)
+{
+ glLightfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_Lighti(GLbyte *pc)
+{
+ glLighti(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8)
+ );
+}
+
+void __glXDisp_Lightiv(GLbyte *pc)
+{
+ glLightiv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *)(pc + 8)
+ );
+}
+
+void __glXDisp_LightModelf(GLbyte *pc)
+{
+ glLightModelf(
+ *(GLenum *)(pc + 0),
+ *(GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDisp_LightModelfv(GLbyte *pc)
+{
+ glLightModelfv(
+ *(GLenum *)(pc + 0),
+ (GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDisp_LightModeli(GLbyte *pc)
+{
+ glLightModeli(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4)
+ );
+}
+
+void __glXDisp_LightModeliv(GLbyte *pc)
+{
+ glLightModeliv(
+ *(GLenum *)(pc + 0),
+ (GLint *)(pc + 4)
+ );
+}
+
+void __glXDisp_LineStipple(GLbyte *pc)
+{
+ glLineStipple(
+ *(GLint *)(pc + 0),
+ *(GLushort *)(pc + 4)
+ );
+}
+
+void __glXDisp_LineWidth(GLbyte *pc)
+{
+ glLineWidth(
+ *(GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_Materialf(GLbyte *pc)
+{
+ glMaterialf(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_Materialfv(GLbyte *pc)
+{
+ glMaterialfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_Materiali(GLbyte *pc)
+{
+ glMateriali(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8)
+ );
+}
+
+void __glXDisp_Materialiv(GLbyte *pc)
+{
+ glMaterialiv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *)(pc + 8)
+ );
+}
+
+void __glXDisp_PointSize(GLbyte *pc)
+{
+ glPointSize(
+ *(GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_PolygonMode(GLbyte *pc)
+{
+ glPolygonMode(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4)
+ );
+}
+
+void __glXDisp_Scissor(GLbyte *pc)
+{
+ glScissor(
+ *(GLint *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLsizei *)(pc + 8),
+ *(GLsizei *)(pc + 12)
+ );
+}
+
+void __glXDisp_ShadeModel(GLbyte *pc)
+{
+ glShadeModel(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexParameterf(GLbyte *pc)
+{
+ glTexParameterf(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_TexParameterfv(GLbyte *pc)
+{
+ glTexParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_TexParameteri(GLbyte *pc)
+{
+ glTexParameteri(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8)
+ );
+}
+
+void __glXDisp_TexParameteriv(GLbyte *pc)
+{
+ glTexParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *)(pc + 8)
+ );
+}
+
+void __glXDisp_TexEnvf(GLbyte *pc)
+{
+ glTexEnvf(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_TexEnvfv(GLbyte *pc)
+{
+ glTexEnvfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_TexEnvi(GLbyte *pc)
+{
+ glTexEnvi(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8)
+ );
+}
+
+void __glXDisp_TexEnviv(GLbyte *pc)
+{
+ glTexEnviv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *)(pc + 8)
+ );
+}
+
+void __glXDisp_TexGend(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ glTexGend(
+ *(GLenum *)(pc + 8),
+ *(GLenum *)(pc + 12),
+ *(GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_TexGendv(GLbyte *pc)
+{
+#ifdef __GLX_ALIGN64
+ GLenum pname;
+ GLint cmdlen;
+ GLint compsize;
+
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glTexGendv_size(pname);
+ if (compsize < 0) compsize = 0;
+ cmdlen = __GLX_PAD(8+compsize*8);
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, cmdlen);
+ pc -= 4;
+ }
+#endif
+
+ glTexGendv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLdouble *)(pc + 8)
+ );
+}
+
+void __glXDisp_TexGenf(GLbyte *pc)
+{
+ glTexGenf(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_TexGenfv(GLbyte *pc)
+{
+ glTexGenfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_TexGeni(GLbyte *pc)
+{
+ glTexGeni(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8)
+ );
+}
+
+void __glXDisp_TexGeniv(GLbyte *pc)
+{
+ glTexGeniv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *)(pc + 8)
+ );
+}
+
+void __glXDisp_InitNames(GLbyte *pc)
+{
+ glInitNames(
+ );
+}
+
+void __glXDisp_LoadName(GLbyte *pc)
+{
+ glLoadName(
+ *(GLuint *)(pc + 0)
+ );
+}
+
+void __glXDisp_PassThrough(GLbyte *pc)
+{
+ glPassThrough(
+ *(GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_PopName(GLbyte *pc)
+{
+ glPopName(
+ );
+}
+
+void __glXDisp_PushName(GLbyte *pc)
+{
+ glPushName(
+ *(GLuint *)(pc + 0)
+ );
+}
+
+void __glXDisp_DrawBuffer(GLbyte *pc)
+{
+ glDrawBuffer(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDisp_Clear(GLbyte *pc)
+{
+ glClear(
+ *(GLbitfield *)(pc + 0)
+ );
+}
+
+void __glXDisp_ClearAccum(GLbyte *pc)
+{
+ glClearAccum(
+ *(GLfloat *)(pc + 0),
+ *(GLfloat *)(pc + 4),
+ *(GLfloat *)(pc + 8),
+ *(GLfloat *)(pc + 12)
+ );
+}
+
+void __glXDisp_ClearIndex(GLbyte *pc)
+{
+ glClearIndex(
+ *(GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_ClearColor(GLbyte *pc)
+{
+ glClearColor(
+ *(GLclampf *)(pc + 0),
+ *(GLclampf *)(pc + 4),
+ *(GLclampf *)(pc + 8),
+ *(GLclampf *)(pc + 12)
+ );
+}
+
+void __glXDisp_ClearStencil(GLbyte *pc)
+{
+ glClearStencil(
+ *(GLint *)(pc + 0)
+ );
+}
+
+void __glXDisp_ClearDepth(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 8);
+ pc -= 4;
+ }
+#endif
+ glClearDepth(
+ *(GLclampd *)(pc + 0)
+ );
+}
+
+void __glXDisp_StencilMask(GLbyte *pc)
+{
+ glStencilMask(
+ *(GLuint *)(pc + 0)
+ );
+}
+
+void __glXDisp_ColorMask(GLbyte *pc)
+{
+ glColorMask(
+ *(GLboolean *)(pc + 0),
+ *(GLboolean *)(pc + 1),
+ *(GLboolean *)(pc + 2),
+ *(GLboolean *)(pc + 3)
+ );
+}
+
+void __glXDisp_DepthMask(GLbyte *pc)
+{
+ glDepthMask(
+ *(GLboolean *)(pc + 0)
+ );
+}
+
+void __glXDisp_IndexMask(GLbyte *pc)
+{
+ glIndexMask(
+ *(GLuint *)(pc + 0)
+ );
+}
+
+void __glXDisp_Accum(GLbyte *pc)
+{
+ glAccum(
+ *(GLenum *)(pc + 0),
+ *(GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDisp_Disable(GLbyte *pc)
+{
+ glDisable(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDisp_Enable(GLbyte *pc)
+{
+ glEnable(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDisp_PopAttrib(GLbyte *pc)
+{
+ glPopAttrib(
+ );
+}
+
+void __glXDisp_PushAttrib(GLbyte *pc)
+{
+ glPushAttrib(
+ *(GLbitfield *)(pc + 0)
+ );
+}
+
+void __glXDisp_MapGrid1d(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 20);
+ pc -= 4;
+ }
+#endif
+ glMapGrid1d(
+ *(GLint *)(pc + 16),
+ *(GLdouble *)(pc + 0),
+ *(GLdouble *)(pc + 8)
+ );
+}
+
+void __glXDisp_MapGrid1f(GLbyte *pc)
+{
+ glMapGrid1f(
+ *(GLint *)(pc + 0),
+ *(GLfloat *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_MapGrid2d(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 40);
+ pc -= 4;
+ }
+#endif
+ glMapGrid2d(
+ *(GLint *)(pc + 32),
+ *(GLdouble *)(pc + 0),
+ *(GLdouble *)(pc + 8),
+ *(GLint *)(pc + 36),
+ *(GLdouble *)(pc + 16),
+ *(GLdouble *)(pc + 24)
+ );
+}
+
+void __glXDisp_MapGrid2f(GLbyte *pc)
+{
+ glMapGrid2f(
+ *(GLint *)(pc + 0),
+ *(GLfloat *)(pc + 4),
+ *(GLfloat *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLfloat *)(pc + 16),
+ *(GLfloat *)(pc + 20)
+ );
+}
+
+void __glXDisp_EvalCoord1dv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 8);
+ pc -= 4;
+ }
+#endif
+ glEvalCoord1dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_EvalCoord1fv(GLbyte *pc)
+{
+ glEvalCoord1fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_EvalCoord2dv(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ glEvalCoord2dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_EvalCoord2fv(GLbyte *pc)
+{
+ glEvalCoord2fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_EvalMesh1(GLbyte *pc)
+{
+ glEvalMesh1(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLint *)(pc + 8)
+ );
+}
+
+void __glXDisp_EvalPoint1(GLbyte *pc)
+{
+ glEvalPoint1(
+ *(GLint *)(pc + 0)
+ );
+}
+
+void __glXDisp_EvalMesh2(GLbyte *pc)
+{
+ glEvalMesh2(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLint *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLint *)(pc + 16)
+ );
+}
+
+void __glXDisp_EvalPoint2(GLbyte *pc)
+{
+ glEvalPoint2(
+ *(GLint *)(pc + 0),
+ *(GLint *)(pc + 4)
+ );
+}
+
+void __glXDisp_AlphaFunc(GLbyte *pc)
+{
+ glAlphaFunc(
+ *(GLenum *)(pc + 0),
+ *(GLclampf *)(pc + 4)
+ );
+}
+
+void __glXDisp_BlendFunc(GLbyte *pc)
+{
+ glBlendFunc(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4)
+ );
+}
+
+void __glXDisp_LogicOp(GLbyte *pc)
+{
+ glLogicOp(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDisp_StencilFunc(GLbyte *pc)
+{
+ glStencilFunc(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLuint *)(pc + 8)
+ );
+}
+
+void __glXDisp_StencilOp(GLbyte *pc)
+{
+ glStencilOp(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLenum *)(pc + 8)
+ );
+}
+
+void __glXDisp_DepthFunc(GLbyte *pc)
+{
+ glDepthFunc(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDisp_PixelZoom(GLbyte *pc)
+{
+ glPixelZoom(
+ *(GLfloat *)(pc + 0),
+ *(GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDisp_PixelTransferf(GLbyte *pc)
+{
+ glPixelTransferf(
+ *(GLenum *)(pc + 0),
+ *(GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDisp_PixelTransferi(GLbyte *pc)
+{
+ glPixelTransferi(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4)
+ );
+}
+
+void __glXDisp_PixelMapfv(GLbyte *pc)
+{
+ glPixelMapfv(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_PixelMapuiv(GLbyte *pc)
+{
+ glPixelMapuiv(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ (GLuint *)(pc + 8)
+ );
+}
+
+void __glXDisp_PixelMapusv(GLbyte *pc)
+{
+ glPixelMapusv(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ (GLushort *)(pc + 8)
+ );
+}
+
+void __glXDisp_ReadBuffer(GLbyte *pc)
+{
+ glReadBuffer(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDisp_CopyPixels(GLbyte *pc)
+{
+ glCopyPixels(
+ *(GLint *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLsizei *)(pc + 8),
+ *(GLsizei *)(pc + 12),
+ *(GLenum *)(pc + 16)
+ );
+}
+
+void __glXDisp_DepthRange(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ glDepthRange(
+ *(GLclampd *)(pc + 0),
+ *(GLclampd *)(pc + 8)
+ );
+}
+
+void __glXDisp_Frustum(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 48);
+ pc -= 4;
+ }
+#endif
+ glFrustum(
+ *(GLdouble *)(pc + 0),
+ *(GLdouble *)(pc + 8),
+ *(GLdouble *)(pc + 16),
+ *(GLdouble *)(pc + 24),
+ *(GLdouble *)(pc + 32),
+ *(GLdouble *)(pc + 40)
+ );
+}
+
+void __glXDisp_LoadIdentity(GLbyte *pc)
+{
+ glLoadIdentity(
+ );
+}
+
+void __glXDisp_LoadMatrixf(GLbyte *pc)
+{
+ glLoadMatrixf(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_LoadMatrixd(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 128);
+ pc -= 4;
+ }
+#endif
+ glLoadMatrixd(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_MatrixMode(GLbyte *pc)
+{
+ glMatrixMode(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDisp_MultMatrixf(GLbyte *pc)
+{
+ glMultMatrixf(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDisp_MultMatrixd(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 128);
+ pc -= 4;
+ }
+#endif
+ glMultMatrixd(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_Ortho(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 48);
+ pc -= 4;
+ }
+#endif
+ glOrtho(
+ *(GLdouble *)(pc + 0),
+ *(GLdouble *)(pc + 8),
+ *(GLdouble *)(pc + 16),
+ *(GLdouble *)(pc + 24),
+ *(GLdouble *)(pc + 32),
+ *(GLdouble *)(pc + 40)
+ );
+}
+
+void __glXDisp_PopMatrix(GLbyte *pc)
+{
+ glPopMatrix(
+ );
+}
+
+void __glXDisp_PushMatrix(GLbyte *pc)
+{
+ glPushMatrix(
+ );
+}
+
+void __glXDisp_Rotated(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ glRotated(
+ *(GLdouble *)(pc + 0),
+ *(GLdouble *)(pc + 8),
+ *(GLdouble *)(pc + 16),
+ *(GLdouble *)(pc + 24)
+ );
+}
+
+void __glXDisp_Rotatef(GLbyte *pc)
+{
+ glRotatef(
+ *(GLfloat *)(pc + 0),
+ *(GLfloat *)(pc + 4),
+ *(GLfloat *)(pc + 8),
+ *(GLfloat *)(pc + 12)
+ );
+}
+
+void __glXDisp_Scaled(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ glScaled(
+ *(GLdouble *)(pc + 0),
+ *(GLdouble *)(pc + 8),
+ *(GLdouble *)(pc + 16)
+ );
+}
+
+void __glXDisp_Scalef(GLbyte *pc)
+{
+ glScalef(
+ *(GLfloat *)(pc + 0),
+ *(GLfloat *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_Translated(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ glTranslated(
+ *(GLdouble *)(pc + 0),
+ *(GLdouble *)(pc + 8),
+ *(GLdouble *)(pc + 16)
+ );
+}
+
+void __glXDisp_Translatef(GLbyte *pc)
+{
+ glTranslatef(
+ *(GLfloat *)(pc + 0),
+ *(GLfloat *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_Viewport(GLbyte *pc)
+{
+ glViewport(
+ *(GLint *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLsizei *)(pc + 8),
+ *(GLsizei *)(pc + 12)
+ );
+}
+
+void __glXDisp_PolygonOffset(GLbyte *pc)
+{
+ glPolygonOffset(
+ *(GLfloat *)(pc + 0),
+ *(GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDisp_CopyTexImage1D(GLbyte *pc)
+{
+ glCopyTexImage1D(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLint *)(pc + 16),
+ *(GLsizei *)(pc + 20),
+ *(GLint *)(pc + 24)
+ );
+}
+
+void __glXDisp_CopyTexImage2D(GLbyte *pc)
+{
+ glCopyTexImage2D(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLint *)(pc + 16),
+ *(GLsizei *)(pc + 20),
+ *(GLsizei *)(pc + 24),
+ *(GLint *)(pc + 28)
+ );
+}
+
+void __glXDisp_CopyTexSubImage1D(GLbyte *pc)
+{
+ glCopyTexSubImage1D(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLint *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLint *)(pc + 16),
+ *(GLsizei *)(pc + 20)
+ );
+}
+
+void __glXDisp_CopyTexSubImage2D(GLbyte *pc)
+{
+ glCopyTexSubImage2D(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLint *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLint *)(pc + 16),
+ *(GLint *)(pc + 20),
+ *(GLsizei *)(pc + 24),
+ *(GLsizei *)(pc + 28)
+ );
+}
+
+void __glXDisp_BindTexture(GLbyte *pc)
+{
+ glBindTexture(
+ *(GLenum *)(pc + 0),
+ *(GLuint *)(pc + 4)
+ );
+}
+
+void __glXDisp_PrioritizeTextures(GLbyte *pc)
+{
+ GLsizei n;
+
+ n = *(GLsizei *)(pc + 0);
+
+ glPrioritizeTextures(
+ *(GLsizei *)(pc + 0),
+ (GLuint *)(pc + 4),
+ (GLclampf *)(pc + 4+n*4)
+ );
+}
+
+void __glXDisp_Indexubv(GLbyte *pc)
+{
+ glIndexubv(
+ (GLubyte *)(pc + 0)
+ );
+}
+
+void __glXDisp_BlendColor(GLbyte *pc)
+{
+ glBlendColor(
+ *(GLclampf *)(pc + 0),
+ *(GLclampf *)(pc + 4),
+ *(GLclampf *)(pc + 8),
+ *(GLclampf *)(pc + 12)
+ );
+}
+
+void __glXDisp_BlendEquation(GLbyte *pc)
+{
+ glBlendEquation(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDisp_ColorTableParameterfv(GLbyte *pc)
+{
+ glColorTableParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_ColorTableParameteriv(GLbyte *pc)
+{
+ glColorTableParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *)(pc + 8)
+ );
+}
+
+void __glXDisp_CopyColorTable(GLbyte *pc)
+{
+ glCopyColorTable(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLsizei *)(pc + 16)
+ );
+}
+
+void __glXDisp_CopyColorSubTable(GLbyte *pc)
+{
+ glCopyColorSubTable(
+ *(GLenum *)(pc + 0),
+ *(GLsizei *)(pc + 4),
+ *(GLint *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLsizei *)(pc + 16)
+ );
+}
+
+void __glXDisp_ConvolutionParameterf(GLbyte *pc)
+{
+ glConvolutionParameterf(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_ConvolutionParameterfv(GLbyte *pc)
+{
+ glConvolutionParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDisp_ConvolutionParameteri(GLbyte *pc)
+{
+ glConvolutionParameteri(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8)
+ );
+}
+
+void __glXDisp_ConvolutionParameteriv(GLbyte *pc)
+{
+ glConvolutionParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *)(pc + 8)
+ );
+}
+
+void __glXDisp_CopyConvolutionFilter1D(GLbyte *pc)
+{
+ glCopyConvolutionFilter1D(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLsizei *)(pc + 16)
+ );
+}
+
+void __glXDisp_CopyConvolutionFilter2D(GLbyte *pc)
+{
+ glCopyConvolutionFilter2D(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLsizei *)(pc + 16),
+ *(GLsizei *)(pc + 20)
+ );
+}
+
+void __glXDisp_Histogram(GLbyte *pc)
+{
+ glHistogram(
+ *(GLenum *)(pc + 0),
+ *(GLsizei *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ *(GLboolean *)(pc + 12)
+ );
+}
+
+void __glXDisp_Minmax(GLbyte *pc)
+{
+ glMinmax(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLboolean *)(pc + 8)
+ );
+}
+
+void __glXDisp_ResetHistogram(GLbyte *pc)
+{
+ glResetHistogram(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDisp_ResetMinmax(GLbyte *pc)
+{
+ glResetMinmax(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDisp_CopyTexSubImage3D(GLbyte *pc)
+{
+ glCopyTexSubImage3D(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLint *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLint *)(pc + 16),
+ *(GLint *)(pc + 20),
+ *(GLint *)(pc + 24),
+ *(GLsizei *)(pc + 28),
+ *(GLsizei *)(pc + 32)
+ );
+}
+
+void __glXDisp_ActiveTextureARB(GLbyte *pc)
+{
+ glActiveTextureARB(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDisp_MultiTexCoord1dvARB(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 12);
+ pc -= 4;
+ }
+#endif
+ glMultiTexCoord1dvARB(
+ *(GLenum *)(pc + 8),
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_MultiTexCoord1fvARB(GLbyte *pc)
+{
+ glMultiTexCoord1fvARB(
+ *(GLenum *)(pc + 0),
+ (GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDisp_MultiTexCoord1ivARB(GLbyte *pc)
+{
+ glMultiTexCoord1ivARB(
+ *(GLenum *)(pc + 0),
+ (GLint *)(pc + 4)
+ );
+}
+
+void __glXDisp_MultiTexCoord1svARB(GLbyte *pc)
+{
+ glMultiTexCoord1svARB(
+ *(GLenum *)(pc + 0),
+ (GLshort *)(pc + 4)
+ );
+}
+
+void __glXDisp_MultiTexCoord2dvARB(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 20);
+ pc -= 4;
+ }
+#endif
+ glMultiTexCoord2dvARB(
+ *(GLenum *)(pc + 16),
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_MultiTexCoord2fvARB(GLbyte *pc)
+{
+ glMultiTexCoord2fvARB(
+ *(GLenum *)(pc + 0),
+ (GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDisp_MultiTexCoord2ivARB(GLbyte *pc)
+{
+ glMultiTexCoord2ivARB(
+ *(GLenum *)(pc + 0),
+ (GLint *)(pc + 4)
+ );
+}
+
+void __glXDisp_MultiTexCoord2svARB(GLbyte *pc)
+{
+ glMultiTexCoord2svARB(
+ *(GLenum *)(pc + 0),
+ (GLshort *)(pc + 4)
+ );
+}
+
+void __glXDisp_MultiTexCoord3dvARB(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 28);
+ pc -= 4;
+ }
+#endif
+ glMultiTexCoord3dvARB(
+ *(GLenum *)(pc + 24),
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_MultiTexCoord3fvARB(GLbyte *pc)
+{
+ glMultiTexCoord3fvARB(
+ *(GLenum *)(pc + 0),
+ (GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDisp_MultiTexCoord3ivARB(GLbyte *pc)
+{
+ glMultiTexCoord3ivARB(
+ *(GLenum *)(pc + 0),
+ (GLint *)(pc + 4)
+ );
+}
+
+void __glXDisp_MultiTexCoord3svARB(GLbyte *pc)
+{
+ glMultiTexCoord3svARB(
+ *(GLenum *)(pc + 0),
+ (GLshort *)(pc + 4)
+ );
+}
+
+void __glXDisp_MultiTexCoord4dvARB(GLbyte *pc)
+{
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 36);
+ pc -= 4;
+ }
+#endif
+ glMultiTexCoord4dvARB(
+ *(GLenum *)(pc + 32),
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDisp_MultiTexCoord4fvARB(GLbyte *pc)
+{
+ glMultiTexCoord4fvARB(
+ *(GLenum *)(pc + 0),
+ (GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDisp_MultiTexCoord4ivARB(GLbyte *pc)
+{
+ glMultiTexCoord4ivARB(
+ *(GLenum *)(pc + 0),
+ (GLint *)(pc + 4)
+ );
+}
+
+void __glXDisp_MultiTexCoord4svARB(GLbyte *pc)
+{
+ glMultiTexCoord4svARB(
+ *(GLenum *)(pc + 0),
+ (GLshort *)(pc + 4)
+ );
+}
+
+
+/*
+ * Extensions
+ */
+
+#ifndef MISSING_GL_EXTS
+
+void __glXDisp_PointParameterfARB(GLbyte *pc)
+{
+ glPointParameterfARB(
+ *(GLenum *)(pc + 0),
+ *(GLfloat *)(pc + 4)
+ );
+}
+
+
+void __glXDisp_PointParameterfvARB(GLbyte *pc)
+{
+ glPointParameterfvARB(
+ *(GLenum *)(pc + 0),
+ (GLfloat *)(pc + 4)
+ );
+}
+
+dispatch_template_enum1_1s(PointParameteriNV, GLint)
+dispatch_template_enum1_Vv(PointParameterivNV, GLint)
+
+void __glXDisp_ActiveStencilFaceEXT(GLbyte *pc)
+{
+ glActiveStencilFaceEXT(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDisp_WindowPos3fARB(GLbyte *pc)
+{
+ glWindowPos3fARB(
+ *(GLfloat *)(pc + 0),
+ *(GLfloat *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+#endif /* !MISSING_GL_EXTS */
+
+void __glXDisp_SampleCoverageARB(GLbyte *pc)
+{
+ glSampleCoverageARB(
+ *(GLfloat *)(pc + 0),
+ *(GLboolean *)(pc + 4)
+ );
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/g_renderswap.c b/nx-X11/programs/Xserver/GL/glx/g_renderswap.c
new file mode 100644
index 000000000..f485a2690
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/g_renderswap.c
@@ -0,0 +1,3387 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/g_renderswap.c,v 1.8 2004/01/28 18:11:50 alanh Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxext.h"
+#include "g_disptab.h"
+#include "g_disptab_EXT.h"
+#include "unpack.h"
+#include "impsize.h"
+#include "singlesize.h"
+
+void __glXDispSwap_CallList(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glCallList(
+ *(GLuint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_ListBase(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glListBase(
+ *(GLuint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Begin(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glBegin(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Color3bv(GLbyte *pc)
+{
+ glColor3bv(
+ (GLbyte *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Color3dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 3);
+
+ glColor3dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Color3fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 3);
+
+ glColor3fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Color3iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 3);
+
+ glColor3iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Color3sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
+
+ glColor3sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Color3ubv(GLbyte *pc)
+{
+ glColor3ubv(
+ (GLubyte *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Color3uiv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 3);
+
+ glColor3uiv(
+ (GLuint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Color3usv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
+
+ glColor3usv(
+ (GLushort *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Color4bv(GLbyte *pc)
+{
+ glColor4bv(
+ (GLbyte *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Color4dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 4);
+
+ glColor4dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Color4fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 4);
+
+ glColor4fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Color4iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 4);
+
+ glColor4iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Color4sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 4);
+
+ glColor4sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Color4ubv(GLbyte *pc)
+{
+ glColor4ubv(
+ (GLubyte *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Color4uiv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 4);
+
+ glColor4uiv(
+ (GLuint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Color4usv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 4);
+
+ glColor4usv(
+ (GLushort *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_EdgeFlagv(GLbyte *pc)
+{
+ glEdgeFlagv(
+ (GLboolean *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_End(GLbyte *pc)
+{
+ glEnd(
+ );
+}
+
+void __glXDispSwap_Indexdv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 8);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 1);
+
+ glIndexdv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Indexfv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 1);
+
+ glIndexfv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Indexiv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 1);
+
+ glIndexiv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Indexsv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 1);
+
+ glIndexsv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Normal3bv(GLbyte *pc)
+{
+ glNormal3bv(
+ (GLbyte *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Normal3dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 3);
+
+ glNormal3dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Normal3fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 3);
+
+ glNormal3fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Normal3iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 3);
+
+ glNormal3iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Normal3sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
+
+ glNormal3sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_RasterPos2dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 2);
+
+ glRasterPos2dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_RasterPos2fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 2);
+
+ glRasterPos2fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_RasterPos2iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 2);
+
+ glRasterPos2iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_RasterPos2sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 2);
+
+ glRasterPos2sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_RasterPos3dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 3);
+
+ glRasterPos3dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_RasterPos3fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 3);
+
+ glRasterPos3fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_RasterPos3iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 3);
+
+ glRasterPos3iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_RasterPos3sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
+
+ glRasterPos3sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_RasterPos4dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 4);
+
+ glRasterPos4dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_RasterPos4fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 4);
+
+ glRasterPos4fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_RasterPos4iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 4);
+
+ glRasterPos4iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_RasterPos4sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 4);
+
+ glRasterPos4sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Rectdv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 2);
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 16, 2);
+
+ glRectdv(
+ (GLdouble *)(pc + 0),
+ (GLdouble *)(pc + 16)
+ );
+}
+
+void __glXDispSwap_Rectfv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 2);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, 2);
+
+ glRectfv(
+ (GLfloat *)(pc + 0),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_Rectiv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 2);
+ __GLX_SWAP_INT_ARRAY(pc + 8, 2);
+
+ glRectiv(
+ (GLint *)(pc + 0),
+ (GLint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_Rectsv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 2);
+ __GLX_SWAP_SHORT_ARRAY(pc + 4, 2);
+
+ glRectsv(
+ (GLshort *)(pc + 0),
+ (GLshort *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_TexCoord1dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 8);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 1);
+
+ glTexCoord1dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexCoord1fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 1);
+
+ glTexCoord1fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexCoord1iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 1);
+
+ glTexCoord1iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexCoord1sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 1);
+
+ glTexCoord1sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexCoord2dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 2);
+
+ glTexCoord2dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexCoord2fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 2);
+
+ glTexCoord2fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexCoord2iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 2);
+
+ glTexCoord2iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexCoord2sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 2);
+
+ glTexCoord2sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexCoord3dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 3);
+
+ glTexCoord3dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexCoord3fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 3);
+
+ glTexCoord3fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexCoord3iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 3);
+
+ glTexCoord3iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexCoord3sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
+
+ glTexCoord3sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexCoord4dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 4);
+
+ glTexCoord4dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexCoord4fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 4);
+
+ glTexCoord4fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexCoord4iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 4);
+
+ glTexCoord4iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexCoord4sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 4);
+
+ glTexCoord4sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Vertex2dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 2);
+
+ glVertex2dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Vertex2fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 2);
+
+ glVertex2fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Vertex2iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 2);
+
+ glVertex2iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Vertex2sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 2);
+
+ glVertex2sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Vertex3dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 3);
+
+ glVertex3dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Vertex3fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 3);
+
+ glVertex3fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Vertex3iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 3);
+
+ glVertex3iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Vertex3sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
+
+ glVertex3sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Vertex4dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 4);
+
+ glVertex4dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Vertex4fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 4);
+
+ glVertex4fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Vertex4iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 4);
+
+ glVertex4iv(
+ (GLint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Vertex4sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 4);
+
+ glVertex4sv(
+ (GLshort *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_ClipPlane(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 36);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 32);
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 4);
+
+ glClipPlane(
+ *(GLenum *)(pc + 32),
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_ColorMaterial(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+ glColorMaterial(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_CullFace(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glCullFace(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Fogf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+
+ glFogf(
+ *(GLenum *)(pc + 0),
+ *(GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_Fogfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glFogfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_FLOAT_ARRAY(pc + 4, compsize);
+
+ glFogfv(
+ *(GLenum *)(pc + 0),
+ (GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_Fogi(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+ glFogi(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_Fogiv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glFogiv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT_ARRAY(pc + 4, compsize);
+
+ glFogiv(
+ *(GLenum *)(pc + 0),
+ (GLint *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_FrontFace(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glFrontFace(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Hint(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+ glHint(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_Lightf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+ glLightf(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_Lightfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glLightfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, compsize);
+
+ glLightfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_Lighti(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+ glLighti(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_Lightiv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glLightiv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 8, compsize);
+
+ glLightiv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_LightModelf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+
+ glLightModelf(
+ *(GLenum *)(pc + 0),
+ *(GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_LightModelfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glLightModelfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_FLOAT_ARRAY(pc + 4, compsize);
+
+ glLightModelfv(
+ *(GLenum *)(pc + 0),
+ (GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_LightModeli(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+ glLightModeli(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_LightModeliv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glLightModeliv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT_ARRAY(pc + 4, compsize);
+
+ glLightModeliv(
+ *(GLenum *)(pc + 0),
+ (GLint *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_LineStipple(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_SHORT(pc + 4);
+
+ glLineStipple(
+ *(GLint *)(pc + 0),
+ *(GLushort *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_LineWidth(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+
+ glLineWidth(
+ *(GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Materialf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+ glMaterialf(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_Materialfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glMaterialfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, compsize);
+
+ glMaterialfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_Materiali(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+ glMateriali(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_Materialiv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glMaterialiv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 8, compsize);
+
+ glMaterialiv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_PointSize(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+
+ glPointSize(
+ *(GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_PolygonMode(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+ glPolygonMode(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_Scissor(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+
+ glScissor(
+ *(GLint *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLsizei *)(pc + 8),
+ *(GLsizei *)(pc + 12)
+ );
+}
+
+void __glXDispSwap_ShadeModel(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glShadeModel(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexParameterf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+ glTexParameterf(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_TexParameterfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glTexParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, compsize);
+
+ glTexParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_TexParameteri(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+ glTexParameteri(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_TexParameteriv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glTexParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 8, compsize);
+
+ glTexParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_TexEnvf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+ glTexEnvf(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_TexEnvfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glTexEnvfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, compsize);
+
+ glTexEnvfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_TexEnvi(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+ glTexEnvi(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_TexEnviv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glTexEnviv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 8, compsize);
+
+ glTexEnviv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_TexGend(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_DOUBLE(pc + 0);
+
+ glTexGend(
+ *(GLenum *)(pc + 8),
+ *(GLenum *)(pc + 12),
+ *(GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_TexGendv(GLbyte *pc)
+{
+ GLenum pname;
+#ifdef __GLX_ALIGN64
+ GLint cmdlen;
+#endif
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glTexGendv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+#ifdef __GLX_ALIGN64
+ cmdlen = __GLX_PAD(8+compsize*8);
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, cmdlen);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 8, compsize);
+
+ glTexGendv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLdouble *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_TexGenf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+ glTexGenf(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_TexGenfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glTexGenfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, compsize);
+
+ glTexGenfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_TexGeni(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+ glTexGeni(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_TexGeniv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glTexGeniv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 8, compsize);
+
+ glTexGeniv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_InitNames(GLbyte *pc)
+{
+ glInitNames(
+ );
+}
+
+void __glXDispSwap_LoadName(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glLoadName(
+ *(GLuint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_PassThrough(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+
+ glPassThrough(
+ *(GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_PopName(GLbyte *pc)
+{
+ glPopName(
+ );
+}
+
+void __glXDispSwap_PushName(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glPushName(
+ *(GLuint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_DrawBuffer(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glDrawBuffer(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Clear(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glClear(
+ *(GLbitfield *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_ClearAccum(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+ __GLX_SWAP_FLOAT(pc + 12);
+
+ glClearAccum(
+ *(GLfloat *)(pc + 0),
+ *(GLfloat *)(pc + 4),
+ *(GLfloat *)(pc + 8),
+ *(GLfloat *)(pc + 12)
+ );
+}
+
+void __glXDispSwap_ClearIndex(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+
+ glClearIndex(
+ *(GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_ClearColor(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+ __GLX_SWAP_FLOAT(pc + 12);
+
+ glClearColor(
+ *(GLclampf *)(pc + 0),
+ *(GLclampf *)(pc + 4),
+ *(GLclampf *)(pc + 8),
+ *(GLclampf *)(pc + 12)
+ );
+}
+
+void __glXDispSwap_ClearStencil(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glClearStencil(
+ *(GLint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_ClearDepth(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 8);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE(pc + 0);
+
+ glClearDepth(
+ *(GLclampd *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_StencilMask(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glStencilMask(
+ *(GLuint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_ColorMask(GLbyte *pc)
+{
+ glColorMask(
+ *(GLboolean *)(pc + 0),
+ *(GLboolean *)(pc + 1),
+ *(GLboolean *)(pc + 2),
+ *(GLboolean *)(pc + 3)
+ );
+}
+
+void __glXDispSwap_DepthMask(GLbyte *pc)
+{
+ glDepthMask(
+ *(GLboolean *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_IndexMask(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glIndexMask(
+ *(GLuint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Accum(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+
+ glAccum(
+ *(GLenum *)(pc + 0),
+ *(GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_Disable(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glDisable(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Enable(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glEnable(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_PopAttrib(GLbyte *pc)
+{
+ glPopAttrib(
+ );
+}
+
+void __glXDispSwap_PushAttrib(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glPushAttrib(
+ *(GLbitfield *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_MapGrid1d(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 20);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+
+ glMapGrid1d(
+ *(GLint *)(pc + 16),
+ *(GLdouble *)(pc + 0),
+ *(GLdouble *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_MapGrid1f(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+ glMapGrid1f(
+ *(GLint *)(pc + 0),
+ *(GLfloat *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_MapGrid2d(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 40);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 32);
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_INT(pc + 36);
+ __GLX_SWAP_DOUBLE(pc + 16);
+ __GLX_SWAP_DOUBLE(pc + 24);
+
+ glMapGrid2d(
+ *(GLint *)(pc + 32),
+ *(GLdouble *)(pc + 0),
+ *(GLdouble *)(pc + 8),
+ *(GLint *)(pc + 36),
+ *(GLdouble *)(pc + 16),
+ *(GLdouble *)(pc + 24)
+ );
+}
+
+void __glXDispSwap_MapGrid2f(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_FLOAT(pc + 16);
+ __GLX_SWAP_FLOAT(pc + 20);
+
+ glMapGrid2f(
+ *(GLint *)(pc + 0),
+ *(GLfloat *)(pc + 4),
+ *(GLfloat *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLfloat *)(pc + 16),
+ *(GLfloat *)(pc + 20)
+ );
+}
+
+void __glXDispSwap_EvalCoord1dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 8);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 1);
+
+ glEvalCoord1dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_EvalCoord1fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 1);
+
+ glEvalCoord1fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_EvalCoord2dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 2);
+
+ glEvalCoord2dv(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_EvalCoord2fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 2);
+
+ glEvalCoord2fv(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_EvalMesh1(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+ glEvalMesh1(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_EvalPoint1(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glEvalPoint1(
+ *(GLint *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_EvalMesh2(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+
+ glEvalMesh2(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLint *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLint *)(pc + 16)
+ );
+}
+
+void __glXDispSwap_EvalPoint2(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+ glEvalPoint2(
+ *(GLint *)(pc + 0),
+ *(GLint *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_AlphaFunc(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+
+ glAlphaFunc(
+ *(GLenum *)(pc + 0),
+ *(GLclampf *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_BlendFunc(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+ glBlendFunc(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_LogicOp(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glLogicOp(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_StencilFunc(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+ glStencilFunc(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLuint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_StencilOp(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+ glStencilOp(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLenum *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_DepthFunc(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glDepthFunc(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_PixelZoom(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+
+ glPixelZoom(
+ *(GLfloat *)(pc + 0),
+ *(GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_PixelTransferf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+
+ glPixelTransferf(
+ *(GLenum *)(pc + 0),
+ *(GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_PixelTransferi(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+ glPixelTransferi(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_PixelMapfv(GLbyte *pc)
+{
+ GLint mapsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ mapsize = *(GLint *)(pc + 4);
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, mapsize);
+
+ glPixelMapfv(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_PixelMapuiv(GLbyte *pc)
+{
+ GLint mapsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ mapsize = *(GLint *)(pc + 4);
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 8, mapsize);
+
+ glPixelMapuiv(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ (GLuint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_PixelMapusv(GLbyte *pc)
+{
+ GLint mapsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ mapsize = *(GLint *)(pc + 4);
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_SHORT_ARRAY(pc + 8, mapsize);
+
+ glPixelMapusv(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ (GLushort *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_ReadBuffer(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glReadBuffer(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_CopyPixels(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+
+ glCopyPixels(
+ *(GLint *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLsizei *)(pc + 8),
+ *(GLsizei *)(pc + 12),
+ *(GLenum *)(pc + 16)
+ );
+}
+
+void __glXDispSwap_DepthRange(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+
+ glDepthRange(
+ *(GLclampd *)(pc + 0),
+ *(GLclampd *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_Frustum(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 48);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_DOUBLE(pc + 16);
+ __GLX_SWAP_DOUBLE(pc + 24);
+ __GLX_SWAP_DOUBLE(pc + 32);
+ __GLX_SWAP_DOUBLE(pc + 40);
+
+ glFrustum(
+ *(GLdouble *)(pc + 0),
+ *(GLdouble *)(pc + 8),
+ *(GLdouble *)(pc + 16),
+ *(GLdouble *)(pc + 24),
+ *(GLdouble *)(pc + 32),
+ *(GLdouble *)(pc + 40)
+ );
+}
+
+void __glXDispSwap_LoadIdentity(GLbyte *pc)
+{
+ glLoadIdentity(
+ );
+}
+
+void __glXDispSwap_LoadMatrixf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 16);
+
+ glLoadMatrixf(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_LoadMatrixd(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 128);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 16);
+
+ glLoadMatrixd(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_MatrixMode(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glMatrixMode(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_MultMatrixf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 16);
+
+ glMultMatrixf(
+ (GLfloat *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_MultMatrixd(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 128);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 16);
+
+ glMultMatrixd(
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_Ortho(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 48);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_DOUBLE(pc + 16);
+ __GLX_SWAP_DOUBLE(pc + 24);
+ __GLX_SWAP_DOUBLE(pc + 32);
+ __GLX_SWAP_DOUBLE(pc + 40);
+
+ glOrtho(
+ *(GLdouble *)(pc + 0),
+ *(GLdouble *)(pc + 8),
+ *(GLdouble *)(pc + 16),
+ *(GLdouble *)(pc + 24),
+ *(GLdouble *)(pc + 32),
+ *(GLdouble *)(pc + 40)
+ );
+}
+
+void __glXDispSwap_PopMatrix(GLbyte *pc)
+{
+ glPopMatrix(
+ );
+}
+
+void __glXDispSwap_PushMatrix(GLbyte *pc)
+{
+ glPushMatrix(
+ );
+}
+
+void __glXDispSwap_Rotated(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_DOUBLE(pc + 16);
+ __GLX_SWAP_DOUBLE(pc + 24);
+
+ glRotated(
+ *(GLdouble *)(pc + 0),
+ *(GLdouble *)(pc + 8),
+ *(GLdouble *)(pc + 16),
+ *(GLdouble *)(pc + 24)
+ );
+}
+
+void __glXDispSwap_Rotatef(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+ __GLX_SWAP_FLOAT(pc + 12);
+
+ glRotatef(
+ *(GLfloat *)(pc + 0),
+ *(GLfloat *)(pc + 4),
+ *(GLfloat *)(pc + 8),
+ *(GLfloat *)(pc + 12)
+ );
+}
+
+void __glXDispSwap_Scaled(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_DOUBLE(pc + 16);
+
+ glScaled(
+ *(GLdouble *)(pc + 0),
+ *(GLdouble *)(pc + 8),
+ *(GLdouble *)(pc + 16)
+ );
+}
+
+void __glXDispSwap_Scalef(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+ glScalef(
+ *(GLfloat *)(pc + 0),
+ *(GLfloat *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_Translated(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_DOUBLE(pc + 16);
+
+ glTranslated(
+ *(GLdouble *)(pc + 0),
+ *(GLdouble *)(pc + 8),
+ *(GLdouble *)(pc + 16)
+ );
+}
+
+void __glXDispSwap_Translatef(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+ glTranslatef(
+ *(GLfloat *)(pc + 0),
+ *(GLfloat *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_Viewport(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+
+ glViewport(
+ *(GLint *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLsizei *)(pc + 8),
+ *(GLsizei *)(pc + 12)
+ );
+}
+
+void __glXDispSwap_PolygonOffset(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+
+ glPolygonOffset(
+ *(GLfloat *)(pc + 0),
+ *(GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_CopyTexImage1D(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_INT(pc + 20);
+ __GLX_SWAP_INT(pc + 24);
+
+ glCopyTexImage1D(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLint *)(pc + 16),
+ *(GLsizei *)(pc + 20),
+ *(GLint *)(pc + 24)
+ );
+}
+
+void __glXDispSwap_CopyTexImage2D(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_INT(pc + 20);
+ __GLX_SWAP_INT(pc + 24);
+ __GLX_SWAP_INT(pc + 28);
+
+ glCopyTexImage2D(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLint *)(pc + 16),
+ *(GLsizei *)(pc + 20),
+ *(GLsizei *)(pc + 24),
+ *(GLint *)(pc + 28)
+ );
+}
+
+void __glXDispSwap_CopyTexSubImage1D(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_INT(pc + 20);
+
+ glCopyTexSubImage1D(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLint *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLint *)(pc + 16),
+ *(GLsizei *)(pc + 20)
+ );
+}
+
+void __glXDispSwap_CopyTexSubImage2D(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_INT(pc + 20);
+ __GLX_SWAP_INT(pc + 24);
+ __GLX_SWAP_INT(pc + 28);
+
+ glCopyTexSubImage2D(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLint *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLint *)(pc + 16),
+ *(GLint *)(pc + 20),
+ *(GLsizei *)(pc + 24),
+ *(GLsizei *)(pc + 28)
+ );
+}
+
+void __glXDispSwap_BindTexture(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+ glBindTexture(
+ *(GLenum *)(pc + 0),
+ *(GLuint *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_PrioritizeTextures(GLbyte *pc)
+{
+ GLsizei n;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ n = *(GLsizei *)(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 4, n);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 4+n*4, n);
+
+ glPrioritizeTextures(
+ *(GLsizei *)(pc + 0),
+ (GLuint *)(pc + 4),
+ (GLclampf *)(pc + 4+n*4)
+ );
+}
+
+void __glXDispSwap_Indexubv(GLbyte *pc)
+{
+ glIndexubv(
+ (GLubyte *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_BlendColor(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+ __GLX_SWAP_FLOAT(pc + 12);
+
+ glBlendColor(
+ *(GLclampf *)(pc + 0),
+ *(GLclampf *)(pc + 4),
+ *(GLclampf *)(pc + 8),
+ *(GLclampf *)(pc + 12)
+ );
+}
+
+void __glXDispSwap_BlendEquation(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glBlendEquation(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_ColorTableParameterfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glColorTableParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, compsize);
+
+ glColorTableParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_ColorTableParameteriv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glColorTableParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 8, compsize);
+
+ glColorTableParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_CopyColorTable(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+
+ glCopyColorTable(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLsizei *)(pc + 16)
+ );
+}
+
+void __glXDispSwap_CopyColorSubTable(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+
+ glCopyColorSubTable(
+ *(GLenum *)(pc + 0),
+ *(GLsizei *)(pc + 4),
+ *(GLint *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLsizei *)(pc + 16)
+ );
+}
+
+void __glXDispSwap_ConvolutionParameterf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+ glConvolutionParameterf(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_ConvolutionParameterfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glConvolutionParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, compsize);
+
+ glConvolutionParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_ConvolutionParameteri(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+ glConvolutionParameteri(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_ConvolutionParameteriv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glConvolutionParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 8, compsize);
+
+ glConvolutionParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_CopyConvolutionFilter1D(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+
+ glCopyConvolutionFilter1D(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLsizei *)(pc + 16)
+ );
+}
+
+void __glXDispSwap_CopyConvolutionFilter2D(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_INT(pc + 20);
+
+ glCopyConvolutionFilter2D(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLint *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLsizei *)(pc + 16),
+ *(GLsizei *)(pc + 20)
+ );
+}
+
+void __glXDispSwap_Histogram(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+ glHistogram(
+ *(GLenum *)(pc + 0),
+ *(GLsizei *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ *(GLboolean *)(pc + 12)
+ );
+}
+
+void __glXDispSwap_Minmax(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+ glMinmax(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLboolean *)(pc + 8)
+ );
+}
+
+void __glXDispSwap_ResetHistogram(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glResetHistogram(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_ResetMinmax(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glResetMinmax(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_CopyTexSubImage3D(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_INT(pc + 20);
+ __GLX_SWAP_INT(pc + 24);
+ __GLX_SWAP_INT(pc + 28);
+ __GLX_SWAP_INT(pc + 32);
+
+ glCopyTexSubImage3D(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLint *)(pc + 8),
+ *(GLint *)(pc + 12),
+ *(GLint *)(pc + 16),
+ *(GLint *)(pc + 20),
+ *(GLint *)(pc + 24),
+ *(GLsizei *)(pc + 28),
+ *(GLsizei *)(pc + 32)
+ );
+}
+
+void __glXDispSwap_ActiveTextureARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glActiveTextureARB(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_MultiTexCoord1dvARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 12);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 1);
+
+ glMultiTexCoord1dvARB(
+ *(GLenum *)(pc + 8),
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_MultiTexCoord1fvARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 4, 1);
+
+ glMultiTexCoord1fvARB(
+ *(GLenum *)(pc + 0),
+ (GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_MultiTexCoord1ivARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 4, 1);
+
+ glMultiTexCoord1ivARB(
+ *(GLenum *)(pc + 0),
+ (GLint *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_MultiTexCoord1svARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_SHORT_ARRAY(pc + 4, 1);
+
+ glMultiTexCoord1svARB(
+ *(GLenum *)(pc + 0),
+ (GLshort *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_MultiTexCoord2dvARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 20);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 2);
+
+ glMultiTexCoord2dvARB(
+ *(GLenum *)(pc + 16),
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_MultiTexCoord2fvARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 4, 2);
+
+ glMultiTexCoord2fvARB(
+ *(GLenum *)(pc + 0),
+ (GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_MultiTexCoord2ivARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 4, 2);
+
+ glMultiTexCoord2ivARB(
+ *(GLenum *)(pc + 0),
+ (GLint *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_MultiTexCoord2svARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_SHORT_ARRAY(pc + 4, 2);
+
+ glMultiTexCoord2svARB(
+ *(GLenum *)(pc + 0),
+ (GLshort *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_MultiTexCoord3dvARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 28);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 24);
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 3);
+
+ glMultiTexCoord3dvARB(
+ *(GLenum *)(pc + 24),
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_MultiTexCoord3fvARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 4, 3);
+
+ glMultiTexCoord3fvARB(
+ *(GLenum *)(pc + 0),
+ (GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_MultiTexCoord3ivARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 4, 3);
+
+ glMultiTexCoord3ivARB(
+ *(GLenum *)(pc + 0),
+ (GLint *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_MultiTexCoord3svARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_SHORT_ARRAY(pc + 4, 3);
+
+ glMultiTexCoord3svARB(
+ *(GLenum *)(pc + 0),
+ (GLshort *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_MultiTexCoord4dvARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 36);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 32);
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 4);
+
+ glMultiTexCoord4dvARB(
+ *(GLenum *)(pc + 32),
+ (GLdouble *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_MultiTexCoord4fvARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 4, 4);
+
+ glMultiTexCoord4fvARB(
+ *(GLenum *)(pc + 0),
+ (GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_MultiTexCoord4ivARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 4, 4);
+
+ glMultiTexCoord4ivARB(
+ *(GLenum *)(pc + 0),
+ (GLint *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_MultiTexCoord4svARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_SHORT_ARRAY(pc + 4, 4);
+
+ glMultiTexCoord4svARB(
+ *(GLenum *)(pc + 0),
+ (GLshort *)(pc + 4)
+ );
+}
+
+
+/*
+ * Extensions
+ */
+
+#ifndef MISSING_GL_EXTS
+
+void __glXDispSwap_PointParameterfARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ glPointParameterfARB(
+ *(GLenum *)(pc + 0),
+ *(GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_PointParameterfvARB(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glPointParameterfvEXT_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_FLOAT_ARRAY(pc + 4, compsize);
+
+ glPointParameterfvARB(
+ *(GLenum *)(pc + 0),
+ (GLfloat *)(pc + 4)
+ );
+}
+
+void __glXDispSwap_ActiveStencilFaceEXT(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+ glActiveStencilFaceEXT(
+ *(GLenum *)(pc + 0)
+ );
+}
+
+void __glXDispSwap_WindowPos3fARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+ glWindowPos3fARB(
+ *(GLfloat *)(pc + 0),
+ *(GLfloat *)(pc + 4),
+ *(GLfloat *)(pc + 8)
+ );
+}
+#endif /* !MISSING_GL_EXTS */
+
+void __glXDispSwap_SampleCoverageARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+ glSampleCoverageARB(
+ *(GLfloat *)(pc + 0),
+ *(GLboolean *)(pc + 4)
+ );
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/g_single.c b/nx-X11/programs/Xserver/GL/glx/g_single.c
new file mode 100644
index 000000000..a60bf44c1
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/g_single.c
@@ -0,0 +1,1787 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/g_single.c,v 1.5tsi Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxext.h"
+#include "g_disptab.h"
+#include "g_disptab_EXT.h"
+#include "unpack.h"
+#include "impsize.h"
+#include "singlesize.h"
+
+int __glXDisp_NewList(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+
+ glNewList(
+ *(GLuint *)(pc + 0),
+ *(GLenum *)(pc + 4)
+ );
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDisp_EndList(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ glEndList(
+ );
+ return Success;
+}
+
+int __glXDisp_DeleteLists(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+
+ glDeleteLists(
+ *(GLuint *)(pc + 0),
+ *(GLsizei *)(pc + 4)
+ );
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDisp_GenLists(__GLXclientState *cl, GLbyte *pc)
+{
+ GLuint retval;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+
+ retval =
+ glGenLists(
+ *(GLsizei *)(pc + 0)
+ );
+ __GLX_PUT_RETVAL(retval);
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ return Success;
+}
+
+int __glXDisp_PixelStoref(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+
+ glPixelStoref(
+ *(GLenum *)(pc + 0),
+ *(GLfloat *)(pc + 4)
+ );
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDisp_PixelStorei(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+
+ glPixelStorei(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4)
+ );
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDisp_GetBooleanv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLboolean answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glGetBooleanv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
+ __glXClearErrorOccured();
+ glGetBooleanv(
+ *(GLenum *)(pc + 0),
+ (GLboolean *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_BYTE();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_BYTE_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetDoublev(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLdouble answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glGetDoublev_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*8,8);
+ __glXClearErrorOccured();
+ glGetDoublev(
+ *(GLenum *)(pc + 0),
+ (GLdouble *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_DOUBLE();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*8);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_DOUBLE_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetError(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum retval;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ retval =
+ glGetError(
+ );
+ __GLX_PUT_RETVAL(retval);
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ return Success;
+}
+
+int __glXDisp_GetFloatv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glGetFloatv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetFloatv(
+ *(GLenum *)(pc + 0),
+ (GLfloat *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetIntegerv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glGetIntegerv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetIntegerv(
+ *(GLenum *)(pc + 0),
+ (GLint *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetLightfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetLightfv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetLightfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetLightiv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetLightiv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetLightiv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetMapdv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum target;
+ GLenum query;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLdouble answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ target = *(GLenum *)(pc + 0);
+ query = *(GLenum *)(pc + 4);
+ compsize = __glGetMapdv_size(target,query);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*8,8);
+ __glXClearErrorOccured();
+ glGetMapdv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLdouble *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_DOUBLE();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*8);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_DOUBLE_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetMapfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum target;
+ GLenum query;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ target = *(GLenum *)(pc + 0);
+ query = *(GLenum *)(pc + 4);
+ compsize = __glGetMapfv_size(target,query);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetMapfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetMapiv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum target;
+ GLenum query;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ target = *(GLenum *)(pc + 0);
+ query = *(GLenum *)(pc + 4);
+ compsize = __glGetMapiv_size(target,query);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetMapiv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetMaterialfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetMaterialfv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetMaterialfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetMaterialiv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetMaterialiv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetMaterialiv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetPixelMapfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum map;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ map = *(GLenum *)(pc + 0);
+ compsize = __glGetPixelMapfv_size(map);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetPixelMapfv(
+ *(GLenum *)(pc + 0),
+ (GLfloat *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetPixelMapuiv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum map;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLuint answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ map = *(GLenum *)(pc + 0);
+ compsize = __glGetPixelMapuiv_size(map);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetPixelMapuiv(
+ *(GLenum *)(pc + 0),
+ (GLuint *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetPixelMapusv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum map;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLushort answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ map = *(GLenum *)(pc + 0);
+ compsize = __glGetPixelMapusv_size(map);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*2,2);
+ __glXClearErrorOccured();
+ glGetPixelMapusv(
+ *(GLenum *)(pc + 0),
+ (GLushort *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_SHORT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*2);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_SHORT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetTexEnvfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetTexEnvfv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetTexEnvfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetTexEnviv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetTexEnviv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetTexEnviv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetTexGendv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLdouble answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetTexGendv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*8,8);
+ __glXClearErrorOccured();
+ glGetTexGendv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLdouble *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_DOUBLE();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*8);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_DOUBLE_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetTexGenfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetTexGenfv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetTexGenfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetTexGeniv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetTexGeniv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetTexGeniv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetTexParameterfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetTexParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetTexParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetTexParameteriv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetTexParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetTexParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetTexLevelParameterfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 8);
+ compsize = __glGetTexLevelParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetTexLevelParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ (GLfloat *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetTexLevelParameteriv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 8);
+ compsize = __glGetTexLevelParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetTexLevelParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ (GLint *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_IsEnabled(__GLXclientState *cl, GLbyte *pc)
+{
+ GLboolean retval;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+
+ retval =
+ glIsEnabled(
+ *(GLenum *)(pc + 0)
+ );
+ __GLX_PUT_RETVAL(retval);
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ return Success;
+}
+
+int __glXDisp_IsList(__GLXclientState *cl, GLbyte *pc)
+{
+ GLboolean retval;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+
+ retval =
+ glIsList(
+ *(GLuint *)(pc + 0)
+ );
+ __GLX_PUT_RETVAL(retval);
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ return Success;
+}
+
+int __glXDisp_AreTexturesResident(__GLXclientState *cl, GLbyte *pc)
+{
+ GLsizei n;
+ GLboolean retval;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLboolean answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ n = *(GLsizei *)(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,n,1);
+ retval =
+ glAreTexturesResident(
+ *(GLsizei *)(pc + 0),
+ (GLuint *)(pc + 4),
+ (GLboolean *) answer
+ );
+ __GLX_PUT_RETVAL(retval);
+ __GLX_BEGIN_REPLY(n);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_BYTE_ARRAY(n);
+ return Success;
+}
+
+int __glXDisp_DeleteTextures(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+
+ glDeleteTextures(
+ *(GLsizei *)(pc + 0),
+ (GLuint *)(pc + 4)
+ );
+ return Success;
+}
+
+int __glXDisp_GenTextures(__GLXclientState *cl, GLbyte *pc)
+{
+ GLsizei n;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLuint answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ n = *(GLsizei *)(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,n*4,4);
+ glGenTextures(
+ *(GLsizei *)(pc + 0),
+ (GLuint *) answer
+ );
+ __GLX_BEGIN_REPLY(n*4);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(n);
+ return Success;
+}
+
+int __glXDisp_IsTexture(__GLXclientState *cl, GLbyte *pc)
+{
+ GLboolean retval;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+
+ retval =
+ glIsTexture(
+ *(GLuint *)(pc + 0)
+ );
+ __GLX_PUT_RETVAL(retval);
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ return Success;
+}
+
+int __glXDisp_GetColorTableParameterfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetColorTableParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetColorTableParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetColorTableParameteriv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetColorTableParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetColorTableParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetConvolutionParameterfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetConvolutionParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetConvolutionParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetConvolutionParameteriv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetConvolutionParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetConvolutionParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetHistogramParameterfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetHistogramParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetHistogramParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetHistogramParameteriv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetHistogramParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetHistogramParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetMinmaxParameterfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetMinmaxParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetMinmaxParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetMinmaxParameteriv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetMinmaxParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetMinmaxParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_SIZE(1);
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_AreTexturesResidentEXT(__GLXclientState *cl, GLbyte *pc)
+{
+ GLsizei n;
+ GLboolean retval;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLboolean answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_VENDPRIV_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_VENDPRIV_HDR_SIZE;
+ n = *(GLsizei *)(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,n,1);
+ retval =
+ glAreTexturesResidentEXT(
+ *(GLsizei *)(pc + 0),
+ (GLuint *)(pc + 4),
+ (GLboolean *) answer
+ );
+ __GLX_PUT_RETVAL(retval);
+ __GLX_BEGIN_REPLY(n);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_BYTE_ARRAY(n);
+ return Success;
+}
+
+int __glXDisp_DeleteTexturesEXT(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_VENDPRIV_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_VENDPRIV_HDR_SIZE;
+
+ glDeleteTexturesEXT(
+ *(GLsizei *)(pc + 0),
+ (GLuint *)(pc + 4)
+ );
+ return Success;
+}
+
+int __glXDisp_GenTexturesEXT(__GLXclientState *cl, GLbyte *pc)
+{
+ GLsizei n;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLuint answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_VENDPRIV_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_VENDPRIV_HDR_SIZE;
+ n = *(GLsizei *)(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,n*4,4);
+ glGenTexturesEXT(
+ *(GLsizei *)(pc + 0),
+ (GLuint *) answer
+ );
+ __GLX_BEGIN_REPLY(n*4);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(n);
+ return Success;
+}
+
+int __glXDisp_IsTextureEXT(__GLXclientState *cl, GLbyte *pc)
+{
+ GLboolean retval;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_VENDPRIV_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_VENDPRIV_HDR_SIZE;
+
+ retval =
+ glIsTextureEXT(
+ *(GLuint *)(pc + 0)
+ );
+ __GLX_PUT_RETVAL(retval);
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ return Success;
+}
+
diff --git a/nx-X11/programs/Xserver/GL/glx/g_singleswap.c b/nx-X11/programs/Xserver/GL/glx/g_singleswap.c
new file mode 100644
index 000000000..026530374
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/g_singleswap.c
@@ -0,0 +1,2208 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/g_singleswap.c,v 1.4tsi Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxext.h"
+#include "g_disptab.h"
+#include "g_disptab_EXT.h"
+#include "unpack.h"
+#include "impsize.h"
+#include "singlesize.h"
+
+int __glXDispSwap_NewList(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+ glNewList(
+ *(GLuint *)(pc + 0),
+ *(GLenum *)(pc + 4)
+ );
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDispSwap_EndList(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ glEndList(
+ );
+ return Success;
+}
+
+int __glXDispSwap_DeleteLists(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+ glDeleteLists(
+ *(GLuint *)(pc + 0),
+ *(GLsizei *)(pc + 4)
+ );
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDispSwap_GenLists(__GLXclientState *cl, GLbyte *pc)
+{
+ GLuint retval;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+
+ retval =
+ glGenLists(
+ *(GLsizei *)(pc + 0)
+ );
+ __GLX_PUT_RETVAL(retval);
+ __GLX_SWAP_REPLY_RETVAL();
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ return Success;
+}
+
+int __glXDispSwap_PixelStoref(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+
+ glPixelStoref(
+ *(GLenum *)(pc + 0),
+ *(GLfloat *)(pc + 4)
+ );
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDispSwap_PixelStorei(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+ glPixelStorei(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4)
+ );
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDispSwap_GetBooleanv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLboolean answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glGetBooleanv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
+ __glXClearErrorOccured();
+ glGetBooleanv(
+ *(GLenum *)(pc + 0),
+ (GLboolean *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_BYTE();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_BYTE_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetDoublev(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLdouble answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glGetDoublev_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*8,8);
+ __glXClearErrorOccured();
+ glGetDoublev(
+ *(GLenum *)(pc + 0),
+ (GLdouble *) answer
+ );
+ __GLX_SWAP_DOUBLE_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_DOUBLE();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*8);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_DOUBLE_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetError(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum retval;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ retval =
+ glGetError(
+ );
+ __GLX_PUT_RETVAL(retval);
+ __GLX_SWAP_REPLY_RETVAL();
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ return Success;
+}
+
+int __glXDispSwap_GetFloatv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glGetFloatv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetFloatv(
+ *(GLenum *)(pc + 0),
+ (GLfloat *) answer
+ );
+ __GLX_SWAP_FLOAT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetIntegerv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glGetIntegerv_size(pname);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetIntegerv(
+ *(GLenum *)(pc + 0),
+ (GLint *) answer
+ );
+ __GLX_SWAP_INT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetLightfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetLightfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetLightfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ __GLX_SWAP_FLOAT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetLightiv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetLightiv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetLightiv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ __GLX_SWAP_INT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetMapdv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum target;
+ GLenum query;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLdouble answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ target = *(GLenum *)(pc + 0);
+ query = *(GLenum *)(pc + 4);
+ compsize = __glGetMapdv_size(target,query);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*8,8);
+ __glXClearErrorOccured();
+ glGetMapdv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLdouble *) answer
+ );
+ __GLX_SWAP_DOUBLE_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_DOUBLE();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*8);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_DOUBLE_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetMapfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum target;
+ GLenum query;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ target = *(GLenum *)(pc + 0);
+ query = *(GLenum *)(pc + 4);
+ compsize = __glGetMapfv_size(target,query);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetMapfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ __GLX_SWAP_FLOAT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetMapiv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum target;
+ GLenum query;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ target = *(GLenum *)(pc + 0);
+ query = *(GLenum *)(pc + 4);
+ compsize = __glGetMapiv_size(target,query);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetMapiv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ __GLX_SWAP_INT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetMaterialfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetMaterialfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetMaterialfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ __GLX_SWAP_FLOAT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetMaterialiv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetMaterialiv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetMaterialiv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ __GLX_SWAP_INT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetPixelMapfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum map;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ map = *(GLenum *)(pc + 0);
+ compsize = __glGetPixelMapfv_size(map);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetPixelMapfv(
+ *(GLenum *)(pc + 0),
+ (GLfloat *) answer
+ );
+ __GLX_SWAP_FLOAT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetPixelMapuiv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum map;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLuint answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ map = *(GLenum *)(pc + 0);
+ compsize = __glGetPixelMapuiv_size(map);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetPixelMapuiv(
+ *(GLenum *)(pc + 0),
+ (GLuint *) answer
+ );
+ __GLX_SWAP_INT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetPixelMapusv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum map;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLushort answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ map = *(GLenum *)(pc + 0);
+ compsize = __glGetPixelMapusv_size(map);
+ if (compsize < 0) compsize = 0;
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*2,2);
+ __glXClearErrorOccured();
+ glGetPixelMapusv(
+ *(GLenum *)(pc + 0),
+ (GLushort *) answer
+ );
+ __GLX_SWAP_SHORT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_SHORT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*2);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_SHORT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetTexEnvfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetTexEnvfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetTexEnvfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ __GLX_SWAP_FLOAT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetTexEnviv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetTexEnviv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetTexEnviv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ __GLX_SWAP_INT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetTexGendv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLdouble answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetTexGendv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*8,8);
+ __glXClearErrorOccured();
+ glGetTexGendv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLdouble *) answer
+ );
+ __GLX_SWAP_DOUBLE_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_DOUBLE();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*8);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_DOUBLE_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetTexGenfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetTexGenfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetTexGenfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ __GLX_SWAP_FLOAT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetTexGeniv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetTexGeniv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetTexGeniv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ __GLX_SWAP_INT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetTexParameterfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetTexParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetTexParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ __GLX_SWAP_FLOAT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetTexParameteriv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetTexParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetTexParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ __GLX_SWAP_INT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetTexLevelParameterfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 8);
+ pname = *(GLenum *)(pc + 8);
+ compsize = __glGetTexLevelParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetTexLevelParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ (GLfloat *) answer
+ );
+ __GLX_SWAP_FLOAT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetTexLevelParameteriv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 8);
+ pname = *(GLenum *)(pc + 8);
+ compsize = __glGetTexLevelParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetTexLevelParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ (GLint *) answer
+ );
+ __GLX_SWAP_INT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_IsEnabled(__GLXclientState *cl, GLbyte *pc)
+{
+ GLboolean retval;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+
+ retval =
+ glIsEnabled(
+ *(GLenum *)(pc + 0)
+ );
+ __GLX_PUT_RETVAL(retval);
+ __GLX_SWAP_REPLY_RETVAL();
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ return Success;
+}
+
+int __glXDispSwap_IsList(__GLXclientState *cl, GLbyte *pc)
+{
+ GLboolean retval;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+
+ retval =
+ glIsList(
+ *(GLuint *)(pc + 0)
+ );
+ __GLX_PUT_RETVAL(retval);
+ __GLX_SWAP_REPLY_RETVAL();
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ return Success;
+}
+
+int __glXDispSwap_AreTexturesResident(__GLXclientState *cl, GLbyte *pc)
+{
+ GLsizei n;
+ GLboolean retval;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLboolean answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ n = *(GLsizei *)(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 4, n);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,n,1);
+ retval =
+ glAreTexturesResident(
+ *(GLsizei *)(pc + 0),
+ (GLuint *)(pc + 4),
+ (GLboolean *) answer
+ );
+ __GLX_PUT_RETVAL(retval);
+ __GLX_SWAP_REPLY_RETVAL();
+ __GLX_BEGIN_REPLY(n);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_BYTE_ARRAY(n);
+ return Success;
+}
+
+int __glXDispSwap_DeleteTextures(__GLXclientState *cl, GLbyte *pc)
+{
+ GLsizei n;
+ __GLXcontext *cx;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ n = *(GLsizei *)(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 4, n);
+
+ glDeleteTextures(
+ *(GLsizei *)(pc + 0),
+ (GLuint *)(pc + 4)
+ );
+ return Success;
+}
+
+int __glXDispSwap_GenTextures(__GLXclientState *cl, GLbyte *pc)
+{
+ GLsizei n;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLuint answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ n = *(GLsizei *)(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,n*4,4);
+ glGenTextures(
+ *(GLsizei *)(pc + 0),
+ (GLuint *) answer
+ );
+ __GLX_SWAP_INT_ARRAY(answer, n);
+ __GLX_BEGIN_REPLY(n*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(n);
+ return Success;
+}
+
+int __glXDispSwap_IsTexture(__GLXclientState *cl, GLbyte *pc)
+{
+ GLboolean retval;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+
+ retval =
+ glIsTexture(
+ *(GLuint *)(pc + 0)
+ );
+ __GLX_PUT_RETVAL(retval);
+ __GLX_SWAP_REPLY_RETVAL();
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ return Success;
+}
+
+int __glXDispSwap_GetColorTableParameterfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetColorTableParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetColorTableParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ __GLX_SWAP_FLOAT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetColorTableParameteriv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetColorTableParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetColorTableParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ __GLX_SWAP_INT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetConvolutionParameterfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetConvolutionParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetConvolutionParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ __GLX_SWAP_FLOAT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetConvolutionParameteriv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetConvolutionParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetConvolutionParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ __GLX_SWAP_INT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetHistogramParameterfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetHistogramParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetHistogramParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ __GLX_SWAP_FLOAT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetHistogramParameteriv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetHistogramParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetHistogramParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ __GLX_SWAP_INT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetMinmaxParameterfv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLfloat answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetMinmaxParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetMinmaxParameterfv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLfloat *) answer
+ );
+ __GLX_SWAP_FLOAT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_FLOAT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_FLOAT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetMinmaxParameteriv(__GLXclientState *cl, GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLint answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glGetMinmaxParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
+ __glXClearErrorOccured();
+ glGetMinmaxParameteriv(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ (GLint *) answer
+ );
+ __GLX_SWAP_INT_ARRAY(answer, compsize);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(0);
+ __GLX_SEND_HEADER();
+ } else if (compsize == 1) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(1);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_PUT_INT();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_PUT_SIZE(compsize);
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_AreTexturesResidentEXT(__GLXclientState *cl, GLbyte *pc)
+{
+ GLsizei n;
+ GLboolean retval;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLboolean answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXVendorPrivateReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_VENDPRIV_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_VENDPRIV_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ n = *(GLsizei *)(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 4, n);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,n,1);
+ retval =
+ glAreTexturesResidentEXT(
+ *(GLsizei *)(pc + 0),
+ (GLuint *)(pc + 4),
+ (GLboolean *) answer
+ );
+ __GLX_PUT_RETVAL(retval);
+ __GLX_SWAP_REPLY_RETVAL();
+ __GLX_BEGIN_REPLY(n);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_BYTE_ARRAY(n);
+ return Success;
+}
+
+int __glXDispSwap_DeleteTexturesEXT(__GLXclientState *cl, GLbyte *pc)
+{
+ GLsizei n;
+ __GLXcontext *cx;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXVendorPrivateReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_VENDPRIV_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_VENDPRIV_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ n = *(GLsizei *)(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 4, n);
+
+ glDeleteTexturesEXT(
+ *(GLsizei *)(pc + 0),
+ (GLuint *)(pc + 4)
+ );
+ return Success;
+}
+
+int __glXDispSwap_GenTexturesEXT(__GLXclientState *cl, GLbyte *pc)
+{
+ GLsizei n;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLuint answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXVendorPrivateReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_VENDPRIV_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_VENDPRIV_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+ n = *(GLsizei *)(pc + 0);
+
+ __GLX_GET_ANSWER_BUFFER(answer,cl,n*4,4);
+ glGenTexturesEXT(
+ *(GLsizei *)(pc + 0),
+ (GLuint *) answer
+ );
+ __GLX_SWAP_INT_ARRAY(answer, n);
+ __GLX_BEGIN_REPLY(n*4);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_INT_ARRAY(n);
+ return Success;
+}
+
+int __glXDispSwap_IsTextureEXT(__GLXclientState *cl, GLbyte *pc)
+{
+ GLboolean retval;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXVendorPrivateReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_VENDPRIV_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_VENDPRIV_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+
+ retval =
+ glIsTextureEXT(
+ *(GLuint *)(pc + 0)
+ );
+ __GLX_PUT_RETVAL(retval);
+ __GLX_SWAP_REPLY_RETVAL();
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ return Success;
+}
+
diff --git a/nx-X11/programs/Xserver/GL/glx/global.c b/nx-X11/programs/Xserver/GL/glx/global.c
new file mode 100644
index 000000000..18cd5edc2
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/global.c
@@ -0,0 +1,76 @@
+/* $XFree86$ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+
+/*
+** The last context used by the server. It is the context that is current
+** from the server's perspective.
+*/
+__GLXcontext *__glXLastContext;
+
+/*
+** X resources.
+*/
+RESTYPE __glXContextRes;
+RESTYPE __glXClientRes;
+RESTYPE __glXPixmapRes;
+RESTYPE __glXSwapBarrierRes;
+
+/*
+** Error codes with the extension error base already added in.
+*/
+int __glXBadContext, __glXBadContextState, __glXBadDrawable, __glXBadPixmap;
+int __glXBadContextTag, __glXBadCurrentWindow;
+int __glXBadRenderRequest, __glXBadLargeRequest;
+int __glXUnsupportedPrivateRequest;
+
+/*
+** Reply for most singles.
+*/
+xGLXSingleReply __glXReply;
+
+/*
+** A set of state for each client. The 0th one is unused because client
+** indices start at 1, not 0.
+*/
+__GLXclientState *__glXClients[MAXCLIENTS+1];
+
diff --git a/nx-X11/programs/Xserver/GL/glx/glx-def.cpp b/nx-X11/programs/Xserver/GL/glx/glx-def.cpp
new file mode 100644
index 000000000..a653f4cb7
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glx-def.cpp
@@ -0,0 +1,662 @@
+LIBRARY GLX
+VERSION LIBRARY_VERSION
+EXPORTS
+__glXFBInitDrawable
+__glXFreeBuffers
+__glXPixInitDrawable
+__glXResizeBuffers
+__glXClientInfo
+__glXCopyContext
+__glXCreateContext
+__glXCreateGLXPixmap
+__glXDestroyContext
+__glXDestroyGLXPixmap
+__glXGetVisualConfigs
+__glXIsDirect
+__glXLookupContextByTag
+__glXMakeCurrent
+__glXQueryContextInfoEXT
+__glXQueryExtensionsString
+__glXQueryServerString
+__glXQueryVersion
+__glXRender
+__glXRenderLarge
+__glXSwapBuffers
+__glXVendorPrivate
+__glXVendorPrivateWithReply
+__glXWaitGL
+__glXWaitX
+__glXSwapClientInfo
+__glXSwapCopyContext
+__glXSwapCreateContext
+__glXSwapCreateGLXPixmap
+__glXSwapDestroyContext
+__glXSwapDestroyGLXPixmap
+__glXSwapGetVisualConfigs
+__glXSwapIsDirect
+__glXSwapIsDirectReply
+__glXSwapMakeCurrent
+__glXSwapMakeCurrentReply
+__glXSwapQueryContextInfoEXT
+__glXSwapQueryContextInfoEXTReply
+__glXSwapQueryExtensionsString
+__glXSwapQueryServerString
+__glXSwapQueryVersion
+__glXSwapQueryVersionReply
+__glXSwapRender
+__glXSwapRenderLarge
+__glXSwapSwapBuffers
+__glXSwapUseXFont
+__glXSwapVendorPrivate
+__glXSwapVendorPrivateWithReply
+__glXSwapWaitGL
+__glXSwapWaitX
+glxSwapQueryExtensionsStringReply
+glxSwapQueryServerStringReply
+GlxExtensionInit
+GlxInitVisuals
+GlxSetVisualConfigs
+GlxWrapInitVisuals
+__glXClearErrorOccured
+__glXCoreType
+__glXErrorCallBack
+__glXErrorOccured
+__glXFlushContextCache
+__glXForceCurrent
+__glXFreeContext
+__glXNoSuchRenderOpcode
+__glXNoSuchSingleOpcode
+__glXResetLargeCommandStatus
+__glXFBGetGC
+__glXFBMemSwapBuffers
+__glXInitFB
+__glXImpCalloc
+__glXImpFatal
+__glXImpFclose
+__glXImpFopen
+__glXImpFprintf
+__glXImpFree
+__glXImpGetDrawablePrivate
+__glXImpGetenv
+__glXImpMalloc
+__glXImpRealloc
+__glXImpSprintf
+__glXImpWarning
+__glXInitMem
+__glXInitPix
+__glXScreenInit
+__glXAssociateContext
+__glXCacheDrawableSize
+__glXCalloc
+__glXCreateDrawablePrivate
+__glXDeassociateContext
+__glXDestroyDrawablePrivate
+__glXFindDrawablePrivate
+__glXFree
+__glXGetDrawablePrivate
+__glXGetDrawableSize
+__glXMalloc
+__glXNop
+__glXRealloc
+__glXRefDrawablePrivate
+__glXResizeDrawable
+__glXResizeDrawableBuffers
+__glXUnrefDrawablePrivate
+__glXDisp_CallLists
+__glXDisp_DrawArrays
+__glXDisp_Map1d
+__glXDisp_Map1f
+__glXDisp_Map2d
+__glXDisp_Map2f
+__glXDispSwap_CallLists
+__glXDispSwap_DrawArrays
+__glXDispSwap_Map1d
+__glXDispSwap_Map1f
+__glXDispSwap_Map2d
+__glXDispSwap_Map2f
+__glXDisp_Bitmap
+__glXDisp_DrawPixels
+__glXDisp_PolygonStipple
+__glXDisp_TexImage1D
+__glXDisp_TexImage2D
+__glXDisp_TexSubImage1D
+__glXDisp_TexSubImage2D
+__glXDispSwap_Bitmap
+__glXDispSwap_DrawPixels
+__glXDispSwap_PolygonStipple
+__glXDispSwap_TexImage1D
+__glXDispSwap_TexImage2D
+__glXDispSwap_TexSubImage1D
+__glXDispSwap_TexSubImage2D
+__glXBitmapReqSize
+__glXCallListsReqSize
+__glXDrawArraysSize
+__glXDrawPixelsReqSize
+__glXFogfvReqSize
+__glXFogivReqSize
+__glXLightModelfvReqSize
+__glXLightModelivReqSize
+__glXLightfvReqSize
+__glXLightivReqSize
+__glXMap1dReqSize
+__glXMap1fReqSize
+__glXMap2dReqSize
+__glXMap2fReqSize
+__glXMaterialfvReqSize
+__glXMaterialivReqSize
+__glXPixelMapfvReqSize
+__glXPixelMapuivReqSize
+__glXPixelMapusvReqSize
+__glXPrioritizeTexturesReqSize
+__glXTexEnvfvReqSize
+__glXTexEnvivReqSize
+__glXTexGendvReqSize
+__glXTexGenfvReqSize
+__glXTexGenivReqSize
+__glXTexImage1DReqSize
+__glXTexImage2DReqSize
+__glXTexParameterfvReqSize
+__glXTexParameterivReqSize
+__glXTexSubImage1DReqSize
+__glXTexSubImage2DReqSize
+__glXTypeSize
+__glXDisp_FeedbackBuffer
+__glXDisp_Finish
+__glXDisp_Flush
+__glXDisp_GetClipPlane
+__glXDisp_GetString
+__glXDisp_RenderMode
+__glXDisp_SelectBuffer
+__glXcombine_strings
+__glXDispSwap_FeedbackBuffer
+__glXDispSwap_Finish
+__glXDispSwap_Flush
+__glXDispSwap_GetClipPlane
+__glXDispSwap_GetString
+__glXDispSwap_RenderMode
+__glXDispSwap_SelectBuffer
+__glXDisp_GetPolygonStipple
+__glXDisp_GetTexImage
+__glXDisp_ReadPixels
+__glXDispSwap_GetPolygonStipple
+__glXDispSwap_GetTexImage
+__glXDispSwap_ReadPixels
+__glGetBooleanv_size
+__glGetDoublev_size
+__glGetFloatv_size
+__glGetIntegerv_size
+__glGetLightfv_size
+__glGetLightiv_size
+__glGetMap_size
+__glGetMapdv_size
+__glGetMapfv_size
+__glGetMapiv_size
+__glGetMaterialfv_size
+__glGetMaterialiv_size
+__glGetPixelMap_size
+__glGetPixelMapfv_size
+__glGetPixelMapuiv_size
+__glGetPixelMapusv_size
+__glGetTexEnvfv_size
+__glGetTexEnviv_size
+__glGetTexGendv_size
+__glGetTexGenfv_size
+__glGetTexGeniv_size
+__glGetTexImage_size
+__glGetTexLevelParameterfv_size
+__glGetTexLevelParameteriv_size
+__glGetTexParameterfv_size
+__glGetTexParameteriv_size
+__glGet_size
+__glReadPixels_size
+__glXUseXFont
+__glXDisp_Accum
+__glXDisp_AlphaFunc
+__glXDisp_Begin
+__glXDisp_BindTexture
+__glXDisp_BlendFunc
+__glXDisp_CallList
+__glXDisp_Clear
+__glXDisp_ClearAccum
+__glXDisp_ClearColor
+__glXDisp_ClearDepth
+__glXDisp_ClearIndex
+__glXDisp_ClearStencil
+__glXDisp_ClipPlane
+__glXDisp_Color3bv
+__glXDisp_Color3dv
+__glXDisp_Color3fv
+__glXDisp_Color3iv
+__glXDisp_Color3sv
+__glXDisp_Color3ubv
+__glXDisp_Color3uiv
+__glXDisp_Color3usv
+__glXDisp_Color4bv
+__glXDisp_Color4dv
+__glXDisp_Color4fv
+__glXDisp_Color4iv
+__glXDisp_Color4sv
+__glXDisp_Color4ubv
+__glXDisp_Color4uiv
+__glXDisp_Color4usv
+__glXDisp_ColorMask
+__glXDisp_ColorMaterial
+__glXDisp_CopyPixels
+__glXDisp_CopyTexImage1D
+__glXDisp_CopyTexImage2D
+__glXDisp_CopyTexSubImage1D
+__glXDisp_CopyTexSubImage2D
+__glXDisp_CullFace
+__glXDisp_DepthFunc
+__glXDisp_DepthMask
+__glXDisp_DepthRange
+__glXDisp_Disable
+__glXDisp_DrawBuffer
+__glXDisp_EdgeFlagv
+__glXDisp_Enable
+__glXDisp_End
+__glXDisp_EvalCoord1dv
+__glXDisp_EvalCoord1fv
+__glXDisp_EvalCoord2dv
+__glXDisp_EvalCoord2fv
+__glXDisp_EvalMesh1
+__glXDisp_EvalMesh2
+__glXDisp_EvalPoint1
+__glXDisp_EvalPoint2
+__glXDisp_Fogf
+__glXDisp_Fogfv
+__glXDisp_Fogi
+__glXDisp_Fogiv
+__glXDisp_FrontFace
+__glXDisp_Frustum
+__glXDisp_Hint
+__glXDisp_IndexMask
+__glXDisp_Indexdv
+__glXDisp_Indexfv
+__glXDisp_Indexiv
+__glXDisp_Indexsv
+__glXDisp_Indexubv
+__glXDisp_InitNames
+__glXDisp_LightModelf
+__glXDisp_LightModelfv
+__glXDisp_LightModeli
+__glXDisp_LightModeliv
+__glXDisp_Lightf
+__glXDisp_Lightfv
+__glXDisp_Lighti
+__glXDisp_Lightiv
+__glXDisp_LineStipple
+__glXDisp_LineWidth
+__glXDisp_ListBase
+__glXDisp_LoadIdentity
+__glXDisp_LoadMatrixd
+__glXDisp_LoadMatrixf
+__glXDisp_LoadName
+__glXDisp_LogicOp
+__glXDisp_MapGrid1d
+__glXDisp_MapGrid1f
+__glXDisp_MapGrid2d
+__glXDisp_MapGrid2f
+__glXDisp_Materialf
+__glXDisp_Materialfv
+__glXDisp_Materiali
+__glXDisp_Materialiv
+__glXDisp_MatrixMode
+__glXDisp_MultMatrixd
+__glXDisp_MultMatrixf
+__glXDisp_Normal3bv
+__glXDisp_Normal3dv
+__glXDisp_Normal3fv
+__glXDisp_Normal3iv
+__glXDisp_Normal3sv
+__glXDisp_Ortho
+__glXDisp_PassThrough
+__glXDisp_PixelMapfv
+__glXDisp_PixelMapuiv
+__glXDisp_PixelMapusv
+__glXDisp_PixelTransferf
+__glXDisp_PixelTransferi
+__glXDisp_PixelZoom
+__glXDisp_PointSize
+__glXDisp_PolygonMode
+__glXDisp_PolygonOffset
+__glXDisp_PopAttrib
+__glXDisp_PopMatrix
+__glXDisp_PopName
+__glXDisp_PrioritizeTextures
+__glXDisp_PushAttrib
+__glXDisp_PushMatrix
+__glXDisp_PushName
+__glXDisp_RasterPos2dv
+__glXDisp_RasterPos2fv
+__glXDisp_RasterPos2iv
+__glXDisp_RasterPos2sv
+__glXDisp_RasterPos3dv
+__glXDisp_RasterPos3fv
+__glXDisp_RasterPos3iv
+__glXDisp_RasterPos3sv
+__glXDisp_RasterPos4dv
+__glXDisp_RasterPos4fv
+__glXDisp_RasterPos4iv
+__glXDisp_RasterPos4sv
+__glXDisp_ReadBuffer
+__glXDisp_Rectdv
+__glXDisp_Rectfv
+__glXDisp_Rectiv
+__glXDisp_Rectsv
+__glXDisp_Rotated
+__glXDisp_Rotatef
+__glXDisp_Scaled
+__glXDisp_Scalef
+__glXDisp_Scissor
+__glXDisp_ShadeModel
+__glXDisp_StencilFunc
+__glXDisp_StencilMask
+__glXDisp_StencilOp
+__glXDisp_TexCoord1dv
+__glXDisp_TexCoord1fv
+__glXDisp_TexCoord1iv
+__glXDisp_TexCoord1sv
+__glXDisp_TexCoord2dv
+__glXDisp_TexCoord2fv
+__glXDisp_TexCoord2iv
+__glXDisp_TexCoord2sv
+__glXDisp_TexCoord3dv
+__glXDisp_TexCoord3fv
+__glXDisp_TexCoord3iv
+__glXDisp_TexCoord3sv
+__glXDisp_TexCoord4dv
+__glXDisp_TexCoord4fv
+__glXDisp_TexCoord4iv
+__glXDisp_TexCoord4sv
+__glXDisp_TexEnvf
+__glXDisp_TexEnvfv
+__glXDisp_TexEnvi
+__glXDisp_TexEnviv
+__glXDisp_TexGend
+__glXDisp_TexGendv
+__glXDisp_TexGenf
+__glXDisp_TexGenfv
+__glXDisp_TexGeni
+__glXDisp_TexGeniv
+__glXDisp_TexParameterf
+__glXDisp_TexParameterfv
+__glXDisp_TexParameteri
+__glXDisp_TexParameteriv
+__glXDisp_Translated
+__glXDisp_Translatef
+__glXDisp_Vertex2dv
+__glXDisp_Vertex2fv
+__glXDisp_Vertex2iv
+__glXDisp_Vertex2sv
+__glXDisp_Vertex3dv
+__glXDisp_Vertex3fv
+__glXDisp_Vertex3iv
+__glXDisp_Vertex3sv
+__glXDisp_Vertex4dv
+__glXDisp_Vertex4fv
+__glXDisp_Vertex4iv
+__glXDisp_Vertex4sv
+__glXDisp_Viewport
+__glXDispSwap_Accum
+__glXDispSwap_AlphaFunc
+__glXDispSwap_Begin
+__glXDispSwap_BindTexture
+__glXDispSwap_BlendFunc
+__glXDispSwap_CallList
+__glXDispSwap_Clear
+__glXDispSwap_ClearAccum
+__glXDispSwap_ClearColor
+__glXDispSwap_ClearDepth
+__glXDispSwap_ClearIndex
+__glXDispSwap_ClearStencil
+__glXDispSwap_ClipPlane
+__glXDispSwap_Color3bv
+__glXDispSwap_Color3dv
+__glXDispSwap_Color3fv
+__glXDispSwap_Color3iv
+__glXDispSwap_Color3sv
+__glXDispSwap_Color3ubv
+__glXDispSwap_Color3uiv
+__glXDispSwap_Color3usv
+__glXDispSwap_Color4bv
+__glXDispSwap_Color4dv
+__glXDispSwap_Color4fv
+__glXDispSwap_Color4iv
+__glXDispSwap_Color4sv
+__glXDispSwap_Color4ubv
+__glXDispSwap_Color4uiv
+__glXDispSwap_Color4usv
+__glXDispSwap_ColorMask
+__glXDispSwap_ColorMaterial
+__glXDispSwap_CopyPixels
+__glXDispSwap_CopyTexImage1D
+__glXDispSwap_CopyTexImage2D
+__glXDispSwap_CopyTexSubImage1D
+__glXDispSwap_CopyTexSubImage2D
+__glXDispSwap_CullFace
+__glXDispSwap_DepthFunc
+__glXDispSwap_DepthMask
+__glXDispSwap_DepthRange
+__glXDispSwap_Disable
+__glXDispSwap_DrawBuffer
+__glXDispSwap_EdgeFlagv
+__glXDispSwap_Enable
+__glXDispSwap_End
+__glXDispSwap_EvalCoord1dv
+__glXDispSwap_EvalCoord1fv
+__glXDispSwap_EvalCoord2dv
+__glXDispSwap_EvalCoord2fv
+__glXDispSwap_EvalMesh1
+__glXDispSwap_EvalMesh2
+__glXDispSwap_EvalPoint1
+__glXDispSwap_EvalPoint2
+__glXDispSwap_Fogf
+__glXDispSwap_Fogfv
+__glXDispSwap_Fogi
+__glXDispSwap_Fogiv
+__glXDispSwap_FrontFace
+__glXDispSwap_Frustum
+__glXDispSwap_Hint
+__glXDispSwap_IndexMask
+__glXDispSwap_Indexdv
+__glXDispSwap_Indexfv
+__glXDispSwap_Indexiv
+__glXDispSwap_Indexsv
+__glXDispSwap_Indexubv
+__glXDispSwap_InitNames
+__glXDispSwap_LightModelf
+__glXDispSwap_LightModelfv
+__glXDispSwap_LightModeli
+__glXDispSwap_LightModeliv
+__glXDispSwap_Lightf
+__glXDispSwap_Lightfv
+__glXDispSwap_Lighti
+__glXDispSwap_Lightiv
+__glXDispSwap_LineStipple
+__glXDispSwap_LineWidth
+__glXDispSwap_ListBase
+__glXDispSwap_LoadIdentity
+__glXDispSwap_LoadMatrixd
+__glXDispSwap_LoadMatrixf
+__glXDispSwap_LoadName
+__glXDispSwap_LogicOp
+__glXDispSwap_MapGrid1d
+__glXDispSwap_MapGrid1f
+__glXDispSwap_MapGrid2d
+__glXDispSwap_MapGrid2f
+__glXDispSwap_Materialf
+__glXDispSwap_Materialfv
+__glXDispSwap_Materiali
+__glXDispSwap_Materialiv
+__glXDispSwap_MatrixMode
+__glXDispSwap_MultMatrixd
+__glXDispSwap_MultMatrixf
+__glXDispSwap_Normal3bv
+__glXDispSwap_Normal3dv
+__glXDispSwap_Normal3fv
+__glXDispSwap_Normal3iv
+__glXDispSwap_Normal3sv
+__glXDispSwap_Ortho
+__glXDispSwap_PassThrough
+__glXDispSwap_PixelMapfv
+__glXDispSwap_PixelMapuiv
+__glXDispSwap_PixelMapusv
+__glXDispSwap_PixelTransferf
+__glXDispSwap_PixelTransferi
+__glXDispSwap_PixelZoom
+__glXDispSwap_PointSize
+__glXDispSwap_PolygonMode
+__glXDispSwap_PolygonOffset
+__glXDispSwap_PopAttrib
+__glXDispSwap_PopMatrix
+__glXDispSwap_PopName
+__glXDispSwap_PrioritizeTextures
+__glXDispSwap_PushAttrib
+__glXDispSwap_PushMatrix
+__glXDispSwap_PushName
+__glXDispSwap_RasterPos2dv
+__glXDispSwap_RasterPos2fv
+__glXDispSwap_RasterPos2iv
+__glXDispSwap_RasterPos2sv
+__glXDispSwap_RasterPos3dv
+__glXDispSwap_RasterPos3fv
+__glXDispSwap_RasterPos3iv
+__glXDispSwap_RasterPos3sv
+__glXDispSwap_RasterPos4dv
+__glXDispSwap_RasterPos4fv
+__glXDispSwap_RasterPos4iv
+__glXDispSwap_RasterPos4sv
+__glXDispSwap_ReadBuffer
+__glXDispSwap_Rectdv
+__glXDispSwap_Rectfv
+__glXDispSwap_Rectiv
+__glXDispSwap_Rectsv
+__glXDispSwap_Rotated
+__glXDispSwap_Rotatef
+__glXDispSwap_Scaled
+__glXDispSwap_Scalef
+__glXDispSwap_Scissor
+__glXDispSwap_ShadeModel
+__glXDispSwap_StencilFunc
+__glXDispSwap_StencilMask
+__glXDispSwap_StencilOp
+__glXDispSwap_TexCoord1dv
+__glXDispSwap_TexCoord1fv
+__glXDispSwap_TexCoord1iv
+__glXDispSwap_TexCoord1sv
+__glXDispSwap_TexCoord2dv
+__glXDispSwap_TexCoord2fv
+__glXDispSwap_TexCoord2iv
+__glXDispSwap_TexCoord2sv
+__glXDispSwap_TexCoord3dv
+__glXDispSwap_TexCoord3fv
+__glXDispSwap_TexCoord3iv
+__glXDispSwap_TexCoord3sv
+__glXDispSwap_TexCoord4dv
+__glXDispSwap_TexCoord4fv
+__glXDispSwap_TexCoord4iv
+__glXDispSwap_TexCoord4sv
+__glXDispSwap_TexEnvf
+__glXDispSwap_TexEnvfv
+__glXDispSwap_TexEnvi
+__glXDispSwap_TexEnviv
+__glXDispSwap_TexGend
+__glXDispSwap_TexGendv
+__glXDispSwap_TexGenf
+__glXDispSwap_TexGenfv
+__glXDispSwap_TexGeni
+__glXDispSwap_TexGeniv
+__glXDispSwap_TexParameterf
+__glXDispSwap_TexParameterfv
+__glXDispSwap_TexParameteri
+__glXDispSwap_TexParameteriv
+__glXDispSwap_Translated
+__glXDispSwap_Translatef
+__glXDispSwap_Vertex2dv
+__glXDispSwap_Vertex2fv
+__glXDispSwap_Vertex2iv
+__glXDispSwap_Vertex2sv
+__glXDispSwap_Vertex3dv
+__glXDispSwap_Vertex3fv
+__glXDispSwap_Vertex3iv
+__glXDispSwap_Vertex3sv
+__glXDispSwap_Vertex4dv
+__glXDispSwap_Vertex4fv
+__glXDispSwap_Vertex4iv
+__glXDispSwap_Vertex4sv
+__glXDispSwap_Viewport
+__glXDisp_AreTexturesResident
+__glXDisp_DeleteLists
+__glXDisp_DeleteTextures
+__glXDisp_EndList
+__glXDisp_GenLists
+__glXDisp_GenTextures
+__glXDisp_GetBooleanv
+__glXDisp_GetDoublev
+__glXDisp_GetError
+__glXDisp_GetFloatv
+__glXDisp_GetIntegerv
+__glXDisp_GetLightfv
+__glXDisp_GetLightiv
+__glXDisp_GetMapdv
+__glXDisp_GetMapfv
+__glXDisp_GetMapiv
+__glXDisp_GetMaterialfv
+__glXDisp_GetMaterialiv
+__glXDisp_GetPixelMapfv
+__glXDisp_GetPixelMapuiv
+__glXDisp_GetPixelMapusv
+__glXDisp_GetTexEnvfv
+__glXDisp_GetTexEnviv
+__glXDisp_GetTexGendv
+__glXDisp_GetTexGenfv
+__glXDisp_GetTexGeniv
+__glXDisp_GetTexLevelParameterfv
+__glXDisp_GetTexLevelParameteriv
+__glXDisp_GetTexParameterfv
+__glXDisp_GetTexParameteriv
+__glXDisp_IsEnabled
+__glXDisp_IsList
+__glXDisp_IsTexture
+__glXDisp_NewList
+__glXDisp_PixelStoref
+__glXDisp_PixelStorei
+__glXDispSwap_AreTexturesResident
+__glXDispSwap_DeleteLists
+__glXDispSwap_DeleteTextures
+__glXDispSwap_EndList
+__glXDispSwap_GenLists
+__glXDispSwap_GenTextures
+__glXDispSwap_GetBooleanv
+__glXDispSwap_GetDoublev
+__glXDispSwap_GetError
+__glXDispSwap_GetFloatv
+__glXDispSwap_GetIntegerv
+__glXDispSwap_GetLightfv
+__glXDispSwap_GetLightiv
+__glXDispSwap_GetMapdv
+__glXDispSwap_GetMapfv
+__glXDispSwap_GetMapiv
+__glXDispSwap_GetMaterialfv
+__glXDispSwap_GetMaterialiv
+__glXDispSwap_GetPixelMapfv
+__glXDispSwap_GetPixelMapuiv
+__glXDispSwap_GetPixelMapusv
+__glXDispSwap_GetTexEnvfv
+__glXDispSwap_GetTexEnviv
+__glXDispSwap_GetTexGendv
+__glXDispSwap_GetTexGenfv
+__glXDispSwap_GetTexGeniv
+__glXDispSwap_GetTexLevelParameterfv
+__glXDispSwap_GetTexLevelParameteriv
+__glXDispSwap_GetTexParameterfv
+__glXDispSwap_GetTexParameteriv
+__glXDispSwap_IsEnabled
+__glXDispSwap_IsList
+__glXDispSwap_IsTexture
+__glXDispSwap_NewList
+__glXDispSwap_PixelStoref
+__glXDispSwap_PixelStorei
+
+/* $XFree86$ */
diff --git a/nx-X11/programs/Xserver/GL/glx/glxbuf.c b/nx-X11/programs/Xserver/GL/glx/glxbuf.c
new file mode 100644
index 000000000..44be53614
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxbuf.c
@@ -0,0 +1,296 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxbuf.c,v 1.6 2001/03/25 05:32:01 tsi Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxutil.h"
+#include "glxbuf.h"
+#include "glxfb.h"
+#include "glxmem.h"
+#include "glxpix.h"
+
+void
+__glXFBInitDrawable(__GLXdrawablePrivate *glxPriv, __GLcontextModes *modes)
+{
+ __GLdrawablePrivate *glPriv;
+ GLint rgbBits;
+ GLint accumBits;
+
+ glPriv = &glxPriv->glPriv;
+ rgbBits = modes->rgbBits;
+ accumBits = modes->accumRedBits + modes->accumGreenBits +
+ modes->accumBlueBits + modes->accumAlphaBits;
+
+#if defined(__GL_ALIGNED_BUFFERS)
+ /* initialize pixel alignments (for more details see context.h) */
+ glPriv->xAlignment = 1;
+ glPriv->yAlignment = 1;
+#endif
+
+ glxPriv->swapBuffers = __glXFBMemSwapBuffers;
+
+ glPriv->yInverted = GL_TRUE; /* Y is upside-down */
+
+ if (modes->doubleBufferMode) {
+ if (modes->colorIndexMode) {
+ __glXInitFB(&glPriv->frontBuffer, glPriv, modes->indexBits);
+ __glXInitMem(&glPriv->backBuffer, glPriv, modes->indexBits);
+ } else {
+ __glXInitFB(&glPriv->frontBuffer, glPriv, rgbBits);
+ __glXInitMem(&glPriv->backBuffer, glPriv, rgbBits);
+ }
+ } else {
+ if (modes->colorIndexMode) {
+ __glXInitFB(&glPriv->frontBuffer, glPriv, modes->indexBits);
+ } else {
+ __glXInitFB(&glPriv->frontBuffer, glPriv, rgbBits);
+ }
+ }
+
+#if defined(__GL_MAX_AUXBUFFERS) && (__GL_MAX_AUXBUFFERS > 0)
+ if (modes->maxAuxBuffers > 0) {
+ GLint i;
+
+ for (i=0; i < modes->maxAuxBuffers; i++) {
+ if (modes->colorIndexMode) {
+ __glXInitMem(&glPriv->auxBuffer[i], glPriv, modes->indexBits);
+ } else {
+ __glXInitMem(&glPriv->auxBuffer[i], glPriv, rgbBits);
+ }
+ }
+ }
+#endif
+
+ if (modes->haveAccumBuffer) {
+ __glXInitMem(&glPriv->accumBuffer, glPriv, accumBits);
+ }
+ if (modes->haveDepthBuffer) {
+ __glXInitMem(&glPriv->depthBuffer, glPriv, modes->depthBits);
+ }
+ if (modes->haveStencilBuffer) {
+ __glXInitMem(&glPriv->stencilBuffer, glPriv, modes->stencilBits);
+ }
+}
+
+void
+__glXPixInitDrawable(__GLXdrawablePrivate *glxPriv, __GLcontextModes *modes)
+{
+ __GLdrawablePrivate *glPriv;
+ GLint rgbBits;
+ GLint accumBits;
+
+ assert(glxPriv->pGlxPixmap);
+
+ glPriv = &glxPriv->glPriv;
+ rgbBits = modes->rgbBits;
+ accumBits = modes->accumRedBits + modes->accumGreenBits +
+ modes->accumBlueBits + modes->accumAlphaBits;
+
+#if defined(__GL_ALIGNED_BUFFERS)
+ /* initialize pixel alignments (for more details see context.h) */
+ glPriv->xAlignment = 1;
+ glPriv->yAlignment = 1;
+#endif
+
+ glxPriv->swapBuffers = (GLboolean (*)(__GLXdrawablePrivate *))__glXNop;
+
+ glPriv->yInverted = GL_FALSE;
+
+ if (modes->doubleBufferMode) {
+ if (modes->colorIndexMode) {
+ __glXInitPix(&glPriv->frontBuffer, glPriv, rgbBits,
+ glxPriv->drawId, glxPriv->pGlxPixmap);
+ __glXInitMem(&glPriv->backBuffer, glPriv, modes->indexBits);
+ } else {
+ __glXInitPix(&glPriv->frontBuffer, glPriv, rgbBits,
+ glxPriv->drawId, glxPriv->pGlxPixmap);
+ __glXInitMem(&glPriv->backBuffer, glPriv, rgbBits);
+ }
+ } else {
+ if (modes->colorIndexMode) {
+ __glXInitPix(&glPriv->frontBuffer, glPriv, rgbBits,
+ glxPriv->drawId, glxPriv->pGlxPixmap);
+ } else {
+ __glXInitPix(&glPriv->frontBuffer, glPriv, rgbBits,
+ glxPriv->drawId, glxPriv->pGlxPixmap);
+ }
+ }
+
+#if defined(__GL_MAX_AUXBUFFERS) && (__GL_MAX_AUXBUFFERS > 0)
+ if (modes->maxAuxBuffers > 0) {
+ GLint i;
+
+ for (i=0; i < modes->maxAuxBuffers; i++) {
+ if (modes->colorIndexMode) {
+ __glXInitMem(&glPriv->auxBuffer[i], glPriv, modes->indexBits);
+ } else {
+ __glXInitMem(&glPriv->auxBuffer[i], glPriv, rgbBits);
+ }
+ }
+ }
+#endif
+
+ if (modes->haveAccumBuffer) {
+ __glXInitMem(&glPriv->accumBuffer, glPriv, accumBits);
+ }
+ if (modes->haveDepthBuffer) {
+ __glXInitMem(&glPriv->depthBuffer, glPriv, modes->depthBits);
+ }
+ if (modes->haveStencilBuffer) {
+ __glXInitMem(&glPriv->stencilBuffer, glPriv, modes->stencilBits);
+ }
+}
+
+
+#define __GLX_SET_ACCEL_BUFFER_MASK(bm) \
+ if (status == GL_FALSE) return GL_FALSE; \
+ if (status == GL_TRUE) accelBufferMask |= bm; \
+ /* for __GL_BUFFER_FALLBACK don't do anything */
+
+GLboolean
+__glXResizeBuffers(__GLdrawablePrivate *glPriv,
+ GLint x, GLint y, GLuint width, GLuint height)
+{
+ __GLcontextModes *modes;
+ __GLdrawableRegion *glRegion;
+ GLboolean status;
+ GLuint accelBufferMask;
+
+ modes = glPriv->modes;
+ accelBufferMask = 0;
+
+ status = (*glPriv->frontBuffer.resize)(&glPriv->frontBuffer,
+ x, y, width, height, glPriv,
+ __GL_FRONT_BUFFER_MASK);
+ __GLX_SET_ACCEL_BUFFER_MASK(__GL_FRONT_BUFFER_MASK);
+
+ if (modes->doubleBufferMode) {
+ status = (*glPriv->backBuffer.resize)(&glPriv->backBuffer,
+ x, y, width, height, glPriv,
+ __GL_BACK_BUFFER_MASK);
+ __GLX_SET_ACCEL_BUFFER_MASK(__GL_BACK_BUFFER_MASK);
+ }
+
+#if defined(__GL_MAX_AUXBUFFERS) && (__GL_MAX_AUXBUFFERS > 0)
+ if (modes->maxAuxBuffers > 0) {
+ GLint i;
+
+ for (i=0; i < modes->maxAuxBuffers; i++) {
+ status = (*glPriv->auxBuffers[i].resize)(&glPriv->auxBuffer[i],
+ x, y, width, height,
+ glPriv,
+ __GL_AUX_BUFFER_MASK(i));
+ __GLX_SET_ACCEL_BUFFER_MASK(__GL_AUX_BUFFER_MASK(i));
+ }
+ }
+#endif
+
+ if (modes->haveAccumBuffer) {
+ status = (*glPriv->accumBuffer.resize)(&glPriv->accumBuffer,
+ x, y, width, height, glPriv,
+ __GL_ACCUM_BUFFER_MASK);
+ __GLX_SET_ACCEL_BUFFER_MASK(__GL_ACCUM_BUFFER_MASK);
+ }
+
+ if (modes->haveDepthBuffer) {
+ status = (*glPriv->depthBuffer.resize)(&glPriv->depthBuffer,
+ x, y, width, height, glPriv,
+ __GL_DEPTH_BUFFER_MASK);
+ __GLX_SET_ACCEL_BUFFER_MASK(__GL_DEPTH_BUFFER_MASK);
+ }
+
+ if (modes->haveStencilBuffer) {
+ status = (*glPriv->stencilBuffer.resize)(&glPriv->stencilBuffer,
+ x, y, width, height, glPriv,
+ __GL_STENCIL_BUFFER_MASK);
+ __GLX_SET_ACCEL_BUFFER_MASK(__GL_STENCIL_BUFFER_MASK);
+ }
+
+ glPriv->accelBufferMask = accelBufferMask;
+
+ /* finally, update the ownership region */
+ glRegion = &glPriv->ownershipRegion;
+ glRegion->numRects = 1;
+ glRegion->rects[0].x0 = 0;
+ glRegion->rects[0].y0 = 0;
+ glRegion->rects[0].x1 = width;
+ glRegion->rects[0].y1 = height;
+
+ return GL_TRUE;
+}
+
+void
+__glXFreeBuffers(__GLXdrawablePrivate *glxPriv)
+{
+ __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
+#if defined(__GL_MAX_AUXBUFFERS) && (__GL_MAX_AUXBUFFERS > 0)
+ __GLcontextModes *modes = glPriv->modes;
+#endif
+
+ if (glPriv->frontBuffer.free) {
+ (*glPriv->frontBuffer.free)(&glPriv->frontBuffer, glPriv);
+ }
+ if (glPriv->backBuffer.free) {
+ (*glPriv->backBuffer.free)(&glPriv->backBuffer, glPriv);
+ }
+
+#if defined(__GL_MAX_AUXBUFFERS) && (__GL_MAX_AUXBUFFERS > 0)
+ if (modes->maxAuxBuffers > 0) {
+ GLint i;
+
+ for (i=0; i < modes->maxAuxBuffers; i++) {
+ if (glPriv->auxBuffer[i].free) {
+ (*glPriv->auxBuffer[i].free)(&glPriv->auxBuffer[i], glPriv);
+ }
+ }
+ }
+#endif
+
+ if (glPriv->accumBuffer.free) {
+ (*glPriv->accumBuffer.free)(&glPriv->accumBuffer, glPriv);
+ }
+
+ if (glPriv->depthBuffer.free) {
+ (*glPriv->depthBuffer.free)(&glPriv->depthBuffer, glPriv);
+ }
+
+ if (glPriv->stencilBuffer.free) {
+ (*glPriv->stencilBuffer.free)(&glPriv->stencilBuffer, glPriv);
+ }
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/glxbuf.h b/nx-X11/programs/Xserver/GL/glx/glxbuf.h
new file mode 100644
index 000000000..88b04e8bd
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxbuf.h
@@ -0,0 +1,57 @@
+/* $XFree86$ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _glxbuf_h_
+#define _glxbuf_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+extern void __glXFBInitDrawable(__GLXdrawablePrivate *glxPriv,
+ __GLcontextModes *modes);
+extern void __glXPixInitDrawable(__GLXdrawablePrivate *glxPriv,
+ __GLcontextModes *modes);
+
+extern GLboolean __glXResizeBuffers(__GLdrawablePrivate *glPriv,
+ GLint x, GLint y,
+ GLuint width, GLuint height);
+
+extern void __glXFreeBuffers(__GLXdrawablePrivate *glxPriv);
+extern void __glXUpdatePalette(__GLXdrawablePrivate *);
+
+#endif /* _glxbuf_h_ */
+
diff --git a/nx-X11/programs/Xserver/GL/glx/glxcmds.c b/nx-X11/programs/Xserver/GL/glx/glxcmds.c
new file mode 100644
index 000000000..ca5eee82a
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxcmds.c
@@ -0,0 +1,2156 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxcmds.c,v 1.12 2004/01/28 18:11:50 alanh Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define NEED_REPLIES
+#define FONT_PCF
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include <GL/glxtokens.h>
+#include <unpack.h>
+#include "g_disptab.h"
+#include <pixmapstr.h>
+#include <windowstr.h>
+#include "g_disptab_EXT.h"
+#include "glximports.h"
+#include "glxutil.h"
+#include "glxext.h"
+#include "GL/glx_ansic.h"
+#include "glcontextmodes.h"
+
+/************************************************************************/
+
+static __GLimports imports = {
+ __glXImpMalloc,
+ __glXImpCalloc,
+ __glXImpRealloc,
+ __glXImpFree,
+ __glXImpWarning,
+ __glXImpFatal,
+ __glXImpGetenv,
+ __glXImpAtoi,
+ __glXImpSprintf,
+ __glXImpFopen,
+ __glXImpFclose,
+ __glXImpFprintf,
+ __glXImpGetDrawablePrivate,
+ __glXImpGetReadablePrivate,
+ NULL
+};
+
+static int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc);
+static int __glXCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc);
+static int __glXCreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc);
+static int __glXMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc);
+
+static int __glXBindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc);
+static int __glXQueryMaxSwapBarriersSGIX(__GLXclientState *cl, GLbyte *pc);
+static int __glxQueryHyperpipeNetworkSGIX(__GLXclientState *cl, GLbyte *pc);
+static int __glxDestroyHyperpipeConfigSGIX (__GLXclientState *cl, GLbyte *pc);
+static int __glxQueryHyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc);
+static int __glxHyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc);
+
+
+/************************************************************************/
+
+/**
+ * Create a GL context with the given properties. This routine is used
+ * to implement \c glXCreateContext, \c glXCreateNewContext, and
+ * \c glXCreateContextWithConfigSGIX. This works becuase of the hack way
+ * that GLXFBConfigs are implemented. Basically, the FBConfigID is the
+ * same as the VisualID.
+ */
+
+int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
+ GLXContextID shareList, VisualID visual,
+ GLuint screen, GLboolean isDirect)
+{
+ ClientPtr client = cl->client;
+ VisualPtr pVisual;
+ ScreenPtr pScreen;
+ __GLXcontext *glxc, *shareglxc;
+ __GLcontextModes *modes;
+ __GLXscreenInfo *pGlxScreen;
+ __GLinterface *shareGC;
+ GLint i;
+
+ LEGAL_NEW_RESOURCE(gcId, client);
+
+ /*
+ ** Check if screen exists.
+ */
+ if (screen >= screenInfo.numScreens) {
+ client->errorValue = screen;
+ return BadValue;
+ }
+ pScreen = screenInfo.screens[screen];
+ pGlxScreen = &__glXActiveScreens[screen];
+
+ /*
+ ** Check if the visual ID is valid for this screen.
+ */
+ pVisual = pScreen->visuals;
+ for (i = 0; i < pScreen->numVisuals; i++, pVisual++) {
+ if (pVisual->vid == visual) {
+ break;
+ }
+ }
+ if (i == pScreen->numVisuals) {
+ client->errorValue = visual;
+ return BadValue;
+ }
+
+ /*
+ ** Get configuration of the visual. This assumes that the
+ ** glXActiveScreens structure contains visual configurations only for the
+ ** subset of Visuals that are supported by this implementation of the
+ ** OpenGL.
+ */
+
+ modes = _gl_context_modes_find_visual( pGlxScreen->modes, visual );
+ if (modes == NULL) {
+ /*
+ ** Visual not support on this screen by this OpenGL implementation.
+ */
+ client->errorValue = visual;
+ return BadValue;
+ }
+
+ /*
+ ** Find the display list space that we want to share.
+ **
+ ** NOTE: In a multithreaded X server, we would need to keep a reference
+ ** count for each display list so that if one client detroyed a list that
+ ** another client was using, the list would not really be freed until it
+ ** was no longer in use. Since this sample implementation has no support
+ ** for multithreaded servers, we don't do this.
+ */
+ if (shareList == None) {
+ shareGC = 0;
+ } else {
+ shareglxc = (__GLXcontext *) LookupIDByType(shareList, __glXContextRes);
+ if (!shareglxc) {
+ client->errorValue = shareList;
+ return __glXBadContext;
+ }
+ if (shareglxc->isDirect) {
+ /*
+ ** NOTE: no support for sharing display lists between direct
+ ** contexts, even if they are in the same address space.
+ */
+#if 0
+ /* Disabling this code seems to allow shared display lists
+ * and texture objects to work. We'll leave it disabled for now.
+ */
+ client->errorValue = shareList;
+ return BadMatch;
+#endif
+ } else {
+ /*
+ ** Create an indirect context regardless of what the client asked
+ ** for; this way we can share display list space with shareList.
+ */
+ isDirect = GL_FALSE;
+ }
+ shareGC = shareglxc->gc;
+ }
+
+ /*
+ ** Allocate memory for the new context
+ */
+ glxc = (__GLXcontext *) __glXMalloc(sizeof(__GLXcontext));
+ if (!glxc) {
+ return BadAlloc;
+ }
+ __glXMemset(glxc, 0, sizeof(__GLXcontext));
+
+ /*
+ ** Initially, setup the part of the context that could be used by
+ ** a GL core that needs windowing information (e.g., Mesa).
+ */
+ glxc->pScreen = pScreen;
+ glxc->pGlxScreen = pGlxScreen;
+ glxc->pVisual = pVisual;
+ glxc->modes = modes;
+
+ if (!isDirect) {
+
+ /*
+ ** Allocate a GL context
+ */
+ imports.other = (void *)glxc;
+ glxc->gc = (*pGlxScreen->createContext)(&imports, glxc->modes, shareGC);
+ if (!glxc->gc) {
+ __glXFree(glxc);
+ client->errorValue = gcId;
+ return BadAlloc;
+ }
+ } else {
+ /*
+ ** Don't need local GL context for a direct context.
+ */
+ glxc->gc = 0;
+ }
+ /*
+ ** Register this context as a resource.
+ */
+ if (!AddResource(gcId, __glXContextRes, (pointer)glxc)) {
+ if (!isDirect) {
+ (*glxc->gc->exports.destroyContext)((__GLcontext *)glxc->gc);
+ }
+ __glXFree(glxc);
+ client->errorValue = gcId;
+ return BadAlloc;
+ }
+
+ /*
+ ** Finally, now that everything is working, setup the rest of the
+ ** context.
+ */
+ glxc->id = gcId;
+ glxc->share_id = shareList;
+ glxc->idExists = GL_TRUE;
+ glxc->isCurrent = GL_FALSE;
+ glxc->isDirect = isDirect;
+ glxc->renderMode = GL_RENDER;
+
+ return Success;
+}
+
+
+int __glXCreateContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
+ return DoCreateContext( cl, req->context, req->shareList, req->visual,
+ req->screen, req->isDirect );
+}
+
+
+int __glXCreateNewContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
+ return DoCreateContext( cl, req->context, req->shareList, req->fbconfig,
+ req->screen, req->isDirect );
+}
+
+
+int __glXCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextWithConfigSGIXReq *req =
+ (xGLXCreateContextWithConfigSGIXReq *) pc;
+ return DoCreateContext( cl, req->context, req->shareList, req->fbconfig,
+ req->screen, req->isDirect );
+}
+
+/*
+** Destroy a GL context as an X resource.
+*/
+int __glXDestroyContext(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
+ GLXContextID gcId = req->context;
+ __GLXcontext *glxc;
+
+ glxc = (__GLXcontext *) LookupIDByType(gcId, __glXContextRes);
+ if (glxc) {
+ /*
+ ** Just free the resource; don't actually destroy the context,
+ ** because it might be in use. The
+ ** destroy method will be called by the resource destruction routine
+ ** if necessary.
+ */
+ FreeResourceByType(gcId, __glXContextRes, FALSE);
+ return Success;
+ } else {
+ client->errorValue = gcId;
+ return __glXBadContext;
+ }
+}
+
+/*****************************************************************************/
+
+/*
+** For each client, the server keeps a table of all the contexts that are
+** current for that client (each thread of a client may have its own current
+** context). These routines add, change, and lookup contexts in the table.
+*/
+
+/*
+** Add a current context, and return the tag that will be used to refer to it.
+*/
+static int AddCurrentContext(__GLXclientState *cl, __GLXcontext *glxc)
+{
+ int i;
+ int num = cl->numCurrentContexts;
+ __GLXcontext **table = cl->currentContexts;
+
+ if (!glxc) return -1;
+
+ /*
+ ** Try to find an empty slot and use it.
+ */
+ for (i=0; i < num; i++) {
+ if (!table[i]) {
+ table[i] = glxc;
+ return i+1;
+ }
+ }
+ /*
+ ** Didn't find a free slot, so we'll have to grow the table.
+ */
+ if (!num) {
+ table = (__GLXcontext **) __glXMalloc(sizeof(__GLXcontext *));
+ } else {
+ table = (__GLXcontext **) __glXRealloc(table,
+ (num+1)*sizeof(__GLXcontext *));
+ }
+ table[num] = glxc;
+ cl->currentContexts = table;
+ cl->numCurrentContexts++;
+ return num+1;
+}
+
+/*
+** Given a tag, change the current context for the corresponding entry.
+*/
+static void ChangeCurrentContext(__GLXclientState *cl, __GLXcontext *glxc,
+ GLXContextTag tag)
+{
+ __GLXcontext **table = cl->currentContexts;
+ table[tag-1] = glxc;
+}
+
+/*
+** For this implementation we have chosen to simply use the index of the
+** context's entry in the table as the context tag. A tag must be greater
+** than 0.
+*/
+__GLXcontext *__glXLookupContextByTag(__GLXclientState *cl, GLXContextTag tag)
+{
+ int num = cl->numCurrentContexts;
+
+ if (tag < 1 || tag > num) {
+ return 0;
+ } else {
+ return cl->currentContexts[tag-1];
+ }
+}
+
+/*****************************************************************************/
+
+static void StopUsingContext(__GLXcontext *glxc)
+{
+ if (glxc) {
+ if (glxc == __glXLastContext) {
+ /* Tell server GL library */
+ __glXLastContext = 0;
+ }
+ glxc->isCurrent = GL_FALSE;
+ if (!glxc->idExists) {
+ __glXFreeContext(glxc);
+ }
+ }
+}
+
+static void StartUsingContext(__GLXclientState *cl, __GLXcontext *glxc)
+{
+ glxc->isCurrent = GL_TRUE;
+}
+
+/*****************************************************************************/
+/*
+** Make an OpenGL context and drawable current.
+*/
+
+int __glXMakeCurrent(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc;
+
+ return DoMakeCurrent( cl, req->drawable, req->drawable,
+ req->context, req->oldContextTag );
+}
+
+int __glXMakeContextCurrent(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc;
+
+ return DoMakeCurrent( cl, req->drawable, req->readdrawable,
+ req->context, req->oldContextTag );
+}
+
+int __glXMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc;
+
+ return DoMakeCurrent( cl, req->drawable, req->readable,
+ req->context, req->oldContextTag );
+}
+
+
+/**
+ * Given a drawable ID, get the associated drawable and / or pixmap.
+ *
+ * If the specified drawable ID is not a pixmap, \c ppPixmap will be set
+ * to \c NULL on return. In either case, \c ppDraw will be set to a drawable.
+ * In the case where the drawable ID is a pixmap, \c ppDraw will be set to
+ * the drawable associated with that pixmap.
+ *
+ * \param glxc Associated GLX context.
+ * \param drawId ID of the drawable.
+ * \param ppDraw Location to store the pointer to the drawable.
+ * \param ppPixmap Location to store the pointer to the pixmap.
+ * \param client Pointer to the client state.
+ * \return Zero is returned on success. Otherwise a GLX / X11 protocol error
+ * is returned.
+ *
+ * \notes This function will need some modification when support pbuffers
+ * is added.
+ */
+static int GetDrawableOrPixmap( __GLXcontext *glxc, GLXDrawable drawId,
+ DrawablePtr *ppDraw, __GLXpixmap **ppPixmap,
+ ClientPtr client )
+{
+ DrawablePtr pDraw;
+ __GLXpixmap *drawPixmap = NULL;
+
+ pDraw = (DrawablePtr) LookupDrawable(drawId, client);
+ if (pDraw) {
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ /*
+ ** Drawable is an X Window.
+ */
+ WindowPtr pWin = (WindowPtr)pDraw;
+ VisualID vid = wVisual(pWin);
+
+ /*
+ ** Check if window and context are similar.
+ */
+ if ((vid != glxc->pVisual->vid) ||
+ (pWin->drawable.pScreen != glxc->pScreen)) {
+ client->errorValue = drawId;
+ return BadMatch;
+ }
+ } else {
+ /*
+ ** An X Pixmap is not allowed as a parameter (a GLX Pixmap
+ ** is, but it must first be created with glxCreateGLXPixmap).
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ } else {
+ drawPixmap = (__GLXpixmap *) LookupIDByType(drawId, __glXPixmapRes);
+ if (drawPixmap) {
+ /*
+ ** Check if pixmap and context are similar.
+ */
+ if (drawPixmap->pScreen != glxc->pScreen ||
+ drawPixmap->modes->visualID != glxc->modes->visualID) {
+ client->errorValue = drawId;
+ return BadMatch;
+ }
+ pDraw = drawPixmap->pDraw;
+
+ } else {
+ /*
+ ** Drawable is neither a Window nor a GLXPixmap.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ }
+
+ *ppPixmap = drawPixmap;
+ *ppDraw = pDraw;
+
+ return 0;
+}
+
+
+int DoMakeCurrent( __GLXclientState *cl,
+ GLXDrawable drawId, GLXDrawable readId,
+ GLXContextID contextId, GLXContextTag tag )
+{
+ ClientPtr client = cl->client;
+ DrawablePtr pDraw;
+ DrawablePtr pRead;
+ xGLXMakeCurrentReply reply;
+ __GLXpixmap *drawPixmap = NULL;
+ __GLXpixmap *readPixmap = NULL;
+ __GLXcontext *glxc, *prevglxc;
+ __GLinterface *gc, *prevgc;
+ __GLXdrawablePrivate *drawPriv = NULL;
+ __GLXdrawablePrivate *readPriv = NULL;
+ GLint error;
+ GLuint mask;
+
+ /*
+ ** If one is None and the other isn't, it's a bad match.
+ */
+
+ mask = (drawId == None) ? (1 << 0) : 0;
+ mask |= (readId == None) ? (1 << 1) : 0;
+ mask |= (contextId == None) ? (1 << 2) : 0;
+
+ if ( (mask != 0x00) && (mask != 0x07) ) {
+ return BadMatch;
+ }
+
+ /*
+ ** Lookup old context. If we have one, it must be in a usable state.
+ */
+ if (tag != 0) {
+ prevglxc = __glXLookupContextByTag(cl, tag);
+ if (!prevglxc) {
+ /*
+ ** Tag for previous context is invalid.
+ */
+ return __glXBadContextTag;
+ }
+ if (prevglxc->renderMode != GL_RENDER) {
+ /* Oops. Not in render mode render. */
+ client->errorValue = prevglxc->id;
+ return __glXBadContextState;
+ }
+ prevgc = prevglxc->gc;
+ } else {
+ prevglxc = 0;
+ prevgc = 0;
+ }
+
+ /*
+ ** Lookup new context. It must not be current for someone else.
+ */
+ if (contextId != None) {
+ int status;
+
+ glxc = (__GLXcontext *) LookupIDByType(contextId, __glXContextRes);
+ if (!glxc) {
+ client->errorValue = contextId;
+ return __glXBadContext;
+ }
+ if ((glxc != prevglxc) && glxc->isCurrent) {
+ /* Context is current to somebody else */
+ return BadAccess;
+ }
+ gc = glxc->gc;
+
+
+ assert( drawId != None );
+ assert( readId != None );
+
+ status = GetDrawableOrPixmap( glxc, drawId, & pDraw, & drawPixmap,
+ client );
+ if ( status != 0 ) {
+ return status;
+ }
+
+ if ( readId != drawId ) {
+ status = GetDrawableOrPixmap( glxc, readId, & pRead, & readPixmap,
+ client );
+ if ( status != 0 ) {
+ return status;
+ }
+ } else {
+ pRead = pDraw;
+ }
+
+ /* FIXME: Finish refactoring this. - idr */
+ /* get the drawable private */
+ if (pDraw) {
+ drawPriv = __glXGetDrawablePrivate(pDraw, drawId, glxc->modes);
+ if (drawPriv == NULL) {
+ return __glXBadDrawable;
+ }
+ }
+
+ if (pRead != pDraw) {
+ readPriv = __glXGetDrawablePrivate(pRead, readId, glxc->modes);
+ if (readPriv == NULL) {
+ return __glXBadDrawable;
+ }
+ } else {
+ readPriv = drawPriv;
+ }
+
+ } else {
+ /* Switching to no context. Ignore new drawable. */
+ glxc = 0;
+ gc = 0;
+ pDraw = 0;
+ pRead = 0;
+ }
+
+
+ if (prevglxc) {
+ /*
+ ** Flush the previous context if needed.
+ */
+ if (__GLX_HAS_UNFLUSHED_CMDS(prevglxc)) {
+ if (__glXForceCurrent(cl, tag, (int *)&error)) {
+ glFlush();
+ __GLX_NOTE_FLUSHED_CMDS(prevglxc);
+ } else {
+ return error;
+ }
+ }
+
+ /*
+ ** Make the previous context not current.
+ */
+ if (!(*prevgc->exports.loseCurrent)((__GLcontext *)prevgc)) {
+ return __glXBadContext;
+ }
+ __glXDeassociateContext(prevglxc);
+ }
+
+
+ if ((glxc != 0) && !glxc->isDirect) {
+
+ glxc->drawPriv = drawPriv;
+ glxc->readPriv = readPriv;
+ __glXCacheDrawableSize(drawPriv);
+
+ /* make the context current */
+ if (!(*gc->exports.makeCurrent)((__GLcontext *)gc)) {
+ glxc->drawPriv = NULL;
+ glxc->readPriv = NULL;
+ return __glXBadContext;
+ }
+
+ /* resize the buffers */
+ if (!__glXResizeDrawableBuffers(drawPriv)) {
+ /* could not do initial resize. make current failed */
+ (*gc->exports.loseCurrent)((__GLcontext *)gc);
+ glxc->drawPriv = NULL;
+ glxc->readPriv = NULL;
+ return __glXBadContext;
+ }
+
+ glxc->isCurrent = GL_TRUE;
+ __glXAssociateContext(glxc);
+ assert(drawPriv->drawGlxc == glxc);
+ assert(readPriv->readGlxc == glxc);
+ }
+
+ if (prevglxc) {
+ if (prevglxc->drawPixmap) {
+ if (prevglxc->readPixmap &&
+ prevglxc->drawPixmap != prevglxc->readPixmap) {
+ /*
+ ** The previous drawable was a glx pixmap, release it.
+ */
+ prevglxc->readPixmap->refcnt--;
+ if (!prevglxc->readPixmap->idExists &&
+ !prevglxc->readPixmap->refcnt) {
+ PixmapPtr pPixmap = (PixmapPtr) prevglxc->readPixmap->pDraw;
+ /*
+ ** The DestroyPixmap routine should decrement the
+ ** refcount of the X pixmap and free only if it's zero.
+ */
+ (*prevglxc->readPixmap->pScreen->DestroyPixmap)(pPixmap);
+ __glXFree(prevglxc->readPixmap);
+ }
+ }
+
+ /*
+ ** The previous drawable was a glx pixmap, release it.
+ */
+ prevglxc->drawPixmap->refcnt--;
+ if (!prevglxc->drawPixmap->idExists &&
+ !prevglxc->drawPixmap->refcnt) {
+ PixmapPtr pPixmap = (PixmapPtr) prevglxc->drawPixmap->pDraw;
+ /*
+ ** The DestroyPixmap routine should decrement the
+ ** refcount of the X pixmap and free only if it's zero.
+ */
+ (*prevglxc->drawPixmap->pScreen->DestroyPixmap)(pPixmap);
+ __glXFree(prevglxc->drawPixmap);
+ }
+
+ prevglxc->drawPixmap = NULL;
+ }
+ ChangeCurrentContext(cl, glxc, tag);
+ StopUsingContext(prevglxc);
+ } else {
+ tag = AddCurrentContext(cl, glxc);
+ }
+
+ if (glxc) {
+ if (drawPixmap) {
+ drawPixmap->refcnt++;
+ glxc->drawPixmap = drawPixmap;
+ }
+
+ if (readPixmap && (readPixmap != drawPixmap)) {
+ readPixmap->refcnt++;
+ glxc->readPixmap = readPixmap;
+ }
+
+ StartUsingContext(cl, glxc);
+ reply.contextTag = tag;
+ } else {
+ reply.contextTag = 0;
+ }
+
+ reply.length = 0;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (client->swapped) {
+ __glXSwapMakeCurrentReply(client, &reply);
+ } else {
+ WriteToClient(client, sz_xGLXMakeCurrentReply, (char *)&reply);
+ }
+ return Success;
+}
+
+int __glXIsDirect(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
+ xGLXIsDirectReply reply;
+ __GLXcontext *glxc;
+
+ /*
+ ** Find the GL context.
+ */
+ glxc = (__GLXcontext *) LookupIDByType(req->context, __glXContextRes);
+ if (!glxc) {
+ client->errorValue = req->context;
+ return __glXBadContext;
+ }
+
+ reply.isDirect = glxc->isDirect;
+ reply.length = 0;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (client->swapped) {
+ __glXSwapIsDirectReply(client, &reply);
+ } else {
+ WriteToClient(client, sz_xGLXIsDirectReply, (char *)&reply);
+ }
+
+ return Success;
+}
+
+int __glXQueryVersion(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc;
+ xGLXQueryVersionReply reply;
+ GLuint major, minor;
+
+ major = req->majorVersion;
+ minor = req->minorVersion;
+ (void)major;
+ (void)minor;
+
+ /*
+ ** Server should take into consideration the version numbers sent by the
+ ** client if it wants to work with older clients; however, in this
+ ** implementation the server just returns its version number.
+ */
+ reply.majorVersion = GLX_SERVER_MAJOR_VERSION;
+ reply.minorVersion = GLX_SERVER_MINOR_VERSION;
+ reply.length = 0;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (client->swapped) {
+ __glXSwapQueryVersionReply(client, &reply);
+ } else {
+ WriteToClient(client, sz_xGLXQueryVersionReply, (char *)&reply);
+ }
+ return Success;
+}
+
+int __glXWaitGL(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXWaitGLReq *req = (xGLXWaitGLReq *)pc;
+ int error;
+
+ if (!__glXForceCurrent(cl, req->contextTag, &error)) {
+ return error;
+ }
+ glFinish();
+ return Success;
+}
+
+int __glXWaitX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXWaitXReq *req = (xGLXWaitXReq *)pc;
+ int error;
+
+ if (!__glXForceCurrent(cl, req->contextTag, &error)) {
+ return error;
+ }
+ /*
+ ** In a multithreaded server that had separate X and GL threads, we would
+ ** have to wait for the X thread to finish before returning. As it stands,
+ ** this sample implementation only supports singlethreaded servers, and
+ ** nothing needs to be done here.
+ */
+ return Success;
+}
+
+int __glXCopyContext(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc;
+ GLXContextID source = req->source;
+ GLXContextID dest = req->dest;
+ GLXContextTag tag = req->contextTag;
+ unsigned long mask = req->mask;
+ __GLXcontext *src, *dst;
+ int error;
+
+ /*
+ ** Check that each context exists.
+ */
+ src = (__GLXcontext *) LookupIDByType(source, __glXContextRes);
+ if (!src) {
+ client->errorValue = source;
+ return __glXBadContext;
+ }
+ dst = (__GLXcontext *) LookupIDByType(dest, __glXContextRes);
+ if (!dst) {
+ client->errorValue = dest;
+ return __glXBadContext;
+ }
+
+ /*
+ ** They must be in the same address space, and same screen.
+ ** NOTE: no support for direct rendering contexts here.
+ */
+ if (src->isDirect || dst->isDirect ||
+ (src->pGlxScreen != dst->pGlxScreen)) {
+ client->errorValue = source;
+ return BadMatch;
+ }
+
+ /*
+ ** The destination context must not be current for any client.
+ */
+ if (dst->isCurrent) {
+ client->errorValue = dest;
+ return BadAccess;
+ }
+
+ if (tag) {
+ __GLXcontext *tagcx = __glXLookupContextByTag(cl, tag);
+
+ if (!tagcx) {
+ return __glXBadContextTag;
+ }
+ if (tagcx != src) {
+ /*
+ ** This would be caused by a faulty implementation of the client
+ ** library.
+ */
+ return BadMatch;
+ }
+ /*
+ ** In this case, glXCopyContext is in both GL and X streams, in terms
+ ** of sequentiality.
+ */
+ if (__glXForceCurrent(cl, tag, &error)) {
+ /*
+ ** Do whatever is needed to make sure that all preceding requests
+ ** in both streams are completed before the copy is executed.
+ */
+ glFinish();
+ __GLX_NOTE_FLUSHED_CMDS(tagcx);
+ } else {
+ return error;
+ }
+ }
+ /*
+ ** Issue copy. The only reason for failure is a bad mask.
+ */
+ if (!(*dst->gc->exports.copyContext)((__GLcontext *)dst->gc,
+ (__GLcontext *)src->gc,
+ mask)) {
+ client->errorValue = mask;
+ return BadValue;
+ }
+ return Success;
+}
+
+
+int DoGetVisualConfigs(__GLXclientState *cl, unsigned screen,
+ GLboolean do_swap)
+{
+ ClientPtr client = cl->client;
+ xGLXGetVisualConfigsReply reply;
+ __GLXscreenInfo *pGlxScreen;
+ __GLcontextModes *modes;
+ CARD32 buf[__GLX_TOTAL_CONFIG];
+ int p;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ if (screen >= screenInfo.numScreens) {
+ /* The client library must send a valid screen number. */
+ client->errorValue = screen;
+ return BadValue;
+ }
+ pGlxScreen = &__glXActiveScreens[screen];
+
+ reply.numVisuals = pGlxScreen->numUsableVisuals;
+ reply.numProps = __GLX_TOTAL_CONFIG;
+ reply.length = (pGlxScreen->numUsableVisuals * __GLX_SIZE_CARD32 *
+ __GLX_TOTAL_CONFIG) >> 2;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if ( do_swap ) {
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.numVisuals);
+ __GLX_SWAP_INT(&reply.numProps);
+ }
+
+ WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char *)&reply);
+
+ for ( modes = pGlxScreen->modes ; modes != NULL ; modes = modes->next ) {
+ if (modes->visualID == 0) {
+ /* not a usable visual */
+ continue;
+ }
+ p = 0;
+ buf[p++] = modes->visualID;
+ buf[p++] = _gl_convert_to_x_visual_type( modes->visualType );
+ buf[p++] = modes->rgbMode;
+
+ buf[p++] = modes->redBits;
+ buf[p++] = modes->greenBits;
+ buf[p++] = modes->blueBits;
+ buf[p++] = modes->alphaBits;
+ buf[p++] = modes->accumRedBits;
+ buf[p++] = modes->accumGreenBits;
+ buf[p++] = modes->accumBlueBits;
+ buf[p++] = modes->accumAlphaBits;
+
+ buf[p++] = modes->doubleBufferMode;
+ buf[p++] = modes->stereoMode;
+
+ buf[p++] = modes->rgbBits;
+ buf[p++] = modes->depthBits;
+ buf[p++] = modes->stencilBits;
+ buf[p++] = modes->numAuxBuffers;
+ buf[p++] = modes->level;
+ /*
+ ** Add token/value pairs for extensions.
+ */
+ buf[p++] = GLX_VISUAL_CAVEAT_EXT;
+ buf[p++] = modes->visualRating;
+ buf[p++] = GLX_TRANSPARENT_TYPE;
+ buf[p++] = modes->transparentPixel;
+ buf[p++] = GLX_TRANSPARENT_RED_VALUE;
+ buf[p++] = modes->transparentRed;
+ buf[p++] = GLX_TRANSPARENT_GREEN_VALUE;
+ buf[p++] = modes->transparentGreen;
+ buf[p++] = GLX_TRANSPARENT_BLUE_VALUE;
+ buf[p++] = modes->transparentBlue;
+ buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE;
+ buf[p++] = modes->transparentAlpha;
+ buf[p++] = GLX_TRANSPARENT_INDEX_VALUE;
+ buf[p++] = modes->transparentIndex;
+
+ if ( do_swap ) {
+ __GLX_SWAP_INT_ARRAY(buf, __GLX_TOTAL_CONFIG);
+ }
+ WriteToClient(client, __GLX_SIZE_CARD32 * __GLX_TOTAL_CONFIG,
+ (char *)buf);
+ }
+ return Success;
+}
+
+int __glXGetVisualConfigs(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
+ return DoGetVisualConfigs( cl, req->screen, GL_FALSE );
+}
+
+
+
+#define __GLX_TOTAL_FBCONFIG_ATTRIBS (28)
+#define __GLX_FBCONFIG_ATTRIBS_LENGTH (__GLX_TOTAL_FBCONFIG_ATTRIBS * 2)
+/**
+ * Send the set of GLXFBConfigs to the client. There is not currently
+ * and interface into the driver on the server-side to get GLXFBConfigs,
+ * so we "invent" some based on the \c __GLXvisualConfig structures that
+ * the driver does supply.
+ *
+ * The reply format for both \c glXGetFBConfigs and \c glXGetFBConfigsSGIX
+ * is the same, so this routine pulls double duty.
+ */
+
+int DoGetFBConfigs(__GLXclientState *cl, unsigned screen, GLboolean do_swap)
+{
+ ClientPtr client = cl->client;
+ xGLXGetFBConfigsReply reply;
+ __GLXscreenInfo *pGlxScreen;
+ CARD32 buf[__GLX_FBCONFIG_ATTRIBS_LENGTH];
+ int p;
+ __GLcontextModes *modes;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+
+ if (screen >= screenInfo.numScreens) {
+ /* The client library must send a valid screen number. */
+ client->errorValue = screen;
+ return BadValue;
+ }
+ pGlxScreen = &__glXActiveScreens[screen];
+
+ reply.numFBConfigs = pGlxScreen->numUsableVisuals;
+ reply.numAttribs = __GLX_TOTAL_FBCONFIG_ATTRIBS;
+ reply.length = (__GLX_FBCONFIG_ATTRIBS_LENGTH * reply.numFBConfigs);
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if ( do_swap ) {
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.numFBConfigs);
+ __GLX_SWAP_INT(&reply.numAttribs);
+ }
+
+ WriteToClient(client, sz_xGLXGetFBConfigsReply, (char *)&reply);
+
+ for ( modes = pGlxScreen->modes ; modes != NULL ; modes = modes->next ) {
+ if (modes->visualID == 0) {
+ /* not a usable visual */
+ continue;
+ }
+ p = 0;
+
+#define WRITE_PAIR(tag,value) \
+ do { buf[p++] = tag ; buf[p++] = value ; } while( 0 )
+
+ WRITE_PAIR( GLX_VISUAL_ID, modes->visualID );
+ WRITE_PAIR( GLX_FBCONFIG_ID, modes->visualID );
+ WRITE_PAIR( GLX_X_RENDERABLE, GL_TRUE );
+
+ WRITE_PAIR( GLX_RGBA, modes->rgbMode );
+ WRITE_PAIR( GLX_DOUBLEBUFFER, modes->doubleBufferMode );
+ WRITE_PAIR( GLX_STEREO, modes->stereoMode );
+
+ WRITE_PAIR( GLX_BUFFER_SIZE, modes->rgbBits );
+ WRITE_PAIR( GLX_LEVEL, modes->level );
+ WRITE_PAIR( GLX_AUX_BUFFERS, modes->numAuxBuffers );
+ WRITE_PAIR( GLX_RED_SIZE, modes->redBits );
+ WRITE_PAIR( GLX_GREEN_SIZE, modes->greenBits );
+ WRITE_PAIR( GLX_BLUE_SIZE, modes->blueBits );
+ WRITE_PAIR( GLX_ALPHA_SIZE, modes->alphaBits );
+ WRITE_PAIR( GLX_ACCUM_RED_SIZE, modes->accumRedBits );
+ WRITE_PAIR( GLX_ACCUM_GREEN_SIZE, modes->accumGreenBits );
+ WRITE_PAIR( GLX_ACCUM_BLUE_SIZE, modes->accumBlueBits );
+ WRITE_PAIR( GLX_ACCUM_ALPHA_SIZE, modes->accumAlphaBits );
+ WRITE_PAIR( GLX_DEPTH_SIZE, modes->depthBits );
+ WRITE_PAIR( GLX_STENCIL_SIZE, modes->stencilBits );
+
+ WRITE_PAIR( GLX_X_VISUAL_TYPE, modes->visualType );
+
+ /*
+ ** Add token/value pairs for extensions.
+ */
+ WRITE_PAIR( GLX_CONFIG_CAVEAT, modes->visualRating );
+ WRITE_PAIR( GLX_TRANSPARENT_TYPE, modes->transparentPixel );
+ WRITE_PAIR( GLX_TRANSPARENT_RED_VALUE, modes->transparentRed );
+ WRITE_PAIR( GLX_TRANSPARENT_GREEN_VALUE, modes->transparentGreen );
+ WRITE_PAIR( GLX_TRANSPARENT_BLUE_VALUE, modes->transparentBlue );
+ WRITE_PAIR( GLX_TRANSPARENT_ALPHA_VALUE, modes->transparentAlpha );
+ WRITE_PAIR( GLX_TRANSPARENT_INDEX_VALUE, modes->transparentIndex );
+ WRITE_PAIR( GLX_SWAP_METHOD_OML, modes->swapMethod );
+
+ if ( do_swap ) {
+ __GLX_SWAP_INT_ARRAY(buf, __GLX_FBCONFIG_ATTRIBS_LENGTH);
+ }
+ WriteToClient(client, __GLX_SIZE_CARD32 * __GLX_FBCONFIG_ATTRIBS_LENGTH,
+ (char *)buf);
+ }
+ return Success;
+}
+
+
+int __glXGetFBConfigs(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
+ return DoGetFBConfigs( cl, req->screen, GL_FALSE );
+}
+
+
+int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc;
+ return DoGetFBConfigs( cl, req->screen, GL_FALSE );
+}
+
+
+/*
+** Create a GLX Pixmap from an X Pixmap.
+*/
+int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual,
+ GLuint screenNum, XID pixmapId, XID glxpixmapId)
+{
+ ClientPtr client = cl->client;
+ DrawablePtr pDraw;
+ ScreenPtr pScreen;
+ VisualPtr pVisual;
+ __GLXpixmap *pGlxPixmap;
+ __GLXscreenInfo *pGlxScreen;
+ __GLcontextModes *modes;
+ int i;
+
+ LEGAL_NEW_RESOURCE(glxpixmapId, client);
+
+ pDraw = (DrawablePtr) LookupDrawable(pixmapId, client);
+ if (!pDraw || pDraw->type != DRAWABLE_PIXMAP) {
+ client->errorValue = pixmapId;
+ return BadPixmap;
+ }
+
+ /*
+ ** Check if screen of visual matches screen of pixmap.
+ */
+ pScreen = pDraw->pScreen;
+ if (screenNum != pScreen->myNum) {
+ return BadMatch;
+ }
+
+ /*
+ ** Find the VisualRec for this visual.
+ */
+ pVisual = pScreen->visuals;
+ for (i=0; i < pScreen->numVisuals; i++, pVisual++) {
+ if (pVisual->vid == visual) {
+ break;
+ }
+ }
+ if (i == pScreen->numVisuals) {
+ client->errorValue = visual;
+ return BadValue;
+ }
+ /*
+ ** Check if depth of visual matches depth of pixmap.
+ */
+ if (pVisual->nplanes != pDraw->depth) {
+ return BadMatch;
+ }
+
+ /*
+ ** Get configuration of the visual.
+ */
+ pGlxScreen = &__glXActiveScreens[screenNum];
+ modes = _gl_context_modes_find_visual( pGlxScreen->modes, visual );
+ if (modes == NULL) {
+ /*
+ ** Visual not support on this screen by this OpenGL implementation.
+ */
+ client->errorValue = visual;
+ return BadValue;
+ }
+
+ pGlxPixmap = (__GLXpixmap *) __glXMalloc(sizeof(__GLXpixmap));
+ if (!pGlxPixmap) {
+ return BadAlloc;
+ }
+ if (!(AddResource(glxpixmapId, __glXPixmapRes, pGlxPixmap))) {
+ return BadAlloc;
+ }
+ pGlxPixmap->pDraw = pDraw;
+ pGlxPixmap->pGlxScreen = pGlxScreen;
+ pGlxPixmap->pScreen = pScreen;
+ pGlxPixmap->idExists = True;
+ pGlxPixmap->refcnt = 0;
+
+ pGlxPixmap->modes = modes;
+
+ /*
+ ** Bump the ref count on the X pixmap so it won't disappear.
+ */
+ ((PixmapPtr) pDraw)->refcnt++;
+
+ return Success;
+}
+
+int __glXCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
+ return DoCreateGLXPixmap( cl, req->visual, req->screen,
+ req->pixmap, req->glxpixmap );
+}
+
+int __glXCreatePixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
+ return DoCreateGLXPixmap( cl, req->fbconfig, req->screen,
+ req->pixmap, req->glxpixmap );
+}
+
+int __glXCreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateGLXPixmapWithConfigSGIXReq *req =
+ (xGLXCreateGLXPixmapWithConfigSGIXReq *) pc;
+ return DoCreateGLXPixmap( cl, req->fbconfig, req->screen,
+ req->pixmap, req->glxpixmap );
+}
+
+
+/**
+ * Destroy a GLX pixmap. This function is used for both
+ * \c glXDestroyGLXPixmap and \c glXDestroyPixmap.
+ */
+
+int __glXDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
+ XID glxpixmap = req->glxpixmap;
+
+ /*
+ ** Check if it's a valid GLX pixmap.
+ */
+ if (!LookupIDByType(glxpixmap, __glXPixmapRes)) {
+ client->errorValue = glxpixmap;
+ return __glXBadPixmap;
+ }
+ FreeResource(glxpixmap, FALSE);
+ return Success;
+}
+
+/*****************************************************************************/
+
+/*
+** NOTE: There is no portable implementation for swap buffers as of
+** this time that is of value. Consequently, this code must be
+** implemented by somebody other than SGI.
+*/
+int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ DrawablePtr pDraw;
+ xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc;
+ GLXContextTag tag = req->contextTag;
+ XID drawId = req->drawable;
+ __GLXpixmap *pGlxPixmap;
+ __GLXcontext *glxc = NULL;
+ int error;
+
+ /*
+ ** Check that the GLX drawable is valid.
+ */
+ pDraw = (DrawablePtr) LookupDrawable(drawId, client);
+ if (pDraw) {
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ /*
+ ** Drawable is an X window.
+ */
+ } else {
+ /*
+ ** Drawable is an X pixmap, which is not allowed.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ } else {
+ pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId,
+ __glXPixmapRes);
+ if (pGlxPixmap) {
+ /*
+ ** Drawable is a GLX pixmap.
+ */
+ } else {
+ /*
+ ** Drawable is neither a X window nor a GLX pixmap.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ }
+
+ if (tag) {
+ glxc = __glXLookupContextByTag(cl, tag);
+ if (!glxc) {
+ return __glXBadContextTag;
+ }
+ /*
+ ** The calling thread is swapping its current drawable. In this case,
+ ** glxSwapBuffers is in both GL and X streams, in terms of
+ ** sequentiality.
+ */
+ if (__glXForceCurrent(cl, tag, &error)) {
+ /*
+ ** Do whatever is needed to make sure that all preceding requests
+ ** in both streams are completed before the swap is executed.
+ */
+ glFinish();
+ __GLX_NOTE_FLUSHED_CMDS(glxc);
+ } else {
+ return error;
+ }
+ }
+
+ if (pDraw) {
+ __GLXdrawablePrivate *glxPriv;
+
+ if (glxc) {
+ glxPriv = __glXGetDrawablePrivate(pDraw, drawId, glxc->modes);
+ if (glxPriv == NULL) {
+ return __glXBadDrawable;
+ }
+ }
+ else {
+ glxPriv = __glXFindDrawablePrivate(drawId);
+ if (glxPriv == NULL) {
+ /* This is a window we've never seen before, do nothing */
+ return Success;
+ }
+ }
+
+ if ((*glxPriv->swapBuffers)(glxPriv) == GL_FALSE) {
+ return __glXBadDrawable;
+ }
+ }
+
+ return Success;
+}
+
+
+int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ __GLXcontext *ctx;
+ xGLXQueryContextInfoEXTReq *req;
+ xGLXQueryContextInfoEXTReply reply;
+ int nProps;
+ int *sendBuf, *pSendBuf;
+ int nReplyBytes;
+
+ req = (xGLXQueryContextInfoEXTReq *)pc;
+ ctx = (__GLXcontext *) LookupIDByType(req->context, __glXContextRes);
+ if (!ctx) {
+ client->errorValue = req->context;
+ return __glXBadContext;
+ }
+
+ nProps = 3;
+ reply.length = nProps << 1;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.n = nProps;
+
+ nReplyBytes = reply.length << 2;
+ sendBuf = (int *)__glXMalloc((size_t)nReplyBytes);
+ if (sendBuf == NULL) {
+ return __glXBadContext; /* XXX: Is this correct? */
+ }
+ pSendBuf = sendBuf;
+ *pSendBuf++ = GLX_SHARE_CONTEXT_EXT;
+ *pSendBuf++ = (int)(ctx->share_id);
+ *pSendBuf++ = GLX_VISUAL_ID_EXT;
+ *pSendBuf++ = (int)(ctx->pVisual->vid);
+ *pSendBuf++ = GLX_SCREEN_EXT;
+ *pSendBuf++ = (int)(ctx->pScreen->myNum);
+
+ if (client->swapped) {
+ __glXSwapQueryContextInfoEXTReply(client, &reply, sendBuf);
+ } else {
+ WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, (char *)&reply);
+ WriteToClient(client, nReplyBytes, (char *)sendBuf);
+ }
+ __glXFree((char *)sendBuf);
+
+ return Success;
+}
+
+
+/************************************************************************/
+
+/*
+** Render and Renderlarge are not in the GLX API. They are used by the GLX
+** client library to send batches of GL rendering commands.
+*/
+
+/*
+** Execute all the drawing commands in a request.
+*/
+int __glXRender(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXRenderReq *req;
+ ClientPtr client= cl->client;
+ int left, cmdlen, error;
+ int commandsDone;
+ CARD16 opcode;
+ __GLXrenderHeader *hdr;
+ __GLXcontext *glxc;
+
+ /*
+ ** NOTE: much of this code also appears in the byteswapping version of this
+ ** routine, __glXSwapRender(). Any changes made here should also be
+ ** duplicated there.
+ */
+
+ req = (xGLXRenderReq *) pc;
+ glxc = __glXForceCurrent(cl, req->contextTag, &error);
+ if (!glxc) {
+ return error;
+ }
+
+ commandsDone = 0;
+ pc += sz_xGLXRenderReq;
+ left = (req->length << 2) - sz_xGLXRenderReq;
+ while (left > 0) {
+ __GLXrenderSizeData *entry;
+ int extra;
+ void (* proc)(GLbyte *);
+
+ /*
+ ** Verify that the header length and the overall length agree.
+ ** Also, each command must be word aligned.
+ */
+ hdr = (__GLXrenderHeader *) pc;
+ cmdlen = hdr->length;
+ opcode = hdr->opcode;
+
+ /*
+ ** Check for core opcodes and grab entry data.
+ */
+ if ( (opcode >= __GLX_MIN_RENDER_OPCODE) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE) ) {
+ entry = &__glXRenderSizeTable[opcode];
+ proc = __glXRenderTable[opcode];
+#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT
+ } else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) {
+ entry =
+ &__glXRenderSizeTable_EXT[opcode -
+ __GLX_MIN_RENDER_OPCODE_EXT];
+ proc = __glXRenderTable_EXT[opcode -
+ __GLX_MIN_RENDER_OPCODE_EXT];
+#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */
+ } else {
+ client->errorValue = commandsDone;
+ return __glXBadRenderRequest;
+ }
+
+ if (!entry->bytes) {
+ /* unused opcode */
+ client->errorValue = commandsDone;
+ return __glXBadRenderRequest;
+ }
+ if (entry->varsize) {
+ /* variable size command */
+ extra = (*entry->varsize)(pc + __GLX_RENDER_HDR_SIZE, False);
+ if (extra < 0) {
+ extra = 0;
+ }
+ if (cmdlen != __GLX_PAD(entry->bytes + extra)) {
+ return BadLength;
+ }
+ } else {
+ /* constant size command */
+ if (cmdlen != __GLX_PAD(entry->bytes)) {
+ return BadLength;
+ }
+ }
+ if (left < cmdlen) {
+ return BadLength;
+ }
+
+ /*
+ ** Skip over the header and execute the command. We allow the
+ ** caller to trash the command memory. This is useful especially
+ ** for things that require double alignment - they can just shift
+ ** the data towards lower memory (trashing the header) by 4 bytes
+ ** and achieve the required alignment.
+ */
+ (*proc)(pc + __GLX_RENDER_HDR_SIZE);
+ pc += cmdlen;
+ left -= cmdlen;
+ commandsDone++;
+ }
+ __GLX_NOTE_UNFLUSHED_CMDS(glxc);
+ return Success;
+}
+
+/*
+** Execute a large rendering request (one that spans multiple X requests).
+*/
+int __glXRenderLarge(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXRenderLargeReq *req;
+ ClientPtr client= cl->client;
+ GLuint dataBytes;
+ void (*proc)(GLbyte *);
+ __GLXrenderLargeHeader *hdr;
+ __GLXcontext *glxc;
+ int error;
+ CARD16 opcode;
+
+ /*
+ ** NOTE: much of this code also appears in the byteswapping version of this
+ ** routine, __glXSwapRenderLarge(). Any changes made here should also be
+ ** duplicated there.
+ */
+
+ req = (xGLXRenderLargeReq *) pc;
+ glxc = __glXForceCurrent(cl, req->contextTag, &error);
+ if (!glxc) {
+ /* Reset in case this isn't 1st request. */
+ __glXResetLargeCommandStatus(cl);
+ return error;
+ }
+ dataBytes = req->dataBytes;
+
+ /*
+ ** Check the request length.
+ */
+ if ((req->length << 2) != __GLX_PAD(dataBytes) + sz_xGLXRenderLargeReq) {
+ client->errorValue = req->length;
+ /* Reset in case this isn't 1st request. */
+ __glXResetLargeCommandStatus(cl);
+ return BadLength;
+ }
+ pc += sz_xGLXRenderLargeReq;
+
+ if (cl->largeCmdRequestsSoFar == 0) {
+ __GLXrenderSizeData *entry;
+ int extra, cmdlen;
+ /*
+ ** This is the first request of a multi request command.
+ ** Make enough space in the buffer, then copy the entire request.
+ */
+ if (req->requestNumber != 1) {
+ client->errorValue = req->requestNumber;
+ return __glXBadLargeRequest;
+ }
+
+ hdr = (__GLXrenderLargeHeader *) pc;
+ cmdlen = hdr->length;
+ opcode = hdr->opcode;
+
+ /*
+ ** Check for core opcodes and grab entry data.
+ */
+ if ( (opcode >= __GLX_MIN_RENDER_OPCODE) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE) ) {
+ entry = &__glXRenderSizeTable[opcode];
+#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT
+ } else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) {
+ opcode -= __GLX_MIN_RENDER_OPCODE_EXT;
+ entry = &__glXRenderSizeTable_EXT[opcode];
+#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */
+ } else {
+ client->errorValue = opcode;
+ return __glXBadLargeRequest;
+ }
+
+ if (!entry->bytes) {
+ /* unused opcode */
+ client->errorValue = opcode;
+ return __glXBadLargeRequest;
+ }
+ if (entry->varsize) {
+ /*
+ ** If it's a variable-size command (a command whose length must
+ ** be computed from its parameters), all the parameters needed
+ ** will be in the 1st request, so it's okay to do this.
+ */
+ extra = (*entry->varsize)(pc + __GLX_RENDER_LARGE_HDR_SIZE, False);
+ if (extra < 0) {
+ extra = 0;
+ }
+ /* large command's header is 4 bytes longer, so add 4 */
+ if (cmdlen != __GLX_PAD(entry->bytes + 4 + extra)) {
+ return BadLength;
+ }
+ } else {
+ /* constant size command */
+ if (cmdlen != __GLX_PAD(entry->bytes + 4)) {
+ return BadLength;
+ }
+ }
+ /*
+ ** Make enough space in the buffer, then copy the entire request.
+ */
+ if (cl->largeCmdBufSize < cmdlen) {
+ if (!cl->largeCmdBuf) {
+ cl->largeCmdBuf = (GLbyte *) __glXMalloc((size_t)cmdlen);
+ } else {
+ cl->largeCmdBuf = (GLbyte *) __glXRealloc(cl->largeCmdBuf,
+ (size_t)cmdlen);
+ }
+ if (!cl->largeCmdBuf) {
+ return BadAlloc;
+ }
+ cl->largeCmdBufSize = cmdlen;
+ }
+ __glXMemcpy(cl->largeCmdBuf, pc, dataBytes);
+
+ cl->largeCmdBytesSoFar = dataBytes;
+ cl->largeCmdBytesTotal = cmdlen;
+ cl->largeCmdRequestsSoFar = 1;
+ cl->largeCmdRequestsTotal = req->requestTotal;
+ return Success;
+
+ } else {
+ /*
+ ** We are receiving subsequent (i.e. not the first) requests of a
+ ** multi request command.
+ */
+
+ /*
+ ** Check the request number and the total request count.
+ */
+ if (req->requestNumber != cl->largeCmdRequestsSoFar + 1) {
+ client->errorValue = req->requestNumber;
+ __glXResetLargeCommandStatus(cl);
+ return __glXBadLargeRequest;
+ }
+ if (req->requestTotal != cl->largeCmdRequestsTotal) {
+ client->errorValue = req->requestTotal;
+ __glXResetLargeCommandStatus(cl);
+ return __glXBadLargeRequest;
+ }
+
+ /*
+ ** Check that we didn't get too much data.
+ */
+ if ((cl->largeCmdBytesSoFar + dataBytes) > cl->largeCmdBytesTotal) {
+ client->errorValue = dataBytes;
+ __glXResetLargeCommandStatus(cl);
+ return __glXBadLargeRequest;
+ }
+ __glXMemcpy(cl->largeCmdBuf + cl->largeCmdBytesSoFar, pc, dataBytes);
+ cl->largeCmdBytesSoFar += dataBytes;
+ cl->largeCmdRequestsSoFar++;
+
+ if (req->requestNumber == cl->largeCmdRequestsTotal) {
+ /*
+ ** This is the last request; it must have enough bytes to complete
+ ** the command.
+ */
+ /* NOTE: the two pad macros have been added below; they are needed
+ ** because the client library pads the total byte count, but not
+ ** the per-request byte counts. The Protocol Encoding says the
+ ** total byte count should not be padded, so a proposal will be
+ ** made to the ARB to relax the padding constraint on the total
+ ** byte count, thus preserving backward compatibility. Meanwhile,
+ ** the padding done below fixes a bug that did not allow
+ ** large commands of odd sizes to be accepted by the server.
+ */
+ if (__GLX_PAD(cl->largeCmdBytesSoFar) !=
+ __GLX_PAD(cl->largeCmdBytesTotal)) {
+ client->errorValue = dataBytes;
+ __glXResetLargeCommandStatus(cl);
+ return __glXBadLargeRequest;
+ }
+ hdr = (__GLXrenderLargeHeader *) cl->largeCmdBuf;
+ opcode = hdr->opcode;
+
+ /*
+ ** Use the opcode to index into the procedure table.
+ */
+ if ( (opcode >= __GLX_MIN_RENDER_OPCODE) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE) ) {
+ proc = __glXRenderTable[opcode];
+#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT
+ } else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) {
+ opcode -= __GLX_MIN_RENDER_OPCODE_EXT;
+ proc = __glXRenderTable_EXT[opcode];
+#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */
+ } else {
+ client->errorValue = opcode;
+ return __glXBadLargeRequest;
+ }
+
+ /*
+ ** Skip over the header and execute the command.
+ */
+ (*proc)(cl->largeCmdBuf + __GLX_RENDER_LARGE_HDR_SIZE);
+ __GLX_NOTE_UNFLUSHED_CMDS(glxc);
+
+ /*
+ ** Reset for the next RenderLarge series.
+ */
+ __glXResetLargeCommandStatus(cl);
+ } else {
+ /*
+ ** This is neither the first nor the last request.
+ */
+ }
+ return Success;
+ }
+}
+
+extern RESTYPE __glXSwapBarrierRes;
+
+static int __glXBindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXBindSwapBarrierSGIXReq *req = (xGLXBindSwapBarrierSGIXReq *) pc;
+ XID drawable = req->drawable;
+ int barrier = req->barrier;
+ DrawablePtr pDraw = (DrawablePtr) LookupDrawable(drawable, client);
+ int screen = pDraw->pScreen->myNum;
+
+
+ if (pDraw && (pDraw->type == DRAWABLE_WINDOW)) {
+ if (__glXSwapBarrierFuncs &&
+ __glXSwapBarrierFuncs[screen].bindSwapBarrierFunc) {
+ int ret = __glXSwapBarrierFuncs[screen].bindSwapBarrierFunc(screen, drawable, barrier);
+ if (ret == Success) {
+ if (barrier)
+ /* add source for cleanup when drawable is gone */
+ AddResource(drawable, __glXSwapBarrierRes, (pointer)screen);
+ else
+ /* delete source */
+ FreeResourceByType(drawable, __glXSwapBarrierRes, FALSE);
+ }
+ return ret;
+ }
+ }
+ client->errorValue = drawable;
+ return __glXBadDrawable;
+}
+
+
+static int __glXQueryMaxSwapBarriersSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXQueryMaxSwapBarriersSGIXReq *req =
+ (xGLXQueryMaxSwapBarriersSGIXReq *) pc;
+ xGLXQueryMaxSwapBarriersSGIXReply reply;
+ int screen = req->screen;
+
+ if (__glXSwapBarrierFuncs &&
+ __glXSwapBarrierFuncs[screen].queryMaxSwapBarriersFunc)
+ reply.max = __glXSwapBarrierFuncs[screen].queryMaxSwapBarriersFunc(screen);
+ else
+ reply.max = 0;
+
+
+ reply.length = 0;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (client->swapped) {
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ }
+
+ WriteToClient(client, sz_xGLXQueryMaxSwapBarriersSGIXReply,
+ (char *) &reply);
+ return Success;
+}
+
+#define GLX_BAD_HYPERPIPE_SGIX 92
+
+static int __glxQueryHyperpipeNetworkSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXQueryHyperpipeNetworkSGIXReq * req = (xGLXQueryHyperpipeNetworkSGIXReq *) pc;
+ xGLXQueryHyperpipeNetworkSGIXReply reply;
+ int screen = req->screen;
+ void *rdata = NULL;
+
+ int length=0;
+ int npipes=0;
+
+ int n= 0;
+
+ if (__glXHyperpipeFuncs &&
+ __glXHyperpipeFuncs[screen].queryHyperpipeNetworkFunc != NULL) {
+ rdata =
+ (__glXHyperpipeFuncs[screen].queryHyperpipeNetworkFunc(screen, &npipes, &n));
+ }
+ length = __GLX_PAD(n) >> 2;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = length;
+ reply.n = n;
+ reply.npipes = npipes;
+
+ if (client->swapped) {
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.n);
+ __GLX_SWAP_INT(&reply.npipes);
+ }
+ WriteToClient(client, sz_xGLXQueryHyperpipeNetworkSGIXReply,
+ (char *) &reply);
+
+ WriteToClient(client, length << 2, (char *)rdata);
+
+ return Success;
+}
+
+static int __glxDestroyHyperpipeConfigSGIX (__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXDestroyHyperpipeConfigSGIXReq * req =
+ (xGLXDestroyHyperpipeConfigSGIXReq *) pc;
+ xGLXDestroyHyperpipeConfigSGIXReply reply;
+ int screen = req->screen;
+ int success = GLX_BAD_HYPERPIPE_SGIX;
+ int hpId ;
+
+ hpId = req->hpId;
+
+
+ if (__glXHyperpipeFuncs &&
+ __glXHyperpipeFuncs[screen].destroyHyperpipeConfigFunc != NULL) {
+ success = __glXHyperpipeFuncs[screen].destroyHyperpipeConfigFunc(screen, hpId);
+ }
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = __GLX_PAD(0) >> 2;
+ reply.n = 0;
+ reply.success = success;
+
+
+ if (client->swapped) {
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ }
+ WriteToClient(client,
+ sz_xGLXDestroyHyperpipeConfigSGIXReply,
+ (char *) &reply);
+ return Success;
+}
+
+static int __glxQueryHyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXQueryHyperpipeConfigSGIXReq * req =
+ (xGLXQueryHyperpipeConfigSGIXReq *) pc;
+ xGLXQueryHyperpipeConfigSGIXReply reply;
+ int screen = req->screen;
+ void *rdata = NULL;
+ int length;
+ int npipes=0;
+ int n= 0;
+ int hpId;
+
+ hpId = req->hpId;
+
+ if (__glXHyperpipeFuncs &&
+ __glXHyperpipeFuncs[screen].queryHyperpipeConfigFunc != NULL) {
+ rdata = __glXHyperpipeFuncs[screen].queryHyperpipeConfigFunc(screen, hpId,&npipes, &n);
+ }
+
+ length = __GLX_PAD(n) >> 2;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = length;
+ reply.n = n;
+ reply.npipes = npipes;
+
+
+ if (client->swapped) {
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.n);
+ __GLX_SWAP_INT(&reply.npipes);
+ }
+
+ WriteToClient(client, sz_xGLXQueryHyperpipeConfigSGIXReply,
+ (char *) &reply);
+
+ WriteToClient(client, length << 2, (char *)rdata);
+
+ return Success;
+}
+
+static int __glxHyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXHyperpipeConfigSGIXReq * req =
+ (xGLXHyperpipeConfigSGIXReq *) pc;
+ xGLXHyperpipeConfigSGIXReply reply;
+ int screen = req->screen;
+ void *rdata;
+
+ int npipes=0, networkId;
+ int hpId=-1;
+
+ networkId = (int)req->networkId;
+ npipes = (int)req->npipes;
+ rdata = (void *)(req +1);
+
+ if (__glXHyperpipeFuncs &&
+ __glXHyperpipeFuncs[screen].hyperpipeConfigFunc != NULL) {
+ __glXHyperpipeFuncs[screen].hyperpipeConfigFunc(screen,networkId,
+ &hpId, &npipes,
+ (void *) rdata);
+ }
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = __GLX_PAD(0) >> 2;
+ reply.n = 0;
+ reply.npipes = npipes;
+ reply.hpId = hpId;
+
+ if (client->swapped) {
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.npipes);
+ __GLX_SWAP_INT(&reply.hpId);
+ }
+
+ WriteToClient(client, sz_xGLXHyperpipeConfigSGIXReply,
+ (char *) &reply);
+
+ return Success;
+}
+
+
+/************************************************************************/
+
+/*
+** No support is provided for the vendor-private requests other than
+** allocating the entry points in the dispatch table.
+*/
+
+int __glXVendorPrivate(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateReq *req;
+ GLint vendorcode;
+
+ req = (xGLXVendorPrivateReq *) pc;
+ vendorcode = req->vendorCode;
+
+#ifndef __DARWIN__
+ switch( vendorcode ) {
+ case X_GLvop_SampleMaskSGIS:
+ glSampleMaskSGIS(*(GLfloat *)(pc + 4),
+ *(GLboolean *)(pc + 8));
+ return Success;
+ case X_GLvop_SamplePatternSGIS:
+ glSamplePatternSGIS( *(GLenum *)(pc + 4));
+ return Success;
+ case X_GLXvop_BindSwapBarrierSGIX:
+ return __glXBindSwapBarrierSGIX(cl, pc);
+ }
+#endif
+
+ if ((vendorcode >= __GLX_MIN_VENDPRIV_OPCODE_EXT) &&
+ (vendorcode <= __GLX_MAX_VENDPRIV_OPCODE_EXT)) {
+ (*__glXVendorPrivTable_EXT[vendorcode-__GLX_MIN_VENDPRIV_OPCODE_EXT])
+ (cl, (GLbyte*)req);
+ return Success;
+ }
+ /*
+ ** This sample implemention does not support any private requests.
+ */
+ cl->client->errorValue = req->vendorCode;
+ return __glXUnsupportedPrivateRequest;
+}
+
+int __glXVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateWithReplyReq *req;
+ GLint vendorcode;
+
+ req = (xGLXVendorPrivateWithReplyReq *) pc;
+ vendorcode = req->vendorCode;
+
+ switch (vendorcode) {
+ case X_GLXvop_QueryContextInfoEXT:
+ return __glXQueryContextInfoEXT(cl, pc);
+ case X_GLXvop_MakeCurrentReadSGI:
+ return __glXMakeCurrentReadSGI(cl, pc);
+ case X_GLXvop_QueryMaxSwapBarriersSGIX:
+ return __glXQueryMaxSwapBarriersSGIX(cl, pc);
+ case X_GLXvop_QueryHyperpipeNetworkSGIX:
+ return __glxQueryHyperpipeNetworkSGIX(cl, pc);
+ case X_GLXvop_QueryHyperpipeConfigSGIX:
+ return __glxQueryHyperpipeConfigSGIX(cl, pc);
+ case X_GLXvop_DestroyHyperpipeConfigSGIX:
+ return __glxDestroyHyperpipeConfigSGIX(cl, pc);
+ case X_GLXvop_HyperpipeConfigSGIX:
+ return __glxHyperpipeConfigSGIX(cl, pc);
+ case X_GLXvop_GetFBConfigsSGIX:
+ return __glXGetFBConfigsSGIX(cl, pc);
+ case X_GLXvop_CreateContextWithConfigSGIX:
+ return __glXCreateContextWithConfigSGIX(cl, pc);
+ case X_GLXvop_CreateGLXPixmapWithConfigSGIX:
+ return __glXCreateGLXPixmapWithConfigSGIX(cl, pc);
+ default:
+ break;
+ }
+
+ if ((vendorcode >= __GLX_MIN_VENDPRIV_OPCODE_EXT) &&
+ (vendorcode <= __GLX_MAX_VENDPRIV_OPCODE_EXT)) {
+ return
+ (*__glXVendorPrivTable_EXT[vendorcode-__GLX_MIN_VENDPRIV_OPCODE_EXT])
+ (cl, (GLbyte*)req);
+ }
+
+ cl->client->errorValue = vendorcode;
+ return __glXUnsupportedPrivateRequest;
+}
+
+int __glXQueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *) pc;
+ xGLXQueryExtensionsStringReply reply;
+ GLuint screen;
+ size_t n, length;
+ const char *ptr;
+ char *buf;
+
+ screen = req->screen;
+ /*
+ ** Check if screen exists.
+ */
+ if (screen >= screenInfo.numScreens) {
+ client->errorValue = screen;
+ return BadValue;
+ }
+
+ ptr = __glXActiveScreens[screen].GLXextensions;
+
+ n = __glXStrlen(ptr) + 1;
+ length = __GLX_PAD(n) >> 2;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = length;
+ reply.n = n;
+
+ if ((buf = (char *) __glXMalloc(length << 2)) == NULL) {
+ return BadAlloc;
+ }
+ __glXStrncpy(buf, ptr, n);
+
+ if (client->swapped) {
+ glxSwapQueryExtensionsStringReply(client, &reply, buf);
+ } else {
+ WriteToClient(client, sz_xGLXQueryExtensionsStringReply,(char *)&reply);
+ WriteToClient(client, (int)(length << 2), (char *)buf);
+ }
+
+ __glXFree(buf);
+ return Success;
+}
+
+int __glXQueryServerString(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) pc;
+ xGLXQueryServerStringReply reply;
+ int name;
+ GLuint screen;
+ size_t n, length;
+ const char *ptr;
+ char *buf;
+
+ name = req->name;
+ screen = req->screen;
+ /*
+ ** Check if screen exists.
+ */
+ if (screen >= screenInfo.numScreens) {
+ client->errorValue = screen;
+ return BadValue;
+ }
+ switch(name) {
+ case GLX_VENDOR:
+ ptr = __glXActiveScreens[screen].GLXvendor;
+ break;
+ case GLX_VERSION:
+ ptr = __glXActiveScreens[screen].GLXversion;
+ break;
+ case GLX_EXTENSIONS:
+ ptr = __glXActiveScreens[screen].GLXextensions;
+ break;
+ default:
+ return BadValue;
+ }
+
+ n = __glXStrlen(ptr) + 1;
+ length = __GLX_PAD(n) >> 2;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = length;
+ reply.n = n;
+
+ if ((buf = (char *) Xalloc(length << 2)) == NULL) {
+ return BadAlloc;
+ }
+ __glXStrncpy(buf, ptr, n);
+
+ if (client->swapped) {
+ glxSwapQueryServerStringReply(client, &reply, buf);
+ } else {
+ WriteToClient(client, sz_xGLXQueryServerStringReply, (char *)&reply);
+ WriteToClient(client, (int)(length << 2), buf);
+ }
+
+ __glXFree(buf);
+ return Success;
+}
+
+int __glXClientInfo(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXClientInfoReq *req = (xGLXClientInfoReq *) pc;
+ const char *buf;
+
+ cl->GLClientmajorVersion = req->major;
+ cl->GLClientminorVersion = req->minor;
+ if (cl->GLClientextensions) __glXFree(cl->GLClientextensions);
+ buf = (const char *)(req+1);
+ cl->GLClientextensions = __glXStrdup(buf);
+
+ return Success;
+}
+
diff --git a/nx-X11/programs/Xserver/GL/glx/glxcmdsswap.c b/nx-X11/programs/Xserver/GL/glx/glxcmdsswap.c
new file mode 100644
index 000000000..595e814e5
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxcmdsswap.c
@@ -0,0 +1,871 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxcmdsswap.c,v 1.10 2004/01/28 18:11:50 alanh Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define NEED_REPLIES
+#define FONT_PCF
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxutil.h"
+#include <GL/glxtokens.h>
+#include <unpack.h>
+#include <g_disptab.h>
+#include <g_disptab_EXT.h>
+#include <pixmapstr.h>
+#include <windowstr.h>
+#include "glxext.h"
+#include "GL/glx_ansic.h"
+
+static int __glXSwapGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc);
+static int __glXSwapCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc);
+static int __glXSwapCreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc);
+static int __glXSwapMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc);
+
+/************************************************************************/
+
+/*
+** Byteswapping versions of GLX commands. In most cases they just swap
+** the incoming arguments and then call the unswapped routine. For commands
+** that have replies, a separate swapping routine for the reply is provided;
+** it is called at the end of the unswapped routine.
+*/
+
+int __glXSwapCreateContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->visual);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->shareList);
+
+ return DoCreateContext( cl, req->context, req->shareList, req->visual,
+ req->screen, req->isDirect );
+}
+
+int __glXSwapCreateNewContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->renderType);
+ __GLX_SWAP_INT(&req->shareList);
+
+ return DoCreateContext( cl, req->context, req->shareList, req->fbconfig,
+ req->screen, req->isDirect );
+}
+
+int __glXSwapCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextWithConfigSGIXReq *req =
+ (xGLXCreateContextWithConfigSGIXReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->renderType);
+ __GLX_SWAP_INT(&req->shareList);
+
+ return DoCreateContext( cl, req->context, req->shareList, req->fbconfig,
+ req->screen, req->isDirect );
+}
+
+int __glXSwapDestroyContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+
+ return __glXDestroyContext(cl, pc);
+}
+
+int __glXSwapMakeCurrent(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->oldContextTag);
+
+ return DoMakeCurrent( cl, req->drawable, req->drawable,
+ req->context, req->oldContextTag );
+}
+
+int __glXSwapMakeContextCurrent(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+ __GLX_SWAP_INT(&req->readdrawable);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->oldContextTag);
+
+ return DoMakeCurrent( cl, req->drawable, req->readdrawable,
+ req->context, req->oldContextTag );
+}
+
+int __glXSwapMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+ __GLX_SWAP_INT(&req->readable);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->oldContextTag);
+
+ return DoMakeCurrent( cl, req->drawable, req->readable,
+ req->context, req->oldContextTag );
+}
+
+int __glXSwapIsDirect(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+
+ return __glXIsDirect(cl, pc);
+}
+
+int __glXSwapQueryVersion(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->majorVersion);
+ __GLX_SWAP_INT(&req->minorVersion);
+
+ return __glXQueryVersion(cl, pc);
+}
+
+int __glXSwapWaitGL(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXWaitGLReq *req = (xGLXWaitGLReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ return __glXWaitGL(cl, pc);
+}
+
+int __glXSwapWaitX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXWaitXReq *req = (xGLXWaitXReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ return __glXWaitX(cl, pc);
+}
+
+int __glXSwapCopyContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->source);
+ __GLX_SWAP_INT(&req->dest);
+ __GLX_SWAP_INT(&req->mask);
+
+ return __glXCopyContext(cl, pc);
+}
+
+int __glXSwapGetVisualConfigs(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&req->screen);
+ return DoGetVisualConfigs( cl, req->screen, GL_TRUE );
+}
+
+int __glXSwapGetFBConfigs(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&req->screen);
+ return DoGetFBConfigs( cl, req->screen, GL_TRUE );
+}
+
+int __glXSwapGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&req->screen);
+ return DoGetFBConfigs( cl, req->screen, GL_TRUE );
+}
+
+int __glXSwapCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->visual);
+ __GLX_SWAP_INT(&req->pixmap);
+ __GLX_SWAP_INT(&req->glxpixmap);
+
+ return DoCreateGLXPixmap( cl, req->visual, req->screen,
+ req->pixmap, req->glxpixmap );
+}
+
+int __glXSwapCreatePixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->pixmap);
+ __GLX_SWAP_INT(&req->glxpixmap);
+
+ return DoCreateGLXPixmap( cl, req->fbconfig, req->screen,
+ req->pixmap, req->glxpixmap );
+}
+
+int __glXSwapCreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateGLXPixmapWithConfigSGIXReq *req =
+ (xGLXCreateGLXPixmapWithConfigSGIXReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->pixmap);
+ __GLX_SWAP_INT(&req->glxpixmap);
+
+ return DoCreateGLXPixmap( cl, req->fbconfig, req->screen,
+ req->pixmap, req->glxpixmap );
+}
+
+int __glXSwapDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->glxpixmap);
+
+ return __glXDestroyGLXPixmap(cl, pc);
+}
+
+int __glXSwapSwapBuffers(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+ __GLX_SWAP_INT(&req->drawable);
+
+ return __glXSwapBuffers(cl, pc);
+}
+
+int __glXSwapUseXFont(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXUseXFontReq *req = (xGLXUseXFontReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+ __GLX_SWAP_INT(&req->font);
+ __GLX_SWAP_INT(&req->first);
+ __GLX_SWAP_INT(&req->count);
+ __GLX_SWAP_INT(&req->listBase);
+
+ return __glXUseXFont(cl, pc);
+}
+
+
+int __glXSwapQueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXQueryExtensionsStringReq *req = NULL;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+
+ return __glXQueryExtensionsString(cl, pc);
+}
+
+int __glXSwapQueryServerString(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->name);
+
+ return __glXQueryServerString(cl, pc);
+}
+
+int __glXSwapClientInfo(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXClientInfoReq *req = (xGLXClientInfoReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->major);
+ __GLX_SWAP_INT(&req->minor);
+ __GLX_SWAP_INT(&req->numbytes);
+
+ return __glXClientInfo(cl, pc);
+}
+
+int __glXSwapQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+
+ return __glXQueryContextInfoEXT(cl, pc);
+}
+
+/************************************************************************/
+
+/*
+** Swap replies.
+*/
+
+void __glXSwapMakeCurrentReply(ClientPtr client, xGLXMakeCurrentReply *reply)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->contextTag);
+ WriteToClient(client, sz_xGLXMakeCurrentReply, (char *)reply);
+}
+
+void __glXSwapIsDirectReply(ClientPtr client, xGLXIsDirectReply *reply)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ WriteToClient(client, sz_xGLXIsDirectReply, (char *)reply);
+}
+
+void __glXSwapQueryVersionReply(ClientPtr client, xGLXQueryVersionReply *reply)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->majorVersion);
+ __GLX_SWAP_INT(&reply->minorVersion);
+ WriteToClient(client, sz_xGLXQueryVersionReply, (char *)reply);
+}
+
+void glxSwapQueryExtensionsStringReply(ClientPtr client,
+ xGLXQueryExtensionsStringReply *reply, char *buf)
+{
+ int length = reply->length;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->n);
+ WriteToClient(client, sz_xGLXQueryExtensionsStringReply, (char *)reply);
+ __GLX_SWAP_INT_ARRAY((int *)buf, length);
+ WriteToClient(client, length << 2, buf);
+}
+
+void glxSwapQueryServerStringReply(ClientPtr client,
+ xGLXQueryServerStringReply *reply, char *buf)
+{
+ int length = reply->length;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->n);
+ WriteToClient(client, sz_xGLXQueryServerStringReply, (char *)reply);
+ /** no swap is needed for an array of chars **/
+ /* __GLX_SWAP_INT_ARRAY((int *)buf, length); */
+ WriteToClient(client, length << 2, buf);
+}
+
+void __glXSwapQueryContextInfoEXTReply(ClientPtr client, xGLXQueryContextInfoEXTReply *reply, int *buf)
+{
+ int length = reply->length;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->n);
+ WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, (char *)reply);
+ __GLX_SWAP_INT_ARRAY((int *)buf, length);
+ WriteToClient(client, length << 2, (char *)buf);
+}
+
+
+/************************************************************************/
+
+/*
+** Render and Renderlarge are not in the GLX API. They are used by the GLX
+** client library to send batches of GL rendering commands.
+*/
+
+int __glXSwapRender(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXRenderReq *req;
+ ClientPtr client= cl->client;
+ int left, cmdlen, error;
+ int commandsDone;
+ CARD16 opcode;
+ __GLXrenderHeader *hdr;
+ __GLXcontext *cx;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ /*
+ ** NOTE: much of this code also appears in the nonswapping version of this
+ ** routine, __glXRender(). Any changes made here should also be
+ ** duplicated there.
+ */
+
+ req = (xGLXRenderReq *) pc;
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ cx = __glXForceCurrent(cl, req->contextTag, &error);
+ if (!cx) {
+ return error;
+ }
+
+ commandsDone = 0;
+ pc += sz_xGLXRenderReq;
+ left = (req->length << 2) - sz_xGLXRenderReq;
+ while (left > 0) {
+ __GLXrenderSizeData *entry;
+ int extra;
+ void (* proc)(GLbyte *);
+
+ /*
+ ** Verify that the header length and the overall length agree.
+ ** Also, each command must be word aligned.
+ */
+ hdr = (__GLXrenderHeader *) pc;
+ __GLX_SWAP_SHORT(&hdr->length);
+ __GLX_SWAP_SHORT(&hdr->opcode);
+ cmdlen = hdr->length;
+ opcode = hdr->opcode;
+
+ if ( (opcode >= __GLX_MIN_RENDER_OPCODE) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE) ) {
+ entry = &__glXRenderSizeTable[opcode];
+ proc = __glXSwapRenderTable[opcode];
+#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT
+ } else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) {
+ int index = opcode - __GLX_MIN_RENDER_OPCODE_EXT;
+ entry = &__glXRenderSizeTable_EXT[index];
+ proc = __glXSwapRenderTable_EXT[index];
+#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */
+ } else {
+ client->errorValue = commandsDone;
+ return __glXBadRenderRequest;
+ }
+ if (!entry->bytes) {
+ /* unused opcode */
+ client->errorValue = commandsDone;
+ return __glXBadRenderRequest;
+ }
+ if (entry->varsize) {
+ /* variable size command */
+ extra = (*entry->varsize)(pc + __GLX_RENDER_HDR_SIZE, True);
+ if (extra < 0) {
+ extra = 0;
+ }
+ if (cmdlen != __GLX_PAD(entry->bytes + extra)) {
+ return BadLength;
+ }
+ } else {
+ /* constant size command */
+ if (cmdlen != __GLX_PAD(entry->bytes)) {
+ return BadLength;
+ }
+ }
+ if (left < cmdlen) {
+ return BadLength;
+ }
+
+ /*
+ ** Skip over the header and execute the command. We allow the
+ ** caller to trash the command memory. This is useful especially
+ ** for things that require double alignment - they can just shift
+ ** the data towards lower memory (trashing the header) by 4 bytes
+ ** and achieve the required alignment.
+ */
+ (*proc)(pc + __GLX_RENDER_HDR_SIZE);
+ pc += cmdlen;
+ left -= cmdlen;
+ commandsDone++;
+ }
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+/*
+** Execute a large rendering request (one that spans multiple X requests).
+*/
+int __glXSwapRenderLarge(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXRenderLargeReq *req;
+ ClientPtr client= cl->client;
+ size_t dataBytes;
+ void (*proc)(GLbyte *);
+ __GLXrenderLargeHeader *hdr;
+ __GLXcontext *cx;
+ int error;
+ CARD16 opcode;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ /*
+ ** NOTE: much of this code also appears in the nonswapping version of this
+ ** routine, __glXRenderLarge(). Any changes made here should also be
+ ** duplicated there.
+ */
+
+ req = (xGLXRenderLargeReq *) pc;
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+ __GLX_SWAP_INT(&req->dataBytes);
+ __GLX_SWAP_SHORT(&req->requestNumber);
+ __GLX_SWAP_SHORT(&req->requestTotal);
+ cx = __glXForceCurrent(cl, req->contextTag, &error);
+ if (!cx) {
+ /* Reset in case this isn't 1st request. */
+ __glXResetLargeCommandStatus(cl);
+ return error;
+ }
+ dataBytes = req->dataBytes;
+
+ /*
+ ** Check the request length.
+ */
+ if ((req->length << 2) != __GLX_PAD(dataBytes) + sz_xGLXRenderLargeReq) {
+ client->errorValue = req->length;
+ /* Reset in case this isn't 1st request. */
+ __glXResetLargeCommandStatus(cl);
+ return BadLength;
+ }
+ pc += sz_xGLXRenderLargeReq;
+
+ if (cl->largeCmdRequestsSoFar == 0) {
+ __GLXrenderSizeData *entry;
+ int extra;
+ size_t cmdlen;
+ /*
+ ** This is the first request of a multi request command.
+ ** Make enough space in the buffer, then copy the entire request.
+ */
+ if (req->requestNumber != 1) {
+ client->errorValue = req->requestNumber;
+ return __glXBadLargeRequest;
+ }
+ hdr = (__GLXrenderLargeHeader *) pc;
+ __GLX_SWAP_INT(&hdr->length);
+ __GLX_SWAP_INT(&hdr->opcode);
+ cmdlen = hdr->length;
+ opcode = hdr->opcode;
+
+ if ( (opcode >= __GLX_MIN_RENDER_OPCODE) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE) ) {
+ entry = &__glXRenderSizeTable[opcode];
+ proc = __glXSwapRenderTable[opcode];
+#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT
+ } else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) {
+ int index = opcode - __GLX_MIN_RENDER_OPCODE_EXT;
+ entry = &__glXRenderSizeTable_EXT[index];
+ proc = __glXSwapRenderTable_EXT[index];
+#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */
+ } else {
+ client->errorValue = opcode;
+ return __glXBadLargeRequest;
+ }
+
+ if (!entry->bytes) {
+ /* unused opcode */
+ client->errorValue = opcode;
+ return __glXBadLargeRequest;
+ }
+ if (entry->varsize) {
+ /*
+ ** If it's a variable-size command (a command whose length must
+ ** be computed from its parameters), all the parameters needed
+ ** will be in the 1st request, so it's okay to do this.
+ */
+ extra = (*entry->varsize)(pc + __GLX_RENDER_LARGE_HDR_SIZE, True);
+ if (extra < 0) {
+ extra = 0;
+ }
+ /* large command's header is 4 bytes longer, so add 4 */
+ if (cmdlen != __GLX_PAD(entry->bytes + 4 + extra)) {
+ return BadLength;
+ }
+ } else {
+ /* constant size command */
+ if (cmdlen != __GLX_PAD(entry->bytes + 4)) {
+ return BadLength;
+ }
+ }
+ /*
+ ** Make enough space in the buffer, then copy the entire request.
+ */
+ if (cl->largeCmdBufSize < cmdlen) {
+ if (!cl->largeCmdBuf) {
+ cl->largeCmdBuf = (GLbyte *) __glXMalloc(cmdlen);
+ } else {
+ cl->largeCmdBuf = (GLbyte *) __glXRealloc(cl->largeCmdBuf, cmdlen);
+ }
+ if (!cl->largeCmdBuf) {
+ return BadAlloc;
+ }
+ cl->largeCmdBufSize = cmdlen;
+ }
+ __glXMemcpy(cl->largeCmdBuf, pc, dataBytes);
+
+ cl->largeCmdBytesSoFar = dataBytes;
+ cl->largeCmdBytesTotal = cmdlen;
+ cl->largeCmdRequestsSoFar = 1;
+ cl->largeCmdRequestsTotal = req->requestTotal;
+ return Success;
+
+ } else {
+ /*
+ ** We are receiving subsequent (i.e. not the first) requests of a
+ ** multi request command.
+ */
+
+ /*
+ ** Check the request number and the total request count.
+ */
+ if (req->requestNumber != cl->largeCmdRequestsSoFar + 1) {
+ client->errorValue = req->requestNumber;
+ __glXResetLargeCommandStatus(cl);
+ return __glXBadLargeRequest;
+ }
+ if (req->requestTotal != cl->largeCmdRequestsTotal) {
+ client->errorValue = req->requestTotal;
+ __glXResetLargeCommandStatus(cl);
+ return __glXBadLargeRequest;
+ }
+
+ /*
+ ** Check that we didn't get too much data.
+ */
+ if ((cl->largeCmdBytesSoFar + dataBytes) > cl->largeCmdBytesTotal) {
+ client->errorValue = dataBytes;
+ __glXResetLargeCommandStatus(cl);
+ return __glXBadLargeRequest;
+ }
+ __glXMemcpy(cl->largeCmdBuf + cl->largeCmdBytesSoFar, pc, dataBytes);
+ cl->largeCmdBytesSoFar += dataBytes;
+ cl->largeCmdRequestsSoFar++;
+
+ if (req->requestNumber == cl->largeCmdRequestsTotal) {
+ /*
+ ** This is the last request; it must have enough bytes to complete
+ ** the command.
+ */
+ /* NOTE: the two pad macros have been added below; they are needed
+ ** because the client library pads the total byte count, but not
+ ** the per-request byte counts. The Protocol Encoding says the
+ ** total byte count should not be padded, so a proposal will be
+ ** made to the ARB to relax the padding constraint on the total
+ ** byte count, thus preserving backward compatibility. Meanwhile,
+ ** the padding done below fixes a bug that did not allow
+ ** large commands of odd sizes to be accepted by the server.
+ */
+ if (__GLX_PAD(cl->largeCmdBytesSoFar) !=
+ __GLX_PAD(cl->largeCmdBytesTotal)) {
+ client->errorValue = dataBytes;
+ __glXResetLargeCommandStatus(cl);
+ return __glXBadLargeRequest;
+ }
+ hdr = (__GLXrenderLargeHeader *) cl->largeCmdBuf;
+ /*
+ ** The opcode and length field in the header had already been
+ ** swapped when the first request was received.
+ */
+
+ /*
+ ** Use the opcode to index into the procedure table.
+ */
+ opcode = hdr->opcode;
+ if ( (opcode >= __GLX_MIN_RENDER_OPCODE) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE) ) {
+ proc = __glXSwapRenderTable[opcode];
+#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT
+ } else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) {
+ int index = opcode - __GLX_MIN_RENDER_OPCODE_EXT;
+ proc = __glXSwapRenderTable_EXT[index];
+#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */
+ } else {
+ client->errorValue = opcode;
+ return __glXBadLargeRequest;
+ }
+
+ /*
+ ** Skip over the header and execute the command.
+ */
+ (*proc)(cl->largeCmdBuf + __GLX_RENDER_LARGE_HDR_SIZE);
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+
+ /*
+ ** Reset for the next RenderLarge series.
+ */
+ __glXResetLargeCommandStatus(cl);
+ } else {
+ /*
+ ** This is neither the first nor the last request.
+ */
+ }
+ return Success;
+ }
+}
+
+/************************************************************************/
+
+/*
+** No support is provided for the vendor-private requests other than
+** allocating these entry points in the dispatch table.
+*/
+
+int __glXSwapVendorPrivate(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateReq *req;
+ GLint vendorcode;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ req = (xGLXVendorPrivateReq *) pc;
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+
+ vendorcode = req->vendorCode;
+
+#ifndef __DARWIN__
+ switch( vendorcode ) {
+ case X_GLvop_SampleMaskSGIS:
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ glSampleMaskSGIS(*(GLfloat *)(pc + 4),
+ *(GLboolean *)(pc + 8));
+ return Success;
+ case X_GLvop_SamplePatternSGIS:
+ __GLX_SWAP_INT(pc + 4);
+ glSamplePatternSGIS( *(GLenum *)(pc + 4));
+ return Success;
+ }
+#endif
+
+
+ if ((vendorcode >= __GLX_MIN_VENDPRIV_OPCODE_EXT) &&
+ (vendorcode <= __GLX_MAX_VENDPRIV_OPCODE_EXT)) {
+ (*__glXSwapVendorPrivTable_EXT[vendorcode-__GLX_MIN_VENDPRIV_OPCODE_EXT])(cl, (GLbyte*)req);
+ return Success;
+ }
+ cl->client->errorValue = req->vendorCode;
+ return __glXUnsupportedPrivateRequest;
+}
+
+int __glXSwapVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateWithReplyReq *req;
+ GLint vendorcode;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ req = (xGLXVendorPrivateWithReplyReq *) pc;
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+
+ vendorcode = req->vendorCode;
+
+ switch (vendorcode) {
+ case X_GLXvop_QueryContextInfoEXT:
+ return __glXSwapQueryContextInfoEXT(cl, pc);
+ case X_GLXvop_MakeCurrentReadSGI:
+ return __glXSwapMakeCurrentReadSGI(cl, pc);
+ case X_GLXvop_GetFBConfigsSGIX:
+ return __glXSwapGetFBConfigsSGIX(cl, pc);
+ case X_GLXvop_CreateContextWithConfigSGIX:
+ return __glXSwapCreateContextWithConfigSGIX(cl, pc);
+ case X_GLXvop_CreateGLXPixmapWithConfigSGIX:
+ return __glXSwapCreateGLXPixmapWithConfigSGIX(cl, pc);
+ default:
+ break;
+ }
+
+
+ if ((vendorcode >= __GLX_MIN_VENDPRIV_OPCODE_EXT) &&
+ (vendorcode <= __GLX_MAX_VENDPRIV_OPCODE_EXT)) {
+ return (*__glXSwapVendorPrivTable_EXT[vendorcode-__GLX_MIN_VENDPRIV_OPCODE_EXT])(cl, (GLbyte*)req);
+ }
+ cl->client->errorValue = req->vendorCode;
+ return __glXUnsupportedPrivateRequest;
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/glxcontext.h b/nx-X11/programs/Xserver/GL/glx/glxcontext.h
new file mode 100644
index 000000000..18d8b44c2
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxcontext.h
@@ -0,0 +1,164 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxcontext.h,v 1.4 2002/02/22 21:45:07 dawes Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _GLX_context_h_
+#define _GLX_context_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+typedef struct __GLXcontextRec __GLXcontext;
+
+/* XXX: should be defined somewhere globally */
+#define CAPI
+
+#include "GL/internal/glcore.h"
+
+struct __GLXcontextRec {
+ /*
+ ** list of context structs
+ */
+ struct __GLXcontextRec *last;
+ struct __GLXcontextRec *next;
+
+ /*
+ ** list of contexts bound to the same drawable
+ */
+ struct __GLXcontextRec *nextDrawPriv;
+ struct __GLXcontextRec *nextReadPriv;
+
+ /*
+ ** Opaque pointer the context object created by the GL that the
+ ** server is bound with. Never dereferenced by this code, but used
+ ** as a handle to feed to the routines in the screen info struct.
+ */
+ __GLinterface *gc;
+
+ /*
+ ** mode struct for this context
+ */
+ __GLcontextModes *modes;
+
+ /*
+ ** Pointer to screen info data for this context. This is set
+ ** when the context is created.
+ */
+ ScreenPtr pScreen;
+ __GLXscreenInfo *pGlxScreen;
+
+ /*
+ ** This context is created with respect to this visual.
+ */
+ VisualRec *pVisual;
+
+ /*
+ ** The XID of this context.
+ */
+ XID id;
+
+ /*
+ ** The XID of the shareList context.
+ */
+ XID share_id;
+
+ /*
+ ** Visual id.
+ */
+ VisualID vid;
+
+ /*
+ ** screen number.
+ */
+ GLint screen;
+
+ /*
+ ** Whether this context's ID still exists.
+ */
+ GLboolean idExists;
+
+ /*
+ ** Whether this context is current for some client.
+ */
+ GLboolean isCurrent;
+
+ /*
+ ** Whether this context is a direct rendering context.
+ */
+ GLboolean isDirect;
+
+ /*
+ ** Window pending state
+ */
+ GLuint pendingState;
+
+ /*
+ ** This flag keeps track of whether there are unflushed GL commands.
+ */
+ GLboolean hasUnflushedCommands;
+
+ /*
+ ** Current rendering mode for this context.
+ */
+ GLenum renderMode;
+
+ /*
+ ** Buffers for feedback and selection.
+ */
+ GLfloat *feedbackBuf;
+ GLint feedbackBufSize; /* number of elements allocated */
+ GLuint *selectBuf;
+ GLint selectBufSize; /* number of elements allocated */
+
+ /*
+ ** Set only if current drawable is a glx pixmap.
+ */
+ __GLXpixmap *drawPixmap;
+ __GLXpixmap *readPixmap;
+
+ /*
+ ** The drawable private this context is bound to
+ */
+ __GLXdrawablePrivate *drawPriv;
+ __GLXdrawablePrivate *readPriv;
+};
+
+/* pending state defines */
+#define __GLX_PENDING_RESIZE 0x1
+#define __GLX_PENDING_DESTROY 0x2
+#define __GLX_PENDING_SWAP 0x4
+
+#endif /* !__GLX_context_h__ */
diff --git a/nx-X11/programs/Xserver/GL/glx/glxdrawable.h b/nx-X11/programs/Xserver/GL/glx/glxdrawable.h
new file mode 100644
index 000000000..38a05bfeb
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxdrawable.h
@@ -0,0 +1,112 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxdrawable.h,v 1.3 2001/03/21 16:29:36 dawes Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _GLX_drawable_h_
+#define _GLX_drawable_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+typedef struct {
+
+ DrawablePtr pDraw;
+ __GLcontextModes *modes;
+ __GLXscreenInfo *pGlxScreen;
+ ScreenPtr pScreen;
+ Bool idExists;
+ int refcnt;
+
+} __GLXpixmap;
+
+struct __GLXdrawablePrivateRec {
+ /*
+ ** list of drawable private structs
+ */
+ struct __GLXdrawablePrivateRec *last;
+ struct __GLXdrawablePrivateRec *next;
+
+ DrawablePtr pDraw;
+ XID drawId;
+ __GLXpixmap *pGlxPixmap;
+
+ /*
+ ** Either DRAWABLE_PIXMAP or DRAWABLE_WINDOW, copied from pDraw above.
+ ** Needed by the resource freer because pDraw might already have been
+ ** freed.
+ */
+ int type;
+
+ /*
+ ** Configuration of the visual to which this drawable was created.
+ */
+ __GLcontextModes *modes;
+
+ /*
+ ** cached drawable size and origin
+ */
+
+ GLint xorigin, yorigin;
+ GLint width, height;
+
+ /*
+ ** Lists of contexts bound to this drawable. There are two lists here.
+ ** One list is of the contexts that have this drawable bound for drawing,
+ ** and the other is the list of contexts that have this drawable bound
+ ** for reading.
+ */
+ struct __GLXcontextRec *drawGlxc;
+ struct __GLXcontextRec *readGlxc;
+
+ /*
+ ** "methods" that the drawble should be able to respond to.
+ */
+ void (*freeBuffers)(struct __GLXdrawablePrivateRec *);
+ void (*updatePalette)(struct __GLXdrawablePrivateRec *);
+ GLboolean (*swapBuffers)(struct __GLXdrawablePrivateRec *);
+
+ /*
+ ** The GL drawable (information shared between GLX and the GL core)
+ */
+ __GLdrawablePrivate glPriv;
+
+ /*
+ ** reference count
+ */
+ int refCount;
+};
+
+#endif /* !__GLX_drawable_h__ */
diff --git a/nx-X11/programs/Xserver/GL/glx/glxerror.h b/nx-X11/programs/Xserver/GL/glx/glxerror.h
new file mode 100644
index 000000000..2c6d6d863
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxerror.h
@@ -0,0 +1,58 @@
+/* $XFree86$ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _GLX_error_h_
+#define _GLX_error_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+/*
+** Error codes. These have the extension error base added to them
+** when the extension initializes.
+*/
+extern int __glXBadContext;
+extern int __glXBadContextState;
+extern int __glXBadDrawable;
+extern int __glXBadPixmap;
+extern int __glXBadCurrentWindow;
+extern int __glXBadContextTag;
+extern int __glXBadRenderRequest;
+extern int __glXBadLargeRequest;
+extern int __glXUnsupportedPrivateRequest;
+
+#endif
diff --git a/nx-X11/programs/Xserver/GL/glx/glxext.c b/nx-X11/programs/Xserver/GL/glx/glxext.c
new file mode 100644
index 000000000..fa1382983
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxext.c
@@ -0,0 +1,505 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxext.c,v 1.9 2003/09/28 20:15:43 alanh Exp $
+** The contents of this file are subject to the GLX Public License Version 1.0
+** (the "License"). You may not use this file except in compliance with the
+** License. You may obtain a copy of the License at Silicon Graphics, Inc.,
+** attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA 94043
+** or at http://www.sgi.com/software/opensource/glx/license.html.
+**
+** Software distributed under the License is distributed on an "AS IS"
+** basis. ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY
+** IMPLIED WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
+** PURPOSE OR OF NON- INFRINGEMENT. See the License for the specific
+** language governing rights and limitations under the License.
+**
+** The Original Software is GLX version 1.2 source code, released February,
+** 1999. The developer of the Original Software is Silicon Graphics, Inc.
+** Those portions of the Subject Software created by Silicon Graphics, Inc.
+** are Copyright (c) 1991-9 Silicon Graphics, Inc. All Rights Reserved.
+**
+*/
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include <windowstr.h>
+#include <propertyst.h>
+#include <os.h>
+#include "g_disptab.h"
+#include "unpack.h"
+#include "glxutil.h"
+#include "glxext.h"
+#include "micmap.h"
+
+
+void GlxWrapInitVisuals(miInitVisualsProcPtr *);
+void GlxSetVisualConfigs(int nconfigs,
+ __GLXvisualConfig *configs, void **privates);
+
+static __GLXextensionInfo *__glXExt /* = &__glDDXExtensionInfo */;
+
+/*
+** Forward declarations.
+*/
+static int __glXSwapDispatch(ClientPtr);
+static int __glXDispatch(ClientPtr);
+
+/*
+** Called when the extension is reset.
+*/
+static void ResetExtension(ExtensionEntry* extEntry)
+{
+ __glXFlushContextCache();
+ (*__glXExt->resetExtension)();
+ __glXScreenReset();
+}
+
+/*
+** Initialize the per-client context storage.
+*/
+static void ResetClientState(int clientIndex)
+{
+ __GLXclientState *cl = __glXClients[clientIndex];
+
+ if (cl->returnBuf) __glXFree(cl->returnBuf);
+ if (cl->largeCmdBuf) __glXFree(cl->largeCmdBuf);
+ if (cl->currentContexts) __glXFree(cl->currentContexts);
+ __glXMemset(cl, 0, sizeof(__GLXclientState));
+ /*
+ ** By default, assume that the client supports
+ ** GLX major version 1 minor version 0 protocol.
+ */
+ cl->GLClientmajorVersion = 1;
+ cl->GLClientminorVersion = 0;
+ if (cl->GLClientextensions) __glXFree(cl->GLClientextensions);
+
+}
+
+/*
+** Reset state used to keep track of large (multi-request) commands.
+*/
+void __glXResetLargeCommandStatus(__GLXclientState *cl)
+{
+ cl->largeCmdBytesSoFar = 0;
+ cl->largeCmdBytesTotal = 0;
+ cl->largeCmdRequestsSoFar = 0;
+ cl->largeCmdRequestsTotal = 0;
+}
+
+/*
+** This procedure is called when the client who created the context goes
+** away OR when glXDestroyContext is called. In either case, all we do is
+** flag that the ID is no longer valid, and (maybe) free the context.
+** use.
+*/
+static int ContextGone(__GLXcontext* cx, XID id)
+{
+ cx->idExists = GL_FALSE;
+ if (!cx->isCurrent) {
+ __glXFreeContext(cx);
+ }
+
+ return True;
+}
+
+/*
+** Free a client's state.
+*/
+static int ClientGone(int clientIndex, XID id)
+{
+ __GLXcontext *cx;
+ __GLXclientState *cl = __glXClients[clientIndex];
+ int i;
+
+ if (cl) {
+ /*
+ ** Free all the contexts that are current for this client.
+ */
+ for (i=0; i < cl->numCurrentContexts; i++) {
+ cx = cl->currentContexts[i];
+ if (cx) {
+ __glXDeassociateContext(cx);
+ cx->isCurrent = GL_FALSE;
+ if (!cx->idExists) {
+ __glXFreeContext(cx);
+ }
+ }
+ }
+ /*
+ ** Re-initialize the client state structure. Don't free it because
+ ** we'll probably get another client with this index and use the struct
+ ** again. There is a maximum of MAXCLIENTS of these structures.
+ */
+ ResetClientState(clientIndex);
+ }
+
+ return True;
+}
+
+/*
+** Free a GLX Pixmap.
+*/
+static int PixmapGone(__GLXpixmap *pGlxPixmap, XID id)
+{
+ PixmapPtr pPixmap = (PixmapPtr) pGlxPixmap->pDraw;
+
+ pGlxPixmap->idExists = False;
+ if (!pGlxPixmap->refcnt) {
+ /*
+ ** The DestroyPixmap routine should decrement the refcount and free
+ ** only if it's zero.
+ */
+ (*pGlxPixmap->pScreen->DestroyPixmap)(pPixmap);
+ __glXFree(pGlxPixmap);
+ }
+
+ return True;
+}
+
+/*
+** Free a context.
+*/
+GLboolean __glXFreeContext(__GLXcontext *cx)
+{
+ if (cx->idExists || cx->isCurrent) return GL_FALSE;
+
+ if (!cx->isDirect) {
+ if ((*cx->gc->exports.destroyContext)((__GLcontext *)cx->gc) == GL_FALSE) {
+ return GL_FALSE;
+ }
+ }
+ if (cx->feedbackBuf) __glXFree(cx->feedbackBuf);
+ if (cx->selectBuf) __glXFree(cx->selectBuf);
+ __glXFree(cx);
+ if (cx == __glXLastContext) {
+ __glXFlushContextCache();
+ }
+
+ return GL_TRUE;
+}
+
+extern RESTYPE __glXSwapBarrierRes;
+
+static int SwapBarrierGone(int screen, XID drawable)
+{
+ if (__glXSwapBarrierFuncs &&
+ __glXSwapBarrierFuncs[screen].bindSwapBarrierFunc != NULL) {
+ __glXSwapBarrierFuncs[screen].bindSwapBarrierFunc(screen, drawable, 0);
+ }
+ FreeResourceByType(drawable, __glXSwapBarrierRes, FALSE);
+ return True;
+}
+
+/************************************************************************/
+
+/*
+** These routines can be used to check whether a particular GL command
+** has caused an error. Specifically, we use them to check whether a
+** given query has caused an error, in which case a zero-length data
+** reply is sent to the client.
+*/
+
+static GLboolean errorOccured = GL_FALSE;
+
+/*
+** The GL was will call this routine if an error occurs.
+*/
+void __glXErrorCallBack(__GLinterface *gc, GLenum code)
+{
+ errorOccured = GL_TRUE;
+}
+
+/*
+** Clear the error flag before calling the GL command.
+*/
+void __glXClearErrorOccured(void)
+{
+ errorOccured = GL_FALSE;
+}
+
+/*
+** Check if the GL command caused an error.
+*/
+GLboolean __glXErrorOccured(void)
+{
+ return errorOccured;
+}
+
+/************************************************************************/
+
+/*
+** Initialize the GLX extension.
+*/
+void GlxExtensionInit(void)
+{
+ ExtensionEntry *extEntry;
+ int i;
+
+ __glXContextRes = CreateNewResourceType((DeleteType)ContextGone);
+ __glXClientRes = CreateNewResourceType((DeleteType)ClientGone);
+ __glXPixmapRes = CreateNewResourceType((DeleteType)PixmapGone);
+
+ /*
+ ** Add extension to server extensions.
+ */
+ extEntry = AddExtension(GLX_EXTENSION_NAME, __GLX_NUMBER_EVENTS,
+ __GLX_NUMBER_ERRORS, __glXDispatch,
+ __glXSwapDispatch, ResetExtension,
+ StandardMinorOpcode);
+ if (!extEntry) {
+ FatalError("__glXExtensionInit: AddExtensions failed\n");
+ return;
+ }
+ if (!AddExtensionAlias(GLX_EXTENSION_ALIAS, extEntry)) {
+ ErrorF("__glXExtensionInit: AddExtensionAlias failed\n");
+ return;
+ }
+
+ __glXBadContext = extEntry->errorBase + GLXBadContext;
+ __glXBadContextState = extEntry->errorBase + GLXBadContextState;
+ __glXBadDrawable = extEntry->errorBase + GLXBadDrawable;
+ __glXBadPixmap = extEntry->errorBase + GLXBadPixmap;
+ __glXBadContextTag = extEntry->errorBase + GLXBadContextTag;
+ __glXBadCurrentWindow = extEntry->errorBase + GLXBadCurrentWindow;
+ __glXBadRenderRequest = extEntry->errorBase + GLXBadRenderRequest;
+ __glXBadLargeRequest = extEntry->errorBase + GLXBadLargeRequest;
+ __glXUnsupportedPrivateRequest = extEntry->errorBase +
+ GLXUnsupportedPrivateRequest;
+
+ __glXSwapBarrierRes = CreateNewResourceType((DeleteType)SwapBarrierGone);
+
+ /*
+ ** Initialize table of client state. There is never a client 0.
+ */
+ for (i=1; i <= MAXCLIENTS; i++) {
+ __glXClients[i] = 0;
+ }
+
+ /*
+ ** Initialize screen specific data.
+ */
+ __glXScreenInit(screenInfo.numScreens);
+}
+
+/************************************************************************/
+
+Bool __glXCoreType(void)
+{
+ return __glXExt->type;
+}
+
+/************************************************************************/
+
+void GlxSetVisualConfigs(int nconfigs,
+ __GLXvisualConfig *configs, void **privates)
+{
+ (*__glXExt->setVisualConfigs)(nconfigs, configs, privates);
+}
+
+static miInitVisualsProcPtr saveInitVisualsProc;
+
+Bool GlxInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
+ int *nvisualp, int *ndepthp,
+ int *rootDepthp, VisualID *defaultVisp,
+ unsigned long sizes, int bitsPerRGB,
+ int preferredVis)
+{
+ Bool ret;
+
+ if (saveInitVisualsProc) {
+ ret = saveInitVisualsProc(visualp, depthp, nvisualp, ndepthp,
+ rootDepthp, defaultVisp, sizes, bitsPerRGB,
+ preferredVis);
+ if (!ret)
+ return False;
+ }
+ (*__glXExt->initVisuals)(visualp, depthp, nvisualp, ndepthp, rootDepthp,
+ defaultVisp, sizes, bitsPerRGB);
+ return True;
+}
+
+void
+GlxWrapInitVisuals(miInitVisualsProcPtr *initVisProc)
+{
+ saveInitVisualsProc = *initVisProc;
+ *initVisProc = GlxInitVisuals;
+ /* HACK: this shouldn't be done here but it's the earliest time */
+ __glXExt = __glXglDDXExtensionInfo(); /* from GLcore */
+}
+
+/************************************************************************/
+
+void __glXFlushContextCache(void)
+{
+ __glXLastContext = 0;
+}
+
+/*
+** Make a context the current one for the GL (in this implementation, there
+** is only one instance of the GL, and we use it to serve all GL clients by
+** switching it between different contexts). While we are at it, look up
+** a context by its tag and return its (__GLXcontext *).
+*/
+__GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag,
+ int *error)
+{
+ __GLXcontext *cx;
+
+ /*
+ ** See if the context tag is legal; it is managed by the extension,
+ ** so if it's invalid, we have an implementation error.
+ */
+ cx = (__GLXcontext *) __glXLookupContextByTag(cl, tag);
+ if (!cx) {
+ cl->client->errorValue = tag;
+ *error = __glXBadContextTag;
+ return 0;
+ }
+
+ if (!cx->isDirect) {
+ if (cx->drawPriv == NULL) {
+ /*
+ ** The drawable has vanished. It must be a window, because only
+ ** windows can be destroyed from under us; GLX pixmaps are
+ ** refcounted and don't go away until no one is using them.
+ */
+ *error = __glXBadCurrentWindow;
+ return 0;
+ }
+ }
+
+ if (cx == __glXLastContext) {
+ /* No need to re-bind */
+ return cx;
+ }
+
+ /* Make this context the current one for the GL. */
+ if (!cx->isDirect) {
+ if (!(*cx->gc->exports.forceCurrent)((__GLcontext *)cx->gc)) {
+ /* Bind failed, and set the error code. Bummer */
+ cl->client->errorValue = cx->id;
+ *error = __glXBadContextState;
+ return 0;
+ }
+ }
+ __glXLastContext = cx;
+ return cx;
+}
+
+/************************************************************************/
+
+/*
+** Top level dispatcher; all commands are executed from here down.
+*/
+static int __glXDispatch(ClientPtr client)
+{
+ REQUEST(xGLXSingleReq);
+ CARD8 opcode;
+ int (*proc)(__GLXclientState *cl, GLbyte *pc);
+ __GLXclientState *cl;
+
+ opcode = stuff->glxCode;
+ cl = __glXClients[client->index];
+ if (!cl) {
+ cl = (__GLXclientState *) __glXMalloc(sizeof(__GLXclientState));
+ __glXClients[client->index] = cl;
+ if (!cl) {
+ return BadAlloc;
+ }
+ __glXMemset(cl, 0, sizeof(__GLXclientState));
+ }
+
+ if (!cl->inUse) {
+ /*
+ ** This is first request from this client. Associate a resource
+ ** with the client so we will be notified when the client dies.
+ */
+ XID xid = FakeClientID(client->index);
+ if (!AddResource( xid, __glXClientRes, (pointer)(long)client->index)) {
+ return BadAlloc;
+ }
+ ResetClientState(client->index);
+ cl->inUse = GL_TRUE;
+ cl->client = client;
+ }
+
+ /*
+ ** Check for valid opcode.
+ */
+ if (opcode >= __GLX_SINGLE_TABLE_SIZE) {
+ return BadRequest;
+ }
+
+ /*
+ ** If we're expecting a glXRenderLarge request, this better be one.
+ */
+ if ((cl->largeCmdRequestsSoFar != 0) && (opcode != X_GLXRenderLarge)) {
+ client->errorValue = stuff->glxCode;
+ return __glXBadLargeRequest;
+ }
+
+ /*
+ ** Use the opcode to index into the procedure table.
+ */
+ proc = __glXSingleTable[opcode];
+ return (*proc)(cl, (GLbyte *) stuff);
+}
+
+static int __glXSwapDispatch(ClientPtr client)
+{
+ REQUEST(xGLXSingleReq);
+ CARD8 opcode;
+ int (*proc)(__GLXclientState *cl, GLbyte *pc);
+ __GLXclientState *cl;
+
+ opcode = stuff->glxCode;
+ cl = __glXClients[client->index];
+ if (!cl) {
+ cl = (__GLXclientState *) __glXMalloc(sizeof(__GLXclientState));
+ __glXClients[client->index] = cl;
+ if (!cl) {
+ return BadAlloc;
+ }
+ __glXMemset(cl, 0, sizeof(__GLXclientState));
+ }
+
+ if (!cl->inUse) {
+ /*
+ ** This is first request from this client. Associate a resource
+ ** with the client so we will be notified when the client dies.
+ */
+ XID xid = FakeClientID(client->index);
+ if (!AddResource( xid, __glXClientRes, (pointer)(long)client->index)) {
+ return BadAlloc;
+ }
+ ResetClientState(client->index);
+ cl->inUse = GL_TRUE;
+ cl->client = client;
+ }
+
+ /*
+ ** Check for valid opcode.
+ */
+ if (opcode >= __GLX_SINGLE_TABLE_SIZE) {
+ return BadRequest;
+ }
+
+ /*
+ ** Use the opcode to index into the procedure table.
+ */
+ proc = __glXSwapSingleTable[opcode];
+ return (*proc)(cl, (GLbyte *) stuff);
+}
+
+int __glXNoSuchSingleOpcode(__GLXclientState *cl, GLbyte *pc)
+{
+ return BadRequest;
+}
+
+void __glXNoSuchRenderOpcode(GLbyte *pc)
+{
+ return;
+}
+
diff --git a/nx-X11/programs/Xserver/GL/glx/glxext.h b/nx-X11/programs/Xserver/GL/glx/glxext.h
new file mode 100644
index 000000000..5d569899f
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxext.h
@@ -0,0 +1,131 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxext.h,v 1.7 2003/11/17 22:20:26 dawes Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _glxext_h_
+#define _glxext_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+/*
+ * Added by VA Linux for XFree86 4.0.x
+ */
+typedef struct {
+ int type;
+ void (*resetExtension)(void);
+ Bool (*initVisuals)(
+ VisualPtr * visualp,
+ DepthPtr * depthp,
+ int * nvisualp,
+ int * ndepthp,
+ int * rootDepthp,
+ VisualID * defaultVisp,
+ unsigned long sizes,
+ int bitsPerRGB
+ );
+ void (*setVisualConfigs)(
+ int nconfigs,
+ __GLXvisualConfig *configs,
+ void **privates
+ );
+} __GLXextensionInfo;
+
+extern GLboolean __glXFreeContext(__GLXcontext *glxc);
+extern void __glXFlushContextCache(void);
+
+extern void __glXNoSuchRenderOpcode(GLbyte*);
+extern int __glXNoSuchSingleOpcode(__GLXclientState*, GLbyte*);
+extern void __glXErrorCallBack(__GLinterface *gc, GLenum code);
+extern void __glXClearErrorOccured(void);
+extern GLboolean __glXErrorOccured(void);
+extern void __glXResetLargeCommandStatus(__GLXclientState*);
+
+extern int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc);
+extern int __glXSwapQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc);
+
+extern int DoMakeCurrent( __GLXclientState *cl, GLXDrawable drawId,
+ GLXDrawable readId, GLXContextID contextId, GLXContextTag tag );
+extern int DoGetVisualConfigs(__GLXclientState *cl, unsigned screen,
+ GLboolean do_swap);
+extern int DoGetFBConfigs(__GLXclientState *cl, unsigned screen,
+ GLboolean do_swap);
+extern int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
+ GLXContextID shareList, VisualID visual, GLuint screen, GLboolean isDirect);
+extern int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual,
+ GLuint screenNum, XID pixmapId, XID glxpixmapId);
+
+extern void GlxExtensionInit(void);
+
+extern Bool __glXCoreType(void);
+
+extern const char GLServerVersion[];
+extern int DoGetString(__GLXclientState *cl, GLbyte *pc, GLboolean need_swap);
+
+extern int GlxInitVisuals(
+ VisualPtr * visualp,
+ DepthPtr * depthp,
+ int * nvisualp,
+ int * ndepthp,
+ int * rootDepthp,
+ VisualID * defaultVisp,
+ unsigned long sizes,
+ int bitsPerRGB,
+ int preferredVis
+);
+
+typedef struct {
+ void * (* queryHyperpipeNetworkFunc)(int, int *, int *);
+ void * (* queryHyperpipeConfigFunc)(int, int, int *, int *);
+ int (* destroyHyperpipeConfigFunc)(int, int);
+ void * (* hyperpipeConfigFunc)(int, int, int *, int *, void *);
+} __GLXHyperpipeExtensionFuncs;
+
+extern void __glXHyperpipeInit(int screen, __GLXHyperpipeExtensionFuncs *funcs);
+
+extern __GLXHyperpipeExtensionFuncs *__glXHyperpipeFuncs;
+
+typedef struct {
+ int (* bindSwapBarrierFunc)(int, XID, int);
+ int (* queryMaxSwapBarriersFunc)(int);
+} __GLXSwapBarrierExtensionFuncs;
+
+extern void __glXSwapBarrierInit(int screen, __GLXSwapBarrierExtensionFuncs *funcs);
+
+extern __GLXSwapBarrierExtensionFuncs *__glXSwapBarrierFuncs;
+
+#endif /* _glxext_h_ */
+
diff --git a/nx-X11/programs/Xserver/GL/glx/glxfb.c b/nx-X11/programs/Xserver/GL/glx/glxfb.c
new file mode 100644
index 000000000..0d433d25d
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxfb.c
@@ -0,0 +1,183 @@
+/* $XFree86$ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+/*
+** An implementation of a buffer which is part of the front buffer
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxutil.h"
+#include "glxfb.h"
+
+#include <gcstruct.h>
+
+/* so we don't include glmath.h */
+extern GLuint __glFloorLog2(GLuint);
+
+typedef struct __GLFBbufferInfoRec {
+ GCPtr pGC;
+} __GLFBbufferInfo;
+
+extern PixmapPtr __glXPrivPixGetPtr(__GLdrawableBuffer *);
+
+/* ---------------------------------------------------------- */
+
+static GLboolean
+Resize(__GLdrawableBuffer *buf,
+ GLint x, GLint y, GLuint width, GLuint height,
+ __GLdrawablePrivate *glPriv, GLuint bufferMask)
+{
+ buf->width = width;
+ buf->height = height;
+ buf->byteWidth = width * buf->elementSize;
+ buf->outerWidth = width;
+
+ return GL_TRUE;
+}
+
+static void
+Lock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
+{
+}
+
+static void
+Unlock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
+{
+}
+
+/*
+** Do a swap buffer with
+** a memory surface as a back buffer
+** a FB surface as a front buffer
+*/
+GLboolean
+__glXFBMemSwapBuffers(__GLXdrawablePrivate *glxPriv)
+{
+ __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
+ __GLdrawableBuffer *front = &glPriv->frontBuffer;
+ __GLdrawableBuffer *back = &glPriv->backBuffer;
+ __GLFBbufferInfo *bufferInfo;
+ GCPtr pGC;
+ GLint width, height, depth, pad;
+ GLubyte *buf;
+
+ bufferInfo = (__GLFBbufferInfo *) front->other;
+ pGC = bufferInfo->pGC;
+
+ width = back->width;
+ height = back->height;
+ depth = back->depth;
+ buf = back->base;
+ pad = back->outerWidth - back->width; /* back buffer padding */
+ /* adjust buffer padding. X wants left, GL has right */
+ buf -= pad;
+
+ ValidateGC(glxPriv->pDraw, pGC);
+ (*pGC->ops->PutImage)(glxPriv->pDraw, pGC,
+ depth,
+ 0, 0, width, height,
+ pad, ZPixmap,
+ (char *)buf);
+
+ return GL_TRUE;
+}
+
+static void
+Free(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
+{
+ __GLFBbufferInfo *bufferInfo;
+
+ bufferInfo = (__GLFBbufferInfo *) buf->other;
+
+ if (bufferInfo->pGC) {
+ FreeScratchGC(bufferInfo->pGC);
+ }
+
+ __glXFree(bufferInfo);
+ buf->other = NULL;
+}
+
+/*
+** function to return the X GC of this buffer (to be used by DDX)
+*/
+GCPtr __glXFBGetGC(__GLdrawableBuffer *buf)
+{
+ __GLFBbufferInfo *bufferInfo;
+
+ bufferInfo = (__GLFBbufferInfo *) buf->other;
+
+ if (bufferInfo) {
+ return bufferInfo->pGC;
+ } else {
+ return NULL;
+ }
+}
+
+
+void
+__glXInitFB(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv, GLint bits)
+{
+ __GLFBbufferInfo *bufferInfo;
+ __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *) glPriv->other;
+ GCPtr pGC;
+
+ buf->depth = bits;
+ buf->width = buf->height = 0; /* to be filled during Update */
+ buf->handle = buf->base = NULL; /* to be filled during Update */
+ buf->size = 0;
+ buf->byteWidth = 0;
+ buf->elementSize = ((bits-1) / 8) + 1;
+ buf->elementSizeLog2 = __glFloorLog2(buf->elementSize);
+
+ buf->resize = Resize;
+ buf->lock = Lock;
+ buf->unlock = Unlock;
+ buf->fill = NULL;
+ buf->free = Free;
+
+ /* allocate local information */
+ bufferInfo = (__GLFBbufferInfo *) __glXMalloc(sizeof(__GLFBbufferInfo));
+ buf->other = (void *) bufferInfo;
+
+ pGC = CreateScratchGC(glxPriv->pDraw->pScreen,
+ glxPriv->pDraw->depth);
+ bufferInfo->pGC = pGC;
+ (*pGC->funcs->ChangeClip)(pGC, CT_NONE, NULL, 0);
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/glxfb.h b/nx-X11/programs/Xserver/GL/glx/glxfb.h
new file mode 100644
index 000000000..325146d43
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxfb.h
@@ -0,0 +1,52 @@
+/* $XFree86$ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _glxfb_h_
+#define _glxfb_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+extern void __glXInitFB(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
+ GLint bits);
+
+extern GCPtr __glXFBGetGC(__GLdrawableBuffer *buf);
+
+extern GLboolean __glXFBMemSwapBuffers(__GLXdrawablePrivate *glxPriv);
+
+#endif /* _glxfb_h_ */
+
diff --git a/nx-X11/programs/Xserver/GL/glx/glximports.c b/nx-X11/programs/Xserver/GL/glx/glximports.c
new file mode 100644
index 000000000..fae2346b9
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glximports.c
@@ -0,0 +1,184 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glximports.c,v 1.5 2001/03/21 16:29:36 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxcontext.h"
+#include "glximports.h"
+#include "GL/glx_ansic.h"
+
+void *__glXImpMalloc(__GLcontext *gc, size_t size)
+{
+ void *addr;
+
+ if (size == 0) {
+ return NULL;
+ }
+ addr = xalloc(size);
+ if (addr == NULL) {
+ /* XXX: handle out of memory error */
+ return NULL;
+ }
+ return addr;
+}
+
+void *__glXImpCalloc(__GLcontext *gc, size_t numElements, size_t elementSize)
+{
+ void *addr;
+ size_t size;
+
+ if ((numElements == 0) || (elementSize == 0)) {
+ return NULL;
+ }
+ size = numElements * elementSize;
+ addr = xalloc(size);
+ if (addr == NULL) {
+ /* XXX: handle out of memory error */
+ return NULL;
+ }
+ /* zero out memory */
+ __glXMemset(addr, 0, size);
+
+ return addr;
+}
+
+void __glXImpFree(__GLcontext *gc, void *addr)
+{
+ if (addr) {
+ xfree(addr);
+ }
+}
+
+void *__glXImpRealloc(__GLcontext *gc, void *addr, size_t newSize)
+{
+ void *newAddr;
+
+ if (addr) {
+ if (newSize == 0) {
+ xfree(addr);
+ return NULL;
+ }
+ newAddr = xrealloc(addr, newSize);
+ } else {
+ if (newSize == 0) {
+ return NULL;
+ }
+ newAddr = xalloc(newSize);
+ }
+ if (newAddr == NULL) {
+ return NULL; /* XXX: out of memory error */
+ }
+
+ return newAddr;
+}
+
+void __glXImpWarning(__GLcontext *gc, char *msg)
+{
+ ErrorF((char *)msg);
+}
+
+void __glXImpFatal(__GLcontext *gc, char *msg)
+{
+ ErrorF((char *)msg);
+ __glXAbort();
+}
+
+char *__glXImpGetenv(__GLcontext *gc, const char *var)
+{
+ return __glXGetenv(var);
+}
+
+int __glXImpAtoi(__GLcontext *gc, const char *str)
+{
+ return __glXAtoi(str);
+}
+
+int __glXImpSprintf(__GLcontext *gc, char *str, const char *fmt, ...)
+{
+ va_list ap;
+ int ret;
+
+ /* have to deal with var args */
+ va_start(ap, fmt);
+ ret = __glXVsprintf(str, fmt, ap);
+ va_end(ap);
+
+ return ret;
+}
+
+void *__glXImpFopen(__GLcontext *gc, const char *path, const char *mode)
+{
+ return (void *) __glXFopen(path, mode);
+}
+
+int __glXImpFclose(__GLcontext *gc, void *stream)
+{
+ return __glXFclose((FILE *)stream);
+}
+
+int __glXImpFprintf(__GLcontext *gc, void *stream, const char *fmt, ...)
+{
+ va_list ap;
+ int ret;
+
+ /* have to deal with var args */
+ va_start(ap, fmt);
+ ret = __glXVfprintf((FILE *)stream, fmt, ap);
+ va_end(ap);
+
+ return ret;
+}
+
+
+__GLdrawablePrivate *__glXImpGetDrawablePrivate(__GLcontext *gc)
+{
+ __GLinterface *glci = (__GLinterface *) gc;
+ __GLXcontext *glrc = (__GLXcontext *) glci->imports.other;
+
+ return &glrc->drawPriv->glPriv;
+}
+
+
+__GLdrawablePrivate *__glXImpGetReadablePrivate(__GLcontext *gc)
+{
+ __GLinterface *glci = (__GLinterface *) gc;
+ __GLXcontext *glrc = (__GLXcontext *) glci->imports.other;
+
+ return &glrc->readPriv->glPriv;
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/glximports.h b/nx-X11/programs/Xserver/GL/glx/glximports.h
new file mode 100644
index 000000000..ef485822e
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glximports.h
@@ -0,0 +1,66 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glximports.h,v 1.3 2001/03/21 16:29:36 dawes Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _glximports_h_
+#define _glximports_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+extern void *__glXImpMalloc(__GLcontext *gc, size_t size);
+extern void *__glXImpCalloc(__GLcontext *gc, size_t nElem, size_t eSize);
+extern void *__glXImpRealloc(__GLcontext *gc, void *addr, size_t newSize);
+extern void __glXImpFree(__GLcontext *gc, void *addr);
+
+extern void __glXImpWarning(__GLcontext *gc, char *msg);
+extern void __glXImpFatal(__GLcontext *gc, char *msg);
+
+extern char *__glXImpGetenv(__GLcontext *gc, const char *var);
+extern int __glXImpAtoi(__GLcontext *gc, const char *str);
+extern int __glXImpSprintf(__GLcontext *gc, char *str, const char *fmt, ...);
+extern void *__glXImpFopen(__GLcontext *gc, const char *path,
+ const char *mode);
+extern int __glXImpFclose(__GLcontext *gc, void *stream);
+extern int __glXImpFprintf(__GLcontext *gc, void *stream,
+ const char *fmt, ...);
+
+extern __GLdrawablePrivate *__glXImpGetDrawablePrivate(__GLcontext *gc);
+extern __GLdrawablePrivate *__glXImpGetReadablePrivate(__GLcontext *gc);
+
+
+#endif /* _glximports_h_ */
+
diff --git a/nx-X11/programs/Xserver/GL/glx/glxmem.c b/nx-X11/programs/Xserver/GL/glx/glxmem.c
new file mode 100644
index 000000000..21a7c7962
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxmem.c
@@ -0,0 +1,151 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxmem.c,v 1.6 2001/10/31 22:50:27 tsi Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+/*
+** Implementation of a buffer in main memory
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxmem.h"
+#include "glxext.h"
+#include "GL/internal/glcore.h"
+
+/* don't want to include glmath.h */
+extern GLuint __glFloorLog2(GLuint);
+
+/* ---------------------------------------------------------- */
+
+#define BUF_ALIGN 32 /* x86 cache alignment (used for assembly paths) */
+#define BUF_ALIGN_MASK (BUF_ALIGN-1)
+
+static GLboolean
+Resize(__GLdrawableBuffer *buf,
+ GLint x, GLint y, GLuint width, GLuint height,
+ __GLdrawablePrivate *glPriv, GLuint bufferMask)
+{
+ GLuint newSize;
+ void *ubase;
+ GLint pixelWidth;
+ GLint alignedWidth;
+
+ /*
+ ** Note:
+ ** buf->handle : unaligned base
+ ** buf->base : aligned base
+ */
+
+ pixelWidth = BUF_ALIGN / buf->elementSize;
+ alignedWidth = (width & ~(pixelWidth-1)) + pixelWidth;
+
+ newSize = alignedWidth * height * buf->elementSize;
+
+ /*
+ ** Only allocate buffer space for the SGI core.
+ ** Mesa and Aqua handle their own buffer allocations.
+ */
+#if defined(__GL_BUFFER_SIZE_TRACKS_WINDOW)
+ if (__glXCoreType() == GL_CORE_SGI) {
+#else
+ if (newSize > buf->size && __glXCoreType() == GL_CORE_SGI) {
+#endif
+ if (buf->handle) {
+ ubase = (*glPriv->realloc)(buf->handle, newSize + BUF_ALIGN_MASK);
+ if (ubase == NULL) {
+ return GL_FALSE;
+ }
+ } else {
+ ubase = (*glPriv->malloc)(newSize + BUF_ALIGN_MASK);
+ if (ubase == NULL) {
+ return GL_FALSE;
+ }
+ }
+ buf->size = newSize;
+
+ buf->handle = ubase;
+ buf->base = (void *)(((size_t)ubase + BUF_ALIGN_MASK) &
+ (unsigned int) ~BUF_ALIGN_MASK);
+ assert(((size_t)buf->base % BUF_ALIGN) == 0);
+ }
+
+ buf->width = width;
+ buf->height = height;
+ buf->byteWidth = alignedWidth * buf->elementSize;
+ buf->outerWidth = alignedWidth;
+
+ return GL_TRUE;
+}
+
+static void
+Lock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
+{
+}
+
+static void
+Unlock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
+{
+}
+
+static void
+Free(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
+{
+ if (buf->handle) {
+ (*glPriv->free)(buf->handle);
+ buf->handle = NULL;
+ }
+}
+
+
+void
+__glXInitMem(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv, GLint bits)
+{
+ buf->width = buf->height = 0; /* to be filled during Update */
+ buf->depth = bits;
+ buf->size = 0;
+ buf->handle = buf->base = NULL; /* to be filled during Update */
+ buf->byteWidth = 0;
+ buf->elementSize = ((bits - 1) / 8) + 1;
+ buf->elementSizeLog2 = __glFloorLog2(buf->elementSize);
+
+ buf->resize = Resize;
+ buf->lock = Lock;
+ buf->unlock = Unlock;
+ buf->fill = NULL;
+ buf->free = Free;
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/glxmem.h b/nx-X11/programs/Xserver/GL/glx/glxmem.h
new file mode 100644
index 000000000..06720dfdf
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxmem.h
@@ -0,0 +1,48 @@
+/* $XFree86$ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _glxmem_h_
+#define _glxmem_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+extern void __glXInitMem(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
+ GLint bits);
+
+#endif /* _glxmem_h_ */
+
diff --git a/nx-X11/programs/Xserver/GL/glx/glxpix.c b/nx-X11/programs/Xserver/GL/glx/glxpix.c
new file mode 100644
index 000000000..98c033c98
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxpix.c
@@ -0,0 +1,132 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxpix.c,v 1.3 2000/09/26 15:57:02 tsi Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+/*
+** An implementation of a glx pixmap buffer
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxutil.h"
+#include "glxpix.h"
+
+#include <gcstruct.h>
+
+/* don't want to include glmath.h */
+extern GLuint __glFloorLog2(GLuint);
+
+typedef struct __GLPixBufferInfoRec {
+ GCPtr pGC;
+} __GLPixBufferInfo;
+
+/* ---------------------------------------------------------- */
+
+static GLboolean
+Resize(__GLdrawableBuffer *buf,
+ GLint x, GLint y, GLuint width, GLuint height,
+ __GLdrawablePrivate *glPriv, GLuint bufferMask)
+{
+ buf->width = width;
+ buf->height = width;
+ buf->byteWidth = width * buf->elementSize;
+ buf->outerWidth = width;
+
+ return GL_TRUE;
+}
+
+static void
+Lock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
+{
+}
+
+static void
+Unlock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
+{
+}
+
+static void
+Free(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
+{
+ __GLPixBufferInfo *bufferInfo;
+
+ if (LookupIDByType((XID)(long)buf->handle, __glXPixmapRes)) {
+ FreeResource((XID)(long)buf->handle, FALSE);
+ buf->handle = NULL;
+ }
+
+ bufferInfo = (__GLPixBufferInfo *) buf->other;
+
+ if (bufferInfo->pGC) {
+ FreeScratchGC(bufferInfo->pGC);
+ }
+
+ __glXFree(bufferInfo);
+ buf->other = NULL;
+}
+
+void
+__glXInitPix(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
+ GLint bits, XID glxpixmapId, __GLXpixmap *pGlxPixmap)
+{
+ __GLPixBufferInfo *bufferInfo;
+
+ buf->width = buf->height = 0; /* to be filled during Update */
+ buf->depth = bits;
+ buf->size = 0;
+ buf->base = NULL;
+ buf->byteWidth = 0;
+ buf->elementSize = ((bits-1) / 8) + 1;
+ buf->elementSizeLog2 = __glFloorLog2(buf->elementSize);
+
+ buf->handle = (void *)(long) glxpixmapId;
+ pGlxPixmap->refcnt++;
+
+ buf->resize = Resize;
+ buf->lock = Lock;
+ buf->unlock = Unlock;
+ buf->fill = NULL;
+ buf->free = Free;
+
+ /* allocate local information */
+ bufferInfo = (__GLPixBufferInfo *) __glXMalloc(sizeof(__GLPixBufferInfo));
+ buf->other = (void *) bufferInfo;
+
+ bufferInfo->pGC = CreateScratchGC(pGlxPixmap->pDraw->pScreen,
+ pGlxPixmap->pDraw->depth);
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/glxpix.h b/nx-X11/programs/Xserver/GL/glx/glxpix.h
new file mode 100644
index 000000000..4b16352b4
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxpix.h
@@ -0,0 +1,48 @@
+/* $XFree86$ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _glxpix_h_
+#define _glxpix_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+extern void __glXInitPix(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
+ GLint bits, XID glxpixmapId, __GLXpixmap *pGlxPixmap);
+
+#endif /* _glxpix_h_ */
+
diff --git a/nx-X11/programs/Xserver/GL/glx/glxscreens.c b/nx-X11/programs/Xserver/GL/glx/glxscreens.c
new file mode 100644
index 000000000..58b38b1a2
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxscreens.c
@@ -0,0 +1,378 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxscreens.c,v 1.14 2004/02/09 23:46:31 alanh Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef IN_MODULE
+#include <xf86_ansic.h>
+#else
+#include <string.h>
+#include <signal.h>
+#endif
+
+#include <windowstr.h>
+
+#include "glxserver.h"
+#include "glxutil.h"
+#include "glxext.h"
+
+const char GLServerVersion[] = "1.2";
+static const char GLServerExtensions[] =
+ "GL_ARB_depth_texture "
+ "GL_ARB_imaging "
+ "GL_ARB_multitexture "
+ "GL_ARB_point_parameters "
+ "GL_ARB_point_sprite "
+ "GL_ARB_shadow "
+ "GL_ARB_shadow_ambient "
+ "GL_ARB_texture_border_clamp "
+ "GL_ARB_texture_cube_map "
+ "GL_ARB_texture_env_add "
+ "GL_ARB_texture_env_combine "
+ "GL_ARB_texture_env_crossbar "
+ "GL_ARB_texture_env_dot3 "
+ "GL_ARB_texture_mirrored_repeat "
+ "GL_ARB_transpose_matrix "
+ "GL_ARB_window_pos "
+ "GL_EXT_abgr "
+ "GL_EXT_bgra "
+ "GL_EXT_blend_color "
+ "GL_EXT_blend_func_separate "
+ "GL_EXT_blend_logic_op "
+ "GL_EXT_blend_minmax "
+ "GL_EXT_blend_subtract "
+ "GL_EXT_clip_volume_hint "
+ "GL_EXT_copy_texture "
+ "GL_EXT_draw_range_elements "
+ "GL_EXT_fog_coord "
+ "GL_EXT_multi_draw_arrays "
+ "GL_EXT_packed_pixels "
+ "GL_EXT_polygon_offset "
+ "GL_EXT_rescale_normal "
+ "GL_EXT_secondary_color "
+ "GL_EXT_separate_specular_color "
+ "GL_EXT_shadow_funcs "
+ "GL_EXT_stencil_two_side "
+ "GL_EXT_stencil_wrap "
+ "GL_EXT_subtexture "
+ "GL_EXT_texture "
+ "GL_EXT_texture3D "
+ "GL_EXT_texture_edge_clamp "
+ "GL_EXT_texture_env_add "
+ "GL_EXT_texture_env_combine "
+ "GL_EXT_texture_env_dot3 "
+ "GL_EXT_texture_lod "
+ "GL_EXT_texture_lod_bias "
+ "GL_EXT_texture_object "
+ "GL_EXT_texture_rectangle "
+ "GL_EXT_vertex_array "
+ "GL_APPLE_packed_pixels "
+ "GL_ATI_texture_mirror_once "
+ "GL_ATI_texture_env_combine3 "
+ "GL_HP_occlusion_test "
+ "GL_IBM_texture_mirrored_repeat "
+ "GL_MESA_pack_invert "
+ "GL_MESA_ycbcr_texture "
+ "GL_NV_blend_square "
+ "GL_NV_point_sprite "
+ "GL_NV_texgen_reflection "
+ "GL_NV_texture_rectangle "
+ "GL_SGIS_generate_mipmap "
+ "GL_SGIS_texture_border_clamp "
+ "GL_SGIS_texture_edge_clamp "
+ "GL_SGIS_texture_lod "
+ "GL_SGIX_depth_texture "
+ "GL_SGIX_shadow "
+ "GL_SGIX_shadow_ambient "
+ ;
+
+/*
+** We have made the simplifying assuption that the same extensions are
+** supported across all screens in a multi-screen system.
+*/
+static char GLXServerVendorName[] = "SGI";
+static char GLXServerVersion[] = "1.2";
+static char GLXServerExtensions[] =
+ "GLX_ARB_multisample "
+ "GLX_EXT_visual_info "
+ "GLX_EXT_visual_rating "
+ "GLX_EXT_import_context "
+ "GLX_OML_swap_method "
+ "GLX_SGI_make_current_read "
+#ifndef __DARWIN__
+ "GLX_SGIS_multisample "
+ "GLX_SGIX_hyperpipe "
+ "GLX_SGIX_swap_barrier "
+#endif
+ "GLX_SGIX_fbconfig "
+ ;
+
+/*
+ * __glDDXScreenInfo comes from GLcore, so we can't resolve this symbol at
+ * module open time. Leave a placeholder, and fill this in when we first
+ * need it (in __glXScreenInit). XXX Why make this an array?
+ */
+static __GLXscreenInfo *__glXScreens[] = {
+ NULL /* &__glDDXScreenInfo */ ,
+};
+
+static GLint __glXNumStaticScreens =
+ (sizeof __glXScreens / sizeof __glXScreens[0]);
+
+__GLXscreenInfo *__glXActiveScreens;
+GLint __glXNumActiveScreens;
+
+__GLXSwapBarrierExtensionFuncs *__glXSwapBarrierFuncs = NULL;
+static int __glXNumSwapBarrierFuncs = 0;
+__GLXHyperpipeExtensionFuncs *__glXHyperpipeFuncs = NULL;
+static int __glXNumHyperpipeFuncs = 0;
+
+
+RESTYPE __glXDrawableRes;
+
+__GLXscreenInfo *__glXgetActiveScreen(int num) {
+ return &__glXActiveScreens[num];
+}
+
+/*
+** Destroy routine that gets called when a drawable is freed. A drawable
+** contains the ancillary buffers needed for rendering.
+*/
+static Bool DrawableGone(__GLXdrawablePrivate *glxPriv, XID xid)
+{
+ __GLXcontext *cx, *cx1;
+
+ /*
+ ** Use glxPriv->type to figure out what kind of drawable this is. Don't
+ ** use glxPriv->pDraw->type because by the time this routine is called,
+ ** the pDraw might already have been freed.
+ */
+ if (glxPriv->type == DRAWABLE_WINDOW) {
+ /*
+ ** When a window is destroyed, notify all context bound to
+ ** it, that there are no longer bound to anything.
+ */
+ for (cx = glxPriv->drawGlxc; cx; cx = cx1) {
+ cx1 = cx->nextDrawPriv;
+ cx->pendingState |= __GLX_PENDING_DESTROY;
+ }
+
+ for (cx = glxPriv->readGlxc; cx; cx = cx1) {
+ cx1 = cx->nextReadPriv;
+ cx->pendingState |= __GLX_PENDING_DESTROY;
+ }
+ }
+
+ /*
+ ** set the size to 0, so that context that may still be using this
+ ** drawable not do anything harmful
+ */
+ glxPriv->xorigin = 0;
+ glxPriv->yorigin = 0;
+ glxPriv->width = 0;
+ glxPriv->height = 0;
+
+ __glXUnrefDrawablePrivate(glxPriv);
+
+ return True;
+}
+
+/*
+** This hook gets called when a window moves or changes size.
+*/
+static Bool PositionWindow(WindowPtr pWin, int x, int y)
+{
+ ScreenPtr pScreen;
+ __GLXcontext *glxc;
+ __GLXdrawablePrivate *glxPriv;
+ Bool ret;
+
+ /*
+ ** Call wrapped position window routine
+ */
+ pScreen = pWin->drawable.pScreen;
+ pScreen->PositionWindow =
+ __glXActiveScreens[pScreen->myNum].WrappedPositionWindow;
+ ret = (*pScreen->PositionWindow)(pWin, x, y);
+ pScreen->PositionWindow = PositionWindow;
+
+ /*
+ ** Tell all contexts rendering into this window that the window size
+ ** has changed.
+ */
+ glxPriv = (__GLXdrawablePrivate *) LookupIDByType(pWin->drawable.id,
+ __glXDrawableRes);
+ if (glxPriv == NULL) {
+ /*
+ ** This window is not being used by the OpenGL.
+ */
+ return ret;
+ }
+
+ /*
+ ** resize the drawable
+ */
+ /* first change the drawable size */
+ if (__glXResizeDrawableBuffers(glxPriv) == GL_FALSE) {
+ /* resize failed! */
+ /* XXX: what can we possibly do here? */
+ ret = False;
+ }
+
+ /* mark contexts as needing resize */
+
+ for (glxc = glxPriv->drawGlxc; glxc; glxc = glxc->nextDrawPriv) {
+ glxc->pendingState |= __GLX_PENDING_RESIZE;
+ }
+
+ for (glxc = glxPriv->readGlxc; glxc; glxc = glxc->nextReadPriv) {
+ glxc->pendingState |= __GLX_PENDING_RESIZE;
+ }
+
+ return ret;
+}
+
+/*
+** Wrap our own PositionWindow routine around the server's, so we can
+** be notified when a window changes size
+*/
+static void wrapPositionWindow(int screen)
+{
+ ScreenPtr pScreen = screenInfo.screens[screen];
+
+ __glXActiveScreens[screen].WrappedPositionWindow = pScreen->PositionWindow;
+ pScreen->PositionWindow = PositionWindow;
+}
+
+/*
+ * If your DDX driver wants to register support for swap barriers or hyperpipe
+ * topology, it should call __glXHyperpipeInit() or __glXSwapBarrierInit()
+ * with a dispatch table of functions to handle the requests. In the XFree86
+ * DDX, for example, you would call these near the bottom of the driver's
+ * ScreenInit method, after DRI has been initialized.
+ *
+ * This should be replaced with a better method when we teach the server how
+ * to load DRI drivers.
+ */
+
+void __glXHyperpipeInit(int screen, __GLXHyperpipeExtensionFuncs *funcs)
+{
+ if (__glXNumHyperpipeFuncs < screen + 1) {
+ __glXHyperpipeFuncs = __glXRealloc(__glXHyperpipeFuncs,
+ (screen+1) * sizeof(__GLXHyperpipeExtensionFuncs));
+ __glXNumHyperpipeFuncs = screen + 1;
+ }
+
+ __glXHyperpipeFuncs[screen].queryHyperpipeNetworkFunc =
+ *funcs->queryHyperpipeNetworkFunc;
+ __glXHyperpipeFuncs[screen].queryHyperpipeConfigFunc =
+ *funcs->queryHyperpipeConfigFunc;
+ __glXHyperpipeFuncs[screen].destroyHyperpipeConfigFunc =
+ *funcs->destroyHyperpipeConfigFunc;
+ __glXHyperpipeFuncs[screen].hyperpipeConfigFunc =
+ *funcs->hyperpipeConfigFunc;
+}
+
+void __glXSwapBarrierInit(int screen, __GLXSwapBarrierExtensionFuncs *funcs)
+{
+ if (__glXNumSwapBarrierFuncs < screen + 1) {
+ __glXSwapBarrierFuncs = __glXRealloc(__glXSwapBarrierFuncs,
+ (screen+1) * sizeof(__GLXSwapBarrierExtensionFuncs));
+ __glXNumSwapBarrierFuncs = screen + 1;
+ }
+
+ __glXSwapBarrierFuncs[screen].bindSwapBarrierFunc =
+ funcs->bindSwapBarrierFunc;
+ __glXSwapBarrierFuncs[screen].queryMaxSwapBarriersFunc =
+ funcs->queryMaxSwapBarriersFunc;
+}
+
+void __glXScreenInit(GLint numscreens)
+{
+ GLint i,j;
+
+ __glXScreens[0] = __glXglDDXScreenInfo(); /* from GLcore */
+
+ /*
+ ** This alloc has to work or else the server might as well core dump.
+ */
+ __glXActiveScreens =
+ (__GLXscreenInfo *) __glXMalloc(sizeof(__GLXscreenInfo) * numscreens);
+
+ for (i=0; i < numscreens; i++) {
+ /*
+ ** Probe each static screen to see which exists.
+ */
+ for (j=0; j < __glXNumStaticScreens; j++) {
+ if ((*__glXScreens[j]->screenProbe)(i)) {
+ __glXActiveScreens[i] = *__glXScreens[j];
+
+ __glXActiveScreens[i].numUsableVisuals = __glXActiveScreens[i].numVisuals;
+ __glXActiveScreens[i].GLextensions = __glXStrdup(GLServerExtensions);
+ __glXActiveScreens[i].GLXvendor = __glXStrdup(GLXServerVendorName);
+ __glXActiveScreens[i].GLXversion = __glXStrdup(GLXServerVersion);
+ __glXActiveScreens[i].GLXextensions = __glXStrdup(GLXServerExtensions);
+
+ __glXDrawableRes = CreateNewResourceType((DeleteType)DrawableGone);
+ wrapPositionWindow(i);
+ }
+ }
+ }
+ __glXNumActiveScreens = numscreens;
+}
+
+void __glXScreenReset(void)
+{
+ int i;
+
+ for (i = 0; i < __glXNumActiveScreens; i++) {
+ __glXFree(__glXActiveScreens[i].GLXvendor);
+ __glXFree(__glXActiveScreens[i].GLXversion);
+ __glXFree(__glXActiveScreens[i].GLXextensions);
+ __glXFree(__glXActiveScreens[i].GLextensions);
+ }
+ xfree(__glXActiveScreens);
+ xfree(__glXHyperpipeFuncs);
+ xfree(__glXSwapBarrierFuncs);
+ __glXNumHyperpipeFuncs = 0;
+ __glXNumSwapBarrierFuncs = 0;
+ __glXHyperpipeFuncs = NULL;
+ __glXSwapBarrierFuncs = NULL;
+ __glXActiveScreens = NULL;
+ __glXNumActiveScreens = 0;
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/glxscreens.h b/nx-X11/programs/Xserver/GL/glx/glxscreens.h
new file mode 100644
index 000000000..2d68c8b60
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxscreens.h
@@ -0,0 +1,103 @@
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _GLX_screens_h_
+#define _GLX_screens_h_
+
+/* $XFree86: xc/programs/Xserver/GL/glx/glxscreens.h,v 1.4 2001/03/21 16:29:37 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+/* XXX: should be defined somewhere globally */
+#define CAPI
+
+#include "GL/internal/glcore.h"
+
+/*
+** Screen dependent data. These methods are the interface between the DIX
+** and DDX layers of the GLX server extension. The methods provide an
+** interface for context management on a screen.
+*/
+typedef struct {
+ /*
+ ** Probe the screen and see if it supports GL rendering. It will
+ ** return GL_FALSE if it doesn't, GL_TRUE otherwise.
+ */
+ Bool (*screenProbe)(int screen);
+
+ /*
+ ** Create a context using configuration information from modes.
+ ** Use imports as callbacks back to the OS. Return an opaque handle
+ ** on the context (NULL if failure).
+ */
+ __GLinterface *(*createContext)(__GLimports *imports,
+ __GLcontextModes *modes,
+ __GLinterface *shareGC);
+
+ /*
+ ** Create a buffer using information from glxPriv. This routine
+ ** sets up any wrappers necessary to resize, swap or destroy the
+ ** buffer.
+ */
+ void (*createBuffer)(__GLXdrawablePrivate *glxPriv);
+
+ /**
+ * Linked list of valid context modes for this screen.
+ */
+ __GLcontextModes *modes;
+
+ void **pVisualPriv;
+ GLint numVisuals;
+ GLint numUsableVisuals;
+
+ char *GLextensions;
+
+ char *GLXvendor;
+ char *GLXversion;
+ char *GLXextensions;
+
+ /*
+ ** Things that are not statically set.
+ */
+ Bool (*WrappedPositionWindow)(WindowPtr pWin, int x, int y);
+
+} __GLXscreenInfo;
+
+
+extern void __glXScreenInit(GLint);
+extern void __glXScreenReset(void);
+
+#endif /* !__GLX_screens_h__ */
diff --git a/nx-X11/programs/Xserver/GL/glx/glxserver.h b/nx-X11/programs/Xserver/GL/glx/glxserver.h
new file mode 100644
index 000000000..e8449b2bb
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxserver.h
@@ -0,0 +1,287 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxserver.h,v 1.5 2003/09/28 20:15:43 alanh Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _GLX_server_h_
+#define _GLX_server_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xmd.h>
+#include <misc.h>
+#include <dixstruct.h>
+#include <pixmapstr.h>
+#include <gcstruct.h>
+#include <extnsionst.h>
+#include <resource.h>
+#include <scrnintstr.h>
+#include "GL/glx_ansic.h"
+
+
+/*
+** The X header misc.h defines these math functions.
+*/
+#undef abs
+#undef fabs
+
+#define GL_GLEXT_PROTOTYPES /* we want prototypes */
+#include <GL/gl.h>
+#include <GL/glxproto.h>
+#include <GL/glxint.h>
+
+/* For glxscreens.h */
+typedef struct __GLXdrawablePrivateRec __GLXdrawablePrivate;
+
+#include "glxscreens.h"
+#include "glxdrawable.h"
+#include "glxcontext.h"
+#include "glxerror.h"
+
+
+#define GLX_SERVER_MAJOR_VERSION 1
+#define GLX_SERVER_MINOR_VERSION 2
+
+#ifndef True
+#define True 1
+#endif
+#ifndef False
+#define False 0
+#endif
+
+/*
+** GLX resources.
+*/
+typedef XID GLXContextID;
+typedef XID GLXPixmap;
+typedef XID GLXDrawable;
+
+typedef struct __GLXcontextRec *GLXContext;
+typedef struct __GLXclientStateRec __GLXclientState;
+
+extern __GLXscreenInfo *__glXActiveScreens;
+extern GLint __glXNumActiveScreens;
+extern __GLXscreenInfo *__glXgetActiveScreen(int num);
+
+/************************************************************************/
+
+/*
+** The last context used (from the server's persective) is cached.
+*/
+extern __GLXcontext *__glXLastContext;
+extern __GLXcontext *__glXForceCurrent(__GLXclientState*, GLXContextTag, int*);
+
+/*
+** Macros to set, unset, and retrieve the flag that says whether a context
+** has unflushed commands.
+*/
+#define __GLX_NOTE_UNFLUSHED_CMDS(glxc) glxc->hasUnflushedCommands = GL_TRUE
+#define __GLX_NOTE_FLUSHED_CMDS(glxc) glxc->hasUnflushedCommands = GL_FALSE
+#define __GLX_HAS_UNFLUSHED_CMDS(glxc) (glxc->hasUnflushedCommands)
+
+/************************************************************************/
+
+/*
+** State kept per client.
+*/
+struct __GLXclientStateRec {
+ /*
+ ** Whether this structure is currently being used to support a client.
+ */
+ Bool inUse;
+
+ /*
+ ** Buffer for returned data.
+ */
+ GLbyte *returnBuf;
+ GLint returnBufSize;
+
+ /*
+ ** Keep track of large rendering commands, which span multiple requests.
+ */
+ GLint largeCmdBytesSoFar; /* bytes received so far */
+ GLint largeCmdBytesTotal; /* total bytes expected */
+ GLint largeCmdRequestsSoFar; /* requests received so far */
+ GLint largeCmdRequestsTotal; /* total requests expected */
+ GLbyte *largeCmdBuf;
+ GLint largeCmdBufSize;
+
+ /*
+ ** Keep a list of all the contexts that are current for this client's
+ ** threads.
+ */
+ __GLXcontext **currentContexts;
+ GLint numCurrentContexts;
+
+ /* Back pointer to X client record */
+ ClientPtr client;
+
+ int GLClientmajorVersion;
+ int GLClientminorVersion;
+ char *GLClientextensions;
+};
+
+extern __GLXclientState *__glXClients[];
+
+/************************************************************************/
+
+/*
+** Dispatch tables.
+*/
+typedef void (*__GLXdispatchRenderProcPtr)(GLbyte *);
+typedef int (*__GLXdispatchSingleProcPtr)(__GLXclientState *, GLbyte *);
+typedef int (*__GLXdispatchVendorPrivProcPtr)(__GLXclientState *, GLbyte *);
+
+/*
+ * Dispatch for GLX commands.
+ */
+typedef int (*__GLXprocPtr)(__GLXclientState *, char *pc);
+extern __GLXprocPtr __glXProcTable[];
+
+/*
+ * Tables for computing the size of each rendering command.
+ */
+typedef struct {
+ int bytes;
+ int (*varsize)(GLbyte *pc, Bool swap);
+} __GLXrenderSizeData;
+extern __GLXrenderSizeData __glXRenderSizeTable[];
+extern __GLXrenderSizeData __glXRenderSizeTable_EXT[];
+
+/************************************************************************/
+
+/*
+** X resources.
+*/
+extern RESTYPE __glXContextRes;
+extern RESTYPE __glXClientRes;
+extern RESTYPE __glXPixmapRes;
+extern RESTYPE __glXDrawableRes;
+
+/************************************************************************/
+
+/*
+** Prototypes.
+*/
+
+extern char *__glXcombine_strings(const char *, const char *);
+
+/*
+** Routines for sending swapped replies.
+*/
+
+extern void __glXSwapMakeCurrentReply(ClientPtr client,
+ xGLXMakeCurrentReply *reply);
+extern void __glXSwapIsDirectReply(ClientPtr client,
+ xGLXIsDirectReply *reply);
+extern void __glXSwapQueryVersionReply(ClientPtr client,
+ xGLXQueryVersionReply *reply);
+extern void __glXSwapQueryContextInfoEXTReply(ClientPtr client,
+ xGLXQueryContextInfoEXTReply *reply,
+ int *buf);
+extern void glxSwapQueryExtensionsStringReply(ClientPtr client,
+ xGLXQueryExtensionsStringReply *reply, char *buf);
+extern void glxSwapQueryServerStringReply(ClientPtr client,
+ xGLXQueryServerStringReply *reply, char *buf);
+
+
+/*
+ * Routines for computing the size of variably-sized rendering commands.
+ */
+
+extern int __glXTypeSize(GLenum enm);
+extern int __glXImageSize(GLenum format, GLenum type,
+ GLenum target, GLsizei w, GLsizei h, GLsizei d,
+ GLint imageHeight, GLint rowLength, GLint skipImages, GLint skipRows,
+ GLint alignment);
+
+extern int __glXCallListsReqSize(GLbyte *pc, Bool swap);
+extern int __glXBitmapReqSize(GLbyte *pc, Bool swap);
+extern int __glXFogfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXFogivReqSize(GLbyte *pc, Bool swap);
+extern int __glXLightfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXLightivReqSize(GLbyte *pc, Bool swap);
+extern int __glXLightModelfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXLightModelivReqSize(GLbyte *pc, Bool swap);
+extern int __glXMaterialfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXMaterialivReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexParameterfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexParameterivReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexImage1DReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexImage2DReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexEnvfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexEnvivReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexGendvReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexGenfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexGenivReqSize(GLbyte *pc, Bool swap);
+extern int __glXMap1dReqSize(GLbyte *pc, Bool swap);
+extern int __glXMap1fReqSize(GLbyte *pc, Bool swap);
+extern int __glXMap2dReqSize(GLbyte *pc, Bool swap);
+extern int __glXMap2fReqSize(GLbyte *pc, Bool swap);
+extern int __glXPixelMapfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXPixelMapuivReqSize(GLbyte *pc, Bool swap);
+extern int __glXPixelMapusvReqSize(GLbyte *pc, Bool swap);
+extern int __glXDrawPixelsReqSize(GLbyte *pc, Bool swap);
+extern int __glXDrawArraysSize(GLbyte *pc, Bool swap);
+extern int __glXPrioritizeTexturesReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexSubImage1DReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexSubImage2DReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexImage3DReqSize(GLbyte *pc, Bool swap );
+extern int __glXTexSubImage3DReqSize(GLbyte *pc, Bool swap);
+extern int __glXConvolutionFilter1DReqSize(GLbyte *pc, Bool swap);
+extern int __glXConvolutionFilter2DReqSize(GLbyte *pc, Bool swap);
+extern int __glXConvolutionParameterivReqSize(GLbyte *pc, Bool swap);
+extern int __glXConvolutionParameterfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXSeparableFilter2DReqSize(GLbyte *pc, Bool swap);
+extern int __glXColorTableReqSize(GLbyte *pc, Bool swap);
+extern int __glXColorSubTableReqSize(GLbyte *pc, Bool swap);
+extern int __glXColorTableParameterfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXColorTableParameterivReqSize(GLbyte *pc, Bool swap);
+
+/*
+ * Routines for computing the size of returned data.
+ */
+extern int __glXConvolutionParameterivSize(GLenum pname);
+extern int __glXConvolutionParameterfvSize(GLenum pname);
+extern int __glXColorTableParameterfvSize(GLenum pname);
+extern int __glXColorTableParameterivSize(GLenum pname);
+
+extern int __glXPointParameterfvARBReqSize(GLbyte *pc, Bool swap);
+extern int __glXPointParameterivReqSize(GLbyte *pc, Bool swap);
+
+#endif /* !__GLX_server_h__ */
diff --git a/nx-X11/programs/Xserver/GL/glx/glxutil.c b/nx-X11/programs/Xserver/GL/glx/glxutil.c
new file mode 100644
index 000000000..03bc19f63
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxutil.c
@@ -0,0 +1,507 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxutil.c,v 1.5 2001/03/21 16:29:37 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define NEED_REPLIES
+#define FONT_PCF
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include <GL/glxtokens.h>
+#include <unpack.h>
+#include <pixmapstr.h>
+#include <windowstr.h>
+#include "glxutil.h"
+#include "glxbuf.h"
+#include "GL/glx_ansic.h"
+#include "GL/internal/glcore.h"
+#include "GL/glxint.h"
+#include "glcontextmodes.h"
+
+/************************************************************************/
+
+void __glXNop(void) {}
+
+/************************************************************************/
+
+/* Memory Allocation for GLX */
+
+void *
+__glXMalloc(size_t size)
+{
+ void *addr;
+
+ if (size == 0) {
+ return NULL;
+ }
+ addr = (void *) xalloc(size);
+ if (addr == NULL) {
+ /* XXX: handle out of memory error */
+ return NULL;
+ }
+ return addr;
+}
+
+void *
+__glXCalloc(size_t numElements, size_t elementSize)
+{
+ void *addr;
+ size_t size;
+
+ if ((numElements == 0) || (elementSize == 0)) {
+ return NULL;
+ }
+ size = numElements * elementSize;
+ addr = (void *) xalloc(size);
+ if (addr == NULL) {
+ /* XXX: handle out of memory error */
+ return NULL;
+ }
+ __glXMemset(addr, 0, size);
+ return addr;
+}
+
+void *
+__glXRealloc(void *addr, size_t newSize)
+{
+ void *newAddr;
+
+ if (addr) {
+ if (newSize == 0) {
+ xfree(addr);
+ return NULL;
+ } else {
+ newAddr = xrealloc(addr, newSize);
+ }
+ } else {
+ if (newSize == 0) {
+ return NULL;
+ } else {
+ newAddr = xalloc(newSize);
+ }
+ }
+ if (newAddr == NULL) {
+ return NULL; /* XXX: out of memory */
+ }
+
+ return newAddr;
+}
+
+void
+__glXFree(void *addr)
+{
+ if (addr) {
+ xfree(addr);
+ }
+}
+
+/************************************************************************/
+/* Context stuff */
+
+
+/*
+** associate a context with a drawable
+*/
+void
+__glXAssociateContext(__GLXcontext *glxc)
+{
+ glxc->nextDrawPriv = glxc->drawPriv->drawGlxc;
+ glxc->drawPriv->drawGlxc = glxc;
+
+ __glXRefDrawablePrivate(glxc->drawPriv);
+
+
+ glxc->nextReadPriv = glxc->readPriv->readGlxc;
+ glxc->readPriv->readGlxc = glxc;
+
+ __glXRefDrawablePrivate(glxc->readPriv);
+}
+
+/*
+** Deassociate a context from a drawable
+*/
+void
+__glXDeassociateContext(__GLXcontext *glxc)
+{
+ __GLXcontext *curr, *prev;
+
+ prev = NULL;
+ for ( curr = glxc->drawPriv->drawGlxc
+ ; curr != NULL
+ ; prev = curr, curr = curr->nextDrawPriv ) {
+ if (curr == glxc) {
+ /* found context. Deassociate. */
+ if (prev == NULL) {
+ glxc->drawPriv->drawGlxc = curr->nextDrawPriv;
+ } else {
+ prev->nextDrawPriv = curr->nextDrawPriv;
+ }
+ curr->nextDrawPriv = NULL;
+ __glXUnrefDrawablePrivate(glxc->drawPriv);
+ break;
+ }
+ }
+
+
+ prev = NULL;
+ for ( curr = glxc->readPriv->readGlxc
+ ; curr != NULL
+ ; prev = curr, curr = curr->nextReadPriv ) {
+ if (curr == glxc) {
+ /* found context. Deassociate. */
+ if (prev == NULL) {
+ glxc->readPriv->readGlxc = curr->nextReadPriv;
+ } else {
+ prev->nextReadPriv = curr->nextReadPriv;
+ }
+ curr->nextReadPriv = NULL;
+ __glXUnrefDrawablePrivate(glxc->readPriv);
+ break;
+ }
+ }
+}
+
+/************************************************************************/
+
+void
+__glXGetDrawableSize(__GLdrawablePrivate *glPriv,
+ GLint *x, GLint *y, GLuint *width, GLuint *height)
+{
+ __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other;
+
+ if (glxPriv) {
+ *x = glxPriv->xorigin;
+ *y = glxPriv->yorigin;
+ *width = glxPriv->width;
+ *height = glxPriv->height;
+ } else {
+ *x = *y = *width = *height = 0;
+ }
+}
+
+GLboolean
+__glXResizeDrawable(__GLdrawablePrivate *glPriv)
+{
+ /* nothing to be done here */
+ return GL_TRUE;
+}
+
+
+/*****************************************************************************/
+/* accessing the drawable private */
+
+static void
+LockDP(__GLdrawablePrivate *glPriv, __GLcontext *gc)
+{
+ __GLinterface *glci = (__GLinterface *) gc;
+ __GLXcontext *glxc = (__GLXcontext *) glci->imports.other;
+
+ /* quick exit test */
+ if ((glxc->pendingState &
+ (__GLX_PENDING_RESIZE |
+ __GLX_PENDING_DESTROY |
+ __GLX_PENDING_SWAP)) == 0x0)
+ return;
+
+ /* some pending state. Deal with it */
+ if (glxc->pendingState & __GLX_PENDING_RESIZE) {
+ glxc->pendingState &= ~__GLX_PENDING_RESIZE;
+
+ (*glci->exports.notifyResize)(gc);
+ assert((glxc->pendingState & __GLX_PENDING_RESIZE) == 0x0);
+ }
+ if (glxc->pendingState & __GLX_PENDING_DESTROY) {
+ glxc->pendingState &= ~__GLX_PENDING_DESTROY;
+
+ assert(glxc->drawPriv->xorigin == 0);
+ assert(glxc->drawPriv->yorigin == 0);
+ assert(glxc->drawPriv->width == 0);
+ assert(glxc->drawPriv->height == 0);
+ assert(glxc->readPriv->xorigin == 0);
+ assert(glxc->readPriv->yorigin == 0);
+ assert(glxc->readPriv->width == 0);
+ assert(glxc->readPriv->height == 0);
+ (*glci->exports.notifyDestroy)(gc);
+ __glXDeassociateContext(glxc);
+ assert((glxc->pendingState & __GLX_PENDING_DESTROY) == 0x0);
+ }
+ if (glxc->pendingState & __GLX_PENDING_SWAP) {
+
+ glxc->pendingState &= ~__GLX_PENDING_SWAP;
+
+ (*glci->exports.notifySwapBuffers)(gc);
+ assert((glxc->pendingState & __GLX_PENDING_SWAP) == 0x0);
+ }
+}
+
+static void
+UnlockDP(__GLdrawablePrivate *glPriv)
+{
+}
+
+/*****************************************************************************/
+/* Drawable private stuff */
+
+void
+__glXRefDrawablePrivate(__GLXdrawablePrivate *glxPriv)
+{
+ glxPriv->refCount++;
+}
+
+void
+__glXUnrefDrawablePrivate(__GLXdrawablePrivate *glxPriv)
+{
+ glxPriv->refCount--;
+ if (glxPriv->refCount == 0) {
+ __glXDestroyDrawablePrivate(glxPriv);
+ }
+}
+
+__GLXdrawablePrivate *
+__glXCreateDrawablePrivate(DrawablePtr pDraw, XID drawId,
+ __GLcontextModes *modes)
+{
+ __GLXdrawablePrivate *glxPriv;
+ __GLdrawablePrivate *glPriv;
+ __GLXscreenInfo *pGlxScreen;
+
+ glxPriv = (__GLXdrawablePrivate *) __glXMalloc(sizeof(*glxPriv));
+ __glXMemset(glxPriv, 0, sizeof(__GLXdrawablePrivate));
+
+ glxPriv->type = pDraw->type;
+ glxPriv->pDraw = pDraw;
+ glxPriv->drawId = drawId;
+
+ /* if not a pixmap, lookup will fail, so pGlxPixmap will be NULL */
+ glxPriv->pGlxPixmap = (__GLXpixmap *)
+ LookupIDByType(drawId, __glXPixmapRes);
+ /* since we are creating the drawablePrivate, drawId should be new */
+ if (!AddResource(drawId, __glXDrawableRes, glxPriv)) {
+ /* oops! */
+ __glXFree(glxPriv);
+ return NULL;
+ }
+
+ /* fill up glPriv */
+ glPriv = &glxPriv->glPriv;
+ glPriv->modes = (__GLcontextModes *) __glXMalloc(sizeof(__GLcontextModes));
+ *glPriv->modes = *modes;
+ glPriv->malloc = __glXMalloc;
+ glPriv->calloc = __glXCalloc;
+ glPriv->realloc = __glXRealloc;
+ glPriv->free = __glXFree;
+ glPriv->addSwapRect = NULL;
+ glPriv->setClipRect = (void (*)(__GLdrawablePrivate *, GLint, GLint, GLsizei, GLsizei)) __glXNop;
+ glPriv->lockDP = LockDP;
+ glPriv->unlockDP = UnlockDP;
+ glPriv->getDrawableSize = __glXGetDrawableSize;
+ glPriv->resize = __glXResizeDrawable;
+ glPriv->other = glxPriv;
+
+ /* allocate a one-rect ownership region */
+ glPriv->ownershipRegion.rects =
+ (__GLregionRect *)__glXCalloc(1, sizeof(__GLregionRect));
+ glPriv->ownershipRegion.numRects = 1;
+
+ glxPriv->freeBuffers = __glXFreeBuffers;
+ glxPriv->updatePalette = (void (*)(__GLXdrawablePrivate *)) __glXNop;
+
+ pGlxScreen = &__glXActiveScreens[pDraw->pScreen->myNum];
+
+ if (glxPriv->type == DRAWABLE_WINDOW) {
+ VisualID vid = wVisual((WindowPtr)pDraw);
+
+ glxPriv->modes = _gl_context_modes_find_visual( pGlxScreen->modes, vid );
+ __glXFBInitDrawable(glxPriv, modes);
+ } else {
+ glxPriv->modes = glxPriv->pGlxPixmap->modes;
+ __glXPixInitDrawable(glxPriv, modes);
+ }
+
+ /* initialize the core's private buffer information */
+ (*pGlxScreen->createBuffer)(glxPriv);
+
+ return glxPriv;
+}
+
+GLboolean
+__glXDestroyDrawablePrivate(__GLXdrawablePrivate *glxPriv)
+{
+ __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
+
+ /* remove the drawable from the drawable list */
+ FreeResourceByType(glxPriv->drawId, __glXDrawableRes, FALSE);
+
+ /* Have the core free any memory it may have attached to the drawable */
+ if (glPriv->freePrivate) {
+ (*glPriv->freePrivate)(glPriv);
+ }
+
+ /* Free any framebuffer memory attached to the drawable */
+ if (glxPriv->freeBuffers) {
+ (*glxPriv->freeBuffers)(glxPriv);
+ }
+
+ /* Free the drawable Private */
+ __glXFree(glxPriv->glPriv.modes);
+ __glXFree(glxPriv->glPriv.ownershipRegion.rects);
+ __glXFree(glxPriv);
+
+ return GL_TRUE;
+}
+
+__GLXdrawablePrivate *
+__glXFindDrawablePrivate(XID drawId)
+{
+ __GLXdrawablePrivate *glxPriv;
+
+ glxPriv = (__GLXdrawablePrivate *)LookupIDByType(drawId, __glXDrawableRes);
+
+ return glxPriv;
+}
+
+__GLXdrawablePrivate *
+__glXGetDrawablePrivate(DrawablePtr pDraw, XID drawId,
+ __GLcontextModes *modes)
+{
+ __GLXdrawablePrivate *glxPriv;
+
+ glxPriv = __glXFindDrawablePrivate(drawId);
+
+ if (glxPriv == NULL) {
+ glxPriv = __glXCreateDrawablePrivate(pDraw, drawId, modes);
+ if (glxPriv) {
+ __glXRefDrawablePrivate(glxPriv);
+ }
+ }
+
+ return glxPriv;
+}
+
+void
+__glXCacheDrawableSize(__GLXdrawablePrivate *glxPriv)
+{
+ if (glxPriv) {
+ if (glxPriv->pDraw) {
+ glxPriv->xorigin = glxPriv->pDraw->x;
+ glxPriv->yorigin = glxPriv->pDraw->y;
+ glxPriv->width = glxPriv->pDraw->width;
+ glxPriv->height = glxPriv->pDraw->height;
+ }
+ }
+}
+
+/*
+** resize/move the drawable. Called during the actual resize callback
+** to update the drawable side of the buffers
+*/
+GLboolean
+__glXResizeDrawableBuffers(__GLXdrawablePrivate *glxPriv)
+{
+ __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
+ GLint x, y;
+ GLuint w, h;
+#if defined(__GL_ALIGNED_BUFFERS)
+ GLint xAlignment, yAlignment;
+ GLint xOffset, yOffset;
+ GLint xStart, xEnd;
+ GLint yStart, yEnd;
+ GLuint xAlignedMask, yAlignedMask;
+#endif
+ GLboolean status = GL_TRUE;
+
+ __glXCacheDrawableSize(glxPriv);
+
+ w = glxPriv->width;
+ h = glxPriv->height;
+ x = glxPriv->xorigin;
+ y = glxPriv->yorigin;
+
+#if defined(__GL_ALIGNED_BUFFERS)
+ xAlignment = glPriv->xAlignment;
+ yAlignment = glPriv->yAlignment;
+
+ xOffset = x & (xAlignment-1);
+ yOffset = y & (yAlignment-1);
+
+ xAlignedMask = ~(xAlignment-1);
+ yAlignedMask = ~(yAlignment-1);
+
+ xStart = x; xEnd = x+w;
+ yStart = y; yEnd = y+h;
+
+ xStart &= xAlignedMask;
+ if (xEnd & ~xAlignedMask) {
+ xEnd = (xEnd&xAlignedMask) + xAlignment;
+ }
+ yStart &= yAlignedMask;
+ if (yEnd & ~yAlignedMask) {
+ yEnd = (yEnd&yAlignedMask) + yAlignment;
+ }
+
+ x = xStart; y = yStart;
+ w = xEnd-xStart; h = yEnd-yStart;
+#endif
+
+ if ((x != glPriv->xOrigin) ||
+ (y != glPriv->yOrigin) ||
+#if defined(__GL_ALIGNED_BUFFERS)
+ (xOffset != glPriv->xOffset) ||
+ (yOffset != glPriv->yOffset) ||
+#endif
+ (w != glPriv->width) ||
+ (h != glPriv->height) ||
+ (!w && !h)) {
+ /* set up the glPriv info */
+ glPriv->width = w;
+ glPriv->height = h;
+ glPriv->xOrigin = x;
+ glPriv->yOrigin = y;
+#if defined(__GL_ALIGNED_BUFFERS)
+ glPriv->xOffset = xOffset;
+ glPriv->yOffset = yOffset;
+#endif
+
+ /* notify the buffers */
+ status = __glXResizeBuffers(glPriv, x, y, w, h);
+ }
+
+ return status;
+}
+
+/************************************************************************/
+
diff --git a/nx-X11/programs/Xserver/GL/glx/glxutil.h b/nx-X11/programs/Xserver/GL/glx/glxutil.h
new file mode 100644
index 000000000..2c3090a46
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/glxutil.h
@@ -0,0 +1,84 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxutil.h,v 1.3 2001/03/21 16:29:37 dawes Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _glxcmds_h_
+#define _glxcmds_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+extern void __glXNop(void);
+
+/* memory management */
+extern void *__glXMalloc(size_t size);
+extern void *__glXCalloc(size_t numElements, size_t elementSize);
+extern void *__glXRealloc(void *addr, size_t newSize);
+extern void __glXFree(void *ptr);
+
+/* relate contexts with drawables */
+extern void __glXAssociateContext(__GLXcontext *glxc);
+extern void __glXDeassociateContext(__GLXcontext *glxc);
+
+/* drawable operation */
+extern void __glXGetDrawableSize(__GLdrawablePrivate *glPriv,
+ GLint *x, GLint *y,
+ GLuint *width, GLuint *height);
+extern GLboolean __glXResizeDrawable(__GLdrawablePrivate *glPriv);
+extern GLboolean __glXResizeDrawableBuffers(__GLXdrawablePrivate *glxPriv);
+
+/* drawable management */
+extern void __glXRefDrawablePrivate(__GLXdrawablePrivate *glxPriv);
+extern void __glXUnrefDrawablePrivate(__GLXdrawablePrivate *glxPriv);
+extern __GLXdrawablePrivate *__glXCreateDrawablePrivate(DrawablePtr pDraw,
+ XID glxpixmapId,
+ __GLcontextModes *modes);
+extern GLboolean __glXDestroyDrawablePrivate(__GLXdrawablePrivate *glxPriv);
+extern __GLXdrawablePrivate *__glXFindDrawablePrivate(XID glxpixmapId);
+extern __GLXdrawablePrivate *__glXGetDrawablePrivate(DrawablePtr pDraw,
+ XID glxpixmapId,
+ __GLcontextModes *modes);
+extern void __glXCacheDrawableSize(__GLXdrawablePrivate *glxPriv);
+
+/* context helper routines */
+extern __GLXcontext *__glXLookupContextByTag(__GLXclientState*, GLXContextTag);
+
+/* init helper routines */
+extern void *__glXglDDXScreenInfo(void);
+extern void *__glXglDDXExtensionInfo(void);
+
+#endif /* _glxcmds_h_ */
+
diff --git a/nx-X11/programs/Xserver/GL/glx/impsize.h b/nx-X11/programs/Xserver/GL/glx/impsize.h
new file mode 100644
index 000000000..0eaebb6d5
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/impsize.h
@@ -0,0 +1,56 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/impsize.h,v 1.4 2003/09/28 20:15:43 alanh Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _impsize_h_
+#define _impsize_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+/*
+** These are defined in libsampleGL.a. They are not technically part of
+** the defined interface between libdixGL.a and libsampleGL.a (that interface
+** being the functions in the __glXScreenInfo structure, plus the OpenGL API
+** itself), but we thought it was better to call these routines than to
+** replicate the code in here.
+*/
+
+#include "indirect_size.h"
+
+extern int __glDrawPixels_size(GLenum format, GLenum type, GLsizei w,GLsizei h);
+
+#endif /* _impsize_h_ */
diff --git a/nx-X11/programs/Xserver/GL/glx/module/Imakefile b/nx-X11/programs/Xserver/GL/glx/module/Imakefile
new file mode 100644
index 000000000..d063bc28d
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/module/Imakefile
@@ -0,0 +1,4 @@
+#define IHaveModules
+#define LinkDirectory ..
+
+#include "../Imakefile"
diff --git a/nx-X11/programs/Xserver/GL/glx/render2.c b/nx-X11/programs/Xserver/GL/glx/render2.c
new file mode 100644
index 000000000..39d0c132a
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/render2.c
@@ -0,0 +1,271 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/render2.c,v 1.8 2004/02/03 23:04:08 alanh Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+/* #define NEED_REPLIES */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <glxserver.h>
+#include "unpack.h"
+#include "g_disptab.h"
+#include "g_disptab_EXT.h"
+
+
+void __glXDisp_Map1f(GLbyte *pc)
+{
+ GLint order, k;
+ GLfloat u1, u2, *points;
+ GLenum target;
+
+ target = *(GLenum *)(pc + 0);
+ order = *(GLint *)(pc + 12);
+ u1 = *(GLfloat *)(pc + 4);
+ u2 = *(GLfloat *)(pc + 8);
+ points = (GLfloat *)(pc + 16);
+ k = __glMap1f_size(target);
+
+ glMap1f(target, u1, u2, k, order, points);
+}
+
+void __glXDisp_Map2f(GLbyte *pc)
+{
+ GLint uorder, vorder, ustride, vstride, k;
+ GLfloat u1, u2, v1, v2, *points;
+ GLenum target;
+
+ target = *(GLenum *)(pc + 0);
+ uorder = *(GLint *)(pc + 12);
+ vorder = *(GLint *)(pc + 24);
+ u1 = *(GLfloat *)(pc + 4);
+ u2 = *(GLfloat *)(pc + 8);
+ v1 = *(GLfloat *)(pc + 16);
+ v2 = *(GLfloat *)(pc + 20);
+ points = (GLfloat *)(pc + 28);
+
+ k = __glMap2f_size(target);
+ ustride = vorder * k;
+ vstride = k;
+
+ glMap2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
+}
+
+void __glXDisp_Map1d(GLbyte *pc)
+{
+ GLint order, k;
+#ifdef __GLX_ALIGN64
+ GLint compsize;
+#endif
+ GLenum target;
+ GLdouble u1, u2, *points;
+
+ target = *(GLenum*) (pc + 16);
+ order = *(GLint*) (pc + 20);
+ k = __glMap1d_size(target);
+
+#ifdef __GLX_ALIGN64
+ if (order < 0 || k < 0) {
+ compsize = 0;
+ } else {
+ compsize = order * k;
+ }
+#endif
+
+ __GLX_GET_DOUBLE(u1,pc);
+ __GLX_GET_DOUBLE(u2,pc+8);
+ pc += 24;
+
+#ifdef __GLX_ALIGN64
+ if (((unsigned long)pc) & 7) {
+ /*
+ ** Copy the doubles up 4 bytes, trashing the command but aligning
+ ** the data in the process
+ */
+ __GLX_MEM_COPY(pc-4, pc, compsize*8);
+ points = (GLdouble*) (pc - 4);
+ } else {
+ points = (GLdouble*) pc;
+ }
+#else
+ points = (GLdouble*) pc;
+#endif
+ glMap1d(target, u1, u2, k, order, points);
+}
+
+void __glXDisp_Map2d(GLbyte *pc)
+{
+ GLdouble u1, u2, v1, v2, *points;
+ GLint uorder, vorder, ustride, vstride, k;
+#ifdef __GLX_ALIGN64
+ GLint compsize;
+#endif
+ GLenum target;
+
+ target = *(GLenum *)(pc + 32);
+ uorder = *(GLint *)(pc + 36);
+ vorder = *(GLint *)(pc + 40);
+ k = __glMap2d_size(target);
+
+#ifdef __GLX_ALIGN64
+ if (vorder < 0 || uorder < 0 || k < 0) {
+ compsize = 0;
+ } else {
+ compsize = uorder * vorder * k;
+ }
+#endif
+
+ __GLX_GET_DOUBLE(u1,pc);
+ __GLX_GET_DOUBLE(u2,pc+8);
+ __GLX_GET_DOUBLE(v1,pc+16);
+ __GLX_GET_DOUBLE(v2,pc+24);
+ pc += 44;
+
+ ustride = vorder * k;
+ vstride = k;
+
+#ifdef __GLX_ALIGN64
+ if (((unsigned long)pc) & 7) {
+ /*
+ ** Copy the doubles up 4 bytes, trashing the command but aligning
+ ** the data in the process
+ */
+ __GLX_MEM_COPY(pc-4, pc, compsize*8);
+ points = (GLdouble*) (pc - 4);
+ } else {
+ points = (GLdouble*) pc;
+ }
+#else
+ points = (GLdouble*) pc;
+#endif
+ glMap2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
+}
+
+void __glXDisp_CallLists(GLbyte *pc)
+{
+ GLenum type;
+ GLsizei n;
+
+ type = *(GLenum *)(pc + 4);
+ n = *(GLsizei *)(pc + 0);
+ glCallLists(n, type, pc + 8);
+}
+
+void __glXDisp_DrawArrays(GLbyte *pc)
+{
+ __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *)pc;
+ __GLXdispatchDrawArraysComponentHeader *compHeader;
+ GLint numVertexes = hdr->numVertexes;
+ GLint numComponents = hdr->numComponents;
+ GLenum primType = hdr->primType;
+ GLint stride = 0;
+ int i;
+
+ pc += sizeof(__GLXdispatchDrawArraysHeader);
+ compHeader = (__GLXdispatchDrawArraysComponentHeader *)pc;
+
+ /* compute stride (same for all component arrays) */
+ for (i = 0; i < numComponents; i++) {
+ GLenum datatype = compHeader[i].datatype;
+ GLint numVals = compHeader[i].numVals;
+
+ stride += __GLX_PAD(numVals * __glXTypeSize(datatype));
+ }
+
+ pc += numComponents * sizeof(__GLXdispatchDrawArraysComponentHeader);
+
+ /* set up component arrays */
+ for (i = 0; i < numComponents; i++) {
+ GLenum datatype = compHeader[i].datatype;
+ GLint numVals = compHeader[i].numVals;
+ GLenum component = compHeader[i].component;
+
+ switch (component) {
+ case GL_VERTEX_ARRAY:
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(numVals, datatype, stride, pc);
+ break;
+ case GL_NORMAL_ARRAY:
+ glEnableClientState(GL_NORMAL_ARRAY);
+ glNormalPointer(datatype, stride, pc);
+ break;
+ case GL_COLOR_ARRAY:
+ glEnableClientState(GL_COLOR_ARRAY);
+ glColorPointer(numVals, datatype, stride, pc);
+ break;
+ case GL_INDEX_ARRAY:
+ glEnableClientState(GL_INDEX_ARRAY);
+ glIndexPointer(datatype, stride, pc);
+ break;
+ case GL_TEXTURE_COORD_ARRAY:
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glTexCoordPointer(numVals, datatype, stride, pc);
+ break;
+ case GL_EDGE_FLAG_ARRAY:
+ glEnableClientState(GL_EDGE_FLAG_ARRAY);
+ glEdgeFlagPointer(stride, (const GLboolean *)pc);
+ break;
+ case GL_SECONDARY_COLOR_ARRAY:
+ glEnableClientState(GL_SECONDARY_COLOR_ARRAY);
+ glSecondaryColorPointer(numVals, datatype, stride, pc);
+ break;
+ case GL_FOG_COORD_ARRAY:
+ glEnableClientState(GL_FOG_COORD_ARRAY);
+ glFogCoordPointer(datatype, stride, pc);
+ break;
+ default:
+ break;
+ }
+
+ pc += __GLX_PAD(numVals * __glXTypeSize(datatype));
+ }
+
+ glDrawArrays(primType, 0, numVertexes);
+
+ /* turn off anything we might have turned on */
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_INDEX_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_EDGE_FLAG_ARRAY);
+ glDisableClientState(GL_SECONDARY_COLOR_ARRAY);
+ glDisableClientState(GL_FOG_COORD_ARRAY);
+}
+
+void __glXDisp_DrawArraysEXT(GLbyte *pc)
+{
+ __glXDisp_DrawArrays(pc);
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/render2swap.c b/nx-X11/programs/Xserver/GL/glx/render2swap.c
new file mode 100644
index 000000000..65ac5e18a
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/render2swap.c
@@ -0,0 +1,393 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/render2swap.c,v 1.6 2002/01/14 22:47:08 tsi Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+/* #define NEED_REPLIES */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "unpack.h"
+#include "g_disptab.h"
+#include "g_disptab_EXT.h"
+
+
+void __glXDispSwap_Map1f(GLbyte *pc)
+{
+ GLint order, k;
+ GLfloat u1, u2, *points;
+ GLenum target;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+ target = *(GLenum *)(pc + 0);
+ order = *(GLint *)(pc + 12);
+ u1 = *(GLfloat *)(pc + 4);
+ u2 = *(GLfloat *)(pc + 8);
+ points = (GLfloat *)(pc + 16);
+ k = __glMap1f_size(target);
+
+ if (order <= 0 || k < 0) {
+ /* Erroneous command. */
+ compsize = 0;
+ } else {
+ compsize = order * k;
+ }
+ __GLX_SWAP_FLOAT_ARRAY(points, compsize);
+
+ glMap1f(target, u1, u2, k, order, points);
+}
+
+void __glXDispSwap_Map2f(GLbyte *pc)
+{
+ GLint uorder, vorder, ustride, vstride, k;
+ GLfloat u1, u2, v1, v2, *points;
+ GLenum target;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 24);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+ __GLX_SWAP_FLOAT(pc + 16);
+ __GLX_SWAP_FLOAT(pc + 20);
+
+ target = *(GLenum *)(pc + 0);
+ uorder = *(GLint *)(pc + 12);
+ vorder = *(GLint *)(pc + 24);
+ u1 = *(GLfloat *)(pc + 4);
+ u2 = *(GLfloat *)(pc + 8);
+ v1 = *(GLfloat *)(pc + 16);
+ v2 = *(GLfloat *)(pc + 20);
+ points = (GLfloat *)(pc + 28);
+
+ k = __glMap2f_size(target);
+ ustride = vorder * k;
+ vstride = k;
+
+ if (vorder <= 0 || uorder <= 0 || k < 0) {
+ /* Erroneous command. */
+ compsize = 0;
+ } else {
+ compsize = uorder * vorder * k;
+ }
+ __GLX_SWAP_FLOAT_ARRAY(points, compsize);
+
+ glMap2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
+}
+
+void __glXDispSwap_Map1d(GLbyte *pc)
+{
+ GLint order, k, compsize;
+ GLenum target;
+ GLdouble u1, u2, *points;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_INT(pc + 20);
+
+ target = *(GLenum*) (pc + 16);
+ order = *(GLint*) (pc + 20);
+ k = __glMap1d_size(target);
+ if (order <= 0 || k < 0) {
+ /* Erroneous command. */
+ compsize = 0;
+ } else {
+ compsize = order * k;
+ }
+ __GLX_GET_DOUBLE(u1,pc);
+ __GLX_GET_DOUBLE(u2,pc+8);
+ __GLX_SWAP_DOUBLE_ARRAY(pc+24, compsize);
+ pc += 24;
+
+#ifdef __GLX_ALIGN64
+ if (((unsigned long)pc) & 7) {
+ /*
+ ** Copy the doubles up 4 bytes, trashing the command but aligning
+ ** the data in the process
+ */
+ __GLX_MEM_COPY(pc-4, pc, compsize*8);
+ points = (GLdouble*) (pc - 4);
+ } else {
+ points = (GLdouble*) pc;
+ }
+#else
+ points = (GLdouble*) pc;
+#endif
+ glMap1d(target, u1, u2, k, order, points);
+}
+
+void __glXDispSwap_Map2d(GLbyte *pc)
+{
+ GLdouble u1, u2, v1, v2, *points;
+ GLint uorder, vorder, ustride, vstride, k, compsize;
+ GLenum target;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_DOUBLE(pc + 16);
+ __GLX_SWAP_DOUBLE(pc + 24);
+ __GLX_SWAP_INT(pc + 32);
+ __GLX_SWAP_INT(pc + 36);
+ __GLX_SWAP_INT(pc + 40);
+
+ target = *(GLenum *)(pc + 32);
+ uorder = *(GLint *)(pc + 36);
+ vorder = *(GLint *)(pc + 40);
+ k = __glMap2d_size(target);
+ if (vorder <= 0 || uorder <= 0 || k < 0) {
+ /* Erroneous command. */
+ compsize = 0;
+ } else {
+ compsize = uorder * vorder * k;
+ }
+ __GLX_GET_DOUBLE(u1,pc);
+ __GLX_GET_DOUBLE(u2,pc+8);
+ __GLX_GET_DOUBLE(v1,pc+16);
+ __GLX_GET_DOUBLE(v2,pc+24);
+ __GLX_SWAP_DOUBLE_ARRAY(pc+44, compsize);
+ pc += 44;
+ ustride = vorder * k;
+ vstride = k;
+
+#ifdef __GLX_ALIGN64
+ if (((unsigned long)pc) & 7) {
+ /*
+ ** Copy the doubles up 4 bytes, trashing the command but aligning
+ ** the data in the process
+ */
+ __GLX_MEM_COPY(pc-4, pc, compsize*8);
+ points = (GLdouble*) (pc - 4);
+ } else {
+ points = (GLdouble*) pc;
+ }
+#else
+ points = (GLdouble*) pc;
+#endif
+ glMap2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
+}
+
+void __glXDispSwap_CallLists(GLbyte *pc)
+{
+ GLenum type;
+ GLsizei n;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 0);
+ type = *(GLenum *)(pc + 4);
+ n = *(GLsizei *)(pc + 0);
+
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_2_BYTES:
+ case GL_3_BYTES:
+ case GL_4_BYTES:
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ __GLX_SWAP_SHORT_ARRAY(pc+8, n);
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ __GLX_SWAP_INT_ARRAY(pc+8, n);
+ break;
+ case GL_FLOAT:
+ __GLX_SWAP_FLOAT_ARRAY(pc+8, n);
+ break;
+ }
+
+ glCallLists(n, type, pc+8);
+}
+
+static void swapArray(GLint numVals, GLenum datatype,
+ GLint stride, GLint numVertexes, GLbyte *pc)
+{
+ int i,j;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ switch (datatype) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ /* don't need to swap */
+ return;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ for (i=0; i<numVertexes; i++) {
+ GLshort *pVal = (GLshort *) pc;
+ for (j=0; j<numVals; j++) {
+ __GLX_SWAP_SHORT(&pVal[j]);
+ }
+ pc += stride;
+ }
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ for (i=0; i<numVertexes; i++) {
+ GLint *pVal = (GLint *) pc;
+ for (j=0; j<numVals; j++) {
+ __GLX_SWAP_INT(&pVal[j]);
+ }
+ pc += stride;
+ }
+ break;
+ case GL_FLOAT:
+ for (i=0; i<numVertexes; i++) {
+ GLfloat *pVal = (GLfloat *) pc;
+ for (j=0; j<numVals; j++) {
+ __GLX_SWAP_FLOAT(&pVal[j]);
+ }
+ pc += stride;
+ }
+ break;
+ case GL_DOUBLE:
+ for (i=0; i<numVertexes; i++) {
+ GLdouble *pVal = (GLdouble *) pc;
+ for (j=0; j<numVals; j++) {
+ __GLX_SWAP_DOUBLE(&pVal[j]);
+ }
+ pc += stride;
+ }
+ break;
+ default:
+ return;
+ }
+}
+
+void __glXDispSwap_DrawArrays(GLbyte *pc)
+{
+ __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *)pc;
+ __GLXdispatchDrawArraysComponentHeader *compHeader;
+ GLint numVertexes = hdr->numVertexes;
+ GLint numComponents = hdr->numComponents;
+ GLenum primType = hdr->primType;
+ GLint stride = 0;
+ int i;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&numVertexes);
+ __GLX_SWAP_INT(&numComponents);
+ __GLX_SWAP_INT(&primType);
+
+ pc += sizeof(__GLXdispatchDrawArraysHeader);
+ compHeader = (__GLXdispatchDrawArraysComponentHeader *) pc;
+
+ /* compute stride (same for all component arrays) */
+ for (i=0; i<numComponents; i++) {
+ GLenum datatype = compHeader[i].datatype;
+ GLint numVals = compHeader[i].numVals;
+ GLenum component = compHeader[i].component;
+
+ __GLX_SWAP_INT(&datatype);
+ __GLX_SWAP_INT(&numVals);
+ __GLX_SWAP_INT(&component);
+
+ stride += __GLX_PAD(numVals * __glXTypeSize(datatype));
+ }
+
+ pc += numComponents * sizeof(__GLXdispatchDrawArraysComponentHeader);
+
+ /* set up component arrays */
+ for (i=0; i<numComponents; i++) {
+ GLenum datatype = compHeader[i].datatype;
+ GLint numVals = compHeader[i].numVals;
+ GLenum component = compHeader[i].component;
+
+ swapArray(numVals, datatype, stride, numVertexes, pc);
+
+ switch (component) {
+ case GL_VERTEX_ARRAY:
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(numVals, datatype, stride, pc);
+ break;
+ case GL_NORMAL_ARRAY:
+ glEnableClientState(GL_NORMAL_ARRAY);
+ glNormalPointer(datatype, stride, pc);
+ break;
+ case GL_COLOR_ARRAY:
+ glEnableClientState(GL_COLOR_ARRAY);
+ glColorPointer(numVals, datatype, stride, pc);
+ break;
+ case GL_INDEX_ARRAY:
+ glEnableClientState(GL_INDEX_ARRAY);
+ glIndexPointer(datatype, stride, pc);
+ break;
+ case GL_TEXTURE_COORD_ARRAY:
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glTexCoordPointer(numVals, datatype, stride, pc);
+ break;
+ case GL_EDGE_FLAG_ARRAY:
+ glEnableClientState(GL_EDGE_FLAG_ARRAY);
+ glEdgeFlagPointer(stride, (const GLboolean *)pc);
+ break;
+ default:
+ break;
+ }
+
+ pc += __GLX_PAD(numVals * __glXTypeSize(datatype));
+ }
+
+ glDrawArrays(primType, 0, numVertexes);
+
+ /* turn off anything we might have turned on */
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_INDEX_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_EDGE_FLAG_ARRAY);
+}
+
+void __glXDispSwap_DrawArraysEXT(GLbyte *pc)
+{
+ __glXDispSwap_DrawArrays(pc);
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/renderpix.c b/nx-X11/programs/Xserver/GL/glx/renderpix.c
new file mode 100644
index 000000000..fe508e299
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/renderpix.c
@@ -0,0 +1,312 @@
+/* $XFree86$ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "unpack.h"
+#include "g_disptab.h"
+#include "g_disptab_EXT.h"
+
+void __glXDisp_PolygonStipple(GLbyte *pc)
+{
+ __GLXpixelHeader *hdr = (__GLXpixelHeader *) pc;
+
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, (GLint) hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, (GLint) hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, (GLint) hdr->alignment);
+
+ glPolygonStipple((GLubyte *)(hdr+1));
+}
+
+void __glXDisp_Bitmap(GLbyte *pc)
+{
+ __GLXdispatchBitmapHeader *hdr = (__GLXdispatchBitmapHeader *) pc;
+
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, (GLint) hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, (GLint) hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, (GLint) hdr->alignment);
+
+ glBitmap((GLsizei) hdr->width,
+ (GLsizei) hdr->height,
+ (GLfloat) hdr->xorig,
+ (GLfloat) hdr->yorig,
+ (GLfloat) hdr->xmove,
+ (GLfloat) hdr->ymove,
+ (GLubyte *)(hdr+1));
+}
+
+void __glXDisp_TexImage1D(GLbyte *pc)
+{
+ __GLXdispatchTexImageHeader *hdr = (__GLXdispatchTexImageHeader *) pc;
+
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, (GLint) hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, (GLint) hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, (GLint) hdr->alignment);
+
+ glTexImage1D(hdr->target,
+ (GLint) hdr->level,
+ (GLint) hdr->components,
+ (GLsizei) hdr->width,
+ (GLint) hdr->border,
+ hdr->format,
+ hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDisp_TexImage2D(GLbyte *pc)
+{
+ __GLXdispatchTexImageHeader *hdr = (__GLXdispatchTexImageHeader *) pc;
+
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, (GLint) hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, (GLint) hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, (GLint) hdr->alignment);
+
+ glTexImage2D(hdr->target,
+ (GLint) hdr->level,
+ (GLint) hdr->components,
+ (GLsizei) hdr->width,
+ (GLsizei) hdr->height,
+ (GLint) hdr->border,
+ hdr->format,
+ hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDisp_TexImage3D(GLbyte *pc)
+{
+ __GLXdispatchTexImage3DHeader *hdr = (__GLXdispatchTexImage3DHeader *) pc;
+
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, hdr->rowLength);
+ glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, hdr->imageHeight);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_IMAGES, hdr->skipImages);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, hdr->alignment);
+
+ glTexImage3D(hdr->target, hdr->level, hdr->internalformat, hdr->width,
+ hdr->height, hdr->depth, hdr->border, hdr->format, hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDisp_DrawPixels(GLbyte *pc)
+{
+ __GLXdispatchDrawPixelsHeader *hdr = (__GLXdispatchDrawPixelsHeader *) pc;
+
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, (GLint) hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, (GLint) hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, (GLint) hdr->alignment);
+
+ glDrawPixels((GLsizei) hdr->width,
+ (GLsizei) hdr->height,
+ hdr->format,
+ hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDisp_TexSubImage1D(GLbyte *pc)
+{
+ __GLXdispatchTexSubImageHeader *hdr = (__GLXdispatchTexSubImageHeader *) pc;
+
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, (GLint) hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, (GLint) hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, (GLint) hdr->alignment);
+
+ glTexSubImage1D(hdr->target,
+ (GLint) hdr->level,
+ (GLint) hdr->xoffset,
+ (GLsizei) hdr->width,
+ hdr->format,
+ hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDisp_TexSubImage2D(GLbyte *pc)
+{
+ __GLXdispatchTexSubImageHeader *hdr = (__GLXdispatchTexSubImageHeader *) pc;
+
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, (GLint) hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, (GLint) hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, (GLint) hdr->alignment);
+
+ glTexSubImage2D(hdr->target,
+ (GLint) hdr->level,
+ (GLint) hdr->xoffset,
+ (GLint) hdr->yoffset,
+ (GLsizei) hdr->width,
+ (GLsizei) hdr->height,
+ hdr->format,
+ hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDisp_TexSubImage3D(GLbyte *pc)
+{
+ __GLXdispatchTexSubImage3DHeader *hdr =
+ (__GLXdispatchTexSubImage3DHeader *) pc;
+
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, hdr->rowLength);
+ glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, hdr->imageHeight);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_IMAGES, hdr->skipImages);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, hdr->alignment);
+
+ glTexSubImage3D(hdr->target, hdr->level, hdr->xoffset, hdr->yoffset,
+ hdr->zoffset, hdr->width, hdr->height, hdr->depth,
+ hdr->format, hdr->type, (GLvoid *)(hdr+1));
+}
+
+void __glXDisp_ColorTable(GLbyte *pc)
+{
+ __GLXdispatchColorTableHeader *hdr =
+ (__GLXdispatchColorTableHeader *) pc;
+
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, hdr->alignment);
+
+ glColorTable(hdr->target, hdr->internalformat,
+ hdr->width, hdr->format, hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDisp_ColorSubTable(GLbyte *pc)
+{
+ __GLXdispatchColorSubTableHeader *hdr =
+ (__GLXdispatchColorSubTableHeader *) pc;
+
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, hdr->alignment);
+
+ glColorSubTable(hdr->target, hdr->start, hdr->count, hdr->format,
+ hdr->type, (GLvoid *)(hdr+1));
+}
+
+void __glXDisp_ConvolutionFilter1D(GLbyte *pc)
+{
+ __GLXdispatchConvolutionFilterHeader *hdr =
+ (__GLXdispatchConvolutionFilterHeader *) pc;
+
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, hdr->alignment);
+
+ glConvolutionFilter1D(hdr->target, hdr->internalformat,
+ hdr->width, hdr->format, hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDisp_ConvolutionFilter2D(GLbyte *pc)
+{
+ __GLXdispatchConvolutionFilterHeader *hdr =
+ (__GLXdispatchConvolutionFilterHeader *) pc;
+
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, hdr->alignment);
+
+ glConvolutionFilter2D(hdr->target, hdr->internalformat,
+ hdr->width, hdr->height, hdr->format, hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDisp_SeparableFilter2D(GLbyte *pc)
+{
+ __GLXdispatchConvolutionFilterHeader *hdr =
+ (__GLXdispatchConvolutionFilterHeader *) pc;
+ GLint hdrlen, image1len;
+
+ hdrlen = __GLX_PAD(__GLX_CONV_FILT_CMD_DISPATCH_HDR_SIZE);
+
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, hdr->alignment);
+
+ /* XXX check this usage - internal code called
+ ** a version without the packing parameters
+ */
+ image1len = __glXImageSize(hdr->format, hdr->type, 0, hdr->width, 1, 1,
+ 0, hdr->rowLength, 0, hdr->skipRows,
+ hdr->alignment);
+ image1len = __GLX_PAD(image1len);
+
+ glSeparableFilter2D(hdr->target, hdr->internalformat,
+ hdr->width, hdr->height, hdr->format, hdr->type,
+ ((GLubyte *)hdr+hdrlen), ((GLubyte *)hdr+hdrlen+image1len));
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/renderpixswap.c b/nx-X11/programs/Xserver/GL/glx/renderpixswap.c
new file mode 100644
index 000000000..9c3100fb3
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/renderpixswap.c
@@ -0,0 +1,555 @@
+/* $XFree86$ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "unpack.h"
+#include "g_disptab.h"
+#include "g_disptab_EXT.h"
+
+void __glXDispSwap_PolygonStipple(GLbyte *pc)
+{
+ __GLXpixelHeader *hdr = (__GLXpixelHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, (GLint) hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, (GLint) hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, (GLint) hdr->alignment);
+
+ glPolygonStipple((GLubyte *)(hdr+1));
+}
+
+void __glXDispSwap_Bitmap(GLbyte *pc)
+{
+ __GLXdispatchBitmapHeader *hdr = (__GLXdispatchBitmapHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_FLOAT((GLbyte *)&hdr->xorig);
+ __GLX_SWAP_FLOAT((GLbyte *)&hdr->yorig);
+ __GLX_SWAP_FLOAT((GLbyte *)&hdr->xmove);
+ __GLX_SWAP_FLOAT((GLbyte *)&hdr->ymove);
+
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, (GLint) hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, (GLint) hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, (GLint) hdr->alignment);
+
+ glBitmap((GLsizei) hdr->width,
+ (GLsizei) hdr->height,
+ (GLfloat) hdr->xorig,
+ (GLfloat) hdr->yorig,
+ (GLfloat) hdr->xmove,
+ (GLfloat) hdr->ymove,
+ (GLubyte *)(hdr+1));
+}
+
+void __glXDispSwap_TexImage1D(GLbyte *pc)
+{
+ __GLXdispatchTexImageHeader *hdr = (__GLXdispatchTexImageHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->level);
+ __GLX_SWAP_INT((GLbyte *)&hdr->components);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_INT((GLbyte *)&hdr->border);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, !hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, (GLint) hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, (GLint) hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, (GLint) hdr->alignment);
+
+ glTexImage1D(hdr->target,
+ (GLint) hdr->level,
+ (GLint) hdr->components,
+ (GLsizei) hdr->width,
+ (GLint) hdr->border,
+ hdr->format,
+ hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDispSwap_TexImage2D(GLbyte *pc)
+{
+ __GLXdispatchTexImageHeader *hdr = (__GLXdispatchTexImageHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->level);
+ __GLX_SWAP_INT((GLbyte *)&hdr->components);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_INT((GLbyte *)&hdr->border);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, !hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, (GLint) hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, (GLint) hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, (GLint) hdr->alignment);
+
+ glTexImage2D(hdr->target,
+ (GLint) hdr->level,
+ (GLint) hdr->components,
+ (GLsizei) hdr->width,
+ (GLsizei) hdr->height,
+ (GLint) hdr->border,
+ hdr->format,
+ hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDispSwap_TexImage3D(GLbyte *pc)
+{
+ __GLXdispatchTexImage3DHeader *hdr = (__GLXdispatchTexImage3DHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->imageHeight);
+ __GLX_SWAP_INT((GLbyte *)&hdr->imageDepth);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipImages);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipVolumes);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->level);
+ __GLX_SWAP_INT((GLbyte *)&hdr->internalformat);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_INT((GLbyte *)&hdr->depth);
+ __GLX_SWAP_INT((GLbyte *)&hdr->size4d);
+ __GLX_SWAP_INT((GLbyte *)&hdr->border);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, !hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, hdr->rowLength);
+ glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, hdr->imageHeight);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_IMAGES, hdr->skipImages);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, hdr->alignment);
+
+ glTexImage3D(hdr->target, hdr->level, hdr->internalformat, hdr->width,
+ hdr->height, hdr->depth, hdr->border, hdr->format, hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDispSwap_DrawPixels(GLbyte *pc)
+{
+ __GLXdispatchDrawPixelsHeader *hdr = (__GLXdispatchDrawPixelsHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, !hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, (GLint) hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, (GLint) hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, (GLint) hdr->alignment);
+
+ glDrawPixels((GLsizei) hdr->width,
+ (GLsizei) hdr->height,
+ hdr->format,
+ hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDispSwap_TexSubImage1D(GLbyte *pc)
+{
+ __GLXdispatchTexSubImageHeader *hdr = (__GLXdispatchTexSubImageHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->level);
+ __GLX_SWAP_INT((GLbyte *)&hdr->xoffset);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, !hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, (GLint) hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, (GLint) hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, (GLint) hdr->alignment);
+
+ glTexSubImage1D(hdr->target,
+ (GLint) hdr->level,
+ (GLint) hdr->xoffset,
+ (GLsizei) hdr->width,
+ hdr->format,
+ hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDispSwap_TexSubImage2D(GLbyte *pc)
+{
+ __GLXdispatchTexSubImageHeader *hdr = (__GLXdispatchTexSubImageHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->level);
+ __GLX_SWAP_INT((GLbyte *)&hdr->xoffset);
+ __GLX_SWAP_INT((GLbyte *)&hdr->yoffset);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, !hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, (GLint) hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, (GLint) hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, (GLint) hdr->alignment);
+
+ glTexSubImage2D(hdr->target,
+ (GLint) hdr->level,
+ (GLint) hdr->xoffset,
+ (GLint) hdr->yoffset,
+ (GLsizei) hdr->width,
+ (GLsizei) hdr->height,
+ hdr->format,
+ hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDispSwap_TexSubImage3D(GLbyte *pc)
+{
+ __GLXdispatchTexSubImage3DHeader *hdr =
+ (__GLXdispatchTexSubImage3DHeader *) pc;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->imageHeight);
+ __GLX_SWAP_INT((GLbyte *)&hdr->imageDepth);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipImages);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipVolumes);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->level);
+ __GLX_SWAP_INT((GLbyte *)&hdr->xoffset);
+ __GLX_SWAP_INT((GLbyte *)&hdr->yoffset);
+ __GLX_SWAP_INT((GLbyte *)&hdr->zoffset);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_INT((GLbyte *)&hdr->depth);
+ __GLX_SWAP_INT((GLbyte *)&hdr->size4d);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, !hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, hdr->rowLength);
+ glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, hdr->imageHeight);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_IMAGES, hdr->skipImages);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, hdr->alignment);
+
+ glTexSubImage3D(hdr->target, hdr->level, hdr->xoffset, hdr->yoffset,
+ hdr->zoffset, hdr->width, hdr->height, hdr->depth,
+ hdr->format, hdr->type, (GLvoid *)(hdr+1));
+}
+
+void __glXDispSwap_ColorTable(GLbyte *pc)
+{
+ __GLXdispatchColorTableHeader *hdr =
+ (__GLXdispatchColorTableHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->internalformat);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, !hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, hdr->alignment);
+
+ glColorTable(hdr->target, hdr->internalformat,
+ hdr->width, hdr->format, hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDispSwap_ColorSubTable(GLbyte *pc)
+{
+ __GLXdispatchColorSubTableHeader *hdr =
+ (__GLXdispatchColorSubTableHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->start);
+ __GLX_SWAP_INT((GLbyte *)&hdr->count);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, !hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, hdr->alignment);
+
+ glColorSubTable(hdr->target, hdr->start, hdr->count, hdr->format,
+ hdr->type, (GLvoid *)(hdr+1));
+}
+
+void __glXDispSwap_ConvolutionFilter1D(GLbyte *pc)
+{
+ __GLXdispatchConvolutionFilterHeader *hdr =
+ (__GLXdispatchConvolutionFilterHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->internalformat);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, !hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, hdr->alignment);
+
+ glConvolutionFilter2D(hdr->target, hdr->internalformat,
+ hdr->width, 1, hdr->format, hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDispSwap_ConvolutionFilter2D(GLbyte *pc)
+{
+ __GLXdispatchConvolutionFilterHeader *hdr =
+ (__GLXdispatchConvolutionFilterHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->internalformat);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, !hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, hdr->alignment);
+
+ glConvolutionFilter2D(hdr->target, hdr->internalformat,
+ hdr->width, hdr->height, hdr->format, hdr->type,
+ (GLvoid *)(hdr+1));
+}
+
+void __glXDispSwap_SeparableFilter2D(GLbyte *pc)
+{
+ __GLXdispatchConvolutionFilterHeader *hdr =
+ (__GLXdispatchConvolutionFilterHeader *) pc;
+ GLint hdrlen, image1len;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ hdrlen = __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->internalformat);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, !hdr->swapBytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, hdr->lsbFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, hdr->rowLength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, hdr->skipRows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, hdr->skipPixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, hdr->alignment);
+
+ /* XXX check this usage - internal code called
+ ** a version without the packing parameters
+ */
+ image1len = __glXImageSize(hdr->format, hdr->type, 0, hdr->width, 1, 1,
+ 0, hdr->rowLength, 0, hdr->skipRows,
+ hdr->alignment);
+ image1len = __GLX_PAD(image1len);
+
+
+ glSeparableFilter2D(hdr->target, hdr->internalformat,
+ hdr->width, hdr->height, hdr->format, hdr->type,
+ ((GLubyte *)hdr+hdrlen), ((GLubyte *)hdr+hdrlen+image1len));
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/rensize.c b/nx-X11/programs/Xserver/GL/glx/rensize.c
new file mode 100644
index 000000000..7ab02d257
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/rensize.c
@@ -0,0 +1,987 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/rensize.c,v 1.6 2003/09/28 20:15:43 alanh Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <GL/gl.h>
+#include "glxserver.h"
+#include "GL/glxproto.h"
+#include "unpack.h"
+#include "impsize.h"
+
+#define SWAPL(a) \
+ (((a & 0xff000000U)>>24) | ((a & 0xff0000U)>>8) | \
+ ((a & 0xff00U)<<8) | ((a & 0xffU)<<24))
+
+int __glXCallListsReqSize(GLbyte *pc, Bool swap )
+{
+ GLsizei n = *(GLsizei *)(pc + 0);
+ GLenum type = *(GLenum *)(pc + 4);
+
+ if (swap) {
+ n = SWAPL( n );
+ type = SWAPL( type );
+ }
+ return n * __glCallLists_size( type );
+}
+
+int __glXFogivReqSize(GLbyte *pc, Bool swap )
+{
+ GLenum pname = *(GLenum *)(pc + 0);
+ if (swap) {
+ pname = SWAPL( pname );
+ }
+ return 4 * __glFogiv_size( pname ); /* defined in samplegl lib */
+}
+
+int __glXFogfvReqSize(GLbyte *pc, Bool swap )
+{
+ return __glXFogivReqSize( pc, swap );
+}
+
+int __glXLightfvReqSize(GLbyte *pc, Bool swap )
+{
+ GLenum pname = *(GLenum *)(pc + 4);
+ if (swap) {
+ pname = SWAPL( pname );
+ }
+ return 4 * __glLightfv_size( pname ); /* defined in samplegl lib */
+}
+
+int __glXLightivReqSize(GLbyte *pc, Bool swap )
+{
+ return __glXLightfvReqSize( pc, swap );
+}
+
+int __glXLightModelfvReqSize(GLbyte *pc, Bool swap )
+{
+ GLenum pname = *(GLenum *)(pc + 0);
+ if (swap) {
+ pname = SWAPL( pname );
+ }
+ return 4 * __glLightModelfv_size( pname ); /* defined in samplegl lib */
+}
+
+int __glXLightModelivReqSize(GLbyte *pc, Bool swap )
+{
+ return __glXLightModelfvReqSize( pc, swap );
+}
+
+int __glXMaterialfvReqSize(GLbyte *pc, Bool swap )
+{
+ GLenum pname = *(GLenum *)(pc + 4);
+ if (swap) {
+ pname = SWAPL( pname );
+ }
+ return 4 * __glMaterialfv_size( pname ); /* defined in samplegl lib */
+}
+
+int __glXMaterialivReqSize(GLbyte *pc, Bool swap )
+{
+ return __glXMaterialfvReqSize( pc, swap );
+}
+
+int __glXTexGendvReqSize(GLbyte *pc, Bool swap )
+{
+ GLenum pname = *(GLenum *)(pc + 4);
+ if (swap) {
+ pname = SWAPL( pname );
+ }
+ return 8 * __glTexGendv_size( pname ); /* defined in samplegl lib */
+}
+
+int __glXTexGenfvReqSize(GLbyte *pc, Bool swap )
+{
+ GLenum pname = *(GLenum *)(pc + 4);
+ if (swap) {
+ pname = SWAPL( pname );
+ }
+ return 4 * __glTexGenfv_size( pname ); /* defined in samplegl lib */
+}
+
+int __glXTexGenivReqSize(GLbyte *pc, Bool swap )
+{
+ return __glXTexGenfvReqSize( pc, swap );
+}
+
+int __glXTexParameterfvReqSize(GLbyte *pc, Bool swap )
+{
+ GLenum pname = *(GLenum *)(pc + 4);
+ if (swap) {
+ pname = SWAPL( pname );
+ }
+ return 4 * __glTexParameterfv_size( pname ); /* defined in samplegl lib */
+}
+
+int __glXTexParameterivReqSize(GLbyte *pc, Bool swap )
+{
+ return __glXTexParameterfvReqSize( pc, swap );
+}
+
+int __glXTexEnvfvReqSize(GLbyte *pc, Bool swap )
+{
+ GLenum pname = *(GLenum *)(pc + 4);
+ if (swap) {
+ pname = SWAPL( pname );
+ }
+ return 4 * __glTexEnvfv_size( pname ); /* defined in samplegl lib */
+}
+
+int __glXTexEnvivReqSize(GLbyte *pc, Bool swap )
+{
+ return __glXTexEnvfvReqSize( pc, swap );
+}
+
+static int Map1Size( GLint k, GLint order)
+{
+ if (order <= 0 || k < 0) return -1;
+ return k * order;
+}
+
+int __glXMap1dReqSize(GLbyte *pc, Bool swap )
+{
+ GLenum target;
+ GLint order, k;
+
+ target = *(GLenum*) (pc + 16);
+ order = *(GLint*) (pc + 20);
+ if (swap) {
+ target = SWAPL( target );
+ order = SWAPL( order );
+ }
+ k = __glMap1d_size( target );
+ return 8 * Map1Size( k, order );
+}
+
+int __glXMap1fReqSize(GLbyte *pc, Bool swap )
+{
+ GLenum target;
+ GLint order, k;
+
+ target = *(GLenum *)(pc + 0);
+ order = *(GLint *)(pc + 12);
+ if (swap) {
+ target = SWAPL( target );
+ order = SWAPL( order );
+ }
+ k = __glMap1f_size(target);
+ return 4 * Map1Size(k, order);
+}
+
+static int Map2Size(int k, int majorOrder, int minorOrder)
+{
+ if (majorOrder <= 0 || minorOrder <= 0 || k < 0) return -1;
+ return k * majorOrder * minorOrder;
+}
+
+int __glXMap2dReqSize(GLbyte *pc, Bool swap )
+{
+ GLenum target;
+ GLint uorder, vorder, k;
+
+ target = *(GLenum *)(pc + 32);
+ uorder = *(GLint *)(pc + 36);
+ vorder = *(GLint *)(pc + 40);
+ if (swap) {
+ target = SWAPL( target );
+ uorder = SWAPL( uorder );
+ vorder = SWAPL( vorder );
+ }
+ k = __glMap2d_size( target );
+ return 8 * Map2Size( k, uorder, vorder );
+}
+
+int __glXMap2fReqSize(GLbyte *pc, Bool swap )
+{
+ GLenum target;
+ GLint uorder, vorder, k;
+
+ target = *(GLenum *)(pc + 0);
+ uorder = *(GLint *)(pc + 12);
+ vorder = *(GLint *)(pc + 24);
+ if (swap) {
+ target = SWAPL( target );
+ uorder = SWAPL( uorder );
+ vorder = SWAPL( vorder );
+ }
+ k = __glMap2f_size( target );
+ return 4 * Map2Size( k, uorder, vorder );
+}
+
+int __glXPixelMapfvReqSize(GLbyte *pc, Bool swap )
+{
+ GLint mapsize;
+ mapsize = *(GLint *)(pc + 4);
+ if (swap) {
+ mapsize = SWAPL( mapsize );
+ }
+ return 4 * mapsize;
+}
+
+int __glXPixelMapuivReqSize(GLbyte *pc, Bool swap )
+{
+ return __glXPixelMapfvReqSize( pc, swap );
+}
+
+int __glXPixelMapusvReqSize(GLbyte *pc, Bool swap )
+{
+ GLint mapsize;
+ mapsize = *(GLint *)(pc + 4);
+ if (swap) {
+ mapsize = SWAPL( mapsize );
+ }
+ return 2 * mapsize;
+}
+
+/**
+ * Calculate the size of an image.
+ *
+ * The size of an image sent to the server from the client or sent from the
+ * server to the client is calculated. The size is based on the dimensions
+ * of the image, the type of pixel data, padding in the image, and the
+ * alignment requirements of the image.
+ *
+ * \param format Format of the pixels. Same as the \c format parameter
+ * to \c glTexImage1D
+ * \param type Type of the pixel data. Same as the \c type parameter
+ * to \c glTexImage1D
+ * \param target Typically the texture target of the image. If the
+ * target is one of \c GL_PROXY_*, the size returned is
+ * always zero. For uses that do not have a texture target
+ * (e.g, glDrawPixels), zero should be specified.
+ * \param w Width of the image data. Must be >= 1.
+ * \param h Height of the image data. Must be >= 1, even for 1D
+ * images.
+ * \param d Depth of the image data. Must be >= 1, even for 1D or
+ * 2D images.
+ * \param imageHeight If non-zero, defines the true height of a volumetric
+ * image. This value will be used instead of \c h for
+ * calculating the size of the image.
+ * \param rowLength If non-zero, defines the true width of an image. This
+ * value will be used instead of \c w for calculating the
+ * size of the image.
+ * \param skipImages Number of extra layers of image data in a volumtric
+ * image that are to be skipped before the real data.
+ * \param skipRows Number of extra rows of image data in an image that are
+ * to be skipped before the real data.
+ * \param alignment Specifies the alignment for the start of each pixel row
+ * in memory. This value must be one of 1, 2, 4, or 8.
+ *
+ * \returns
+ * The size of the image is returned. If the specified \c format and \c type
+ * are invalid, -1 is returned. If \c target is one of \c GL_PROXY_*, zero
+ * is returned.
+ */
+int __glXImageSize( GLenum format, GLenum type, GLenum target,
+ GLsizei w, GLsizei h, GLsizei d,
+ GLint imageHeight, GLint rowLength,
+ GLint skipImages, GLint skipRows, GLint alignment )
+{
+ GLint bytesPerElement, elementsPerGroup, groupsPerRow;
+ GLint groupSize, rowSize, padding, imageSize;
+
+ if (w < 0 || h < 0 || d < 0 ||
+ (type == GL_BITMAP &&
+ (format != GL_COLOR_INDEX && format != GL_STENCIL_INDEX))) {
+ return -1;
+ }
+ if (w==0 || h==0 || d == 0) return 0;
+
+ switch( target ) {
+ case GL_PROXY_TEXTURE_1D:
+ case GL_PROXY_TEXTURE_2D:
+ case GL_PROXY_TEXTURE_3D:
+ case GL_PROXY_TEXTURE_4D_SGIS:
+ case GL_PROXY_TEXTURE_CUBE_MAP:
+ case GL_PROXY_TEXTURE_RECTANGLE_ARB:
+ case GL_PROXY_HISTOGRAM:
+ case GL_PROXY_COLOR_TABLE:
+ case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:
+ case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
+ case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
+ case GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP:
+ return 0;
+ }
+
+ if (type == GL_BITMAP) {
+ if (rowLength > 0) {
+ groupsPerRow = rowLength;
+ } else {
+ groupsPerRow = w;
+ }
+ rowSize = (groupsPerRow + 7) >> 3;
+ padding = (rowSize % alignment);
+ if (padding) {
+ rowSize += alignment - padding;
+ }
+ return ((h + skipRows) * rowSize);
+ } else {
+ switch(format) {
+ case GL_COLOR_INDEX:
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_COMPONENT:
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_INTENSITY:
+ elementsPerGroup = 1;
+ break;
+ case GL_422_EXT:
+ case GL_422_REV_EXT:
+ case GL_422_AVERAGE_EXT:
+ case GL_422_REV_AVERAGE_EXT:
+ case GL_DEPTH_STENCIL_NV:
+ case GL_DEPTH_STENCIL_MESA:
+ case GL_YCBCR_MESA:
+ case GL_LUMINANCE_ALPHA:
+ elementsPerGroup = 2;
+ break;
+ case GL_RGB:
+ case GL_BGR:
+ elementsPerGroup = 3;
+ break;
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_ABGR_EXT:
+ elementsPerGroup = 4;
+ break;
+ default:
+ return -1;
+ }
+ switch(type) {
+ case GL_UNSIGNED_BYTE:
+ case GL_BYTE:
+ bytesPerElement = 1;
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ bytesPerElement = 1;
+ elementsPerGroup = 1;
+ break;
+ case GL_UNSIGNED_SHORT:
+ case GL_SHORT:
+ bytesPerElement = 2;
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_SHORT_8_8_APPLE:
+ case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
+ case GL_UNSIGNED_SHORT_15_1_MESA:
+ case GL_UNSIGNED_SHORT_1_15_REV_MESA:
+ bytesPerElement = 2;
+ elementsPerGroup = 1;
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ bytesPerElement = 4;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ case GL_UNSIGNED_INT_24_8_NV:
+ case GL_UNSIGNED_INT_24_8_MESA:
+ case GL_UNSIGNED_INT_8_24_REV_MESA:
+ bytesPerElement = 4;
+ elementsPerGroup = 1;
+ break;
+ default:
+ return -1;
+ }
+ groupSize = bytesPerElement * elementsPerGroup;
+ if (rowLength > 0) {
+ groupsPerRow = rowLength;
+ } else {
+ groupsPerRow = w;
+ }
+ rowSize = groupsPerRow * groupSize;
+ padding = (rowSize % alignment);
+ if (padding) {
+ rowSize += alignment - padding;
+ }
+ if (imageHeight > 0) {
+ imageSize = (imageHeight + skipRows) * rowSize;
+ } else {
+ imageSize = (h + skipRows) * rowSize;
+ }
+ return ((d + skipImages) * imageSize);
+ }
+}
+
+
+int __glXDrawPixelsReqSize(GLbyte *pc, Bool swap )
+{
+ __GLXdispatchDrawPixelsHeader *hdr = (__GLXdispatchDrawPixelsHeader *) pc;
+ GLenum format = hdr->format;
+ GLenum type = hdr->type;
+ GLint w = hdr->width;
+ GLint h = hdr->height;
+ GLint rowLength = hdr->rowLength;
+ GLint skipRows = hdr->skipRows;
+ GLint alignment = hdr->alignment;
+
+ if (swap) {
+ format = SWAPL( format );
+ type = SWAPL( type );
+ w = SWAPL( w );
+ h = SWAPL( h );
+ rowLength = SWAPL( rowLength );
+ skipRows = SWAPL( skipRows );
+ alignment = SWAPL( alignment );
+ }
+ return __glXImageSize( format, type, 0, w, h, 1,
+ 0, rowLength, 0, skipRows, alignment );
+}
+
+int __glXBitmapReqSize(GLbyte *pc, Bool swap )
+{
+ __GLXdispatchBitmapHeader *hdr = (__GLXdispatchBitmapHeader *) pc;
+ GLint w = hdr->width;
+ GLint h = hdr->height;
+ GLint rowLength = hdr->rowLength;
+ GLint skipRows = hdr->skipRows;
+ GLint alignment = hdr->alignment;
+
+ if (swap) {
+ w = SWAPL( w );
+ h = SWAPL( h );
+ rowLength = SWAPL( rowLength );
+ skipRows = SWAPL( skipRows );
+ alignment = SWAPL( alignment );
+ }
+ return __glXImageSize( GL_COLOR_INDEX, GL_BITMAP, 0, w, h, 1,
+ 0, rowLength, 0, skipRows, alignment );
+}
+
+int __glXTexImage1DReqSize(GLbyte *pc, Bool swap )
+{
+ __GLXdispatchTexImageHeader *hdr = (__GLXdispatchTexImageHeader *) pc;
+ GLenum target = hdr->target;
+ GLenum format = hdr->format;
+ GLenum type = hdr->type;
+ GLint w = hdr->width;
+ GLint rowLength = hdr->rowLength;
+ GLint skipRows = hdr->skipRows;
+ GLint alignment = hdr->alignment;
+
+ if (swap) {
+ target = SWAPL( target );
+ format = SWAPL( format );
+ type = SWAPL( type );
+ w = SWAPL( w );
+ rowLength = SWAPL( rowLength );
+ skipRows = SWAPL( skipRows );
+ alignment = SWAPL( alignment );
+ }
+ if (target == GL_PROXY_TEXTURE_1D) {
+ return 0;
+ } else if (format == GL_STENCIL_INDEX || format == GL_DEPTH_COMPONENT) {
+ return -1;
+ }
+ return __glXImageSize( format, type, 0, w, 1, 1,
+ 0, rowLength, 0, skipRows, alignment );
+}
+
+int __glXTexImage2DReqSize(GLbyte *pc, Bool swap )
+{
+ __GLXdispatchTexImageHeader *hdr = (__GLXdispatchTexImageHeader *) pc;
+ GLenum target = hdr->target;
+ GLenum format = hdr->format;
+ GLenum type = hdr->type;
+ GLint w = hdr->width;
+ GLint h = hdr->height;
+ GLint rowLength = hdr->rowLength;
+ GLint skipRows = hdr->skipRows;
+ GLint alignment = hdr->alignment;
+
+ if (swap) {
+ target = SWAPL( target );
+ format = SWAPL( format );
+ type = SWAPL( type );
+ w = SWAPL( w );
+ h = SWAPL( h );
+ rowLength = SWAPL( rowLength );
+ skipRows = SWAPL( skipRows );
+ alignment = SWAPL( alignment );
+ }
+ if (target == GL_PROXY_TEXTURE_2D || target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
+ return 0;
+ } else if (format == GL_STENCIL_INDEX || format == GL_DEPTH_COMPONENT) {
+ return -1;
+ }
+ return __glXImageSize( format, type, 0, w, h, 1,
+ 0, rowLength, 0, skipRows, alignment );
+}
+
+/* XXX this is used elsewhere - should it be exported from glxserver.h? */
+int __glXTypeSize(GLenum enm)
+{
+ switch(enm) {
+ case GL_BYTE: return sizeof(GLbyte);
+ case GL_UNSIGNED_BYTE: return sizeof(GLubyte);
+ case GL_SHORT: return sizeof(GLshort);
+ case GL_UNSIGNED_SHORT: return sizeof(GLushort);
+ case GL_INT: return sizeof(GLint);
+ case GL_UNSIGNED_INT: return sizeof(GLint);
+ case GL_FLOAT: return sizeof(GLfloat);
+ case GL_DOUBLE: return sizeof(GLdouble);
+ default: return -1;
+ }
+}
+
+int __glXDrawArraysSize( GLbyte *pc, Bool swap )
+{
+ __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *) pc;
+ __GLXdispatchDrawArraysComponentHeader *compHeader;
+ GLint numVertexes = hdr->numVertexes;
+ GLint numComponents = hdr->numComponents;
+ GLint arrayElementSize = 0;
+ int i;
+
+ if (swap) {
+ numVertexes = SWAPL( numVertexes );
+ numComponents = SWAPL( numComponents );
+ }
+
+ pc += sizeof(__GLXdispatchDrawArraysHeader);
+ compHeader = (__GLXdispatchDrawArraysComponentHeader *) pc;
+
+ for (i=0; i<numComponents; i++) {
+ GLenum datatype = compHeader[i].datatype;
+ GLint numVals = compHeader[i].numVals;
+ GLint component = compHeader[i].component;
+
+ if (swap) {
+ datatype = SWAPL( datatype );
+ numVals = SWAPL( numVals );
+ component = SWAPL( component );
+ }
+
+ switch (component) {
+ case GL_VERTEX_ARRAY:
+ case GL_COLOR_ARRAY:
+ case GL_TEXTURE_COORD_ARRAY:
+ break;
+ case GL_SECONDARY_COLOR_ARRAY:
+ case GL_NORMAL_ARRAY:
+ if (numVals != 3) {
+ /* bad size */
+ return -1;
+ }
+ break;
+ case GL_FOG_COORD_ARRAY:
+ case GL_INDEX_ARRAY:
+ if (numVals != 1) {
+ /* bad size */
+ return -1;
+ }
+ break;
+ case GL_EDGE_FLAG_ARRAY:
+ if ((numVals != 1) && (datatype != GL_UNSIGNED_BYTE)) {
+ /* bad size or bad type */
+ return -1;
+ }
+ break;
+ default:
+ /* unknown component type */
+ return -1;
+ }
+
+ arrayElementSize += __GLX_PAD(numVals * __glXTypeSize(datatype));
+
+ pc += sizeof(__GLXdispatchDrawArraysComponentHeader);
+ }
+
+ return ((numComponents * sizeof(__GLXdispatchDrawArraysComponentHeader)) +
+ (numVertexes * arrayElementSize));
+}
+
+int __glXPrioritizeTexturesReqSize(GLbyte *pc, Bool swap )
+{
+ GLint n = *(GLsizei *)(pc + 0);
+ if (swap) n = SWAPL(n);
+ return(8*n); /* 4*n for textures, 4*n for priorities */
+}
+
+int __glXTexSubImage1DReqSize(GLbyte *pc, Bool swap )
+{
+ __GLXdispatchTexSubImageHeader *hdr = (__GLXdispatchTexSubImageHeader *) pc;
+ GLenum format = hdr->format;
+ GLenum type = hdr->type;
+ GLint w = hdr->width;
+ GLint rowLength = hdr->rowLength;
+ GLint skipRows = hdr->skipRows;
+ GLint alignment = hdr->alignment;
+
+ if (swap) {
+ format = SWAPL( format );
+ type = SWAPL( type );
+ w = SWAPL( w );
+ rowLength = SWAPL( rowLength );
+ skipRows = SWAPL( skipRows );
+ alignment = SWAPL( alignment );
+ }
+ return __glXImageSize( format, type, 0, w, 1, 1,
+ 0, rowLength, 0, skipRows, alignment );
+}
+
+int __glXTexSubImage2DReqSize(GLbyte *pc, Bool swap )
+{
+ __GLXdispatchTexSubImageHeader *hdr = (__GLXdispatchTexSubImageHeader *) pc;
+ GLenum format = hdr->format;
+ GLenum type = hdr->type;
+ GLint w = hdr->width;
+ GLint h = hdr->height;
+ GLint rowLength = hdr->rowLength;
+ GLint skipRows = hdr->skipRows;
+ GLint alignment = hdr->alignment;
+
+ if (swap) {
+ format = SWAPL( format );
+ type = SWAPL( type );
+ w = SWAPL( w );
+ h = SWAPL( h );
+ rowLength = SWAPL( rowLength );
+ skipRows = SWAPL( skipRows );
+ alignment = SWAPL( alignment );
+ }
+ return __glXImageSize( format, type, 0, w, h, 1,
+ 0, rowLength, 0, skipRows, alignment );
+}
+
+int __glXTexImage3DReqSize(GLbyte *pc, Bool swap )
+{
+ __GLXdispatchTexImage3DHeader *hdr = (__GLXdispatchTexImage3DHeader *) pc;
+ GLenum target = hdr->target;
+ GLenum format = hdr->format;
+ GLenum type = hdr->type;
+ GLint w = hdr->width;
+ GLint h = hdr->height;
+ GLint d = hdr->depth;
+ GLint imageHeight = hdr->imageHeight;
+ GLint rowLength = hdr->rowLength;
+ GLint skipImages = hdr->skipImages;
+ GLint skipRows = hdr->skipRows;
+ GLint alignment = hdr->alignment;
+ GLint nullImage = hdr->nullimage;
+
+ if (swap) {
+ target = SWAPL( target );
+ format = SWAPL( format );
+ type = SWAPL( type );
+ w = SWAPL( w );
+ h = SWAPL( h );
+ d = SWAPL( d );
+ imageHeight = SWAPL( imageHeight );
+ rowLength = SWAPL( rowLength );
+ skipImages = SWAPL( skipImages );
+ skipRows = SWAPL( skipRows );
+ alignment = SWAPL( alignment );
+ }
+ if (target == GL_PROXY_TEXTURE_3D || nullImage) {
+ return 0;
+ } else {
+ return __glXImageSize( format, type, target, w, h, d, imageHeight,
+ rowLength, skipImages, skipRows, alignment );
+ }
+}
+
+int __glXTexSubImage3DReqSize(GLbyte *pc, Bool swap )
+{
+ __GLXdispatchTexSubImage3DHeader *hdr =
+ (__GLXdispatchTexSubImage3DHeader *) pc;
+ GLenum target = hdr->target;
+ GLenum format = hdr->format;
+ GLenum type = hdr->type;
+ GLint w = hdr->width;
+ GLint h = hdr->height;
+ GLint d = hdr->depth;
+ GLint imageHeight = hdr->imageHeight;
+ GLint rowLength = hdr->rowLength;
+ GLint skipImages = hdr->skipImages;
+ GLint skipRows = hdr->skipRows;
+ GLint alignment = hdr->alignment;
+
+ if (swap) {
+ target = SWAPL( target );
+ format = SWAPL( format );
+ type = SWAPL( type );
+ w = SWAPL( w );
+ h = SWAPL( h );
+ d = SWAPL( d );
+ imageHeight = SWAPL( imageHeight );
+ rowLength = SWAPL( rowLength );
+ skipImages = SWAPL( skipImages );
+ skipRows = SWAPL( skipRows );
+ alignment = SWAPL( alignment );
+ }
+ if (target == GL_PROXY_TEXTURE_3D) {
+ return 0;
+ } else {
+ return __glXImageSize( format, type, target, w, h, d, imageHeight,
+ rowLength, skipImages, skipRows, alignment );
+ }
+}
+
+int __glXConvolutionFilter1DReqSize(GLbyte *pc, Bool swap )
+{
+ __GLXdispatchConvolutionFilterHeader *hdr =
+ (__GLXdispatchConvolutionFilterHeader *) pc;
+
+ GLenum format = hdr->format;
+ GLenum type = hdr->type;
+ GLint w = hdr->width;
+ GLint rowLength = hdr->rowLength;
+ GLint alignment = hdr->alignment;
+
+ if (swap) {
+ format = SWAPL( format );
+ type = SWAPL( type );
+ w = SWAPL( w );
+ rowLength = SWAPL( rowLength );
+ alignment = SWAPL( alignment );
+ }
+
+ return __glXImageSize( format, type, 0, w, 1, 1,
+ 0, rowLength, 0, 0, alignment );
+}
+
+int __glXConvolutionFilter2DReqSize(GLbyte *pc, Bool swap )
+{
+ __GLXdispatchConvolutionFilterHeader *hdr =
+ (__GLXdispatchConvolutionFilterHeader *) pc;
+
+ GLenum format = hdr->format;
+ GLenum type = hdr->type;
+ GLint w = hdr->width;
+ GLint h = hdr->height;
+ GLint rowLength = hdr->rowLength;
+ GLint skipRows = hdr->skipRows;
+ GLint alignment = hdr->alignment;
+
+ if (swap) {
+ format = SWAPL( format );
+ type = SWAPL( type );
+ w = SWAPL( w );
+ h = SWAPL( h );
+ rowLength = SWAPL( rowLength );
+ skipRows = SWAPL( skipRows );
+ alignment = SWAPL( alignment );
+ }
+
+ return __glXImageSize( format, type, 0, w, h, 1,
+ 0, rowLength, 0, skipRows, alignment );
+}
+
+int __glXConvolutionParameterivSize(GLenum pname)
+{
+ switch (pname) {
+ case GL_CONVOLUTION_BORDER_COLOR:
+ case GL_CONVOLUTION_FILTER_SCALE:
+ case GL_CONVOLUTION_FILTER_BIAS:
+ return 4;
+ case GL_CONVOLUTION_BORDER_MODE:
+ return 1;
+ default:
+ return -1;
+ }
+}
+
+int __glXConvolutionParameterfvSize(GLenum pname)
+{
+ return __glXConvolutionParameterivSize(pname);
+}
+
+int __glXConvolutionParameterivReqSize(GLbyte *pc, Bool swap )
+{
+ GLenum pname = *(GLenum *)(pc + 4);
+ if (swap) {
+ pname = SWAPL( pname );
+ }
+ return 4 * __glXConvolutionParameterivSize( pname );
+}
+
+int __glXConvolutionParameterfvReqSize(GLbyte *pc, Bool swap )
+{
+ return __glXConvolutionParameterivReqSize( pc, swap );
+}
+
+int __glXSeparableFilter2DReqSize(GLbyte *pc, Bool swap )
+{
+ __GLXdispatchConvolutionFilterHeader *hdr =
+ (__GLXdispatchConvolutionFilterHeader *) pc;
+
+ GLint image1size, image2size;
+ GLenum format = hdr->format;
+ GLenum type = hdr->type;
+ GLint w = hdr->width;
+ GLint h = hdr->height;
+ GLint rowLength = hdr->rowLength;
+ GLint alignment = hdr->alignment;
+
+ if (swap) {
+ format = SWAPL( format );
+ type = SWAPL( type );
+ w = SWAPL( w );
+ h = SWAPL( h );
+ rowLength = SWAPL( rowLength );
+ alignment = SWAPL( alignment );
+ }
+
+ /* XXX Should rowLength be used for either or both image? */
+ image1size = __glXImageSize( format, type, 0, w, 1, 1,
+ 0, rowLength, 0, 0, alignment );
+ image1size = __GLX_PAD(image1size);
+ image2size = __glXImageSize( format, type, 0, h, 1, 1,
+ 0, rowLength, 0, 0, alignment );
+ return image1size + image2size;
+
+}
+
+int __glXColorTableParameterfvSize(GLenum pname)
+{
+ /* currently, only scale and bias are supported; return RGBA */
+ switch(pname) {
+ case GL_COLOR_TABLE_SCALE:
+ case GL_COLOR_TABLE_BIAS:
+ return 4;
+ default:
+ return 0;
+ }
+}
+
+int __glXColorTableParameterivSize(GLenum pname)
+{
+ /* fv and iv are the same in this context */
+ return __glXColorTableParameterfvSize(pname);
+}
+
+int __glXColorTableReqSize(GLbyte *pc, Bool swap )
+{
+ __GLXdispatchColorTableHeader *hdr =
+ (__GLXdispatchColorTableHeader *) pc;
+
+ GLenum target = hdr->target;
+ GLenum format = hdr->format;
+ GLenum type = hdr->type;
+ GLint w = hdr->width;
+ GLint rowLength = hdr->rowLength;
+ GLint alignment = hdr->alignment;
+
+ switch (target) {
+ case GL_PROXY_TEXTURE_1D:
+ case GL_PROXY_TEXTURE_2D:
+ case GL_PROXY_TEXTURE_3D:
+ case GL_PROXY_COLOR_TABLE:
+ case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
+ case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
+ return 0;
+ }
+
+ if (swap) {
+ format = SWAPL( format );
+ type = SWAPL( type );
+ w = SWAPL( w );
+ rowLength = SWAPL( rowLength );
+ alignment = SWAPL( alignment );
+ }
+
+ return __glXImageSize( format, type, 0, w, 1, 1,
+ 0, rowLength, 0, 0, alignment );
+}
+
+int __glXColorSubTableReqSize(GLbyte *pc, Bool swap )
+{
+ __GLXdispatchColorSubTableHeader *hdr =
+ (__GLXdispatchColorSubTableHeader *) pc;
+
+ GLenum format = hdr->format;
+ GLenum type = hdr->type;
+ GLint count = hdr->count;
+ GLint rowLength = hdr->rowLength;
+ GLint alignment = hdr->alignment;
+
+ if (swap) {
+ format = SWAPL( format );
+ type = SWAPL( type );
+ count = SWAPL( count );
+ rowLength = SWAPL( rowLength );
+ alignment = SWAPL( alignment );
+ }
+
+ return __glXImageSize( format, type, 0, count, 1, 1,
+ 0, rowLength, 0, 0, alignment );
+}
+
+int __glXColorTableParameterfvReqSize(GLbyte *pc, Bool swap )
+{
+ GLenum pname = *(GLenum *)(pc + 4);
+ if (swap) {
+ pname = SWAPL( pname );
+ }
+ return 4 * __glXColorTableParameterfvSize(pname);
+}
+
+int __glXColorTableParameterivReqSize(GLbyte *pc, Bool swap )
+{
+ /* no difference between fv and iv versions */
+ return __glXColorTableParameterfvReqSize(pc, swap);
+}
+
+int __glXPointParameterfvARBReqSize(GLbyte *pc, Bool swap )
+{
+ GLenum pname = *(GLenum *)(pc + 0);
+ if (swap) {
+ pname = SWAPL( pname );
+ }
+ return 4 * __glPointParameterfvEXT_size( pname );
+}
+
+int __glXPointParameterivReqSize(GLbyte *pc, Bool swap )
+{
+ /* no difference between fv and iv versions */
+ return __glXPointParameterfvARBReqSize(pc, swap);
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/rensizetab.c b/nx-X11/programs/Xserver/GL/glx/rensizetab.c
new file mode 100644
index 000000000..41656890c
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/rensizetab.c
@@ -0,0 +1,2448 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/rensizetab.c,v 1.5 2004/01/28 18:11:53 alanh Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "g_disptab_EXT.h"
+
+__GLXrenderSizeData __glXRenderSizeTable[__GLX_MAX_RENDER_OPCODE_EXT - __GLX_MIN_RENDER_OPCODE_EXT + 1] = {
+ /* no such opcode */ { 0, 0 },
+ /* CallList */ { 8, 0 },
+ /* CallLists */ { 12, __glXCallListsReqSize },
+ /* ListBase */ { 8, 0 },
+ /* Begin */ { 8, 0 },
+ /* Bitmap */ { 48, __glXBitmapReqSize },
+ /* Color3bv */ { 8, 0 },
+ /* Color3dv */ { 28, 0 },
+ /* Color3fv */ { 16, 0 },
+ /* Color3iv */ { 16, 0 },
+ /* Color3sv */ { 12, 0 },
+ /* Color3ubv */ { 8, 0 },
+ /* Color3uiv */ { 16, 0 },
+ /* Color3usv */ { 12, 0 },
+ /* Color4bv */ { 8, 0 },
+ /* Color4dv */ { 36, 0 },
+ /* Color4fv */ { 20, 0 },
+ /* Color4iv */ { 20, 0 },
+ /* Color4sv */ { 12, 0 },
+ /* Color4ubv */ { 8, 0 },
+ /* Color4uiv */ { 20, 0 },
+ /* Color4usv */ { 12, 0 },
+ /* EdgeFlagv */ { 8, 0 },
+ /* End */ { 4, 0 },
+ /* Indexdv */ { 12, 0 },
+ /* Indexfv */ { 8, 0 },
+ /* Indexiv */ { 8, 0 },
+ /* Indexsv */ { 8, 0 },
+ /* Normal3bv */ { 8, 0 },
+ /* Normal3dv */ { 28, 0 },
+ /* Normal3fv */ { 16, 0 },
+ /* Normal3iv */ { 16, 0 },
+ /* Normal3sv */ { 12, 0 },
+ /* RasterPos2dv */ { 20, 0 },
+ /* RasterPos2fv */ { 12, 0 },
+ /* RasterPos2iv */ { 12, 0 },
+ /* RasterPos2sv */ { 8, 0 },
+ /* RasterPos3dv */ { 28, 0 },
+ /* RasterPos3fv */ { 16, 0 },
+ /* RasterPos3iv */ { 16, 0 },
+ /* RasterPos3sv */ { 12, 0 },
+ /* RasterPos4dv */ { 36, 0 },
+ /* RasterPos4fv */ { 20, 0 },
+ /* RasterPos4iv */ { 20, 0 },
+ /* RasterPos4sv */ { 12, 0 },
+ /* Rectdv */ { 36, 0 },
+ /* Rectfv */ { 20, 0 },
+ /* Rectiv */ { 20, 0 },
+ /* Rectsv */ { 12, 0 },
+ /* TexCoord1dv */ { 12, 0 },
+ /* TexCoord1fv */ { 8, 0 },
+ /* TexCoord1iv */ { 8, 0 },
+ /* TexCoord1sv */ { 8, 0 },
+ /* TexCoord2dv */ { 20, 0 },
+ /* TexCoord2fv */ { 12, 0 },
+ /* TexCoord2iv */ { 12, 0 },
+ /* TexCoord2sv */ { 8, 0 },
+ /* TexCoord3dv */ { 28, 0 },
+ /* TexCoord3fv */ { 16, 0 },
+ /* TexCoord3iv */ { 16, 0 },
+ /* TexCoord3sv */ { 12, 0 },
+ /* TexCoord4dv */ { 36, 0 },
+ /* TexCoord4fv */ { 20, 0 },
+ /* TexCoord4iv */ { 20, 0 },
+ /* TexCoord4sv */ { 12, 0 },
+ /* Vertex2dv */ { 20, 0 },
+ /* Vertex2fv */ { 12, 0 },
+ /* Vertex2iv */ { 12, 0 },
+ /* Vertex2sv */ { 8, 0 },
+ /* Vertex3dv */ { 28, 0 },
+ /* Vertex3fv */ { 16, 0 },
+ /* Vertex3iv */ { 16, 0 },
+ /* Vertex3sv */ { 12, 0 },
+ /* Vertex4dv */ { 36, 0 },
+ /* Vertex4fv */ { 20, 0 },
+ /* Vertex4iv */ { 20, 0 },
+ /* Vertex4sv */ { 12, 0 },
+ /* ClipPlane */ { 40, 0 },
+ /* ColorMaterial */ { 12, 0 },
+ /* CullFace */ { 8, 0 },
+ /* Fogf */ { 12, 0 },
+ /* Fogfv */ { 8, __glXFogfvReqSize },
+ /* Fogi */ { 12, 0 },
+ /* Fogiv */ { 8, __glXFogivReqSize },
+ /* FrontFace */ { 8, 0 },
+ /* Hint */ { 12, 0 },
+ /* Lightf */ { 16, 0 },
+ /* Lightfv */ { 12, __glXLightfvReqSize },
+ /* Lighti */ { 16, 0 },
+ /* Lightiv */ { 12, __glXLightivReqSize },
+ /* LightModelf */ { 12, 0 },
+ /* LightModelfv */ { 8, __glXLightModelfvReqSize },
+ /* LightModeli */ { 12, 0 },
+ /* LightModeliv */ { 8, __glXLightModelivReqSize },
+ /* LineStipple */ { 12, 0 },
+ /* LineWidth */ { 8, 0 },
+ /* Materialf */ { 16, 0 },
+ /* Materialfv */ { 12, __glXMaterialfvReqSize },
+ /* Materiali */ { 16, 0 },
+ /* Materialiv */ { 12, __glXMaterialivReqSize },
+ /* PointSize */ { 8, 0 },
+ /* PolygonMode */ { 12, 0 },
+ /* PolygonStipple */ { 152, 0 },
+ /* Scissor */ { 20, 0 },
+ /* ShadeModel */ { 8, 0 },
+ /* TexParameterf */ { 16, 0 },
+ /* TexParameterfv */ { 12, __glXTexParameterfvReqSize },
+ /* TexParameteri */ { 16, 0 },
+ /* TexParameteriv */ { 12, __glXTexParameterivReqSize },
+ /* TexImage1D */ { 56, __glXTexImage1DReqSize },
+ /* TexImage2D */ { 56, __glXTexImage2DReqSize },
+ /* TexEnvf */ { 16, 0 },
+ /* TexEnvfv */ { 12, __glXTexEnvfvReqSize },
+ /* TexEnvi */ { 16, 0 },
+ /* TexEnviv */ { 12, __glXTexEnvivReqSize },
+ /* TexGend */ { 20, 0 },
+ /* TexGendv */ { 12, __glXTexGendvReqSize },
+ /* TexGenf */ { 16, 0 },
+ /* TexGenfv */ { 12, __glXTexGenfvReqSize },
+ /* TexGeni */ { 16, 0 },
+ /* TexGeniv */ { 12, __glXTexGenivReqSize },
+ /* InitNames */ { 4, 0 },
+ /* LoadName */ { 8, 0 },
+ /* PassThrough */ { 8, 0 },
+ /* PopName */ { 4, 0 },
+ /* PushName */ { 8, 0 },
+ /* DrawBuffer */ { 8, 0 },
+ /* Clear */ { 8, 0 },
+ /* ClearAccum */ { 20, 0 },
+ /* ClearIndex */ { 8, 0 },
+ /* ClearColor */ { 20, 0 },
+ /* ClearStencil */ { 8, 0 },
+ /* ClearDepth */ { 12, 0 },
+ /* StencilMask */ { 8, 0 },
+ /* ColorMask */ { 8, 0 },
+ /* DepthMask */ { 8, 0 },
+ /* IndexMask */ { 8, 0 },
+ /* Accum */ { 12, 0 },
+ /* Disable */ { 8, 0 },
+ /* Enable */ { 8, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* PopAttrib */ { 4, 0 },
+ /* PushAttrib */ { 8, 0 },
+ /* Map1d */ { 28, __glXMap1dReqSize },
+ /* Map1f */ { 20, __glXMap1fReqSize },
+ /* Map2d */ { 48, __glXMap2dReqSize },
+ /* Map2f */ { 32, __glXMap2fReqSize },
+ /* MapGrid1d */ { 24, 0 },
+ /* MapGrid1f */ { 16, 0 },
+ /* MapGrid2d */ { 44, 0 },
+ /* MapGrid2f */ { 28, 0 },
+ /* EvalCoord1dv */ { 12, 0 },
+ /* EvalCoord1fv */ { 8, 0 },
+ /* EvalCoord2dv */ { 20, 0 },
+ /* EvalCoord2fv */ { 12, 0 },
+ /* EvalMesh1 */ { 16, 0 },
+ /* EvalPoint1 */ { 8, 0 },
+ /* EvalMesh2 */ { 24, 0 },
+ /* EvalPoint2 */ { 12, 0 },
+ /* AlphaFunc */ { 12, 0 },
+ /* BlendFunc */ { 12, 0 },
+ /* LogicOp */ { 8, 0 },
+ /* StencilFunc */ { 16, 0 },
+ /* StencilOp */ { 16, 0 },
+ /* DepthFunc */ { 8, 0 },
+ /* PixelZoom */ { 12, 0 },
+ /* PixelTransferf */ { 12, 0 },
+ /* PixelTransferi */ { 12, 0 },
+ /* PixelMapfv */ { 12, __glXPixelMapfvReqSize },
+ /* PixelMapuiv */ { 12, __glXPixelMapuivReqSize },
+ /* PixelMapusv */ { 12, __glXPixelMapusvReqSize },
+ /* ReadBuffer */ { 8, 0 },
+ /* CopyPixels */ { 24, 0 },
+ /* DrawPixels */ { 40, __glXDrawPixelsReqSize },
+ /* DepthRange */ { 20, 0 },
+ /* Frustum */ { 52, 0 },
+ /* LoadIdentity */ { 4, 0 },
+ /* LoadMatrixf */ { 68, 0 },
+ /* LoadMatrixd */ { 132, 0 },
+ /* MatrixMode */ { 8, 0 },
+ /* MultMatrixf */ { 68, 0 },
+ /* MultMatrixd */ { 132, 0 },
+ /* Ortho */ { 52, 0 },
+ /* PopMatrix */ { 4, 0 },
+ /* PushMatrix */ { 4, 0 },
+ /* Rotated */ { 36, 0 },
+ /* Rotatef */ { 20, 0 },
+ /* Scaled */ { 28, 0 },
+ /* Scalef */ { 16, 0 },
+ /* Translated */ { 28, 0 },
+ /* Translatef */ { 16, 0 },
+ /* Viewport */ { 20, 0 },
+ /* PolygonOffset */ { 12, 0 },
+ /* DrawArrays */ { 16, __glXDrawArraysSize },
+ /* Indexubv */ { 8, 0 },
+ /* ColorSubTable */ { 44, __glXColorSubTableReqSize },
+ /* CopyColorSubTable */ { 24, 0 },
+ /* ActiveTextureARB */ { 8, 0 },
+ /* MultiTexCoord1dvARB */ { 16, 0 },
+ /* MultiTexCoord1fvARB */ { 12, 0 },
+ /* MultiTexCoord1ivARB */ { 12, 0 },
+ /* MultiTexCoord1svARB */ { 12, 0 },
+ /* MultiTexCoord2dvARB */ { 24, 0 },
+ /* MultiTexCoord2fvARB */ { 16, 0 },
+ /* MultiTexCoord2ivARB */ { 16, 0 },
+ /* MultiTexCoord2svARB */ { 12, 0 },
+ /* MultiTexCoord3dvARB */ { 32, 0 },
+ /* MultiTexCoord3fvARB */ { 20, 0 },
+ /* MultiTexCoord3ivARB */ { 20, 0 },
+ /* MultiTexCoord3svARB */ { 16, 0 },
+ /* MultiTexCoord4dvARB */ { 40, 0 },
+ /* MultiTexCoord4fvARB */ { 24, 0 },
+ /* MultiTexCoord4ivARB */ { 24, 0 },
+ /* MultiTexCoord4svARB 213 */ { 16, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode 220 */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* WindowPos3fARB 230 */ { 16, 0 },
+};
+__GLXrenderSizeData __glXRenderSizeTable_EXT[__GLX_MAX_RENDER_OPCODE_EXT - __GLX_MIN_RENDER_OPCODE_EXT + 1] = {
+ /* ColorTable 2053 */ { 44, __glXColorTableReqSize },
+ /* ColorTableParameterfv */ { 12, __glXColorTableParameterfvReqSize },
+ /* ColorTableParameteriv */ { 12, __glXColorTableParameterivReqSize },
+ /* CopyColorTable */ { 24, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* PointParameterfARB 2065 */ { 12, 0 },
+ /* PointParameterfvARB 2066 */ { 8, __glXPointParameterfvARBReqSize },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* BlendColor */ { 20, 0 },
+ /* BlendEquation */ { 8, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* TexSubImage1D */ { 60, __glXTexSubImage1DReqSize },
+ /* TexSubImage2D */ { 60, __glXTexSubImage2DReqSize },
+ /* ConvolutionFilter1D */ { 48, __glXConvolutionFilter1DReqSize },
+ /* ConvolutionFilter2D */ { 48, __glXConvolutionFilter2DReqSize },
+ /* ConvolutionParameterf */ { 16, 0 },
+ /* ConvolutionParameterfv */ { 12, __glXConvolutionParameterfvReqSize },
+ /* ConvolutionParameteri */ { 16, 0 },
+ /* ConvolutionParameteriv */ { 12, __glXConvolutionParameterivReqSize },
+ /* CopyConvolutionFilter1D */ { 24, },
+ /* CopyConvolutionFilter2D */ { 28, },
+ /* SeparableFilter2D */ { 48, __glXSeparableFilter2DReqSize },
+ /* Histogram */ { 20, },
+ /* Minmax */ { 16, },
+ /* ResetHistogram */ { 8, },
+ /* ResetMinmax */ { 8, },
+ /* TexImage3D */ { 84, __glXTexImage3DReqSize },
+ /* TexSubImage3D */ { 92, __glXTexSubImage3DReqSize },
+ /* DrawArrays */ { 16, __glXDrawArraysSize },
+ /* BindTexture */ { 12, 0 },
+ /* PrioritizeTextures */ { 8, __glXPrioritizeTexturesReqSize },
+ /* CopyTexImage1D */ { 32, 0 },
+ /* CopyTexImage2D */ { 36, 0 },
+ /* CopyTexSubImage1D */ { 28, 0 },
+ /* CopyTexSubImage2D */ { 36, 0 },
+ /* CopyTexSubImage3D 4123 */ { 40, 0 },
+ /* FogCoordfv 4124 */ { 8, 0 },
+ /* FogCoorddv 4125 */ { 12, 0 },
+ /* SecondaryColor3bv 4126 */ { 8, 0 },
+ /* SecondaryColor3sv 4127 */ { 12, 0 },
+ /* SecondaryColor3iv 4128 */ { 16, 0 },
+ /* SecondaryColor3fv 4129 */ { 16, 0 },
+ /* SecondaryColor3dv 4130 */ { 28, 0 },
+ /* SecondaryColor3ubv 4131 */ { 8, 0 },
+ /* SecondaryColor3usv 4132 */ { 12, 0 },
+ /* SecondaryColor3uiv 4133 */ { 16, 0 },
+ /* BlendFuncSeparate 4134 */ { 20, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* no such opcode */ { 0, 0 },
+ /* ActiveStencilFaceEXT 4220 */ { 8, 0 },
+ /* PointParameteri 4221 */ { 12, 0 },
+ /* PointParameteriv 4222 */ { 8, __glXPointParameterivReqSize },
+};
diff --git a/nx-X11/programs/Xserver/GL/glx/single2.c b/nx-X11/programs/Xserver/GL/glx/single2.c
new file mode 100644
index 000000000..9fee5ff49
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/single2.c
@@ -0,0 +1,411 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/single2.c,v 1.8 2004/02/10 22:54:15 alanh Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxutil.h"
+#include "glxext.h"
+#include "unpack.h"
+#include "g_disptab.h"
+#include "GL/glx_ansic.h"
+
+int __glXDisp_FeedbackBuffer(__GLXclientState *cl, GLbyte *pc)
+{
+ GLsizei size;
+ GLenum type;
+ __GLXcontext *cx;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ size = *(GLsizei *)(pc+0);
+ type = *(GLenum *)(pc+4);
+ if (cx->feedbackBufSize < size) {
+ cx->feedbackBuf = (GLfloat *) __glXRealloc(cx->feedbackBuf,
+ (size_t)size
+ * __GLX_SIZE_FLOAT32);
+ if (!cx->feedbackBuf) {
+ cl->client->errorValue = size;
+ return BadAlloc;
+ }
+ cx->feedbackBufSize = size;
+ }
+ glFeedbackBuffer(size, type, cx->feedbackBuf);
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDisp_SelectBuffer(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ GLsizei size;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ size = *(GLsizei *)(pc+0);
+ if (cx->selectBufSize < size) {
+ cx->selectBuf = (GLuint *) __glXRealloc(cx->selectBuf,
+ (size_t) size
+ * __GLX_SIZE_CARD32);
+ if (!cx->selectBuf) {
+ cl->client->errorValue = size;
+ return BadAlloc;
+ }
+ cx->selectBufSize = size;
+ }
+ glSelectBuffer(size, cx->selectBuf);
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDisp_RenderMode(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client;
+ xGLXRenderModeReply reply;
+ __GLXcontext *cx;
+ GLint nitems=0, retBytes=0, retval, newModeCheck;
+ GLubyte *retBuffer = NULL;
+ GLenum newMode;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ newMode = *(GLenum*) pc;
+ retval = glRenderMode(newMode);
+
+ /* Check that render mode worked */
+ glGetIntegerv(GL_RENDER_MODE, &newModeCheck);
+ if (newModeCheck != newMode) {
+ /* Render mode change failed. Bail */
+ newMode = newModeCheck;
+ goto noChangeAllowed;
+ }
+
+ /*
+ ** Render mode might have still failed if we get here. But in this
+ ** case we can't really tell, nor does it matter. If it did fail, it
+ ** will return 0, and thus we won't send any data across the wire.
+ */
+
+ switch (cx->renderMode) {
+ case GL_RENDER:
+ cx->renderMode = newMode;
+ break;
+ case GL_FEEDBACK:
+ if (retval < 0) {
+ /* Overflow happened. Copy the entire buffer */
+ nitems = cx->feedbackBufSize;
+ } else {
+ nitems = retval;
+ }
+ retBytes = nitems * __GLX_SIZE_FLOAT32;
+ retBuffer = (GLubyte*) cx->feedbackBuf;
+ cx->renderMode = newMode;
+ break;
+ case GL_SELECT:
+ if (retval < 0) {
+ /* Overflow happened. Copy the entire buffer */
+ nitems = cx->selectBufSize;
+ } else {
+ GLuint *bp = cx->selectBuf;
+ GLint i;
+
+ /*
+ ** Figure out how many bytes of data need to be sent. Parse
+ ** the selection buffer to determine this fact as the
+ ** return value is the number of hits, not the number of
+ ** items in the buffer.
+ */
+ nitems = 0;
+ i = retval;
+ while (--i >= 0) {
+ GLuint n;
+
+ /* Parse select data for this hit */
+ n = *bp;
+ bp += 3 + n;
+ }
+ nitems = bp - cx->selectBuf;
+ }
+ retBytes = nitems * __GLX_SIZE_CARD32;
+ retBuffer = (GLubyte*) cx->selectBuf;
+ cx->renderMode = newMode;
+ break;
+ }
+
+ /*
+ ** First reply is the number of elements returned in the feedback or
+ ** selection array, as per the API for glRenderMode itself.
+ */
+ noChangeAllowed:;
+ client = cl->client;
+ reply.length = nitems;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.retval = retval;
+ reply.size = nitems;
+ reply.newMode = newMode;
+ WriteToClient(client, sz_xGLXRenderModeReply, (char *)&reply);
+ if (retBytes) {
+ WriteToClient(client, retBytes, (char *)retBuffer);
+ }
+ return Success;
+}
+
+int __glXDisp_Flush(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ glFlush();
+ __GLX_NOTE_FLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDisp_Finish(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ ClientPtr client;
+ int error;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ /* Do a local glFinish */
+ glFinish();
+ __GLX_NOTE_FLUSHED_CMDS(cx);
+
+ /* Send empty reply packet to indicate finish is finished */
+ client = cl->client;
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ return Success;
+}
+
+#define SEPARATOR " "
+
+char *__glXcombine_strings(const char *cext_string, const char *sext_string)
+{
+ size_t clen, slen;
+ char *combo_string, *token, *s1;
+ const char *s2, *end;
+
+ /* safeguard to prevent potentially fatal errors in the string functions */
+ if (!cext_string)
+ cext_string = "";
+ if (!sext_string)
+ sext_string = "";
+
+ /*
+ ** String can't be longer than min(cstring, sstring)
+ ** pull tokens out of shortest string
+ ** include space in combo_string for final separator and null terminator
+ */
+ if ( (clen = __glXStrlen(cext_string)) > (slen = __glXStrlen(sext_string)) ) {
+ combo_string = (char *) __glXMalloc(slen + 2);
+ s1 = (char *) __glXMalloc(slen + 2); __glXStrcpy(s1, sext_string);
+ s2 = cext_string;
+ } else {
+ combo_string = (char *) __glXMalloc(clen + 2);
+ s1 = (char *) __glXMalloc(clen + 2); __glXStrcpy(s1, cext_string);
+ s2 = sext_string;
+ }
+ if (!combo_string || !s1) {
+ if (combo_string) __glXFree(combo_string);
+ if (s1) __glXFree(s1);
+ return NULL;
+ }
+ combo_string[0] = '\0';
+
+ /* Get first extension token */
+ token = __glXStrtok( s1, SEPARATOR);
+ while ( token != NULL ) {
+
+ /*
+ ** if token in second string then save it
+ ** beware of extension names which are prefixes of other extension names
+ */
+ const char *p = s2;
+ end = p + __glXStrlen(p);
+ while (p < end) {
+ size_t n = __glXStrcspn(p, SEPARATOR);
+ if ((__glXStrlen(token) == n) && (__glXStrncmp(token, p, n) == 0)) {
+ combo_string = __glXStrcat( combo_string, token);
+ combo_string = __glXStrcat( combo_string, SEPARATOR);
+ }
+ p += (n + 1);
+ }
+
+ /* Get next extension token */
+ token = __glXStrtok( NULL, SEPARATOR);
+ }
+ __glXFree(s1);
+ return combo_string;
+}
+
+int DoGetString(__GLXclientState *cl, GLbyte *pc, GLboolean need_swap)
+{
+ ClientPtr client;
+ __GLXcontext *cx;
+ GLenum name;
+ const char *string;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ int error;
+ char *buf = NULL, *buf1 = NULL;
+ GLint length = 0;
+
+ /* If the client has the opposite byte order, swap the contextTag and
+ * the name.
+ */
+ if ( need_swap ) {
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + __GLX_SINGLE_HDR_SIZE);
+ }
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ name = *(GLenum *)(pc + 0);
+ string = (const char *)glGetString(name);
+ client = cl->client;
+
+ /*
+ ** Restrict extensions to those that are supported by both the
+ ** implementation and the connection. That is, return the
+ ** intersection of client, server, and core extension strings.
+ */
+ if (name == GL_EXTENSIONS) {
+ buf1 = __glXcombine_strings(string,
+ cl->GLClientextensions);
+ buf = __glXcombine_strings(buf1,
+ cx->pGlxScreen->GLextensions);
+ if (buf1 != NULL) {
+ __glXFree(buf1);
+ }
+ string = buf;
+ }
+ else if ( name == GL_VERSION ) {
+ if ( atof( string ) > atof( GLServerVersion ) ) {
+ buf = __glXMalloc( __glXStrlen( string )
+ + __glXStrlen( GLServerVersion )
+ + 4 );
+ if ( buf == NULL ) {
+ string = GLServerVersion;
+ }
+ else {
+ __glXSprintf( buf, "%s (%s)", GLServerVersion, string );
+ string = buf;
+ }
+ }
+ }
+ if (string) {
+ length = __glXStrlen((const char *) string) + 1;
+ }
+
+ __GLX_BEGIN_REPLY(length);
+ __GLX_PUT_SIZE(length);
+
+ if ( need_swap ) {
+ __GLX_SWAP_REPLY_SIZE();
+ __GLX_SWAP_REPLY_HEADER();
+ }
+
+ __GLX_SEND_HEADER();
+ WriteToClient(client, length, (char *) string);
+ if (buf != NULL) {
+ __glXFree(buf);
+ }
+ return Success;
+}
+
+int __glXDisp_GetString(__GLXclientState *cl, GLbyte *pc)
+{
+ return DoGetString(cl, pc, GL_FALSE);
+}
+
+int __glXDisp_GetClipPlane(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLdouble answer[4];
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+
+ __glXClearErrorOccured();
+ glGetClipPlane(*(GLenum *)(pc + 0), answer);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(32);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_DOUBLE_ARRAY(4);
+ }
+ return Success;
+}
+
diff --git a/nx-X11/programs/Xserver/GL/glx/single2swap.c b/nx-X11/programs/Xserver/GL/glx/single2swap.c
new file mode 100644
index 000000000..dab98ade9
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/single2swap.c
@@ -0,0 +1,303 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/single2swap.c,v 1.7 2002/01/14 22:47:08 tsi Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxutil.h"
+#include "glxext.h"
+#include "unpack.h"
+#include "g_disptab.h"
+#include "GL/glx_ansic.h"
+
+int __glXDispSwap_FeedbackBuffer(__GLXclientState *cl, GLbyte *pc)
+{
+ GLsizei size;
+ GLenum type;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLXcontext *cx;
+ int error;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc+0);
+ __GLX_SWAP_INT(pc+4);
+ size = *(GLsizei *)(pc+0);
+ type = *(GLenum *)(pc+4);
+ if (cx->feedbackBufSize < size) {
+ cx->feedbackBuf = (GLfloat *) __glXRealloc(cx->feedbackBuf,
+ (size_t) size
+ * __GLX_SIZE_FLOAT32);
+ if (!cx->feedbackBuf) {
+ cl->client->errorValue = size;
+ return BadAlloc;
+ }
+ cx->feedbackBufSize = size;
+ }
+ glFeedbackBuffer(size, type, cx->feedbackBuf);
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDispSwap_SelectBuffer(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ GLsizei size;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ int error;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc+0);
+ size = *(GLsizei *)(pc+0);
+ if (cx->selectBufSize < size) {
+ cx->selectBuf = (GLuint *) __glXRealloc(cx->selectBuf,
+ (size_t) size
+ * __GLX_SIZE_CARD32);
+ if (!cx->selectBuf) {
+ cl->client->errorValue = size;
+ return BadAlloc;
+ }
+ cx->selectBufSize = size;
+ }
+ glSelectBuffer(size, cx->selectBuf);
+ __GLX_NOTE_UNFLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDispSwap_RenderMode(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client;
+ __GLXcontext *cx;
+ xGLXRenderModeReply reply;
+ GLint nitems=0, retBytes=0, retval, newModeCheck;
+ GLubyte *retBuffer = NULL;
+ GLenum newMode;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+ int error;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc);
+ newMode = *(GLenum*) pc;
+ retval = glRenderMode(newMode);
+
+ /* Check that render mode worked */
+ glGetIntegerv(GL_RENDER_MODE, &newModeCheck);
+ if (newModeCheck != newMode) {
+ /* Render mode change failed. Bail */
+ newMode = newModeCheck;
+ goto noChangeAllowed;
+ }
+
+ /*
+ ** Render mode might have still failed if we get here. But in this
+ ** case we can't really tell, nor does it matter. If it did fail, it
+ ** will return 0, and thus we won't send any data across the wire.
+ */
+
+ switch (cx->renderMode) {
+ case GL_RENDER:
+ cx->renderMode = newMode;
+ break;
+ case GL_FEEDBACK:
+ if (retval < 0) {
+ /* Overflow happened. Copy the entire buffer */
+ nitems = cx->feedbackBufSize;
+ } else {
+ nitems = retval;
+ }
+ retBytes = nitems * __GLX_SIZE_FLOAT32;
+ retBuffer = (GLubyte*) cx->feedbackBuf;
+ __GLX_SWAP_FLOAT_ARRAY((GLbyte *)retBuffer, nitems);
+ cx->renderMode = newMode;
+ break;
+ case GL_SELECT:
+ if (retval < 0) {
+ /* Overflow happened. Copy the entire buffer */
+ nitems = cx->selectBufSize;
+ } else {
+ GLuint *bp = cx->selectBuf;
+ GLint i;
+
+ /*
+ ** Figure out how many bytes of data need to be sent. Parse
+ ** the selection buffer to determine this fact as the
+ ** return value is the number of hits, not the number of
+ ** items in the buffer.
+ */
+ nitems = 0;
+ i = retval;
+ while (--i >= 0) {
+ GLuint n;
+
+ /* Parse select data for this hit */
+ n = *bp;
+ bp += 3 + n;
+ }
+ nitems = bp - cx->selectBuf;
+ }
+ retBytes = nitems * __GLX_SIZE_CARD32;
+ retBuffer = (GLubyte*) cx->selectBuf;
+ __GLX_SWAP_INT_ARRAY((GLbyte *)retBuffer, nitems);
+ cx->renderMode = newMode;
+ break;
+ }
+
+ /*
+ ** First reply is the number of elements returned in the feedback or
+ ** selection array, as per the API for glRenderMode itself.
+ */
+ noChangeAllowed:;
+ client = cl->client;
+ reply.length = nitems;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.retval = retval;
+ reply.size = nitems;
+ reply.newMode = newMode;
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.retval);
+ __GLX_SWAP_INT(&reply.size);
+ __GLX_SWAP_INT(&reply.newMode);
+ WriteToClient(client, sz_xGLXRenderModeReply, (char *)&reply);
+ if (retBytes) {
+ WriteToClient(client, retBytes, (char *)retBuffer);
+ }
+ return Success;
+}
+
+int __glXDispSwap_Flush(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ glFlush();
+ __GLX_NOTE_FLUSHED_CMDS(cx);
+ return Success;
+}
+
+int __glXDispSwap_Finish(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ ClientPtr client;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ /* Do a local glFinish */
+ glFinish();
+ __GLX_NOTE_FLUSHED_CMDS(cx);
+
+ /* Send empty reply packet to indicate finish is finished */
+ client = cl->client;
+ __GLX_BEGIN_REPLY(0);
+ __GLX_PUT_RETVAL(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+
+ return Success;
+}
+
+int __glXDispSwap_GetString(__GLXclientState *cl, GLbyte *pc)
+{
+ return DoGetString(cl, pc, GL_TRUE);
+}
+
+int __glXDispSwap_GetClipPlane(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLdouble answer[4];
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc + 0);
+
+ __glXClearErrorOccured();
+ glGetClipPlane(*(GLenum *)(pc + 0), answer);
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_SWAP_DOUBLE_ARRAY((GLbyte *)answer, 4);
+ __GLX_BEGIN_REPLY(32);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_DOUBLE_ARRAY(4);
+ }
+ return Success;
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/singlepix.c b/nx-X11/programs/Xserver/GL/glx/singlepix.c
new file mode 100644
index 000000000..845c46a64
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/singlepix.c
@@ -0,0 +1,462 @@
+/* $XFree86$ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxext.h"
+#include "singlesize.h"
+#include "unpack.h"
+#include "g_disptab.h"
+#include "g_disptab_EXT.h"
+
+int __glXDisp_ReadPixels(__GLXclientState *cl, GLbyte *pc)
+{
+ GLsizei width, height;
+ GLenum format, type;
+ GLboolean swapBytes, lsbFirst;
+ GLint compsize;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ char *answer, answerBuffer[200];
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ width = *(GLsizei *)(pc + 8);
+ height = *(GLsizei *)(pc + 12);
+ format = *(GLenum *)(pc + 16);
+ type = *(GLenum *)(pc + 20);
+ swapBytes = *(GLboolean *)(pc + 24);
+ lsbFirst = *(GLboolean *)(pc + 25);
+ compsize = __glReadPixels_size(format,type,width,height);
+ if (compsize < 0) compsize = 0;
+
+ glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
+ glPixelStorei(GL_PACK_LSB_FIRST, lsbFirst);
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
+ __glXClearErrorOccured();
+ glReadPixels(
+ *(GLint *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLsizei *)(pc + 8),
+ *(GLsizei *)(pc + 12),
+ *(GLenum *)(pc + 16),
+ *(GLenum *)(pc + 20),
+ answer
+ );
+
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_VOID_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetTexImage(__GLXclientState *cl, GLbyte *pc)
+{
+ GLint level, compsize;
+ GLenum format, type, target;
+ GLboolean swapBytes;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ char *answer, answerBuffer[200];
+ GLint width=0, height=0, depth=1;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ level = *(GLint *)(pc + 4);
+ format = *(GLenum *)(pc + 8);
+ type = *(GLenum *)(pc + 12);
+ target = *(GLenum *)(pc + 0);
+ swapBytes = *(GLboolean *)(pc + 16);
+
+ glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
+ glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
+ if ( target == GL_TEXTURE_3D) {
+ glGetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH, &depth);
+ }
+ /*
+ * The three queries above might fail if we're in a state where queries
+ * are illegal, but then width, height, and depth would still be zero anyway.
+ */
+ compsize = __glGetTexImage_size(target,level,format,type,width,height,depth);
+ if (compsize < 0) compsize = 0;
+
+ glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
+ __glXClearErrorOccured();
+ glGetTexImage(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ *(GLenum *)(pc + 12),
+ answer
+ );
+
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize);
+ ((xGLXGetTexImageReply *)&__glXReply)->width = width;
+ ((xGLXGetTexImageReply *)&__glXReply)->height = height;
+ ((xGLXGetTexImageReply *)&__glXReply)->depth = depth;
+ __GLX_SEND_HEADER();
+ __GLX_SEND_VOID_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDisp_GetPolygonStipple(__GLXclientState *cl, GLbyte *pc)
+{
+ GLboolean lsbFirst;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLubyte answerBuffer[200];
+ char *answer;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ lsbFirst = *(GLboolean *)(pc + 0);
+
+ glPixelStorei(GL_PACK_LSB_FIRST, lsbFirst);
+ __GLX_GET_ANSWER_BUFFER(answer,cl,128,1);
+
+ __glXClearErrorOccured();
+ glGetPolygonStipple(
+ (GLubyte *) answer
+ );
+
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(128);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_BYTE_ARRAY(128);
+ }
+ return Success;
+}
+
+int __glXDisp_GetSeparableFilter(__GLXclientState *cl, GLbyte *pc)
+{
+ GLint compsize, compsize2;
+ GLenum format, type, target;
+ GLboolean swapBytes;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ char *answer, answerBuffer[200];
+ GLint width=0, height=0;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ format = *(GLenum *)(pc + 4);
+ type = *(GLenum *)(pc + 8);
+ target = *(GLenum *)(pc + 0);
+ swapBytes = *(GLboolean *)(pc + 12);
+
+ /* target must be SEPARABLE_2D, however I guess we can let the GL
+ barf on this one.... */
+
+ glGetConvolutionParameteriv(target, GL_CONVOLUTION_WIDTH, &width);
+ glGetConvolutionParameteriv(target, GL_CONVOLUTION_HEIGHT, &height);
+ /*
+ * The two queries above might fail if we're in a state where queries
+ * are illegal, but then width and height would still be zero anyway.
+ */
+ compsize = __glGetTexImage_size(target,1,format,type,width,1,1);
+ compsize2 = __glGetTexImage_size(target,1,format,type,height,1,1);
+
+ if (compsize < 0) compsize = 0;
+ if (compsize2 < 0) compsize2 = 0;
+ compsize = __GLX_PAD(compsize);
+ compsize2 = __GLX_PAD(compsize2);
+
+ glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize + compsize2,1);
+ __glXClearErrorOccured();
+ glGetSeparableFilter(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ answer,
+ answer + compsize,
+ NULL
+ );
+
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize + compsize2);
+ ((xGLXGetSeparableFilterReply *)&__glXReply)->width = width;
+ ((xGLXGetSeparableFilterReply *)&__glXReply)->height = height;
+ __GLX_SEND_HEADER();
+ __GLX_SEND_VOID_ARRAY(compsize + compsize2);
+ }
+
+ return Success;
+}
+
+int __glXDisp_GetConvolutionFilter(__GLXclientState *cl, GLbyte *pc)
+{
+ GLint compsize;
+ GLenum format, type, target;
+ GLboolean swapBytes;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ char *answer, answerBuffer[200];
+ GLint width=0, height=0;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ format = *(GLenum *)(pc + 4);
+ type = *(GLenum *)(pc + 8);
+ target = *(GLenum *)(pc + 0);
+ swapBytes = *(GLboolean *)(pc + 12);
+
+ glGetConvolutionParameteriv(target, GL_CONVOLUTION_WIDTH, &width);
+ if (target == GL_CONVOLUTION_1D) {
+ height = 1;
+ } else {
+ glGetConvolutionParameteriv(target, GL_CONVOLUTION_HEIGHT, &height);
+ }
+ /*
+ * The two queries above might fail if we're in a state where queries
+ * are illegal, but then width and height would still be zero anyway.
+ */
+ compsize = __glGetTexImage_size(target,1,format,type,width,height,1);
+ if (compsize < 0) compsize = 0;
+
+ glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
+ __glXClearErrorOccured();
+ glGetConvolutionFilter(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ answer
+ );
+
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize);
+ ((xGLXGetConvolutionFilterReply *)&__glXReply)->width = width;
+ ((xGLXGetConvolutionFilterReply *)&__glXReply)->height = height;
+ __GLX_SEND_HEADER();
+ __GLX_SEND_VOID_ARRAY(compsize);
+ }
+
+ return Success;
+}
+
+int __glXDisp_GetHistogram(__GLXclientState *cl, GLbyte *pc)
+{
+ GLint compsize;
+ GLenum format, type, target;
+ GLboolean swapBytes, reset;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ char *answer, answerBuffer[200];
+ GLint width=0;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ format = *(GLenum *)(pc + 4);
+ type = *(GLenum *)(pc + 8);
+ target = *(GLenum *)(pc + 0);
+ swapBytes = *(GLboolean *)(pc + 12);
+ reset = *(GLboolean *)(pc + 13);
+
+ glGetHistogramParameteriv(target, GL_HISTOGRAM_WIDTH, &width);
+ /*
+ * The one query above might fail if we're in a state where queries
+ * are illegal, but then width would still be zero anyway.
+ */
+ compsize = __glGetTexImage_size(target,1,format,type,width,1,1);
+ if (compsize < 0) compsize = 0;
+
+ glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
+ __glXClearErrorOccured();
+ glGetHistogram( target, reset, format, type, answer);
+
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize);
+ ((xGLXGetHistogramReply *)&__glXReply)->width = width;
+ __GLX_SEND_HEADER();
+ __GLX_SEND_VOID_ARRAY(compsize);
+ }
+
+ return Success;
+}
+
+int __glXDisp_GetMinmax(__GLXclientState *cl, GLbyte *pc)
+{
+ GLint compsize;
+ GLenum format, type, target;
+ GLboolean swapBytes, reset;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ char *answer, answerBuffer[200];
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ format = *(GLenum *)(pc + 4);
+ type = *(GLenum *)(pc + 8);
+ target = *(GLenum *)(pc + 0);
+ swapBytes = *(GLboolean *)(pc + 12);
+ reset = *(GLboolean *)(pc + 13);
+
+ compsize = __glGetTexImage_size(target,1,format,type,2,1,1);
+ if (compsize < 0) compsize = 0;
+
+ glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
+ __glXClearErrorOccured();
+ glGetMinmax( target, reset, format, type, answer);
+
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize);
+ __GLX_SEND_HEADER();
+ __GLX_SEND_VOID_ARRAY(compsize);
+ }
+
+ return Success;
+}
+
+int __glXDisp_GetColorTable(__GLXclientState *cl, GLbyte *pc)
+{
+ GLint compsize;
+ GLenum format, type, target;
+ GLboolean swapBytes;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ char *answer, answerBuffer[200];
+ GLint width=0;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ target = *(GLenum *)(pc + 0);
+ format = *(GLenum *)(pc + 4);
+ type = *(GLenum *)(pc + 8);
+ swapBytes = *(GLboolean *)(pc + 12);
+
+ glGetColorTableParameteriv(target, GL_COLOR_TABLE_WIDTH, &width);
+ /*
+ * The one query above might fail if we're in a state where queries
+ * are illegal, but then width would still be zero anyway.
+ */
+ compsize = __glGetTexImage_size(target,1,format,type,width,1,1);
+ if (compsize < 0) compsize = 0;
+
+ glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
+ __glXClearErrorOccured();
+ glGetColorTable(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ answer
+ );
+
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize);
+ ((xGLXGetColorTableReply *)&__glXReply)->width = width;
+ __GLX_SEND_HEADER();
+ __GLX_SEND_VOID_ARRAY(compsize);
+ }
+
+ return Success;
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/singlepixswap.c b/nx-X11/programs/Xserver/GL/glx/singlepixswap.c
new file mode 100644
index 000000000..ff68ecedf
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/singlepixswap.c
@@ -0,0 +1,518 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/singlepixswap.c,v 1.5 2001/03/21 16:29:37 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxext.h"
+#include "singlesize.h"
+#include "unpack.h"
+#include "g_disptab.h"
+#include "g_disptab_EXT.h"
+
+int __glXDispSwap_ReadPixels(__GLXclientState *cl, GLbyte *pc)
+{
+ GLsizei width, height;
+ GLenum format, type;
+ GLboolean swapBytes, lsbFirst;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ char *answer, answerBuffer[200];
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc+0);
+ __GLX_SWAP_INT(pc+4);
+ __GLX_SWAP_INT(pc+8);
+ __GLX_SWAP_INT(pc+12);
+ __GLX_SWAP_INT(pc+16);
+ __GLX_SWAP_INT(pc+20);
+
+ width = *(GLsizei *)(pc + 8);
+ height = *(GLsizei *)(pc + 12);
+ format = *(GLenum *)(pc + 16);
+ type = *(GLenum *)(pc + 20);
+ swapBytes = *(GLboolean *)(pc + 24);
+ lsbFirst = *(GLboolean *)(pc + 25);
+ compsize = __glReadPixels_size(format,type,width,height);
+ if (compsize < 0) compsize = 0;
+
+ glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
+ glPixelStorei(GL_PACK_LSB_FIRST, lsbFirst);
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
+ __glXClearErrorOccured();
+ glReadPixels(
+ *(GLint *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLsizei *)(pc + 8),
+ *(GLsizei *)(pc + 12),
+ *(GLenum *)(pc + 16),
+ *(GLenum *)(pc + 20),
+ answer
+ );
+
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_VOID_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetTexImage(__GLXclientState *cl, GLbyte *pc)
+{
+ GLint level, compsize;
+ GLenum format, type, target;
+ GLboolean swapBytes;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ char *answer, answerBuffer[200];
+ GLint width=0, height=0, depth=1;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc+0);
+ __GLX_SWAP_INT(pc+4);
+ __GLX_SWAP_INT(pc+8);
+ __GLX_SWAP_INT(pc+12);
+
+ level = *(GLint *)(pc + 4);
+ format = *(GLenum *)(pc + 8);
+ type = *(GLenum *)(pc + 12);
+ target = *(GLenum *)(pc + 0);
+ swapBytes = *(GLboolean *)(pc + 16);
+
+ glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
+ glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
+ if ( target == GL_TEXTURE_3D) {
+ glGetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH, &depth);
+ }
+ /*
+ * The three queries above might fail if we're in a state where queries
+ * are illegal, but then width, height, and depth would still be zero anyway.
+ */
+ compsize = __glGetTexImage_size(target,level,format,type,width,height,depth);
+ if (compsize < 0) compsize = 0;
+
+ glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
+ __glXClearErrorOccured();
+ glGetTexImage(
+ *(GLenum *)(pc + 0),
+ *(GLint *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ *(GLenum *)(pc + 12),
+ answer
+ );
+
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SWAP_INT(&width);
+ __GLX_SWAP_INT(&height);
+ __GLX_SWAP_INT(&depth);
+ ((xGLXGetTexImageReply *)&__glXReply)->width = width;
+ ((xGLXGetTexImageReply *)&__glXReply)->height = height;
+ ((xGLXGetTexImageReply *)&__glXReply)->depth = depth;
+ __GLX_SEND_HEADER();
+ __GLX_SEND_VOID_ARRAY(compsize);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetPolygonStipple(__GLXclientState *cl, GLbyte *pc)
+{
+ GLboolean lsbFirst;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ GLubyte answerBuffer[200];
+ char *answer;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&((xGLXSingleReq *)pc)->contextTag);
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+ pc += __GLX_SINGLE_HDR_SIZE;
+ lsbFirst = *(GLboolean *)(pc + 0);
+
+ glPixelStorei(GL_PACK_LSB_FIRST, lsbFirst);
+ __GLX_GET_ANSWER_BUFFER(answer,cl,128,1);
+
+ __glXClearErrorOccured();
+ glGetPolygonStipple(
+ (GLubyte *) answer
+ );
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(128);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_HEADER();
+ __GLX_SEND_BYTE_ARRAY(128);
+ }
+ return Success;
+}
+
+int __glXDispSwap_GetSeparableFilter(__GLXclientState *cl, GLbyte *pc)
+{
+ GLint compsize, compsize2;
+ GLenum format, type, target;
+ GLboolean swapBytes;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ char *answer, answerBuffer[200];
+ GLint width=0, height=0;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc+0);
+ __GLX_SWAP_INT(pc+4);
+ __GLX_SWAP_INT(pc+8);
+
+ format = *(GLenum *)(pc + 4);
+ type = *(GLenum *)(pc + 8);
+ target = *(GLenum *)(pc + 0);
+ swapBytes = *(GLboolean *)(pc + 12);
+
+ /* target must be SEPARABLE_2D, however I guess we can let the GL
+ barf on this one.... */
+
+ glGetConvolutionParameteriv(target, GL_CONVOLUTION_WIDTH, &width);
+ glGetConvolutionParameteriv(target, GL_CONVOLUTION_HEIGHT, &height);
+ /*
+ * The two queries above might fail if we're in a state where queries
+ * are illegal, but then width and height would still be zero anyway.
+ */
+ compsize = __glGetTexImage_size(target,1,format,type,width,1,1);
+ compsize2 = __glGetTexImage_size(target,1,format,type,height,1,1);
+
+ if (compsize < 0) compsize = 0;
+ if (compsize2 < 0) compsize2 = 0;
+ compsize = __GLX_PAD(compsize);
+ compsize2 = __GLX_PAD(compsize2);
+
+ glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize + compsize2,1);
+ __glXClearErrorOccured();
+ glGetSeparableFilter(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ answer,
+ answer + compsize,
+ NULL
+ );
+
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize + compsize2);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SWAP_INT(&width);
+ __GLX_SWAP_INT(&height);
+ ((xGLXGetSeparableFilterReply *)&__glXReply)->width = width;
+ ((xGLXGetSeparableFilterReply *)&__glXReply)->height = height;
+ __GLX_SEND_VOID_ARRAY(compsize + compsize2);
+ }
+
+ return Success;
+}
+
+int __glXDispSwap_GetConvolutionFilter(__GLXclientState *cl, GLbyte *pc)
+{
+ GLint compsize;
+ GLenum format, type, target;
+ GLboolean swapBytes;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ char *answer, answerBuffer[200];
+ GLint width=0, height=0;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc+0);
+ __GLX_SWAP_INT(pc+4);
+ __GLX_SWAP_INT(pc+8);
+
+ format = *(GLenum *)(pc + 4);
+ type = *(GLenum *)(pc + 8);
+ target = *(GLenum *)(pc + 0);
+ swapBytes = *(GLboolean *)(pc + 12);
+
+ glGetConvolutionParameteriv(target, GL_CONVOLUTION_WIDTH, &width);
+ if (target == GL_CONVOLUTION_2D) {
+ height = 1;
+ } else {
+ glGetConvolutionParameteriv(target, GL_CONVOLUTION_HEIGHT, &height);
+ }
+ /*
+ * The two queries above might fail if we're in a state where queries
+ * are illegal, but then width and height would still be zero anyway.
+ */
+ compsize = __glGetTexImage_size(target,1,format,type,width,height,1);
+ if (compsize < 0) compsize = 0;
+
+ glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
+ __glXClearErrorOccured();
+ glGetConvolutionFilter(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ answer
+ );
+
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SWAP_INT(&width);
+ __GLX_SWAP_INT(&height);
+ ((xGLXGetConvolutionFilterReply *)&__glXReply)->width = width;
+ ((xGLXGetConvolutionFilterReply *)&__glXReply)->height = height;
+ __GLX_SEND_VOID_ARRAY(compsize);
+ }
+
+ return Success;
+}
+
+int __glXDispSwap_GetHistogram(__GLXclientState *cl, GLbyte *pc)
+{
+ GLint compsize;
+ GLenum format, type, target;
+ GLboolean swapBytes, reset;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ char *answer, answerBuffer[200];
+ GLint width=0;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc+0);
+ __GLX_SWAP_INT(pc+4);
+ __GLX_SWAP_INT(pc+8);
+
+ format = *(GLenum *)(pc + 4);
+ type = *(GLenum *)(pc + 8);
+ target = *(GLenum *)(pc + 0);
+ swapBytes = *(GLboolean *)(pc + 12);
+ reset = *(GLboolean *)(pc + 13);
+
+ glGetHistogramParameteriv(target, GL_HISTOGRAM_WIDTH, &width);
+ /*
+ * The one query above might fail if we're in a state where queries
+ * are illegal, but then width would still be zero anyway.
+ */
+ compsize = __glGetTexImage_size(target,1,format,type,width,1,1);
+ if (compsize < 0) compsize = 0;
+
+ glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
+ __glXClearErrorOccured();
+ glGetHistogram( target, reset, format, type, answer);
+
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SWAP_INT(&width);
+ ((xGLXGetHistogramReply *)&__glXReply)->width = width;
+ __GLX_SEND_VOID_ARRAY(compsize);
+ }
+
+ return Success;
+}
+
+int __glXDispSwap_GetMinmax(__GLXclientState *cl, GLbyte *pc)
+{
+ GLint compsize;
+ GLenum format, type, target;
+ GLboolean swapBytes, reset;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ char *answer, answerBuffer[200];
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc+0);
+ __GLX_SWAP_INT(pc+4);
+ __GLX_SWAP_INT(pc+8);
+
+ format = *(GLenum *)(pc + 4);
+ type = *(GLenum *)(pc + 8);
+ target = *(GLenum *)(pc + 0);
+ swapBytes = *(GLboolean *)(pc + 12);
+ reset = *(GLboolean *)(pc + 13);
+
+ compsize = __glGetTexImage_size(target,1,format,type,2,1,1);
+ if (compsize < 0) compsize = 0;
+
+ glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
+ __glXClearErrorOccured();
+ glGetMinmax( target, reset, format, type, answer);
+
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SEND_VOID_ARRAY(compsize);
+ }
+
+ return Success;
+}
+
+int __glXDispSwap_GetColorTable(__GLXclientState *cl, GLbyte *pc)
+{
+ GLint compsize;
+ GLenum format, type, target;
+ GLboolean swapBytes;
+ __GLXcontext *cx;
+ ClientPtr client = cl->client;
+ int error;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ char *answer, answerBuffer[200];
+ GLint width=0;
+
+ cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
+ if (!cx) {
+ return error;
+ }
+
+ pc += __GLX_SINGLE_HDR_SIZE;
+ __GLX_SWAP_INT(pc+0);
+ __GLX_SWAP_INT(pc+4);
+ __GLX_SWAP_INT(pc+8);
+
+ format = *(GLenum *)(pc + 4);
+ type = *(GLenum *)(pc + 8);
+ target = *(GLenum *)(pc + 0);
+ swapBytes = *(GLboolean *)(pc + 12);
+
+ glGetColorTableParameteriv(target, GL_COLOR_TABLE_WIDTH, &width);
+ /*
+ * The one query above might fail if we're in a state where queries
+ * are illegal, but then width would still be zero anyway.
+ */
+ compsize = __glGetTexImage_size(target,1,format,type,width,1,1);
+ if (compsize < 0) compsize = 0;
+
+ glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
+ __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
+ __glXClearErrorOccured();
+ glGetColorTable(
+ *(GLenum *)(pc + 0),
+ *(GLenum *)(pc + 4),
+ *(GLenum *)(pc + 8),
+ answer
+ );
+
+ if (__glXErrorOccured()) {
+ __GLX_BEGIN_REPLY(0);
+ __GLX_SWAP_REPLY_HEADER();
+ } else {
+ __GLX_BEGIN_REPLY(compsize);
+ __GLX_SWAP_REPLY_HEADER();
+ __GLX_SWAP_INT(&width);
+ ((xGLXGetColorTableReply *)&__glXReply)->width = width;
+ __GLX_SEND_VOID_ARRAY(compsize);
+ }
+
+ return Success;
+}
diff --git a/nx-X11/programs/Xserver/GL/glx/singlesize.c b/nx-X11/programs/Xserver/GL/glx/singlesize.c
new file mode 100644
index 000000000..7ed5fe3ef
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/singlesize.c
@@ -0,0 +1,1222 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/singlesize.c,v 1.7tsi Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <GL/gl.h>
+#include "glxserver.h"
+#include "singlesize.h"
+
+/*
+** These routines compute the size of variable-size returned parameters.
+** Unlike the similar routines that do the same thing for variable-size
+** incoming parameters, the samplegl library itself doesn't use these routines.
+** Hence, they are located here, in the GLX extension library.
+*/
+
+GLint __glReadPixels_size(GLenum format, GLenum type, GLint w, GLint h)
+{
+ return __glXImageSize( format, type, 0, w, h, 1, 0, 0, 0, 0, 4 );
+}
+
+/**
+ * Determine the number of data elements that go with the specified \c pname
+ * to a \c glGetTexEnvfv or \c glGetTexEnviv call.
+ *
+ * \todo
+ * Replace this function with a call to \c __glTexEnvfv_size. Make that there
+ * aren't any values of \c pname that are valid for one but not the other.
+ */
+GLint __glGetTexEnvfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_TEXTURE_ENV_MODE:
+ case GL_TEXTURE_LOD_BIAS:
+ case GL_COMBINE_RGB:
+ case GL_COMBINE_ALPHA:
+ case GL_SOURCE0_RGB:
+ case GL_SOURCE1_RGB:
+ case GL_SOURCE2_RGB:
+ case GL_SOURCE0_ALPHA:
+ case GL_SOURCE1_ALPHA:
+ case GL_SOURCE2_ALPHA:
+ case GL_OPERAND0_RGB:
+ case GL_OPERAND1_RGB:
+ case GL_OPERAND2_RGB:
+ case GL_OPERAND0_ALPHA:
+ case GL_OPERAND1_ALPHA:
+ case GL_OPERAND2_ALPHA:
+ case GL_RGB_SCALE:
+ case GL_ALPHA_SCALE:
+
+ /* GL_ARB_point_sprite / GL_NV_point_sprite */
+ case GL_COORD_REPLACE_ARB:
+
+ /* GL_NV_texture_env_combine4 */
+ case GL_SOURCE3_RGB_NV:
+ case GL_SOURCE3_ALPHA_NV:
+ case GL_OPERAND3_RGB_NV:
+ case GL_OPERAND3_ALPHA_NV:
+ return 1;
+
+ case GL_TEXTURE_ENV_COLOR:
+ return 4;
+ default:
+ return -1;
+ }
+}
+
+
+GLint __glGetTexEnviv_size(GLenum pname)
+{
+ return __glGetTexEnvfv_size(pname);
+}
+
+GLint __glGetTexGenfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_TEXTURE_GEN_MODE:
+ return 1;
+ case GL_OBJECT_PLANE:
+ return 4;
+ case GL_EYE_PLANE:
+ return 4;
+ default:
+ return -1;
+ }
+}
+
+GLint __glGetTexGendv_size(GLenum pname)
+{
+ return __glGetTexGenfv_size(pname);
+}
+
+GLint __glGetTexGeniv_size(GLenum pname)
+{
+ return __glGetTexGenfv_size(pname);
+}
+
+GLint __glGetTexParameterfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_TEXTURE_BORDER_COLOR:
+ return 4;
+
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ case GL_TEXTURE_WRAP_R:
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ case GL_TEXTURE_PRIORITY:
+ case GL_TEXTURE_RESIDENT:
+
+ /* GL_SGIS_texture_lod / GL_EXT_texture_lod / GL 1.2 */
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+
+ /* GL_SGIX_texture_lod_bias */
+ case GL_TEXTURE_LOD_BIAS_S_SGIX:
+ case GL_TEXTURE_LOD_BIAS_T_SGIX:
+ case GL_TEXTURE_LOD_BIAS_R_SGIX:
+
+ /* GL_ARB_shadow / GL 1.4 */
+ case GL_TEXTURE_COMPARE_MODE:
+ case GL_TEXTURE_COMPARE_FUNC:
+
+ /* GL_SGIS_generate_mipmap / GL 1.4 */
+ case GL_GENERATE_MIPMAP:
+
+ /* GL_ARB_depth_texture / GL 1.4 */
+ case GL_DEPTH_TEXTURE_MODE:
+
+ /* GL_EXT_texture_lod_bias / GL 1.4 */
+ case GL_TEXTURE_LOD_BIAS:
+
+ /* GL_SGIX_shadow_ambient / GL_ARB_shadow_ambient */
+ case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
+
+ /* GL_SGIX_shadow */
+ case GL_TEXTURE_COMPARE_SGIX:
+ case GL_TEXTURE_COMPARE_OPERATOR_SGIX:
+
+ /* GL_SGIX_texture_coordinate_clamp */
+ case GL_TEXTURE_MAX_CLAMP_S_SGIX:
+ case GL_TEXTURE_MAX_CLAMP_T_SGIX:
+ case GL_TEXTURE_MAX_CLAMP_R_SGIX:
+
+ /* GL_EXT_texture_filter_anisotropic */
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+
+ /* GL_NV_texture_expand_normal */
+ case GL_TEXTURE_UNSIGNED_REMAP_MODE_NV:
+ return 1;
+
+ default:
+ return -1;
+ }
+}
+
+GLint __glGetTexParameteriv_size(GLenum pname)
+{
+ return __glGetTexParameterfv_size(pname);
+}
+
+GLint __glGetLightfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_AMBIENT:
+ return 4;
+ case GL_DIFFUSE:
+ return 4;
+ case GL_SPECULAR:
+ return 4;
+ case GL_POSITION:
+ return 4;
+ case GL_SPOT_DIRECTION:
+ return 3;
+ case GL_SPOT_EXPONENT:
+ return 1;
+ case GL_SPOT_CUTOFF:
+ return 1;
+ case GL_CONSTANT_ATTENUATION:
+ return 1;
+ case GL_LINEAR_ATTENUATION:
+ return 1;
+ case GL_QUADRATIC_ATTENUATION:
+ return 1;
+ default:
+ return -1;
+ }
+}
+
+GLint __glGetLightiv_size(GLenum pname)
+{
+ return __glGetLightfv_size(pname);
+}
+
+GLint __glGetMap_size(GLenum target, GLenum query)
+{
+ GLint k, order=0, majorMinor[2];
+
+ /*
+ ** Assume target and query are both valid.
+ */
+ switch (target) {
+ case GL_MAP1_COLOR_4:
+ case GL_MAP1_NORMAL:
+ case GL_MAP1_INDEX:
+ case GL_MAP1_TEXTURE_COORD_1:
+ case GL_MAP1_TEXTURE_COORD_2:
+ case GL_MAP1_TEXTURE_COORD_3:
+ case GL_MAP1_TEXTURE_COORD_4:
+ case GL_MAP1_VERTEX_3:
+ case GL_MAP1_VERTEX_4:
+ switch (query) {
+ case GL_COEFF:
+ k = __glMap1d_size(target);
+ glGetMapiv(target, GL_ORDER, &order);
+ /*
+ ** The query above might fail, but then order will be zero anyway.
+ */
+ return (order * k);
+ case GL_DOMAIN:
+ return 2;
+ case GL_ORDER:
+ return 1;
+ }
+ break;
+ case GL_MAP2_COLOR_4:
+ case GL_MAP2_NORMAL:
+ case GL_MAP2_INDEX:
+ case GL_MAP2_TEXTURE_COORD_1:
+ case GL_MAP2_TEXTURE_COORD_2:
+ case GL_MAP2_TEXTURE_COORD_3:
+ case GL_MAP2_TEXTURE_COORD_4:
+ case GL_MAP2_VERTEX_3:
+ case GL_MAP2_VERTEX_4:
+ switch (query) {
+ case GL_COEFF:
+ k = __glMap2d_size(target);
+ majorMinor[0] = majorMinor[1] = 0;
+ glGetMapiv(target, GL_ORDER, majorMinor);
+ /*
+ ** The query above might fail, but then majorMinor will be zeroes
+ */
+ return (majorMinor[0] * majorMinor[1] * k);
+ case GL_DOMAIN:
+ return 4;
+ case GL_ORDER:
+ return 2;
+ }
+ break;
+ }
+ return -1;
+}
+
+GLint __glGetMapdv_size(GLenum target, GLenum query)
+{
+ return __glGetMap_size(target, query);
+}
+
+GLint __glGetMapfv_size(GLenum target, GLenum query)
+{
+ return __glGetMap_size(target, query);
+}
+
+GLint __glGetMapiv_size(GLenum target, GLenum query)
+{
+ return __glGetMap_size(target, query);
+}
+
+GLint __glGetMaterialfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_SHININESS:
+ return 1;
+ case GL_COLOR_INDEXES:
+ return 3;
+ case GL_EMISSION:
+ return 4;
+ case GL_AMBIENT:
+ return 4;
+ case GL_DIFFUSE:
+ return 4;
+ case GL_SPECULAR:
+ return 4;
+ case GL_AMBIENT_AND_DIFFUSE:
+ return 4;
+ default:
+ return -1;
+ }
+}
+
+GLint __glGetMaterialiv_size(GLenum pname)
+{
+ return __glGetMaterialfv_size(pname);
+}
+
+GLint __glGetPixelMap_size(GLenum map)
+{
+ GLint size;
+ GLenum query;
+
+ switch (map) {
+ case GL_PIXEL_MAP_I_TO_I:
+ query = GL_PIXEL_MAP_I_TO_I_SIZE;
+ break;
+ case GL_PIXEL_MAP_S_TO_S:
+ query = GL_PIXEL_MAP_S_TO_S_SIZE;
+ break;
+ case GL_PIXEL_MAP_I_TO_R:
+ query = GL_PIXEL_MAP_I_TO_R_SIZE;
+ break;
+ case GL_PIXEL_MAP_I_TO_G:
+ query = GL_PIXEL_MAP_I_TO_G_SIZE;
+ break;
+ case GL_PIXEL_MAP_I_TO_B:
+ query = GL_PIXEL_MAP_I_TO_B_SIZE;
+ break;
+ case GL_PIXEL_MAP_I_TO_A:
+ query = GL_PIXEL_MAP_I_TO_A_SIZE;
+ break;
+ case GL_PIXEL_MAP_R_TO_R:
+ query = GL_PIXEL_MAP_R_TO_R_SIZE;
+ break;
+ case GL_PIXEL_MAP_G_TO_G:
+ query = GL_PIXEL_MAP_G_TO_G_SIZE;
+ break;
+ case GL_PIXEL_MAP_B_TO_B:
+ query = GL_PIXEL_MAP_B_TO_B_SIZE;
+ break;
+ case GL_PIXEL_MAP_A_TO_A:
+ query = GL_PIXEL_MAP_A_TO_A_SIZE;
+ break;
+ default:
+ return -1;
+ }
+ glGetIntegerv(query, &size);
+ return size;
+}
+
+GLint __glGetPixelMapfv_size(GLenum map)
+{
+ return __glGetPixelMap_size(map);
+}
+
+GLint __glGetPixelMapuiv_size(GLenum map)
+{
+ return __glGetPixelMap_size(map);
+}
+
+GLint __glGetPixelMapusv_size(GLenum map)
+{
+ return __glGetPixelMap_size(map);
+}
+
+/*
+** Return the number of words needed to pass back the requested
+** value.
+*/
+GLint __glGet_size(GLenum sq)
+{
+ switch (sq) {
+ case GL_MAX_TEXTURE_SIZE:
+ return 1;
+ case GL_SUBPIXEL_BITS:
+ return 1;
+ case GL_MAX_LIST_NESTING:
+ return 1;
+ case GL_MAP1_COLOR_4:
+ case GL_MAP1_INDEX:
+ case GL_MAP1_NORMAL:
+ case GL_MAP1_TEXTURE_COORD_1:
+ case GL_MAP1_TEXTURE_COORD_2:
+ case GL_MAP1_TEXTURE_COORD_3:
+ case GL_MAP1_TEXTURE_COORD_4:
+ case GL_MAP1_VERTEX_3:
+ case GL_MAP1_VERTEX_4:
+ return 1;
+ case GL_MAP2_COLOR_4:
+ case GL_MAP2_INDEX:
+ case GL_MAP2_NORMAL:
+ case GL_MAP2_TEXTURE_COORD_1:
+ case GL_MAP2_TEXTURE_COORD_2:
+ case GL_MAP2_TEXTURE_COORD_3:
+ case GL_MAP2_TEXTURE_COORD_4:
+ case GL_MAP2_VERTEX_3:
+ case GL_MAP2_VERTEX_4:
+ return 1;
+ case GL_AUTO_NORMAL:
+ return 1;
+ case GL_CURRENT_COLOR:
+ return 4;
+ case GL_CURRENT_INDEX:
+ return 1;
+ case GL_CURRENT_NORMAL:
+ return 3;
+ case GL_CURRENT_TEXTURE_COORDS:
+ return 4;
+ case GL_CURRENT_RASTER_INDEX:
+ return 1;
+ case GL_CURRENT_RASTER_COLOR:
+ return 4;
+ case GL_CURRENT_RASTER_TEXTURE_COORDS:
+ return 4;
+ case GL_CURRENT_RASTER_POSITION:
+ return 4;
+ case GL_CURRENT_RASTER_POSITION_VALID:
+ return 1;
+ case GL_CURRENT_RASTER_DISTANCE:
+ return 1;
+ case GL_POINT_SIZE:
+ return 1;
+ case GL_POINT_SIZE_RANGE:
+ /* case GL_SMOOTH_POINT_SIZE_RANGE: */ /* alias */
+ return 2;
+ case GL_POINT_SIZE_GRANULARITY:
+ /* case GL_SMOOTH_POINT_SIZE_GRANULARITY: */ /* alias */
+ return 1;
+ case GL_ALIASED_POINT_SIZE_RANGE:
+ return 2;
+ case GL_POINT_SMOOTH:
+ return 1;
+ case GL_LINE_SMOOTH:
+ return 1;
+ case GL_LINE_WIDTH:
+ return 1;
+ case GL_LINE_WIDTH_RANGE:
+ /* case GL_SMOOTH_LINE_WIDTH_RANGE: */ /* alias */
+ return 2;
+ case GL_LINE_WIDTH_GRANULARITY:
+ /* case GL_SMOOTH_LINE_WIDTH_GRANULARITY: */ /* alias */
+ return 1;
+ case GL_ALIASED_LINE_WIDTH_RANGE:
+ return 2;
+ case GL_LINE_STIPPLE_PATTERN:
+ return 1;
+ case GL_LINE_STIPPLE_REPEAT:
+ return 1;
+ case GL_LINE_STIPPLE:
+ return 1;
+ case GL_POLYGON_MODE:
+ return 2;
+ case GL_POLYGON_SMOOTH:
+ return 1;
+ case GL_POLYGON_STIPPLE:
+ return 1;
+ case GL_EDGE_FLAG:
+ return 1;
+ case GL_CULL_FACE:
+ return 1;
+ case GL_CULL_FACE_MODE:
+ return 1;
+ case GL_FRONT_FACE:
+ return 1;
+ case GL_LIGHTING:
+ return 1;
+ case GL_LIGHT_MODEL_LOCAL_VIEWER:
+ return 1;
+ case GL_LIGHT_MODEL_TWO_SIDE:
+ return 1;
+ case GL_LIGHT_MODEL_AMBIENT:
+ return 4;
+ case GL_LIGHT_MODEL_COLOR_CONTROL:
+ return 1;
+ case GL_COLOR_MATERIAL:
+ return 1;
+ case GL_COLOR_MATERIAL_FACE:
+ return 1;
+ case GL_COLOR_MATERIAL_PARAMETER:
+ return 1;
+ case GL_SHADE_MODEL:
+ return 1;
+ case GL_FOG:
+ return 1;
+ case GL_FOG_INDEX:
+ return 1;
+ case GL_FOG_DENSITY:
+ return 1;
+ case GL_FOG_START:
+ return 1;
+ case GL_FOG_END:
+ return 1;
+ case GL_FOG_MODE:
+ return 1;
+ case GL_FOG_COLOR:
+ return 4;
+ case GL_DEPTH_RANGE:
+ return 2;
+ case GL_DEPTH_TEST:
+ return 1;
+ case GL_DEPTH_WRITEMASK:
+ return 1;
+ case GL_DEPTH_CLEAR_VALUE:
+ return 1;
+ case GL_DEPTH_FUNC:
+ return 1;
+ case GL_ACCUM_CLEAR_VALUE:
+ return 4;
+ case GL_STENCIL_TEST:
+ return 1;
+ case GL_STENCIL_CLEAR_VALUE:
+ return 1;
+ case GL_STENCIL_FUNC:
+ return 1;
+ case GL_STENCIL_VALUE_MASK:
+ return 1;
+ case GL_STENCIL_FAIL:
+ return 1;
+ case GL_STENCIL_PASS_DEPTH_FAIL:
+ return 1;
+ case GL_STENCIL_PASS_DEPTH_PASS:
+ return 1;
+ case GL_STENCIL_REF:
+ return 1;
+ case GL_STENCIL_WRITEMASK:
+ return 1;
+ case GL_MATRIX_MODE:
+ return 1;
+ case GL_NORMALIZE:
+ return 1;
+ case GL_VIEWPORT:
+ return 4;
+ case GL_ATTRIB_STACK_DEPTH:
+ return 1;
+ case GL_MODELVIEW_STACK_DEPTH:
+ return 1;
+ case GL_PROJECTION_STACK_DEPTH:
+ return 1;
+ case GL_TEXTURE_STACK_DEPTH:
+ return 1;
+ case GL_MODELVIEW_MATRIX:
+ return 16;
+ case GL_PROJECTION_MATRIX:
+ return 16;
+ case GL_TEXTURE_MATRIX:
+ return 16;
+ case GL_ALPHA_TEST:
+ return 1;
+ case GL_ALPHA_TEST_FUNC:
+ return 1;
+ case GL_ALPHA_TEST_REF:
+ return 1;
+ case GL_DITHER:
+ return 1;
+ case GL_BLEND_DST:
+ return 1;
+ case GL_BLEND_SRC:
+ return 1;
+ case GL_BLEND:
+ return 1;
+ case GL_LOGIC_OP_MODE:
+ return 1;
+ case GL_LOGIC_OP:
+ return 1;
+ case GL_DRAW_BUFFER:
+ return 1;
+ case GL_READ_BUFFER:
+ return 1;
+ case GL_SCISSOR_TEST:
+ return 1;
+ case GL_SCISSOR_BOX:
+ return 4;
+ case GL_INDEX_CLEAR_VALUE:
+ return 1;
+ case GL_INDEX_MODE:
+ return 1;
+ case GL_INDEX_WRITEMASK:
+ return 1;
+ case GL_COLOR_CLEAR_VALUE:
+ return 4;
+ case GL_RGBA_MODE:
+ return 1;
+ case GL_COLOR_WRITEMASK:
+ return 4;
+ case GL_RENDER_MODE:
+ return 1;
+ case GL_PERSPECTIVE_CORRECTION_HINT:
+ return 1;
+ case GL_POINT_SMOOTH_HINT:
+ return 1;
+ case GL_LINE_SMOOTH_HINT:
+ return 1;
+ case GL_POLYGON_SMOOTH_HINT:
+ return 1;
+ case GL_FOG_HINT:
+ return 1;
+ case GL_LIST_BASE:
+ return 1;
+ case GL_LIST_INDEX:
+ return 1;
+ case GL_LIST_MODE:
+ return 1;
+ case GL_TEXTURE_GEN_S:
+ return 1;
+ case GL_TEXTURE_GEN_T:
+ return 1;
+ case GL_TEXTURE_GEN_R:
+ return 1;
+ case GL_TEXTURE_GEN_Q:
+ return 1;
+ case GL_PACK_SWAP_BYTES:
+ return 1;
+ case GL_PACK_LSB_FIRST:
+ return 1;
+ case GL_PACK_ROW_LENGTH:
+ return 1;
+ case GL_PACK_IMAGE_HEIGHT:
+ return 1;
+ case GL_PACK_SKIP_ROWS:
+ return 1;
+ case GL_PACK_SKIP_PIXELS:
+ return 1;
+ case GL_PACK_SKIP_IMAGES:
+ return 1;
+ case GL_PACK_ALIGNMENT:
+ return 1;
+ case GL_UNPACK_SWAP_BYTES:
+ return 1;
+ case GL_UNPACK_LSB_FIRST:
+ return 1;
+ case GL_UNPACK_ROW_LENGTH:
+ return 1;
+ case GL_UNPACK_IMAGE_HEIGHT:
+ return 1;
+ case GL_UNPACK_SKIP_ROWS:
+ return 1;
+ case GL_UNPACK_SKIP_PIXELS:
+ return 1;
+ case GL_UNPACK_SKIP_IMAGES:
+ return 1;
+ case GL_UNPACK_ALIGNMENT:
+ return 1;
+ case GL_MAP_COLOR:
+ return 1;
+ case GL_MAP_STENCIL:
+ return 1;
+ case GL_INDEX_SHIFT:
+ return 1;
+ case GL_INDEX_OFFSET:
+ return 1;
+ case GL_RED_SCALE:
+ case GL_GREEN_SCALE:
+ case GL_BLUE_SCALE:
+ case GL_ALPHA_SCALE:
+ case GL_DEPTH_SCALE:
+ return 1;
+ case GL_RED_BIAS:
+ case GL_GREEN_BIAS:
+ case GL_BLUE_BIAS:
+ case GL_ALPHA_BIAS:
+ case GL_DEPTH_BIAS:
+ return 1;
+ case GL_ZOOM_X:
+ case GL_ZOOM_Y:
+ return 1;
+ case GL_PIXEL_MAP_I_TO_I_SIZE: case GL_PIXEL_MAP_S_TO_S_SIZE:
+ case GL_PIXEL_MAP_I_TO_R_SIZE: case GL_PIXEL_MAP_I_TO_G_SIZE:
+ case GL_PIXEL_MAP_I_TO_B_SIZE: case GL_PIXEL_MAP_I_TO_A_SIZE:
+ case GL_PIXEL_MAP_R_TO_R_SIZE: case GL_PIXEL_MAP_G_TO_G_SIZE:
+ case GL_PIXEL_MAP_B_TO_B_SIZE: case GL_PIXEL_MAP_A_TO_A_SIZE:
+ return 1;
+ case GL_MAX_EVAL_ORDER:
+ return 1;
+ case GL_MAX_LIGHTS:
+ return 1;
+ case GL_MAX_CLIP_PLANES:
+ return 1;
+ case GL_MAX_PIXEL_MAP_TABLE:
+ return 1;
+ case GL_MAX_ATTRIB_STACK_DEPTH:
+ return 1;
+ case GL_MAX_MODELVIEW_STACK_DEPTH:
+ return 1;
+ case GL_MAX_NAME_STACK_DEPTH:
+ return 1;
+ case GL_MAX_PROJECTION_STACK_DEPTH:
+ return 1;
+ case GL_MAX_TEXTURE_STACK_DEPTH:
+ return 1;
+ case GL_INDEX_BITS:
+ return 1;
+ case GL_RED_BITS:
+ return 1;
+ case GL_GREEN_BITS:
+ return 1;
+ case GL_BLUE_BITS:
+ return 1;
+ case GL_ALPHA_BITS:
+ return 1;
+ case GL_DEPTH_BITS:
+ return 1;
+ case GL_STENCIL_BITS:
+ return 1;
+ case GL_ACCUM_RED_BITS:
+ case GL_ACCUM_GREEN_BITS:
+ case GL_ACCUM_BLUE_BITS:
+ case GL_ACCUM_ALPHA_BITS:
+ return 1;
+ case GL_MAP1_GRID_DOMAIN:
+ return 2;
+ case GL_MAP1_GRID_SEGMENTS:
+ return 1;
+ case GL_MAP2_GRID_DOMAIN:
+ return 4;
+ case GL_MAP2_GRID_SEGMENTS:
+ return 2;
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ return 1;
+ case GL_NAME_STACK_DEPTH:
+ return 1;
+ case GL_MAX_VIEWPORT_DIMS:
+ return 2;
+ case GL_DOUBLEBUFFER:
+ return 1;
+ case GL_AUX_BUFFERS:
+ return 1;
+ case GL_STEREO:
+ return 1;
+ case GL_CLIP_PLANE0: case GL_CLIP_PLANE1:
+ case GL_CLIP_PLANE2: case GL_CLIP_PLANE3:
+ case GL_CLIP_PLANE4: case GL_CLIP_PLANE5:
+ return 1;
+ case GL_LIGHT0: case GL_LIGHT1:
+ case GL_LIGHT2: case GL_LIGHT3:
+ case GL_LIGHT4: case GL_LIGHT5:
+ case GL_LIGHT6: case GL_LIGHT7:
+ return 1;
+ case GL_VERTEX_ARRAY:
+ case GL_VERTEX_ARRAY_SIZE:
+ case GL_VERTEX_ARRAY_TYPE:
+ case GL_VERTEX_ARRAY_STRIDE:
+ case GL_NORMAL_ARRAY:
+ case GL_NORMAL_ARRAY_TYPE:
+ case GL_NORMAL_ARRAY_STRIDE:
+ case GL_COLOR_ARRAY:
+ case GL_COLOR_ARRAY_SIZE:
+ case GL_COLOR_ARRAY_TYPE:
+ case GL_COLOR_ARRAY_STRIDE:
+ case GL_INDEX_ARRAY:
+ case GL_INDEX_ARRAY_TYPE:
+ case GL_INDEX_ARRAY_STRIDE:
+ case GL_TEXTURE_COORD_ARRAY:
+ case GL_TEXTURE_COORD_ARRAY_SIZE:
+ case GL_TEXTURE_COORD_ARRAY_TYPE:
+ case GL_TEXTURE_COORD_ARRAY_STRIDE:
+ case GL_EDGE_FLAG_ARRAY:
+ case GL_EDGE_FLAG_ARRAY_STRIDE:
+ return 1;
+ case GL_TEXTURE_BINDING_1D:
+ case GL_TEXTURE_BINDING_2D:
+ case GL_TEXTURE_BINDING_3D:
+ return 1;
+ case GL_BLEND_COLOR:
+ return 4;
+ case GL_BLEND_EQUATION:
+ return 1;
+ case GL_COLOR_MATRIX:
+ return 16;
+ case GL_COLOR_MATRIX_STACK_DEPTH:
+ return 1;
+ case GL_COLOR_TABLE:
+ case GL_POST_CONVOLUTION_COLOR_TABLE:
+ case GL_POST_COLOR_MATRIX_COLOR_TABLE:
+ case GL_CONVOLUTION_1D:
+ case GL_CONVOLUTION_2D:
+ case GL_SEPARABLE_2D:
+ case GL_HISTOGRAM:
+ case GL_MINMAX:
+ return 1;
+ case GL_POLYGON_OFFSET_FACTOR:
+ case GL_POLYGON_OFFSET_UNITS:
+ return 1;
+ case GL_POST_CONVOLUTION_RED_SCALE:
+ case GL_POST_CONVOLUTION_GREEN_SCALE:
+ case GL_POST_CONVOLUTION_BLUE_SCALE:
+ case GL_POST_CONVOLUTION_ALPHA_SCALE:
+ case GL_POST_CONVOLUTION_RED_BIAS:
+ case GL_POST_CONVOLUTION_GREEN_BIAS:
+ case GL_POST_CONVOLUTION_BLUE_BIAS:
+ case GL_POST_CONVOLUTION_ALPHA_BIAS:
+ return 1;
+ case GL_POST_COLOR_MATRIX_RED_SCALE:
+ case GL_POST_COLOR_MATRIX_GREEN_SCALE:
+ case GL_POST_COLOR_MATRIX_BLUE_SCALE:
+ case GL_POST_COLOR_MATRIX_ALPHA_SCALE:
+ case GL_POST_COLOR_MATRIX_RED_BIAS:
+ case GL_POST_COLOR_MATRIX_GREEN_BIAS:
+ case GL_POST_COLOR_MATRIX_BLUE_BIAS:
+ case GL_POST_COLOR_MATRIX_ALPHA_BIAS:
+ return 1;
+ case GL_RESCALE_NORMAL:
+ return 1;
+ case GL_MAX_ELEMENTS_INDICES:
+ case GL_MAX_ELEMENTS_VERTICES:
+ return 1;
+ case GL_ACTIVE_TEXTURE_ARB:
+ case GL_CLIENT_ACTIVE_TEXTURE_ARB:
+ case GL_MAX_TEXTURE_UNITS_ARB:
+ return 1;
+ case GL_MAX_COLOR_MATRIX_STACK_DEPTH:
+ case GL_MAX_CONVOLUTION_WIDTH:
+ case GL_MAX_CONVOLUTION_HEIGHT:
+ return 1;
+ case GL_OCCLUSION_TEST_RESULT_HP:
+ case GL_OCCLUSION_TEST_HP:
+ return 1;
+ case GL_PACK_INVERT_MESA:
+ return 1;
+ case GL_CULL_VERTEX_IBM:
+ return 1;
+ case GL_RASTER_POSITION_UNCLIPPED_IBM:
+ return 1;
+
+ /* GL_ARB_texture_cube_map / GL 1.3 */
+ case GL_TEXTURE_CUBE_MAP:
+ case GL_TEXTURE_BINDING_CUBE_MAP:
+ case GL_MAX_CUBE_MAP_TEXTURE_SIZE:
+
+ /* GL_ARB_multisample / GL 1.3 */
+ case GL_MULTISAMPLE:
+ case GL_SAMPLE_ALPHA_TO_COVERAGE:
+ case GL_SAMPLE_ALPHA_TO_ONE:
+ case GL_SAMPLE_COVERAGE:
+ case GL_SAMPLE_BUFFERS:
+ case GL_SAMPLES:
+ case GL_SAMPLE_COVERAGE_VALUE:
+ case GL_SAMPLE_COVERAGE_INVERT:
+
+ /* GL_ARB_texture_comrpession / GL 1.3 */
+ case GL_TEXTURE_COMPRESSION_HINT:
+ case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
+
+ /* GL_EXT_blend_func_separate / GL 1.4 */
+ case GL_BLEND_DST_RGB:
+ case GL_BLEND_SRC_RGB:
+ case GL_BLEND_DST_ALPHA:
+ case GL_BLEND_SRC_ALPHA:
+
+ /* GL_EXT_fog_coord / GL 1.4 */
+ case GL_CURRENT_FOG_COORD:
+ case GL_FOG_COORD_ARRAY_TYPE:
+ case GL_FOG_COORD_ARRAY_STRIDE:
+ case GL_FOG_COORD_ARRAY:
+ case GL_FOG_COORD_SRC:
+
+ /* GL_EXT_secondary_color / GL 1.4 */
+ case GL_COLOR_SUM:
+ case GL_SECONDARY_COLOR_ARRAY_SIZE:
+ case GL_SECONDARY_COLOR_ARRAY_TYPE:
+ case GL_SECONDARY_COLOR_ARRAY_STRIDE:
+ case GL_SECONDARY_COLOR_ARRAY:
+
+ /* GL_EXT_texture_lod_bias / GL 1.4 */
+ case GL_MAX_TEXTURE_LOD_BIAS:
+
+ /* GL_ARB_point_sprite */
+ case GL_POINT_SPRITE_ARB:
+
+ /* GL_ARB_vertex_blend */
+ case GL_MAX_VERTEX_UNITS_ARB:
+ case GL_ACTIVE_VERTEX_UNITS_ARB:
+ case GL_WEIGHT_SUM_UNITY_ARB:
+ case GL_VERTEX_BLEND_ARB:
+ case GL_CURRENT_WEIGHT_ARB:
+ case GL_WEIGHT_ARRAY_ARB:
+ case GL_WEIGHT_ARRAY_TYPE_ARB:
+ case GL_WEIGHT_ARRAY_STRIDE_ARB:
+ case GL_WEIGHT_ARRAY_SIZE_ARB:
+
+ /* GL_ARB_matrix_palette */
+ case GL_MATRIX_PALETTE_ARB:
+ case GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB:
+ case GL_MAX_PALETTE_MATRICES_ARB:
+ case GL_CURRENT_PALETTE_MATRIX_ARB:
+ case GL_CURRENT_MATRIX_INDEX_ARB:
+ case GL_MATRIX_INDEX_ARRAY_ARB:
+ case GL_MATRIX_INDEX_ARRAY_SIZE_ARB:
+ case GL_MATRIX_INDEX_ARRAY_TYPE_ARB:
+ case GL_MATRIX_INDEX_ARRAY_STRIDE_ARB:
+
+ /* GL_EXT_clip_volume_hint */
+ case GL_CLIP_VOLUME_CLIPPING_HINT_EXT:
+
+ /* GL_EXT_depth_bounds_test */
+ case GL_DEPTH_BOUNDS_TEST_EXT:
+
+ /* GL_EXT_stencil_two_size */
+ case GL_STENCIL_TEST_TWO_SIDE_EXT:
+ case GL_ACTIVE_STENCIL_FACE_EXT:
+
+ /* GL_EXT_vertex_weighting */
+ case GL_VERTEX_WEIGHTING_EXT:
+ case GL_MODELVIEW0_EXT:
+ case GL_MODELVIEW1_EXT:
+ case GL_CURRENT_VERTEX_WEIGHT_EXT:
+ case GL_VERTEX_WEIGHT_ARRAY_EXT:
+ case GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT:
+ case GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT:
+ case GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT:
+ /* case GL_MODELVIEW0_STACK_DEPTH_EXT: */ /* alias */
+ case GL_MODELVIEW1_STACK_DEPTH_EXT:
+
+ /* GL_EXT_blend_equation_separate */
+ /* case GL_BLEND_EQUATION_RGB_EXT: */ /* alias */
+ case GL_BLEND_EQUATION_ALPHA_EXT:
+
+ /* GL_ATI_vertex_streams */
+ case GL_MAX_VERTEX_STREAMS_ATI:
+
+ /* GL_ATI_draw_buffers */
+ case GL_MAX_DRAW_BUFFERS_ATI:
+ case GL_DRAW_BUFFER0_ATI:
+ case GL_DRAW_BUFFER1_ATI:
+ case GL_DRAW_BUFFER2_ATI:
+ case GL_DRAW_BUFFER3_ATI:
+ case GL_DRAW_BUFFER4_ATI:
+ case GL_DRAW_BUFFER5_ATI:
+ case GL_DRAW_BUFFER6_ATI:
+ case GL_DRAW_BUFFER7_ATI:
+ case GL_DRAW_BUFFER8_ATI:
+ case GL_DRAW_BUFFER9_ATI:
+ case GL_DRAW_BUFFER10_ATI:
+ case GL_DRAW_BUFFER11_ATI:
+ case GL_DRAW_BUFFER12_ATI:
+ case GL_DRAW_BUFFER13_ATI:
+ case GL_DRAW_BUFFER14_ATI:
+ case GL_DRAW_BUFFER15_ATI:
+
+ /* GL_ATI_separate_stencil */
+ case GL_STENCIL_BACK_FUNC_ATI:
+ case GL_STENCIL_BACK_FAIL_ATI:
+ case GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI:
+ case GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI:
+
+ /* GL_NV_depth_clamp */
+ case GL_DEPTH_CLAMP_NV:
+
+ /* GL_NV_fog_distance */
+ case GL_FOG_DISTANCE_MODE_NV:
+
+ /* GL_NV_light_max_exponent */
+ case GL_MAX_SHININESS_NV:
+ case GL_MAX_SPOT_EXPONENT_NV:
+
+ /* GL_NV_multisample_filter_hint */
+ case GL_MULTISAMPLE_FILTER_HINT_NV:
+
+ /* GL_NV_point_sprite */
+ /* case GL_POINT_SPRITE_NV: */ /* alias */
+ case GL_POINT_SPRITE_R_MODE_NV:
+
+ /* GL_NV_primitive_restart */
+ case GL_PRIMITIVE_RESTART_NV:
+ case GL_PRIMITIVE_RESTART_INDEX_NV:
+
+ /* GL_NV_register_combiners */
+ case GL_REGISTER_COMBINERS_NV:
+ case GL_NUM_GENERAL_COMBINERS_NV:
+ case GL_COLOR_SUM_CLAMP_NV:
+ case GL_MAX_GENERAL_COMBINERS_NV:
+
+ /* GL_NV_register_combiners2 */
+ case GL_PER_STAGE_CONSTANTS_NV:
+
+ /* GL_NV_texture_rectangle */
+ case GL_TEXTURE_RECTANGLE_NV:
+ case GL_TEXTURE_BINDING_RECTANGLE_NV:
+ case GL_MAX_RECTANGLE_TEXTURE_SIZE_NV:
+ return 1;
+
+ /* GL_EXT_depth_bounds_test */
+ case GL_DEPTH_BOUNDS_EXT:
+ return 2;
+
+ /* GL_EXT_secondary_color / GL 1.4 */
+ case GL_CURRENT_SECONDARY_COLOR:
+
+ /* GL_NV_register_combiners */
+ case GL_CONSTANT_COLOR0_NV:
+ case GL_CONSTANT_COLOR1_NV:
+ return 4;
+
+ /* GL_ARB_vertex_blend */
+ /* case GL_MODELVIEW0_ARB: */ /* alias */
+ /* case GL_MODELVIEW1_ARB: */ /* alias */
+ case GL_MODELVIEW2_ARB:
+ case GL_MODELVIEW3_ARB:
+ case GL_MODELVIEW4_ARB:
+ case GL_MODELVIEW5_ARB:
+ case GL_MODELVIEW6_ARB:
+ case GL_MODELVIEW7_ARB:
+ case GL_MODELVIEW8_ARB:
+ case GL_MODELVIEW9_ARB:
+ case GL_MODELVIEW10_ARB:
+ case GL_MODELVIEW11_ARB:
+ case GL_MODELVIEW12_ARB:
+ case GL_MODELVIEW13_ARB:
+ case GL_MODELVIEW14_ARB:
+ case GL_MODELVIEW15_ARB:
+ case GL_MODELVIEW16_ARB:
+ case GL_MODELVIEW17_ARB:
+ case GL_MODELVIEW18_ARB:
+ case GL_MODELVIEW19_ARB:
+ case GL_MODELVIEW20_ARB:
+ case GL_MODELVIEW21_ARB:
+ case GL_MODELVIEW22_ARB:
+ case GL_MODELVIEW23_ARB:
+ case GL_MODELVIEW24_ARB:
+ case GL_MODELVIEW25_ARB:
+ case GL_MODELVIEW26_ARB:
+ case GL_MODELVIEW27_ARB:
+ case GL_MODELVIEW28_ARB:
+ case GL_MODELVIEW29_ARB:
+ case GL_MODELVIEW30_ARB:
+ case GL_MODELVIEW31_ARB:
+
+ /* GL_EXT_vertex_weighting */
+ /* case GL_MODELVIEW0_MATRIX_EXT: */ /* alias */
+ case GL_MODELVIEW1_MATRIX_EXT:
+ return 32;
+
+ /* GL_ARB_texture_comrpession / GL 1.3 */
+ case GL_COMPRESSED_TEXTURE_FORMATS: {
+ GLint temp;
+
+ glGetIntegerv( GL_NUM_COMPRESSED_TEXTURE_FORMATS, & temp );
+ return temp;
+ }
+
+ default:
+ return -1;
+ }
+}
+
+GLint __glGetDoublev_size(GLenum sq)
+{
+ return __glGet_size(sq);
+}
+
+GLint __glGetFloatv_size(GLenum sq)
+{
+ return __glGet_size(sq);
+}
+
+GLint __glGetIntegerv_size(GLenum sq)
+{
+ return __glGet_size(sq);
+}
+
+GLint __glGetBooleanv_size(GLenum sq)
+{
+ return __glGet_size(sq);
+}
+
+GLint __glGetTexLevelParameterfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_TEXTURE_WIDTH:
+ case GL_TEXTURE_HEIGHT:
+ case GL_TEXTURE_DEPTH:
+ case GL_TEXTURE_COMPONENTS:
+ case GL_TEXTURE_BORDER:
+ case GL_TEXTURE_RED_SIZE:
+ case GL_TEXTURE_GREEN_SIZE:
+ case GL_TEXTURE_BLUE_SIZE:
+ case GL_TEXTURE_ALPHA_SIZE:
+ case GL_TEXTURE_LUMINANCE_SIZE:
+ case GL_TEXTURE_INTENSITY_SIZE:
+
+ /* GL_ARB_texture_compression / GL 1.3 */
+ case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
+ case GL_TEXTURE_COMPRESSED:
+
+ /* GL_ARB_depth_texture / GL 1.4 */
+ case GL_TEXTURE_DEPTH_SIZE:
+ return 1;
+
+ default:
+ return -1;
+ }
+}
+
+GLint __glGetTexLevelParameteriv_size(GLenum pname)
+{
+ return __glGetTexLevelParameterfv_size(pname);
+}
+
+GLint __glGetTexImage_size(GLenum target, GLint level, GLenum format,
+ GLenum type, GLint width, GLint height, GLint depth)
+{
+ return __glXImageSize( format, type, target, width, height, depth,
+ 0, 0, 0, 0, 4 );
+}
+
+GLint __glGetConvolutionParameteriv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_CONVOLUTION_BORDER_COLOR:
+ case GL_CONVOLUTION_FILTER_SCALE:
+ case GL_CONVOLUTION_FILTER_BIAS:
+ return 4;
+ case GL_CONVOLUTION_BORDER_MODE:
+ case GL_CONVOLUTION_FORMAT:
+ case GL_CONVOLUTION_WIDTH:
+ case GL_CONVOLUTION_HEIGHT:
+ case GL_MAX_CONVOLUTION_WIDTH:
+ case GL_MAX_CONVOLUTION_HEIGHT:
+ return 1;
+ default:
+ return -1;
+ }
+}
+
+GLint __glGetConvolutionParameterfv_size(GLenum pname)
+{
+ return __glGetConvolutionParameteriv_size(pname);
+}
+
+
+GLint __glGetHistogramParameterfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_HISTOGRAM_WIDTH:
+ case GL_HISTOGRAM_FORMAT:
+ case GL_HISTOGRAM_RED_SIZE:
+ case GL_HISTOGRAM_GREEN_SIZE:
+ case GL_HISTOGRAM_BLUE_SIZE:
+ case GL_HISTOGRAM_ALPHA_SIZE:
+ case GL_HISTOGRAM_LUMINANCE_SIZE:
+ case GL_HISTOGRAM_SINK:
+ return 1;
+ default:
+ return -1;
+ }
+}
+
+GLint __glGetHistogramParameteriv_size(GLenum pname)
+{
+ return __glGetHistogramParameterfv_size(pname);
+}
+
+GLint __glGetMinmaxParameterfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_MINMAX_FORMAT:
+ case GL_MINMAX_SINK:
+ return 1;
+ default:
+ return -1;
+ }
+}
+
+GLint __glGetMinmaxParameteriv_size(GLenum pname)
+{
+ return __glGetMinmaxParameterfv_size(pname);
+}
+
+GLint __glGetColorTableParameterfv_size(GLenum pname)
+{
+ switch(pname) {
+
+ case GL_COLOR_TABLE_SCALE: /* return RGBA */
+ case GL_COLOR_TABLE_BIAS:
+ return 4;
+ case GL_COLOR_TABLE_FORMAT:
+ case GL_COLOR_TABLE_WIDTH:
+ case GL_COLOR_TABLE_RED_SIZE:
+ case GL_COLOR_TABLE_GREEN_SIZE:
+ case GL_COLOR_TABLE_BLUE_SIZE:
+ case GL_COLOR_TABLE_ALPHA_SIZE:
+ case GL_COLOR_TABLE_LUMINANCE_SIZE:
+ case GL_COLOR_TABLE_INTENSITY_SIZE:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+GLint __glGetColorTableParameteriv_size(GLenum pname)
+{
+ return __glGetColorTableParameterfv_size(pname);
+}
+
diff --git a/nx-X11/programs/Xserver/GL/glx/singlesize.h b/nx-X11/programs/Xserver/GL/glx/singlesize.h
new file mode 100644
index 000000000..4804a9982
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/singlesize.h
@@ -0,0 +1,87 @@
+/* $XFree86$ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _singlesize_h_
+#define _singlesize_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include "indirect_size.h"
+
+extern GLint __glReadPixels_size(GLenum format, GLenum type,
+ GLint width, GLint height);
+extern GLint __glGetTexEnvfv_size(GLenum pname);
+extern GLint __glGetTexEnviv_size(GLenum pname);
+extern GLint __glGetTexGenfv_size(GLenum pname);
+extern GLint __glGetTexGendv_size(GLenum pname);
+extern GLint __glGetTexGeniv_size(GLenum pname);
+extern GLint __glGetTexParameterfv_size(GLenum pname);
+extern GLint __glGetTexParameteriv_size(GLenum pname);
+extern GLint __glGetLightfv_size(GLenum pname);
+extern GLint __glGetLightiv_size(GLenum pname);
+extern GLint __glGetMap_size(GLenum pname, GLenum query);
+extern GLint __glGetMapdv_size(GLenum target, GLenum query);
+extern GLint __glGetMapfv_size(GLenum target, GLenum query);
+extern GLint __glGetMapiv_size(GLenum target, GLenum query);
+extern GLint __glGetMaterialfv_size(GLenum pname);
+extern GLint __glGetMaterialiv_size(GLenum pname);
+extern GLint __glGetPixelMap_size(GLenum map);
+extern GLint __glGetPixelMapfv_size(GLenum map);
+extern GLint __glGetPixelMapuiv_size(GLenum map);
+extern GLint __glGetPixelMapusv_size(GLenum map);
+extern GLint __glGet_size(GLenum sq);
+extern GLint __glGetDoublev_size(GLenum sq);
+extern GLint __glGetFloatv_size(GLenum sq);
+extern GLint __glGetIntegerv_size(GLenum sq);
+extern GLint __glGetBooleanv_size(GLenum sq);
+extern GLint __glGetTexLevelParameterfv_size(GLenum pname);
+extern GLint __glGetTexLevelParameteriv_size(GLenum pname);
+extern GLint __glGetTexImage_size(GLenum target, GLint level, GLenum format,
+ GLenum type, GLint width, GLint height,
+ GLint depth);
+extern GLint __glGetColorTableParameterfv_size(GLenum pname);
+extern GLint __glGetColorTableParameteriv_size(GLenum pname);
+extern GLint __glGetConvolutionParameterfv_size(GLenum pname);
+extern GLint __glGetConvolutionParameteriv_size(GLenum pname);
+extern GLint __glGetHistogramParameterfv_size(GLenum pname);
+extern GLint __glGetHistogramParameteriv_size(GLenum pname);
+extern GLint __glGetMinmaxParameterfv_size(GLenum pname);
+extern GLint __glGetMinmaxParameteriv_size(GLenum pname);
+
+#endif /* _singlesize_h_ */
+
diff --git a/nx-X11/programs/Xserver/GL/glx/unpack.h b/nx-X11/programs/Xserver/GL/glx/unpack.h
new file mode 100644
index 000000000..723fb85f3
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/unpack.h
@@ -0,0 +1,240 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/unpack.h,v 1.4 2002/01/14 22:47:08 tsi Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef __GLX_unpack_h__
+#define __GLX_unpack_h__
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define __GLX_PAD(s) (((s)+3) & (GLuint)~3)
+
+/*
+** Fetch the context-id out of a SingleReq request pointed to by pc.
+*/
+#define __GLX_GET_SINGLE_CONTEXT_TAG(pc) (((xGLXSingleReq*)pc)->contextTag)
+#define __GLX_GET_VENDPRIV_CONTEXT_TAG(pc) (((xGLXVendorPrivateReq*)pc)->contextTag)
+
+/*
+** Fetch a double from potentially unaligned memory.
+*/
+#ifdef __GLX_ALIGN64
+#define __GLX_MEM_COPY(dst,src,n) if (src && dst) memcpy(dst,src,n)
+#define __GLX_GET_DOUBLE(dst,src) __GLX_MEM_COPY(&dst,src,8)
+#else
+#define __GLX_GET_DOUBLE(dst,src) (dst) = *((GLdouble*)(src))
+#endif
+
+extern void __glXMemInit(void);
+
+extern xGLXSingleReply __glXReply;
+
+#define __GLX_BEGIN_REPLY(size) \
+ __glXReply.length = __GLX_PAD(size) >> 2; \
+ __glXReply.type = X_Reply; \
+ __glXReply.sequenceNumber = client->sequence;
+
+#define __GLX_SEND_HEADER() \
+ WriteToClient( client, sz_xGLXSingleReply, (char *)&__glXReply);
+
+#define __GLX_PUT_RETVAL(a) \
+ __glXReply.retval = (a);
+
+#define __GLX_PUT_SIZE(a) \
+ __glXReply.size = (a);
+
+#define __GLX_PUT_RENDERMODE(m) \
+ __glXReply.pad3 = (m)
+
+/*
+** Get a buffer to hold returned data, with the given alignment. If we have
+** to realloc, allocate size+align, in case the pointer has to be bumped for
+** alignment. The answerBuffer should already be aligned.
+**
+** NOTE: the cast (long)res below assumes a long is large enough to hold a
+** pointer.
+*/
+#define __GLX_GET_ANSWER_BUFFER(res,cl,size,align) \
+ if ((size) > sizeof(answerBuffer)) { \
+ int bump; \
+ if ((cl)->returnBufSize < (size)+(align)) { \
+ (cl)->returnBuf = (GLbyte*)Xrealloc((cl)->returnBuf, \
+ (size)+(align)); \
+ if (!(cl)->returnBuf) { \
+ return BadAlloc; \
+ } \
+ (cl)->returnBufSize = (size)+(align); \
+ } \
+ res = (char*)cl->returnBuf; \
+ bump = (long)(res) % (align); \
+ if (bump) res += (align) - (bump); \
+ } else { \
+ res = (char *)answerBuffer; \
+ }
+
+#define __GLX_PUT_BYTE() \
+ *(GLbyte *)&__glXReply.pad3 = *(GLbyte *)answer
+
+#define __GLX_PUT_SHORT() \
+ *(GLshort *)&__glXReply.pad3 = *(GLshort *)answer
+
+#define __GLX_PUT_INT() \
+ *(GLint *)&__glXReply.pad3 = *(GLint *)answer
+
+#define __GLX_PUT_FLOAT() \
+ *(GLfloat *)&__glXReply.pad3 = *(GLfloat *)answer
+
+#define __GLX_PUT_DOUBLE() \
+ *(GLdouble *)&__glXReply.pad3 = *(GLdouble *)answer
+
+#define __GLX_SEND_BYTE_ARRAY(len) \
+ WriteToClient(client, __GLX_PAD((len)*__GLX_SIZE_INT8), (char *)answer)
+
+#define __GLX_SEND_SHORT_ARRAY(len) \
+ WriteToClient(client, __GLX_PAD((len)*__GLX_SIZE_INT16), (char *)answer)
+
+#define __GLX_SEND_INT_ARRAY(len) \
+ WriteToClient(client, (len)*__GLX_SIZE_INT32, (char *)answer)
+
+#define __GLX_SEND_FLOAT_ARRAY(len) \
+ WriteToClient(client, (len)*__GLX_SIZE_FLOAT32, (char *)answer)
+
+#define __GLX_SEND_DOUBLE_ARRAY(len) \
+ WriteToClient(client, (len)*__GLX_SIZE_FLOAT64, (char *)answer)
+
+
+#define __GLX_SEND_VOID_ARRAY(len) __GLX_SEND_BYTE_ARRAY(len)
+#define __GLX_SEND_UBYTE_ARRAY(len) __GLX_SEND_BYTE_ARRAY(len)
+#define __GLX_SEND_USHORT_ARRAY(len) __GLX_SEND_SHORT_ARRAY(len)
+#define __GLX_SEND_UINT_ARRAY(len) __GLX_SEND_INT_ARRAY(len)
+
+/*
+** PERFORMANCE NOTE:
+** Machine dependent optimizations abound here; these swapping macros can
+** conceivably be replaced with routines that do the job faster.
+*/
+#define __GLX_DECLARE_SWAP_VARIABLES \
+ GLbyte sw
+
+#define __GLX_DECLARE_SWAP_ARRAY_VARIABLES \
+ GLbyte *swapPC; \
+ GLbyte *swapEnd
+
+
+#define __GLX_SWAP_INT(pc) \
+ sw = ((GLbyte *)(pc))[0]; \
+ ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[3]; \
+ ((GLbyte *)(pc))[3] = sw; \
+ sw = ((GLbyte *)(pc))[1]; \
+ ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[2]; \
+ ((GLbyte *)(pc))[2] = sw;
+
+#define __GLX_SWAP_SHORT(pc) \
+ sw = ((GLbyte *)(pc))[0]; \
+ ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[1]; \
+ ((GLbyte *)(pc))[1] = sw;
+
+#define __GLX_SWAP_DOUBLE(pc) \
+ sw = ((GLbyte *)(pc))[0]; \
+ ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[7]; \
+ ((GLbyte *)(pc))[7] = sw; \
+ sw = ((GLbyte *)(pc))[1]; \
+ ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[6]; \
+ ((GLbyte *)(pc))[6] = sw; \
+ sw = ((GLbyte *)(pc))[2]; \
+ ((GLbyte *)(pc))[2] = ((GLbyte *)(pc))[5]; \
+ ((GLbyte *)(pc))[5] = sw; \
+ sw = ((GLbyte *)(pc))[3]; \
+ ((GLbyte *)(pc))[3] = ((GLbyte *)(pc))[4]; \
+ ((GLbyte *)(pc))[4] = sw;
+
+#define __GLX_SWAP_FLOAT(pc) \
+ sw = ((GLbyte *)(pc))[0]; \
+ ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[3]; \
+ ((GLbyte *)(pc))[3] = sw; \
+ sw = ((GLbyte *)(pc))[1]; \
+ ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[2]; \
+ ((GLbyte *)(pc))[2] = sw;
+
+#define __GLX_SWAP_INT_ARRAY(pc, count) \
+ swapPC = ((GLbyte *)(pc)); \
+ swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_INT32;\
+ while (swapPC < swapEnd) { \
+ __GLX_SWAP_INT(swapPC); \
+ swapPC += __GLX_SIZE_INT32; \
+ }
+
+#define __GLX_SWAP_SHORT_ARRAY(pc, count) \
+ swapPC = ((GLbyte *)(pc)); \
+ swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_INT16;\
+ while (swapPC < swapEnd) { \
+ __GLX_SWAP_SHORT(swapPC); \
+ swapPC += __GLX_SIZE_INT16; \
+ }
+
+#define __GLX_SWAP_DOUBLE_ARRAY(pc, count) \
+ swapPC = ((GLbyte *)(pc)); \
+ swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_FLOAT64;\
+ while (swapPC < swapEnd) { \
+ __GLX_SWAP_DOUBLE(swapPC); \
+ swapPC += __GLX_SIZE_FLOAT64; \
+ }
+
+#define __GLX_SWAP_FLOAT_ARRAY(pc, count) \
+ swapPC = ((GLbyte *)(pc)); \
+ swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_FLOAT32;\
+ while (swapPC < swapEnd) { \
+ __GLX_SWAP_FLOAT(swapPC); \
+ swapPC += __GLX_SIZE_FLOAT32; \
+ }
+
+#define __GLX_SWAP_REPLY_HEADER() \
+ __GLX_SWAP_SHORT(&__glXReply.sequenceNumber); \
+ __GLX_SWAP_INT(&__glXReply.length);
+
+#define __GLX_SWAP_REPLY_RETVAL() \
+ __GLX_SWAP_INT(&__glXReply.retval)
+
+#define __GLX_SWAP_REPLY_SIZE() \
+ __GLX_SWAP_INT(&__glXReply.size)
+
+#endif /* !__GLX_unpack_h__ */
+
+
+
+
+
diff --git a/nx-X11/programs/Xserver/GL/glx/xfont.c b/nx-X11/programs/Xserver/GL/glx/xfont.c
new file mode 100644
index 000000000..c4995e272
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glx/xfont.c
@@ -0,0 +1,195 @@
+/* $XFree86$ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glxserver.h"
+#include "glxutil.h"
+#include "g_disptab.h"
+#include <unpack.h>
+#include <GL/gl.h>
+#include <pixmapstr.h>
+#include <windowstr.h>
+#include <dixfontstr.h>
+
+extern XID clientErrorValue; /* imported kludge from dix layer */
+
+/*
+** Make a single GL bitmap from a single X glyph
+*/
+static int __glXMakeBitmapFromGlyph(FontPtr font, CharInfoPtr pci)
+{
+ int i, j;
+ int widthPadded; /* width of glyph in bytes, as padded by X */
+ int allocBytes; /* bytes to allocate to store bitmap */
+ int w; /* width of glyph in bits */
+ int h; /* height of glyph */
+ register unsigned char *pglyph;
+ register unsigned char *p;
+ unsigned char *allocbuf;
+#define __GL_CHAR_BUF_SIZE 2048
+ unsigned char buf[__GL_CHAR_BUF_SIZE];
+
+ w = GLYPHWIDTHPIXELS(pci);
+ h = GLYPHHEIGHTPIXELS(pci);
+ widthPadded = GLYPHWIDTHBYTESPADDED(pci);
+
+ /*
+ ** Use the local buf if possible, otherwise malloc.
+ */
+ allocBytes = widthPadded * h;
+ if (allocBytes <= __GL_CHAR_BUF_SIZE) {
+ p = buf;
+ allocbuf = 0;
+ } else {
+ p = (unsigned char *) __glXMalloc(allocBytes);
+ if (!p)
+ return BadAlloc;
+ allocbuf = p;
+ }
+
+ /*
+ ** We have to reverse the picture, top to bottom
+ */
+
+ pglyph = FONTGLYPHBITS(FONTGLYPHS(font), pci) + (h-1)*widthPadded;
+ for (j=0; j < h; j++) {
+ for (i=0; i < widthPadded; i++) {
+ p[i] = pglyph[i];
+ }
+ pglyph -= widthPadded;
+ p += widthPadded;
+ }
+ glBitmap(w, h, -pci->metrics.leftSideBearing, pci->metrics.descent,
+ pci->metrics.characterWidth, 0, allocbuf ? allocbuf : buf);
+
+ if (allocbuf) {
+ __glXFree(allocbuf);
+ }
+ return Success;
+#undef __GL_CHAR_BUF_SIZE
+}
+
+/*
+** Create a GL bitmap for each character in the X font. The bitmap is stored
+** in a display list.
+*/
+
+static int
+MakeBitmapsFromFont(FontPtr pFont, int first, int count, int list_base)
+{
+ unsigned long i, nglyphs;
+ CARD8 chs[2]; /* the font index we are going after */
+ CharInfoPtr pci;
+ int rv; /* return value */
+ int encoding = (FONTLASTROW(pFont) == 0) ? Linear16Bit : TwoD16Bit;
+
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, FALSE);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, BITMAP_BIT_ORDER == LSBFirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, GLYPHPADBYTES);
+ for (i=0; i < count; i++) {
+ chs[0] = (first + i) >> 8; /* high byte is first byte */
+ chs[1] = first + i;
+
+ (*pFont->get_glyphs)(pFont, 1, chs, (FontEncoding)encoding,
+ &nglyphs, &pci);
+
+ /*
+ ** Define a display list containing just a glBitmap() call.
+ */
+ glNewList(list_base + i, GL_COMPILE);
+ if (nglyphs ) {
+ rv = __glXMakeBitmapFromGlyph(pFont, pci);
+ if (rv) {
+ return rv;
+ }
+ }
+ glEndList();
+ }
+ return Success;
+}
+
+/************************************************************************/
+
+int __glXUseXFont(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXUseXFontReq *req;
+ FontPtr pFont;
+ GC *pGC;
+ GLuint currentListIndex;
+ __GLXcontext *cx;
+ int error;
+
+ req = (xGLXUseXFontReq *) pc;
+ cx = __glXForceCurrent(cl, req->contextTag, &error);
+ if (!cx) {
+ return error;
+ }
+
+ glGetIntegerv(GL_LIST_INDEX, (GLint*) &currentListIndex);
+ if (currentListIndex != 0) {
+ /*
+ ** A display list is currently being made. It is an error
+ ** to try to make a font during another lists construction.
+ */
+ client->errorValue = cx->id;
+ return __glXBadContextState;
+ }
+
+ /*
+ ** Font can actually be either the ID of a font or the ID of a GC
+ ** containing a font.
+ */
+ pFont = (FontPtr)LookupIDByType(req->font, RT_FONT);
+ if (!pFont) {
+ pGC = (GC *)LookupIDByType(req->font, RT_GC);
+ if (!pGC) {
+ client->errorValue = req->font;
+ return BadFont;
+ }
+ pFont = pGC->font;
+ }
+
+ return MakeBitmapsFromFont(pFont, req->first, req->count,
+ req->listBase);
+}
diff --git a/nx-X11/programs/Xserver/GL/glxmodule.c b/nx-X11/programs/Xserver/GL/glxmodule.c
new file mode 100644
index 000000000..f8c03913e
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/glxmodule.c
@@ -0,0 +1,1270 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/programs/Xserver/GL/glxmodule.c,v 1.11 2001/06/15 21:22:38 dawes Exp $ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Module.h"
+#include "colormap.h"
+#include "micmap.h"
+#include "globals.h"
+
+static MODULESETUPPROTO(glxSetup);
+
+extern void GlxExtensionInit(INITARGS);
+extern void GlxWrapInitVisuals(miInitVisualsProcPtr *);
+extern void InitGlxWrapInitVisuals(void (*f)(miInitVisualsProcPtr *));
+
+static const char *initdeps[] = { "DOUBLE-BUFFER", NULL };
+
+ExtensionModule GLXExt =
+{
+ GlxExtensionInit,
+ "GLX",
+ &noGlxExtension,
+ NULL,
+ initdeps
+};
+
+static const char *glcoreSymbols[] = {
+ "__glCallLists_size",
+ "__glColorTableParameterfv_size",
+ "__glColorTableParameteriv_size",
+ "__glConvolutionParameterfv_size",
+ "__glConvolutionParameteriv_size",
+ "__glDDXExtensionInfo",
+ "__glDDXScreenInfo",
+ "__glFloorLog2",
+ "__glFogfv_size",
+ "__glFogiv_size",
+ "__glGetBooleanv_size",
+ "__glGetColorTableParameterfv_size",
+ "__glGetColorTableParameteriv_size",
+ "__glGetConvolutionParameterfv_size",
+ "__glGetConvolutionParameteriv_size",
+ "__glGetDoublev_size",
+ "__glGetFloatv_size",
+ "__glGetHistogramParameterfv_size",
+ "__glGetHistogramParameteriv_size",
+ "__glGetIntegerv_size",
+ "__glGetLightfv_size",
+ "__glGetLightiv_size",
+ "__glGetMapdv_size",
+ "__glGetMapfv_size",
+ "__glGetMapiv_size",
+ "__glGetMaterialfv_size",
+ "__glGetMaterialiv_size",
+ "__glGetMinmaxParameterfv_size",
+ "__glGetMinmaxParameteriv_size",
+ "__glGetPixelMapfv_size",
+ "__glGetPixelMapuiv_size",
+ "__glGetPixelMapusv_size",
+ "__glGetTexEnvfv_size",
+ "__glGetTexEnviv_size",
+ "__glGetTexGendv_size",
+ "__glGetTexGenfv_size",
+ "__glGetTexGeniv_size",
+ "__glGetTexImage_size",
+ "__glGetTexLevelParameterfv_size",
+ "__glGetTexLevelParameteriv_size",
+ "__glGetTexParameterfv_size",
+ "__glGetTexParameteriv_size",
+ "__glLightModelfv_size",
+ "__glLightModeliv_size",
+ "__glLightfv_size",
+ "__glLightiv_size",
+ "__glMaterialfv_size",
+ "__glMaterialiv_size",
+ "__glPointParameterfvARB_size",
+ "__glReadPixels_size",
+ "__glTexEnvfv_size",
+ "__glTexEnviv_size",
+ "__glTexGendv_size",
+ "__glTexGenfv_size",
+ "__glTexGeniv_size",
+ "__glTexParameterfv_size",
+ "__glTexParameteriv_size",
+ "__glXglDDXExtensionInfo",
+ "__glXglDDXScreenInfo",
+ "__glXActiveScreens",
+ "__glXAssociateContext",
+ "__glXBadContext",
+ "__glXBadContextState",
+ "__glXBadContextTag",
+ "__glXBadCurrentWindow",
+ "__glXBadDrawable",
+ "__glXBadLargeRequest",
+ "__glXBadPixmap",
+ "__glXBadRenderRequest",
+ "__glXBitmapReqSize",
+ "__glXCacheDrawableSize",
+ "__glXCallListsReqSize",
+ "__glXClearErrorOccured",
+ "__glXClientInfo",
+ "__glXClientRes",
+ "__glXClients",
+ "__glXColorSubTableReqSize",
+ "__glXColorTableParameterfvReqSize",
+ "__glXColorTableParameterivReqSize",
+ "__glXColorTableReqSize",
+ "__glXContextRes",
+ "__glXConvolutionFilter1DReqSize",
+ "__glXConvolutionFilter2DReqSize",
+ "__glXConvolutionParameterfvReqSize",
+ "__glXConvolutionParameterivReqSize",
+ "__glXCopyContext",
+ "__glXCoreType",
+ "__glXCreateContext",
+ "__glXCreateGLXPixmap",
+ "__glXDeassociateContext",
+ "__glXDestroyContext",
+ "__glXDestroyGLXPixmap",
+ "__glXDispSwap_Accum",
+ "__glXDispSwap_ActiveStencilFaceEXT",
+ "__glXDispSwap_ActiveTextureARB",
+ "__glXDispSwap_AlphaFunc",
+ "__glXDispSwap_AreTexturesResident",
+ "__glXDispSwap_AreTexturesResidentEXT",
+ "__glXDispSwap_Begin",
+ "__glXDispSwap_BindTexture",
+ "__glXDispSwap_Bitmap",
+ "__glXDispSwap_BlendColor",
+ "__glXDispSwap_BlendEquation",
+ "__glXDispSwap_BlendFunc",
+ "__glXDispSwap_CallList",
+ "__glXDispSwap_CallLists",
+ "__glXDispSwap_Clear",
+ "__glXDispSwap_ClearAccum",
+ "__glXDispSwap_ClearColor",
+ "__glXDispSwap_ClearDepth",
+ "__glXDispSwap_ClearIndex",
+ "__glXDispSwap_ClearStencil",
+ "__glXDispSwap_ClipPlane",
+ "__glXDispSwap_Color3bv",
+ "__glXDispSwap_Color3dv",
+ "__glXDispSwap_Color3fv",
+ "__glXDispSwap_Color3iv",
+ "__glXDispSwap_Color3sv",
+ "__glXDispSwap_Color3ubv",
+ "__glXDispSwap_Color3uiv",
+ "__glXDispSwap_Color3usv",
+ "__glXDispSwap_Color4bv",
+ "__glXDispSwap_Color4dv",
+ "__glXDispSwap_Color4fv",
+ "__glXDispSwap_Color4iv",
+ "__glXDispSwap_Color4sv",
+ "__glXDispSwap_Color4ubv",
+ "__glXDispSwap_Color4uiv",
+ "__glXDispSwap_Color4usv",
+ "__glXDispSwap_ColorMask",
+ "__glXDispSwap_ColorMaterial",
+ "__glXDispSwap_ColorSubTable",
+ "__glXDispSwap_ColorTable",
+ "__glXDispSwap_ColorTableParameterfv",
+ "__glXDispSwap_ColorTableParameteriv",
+ "__glXDispSwap_ConvolutionFilter1D",
+ "__glXDispSwap_ConvolutionFilter2D",
+ "__glXDispSwap_ConvolutionParameterf",
+ "__glXDispSwap_ConvolutionParameterfv",
+ "__glXDispSwap_ConvolutionParameteri",
+ "__glXDispSwap_ConvolutionParameteriv",
+ "__glXDispSwap_CopyColorSubTable",
+ "__glXDispSwap_CopyColorTable",
+ "__glXDispSwap_CopyConvolutionFilter1D",
+ "__glXDispSwap_CopyConvolutionFilter2D",
+ "__glXDispSwap_CopyPixels",
+ "__glXDispSwap_CopyTexImage1D",
+ "__glXDispSwap_CopyTexImage2D",
+ "__glXDispSwap_CopyTexSubImage1D",
+ "__glXDispSwap_CopyTexSubImage2D",
+ "__glXDispSwap_CopyTexSubImage3D",
+ "__glXDispSwap_CullFace",
+ "__glXDispSwap_DeleteLists",
+ "__glXDispSwap_DeleteTextures",
+ "__glXDispSwap_DeleteTexturesEXT",
+ "__glXDispSwap_DepthFunc",
+ "__glXDispSwap_DepthMask",
+ "__glXDispSwap_DepthRange",
+ "__glXDispSwap_Disable",
+ "__glXDispSwap_DrawArrays",
+ "__glXDispSwap_DrawArraysEXT",
+ "__glXDispSwap_DrawBuffer",
+ "__glXDispSwap_DrawPixels",
+ "__glXDispSwap_EdgeFlagv",
+ "__glXDispSwap_Enable",
+ "__glXDispSwap_End",
+ "__glXDispSwap_EndList",
+ "__glXDispSwap_EvalCoord1dv",
+ "__glXDispSwap_EvalCoord1fv",
+ "__glXDispSwap_EvalCoord2dv",
+ "__glXDispSwap_EvalCoord2fv",
+ "__glXDispSwap_EvalMesh1",
+ "__glXDispSwap_EvalMesh2",
+ "__glXDispSwap_EvalPoint1",
+ "__glXDispSwap_EvalPoint2",
+ "__glXDispSwap_FeedbackBuffer",
+ "__glXDispSwap_Finish",
+ "__glXDispSwap_Flush",
+ "__glXDispSwap_Fogf",
+ "__glXDispSwap_Fogfv",
+ "__glXDispSwap_Fogi",
+ "__glXDispSwap_Fogiv",
+ "__glXDispSwap_FrontFace",
+ "__glXDispSwap_Frustum",
+ "__glXDispSwap_GenLists",
+ "__glXDispSwap_GenTextures",
+ "__glXDispSwap_GenTexturesEXT",
+ "__glXDispSwap_GetBooleanv",
+ "__glXDispSwap_GetClipPlane",
+ "__glXDispSwap_GetColorTable",
+ "__glXDispSwap_GetColorTableParameterfv",
+ "__glXDispSwap_GetColorTableParameteriv",
+ "__glXDispSwap_GetConvolutionFilter",
+ "__glXDispSwap_GetConvolutionParameterfv",
+ "__glXDispSwap_GetConvolutionParameteriv",
+ "__glXDispSwap_GetDoublev",
+ "__glXDispSwap_GetError",
+ "__glXDispSwap_GetFloatv",
+ "__glXDispSwap_GetHistogram",
+ "__glXDispSwap_GetHistogramParameterfv",
+ "__glXDispSwap_GetHistogramParameteriv",
+ "__glXDispSwap_GetIntegerv",
+ "__glXDispSwap_GetLightfv",
+ "__glXDispSwap_GetLightiv",
+ "__glXDispSwap_GetMapdv",
+ "__glXDispSwap_GetMapfv",
+ "__glXDispSwap_GetMapiv",
+ "__glXDispSwap_GetMaterialfv",
+ "__glXDispSwap_GetMaterialiv",
+ "__glXDispSwap_GetMinmax",
+ "__glXDispSwap_GetMinmaxParameterfv",
+ "__glXDispSwap_GetMinmaxParameteriv",
+ "__glXDispSwap_GetPixelMapfv",
+ "__glXDispSwap_GetPixelMapuiv",
+ "__glXDispSwap_GetPixelMapusv",
+ "__glXDispSwap_GetPolygonStipple",
+ "__glXDispSwap_GetSeparableFilter",
+ "__glXDispSwap_GetString",
+ "__glXDispSwap_GetTexEnvfv",
+ "__glXDispSwap_GetTexEnviv",
+ "__glXDispSwap_GetTexGendv",
+ "__glXDispSwap_GetTexGenfv",
+ "__glXDispSwap_GetTexGeniv",
+ "__glXDispSwap_GetTexImage",
+ "__glXDispSwap_GetTexLevelParameterfv",
+ "__glXDispSwap_GetTexLevelParameteriv",
+ "__glXDispSwap_GetTexParameterfv",
+ "__glXDispSwap_GetTexParameteriv",
+ "__glXDispSwap_Hint",
+ "__glXDispSwap_Histogram",
+ "__glXDispSwap_IndexMask",
+ "__glXDispSwap_Indexdv",
+ "__glXDispSwap_Indexfv",
+ "__glXDispSwap_Indexiv",
+ "__glXDispSwap_Indexsv",
+ "__glXDispSwap_Indexubv",
+ "__glXDispSwap_InitNames",
+ "__glXDispSwap_IsEnabled",
+ "__glXDispSwap_IsList",
+ "__glXDispSwap_IsTexture",
+ "__glXDispSwap_IsTextureEXT",
+ "__glXDispSwap_LightModelf",
+ "__glXDispSwap_LightModelfv",
+ "__glXDispSwap_LightModeli",
+ "__glXDispSwap_LightModeliv",
+ "__glXDispSwap_Lightf",
+ "__glXDispSwap_Lightfv",
+ "__glXDispSwap_Lighti",
+ "__glXDispSwap_Lightiv",
+ "__glXDispSwap_LineStipple",
+ "__glXDispSwap_LineWidth",
+ "__glXDispSwap_ListBase",
+ "__glXDispSwap_LoadIdentity",
+ "__glXDispSwap_LoadMatrixd",
+ "__glXDispSwap_LoadMatrixf",
+ "__glXDispSwap_LoadName",
+ "__glXDispSwap_LogicOp",
+ "__glXDispSwap_Map1d",
+ "__glXDispSwap_Map1f",
+ "__glXDispSwap_Map2d",
+ "__glXDispSwap_Map2f",
+ "__glXDispSwap_MapGrid1d",
+ "__glXDispSwap_MapGrid1f",
+ "__glXDispSwap_MapGrid2d",
+ "__glXDispSwap_MapGrid2f",
+ "__glXDispSwap_Materialf",
+ "__glXDispSwap_Materialfv",
+ "__glXDispSwap_Materiali",
+ "__glXDispSwap_Materialiv",
+ "__glXDispSwap_MatrixMode",
+ "__glXDispSwap_Minmax",
+ "__glXDispSwap_MultMatrixd",
+ "__glXDispSwap_MultMatrixf",
+ "__glXDispSwap_MultiTexCoord1dvARB",
+ "__glXDispSwap_MultiTexCoord1fvARB",
+ "__glXDispSwap_MultiTexCoord1ivARB",
+ "__glXDispSwap_MultiTexCoord1svARB",
+ "__glXDispSwap_MultiTexCoord2dvARB",
+ "__glXDispSwap_MultiTexCoord2fvARB",
+ "__glXDispSwap_MultiTexCoord2ivARB",
+ "__glXDispSwap_MultiTexCoord2svARB",
+ "__glXDispSwap_MultiTexCoord3dvARB",
+ "__glXDispSwap_MultiTexCoord3fvARB",
+ "__glXDispSwap_MultiTexCoord3ivARB",
+ "__glXDispSwap_MultiTexCoord3svARB",
+ "__glXDispSwap_MultiTexCoord4dvARB",
+ "__glXDispSwap_MultiTexCoord4fvARB",
+ "__glXDispSwap_MultiTexCoord4ivARB",
+ "__glXDispSwap_MultiTexCoord4svARB",
+ "__glXDispSwap_NewList",
+ "__glXDispSwap_Normal3bv",
+ "__glXDispSwap_Normal3dv",
+ "__glXDispSwap_Normal3fv",
+ "__glXDispSwap_Normal3iv",
+ "__glXDispSwap_Normal3sv",
+ "__glXDispSwap_Ortho",
+ "__glXDispSwap_PassThrough",
+ "__glXDispSwap_PixelMapfv",
+ "__glXDispSwap_PixelMapuiv",
+ "__glXDispSwap_PixelMapusv",
+ "__glXDispSwap_PixelStoref",
+ "__glXDispSwap_PixelStorei",
+ "__glXDispSwap_PixelTransferf",
+ "__glXDispSwap_PixelTransferi",
+ "__glXDispSwap_PixelZoom",
+ "__glXDispSwap_PointParameterfARB",
+ "__glXDispSwap_PointParameterfvARB",
+ "__glXDispSwap_PointSize",
+ "__glXDispSwap_PolygonMode",
+ "__glXDispSwap_PolygonOffset",
+ "__glXDispSwap_PolygonStipple",
+ "__glXDispSwap_PopAttrib",
+ "__glXDispSwap_PopMatrix",
+ "__glXDispSwap_PopName",
+ "__glXDispSwap_PrioritizeTextures",
+ "__glXDispSwap_PushAttrib",
+ "__glXDispSwap_PushMatrix",
+ "__glXDispSwap_PushName",
+ "__glXDispSwap_RasterPos2dv",
+ "__glXDispSwap_RasterPos2fv",
+ "__glXDispSwap_RasterPos2iv",
+ "__glXDispSwap_RasterPos2sv",
+ "__glXDispSwap_RasterPos3dv",
+ "__glXDispSwap_RasterPos3fv",
+ "__glXDispSwap_RasterPos3iv",
+ "__glXDispSwap_RasterPos3sv",
+ "__glXDispSwap_RasterPos4dv",
+ "__glXDispSwap_RasterPos4fv",
+ "__glXDispSwap_RasterPos4iv",
+ "__glXDispSwap_RasterPos4sv",
+ "__glXDispSwap_ReadBuffer",
+ "__glXDispSwap_ReadPixels",
+ "__glXDispSwap_Rectdv",
+ "__glXDispSwap_Rectfv",
+ "__glXDispSwap_Rectiv",
+ "__glXDispSwap_Rectsv",
+ "__glXDispSwap_RenderMode",
+ "__glXDispSwap_ResetHistogram",
+ "__glXDispSwap_ResetMinmax",
+ "__glXDispSwap_Rotated",
+ "__glXDispSwap_Rotatef",
+ "__glXDispSwap_Scaled",
+ "__glXDispSwap_Scalef",
+ "__glXDispSwap_Scissor",
+ "__glXDispSwap_SelectBuffer",
+ "__glXDispSwap_SeparableFilter2D",
+ "__glXDispSwap_ShadeModel",
+ "__glXDispSwap_StencilFunc",
+ "__glXDispSwap_StencilMask",
+ "__glXDispSwap_StencilOp",
+ "__glXDispSwap_TexCoord1dv",
+ "__glXDispSwap_TexCoord1fv",
+ "__glXDispSwap_TexCoord1iv",
+ "__glXDispSwap_TexCoord1sv",
+ "__glXDispSwap_TexCoord2dv",
+ "__glXDispSwap_TexCoord2fv",
+ "__glXDispSwap_TexCoord2iv",
+ "__glXDispSwap_TexCoord2sv",
+ "__glXDispSwap_TexCoord3dv",
+ "__glXDispSwap_TexCoord3fv",
+ "__glXDispSwap_TexCoord3iv",
+ "__glXDispSwap_TexCoord3sv",
+ "__glXDispSwap_TexCoord4dv",
+ "__glXDispSwap_TexCoord4fv",
+ "__glXDispSwap_TexCoord4iv",
+ "__glXDispSwap_TexCoord4sv",
+ "__glXDispSwap_TexEnvf",
+ "__glXDispSwap_TexEnvfv",
+ "__glXDispSwap_TexEnvi",
+ "__glXDispSwap_TexEnviv",
+ "__glXDispSwap_TexGend",
+ "__glXDispSwap_TexGendv",
+ "__glXDispSwap_TexGenf",
+ "__glXDispSwap_TexGenfv",
+ "__glXDispSwap_TexGeni",
+ "__glXDispSwap_TexGeniv",
+ "__glXDispSwap_TexImage1D",
+ "__glXDispSwap_TexImage2D",
+ "__glXDispSwap_TexImage3D",
+ "__glXDispSwap_TexParameterf",
+ "__glXDispSwap_TexParameterfv",
+ "__glXDispSwap_TexParameteri",
+ "__glXDispSwap_TexParameteriv",
+ "__glXDispSwap_TexSubImage1D",
+ "__glXDispSwap_TexSubImage2D",
+ "__glXDispSwap_TexSubImage3D",
+ "__glXDispSwap_Translated",
+ "__glXDispSwap_Translatef",
+ "__glXDispSwap_Vertex2dv",
+ "__glXDispSwap_Vertex2fv",
+ "__glXDispSwap_Vertex2iv",
+ "__glXDispSwap_Vertex2sv",
+ "__glXDispSwap_Vertex3dv",
+ "__glXDispSwap_Vertex3fv",
+ "__glXDispSwap_Vertex3iv",
+ "__glXDispSwap_Vertex3sv",
+ "__glXDispSwap_Vertex4dv",
+ "__glXDispSwap_Vertex4fv",
+ "__glXDispSwap_Vertex4iv",
+ "__glXDispSwap_Vertex4sv",
+ "__glXDispSwap_Viewport",
+ "__glXDispSwap_WindowPos3fARB",
+ "__glXDisp_Accum",
+ "__glXDisp_ActiveStencilFaceEXT",
+ "__glXDisp_ActiveTextureARB",
+ "__glXDisp_AlphaFunc",
+ "__glXDisp_AreTexturesResident",
+ "__glXDisp_AreTexturesResidentEXT",
+ "__glXDisp_Begin",
+ "__glXDisp_BindTexture",
+ "__glXDisp_Bitmap",
+ "__glXDisp_BlendColor",
+ "__glXDisp_BlendEquation",
+ "__glXDisp_BlendFunc",
+ "__glXDisp_CallList",
+ "__glXDisp_CallLists",
+ "__glXDisp_Clear",
+ "__glXDisp_ClearAccum",
+ "__glXDisp_ClearColor",
+ "__glXDisp_ClearDepth",
+ "__glXDisp_ClearIndex",
+ "__glXDisp_ClearStencil",
+ "__glXDisp_ClipPlane",
+ "__glXDisp_Color3bv",
+ "__glXDisp_Color3dv",
+ "__glXDisp_Color3fv",
+ "__glXDisp_Color3iv",
+ "__glXDisp_Color3sv",
+ "__glXDisp_Color3ubv",
+ "__glXDisp_Color3uiv",
+ "__glXDisp_Color3usv",
+ "__glXDisp_Color4bv",
+ "__glXDisp_Color4dv",
+ "__glXDisp_Color4fv",
+ "__glXDisp_Color4iv",
+ "__glXDisp_Color4sv",
+ "__glXDisp_Color4ubv",
+ "__glXDisp_Color4uiv",
+ "__glXDisp_Color4usv",
+ "__glXDisp_ColorMask",
+ "__glXDisp_ColorMaterial",
+ "__glXDisp_ColorSubTable",
+ "__glXDisp_ColorTable",
+ "__glXDisp_ColorTableParameterfv",
+ "__glXDisp_ColorTableParameteriv",
+ "__glXDisp_ConvolutionFilter1D",
+ "__glXDisp_ConvolutionFilter2D",
+ "__glXDisp_ConvolutionParameterf",
+ "__glXDisp_ConvolutionParameterfv",
+ "__glXDisp_ConvolutionParameteri",
+ "__glXDisp_ConvolutionParameteriv",
+ "__glXDisp_CopyColorSubTable",
+ "__glXDisp_CopyColorTable",
+ "__glXDisp_CopyConvolutionFilter1D",
+ "__glXDisp_CopyConvolutionFilter2D",
+ "__glXDisp_CopyPixels",
+ "__glXDisp_CopyTexImage1D",
+ "__glXDisp_CopyTexImage2D",
+ "__glXDisp_CopyTexSubImage1D",
+ "__glXDisp_CopyTexSubImage2D",
+ "__glXDisp_CopyTexSubImage3D",
+ "__glXDisp_CullFace",
+ "__glXDisp_DeleteLists",
+ "__glXDisp_DeleteTextures",
+ "__glXDisp_DeleteTexturesEXT",
+ "__glXDisp_DepthFunc",
+ "__glXDisp_DepthMask",
+ "__glXDisp_DepthRange",
+ "__glXDisp_Disable",
+ "__glXDisp_DrawArrays",
+ "__glXDisp_DrawArraysEXT",
+ "__glXDisp_DrawBuffer",
+ "__glXDisp_DrawPixels",
+ "__glXDisp_EdgeFlagv",
+ "__glXDisp_Enable",
+ "__glXDisp_End",
+ "__glXDisp_EndList",
+ "__glXDisp_EvalCoord1dv",
+ "__glXDisp_EvalCoord1fv",
+ "__glXDisp_EvalCoord2dv",
+ "__glXDisp_EvalCoord2fv",
+ "__glXDisp_EvalMesh1",
+ "__glXDisp_EvalMesh2",
+ "__glXDisp_EvalPoint1",
+ "__glXDisp_EvalPoint2",
+ "__glXDisp_FeedbackBuffer",
+ "__glXDisp_Finish",
+ "__glXDisp_Flush",
+ "__glXDisp_Fogf",
+ "__glXDisp_Fogfv",
+ "__glXDisp_Fogi",
+ "__glXDisp_Fogiv",
+ "__glXDisp_FrontFace",
+ "__glXDisp_Frustum",
+ "__glXDisp_GenLists",
+ "__glXDisp_GenTextures",
+ "__glXDisp_GenTexturesEXT",
+ "__glXDisp_GetBooleanv",
+ "__glXDisp_GetClipPlane",
+ "__glXDisp_GetColorTable",
+ "__glXDisp_GetColorTableParameterfv",
+ "__glXDisp_GetColorTableParameteriv",
+ "__glXDisp_GetConvolutionFilter",
+ "__glXDisp_GetConvolutionParameterfv",
+ "__glXDisp_GetConvolutionParameteriv",
+ "__glXDisp_GetDoublev",
+ "__glXDisp_GetError",
+ "__glXDisp_GetFloatv",
+ "__glXDisp_GetHistogram",
+ "__glXDisp_GetHistogramParameterfv",
+ "__glXDisp_GetHistogramParameteriv",
+ "__glXDisp_GetIntegerv",
+ "__glXDisp_GetLightfv",
+ "__glXDisp_GetLightiv",
+ "__glXDisp_GetMapdv",
+ "__glXDisp_GetMapfv",
+ "__glXDisp_GetMapiv",
+ "__glXDisp_GetMaterialfv",
+ "__glXDisp_GetMaterialiv",
+ "__glXDisp_GetMinmax",
+ "__glXDisp_GetMinmaxParameterfv",
+ "__glXDisp_GetMinmaxParameteriv",
+ "__glXDisp_GetPixelMapfv",
+ "__glXDisp_GetPixelMapuiv",
+ "__glXDisp_GetPixelMapusv",
+ "__glXDisp_GetPolygonStipple",
+ "__glXDisp_GetSeparableFilter",
+ "__glXDisp_GetString",
+ "__glXDisp_GetTexEnvfv",
+ "__glXDisp_GetTexEnviv",
+ "__glXDisp_GetTexGendv",
+ "__glXDisp_GetTexGenfv",
+ "__glXDisp_GetTexGeniv",
+ "__glXDisp_GetTexImage",
+ "__glXDisp_GetTexLevelParameterfv",
+ "__glXDisp_GetTexLevelParameteriv",
+ "__glXDisp_GetTexParameterfv",
+ "__glXDisp_GetTexParameteriv",
+ "__glXDisp_Hint",
+ "__glXDisp_Histogram",
+ "__glXDisp_IndexMask",
+ "__glXDisp_Indexdv",
+ "__glXDisp_Indexfv",
+ "__glXDisp_Indexiv",
+ "__glXDisp_Indexsv",
+ "__glXDisp_Indexubv",
+ "__glXDisp_InitNames",
+ "__glXDisp_IsEnabled",
+ "__glXDisp_IsList",
+ "__glXDisp_IsTexture",
+ "__glXDisp_IsTextureEXT",
+ "__glXDisp_LightModelf",
+ "__glXDisp_LightModelfv",
+ "__glXDisp_LightModeli",
+ "__glXDisp_LightModeliv",
+ "__glXDisp_Lightf",
+ "__glXDisp_Lightfv",
+ "__glXDisp_Lighti",
+ "__glXDisp_Lightiv",
+ "__glXDisp_LineStipple",
+ "__glXDisp_LineWidth",
+ "__glXDisp_ListBase",
+ "__glXDisp_LoadIdentity",
+ "__glXDisp_LoadMatrixd",
+ "__glXDisp_LoadMatrixf",
+ "__glXDisp_LoadName",
+ "__glXDisp_LogicOp",
+ "__glXDisp_Map1d",
+ "__glXDisp_Map1f",
+ "__glXDisp_Map2d",
+ "__glXDisp_Map2f",
+ "__glXDisp_MapGrid1d",
+ "__glXDisp_MapGrid1f",
+ "__glXDisp_MapGrid2d",
+ "__glXDisp_MapGrid2f",
+ "__glXDisp_Materialf",
+ "__glXDisp_Materialfv",
+ "__glXDisp_Materiali",
+ "__glXDisp_Materialiv",
+ "__glXDisp_MatrixMode",
+ "__glXDisp_Minmax",
+ "__glXDisp_MultMatrixd",
+ "__glXDisp_MultMatrixf",
+ "__glXDisp_MultiTexCoord1dvARB",
+ "__glXDisp_MultiTexCoord1fvARB",
+ "__glXDisp_MultiTexCoord1ivARB",
+ "__glXDisp_MultiTexCoord1svARB",
+ "__glXDisp_MultiTexCoord2dvARB",
+ "__glXDisp_MultiTexCoord2fvARB",
+ "__glXDisp_MultiTexCoord2ivARB",
+ "__glXDisp_MultiTexCoord2svARB",
+ "__glXDisp_MultiTexCoord3dvARB",
+ "__glXDisp_MultiTexCoord3fvARB",
+ "__glXDisp_MultiTexCoord3ivARB",
+ "__glXDisp_MultiTexCoord3svARB",
+ "__glXDisp_MultiTexCoord4dvARB",
+ "__glXDisp_MultiTexCoord4fvARB",
+ "__glXDisp_MultiTexCoord4ivARB",
+ "__glXDisp_MultiTexCoord4svARB",
+ "__glXDisp_NewList",
+ "__glXDisp_Normal3bv",
+ "__glXDisp_Normal3dv",
+ "__glXDisp_Normal3fv",
+ "__glXDisp_Normal3iv",
+ "__glXDisp_Normal3sv",
+ "__glXDisp_Ortho",
+ "__glXDisp_PassThrough",
+ "__glXDisp_PixelMapfv",
+ "__glXDisp_PixelMapuiv",
+ "__glXDisp_PixelMapusv",
+ "__glXDisp_PixelStoref",
+ "__glXDisp_PixelStorei",
+ "__glXDisp_PixelTransferf",
+ "__glXDisp_PixelTransferi",
+ "__glXDisp_PixelZoom",
+ "__glXDisp_PointParameterfARB",
+ "__glXDisp_PointParameterfvARB",
+ "__glXDisp_PointSize",
+ "__glXDisp_PolygonMode",
+ "__glXDisp_PolygonOffset",
+ "__glXDisp_PolygonStipple",
+ "__glXDisp_PopAttrib",
+ "__glXDisp_PopMatrix",
+ "__glXDisp_PopName",
+ "__glXDisp_PrioritizeTextures",
+ "__glXDisp_PushAttrib",
+ "__glXDisp_PushMatrix",
+ "__glXDisp_PushName",
+ "__glXDisp_RasterPos2dv",
+ "__glXDisp_RasterPos2fv",
+ "__glXDisp_RasterPos2iv",
+ "__glXDisp_RasterPos2sv",
+ "__glXDisp_RasterPos3dv",
+ "__glXDisp_RasterPos3fv",
+ "__glXDisp_RasterPos3iv",
+ "__glXDisp_RasterPos3sv",
+ "__glXDisp_RasterPos4dv",
+ "__glXDisp_RasterPos4fv",
+ "__glXDisp_RasterPos4iv",
+ "__glXDisp_RasterPos4sv",
+ "__glXDisp_ReadBuffer",
+ "__glXDisp_ReadPixels",
+ "__glXDisp_Rectdv",
+ "__glXDisp_Rectfv",
+ "__glXDisp_Rectiv",
+ "__glXDisp_Rectsv",
+ "__glXDisp_RenderMode",
+ "__glXDisp_ResetHistogram",
+ "__glXDisp_ResetMinmax",
+ "__glXDisp_Rotated",
+ "__glXDisp_Rotatef",
+ "__glXDisp_Scaled",
+ "__glXDisp_Scalef",
+ "__glXDisp_Scissor",
+ "__glXDisp_SelectBuffer",
+ "__glXDisp_SeparableFilter2D",
+ "__glXDisp_ShadeModel",
+ "__glXDisp_StencilFunc",
+ "__glXDisp_StencilMask",
+ "__glXDisp_StencilOp",
+ "__glXDisp_TexCoord1dv",
+ "__glXDisp_TexCoord1fv",
+ "__glXDisp_TexCoord1iv",
+ "__glXDisp_TexCoord1sv",
+ "__glXDisp_TexCoord2dv",
+ "__glXDisp_TexCoord2fv",
+ "__glXDisp_TexCoord2iv",
+ "__glXDisp_TexCoord2sv",
+ "__glXDisp_TexCoord3dv",
+ "__glXDisp_TexCoord3fv",
+ "__glXDisp_TexCoord3iv",
+ "__glXDisp_TexCoord3sv",
+ "__glXDisp_TexCoord4dv",
+ "__glXDisp_TexCoord4fv",
+ "__glXDisp_TexCoord4iv",
+ "__glXDisp_TexCoord4sv",
+ "__glXDisp_TexEnvf",
+ "__glXDisp_TexEnvfv",
+ "__glXDisp_TexEnvi",
+ "__glXDisp_TexEnviv",
+ "__glXDisp_TexGend",
+ "__glXDisp_TexGendv",
+ "__glXDisp_TexGenf",
+ "__glXDisp_TexGenfv",
+ "__glXDisp_TexGeni",
+ "__glXDisp_TexGeniv",
+ "__glXDisp_TexImage1D",
+ "__glXDisp_TexImage2D",
+ "__glXDisp_TexImage3D",
+ "__glXDisp_TexParameterf",
+ "__glXDisp_TexParameterfv",
+ "__glXDisp_TexParameteri",
+ "__glXDisp_TexParameteriv",
+ "__glXDisp_TexSubImage1D",
+ "__glXDisp_TexSubImage2D",
+ "__glXDisp_TexSubImage3D",
+ "__glXDisp_Translated",
+ "__glXDisp_Translatef",
+ "__glXDisp_Vertex2dv",
+ "__glXDisp_Vertex2fv",
+ "__glXDisp_Vertex2iv",
+ "__glXDisp_Vertex2sv",
+ "__glXDisp_Vertex3dv",
+ "__glXDisp_Vertex3fv",
+ "__glXDisp_Vertex3iv",
+ "__glXDisp_Vertex3sv",
+ "__glXDisp_Vertex4dv",
+ "__glXDisp_Vertex4fv",
+ "__glXDisp_Vertex4iv",
+ "__glXDisp_Vertex4sv",
+ "__glXDisp_Viewport",
+ "__glXDisp_WindowPos3fARB",
+ "__glXDrawArraysSize",
+ "__glXDrawPixelsReqSize",
+ "__glXDrawableRes",
+ "__glXErrorOccured",
+ "__glXFBInitDrawable",
+ "__glXFBMemSwapBuffers",
+ "__glXFindDrawablePrivate",
+ "__glXFogfvReqSize",
+ "__glXFogivReqSize",
+ "__glXForceCurrent",
+ "__glXFree",
+ "__glXFreeBuffers",
+ "__glXFreeContext",
+ "__glXGetDrawablePrivate",
+ "__glXGetVisualConfigs",
+ "__glXImageSize",
+ "__glXImpAtoi",
+ "__glXImpCalloc",
+ "__glXImpFatal",
+ "__glXImpFclose",
+ "__glXImpFopen",
+ "__glXImpFprintf",
+ "__glXImpFree",
+ "__glXImpGetDrawablePrivate",
+ "__glXImpGetenv",
+ "__glXImpMalloc",
+ "__glXImpRealloc",
+ "__glXImpSprintf",
+ "__glXImpWarning",
+ "__glXInitFB",
+ "__glXInitMem",
+ "__glXInitPix",
+ "__glXIsDirect",
+ "__glXLastContext",
+ "__glXLightModelfvReqSize",
+ "__glXLightModelivReqSize",
+ "__glXLightfvReqSize",
+ "__glXLightivReqSize",
+ "__glXLookupContextByTag",
+ "__glXMakeCurrent",
+ "__glXMalloc",
+ "__glXMap1dReqSize",
+ "__glXMap1fReqSize",
+ "__glXMap2dReqSize",
+ "__glXMap2fReqSize",
+ "__glXMaterialfvReqSize",
+ "__glXMaterialivReqSize",
+ "__glXNoSuchRenderOpcode",
+ "__glXNoSuchSingleOpcode",
+ "__glXNop",
+ "__glXPixInitDrawable",
+ "__glXPixelMapfvReqSize",
+ "__glXPixelMapuivReqSize",
+ "__glXPixelMapusvReqSize",
+ "__glXPixmapRes",
+ "__glXPrioritizeTexturesReqSize",
+ "__glXQueryContextInfoEXT",
+ "__glXQueryExtensionsString",
+ "__glXQueryServerString",
+ "__glXQueryVersion",
+ "__glXRealloc",
+ "__glXRender",
+ "__glXRenderLarge",
+ "__glXRenderSizeTable",
+ "__glXRenderSizeTable_EXT",
+ "__glXRenderTable",
+ "__glXRenderTable_EXT",
+ "__glXReply",
+ "__glXResetLargeCommandStatus",
+ "__glXResizeBuffers",
+ "__glXResizeDrawableBuffers",
+ "__glXScreenInit",
+ "__glXScreenReset",
+ "__glXSeparableFilter2DReqSize",
+ "__glXSingleTable",
+ "__glXSwapBuffers",
+ "__glXSwapClientInfo",
+ "__glXSwapCopyContext",
+ "__glXSwapCreateContext",
+ "__glXSwapCreateGLXPixmap",
+ "__glXSwapDestroyContext",
+ "__glXSwapDestroyGLXPixmap",
+ "__glXSwapGetVisualConfigs",
+ "__glXSwapIsDirect",
+ "__glXSwapIsDirectReply",
+ "__glXSwapMakeCurrent",
+ "__glXSwapMakeCurrentReply",
+ "__glXSwapQueryContextInfoEXTReply",
+ "__glXSwapQueryExtensionsString",
+ "__glXSwapQueryServerString",
+ "__glXSwapQueryVersion",
+ "__glXSwapQueryVersionReply",
+ "__glXSwapRender",
+ "__glXSwapRenderLarge",
+ "__glXSwapRenderTable",
+ "__glXSwapRenderTable_EXT",
+ "__glXSwapSingleTable",
+ "__glXSwapSwapBuffers",
+ "__glXSwapUseXFont",
+ "__glXSwapVendorPrivTable_EXT",
+ "__glXSwapVendorPrivate",
+ "__glXSwapVendorPrivateWithReply",
+ "__glXSwapWaitGL",
+ "__glXSwapWaitX",
+ "__glXTexEnvfvReqSize",
+ "__glXTexEnvivReqSize",
+ "__glXTexGendvReqSize",
+ "__glXTexGenfvReqSize",
+ "__glXTexGenivReqSize",
+ "__glXTexImage1DReqSize",
+ "__glXTexImage2DReqSize",
+ "__glXTexImage3DReqSize",
+ "__glXTexParameterfvReqSize",
+ "__glXTexParameterivReqSize",
+ "__glXTexSubImage1DReqSize",
+ "__glXTexSubImage2DReqSize",
+ "__glXTexSubImage3DReqSize",
+ "__glXTypeSize",
+ "__glXUnrefDrawablePrivate",
+ "__glXUnsupportedPrivateRequest",
+ "__glXUseXFont",
+ "__glXVendorPrivTable_EXT",
+ "__glXVendorPrivate",
+ "__glXVendorPrivateWithReply",
+ "__glXWaitGL",
+ "__glXWaitX",
+ "__glXcombine_strings",
+ "glAccum",
+ "glActiveStencilFaceEXT",
+ "glActiveTextureARB",
+ "glAlphaFunc",
+ "glAreTexturesResident",
+ "glAreTexturesResidentEXT",
+ "glBegin",
+ "glBindTexture",
+ "glBitmap",
+ "glBlendColor",
+ "glBlendEquation",
+ "glBlendFunc",
+ "glCallList",
+ "glCallLists",
+ "glClear",
+ "glClearAccum",
+ "glClearColor",
+ "glClearDepth",
+ "glClearIndex",
+ "glClearStencil",
+ "glClipPlane",
+ "glColor3bv",
+ "glColor3dv",
+ "glColor3fv",
+ "glColor3iv",
+ "glColor3sv",
+ "glColor3ubv",
+ "glColor3uiv",
+ "glColor3usv",
+ "glColor4bv",
+ "glColor4dv",
+ "glColor4fv",
+ "glColor4iv",
+ "glColor4sv",
+ "glColor4ubv",
+ "glColor4uiv",
+ "glColor4usv",
+ "glColorMask",
+ "glColorMaterial",
+ "glColorPointer",
+ "glColorSubTable",
+ "glColorTable",
+ "glColorTableParameterfv",
+ "glColorTableParameteriv",
+ "glConvolutionFilter1D",
+ "glConvolutionFilter2D",
+ "glConvolutionParameterf",
+ "glConvolutionParameterfv",
+ "glConvolutionParameteri",
+ "glConvolutionParameteriv",
+ "glCopyColorSubTable",
+ "glCopyColorTable",
+ "glCopyConvolutionFilter1D",
+ "glCopyConvolutionFilter2D",
+ "glCopyPixels",
+ "glCopyTexImage1D",
+ "glCopyTexImage2D",
+ "glCopyTexSubImage1D",
+ "glCopyTexSubImage2D",
+ "glCopyTexSubImage3D",
+ "glCullFace",
+ "glDeleteLists",
+ "glDeleteTextures",
+ "glDeleteTexturesEXT",
+ "glDepthFunc",
+ "glDepthMask",
+ "glDepthRange",
+ "glDisable",
+ "glDisableClientState",
+ "glDrawArrays",
+ "glDrawBuffer",
+ "glDrawPixels",
+ "glEdgeFlagPointer",
+ "glEdgeFlagv",
+ "glEnable",
+ "glEnableClientState",
+ "glEnd",
+ "glEndList",
+ "glEvalCoord1dv",
+ "glEvalCoord1fv",
+ "glEvalCoord2dv",
+ "glEvalCoord2fv",
+ "glEvalMesh1",
+ "glEvalMesh2",
+ "glEvalPoint1",
+ "glEvalPoint2",
+ "glFeedbackBuffer",
+ "glFinish",
+ "glFlush",
+ "glFogf",
+ "glFogfv",
+ "glFogi",
+ "glFogiv",
+ "glFrontFace",
+ "glFrustum",
+ "glGenLists",
+ "glGenTextures",
+ "glGenTexturesEXT",
+ "glGetBooleanv",
+ "glGetClipPlane",
+ "glGetColorTable",
+ "glGetColorTableParameterfv",
+ "glGetColorTableParameteriv",
+ "glGetConvolutionFilter",
+ "glGetConvolutionParameterfv",
+ "glGetConvolutionParameteriv",
+ "glGetDoublev",
+ "glGetError",
+ "glGetFloatv",
+ "glGetHistogram",
+ "glGetHistogramParameterfv",
+ "glGetHistogramParameteriv",
+ "glGetIntegerv",
+ "glGetLightfv",
+ "glGetLightiv",
+ "glGetMapdv",
+ "glGetMapfv",
+ "glGetMapiv",
+ "glGetMaterialfv",
+ "glGetMaterialiv",
+ "glGetMinmax",
+ "glGetMinmaxParameterfv",
+ "glGetMinmaxParameteriv",
+ "glGetPixelMapfv",
+ "glGetPixelMapuiv",
+ "glGetPixelMapusv",
+ "glGetPolygonStipple",
+ "glGetSeparableFilter",
+ "glGetString",
+ "glGetTexEnvfv",
+ "glGetTexEnviv",
+ "glGetTexGendv",
+ "glGetTexGenfv",
+ "glGetTexGeniv",
+ "glGetTexImage",
+ "glGetTexLevelParameterfv",
+ "glGetTexLevelParameteriv",
+ "glGetTexParameterfv",
+ "glGetTexParameteriv",
+ "glHint",
+ "glHistogram",
+ "glIndexMask",
+ "glIndexPointer",
+ "glIndexdv",
+ "glIndexfv",
+ "glIndexiv",
+ "glIndexsv",
+ "glIndexubv",
+ "glInitNames",
+ "glIsEnabled",
+ "glIsList",
+ "glIsTexture",
+ "glIsTextureEXT",
+ "glLightModelf",
+ "glLightModelfv",
+ "glLightModeli",
+ "glLightModeliv",
+ "glLightf",
+ "glLightfv",
+ "glLighti",
+ "glLightiv",
+ "glLineStipple",
+ "glLineWidth",
+ "glListBase",
+ "glLoadIdentity",
+ "glLoadMatrixd",
+ "glLoadMatrixf",
+ "glLoadName",
+ "glLogicOp",
+ "glMap1d",
+ "glMap1f",
+ "glMap2d",
+ "glMap2f",
+ "glMapGrid1d",
+ "glMapGrid1f",
+ "glMapGrid2d",
+ "glMapGrid2f",
+ "glMaterialf",
+ "glMaterialfv",
+ "glMateriali",
+ "glMaterialiv",
+ "glMatrixMode",
+ "glMinmax",
+ "glMultMatrixd",
+ "glMultMatrixf",
+ "glMultiTexCoord1dvARB",
+ "glMultiTexCoord1fvARB",
+ "glMultiTexCoord1ivARB",
+ "glMultiTexCoord1svARB",
+ "glMultiTexCoord2dvARB",
+ "glMultiTexCoord2fvARB",
+ "glMultiTexCoord2ivARB",
+ "glMultiTexCoord2svARB",
+ "glMultiTexCoord3dvARB",
+ "glMultiTexCoord3fvARB",
+ "glMultiTexCoord3ivARB",
+ "glMultiTexCoord3svARB",
+ "glMultiTexCoord4dvARB",
+ "glMultiTexCoord4fvARB",
+ "glMultiTexCoord4ivARB",
+ "glMultiTexCoord4svARB",
+ "glNewList",
+ "glNormal3bv",
+ "glNormal3dv",
+ "glNormal3fv",
+ "glNormal3iv",
+ "glNormal3sv",
+ "glNormalPointer",
+ "glOrtho",
+ "glPassThrough",
+ "glPixelMapfv",
+ "glPixelMapuiv",
+ "glPixelMapusv",
+ "glPixelStoref",
+ "glPixelStorei",
+ "glPixelTransferf",
+ "glPixelTransferi",
+ "glPixelZoom",
+ "glPointParameterfARB",
+ "glPointParameterfvARB",
+ "glPointSize",
+ "glPolygonMode",
+ "glPolygonOffset",
+ "glPolygonStipple",
+ "glPopAttrib",
+ "glPopMatrix",
+ "glPopName",
+ "glPrioritizeTextures",
+ "glPushAttrib",
+ "glPushMatrix",
+ "glPushName",
+ "glRasterPos2dv",
+ "glRasterPos2fv",
+ "glRasterPos2iv",
+ "glRasterPos2sv",
+ "glRasterPos3dv",
+ "glRasterPos3fv",
+ "glRasterPos3iv",
+ "glRasterPos3sv",
+ "glRasterPos4dv",
+ "glRasterPos4fv",
+ "glRasterPos4iv",
+ "glRasterPos4sv",
+ "glReadBuffer",
+ "glReadPixels",
+ "glRectdv",
+ "glRectfv",
+ "glRectiv",
+ "glRectsv",
+ "glRenderMode",
+ "glResetHistogram",
+ "glResetMinmax",
+ "glRotated",
+ "glRotatef",
+ "glScaled",
+ "glScalef",
+ "glScissor",
+ "glSelectBuffer",
+ "glSeparableFilter2D",
+ "glShadeModel",
+ "glStencilFunc",
+ "glStencilMask",
+ "glStencilOp",
+ "glTexCoord1dv",
+ "glTexCoord1fv",
+ "glTexCoord1iv",
+ "glTexCoord1sv",
+ "glTexCoord2dv",
+ "glTexCoord2fv",
+ "glTexCoord2iv",
+ "glTexCoord2sv",
+ "glTexCoord3dv",
+ "glTexCoord3fv",
+ "glTexCoord3iv",
+ "glTexCoord3sv",
+ "glTexCoord4dv",
+ "glTexCoord4fv",
+ "glTexCoord4iv",
+ "glTexCoord4sv",
+ "glTexCoordPointer",
+ "glTexEnvf",
+ "glTexEnvfv",
+ "glTexEnvi",
+ "glTexEnviv",
+ "glTexGend",
+ "glTexGendv",
+ "glTexGenf",
+ "glTexGenfv",
+ "glTexGeni",
+ "glTexGeniv",
+ "glTexImage1D",
+ "glTexImage2D",
+ "glTexImage3D",
+ "glTexParameterf",
+ "glTexParameterfv",
+ "glTexParameteri",
+ "glTexParameteriv",
+ "glTexSubImage1D",
+ "glTexSubImage2D",
+ "glTexSubImage3D",
+ "glTranslated",
+ "glTranslatef",
+ "glVertex2dv",
+ "glVertex2fv",
+ "glVertex2iv",
+ "glVertex2sv",
+ "glVertex3dv",
+ "glVertex3fv",
+ "glVertex3iv",
+ "glVertex3sv",
+ "glVertex4dv",
+ "glVertex4fv",
+ "glVertex4iv",
+ "glVertex4sv",
+ "glVertexPointer",
+ "glViewport",
+ "glWindowPos3fARB",
+ "glxSwapQueryExtensionsStringReply",
+ "glxSwapQueryServerStringReply",
+ NULL
+};
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "glx",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_EXTENSION,
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_NONE,
+ {0,0,0,0}
+};
+
+XF86ModuleData glxModuleData = { &VersRec, glxSetup, NULL };
+
+static pointer
+glxSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+ pointer GLcore = NULL;
+#ifdef GLX_USE_SGI_SI
+ char GLcoreName[] = "GL";
+#else
+ char GLcoreName[] = "GLcore";
+#endif
+
+ if (!setupDone) {
+ setupDone = TRUE;
+
+ GLcore = LoadSubModule(module, GLcoreName, NULL, NULL, NULL, NULL,
+ errmaj, errmin);
+ if (!GLcore) {
+ if (errmaj) *errmaj = LDR_NOSUBENT;
+ } else {
+ LoaderReqSymLists(glcoreSymbols, NULL);
+ LoadExtension(&GLXExt, FALSE);
+ /* Wrap the init visuals routine in micmap.c */
+ GlxWrapInitVisuals(&miInitVisualsProc);
+ /* Make sure this gets wrapped each time InitVisualWrap is called */
+ miHookInitVisuals(NULL, GlxWrapInitVisuals);
+ }
+ } else {
+ if (errmaj) *errmaj = LDR_ONCEONLY;
+ }
+ /* Need a non-NULL return value to indicate success */
+ return GLcore;
+}
diff --git a/nx-X11/programs/Xserver/GL/include/GL/glx_ansic.h b/nx-X11/programs/Xserver/GL/include/GL/glx_ansic.h
new file mode 100644
index 000000000..c94393fd1
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/include/GL/glx_ansic.h
@@ -0,0 +1,115 @@
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _glx_ansic_h_
+#define _glx_ansic_h_
+
+/* $XFree86: xc/programs/Xserver/GL/include/GL/glx_ansic.h,v 1.5 2001/03/21 20:49:08 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+*/
+
+/*
+** this needs to check whether we're using XFree86 at all, and then
+** which version we're using. Use these macros if version is 3.9+, else
+** use normal commands below.
+*/
+
+/*
+** turns out this include file only exists for XFree86 3.9+
+** I notice that not having it is not an error and does not stop the build,
+** but having it will allow opengl and glx to be built for 3.9+. We no longer
+** need an explicit define in the Makefile, just point to the correct X source
+** tree and all should be taken care of.
+*/
+
+#ifdef XFree86Server
+
+#ifdef XFree86LOADER
+#include "xf86_ansic.h"
+#endif
+#ifndef assert
+#define assert(a)
+#endif
+
+#else
+
+#if defined(Lynx) && defined(__assert_h)
+#undef __assert_h
+#endif
+#ifdef assert
+#undef assert
+#endif
+#include <assert.h>
+
+#endif
+
+
+#define GLX_STDOUT stdout
+#define GLX_STDERR stderr
+#define __glXPrintf printf
+#define __glXFprintf fprintf
+#define __glXSprintf sprintf
+#define __glXVfprintf vfprintf
+#define __glXVsprintf vsprintf
+#define __glXFopen fopen
+#define __glXFclose fclose
+#define __glXCos(x) cos(x)
+#define __glXSin(x) sin(x)
+#define __glXAtan(x) atan(x)
+#define __glXAbs(x) abs(x)
+#define __glXLog(x) log(x)
+#define __glXCeil(x) ceil(x)
+#define __glXFloor(x) floor(x)
+#define __glXSqrt(x) sqrt(x)
+#define __glXPow(x, y) pow(x, y)
+#define __glXMemmove(dest, src, n) memmove(dest, src, n)
+#define __glXMemcpy(dest, src, n) memcpy(dest, src, n)
+#define __glXMemset(s, c, n) memset(s, c, n)
+#define __glXStrdup(str) xstrdup(str)
+#define __glXStrcpy(dest, src) strcpy(dest, src)
+#define __glXStrncpy(dest, src, n) strncpy(dest, src, n)
+#define __glXStrcat(dest, src) strcat(dest, src)
+#define __glXStrncat(dest, src, n) strncat(dest, src, n)
+#define __glXStrcmp(s1, s2) strcmp(s1, s2)
+#define __glXStrncmp(s1, s2, n) strncmp(s1, s2, n)
+#define __glXStrlen(str) strlen(str)
+#define __glXAbort() abort()
+#define __glXStrtok(s, delim) strtok(s, delim)
+#define __glXStrcspn(s, reject) strcspn(s, reject)
+#define __glXGetenv(a) getenv(a)
+#define __glXAtoi(a) atoi(a)
+
+#endif /* _glx_ansic_h_ */
+
diff --git a/nx-X11/programs/Xserver/GL/include/GL/xf86glx.h b/nx-X11/programs/Xserver/GL/include/GL/xf86glx.h
new file mode 100644
index 000000000..66f096a98
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/include/GL/xf86glx.h
@@ -0,0 +1,43 @@
+/* $XFree86: xc/programs/Xserver/GL/include/GL/xf86glx.h,v 1.3 1999/06/14 07:31:41 dawes Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "miscstruct.h"
+
+#ifdef XFree86LOADER
+#include "xf86_ansic.h"
+#endif
diff --git a/nx-X11/programs/Xserver/GL/mesa/GLcore/GLcore-def.cpp b/nx-X11/programs/Xserver/GL/mesa/GLcore/GLcore-def.cpp
new file mode 100644
index 000000000..6fca465cd
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/GLcore/GLcore-def.cpp
@@ -0,0 +1,1462 @@
+LIBRARY GLcore
+VERSION LIBRARY_VERSION
+EXPORTS
+
+_mesa_set_aa_triangle_function
+_mesa_Accum
+_mesa_ClearAccum
+_mesa_alloc_accum_buffer
+_mesa_clear_accum_buffer
+_mesa_AlphaFunc
+_mesa_alpha_test
+_mesa_alloc_alpha_buffers
+_mesa_clear_alpha_buffers
+_mesa_read_alpha_pixels
+_mesa_read_alpha_span
+_mesa_write_alpha_pixels
+_mesa_write_alpha_span
+_mesa_write_mono_alpha_pixels
+_mesa_write_mono_alpha_span
+_mesa_PopAttrib
+_mesa_PopClientAttrib
+_mesa_PushAttrib
+_mesa_PushClientAttrib
+_mesa_Bitmap
+_mesa_BlendColor
+_mesa_BlendEquation
+_mesa_BlendFunc
+_mesa_BlendFuncSeparateEXT
+_mesa_blend_pixels
+_mesa_blend_span
+_mesa_Clear
+_mesa_ClearColor
+_mesa_ClearIndex
+_mesa_DrawBuffer
+_mesa_ReadBuffer
+_mesa_ResizeBuffersMESA
+_mesa_ClipPlane
+_mesa_GetClipPlane
+gl_init_clip
+gl_update_clipmask
+gl_update_userclip
+gl_user_cliptest
+gl_userclip_point
+gl_viewclip_point
+_mesa_ColorSubTable
+_mesa_ColorTable
+_mesa_ColorTableParameterfv
+_mesa_ColorTableParameteriv
+_mesa_CopyColorSubTable
+_mesa_CopyColorTable
+_mesa_GetColorTable
+_mesa_GetColorTableParameterfv
+_mesa_GetColorTableParameteriv
+_mesa_free_colortable_data
+_mesa_init_colortable
+gl_read_config_file
+gl_register_config_var
+_mesa_Finish
+_mesa_Flush
+_mesa_create_visual
+_mesa_destroy_visual
+_mesa_get_dispatch
+_mesa_initialize_context
+_mesa_initialize_framebuffer
+_mesa_initialize_visual
+_mesa_swapbuffers
+gl_compile_error
+gl_context_initialize
+gl_copy_context
+gl_create_context
+gl_create_framebuffer
+gl_create_visual
+gl_destroy_context
+gl_destroy_framebuffer
+gl_destroy_visual
+gl_error
+gl_free_context_data
+gl_get_current_context
+gl_make_current
+gl_make_current2
+gl_problem
+gl_warning
+_mesa_CopyPixels
+_mesa_LockArraysEXT
+_mesa_UnlockArraysEXT
+gl_alloc_cva_store
+gl_cva_compile_cassette
+gl_cva_force_precalc
+gl_cva_init
+gl_free_cva_store
+gl_merge_cva
+gl_prepare_arrays_cva
+gl_rescue_cva
+_mesa_ClearDepth
+_mesa_DepthFunc
+_mesa_DepthMask
+_mesa_alloc_depth_buffer
+_mesa_clear_depth_buffer
+_mesa_depth_test_pixels
+_mesa_depth_test_span
+_mesa_read_depth_span
+_mesa_read_depth_span_float
+_mesa_zbuffer_address
+glAccum
+glActiveTextureARB
+glAlphaFunc
+glAreTexturesResident
+glAreTexturesResidentEXT
+glArrayElement
+glArrayElementEXT
+glBegin
+glBindTexture
+glBindTextureEXT
+glBitmap
+glBlendColor
+glBlendColorEXT
+glBlendEquation
+glBlendEquationEXT
+glBlendFunc
+glBlendFuncSeparateEXT
+glBlendFuncSeparateINGR
+glCallList
+glCallLists
+glClear
+glClearAccum
+glClearColor
+glClearDepth
+glClearIndex
+glClearStencil
+glClientActiveTextureARB
+glClipPlane
+glColor3b
+glColor3bv
+glColor3d
+glColor3dv
+glColor3f
+glColor3fv
+glColor3i
+glColor3iv
+glColor3s
+glColor3sv
+glColor3ub
+glColor3ubv
+glColor3ui
+glColor3uiv
+glColor3us
+glColor3usv
+glColor4b
+glColor4bv
+glColor4d
+glColor4dv
+glColor4f
+glColor4fv
+glColor4i
+glColor4iv
+glColor4s
+glColor4sv
+glColor4ub
+glColor4ubv
+glColor4ui
+glColor4uiv
+glColor4us
+glColor4usv
+glColorMask
+glColorMaterial
+glColorPointer
+glColorPointerEXT
+glColorSubTable
+glColorSubTableEXT
+glColorTable
+glColorTableEXT
+glColorTableParameterfv
+glColorTableParameterfvSGI
+glColorTableParameteriv
+glColorTableParameterivSGI
+glColorTableSGI
+glCombinerInputNV
+glCombinerOutputNV
+glCombinerParameterfNV
+glCombinerParameterfvNV
+glCombinerParameteriNV
+glCombinerParameterivNV
+glCompressedTexImage1DARB
+glCompressedTexImage2DARB
+glCompressedTexImage3DARB
+glCompressedTexSubImage1DARB
+glCompressedTexSubImage2DARB
+glCompressedTexSubImage3DARB
+glConvolutionFilter1D
+glConvolutionFilter1DEXT
+glConvolutionFilter2D
+glConvolutionFilter2DEXT
+glConvolutionParameterf
+glConvolutionParameterfEXT
+glConvolutionParameterfv
+glConvolutionParameterfvEXT
+glConvolutionParameteri
+glConvolutionParameteriEXT
+glConvolutionParameteriv
+glConvolutionParameterivEXT
+glCopyColorSubTable
+glCopyColorSubTableEXT
+glCopyColorTable
+glCopyColorTableSGI
+glCopyConvolutionFilter1D
+glCopyConvolutionFilter1DEXT
+glCopyConvolutionFilter2D
+glCopyConvolutionFilter2DEXT
+glCopyPixels
+glCopyTexImage1D
+glCopyTexImage1DEXT
+glCopyTexImage2D
+glCopyTexImage2DEXT
+glCopyTexSubImage1D
+glCopyTexSubImage1DEXT
+glCopyTexSubImage2D
+glCopyTexSubImage2DEXT
+glCopyTexSubImage3D
+glCopyTexSubImage3DEXT
+glCullFace
+glCullParameterdvEXT
+glCullParameterfvEXT
+glDeleteLists
+glDeleteTextures
+glDeleteTexturesEXT
+glDepthFunc
+glDepthMask
+glDepthRange
+glDetailTexFuncSGIS
+glDisable
+glDisableClientState
+glDrawArrays
+glDrawArraysEXT
+glDrawBuffer
+glDrawElements
+glDrawPixels
+glDrawRangeElements
+glDrawRangeElementsEXT
+glEdgeFlag
+glEdgeFlagPointer
+glEdgeFlagPointerEXT
+glEdgeFlagv
+glEnable
+glEnableClientState
+glEnd
+glEndList
+glEvalCoord1d
+glEvalCoord1dv
+glEvalCoord1f
+glEvalCoord1fv
+glEvalCoord2d
+glEvalCoord2dv
+glEvalCoord2f
+glEvalCoord2fv
+glEvalMesh1
+glEvalMesh2
+glEvalPoint1
+glEvalPoint2
+glFeedbackBuffer
+glFinalCombinerInputNV
+glFinish
+glFlush
+glFlushRasterSGIX
+glFlushVertexArrayRangeNV
+glFogCoordPointerEXT
+glFogCoorddEXT
+glFogCoorddvEXT
+glFogCoordfEXT
+glFogCoordfvEXT
+glFogf
+glFogfv
+glFogi
+glFogiv
+glFragmentColorMaterialSGIX
+glFragmentLightModelfSGIX
+glFragmentLightModelfvSGIX
+glFragmentLightModeliSGIX
+glFragmentLightModelivSGIX
+glFragmentLightfSGIX
+glFragmentLightfvSGIX
+glFragmentLightiSGIX
+glFragmentLightivSGIX
+glFragmentMaterialfSGIX
+glFragmentMaterialfvSGIX
+glFragmentMaterialiSGIX
+glFragmentMaterialivSGIX
+glFrameZoomSGIX
+glFrontFace
+glFrustum
+glGenLists
+glGenTextures
+glGenTexturesEXT
+glGetBooleanv
+glGetClipPlane
+glGetColorTable
+glGetColorTableEXT
+glGetColorTableParameterfv
+glGetColorTableParameterfvEXT
+glGetColorTableParameterfvSGI
+glGetColorTableParameteriv
+glGetColorTableParameterivEXT
+glGetColorTableParameterivSGI
+glGetColorTableSGI
+glGetCombinerInputParameterfvNV
+glGetCombinerInputParameterivNV
+glGetCombinerOutputParameterfvNV
+glGetCombinerOutputParameterivNV
+glGetCompressedTexImageARB
+glGetConvolutionFilter
+glGetConvolutionFilterEXT
+glGetConvolutionParameterfv
+glGetConvolutionParameterfvEXT
+glGetConvolutionParameteriv
+glGetConvolutionParameterivEXT
+glGetDetailTexFuncSGIS
+glGetDoublev
+glGetError
+glGetFinalCombinerInputParameterfvNV
+glGetFinalCombinerInputParameterivNV
+glGetFloatv
+glGetFragmentLightfvSGIX
+glGetFragmentLightivSGIX
+glGetFragmentMaterialfvSGIX
+glGetFragmentMaterialivSGIX
+glGetHistogram
+glGetHistogramEXT
+glGetHistogramParameterfv
+glGetHistogramParameterfvEXT
+glGetHistogramParameteriv
+glGetHistogramParameterivEXT
+glGetInstrumentsSGIX
+glGetIntegerv
+glGetLightfv
+glGetLightiv
+glGetListParameterfvSGIX
+glGetListParameterivSGIX
+glGetMapdv
+glGetMapfv
+glGetMapiv
+glGetMaterialfv
+glGetMaterialiv
+glGetMinmax
+glGetMinmaxEXT
+glGetMinmaxParameterfv
+glGetMinmaxParameterfvEXT
+glGetMinmaxParameteriv
+glGetMinmaxParameterivEXT
+glGetPixelMapfv
+glGetPixelMapuiv
+glGetPixelMapusv
+glGetPixelTexGenParameterfvSGIS
+glGetPixelTexGenParameterivSGIS
+glGetPointerv
+glGetPointervEXT
+glGetPolygonStipple
+glGetSeparableFilter
+glGetSeparableFilterEXT
+glGetSharpenTexFuncSGIS
+glGetString
+glGetTexEnvfv
+glGetTexEnviv
+glGetTexFilterFuncSGIS
+glGetTexGendv
+glGetTexGenfv
+glGetTexGeniv
+glGetTexImage
+glGetTexLevelParameterfv
+glGetTexLevelParameteriv
+glGetTexParameterfv
+glGetTexParameteriv
+glHint
+glHintPGI
+glHistogram
+glHistogramEXT
+glIndexFuncEXT
+glIndexMask
+glIndexMaterialEXT
+glIndexPointer
+glIndexPointerEXT
+glIndexd
+glIndexdv
+glIndexf
+glIndexfv
+glIndexi
+glIndexiv
+glIndexs
+glIndexsv
+glIndexub
+glIndexubv
+glInitNames
+glInstrumentsBufferSGIX
+glInterleavedArrays
+glIsEnabled
+glIsList
+glIsTexture
+glIsTextureEXT
+glLightEnviSGIX
+glLightModelf
+glLightModelfv
+glLightModeli
+glLightModeliv
+glLightf
+glLightfv
+glLighti
+glLightiv
+glLineStipple
+glLineWidth
+glListBase
+glListParameterfSGIX
+glListParameterfvSGIX
+glListParameteriSGIX
+glListParameterivSGIX
+glLoadIdentity
+glLoadMatrixd
+glLoadMatrixf
+glLoadName
+glLoadTransposeMatrixdARB
+glLoadTransposeMatrixfARB
+glLockArraysEXT
+glLogicOp
+glMap1d
+glMap1f
+glMap2d
+glMap2f
+glMapGrid1d
+glMapGrid1f
+glMapGrid2d
+glMapGrid2f
+glMaterialf
+glMaterialfv
+glMateriali
+glMaterialiv
+glMatrixMode
+glMinmax
+glMinmaxEXT
+glMultMatrixd
+glMultMatrixf
+glMultTransposeMatrixdARB
+glMultTransposeMatrixfARB
+glMultiTexCoord1dARB
+glMultiTexCoord1dvARB
+glMultiTexCoord1fARB
+glMultiTexCoord1fvARB
+glMultiTexCoord1iARB
+glMultiTexCoord1ivARB
+glMultiTexCoord1sARB
+glMultiTexCoord1svARB
+glMultiTexCoord2dARB
+glMultiTexCoord2dvARB
+glMultiTexCoord2fARB
+glMultiTexCoord2fvARB
+glMultiTexCoord2iARB
+glMultiTexCoord2ivARB
+glMultiTexCoord2sARB
+glMultiTexCoord2svARB
+glMultiTexCoord3dARB
+glMultiTexCoord3dvARB
+glMultiTexCoord3fARB
+glMultiTexCoord3fvARB
+glMultiTexCoord3iARB
+glMultiTexCoord3ivARB
+glMultiTexCoord3sARB
+glMultiTexCoord3svARB
+glMultiTexCoord4dARB
+glMultiTexCoord4dvARB
+glMultiTexCoord4fARB
+glMultiTexCoord4fvARB
+glMultiTexCoord4iARB
+glMultiTexCoord4ivARB
+glMultiTexCoord4sARB
+glMultiTexCoord4svARB
+glNewList
+glNormal3b
+glNormal3bv
+glNormal3d
+glNormal3dv
+glNormal3f
+glNormal3fv
+glNormal3i
+glNormal3iv
+glNormal3s
+glNormal3sv
+glNormalPointer
+glNormalPointerEXT
+glOrtho
+glPassThrough
+glPixelMapfv
+glPixelMapuiv
+glPixelMapusv
+glPixelStoref
+glPixelStorei
+glPixelTexGenParameterfSGIS
+glPixelTexGenParameterfvSGIS
+glPixelTexGenParameteriSGIS
+glPixelTexGenParameterivSGIS
+glPixelTexGenSGIX
+glPixelTransferf
+glPixelTransferi
+glPixelZoom
+glPointParameterfEXT
+glPointParameterfSGIS
+glPointParameterfvEXT
+glPointParameterfvSGIS
+glPointSize
+glPollInstrumentsSGIX
+glPolygonMode
+glPolygonOffset
+glPolygonOffsetEXT
+glPolygonStipple
+glPopAttrib
+glPopClientAttrib
+glPopMatrix
+glPopName
+glPrioritizeTextures
+glPrioritizeTexturesEXT
+glPushAttrib
+glPushClientAttrib
+glPushMatrix
+glPushName
+glRasterPos2d
+glRasterPos2dv
+glRasterPos2f
+glRasterPos2fv
+glRasterPos2i
+glRasterPos2iv
+glRasterPos2s
+glRasterPos2sv
+glRasterPos3d
+glRasterPos3dv
+glRasterPos3f
+glRasterPos3fv
+glRasterPos3i
+glRasterPos3iv
+glRasterPos3s
+glRasterPos3sv
+glRasterPos4d
+glRasterPos4dv
+glRasterPos4f
+glRasterPos4fv
+glRasterPos4i
+glRasterPos4iv
+glRasterPos4s
+glRasterPos4sv
+glReadBuffer
+glReadInstrumentsSGIX
+glReadPixels
+glRectd
+glRectdv
+glRectf
+glRectfv
+glRecti
+glRectiv
+glRects
+glRectsv
+glReferencePlaneSGIX
+glRenderMode
+glResetHistogram
+glResetHistogramEXT
+glResetMinmax
+glResetMinmaxEXT
+glResizeBuffersMESA
+glRotated
+glRotatef
+glSampleCoverageARB
+glSampleMaskEXT
+glSampleMaskSGIS
+glSamplePassARB
+glSamplePatternEXT
+glSamplePatternSGIS
+glScaled
+glScalef
+glScissor
+glSelectBuffer
+glSeparableFilter2D
+glSeparableFilter2DEXT
+glShadeModel
+glSharpenTexFuncSGIS
+glSpriteParameterfSGIX
+glSpriteParameterfvSGIX
+glSpriteParameteriSGIX
+glSpriteParameterivSGIX
+glStartInstrumentsSGIX
+glStencilFunc
+glStencilMask
+glStencilOp
+glStopInstrumentsSGIX
+glTagSampleBufferSGIX
+glTbufferMask3DFX
+glTexCoord1d
+glTexCoord1dv
+glTexCoord1f
+glTexCoord1fv
+glTexCoord1i
+glTexCoord1iv
+glTexCoord1s
+glTexCoord1sv
+glTexCoord2d
+glTexCoord2dv
+glTexCoord2f
+glTexCoord2fv
+glTexCoord2i
+glTexCoord2iv
+glTexCoord2s
+glTexCoord2sv
+glTexCoord3d
+glTexCoord3dv
+glTexCoord3f
+glTexCoord3fv
+glTexCoord3i
+glTexCoord3iv
+glTexCoord3s
+glTexCoord3sv
+glTexCoord4d
+glTexCoord4dv
+glTexCoord4f
+glTexCoord4fv
+glTexCoord4i
+glTexCoord4iv
+glTexCoord4s
+glTexCoord4sv
+glTexCoordPointer
+glTexCoordPointerEXT
+glTexEnvf
+glTexEnvfv
+glTexEnvi
+glTexEnviv
+glTexFilterFuncSGIS
+glTexGend
+glTexGendv
+glTexGenf
+glTexGenfv
+glTexGeni
+glTexGeniv
+glTexImage1D
+glTexImage2D
+glTexImage3D
+glTexImage3DEXT
+glTexImage4DSGIS
+glTexParameterf
+glTexParameterfv
+glTexParameteri
+glTexParameteriv
+glTexSubImage1D
+glTexSubImage1DEXT
+glTexSubImage2D
+glTexSubImage2DEXT
+glTexSubImage3D
+glTexSubImage3DEXT
+glTexSubImage4DSGIS
+glTranslated
+glTranslatef
+glUnlockArraysEXT
+glVertex2d
+glVertex2dv
+glVertex2f
+glVertex2fv
+glVertex2i
+glVertex2iv
+glVertex2s
+glVertex2sv
+glVertex3d
+glVertex3dv
+glVertex3f
+glVertex3fv
+glVertex3i
+glVertex3iv
+glVertex3s
+glVertex3sv
+glVertex4d
+glVertex4dv
+glVertex4f
+glVertex4fv
+glVertex4i
+glVertex4iv
+glVertex4s
+glVertex4sv
+glVertexArrayRangeNV
+glVertexPointer
+glVertexPointerEXT
+glVertexWeightPointerEXT
+glVertexWeightfEXT
+glVertexWeightfvEXT
+glViewport
+glWindowPos2dMESA
+glWindowPos2dvMESA
+glWindowPos2fMESA
+glWindowPos2fvMESA
+glWindowPos2iMESA
+glWindowPos2ivMESA
+glWindowPos2sMESA
+glWindowPos2svMESA
+glWindowPos3dMESA
+glWindowPos3dvMESA
+glWindowPos3fMESA
+glWindowPos3fvMESA
+glWindowPos3iMESA
+glWindowPos3ivMESA
+glWindowPos3sMESA
+glWindowPos3svMESA
+glWindowPos4dMESA
+glWindowPos4dvMESA
+glWindowPos4fMESA
+glWindowPos4fvMESA
+glWindowPos4iMESA
+glWindowPos4ivMESA
+glWindowPos4sMESA
+glWindowPos4svMESA
+_mesa_CallList
+_mesa_CallLists
+_mesa_DeleteLists
+_mesa_EndList
+_mesa_GenLists
+_mesa_IsList
+_mesa_ListBase
+_mesa_NewList
+_mesa_init_dlist_table
+gl_compile_cassette
+gl_destroy_list
+gl_init_lists
+gl_save_error
+mesa_print_display_list
+_mesa_DrawPixels
+_mesa_clip_pixelrect
+_mesa_Disable
+_mesa_DisableClientState
+_mesa_Enable
+_mesa_EnableClientState
+_mesa_IsEnabled
+_mesa_set_enable
+gl_lookup_enum_by_name
+gl_lookup_enum_by_nr
+_mesa_EvalCoord1d
+_mesa_EvalCoord1dv
+_mesa_EvalCoord1f
+_mesa_EvalCoord1fv
+_mesa_EvalCoord2d
+_mesa_EvalCoord2dv
+_mesa_EvalCoord2f
+_mesa_EvalCoord2fv
+_mesa_EvalMesh1
+_mesa_EvalMesh2
+_mesa_EvalPoint1
+_mesa_EvalPoint2
+_mesa_GetMapdv
+_mesa_GetMapfv
+_mesa_GetMapiv
+_mesa_Map1d
+_mesa_Map1f
+_mesa_Map2d
+_mesa_Map2f
+_mesa_MapGrid1d
+_mesa_MapGrid1f
+_mesa_MapGrid2d
+_mesa_MapGrid2f
+_mesa_evaluator_components
+gl_copy_map_points1d
+gl_copy_map_points1f
+gl_copy_map_points2d
+gl_copy_map_points2f
+gl_eval_vb
+gl_init_eval
+gl_extension_is_enabled
+gl_extensions_add
+gl_extensions_ctr
+gl_extensions_disable
+gl_extensions_dtr
+gl_extensions_enable
+gl_extensions_get_string
+_mesa_FeedbackBuffer
+_mesa_InitNames
+_mesa_LoadName
+_mesa_PassThrough
+_mesa_PopName
+_mesa_PushName
+_mesa_RenderMode
+_mesa_SelectBuffer
+gl_feedback_line
+gl_feedback_points
+gl_feedback_triangle
+gl_feedback_vertex
+gl_select_line
+gl_select_points
+gl_select_triangle
+gl_update_hitflag
+_mesa_Fogf
+_mesa_Fogfv
+_mesa_Fogi
+_mesa_Fogiv
+_mesa_fog_ci_pixels
+_mesa_fog_rgba_pixels
+_mesa_fog_vertices
+_mesa_init_fog
+_mesa_GetBooleanv
+_mesa_GetDoublev
+_mesa_GetError
+_mesa_GetFloatv
+_mesa_GetIntegerv
+_mesa_GetPointerv
+_mesa_GetString
+_glapi_add_entrypoint
+_glapi_check_multithread
+_glapi_check_table
+_glapi_get_context
+_glapi_get_dispatch
+_glapi_get_dispatch_table_size
+_glapi_get_proc_address
+_glapi_get_proc_name
+_glapi_get_proc_offset
+_glapi_get_version
+_glapi_set_context
+_glapi_set_dispatch
+_glapi_noop_enable_warnings
+_glthread_GetID
+_glthread_GetTSD
+_glthread_InitTSD
+_glthread_SetTSD
+_mesa_DeleteHashTable
+_mesa_HashFindFreeKeyBlock
+_mesa_HashFirstEntry
+_mesa_HashInsert
+_mesa_HashLookup
+_mesa_HashPrint
+_mesa_HashRemove
+_mesa_NewHashTable
+_mesa_Hint
+_mesa_HintPGI
+_mesa_try_Hint
+_mesa_bytes_per_pixel
+_mesa_components_in_format
+_mesa_image_address
+_mesa_image_row_stride
+_mesa_is_legal_format_and_type
+_mesa_native_packing
+_mesa_pack_bitmap
+_mesa_pack_polygon_stipple
+_mesa_pack_rgba_span
+_mesa_sizeof_packed_type
+_mesa_sizeof_type
+_mesa_swap2
+_mesa_swap4
+_mesa_unpack_bitmap
+_mesa_unpack_depth_span
+_mesa_unpack_float_color_span
+_mesa_unpack_image
+_mesa_unpack_index_span
+_mesa_unpack_polygon_stipple
+_mesa_unpack_stencil_span
+_mesa_unpack_ubyte_color_span
+_mesa_ConvolutionFilter1D
+_mesa_ConvolutionFilter2D
+_mesa_ConvolutionParameterf
+_mesa_ConvolutionParameterfv
+_mesa_ConvolutionParameteri
+_mesa_ConvolutionParameteriv
+_mesa_CopyConvolutionFilter1D
+_mesa_CopyConvolutionFilter2D
+_mesa_GetConvolutionFilter
+_mesa_GetConvolutionParameterfv
+_mesa_GetConvolutionParameteriv
+_mesa_GetHistogram
+_mesa_GetHistogramParameterfv
+_mesa_GetHistogramParameteriv
+_mesa_GetMinmax
+_mesa_GetMinmaxParameterfv
+_mesa_GetMinmaxParameteriv
+_mesa_GetSeparableFilter
+_mesa_Histogram
+_mesa_Minmax
+_mesa_ResetHistogram
+_mesa_ResetMinmax
+_mesa_SeparableFilter2D
+_mesa_update_histogram
+_mesa_update_minmax
+_mesa_ColorMaterial
+_mesa_GetLightfv
+_mesa_GetLightiv
+_mesa_GetMaterialfv
+_mesa_GetMaterialiv
+_mesa_LightModelf
+_mesa_LightModelfv
+_mesa_LightModeli
+_mesa_LightModeliv
+_mesa_Lightf
+_mesa_Lightfv
+_mesa_Lighti
+_mesa_Lightiv
+_mesa_Materialf
+_mesa_Materialfv
+_mesa_Materiali
+_mesa_Materialiv
+_mesa_ShadeModel
+gl_compute_light_positions
+gl_compute_shine_table
+gl_compute_spot_exp_table
+gl_material_bitmask
+gl_update_color_material
+gl_update_lighting
+gl_update_material
+gl_update_normal_transform
+_mesa_LineStipple
+_mesa_LineWidth
+gl_set_line_function
+_mesa_LogicOp
+_mesa_logicop_ci_pixels
+_mesa_logicop_ci_span
+_mesa_logicop_rgba_pixels
+_mesa_logicop_rgba_span
+_mesa_ColorMask
+_mesa_IndexMask
+_mesa_mask_index_pixels
+_mesa_mask_index_span
+_mesa_mask_rgba_pixels
+_mesa_mask_rgba_span
+_mesa_DepthRange
+_mesa_Frustum
+_mesa_LoadIdentity
+_mesa_LoadMatrixd
+_mesa_LoadMatrixf
+_mesa_LoadTransposeMatrixdARB
+_mesa_LoadTransposeMatrixfARB
+_mesa_MatrixMode
+_mesa_MultMatrixd
+_mesa_MultMatrixf
+_mesa_MultTransposeMatrixdARB
+_mesa_MultTransposeMatrixfARB
+_mesa_Ortho
+_mesa_PopMatrix
+_mesa_PushMatrix
+_mesa_Rotated
+_mesa_Rotatef
+_mesa_Scaled
+_mesa_Scalef
+_mesa_Translated
+_mesa_Translatef
+_mesa_Viewport
+gl_Viewport
+gl_calculate_model_project_matrix
+gl_mat_mul_floats
+gl_mat_mul_mat
+gl_matrix_alloc_inv
+gl_matrix_analyze
+gl_matrix_copy
+gl_matrix_ctr
+gl_matrix_dtr
+gl_matrix_invert
+gl_matrix_mul
+gl_matrix_transposed
+gl_matrix_transposef
+gl_print_matrix
+gl_rotation_matrix
+_mesa_calloc
+_mesa_free
+_mesa_malloc
+_mesa_bitcount
+_mesa_init_math
+gl_sqrt
+gl_alloc_pb
+gl_flush_pb
+gl_build_immediate_pipeline
+gl_build_precalc_pipeline
+gl_pipeline_init
+gl_print_active_pipeline
+gl_print_pipe_ops
+gl_print_pipeline
+gl_print_tri_caps
+gl_print_vert_flags
+gl_reset_cva_vb
+gl_run_pipeline
+gl_update_pipelines
+_mesa_GetPixelMapfv
+_mesa_GetPixelMapuiv
+_mesa_GetPixelMapusv
+_mesa_PixelMapfv
+_mesa_PixelMapuiv
+_mesa_PixelMapusv
+_mesa_PixelStoref
+_mesa_PixelStorei
+_mesa_PixelTransferf
+_mesa_PixelTransferi
+_mesa_PixelZoom
+_mesa_lookup_rgba
+_mesa_map_ci
+_mesa_map_ci8_to_rgba
+_mesa_map_ci_to_rgba
+_mesa_map_ci_to_rgba_ubyte
+_mesa_map_rgba
+_mesa_map_stencil
+_mesa_scale_and_bias_rgba
+_mesa_shift_and_offset_ci
+_mesa_shift_and_offset_stencil
+_mesa_transform_rgba
+_mesa_GetPixelTexGenParameterfvSGIS
+_mesa_GetPixelTexGenParameterivSGIS
+_mesa_PixelTexGenParameterfSGIS
+_mesa_PixelTexGenParameterfvSGIS
+_mesa_PixelTexGenParameteriSGIS
+_mesa_PixelTexGenParameterivSGIS
+_mesa_PixelTexGenSGIX
+_mesa_pixeltexgen
+_mesa_PointParameterfEXT
+_mesa_PointParameterfvEXT
+_mesa_PointSize
+gl_set_point_function
+_mesa_CullFace
+_mesa_FrontFace
+_mesa_GetPolygonStipple
+_mesa_PolygonMode
+_mesa_PolygonOffset
+_mesa_PolygonOffsetEXT
+_mesa_PolygonStipple
+gl_set_quad_function
+_mesa_RasterPos2d
+_mesa_RasterPos2dv
+_mesa_RasterPos2f
+_mesa_RasterPos2fv
+_mesa_RasterPos2i
+_mesa_RasterPos2iv
+_mesa_RasterPos2s
+_mesa_RasterPos2sv
+_mesa_RasterPos3d
+_mesa_RasterPos3dv
+_mesa_RasterPos3f
+_mesa_RasterPos3fv
+_mesa_RasterPos3i
+_mesa_RasterPos3iv
+_mesa_RasterPos3s
+_mesa_RasterPos3sv
+_mesa_RasterPos4d
+_mesa_RasterPos4dv
+_mesa_RasterPos4f
+_mesa_RasterPos4fv
+_mesa_RasterPos4i
+_mesa_RasterPos4iv
+_mesa_RasterPos4s
+_mesa_RasterPos4sv
+_mesa_ReadPixels
+_mesa_Rectd
+_mesa_Rectdv
+_mesa_Rectf
+_mesa_Rectfv
+_mesa_Recti
+_mesa_Rectiv
+_mesa_Rects
+_mesa_Rectsv
+_mesa_Scissor
+gl_scissor_pixels
+gl_scissor_span
+gl_init_shade
+gl_shade_rastpos
+gl_update_lighting_function
+gl_read_index_span
+gl_read_rgba_span
+gl_write_index_span
+gl_write_monocolor_span
+gl_write_monoindex_span
+gl_write_multitexture_span
+gl_write_rgba_span
+gl_write_texture_span
+gl_clean_color
+gl_default_nr_stages
+gl_default_pipeline
+gl_import_client_data
+gl_init_vbxform
+gl_update_materials
+_mesa_init_exec_table
+_mesa_init_no_op_table
+gl_print_enable_flags
+gl_print_state
+gl_update_state
+_mesa_ClearStencil
+_mesa_StencilFunc
+_mesa_StencilMask
+_mesa_StencilOp
+_mesa_alloc_stencil_buffer
+_mesa_clear_stencil_buffer
+_mesa_read_stencil_span
+_mesa_stencil_and_ztest_pixels
+_mesa_stencil_and_ztest_span
+_mesa_write_stencil_span
+_mesa_CompressedTexImage1DARB
+_mesa_CompressedTexImage2DARB
+_mesa_CompressedTexImage3DARB
+_mesa_CompressedTexSubImage1DARB
+_mesa_CompressedTexSubImage2DARB
+_mesa_CompressedTexSubImage3DARB
+_mesa_CopyTexImage1D
+_mesa_CopyTexImage2D
+_mesa_CopyTexSubImage1D
+_mesa_CopyTexSubImage2D
+_mesa_CopyTexSubImage3D
+_mesa_GetCompressedTexImageARB
+_mesa_GetTexImage
+_mesa_TexImage1D
+_mesa_TexImage2D
+_mesa_TexImage3D
+_mesa_TexImage3DEXT
+_mesa_TexSubImage1D
+_mesa_TexSubImage2D
+_mesa_TexSubImage3D
+_mesa_alloc_texture_image
+_mesa_base_tex_format
+_mesa_compressed_image_size
+_mesa_free_texture_image
+_mesa_get_teximage_from_driver
+_mesa_select_tex_image
+_mesa_select_tex_object
+_mesa_AreTexturesResident
+_mesa_BindTexture
+_mesa_DeleteTextures
+_mesa_GenTextures
+_mesa_IsTexture
+_mesa_PrioritizeTextures
+_mesa_test_texobj_completeness
+gl_alloc_texture_object
+gl_free_texture_object
+_mesa_ActiveTextureARB
+_mesa_ClientActiveTextureARB
+_mesa_GetTexEnvfv
+_mesa_GetTexEnviv
+_mesa_GetTexGendv
+_mesa_GetTexGenfv
+_mesa_GetTexGeniv
+_mesa_GetTexLevelParameterfv
+_mesa_GetTexLevelParameteriv
+_mesa_GetTexParameterfv
+_mesa_GetTexParameteriv
+_mesa_TexEnvf
+_mesa_TexEnvfv
+_mesa_TexEnvi
+_mesa_TexEnviv
+_mesa_TexGend
+_mesa_TexGendv
+_mesa_TexGenf
+_mesa_TexGenfv
+_mesa_TexGeni
+_mesa_TexGeniv
+_mesa_TexParameterf
+_mesa_TexParameterfv
+_mesa_TexParameteri
+_mesa_TexParameteriv
+gl_put_texobj_on_dirty_list
+gl_remove_texobj_from_dirty_list
+gl_update_dirty_texobjs
+_mesa_set_texture_sampler
+gl_init_texture
+gl_texture_pixels
+gl_update_texture_unit
+gl_init_translate
+gl_cull_triangle
+gl_set_triangle_function
+_mesa_ArrayElement
+_mesa_ColorPointer
+_mesa_ColorPointerEXT
+_mesa_DrawArrays
+_mesa_DrawElements
+_mesa_DrawRangeElements
+_mesa_EdgeFlagPointer
+_mesa_EdgeFlagPointerEXT
+_mesa_IndexPointer
+_mesa_IndexPointerEXT
+_mesa_InterleavedArrays
+_mesa_NormalPointer
+_mesa_NormalPointerEXT
+_mesa_TexCoordPointer
+_mesa_TexCoordPointerEXT
+_mesa_VertexPointer
+_mesa_VertexPointerEXT
+gl_exec_array_elements
+gl_update_client_state
+gl_immediate_alloc
+gl_immediate_free
+gl_vb_create_for_cva
+gl_vb_create_for_immediate
+gl_vb_free
+gl_cull_vb
+gl_dont_cull_vb
+gl_fast_copy_vb
+gl_make_normal_cullmask
+gl_purge_vertices
+_mesa_Begin
+_mesa_Color3b
+_mesa_Color3bv
+_mesa_Color3d
+_mesa_Color3dv
+_mesa_Color3f
+_mesa_Color3fv
+_mesa_Color3i
+_mesa_Color3iv
+_mesa_Color3s
+_mesa_Color3sv
+_mesa_Color3ub
+_mesa_Color3ubv
+_mesa_Color3ui
+_mesa_Color3uiv
+_mesa_Color3us
+_mesa_Color3usv
+_mesa_Color4b
+_mesa_Color4bv
+_mesa_Color4d
+_mesa_Color4dv
+_mesa_Color4f
+_mesa_Color4fv
+_mesa_Color4i
+_mesa_Color4iv
+_mesa_Color4s
+_mesa_Color4sv
+_mesa_Color4ub
+_mesa_Color4ubv
+_mesa_Color4ui
+_mesa_Color4uiv
+_mesa_Color4us
+_mesa_Color4usv
+_mesa_EdgeFlag
+_mesa_EdgeFlagv
+_mesa_End
+_mesa_Indexd
+_mesa_Indexdv
+_mesa_Indexf
+_mesa_Indexfv
+_mesa_Indexi
+_mesa_Indexiv
+_mesa_Indexs
+_mesa_Indexsv
+_mesa_Indexub
+_mesa_Indexubv
+_mesa_MultiTexCoord1dARB
+_mesa_MultiTexCoord1dvARB
+_mesa_MultiTexCoord1fARB
+_mesa_MultiTexCoord1fvARB
+_mesa_MultiTexCoord1iARB
+_mesa_MultiTexCoord1ivARB
+_mesa_MultiTexCoord1sARB
+_mesa_MultiTexCoord1svARB
+_mesa_MultiTexCoord2dARB
+_mesa_MultiTexCoord2dvARB
+_mesa_MultiTexCoord2fARB
+_mesa_MultiTexCoord2fvARB
+_mesa_MultiTexCoord2iARB
+_mesa_MultiTexCoord2ivARB
+_mesa_MultiTexCoord2sARB
+_mesa_MultiTexCoord2svARB
+_mesa_MultiTexCoord3dARB
+_mesa_MultiTexCoord3dvARB
+_mesa_MultiTexCoord3fARB
+_mesa_MultiTexCoord3fvARB
+_mesa_MultiTexCoord3iARB
+_mesa_MultiTexCoord3ivARB
+_mesa_MultiTexCoord3sARB
+_mesa_MultiTexCoord3svARB
+_mesa_MultiTexCoord4dARB
+_mesa_MultiTexCoord4dvARB
+_mesa_MultiTexCoord4fARB
+_mesa_MultiTexCoord4fvARB
+_mesa_MultiTexCoord4iARB
+_mesa_MultiTexCoord4ivARB
+_mesa_MultiTexCoord4sARB
+_mesa_MultiTexCoord4svARB
+_mesa_Normal3b
+_mesa_Normal3bv
+_mesa_Normal3d
+_mesa_Normal3dv
+_mesa_Normal3f
+_mesa_Normal3fv
+_mesa_Normal3i
+_mesa_Normal3iv
+_mesa_Normal3s
+_mesa_Normal3sv
+_mesa_TexCoord1d
+_mesa_TexCoord1dv
+_mesa_TexCoord1f
+_mesa_TexCoord1fv
+_mesa_TexCoord1i
+_mesa_TexCoord1iv
+_mesa_TexCoord1s
+_mesa_TexCoord1sv
+_mesa_TexCoord2d
+_mesa_TexCoord2dv
+_mesa_TexCoord2f
+_mesa_TexCoord2fv
+_mesa_TexCoord2i
+_mesa_TexCoord2iv
+_mesa_TexCoord2s
+_mesa_TexCoord2sv
+_mesa_TexCoord3d
+_mesa_TexCoord3dv
+_mesa_TexCoord3f
+_mesa_TexCoord3fv
+_mesa_TexCoord3i
+_mesa_TexCoord3iv
+_mesa_TexCoord3s
+_mesa_TexCoord3sv
+_mesa_TexCoord4d
+_mesa_TexCoord4dv
+_mesa_TexCoord4f
+_mesa_TexCoord4fv
+_mesa_TexCoord4i
+_mesa_TexCoord4iv
+_mesa_TexCoord4s
+_mesa_TexCoord4sv
+_mesa_Vertex2d
+_mesa_Vertex2dv
+_mesa_Vertex2f
+_mesa_Vertex2fv
+_mesa_Vertex2i
+_mesa_Vertex2iv
+_mesa_Vertex2s
+_mesa_Vertex2sv
+_mesa_Vertex3d
+_mesa_Vertex3dv
+_mesa_Vertex3f
+_mesa_Vertex3fv
+_mesa_Vertex3i
+_mesa_Vertex3iv
+_mesa_Vertex3s
+_mesa_Vertex3sv
+_mesa_Vertex4d
+_mesa_Vertex4dv
+_mesa_Vertex4f
+_mesa_Vertex4fv
+_mesa_Vertex4i
+_mesa_Vertex4iv
+_mesa_Vertex4s
+_mesa_Vertex4sv
+gl_Begin
+gl_End
+gl_Vertex2f
+gl_render_elts
+gl_render_vb_indirect
+gl_init_vbrender
+gl_reduced_prim_change
+gl_render_clipped_line
+gl_render_clipped_triangle
+gl_render_vb
+gl_set_render_vb_function
+RESET_IMMEDIATE
+gl_compute_orflag
+gl_copy_prev_vertices
+gl_copy_to_current
+gl_execute_cassette
+gl_fixup_cassette
+gl_fixup_input
+gl_flush_vb
+gl_internal_flush
+gl_maybe_transform_vb
+gl_print_cassette
+gl_print_cassette_flags
+gl_reset_input
+gl_reset_vb
+gl_texcoord_size
+gl_vector1ub_alloc
+gl_vector1ub_free
+gl_vector1ub_init
+gl_vector1ui_alloc
+gl_vector1ui_free
+gl_vector1ui_init
+gl_vector3f_alloc
+gl_vector3f_free
+gl_vector3f_init
+gl_vector3f_print
+gl_vector4f_alloc
+gl_vector4f_clean_elem
+gl_vector4f_free
+gl_vector4f_init
+gl_vector4f_print
+gl_vector4ub_alloc
+gl_vector4ub_free
+gl_vector4ub_init
+gl_init_vertices
+_mesa_WindowPos2dMESA
+_mesa_WindowPos2dvMESA
+_mesa_WindowPos2fMESA
+_mesa_WindowPos2fvMESA
+_mesa_WindowPos2iMESA
+_mesa_WindowPos2ivMESA
+_mesa_WindowPos2sMESA
+_mesa_WindowPos2svMESA
+_mesa_WindowPos3dMESA
+_mesa_WindowPos3dvMESA
+_mesa_WindowPos3fMESA
+_mesa_WindowPos3fvMESA
+_mesa_WindowPos3iMESA
+_mesa_WindowPos3ivMESA
+_mesa_WindowPos3sMESA
+_mesa_WindowPos3svMESA
+_mesa_WindowPos4dMESA
+_mesa_WindowPos4dvMESA
+_mesa_WindowPos4fMESA
+_mesa_WindowPos4fvMESA
+_mesa_WindowPos4iMESA
+_mesa_WindowPos4ivMESA
+_mesa_WindowPos4sMESA
+_mesa_WindowPos4svMESA
+gl_init_transformation
+gl_project_points
+gl_transform_point_sz
+gl_transform_vector
+gl_write_zoomed_index_span
+gl_write_zoomed_rgb_span
+gl_write_zoomed_rgba_span
+gl_write_zoomed_stencil_span
+__MESA_beginDispatchOverride
+__MESA_copyContext
+__MESA_createBuffer
+__MESA_createContext
+__MESA_destroyBuffer
+__MESA_destroyContext
+__MESA_dispatchExec
+__MESA_endDispatchOverride
+__MESA_forceCurrent
+__MESA_initVisuals
+__MESA_loseCurrent
+__MESA_makeCurrent
+__MESA_notifyDestroy
+__MESA_notifyResize
+__MESA_notifySwapBuffers
+__MESA_resetExtension
+__MESA_resizeBuffers
+__MESA_screenProbe
+__MESA_setVisualConfigs
+__MESA_shareContext
+__MESA_swapBuffers
+__glFloorLog2
+XMesaCreateImage
+XMesaDestroyImage
+XMesaGetPixel
+XMesaPutImageHelper
+XMesaCopySubBuffer
+XMesaCreateContext
+XMesaCreatePixmapBuffer
+XMesaCreateVisual
+XMesaCreateWindowBuffer
+XMesaCreateWindowBuffer2
+XMesaDestroyBuffer
+XMesaDestroyContext
+XMesaDestroyVisual
+XMesaDitherColor
+XMesaFindBuffer
+XMesaFlush
+XMesaForceCurrent
+XMesaGarbageCollect
+XMesaGetBackBuffer
+XMesaGetCurrentBuffer
+XMesaGetCurrentContext
+XMesaGetCurrentReadBuffer
+XMesaGetDepthBuffer
+XMesaGetString
+XMesaLoseCurrent
+XMesaMakeCurrent
+XMesaMakeCurrent2
+XMesaReset
+XMesaSetFXmode
+XMesaSetVisualDisplay
+XMesaSwapBuffers
+XMesaUnbindContext
+xmesa_alloc_back_buffer
+xmesa_color_to_pixel
+xmesa_update_state
+xmesa_get_line_func
+xmesa_get_points_func
+xmesa_get_triangle_func
+
+/* $XFree86: xc/programs/Xserver/GL/mesa/src/GLcore-def.cpp,v 1.1 2000/08/10 17:40:29 dawes Exp $ */
diff --git a/nx-X11/programs/Xserver/GL/mesa/GLcore/GLcoremodule.c b/nx-X11/programs/Xserver/GL/mesa/GLcore/GLcoremodule.c
new file mode 100644
index 000000000..4e03b59fe
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/GLcore/GLcoremodule.c
@@ -0,0 +1,64 @@
+/* $XFree86: xc/programs/Xserver/GL/mesa/src/GLcoremodule.c,v 1.5 2000/02/23 04:46:55 martin Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Module.h"
+
+static MODULESETUPPROTO(GLcoreSetup);
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "GLcore",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_EXTENSION,
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_NONE,
+ {0,0,0,0}
+};
+
+XF86ModuleData GLcoreModuleData = { &VersRec, GLcoreSetup, NULL };
+
+static pointer
+GLcoreSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ /* Need a non-NULL return value to indicate success */
+ return (pointer)1;
+}
diff --git a/nx-X11/programs/Xserver/GL/mesa/GLcore/Imakefile b/nx-X11/programs/Xserver/GL/mesa/GLcore/Imakefile
new file mode 100644
index 000000000..154a5c1a0
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/GLcore/Imakefile
@@ -0,0 +1,77 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/GLcore/Imakefile,v 1.3 2002/05/31 18:12:36 dawes Exp $
+
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+#include <Server.tmpl>
+
+#define NeedAllMesaSrc
+#define MesaInXServer
+#define MesaBuildDir ../main/
+#define MesaACBuildDir ../array_cache/
+#define MesaMathBuildDir ../math/
+#define MesaSwrastBuildDir ../swrast/
+#define MesaSwrastSetupBuildDir ../swrast_setup/
+#define MesaTnlBuildDir ../tnl/
+#define MesaShaderBuildDir ../shader/
+#define MesaGrammarBuildDir ../shader/grammar/
+#define MesaSlangBuildDir ../shader/slang/
+#define MesaXBuildDir ../X/
+
+#include "../../../../../lib/GL/mesa/array_cache/Imakefile.inc"
+#include "../../../../../lib/GL/mesa/swrast/Imakefile.inc"
+#include "../../../../../lib/GL/mesa/swrast_setup/Imakefile.inc"
+#include "../../../../../lib/GL/mesa/tnl/Imakefile.inc"
+#include "../../../../../lib/GL/mesa/main/Imakefile.inc"
+#include "../../../../../lib/GL/mesa/math/Imakefile.inc"
+#include "../../../../../lib/GL/mesa/shader/Imakefile.inc"
+#include "../../../../../lib/GL/mesa/shader/grammar/Imakefile.inc"
+#include "../../../../../lib/GL/mesa/shader/slang/Imakefile.inc"
+#include "../../../../../lib/GL/mesa/drivers/x11/Imakefile.inc"
+#include "../../../../../lib/GL/mesa/Imakefile.inc"
+
+#ifdef IHaveModules
+ MSRCS = GLcoremodule.c
+ MOBJS = GLcoremodule.o
+#endif
+
+ XOBJS = ../X/?*.o
+
+ OBJS = $(COREMESAOBJS) $(MOBJS)
+
+ DONES = ../main/DONE ../X/DONE ../array_cache/DONE \
+ ../math/DONE ../swrast/DONE ../swrast_setup/DONE \
+ ../tnl/DONE ../shader/DONE ../shader/grammar/DONE \
+ ../shader/slang/DONE
+
+ INCLUDES = -I$(INCLUDESRC) -I$(XINCLUDESRC) -I$(EXTINCSRC) \
+ -I$(MESASRCDIR)/include -I$(GLXLIBSRC)/include \
+ -I$(MESASRCDIR)/src/mesa \
+ -I$(SERVERSRC)/include
+
+ DEFINES = $(GLX_DEFINES)
+
+#ifdef IHaveModules
+ModuleObjectRule()
+
+DepLibraryModuleTarget(GLcore, $(DONES) $(OBJS),$(OBJS) $(XOBJS))
+InstallLibraryModule(GLcore,$(MODULEDIR),extensions)
+
+#else
+NormalDepLibraryTarget(GLcore, $(DONES) $(OBJS), $(OBJS) $(XOBJS))
+NormalLibraryObjectRule()
+#endif
+
+InstallDriverSDKLibraryModule(GLcore,$(DRIVERSDKMODULEDIR),extensions)
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/GLcore/module/Imakefile b/nx-X11/programs/Xserver/GL/mesa/GLcore/module/Imakefile
new file mode 100644
index 000000000..18dcdf0a1
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/GLcore/module/Imakefile
@@ -0,0 +1,53 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/GLcore/Imakefile,v 1.2 2002/02/25 18:00:38 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#define NeedAllMesaSrc
+#define MesaInXServer
+#define MesaBuildDir ../../main/module/
+#define MesaACBuildDir ../../array_cache/module/
+#define MesaMathBuildDir ../../math/module/
+#define MesaSwrastBuildDir ../../swrast/module/
+#define MesaSwrastSetupBuildDir ../../swrast_setup/module/
+#define MesaTnlBuildDir ../../tnl/module/
+#define MesaXBuildDir ../../X/module/
+
+#include "../../../../../../lib/GL/mesa/array_cache/Imakefile.inc"
+#include "../../../../../../lib/GL/mesa/swrast/Imakefile.inc"
+#include "../../../../../../lib/GL/mesa/swrast_setup/Imakefile.inc"
+#include "../../../../../../lib/GL/mesa/tnl/Imakefile.inc"
+#include "../../../../../../lib/GL/mesa/math/Imakefile.inc"
+#include "../../../../../../lib/GL/mesa/drivers/x11/Imakefile.inc"
+#include "../../../../../../lib/GL/mesa/Imakefile.inc"
+
+#if DoLoadableServer
+ MSRCS = GLcoremodule.c
+ MOBJS = GLcoremodule.o
+#endif
+
+ XOBJS = ../../X/module/?*.o
+
+ OBJS = $(COREMESAOBJS) $(MOBJS)
+
+ DONES = ../../module/DONE ../../X/module/DONE \
+ ../../array_cache/module/DONE ../../math/module/DONE \
+ ../../swrast/module/DONE \
+ ../../swrast_setup/module/DONE ../../tnl/module/DONE
+
+ INCLUDES = -I$(INCLUDESRC) -I$(XINCLUDESRC) -I$(EXTINCSRC) \
+ -I$(MESASRCDIR)/include -I$(GLXLIBSRC)/include \
+ -I$(MESASRCDIR)/src/mesa \
+ -I$(SERVERSRC)/include
+
+ DEFINES = $(GLX_DEFINES)
+
+ModuleObjectRule()
+
+DepLibraryModuleTarget(GLcore, $(DONES) $(OBJS),$(OBJS) $(XOBJS))
+InstallLibraryModule(GLcore,$(MODULEDIR),extensions)
+
+InstallDriverSDKLibraryModule(GLcore,$(DRIVERSDKMODULEDIR),extensions)
+
+LinkSourceFile(GLcoremodule.c,..)
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/Imakefile b/nx-X11/programs/Xserver/GL/mesa/Imakefile
new file mode 100644
index 000000000..ea7d18aa2
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/Imakefile
@@ -0,0 +1,47 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/Imakefile,v 1.23 2002/11/22 22:56:00 tsi Exp $
+
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+ MODSUBDIR = module
+#endif
+#endif
+
+#if !defined(IHaveModules) || !BuildModuleInSubdir
+#define IHaveSubdirs
+ SUBDIRS = main math array_cache swrast swrast_setup tnl shader X GLcore $(MODSUBDIR)
+#endif
+
+#include <Server.tmpl>
+
+
+#define NeedAllMesaSrc
+#define NeedToLinkMesaSrc
+#define MesaBuildDir /**/
+#if !defined(IHaveModules) || !BuildModuleInSubdir
+#include "../../../../lib/GL/mesa/Imakefile.inc"
+#else
+#include "../../../../../../lib/GL/mesa/Imakefile.inc"
+#endif
+
+ INCLUDES = -I$(INCLUDESRC) -I$(XINCLUDESRC) -I$(EXTINCSRC) \
+ -I$(MESASRCDIR)/include -I$(GLXLIBSRC)/include \
+ -I$(MESASRCDIR)/src/mesa \
+ -I$(SERVERSRC)/include
+
+ DEFINES = $(GLX_DEFINES)
+
+#ifdef IHaveModules
+ModuleObjectRule()
+#else
+NormalLibraryObjectRule()
+#endif
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/X/Imakefile b/nx-X11/programs/Xserver/GL/mesa/X/Imakefile
new file mode 100644
index 000000000..57fb7ff36
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/X/Imakefile
@@ -0,0 +1,93 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/X/Imakefile,v 1.16 2002/11/22 22:56:01 tsi Exp $
+
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+#include <Server.tmpl>
+
+#define NeedAllMesaSrc
+#define NeedToLinkMesaSrc
+#define MesaXBuildDir /**/
+#define MesaInXServer
+#if !defined(IHaveModules) || !BuildModuleInSubdir
+#include "../../../../../lib/GL/mesa/drivers/x11/Imakefile.inc"
+#else
+#include "../../../../../../lib/GL/mesa/drivers/x11/Imakefile.inc"
+#endif
+
+
+LinkSourceFile(compsize.c,$(MESASRCDIR)/src/glx/x11)
+
+ DRIVER_SRCS = $(XMESA_SRCS)
+ DRIVER_OBJS = $(XMESA_OBJS)
+
+ COMMON_SRCS = driverfuncs.c
+ COMMON_OBJS = driverfuncs.o
+
+#ifndef XFree86Version
+
+/* This appears to be the quickest way to build a non-XFree86 server */
+GLXSRV_DEFINES = -DXFree86Server
+
+#endif
+
+ GLX_SRCS = xf86glx.c xf86glx_util.c compsize.c
+ GLX_OBJS = xf86glx.o xf86glx_util.o compsize.o
+
+ SRCS = $(DRIVER_SRCS) $(GLX_SRCS) $(COMMON_SRCS)
+ OBJS = $(DRIVER_OBJS) $(GLX_OBJS) $(COMMON_OBJS)
+
+ INCLUDES = -I$(SERVERSRC)/GL/mesa/X -I$(XINCLUDESRC) \
+ -I$(EXTINCSRC) \
+ -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/src -I$(MESASRCDIR)/src/mesa/drivers/x11 \
+ -I$(MESASRCDIR)/include \
+ -I$(LIBSRC)/GL/glx -I$(LIBSRC)/GL/include \
+ -I$(SERVERSRC)/include -I$(SERVERSRC)/GL/include \
+ -I$(SERVERSRC)/GL/glx \
+ -I$(XF86OSSRC) \
+ -I$(DRMSRCDIR)/shared-core
+
+ DEFINES = $(GLX_DEFINES) $(GLXSRV_DEFINES) /*-DUSE_X86_ASM*/ /*-DUSE_SPARC_ASM*/
+
+#ifdef IHaveModules
+ModuleObjectRule()
+#else
+NormalLibraryObjectRule()
+#endif
+
+SubdirLibraryRule($(OBJS))
+
+LintLibraryTarget(dri,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+#if defined(IHaveModules) && BuildModuleInSubdir
+LinkSourceFile(xf86glx.c,..)
+LinkSourceFile(xf86glx_util.c,..)
+#endif
+
+#ifndef MesaDrvSrcDir
+#define MesaDrvSrcDir $(MESASRCDIR)/src/mesa/drivers/dri
+#endif
+
+MESADRVSRCDIR = MesaDrvSrcDir
+
+
+LinkSourceFile(driverfuncs.c, $(MESADRVSRCDIR)/../common)
+LinkSourceFile(driverfuncs.h, $(MESADRVSRCDIR)/../common)
diff --git a/nx-X11/programs/Xserver/GL/mesa/X/module/Imakefile b/nx-X11/programs/Xserver/GL/mesa/X/module/Imakefile
new file mode 100644
index 000000000..eee4c7556
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/X/module/Imakefile
@@ -0,0 +1,6 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/X/module/Imakefile,v 1.1 2002/05/31 18:12:38 dawes Exp $
+
+#define IHaveModules
+
+#include "../Imakefile"
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/X/xf86glx.c b/nx-X11/programs/Xserver/GL/mesa/X/xf86glx.c
new file mode 100644
index 000000000..5dd4e7c37
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/X/xf86glx.c
@@ -0,0 +1,914 @@
+/* $XFree86: xc/programs/Xserver/GL/mesa/src/X/xf86glx.c,v 1.19 2003/07/16 01:38:27 dawes Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ * Brian E. Paul <brian@precisioninsight.com>
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <regionstr.h>
+#include <resource.h>
+#include <GL/gl.h>
+#include <GL/glxint.h>
+#include <GL/glxtokens.h>
+#include <scrnintstr.h>
+#include <config.h>
+#include <glxserver.h>
+#include <glxscreens.h>
+#include <glxdrawable.h>
+#include <glxcontext.h>
+#include <glxext.h>
+#include <glxutil.h>
+#include "xf86glxint.h"
+#include "context.h"
+#include "xmesaP.h"
+#include <GL/xf86glx.h>
+#include "context.h"
+
+/*
+ * This define is for the glcore.h header file.
+ * If you add it here, then make sure you also add it in
+ * ../../../glx/Imakefile.
+ */
+#if 0
+#define DEBUG
+#include <GL/internal/glcore.h>
+#undef DEBUG
+#else
+#include <GL/internal/glcore.h>
+#endif
+
+#include "glcontextmodes.h"
+
+/*
+ * This structure is statically allocated in the __glXScreens[]
+ * structure. This struct is not used anywhere other than in
+ * __glXScreenInit to initialize each of the active screens
+ * (__glXActiveScreens[]). Several of the fields must be initialized by
+ * the screenProbe routine before they are copied to the active screens
+ * struct. In particular, the contextCreate, pGlxVisual, numVisuals,
+ * and numUsableVisuals fields must be initialized.
+ */
+static __GLXscreenInfo __glDDXScreenInfo = {
+ __MESA_screenProbe, /* Must be generic and handle all screens */
+ __MESA_createContext, /* Substitute screen's createContext routine */
+ __MESA_createBuffer, /* Substitute screen's createBuffer routine */
+ NULL, /* Set up modes in probe */
+ NULL, /* Set up pVisualPriv in probe */
+ 0, /* Set up numVisuals in probe */
+ 0, /* Set up numUsableVisuals in probe */
+ NULL, /* GLextensions is overwritten by __glXScreenInit */
+ "Vendor String", /* GLXvendor is overwritten by __glXScreenInit */
+ "Version String", /* GLXversion is overwritten by __glXScreenInit */
+ "Extensions String", /* GLXextensions is overwritten by __glXScreenInit */
+ NULL /* WrappedPositionWindow is overwritten */
+};
+
+void *__glXglDDXScreenInfo(void) {
+ return &__glDDXScreenInfo;
+}
+
+static __GLXextensionInfo __glDDXExtensionInfo = {
+ GL_CORE_MESA,
+ __MESA_resetExtension,
+ __MESA_initVisuals,
+ __MESA_setVisualConfigs
+};
+
+void *__glXglDDXExtensionInfo(void) {
+ return &__glDDXExtensionInfo;
+}
+
+static __MESA_screen MESAScreens[MAXSCREENS];
+static __GLcontext *MESA_CC = NULL;
+
+static int numConfigs = 0;
+static __GLXvisualConfig *visualConfigs = NULL;
+static void **visualPrivates = NULL;
+
+
+static int count_bits(unsigned int n)
+{
+ int bits = 0;
+
+ while (n > 0) {
+ if (n & 1) bits++;
+ n >>= 1;
+ }
+ return bits;
+}
+
+
+static XMesaVisual find_mesa_visual(int screen, VisualID vid)
+{
+ __MESA_screen * const pMScr = &MESAScreens[screen];
+ const __GLcontextModes *modes;
+ unsigned i = 0;
+
+ for ( modes = pMScr->modes ; modes != NULL ; modes = modes->next ) {
+ if ( modes->visualID == vid ) {
+ break;
+ }
+
+ i++;
+ }
+
+ return (modes != NULL) ? pMScr->xm_vis[i] : NULL;
+}
+
+
+/*
+ * In the case the driver defines no GLX visuals we'll use these.
+ * Note that for TrueColor and DirectColor visuals, bufferSize is the
+ * sum of redSize, greenSize, blueSize and alphaSize, which may be larger
+ * than the nplanes/rootDepth of the server's X11 visuals
+ */
+#define NUM_FALLBACK_CONFIGS 5
+static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
+ /* [0] = RGB, double buffered, Z */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 0, 0, 0, 0, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 0, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [1] = RGB, double buffered, Z, stencil, accum */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 16, 16, 16, 0, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [2] = RGB+Alpha, double buffered, Z, stencil, accum */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 8, /* rgba sizes */
+ -1, -1, -1, -1, /* rgba masks */
+ 16, 16, 16, 16, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [3] = RGB+Alpha, single buffered, Z, stencil, accum */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 8, /* rgba sizes */
+ -1, -1, -1, -1, /* rgba masks */
+ 16, 16, 16, 16, /* rgba accum sizes */
+ False, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [4] = CI, double buffered, Z */
+ {
+ -1, /* vid */
+ -1, /* class */
+ False, /* rgba? (false = color index) */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 0, 0, 0, 0, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 0, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+};
+
+
+static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
+ VisualID *defaultVisp,
+ int ndepth, DepthPtr pdepth,
+ int rootDepth)
+{
+ int numRGBconfigs;
+ int numCIconfigs;
+ int numVisuals = *nvisualp;
+ int numNewVisuals;
+ int numNewConfigs;
+ VisualPtr pVisual = *visualp;
+ VisualPtr pVisualNew = NULL;
+ VisualID *orig_vid = NULL;
+ __GLcontextModes *modes;
+ __GLXvisualConfig *pNewVisualConfigs = NULL;
+ void **glXVisualPriv;
+ void **pNewVisualPriv;
+ int found_default;
+ int i, j, k;
+
+ if (numConfigs > 0)
+ numNewConfigs = numConfigs;
+ else
+ numNewConfigs = NUM_FALLBACK_CONFIGS;
+
+ /* Alloc space for the list of new GLX visuals */
+ pNewVisualConfigs = (__GLXvisualConfig *)
+ __glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig));
+ if (!pNewVisualConfigs) {
+ return FALSE;
+ }
+
+ /* Alloc space for the list of new GLX visual privates */
+ pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *));
+ if (!pNewVisualPriv) {
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /*
+ ** If SetVisualConfigs was not called, then use default GLX
+ ** visual configs.
+ */
+ if (numConfigs == 0) {
+ memcpy(pNewVisualConfigs, FallbackConfigs,
+ NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig));
+ memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *));
+ }
+ else {
+ /* copy driver's visual config info */
+ for (i = 0; i < numConfigs; i++) {
+ pNewVisualConfigs[i] = visualConfigs[i];
+ pNewVisualPriv[i] = visualPrivates[i];
+ }
+ }
+
+ /* Count the number of RGB and CI visual configs */
+ numRGBconfigs = 0;
+ numCIconfigs = 0;
+ for (i = 0; i < numNewConfigs; i++) {
+ if (pNewVisualConfigs[i].rgba)
+ numRGBconfigs++;
+ else
+ numCIconfigs++;
+ }
+
+ /* Count the total number of visuals to compute */
+ numNewVisuals = 0;
+ for (i = 0; i < numVisuals; i++) {
+ numNewVisuals +=
+ (pVisual[i].class == TrueColor || pVisual[i].class == DirectColor)
+ ? numRGBconfigs : numCIconfigs;
+ }
+
+ /* Reset variables for use with the next screen/driver's visual configs */
+ visualConfigs = NULL;
+ numConfigs = 0;
+
+ /* Alloc temp space for the list of orig VisualIDs for each new visual */
+ orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID));
+ if (!orig_vid) {
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the list of glXVisuals */
+ modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes));
+ if (modes == NULL) {
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the list of glXVisualPrivates */
+ glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *));
+ if (!glXVisualPriv) {
+ _gl_context_modes_destroy( modes );
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the new list of the X server's visuals */
+ pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec));
+ if (!pVisualNew) {
+ __glXFree(glXVisualPriv);
+ _gl_context_modes_destroy( modes );
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Initialize the new visuals */
+ found_default = FALSE;
+ MESAScreens[screenInfo.numScreens-1].modes = modes;
+ for (i = j = 0; i < numVisuals; i++) {
+ int is_rgb = (pVisual[i].class == TrueColor ||
+ pVisual[i].class == DirectColor);
+
+ for (k = 0; k < numNewConfigs; k++) {
+ if (pNewVisualConfigs[k].rgba != is_rgb)
+ continue;
+
+ assert( modes != NULL );
+
+ /* Initialize the new visual */
+ pVisualNew[j] = pVisual[i];
+ pVisualNew[j].vid = FakeClientID(0);
+
+ /* Check for the default visual */
+ if (!found_default && pVisual[i].vid == *defaultVisp) {
+ *defaultVisp = pVisualNew[j].vid;
+ found_default = TRUE;
+ }
+
+ /* Save the old VisualID */
+ orig_vid[j] = pVisual[i].vid;
+
+ /* Initialize the glXVisual */
+ _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] );
+ modes->visualID = pVisualNew[j].vid;
+
+ /*
+ * If the class is -1, then assume the X visual information
+ * is identical to what GLX needs, and take them from the X
+ * visual. NOTE: if class != -1, then all other fields MUST
+ * be initialized.
+ */
+ if (modes->visualType == GLX_NONE) {
+ modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class );
+ modes->redBits = count_bits(pVisual[i].redMask);
+ modes->greenBits = count_bits(pVisual[i].greenMask);
+ modes->blueBits = count_bits(pVisual[i].blueMask);
+ modes->alphaBits = modes->alphaBits;
+ modes->redMask = pVisual[i].redMask;
+ modes->greenMask = pVisual[i].greenMask;
+ modes->blueMask = pVisual[i].blueMask;
+ modes->alphaMask = modes->alphaMask;
+ modes->rgbBits = (is_rgb)
+ ? (modes->redBits + modes->greenBits +
+ modes->blueBits + modes->alphaBits)
+ : rootDepth;
+ }
+
+ /* Save the device-dependent private for this visual */
+ glXVisualPriv[j] = pNewVisualPriv[k];
+
+ j++;
+ modes = modes->next;
+ }
+ }
+
+ assert(j <= numNewVisuals);
+
+ /* Save the GLX visuals in the screen structure */
+ MESAScreens[screenInfo.numScreens-1].num_vis = numNewVisuals;
+ MESAScreens[screenInfo.numScreens-1].private = glXVisualPriv;
+
+ /* Set up depth's VisualIDs */
+ for (i = 0; i < ndepth; i++) {
+ int numVids = 0;
+ VisualID *pVids = NULL;
+ int k, n = 0;
+
+ /* Count the new number of VisualIDs at this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numNewVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ numVids++;
+
+ /* Allocate a new list of VisualIDs for this depth */
+ pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID));
+
+ /* Initialize the new list of VisualIDs for this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numNewVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ pVids[n++] = pVisualNew[k].vid;
+
+ /* Update this depth's list of VisualIDs */
+ __glXFree(pdepth[i].vids);
+ pdepth[i].vids = pVids;
+ pdepth[i].numVids = numVids;
+ }
+
+ /* Update the X server's visuals */
+ *nvisualp = numNewVisuals;
+ *visualp = pVisualNew;
+
+ /* Free the old list of the X server's visuals */
+ __glXFree(pVisual);
+
+ /* Clean up temporary allocations */
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+
+ /* Free the private list created by DDX HW driver */
+ if (visualPrivates)
+ xfree(visualPrivates);
+ visualPrivates = NULL;
+
+ return TRUE;
+}
+
+void __MESA_setVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
+ void **privates)
+{
+ numConfigs = nconfigs;
+ visualConfigs = configs;
+ visualPrivates = privates;
+}
+
+Bool __MESA_initVisuals(VisualPtr *visualp, DepthPtr *depthp,
+ int *nvisualp, int *ndepthp, int *rootDepthp,
+ VisualID *defaultVisp, unsigned long sizes,
+ int bitsPerRGB)
+{
+ /*
+ * Setup the visuals supported by this particular screen.
+ */
+ return init_visuals(nvisualp, visualp, defaultVisp,
+ *ndepthp, *depthp, *rootDepthp);
+}
+
+static void fixup_visuals(int screen)
+{
+ ScreenPtr pScreen = screenInfo.screens[screen];
+ __MESA_screen *pMScr = &MESAScreens[screen];
+ int j;
+ __GLcontextModes *modes;
+
+ for ( modes = pMScr->modes ; modes != NULL ; modes = modes->next ) {
+ const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+ const int nplanes = (modes->rgbBits - modes->alphaBits);
+ const VisualPtr pVis = pScreen->visuals;
+
+ /* Find a visual that matches the GLX visual's class and size */
+ for (j = 0; j < pScreen->numVisuals; j++) {
+ if (pVis[j].class == vis_class &&
+ pVis[j].nplanes == nplanes) {
+
+ /* Fixup the masks */
+ modes->redMask = pVis[j].redMask;
+ modes->greenMask = pVis[j].greenMask;
+ modes->blueMask = pVis[j].blueMask;
+
+ /* Recalc the sizes */
+ modes->redBits = count_bits(modes->redMask);
+ modes->greenBits = count_bits(modes->greenMask);
+ modes->blueBits = count_bits(modes->blueMask);
+ }
+ }
+ }
+}
+
+static void init_screen_visuals(int screen)
+{
+ ScreenPtr pScreen = screenInfo.screens[screen];
+ __GLcontextModes *modes;
+ XMesaVisual *pXMesaVisual;
+ int *used;
+ int i, j;
+
+ /* Alloc space for the list of XMesa visuals */
+ pXMesaVisual = (XMesaVisual *)__glXMalloc(MESAScreens[screen].num_vis *
+ sizeof(XMesaVisual));
+ __glXMemset(pXMesaVisual, 0,
+ MESAScreens[screen].num_vis * sizeof(XMesaVisual));
+
+ /* FIXME: Change 'used' to be a array of bits (rather than of ints),
+ * FIXME: create a stack array of 8 or 16 bytes. If 'numVisuals' is less
+ * FIXME: than 64 or 128 the stack array can be used instead of calling
+ * FIXME: __glXMalloc / __glXFree. If nothing else, convert 'used' to
+ * FIXME: array of bytes instead of ints!
+ */
+ used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int));
+ __glXMemset(used, 0, pScreen->numVisuals * sizeof(int));
+
+ i = 0;
+ for ( modes = MESAScreens[screen].modes
+ ; modes != NULL
+ ; modes = modes->next ) {
+ const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+ const int nplanes = (modes->rgbBits - modes->alphaBits);
+ const VisualPtr pVis = pScreen->visuals;
+
+ for (j = 0; j < pScreen->numVisuals; j++) {
+ if (pVis[j].class == vis_class &&
+ pVis[j].nplanes == nplanes &&
+ pVis[j].redMask == modes->redMask &&
+ pVis[j].greenMask == modes->greenMask &&
+ pVis[j].blueMask == modes->blueMask &&
+ !used[j]) {
+
+ /* Create the XMesa visual */
+ pXMesaVisual[i] =
+ XMesaCreateVisual(pScreen,
+ pVis,
+ modes->rgbMode,
+ (modes->alphaBits > 0),
+ modes->doubleBufferMode,
+ modes->stereoMode,
+ GL_TRUE, /* ximage_flag */
+ modes->depthBits,
+ modes->stencilBits,
+ modes->accumRedBits,
+ modes->accumGreenBits,
+ modes->accumBlueBits,
+ modes->accumAlphaBits,
+ modes->samples,
+ modes->level,
+ modes->visualRating);
+ /* Set the VisualID */
+ modes->visualID = pVis[j].vid;
+
+ /* Mark this visual used */
+ used[j] = 1;
+ break;
+ }
+ }
+
+ if ( j == pScreen->numVisuals ) {
+ ErrorF("No matching visual for __GLcontextMode with "
+ "visual class = %d (%d), nplanes = %u\n",
+ vis_class,
+ modes->visualType,
+ (modes->rgbBits - modes->alphaBits) );
+ }
+ else if ( modes->visualID == -1 ) {
+ FatalError( "Matching visual found, but visualID still -1!\n" );
+ }
+
+ i++;
+ }
+
+ __glXFree(used);
+
+ MESAScreens[screen].xm_vis = pXMesaVisual;
+}
+
+Bool __MESA_screenProbe(int screen)
+{
+ /*
+ * Set up the current screen's visuals.
+ */
+ __glDDXScreenInfo.modes = MESAScreens[screen].modes;
+ __glDDXScreenInfo.pVisualPriv = MESAScreens[screen].private;
+ __glDDXScreenInfo.numVisuals =
+ __glDDXScreenInfo.numUsableVisuals = MESAScreens[screen].num_vis;
+
+ /*
+ * Set the current screen's createContext routine. This could be
+ * wrapped by a DDX GLX context creation routine.
+ */
+ __glDDXScreenInfo.createContext = __MESA_createContext;
+
+ /*
+ * The ordering of the rgb compenents might have been changed by the
+ * driver after mi initialized them.
+ */
+ fixup_visuals(screen);
+
+ /*
+ * Find the GLX visuals that are supported by this screen and create
+ * XMesa's visuals.
+ */
+ init_screen_visuals(screen);
+
+ return TRUE;
+}
+
+extern void __MESA_resetExtension(void)
+{
+ int i, j;
+
+ XMesaReset();
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ for (j = 0; j < MESAScreens[i].num_vis; j++) {
+ if (MESAScreens[i].xm_vis[j]) {
+ XMesaDestroyVisual(MESAScreens[i].xm_vis[j]);
+ MESAScreens[i].xm_vis[j] = NULL;
+ }
+ }
+ _gl_context_modes_destroy( MESAScreens[i].modes );
+ MESAScreens[i].modes = NULL;
+ __glXFree(MESAScreens[i].private);
+ MESAScreens[i].private = NULL;
+ __glXFree(MESAScreens[i].xm_vis);
+ MESAScreens[i].xm_vis = NULL;
+ MESAScreens[i].num_vis = 0;
+ }
+ __glDDXScreenInfo.modes = NULL;
+ MESA_CC = NULL;
+}
+
+void __MESA_createBuffer(__GLXdrawablePrivate *glxPriv)
+{
+ DrawablePtr pDraw = glxPriv->pDraw;
+ XMesaVisual xm_vis = find_mesa_visual(pDraw->pScreen->myNum,
+ glxPriv->modes->visualID);
+ __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
+ __MESA_buffer buf;
+
+ if (xm_vis == NULL) {
+ ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
+ glxPriv->modes->visualID);
+ }
+ buf = (__MESA_buffer)__glXMalloc(sizeof(struct __MESA_bufferRec));
+
+ /* Create Mesa's buffers */
+ if (glxPriv->type == DRAWABLE_WINDOW) {
+ buf->xm_buf = (void *)XMesaCreateWindowBuffer(xm_vis,
+ (WindowPtr)pDraw);
+ } else {
+ buf->xm_buf = (void *)XMesaCreatePixmapBuffer(xm_vis,
+ (PixmapPtr)pDraw, 0);
+ }
+
+ /* Wrap the front buffer's resize routine */
+ buf->fbresize = glPriv->frontBuffer.resize;
+ glPriv->frontBuffer.resize = __MESA_resizeBuffers;
+
+ /* Wrap the swap buffers routine */
+ buf->fbswap = glxPriv->swapBuffers;
+ glxPriv->swapBuffers = __MESA_swapBuffers;
+
+ /* Save Mesa's private buffer structure */
+ glPriv->private = (void *)buf;
+ glPriv->freePrivate = __MESA_destroyBuffer;
+}
+
+GLboolean __MESA_resizeBuffers(__GLdrawableBuffer *buffer,
+ GLint x, GLint y,
+ GLuint width, GLuint height,
+ __GLdrawablePrivate *glPriv,
+ GLuint bufferMask)
+{
+ __MESA_buffer buf = (__MESA_buffer)glPriv->private;
+
+ if (buf->xm_buf)
+ XMesaResizeBuffers(buf->xm_buf);
+
+ return (*buf->fbresize)(buffer, x, y, width, height, glPriv, bufferMask);
+}
+
+GLboolean __MESA_swapBuffers(__GLXdrawablePrivate *glxPriv)
+{
+ __MESA_buffer buf = (__MESA_buffer)glxPriv->glPriv.private;
+
+ /*
+ ** Do not call the wrapped swap buffers routine since Mesa has
+ ** already done the swap.
+ */
+ XMesaSwapBuffers(buf->xm_buf);
+
+ return GL_TRUE;
+}
+
+void __MESA_destroyBuffer(__GLdrawablePrivate *glPriv)
+{
+ __MESA_buffer buf = (__MESA_buffer)glPriv->private;
+ __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other;
+
+ /* Destroy Mesa's buffers */
+ if (buf->xm_buf)
+ XMesaDestroyBuffer(buf->xm_buf);
+
+ /* Unwrap these routines */
+ glxPriv->swapBuffers = buf->fbswap;
+ glPriv->frontBuffer.resize = buf->fbresize;
+
+ __glXFree(glPriv->private);
+ glPriv->private = NULL;
+}
+
+__GLinterface *__MESA_createContext(__GLimports *imports,
+ __GLcontextModes *modes,
+ __GLinterface *shareGC)
+{
+ __GLcontext *gl_ctx = NULL;
+ __GLcontext *m_share = NULL;
+ __GLXcontext *glxc = (__GLXcontext *)imports->other;
+ XMesaVisual xm_vis;
+
+ if (shareGC)
+ m_share = (__GLcontext *)shareGC;
+
+ xm_vis = find_mesa_visual(glxc->pScreen->myNum, glxc->modes->visualID);
+ if (xm_vis) {
+ XMesaContext xmshare = m_share ? m_share->DriverCtx : 0;
+ XMesaContext xmctx = XMesaCreateContext(xm_vis, xmshare);
+ gl_ctx = xmctx ? &xmctx->mesa : 0;
+ }
+ else {
+ ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
+ glxc->modes->visualID);
+ }
+
+
+ if (!gl_ctx)
+ return NULL;
+
+ gl_ctx->imports = *imports;
+ gl_ctx->exports.destroyContext = __MESA_destroyContext;
+ gl_ctx->exports.loseCurrent = __MESA_loseCurrent;
+ gl_ctx->exports.makeCurrent = __MESA_makeCurrent;
+ gl_ctx->exports.shareContext = __MESA_shareContext;
+ gl_ctx->exports.copyContext = __MESA_copyContext;
+ gl_ctx->exports.forceCurrent = __MESA_forceCurrent;
+ gl_ctx->exports.notifyResize = __MESA_notifyResize;
+ gl_ctx->exports.notifyDestroy = __MESA_notifyDestroy;
+ gl_ctx->exports.notifySwapBuffers = __MESA_notifySwapBuffers;
+ gl_ctx->exports.dispatchExec = __MESA_dispatchExec;
+ gl_ctx->exports.beginDispatchOverride = __MESA_beginDispatchOverride;
+ gl_ctx->exports.endDispatchOverride = __MESA_endDispatchOverride;
+
+ return (__GLinterface *)gl_ctx;
+}
+
+GLboolean __MESA_destroyContext(__GLcontext *gc)
+{
+ XMesaContext xmesa = (XMesaContext) gc->DriverCtx;
+ XMesaDestroyContext( xmesa );
+ return GL_TRUE;
+}
+
+GLboolean __MESA_loseCurrent(__GLcontext *gc)
+{
+ XMesaContext xmesa = (XMesaContext) gc->DriverCtx;
+ MESA_CC = NULL;
+ __glXLastContext = NULL;
+ return XMesaLoseCurrent(xmesa);
+}
+
+GLboolean __MESA_makeCurrent(__GLcontext *gc)
+{
+ __GLdrawablePrivate *drawPriv = gc->imports.getDrawablePrivate( gc );
+ __MESA_buffer drawBuf = (__MESA_buffer)drawPriv->private;
+ __GLdrawablePrivate *readPriv = gc->imports.getReadablePrivate( gc );
+ __MESA_buffer readBuf = (__MESA_buffer)readPriv->private;
+ XMesaContext xmesa = (XMesaContext) gc->DriverCtx;
+
+ MESA_CC = gc;
+ return XMesaMakeCurrent2(xmesa, drawBuf->xm_buf, readBuf->xm_buf);
+}
+
+GLboolean __MESA_shareContext(__GLcontext *gc, __GLcontext *gcShare)
+{
+ /* NOT_DONE */
+ /* XXX I don't see where/how this could ever be called */
+ ErrorF("__MESA_shareContext\n");
+ return GL_FALSE;
+}
+
+GLboolean __MESA_copyContext(__GLcontext *dst, const __GLcontext *src,
+ GLuint mask)
+{
+ XMesaContext xm_dst = (XMesaContext) dst->DriverCtx;
+ const XMesaContext xm_src = (const XMesaContext) src->DriverCtx;
+ _mesa_copy_context(&xm_src->mesa, &xm_dst->mesa, mask);
+ return GL_TRUE;
+}
+
+GLboolean __MESA_forceCurrent(__GLcontext *gc)
+{
+ XMesaContext xmesa = (XMesaContext) gc->DriverCtx;
+ MESA_CC = gc;
+ return XMesaForceCurrent(xmesa);
+}
+
+GLboolean __MESA_notifyResize(__GLcontext *gc)
+{
+ /* NOT_DONE */
+ ErrorF("__MESA_notifyResize\n");
+ return GL_FALSE;
+}
+
+void __MESA_notifyDestroy(__GLcontext *gc)
+{
+ /* NOT_DONE */
+ ErrorF("__MESA_notifyDestroy\n");
+ return;
+}
+
+void __MESA_notifySwapBuffers(__GLcontext *gc)
+{
+ _mesa_notifySwapBuffers(gc);
+}
+
+struct __GLdispatchStateRec *__MESA_dispatchExec(__GLcontext *gc)
+{
+ /* NOT_DONE */
+ ErrorF("__MESA_dispatchExec\n");
+ return NULL;
+}
+
+void __MESA_beginDispatchOverride(__GLcontext *gc)
+{
+ /* NOT_DONE */
+ ErrorF("__MESA_beginDispatchOverride\n");
+ return;
+}
+
+void __MESA_endDispatchOverride(__GLcontext *gc)
+{
+ /* NOT_DONE */
+ ErrorF("__MESA_endDispatchOverride\n");
+ return;
+}
+
+
+/*
+ * Server-side GLX uses these functions which are normally defined
+ * in the OpenGL SI.
+ */
+
+GLuint __glFloorLog2(GLuint val)
+{
+ int c = 0;
+
+ while (val > 1) {
+ c++;
+ val >>= 1;
+ }
+ return c;
+}
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/X/xf86glx_util.c b/nx-X11/programs/Xserver/GL/mesa/X/xf86glx_util.c
new file mode 100644
index 000000000..6441a4b4f
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/X/xf86glx_util.c
@@ -0,0 +1,151 @@
+/* $XFree86: xc/programs/Xserver/GL/mesa/src/X/xf86glx_util.c,v 1.5 2000/03/02 16:07:39 martin Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ * Brian Paul <brian@precisioninsight.com>
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <gcstruct.h>
+#include "pixmapstr.h"
+#include "xf86glx_util.h"
+#include <X11/Xmd.h>
+#include "GL/xf86glx.h"
+
+#ifdef ROUNDUP
+#undef ROUNDUP
+#endif
+
+#define ROUNDUP(nbytes, pad) ((((nbytes) + ((pad)-1)) / (pad)) * ((pad)>>3))
+
+XMesaImage *XMesaCreateImage(int bitsPerPixel, int width, int height, char *data)
+{
+ XMesaImage *image;
+
+ image = (XMesaImage *)xalloc(sizeof(XMesaImage));
+
+ if (image) {
+ image->width = width;
+ image->height = height;
+ image->data = data;
+ /* Always pad to 32 bits */
+ image->bytes_per_line = ROUNDUP((bitsPerPixel * width), 32);
+ image->bits_per_pixel = bitsPerPixel;
+ }
+
+ return image;
+}
+
+void XMesaDestroyImage(XMesaImage *image)
+{
+ if (image->data)
+ free(image->data);
+ xfree(image);
+}
+
+unsigned long XMesaGetPixel(XMesaImage *image, int x, int y)
+{
+ CARD8 *row = (CARD8 *)(image->data + y*image->bytes_per_line);
+ CARD8 *i8;
+ CARD16 *i16;
+ CARD32 *i32;
+ switch (image->bits_per_pixel) {
+ case 8:
+ i8 = (CARD8 *)row;
+ return i8[x];
+ break;
+ case 15:
+ case 16:
+ i16 = (CARD16 *)row;
+ return i16[x];
+ break;
+ case 24: /* WARNING: architecture specific code */
+ i8 = (CARD8 *)row;
+ return (((CARD32)i8[x*3]) |
+ (((CARD32)i8[x*3+1])<<8) |
+ (((CARD32)i8[x*3+2])<<16));
+ break;
+ case 32:
+ i32 = (CARD32 *)row;
+ return i32[x];
+ break;
+ }
+ return 0;
+}
+
+#ifndef XMESA_USE_PUTPIXEL_MACRO
+void XMesaPutPixel(XMesaImage *image, int x, int y, unsigned long pixel)
+{
+ CARD8 *row = (CARD8 *)(image->data + y*image->bytes_per_line);
+ CARD8 *i8;
+ CARD16 *i16;
+ CARD32 *i32;
+ switch (image->bits_per_pixel) {
+ case 8:
+ i8 = (CARD8 *)row;
+ i8[x] = (CARD8)pixel;
+ break;
+ case 15:
+ case 16:
+ i16 = (CARD16 *)row;
+ i16[x] = (CARD16)pixel;
+ break;
+ case 24: /* WARNING: architecture specific code */
+ i8 = (CARD8 *)__row;
+ i8[x*3] = (CARD8)(p);
+ i8[x*3+1] = (CARD8)(p>>8);
+ i8[x*3+2] = (CARD8)(p>>16);
+ case 32:
+ i32 = (CARD32 *)row;
+ i32[x] = (CARD32)pixel;
+ break;
+ }
+}
+#endif
+
+void XMesaPutImageHelper(ScreenPtr display,
+ DrawablePtr d, GCPtr gc,
+ XMesaImage *image,
+ int src_x, int src_y,
+ int dest_x, int dest_y,
+ unsigned int width, unsigned int height)
+{
+ /* NOT_DONE: Verify that the following works for all depths */
+ char *src = (image->data +
+ src_y * image->bytes_per_line +
+ ((src_x * image->bits_per_pixel) >> 3));
+
+ ValidateGC(d, gc);
+ (*gc->ops->PutImage)(d, gc, d->depth, dest_x, dest_y, width, height,
+ 0, ZPixmap, src);
+}
diff --git a/nx-X11/programs/Xserver/GL/mesa/X/xf86glx_util.h b/nx-X11/programs/Xserver/GL/mesa/X/xf86glx_util.h
new file mode 100644
index 000000000..809c1550f
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/X/xf86glx_util.h
@@ -0,0 +1,106 @@
+/* $XFree86: xc/programs/Xserver/GL/mesa/src/X/xf86glx_util.h,v 1.5 2000/08/10 17:40:29 dawes Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ * Brian Paul <brian@precisioninsight.com>
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _XF86GLX_UTIL_H_
+#define _XF86GLX_UTIL_H_
+
+#ifdef __CYGWIN__
+#undef WIN32
+#undef _WIN32
+#endif
+
+#include <screenint.h>
+#include <pixmap.h>
+#include <gc.h>
+#include "GL/xmesa.h"
+
+#define XMESA_USE_PUTPIXEL_MACRO
+
+struct _XMesaImageRec {
+ int width, height;
+ char *data;
+ int bytes_per_line; /* Padded to 32 bits */
+ int bits_per_pixel;
+};
+
+extern XMesaImage *XMesaCreateImage(int bitsPerPixel, int width, int height,
+ char *data);
+extern void XMesaDestroyImage(XMesaImage *image);
+extern unsigned long XMesaGetPixel(XMesaImage *image, int x, int y);
+#ifdef XMESA_USE_PUTPIXEL_MACRO
+#define XMesaPutPixel(__i,__x,__y,__p) \
+{ \
+ CARD8 *__row = (CARD8 *)(__i->data + __y*__i->bytes_per_line); \
+ CARD8 *__i8; \
+ CARD16 *__i16; \
+ CARD32 *__i32; \
+ switch (__i->bits_per_pixel) { \
+ case 8: \
+ __i8 = (CARD8 *)__row; \
+ __i8[__x] = (CARD8)__p; \
+ break; \
+ case 15: \
+ case 16: \
+ __i16 = (CARD16 *)__row; \
+ __i16[__x] = (CARD16)__p; \
+ break; \
+ case 24: /* WARNING: architecture specific code */ \
+ __i8 = (CARD8 *)__row; \
+ __i8[__x*3] = (CARD8)(__p); \
+ __i8[__x*3+1] = (CARD8)(__p>>8); \
+ __i8[__x*3+2] = (CARD8)(__p>>16); \
+ break; \
+ case 32: \
+ __i32 = (CARD32 *)__row; \
+ __i32[__x] = (CARD32)__p; \
+ break; \
+ } \
+}
+#else
+extern void XMesaPutPixel(XMesaImage *image, int x, int y,
+ unsigned long pixel);
+#endif
+
+extern void XMesaPutImageHelper(ScreenPtr display,
+ DrawablePtr d, GCPtr gc,
+ XMesaImage *image,
+ int src_x, int src_y,
+ int dest_x, int dest_y,
+ unsigned int width, unsigned int height);
+
+#endif /* _XF86GLX_UTIL_H_ */
diff --git a/nx-X11/programs/Xserver/GL/mesa/X/xf86glxint.h b/nx-X11/programs/Xserver/GL/mesa/X/xf86glxint.h
new file mode 100644
index 000000000..974ff0364
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/X/xf86glxint.h
@@ -0,0 +1,102 @@
+/* $XFree86: xc/programs/Xserver/GL/mesa/src/X/xf86glxint.h,v 1.4 2002/02/22 21:45:08 dawes Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _XF86GLXINT_H_
+#define _XF86GLXINT_H_
+
+#include <miscstruct.h>
+#include <GL/gl.h>
+#include <GL/xmesa.h>
+
+typedef struct __MESA_screenRec __MESA_screen;
+struct __MESA_screenRec {
+ int num_vis;
+ __GLcontextModes *modes;
+ XMesaVisual *xm_vis;
+ void **private;
+};
+
+typedef struct __MESA_bufferRec *__MESA_buffer;
+struct __MESA_bufferRec {
+ XMesaBuffer xm_buf;
+ GLboolean (*fbresize)(__GLdrawableBuffer *buf,
+ GLint x, GLint y, GLuint width, GLuint height,
+ __GLdrawablePrivate *glPriv, GLuint bufferMask);
+ GLboolean (*fbswap)(__GLXdrawablePrivate *glxPriv);
+};
+
+extern void __MESA_setVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
+ void **privates);
+extern Bool __MESA_initVisuals(VisualPtr *visualp, DepthPtr *depthp,
+ int *nvisualp, int *ndepthp, int *rootDepthp,
+ VisualID *defaultVisp, unsigned long sizes,
+ int bitsPerRGB);
+extern Bool __MESA_screenProbe(int screen);
+
+extern void __MESA_resetExtension(void);
+
+extern void __MESA_createBuffer(__GLXdrawablePrivate *glxPriv);
+extern GLboolean __MESA_resizeBuffers(__GLdrawableBuffer *buf,
+ GLint x, GLint y,
+ GLuint width, GLuint height,
+ __GLdrawablePrivate *glPriv,
+ GLuint bufferMask);
+extern GLboolean __MESA_swapBuffers(__GLXdrawablePrivate *glxPriv);
+extern void __MESA_destroyBuffer(__GLdrawablePrivate *glPriv);
+
+extern __GLinterface *__MESA_createContext(__GLimports *imports,
+ __GLcontextModes *modes,
+ __GLinterface *shareGC);
+extern GLboolean __MESA_destroyContext(__GLcontext *gc);
+extern GLboolean __MESA_loseCurrent(__GLcontext *gc);
+extern GLboolean __MESA_makeCurrent(__GLcontext *gc);
+extern GLboolean __MESA_shareContext(__GLcontext *gc, __GLcontext *gcShare);
+extern GLboolean __MESA_copyContext(__GLcontext *dst, const __GLcontext *src,
+ GLuint mask);
+extern GLboolean __MESA_forceCurrent(__GLcontext *gc);
+
+extern GLboolean __MESA_notifyResize(__GLcontext *gc);
+extern void __MESA_notifyDestroy(__GLcontext *gc);
+extern void __MESA_notifySwapBuffers(__GLcontext *gc);
+extern struct __GLdispatchStateRec *__MESA_dispatchExec(__GLcontext *gc);
+extern void __MESA_beginDispatchOverride(__GLcontext *gc);
+extern void __MESA_endDispatchOverride(__GLcontext *gc);
+
+extern GLuint __glFloorLog2(GLuint val);
+
+#endif /* _XF86GLXINT_H_ */
diff --git a/nx-X11/programs/Xserver/GL/mesa/array_cache/Imakefile b/nx-X11/programs/Xserver/GL/mesa/array_cache/Imakefile
new file mode 100644
index 000000000..8126c3f30
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/array_cache/Imakefile
@@ -0,0 +1,56 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/array_cache/Imakefile,v 1.8 2002/11/22 22:56:01 tsi Exp $
+
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+#include <Server.tmpl>
+
+#define NeedAllMesaSrc
+#define NeedToLinkMesaSrc
+#define MesaACBuildDir /**/
+#if !defined(IHaveModules) || !BuildModuleInSubdir
+#include "../../../../../lib/GL/mesa/array_cache/Imakefile.inc"
+#else
+#include "../../../../../../lib/GL/mesa/array_cache/Imakefile.inc"
+#endif
+
+ SRCS = $(MESA_AC_SRCS)
+ OBJS = $(MESA_AC_OBJS)
+
+ INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/array_cache \
+ -I$(MESASRCDIR)/src/mesa/math \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/include \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/GL/include -I$(SERVERSRC)/GL/glx \
+ -I$(LIBSRC)/GL/include \
+ -I$(XF86SRC) -I$(INCLUDESRC)
+
+ DEFINES = $(GLX_DEFINES) /*-DUSE_X86_ASM*/ /*-DUSE_SPARC_ASM*/
+
+#ifdef IHaveModules
+ModuleObjectRule()
+#else
+NormalLibraryObjectRule()
+#endif
+
+SubdirLibraryRule($(OBJS))
+
+LintLibraryTarget(dri,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/array_cache/module/Imakefile b/nx-X11/programs/Xserver/GL/mesa/array_cache/module/Imakefile
new file mode 100644
index 000000000..86c585012
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/array_cache/module/Imakefile
@@ -0,0 +1,6 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/array_cache/module/Imakefile,v 1.1 2002/05/31 18:12:39 dawes Exp $
+
+#define IHaveModules
+
+#include "../Imakefile"
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/main/Imakefile b/nx-X11/programs/Xserver/GL/mesa/main/Imakefile
new file mode 100644
index 000000000..463812236
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/main/Imakefile
@@ -0,0 +1,61 @@
+XCOMM $XdotOrg: xc/programs/Xserver/GL/mesa/main/Imakefile,v 1.2 2004/08/19 07:34:43 kem Exp $
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/math/Imakefile,v 1.8 2002/11/22 22:56:01 tsi Exp $
+
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+/* Large PIC tables needed for Solaris/SPARC builds */
+#if defined(SunArchitecture) && defined(SparcArchitecture) && defined(LargePositionIndependentCFlags)
+ PICFLAGS = LargePositionIndependentCFlags
+#endif
+
+#include <Server.tmpl>
+
+#define NeedAllMesaSrc
+#define NeedToLinkMesaSrc
+#define MesaBuildDir /**/
+#if !defined(IHaveModules) || !BuildModuleInSubdir
+#include "../../../../../lib/GL/mesa/main/Imakefile.inc"
+#else
+#include "../../../../../../lib/GL/mesa/main/Imakefile.inc"
+#endif
+
+ SRCS = $(COREMESABASESRCS)
+ OBJS = $(COREMESABASEOBJS)
+
+ INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/include \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/GL/include -I$(SERVERSRC)/GL/glx \
+ -I$(LIBSRC)/GL/include \
+ -I$(XF86SRC) -I$(INCLUDESRC)
+
+ DEFINES = $(GLX_DEFINES) /*-DUSE_X86_ASM*/ /*-DUSE_SPARC_ASM*/
+
+#ifdef IHaveModules
+ModuleObjectRule()
+#else
+NormalLibraryObjectRule()
+#endif
+
+SubdirLibraryRule($(OBJS))
+
+LintLibraryTarget(dri,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/main/module/Imakefile b/nx-X11/programs/Xserver/GL/mesa/main/module/Imakefile
new file mode 100644
index 000000000..e21afd5e5
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/main/module/Imakefile
@@ -0,0 +1,6 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/math/module/Imakefile,v 1.1 2002/05/31 18:12:40 dawes Exp $
+
+#define IHaveModules
+
+#include "../Imakefile"
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/math/Imakefile b/nx-X11/programs/Xserver/GL/mesa/math/Imakefile
new file mode 100644
index 000000000..49720974c
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/math/Imakefile
@@ -0,0 +1,55 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/math/Imakefile,v 1.8 2002/11/22 22:56:01 tsi Exp $
+
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+#include <Server.tmpl>
+
+#define NeedAllMesaSrc
+#define NeedToLinkMesaSrc
+#define MesaMathBuildDir /**/
+#if !defined(IHaveModules) || !BuildModuleInSubdir
+#include "../../../../../lib/GL/mesa/math/Imakefile.inc"
+#else
+#include "../../../../../../lib/GL/mesa/math/Imakefile.inc"
+#endif
+
+ SRCS = $(MESA_MATH_SRCS)
+ OBJS = $(MESA_MATH_OBJS)
+
+ INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/math \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/include \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/GL/include -I$(SERVERSRC)/GL/glx \
+ -I$(LIBSRC)/GL/include \
+ -I$(XF86SRC) -I$(INCLUDESRC)
+
+ DEFINES = $(GLX_DEFINES) /*-DUSE_X86_ASM*/ /*-DUSE_SPARC_ASM*/
+
+#ifdef IHaveModules
+ModuleObjectRule()
+#else
+NormalLibraryObjectRule()
+#endif
+
+SubdirLibraryRule($(OBJS))
+
+LintLibraryTarget(dri,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/math/module/Imakefile b/nx-X11/programs/Xserver/GL/mesa/math/module/Imakefile
new file mode 100644
index 000000000..e21afd5e5
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/math/module/Imakefile
@@ -0,0 +1,6 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/math/module/Imakefile,v 1.1 2002/05/31 18:12:40 dawes Exp $
+
+#define IHaveModules
+
+#include "../Imakefile"
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/shader/Imakefile b/nx-X11/programs/Xserver/GL/mesa/shader/Imakefile
new file mode 100644
index 000000000..7b14ab7b9
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/shader/Imakefile
@@ -0,0 +1,59 @@
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+#if !defined(IHaveModules) || !BuildModuleInSubdir
+#define IHaveSubdirs
+ SUBDIRS = grammar slang
+#endif
+
+#include <Server.tmpl>
+
+#define NeedAllMesaSrc
+#define NeedToLinkMesaSrc
+#define MesaShaderBuildDir /**/
+#if !defined(IHaveModules) || !BuildModuleInSubdir
+#include "../../../../../lib/GL/mesa/shader/Imakefile.inc"
+#else
+#include "../../../../../../lib/GL/mesa/shader/Imakefile.inc"
+#endif
+
+ SRCS = $(MESA_SHADER_SRCS)
+ OBJS = $(MESA_SHADER_OBJS)
+
+ INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/src/mesa/shader/grammar \
+ -I$(MESASRCDIR)/src/mesa/shader/slang \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/include \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/GL/include -I$(SERVERSRC)/GL/glx \
+ -I$(LIBSRC)/GL/include \
+ -I$(XF86SRC) -I$(INCLUDESRC)
+
+ DEFINES = $(GLX_DEFINES) /*-DUSE_X86_ASM*/ /*-DUSE_SPARC_ASM*/
+
+#ifdef IHaveModules
+ModuleObjectRule()
+#else
+NormalLibraryObjectRule()
+#endif
+
+SubdirLibraryRule($(OBJS))
+
+LintLibraryTarget(dri,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
diff --git a/nx-X11/programs/Xserver/GL/mesa/shader/grammar/Imakefile b/nx-X11/programs/Xserver/GL/mesa/shader/grammar/Imakefile
new file mode 100644
index 000000000..c16b3ddad
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/shader/grammar/Imakefile
@@ -0,0 +1,54 @@
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+#include <Server.tmpl>
+
+#define NeedAllMesaSrc
+#define NeedToLinkMesaSrc
+#define MesaGrammarBuildDir /**/
+#if !defined(IHaveModules) || !BuildModuleInSubdir
+#include "../../../../../../lib/GL/mesa/shader/grammar/Imakefile.inc"
+#else
+#include "../../../../../../../lib/GL/mesa/shader/grammar/Imakefile.inc"
+#endif
+
+ SRCS = $(MESA_GRAMMAR_SRCS)
+ OBJS = $(MESA_GRAMMAR_OBJS)
+
+ INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/src/mesa/shader/grammar \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/include \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/GL/include -I$(SERVERSRC)/GL/glx \
+ -I$(LIBSRC)/GL/include \
+ -I$(XF86SRC) -I$(INCLUDESRC)
+
+ DEFINES = $(GLX_DEFINES) /*-DUSE_X86_ASM*/ /*-DUSE_SPARC_ASM*/
+
+#ifdef IHaveModules
+ModuleObjectRule()
+#else
+NormalLibraryObjectRule()
+#endif
+
+SubdirLibraryRule($(OBJS))
+
+LintLibraryTarget(dri,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/shader/slang/Imakefile b/nx-X11/programs/Xserver/GL/mesa/shader/slang/Imakefile
new file mode 100644
index 000000000..0bee2b774
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/shader/slang/Imakefile
@@ -0,0 +1,59 @@
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+#if !defined(IHaveModules) || !BuildModuleInSubdir
+#define IHaveSubdirs
+ SUBDIRS = library
+#endif
+
+#include <Server.tmpl>
+
+#define NeedAllMesaSrc
+#define NeedToLinkMesaSrc
+#define MesaSlangBuildDir /**/
+#if !defined(IHaveModules) || !BuildModuleInSubdir
+#include "../../../../../../lib/GL/mesa/shader/slang/Imakefile.inc"
+#else
+#include "../../../../../../../lib/GL/mesa/shader/slang/Imakefile.inc"
+#endif
+
+ SRCS = $(MESA_SLANG_SRCS)
+ OBJS = $(MESA_SLANG_OBJS)
+
+ INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/src/mesa/shader/grammar \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/include \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/GL/include -I$(SERVERSRC)/GL/glx \
+ -I$(LIBSRC)/GL/include \
+ -I$(XF86SRC) -I$(INCLUDESRC)
+
+ DEFINES = $(GLX_DEFINES) /*-DUSE_X86_ASM*/ /*-DUSE_SPARC_ASM*/
+
+#ifdef IHaveModules
+ModuleObjectRule()
+#else
+NormalLibraryObjectRule()
+#endif
+
+SubdirLibraryRule($(OBJS))
+
+LintLibraryTarget(dri,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/shader/slang/library/Imakefile b/nx-X11/programs/Xserver/GL/mesa/shader/slang/library/Imakefile
new file mode 100644
index 000000000..e332121c9
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/shader/slang/library/Imakefile
@@ -0,0 +1,46 @@
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+#include <Server.tmpl>
+
+#define NeedAllMesaSrc
+#define NeedToLinkMesaSrc
+#define MesaLibraryBuildDir /**/
+#if !defined(IHaveModules) || !BuildModuleInSubdir
+#include "../../../../../../../lib/GL/mesa/shader/slang/library/Imakefile.inc"
+#else
+#include "../../../../../../../../lib/GL/mesa/shader/slang/library/Imakefile.inc"
+#endif
+
+ INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/src/mesa/shader/grammar \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/include \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/GL/include -I$(SERVERSRC)/GL/glx \
+ -I$(LIBSRC)/GL/include \
+ -I$(XF86SRC) -I$(INCLUDESRC)
+
+ DEFINES = $(GLX_DEFINES) /*-DUSE_X86_ASM*/ /*-DUSE_SPARC_ASM*/
+
+#ifdef IHaveModules
+ModuleObjectRule()
+#else
+NormalLibraryObjectRule()
+#endif
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/swrast/Imakefile b/nx-X11/programs/Xserver/GL/mesa/swrast/Imakefile
new file mode 100644
index 000000000..817fead69
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/swrast/Imakefile
@@ -0,0 +1,63 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/swrast/Imakefile,v 1.8 2002/11/22 22:56:01 tsi Exp $
+
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+/* Large PIC tables needed for Solaris/SPARC builds */
+#if defined(SunArchitecture) && defined(SparcArchitecture) && defined(LargePositionIndependentCFlags)
+ PICFLAGS = LargePositionIndependentCFlags
+#endif
+
+#include <Server.tmpl>
+
+#define NeedAllMesaSrc
+#define NeedToLinkMesaSrc
+#define MesaSwrastBuildDir /**/
+#if !defined(IHaveModules) || !BuildModuleInSubdir
+#include "../../../../../lib/GL/mesa/swrast/Imakefile.inc"
+#else
+#include "../../../../../../lib/GL/mesa/swrast/Imakefile.inc"
+#endif
+
+
+ SRCS = $(MESA_SWRAST_SRCS)
+ OBJS = $(MESA_SWRAST_OBJS)
+
+ INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/swrast \
+ -I$(MESASRCDIR)/src/mesa/swrast_setup \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/include \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/GL/include -I$(SERVERSRC)/GL/glx \
+ -I$(LIBSRC)/GL/include \
+ -I$(XF86SRC) -I$(INCLUDESRC)
+
+ DEFINES = $(GLX_DEFINES) /*-DUSE_X86_ASM*/ /*-DUSE_SPARC_ASM*/
+
+#ifdef IHaveModules
+ModuleObjectRule()
+#else
+NormalLibraryObjectRule()
+#endif
+
+SubdirLibraryRule($(OBJS))
+
+LintLibraryTarget(dri,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/swrast/module/Imakefile b/nx-X11/programs/Xserver/GL/mesa/swrast/module/Imakefile
new file mode 100644
index 000000000..7d9974ed0
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/swrast/module/Imakefile
@@ -0,0 +1,6 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/swrast/module/Imakefile,v 1.1 2002/05/31 18:12:40 dawes Exp $
+
+#define IHaveModules
+
+#include "../Imakefile"
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/swrast_setup/Imakefile b/nx-X11/programs/Xserver/GL/mesa/swrast_setup/Imakefile
new file mode 100644
index 000000000..b530457e9
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/swrast_setup/Imakefile
@@ -0,0 +1,55 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/swrast_setup/Imakefile,v 1.8 2002/11/22 22:56:01 tsi Exp $
+
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+#include <Server.tmpl>
+
+#define NeedAllMesaSrc
+#define NeedToLinkMesaSrc
+#define MesaSwrastSetupBuildDir /**/
+#if !defined(IHaveModules) || !BuildModuleInSubdir
+#include "../../../../../lib/GL/mesa/swrast_setup/Imakefile.inc"
+#else
+#include "../../../../../../lib/GL/mesa/swrast_setup/Imakefile.inc"
+#endif
+
+ SRCS = $(MESA_SWR_SETUP_SRCS)
+ OBJS = $(MESA_SWR_SETUP_OBJS)
+
+ INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/swrast_setup \
+ -I$(MESASRCDIR)/include \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/GL/include -I$(SERVERSRC)/GL/glx \
+ -I$(LIBSRC)/GL/include \
+ -I$(XF86SRC) -I$(INCLUDESRC)
+
+ DEFINES = $(GLX_DEFINES) /*-DUSE_X86_ASM*/ /*-DUSE_SPARC_ASM*/
+
+#ifdef IHaveModules
+ModuleObjectRule()
+#else
+NormalLibraryObjectRule()
+#endif
+
+SubdirLibraryRule($(OBJS))
+
+LintLibraryTarget(dri,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/swrast_setup/module/Imakefile b/nx-X11/programs/Xserver/GL/mesa/swrast_setup/module/Imakefile
new file mode 100644
index 000000000..5221debc0
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/swrast_setup/module/Imakefile
@@ -0,0 +1,6 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/swrast_setup/module/Imakefile,v 1.1 2002/05/31 18:12:41 dawes Exp $
+
+#define IHaveModules
+
+#include "../Imakefile"
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/tnl/Imakefile b/nx-X11/programs/Xserver/GL/mesa/tnl/Imakefile
new file mode 100644
index 000000000..c52696e4f
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/tnl/Imakefile
@@ -0,0 +1,66 @@
+XCOMM $XdotOrg: xc/programs/Xserver/GL/mesa/tnl/Imakefile,v 1.2 2004/08/19 07:34:44 kem Exp $
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/tnl/Imakefile,v 1.8 2002/11/22 22:56:02 tsi Exp $
+
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+/* Large PIC tables needed for Solaris/SPARC builds */
+#if defined(SunArchitecture) && defined(SparcArchitecture) && defined(LargePositionIndependentCFlags)
+ PICFLAGS = LargePositionIndependentCFlags
+#endif
+
+
+#include <Server.tmpl>
+
+#define NeedAllMesaSrc
+#define NeedToLinkMesaSrc
+#define MesaTnlBuildDir /**/
+#if !defined(IHaveModules) || !BuildModuleInSubdir
+#include "../../../../../lib/GL/mesa/tnl/Imakefile.inc"
+#else
+#include "../../../../../../lib/GL/mesa/tnl/Imakefile.inc"
+#endif
+
+
+ SRCS = $(MESA_TNL_SRCS)
+ OBJS = $(MESA_TNL_OBJS)
+
+ INCLUDES = -I$(MESASRCDIR)/src/mesa \
+ -I$(MESASRCDIR)/src/mesa/array_cache \
+ -I$(MESASRCDIR)/src/mesa/math \
+ -I$(MESASRCDIR)/src/mesa/main \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ -I$(MESASRCDIR)/src/mesa/shader \
+ -I$(MESASRCDIR)/src/mesa/tnl \
+ -I$(MESASRCDIR)/include \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/GL/include -I$(SERVERSRC)/GL/glx \
+ -I$(LIBSRC)/GL/include \
+ -I$(XF86SRC) -I$(INCLUDESRC)
+
+ DEFINES = $(GLX_DEFINES) /*-DUSE_X86_ASM*/ /*-DUSE_SPARC_ASM*/
+
+#ifdef IHaveModules
+ModuleObjectRule()
+#else
+NormalLibraryObjectRule()
+#endif
+
+SubdirLibraryRule($(OBJS))
+
+LintLibraryTarget(dri,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
diff --git a/nx-X11/programs/Xserver/GL/mesa/tnl/module/Imakefile b/nx-X11/programs/Xserver/GL/mesa/tnl/module/Imakefile
new file mode 100644
index 000000000..5d2a4489d
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/mesa/tnl/module/Imakefile
@@ -0,0 +1,6 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/tnl/module/Imakefile,v 1.1 2002/05/31 18:12:42 dawes Exp $
+
+#define IHaveModules
+
+#include "../Imakefile"
+
diff --git a/nx-X11/programs/Xserver/GL/opengl/Imakefile b/nx-X11/programs/Xserver/GL/opengl/Imakefile
new file mode 100644
index 000000000..420405d9c
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/opengl/Imakefile
@@ -0,0 +1,140 @@
+XCOMM $XFree86$
+
+XCOMM The contents of this file are subject to the GLX Public License Version 1.0
+XCOMM (the "License"). You may not use this file except in compliance with the
+XCOMM License. You may obtain a copy of the License at Silicon Graphics, Inc.,
+XCOMM attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA 94043
+XCOMM or at http://www.sgi.com/software/opensource/glx/license.html.
+XCOMM
+XCOMM Software distributed under the License is distributed on an "AS IS"
+XCOMM basis. ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY
+XCOMM IMPLIED WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
+XCOMM PURPOSE OR OF NON- INFRINGEMENT. See the License for the specific
+XCOMM language governing rights and limitations under the License.
+XCOMM
+XCOMM The Original Software is GLX version 1.2 source code, released February,
+XCOMM 1999. The developer of the Original Software is Silicon Graphics, Inc.
+XCOMM Those portions of the Subject Software created by Silicon Graphics, Inc.
+XCOMM are Copyright (c) 1991-9 Silicon Graphics, Inc. All Rights Reserved.
+
+#include <Library.tmpl>
+
+OBJS = \
+ ddxci.o \
+ ddxcx.o \
+ ddxrgb.o \
+ ddxscreens.o \
+ dl_block.o \
+ dl_heap.o \
+ dl_init.o \
+ dl_list.o \
+ dl_mopt.o \
+ dl_opt.o \
+ dl_pplst.o \
+ dl_splc.o \
+ dl_splst.o \
+ dl_table.o \
+ g_api.o \
+ g_disp.o \
+ g_lcmpex.o \
+ g_lcomp.o \
+ g_lexec.o \
+ g_ltab.o \
+ g_noptab.o \
+ g_splcmp.o \
+ px_api.o \
+ px_mod.o \
+ px_pack.o \
+ px_paths.o \
+ px_read.o \
+ px_rend.o \
+ px_upack.o \
+ s_accum.o \
+ s_atest.o \
+ s_attrib.o \
+ s_bitmap.o \
+ s_blend.o \
+ s_btdraw.o \
+ s_buffer.o \
+ s_capi.o \
+ s_ci.o \
+ s_clear.o \
+ s_clip.o \
+ s_contxt.o \
+ s_cpydsp.o \
+ s_ctable.o \
+ s_depth.o \
+ s_dlist.o \
+ s_eval.o \
+ s_export.o \
+ s_feed.o \
+ s_finish.o \
+ s_fog.o \
+ s_get.o \
+ s_global.o \
+ s_image.o \
+ s_lcache.o \
+ s_lcomp.o \
+ s_light.o \
+ s_lnclip.o \
+ s_lndraw.o \
+ s_lnfast.o \
+ s_lnfin.o \
+ s_lnspan.o \
+ s_math.o \
+ s_memmgr.o \
+ s_names.o \
+ s_napi.o \
+ s_pgaa.o \
+ s_pgclip.o \
+ s_pgdraw.o \
+ s_pgfin.o \
+ s_pgmode.o \
+ s_pgspan.o \
+ s_pick.o \
+ s_prim.o \
+ s_ptaa.o \
+ s_ptdraw.o \
+ s_ptfin.o \
+ s_rapi.o \
+ s_rect.o \
+ s_rgb.o \
+ s_rpos.o \
+ s_select.o \
+ s_size.o \
+ s_span.o \
+ s_sten.o \
+ s_store.o \
+ s_tapi.o \
+ s_tex.o \
+ s_texel.o \
+ s_texmgr.o \
+ s_trap.o \
+ s_vapi.o \
+ s_varray.o \
+ s_vertex.o \
+ s_xform.o \
+ s_zfuncs.o \
+ vc_cache.o \
+ vc_line.o \
+ vc_point.o \
+ vc_poly.o
+
+INCLUDES = \
+ -I. \
+ -I.. \
+ -Iinclude \
+ -I$(TOP)/server/include \
+ -I$(TOP)/programs/Xserver/include \
+ -I$(TOP)/include \
+ -I$(TOP)/include/GL \
+ -I$(INCLUDESRC)
+
+DEFINES = \
+ -D_LANGUAGE_C \
+ -Dunix
+
+NormalLibraryTarget(GL, $(OBJS))
+NormalLibraryObjectRule()
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/GL/windows/ChangeLog b/nx-X11/programs/Xserver/GL/windows/ChangeLog
new file mode 100644
index 000000000..43a817d6a
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/windows/ChangeLog
@@ -0,0 +1,64 @@
+2005-09-27 Ian Romanick <idr@us.ibm.com>
+
+ * indirect.c:
+ Remove __glEvalComputeK. It is no longer used.
+
+
+2005-04-09 Alexander Gottwald <ago at freedesktop dot org>
+
+ * indirect.c:
+ Fix passing of non-RGB visuals. The old code did not initialize the
+ structure properly which lead to a crash in 8bpp mode
+
+2005-03-01 Alexander Gottwald <ago at freedesktop dot org>
+
+ * indirect.c:
+ * glwindows.h:
+ If a context is already attached copy it instead of reattaching to keep
+ displaylists and share displaylists
+ Enable tracing of often called functions with GLWIN_ENABLE_TRACE
+ ForceCurrent is a no-op now
+
+2005-02-02 Alexander Gottwald <ago at freedesktop dot org>
+
+ * Imakefile:
+ Bugzilla #1866 (https://bugs.freedesktop.org/show_bug.cgi?id=1866)
+ attachment #1819 (https://bugs.freedesktop.org/attachment.cgi?id=1819):
+ Define APIENTRY on windows to prevent <GL/gl.h> from loading <windows.h>
+
+2005-02-02 Alexander Gottwald <ago at freedesktop dot org>
+
+ * glwrap.c:
+ * glwindows.h:
+ Bugzilla #1866 (https://bugs.freedesktop.org/show_bug.cgi?id=1866)
+ attachment #1818 (https://bugs.freedesktop.org/attachment.cgi?id=1818):
+ Include Xwindows.h before GL/gl.h to prevent loading windows.h which
+ pollutes our namespace with some symbols.
+
+2005-01-27 Alexander Gottwald <ago at freedesktop dot org>
+
+ * glwrap.c:
+ Functions like glGenTextures and glBindTexture are in OpenGL 1.1
+ and can be resolved at linktime.
+
+2004-11-15 Alexander Gottwald <ago at freedesktop dot org>
+
+ * indirect.c:
+ Bugzilla #1802, http://freedesktop.org/bugzilla/show_bug.cgi?id=1802
+ Added mingw (Win32) port
+
+2004-08-13 Alexander Gottwald <ago@freedesktop.org>
+
+ * Imakefile: Added $(MESASRCDIR)/src/mesa/glapi to INCLUDES.
+ Removed $(SERVERSRC)/mi from INCLUDES.
+ Rearranged INCLUDES for better readability.
+ * glwindows.h: Removed mipointrst.h and miscstruct.h from #include
+ since they are not used anymore.
+
+2004-05-27 Alexander Gottwald <ago@freedesktop.org>
+
+ * glwindows.h: write current function and line in debug output
+ * indirect.c: moved actual setup and creation of windows GL context to
+ glWinCreateContextReal.
+ * indirect.c (glWinCreateContext): Deferred context creation to attach.
+ * indirect.c (glWinMakeCurrent): Check if context is NULL. Fixes segfault.
diff --git a/nx-X11/programs/Xserver/GL/windows/Imakefile b/nx-X11/programs/Xserver/GL/windows/Imakefile
new file mode 100755
index 000000000..2b3ddeb12
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/windows/Imakefile
@@ -0,0 +1,36 @@
+#include <Server.tmpl>
+
+LinkSourceFile(compsize.c,$(MESASRCDIR)/src/glx/x11)
+
+ SRCS = compsize.c indirect.c glwrap.c
+ OBJS = compsize.o indirect.o glwrap.o
+
+ INCLUDES = -I. \
+ -I$(INCLUDESRC) \
+ -I$(XINCLUDESRC) \
+ -I$(EXTINCSRC) \
+ -I$(SERVERSRC)/include \
+ -I$(SERVERSRC)/render \
+ -I$(SERVERSRC)/hw/xwin \
+ -I$(SERVERSRC)/GL/include \
+ -I$(SERVERSRC)/GL/glx \
+ -I$(LIBSRC)/GL/glx \
+ -I$(LIBSRC)/GL/include \
+ -I$(MESASRCDIR)/include \
+ -I$(MESASRCDIR)/src \
+ -I$(MESASRCDIR)/src/mesa/glapi \
+ $(GL_INCLUDES)
+
+#if defined(GlxUseWindows) && GlxUseWindows
+ CYGWIN_GL_DEFINES = -DUSE_OPENGL32
+#endif
+#if defined(Win32Architecture)
+# undef __stdcall
+ APIENTRY_DEFS = -DAPIENTRY=__stdcall
+#endif
+ DEFINES = $(GLX_DEFINES) $(CYGWIN_GL_DEFINES) $(APIENTRY_DEFS)
+
+NormalLibraryTarget(GLcore,$(OBJS))
+NormalLibraryObjectRule()
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/GL/windows/glwindows.h b/nx-X11/programs/Xserver/GL/windows/glwindows.h
new file mode 100644
index 000000000..74e81f24f
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/windows/glwindows.h
@@ -0,0 +1,64 @@
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xwindows.h>
+#include <GL/gl.h>
+#include <GL/glext.h>
+
+#include <glxserver.h>
+#include <glxext.h>
+
+#include <windowstr.h>
+#include <resource.h>
+#include <GL/glxint.h>
+#include <GL/glxtokens.h>
+#include <scrnintstr.h>
+#include <glxserver.h>
+#include <glxscreens.h>
+#include <glxdrawable.h>
+#include <glxcontext.h>
+#include <glxext.h>
+#include <glxutil.h>
+#include <glxscreens.h>
+#include <GL/internal/glcore.h>
+#include <stdlib.h>
+
+
+typedef struct {
+ unsigned enableDebug : 1;
+ unsigned enableTrace : 1;
+ unsigned dumpPFD : 1;
+ unsigned dumpHWND : 1;
+ unsigned dumpDC : 1;
+} glWinDebugSettingsRec, *glWinDebugSettingsPtr;
+extern glWinDebugSettingsRec glWinDebugSettings;
+
+typedef struct {
+ int num_vis;
+ __GLcontextModes *modes;
+ void **priv;
+
+ /* wrapped screen functions */
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ CopyWindowProcPtr CopyWindow;
+} glWinScreenRec;
+
+extern glWinScreenRec glWinScreens[MAXSCREENS];
+
+#define glWinGetScreenPriv(pScreen) &glWinScreens[pScreen->myNum]
+#define glWinScreenPriv(pScreen) glWinScreenRec *pScreenPriv = glWinGetScreenPriv(pScreen);
+
+#if 1
+#define GLWIN_TRACE() if (glWinDebugSettings.enableTrace) ErrorF("%s:%d: Trace\n", __FUNCTION__, __LINE__ )
+#define GLWIN_TRACE_MSG(msg, args...) if (glWinDebugSettings.enableTrace) ErrorF("%s:%d: " msg, __FUNCTION__, __LINE__, ##args )
+#define GLWIN_DEBUG_MSG(msg, args...) if (glWinDebugSettings.enableDebug) ErrorF("%s:%d: " msg, __FUNCTION__, __LINE__, ##args )
+#define GLWIN_DEBUG_MSG2(msg, args...) if (glWinDebugSettings.enableDebug) ErrorF(msg, ##args )
+#else
+#define GLWIN_TRACE()
+#define GLWIN_TRACE_MSG(a, ...)
+#define GLWIN_DEBUG_MSG(a, ...)
+#define GLWIN_DEBUG_MSG2(a, ...)
+#endif
+
diff --git a/nx-X11/programs/Xserver/GL/windows/glwrap.c b/nx-X11/programs/Xserver/GL/windows/glwrap.c
new file mode 100755
index 000000000..f0b38b228
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/windows/glwrap.c
@@ -0,0 +1,583 @@
+/*
+ * GLX implementation that uses Win32's OpenGL
+ * Wrapper functions for Win32's OpenGL
+ *
+ * Authors: Alexander Gottwald
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xwindows.h>
+#include <GL/gl.h>
+#include <GL/glext.h>
+#include <glxserver.h>
+#include <glxext.h>
+
+#define RESOLVE_RET(procname, symbol, retval) \
+ static Bool init = TRUE; \
+ static procname proc = NULL; \
+ if (init) { \
+ proc = (procname)wglGetProcAddress(symbol); \
+ init = FALSE; \
+ if (proc == NULL) { \
+ ErrorF("glwrap: Can't resolve \"%s\"\n", symbol); \
+ } else \
+ ErrorF("glwrap: resolved \"%s\"\n", symbol); \
+ } \
+ if (proc == NULL) { \
+ __glXErrorCallBack(NULL, 0); \
+ return retval; \
+ }
+#define RESOLVE(procname, symbol) RESOLVE_RET(procname, symbol,)
+
+
+/*
+ * GL_ARB_imaging
+ */
+
+
+GLAPI void GLAPIENTRY glColorTable( GLenum target, GLenum internalformat,
+ GLsizei width, GLenum format,
+ GLenum type, const GLvoid *table )
+{
+ RESOLVE(PFNGLCOLORTABLEPROC, "glColorTable");
+ proc(target, internalformat, width, format, type, table);
+}
+
+GLAPI void GLAPIENTRY glColorSubTable( GLenum target,
+ GLsizei start, GLsizei count,
+ GLenum format, GLenum type,
+ const GLvoid *data )
+{
+ RESOLVE(PFNGLCOLORSUBTABLEPROC, "glColorSubTable");
+ proc(target, start, count, format, type, data);
+}
+
+GLAPI void GLAPIENTRY glColorTableParameteriv(GLenum target, GLenum pname,
+ const GLint *params)
+{
+ RESOLVE(PFNGLCOLORTABLEPARAMETERIVPROC, "glColorTableParameteriv");
+ proc(target, pname, params);
+}
+
+GLAPI void GLAPIENTRY glColorTableParameterfv(GLenum target, GLenum pname,
+ const GLfloat *params)
+{
+ RESOLVE(PFNGLCOLORTABLEPARAMETERFVPROC, "glColorTableParameterfv");
+ proc(target, pname, params);
+}
+
+GLAPI void GLAPIENTRY glCopyColorSubTable( GLenum target, GLsizei start,
+ GLint x, GLint y, GLsizei width )
+{
+ RESOLVE(PFNGLCOPYCOLORSUBTABLEPROC, "glCopyColorSubTable");
+ proc(target, start, x, y, width);
+}
+
+GLAPI void GLAPIENTRY glCopyColorTable( GLenum target, GLenum internalformat,
+ GLint x, GLint y, GLsizei width )
+{
+ RESOLVE(PFNGLCOPYCOLORTABLEPROC, "glCopyColorTable");
+ proc(target, internalformat, x, y, width);
+}
+
+
+GLAPI void GLAPIENTRY glGetColorTable( GLenum target, GLenum format,
+ GLenum type, GLvoid *table )
+{
+ RESOLVE(PFNGLGETCOLORTABLEPROC, "glGetColorTable");
+ proc(target, format, type, table);
+}
+
+GLAPI void GLAPIENTRY glGetColorTableParameterfv( GLenum target, GLenum pname,
+ GLfloat *params )
+{
+ RESOLVE(PFNGLGETCOLORTABLEPARAMETERFVPROC, "glGetColorTableParameterfv");
+ proc(target, pname, params);
+}
+
+GLAPI void GLAPIENTRY glGetColorTableParameteriv( GLenum target, GLenum pname,
+ GLint *params )
+{
+ RESOLVE(PFNGLGETCOLORTABLEPARAMETERIVPROC, "glGetColorTableParameteriv");
+ proc(target, pname, params);
+}
+
+GLAPI void GLAPIENTRY glBlendEquation( GLenum mode )
+{
+ RESOLVE(PFNGLBLENDEQUATIONPROC, "glBlendEquation");
+ proc(mode);
+}
+
+GLAPI void GLAPIENTRY glBlendColor( GLclampf red, GLclampf green,
+ GLclampf blue, GLclampf alpha )
+{
+ RESOLVE(PFNGLBLENDCOLORPROC, "glBlendColor");
+ proc(red, green, blue, alpha);
+}
+
+GLAPI void GLAPIENTRY glHistogram( GLenum target, GLsizei width,
+ GLenum internalformat, GLboolean sink )
+{
+ RESOLVE(PFNGLHISTOGRAMPROC, "glHistogram");
+ proc(target, width, internalformat, sink);
+}
+
+GLAPI void GLAPIENTRY glResetHistogram( GLenum target )
+{
+ RESOLVE(PFNGLRESETHISTOGRAMPROC, "glResetHistogram");
+ proc(target);
+}
+
+GLAPI void GLAPIENTRY glGetHistogram( GLenum target, GLboolean reset,
+ GLenum format, GLenum type,
+ GLvoid *values )
+{
+ RESOLVE(PFNGLGETHISTOGRAMPROC, "glGetHistogram");
+ proc(target, reset, format, type, values);
+};
+
+GLAPI void GLAPIENTRY glGetHistogramParameterfv( GLenum target, GLenum pname,
+ GLfloat *params )
+{
+ RESOLVE(PFNGLGETHISTOGRAMPARAMETERFVPROC, "glGetHistogramParameterfv");
+ proc(target, pname, params);
+}
+
+GLAPI void GLAPIENTRY glGetHistogramParameteriv( GLenum target, GLenum pname,
+ GLint *params )
+{
+ RESOLVE(PFNGLGETHISTOGRAMPARAMETERIVPROC, "glGetHistogramParameteriv");
+ proc(target, pname, params);
+}
+
+GLAPI void GLAPIENTRY glMinmax( GLenum target, GLenum internalformat,
+ GLboolean sink )
+{
+ RESOLVE(PFNGLMINMAXPROC, "glMinmax");
+ proc(target, internalformat, sink);
+}
+
+GLAPI void GLAPIENTRY glResetMinmax( GLenum target )
+{
+ RESOLVE(PFNGLRESETMINMAXPROC, "glResetMinmax");
+ proc(target);
+}
+
+GLAPI void GLAPIENTRY glGetMinmax( GLenum target, GLboolean reset,
+ GLenum format, GLenum types,
+ GLvoid *values )
+{
+ RESOLVE(PFNGLGETMINMAXPROC, "glGetMinmax");
+ proc(target, reset, format, types, values);
+}
+
+GLAPI void GLAPIENTRY glGetMinmaxParameterfv( GLenum target, GLenum pname,
+ GLfloat *params )
+{
+ RESOLVE(PFNGLGETMINMAXPARAMETERFVPROC, "glGetMinmaxParameterfv");
+ proc(target, pname, params);
+}
+
+GLAPI void GLAPIENTRY glGetMinmaxParameteriv( GLenum target, GLenum pname,
+ GLint *params )
+{
+ RESOLVE(PFNGLGETMINMAXPARAMETERIVPROC, "glGetMinmaxParameteriv");
+ proc(target, pname, params);
+}
+
+GLAPI void GLAPIENTRY glConvolutionFilter1D( GLenum target,
+ GLenum internalformat, GLsizei width, GLenum format, GLenum type,
+ const GLvoid *image )
+{
+ RESOLVE(PFNGLCONVOLUTIONFILTER1DPROC, "glConvolutionFilter1D");
+ proc(target, internalformat, width, format, type, image);
+}
+
+GLAPI void GLAPIENTRY glConvolutionFilter2D( GLenum target,
+ GLenum internalformat, GLsizei width, GLsizei height, GLenum format,
+ GLenum type, const GLvoid *image )
+{
+ RESOLVE(PFNGLCONVOLUTIONFILTER2DPROC, "glConvolutionFilter2D");
+ proc(target, internalformat, width, height, format, type, image);
+}
+
+GLAPI void GLAPIENTRY glConvolutionParameterf( GLenum target, GLenum pname,
+ GLfloat params )
+{
+ RESOLVE(PFNGLCONVOLUTIONPARAMETERFPROC, "glConvolutionParameterf");
+ proc(target, pname, params);
+}
+
+GLAPI void GLAPIENTRY glConvolutionParameterfv( GLenum target, GLenum pname,
+ const GLfloat *params )
+{
+ RESOLVE(PFNGLCONVOLUTIONPARAMETERFVPROC, "glConvolutionParameterfv");
+ proc(target, pname, params);
+}
+
+GLAPI void GLAPIENTRY glConvolutionParameteri( GLenum target, GLenum pname,
+ GLint params )
+{
+ RESOLVE(PFNGLCONVOLUTIONPARAMETERIPROC, "glConvolutionParameteri");
+ proc(target, pname, params);
+}
+
+GLAPI void GLAPIENTRY glConvolutionParameteriv( GLenum target, GLenum pname,
+ const GLint *params )
+{
+ RESOLVE(PFNGLCONVOLUTIONPARAMETERIVPROC, "glConvolutionParameteriv");
+ proc(target, pname, params);
+}
+
+GLAPI void GLAPIENTRY glCopyConvolutionFilter1D( GLenum target,
+ GLenum internalformat, GLint x, GLint y, GLsizei width )
+{
+ RESOLVE(PFNGLCOPYCONVOLUTIONFILTER1DPROC, "glCopyConvolutionFilter1D");
+ proc(target, internalformat, x, y, width);
+}
+
+GLAPI void GLAPIENTRY glCopyConvolutionFilter2D( GLenum target,
+ GLenum internalformat, GLint x, GLint y, GLsizei width,
+ GLsizei height)
+{
+ RESOLVE(PFNGLCOPYCONVOLUTIONFILTER2DPROC, "glCopyConvolutionFilter2D");
+ proc(target, internalformat, x, y, width, height);
+}
+
+GLAPI void GLAPIENTRY glGetConvolutionFilter( GLenum target, GLenum format,
+ GLenum type, GLvoid *image )
+{
+ RESOLVE(PFNGLGETCONVOLUTIONFILTERPROC, "glGetConvolutionFilter");
+ proc(target, format, type, image);
+}
+
+GLAPI void GLAPIENTRY glGetConvolutionParameterfv( GLenum target, GLenum pname,
+ GLfloat *params )
+{
+ RESOLVE(PFNGLGETCONVOLUTIONPARAMETERFVPROC, "glGetConvolutionParameterfv");
+ proc(target, pname, params);
+}
+
+GLAPI void GLAPIENTRY glGetConvolutionParameteriv( GLenum target, GLenum pname,
+ GLint *params )
+{
+ RESOLVE(PFNGLGETCONVOLUTIONPARAMETERIVPROC, "glGetConvolutionParameteriv");
+ proc(target, pname, params);
+}
+
+GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target,
+ GLenum internalformat, GLsizei width, GLsizei height, GLenum format,
+ GLenum type, const GLvoid *row, const GLvoid *column )
+{
+ RESOLVE(PFNGLSEPARABLEFILTER2DPROC, "glSeparableFilter2D");
+ proc(target, internalformat, width, height, format, type, row, column);
+}
+
+GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format,
+ GLenum type, GLvoid *row, GLvoid *column, GLvoid *span )
+{
+ RESOLVE(PFNGLGETSEPARABLEFILTERPROC, "glGetSeparableFilter");
+ proc(target, format, type, row, column, span);
+}
+
+/*
+ * OpenGL 1.2
+ */
+
+GLAPI void GLAPIENTRY glTexImage3D( GLenum target, GLint level,
+ GLint internalFormat,
+ GLsizei width, GLsizei height,
+ GLsizei depth, GLint border,
+ GLenum format, GLenum type,
+ const GLvoid *pixels )
+{
+ RESOLVE(PFNGLTEXIMAGE3DPROC, "glTexImage3D");
+ proc(target, level, internalFormat, width, height, depth, border, format, type, pixels);
+}
+
+GLAPI void GLAPIENTRY glTexSubImage3D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint zoffset, GLsizei width,
+ GLsizei height, GLsizei depth,
+ GLenum format,
+ GLenum type, const GLvoid *pixels)
+{
+ RESOLVE(PFNGLTEXSUBIMAGE3DPROC, "glTexSubImage3D");
+ proc(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
+}
+
+GLAPI void GLAPIENTRY glCopyTexSubImage3D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint zoffset, GLint x,
+ GLint y, GLsizei width,
+ GLsizei height )
+{
+ RESOLVE(PFNGLCOPYTEXSUBIMAGE3DPROC, "glCopyTexSubImage3D");
+ proc(target, level, xoffset, yoffset, zoffset, x, y, width, height);
+}
+
+
+/*
+ * 20. GL_EXT_texture_object
+ */
+GLAPI void GLAPIENTRY glGenTexturesEXT( GLsizei n, GLuint *textures )
+{
+ glGenTextures(n, textures);
+}
+
+GLAPI void GLAPIENTRY glDeleteTexturesEXT( GLsizei n, const GLuint *textures)
+{
+ glDeleteTextures(n, textures);
+}
+
+GLAPI void GLAPIENTRY glBindTextureEXT( GLenum target, GLuint texture )
+{
+ glBindTexture(target, target);
+}
+
+GLAPI void GLAPIENTRY glPrioritizeTexturesEXT( GLsizei n, const GLuint *textures, const GLclampf *priorities )
+{
+ glPrioritizeTextures(n, textures, priorities);
+}
+
+GLAPI GLboolean GLAPIENTRY glAreTexturesResidentEXT( GLsizei n, const GLuint *textures, GLboolean *residences )
+{
+ return glAreTexturesResident(n, textures, residences);
+}
+
+GLAPI GLboolean GLAPIENTRY glIsTextureEXT( GLuint texture )
+{
+ return glIsTexture(texture);
+}
+
+/*
+ * GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1)
+ */
+
+GLAPI void GLAPIENTRY glActiveTextureARB(GLenum texture)
+{
+ RESOLVE(PFNGLACTIVETEXTUREARBPROC, "glActiveTextureARB");
+ proc(texture);
+}
+
+GLAPI void GLAPIENTRY glMultiTexCoord1dvARB(GLenum target, const GLdouble *v)
+{
+ RESOLVE(PFNGLMULTITEXCOORD1DVARBPROC, "glMultiTexCoord1dvARB");
+ proc(target, v);
+}
+
+GLAPI void GLAPIENTRY glMultiTexCoord1fvARB(GLenum target, const GLfloat *v)
+{
+ RESOLVE(PFNGLMULTITEXCOORD1FVARBPROC, "glMultiTexCoord1fvARB");
+ proc(target, v);
+}
+
+GLAPI void GLAPIENTRY glMultiTexCoord1ivARB(GLenum target, const GLint *v)
+{
+ RESOLVE(PFNGLMULTITEXCOORD1IVARBPROC, "glMultiTexCoord1ivARB");
+ proc(target, v);
+}
+
+GLAPI void GLAPIENTRY glMultiTexCoord1svARB(GLenum target, const GLshort *v)
+{
+ RESOLVE(PFNGLMULTITEXCOORD1SVARBPROC, "glMultiTexCoord1svARB");
+ proc(target, v);
+}
+GLAPI void GLAPIENTRY glMultiTexCoord2dvARB(GLenum target, const GLdouble *v)
+{
+ RESOLVE(PFNGLMULTITEXCOORD2DVARBPROC, "glMultiTexCoord2dvARB");
+ proc(target, v);
+}
+GLAPI void GLAPIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v)
+{
+ RESOLVE(PFNGLMULTITEXCOORD2FVARBPROC, "glMultiTexCoord2fvARB");
+ proc(target, v);
+}
+GLAPI void GLAPIENTRY glMultiTexCoord2ivARB(GLenum target, const GLint *v)
+{
+ RESOLVE(PFNGLMULTITEXCOORD2IVARBPROC, "glMultiTexCoord2ivARB");
+ proc(target, v);
+}
+GLAPI void GLAPIENTRY glMultiTexCoord2svARB(GLenum target, const GLshort *v)
+{
+ RESOLVE(PFNGLMULTITEXCOORD1SVARBPROC, "glMultiTexCoord1svARB");
+ proc(target, v);
+}
+GLAPI void GLAPIENTRY glMultiTexCoord3dvARB(GLenum target, const GLdouble *v)
+{
+ RESOLVE(PFNGLMULTITEXCOORD3DVARBPROC, "glMultiTexCoord3dvARB");
+ proc(target, v);
+}
+GLAPI void GLAPIENTRY glMultiTexCoord3fvARB(GLenum target, const GLfloat *v)
+{
+ RESOLVE(PFNGLMULTITEXCOORD3FVARBPROC, "glMultiTexCoord3fvARB");
+ proc(target, v);
+}
+GLAPI void GLAPIENTRY glMultiTexCoord3ivARB(GLenum target, const GLint *v)
+{
+ RESOLVE(PFNGLMULTITEXCOORD3IVARBPROC, "glMultiTexCoord3ivARB");
+ proc(target, v);
+}
+GLAPI void GLAPIENTRY glMultiTexCoord3svARB(GLenum target, const GLshort *v)
+{
+ RESOLVE(PFNGLMULTITEXCOORD1SVARBPROC, "glMultiTexCoord1svARB");
+ proc(target, v);
+}
+GLAPI void GLAPIENTRY glMultiTexCoord4dvARB(GLenum target, const GLdouble *v)
+{
+ RESOLVE(PFNGLMULTITEXCOORD4DVARBPROC, "glMultiTexCoord4dvARB");
+ proc(target, v);
+}
+GLAPI void GLAPIENTRY glMultiTexCoord4fvARB(GLenum target, const GLfloat *v)
+{
+ RESOLVE(PFNGLMULTITEXCOORD4FVARBPROC, "glMultiTexCoord4fvARB");
+ proc(target, v);
+}
+GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v)
+{
+ RESOLVE(PFNGLMULTITEXCOORD4IVARBPROC, "glMultiTexCoord4ivARB");
+ proc(target, v);
+}
+GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v)
+{
+ RESOLVE(PFNGLMULTITEXCOORD1SVARBPROC, "glMultiTexCoord1svARB");
+ proc(target, v);
+}
+
+
+GLAPI void GLAPIENTRY glActiveStencilFaceEXT(GLenum face)
+{
+ RESOLVE(PFNGLACTIVESTENCILFACEEXTPROC, "glActiveStencilFaceEXT");
+ proc(face);
+}
+
+GLAPI void APIENTRY glPointParameterfARB(GLenum pname, GLfloat param)
+{
+ RESOLVE(PFNGLPOINTPARAMETERFARBPROC, "glPointParameterfARB");
+ proc(pname, param);
+}
+
+GLAPI void APIENTRY glPointParameterfvARB(GLenum pname, const GLfloat *params)
+{
+ RESOLVE(PFNGLPOINTPARAMETERFVARBPROC, "glPointParameterfvARB");
+ proc(pname, params);
+}
+
+
+GLAPI void APIENTRY glWindowPos3fARB(GLfloat x, GLfloat y, GLfloat z)
+{
+ RESOLVE(PFNGLWINDOWPOS3FARBPROC, "glWindowPos3fARB");
+ proc(x, y, z);
+}
+
+GLAPI void APIENTRY glPointParameteri(GLenum pname, GLint param)
+{
+ RESOLVE(PFNGLPOINTPARAMETERIPROC, "glPointParameteri");
+ proc(pname, param);
+}
+
+GLAPI void APIENTRY glPointParameteriv(GLenum pname, const GLint *params)
+{
+ RESOLVE(PFNGLPOINTPARAMETERIVPROC, "glPointParameteriv");
+ proc(pname, params);
+}
+
+GLAPI void APIENTRY glPointParameteriNV(GLenum pname, GLint param)
+{
+ RESOLVE(PFNGLPOINTPARAMETERINVPROC, "glPointParameteriNV");
+ proc(pname, param);
+}
+
+GLAPI void APIENTRY glPointParameterivNV(GLenum pname, const GLint *params)
+{
+ RESOLVE(PFNGLPOINTPARAMETERIVNVPROC, "glPointParameterivNV");
+ proc(pname, params);
+}
+
+GLAPI void APIENTRY glSecondaryColor3bv(const GLbyte *v)
+{
+ RESOLVE(PFNGLSECONDARYCOLOR3BVPROC, "glSecondaryColor3bv");
+ proc(v);
+}
+GLAPI void APIENTRY glSecondaryColor3dv(const GLdouble *v)
+{
+ RESOLVE(PFNGLSECONDARYCOLOR3DVPROC, "glSecondaryColor3dv");
+ proc(v);
+}
+GLAPI void APIENTRY glSecondaryColor3fv(const GLfloat *v)
+{
+ RESOLVE(PFNGLSECONDARYCOLOR3FVPROC, "glSecondaryColor3fv");
+ proc(v);
+}
+GLAPI void APIENTRY glSecondaryColor3iv(const GLint *v)
+{
+ RESOLVE(PFNGLSECONDARYCOLOR3IVPROC, "glSecondaryColor3iv");
+ proc(v);
+}
+GLAPI void APIENTRY glSecondaryColor3sv(const GLshort *v)
+{
+ RESOLVE(PFNGLSECONDARYCOLOR3SVPROC, "glSecondaryColor3sv");
+ proc(v);
+}
+GLAPI void APIENTRY glSecondaryColor3ubv(const GLubyte *v)
+{
+ RESOLVE(PFNGLSECONDARYCOLOR3UBVPROC, "glSecondaryColor3ubv");
+ proc(v);
+}
+GLAPI void APIENTRY glSecondaryColor3uiv(const GLuint *v)
+{
+ RESOLVE(PFNGLSECONDARYCOLOR3UIVPROC, "glSecondaryColor3uiv");
+ proc(v);
+}
+GLAPI void APIENTRY glSecondaryColor3usv(const GLushort *v)
+{
+ RESOLVE(PFNGLSECONDARYCOLOR3USVPROC, "glSecondaryColor3usv");
+ proc(v);
+}
+GLAPI void APIENTRY glSecondaryColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
+{
+ RESOLVE(PFNGLSECONDARYCOLORPOINTERPROC, "glSecondaryColorPointer");
+ proc(size, type, stride, pointer);
+}
+
+
+GLAPI void APIENTRY glBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
+{
+ RESOLVE(PFNGLBLENDFUNCSEPARATEPROC, "glBlendFuncSeparate");
+ proc(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
+}
+GLAPI void APIENTRY glFogCoordfv(const GLfloat *coord)
+{
+ RESOLVE(PFNGLFOGCOORDFVPROC, "glFogCoordfv");
+ proc(coord);
+}
+GLAPI void APIENTRY glFogCoorddv(const GLdouble *coord)
+{
+ RESOLVE(PFNGLFOGCOORDDVPROC, "glFogCoorddv");
+ proc(coord);
+}
+GLAPI void APIENTRY glFogCoordPointer(GLenum type, GLsizei stride, const GLvoid *pointer)
+{
+ RESOLVE(PFNGLFOGCOORDPOINTERPROC, "glFogCoordPointer");
+ proc(type, stride, pointer);
+}
+
+
+GLAPI void APIENTRY glSampleCoverageARB(GLclampf value, GLboolean invert)
+{
+ RESOLVE(PFNGLSAMPLECOVERAGEARBPROC, "glSampleCoverageARB");
+ proc(value, invert);
+}
+GLAPI void APIENTRY glSampleMaskSGIS(GLclampf value, GLboolean invert)
+{
+ RESOLVE(PFNGLSAMPLEMASKSGISPROC, "glSampleMaskSGIS");
+ proc(value, invert);
+}
+GLAPI void APIENTRY glSamplePatternSGIS(GLenum pattern)
+{
+ RESOLVE(PFNGLSAMPLEPATTERNSGISPROC, "glSamplePatternSGIS");
+ proc(pattern);
+}
diff --git a/nx-X11/programs/Xserver/GL/windows/indirect.c b/nx-X11/programs/Xserver/GL/windows/indirect.c
new file mode 100755
index 000000000..5e12022f4
--- /dev/null
+++ b/nx-X11/programs/Xserver/GL/windows/indirect.c
@@ -0,0 +1,1605 @@
+/*
+ * GLX implementation that uses Windows OpenGL library
+ * (Indirect rendering path)
+ *
+ * Authors: Alexander Gottwald
+ */
+/*
+ * Portions of this file are copied from GL/apple/indirect.c,
+ * which contains the following copyright:
+ *
+ * Copyright (c) 2002 Greg Parker. All Rights Reserved.
+ * Copyright (c) 2002 Apple Computer, Inc.
+ *
+ * Portions of this file are copied from xf86glx.c,
+ * which contains the following copyright:
+ *
+ * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "glwindows.h"
+#include <glcontextmodes.h>
+#include <stdint.h>
+
+#include <winpriv.h>
+
+#define GLWIN_DEBUG_HWND(hwnd) \
+ if (glWinDebugSettings.dumpHWND) { \
+ char buffer[1024]; \
+ if (GetWindowText(hwnd, buffer, sizeof(buffer))==0) *buffer=0; \
+ GLWIN_DEBUG_MSG("Got HWND %s (%p)\n", buffer, hwnd); \
+ }
+
+
+/* ggs: needed to call back to glx with visual configs */
+extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs);
+
+glWinDebugSettingsRec glWinDebugSettings = { 1, 0, 0, 0, 0};
+
+static void glWinInitDebugSettings(void)
+{
+ char *envptr;
+
+ envptr = getenv("GLWIN_ENABLE_DEBUG");
+ if (envptr != NULL)
+ glWinDebugSettings.enableDebug = (atoi(envptr) == 1);
+
+ envptr = getenv("GLWIN_ENABLE_TRACE");
+ if (envptr != NULL)
+ glWinDebugSettings.enableTrace = (atoi(envptr) == 1);
+
+ envptr = getenv("GLWIN_DUMP_PFD");
+ if (envptr != NULL)
+ glWinDebugSettings.dumpPFD = (atoi(envptr) == 1);
+
+ envptr = getenv("GLWIN_DUMP_HWND");
+ if (envptr != NULL)
+ glWinDebugSettings.dumpHWND = (atoi(envptr) == 1);
+
+ envptr = getenv("GLWIN_DUMP_DC");
+ if (envptr != NULL)
+ glWinDebugSettings.dumpDC = (atoi(envptr) == 1);
+}
+
+static char errorbuffer[1024];
+const char *glWinErrorMessage(void)
+{
+ if (!FormatMessage(
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &errorbuffer,
+ sizeof(errorbuffer),
+ NULL ))
+ {
+ snprintf(errorbuffer, sizeof(errorbuffer), "Unknown error in FormatMessage: %08x!\n", (unsigned)GetLastError());
+ }
+ return errorbuffer;
+}
+
+/*
+ * GLX implementation that uses Win32's OpenGL
+ */
+
+/*
+ * Server-side GLX uses these functions which are normally defined
+ * in the OpenGL SI.
+ */
+
+GLuint __glFloorLog2(GLuint val)
+{
+ int c = 0;
+
+ while (val > 1) {
+ c++;
+ val >>= 1;
+ }
+ return c;
+}
+
+/* some prototypes */
+static Bool glWinScreenProbe(int screen);
+static Bool glWinInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
+ int *nvisualp, int *ndepthp,
+ int *rootDepthp, VisualID *defaultVisp,
+ unsigned long sizes, int bitsPerRGB);
+static void glWinSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
+ void **privates);
+static __GLinterface *glWinCreateContext(__GLimports *imports,
+ __GLcontextModes *mode,
+ __GLinterface *shareGC);
+static void glWinCreateBuffer(__GLXdrawablePrivate *glxPriv);
+static void glWinResetExtension(void);
+
+/*
+ * This structure is statically allocated in the __glXScreens[]
+ * structure. This struct is not used anywhere other than in
+ * __glXScreenInit to initialize each of the active screens
+ * (__glXActiveScreens[]). Several of the fields must be initialized by
+ * the screenProbe routine before they are copied to the active screens
+ * struct. In particular, the contextCreate, pGlxVisual, numVisuals,
+ * and numUsableVisuals fields must be initialized.
+ */
+static __GLXscreenInfo __glDDXScreenInfo = {
+ glWinScreenProbe, /* Must be generic and handle all screens */
+ glWinCreateContext, /* Substitute screen's createContext routine */
+ glWinCreateBuffer, /* Substitute screen's createBuffer routine */
+ NULL, /* Set up pGlxVisual in probe */
+ NULL, /* Set up pVisualPriv in probe */
+ 0, /* Set up numVisuals in probe */
+ 0, /* Set up numUsableVisuals in probe */
+ "Vendor String", /* GLXvendor is overwritten by __glXScreenInit */
+ "Version String", /* GLXversion is overwritten by __glXScreenInit */
+ "Extensions String", /* GLXextensions is overwritten by __glXScreenInit */
+ NULL /* WrappedPositionWindow is overwritten */
+};
+
+void *__glXglDDXScreenInfo(void) {
+ return &__glDDXScreenInfo;
+}
+
+static __GLXextensionInfo __glDDXExtensionInfo = {
+ GL_CORE_WINDOWS,
+ glWinResetExtension,
+ glWinInitVisuals,
+ glWinSetVisualConfigs
+};
+
+void *__glXglDDXExtensionInfo(void) {
+ return &__glDDXExtensionInfo;
+}
+
+/* prototypes */
+
+static GLboolean glWinDestroyContext(__GLcontext *gc);
+static GLboolean glWinLoseCurrent(__GLcontext *gc);
+static GLboolean glWinMakeCurrent(__GLcontext *gc);
+static GLboolean glWinShareContext(__GLcontext *gc, __GLcontext *gcShare);
+static GLboolean glWinCopyContext(__GLcontext *dst, const __GLcontext *src,
+ GLuint mask);
+static GLboolean glWinForceCurrent(__GLcontext *gc);
+
+/* Drawing surface notification callbacks */
+static GLboolean glWinNotifyResize(__GLcontext *gc);
+static void glWinNotifyDestroy(__GLcontext *gc);
+static void glWinNotifySwapBuffers(__GLcontext *gc);
+
+/* Dispatch table override control for external agents like libGLS */
+static struct __GLdispatchStateRec* glWinDispatchExec(__GLcontext *gc);
+static void glWinBeginDispatchOverride(__GLcontext *gc);
+static void glWinEndDispatchOverride(__GLcontext *gc);
+
+/* Debug output */
+static void pfdOut(const PIXELFORMATDESCRIPTOR *pfd);
+
+static __GLexports glWinExports = {
+ glWinDestroyContext,
+ glWinLoseCurrent,
+ glWinMakeCurrent,
+ glWinShareContext,
+ glWinCopyContext,
+ glWinForceCurrent,
+
+ glWinNotifyResize,
+ glWinNotifyDestroy,
+ glWinNotifySwapBuffers,
+
+ glWinDispatchExec,
+ glWinBeginDispatchOverride,
+ glWinEndDispatchOverride
+};
+
+glWinScreenRec glWinScreens[MAXSCREENS];
+
+/* __GLdrawablePrivate->private */
+typedef struct {
+ DrawablePtr pDraw;
+ /* xp_surface_id sid; */
+} GLWinDrawableRec;
+
+struct __GLcontextRec {
+ struct __GLinterfaceRec interface; /* required to be first */
+
+ HGLRC ctx; /* Windows GL Context */
+
+ HDC dc; /* Windows Device Context */
+ winWindowInfoRec winInfo; /* Window info from XWin */
+
+ PIXELFORMATDESCRIPTOR pfd; /* Pixelformat flags */
+ int pixelFormat; /* Pixelformat index */
+
+ unsigned isAttached :1; /* Flag to track if context is attached */
+};
+
+static HDC glWinMakeDC(__GLcontext *gc)
+{
+ HDC dc;
+
+ /*if (gc->winInfo.hrgn == NULL)
+ {
+ GLWIN_DEBUG_MSG("Creating region from RECT(%ld,%ld,%ld,%ld):",
+ gc->winInfo.rect.left,
+ gc->winInfo.rect.top,
+ gc->winInfo.rect.right,
+ gc->winInfo.rect.bottom);
+ gc->winInfo.hrgn = CreateRectRgnIndirect(&gc->winInfo.rect);
+ GLWIN_DEBUG_MSG2("%p\n", gc->winInfo.hrgn);
+ }*/
+
+ if (glWinDebugSettings.enableTrace)
+ GLWIN_DEBUG_HWND(gc->winInfo.hwnd);
+
+ dc = GetDC(gc->winInfo.hwnd);
+ /*dc = GetDCEx(gc->winInfo.hwnd, gc->winInfo.hrgn,
+ DCX_WINDOW | DCX_NORESETATTRS ); */
+
+ if (dc == NULL)
+ ErrorF("GetDC error: %s\n", glWinErrorMessage());
+ return dc;
+}
+
+static void unattach(__GLcontext *gc)
+{
+ BOOL ret;
+ GLWIN_DEBUG_MSG("unattach (ctx %p)\n", gc->ctx);
+ if (!gc->isAttached)
+ {
+ ErrorF("called unattach on an unattached context\n");
+ return;
+ }
+
+ if (gc->ctx)
+ {
+ ret = wglDeleteContext(gc->ctx);
+ if (!ret)
+ ErrorF("wglDeleteContext error: %s\n", glWinErrorMessage());
+ gc->ctx = NULL;
+ }
+
+ if (gc->winInfo.hrgn)
+ {
+ ret = DeleteObject(gc->winInfo.hrgn);
+ if (!ret)
+ ErrorF("DeleteObject error: %s\n", glWinErrorMessage());
+ gc->winInfo.hrgn = NULL;
+ }
+
+ gc->isAttached = 0;
+}
+
+static BOOL glWinAdjustHWND(__GLcontext *gc, WindowPtr pWin)
+{
+ HDC dc;
+ BOOL ret;
+ HGLRC newctx;
+ HWND oldhwnd;
+
+ GLWIN_DEBUG_MSG("glWinAdjustHWND (ctx %p, pWin %p)\n", gc->ctx, pWin);
+
+ if (pWin == NULL)
+ {
+ GLWIN_DEBUG_MSG("Deferring until window is created\n");
+ return FALSE;
+ }
+
+ oldhwnd = gc->winInfo.hwnd;
+ winGetWindowInfo(pWin, &gc->winInfo);
+
+ GLWIN_DEBUG_HWND(gc->winInfo.hwnd);
+ if (gc->winInfo.hwnd == NULL)
+ {
+ GLWIN_DEBUG_MSG("Deferring until window is created\n");
+ return FALSE;
+ }
+
+ dc = glWinMakeDC(gc);
+
+ if (glWinDebugSettings.dumpDC)
+ GLWIN_DEBUG_MSG("Got HDC %p\n", dc);
+
+ gc->pixelFormat = ChoosePixelFormat(dc, &gc->pfd);
+ if (gc->pixelFormat == 0)
+ {
+ ErrorF("ChoosePixelFormat error: %s\n", glWinErrorMessage());
+ ReleaseDC(gc->winInfo.hwnd, dc);
+ return FALSE;
+ }
+
+ ret = SetPixelFormat(dc, gc->pixelFormat, &gc->pfd);
+ if (!ret) {
+ ErrorF("SetPixelFormat error: %s\n", glWinErrorMessage());
+ ReleaseDC(gc->winInfo.hwnd, dc);
+ return FALSE;
+ }
+
+ newctx = wglCreateContext(dc);
+ if (newctx == NULL) {
+ ErrorF("wglCreateContext error: %s\n", glWinErrorMessage());
+ ReleaseDC(gc->winInfo.hwnd, dc);
+ return FALSE;
+ }
+
+ GLWIN_DEBUG_MSG("wglCreateContext (ctx %p)\n", newctx);
+
+ if (!wglShareLists(gc->ctx, newctx))
+ {
+ ErrorF("wglShareLists error: %s\n", glWinErrorMessage());
+ ReleaseDC(gc->winInfo.hwnd, dc);
+ return FALSE;
+ }
+
+ if (oldhwnd != gc->winInfo.hwnd)
+ {
+ GLWIN_DEBUG_MSG("Trying wglCopyContext\n");
+ if (!wglCopyContext(gc->ctx, newctx, GL_ALL_ATTRIB_BITS))
+ {
+ ErrorF("wglCopyContext error: %s\n", glWinErrorMessage());
+ ReleaseDC(gc->winInfo.hwnd, dc);
+ return FALSE;
+ }
+ }
+
+ if (!wglDeleteContext(gc->ctx))
+ {
+ ErrorF("wglDeleteContext error: %s\n", glWinErrorMessage());
+ }
+
+ gc->ctx = newctx;
+
+ if (!wglMakeCurrent(dc, gc->ctx)) {
+ ErrorF("glMakeCurrent error: %s\n", glWinErrorMessage());
+ ReleaseDC(gc->winInfo.hwnd, dc);
+ return FALSE;
+ }
+
+ ReleaseDC(gc->winInfo.hwnd, dc);
+
+ return TRUE;
+}
+
+static BOOL glWinCreateContextReal(__GLcontext *gc, WindowPtr pWin)
+{
+ HDC dc;
+ BOOL ret;
+
+ GLWIN_DEBUG_MSG("glWinCreateContextReal (pWin %p)\n", pWin);
+
+ if (pWin == NULL)
+ {
+ GLWIN_DEBUG_MSG("Deferring until window is created\n");
+ return FALSE;
+ }
+
+ winGetWindowInfo(pWin, &gc->winInfo);
+
+ GLWIN_DEBUG_HWND(gc->winInfo.hwnd);
+ if (gc->winInfo.hwnd == NULL)
+ {
+ GLWIN_DEBUG_MSG("Deferring until window is created\n");
+ return FALSE;
+ }
+
+
+ dc = glWinMakeDC(gc);
+
+ if (glWinDebugSettings.dumpDC)
+ GLWIN_DEBUG_MSG("Got HDC %p\n", dc);
+
+ gc->pixelFormat = ChoosePixelFormat(dc, &gc->pfd);
+ if (gc->pixelFormat == 0)
+ {
+ ErrorF("ChoosePixelFormat error: %s\n", glWinErrorMessage());
+ ReleaseDC(gc->winInfo.hwnd, dc);
+ return FALSE;
+ }
+
+ ret = SetPixelFormat(dc, gc->pixelFormat, &gc->pfd);
+ if (!ret) {
+ ErrorF("SetPixelFormat error: %s\n", glWinErrorMessage());
+ ReleaseDC(gc->winInfo.hwnd, dc);
+ return FALSE;
+ }
+
+ gc->ctx = wglCreateContext(dc);
+ if (gc->ctx == NULL) {
+ ErrorF("wglCreateContext error: %s\n", glWinErrorMessage());
+ ReleaseDC(gc->winInfo.hwnd, dc);
+ return FALSE;
+ }
+
+ GLWIN_DEBUG_MSG("glWinCreateContextReal (ctx %p)\n", gc->ctx);
+
+ if (!wglMakeCurrent(dc, gc->ctx)) {
+ ErrorF("glMakeCurrent error: %s\n", glWinErrorMessage());
+ ReleaseDC(gc->winInfo.hwnd, dc);
+ return FALSE;
+ }
+
+ ReleaseDC(gc->winInfo.hwnd, dc);
+
+ return TRUE;
+}
+
+static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv)
+{
+ __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other;
+
+ GLWIN_DEBUG_MSG("attach (ctx %p)\n", gc->ctx);
+
+ if (gc->isAttached)
+ {
+ ErrorF("called attach on an attached context\n");
+ return;
+ }
+
+ if (glxPriv->type == DRAWABLE_WINDOW)
+ {
+ WindowPtr pWin = (WindowPtr) glxPriv->pDraw;
+ if (pWin == NULL)
+ {
+ GLWIN_DEBUG_MSG("Deferring ChoosePixelFormat until window is created\n");
+ } else
+ {
+ if (glWinCreateContextReal(gc, pWin))
+ {
+ gc->isAttached = TRUE;
+ GLWIN_DEBUG_MSG("attached\n");
+ }
+ }
+ }
+}
+
+static GLboolean glWinLoseCurrent(__GLcontext *gc)
+{
+ GLWIN_TRACE_MSG("glWinLoseCurrent (ctx %p)\n", gc->ctx);
+
+ __glXLastContext = NULL; /* Mesa does this; why? */
+
+ return GL_TRUE;
+}
+
+/* Context manipulation; return GL_FALSE on failure */
+static GLboolean glWinDestroyContext(__GLcontext *gc)
+{
+ GLWIN_DEBUG_MSG("glWinDestroyContext (ctx %p)\n", gc->ctx);
+
+ if (gc != NULL)
+ {
+ if (gc->isAttached)
+ unattach(gc);
+ if (gc->dc != NULL)
+ DeleteDC(gc->dc);
+ free(gc);
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean glWinMakeCurrent(__GLcontext *gc)
+{
+ __GLdrawablePrivate *glPriv = gc->interface.imports.getDrawablePrivate(gc);
+ BOOL ret;
+ HDC dc;
+
+ GLWIN_TRACE_MSG(" (ctx %p)\n", gc->ctx);
+
+ if (!gc->isAttached)
+ attach(gc, glPriv);
+
+ if (gc->ctx == NULL) {
+ ErrorF("Context is NULL\n");
+ return GL_FALSE;
+ }
+
+ dc = glWinMakeDC(gc);
+ ret = wglMakeCurrent(dc, gc->ctx);
+ if (!ret)
+ ErrorF("glMakeCurrent error: %s\n", glWinErrorMessage());
+ ReleaseDC(gc->winInfo.hwnd, dc);
+
+ return ret?GL_TRUE:GL_FALSE;
+}
+
+static GLboolean glWinShareContext(__GLcontext *gc, __GLcontext *gcShare)
+{
+ GLWIN_DEBUG_MSG("glWinShareContext unimplemented\n");
+
+ return GL_TRUE;
+}
+
+static GLboolean glWinCopyContext(__GLcontext *dst, const __GLcontext *src,
+ GLuint mask)
+{
+ BOOL ret;
+
+ GLWIN_DEBUG_MSG("glWinCopyContext\n");
+
+ ret = wglCopyContext(src->ctx, dst->ctx, mask);
+ if (!ret)
+ {
+ ErrorF("wglCopyContext error: %s\n", glWinErrorMessage());
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean glWinForceCurrent(__GLcontext *gc)
+{
+ GLWIN_TRACE_MSG(" (ctx %p)\n", gc->ctx);
+
+ return GL_TRUE;
+}
+
+/* Drawing surface notification callbacks */
+
+static GLboolean glWinNotifyResize(__GLcontext *gc)
+{
+ GLWIN_DEBUG_MSG("unimplemented glWinNotifyResize");
+ return GL_TRUE;
+}
+
+static void glWinNotifyDestroy(__GLcontext *gc)
+{
+ GLWIN_DEBUG_MSG("unimplemented glWinNotifyDestroy");
+}
+
+static void glWinNotifySwapBuffers(__GLcontext *gc)
+{
+ GLWIN_DEBUG_MSG("unimplemented glWinNotifySwapBuffers");
+}
+
+/* Dispatch table override control for external agents like libGLS */
+static struct __GLdispatchStateRec* glWinDispatchExec(__GLcontext *gc)
+{
+ GLWIN_DEBUG_MSG("unimplemented glWinDispatchExec");
+ return NULL;
+}
+
+static void glWinBeginDispatchOverride(__GLcontext *gc)
+{
+ GLWIN_DEBUG_MSG("unimplemented glWinBeginDispatchOverride");
+}
+
+static void glWinEndDispatchOverride(__GLcontext *gc)
+{
+ GLWIN_DEBUG_MSG("unimplemented glWinEndDispatchOverride");
+}
+
+#define DUMP_PFD_FLAG(flag) \
+ if (pfd->dwFlags & flag) { \
+ ErrorF("%s%s", pipesym, #flag); \
+ pipesym = " | "; \
+ }
+
+static void pfdOut(const PIXELFORMATDESCRIPTOR *pfd)
+{
+ const char *pipesym = ""; /* will be set after first flag dump */
+ ErrorF("PIXELFORMATDESCRIPTOR:\n");
+ ErrorF("nSize = %u\n", pfd->nSize);
+ ErrorF("nVersion = %u\n", pfd->nVersion);
+ ErrorF("dwFlags = %lu = {", pfd->dwFlags);
+ DUMP_PFD_FLAG(PFD_MAIN_PLANE);
+ DUMP_PFD_FLAG(PFD_OVERLAY_PLANE);
+ DUMP_PFD_FLAG(PFD_UNDERLAY_PLANE);
+ DUMP_PFD_FLAG(PFD_DOUBLEBUFFER);
+ DUMP_PFD_FLAG(PFD_STEREO);
+ DUMP_PFD_FLAG(PFD_DRAW_TO_WINDOW);
+ DUMP_PFD_FLAG(PFD_DRAW_TO_BITMAP);
+ DUMP_PFD_FLAG(PFD_SUPPORT_GDI);
+ DUMP_PFD_FLAG(PFD_SUPPORT_OPENGL);
+ DUMP_PFD_FLAG(PFD_GENERIC_FORMAT);
+ DUMP_PFD_FLAG(PFD_NEED_PALETTE);
+ DUMP_PFD_FLAG(PFD_NEED_SYSTEM_PALETTE);
+ DUMP_PFD_FLAG(PFD_SWAP_EXCHANGE);
+ DUMP_PFD_FLAG(PFD_SWAP_COPY);
+ DUMP_PFD_FLAG(PFD_SWAP_LAYER_BUFFERS);
+ DUMP_PFD_FLAG(PFD_GENERIC_ACCELERATED);
+ DUMP_PFD_FLAG(PFD_DEPTH_DONTCARE);
+ DUMP_PFD_FLAG(PFD_DOUBLEBUFFER_DONTCARE);
+ DUMP_PFD_FLAG(PFD_STEREO_DONTCARE);
+ ErrorF("}\n");
+
+ ErrorF("iPixelType = %hu = %s\n", pfd->iPixelType,
+ (pfd->iPixelType == PFD_TYPE_RGBA ? "PFD_TYPE_RGBA" : "PFD_TYPE_COLORINDEX"));
+ ErrorF("cColorBits = %hhu\n", pfd->cColorBits);
+ ErrorF("cRedBits = %hhu\n", pfd->cRedBits);
+ ErrorF("cRedShift = %hhu\n", pfd->cRedShift);
+ ErrorF("cGreenBits = %hhu\n", pfd->cGreenBits);
+ ErrorF("cGreenShift = %hhu\n", pfd->cGreenShift);
+ ErrorF("cBlueBits = %hhu\n", pfd->cBlueBits);
+ ErrorF("cBlueShift = %hhu\n", pfd->cBlueShift);
+ ErrorF("cAlphaBits = %hhu\n", pfd->cAlphaBits);
+ ErrorF("cAlphaShift = %hhu\n", pfd->cAlphaShift);
+ ErrorF("cAccumBits = %hhu\n", pfd->cAccumBits);
+ ErrorF("cAccumRedBits = %hhu\n", pfd->cAccumRedBits);
+ ErrorF("cAccumGreenBits = %hhu\n", pfd->cAccumGreenBits);
+ ErrorF("cAccumBlueBits = %hhu\n", pfd->cAccumBlueBits);
+ ErrorF("cAccumAlphaBits = %hhu\n", pfd->cAccumAlphaBits);
+ ErrorF("cDepthBits = %hhu\n", pfd->cDepthBits);
+ ErrorF("cStencilBits = %hhu\n", pfd->cStencilBits);
+ ErrorF("cAuxBuffers = %hhu\n", pfd->cAuxBuffers);
+ ErrorF("iLayerType = %hhu\n", pfd->iLayerType);
+ ErrorF("bReserved = %hhu\n", pfd->bReserved);
+ ErrorF("dwLayerMask = %lu\n", pfd->dwLayerMask);
+ ErrorF("dwVisibleMask = %lu\n", pfd->dwVisibleMask);
+ ErrorF("dwDamageMask = %lu\n", pfd->dwDamageMask);
+ ErrorF("\n");
+}
+
+static int makeFormat(__GLcontextModes *mode, PIXELFORMATDESCRIPTOR *pfdret)
+{
+ PIXELFORMATDESCRIPTOR pfd = {
+ sizeof(PIXELFORMATDESCRIPTOR), /* size of this pfd */
+ 1, /* version number */
+ PFD_DRAW_TO_WINDOW | /* support window */
+ PFD_SUPPORT_OPENGL, /* support OpenGL */
+ PFD_TYPE_RGBA, /* RGBA type */
+ 24, /* 24-bit color depth */
+ 0, 0, 0, 0, 0, 0, /* color bits ignored */
+ 0, /* no alpha buffer */
+ 0, /* shift bit ignored */
+ 0, /* no accumulation buffer */
+ 0, 0, 0, 0, /* accum bits ignored */
+ 0, /* 32-bit z-buffer */
+ 0, /* no stencil buffer */
+ 0, /* no auxiliary buffer */
+ PFD_MAIN_PLANE, /* main layer */
+ 0, /* reserved */
+ 0, 0, 0 /* layer masks ignored */
+ }, *result = &pfd;
+
+ /* disable anything but rgba. must get rgba to work first */
+ if (!mode->rgbMode)
+ return -1;
+
+ if (mode->stereoMode) {
+ result->dwFlags |= PFD_STEREO;
+ }
+ if (mode->doubleBufferMode) {
+ result->dwFlags |= PFD_DOUBLEBUFFER;
+ }
+
+ if (mode->colorIndexMode) {
+ /* ignored, see above */
+ result->iPixelType = PFD_TYPE_COLORINDEX;
+ result->cColorBits = mode->redBits + mode->greenBits + mode->blueBits;
+ result->cRedBits = mode->redBits;
+ result->cRedShift = 0; /* FIXME */
+ result->cGreenBits = mode->greenBits;
+ result->cGreenShift = 0; /* FIXME */
+ result->cBlueBits = mode->blueBits;
+ result->cBlueShift = 0; /* FIXME */
+ result->cAlphaBits = mode->alphaBits;
+ result->cAlphaShift = 0; /* FIXME */
+ }
+
+ if (mode->rgbMode) {
+ result->iPixelType = PFD_TYPE_RGBA;
+ result->cColorBits = mode->redBits + mode->greenBits + mode->blueBits;
+ result->cRedBits = mode->redBits;
+ result->cRedShift = 0; /* FIXME */
+ result->cGreenBits = mode->greenBits;
+ result->cGreenShift = 0; /* FIXME */
+ result->cBlueBits = mode->blueBits;
+ result->cBlueShift = 0; /* FIXME */
+ result->cAlphaBits = mode->alphaBits;
+ result->cAlphaShift = 0; /* FIXME */
+ }
+
+ if (mode->haveAccumBuffer) {
+ result->cAccumBits = mode->accumRedBits + mode->accumGreenBits
+ + mode->accumBlueBits + mode->accumAlphaBits;
+ result->cAccumRedBits = mode->accumRedBits;
+ result->cAccumGreenBits = mode->accumGreenBits;
+ result->cAccumBlueBits = mode->accumBlueBits;
+ result->cAccumAlphaBits = mode->accumAlphaBits;
+ }
+
+ if (mode->haveDepthBuffer) {
+ result->cDepthBits = mode->depthBits;
+ }
+ if (mode->haveStencilBuffer) {
+ result->cStencilBits = mode->stencilBits;
+ }
+
+ /* result->cAuxBuffers = mode->numAuxBuffers; */
+
+ /* mode->level ignored */
+
+ /* mode->pixmapMode ? */
+
+ *pfdret = pfd;
+
+ return 0;
+}
+
+static __GLinterface *glWinCreateContext(__GLimports *imports,
+ __GLcontextModes *mode,
+ __GLinterface *shareGC)
+{
+ __GLcontext *result;
+
+ GLWIN_DEBUG_MSG("glWinCreateContext\n");
+
+ result = (__GLcontext *)calloc(1, sizeof(__GLcontext));
+ if (!result)
+ return NULL;
+
+ result->interface.imports = *imports;
+ result->interface.exports = glWinExports;
+
+ if (makeFormat(mode, &result->pfd))
+ {
+ ErrorF("makeFormat failed\n");
+ free(result);
+ return NULL;
+ }
+
+ if (glWinDebugSettings.dumpPFD)
+ pfdOut(&result->pfd);
+
+ GLWIN_DEBUG_MSG("glWinCreateContext done\n");
+ return (__GLinterface *)result;
+}
+
+Bool
+glWinRealizeWindow(WindowPtr pWin)
+{
+ /* If this window has GL contexts, tell them to reattach */
+ /* reattaching is bad: display lists and parameters get lost */
+ Bool result;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ glWinScreenRec *screenPriv = &glWinScreens[pScreen->myNum];
+ __GLXdrawablePrivate *glxPriv;
+
+ GLWIN_DEBUG_MSG("glWinRealizeWindow\n");
+
+ /* Allow the window to be created (RootlessRealizeWindow is inside our wrap) */
+ pScreen->RealizeWindow = screenPriv->RealizeWindow;
+ result = pScreen->RealizeWindow(pWin);
+ pScreen->RealizeWindow = glWinRealizeWindow;
+
+ /* Re-attach this window's GL contexts, if any. */
+ glxPriv = __glXFindDrawablePrivate(pWin->drawable.id);
+ if (glxPriv) {
+ __GLXcontext *gx;
+ __GLcontext *gc;
+ __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
+ GLWIN_DEBUG_MSG("glWinRealizeWindow is GL drawable!\n");
+
+ /* GL contexts bound to this window for drawing */
+ for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) {
+ gc = (__GLcontext *)gx->gc;
+ if (gc->isAttached)
+#if 1
+ {
+ GLWIN_DEBUG_MSG("context is already bound! Adjusting HWND.\n");
+ glWinAdjustHWND(gc, pWin);
+ continue;
+ }
+#else
+ unattach(gc);
+#endif
+ attach(gc, glPriv);
+ }
+
+ /* GL contexts bound to this window for reading */
+ for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) {
+ gc = (__GLcontext *)gx->gc;
+ if (gc->isAttached)
+#if 1
+ {
+ GLWIN_DEBUG_MSG("context is already bound! Adjusting HWND.\n");
+ glWinAdjustHWND(gc, pWin);
+ continue;
+ }
+#else
+ unattach(gc);
+#endif
+ attach(gc, glPriv);
+ }
+ }
+
+ return result;
+}
+
+
+void
+glWinCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ glWinScreenRec *screenPriv = &glWinScreens[pScreen->myNum];
+ __GLXdrawablePrivate *glxPriv;
+
+ GLWIN_TRACE_MSG(" (pWindow %p)\n", pWindow);
+
+ /* Check if the window is attached and discard any drawing request */
+ glxPriv = __glXFindDrawablePrivate(pWindow->drawable.id);
+ if (glxPriv) {
+ __GLXcontext *gx;
+
+ /* GL contexts bound to this window for drawing */
+ for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) {
+/*
+ GLWIN_DEBUG_MSG("glWinCopyWindow - calling glDrawBuffer\n");
+ glDrawBuffer(GL_FRONT);
+ */
+
+ return;
+ }
+
+ /* GL contexts bound to this window for reading */
+ for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) {
+ return;
+ }
+ }
+
+ GLWIN_DEBUG_MSG("glWinCopyWindow - passing to hw layer\n");
+
+ pScreen->CopyWindow = screenPriv->CopyWindow;
+ pScreen->CopyWindow(pWindow, ptOldOrg, prgnSrc);
+ pScreen->CopyWindow = glWinCopyWindow;
+}
+
+Bool
+glWinUnrealizeWindow(WindowPtr pWin)
+{
+ /* If this window has GL contexts, tell them to unattach */
+ Bool result;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ glWinScreenRec *screenPriv = &glWinScreens[pScreen->myNum];
+ __GLXdrawablePrivate *glxPriv;
+
+ GLWIN_DEBUG_MSG("glWinUnrealizeWindow\n");
+
+ /* The Aqua window may have already been destroyed (windows
+ * are unrealized from top down)
+ */
+
+ /* Unattach this window's GL contexts, if any. */
+ glxPriv = __glXFindDrawablePrivate(pWin->drawable.id);
+ if (glxPriv) {
+ __GLXcontext *gx;
+ __GLcontext *gc;
+ GLWIN_DEBUG_MSG("glWinUnealizeWindow is GL drawable!\n");
+
+ /* GL contexts bound to this window for drawing */
+ for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) {
+ gc = (__GLcontext *)gx->gc;
+ unattach(gc);
+ }
+
+ /* GL contexts bound to this window for reading */
+ for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) {
+ gc = (__GLcontext *)gx->gc;
+ unattach(gc);
+ }
+ }
+
+ pScreen->UnrealizeWindow = screenPriv->UnrealizeWindow;
+ result = pScreen->UnrealizeWindow(pWin);
+ pScreen->UnrealizeWindow = glWinUnrealizeWindow;
+
+ return result;
+}
+
+
+/*
+ * In the case the driver has no GLX visuals we'll use these.
+ * [0] = RGB, double buffered
+ * [1] = RGB, double buffered, stencil, accum
+ */
+/* Originally copied from Mesa */
+
+static int numConfigs = 0;
+static __GLXvisualConfig *visualConfigs = NULL;
+static void **visualPrivates = NULL;
+
+#define NUM_FALLBACK_CONFIGS 2
+static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 0, 0, 0, 0, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 0, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE_EXT, /* visualRating */
+ 0, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 16, 16, 16, 0, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE_EXT, /* visualRating */
+ 0, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ }
+};
+
+static __GLXvisualConfig NullConfig = {
+ -1, /* vid */
+ -1, /* class */
+ False, /* rgba */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 0, 0, 0, 0, /* rgba accum sizes */
+ False, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 0, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE_EXT, /* visualRating */
+ 0, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+};
+
+static inline int count_bits(uint32_t x)
+{
+ x = x - ((x >> 1) & 0x55555555);
+ x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
+ x = (x + (x >> 4)) & 0x0f0f0f0f;
+ x = x + (x >> 8);
+ x = x + (x >> 16);
+ return x & 63;
+}
+
+/* Mostly copied from Mesa's xf86glx.c */
+static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
+ VisualID *defaultVisp,
+ int ndepth, DepthPtr pdepth,
+ int rootDepth)
+{
+ int numRGBconfigs;
+ int numCIconfigs;
+ int numVisuals = *nvisualp;
+ int numNewVisuals;
+ int numNewConfigs;
+ VisualPtr pVisual = *visualp;
+ VisualPtr pVisualNew = NULL;
+ VisualID *orig_vid = NULL;
+ __GLcontextModes *modes = NULL;
+ __GLXvisualConfig *pNewVisualConfigs = NULL;
+ void **glXVisualPriv;
+ void **pNewVisualPriv;
+ int found_default;
+ int i, j, k;
+
+ GLWIN_DEBUG_MSG("init_visuals\n");
+
+ if (numConfigs > 0)
+ numNewConfigs = numConfigs;
+ else
+ numNewConfigs = NUM_FALLBACK_CONFIGS;
+
+ /* Alloc space for the list of new GLX visuals */
+ pNewVisualConfigs = (__GLXvisualConfig *)
+ __glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig));
+ if (!pNewVisualConfigs) {
+ return FALSE;
+ }
+
+ /* Alloc space for the list of new GLX visual privates */
+ pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *));
+ if (!pNewVisualPriv) {
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /*
+ ** If SetVisualConfigs was not called, then use default GLX
+ ** visual configs.
+ */
+ if (numConfigs == 0) {
+ memcpy(pNewVisualConfigs, FallbackConfigs,
+ NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig));
+ memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *));
+ }
+ else {
+ /* copy driver's visual config info */
+ for (i = 0; i < numConfigs; i++) {
+ pNewVisualConfigs[i] = visualConfigs[i];
+ pNewVisualPriv[i] = visualPrivates[i];
+ }
+ }
+
+ /* Count the number of RGB and CI visual configs */
+ numRGBconfigs = 0;
+ numCIconfigs = 0;
+ for (i = 0; i < numNewConfigs; i++) {
+ if (pNewVisualConfigs[i].rgba)
+ numRGBconfigs++;
+ else
+ numCIconfigs++;
+ }
+
+ /* Count the total number of visuals to compute */
+ numNewVisuals = 0;
+ for (i = 0; i < numVisuals; i++) {
+ int count;
+
+ count = ((pVisual[i].class == TrueColor
+ || pVisual[i].class == DirectColor)
+ ? numRGBconfigs : numCIconfigs);
+ if (count == 0)
+ count = 1; /* preserve the existing visual */
+
+ numNewVisuals += count;
+ }
+
+ /* Reset variables for use with the next screen/driver's visual configs */
+ visualConfigs = NULL;
+ numConfigs = 0;
+
+ /* Alloc temp space for the list of orig VisualIDs for each new visual */
+ orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID));
+ if (!orig_vid) {
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the list of glXVisuals */
+ modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes));
+ if (modes == NULL) {
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the list of glXVisualPrivates */
+ glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *));
+ if (!glXVisualPriv) {
+ _gl_context_modes_destroy( modes );
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the new list of the X server's visuals */
+ pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec));
+ if (!pVisualNew) {
+ __glXFree(glXVisualPriv);
+ _gl_context_modes_destroy( modes );
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Initialize the new visuals */
+ found_default = FALSE;
+ glWinScreens[screenInfo.numScreens-1].modes = modes;
+ for (i = j = 0; i < numVisuals; i++) {
+ int is_rgb = (pVisual[i].class == TrueColor ||
+ pVisual[i].class == DirectColor);
+
+ if (!is_rgb)
+ {
+ /* We don't support non-rgb visuals for GL. But we don't
+ want to remove them either, so just pass them through
+ with null glX configs */
+
+ pVisualNew[j] = pVisual[i];
+ pVisualNew[j].vid = FakeClientID(0);
+
+ /* Check for the default visual */
+ if (!found_default && pVisual[i].vid == *defaultVisp) {
+ *defaultVisp = pVisualNew[j].vid;
+ found_default = TRUE;
+ }
+
+ /* Save the old VisualID */
+ orig_vid[j] = pVisual[i].vid;
+
+ /* Initialize the glXVisual */
+ _gl_copy_visual_to_context_mode( modes, & NullConfig );
+ modes->visualID = pVisualNew[j].vid;
+
+ j++;
+
+ continue;
+ }
+
+ for (k = 0; k < numNewConfigs; k++) {
+ if (pNewVisualConfigs[k].rgba != is_rgb)
+ continue;
+
+ assert( modes != NULL );
+
+ /* Initialize the new visual */
+ pVisualNew[j] = pVisual[i];
+ pVisualNew[j].vid = FakeClientID(0);
+
+ /* Check for the default visual */
+ if (!found_default && pVisual[i].vid == *defaultVisp) {
+ *defaultVisp = pVisualNew[j].vid;
+ found_default = TRUE;
+ }
+
+ /* Save the old VisualID */
+ orig_vid[j] = pVisual[i].vid;
+
+ /* Initialize the glXVisual */
+ _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] );
+ modes->visualID = pVisualNew[j].vid;
+
+ /*
+ * If the class is -1, then assume the X visual information
+ * is identical to what GLX needs, and take them from the X
+ * visual. NOTE: if class != -1, then all other fields MUST
+ * be initialized.
+ */
+ if (modes->visualType == GLX_NONE) {
+ modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class );
+ modes->redBits = count_bits(pVisual[i].redMask);
+ modes->greenBits = count_bits(pVisual[i].greenMask);
+ modes->blueBits = count_bits(pVisual[i].blueMask);
+ modes->alphaBits = modes->alphaBits;
+ modes->redMask = pVisual[i].redMask;
+ modes->greenMask = pVisual[i].greenMask;
+ modes->blueMask = pVisual[i].blueMask;
+ modes->alphaMask = modes->alphaMask;
+ modes->rgbBits = (is_rgb)
+ ? (modes->redBits + modes->greenBits +
+ modes->blueBits + modes->alphaBits)
+ : rootDepth;
+ }
+
+ /* Save the device-dependent private for this visual */
+ glXVisualPriv[j] = pNewVisualPriv[k];
+
+ j++;
+ modes = modes->next;
+ }
+ }
+
+ assert(j <= numNewVisuals);
+
+ /* Save the GLX visuals in the screen structure */
+ glWinScreens[screenInfo.numScreens-1].num_vis = numNewVisuals;
+ glWinScreens[screenInfo.numScreens-1].priv = glXVisualPriv;
+
+ /* Set up depth's VisualIDs */
+ for (i = 0; i < ndepth; i++) {
+ int numVids = 0;
+ VisualID *pVids = NULL;
+ int k, n = 0;
+
+ /* Count the new number of VisualIDs at this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numNewVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ numVids++;
+
+ /* Allocate a new list of VisualIDs for this depth */
+ pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID));
+
+ /* Initialize the new list of VisualIDs for this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numNewVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ pVids[n++] = pVisualNew[k].vid;
+
+ /* Update this depth's list of VisualIDs */
+ __glXFree(pdepth[i].vids);
+ pdepth[i].vids = pVids;
+ pdepth[i].numVids = numVids;
+ }
+
+ /* Update the X server's visuals */
+ *nvisualp = numNewVisuals;
+ *visualp = pVisualNew;
+
+ /* Free the old list of the X server's visuals */
+ __glXFree(pVisual);
+
+ /* Clean up temporary allocations */
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+
+ /* Free the private list created by DDX HW driver */
+ if (visualPrivates)
+ xfree(visualPrivates);
+ visualPrivates = NULL;
+
+ return TRUE;
+}
+
+
+static void fixup_visuals(int screen)
+{
+ ScreenPtr pScreen = screenInfo.screens[screen];
+ glWinScreenRec *pScr = &glWinScreens[screen];
+ __GLcontextModes *modes;
+ int j;
+
+ GLWIN_DEBUG_MSG("fixup_visuals\n");
+
+ for (modes = pScr->modes; modes != NULL; modes = modes->next ) {
+ const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+ const int nplanes = (modes->rgbBits - modes->alphaBits);
+ VisualPtr pVis = pScreen->visuals;
+
+ /* Find a visual that matches the GLX visual's class and size */
+ for (j = 0; j < pScreen->numVisuals; j++) {
+ if (pVis[j].class == vis_class &&
+ pVis[j].nplanes == nplanes) {
+
+ /* Fixup the masks */
+ modes->redMask = pVis[j].redMask;
+ modes->greenMask = pVis[j].greenMask;
+ modes->blueMask = pVis[j].blueMask;
+
+ /* Recalc the sizes */
+ modes->redBits = count_bits(modes->redMask);
+ modes->greenBits = count_bits(modes->greenMask);
+ modes->blueBits = count_bits(modes->blueMask);
+ }
+ }
+ }
+}
+
+static void init_screen_visuals(int screen)
+{
+ ScreenPtr pScreen = screenInfo.screens[screen];
+ __GLcontextModes *modes;
+ int *used;
+ int i, j;
+
+ GLWIN_DEBUG_MSG("init_screen_visuals\n");
+
+ used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int));
+ __glXMemset(used, 0, pScreen->numVisuals * sizeof(int));
+
+ i = 0;
+ for ( modes = glWinScreens[screen].modes
+ ; modes != NULL
+ ; modes = modes->next) {
+ const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+ const int nplanes = (modes->rgbBits - modes->alphaBits);
+ const VisualPtr pVis = pScreen->visuals;
+
+ for (j = 0; j < pScreen->numVisuals; j++) {
+
+ if (pVis[j].class == vis_class &&
+ pVis[j].nplanes == nplanes &&
+ pVis[j].redMask == modes->redMask &&
+ pVis[j].greenMask == modes->greenMask &&
+ pVis[j].blueMask == modes->blueMask &&
+ !used[j]) {
+
+#if 0
+ /* Create the XMesa visual */
+ pXMesaVisual[i] =
+ XMesaCreateVisual(pScreen,
+ pVis,
+ modes->rgbMode,
+ (modes->alphaBits > 0),
+ modes->doubleBufferMode,
+ modes->stereoMode,
+ GL_TRUE, /* ximage_flag */
+ modes->depthBits,
+ modes->stencilBits,
+ modes->accumRedBits,
+ modes->accumGreenBits,
+ modes->accumBlueBits,
+ modes->accumAlphaBits,
+ modes->samples,
+ modes->level,
+ modes->visualRating);
+#endif
+
+ /* Set the VisualID */
+ modes->visualID = pVis[j].vid;
+
+ /* Mark this visual used */
+ used[j] = 1;
+ break;
+ }
+ }
+
+ if ( j == pScreen->numVisuals ) {
+ ErrorF("No matching visual for __GLcontextMode with "
+ "visual class = %d (%d), nplanes = %u\n",
+ vis_class,
+ modes->visualType,
+ (modes->rgbBits - modes->alphaBits) );
+ }
+ else if ( modes->visualID == -1 ) {
+ FatalError( "Matching visual found, but visualID still -1!\n" );
+ }
+
+ i++;
+
+ }
+
+ __glXFree(used);
+
+ /* glWinScreens[screen].xm_vis = pXMesaVisual; */
+}
+
+static Bool glWinScreenProbe(int screen)
+{
+ ScreenPtr pScreen;
+ glWinScreenRec *screenPriv;
+
+ GLWIN_DEBUG_MSG("glWinScreenProbe\n");
+
+ /*
+ * Set up the current screen's visuals.
+ */
+ __glDDXScreenInfo.modes = glWinScreens[screen].modes;
+ __glDDXScreenInfo.pVisualPriv = glWinScreens[screen].priv;
+ __glDDXScreenInfo.numVisuals =
+ __glDDXScreenInfo.numUsableVisuals = glWinScreens[screen].num_vis;
+
+ /*
+ * Set the current screen's createContext routine. This could be
+ * wrapped by a DDX GLX context creation routine.
+ */
+ __glDDXScreenInfo.createContext = glWinCreateContext;
+
+ /*
+ * The ordering of the rgb compenents might have been changed by the
+ * driver after mi initialized them.
+ */
+ fixup_visuals(screen);
+
+ /*
+ * Find the GLX visuals that are supported by this screen and create
+ * XMesa's visuals.
+ */
+ init_screen_visuals(screen);
+
+ /* Wrap RealizeWindow and UnrealizeWindow on this screen */
+ pScreen = screenInfo.screens[screen];
+ screenPriv = &glWinScreens[screen];
+ screenPriv->RealizeWindow = pScreen->RealizeWindow;
+ pScreen->RealizeWindow = glWinRealizeWindow;
+ screenPriv->UnrealizeWindow = pScreen->UnrealizeWindow;
+ pScreen->UnrealizeWindow = glWinUnrealizeWindow;
+ screenPriv->CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = glWinCopyWindow;
+
+ return TRUE;
+}
+
+static GLboolean glWinSwapBuffers(__GLXdrawablePrivate *glxPriv)
+{
+ /* swap buffers on only *one* of the contexts
+ * (e.g. the last one for drawing)
+ */
+ __GLcontext *gc = (__GLcontext *)glxPriv->drawGlxc->gc;
+ HDC dc;
+ BOOL ret;
+
+ GLWIN_TRACE_MSG("glWinSwapBuffers (ctx %p)\n", (gc!=NULL?gc->ctx:NULL));
+
+ if (gc != NULL && gc->ctx != NULL)
+ {
+ dc = glWinMakeDC(gc);
+ if (dc == NULL)
+ return GL_FALSE;
+
+ ret = SwapBuffers(dc);
+ if (!ret)
+ ErrorF("SwapBuffers failed: %s\n", glWinErrorMessage());
+
+ ReleaseDC(gc->winInfo.hwnd, dc);
+ if (!ret)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static void glWinDestroyDrawablePrivate(__GLdrawablePrivate *glPriv)
+{
+ GLWIN_DEBUG_MSG("glWinDestroyDrawablePrivate\n");
+
+ /* It doesn't work to call DRIDestroySurface here, the drawable's
+ already gone.. But dri.c notices the window destruction and
+ frees the surface itself. */
+
+ free(glPriv->private);
+ glPriv->private = NULL;
+}
+
+
+static void glWinCreateBuffer(__GLXdrawablePrivate *glxPriv)
+{
+ GLWinDrawableRec *winPriv = malloc(sizeof(GLWinDrawableRec));
+ __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
+
+ /*winPriv->sid = 0; */
+ winPriv->pDraw = NULL;
+
+ GLWIN_DEBUG_MSG("glWinCreateBuffer\n");
+
+ /* replace swapBuffers (original is never called) */
+ glxPriv->swapBuffers = glWinSwapBuffers;
+
+ /* stash private data */
+ glPriv->private = winPriv;
+ glPriv->freePrivate = glWinDestroyDrawablePrivate;
+}
+
+static void glWinResetExtension(void)
+{
+ GLWIN_DEBUG_MSG("glWinResetExtension\n");
+}
+
+/* based on code in apples/indirect.c which is based on i830_dri.c */
+static void
+glWinInitVisualConfigs(void)
+{
+ int lclNumConfigs = 0;
+ __GLXvisualConfig *lclVisualConfigs = NULL;
+ void **lclVisualPrivates = NULL;
+
+ int depth, aux, buffers, stencil, accum;
+ int i = 0;
+
+ GLWIN_DEBUG_MSG("glWinInitVisualConfigs ");
+
+ /* count num configs:
+ 2 Z buffer (0, 24 bit)
+ 2 AUX buffer (0, 2)
+ 2 buffers (single, double)
+ 2 stencil (0, 8 bit)
+ 2 accum (0, 64 bit)
+ = 32 configs */
+
+ lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */
+
+ /* alloc */
+ lclVisualConfigs = xcalloc(sizeof(__GLXvisualConfig), lclNumConfigs);
+ lclVisualPrivates = xcalloc(sizeof(void *), lclNumConfigs);
+
+ /* fill in configs */
+ if (NULL != lclVisualConfigs) {
+ i = 0; /* current buffer */
+ for (depth = 0; depth < 2; depth++) {
+ for (aux = 0; aux < 2; aux++) {
+ for (buffers = 0; buffers < 2; buffers++) {
+ for (stencil = 0; stencil < 2; stencil++) {
+ for (accum = 0; accum < 2; accum++) {
+ lclVisualConfigs[i].vid = -1;
+ lclVisualConfigs[i].class = -1;
+ lclVisualConfigs[i].rgba = TRUE;
+ lclVisualConfigs[i].redSize = -1;
+ lclVisualConfigs[i].greenSize = -1;
+ lclVisualConfigs[i].blueSize = -1;
+ lclVisualConfigs[i].redMask = -1;
+ lclVisualConfigs[i].greenMask = -1;
+ lclVisualConfigs[i].blueMask = -1;
+ lclVisualConfigs[i].alphaMask = 0;
+ if (accum) {
+ lclVisualConfigs[i].accumRedSize = 16;
+ lclVisualConfigs[i].accumGreenSize = 16;
+ lclVisualConfigs[i].accumBlueSize = 16;
+ lclVisualConfigs[i].accumAlphaSize = 16;
+ }
+ else {
+ lclVisualConfigs[i].accumRedSize = 0;
+ lclVisualConfigs[i].accumGreenSize = 0;
+ lclVisualConfigs[i].accumBlueSize = 0;
+ lclVisualConfigs[i].accumAlphaSize = 0;
+ }
+ lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE;
+ lclVisualConfigs[i].stereo = FALSE;
+ lclVisualConfigs[i].bufferSize = -1;
+
+ lclVisualConfigs[i].depthSize = depth? 24 : 0;
+ lclVisualConfigs[i].stencilSize = stencil ? 8 : 0;
+ lclVisualConfigs[i].auxBuffers = aux ? 2 : 0;
+ lclVisualConfigs[i].level = 0;
+ lclVisualConfigs[i].visualRating = GLX_NONE_EXT;
+ lclVisualConfigs[i].transparentPixel = 0;
+ lclVisualConfigs[i].transparentRed = 0;
+ lclVisualConfigs[i].transparentGreen = 0;
+ lclVisualConfigs[i].transparentBlue = 0;
+ lclVisualConfigs[i].transparentAlpha = 0;
+ lclVisualConfigs[i].transparentIndex = 0;
+ i++;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (i != lclNumConfigs)
+ GLWIN_DEBUG_MSG("glWinInitVisualConfigs failed to alloc visual configs");
+
+ GlxSetVisualConfigs(lclNumConfigs, lclVisualConfigs, lclVisualPrivates);
+}
+
+/* Copied from Mesa */
+static void glWinSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
+ void **privates)
+{
+ GLWIN_DEBUG_MSG("glWinSetVisualConfigs\n");
+
+ numConfigs = nconfigs;
+ visualConfigs = configs;
+ visualPrivates = privates;
+}
+
+/* Copied from Mesa */
+static Bool glWinInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
+ int *nvisualp, int *ndepthp,
+ int *rootDepthp, VisualID *defaultVisp,
+ unsigned long sizes, int bitsPerRGB)
+{
+ glWinInitDebugSettings();
+
+ GLWIN_DEBUG_MSG("glWinInitVisuals\n");
+
+ if (0 == numConfigs) /* if no configs */
+ glWinInitVisualConfigs(); /* ensure the visula configs are setup */
+
+ /*
+ * Setup the visuals supported by this particular screen.
+ */
+ return init_visuals(nvisualp, visualp, defaultVisp,
+ *ndepthp, *depthp, *rootDepthp);
+}
diff --git a/nx-X11/programs/Xserver/Imakefile b/nx-X11/programs/Xserver/Imakefile
new file mode 100644
index 000000000..39b93eb2d
--- /dev/null
+++ b/nx-X11/programs/Xserver/Imakefile
@@ -0,0 +1,1579 @@
+XCOMM $XdotOrg: xc/programs/Xserver/Imakefile,v 1.37 2005/11/18 18:15:23 ajax Exp $
+XCOMM $Xorg: Imakefile,v 1.4 2001/03/14 18:42:02 pookie Exp $
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+/*
+ * Server Master Makefile
+ */
+XCOMM $XFree86: xc/programs/Xserver/Imakefile,v 3.296 2003/11/23 06:47:00 torrey Exp $
+
+#ifndef InstallXserverSetUID
+#define InstallXserverSetUID NO
+#endif
+#define InstallServerSetUID InstallXserverSetUID
+
+#include <Server.tmpl>
+
+/* On most systems the linker requires the libraries in dependency order.
+ But we have no real order because there are cycles. We fix this by adding
+ some libraries twice on the commandline. dependLib will add the
+ dependency library to the commandline if the link order is important */
+#if 1 /* This is currently enabled for all systems */
+#define dependLib(x) x
+#else
+#define dependLib(x)
+#endif
+
+#if (defined (XFree86Version) || defined(XorgVersion))
+/* Do not strip server binaries */
+INSTPGMFLAGS =
+#endif
+
+#define PreFbLibs $(DIX) $(OS) $(XPDDX)
+#define PreFbLibsNoFont $(DIX) $(OS)
+#define BarePostFbLibs $(MFB) $(XPFBLIBS) $(MI)
+#define PostFbLibs BarePostFbLibs $(EXTENSIONS)
+#define NoMfbBarePostFbLibs $(XPFBLIBS) $(MI)
+#if !BuildXinerama
+#define NoMfbPostFbLibs NoMfbBarePostFbLibs $(EXTENSIONS)
+#else
+#define NoMfbPostFbLibs $(EXTENSIONS) NoMfbBarePostFbLibs $(EXTENSIONS)
+#endif
+
+#define MFBBareLibs PreFbLibs BarePostFbLibs
+#define NoMFBBareLibs PreFbLibs NoMfbBarePostFbLibs
+#define MFBLibs PreFbLibs PostFbLibs
+#define NoMFBLibs PreFbLibs NoMfbPostFbLibs
+#define CFBLibs PreFbLibs $(CFB) PostFbLibs
+#define CFB4Libs PreFbLibs $(CFB4) PostFbLibs
+#define CFB8Libs PreFbLibs $(CFB8) PostFbLibs
+#define CFB16Libs PreFbLibs $(CFB16) PostFbLibs
+#define CFB24Libs PreFbLibs $(CFB24) PostFbLibs
+#define CFB32Libs PreFbLibs $(CFB32) PostFbLibs
+
+#define NoMFBCFBLibs PreFbLibs $(CFB) NoMfbPostFbLibs
+#define NoMFBCFB8Libs PreFbLibs $(CFB8) NoMfbPostFbLibs
+#define FbPostFbLibs $(FB) NoMfbPostFbLibs
+#define FBLibs PreFbLibs FbPostFbLibs
+
+#define MiExtLibs $(SHADOW)
+
+#define AllFBLibs PreFbLibs $(FB) $(CFB) PostFbLibs
+
+#if BuildGlxExt
+# if BuildXF86DRI && ((defined(XF86Server) && XF86Server) \
+ || (defined(XorgServer) && XorgServer))
+ DRILIB = GL/dri/ModuleLibraryTargetName(dri)
+# else
+ DRILIB =
+# endif
+# if GlxUseSGISI
+ GLXLIB = GL/glx/ModuleLibraryTargetName(glx) \
+ GL/sgi-si/ModuleLibraryTargetName(GLcore) \
+ $(DRILIB)
+# else
+# if defined(GlxUseWindows) && GlxUseWindows
+ XWin_GL.exe.GLXLIB = GL/glx/ModuleLibraryTargetName(glx_stdcall) \
+ GL/windows/ModuleLibraryTargetName(GLcore)
+# endif /* GlxUseWindows */
+# if defined(Win32Architecture) && defined(GlxUseWindows) && GlxUseWindows
+ GLXLIB = GL/glx/ModuleLibraryTargetName(glx_stdcall) \
+ GL/windows/ModuleLibraryTargetName(GLcore)
+# elif DoLoadableServer
+ GLXLIB = GL/glx/ModuleLibraryTargetName(glx) \
+ GL/mesa/GLcore/ModuleLibraryTargetName(GLcore)
+# else
+ GLXLIB = GL/glx/ModuleLibraryTargetName(glx) \
+ GL/mesa/GLcore/ModuleLibraryTargetName(GLcore) \
+ $(DRILIB)
+# endif
+# endif
+ GLXDIR = GL
+# if defined(cygwinArchitecture) && defined(GlxUseWindows) && GlxUseWindows
+ GLXEXT = $(if $($@.GLXLIB),$($@.GLXLIB), $(GLXLIB))
+# else
+ GLXEXT = $(GLXLIB)
+# endif
+#endif
+
+#if BuildXInputExt
+ XINPUTEXT = Xi/LibraryTargetName(xinput)
+ XIDIR = Xi
+#endif
+#if BuildXKB
+ XKBEXT = xkb/LibraryTargetName(xkb) dependLib($(OS))
+ XKBDIR = xkb
+#if (defined(XFree86Version) || defined(XorgVersion))
+ XF86XKBOBJS = xkb/xf86KillSrv.o xkb/xf86VT.o xkb/xf86Private.o
+#endif
+#endif
+#if BuildLBX
+ LBXEXT = lbx/LibraryTargetName(lbx) \
+ $(TOP)/lib/lbxutil/LibraryTargetName(lbxutil)
+ LBXDIRS = lbx
+#endif
+#if BuildDBE
+ DBEEXT = dbe/LibraryTargetName(dbe)
+#endif
+#if BuildDBE || BuildDBElib
+ DBEDIR = dbe
+#endif
+#if BuildRECORD
+ RECORDEXT = record/LibraryTargetName(record)
+#endif
+#if BuildRECORD || BuildRECORDlib
+ RECORDDIR = record
+#endif
+#if BuildXTrap
+ XTRAPEXT = XTrap/LibraryTargetName(xtrap)
+ XTRAPDIR = XTrap
+#endif
+#ifdef SiteExtensionLibs
+ SITEEXTS = SiteExtensionLibs
+#endif
+#ifdef SiteExtensionDirs
+ SITEEXTDIRS = SiteExtensionDirs
+#endif
+#if DoLoadableServer && HasDlopen
+ LIBDL = DlLibrary
+#endif
+ LIBREGEX = RegexLibrary
+
+#if DoLoadableServer
+ LIBCWRAPPER = os/libcwrapper.o
+#endif
+
+#if BuildXprint
+
+XPCONFIGDIR = XpConfig
+
+#ifndef XpRasterDDX
+#define XpRasterDDX YES
+#endif
+#ifndef XpColorPclDDX
+#define XpColorPclDDX YES
+#endif
+#ifndef XpMonoPclDDX
+#define XpMonoPclDDX NO
+#endif
+#ifndef XpPostScriptDDX
+#define XpPostScriptDDX YES
+#endif
+
+#if XpRasterDDX
+XPRASTLIB = Xprint/raster/LibraryTargetName(raster)
+#endif
+#if XpColorPclDDX
+XPPCLLIB = Xprint/pcl/LibraryTargetName(pcl)
+#endif
+#if XpMonoPclDDX
+XPMPCLLIB = Xprint/pcl-mono/LibraryTargetName(pcl)
+#endif
+#if XpPostScriptDDX
+XPPSLIB = Xprint/ps/LibraryTargetName(ps)
+#endif
+
+XPDDXLIBS = Xprint/LibraryTargetName(printer) \
+ $(XPRASTLIB) $(XPPCLLIB) $(XPMPCLLIB) $(XPPSLIB)
+XPDDXFBLIBS = $(MFB) $(CFB32)
+#if !PrintOnlyServer
+ XPFBLIBS = $(XPDDXFBLIBS)
+ XPDDX = $(XPDDXLIBS)
+#endif
+ XPDDXDIR = Xprint
+#endif
+#if !BuildXprint || PrintOnlyServer
+XPFBLIBS = dix/LibraryTargetName(xpstubs)
+#endif
+
+#if BuildRender
+ RENDERDIR = render
+ RENDERLIB = $(RENDERDIR)/librender.a
+#endif
+#if BuildRandR
+ RANDRDIR = randr
+ RANDRLIB = $(RANDRDIR)/librandr.a
+#endif
+#if BuildXfixes
+ FIXESDIR = xfixes
+ FIXESLIB = $(FIXESDIR)/libxfixes.a
+#endif
+#if BuildDamage
+ DAMAGEDIR = damageext
+ DAMAGELIB = $(DAMAGEDIR)/libdamage.a
+#endif
+#if BuildComposite
+ CWDIR = miext/cw
+ COMPOSITEDIR = composite
+ COMPOSITELIB = $(COMPOSITEDIR)/libcomposite.a
+#if DoLoadableServer
+ CW = miext/cw/ModuleLibraryTargetName(cw)
+#else
+ CW = miext/cw/LibraryTargetName(cw)
+#endif
+#endif
+#if DoLoadableServer
+ EXTENSIONS = $(COMPOSITELIB) $(DAMAGELIB) $(DAMAGE) $(FIXESLIB) $(CW) \
+ $(OTHEREXTS) $(RANDRLIB) $(RENDERLIB)
+ LOADABLEEXTS = $(MISCEXT) $(DBEEXT) $(RECORDEXT) $(GLXEXT) $(XTRAPEXT)
+ MISCEXT = Xext/LibraryTargetName(ext)
+ OTHEREXTS = Xext/LibraryTargetName(exts) $(XKBEXT) $(XINPUTEXT) \
+ $(LBXEXT) $(SITEEXTS)
+#else
+ EXTENSIONS = $(COMPOSITELIB) $(DAMAGELIB) $(DAMAGE) $(FIXESLIB) $(CW) \
+ $(OTHEREXTS) $(GLXEXT) $(RANDRLIB) $(RENDERLIB)
+ OTHEREXTS = Xext/LibraryTargetName(ext) $(XKBEXT) $(XINPUTEXT) \
+ $(LBXEXT) $(DBEEXT) $(RECORDEXT) $(SITEEXTS) $(XTRAPEXT)
+#endif
+ EXTDIRS = Xext $(XKBDIR) $(XIDIR) $(GLXDIR) \
+ $(LBXDIRS) $(DBEDIR) $(RECORDDIR) $(SITEEXTDIRS) \
+ $(RANDRDIR) $(RENDERDIR) $(XTRAPDIR) $(XPCONFIGDIR) \
+ $(FIXESDIR) $(DAMAGEDIR) $(CWDIR) $(COMPOSITEDIR)
+#if BuildLBX || GzipFontCompression
+ ZLIB = GzipLibrary
+#endif
+ OS = os/LibraryTargetName(os) $(DEPXAUTHLIB) $(DEPXDMCPLIB)
+ BSDEMUL = $(DEPXBSDLIB)
+#if DoLoadableServer
+ MFB = mfb/ModuleLibraryTargetName(mfb)
+ FB = fb/ModuleLibraryTargetName(fb)
+#if XF8_32Wid
+ CFB = cfb/ModuleLibraryTargetName(cfb) \
+ cfb16/ModuleLibraryTargetName(cfb16) \
+ cfb24/ModuleLibraryTargetName(cfb24) \
+ cfb32/ModuleLibraryTargetName(cfb32)
+#else
+ CFB = cfb/ModuleLibraryTargetName(cfb) \
+ cfb16/ModuleLibraryTargetName(cfb16) \
+ cfb32/ModuleLibraryTargetName(cfb32)
+#endif
+ CFB8 = cfb/ModuleLibraryTargetName(cfb)
+ CFB4 = cfb/ModuleLibraryTargetName(cfb) \
+ cfb4/ModuleLibraryTargetName(cfb4)
+ CFB16 = cfb/ModuleLibraryTargetName(cfb) \
+ cfb16/ModuleLibraryTargetName(cfb16)
+ CFB24 = cfb/ModuleLibraryTargetName(cfb) \
+ cfb24/ModuleLibraryTargetName(cfb24)
+ CFB32 = cfb/ModuleLibraryTargetName(cfb) \
+ cfb32/ModuleLibraryTargetName(cfb32)
+ DAMAGE = miext/damage/ModuleLibraryTargetName(damage)
+ SHADOW = miext/shadow/ModuleLibraryTargetName(shadow)
+ LAYER = miext/layer/ModuleLibraryTargetName(layer)
+#else
+ MFB = mfb/LibraryTargetName(mfb)
+ FB = fb/LibraryTargetName(fb)
+#if XF8_32Wid
+ CFB = cfb16/LibraryTargetName(cfb16) \
+ cfb24/LibraryTargetName(cfb24) \
+ cfb32/LibraryTargetName(cfb32) \
+ cfb/LibraryTargetName(cfb)
+#else
+ CFB = cfb16/LibraryTargetName(cfb16) \
+ cfb32/LibraryTargetName(cfb32) \
+ cfb/LibraryTargetName(cfb)
+#endif
+ CFB8 = cfb/LibraryTargetName(cfb)
+ CFB4 = cfb4/LibraryTargetName(cfb4) \
+ cfb/LibraryTargetName(cfb)
+ CFB16 = cfb16/LibraryTargetName(cfb16) \
+ cfb/LibraryTargetName(cfb)
+ CFB24 = cfb24/LibraryTargetName(cfb24) \
+ cfb/LibraryTargetName(cfb)
+ CFB32 = cfb32/LibraryTargetName(cfb32) \
+ cfb/LibraryTargetName(cfb)
+ DAMAGE = miext/damage/LibraryTargetName(damage)
+ SHADOW = miext/shadow/LibraryTargetName(shadow)
+ LAYER = miext/layer/LibraryTargetName(layer)
+#endif
+#if !HasFfs && (defined(mingwArchitecture) || defined(cygwinArchitecture))
+ /* Order of libraries is important when linking in mingw or
+ * cygwin. libmi.a requires ffs from libdix.a. So it is added
+ * after libmi.a on the commandline */
+ MI = mi/LibraryTargetName(mi) $(DIX)
+#else
+ MI = mi/LibraryTargetName(mi)
+#endif
+ MIINITEXTOBJ = mi/miinitext.o
+ DIX = dix/LibraryTargetName(dix)
+ FONTBASE = $(FONTLIBSRC)/fontbase.o \
+ $(FONTLIBSRC)/LibraryTargetName(fontbase)
+#if XserverStaticFontLib
+ FONT = $(FONTLIBSRC)/LibraryTargetName(Xfont) $(FREETYPE2LIB)
+#else
+ FONT = $(LDPRELIB) $(XFONTLIB) $(FREETYPE2LIB)
+#endif
+ FONTLIBS = $(FONT) $(XPFBLIBS)
+#if UsbMouseSupport
+#if !HasLibUsb
+ USB = $(XF86OSSRC)/bsd/libusb/LibraryTargetName(usb)
+#else
+ USB = UsbHidLib
+#endif
+#endif
+#ifdef ServerExtraSysLibs
+ EXTRASYSLIBS = ServerExtraSysLibs
+#endif
+#if HasPam && HasPamMisc
+ PAMLIBS = PamLibraries PamMiscLibraries
+#endif
+#if !(SystemV4 || defined(SGIArchitecture) || UseRgbTxt)
+ DBMLIBS = DBMLibrary
+#endif
+ SYSLIBS = $(ZLIB) MathLibrary Krb5Libraries $(DBMLIBS) $(USB) \
+ $(PAMLIBS) $(EXTRASYSLIBS)
+#if !HasCbrt
+ CBRT = mi/LibraryTargetName(cbrt)
+#endif
+ STDDIRS = include dix os mi $(XPDDXDIR) $(EXTDIRS)
+ FBDIR = fb
+ MFBDIR = mfb
+ CFB4DIR = cfb4
+ CFB8DIR = cfb
+ CFB16DIR = cfb16
+ CFB24DIR = cfb24
+ CFB32DIR = cfb32
+ AFBDIR = afb
+
+XCOMM
+XCOMM This turns off the default rule for compiling .c files because
+XCOMM this makefile does not really know how to build it. This is really
+XCOMM just a hack because of the Sun version of make and nfs.
+XCOMM
+.c.o:
+
+.s.o:
+
+/* Build rule blocks, add one for each server
+ *
+ * If a server needs mfb, its build block should have a line like:
+ * MFBSUBDIR = mfb
+ * Similarly, its build block should have:
+ * CFB4SUBDIR = cfb4 (if the server needs 4 bit cfb)
+ * CFB8SUBDIR = cfb (8 bit cfb)
+ * CFB16SUBDIR = cfb16 (16 bit cfb)
+ * CFB24SUBDIR = cfb24 (24 bit cfb)
+ * CFB32SUBDIR = cfb32 (32 bit cfb)
+ *
+ * If a server does not need all of the above components, simply
+ * omit the relevant lines from the build block.
+ *
+ * If these guidelines are followed, a make at the top of the server
+ * tree should result in each subdirectory being built only once,
+ * even if multiple servers that share subdirectories are being built.
+ */
+
+#if defined(XdecServer) && XdecServer
+XCOMM
+XCOMM Digital MIPS based WS server (ultrix 4.2 and beyond)
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+DECWSDDXDIR = hw/dec/ws
+DECDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(DECWSDDXDIR) $(DEPDIRS)
+DECOBJS = hw/dec/ws/init.o hw/dec/ws/sdepthinit.o
+DECLIBS = hw/dec/ws/LibraryTargetName(dec) CFB8Libs
+ServerTarget(Xdec,$(DECDIRS),$(DECOBJS), \
+ $(DECLIBS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xdec
+#endif
+#endif /* XdecServer */
+
+
+#if defined(XdecMultiDepthServer) && XdecMultiDepthServer
+XCOMM
+XCOMM Digital MIPS based WS server (ultrix 4.2 and beyond)
+XCOMM Supports 8, 12, and 24 bit pixmaps
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+CFB24SUBDIR = cfb24
+CFB32SUBDIR = cfb32
+DECWSDDXDIR = hw/dec/ws
+DECDIRS1 = $(STDDIRS) $(MFBDIR) \
+ $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) \
+ $(DECWSDDXDIR) $(DEPDIRS)
+DECOBJS1 = hw/dec/ws/init.o hw/dec/ws/mdepthinit.o
+DECLIBS1 = hw/dec/ws/LibraryTargetName(dec) CFBLibs
+ServerTarget(Xdec_md,$(DECDIRS1),$(DECOBJS1), \
+ $(DECLIBS1),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xdec_md
+#endif
+#endif /* XdecMultiDepthServer */
+
+
+#if defined(XsunServer) && XsunServer
+XCOMM
+XCOMM Sun server
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+SUNDDXDIR = hw/sun
+#if DoLoadableServer
+SUNOBJS = hw/sun/sunInit.o hw/sun/sunInitExt.o hw/sun/stubs.o
+#elif (defined(XF86Server) && XF86Server) \
+ || (defined(XorgServer) && XorgServer)
+SUNOBJS = hw/sun/sunInit.o hw/sun/stubs.o
+#else
+SUNOBJS = hw/sun/sunInit.o
+#endif
+SUNDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(SUNDDXDIR) $(DEPDIRS)
+SUNLIBS = hw/sun/LibraryTargetName(sun) CFB8Libs
+SUNSYSLIBS = $(FONTLIBS) $(WIDECHARSYSLIB) $(SYSLIBS)
+SetUIDServerTarget(Xsun,$(SUNDIRS),$(SUNOBJS), \
+ $(LIBCWRAPPER) $(SUNLIBS) $(LOADABLEEXTS),$(SUNSYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xsun
+#endif
+#endif /* XsunServer */
+
+
+#if defined(Xsun24Server) && Xsun24Server
+XCOMM
+XCOMM Sun multiple pixmap depth (8, 12, 24) server
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+CFB24SUBDIR = cfb24
+CFB32SUBDIR = cfb32
+SUNDDXDIR = hw/sun
+SUN24DIRS = $(STDDIRS) $(MFBDIR) \
+ $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) \
+ $(SUNDDXDIR) $(DEPDIRS)
+#if DoLoadableServer
+SUN24OBJS = hw/sun/sunInitMulti.o hw/sun/sunInitExt.o hw/sun/stubs.o
+#elif defined(XF86Server) && XF86Server \
+ || (defined(XorgServer) && XorgServer)
+SUN24OBJS = hw/sun/sunInitMulti.o hw/sun/stubs.o
+#else
+SUN24OBJS = hw/sun/sunInitMulti.o
+#endif
+SUN24LIBS = hw/sun/LibraryTargetName(sun) CFBLibs
+SetUIDServerTarget(Xsun24,$(SUN24DIRS),$(SUN24OBJS), \
+ $(LIBCWRAPPER) $(SUN24LIBS) $(LOADABLEEXTS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xsun24
+#endif
+#endif /* Xsun24Server */
+
+
+#if defined(XsunMonoServer) && XsunMonoServer
+XCOMM
+XCOMM Sun monochrome server
+XCOMM
+MFBSUBDIR = mfb
+SUNDDXDIR = hw/sun
+SUNMDIRS = $(STDDIRS) $(MFBDIR) $(SUNDDXDIR) $(DEPDIRS)
+#if defined(XF86Server) && XF86Server \
+ || (defined(XorgServer) && XorgServer)
+SUNMOBJS = hw/sun/sunInitMono.o hw/sun/sunInExMono.o hw/sun/stubs.o
+#else
+SUNMOBJS = hw/sun/sunInitMono.o hw/sun/sunInExMono.o
+#endif
+SUNMLIBS = hw/sun/LibraryTargetName(sun) MFBBareLibs $(EXTENSIONS)
+SetUIDServerTarget(XsunMono,$(SUNMDIRS),$(SUNMOBJS), \
+ $(LIBCWRAPPER) $(SUNMLIBS) $(LOADABLEEXTS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall XsunMono
+#endif
+#endif /* XsunMonoServer */
+
+
+#if defined(XsunLynxServer) && XsunLynxServer
+XCOMM
+XCOMM Sun server for LynxOS microSPARC 2.4.0
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+LYNXDDXDIR = hw/sunLynx
+SUNDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(LYNXDDXDIR) $(DEPDIRS)
+SUNOBJS = hw/sunLynx/sunLyInit.o
+SUNLIBS = hw/sunLynx/libsun.a CFB8Libs
+ServerTarget(Xsun,$(SUNDIRS),$(SUNOBJS), \
+ $(SUNLIBS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xsun
+#endif
+#endif /* XsunLynxServer */
+
+
+#if defined(XsunLynxMonoServer) && XsunLynxMonoServer
+XCOMM
+XCOMM Sun monochrome server for LynxOS microSPARC 2.4.0
+XCOMM
+MFBSUBDIR = mfb
+LYNXDDXDIR = hw/sunLynx
+SUNMDIRS = $(STDDIRS) $(MFBDIR) $(LYNXDDXDIR) $(DEPDIRS)
+SUNMOBJS = hw/sunLynx/sunInitMono.o hw/sunLynx/sunInExMono.o
+SUNMLIBS = hw/sunLynx/libsun.a MFBBareLibs $(OTHEREXTS)
+ServerTarget(XsunMono,$(SUNMDIRS),$(SUNMOBJS), \
+ $(SUNMLIBS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall XsunMono
+#endif
+#endif /* XsunLynxMonoServer */
+
+
+#if HasParallelMake
+XCOMM
+XCOMM force non-parallel build of XF86 servers to prevent MUTEX overrides
+XCOMM
+#if defined(XF86Server) && XF86Server
+XF86SERVER = XFree86
+#endif
+#if defined(XorgServer) && XorgServer
+XF86SERVER = Xorg
+#endif
+#if defined(XnestServer) && XnestServer
+XNEST = Xnext
+#endif
+#if defined(XVirtualFramebufferServer) && XVirtualFramebufferServer
+XVFB = Xvfb
+#endif
+#if XdmxServer
+XDMX = Xdmx
+#endif
+#if defined(XWinServer) && XWinServer && !MakeDllModules
+XWIN = XWin
+#endif
+#if defined(NXAgentServer) && NXAgentServer
+NXAGENT = nxagent
+#endif
+#if defined(NXWinServer) && NXWinServer && !MakeDllModules
+NXWIN = NXWin
+#endif
+#if (defined(XF86Server) && XF86Server) || \
+ (defined(XorgServer) && XorgServer) || \
+ (defined(XnestServer) && XnestServer) || \
+ (defined(NXAgentServer) && NXAgentServer) || \
+ (defined(XVirtualFramebufferServer) && XVirtualFramebufferServer) || \
+ (defined(XdmxServer) && XdmxServer) || \
+ (!MakeDllModules && defined(XWinServer) && XWinServer) || \
+ (!MakeDllModules && defined(NXWinServer) && NXWinServer)
+MakeMutex($(XF86SERVER) $(XNEST) $(XVFB) $(XWIN) $(NXAGENT) $(NXWIN))
+#endif
+MakeMutex($(STDDIRS) mfb fb cfb cfb16 cfb24 cfb32)
+#endif
+
+
+#if defined(XF86Server) && XF86Server
+XCOMM
+XCOMM XFree86 Server
+XCOMM
+FBSUBDIR = fb
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+CFB24SUBDIR = cfb24
+CFB32SUBDIR = cfb32
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+LAYERDIR = miext/layer
+#ifdef OS2Architecture
+SERVERDEFFILE = XFree86.def
+XNESTDEFFILE = Xnest.def
+XVFBDEFFILE = Xvfb.def
+#endif
+#if XF86AFB
+AFBSUBDIR = afb
+#endif
+XFREE86DDXDIR = hw/xfree86
+XF86SERVERSUBDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(AFBDIR) \
+ $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) \
+ $(SHADOWDIR) $(LAYERDIR) $(XFREE86DDXDIR) $(DEPDIRS) \
+ $(MIDAMAGEDIR)
+XF86INIT = $(XF86COMSRC)/xf86Init.o $(XF86COMSRC)/xf86IniExt.o
+XF86COMLIB = $(XF86COMSRC)/LibraryTargetName(xf86)
+XF86PARSLIB= $(XF86PARSERSRC)/LibraryTargetName(xf86config)
+XF86OSLIB = $(XF86OSSRC)/LibraryTargetName(xf86_os)
+#if XF86XAA
+XF86XAALIB = $(XF86SRC)/xaa/LibraryTargetName(xaa)
+#endif
+#if XF86EXA
+XF86EXALIB = $(XF86SRC)/exa/LibraryTargetName(exa)
+#endif
+#if XF86VgaHw
+XF86VGAHWLIB = $(XF86SRC)/vgahw/LibraryTargetName(vgahw)
+#endif
+#if XF86FBDevHw
+XF86FBDEVHWLIB = $(XF86SRC)/fbdevhw/LibraryTargetName(fbdevhw)
+#endif
+#if XF1Bpp || XF4Bpp
+XF1BPPLIB = $(XF86SRC)/xf1bpp/LibraryTargetName(xf1bpp)
+#endif
+#if XF4Bpp
+XF4BPPLIB = $(XF86SRC)/xf4bpp/LibraryTargetName(xf4bpp)
+#endif
+#if XF8_32Wid
+XF8_32WIDLIB = $(XF86SRC)/xf8_32wid/LibraryTargetName(xf8_32wid)
+#endif
+#if XF8_32Bpp
+XF8_32BPPLIB = $(XF86SRC)/xf8_32bpp/LibraryTargetName(xf8_32bpp)
+#endif
+#if XF8_16Bpp
+XF8_16BPPLIB = $(XF86SRC)/xf8_16bpp/LibraryTargetName(xf8_16bpp)
+#endif
+#if XFShadowFB
+XFSHADOWFBLIB = $(XF86SRC)/shadowfb/LibraryTargetName(shadowfb)
+#endif
+#if XF86AFB
+AFBLIB = afb/LibraryTargetName(afb)
+#endif
+XF86DRIVERLIB = $(XF86SRC)/drivers/LibraryTargetName(driver)
+#if XF86Ramdac
+XF86RAMDACLIB = $(XF86SRC)/ramdac/LibraryTargetName(ramdac)
+#endif
+#if XF86I2C
+XF86I2CLIB = $(XF86SRC)/i2c/LibraryTargetName(i2c)
+#endif
+#if XF86DDC
+XF86DDCLIB = $(XF86SRC)/ddc/LibraryTargetName(ddc)
+#endif
+#if XF86VBE
+XF86VBELIB = $(XF86SRC)/vbe/LibraryTargetName(vbe)
+#endif
+#if XF86RAC
+XF86RACLIB = $(XF86SRC)/rac/LibraryTargetName(rac)
+#endif
+#if XF86INT10_BUILD > X86EMU_GENERIC
+XF86INT10LIB = $(XF86OSSRC)/LibraryTargetName(int10)
+#else
+XF86INT10LIB = $(XF86SRC)/int10/LibraryTargetName(int10)
+#endif
+#if UseMemLeak
+MEMDEBUGLIB = $(TOP)/util/memleak/LibraryTargetName(memleak)
+#endif
+XF86IDRIVERLIB = $(XF86SRC)/input/LibraryTargetName(idriver)
+#if !DoLoadableServer
+XF86DRVOBJS = $(XF86SRC)/drivers/drvConf.o
+XF86DRVLIBS = $(XF86DRIVERLIB) $(XF86RAMDACLIB) $(XF86DDCLIB) $(XF86I2CLIB) \
+ $(XF86XAALIB) $(XF86EXALIB) $(XF86VGAHWLIB) $(XF86FBDEVHWLIB) \
+ $(XF8_32WIDLIB) $(XF8_32BPPLIB) \
+ $(XF8_16BPPLIB) \
+ $(XF4BPPLIB) $(XF1BPPLIB) $(XFSHADOWFBLIB) $(AFBLIB)
+XF86IDRVOBJS = $(XF86SRC)/input/drvConf.o
+XF86IDRVLIBS = $(XF86IDRIVERLIB)
+XF86SCANLIB = $(XF86SRC)/scanpci/LibraryTargetName(scanpci)
+XF86LIBS = $(MEMDEBUGLIB) $(XF86INIT) $(XF86COMLIB) $(XF86RACLIB) \
+ $(XF86PARSLIB) $(XF86VBELIB) $(XF86OSLIB) $(XF86INT10LIB)
+#else
+XF86LIBS = $(MEMDEBUGLIB) $(XF86INIT) $(XF86COMLIB) \
+ $(XF86PARSLIB) $(XF86OSLIB)
+#endif
+#if DoLoadableServer
+XF86LOADERLIB = $(XF86SRC)/loader/LibraryTargetName(loader)
+XF86MAINLIBS = PreFbLibsNoFont \
+ $(FONTBASE) $(OTHEREXTS) $(XF86COMLIB) \
+ NoMfbPostFbLibs
+XF86SERVERSYSLIBS = $(SYSLIBS) $(LIBDL) $(LIBREGEX)
+XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
+ $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB)
+#else
+XF86MAINLIBS = MiExtLibs AllFBLibs $(XF86COMLIB) $(MI)
+XF86SERVERSYSLIBS = $(FONTLIBS) $(SYSLIBS) $(LIBDL) $(LIBREGEX)
+XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
+ $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB) \
+ $(XF86DDCLIB)
+#endif
+XF86SERVEROBJS = $(XF86XKBOBJS) $(XF86DRVOBJS) $(XF86IDRVOBJS)
+#if HasParallelMake
+MakeMutex($(XF86SERVERSUBDIRS) $(XF86SERVERLIBS) $(XF86SERVERSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XF86SERVERLIBS) $(XF86SERVERSYSLIBS):: $(XF86SERVERSUBDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+SetUIDServerTarget(XFree86,$(XF86SERVERSUBDIRS),$(XF86SERVEROBJS) $(SERVERDEFFILE), \
+ $(XF86SERVERLIBS),$(XF86SERVERSYSLIBS))
+#if DoLoadableServer
+ServerDriverSDKTarget(XFree86)
+#endif
+#ifndef ServerToInstall
+#define ServerToInstall XFree86
+#endif
+#endif /* XF86Server */
+
+#if defined(XorgServer) && XorgServer
+XCOMM
+XCOMM Xorg Server
+XCOMM
+FBSUBDIR = fb
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+#if XF8_32Wid
+CFB24SUBDIR = cfb24
+#endif
+CFB32SUBDIR = cfb32
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+LAYERDIR = miext/layer
+#ifdef OS2Architecture
+SERVERDEFFILE = Xorg.def
+XNESTDEFFILE = Xnest.def
+XVFBDEFFILE = Xvfb.def
+#endif
+#if XF86AFB
+AFBSUBDIR = afb
+#endif
+XFREE86DDXDIR = hw/xfree86
+XF86SERVERSUBDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(AFBDIR) \
+ $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) \
+ $(SHADOWDIR) $(LAYERDIR) $(XFREE86DDXDIR) $(DEPDIRS) \
+ $(MIDAMAGEDIR)
+XF86INIT = $(XF86COMSRC)/xf86Init.o $(XF86COMSRC)/xf86IniExt.o
+XF86COMLIB = $(XF86COMSRC)/LibraryTargetName(xf86)
+XF86PARSLIB= $(XF86PARSERSRC)/LibraryTargetName(xf86config)
+XF86OSLIB = $(XF86OSSRC)/LibraryTargetName(xf86_os)
+#if XF86XAA
+XF86XAALIB = $(XF86SRC)/xaa/LibraryTargetName(xaa)
+#endif
+#if XF86EXA
+XF86EXALIB = $(XF86SRC)/exa/LibraryTargetName(exa)
+#endif
+#if XF86VgaHw
+XF86VGAHWLIB = $(XF86SRC)/vgahw/LibraryTargetName(vgahw)
+#endif
+#if XF86FBDevHw
+XF86FBDEVHWLIB = $(XF86SRC)/fbdevhw/LibraryTargetName(fbdevhw)
+#endif
+#if XF1Bpp || XF4Bpp
+XF1BPPLIB = $(XF86SRC)/xf1bpp/LibraryTargetName(xf1bpp)
+#endif
+#if XF4Bpp
+XF4BPPLIB = $(XF86SRC)/xf4bpp/LibraryTargetName(xf4bpp)
+#endif
+#if XF8_32Wid
+XF8_32WIDLIB = $(XF86SRC)/xf8_32wid/LibraryTargetName(xf8_32wid)
+#endif
+#if XF8_32Bpp
+XF8_32BPPLIB = $(XF86SRC)/xf8_32bpp/LibraryTargetName(xf8_32bpp)
+#endif
+#if XF8_16Bpp
+XF8_16BPPLIB = $(XF86SRC)/xf8_16bpp/LibraryTargetName(xf8_16bpp)
+#endif
+#if XFShadowFB
+XFSHADOWFBLIB = $(XF86SRC)/shadowfb/LibraryTargetName(shadowfb)
+#endif
+#if XF86AFB
+AFBLIB = afb/LibraryTargetName(afb)
+#endif
+XF86DRIVERLIB = $(XF86SRC)/drivers/LibraryTargetName(driver)
+#if XF86Ramdac
+XF86RAMDACLIB = $(XF86SRC)/ramdac/LibraryTargetName(ramdac)
+#endif
+#if XF86I2C
+XF86I2CLIB = $(XF86SRC)/i2c/LibraryTargetName(i2c)
+#endif
+#if XF86DDC
+XF86DDCLIB = $(XF86SRC)/ddc/LibraryTargetName(ddc)
+#endif
+#if XF86VBE
+XF86VBELIB = $(XF86SRC)/vbe/LibraryTargetName(vbe)
+#endif
+#if XF86RAC
+XF86RACLIB = $(XF86SRC)/rac/LibraryTargetName(rac)
+#endif
+#if XF86INT10_BUILD > X86EMU_GENERIC
+XF86INT10LIB = $(XF86OSSRC)/LibraryTargetName(int10)
+#else
+XF86INT10LIB = $(XF86SRC)/int10/LibraryTargetName(int10)
+#endif
+#if UseMemLeak
+MEMDEBUGLIB = $(TOP)/util/memleak/LibraryTargetName(memleak)
+#endif
+XF86IDRIVERLIB = $(XF86SRC)/input/LibraryTargetName(idriver)
+#if !DoLoadableServer
+XF86DRVOBJS = $(XF86SRC)/drivers/drvConf.o
+XF86DRVLIBS = $(XF86DRIVERLIB) $(XF86RAMDACLIB) $(XF86DDCLIB) $(XF86I2CLIB) \
+ $(XF86XAALIB) $(XF86EXALIB) $(XF86VGAHWLIB) $(XF86FBDEVHWLIB) \
+ $(XF8_32WIDLIB) $(XF8_32BPPLIB) \
+ $(XF8_16BPPLIB) \
+ $(XF4BPPLIB) $(XF1BPPLIB) $(XFSHADOWFBLIB) $(AFBLIB)
+XF86IDRVOBJS = $(XF86SRC)/input/drvConf.o
+XF86IDRVLIBS = $(XF86IDRIVERLIB)
+XF86SCANLIB = $(XF86SRC)/scanpci/LibraryTargetName(scanpci)
+XF86LIBS = $(MEMDEBUGLIB) $(XF86INIT) $(XF86COMLIB) $(XF86RACLIB) \
+ $(XF86PARSLIB) $(XF86VBELIB) $(XF86OSLIB) $(XF86INT10LIB)
+#else
+XF86LIBS = $(MEMDEBUGLIB) $(XF86INIT) $(XF86COMLIB) \
+ $(XF86PARSLIB) $(XF86OSLIB)
+#endif
+#if DoLoadableServer
+XF86LOADERLIB = $(XF86SRC)/loader/LibraryTargetName(loader)
+XF86MAINLIBS = PreFbLibsNoFont \
+ $(FONTBASE) $(OTHEREXTS) $(XF86COMLIB) \
+ NoMfbPostFbLibs
+XF86SERVERSYSLIBS = $(SYSLIBS) $(LIBDL) $(LIBREGEX)
+XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
+ $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB)
+#else
+XF86MAINLIBS = MiExtLibs AllFBLibs $(XF86COMLIB) $(MI)
+XF86SERVERSYSLIBS = $(FONTLIBS) $(SYSLIBS) $(LIBDL) $(LIBREGEX)
+XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
+ $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB) \
+ $(XF86DDCLIB)
+#endif
+XF86SERVEROBJS = $(XF86XKBOBJS) $(XF86DRVOBJS) $(XF86IDRVOBJS)
+#if HasParallelMake
+MakeMutex($(XF86SERVERSUBDIRS) $(XF86SERVERLIBS) $(XF86SERVERSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XF86SERVERLIBS) $(XF86SERVERSYSLIBS):: $(XF86SERVERSUBDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+SetUIDServerTarget(Xorg,$(XF86SERVERSUBDIRS),$(XF86SERVEROBJS) $(SERVERDEFFILE), \
+ $(XF86SERVERLIBS),$(XF86SERVERSYSLIBS))
+#if DoLoadableServer
+ServerDriverSDKTarget(Xorg)
+#endif
+#ifndef ServerToInstall
+#define ServerToInstall Xorg
+#endif
+#endif /* XorgServer */
+
+#if defined(XprtServer) && XprtServer
+XCOMM
+XCOMM Print Server
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB32SUBDIR = cfb32
+MIDAMAGEDIR = miext/damage
+XPSUBDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB32DIR) $(DEPDIRS) \
+ $(MIDAMAGEDIR)
+XPOBJS = Xprint/ddxInit.o Xprint/dpmsstubs.o Xprint/miinitext.o
+#if PrintOnlyServer
+XPLIBS = PreFbLibs $(XPDDXLIBS) $(XPDDXFBLIBS) PostFbLibs
+#else
+XPLIBS = PreFbLibs PostFbLibs
+#endif
+#if (defined(SunArchitecture) || defined(SparcArchitecture)) && \
+ defined(SVR4Architecture)
+XPSYSLIBS = $(FONTLIBS) $(CBRT) $(SYSLIBS) $(XONLYLIB) -lw
+#else
+XPSYSLIBS = $(FONTLIBS) $(CBRT) $(SYSLIBS) $(XONLYLIB)
+#endif
+#if HasParallelMake
+MakeMutex($(XPSUBDIRS) $(XPOBJS) $(XPLIBS) $(XPSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XPOBJS) $(XPLIBS) $(XPSYSLIBS):: $(XPSUBDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+ServerTarget(Xprt,$(XPSUBDIRS),$(XPOBJS), \
+ $(LIBCWRAPPER) $(XPLIBS) $(LOADABLEEXTS),$(XPSYSLIBS))
+#endif /* XprtServer */
+
+#if defined(XnestServer) && XnestServer
+XCOMM
+XCOMM Server with Xlib-based ddx
+XCOMM
+#ifndef Win32Architecture
+XNESTDDXDIR = hw/xnest
+#else
+XNESTDDXDIR = hw
+#endif
+#if BuildDPMS
+XNESTDPMSSTUBOBJS = $(XNESTDDXDIR)/dpmsstubs.o
+#endif
+XNESTDIRS = $(STDDIRS) $(XNESTDDXDIR) $(DEPDIRS)
+#if !defined(LynxOSArchitecture) && \
+ !defined(Win32Architecture) && \
+ !defined(QNX4Architecture)
+XNESTOBJS = hw/xnest/miinitext.o $(XNESTDPMSSTUBOBJS)
+#else
+XNESTOBJS = hw/xnest/miinitext.o dix/main.o $(XNESTDPMSSTUBOBJS)
+#endif
+XNEST = hw/xnest/LibraryTargetName(xnest)
+XNESTLIBS = PreFbLibs $(XNEST) NoMfbPostFbLibs $(XNEST)
+XNESTSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XLIB) $(SYSLIBS)
+#if HasParallelMake
+MakeMutex($(XNESTDIRS) $(XNESTOBJS) $(XNESTLIBS) $(XNESTSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XNESTOBJS) $(XNESTLIBS) $(XNESTSYSLIBS):: $(XNESTDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+ServerTarget(Xnest,$(XNESTDIRS),$(XNESTOBJS) $(XNESTDEFFILE), \
+ $(LIBCWRAPPER) $(XNESTLIBS) $(LOADABLEEXTS),$(XNESTSYSLIBS))
+#endif /* XnestServer */
+
+#if defined(NXAgentServer) && NXAgentServer
+XCOMM
+XCOMM Nested server with NXlib-based ddx and compressed transport.
+XCOMM
+FBSUBDIR = fb
+MIDAMAGEDIR = miext/damage
+FBDIR = fb
+#ifndef Win32Architecture
+NXAGENTDDXDIR = hw/nxagent
+#else
+NXAGENTDDXDIR = hw
+#endif
+
+NXAGENTDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(MIDAMAGEDIR) $(NXAGENTDDXDIR) $(DEPDIRS)
+
+#if defined(SunArchitecture) || \
+ defined(SparcArchitecture)
+NXAGENTOBJS = hw/nxagent/miinitext.o \
+ hw/nxagent/NXwindow.o \
+ hw/nxagent/NXevents.o \
+ hw/nxagent/NXproperty.o \
+ hw/nxagent/NXdixfonts.o \
+ hw/nxagent/NXglyphcurs.o \
+ hw/nxagent/NXdispatch.o \
+ hw/nxagent/NXrender.o \
+ hw/nxagent/NXglyph.o \
+ hw/nxagent/NXpicture.o \
+ hw/nxagent/NXextension.o \
+ hw/nxagent/NXglxext.o \
+ hw/nxagent/NXmiglyph.o \
+ hw/nxagent/NXmiexpose.o \
+ hw/nxagent/NXresource.o \
+ hw/nxagent/NXmiwindow.o \
+ hw/nxagent/NXdamage.o
+#elif !defined(LynxOSArchitecture) && \
+ !defined(Win32Architecture) && \
+ !defined(QNX4Architecture)
+NXAGENTOBJS = hw/nxagent/miinitext.o \
+ hw/nxagent/NXwindow.o \
+ hw/nxagent/NXevents.o \
+ hw/nxagent/NXproperty.o \
+ hw/nxagent/NXdixfonts.o \
+ hw/nxagent/NXglyphcurs.o \
+ hw/nxagent/NXdispatch.o \
+ hw/nxagent/NXrender.o \
+ hw/nxagent/NXglyph.o \
+ hw/nxagent/NXpicture.o \
+ hw/nxagent/NXextension.o \
+ hw/nxagent/NXglxext.o \
+ hw/nxagent/NXxvdisp.o \
+ hw/nxagent/NXmiglyph.o \
+ hw/nxagent/NXmiexpose.o \
+ hw/nxagent/NXresource.o \
+ hw/nxagent/NXmiwindow.o \
+ hw/nxagent/NXdamage.o
+#else
+NXAGENTOBJS = hw/nxagent/miinitext.o \
+ hw/nxagent/NXwindow.o \
+ hw/nxagent/NXevents.o \
+ hw/nxagent/NXproperty.o \
+ hw/nxagent/NXdixfonts.o \
+ hw/nxagent/NXglyphcurs.o \
+ hw/nxagent/NXdispatch.o \
+ hw/nxagent/NXrender.o \
+ hw/nxagent/NXglyph.o \
+ hw/nxagent/NXpicture.o \
+ hw/nxagent/NXextension.o \
+ hw/nxagent/NXglxext.o \
+ hw/nxagent/NXxvdisp.o \
+ hw/nxagent/NXmiglyph.o \
+ hw/nxagent/NXmiexpose.o \
+ hw/nxagent/NXresource.o \
+ hw/nxagent/NXmiwindow.o \
+ hw/nxagent/NXdamage.o \
+ dix/main.o
+#endif
+
+XPMLIB = -lXpm
+NXAGENT = hw/nxagent/LibraryTargetName(nxagent)
+NXAGENTLIBS = PreFbLibs $(NXAGENT) FbPostFbLibs $(NXAGENT) $(MI)
+NXAGENTSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XLIB) $(SYSLIBS) $(XPMLIB)
+#if HasParallelMake
+MakeMutex($(NXAGENTDIRS) $(NXAGENTOBJS) $(NXAGENTLIBS) $(NXAGENTSYSLIBS))
+#endif
+#if ForceServerRemake
+$(NXAGENTOBJS) $(NXAGENTLIBS) $(NXAGENTSYSLIBS):: $(NXAGENTDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+#if NXLibraries
+/*
+ * We need this as the linker will try to locate dependencies of X11 and Xext.
+ */
+
+#if defined(SunArchitecture)
+NXAGENTNXLIBS = -L ../../../nxcomp -L ../../../nxcompext -L ../../../nxcompshad \
+ -lXcomp -lXcompext -lXcompshad -lrt -L/usr/sfw/lib -lXrender \
+ -L../../../nx-X11/exports/lib -lXtst -lXdamage -lXrandr -lXcomposite
+#elif defined(cygwinArchitecture)
+NXAGENTNXLIBS = -L ../../../nxcomp -L ../../../nxcompext \
+ -lXcomp -lXcompext -lXrender -lX11 -lXext -lXcomposite \
+ -L ../../../nxcompshad -lXcompshad -L../../../nx-X11/exports/lib -lXtst
+#else
+NXAGENTNXLIBS = -L ../../../nxcomp -L ../../../nxcompext -L ../../../nxcompshad \
+ -lXcomp -lXcompext -lXcompshad -lXrender -lX11 -lXext \
+ -L../../../nx-X11/exports/lib -lXtst -lXdamage -lXrandr -lXcomposite
+#endif
+
+#endif
+
+#ifdef cygwinArchitecture
+NX_XSHADOWLIBNAME = cygXcompshad.dll
+#else
+NX_XSHADOWLIBNAME = libXcompshad.so
+#endif
+
+NX_XSHADOWLIBDIR = $(XTOP)/../nxcompshad
+NX_XSHADOWLIBTARGET = $(NX_XSHADOWLIBDIR)/$(NX_XSHADOWLIBNAME)
+NX_XSHADOWCONFIGTARGET = $(NX_XSHADOWLIBDIR)/config.status
+
+$(NX_XSHADOWCONFIGTARGET):
+ cd $(NX_XSHADOWLIBDIR) && \
+ ./configure
+
+#ifdef SunArchitecture
+$(NX_XSHADOWLIBTARGET): $(NX_XSHADOWCONFIGTARGET)
+ cd $(NX_XSHADOWLIBDIR) && \
+ gmake
+#else
+$(NX_XSHADOWLIBTARGET): $(NX_XSHADOWCONFIGTARGET)
+ cd $(NX_XSHADOWLIBDIR) && \
+ make
+#endif
+
+ServerTarget(nxagent,$(NX_XSHADOWLIBTARGET) $(NXAGENTDIRS),$(NXAGENTOBJS), \
+ $(LIBCWRAPPER) $(NXAGENTLIBS) $(LOADABLEEXTS),$(NXAGENTSYSLIBS) $(NXAGENTNXLIBS))
+
+/*
+ * Hard coded target to build a static nxagent server.
+ */
+nxagent_static: nxagent
+ if [ -f nxagent_static ]; then set -x; \
+ $(MV) nxagent_static nxagent_static.bak; \
+ else exit 0; fi
+ $(CCLINK) -o nxagent_static -static $(LDOPTIONS) $(NXAGENTOBJS) \
+ $(LIBCWRAPPER) $(NXAGENTLIBS) $(LOADABLEEXTS) $(LDLIBS) \
+ $(NXAGENTSYSLIBS) $(EXTRA_LOAD_FLAGS)
+
+/*
+ * Hard coded target to build a static nxagent server except for libX11 and libXext.
+ */
+nxagent_static_nolibs: nxagent
+ if [ -f nxagent_static_nolibs ]; then set -x; \
+ $(MV) nxagent__static_nolibs nxagent_static_nolibs.bak; \
+ else exit 0; fi
+ $(CCLINK) -o nxagent_static_nolibs -Wl,-Bstatic $(LDOPTIONS) $(NXAGENTOBJS) \
+ $(NXAGENTLIBS) $(LOADABLEEXTS) $(LIBCWRAPPER) $(LDLIBS) $(FONTLIBS) \
+ $(LDPRELIBS) $(SYSLIBS) -Wl,-Bdynamic -lXext -lX11 $(EXTRA_LOAD_FLAGS)
+#endif /* NXAgentServer */
+
+#if defined(XnonServer) && XnonServer
+XCOMM
+XCOMM non server, just compile sources for build test
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+CFB32SUBDIR = cfb32
+#if HasParallelMake
+MakeMutex($(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB32DIR) $(DEPDIRS))
+#endif
+Xnon: $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB32DIR) $(DEPDIRS)
+#endif /* XnonServer */
+
+
+#if defined(XVirtualFramebufferServer) && XVirtualFramebufferServer
+XCOMM
+XCOMM server with Virtual (malloced) framebuffer
+XCOMM
+MFBSUBDIR = mfb
+FBSUBDIR = fb
+#if defined(Win32Architecture)
+XVFBDDXDIR = hw
+#else
+XVFBDDXDIR = hw/vfb
+#endif
+XVFBDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(XVFBDDXDIR) $(DEPDIRS)
+#ifndef Win32Architecture
+#if BuildDPMS
+XVFBDPMSSTUBOBJS = $(XVFBDDXDIR)/dpmsstubs.o
+#endif
+XVFBOBJS = $(XVFBDDXDIR)/stubs.o $(XVFBDDXDIR)/miinitext.o $(XVFBDPMSSTUBOBJS)
+#else
+XVFBOBJS = dix/main.o hw/vfb/stubs.o hw/vfb/miinitext.o
+#endif
+XVFB = $(XVFBDDXDIR)/LibraryTargetName(vfb)
+XVFBLIBS = PreFbLibs $(XVFB) $(FB) PostFbLibs $(MI)
+XVFBSYSLIBS = $(FONTLIBS) $(SYSLIBS)
+#if HasParallelMake
+MakeMutex($(XVFBDIRS) $(XVFBOBJS) $(XVFB) $(XVFBLIBS) $(XVFBSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XVFBOBJS) $(XVFB) $(XVFBLIBS) $(XVFBSYSLIBS):: $(XVFBDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+ServerTarget(Xvfb,$(XVFBDIRS),$(XVFBOBJS) $(XVFBDEFFILE), \
+ $(LIBCWRAPPER) $(XVFBLIBS) $(LOADABLEEXTS),$(XVFBSYSLIBS))
+#endif /* XVirtualFramebufferServer */
+
+#if defined(XdmxServer) && XdmxServer
+XCOMM
+XCOMM distribued multihead Server
+XCOMM
+#ifndef Win32Architecture
+XDMXDDXDIR = hw/dmx
+#else
+XDMXDDXDIR = hw
+#endif
+FBDIR = fb
+FBSUBDIR = fb
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+XDMXDIRS = $(STDDIRS) $(XDMXDDXDIR) $(SHADOWDIR) $(DEPDIRS) $(FBDIR) $(MIDAMAGEDIR)
+#if BuildGlxExt
+#if BuildXinerama
+GLXPROXY_EXTRAOBJS = hw/dmx/panoramiX.o
+#endif
+GLXPROXYLIB = hw/dmx/glxProxy/LibraryTargetName(glxProxy)
+#endif
+#if !defined(LynxOSArchitecture) && \
+ !defined(Win32Architecture) && \
+ !defined(QNX4Architecture)
+XDMXOBJS = hw/dmx/miinitext.o $(GLXPROXY_EXTRAOBJS)
+#else
+XDMXOBJS = hw/dmx/miinitext.o $(GLXPROXY_EXTRAOBJS) dix/main.o
+#endif
+XDMX = hw/dmx/LibraryTargetName(dmx) \
+ hw/dmx/input/LibraryTargetName(dmxinput) \
+ hw/dmx/config/LibraryTargetName(dmxconfig) \
+ $(GLXPROXYLIB)
+XDMXLIBS = PreFbLibs $(XDMX) MiExtLibs FbPostFbLibs $(XDMX)
+#if BuildRender
+XDMXRENDERLIB = $(XRENDERLIB)
+#endif
+XDMXSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XILIB) $(XLIB) $(SYSLIBS) $(XMULIB) $(XDMXRENDERLIB)
+#if HasParallelMake
+MakeMutex($(XDMXDIRS) $(XDMXOBJS) $(XDMXLIBS) $(XDMXSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XDMXOBJS) $(XDMXLIBS) $(XDMXSYSLIBS):: $(XDMXDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+ServerTarget(Xdmx,$(XDMXDIRS),$(XDMXOBJS), \
+ $(LIBCWRAPPER) $(XDMXLIBS) $(LOADABLEEXTS),$(XDMXSYSLIBS))
+#endif /* XdmxServer */
+
+#if defined(XWinServer) && XWinServer
+XCOMM
+XCOMM X Server for MS Windows
+XCOMM
+FBSUBDIR = fb
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+#if BuildXWinLayer
+LAYERDIR = miext/layer
+XWINLAYERLIB = $(LAYER)
+#else
+LAYERDIR =
+XWINLAYERLIB =
+#endif
+#if BuildXWinMultiWindowExtWM
+ROOTLESSDIR = miext/rootless
+ROOTLESSLIB = $(ROOTLESSDIR)/LibraryTargetName(rootless) \
+ $(ROOTLESSDIR)/safeAlpha/LibraryTargetName(safeAlpha) \
+ $(ROOTLESSDIR)/accel/LibraryTargetName(rlAccel)
+#else
+ROOTLESSDIR =
+ROOTLESSLIB =
+#endif
+XWINDDXDIR = hw/xwin
+#if BuildXWinXF86Config
+XWINPARSERDIR = hw/xfree86/parser
+XWINPARSERLIB = $(XWINPARSERDIR)/LibraryTargetName(xf86config)
+#else
+XWINPARSERDIR =
+XWINPARSERLIB =
+#endif
+#if defined(GlxUseWindows) && GlxUseWindows
+XWINOPENGLLIB = -lopengl32
+#else
+XWINOPENGLLIB =
+#endif
+
+XWINLIB = $(XWINDDXDIR)/LibraryTargetName(XWin)
+XWINDIRS = $(STDDIRS) $(FBDIR) $(SHADOWDIR) $(LAYERDIR) $(XWINDDXDIR) \
+ $(DEPDIRS) $(XWINPARSERDIR) $(ROOTLESSDIR) $(MIDAMAGEDIR)
+XWINOBJS = $(XWINDDXDIR)/stubs.o $(XWINDDXDIR)/XWin.res
+XWINLIBS = PreFbLibs $(XWINLIB) FbPostFbLibs $(XWINLIB) $(XWINLAYERLIB) \
+ $(SHADOW) $(XWINPARSERLIB) $(ROOTLESSLIB) $(OS)
+#if BuildXWinMultiWindow || BuildXWinClipboard
+XWINX11 = $(XONLYLIB)
+# if defined(Win32Architecture)
+PTHREADLIB = -lpthreadGC2
+# endif
+#endif
+#if defined(Win32Architecture)
+# if defined(GlxUseWindows) && GlxUseWindows
+XWINGL32 = -lopengl32
+# endif
+XWINW32 = -lgdi32 -lwsock32 $(XWINGL32) $(PTHREADLIB)
+#else
+XWINW32 = -lgdi32
+#endif
+XWINSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XWINX11) $(SYSLIBS) $(XWINW32)
+
+EXTRA_LDOPTIONS = -e _mainCRTStartup
+
+#if HasParallelMake
+MakeMutex($(XWINDIRS) $(XWINOBJS) $(XWINLIB) $(XWINLIBS) $(XWINSYSLIBS))
+#endif
+
+#if ForceServerRemake
+$(XWINOBJS) $(XWINLIB) $(XWINLIBS) $(XWINSYSLIBS):: $(XWINDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+
+#ifdef mingwArchitecture
+XWINSERVERNAME=Xming
+XWINGLSERVERNAME=XmingGL
+#else
+XWINSERVERNAME=XWin
+XWINGLSERVERNAME=XWin_GL
+#endif
+ServerTarget($(XWINSERVERNAME),$(XWINDIRS),$(XWINOBJS), \
+ $(LIBCWRAPPER) $(XWINLIBS) $(LOADABLEEXTS),$(XWINSYSLIBS))
+#if defined(cygwinArchitecture) && defined(GlxUseWindows) && GlxUseWindows
+ServerTarget($(XWINGLSERVERNAME),$(XWINDIRS),$(XWINOBJS), \
+ $(LIBCWRAPPER) $(XWINLIBS) $(LOADABLEEXTS),$(XWINSYSLIBS) \
+ $(XWINOPENGLLIB))
+#endif
+
+#ifndef ServerToInstall
+# define ServerToInstall $(XWINSERVERNAME)
+#endif
+
+#endif /* XWinServer */
+
+
+#if defined(NXWinServer) && NXWinServer
+XCOMM
+XCOMM X Server for MS Windows
+XCOMM
+FBSUBDIR = fb
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+#if BuildXWinLayer
+LAYERDIR = miext/layer
+XWINLAYERLIB = $(LAYER)
+#else
+LAYERDIR =
+XWINLAYERLIB =
+#endif
+#if BuildXWinMultiWindowExtWM
+ROOTLESSDIR = miext/rootless
+ROOTLESSLIB = $(ROOTLESSDIR)/LibraryTargetName(rootless) \
+ $(ROOTLESSDIR)/safeAlpha/LibraryTargetName(safeAlpha) \
+ $(ROOTLESSDIR)/accel/LibraryTargetName(rlAccel)
+#else
+ROOTLESSDIR =
+ROOTLESSLIB =
+#endif
+NXWINDDXDIR = hw/nxwin
+#if BuildXWinXF86Config
+XWINPARSERDIR = hw/xfree86/parser
+XWINPARSERLIB = $(XWINPARSERDIR)/LibraryTargetName(xf86config)
+#else
+XWINPARSERDIR =
+XWINPARSERLIB =
+#endif
+#if defined(GlxUseWindows) && GlxUseWindows
+XWINOPENGLLIB = -lopengl32
+#else
+XWINOPENGLLIB =
+#endif
+
+NXWINLIB = $(NXWINDDXDIR)/LibraryTargetName(NXWin)
+NXWINDIRS = $(STDDIRS) $(FBDIR) $(SHADOWDIR) $(LAYERDIR) $(NXWINDDXDIR) \
+ $(DEPDIRS) $(XWINPARSERDIR) $(ROOTLESSDIR) $(MIDAMAGEDIR)
+NXWINOBJS = $(NXWINDDXDIR)/stubs.o $(NXWINDDXDIR)/NXWin.res
+NXWINLIBS = PreFbLibs $(NXWINLIB) FbPostFbLibs $(NXWINLIB) $(XWINLAYERLIB) \
+ $(SHADOW) $(XWINPARSERLIB) $(ROOTLESSLIB) $(OS)
+#if BuildXWinMultiWindow || BuildXWinClipboard
+XWINX11 = $(XONLYLIB)
+# if defined(Win32Architecture)
+PTHREADLIB = -lpthreadGC
+# endif
+#endif
+#if defined(Win32Architecture)
+# if defined(GlxUseWindows) && GlxUseWindows
+XWINGL32 = -lopengl32
+# endif
+XWINW32 = -lgdi32 -lwsock32 $(XWINGL32) $(PTHREADLIB)
+#else
+XWINW32 = -lgdi32
+#endif
+NXWINSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XWINX11) $(SYSLIBS) $(XWINW32)
+
+NXWINNXLIBS = -L../../../nxcomp -lXcomp
+
+/*
+ * These flags cause NXWin.exe to be a Windows executable, which
+ * prevents NXWin.exe from opening a Command Prompt window when it is
+ * started. However, the flags also prevent NXWin.exe from outputting
+ * its status and error message to a Command Prompt; thus, one most
+ * implement a method to redirect status and error messages to a file
+ * before enabling these flags.
+ */
+EXTRA_LDOPTIONS = -e _mainCRTStartup
+
+#if HasParallelMake
+MakeMutex($(NXWINDIRS) $(NXWINOBJS) $(NXWINLIB) $(NXWINLIBS) $(NXWINSYSLIBS) $(NXWINNXLIBS))
+#endif
+
+#if ForceServerRemake
+$(NXWINOBJS) $(NXWINLIB) $(NXWINLIBS) $(NXWINSYSLIBS) $(NXWINNXLIBS):: $(NXWINDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+
+#ifdef mingwArchitecture
+NXWINSERVERNAME=NXming
+NXWINGLSERVERNAME=NXmingGL
+#else
+NXWINSERVERNAME=NXWin
+NXWINGLSERVERNAME=NXWin_GL
+#endif
+ServerTarget($(NXWINSERVERNAME),$(NXWINDIRS),$(NXWINOBJS), \
+ $(LIBCWRAPPER) $(NXWINLIBS) $(LOADABLEEXTS),$(NXWINSYSLIBS) $(NXWINNXLIBS))
+#if defined(cygwinArchitecture) && defined(GlxUseWindows) && GlxUseWindows
+ServerTarget($(NXWINGLSERVERNAME),$(NXWINDIRS),$(NXWINOBJS), \
+ $(LIBCWRAPPER) $(NXWINLIBS) $(LOADABLEEXTS),$(NXWINSYSLIBS) $(NXWINNXLIBS)\
+ $(XWINOPENGLLIB))
+#endif
+
+#ifndef ServerToInstall
+# define ServerToInstall $(NXWINSERVERNAME)
+#endif
+
+#endif /* NXWinServer */
+
+#if 0
+#if defined(NXWinServer) && NXWinServer
+XCOMM
+XCOMM X Server for MS Windows
+XCOMM
+FBDIR = fb
+SHADOWDIR = miext/shadow
+LAYERDIR = miext/layer
+NXWINDDXDIR = hw/nxwin
+XWINPARSERDIR = hw/xfree86/parser
+XWINPARSERLIB = $(XWINPARSERDIR)/LibraryTargetName(xf86config)
+NXWINLIB = $(NXWINDDXDIR)/LibraryTargetName(nxwin)
+NXWINDIRS = $(STDDIRS) $(FBDIR) $(SHADOWDIR) $(LAYERDIR) $(NXWINDDXDIR) \
+ $(DEPDIRS) $(XWINPARSERDIR)
+#NXWINOBJS = $(NXWINDDXDIR)/stubs.o $(NXWINDDXDIR)/NX.res \
+ $(NXWINDDXDIR)/NXwindow.o \
+ $(NXWINDDXDIR)/NXdispatch.o $(NXWINDDXDIR)/NXproperty.o \
+ $(NXWINDDXDIR)/NXevents.o
+NXWINOBJS = $(NXWINDDXDIR)/stubs.o $(NXWINDDXDIR)/NX.res
+NXWINLIBS = PreFbLibs $(NXWINLIB) FbPostFbLibs $(LAYER) $(SHADOW) \
+ $(XWINPARSERLIB)
+NXWINSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XLIB) $(SYSLIBS) -lgdi32 -lddraw
+NXWINNXLIBS = -L../../../nxcomp -lXcomp
+
+/*
+ * These flags cause NXWin.exe to be a Windows executable, which
+ * prevents NXWin.exe from opening a Command Prompt window when it is
+ * started. However, the flags also prevent NXWin.exe from outputting
+ * its status and error message to a Command Prompt; thus, one most
+ * implement a method to redirect status and error messages to a file
+ * before enabling these flags.
+ */
+EXTRA_LDOPTIONS = -mwindows -e _mainCRTStartup
+
+#if HasParallelMake
+MakeMutex($(NXWINDIRS) $(NXWINOBJS) $(NXWINLIB) $(NXWINLIBS) $(NXWINSYSLIBS) $(NXWINNXLIBS))
+#endif
+
+#if ForceServerRemake
+$(NXWINOBJS) $(NXWINLIB) $(NXWINLIBS) $(NXWINSYSLIBS) $(NXWINNXLIBS):: $(NXWINDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+
+ServerTarget(NXWin,$(NXWINDIRS),$(NXWINOBJS), \
+ $(NXWINLIBS) $(LOADABLEEXTS) $(LIBCWRAPPER),$(NXWINSYSLIBS) $(NXWINNXLIBS))
+
+#ifndef ServerToInstall
+#define ServerToInstall NXWin
+#endif
+
+#endif /* NXWinServer */
+#endif
+
+#ifdef DarwinArchitecture
+/*
+ * To allow building even when building the client-side libraries is turned
+ * off, libraries in ProjectRoot are listed as dependencies for some targets.
+ * This causes problems unless we tell make where to find these dependencies.
+ */
+VPATH = $(BUILDLIBDIR):$(USRLIBDIR)
+#endif
+
+#if defined(XDarwinServer) && XDarwinServer
+XCOMM
+XCOMM X Darwin server for Mac OS X / Darwin
+XCOMM
+FBSUBDIR = fb
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+ROOTLESSDIR = miext/rootless
+DARWINDDXDIR = hw/darwin
+DARWINDIRS = $(STDDIRS) $(FBDIR) $(SHADOWDIR) $(DARWINDDXDIR) $(DEPDIRS)
+DARWINOBJS = $(DARWINDDXDIR)/miinitext.o
+DARWINLIBS = PreFbLibs $(DARWINDDXDIR)/LibraryTargetName(darwin)
+DARWINEXTLIBS = MiExtLibs FbPostFbLibs $(DARWINDDXDIR)/LibraryTargetName(darwin)
+DARWINSYSLIBS = $(FONTLIBS) $(SYSLIBS) -framework IOKit
+IOKITLIB = $(DARWINDDXDIR)/iokit/LibraryTargetName(iokit)
+
+/*
+ * IOKit X server
+ */
+SetUIDServerTarget(XDarwin,$(DARWINDIRS),$(DARWINOBJS), \
+ $(DARWINLIBS) $(IOKITLIB) $(DARWINEXTLIBS),$(DARWINSYSLIBS))
+
+#if DarwinQuartzSupport
+
+QUARTZDIR = $(DARWINDDXDIR)/quartz
+QUARTZLIB = $(QUARTZDIR)/LibraryTargetName(XQuartz)
+QUARTZSYSLIBS = -framework ApplicationServices -framework Cocoa \
+ -framework CoreAudio -framework Carbon -ObjC
+ROOTLESSLIB = $(ROOTLESSDIR)/LibraryTargetName(rootless) \
+ $(ROOTLESSDIR)/safeAlpha/LibraryTargetName(safeAlpha) \
+ $(ROOTLESSDIR)/accel/LibraryTargetName(rlAccel)
+XPLUGINLIB = XpluginLibrary
+
+#if NothingOutsideProjectRoot
+XDARWINAPPDIR = $(BINDIR)/XDarwin.app/Contents
+#else
+XDARWINAPPDIR = /Applications/XDarwin.app/Contents
+#endif
+
+/*
+ * Quartz X server (installed in its application bundle)
+ */
+SetUIDServerTarget(XDarwinApp,$(DARWINDIRS),$(DARWINOBJS), \
+ $(DARWINLIBS) $(QUARTZLIB) $(DARWINEXTLIBS), \
+ $(DARWINSYSLIBS) $(QUARTZSYSLIBS) -u _miDCInitialize)
+
+install::
+ $(MKDIRHIER) $(DESTDIR)$(XDARWINAPPDIR)/MacOS
+ $(MV) $(DESTDIR)$(BINDIR)/XDarwinApp \
+ $(DESTDIR)$(XDARWINAPPDIR)/MacOS/XDarwin
+ -(cd $(DESTDIR)$(BINDIR); $(RM) XDarwinQuartz; \
+ $(LN) $(XDARWINAPPDIR)/MacOS/XDarwin XDarwinQuartz)
+
+/*
+ * Display mode bundles for Quartz
+ * (installed in their own bundles inside XDarwin's)
+ */
+#if HasXplugin
+XPRDIRS = $(QUARTZDIR)/xpr $(ROOTLESSDIR) $(ROOTLESSDIR)/safeAlpha
+XPRLIBS = $(QUARTZDIR)/xpr/LibraryTargetName(xpr) $(ROOTLESSLIB)
+
+BundleProgramTarget(xpr,XDarwinApp,$(XPRDIRS),$(QUARTZDIR)/xpr/xprScreen.o, \
+ $(XPRLIBS),-framework ApplicationServices \
+ $(XPLUGINLIB),$(XDARWINAPPDIR)/Resources)
+#endif
+
+CRDIRS = $(QUARTZDIR)/cr $(ROOTLESSDIR) $(ROOTLESSDIR)/safeAlpha
+CRLIBS = $(QUARTZDIR)/cr/LibraryTargetName(cr) $(ROOTLESSLIB)
+
+BundleProgramTarget(cr,XDarwinApp,$(CRDIRS),$(QUARTZDIR)/cr/crScreen.o, \
+ $(CRLIBS),-framework ApplicationServices -framework Cocoa \
+ -framework Carbon -ObjC,$(XDARWINAPPDIR)/Resources)
+
+FSDIRS = $(QUARTZDIR)/fullscreen $(SHADOWDIR)
+FSLIBS = $(QUARTZDIR)/fullscreen/LibraryTargetName(fullscreen) $(SHADOW)
+
+BundleProgramTarget(fullscreen,XDarwinApp,$(FSDIRS), \
+ $(QUARTZDIR)/fullscreen/fullscreen.o,$(FSLIBS), \
+ -framework ApplicationServices,$(XDARWINAPPDIR)/Resources)
+
+/*
+ * GLX bundles for Quartz
+ * (installed in their own bundles inside XDarwin's)
+ */
+BundleProgramTarget(glxAGL,XDarwinApp,GL,GL/glx/glxext.o,GL/glx/libglx.a \
+ GL/apple/libAGLcore.a, \
+ -framework AGL -framework OpenGL,$(XDARWINAPPDIR)/Resources)
+
+#if BuildAppleDRI
+BundleProgramTarget(glxCGL,XDarwinApp,GL,GL/glx/glxext.o,GL/glx/libglx.a \
+ GL/apple/libCGLcore.a, \
+ -framework OpenGL $(XPLUGINLIB),$(XDARWINAPPDIR)/Resources)
+#endif
+
+BundleProgramTarget(glxMesa,XDarwinApp,GL,GL/glx/glxext.o,GL/glx/libglx.a \
+ GL/mesa/GLcore/libGLcore.a,NullParameter,$(XDARWINAPPDIR)/Resources)
+
+#else /* !DarwinQuartzSupport */
+
+#define ServerToInstall XDarwin
+
+#endif /* DarwinQuartzSupport */
+
+#endif /* XDarwinServer */
+
+
+CFBSUBDIRS = $(CFB8SUBDIR) $(CFB16SUBDIR) $(CFB24SUBDIR) $(CFB32SUBDIR)
+MIEXTDIRS = $(SHADOWDIR) $(LAYERDIR) $(ROOTLESSDIR) $(MIDAMAGEDIR)
+IPLANDIRS = $(IPLAN2P2DIR) $(IPLAN2P4DIR) $(IPLAN2P8DIR)
+DDXDIRS = $(DECWSDDXDIR) $(SUNDDXDIR) $(LYNXDDXDIR) \
+ $(HPDDXDIR) $(XFREE86DDXDIR) $(XWINDDXDIR) $(DARWINDDXDIR) \
+ $(XVFBDDXDIR) $(XNESTDDXDIR) $(XDMXDDXDIR) $(NXAGENTDDXDIR) $(NXWINDDXDIR)
+SUBDIRS = $(STDDIRS) $(MFBSUBDIR) $(CFBSUBDIRS) \
+ $(IPLANDIRS) $(ILBMDIR) $(AFBSUBDIR) \
+ $(DDXDIRS) $(FBSUBDIR) $(KDRIVEDIRS) $(MIEXTDIRS)
+
+#if defined(ServerToInstall) && !defined(OS2Architecture)
+install::
+ -(cd $(DESTDIR)$(BINDIR); $(RM) X; $(LN) ServerToInstall X)
+#endif
+
+#define IHaveSubdirs
+
+DependSubdirs($(SUBDIRS))
+MakeLintLibSubdirs($(SUBDIRS))
+LintSubdirs($(SUBDIRS))
+
+ForceSubdirs($(DEPDIRS) $(SUBDIRS))
+
+DEFAULTFONTPATH = DefaultFontPath
+EXTRAMANDEFS = -D__default_font_path__="`echo $(DEFAULTFONTPATH) | sed -e 's/,/, /g'`"
+
+InstallManPage(Xserver,$(MANDIR))
+
+#if MakeDllModules && DoLoadableServer && \
+ (defined(SunArchitecture) && defined(SVR4Architecture))
+XCOMM Hackery for building dlopen-able .so modules on Solaris
+
+AllTarget(linker-deps)
+
+LINKER_DEPS_DIRS = $(SUBDIRS) $(FONTLIBSRC)
+
+XCOMM After everything is built, run through and generate linker dependencies
+linker-deps:
+ RunPerlScript($(XF86SRC)/os-support/sunos/find_deps.pl,-R ProjectRoot $(LINKER_DEPS_DIRS))
+ for i in $(LINKER_DEPS_DIRS) ; do \
+ echo "relinking with dependency flags in $(CURRENT_DIR)/$$i..."; \
+ MakeNamedTargetSubdir($$i,NullParameter,all) ; \
+ done
+#endif
diff --git a/nx-X11/programs/Xserver/Imakefile.NX.original b/nx-X11/programs/Xserver/Imakefile.NX.original
new file mode 100644
index 000000000..39b93eb2d
--- /dev/null
+++ b/nx-X11/programs/Xserver/Imakefile.NX.original
@@ -0,0 +1,1579 @@
+XCOMM $XdotOrg: xc/programs/Xserver/Imakefile,v 1.37 2005/11/18 18:15:23 ajax Exp $
+XCOMM $Xorg: Imakefile,v 1.4 2001/03/14 18:42:02 pookie Exp $
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+/*
+ * Server Master Makefile
+ */
+XCOMM $XFree86: xc/programs/Xserver/Imakefile,v 3.296 2003/11/23 06:47:00 torrey Exp $
+
+#ifndef InstallXserverSetUID
+#define InstallXserverSetUID NO
+#endif
+#define InstallServerSetUID InstallXserverSetUID
+
+#include <Server.tmpl>
+
+/* On most systems the linker requires the libraries in dependency order.
+ But we have no real order because there are cycles. We fix this by adding
+ some libraries twice on the commandline. dependLib will add the
+ dependency library to the commandline if the link order is important */
+#if 1 /* This is currently enabled for all systems */
+#define dependLib(x) x
+#else
+#define dependLib(x)
+#endif
+
+#if (defined (XFree86Version) || defined(XorgVersion))
+/* Do not strip server binaries */
+INSTPGMFLAGS =
+#endif
+
+#define PreFbLibs $(DIX) $(OS) $(XPDDX)
+#define PreFbLibsNoFont $(DIX) $(OS)
+#define BarePostFbLibs $(MFB) $(XPFBLIBS) $(MI)
+#define PostFbLibs BarePostFbLibs $(EXTENSIONS)
+#define NoMfbBarePostFbLibs $(XPFBLIBS) $(MI)
+#if !BuildXinerama
+#define NoMfbPostFbLibs NoMfbBarePostFbLibs $(EXTENSIONS)
+#else
+#define NoMfbPostFbLibs $(EXTENSIONS) NoMfbBarePostFbLibs $(EXTENSIONS)
+#endif
+
+#define MFBBareLibs PreFbLibs BarePostFbLibs
+#define NoMFBBareLibs PreFbLibs NoMfbBarePostFbLibs
+#define MFBLibs PreFbLibs PostFbLibs
+#define NoMFBLibs PreFbLibs NoMfbPostFbLibs
+#define CFBLibs PreFbLibs $(CFB) PostFbLibs
+#define CFB4Libs PreFbLibs $(CFB4) PostFbLibs
+#define CFB8Libs PreFbLibs $(CFB8) PostFbLibs
+#define CFB16Libs PreFbLibs $(CFB16) PostFbLibs
+#define CFB24Libs PreFbLibs $(CFB24) PostFbLibs
+#define CFB32Libs PreFbLibs $(CFB32) PostFbLibs
+
+#define NoMFBCFBLibs PreFbLibs $(CFB) NoMfbPostFbLibs
+#define NoMFBCFB8Libs PreFbLibs $(CFB8) NoMfbPostFbLibs
+#define FbPostFbLibs $(FB) NoMfbPostFbLibs
+#define FBLibs PreFbLibs FbPostFbLibs
+
+#define MiExtLibs $(SHADOW)
+
+#define AllFBLibs PreFbLibs $(FB) $(CFB) PostFbLibs
+
+#if BuildGlxExt
+# if BuildXF86DRI && ((defined(XF86Server) && XF86Server) \
+ || (defined(XorgServer) && XorgServer))
+ DRILIB = GL/dri/ModuleLibraryTargetName(dri)
+# else
+ DRILIB =
+# endif
+# if GlxUseSGISI
+ GLXLIB = GL/glx/ModuleLibraryTargetName(glx) \
+ GL/sgi-si/ModuleLibraryTargetName(GLcore) \
+ $(DRILIB)
+# else
+# if defined(GlxUseWindows) && GlxUseWindows
+ XWin_GL.exe.GLXLIB = GL/glx/ModuleLibraryTargetName(glx_stdcall) \
+ GL/windows/ModuleLibraryTargetName(GLcore)
+# endif /* GlxUseWindows */
+# if defined(Win32Architecture) && defined(GlxUseWindows) && GlxUseWindows
+ GLXLIB = GL/glx/ModuleLibraryTargetName(glx_stdcall) \
+ GL/windows/ModuleLibraryTargetName(GLcore)
+# elif DoLoadableServer
+ GLXLIB = GL/glx/ModuleLibraryTargetName(glx) \
+ GL/mesa/GLcore/ModuleLibraryTargetName(GLcore)
+# else
+ GLXLIB = GL/glx/ModuleLibraryTargetName(glx) \
+ GL/mesa/GLcore/ModuleLibraryTargetName(GLcore) \
+ $(DRILIB)
+# endif
+# endif
+ GLXDIR = GL
+# if defined(cygwinArchitecture) && defined(GlxUseWindows) && GlxUseWindows
+ GLXEXT = $(if $($@.GLXLIB),$($@.GLXLIB), $(GLXLIB))
+# else
+ GLXEXT = $(GLXLIB)
+# endif
+#endif
+
+#if BuildXInputExt
+ XINPUTEXT = Xi/LibraryTargetName(xinput)
+ XIDIR = Xi
+#endif
+#if BuildXKB
+ XKBEXT = xkb/LibraryTargetName(xkb) dependLib($(OS))
+ XKBDIR = xkb
+#if (defined(XFree86Version) || defined(XorgVersion))
+ XF86XKBOBJS = xkb/xf86KillSrv.o xkb/xf86VT.o xkb/xf86Private.o
+#endif
+#endif
+#if BuildLBX
+ LBXEXT = lbx/LibraryTargetName(lbx) \
+ $(TOP)/lib/lbxutil/LibraryTargetName(lbxutil)
+ LBXDIRS = lbx
+#endif
+#if BuildDBE
+ DBEEXT = dbe/LibraryTargetName(dbe)
+#endif
+#if BuildDBE || BuildDBElib
+ DBEDIR = dbe
+#endif
+#if BuildRECORD
+ RECORDEXT = record/LibraryTargetName(record)
+#endif
+#if BuildRECORD || BuildRECORDlib
+ RECORDDIR = record
+#endif
+#if BuildXTrap
+ XTRAPEXT = XTrap/LibraryTargetName(xtrap)
+ XTRAPDIR = XTrap
+#endif
+#ifdef SiteExtensionLibs
+ SITEEXTS = SiteExtensionLibs
+#endif
+#ifdef SiteExtensionDirs
+ SITEEXTDIRS = SiteExtensionDirs
+#endif
+#if DoLoadableServer && HasDlopen
+ LIBDL = DlLibrary
+#endif
+ LIBREGEX = RegexLibrary
+
+#if DoLoadableServer
+ LIBCWRAPPER = os/libcwrapper.o
+#endif
+
+#if BuildXprint
+
+XPCONFIGDIR = XpConfig
+
+#ifndef XpRasterDDX
+#define XpRasterDDX YES
+#endif
+#ifndef XpColorPclDDX
+#define XpColorPclDDX YES
+#endif
+#ifndef XpMonoPclDDX
+#define XpMonoPclDDX NO
+#endif
+#ifndef XpPostScriptDDX
+#define XpPostScriptDDX YES
+#endif
+
+#if XpRasterDDX
+XPRASTLIB = Xprint/raster/LibraryTargetName(raster)
+#endif
+#if XpColorPclDDX
+XPPCLLIB = Xprint/pcl/LibraryTargetName(pcl)
+#endif
+#if XpMonoPclDDX
+XPMPCLLIB = Xprint/pcl-mono/LibraryTargetName(pcl)
+#endif
+#if XpPostScriptDDX
+XPPSLIB = Xprint/ps/LibraryTargetName(ps)
+#endif
+
+XPDDXLIBS = Xprint/LibraryTargetName(printer) \
+ $(XPRASTLIB) $(XPPCLLIB) $(XPMPCLLIB) $(XPPSLIB)
+XPDDXFBLIBS = $(MFB) $(CFB32)
+#if !PrintOnlyServer
+ XPFBLIBS = $(XPDDXFBLIBS)
+ XPDDX = $(XPDDXLIBS)
+#endif
+ XPDDXDIR = Xprint
+#endif
+#if !BuildXprint || PrintOnlyServer
+XPFBLIBS = dix/LibraryTargetName(xpstubs)
+#endif
+
+#if BuildRender
+ RENDERDIR = render
+ RENDERLIB = $(RENDERDIR)/librender.a
+#endif
+#if BuildRandR
+ RANDRDIR = randr
+ RANDRLIB = $(RANDRDIR)/librandr.a
+#endif
+#if BuildXfixes
+ FIXESDIR = xfixes
+ FIXESLIB = $(FIXESDIR)/libxfixes.a
+#endif
+#if BuildDamage
+ DAMAGEDIR = damageext
+ DAMAGELIB = $(DAMAGEDIR)/libdamage.a
+#endif
+#if BuildComposite
+ CWDIR = miext/cw
+ COMPOSITEDIR = composite
+ COMPOSITELIB = $(COMPOSITEDIR)/libcomposite.a
+#if DoLoadableServer
+ CW = miext/cw/ModuleLibraryTargetName(cw)
+#else
+ CW = miext/cw/LibraryTargetName(cw)
+#endif
+#endif
+#if DoLoadableServer
+ EXTENSIONS = $(COMPOSITELIB) $(DAMAGELIB) $(DAMAGE) $(FIXESLIB) $(CW) \
+ $(OTHEREXTS) $(RANDRLIB) $(RENDERLIB)
+ LOADABLEEXTS = $(MISCEXT) $(DBEEXT) $(RECORDEXT) $(GLXEXT) $(XTRAPEXT)
+ MISCEXT = Xext/LibraryTargetName(ext)
+ OTHEREXTS = Xext/LibraryTargetName(exts) $(XKBEXT) $(XINPUTEXT) \
+ $(LBXEXT) $(SITEEXTS)
+#else
+ EXTENSIONS = $(COMPOSITELIB) $(DAMAGELIB) $(DAMAGE) $(FIXESLIB) $(CW) \
+ $(OTHEREXTS) $(GLXEXT) $(RANDRLIB) $(RENDERLIB)
+ OTHEREXTS = Xext/LibraryTargetName(ext) $(XKBEXT) $(XINPUTEXT) \
+ $(LBXEXT) $(DBEEXT) $(RECORDEXT) $(SITEEXTS) $(XTRAPEXT)
+#endif
+ EXTDIRS = Xext $(XKBDIR) $(XIDIR) $(GLXDIR) \
+ $(LBXDIRS) $(DBEDIR) $(RECORDDIR) $(SITEEXTDIRS) \
+ $(RANDRDIR) $(RENDERDIR) $(XTRAPDIR) $(XPCONFIGDIR) \
+ $(FIXESDIR) $(DAMAGEDIR) $(CWDIR) $(COMPOSITEDIR)
+#if BuildLBX || GzipFontCompression
+ ZLIB = GzipLibrary
+#endif
+ OS = os/LibraryTargetName(os) $(DEPXAUTHLIB) $(DEPXDMCPLIB)
+ BSDEMUL = $(DEPXBSDLIB)
+#if DoLoadableServer
+ MFB = mfb/ModuleLibraryTargetName(mfb)
+ FB = fb/ModuleLibraryTargetName(fb)
+#if XF8_32Wid
+ CFB = cfb/ModuleLibraryTargetName(cfb) \
+ cfb16/ModuleLibraryTargetName(cfb16) \
+ cfb24/ModuleLibraryTargetName(cfb24) \
+ cfb32/ModuleLibraryTargetName(cfb32)
+#else
+ CFB = cfb/ModuleLibraryTargetName(cfb) \
+ cfb16/ModuleLibraryTargetName(cfb16) \
+ cfb32/ModuleLibraryTargetName(cfb32)
+#endif
+ CFB8 = cfb/ModuleLibraryTargetName(cfb)
+ CFB4 = cfb/ModuleLibraryTargetName(cfb) \
+ cfb4/ModuleLibraryTargetName(cfb4)
+ CFB16 = cfb/ModuleLibraryTargetName(cfb) \
+ cfb16/ModuleLibraryTargetName(cfb16)
+ CFB24 = cfb/ModuleLibraryTargetName(cfb) \
+ cfb24/ModuleLibraryTargetName(cfb24)
+ CFB32 = cfb/ModuleLibraryTargetName(cfb) \
+ cfb32/ModuleLibraryTargetName(cfb32)
+ DAMAGE = miext/damage/ModuleLibraryTargetName(damage)
+ SHADOW = miext/shadow/ModuleLibraryTargetName(shadow)
+ LAYER = miext/layer/ModuleLibraryTargetName(layer)
+#else
+ MFB = mfb/LibraryTargetName(mfb)
+ FB = fb/LibraryTargetName(fb)
+#if XF8_32Wid
+ CFB = cfb16/LibraryTargetName(cfb16) \
+ cfb24/LibraryTargetName(cfb24) \
+ cfb32/LibraryTargetName(cfb32) \
+ cfb/LibraryTargetName(cfb)
+#else
+ CFB = cfb16/LibraryTargetName(cfb16) \
+ cfb32/LibraryTargetName(cfb32) \
+ cfb/LibraryTargetName(cfb)
+#endif
+ CFB8 = cfb/LibraryTargetName(cfb)
+ CFB4 = cfb4/LibraryTargetName(cfb4) \
+ cfb/LibraryTargetName(cfb)
+ CFB16 = cfb16/LibraryTargetName(cfb16) \
+ cfb/LibraryTargetName(cfb)
+ CFB24 = cfb24/LibraryTargetName(cfb24) \
+ cfb/LibraryTargetName(cfb)
+ CFB32 = cfb32/LibraryTargetName(cfb32) \
+ cfb/LibraryTargetName(cfb)
+ DAMAGE = miext/damage/LibraryTargetName(damage)
+ SHADOW = miext/shadow/LibraryTargetName(shadow)
+ LAYER = miext/layer/LibraryTargetName(layer)
+#endif
+#if !HasFfs && (defined(mingwArchitecture) || defined(cygwinArchitecture))
+ /* Order of libraries is important when linking in mingw or
+ * cygwin. libmi.a requires ffs from libdix.a. So it is added
+ * after libmi.a on the commandline */
+ MI = mi/LibraryTargetName(mi) $(DIX)
+#else
+ MI = mi/LibraryTargetName(mi)
+#endif
+ MIINITEXTOBJ = mi/miinitext.o
+ DIX = dix/LibraryTargetName(dix)
+ FONTBASE = $(FONTLIBSRC)/fontbase.o \
+ $(FONTLIBSRC)/LibraryTargetName(fontbase)
+#if XserverStaticFontLib
+ FONT = $(FONTLIBSRC)/LibraryTargetName(Xfont) $(FREETYPE2LIB)
+#else
+ FONT = $(LDPRELIB) $(XFONTLIB) $(FREETYPE2LIB)
+#endif
+ FONTLIBS = $(FONT) $(XPFBLIBS)
+#if UsbMouseSupport
+#if !HasLibUsb
+ USB = $(XF86OSSRC)/bsd/libusb/LibraryTargetName(usb)
+#else
+ USB = UsbHidLib
+#endif
+#endif
+#ifdef ServerExtraSysLibs
+ EXTRASYSLIBS = ServerExtraSysLibs
+#endif
+#if HasPam && HasPamMisc
+ PAMLIBS = PamLibraries PamMiscLibraries
+#endif
+#if !(SystemV4 || defined(SGIArchitecture) || UseRgbTxt)
+ DBMLIBS = DBMLibrary
+#endif
+ SYSLIBS = $(ZLIB) MathLibrary Krb5Libraries $(DBMLIBS) $(USB) \
+ $(PAMLIBS) $(EXTRASYSLIBS)
+#if !HasCbrt
+ CBRT = mi/LibraryTargetName(cbrt)
+#endif
+ STDDIRS = include dix os mi $(XPDDXDIR) $(EXTDIRS)
+ FBDIR = fb
+ MFBDIR = mfb
+ CFB4DIR = cfb4
+ CFB8DIR = cfb
+ CFB16DIR = cfb16
+ CFB24DIR = cfb24
+ CFB32DIR = cfb32
+ AFBDIR = afb
+
+XCOMM
+XCOMM This turns off the default rule for compiling .c files because
+XCOMM this makefile does not really know how to build it. This is really
+XCOMM just a hack because of the Sun version of make and nfs.
+XCOMM
+.c.o:
+
+.s.o:
+
+/* Build rule blocks, add one for each server
+ *
+ * If a server needs mfb, its build block should have a line like:
+ * MFBSUBDIR = mfb
+ * Similarly, its build block should have:
+ * CFB4SUBDIR = cfb4 (if the server needs 4 bit cfb)
+ * CFB8SUBDIR = cfb (8 bit cfb)
+ * CFB16SUBDIR = cfb16 (16 bit cfb)
+ * CFB24SUBDIR = cfb24 (24 bit cfb)
+ * CFB32SUBDIR = cfb32 (32 bit cfb)
+ *
+ * If a server does not need all of the above components, simply
+ * omit the relevant lines from the build block.
+ *
+ * If these guidelines are followed, a make at the top of the server
+ * tree should result in each subdirectory being built only once,
+ * even if multiple servers that share subdirectories are being built.
+ */
+
+#if defined(XdecServer) && XdecServer
+XCOMM
+XCOMM Digital MIPS based WS server (ultrix 4.2 and beyond)
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+DECWSDDXDIR = hw/dec/ws
+DECDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(DECWSDDXDIR) $(DEPDIRS)
+DECOBJS = hw/dec/ws/init.o hw/dec/ws/sdepthinit.o
+DECLIBS = hw/dec/ws/LibraryTargetName(dec) CFB8Libs
+ServerTarget(Xdec,$(DECDIRS),$(DECOBJS), \
+ $(DECLIBS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xdec
+#endif
+#endif /* XdecServer */
+
+
+#if defined(XdecMultiDepthServer) && XdecMultiDepthServer
+XCOMM
+XCOMM Digital MIPS based WS server (ultrix 4.2 and beyond)
+XCOMM Supports 8, 12, and 24 bit pixmaps
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+CFB24SUBDIR = cfb24
+CFB32SUBDIR = cfb32
+DECWSDDXDIR = hw/dec/ws
+DECDIRS1 = $(STDDIRS) $(MFBDIR) \
+ $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) \
+ $(DECWSDDXDIR) $(DEPDIRS)
+DECOBJS1 = hw/dec/ws/init.o hw/dec/ws/mdepthinit.o
+DECLIBS1 = hw/dec/ws/LibraryTargetName(dec) CFBLibs
+ServerTarget(Xdec_md,$(DECDIRS1),$(DECOBJS1), \
+ $(DECLIBS1),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xdec_md
+#endif
+#endif /* XdecMultiDepthServer */
+
+
+#if defined(XsunServer) && XsunServer
+XCOMM
+XCOMM Sun server
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+SUNDDXDIR = hw/sun
+#if DoLoadableServer
+SUNOBJS = hw/sun/sunInit.o hw/sun/sunInitExt.o hw/sun/stubs.o
+#elif (defined(XF86Server) && XF86Server) \
+ || (defined(XorgServer) && XorgServer)
+SUNOBJS = hw/sun/sunInit.o hw/sun/stubs.o
+#else
+SUNOBJS = hw/sun/sunInit.o
+#endif
+SUNDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(SUNDDXDIR) $(DEPDIRS)
+SUNLIBS = hw/sun/LibraryTargetName(sun) CFB8Libs
+SUNSYSLIBS = $(FONTLIBS) $(WIDECHARSYSLIB) $(SYSLIBS)
+SetUIDServerTarget(Xsun,$(SUNDIRS),$(SUNOBJS), \
+ $(LIBCWRAPPER) $(SUNLIBS) $(LOADABLEEXTS),$(SUNSYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xsun
+#endif
+#endif /* XsunServer */
+
+
+#if defined(Xsun24Server) && Xsun24Server
+XCOMM
+XCOMM Sun multiple pixmap depth (8, 12, 24) server
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+CFB24SUBDIR = cfb24
+CFB32SUBDIR = cfb32
+SUNDDXDIR = hw/sun
+SUN24DIRS = $(STDDIRS) $(MFBDIR) \
+ $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) \
+ $(SUNDDXDIR) $(DEPDIRS)
+#if DoLoadableServer
+SUN24OBJS = hw/sun/sunInitMulti.o hw/sun/sunInitExt.o hw/sun/stubs.o
+#elif defined(XF86Server) && XF86Server \
+ || (defined(XorgServer) && XorgServer)
+SUN24OBJS = hw/sun/sunInitMulti.o hw/sun/stubs.o
+#else
+SUN24OBJS = hw/sun/sunInitMulti.o
+#endif
+SUN24LIBS = hw/sun/LibraryTargetName(sun) CFBLibs
+SetUIDServerTarget(Xsun24,$(SUN24DIRS),$(SUN24OBJS), \
+ $(LIBCWRAPPER) $(SUN24LIBS) $(LOADABLEEXTS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xsun24
+#endif
+#endif /* Xsun24Server */
+
+
+#if defined(XsunMonoServer) && XsunMonoServer
+XCOMM
+XCOMM Sun monochrome server
+XCOMM
+MFBSUBDIR = mfb
+SUNDDXDIR = hw/sun
+SUNMDIRS = $(STDDIRS) $(MFBDIR) $(SUNDDXDIR) $(DEPDIRS)
+#if defined(XF86Server) && XF86Server \
+ || (defined(XorgServer) && XorgServer)
+SUNMOBJS = hw/sun/sunInitMono.o hw/sun/sunInExMono.o hw/sun/stubs.o
+#else
+SUNMOBJS = hw/sun/sunInitMono.o hw/sun/sunInExMono.o
+#endif
+SUNMLIBS = hw/sun/LibraryTargetName(sun) MFBBareLibs $(EXTENSIONS)
+SetUIDServerTarget(XsunMono,$(SUNMDIRS),$(SUNMOBJS), \
+ $(LIBCWRAPPER) $(SUNMLIBS) $(LOADABLEEXTS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall XsunMono
+#endif
+#endif /* XsunMonoServer */
+
+
+#if defined(XsunLynxServer) && XsunLynxServer
+XCOMM
+XCOMM Sun server for LynxOS microSPARC 2.4.0
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+LYNXDDXDIR = hw/sunLynx
+SUNDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(LYNXDDXDIR) $(DEPDIRS)
+SUNOBJS = hw/sunLynx/sunLyInit.o
+SUNLIBS = hw/sunLynx/libsun.a CFB8Libs
+ServerTarget(Xsun,$(SUNDIRS),$(SUNOBJS), \
+ $(SUNLIBS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xsun
+#endif
+#endif /* XsunLynxServer */
+
+
+#if defined(XsunLynxMonoServer) && XsunLynxMonoServer
+XCOMM
+XCOMM Sun monochrome server for LynxOS microSPARC 2.4.0
+XCOMM
+MFBSUBDIR = mfb
+LYNXDDXDIR = hw/sunLynx
+SUNMDIRS = $(STDDIRS) $(MFBDIR) $(LYNXDDXDIR) $(DEPDIRS)
+SUNMOBJS = hw/sunLynx/sunInitMono.o hw/sunLynx/sunInExMono.o
+SUNMLIBS = hw/sunLynx/libsun.a MFBBareLibs $(OTHEREXTS)
+ServerTarget(XsunMono,$(SUNMDIRS),$(SUNMOBJS), \
+ $(SUNMLIBS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall XsunMono
+#endif
+#endif /* XsunLynxMonoServer */
+
+
+#if HasParallelMake
+XCOMM
+XCOMM force non-parallel build of XF86 servers to prevent MUTEX overrides
+XCOMM
+#if defined(XF86Server) && XF86Server
+XF86SERVER = XFree86
+#endif
+#if defined(XorgServer) && XorgServer
+XF86SERVER = Xorg
+#endif
+#if defined(XnestServer) && XnestServer
+XNEST = Xnext
+#endif
+#if defined(XVirtualFramebufferServer) && XVirtualFramebufferServer
+XVFB = Xvfb
+#endif
+#if XdmxServer
+XDMX = Xdmx
+#endif
+#if defined(XWinServer) && XWinServer && !MakeDllModules
+XWIN = XWin
+#endif
+#if defined(NXAgentServer) && NXAgentServer
+NXAGENT = nxagent
+#endif
+#if defined(NXWinServer) && NXWinServer && !MakeDllModules
+NXWIN = NXWin
+#endif
+#if (defined(XF86Server) && XF86Server) || \
+ (defined(XorgServer) && XorgServer) || \
+ (defined(XnestServer) && XnestServer) || \
+ (defined(NXAgentServer) && NXAgentServer) || \
+ (defined(XVirtualFramebufferServer) && XVirtualFramebufferServer) || \
+ (defined(XdmxServer) && XdmxServer) || \
+ (!MakeDllModules && defined(XWinServer) && XWinServer) || \
+ (!MakeDllModules && defined(NXWinServer) && NXWinServer)
+MakeMutex($(XF86SERVER) $(XNEST) $(XVFB) $(XWIN) $(NXAGENT) $(NXWIN))
+#endif
+MakeMutex($(STDDIRS) mfb fb cfb cfb16 cfb24 cfb32)
+#endif
+
+
+#if defined(XF86Server) && XF86Server
+XCOMM
+XCOMM XFree86 Server
+XCOMM
+FBSUBDIR = fb
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+CFB24SUBDIR = cfb24
+CFB32SUBDIR = cfb32
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+LAYERDIR = miext/layer
+#ifdef OS2Architecture
+SERVERDEFFILE = XFree86.def
+XNESTDEFFILE = Xnest.def
+XVFBDEFFILE = Xvfb.def
+#endif
+#if XF86AFB
+AFBSUBDIR = afb
+#endif
+XFREE86DDXDIR = hw/xfree86
+XF86SERVERSUBDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(AFBDIR) \
+ $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) \
+ $(SHADOWDIR) $(LAYERDIR) $(XFREE86DDXDIR) $(DEPDIRS) \
+ $(MIDAMAGEDIR)
+XF86INIT = $(XF86COMSRC)/xf86Init.o $(XF86COMSRC)/xf86IniExt.o
+XF86COMLIB = $(XF86COMSRC)/LibraryTargetName(xf86)
+XF86PARSLIB= $(XF86PARSERSRC)/LibraryTargetName(xf86config)
+XF86OSLIB = $(XF86OSSRC)/LibraryTargetName(xf86_os)
+#if XF86XAA
+XF86XAALIB = $(XF86SRC)/xaa/LibraryTargetName(xaa)
+#endif
+#if XF86EXA
+XF86EXALIB = $(XF86SRC)/exa/LibraryTargetName(exa)
+#endif
+#if XF86VgaHw
+XF86VGAHWLIB = $(XF86SRC)/vgahw/LibraryTargetName(vgahw)
+#endif
+#if XF86FBDevHw
+XF86FBDEVHWLIB = $(XF86SRC)/fbdevhw/LibraryTargetName(fbdevhw)
+#endif
+#if XF1Bpp || XF4Bpp
+XF1BPPLIB = $(XF86SRC)/xf1bpp/LibraryTargetName(xf1bpp)
+#endif
+#if XF4Bpp
+XF4BPPLIB = $(XF86SRC)/xf4bpp/LibraryTargetName(xf4bpp)
+#endif
+#if XF8_32Wid
+XF8_32WIDLIB = $(XF86SRC)/xf8_32wid/LibraryTargetName(xf8_32wid)
+#endif
+#if XF8_32Bpp
+XF8_32BPPLIB = $(XF86SRC)/xf8_32bpp/LibraryTargetName(xf8_32bpp)
+#endif
+#if XF8_16Bpp
+XF8_16BPPLIB = $(XF86SRC)/xf8_16bpp/LibraryTargetName(xf8_16bpp)
+#endif
+#if XFShadowFB
+XFSHADOWFBLIB = $(XF86SRC)/shadowfb/LibraryTargetName(shadowfb)
+#endif
+#if XF86AFB
+AFBLIB = afb/LibraryTargetName(afb)
+#endif
+XF86DRIVERLIB = $(XF86SRC)/drivers/LibraryTargetName(driver)
+#if XF86Ramdac
+XF86RAMDACLIB = $(XF86SRC)/ramdac/LibraryTargetName(ramdac)
+#endif
+#if XF86I2C
+XF86I2CLIB = $(XF86SRC)/i2c/LibraryTargetName(i2c)
+#endif
+#if XF86DDC
+XF86DDCLIB = $(XF86SRC)/ddc/LibraryTargetName(ddc)
+#endif
+#if XF86VBE
+XF86VBELIB = $(XF86SRC)/vbe/LibraryTargetName(vbe)
+#endif
+#if XF86RAC
+XF86RACLIB = $(XF86SRC)/rac/LibraryTargetName(rac)
+#endif
+#if XF86INT10_BUILD > X86EMU_GENERIC
+XF86INT10LIB = $(XF86OSSRC)/LibraryTargetName(int10)
+#else
+XF86INT10LIB = $(XF86SRC)/int10/LibraryTargetName(int10)
+#endif
+#if UseMemLeak
+MEMDEBUGLIB = $(TOP)/util/memleak/LibraryTargetName(memleak)
+#endif
+XF86IDRIVERLIB = $(XF86SRC)/input/LibraryTargetName(idriver)
+#if !DoLoadableServer
+XF86DRVOBJS = $(XF86SRC)/drivers/drvConf.o
+XF86DRVLIBS = $(XF86DRIVERLIB) $(XF86RAMDACLIB) $(XF86DDCLIB) $(XF86I2CLIB) \
+ $(XF86XAALIB) $(XF86EXALIB) $(XF86VGAHWLIB) $(XF86FBDEVHWLIB) \
+ $(XF8_32WIDLIB) $(XF8_32BPPLIB) \
+ $(XF8_16BPPLIB) \
+ $(XF4BPPLIB) $(XF1BPPLIB) $(XFSHADOWFBLIB) $(AFBLIB)
+XF86IDRVOBJS = $(XF86SRC)/input/drvConf.o
+XF86IDRVLIBS = $(XF86IDRIVERLIB)
+XF86SCANLIB = $(XF86SRC)/scanpci/LibraryTargetName(scanpci)
+XF86LIBS = $(MEMDEBUGLIB) $(XF86INIT) $(XF86COMLIB) $(XF86RACLIB) \
+ $(XF86PARSLIB) $(XF86VBELIB) $(XF86OSLIB) $(XF86INT10LIB)
+#else
+XF86LIBS = $(MEMDEBUGLIB) $(XF86INIT) $(XF86COMLIB) \
+ $(XF86PARSLIB) $(XF86OSLIB)
+#endif
+#if DoLoadableServer
+XF86LOADERLIB = $(XF86SRC)/loader/LibraryTargetName(loader)
+XF86MAINLIBS = PreFbLibsNoFont \
+ $(FONTBASE) $(OTHEREXTS) $(XF86COMLIB) \
+ NoMfbPostFbLibs
+XF86SERVERSYSLIBS = $(SYSLIBS) $(LIBDL) $(LIBREGEX)
+XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
+ $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB)
+#else
+XF86MAINLIBS = MiExtLibs AllFBLibs $(XF86COMLIB) $(MI)
+XF86SERVERSYSLIBS = $(FONTLIBS) $(SYSLIBS) $(LIBDL) $(LIBREGEX)
+XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
+ $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB) \
+ $(XF86DDCLIB)
+#endif
+XF86SERVEROBJS = $(XF86XKBOBJS) $(XF86DRVOBJS) $(XF86IDRVOBJS)
+#if HasParallelMake
+MakeMutex($(XF86SERVERSUBDIRS) $(XF86SERVERLIBS) $(XF86SERVERSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XF86SERVERLIBS) $(XF86SERVERSYSLIBS):: $(XF86SERVERSUBDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+SetUIDServerTarget(XFree86,$(XF86SERVERSUBDIRS),$(XF86SERVEROBJS) $(SERVERDEFFILE), \
+ $(XF86SERVERLIBS),$(XF86SERVERSYSLIBS))
+#if DoLoadableServer
+ServerDriverSDKTarget(XFree86)
+#endif
+#ifndef ServerToInstall
+#define ServerToInstall XFree86
+#endif
+#endif /* XF86Server */
+
+#if defined(XorgServer) && XorgServer
+XCOMM
+XCOMM Xorg Server
+XCOMM
+FBSUBDIR = fb
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+#if XF8_32Wid
+CFB24SUBDIR = cfb24
+#endif
+CFB32SUBDIR = cfb32
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+LAYERDIR = miext/layer
+#ifdef OS2Architecture
+SERVERDEFFILE = Xorg.def
+XNESTDEFFILE = Xnest.def
+XVFBDEFFILE = Xvfb.def
+#endif
+#if XF86AFB
+AFBSUBDIR = afb
+#endif
+XFREE86DDXDIR = hw/xfree86
+XF86SERVERSUBDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(AFBDIR) \
+ $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) \
+ $(SHADOWDIR) $(LAYERDIR) $(XFREE86DDXDIR) $(DEPDIRS) \
+ $(MIDAMAGEDIR)
+XF86INIT = $(XF86COMSRC)/xf86Init.o $(XF86COMSRC)/xf86IniExt.o
+XF86COMLIB = $(XF86COMSRC)/LibraryTargetName(xf86)
+XF86PARSLIB= $(XF86PARSERSRC)/LibraryTargetName(xf86config)
+XF86OSLIB = $(XF86OSSRC)/LibraryTargetName(xf86_os)
+#if XF86XAA
+XF86XAALIB = $(XF86SRC)/xaa/LibraryTargetName(xaa)
+#endif
+#if XF86EXA
+XF86EXALIB = $(XF86SRC)/exa/LibraryTargetName(exa)
+#endif
+#if XF86VgaHw
+XF86VGAHWLIB = $(XF86SRC)/vgahw/LibraryTargetName(vgahw)
+#endif
+#if XF86FBDevHw
+XF86FBDEVHWLIB = $(XF86SRC)/fbdevhw/LibraryTargetName(fbdevhw)
+#endif
+#if XF1Bpp || XF4Bpp
+XF1BPPLIB = $(XF86SRC)/xf1bpp/LibraryTargetName(xf1bpp)
+#endif
+#if XF4Bpp
+XF4BPPLIB = $(XF86SRC)/xf4bpp/LibraryTargetName(xf4bpp)
+#endif
+#if XF8_32Wid
+XF8_32WIDLIB = $(XF86SRC)/xf8_32wid/LibraryTargetName(xf8_32wid)
+#endif
+#if XF8_32Bpp
+XF8_32BPPLIB = $(XF86SRC)/xf8_32bpp/LibraryTargetName(xf8_32bpp)
+#endif
+#if XF8_16Bpp
+XF8_16BPPLIB = $(XF86SRC)/xf8_16bpp/LibraryTargetName(xf8_16bpp)
+#endif
+#if XFShadowFB
+XFSHADOWFBLIB = $(XF86SRC)/shadowfb/LibraryTargetName(shadowfb)
+#endif
+#if XF86AFB
+AFBLIB = afb/LibraryTargetName(afb)
+#endif
+XF86DRIVERLIB = $(XF86SRC)/drivers/LibraryTargetName(driver)
+#if XF86Ramdac
+XF86RAMDACLIB = $(XF86SRC)/ramdac/LibraryTargetName(ramdac)
+#endif
+#if XF86I2C
+XF86I2CLIB = $(XF86SRC)/i2c/LibraryTargetName(i2c)
+#endif
+#if XF86DDC
+XF86DDCLIB = $(XF86SRC)/ddc/LibraryTargetName(ddc)
+#endif
+#if XF86VBE
+XF86VBELIB = $(XF86SRC)/vbe/LibraryTargetName(vbe)
+#endif
+#if XF86RAC
+XF86RACLIB = $(XF86SRC)/rac/LibraryTargetName(rac)
+#endif
+#if XF86INT10_BUILD > X86EMU_GENERIC
+XF86INT10LIB = $(XF86OSSRC)/LibraryTargetName(int10)
+#else
+XF86INT10LIB = $(XF86SRC)/int10/LibraryTargetName(int10)
+#endif
+#if UseMemLeak
+MEMDEBUGLIB = $(TOP)/util/memleak/LibraryTargetName(memleak)
+#endif
+XF86IDRIVERLIB = $(XF86SRC)/input/LibraryTargetName(idriver)
+#if !DoLoadableServer
+XF86DRVOBJS = $(XF86SRC)/drivers/drvConf.o
+XF86DRVLIBS = $(XF86DRIVERLIB) $(XF86RAMDACLIB) $(XF86DDCLIB) $(XF86I2CLIB) \
+ $(XF86XAALIB) $(XF86EXALIB) $(XF86VGAHWLIB) $(XF86FBDEVHWLIB) \
+ $(XF8_32WIDLIB) $(XF8_32BPPLIB) \
+ $(XF8_16BPPLIB) \
+ $(XF4BPPLIB) $(XF1BPPLIB) $(XFSHADOWFBLIB) $(AFBLIB)
+XF86IDRVOBJS = $(XF86SRC)/input/drvConf.o
+XF86IDRVLIBS = $(XF86IDRIVERLIB)
+XF86SCANLIB = $(XF86SRC)/scanpci/LibraryTargetName(scanpci)
+XF86LIBS = $(MEMDEBUGLIB) $(XF86INIT) $(XF86COMLIB) $(XF86RACLIB) \
+ $(XF86PARSLIB) $(XF86VBELIB) $(XF86OSLIB) $(XF86INT10LIB)
+#else
+XF86LIBS = $(MEMDEBUGLIB) $(XF86INIT) $(XF86COMLIB) \
+ $(XF86PARSLIB) $(XF86OSLIB)
+#endif
+#if DoLoadableServer
+XF86LOADERLIB = $(XF86SRC)/loader/LibraryTargetName(loader)
+XF86MAINLIBS = PreFbLibsNoFont \
+ $(FONTBASE) $(OTHEREXTS) $(XF86COMLIB) \
+ NoMfbPostFbLibs
+XF86SERVERSYSLIBS = $(SYSLIBS) $(LIBDL) $(LIBREGEX)
+XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
+ $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB)
+#else
+XF86MAINLIBS = MiExtLibs AllFBLibs $(XF86COMLIB) $(MI)
+XF86SERVERSYSLIBS = $(FONTLIBS) $(SYSLIBS) $(LIBDL) $(LIBREGEX)
+XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
+ $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB) \
+ $(XF86DDCLIB)
+#endif
+XF86SERVEROBJS = $(XF86XKBOBJS) $(XF86DRVOBJS) $(XF86IDRVOBJS)
+#if HasParallelMake
+MakeMutex($(XF86SERVERSUBDIRS) $(XF86SERVERLIBS) $(XF86SERVERSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XF86SERVERLIBS) $(XF86SERVERSYSLIBS):: $(XF86SERVERSUBDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+SetUIDServerTarget(Xorg,$(XF86SERVERSUBDIRS),$(XF86SERVEROBJS) $(SERVERDEFFILE), \
+ $(XF86SERVERLIBS),$(XF86SERVERSYSLIBS))
+#if DoLoadableServer
+ServerDriverSDKTarget(Xorg)
+#endif
+#ifndef ServerToInstall
+#define ServerToInstall Xorg
+#endif
+#endif /* XorgServer */
+
+#if defined(XprtServer) && XprtServer
+XCOMM
+XCOMM Print Server
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB32SUBDIR = cfb32
+MIDAMAGEDIR = miext/damage
+XPSUBDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB32DIR) $(DEPDIRS) \
+ $(MIDAMAGEDIR)
+XPOBJS = Xprint/ddxInit.o Xprint/dpmsstubs.o Xprint/miinitext.o
+#if PrintOnlyServer
+XPLIBS = PreFbLibs $(XPDDXLIBS) $(XPDDXFBLIBS) PostFbLibs
+#else
+XPLIBS = PreFbLibs PostFbLibs
+#endif
+#if (defined(SunArchitecture) || defined(SparcArchitecture)) && \
+ defined(SVR4Architecture)
+XPSYSLIBS = $(FONTLIBS) $(CBRT) $(SYSLIBS) $(XONLYLIB) -lw
+#else
+XPSYSLIBS = $(FONTLIBS) $(CBRT) $(SYSLIBS) $(XONLYLIB)
+#endif
+#if HasParallelMake
+MakeMutex($(XPSUBDIRS) $(XPOBJS) $(XPLIBS) $(XPSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XPOBJS) $(XPLIBS) $(XPSYSLIBS):: $(XPSUBDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+ServerTarget(Xprt,$(XPSUBDIRS),$(XPOBJS), \
+ $(LIBCWRAPPER) $(XPLIBS) $(LOADABLEEXTS),$(XPSYSLIBS))
+#endif /* XprtServer */
+
+#if defined(XnestServer) && XnestServer
+XCOMM
+XCOMM Server with Xlib-based ddx
+XCOMM
+#ifndef Win32Architecture
+XNESTDDXDIR = hw/xnest
+#else
+XNESTDDXDIR = hw
+#endif
+#if BuildDPMS
+XNESTDPMSSTUBOBJS = $(XNESTDDXDIR)/dpmsstubs.o
+#endif
+XNESTDIRS = $(STDDIRS) $(XNESTDDXDIR) $(DEPDIRS)
+#if !defined(LynxOSArchitecture) && \
+ !defined(Win32Architecture) && \
+ !defined(QNX4Architecture)
+XNESTOBJS = hw/xnest/miinitext.o $(XNESTDPMSSTUBOBJS)
+#else
+XNESTOBJS = hw/xnest/miinitext.o dix/main.o $(XNESTDPMSSTUBOBJS)
+#endif
+XNEST = hw/xnest/LibraryTargetName(xnest)
+XNESTLIBS = PreFbLibs $(XNEST) NoMfbPostFbLibs $(XNEST)
+XNESTSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XLIB) $(SYSLIBS)
+#if HasParallelMake
+MakeMutex($(XNESTDIRS) $(XNESTOBJS) $(XNESTLIBS) $(XNESTSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XNESTOBJS) $(XNESTLIBS) $(XNESTSYSLIBS):: $(XNESTDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+ServerTarget(Xnest,$(XNESTDIRS),$(XNESTOBJS) $(XNESTDEFFILE), \
+ $(LIBCWRAPPER) $(XNESTLIBS) $(LOADABLEEXTS),$(XNESTSYSLIBS))
+#endif /* XnestServer */
+
+#if defined(NXAgentServer) && NXAgentServer
+XCOMM
+XCOMM Nested server with NXlib-based ddx and compressed transport.
+XCOMM
+FBSUBDIR = fb
+MIDAMAGEDIR = miext/damage
+FBDIR = fb
+#ifndef Win32Architecture
+NXAGENTDDXDIR = hw/nxagent
+#else
+NXAGENTDDXDIR = hw
+#endif
+
+NXAGENTDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(MIDAMAGEDIR) $(NXAGENTDDXDIR) $(DEPDIRS)
+
+#if defined(SunArchitecture) || \
+ defined(SparcArchitecture)
+NXAGENTOBJS = hw/nxagent/miinitext.o \
+ hw/nxagent/NXwindow.o \
+ hw/nxagent/NXevents.o \
+ hw/nxagent/NXproperty.o \
+ hw/nxagent/NXdixfonts.o \
+ hw/nxagent/NXglyphcurs.o \
+ hw/nxagent/NXdispatch.o \
+ hw/nxagent/NXrender.o \
+ hw/nxagent/NXglyph.o \
+ hw/nxagent/NXpicture.o \
+ hw/nxagent/NXextension.o \
+ hw/nxagent/NXglxext.o \
+ hw/nxagent/NXmiglyph.o \
+ hw/nxagent/NXmiexpose.o \
+ hw/nxagent/NXresource.o \
+ hw/nxagent/NXmiwindow.o \
+ hw/nxagent/NXdamage.o
+#elif !defined(LynxOSArchitecture) && \
+ !defined(Win32Architecture) && \
+ !defined(QNX4Architecture)
+NXAGENTOBJS = hw/nxagent/miinitext.o \
+ hw/nxagent/NXwindow.o \
+ hw/nxagent/NXevents.o \
+ hw/nxagent/NXproperty.o \
+ hw/nxagent/NXdixfonts.o \
+ hw/nxagent/NXglyphcurs.o \
+ hw/nxagent/NXdispatch.o \
+ hw/nxagent/NXrender.o \
+ hw/nxagent/NXglyph.o \
+ hw/nxagent/NXpicture.o \
+ hw/nxagent/NXextension.o \
+ hw/nxagent/NXglxext.o \
+ hw/nxagent/NXxvdisp.o \
+ hw/nxagent/NXmiglyph.o \
+ hw/nxagent/NXmiexpose.o \
+ hw/nxagent/NXresource.o \
+ hw/nxagent/NXmiwindow.o \
+ hw/nxagent/NXdamage.o
+#else
+NXAGENTOBJS = hw/nxagent/miinitext.o \
+ hw/nxagent/NXwindow.o \
+ hw/nxagent/NXevents.o \
+ hw/nxagent/NXproperty.o \
+ hw/nxagent/NXdixfonts.o \
+ hw/nxagent/NXglyphcurs.o \
+ hw/nxagent/NXdispatch.o \
+ hw/nxagent/NXrender.o \
+ hw/nxagent/NXglyph.o \
+ hw/nxagent/NXpicture.o \
+ hw/nxagent/NXextension.o \
+ hw/nxagent/NXglxext.o \
+ hw/nxagent/NXxvdisp.o \
+ hw/nxagent/NXmiglyph.o \
+ hw/nxagent/NXmiexpose.o \
+ hw/nxagent/NXresource.o \
+ hw/nxagent/NXmiwindow.o \
+ hw/nxagent/NXdamage.o \
+ dix/main.o
+#endif
+
+XPMLIB = -lXpm
+NXAGENT = hw/nxagent/LibraryTargetName(nxagent)
+NXAGENTLIBS = PreFbLibs $(NXAGENT) FbPostFbLibs $(NXAGENT) $(MI)
+NXAGENTSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XLIB) $(SYSLIBS) $(XPMLIB)
+#if HasParallelMake
+MakeMutex($(NXAGENTDIRS) $(NXAGENTOBJS) $(NXAGENTLIBS) $(NXAGENTSYSLIBS))
+#endif
+#if ForceServerRemake
+$(NXAGENTOBJS) $(NXAGENTLIBS) $(NXAGENTSYSLIBS):: $(NXAGENTDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+#if NXLibraries
+/*
+ * We need this as the linker will try to locate dependencies of X11 and Xext.
+ */
+
+#if defined(SunArchitecture)
+NXAGENTNXLIBS = -L ../../../nxcomp -L ../../../nxcompext -L ../../../nxcompshad \
+ -lXcomp -lXcompext -lXcompshad -lrt -L/usr/sfw/lib -lXrender \
+ -L../../../nx-X11/exports/lib -lXtst -lXdamage -lXrandr -lXcomposite
+#elif defined(cygwinArchitecture)
+NXAGENTNXLIBS = -L ../../../nxcomp -L ../../../nxcompext \
+ -lXcomp -lXcompext -lXrender -lX11 -lXext -lXcomposite \
+ -L ../../../nxcompshad -lXcompshad -L../../../nx-X11/exports/lib -lXtst
+#else
+NXAGENTNXLIBS = -L ../../../nxcomp -L ../../../nxcompext -L ../../../nxcompshad \
+ -lXcomp -lXcompext -lXcompshad -lXrender -lX11 -lXext \
+ -L../../../nx-X11/exports/lib -lXtst -lXdamage -lXrandr -lXcomposite
+#endif
+
+#endif
+
+#ifdef cygwinArchitecture
+NX_XSHADOWLIBNAME = cygXcompshad.dll
+#else
+NX_XSHADOWLIBNAME = libXcompshad.so
+#endif
+
+NX_XSHADOWLIBDIR = $(XTOP)/../nxcompshad
+NX_XSHADOWLIBTARGET = $(NX_XSHADOWLIBDIR)/$(NX_XSHADOWLIBNAME)
+NX_XSHADOWCONFIGTARGET = $(NX_XSHADOWLIBDIR)/config.status
+
+$(NX_XSHADOWCONFIGTARGET):
+ cd $(NX_XSHADOWLIBDIR) && \
+ ./configure
+
+#ifdef SunArchitecture
+$(NX_XSHADOWLIBTARGET): $(NX_XSHADOWCONFIGTARGET)
+ cd $(NX_XSHADOWLIBDIR) && \
+ gmake
+#else
+$(NX_XSHADOWLIBTARGET): $(NX_XSHADOWCONFIGTARGET)
+ cd $(NX_XSHADOWLIBDIR) && \
+ make
+#endif
+
+ServerTarget(nxagent,$(NX_XSHADOWLIBTARGET) $(NXAGENTDIRS),$(NXAGENTOBJS), \
+ $(LIBCWRAPPER) $(NXAGENTLIBS) $(LOADABLEEXTS),$(NXAGENTSYSLIBS) $(NXAGENTNXLIBS))
+
+/*
+ * Hard coded target to build a static nxagent server.
+ */
+nxagent_static: nxagent
+ if [ -f nxagent_static ]; then set -x; \
+ $(MV) nxagent_static nxagent_static.bak; \
+ else exit 0; fi
+ $(CCLINK) -o nxagent_static -static $(LDOPTIONS) $(NXAGENTOBJS) \
+ $(LIBCWRAPPER) $(NXAGENTLIBS) $(LOADABLEEXTS) $(LDLIBS) \
+ $(NXAGENTSYSLIBS) $(EXTRA_LOAD_FLAGS)
+
+/*
+ * Hard coded target to build a static nxagent server except for libX11 and libXext.
+ */
+nxagent_static_nolibs: nxagent
+ if [ -f nxagent_static_nolibs ]; then set -x; \
+ $(MV) nxagent__static_nolibs nxagent_static_nolibs.bak; \
+ else exit 0; fi
+ $(CCLINK) -o nxagent_static_nolibs -Wl,-Bstatic $(LDOPTIONS) $(NXAGENTOBJS) \
+ $(NXAGENTLIBS) $(LOADABLEEXTS) $(LIBCWRAPPER) $(LDLIBS) $(FONTLIBS) \
+ $(LDPRELIBS) $(SYSLIBS) -Wl,-Bdynamic -lXext -lX11 $(EXTRA_LOAD_FLAGS)
+#endif /* NXAgentServer */
+
+#if defined(XnonServer) && XnonServer
+XCOMM
+XCOMM non server, just compile sources for build test
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+CFB32SUBDIR = cfb32
+#if HasParallelMake
+MakeMutex($(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB32DIR) $(DEPDIRS))
+#endif
+Xnon: $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB32DIR) $(DEPDIRS)
+#endif /* XnonServer */
+
+
+#if defined(XVirtualFramebufferServer) && XVirtualFramebufferServer
+XCOMM
+XCOMM server with Virtual (malloced) framebuffer
+XCOMM
+MFBSUBDIR = mfb
+FBSUBDIR = fb
+#if defined(Win32Architecture)
+XVFBDDXDIR = hw
+#else
+XVFBDDXDIR = hw/vfb
+#endif
+XVFBDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(XVFBDDXDIR) $(DEPDIRS)
+#ifndef Win32Architecture
+#if BuildDPMS
+XVFBDPMSSTUBOBJS = $(XVFBDDXDIR)/dpmsstubs.o
+#endif
+XVFBOBJS = $(XVFBDDXDIR)/stubs.o $(XVFBDDXDIR)/miinitext.o $(XVFBDPMSSTUBOBJS)
+#else
+XVFBOBJS = dix/main.o hw/vfb/stubs.o hw/vfb/miinitext.o
+#endif
+XVFB = $(XVFBDDXDIR)/LibraryTargetName(vfb)
+XVFBLIBS = PreFbLibs $(XVFB) $(FB) PostFbLibs $(MI)
+XVFBSYSLIBS = $(FONTLIBS) $(SYSLIBS)
+#if HasParallelMake
+MakeMutex($(XVFBDIRS) $(XVFBOBJS) $(XVFB) $(XVFBLIBS) $(XVFBSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XVFBOBJS) $(XVFB) $(XVFBLIBS) $(XVFBSYSLIBS):: $(XVFBDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+ServerTarget(Xvfb,$(XVFBDIRS),$(XVFBOBJS) $(XVFBDEFFILE), \
+ $(LIBCWRAPPER) $(XVFBLIBS) $(LOADABLEEXTS),$(XVFBSYSLIBS))
+#endif /* XVirtualFramebufferServer */
+
+#if defined(XdmxServer) && XdmxServer
+XCOMM
+XCOMM distribued multihead Server
+XCOMM
+#ifndef Win32Architecture
+XDMXDDXDIR = hw/dmx
+#else
+XDMXDDXDIR = hw
+#endif
+FBDIR = fb
+FBSUBDIR = fb
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+XDMXDIRS = $(STDDIRS) $(XDMXDDXDIR) $(SHADOWDIR) $(DEPDIRS) $(FBDIR) $(MIDAMAGEDIR)
+#if BuildGlxExt
+#if BuildXinerama
+GLXPROXY_EXTRAOBJS = hw/dmx/panoramiX.o
+#endif
+GLXPROXYLIB = hw/dmx/glxProxy/LibraryTargetName(glxProxy)
+#endif
+#if !defined(LynxOSArchitecture) && \
+ !defined(Win32Architecture) && \
+ !defined(QNX4Architecture)
+XDMXOBJS = hw/dmx/miinitext.o $(GLXPROXY_EXTRAOBJS)
+#else
+XDMXOBJS = hw/dmx/miinitext.o $(GLXPROXY_EXTRAOBJS) dix/main.o
+#endif
+XDMX = hw/dmx/LibraryTargetName(dmx) \
+ hw/dmx/input/LibraryTargetName(dmxinput) \
+ hw/dmx/config/LibraryTargetName(dmxconfig) \
+ $(GLXPROXYLIB)
+XDMXLIBS = PreFbLibs $(XDMX) MiExtLibs FbPostFbLibs $(XDMX)
+#if BuildRender
+XDMXRENDERLIB = $(XRENDERLIB)
+#endif
+XDMXSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XILIB) $(XLIB) $(SYSLIBS) $(XMULIB) $(XDMXRENDERLIB)
+#if HasParallelMake
+MakeMutex($(XDMXDIRS) $(XDMXOBJS) $(XDMXLIBS) $(XDMXSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XDMXOBJS) $(XDMXLIBS) $(XDMXSYSLIBS):: $(XDMXDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+ServerTarget(Xdmx,$(XDMXDIRS),$(XDMXOBJS), \
+ $(LIBCWRAPPER) $(XDMXLIBS) $(LOADABLEEXTS),$(XDMXSYSLIBS))
+#endif /* XdmxServer */
+
+#if defined(XWinServer) && XWinServer
+XCOMM
+XCOMM X Server for MS Windows
+XCOMM
+FBSUBDIR = fb
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+#if BuildXWinLayer
+LAYERDIR = miext/layer
+XWINLAYERLIB = $(LAYER)
+#else
+LAYERDIR =
+XWINLAYERLIB =
+#endif
+#if BuildXWinMultiWindowExtWM
+ROOTLESSDIR = miext/rootless
+ROOTLESSLIB = $(ROOTLESSDIR)/LibraryTargetName(rootless) \
+ $(ROOTLESSDIR)/safeAlpha/LibraryTargetName(safeAlpha) \
+ $(ROOTLESSDIR)/accel/LibraryTargetName(rlAccel)
+#else
+ROOTLESSDIR =
+ROOTLESSLIB =
+#endif
+XWINDDXDIR = hw/xwin
+#if BuildXWinXF86Config
+XWINPARSERDIR = hw/xfree86/parser
+XWINPARSERLIB = $(XWINPARSERDIR)/LibraryTargetName(xf86config)
+#else
+XWINPARSERDIR =
+XWINPARSERLIB =
+#endif
+#if defined(GlxUseWindows) && GlxUseWindows
+XWINOPENGLLIB = -lopengl32
+#else
+XWINOPENGLLIB =
+#endif
+
+XWINLIB = $(XWINDDXDIR)/LibraryTargetName(XWin)
+XWINDIRS = $(STDDIRS) $(FBDIR) $(SHADOWDIR) $(LAYERDIR) $(XWINDDXDIR) \
+ $(DEPDIRS) $(XWINPARSERDIR) $(ROOTLESSDIR) $(MIDAMAGEDIR)
+XWINOBJS = $(XWINDDXDIR)/stubs.o $(XWINDDXDIR)/XWin.res
+XWINLIBS = PreFbLibs $(XWINLIB) FbPostFbLibs $(XWINLIB) $(XWINLAYERLIB) \
+ $(SHADOW) $(XWINPARSERLIB) $(ROOTLESSLIB) $(OS)
+#if BuildXWinMultiWindow || BuildXWinClipboard
+XWINX11 = $(XONLYLIB)
+# if defined(Win32Architecture)
+PTHREADLIB = -lpthreadGC2
+# endif
+#endif
+#if defined(Win32Architecture)
+# if defined(GlxUseWindows) && GlxUseWindows
+XWINGL32 = -lopengl32
+# endif
+XWINW32 = -lgdi32 -lwsock32 $(XWINGL32) $(PTHREADLIB)
+#else
+XWINW32 = -lgdi32
+#endif
+XWINSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XWINX11) $(SYSLIBS) $(XWINW32)
+
+EXTRA_LDOPTIONS = -e _mainCRTStartup
+
+#if HasParallelMake
+MakeMutex($(XWINDIRS) $(XWINOBJS) $(XWINLIB) $(XWINLIBS) $(XWINSYSLIBS))
+#endif
+
+#if ForceServerRemake
+$(XWINOBJS) $(XWINLIB) $(XWINLIBS) $(XWINSYSLIBS):: $(XWINDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+
+#ifdef mingwArchitecture
+XWINSERVERNAME=Xming
+XWINGLSERVERNAME=XmingGL
+#else
+XWINSERVERNAME=XWin
+XWINGLSERVERNAME=XWin_GL
+#endif
+ServerTarget($(XWINSERVERNAME),$(XWINDIRS),$(XWINOBJS), \
+ $(LIBCWRAPPER) $(XWINLIBS) $(LOADABLEEXTS),$(XWINSYSLIBS))
+#if defined(cygwinArchitecture) && defined(GlxUseWindows) && GlxUseWindows
+ServerTarget($(XWINGLSERVERNAME),$(XWINDIRS),$(XWINOBJS), \
+ $(LIBCWRAPPER) $(XWINLIBS) $(LOADABLEEXTS),$(XWINSYSLIBS) \
+ $(XWINOPENGLLIB))
+#endif
+
+#ifndef ServerToInstall
+# define ServerToInstall $(XWINSERVERNAME)
+#endif
+
+#endif /* XWinServer */
+
+
+#if defined(NXWinServer) && NXWinServer
+XCOMM
+XCOMM X Server for MS Windows
+XCOMM
+FBSUBDIR = fb
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+#if BuildXWinLayer
+LAYERDIR = miext/layer
+XWINLAYERLIB = $(LAYER)
+#else
+LAYERDIR =
+XWINLAYERLIB =
+#endif
+#if BuildXWinMultiWindowExtWM
+ROOTLESSDIR = miext/rootless
+ROOTLESSLIB = $(ROOTLESSDIR)/LibraryTargetName(rootless) \
+ $(ROOTLESSDIR)/safeAlpha/LibraryTargetName(safeAlpha) \
+ $(ROOTLESSDIR)/accel/LibraryTargetName(rlAccel)
+#else
+ROOTLESSDIR =
+ROOTLESSLIB =
+#endif
+NXWINDDXDIR = hw/nxwin
+#if BuildXWinXF86Config
+XWINPARSERDIR = hw/xfree86/parser
+XWINPARSERLIB = $(XWINPARSERDIR)/LibraryTargetName(xf86config)
+#else
+XWINPARSERDIR =
+XWINPARSERLIB =
+#endif
+#if defined(GlxUseWindows) && GlxUseWindows
+XWINOPENGLLIB = -lopengl32
+#else
+XWINOPENGLLIB =
+#endif
+
+NXWINLIB = $(NXWINDDXDIR)/LibraryTargetName(NXWin)
+NXWINDIRS = $(STDDIRS) $(FBDIR) $(SHADOWDIR) $(LAYERDIR) $(NXWINDDXDIR) \
+ $(DEPDIRS) $(XWINPARSERDIR) $(ROOTLESSDIR) $(MIDAMAGEDIR)
+NXWINOBJS = $(NXWINDDXDIR)/stubs.o $(NXWINDDXDIR)/NXWin.res
+NXWINLIBS = PreFbLibs $(NXWINLIB) FbPostFbLibs $(NXWINLIB) $(XWINLAYERLIB) \
+ $(SHADOW) $(XWINPARSERLIB) $(ROOTLESSLIB) $(OS)
+#if BuildXWinMultiWindow || BuildXWinClipboard
+XWINX11 = $(XONLYLIB)
+# if defined(Win32Architecture)
+PTHREADLIB = -lpthreadGC
+# endif
+#endif
+#if defined(Win32Architecture)
+# if defined(GlxUseWindows) && GlxUseWindows
+XWINGL32 = -lopengl32
+# endif
+XWINW32 = -lgdi32 -lwsock32 $(XWINGL32) $(PTHREADLIB)
+#else
+XWINW32 = -lgdi32
+#endif
+NXWINSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XWINX11) $(SYSLIBS) $(XWINW32)
+
+NXWINNXLIBS = -L../../../nxcomp -lXcomp
+
+/*
+ * These flags cause NXWin.exe to be a Windows executable, which
+ * prevents NXWin.exe from opening a Command Prompt window when it is
+ * started. However, the flags also prevent NXWin.exe from outputting
+ * its status and error message to a Command Prompt; thus, one most
+ * implement a method to redirect status and error messages to a file
+ * before enabling these flags.
+ */
+EXTRA_LDOPTIONS = -e _mainCRTStartup
+
+#if HasParallelMake
+MakeMutex($(NXWINDIRS) $(NXWINOBJS) $(NXWINLIB) $(NXWINLIBS) $(NXWINSYSLIBS) $(NXWINNXLIBS))
+#endif
+
+#if ForceServerRemake
+$(NXWINOBJS) $(NXWINLIB) $(NXWINLIBS) $(NXWINSYSLIBS) $(NXWINNXLIBS):: $(NXWINDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+
+#ifdef mingwArchitecture
+NXWINSERVERNAME=NXming
+NXWINGLSERVERNAME=NXmingGL
+#else
+NXWINSERVERNAME=NXWin
+NXWINGLSERVERNAME=NXWin_GL
+#endif
+ServerTarget($(NXWINSERVERNAME),$(NXWINDIRS),$(NXWINOBJS), \
+ $(LIBCWRAPPER) $(NXWINLIBS) $(LOADABLEEXTS),$(NXWINSYSLIBS) $(NXWINNXLIBS))
+#if defined(cygwinArchitecture) && defined(GlxUseWindows) && GlxUseWindows
+ServerTarget($(NXWINGLSERVERNAME),$(NXWINDIRS),$(NXWINOBJS), \
+ $(LIBCWRAPPER) $(NXWINLIBS) $(LOADABLEEXTS),$(NXWINSYSLIBS) $(NXWINNXLIBS)\
+ $(XWINOPENGLLIB))
+#endif
+
+#ifndef ServerToInstall
+# define ServerToInstall $(NXWINSERVERNAME)
+#endif
+
+#endif /* NXWinServer */
+
+#if 0
+#if defined(NXWinServer) && NXWinServer
+XCOMM
+XCOMM X Server for MS Windows
+XCOMM
+FBDIR = fb
+SHADOWDIR = miext/shadow
+LAYERDIR = miext/layer
+NXWINDDXDIR = hw/nxwin
+XWINPARSERDIR = hw/xfree86/parser
+XWINPARSERLIB = $(XWINPARSERDIR)/LibraryTargetName(xf86config)
+NXWINLIB = $(NXWINDDXDIR)/LibraryTargetName(nxwin)
+NXWINDIRS = $(STDDIRS) $(FBDIR) $(SHADOWDIR) $(LAYERDIR) $(NXWINDDXDIR) \
+ $(DEPDIRS) $(XWINPARSERDIR)
+#NXWINOBJS = $(NXWINDDXDIR)/stubs.o $(NXWINDDXDIR)/NX.res \
+ $(NXWINDDXDIR)/NXwindow.o \
+ $(NXWINDDXDIR)/NXdispatch.o $(NXWINDDXDIR)/NXproperty.o \
+ $(NXWINDDXDIR)/NXevents.o
+NXWINOBJS = $(NXWINDDXDIR)/stubs.o $(NXWINDDXDIR)/NX.res
+NXWINLIBS = PreFbLibs $(NXWINLIB) FbPostFbLibs $(LAYER) $(SHADOW) \
+ $(XWINPARSERLIB)
+NXWINSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XLIB) $(SYSLIBS) -lgdi32 -lddraw
+NXWINNXLIBS = -L../../../nxcomp -lXcomp
+
+/*
+ * These flags cause NXWin.exe to be a Windows executable, which
+ * prevents NXWin.exe from opening a Command Prompt window when it is
+ * started. However, the flags also prevent NXWin.exe from outputting
+ * its status and error message to a Command Prompt; thus, one most
+ * implement a method to redirect status and error messages to a file
+ * before enabling these flags.
+ */
+EXTRA_LDOPTIONS = -mwindows -e _mainCRTStartup
+
+#if HasParallelMake
+MakeMutex($(NXWINDIRS) $(NXWINOBJS) $(NXWINLIB) $(NXWINLIBS) $(NXWINSYSLIBS) $(NXWINNXLIBS))
+#endif
+
+#if ForceServerRemake
+$(NXWINOBJS) $(NXWINLIB) $(NXWINLIBS) $(NXWINSYSLIBS) $(NXWINNXLIBS):: $(NXWINDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+
+ServerTarget(NXWin,$(NXWINDIRS),$(NXWINOBJS), \
+ $(NXWINLIBS) $(LOADABLEEXTS) $(LIBCWRAPPER),$(NXWINSYSLIBS) $(NXWINNXLIBS))
+
+#ifndef ServerToInstall
+#define ServerToInstall NXWin
+#endif
+
+#endif /* NXWinServer */
+#endif
+
+#ifdef DarwinArchitecture
+/*
+ * To allow building even when building the client-side libraries is turned
+ * off, libraries in ProjectRoot are listed as dependencies for some targets.
+ * This causes problems unless we tell make where to find these dependencies.
+ */
+VPATH = $(BUILDLIBDIR):$(USRLIBDIR)
+#endif
+
+#if defined(XDarwinServer) && XDarwinServer
+XCOMM
+XCOMM X Darwin server for Mac OS X / Darwin
+XCOMM
+FBSUBDIR = fb
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+ROOTLESSDIR = miext/rootless
+DARWINDDXDIR = hw/darwin
+DARWINDIRS = $(STDDIRS) $(FBDIR) $(SHADOWDIR) $(DARWINDDXDIR) $(DEPDIRS)
+DARWINOBJS = $(DARWINDDXDIR)/miinitext.o
+DARWINLIBS = PreFbLibs $(DARWINDDXDIR)/LibraryTargetName(darwin)
+DARWINEXTLIBS = MiExtLibs FbPostFbLibs $(DARWINDDXDIR)/LibraryTargetName(darwin)
+DARWINSYSLIBS = $(FONTLIBS) $(SYSLIBS) -framework IOKit
+IOKITLIB = $(DARWINDDXDIR)/iokit/LibraryTargetName(iokit)
+
+/*
+ * IOKit X server
+ */
+SetUIDServerTarget(XDarwin,$(DARWINDIRS),$(DARWINOBJS), \
+ $(DARWINLIBS) $(IOKITLIB) $(DARWINEXTLIBS),$(DARWINSYSLIBS))
+
+#if DarwinQuartzSupport
+
+QUARTZDIR = $(DARWINDDXDIR)/quartz
+QUARTZLIB = $(QUARTZDIR)/LibraryTargetName(XQuartz)
+QUARTZSYSLIBS = -framework ApplicationServices -framework Cocoa \
+ -framework CoreAudio -framework Carbon -ObjC
+ROOTLESSLIB = $(ROOTLESSDIR)/LibraryTargetName(rootless) \
+ $(ROOTLESSDIR)/safeAlpha/LibraryTargetName(safeAlpha) \
+ $(ROOTLESSDIR)/accel/LibraryTargetName(rlAccel)
+XPLUGINLIB = XpluginLibrary
+
+#if NothingOutsideProjectRoot
+XDARWINAPPDIR = $(BINDIR)/XDarwin.app/Contents
+#else
+XDARWINAPPDIR = /Applications/XDarwin.app/Contents
+#endif
+
+/*
+ * Quartz X server (installed in its application bundle)
+ */
+SetUIDServerTarget(XDarwinApp,$(DARWINDIRS),$(DARWINOBJS), \
+ $(DARWINLIBS) $(QUARTZLIB) $(DARWINEXTLIBS), \
+ $(DARWINSYSLIBS) $(QUARTZSYSLIBS) -u _miDCInitialize)
+
+install::
+ $(MKDIRHIER) $(DESTDIR)$(XDARWINAPPDIR)/MacOS
+ $(MV) $(DESTDIR)$(BINDIR)/XDarwinApp \
+ $(DESTDIR)$(XDARWINAPPDIR)/MacOS/XDarwin
+ -(cd $(DESTDIR)$(BINDIR); $(RM) XDarwinQuartz; \
+ $(LN) $(XDARWINAPPDIR)/MacOS/XDarwin XDarwinQuartz)
+
+/*
+ * Display mode bundles for Quartz
+ * (installed in their own bundles inside XDarwin's)
+ */
+#if HasXplugin
+XPRDIRS = $(QUARTZDIR)/xpr $(ROOTLESSDIR) $(ROOTLESSDIR)/safeAlpha
+XPRLIBS = $(QUARTZDIR)/xpr/LibraryTargetName(xpr) $(ROOTLESSLIB)
+
+BundleProgramTarget(xpr,XDarwinApp,$(XPRDIRS),$(QUARTZDIR)/xpr/xprScreen.o, \
+ $(XPRLIBS),-framework ApplicationServices \
+ $(XPLUGINLIB),$(XDARWINAPPDIR)/Resources)
+#endif
+
+CRDIRS = $(QUARTZDIR)/cr $(ROOTLESSDIR) $(ROOTLESSDIR)/safeAlpha
+CRLIBS = $(QUARTZDIR)/cr/LibraryTargetName(cr) $(ROOTLESSLIB)
+
+BundleProgramTarget(cr,XDarwinApp,$(CRDIRS),$(QUARTZDIR)/cr/crScreen.o, \
+ $(CRLIBS),-framework ApplicationServices -framework Cocoa \
+ -framework Carbon -ObjC,$(XDARWINAPPDIR)/Resources)
+
+FSDIRS = $(QUARTZDIR)/fullscreen $(SHADOWDIR)
+FSLIBS = $(QUARTZDIR)/fullscreen/LibraryTargetName(fullscreen) $(SHADOW)
+
+BundleProgramTarget(fullscreen,XDarwinApp,$(FSDIRS), \
+ $(QUARTZDIR)/fullscreen/fullscreen.o,$(FSLIBS), \
+ -framework ApplicationServices,$(XDARWINAPPDIR)/Resources)
+
+/*
+ * GLX bundles for Quartz
+ * (installed in their own bundles inside XDarwin's)
+ */
+BundleProgramTarget(glxAGL,XDarwinApp,GL,GL/glx/glxext.o,GL/glx/libglx.a \
+ GL/apple/libAGLcore.a, \
+ -framework AGL -framework OpenGL,$(XDARWINAPPDIR)/Resources)
+
+#if BuildAppleDRI
+BundleProgramTarget(glxCGL,XDarwinApp,GL,GL/glx/glxext.o,GL/glx/libglx.a \
+ GL/apple/libCGLcore.a, \
+ -framework OpenGL $(XPLUGINLIB),$(XDARWINAPPDIR)/Resources)
+#endif
+
+BundleProgramTarget(glxMesa,XDarwinApp,GL,GL/glx/glxext.o,GL/glx/libglx.a \
+ GL/mesa/GLcore/libGLcore.a,NullParameter,$(XDARWINAPPDIR)/Resources)
+
+#else /* !DarwinQuartzSupport */
+
+#define ServerToInstall XDarwin
+
+#endif /* DarwinQuartzSupport */
+
+#endif /* XDarwinServer */
+
+
+CFBSUBDIRS = $(CFB8SUBDIR) $(CFB16SUBDIR) $(CFB24SUBDIR) $(CFB32SUBDIR)
+MIEXTDIRS = $(SHADOWDIR) $(LAYERDIR) $(ROOTLESSDIR) $(MIDAMAGEDIR)
+IPLANDIRS = $(IPLAN2P2DIR) $(IPLAN2P4DIR) $(IPLAN2P8DIR)
+DDXDIRS = $(DECWSDDXDIR) $(SUNDDXDIR) $(LYNXDDXDIR) \
+ $(HPDDXDIR) $(XFREE86DDXDIR) $(XWINDDXDIR) $(DARWINDDXDIR) \
+ $(XVFBDDXDIR) $(XNESTDDXDIR) $(XDMXDDXDIR) $(NXAGENTDDXDIR) $(NXWINDDXDIR)
+SUBDIRS = $(STDDIRS) $(MFBSUBDIR) $(CFBSUBDIRS) \
+ $(IPLANDIRS) $(ILBMDIR) $(AFBSUBDIR) \
+ $(DDXDIRS) $(FBSUBDIR) $(KDRIVEDIRS) $(MIEXTDIRS)
+
+#if defined(ServerToInstall) && !defined(OS2Architecture)
+install::
+ -(cd $(DESTDIR)$(BINDIR); $(RM) X; $(LN) ServerToInstall X)
+#endif
+
+#define IHaveSubdirs
+
+DependSubdirs($(SUBDIRS))
+MakeLintLibSubdirs($(SUBDIRS))
+LintSubdirs($(SUBDIRS))
+
+ForceSubdirs($(DEPDIRS) $(SUBDIRS))
+
+DEFAULTFONTPATH = DefaultFontPath
+EXTRAMANDEFS = -D__default_font_path__="`echo $(DEFAULTFONTPATH) | sed -e 's/,/, /g'`"
+
+InstallManPage(Xserver,$(MANDIR))
+
+#if MakeDllModules && DoLoadableServer && \
+ (defined(SunArchitecture) && defined(SVR4Architecture))
+XCOMM Hackery for building dlopen-able .so modules on Solaris
+
+AllTarget(linker-deps)
+
+LINKER_DEPS_DIRS = $(SUBDIRS) $(FONTLIBSRC)
+
+XCOMM After everything is built, run through and generate linker dependencies
+linker-deps:
+ RunPerlScript($(XF86SRC)/os-support/sunos/find_deps.pl,-R ProjectRoot $(LINKER_DEPS_DIRS))
+ for i in $(LINKER_DEPS_DIRS) ; do \
+ echo "relinking with dependency flags in $(CURRENT_DIR)/$$i..."; \
+ MakeNamedTargetSubdir($$i,NullParameter,all) ; \
+ done
+#endif
diff --git a/nx-X11/programs/Xserver/Imakefile.X.original b/nx-X11/programs/Xserver/Imakefile.X.original
new file mode 100644
index 000000000..58471ca7f
--- /dev/null
+++ b/nx-X11/programs/Xserver/Imakefile.X.original
@@ -0,0 +1,1242 @@
+XCOMM $XdotOrg: xc/programs/Xserver/Imakefile,v 1.37 2005/11/18 18:15:23 ajax Exp $
+XCOMM $Xorg: Imakefile,v 1.4 2001/03/14 18:42:02 pookie Exp $
+/*
+ * Server Master Makefile
+ */
+XCOMM $XFree86: xc/programs/Xserver/Imakefile,v 3.296 2003/11/23 06:47:00 torrey Exp $
+
+#ifndef InstallXserverSetUID
+#define InstallXserverSetUID NO
+#endif
+#define InstallServerSetUID InstallXserverSetUID
+
+#include <Server.tmpl>
+
+/* On most systems the linker requires the libraries in dependency order.
+ But we have no real order because there are cycles. We fix this by adding
+ some libraries twice on the commandline. dependLib will add the
+ dependency library to the commandline if the link order is important */
+#if 1 /* This is currently enabled for all systems */
+#define dependLib(x) x
+#else
+#define dependLib(x)
+#endif
+
+#if (defined (XFree86Version) || defined(XorgVersion))
+/* Do not strip server binaries */
+INSTPGMFLAGS =
+#endif
+
+#define PreFbLibs $(DIX) $(OS) $(XPDDX)
+#define PreFbLibsNoFont $(DIX) $(OS)
+#define BarePostFbLibs $(MFB) $(XPFBLIBS) $(MI)
+#define PostFbLibs BarePostFbLibs $(EXTENSIONS)
+#define NoMfbBarePostFbLibs $(XPFBLIBS) $(MI)
+#if !BuildXinerama
+#define NoMfbPostFbLibs NoMfbBarePostFbLibs $(EXTENSIONS)
+#else
+#define NoMfbPostFbLibs $(EXTENSIONS) NoMfbBarePostFbLibs $(EXTENSIONS)
+#endif
+
+#define MFBBareLibs PreFbLibs BarePostFbLibs
+#define NoMFBBareLibs PreFbLibs NoMfbBarePostFbLibs
+#define MFBLibs PreFbLibs PostFbLibs
+#define NoMFBLibs PreFbLibs NoMfbPostFbLibs
+#define CFBLibs PreFbLibs $(CFB) PostFbLibs
+#define CFB4Libs PreFbLibs $(CFB4) PostFbLibs
+#define CFB8Libs PreFbLibs $(CFB8) PostFbLibs
+#define CFB16Libs PreFbLibs $(CFB16) PostFbLibs
+#define CFB24Libs PreFbLibs $(CFB24) PostFbLibs
+#define CFB32Libs PreFbLibs $(CFB32) PostFbLibs
+
+#define NoMFBCFBLibs PreFbLibs $(CFB) NoMfbPostFbLibs
+#define NoMFBCFB8Libs PreFbLibs $(CFB8) NoMfbPostFbLibs
+#define FbPostFbLibs $(FB) NoMfbPostFbLibs
+#define FBLibs PreFbLibs FbPostFbLibs
+
+#define MiExtLibs $(SHADOW)
+
+#define AllFBLibs PreFbLibs $(FB) $(CFB) PostFbLibs
+
+#if BuildGlxExt
+# if BuildXF86DRI && ((defined(XF86Server) && XF86Server) \
+ || (defined(XorgServer) && XorgServer))
+ DRILIB = GL/dri/ModuleLibraryTargetName(dri)
+# else
+ DRILIB =
+# endif
+# if GlxUseSGISI
+ GLXLIB = GL/glx/ModuleLibraryTargetName(glx) \
+ GL/sgi-si/ModuleLibraryTargetName(GLcore) \
+ $(DRILIB)
+# else
+# if defined(GlxUseWindows) && GlxUseWindows
+ XWin_GL.exe.GLXLIB = GL/glx/ModuleLibraryTargetName(glx_stdcall) \
+ GL/windows/ModuleLibraryTargetName(GLcore)
+# endif /* GlxUseWindows */
+# if defined(Win32Architecture) && defined(GlxUseWindows) && GlxUseWindows
+ GLXLIB = GL/glx/ModuleLibraryTargetName(glx_stdcall) \
+ GL/windows/ModuleLibraryTargetName(GLcore)
+# elif DoLoadableServer
+ GLXLIB = GL/glx/ModuleLibraryTargetName(glx) \
+ GL/mesa/GLcore/ModuleLibraryTargetName(GLcore)
+# else
+ GLXLIB = GL/glx/ModuleLibraryTargetName(glx) \
+ GL/mesa/GLcore/ModuleLibraryTargetName(GLcore) \
+ $(DRILIB)
+# endif
+# endif
+ GLXDIR = GL
+# if defined(cygwinArchitecture) && defined(GlxUseWindows) && GlxUseWindows
+ GLXEXT = $(if $($@.GLXLIB),$($@.GLXLIB), $(GLXLIB))
+# else
+ GLXEXT = $(GLXLIB)
+# endif
+#endif
+
+#if BuildXInputExt
+ XINPUTEXT = Xi/LibraryTargetName(xinput)
+ XIDIR = Xi
+#endif
+#if BuildXKB
+ XKBEXT = xkb/LibraryTargetName(xkb) dependLib($(OS))
+ XKBDIR = xkb
+#if (defined(XFree86Version) || defined(XorgVersion))
+ XF86XKBOBJS = xkb/xf86KillSrv.o xkb/xf86VT.o xkb/xf86Private.o
+#endif
+#endif
+#if BuildLBX
+ LBXEXT = lbx/LibraryTargetName(lbx) \
+ $(TOP)/lib/lbxutil/LibraryTargetName(lbxutil)
+ LBXDIRS = lbx
+#endif
+#if BuildDBE
+ DBEEXT = dbe/LibraryTargetName(dbe)
+#endif
+#if BuildDBE || BuildDBElib
+ DBEDIR = dbe
+#endif
+#if BuildRECORD
+ RECORDEXT = record/LibraryTargetName(record)
+#endif
+#if BuildRECORD || BuildRECORDlib
+ RECORDDIR = record
+#endif
+#if BuildXTrap
+ XTRAPEXT = XTrap/LibraryTargetName(xtrap)
+ XTRAPDIR = XTrap
+#endif
+#ifdef SiteExtensionLibs
+ SITEEXTS = SiteExtensionLibs
+#endif
+#ifdef SiteExtensionDirs
+ SITEEXTDIRS = SiteExtensionDirs
+#endif
+#if DoLoadableServer && HasDlopen
+ LIBDL = DlLibrary
+#endif
+ LIBREGEX = RegexLibrary
+
+#if DoLoadableServer
+ LIBCWRAPPER = os/libcwrapper.o
+#endif
+
+#if BuildXprint
+
+XPCONFIGDIR = XpConfig
+
+#ifndef XpRasterDDX
+#define XpRasterDDX YES
+#endif
+#ifndef XpColorPclDDX
+#define XpColorPclDDX YES
+#endif
+#ifndef XpMonoPclDDX
+#define XpMonoPclDDX NO
+#endif
+#ifndef XpPostScriptDDX
+#define XpPostScriptDDX YES
+#endif
+
+#if XpRasterDDX
+XPRASTLIB = Xprint/raster/LibraryTargetName(raster)
+#endif
+#if XpColorPclDDX
+XPPCLLIB = Xprint/pcl/LibraryTargetName(pcl)
+#endif
+#if XpMonoPclDDX
+XPMPCLLIB = Xprint/pcl-mono/LibraryTargetName(pcl)
+#endif
+#if XpPostScriptDDX
+XPPSLIB = Xprint/ps/LibraryTargetName(ps)
+#endif
+
+XPDDXLIBS = Xprint/LibraryTargetName(printer) \
+ $(XPRASTLIB) $(XPPCLLIB) $(XPMPCLLIB) $(XPPSLIB)
+XPDDXFBLIBS = $(MFB) $(CFB32)
+#if !PrintOnlyServer
+ XPFBLIBS = $(XPDDXFBLIBS)
+ XPDDX = $(XPDDXLIBS)
+#endif
+ XPDDXDIR = Xprint
+#endif
+#if !BuildXprint || PrintOnlyServer
+XPFBLIBS = dix/LibraryTargetName(xpstubs)
+#endif
+
+#if BuildRender
+ RENDERDIR = render
+ RENDERLIB = $(RENDERDIR)/librender.a
+#endif
+#if BuildRandR
+ RANDRDIR = randr
+ RANDRLIB = $(RANDRDIR)/librandr.a
+#endif
+#if BuildXfixes
+ FIXESDIR = xfixes
+ FIXESLIB = $(FIXESDIR)/libxfixes.a
+#endif
+#if BuildDamage
+ DAMAGEDIR = damageext
+ DAMAGELIB = $(DAMAGEDIR)/libdamage.a
+#endif
+#if BuildComposite
+ CWDIR = miext/cw
+ COMPOSITEDIR = composite
+ COMPOSITELIB = $(COMPOSITEDIR)/libcomposite.a
+#if DoLoadableServer
+ CW = miext/cw/ModuleLibraryTargetName(cw)
+#else
+ CW = miext/cw/LibraryTargetName(cw)
+#endif
+#endif
+#if DoLoadableServer
+ EXTENSIONS = $(COMPOSITELIB) $(DAMAGELIB) $(DAMAGE) $(FIXESLIB) $(CW) \
+ $(OTHEREXTS) $(RANDRLIB) $(RENDERLIB)
+ LOADABLEEXTS = $(MISCEXT) $(DBEEXT) $(RECORDEXT) $(GLXEXT) $(XTRAPEXT)
+ MISCEXT = Xext/LibraryTargetName(ext)
+ OTHEREXTS = Xext/LibraryTargetName(exts) $(XKBEXT) $(XINPUTEXT) \
+ $(LBXEXT) $(SITEEXTS)
+#else
+ EXTENSIONS = $(COMPOSITELIB) $(DAMAGELIB) $(DAMAGE) $(FIXESLIB) $(CW) \
+ $(OTHEREXTS) $(GLXEXT) $(RANDRLIB) $(RENDERLIB)
+ OTHEREXTS = Xext/LibraryTargetName(ext) $(XKBEXT) $(XINPUTEXT) \
+ $(LBXEXT) $(DBEEXT) $(RECORDEXT) $(SITEEXTS) $(XTRAPEXT)
+#endif
+ EXTDIRS = Xext $(XKBDIR) $(XIDIR) $(GLXDIR) \
+ $(LBXDIRS) $(DBEDIR) $(RECORDDIR) $(SITEEXTDIRS) \
+ $(RANDRDIR) $(RENDERDIR) $(XTRAPDIR) $(XPCONFIGDIR) \
+ $(FIXESDIR) $(DAMAGEDIR) $(CWDIR) $(COMPOSITEDIR)
+#if BuildLBX || GzipFontCompression
+ ZLIB = GzipLibrary
+#endif
+ OS = os/LibraryTargetName(os)
+ BSDEMUL = $(DEPXBSDLIB)
+#if DoLoadableServer
+ MFB = mfb/ModuleLibraryTargetName(mfb)
+ FB = fb/ModuleLibraryTargetName(fb)
+#if XF8_32Wid
+ CFB = cfb/ModuleLibraryTargetName(cfb) \
+ cfb16/ModuleLibraryTargetName(cfb16) \
+ cfb24/ModuleLibraryTargetName(cfb24) \
+ cfb32/ModuleLibraryTargetName(cfb32)
+#else
+ CFB = cfb/ModuleLibraryTargetName(cfb) \
+ cfb16/ModuleLibraryTargetName(cfb16) \
+ cfb32/ModuleLibraryTargetName(cfb32)
+#endif
+ CFB8 = cfb/ModuleLibraryTargetName(cfb)
+ CFB4 = cfb/ModuleLibraryTargetName(cfb) \
+ cfb4/ModuleLibraryTargetName(cfb4)
+ CFB16 = cfb/ModuleLibraryTargetName(cfb) \
+ cfb16/ModuleLibraryTargetName(cfb16)
+ CFB24 = cfb/ModuleLibraryTargetName(cfb) \
+ cfb24/ModuleLibraryTargetName(cfb24)
+ CFB32 = cfb/ModuleLibraryTargetName(cfb) \
+ cfb32/ModuleLibraryTargetName(cfb32)
+ DAMAGE = miext/damage/ModuleLibraryTargetName(damage)
+ SHADOW = miext/shadow/ModuleLibraryTargetName(shadow)
+ LAYER = miext/layer/ModuleLibraryTargetName(layer)
+#else
+ MFB = mfb/LibraryTargetName(mfb)
+ FB = fb/LibraryTargetName(fb)
+#if XF8_32Wid
+ CFB = cfb16/LibraryTargetName(cfb16) \
+ cfb24/LibraryTargetName(cfb24) \
+ cfb32/LibraryTargetName(cfb32) \
+ cfb/LibraryTargetName(cfb)
+#else
+ CFB = cfb16/LibraryTargetName(cfb16) \
+ cfb32/LibraryTargetName(cfb32) \
+ cfb/LibraryTargetName(cfb)
+#endif
+ CFB8 = cfb/LibraryTargetName(cfb)
+ CFB4 = cfb4/LibraryTargetName(cfb4) \
+ cfb/LibraryTargetName(cfb)
+ CFB16 = cfb16/LibraryTargetName(cfb16) \
+ cfb/LibraryTargetName(cfb)
+ CFB24 = cfb24/LibraryTargetName(cfb24) \
+ cfb/LibraryTargetName(cfb)
+ CFB32 = cfb32/LibraryTargetName(cfb32) \
+ cfb/LibraryTargetName(cfb)
+ DAMAGE = miext/damage/LibraryTargetName(damage)
+ SHADOW = miext/shadow/LibraryTargetName(shadow)
+ LAYER = miext/layer/LibraryTargetName(layer)
+#endif
+#if !HasFfs && (defined(mingwArchitecture) || defined(cygwinArchitecture))
+ /* Order of libraries is important when linking in mingw or
+ * cygwin. libmi.a requires ffs from libdix.a. So it is added
+ * after libmi.a on the commandline */
+ MI = mi/LibraryTargetName(mi) $(DIX)
+#else
+ MI = mi/LibraryTargetName(mi)
+#endif
+ MIINITEXTOBJ = mi/miinitext.o
+ DIX = dix/LibraryTargetName(dix)
+ FONTBASE = $(FONTLIBSRC)/fontbase.o \
+ $(FONTLIBSRC)/LibraryTargetName(fontbase)
+#if XserverStaticFontLib
+ FONT = $(FONTLIBSRC)/LibraryTargetName(Xfont) $(FREETYPE2LIB)
+#else
+ FONT = $(LDPRELIB) $(XFONTLIB) $(FREETYPE2LIB)
+#endif
+ FONTLIBS = $(FONT) $(XPFBLIBS)
+#if UsbMouseSupport
+#if !HasLibUsb
+ USB = $(XF86OSSRC)/bsd/libusb/LibraryTargetName(usb)
+#else
+ USB = UsbHidLib
+#endif
+#endif
+#ifdef ServerExtraSysLibs
+ EXTRASYSLIBS = ServerExtraSysLibs
+#endif
+#if HasPam && HasPamMisc
+ PAMLIBS = PamLibraries PamMiscLibraries
+#endif
+#if !(SystemV4 || defined(SGIArchitecture) || UseRgbTxt)
+ DBMLIBS = DBMLibrary
+#endif
+ SYSLIBS = $(ZLIB) MathLibrary Krb5Libraries $(DBMLIBS) $(USB) \
+ $(PAMLIBS) $(XAUTHLIB) $(XDMCPLIB) $(EXTRASYSLIBS)
+#if !HasCbrt
+ CBRT = mi/LibraryTargetName(cbrt)
+#endif
+ STDDIRS = include dix os mi $(XPDDXDIR) $(EXTDIRS)
+ FBDIR = fb
+ MFBDIR = mfb
+ CFB4DIR = cfb4
+ CFB8DIR = cfb
+ CFB16DIR = cfb16
+ CFB24DIR = cfb24
+ CFB32DIR = cfb32
+ AFBDIR = afb
+
+XCOMM
+XCOMM This turns off the default rule for compiling .c files because
+XCOMM this makefile does not really know how to build it. This is really
+XCOMM just a hack because of the Sun version of make and nfs.
+XCOMM
+.c.o:
+
+.s.o:
+
+/* Build rule blocks, add one for each server
+ *
+ * If a server needs mfb, its build block should have a line like:
+ * MFBSUBDIR = mfb
+ * Similarly, its build block should have:
+ * CFB4SUBDIR = cfb4 (if the server needs 4 bit cfb)
+ * CFB8SUBDIR = cfb (8 bit cfb)
+ * CFB16SUBDIR = cfb16 (16 bit cfb)
+ * CFB24SUBDIR = cfb24 (24 bit cfb)
+ * CFB32SUBDIR = cfb32 (32 bit cfb)
+ *
+ * If a server does not need all of the above components, simply
+ * omit the relevant lines from the build block.
+ *
+ * If these guidelines are followed, a make at the top of the server
+ * tree should result in each subdirectory being built only once,
+ * even if multiple servers that share subdirectories are being built.
+ */
+
+#if defined(XdecServer) && XdecServer
+XCOMM
+XCOMM Digital MIPS based WS server (ultrix 4.2 and beyond)
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+DECWSDDXDIR = hw/dec/ws
+DECDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(DECWSDDXDIR) $(DEPDIRS)
+DECOBJS = hw/dec/ws/init.o hw/dec/ws/sdepthinit.o
+DECLIBS = hw/dec/ws/LibraryTargetName(dec) CFB8Libs
+ServerTarget(Xdec,$(DECDIRS),$(DECOBJS), \
+ $(DECLIBS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xdec
+#endif
+#endif /* XdecServer */
+
+
+#if defined(XdecMultiDepthServer) && XdecMultiDepthServer
+XCOMM
+XCOMM Digital MIPS based WS server (ultrix 4.2 and beyond)
+XCOMM Supports 8, 12, and 24 bit pixmaps
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+CFB24SUBDIR = cfb24
+CFB32SUBDIR = cfb32
+DECWSDDXDIR = hw/dec/ws
+DECDIRS1 = $(STDDIRS) $(MFBDIR) \
+ $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) \
+ $(DECWSDDXDIR) $(DEPDIRS)
+DECOBJS1 = hw/dec/ws/init.o hw/dec/ws/mdepthinit.o
+DECLIBS1 = hw/dec/ws/LibraryTargetName(dec) CFBLibs
+ServerTarget(Xdec_md,$(DECDIRS1),$(DECOBJS1), \
+ $(DECLIBS1),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xdec_md
+#endif
+#endif /* XdecMultiDepthServer */
+
+
+#if defined(XsunServer) && XsunServer
+XCOMM
+XCOMM Sun server
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+SUNDDXDIR = hw/sun
+#if DoLoadableServer
+SUNOBJS = hw/sun/sunInit.o hw/sun/sunInitExt.o hw/sun/stubs.o
+#elif (defined(XF86Server) && XF86Server) \
+ || (defined(XorgServer) && XorgServer)
+SUNOBJS = hw/sun/sunInit.o hw/sun/stubs.o
+#else
+SUNOBJS = hw/sun/sunInit.o
+#endif
+SUNDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(SUNDDXDIR) $(DEPDIRS)
+SUNLIBS = hw/sun/LibraryTargetName(sun) CFB8Libs
+SUNSYSLIBS = $(FONTLIBS) $(WIDECHARSYSLIB) $(SYSLIBS)
+SetUIDServerTarget(Xsun,$(SUNDIRS),$(SUNOBJS), \
+ $(LIBCWRAPPER) $(SUNLIBS) $(LOADABLEEXTS),$(SUNSYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xsun
+#endif
+#endif /* XsunServer */
+
+
+#if defined(Xsun24Server) && Xsun24Server
+XCOMM
+XCOMM Sun multiple pixmap depth (8, 12, 24) server
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+CFB24SUBDIR = cfb24
+CFB32SUBDIR = cfb32
+SUNDDXDIR = hw/sun
+SUN24DIRS = $(STDDIRS) $(MFBDIR) \
+ $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) \
+ $(SUNDDXDIR) $(DEPDIRS)
+#if DoLoadableServer
+SUN24OBJS = hw/sun/sunInitMulti.o hw/sun/sunInitExt.o hw/sun/stubs.o
+#elif defined(XF86Server) && XF86Server \
+ || (defined(XorgServer) && XorgServer)
+SUN24OBJS = hw/sun/sunInitMulti.o hw/sun/stubs.o
+#else
+SUN24OBJS = hw/sun/sunInitMulti.o
+#endif
+SUN24LIBS = hw/sun/LibraryTargetName(sun) CFBLibs
+SetUIDServerTarget(Xsun24,$(SUN24DIRS),$(SUN24OBJS), \
+ $(LIBCWRAPPER) $(SUN24LIBS) $(LOADABLEEXTS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xsun24
+#endif
+#endif /* Xsun24Server */
+
+
+#if defined(XsunMonoServer) && XsunMonoServer
+XCOMM
+XCOMM Sun monochrome server
+XCOMM
+MFBSUBDIR = mfb
+SUNDDXDIR = hw/sun
+SUNMDIRS = $(STDDIRS) $(MFBDIR) $(SUNDDXDIR) $(DEPDIRS)
+#if defined(XF86Server) && XF86Server \
+ || (defined(XorgServer) && XorgServer)
+SUNMOBJS = hw/sun/sunInitMono.o hw/sun/sunInExMono.o hw/sun/stubs.o
+#else
+SUNMOBJS = hw/sun/sunInitMono.o hw/sun/sunInExMono.o
+#endif
+SUNMLIBS = hw/sun/LibraryTargetName(sun) MFBBareLibs $(EXTENSIONS)
+SetUIDServerTarget(XsunMono,$(SUNMDIRS),$(SUNMOBJS), \
+ $(LIBCWRAPPER) $(SUNMLIBS) $(LOADABLEEXTS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall XsunMono
+#endif
+#endif /* XsunMonoServer */
+
+
+#if defined(XsunLynxServer) && XsunLynxServer
+XCOMM
+XCOMM Sun server for LynxOS microSPARC 2.4.0
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+LYNXDDXDIR = hw/sunLynx
+SUNDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(LYNXDDXDIR) $(DEPDIRS)
+SUNOBJS = hw/sunLynx/sunLyInit.o
+SUNLIBS = hw/sunLynx/libsun.a CFB8Libs
+ServerTarget(Xsun,$(SUNDIRS),$(SUNOBJS), \
+ $(SUNLIBS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xsun
+#endif
+#endif /* XsunLynxServer */
+
+
+#if defined(XsunLynxMonoServer) && XsunLynxMonoServer
+XCOMM
+XCOMM Sun monochrome server for LynxOS microSPARC 2.4.0
+XCOMM
+MFBSUBDIR = mfb
+LYNXDDXDIR = hw/sunLynx
+SUNMDIRS = $(STDDIRS) $(MFBDIR) $(LYNXDDXDIR) $(DEPDIRS)
+SUNMOBJS = hw/sunLynx/sunInitMono.o hw/sunLynx/sunInExMono.o
+SUNMLIBS = hw/sunLynx/libsun.a MFBBareLibs $(OTHEREXTS)
+ServerTarget(XsunMono,$(SUNMDIRS),$(SUNMOBJS), \
+ $(SUNMLIBS),$(FONTLIBS) $(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall XsunMono
+#endif
+#endif /* XsunLynxMonoServer */
+
+
+#if HasParallelMake
+XCOMM
+XCOMM force non-parallel build of XF86 servers to prevent MUTEX overrides
+XCOMM
+#if defined(XF86Server) && XF86Server
+XF86SERVER = XFree86
+#endif
+#if defined(XorgServer) && XorgServer
+XF86SERVER = Xorg
+#endif
+#if defined(XnestServer) && XnestServer
+XNEST = Xnext
+#endif
+#if defined(XVirtualFramebufferServer) && XVirtualFramebufferServer
+XVFB = Xvfb
+#endif
+#if XdmxServer
+XDMX = Xdmx
+#endif
+#if defined(XWinServer) && XWinServer && !MakeDllModules
+XWIN = XWin
+#endif
+#if (defined(XF86Server) && XF86Server) || \
+ (defined(XorgServer) && XorgServer) || \
+ (defined(XnestServer) && XnestServer) || \
+ (defined(XVirtualFramebufferServer) && XVirtualFramebufferServer) || \
+ (defined(XdmxServer) && XdmxServer) || \
+ (!MakeDllModules && defined(XWinServer) && XWinServer)
+MakeMutex($(XF86SERVER) $(XNEST) $(XVFB) $(XWIN))
+#endif
+MakeMutex($(STDDIRS) mfb fb cfb cfb16 cfb24 cfb32)
+#endif
+
+
+#if defined(XF86Server) && XF86Server
+XCOMM
+XCOMM XFree86 Server
+XCOMM
+FBSUBDIR = fb
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+CFB24SUBDIR = cfb24
+CFB32SUBDIR = cfb32
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+LAYERDIR = miext/layer
+#ifdef OS2Architecture
+SERVERDEFFILE = XFree86.def
+XNESTDEFFILE = Xnest.def
+XVFBDEFFILE = Xvfb.def
+#endif
+#if XF86AFB
+AFBSUBDIR = afb
+#endif
+XFREE86DDXDIR = hw/xfree86
+XF86SERVERSUBDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(AFBDIR) \
+ $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) \
+ $(SHADOWDIR) $(LAYERDIR) $(XFREE86DDXDIR) $(DEPDIRS) \
+ $(MIDAMAGEDIR)
+XF86INIT = $(XF86COMSRC)/xf86Init.o $(XF86COMSRC)/xf86IniExt.o
+XF86COMLIB = $(XF86COMSRC)/LibraryTargetName(xf86)
+XF86PARSLIB= $(XF86PARSERSRC)/LibraryTargetName(xf86config)
+XF86OSLIB = $(XF86OSSRC)/LibraryTargetName(xf86_os)
+#if XF86XAA
+XF86XAALIB = $(XF86SRC)/xaa/LibraryTargetName(xaa)
+#endif
+#if XF86EXA
+XF86EXALIB = $(XF86SRC)/exa/LibraryTargetName(exa)
+#endif
+#if XF86VgaHw
+XF86VGAHWLIB = $(XF86SRC)/vgahw/LibraryTargetName(vgahw)
+#endif
+#if XF86FBDevHw
+XF86FBDEVHWLIB = $(XF86SRC)/fbdevhw/LibraryTargetName(fbdevhw)
+#endif
+#if XF1Bpp || XF4Bpp
+XF1BPPLIB = $(XF86SRC)/xf1bpp/LibraryTargetName(xf1bpp)
+#endif
+#if XF4Bpp
+XF4BPPLIB = $(XF86SRC)/xf4bpp/LibraryTargetName(xf4bpp)
+#endif
+#if XF8_32Wid
+XF8_32WIDLIB = $(XF86SRC)/xf8_32wid/LibraryTargetName(xf8_32wid)
+#endif
+#if XF8_32Bpp
+XF8_32BPPLIB = $(XF86SRC)/xf8_32bpp/LibraryTargetName(xf8_32bpp)
+#endif
+#if XF8_16Bpp
+XF8_16BPPLIB = $(XF86SRC)/xf8_16bpp/LibraryTargetName(xf8_16bpp)
+#endif
+#if XFShadowFB
+XFSHADOWFBLIB = $(XF86SRC)/shadowfb/LibraryTargetName(shadowfb)
+#endif
+#if XF86AFB
+AFBLIB = afb/LibraryTargetName(afb)
+#endif
+XF86DRIVERLIB = $(XF86SRC)/drivers/LibraryTargetName(driver)
+#if XF86Ramdac
+XF86RAMDACLIB = $(XF86SRC)/ramdac/LibraryTargetName(ramdac)
+#endif
+#if XF86I2C
+XF86I2CLIB = $(XF86SRC)/i2c/LibraryTargetName(i2c)
+#endif
+#if XF86DDC
+XF86DDCLIB = $(XF86SRC)/ddc/LibraryTargetName(ddc)
+#endif
+#if XF86VBE
+XF86VBELIB = $(XF86SRC)/vbe/LibraryTargetName(vbe)
+#endif
+#if XF86RAC
+XF86RACLIB = $(XF86SRC)/rac/LibraryTargetName(rac)
+#endif
+#if XF86INT10_BUILD > X86EMU_GENERIC
+XF86INT10LIB = $(XF86OSSRC)/LibraryTargetName(int10)
+#else
+XF86INT10LIB = $(XF86SRC)/int10/LibraryTargetName(int10)
+#endif
+#if UseMemLeak
+MEMDEBUGLIB = $(TOP)/util/memleak/LibraryTargetName(memleak)
+#endif
+XF86IDRIVERLIB = $(XF86SRC)/input/LibraryTargetName(idriver)
+#if !DoLoadableServer
+XF86DRVOBJS = $(XF86SRC)/drivers/drvConf.o
+XF86DRVLIBS = $(XF86DRIVERLIB) $(XF86RAMDACLIB) $(XF86DDCLIB) $(XF86I2CLIB) \
+ $(XF86XAALIB) $(XF86EXALIB) $(XF86VGAHWLIB) $(XF86FBDEVHWLIB) \
+ $(XF8_32WIDLIB) $(XF8_32BPPLIB) \
+ $(XF8_16BPPLIB) \
+ $(XF4BPPLIB) $(XF1BPPLIB) $(XFSHADOWFBLIB) $(AFBLIB)
+XF86IDRVOBJS = $(XF86SRC)/input/drvConf.o
+XF86IDRVLIBS = $(XF86IDRIVERLIB)
+XF86SCANLIB = $(XF86SRC)/scanpci/LibraryTargetName(scanpci)
+XF86LIBS = $(MEMDEBUGLIB) $(XF86INIT) $(XF86COMLIB) $(XF86RACLIB) \
+ $(XF86PARSLIB) $(XF86VBELIB) $(XF86OSLIB) $(XF86INT10LIB)
+#else
+XF86LIBS = $(MEMDEBUGLIB) $(XF86INIT) $(XF86COMLIB) \
+ $(XF86PARSLIB) $(XF86OSLIB)
+#endif
+#if DoLoadableServer
+XF86LOADERLIB = $(XF86SRC)/loader/LibraryTargetName(loader)
+XF86MAINLIBS = PreFbLibsNoFont \
+ $(FONTBASE) $(OTHEREXTS) $(XF86COMLIB) \
+ NoMfbPostFbLibs
+XF86SERVERSYSLIBS = $(SYSLIBS) $(LIBDL) $(LIBREGEX)
+XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
+ $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB)
+#else
+XF86MAINLIBS = MiExtLibs AllFBLibs $(XF86COMLIB) $(MI)
+XF86SERVERSYSLIBS = $(FONTLIBS) $(SYSLIBS) $(LIBDL) $(LIBREGEX)
+XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
+ $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB) \
+ $(XF86DDCLIB)
+#endif
+XF86SERVEROBJS = $(XF86XKBOBJS) $(XF86DRVOBJS) $(XF86IDRVOBJS)
+#if HasParallelMake
+MakeMutex($(XF86SERVERSUBDIRS) $(XF86SERVERLIBS) $(XF86SERVERSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XF86SERVERLIBS) $(XF86SERVERSYSLIBS):: $(XF86SERVERSUBDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+SetUIDServerTarget(XFree86,$(XF86SERVERSUBDIRS),$(XF86SERVEROBJS) $(SERVERDEFFILE), \
+ $(XF86SERVERLIBS),$(XF86SERVERSYSLIBS))
+#if DoLoadableServer
+ServerDriverSDKTarget(XFree86)
+#endif
+#ifndef ServerToInstall
+#define ServerToInstall XFree86
+#endif
+#endif /* XF86Server */
+
+#if defined(XorgServer) && XorgServer
+XCOMM
+XCOMM Xorg Server
+XCOMM
+FBSUBDIR = fb
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+#if XF8_32Wid
+CFB24SUBDIR = cfb24
+#endif
+CFB32SUBDIR = cfb32
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+LAYERDIR = miext/layer
+#ifdef OS2Architecture
+SERVERDEFFILE = Xorg.def
+XNESTDEFFILE = Xnest.def
+XVFBDEFFILE = Xvfb.def
+#endif
+#if XF86AFB
+AFBSUBDIR = afb
+#endif
+XFREE86DDXDIR = hw/xfree86
+XF86SERVERSUBDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(AFBDIR) \
+ $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) \
+ $(SHADOWDIR) $(LAYERDIR) $(XFREE86DDXDIR) $(DEPDIRS) \
+ $(MIDAMAGEDIR)
+XF86INIT = $(XF86COMSRC)/xf86Init.o $(XF86COMSRC)/xf86IniExt.o
+XF86COMLIB = $(XF86COMSRC)/LibraryTargetName(xf86)
+XF86PARSLIB= $(XF86PARSERSRC)/LibraryTargetName(xf86config)
+XF86OSLIB = $(XF86OSSRC)/LibraryTargetName(xf86_os)
+#if XF86XAA
+XF86XAALIB = $(XF86SRC)/xaa/LibraryTargetName(xaa)
+#endif
+#if XF86EXA
+XF86EXALIB = $(XF86SRC)/exa/LibraryTargetName(exa)
+#endif
+#if XF86VgaHw
+XF86VGAHWLIB = $(XF86SRC)/vgahw/LibraryTargetName(vgahw)
+#endif
+#if XF86FBDevHw
+XF86FBDEVHWLIB = $(XF86SRC)/fbdevhw/LibraryTargetName(fbdevhw)
+#endif
+#if XF1Bpp || XF4Bpp
+XF1BPPLIB = $(XF86SRC)/xf1bpp/LibraryTargetName(xf1bpp)
+#endif
+#if XF4Bpp
+XF4BPPLIB = $(XF86SRC)/xf4bpp/LibraryTargetName(xf4bpp)
+#endif
+#if XF8_32Wid
+XF8_32WIDLIB = $(XF86SRC)/xf8_32wid/LibraryTargetName(xf8_32wid)
+#endif
+#if XF8_32Bpp
+XF8_32BPPLIB = $(XF86SRC)/xf8_32bpp/LibraryTargetName(xf8_32bpp)
+#endif
+#if XF8_16Bpp
+XF8_16BPPLIB = $(XF86SRC)/xf8_16bpp/LibraryTargetName(xf8_16bpp)
+#endif
+#if XFShadowFB
+XFSHADOWFBLIB = $(XF86SRC)/shadowfb/LibraryTargetName(shadowfb)
+#endif
+#if XF86AFB
+AFBLIB = afb/LibraryTargetName(afb)
+#endif
+XF86DRIVERLIB = $(XF86SRC)/drivers/LibraryTargetName(driver)
+#if XF86Ramdac
+XF86RAMDACLIB = $(XF86SRC)/ramdac/LibraryTargetName(ramdac)
+#endif
+#if XF86I2C
+XF86I2CLIB = $(XF86SRC)/i2c/LibraryTargetName(i2c)
+#endif
+#if XF86DDC
+XF86DDCLIB = $(XF86SRC)/ddc/LibraryTargetName(ddc)
+#endif
+#if XF86VBE
+XF86VBELIB = $(XF86SRC)/vbe/LibraryTargetName(vbe)
+#endif
+#if XF86RAC
+XF86RACLIB = $(XF86SRC)/rac/LibraryTargetName(rac)
+#endif
+#if XF86INT10_BUILD > X86EMU_GENERIC
+XF86INT10LIB = $(XF86OSSRC)/LibraryTargetName(int10)
+#else
+XF86INT10LIB = $(XF86SRC)/int10/LibraryTargetName(int10)
+#endif
+#if UseMemLeak
+MEMDEBUGLIB = $(TOP)/util/memleak/LibraryTargetName(memleak)
+#endif
+XF86IDRIVERLIB = $(XF86SRC)/input/LibraryTargetName(idriver)
+#if !DoLoadableServer
+XF86DRVOBJS = $(XF86SRC)/drivers/drvConf.o
+XF86DRVLIBS = $(XF86DRIVERLIB) $(XF86RAMDACLIB) $(XF86DDCLIB) $(XF86I2CLIB) \
+ $(XF86XAALIB) $(XF86EXALIB) $(XF86VGAHWLIB) $(XF86FBDEVHWLIB) \
+ $(XF8_32WIDLIB) $(XF8_32BPPLIB) \
+ $(XF8_16BPPLIB) \
+ $(XF4BPPLIB) $(XF1BPPLIB) $(XFSHADOWFBLIB) $(AFBLIB)
+XF86IDRVOBJS = $(XF86SRC)/input/drvConf.o
+XF86IDRVLIBS = $(XF86IDRIVERLIB)
+XF86SCANLIB = $(XF86SRC)/scanpci/LibraryTargetName(scanpci)
+XF86LIBS = $(MEMDEBUGLIB) $(XF86INIT) $(XF86COMLIB) $(XF86RACLIB) \
+ $(XF86PARSLIB) $(XF86VBELIB) $(XF86OSLIB) $(XF86INT10LIB)
+#else
+XF86LIBS = $(MEMDEBUGLIB) $(XF86INIT) $(XF86COMLIB) \
+ $(XF86PARSLIB) $(XF86OSLIB)
+#endif
+#if DoLoadableServer
+XF86LOADERLIB = $(XF86SRC)/loader/LibraryTargetName(loader)
+XF86MAINLIBS = PreFbLibsNoFont \
+ $(FONTBASE) $(OTHEREXTS) $(XF86COMLIB) \
+ NoMfbPostFbLibs
+XF86SERVERSYSLIBS = $(SYSLIBS) $(LIBDL) $(LIBREGEX)
+XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
+ $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB)
+#else
+XF86MAINLIBS = MiExtLibs AllFBLibs $(XF86COMLIB) $(MI)
+XF86SERVERSYSLIBS = $(FONTLIBS) $(SYSLIBS) $(LIBDL) $(LIBREGEX)
+XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
+ $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB) \
+ $(XF86DDCLIB)
+#endif
+XF86SERVEROBJS = $(XF86XKBOBJS) $(XF86DRVOBJS) $(XF86IDRVOBJS)
+#if HasParallelMake
+MakeMutex($(XF86SERVERSUBDIRS) $(XF86SERVERLIBS) $(XF86SERVERSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XF86SERVERLIBS) $(XF86SERVERSYSLIBS):: $(XF86SERVERSUBDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+SetUIDServerTarget(Xorg,$(XF86SERVERSUBDIRS),$(XF86SERVEROBJS) $(SERVERDEFFILE), \
+ $(XF86SERVERLIBS),$(XF86SERVERSYSLIBS))
+#if DoLoadableServer
+ServerDriverSDKTarget(Xorg)
+#endif
+#ifndef ServerToInstall
+#define ServerToInstall Xorg
+#endif
+#endif /* XorgServer */
+
+#if defined(XprtServer) && XprtServer
+XCOMM
+XCOMM Print Server
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB32SUBDIR = cfb32
+MIDAMAGEDIR = miext/damage
+XPSUBDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB32DIR) $(DEPDIRS) \
+ $(MIDAMAGEDIR)
+XPOBJS = Xprint/ddxInit.o Xprint/dpmsstubs.o Xprint/miinitext.o
+#if PrintOnlyServer
+XPLIBS = PreFbLibs $(XPDDXLIBS) $(XPDDXFBLIBS) PostFbLibs
+#else
+XPLIBS = PreFbLibs PostFbLibs
+#endif
+#if (defined(SunArchitecture) || defined(SparcArchitecture)) && \
+ defined(SVR4Architecture)
+XPSYSLIBS = $(FONTLIBS) $(CBRT) $(SYSLIBS) $(XONLYLIB) -lw
+#else
+XPSYSLIBS = $(FONTLIBS) $(CBRT) $(SYSLIBS) $(XONLYLIB)
+#endif
+#if HasParallelMake
+MakeMutex($(XPSUBDIRS) $(XPOBJS) $(XPLIBS) $(XPSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XPOBJS) $(XPLIBS) $(XPSYSLIBS):: $(XPSUBDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+ServerTarget(Xprt,$(XPSUBDIRS),$(XPOBJS), \
+ $(LIBCWRAPPER) $(XPLIBS) $(LOADABLEEXTS),$(XPSYSLIBS))
+#endif /* XprtServer */
+
+#if defined(XnestServer) && XnestServer
+XCOMM
+XCOMM Server with Xlib-based ddx
+XCOMM
+#ifndef Win32Architecture
+XNESTDDXDIR = hw/xnest
+#else
+XNESTDDXDIR = hw
+#endif
+#if BuildDPMS
+XNESTDPMSSTUBOBJS = $(XNESTDDXDIR)/dpmsstubs.o
+#endif
+XNESTDIRS = $(STDDIRS) $(XNESTDDXDIR) $(DEPDIRS)
+#if !defined(LynxOSArchitecture) && \
+ !defined(Win32Architecture) && \
+ !defined(QNX4Architecture)
+XNESTOBJS = hw/xnest/miinitext.o $(XNESTDPMSSTUBOBJS)
+#else
+XNESTOBJS = hw/xnest/miinitext.o dix/main.o $(XNESTDPMSSTUBOBJS)
+#endif
+XNEST = hw/xnest/LibraryTargetName(xnest)
+XNESTLIBS = PreFbLibs $(XNEST) NoMfbPostFbLibs $(XNEST)
+XNESTSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XLIB) $(SYSLIBS)
+#if HasParallelMake
+MakeMutex($(XNESTDIRS) $(XNESTOBJS) $(XNESTLIBS) $(XNESTSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XNESTOBJS) $(XNESTLIBS) $(XNESTSYSLIBS):: $(XNESTDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+ServerTarget(Xnest,$(XNESTDIRS),$(XNESTOBJS) $(XNESTDEFFILE), \
+ $(LIBCWRAPPER) $(XNESTLIBS) $(LOADABLEEXTS),$(XNESTSYSLIBS))
+#endif /* XnestServer */
+
+
+#if defined(XnonServer) && XnonServer
+XCOMM
+XCOMM non server, just compile sources for build test
+XCOMM
+MFBSUBDIR = mfb
+CFB8SUBDIR = cfb
+CFB16SUBDIR = cfb16
+CFB32SUBDIR = cfb32
+#if HasParallelMake
+MakeMutex($(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB32DIR) $(DEPDIRS))
+#endif
+Xnon: $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB32DIR) $(DEPDIRS)
+#endif /* XnonServer */
+
+
+#if defined(XVirtualFramebufferServer) && XVirtualFramebufferServer
+XCOMM
+XCOMM server with Virtual (malloced) framebuffer
+XCOMM
+MFBSUBDIR = mfb
+FBSUBDIR = fb
+#if defined(Win32Architecture)
+XVFBDDXDIR = hw
+#else
+XVFBDDXDIR = hw/vfb
+#endif
+XVFBDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(XVFBDDXDIR) $(DEPDIRS)
+#ifndef Win32Architecture
+#if BuildDPMS
+XVFBDPMSSTUBOBJS = $(XVFBDDXDIR)/dpmsstubs.o
+#endif
+XVFBOBJS = $(XVFBDDXDIR)/stubs.o $(XVFBDDXDIR)/miinitext.o $(XVFBDPMSSTUBOBJS)
+#else
+XVFBOBJS = dix/main.o hw/vfb/stubs.o hw/vfb/miinitext.o
+#endif
+XVFB = $(XVFBDDXDIR)/LibraryTargetName(vfb)
+XVFBLIBS = PreFbLibs $(XVFB) $(FB) PostFbLibs $(MI)
+XVFBSYSLIBS = $(FONTLIBS) $(SYSLIBS)
+#if HasParallelMake
+MakeMutex($(XVFBDIRS) $(XVFBOBJS) $(XVFB) $(XVFBLIBS) $(XVFBSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XVFBOBJS) $(XVFB) $(XVFBLIBS) $(XVFBSYSLIBS):: $(XVFBDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+ServerTarget(Xvfb,$(XVFBDIRS),$(XVFBOBJS) $(XVFBDEFFILE), \
+ $(LIBCWRAPPER) $(XVFBLIBS) $(LOADABLEEXTS),$(XVFBSYSLIBS))
+#endif /* XVirtualFramebufferServer */
+
+#if defined(XdmxServer) && XdmxServer
+XCOMM
+XCOMM distribued multihead Server
+XCOMM
+#ifndef Win32Architecture
+XDMXDDXDIR = hw/dmx
+#else
+XDMXDDXDIR = hw
+#endif
+FBDIR = fb
+FBSUBDIR = fb
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+XDMXDIRS = $(STDDIRS) $(XDMXDDXDIR) $(SHADOWDIR) $(DEPDIRS) $(FBDIR) $(MIDAMAGEDIR)
+#if BuildGlxExt
+#if BuildXinerama
+GLXPROXY_EXTRAOBJS = hw/dmx/panoramiX.o
+#endif
+GLXPROXYLIB = hw/dmx/glxProxy/LibraryTargetName(glxProxy)
+#endif
+#if !defined(LynxOSArchitecture) && \
+ !defined(Win32Architecture) && \
+ !defined(QNX4Architecture)
+XDMXOBJS = hw/dmx/miinitext.o $(GLXPROXY_EXTRAOBJS)
+#else
+XDMXOBJS = hw/dmx/miinitext.o $(GLXPROXY_EXTRAOBJS) dix/main.o
+#endif
+XDMX = hw/dmx/LibraryTargetName(dmx) \
+ hw/dmx/input/LibraryTargetName(dmxinput) \
+ hw/dmx/config/LibraryTargetName(dmxconfig) \
+ $(GLXPROXYLIB)
+XDMXLIBS = PreFbLibs $(XDMX) MiExtLibs FbPostFbLibs $(XDMX)
+#if BuildRender
+XDMXRENDERLIB = $(XRENDERLIB)
+#endif
+XDMXSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XILIB) $(XLIB) $(SYSLIBS) $(XMULIB) $(XDMXRENDERLIB)
+#if HasParallelMake
+MakeMutex($(XDMXDIRS) $(XDMXOBJS) $(XDMXLIBS) $(XDMXSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XDMXOBJS) $(XDMXLIBS) $(XDMXSYSLIBS):: $(XDMXDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+ServerTarget(Xdmx,$(XDMXDIRS),$(XDMXOBJS), \
+ $(LIBCWRAPPER) $(XDMXLIBS) $(LOADABLEEXTS),$(XDMXSYSLIBS))
+#endif /* XdmxServer */
+
+#if defined(XWinServer) && XWinServer
+XCOMM
+XCOMM X Server for MS Windows
+XCOMM
+FBSUBDIR = fb
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+#if BuildXWinLayer
+LAYERDIR = miext/layer
+XWINLAYERLIB = $(LAYER)
+#else
+LAYERDIR =
+XWINLAYERLIB =
+#endif
+#if BuildXWinMultiWindowExtWM
+ROOTLESSDIR = miext/rootless
+ROOTLESSLIB = $(ROOTLESSDIR)/LibraryTargetName(rootless) \
+ $(ROOTLESSDIR)/safeAlpha/LibraryTargetName(safeAlpha) \
+ $(ROOTLESSDIR)/accel/LibraryTargetName(rlAccel)
+#else
+ROOTLESSDIR =
+ROOTLESSLIB =
+#endif
+XWINDDXDIR = hw/xwin
+#if BuildXWinXF86Config
+XWINPARSERDIR = hw/xfree86/parser
+XWINPARSERLIB = $(XWINPARSERDIR)/LibraryTargetName(xf86config)
+#else
+XWINPARSERDIR =
+XWINPARSERLIB =
+#endif
+#if defined(GlxUseWindows) && GlxUseWindows
+XWINOPENGLLIB = -lopengl32
+#else
+XWINOPENGLLIB =
+#endif
+
+XWINLIB = $(XWINDDXDIR)/LibraryTargetName(XWin)
+XWINDIRS = $(STDDIRS) $(FBDIR) $(SHADOWDIR) $(LAYERDIR) $(XWINDDXDIR) \
+ $(DEPDIRS) $(XWINPARSERDIR) $(ROOTLESSDIR) $(MIDAMAGEDIR)
+XWINOBJS = $(XWINDDXDIR)/stubs.o $(XWINDDXDIR)/XWin.res
+XWINLIBS = PreFbLibs $(XWINLIB) FbPostFbLibs $(XWINLIB) $(XWINLAYERLIB) \
+ $(SHADOW) $(XWINPARSERLIB) $(ROOTLESSLIB) $(OS)
+#if BuildXWinMultiWindow || BuildXWinClipboard
+XWINX11 = $(XONLYLIB)
+# if defined(Win32Architecture)
+PTHREADLIB = -lpthreadGC2
+# endif
+#endif
+#if defined(Win32Architecture)
+# if defined(GlxUseWindows) && GlxUseWindows
+XWINGL32 = -lopengl32
+# endif
+XWINW32 = -lgdi32 -lwsock32 $(XWINGL32) $(PTHREADLIB)
+#else
+XWINW32 = -lgdi32
+#endif
+XWINSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XWINX11) $(SYSLIBS) $(XWINW32)
+
+EXTRA_LDOPTIONS = -e _mainCRTStartup
+
+#if HasParallelMake
+MakeMutex($(XWINDIRS) $(XWINOBJS) $(XWINLIB) $(XWINLIBS) $(XWINSYSLIBS))
+#endif
+
+#if ForceServerRemake
+$(XWINOBJS) $(XWINLIB) $(XWINLIBS) $(XWINSYSLIBS):: $(XWINDIRS)
+ @if [ -f $@ ]; then touch $@ >/dev/null 2>&1 || exit 0; fi
+#endif
+
+#ifdef mingwArchitecture
+XWINSERVERNAME=Xming
+XWINGLSERVERNAME=XmingGL
+#else
+XWINSERVERNAME=XWin
+XWINGLSERVERNAME=XWin_GL
+#endif
+ServerTarget($(XWINSERVERNAME),$(XWINDIRS),$(XWINOBJS), \
+ $(LIBCWRAPPER) $(XWINLIBS) $(LOADABLEEXTS),$(XWINSYSLIBS))
+#if defined(cygwinArchitecture) && defined(GlxUseWindows) && GlxUseWindows
+ServerTarget($(XWINGLSERVERNAME),$(XWINDIRS),$(XWINOBJS), \
+ $(LIBCWRAPPER) $(XWINLIBS) $(LOADABLEEXTS),$(XWINSYSLIBS) \
+ $(XWINOPENGLLIB))
+#endif
+
+#ifndef ServerToInstall
+# define ServerToInstall $(XWINSERVERNAME)
+#endif
+
+#endif /* XWinServer */
+
+
+#ifdef DarwinArchitecture
+/*
+ * To allow building even when building the client-side libraries is turned
+ * off, libraries in ProjectRoot are listed as dependencies for some targets.
+ * This causes problems unless we tell make where to find these dependencies.
+ */
+VPATH = $(BUILDLIBDIR):$(USRLIBDIR)
+#endif
+
+#if defined(XDarwinServer) && XDarwinServer
+XCOMM
+XCOMM X Darwin server for Mac OS X / Darwin
+XCOMM
+FBSUBDIR = fb
+MIDAMAGEDIR = miext/damage
+SHADOWDIR = miext/shadow
+ROOTLESSDIR = miext/rootless
+DARWINDDXDIR = hw/darwin
+DARWINDIRS = $(STDDIRS) $(FBDIR) $(SHADOWDIR) $(DARWINDDXDIR) $(DEPDIRS)
+DARWINOBJS = $(DARWINDDXDIR)/miinitext.o
+DARWINLIBS = PreFbLibs $(DARWINDDXDIR)/LibraryTargetName(darwin)
+DARWINEXTLIBS = MiExtLibs FbPostFbLibs $(DARWINDDXDIR)/LibraryTargetName(darwin)
+DARWINSYSLIBS = $(FONTLIBS) $(SYSLIBS) -framework IOKit
+IOKITLIB = $(DARWINDDXDIR)/iokit/LibraryTargetName(iokit)
+
+/*
+ * IOKit X server
+ */
+SetUIDServerTarget(XDarwin,$(DARWINDIRS),$(DARWINOBJS), \
+ $(DARWINLIBS) $(IOKITLIB) $(DARWINEXTLIBS),$(DARWINSYSLIBS))
+
+#if DarwinQuartzSupport
+
+QUARTZDIR = $(DARWINDDXDIR)/quartz
+QUARTZLIB = $(QUARTZDIR)/LibraryTargetName(XQuartz)
+QUARTZSYSLIBS = -framework ApplicationServices -framework Cocoa \
+ -framework CoreAudio -framework Carbon -ObjC
+ROOTLESSLIB = $(ROOTLESSDIR)/LibraryTargetName(rootless) \
+ $(ROOTLESSDIR)/safeAlpha/LibraryTargetName(safeAlpha) \
+ $(ROOTLESSDIR)/accel/LibraryTargetName(rlAccel)
+XPLUGINLIB = XpluginLibrary
+
+#if NothingOutsideProjectRoot
+XDARWINAPPDIR = $(BINDIR)/XDarwin.app/Contents
+#else
+XDARWINAPPDIR = /Applications/XDarwin.app/Contents
+#endif
+
+/*
+ * Quartz X server (installed in its application bundle)
+ */
+SetUIDServerTarget(XDarwinApp,$(DARWINDIRS),$(DARWINOBJS), \
+ $(DARWINLIBS) $(QUARTZLIB) $(DARWINEXTLIBS), \
+ $(DARWINSYSLIBS) $(QUARTZSYSLIBS) -u _miDCInitialize)
+
+install::
+ $(MKDIRHIER) $(DESTDIR)$(XDARWINAPPDIR)/MacOS
+ $(MV) $(DESTDIR)$(BINDIR)/XDarwinApp \
+ $(DESTDIR)$(XDARWINAPPDIR)/MacOS/XDarwin
+ -(cd $(DESTDIR)$(BINDIR); $(RM) XDarwinQuartz; \
+ $(LN) $(XDARWINAPPDIR)/MacOS/XDarwin XDarwinQuartz)
+
+/*
+ * Display mode bundles for Quartz
+ * (installed in their own bundles inside XDarwin's)
+ */
+#if HasXplugin
+XPRDIRS = $(QUARTZDIR)/xpr $(ROOTLESSDIR) $(ROOTLESSDIR)/safeAlpha
+XPRLIBS = $(QUARTZDIR)/xpr/LibraryTargetName(xpr) $(ROOTLESSLIB)
+
+BundleProgramTarget(xpr,XDarwinApp,$(XPRDIRS),$(QUARTZDIR)/xpr/xprScreen.o, \
+ $(XPRLIBS),-framework ApplicationServices \
+ $(XPLUGINLIB),$(XDARWINAPPDIR)/Resources)
+#endif
+
+CRDIRS = $(QUARTZDIR)/cr $(ROOTLESSDIR) $(ROOTLESSDIR)/safeAlpha
+CRLIBS = $(QUARTZDIR)/cr/LibraryTargetName(cr) $(ROOTLESSLIB)
+
+BundleProgramTarget(cr,XDarwinApp,$(CRDIRS),$(QUARTZDIR)/cr/crScreen.o, \
+ $(CRLIBS),-framework ApplicationServices -framework Cocoa \
+ -framework Carbon -ObjC,$(XDARWINAPPDIR)/Resources)
+
+FSDIRS = $(QUARTZDIR)/fullscreen $(SHADOWDIR)
+FSLIBS = $(QUARTZDIR)/fullscreen/LibraryTargetName(fullscreen) $(SHADOW)
+
+BundleProgramTarget(fullscreen,XDarwinApp,$(FSDIRS), \
+ $(QUARTZDIR)/fullscreen/fullscreen.o,$(FSLIBS), \
+ -framework ApplicationServices,$(XDARWINAPPDIR)/Resources)
+
+/*
+ * GLX bundles for Quartz
+ * (installed in their own bundles inside XDarwin's)
+ */
+BundleProgramTarget(glxAGL,XDarwinApp,GL,GL/glx/glxext.o,GL/glx/libglx.a \
+ GL/apple/libAGLcore.a, \
+ -framework AGL -framework OpenGL,$(XDARWINAPPDIR)/Resources)
+
+#if BuildAppleDRI
+BundleProgramTarget(glxCGL,XDarwinApp,GL,GL/glx/glxext.o,GL/glx/libglx.a \
+ GL/apple/libCGLcore.a, \
+ -framework OpenGL $(XPLUGINLIB),$(XDARWINAPPDIR)/Resources)
+#endif
+
+BundleProgramTarget(glxMesa,XDarwinApp,GL,GL/glx/glxext.o,GL/glx/libglx.a \
+ GL/mesa/GLcore/libGLcore.a,NullParameter,$(XDARWINAPPDIR)/Resources)
+
+#else /* !DarwinQuartzSupport */
+
+#define ServerToInstall XDarwin
+
+#endif /* DarwinQuartzSupport */
+
+#endif /* XDarwinServer */
+
+
+CFBSUBDIRS = $(CFB8SUBDIR) $(CFB16SUBDIR) $(CFB24SUBDIR) $(CFB32SUBDIR)
+MIEXTDIRS = $(SHADOWDIR) $(LAYERDIR) $(ROOTLESSDIR) $(MIDAMAGEDIR)
+IPLANDIRS = $(IPLAN2P2DIR) $(IPLAN2P4DIR) $(IPLAN2P8DIR)
+DDXDIRS = $(DECWSDDXDIR) $(SUNDDXDIR) $(LYNXDDXDIR) \
+ $(HPDDXDIR) $(XFREE86DDXDIR) $(XWINDDXDIR) $(DARWINDDXDIR) \
+ $(XVFBDDXDIR) $(XNESTDDXDIR) $(XDMXDDXDIR)
+SUBDIRS = $(STDDIRS) $(MFBSUBDIR) $(CFBSUBDIRS) \
+ $(IPLANDIRS) $(ILBMDIR) $(AFBSUBDIR) \
+ $(DDXDIRS) $(FBSUBDIR) $(KDRIVEDIRS) $(MIEXTDIRS)
+
+#if defined(ServerToInstall) && !defined(OS2Architecture)
+install::
+ -(cd $(DESTDIR)$(BINDIR); $(RM) X; $(LN) ServerToInstall X)
+#endif
+
+#define IHaveSubdirs
+
+DependSubdirs($(SUBDIRS))
+MakeLintLibSubdirs($(SUBDIRS))
+LintSubdirs($(SUBDIRS))
+
+ForceSubdirs($(DEPDIRS) $(SUBDIRS))
+
+DEFAULTFONTPATH = DefaultFontPath
+EXTRAMANDEFS = -D__default_font_path__="`echo $(DEFAULTFONTPATH) | sed -e 's/,/, /g'`"
+
+InstallManPage(Xserver,$(MANDIR))
+
+#if MakeDllModules && DoLoadableServer && \
+ (defined(SunArchitecture) && defined(SVR4Architecture))
+XCOMM Hackery for building dlopen-able .so modules on Solaris
+
+AllTarget(linker-deps)
+
+LINKER_DEPS_DIRS = $(SUBDIRS) $(FONTLIBSRC)
+
+XCOMM After everything is built, run through and generate linker dependencies
+linker-deps:
+ RunPerlScript($(XF86SRC)/os-support/sunos/find_deps.pl,-R ProjectRoot $(LINKER_DEPS_DIRS))
+ for i in $(LINKER_DEPS_DIRS) ; do \
+ echo "relinking with dependency flags in $(CURRENT_DIR)/$$i..."; \
+ MakeNamedTargetSubdir($$i,NullParameter,all) ; \
+ done
+#endif
diff --git a/nx-X11/programs/Xserver/XFree86.def b/nx-X11/programs/Xserver/XFree86.def
new file mode 100644
index 000000000..a233c197e
--- /dev/null
+++ b/nx-X11/programs/Xserver/XFree86.def
@@ -0,0 +1,5 @@
+NAME XFree86 NOTWINDOWCOMPAT
+DESCRIPTION "@#XFREE86:4.4.0#@ $XFree86: xc/programs/Xserver/XFree86.def,v 1.4 2002/05/31 18:45:53 dawes Exp $"
+PROTMODE
+EXETYPE OS2
+
diff --git a/nx-X11/programs/Xserver/XTrap/Imakefile b/nx-X11/programs/Xserver/XTrap/Imakefile
new file mode 100644
index 000000000..2362634c7
--- /dev/null
+++ b/nx-X11/programs/Xserver/XTrap/Imakefile
@@ -0,0 +1,27 @@
+XCOMM $XFree86: xc/programs/Xserver/XTrap/Imakefile,v 1.1 2001/11/02 23:29:29 dawes Exp $
+
+#if DoLoadableServer
+#define IHaveSubdirs
+#endif
+
+#include <Server.tmpl>
+
+#if DoLoadableServer
+ SUBDIRS = module
+#endif
+ SRCS = xtrapddmi.c xtrapdi.c xtrapdiswp.c xtrapditbl.c
+ OBJS = xtrapddmi.o xtrapdi.o xtrapdiswp.o xtrapditbl.o
+ INCLUDES = -I../include -I$(EXTINCSRC) -I$(XINCLUDESRC) -I$(SERVERSRC)/Xext
+
+NormalLibraryTarget(xtrap,$(OBJS))
+LintLibraryTarget(xtrap,$(SRCS))
+NormalLintTarget($(SRCS))
+
+NormalLibraryObjectRule()
+
+#if DoLoadableServer
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/XTrap/module/Imakefile b/nx-X11/programs/Xserver/XTrap/module/Imakefile
new file mode 100644
index 000000000..8f8a77ba2
--- /dev/null
+++ b/nx-X11/programs/Xserver/XTrap/module/Imakefile
@@ -0,0 +1,26 @@
+XCOMM $XFree86: xc/programs/Xserver/XTrap/module/Imakefile,v 1.2 2002/01/23 03:31:40 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+ SRCS = xtrapddmi.c xtrapdi.c xtrapdiswp.c xtrapditbl.c xf86XTrapModule.c
+ OBJS = xtrapddmi.o xtrapdi.o xtrapdiswp.o xtrapditbl.o xf86XTrapModule.o
+ INCLUDES = -I.. -I../../include -I$(EXTINCSRC) -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/Xext
+ DEFINES = -DEXTMODULE
+
+LinkSourceFile(xf86XTrapModule.c,..)
+LinkSourceFile(xtrapddmi.c,..)
+LinkSourceFile(xtrapdi.c,..)
+LinkSourceFile(xtrapdiswp.c,..)
+LinkSourceFile(xtrapditbl.c,..)
+
+ModuleObjectRule()
+LibraryModuleTarget(xtrap,$(OBJS))
+
+InstallLibraryModule(xtrap,$(MODULEDIR),extensions)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(xtrap,$(DRIVERSDKMODULEDIR),extensions)
+
diff --git a/nx-X11/programs/Xserver/XTrap/xf86XTrapModule.c b/nx-X11/programs/Xserver/XTrap/xf86XTrapModule.c
new file mode 100644
index 000000000..1783d577a
--- /dev/null
+++ b/nx-X11/programs/Xserver/XTrap/xf86XTrapModule.c
@@ -0,0 +1,51 @@
+/* $XFree86$ */
+/* This is the xf86 module code for the DEC_XTRAP extension.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xf86Module.h"
+
+#include <X11/extensions/xtrapdi.h>
+
+extern void DEC_XTRAPInit(INITARGS);
+
+#ifdef XFree86LOADER
+
+static MODULESETUPPROTO(xtrapSetup);
+
+ExtensionModule xtrapExt =
+{
+ DEC_XTRAPInit,
+ XTrapExtName,
+ NULL,
+ NULL,
+ NULL
+};
+
+static XF86ModuleVersionInfo xtrapVersRec =
+{
+ "xtrap",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_EXTENSION, /* needs the server extension ABI */
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_EXTENSION,
+ {0,0,0,0}
+};
+
+XF86ModuleData xtrapModuleData = { &xtrapVersRec, xtrapSetup, NULL };
+
+static pointer
+xtrapSetup(pointer module, pointer opts, int *errmaj, int *errmin) {
+ LoadExtension(&xtrapExt, FALSE);
+ /* Need a non-NULL return value to indicate success */
+ return (pointer)1;
+}
+
+#endif /* XFree86LOADER */
diff --git a/nx-X11/programs/Xserver/XTrap/xtrapddmi.c b/nx-X11/programs/Xserver/XTrap/xtrapddmi.c
new file mode 100644
index 000000000..2dba356b7
--- /dev/null
+++ b/nx-X11/programs/Xserver/XTrap/xtrapddmi.c
@@ -0,0 +1,188 @@
+/* $XFree86: xc/programs/Xserver/XTrap/xtrapddmi.c,v 1.1 2001/11/02 23:29:29 dawes Exp $ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991 by Digital Equipment Corp., Maynard, MA
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*****************************************************************************/
+/*
+ * ABSTRACT:
+ *
+ * This module is the platform-specific but conditionally independent
+ * code for the XTrap extension (usually I/O or platform setup).
+ * This is shared code and is subject to change only by team approval.
+ *
+ * CONTRIBUTORS:
+ *
+ * Dick Annicchiarico
+ * Robert Chesler
+ * Gene Durso
+ * Marc Evans
+ * Alan Jamison
+ * Mark Henry
+ * Ken Miller
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef EXTMODULE
+#include <errno.h>
+#include <X11/Xos.h>
+#ifdef PC
+# include "fcntl.h"
+# include "io.h"
+# define O_NDELAY 0L
+#endif
+#else
+#include "xf86_ansic.h"
+#endif
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h> /* From library include environment */
+#include "input.h" /* From server include env. (must be before Xlib.h!) */
+#ifdef PC
+# include "scrintst.h" /* Screen struct */
+# include "extnsist.h"
+#else
+# include "extnsionst.h" /* Server ExtensionEntry definitions */
+# include "scrnintstr.h" /* Screen struct */
+#endif
+
+#include <X11/extensions/xtrapdi.h>
+#include <X11/extensions/xtrapddmi.h>
+#include <X11/extensions/xtrapproto.h>
+
+extern int XETrapErrorBase;
+extern xXTrapGetAvailReply XETrap_avail;
+extern DevicePtr XETrapKbdDev;
+extern DevicePtr XETrapPtrDev;
+
+/*
+ * DESCRIPTION:
+ *
+ * This function performs the platform specific setup for server
+ * extension implementations.
+ */
+void XETrapPlatformSetup()
+{
+}
+
+
+#if !defined _XINPUT
+/*
+ * DESCRIPTION:
+ *
+ * This routine processes the simulation of some input event.
+ *
+ */
+int XETrapSimulateXEvent(register xXTrapInputReq *request,
+ register ClientPtr client)
+{
+ ScreenPtr pScr = NULL;
+ int status = Success;
+ xEvent xev;
+ register int x = request->input.x;
+ register int y = request->input.y;
+ DevicePtr keydev = LookupKeyboardDevice();
+ DevicePtr ptrdev = LookupPointerDevice();
+
+ if (request->input.screen < screenInfo.numScreens)
+ {
+ pScr = screenInfo.screens[request->input.screen];
+ }
+ else
+ { /* Trying to play bogus events to this WS! */
+#ifdef VERBOSE
+ ErrorF("%s: Trying to send events to screen %d!\n", XTrapExtName,
+ request->input.screen);
+#endif
+ status = XETrapErrorBase + BadScreen;
+ }
+ /* Fill in the event structure with the information
+ * Note: root, event, child, eventX, eventY, state, and sameScreen
+ * are all updated by FixUpEventFromWindow() when the events
+ * are delivered via DeliverDeviceEvents() or whatever. XTrap
+ * needs to only concern itself with type, detail, time, rootX,
+ * and rootY.
+ */
+ if (status == Success)
+ {
+ xev.u.u.type = request->input.type;
+ xev.u.u.detail = request->input.detail;
+ xev.u.keyButtonPointer.time = GetTimeInMillis();
+ xev.u.keyButtonPointer.rootX = x;
+ xev.u.keyButtonPointer.rootY = y;
+
+ if (request->input.type == MotionNotify)
+ { /* Set new cursor position on screen */
+ XETrap_avail.data.cur_x = x;
+ XETrap_avail.data.cur_y = y;
+ NewCurrentScreen (pScr, x, y); /* fix from amnonc@mercury.co.il */
+ if (!(*pScr->SetCursorPosition)(pScr, x, y, xFalse))
+ {
+ status = BadImplementation;
+ }
+ }
+ }
+ if (status == Success)
+ {
+ switch(request->input.type)
+ { /* Now process the event appropriately */
+ case KeyPress:
+ case KeyRelease:
+ (*XETrapKbdDev->realInputProc)(&xev,(DeviceIntPtr)keydev, 1L);
+ break;
+ case MotionNotify:
+ case ButtonPress:
+ case ButtonRelease:
+ (*XETrapPtrDev->realInputProc)(&xev,(DeviceIntPtr)ptrdev, 1L);
+ break;
+ default:
+ status = BadValue;
+ break;
+ }
+ }
+ return(status);
+}
+#endif /* _XINPUT */
+
+#if defined vms && !defined LINKED_IN
+/* Used by swapping code not visible from VMS (from main.c) */
+#ifndef BLADE
+void
+NotImplemented()
+{
+ FatalError("Not implemented");
+}
+#endif
+
+int
+#ifdef __STDC__
+ProcBadRequest( ClientPtr client)
+#else
+ProcBadRequest(client)
+ ClientPtr client;
+#endif
+{
+ return (BadRequest);
+}
+
+#endif /* vms && ! LINKED_IN */
diff --git a/nx-X11/programs/Xserver/XTrap/xtrapdi.c b/nx-X11/programs/Xserver/XTrap/xtrapdi.c
new file mode 100644
index 000000000..1055429d4
--- /dev/null
+++ b/nx-X11/programs/Xserver/XTrap/xtrapdi.c
@@ -0,0 +1,2157 @@
+/* $XdotOrg: xc/programs/Xserver/XTrap/xtrapdi.c,v 1.5 2005/07/03 08:53:36 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/XTrap/xtrapdi.c,v 1.6tsi Exp $ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991 by Digital Equipment Corp., Maynard, MA
+X11R6 Changes Copyright (c) 1994 by Robert Chesler of Absol-Puter, Hudson, NH.
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL AND ABSOL-PUTER DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL DIGITAL OR ABSOL-PUTER BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+*****************************************************************************/
+/*
+ * ABSTRACT:
+ *
+ * This module is the main module for extension initialization and setup.
+ * It is called by the server and by clients using the extension.
+ * This is shared code and is subject to change only by team approval.
+ *
+ * CONTRIBUTORS:
+ *
+ * Dick Annicchiarico
+ * Robert Chesler
+ * Gene Durso
+ * Marc Evans
+ * Alan Jamison
+ * Mark Henry
+ * Ken Miller
+ *
+ * CHANGES:
+ *
+ * Robert Chesler - grab-impreviousness patch to improve grab behavior
+ * Robert Chesler - add client arg to swapping routines for X11R6 port
+ *
+ */
+
+/*-----------------*
+ * Include Files *
+ *-----------------*/
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef EXTMODULE
+#include <stdio.h>
+#include <errno.h>
+#include <X11/Xos.h>
+#else
+#include "xf86_ansic.h"
+#endif
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "input.h" /* Server DevicePtr definitions */
+#include "misc.h" /* Server swapping macros */
+#include "dixstruct.h" /* Server ClientRec definitions */
+#include "resource.h" /* Used with the MakeAtom call */
+#ifdef PC
+# include "scrintst.h" /* Screen struct */
+# include "extnsist.h"
+#else
+# include "extnsionst.h" /* Server ExtensionEntry definitions */
+# include "scrnintstr.h" /* Screen struct */
+#endif
+#include "pixmapstr.h" /* DrawableRec */
+#include "windowstr.h" /* Drawable Lookup structures */
+#include <X11/extensions/xtrapdi.h>
+#include <X11/extensions/xtrapddmi.h>
+#include <X11/extensions/xtrapproto.h>
+#include "colormapst.h"
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#include "cursor.h"
+#endif
+
+
+/*----------------------------*
+ * Global Data Declarations *
+ *----------------------------*/
+
+DevicePtr XETrapKbdDev = NULL;
+DevicePtr XETrapPtrDev = NULL;
+int XETrapErrorBase = 0L;
+xXTrapGetAvailReply XETrap_avail; /* What's available to clients */
+
+globalref int_function XETrapDispatchVector[10L]; /* Vector of XTrap Rtns */
+globalref int_function XETSwDispatchVector[10L]; /* Swapped XTrap Rtns */
+
+globalref int_function XETrapProcVector[256L]; /* The "shadowed" ProcVector */
+ /* The "real" EventVector (XTrap creates it till events
+ * truly become vectored
+ */
+#ifndef VECTORED_EVENTS
+globalref int_function EventProcVector[XETrapCoreEvents];
+#else
+extern WindowPtr GetCurrentRootWindow();
+globalref int_function EventProcVector[128L];
+#endif
+static int_function keybd_process_inp = NULL; /* Used for VECTORED_EVENTS */
+ /* The "shadowed" Event Vector */
+globalref int_function XETrapEventProcVector[XETrapCoreEvents];
+
+globalref void_function XETSwProcVector[256L];/* Vector of Req swapping rtns */
+
+/* This macro returns a true/false indicator based on whether it changes the
+ * environment state bits local to the server extension. This is based on the
+ * idea that if a valid flag is set and the corresponding data bit is not in
+ * the same state as desired, then true is returned, otherwise false is
+ * returned.
+ */
+#define _CheckChangeBit(valid,data,local,bit) \
+ (BitIsFalse(valid,bit) ? 0L : \
+ (((BitIsTrue(data,bit) && BitIsTrue(local,bit)) || \
+ (BitIsFalse(data,bit) && BitIsFalse(local,bit))) ? 0L : \
+ (BitToggle(local,bit), 1L)))
+
+/* This macro is designed to return the number of elements in an
+ * automatically allocated array.
+ */
+#ifndef ASIZE
+#define ASIZE(array) (sizeof(array)/sizeof(array[0L]))
+#endif
+
+/* This macro is designed to return the number of long words beyond
+ * XETrapMinRepSize contained in a data structure.
+ */
+#ifndef XEXTRA
+#define XEXTRA(s) \
+ ((sizeof(s)+(sizeof(CARD32)-1L)-XETrapMinRepSize)/sizeof(CARD32))
+#endif
+
+/* Static Declarations known to XTrap Only
+ * All XTrap clients refer to these single copies!
+ */
+/* This carries all of the information XTrap uses for internal information */
+static XETrapEnv *XETenv[MAXCLIENTS] = {NULL};
+#ifndef RESTYPE
+#define RESTYPE unsigned long
+#endif
+static RESTYPE XETrapClass = 0L; /* Resource class for this extension */
+static RESTYPE XETrapType = 0L; /* Resource type for this extension */
+static Bool gate_closed = False; /* The global "gatekeeper" */
+static Bool key_ignore = False; /* The global "keymaster" */
+static Bool ignore_grabs = False;
+static CARD8 next_key = XEKeyIsClear; /* Echo, Clear, or Other */
+#ifdef VECTORED_EVENTS
+static INT16 current_screen = -1L; /* Current screen for events */
+#endif
+static INT16 vectored_requests[256L] = {0L}; /* cnt of vectoring clients */
+static INT16 vectored_events[KeyPress+MotionNotify] = {0L};
+typedef struct _client_list
+{
+ struct _client_list *next;
+ ClientPtr client;
+} ClientList;
+static ClientList io_clients; /* Linked-list of clients currently doing I/O */
+static ClientList stats_clients; /* Linked-list of clients collecting stats */
+static ClientList cmd_clients; /* Linked-list of clients using command key */
+
+/*----------------------------*
+ * Forward Declarations
+ *----------------------------*/
+static void _SwapProc (int (**f1 )(), int (**f2 )());
+static void sXETrapEvent (xETrapDataEvent *from , xETrapDataEvent *to );
+static int add_accelerator_node (ClientPtr client , ClientList *accel );
+static void remove_accelerator_node (ClientPtr client , ClientList *accel );
+static void update_protocol (xXTrapGetReq *reqptr , ClientPtr client );
+#ifdef COLOR_REPLIES
+static void GetSendColorRep (ClientPtr client , xResourceReq *req );
+static void GetSendNamedColorRep (ClientPtr client , xResourceReq *req );
+static void GetSendColorCellsRep (ClientPtr client , xResourceReq *req );
+static void GetSendColorPlanesRep (ClientPtr client , xResourceReq *req );
+#endif
+
+/*
+ * DESCRIPTION:
+ *
+ * This routine is called by the server when a given client
+ * goes away (as identified by the first argument). All
+ * memory allocations, misc. values specific to a given
+ * client would be reset here.
+ *
+ */
+int XETrapDestroyEnv(pointer value, XID id)
+{
+ xXTrapReq request;
+ XETrapEnv *penv = XETenv[(long)value];
+
+ XETrapReset(&request,penv->client);
+ /* Free any memory malloc'd for a particular client here */
+ /* In case stop I/O wasn't received for this client */
+ if (penv->stats)
+ { /* Remove from client accelerator list */
+ remove_accelerator_node(penv->client, &stats_clients);
+ Xfree(penv->stats); /* Free the stats buckets */
+ }
+ if (cmd_clients.next == NULL)
+ { /* No more command key clients! Let's reset the gate */
+ gate_closed = False;
+ key_ignore = False;
+ next_key = XEKeyIsClear;
+ }
+
+#ifdef VECTORED_EVENTS
+ current_screen = -1L; /* Invalidate current screen */
+#endif
+
+#ifdef VERBOSE
+ ErrorF("%s: Client '%d' Disconnected\n", XTrapExtName,
+ penv->client->index);
+#endif
+
+ Xfree(penv);
+ XETenv[(long)value] = NULL;
+
+ return 0;
+}
+
+/*
+ * DESCRIPTION:
+ *
+ * This routine is called by the server when the last client
+ * (the session manager in most cases) goes away. This is server
+ * reset. When the server comes back up, this extension will not
+ * be loaded unless this routine makes the proper arrangements.
+ *
+ * The real concern here is to unload the extension
+ * and possibly make arragements to be called upon
+ * server restart.
+ *
+ */
+void XETrapCloseDown(ExtensionEntry *extEntry)
+{
+ long i;
+
+ for (i=0L; i<MAXCLIENTS; i++)
+ {
+ if (XETenv[i] != NULL)
+ {
+ XETrapDestroyEnv((pointer)i,0L);
+ }
+ }
+ ignore_grabs = False;
+ return;
+}
+
+/*
+ *
+ * DESCRIPTION:
+ *
+ * This routine has been created because of the initialization
+ * order that X uses, such that extensions are initialized before
+ * devices. This means that this extension must perform a second
+ * level of initialization to obtain the device references at some
+ * point after they have been initialized. It is assumed that when
+ * a client establishes communication with the extension that the
+ * devices havae been initialized, and therefore this function can
+ * obtain the information it needs.
+ *
+ * In obtaining the information, this function also places its own
+ * functions in place of the *standard* functions. The original
+ * functions are retained for vectoring purposes.
+ */
+
+Bool XETrapRedirectDevices()
+{
+ Bool retval = True;
+
+ /* Do we need to redirect the keyboard device? */
+ if (XETrapKbdDev == NULL)
+ {
+ if ((XETrapKbdDev = LookupKeyboardDevice()) == NULL)
+ {
+ retval = False;
+ }
+ else
+ {
+ EventProcVector[KeyPress] =
+ (int_function)XETrapKbdDev->realInputProc;
+ EventProcVector[KeyRelease] =
+ (int_function)XETrapKbdDev->realInputProc;
+ }
+#ifdef VECTORED_EVENTS
+ keybd_process_inp = EventProcVector[KeyPress];
+ EventProcVector[KeyPress] = EventProcVector[KeyRelease] = NULL;
+ XETrapEventProcVector[KeyPress] = XETrapEventVector;
+ XETrapEventProcVector[KeyRelease] = XETrapEventVector;
+#else /* !VECTORED_EVENTS */
+ XETrapEventProcVector[KeyPress] = XETrapKeyboard;
+ XETrapEventProcVector[KeyRelease] = XETrapKeyboard;
+#endif /* !VECTORED_EVENTS */
+ }
+ /* Do we need to redirect the pointer device? */
+#ifndef VECTORED_EVENTS
+ if (XETrapPtrDev == NULL)
+ {
+ if ((XETrapPtrDev = LookupPointerDevice()) == 0L)
+ {
+ retval = False;
+ }
+ else
+ {
+ EventProcVector[ButtonPress] =
+ (int_function)XETrapPtrDev->realInputProc;
+ EventProcVector[ButtonRelease] =
+ (int_function)XETrapPtrDev->realInputProc;
+ EventProcVector[MotionNotify] =
+ (int_function)XETrapPtrDev->realInputProc;
+ }
+ XETrapEventProcVector[ButtonPress] = XETrapPointer;
+ XETrapEventProcVector[ButtonRelease] = XETrapPointer;
+ XETrapEventProcVector[MotionNotify] = XETrapPointer;
+ }
+#endif /* !VECTORED_EVENTS */
+ return(retval);
+}
+
+/*
+ *
+ * DESCRIPTION:
+ *
+ * This routine is the main entry point for the Xtrap extension. It is
+ * called by the server to inititalize the Xtrap extension. Once the
+ * extension is initialized, life is controlled by the XtrapDispatch
+ * routine by the requests it will handle.
+ *
+ * Initializes all the XTrap data structures with the proper
+ * addresses of defined routines that will help control the extension.
+ * It is vital that the extension state be kept accurate so that only
+ * one call to this routine be made.
+ *
+ */
+
+void DEC_XTRAPInit()
+{
+ register ExtensionEntry *extEntry;
+ unsigned int i;
+ Atom a;
+
+ /* Make the extension known to the server. Must be done every time
+ * DEC_XTRAPInit is called, else server will think it failed.
+ */
+ if ((extEntry = AddExtension(XTrapExtName,XETrapNumEvents,
+ XETrapNumErrors,XETrapDispatch,sXETrapDispatch,XETrapCloseDown
+ ,StandardMinorOpcode)) == NULL)
+ {
+ ErrorF("%s: AddExtension Failed!\n", XTrapExtName);
+ return;
+ }
+#ifdef VERBOSE
+ ErrorF("%s: AddExtension assigned Major Opcode '%d'\n",
+ XTrapExtName, extEntry->base);
+#endif
+ XETrap_avail.data.major_opcode = extEntry->base;
+ XETrapErrorBase = extEntry->errorBase;
+ XETrap_avail.data.event_base = extEntry->eventBase;
+
+ /* Set up our swapped reply vector */
+ ReplySwapVector[XETrap_avail.data.major_opcode] =
+ (void_function) sReplyXTrapDispatch;
+
+ /* Set up our swapped event vector */
+ EventSwapVector[extEntry->eventBase + XETrapData] =
+ (EventSwapPtr) sXETrapEvent;
+
+ /* make an atom saying that the extension is present. The
+ * adding of the resource occurs during XETrapCreateEnv().
+ */
+ if ((a = MakeAtom(XTrapExtName,strlen(XTrapExtName),1L)) == None ||
+ (XETrapType = CreateNewResourceType(XETrapDestroyEnv)) == 0L)
+ {
+ ErrorF("%s: Setup can't create new resource type (%d,%d,%d)\n",
+ XTrapExtName, (int)a,(int)XETrapClass,(int)XETrapType);
+ return;
+ }
+ /* initialize the GetAvailable info reply here */
+ XETrap_avail.hdr.type = X_Reply;
+ XETrap_avail.hdr.length = XEXTRA(xXTrapGetAvailReply);
+ XETrap_avail.data.xtrap_release = XETrapRelease;
+ XETrap_avail.data.xtrap_version = XETrapVersion;
+ XETrap_avail.data.xtrap_revision = XETrapRevision;
+ XETrap_avail.data.pf_ident = XETrapPlatform;
+ XETrap_avail.data.max_pkt_size = 0xFFFF; /* very large number */
+ for (i=0L; i<ASIZE(XETrap_avail.data.valid); i++)
+ {
+ XETrap_avail.data.valid[i] = 0L; /* Clear bits initially */
+ }
+ BitTrue(XETrap_avail.data.valid,XETrapTimestamp);
+ BitTrue(XETrap_avail.data.valid,XETrapCmd);
+ BitTrue(XETrap_avail.data.valid,XETrapCmdKeyMod);
+ BitTrue(XETrap_avail.data.valid,XETrapRequest);
+ BitTrue(XETrap_avail.data.valid,XETrapEvent);
+ BitTrue(XETrap_avail.data.valid,XETrapMaxPacket);
+ BitTrue(XETrap_avail.data.valid,XETrapStatistics);
+ BitTrue(XETrap_avail.data.valid,XETrapWinXY);
+ /* Not yet implemented */
+ BitFalse(XETrap_avail.data.valid,XETrapCursor);
+#ifndef _XINPUT
+ BitFalse(XETrap_avail.data.valid,XETrapXInput);
+#else
+ BitTrue(XETrap_avail.data.valid,XETrapXInput);
+#endif
+#ifndef VECTORED_EVENTS
+ BitFalse(XETrap_avail.data.valid,XETrapVectorEvents);
+#else
+ BitTrue(XETrap_avail.data.valid,XETrapVectorEvents);
+#endif /* VECTORED_EVENTS */
+#ifndef COLOR_REPLIES
+ BitFalse(XETrap_avail.data.valid,XETrapColorReplies);
+#else
+ BitTrue(XETrap_avail.data.valid,XETrapColorReplies);
+#endif /* COLOR_REPLIES */
+ BitTrue(XETrap_avail.data.valid,XETrapGrabServer);
+ /* initialize multi-client accelerator lists */
+ io_clients.next = NULL;
+ stats_clients.next = NULL;
+ cmd_clients.next = NULL;
+ for (i=0L; i<256L; i++)
+ {
+ vectored_requests[i] = 0L;
+ }
+ for (i=KeyPress; i<=MotionNotify; i++)
+ {
+ vectored_events[i] = 0L;
+ }
+ gate_closed = False;
+ key_ignore = False;
+ next_key = XEKeyIsClear;
+
+ XETrapPlatformSetup();
+ /* Initialize any local memory we use */
+ for (i=0L; i<ASIZE(EventProcVector); i++)
+ {
+ EventProcVector[i] = NULL;
+#ifndef VECTORED_EVENTS
+ XETrapEventProcVector[i] = NULL;
+#else
+ XETrapEventProcVector[i] = XETrapEventVector;
+#endif
+ }
+ XETrapKbdDev = NULL;
+ XETrapPtrDev = NULL;
+ for (i=0L; i<ASIZE(XETrapProcVector); i++)
+ {
+ XETrapProcVector[i] = XETrapRequestVector;
+ }
+ for (i=128L; i<=255L; i++)
+ { /* Extension "swapped" requests are not implemented */
+ XETSwProcVector[i] = NotImplemented;
+ }
+#ifdef VERBOSE
+ ErrorF("%s: Vers. %d.%d-%d successfully loaded\n", XTrapExtName,
+ XETrap_avail.data.xtrap_release,
+ XETrap_avail.data.xtrap_version,
+ XETrap_avail.data.xtrap_revision);
+#endif
+
+ return;
+}
+
+/*
+ * DESCRIPTION:
+ *
+ * This procedure is called upon dispatch to allocate an
+ * environment structure for a new XTrap client. The XETenv[]
+ * entry is allocated and initialized with default values.
+ * XETrapDestroyEnv() is responsible for deallocating this memory
+ * upon client termination.
+ *
+ * Note: the status of this routine is returned to the caller of
+ * the Dispatch routine which will in turn SendErrorToClient if
+ * necessary.
+ *
+ */
+
+int XETrapCreateEnv(ClientPtr client)
+{
+ XETrapEnv *penv = NULL;
+ int status = Success;
+
+ if (client->index > MAXCLIENTS)
+ {
+ status = BadImplementation;
+ }
+ else if ((XETenv[client->index] = (XETrapEnv *)Xcalloc(sizeof(XETrapEnv)))
+ == NULL)
+ {
+ status = BadAlloc;
+ }
+ if (status == Success)
+ {
+ penv = XETenv[client->index];
+ penv->client = client;
+ penv->protocol = 31; /* default to backwards compatibility */
+ /* prep for client's departure (for memory dealloc, cleanup) */
+ AddResource(FakeClientID(client->index),XETrapType,
+ (pointer)(long)(client->index));
+ if (XETrapRedirectDevices() == False)
+ {
+ status = XETrapErrorBase + BadDevices;
+ }
+ /* Initialize the current state */
+ if (status == Success)
+ {
+ status = XETrapReset(NULL, penv->client);
+ }
+ }
+
+#ifdef VECTORED_EVENTS
+ current_screen = -1L; /* Invalidate current screen */
+#endif
+
+#ifdef VERBOSE
+ if (status == Success)
+ {
+ ErrorF("%s: Client '%d' Connection Accepted\n", XTrapExtName,
+ penv->client->index);
+ }
+#endif
+
+ return(status);
+}
+
+/*
+ * DESCRIPTION:
+ *
+ * This procedure is defined for the call to AddExtension()
+ * in which it is expected to be a parameter of the call.
+ *
+ * This routine will be called by the server dispatcher
+ * when a client makes a request that is handled
+ * by the extension and the byte ordering of the client is the
+ * SAME as that of the extension.
+ *
+ * Note: the status of the requests is returned to the caller of
+ * the Dispatch routine which will in turn SendErrorToClient if
+ * necessary.
+ */
+
+int XETrapDispatch(ClientPtr client)
+{
+
+ REQUEST(xXTrapReq);
+ register int status = Success;
+
+ REQUEST_AT_LEAST_SIZE(xXTrapReq);
+
+ /* Have we seen this client before? */
+ if (XETenv[client->index] == NULL)
+ {
+ status = XETrapCreateEnv(client);
+ }
+ /* Do we have a valid request? */
+ if (status == Success)
+ {
+ if (stuff->minor_opcode < ASIZE(XETrapDispatchVector))
+ {
+ /* Then vector to the pointed to function */
+ status =
+ (*(XETrapDispatchVector[stuff->minor_opcode]))(stuff,client);
+ }
+ else
+ {
+ status = BadRequest;
+ }
+ }
+ return(status);
+}
+
+/*
+ * DESCRIPTION:
+ *
+ * This procedure is defined for the call to AddExtension()
+ * in which it is expected to be a parameter of the call.
+ *
+ * This routine would ordinarily be called by the server
+ * dispatcher when a client makes a request that is handled
+ * by the extension and the byte ordering of the client is
+ * DIFFERENT than that of the extension.
+ */
+
+int sXETrapDispatch(ClientPtr client)
+{
+
+ REQUEST(xXTrapReq);
+ register int status = Success;
+
+ REQUEST_AT_LEAST_SIZE(xXTrapReq);
+
+ /* Have we seen this client before? */
+ if (XETenv[client->index] == NULL)
+ {
+ status = XETrapCreateEnv(client);
+ }
+ /* Do we have a valid request? */
+ if (status == Success)
+ {
+ if (stuff->minor_opcode < ASIZE(XETSwDispatchVector))
+ {
+ /* Then vector to the pointed to function */
+ status =
+ (*(XETSwDispatchVector[stuff->minor_opcode]))(stuff,client);
+ }
+ else
+ {
+ status = BadRequest;
+ }
+ }
+ return(status);
+}
+
+/*
+ * DESCRIPTION:
+ *
+ * This routine will place the extension in a steady and known
+ * state. Any current state will be reset. This is called either
+ * by a client request (dispatched) or when a new client environment
+ * is created.
+ *
+ */
+int XETrapReset(xXTrapReq *request, ClientPtr client)
+{
+ static xXTrapConfigReq DummyReq;
+ register int i;
+ register int status = Success;
+ XETrapEnv *penv = XETenv[client->index];
+
+ /* in case any i/o's pending */
+ (void)XETrapStopTrap((xXTrapReq *)NULL, client);
+ penv->cur.hdr.type = X_Reply;
+ penv->cur.hdr.length = XEXTRA(xXTrapGetCurReply);
+ /* Fill in a dummy config request to clear all elements */
+ for (i=0L; i<ASIZE(DummyReq.config_flags_valid); i++)
+ {
+ DummyReq.config_flags_valid[i] = 0xFFL; /* set all the valid flags */
+ DummyReq.config_flags_data[i] = 0L; /* clear all data flags */
+ }
+ /* Don't reset grab server arbitrarily, it must be explicitly
+ * de-configured.
+ */
+ BitSet(DummyReq.config_flags_data, XETrapGrabServer, ignore_grabs);
+ for (i=0L; i< ASIZE(DummyReq.config_flags_req); i++)
+ {
+ DummyReq.config_flags_req[i] = 0xFF; /* Clear all protocol requests */
+ }
+ for (i=0L; i< ASIZE(DummyReq.config_flags_event); i++)
+ {
+ DummyReq.config_flags_event[i] = 0xFF; /* Clear all protocol events */
+ }
+ /* Call config routine to clear all configurable fields */
+ status = XETrapConfig(&DummyReq, client);
+ /* reset the environment */
+ for (i=0L; i<ASIZE(penv->cur.data_state_flags); i++)
+ {
+ penv->cur.data_state_flags[i] = 0L; /* Clear all env flags */
+ }
+ penv->cur.data_config_max_pkt_size = XETrap_avail.data.max_pkt_size;
+
+ return(status);
+}
+
+/*
+ * DESCRIPTION:
+ *
+ * This function sends a reply back to the requesting client indicating
+ * the available states of the extension can be configured for.
+ */
+int XETrapGetAvailable(xXTrapGetReq *request, ClientPtr client)
+{
+ XETrapEnv *penv = XETenv[client->index];
+ update_protocol(request, client);
+ /* Initialize the reply as needed */
+ XETrap_avail.data.xtrap_protocol = penv->protocol;
+ XETrap_avail.hdr.detail = XETrap_GetAvailable;
+ XETrap_avail.hdr.sequenceNumber = client->sequence;
+ WriteReplyToClient(client, sizeof(xXTrapGetAvailReply), &XETrap_avail);
+ return(Success);
+}
+
+/*
+ * DESCRIPTION:
+ *
+ * This function sends a reply back to the requesting client indicating
+ * the current state of the extension.
+ */
+int XETrapGetCurrent(xXTrapReq *request, ClientPtr client)
+{
+ XETrapEnv *penv = XETenv[client->index];
+ int rep_size = (penv->protocol == 31 ? 284 : sz_xXTrapGetCurReply);
+ penv->cur.hdr.length = (rep_size - 32L) / SIZEOF(CARD32);
+
+ /* Initialize the reply as needed */
+ penv->cur.hdr.detail = XETrap_GetCurrent;
+ penv->cur.hdr.sequenceNumber = client->sequence;
+ WriteReplyToClient(client, rep_size, &(penv->cur));
+
+ return(Success);
+}
+
+/*
+ * DESCRIPTION:
+ *
+ * This function sends a reply back to the requesting client dumping
+ * statistics (counts) of requests and events. If stat's isn't
+ * configured, return failure.
+ */
+int XETrapGetStatistics(xXTrapReq *request, ClientPtr client)
+{
+ int status = Success;
+ XETrapEnv *penv = XETenv[client->index];
+
+ if ((BitIsTrue(penv->cur.data_config_flags_data, XETrapStatistics)) &&
+ (penv->stats))
+ {
+ /* Initialize the reply as needed */
+ int rep_size = sizeof(xXTrapGetStatsReply);
+ penv->stats->detail = XETrap_GetStatistics;
+ penv->stats->sequenceNumber = client->sequence;
+ if (penv->protocol == 31)
+ {
+ xXTrapGetStatsReply rep_stats;
+ rep_stats = *penv->stats;
+#ifndef VECTORED_EVENTS
+ rep_size = 1060;
+#else
+ rep_size = 1544;
+#endif
+ rep_stats.length = (rep_size - 32L) / SIZEOF(CARD32);
+ /*
+ * Now we need to shift the data *into* the header area
+ * for bug compatibility.
+ */
+ memcpy(&(rep_stats.pad0),&(penv->stats->data),
+ sizeof(XETrapGetStatsRep));
+ WriteReplyToClient(client, rep_size, &rep_stats);
+ }
+ else
+ {
+ WriteReplyToClient(client, rep_size, penv->stats);
+ }
+ }
+ else
+ {
+ status = XETrapErrorBase + BadStatistics;
+ }
+ return(status);
+}
+
+/*
+ * DESCRIPTION:
+ *
+ * This function is dispatched when a client requests the extension to
+ * be configured in some manner.
+ */
+int XETrapConfig(xXTrapConfigReq *request, ClientPtr client)
+{
+ UByteP vflags = request->config_flags_valid;
+ UByteP dflags = request->config_flags_data;
+ UByteP req_flags = request->config_flags_req;
+ UByteP event_flags = request->config_flags_event;
+ XETrapEnv *penv = XETenv[client->index];
+ UByteP bit_flags = penv->cur.data_config_flags_data;
+ int status = Success;
+ CARD32 i = 0L;
+
+ /* Check events and swap if desired */
+ if (BitIsTrue(vflags,XETrapEvent))
+ { /* Loop through all of the events */
+ for (i=0L; i<ASIZE(EventProcVector); i++)
+ {
+ if (BitIsTrue(event_flags,i) && /* Do we care about this one? */
+ (BitValue(dflags,XETrapEvent) ^ /* Exclusive Or */
+ (BitValue(penv->cur.data_config_flags_event,i))))
+ { /* At this point we *know* there's a change. The
+ * only question remaining is are there any more
+ * clients interested in this specific event. If
+ * so, *don't* swap this process!
+ */
+ if (BitIsTrue(dflags,XETrapEvent))
+ { /* Client wants the XTrap rtn */
+ if (++(vectored_events[i]) <= 1L)
+ { /* first client, so do it */
+ _SwapProc(&(XETrapEventProcVector[i]),
+ &(EventProcVector[i]));
+ }
+ }
+ else
+ { /* Client wants the *real* rtn */
+ if (--(vectored_events[i]) <= 0L)
+ { /* No more clients using, so do it */
+ _SwapProc(&(XETrapEventProcVector[i]),
+ &(EventProcVector[i]));
+ }
+ }
+ switch(i)
+ {
+ case KeyPress: /* needed for command key processing */
+ case KeyRelease:
+ XETrapKbdDev->processInputProc =
+ (void_function)(EventProcVector[i] ?
+ (void_function)EventProcVector[i] :
+ (void_function)keybd_process_inp);
+ XETrapKbdDev->realInputProc =
+ (void_function)(EventProcVector[i] ?
+ (void_function)EventProcVector[i] :
+ (void_function)keybd_process_inp);
+ break;
+#ifndef VECTORED_EVENTS
+ case ButtonPress: /* hack until events become vectored */
+ case ButtonRelease:
+ case MotionNotify:
+ XETrapPtrDev->processInputProc =
+ (void_function)EventProcVector[i];
+ XETrapPtrDev->realInputProc =
+ (void_function)EventProcVector[i];
+ break;
+ default:
+ status = BadImplementation;
+ break;
+#endif /* !VECTORED_EVENTS */
+ }
+ BitToggle(penv->cur.data_config_flags_event,i);
+ }
+ }
+ }
+ if ((status == Success) &&
+ (_CheckChangeBit(vflags,dflags,bit_flags,XETrapCmd)))
+ {
+ if (BitIsTrue(dflags, XETrapCmd))
+ { /* Add accelerator entry to cmd_clients list iff necessary */
+ penv->cur.data_config_cmd_key = request->config_cmd_key;
+ status = add_accelerator_node(penv->client, &cmd_clients);
+ }
+ else
+ {
+ penv->cur.data_config_cmd_key = 0L; /* default no KeyCode */
+ remove_accelerator_node(penv->client, &cmd_clients);
+ }
+ }
+ if ((status == Success) &&
+ (_CheckChangeBit(vflags,dflags,bit_flags,XETrapMaxPacket)))
+ {
+ if (BitIsTrue(dflags,XETrapMaxPacket))
+ { /* Set size to what's passed in */
+ if (request->config_max_pkt_size < XETrapMinPktSize)
+ { /* Tell them the value is too small */
+ status = BadValue;
+ }
+ else
+ {
+ penv->cur.data_config_max_pkt_size =
+ request->config_max_pkt_size;
+ }
+ }
+ else
+ { /* Set it to the default (a *very* big number) */
+ penv->cur.data_config_max_pkt_size = 0xFFFF;
+ }
+ }
+ /* If the valid flag is set for requests, then each of the
+ * requests is swapped if it's different from current state.
+ */
+ if (BitIsTrue(vflags,XETrapRequest) && status == Success)
+ { /* Loop through all of the core requests */
+ for (i=0L; i<ASIZE(XETrapProcVector); i++)
+ {
+ if (BitIsTrue(req_flags,i) && /* Do we care about this one? */
+ (BitValue(dflags,XETrapRequest) ^ /* Exclusive Or */
+ (BitValue(penv->cur.data_config_flags_req,i))))
+ { /* At this point we *know* there's a change. The
+ * only question remaining is are there any more
+ * clients interested in this specific request. If
+ * so, *don't* swap this process!
+ */
+ if (BitIsTrue(dflags,XETrapRequest))
+ { /* Client wants the XTrap rtn */
+ if (++(vectored_requests[i]) <= 1L)
+ { /* first client, so do it */
+ _SwapProc(&(XETrapProcVector[i]), &(ProcVector[i]));
+ }
+ }
+ else
+ { /* Client wants the *real* rtn */
+ if (--(vectored_requests[i]) <= 0L)
+ { /* No more clients using, so do it */
+ _SwapProc(&(XETrapProcVector[i]), &(ProcVector[i]));
+ }
+ }
+ if (status == Success)
+ {
+ BitToggle(penv->cur.data_config_flags_req,i);
+ }
+ }
+ }
+ }
+ /* Check & Set the boolean flags */
+ if (status == Success)
+ {
+ _CheckChangeBit(vflags,dflags,bit_flags,XETrapCmdKeyMod);
+ _CheckChangeBit(vflags,dflags,bit_flags,XETrapTimestamp);
+ _CheckChangeBit(vflags,dflags,bit_flags,XETrapWinXY);
+/* _CheckChangeBit(vflags,dflags,bit_flags,XETrapCursor); */
+#ifdef COLOR_REPLIES
+ _CheckChangeBit(vflags,dflags,bit_flags,XETrapColorReplies);
+#endif /* COLOR_REPLIES */
+ if (_CheckChangeBit(vflags,dflags,bit_flags,XETrapGrabServer))
+ { /* Let any client uncoditionally set/clear Grabs */
+ ignore_grabs = BitValue(dflags, XETrapGrabServer);
+ }
+ }
+ /* The statistics vflag/dflag mechanism is a little different
+ * from most. The dflag is initially set to 0 to indicate no
+ * statistics. When a config request comes in to request
+ * statistics, memory's allocated and the dflag is set.
+ * Thereafter, whenever a client wants to clear the counters, he
+ * simply sets the vflag and clears the dflag. Multiple requests
+ * for statistics configuration are ignored, and the stats memory is
+ * free'd only when the client disconnects.
+ */
+ if (status == Success)
+ {
+ if (_CheckChangeBit(vflags,dflags,bit_flags,XETrapStatistics))
+ {
+ if (BitIsTrue(dflags,XETrapStatistics))
+ { /* Do we need to allocate memory? */
+ if (penv->stats == NULL && (penv->stats =
+ (xXTrapGetStatsReply *)Xcalloc(sizeof(xXTrapGetStatsReply)))
+ != NULL)
+ { /* Set up the reply header */
+ penv->stats->type = X_Reply;
+ penv->stats->length = XEXTRA(xXTrapGetStatsReply);
+ /* add accelerator node for stats clients list */
+ status = add_accelerator_node(penv->client, &stats_clients);
+ }
+ else if (penv->stats == NULL)
+ { /* No Memory! */
+ status = BadAlloc;
+ }
+ }
+ else
+ { /* Zero out counters */
+ (void)memset(penv->stats->data.requests, 0L,
+ sizeof(penv->stats->data.requests));
+ (void)memset(penv->stats->data.events, 0L,
+ sizeof(penv->stats->data.events));
+ /* Re-cock the Stat's flag so that it'll
+ * sense a change for next zero'ing out
+ * of the counters.
+ */
+ BitTrue(penv->cur.data_config_flags_data, XETrapStatistics);
+ }
+ }
+ }
+ return(status);
+}
+
+/*
+ * DESCRIPTION:
+ *
+ * This function sets the XETrapTrapActive bit to indicate that Trapping
+ * of requests and/or core events to the client may take place.
+ *
+ */
+int XETrapStartTrap(xXTrapReq *request, ClientPtr client)
+{
+ XETrapEnv *penv = XETenv[client->index];
+ int status = add_accelerator_node(penv->client, &io_clients);
+ if (status == Success)
+ {
+ BitTrue(penv->cur.data_state_flags, XETrapTrapActive);
+ }
+ return(status);
+}
+/*
+ * DESCRIPTION:
+ *
+ * This function clears the XETrapTrapActive bit to indicate that Trapping
+ * of requests and/or core events to the client may *not* take place.
+ *
+ */
+int XETrapStopTrap(xXTrapReq *request, ClientPtr client)
+{
+ XETrapEnv *penv = XETenv[client->index];
+
+ remove_accelerator_node(penv->client, &io_clients);
+ BitFalse(penv->cur.data_state_flags, XETrapTrapActive);
+ return(Success);
+}
+
+/*
+ * DESCRIPTION:
+ *
+ * This function sends a reply back to the requesting client indicating
+ * the specific XTrap version of this extension.
+ */
+int XETrapGetVersion(xXTrapGetReq *request, ClientPtr client)
+{
+ xXTrapGetVersReply ver_rep;
+ XETrapEnv *penv = XETenv[client->index];
+
+ update_protocol(request,client); /* to agree on protocol version */
+ /* Initialize the reply as needed */
+ ver_rep.hdr.type = X_Reply;
+ ver_rep.hdr.detail = XETrap_GetVersion;
+ ver_rep.hdr.sequenceNumber = client->sequence;
+ ver_rep.hdr.length = XEXTRA(xXTrapGetVersReply);
+ ver_rep.data.xtrap_release = XETrap_avail.data.xtrap_release;
+ ver_rep.data.xtrap_version = XETrap_avail.data.xtrap_version;
+ ver_rep.data.xtrap_revision = XETrap_avail.data.xtrap_revision;
+ ver_rep.data.xtrap_protocol = penv->protocol; /* return agreed protocol */
+ WriteReplyToClient(client, sizeof(xXTrapGetVersReply), &ver_rep);
+ return(Success);
+}
+
+/*
+ * DESCRIPTION:
+ *
+ * This function sends a reply back to the requesting client indicating
+ * the specific XTrap version of this extension.
+ */
+int XETrapGetLastInpTime(xXTrapReq *request, ClientPtr client)
+{
+ xXTrapGetLITimReply tim_rep;
+ XETrapEnv *penv = XETenv[client->index];
+
+ /* Initialize the reply as needed */
+ tim_rep.hdr.type = X_Reply;
+ tim_rep.hdr.detail = XETrap_GetLastInpTime;
+ tim_rep.hdr.sequenceNumber = client->sequence;
+ tim_rep.hdr.length = XEXTRA(xXTrapGetLITimReply);
+ tim_rep.data_last_time = penv->last_input_time;
+ WriteReplyToClient(client, sizeof(xXTrapGetLITimReply), &tim_rep);
+ return(Success);
+}
+
+/*
+ * DESCRIPTION:
+ *
+ * This routine is swapped in for the server's output request vectors.
+ * After writing the request to one (or more) XTrap client(s), this
+ * routine ALWAYS returns by calling the REAL output request vector rtn.
+ *
+ * Note: Swapped Requests are handled automatically since the unswapped
+ * vectored routine is called after the request has been swapped.
+ * IOW, all requests are directed through ProcVector eventually and are
+ * "unswapped" at that point. It is necessary to swap the data
+ * back if writing to a swapped client, however, and this is done
+ * by calling the appropriate XETSwProcVector[] routine.
+ */
+int XETrapRequestVector(ClientPtr client)
+{
+ int status = True;
+ XETrapDatum *pdata, *spdata = NULL;
+ REQUEST(xResourceReq);
+ WindowPtr window_ptr;
+ XETrapEnv *penv;
+ BYTE *tptr;
+ ClientList *ioc = &io_clients;
+ ClientList *stc = &stats_clients;
+ INT32 asize = sizeof(pdata->hdr) + stuff->length * sizeof(CARD32);
+ INT32 size = MAX(asize,XETrapMinPktSize); /* Must be at least */
+ INT32 csize; /* size of request to send to the XTrap client */
+
+ /* Get memory for the data to be sent */
+ if ((pdata = (XETrapDatum *)Xcalloc(size)) == NULL)
+ { /* Can't do anything accept set a flag since we don't
+ * know who to send the error to yet.
+ */
+ status = False;
+ }
+
+ while (ioc->next != NULL)
+ {
+ ioc = ioc->next;
+ penv = XETenv[ioc->client->index];
+ if (status == False)
+ { /* We didn't get the memory! Complain */
+ SendErrorToClient(penv->client,XETrap_avail.data.major_opcode,
+ stuff->reqType, 0L, BadAlloc);
+ break;
+ }
+ if (BitIsTrue(penv->cur.data_config_flags_req,stuff->reqType))
+ { /* This particular client is interested in *this* request */
+ pdata->hdr.client = client->index; /* stuff client index in hdr */
+ if (BitIsTrue(penv->cur.data_config_flags_data,XETrapWinXY))
+ {
+ window_ptr = (WindowPtr) LookupDrawable(stuff->id, client);
+ if (window_ptr == 0L)
+ { /* Failed...invalidate the X and Y coordinate data. */
+ pdata->hdr.win_x = -1L;
+ pdata->hdr.win_y = -1L;
+ }
+ else
+ {
+ pdata->hdr.screen = window_ptr->drawable.pScreen->myNum;
+ pdata->hdr.win_x = window_ptr->drawable.x;
+ pdata->hdr.win_y = window_ptr->drawable.y;
+ }
+ }
+ if (BitIsTrue(penv->cur.data_config_flags_data,XETrapTimestamp))
+ {
+ pdata->hdr.timestamp = GetTimeInMillis();
+ }
+ /* Copy the information to a location we can write it from */
+ (void) memcpy(&(pdata->u.req),stuff,stuff->length*sizeof(CARD32));
+ pdata->hdr.count = MIN(penv->cur.data_config_max_pkt_size,asize);
+ XETrapSetHeaderRequest(&(pdata->hdr));
+
+ /* Perform any needed byte/word swapping. NOTE: This is not
+ * the "normal" technique that should be used to perform the
+ * swapping. The reason that we do it here is to be sure to
+ * do it only once in a controlled manner, which we can not
+ * guarentee in the case of the Xlib transport. Notice that
+ * we don't swap the XTRAP EVENT information. This is done
+ * in the XETrapWriteXLib() routine.
+ */
+
+ if (penv->client->swapped)
+ { /* need to deal with swapped clients */
+ if (spdata == NULL)
+ { /* Get memory for the swapped data to be sent */
+ if ((spdata = (XETrapDatum *)Xcalloc(size)) == NULL)
+ {
+ SendErrorToClient(penv->client,
+ XETrap_avail.data.major_opcode,
+ stuff->reqType, 0L, BadAlloc);
+ break;
+ }
+
+ memcpy(spdata,pdata,size); /* fill in the info */
+ /* Now call the request-specific rtn to swap the request */
+ if (stuff->reqType < 128)
+ { /* a core request, good */
+ (*XETSwProcVector[stuff->reqType])(&(spdata->u.req),
+ penv->client); /* RTC X11R6 */
+ }
+ else if (penv->cur.data_config_max_pkt_size ==
+ XETrapMinPktSize)
+ { /* Minimum size, so swap it as an ResourceReq */
+ XETSwResourceReq(&(spdata->u.req));
+ }
+ else
+ { /* trying to swap an extension request! */
+ SendErrorToClient(penv->client,
+ XETrap_avail.data.major_opcode,
+ stuff->reqType, 0L, XETrapErrorBase + BadSwapReq);
+ }
+ }
+ /* need to stow in the latest header (count) */
+ memcpy(spdata,pdata,SIZEOF(XETrapHeader));
+ sXETrapHeader(&(spdata->hdr)); /* swap the XTrap Header */
+ }
+ /* Write as many bytes of information as the client wants */
+ tptr = (BYTE *)(penv->client->swapped ? spdata : pdata);
+ csize = MAX(pdata->hdr.count, XETrapMinPktSize);
+ if (XETrapWriteXLib(penv, tptr, csize) != csize)
+ {
+ SendErrorToClient(penv->client,XETrap_avail.data.major_opcode,
+ stuff->reqType, 0L, XETrapErrorBase + BadIO);
+ }
+#ifdef COLOR_REPLIES
+ /* Process Color Replies, if desired, and applicable */
+ if (BitIsTrue(penv->cur.data_config_flags_data,XETrapColorReplies))
+ { /* wants color replies */
+ switch(stuff->reqType)
+ {
+ case X_AllocColor:
+ GetSendColorRep(client, stuff);
+ break;
+ case X_AllocNamedColor:
+ GetSendNamedColorRep(client, stuff);
+ break;
+ case X_AllocColorCells:
+ GetSendColorCellsRep(client, stuff);
+ break;
+ case X_AllocColorPlanes:
+ GetSendColorPlanesRep(client, stuff);
+ break;
+ default:
+ break;
+ }
+ }
+#endif /* COLOR_REPLIES */
+ }
+ }
+ while (stc->next != NULL)
+ { /* increment appropriate stats bucket for each interested client */
+ stc = stc->next;
+ penv = XETenv[stc->client->index];
+ if (BitIsTrue(penv->cur.data_config_flags_req,stuff->reqType))
+ { /* This particular client would like this particular stat */
+ penv->stats->data.requests[stuff->reqType]++;
+ }
+ }
+
+ if (pdata)
+ {
+ Xfree(pdata);
+ }
+ if (spdata)
+ {
+ Xfree(spdata);
+ }
+ if (ignore_grabs == True &&
+ (stuff->reqType == X_GrabServer || stuff->reqType == X_UngrabServer))
+ { /* doesn't want Grab's! Note: this is a "last configured" setting */
+#ifndef NO_NEW_XTRAP
+ int status;
+
+ if (stuff->reqType == X_GrabServer)
+ {
+ ClientList *pclient;
+
+ /* first call grab server procedure */
+ status = (*XETrapProcVector[stuff->reqType])(client);
+
+ /* then add XTrap controlling clients */
+ for (pclient = &io_clients; pclient; pclient = pclient->next)
+ if (pclient->client)
+ MakeClientGrabImpervious(pclient->client);
+ }
+ else
+ {
+ ClientList *pclient;
+
+ /* first drop XTrap controlling clients */
+ for (pclient = &io_clients; pclient; pclient = pclient->next)
+ if (pclient->client)
+ MakeClientGrabPervious(pclient->client);
+
+ /* then call ungrab server procedure */
+ status = (*XETrapProcVector[stuff->reqType])(client);
+ }
+ return status;
+#else /* NO_NEW_XTRAP */
+ return(Success);
+#endif /* NO_NEW_XTRAP */
+ }
+ else
+ {
+ return((*XETrapProcVector[stuff->reqType])(client));
+ }
+}
+/*
+ *
+ * DESCRIPTION:
+ *
+ * This routine intercepts input xEvents from the keyboard.
+ * if XETrapTrapActive, will write record to client(s)
+ * and then pass the event to the server iff not command
+ * key and gate is open. If it's a command key, then twiddle
+ * the gate state as required (optional, see below).
+ *
+ * This routine implements an optional user specified command key
+ * that can be used to close the input pipe into the server
+ * while a client command is generated. The keypress of the
+ * command key places this routine in command mode, the keyrelease
+ * exits command mode.
+ *
+ * A keypress of the command key followed by the
+ * optionally specified lock key will place this routine in continuous
+ * command mode until the command key and lock key are pressed again
+ * to exit command mode. In the locked state, the client interprets
+ * keystrokes as it wishes, as commands or as input to a prior command.
+ *
+ * Both mechanisms can be used alternately.
+ *
+ * IMPLICIT INPUTS :
+ *
+ * penv->cur.data_config_cmd_key :
+ * This is the keycode of the key that is used to stop
+ * and restart the transmission of intercepted input
+ * events to the server. If specified, the gate_state
+ * flag will be set or cleared depending on the state of
+ * the command_key.
+ *
+ * penv->cur.data_config_flags_data.XETrapCmdKeyMod:
+ * This is the value of the mode in which the command_key
+ * will operate. It currently has two values: MODIFIER and
+ * COMMAND_LOCK. MODIFIER mode clears gate_state on
+ * keypress, and sets gate_state on keyrelease.
+ * COMMAND_LOCK mode toggles gate_state on
+ * or off.
+ *
+ * gate_closed:
+ * A flag that is set/cleared in the xtrap_keyboard
+ * routine that indicates whether intercepted input
+ * should be passed to the server at any particular
+ * instance.
+ *
+ *
+ * next_key:
+ * This variable tracks the state of the next key to be
+ * pressed or released. It allows the checking of double
+ * presses of the command key to be sent to the server and
+ * keeps good state order when the command key is used.
+ *
+ * key_ignore:
+ * This variable indicates whether or not the specific
+ * key should be ignored for subsequent server processing.
+ *
+ */
+int XETrapKeyboard(xEvent *x_event, DevicePtr keybd, int count)
+{
+ register BYTE type = x_event->u.u.type;
+ register BYTE detail = x_event->u.u.detail;
+ XETrapEnv *penv;
+ ClientList *stc = &stats_clients;
+ ClientList *cmc = &cmd_clients;
+ int_function cur_func = XETrapKeyboard;
+
+#ifdef VERBOSE
+ if (count != 1L)
+ { /* We haven't coded for this situation yet! */
+ ErrorF("Warning! Event count != 1 (%d)\n", count);
+ }
+#endif
+ while (stc->next != NULL)
+ { /* increment appropriate stats bucket for each interested client */
+ stc = stc->next;
+ penv = XETenv[stc->client->index];
+ if (BitIsTrue(penv->cur.data_config_flags_event,type))
+ { /* This particular client would like this particular stat */
+ penv->stats->data.events[type]++;
+ }
+ }
+#ifndef VECTORED_EVENTS
+ /* We *only* StampAndMail command keys with vectored events since
+ * we get much more data by waiting till we get called in XETrapEventVector
+ */
+ XETrapStampAndMail(x_event); /* send to XTrap client if necessry */
+#endif
+ while (cmc->next != NULL)
+ {
+ cmc = cmc->next;
+ penv = XETenv[cmc->client->index];
+ key_ignore = False;
+ if (detail == penv->cur.data_config_cmd_key)
+ {
+ if (BitIsTrue(penv->cur.data_config_flags_data, XETrapCmdKeyMod))
+ {
+ switch (type)
+ {
+ case KeyPress:
+ if (next_key == XEKeyIsEcho)
+ {
+ break;
+ }
+ gate_closed = True;
+ next_key = XEKeyIsClear;
+ break;
+
+ case KeyRelease:
+ if (next_key == XEKeyIsEcho)
+ {
+ next_key = XEKeyIsClear;
+ break;
+ }
+ if (next_key == XEKeyIsClear)
+ {
+ next_key = XEKeyIsEcho;
+ }
+ else
+ { /* it's Other, so Clear it */
+ next_key = XEKeyIsClear;
+ }
+ gate_closed = False;
+ key_ignore = True;
+ break;
+
+ default: break;
+ }
+ }
+ else
+ {
+ switch (type)
+ {
+ case KeyPress:
+ if (next_key == XEKeyIsEcho)
+ {
+ gate_closed = False;
+ break;
+ }
+ /* Open gate on cmd key release */
+ if ((next_key == XEKeyIsOther) &&
+ gate_closed == True)
+ {
+ break;
+ }
+ gate_closed = True;
+ next_key = XEKeyIsClear;
+ break;
+
+ case KeyRelease:
+ if (next_key == XEKeyIsClear)
+ {
+ next_key = XEKeyIsEcho;
+ break;
+ }
+
+ if (next_key == XEKeyIsEcho)
+ {
+ next_key = XEKeyIsClear;
+ break;
+ }
+
+ gate_closed = False;
+ key_ignore = True;
+ next_key = XEKeyIsClear;
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ else
+ {
+ next_key = XEKeyIsOther;
+ }
+ }
+
+ /*
+ * If the gate to the server is open,
+ * and we are not ignoring a keyrelease,
+ * pass the event to the server for normal processing.
+ */
+#ifndef VECTORED_EVENTS
+ if ((gate_closed == False) && (key_ignore == False))
+ {
+ if (XETrapEventProcVector[type] != cur_func)
+ { /* to protect us from infinite loops */
+ (void)(*XETrapEventProcVector[type])(x_event,keybd,count);
+ }
+ else
+ {
+ (void)(*EventProcVector[type])(x_event,keybd,count);
+ }
+ }
+#else /* VECTORED_EVENTS */
+ if ((gate_closed == False) && (key_ignore == False))
+ { /* send event on to server to be trapped again in XETrapEventVector */
+ (void)(*keybd_process_inp)(x_event,keybd,count);
+ }
+ else
+ {
+ XETrapStampAndMail(x_event); /* send to XTrap client if necessry */
+ }
+#endif
+ key_ignore = False; /* reset for next time around */
+ return 0;
+}
+
+/*
+ * DESCRIPTION:
+ *
+ * This routine intercepts input xEvents from the pointer device
+ * and passes the input event back to the server for normal processing.
+ *
+ * This routine is sensitive to whether input is being passed
+ * up to the server or not. This state is set by the keyboard
+ * input routine.
+ *
+ *
+ */
+#ifndef VECTORED_EVENTS
+int XETrapPointer(xEvent *x_event, DevicePtr ptrdev, int count)
+{
+ XETrapEnv *penv;
+ ClientList *stc = &stats_clients;
+ int_function cur_func = XETrapPointer;
+
+#ifdef VERBOSE
+ if (count != 1L)
+ { /* We haven't coded for this situation yet! */
+ ErrorF("Warning! Event count != 1 (%d)\n", count);
+ }
+#endif
+ while (stc->next != NULL)
+ { /* increment appropriate stats bucket for each interested client */
+ stc = stc->next;
+ penv = XETenv[stc->client->index];
+ if (BitIsTrue(penv->cur.data_config_flags_event,x_event->u.u.type))
+ { /* This particular client would like this particular stat */
+ penv->stats->data.events[x_event->u.u.type]++;
+ }
+ }
+ XETrapStampAndMail(x_event); /* send to XTrap client if necessry */
+ /*
+ * If the gate to the server is open,
+ * pass the event up like nothing has happened.
+ */
+ if (gate_closed == False)
+ {
+ if (XETrapEventProcVector[x_event->u.u.type] != cur_func)
+ { /* to protect us from infinite loops */
+ (void)(*XETrapEventProcVector[x_event->u.u.type])(x_event,ptrdev,
+ count);
+ }
+ else
+ {
+ (void)(*EventProcVector[x_event->u.u.type])(x_event,ptrdev,count);
+ }
+ }
+ return 0;
+}
+#endif /* !VECTORED_EVENTS */
+
+
+/*
+ * DESCRIPTION:
+ *
+ * This routine determines whether it needs to send event data
+ * to the XTrap Client(s). If so, it timestamps it appropriately
+ * and writes out both the header and detail information.
+ *
+ */
+void XETrapStampAndMail(xEvent *x_event)
+{
+ XETrapDatum data;
+ register CARD32 size;
+ XETrapEnv *penv;
+ ClientList *ioc = &io_clients;
+
+ /* Currently, we're intercepting core events *before* most
+ * of the event information's filled in. Specifically, the
+ * only fields that are valid at this level are: type, detail,
+ * time, rootX, rootY, and state.
+ */
+ /* Loop through all clients wishing I/O */
+ while (ioc->next != NULL)
+ {
+ ioc = ioc->next;
+ penv = XETenv[ioc->client->index];
+ /* Do we have a valid fd? Do we care about this event? */
+ if (BitIsTrue(penv->cur.data_config_flags_event, x_event->u.u.type))
+ {
+ XETrapSetHeaderEvent(&(data.hdr));
+ data.hdr.win_x = data.hdr.win_y = -1L; /* Invalidate req draw */
+ data.hdr.screen = 0L; /* not till Events are vectored! */
+ data.hdr.client = 0L; /* not till Events are vectored! */
+ if (BitIsTrue(penv->cur.data_config_flags_data,
+ XETrapTimestamp))
+ {
+ data.hdr.timestamp = GetTimeInMillis();
+ }
+ size = data.hdr.count = XETrapMinPktSize; /* Always for evts */
+ penv->last_input_time = x_event->u.keyButtonPointer.time;
+ /* Copy the event information into our local memory */
+ (void)memcpy(&(data.u.event),x_event,sizeof(xEvent));
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension &&
+ (data.u.event.u.u.type == MotionNotify ||
+ data.u.event.u.u.type == ButtonPress ||
+ data.u.event.u.u.type == ButtonRelease ||
+ data.u.event.u.u.type == KeyPress ||
+ data.u.event.u.u.type == KeyRelease)) {
+ int scr = XineramaGetCursorScreen();
+ data.u.event.u.keyButtonPointer.rootX +=
+ panoramiXdataPtr[scr].x - panoramiXdataPtr[0].x;
+ data.u.event.u.keyButtonPointer.rootY +=
+ panoramiXdataPtr[scr].y - panoramiXdataPtr[0].y;
+ }
+#endif
+
+ if (penv->client->swapped)
+ { /*
+ * Notice that we don't swap the XTRAP EVENT information.
+ * This is done in the XETrapWriteXLib() routine.
+ */
+ xEvent ToEvent;
+ (*EventSwapVector[data.u.event.u.u.type & 0177])
+ (&data.u.event,&ToEvent);
+ (void)memcpy(&(data.u.event),&ToEvent,sizeof(ToEvent));
+ sXETrapHeader(&(data.hdr)); /* swap the XTrap Header */
+ }
+ /* From this point on, the contents of data is swapped and
+ * therefore we should not refer to it for information.
+ */
+ if (XETrapWriteXLib(penv, (BYTE *)&data, size) != size)
+ {
+ SendErrorToClient(penv->client,
+ XETrap_avail.data.major_opcode,
+ x_event->u.u.type, 0L, XETrapErrorBase + BadIO);
+ }
+ }
+ }
+ return;
+}
+#ifdef VECTORED_EVENTS
+int XETrapEventVector(ClientPtr client, xEvent *x_event)
+{
+ XETrapDatum data;
+ register CARD32 size;
+ XETrapEnv *penv;
+ ClientList *ioc = &io_clients;
+
+ /* Loop through all clients wishing I/O */
+ while (ioc->next != NULL)
+ {
+ ioc = ioc->next;
+ penv = XETenv[ioc->client->index];
+ /* Do we care about this event? */
+ if (BitIsTrue(penv->cur.data_config_flags_event, x_event->u.u.type))
+ {
+ XETrapSetHeaderEvent(&(data.hdr));
+ data.hdr.client = client->index;
+ data.hdr.win_x = data.hdr.win_y = -1L; /* Invalidate req draw */
+ if ((current_screen < 0L) || ((x_event->u.u.type >= KeyPress) &&
+ (x_event->u.u.type <= MotionNotify) &&
+ (!x_event->u.keyButtonPointer.sameScreen)))
+ { /* we've moved/warped to another screen */
+ WindowPtr root_win = GetCurrentRootWindow();
+ current_screen = root_win->drawable.pScreen->myNum;
+ }
+ data.hdr.screen = current_screen;
+ if (BitIsTrue(penv->cur.data_config_flags_data,
+ XETrapTimestamp))
+ {
+ data.hdr.timestamp = GetTimeInMillis();
+ }
+ size = data.hdr.count = XETrapMinPktSize; /* Always for evts */
+ penv->last_input_time = x_event->u.keyButtonPointer.time;
+ /* Copy the event information into our local memory */
+ (void)memcpy(&(data.u.event),x_event,sizeof(xEvent));
+
+ if (penv->client->swapped)
+ {
+ xEvent ToEvent;
+ (*EventSwapVector[data.u.event.u.u.type & 0177])
+ (&data.u.event,&ToEvent);
+ (void)memcpy(&(data.u.event),&ToEvent,sizeof(ToEvent));
+ sXETrapHeader(&(data.hdr)); /* swap the XTrap Header */
+ }
+ /* From this point on, the contents of pdata is swapped and
+ * therefore we should not refer to it for information.
+ */
+ if (XETrapWriteXLib(penv, (BYTE *)&data, size) != size)
+ {
+ SendErrorToClient(penv->client,
+ XETrap_avail.data.major_opcode,
+ x_event->u.u.type, 0L, XETrapErrorBase + BadIO);
+ }
+ }
+ }
+ return;
+}
+#endif /* VECTORED_EVENTS */
+void sReplyXTrapDispatch(ClientPtr client, int size, char *reply)
+{
+ register XETrapRepHdr *rep = (XETrapRepHdr *)reply;
+
+ switch(rep->detail)
+ {
+ case XETrap_GetAvailable:
+ {
+ xXTrapGetAvailReply lrep;
+ (void)memcpy((char *)&lrep,reply,sizeof(lrep));
+ sReplyXETrapGetAvail(client,size,(char *)&lrep);
+ }
+ break;
+ case XETrap_GetCurrent:
+ {
+ xXTrapGetCurReply lrep;
+ (void)memcpy((char *)&lrep,reply,sizeof(lrep));
+ sReplyXETrapGetCur(client,size,(char *)&lrep);
+ }
+ break;
+ case XETrap_GetStatistics:
+ {
+ xXTrapGetStatsReply lrep;
+ (void)memcpy((char *)&lrep,reply,sizeof(lrep));
+ sReplyXETrapGetStats(client,size,(char *)&lrep);
+ }
+ break;
+ case XETrap_GetVersion:
+ {
+ xXTrapGetVersReply lrep;
+ (void)memcpy((char *)&lrep,reply,sizeof(lrep));
+ sReplyXETrapGetVers(client,size,(char *)&lrep);
+ }
+ break;
+ case XETrap_GetLastInpTime:
+ {
+ xXTrapGetLITimReply lrep;
+ (void)memcpy((char *)&lrep,reply,sizeof(lrep));
+ sReplyXETrapGetLITim(client,size,(char *)&lrep);
+ }
+ break;
+ default:
+ SendErrorToClient(client,XETrap_avail.data.major_opcode,
+ rep->detail, 0L, BadImplementation);
+ break;
+ }
+ return;
+}
+
+/*
+ * XLib communications routines
+ */
+
+/*
+ * DESCRIPTION:
+ *
+ * This function performs the transport specific functions required
+ * for writing data back to an XTrap client over XLib. The trick is
+ * packaging the data into <=32 byte packets to conform to the sizeof
+ * an X Event. nbytes must be at least equal to XETrapMinPktSize
+ *
+ */
+int XETrapWriteXLib(XETrapEnv *penv, BYTE *data, CARD32 nbytes)
+{
+ CARD32 size, total = 0L;
+ xETrapDataEvent event;
+
+ /* Initialize the detail field to show the beginning of a datum */
+ event.detail = XETrapDataStart;
+ event.idx = 0L;
+
+ /* This loop could be optimized by not calling Write until after all
+ * of the events are packaged. However, this would require memory
+ * games, and may not therefore be a win.
+ */
+ while (nbytes > 0L)
+ { /* How many bytes can we send in this packet */
+ size = (nbytes > sz_EventData) ? sz_EventData : nbytes;
+
+ /* Initialize the event */
+ event.type = XETrapData + XETrap_avail.data.event_base;
+ event.sequenceNumber = penv->client->sequence;
+
+ /* Copy the data we are sending */
+ (void)memcpy(event.data,data,size);
+ if (size < sz_EventData)
+ (void)memset(event.data+size,0L,sz_EventData-size);
+ data += size;
+ nbytes -= size;
+ total += size;
+
+ /* Set the detail field to show the continuation of datum */
+ if (total != size)
+ { /* this is not the first one */
+ event.detail = (nbytes > 0) ? XETrapDataContinued : XETrapDataLast;
+ }
+
+ /* Send this part to the client */
+ WriteEventsToClient(penv->client, 1L, (xEvent *) &event);
+ event.idx++; /* Bump the index for the next event */
+ }
+ return(total);
+}
+
+/*----------------------------*
+ * Static Functions
+ *----------------------------*/
+
+static void update_protocol(xXTrapGetReq *reqptr, ClientPtr client)
+{
+ XETrapEnv *penv = XETenv[client->index];
+ /* update protocol number */
+ switch (reqptr->protocol)
+ {
+ /* known acceptable protocols */
+ case 31:
+ case XETrapProtocol:
+ penv->protocol = reqptr->protocol;
+ break;
+ /* all else */
+ default: /* stay backwards compatible */
+ penv->protocol = 31;
+ break;
+ }
+}
+
+/* Swap 2 functions. This is a function instead of a macro to help to keep
+ * lint from complaining about mixed types. It seems to work, but I would
+ * probably classify this as a hack.
+ */
+static void _SwapProc( register int (**f1)(), register int (**f2)())
+{
+ register int (*t1)() = *f1;
+ *f1 = *f2;
+ *f2 = t1;
+
+ return;
+}
+
+/*
+ * DESCRIPTION:
+ *
+ * This function swaps the byte order of fields within
+ * the XTrap Event Header. It assumes the data will be
+ * swapped by code in XETrapRequestVector().
+ *
+ */
+static void sXETrapEvent(xETrapDataEvent *from, xETrapDataEvent *to)
+{
+ to->type = from->type;
+ to->detail = from->detail;
+ cpswaps(from->sequenceNumber,to->sequenceNumber);
+ cpswapl(from->idx,to->idx);
+ /* Assumes that the data's already been swapped by XETrapRequestVector */
+ memcpy(to->data, from->data, SIZEOF(EventData));
+}
+
+/*
+ * DESCRIPTION:
+ *
+ * This function adds a node from an accelerator linked-list
+ * (either io_clients, stats_clients, or cmd_clients).
+ *
+ */
+static int add_accelerator_node(ClientPtr client, ClientList *accel)
+{
+ Bool found = False;
+ int status = Success;
+
+ while (accel->next != NULL)
+ {
+ if (accel->client == client)
+ {
+ found = True; /* Client's already known */
+ break;
+ }
+ else
+ {
+ accel = accel->next;
+ }
+ }
+ if (found == False)
+ {
+ if ((accel->next = (ClientList *)Xcalloc(sizeof(ClientList))) == NULL)
+ {
+ status = BadAlloc;
+ }
+ else
+ { /* fill in the node */
+ accel = accel->next;
+ accel->next = NULL;
+ accel->client = client;
+ }
+ }
+ return(status);
+}
+/*
+ * DESCRIPTION:
+ *
+ * This function removes a node from an accelerator linked-list
+ * (either io_clients, stats_clients, or cmd_clients).
+ *
+ */
+static void remove_accelerator_node(ClientPtr client, ClientList *accel)
+{
+ while (accel->next != NULL)
+ {
+ if (accel->next->client == client)
+ {
+ ClientList *tmp = accel->next->next;
+ Xfree(accel->next);
+ accel->next = tmp;
+ break;
+ }
+ else
+ {
+ accel = accel->next;
+ }
+ }
+
+ return;
+}
+
+#ifdef COLOR_REPLIES
+static void GetSendColorRep(ClientPtr client, xResourceReq *req)
+{ /* adapted from ProcAllocColor() in dispatch.c */
+ XETrapDatum data;
+ int retval;
+ XETrapEnv *penv = XETenv[client->index];
+ xAllocColorReply *crep = (xAllocColorReply *)&(data.u.reply);
+ xAllocColorReq *creq = (xAllocColorReq *)req;
+ ColormapPtr pmap = (ColormapPtr )LookupIDByType(creq->cmap, RT_COLORMAP);
+
+ /* Fill in the header fields */
+ data.hdr.count = XETrapMinPktSize; /* The color replies are 32 bytes */
+ XETrapSetHeaderReply(&(data.hdr));
+ /* Hack alert:
+ * We need to pass the "reply" type in the header since replies don't
+ * contain the id's themselves. However, we're not changing the
+ * protocol to support this until we decide exactly how we want to
+ * do *all* replies (e.g. not just ColorReplies). So until then, stow
+ * the reply id in the screen field which wouldn't normally be used in
+ * this context.
+ */
+ data.hdr.screen = req->reqType;
+ if (!pmap)
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, BadColor);
+ return;
+ }
+ crep->red = creq->red;
+ crep->green = creq->green;
+ crep->blue = creq->blue;
+ crep->pixel = 0;
+ if ((retval = AllocColor(pmap, &(crep->red), &(crep->green),
+ &(crep->blue), &(crep->pixel), client->index)) != Success)
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, retval);
+ return;
+ }
+ /* Swap data if necessary */
+ if (client->swapped)
+ {
+ INT32 n;
+ swaps(&(crep->red), n);
+ swaps(&(crep->green), n);
+ swaps(&(crep->blue), n);
+ swapl(&(crep->pixel), n);
+ }
+ /* Send data to client */
+ if (XETrapWriteXLib(penv, (BYTE *)&data, XETrapMinPktSize)
+ != XETrapMinPktSize)
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, XETrapErrorBase + BadIO);
+ }
+}
+
+static void GetSendNamedColorRep(ClientPtr client, xResourceReq *req)
+{ /* adapted from ProcAllocNamedColor() in dispatch.c */
+ XETrapDatum data;
+ XETrapEnv *penv = XETenv[client->index];
+ int retval;
+ xAllocNamedColorReply *nrep = (xAllocNamedColorReply *)&(data.u.reply);
+ xAllocNamedColorReq *nreq = (xAllocNamedColorReq *)req;
+ ColormapPtr pcmp = (ColormapPtr )LookupIDByType(nreq->cmap, RT_COLORMAP);
+
+ data.hdr.count = XETrapMinPktSize; /* The color replies are 32 bytes */
+ XETrapSetHeaderReply(&(data.hdr));
+ /* Hack alert:
+ * We need to pass the "reply" type in the header since replies don't
+ * contain the id's themselves. However, we're not changing the
+ * protocol to support this until we decide exactly how we want to
+ * do *all* replies (e.g. not just ColorReplies). So until then, stow
+ * the reply id in the screen field which wouldn't normally be used in
+ * this context.
+ */
+ data.hdr.screen = req->reqType;
+ if (!pcmp)
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, BadColor);
+ return;
+ }
+ if (!OsLookupColor(pcmp->pScreen->myNum, (char *)&nreq[1],
+ nreq->nbytes, &(nrep->exactRed), &(nrep->exactGreen),
+ &(nrep->exactBlue)))
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, BadName);
+ return;
+ }
+ nrep->screenRed = nrep->exactRed;
+ nrep->screenGreen = nrep->exactGreen;
+ nrep->screenBlue = nrep->exactBlue;
+ nrep->pixel = 0;
+ if ((retval = AllocColor(pcmp, &(nrep->screenRed),
+ &(nrep->screenGreen), &(nrep->screenBlue), &(nrep->pixel),
+ client->index)) != Success)
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, retval);
+ return;
+ }
+ /* Swap data if necessary */
+ if (client->swapped)
+ {
+ INT32 n;
+ swapl(&(nrep->pixel), n);
+ swaps(&(nrep->exactRed), n);
+ swaps(&(nrep->exactGreen), n);
+ swaps(&(nrep->exactBlue), n);
+ swaps(&(nrep->screenRed), n);
+ swaps(&(nrep->screenGreen), n);
+ swaps(&(nrep->screenBlue), n);
+ }
+
+ /* Send data to client */
+ if (XETrapWriteXLib(penv, (BYTE *)&data, XETrapMinPktSize)
+ != XETrapMinPktSize)
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, XETrapErrorBase + BadIO);
+ }
+}
+
+static void GetSendColorCellsRep(ClientPtr client, xResourceReq *req)
+{ /* adapted from ProcAllocColorCells() in dispatch.c */
+ int retval;
+ int npixels, nmasks;
+ unsigned long *ppixels, *pmasks;
+ long length;
+ XETrapDatum *data;
+ XETrapEnv *penv = XETenv[client->index];
+ xAllocColorCellsReply *crep;
+ xAllocColorCellsReq *creq = (xAllocColorCellsReq *)req;
+ ColormapPtr pmap = (ColormapPtr )LookupIDByType(creq->cmap, RT_COLORMAP);
+
+ if (!pmap)
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, BadColor);
+ return;
+ }
+ npixels = creq->colors;
+ if (!npixels)
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, BadValue);
+ return;
+ }
+ nmasks = creq->planes;
+ length = ((long)npixels + (long)nmasks) * sizeof(Pixel);
+ data = (XETrapDatum *)ALLOCATE_LOCAL(sizeof(XETrapDatum)+length);
+ if (!data)
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, BadAlloc);
+ return;
+ }
+ data->hdr.count = MIN(penv->cur.data_config_max_pkt_size,
+ sizeof(XETrapDatum)+length);
+ XETrapSetHeaderReply(&(data->hdr));
+ data->hdr.screen = req->reqType; /* hack! but necessary */
+ ppixels = (unsigned long *)((char *)data + sizeof(XETrapDatum));
+ pmasks = ppixels + npixels;
+ if ((retval = AllocColorCells(client->index, pmap, npixels,
+ nmasks, (Bool)creq->contiguous, ppixels, pmasks)) != Success)
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, retval);
+ DEALLOCATE_LOCAL(data);
+ return;
+ }
+ crep = (xAllocColorCellsReply *)&(data->u.reply);
+ crep->nPixels = npixels;
+ crep->nMasks = nmasks;
+ /* Swap data if necessary */
+ if (client->swapped)
+ {
+ INT32 n, i, *ptr;
+ ptr=(INT32 *)ppixels;
+ swaps(&(crep->nPixels), n);
+ swaps(&(crep->nMasks), n);
+ for (i=0; i<length; i++)
+ {
+ swapl(&(ptr[i]), n);
+ }
+ }
+ /* Send data to client */
+ if (XETrapWriteXLib(penv, (BYTE *)&data, data->hdr.count)
+ != data->hdr.count)
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, XETrapErrorBase + BadIO);
+ }
+ DEALLOCATE_LOCAL(data);
+}
+static void GetSendColorPlanesRep(ClientPtr client, xResourceReq *req)
+{ /* adapted from ProcAllocColorPlanes() in dispatch.c */
+ int retval;
+ int npixels, nmasks;
+ unsigned long *ppixels, *pmasks;
+ long length;
+ XETrapDatum *data;
+ XETrapEnv *penv = XETenv[client->index];
+ xAllocColorPlanesReply *crep;
+ xAllocColorPlanesReq *creq = (xAllocColorPlanesReq *)req;
+ ColormapPtr pmap = (ColormapPtr )LookupIDByType(creq->cmap, RT_COLORMAP);
+
+ if (!pmap)
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, BadColor);
+ return;
+ }
+ npixels = creq->colors;
+ if (!npixels)
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, BadValue);
+ return;
+ }
+ length = (long)npixels * sizeof(Pixel);
+ data = (XETrapDatum *)ALLOCATE_LOCAL(sizeof(XETrapDatum)+length);
+ if (!data)
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, BadAlloc);
+ return;
+ }
+ data->hdr.count = MIN(penv->cur.data_config_max_pkt_size,
+ sizeof(XETrapDatum)+length);
+ XETrapSetHeaderReply(&(data->hdr));
+ data->hdr.screen = req->reqType; /* hack! but necessary */
+ ppixels = (unsigned long *)((char *)data + sizeof(XETrapDatum));
+ crep = (xAllocColorPlanesReply *)&(data->u.reply);
+ if ((retval = AllocColorPlanes(client->index, pmap, npixels,
+ (int)creq->red, (int)creq->green, (int)creq->blue,
+ (int)creq->contiguous, ppixels, &(crep->redMask), &(crep->greenMask),
+ &(crep->blueMask))) != Success)
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, retval);
+ DEALLOCATE_LOCAL(data);
+ return;
+ }
+ crep->nPixels = npixels;
+ /* Swap data if necessary */
+ if (client->swapped)
+ {
+ INT32 n, i, *ptr;
+ ptr=(INT32 *)ppixels;
+ swaps(&(crep->nPixels), n);
+ swapl(&(crep->redMask), n);
+ swapl(&(crep->greenMask), n);
+ swapl(&(crep->blueMask), n);
+ for (i=0; i<length; i++)
+ {
+ swapl(&(ptr[i]), n);
+ }
+ }
+ /* Send data to client */
+ if (XETrapWriteXLib(penv, (BYTE *)&data, data->hdr.count)
+ != data->hdr.count)
+ {
+ SendErrorToClient(penv->client, XETrap_avail.data.major_opcode,
+ req->reqType, 0L, XETrapErrorBase + BadIO);
+ }
+ DEALLOCATE_LOCAL(data);
+}
+#endif /* COLOR_REPLIES */
diff --git a/nx-X11/programs/Xserver/XTrap/xtrapdiswp.c b/nx-X11/programs/Xserver/XTrap/xtrapdiswp.c
new file mode 100644
index 000000000..c43f6e332
--- /dev/null
+++ b/nx-X11/programs/Xserver/XTrap/xtrapdiswp.c
@@ -0,0 +1,1010 @@
+/* $XFree86$ */
+/****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991, 1992 by
+
+ Digital Equipment Corp., Maynard, MA
+
+X11R6 Changes Copyright (c) 1994 by Robert Chesler of Absol-Puter, Hudson, NH.
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL AND ABSOL-PUTER DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL DIGITAL OR ABSOL-PUTER BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+*****************************************************************************/
+/*
+ * ABSTRACT:
+ *
+ * This module is the device independent module responsible for all
+ * routines required for proper communication in a heterogeneous
+ * networking environment (i.e. client & server on different endian
+ * machines). The bulk of this module is patterned after X11/R4's
+ * server/dix/swapreq.c ; however, they infact swap fields
+ * in the exact opposite order since XTrap requires "unswapped" data
+ * to become "swapped" before sending it to a "swapped" client.
+ *
+ * CONTRIBUTORS:
+ *
+ * Ken Miller
+ * Marc Evans
+ *
+ * CHANGES:
+ *
+ * Robert Chesler - added client arg for X11R6 port in many spots
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include <X11/Xprotostr.h>
+#include <X11/extensions/xtrapdi.h>
+#include "input.h" /* Server DevicePtr definitions */
+#include "misc.h"
+#include "dixstruct.h"
+#ifdef PC
+# include "extnsist.h"
+#else
+# include "extnsionst.h" /* Server ExtensionEntry definitions */
+#endif
+# include "swapreq.h" /* Server SwapColorItem definition */
+#include <X11/extensions/xtrapddmi.h>
+#include <X11/extensions/xtrapproto.h>
+
+/* In-coming XTrap requests needing to be swapped to native format */
+
+int sXETrapReset(xXTrapReq *request, ClientPtr client)
+{
+ register char n;
+ swaps(&(request->length),n);
+ return(XETrapReset(request,client));
+}
+
+int sXETrapGetAvailable(xXTrapGetReq *request, ClientPtr client)
+{
+ register char n;
+ swaps(&(request->length),n);
+ swaps(&(request->protocol),n);
+ return(XETrapGetAvailable(request,client));
+}
+
+int sXETrapConfig(xXTrapConfigReq *request, ClientPtr client)
+{
+ register char n;
+ swaps(&(request->length),n);
+ swaps(&(request->config_max_pkt_size),n);
+ return(XETrapConfig(request,client));
+}
+
+int sXETrapStartTrap(xXTrapReq *request, ClientPtr client)
+{
+ register char n;
+ swaps(&(request->length),n);
+ return(XETrapStartTrap(request,client));
+}
+
+int sXETrapStopTrap(xXTrapReq *request, ClientPtr client)
+{
+ register char n;
+ swaps(&(request->length),n);
+ return(XETrapStopTrap(request,client));
+}
+
+int sXETrapGetCurrent(xXTrapReq *request, ClientPtr client)
+{
+ register char n;
+ swaps(&(request->length),n);
+ return(XETrapGetCurrent(request,client));
+}
+
+int sXETrapGetStatistics(xXTrapReq *request, ClientPtr client)
+{
+ register char n;
+ swaps(&(request->length),n);
+ return(XETrapGetStatistics(request,client));
+}
+
+#ifndef _XINPUT
+int sXETrapSimulateXEvent(xXTrapInputReq *request, ClientPtr client)
+{
+ register char n;
+ swaps(&(request->input.x),n);
+ swaps(&(request->input.y),n);
+ return(XETrapSimulateXEvent(request,client));
+}
+#endif
+
+int sXETrapGetVersion(xXTrapGetReq *request, ClientPtr client)
+{
+ register char n;
+ swaps(&(request->length),n);
+ swaps(&(request->protocol),n);
+ return(XETrapGetVersion(request,client));
+}
+
+int sXETrapGetLastInpTime(xXTrapReq *request, ClientPtr client)
+{
+ register char n;
+ swaps(&(request->length),n);
+ return(XETrapGetLastInpTime(request,client));
+}
+
+
+/* Out-going XTrap replies needing to be swapped *from* native format */
+
+void sReplyXETrapGetAvail(ClientPtr client, int size, char *reply)
+{
+ xXTrapGetAvailReply *rep = (xXTrapGetAvailReply *)reply;
+ register char n;
+ swaps(&(rep->hdr.sequenceNumber),n);
+ swapl(&(rep->hdr.length),n);
+ swapl(&(rep->data.pf_ident),n);
+ swaps(&(rep->data.xtrap_release),n);
+ swaps(&(rep->data.xtrap_version),n);
+ swaps(&(rep->data.xtrap_revision),n);
+ swaps(&(rep->data.max_pkt_size),n);
+ swapl(&(rep->data.major_opcode),n);
+ swapl(&(rep->data.event_base),n);
+ swaps(&(rep->data.cur_x),n);
+ swaps(&(rep->data.cur_y),n);
+ (void)WriteToClient(client,size,reply);
+ return;
+}
+void sReplyXETrapGetVers(ClientPtr client, int size, char *reply)
+{
+ xXTrapGetVersReply *rep = (xXTrapGetVersReply *)reply;
+ register char n;
+ swaps(&(rep->hdr.sequenceNumber),n);
+ swapl(&(rep->hdr.length),n);
+ swaps(&(rep->data.xtrap_release),n);
+ swaps(&(rep->data.xtrap_version),n);
+ swaps(&(rep->data.xtrap_revision),n);
+ (void)WriteToClient(client,size,reply);
+ return;
+}
+void sReplyXETrapGetLITim(ClientPtr client, int size, char *reply)
+{
+ xXTrapGetLITimReply *rep = (xXTrapGetLITimReply *)reply;
+ register char n;
+ swaps(&(rep->hdr.sequenceNumber),n);
+ swapl(&(rep->hdr.length),n);
+ swapl(&(rep->data_last_time),n);
+ (void)WriteToClient(client,size,reply);
+ return;
+}
+void sReplyXETrapGetCur(ClientPtr client, int size, char *reply)
+{
+ xXTrapGetCurReply *rep = (xXTrapGetCurReply *)reply;
+ register char n;
+ swaps(&(rep->hdr.sequenceNumber),n);
+ swapl(&(rep->hdr.length),n);
+ swaps(&(rep->data_config_max_pkt_size),n);
+ (void)WriteToClient(client,size,reply);
+ return;
+}
+void sReplyXETrapGetStats(ClientPtr client, int size, char *reply)
+{
+ xXTrapGetStatsReply *rep = (xXTrapGetStatsReply *)reply;
+ register char n;
+ register int i;
+ long *p;
+
+ swaps(&(rep->sequenceNumber),n);
+ swapl(&(rep->length),n);
+ for (i=0L, p = (long *)rep->data.requests; i<256L; i++, p++)
+ {
+ swapl(p,n);
+ }
+ for (i=0L, p = (long *)rep->data.events; i<XETrapCoreEvents; i++, p++)
+ {
+ swapl(p,n);
+ }
+ (void)WriteToClient(client,size,reply);
+ return;
+}
+
+/* Out-going XTrap I/O header needing to be swapped *from* native format */
+
+void sXETrapHeader(XETrapHeader *hdr)
+{
+ register char n;
+
+ swapl(&(hdr->count), n);
+ swapl(&(hdr->timestamp), n);
+ swaps(&(hdr->win_x), n);
+ swaps(&(hdr->win_y), n);
+ swaps(&(hdr->client), n);
+}
+
+ /* Out-going requests needing to be swapped *from* native format
+ * aka swapreq.c "equivalents"
+ */
+
+/* The following is used for all requests that have
+ no fields to be swapped (except "length") */
+void XETSwSimpleReq(register xReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+}
+
+/* The following is used for all requests that have
+ only a single 32-bit field to be swapped, coming
+ right after the "length" field */
+
+void XETSwResourceReq(register xResourceReq *data)
+{
+ register char n;
+
+ swaps(&(data->length), n);
+ swapl(&(data->id), n);
+}
+
+void XETSwCreateWindow(register xCreateWindowReq *data,ClientPtr client)
+{
+ register char n;
+
+ swapl(&(data->wid), n);
+ swapl(&(data->parent), n);
+ swaps(&(data->x), n);
+ swaps(&(data->y), n);
+ swaps(&(data->width), n);
+ swaps(&(data->height), n);
+ swaps(&(data->borderWidth), n);
+ swaps(&(data->class), n);
+ swapl(&(data->visual), n);
+ swapl(&(data->mask), n);
+ SwapRestL(data);
+ swaps(&(data->length), n);
+}
+
+void XETSwChangeWindowAttributes(register xChangeWindowAttributesReq *data,
+ClientPtr client)
+{
+ register char n;
+
+ swapl(&(data->window), n);
+ swapl(&(data->valueMask), n);
+ SwapRestL(data);
+ swaps(&(data->length), n);
+}
+
+void XETSwReparentWindow(register xReparentWindowReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->window), n);
+ swapl(&(data->parent), n);
+ swaps(&(data->x), n);
+ swaps(&(data->y), n);
+}
+
+void XETSwConfigureWindow(xConfigureWindowReq *data, ClientPtr client)
+{
+ register char n;
+ swapl(&(data->window), n);
+ swaps(&(data->mask), n);
+ SwapRestL(data);
+ swaps(&(data->length), n);
+}
+
+
+void XETSwInternAtom(register xInternAtomReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swaps(&(data->nbytes), n);
+}
+
+void XETSwChangeProperty(register xChangePropertyReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->window), n);
+ swapl(&(data->property), n);
+ swapl(&(data->type), n);
+ switch ( data->format ) {
+ case 8L : break;
+ case 16L:
+ SwapShorts((short *)(data + 1), data->nUnits);
+ break;
+ case 32L:
+ SwapLongs((CARD32 *)(data + 1), data->nUnits);
+ break;
+ }
+ swapl(&(data->nUnits), n);
+}
+
+void XETSwDeleteProperty(register xDeletePropertyReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->window), n);
+ swapl(&(data->property), n);
+
+}
+void XETSwGetProperty(register xGetPropertyReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->window), n);
+ swapl(&(data->property), n);
+ swapl(&(data->type), n);
+ swapl(&(data->longOffset), n);
+ swapl(&(data->longLength), n);
+}
+
+void XETSwSetSelectionOwner(register xSetSelectionOwnerReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->window), n);
+ swapl(&(data->selection), n);
+ swapl(&(data->time), n);
+}
+
+void XETSwConvertSelection(register xConvertSelectionReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->requestor), n);
+ swapl(&(data->selection), n);
+ swapl(&(data->target), n);
+ swapl(&(data->property), n);
+ swapl(&(data->time), n);
+}
+
+void XETSwSendEvent(register xSendEventReq *data)
+{
+ register char n;
+ xEvent eventT;
+ void (*proc)();
+ swapl(&(data->destination), n);
+ swapl(&(data->eventMask), n);
+
+ /* Swap event */
+ proc = EventSwapVector[data->event.u.u.type & 0177];
+ if (!proc || (int (*)()) proc == (int (*)()) NotImplemented)
+ (*proc)(&(data->event), &eventT);
+ data->event = eventT;
+ swaps(&(data->length), n);
+}
+
+void XETSwGrabPointer(register xGrabPointerReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->grabWindow), n);
+ swaps(&(data->eventMask), n);
+ swapl(&(data->confineTo), n);
+ swapl(&(data->cursor), n);
+ swapl(&(data->time), n);
+}
+
+void XETSwGrabButton(register xGrabButtonReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->grabWindow), n);
+ swaps(&(data->eventMask), n);
+ swapl(&(data->confineTo), n);
+ swapl(&(data->cursor), n);
+ swaps(&(data->modifiers), n);
+}
+
+void XETSwUngrabButton(register xUngrabButtonReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->grabWindow), n);
+ swaps(&(data->modifiers), n);
+}
+
+void XETSwChangeActivePointerGrab(register xChangeActivePointerGrabReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->cursor), n);
+ swapl(&(data->time), n);
+ swaps(&(data->eventMask), n);
+}
+
+void XETSwGrabKeyboard(register xGrabKeyboardReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->grabWindow), n);
+ swapl(&(data->time), n);
+}
+
+void XETSwGrabKey(register xGrabKeyReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->grabWindow), n);
+ swaps(&(data->modifiers), n);
+}
+
+void XETSwUngrabKey(register xUngrabKeyReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->grabWindow), n);
+ swaps(&(data->modifiers), n);
+}
+
+void XETSwGetMotionEvents(register xGetMotionEventsReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->window), n);
+ swapl(&(data->start), n);
+ swapl(&(data->stop), n);
+}
+
+void XETSwTranslateCoords(register xTranslateCoordsReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->srcWid), n);
+ swapl(&(data->dstWid), n);
+ swaps(&(data->srcX), n);
+ swaps(&(data->srcY), n);
+}
+
+void XETSwWarpPointer(register xWarpPointerReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->srcWid), n);
+ swapl(&(data->dstWid), n);
+ swaps(&(data->srcX), n);
+ swaps(&(data->srcY), n);
+ swaps(&(data->srcWidth), n);
+ swaps(&(data->srcHeight), n);
+ swaps(&(data->dstX), n);
+ swaps(&(data->dstY), n);
+}
+
+void XETSwSetInputFocus(register xSetInputFocusReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->focus), n);
+ swapl(&(data->time), n);
+}
+
+void XETSwOpenFont(register xOpenFontReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->fid), n);
+ swaps(&(data->nbytes), n);
+}
+
+void XETSwListFonts(register xListFontsReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swaps(&(data->maxNames), n);
+ swaps(&(data->nbytes), n);
+}
+
+void XETSwListFontsWithInfo(register xListFontsWithInfoReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swaps(&(data->maxNames), n);
+ swaps(&(data->nbytes), n);
+}
+
+void XETSwSetFontPath(register xSetFontPathReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swaps(&(data->nFonts), n);
+}
+
+void XETSwCreatePixmap(register xCreatePixmapReq *data)
+{
+ register char n;
+
+ swaps(&(data->length), n);
+ swapl(&(data->pid), n);
+ swapl(&(data->drawable), n);
+ swaps(&(data->width), n);
+ swaps(&(data->height), n);
+}
+
+void XETSwCreateGC(register xCreateGCReq *data, ClientPtr client)
+{
+ register char n;
+ swapl(&(data->gc), n);
+ swapl(&(data->drawable), n);
+ swapl(&(data->mask), n);
+ SwapRestL(data);
+ swaps(&(data->length), n);
+}
+
+void XETSwChangeGC(register xChangeGCReq *data, ClientPtr client)
+{
+ register char n;
+ swapl(&(data->gc), n);
+ swapl(&(data->mask), n);
+ SwapRestL(data);
+ swaps(&(data->length), n);
+}
+
+void XETSwCopyGC(register xCopyGCReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->srcGC), n);
+ swapl(&(data->dstGC), n);
+ swapl(&(data->mask), n);
+}
+
+void XETSwSetDashes(register xSetDashesReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->gc), n);
+ swaps(&(data->dashOffset), n);
+ swaps(&(data->nDashes), n);
+}
+
+void XETSwSetClipRectangles(register xSetClipRectanglesReq *data, ClientPtr
+client)
+{
+ register char n;
+ swapl(&(data->gc), n);
+ swaps(&(data->xOrigin), n);
+ swaps(&(data->yOrigin), n);
+ SwapRestS(data);
+ swaps(&(data->length), n);
+}
+
+void XETSwClearToBackground(register xClearAreaReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->window), n);
+ swaps(&(data->x), n);
+ swaps(&(data->y), n);
+ swaps(&(data->width), n);
+ swaps(&(data->height), n);
+}
+
+void XETSwCopyArea(register xCopyAreaReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->srcDrawable), n);
+ swapl(&(data->dstDrawable), n);
+ swapl(&(data->gc), n);
+ swaps(&(data->srcX), n);
+ swaps(&(data->srcY), n);
+ swaps(&(data->dstX), n);
+ swaps(&(data->dstY), n);
+ swaps(&(data->width), n);
+ swaps(&(data->height), n);
+}
+
+void XETSwCopyPlane(register xCopyPlaneReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->srcDrawable), n);
+ swapl(&(data->dstDrawable), n);
+ swapl(&(data->gc), n);
+ swaps(&(data->srcX), n);
+ swaps(&(data->srcY), n);
+ swaps(&(data->dstX), n);
+ swaps(&(data->dstY), n);
+ swaps(&(data->width), n);
+ swaps(&(data->height), n);
+ swapl(&(data->bitPlane), n);
+}
+
+/* The following routine is used for all Poly drawing requests
+ (except FillPoly, which uses a different request format) */
+void XETSwPoly(register xPolyPointReq *data, ClientPtr client)
+{
+ register char n;
+
+ swapl(&(data->drawable), n);
+ swapl(&(data->gc), n);
+ SwapRestS(data);
+ swaps(&(data->length), n);
+}
+ /* cannot use XETSwPoly for this one, because xFillPolyReq
+ * is longer than xPolyPointReq, and we don't want to swap
+ * the difference as shorts!
+ */
+void XETSwFillPoly(register xFillPolyReq *data, ClientPtr client)
+{
+ register char n;
+
+ swapl(&(data->drawable), n);
+ swapl(&(data->gc), n);
+ SwapRestS(data);
+ swaps(&(data->length), n);
+}
+
+void XETSwPutImage(register xPutImageReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->drawable), n);
+ swapl(&(data->gc), n);
+ swaps(&(data->width), n);
+ swaps(&(data->height), n);
+ swaps(&(data->dstX), n);
+ swaps(&(data->dstY), n);
+ /* Image should already be swapped */
+}
+
+void XETSwGetImage(register xGetImageReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->drawable), n);
+ swaps(&(data->x), n);
+ swaps(&(data->y), n);
+ swaps(&(data->width), n);
+ swaps(&(data->height), n);
+ swapl(&(data->planeMask), n);
+}
+
+/* ProcPolyText used for both PolyText8 and PolyText16 */
+
+void XETSwPolyText(register xPolyTextReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->drawable), n);
+ swapl(&(data->gc), n);
+ swaps(&(data->x), n);
+ swaps(&(data->y), n);
+}
+
+/* ProcImageText used for both ImageText8 and ImageText16 */
+
+void XETSwImageText(register xImageTextReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->drawable), n);
+ swapl(&(data->gc), n);
+ swaps(&(data->x), n);
+ swaps(&(data->y), n);
+}
+
+void XETSwCreateColormap(register xCreateColormapReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->mid), n);
+ swapl(&(data->window), n);
+ swapl(&(data->visual), n);
+}
+
+
+void XETSwCopyColormapAndFree(register xCopyColormapAndFreeReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->mid), n);
+ swapl(&(data->srcCmap), n);
+
+}
+
+void XETSwAllocColor (register xAllocColorReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->cmap), n);
+ swaps(&(data->red), n);
+ swaps(&(data->green), n);
+ swaps(&(data->blue), n);
+}
+
+void XETSwAllocNamedColor (register xAllocNamedColorReq *data)
+{
+ register char n;
+
+ swaps(&(data->length), n);
+ swapl(&(data->cmap), n);
+ swaps(&(data->nbytes), n);
+}
+
+void XETSwAllocColorCells (register xAllocColorCellsReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->cmap), n);
+ swaps(&(data->colors), n);
+ swaps(&(data->planes), n);
+}
+
+void XETSwAllocColorPlanes(register xAllocColorPlanesReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->cmap), n);
+ swaps(&(data->colors), n);
+ swaps(&(data->red), n);
+ swaps(&(data->green), n);
+ swaps(&(data->blue), n);
+}
+
+void XETSwFreeColors (register xFreeColorsReq *data, ClientPtr
+client)
+{
+ register char n;
+ swapl(&(data->cmap), n);
+ swapl(&(data->planeMask), n);
+ SwapRestL(data);
+ swaps(&(data->length), n);
+
+}
+
+void XETSwStoreColors (register xStoreColorsReq *data,ClientPtr
+client)
+{
+ register char n;
+ unsigned long count;
+ xColorItem *pItem;
+
+ swapl(&(data->cmap), n);
+ pItem = (xColorItem *) &(data[1]);
+ for(count = LengthRestB(data)/sizeof(xColorItem); count != 0; count--)
+ SwapColorItem(pItem++);
+ swaps(&(data->length), n);
+}
+
+void XETSwStoreNamedColor (register xStoreNamedColorReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->cmap), n);
+ swapl(&(data->pixel), n);
+ swaps(&(data->nbytes), n);
+}
+
+void XETSwQueryColors(register xQueryColorsReq *data, ClientPtr client)
+{
+ register char n;
+ swapl(&(data->cmap), n);
+ SwapRestL(data);
+ swaps(&(data->length), n);
+}
+
+void XETSwLookupColor(register xLookupColorReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->cmap), n);
+ swaps(&(data->nbytes), n);
+}
+
+void XETSwCreateCursor(register xCreateCursorReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->cid), n);
+ swapl(&(data->source), n);
+ swapl(&(data->mask), n);
+ swaps(&(data->foreRed), n);
+ swaps(&(data->foreGreen), n);
+ swaps(&(data->foreBlue), n);
+ swaps(&(data->backRed), n);
+ swaps(&(data->backGreen), n);
+ swaps(&(data->backBlue), n);
+ swaps(&(data->x), n);
+ swaps(&(data->y), n);
+}
+
+void XETSwCreateGlyphCursor(register xCreateGlyphCursorReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->cid), n);
+ swapl(&(data->source), n);
+ swapl(&(data->mask), n);
+ swaps(&(data->sourceChar), n);
+ swaps(&(data->maskChar), n);
+ swaps(&(data->foreRed), n);
+ swaps(&(data->foreGreen), n);
+ swaps(&(data->foreBlue), n);
+ swaps(&(data->backRed), n);
+ swaps(&(data->backGreen), n);
+ swaps(&(data->backBlue), n);
+}
+
+
+void XETSwRecolorCursor(register xRecolorCursorReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->cursor), n);
+ swaps(&(data->foreRed), n);
+ swaps(&(data->foreGreen), n);
+ swaps(&(data->foreBlue), n);
+ swaps(&(data->backRed), n);
+ swaps(&(data->backGreen), n);
+ swaps(&(data->backBlue), n);
+}
+
+void XETSwQueryBestSize (register xQueryBestSizeReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swapl(&(data->drawable), n);
+ swaps(&(data->width), n);
+ swaps(&(data->height), n);
+
+}
+
+void XETSwQueryExtension (register xQueryExtensionReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swaps(&(data->nbytes), n);
+}
+
+void XETSwChangeKeyboardMapping (register xChangeKeyboardMappingReq *data)
+{
+ register char n;
+ register long *p;
+ register int i, count;
+
+ swaps(&(data->length), n);
+ p = (long *)&(data[1]);
+ count = data->keyCodes * data->keySymsPerKeyCode;
+ for(i = 0; i < count; i++)
+ {
+ swapl(p, n);
+ p++;
+ }
+}
+
+
+void XETSwChangeKeyboardControl (register xChangeKeyboardControlReq *data,
+ ClientPtr client)
+{
+ register char n;
+ swapl(&(data->mask), n);
+ SwapRestL(data);
+ swaps(&(data->length), n);
+}
+
+void XETSwChangePointerControl (register xChangePointerControlReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swaps(&(data->accelNum), n);
+ swaps(&(data->accelDenum), n);
+ swaps(&(data->threshold), n);
+}
+
+
+void XETSwSetScreenSaver (register xSetScreenSaverReq *data)
+{
+ register char n;
+ swaps(&(data->length), n);
+ swaps(&(data->timeout), n);
+ swaps(&(data->interval), n);
+}
+
+void XETSwChangeHosts(register xChangeHostsReq *data)
+{
+ register char n;
+
+ swaps(&(data->length), n);
+ swaps(&(data->hostLength), n);
+
+}
+void XETSwRotateProperties(register xRotatePropertiesReq *data, ClientPtr client)
+{
+ register char n;
+ swapl(&(data->window), n);
+ swaps(&(data->nAtoms), n);
+ swaps(&(data->nPositions), n);
+ SwapRestL(data);
+ swaps(&(data->length), n);
+}
+
+/*ARGSUSED*/
+void XETSwNoOperation(xReq *data)
+{
+ /* noop -- don't do anything */
+}
+
+/* Byte swap a list of longs */
+#if defined vms && !defined MITR5
+#ifndef LINKED_IN
+void SwapLongs ( register long *list, register unsigned long count)
+{
+ register char n;
+
+ while (count >= 8) {
+ swapl(list+0, n);
+ swapl(list+1, n);
+ swapl(list+2, n);
+ swapl(list+3, n);
+ swapl(list+4, n);
+ swapl(list+5, n);
+ swapl(list+6, n);
+ swapl(list+7, n);
+ list += 8;
+ count -= 8;
+ }
+ if (count != 0) {
+ do {
+ swapl(list, n);
+ list++;
+ } while (--count != 0);
+ }
+}
+
+/* Byte swap a list of shorts */
+
+void SwapShorts (register short *list, register unsigned long count)
+{
+ register char n;
+
+ while (count >= 16) {
+ swaps(list+0, n);
+ swaps(list+1, n);
+ swaps(list+2, n);
+ swaps(list+3, n);
+ swaps(list+4, n);
+ swaps(list+5, n);
+ swaps(list+6, n);
+ swaps(list+7, n);
+ swaps(list+8, n);
+ swaps(list+9, n);
+ swaps(list+10, n);
+ swaps(list+11, n);
+ swaps(list+12, n);
+ swaps(list+13, n);
+ swaps(list+14, n);
+ swaps(list+15, n);
+ list += 16;
+ count -= 16;
+ }
+ if (count != 0) {
+ do {
+ swaps(list, n);
+ list++;
+ } while (--count != 0);
+ }
+}
+
+SwapColorItem(xColorItem *pItem)
+{
+ register char n;
+ swapl(&pItem->pixel, n);
+ swaps(&pItem->red, n);
+ swaps(&pItem->green, n);
+ swaps(&pItem->blue, n);
+}
+#endif /* LINKED_IN */
+#endif /* vms */
diff --git a/nx-X11/programs/Xserver/XTrap/xtrapditbl.c b/nx-X11/programs/Xserver/XTrap/xtrapditbl.c
new file mode 100644
index 000000000..a9ceddb3d
--- /dev/null
+++ b/nx-X11/programs/Xserver/XTrap/xtrapditbl.c
@@ -0,0 +1,242 @@
+/* $XFree86$ */
+/****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991 by Digital Equipment Corp., Maynard, MA
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*****************************************************************************/
+/*
+ * ABSTRACT:
+ *
+ * This module is contains Vector tables used for swapping and general
+ * dispatch by the XTrap server extension.
+ *
+ * CONTRIBUTORS:
+ *
+ * Ken Miller
+ * Marc Evans
+ *
+ */
+
+/*-----------------*
+ * Include Files *
+ *-----------------*/
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include <X11/Xprotostr.h>
+#include <X11/extensions/xtrapdi.h>
+#include "input.h" /* Server DevicePtr definitions */
+#include "misc.h"
+#include "dixstruct.h"
+#ifdef PC
+# include "extnsist.h"
+#else
+# include "extnsionst.h" /* Server ExtensionEntry definitions */
+#endif
+#include <X11/extensions/xtrapddmi.h>
+#include <X11/extensions/xtrapproto.h>
+
+globaldef void_function XETSwProcVector[256L] =
+{
+ (void_function)ProcBadRequest,
+ XETSwCreateWindow,
+ XETSwChangeWindowAttributes,
+ XETSwResourceReq, /* GetWindowAttributes */
+ XETSwResourceReq, /* DestroyWindow */
+ XETSwResourceReq, /* 5 DestroySubwindows */
+ XETSwResourceReq, /* XETSwChangeSaveSet, */
+ XETSwReparentWindow,
+ XETSwResourceReq, /* MapWindow */
+ XETSwResourceReq, /* MapSubwindows */
+ XETSwResourceReq, /* 10 UnmapWindow */
+ XETSwResourceReq, /* UnmapSubwindows */
+ XETSwConfigureWindow,
+ XETSwResourceReq, /* XETSwCirculateWindow, */
+ XETSwResourceReq, /* GetGeometry */
+ XETSwResourceReq, /* 15 QueryTree */
+ XETSwInternAtom,
+ XETSwResourceReq, /* XETSwGetAtomName, */
+ XETSwChangeProperty,
+ XETSwDeleteProperty,
+ XETSwGetProperty, /* 20 */
+ XETSwResourceReq, /* XETSwListProperties, */
+ XETSwSetSelectionOwner,
+ XETSwResourceReq, /* XETSwGetSelectionOwner, */
+ XETSwConvertSelection,
+ XETSwSendEvent, /* 25 */
+ XETSwGrabPointer,
+ XETSwResourceReq, /* XETSwUngrabPointer, */
+ XETSwGrabButton,
+ XETSwUngrabButton,
+ XETSwChangeActivePointerGrab, /* 30 */
+ XETSwGrabKeyboard,
+ XETSwResourceReq, /* XETSwUngrabKeyboard, */
+ XETSwGrabKey,
+ XETSwUngrabKey,
+ XETSwResourceReq, /* 35 XETSwAllowEvents, */
+ XETSwSimpleReq, /* XETSwGrabServer, */
+ XETSwSimpleReq, /* XETSwUngrabServer, */
+ XETSwResourceReq, /* XETSwQueryPointer, */
+ XETSwGetMotionEvents,
+ XETSwTranslateCoords, /*40 */
+ XETSwWarpPointer,
+ XETSwSetInputFocus,
+ XETSwSimpleReq, /* XETSwGetInputFocus, */
+ XETSwSimpleReq, /* QueryKeymap, */
+ XETSwOpenFont, /* 45 */
+ XETSwResourceReq, /* XETSwCloseFont, */
+ XETSwResourceReq, /* XETSwQueryFont, */
+ XETSwResourceReq, /* XETSwQueryTextExtents, */
+ XETSwListFonts,
+ XETSwListFontsWithInfo, /* 50 */
+ XETSwSetFontPath,
+ XETSwSimpleReq, /* GetFontPath, */
+ XETSwCreatePixmap,
+ XETSwResourceReq, /* XETSwFreePixmap, */
+ XETSwCreateGC, /* 55 */
+ XETSwChangeGC,
+ XETSwCopyGC,
+ XETSwSetDashes,
+ XETSwSetClipRectangles,
+ XETSwResourceReq, /* 60 XETSwFreeGC, */
+ XETSwClearToBackground,
+ XETSwCopyArea,
+ XETSwCopyPlane,
+ XETSwPoly, /* PolyPoint, */
+ XETSwPoly, /* 65 PolyLine */
+ XETSwPoly, /* PolySegment, */
+ XETSwPoly, /* PolyRectangle, */
+ XETSwPoly, /* PolyArc, */
+ XETSwFillPoly,
+ XETSwPoly, /* 70 PolyFillRectangle */
+ XETSwPoly, /* PolyFillArc, */
+ XETSwPutImage,
+ XETSwGetImage,
+ XETSwPolyText,
+ XETSwPolyText, /* 75 */
+ XETSwImageText,
+ XETSwImageText,
+ XETSwCreateColormap,
+ XETSwResourceReq, /* XETSwFreeColormap, */
+ XETSwCopyColormapAndFree, /* 80 */
+ XETSwResourceReq, /* XETSwInstallColormap, */
+ XETSwResourceReq, /* XETSwUninstallColormap, */
+ XETSwResourceReq, /* XETSwListInstalledColormaps, */
+ XETSwAllocColor,
+ XETSwAllocNamedColor, /* 85 */
+ XETSwAllocColorCells,
+ XETSwAllocColorPlanes,
+ XETSwFreeColors,
+ XETSwStoreColors,
+ XETSwStoreNamedColor, /* 90 */
+ XETSwQueryColors,
+ XETSwLookupColor,
+ XETSwCreateCursor,
+ XETSwCreateGlyphCursor,
+ XETSwResourceReq, /* 95 XETSwFreeCursor, */
+ XETSwRecolorCursor,
+ XETSwQueryBestSize,
+ XETSwQueryExtension,
+ XETSwSimpleReq, /* ListExtensions, */
+ XETSwChangeKeyboardMapping, /* 100 */
+ XETSwSimpleReq, /* GetKeyboardMapping, */
+ XETSwChangeKeyboardControl,
+ XETSwSimpleReq, /* GetKeyboardControl, */
+ XETSwSimpleReq, /* Bell, */
+ XETSwChangePointerControl, /* 105 */
+ XETSwSimpleReq, /* GetPointerControl, */
+ XETSwSetScreenSaver,
+ XETSwSimpleReq, /* GetScreenSaver, */
+ XETSwChangeHosts,
+ XETSwSimpleReq, /* 110 ListHosts, */
+ XETSwSimpleReq, /* XETSwChangeAccessControl, */
+ XETSwSimpleReq, /* XETSwChangeCloseDownMode, */
+ XETSwResourceReq, /* XETSwKillClient, */
+ XETSwRotateProperties,
+ XETSwSimpleReq, /* 115 ForceScreenSaver */
+ XETSwSimpleReq, /* SetPointerMapping, */
+ XETSwSimpleReq, /* GetPointerMapping, */
+ XETSwSimpleReq, /* SetModifierMapping, */
+ XETSwSimpleReq, /* GetModifierMapping, */
+ NotImplemented, /* 120 */
+ NotImplemented,
+ NotImplemented,
+ NotImplemented,
+ NotImplemented,
+ NotImplemented, /* 125 */
+ NotImplemented,
+ XETSwNoOperation
+};
+
+/* NOTE: This array must align with the values of the constants used
+ * as minor_opcode values in the request structure. Failure to do this
+ * could result in random code paths.
+ */
+globaldef int_function XETrapDispatchVector[10L] =
+{
+ XETrapReset, /* 0 XETrap_Reset */
+ XETrapGetAvailable, /* 1 XETrap_GetAvailable */
+ XETrapConfig, /* 2 XETrap_Config */
+ XETrapStartTrap, /* 3 XETrap_StartTrap */
+ XETrapStopTrap, /* 4 XETrap_StopTrap */
+ XETrapGetCurrent, /* 5 XETrap_GetCurrent */
+ XETrapGetStatistics, /* 6 XETrap_GetStatistics */
+#ifndef _XINPUT
+ XETrapSimulateXEvent, /* 7 XETrap_SimulateXEvent */
+#endif
+ XETrapGetVersion, /* 8 XETrap_GetVersion */
+ XETrapGetLastInpTime, /* 9 XETrap_GetLastInpTime */
+};
+
+/* NOTE: This array must align with the values of the constants used
+ * as minor_opcode values in the request structure. Failure to do this
+ * could result in random code paths.
+ */
+globaldef int_function XETSwDispatchVector[10L] =
+{
+ sXETrapReset, /* 0 XETrap_Reset */
+ sXETrapGetAvailable, /* 1 XETrap_GetAvailable */
+ sXETrapConfig, /* 2 XETrap_Config */
+ sXETrapStartTrap, /* 3 XETrap_StartTrap */
+ sXETrapStopTrap, /* 4 XETrap_StopTrap */
+ sXETrapGetCurrent, /* 5 XETrap_GetCurrent */
+ sXETrapGetStatistics, /* 6 XETrap_GetStatistics */
+#ifndef _XINPUT
+ sXETrapSimulateXEvent, /* 7 XETrap_SimulateXEvent */
+#endif
+ sXETrapGetVersion, /* 8 XETrap_GetVersion */
+ sXETrapGetLastInpTime, /* 9 XETrap_GetLastInpTime */
+};
+
+/* ProcVector shadow vector */
+globaldef int_function XETrapProcVector[256L] = {XETrapRequestVector};
+/*
+ * Events are faked as if they're vectored since that's
+ * the way it'll eventually be (X11 R5?).
+ */
+#ifndef VECTORED_EVENTS
+globaldef int_function EventProcVector[XETrapCoreEvents] = {NULL};
+#endif
+globaldef int_function XETrapEventProcVector[XETrapCoreEvents] = {NULL};
+
+
diff --git a/nx-X11/programs/Xserver/Xext/EVI.c b/nx-X11/programs/Xserver/Xext/EVI.c
new file mode 100644
index 000000000..b59180685
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/EVI.c
@@ -0,0 +1,202 @@
+/* $Xorg: EVI.c,v 1.3 2000/08/17 19:47:55 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1997 by Silicon Graphics Computer Systems, Inc.
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xext/EVI.c,v 3.10tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "dix.h"
+#define _XEVI_SERVER_
+#include <X11/extensions/XEVIstr.h>
+#include "EVIstruct.h"
+#include "modinit.h"
+
+#if 0
+static unsigned char XEVIReqCode = 0;
+#endif
+static EviPrivPtr eviPriv;
+
+static int
+ProcEVIQueryVersion(ClientPtr client)
+{
+ /* REQUEST(xEVIQueryVersionReq); */
+ xEVIQueryVersionReply rep;
+ register int n;
+ REQUEST_SIZE_MATCH (xEVIQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = XEVI_MAJOR_VERSION;
+ rep.minorVersion = XEVI_MAJOR_VERSION;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof (xEVIQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+#define swapEviInfo(eviInfo, l) \
+{ \
+ int l1 = l; \
+ xExtendedVisualInfo *eviInfo1 = eviInfo; \
+ while (l1-- > 0) { \
+ swapl(&eviInfo1->core_visual_id, n); \
+ swapl(&eviInfo1->transparency_value, n); \
+ swaps(&eviInfo1->num_colormap_conflicts, n); \
+ eviInfo1++; \
+ } \
+}
+#define swapVisual(visual, l) \
+{ \
+ int l1 = l; \
+ VisualID32 *visual1 = visual; \
+ while (l1-- > 0) { \
+ swapl(visual1, n); \
+ visual1++; \
+ } \
+}
+
+static int
+ProcEVIGetVisualInfo(ClientPtr client)
+{
+ REQUEST(xEVIGetVisualInfoReq);
+ xEVIGetVisualInfoReply rep;
+ int n, n_conflict, n_info, sz_info, sz_conflict;
+ VisualID32 *conflict;
+ xExtendedVisualInfo *eviInfo;
+ int status;
+ REQUEST_FIXED_SIZE(xEVIGetVisualInfoReq, stuff->n_visual * sz_VisualID32);
+ status = eviPriv->getVisualInfo((VisualID32 *)&stuff[1], (int)stuff->n_visual,
+ &eviInfo, &n_info, &conflict, &n_conflict);
+ if (status != Success)
+ return status;
+ sz_info = n_info * sz_xExtendedVisualInfo;
+ sz_conflict = n_conflict * sz_VisualID32;
+ rep.type = X_Reply;
+ rep.n_info = n_info;
+ rep.n_conflicts = n_conflict;
+ rep.sequenceNumber = client->sequence;
+ rep.length = (sz_info + sz_conflict) >> 2;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.n_info, n);
+ swapl(&rep.n_conflicts, n);
+ swapEviInfo(eviInfo, n_info);
+ swapVisual(conflict, n_conflict);
+ }
+ WriteToClient(client, sz_xEVIGetVisualInfoReply, (char *)&rep);
+ WriteToClient(client, sz_info, (char *)eviInfo);
+ WriteToClient(client, sz_conflict, (char *)conflict);
+ eviPriv->freeVisualInfo(eviInfo, conflict);
+ return (client->noClientException);
+}
+
+static int
+ProcEVIDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+ switch (stuff->data) {
+ case X_EVIQueryVersion:
+ return ProcEVIQueryVersion (client);
+ case X_EVIGetVisualInfo:
+ return ProcEVIGetVisualInfo (client);
+ default:
+ return BadRequest;
+ }
+}
+
+static int
+SProcEVIQueryVersion(ClientPtr client)
+{
+ REQUEST(xEVIQueryVersionReq);
+ int n;
+ swaps(&stuff->length, n);
+ return ProcEVIQueryVersion(client);
+}
+
+static int
+SProcEVIGetVisualInfo(ClientPtr client)
+{
+ register int n;
+ REQUEST(xEVIGetVisualInfoReq);
+ swaps(&stuff->length, n);
+ return ProcEVIGetVisualInfo(client);
+}
+
+static int
+SProcEVIDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_EVIQueryVersion:
+ return SProcEVIQueryVersion (client);
+ case X_EVIGetVisualInfo:
+ return SProcEVIGetVisualInfo (client);
+ default:
+ return BadRequest;
+ }
+}
+
+/*ARGSUSED*/
+static void
+EVIResetProc(ExtensionEntry *extEntry)
+{
+ eviDDXReset();
+}
+
+/****************
+ * XEVIExtensionInit
+ *
+ * Called from InitExtensions in main() or from QueryExtension() if the
+ * extension is dynamically loaded.
+ *
+ ****************/
+void
+EVIExtensionInit(INITARGS)
+{
+#if 0
+ ExtensionEntry *extEntry;
+
+ if ((extEntry = AddExtension(EVINAME, 0, 0,
+ ProcEVIDispatch,
+ SProcEVIDispatch,
+ EVIResetProc, StandardMinorOpcode))) {
+ XEVIReqCode = (unsigned char)extEntry->base;
+#else
+ if (AddExtension(EVINAME, 0, 0,
+ ProcEVIDispatch, SProcEVIDispatch,
+ EVIResetProc, StandardMinorOpcode)) {
+#endif
+ eviPriv = eviDDXInit();
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xext/EVIstruct.h b/nx-X11/programs/Xserver/Xext/EVIstruct.h
new file mode 100644
index 000000000..857e7565a
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/EVIstruct.h
@@ -0,0 +1,60 @@
+/* $Xorg: EVIstruct.h,v 1.3 2000/08/17 19:47:55 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1997 by Silicon Graphics Computer Systems, Inc.
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xext/EVIstruct.h,v 3.5 2003/07/16 01:38:28 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef EVI_STRUCT_H
+#define EVI_STRUCT_H
+
+/*
+ ******************************************************************************
+ ** Per-ddx data
+ ******************************************************************************
+ */
+
+typedef int (*GetVisualInfoProc)(
+ VisualID32*,
+ int,
+ xExtendedVisualInfo**,
+ int*,
+ VisualID32**,
+ int*
+);
+
+typedef void (*FreeVisualInfoProc)(
+ xExtendedVisualInfo*,
+ VisualID32*
+);
+typedef struct _EviPrivRec {
+ GetVisualInfoProc getVisualInfo;
+ FreeVisualInfoProc freeVisualInfo;
+} EviPrivRec, *EviPrivPtr;
+
+extern EviPrivPtr eviDDXInit(void);
+extern void eviDDXReset(void);
+
+#endif /* EVI_STRUCT_H */
diff --git a/nx-X11/programs/Xserver/Xext/Imakefile b/nx-X11/programs/Xserver/Xext/Imakefile
new file mode 100644
index 000000000..73220a70f
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/Imakefile
@@ -0,0 +1,226 @@
+/* $XdotOrg: xc/programs/Xserver/Xext/Imakefile,v 1.9 2005/04/24 01:10:12 gisburn Exp $ */
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:47:55 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/Xext/Imakefile,v 3.43 2003/04/21 18:56:48 sven Exp $
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+#include <Server.tmpl>
+
+#if DoLoadableServer
+#define IHaveSubdirs
+SUBDIRS = extmod
+#endif
+
+#if BuildEVI
+#ifdef SGIArchitectureNotTog
+ EVISRCS = EVI.c sgiEVI.c
+ EVIOBJS = EVI.o sgiEVI.o
+#else
+ EVISRCS = EVI.c sampleEVI.c
+ EVIOBJS = EVI.o sampleEVI.o
+#endif
+#endif
+#if HasShm
+ SHMSRCS = shm.c
+ SHMOBJS = shm.o
+#endif
+
+#if BuildMultibuffer
+ MULTIBUFSRC = mbuf.c
+ MULTIBUFOBJ = mbuf.o
+#endif
+
+#if BuildScreenSaverExt
+ SCRNSAVSRC = saver.c
+ SCRNSAVOBJ = saver.o
+#endif
+
+#if BuildXF86VidModeExt && \
+ ((defined(XF86Server) && XF86Server) || \
+ (defined(XorgServer) && XorgServer))
+ VIDMODESRCS = xf86vmode.c
+ VIDMODEOBJS = xf86vmode.o
+#endif
+
+#if BuildXF86MiscExt && \
+ ((defined(XF86Server) && XF86Server) || \
+ (defined(XorgServer) && XorgServer))
+XF86MISCSRCS = xf86misc.c
+XF86MISCOBJS = xf86misc.o
+#endif
+
+#if BuildXF86BigfontExt
+XF86BIGFSRCS = xf86bigfont.c
+XF86BIGFOBJS = xf86bigfont.o
+#if HasShm
+ SHM_DEFINES = -DHAS_SHM
+#endif
+#endif
+
+#if BuildXF86DGA
+ XF86DGASRCS = xf86dga.c xf86dga2.c
+ XF86DGAOBJS = xf86dga.o xf86dga2.o
+#if HasShm
+ XVMCSHM_DEFINES = -DHAS_XVMCSHM
+#endif
+#endif
+
+#if BuildXvExt
+ XVSRCS = xvmain.c xvdisp.c xvmc.c
+ XVOBJS = xvmain.o xvdisp.o xvmc.o
+#endif
+
+#if BuildXResExt
+ XRESSRCS = xres.c
+ XRESOBJS = xres.o
+#endif
+
+#if BuildAppgroup
+ APPGROUPSRCS = appgroup.c
+ APPGROUPOBJS = appgroup.o
+#endif
+#if BuildXCSecurity
+ SECURITYSRCS = security.c
+ SECURITYOBJS = security.o
+ SERVERCONFIGDIR = ServerConfigDir
+ POLICYFILEDEF = -DDEFAULTPOLICYFILE=\"$(SERVERCONFIGDIR)/SecurityPolicy\"
+#endif
+#if BuildCup
+ CUPSRCS = cup.c
+ CUPOBJS = cup.o
+#endif
+#if BuildXinerama
+ PNRXSRCS = panoramiX.c panoramiXSwap.c panoramiXprocs.c
+ PNRXOBJS = panoramiX.o panoramiXSwap.o panoramiXprocs.o
+ PNRXINCLUDES = -I$(FONTINCSRC) -I../mi -I../render
+#endif
+#if XdmxServer
+ DMXSRCS = dmx.c
+ DMXOBJS = dmx.o
+ DMXINCLUDES = -I../hw/dmx
+#endif
+#if BuildDPMS
+ DPMSSRCS = dpms.c
+ DPMSOBJS = dpms.o
+#endif
+
+#if BuildFontCache
+ FONTCACHESRCS = fontcache.c
+ FONTCACHEOBJS = fontcache.o
+#if 0
+ FONTCACHEINCLUDES = -I$(XF86SRC)/os-support
+#endif
+#endif
+
+#if BuildXevie
+ XEVIESRCS = xevie.c
+ XEVIEOBJS = xevie.o
+#endif
+
+#if BuildXprint
+ XPRINTSRCS = xprint.c
+ XPRINTOBJS = xprint.o
+#endif
+
+ SRCS = shape.c $(SHMSRCS) $(MULTIBUFSRC) \
+ mitmisc.c xtest.c xtest1di.c xtest1dd.c sleepuntil.c \
+ bigreq.c sync.c $(SCRNSAVSRC) xcmisc.c $(VIDMODESRCS) \
+ $(XF86MISCSRCS) $(XF86BIGFSRCS) $(XF86DGASRCS) $(SECURITYSRCS) \
+ $(APPGROUPSRCS) $(XPRINTSRCS) $(CUPSRCS) $(PNRXSRCS) $(DPMSSRCS) \
+ $(XEVIESRCS) \
+ $(EVISRCS) $(XVSRCS) $(FONTCACHESRCS) $(XRESSRCS) $(DMXSRCS)
+
+ OBJS = shape.o $(SHMOBJS) $(MULTIBUFOBJ) \
+ mitmisc.o xtest.o xtest1di.o xtest1dd.o sleepuntil.o \
+ bigreq.o sync.o $(SCRNSAVOBJ) xcmisc.o $(VIDMODEOBJS) \
+ $(XF86MISCOBJS) $(XF86BIGFOBJS) $(XF86DGAOBJS) $(SECURITYOBJS) \
+ $(APPGROUPOBJS) $(XPRINTOBJS) $(CUPOBJS) $(PNRXOBJS) $(DPMSOBJS) \
+ $(XEVIEOBJS) \
+ $(EVIOBJS) $(XVOBJS) $(FONTCACHEOBJS) $(XRESOBJS) $(DMXOBJS)
+
+ SOBJS = $(SHMOBJS) $(APPGROUPOBJS) $(SECURITYOBJS) $(XPRINTOBJS) \
+ shape.o xtest.o xtest1di.o xtest1dd.o sleepuntil.o $(PNRXOBJS) \
+ $(XEVIEOBJS) \
+ $(XF86BIGFOBJS)
+
+#if defined(NXAgentServer) && NXAgentServer
+NX_DEFINES = -DNXAGENT_SERVER
+#endif
+
+
+#if (defined(XFree86Version) || defined(XorgVersion))
+/* XXX Check if this can be eliminated */
+XF86INCLUDES = -I$(XF86COMSRC)
+#endif
+ INCLUDES = -I. -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) \
+ $(PNRXINCLUDES) $(XF86INCLUDES) -I$(FONTINCSRC) \
+ $(FONTCACHEINCLUDES) $(DMXINCLUDES)
+ LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+
+#if defined(NXAgentServer) && NXAgentServer
+ DEFINES = $(EXT_DEFINES) $(XVMCSHM_DEFINES) $(NX_DEFINES)
+#else
+ DEFINES = $(EXT_DEFINES) $(XVMCSHM_DEFINES)
+#endif
+
+NormalLibraryObjectRule()
+
+/*
+ * A hack to work around an optimization problem with gcc 2.95.2
+ */
+#if BuildXF86VidModeExt && defined(GccOptBug295)
+SpecialCObjectRule(xf86vmode,NullParameter,-O0)
+#endif
+
+NormalLibraryTarget(ext,$(OBJS))
+LintLibraryTarget(ext,$(SRCS))
+NormalLintTarget($(SRCS))
+
+#if DoLoadableServer
+NormalLibraryTarget(exts,$(SOBJS))
+#endif
+
+#if BuildXF86BigfontExt
+SpecialCObjectRule(xf86bigfont,$(ICONFIGFILES),$(SHM_DEFINES))
+#endif
+#if BuildXCSecurity
+SpecialCObjectRule(security,$(ICONFIGFILES),$(POLICYFILEDEF))
+#endif
+
+LinkConfDirectory(xserver,.,xserver,.)
+
+LinkSourceFile(modinit.h,extmod)
+
+#if BuildXCSecurity && InstallSecurityConfig
+InstallNonExecFile(SecurityPolicy,$(SERVERCONFIGDIR))
+#endif
+
+DependTarget()
+
+#if DoLoadableServer
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+InstallDriverSDKNonExecFile(dgaproc.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xvdix.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xvmcext.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/Xext/Imakefile.NX.original b/nx-X11/programs/Xserver/Xext/Imakefile.NX.original
new file mode 100644
index 000000000..73220a70f
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/Imakefile.NX.original
@@ -0,0 +1,226 @@
+/* $XdotOrg: xc/programs/Xserver/Xext/Imakefile,v 1.9 2005/04/24 01:10:12 gisburn Exp $ */
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:47:55 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/Xext/Imakefile,v 3.43 2003/04/21 18:56:48 sven Exp $
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+#include <Server.tmpl>
+
+#if DoLoadableServer
+#define IHaveSubdirs
+SUBDIRS = extmod
+#endif
+
+#if BuildEVI
+#ifdef SGIArchitectureNotTog
+ EVISRCS = EVI.c sgiEVI.c
+ EVIOBJS = EVI.o sgiEVI.o
+#else
+ EVISRCS = EVI.c sampleEVI.c
+ EVIOBJS = EVI.o sampleEVI.o
+#endif
+#endif
+#if HasShm
+ SHMSRCS = shm.c
+ SHMOBJS = shm.o
+#endif
+
+#if BuildMultibuffer
+ MULTIBUFSRC = mbuf.c
+ MULTIBUFOBJ = mbuf.o
+#endif
+
+#if BuildScreenSaverExt
+ SCRNSAVSRC = saver.c
+ SCRNSAVOBJ = saver.o
+#endif
+
+#if BuildXF86VidModeExt && \
+ ((defined(XF86Server) && XF86Server) || \
+ (defined(XorgServer) && XorgServer))
+ VIDMODESRCS = xf86vmode.c
+ VIDMODEOBJS = xf86vmode.o
+#endif
+
+#if BuildXF86MiscExt && \
+ ((defined(XF86Server) && XF86Server) || \
+ (defined(XorgServer) && XorgServer))
+XF86MISCSRCS = xf86misc.c
+XF86MISCOBJS = xf86misc.o
+#endif
+
+#if BuildXF86BigfontExt
+XF86BIGFSRCS = xf86bigfont.c
+XF86BIGFOBJS = xf86bigfont.o
+#if HasShm
+ SHM_DEFINES = -DHAS_SHM
+#endif
+#endif
+
+#if BuildXF86DGA
+ XF86DGASRCS = xf86dga.c xf86dga2.c
+ XF86DGAOBJS = xf86dga.o xf86dga2.o
+#if HasShm
+ XVMCSHM_DEFINES = -DHAS_XVMCSHM
+#endif
+#endif
+
+#if BuildXvExt
+ XVSRCS = xvmain.c xvdisp.c xvmc.c
+ XVOBJS = xvmain.o xvdisp.o xvmc.o
+#endif
+
+#if BuildXResExt
+ XRESSRCS = xres.c
+ XRESOBJS = xres.o
+#endif
+
+#if BuildAppgroup
+ APPGROUPSRCS = appgroup.c
+ APPGROUPOBJS = appgroup.o
+#endif
+#if BuildXCSecurity
+ SECURITYSRCS = security.c
+ SECURITYOBJS = security.o
+ SERVERCONFIGDIR = ServerConfigDir
+ POLICYFILEDEF = -DDEFAULTPOLICYFILE=\"$(SERVERCONFIGDIR)/SecurityPolicy\"
+#endif
+#if BuildCup
+ CUPSRCS = cup.c
+ CUPOBJS = cup.o
+#endif
+#if BuildXinerama
+ PNRXSRCS = panoramiX.c panoramiXSwap.c panoramiXprocs.c
+ PNRXOBJS = panoramiX.o panoramiXSwap.o panoramiXprocs.o
+ PNRXINCLUDES = -I$(FONTINCSRC) -I../mi -I../render
+#endif
+#if XdmxServer
+ DMXSRCS = dmx.c
+ DMXOBJS = dmx.o
+ DMXINCLUDES = -I../hw/dmx
+#endif
+#if BuildDPMS
+ DPMSSRCS = dpms.c
+ DPMSOBJS = dpms.o
+#endif
+
+#if BuildFontCache
+ FONTCACHESRCS = fontcache.c
+ FONTCACHEOBJS = fontcache.o
+#if 0
+ FONTCACHEINCLUDES = -I$(XF86SRC)/os-support
+#endif
+#endif
+
+#if BuildXevie
+ XEVIESRCS = xevie.c
+ XEVIEOBJS = xevie.o
+#endif
+
+#if BuildXprint
+ XPRINTSRCS = xprint.c
+ XPRINTOBJS = xprint.o
+#endif
+
+ SRCS = shape.c $(SHMSRCS) $(MULTIBUFSRC) \
+ mitmisc.c xtest.c xtest1di.c xtest1dd.c sleepuntil.c \
+ bigreq.c sync.c $(SCRNSAVSRC) xcmisc.c $(VIDMODESRCS) \
+ $(XF86MISCSRCS) $(XF86BIGFSRCS) $(XF86DGASRCS) $(SECURITYSRCS) \
+ $(APPGROUPSRCS) $(XPRINTSRCS) $(CUPSRCS) $(PNRXSRCS) $(DPMSSRCS) \
+ $(XEVIESRCS) \
+ $(EVISRCS) $(XVSRCS) $(FONTCACHESRCS) $(XRESSRCS) $(DMXSRCS)
+
+ OBJS = shape.o $(SHMOBJS) $(MULTIBUFOBJ) \
+ mitmisc.o xtest.o xtest1di.o xtest1dd.o sleepuntil.o \
+ bigreq.o sync.o $(SCRNSAVOBJ) xcmisc.o $(VIDMODEOBJS) \
+ $(XF86MISCOBJS) $(XF86BIGFOBJS) $(XF86DGAOBJS) $(SECURITYOBJS) \
+ $(APPGROUPOBJS) $(XPRINTOBJS) $(CUPOBJS) $(PNRXOBJS) $(DPMSOBJS) \
+ $(XEVIEOBJS) \
+ $(EVIOBJS) $(XVOBJS) $(FONTCACHEOBJS) $(XRESOBJS) $(DMXOBJS)
+
+ SOBJS = $(SHMOBJS) $(APPGROUPOBJS) $(SECURITYOBJS) $(XPRINTOBJS) \
+ shape.o xtest.o xtest1di.o xtest1dd.o sleepuntil.o $(PNRXOBJS) \
+ $(XEVIEOBJS) \
+ $(XF86BIGFOBJS)
+
+#if defined(NXAgentServer) && NXAgentServer
+NX_DEFINES = -DNXAGENT_SERVER
+#endif
+
+
+#if (defined(XFree86Version) || defined(XorgVersion))
+/* XXX Check if this can be eliminated */
+XF86INCLUDES = -I$(XF86COMSRC)
+#endif
+ INCLUDES = -I. -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) \
+ $(PNRXINCLUDES) $(XF86INCLUDES) -I$(FONTINCSRC) \
+ $(FONTCACHEINCLUDES) $(DMXINCLUDES)
+ LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+
+#if defined(NXAgentServer) && NXAgentServer
+ DEFINES = $(EXT_DEFINES) $(XVMCSHM_DEFINES) $(NX_DEFINES)
+#else
+ DEFINES = $(EXT_DEFINES) $(XVMCSHM_DEFINES)
+#endif
+
+NormalLibraryObjectRule()
+
+/*
+ * A hack to work around an optimization problem with gcc 2.95.2
+ */
+#if BuildXF86VidModeExt && defined(GccOptBug295)
+SpecialCObjectRule(xf86vmode,NullParameter,-O0)
+#endif
+
+NormalLibraryTarget(ext,$(OBJS))
+LintLibraryTarget(ext,$(SRCS))
+NormalLintTarget($(SRCS))
+
+#if DoLoadableServer
+NormalLibraryTarget(exts,$(SOBJS))
+#endif
+
+#if BuildXF86BigfontExt
+SpecialCObjectRule(xf86bigfont,$(ICONFIGFILES),$(SHM_DEFINES))
+#endif
+#if BuildXCSecurity
+SpecialCObjectRule(security,$(ICONFIGFILES),$(POLICYFILEDEF))
+#endif
+
+LinkConfDirectory(xserver,.,xserver,.)
+
+LinkSourceFile(modinit.h,extmod)
+
+#if BuildXCSecurity && InstallSecurityConfig
+InstallNonExecFile(SecurityPolicy,$(SERVERCONFIGDIR))
+#endif
+
+DependTarget()
+
+#if DoLoadableServer
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+InstallDriverSDKNonExecFile(dgaproc.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xvdix.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xvmcext.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/Xext/Imakefile.X.original b/nx-X11/programs/Xserver/Xext/Imakefile.X.original
new file mode 100644
index 000000000..f2753b3f4
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/Imakefile.X.original
@@ -0,0 +1,200 @@
+/* $XdotOrg: xc/programs/Xserver/Xext/Imakefile,v 1.9 2005/04/24 01:10:12 gisburn Exp $ */
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:47:55 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/Xext/Imakefile,v 3.43 2003/04/21 18:56:48 sven Exp $
+
+#include <Server.tmpl>
+
+#if DoLoadableServer
+#define IHaveSubdirs
+SUBDIRS = extmod
+#endif
+
+#if BuildEVI
+#ifdef SGIArchitectureNotTog
+ EVISRCS = EVI.c sgiEVI.c
+ EVIOBJS = EVI.o sgiEVI.o
+#else
+ EVISRCS = EVI.c sampleEVI.c
+ EVIOBJS = EVI.o sampleEVI.o
+#endif
+#endif
+#if HasShm
+ SHMSRCS = shm.c
+ SHMOBJS = shm.o
+#endif
+
+#if BuildMultibuffer
+ MULTIBUFSRC = mbuf.c
+ MULTIBUFOBJ = mbuf.o
+#endif
+
+#if BuildScreenSaverExt
+ SCRNSAVSRC = saver.c
+ SCRNSAVOBJ = saver.o
+#endif
+
+#if BuildXF86VidModeExt && \
+ ((defined(XF86Server) && XF86Server) || \
+ (defined(XorgServer) && XorgServer))
+ VIDMODESRCS = xf86vmode.c
+ VIDMODEOBJS = xf86vmode.o
+#endif
+
+#if BuildXF86MiscExt && \
+ ((defined(XF86Server) && XF86Server) || \
+ (defined(XorgServer) && XorgServer))
+XF86MISCSRCS = xf86misc.c
+XF86MISCOBJS = xf86misc.o
+#endif
+
+#if BuildXF86BigfontExt
+XF86BIGFSRCS = xf86bigfont.c
+XF86BIGFOBJS = xf86bigfont.o
+#if HasShm
+ SHM_DEFINES = -DHAS_SHM
+#endif
+#endif
+
+#if BuildXF86DGA
+ XF86DGASRCS = xf86dga.c xf86dga2.c
+ XF86DGAOBJS = xf86dga.o xf86dga2.o
+#if HasShm
+ XVMCSHM_DEFINES = -DHAS_XVMCSHM
+#endif
+#endif
+
+#if BuildXvExt
+ XVSRCS = xvmain.c xvdisp.c xvmc.c
+ XVOBJS = xvmain.o xvdisp.o xvmc.o
+#endif
+
+#if BuildXResExt
+ XRESSRCS = xres.c
+ XRESOBJS = xres.o
+#endif
+
+#if BuildAppgroup
+ APPGROUPSRCS = appgroup.c
+ APPGROUPOBJS = appgroup.o
+#endif
+#if BuildXCSecurity
+ SECURITYSRCS = security.c
+ SECURITYOBJS = security.o
+ SERVERCONFIGDIR = ServerConfigDir
+ POLICYFILEDEF = -DDEFAULTPOLICYFILE=\"$(SERVERCONFIGDIR)/SecurityPolicy\"
+#endif
+#if BuildCup
+ CUPSRCS = cup.c
+ CUPOBJS = cup.o
+#endif
+#if BuildXinerama
+ PNRXSRCS = panoramiX.c panoramiXSwap.c panoramiXprocs.c
+ PNRXOBJS = panoramiX.o panoramiXSwap.o panoramiXprocs.o
+ PNRXINCLUDES = -I$(FONTINCSRC) -I../mi -I../render
+#endif
+#if XdmxServer
+ DMXSRCS = dmx.c
+ DMXOBJS = dmx.o
+ DMXINCLUDES = -I../hw/dmx
+#endif
+#if BuildDPMS
+ DPMSSRCS = dpms.c
+ DPMSOBJS = dpms.o
+#endif
+
+#if BuildFontCache
+ FONTCACHESRCS = fontcache.c
+ FONTCACHEOBJS = fontcache.o
+#if 0
+ FONTCACHEINCLUDES = -I$(XF86SRC)/os-support
+#endif
+#endif
+
+#if BuildXevie
+ XEVIESRCS = xevie.c
+ XEVIEOBJS = xevie.o
+#endif
+
+#if BuildXprint
+ XPRINTSRCS = xprint.c
+ XPRINTOBJS = xprint.o
+#endif
+
+ SRCS = shape.c $(SHMSRCS) $(MULTIBUFSRC) \
+ mitmisc.c xtest.c xtest1di.c xtest1dd.c sleepuntil.c \
+ bigreq.c sync.c $(SCRNSAVSRC) xcmisc.c $(VIDMODESRCS) \
+ $(XF86MISCSRCS) $(XF86BIGFSRCS) $(XF86DGASRCS) $(SECURITYSRCS) \
+ $(APPGROUPSRCS) $(XPRINTSRCS) $(CUPSRCS) $(PNRXSRCS) $(DPMSSRCS) \
+ $(XEVIESRCS) \
+ $(EVISRCS) $(XVSRCS) $(FONTCACHESRCS) $(XRESSRCS) $(DMXSRCS)
+
+ OBJS = shape.o $(SHMOBJS) $(MULTIBUFOBJ) \
+ mitmisc.o xtest.o xtest1di.o xtest1dd.o sleepuntil.o \
+ bigreq.o sync.o $(SCRNSAVOBJ) xcmisc.o $(VIDMODEOBJS) \
+ $(XF86MISCOBJS) $(XF86BIGFOBJS) $(XF86DGAOBJS) $(SECURITYOBJS) \
+ $(APPGROUPOBJS) $(XPRINTOBJS) $(CUPOBJS) $(PNRXOBJS) $(DPMSOBJS) \
+ $(XEVIEOBJS) \
+ $(EVIOBJS) $(XVOBJS) $(FONTCACHEOBJS) $(XRESOBJS) $(DMXOBJS)
+
+ SOBJS = $(SHMOBJS) $(APPGROUPOBJS) $(SECURITYOBJS) $(XPRINTOBJS) \
+ shape.o xtest.o xtest1di.o xtest1dd.o sleepuntil.o $(PNRXOBJS) \
+ $(XEVIEOBJS) \
+ $(XF86BIGFOBJS)
+
+#if (defined(XFree86Version) || defined(XorgVersion))
+/* XXX Check if this can be eliminated */
+XF86INCLUDES = -I$(XF86COMSRC)
+#endif
+ INCLUDES = -I. -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) \
+ $(PNRXINCLUDES) $(XF86INCLUDES) -I$(FONTINCSRC) \
+ $(FONTCACHEINCLUDES) $(DMXINCLUDES)
+ LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+
+ DEFINES = $(EXT_DEFINES) $(XVMCSHM_DEFINES)
+
+NormalLibraryObjectRule()
+
+/*
+ * A hack to work around an optimization problem with gcc 2.95.2
+ */
+#if BuildXF86VidModeExt && defined(GccOptBug295)
+SpecialCObjectRule(xf86vmode,NullParameter,-O0)
+#endif
+
+NormalLibraryTarget(ext,$(OBJS))
+LintLibraryTarget(ext,$(SRCS))
+NormalLintTarget($(SRCS))
+
+#if DoLoadableServer
+NormalLibraryTarget(exts,$(SOBJS))
+#endif
+
+#if BuildXF86BigfontExt
+SpecialCObjectRule(xf86bigfont,$(ICONFIGFILES),$(SHM_DEFINES))
+#endif
+#if BuildXCSecurity
+SpecialCObjectRule(security,$(ICONFIGFILES),$(POLICYFILEDEF))
+#endif
+
+LinkConfDirectory(xserver,.,xserver,.)
+
+LinkSourceFile(modinit.h,extmod)
+
+#if BuildXCSecurity && InstallSecurityConfig
+InstallNonExecFile(SecurityPolicy,$(SERVERCONFIGDIR))
+#endif
+
+DependTarget()
+
+#if DoLoadableServer
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+InstallDriverSDKNonExecFile(dgaproc.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xvdix.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xvmcext.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/Xext/SecurityPolicy b/nx-X11/programs/Xserver/Xext/SecurityPolicy
new file mode 100644
index 000000000..cc521c263
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/SecurityPolicy
@@ -0,0 +1,88 @@
+version-1
+
+# $Xorg: SecurityPolicy,v 1.3 2000/08/17 19:47:56 cpqbld Exp $
+
+# The site policy fields are interpreted by the XC-QUERY-SECURITY-1
+# authorization protocol. The values are arbitrary and site-specific.
+# Refer to the Security Extension Specification for the usage of the policies.
+#sitepolicy A
+#sitepolicy B
+#sitepolicy C
+
+# Property access rules:
+# property <property> <window> <permissions>
+# <window> ::= any | root | <propertyselector>
+# <propertyselector> ::= <property> | <property>=<value>
+# <permissions> :== [ <operation> | <action> | <space> ]*
+# <operation> :== r | w | d
+# r read
+# w write
+# d delete
+# <action> :== a | i | e
+# a allow
+# i ignore
+# e error
+
+# Allow reading of application resources, but not writing.
+property RESOURCE_MANAGER root ar iw
+property SCREEN_RESOURCES root ar iw
+
+# Ignore attempts to use cut buffers. Giving errors causes apps to crash,
+# and allowing access may give away too much information.
+property CUT_BUFFER0 root irw
+property CUT_BUFFER1 root irw
+property CUT_BUFFER2 root irw
+property CUT_BUFFER3 root irw
+property CUT_BUFFER4 root irw
+property CUT_BUFFER5 root irw
+property CUT_BUFFER6 root irw
+property CUT_BUFFER7 root irw
+
+# If you are using Motif, you probably want these.
+property _MOTIF_DEFAULT_BINDINGS root ar iw
+property _MOTIF_DRAG_WINDOW root ar iw
+property _MOTIF_DRAG_TARGETS any ar iw
+property _MOTIF_DRAG_ATOMS any ar iw
+property _MOTIF_DRAG_ATOM_PAIRS any ar iw
+
+# If you are running CDE you also need these
+property _MOTIF_WM_INFO root arw
+property TT_SESSION root irw
+property WM_ICON_SIZE root irw
+property "SDT Pixel Set" any irw
+
+# The next two rules let xwininfo -tree work when untrusted.
+property WM_NAME any ar
+
+# Allow read of WM_CLASS, but only for windows with WM_NAME.
+# This might be more restrictive than necessary, but demonstrates
+# the <required property> facility, and is also an attempt to
+# say "top level windows only."
+property WM_CLASS WM_NAME ar
+
+# These next three let xlsclients work untrusted. Think carefully
+# before including these; giving away the client machine name and command
+# may be exposing too much.
+property WM_STATE WM_NAME ar
+property WM_CLIENT_MACHINE WM_NAME ar
+property WM_COMMAND WM_NAME ar
+
+# To let untrusted clients use the standard colormaps created by
+# xstdcmap, include these lines.
+property RGB_DEFAULT_MAP root ar
+property RGB_BEST_MAP root ar
+property RGB_RED_MAP root ar
+property RGB_GREEN_MAP root ar
+property RGB_BLUE_MAP root ar
+property RGB_GRAY_MAP root ar
+
+# To let untrusted clients use the color management database created
+# by xcmsdb, include these lines.
+property XDCCC_LINEAR_RGB_CORRECTION root ar
+property XDCCC_LINEAR_RGB_MATRICES root ar
+property XDCCC_GRAY_SCREENWHITEPOINT root ar
+property XDCCC_GRAY_CORRECTION root ar
+
+# To let untrusted clients use the overlay visuals that many vendors
+# support, include this line.
+property SERVER_OVERLAY_VISUALS root ar
diff --git a/nx-X11/programs/Xserver/Xext/appgroup.c b/nx-X11/programs/Xserver/Xext/appgroup.c
new file mode 100644
index 000000000..ad4afa9e4
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/appgroup.c
@@ -0,0 +1,829 @@
+/* $XFree86: xc/programs/Xserver/Xext/appgroup.c,v 1.10tsi Exp $ */
+/*
+Copyright 1996, 1998, 2001 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+*/
+/* $Xorg: appgroup.c,v 1.6 2001/02/09 02:04:32 xorgcvs Exp $ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "colormapst.h"
+#include "servermd.h"
+#define _XAG_SERVER_
+#include <X11/extensions/Xagstr.h>
+#include <X11/extensions/Xagsrv.h>
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#include <X11/Xfuncproto.h>
+
+#define XSERV_t
+#include <X11/Xtrans/Xtrans.h>
+#include "../os/osdep.h"
+
+#include <stdio.h>
+
+#include "modinit.h"
+#include "appgroup.h"
+
+typedef struct _AppGroupRec {
+ struct _AppGroupRec* next;
+ XID appgroupId;
+ ClientPtr* clients;
+ int nclients;
+ ClientPtr leader;
+ Bool single_screen;
+ Window default_root;
+ VisualID root_visual;
+ Colormap default_colormap;
+ Pixel black_pixel;
+ Pixel white_pixel;
+ xConnSetupPrefix connSetupPrefix;
+ char* ConnectionInfo;
+} AppGroupRec, *AppGroupPtr;
+
+static int ProcXagDispatch(ClientPtr client);
+static int SProcXagDispatch(ClientPtr client);
+static void XagResetProc(ExtensionEntry* extEntry);
+
+#if 0
+static unsigned char XagReqCode = 0;
+static int XagErrorBase;
+#endif
+static int XagCallbackRefCount = 0;
+
+static RESTYPE RT_APPGROUP;
+static AppGroupPtr appGrpList = NULL;
+
+extern xConnSetupPrefix connSetupPrefix;
+extern char* ConnectionInfo;
+extern int connBlockScreenStart;
+
+static
+int XagAppGroupFree(
+ pointer what,
+ XID id) /* unused */
+{
+ int i;
+ AppGroupPtr pAppGrp = (AppGroupPtr) what;
+
+ if (pAppGrp->leader)
+ for (i = 0; i < pAppGrp->nclients; i++) {
+ pAppGrp->clients[i]->appgroup = NULL;
+ CloseDownClient (pAppGrp->clients[i]);
+ }
+
+ if (pAppGrp == appGrpList)
+ appGrpList = appGrpList->next;
+ else {
+ AppGroupPtr tpAppGrp;
+ for (tpAppGrp = appGrpList;
+ tpAppGrp->next != NULL;
+ tpAppGrp = tpAppGrp->next) {
+ if (tpAppGrp->next == pAppGrp) {
+ tpAppGrp->next = tpAppGrp->next->next;
+ break;
+ }
+ }
+ }
+ (void) xfree (pAppGrp->clients);
+ (void) xfree (pAppGrp->ConnectionInfo);
+ (void) xfree (what);
+ return Success;
+}
+
+/* static */
+void XagClientStateChange(
+ CallbackListPtr* pcbl,
+ pointer nulldata,
+ pointer calldata)
+{
+ SecurityAuthorizationPtr pAuth;
+ NewClientInfoRec* pci = (NewClientInfoRec*) calldata;
+ ClientPtr pClient = pci->client;
+ AppGroupPtr pAppGrp;
+ XID authId = 0;
+
+ if (!pClient->appgroup) {
+ switch (pClient->clientState) {
+
+ case ClientStateAuthenticating:
+ case ClientStateRunning:
+ case ClientStateCheckingSecurity:
+ return;
+
+ case ClientStateInitial:
+ case ClientStateCheckedSecurity:
+ /*
+ * If the client is connecting via a firewall proxy (which
+ * uses XC-QUERY-SECURITY-1, then the authId is available
+ * during ClientStateCheckedSecurity, otherwise it's
+ * available during ClientStateInitial.
+ *
+ * Don't get it from pClient because can't guarantee the order
+ * of the callbacks and the security extension might not have
+ * plugged it in yet.
+ */
+ authId = AuthorizationIDOfClient(pClient);
+ break;
+
+ case ClientStateGone:
+ case ClientStateRetained:
+ /*
+ * Don't get if from AuthorizationIDOfClient because can't
+ * guarantee the order of the callbacks and the security
+ * extension may have torn down the client's private data
+ */
+ authId = pClient->authId;
+ break;
+ }
+
+ if (authId == None)
+ return;
+
+ pAuth = (SecurityAuthorizationPtr)SecurityLookupIDByType(pClient,
+ authId, SecurityAuthorizationResType, SecurityReadAccess);
+
+ if (pAuth == NULL)
+ return;
+
+ for (pAppGrp = appGrpList; pAppGrp != NULL; pAppGrp = pAppGrp->next)
+ if (pAppGrp->appgroupId == pAuth->group) break;
+ } else {
+ pAppGrp = pClient->appgroup;
+ }
+
+ if (!pAppGrp)
+ return;
+
+ switch (pClient->clientState) {
+ case ClientStateAuthenticating:
+ case ClientStateRunning:
+ case ClientStateCheckingSecurity:
+ break;
+
+ case ClientStateInitial:
+ case ClientStateCheckedSecurity:
+ /* see the comment above about Initial vs. CheckedSecurity */
+ {
+ /* if this client already in AppGroup, don't add it again */
+ int i;
+ for (i = 0; i < pAppGrp->nclients; i++)
+ if (pClient == pAppGrp->clients[i]) return;
+ }
+ pAppGrp->clients = (ClientPtr*) xrealloc (pAppGrp->clients,
+ ++pAppGrp->nclients * sizeof (ClientPtr));
+ pAppGrp->clients[pAppGrp->nclients - 1] = pClient;
+ pClient->appgroup = pAppGrp;
+ break;
+
+ case ClientStateGone:
+ case ClientStateRetained: /* client disconnected, dump it */
+ {
+ int i;
+ for (i = 0; i < pAppGrp->nclients; i++)
+ if (pAppGrp->clients[i] == pClient) {
+ pAppGrp->clients[i] = NULL;
+ break;
+ }
+ for (i = 0; i < pAppGrp->nclients; i++)
+ if (pAppGrp->clients[i] == NULL && i + 1 < pAppGrp->nclients)
+ pAppGrp->clients[i] = pAppGrp->clients[i + 1];
+ pAppGrp->nclients--;
+ }
+ pClient->appgroup = NULL; /* redundant, pClient will be freed */
+ break;
+ }
+}
+
+void
+XagExtensionInit(INITARGS)
+{
+#if 0
+ ExtensionEntry* extEntry;
+
+ if ((extEntry = AddExtension (XAGNAME,
+ 0,
+ XagNumberErrors,
+ ProcXagDispatch,
+ SProcXagDispatch,
+ XagResetProc,
+ StandardMinorOpcode))) {
+ XagReqCode = (unsigned char)extEntry->base;
+ XagErrorBase = extEntry->errorBase;
+#else
+ if (AddExtension (XAGNAME,
+ 0,
+ XagNumberErrors,
+ ProcXagDispatch,
+ SProcXagDispatch,
+ XagResetProc,
+ StandardMinorOpcode)) {
+#endif
+ RT_APPGROUP = CreateNewResourceType (XagAppGroupFree);
+ }
+}
+
+/*ARGSUSED*/
+static
+void XagResetProc(
+ ExtensionEntry* extEntry)
+{
+ DeleteCallback (&ClientStateCallback, XagClientStateChange, NULL);
+ XagCallbackRefCount = 0;
+ while (appGrpList) XagAppGroupFree ((pointer) appGrpList, 0);
+}
+
+static
+int ProcXagQueryVersion(
+ register ClientPtr client)
+{
+ /* REQUEST (xXagQueryVersionReq); */
+ xXagQueryVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH (xXagQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequence_number = client->sequence;
+ rep.server_major_version = XAG_MAJOR_VERSION;
+ rep.server_minor_version = XAG_MINOR_VERSION;
+ if (client->swapped) {
+ swaps (&rep.sequence_number, n);
+ swapl (&rep.length, n);
+ swaps (&rep.server_major_version, n);
+ swaps (&rep.server_minor_version, n);
+ }
+ WriteToClient (client, sizeof (xXagQueryVersionReply), (char *)&rep);
+ return client->noClientException;
+}
+
+static
+void ProcessAttr(
+ AppGroupPtr pAppGrp,
+ ClientPtr client,
+ unsigned int attrib_mask,
+ CARD32* attribs)
+{
+ int i;
+
+ for (i = 0; i <= XagNappGroupLeader; i++) {
+ switch (attrib_mask & (1 << i)) {
+ case XagSingleScreenMask:
+ pAppGrp->single_screen = *attribs;
+ break;
+ case XagDefaultRootMask:
+ pAppGrp->default_root = *attribs;
+ break;
+ case XagRootVisualMask:
+ pAppGrp->root_visual = *attribs;
+ break;
+ case XagDefaultColormapMask:
+ pAppGrp->default_colormap = *attribs;
+ break;
+ case XagBlackPixelMask:
+ pAppGrp->black_pixel = *attribs;
+ break;
+ case XagWhitePixelMask:
+ pAppGrp->white_pixel = *attribs;
+ break;
+ case XagAppGroupLeaderMask:
+ pAppGrp->leader = client;
+ break;
+ default: continue;
+ }
+ attribs++;
+ }
+}
+
+static
+void CreateConnectionInfo(
+ AppGroupPtr pAppGrp)
+{
+ xWindowRoot* rootp;
+ xWindowRoot* roots[MAXSCREENS];
+ unsigned int rootlens[MAXSCREENS];
+ xDepth* depth;
+ int olen;
+ int snum, i;
+
+ rootp = (xWindowRoot*) (ConnectionInfo + connBlockScreenStart);
+ for (snum = 0; snum < screenInfo.numScreens; snum++) {
+
+ rootlens[snum] = sizeof (xWindowRoot);
+ roots[snum] = rootp;
+
+ depth = (xDepth*) (rootp + 1);
+ for (i = 0; i < rootp->nDepths; i++) {
+ rootlens[snum] += sizeof (xDepth) +
+ depth->nVisuals * sizeof (xVisualType);
+ depth = (xDepth *)(((char*)(depth + 1)) +
+ depth->nVisuals * sizeof (xVisualType));
+ }
+ rootp = (xWindowRoot*) depth;
+ }
+ snum = 0;
+ if (pAppGrp->default_root) {
+ for (; snum < screenInfo.numVideoScreens; snum++) {
+ if (roots[snum]->windowId == pAppGrp->default_root)
+ break;
+ }
+ }
+ olen = connBlockScreenStart + rootlens[snum];
+ for (i = screenInfo.numVideoScreens; i < screenInfo.numScreens; i++)
+ olen += rootlens[i];
+ pAppGrp->ConnectionInfo = (char*) xalloc (olen);
+ if (!pAppGrp->ConnectionInfo)
+ return;
+ memmove (pAppGrp->ConnectionInfo, ConnectionInfo, connBlockScreenStart);
+ ((xConnSetup*) (pAppGrp->ConnectionInfo))->numRoots =
+ 1 + screenInfo.numScreens - screenInfo.numVideoScreens;
+ memmove (pAppGrp->ConnectionInfo + connBlockScreenStart,
+ (void*) roots[snum], rootlens[snum]);
+ rootp = (xWindowRoot*) (pAppGrp->ConnectionInfo + connBlockScreenStart);
+ if (pAppGrp->default_colormap) {
+ rootp->defaultColormap = pAppGrp->default_colormap;
+ rootp->whitePixel = pAppGrp->white_pixel;
+ rootp->blackPixel = pAppGrp->black_pixel;
+ }
+ if (pAppGrp->root_visual)
+ rootp->rootVisualID = pAppGrp->root_visual;
+ rootp = (xWindowRoot*) (((char*)rootp) + rootlens[snum]);
+ for (i = screenInfo.numVideoScreens; i < screenInfo.numScreens; i++) {
+ memmove ((void*) rootp, (void*) roots[i], rootlens[i]);
+ rootp = (xWindowRoot*) (((char*) rootp) + rootlens[i]);
+ }
+ pAppGrp->connSetupPrefix = connSetupPrefix;
+ pAppGrp->connSetupPrefix.length = olen >> 2;
+}
+
+static
+AppGroupPtr CreateAppGroup(
+ ClientPtr client,
+ XID appgroupId,
+ unsigned int attrib_mask,
+ CARD32* attribs)
+{
+ AppGroupPtr pAppGrp;
+
+ pAppGrp = (AppGroupPtr) xalloc (sizeof(AppGroupRec));
+ if (pAppGrp) {
+ pAppGrp->next = appGrpList;
+ appGrpList = pAppGrp;
+ pAppGrp->appgroupId = appgroupId;
+ pAppGrp->clients = (ClientPtr*) xalloc (0);
+ pAppGrp->nclients = 0;
+ pAppGrp->leader = NULL;
+ pAppGrp->default_root = 0;
+ pAppGrp->root_visual = 0;
+ pAppGrp->default_colormap = 0;
+ pAppGrp->black_pixel = -1;
+ pAppGrp->white_pixel = -1;
+ pAppGrp->ConnectionInfo = NULL;
+ ProcessAttr (pAppGrp, client, attrib_mask, attribs);
+ }
+ return pAppGrp;
+}
+
+static
+int AttrValidate(
+ ClientPtr client,
+ int attrib_mask,
+ AppGroupPtr pAppGrp)
+{
+ WindowPtr pWin;
+ int idepth, ivids, found;
+ ScreenPtr pScreen;
+ DepthPtr pDepth;
+ ColormapPtr pColormap;
+
+ pWin = LookupWindow (pAppGrp->default_root, client);
+ /* XXX check that pWin is not NULL */
+ pScreen = pWin->drawable.pScreen;
+ if (WindowTable[pScreen->myNum]->drawable.id != pAppGrp->default_root)
+ return BadWindow;
+ pDepth = pScreen->allowedDepths;
+ if (pAppGrp->root_visual) {
+ found = FALSE;
+ for (idepth = 0; idepth < pScreen->numDepths; idepth++, pDepth++) {
+ for (ivids = 0; ivids < pDepth->numVids; ivids++) {
+ if (pAppGrp->root_visual == pDepth->vids[ivids]) {
+ found = TRUE;
+ break;
+ }
+ }
+ }
+ if (!found)
+ return BadMatch;
+ }
+ if (pAppGrp->default_colormap) {
+
+ pColormap = (ColormapPtr)LookupIDByType (pAppGrp->default_colormap, RT_COLORMAP);
+ /* XXX check that pColormap is not NULL */
+ if (pColormap->pScreen != pScreen)
+ return BadColor;
+ if (pColormap->pVisual->vid != (pAppGrp->root_visual ? pAppGrp->root_visual : pScreen->rootVisual))
+ return BadMatch;
+ }
+ return client->noClientException;
+}
+
+/* static */
+int ProcXagCreate (
+ register ClientPtr client)
+{
+ REQUEST (xXagCreateReq);
+ AppGroupPtr pAppGrp;
+ int ret;
+
+ REQUEST_AT_LEAST_SIZE (xXagCreateReq);
+
+ LEGAL_NEW_RESOURCE (stuff->app_group, client);
+ pAppGrp = CreateAppGroup (client, stuff->app_group,
+ stuff->attrib_mask, (CARD32*) &stuff[1]);
+ if (!pAppGrp)
+ return BadAlloc;
+ ret = AttrValidate (client, stuff->attrib_mask, pAppGrp);
+ if (ret != Success) {
+ XagAppGroupFree ((pointer)pAppGrp, (XID)0);
+ return ret;
+ }
+ if (pAppGrp->single_screen) {
+ CreateConnectionInfo (pAppGrp);
+ if (!pAppGrp->ConnectionInfo)
+ return BadAlloc;
+ }
+ if (!AddResource (stuff->app_group, RT_APPGROUP, (pointer)pAppGrp))
+ return BadAlloc;
+ if (XagCallbackRefCount++ == 0)
+ (void) AddCallback (&ClientStateCallback, XagClientStateChange, NULL);
+ return client->noClientException;
+}
+
+/* static */
+int ProcXagDestroy(
+ register ClientPtr client)
+{
+ AppGroupPtr pAppGrp;
+ REQUEST (xXagDestroyReq);
+
+ REQUEST_SIZE_MATCH (xXagDestroyReq);
+ pAppGrp = (AppGroupPtr)SecurityLookupIDByType (client,
+ (XID)stuff->app_group, RT_APPGROUP, SecurityReadAccess);
+ if (!pAppGrp) return XagBadAppGroup;
+ FreeResource ((XID)stuff->app_group, RT_NONE);
+ if (--XagCallbackRefCount == 0)
+ (void) DeleteCallback (&ClientStateCallback, XagClientStateChange, NULL);
+ return client->noClientException;
+}
+
+static
+int ProcXagGetAttr(
+ register ClientPtr client)
+{
+ AppGroupPtr pAppGrp;
+ REQUEST (xXagGetAttrReq);
+ xXagGetAttrReply rep;
+ int n;
+
+ REQUEST_SIZE_MATCH (xXagGetAttrReq);
+ pAppGrp = (AppGroupPtr)SecurityLookupIDByType (client,
+ (XID)stuff->app_group, RT_APPGROUP, SecurityReadAccess);
+ if (!pAppGrp) return XagBadAppGroup;
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequence_number = client->sequence;
+ rep.default_root = pAppGrp->default_root;
+ rep.root_visual = pAppGrp->root_visual;
+ rep.default_colormap = pAppGrp->default_colormap;
+ rep.black_pixel = pAppGrp->black_pixel;
+ rep.white_pixel = pAppGrp->white_pixel;
+ rep.single_screen = pAppGrp->single_screen;
+ rep.app_group_leader = (pAppGrp->leader) ? 1 : 0;
+ if (client->swapped) {
+ swaps (&rep.sequence_number, n);
+ swapl (&rep.length, n);
+ swapl (&rep.default_root, n);
+ swapl (&rep.root_visual, n);
+ swapl (&rep.default_colormap, n);
+ swapl (&rep.black_pixel, n);
+ swapl (&rep.white_pixel, n);
+ }
+ WriteToClient (client, sizeof (xXagGetAttrReply), (char *)&rep);
+ return client->noClientException;
+}
+
+static
+int ProcXagQuery(
+ register ClientPtr client)
+{
+ ClientPtr pClient;
+ AppGroupPtr pAppGrp;
+ REQUEST (xXagQueryReq);
+ int n;
+
+ REQUEST_SIZE_MATCH (xXagQueryReq);
+ pClient = LookupClient (stuff->resource, client);
+ for (pAppGrp = appGrpList; pAppGrp != NULL; pAppGrp = pAppGrp->next)
+ for (n = 0; n < pAppGrp->nclients; n++)
+ if (pAppGrp->clients[n] == pClient) {
+ xXagQueryReply rep;
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequence_number = client->sequence;
+ rep.app_group = pAppGrp->appgroupId;
+ if (client->swapped) {
+ swaps (&rep.sequence_number, n);
+ swapl (&rep.length, n);
+ swapl (&rep.app_group, n);
+ }
+ WriteToClient (client, sizeof (xXagQueryReply), (char *)&rep);
+ return client->noClientException;
+ }
+
+ return BadMatch;
+}
+
+static
+int ProcXagCreateAssoc(
+ register ClientPtr client)
+{
+ REQUEST (xXagCreateAssocReq);
+
+ REQUEST_SIZE_MATCH (xXagCreateAssocReq);
+#ifdef WIN32
+ if (stuff->window_type != XagWindowTypeWin32)
+#else
+ if (stuff->window_type != XagWindowTypeX11)
+#endif
+ return BadMatch;
+#if defined(WIN32) || defined(__CYGWIN__) /* and Mac, etc */
+ if (!LocalClient (client))
+ return BadAccess;
+#endif
+
+/* Macintosh, OS/2, and MS-Windows servers have some work to do here */
+
+ return client->noClientException;
+}
+
+static
+int ProcXagDestroyAssoc(
+ register ClientPtr client)
+{
+ /* REQUEST (xXagDestroyAssocReq); */
+
+ REQUEST_SIZE_MATCH (xXagDestroyAssocReq);
+/* Macintosh, OS/2, and MS-Windows servers have some work to do here */
+ return client->noClientException;
+}
+
+static
+int ProcXagDispatch (
+ register ClientPtr client)
+{
+ REQUEST (xReq);
+ switch (stuff->data)
+ {
+ case X_XagQueryVersion:
+ return ProcXagQueryVersion (client);
+ case X_XagCreate:
+ return ProcXagCreate (client);
+ case X_XagDestroy:
+ return ProcXagDestroy (client);
+ case X_XagGetAttr:
+ return ProcXagGetAttr (client);
+ case X_XagQuery:
+ return ProcXagQuery (client);
+ case X_XagCreateAssoc:
+ return ProcXagCreateAssoc (client);
+ case X_XagDestroyAssoc:
+ return ProcXagDestroyAssoc (client);
+ default:
+ return BadRequest;
+ }
+}
+
+static
+int SProcXagQueryVersion(
+ register ClientPtr client)
+{
+ register int n;
+ REQUEST(xXagQueryVersionReq);
+ swaps(&stuff->length, n);
+ return ProcXagQueryVersion(client);
+}
+
+static
+int SProcXagCreate(
+ ClientPtr client)
+{
+ register int n;
+ REQUEST (xXagCreateReq);
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE (xXagCreateReq);
+ swapl (&stuff->app_group, n);
+ swapl (&stuff->attrib_mask, n);
+ SwapRestL (stuff);
+ return ProcXagCreate (client);
+}
+
+static
+int SProcXagDestroy(
+ ClientPtr client)
+{
+ register int n;
+ REQUEST (xXagDestroyReq);
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH (xXagDestroyReq);
+ swapl (&stuff->app_group, n);
+ return ProcXagDestroy (client);
+}
+
+static
+int SProcXagGetAttr(
+ ClientPtr client)
+{
+ register int n;
+ REQUEST (xXagGetAttrReq);
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH (xXagGetAttrReq);
+ swapl (&stuff->app_group, n);
+ return ProcXagGetAttr (client);
+}
+
+static
+int SProcXagQuery(
+ ClientPtr client)
+{
+ register int n;
+ REQUEST (xXagQueryReq);
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH (xXagQueryReq);
+ swapl (&stuff->resource, n);
+ return ProcXagQuery (client);
+}
+
+static
+int SProcXagCreateAssoc(
+ ClientPtr client)
+{
+ register int n;
+ REQUEST (xXagCreateAssocReq);
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH (xXagCreateAssocReq);
+ swapl (&stuff->window, n);
+ swapl (&stuff->window_type, n);
+ swaps (&stuff->system_window_len, n);
+ return ProcXagCreateAssoc (client);
+}
+
+static
+int SProcXagDestroyAssoc(
+ ClientPtr client)
+{
+ register int n;
+ REQUEST (xXagDestroyAssocReq);
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH (xXagDestroyAssocReq);
+ swapl (&stuff->window, n);
+ return ProcXagDestroyAssoc (client);
+}
+
+static
+int SProcXagDispatch(
+ register ClientPtr client)
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_XagQueryVersion:
+ return SProcXagQueryVersion (client);
+ case X_XagCreate:
+ return SProcXagCreate (client);
+ case X_XagDestroy:
+ return SProcXagDestroy (client);
+ case X_XagGetAttr:
+ return SProcXagGetAttr (client);
+ case X_XagQuery:
+ return SProcXagQuery (client);
+ case X_XagCreateAssoc:
+ return SProcXagCreateAssoc (client);
+ case X_XagDestroyAssoc:
+ return SProcXagDestroyAssoc (client);
+ default:
+ return BadRequest;
+ }
+}
+
+Colormap XagDefaultColormap(
+ ClientPtr client)
+{
+ return (client->appgroup ? client->appgroup->default_colormap : None);
+}
+
+VisualID XagRootVisual(
+ ClientPtr client)
+{
+ return (client->appgroup ? client->appgroup->root_visual : 0);
+}
+
+ClientPtr XagLeader(
+ ClientPtr client)
+{
+ return (client->appgroup ? client->appgroup->leader : NULL);
+}
+
+/*
+ * Return whether the Map request event should be sent to the appgroup leader.
+ * We don't want to send it to the leader when the window is on a different
+ * screen, e.g. a print screen.
+ */
+Bool XagIsControlledRoot(
+ ClientPtr client,
+ WindowPtr pParent)
+{
+ if (client->appgroup) {
+ if (client->appgroup->single_screen &&
+ pParent->drawable.id == client->appgroup->default_root)
+ return TRUE;
+ else if (!pParent->parent)
+ return TRUE;
+ else
+ return FALSE;
+ }
+ return FALSE;
+}
+
+void XagConnectionInfo(
+ ClientPtr client,
+ xConnSetupPrefix** conn_prefix,
+ char** conn_info,
+ int* num_screen)
+{
+ if (client->appgroup && client->appgroup->ConnectionInfo) {
+ *conn_prefix = &client->appgroup->connSetupPrefix;
+ *conn_info = client->appgroup->ConnectionInfo;
+ *num_screen = ((xConnSetup*)(client->appgroup->ConnectionInfo))->numRoots;
+ }
+}
+
+XID XagId(
+ ClientPtr client)
+{
+ return (client->appgroup ? client->appgroup->appgroupId : 0);
+}
+
+void XagGetDeltaInfo(
+ ClientPtr client,
+ CARD32* buf)
+{
+ *buf++ = (CARD32) client->appgroup->default_root;
+ *buf++ = (CARD32) client->appgroup->root_visual;
+ *buf++ = (CARD32) client->appgroup->default_colormap;
+ *buf++ = (CARD32) client->appgroup->black_pixel;
+ *buf = (CARD32) client->appgroup->white_pixel;
+}
+
+void XagCallClientStateChange(
+ ClientPtr client)
+{
+ if (appGrpList) {
+ NewClientInfoRec clientinfo;
+
+ clientinfo.client = client;
+ XagClientStateChange (NULL, NULL, (pointer)&clientinfo);
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xext/appgroup.h b/nx-X11/programs/Xserver/Xext/appgroup.h
new file mode 100644
index 000000000..05c9ef124
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/appgroup.h
@@ -0,0 +1,10 @@
+/* $XFree86$ */
+
+void XagClientStateChange(
+ CallbackListPtr* pcbl,
+ pointer nulldata,
+ pointer calldata);
+int ProcXagCreate (
+ register ClientPtr client);
+int ProcXagDestroy(
+ register ClientPtr client);
diff --git a/nx-X11/programs/Xserver/Xext/bigreq.c b/nx-X11/programs/Xserver/Xext/bigreq.c
new file mode 100644
index 000000000..1af8a930b
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/bigreq.c
@@ -0,0 +1,107 @@
+/* $Xorg: bigreq.c,v 1.4 2001/02/09 02:04:32 xorgcvs Exp $ */
+/*
+
+Copyright 1992, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/Xext/bigreq.c,v 3.8 2003/10/28 23:08:43 tsi Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include <X11/extensions/bigreqstr.h>
+#include "opaque.h"
+#include "modinit.h"
+
+#if 0
+static unsigned char XBigReqCode;
+#endif
+
+static void BigReqResetProc(
+ ExtensionEntry * /* extEntry */
+);
+
+static DISPATCH_PROC(ProcBigReqDispatch);
+
+void
+BigReqExtensionInit(INITARGS)
+{
+#if 0
+ ExtensionEntry *extEntry;
+
+ if ((extEntry = AddExtension(XBigReqExtensionName, 0, 0,
+ ProcBigReqDispatch, ProcBigReqDispatch,
+ BigReqResetProc, StandardMinorOpcode)) != 0)
+ XBigReqCode = (unsigned char)extEntry->base;
+#else
+ (void) AddExtension(XBigReqExtensionName, 0, 0,
+ ProcBigReqDispatch, ProcBigReqDispatch,
+ BigReqResetProc, StandardMinorOpcode);
+#endif
+
+ DeclareExtensionSecurity(XBigReqExtensionName, TRUE);
+}
+
+/*ARGSUSED*/
+static void
+BigReqResetProc (extEntry)
+ ExtensionEntry *extEntry;
+{
+}
+
+static int
+ProcBigReqDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xBigReqEnableReq);
+ xBigReqEnableReply rep;
+ register int n;
+
+ if (client->swapped) {
+ swaps(&stuff->length, n);
+ }
+ if (stuff->brReqType != X_BigReqEnable)
+ return BadRequest;
+ REQUEST_SIZE_MATCH(xBigReqEnableReq);
+ client->big_requests = TRUE;
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.max_request_size = maxBigRequestSize;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.max_request_size, n);
+ }
+ WriteToClient(client, sizeof(xBigReqEnableReply), (char *)&rep);
+ return(client->noClientException);
+}
diff --git a/nx-X11/programs/Xserver/Xext/cup.c b/nx-X11/programs/Xserver/Xext/cup.c
new file mode 100644
index 000000000..4db62cf15
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/cup.c
@@ -0,0 +1,364 @@
+/* $Xorg: cup.c,v 1.4 2001/02/09 02:04:32 xorgcvs Exp $ */
+/*
+
+Copyright 1997, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/Xext/cup.c,v 1.11tsi Exp $ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#include "swapreq.h"
+#define _XCUP_SERVER_
+#include <X11/extensions/Xcupstr.h>
+#include <X11/Xfuncproto.h>
+
+#ifndef EXTMODULE
+#include "../os/osdep.h"
+#else
+#include "xf86_ansic.h"
+#endif
+
+#include "modinit.h"
+
+static int ProcDispatch(ClientPtr client);
+static int SProcDispatch(ClientPtr client);
+static void ResetProc(ExtensionEntry* extEntry);
+
+#if 0
+static unsigned char ReqCode = 0;
+static int ErrorBase;
+#endif
+
+#if defined(WIN32) || defined(TESTWIN32)
+#define HAVE_SPECIAL_DESKTOP_COLORS
+#endif
+
+static xColorItem citems[] = {
+#ifndef HAVE_SPECIAL_DESKTOP_COLORS
+#define CUP_BLACK_PIXEL 0
+#define CUP_WHITE_PIXEL 1
+ /* pix red green blue */
+ { 0, 0, 0, 0, 0, 0 },
+ { 1, 0xffff, 0xffff, 0xffff, 0, 0 }
+#else
+#ifndef WIN32
+ /*
+ This approximates the MS-Windows desktop colormap for testing
+ purposes but has black and white pixels in the typical Unix
+ locations, which should be switched if necessary if your system
+ has blackPixel and whitePixel swapped. No entries are provided
+ for colormap entries 254 and 255 because AllocColor/FindColor
+ will reuse entries zero and one.
+ */
+ { 0, 0, 0, 0, 0, 0 },
+ { 1, 0xffff, 0xffff, 0xffff, 0, 0 },
+ { 2, 0x8000, 0, 0, 0, 0 },
+ { 3, 0, 0x8000, 0, 0, 0 },
+ { 4, 0x8000, 0x8000, 0, 0, 0 },
+ { 5, 0, 0, 0x8000, 0, 0 },
+ { 6, 0x8000, 0, 0x8000, 0, 0 },
+ { 7, 0, 0x8000, 0x8000, 0, 0 },
+ { 8, 0xc000, 0xc000, 0xc000, 0, 0 },
+ { 9, 0xc000, 0xdc00, 0xc000, 0, 0 },
+ { 246, 0xa000, 0xa000, 0xa000, 0, 0 },
+ { 247, 0x8000, 0x8000, 0x8000, 0, 0 },
+ { 248, 0xffff, 0, 0, 0, 0 },
+ { 249, 0, 0xffff, 0, 0, 0 },
+ { 250, 0xffff, 0xffff, 0, 0, 0 },
+ { 251, 0, 0, 0xffff, 0, 0 },
+ { 252, 0xffff, 0, 0xffff, 0, 0 },
+ { 253, 0, 0xffff, 0xffff, 0, 0 }
+#else
+ /*
+ this is the MS-Windows desktop, adjusted for X's 16-bit color
+ specifications.
+ */
+ { 0, 0, 0, 0, 0, 0 },
+ { 1, 0x8000, 0, 0, 0, 0 },
+ { 2, 0, 0x8000, 0, 0, 0 },
+ { 3, 0x8000, 0x8000, 0, 0, 0 },
+ { 4, 0, 0, 0x8000, 0, 0 },
+ { 5, 0x8000, 0, 0x8000, 0, 0 },
+ { 6, 0, 0x8000, 0x8000, 0, 0 },
+ { 7, 0xc000, 0xc000, 0xc000, 0, 0 },
+ { 8, 0xc000, 0xdc00, 0xc000, 0, 0 },
+ { 9, 0xa600, 0xca00, 0xf000, 0, 0 },
+ { 246, 0xff00, 0xfb00, 0xf000, 0, 0 },
+ { 247, 0xa000, 0xa000, 0xa400, 0, 0 },
+ { 248, 0x8000, 0x8000, 0x8000, 0, 0 },
+ { 249, 0xff00, 0, 0, 0, 0 },
+ { 250, 0, 0xff00, 0, 0, 0 },
+ { 251, 0xff00, 0xff00, 0, 0, 0 },
+ { 252, 0, 0, 0xff00, 0, 0 },
+ { 253, 0xff00, 0, 0xff00, 0, 0 },
+ { 254, 0, 0xff00, 0xff00, 0, 0 },
+ { 255, 0xff00, 0xff00, 0xff00, 0, 0 }
+#endif
+#endif
+};
+#define NUM_DESKTOP_COLORS (sizeof citems / sizeof citems[0])
+
+void
+XcupExtensionInit (INITARGS)
+{
+#if 0
+ ExtensionEntry* extEntry;
+
+ if ((extEntry = AddExtension (XCUPNAME,
+ 0,
+ XcupNumberErrors,
+ ProcDispatch,
+ SProcDispatch,
+ ResetProc,
+ StandardMinorOpcode))) {
+ ReqCode = (unsigned char)extEntry->base;
+ ErrorBase = extEntry->errorBase;
+ }
+#else
+ (void) AddExtension (XCUPNAME,
+ 0,
+ XcupNumberErrors,
+ ProcDispatch,
+ SProcDispatch,
+ ResetProc,
+ StandardMinorOpcode);
+#endif
+
+ /* PC servers initialize the desktop colors (citems) here! */
+}
+
+/*ARGSUSED*/
+static
+void ResetProc(
+ ExtensionEntry* extEntry)
+{
+}
+
+static
+int ProcQueryVersion(
+ register ClientPtr client)
+{
+ /* REQUEST (xXcupQueryVersionReq); */
+ xXcupQueryVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH (xXcupQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequence_number = client->sequence;
+ rep.server_major_version = XCUP_MAJOR_VERSION;
+ rep.server_minor_version = XCUP_MINOR_VERSION;
+ if (client->swapped) {
+ swaps (&rep.sequence_number, n);
+ swapl (&rep.length, n);
+ swaps (&rep.server_major_version, n);
+ swaps (&rep.server_minor_version, n);
+ }
+ WriteToClient (client, sizeof (xXcupQueryVersionReply), (char *)&rep);
+ return client->noClientException;
+}
+
+static
+int ProcGetReservedColormapEntries(
+ register ClientPtr client)
+{
+ REQUEST (xXcupGetReservedColormapEntriesReq);
+ xXcupGetReservedColormapEntriesReply rep;
+ xColorItem* cptr;
+ register int n;
+
+ REQUEST_SIZE_MATCH (xXcupGetReservedColormapEntriesReq);
+
+#ifndef HAVE_SPECIAL_DESKTOP_COLORS
+ citems[CUP_BLACK_PIXEL].pixel =
+ screenInfo.screens[stuff->screen]->blackPixel;
+ citems[CUP_WHITE_PIXEL].pixel =
+ screenInfo.screens[stuff->screen]->whitePixel;
+#endif
+
+ rep.type = X_Reply;
+ rep.sequence_number = client->sequence;
+ rep.length = NUM_DESKTOP_COLORS * 3;
+ if (client->swapped) {
+ swaps (&rep.sequence_number, n);
+ swapl (&rep.length, n);
+ }
+ WriteToClient (client, sizeof (xXcupGetReservedColormapEntriesReply), (char *)&rep);
+ for (n = 0, cptr = citems; n < NUM_DESKTOP_COLORS; n++, cptr++) {
+ if (client->swapped) SwapColorItem (cptr);
+ WriteToClient (client, SIZEOF(xColorItem), (char *)cptr);
+ }
+ return client->noClientException;
+}
+
+static
+int ProcStoreColors(
+ register ClientPtr client)
+{
+ REQUEST (xXcupStoreColorsReq);
+ ColormapPtr pcmp;
+
+ REQUEST_AT_LEAST_SIZE (xXcupStoreColorsReq);
+ pcmp = (ColormapPtr) SecurityLookupIDByType (client, stuff->cmap,
+ RT_COLORMAP, SecurityWriteAccess);
+
+ if (pcmp) {
+ int ncolors, n;
+ xXcupStoreColorsReply rep;
+ xColorItem* cptr;
+
+ if (!(pcmp->class & DynamicClass))
+ return BadMatch;
+
+ ncolors = (client->req_len << 2) - SIZEOF (xXcupStoreColorsReq);
+ if (ncolors % SIZEOF(xColorItem))
+ return BadLength;
+
+ ncolors /= SIZEOF (xColorItem);
+
+
+ for (n = 0, cptr = (xColorItem*) &stuff[1]; n < ncolors; n++) {
+ Pixel pixel = cptr->pixel;
+
+ if (AllocColor (pcmp,
+ &cptr->red, &cptr->green, &cptr->blue,
+ &pixel, client->index) == Success) {
+ cptr->pixel = pixel;
+ cptr->flags = 0x08;
+ } else
+ cptr->flags = 0;
+ cptr = (xColorItem*) (((char*)cptr) + SIZEOF(xColorItem));
+ }
+
+ rep.type = X_Reply;
+ rep.sequence_number = client->sequence;
+ rep.length = ncolors * 3;
+ if (client->swapped) {
+ swaps (&rep.sequence_number, n);
+ swapl (&rep.length, n);
+ }
+ WriteToClient (client, sizeof (xXcupGetReservedColormapEntriesReply), (char *)&rep);
+ for (n = 0, cptr = (xColorItem*) &stuff[1]; n < ncolors; n++) {
+ if (client->swapped) SwapColorItem (cptr);
+ WriteToClient (client, SIZEOF(xColorItem), (char *)cptr);
+ cptr = (xColorItem*) (((char*)cptr) + SIZEOF(xColorItem));
+ }
+ return client->noClientException;
+ } else {
+ client->errorValue = stuff->cmap;
+ return BadColor;
+ }
+}
+
+static
+int ProcDispatch(
+ register ClientPtr client)
+{
+ REQUEST (xReq);
+ switch (stuff->data)
+ {
+ case X_XcupQueryVersion:
+ return ProcQueryVersion (client);
+ case X_XcupGetReservedColormapEntries:
+ return ProcGetReservedColormapEntries (client);
+ case X_XcupStoreColors:
+ return ProcStoreColors (client);
+ default:
+ return BadRequest;
+ }
+}
+
+static
+int SProcQueryVersion(
+ register ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xXcupQueryVersionReq);
+ swaps(&stuff->length, n);
+ return ProcQueryVersion(client);
+}
+
+static
+int SProcGetReservedColormapEntries(
+ ClientPtr client)
+{
+ register int n;
+
+ REQUEST (xXcupGetReservedColormapEntriesReq);
+ swaps (&stuff->length, n);
+ swapl (&stuff->screen, n);
+ REQUEST_AT_LEAST_SIZE (xXcupGetReservedColormapEntriesReq);
+ return ProcGetReservedColormapEntries (client);
+}
+
+static
+int SProcXcupStoreColors(
+ ClientPtr client)
+{
+ register int n;
+ int count;
+ xColorItem* pItem;
+
+ REQUEST (xXcupStoreColorsReq);
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE (xXcupStoreColorsReq);
+ swapl(&stuff->cmap, n);
+ pItem = (xColorItem*) &stuff[1];
+ for(count = LengthRestB(stuff)/sizeof(xColorItem); --count >= 0; )
+ SwapColorItem(pItem++);
+ return ProcStoreColors (client);
+}
+
+static
+int SProcDispatch(
+ register ClientPtr client)
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_XcupQueryVersion:
+ return SProcQueryVersion (client);
+ case X_XcupGetReservedColormapEntries:
+ return SProcGetReservedColormapEntries (client);
+ case X_XcupStoreColors:
+ return SProcXcupStoreColors (client);
+ default:
+ return BadRequest;
+ }
+}
+
+
diff --git a/nx-X11/programs/Xserver/Xext/dgaproc.h b/nx-X11/programs/Xserver/Xext/dgaproc.h
new file mode 100644
index 000000000..eb9791098
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/dgaproc.h
@@ -0,0 +1,144 @@
+/* $XFree86: xc/programs/Xserver/Xext/dgaproc.h,v 1.21 2000/06/30 19:06:54 keithp Exp $ */
+
+#ifndef __DGAPROC_H
+#define __DGAPROC_H
+
+#include <X11/Xproto.h>
+#include "pixmap.h"
+
+#define DGA_CONCURRENT_ACCESS 0x00000001
+#define DGA_FILL_RECT 0x00000002
+#define DGA_BLIT_RECT 0x00000004
+#define DGA_BLIT_RECT_TRANS 0x00000008
+#define DGA_PIXMAP_AVAILABLE 0x00000010
+
+#define DGA_INTERLACED 0x00010000
+#define DGA_DOUBLESCAN 0x00020000
+
+#define DGA_FLIP_IMMEDIATE 0x00000001
+#define DGA_FLIP_RETRACE 0x00000002
+
+#define DGA_COMPLETED 0x00000000
+#define DGA_PENDING 0x00000001
+
+#define DGA_NEED_ROOT 0x00000001
+
+typedef struct {
+ int num; /* A unique identifier for the mode (num > 0) */
+ char *name; /* name of mode given in the XF86Config */
+ int VSync_num;
+ int VSync_den;
+ int flags; /* DGA_CONCURRENT_ACCESS, etc... */
+ int imageWidth; /* linear accessible portion (pixels) */
+ int imageHeight;
+ int pixmapWidth; /* Xlib accessible portion (pixels) */
+ int pixmapHeight; /* both fields ignored if no concurrent access */
+ int bytesPerScanline;
+ int byteOrder; /* MSBFirst, LSBFirst */
+ int depth;
+ int bitsPerPixel;
+ unsigned long red_mask;
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ short visualClass;
+ int viewportWidth;
+ int viewportHeight;
+ int xViewportStep; /* viewport position granularity */
+ int yViewportStep;
+ int maxViewportX; /* max viewport origin */
+ int maxViewportY;
+ int viewportFlags; /* types of page flipping possible */
+ int offset;
+ int reserved1;
+ int reserved2;
+} XDGAModeRec, *XDGAModePtr;
+
+/* DDX interface */
+
+int
+DGASetMode(
+ int Index,
+ int num,
+ XDGAModePtr mode,
+ PixmapPtr *pPix
+);
+
+void
+DGASetInputMode(
+ int Index,
+ Bool keyboard,
+ Bool mouse
+);
+
+void
+DGASelectInput(
+ int Index,
+ ClientPtr client,
+ long mask
+);
+
+Bool DGAAvailable(int Index);
+Bool DGAActive(int Index);
+void DGAShutdown(void);
+void DGAInstallCmap(ColormapPtr cmap);
+int DGAGetViewportStatus(int Index);
+int DGASync(int Index);
+
+int
+DGAFillRect(
+ int Index,
+ int x, int y, int w, int h,
+ unsigned long color
+);
+
+int
+DGABlitRect(
+ int Index,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty
+);
+
+int
+DGABlitTransRect(
+ int Index,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty,
+ unsigned long color
+);
+
+int
+DGASetViewport(
+ int Index,
+ int x, int y,
+ int mode
+);
+
+int DGAGetModes(int Index);
+int DGAGetOldDGAMode(int Index);
+
+int DGAGetModeInfo(int Index, XDGAModePtr mode, int num);
+
+Bool DGAVTSwitch(void);
+Bool DGAStealMouseEvent(int Index, xEvent *e, int dx, int dy);
+Bool DGAStealKeyEvent(int Index, xEvent *e);
+Bool DGAIsDgaEvent (xEvent *e);
+
+Bool DGADeliverEvent (ScreenPtr pScreen, xEvent *e);
+
+Bool DGAOpenFramebuffer(int Index, char **name, unsigned char **mem,
+ int *size, int *offset, int *flags);
+void DGACloseFramebuffer(int Index);
+Bool DGAChangePixmapMode(int Index, int *x, int *y, int mode);
+int DGACreateColormap(int Index, ClientPtr client, int id, int mode,
+ int alloc);
+
+extern unsigned char DGAReqCode;
+extern int DGAErrorBase;
+extern int DGAEventBase;
+extern int *XDGAEventBase;
+
+
+
+#endif /* __DGAPROC_H */
diff --git a/nx-X11/programs/Xserver/Xext/dmx.c b/nx-X11/programs/Xserver/Xext/dmx.c
new file mode 100644
index 000000000..75623e696
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/dmx.c
@@ -0,0 +1,1133 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * This file implements the server-side part of the DMX protocol. A
+ * vector of fucntions is provided at extension initialization time, so
+ * most all of the useful functions in this file are declared static and
+ * do not appear in the doxygen documentation.
+ *
+ * Much of the low-level work is done by functions in #dmxextension.c
+ *
+ * Please see the Client-to-Server DMX Extension to the X Protocol
+ * document for details about the protocol. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#define EXTENSION_PROC_ARGS void *
+#include "extnsionst.h"
+#include "opaque.h"
+
+#include "dmxextension.h"
+#include <X11/extensions/dmxproto.h>
+
+#define _DMX_SERVER_
+#include <X11/extensions/dmxext.h>
+
+#ifdef PANORAMIX
+#include "panoramiX.h"
+extern unsigned long XRT_WINDOW;
+extern int PanoramiXNumScreens;
+#endif
+
+extern void DMXExtensionInit(void);
+
+static unsigned char DMXCode;
+
+static DISPATCH_PROC(ProcDMXDispatch);
+static DISPATCH_PROC(ProcDMXQueryVersion);
+static DISPATCH_PROC(ProcDMXSync);
+static DISPATCH_PROC(ProcDMXForceWindowCreation);
+static DISPATCH_PROC(ProcDMXGetScreenCount);
+static DISPATCH_PROC(ProcDMXGetScreenAttributes);
+static DISPATCH_PROC(ProcDMXChangeScreensAttributes);
+static DISPATCH_PROC(ProcDMXAddScreen);
+static DISPATCH_PROC(ProcDMXRemoveScreen);
+static DISPATCH_PROC(ProcDMXGetWindowAttributes);
+static DISPATCH_PROC(ProcDMXGetDesktopAttributes);
+static DISPATCH_PROC(ProcDMXChangeDesktopAttributes);
+static DISPATCH_PROC(ProcDMXGetInputCount);
+static DISPATCH_PROC(ProcDMXGetInputAttributes);
+static DISPATCH_PROC(ProcDMXAddInput);
+static DISPATCH_PROC(ProcDMXRemoveInput);
+
+static DISPATCH_PROC(SProcDMXDispatch);
+static DISPATCH_PROC(SProcDMXQueryVersion);
+static DISPATCH_PROC(SProcDMXSync);
+static DISPATCH_PROC(SProcDMXForceWindowCreation);
+static DISPATCH_PROC(SProcDMXGetScreenCount);
+static DISPATCH_PROC(SProcDMXGetScreenAttributes);
+static DISPATCH_PROC(SProcDMXChangeScreensAttributes);
+static DISPATCH_PROC(SProcDMXAddScreen);
+static DISPATCH_PROC(SProcDMXRemoveScreen);
+static DISPATCH_PROC(SProcDMXGetWindowAttributes);
+static DISPATCH_PROC(SProcDMXGetDesktopAttributes);
+static DISPATCH_PROC(SProcDMXChangeDesktopAttributes);
+static DISPATCH_PROC(SProcDMXGetInputCount);
+static DISPATCH_PROC(SProcDMXGetInputAttributes);
+static DISPATCH_PROC(SProcDMXAddInput);
+static DISPATCH_PROC(SProcDMXRemoveInput);
+
+static int _DMXXineramaActive(void)
+{
+#ifdef PANORAMIX
+ return !noPanoramiXExtension;
+#endif
+ return 0;
+}
+
+static void DMXResetProc(ExtensionEntry *extEntry)
+{
+}
+
+/** Initialize the extension. */
+void DMXExtensionInit(void)
+{
+ ExtensionEntry *extEntry;
+
+ if ((extEntry = AddExtension(DMX_EXTENSION_NAME, 0, 0,
+ ProcDMXDispatch, SProcDMXDispatch,
+ DMXResetProc, StandardMinorOpcode)))
+ DMXCode = extEntry->base;
+}
+
+static void dmxSetScreenAttribute(int bit, DMXScreenAttributesPtr attr,
+ CARD32 value)
+{
+ switch (1 << bit) {
+ case DMXScreenWindowWidth: attr->screenWindowWidth = value; break;
+ case DMXScreenWindowHeight: attr->screenWindowHeight = value; break;
+ case DMXScreenWindowXoffset: attr->screenWindowXoffset = value; break;
+ case DMXScreenWindowYoffset: attr->screenWindowYoffset = value; break;
+ case DMXRootWindowWidth: attr->rootWindowWidth = value; break;
+ case DMXRootWindowHeight: attr->rootWindowHeight = value; break;
+ case DMXRootWindowXoffset: attr->rootWindowXoffset = value; break;
+ case DMXRootWindowYoffset: attr->rootWindowYoffset = value; break;
+ case DMXRootWindowXorigin: attr->rootWindowXorigin = value; break;
+ case DMXRootWindowYorigin: attr->rootWindowYorigin = value; break;
+ }
+}
+
+static int dmxFetchScreenAttributes(unsigned int mask,
+ DMXScreenAttributesPtr attr,
+ CARD32 *value_list)
+{
+ int i;
+ CARD32 *value = value_list;
+ int count = 0;
+
+ for (i = 0; i < 32; i++) {
+ if (mask & (1 << i)) {
+ dmxSetScreenAttribute(i, attr, *value);
+ ++value;
+ ++count;
+ }
+ }
+ return count;
+}
+
+static void dmxSetDesktopAttribute(int bit, DMXDesktopAttributesPtr attr,
+ CARD32 value)
+{
+ switch (1 << bit) {
+ case DMXDesktopWidth: attr->width = value; break;
+ case DMXDesktopHeight: attr->height = value; break;
+ case DMXDesktopShiftX: attr->shiftX = value; break;
+ case DMXDesktopShiftY: attr->shiftY = value; break;
+ }
+}
+
+static int dmxFetchDesktopAttributes(unsigned int mask,
+ DMXDesktopAttributesPtr attr,
+ CARD32 *value_list)
+{
+ int i;
+ CARD32 *value = value_list;
+ int count = 0;
+
+ for (i = 0; i < 32; i++) {
+ if (mask & (1 << i)) {
+ dmxSetDesktopAttribute(i, attr, *value);
+ ++value;
+ ++count;
+ }
+ }
+ return count;
+}
+
+static void dmxSetInputAttribute(int bit, DMXInputAttributesPtr attr,
+ CARD32 value)
+{
+ switch (1 << bit) {
+ case DMXInputType: attr->inputType = value; break;
+ case DMXInputPhysicalScreen: attr->physicalScreen = value; break;
+ case DMXInputSendsCore: attr->sendsCore = !!value; break;
+ }
+}
+
+static int dmxFetchInputAttributes(unsigned int mask,
+ DMXInputAttributesPtr attr,
+ CARD32 *value_list)
+{
+ int i;
+ CARD32 *value = value_list;
+ int count = 0;
+
+ for (i = 0; i < 32; i++) {
+ if (mask & (1 << i)) {
+ dmxSetInputAttribute(i, attr, *value);
+ ++value;
+ ++count;
+ }
+ }
+ return count;
+}
+
+static int ProcDMXQueryVersion(ClientPtr client)
+{
+ xDMXQueryVersionReply rep;
+ int n;
+
+ REQUEST_SIZE_MATCH(xDMXQueryVersionReq);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.majorVersion = DMX_EXTENSION_MAJOR;
+ rep.minorVersion = DMX_EXTENSION_MINOR;
+ rep.patchVersion = DMX_EXTENSION_PATCH;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.majorVersion, n);
+ swapl(&rep.minorVersion, n);
+ swapl(&rep.patchVersion, n);
+ }
+ WriteToClient(client, sizeof(xDMXQueryVersionReply), (char *)&rep);
+ return client->noClientException;
+}
+
+static int ProcDMXSync(ClientPtr client)
+{
+ xDMXSyncReply rep;
+ int n;
+
+ REQUEST_SIZE_MATCH(xDMXSyncReq);
+
+ dmxFlushPendingSyncs();
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.status = 0;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.status, n);
+ }
+ WriteToClient(client, sizeof(xDMXSyncReply), (char *)&rep);
+ return client->noClientException;
+}
+
+static int ProcDMXForceWindowCreation(ClientPtr client)
+{
+ xDMXForceWindowCreationReply rep;
+ REQUEST(xDMXForceWindowCreationReq);
+ WindowPtr pWin;
+ int n;
+
+ REQUEST_SIZE_MATCH(xDMXForceWindowCreationReq);
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ PanoramiXRes *win;
+ int i;
+
+ if (!(win = SecurityLookupIDByType(client, stuff->window, XRT_WINDOW,
+ SecurityReadAccess)))
+ return -1; /* BadWindow */
+
+ FOR_NSCREENS(i) {
+ if (!(pWin = SecurityLookupWindow(win->info[i].id, client,
+ SecurityReadAccess)))
+ return -1; /* BadWindow */
+
+ dmxForceWindowCreation(pWin);
+ }
+ goto doreply;
+ }
+#endif
+
+ if (!(pWin = SecurityLookupWindow(stuff->window, client,
+ SecurityReadAccess)))
+ return -1; /* BadWindow */
+
+ dmxForceWindowCreation(pWin);
+ doreply:
+ dmxFlushPendingSyncs();
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.status = 0;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.status, n);
+ }
+ WriteToClient(client, sizeof(xDMXForceWindowCreationReply), (char *)&rep);
+ return Success;
+}
+
+static int ProcDMXGetScreenCount(ClientPtr client)
+{
+ xDMXGetScreenCountReply rep;
+ int n;
+
+ REQUEST_SIZE_MATCH(xDMXGetScreenCountReq);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.screenCount = dmxGetNumScreens();
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.screenCount, n);
+ }
+ WriteToClient(client, sizeof(xDMXGetScreenCountReply), (char *)&rep);
+ return client->noClientException;
+}
+
+static int ProcDMXGetScreenAttributes(ClientPtr client)
+{
+ REQUEST(xDMXGetScreenAttributesReq);
+ xDMXGetScreenAttributesReply rep;
+ int n;
+ int length;
+ int paddedLength;
+ DMXScreenAttributesRec attr;
+
+ REQUEST_SIZE_MATCH(xDMXGetScreenAttributesReq);
+
+ if (stuff->physicalScreen < 0
+ || stuff->physicalScreen >= dmxGetNumScreens()) return BadValue;
+
+ if (!dmxGetScreenAttributes(stuff->physicalScreen, &attr))
+ return BadValue;
+
+ rep.logicalScreen = attr.logicalScreen;
+ rep.screenWindowWidth = attr.screenWindowWidth;
+ rep.screenWindowHeight = attr.screenWindowHeight;
+ rep.screenWindowXoffset = attr.screenWindowXoffset;
+ rep.screenWindowYoffset = attr.screenWindowYoffset;
+ rep.rootWindowWidth = attr.rootWindowWidth;
+ rep.rootWindowHeight = attr.rootWindowHeight;
+ rep.rootWindowXoffset = attr.rootWindowXoffset;
+ rep.rootWindowYoffset = attr.rootWindowYoffset;
+ rep.rootWindowXorigin = attr.rootWindowXorigin;
+ rep.rootWindowYorigin = attr.rootWindowYorigin;
+
+ length = attr.displayName ? strlen(attr.displayName) : 0;
+ paddedLength = (length + 3) & ~3;
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = paddedLength >> 2;
+ rep.displayNameLength = length;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.displayNameLength, n);
+ swapl(&rep.logicalScreen, n);
+ swaps(&rep.screenWindowWidth, n);
+ swaps(&rep.screenWindowHeight, n);
+ swaps(&rep.screenWindowXoffset, n);
+ swaps(&rep.screenWindowYoffset, n);
+ swaps(&rep.rootWindowWidth, n);
+ swaps(&rep.rootWindowHeight, n);
+ swaps(&rep.rootWindowXoffset, n);
+ swaps(&rep.rootWindowYoffset, n);
+ swaps(&rep.rootWindowXorigin, n);
+ swaps(&rep.rootWindowYorigin, n);
+ }
+ WriteToClient(client, sizeof(xDMXGetScreenAttributesReply), (char *)&rep);
+ if (length) WriteToClient(client, length, (char *)attr.displayName);
+ return client->noClientException;
+}
+
+static int ProcDMXChangeScreensAttributes(ClientPtr client)
+{
+ REQUEST(xDMXChangeScreensAttributesReq);
+ xDMXChangeScreensAttributesReply rep;
+ int n;
+ int status = DMX_BAD_XINERAMA;
+ unsigned int mask = 0;
+ unsigned int i;
+ CARD32 *screen_list;
+ CARD32 *mask_list;
+ CARD32 *value_list;
+ DMXScreenAttributesPtr attribs;
+ int errorScreen = 0;
+ unsigned int len;
+ int ones = 0;
+
+
+ REQUEST_AT_LEAST_SIZE(xDMXChangeScreensAttributesReq);
+ len = client->req_len - (sizeof(xDMXChangeScreensAttributesReq) >> 2);
+ if (len < stuff->screenCount + stuff->maskCount)
+ return BadLength;
+
+ screen_list = (CARD32 *)(stuff + 1);
+ mask_list = &screen_list[stuff->screenCount];
+ value_list = &mask_list[stuff->maskCount];
+
+ for (i = 0; i < stuff->maskCount; i++) ones += Ones(mask_list[i]);
+ if (len != stuff->screenCount + stuff->maskCount + ones)
+ return BadLength;
+
+ if (!_DMXXineramaActive()) goto noxinerama;
+
+ if (!(attribs = ALLOCATE_LOCAL(stuff->screenCount * sizeof(*attribs))))
+ return BadAlloc;
+
+ for (i = 0; i < stuff->screenCount; i++) {
+ int count;
+
+ if (i < stuff->maskCount) mask = mask_list[i];
+ dmxGetScreenAttributes(screen_list[i], &attribs[i]);
+ count = dmxFetchScreenAttributes(mask, &attribs[i], value_list);
+ value_list += count;
+ }
+
+#if PANORAMIX
+ status = dmxConfigureScreenWindows(stuff->screenCount,
+ screen_list,
+ attribs,
+ &errorScreen);
+#endif
+
+ DEALLOCATE_LOCAL(attribs);
+
+ if (status == BadValue) return status;
+
+ noxinerama:
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.status = status;
+ rep.errorScreen = errorScreen;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.status, n);
+ swapl(&rep.errorScreen, n);
+ }
+ WriteToClient(client,
+ sizeof(xDMXChangeScreensAttributesReply),
+ (char *)&rep);
+ return client->noClientException;
+}
+
+static int ProcDMXAddScreen(ClientPtr client)
+{
+ REQUEST(xDMXAddScreenReq);
+ xDMXAddScreenReply rep;
+ int n;
+ int status = 0;
+ CARD32 *value_list;
+ DMXScreenAttributesRec attr;
+ int count;
+ char *name;
+ int len;
+ int paddedLength;
+
+ REQUEST_AT_LEAST_SIZE(xDMXAddScreenReq);
+ paddedLength = (stuff->displayNameLength + 3) & ~3;
+ len = client->req_len - (sizeof(xDMXAddScreenReq) >> 2);
+ if (len != Ones(stuff->valueMask) + paddedLength/4)
+ return BadLength;
+
+ memset(&attr, 0, sizeof(attr));
+ dmxGetScreenAttributes(stuff->physicalScreen, &attr);
+ value_list = (CARD32 *)(stuff + 1);
+ count = dmxFetchScreenAttributes(stuff->valueMask, &attr, value_list);
+
+ if (!(name = ALLOCATE_LOCAL(stuff->displayNameLength + 1 + 4)))
+ return BadAlloc;
+ memcpy(name, &value_list[count], stuff->displayNameLength);
+ name[stuff->displayNameLength] = '\0';
+ attr.displayName = name;
+
+ status = dmxAttachScreen(stuff->physicalScreen, &attr);
+
+ DEALLOCATE_LOCAL(name);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.status = status;
+ rep.physicalScreen = stuff->physicalScreen;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.status, n);
+ swapl(&rep.physicalScreen, n);
+ }
+ WriteToClient(client,
+ sizeof(xDMXAddScreenReply),
+ (char *)&rep);
+ return client->noClientException;
+}
+
+static int ProcDMXRemoveScreen(ClientPtr client)
+{
+ REQUEST(xDMXRemoveScreenReq);
+ xDMXRemoveScreenReply rep;
+ int n;
+ int status = 0;
+
+ REQUEST_SIZE_MATCH(xDMXRemoveScreenReq);
+
+ status = dmxDetachScreen(stuff->physicalScreen);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.status = status;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.status, n);
+ }
+ WriteToClient(client,
+ sizeof(xDMXRemoveScreenReply),
+ (char *)&rep);
+ return client->noClientException;
+}
+
+
+#ifdef PANORAMIX
+static int dmxPopulatePanoramiX(ClientPtr client, Window window,
+ CARD32 *screens, CARD32 *windows,
+ xRectangle *pos, xRectangle *vis)
+{
+ WindowPtr pWin;
+ PanoramiXRes *win;
+ int i;
+ int count = 0;
+ DMXWindowAttributesRec attr;
+
+ if (!(win = SecurityLookupIDByType(client, window, XRT_WINDOW,
+ SecurityReadAccess)))
+ return -1; /* BadWindow */
+
+ FOR_NSCREENS(i) {
+ if (!(pWin = SecurityLookupWindow(win->info[i].id, client,
+ SecurityReadAccess)))
+ return -1; /* BadWindow */
+ if (dmxGetWindowAttributes(pWin, &attr)) {
+ screens[count] = attr.screen;
+ windows[count] = attr.window;
+ pos[count] = attr.pos;
+ vis[count] = attr.vis;
+ ++count; /* Only count existing windows */
+ }
+ }
+ return count;
+}
+#endif
+
+static int dmxPopulate(ClientPtr client, Window window, CARD32 *screens,
+ CARD32 *windows, xRectangle *pos, xRectangle *vis)
+{
+ WindowPtr pWin;
+ DMXWindowAttributesRec attr;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension)
+ return dmxPopulatePanoramiX(client, window, screens, windows,
+ pos, vis);
+#endif
+
+ if (!(pWin = SecurityLookupWindow(window, client, SecurityReadAccess)))
+ return -1; /* BadWindow */
+
+ dmxGetWindowAttributes(pWin, &attr);
+ *screens = attr.screen;
+ *windows = attr.window;
+ *pos = attr.pos;
+ *vis = attr.vis;
+ return 1;
+}
+
+static int dmxMaxNumScreens(void)
+{
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) return PanoramiXNumScreens;
+#endif
+ return 1;
+}
+
+static int ProcDMXGetWindowAttributes(ClientPtr client)
+{
+ REQUEST(xDMXGetWindowAttributesReq);
+ xDMXGetWindowAttributesReply rep;
+ int i, n;
+ CARD32 *screens;
+ CARD32 *windows;
+ xRectangle *pos, *vis;
+ int count = dmxMaxNumScreens();
+
+ REQUEST_SIZE_MATCH(xDMXGetWindowAttributesReq);
+
+ if (!(screens = ALLOCATE_LOCAL(count * sizeof(*screens))))
+ return BadAlloc;
+ if (!(windows = ALLOCATE_LOCAL(count * sizeof(*windows)))) {
+ DEALLOCATE_LOCAL(screens);
+ return BadAlloc;
+ }
+ if (!(pos = ALLOCATE_LOCAL(count * sizeof(*pos)))) {
+ DEALLOCATE_LOCAL(windows);
+ DEALLOCATE_LOCAL(screens);
+ return BadAlloc;
+ }
+ if (!(vis = ALLOCATE_LOCAL(count * sizeof(*vis)))) {
+ DEALLOCATE_LOCAL(pos);
+ DEALLOCATE_LOCAL(windows);
+ DEALLOCATE_LOCAL(screens);
+ return BadAlloc;
+ }
+
+ if ((count = dmxPopulate(client, stuff->window, screens, windows,
+ pos, vis)) < 0) {
+ DEALLOCATE_LOCAL(vis);
+ DEALLOCATE_LOCAL(pos);
+ DEALLOCATE_LOCAL(windows);
+ DEALLOCATE_LOCAL(screens);
+ return BadWindow;
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = count * 6;
+ rep.screenCount = count;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.screenCount, n);
+ for (i = 0; i < count; i++) {
+ swapl(&screens[i], n);
+ swapl(&windows[i], n);
+
+ swaps(&pos[i].x, n);
+ swaps(&pos[i].y, n);
+ swaps(&pos[i].width, n);
+ swaps(&pos[i].height, n);
+
+ swaps(&vis[i].x, n);
+ swaps(&vis[i].y, n);
+ swaps(&vis[i].width, n);
+ swaps(&vis[i].height, n);
+ }
+ }
+
+ dmxFlushPendingSyncs();
+
+ WriteToClient(client, sizeof(xDMXGetWindowAttributesReply), (char *)&rep);
+ if (count) {
+ WriteToClient(client, count * sizeof(*screens), (char *)screens);
+ WriteToClient(client, count * sizeof(*windows), (char *)windows);
+ WriteToClient(client, count * sizeof(*pos), (char *)pos);
+ WriteToClient(client, count * sizeof(*vis), (char *)vis);
+ }
+
+ DEALLOCATE_LOCAL(vis);
+ DEALLOCATE_LOCAL(pos);
+ DEALLOCATE_LOCAL(windows);
+ DEALLOCATE_LOCAL(screens);
+
+ return client->noClientException;
+}
+
+static int ProcDMXGetDesktopAttributes(ClientPtr client)
+{
+ xDMXGetDesktopAttributesReply rep;
+ int n;
+ DMXDesktopAttributesRec attr;
+
+ REQUEST_SIZE_MATCH(xDMXGetDesktopAttributesReq);
+
+ dmxGetDesktopAttributes(&attr);
+
+ rep.width = attr.width;
+ rep.height = attr.height;
+ rep.shiftX = attr.shiftX;
+ rep.shiftY = attr.shiftY;
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.width, n);
+ swapl(&rep.height, n);
+ swapl(&rep.shiftX, n);
+ swapl(&rep.shiftY, n);
+ }
+ WriteToClient(client, sizeof(xDMXGetDesktopAttributesReply), (char *)&rep);
+ return client->noClientException;
+}
+
+static int ProcDMXChangeDesktopAttributes(ClientPtr client)
+{
+ REQUEST(xDMXChangeDesktopAttributesReq);
+ xDMXChangeDesktopAttributesReply rep;
+ int n;
+ int status = DMX_BAD_XINERAMA;
+ CARD32 *value_list;
+ DMXDesktopAttributesRec attr;
+ int len;
+
+ REQUEST_AT_LEAST_SIZE(xDMXChangeDesktopAttributesReq);
+ len = client->req_len - (sizeof(xDMXChangeDesktopAttributesReq) >> 2);
+ if (len != Ones(stuff->valueMask))
+ return BadLength;
+
+ if (!_DMXXineramaActive()) goto noxinerama;
+
+ value_list = (CARD32 *)(stuff + 1);
+
+ dmxGetDesktopAttributes(&attr);
+ dmxFetchDesktopAttributes(stuff->valueMask, &attr, value_list);
+
+#if PANORAMIX
+ status = dmxConfigureDesktop(&attr);
+#endif
+ if (status == BadValue) return status;
+
+ noxinerama:
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.status = status;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.status, n);
+ }
+ WriteToClient(client,
+ sizeof(xDMXChangeDesktopAttributesReply),
+ (char *)&rep);
+ return client->noClientException;
+}
+
+static int ProcDMXGetInputCount(ClientPtr client)
+{
+ xDMXGetInputCountReply rep;
+ int n;
+
+ REQUEST_SIZE_MATCH(xDMXGetInputCountReq);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.inputCount = dmxGetInputCount();
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.inputCount, n);
+ }
+ WriteToClient(client, sizeof(xDMXGetInputCountReply), (char *)&rep);
+ return client->noClientException;
+}
+
+static int ProcDMXGetInputAttributes(ClientPtr client)
+{
+ REQUEST(xDMXGetInputAttributesReq);
+ xDMXGetInputAttributesReply rep;
+ int n;
+ int length;
+ int paddedLength;
+ DMXInputAttributesRec attr;
+
+ REQUEST_SIZE_MATCH(xDMXGetInputAttributesReq);
+
+ if (dmxGetInputAttributes(stuff->deviceId, &attr)) return BadValue;
+ rep.inputType = attr.inputType;
+ rep.physicalScreen = attr.physicalScreen;
+ rep.physicalId = attr.physicalId;
+ rep.isCore = attr.isCore;
+ rep.sendsCore = attr.sendsCore;
+ rep.detached = attr.detached;
+
+ length = attr.name ? strlen(attr.name) : 0;
+ paddedLength = (length + 3) & ~3;
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = paddedLength >> 2;
+ rep.nameLength = length;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.inputType, n);
+ swapl(&rep.physicalScreen, n);
+ swapl(&rep.physicalId, n);
+ swapl(&rep.nameLength, n);
+ }
+ WriteToClient(client, sizeof(xDMXGetInputAttributesReply), (char *)&rep);
+ if (length) WriteToClient(client, length, (char *)attr.name);
+ return client->noClientException;
+}
+
+static int ProcDMXAddInput(ClientPtr client)
+{
+ REQUEST(xDMXAddInputReq);
+ xDMXAddInputReply rep;
+ int n;
+ int status = 0;
+ CARD32 *value_list;
+ DMXInputAttributesRec attr;
+ int count;
+ char *name;
+ int len;
+ int paddedLength;
+ int id = -1;
+
+ REQUEST_AT_LEAST_SIZE(xDMXAddInputReq);
+ paddedLength = (stuff->displayNameLength + 3) & ~3;
+ len = client->req_len - (sizeof(xDMXAddInputReq) >> 2);
+ if (len != Ones(stuff->valueMask) + paddedLength/4)
+ return BadLength;
+
+ memset(&attr, 0, sizeof(attr));
+ value_list = (CARD32 *)(stuff + 1);
+ count = dmxFetchInputAttributes(stuff->valueMask, &attr, value_list);
+
+ if (!(name = ALLOCATE_LOCAL(stuff->displayNameLength + 1 + 4)))
+ return BadAlloc;
+ memcpy(name, &value_list[count], stuff->displayNameLength);
+ name[stuff->displayNameLength] = '\0';
+ attr.name = name;
+
+ status = dmxAddInput(&attr, &id);
+
+ DEALLOCATE_LOCAL(name);
+
+ if (status) return status;
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.status = status;
+ rep.physicalId = id;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.status, n);
+ swapl(&rep.physicalId, n);
+ }
+ WriteToClient(client, sizeof(xDMXAddInputReply), (char *)&rep);
+ return client->noClientException;
+}
+
+static int ProcDMXRemoveInput(ClientPtr client)
+{
+ REQUEST(xDMXRemoveInputReq);
+ xDMXRemoveInputReply rep;
+ int n;
+ int status = 0;
+
+ REQUEST_SIZE_MATCH(xDMXRemoveInputReq);
+
+ status = dmxRemoveInput(stuff->physicalId);
+
+ if (status) return status;
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.status = status;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.status, n);
+ }
+ WriteToClient(client, sizeof(xDMXRemoveInputReply), (char *)&rep);
+ return client->noClientException;
+}
+
+static int ProcDMXDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data) {
+ case X_DMXQueryVersion: return ProcDMXQueryVersion(client);
+ case X_DMXSync: return ProcDMXSync(client);
+ case X_DMXForceWindowCreation: return ProcDMXForceWindowCreation(client);
+ case X_DMXGetScreenCount: return ProcDMXGetScreenCount(client);
+ case X_DMXGetScreenAttributes: return ProcDMXGetScreenAttributes(client);
+ case X_DMXChangeScreensAttributes:
+ return ProcDMXChangeScreensAttributes(client);
+ case X_DMXAddScreen: return ProcDMXAddScreen(client);
+ case X_DMXRemoveScreen: return ProcDMXRemoveScreen(client);
+ case X_DMXGetWindowAttributes: return ProcDMXGetWindowAttributes(client);
+ case X_DMXGetDesktopAttributes: return ProcDMXGetDesktopAttributes(client);
+ case X_DMXChangeDesktopAttributes:
+ return ProcDMXChangeDesktopAttributes(client);
+ case X_DMXGetInputCount: return ProcDMXGetInputCount(client);
+ case X_DMXGetInputAttributes: return ProcDMXGetInputAttributes(client);
+ case X_DMXAddInput: return ProcDMXAddInput(client);
+ case X_DMXRemoveInput: return ProcDMXRemoveInput(client);
+
+ case X_DMXGetScreenInformationDEPRECATED:
+ case X_DMXForceWindowCreationDEPRECATED:
+ case X_DMXReconfigureScreenDEPRECATED:
+ return BadImplementation;
+
+ default: return BadRequest;
+ }
+}
+
+static int SProcDMXQueryVersion(ClientPtr client)
+{
+ int n;
+ REQUEST(xDMXQueryVersionReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDMXQueryVersionReq);
+ return ProcDMXQueryVersion(client);
+}
+
+static int SProcDMXSync(ClientPtr client)
+{
+ int n;
+ REQUEST(xDMXSyncReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDMXSyncReq);
+ return ProcDMXSync(client);
+}
+
+static int SProcDMXForceWindowCreation(ClientPtr client)
+{
+ int n;
+ REQUEST(xDMXForceWindowCreationReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDMXForceWindowCreationReq);
+ swaps(&stuff->window, n);
+ return ProcDMXForceWindowCreation(client);
+}
+
+static int SProcDMXGetScreenCount(ClientPtr client)
+{
+ int n;
+ REQUEST(xDMXGetScreenCountReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDMXGetScreenCountReq);
+ return ProcDMXGetScreenCount(client);
+}
+
+static int SProcDMXGetScreenAttributes(ClientPtr client)
+{
+ int n;
+ REQUEST(xDMXGetScreenAttributesReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDMXGetScreenAttributesReq);
+ swapl(&stuff->physicalScreen, n);
+ return ProcDMXGetScreenAttributes(client);
+}
+
+static int SProcDMXChangeScreensAttributes(ClientPtr client)
+{
+ int n;
+ REQUEST(xDMXChangeScreensAttributesReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xDMXGetScreenAttributesReq);
+ swapl(&stuff->screenCount, n);
+ swapl(&stuff->maskCount, n);
+ SwapRestL(stuff);
+ return ProcDMXGetScreenAttributes(client);
+}
+
+static int SProcDMXAddScreen(ClientPtr client)
+{
+ int n;
+ int paddedLength;
+ REQUEST(xDMXAddScreenReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xDMXAddScreenReq);
+ swapl(&stuff->displayNameLength, n);
+ swapl(&stuff->valueMask, n);
+ paddedLength = (stuff->displayNameLength + 3) & ~3;
+ SwapLongs((CARD32 *)(stuff+1), LengthRestL(stuff) - paddedLength/4);
+ return ProcDMXAddScreen(client);
+}
+
+static int SProcDMXRemoveScreen(ClientPtr client)
+{
+ int n;
+ REQUEST(xDMXRemoveScreenReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDMXRemoveScreenReq);
+ swapl(&stuff->physicalScreen, n);
+ return ProcDMXRemoveScreen(client);
+}
+
+static int SProcDMXGetWindowAttributes(ClientPtr client)
+{
+ int n;
+ REQUEST(xDMXGetWindowAttributesReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDMXGetWindowAttributesReq);
+ swapl(&stuff->window, n);
+ return ProcDMXGetWindowAttributes(client);
+}
+
+static int SProcDMXGetDesktopAttributes(ClientPtr client)
+{
+ int n;
+ REQUEST(xDMXGetDesktopAttributesReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDMXGetDesktopAttributesReq);
+ return ProcDMXGetDesktopAttributes(client);
+}
+
+static int SProcDMXChangeDesktopAttributes(ClientPtr client)
+{
+ int n;
+ REQUEST(xDMXChangeDesktopAttributesReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xDMXChangeDesktopAttributesReq);
+ swapl(&stuff->valueMask, n);
+ SwapRestL(stuff);
+ return ProcDMXChangeDesktopAttributes(client);
+}
+
+static int SProcDMXGetInputCount(ClientPtr client)
+{
+ int n;
+ REQUEST(xDMXGetInputCountReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDMXGetInputCountReq);
+ return ProcDMXGetInputCount(client);
+}
+
+static int SProcDMXGetInputAttributes(ClientPtr client)
+{
+ int n;
+ REQUEST(xDMXGetInputAttributesReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDMXGetInputAttributesReq);
+ swapl(&stuff->deviceId, n);
+ return ProcDMXGetInputAttributes(client);
+}
+
+static int SProcDMXAddInput(ClientPtr client)
+{
+ int n;
+ int paddedLength;
+ REQUEST(xDMXAddInputReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xDMXAddInputReq);
+ swapl(&stuff->displayNameLength, n);
+ swapl(&stuff->valueMask, n);
+ paddedLength = (stuff->displayNameLength + 3) & ~3;
+ SwapLongs((CARD32 *)(stuff+1), LengthRestL(stuff) - paddedLength/4);
+ return ProcDMXAddInput(client);
+}
+
+static int SProcDMXRemoveInput(ClientPtr client)
+{
+ int n;
+ REQUEST(xDMXRemoveInputReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDMXRemoveInputReq);
+ swapl(&stuff->physicalId, n);
+ return ProcDMXRemoveInput(client);
+}
+
+static int SProcDMXDispatch (ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data) {
+ case X_DMXQueryVersion: return SProcDMXQueryVersion(client);
+ case X_DMXSync: return SProcDMXSync(client);
+ case X_DMXForceWindowCreation: return SProcDMXForceWindowCreation(client);
+ case X_DMXGetScreenCount: return SProcDMXGetScreenCount(client);
+ case X_DMXGetScreenAttributes: return SProcDMXGetScreenAttributes(client);
+ case X_DMXChangeScreensAttributes:
+ return SProcDMXChangeScreensAttributes(client);
+ case X_DMXAddScreen: return SProcDMXAddScreen(client);
+ case X_DMXRemoveScreen: return SProcDMXRemoveScreen(client);
+ case X_DMXGetWindowAttributes: return SProcDMXGetWindowAttributes(client);
+ case X_DMXGetDesktopAttributes:
+ return SProcDMXGetDesktopAttributes(client);
+ case X_DMXChangeDesktopAttributes:
+ return SProcDMXChangeDesktopAttributes(client);
+ case X_DMXGetInputCount: return SProcDMXGetInputCount(client);
+ case X_DMXGetInputAttributes: return SProcDMXGetInputAttributes(client);
+ case X_DMXAddInput: return SProcDMXAddInput(client);
+ case X_DMXRemoveInput: return SProcDMXRemoveInput(client);
+
+ case X_DMXGetScreenInformationDEPRECATED:
+ case X_DMXForceWindowCreationDEPRECATED:
+ case X_DMXReconfigureScreenDEPRECATED:
+ return BadImplementation;
+
+ default: return BadRequest;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xext/dpms.c b/nx-X11/programs/Xserver/Xext/dpms.c
new file mode 100644
index 000000000..3e79602d1
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/dpms.c
@@ -0,0 +1,450 @@
+/* $Xorg: dpms.c,v 1.3 2000/08/17 19:47:56 cpqbld Exp $ */
+/*****************************************************************
+
+Copyright (c) 1996 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+
+/*
+ * HISTORY
+ *
+ * @(#)RCSfile: dpms.c,v Revision: 1.1.4.5 (DEC) Date: 1996/03/04 15:27:00
+ */
+
+/* $XFree86: xc/programs/Xserver/Xext/dpms.c,v 3.10tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "opaque.h"
+#define DPMS_SERVER
+#include <X11/extensions/dpms.h>
+#include <X11/extensions/dpmsstr.h>
+#include "dpmsproc.h"
+#include "modinit.h"
+
+#if 0
+static unsigned char DPMSCode;
+#endif
+static DISPATCH_PROC(ProcDPMSDispatch);
+static DISPATCH_PROC(SProcDPMSDispatch);
+static DISPATCH_PROC(ProcDPMSGetVersion);
+static DISPATCH_PROC(SProcDPMSGetVersion);
+static DISPATCH_PROC(ProcDPMSGetTimeouts);
+static DISPATCH_PROC(SProcDPMSGetTimeouts);
+static DISPATCH_PROC(ProcDPMSSetTimeouts);
+static DISPATCH_PROC(SProcDPMSSetTimeouts);
+static DISPATCH_PROC(ProcDPMSEnable);
+static DISPATCH_PROC(SProcDPMSEnable);
+static DISPATCH_PROC(ProcDPMSDisable);
+static DISPATCH_PROC(SProcDPMSDisable);
+static DISPATCH_PROC(ProcDPMSForceLevel);
+static DISPATCH_PROC(SProcDPMSForceLevel);
+static DISPATCH_PROC(ProcDPMSInfo);
+static DISPATCH_PROC(SProcDPMSInfo);
+static DISPATCH_PROC(ProcDPMSCapable);
+static DISPATCH_PROC(SProcDPMSCapable);
+static void DPMSResetProc(ExtensionEntry* extEntry);
+
+void
+DPMSExtensionInit(INITARGS)
+{
+#if 0
+ ExtensionEntry *extEntry;
+
+ if ((extEntry = AddExtension(DPMSExtensionName, 0, 0,
+ ProcDPMSDispatch, SProcDPMSDispatch,
+ DPMSResetProc, StandardMinorOpcode)))
+ DPMSCode = (unsigned char)extEntry->base;
+#else
+ (void) AddExtension(DPMSExtensionName, 0, 0,
+ ProcDPMSDispatch, SProcDPMSDispatch,
+ DPMSResetProc, StandardMinorOpcode);
+#endif
+}
+
+/*ARGSUSED*/
+static void
+DPMSResetProc (extEntry)
+ ExtensionEntry *extEntry;
+{
+}
+
+static int
+ProcDPMSGetVersion(client)
+ register ClientPtr client;
+{
+ /* REQUEST(xDPMSGetVersionReq); */
+ xDPMSGetVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xDPMSGetVersionReq);
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = DPMSMajorVersion;
+ rep.minorVersion = DPMSMinorVersion;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof(xDPMSGetVersionReply), (char *)&rep);
+ return(client->noClientException);
+}
+
+static int
+ProcDPMSCapable(register ClientPtr client)
+{
+ /* REQUEST(xDPMSCapableReq); */
+ xDPMSCapableReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xDPMSCapableReq);
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.capable = DPMSCapableFlag;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ }
+ WriteToClient(client, sizeof(xDPMSCapableReply), (char *)&rep);
+ return(client->noClientException);
+}
+
+static int
+ProcDPMSGetTimeouts(client)
+ register ClientPtr client;
+{
+ /* REQUEST(xDPMSGetTimeoutsReq); */
+ xDPMSGetTimeoutsReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq);
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.standby = DPMSStandbyTime / MILLI_PER_SECOND;
+ rep.suspend = DPMSSuspendTime / MILLI_PER_SECOND;
+ rep.off = DPMSOffTime / MILLI_PER_SECOND;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swaps(&rep.standby, n);
+ swaps(&rep.suspend, n);
+ swaps(&rep.off, n);
+ }
+ WriteToClient(client, sizeof(xDPMSGetTimeoutsReply), (char *)&rep);
+ return(client->noClientException);
+}
+
+static int
+ProcDPMSSetTimeouts(client)
+ register ClientPtr client;
+{
+ REQUEST(xDPMSSetTimeoutsReq);
+
+ REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq);
+
+ if ((stuff->off != 0)&&(stuff->off < stuff->suspend))
+ {
+ client->errorValue = stuff->off;
+ return BadValue;
+ }
+ if ((stuff->suspend != 0)&&(stuff->suspend < stuff->standby))
+ {
+ client->errorValue = stuff->suspend;
+ return BadValue;
+ }
+
+ DPMSStandbyTime = stuff->standby * MILLI_PER_SECOND;
+ DPMSSuspendTime = stuff->suspend * MILLI_PER_SECOND;
+ DPMSOffTime = stuff->off * MILLI_PER_SECOND;
+ SetDPMSTimers();
+
+ return(client->noClientException);
+}
+
+static int
+ProcDPMSEnable(client)
+ register ClientPtr client;
+{
+ /* REQUEST(xDPMSEnableReq); */
+
+ REQUEST_SIZE_MATCH(xDPMSEnableReq);
+
+ if (DPMSCapableFlag)
+ DPMSEnabled = TRUE;
+
+ return(client->noClientException);
+}
+
+static int
+ProcDPMSDisable(client)
+ register ClientPtr client;
+{
+ /* REQUEST(xDPMSDisableReq); */
+
+ REQUEST_SIZE_MATCH(xDPMSDisableReq);
+
+ DPMSSet(DPMSModeOn);
+
+ DPMSEnabled = FALSE;
+
+ return(client->noClientException);
+}
+
+static int
+ProcDPMSForceLevel(client)
+ register ClientPtr client;
+{
+ REQUEST(xDPMSForceLevelReq);
+
+ REQUEST_SIZE_MATCH(xDPMSForceLevelReq);
+
+ if (!DPMSEnabled)
+ return BadMatch;
+
+ if (stuff->level == DPMSModeOn) {
+ lastDeviceEventTime.milliseconds =
+ GetTimeInMillis();
+ } else if (stuff->level == DPMSModeStandby) {
+ lastDeviceEventTime.milliseconds =
+ GetTimeInMillis() - DPMSStandbyTime;
+ } else if (stuff->level == DPMSModeSuspend) {
+ lastDeviceEventTime.milliseconds =
+ GetTimeInMillis() - DPMSSuspendTime;
+ } else if (stuff->level == DPMSModeOff) {
+ lastDeviceEventTime.milliseconds =
+ GetTimeInMillis() - DPMSOffTime;
+ } else {
+ client->errorValue = stuff->level;
+ return BadValue;
+ }
+
+ DPMSSet(stuff->level);
+
+ return(client->noClientException);
+}
+
+static int
+ProcDPMSInfo(register ClientPtr client)
+{
+ /* REQUEST(xDPMSInfoReq); */
+ xDPMSInfoReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xDPMSInfoReq);
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.power_level = DPMSPowerLevel;
+ rep.state = DPMSEnabled;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swaps(&rep.power_level, n);
+ }
+ WriteToClient(client, sizeof(xDPMSInfoReply), (char *)&rep);
+ return(client->noClientException);
+}
+
+static int
+ProcDPMSDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_DPMSGetVersion:
+ return ProcDPMSGetVersion(client);
+ case X_DPMSCapable:
+ return ProcDPMSCapable(client);
+ case X_DPMSGetTimeouts:
+ return ProcDPMSGetTimeouts(client);
+ case X_DPMSSetTimeouts:
+ return ProcDPMSSetTimeouts(client);
+ case X_DPMSEnable:
+ return ProcDPMSEnable(client);
+ case X_DPMSDisable:
+ return ProcDPMSDisable(client);
+ case X_DPMSForceLevel:
+ return ProcDPMSForceLevel(client);
+ case X_DPMSInfo:
+ return ProcDPMSInfo(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static int
+SProcDPMSGetVersion(client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST(xDPMSGetVersionReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDPMSGetVersionReq);
+ swaps(&stuff->majorVersion, n);
+ swaps(&stuff->minorVersion, n);
+ return ProcDPMSGetVersion(client);
+}
+
+static int
+SProcDPMSCapable(register ClientPtr client)
+{
+ REQUEST(xDPMSCapableReq);
+ register int n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDPMSCapableReq);
+
+ return ProcDPMSCapable(client);
+}
+
+static int
+SProcDPMSGetTimeouts(client)
+ register ClientPtr client;
+{
+ REQUEST(xDPMSGetTimeoutsReq);
+ register int n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq);
+
+ return ProcDPMSGetTimeouts(client);
+}
+
+static int
+SProcDPMSSetTimeouts(client)
+ register ClientPtr client;
+{
+ REQUEST(xDPMSSetTimeoutsReq);
+ register int n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq);
+
+ swaps(&stuff->standby, n);
+ swaps(&stuff->suspend, n);
+ swaps(&stuff->off, n);
+ return ProcDPMSSetTimeouts(client);
+}
+
+static int
+SProcDPMSEnable(client)
+ register ClientPtr client;
+{
+ REQUEST(xDPMSEnableReq);
+ register int n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDPMSEnableReq);
+
+ return ProcDPMSEnable(client);
+}
+
+static int
+SProcDPMSDisable(client)
+ register ClientPtr client;
+{
+ REQUEST(xDPMSDisableReq);
+ register int n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDPMSDisableReq);
+
+ return ProcDPMSDisable(client);
+}
+
+static int
+SProcDPMSForceLevel(client)
+ register ClientPtr client;
+{
+ REQUEST(xDPMSForceLevelReq);
+ register int n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDPMSForceLevelReq);
+
+ swaps(&stuff->level, n);
+
+ return ProcDPMSForceLevel(client);
+}
+
+static int
+SProcDPMSInfo(client)
+ register ClientPtr client;
+{
+ REQUEST(xDPMSInfoReq);
+ register int n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDPMSInfoReq);
+
+ return ProcDPMSInfo(client);
+}
+
+static int
+SProcDPMSDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_DPMSGetVersion:
+ return SProcDPMSGetVersion(client);
+ case X_DPMSCapable:
+ return SProcDPMSCapable(client);
+ case X_DPMSGetTimeouts:
+ return SProcDPMSGetTimeouts(client);
+ case X_DPMSSetTimeouts:
+ return SProcDPMSSetTimeouts(client);
+ case X_DPMSEnable:
+ return SProcDPMSEnable(client);
+ case X_DPMSDisable:
+ return SProcDPMSDisable(client);
+ case X_DPMSForceLevel:
+ return SProcDPMSForceLevel(client);
+ case X_DPMSInfo:
+ return SProcDPMSInfo(client);
+ default:
+ return BadRequest;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xext/dpmsproc.h b/nx-X11/programs/Xserver/Xext/dpmsproc.h
new file mode 100644
index 000000000..ae1e6e25a
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/dpmsproc.h
@@ -0,0 +1,16 @@
+/* $XFree86: xc/programs/Xserver/Xext/dpmsproc.h,v 1.3 2001/10/28 03:32:50 tsi Exp $ */
+
+/* Prototypes for functions that the DDX must provide */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _DPMSPROC_H_
+#define _DPMSPROC_H_
+
+void DPMSSet(int level);
+int DPMSGet(int *plevel);
+Bool DPMSSupported(void);
+
+#endif
diff --git a/nx-X11/programs/Xserver/Xext/dpmsstubs.c b/nx-X11/programs/Xserver/Xext/dpmsstubs.c
new file mode 100644
index 000000000..128c57bb0
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/dpmsstubs.c
@@ -0,0 +1,54 @@
+/* $Xorg: dpmsstubs.c,v 1.3 2000/08/17 19:47:56 cpqbld Exp $ */
+/*****************************************************************
+
+Copyright (c) 1996 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/Xext/dpmsstubs.c,v 3.4 2001/01/17 22:13:15 dawes Exp $ */
+
+typedef int Bool;
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "dpmsproc.h"
+
+#define FALSE 0
+
+Bool DPMSSupported(void)
+{
+ return FALSE;
+}
+
+int DPMSGet(int *plevel)
+{
+ return -1;
+}
+
+void DPMSSet(int level)
+{
+
+}
diff --git a/nx-X11/programs/Xserver/Xext/extmod/Imakefile b/nx-X11/programs/Xserver/Xext/extmod/Imakefile
new file mode 100644
index 000000000..450a318b4
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/extmod/Imakefile
@@ -0,0 +1,127 @@
+XCOMM $XFree86: xc/programs/Xserver/Xext/extmod/Imakefile,v 1.21 2001/03/05 04:51:56 mvojkovi Exp $
+XCOMM This directory is only entered if DoLoadableServer is set
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#if BuildMultibuffer
+ MULTIBUFSRC = mbuf.c
+ MULTIBUFOBJ = mbuf.o
+LinkSourceFile(mbuf.c,..)
+#endif
+
+#if BuildScreenSaverExt
+ SCRNSAVSRC = saver.c
+ SCRNSAVOBJ = saver.o
+LinkSourceFile(saver.c,..)
+#endif
+
+#if BuildXF86VidModeExt
+ VIDMODESRCS = xf86vmode.c
+ VIDMODEOBJS = xf86vmode.o
+LinkSourceFile(xf86vmode.c,..)
+#endif
+
+#if BuildXF86MiscExt
+ XF86MISCSRCS = xf86misc.c
+ XF86MISCOBJS = xf86misc.o
+LinkSourceFile(xf86misc.c,..)
+#endif
+
+#if BuildXF86DGA
+ XF86DGASRCS = xf86dga.c xf86dga2.c
+ XF86DGAOBJS = xf86dga.o xf86dga2.o
+LinkSourceFile(xf86dga.c,..)
+LinkSourceFile(xf86dga2.c,..)
+#endif
+
+#if BuildDPMS
+ DPMSSRCS = dpms.c
+ DPMSOBJS = dpms.o
+LinkSourceFile(dpms.c,..)
+#endif
+
+#if BuildFontCache
+ FONTCACHESRCS = fontcache.c
+ FONTCACHEOBJS = fontcache.o
+#if 0
+ FONTCACHEINCLUDES = -I$(XF86SRC)/os-support
+#endif
+LinkSourceFile(fontcache.c,..)
+#endif
+
+#if BuildXvExt
+ XVSRCS = xvmain.c xvdisp.c xvmod.c xvmc.c
+ XVOBJS = xvmain.o xvdisp.o xvmod.o xvmc.o
+LinkSourceFile(xvmain.c,..)
+LinkSourceFile(xvdisp.c,..)
+LinkSourceFile(xvmod.c,..)
+LinkSourceFile(xvmc.c,..)
+#endif
+
+#if BuildXResExt
+ XRESSRCS = xres.c
+ XRESOBJS = xres.o
+LinkSourceFile(xres.c,..)
+#endif
+
+#if BuildEVI
+ EVISRCS = EVI.c sampleEVI.c
+ EVIOBJS = EVI.o sampleEVI.o
+LinkSourceFile(EVI.c,..)
+LinkSourceFile(sampleEVI.c,..)
+#endif
+
+#if BuildCup
+ CUPSRCS = cup.c
+ CUPOBJS = cup.o
+LinkSourceFile(cup.c,..)
+#endif
+
+ MODINITSRCS = modinit.c
+ MODINITOBJS = modinit.o
+
+ SRCS = shape.c $(MULTIBUFSRC) \
+ mitmisc.c \
+ bigreq.c sync.c $(SCRNSAVSRC) xcmisc.c $(VIDMODESRCS) \
+ $(XF86MISCSRCS) $(XF86DGASRCS) \
+ $(CUPSRCS) $(DPMSSRCS) $(FONTCACHESRCS) \
+ $(EVISRCS) $(XVSRCS) $(MODINITSRCS) $(XRESSRCS)
+
+ MOBJS = $(MODINITOBJS) shape.o $(MULTIBUFOBJ) mitmisc.o \
+ bigreq.o sync.o $(SCRNSAVOBJ) xcmisc.o \
+ $(VIDMODEOBJS) $(XF86MISCOBJS) $(XF86DGAOBJS) \
+ $(CUPOBJS) $(DPMSOBJS) $(FONTCACHEOBJS) \
+ $(EVIOBJS) $(XVOBJS) $(XRESOBJS)
+
+ DEFINES = -DEXTMODULE $(EXT_DEFINES)
+
+XF86INCLUDES = -I$(XF86COMSRC)
+ INCLUDES = -I.. -I../../include -I$(XINCLUDESRC) -I$(EXTINCSRC) \
+ $(XF86INCLUDES) $(FONTCACHEINCLUDES) -I$(FONTINCSRC)
+ LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln
+
+LinkSourceFile(shape.c,..)
+LinkSourceFile(mitmisc.c,..)
+LinkSourceFile(bigreq.c,..)
+LinkSourceFile(sync.c,..)
+LinkSourceFile(xcmisc.c,..)
+
+ModuleObjectRule()
+
+/*
+ * A hack to work around an optimization problem with gcc 2.95.2
+ */
+#if BuildXF86VidModeExt && defined(GccOptBug295)
+SpecialCObjectRule(xf86vmode,NullParameter,-O0)
+#endif
+
+SpecialCObjectRule(modinit,$(ICONFIGFILES),$(EXT_DEFINES))
+LibraryModuleTarget(extmod,$(MOBJS))
+NormalLintTarget($(SRCS))
+
+InstallLibraryModule(extmod,$(MODULEDIR),extensions)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(extmod,$(DRIVERSDKMODULEDIR),extensions)
diff --git a/nx-X11/programs/Xserver/Xext/extmod/modinit.c b/nx-X11/programs/Xserver/Xext/extmod/modinit.c
new file mode 100644
index 000000000..3c2044f78
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/extmod/modinit.c
@@ -0,0 +1,264 @@
+/* $XFree86: xc/programs/Xserver/Xext/extmod/modinit.c,v 1.16 2002/03/06 21:12:33 mvojkovi Exp $ */
+
+/*
+ *
+ * Copyright (c) 1997 Matthieu Herrb
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Matthieu Herrb not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Matthieu Herrb makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * MATTHIEU HERRB DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL MATTHIEU HERRB BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef XFree86LOADER
+#include "xf86_ansic.h"
+
+#include "xf86Module.h"
+#include "xf86Opt.h"
+
+#include <X11/Xproto.h>
+
+#include "modinit.h"
+#include "globals.h"
+
+static MODULESETUPPROTO(extmodSetup);
+
+/*
+ * Array describing extensions to be initialized
+ */
+ExtensionModule extensionModules[] = {
+#ifdef SHAPE
+ {
+ ShapeExtensionInit,
+ SHAPENAME,
+ &noShapeExtension,
+ NULL,
+ NULL
+ },
+#endif
+#ifdef MULTIBUFFER
+ {
+ MultibufferExtensionInit,
+ MULTIBUFFER_PROTOCOL_NAME,
+ &noMultibufferExtension,
+ NULL,
+ NULL
+ },
+#endif
+#ifdef MITMISC
+ {
+ MITMiscExtensionInit,
+ MITMISCNAME,
+ &noMITMiscExtension,
+ NULL,
+ NULL
+ },
+#endif
+#ifdef notyet
+ {
+ XTestExtensionInit,
+ XTestExtensionName,
+ &noTestExtensions,
+ NULL,
+ NULL
+ },
+#endif
+#ifdef BIGREQS
+ {
+ BigReqExtensionInit,
+ XBigReqExtensionName,
+ &noBigReqExtension,
+ NULL,
+ NULL
+ },
+#endif
+#ifdef XSYNC
+ {
+ SyncExtensionInit,
+ SYNC_NAME,
+ &noSyncExtension,
+ NULL,
+ NULL
+ },
+#endif
+#ifdef SCREENSAVER
+ {
+ ScreenSaverExtensionInit,
+ ScreenSaverName,
+ &noScreenSaverExtension,
+ NULL,
+ NULL
+ },
+#endif
+#ifdef XCMISC
+ {
+ XCMiscExtensionInit,
+ XCMiscExtensionName,
+ &noXCMiscExtension,
+ NULL,
+ NULL
+ },
+#endif
+#ifdef XF86VIDMODE
+ {
+ XFree86VidModeExtensionInit,
+ XF86VIDMODENAME,
+ &noXFree86VidModeExtension,
+ NULL,
+ NULL
+ },
+#endif
+#ifdef XF86MISC
+ {
+ XFree86MiscExtensionInit,
+ XF86MISCNAME,
+ &noXFree86MiscExtension,
+ NULL,
+ NULL
+ },
+#endif
+#ifdef XFreeXDGA
+ {
+ XFree86DGAExtensionInit,
+ XF86DGANAME,
+ &noXFree86DGAExtension,
+ XFree86DGARegister,
+ NULL
+ },
+#endif
+#ifdef DPMSExtension
+ {
+ DPMSExtensionInit,
+ DPMSExtensionName,
+ &noDPMSExtension,
+ NULL,
+ NULL
+ },
+#endif
+#ifdef FONTCACHE
+ {
+ FontCacheExtensionInit,
+ FONTCACHENAME,
+ &noFontCacheExtension,
+ NULL,
+ NULL
+ },
+#endif
+#ifdef TOGCUP
+ {
+ XcupExtensionInit,
+ XCUPNAME,
+ &noXcupExtension,
+ NULL,
+ NULL
+ },
+#endif
+#ifdef EVI
+ {
+ EVIExtensionInit,
+ EVINAME,
+ &noEVIExtension,
+ NULL,
+ NULL
+ },
+#endif
+#ifdef XV
+ {
+ XvExtensionInit,
+ XvName,
+ &noXvExtension,
+ XvRegister,
+ NULL
+ },
+ {
+ XvMCExtensionInit,
+ XvMCName,
+ &noXvExtension,
+ NULL,
+ NULL
+ },
+#endif
+#ifdef RES
+ {
+ ResExtensionInit,
+ XRES_NAME,
+ &noResExtension,
+ NULL,
+ NULL
+ },
+#endif
+ { /* DON'T delete this entry ! */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ }
+};
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "extmod",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_EXTENSION,
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_EXTENSION,
+ {0,0,0,0}
+};
+
+/*
+ * Data for the loader
+ */
+XF86ModuleData extmodModuleData = { &VersRec, extmodSetup, NULL };
+
+static pointer
+extmodSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ int i;
+
+ /* XXX the option stuff here is largely a sample/test case */
+
+ for (i = 0; extensionModules[i].name != NULL; i++) {
+ if (opts) {
+ char *s;
+ s = (char *)xalloc(strlen(extensionModules[i].name) + 5);
+ if (s) {
+ pointer o;
+ strcpy(s, "omit");
+ strcat(s, extensionModules[i].name);
+ o = xf86FindOption(opts, s);
+ xfree(s);
+ if (o) {
+ xf86MarkOptionUsed(o);
+ continue;
+ }
+ }
+ }
+ LoadExtension(&extensionModules[i], FALSE);
+ }
+ /* Need a non-NULL return */
+ return (pointer)1;
+}
+
+#endif /* XFree86LOADER */
diff --git a/nx-X11/programs/Xserver/Xext/extmod/modinit.h b/nx-X11/programs/Xserver/Xext/extmod/modinit.h
new file mode 100644
index 000000000..2bafdb2b0
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/extmod/modinit.h
@@ -0,0 +1,149 @@
+/* $XdotOrg: xc/programs/Xserver/Xext/extmod/modinit.h,v 1.5 2005/07/03 07:01:06 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/Xext/extmod/modinit.h,v 1.1 2003/07/16 01:38:33 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef INITARGS
+#define INITARGS void
+#endif
+
+#ifdef SHAPE
+extern void ShapeExtensionInit(INITARGS);
+#define _SHAPE_SERVER_ /* don't want Xlib structures */
+#include <X11/extensions/shapestr.h>
+#endif
+
+#ifdef MULTIBUFFER
+extern void MultibufferExtensionInit(INITARGS);
+#define _MULTIBUF_SERVER_ /* don't want Xlib structures */
+#include <X11/extensions/multibufst.h>
+#endif
+
+#ifdef MITMISC
+extern void MITMiscExtensionInit(INITARGS);
+#define _MITMISC_SERVER_
+#include <X11/extensions/mitmiscstr.h>
+#endif
+
+#ifdef XTEST
+extern void XTestExtensionInit(INITARGS);
+#define _XTEST_SERVER_
+#include <X11/extensions/XTest.h>
+#include <X11/extensions/xteststr.h>
+#endif
+
+#if 1
+extern void XTestExtension1Init(INITARGS);
+#endif
+
+#ifdef BIGREQS
+extern void BigReqExtensionInit(INITARGS);
+#include <X11/extensions/bigreqstr.h>
+#endif
+
+#ifdef XSYNC
+extern void SyncExtensionInit(INITARGS);
+#define _SYNC_SERVER
+#include <X11/extensions/sync.h>
+#include <X11/extensions/syncstr.h>
+#endif
+
+#ifdef SCREENSAVER
+extern void ScreenSaverExtensionInit (INITARGS);
+#include <X11/extensions/saver.h>
+#endif
+
+#ifdef XCMISC
+extern void XCMiscExtensionInit(INITARGS);
+#include <X11/extensions/xcmiscstr.h>
+#endif
+
+#ifdef XF86VIDMODE
+extern void XFree86VidModeExtensionInit(INITARGS);
+#define _XF86VIDMODE_SERVER_
+#include <X11/extensions/xf86vmstr.h>
+#endif
+
+#ifdef XF86MISC
+extern void XFree86MiscExtensionInit(INITARGS);
+#define _XF86MISC_SERVER_
+#define _XF86MISC_SAVER_COMPAT_
+#include <X11/extensions/xf86mscstr.h>
+#endif
+
+#ifdef XFreeXDGA
+extern void XFree86DGAExtensionInit(INITARGS);
+extern void XFree86DGARegister(INITARGS);
+#define _XF86DGA_SERVER_
+#include <X11/extensions/xf86dgastr.h>
+#endif
+
+#ifdef DPMSExtension
+extern void DPMSExtensionInit(INITARGS);
+#include <X11/extensions/dpmsstr.h>
+#endif
+
+#ifdef FONTCACHE
+extern void FontCacheExtensionInit(INITARGS);
+#define _FONTCACHE_SERVER_
+#include "fontcacheP.h"
+#include "fontcachstr.h"
+#endif
+
+#ifdef TOGCUP
+extern void XcupExtensionInit(INITARGS);
+#define _XCUP_SERVER_
+#include <X11/extensions/Xcupstr.h>
+#endif
+
+#ifdef EVI
+extern void EVIExtensionInit(INITARGS);
+#define _XEVI_SERVER_
+#include <X11/extensions/XEVIstr.h>
+#endif
+
+#ifdef XV
+extern void XvExtensionInit(INITARGS);
+extern void XvMCExtensionInit(INITARGS);
+extern void XvRegister(INITARGS);
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/XvMC.h>
+#endif
+
+#ifdef RES
+extern void ResExtensionInit(INITARGS);
+#include <X11/extensions/XResproto.h>
+#endif
+
+#ifdef SHM
+extern void ShmExtensionInit(INITARGS);
+#include <X11/extensions/shmstr.h>
+extern void ShmSetPixmapFormat(
+ ScreenPtr pScreen,
+ int format);
+extern void ShmRegisterFuncs(
+ ScreenPtr pScreen,
+ ShmFuncsPtr funcs);
+#endif
+
+#if 1
+extern void SecurityExtensionInit(INITARGS);
+#endif
+
+#if 1
+extern void XagExtensionInit(INITARGS);
+#endif
+
+#if 1
+extern void XpExtensionInit(INITARGS);
+#endif
+
+#if 1
+extern void PanoramiXExtensionInit(int argc, char *argv[]);
+#endif
+
+#if 1
+extern void XkbExtensionInit(INITARGS);
+#endif
diff --git a/nx-X11/programs/Xserver/Xext/fontcache.c b/nx-X11/programs/Xserver/Xext/fontcache.c
new file mode 100644
index 000000000..9ab23a122
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/fontcache.c
@@ -0,0 +1,333 @@
+/*-
+ * Copyright (c) 1998-1999 Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
+ * All rights reserved.
+ * Copyright (c) 1998-1999 X-TrueType Server Project, All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Id: fontcache.c,v 1.12 1999/01/31 13:47:45 akiyama Exp $
+ */
+/* $XFree86: xc/programs/Xserver/Xext/fontcache.c,v 1.7 2003/10/28 23:08:43 tsi Exp $ */
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "scrnintstr.h"
+#include "inputstr.h"
+#include "servermd.h"
+#define _FONTCACHE_SERVER_
+#include "fontcacheP.h"
+#include "fontcachstr.h"
+#include <X11/Xfuncproto.h>
+
+#include "swaprep.h"
+#include "modinit.h"
+
+static int miscErrorBase;
+
+static void FontCacheResetProc(
+ ExtensionEntry* /* extEntry */
+);
+
+static DISPATCH_PROC(ProcFontCacheDispatch);
+static DISPATCH_PROC(ProcFontCacheGetCacheSettings);
+static DISPATCH_PROC(ProcFontCacheGetCacheStatistics);
+static DISPATCH_PROC(ProcFontCacheQueryVersion);
+static DISPATCH_PROC(ProcFontCacheChangeCacheSettings);
+static DISPATCH_PROC(SProcFontCacheDispatch);
+static DISPATCH_PROC(SProcFontCacheGetCacheSettings);
+static DISPATCH_PROC(SProcFontCacheGetCacheStatistics);
+static DISPATCH_PROC(SProcFontCacheQueryVersion);
+static DISPATCH_PROC(SProcFontCacheChangeCacheSettings);
+
+#if 0
+static unsigned char FontCacheReqCode = 0;
+#endif
+
+void
+FontCacheExtensionInit(INITARGS)
+{
+ ExtensionEntry* extEntry;
+
+ if (
+ (extEntry = AddExtension(FONTCACHENAME,
+ FontCacheNumberEvents,
+ FontCacheNumberErrors,
+ ProcFontCacheDispatch,
+ SProcFontCacheDispatch,
+ FontCacheResetProc,
+ StandardMinorOpcode))) {
+#if 0
+ FontCacheReqCode = (unsigned char)extEntry->base;
+#endif
+ miscErrorBase = extEntry->errorBase;
+ }
+}
+
+/*ARGSUSED*/
+static void
+FontCacheResetProc (extEntry)
+ ExtensionEntry* extEntry;
+{
+}
+
+static int
+ProcFontCacheQueryVersion(client)
+ register ClientPtr client;
+{
+ xFontCacheQueryVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xFontCacheQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = FONTCACHE_MAJOR_VERSION;
+ rep.minorVersion = FONTCACHE_MINOR_VERSION;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ }
+ WriteToClient(client, SIZEOF(xFontCacheQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcFontCacheGetCacheSettings(client)
+ register ClientPtr client;
+{
+ xFontCacheGetCacheSettingsReply rep;
+ FontCacheSettings cinfo;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xFontCacheGetCacheSettingsReq);
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+
+ /* XXX */
+ FontCacheGetSettings(&cinfo);
+ rep.himark = cinfo.himark;
+ rep.lowmark = cinfo.lowmark;
+ rep.balance = cinfo.balance;
+ rep.reserve0 = 0;
+ rep.reserve1 = 0;
+ rep.reserve2 = 0;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.himark, n);
+ swapl(&rep.lowmark, n);
+ swapl(&rep.balance, n);
+ swapl(&rep.reserve0, n);
+ swapl(&rep.reserve1, n);
+ swapl(&rep.reserve2, n);
+ }
+ /* XXX */
+
+ WriteToClient(client, SIZEOF(xFontCacheGetCacheSettingsReply),
+ (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcFontCacheGetCacheStatistics(client)
+ register ClientPtr client;
+{
+ xFontCacheGetCacheStatisticsReply rep;
+ FontCacheStatistics cstats;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xFontCacheGetCacheStatisticsReq);
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = (sz_xFontCacheGetCacheStatisticsReply - 32) >> 2;
+
+ /* XXX */
+ FontCacheGetStatistics(&cstats);
+ rep.purge_runs = cstats.purge_runs;
+ rep.purge_stat = cstats.purge_stat;
+ rep.balance = cstats.balance;
+ rep.reserve0 = 0;
+ rep.f_hits = cstats.f.hits;
+ rep.f_misshits = cstats.f.misshits;
+ rep.f_purged = cstats.f.purged;
+ rep.f_usage = cstats.f.usage;
+ rep.f_reserve0 = 0;
+ rep.v_hits = cstats.v.hits;
+ rep.v_misshits = cstats.v.misshits;
+ rep.v_purged = cstats.v.purged;
+ rep.v_usage = cstats.v.usage;
+ rep.v_reserve0 = 0;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.purge_runs, n);
+ swapl(&rep.purge_stat, n);
+ swapl(&rep.balance, n);
+ swapl(&rep.reserve0, n);
+ swapl(&rep.f_hits, n);
+ swapl(&rep.f_misshits, n);
+ swapl(&rep.f_purged, n);
+ swapl(&rep.f_usage, n);
+ swapl(&rep.f_reserve0, n);
+ swapl(&rep.v_hits, n);
+ swapl(&rep.v_misshits, n);
+ swapl(&rep.v_purged, n);
+ swapl(&rep.v_usage, n);
+ swapl(&rep.v_reserve0, n);
+ }
+ /* XXX */
+ WriteToClient(client, SIZEOF(xFontCacheGetCacheStatisticsReply),
+ (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcFontCacheChangeCacheSettings(client)
+ register ClientPtr client;
+{
+ FontCacheSettings cs;
+
+ REQUEST(xFontCacheChangeCacheSettingsReq);
+
+ REQUEST_SIZE_MATCH(xFontCacheChangeCacheSettingsReq);
+
+ /* XXX */
+ cs.himark = stuff->himark;
+ cs.lowmark = stuff->lowmark;
+ cs.balance = stuff->balance;
+
+ if (cs.himark < 0 || cs.lowmark < 0)
+ return BadValue;
+ if (cs.himark <= cs.lowmark)
+ return BadValue;
+ if (!(10 <= cs.balance && cs.balance <= 90))
+ return BadValue;
+
+ if (FontCacheChangeSettings(&cs) == 0)
+ return miscErrorBase + FontCacheCannotAllocMemory;
+ /* XXX */
+
+ return (client->noClientException);
+}
+
+static int
+ProcFontCacheDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_FontCacheQueryVersion:
+ return ProcFontCacheQueryVersion(client);
+ case X_FontCacheGetCacheSettings:
+ return ProcFontCacheGetCacheSettings(client);
+ case X_FontCacheGetCacheStatistics:
+ return ProcFontCacheGetCacheStatistics(client);
+ case X_FontCacheChangeCacheSettings:
+ return ProcFontCacheChangeCacheSettings(client);
+ default:
+ return miscErrorBase + FontCacheBadProtocol;
+ }
+}
+
+static int
+SProcFontCacheQueryVersion(client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST(xFontCacheQueryVersionReq);
+ swaps(&stuff->length, n);
+ return ProcFontCacheQueryVersion(client);
+}
+
+static int
+SProcFontCacheGetCacheSettings(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xFontCacheGetCacheSettingsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xFontCacheGetCacheSettingsReq);
+ return ProcFontCacheGetCacheSettings(client);
+}
+
+static int
+SProcFontCacheGetCacheStatistics(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xFontCacheGetCacheStatisticsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xFontCacheGetCacheStatisticsReq);
+ return ProcFontCacheGetCacheStatistics(client);
+}
+
+static int
+SProcFontCacheChangeCacheSettings(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xFontCacheChangeCacheSettingsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xFontCacheChangeCacheSettingsReq);
+ /* XXX */
+ swapl(&stuff->himark, n);
+ swapl(&stuff->lowmark, n);
+ swapl(&stuff->balance, n);
+ /* XXX */
+ return ProcFontCacheChangeCacheSettings(client);
+}
+
+static int
+SProcFontCacheDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_FontCacheQueryVersion:
+ return SProcFontCacheQueryVersion(client);
+ case X_FontCacheGetCacheSettings:
+ return SProcFontCacheGetCacheSettings(client);
+ case X_FontCacheGetCacheStatistics:
+ return SProcFontCacheGetCacheStatistics(client);
+ case X_FontCacheChangeCacheSettings:
+ return SProcFontCacheChangeCacheSettings(client);
+ default:
+ return miscErrorBase + FontCacheBadProtocol;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xext/mbuf.c b/nx-X11/programs/Xserver/Xext/mbuf.c
new file mode 100644
index 000000000..3129edd87
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/mbuf.c
@@ -0,0 +1,1787 @@
+/* $XFree86: xc/programs/Xserver/Xext/mbuf.c,v 3.15 2003/10/28 23:08:43 tsi Exp $ */
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+********************************************************/
+
+/* $Xorg: mbuf.c,v 1.4 2001/02/09 02:04:32 xorgcvs Exp $ */
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "window.h"
+#include "os.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "gcstruct.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "opaque.h"
+#include "sleepuntil.h"
+#define _MULTIBUF_SERVER_ /* don't want Xlib structures */
+#include <X11/extensions/multibufst.h>
+
+#ifdef EXTMODULE
+#include "xf86_ansic.h"
+#else
+#include <stdio.h>
+#if !defined(WIN32) && !defined(Lynx)
+#include <sys/time.h>
+#endif
+#endif
+
+/* given an OtherClientPtr obj, get the ClientPtr */
+#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
+
+/* given a MultibufferPtr b, get the ClientPtr */
+#define bClient(b) (clients[CLIENT_ID(b->pPixmap->drawable.id)])
+
+#define ValidEventMasks (ExposureMask|MultibufferClobberNotifyMask|MultibufferUpdateNotifyMask)
+
+#if 0
+static unsigned char MultibufferReqCode;
+#endif
+static int MultibufferEventBase;
+static int MultibufferErrorBase;
+int MultibufferScreenIndex = -1;
+int MultibufferWindowIndex = -1;
+
+static void PerformDisplayRequest (
+ MultibuffersPtr * /* ppMultibuffers */,
+ MultibufferPtr * /* pMultibuffer */,
+ int /* nbuf */
+ );
+static Bool QueueDisplayRequest (
+ ClientPtr /* client */,
+ TimeStamp /* activateTime */
+ );
+
+static void BumpTimeStamp (
+ TimeStamp * /* ts */,
+ CARD32 /* inc */
+ );
+
+static void AliasMultibuffer (
+ MultibuffersPtr /* pMultibuffers */,
+ int /* i */
+ );
+static void RecalculateMultibufferOtherEvents (
+ MultibufferPtr /* pMultibuffer */
+ );
+static int EventSelectForMultibuffer(
+ MultibufferPtr /* pMultibuffer */,
+ ClientPtr /* client */,
+ Mask /* mask */
+ );
+
+/*
+ * The Pixmap associated with a buffer can be found as a resource
+ * with this type
+ */
+RESTYPE MultibufferDrawableResType;
+static int MultibufferDrawableDelete (
+ pointer /* value */,
+ XID /* id */
+ );
+/*
+ * The per-buffer data can be found as a resource with this type.
+ * the resource id of the per-buffer data is the same as the resource
+ * id of the pixmap
+ */
+static RESTYPE MultibufferResType;
+static int MultibufferDelete (
+ pointer /* value */,
+ XID /* id */
+ );
+
+/*
+ * The per-window data can be found as a resource with this type,
+ * using the window resource id
+ */
+static RESTYPE MultibuffersResType;
+static int MultibuffersDelete (
+ pointer /* value */,
+ XID /* id */
+ );
+
+/*
+ * Clients other than the buffer creator attach event masks in
+ * OtherClient structures; each has a resource of this type.
+ */
+static RESTYPE OtherClientResType;
+static int OtherClientDelete (
+ pointer /* value */,
+ XID /* id */
+ );
+
+/****************
+ * MultibufferExtensionInit
+ *
+ * Called from InitExtensions in main()
+ *
+ ****************/
+
+extern DISPATCH_PROC(ProcGetBufferAttributes);
+
+static DISPATCH_PROC(ProcClearImageBufferArea);
+static DISPATCH_PROC(ProcCreateImageBuffers);
+static DISPATCH_PROC(ProcDestroyImageBuffers);
+static DISPATCH_PROC(ProcDisplayImageBuffers);
+static DISPATCH_PROC(ProcGetBufferInfo);
+static DISPATCH_PROC(ProcGetBufferVersion);
+static DISPATCH_PROC(ProcGetMBufferAttributes);
+static DISPATCH_PROC(ProcMultibufferDispatch);
+static DISPATCH_PROC(ProcSetBufferAttributes);
+static DISPATCH_PROC(ProcSetMBufferAttributes);
+static DISPATCH_PROC(SProcClearImageBufferArea);
+static DISPATCH_PROC(SProcCreateImageBuffers);
+static DISPATCH_PROC(SProcDestroyImageBuffers);
+static DISPATCH_PROC(SProcDisplayImageBuffers);
+static DISPATCH_PROC(SProcGetBufferAttributes);
+static DISPATCH_PROC(SProcGetBufferInfo);
+static DISPATCH_PROC(SProcGetBufferVersion);
+static DISPATCH_PROC(SProcGetMBufferAttributes);
+static DISPATCH_PROC(SProcMultibufferDispatch);
+static DISPATCH_PROC(SProcSetBufferAttributes);
+static DISPATCH_PROC(SProcSetMBufferAttributes);
+
+static void MultibufferResetProc(
+ ExtensionEntry * /* extEntry */
+ );
+static void SClobberNotifyEvent(
+ xMbufClobberNotifyEvent * /* from */,
+ xMbufClobberNotifyEvent * /* to */
+ );
+static void SUpdateNotifyEvent(
+ xMbufUpdateNotifyEvent * /* from */,
+ xMbufUpdateNotifyEvent * /* to */
+ );
+static Bool MultibufferPositionWindow(
+ WindowPtr /* pWin */,
+ int /* x */,
+ int /* y */
+ );
+
+static void SetupBackgroundPainter (
+ WindowPtr /* pWin */,
+ GCPtr /* pGC */
+ );
+
+static int DeliverEventsToMultibuffer (
+ MultibufferPtr /* pMultibuffer */,
+ xEvent * /* pEvents */,
+ int /* count */,
+ Mask /* filter */
+ );
+
+void
+MultibufferExtensionInit()
+{
+ ExtensionEntry *extEntry;
+ int i, j;
+ ScreenPtr pScreen;
+ MultibufferScreenPtr pMultibufferScreen;
+
+ /*
+ * allocate private pointers in windows and screens. Allocating
+ * window privates may seem like an unnecessary expense, but every
+ * PositionWindow call must check to see if the window is
+ * multi-buffered; a resource lookup is too expensive.
+ */
+ MultibufferScreenIndex = AllocateScreenPrivateIndex ();
+ if (MultibufferScreenIndex < 0)
+ return;
+ MultibufferWindowIndex = AllocateWindowPrivateIndex ();
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ pScreen = screenInfo.screens[i];
+ if (!AllocateWindowPrivate (pScreen, MultibufferWindowIndex, 0) ||
+ !(pMultibufferScreen = (MultibufferScreenPtr) xalloc (sizeof (MultibufferScreenRec))))
+ {
+ for (j = 0; j < i; j++)
+ xfree (screenInfo.screens[j]->devPrivates[MultibufferScreenIndex].ptr);
+ return;
+ }
+ pScreen->devPrivates[MultibufferScreenIndex].ptr = (pointer) pMultibufferScreen;
+ /*
+ * wrap PositionWindow to resize the pixmap when the window
+ * changes size
+ */
+ pMultibufferScreen->PositionWindow = pScreen->PositionWindow;
+ pScreen->PositionWindow = MultibufferPositionWindow;
+ }
+ /*
+ * create the resource types
+ */
+ MultibufferDrawableResType =
+ CreateNewResourceType(MultibufferDrawableDelete)|RC_CACHED|RC_DRAWABLE;
+ MultibufferResType = CreateNewResourceType(MultibufferDelete);
+ MultibuffersResType = CreateNewResourceType(MultibuffersDelete);
+ OtherClientResType = CreateNewResourceType(OtherClientDelete);
+ if (MultibufferDrawableResType && MultibufferResType &&
+ MultibuffersResType && OtherClientResType &&
+ (extEntry = AddExtension(MULTIBUFFER_PROTOCOL_NAME,
+ MultibufferNumberEvents,
+ MultibufferNumberErrors,
+ ProcMultibufferDispatch, SProcMultibufferDispatch,
+ MultibufferResetProc, StandardMinorOpcode)))
+ {
+#if 0
+ MultibufferReqCode = (unsigned char)extEntry->base;
+#endif
+ MultibufferEventBase = extEntry->eventBase;
+ MultibufferErrorBase = extEntry->errorBase;
+ EventSwapVector[MultibufferEventBase + MultibufferClobberNotify] = (EventSwapPtr) SClobberNotifyEvent;
+ EventSwapVector[MultibufferEventBase + MultibufferUpdateNotify] = (EventSwapPtr) SUpdateNotifyEvent;
+ }
+}
+
+/*ARGSUSED*/
+static void
+MultibufferResetProc (extEntry)
+ExtensionEntry *extEntry;
+{
+ int i;
+ ScreenPtr pScreen;
+ MultibufferScreenPtr pMultibufferScreen;
+
+ if (MultibufferScreenIndex < 0)
+ return;
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ pScreen = screenInfo.screens[i];
+ if (pScreen->devPrivates[MultibufferScreenIndex].ptr)
+ {
+ pMultibufferScreen = (MultibufferScreenPtr) pScreen->devPrivates[MultibufferScreenIndex].ptr;
+ pScreen->PositionWindow = pMultibufferScreen->PositionWindow;
+ xfree (pMultibufferScreen);
+ }
+ }
+}
+
+static int
+ProcGetBufferVersion (client)
+ register ClientPtr client;
+{
+ xMbufGetBufferVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH (xMbufGetBufferVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = MULTIBUFFER_MAJOR_VERSION;
+ rep.minorVersion = MULTIBUFFER_MINOR_VERSION;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ }
+ WriteToClient(client, sizeof (xMbufGetBufferVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static void
+SetupBackgroundPainter (pWin, pGC)
+ WindowPtr pWin;
+ GCPtr pGC;
+{
+ pointer gcvalues[4];
+ int ts_x_origin, ts_y_origin;
+ PixUnion background;
+ int backgroundState;
+ Mask gcmask;
+
+ /*
+ * First take care of any ParentRelative stuff by altering the
+ * tile/stipple origin to match the coordinates of the upper-left
+ * corner of the first ancestor without a ParentRelative background.
+ * This coordinate is, of course, negative.
+ */
+
+ ts_x_origin = ts_y_origin = 0;
+ while (pWin->backgroundState == ParentRelative) {
+ ts_x_origin -= pWin->origin.x;
+ ts_y_origin -= pWin->origin.y;
+ pWin = pWin->parent;
+ }
+ backgroundState = pWin->backgroundState;
+ background = pWin->background;
+
+ switch (backgroundState)
+ {
+ case BackgroundPixel:
+ gcvalues[0] = (pointer) background.pixel;
+ gcvalues[1] = (pointer) FillSolid;
+ gcmask = GCForeground|GCFillStyle;
+ break;
+
+ case BackgroundPixmap:
+ gcvalues[0] = (pointer) FillTiled;
+ gcvalues[1] = (pointer) background.pixmap;
+ gcvalues[2] = (pointer)(long) ts_x_origin;
+ gcvalues[3] = (pointer)(long) ts_y_origin;
+ gcmask = GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin;
+ break;
+
+ default:
+ gcvalues[0] = (pointer) GXnoop;
+ gcmask = GCFunction;
+ }
+ DoChangeGC(pGC, gcmask, (XID *)gcvalues, TRUE);
+}
+
+int
+CreateImageBuffers (pWin, nbuf, ids, action, hint)
+ WindowPtr pWin;
+ int nbuf;
+ XID *ids;
+ int action;
+ int hint;
+{
+ MultibuffersPtr pMultibuffers;
+ MultibufferPtr pMultibuffer;
+ ScreenPtr pScreen;
+ int width, height, depth;
+ int i;
+ GCPtr pClearGC = NULL;
+ xRectangle clearRect;
+
+ DestroyImageBuffers(pWin);
+ pMultibuffers = (MultibuffersPtr) xalloc (sizeof (MultibuffersRec) +
+ nbuf * sizeof (MultibufferRec));
+ if (!pMultibuffers)
+ return BadAlloc;
+ pMultibuffers->pWindow = pWin;
+ pMultibuffers->buffers = (MultibufferPtr) (pMultibuffers + 1);
+ pMultibuffers->refcnt = pMultibuffers->numMultibuffer = 0;
+ if (!AddResource (pWin->drawable.id, MultibuffersResType, (pointer) pMultibuffers))
+ return BadAlloc;
+ width = pWin->drawable.width;
+ height = pWin->drawable.height;
+ depth = pWin->drawable.depth;
+ pScreen = pWin->drawable.pScreen;
+
+ if (pWin->backgroundState != None)
+ {
+ pClearGC = GetScratchGC (pWin->drawable.depth, pScreen);
+ SetupBackgroundPainter (pWin, pClearGC);
+ clearRect.x = clearRect.y = 0;
+ clearRect.width = width;
+ clearRect.height = height;
+ }
+
+ for (i = 0; i < nbuf; i++)
+ {
+ pMultibuffer = &pMultibuffers->buffers[i];
+ pMultibuffer->eventMask = 0L;
+ pMultibuffer->otherEventMask = 0L;
+ pMultibuffer->otherClients = (OtherClientsPtr) NULL;
+ pMultibuffer->number = i;
+ pMultibuffer->side = MultibufferSideMono;
+ pMultibuffer->clobber = MultibufferUnclobbered;
+ pMultibuffer->pMultibuffers = pMultibuffers;
+ if (!AddResource (ids[i], MultibufferResType, (pointer) pMultibuffer))
+ break;
+ pMultibuffer->pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, depth);
+ if (!pMultibuffer->pPixmap)
+ break;
+ if (!AddResource (ids[i], MultibufferDrawableResType, (pointer) pMultibuffer->pPixmap))
+ {
+ FreeResource (ids[i], MultibufferResType);
+ (*pScreen->DestroyPixmap) (pMultibuffer->pPixmap);
+ break;
+ }
+ pMultibuffer->pPixmap->drawable.id = ids[i];
+
+ if (i > 0 && pClearGC)
+ {
+ ValidateGC((DrawablePtr)pMultibuffer->pPixmap, pClearGC);
+ (*pClearGC->ops->PolyFillRect)((DrawablePtr)pMultibuffer->pPixmap,
+ pClearGC, 1, &clearRect);
+ }
+ }
+ pMultibuffers->numMultibuffer = i;
+ pMultibuffers->refcnt = i;
+ pMultibuffers->displayedMultibuffer = -1;
+ if (i > 0)
+ AliasMultibuffer (pMultibuffers, 0);
+ pMultibuffers->updateAction = action;
+ pMultibuffers->updateHint = hint;
+ pMultibuffers->windowMode = MultibufferModeMono;
+ pMultibuffers->lastUpdate.months = 0;
+ pMultibuffers->lastUpdate.milliseconds = 0;
+ pMultibuffers->width = width;
+ pMultibuffers->height = height;
+ pWin->devPrivates[MultibufferWindowIndex].ptr = (pointer) pMultibuffers;
+ if (pClearGC) FreeScratchGC(pClearGC);
+ return Success;
+}
+
+
+static int
+ProcCreateImageBuffers (client)
+ register ClientPtr client;
+{
+ REQUEST(xMbufCreateImageBuffersReq);
+ xMbufCreateImageBuffersReply rep;
+ register int n;
+ WindowPtr pWin;
+ XID *ids;
+ int len, nbuf;
+ int i;
+ int err;
+
+ REQUEST_AT_LEAST_SIZE (xMbufCreateImageBuffersReq);
+ len = stuff->length - (sizeof(xMbufCreateImageBuffersReq) >> 2);
+ if (len == 0)
+ return BadLength;
+ if (!(pWin = LookupWindow (stuff->window, client)))
+ return BadWindow;
+ if (pWin->drawable.class == InputOnly)
+ return BadMatch;
+ switch (stuff->updateAction)
+ {
+ case MultibufferUpdateActionUndefined:
+ case MultibufferUpdateActionBackground:
+ case MultibufferUpdateActionUntouched:
+ case MultibufferUpdateActionCopied:
+ break;
+ default:
+ client->errorValue = stuff->updateAction;
+ return BadValue;
+ }
+ switch (stuff->updateHint)
+ {
+ case MultibufferUpdateHintFrequent:
+ case MultibufferUpdateHintIntermittent:
+ case MultibufferUpdateHintStatic:
+ break;
+ default:
+ client->errorValue = stuff->updateHint;
+ return BadValue;
+ }
+ nbuf = len;
+ ids = (XID *) &stuff[1];
+ for (i = 0; i < nbuf; i++)
+ {
+ LEGAL_NEW_RESOURCE(ids[i], client);
+ }
+ err = CreateImageBuffers (pWin, nbuf, ids,
+ stuff->updateAction, stuff->updateHint);
+ if (err != Success)
+ return err;
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.numberBuffer = ((MultibuffersPtr) (pWin->devPrivates[MultibufferWindowIndex].ptr))->numMultibuffer;
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.numberBuffer, n);
+ }
+ WriteToClient(client, sizeof (xMbufCreateImageBuffersReply), (char*)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcDisplayImageBuffers (client)
+ register ClientPtr client;
+{
+ REQUEST(xMbufDisplayImageBuffersReq);
+ MultibufferPtr *pMultibuffer;
+ MultibuffersPtr *ppMultibuffers;
+ int nbuf;
+ XID *ids;
+ int i, j;
+ CARD32 minDelay;
+ TimeStamp activateTime, bufferTime;
+
+
+ REQUEST_AT_LEAST_SIZE (xMbufDisplayImageBuffersReq);
+ nbuf = stuff->length - (sizeof (xMbufDisplayImageBuffersReq) >> 2);
+ if (!nbuf)
+ return Success;
+ minDelay = stuff->minDelay;
+ ids = (XID *) &stuff[1];
+ ppMultibuffers = (MultibuffersPtr *) ALLOCATE_LOCAL(nbuf * sizeof (MultibuffersPtr));
+ pMultibuffer = (MultibufferPtr *) ALLOCATE_LOCAL(nbuf * sizeof (MultibufferPtr));
+ if (!ppMultibuffers || !pMultibuffer)
+ {
+ if (ppMultibuffers) DEALLOCATE_LOCAL(ppMultibuffers);
+ if (pMultibuffer) DEALLOCATE_LOCAL(pMultibuffer);
+ client->errorValue = 0;
+ return BadAlloc;
+ }
+ activateTime.months = 0;
+ activateTime.milliseconds = 0;
+ for (i = 0; i < nbuf; i++)
+ {
+ pMultibuffer[i] = (MultibufferPtr) LookupIDByType (ids[i],
+MultibufferResType);
+ if (!pMultibuffer[i])
+ {
+ DEALLOCATE_LOCAL(ppMultibuffers);
+ DEALLOCATE_LOCAL(pMultibuffer);
+ client->errorValue = ids[i];
+ return MultibufferErrorBase + MultibufferBadBuffer;
+ }
+ ppMultibuffers[i] = pMultibuffer[i]->pMultibuffers;
+ for (j = 0; j < i; j++)
+ {
+ if (ppMultibuffers[i] == ppMultibuffers[j])
+ {
+ DEALLOCATE_LOCAL(ppMultibuffers);
+ DEALLOCATE_LOCAL(pMultibuffer);
+ client->errorValue = ids[i];
+ return BadMatch;
+ }
+ }
+ bufferTime = ppMultibuffers[i]->lastUpdate;
+ BumpTimeStamp (&bufferTime, minDelay);
+ if (CompareTimeStamps (bufferTime, activateTime) == LATER)
+ activateTime = bufferTime;
+ }
+ UpdateCurrentTime ();
+ if (CompareTimeStamps (activateTime, currentTime) == LATER &&
+ QueueDisplayRequest (client, activateTime))
+ {
+ ;
+ }
+ else
+ PerformDisplayRequest (ppMultibuffers, pMultibuffer, nbuf);
+
+ DEALLOCATE_LOCAL(ppMultibuffers);
+ DEALLOCATE_LOCAL(pMultibuffer);
+ return Success;
+}
+
+
+static int
+ProcDestroyImageBuffers (client)
+ register ClientPtr client;
+{
+ REQUEST (xMbufDestroyImageBuffersReq);
+ WindowPtr pWin;
+
+ REQUEST_SIZE_MATCH (xMbufDestroyImageBuffersReq);
+ if (!(pWin = LookupWindow (stuff->window, client)))
+ return BadWindow;
+ DestroyImageBuffers (pWin);
+ return Success;
+}
+
+static int
+ProcSetMBufferAttributes (client)
+ register ClientPtr client;
+{
+ REQUEST (xMbufSetMBufferAttributesReq);
+ WindowPtr pWin;
+ MultibuffersPtr pMultibuffers;
+ int len;
+ Mask vmask;
+ Mask index2;
+ CARD32 updateHint;
+ XID *vlist;
+
+ REQUEST_AT_LEAST_SIZE (xMbufSetMBufferAttributesReq);
+ pWin = LookupWindow (stuff->window, client);
+ if (!pWin)
+ return BadWindow;
+ pMultibuffers = (MultibuffersPtr)LookupIDByType (pWin->drawable.id, MultibuffersResType);
+ if (!pMultibuffers)
+ return BadMatch;
+ len = stuff->length - (sizeof (xMbufSetMBufferAttributesReq) >> 2);
+ vmask = stuff->valueMask;
+ if (len != Ones (vmask))
+ return BadLength;
+ vlist = (XID *) &stuff[1];
+ while (vmask)
+ {
+ index2 = (Mask) lowbit (vmask);
+ vmask &= ~index2;
+ switch (index2)
+ {
+ case MultibufferWindowUpdateHint:
+ updateHint = (CARD32) *vlist;
+ switch (updateHint)
+ {
+ case MultibufferUpdateHintFrequent:
+ case MultibufferUpdateHintIntermittent:
+ case MultibufferUpdateHintStatic:
+ pMultibuffers->updateHint = updateHint;
+ break;
+ default:
+ client->errorValue = updateHint;
+ return BadValue;
+ }
+ vlist++;
+ break;
+ default:
+ client->errorValue = stuff->valueMask;
+ return BadValue;
+ }
+ }
+ return Success;
+}
+
+static int
+ProcGetMBufferAttributes (client)
+ ClientPtr client;
+{
+ REQUEST (xMbufGetMBufferAttributesReq);
+ WindowPtr pWin;
+ MultibuffersPtr pMultibuffers;
+ XID *ids;
+ xMbufGetMBufferAttributesReply rep;
+ int i, n;
+
+ REQUEST_SIZE_MATCH (xMbufGetMBufferAttributesReq);
+ pWin = LookupWindow (stuff->window, client);
+ if (!pWin)
+ return BadWindow;
+ pMultibuffers = (MultibuffersPtr)LookupIDByType (pWin->drawable.id, MultibuffersResType);
+ if (!pMultibuffers)
+ return BadAccess;
+ ids = (XID *) ALLOCATE_LOCAL (pMultibuffers->numMultibuffer * sizeof (XID));
+ if (!ids)
+ return BadAlloc;
+ for (i = 0; i < pMultibuffers->numMultibuffer; i++)
+ ids[i] = pMultibuffers->buffers[i].pPixmap->drawable.id;
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = pMultibuffers->numMultibuffer;
+ rep.displayedBuffer = pMultibuffers->displayedMultibuffer;
+ rep.updateAction = pMultibuffers->updateAction;
+ rep.updateHint = pMultibuffers->updateHint;
+ rep.windowMode = pMultibuffers->windowMode;
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.displayedBuffer, n);
+ SwapLongs (ids, pMultibuffers->numMultibuffer);
+ }
+ WriteToClient (client, sizeof(xMbufGetMBufferAttributesReply),
+ (char *)&rep);
+ WriteToClient (client, (int)(pMultibuffers->numMultibuffer * sizeof (XID)),
+ (char *)ids);
+ DEALLOCATE_LOCAL((pointer) ids);
+ return client->noClientException;
+}
+
+static int
+ProcSetBufferAttributes (client)
+ register ClientPtr client;
+{
+ REQUEST(xMbufSetBufferAttributesReq);
+ MultibufferPtr pMultibuffer;
+ int len;
+ Mask vmask, index2;
+ XID *vlist;
+ Mask eventMask;
+ int result;
+
+ REQUEST_AT_LEAST_SIZE (xMbufSetBufferAttributesReq);
+ pMultibuffer = (MultibufferPtr) LookupIDByType (stuff->buffer, MultibufferResType);
+ if (!pMultibuffer)
+ return MultibufferErrorBase + MultibufferBadBuffer;
+ len = stuff->length - (sizeof (xMbufSetBufferAttributesReq) >> 2);
+ vmask = stuff->valueMask;
+ if (len != Ones (vmask))
+ return BadLength;
+ vlist = (XID *) &stuff[1];
+ while (vmask)
+ {
+ index2 = (Mask) lowbit (vmask);
+ vmask &= ~index2;
+ switch (index2)
+ {
+ case MultibufferBufferEventMask:
+ eventMask = (Mask) *vlist;
+ vlist++;
+ result = EventSelectForMultibuffer (pMultibuffer, client, eventMask);
+ if (result != Success)
+ return result;
+ break;
+ default:
+ client->errorValue = stuff->valueMask;
+ return BadValue;
+ }
+ }
+ return Success;
+}
+
+int
+ProcGetBufferAttributes (client)
+ register ClientPtr client;
+{
+ REQUEST(xMbufGetBufferAttributesReq);
+ MultibufferPtr pMultibuffer;
+ xMbufGetBufferAttributesReply rep;
+ OtherClientsPtr other;
+ int n;
+
+ REQUEST_SIZE_MATCH (xMbufGetBufferAttributesReq);
+ pMultibuffer = (MultibufferPtr) LookupIDByType (stuff->buffer, MultibufferResType);
+ if (!pMultibuffer)
+ return MultibufferErrorBase + MultibufferBadBuffer;
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.window = pMultibuffer->pMultibuffers->pWindow->drawable.id;
+ if (bClient (pMultibuffer) == client)
+ rep.eventMask = pMultibuffer->eventMask;
+ else
+ {
+ rep.eventMask = (Mask) 0L;
+ for (other = pMultibuffer->otherClients; other; other = other->next)
+ if (SameClient (other, client))
+ {
+ rep.eventMask = other->mask;
+ break;
+ }
+ }
+ rep.bufferIndex = pMultibuffer->number;
+ rep.side = pMultibuffer->side;
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.window, n);
+ swapl(&rep.eventMask, n);
+ swaps(&rep.bufferIndex, n);
+ }
+ WriteToClient(client, sizeof (xMbufGetBufferAttributesReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcGetBufferInfo (client)
+ register ClientPtr client;
+{
+ REQUEST (xMbufGetBufferInfoReq);
+ DrawablePtr pDrawable;
+ xMbufGetBufferInfoReply rep;
+ ScreenPtr pScreen;
+ int i, j, k;
+ int n;
+ xMbufBufferInfo *pInfo;
+ int nInfo;
+ DepthPtr pDepth;
+
+ pDrawable = (DrawablePtr) LookupDrawable (stuff->drawable, client);
+ if (!pDrawable)
+ return BadDrawable;
+ pScreen = pDrawable->pScreen;
+ nInfo = 0;
+ for (i = 0; i < pScreen->numDepths; i++)
+ {
+ pDepth = &pScreen->allowedDepths[i];
+ nInfo += pDepth->numVids;
+ }
+ pInfo = (xMbufBufferInfo *)
+ ALLOCATE_LOCAL (nInfo * sizeof (xMbufBufferInfo));
+ if (!pInfo)
+ return BadAlloc;
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = nInfo * (sizeof (xMbufBufferInfo) >> 2);
+ rep.normalInfo = nInfo;
+ rep.stereoInfo = 0;
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.normalInfo, n);
+ swaps(&rep.stereoInfo, n);
+ }
+
+ k = 0;
+ for (i = 0; i < pScreen->numDepths; i++)
+ {
+ pDepth = &pScreen->allowedDepths[i];
+ for (j = 0; j < pDepth->numVids; j++)
+ {
+ pInfo[k].visualID = pDepth->vids[j];
+ pInfo[k].maxBuffers = 0;
+ pInfo[k].depth = pDepth->depth;
+ if (client->swapped)
+ {
+ swapl (&pInfo[k].visualID, n);
+ swaps (&pInfo[k].maxBuffers, n);
+ }
+ k++;
+ }
+ }
+ WriteToClient (client, sizeof (xMbufGetBufferInfoReply), (pointer) &rep);
+ WriteToClient (client, (int) nInfo * sizeof (xMbufBufferInfo), (pointer) pInfo);
+ DEALLOCATE_LOCAL ((pointer) pInfo);
+ return client->noClientException;
+}
+
+static int
+ProcClearImageBufferArea (client)
+ register ClientPtr client;
+{
+ REQUEST (xMbufClearImageBufferAreaReq);
+ MultibufferPtr pMultibuffer;
+ WindowPtr pWin;
+ xRectangle clearRect;
+ int width, height;
+ DrawablePtr pDrawable;
+ ScreenPtr pScreen;
+
+ REQUEST_SIZE_MATCH (xMbufClearImageBufferAreaReq);
+ pMultibuffer = (MultibufferPtr) LookupIDByType (stuff->buffer, MultibufferResType);
+ if (!pMultibuffer)
+ return MultibufferErrorBase + MultibufferBadBuffer;
+ if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse))
+ {
+ client->errorValue = stuff->exposures;
+ return(BadValue);
+ }
+ pWin = pMultibuffer->pMultibuffers->pWindow;
+ width = pWin->drawable.width;
+ height = pWin->drawable.height;
+ pScreen = pWin->drawable.pScreen;
+
+ clearRect.x = stuff->x;
+ clearRect.y = stuff->y;
+ clearRect.width = stuff->width ? stuff->width : width;
+ clearRect.height = stuff->height ? stuff->height : height;
+
+ if (pWin->backgroundState != None)
+ {
+ GCPtr pClearGC;
+ pClearGC = GetScratchGC (pWin->drawable.depth, pScreen);
+ SetupBackgroundPainter (pWin, pClearGC);
+
+ if (pMultibuffer->number == pMultibuffer->pMultibuffers->displayedMultibuffer)
+ pDrawable = (DrawablePtr)pWin;
+ else
+ pDrawable = (DrawablePtr)pMultibuffer->pPixmap;
+
+ ValidateGC(pDrawable, pClearGC);
+ (*pClearGC->ops->PolyFillRect) (pDrawable, pClearGC, 1, &clearRect);
+ FreeScratchGC(pClearGC);
+ }
+
+ if (stuff->exposures)
+ {
+ RegionRec region;
+ BoxRec box;
+ box.x1 = clearRect.x;
+ box.y1 = clearRect.y;
+ box.x2 = clearRect.x + clearRect.width;
+ box.y2 = clearRect.y + clearRect.height;
+ REGION_INIT(pScreen, &region, &box, 1);
+ MultibufferExpose(pMultibuffer, &region);
+ REGION_UNINIT(pScreen, &region);
+ }
+ return Success;
+}
+
+static int
+ProcMultibufferDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data) {
+ case X_MbufGetBufferVersion:
+ return ProcGetBufferVersion (client);
+ case X_MbufCreateImageBuffers:
+ return ProcCreateImageBuffers (client);
+ case X_MbufDisplayImageBuffers:
+ return ProcDisplayImageBuffers (client);
+ case X_MbufDestroyImageBuffers:
+ return ProcDestroyImageBuffers (client);
+ case X_MbufSetMBufferAttributes:
+ return ProcSetMBufferAttributes (client);
+ case X_MbufGetMBufferAttributes:
+ return ProcGetMBufferAttributes (client);
+ case X_MbufSetBufferAttributes:
+ return ProcSetBufferAttributes (client);
+ case X_MbufGetBufferAttributes:
+ return ProcGetBufferAttributes (client);
+ case X_MbufGetBufferInfo:
+ return ProcGetBufferInfo (client);
+ case X_MbufClearImageBufferArea:
+ return ProcClearImageBufferArea (client);
+ default:
+ return BadRequest;
+ }
+}
+
+static int
+SProcGetBufferVersion (client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST (xMbufGetBufferVersionReq);
+
+ swaps (&stuff->length, n);
+ return ProcGetBufferVersion (client);
+}
+
+static int
+SProcCreateImageBuffers (client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST (xMbufCreateImageBuffersReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE (xMbufCreateImageBuffersReq);
+ swapl (&stuff->window, n);
+ SwapRestL(stuff);
+ return ProcCreateImageBuffers (client);
+}
+
+static int
+SProcDisplayImageBuffers (client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST (xMbufDisplayImageBuffersReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE (xMbufDisplayImageBuffersReq);
+ swaps (&stuff->minDelay, n);
+ swaps (&stuff->maxDelay, n);
+ SwapRestL(stuff);
+ return ProcDisplayImageBuffers (client);
+}
+
+static int
+SProcDestroyImageBuffers (client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST (xMbufDestroyImageBuffersReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH (xMbufDestroyImageBuffersReq);
+ swapl (&stuff->window, n);
+ return ProcDestroyImageBuffers (client);
+}
+
+static int
+SProcSetMBufferAttributes (client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST (xMbufSetMBufferAttributesReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xMbufSetMBufferAttributesReq);
+ swapl (&stuff->window, n);
+ swapl (&stuff->valueMask, n);
+ SwapRestL(stuff);
+ return ProcSetMBufferAttributes (client);
+}
+
+static int
+SProcGetMBufferAttributes (client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST (xMbufGetMBufferAttributesReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xMbufGetMBufferAttributesReq);
+ swapl (&stuff->window, n);
+ return ProcGetMBufferAttributes (client);
+}
+
+static int
+SProcSetBufferAttributes (client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST (xMbufSetBufferAttributesReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xMbufSetBufferAttributesReq);
+ swapl (&stuff->buffer, n);
+ swapl (&stuff->valueMask, n);
+ SwapRestL(stuff);
+ return ProcSetBufferAttributes (client);
+}
+
+static int
+SProcGetBufferAttributes (client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST (xMbufGetBufferAttributesReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xMbufGetBufferAttributesReq);
+ swapl (&stuff->buffer, n);
+ return ProcGetBufferAttributes (client);
+}
+
+static int
+SProcGetBufferInfo (client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST (xMbufGetBufferInfoReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH (xMbufGetBufferInfoReq);
+ swapl (&stuff->drawable, n);
+ return ProcGetBufferInfo (client);
+}
+
+static int
+SProcClearImageBufferArea(client)
+ register ClientPtr client;
+{
+ register char n;
+ REQUEST(xMbufClearImageBufferAreaReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xMbufClearImageBufferAreaReq);
+ swapl(&stuff->buffer, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ return ProcClearImageBufferArea(client);
+}
+
+static int
+SProcMultibufferDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data) {
+ case X_MbufGetBufferVersion:
+ return SProcGetBufferVersion (client);
+ case X_MbufCreateImageBuffers:
+ return SProcCreateImageBuffers (client);
+ case X_MbufDisplayImageBuffers:
+ return SProcDisplayImageBuffers (client);
+ case X_MbufDestroyImageBuffers:
+ return SProcDestroyImageBuffers (client);
+ case X_MbufSetMBufferAttributes:
+ return SProcSetMBufferAttributes (client);
+ case X_MbufGetMBufferAttributes:
+ return SProcGetMBufferAttributes (client);
+ case X_MbufSetBufferAttributes:
+ return SProcSetBufferAttributes (client);
+ case X_MbufGetBufferAttributes:
+ return SProcGetBufferAttributes (client);
+ case X_MbufGetBufferInfo:
+ return SProcGetBufferInfo (client);
+ case X_MbufClearImageBufferArea:
+ return SProcClearImageBufferArea (client);
+ default:
+ return BadRequest;
+ }
+}
+
+static void
+SUpdateNotifyEvent (from, to)
+ xMbufUpdateNotifyEvent *from, *to;
+{
+ to->type = from->type;
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswapl (from->buffer, to->buffer);
+ cpswapl (from->timeStamp, to->timeStamp);
+}
+
+static void
+SClobberNotifyEvent (from, to)
+ xMbufClobberNotifyEvent *from, *to;
+{
+ to->type = from->type;
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswapl (from->buffer, to->buffer);
+ to->state = from->state;
+}
+
+static void
+PerformDisplayRequest (ppMultibuffers, pMultibuffer, nbuf)
+ MultibufferPtr *pMultibuffer;
+ MultibuffersPtr *ppMultibuffers;
+ int nbuf;
+{
+ GCPtr pGC;
+ PixmapPtr pPrevPixmap, pNewPixmap;
+ xRectangle clearRect;
+ WindowPtr pWin;
+ RegionPtr pExposed;
+ int i;
+ MultibufferPtr pPrevMultibuffer;
+ XID graphicsExpose;
+
+ UpdateCurrentTime ();
+ for (i = 0; i < nbuf; i++)
+ {
+ pWin = ppMultibuffers[i]->pWindow;
+ pGC = GetScratchGC (pWin->drawable.depth, pWin->drawable.pScreen);
+ pPrevMultibuffer =
+ &ppMultibuffers[i]->buffers[ppMultibuffers[i]->displayedMultibuffer];
+ pPrevPixmap = pPrevMultibuffer->pPixmap;
+ pNewPixmap = pMultibuffer[i]->pPixmap;
+ switch (ppMultibuffers[i]->updateAction)
+ {
+ case MultibufferUpdateActionUndefined:
+ break;
+ case MultibufferUpdateActionBackground:
+ SetupBackgroundPainter (pWin, pGC);
+ ValidateGC ((DrawablePtr)pPrevPixmap, pGC);
+ clearRect.x = 0;
+ clearRect.y = 0;
+ clearRect.width = pPrevPixmap->drawable.width;
+ clearRect.height = pPrevPixmap->drawable.height;
+ (*pGC->ops->PolyFillRect) ((DrawablePtr)pPrevPixmap, pGC,
+ 1, &clearRect);
+ break;
+ case MultibufferUpdateActionUntouched:
+ /* copy the window to the pixmap that represents the
+ * currently displayed buffer
+ */
+ if (pPrevMultibuffer->eventMask & ExposureMask)
+ {
+ graphicsExpose = TRUE;
+ DoChangeGC (pGC, GCGraphicsExposures, &graphicsExpose, FALSE);
+ }
+ ValidateGC ((DrawablePtr)pPrevPixmap, pGC);
+ pExposed = (*pGC->ops->CopyArea)
+ ((DrawablePtr) pWin,
+ (DrawablePtr) pPrevPixmap,
+ pGC,
+ 0, 0,
+ pWin->drawable.width, pWin->drawable.height,
+ 0, 0);
+
+ /* if we couldn't copy the whole window to the buffer,
+ * send expose events (if any client wants them)
+ */
+ if (pPrevMultibuffer->eventMask & ExposureMask)
+ { /* some client wants expose events */
+ if (pExposed)
+ {
+ RegionPtr pWinSize;
+
+ pWinSize = CreateUnclippedWinSize (pWin);
+ /* pExposed is window-relative, but at this point
+ * pWinSize is screen-relative. Make pWinSize be
+ * window-relative so that region ops involving
+ * pExposed and pWinSize behave sensibly.
+ */
+ REGION_TRANSLATE(pWin->drawable.pScreen, pWinSize,
+ -pWin->drawable.x, -pWin->drawable.y);
+ REGION_INTERSECT(pWin->drawable.pScreen, pExposed,
+ pExposed, pWinSize);
+ REGION_DESTROY(pWin->drawable.pScreen, pWinSize);
+ MultibufferExpose (pPrevMultibuffer, pExposed);
+ REGION_DESTROY(pWin->drawable.pScreen, pExposed);
+ }
+ graphicsExpose = FALSE;
+ DoChangeGC (pGC, GCGraphicsExposures, &graphicsExpose, FALSE);
+ }
+ break; /* end case MultibufferUpdateActionUntouched */
+
+ case MultibufferUpdateActionCopied:
+ ValidateGC ((DrawablePtr)pPrevPixmap, pGC);
+ (*pGC->ops->CopyArea) ((DrawablePtr)pNewPixmap,
+ (DrawablePtr)pPrevPixmap, pGC,
+ 0, 0,
+ pWin->drawable.width, pWin->drawable.height,
+ 0, 0);
+ break;
+ } /* end switch on update action */
+
+ /* display the new buffer */
+ ValidateGC ((DrawablePtr)pWin, pGC);
+ (*pGC->ops->CopyArea) ((DrawablePtr)pNewPixmap, (DrawablePtr)pWin, pGC,
+ 0, 0,
+ pWin->drawable.width, pWin->drawable.height,
+ 0, 0);
+ ppMultibuffers[i]->lastUpdate = currentTime;
+ MultibufferUpdate (pMultibuffer[i],
+ ppMultibuffers[i]->lastUpdate.milliseconds);
+ AliasMultibuffer (ppMultibuffers[i],
+ pMultibuffer[i] - ppMultibuffers[i]->buffers);
+ FreeScratchGC (pGC);
+ }
+}
+
+DrawablePtr
+GetBufferPointer (pWin, i)
+ WindowPtr pWin;
+ int i;
+{
+ MultibuffersPtr pMultibuffers;
+
+ if (!(pMultibuffers = (MultibuffersPtr) pWin->devPrivates[MultibufferWindowIndex].ptr))
+ return NULL;
+ return (DrawablePtr) pMultibuffers->buffers[i].pPixmap;
+}
+
+int
+DisplayImageBuffers (ids, nbuf)
+ XID *ids;
+ int nbuf;
+{
+ MultibufferPtr *pMultibuffer;
+ MultibuffersPtr *pMultibuffers;
+ int i, j;
+
+ pMultibuffer = (MultibufferPtr *) ALLOCATE_LOCAL (nbuf * sizeof *pMultibuffer +
+ nbuf * sizeof *pMultibuffers);
+ if (!pMultibuffer)
+ return BadAlloc;
+ pMultibuffers = (MultibuffersPtr *) (pMultibuffer + nbuf);
+ for (i = 0; i < nbuf; i++)
+ {
+ pMultibuffer[i] = (MultibufferPtr) LookupIDByType (ids[i], MultibufferResType);
+ if (!pMultibuffer[i])
+ {
+ DEALLOCATE_LOCAL (pMultibuffer);
+ return MultibufferErrorBase + MultibufferBadBuffer;
+ }
+ pMultibuffers[i] = pMultibuffer[i]->pMultibuffers;
+ for (j = 0; j < i; j++)
+ if (pMultibuffers[i] == pMultibuffers[j])
+ {
+ DEALLOCATE_LOCAL (pMultibuffer);
+ return BadMatch;
+ }
+ }
+ PerformDisplayRequest (pMultibuffers, pMultibuffer, nbuf);
+ DEALLOCATE_LOCAL (pMultibuffer);
+ return Success;
+}
+
+
+static Bool
+QueueDisplayRequest (client, activateTime)
+ ClientPtr client;
+ TimeStamp activateTime;
+{
+ /* see xtest.c:ProcXTestFakeInput for code similar to this */
+
+ if (!ClientSleepUntil(client, &activateTime, NULL, NULL))
+ {
+ return FALSE;
+ }
+ /* swap the request back so we can simply re-execute it */
+ if (client->swapped)
+ {
+ register int n;
+ REQUEST (xMbufDisplayImageBuffersReq);
+
+ SwapRestL(stuff);
+ swaps (&stuff->length, n);
+ swaps (&stuff->minDelay, n);
+ swaps (&stuff->maxDelay, n);
+ }
+ ResetCurrentRequest (client);
+ client->sequence--;
+ return TRUE;
+}
+
+
+/*
+ * Deliver events to a buffer
+ */
+
+static int
+DeliverEventsToMultibuffer (pMultibuffer, pEvents, count, filter)
+ MultibufferPtr pMultibuffer;
+ xEvent *pEvents;
+ int count;
+ Mask filter;
+{
+ int deliveries = 0, nondeliveries = 0;
+ int attempt;
+ OtherClients *other;
+
+ /* if nobody wants the event, we're done */
+ if (!((pMultibuffer->otherEventMask|pMultibuffer->eventMask) & filter))
+ return 0;
+
+ /* maybe send event to owner */
+ if ((attempt = TryClientEvents(
+ bClient(pMultibuffer), pEvents, count, pMultibuffer->eventMask, filter, (GrabPtr) 0)) != 0)
+ {
+ if (attempt > 0)
+ deliveries++;
+ else
+ nondeliveries--;
+ }
+
+ /* maybe send event to other clients */
+ for (other = pMultibuffer->otherClients; other; other=other->next)
+ {
+ if ((attempt = TryClientEvents(
+ rClient(other), pEvents, count, other->mask, filter, (GrabPtr) 0)) != 0)
+ {
+ if (attempt > 0)
+ deliveries++;
+ else
+ nondeliveries--;
+ }
+ }
+ if (deliveries)
+ return deliveries;
+ return nondeliveries;
+}
+
+/*
+ * Send Expose events to interested clients
+ */
+
+void
+MultibufferExpose (pMultibuffer, pRegion)
+ MultibufferPtr pMultibuffer;
+ RegionPtr pRegion;
+{
+ if (pRegion && !REGION_NIL(pRegion))
+ {
+ xEvent *pEvent;
+ PixmapPtr pPixmap;
+ register xEvent *pe;
+ register BoxPtr pBox;
+ register int i;
+ int numRects;
+
+ pPixmap = pMultibuffer->pPixmap;
+ REGION_TRANSLATE(pPixmap->drawable.pScreen, pRegion,
+ -pPixmap->drawable.x, -pPixmap->drawable.y);
+ /* XXX MultibufferExpose "knows" the region representation */
+ numRects = REGION_NUM_RECTS(pRegion);
+ pBox = REGION_RECTS(pRegion);
+
+ pEvent = (xEvent *) ALLOCATE_LOCAL(numRects * sizeof(xEvent));
+ if (pEvent) {
+ pe = pEvent;
+
+ for (i=1; i<=numRects; i++, pe++, pBox++)
+ {
+ pe->u.u.type = Expose;
+ pe->u.expose.window = pPixmap->drawable.id;
+ pe->u.expose.x = pBox->x1;
+ pe->u.expose.y = pBox->y1;
+ pe->u.expose.width = pBox->x2 - pBox->x1;
+ pe->u.expose.height = pBox->y2 - pBox->y1;
+ pe->u.expose.count = (numRects - i);
+ }
+ (void) DeliverEventsToMultibuffer (pMultibuffer, pEvent, numRects,
+ ExposureMask);
+ DEALLOCATE_LOCAL(pEvent);
+ }
+ }
+}
+
+/* send UpdateNotify event */
+void
+MultibufferUpdate (pMultibuffer, time2)
+ MultibufferPtr pMultibuffer;
+ CARD32 time2;
+{
+ xMbufUpdateNotifyEvent event;
+
+ event.type = MultibufferEventBase + MultibufferUpdateNotify;
+ event.buffer = pMultibuffer->pPixmap->drawable.id;
+ event.timeStamp = time2;
+ (void) DeliverEventsToMultibuffer (pMultibuffer, (xEvent *)&event,
+ 1, (Mask)MultibufferUpdateNotifyMask);
+}
+
+/*
+ * The sample implementation will never generate MultibufferClobberNotify
+ * events
+ */
+
+void
+MultibufferClobber (pMultibuffer)
+ MultibufferPtr pMultibuffer;
+{
+ xMbufClobberNotifyEvent event;
+
+ event.type = MultibufferEventBase + MultibufferClobberNotify;
+ event.buffer = pMultibuffer->pPixmap->drawable.id;
+ event.state = pMultibuffer->clobber;
+ (void) DeliverEventsToMultibuffer (pMultibuffer, (xEvent *)&event,
+ 1, (Mask)MultibufferClobberNotifyMask);
+}
+
+/*
+ * make the resource id for buffer i refer to the window
+ * drawable instead of the pixmap;
+ */
+
+static void
+AliasMultibuffer (pMultibuffers, i)
+ MultibuffersPtr pMultibuffers;
+ int i;
+{
+ MultibufferPtr pMultibuffer;
+
+ if (i == pMultibuffers->displayedMultibuffer)
+ return;
+ /*
+ * remove the old association
+ */
+ if (pMultibuffers->displayedMultibuffer >= 0)
+ {
+ pMultibuffer = &pMultibuffers->buffers[pMultibuffers->displayedMultibuffer];
+ ChangeResourceValue (pMultibuffer->pPixmap->drawable.id,
+ MultibufferDrawableResType,
+ (pointer) pMultibuffer->pPixmap);
+ }
+ /*
+ * make the new association
+ */
+ pMultibuffer = &pMultibuffers->buffers[i];
+ ChangeResourceValue (pMultibuffer->pPixmap->drawable.id,
+ MultibufferDrawableResType,
+ (pointer) pMultibuffers->pWindow);
+ pMultibuffers->displayedMultibuffer = i;
+}
+
+/*
+ * free everything associated with multibuffering for this
+ * window
+ */
+
+void
+DestroyImageBuffers (pWin)
+ WindowPtr pWin;
+{
+ FreeResourceByType (pWin->drawable.id, MultibuffersResType, FALSE);
+ /* Zero out the window's pointer to the buffers so they won't be reused */
+ pWin->devPrivates[MultibufferWindowIndex].ptr = NULL;
+}
+
+/*
+ * resize the buffers when the window is resized
+ */
+
+static Bool
+MultibufferPositionWindow (pWin, x, y)
+ WindowPtr pWin;
+ int x, y;
+{
+ ScreenPtr pScreen;
+ MultibufferScreenPtr pMultibufferScreen;
+ MultibuffersPtr pMultibuffers;
+ MultibufferPtr pMultibuffer;
+ int width, height;
+ int i;
+ int dx, dy, dw, dh;
+ int sourcex, sourcey;
+ int destx, desty;
+ PixmapPtr pPixmap;
+ GCPtr pGC;
+ int savewidth, saveheight;
+ xRectangle clearRect;
+ Bool clear;
+
+ pScreen = pWin->drawable.pScreen;
+ pMultibufferScreen = (MultibufferScreenPtr) pScreen->devPrivates[MultibufferScreenIndex].ptr;
+ (*pMultibufferScreen->PositionWindow) (pWin, x, y);
+
+ /* if this window is not multibuffered, we're done */
+ if (!(pMultibuffers = (MultibuffersPtr) pWin->devPrivates[MultibufferWindowIndex].ptr))
+ return TRUE;
+
+ /* if new size is same as old, we're done */
+ if (pMultibuffers->width == pWin->drawable.width &&
+ pMultibuffers->height == pWin->drawable.height)
+ return TRUE;
+
+ width = pWin->drawable.width;
+ height = pWin->drawable.height;
+ dx = pWin->drawable.x - pMultibuffers->x;
+ dy = pWin->drawable.x - pMultibuffers->y;
+ dw = width - pMultibuffers->width;
+ dh = height - pMultibuffers->height;
+ GravityTranslate (0, 0, -dx, -dy, dw, dh,
+ pWin->bitGravity, &destx, &desty);
+
+ /* if the window grew, remember to paint the window background,
+ * and maybe send expose events, for the new areas of the buffers
+ */
+ clear = pMultibuffers->width < width || pMultibuffers->height < height ||
+ pWin->bitGravity == ForgetGravity;
+
+ sourcex = 0;
+ sourcey = 0;
+ savewidth = pMultibuffers->width;
+ saveheight = pMultibuffers->height;
+ /* clip rectangle to source and destination */
+ if (destx < 0)
+ {
+ savewidth += destx;
+ sourcex -= destx;
+ destx = 0;
+ }
+ if (destx + savewidth > width)
+ savewidth = width - destx;
+ if (desty < 0)
+ {
+ saveheight += desty;
+ sourcey -= desty;
+ desty = 0;
+ }
+ if (desty + saveheight > height)
+ saveheight = height - desty;
+
+ pMultibuffers->width = width;
+ pMultibuffers->height = height;
+ pMultibuffers->x = pWin->drawable.x;
+ pMultibuffers->y = pWin->drawable.y;
+
+ pGC = GetScratchGC (pWin->drawable.depth, pScreen);
+ if (clear)
+ {
+ SetupBackgroundPainter (pWin, pGC);
+ clearRect.x = 0;
+ clearRect.y = 0;
+ clearRect.width = width;
+ clearRect.height = height;
+ }
+ for (i = 0; i < pMultibuffers->numMultibuffer; i++)
+ {
+ pMultibuffer = &pMultibuffers->buffers[i];
+ pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
+ pWin->drawable.depth);
+ if (!pPixmap)
+ {
+ DestroyImageBuffers (pWin);
+ break;
+ }
+ ValidateGC ((DrawablePtr)pPixmap, pGC);
+ /*
+ * I suppose this could avoid quite a bit of work if
+ * it computed the minimal area required.
+ */
+ if (clear)
+ (*pGC->ops->PolyFillRect) ((DrawablePtr)pPixmap, pGC, 1, &clearRect);
+ if (pWin->bitGravity != ForgetGravity)
+ {
+ (*pGC->ops->CopyArea) ((DrawablePtr)pMultibuffer->pPixmap,
+ (DrawablePtr)pPixmap, pGC,
+ sourcex, sourcey, savewidth, saveheight,
+ destx, desty);
+ }
+ pPixmap->drawable.id = pMultibuffer->pPixmap->drawable.id;
+ (*pScreen->DestroyPixmap) (pMultibuffer->pPixmap);
+ pMultibuffer->pPixmap = pPixmap;
+ if (i != pMultibuffers->displayedMultibuffer)
+ {
+ ChangeResourceValue (pPixmap->drawable.id,
+ MultibufferDrawableResType,
+ (pointer) pPixmap);
+ }
+ }
+ FreeScratchGC (pGC);
+ return TRUE;
+}
+
+/* Resource delete func for MultibufferDrawableResType */
+/*ARGSUSED*/
+static int
+MultibufferDrawableDelete (value, id)
+ pointer value;
+ XID id;
+{
+ DrawablePtr pDrawable = (DrawablePtr)value;
+ WindowPtr pWin;
+ MultibuffersPtr pMultibuffers;
+ PixmapPtr pPixmap;
+
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ {
+ pWin = (WindowPtr) pDrawable;
+ pMultibuffers = (MultibuffersPtr) pWin->devPrivates[MultibufferWindowIndex].ptr;
+ pPixmap = pMultibuffers->buffers[pMultibuffers->displayedMultibuffer].pPixmap;
+ }
+ else
+ {
+ pPixmap = (PixmapPtr) pDrawable;
+ }
+ (*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap);
+ return Success;
+}
+
+/* Resource delete func for MultibufferResType */
+/*ARGSUSED*/
+static int
+MultibufferDelete (value, id)
+ pointer value;
+ XID id;
+{
+ MultibufferPtr pMultibuffer = (MultibufferPtr)value;
+ MultibuffersPtr pMultibuffers;
+
+ pMultibuffers = pMultibuffer->pMultibuffers;
+ if (--pMultibuffers->refcnt == 0)
+ {
+ FreeResourceByType (pMultibuffers->pWindow->drawable.id,
+ MultibuffersResType, TRUE);
+ xfree (pMultibuffers);
+ }
+ return Success;
+}
+
+/* Resource delete func for MultibuffersResType */
+/*ARGSUSED*/
+static int
+MultibuffersDelete (value, id)
+ pointer value;
+ XID id;
+{
+ MultibuffersPtr pMultibuffers = (MultibuffersPtr)value;
+ int i;
+
+ if (pMultibuffers->refcnt == pMultibuffers->numMultibuffer)
+ {
+ for (i = pMultibuffers->numMultibuffer; --i >= 0; )
+ FreeResource (pMultibuffers->buffers[i].pPixmap->drawable.id, 0);
+ }
+ return Success;
+}
+
+/* Resource delete func for OtherClientResType */
+static int
+OtherClientDelete (value, id)
+ pointer value;
+ XID id;
+{
+ MultibufferPtr pMultibuffer = (MultibufferPtr)value;
+ register OtherClientsPtr other, prev;
+
+ prev = 0;
+ for (other = pMultibuffer->otherClients; other; other = other->next)
+ {
+ if (other->resource == id)
+ {
+ if (prev)
+ prev->next = other->next;
+ else
+ pMultibuffer->otherClients = other->next;
+ xfree (other);
+ RecalculateMultibufferOtherEvents (pMultibuffer);
+ break;
+ }
+ prev = other;
+ }
+ return Success;
+}
+
+static int
+EventSelectForMultibuffer (pMultibuffer, client, mask)
+ MultibufferPtr pMultibuffer;
+ ClientPtr client;
+ Mask mask;
+{
+ OtherClientsPtr other;
+
+ if (mask & ~ValidEventMasks)
+ {
+ client->errorValue = mask;
+ return BadValue;
+ }
+ if (bClient (pMultibuffer) == client)
+ {
+ pMultibuffer->eventMask = mask;
+ }
+ else /* some other client besides the creator wants events */
+ {
+ for (other = pMultibuffer->otherClients; other; other = other->next)
+ {
+ if (SameClient (other, client))
+ {
+ if (mask == 0)
+ {
+ FreeResource (other->resource, RT_NONE);
+ break;
+ }
+ other->mask = mask;
+ break;
+ }
+ }
+ if (!other)
+ { /* new client that never selected events on this buffer before */
+ other = (OtherClients *) xalloc (sizeof (OtherClients));
+ if (!other)
+ return BadAlloc;
+ other->mask = mask;
+ other->resource = FakeClientID (client->index);
+ if (!AddResource (other->resource, OtherClientResType, (pointer) pMultibuffer))
+ {
+ xfree (other);
+ return BadAlloc;
+ }
+ other->next = pMultibuffer->otherClients;
+ pMultibuffer->otherClients = other;
+ }
+ RecalculateMultibufferOtherEvents (pMultibuffer);
+ }
+ return (client->noClientException);
+}
+
+/* or together all the otherClients event masks */
+static void
+RecalculateMultibufferOtherEvents (pMultibuffer)
+ MultibufferPtr pMultibuffer;
+{
+ Mask otherEventMask;
+ OtherClients *other;
+
+ otherEventMask = 0L;
+ for (other = pMultibuffer->otherClients; other; other = other->next)
+ otherEventMask |= other->mask;
+ pMultibuffer->otherEventMask = otherEventMask;
+}
+
+/* add milliseconds to a timestamp, handling overflow */
+static void
+BumpTimeStamp (ts, inc)
+TimeStamp *ts;
+CARD32 inc;
+{
+ CARD32 newms;
+
+ newms = ts->milliseconds + inc;
+ if (newms < ts->milliseconds)
+ ts->months++;
+ ts->milliseconds = newms;
+}
diff --git a/nx-X11/programs/Xserver/Xext/mbufbf.c b/nx-X11/programs/Xserver/Xext/mbufbf.c
new file mode 100644
index 000000000..8585c52d2
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/mbufbf.c
@@ -0,0 +1,1030 @@
+/* $XFree86: xc/programs/Xserver/Xext/mbufbf.c,v 3.5tsi Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/* $Xorg: mbufbf.c,v 1.4 2001/02/09 02:04:32 xorgcvs Exp $ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "opaque.h"
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "inputstr.h"
+#include "validate.h"
+#include <sys/time.h>
+
+#define _MULTIBUF_SERVER_ /* don't want Xlib structures */
+#define _MULTIBUF_BUFFER_
+#include <X11/extensions/multibufst.h>
+
+/*
+Support for doublebuffer hardare
+
+This code is designed to support doublebuffer hardware where the
+displayed buffer is selected on a per-pixel basis by an additional bit
+plane, called the select plane. It could probably be easily modified
+to work with systems that use window-id planes.
+
+This is done by creating a new drawable type, DRAWABLE_BUFFER. The
+type has the same exact layout as a window drawable. Your code should
+treat a DRAWABLE_BUFFER the same as it would tread a DRAWABLE_WINDOW
+when handling the gc drawing functions. In addition, PaintWindowBackground,
+CopyWindow, and all of the gc drawing functions to be able to draw into both
+framebuffers. Which framebuffer to draw into is selected by the contents of
+ pWin->devPrivates[frameWindowPrivateIndex].
+The content of the devPrivate is either from frameBuffer[0] or
+frameBuffer[1], depending on which buffer is being drawn into. When
+ pWin->devPrivates[frameWindowPrivateIndex] == frameBuffer[0],
+the functions should draw into the front framebuffer. When
+ pWin->devPrivates[frameWindowPrivateIndex] == frameBuffer[1],
+the functions should draw into the back framebuffer.
+
+In addition, you need to provide a function that allows you to copy
+bits between the buffers (optional since CopyArea can be used) and a
+function that draws into the select plane. Then, you need to register
+your functions and other information, by calling:
+
+void
+RegisterDoubleBufferHardware(pScreen, nInfo, pInfo, frameBuffer, selectPlane,
+ CopyBufferBitsFunc, DrawSelectPlaneFunc)
+ int nInfo;
+ xMbufBufferInfo *pInfo;
+ DevUnion *frameBuffer;
+ DevUnion selectPlane;
+
+"pInfo" is an array indicating which visuals and depths that double
+buffering is supported on. "nInfo" is the length of the array.
+
+"frameBuffer" is array of length 2. The contents of the array element
+is ddx-specific. The content of frameBuffer[0] should, when placed in
+the window private, indicate that framebuffer 0 should be drawn into.
+The contents of frameBuffer[1], when placed into the window private,
+should indicate that framebuffer 1 should be drawn into.
+
+"selectPlane" is ddx-specific. It should contain information
+neccessary for your displayProc to access the select plane.
+It is passed to DrawSelectPlaneFunc.
+
+"CopyBufferBitsFunc" is a ddx-specific function that copies from one
+buffer of a multibuffered window to another buffer. If the CopyBufferBitsFunc
+is NULL, a default function will be used that calls pScreen->CopyArea.
+
+ void CopyBufferBitsFunc(pMBWindow, srcBufferNum, dstBufferNum)
+ mbufWindowPtr pMBWindow;
+ int srcBufferNum, dstBufferNum;
+
+"DrawSelectPlaneFunc" is a ddx-specific function that fills the
+regions "prgn" of select plane with the value "bufferNum". If
+selectPlane is a DrawablePtr (such as a PixmapPtr), you can pass
+NULL for DrawSelectPlaneFunc, a default function will be used that
+calls FillRectangle on the selectPlane.
+
+ void DrawSelectPlaneFunc(pScreen, selectPlane, prgn, bufferNum)
+ ScreenPtr pScreen;
+ DevUnion selectPlane;
+ RegionPtr prgn;
+ long bufferNum;
+
+...
+...
+...
+
+*/
+
+#define MAX_BUFFERS 2 /* Only supports 2 buffers */
+#define FRONT_BUFFER 0
+#define BACK_BUFFER 1
+
+
+/* Buffer drawables have the same structure as window drawables */
+typedef WindowRec BufferRec;
+typedef WindowPtr BufferPtr;
+
+
+/*
+ * Call RegisterHdwrBuffer for every screen that has doublebuffer hardware.
+ */
+
+static int bufNumInfo[MAXSCREENS];
+static xMbufBufferInfo *bufInfo[MAXSCREENS];
+static DevUnion *bufFrameBuffer[MAXSCREENS];
+static DevUnion bufselectPlane[MAXSCREENS];
+static void (* bufCopyBufferBitsFunc[MAXSCREENS])();
+static void (* bufDrawSelectPlaneFunc[MAXSCREENS])();
+
+static Bool bufMultibufferInit();
+
+
+void
+RegisterDoubleBufferHardware(pScreen, nInfo, pInfo, frameBuffer, selectPlane,
+ CopyBufferBitsFunc, DrawSelectPlaneFunc)
+ ScreenPtr pScreen;
+ int nInfo;
+ xMbufBufferInfo *pInfo;
+ DevUnion *frameBuffer;
+ DevUnion selectPlane;
+ void (* CopyBufferBitsFunc)();
+ void (* DrawSelectPlaneFunc)();
+{
+ bufNumInfo[pScreen->myNum] = nInfo;
+ bufInfo[pScreen->myNum] = pInfo;
+ bufFrameBuffer[pScreen->myNum] = frameBuffer;
+ bufselectPlane[pScreen->myNum] = selectPlane;
+
+ bufCopyBufferBitsFunc[pScreen->myNum] = CopyBufferBitsFunc;
+ bufDrawSelectPlaneFunc[pScreen->myNum] = DrawSelectPlaneFunc;
+
+ /* Register ourselves with device-independent multibuffers code */
+ RegisterMultibufferInit(pScreen, bufMultibufferInit);
+}
+
+
+/*
+ * Called by Multibuffer extension initialization.
+ * Initializes mbufScreenRec and its devPrivate.
+ */
+
+static Bool NoopDDA_True() { return TRUE; }
+static Bool bufPositionWindow();
+static int bufCreateImageBuffers();
+static void bufDestroyImageBuffers();
+static void bufDisplayImageBuffers();
+static void bufClearImageBufferArea();
+static void bufDestroyBuffer();
+static void bufCopyBufferBits();
+static void bufDrawSelectPlane();
+static void bufWrapScreenFuncs();
+static void bufResetProc();
+
+static void bufPostValidateTree();
+static void bufClipNotify();
+static void bufWindowExposures();
+static Bool bufChangeWindowAttributes();
+static void bufClearToBackground();
+static void bufCopyWindow();
+
+extern WindowPtr *WindowTable;
+
+static Bool
+bufMultibufferInit(pScreen, pMBScreen)
+ ScreenPtr pScreen;
+ mbufScreenPtr pMBScreen;
+{
+ mbufBufferPrivPtr pMBPriv;
+ BoxRec box;
+
+ /* Multibuffer info */
+ pMBScreen->nInfo = bufNumInfo[pScreen->myNum];
+ pMBScreen->pInfo = bufInfo[pScreen->myNum];
+
+ /* Hooks */
+ pMBScreen->CreateImageBuffers = bufCreateImageBuffers;
+ pMBScreen->DestroyImageBuffers = bufDestroyImageBuffers;
+ pMBScreen->DisplayImageBuffers = bufDisplayImageBuffers;
+ pMBScreen->ClearImageBufferArea = bufClearImageBufferArea;
+ pMBScreen->ChangeMBufferAttributes = NoopDDA_True;
+ pMBScreen->ChangeBufferAttributes = NoopDDA_True;
+ pMBScreen->DeleteBufferDrawable = bufDestroyBuffer;
+ pMBScreen->WrapScreenFuncs = bufWrapScreenFuncs;
+ pMBScreen->ResetProc = bufResetProc;
+ /* Create devPrivate part */
+ pMBPriv = (mbufBufferPrivPtr) xalloc(sizeof *pMBPriv);
+ if (!pMBPriv)
+ return (FALSE);
+
+ pMBScreen->devPrivate.ptr = (pointer) pMBPriv;
+ pMBPriv->frameBuffer = bufFrameBuffer[pScreen->myNum];
+ pMBPriv->selectPlane = bufselectPlane[pScreen->myNum];
+
+ /*
+ * Initializing the subtractRgn to the screen area will ensure that
+ * the selectPlane will get cleared on the first PostValidateTree.
+ */
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pScreen->width;
+ box.y2 = pScreen->height;
+
+ pMBPriv->rgnChanged = TRUE;
+ REGION_INIT(pScreen, &pMBPriv->backBuffer, &box, 1);
+ REGION_INIT(pScreen, &pMBPriv->subtractRgn, &box, 1);
+ REGION_NULL(pScreen, &pMBPriv->unionRgn);
+
+ /* Misc functions */
+ pMBPriv->CopyBufferBits = bufCopyBufferBitsFunc[pScreen->myNum];
+ pMBPriv->DrawSelectPlane = bufDrawSelectPlaneFunc[pScreen->myNum];
+
+ if (!pMBPriv->CopyBufferBits)
+ pMBPriv->CopyBufferBits = bufCopyBufferBits;
+
+ if (!pMBPriv->DrawSelectPlane)
+ pMBPriv->DrawSelectPlane = bufDrawSelectPlane;
+
+ /* screen functions */
+ pMBPriv->funcsWrapped = 0;
+ pMBPriv->inClearToBackground = FALSE;
+ pMBPriv->WindowExposures = NULL;
+ pMBPriv->CopyWindow = NULL;
+ pMBPriv->ClearToBackground = NULL;
+ pMBPriv->ClipNotify = NULL;
+ pMBPriv->ChangeWindowAttributes = NULL;
+
+ /* Start out wrapped to clear select plane */
+ WRAP_SCREEN_FUNC(pScreen,pMBPriv,PostValidateTree, bufPostValidateTree);
+ return TRUE;
+}
+
+static void
+UpdateBufferFromWindow(pBuffer, pWin)
+ BufferPtr pBuffer;
+ WindowPtr pWin;
+{
+ pBuffer->drawable.x = pWin->drawable.x;
+ pBuffer->drawable.y = pWin->drawable.y;
+ pBuffer->drawable.width = pWin->drawable.width;
+ pBuffer->drawable.height = pWin->drawable.height;
+
+ pBuffer->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+ /* Update for PaintWindowBackground */
+ pBuffer->parent = pWin->parent;
+
+ /*
+ * Make the borderClip the same as the clipList so
+ * NotClippedByChildren comes out with just clipList.
+ */
+
+ pBuffer->clipList = pWin->clipList;
+ pBuffer->borderClip = pWin->clipList;
+ pBuffer->winSize = pWin->winSize;
+ pBuffer->borderSize = pWin->borderSize;
+
+ pBuffer->origin = pWin->origin;
+}
+
+static BufferPtr
+bufCreateBuffer(pScreen, pWin, bufferNum)
+ ScreenPtr pScreen;
+ WindowPtr pWin;
+ int bufferNum;
+{
+ mbufBufferPrivPtr pMBPriv;
+ DevUnion *devPrivates;
+ BufferPtr pBuffer;
+ int i;
+
+ pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
+
+ pBuffer = AllocateWindow(pWin->drawable.pScreen);
+ if (!pBuffer)
+ return (NULL);
+
+ /* XXX- Until we know what is needed, copy everything. */
+ devPrivates = pBuffer->devPrivates;
+ *pBuffer = *pWin;
+ pBuffer->devPrivates = devPrivates;
+
+ pBuffer->drawable.type = DRAWABLE_BUFFER;
+ pBuffer->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+ pBuffer->nextSib = NULL;
+ pBuffer->prevSib = NULL;
+ pBuffer->firstChild = NULL;
+ pBuffer->lastChild = NULL;
+
+ /* XXX - Worry about backingstore later */
+ pBuffer->backStorage = NULL;
+ pBuffer->backingStore = NotUseful;
+
+ /* XXX - Need to call pScreen->CreateWindow for tile/stipples
+ * or should I just copy the devPrivates?
+ */
+
+ for (i=0; i < pScreen->WindowPrivateLen; i++)
+ pBuffer->devPrivates[i] = pWin->devPrivates[i];
+
+ pBuffer->devPrivates[frameWindowPrivateIndex] =
+ pMBPriv->frameBuffer[bufferNum];
+
+ return pBuffer;
+}
+
+static void
+bufDestroyBuffer(pDrawable)
+ DrawablePtr pDrawable;
+{
+ xfree(pDrawable);
+}
+
+/*ARGSUSED*/
+static int
+bufCreateImageBuffers (pWin, nbuf, ids, action, hint)
+ WindowPtr pWin;
+ int nbuf;
+ XID *ids;
+ int action;
+ int hint;
+{
+ ScreenPtr pScreen;
+ mbufScreenPtr pMBScreen;
+ mbufWindowPtr pMBWindow;
+ mbufBufferPtr pMBBuffer;
+ int i;
+
+ pScreen = pWin->drawable.pScreen;
+ pMBScreen = MB_SCREEN_PRIV(pScreen);
+ pMBWindow = MB_WINDOW_PRIV(pWin);
+
+ pMBWindow->devPrivate.ptr = (pointer) REGION_CREATE(pScreen, 0,0);
+ if (!pMBWindow->devPrivate.ptr)
+ return(0);
+ REGION_COPY(pScreen, (RegionPtr) pMBWindow->devPrivate.ptr,
+ &pWin->clipList);
+
+ for (i = 0; i < nbuf; i++)
+ {
+ pMBBuffer = pMBWindow->buffers + i;
+ pMBBuffer->pDrawable = (DrawablePtr) bufCreateBuffer(pScreen,pWin,i);
+
+ if (!pMBBuffer->pDrawable)
+ break;
+
+ if (!AddResource (ids[i], MultibufferDrawableResType,
+ (pointer) pMBBuffer->pDrawable))
+ {
+ bufDestroyBuffer((BufferPtr) pMBBuffer->pDrawable);
+ break;
+ }
+ pMBBuffer->pDrawable->id = ids[i];
+
+ /*
+ * If window is already mapped, generate exposures and
+ * clear the area of the newly buffers.
+ */
+
+ if ((pWin->realized) && (i != pMBWindow->displayedMultibuffer))
+ (* pMBScreen->ClearImageBufferArea)(pMBBuffer, 0,0, 0,0, TRUE);
+ }
+
+ return i;
+}
+
+static void
+bufDestroyImageBuffers(pWin)
+ WindowPtr pWin;
+{
+ ScreenPtr pScreen;
+ mbufWindowPtr pMBWindow;
+
+ pScreen = pWin->drawable.pScreen;
+
+ if (pMBWindow = MB_WINDOW_PRIV(pWin))
+ {
+ mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
+
+ /*
+ * if the backbuffer is currently being displayed, move the bits
+ * to the frontbuffer and display it instead.
+ */
+
+ if (pWin->realized && (pMBWindow->displayedMultibuffer == BACK_BUFFER))
+ {
+ (* pMBPriv->CopyBufferBits)(pMBWindow, BACK_BUFFER, FRONT_BUFFER);
+ REGION_SUBTRACT(pScreen, &pMBPriv->backBuffer,
+ &pMBPriv->backBuffer, &pWin->clipList);
+ (* pMBPriv->DrawSelectPlane)(pScreen, pMBPriv->selectPlane,
+ &pWin->clipList, FRONT_BUFFER);
+ }
+
+ /* Switch window rendering to front buffer */
+ pWin->devPrivates[frameWindowPrivateIndex] =
+ pMBPriv->frameBuffer[FRONT_BUFFER];
+
+ REGION_DESTROY(pScreen, (RegionPtr) pMBWindow->devPrivate.ptr);
+ pMBWindow->devPrivate.ptr = NULL;
+ }
+}
+
+/*
+ * Can be replaced by pScreen->ClearToBackground if pBuffer->eventMask
+ * and wOtherEventsMasks(pBuffer) were setup.
+ */
+
+static void
+bufClearImageBufferArea(pMBBuffer, x,y, w,h, generateExposures)
+ mbufBufferPtr pMBBuffer;
+ short x,y;
+ unsigned short w,h;
+ Bool generateExposures;
+{
+ BoxRec box;
+ RegionRec reg;
+ RegionPtr pBSReg = NullRegion;
+ ScreenPtr pScreen;
+ BoxPtr extents;
+ int x1, y1, x2, y2;
+ BufferPtr pBuffer;
+
+ pBuffer = (BufferPtr) pMBBuffer->pDrawable;
+ /* compute everything using ints to avoid overflow */
+
+ x1 = pBuffer->drawable.x + x;
+ y1 = pBuffer->drawable.y + y;
+ if (w)
+ x2 = x1 + (int) w;
+ else
+ x2 = x1 + (int) pBuffer->drawable.width - (int) x;
+ if (h)
+ y2 = y1 + h;
+ else
+ y2 = y1 + (int) pBuffer->drawable.height - (int) y;
+
+ extents = &pBuffer->clipList.extents;
+
+ /* clip the resulting rectangle to the window clipList extents. This
+ * makes sure that the result will fit in a box, given that the
+ * screen is < 32768 on a side.
+ */
+
+ if (x1 < extents->x1)
+ x1 = extents->x1;
+ if (x2 > extents->x2)
+ x2 = extents->x2;
+ if (y1 < extents->y1)
+ y1 = extents->y1;
+ if (y2 > extents->y2)
+ y2 = extents->y2;
+
+ if (x2 <= x1 || y2 <= y1)
+ {
+ x2 = x1 = 0;
+ y2 = y1 = 0;
+ }
+
+ box.x1 = x1;
+ box.x2 = x2;
+ box.y1 = y1;
+ box.y2 = y2;
+
+ pScreen = pBuffer->drawable.pScreen;
+ REGION_INIT(pScreen, &reg, &box, 1);
+ if (pBuffer->backStorage)
+ {
+ /*
+ * If the window has backing-store on, call through the
+ * ClearToBackground vector to handle the special semantics
+ * (i.e. things backing store is to be cleared out and
+ * an Expose event is to be generated for those areas in backing
+ * store if generateExposures is TRUE).
+ */
+ pBSReg = (* pScreen->ClearBackingStore)(pBuffer, x, y, w, h,
+ generateExposures);
+ }
+
+ REGION_INTERSECT(pScreen, &reg, &reg, &pBuffer->clipList);
+ if (pBuffer->backgroundState != None)
+ (*pScreen->PaintWindowBackground)(pBuffer, &reg, PW_BACKGROUND);
+ if (generateExposures)
+ MultibufferExpose(pMBBuffer, &reg);
+#ifdef _notdef
+ /* XXBS - This is the original miClearToBackground code.
+ * WindowExposures needs to be called (or the functionality emulated)
+ * in order for backingStore to work, but first, pBuffer->eventMask
+ * and wOtherEventsMasks(pBuffer) need to be setup correctly.
+ */
+
+ if (generateExposures)
+ (*pScreen->WindowExposures)(pBuffer, &reg, pBSReg);
+ else if (pBuffer->backgroundState != None)
+ (*pScreen->PaintWindowBackground)(pBuffer, &reg, PW_BACKGROUND);
+#endif
+ REGION_UNINIT(pScreen, &reg);
+ if (pBSReg)
+ REGION_DESTROY(pScreen, pBSReg);
+}
+
+static void
+bufWrapScreenFuncs(pScreen)
+ ScreenPtr pScreen;
+{
+ mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
+
+ WRAP_SCREEN_FUNC(pScreen,pMBPriv,PostValidateTree, bufPostValidateTree);
+ WRAP_SCREEN_FUNC(pScreen,pMBPriv,ClipNotify, bufClipNotify);
+ WRAP_SCREEN_FUNC(pScreen,pMBPriv,WindowExposures,bufWindowExposures);
+ WRAP_SCREEN_FUNC(pScreen,pMBPriv,ChangeWindowAttributes, bufChangeWindowAttributes);
+ WRAP_SCREEN_FUNC(pScreen,pMBPriv,ClearToBackground,bufClearToBackground);
+ WRAP_SCREEN_FUNC(pScreen,pMBPriv,CopyWindow,bufCopyWindow);
+}
+
+static void
+bufResetProc(pScreen)
+ ScreenPtr pScreen;
+{
+ mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
+
+ /*
+ * frameBuffer, selectPlane, and pInfo should be freed by
+ * whoever called RegisterDoubleBufferHardware
+ */
+
+ REGION_UNINIT(pScreen, &pMBPriv->backBuffer);
+ REGION_UNINIT(pScreen, &pMBPriv->subtractRgn);
+ REGION_UNINIT(pScreen, &pMBPriv->unionRgn);
+ xfree(pMBPriv);
+}
+
+/*---------------------------------------------------------------------------*/
+
+/*
+ * Used if CopyBufferBitsFunc is not provided when registering.
+ * This should work for everybody since CopyArea needs to support
+ * copying between buffers anyway.
+ */
+
+static void
+bufCopyBufferBits(pMBWindow, srcBufferNum, dstBufferNum)
+ mbufWindowPtr pMBWindow;
+ int srcBufferNum, dstBufferNum;
+{
+ DrawablePtr pSrcBuffer, pDstBuffer;
+ GCPtr pGC;
+
+ pSrcBuffer = pMBWindow->buffers[srcBufferNum].pDrawable;
+ pDstBuffer = pMBWindow->buffers[dstBufferNum].pDrawable;
+
+ pGC = GetScratchGC (pDstBuffer->depth, pDstBuffer->pScreen);
+ if (!pGC)
+ return;
+
+ ValidateGC (pDstBuffer, pGC);
+ (* pGC->ops->CopyArea) (pSrcBuffer, pDstBuffer, pGC,
+ 0,0, pDstBuffer->width, pDstBuffer->height, 0,0);
+ FreeScratchGC (pGC);
+}
+
+/*
+ * Used if DrawSelectPlanFunc is not provided for when registering.
+ * However, it only works if selectPlane.ptr is a drawable. Also
+ * assumes that painting with color 0 selects the front buffer,
+ * while color 1 selects the back buffer.
+ */
+
+static void
+bufDrawSelectPlane(pScreen, selectPlane, prgn, bufferNum)
+ ScreenPtr pScreen;
+ DevUnion selectPlane;
+ RegionPtr prgn;
+ long bufferNum;
+{
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ register int i;
+ register BoxPtr pbox;
+ register xRectangle *prect;
+ int numRects;
+ XID value;
+
+ if (REGION_NUM_RECTS(prgn) == 0)
+ return;
+
+ pDrawable = (DrawablePtr) selectPlane.ptr;
+ pGC = GetScratchGC (pDrawable->depth, pScreen);
+ if (!pGC)
+ return;
+
+ prect = (xRectangle *)ALLOCATE_LOCAL(REGION_NUM_RECTS(prgn) *
+ sizeof(xRectangle));
+ if (!prect)
+ {
+ FreeScratchGC(pGC);
+ return;
+ }
+
+ value = (XID) bufferNum;
+ DoChangeGC(pGC, GCForeground, &value, 0);
+ ValidateGC(pDrawable, pGC);
+
+ numRects = REGION_NUM_RECTS(prgn);
+ pbox = REGION_RECTS(prgn);
+ for (i= numRects; --i >= 0; pbox++, prect++)
+ {
+ prect->x = pbox->x1;
+ prect->y = pbox->y1;
+ prect->width = pbox->x2 - pbox->x1;
+ prect->height = pbox->y2 - pbox->y1;
+ }
+ prect -= numRects;
+ (* pGC->ops->PolyFillRect)(pDrawable, pGC, numRects, prect);
+
+ DEALLOCATE_LOCAL(prect);
+ FreeScratchGC (pGC);
+}
+
+
+static void
+bufDisplayImageBuffers(pScreen, ppMBWindow, ppMBBuffer, nbuf)
+ ScreenPtr pScreen;
+ mbufBufferPtr *ppMBBuffer;
+ mbufWindowPtr *ppMBWindow;
+ int nbuf;
+{
+ WindowPtr pWin;
+ BufferPtr pPrevBuffer, pNewBuffer;
+ int i, number;
+ mbufBufferPrivPtr pMBPriv;
+ mbufBufferPtr pPrevMBBuffer;
+
+ pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
+
+ for (i = 0; i < nbuf; i++)
+ {
+ number = ppMBBuffer[i]->number; /* 0=frontbuffer, 1=backbuffer */
+ pWin = ppMBWindow[i]->pWindow;
+ pPrevMBBuffer = MB_DISPLAYED_BUFFER(ppMBWindow[i]);
+
+ pPrevBuffer = (BufferPtr) pPrevMBBuffer->pDrawable;
+ pNewBuffer = (BufferPtr) ppMBBuffer[i]->pDrawable;
+
+ if (pPrevBuffer != pNewBuffer)
+ {
+ RegionPtr backBuffer = &pMBPriv->backBuffer;
+
+ /*
+ * Update the select plane and the backBuffer region.
+ */
+
+ (* pMBPriv->DrawSelectPlane)(pScreen, pMBPriv->selectPlane,
+ &pWin->clipList, number);
+
+ if (number == BACK_BUFFER)
+ REGION_UNION(pScreen, backBuffer, backBuffer,
+ &pWin->clipList);
+ else
+ REGION_SUBTRACT(pScreen, backBuffer, backBuffer,
+ &pWin->clipList);
+
+ /* Switch which framebuffer the window draws into */
+ pWin->devPrivates[frameWindowPrivateIndex] =
+ pMBPriv->frameBuffer[number];
+ }
+
+ switch (ppMBWindow[i]->updateAction)
+ {
+ case MultibufferUpdateActionUndefined:
+ break;
+ case MultibufferUpdateActionBackground:
+ (* MB_SCREEN_PRIV(pScreen)->ClearImageBufferArea)
+ (pPrevMBBuffer, 0,0, 0,0, FALSE);
+ break;
+ case MultibufferUpdateActionUntouched:
+ break;
+ case MultibufferUpdateActionCopied:
+ if (pPrevBuffer != pNewBuffer)
+ {
+ (* pMBPriv->CopyBufferBits) (ppMBWindow[i],
+ ppMBBuffer[i]->number, pPrevMBBuffer->number);
+ }
+ break;
+ }
+ }
+}
+
+/* Updates the backBuffer region and paints the selectPlane. */
+
+static void
+bufPostValidateTree(pParent, pChild, kind)
+ WindowPtr pParent, pChild;
+ VTKind kind;
+{
+ ScreenPtr pScreen;
+ mbufBufferPrivPtr pMBPriv;
+
+ if (pParent)
+ pScreen = pParent->drawable.pScreen;
+ else if (pChild)
+ pScreen = pChild->drawable.pScreen;
+ else
+ return; /* Hopeless */
+
+ pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
+
+ UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, PostValidateTree);
+ if (pScreen->PostValidateTree)
+ (* pScreen->PostValidateTree)(pParent, pChild, kind);
+ REWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, PostValidateTree);
+
+ /* Does backBuffer need to change? */
+ if (pMBPriv->rgnChanged)
+ {
+ RegionRec exposed;
+ RegionPtr pSubtractRgn, pUnionRgn;
+ Bool overlap;
+
+ pMBPriv->rgnChanged = FALSE;
+
+ pSubtractRgn = &pMBPriv->subtractRgn;
+ pUnionRgn = &pMBPriv->unionRgn;
+ REGION_VALIDATE(pScreen, pSubtractRgn, &overlap);
+#ifdef DEBUG
+ if (overlap)
+ FatalError("bufPostValidateTree: subtractRgn overlaps");
+#endif
+ REGION_VALIDATE(pScreen, pUnionRgn, &overlap);
+#ifdef DEBUG
+ if (overlap)
+ FatalError("bufPostValidateTree: unionRgn overlaps");
+#endif
+
+ /* Update backBuffer: subtract must come before union */
+ REGION_SUBTRACT(pScreen, &pMBPriv->backBuffer, &pMBPriv->backBuffer,
+ pSubtractRgn);
+ REGION_UNION(pScreen, &pMBPriv->backBuffer, &pMBPriv->backBuffer,
+ pUnionRgn);
+
+ /* Paint gained and lost backbuffer areas in select plane */
+ REGION_NULL(pScreen, &exposed);
+ REGION_SUBTRACT(pScreen, &exposed, pSubtractRgn, pUnionRgn);
+ (* pMBPriv->DrawSelectPlane)(pScreen, pMBPriv->selectPlane,
+ &exposed, FRONT_BUFFER);
+
+ REGION_SUBTRACT(pScreen, &exposed, pUnionRgn, pSubtractRgn);
+ (* pMBPriv->DrawSelectPlane)(pScreen, pMBPriv->selectPlane,
+ &exposed, BACK_BUFFER);
+
+ REGION_UNINIT(pScreen, &exposed);
+ REGION_EMPTY(pScreen, pSubtractRgn);
+ REGION_EMPTY(pScreen, pUnionRgn);
+ }
+}
+
+/*
+ * If the window is multibuffered and displaying the backbuffer,
+ * add the old clipList to the subtractRgn and add the new clipList
+ * to the unionRgn. PostValidateTree will use subtractRgn and unionRgn
+ * to update the backBuffer region and the selectPlane.
+ *
+ * Copy changes to the window structure into the buffers.
+ * Send ClobberNotify events.
+ */
+
+static void
+bufClipNotify(pWin, dx,dy)
+ WindowPtr pWin;
+ int dx,dy;
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
+ mbufWindowPtr pMBWindow;
+ int i;
+
+ UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, ClipNotify);
+ if (pScreen->ClipNotify)
+ (* pScreen->ClipNotify)(pWin, dx,dy);
+ REWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, ClipNotify);
+
+ if (pMBWindow = MB_WINDOW_PRIV(pWin))
+ {
+ RegionPtr pOldClipList = (RegionPtr) pMBWindow->devPrivate.ptr;
+
+ if (! REGION_EQUAL(pScreen, pOldClipList, &pWin->clipList))
+ {
+ if (pMBWindow->displayedMultibuffer == BACK_BUFFER)
+ {
+ pMBPriv->rgnChanged = TRUE;
+ REGION_APPEND(pScreen, &pMBPriv->subtractRgn, pOldClipList);
+ REGION_APPEND(pScreen, &pMBPriv->unionRgn, &pWin->clipList);
+ }
+
+ REGION_COPY(pScreen, pOldClipList,&pWin->clipList);
+ }
+
+ /* Update buffer x,y,w,h, and clipList */
+ for (i=0; i<pMBWindow->numMultibuffer; i++)
+ {
+ mbufBufferPtr pMBBuffer = pMBWindow->buffers + i;
+ if (pMBBuffer->clobber != pWin->visibility)
+ {
+ pMBBuffer->clobber = pWin->visibility;
+ MultibufferClobber(pMBBuffer);
+ }
+ UpdateBufferFromWindow(pMBBuffer->pDrawable, pWin);
+ }
+ }
+}
+
+/*
+ * Updates buffer's background fields when the window's changes.
+ * This is necessary because pScreen->PaintWindowBackground
+ * is used to paint the buffer.
+ *
+ * XXBS - Backingstore state will have be tracked too if it is supported.
+ */
+
+static Bool
+bufChangeWindowAttributes(pWin, mask)
+ WindowPtr pWin;
+ unsigned long mask;
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
+ mbufWindowPtr pMBWindow;
+ Bool ret;
+
+ UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, Bool, ChangeWindowAttributes);
+ ret = (* pScreen->ChangeWindowAttributes)(pWin, mask);
+ REWRAP_SCREEN_FUNC(pScreen, pMBPriv, Bool, ChangeWindowAttributes);
+
+ if (pMBWindow = MB_WINDOW_PRIV(pWin))
+ {
+ if (mask & (CWBackPixmap | CWBackPixel))
+ {
+ BufferPtr pBuffer;
+ int i;
+
+ for (i=0; i<pMBWindow->displayedMultibuffer; i++)
+ {
+ pBuffer = (BufferPtr) pMBWindow->buffers[i].pDrawable;
+ pBuffer->backgroundState = pWin->backgroundState;
+ pBuffer->background = pWin->background;
+ }
+ }
+ }
+ return ret;
+}
+
+/*
+ * Send exposures and clear the background for a buffer whenever
+ * its corresponding window is exposed, except when called by
+ * ClearToBackground.
+ */
+
+static void
+bufWindowExposures(pWin, prgn, other_exposed)
+ WindowPtr pWin;
+ register RegionPtr prgn, other_exposed;
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ mbufWindowPtr pMBWindow = MB_WINDOW_PRIV(pWin);
+ mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
+ RegionRec tmp_rgn;
+ int i;
+ Bool handleBuffers;
+
+ handleBuffers = (!pMBPriv->inClearToBackground) &&
+ (pWin->drawable.type == DRAWABLE_WINDOW) &&
+ pMBWindow && (prgn && !REGION_NIL(prgn));
+
+ /* miWindowExposures munges prgn and other_exposed. */
+ if (handleBuffers)
+ {
+ REGION_NULL(pScreen, &tmp_rgn);
+ REGION_COPY(pScreen, &tmp_rgn, prgn);
+ }
+
+ UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, WindowExposures);
+ (* pScreen->WindowExposures) (pWin, prgn, other_exposed);
+ REWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, WindowExposures);
+
+ if (!handleBuffers)
+ return;
+
+ /*
+ * Send expose events to all clients. Paint the exposed region for all
+ * buffers except the displayed buffer since it is handled when the
+ * window is painted.
+ *
+ * XXBS - Will have to be re-written to handle BackingStore on buffers.
+ */
+
+ for (i=0; i<pMBWindow->numMultibuffer; i++)
+ {
+ mbufBufferPtr pMBBuffer;
+ BufferPtr pBuffer;
+
+ pMBBuffer = pMBWindow->buffers + i;
+ pBuffer = (BufferPtr) pMBBuffer->pDrawable;
+
+ if (i != pMBWindow->displayedMultibuffer)
+ (* pScreen->PaintWindowBackground)(pBuffer,&tmp_rgn,PW_BACKGROUND);
+ if ((pMBBuffer->otherEventMask | pMBBuffer->eventMask) & ExposureMask)
+ MultibufferExpose(pMBBuffer, &tmp_rgn);
+ }
+
+ REGION_UNINIT(pScreen, &tmp_rgn);
+}
+
+/*
+ * Set ``inClearToBackground'' so that WindowExposures does not attempt
+ * to send expose events or clear the background on the buffers.
+ */
+
+static void
+bufClearToBackground(pWin, x,y,w,h, sendExpose)
+ WindowPtr pWin;
+ int x,y, w,h;
+ Bool sendExpose;
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
+
+ pMBPriv->inClearToBackground = TRUE;
+
+ UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, ClearToBackground);
+ (* pScreen->ClearToBackground)(pWin, x,y,w,h, sendExpose);
+ REWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, ClearToBackground);
+
+ pMBPriv->inClearToBackground = FALSE;
+}
+
+/*
+ * Move bits in both buffers. It does this by calling pScreen->CopyWindow
+ * twice, once with the root window's devPrivate[frameWindowPrivateIndex]
+ * pointing to the frontbuffer pixmap and once with it pointed to the
+ * backbuffer pixmap. It does this if there are *any* existing multibuffered
+ * window... a possible optimization is to copy the backbuffer only if this
+ * window or its inferiors are multibuffered. May be faster, maybe not.
+ *
+ * XXX - Only works if your CopyWindow checks the root window's devPrivate
+ * to see which buffer to draw into. Works for cfbPaintWindow.
+ */
+
+/*ARGSUSED*/
+static void
+bufCopyWindow(pWin, ptOldOrg, prgnSrc)
+ WindowPtr pWin;
+ DDXPointRec ptOldOrg;
+ RegionPtr prgnSrc;
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
+ WindowPtr pwinroot;
+ DevUnion save;
+
+ UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, CopyWindow);
+
+ pwinroot = WindowTable[pScreen->myNum];
+ save = pwinroot->devPrivates[frameWindowPrivateIndex];
+
+ /*
+ * Copy front buffer
+ */
+
+ pwinroot->devPrivates[frameWindowPrivateIndex] =
+ pMBPriv->frameBuffer[FRONT_BUFFER];
+ (* pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
+
+ /*
+ * Copy back buffer
+ */
+
+ /* CopyWindow translates prgnSrc... translate it back for 2nd call. */
+ REGION_TRANSLATE(pScreen, prgnSrc,
+ ptOldOrg.x - pWin->drawable.x,
+ ptOldOrg.y - pWin->drawable.y);
+ pwinroot->devPrivates[frameWindowPrivateIndex] =
+ pMBPriv->frameBuffer[BACK_BUFFER];
+ (* pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
+
+ pwinroot->devPrivates[frameWindowPrivateIndex] = save;
+ REWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, CopyWindow);
+}
diff --git a/nx-X11/programs/Xserver/Xext/mbufpx.c b/nx-X11/programs/Xserver/Xext/mbufpx.c
new file mode 100644
index 000000000..c986217ee
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/mbufpx.c
@@ -0,0 +1,651 @@
+/* $XFree86: xc/programs/Xserver/Xext/mbufpx.c,v 3.3 2001/07/23 13:15:44 dawes Exp $ */
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+********************************************************/
+
+/* $Xorg: mbufpx.c,v 1.4 2001/02/09 02:04:32 xorgcvs Exp $ */
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "opaque.h"
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "inputstr.h"
+#include <sys/time.h>
+
+#define _MULTIBUF_SERVER_ /* don't want Xlib structures */
+#define _MULTIBUF_PIXMAP_
+#include <X11/extensions/multibufst.h>
+
+
+static Bool NoopDDA_True() { return TRUE; }
+
+static Bool pixPositionWindow();
+static int pixCreateImageBuffers();
+static void pixDisplayImageBuffers();
+static void pixClearImageBufferArea();
+static void pixDeleteBufferDrawable();
+static void pixWrapScreenFuncs();
+static void pixResetProc();
+
+Bool
+pixMultibufferInit(pScreen, pMBScreen)
+ ScreenPtr pScreen;
+ mbufScreenPtr pMBScreen;
+{
+ int i, j, k;
+ xMbufBufferInfo *pInfo;
+ int nInfo;
+ DepthPtr pDepth;
+ mbufPixmapPrivPtr pMBPriv;
+
+ pMBScreen->CreateImageBuffers = pixCreateImageBuffers;
+ pMBScreen->DestroyImageBuffers = (void (*)())NoopDDA;
+ pMBScreen->DisplayImageBuffers = pixDisplayImageBuffers;
+ pMBScreen->ClearImageBufferArea = pixClearImageBufferArea;
+ pMBScreen->ChangeMBufferAttributes = NoopDDA_True;
+ pMBScreen->ChangeBufferAttributes = NoopDDA_True;
+ pMBScreen->DeleteBufferDrawable = pixDeleteBufferDrawable;
+ pMBScreen->WrapScreenFuncs = pixWrapScreenFuncs;
+ pMBScreen->ResetProc = pixResetProc;
+
+ /* Support every depth and visual combination that the screen does */
+
+ nInfo = 0;
+ for (i = 0; i < pScreen->numDepths; i++)
+ {
+ pDepth = &pScreen->allowedDepths[i];
+ nInfo += pDepth->numVids;
+ }
+
+ pInfo = (xMbufBufferInfo *) xalloc (nInfo * sizeof (xMbufBufferInfo));
+ if (!pInfo)
+ return FALSE;
+
+ k = 0;
+ for (i = 0; i < pScreen->numDepths; i++)
+ {
+ pDepth = &pScreen->allowedDepths[i];
+ for (j = 0; j < pDepth->numVids; j++)
+ {
+ pInfo[k].visualID = pDepth->vids[j];
+ pInfo[k].maxBuffers = 0;
+ pInfo[k].depth = pDepth->depth;
+ k++;
+ }
+ }
+
+ pMBScreen->nInfo = nInfo;
+ pMBScreen->pInfo = pInfo;
+
+ /*
+ * Setup the devPrivate to mbufScreenRec
+ */
+
+ pMBPriv = (mbufPixmapPrivPtr) xalloc(sizeof(* pMBPriv));
+ if (!pMBPriv)
+ {
+ xfree(pInfo);
+ return (FALSE);
+ }
+ pMBScreen->devPrivate.ptr = (pointer) pMBPriv;
+ pMBPriv->PositionWindow = NULL;
+ pMBPriv->funcsWrapped = 0;
+
+ return TRUE;
+}
+
+/*ARGSUSED*/
+static int
+pixCreateImageBuffers (pWin, nbuf, ids, action, hint)
+ WindowPtr pWin;
+ int nbuf;
+ XID *ids;
+ int action;
+ int hint;
+{
+ mbufWindowPtr pMBWindow;
+ mbufBufferPtr pMBBuffer;
+ ScreenPtr pScreen;
+ int width, height, depth;
+ int i;
+
+ pMBWindow = MB_WINDOW_PRIV(pWin);
+
+ width = pWin->drawable.width;
+ height = pWin->drawable.height;
+ depth = pWin->drawable.depth;
+ pScreen = pWin->drawable.pScreen;
+
+ for (i = 0; i < nbuf; i++)
+ {
+ pMBBuffer = &pMBWindow->buffers[i];
+ pMBBuffer->pDrawable = (DrawablePtr)
+ (*pScreen->CreatePixmap) (pScreen, width, height, depth);
+ if (!pMBBuffer->pDrawable)
+ break;
+
+ if (!AddResource (ids[i], MultibufferDrawableResType,
+ (pointer) pMBBuffer->pDrawable))
+ {
+ (*pScreen->DestroyPixmap) ((PixmapPtr) pMBBuffer->pDrawable);
+ break;
+ }
+ pMBBuffer->pDrawable->id = ids[i];
+
+ /*
+ * In the description of the CreateImageBuffers request:
+ * "If the window is mapped, or if these image buffers have
+ * backing store, their contents will be tiled with the window
+ * background, and zero or more expose events will be generated
+ * for each of these buffers."
+ */
+
+ (* MB_SCREEN_PRIV(pScreen)->ClearImageBufferArea)
+ (pMBBuffer, 0,0, 0,0, TRUE);
+ }
+
+ return i;
+}
+
+/*
+ * set up the gc to clear the pixmaps;
+ */
+static Bool
+SetupBackgroundPainter (pWin, pGC)
+ WindowPtr pWin;
+ GCPtr pGC;
+{
+ XID gcvalues[4];
+ int ts_x_origin, ts_y_origin;
+ PixUnion background;
+ int backgroundState;
+ Mask gcmask;
+
+ /*
+ * First take care of any ParentRelative stuff by altering the
+ * tile/stipple origin to match the coordinates of the upper-left
+ * corner of the first ancestor without a ParentRelative background.
+ * This coordinate is, of course, negative.
+ */
+
+ ts_x_origin = ts_y_origin = 0;
+ while (pWin->backgroundState == ParentRelative) {
+ ts_x_origin -= pWin->origin.x;
+ ts_y_origin -= pWin->origin.y;
+ pWin = pWin->parent;
+ }
+ backgroundState = pWin->backgroundState;
+ background = pWin->background;
+
+ switch (backgroundState)
+ {
+ case BackgroundPixel:
+ gcvalues[0] = (XID) background.pixel;
+ gcvalues[1] = FillSolid;
+ gcmask = GCForeground|GCFillStyle;
+ break;
+
+ case BackgroundPixmap:
+ gcvalues[0] = FillTiled;
+ gcvalues[1] = (XID) background.pixmap;
+ gcvalues[2] = ts_x_origin;
+ gcvalues[3] = ts_y_origin;
+ gcmask = GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin;
+ break;
+
+ default:
+ return FALSE;
+ }
+ DoChangeGC(pGC, gcmask, gcvalues, TRUE);
+ return TRUE;
+}
+
+static void
+MultibufferPaintBackgroundRectangles(pWin, pDrawable, nrects, pRects)
+ WindowPtr pWin;
+ DrawablePtr pDrawable;
+ int nrects;
+ xRectangle *pRects;
+{
+ GCPtr pGC;
+
+ pGC = GetScratchGC (pWin->drawable.depth, pWin->drawable.pScreen);
+ if (SetupBackgroundPainter(pWin, pGC))
+ {
+ ValidateGC(pDrawable, pGC);
+ (*pGC->ops->PolyFillRect) (pDrawable, pGC, nrects, pRects);
+ }
+ FreeScratchGC(pGC);
+}
+
+static void
+MultibufferPaintBackgroundRegion(pWin, pDrawable, pRegion)
+ WindowPtr pWin;
+ DrawablePtr pDrawable;
+ RegionPtr pRegion;
+{
+ xRectangle *pRects;
+ int nrects = REGION_NUM_RECTS(pRegion);
+ BoxPtr pbox = REGION_RECTS(pRegion);
+
+ pRects = (xRectangle *)ALLOCATE_LOCAL(nrects * sizeof(xRectangle));
+ if (pRects)
+ {
+ int i;
+ for (i = 0; i < nrects; i++)
+ {
+ pRects[i].x = pbox->x1;
+ pRects[i].y = pbox->y1;
+ pRects[i].width = pbox->x2 - pbox->x1;
+ pRects[i].height = pbox->y2 - pbox->y1;
+ }
+ MultibufferPaintBackgroundRectangles(pWin, pDrawable, nrects, pRects);
+ DEALLOCATE_LOCAL(pRects);
+ }
+}
+
+static void
+pixDisplayImageBuffers(pScreen, ppMBWindow, ppMBBuffer, nbuf)
+ mbufBufferPtr *ppMBBuffer;
+ mbufWindowPtr *ppMBWindow;
+ int nbuf;
+{
+ GCPtr pGC = NULL;
+ PixmapPtr pPrevPixmap, pNewPixmap;
+ WindowPtr pWin;
+ RegionPtr pExposed;
+ int i;
+ mbufBufferPtr pPrevMBBuffer;
+ XID bool;
+ xRectangle r;
+
+ UpdateCurrentTime ();
+ for (i = 0; i < nbuf; i++)
+ {
+ pWin = ppMBWindow[i]->pWindow;
+
+ /* Time to get a different scratch GC? */
+
+ if (!pGC
+ || pGC->depth != pWin->drawable.depth
+ || pGC->pScreen != pWin->drawable.pScreen)
+ {
+ if (pGC) FreeScratchGC(pGC);
+ pGC = GetScratchGC (pWin->drawable.depth, pWin->drawable.pScreen);
+ }
+ pPrevMBBuffer = MB_DISPLAYED_BUFFER(ppMBWindow[i]);
+ pPrevPixmap = (PixmapPtr) pPrevMBBuffer->pDrawable;
+ pNewPixmap = (PixmapPtr) ppMBBuffer[i]->pDrawable;
+
+ if (pPrevPixmap == pNewPixmap)
+ {
+ /* "If a specified buffer is already displayed, any delays and
+ * update action will still be performed for that buffer."
+ *
+ * We special-case this because applications do occasionally
+ * request a redundant DisplayImageBuffers, and we can save
+ * strokes by recognizing that the only update action that will
+ * change the buffer contents in this case is Background.
+ */
+ if (ppMBWindow[i]->updateAction == MultibufferUpdateActionBackground)
+ {
+ r.x = r.y = 0;
+ r.width = pWin->drawable.width;
+ r.height = pWin->drawable.height;
+ MultibufferPaintBackgroundRectangles(pWin, (DrawablePtr)pWin,
+ 1, &r);
+ }
+ }
+ else /* different buffer is being displayed */
+ {
+ /* perform update action */
+
+ switch (ppMBWindow[i]->updateAction)
+ {
+ case MultibufferUpdateActionUndefined:
+ break;
+
+ case MultibufferUpdateActionBackground:
+
+ r.x = r.y = 0;
+ r.width = pPrevPixmap->drawable.width;
+ r.height = pPrevPixmap->drawable.height;
+ MultibufferPaintBackgroundRectangles(pWin,
+ (DrawablePtr)pPrevPixmap,
+ 1, &r);
+ break;
+
+ case MultibufferUpdateActionUntouched:
+
+ /* copy the window to the pixmap that represents the
+ * currently displayed buffer
+ */
+
+ if (pPrevMBBuffer->eventMask & ExposureMask)
+ {
+ bool = TRUE;
+ DoChangeGC (pGC, GCGraphicsExposures, &bool, FALSE);
+ }
+ ValidateGC ((DrawablePtr)pPrevPixmap, pGC);
+ pExposed = (*pGC->ops->CopyArea)((DrawablePtr) pWin,
+ (DrawablePtr) pPrevPixmap,
+ pGC,
+ 0, 0,
+ pWin->drawable.width,
+ pWin->drawable.height,
+ 0, 0);
+
+ /* if we couldn't copy the whole window to the buffer,
+ * send expose events (if any client wants them)
+ */
+
+ if (pPrevMBBuffer->eventMask & ExposureMask)
+ { /* some client wants expose events */
+ if (pExposed)
+ {
+ RegionPtr pWinSize;
+ extern RegionPtr CreateUnclippedWinSize();
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ pWinSize = CreateUnclippedWinSize (pWin);
+ /*
+ * pExposed is window-relative, but at this point
+ * pWinSize is screen-relative. Make pWinSize be
+ * window-relative so that region ops involving
+ * pExposed and pWinSize behave sensibly.
+ */
+ REGION_TRANSLATE(pScreen, pWinSize,
+ -pWin->drawable.x,
+ -pWin->drawable.y);
+ REGION_INTERSECT(pScreen, pExposed, pExposed, pWinSize);
+ REGION_DESTROY(pScreen, pWinSize);
+ MultibufferExpose (pPrevMBBuffer, pExposed);
+ REGION_DESTROY(pScreen, pExposed);
+ }
+ bool = FALSE;
+ DoChangeGC (pGC, GCGraphicsExposures, &bool, FALSE);
+ } /* end some client wants expose events */
+
+ break; /* end case MultibufferUpdateActionUntouched */
+
+ case MultibufferUpdateActionCopied:
+
+ ValidateGC ((DrawablePtr)pPrevPixmap, pGC);
+ (*pGC->ops->CopyArea) ((DrawablePtr)pNewPixmap,
+ (DrawablePtr)pPrevPixmap, pGC,
+ 0, 0, pWin->drawable.width,
+ pWin->drawable.height, 0, 0);
+ break;
+
+ } /* end switch on update action */
+
+ /* display the new buffer */
+
+ ValidateGC ((DrawablePtr)pWin, pGC);
+ (*pGC->ops->CopyArea) ((DrawablePtr)pNewPixmap, (DrawablePtr)pWin,
+ pGC, 0, 0,
+ pWin->drawable.width, pWin->drawable.height,
+ 0, 0);
+ }
+
+ ppMBWindow[i]->lastUpdate = currentTime;
+ }
+
+ if (pGC) FreeScratchGC (pGC);
+ return;
+}
+
+/*
+ * resize the buffers when the window is resized
+ */
+
+static Bool
+pixPositionWindow (pWin, x, y)
+ WindowPtr pWin;
+ int x, y;
+{
+ ScreenPtr pScreen;
+ mbufPixmapPrivPtr pMBPriv;
+ mbufWindowPtr pMBWindow;
+ mbufBufferPtr pMBBuffer;
+ int width, height;
+ int i;
+ int dx, dy, dw, dh;
+ int sourcex, sourcey;
+ int destx, desty;
+ PixmapPtr pPixmap;
+ GCPtr pGC;
+ int savewidth, saveheight;
+ Bool clear;
+ RegionRec exposedRegion;
+ Bool ret;
+
+ pScreen = pWin->drawable.pScreen;
+ pMBPriv = MB_SCREEN_PRIV_PIXMAP(pScreen);
+
+ UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, Bool, PositionWindow);
+ ret = (* pScreen->PositionWindow) (pWin, x, y);
+ REWRAP_SCREEN_FUNC(pScreen, pMBPriv, Bool, PositionWindow);
+
+ if (!(pMBWindow = MB_WINDOW_PRIV(pWin)))
+ return ret;
+
+ /* if new size is same as old, we're done */
+
+ if (pMBWindow->width == pWin->drawable.width &&
+ pMBWindow->height == pWin->drawable.height)
+ return ret;
+
+ width = pWin->drawable.width;
+ height = pWin->drawable.height;
+ dx = pWin->drawable.x - pMBWindow->x;
+ dy = pWin->drawable.x - pMBWindow->y;
+ dw = width - pMBWindow->width;
+ dh = height - pMBWindow->height;
+ GravityTranslate (0, 0, -dx, -dy, dw, dh,
+ pWin->bitGravity, &destx, &desty);
+
+ /* if the window grew, remember to paint the window background,
+ * and maybe send expose events, for the new areas of the buffers
+ */
+
+ clear = pMBWindow->width < width || pMBWindow->height < height ||
+ pWin->bitGravity == ForgetGravity;
+
+ sourcex = 0;
+ sourcey = 0;
+ savewidth = pMBWindow->width;
+ saveheight = pMBWindow->height;
+ /* clip rectangle to source and destination */
+ if (destx < 0)
+ {
+ savewidth += destx;
+ sourcex -= destx;
+ destx = 0;
+ }
+ if (destx + savewidth > width)
+ savewidth = width - destx;
+ if (desty < 0)
+ {
+ saveheight += desty;
+ sourcey -= desty;
+ desty = 0;
+ }
+ if (desty + saveheight > height)
+ saveheight = height - desty;
+
+ pMBWindow->width = width;
+ pMBWindow->height = height;
+ pMBWindow->x = pWin->drawable.x;
+ pMBWindow->y = pWin->drawable.y;
+
+ if (clear)
+ {
+ BoxRec box;
+
+ box.x1 = box.y1 = 0;
+ box.x2 = width;
+ box.y2 = height;
+ REGION_INIT(pScreen, &exposedRegion, &box, 1);
+ if (pWin->bitGravity != ForgetGravity)
+ {
+ RegionRec preservedRegion;
+ box.x1 = destx;
+ box.y1 = desty;
+ box.x2 = destx + savewidth;
+ box.y2 = desty + saveheight;
+ REGION_INIT(pScreen, &preservedRegion, &box, 1);
+ REGION_SUBTRACT(pScreen, &exposedRegion, &exposedRegion, &preservedRegion);
+ REGION_UNINIT(pScreen, &preservedRegion);
+ }
+
+ } /* end if (clear) */
+
+ pGC = GetScratchGC (pWin->drawable.depth, pScreen);
+
+ /* create buffers with new window size */
+
+ for (i = 0; i < pMBWindow->numMultibuffer; i++)
+ {
+ pMBBuffer = &pMBWindow->buffers[i];
+ pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, pWin->drawable.depth);
+ if (!pPixmap)
+ {
+ (* MB_SCREEN_PRIV(pScreen)->DestroyImageBuffers)(pWin);
+ break;
+ }
+ if (clear)
+ {
+ MultibufferPaintBackgroundRegion(pWin, (DrawablePtr)pPixmap, &exposedRegion);
+ MultibufferExpose(pMBBuffer, &exposedRegion);
+ }
+ if (pWin->bitGravity != ForgetGravity)
+ {
+ ValidateGC ((DrawablePtr)pPixmap, pGC);
+ (*pGC->ops->CopyArea) (pMBBuffer->pDrawable, (DrawablePtr)pPixmap,
+ pGC,
+ sourcex, sourcey, savewidth, saveheight,
+ destx, desty);
+ }
+ pPixmap->drawable.id = pMBBuffer->pDrawable->id;
+ (*pScreen->DestroyPixmap) ((PixmapPtr) pMBBuffer->pDrawable);
+ pMBBuffer->pDrawable = (DrawablePtr) pPixmap;
+ if (i != pMBWindow->displayedMultibuffer)
+ {
+ ChangeResourceValue (pPixmap->drawable.id,
+ MultibufferDrawableResType,
+ (pointer) pPixmap);
+ }
+ }
+ FreeScratchGC (pGC);
+ if (clear)
+ REGION_UNINIT(pScreen, &exposedRegion);
+ return TRUE;
+}
+
+static void
+pixWrapScreenFuncs(pScreen)
+ ScreenPtr pScreen;
+{
+ mbufPixmapPrivPtr pMBPriv = MB_SCREEN_PRIV_PIXMAP(pScreen);
+ WRAP_SCREEN_FUNC(pScreen, pMBPriv, PositionWindow, pixPositionWindow);
+}
+
+static void
+pixResetProc(pScreen)
+ ScreenPtr pScreen;
+{
+ mbufScreenPtr pMBScreen = MB_SCREEN_PRIV(pScreen);
+ mbufPixmapPrivPtr pMBPriv = MB_SCREEN_PRIV_PIXMAP(pScreen);
+
+ xfree(pMBScreen->pInfo);
+ xfree(pMBPriv);
+}
+
+static void
+pixClearImageBufferArea(pMBBuffer, x,y, width,height, exposures)
+ mbufBufferPtr pMBBuffer;
+ short x, y;
+ unsigned short width, height;
+ Bool exposures;
+{
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ BoxRec box;
+ RegionRec region;
+ int w_width, w_height;
+ DrawablePtr pDrawable;
+
+ pWin = pMBBuffer->pMBWindow->pWindow;
+ pScreen = pWin->drawable.pScreen;
+
+ w_width = pWin->drawable.width;
+ w_height = pWin->drawable.height;
+
+ box.x1 = x;
+ box.y1 = y;
+ box.x2 = width ? (box.x1 + width) : w_width;
+ box.y2 = height ? (box.y1 + height) : w_height;
+
+ if (box.x1 < 0) box.x1 = 0;
+ if (box.y1 < 0) box.y1 = 0;
+ if (box.x2 > w_width) box.x2 = w_width;
+ if (box.y2 > w_height) box.y2 = w_height;
+
+ REGION_INIT(pScreen, &region, &box, 1);
+
+ if (pMBBuffer->number == pMBBuffer->pMBWindow->displayedMultibuffer)
+ pDrawable = (DrawablePtr) pWin;
+ else
+ pDrawable = pMBBuffer->pDrawable;
+
+ MultibufferPaintBackgroundRegion(pWin, pDrawable, &region);
+
+ if (exposures)
+ MultibufferExpose(pMBBuffer, &region);
+
+ REGION_UNINIT(pScreen, &region);
+}
+
+static void
+pixDeleteBufferDrawable(pDrawable)
+ DrawablePtr pDrawable;
+{
+ (* pDrawable->pScreen->DestroyPixmap)((PixmapPtr) pDrawable);
+}
diff --git a/nx-X11/programs/Xserver/Xext/mitmisc.c b/nx-X11/programs/Xserver/Xext/mitmisc.c
new file mode 100644
index 000000000..f7b0ee55c
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/mitmisc.c
@@ -0,0 +1,176 @@
+/* $XFree86: xc/programs/Xserver/Xext/mitmisc.c,v 3.6 2003/10/28 23:08:43 tsi Exp $ */
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+********************************************************/
+
+/* RANDOM CRUFT! THIS HAS NO OFFICIAL X CONSORTIUM OR X PROJECT TEAM BLESSING */
+
+/* $Xorg: mitmisc.c,v 1.4 2001/02/09 02:04:32 xorgcvs Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#define _MITMISC_SERVER_
+#include <X11/extensions/mitmiscstr.h>
+#include "modinit.h"
+
+extern Bool permitOldBugs;
+
+#if 0
+static unsigned char MITReqCode;
+#endif
+
+static void MITResetProc(
+ ExtensionEntry * /* extEntry */
+);
+
+static DISPATCH_PROC(ProcMITDispatch);
+static DISPATCH_PROC(ProcMITGetBugMode);
+static DISPATCH_PROC(ProcMITSetBugMode);
+static DISPATCH_PROC(SProcMITDispatch);
+static DISPATCH_PROC(SProcMITGetBugMode);
+static DISPATCH_PROC(SProcMITSetBugMode);
+
+void
+MITMiscExtensionInit(INITARGS)
+{
+#if 0
+ ExtensionEntry *extEntry;
+
+ if ((extEntry = AddExtension(MITMISCNAME, 0, 0,
+ ProcMITDispatch, SProcMITDispatch,
+ MITResetProc, StandardMinorOpcode)) != 0)
+ MITReqCode = (unsigned char)extEntry->base;
+#else
+ (void) AddExtension(MITMISCNAME, 0, 0,
+ ProcMITDispatch, SProcMITDispatch,
+ MITResetProc, StandardMinorOpcode);
+#endif
+}
+
+/*ARGSUSED*/
+static void
+MITResetProc (extEntry)
+ExtensionEntry *extEntry;
+{
+}
+
+static int
+ProcMITSetBugMode(client)
+ register ClientPtr client;
+{
+ REQUEST(xMITSetBugModeReq);
+
+ REQUEST_SIZE_MATCH(xMITSetBugModeReq);
+ if ((stuff->onOff != xTrue) && (stuff->onOff != xFalse))
+ {
+ client->errorValue = stuff->onOff;
+ return BadValue;
+ }
+ permitOldBugs = stuff->onOff;
+ return(client->noClientException);
+}
+
+static int
+ProcMITGetBugMode(client)
+ register ClientPtr client;
+{
+ xMITGetBugModeReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xMITGetBugModeReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.onOff = permitOldBugs;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ }
+ WriteToClient(client, sizeof(xMITGetBugModeReply), (char *)&rep);
+ return(client->noClientException);
+}
+
+static int
+ProcMITDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_MITSetBugMode:
+ return ProcMITSetBugMode(client);
+ case X_MITGetBugMode:
+ return ProcMITGetBugMode(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static int
+SProcMITSetBugMode(client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST(xMITSetBugModeReq);
+
+ swaps(&stuff->length, n);
+ return ProcMITSetBugMode(client);
+}
+
+static int
+SProcMITGetBugMode(client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST(xMITGetBugModeReq);
+
+ swaps(&stuff->length, n);
+ return ProcMITGetBugMode(client);
+}
+
+static int
+SProcMITDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_MITSetBugMode:
+ return SProcMITSetBugMode(client);
+ case X_MITGetBugMode:
+ return SProcMITGetBugMode(client);
+ default:
+ return BadRequest;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xext/panoramiX.c b/nx-X11/programs/Xserver/Xext/panoramiX.c
new file mode 100644
index 000000000..33faedc57
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/panoramiX.c
@@ -0,0 +1,1308 @@
+/* $Xorg: panoramiX.c,v 1.5 2000/08/17 19:47:57 cpqbld Exp $ */
+/*****************************************************************
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/Xext/panoramiX.c,v 3.37tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#define NEED_REPLIES
+#include <stdio.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xarch.h>
+#include "misc.h"
+#include "cursor.h"
+#include "cursorstr.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "gc.h"
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "window.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "panoramiX.h"
+#include <X11/extensions/panoramiXproto.h>
+#include "panoramiXsrv.h"
+#include "globals.h"
+#include "servermd.h"
+#include "resource.h"
+#ifdef RENDER
+#include "picturestr.h"
+#endif
+#include "modinit.h"
+
+
+#ifdef GLXPROXY
+extern VisualPtr glxMatchVisual(ScreenPtr pScreen,
+ VisualPtr pVisual,
+ ScreenPtr pMatchScreen);
+#endif
+
+#if 0
+static unsigned char PanoramiXReqCode = 0;
+#endif
+/*
+ * PanoramiX data declarations
+ */
+
+int PanoramiXPixWidth = 0;
+int PanoramiXPixHeight = 0;
+int PanoramiXNumScreens = 0;
+
+PanoramiXData *panoramiXdataPtr = NULL;
+RegionRec PanoramiXScreenRegion = {{0, 0, 0, 0}, NULL};
+
+static int PanoramiXNumDepths;
+static DepthPtr PanoramiXDepths;
+static int PanoramiXNumVisuals;
+static VisualPtr PanoramiXVisuals;
+
+/* We support at most 256 visuals */
+XID *PanoramiXVisualTable = NULL;
+
+unsigned long XRC_DRAWABLE;
+unsigned long XRT_WINDOW;
+unsigned long XRT_PIXMAP;
+unsigned long XRT_GC;
+unsigned long XRT_COLORMAP;
+
+/*
+ * Function prototypes
+ */
+
+static int panoramiXGeneration;
+static int ProcPanoramiXDispatch(ClientPtr client);
+
+static void PanoramiXResetProc(ExtensionEntry*);
+
+/*
+ * External references for functions and data variables
+ */
+
+#include "panoramiXh.h"
+
+int (* SavedProcVector[256]) (ClientPtr client) = { NULL, };
+ScreenInfo *GlobalScrInfo = NULL;
+
+static int PanoramiXGCIndex = -1;
+static int PanoramiXScreenIndex = -1;
+
+typedef struct {
+ DDXPointRec clipOrg;
+ DDXPointRec patOrg;
+ GCFuncs *wrapFuncs;
+} PanoramiXGCRec, *PanoramiXGCPtr;
+
+typedef struct {
+ CreateGCProcPtr CreateGC;
+ CloseScreenProcPtr CloseScreen;
+} PanoramiXScreenRec, *PanoramiXScreenPtr;
+
+RegionRec XineramaScreenRegions[MAXSCREENS];
+
+static void XineramaValidateGC(GCPtr, unsigned long, DrawablePtr);
+static void XineramaChangeGC(GCPtr, unsigned long);
+static void XineramaCopyGC(GCPtr, unsigned long, GCPtr);
+static void XineramaDestroyGC(GCPtr);
+static void XineramaChangeClip(GCPtr, int, pointer, int);
+static void XineramaDestroyClip(GCPtr);
+static void XineramaCopyClip(GCPtr, GCPtr);
+
+GCFuncs XineramaGCFuncs = {
+ XineramaValidateGC, XineramaChangeGC, XineramaCopyGC, XineramaDestroyGC,
+ XineramaChangeClip, XineramaDestroyClip, XineramaCopyClip
+};
+
+#define Xinerama_GC_FUNC_PROLOGUE(pGC)\
+ PanoramiXGCPtr pGCPriv = \
+ (PanoramiXGCPtr) (pGC)->devPrivates[PanoramiXGCIndex].ptr;\
+ (pGC)->funcs = pGCPriv->wrapFuncs;
+
+#define Xinerama_GC_FUNC_EPILOGUE(pGC)\
+ pGCPriv->wrapFuncs = (pGC)->funcs;\
+ (pGC)->funcs = &XineramaGCFuncs;
+
+
+static Bool
+XineramaCloseScreen (int i, ScreenPtr pScreen)
+{
+ PanoramiXScreenPtr pScreenPriv =
+ (PanoramiXScreenPtr) pScreen->devPrivates[PanoramiXScreenIndex].ptr;
+
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+ pScreen->CreateGC = pScreenPriv->CreateGC;
+
+ REGION_UNINIT(pScreen, &XineramaScreenRegions[pScreen->myNum]);
+ if (pScreen->myNum == 0)
+ REGION_UNINIT(pScreen, &PanoramiXScreenRegion);
+
+ xfree ((pointer) pScreenPriv);
+
+ return (*pScreen->CloseScreen) (i, pScreen);
+}
+
+Bool
+XineramaCreateGC(GCPtr pGC)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ PanoramiXScreenPtr pScreenPriv =
+ (PanoramiXScreenPtr) pScreen->devPrivates[PanoramiXScreenIndex].ptr;
+ Bool ret;
+
+ pScreen->CreateGC = pScreenPriv->CreateGC;
+ if((ret = (*pScreen->CreateGC)(pGC))) {
+ PanoramiXGCPtr pGCPriv =
+ (PanoramiXGCPtr) pGC->devPrivates[PanoramiXGCIndex].ptr;
+
+ pGCPriv->wrapFuncs = pGC->funcs;
+ pGC->funcs = &XineramaGCFuncs;
+
+ pGCPriv->clipOrg.x = pGC->clipOrg.x;
+ pGCPriv->clipOrg.y = pGC->clipOrg.y;
+ pGCPriv->patOrg.x = pGC->patOrg.x;
+ pGCPriv->patOrg.y = pGC->patOrg.y;
+ }
+ pScreen->CreateGC = XineramaCreateGC;
+
+ return ret;
+}
+
+static void
+XineramaValidateGC(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDraw
+){
+ Xinerama_GC_FUNC_PROLOGUE (pGC);
+
+ if((pDraw->type == DRAWABLE_WINDOW) && !(((WindowPtr)pDraw)->parent)) {
+ /* the root window */
+ int x_off = panoramiXdataPtr[pGC->pScreen->myNum].x;
+ int y_off = panoramiXdataPtr[pGC->pScreen->myNum].y;
+ int new_val;
+
+ new_val = pGCPriv->clipOrg.x - x_off;
+ if(pGC->clipOrg.x != new_val) {
+ pGC->clipOrg.x = new_val;
+ changes |= GCClipXOrigin;
+ }
+ new_val = pGCPriv->clipOrg.y - y_off;
+ if(pGC->clipOrg.y != new_val) {
+ pGC->clipOrg.y = new_val;
+ changes |= GCClipYOrigin;
+ }
+ new_val = pGCPriv->patOrg.x - x_off;
+ if(pGC->patOrg.x != new_val) {
+ pGC->patOrg.x = new_val;
+ changes |= GCTileStipXOrigin;
+ }
+ new_val = pGCPriv->patOrg.y - y_off;
+ if(pGC->patOrg.y != new_val) {
+ pGC->patOrg.y = new_val;
+ changes |= GCTileStipYOrigin;
+ }
+ } else {
+ if(pGC->clipOrg.x != pGCPriv->clipOrg.x) {
+ pGC->clipOrg.x = pGCPriv->clipOrg.x;
+ changes |= GCClipXOrigin;
+ }
+ if(pGC->clipOrg.y != pGCPriv->clipOrg.y) {
+ pGC->clipOrg.y = pGCPriv->clipOrg.y;
+ changes |= GCClipYOrigin;
+ }
+ if(pGC->patOrg.x != pGCPriv->patOrg.x) {
+ pGC->patOrg.x = pGCPriv->patOrg.x;
+ changes |= GCTileStipXOrigin;
+ }
+ if(pGC->patOrg.y != pGCPriv->patOrg.y) {
+ pGC->patOrg.y = pGCPriv->patOrg.y;
+ changes |= GCTileStipYOrigin;
+ }
+ }
+
+ (*pGC->funcs->ValidateGC)(pGC, changes, pDraw);
+ Xinerama_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+XineramaDestroyGC(GCPtr pGC)
+{
+ Xinerama_GC_FUNC_PROLOGUE (pGC);
+ (*pGC->funcs->DestroyGC)(pGC);
+ Xinerama_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+XineramaChangeGC (
+ GCPtr pGC,
+ unsigned long mask
+){
+ Xinerama_GC_FUNC_PROLOGUE (pGC);
+
+ if(mask & GCTileStipXOrigin)
+ pGCPriv->patOrg.x = pGC->patOrg.x;
+ if(mask & GCTileStipYOrigin)
+ pGCPriv->patOrg.y = pGC->patOrg.y;
+ if(mask & GCClipXOrigin)
+ pGCPriv->clipOrg.x = pGC->clipOrg.x;
+ if(mask & GCClipYOrigin)
+ pGCPriv->clipOrg.y = pGC->clipOrg.y;
+
+ (*pGC->funcs->ChangeGC) (pGC, mask);
+ Xinerama_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+XineramaCopyGC (
+ GCPtr pGCSrc,
+ unsigned long mask,
+ GCPtr pGCDst
+){
+ PanoramiXGCPtr pSrcPriv =
+ (PanoramiXGCPtr) pGCSrc->devPrivates[PanoramiXGCIndex].ptr;
+ Xinerama_GC_FUNC_PROLOGUE (pGCDst);
+
+ if(mask & GCTileStipXOrigin)
+ pGCPriv->patOrg.x = pSrcPriv->patOrg.x;
+ if(mask & GCTileStipYOrigin)
+ pGCPriv->patOrg.y = pSrcPriv->patOrg.y;
+ if(mask & GCClipXOrigin)
+ pGCPriv->clipOrg.x = pSrcPriv->clipOrg.x;
+ if(mask & GCClipYOrigin)
+ pGCPriv->clipOrg.y = pSrcPriv->clipOrg.y;
+
+ (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
+ Xinerama_GC_FUNC_EPILOGUE (pGCDst);
+}
+
+static void
+XineramaChangeClip (
+ GCPtr pGC,
+ int type,
+ pointer pvalue,
+ int nrects
+){
+ Xinerama_GC_FUNC_PROLOGUE (pGC);
+ (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
+ Xinerama_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+XineramaCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
+{
+ Xinerama_GC_FUNC_PROLOGUE (pgcDst);
+ (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
+ Xinerama_GC_FUNC_EPILOGUE (pgcDst);
+}
+
+static void
+XineramaDestroyClip(GCPtr pGC)
+{
+ Xinerama_GC_FUNC_PROLOGUE (pGC);
+ (* pGC->funcs->DestroyClip)(pGC);
+ Xinerama_GC_FUNC_EPILOGUE (pGC);
+}
+
+
+
+int
+XineramaDeleteResource(pointer data, XID id)
+{
+ xfree(data);
+ return 1;
+}
+
+
+static Bool
+XineramaFindIDOnAnyScreen(pointer resource, XID id, pointer privdata)
+{
+ PanoramiXRes *res = (PanoramiXRes*)resource;
+ int j;
+
+ FOR_NSCREENS(j)
+ if(res->info[j].id == *((XID*)privdata)) return TRUE;
+
+ return FALSE;
+}
+
+PanoramiXRes *
+PanoramiXFindIDOnAnyScreen(RESTYPE type, XID id)
+{
+ return LookupClientResourceComplex(clients[CLIENT_ID(id)], type,
+ XineramaFindIDOnAnyScreen, &id);
+}
+
+typedef struct {
+ int screen;
+ int id;
+} PanoramiXSearchData;
+
+
+static Bool
+XineramaFindIDByScrnum(pointer resource, XID id, pointer privdata)
+{
+ PanoramiXRes *res = (PanoramiXRes*)resource;
+ PanoramiXSearchData *data = (PanoramiXSearchData*)privdata;
+
+ return (res->info[data->screen].id == data->id);
+}
+
+PanoramiXRes *
+PanoramiXFindIDByScrnum(RESTYPE type, XID id, int screen)
+{
+ PanoramiXSearchData data;
+
+ if(!screen)
+ return LookupIDByType(id, type);
+
+ data.screen = screen;
+ data.id = id;
+
+ return LookupClientResourceComplex(clients[CLIENT_ID(id)], type,
+ XineramaFindIDByScrnum, &data);
+}
+
+WindowPtr
+PanoramiXChangeWindow(int ScrnNum, WindowPtr pWin)
+{
+ int num = pWin->drawable.pScreen->myNum;
+
+ if(num != ScrnNum) {
+ PanoramiXRes *win;
+
+ win = PanoramiXFindIDByScrnum(XRT_WINDOW, pWin->drawable.id, num);
+
+ if (win)
+ pWin = (WindowPtr) LookupIDByType(win->info[ScrnNum].id, RT_WINDOW);
+ }
+
+ return pWin;
+}
+
+typedef struct _connect_callback_list {
+ void (*func)(void);
+ struct _connect_callback_list *next;
+} XineramaConnectionCallbackList;
+
+static XineramaConnectionCallbackList *ConnectionCallbackList = NULL;
+
+Bool
+XineramaRegisterConnectionBlockCallback(void (*func)(void))
+{
+ XineramaConnectionCallbackList *newlist;
+
+ if(!(newlist = xalloc(sizeof(XineramaConnectionCallbackList))))
+ return FALSE;
+
+ newlist->next = ConnectionCallbackList;
+ newlist->func = func;
+ ConnectionCallbackList = newlist;
+
+ return TRUE;
+}
+
+static void XineramaInitData(ScreenPtr pScreen)
+{
+ int i, w, h;
+
+ REGION_NULL(pScreen, &PanoramiXScreenRegion)
+ for (i = 0; i < PanoramiXNumScreens; i++) {
+ BoxRec TheBox;
+
+ pScreen = screenInfo.screens[i];
+
+ panoramiXdataPtr[i].x = dixScreenOrigins[i].x;
+ panoramiXdataPtr[i].y = dixScreenOrigins[i].y;
+ panoramiXdataPtr[i].width = pScreen->width;
+ panoramiXdataPtr[i].height = pScreen->height;
+
+ TheBox.x1 = panoramiXdataPtr[i].x;
+ TheBox.x2 = TheBox.x1 + panoramiXdataPtr[i].width;
+ TheBox.y1 = panoramiXdataPtr[i].y;
+ TheBox.y2 = TheBox.y1 + panoramiXdataPtr[i].height;
+
+ REGION_INIT(pScreen, &XineramaScreenRegions[i], &TheBox, 1);
+ REGION_UNION(pScreen, &PanoramiXScreenRegion, &PanoramiXScreenRegion,
+ &XineramaScreenRegions[i]);
+ }
+
+ PanoramiXPixWidth = panoramiXdataPtr[0].x + panoramiXdataPtr[0].width;
+ PanoramiXPixHeight = panoramiXdataPtr[0].y + panoramiXdataPtr[0].height;
+
+ for (i = 1; i < PanoramiXNumScreens; i++) {
+ w = panoramiXdataPtr[i].x + panoramiXdataPtr[i].width;
+ h = panoramiXdataPtr[i].y + panoramiXdataPtr[i].height;
+
+ if (PanoramiXPixWidth < w)
+ PanoramiXPixWidth = w;
+ if (PanoramiXPixHeight < h)
+ PanoramiXPixHeight = h;
+ }
+}
+
+void XineramaReinitData(ScreenPtr pScreen)
+{
+ int i;
+
+ REGION_UNINIT(pScreen, &PanoramiXScreenRegion);
+ for (i = 0; i < PanoramiXNumScreens; i++)
+ REGION_UNINIT(pScreen, &XineramaScreenRegions[i]);
+
+ XineramaInitData(pScreen);
+}
+
+/*
+ * PanoramiXExtensionInit():
+ * Called from InitExtensions in main().
+ * Register PanoramiXeen Extension
+ * Initialize global variables.
+ */
+
+void PanoramiXExtensionInit(int argc, char *argv[])
+{
+ int i;
+ Bool success = FALSE;
+ ExtensionEntry *extEntry;
+ ScreenPtr pScreen = screenInfo.screens[0];
+ PanoramiXScreenPtr pScreenPriv;
+
+ if (noPanoramiXExtension)
+ return;
+
+ GlobalScrInfo = &screenInfo; /* For debug visibility */
+ PanoramiXNumScreens = screenInfo.numScreens;
+ if (PanoramiXNumScreens == 1) { /* Only 1 screen */
+ noPanoramiXExtension = TRUE;
+ return;
+ }
+
+ while (panoramiXGeneration != serverGeneration) {
+ extEntry = AddExtension(PANORAMIX_PROTOCOL_NAME, 0,0,
+ ProcPanoramiXDispatch,
+ SProcPanoramiXDispatch, PanoramiXResetProc,
+ StandardMinorOpcode);
+ if (!extEntry) {
+ ErrorF("PanoramiXExtensionInit(): failed to AddExtension\n");
+ break;
+ }
+
+#if 0
+ PanoramiXReqCode = (unsigned char)extEntry->base;
+#endif
+
+ /*
+ * First make sure all the basic allocations succeed. If not,
+ * run in non-PanoramiXeen mode.
+ */
+
+ panoramiXdataPtr = (PanoramiXData *)
+ xcalloc(PanoramiXNumScreens, sizeof(PanoramiXData));
+
+ BREAK_IF(!panoramiXdataPtr);
+ BREAK_IF((PanoramiXGCIndex = AllocateGCPrivateIndex()) < 0);
+ BREAK_IF((PanoramiXScreenIndex = AllocateScreenPrivateIndex()) < 0);
+
+ for (i = 0; i < PanoramiXNumScreens; i++) {
+ pScreen = screenInfo.screens[i];
+ if(!AllocateGCPrivate(pScreen, PanoramiXGCIndex,
+ sizeof(PanoramiXGCRec))) {
+ noPanoramiXExtension = TRUE;
+ return;
+ }
+
+ pScreenPriv = xalloc(sizeof(PanoramiXScreenRec));
+ pScreen->devPrivates[PanoramiXScreenIndex].ptr =
+ (pointer)pScreenPriv;
+ if(!pScreenPriv) {
+ noPanoramiXExtension = TRUE;
+ return;
+ }
+
+ pScreenPriv->CreateGC = pScreen->CreateGC;
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+
+ pScreen->CreateGC = XineramaCreateGC;
+ pScreen->CloseScreen = XineramaCloseScreen;
+ }
+
+ XRC_DRAWABLE = CreateNewResourceClass();
+ XRT_WINDOW = CreateNewResourceType(XineramaDeleteResource) |
+ XRC_DRAWABLE;
+ XRT_PIXMAP = CreateNewResourceType(XineramaDeleteResource) |
+ XRC_DRAWABLE;
+ XRT_GC = CreateNewResourceType(XineramaDeleteResource);
+ XRT_COLORMAP = CreateNewResourceType(XineramaDeleteResource);
+
+ panoramiXGeneration = serverGeneration;
+ success = TRUE;
+ }
+
+ if (!success) {
+ noPanoramiXExtension = TRUE;
+ ErrorF("%s Extension failed to initialize\n", PANORAMIX_PROTOCOL_NAME);
+ return;
+ }
+
+ XineramaInitData(pScreen);
+
+ /*
+ * Put our processes into the ProcVector
+ */
+
+ for (i = 256; i--; )
+ SavedProcVector[i] = ProcVector[i];
+
+ ProcVector[X_CreateWindow] = PanoramiXCreateWindow;
+ ProcVector[X_ChangeWindowAttributes] = PanoramiXChangeWindowAttributes;
+ ProcVector[X_DestroyWindow] = PanoramiXDestroyWindow;
+ ProcVector[X_DestroySubwindows] = PanoramiXDestroySubwindows;
+ ProcVector[X_ChangeSaveSet] = PanoramiXChangeSaveSet;
+ ProcVector[X_ReparentWindow] = PanoramiXReparentWindow;
+ ProcVector[X_MapWindow] = PanoramiXMapWindow;
+ ProcVector[X_MapSubwindows] = PanoramiXMapSubwindows;
+ ProcVector[X_UnmapWindow] = PanoramiXUnmapWindow;
+ ProcVector[X_UnmapSubwindows] = PanoramiXUnmapSubwindows;
+ ProcVector[X_ConfigureWindow] = PanoramiXConfigureWindow;
+ ProcVector[X_CirculateWindow] = PanoramiXCirculateWindow;
+ ProcVector[X_GetGeometry] = PanoramiXGetGeometry;
+ ProcVector[X_TranslateCoords] = PanoramiXTranslateCoords;
+ ProcVector[X_CreatePixmap] = PanoramiXCreatePixmap;
+ ProcVector[X_FreePixmap] = PanoramiXFreePixmap;
+ ProcVector[X_CreateGC] = PanoramiXCreateGC;
+ ProcVector[X_ChangeGC] = PanoramiXChangeGC;
+ ProcVector[X_CopyGC] = PanoramiXCopyGC;
+ ProcVector[X_SetDashes] = PanoramiXSetDashes;
+ ProcVector[X_SetClipRectangles] = PanoramiXSetClipRectangles;
+ ProcVector[X_FreeGC] = PanoramiXFreeGC;
+ ProcVector[X_ClearArea] = PanoramiXClearToBackground;
+ ProcVector[X_CopyArea] = PanoramiXCopyArea;;
+ ProcVector[X_CopyPlane] = PanoramiXCopyPlane;;
+ ProcVector[X_PolyPoint] = PanoramiXPolyPoint;
+ ProcVector[X_PolyLine] = PanoramiXPolyLine;
+ ProcVector[X_PolySegment] = PanoramiXPolySegment;
+ ProcVector[X_PolyRectangle] = PanoramiXPolyRectangle;
+ ProcVector[X_PolyArc] = PanoramiXPolyArc;
+ ProcVector[X_FillPoly] = PanoramiXFillPoly;
+ ProcVector[X_PolyFillRectangle] = PanoramiXPolyFillRectangle;
+ ProcVector[X_PolyFillArc] = PanoramiXPolyFillArc;
+ ProcVector[X_PutImage] = PanoramiXPutImage;
+ ProcVector[X_GetImage] = PanoramiXGetImage;
+ ProcVector[X_PolyText8] = PanoramiXPolyText8;
+ ProcVector[X_PolyText16] = PanoramiXPolyText16;
+ ProcVector[X_ImageText8] = PanoramiXImageText8;
+ ProcVector[X_ImageText16] = PanoramiXImageText16;
+ ProcVector[X_CreateColormap] = PanoramiXCreateColormap;
+ ProcVector[X_FreeColormap] = PanoramiXFreeColormap;
+ ProcVector[X_CopyColormapAndFree] = PanoramiXCopyColormapAndFree;
+ ProcVector[X_InstallColormap] = PanoramiXInstallColormap;
+ ProcVector[X_UninstallColormap] = PanoramiXUninstallColormap;
+ ProcVector[X_AllocColor] = PanoramiXAllocColor;
+ ProcVector[X_AllocNamedColor] = PanoramiXAllocNamedColor;
+ ProcVector[X_AllocColorCells] = PanoramiXAllocColorCells;
+ ProcVector[X_AllocColorPlanes] = PanoramiXAllocColorPlanes;
+ ProcVector[X_FreeColors] = PanoramiXFreeColors;
+ ProcVector[X_StoreColors] = PanoramiXStoreColors;
+ ProcVector[X_StoreNamedColor] = PanoramiXStoreNamedColor;
+
+#ifdef RENDER
+ PanoramiXRenderInit ();
+#endif
+}
+
+extern Bool CreateConnectionBlock(void);
+
+Bool PanoramiXCreateConnectionBlock(void)
+{
+ int i, j, length;
+ Bool disableBackingStore = FALSE;
+ Bool disableSaveUnders = FALSE;
+ int old_width, old_height;
+ float width_mult, height_mult;
+ xWindowRoot *root;
+ xVisualType *visual;
+ xDepth *depth;
+ VisualPtr pVisual;
+ ScreenPtr pScreen;
+
+ /*
+ * Do normal CreateConnectionBlock but faking it for only one screen
+ */
+
+ if(!PanoramiXNumDepths) {
+ ErrorF("PanoramiX error: Incompatible screens. No common visuals\n");
+ return FALSE;
+ }
+
+ for(i = 1; i < screenInfo.numScreens; i++) {
+ pScreen = screenInfo.screens[i];
+ if(pScreen->rootDepth != screenInfo.screens[0]->rootDepth) {
+ ErrorF("PanoramiX error: Incompatible screens. Root window depths differ\n");
+ return FALSE;
+ }
+ if(pScreen->backingStoreSupport != screenInfo.screens[0]->backingStoreSupport)
+ disableBackingStore = TRUE;
+ if(pScreen->saveUnderSupport != screenInfo.screens[0]->saveUnderSupport)
+ disableSaveUnders = TRUE;
+ }
+
+ if(disableBackingStore || disableSaveUnders) {
+ for(i = 0; i < screenInfo.numScreens; i++) {
+ pScreen = screenInfo.screens[i];
+ if(disableBackingStore)
+ pScreen->backingStoreSupport = NotUseful;
+ if(disableSaveUnders)
+ pScreen->saveUnderSupport = NotUseful;
+ }
+ }
+
+ i = screenInfo.numScreens;
+ screenInfo.numScreens = 1;
+ if (!CreateConnectionBlock()) {
+ screenInfo.numScreens = i;
+ return FALSE;
+ }
+
+ screenInfo.numScreens = i;
+
+ root = (xWindowRoot *) (ConnectionInfo + connBlockScreenStart);
+ length = connBlockScreenStart + sizeof(xWindowRoot);
+
+ /* overwrite the connection block */
+ root->nDepths = PanoramiXNumDepths;
+
+ for (i = 0; i < PanoramiXNumDepths; i++) {
+ depth = (xDepth *) (ConnectionInfo + length);
+ depth->depth = PanoramiXDepths[i].depth;
+ depth->nVisuals = PanoramiXDepths[i].numVids;
+ length += sizeof(xDepth);
+ visual = (xVisualType *)(ConnectionInfo + length);
+
+ for (j = 0; j < depth->nVisuals; j++, visual++) {
+ visual->visualID = PanoramiXDepths[i].vids[j];
+
+ for (pVisual = PanoramiXVisuals;
+ pVisual->vid != visual->visualID;
+ pVisual++)
+ ;
+
+ visual->class = pVisual->class;
+ visual->bitsPerRGB = pVisual->bitsPerRGBValue;
+ visual->colormapEntries = pVisual->ColormapEntries;
+ visual->redMask = pVisual->redMask;
+ visual->greenMask = pVisual->greenMask;
+ visual->blueMask = pVisual->blueMask;
+ }
+
+ length += (depth->nVisuals * sizeof(xVisualType));
+ }
+
+ connSetupPrefix.length = length >> 2;
+
+ xfree(PanoramiXVisuals);
+ for (i = 0; i < PanoramiXNumDepths; i++)
+ xfree(PanoramiXDepths[i].vids);
+ xfree(PanoramiXDepths);
+
+ /*
+ * OK, change some dimensions so it looks as if it were one big screen
+ */
+
+ old_width = root->pixWidth;
+ old_height = root->pixHeight;
+
+ root->pixWidth = PanoramiXPixWidth;
+ root->pixHeight = PanoramiXPixHeight;
+ width_mult = (1.0 * root->pixWidth) / old_width;
+ height_mult = (1.0 * root->pixHeight) / old_height;
+ root->mmWidth *= width_mult;
+ root->mmHeight *= height_mult;
+
+ while(ConnectionCallbackList) {
+ pointer tmp;
+
+ tmp = (pointer)ConnectionCallbackList;
+ (*ConnectionCallbackList->func)();
+ ConnectionCallbackList = ConnectionCallbackList->next;
+ xfree(tmp);
+ }
+
+ return TRUE;
+}
+
+extern
+void PanoramiXConsolidate(void)
+{
+ int i, j, k;
+ VisualPtr pVisual, pVisual2;
+ ScreenPtr pScreen, pScreen2;
+ DepthPtr pDepth, pDepth2;
+ PanoramiXRes *root, *defmap, *saver;
+ Bool foundDepth, missingDepth;
+
+ if(!PanoramiXVisualTable)
+ PanoramiXVisualTable = xcalloc(256 * MAXSCREENS, sizeof(XID));
+
+ pScreen = screenInfo.screens[0];
+ pVisual = pScreen->visuals;
+ pDepth = pScreen->allowedDepths;
+
+ PanoramiXNumDepths = 0;
+ PanoramiXDepths = xcalloc(pScreen->numDepths,sizeof(DepthRec));
+ PanoramiXNumVisuals = 0;
+ PanoramiXVisuals = xcalloc(pScreen->numVisuals,sizeof(VisualRec));
+
+ for (i = 0; i < pScreen->numDepths; i++, pDepth++) {
+ missingDepth = FALSE;
+ for (j = 1; j < PanoramiXNumScreens; j++) {
+ pScreen2 = screenInfo.screens[j];
+ pDepth2 = pScreen2->allowedDepths;
+
+ foundDepth = FALSE;
+ for (k = 0; k < pScreen2->numDepths; k++, pDepth2++) {
+ if(pDepth2->depth == pDepth->depth) {
+ foundDepth = TRUE;
+ break;
+ }
+ }
+
+ if(!foundDepth) {
+ missingDepth = TRUE;
+ break;
+ }
+ }
+
+ if(!missingDepth) {
+ PanoramiXDepths[PanoramiXNumDepths].depth = pDepth->depth;
+ PanoramiXDepths[PanoramiXNumDepths].numVids = 0;
+ if(pDepth->numVids)
+ PanoramiXDepths[PanoramiXNumDepths].vids =
+ xalloc(sizeof(VisualID) * pDepth->numVids);
+ else
+ PanoramiXDepths[PanoramiXNumDepths].vids = NULL;
+ PanoramiXNumDepths++;
+ }
+ }
+
+ for (i = 0; i < pScreen->numVisuals; i++, pVisual++) {
+ PanoramiXVisualTable[pVisual->vid * MAXSCREENS] = pVisual->vid;
+
+ /* check if the visual exists on all screens */
+ for (j = 1; j < PanoramiXNumScreens; j++) {
+ pScreen2 = screenInfo.screens[j];
+
+#ifdef GLXPROXY
+ pVisual2 = glxMatchVisual(pScreen, pVisual, pScreen2);
+ if (pVisual2) {
+ PanoramiXVisualTable[(pVisual->vid * MAXSCREENS) + j] =
+ pVisual2->vid;
+ continue;
+ } else if (glxMatchVisual(pScreen, pVisual, pScreen)) {
+ PanoramiXVisualTable[(pVisual->vid * MAXSCREENS) + j] = 0;
+ break;
+ }
+#endif
+ pVisual2 = pScreen2->visuals;
+
+ for (k = 0; k < pScreen2->numVisuals; k++, pVisual2++) {
+ if ((pVisual->class == pVisual2->class) &&
+ (pVisual->ColormapEntries == pVisual2->ColormapEntries) &&
+ (pVisual->nplanes == pVisual2->nplanes) &&
+ (pVisual->redMask == pVisual2->redMask) &&
+ (pVisual->greenMask == pVisual2->greenMask) &&
+ (pVisual->blueMask == pVisual2->blueMask) &&
+ (pVisual->offsetRed == pVisual2->offsetRed) &&
+ (pVisual->offsetGreen == pVisual2->offsetGreen) &&
+ (pVisual->offsetBlue == pVisual2->offsetBlue))
+ {
+ /* We merely assign the first visual that matches. OpenGL
+ will need to get involved at some point if you want
+ match GLX visuals */
+ PanoramiXVisualTable[(pVisual->vid * MAXSCREENS) + j] =
+ pVisual2->vid;
+ break;
+ }
+ }
+ }
+
+ /* if it doesn't exist on all screens we can't use it */
+ for (j = 0; j < PanoramiXNumScreens; j++) {
+ if (!PanoramiXVisualTable[(pVisual->vid * MAXSCREENS) + j]) {
+ PanoramiXVisualTable[pVisual->vid * MAXSCREENS] = 0;
+ break;
+ }
+ }
+
+ /* if it does, make sure it's in the list of supported depths and visuals */
+ if(PanoramiXVisualTable[pVisual->vid * MAXSCREENS]) {
+ PanoramiXVisuals[PanoramiXNumVisuals].vid = pVisual->vid;
+ PanoramiXVisuals[PanoramiXNumVisuals].class = pVisual->class;
+ PanoramiXVisuals[PanoramiXNumVisuals].bitsPerRGBValue = pVisual->bitsPerRGBValue;
+ PanoramiXVisuals[PanoramiXNumVisuals].ColormapEntries = pVisual->ColormapEntries;
+ PanoramiXVisuals[PanoramiXNumVisuals].nplanes = pVisual->nplanes;
+ PanoramiXVisuals[PanoramiXNumVisuals].redMask = pVisual->redMask;
+ PanoramiXVisuals[PanoramiXNumVisuals].greenMask = pVisual->greenMask;
+ PanoramiXVisuals[PanoramiXNumVisuals].blueMask = pVisual->blueMask;
+ PanoramiXVisuals[PanoramiXNumVisuals].offsetRed = pVisual->offsetRed;
+ PanoramiXVisuals[PanoramiXNumVisuals].offsetGreen = pVisual->offsetGreen;
+ PanoramiXVisuals[PanoramiXNumVisuals].offsetBlue = pVisual->offsetBlue;
+ PanoramiXNumVisuals++;
+
+ for (j = 0; j < PanoramiXNumDepths; j++) {
+ if (PanoramiXDepths[j].depth == pVisual->nplanes) {
+ PanoramiXDepths[j].vids[PanoramiXDepths[j].numVids] = pVisual->vid;
+ PanoramiXDepths[j].numVids++;
+ break;
+ }
+ }
+ }
+ }
+
+
+ root = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes));
+ root->type = XRT_WINDOW;
+ defmap = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes));
+ defmap->type = XRT_COLORMAP;
+ saver = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes));
+ saver->type = XRT_WINDOW;
+
+
+ for (i = 0; i < PanoramiXNumScreens; i++) {
+ root->info[i].id = WindowTable[i]->drawable.id;
+ root->u.win.class = InputOutput;
+ root->u.win.root = TRUE;
+ saver->info[i].id = savedScreenInfo[i].wid;
+ saver->u.win.class = InputOutput;
+ saver->u.win.root = TRUE;
+ defmap->info[i].id = (screenInfo.screens[i])->defColormap;
+ }
+
+ AddResource(root->info[0].id, XRT_WINDOW, root);
+ AddResource(saver->info[0].id, XRT_WINDOW, saver);
+ AddResource(defmap->info[0].id, XRT_COLORMAP, defmap);
+}
+
+
+/*
+ * PanoramiXResetProc()
+ * Exit, deallocating as needed.
+ */
+
+static void PanoramiXResetProc(ExtensionEntry* extEntry)
+{
+ int i;
+
+#ifdef RENDER
+ PanoramiXRenderReset ();
+#endif
+ screenInfo.numScreens = PanoramiXNumScreens;
+ for (i = 256; i--; )
+ ProcVector[i] = SavedProcVector[i];
+
+ Xfree(panoramiXdataPtr);
+}
+
+
+int
+ProcPanoramiXQueryVersion (ClientPtr client)
+{
+ /* REQUEST(xPanoramiXQueryVersionReq); */
+ xPanoramiXQueryVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = PANORAMIX_MAJOR_VERSION;
+ rep.minorVersion = PANORAMIX_MINOR_VERSION;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof (xPanoramiXQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+int
+ProcPanoramiXGetState(ClientPtr client)
+{
+ REQUEST(xPanoramiXGetStateReq);
+ WindowPtr pWin;
+ xPanoramiXGetStateReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
+ pWin = LookupWindow (stuff->window, client);
+ if (!pWin)
+ return BadWindow;
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.state = !noPanoramiXExtension;
+ if (client->swapped) {
+ swaps (&rep.sequenceNumber, n);
+ swapl (&rep.length, n);
+ swaps (&rep.state, n);
+ }
+ WriteToClient (client, sizeof (xPanoramiXGetStateReply), (char *) &rep);
+ return client->noClientException;
+
+}
+
+int
+ProcPanoramiXGetScreenCount(ClientPtr client)
+{
+ REQUEST(xPanoramiXGetScreenCountReq);
+ WindowPtr pWin;
+ xPanoramiXGetScreenCountReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
+ pWin = LookupWindow (stuff->window, client);
+ if (!pWin)
+ return BadWindow;
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.ScreenCount = PanoramiXNumScreens;
+ if (client->swapped) {
+ swaps (&rep.sequenceNumber, n);
+ swapl (&rep.length, n);
+ swaps (&rep.ScreenCount, n);
+ }
+ WriteToClient (client, sizeof (xPanoramiXGetScreenCountReply), (char *) &rep);
+ return client->noClientException;
+}
+
+int
+ProcPanoramiXGetScreenSize(ClientPtr client)
+{
+ REQUEST(xPanoramiXGetScreenSizeReq);
+ WindowPtr pWin;
+ xPanoramiXGetScreenSizeReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+ pWin = LookupWindow (stuff->window, client);
+ if (!pWin)
+ return BadWindow;
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ /* screen dimensions */
+ rep.width = panoramiXdataPtr[stuff->screen].width;
+ rep.height = panoramiXdataPtr[stuff->screen].height;
+ if (client->swapped) {
+ swaps (&rep.sequenceNumber, n);
+ swapl (&rep.length, n);
+ swaps (&rep.width, n);
+ swaps (&rep.height, n);
+ }
+ WriteToClient (client, sizeof (xPanoramiXGetScreenSizeReply), (char *) &rep);
+ return client->noClientException;
+}
+
+
+int
+ProcXineramaIsActive(ClientPtr client)
+{
+ /* REQUEST(xXineramaIsActiveReq); */
+ xXineramaIsActiveReply rep;
+
+ REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+#if 1
+ {
+ /* The following hack fools clients into thinking that Xinerama
+ * is disabled even though it is not. */
+ extern Bool PanoramiXExtensionDisabledHack;
+ rep.state = !noPanoramiXExtension && !PanoramiXExtensionDisabledHack;
+ }
+#else
+ rep.state = !noPanoramiXExtension;
+#endif
+ if (client->swapped) {
+ register int n;
+ swaps (&rep.sequenceNumber, n);
+ swapl (&rep.length, n);
+ swapl (&rep.state, n);
+ }
+ WriteToClient (client, sizeof (xXineramaIsActiveReply), (char *) &rep);
+ return client->noClientException;
+}
+
+
+int
+ProcXineramaQueryScreens(ClientPtr client)
+{
+ /* REQUEST(xXineramaQueryScreensReq); */
+ xXineramaQueryScreensReply rep;
+
+ REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens;
+ rep.length = rep.number * sz_XineramaScreenInfo >> 2;
+ if (client->swapped) {
+ register int n;
+ swaps (&rep.sequenceNumber, n);
+ swapl (&rep.length, n);
+ swapl (&rep.number, n);
+ }
+ WriteToClient (client, sizeof (xXineramaQueryScreensReply), (char *) &rep);
+
+ if(!noPanoramiXExtension) {
+ xXineramaScreenInfo scratch;
+ int i;
+
+ for(i = 0; i < PanoramiXNumScreens; i++) {
+ scratch.x_org = panoramiXdataPtr[i].x;
+ scratch.y_org = panoramiXdataPtr[i].y;
+ scratch.width = panoramiXdataPtr[i].width;
+ scratch.height = panoramiXdataPtr[i].height;
+
+ if(client->swapped) {
+ register int n;
+ swaps (&scratch.x_org, n);
+ swaps (&scratch.y_org, n);
+ swaps (&scratch.width, n);
+ swaps (&scratch.height, n);
+ }
+ WriteToClient (client, sz_XineramaScreenInfo, (char *) &scratch);
+ }
+ }
+
+ return client->noClientException;
+}
+
+
+static int
+ProcPanoramiXDispatch (ClientPtr client)
+{ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_PanoramiXQueryVersion:
+ return ProcPanoramiXQueryVersion(client);
+ case X_PanoramiXGetState:
+ return ProcPanoramiXGetState(client);
+ case X_PanoramiXGetScreenCount:
+ return ProcPanoramiXGetScreenCount(client);
+ case X_PanoramiXGetScreenSize:
+ return ProcPanoramiXGetScreenSize(client);
+ case X_XineramaIsActive:
+ return ProcXineramaIsActive(client);
+ case X_XineramaQueryScreens:
+ return ProcXineramaQueryScreens(client);
+ }
+ return BadRequest;
+}
+
+
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+#define SHIFT_L(v,s) (v) << (s)
+#define SHIFT_R(v,s) (v) >> (s)
+#else
+#define SHIFT_L(v,s) (v) >> (s)
+#define SHIFT_R(v,s) (v) << (s)
+#endif
+
+static void
+CopyBits(char *dst, int shiftL, char *src, int bytes)
+{
+ /* Just get it to work. Worry about speed later */
+ int shiftR = 8 - shiftL;
+
+ while(bytes--) {
+ *dst |= SHIFT_L(*src, shiftL);
+ *(dst + 1) |= SHIFT_R(*src, shiftR);
+ dst++; src++;
+ }
+}
+
+
+/* Caution. This doesn't support 2 and 4 bpp formats. We expect
+ 1 bpp and planar data to be already cleared when presented
+ to this function */
+
+void
+XineramaGetImageData(
+ DrawablePtr *pDrawables,
+ int left,
+ int top,
+ int width,
+ int height,
+ unsigned int format,
+ unsigned long planemask,
+ char *data,
+ int pitch,
+ Bool isRoot
+){
+ RegionRec SrcRegion, GrabRegion;
+ BoxRec SrcBox, *pbox;
+ int x, y, w, h, i, j, nbox, size, sizeNeeded, ScratchPitch, inOut, depth;
+ DrawablePtr pDraw = pDrawables[0];
+ ScreenPtr pScreen = pDraw->pScreen;
+ char *ScratchMem = NULL;
+
+ size = 0;
+
+ /* find box in logical screen space */
+ SrcBox.x1 = left;
+ SrcBox.y1 = top;
+ if(!isRoot) {
+ SrcBox.x1 += pDraw->x + panoramiXdataPtr[0].x;
+ SrcBox.y1 += pDraw->y + panoramiXdataPtr[0].y;
+ }
+ SrcBox.x2 = SrcBox.x1 + width;
+ SrcBox.y2 = SrcBox.y1 + height;
+
+ REGION_INIT(pScreen, &SrcRegion, &SrcBox, 1);
+ REGION_NULL(pScreen, &GrabRegion);
+
+ depth = (format == XYPixmap) ? 1 : pDraw->depth;
+
+ for(i = 0; i < PanoramiXNumScreens; i++) {
+ pDraw = pDrawables[i];
+
+ inOut = RECT_IN_REGION(pScreen,&XineramaScreenRegions[i],&SrcBox);
+
+ if(inOut == rgnIN) {
+ (*pDraw->pScreen->GetImage)(pDraw,
+ SrcBox.x1 - pDraw->x - panoramiXdataPtr[i].x,
+ SrcBox.y1 - pDraw->y - panoramiXdataPtr[i].y,
+ width, height, format, planemask, data);
+ break;
+ } else if (inOut == rgnOUT)
+ continue;
+
+ REGION_INTERSECT(pScreen, &GrabRegion, &SrcRegion,
+ &XineramaScreenRegions[i]);
+
+ nbox = REGION_NUM_RECTS(&GrabRegion);
+
+ if(nbox) {
+ pbox = REGION_RECTS(&GrabRegion);
+
+ while(nbox--) {
+ w = pbox->x2 - pbox->x1;
+ h = pbox->y2 - pbox->y1;
+ ScratchPitch = PixmapBytePad(w, depth);
+ sizeNeeded = ScratchPitch * h;
+
+ if(sizeNeeded > size) {
+ char *tmpdata = ScratchMem;
+ ScratchMem = xrealloc(ScratchMem, sizeNeeded);
+ if(ScratchMem)
+ size = sizeNeeded;
+ else {
+ ScratchMem = tmpdata;
+ break;
+ }
+ }
+
+ x = pbox->x1 - pDraw->x - panoramiXdataPtr[i].x;
+ y = pbox->y1 - pDraw->y - panoramiXdataPtr[i].y;
+
+ (*pDraw->pScreen->GetImage)(pDraw, x, y, w, h,
+ format, planemask, ScratchMem);
+
+ /* copy the memory over */
+
+ if(depth == 1) {
+ int k, shift, leftover, index, index2;
+
+ x = pbox->x1 - SrcBox.x1;
+ y = pbox->y1 - SrcBox.y1;
+ shift = x & 7;
+ x >>= 3;
+ leftover = w & 7;
+ w >>= 3;
+
+ /* clean up the edge */
+ if(leftover) {
+ int mask = (1 << leftover) - 1;
+ for(j = h, k = w; j--; k += ScratchPitch)
+ ScratchMem[k] &= mask;
+ }
+
+ for(j = 0, index = (pitch * y) + x, index2 = 0; j < h;
+ j++, index += pitch, index2 += ScratchPitch)
+ {
+ if(w) {
+ if(!shift)
+ memcpy(data + index, ScratchMem + index2, w);
+ else
+ CopyBits(data + index, shift,
+ ScratchMem + index2, w);
+ }
+
+ if(leftover) {
+ data[index + w] |=
+ SHIFT_L(ScratchMem[index2 + w], shift);
+ if((shift + leftover) > 8)
+ data[index + w + 1] |=
+ SHIFT_R(ScratchMem[index2 + w],(8 - shift));
+ }
+ }
+ } else {
+ j = BitsPerPixel(depth) >> 3;
+ x = (pbox->x1 - SrcBox.x1) * j;
+ y = pbox->y1 - SrcBox.y1;
+ w *= j;
+
+ for(j = 0; j < h; j++) {
+ memcpy(data + (pitch * (y + j)) + x,
+ ScratchMem + (ScratchPitch * j), w);
+ }
+ }
+ pbox++;
+ }
+
+ REGION_SUBTRACT(pScreen, &SrcRegion, &SrcRegion, &GrabRegion);
+ if(!REGION_NOTEMPTY(pScreen, &SrcRegion))
+ break;
+ }
+
+ }
+
+ if(ScratchMem)
+ xfree(ScratchMem);
+
+ REGION_UNINIT(pScreen, &SrcRegion);
+ REGION_UNINIT(pScreen, &GrabRegion);
+}
diff --git a/nx-X11/programs/Xserver/Xext/panoramiX.h b/nx-X11/programs/Xserver/Xext/panoramiX.h
new file mode 100644
index 000000000..5fa4ed35c
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/panoramiX.h
@@ -0,0 +1,115 @@
+/* $TOG: panoramiX.h /main/4 1998/03/17 06:51:02 kaleb $ */
+/* $XdotOrg: xc/programs/Xserver/Xext/panoramiX.h,v 1.5 2005/07/03 07:01:04 daniels Exp $ */
+/*****************************************************************
+
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+
+/* $XFree86: xc/programs/Xserver/Xext/panoramiX.h,v 1.5 2001/01/03 02:54:17 keithp Exp $ */
+
+/* THIS IS NOT AN X PROJECT TEAM SPECIFICATION */
+
+/*
+ * PanoramiX definitions
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _PANORAMIX_H_
+#define _PANORAMIX_H_
+
+#include <X11/extensions/panoramiXext.h>
+#include "gcstruct.h"
+
+
+typedef struct _PanoramiXData {
+ int x;
+ int y;
+ int width;
+ int height;
+} PanoramiXData;
+
+typedef struct _PanoramiXInfo {
+ XID id ;
+} PanoramiXInfo;
+
+typedef struct {
+ PanoramiXInfo info[MAXSCREENS];
+ RESTYPE type;
+ union {
+ struct {
+ char visibility;
+ char class;
+ char root;
+ } win;
+ struct {
+ Bool shared;
+ } pix;
+#ifdef RENDER
+ struct {
+ Bool root;
+ } pict;
+#endif
+ char raw_data[4];
+ } u;
+} PanoramiXRes;
+
+#define FOR_NSCREENS_FORWARD(j) for(j = 0; j < PanoramiXNumScreens; j++)
+#define FOR_NSCREENS_BACKWARD(j) for(j = PanoramiXNumScreens - 1; j >= 0; j--)
+#define FOR_NSCREENS(j) FOR_NSCREENS_FORWARD(j)
+
+#define BREAK_IF(a) if ((a)) break
+#define IF_RETURN(a,b) if ((a)) return (b)
+
+#define FORCE_ROOT(a) { \
+ int _j; \
+ for (_j = PanoramiXNumScreens - 1; _j; _j--) \
+ if ((a).root == WindowTable[_j]->drawable.id) \
+ break; \
+ (a).rootX += panoramiXdataPtr[_j].x; \
+ (a).rootY += panoramiXdataPtr[_j].y; \
+ (a).root = WindowTable[0]->drawable.id; \
+}
+
+#define FORCE_WIN(a) { \
+ if ((win = PanoramiXFindIDOnAnyScreen(XRT_WINDOW, a))) { \
+ (a) = win->info[0].id; /* Real ID */ \
+ } \
+}
+
+#define FORCE_CMAP(a) { \
+ if ((win = PanoramiXFindIDOnAnyScreen(XRT_COLORMAP, a))) { \
+ (a) = win->info[0].id; /* Real ID */ \
+ } \
+}
+
+#define IS_SHARED_PIXMAP(r) (((r)->type == XRT_PIXMAP) && (r)->u.pix.shared)
+
+#define SKIP_FAKE_WINDOW(a) if(!LookupIDByType(a, XRT_WINDOW)) return
+
+#endif /* _PANORAMIX_H_ */
diff --git a/nx-X11/programs/Xserver/Xext/panoramiXSwap.c b/nx-X11/programs/Xserver/Xext/panoramiXSwap.c
new file mode 100644
index 000000000..e0548df7b
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/panoramiXSwap.c
@@ -0,0 +1,144 @@
+/* $Xorg: panoramiXSwap.c,v 1.4 2000/08/17 19:47:57 cpqbld Exp $ */
+/*****************************************************************
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/Xext/panoramiXSwap.c,v 3.9 2003/07/16 01:38:29 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "cursor.h"
+#include "cursorstr.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "gc.h"
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "window.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#if 0
+#include <sys/workstation.h>
+#include <X11/Xserver/ws.h>
+#endif
+#include "panoramiX.h"
+#include <X11/extensions/panoramiXproto.h>
+#include "panoramiXsrv.h"
+#include "globals.h"
+#include "panoramiXh.h"
+
+static int
+SProcPanoramiXQueryVersion (ClientPtr client)
+{
+ REQUEST(xPanoramiXQueryVersionReq);
+ register int n;
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq);
+ return ProcPanoramiXQueryVersion(client);
+}
+
+static int
+SProcPanoramiXGetState(ClientPtr client)
+{
+ REQUEST(xPanoramiXGetStateReq);
+ register int n;
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
+ return ProcPanoramiXGetState(client);
+}
+
+static int
+SProcPanoramiXGetScreenCount(ClientPtr client)
+{
+ REQUEST(xPanoramiXGetScreenCountReq);
+ register int n;
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
+ return ProcPanoramiXGetScreenCount(client);
+}
+
+static int
+SProcPanoramiXGetScreenSize(ClientPtr client)
+{
+ REQUEST(xPanoramiXGetScreenSizeReq);
+ register int n;
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+ return ProcPanoramiXGetScreenSize(client);
+}
+
+
+static int
+SProcXineramaIsActive(ClientPtr client)
+{
+ REQUEST(xXineramaIsActiveReq);
+ register int n;
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
+ return ProcXineramaIsActive(client);
+}
+
+
+static int
+SProcXineramaQueryScreens(ClientPtr client)
+{
+ REQUEST(xXineramaQueryScreensReq);
+ register int n;
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
+ return ProcXineramaQueryScreens(client);
+}
+
+
+int
+SProcPanoramiXDispatch (ClientPtr client)
+{ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_PanoramiXQueryVersion:
+ return SProcPanoramiXQueryVersion(client);
+ case X_PanoramiXGetState:
+ return SProcPanoramiXGetState(client);
+ case X_PanoramiXGetScreenCount:
+ return SProcPanoramiXGetScreenCount(client);
+ case X_PanoramiXGetScreenSize:
+ return SProcPanoramiXGetScreenSize(client);
+ case X_XineramaIsActive:
+ return SProcXineramaIsActive(client);
+ case X_XineramaQueryScreens:
+ return SProcXineramaQueryScreens(client);
+ }
+ return BadRequest;
+}
diff --git a/nx-X11/programs/Xserver/Xext/panoramiXh.h b/nx-X11/programs/Xserver/Xext/panoramiXh.h
new file mode 100644
index 000000000..9da5876fd
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/panoramiXh.h
@@ -0,0 +1,78 @@
+/* $XFree86: xc/programs/Xserver/Xext/panoramiXh.h,v 1.2 2003/09/13 21:33:03 dawes Exp $ */
+
+/*
+ * Server dispatcher function replacements
+ */
+
+extern int PanoramiXCreateWindow(ClientPtr client);
+extern int PanoramiXChangeWindowAttributes(ClientPtr client);
+extern int PanoramiXDestroyWindow(ClientPtr client);
+extern int PanoramiXDestroySubwindows(ClientPtr client);
+extern int PanoramiXChangeSaveSet(ClientPtr client);
+extern int PanoramiXReparentWindow(ClientPtr client);
+extern int PanoramiXMapWindow(ClientPtr client);
+extern int PanoramiXMapSubwindows(ClientPtr client);
+extern int PanoramiXUnmapWindow(ClientPtr client);
+extern int PanoramiXUnmapSubwindows(ClientPtr client);
+extern int PanoramiXConfigureWindow(ClientPtr client);
+extern int PanoramiXCirculateWindow(ClientPtr client);
+extern int PanoramiXGetGeometry(ClientPtr client);
+extern int PanoramiXTranslateCoords(ClientPtr client);
+extern int PanoramiXCreatePixmap(ClientPtr client);
+extern int PanoramiXFreePixmap(ClientPtr client);
+extern int PanoramiXCreateGC(ClientPtr client);
+extern int PanoramiXChangeGC(ClientPtr client);
+extern int PanoramiXCopyGC(ClientPtr client);
+extern int PanoramiXCopyColormapAndFree(ClientPtr client);
+extern int PanoramiXSetDashes(ClientPtr client);
+extern int PanoramiXSetClipRectangles(ClientPtr client);
+extern int PanoramiXFreeGC(ClientPtr client);
+extern int PanoramiXClearToBackground(ClientPtr client);
+extern int PanoramiXCopyArea(ClientPtr client);
+extern int PanoramiXCopyPlane(ClientPtr client);
+extern int PanoramiXPolyPoint(ClientPtr client);
+extern int PanoramiXPolyLine(ClientPtr client);
+extern int PanoramiXPolySegment(ClientPtr client);
+extern int PanoramiXPolyRectangle(ClientPtr client);
+extern int PanoramiXPolyArc(ClientPtr client);
+extern int PanoramiXFillPoly(ClientPtr client);
+extern int PanoramiXPolyFillArc(ClientPtr client);
+extern int PanoramiXPolyFillRectangle(ClientPtr client);
+extern int PanoramiXPutImage(ClientPtr client);
+extern int PanoramiXGetImage(ClientPtr client);
+extern int PanoramiXPolyText8(ClientPtr client);
+extern int PanoramiXPolyText16(ClientPtr client);
+extern int PanoramiXImageText8(ClientPtr client);
+extern int PanoramiXImageText16(ClientPtr client);
+extern int PanoramiXCreateColormap(ClientPtr client);
+extern int PanoramiXFreeColormap(ClientPtr client);
+extern int PanoramiXInstallColormap(ClientPtr client);
+extern int PanoramiXUninstallColormap(ClientPtr client);
+extern int PanoramiXAllocColor(ClientPtr client);
+extern int PanoramiXAllocNamedColor(ClientPtr client);
+extern int PanoramiXAllocColorCells(ClientPtr client);
+extern int PanoramiXStoreNamedColor(ClientPtr client);
+extern int PanoramiXFreeColors(ClientPtr client);
+extern int PanoramiXStoreColors(ClientPtr client);
+extern int PanoramiXAllocColorPlanes(ClientPtr client);
+
+#define PROC_EXTERN(pfunc) extern int pfunc(ClientPtr)
+
+PROC_EXTERN(ProcPanoramiXQueryVersion);
+PROC_EXTERN(ProcPanoramiXGetState);
+PROC_EXTERN(ProcPanoramiXGetScreenCount);
+PROC_EXTERN(ProcPanoramiXGetScreenSize);
+
+PROC_EXTERN(ProcXineramaQueryScreens);
+PROC_EXTERN(ProcXineramaIsActive);
+extern Bool XineramaCreateGC(GCPtr pGC);
+
+extern int SProcPanoramiXDispatch(ClientPtr client);
+
+extern char *ConnectionInfo;
+extern int connBlockScreenStart;
+extern xConnSetupPrefix connSetupPrefix;
+
+extern ScreenInfo *GlobalScrInfo;
+extern int (* SavedProcVector[256]) (ClientPtr client);
+
diff --git a/nx-X11/programs/Xserver/Xext/panoramiXprocs.c b/nx-X11/programs/Xserver/Xext/panoramiXprocs.c
new file mode 100644
index 000000000..79a5a3290
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/panoramiXprocs.c
@@ -0,0 +1,2372 @@
+/* $Xorg: panoramiXprocs.c,v 1.5 2000/08/17 19:47:57 cpqbld Exp $ */
+/*****************************************************************
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+******************************************************************/
+
+/* Massively rewritten by Mark Vojkovich <markv@valinux.com> */
+
+/* $XFree86: xc/programs/Xserver/Xext/panoramiXprocs.c,v 3.36tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <X11/X.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include "windowstr.h"
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "colormapst.h"
+#include "scrnintstr.h"
+#include "opaque.h"
+#include "inputstr.h"
+#include "migc.h"
+#include "misc.h"
+#include "dixstruct.h"
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#include "resource.h"
+#include "panoramiXh.h"
+
+#define XINERAMA_IMAGE_BUFSIZE (256*1024)
+#define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \
+ CWDontPropagate | CWOverrideRedirect | CWCursor )
+
+#if 0
+extern void (* EventSwapVector[128]) (fsError *, fsError *);
+
+extern void Swap32Write();
+extern void SLHostsExtend();
+extern void SQColorsExtend();
+WriteSConnectionInfo();
+extern void WriteSConnSetupPrefix();
+#endif
+
+/* Various of the DIX function interfaces were not designed to allow
+ * the client->errorValue to be set on BadValue and other errors.
+ * Rather than changing interfaces and breaking untold code we introduce
+ * a new global that dispatch can use.
+ */
+extern XID clientErrorValue; /* XXX this is a kludge */
+
+int PanoramiXCreateWindow(ClientPtr client)
+{
+ PanoramiXRes *parent, *newWin;
+ PanoramiXRes *backPix = NULL;
+ PanoramiXRes *bordPix = NULL;
+ PanoramiXRes *cmap = NULL;
+ REQUEST(xCreateWindowReq);
+ int pback_offset = 0, pbord_offset = 0, cmap_offset = 0;
+ int result = 0, len, j;
+ int orig_x, orig_y;
+ XID orig_visual, tmp;
+ Bool parentIsRoot;
+
+ REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
+
+ len = client->req_len - (sizeof(xCreateWindowReq) >> 2);
+ if (Ones(stuff->mask) != len)
+ return BadLength;
+
+ if (!(parent = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->parent, XRT_WINDOW, SecurityWriteAccess)))
+ return BadWindow;
+
+ if(stuff->class == CopyFromParent)
+ stuff->class = parent->u.win.class;
+
+ if((stuff->class == InputOnly) && (stuff->mask & (~INPUTONLY_LEGAL_MASK)))
+ return BadMatch;
+
+ if ((Mask)stuff->mask & CWBackPixmap) {
+ pback_offset = Ones((Mask)stuff->mask & (CWBackPixmap - 1));
+ tmp = *((CARD32 *) &stuff[1] + pback_offset);
+ if ((tmp != None) && (tmp != ParentRelative)) {
+ if(!(backPix = (PanoramiXRes*) SecurityLookupIDByType(
+ client, tmp, XRT_PIXMAP, SecurityReadAccess)))
+ return BadPixmap;
+ }
+ }
+ if ((Mask)stuff->mask & CWBorderPixmap) {
+ pbord_offset = Ones((Mask)stuff->mask & (CWBorderPixmap - 1));
+ tmp = *((CARD32 *) &stuff[1] + pbord_offset);
+ if (tmp != CopyFromParent) {
+ if(!(bordPix = (PanoramiXRes*) SecurityLookupIDByType(
+ client, tmp, XRT_PIXMAP, SecurityReadAccess)))
+ return BadPixmap;
+ }
+ }
+ if ((Mask)stuff->mask & CWColormap) {
+ cmap_offset = Ones((Mask)stuff->mask & (CWColormap - 1));
+ tmp = *((CARD32 *) &stuff[1] + cmap_offset);
+ if ((tmp != CopyFromParent) && (tmp != None)) {
+ if(!(cmap = (PanoramiXRes*) SecurityLookupIDByType(
+ client, tmp, XRT_COLORMAP, SecurityReadAccess)))
+ return BadColor;
+ }
+ }
+
+ if(!(newWin = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
+ return BadAlloc;
+
+ newWin->type = XRT_WINDOW;
+ newWin->u.win.visibility = VisibilityNotViewable;
+ newWin->u.win.class = stuff->class;
+ newWin->u.win.root = FALSE;
+ newWin->info[0].id = stuff->wid;
+ for(j = 1; j < PanoramiXNumScreens; j++)
+ newWin->info[j].id = FakeClientID(client->index);
+
+ if (stuff->class == InputOnly)
+ stuff->visual = CopyFromParent;
+ orig_visual = stuff->visual;
+ orig_x = stuff->x;
+ orig_y = stuff->y;
+ parentIsRoot = (stuff->parent == WindowTable[0]->drawable.id) ||
+ (stuff->parent == savedScreenInfo[0].wid);
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->wid = newWin->info[j].id;
+ stuff->parent = parent->info[j].id;
+ if (parentIsRoot) {
+ stuff->x = orig_x - panoramiXdataPtr[j].x;
+ stuff->y = orig_y - panoramiXdataPtr[j].y;
+ }
+ if (backPix)
+ *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id;
+ if (bordPix)
+ *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[j].id;
+ if (cmap)
+ *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[j].id;
+ if ( orig_visual != CopyFromParent )
+ stuff->visual = PanoramiXVisualTable[(orig_visual*MAXSCREENS) + j];
+ result = (*SavedProcVector[X_CreateWindow])(client);
+ if(result != Success) break;
+ }
+
+ if (result == Success)
+ AddResource(newWin->info[0].id, XRT_WINDOW, newWin);
+ else
+ xfree(newWin);
+
+ return (result);
+}
+
+
+int PanoramiXChangeWindowAttributes(ClientPtr client)
+{
+ PanoramiXRes *win;
+ PanoramiXRes *backPix = NULL;
+ PanoramiXRes *bordPix = NULL;
+ PanoramiXRes *cmap = NULL;
+ REQUEST(xChangeWindowAttributesReq);
+ int pback_offset = 0, pbord_offset = 0, cmap_offset = 0;
+ int result = 0, len, j;
+ XID tmp;
+
+ REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
+
+ len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2);
+ if (Ones(stuff->valueMask) != len)
+ return BadLength;
+
+ if (!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->window, XRT_WINDOW, SecurityWriteAccess)))
+ return BadWindow;
+
+ if((win->u.win.class == InputOnly) &&
+ (stuff->valueMask & (~INPUTONLY_LEGAL_MASK)))
+ return BadMatch;
+
+ if ((Mask)stuff->valueMask & CWBackPixmap) {
+ pback_offset = Ones((Mask)stuff->valueMask & (CWBackPixmap - 1));
+ tmp = *((CARD32 *) &stuff[1] + pback_offset);
+ if ((tmp != None) && (tmp != ParentRelative)) {
+ if(!(backPix = (PanoramiXRes*) SecurityLookupIDByType(
+ client, tmp, XRT_PIXMAP, SecurityReadAccess)))
+ return BadPixmap;
+ }
+ }
+ if ((Mask)stuff->valueMask & CWBorderPixmap) {
+ pbord_offset = Ones((Mask)stuff->valueMask & (CWBorderPixmap - 1));
+ tmp = *((CARD32 *) &stuff[1] + pbord_offset);
+ if (tmp != CopyFromParent) {
+ if(!(bordPix = (PanoramiXRes*) SecurityLookupIDByType(
+ client, tmp, XRT_PIXMAP, SecurityReadAccess)))
+ return BadPixmap;
+ }
+ }
+ if ((Mask)stuff->valueMask & CWColormap) {
+ cmap_offset = Ones((Mask)stuff->valueMask & (CWColormap - 1));
+ tmp = *((CARD32 *) &stuff[1] + cmap_offset);
+ if ((tmp != CopyFromParent) && (tmp != None)) {
+ if(!(cmap = (PanoramiXRes*) SecurityLookupIDByType(
+ client, tmp, XRT_COLORMAP, SecurityReadAccess)))
+ return BadColor;
+ }
+ }
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->window = win->info[j].id;
+ if (backPix)
+ *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id;
+ if (bordPix)
+ *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[j].id;
+ if (cmap)
+ *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[j].id;
+ result = (*SavedProcVector[X_ChangeWindowAttributes])(client);
+ }
+
+ return (result);
+}
+
+
+int PanoramiXDestroyWindow(ClientPtr client)
+{
+ PanoramiXRes *win;
+ int result = 0, j;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+
+ if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->id, XRT_WINDOW, SecurityDestroyAccess)))
+ return BadWindow;
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->id = win->info[j].id;
+ result = (*SavedProcVector[X_DestroyWindow])(client);
+ if(result != Success) break;
+ }
+
+ /* Since ProcDestroyWindow is using FreeResource, it will free
+ our resource for us on the last pass through the loop above */
+
+ return (result);
+}
+
+
+int PanoramiXDestroySubwindows(ClientPtr client)
+{
+ PanoramiXRes *win;
+ int result = 0, j;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+
+ if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->id, XRT_WINDOW, SecurityDestroyAccess)))
+ return BadWindow;
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->id = win->info[j].id;
+ result = (*SavedProcVector[X_DestroySubwindows])(client);
+ if(result != Success) break;
+ }
+
+ /* DestroySubwindows is using FreeResource which will free
+ our resources for us on the last pass through the loop above */
+
+ return (result);
+}
+
+
+int PanoramiXChangeSaveSet(ClientPtr client)
+{
+ PanoramiXRes *win;
+ int result = 0, j;
+ REQUEST(xChangeSaveSetReq);
+
+ REQUEST_SIZE_MATCH(xChangeSaveSetReq);
+
+ if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->window, XRT_WINDOW, SecurityReadAccess)))
+ return BadWindow;
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->window = win->info[j].id;
+ result = (*SavedProcVector[X_ChangeSaveSet])(client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+
+int PanoramiXReparentWindow(ClientPtr client)
+{
+ PanoramiXRes *win, *parent;
+ int result = 0, j;
+ int x, y;
+ Bool parentIsRoot;
+ REQUEST(xReparentWindowReq);
+
+ REQUEST_SIZE_MATCH(xReparentWindowReq);
+
+ if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->window, XRT_WINDOW, SecurityWriteAccess)))
+ return BadWindow;
+
+ if(!(parent = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->parent, XRT_WINDOW, SecurityWriteAccess)))
+ return BadWindow;
+
+ x = stuff->x;
+ y = stuff->y;
+ parentIsRoot = (stuff->parent == WindowTable[0]->drawable.id) ||
+ (stuff->parent == savedScreenInfo[0].wid);
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->window = win->info[j].id;
+ stuff->parent = parent->info[j].id;
+ if(parentIsRoot) {
+ stuff->x = x - panoramiXdataPtr[j].x;
+ stuff->y = y - panoramiXdataPtr[j].y;
+ }
+ result = (*SavedProcVector[X_ReparentWindow])(client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+
+int PanoramiXMapWindow(ClientPtr client)
+{
+ PanoramiXRes *win;
+ int result = 0, j;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+
+ if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->id, XRT_WINDOW, SecurityReadAccess)))
+ return BadWindow;
+
+ FOR_NSCREENS_FORWARD(j) {
+ stuff->id = win->info[j].id;
+ result = (*SavedProcVector[X_MapWindow])(client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+
+int PanoramiXMapSubwindows(ClientPtr client)
+{
+ PanoramiXRes *win;
+ int result = 0, j;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+
+ if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->id, XRT_WINDOW, SecurityReadAccess)))
+ return BadWindow;
+
+ FOR_NSCREENS_FORWARD(j) {
+ stuff->id = win->info[j].id;
+ result = (*SavedProcVector[X_MapSubwindows])(client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+
+int PanoramiXUnmapWindow(ClientPtr client)
+{
+ PanoramiXRes *win;
+ int result = 0, j;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+
+ if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->id, XRT_WINDOW, SecurityReadAccess)))
+ return BadWindow;
+
+ FOR_NSCREENS_FORWARD(j) {
+ stuff->id = win->info[j].id;
+ result = (*SavedProcVector[X_UnmapWindow])(client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+
+int PanoramiXUnmapSubwindows(ClientPtr client)
+{
+ PanoramiXRes *win;
+ int result = 0, j;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+
+ if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->id, XRT_WINDOW, SecurityReadAccess)))
+ return BadWindow;
+
+ FOR_NSCREENS_FORWARD(j) {
+ stuff->id = win->info[j].id;
+ result = (*SavedProcVector[X_UnmapSubwindows])(client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+
+int PanoramiXConfigureWindow(ClientPtr client)
+{
+ PanoramiXRes *win;
+ PanoramiXRes *sib = NULL;
+ WindowPtr pWin;
+ int result = 0, j, len, sib_offset = 0, x = 0, y = 0;
+ int x_offset = -1;
+ int y_offset = -1;
+ REQUEST(xConfigureWindowReq);
+
+ REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
+
+ len = client->req_len - (sizeof(xConfigureWindowReq) >> 2);
+ if (Ones(stuff->mask) != len)
+ return BadLength;
+
+ /* because we need the parent */
+ if (!(pWin = (WindowPtr)SecurityLookupIDByType(
+ client, stuff->window, RT_WINDOW, SecurityWriteAccess)))
+ return BadWindow;
+
+ if (!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->window, XRT_WINDOW, SecurityWriteAccess)))
+ return BadWindow;
+
+ if ((Mask)stuff->mask & CWSibling) {
+ XID tmp;
+ sib_offset = Ones((Mask)stuff->mask & (CWSibling - 1));
+ if ((tmp = *((CARD32 *) &stuff[1] + sib_offset))) {
+ if(!(sib = (PanoramiXRes*) SecurityLookupIDByType(
+ client, tmp, XRT_WINDOW, SecurityReadAccess)))
+ return BadWindow;
+ }
+ }
+
+ if(pWin->parent && ((pWin->parent == WindowTable[0]) ||
+ (pWin->parent->drawable.id == savedScreenInfo[0].wid)))
+ {
+ if ((Mask)stuff->mask & CWX) {
+ x_offset = 0;
+ x = *((CARD32 *)&stuff[1]);
+ }
+ if ((Mask)stuff->mask & CWY) {
+ y_offset = (x_offset == -1) ? 0 : 1;
+ y = *((CARD32 *) &stuff[1] + y_offset);
+ }
+ }
+
+ /* have to go forward or you get expose events before
+ ConfigureNotify events */
+ FOR_NSCREENS_FORWARD(j) {
+ stuff->window = win->info[j].id;
+ if(sib)
+ *((CARD32 *) &stuff[1] + sib_offset) = sib->info[j].id;
+ if(x_offset >= 0)
+ *((CARD32 *) &stuff[1] + x_offset) = x - panoramiXdataPtr[j].x;
+ if(y_offset >= 0)
+ *((CARD32 *) &stuff[1] + y_offset) = y - panoramiXdataPtr[j].y;
+ result = (*SavedProcVector[X_ConfigureWindow])(client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+
+int PanoramiXCirculateWindow(ClientPtr client)
+{
+ PanoramiXRes *win;
+ int result = 0, j;
+ REQUEST(xCirculateWindowReq);
+
+ REQUEST_SIZE_MATCH(xCirculateWindowReq);
+
+ if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->window, XRT_WINDOW, SecurityWriteAccess)))
+ return BadWindow;
+
+ FOR_NSCREENS_FORWARD(j) {
+ stuff->window = win->info[j].id;
+ result = (*SavedProcVector[X_CirculateWindow])(client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+
+int PanoramiXGetGeometry(ClientPtr client)
+{
+ xGetGeometryReply rep;
+ DrawablePtr pDraw;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ VERIFY_GEOMETRABLE (pDraw, stuff->id, client);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.root = WindowTable[0]->drawable.id;
+ rep.depth = pDraw->depth;
+ rep.width = pDraw->width;
+ rep.height = pDraw->height;
+ rep.x = rep.y = rep.borderWidth = 0;
+
+ if (stuff->id == rep.root) {
+ xWindowRoot *root = (xWindowRoot *)
+ (ConnectionInfo + connBlockScreenStart);
+
+ rep.width = root->pixWidth;
+ rep.height = root->pixHeight;
+ } else
+ if ((pDraw->type == UNDRAWABLE_WINDOW) || (pDraw->type == DRAWABLE_WINDOW))
+ {
+ WindowPtr pWin = (WindowPtr)pDraw;
+ rep.x = pWin->origin.x - wBorderWidth (pWin);
+ rep.y = pWin->origin.y - wBorderWidth (pWin);
+ if((pWin->parent == WindowTable[0]) ||
+ (pWin->parent->drawable.id == savedScreenInfo[0].wid))
+ {
+ rep.x += panoramiXdataPtr[0].x;
+ rep.y += panoramiXdataPtr[0].y;
+ }
+ rep.borderWidth = pWin->borderWidth;
+ }
+
+ WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep);
+ return (client->noClientException);
+}
+
+int PanoramiXTranslateCoords(ClientPtr client)
+{
+ INT16 x, y;
+ REQUEST(xTranslateCoordsReq);
+
+ register WindowPtr pWin, pDst;
+ xTranslateCoordsReply rep;
+
+ REQUEST_SIZE_MATCH(xTranslateCoordsReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->srcWid, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ pDst = (WindowPtr)SecurityLookupWindow(stuff->dstWid, client,
+ SecurityReadAccess);
+ if (!pDst)
+ return(BadWindow);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.sameScreen = xTrue;
+ rep.child = None;
+
+ if((pWin == WindowTable[0]) ||
+ (pWin->drawable.id == savedScreenInfo[0].wid))
+ {
+ x = stuff->srcX - panoramiXdataPtr[0].x;
+ y = stuff->srcY - panoramiXdataPtr[0].y;
+ } else {
+ x = pWin->drawable.x + stuff->srcX;
+ y = pWin->drawable.y + stuff->srcY;
+ }
+ pWin = pDst->firstChild;
+ while (pWin) {
+#ifdef SHAPE
+ BoxRec box;
+#endif
+ if ((pWin->mapped) &&
+ (x >= pWin->drawable.x - wBorderWidth (pWin)) &&
+ (x < pWin->drawable.x + (int)pWin->drawable.width +
+ wBorderWidth (pWin)) &&
+ (y >= pWin->drawable.y - wBorderWidth (pWin)) &&
+ (y < pWin->drawable.y + (int)pWin->drawable.height +
+ wBorderWidth (pWin))
+#ifdef SHAPE
+ /* When a window is shaped, a further check
+ * is made to see if the point is inside
+ * borderSize
+ */
+ && (!wBoundingShape(pWin) ||
+ POINT_IN_REGION(pWin->drawable.pScreen,
+ wBoundingShape(pWin),
+ x - pWin->drawable.x,
+ y - pWin->drawable.y, &box))
+#endif
+ )
+ {
+ rep.child = pWin->drawable.id;
+ pWin = (WindowPtr) NULL;
+ }
+ else
+ pWin = pWin->nextSib;
+ }
+ rep.dstX = x - pDst->drawable.x;
+ rep.dstY = y - pDst->drawable.y;
+ if((pDst == WindowTable[0]) ||
+ (pDst->drawable.id == savedScreenInfo[0].wid))
+ {
+ rep.dstX += panoramiXdataPtr[0].x;
+ rep.dstY += panoramiXdataPtr[0].y;
+ }
+
+ WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep);
+ return(client->noClientException);
+}
+
+int PanoramiXCreatePixmap(ClientPtr client)
+{
+ PanoramiXRes *refDraw, *newPix;
+ int result = 0, j;
+ REQUEST(xCreatePixmapReq);
+
+ REQUEST_SIZE_MATCH(xCreatePixmapReq);
+ client->errorValue = stuff->pid;
+
+ if(!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityReadAccess)))
+ return BadDrawable;
+
+ if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
+ return BadAlloc;
+
+ newPix->type = XRT_PIXMAP;
+ newPix->u.pix.shared = FALSE;
+ newPix->info[0].id = stuff->pid;
+ for(j = 1; j < PanoramiXNumScreens; j++)
+ newPix->info[j].id = FakeClientID(client->index);
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->pid = newPix->info[j].id;
+ stuff->drawable = refDraw->info[j].id;
+ result = (*SavedProcVector[X_CreatePixmap])(client);
+ if(result != Success) break;
+ }
+
+ if (result == Success)
+ AddResource(newPix->info[0].id, XRT_PIXMAP, newPix);
+ else
+ xfree(newPix);
+
+ return (result);
+}
+
+
+int PanoramiXFreePixmap(ClientPtr client)
+{
+ PanoramiXRes *pix;
+ int result = 0, j;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+
+ client->errorValue = stuff->id;
+
+ if(!(pix = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->id, XRT_PIXMAP, SecurityDestroyAccess)))
+ return BadPixmap;
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->id = pix->info[j].id;
+ result = (*SavedProcVector[X_FreePixmap])(client);
+ if(result != Success) break;
+ }
+
+ /* Since ProcFreePixmap is using FreeResource, it will free
+ our resource for us on the last pass through the loop above */
+
+ return (result);
+}
+
+
+int PanoramiXCreateGC(ClientPtr client)
+{
+ PanoramiXRes *refDraw;
+ PanoramiXRes *newGC;
+ PanoramiXRes *stip = NULL;
+ PanoramiXRes *tile = NULL;
+ PanoramiXRes *clip = NULL;
+ REQUEST(xCreateGCReq);
+ int tile_offset = 0, stip_offset = 0, clip_offset = 0;
+ int result = 0, len, j;
+ XID tmp;
+
+ REQUEST_AT_LEAST_SIZE(xCreateGCReq);
+
+ client->errorValue = stuff->gc;
+ len = client->req_len - (sizeof(xCreateGCReq) >> 2);
+ if (Ones(stuff->mask) != len)
+ return BadLength;
+
+ if (!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityReadAccess)))
+ return BadDrawable;
+
+ if ((Mask)stuff->mask & GCTile) {
+ tile_offset = Ones((Mask)stuff->mask & (GCTile - 1));
+ if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) {
+ if(!(tile = (PanoramiXRes*) SecurityLookupIDByType(
+ client, tmp, XRT_PIXMAP, SecurityReadAccess)))
+ return BadPixmap;
+ }
+ }
+ if ((Mask)stuff->mask & GCStipple) {
+ stip_offset = Ones((Mask)stuff->mask & (GCStipple - 1));
+ if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) {
+ if(!(stip = (PanoramiXRes*) SecurityLookupIDByType(
+ client, tmp, XRT_PIXMAP, SecurityReadAccess)))
+ return BadPixmap;
+ }
+ }
+ if ((Mask)stuff->mask & GCClipMask) {
+ clip_offset = Ones((Mask)stuff->mask & (GCClipMask - 1));
+ if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) {
+ if(!(clip = (PanoramiXRes*) SecurityLookupIDByType(
+ client, tmp, XRT_PIXMAP, SecurityReadAccess)))
+ return BadPixmap;
+ }
+ }
+
+ if(!(newGC = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
+ return BadAlloc;
+
+ newGC->type = XRT_GC;
+ newGC->info[0].id = stuff->gc;
+ for(j = 1; j < PanoramiXNumScreens; j++)
+ newGC->info[j].id = FakeClientID(client->index);
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->gc = newGC->info[j].id;
+ stuff->drawable = refDraw->info[j].id;
+ if (tile)
+ *((CARD32 *) &stuff[1] + tile_offset) = tile->info[j].id;
+ if (stip)
+ *((CARD32 *) &stuff[1] + stip_offset) = stip->info[j].id;
+ if (clip)
+ *((CARD32 *) &stuff[1] + clip_offset) = clip->info[j].id;
+ result = (*SavedProcVector[X_CreateGC])(client);
+ if(result != Success) break;
+ }
+
+ if (result == Success)
+ AddResource(newGC->info[0].id, XRT_GC, newGC);
+ else
+ xfree(newGC);
+
+ return (result);
+}
+
+int PanoramiXChangeGC(ClientPtr client)
+{
+ PanoramiXRes *gc;
+ PanoramiXRes *stip = NULL;
+ PanoramiXRes *tile = NULL;
+ PanoramiXRes *clip = NULL;
+ REQUEST(xChangeGCReq);
+ int tile_offset = 0, stip_offset = 0, clip_offset = 0;
+ int result = 0, len, j;
+ XID tmp;
+
+ REQUEST_AT_LEAST_SIZE(xChangeGCReq);
+
+ len = client->req_len - (sizeof(xChangeGCReq) >> 2);
+ if (Ones(stuff->mask) != len)
+ return BadLength;
+
+ if (!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ if ((Mask)stuff->mask & GCTile) {
+ tile_offset = Ones((Mask)stuff->mask & (GCTile - 1));
+ if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) {
+ if(!(tile = (PanoramiXRes*) SecurityLookupIDByType(
+ client, tmp, XRT_PIXMAP, SecurityReadAccess)))
+ return BadPixmap;
+ }
+ }
+ if ((Mask)stuff->mask & GCStipple) {
+ stip_offset = Ones((Mask)stuff->mask & (GCStipple - 1));
+ if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) {
+ if(!(stip = (PanoramiXRes*) SecurityLookupIDByType(
+ client, tmp, XRT_PIXMAP, SecurityReadAccess)))
+ return BadPixmap;
+ }
+ }
+ if ((Mask)stuff->mask & GCClipMask) {
+ clip_offset = Ones((Mask)stuff->mask & (GCClipMask - 1));
+ if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) {
+ if(!(clip = (PanoramiXRes*) SecurityLookupIDByType(
+ client, tmp, XRT_PIXMAP, SecurityReadAccess)))
+ return BadPixmap;
+ }
+ }
+
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->gc = gc->info[j].id;
+ if (tile)
+ *((CARD32 *) &stuff[1] + tile_offset) = tile->info[j].id;
+ if (stip)
+ *((CARD32 *) &stuff[1] + stip_offset) = stip->info[j].id;
+ if (clip)
+ *((CARD32 *) &stuff[1] + clip_offset) = clip->info[j].id;
+ result = (*SavedProcVector[X_ChangeGC])(client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+
+int PanoramiXCopyGC(ClientPtr client)
+{
+ PanoramiXRes *srcGC, *dstGC;
+ int result = 0, j;
+ REQUEST(xCopyGCReq);
+
+ REQUEST_SIZE_MATCH(xCopyGCReq);
+
+ if(!(srcGC = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->srcGC, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ if(!(dstGC = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->dstGC, XRT_GC, SecurityWriteAccess)))
+ return BadGC;
+
+ FOR_NSCREENS(j) {
+ stuff->srcGC = srcGC->info[j].id;
+ stuff->dstGC = dstGC->info[j].id;
+ result = (*SavedProcVector[X_CopyGC])(client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+
+int PanoramiXSetDashes(ClientPtr client)
+{
+ PanoramiXRes *gc;
+ int result = 0, j;
+ REQUEST(xSetDashesReq);
+
+ REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityWriteAccess)))
+ return BadGC;
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->gc = gc->info[j].id;
+ result = (*SavedProcVector[X_SetDashes])(client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+
+int PanoramiXSetClipRectangles(ClientPtr client)
+{
+ PanoramiXRes *gc;
+ int result = 0, j;
+ REQUEST(xSetClipRectanglesReq);
+
+ REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityWriteAccess)))
+ return BadGC;
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->gc = gc->info[j].id;
+ result = (*SavedProcVector[X_SetClipRectangles])(client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+
+int PanoramiXFreeGC(ClientPtr client)
+{
+ PanoramiXRes *gc;
+ int result = 0, j;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->id, XRT_GC, SecurityDestroyAccess)))
+ return BadGC;
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->id = gc->info[j].id;
+ result = (*SavedProcVector[X_FreeGC])(client);
+ if(result != Success) break;
+ }
+
+ /* Since ProcFreeGC is using FreeResource, it will free
+ our resource for us on the last pass through the loop above */
+
+ return (result);
+}
+
+
+int PanoramiXClearToBackground(ClientPtr client)
+{
+ PanoramiXRes *win;
+ int result = 0, j, x, y;
+ Bool isRoot;
+ REQUEST(xClearAreaReq);
+
+ REQUEST_SIZE_MATCH(xClearAreaReq);
+
+ if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->window, XRT_WINDOW, SecurityWriteAccess)))
+ return BadWindow;
+
+ x = stuff->x;
+ y = stuff->y;
+ isRoot = win->u.win.root;
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->window = win->info[j].id;
+ if(isRoot) {
+ stuff->x = x - panoramiXdataPtr[j].x;
+ stuff->y = y - panoramiXdataPtr[j].y;
+ }
+ result = (*SavedProcVector[X_ClearArea])(client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+
+/*
+ For Window to Pixmap copies you're screwed since each screen's
+ pixmap will look like what it sees on its screen. Unless the
+ screens overlap and the window lies on each, the two copies
+ will be out of sync. To remedy this we do a GetImage and PutImage
+ in place of the copy. Doing this as a single Image isn't quite
+ correct since it will include the obscured areas but we will
+ have to fix this later. (MArk).
+*/
+
+int PanoramiXCopyArea(ClientPtr client)
+{
+ int j, result = 0, srcx, srcy, dstx, dsty;
+ PanoramiXRes *gc, *src, *dst;
+ Bool srcIsRoot = FALSE;
+ Bool dstIsRoot = FALSE;
+ Bool srcShared, dstShared;
+ REQUEST(xCopyAreaReq);
+
+ REQUEST_SIZE_MATCH(xCopyAreaReq);
+
+ if(!(src = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->srcDrawable, XRC_DRAWABLE, SecurityReadAccess)))
+ return BadDrawable;
+
+ srcShared = IS_SHARED_PIXMAP(src);
+
+ if(!(dst = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->dstDrawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ dstShared = IS_SHARED_PIXMAP(dst);
+
+ if(dstShared && srcShared)
+ return (* SavedProcVector[X_CopyArea])(client);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ if((dst->type == XRT_WINDOW) && dst->u.win.root)
+ dstIsRoot = TRUE;
+ if((src->type == XRT_WINDOW) && src->u.win.root)
+ srcIsRoot = TRUE;
+
+ srcx = stuff->srcX; srcy = stuff->srcY;
+ dstx = stuff->dstX; dsty = stuff->dstY;
+ if((dst->type == XRT_PIXMAP) && (src->type == XRT_WINDOW)) {
+ DrawablePtr drawables[MAXSCREENS];
+ DrawablePtr pDst;
+ GCPtr pGC;
+ char *data;
+ int pitch;
+
+ FOR_NSCREENS(j)
+ VERIFY_DRAWABLE(drawables[j], src->info[j].id, client);
+
+ pitch = PixmapBytePad(stuff->width, drawables[0]->depth);
+ if(!(data = xcalloc(1, stuff->height * pitch)))
+ return BadAlloc;
+
+ XineramaGetImageData(drawables, srcx, srcy,
+ stuff->width, stuff->height, ZPixmap, ~0, data, pitch,
+ srcIsRoot);
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->gc = gc->info[j].id;
+ VALIDATE_DRAWABLE_AND_GC(dst->info[j].id, pDst, pGC, client);
+
+ if(drawables[0]->depth != pDst->depth) {
+ client->errorValue = stuff->dstDrawable;
+ xfree(data);
+ return (BadMatch);
+ }
+
+ (*pGC->ops->PutImage) (pDst, pGC, pDst->depth, dstx, dsty,
+ stuff->width, stuff->height,
+ 0, ZPixmap, data);
+
+ if(dstShared) break;
+ }
+
+ xfree(data);
+
+ result = Success;
+ } else {
+ DrawablePtr pDst = NULL, pSrc = NULL;
+ GCPtr pGC = NULL;
+ RegionPtr pRgn[MAXSCREENS];
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->dstDrawable = dst->info[j].id;
+ stuff->srcDrawable = src->info[j].id;
+ stuff->gc = gc->info[j].id;
+ if (srcIsRoot) {
+ stuff->srcX = srcx - panoramiXdataPtr[j].x;
+ stuff->srcY = srcy - panoramiXdataPtr[j].y;
+ }
+ if (dstIsRoot) {
+ stuff->dstX = dstx - panoramiXdataPtr[j].x;
+ stuff->dstY = dsty - panoramiXdataPtr[j].y;
+ }
+
+ VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client);
+ if (stuff->dstDrawable != stuff->srcDrawable) {
+ SECURITY_VERIFY_DRAWABLE(pSrc, stuff->srcDrawable, client,
+ SecurityReadAccess);
+ if ((pDst->pScreen != pSrc->pScreen) ||
+ (pDst->depth != pSrc->depth)) {
+ client->errorValue = stuff->dstDrawable;
+ return (BadMatch);
+ }
+ } else
+ pSrc = pDst;
+
+ pRgn[j] = (*pGC->ops->CopyArea)(pSrc, pDst, pGC,
+ stuff->srcX, stuff->srcY,
+ stuff->width, stuff->height,
+ stuff->dstX, stuff->dstY);
+
+ if(dstShared) {
+ while(j--) pRgn[j] = NULL;
+ break;
+ }
+ }
+
+ if(pGC->graphicsExposures) {
+ ScreenPtr pScreen = pDst->pScreen;
+ RegionRec totalReg;
+ Bool overlap;
+
+ REGION_NULL(pScreen, &totalReg);
+ FOR_NSCREENS_BACKWARD(j) {
+ if(pRgn[j]) {
+ if(srcIsRoot) {
+ REGION_TRANSLATE(pScreen, pRgn[j],
+ panoramiXdataPtr[j].x, panoramiXdataPtr[j].y);
+ }
+ REGION_APPEND(pScreen, &totalReg, pRgn[j]);
+ REGION_DESTROY(pScreen, pRgn[j]);
+ }
+ }
+ REGION_VALIDATE(pScreen, &totalReg, &overlap);
+ (*pScreen->SendGraphicsExpose)(
+ client, &totalReg, stuff->dstDrawable, X_CopyArea, 0);
+ REGION_UNINIT(pScreen, &totalReg);
+ }
+
+ result = client->noClientException;
+ }
+
+ return (result);
+}
+
+
+int PanoramiXCopyPlane(ClientPtr client)
+{
+ int j, srcx, srcy, dstx, dsty;
+ PanoramiXRes *gc, *src, *dst;
+ Bool srcIsRoot = FALSE;
+ Bool dstIsRoot = FALSE;
+ Bool srcShared, dstShared;
+ DrawablePtr psrcDraw, pdstDraw = NULL;
+ GCPtr pGC = NULL;
+ RegionPtr pRgn[MAXSCREENS];
+ REQUEST(xCopyPlaneReq);
+
+ REQUEST_SIZE_MATCH(xCopyPlaneReq);
+
+ if(!(src = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->srcDrawable, XRC_DRAWABLE, SecurityReadAccess)))
+ return BadDrawable;
+
+ srcShared = IS_SHARED_PIXMAP(src);
+
+ if(!(dst = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->dstDrawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ dstShared = IS_SHARED_PIXMAP(dst);
+
+ if(dstShared && srcShared)
+ return (* SavedProcVector[X_CopyPlane])(client);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ if((dst->type == XRT_WINDOW) && dst->u.win.root)
+ dstIsRoot = TRUE;
+ if((src->type == XRT_WINDOW) && src->u.win.root)
+ srcIsRoot = TRUE;
+
+ srcx = stuff->srcX; srcy = stuff->srcY;
+ dstx = stuff->dstX; dsty = stuff->dstY;
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->dstDrawable = dst->info[j].id;
+ stuff->srcDrawable = src->info[j].id;
+ stuff->gc = gc->info[j].id;
+ if (srcIsRoot) {
+ stuff->srcX = srcx - panoramiXdataPtr[j].x;
+ stuff->srcY = srcy - panoramiXdataPtr[j].y;
+ }
+ if (dstIsRoot) {
+ stuff->dstX = dstx - panoramiXdataPtr[j].x;
+ stuff->dstY = dsty - panoramiXdataPtr[j].y;
+ }
+
+ VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, pGC, client);
+ if (stuff->dstDrawable != stuff->srcDrawable) {
+ SECURITY_VERIFY_DRAWABLE(psrcDraw, stuff->srcDrawable, client,
+ SecurityReadAccess);
+ if (pdstDraw->pScreen != psrcDraw->pScreen) {
+ client->errorValue = stuff->dstDrawable;
+ return (BadMatch);
+ }
+ } else
+ psrcDraw = pdstDraw;
+
+ if(stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) ||
+ (stuff->bitPlane > (1L << (psrcDraw->depth - 1)))) {
+ client->errorValue = stuff->bitPlane;
+ return(BadValue);
+ }
+
+ pRgn[j] = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC,
+ stuff->srcX, stuff->srcY,
+ stuff->width, stuff->height,
+ stuff->dstX, stuff->dstY, stuff->bitPlane);
+
+ if(dstShared) {
+ while(j--) pRgn[j] = NULL;
+ break;
+ }
+ }
+
+ if(pGC->graphicsExposures) {
+ ScreenPtr pScreen = pdstDraw->pScreen;
+ RegionRec totalReg;
+ Bool overlap;
+
+ REGION_NULL(pScreen, &totalReg);
+ FOR_NSCREENS_BACKWARD(j) {
+ if(pRgn[j]) {
+ REGION_APPEND(pScreen, &totalReg, pRgn[j]);
+ REGION_DESTROY(pScreen, pRgn[j]);
+ }
+ }
+ REGION_VALIDATE(pScreen, &totalReg, &overlap);
+ (*pScreen->SendGraphicsExpose)(
+ client, &totalReg, stuff->dstDrawable, X_CopyPlane, 0);
+ REGION_UNINIT(pScreen, &totalReg);
+ }
+
+ return (client->noClientException);
+}
+
+
+int PanoramiXPolyPoint(ClientPtr client)
+{
+ PanoramiXRes *gc, *draw;
+ int result = 0, npoint, j;
+ xPoint *origPts;
+ Bool isRoot;
+ REQUEST(xPolyPointReq);
+
+ REQUEST_AT_LEAST_SIZE(xPolyPointReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(IS_SHARED_PIXMAP(draw))
+ return (*SavedProcVector[X_PolyPoint])(client);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+ npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2;
+ if (npoint > 0) {
+ origPts = (xPoint *) ALLOCATE_LOCAL(npoint * sizeof(xPoint));
+ memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
+ FOR_NSCREENS_FORWARD(j){
+
+ if(j) memcpy(&stuff[1], origPts, npoint * sizeof(xPoint));
+
+ if (isRoot) {
+ int x_off = panoramiXdataPtr[j].x;
+ int y_off = panoramiXdataPtr[j].y;
+
+ if(x_off || y_off) {
+ xPoint *pnts = (xPoint*)&stuff[1];
+ int i = (stuff->coordMode==CoordModePrevious) ? 1 : npoint;
+
+ while(i--) {
+ pnts->x -= x_off;
+ pnts->y -= y_off;
+ pnts++;
+ }
+ }
+ }
+
+ stuff->drawable = draw->info[j].id;
+ stuff->gc = gc->info[j].id;
+ result = (* SavedProcVector[X_PolyPoint])(client);
+ if(result != Success) break;
+ }
+ DEALLOCATE_LOCAL(origPts);
+ return (result);
+ } else
+ return (client->noClientException);
+}
+
+
+int PanoramiXPolyLine(ClientPtr client)
+{
+ PanoramiXRes *gc, *draw;
+ int result = 0, npoint, j;
+ xPoint *origPts;
+ Bool isRoot;
+ REQUEST(xPolyLineReq);
+
+ REQUEST_AT_LEAST_SIZE(xPolyLineReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(IS_SHARED_PIXMAP(draw))
+ return (*SavedProcVector[X_PolyLine])(client);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+ npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2;
+ if (npoint > 0){
+ origPts = (xPoint *) ALLOCATE_LOCAL(npoint * sizeof(xPoint));
+ memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
+ FOR_NSCREENS_FORWARD(j){
+
+ if(j) memcpy(&stuff[1], origPts, npoint * sizeof(xPoint));
+
+ if (isRoot) {
+ int x_off = panoramiXdataPtr[j].x;
+ int y_off = panoramiXdataPtr[j].y;
+
+ if(x_off || y_off) {
+ xPoint *pnts = (xPoint*)&stuff[1];
+ int i = (stuff->coordMode==CoordModePrevious) ? 1 : npoint;
+
+ while(i--) {
+ pnts->x -= x_off;
+ pnts->y -= y_off;
+ pnts++;
+ }
+ }
+ }
+
+ stuff->drawable = draw->info[j].id;
+ stuff->gc = gc->info[j].id;
+ result = (* SavedProcVector[X_PolyLine])(client);
+ if(result != Success) break;
+ }
+ DEALLOCATE_LOCAL(origPts);
+ return (result);
+ } else
+ return (client->noClientException);
+}
+
+
+int PanoramiXPolySegment(ClientPtr client)
+{
+ int result = 0, nsegs, i, j;
+ PanoramiXRes *gc, *draw;
+ xSegment *origSegs;
+ Bool isRoot;
+ REQUEST(xPolySegmentReq);
+
+ REQUEST_AT_LEAST_SIZE(xPolySegmentReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(IS_SHARED_PIXMAP(draw))
+ return (*SavedProcVector[X_PolySegment])(client);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq);
+ if(nsegs & 4) return BadLength;
+ nsegs >>= 3;
+ if (nsegs > 0) {
+ origSegs = (xSegment *) ALLOCATE_LOCAL(nsegs * sizeof(xSegment));
+ memcpy((char *) origSegs, (char *) &stuff[1], nsegs * sizeof(xSegment));
+ FOR_NSCREENS_FORWARD(j){
+
+ if(j) memcpy(&stuff[1], origSegs, nsegs * sizeof(xSegment));
+
+ if (isRoot) {
+ int x_off = panoramiXdataPtr[j].x;
+ int y_off = panoramiXdataPtr[j].y;
+
+ if(x_off || y_off) {
+ xSegment *segs = (xSegment*)&stuff[1];
+
+ for (i = nsegs; i--; segs++) {
+ segs->x1 -= x_off;
+ segs->x2 -= x_off;
+ segs->y1 -= y_off;
+ segs->y2 -= y_off;
+ }
+ }
+ }
+
+ stuff->drawable = draw->info[j].id;
+ stuff->gc = gc->info[j].id;
+ result = (* SavedProcVector[X_PolySegment])(client);
+ if(result != Success) break;
+ }
+ DEALLOCATE_LOCAL(origSegs);
+ return (result);
+ } else
+ return (client->noClientException);
+}
+
+
+int PanoramiXPolyRectangle(ClientPtr client)
+{
+ int result = 0, nrects, i, j;
+ PanoramiXRes *gc, *draw;
+ Bool isRoot;
+ xRectangle *origRecs;
+ REQUEST(xPolyRectangleReq);
+
+ REQUEST_AT_LEAST_SIZE(xPolyRectangleReq);
+
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(IS_SHARED_PIXMAP(draw))
+ return (*SavedProcVector[X_PolyRectangle])(client);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq);
+ if(nrects & 4) return BadLength;
+ nrects >>= 3;
+ if (nrects > 0){
+ origRecs = (xRectangle *) ALLOCATE_LOCAL(nrects * sizeof(xRectangle));
+ memcpy((char *)origRecs,(char *)&stuff[1],nrects * sizeof(xRectangle));
+ FOR_NSCREENS_FORWARD(j){
+
+ if(j) memcpy(&stuff[1], origRecs, nrects * sizeof(xRectangle));
+
+ if (isRoot) {
+ int x_off = panoramiXdataPtr[j].x;
+ int y_off = panoramiXdataPtr[j].y;
+
+
+ if(x_off || y_off) {
+ xRectangle *rects = (xRectangle *) &stuff[1];
+
+ for (i = nrects; i--; rects++) {
+ rects->x -= x_off;
+ rects->y -= y_off;
+ }
+ }
+ }
+
+ stuff->drawable = draw->info[j].id;
+ stuff->gc = gc->info[j].id;
+ result = (* SavedProcVector[X_PolyRectangle])(client);
+ if(result != Success) break;
+ }
+ DEALLOCATE_LOCAL(origRecs);
+ return (result);
+ } else
+ return (client->noClientException);
+}
+
+
+int PanoramiXPolyArc(ClientPtr client)
+{
+ int result = 0, narcs, i, j;
+ PanoramiXRes *gc, *draw;
+ Bool isRoot;
+ xArc *origArcs;
+ REQUEST(xPolyArcReq);
+
+ REQUEST_AT_LEAST_SIZE(xPolyArcReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(IS_SHARED_PIXMAP(draw))
+ return (*SavedProcVector[X_PolyArc])(client);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ narcs = (client->req_len << 2) - sizeof(xPolyArcReq);
+ if(narcs % sizeof(xArc)) return BadLength;
+ narcs /= sizeof(xArc);
+ if (narcs > 0){
+ origArcs = (xArc *) ALLOCATE_LOCAL(narcs * sizeof(xArc));
+ memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc));
+ FOR_NSCREENS_FORWARD(j){
+
+ if(j) memcpy(&stuff[1], origArcs, narcs * sizeof(xArc));
+
+ if (isRoot) {
+ int x_off = panoramiXdataPtr[j].x;
+ int y_off = panoramiXdataPtr[j].y;
+
+ if(x_off || y_off) {
+ xArc *arcs = (xArc *) &stuff[1];
+
+ for (i = narcs; i--; arcs++) {
+ arcs->x -= x_off;
+ arcs->y -= y_off;
+ }
+ }
+ }
+ stuff->drawable = draw->info[j].id;
+ stuff->gc = gc->info[j].id;
+ result = (* SavedProcVector[X_PolyArc])(client);
+ if(result != Success) break;
+ }
+ DEALLOCATE_LOCAL(origArcs);
+ return (result);
+ } else
+ return (client->noClientException);
+}
+
+
+int PanoramiXFillPoly(ClientPtr client)
+{
+ int result = 0, count, j;
+ PanoramiXRes *gc, *draw;
+ Bool isRoot;
+ DDXPointPtr locPts;
+ REQUEST(xFillPolyReq);
+
+ REQUEST_AT_LEAST_SIZE(xFillPolyReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(IS_SHARED_PIXMAP(draw))
+ return (*SavedProcVector[X_FillPoly])(client);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ count = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2;
+ if (count > 0){
+ locPts = (DDXPointPtr) ALLOCATE_LOCAL(count * sizeof(DDXPointRec));
+ memcpy((char *)locPts, (char *)&stuff[1], count * sizeof(DDXPointRec));
+ FOR_NSCREENS_FORWARD(j){
+
+ if(j) memcpy(&stuff[1], locPts, count * sizeof(DDXPointRec));
+
+ if (isRoot) {
+ int x_off = panoramiXdataPtr[j].x;
+ int y_off = panoramiXdataPtr[j].y;
+
+ if(x_off || y_off) {
+ DDXPointPtr pnts = (DDXPointPtr)&stuff[1];
+ int i = (stuff->coordMode==CoordModePrevious) ? 1 : count;
+
+ while(i--) {
+ pnts->x -= x_off;
+ pnts->y -= y_off;
+ pnts++;
+ }
+ }
+ }
+
+ stuff->drawable = draw->info[j].id;
+ stuff->gc = gc->info[j].id;
+ result = (* SavedProcVector[X_FillPoly])(client);
+ if(result != Success) break;
+ }
+ DEALLOCATE_LOCAL(locPts);
+ return (result);
+ } else
+ return (client->noClientException);
+}
+
+
+int PanoramiXPolyFillRectangle(ClientPtr client)
+{
+ int result = 0, things, i, j;
+ PanoramiXRes *gc, *draw;
+ Bool isRoot;
+ xRectangle *origRects;
+ REQUEST(xPolyFillRectangleReq);
+
+ REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(IS_SHARED_PIXMAP(draw))
+ return (*SavedProcVector[X_PolyFillRectangle])(client);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq);
+ if(things & 4) return BadLength;
+ things >>= 3;
+ if (things > 0){
+ origRects = (xRectangle *) ALLOCATE_LOCAL(things * sizeof(xRectangle));
+ memcpy((char*)origRects,(char*)&stuff[1], things * sizeof(xRectangle));
+ FOR_NSCREENS_FORWARD(j){
+
+ if(j) memcpy(&stuff[1], origRects, things * sizeof(xRectangle));
+
+ if (isRoot) {
+ int x_off = panoramiXdataPtr[j].x;
+ int y_off = panoramiXdataPtr[j].y;
+
+ if(x_off || y_off) {
+ xRectangle *rects = (xRectangle *) &stuff[1];
+
+ for (i = things; i--; rects++) {
+ rects->x -= x_off;
+ rects->y -= y_off;
+ }
+ }
+ }
+
+ stuff->drawable = draw->info[j].id;
+ stuff->gc = gc->info[j].id;
+ result = (* SavedProcVector[X_PolyFillRectangle])(client);
+ if(result != Success) break;
+ }
+ DEALLOCATE_LOCAL(origRects);
+ return (result);
+ } else
+ return (client->noClientException);
+}
+
+
+int PanoramiXPolyFillArc(ClientPtr client)
+{
+ PanoramiXRes *gc, *draw;
+ Bool isRoot;
+ int result = 0, narcs, i, j;
+ xArc *origArcs;
+ REQUEST(xPolyFillArcReq);
+
+ REQUEST_AT_LEAST_SIZE(xPolyFillArcReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(IS_SHARED_PIXMAP(draw))
+ return (*SavedProcVector[X_PolyFillArc])(client);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq);
+ IF_RETURN((narcs % sizeof(xArc)), BadLength);
+ narcs /= sizeof(xArc);
+ if (narcs > 0) {
+ origArcs = (xArc *) ALLOCATE_LOCAL(narcs * sizeof(xArc));
+ memcpy((char *) origArcs, (char *)&stuff[1], narcs * sizeof(xArc));
+ FOR_NSCREENS_FORWARD(j){
+
+ if(j) memcpy(&stuff[1], origArcs, narcs * sizeof(xArc));
+
+ if (isRoot) {
+ int x_off = panoramiXdataPtr[j].x;
+ int y_off = panoramiXdataPtr[j].y;
+
+ if(x_off || y_off) {
+ xArc *arcs = (xArc *) &stuff[1];
+
+ for (i = narcs; i--; arcs++) {
+ arcs->x -= x_off;
+ arcs->y -= y_off;
+ }
+ }
+ }
+
+ stuff->drawable = draw->info[j].id;
+ stuff->gc = gc->info[j].id;
+ result = (* SavedProcVector[X_PolyFillArc])(client);
+ if(result != Success) break;
+ }
+ DEALLOCATE_LOCAL(origArcs);
+ return (result);
+ } else
+ return (client->noClientException);
+}
+
+
+int PanoramiXPutImage(ClientPtr client)
+{
+ PanoramiXRes *gc, *draw;
+ Bool isRoot;
+ int j, result = 0, orig_x, orig_y;
+ REQUEST(xPutImageReq);
+
+ REQUEST_AT_LEAST_SIZE(xPutImageReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(IS_SHARED_PIXMAP(draw))
+ return (*SavedProcVector[X_PutImage])(client);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ orig_x = stuff->dstX;
+ orig_y = stuff->dstY;
+ FOR_NSCREENS_BACKWARD(j){
+ if (isRoot) {
+ stuff->dstX = orig_x - panoramiXdataPtr[j].x;
+ stuff->dstY = orig_y - panoramiXdataPtr[j].y;
+ }
+ stuff->drawable = draw->info[j].id;
+ stuff->gc = gc->info[j].id;
+ result = (* SavedProcVector[X_PutImage])(client);
+ if(result != Success) break;
+ }
+ return (result);
+}
+
+
+int PanoramiXGetImage(ClientPtr client)
+{
+ DrawablePtr drawables[MAXSCREENS];
+ DrawablePtr pDraw;
+ PanoramiXRes *draw;
+ xGetImageReply xgi;
+ Bool isRoot;
+ char *pBuf;
+ int i, x, y, w, h, format;
+ Mask plane = 0, planemask;
+ int linesDone, nlines, linesPerBuf;
+ long widthBytesLine, length;
+
+ REQUEST(xGetImageReq);
+
+ REQUEST_SIZE_MATCH(xGetImageReq);
+
+ if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) {
+ client->errorValue = stuff->format;
+ return(BadValue);
+ }
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(draw->type == XRT_PIXMAP)
+ return (*SavedProcVector[X_GetImage])(client);
+
+ VERIFY_DRAWABLE(pDraw, stuff->drawable, client);
+
+ if(!((WindowPtr)pDraw)->realized)
+ return(BadMatch);
+
+ x = stuff->x;
+ y = stuff->y;
+ w = stuff->width;
+ h = stuff->height;
+ format = stuff->format;
+ planemask = stuff->planeMask;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ if(isRoot) {
+ if( /* check for being onscreen */
+ x < 0 || x + w > PanoramiXPixWidth ||
+ y < 0 || y + h > PanoramiXPixHeight )
+ return(BadMatch);
+ } else {
+ if( /* check for being onscreen */
+ panoramiXdataPtr[0].x + pDraw->x + x < 0 ||
+ panoramiXdataPtr[0].x + pDraw->x + x + w > PanoramiXPixWidth ||
+ panoramiXdataPtr[0].y + pDraw->y + y < 0 ||
+ panoramiXdataPtr[0].y + pDraw->y + y + h > PanoramiXPixHeight ||
+ /* check for being inside of border */
+ x < - wBorderWidth((WindowPtr)pDraw) ||
+ x + w > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
+ y < -wBorderWidth((WindowPtr)pDraw) ||
+ y + h > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height)
+ return(BadMatch);
+ }
+
+ drawables[0] = pDraw;
+ for(i = 1; i < PanoramiXNumScreens; i++)
+ VERIFY_DRAWABLE(drawables[i], draw->info[i].id, client);
+
+ xgi.visual = wVisual (((WindowPtr) pDraw));
+ xgi.type = X_Reply;
+ xgi.sequenceNumber = client->sequence;
+ xgi.depth = pDraw->depth;
+ if(format == ZPixmap) {
+ widthBytesLine = PixmapBytePad(w, pDraw->depth);
+ length = widthBytesLine * h;
+
+
+ } else {
+ widthBytesLine = BitmapBytePad(w);
+ plane = ((Mask)1) << (pDraw->depth - 1);
+ /* only planes asked for */
+ length = widthBytesLine * h *
+ Ones(planemask & (plane | (plane - 1)));
+
+ }
+
+ xgi.length = (length + 3) >> 2;
+
+ if (widthBytesLine == 0 || h == 0)
+ linesPerBuf = 0;
+ else if (widthBytesLine >= XINERAMA_IMAGE_BUFSIZE)
+ linesPerBuf = 1;
+ else {
+ linesPerBuf = XINERAMA_IMAGE_BUFSIZE / widthBytesLine;
+ if (linesPerBuf > h)
+ linesPerBuf = h;
+ }
+ length = linesPerBuf * widthBytesLine;
+ if(!(pBuf = xalloc(length)))
+ return (BadAlloc);
+
+ WriteReplyToClient(client, sizeof (xGetImageReply), &xgi);
+
+ if (linesPerBuf == 0) {
+ /* nothing to do */
+ }
+ else if (format == ZPixmap) {
+ linesDone = 0;
+ while (h - linesDone > 0) {
+ nlines = min(linesPerBuf, h - linesDone);
+
+ if(pDraw->depth == 1)
+ bzero(pBuf, nlines * widthBytesLine);
+
+ XineramaGetImageData(drawables, x, y + linesDone, w, nlines,
+ format, planemask, pBuf, widthBytesLine, isRoot);
+
+ (void)WriteToClient(client,
+ (int)(nlines * widthBytesLine),
+ pBuf);
+ linesDone += nlines;
+ }
+ } else { /* XYPixmap */
+ for (; plane; plane >>= 1) {
+ if (planemask & plane) {
+ linesDone = 0;
+ while (h - linesDone > 0) {
+ nlines = min(linesPerBuf, h - linesDone);
+
+ bzero(pBuf, nlines * widthBytesLine);
+
+ XineramaGetImageData(drawables, x, y + linesDone, w,
+ nlines, format, plane, pBuf,
+ widthBytesLine, isRoot);
+
+ (void)WriteToClient(client,
+ (int)(nlines * widthBytesLine),
+ pBuf);
+
+ linesDone += nlines;
+ }
+ }
+ }
+ }
+ xfree(pBuf);
+ return (client->noClientException);
+}
+
+
+/* The text stuff should be rewritten so that duplication happens
+ at the GlyphBlt level. That is, loading the font and getting
+ the glyphs should only happen once */
+
+int
+PanoramiXPolyText8(ClientPtr client)
+{
+ PanoramiXRes *gc, *draw;
+ Bool isRoot;
+ int result = 0, j;
+ int orig_x, orig_y;
+ REQUEST(xPolyTextReq);
+
+ REQUEST_AT_LEAST_SIZE(xPolyTextReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(IS_SHARED_PIXMAP(draw))
+ return (*SavedProcVector[X_PolyText8])(client);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ orig_x = stuff->x;
+ orig_y = stuff->y;
+ FOR_NSCREENS_BACKWARD(j){
+ stuff->drawable = draw->info[j].id;
+ stuff->gc = gc->info[j].id;
+ if (isRoot) {
+ stuff->x = orig_x - panoramiXdataPtr[j].x;
+ stuff->y = orig_y - panoramiXdataPtr[j].y;
+ }
+ result = (*SavedProcVector[X_PolyText8])(client);
+ if(result != Success) break;
+ }
+ return (result);
+}
+
+int
+PanoramiXPolyText16(ClientPtr client)
+{
+ PanoramiXRes *gc, *draw;
+ Bool isRoot;
+ int result = 0, j;
+ int orig_x, orig_y;
+ REQUEST(xPolyTextReq);
+
+ REQUEST_AT_LEAST_SIZE(xPolyTextReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(IS_SHARED_PIXMAP(draw))
+ return (*SavedProcVector[X_PolyText16])(client);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ orig_x = stuff->x;
+ orig_y = stuff->y;
+ FOR_NSCREENS_BACKWARD(j){
+ stuff->drawable = draw->info[j].id;
+ stuff->gc = gc->info[j].id;
+ if (isRoot) {
+ stuff->x = orig_x - panoramiXdataPtr[j].x;
+ stuff->y = orig_y - panoramiXdataPtr[j].y;
+ }
+ result = (*SavedProcVector[X_PolyText16])(client);
+ if(result != Success) break;
+ }
+ return (result);
+}
+
+
+int PanoramiXImageText8(ClientPtr client)
+{
+ int result = 0, j;
+ PanoramiXRes *gc, *draw;
+ Bool isRoot;
+ int orig_x, orig_y;
+ REQUEST(xImageTextReq);
+
+ REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(IS_SHARED_PIXMAP(draw))
+ return (*SavedProcVector[X_ImageText8])(client);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ orig_x = stuff->x;
+ orig_y = stuff->y;
+ FOR_NSCREENS_BACKWARD(j){
+ stuff->drawable = draw->info[j].id;
+ stuff->gc = gc->info[j].id;
+ if (isRoot) {
+ stuff->x = orig_x - panoramiXdataPtr[j].x;
+ stuff->y = orig_y - panoramiXdataPtr[j].y;
+ }
+ result = (*SavedProcVector[X_ImageText8])(client);
+ if(result != Success) break;
+ }
+ return (result);
+}
+
+
+int PanoramiXImageText16(ClientPtr client)
+{
+ int result = 0, j;
+ PanoramiXRes *gc, *draw;
+ Bool isRoot;
+ int orig_x, orig_y;
+ REQUEST(xImageTextReq);
+
+ REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(IS_SHARED_PIXMAP(draw))
+ return (*SavedProcVector[X_ImageText16])(client);
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ orig_x = stuff->x;
+ orig_y = stuff->y;
+ FOR_NSCREENS_BACKWARD(j){
+ stuff->drawable = draw->info[j].id;
+ stuff->gc = gc->info[j].id;
+ if (isRoot) {
+ stuff->x = orig_x - panoramiXdataPtr[j].x;
+ stuff->y = orig_y - panoramiXdataPtr[j].y;
+ }
+ result = (*SavedProcVector[X_ImageText16])(client);
+ if(result != Success) break;
+ }
+ return (result);
+}
+
+
+
+int PanoramiXCreateColormap(ClientPtr client)
+{
+ PanoramiXRes *win, *newCmap;
+ int result = 0, j, orig_visual;
+ REQUEST(xCreateColormapReq);
+
+ REQUEST_SIZE_MATCH(xCreateColormapReq);
+
+ if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->window, XRT_WINDOW, SecurityReadAccess)))
+ return BadWindow;
+
+ if(!stuff->visual || (stuff->visual > 255))
+ return BadValue;
+
+ if(!(newCmap = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
+ return BadAlloc;
+
+ newCmap->type = XRT_COLORMAP;
+ newCmap->info[0].id = stuff->mid;
+ for(j = 1; j < PanoramiXNumScreens; j++)
+ newCmap->info[j].id = FakeClientID(client->index);
+
+ orig_visual = stuff->visual;
+ FOR_NSCREENS_BACKWARD(j){
+ stuff->mid = newCmap->info[j].id;
+ stuff->window = win->info[j].id;
+ stuff->visual = PanoramiXVisualTable[(orig_visual * MAXSCREENS) + j];
+ result = (* SavedProcVector[X_CreateColormap])(client);
+ if(result != Success) break;
+ }
+
+ if (result == Success)
+ AddResource(newCmap->info[0].id, XRT_COLORMAP, newCmap);
+ else
+ xfree(newCmap);
+
+ return (result);
+}
+
+
+int PanoramiXFreeColormap(ClientPtr client)
+{
+ PanoramiXRes *cmap;
+ int result = 0, j;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+
+ client->errorValue = stuff->id;
+
+ if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->id, XRT_COLORMAP, SecurityDestroyAccess)))
+ return BadColor;
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->id = cmap->info[j].id;
+ result = (* SavedProcVector[X_FreeColormap])(client);
+ if(result != Success) break;
+ }
+
+ /* Since ProcFreeColormap is using FreeResource, it will free
+ our resource for us on the last pass through the loop above */
+
+ return (result);
+}
+
+
+int
+PanoramiXCopyColormapAndFree(ClientPtr client)
+{
+ PanoramiXRes *cmap, *newCmap;
+ int result = 0, j;
+ REQUEST(xCopyColormapAndFreeReq);
+
+ REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
+
+ client->errorValue = stuff->srcCmap;
+
+ if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->srcCmap, XRT_COLORMAP,
+ SecurityReadAccess | SecurityWriteAccess)))
+ return BadColor;
+
+ if(!(newCmap = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
+ return BadAlloc;
+
+ newCmap->type = XRT_COLORMAP;
+ newCmap->info[0].id = stuff->mid;
+ for(j = 1; j < PanoramiXNumScreens; j++)
+ newCmap->info[j].id = FakeClientID(client->index);
+
+ FOR_NSCREENS_BACKWARD(j){
+ stuff->srcCmap = cmap->info[j].id;
+ stuff->mid = newCmap->info[j].id;
+ result = (* SavedProcVector[X_CopyColormapAndFree])(client);
+ if(result != Success) break;
+ }
+
+ if (result == Success)
+ AddResource(newCmap->info[0].id, XRT_COLORMAP, newCmap);
+ else
+ xfree(newCmap);
+
+ return (result);
+}
+
+
+int PanoramiXInstallColormap(ClientPtr client)
+{
+ REQUEST(xResourceReq);
+ int result = 0, j;
+ PanoramiXRes *cmap;
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+
+ client->errorValue = stuff->id;
+
+ if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->id, XRT_COLORMAP, SecurityReadAccess)))
+ return BadColor;
+
+ FOR_NSCREENS_BACKWARD(j){
+ stuff->id = cmap->info[j].id;
+ result = (* SavedProcVector[X_InstallColormap])(client);
+ if(result != Success) break;
+ }
+ return (result);
+}
+
+
+int PanoramiXUninstallColormap(ClientPtr client)
+{
+ REQUEST(xResourceReq);
+ int result = 0, j;
+ PanoramiXRes *cmap;
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+
+ client->errorValue = stuff->id;
+
+ if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->id, XRT_COLORMAP, SecurityReadAccess)))
+ return BadColor;
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->id = cmap->info[j].id;
+ result = (* SavedProcVector[X_UninstallColormap])(client);
+ if(result != Success) break;
+ }
+ return (result);
+}
+
+
+int PanoramiXAllocColor(ClientPtr client)
+{
+ int result = 0, j;
+ PanoramiXRes *cmap;
+ REQUEST(xAllocColorReq);
+
+ REQUEST_SIZE_MATCH(xAllocColorReq);
+
+ client->errorValue = stuff->cmap;
+
+ if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess)))
+ return BadColor;
+
+ FOR_NSCREENS_BACKWARD(j){
+ stuff->cmap = cmap->info[j].id;
+ result = (* SavedProcVector[X_AllocColor])(client);
+ if(result != Success) break;
+ }
+ return (result);
+}
+
+
+int PanoramiXAllocNamedColor(ClientPtr client)
+{
+ int result = 0, j;
+ PanoramiXRes *cmap;
+ REQUEST(xAllocNamedColorReq);
+
+ REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes);
+
+ client->errorValue = stuff->cmap;
+
+ if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess)))
+ return BadColor;
+
+ FOR_NSCREENS_BACKWARD(j){
+ stuff->cmap = cmap->info[j].id;
+ result = (* SavedProcVector[X_AllocNamedColor])(client);
+ if(result != Success) break;
+ }
+ return (result);
+}
+
+
+int PanoramiXAllocColorCells(ClientPtr client)
+{
+ int result = 0, j;
+ PanoramiXRes *cmap;
+ REQUEST(xAllocColorCellsReq);
+
+ REQUEST_SIZE_MATCH(xAllocColorCellsReq);
+
+ client->errorValue = stuff->cmap;
+
+ if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess)))
+ return BadColor;
+
+ FOR_NSCREENS_BACKWARD(j){
+ stuff->cmap = cmap->info[j].id;
+ result = (* SavedProcVector[X_AllocColorCells])(client);
+ if(result != Success) break;
+ }
+ return (result);
+}
+
+
+int PanoramiXAllocColorPlanes(ClientPtr client)
+{
+ int result = 0, j;
+ PanoramiXRes *cmap;
+ REQUEST(xAllocColorPlanesReq);
+
+ REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
+
+ client->errorValue = stuff->cmap;
+
+ if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess)))
+ return BadColor;
+
+ FOR_NSCREENS_BACKWARD(j){
+ stuff->cmap = cmap->info[j].id;
+ result = (* SavedProcVector[X_AllocColorPlanes])(client);
+ if(result != Success) break;
+ }
+ return (result);
+}
+
+
+
+int PanoramiXFreeColors(ClientPtr client)
+{
+ int result = 0, j;
+ PanoramiXRes *cmap;
+ REQUEST(xFreeColorsReq);
+
+ REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
+
+ client->errorValue = stuff->cmap;
+
+ if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess)))
+ return BadColor;
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->cmap = cmap->info[j].id;
+ result = (* SavedProcVector[X_FreeColors])(client);
+ }
+ return (result);
+}
+
+
+int PanoramiXStoreColors(ClientPtr client)
+{
+ int result = 0, j;
+ PanoramiXRes *cmap;
+ REQUEST(xStoreColorsReq);
+
+ REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
+
+ client->errorValue = stuff->cmap;
+
+ if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess)))
+ return BadColor;
+
+ FOR_NSCREENS_BACKWARD(j){
+ stuff->cmap = cmap->info[j].id;
+ result = (* SavedProcVector[X_StoreColors])(client);
+ if(result != Success) break;
+ }
+ return (result);
+}
+
+
+int PanoramiXStoreNamedColor(ClientPtr client)
+{
+ int result = 0, j;
+ PanoramiXRes *cmap;
+ REQUEST(xStoreNamedColorReq);
+
+ REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes);
+
+ client->errorValue = stuff->cmap;
+
+ if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess)))
+ return BadColor;
+
+ FOR_NSCREENS_BACKWARD(j){
+ stuff->cmap = cmap->info[j].id;
+ result = (* SavedProcVector[X_StoreNamedColor])(client);
+ if(result != Success) break;
+ }
+ return (result);
+}
diff --git a/nx-X11/programs/Xserver/Xext/panoramiXsrv.h b/nx-X11/programs/Xserver/Xext/panoramiXsrv.h
new file mode 100644
index 000000000..dc3b3d805
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/panoramiXsrv.h
@@ -0,0 +1,50 @@
+/* $XFree86: xc/programs/Xserver/Xext/panoramiXsrv.h,v 1.8 2001/08/01 00:44:44 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _PANORAMIXSRV_H_
+#define _PANORAMIXSRV_H_
+
+#include "panoramiX.h"
+
+extern int PanoramiXNumScreens;
+extern PanoramiXData *panoramiXdataPtr;
+extern int PanoramiXPixWidth;
+extern int PanoramiXPixHeight;
+extern RegionRec PanoramiXScreenRegion;
+extern XID *PanoramiXVisualTable;
+
+extern void PanoramiXConsolidate(void);
+extern Bool PanoramiXCreateConnectionBlock(void);
+extern PanoramiXRes * PanoramiXFindIDByScrnum(RESTYPE, XID, int);
+extern PanoramiXRes * PanoramiXFindIDOnAnyScreen(RESTYPE, XID);
+extern WindowPtr PanoramiXChangeWindow(int, WindowPtr);
+extern Bool XineramaRegisterConnectionBlockCallback(void (*func)(void));
+extern int XineramaDeleteResource(pointer, XID);
+
+extern void XineramaReinitData(ScreenPtr);
+
+extern RegionRec XineramaScreenRegions[MAXSCREENS];
+
+extern unsigned long XRC_DRAWABLE;
+extern unsigned long XRT_WINDOW;
+extern unsigned long XRT_PIXMAP;
+extern unsigned long XRT_GC;
+extern unsigned long XRT_COLORMAP;
+
+extern void XineramaGetImageData(
+ DrawablePtr *pDrawables,
+ int left,
+ int top,
+ int width,
+ int height,
+ unsigned int format,
+ unsigned long planemask,
+ char *data,
+ int pitch,
+ Bool isRoot
+);
+
+#endif /* _PANORAMIXSRV_H_ */
diff --git a/nx-X11/programs/Xserver/Xext/sampleEVI.c b/nx-X11/programs/Xserver/Xext/sampleEVI.c
new file mode 100644
index 000000000..67caa5613
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/sampleEVI.c
@@ -0,0 +1,106 @@
+/* $Xorg: sampleEVI.c,v 1.3 2000/08/17 19:47:58 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1997 by Silicon Graphics Computer Systems, Inc.
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+********************************************************/
+/* $XFree86$ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "dix.h"
+#define _XEVI_SERVER_
+#include <X11/extensions/XEVIstr.h>
+#include "EVIstruct.h"
+#include "scrnintstr.h"
+static int sampleGetVisualInfo(
+ VisualID32 *visual,
+ int n_visual,
+ xExtendedVisualInfo **evi_rn,
+ int *n_info_rn,
+ VisualID32 **conflict_rn,
+ int *n_conflict_rn)
+{
+ int max_sz_evi = n_visual * sz_xExtendedVisualInfo * screenInfo.numScreens;
+ VisualID32 *temp_conflict;
+ xExtendedVisualInfo *evi;
+ int max_visuals = 0, max_sz_conflict, sz_conflict = 0;
+ register int visualI, scrI, sz_evi = 0, conflictI, n_conflict;
+ *evi_rn = evi = (xExtendedVisualInfo *)xalloc(max_sz_evi);
+ if (!*evi_rn)
+ return BadAlloc;
+ for (scrI = 0; scrI < screenInfo.numScreens; scrI++) {
+ if (screenInfo.screens[scrI]->numVisuals > max_visuals)
+ max_visuals = screenInfo.screens[scrI]->numVisuals;
+ }
+ max_sz_conflict = n_visual * sz_VisualID32 * screenInfo.numScreens * max_visuals;
+ temp_conflict = (VisualID32 *)xalloc(max_sz_conflict);
+ if (!temp_conflict) {
+ xfree(*evi_rn);
+ return BadAlloc;
+ }
+ for (scrI = 0; scrI < screenInfo.numScreens; scrI++) {
+ for (visualI = 0; visualI < n_visual; visualI++) {
+ evi[sz_evi].core_visual_id = visual[visualI];
+ evi[sz_evi].screen = scrI;
+ evi[sz_evi].level = 0;
+ evi[sz_evi].transparency_type = XEVI_TRANSPARENCY_NONE;
+ evi[sz_evi].transparency_value = 0;
+ evi[sz_evi].min_hw_colormaps = 1;
+ evi[sz_evi].max_hw_colormaps = 1;
+ evi[sz_evi].num_colormap_conflicts = n_conflict = 0;
+ for (conflictI = 0; conflictI < n_conflict; conflictI++)
+ temp_conflict[sz_conflict++] = visual[visualI];
+ sz_evi++;
+ }
+ }
+ *conflict_rn = temp_conflict;
+ *n_conflict_rn = sz_conflict;
+ *n_info_rn = sz_evi;
+ return Success;
+}
+
+static void sampleFreeVisualInfo(
+ xExtendedVisualInfo *evi,
+ VisualID32 *conflict)
+{
+ if (evi)
+ xfree(evi);
+ if (conflict)
+ xfree(conflict);
+}
+
+EviPrivPtr eviDDXInit(void)
+{
+ static EviPrivRec eviPriv;
+ eviPriv.getVisualInfo = sampleGetVisualInfo;
+ eviPriv.freeVisualInfo = sampleFreeVisualInfo;
+ return &eviPriv;
+}
+
+void eviDDXReset(void)
+{
+}
diff --git a/nx-X11/programs/Xserver/Xext/saver.c b/nx-X11/programs/Xserver/Xext/saver.c
new file mode 100644
index 000000000..14b0d2751
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/saver.c
@@ -0,0 +1,1415 @@
+/* $XdotOrg: xc/programs/Xserver/Xext/saver.c,v 1.10 2005/07/03 08:53:36 daniels Exp $ */
+/*
+ * $XConsortium: saver.c,v 1.12 94/04/17 20:59:36 dpw Exp $
+ *
+Copyright (c) 1992 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/programs/Xserver/Xext/saver.c,v 3.7 2003/10/28 23:08:43 tsi Exp $ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "opaque.h"
+#include <X11/extensions/saverproto.h>
+#include "gcstruct.h"
+#include "cursorstr.h"
+#include "colormapst.h"
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+
+
+#ifdef IN_MODULE
+#include <xf86_ansic.h>
+#else
+#include <stdio.h>
+#endif
+
+#include "modinit.h"
+
+#if 0
+static unsigned char ScreenSaverReqCode = 0;
+#endif
+static int ScreenSaverEventBase = 0;
+
+extern DISPATCH_PROC(ProcScreenSaverQueryInfo);
+static DISPATCH_PROC(ProcScreenSaverDispatch);
+static DISPATCH_PROC(ProcScreenSaverQueryVersion);
+static DISPATCH_PROC(ProcScreenSaverSelectInput);
+static DISPATCH_PROC(ProcScreenSaverSetAttributes);
+static DISPATCH_PROC(ProcScreenSaverUnsetAttributes);
+static DISPATCH_PROC(SProcScreenSaverDispatch);
+static DISPATCH_PROC(SProcScreenSaverQueryInfo);
+static DISPATCH_PROC(SProcScreenSaverQueryVersion);
+static DISPATCH_PROC(SProcScreenSaverSelectInput);
+static DISPATCH_PROC(SProcScreenSaverSetAttributes);
+static DISPATCH_PROC(SProcScreenSaverUnsetAttributes);
+
+static Bool ScreenSaverHandle (
+ ScreenPtr /* pScreen */,
+ int /* xstate */,
+ Bool /* force */
+ );
+
+static Bool
+CreateSaverWindow (
+ ScreenPtr /* pScreen */
+ );
+
+static Bool
+DestroySaverWindow (
+ ScreenPtr /* pScreen */
+ );
+
+static void
+UninstallSaverColormap (
+ ScreenPtr /* pScreen */
+ );
+
+static void
+CheckScreenPrivate (
+ ScreenPtr /* pScreen */
+ );
+
+static void SScreenSaverNotifyEvent (
+ xScreenSaverNotifyEvent * /* from */,
+ xScreenSaverNotifyEvent * /* to */
+ );
+
+static void ScreenSaverResetProc (
+ ExtensionEntry * /* extEntry */
+ );
+
+/*
+ * each screen has a list of clients requesting
+ * ScreenSaverNotify events. Each client has a resource
+ * for each screen it selects ScreenSaverNotify input for,
+ * this resource is used to delete the ScreenSaverNotifyRec
+ * entry from the per-screen queue.
+ */
+
+static RESTYPE EventType; /* resource type for event masks */
+
+typedef struct _ScreenSaverEvent *ScreenSaverEventPtr;
+
+typedef struct _ScreenSaverEvent {
+ ScreenSaverEventPtr next;
+ ClientPtr client;
+ ScreenPtr screen;
+ XID resource;
+ CARD32 mask;
+} ScreenSaverEventRec;
+
+static int ScreenSaverFreeEvents(
+ pointer /* value */,
+ XID /* id */
+);
+
+static Bool setEventMask (
+ ScreenPtr /* pScreen */,
+ ClientPtr /* client */,
+ unsigned long /* mask */
+);
+
+static unsigned long getEventMask (
+ ScreenPtr /* pScreen */,
+ ClientPtr /* client */
+);
+
+/*
+ * when a client sets the screen saver attributes, a resource is
+ * kept to be freed when the client exits
+ */
+
+static RESTYPE AttrType; /* resource type for attributes */
+
+typedef struct _ScreenSaverAttr {
+ ScreenPtr screen;
+ ClientPtr client;
+ XID resource;
+ short x, y;
+ unsigned short width, height, borderWidth;
+ unsigned char class;
+ unsigned char depth;
+ VisualID visual;
+ CursorPtr pCursor;
+ PixmapPtr pBackgroundPixmap;
+ PixmapPtr pBorderPixmap;
+ Colormap colormap;
+ unsigned long mask; /* no pixmaps or cursors */
+ unsigned long *values;
+} ScreenSaverAttrRec, *ScreenSaverAttrPtr;
+
+static int ScreenSaverFreeAttr (
+ pointer /* value */,
+ XID /* id */
+);
+
+static void FreeAttrs (
+ ScreenSaverAttrPtr /* pAttr */
+);
+
+static void FreeScreenAttr (
+ ScreenSaverAttrPtr /* pAttr */
+);
+
+static void
+SendScreenSaverNotify (
+ ScreenPtr /* pScreen */,
+ int /* state */,
+ Bool /* forced */
+);
+
+typedef struct _ScreenSaverScreenPrivate {
+ ScreenSaverEventPtr events;
+ ScreenSaverAttrPtr attr;
+ Bool hasWindow;
+ Colormap installedMap;
+} ScreenSaverScreenPrivateRec, *ScreenSaverScreenPrivatePtr;
+
+static ScreenSaverScreenPrivatePtr
+MakeScreenPrivate (
+ ScreenPtr /* pScreen */
+ );
+
+static int ScreenPrivateIndex;
+
+#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr)(s)->devPrivates[ScreenPrivateIndex].ptr)
+#define SetScreenPrivate(s,v) ((s)->devPrivates[ScreenPrivateIndex].ptr = (pointer) v);
+#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = (s ? GetScreenPrivate(s) : NULL)
+
+#define New(t) ((t *) xalloc (sizeof (t)))
+
+/****************
+ * ScreenSaverExtensionInit
+ *
+ * Called from InitExtensions in main() or from QueryExtension() if the
+ * extension is dynamically loaded.
+ *
+ ****************/
+
+void
+ScreenSaverExtensionInit(INITARGS)
+{
+ ExtensionEntry *extEntry;
+ int i;
+ ScreenPtr pScreen;
+
+ AttrType = CreateNewResourceType(ScreenSaverFreeAttr);
+ EventType = CreateNewResourceType(ScreenSaverFreeEvents);
+ ScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ pScreen = screenInfo.screens[i];
+ SetScreenPrivate (pScreen, NULL);
+ }
+ if (AttrType && EventType && ScreenPrivateIndex != -1 &&
+ (extEntry = AddExtension(ScreenSaverName, ScreenSaverNumberEvents, 0,
+ ProcScreenSaverDispatch, SProcScreenSaverDispatch,
+ ScreenSaverResetProc, StandardMinorOpcode)))
+ {
+#if 0
+ ScreenSaverReqCode = (unsigned char)extEntry->base;
+#endif
+ ScreenSaverEventBase = extEntry->eventBase;
+ EventSwapVector[ScreenSaverEventBase] = (EventSwapPtr) SScreenSaverNotifyEvent;
+ }
+}
+
+/*ARGSUSED*/
+static void
+ScreenSaverResetProc (extEntry)
+ExtensionEntry *extEntry;
+{
+}
+
+static void
+CheckScreenPrivate (pScreen)
+ ScreenPtr pScreen;
+{
+ SetupScreen (pScreen);
+
+ if (!pPriv)
+ return;
+ if (!pPriv->attr && !pPriv->events &&
+ !pPriv->hasWindow && pPriv->installedMap == None)
+ {
+ xfree (pPriv);
+ SetScreenPrivate (pScreen, NULL);
+ savedScreenInfo[pScreen->myNum].ExternalScreenSaver = NULL;
+ }
+}
+
+static ScreenSaverScreenPrivatePtr
+MakeScreenPrivate (pScreen)
+ ScreenPtr pScreen;
+{
+ SetupScreen (pScreen);
+
+ if (pPriv)
+ return pPriv;
+ pPriv = New (ScreenSaverScreenPrivateRec);
+ if (!pPriv)
+ return 0;
+ pPriv->events = 0;
+ pPriv->attr = 0;
+ pPriv->hasWindow = FALSE;
+ pPriv->installedMap = None;
+ SetScreenPrivate (pScreen, pPriv);
+ savedScreenInfo[pScreen->myNum].ExternalScreenSaver = ScreenSaverHandle;
+ return pPriv;
+}
+
+static unsigned long
+getEventMask (pScreen, client)
+ ScreenPtr pScreen;
+ ClientPtr client;
+{
+ SetupScreen(pScreen);
+ ScreenSaverEventPtr pEv;
+
+ if (!pPriv)
+ return 0;
+ for (pEv = pPriv->events; pEv; pEv = pEv->next)
+ if (pEv->client == client)
+ return pEv->mask;
+ return 0;
+}
+
+static Bool
+setEventMask (pScreen, client, mask)
+ ScreenPtr pScreen;
+ ClientPtr client;
+ unsigned long mask;
+{
+ SetupScreen(pScreen);
+ ScreenSaverEventPtr pEv, *pPrev;
+
+ if (getEventMask (pScreen, client) == mask)
+ return TRUE;
+ if (!pPriv)
+ {
+ pPriv = MakeScreenPrivate (pScreen);
+ if (!pPriv)
+ return FALSE;
+ }
+ for (pPrev = &pPriv->events; (pEv = *pPrev) != 0; pPrev = &pEv->next)
+ if (pEv->client == client)
+ break;
+ if (mask == 0)
+ {
+ FreeResource (pEv->resource, EventType);
+ *pPrev = pEv->next;
+ xfree (pEv);
+ CheckScreenPrivate (pScreen);
+ }
+ else
+ {
+ if (!pEv)
+ {
+ pEv = New (ScreenSaverEventRec);
+ if (!pEv)
+ {
+ CheckScreenPrivate (pScreen);
+ return FALSE;
+ }
+ *pPrev = pEv;
+ pEv->next = NULL;
+ pEv->client = client;
+ pEv->screen = pScreen;
+ pEv->resource = FakeClientID (client->index);
+ if (!AddResource (pEv->resource, EventType, (pointer) pEv))
+ return FALSE;
+ }
+ pEv->mask = mask;
+ }
+ return TRUE;
+}
+
+static void
+FreeAttrs (pAttr)
+ ScreenSaverAttrPtr pAttr;
+{
+ PixmapPtr pPixmap;
+ CursorPtr pCursor;
+
+ if ((pPixmap = pAttr->pBackgroundPixmap) != 0)
+ (*pPixmap->drawable.pScreen->DestroyPixmap)(pPixmap);
+ if ((pPixmap = pAttr->pBorderPixmap) != 0)
+ (*pPixmap->drawable.pScreen->DestroyPixmap)(pPixmap);
+ if ((pCursor = pAttr->pCursor) != 0)
+ FreeCursor (pCursor, (Cursor) 0);
+}
+
+static void
+FreeScreenAttr (pAttr)
+ ScreenSaverAttrPtr pAttr;
+{
+ FreeAttrs (pAttr);
+ xfree (pAttr->values);
+ xfree (pAttr);
+}
+
+static int
+ScreenSaverFreeEvents (value, id)
+ pointer value;
+ XID id;
+{
+ ScreenSaverEventPtr pOld = (ScreenSaverEventPtr)value;
+ ScreenPtr pScreen = pOld->screen;
+ SetupScreen (pScreen);
+ ScreenSaverEventPtr pEv, *pPrev;
+
+ if (!pPriv)
+ return TRUE;
+ for (pPrev = &pPriv->events; (pEv = *pPrev) != 0; pPrev = &pEv->next)
+ if (pEv == pOld)
+ break;
+ if (!pEv)
+ return TRUE;
+ *pPrev = pEv->next;
+ xfree (pEv);
+ CheckScreenPrivate (pScreen);
+ return TRUE;
+}
+
+static int
+ScreenSaverFreeAttr (value, id)
+ pointer value;
+ XID id;
+{
+ ScreenSaverAttrPtr pOldAttr = (ScreenSaverAttrPtr)value;
+ ScreenPtr pScreen = pOldAttr->screen;
+ SetupScreen (pScreen);
+
+ if (!pPriv)
+ return TRUE;
+ if (pPriv->attr != pOldAttr)
+ return TRUE;
+ FreeScreenAttr (pOldAttr);
+ pPriv->attr = NULL;
+ if (pPriv->hasWindow)
+ {
+ SaveScreens (SCREEN_SAVER_FORCER, ScreenSaverReset);
+ SaveScreens (SCREEN_SAVER_FORCER, ScreenSaverActive);
+ }
+ CheckScreenPrivate (pScreen);
+ return TRUE;
+}
+
+static void
+SendScreenSaverNotify (pScreen, state, forced)
+ ScreenPtr pScreen;
+ int state;
+ Bool forced;
+{
+ ScreenSaverScreenPrivatePtr pPriv;
+ ScreenSaverEventPtr pEv;
+ unsigned long mask;
+ xScreenSaverNotifyEvent ev;
+ ClientPtr client;
+ int kind;
+
+ UpdateCurrentTimeIf ();
+ mask = ScreenSaverNotifyMask;
+ if (state == ScreenSaverCycle)
+ mask = ScreenSaverCycleMask;
+ pScreen = screenInfo.screens[pScreen->myNum];
+ pPriv = GetScreenPrivate(pScreen);
+ if (!pPriv)
+ return;
+ if (pPriv->attr)
+ kind = ScreenSaverExternal;
+ else if (ScreenSaverBlanking != DontPreferBlanking)
+ kind = ScreenSaverBlanked;
+ else
+ kind = ScreenSaverInternal;
+ for (pEv = pPriv->events; pEv; pEv = pEv->next)
+ {
+ client = pEv->client;
+ if (client->clientGone)
+ continue;
+ if (!(pEv->mask & mask))
+ continue;
+ ev.type = ScreenSaverNotify + ScreenSaverEventBase;
+ ev.state = state;
+ ev.sequenceNumber = client->sequence;
+ ev.timestamp = currentTime.milliseconds;
+ ev.root = WindowTable[pScreen->myNum]->drawable.id;
+ ev.window = savedScreenInfo[pScreen->myNum].wid;
+ ev.kind = kind;
+ ev.forced = forced;
+ WriteEventsToClient (client, 1, (xEvent *) &ev);
+ }
+}
+
+static void
+SScreenSaverNotifyEvent (from, to)
+ xScreenSaverNotifyEvent *from, *to;
+{
+ to->type = from->type;
+ to->state = from->state;
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswapl (from->timestamp, to->timestamp);
+ cpswapl (from->root, to->root);
+ cpswapl (from->window, to->window);
+ to->kind = from->kind;
+ to->forced = from->forced;
+}
+
+static void
+UninstallSaverColormap (pScreen)
+ ScreenPtr pScreen;
+{
+ SetupScreen(pScreen);
+ ColormapPtr pCmap;
+
+ if (pPriv && pPriv->installedMap != None)
+ {
+ pCmap = (ColormapPtr) LookupIDByType (pPriv->installedMap, RT_COLORMAP);
+ if (pCmap)
+ (*pCmap->pScreen->UninstallColormap) (pCmap);
+ pPriv->installedMap = None;
+ CheckScreenPrivate (pScreen);
+ }
+}
+
+static Bool
+CreateSaverWindow (pScreen)
+ ScreenPtr pScreen;
+{
+ SetupScreen (pScreen);
+ ScreenSaverStuffPtr pSaver;
+ ScreenSaverAttrPtr pAttr;
+ WindowPtr pWin;
+ int result;
+ unsigned long mask;
+ Colormap *installedMaps;
+ int numInstalled;
+ int i;
+ Colormap wantMap;
+ ColormapPtr pCmap;
+
+ pSaver = &savedScreenInfo[pScreen->myNum];
+ if (pSaver->pWindow)
+ {
+ pSaver->pWindow = NullWindow;
+ FreeResource (pSaver->wid, RT_NONE);
+ if (pPriv)
+ {
+ UninstallSaverColormap (pScreen);
+ pPriv->hasWindow = FALSE;
+ CheckScreenPrivate (pScreen);
+ }
+ }
+
+ if (!pPriv || !(pAttr = pPriv->attr))
+ return FALSE;
+
+ pPriv->installedMap = None;
+
+ if (GrabInProgress && GrabInProgress != pAttr->client->index)
+ return FALSE;
+
+ pWin = CreateWindow (pSaver->wid, WindowTable[pScreen->myNum],
+ pAttr->x, pAttr->y, pAttr->width, pAttr->height,
+ pAttr->borderWidth, pAttr->class,
+ pAttr->mask, (XID *)pAttr->values,
+ pAttr->depth, serverClient, pAttr->visual,
+ &result);
+ if (!pWin)
+ return FALSE;
+
+ if (!AddResource(pWin->drawable.id, RT_WINDOW, pWin))
+ return FALSE;
+
+ mask = 0;
+ if (pAttr->pBackgroundPixmap)
+ {
+ pWin->backgroundState = BackgroundPixmap;
+ pWin->background.pixmap = pAttr->pBackgroundPixmap;
+ pAttr->pBackgroundPixmap->refcnt++;
+ mask |= CWBackPixmap;
+ }
+ if (pAttr->pBorderPixmap)
+ {
+ pWin->borderIsPixel = FALSE;
+ pWin->border.pixmap = pAttr->pBorderPixmap;
+ pAttr->pBorderPixmap->refcnt++;
+ mask |= CWBorderPixmap;
+ }
+ if (pAttr->pCursor)
+ {
+ if (!pWin->optional)
+ if (!MakeWindowOptional (pWin))
+ {
+ FreeResource (pWin->drawable.id, RT_NONE);
+ return FALSE;
+ }
+ if (pWin->optional->cursor)
+ FreeCursor (pWin->optional->cursor, (Cursor)0);
+ pWin->optional->cursor = pAttr->pCursor;
+ pAttr->pCursor->refcnt++;
+ pWin->cursorIsNone = FALSE;
+ CheckWindowOptionalNeed (pWin);
+ mask |= CWCursor;
+ }
+ if (mask)
+ (*pScreen->ChangeWindowAttributes) (pWin, mask);
+
+ if (pAttr->colormap != None)
+ (void) ChangeWindowAttributes (pWin, CWColormap, &pAttr->colormap,
+ serverClient);
+
+ MapWindow (pWin, serverClient);
+
+ pPriv->hasWindow = TRUE;
+ pSaver->pWindow = pWin;
+
+ /* check and install our own colormap if it isn't installed now */
+ wantMap = wColormap (pWin);
+ if (wantMap == None)
+ return TRUE;
+ installedMaps = (Colormap *) ALLOCATE_LOCAL (pScreen->maxInstalledCmaps *
+ sizeof (Colormap));
+ numInstalled = (*pWin->drawable.pScreen->ListInstalledColormaps)
+ (pScreen, installedMaps);
+ for (i = 0; i < numInstalled; i++)
+ if (installedMaps[i] == wantMap)
+ break;
+
+ DEALLOCATE_LOCAL ((char *) installedMaps);
+
+ if (i < numInstalled)
+ return TRUE;
+
+ pCmap = (ColormapPtr) LookupIDByType (wantMap, RT_COLORMAP);
+ if (!pCmap)
+ return TRUE;
+
+ pPriv->installedMap = wantMap;
+
+ (*pCmap->pScreen->InstallColormap) (pCmap);
+
+ return TRUE;
+}
+
+static Bool
+DestroySaverWindow (pScreen)
+ ScreenPtr pScreen;
+{
+ SetupScreen(pScreen);
+ ScreenSaverStuffPtr pSaver;
+
+ if (!pPriv || !pPriv->hasWindow)
+ return FALSE;
+
+ pSaver = &savedScreenInfo[pScreen->myNum];
+ if (pSaver->pWindow)
+ {
+ pSaver->pWindow = NullWindow;
+ FreeResource (pSaver->wid, RT_NONE);
+ }
+ pPriv->hasWindow = FALSE;
+ CheckScreenPrivate (pScreen);
+ UninstallSaverColormap (pScreen);
+ return TRUE;
+}
+
+static Bool
+ScreenSaverHandle (pScreen, xstate, force)
+ ScreenPtr pScreen;
+ int xstate;
+ Bool force;
+{
+ int state = 0;
+ Bool ret = FALSE;
+ ScreenSaverScreenPrivatePtr pPriv;
+
+ switch (xstate)
+ {
+ case SCREEN_SAVER_ON:
+ state = ScreenSaverOn;
+ ret = CreateSaverWindow (pScreen);
+ break;
+ case SCREEN_SAVER_OFF:
+ state = ScreenSaverOff;
+ ret = DestroySaverWindow (pScreen);
+ break;
+ case SCREEN_SAVER_CYCLE:
+ state = ScreenSaverCycle;
+ pPriv = GetScreenPrivate (pScreen);
+ if (pPriv && pPriv->hasWindow)
+ ret = TRUE;
+
+ }
+#ifdef PANORAMIX
+ if(noPanoramiXExtension || !pScreen->myNum)
+#endif
+ SendScreenSaverNotify (pScreen, state, force);
+ return ret;
+}
+
+static int
+ProcScreenSaverQueryVersion (client)
+ register ClientPtr client;
+{
+ xScreenSaverQueryVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH (xScreenSaverQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = ScreenSaverMajorVersion;
+ rep.minorVersion = ScreenSaverMinorVersion;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ }
+ WriteToClient(client, sizeof (xScreenSaverQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+int
+ProcScreenSaverQueryInfo (client)
+ register ClientPtr client;
+{
+ REQUEST(xScreenSaverQueryInfoReq);
+ xScreenSaverQueryInfoReply rep;
+ register int n;
+ ScreenSaverStuffPtr pSaver;
+ DrawablePtr pDraw;
+ CARD32 lastInput;
+ ScreenSaverScreenPrivatePtr pPriv;
+
+ REQUEST_SIZE_MATCH (xScreenSaverQueryInfoReq);
+ pDraw = (DrawablePtr) LookupDrawable (stuff->drawable, client);
+ if (!pDraw)
+ return BadDrawable;
+
+ pSaver = &savedScreenInfo[pDraw->pScreen->myNum];
+ pPriv = GetScreenPrivate (pDraw->pScreen);
+
+ UpdateCurrentTime ();
+ lastInput = GetTimeInMillis() - lastDeviceEventTime.milliseconds;
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.window = pSaver->wid;
+ if (screenIsSaved != SCREEN_SAVER_OFF)
+ {
+ rep.state = ScreenSaverOn;
+ if (ScreenSaverTime)
+ rep.tilOrSince = lastInput - ScreenSaverTime;
+ else
+ rep.tilOrSince = 0;
+ }
+ else
+ {
+ if (ScreenSaverTime)
+ {
+ rep.state = ScreenSaverOff;
+ if (ScreenSaverTime < lastInput)
+ rep.tilOrSince = 0;
+ else
+ rep.tilOrSince = ScreenSaverTime - lastInput;
+ }
+ else
+ {
+ rep.state = ScreenSaverDisabled;
+ rep.tilOrSince = 0;
+ }
+ }
+ rep.idle = lastInput;
+ rep.eventMask = getEventMask (pDraw->pScreen, client);
+ if (pPriv && pPriv->attr)
+ rep.kind = ScreenSaverExternal;
+ else if (ScreenSaverBlanking != DontPreferBlanking)
+ rep.kind = ScreenSaverBlanked;
+ else
+ rep.kind = ScreenSaverInternal;
+ if (client->swapped)
+ {
+ swaps (&rep.sequenceNumber, n);
+ swapl (&rep.length, n);
+ swapl (&rep.window, n);
+ swapl (&rep.tilOrSince, n);
+ swapl (&rep.idle, n);
+ swapl (&rep.eventMask, n);
+ }
+ WriteToClient(client, sizeof (xScreenSaverQueryInfoReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcScreenSaverSelectInput (client)
+ register ClientPtr client;
+{
+ REQUEST(xScreenSaverSelectInputReq);
+ DrawablePtr pDraw;
+
+ REQUEST_SIZE_MATCH (xScreenSaverSelectInputReq);
+ pDraw = (DrawablePtr) LookupDrawable (stuff->drawable, client);
+ if (!pDraw)
+ return BadDrawable;
+ if (!setEventMask (pDraw->pScreen, client, stuff->eventMask))
+ return BadAlloc;
+ return Success;
+}
+
+static int
+ScreenSaverSetAttributes (ClientPtr client)
+{
+ REQUEST(xScreenSaverSetAttributesReq);
+ DrawablePtr pDraw;
+ WindowPtr pParent;
+ ScreenPtr pScreen;
+ ScreenSaverScreenPrivatePtr pPriv = 0;
+ ScreenSaverAttrPtr pAttr = 0;
+ int ret;
+ int len;
+ int class, bw, depth;
+ unsigned long visual;
+ int idepth, ivisual;
+ Bool fOK;
+ DepthPtr pDepth;
+ WindowOptPtr ancwopt;
+ unsigned int *pVlist;
+ unsigned long *values = 0;
+ unsigned long tmask, imask;
+ unsigned long val;
+ Pixmap pixID;
+ PixmapPtr pPixmap;
+ Cursor cursorID;
+ CursorPtr pCursor;
+ Colormap cmap;
+ ColormapPtr pCmap;
+
+ REQUEST_AT_LEAST_SIZE (xScreenSaverSetAttributesReq);
+ pDraw = (DrawablePtr) LookupDrawable (stuff->drawable, client);
+ if (!pDraw)
+ return BadDrawable;
+ pScreen = pDraw->pScreen;
+ pParent = WindowTable[pScreen->myNum];
+
+ len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2);
+ if (Ones(stuff->mask) != len)
+ return BadLength;
+ if (!stuff->width || !stuff->height)
+ {
+ client->errorValue = 0;
+ return BadValue;
+ }
+ switch (class = stuff->c_class)
+ {
+ case CopyFromParent:
+ case InputOnly:
+ case InputOutput:
+ break;
+ default:
+ client->errorValue = class;
+ return BadValue;
+ }
+ bw = stuff->borderWidth;
+ depth = stuff->depth;
+ visual = stuff->visualID;
+
+ /* copied directly from CreateWindow */
+
+ if (class == CopyFromParent)
+ class = pParent->drawable.class;
+
+ if ((class != InputOutput) && (class != InputOnly))
+ {
+ client->errorValue = class;
+ return BadValue;
+ }
+
+ if ((class != InputOnly) && (pParent->drawable.class == InputOnly))
+ return BadMatch;
+
+ if ((class == InputOnly) && ((bw != 0) || (depth != 0)))
+ return BadMatch;
+
+ if ((class == InputOutput) && (depth == 0))
+ depth = pParent->drawable.depth;
+ ancwopt = pParent->optional;
+ if (!ancwopt)
+ ancwopt = FindWindowWithOptional(pParent)->optional;
+ if (visual == CopyFromParent)
+ visual = ancwopt->visual;
+
+ /* Find out if the depth and visual are acceptable for this Screen */
+ if ((visual != ancwopt->visual) || (depth != pParent->drawable.depth))
+ {
+ fOK = FALSE;
+ for(idepth = 0; idepth < pScreen->numDepths; idepth++)
+ {
+ pDepth = (DepthPtr) &pScreen->allowedDepths[idepth];
+ if ((depth == pDepth->depth) || (depth == 0))
+ {
+ for (ivisual = 0; ivisual < pDepth->numVids; ivisual++)
+ {
+ if (visual == pDepth->vids[ivisual])
+ {
+ fOK = TRUE;
+ break;
+ }
+ }
+ }
+ }
+ if (fOK == FALSE)
+ return BadMatch;
+ }
+
+ if (((stuff->mask & (CWBorderPixmap | CWBorderPixel)) == 0) &&
+ (class != InputOnly) &&
+ (depth != pParent->drawable.depth))
+ {
+ return BadMatch;
+ }
+
+ if (((stuff->mask & CWColormap) == 0) &&
+ (class != InputOnly) &&
+ ((visual != ancwopt->visual) || (ancwopt->colormap == None)))
+ {
+ return BadMatch;
+ }
+
+ /* end of errors from CreateWindow */
+
+ pPriv = GetScreenPrivate (pScreen);
+ if (pPriv && pPriv->attr)
+ {
+ if (pPriv->attr->client != client)
+ return BadAccess;
+ }
+ if (!pPriv)
+ {
+ pPriv = MakeScreenPrivate (pScreen);
+ if (!pPriv)
+ return FALSE;
+ }
+ pAttr = New (ScreenSaverAttrRec);
+ if (!pAttr)
+ {
+ ret = BadAlloc;
+ goto bail;
+ }
+ /* over allocate for override redirect */
+ values = (unsigned long *) xalloc ((len + 1) * sizeof (unsigned long));
+ if (!values)
+ {
+ ret = BadAlloc;
+ goto bail;
+ }
+ pAttr->screen = pScreen;
+ pAttr->client = client;
+ pAttr->x = stuff->x;
+ pAttr->y = stuff->y;
+ pAttr->width = stuff->width;
+ pAttr->height = stuff->height;
+ pAttr->borderWidth = stuff->borderWidth;
+ pAttr->class = stuff->c_class;
+ pAttr->depth = depth;
+ pAttr->visual = visual;
+ pAttr->colormap = None;
+ pAttr->pCursor = NullCursor;
+ pAttr->pBackgroundPixmap = NullPixmap;
+ pAttr->pBorderPixmap = NullPixmap;
+ pAttr->values = values;
+ /*
+ * go through the mask, checking the values,
+ * looking up pixmaps and cursors and hold a reference
+ * to them.
+ */
+ pAttr->mask = tmask = stuff->mask | CWOverrideRedirect;
+ pVlist = (unsigned int *) (stuff + 1);
+ while (tmask) {
+ imask = lowbit (tmask);
+ tmask &= ~imask;
+ switch (imask)
+ {
+ case CWBackPixmap:
+ pixID = (Pixmap )*pVlist;
+ if (pixID == None)
+ {
+ *values++ = None;
+ }
+ else if (pixID == ParentRelative)
+ {
+ if (depth != pParent->drawable.depth)
+ {
+ ret = BadMatch;
+ goto PatchUp;
+ }
+ *values++ = ParentRelative;
+ }
+ else
+ {
+ pPixmap = (PixmapPtr)LookupIDByType(pixID, RT_PIXMAP);
+ if (pPixmap != (PixmapPtr) NULL)
+ {
+ if ((pPixmap->drawable.depth != depth) ||
+ (pPixmap->drawable.pScreen != pScreen))
+ {
+ ret = BadMatch;
+ goto PatchUp;
+ }
+ pAttr->pBackgroundPixmap = pPixmap;
+ pPixmap->refcnt++;
+ pAttr->mask &= ~CWBackPixmap;
+ }
+ else
+ {
+ ret = BadPixmap;
+ client->errorValue = pixID;
+ goto PatchUp;
+ }
+ }
+ break;
+ case CWBackPixel:
+ *values++ = (CARD32) *pVlist;
+ break;
+ case CWBorderPixmap:
+ pixID = (Pixmap ) *pVlist;
+ if (pixID == CopyFromParent)
+ {
+ if (depth != pParent->drawable.depth)
+ {
+ ret = BadMatch;
+ goto PatchUp;
+ }
+ *values++ = CopyFromParent;
+ }
+ else
+ {
+ pPixmap = (PixmapPtr)LookupIDByType(pixID, RT_PIXMAP);
+ if (pPixmap)
+ {
+ if ((pPixmap->drawable.depth != depth) ||
+ (pPixmap->drawable.pScreen != pScreen))
+ {
+ ret = BadMatch;
+ goto PatchUp;
+ }
+ pAttr->pBorderPixmap = pPixmap;
+ pPixmap->refcnt++;
+ pAttr->mask &= ~CWBorderPixmap;
+ }
+ else
+ {
+ ret = BadPixmap;
+ client->errorValue = pixID;
+ goto PatchUp;
+ }
+ }
+ break;
+ case CWBorderPixel:
+ *values++ = (CARD32) *pVlist;
+ break;
+ case CWBitGravity:
+ val = (CARD8 )*pVlist;
+ if (val > StaticGravity)
+ {
+ ret = BadValue;
+ client->errorValue = val;
+ goto PatchUp;
+ }
+ *values++ = val;
+ break;
+ case CWWinGravity:
+ val = (CARD8 )*pVlist;
+ if (val > StaticGravity)
+ {
+ ret = BadValue;
+ client->errorValue = val;
+ goto PatchUp;
+ }
+ *values++ = val;
+ break;
+ case CWBackingStore:
+ val = (CARD8 )*pVlist;
+ if ((val != NotUseful) && (val != WhenMapped) && (val != Always))
+ {
+ ret = BadValue;
+ client->errorValue = val;
+ goto PatchUp;
+ }
+ *values++ = val;
+ break;
+ case CWBackingPlanes:
+ *values++ = (CARD32) *pVlist;
+ break;
+ case CWBackingPixel:
+ *values++ = (CARD32) *pVlist;
+ break;
+ case CWSaveUnder:
+ val = (BOOL) *pVlist;
+ if ((val != xTrue) && (val != xFalse))
+ {
+ ret = BadValue;
+ client->errorValue = val;
+ goto PatchUp;
+ }
+ *values++ = val;
+ break;
+ case CWEventMask:
+ *values++ = (CARD32) *pVlist;
+ break;
+ case CWDontPropagate:
+ *values++ = (CARD32) *pVlist;
+ break;
+ case CWOverrideRedirect:
+ if (!(stuff->mask & CWOverrideRedirect))
+ pVlist--;
+ else
+ {
+ val = (BOOL ) *pVlist;
+ if ((val != xTrue) && (val != xFalse))
+ {
+ ret = BadValue;
+ client->errorValue = val;
+ goto PatchUp;
+ }
+ }
+ *values++ = xTrue;
+ break;
+ case CWColormap:
+ cmap = (Colormap) *pVlist;
+ pCmap = (ColormapPtr)LookupIDByType(cmap, RT_COLORMAP);
+ if (!pCmap)
+ {
+ ret = BadColor;
+ client->errorValue = cmap;
+ goto PatchUp;
+ }
+ if (pCmap->pVisual->vid != visual || pCmap->pScreen != pScreen)
+ {
+ ret = BadMatch;
+ goto PatchUp;
+ }
+ pAttr->colormap = cmap;
+ pAttr->mask &= ~CWColormap;
+ break;
+ case CWCursor:
+ cursorID = (Cursor ) *pVlist;
+ if ( cursorID == None)
+ {
+ *values++ = None;
+ }
+ else
+ {
+ pCursor = (CursorPtr)LookupIDByType(cursorID, RT_CURSOR);
+ if (!pCursor)
+ {
+ ret = BadCursor;
+ client->errorValue = cursorID;
+ goto PatchUp;
+ }
+ pCursor->refcnt++;
+ pAttr->pCursor = pCursor;
+ pAttr->mask &= ~CWCursor;
+ }
+ break;
+ default:
+ ret = BadValue;
+ client->errorValue = stuff->mask;
+ goto PatchUp;
+ }
+ pVlist++;
+ }
+ if (pPriv->attr)
+ FreeScreenAttr (pPriv->attr);
+ pPriv->attr = pAttr;
+ pAttr->resource = FakeClientID (client->index);
+ if (!AddResource (pAttr->resource, AttrType, (pointer) pAttr))
+ return BadAlloc;
+ return Success;
+PatchUp:
+ FreeAttrs (pAttr);
+bail:
+ CheckScreenPrivate (pScreen);
+ if (pAttr) xfree (pAttr->values);
+ xfree (pAttr);
+ return ret;
+}
+
+static int
+ScreenSaverUnsetAttributes (ClientPtr client)
+{
+ REQUEST(xScreenSaverSetAttributesReq);
+ DrawablePtr pDraw;
+ ScreenSaverScreenPrivatePtr pPriv;
+
+ REQUEST_SIZE_MATCH (xScreenSaverUnsetAttributesReq);
+ pDraw = (DrawablePtr) LookupDrawable (stuff->drawable, client);
+ if (!pDraw)
+ return BadDrawable;
+ pPriv = GetScreenPrivate (pDraw->pScreen);
+ if (pPriv && pPriv->attr && pPriv->attr->client == client)
+ {
+ FreeResource (pPriv->attr->resource, AttrType);
+ FreeScreenAttr (pPriv->attr);
+ pPriv->attr = NULL;
+ CheckScreenPrivate (pDraw->pScreen);
+ }
+ return Success;
+}
+
+static int
+ProcScreenSaverSetAttributes (ClientPtr client)
+{
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ REQUEST(xScreenSaverSetAttributesReq);
+ PanoramiXRes *draw;
+ PanoramiXRes *backPix = NULL;
+ PanoramiXRes *bordPix = NULL;
+ PanoramiXRes *cmap = NULL;
+ int i, status = 0, len;
+ int pback_offset = 0, pbord_offset = 0, cmap_offset = 0;
+ XID orig_visual, tmp;
+
+ REQUEST_AT_LEAST_SIZE (xScreenSaverSetAttributesReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2);
+ if (Ones(stuff->mask) != len)
+ return BadLength;
+
+ if((Mask)stuff->mask & CWBackPixmap) {
+ pback_offset = Ones((Mask)stuff->mask & (CWBackPixmap - 1));
+ tmp = *((CARD32 *) &stuff[1] + pback_offset);
+ if ((tmp != None) && (tmp != ParentRelative)) {
+ if(!(backPix = (PanoramiXRes*) SecurityLookupIDByType(
+ client, tmp, XRT_PIXMAP, SecurityReadAccess)))
+ return BadPixmap;
+ }
+ }
+
+ if ((Mask)stuff->mask & CWBorderPixmap) {
+ pbord_offset = Ones((Mask)stuff->mask & (CWBorderPixmap - 1));
+ tmp = *((CARD32 *) &stuff[1] + pbord_offset);
+ if (tmp != CopyFromParent) {
+ if(!(bordPix = (PanoramiXRes*) SecurityLookupIDByType(
+ client, tmp, XRT_PIXMAP, SecurityReadAccess)))
+ return BadPixmap;
+ }
+ }
+
+ if ((Mask)stuff->mask & CWColormap) {
+ cmap_offset = Ones((Mask)stuff->mask & (CWColormap - 1));
+ tmp = *((CARD32 *) &stuff[1] + cmap_offset);
+ if ((tmp != CopyFromParent) && (tmp != None)) {
+ if(!(cmap = (PanoramiXRes*) SecurityLookupIDByType(
+ client, tmp, XRT_COLORMAP, SecurityReadAccess)))
+ return BadColor;
+ }
+ }
+
+ orig_visual = stuff->visualID;
+
+ FOR_NSCREENS_BACKWARD(i) {
+ stuff->drawable = draw->info[i].id;
+ if (backPix)
+ *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[i].id;
+ if (bordPix)
+ *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[i].id;
+ if (cmap)
+ *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[i].id;
+
+ if (orig_visual != CopyFromParent)
+ stuff->visualID =
+ PanoramiXVisualTable[(orig_visual*MAXSCREENS) + i];
+
+ status = ScreenSaverSetAttributes(client);
+ }
+
+ return status;
+ }
+#endif
+
+ return ScreenSaverSetAttributes(client);
+}
+
+static int
+ProcScreenSaverUnsetAttributes (ClientPtr client)
+{
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ REQUEST(xScreenSaverUnsetAttributesReq);
+ PanoramiXRes *draw;
+ int i;
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ for(i = PanoramiXNumScreens - 1; i > 0; i--) {
+ stuff->drawable = draw->info[i].id;
+ ScreenSaverUnsetAttributes(client);
+ }
+
+ stuff->drawable = draw->info[0].id;
+ }
+#endif
+
+ return ScreenSaverUnsetAttributes(client);
+}
+
+static DISPATCH_PROC((*NormalVector[])) = {
+ ProcScreenSaverQueryVersion,
+ ProcScreenSaverQueryInfo,
+ ProcScreenSaverSelectInput,
+ ProcScreenSaverSetAttributes,
+ ProcScreenSaverUnsetAttributes,
+};
+
+#define NUM_REQUESTS ((sizeof NormalVector) / (sizeof NormalVector[0]))
+
+static int
+ProcScreenSaverDispatch (client)
+ ClientPtr client;
+{
+ REQUEST(xReq);
+
+ if (stuff->data < NUM_REQUESTS)
+ return (*NormalVector[stuff->data])(client);
+ return BadRequest;
+}
+
+static int
+SProcScreenSaverQueryVersion (client)
+ ClientPtr client;
+{
+ REQUEST(xScreenSaverQueryVersionReq);
+ int n;
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xScreenSaverQueryVersionReq);
+ return ProcScreenSaverQueryVersion (client);
+}
+
+static int
+SProcScreenSaverQueryInfo (client)
+ ClientPtr client;
+{
+ REQUEST(xScreenSaverQueryInfoReq);
+ int n;
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xScreenSaverQueryInfoReq);
+ swapl (&stuff->drawable, n);
+ return ProcScreenSaverQueryInfo (client);
+}
+
+static int
+SProcScreenSaverSelectInput (client)
+ ClientPtr client;
+{
+ REQUEST(xScreenSaverSelectInputReq);
+ int n;
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xScreenSaverSelectInputReq);
+ swapl (&stuff->drawable, n);
+ swapl (&stuff->eventMask, n);
+ return ProcScreenSaverSelectInput (client);
+}
+
+static int
+SProcScreenSaverSetAttributes (client)
+ ClientPtr client;
+{
+ REQUEST(xScreenSaverSetAttributesReq);
+ int n;
+
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq);
+ swapl (&stuff->drawable, n);
+ swaps (&stuff->x, n);
+ swaps (&stuff->y, n);
+ swaps (&stuff->width, n);
+ swaps (&stuff->height, n);
+ swaps (&stuff->borderWidth, n);
+ swapl (&stuff->visualID, n);
+ swapl (&stuff->mask, n);
+ SwapRestL(stuff);
+ return ProcScreenSaverSetAttributes (client);
+}
+
+static int
+SProcScreenSaverUnsetAttributes (client)
+ ClientPtr client;
+{
+ REQUEST(xScreenSaverUnsetAttributesReq);
+ int n;
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+ swapl (&stuff->drawable, n);
+ return ProcScreenSaverUnsetAttributes (client);
+}
+
+static DISPATCH_PROC((*SwappedVector[])) = {
+ SProcScreenSaverQueryVersion,
+ SProcScreenSaverQueryInfo,
+ SProcScreenSaverSelectInput,
+ SProcScreenSaverSetAttributes,
+ SProcScreenSaverUnsetAttributes,
+};
+
+static int
+SProcScreenSaverDispatch (client)
+ ClientPtr client;
+{
+ REQUEST(xReq);
+
+ if (stuff->data < NUM_REQUESTS)
+ return (*SwappedVector[stuff->data])(client);
+ return BadRequest;
+}
diff --git a/nx-X11/programs/Xserver/Xext/security.c b/nx-X11/programs/Xserver/Xext/security.c
new file mode 100644
index 000000000..f37be696b
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/security.c
@@ -0,0 +1,2241 @@
+/* $XdotOrg: xc/programs/Xserver/Xext/security.c,v 1.5 2005/07/03 07:01:04 daniels Exp $ */
+/* $Xorg: security.c,v 1.4 2001/02/09 02:04:32 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/Xext/security.c,v 1.16tsi Exp $ */
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "windowstr.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "colormapst.h"
+#include "propertyst.h"
+#define _SECURITY_SERVER
+#include <X11/extensions/securstr.h>
+#include <assert.h>
+#include <stdarg.h>
+#ifdef LBX
+#define _XLBX_SERVER_
+#include <X11/extensions/XLbx.h>
+extern unsigned char LbxReqCode;
+#endif
+#ifdef XAPPGROUP
+#include <X11/extensions/Xagsrv.h>
+#endif
+#include <stdio.h> /* for file reading operations */
+#include <X11/Xatom.h> /* for XA_STRING */
+
+#ifdef NXAGENT_SERVER
+
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#endif
+
+#ifndef DEFAULTPOLICYFILE
+# define DEFAULTPOLICYFILE NULL
+#endif
+
+#ifdef NXAGENT_SERVER
+
+#define NX_ALTERNATIVEPOLICYFILE "/usr/lib/xserver/SecurityPolicy"
+
+#endif
+
+#if defined(WIN32) || defined(__CYGWIN__)
+#include <X11/Xos.h>
+#undef index
+#endif
+
+/*
+ * Set here the required NX log level.
+ */
+
+#ifdef NXAGENT_SERVER
+
+#define PANIC
+#define WARNING
+#undef TEST
+#undef DEBUG
+
+#endif
+
+#ifdef NXAGENT_SERVER
+
+static char _NXPolicyFilePath[1024];
+
+#endif
+
+#include "modinit.h"
+
+static int SecurityErrorBase; /* first Security error number */
+static int SecurityEventBase; /* first Security event number */
+
+CallbackListPtr SecurityValidateGroupCallback = NULL; /* see security.h */
+
+RESTYPE SecurityAuthorizationResType; /* resource type for authorizations */
+
+static RESTYPE RTEventClient;
+
+/* Proc vectors for untrusted clients, swapped and unswapped versions.
+ * These are the same as the normal proc vectors except that extensions
+ * that haven't declared themselves secure will have ProcBadRequest plugged
+ * in for their major opcode dispatcher. This prevents untrusted clients
+ * from guessing extension major opcodes and using the extension even though
+ * the extension can't be listed or queried.
+ */
+int (*UntrustedProcVector[256])(
+ ClientPtr /*client*/
+);
+int (*SwappedUntrustedProcVector[256])(
+ ClientPtr /*client*/
+);
+
+#ifdef NXAGENT_SERVER
+
+/*
+ * This function returns the SecurityPolicy
+ * file full path. This path is referred by
+ * SecurityPolicyFile variable (generally it
+ * contains the hardcoded path at compile time).
+ * If the path does not exist, the function will
+ * try a set of well known paths.
+ */
+
+const char *_NXGetPolicyFilePath(const char *path)
+{
+
+ struct stat SecurityPolicyStat;
+
+ /*
+ * Check the policy file path only once.
+ */
+
+ if (*_NXPolicyFilePath != '\0')
+ {
+ return _NXPolicyFilePath;
+ }
+
+ if (stat(path, &SecurityPolicyStat) == 0)
+ {
+ if (strlen(path) + 1 > 1024)
+ {
+ #ifdef WARNING
+ fprintf(stderr, "_NXGetPolicyFilePath: WARNING! Maximum length of SecurityPolicy file path exceeded.\n");
+ #endif
+
+ goto _NXGetPolicyFilePathError;
+ }
+
+ strcpy(_NXPolicyFilePath, path);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetPolicyFilePath: Using SecurityPolicy file path [%s].\n",
+ _NXPolicyFilePath);
+ #endif
+
+ return _NXPolicyFilePath;
+ }
+
+ if (stat(DEFAULTPOLICYFILE, &SecurityPolicyStat) == 0)
+ {
+ if (strlen(DEFAULTPOLICYFILE) + 1 > 1024)
+ {
+ #ifdef WARNING
+ fprintf(stderr, "_NXGetPolicyFilePath: WARNING! Maximum length of SecurityPolicy file path exceeded.\n");
+ #endif
+
+ goto _NXGetPolicyFilePathError;
+ }
+
+ strcpy(_NXPolicyFilePath, DEFAULTPOLICYFILE);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetPolicyFilePath: Using SecurityPolicy file path [%s].\n",
+ _NXPolicyFilePath);
+ #endif
+
+ return _NXPolicyFilePath;
+ }
+
+ if (stat(NX_ALTERNATIVEPOLICYFILE, &SecurityPolicyStat) == 0)
+ {
+ if (strlen(NX_ALTERNATIVEPOLICYFILE) + 1 > 1024)
+ {
+ #ifdef WARNING
+ fprintf(stderr, "_NXGetPolicyFilePath: WARNING! Maximum length of SecurityPolicy file path exceeded.\n");
+ #endif
+
+ goto _NXGetPolicyFilePathError;
+ }
+
+ strcpy(_NXPolicyFilePath, NX_ALTERNATIVEPOLICYFILE);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetPolicyFilePath: Using SecurityPolicy file path [%s].\n",
+ _NXPolicyFilePath);
+ #endif
+
+ return _NXPolicyFilePath;
+ }
+
+_NXGetPolicyFilePathError:
+
+ if (strlen(path) + 1 > 1024)
+ {
+ #ifdef WARNING
+ fprintf(stderr, "_NXGetPolicyFilePath: WARNING! Maximum length of SecurityPolicy file exceeded.\n");
+ #endif
+ }
+
+ strcpy(_NXPolicyFilePath, path);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetPolicyFilePath: Using default SecurityPolicy file path [%s].\n",
+ _NXPolicyFilePath);
+ #endif
+
+ return _NXPolicyFilePath;
+}
+
+#endif
+
+/* SecurityAudit
+ *
+ * Arguments:
+ * format is the formatting string to be used to interpret the
+ * remaining arguments.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Writes the message to the log file if security logging is on.
+ */
+
+void
+SecurityAudit(char *format, ...)
+{
+ va_list args;
+
+ if (auditTrailLevel < SECURITY_AUDIT_LEVEL)
+ return;
+ va_start(args, format);
+ VAuditF(format, args);
+ va_end(args);
+} /* SecurityAudit */
+
+#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
+
+/* SecurityDeleteAuthorization
+ *
+ * Arguments:
+ * value is the authorization to delete.
+ * id is its resource ID.
+ *
+ * Returns: Success.
+ *
+ * Side Effects:
+ * Frees everything associated with the authorization.
+ */
+
+static int
+SecurityDeleteAuthorization(
+ pointer value,
+ XID id)
+{
+ SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)value;
+ unsigned short name_len, data_len;
+ char *name, *data;
+ int status;
+ int i;
+ OtherClientsPtr pEventClient;
+
+ /* Remove the auth using the os layer auth manager */
+
+ status = AuthorizationFromID(pAuth->id, &name_len, &name,
+ &data_len, &data);
+ assert(status);
+ status = RemoveAuthorization(name_len, name, data_len, data);
+ assert(status);
+ (void)status;
+
+ /* free the auth timer if there is one */
+
+ if (pAuth->timer) TimerFree(pAuth->timer);
+
+ /* send revoke events */
+
+ while ((pEventClient = pAuth->eventClients))
+ {
+ /* send revocation event event */
+ ClientPtr client = rClient(pEventClient);
+
+ if (!client->clientGone)
+ {
+ xSecurityAuthorizationRevokedEvent are;
+ are.type = SecurityEventBase + XSecurityAuthorizationRevoked;
+ are.sequenceNumber = client->sequence;
+ are.authId = pAuth->id;
+ WriteEventsToClient(client, 1, (xEvent *)&are);
+ }
+ FreeResource(pEventClient->resource, RT_NONE);
+ }
+
+ /* kill all clients using this auth */
+
+ for (i = 1; i<currentMaxClients; i++)
+ {
+ if (clients[i] && (clients[i]->authId == pAuth->id))
+ CloseDownClient(clients[i]);
+ }
+
+ SecurityAudit("revoked authorization ID %d\n", pAuth->id);
+ xfree(pAuth);
+ return Success;
+
+} /* SecurityDeleteAuthorization */
+
+
+/* resource delete function for RTEventClient */
+static int
+SecurityDeleteAuthorizationEventClient(
+ pointer value,
+ XID id)
+{
+ OtherClientsPtr pEventClient, prev = NULL;
+ SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)value;
+
+ for (pEventClient = pAuth->eventClients;
+ pEventClient;
+ pEventClient = pEventClient->next)
+ {
+ if (pEventClient->resource == id)
+ {
+ if (prev)
+ prev->next = pEventClient->next;
+ else
+ pAuth->eventClients = pEventClient->next;
+ xfree(pEventClient);
+ return(Success);
+ }
+ prev = pEventClient;
+ }
+ /*NOTREACHED*/
+ return -1; /* make compiler happy */
+} /* SecurityDeleteAuthorizationEventClient */
+
+
+/* SecurityComputeAuthorizationTimeout
+ *
+ * Arguments:
+ * pAuth is the authorization for which we are computing the timeout
+ * seconds is the number of seconds we want to wait
+ *
+ * Returns:
+ * the number of milliseconds that the auth timer should be set to
+ *
+ * Side Effects:
+ * Sets pAuth->secondsRemaining to any "overflow" amount of time
+ * that didn't fit in 32 bits worth of milliseconds
+ */
+
+static CARD32
+SecurityComputeAuthorizationTimeout(
+ SecurityAuthorizationPtr pAuth,
+ unsigned int seconds)
+{
+ /* maxSecs is the number of full seconds that can be expressed in
+ * 32 bits worth of milliseconds
+ */
+ CARD32 maxSecs = (CARD32)(~0) / (CARD32)MILLI_PER_SECOND;
+
+ if (seconds > maxSecs)
+ { /* only come here if we want to wait more than 49 days */
+ pAuth->secondsRemaining = seconds - maxSecs;
+ return maxSecs * MILLI_PER_SECOND;
+ }
+ else
+ { /* by far the common case */
+ pAuth->secondsRemaining = 0;
+ return seconds * MILLI_PER_SECOND;
+ }
+} /* SecurityStartAuthorizationTimer */
+
+/* SecurityAuthorizationExpired
+ *
+ * This function is passed as an argument to TimerSet and gets called from
+ * the timer manager in the os layer when its time is up.
+ *
+ * Arguments:
+ * timer is the timer for this authorization.
+ * time is the current time.
+ * pval is the authorization whose time is up.
+ *
+ * Returns:
+ * A new time delay in milliseconds if the timer should wait some
+ * more, else zero.
+ *
+ * Side Effects:
+ * Frees the authorization resource if the timeout period is really
+ * over, otherwise recomputes pAuth->secondsRemaining.
+ */
+
+static CARD32
+SecurityAuthorizationExpired(
+ OsTimerPtr timer,
+ CARD32 time,
+ pointer pval)
+{
+ SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)pval;
+
+ assert(pAuth->timer == timer);
+
+ if (pAuth->secondsRemaining)
+ {
+ return SecurityComputeAuthorizationTimeout(pAuth,
+ pAuth->secondsRemaining);
+ }
+ else
+ {
+ FreeResource(pAuth->id, RT_NONE);
+ return 0;
+ }
+} /* SecurityAuthorizationExpired */
+
+/* SecurityStartAuthorizationTimer
+ *
+ * Arguments:
+ * pAuth is the authorization whose timer should be started.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * A timer is started, set to expire after the timeout period for
+ * this authorization. When it expires, the function
+ * SecurityAuthorizationExpired will be called.
+ */
+
+static void
+SecurityStartAuthorizationTimer(
+ SecurityAuthorizationPtr pAuth)
+{
+ pAuth->timer = TimerSet(pAuth->timer, 0,
+ SecurityComputeAuthorizationTimeout(pAuth, pAuth->timeout),
+ SecurityAuthorizationExpired, pAuth);
+} /* SecurityStartAuthorizationTimer */
+
+
+/* Proc functions all take a client argument, execute the request in
+ * client->requestBuffer, and return a protocol error status.
+ */
+
+static int
+ProcSecurityQueryVersion(
+ ClientPtr client)
+{
+ /* REQUEST(xSecurityQueryVersionReq); */
+ xSecurityQueryVersionReply rep;
+
+ /* paranoia: this "can't happen" because this extension is hidden
+ * from untrusted clients, but just in case...
+ */
+ if (client->trustLevel != XSecurityClientTrusted)
+ return BadRequest;
+
+ REQUEST_SIZE_MATCH(xSecurityQueryVersionReq);
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.majorVersion = SECURITY_MAJOR_VERSION;
+ rep.minorVersion = SECURITY_MINOR_VERSION;
+ if(client->swapped)
+ {
+ register char n;
+ swaps(&rep.sequenceNumber, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ }
+ (void)WriteToClient(client, SIZEOF(xSecurityQueryVersionReply),
+ (char *)&rep);
+ return (client->noClientException);
+} /* ProcSecurityQueryVersion */
+
+
+static int
+SecurityEventSelectForAuthorization(
+ SecurityAuthorizationPtr pAuth,
+ ClientPtr client,
+ Mask mask)
+{
+ OtherClients *pEventClient;
+
+ for (pEventClient = pAuth->eventClients;
+ pEventClient;
+ pEventClient = pEventClient->next)
+ {
+ if (SameClient(pEventClient, client))
+ {
+ if (mask == 0)
+ FreeResource(pEventClient->resource, RT_NONE);
+ else
+ pEventClient->mask = mask;
+ return Success;
+ }
+ }
+
+ pEventClient = (OtherClients *) xalloc(sizeof(OtherClients));
+ if (!pEventClient)
+ return BadAlloc;
+ pEventClient->mask = mask;
+ pEventClient->resource = FakeClientID(client->index);
+ pEventClient->next = pAuth->eventClients;
+ if (!AddResource(pEventClient->resource, RTEventClient,
+ (pointer)pAuth))
+ {
+ xfree(pEventClient);
+ return BadAlloc;
+ }
+ pAuth->eventClients = pEventClient;
+
+ return Success;
+} /* SecurityEventSelectForAuthorization */
+
+
+static int
+ProcSecurityGenerateAuthorization(
+ ClientPtr client)
+{
+ REQUEST(xSecurityGenerateAuthorizationReq);
+ int len; /* request length in CARD32s*/
+ Bool removeAuth = FALSE; /* if bailout, call RemoveAuthorization? */
+ SecurityAuthorizationPtr pAuth = NULL; /* auth we are creating */
+ int err; /* error to return from this function */
+ XID authId; /* authorization ID assigned by os layer */
+ xSecurityGenerateAuthorizationReply rep; /* reply struct */
+ unsigned int trustLevel; /* trust level of new auth */
+ XID group; /* group of new auth */
+ CARD32 timeout; /* timeout of new auth */
+ CARD32 *values; /* list of supplied attributes */
+ char *protoname; /* auth proto name sent in request */
+ char *protodata; /* auth proto data sent in request */
+ unsigned int authdata_len; /* # bytes of generated auth data */
+ char *pAuthdata; /* generated auth data */
+ Mask eventMask; /* what events on this auth does client want */
+
+ /* paranoia: this "can't happen" because this extension is hidden
+ * from untrusted clients, but just in case...
+ */
+ if (client->trustLevel != XSecurityClientTrusted)
+ return BadRequest;
+
+ /* check request length */
+
+ REQUEST_AT_LEAST_SIZE(xSecurityGenerateAuthorizationReq);
+ len = SIZEOF(xSecurityGenerateAuthorizationReq) >> 2;
+ len += (stuff->nbytesAuthProto + (unsigned)3) >> 2;
+ len += (stuff->nbytesAuthData + (unsigned)3) >> 2;
+ values = ((CARD32 *)stuff) + len;
+ len += Ones(stuff->valueMask);
+ if (client->req_len != len)
+ return BadLength;
+
+ /* check valuemask */
+ if (stuff->valueMask & ~XSecurityAllAuthorizationAttributes)
+ {
+ client->errorValue = stuff->valueMask;
+ return BadValue;
+ }
+
+ /* check timeout */
+ timeout = 60;
+ if (stuff->valueMask & XSecurityTimeout)
+ {
+ timeout = *values++;
+ }
+
+ /* check trustLevel */
+ trustLevel = XSecurityClientUntrusted;
+ if (stuff->valueMask & XSecurityTrustLevel)
+ {
+ trustLevel = *values++;
+ if (trustLevel != XSecurityClientTrusted &&
+ trustLevel != XSecurityClientUntrusted)
+ {
+ client->errorValue = trustLevel;
+ return BadValue;
+ }
+ }
+
+ /* check group */
+ group = None;
+ if (stuff->valueMask & XSecurityGroup)
+ {
+ group = *values++;
+ if (SecurityValidateGroupCallback)
+ {
+ SecurityValidateGroupInfoRec vgi;
+ vgi.group = group;
+ vgi.valid = FALSE;
+ CallCallbacks(&SecurityValidateGroupCallback, (pointer)&vgi);
+
+ /* if nobody said they recognized it, it's an error */
+
+ if (!vgi.valid)
+ {
+ client->errorValue = group;
+ return BadValue;
+ }
+ }
+ }
+
+ /* check event mask */
+ eventMask = 0;
+ if (stuff->valueMask & XSecurityEventMask)
+ {
+ eventMask = *values++;
+ if (eventMask & ~XSecurityAllEventMasks)
+ {
+ client->errorValue = eventMask;
+ return BadValue;
+ }
+ }
+
+ protoname = (char *)&stuff[1];
+ protodata = protoname + ((stuff->nbytesAuthProto + (unsigned)3) >> 2);
+
+ /* call os layer to generate the authorization */
+
+ authId = GenerateAuthorization(stuff->nbytesAuthProto, protoname,
+ stuff->nbytesAuthData, protodata,
+ &authdata_len, &pAuthdata);
+ if ((XID) ~0L == authId)
+ {
+ err = SecurityErrorBase + XSecurityBadAuthorizationProtocol;
+ goto bailout;
+ }
+
+ /* now that we've added the auth, remember to remove it if we have to
+ * abort the request for some reason (like allocation failure)
+ */
+ removeAuth = TRUE;
+
+ /* associate additional information with this auth ID */
+
+ pAuth = (SecurityAuthorizationPtr)xalloc(sizeof(SecurityAuthorizationRec));
+ if (!pAuth)
+ {
+ err = BadAlloc;
+ goto bailout;
+ }
+
+ /* fill in the auth fields */
+
+ pAuth->id = authId;
+ pAuth->timeout = timeout;
+ pAuth->group = group;
+ pAuth->trustLevel = trustLevel;
+ pAuth->refcnt = 0; /* the auth was just created; nobody's using it yet */
+ pAuth->secondsRemaining = 0;
+ pAuth->timer = NULL;
+ pAuth->eventClients = NULL;
+
+ /* handle event selection */
+ if (eventMask)
+ {
+ err = SecurityEventSelectForAuthorization(pAuth, client, eventMask);
+ if (err != Success)
+ goto bailout;
+ }
+
+ if (!AddResource(authId, SecurityAuthorizationResType, pAuth))
+ {
+ err = BadAlloc;
+ goto bailout;
+ }
+
+ /* start the timer ticking */
+
+ if (pAuth->timeout != 0)
+ SecurityStartAuthorizationTimer(pAuth);
+
+ /* tell client the auth id and data */
+
+ rep.type = X_Reply;
+ rep.length = (authdata_len + 3) >> 2;
+ rep.sequenceNumber = client->sequence;
+ rep.authId = authId;
+ rep.dataLength = authdata_len;
+
+ if (client->swapped)
+ {
+ register char n;
+ swapl(&rep.length, n);
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.authId, n);
+ swaps(&rep.dataLength, n);
+ }
+
+ WriteToClient(client, SIZEOF(xSecurityGenerateAuthorizationReply),
+ (char *)&rep);
+ WriteToClient(client, authdata_len, pAuthdata);
+
+ SecurityAudit("client %d generated authorization %d trust %d timeout %d group %d events %d\n",
+ client->index, pAuth->id, pAuth->trustLevel, pAuth->timeout,
+ pAuth->group, eventMask);
+
+ /* the request succeeded; don't call RemoveAuthorization or free pAuth */
+
+ removeAuth = FALSE;
+ pAuth = NULL;
+ err = client->noClientException;
+
+bailout:
+ if (removeAuth)
+ RemoveAuthorization(stuff->nbytesAuthProto, protoname,
+ authdata_len, pAuthdata);
+ if (pAuth) xfree(pAuth);
+ return err;
+
+} /* ProcSecurityGenerateAuthorization */
+
+static int
+ProcSecurityRevokeAuthorization(
+ ClientPtr client)
+{
+ REQUEST(xSecurityRevokeAuthorizationReq);
+ SecurityAuthorizationPtr pAuth;
+
+ /* paranoia: this "can't happen" because this extension is hidden
+ * from untrusted clients, but just in case...
+ */
+ if (client->trustLevel != XSecurityClientTrusted)
+ return BadRequest;
+
+ REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq);
+
+ pAuth = (SecurityAuthorizationPtr)SecurityLookupIDByType(client,
+ stuff->authId, SecurityAuthorizationResType, SecurityDestroyAccess);
+ if (!pAuth)
+ return SecurityErrorBase + XSecurityBadAuthorization;
+
+ FreeResource(stuff->authId, RT_NONE);
+ return Success;
+} /* ProcSecurityRevokeAuthorization */
+
+
+static int
+ProcSecurityDispatch(
+ ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_SecurityQueryVersion:
+ return ProcSecurityQueryVersion(client);
+ case X_SecurityGenerateAuthorization:
+ return ProcSecurityGenerateAuthorization(client);
+ case X_SecurityRevokeAuthorization:
+ return ProcSecurityRevokeAuthorization(client);
+ default:
+ return BadRequest;
+ }
+} /* ProcSecurityDispatch */
+
+static int
+SProcSecurityQueryVersion(
+ ClientPtr client)
+{
+ REQUEST(xSecurityQueryVersionReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSecurityQueryVersionReq);
+ swaps(&stuff->majorVersion, n);
+ swaps(&stuff->minorVersion,n);
+ return ProcSecurityQueryVersion(client);
+} /* SProcSecurityQueryVersion */
+
+
+static int
+SProcSecurityGenerateAuthorization(
+ ClientPtr client)
+{
+ REQUEST(xSecurityGenerateAuthorizationReq);
+ register char n;
+ CARD32 *values;
+ unsigned long nvalues;
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSecurityGenerateAuthorizationReq);
+ swaps(&stuff->nbytesAuthProto, n);
+ swaps(&stuff->nbytesAuthData, n);
+ swapl(&stuff->valueMask, n);
+ values = (CARD32 *)(&stuff[1]) +
+ ((stuff->nbytesAuthProto + (unsigned)3) >> 2) +
+ ((stuff->nbytesAuthData + (unsigned)3) >> 2);
+ nvalues = (((CARD32 *)stuff) + stuff->length) - values;
+ SwapLongs(values, nvalues);
+ return ProcSecurityGenerateAuthorization(client);
+} /* SProcSecurityGenerateAuthorization */
+
+
+static int
+SProcSecurityRevokeAuthorization(
+ ClientPtr client)
+{
+ REQUEST(xSecurityRevokeAuthorizationReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq);
+ swapl(&stuff->authId, n);
+ return ProcSecurityRevokeAuthorization(client);
+} /* SProcSecurityRevokeAuthorization */
+
+
+static int
+SProcSecurityDispatch(
+ ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_SecurityQueryVersion:
+ return SProcSecurityQueryVersion(client);
+ case X_SecurityGenerateAuthorization:
+ return SProcSecurityGenerateAuthorization(client);
+ case X_SecurityRevokeAuthorization:
+ return SProcSecurityRevokeAuthorization(client);
+ default:
+ return BadRequest;
+ }
+} /* SProcSecurityDispatch */
+
+static void
+SwapSecurityAuthorizationRevokedEvent(
+ xSecurityAuthorizationRevokedEvent *from,
+ xSecurityAuthorizationRevokedEvent *to)
+{
+ to->type = from->type;
+ to->detail = from->detail;
+ cpswaps(from->sequenceNumber, to->sequenceNumber);
+ cpswapl(from->authId, to->authId);
+}
+
+/* SecurityDetermineEventPropogationLimits
+ *
+ * This is a helper function for SecurityCheckDeviceAccess.
+ *
+ * Arguments:
+ * dev is the device for which the starting and stopping windows for
+ * event propogation should be determined.
+ * The values pointed to by ppWin and ppStopWin are not used.
+ *
+ * Returns:
+ * ppWin is filled in with a pointer to the window at which event
+ * propogation for the given device should start given the current
+ * state of the server (pointer position, window layout, etc.)
+ * ppStopWin is filled in with the window at which event propogation
+ * should stop; events should not go to ppStopWin.
+ *
+ * Side Effects: none.
+ */
+
+static void
+SecurityDetermineEventPropogationLimits(
+ DeviceIntPtr dev,
+ WindowPtr *ppWin,
+ WindowPtr *ppStopWin)
+{
+ WindowPtr pFocusWin = dev->focus ? dev->focus->win : NoneWin;
+
+ if (pFocusWin == NoneWin)
+ { /* no focus -- events don't go anywhere */
+ *ppWin = *ppStopWin = NULL;
+ return;
+ }
+
+ if (pFocusWin == PointerRootWin)
+ { /* focus follows the pointer */
+ *ppWin = GetSpriteWindow();
+ *ppStopWin = NULL; /* propogate all the way to the root */
+ }
+ else
+ { /* a real window is set for the focus */
+ WindowPtr pSpriteWin = GetSpriteWindow();
+ *ppStopWin = pFocusWin->parent; /* don't go past the focus window */
+
+ /* if the pointer is in a subwindow of the focus window, start
+ * at that subwindow, else start at the focus window itself
+ */
+ if (IsParent(pFocusWin, pSpriteWin))
+ *ppWin = pSpriteWin;
+ else *ppWin = pFocusWin;
+ }
+} /* SecurityDetermineEventPropogationLimits */
+
+
+/* SecurityCheckDeviceAccess
+ *
+ * Arguments:
+ * client is the client attempting to access a device.
+ * dev is the device being accessed.
+ * fromRequest is TRUE if the device access is a direct result of
+ * the client executing some request and FALSE if it is a
+ * result of the server trying to send an event (e.g. KeymapNotify)
+ * to the client.
+ * Returns:
+ * TRUE if the device access should be allowed, else FALSE.
+ *
+ * Side Effects:
+ * An audit message is generated if access is denied.
+ */
+
+Bool
+SecurityCheckDeviceAccess(client, dev, fromRequest)
+ ClientPtr client;
+ DeviceIntPtr dev;
+ Bool fromRequest;
+{
+ WindowPtr pWin, pStopWin;
+ Bool untrusted_got_event;
+ Bool found_event_window;
+ Mask eventmask;
+ int reqtype = 0;
+
+ /* trusted clients always allowed to do anything */
+ if (client->trustLevel == XSecurityClientTrusted)
+ return TRUE;
+
+ /* device security other than keyboard is not implemented yet */
+ if (dev != inputInfo.keyboard)
+ return TRUE;
+
+ /* some untrusted client wants access */
+
+ if (fromRequest)
+ {
+ reqtype = ((xReq *)client->requestBuffer)->reqType;
+ switch (reqtype)
+ {
+ /* never allow these */
+ case X_ChangeKeyboardMapping:
+ case X_ChangeKeyboardControl:
+ case X_SetModifierMapping:
+ SecurityAudit("client %d attempted request %d\n",
+ client->index, reqtype);
+ return FALSE;
+ default:
+ break;
+ }
+ }
+
+ untrusted_got_event = FALSE;
+ found_event_window = FALSE;
+
+ if (dev->grab)
+ {
+ untrusted_got_event =
+ ((rClient(dev->grab))->trustLevel != XSecurityClientTrusted);
+ }
+ else
+ {
+ SecurityDetermineEventPropogationLimits(dev, &pWin, &pStopWin);
+
+ eventmask = KeyPressMask | KeyReleaseMask;
+ while ( (pWin != pStopWin) && !found_event_window)
+ {
+ OtherClients *other;
+
+ if (pWin->eventMask & eventmask)
+ {
+ found_event_window = TRUE;
+ client = wClient(pWin);
+ if (client->trustLevel != XSecurityClientTrusted)
+ {
+ untrusted_got_event = TRUE;
+ }
+ }
+ if (wOtherEventMasks(pWin) & eventmask)
+ {
+ found_event_window = TRUE;
+ for (other = wOtherClients(pWin); other; other = other->next)
+ {
+ if (other->mask & eventmask)
+ {
+ client = rClient(other);
+ if (client->trustLevel != XSecurityClientTrusted)
+ {
+ untrusted_got_event = TRUE;
+ break;
+ }
+ }
+ }
+ }
+ if (wDontPropagateMask(pWin) & eventmask)
+ break;
+ pWin = pWin->parent;
+ } /* while propogating the event */
+ }
+
+ /* allow access by untrusted clients only if an event would have gone
+ * to an untrusted client
+ */
+
+ if (!untrusted_got_event)
+ {
+ char *devname = dev->name;
+ if (!devname) devname = "unnamed";
+ if (fromRequest)
+ SecurityAudit("client %d attempted request %d device %d (%s)\n",
+ client->index, reqtype, dev->id, devname);
+ else
+ SecurityAudit("client %d attempted to access device %d (%s)\n",
+ client->index, dev->id, devname);
+ }
+ return untrusted_got_event;
+} /* SecurityCheckDeviceAccess */
+
+
+
+/* SecurityAuditResourceIDAccess
+ *
+ * Arguments:
+ * client is the client doing the resource access.
+ * id is the resource id.
+ *
+ * Returns: NULL
+ *
+ * Side Effects:
+ * An audit message is generated with details of the denied
+ * resource access.
+ */
+
+static pointer
+SecurityAuditResourceIDAccess(
+ ClientPtr client,
+ XID id)
+{
+ int cid = CLIENT_ID(id);
+ int reqtype = ((xReq *)client->requestBuffer)->reqType;
+ switch (reqtype)
+ {
+ case X_ChangeProperty:
+ case X_DeleteProperty:
+ case X_GetProperty:
+ {
+ xChangePropertyReq *req =
+ (xChangePropertyReq *)client->requestBuffer;
+ int propertyatom = req->property;
+ char *propertyname = NameForAtom(propertyatom);
+
+ SecurityAudit("client %d attempted request %d with window 0x%x property %s of client %d\n",
+ client->index, reqtype, id, propertyname, cid);
+ break;
+ }
+ default:
+ {
+ SecurityAudit("client %d attempted request %d with resource 0x%x of client %d\n",
+ client->index, reqtype, id, cid);
+ break;
+ }
+ }
+ return NULL;
+} /* SecurityAuditResourceIDAccess */
+
+
+/* SecurityCheckResourceIDAccess
+ *
+ * This function gets plugged into client->CheckAccess and is called from
+ * SecurityLookupIDByType/Class to determine if the client can access the
+ * resource.
+ *
+ * Arguments:
+ * client is the client doing the resource access.
+ * id is the resource id.
+ * rtype is its type or class.
+ * access_mode represents the intended use of the resource; see
+ * resource.h.
+ * rval is a pointer to the resource structure for this resource.
+ *
+ * Returns:
+ * If access is granted, the value of rval that was passed in, else NULL.
+ *
+ * Side Effects:
+ * Disallowed resource accesses are audited.
+ */
+
+static pointer
+SecurityCheckResourceIDAccess(
+ ClientPtr client,
+ XID id,
+ RESTYPE rtype,
+ Mask access_mode,
+ pointer rval)
+{
+ int cid = CLIENT_ID(id);
+ int reqtype = ((xReq *)client->requestBuffer)->reqType;
+
+ if (SecurityUnknownAccess == access_mode)
+ return rval; /* for compatibility, we have to allow access */
+
+ switch (reqtype)
+ { /* these are always allowed */
+ case X_QueryTree:
+ case X_TranslateCoords:
+ case X_GetGeometry:
+ /* property access is controlled in SecurityCheckPropertyAccess */
+ case X_GetProperty:
+ case X_ChangeProperty:
+ case X_DeleteProperty:
+ case X_RotateProperties:
+ case X_ListProperties:
+ return rval;
+ default:
+ break;
+ }
+
+ if (cid != 0)
+ { /* not a server-owned resource */
+ /*
+ * The following 'if' restricts clients to only access resources at
+ * the same trustLevel. Since there are currently only two trust levels,
+ * and trusted clients never call this function, this degenerates into
+ * saying that untrusted clients can only access resources of other
+ * untrusted clients. One way to add the notion of groups would be to
+ * allow values other than Trusted (0) and Untrusted (1) for this field.
+ * Clients at the same trust level would be able to use each other's
+ * resources, but not those of clients at other trust levels. I haven't
+ * tried it, but this probably mostly works already. The obvious
+ * competing alternative for grouping clients for security purposes is to
+ * use app groups. dpw
+ */
+ if (client->trustLevel == clients[cid]->trustLevel
+#ifdef XAPPGROUP
+ || (RT_COLORMAP == rtype &&
+ XagDefaultColormap (client) == (Colormap) id)
+#endif
+ )
+ return rval;
+ else
+ return SecurityAuditResourceIDAccess(client, id);
+ }
+ else /* server-owned resource - probably a default colormap or root window */
+ {
+ if (RT_WINDOW == rtype || RC_DRAWABLE == rtype)
+ {
+ switch (reqtype)
+ { /* the following operations are allowed on root windows */
+ case X_CreatePixmap:
+ case X_CreateGC:
+ case X_CreateWindow:
+ case X_CreateColormap:
+ case X_ListProperties:
+ case X_GrabPointer:
+ case X_UngrabButton:
+ case X_QueryBestSize:
+ case X_GetWindowAttributes:
+ break;
+ case X_SendEvent:
+ { /* see if it is an event specified by the ICCCM */
+ xSendEventReq *req = (xSendEventReq *)
+ (client->requestBuffer);
+ if (req->propagate == xTrue
+ ||
+ (req->eventMask != ColormapChangeMask &&
+ req->eventMask != StructureNotifyMask &&
+ req->eventMask !=
+ (SubstructureRedirectMask|SubstructureNotifyMask)
+ )
+ ||
+ (req->event.u.u.type != UnmapNotify &&
+ req->event.u.u.type != ConfigureRequest &&
+ req->event.u.u.type != ClientMessage
+ )
+ )
+ { /* not an ICCCM event */
+ return SecurityAuditResourceIDAccess(client, id);
+ }
+ break;
+ } /* case X_SendEvent on root */
+
+ case X_ChangeWindowAttributes:
+ { /* Allow selection of PropertyNotify and StructureNotify
+ * events on the root.
+ */
+ xChangeWindowAttributesReq *req =
+ (xChangeWindowAttributesReq *)(client->requestBuffer);
+ if (req->valueMask == CWEventMask)
+ {
+ CARD32 value = *((CARD32 *)(req + 1));
+ if ( (value &
+ ~(PropertyChangeMask|StructureNotifyMask)) == 0)
+ break;
+ }
+ return SecurityAuditResourceIDAccess(client, id);
+ } /* case X_ChangeWindowAttributes on root */
+
+ default:
+ {
+#ifdef LBX
+ /* XXX really need per extension dispatching */
+ if (reqtype == LbxReqCode) {
+ switch (((xReq *)client->requestBuffer)->data) {
+ case X_LbxGetProperty:
+ case X_LbxChangeProperty:
+ return rval;
+ default:
+ break;
+ }
+ }
+#endif
+ /* others not allowed */
+ return SecurityAuditResourceIDAccess(client, id);
+ }
+ }
+ } /* end server-owned window or drawable */
+ else if (SecurityAuthorizationResType == rtype)
+ {
+ SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)rval;
+ if (pAuth->trustLevel != client->trustLevel)
+ return SecurityAuditResourceIDAccess(client, id);
+ }
+ else if (RT_COLORMAP != rtype)
+ { /* don't allow anything else besides colormaps */
+ return SecurityAuditResourceIDAccess(client, id);
+ }
+ }
+ return rval;
+} /* SecurityCheckResourceIDAccess */
+
+
+/* SecurityClientStateCallback
+ *
+ * Arguments:
+ * pcbl is &ClientStateCallback.
+ * nullata is NULL.
+ * calldata is a pointer to a NewClientInfoRec (include/dixstruct.h)
+ * which contains information about client state changes.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ *
+ * If a new client is connecting, its authorization ID is copied to
+ * client->authID. If this is a generated authorization, its reference
+ * count is bumped, its timer is cancelled if it was running, and its
+ * trustlevel is copied to client->trustLevel.
+ *
+ * If a client is disconnecting and the client was using a generated
+ * authorization, the authorization's reference count is decremented, and
+ * if it is now zero, the timer for this authorization is started.
+ */
+
+static void
+SecurityClientStateCallback(
+ CallbackListPtr *pcbl,
+ pointer nulldata,
+ pointer calldata)
+{
+ NewClientInfoRec *pci = (NewClientInfoRec *)calldata;
+ ClientPtr client = pci->client;
+
+ switch (client->clientState)
+ {
+ case ClientStateRunning:
+ {
+ XID authId = AuthorizationIDOfClient(client);
+ SecurityAuthorizationPtr pAuth;
+
+ client->authId = authId;
+ pAuth = (SecurityAuthorizationPtr)LookupIDByType(authId,
+ SecurityAuthorizationResType);
+ if (pAuth)
+ { /* it is a generated authorization */
+ pAuth->refcnt++;
+ if (pAuth->refcnt == 1)
+ {
+ if (pAuth->timer) TimerCancel(pAuth->timer);
+ }
+ client->trustLevel = pAuth->trustLevel;
+ if (client->trustLevel != XSecurityClientTrusted)
+ {
+ client->CheckAccess = SecurityCheckResourceIDAccess;
+ client->requestVector = client->swapped ?
+ SwappedUntrustedProcVector : UntrustedProcVector;
+ }
+ }
+ break;
+ }
+ case ClientStateGone:
+ case ClientStateRetained: /* client disconnected */
+ {
+ XID authId = client->authId;
+ SecurityAuthorizationPtr pAuth;
+
+ pAuth = (SecurityAuthorizationPtr)LookupIDByType(authId,
+ SecurityAuthorizationResType);
+ if (pAuth)
+ { /* it is a generated authorization */
+ pAuth->refcnt--;
+ if (pAuth->refcnt == 0)
+ {
+ SecurityStartAuthorizationTimer(pAuth);
+ }
+ }
+ break;
+ }
+ default: break;
+ }
+} /* SecurityClientStateCallback */
+
+#ifdef LBX
+Bool
+SecuritySameLevel(client, authId)
+ ClientPtr client;
+ XID authId;
+{
+ SecurityAuthorizationPtr pAuth;
+
+ pAuth = (SecurityAuthorizationPtr)LookupIDByType(authId,
+ SecurityAuthorizationResType);
+ if (pAuth)
+ return client->trustLevel == pAuth->trustLevel;
+ return client->trustLevel == XSecurityClientTrusted;
+}
+#endif
+
+/* SecurityCensorImage
+ *
+ * Called after pScreen->GetImage to prevent pieces or trusted windows from
+ * being returned in image data from an untrusted window.
+ *
+ * Arguments:
+ * client is the client doing the GetImage.
+ * pVisibleRegion is the visible region of the window.
+ * widthBytesLine is the width in bytes of one horizontal line in pBuf.
+ * pDraw is the source window.
+ * x, y, w, h is the rectangle of image data from pDraw in pBuf.
+ * format is the format of the image data in pBuf: ZPixmap or XYPixmap.
+ * pBuf is the image data.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Any part of the rectangle (x, y, w, h) that is outside the visible
+ * region of the window will be destroyed (overwritten) in pBuf.
+ */
+void
+SecurityCensorImage(client, pVisibleRegion, widthBytesLine, pDraw, x, y, w, h,
+ format, pBuf)
+ ClientPtr client;
+ RegionPtr pVisibleRegion;
+ long widthBytesLine;
+ DrawablePtr pDraw;
+ int x, y, w, h;
+ unsigned int format;
+ char * pBuf;
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ RegionRec imageRegion; /* region representing x,y,w,h */
+ RegionRec censorRegion; /* region to obliterate */
+ BoxRec imageBox;
+ int nRects;
+
+ imageBox.x1 = x;
+ imageBox.y1 = y;
+ imageBox.x2 = x + w;
+ imageBox.y2 = y + h;
+ REGION_INIT(pScreen, &imageRegion, &imageBox, 1);
+ REGION_NULL(pScreen, &censorRegion);
+
+ /* censorRegion = imageRegion - visibleRegion */
+ REGION_SUBTRACT(pScreen, &censorRegion, &imageRegion, pVisibleRegion);
+ nRects = REGION_NUM_RECTS(&censorRegion);
+ if (nRects > 0)
+ { /* we have something to censor */
+ GCPtr pScratchGC = NULL;
+ PixmapPtr pPix = NULL;
+ xRectangle *pRects = NULL;
+ Bool failed = FALSE;
+ int depth = 1;
+ int bitsPerPixel = 1;
+ int i;
+ BoxPtr pBox;
+
+ /* convert region to list-of-rectangles for PolyFillRect */
+
+ pRects = (xRectangle *)ALLOCATE_LOCAL(nRects * sizeof(xRectangle *));
+ if (!pRects)
+ {
+ failed = TRUE;
+ goto failSafe;
+ }
+ for (pBox = REGION_RECTS(&censorRegion), i = 0;
+ i < nRects;
+ i++, pBox++)
+ {
+ pRects[i].x = pBox->x1;
+ pRects[i].y = pBox->y1 - imageBox.y1;
+ pRects[i].width = pBox->x2 - pBox->x1;
+ pRects[i].height = pBox->y2 - pBox->y1;
+ }
+
+ /* use pBuf as a fake pixmap */
+
+ if (format == ZPixmap)
+ {
+ depth = pDraw->depth;
+ bitsPerPixel = pDraw->bitsPerPixel;
+ }
+
+ pPix = GetScratchPixmapHeader(pDraw->pScreen, w, h,
+ depth, bitsPerPixel,
+ widthBytesLine, (pointer)pBuf);
+ if (!pPix)
+ {
+ failed = TRUE;
+ goto failSafe;
+ }
+
+ pScratchGC = GetScratchGC(depth, pPix->drawable.pScreen);
+ if (!pScratchGC)
+ {
+ failed = TRUE;
+ goto failSafe;
+ }
+
+ ValidateGC(&pPix->drawable, pScratchGC);
+ (* pScratchGC->ops->PolyFillRect)(&pPix->drawable,
+ pScratchGC, nRects, pRects);
+
+ failSafe:
+ if (failed)
+ {
+ /* Censoring was not completed above. To be safe, wipe out
+ * all the image data so that nothing trusted gets out.
+ */
+ bzero(pBuf, (int)(widthBytesLine * h));
+ }
+ if (pRects) DEALLOCATE_LOCAL(pRects);
+ if (pScratchGC) FreeScratchGC(pScratchGC);
+ if (pPix) FreeScratchPixmapHeader(pPix);
+ }
+ REGION_UNINIT(pScreen, &imageRegion);
+ REGION_UNINIT(pScreen, &censorRegion);
+} /* SecurityCensorImage */
+
+/**********************************************************************/
+
+typedef struct _PropertyAccessRec {
+ ATOM name;
+ ATOM mustHaveProperty;
+ char *mustHaveValue;
+ char windowRestriction;
+#define SecurityAnyWindow 0
+#define SecurityRootWindow 1
+#define SecurityWindowWithProperty 2
+ char readAction;
+ char writeAction;
+ char destroyAction;
+ struct _PropertyAccessRec *next;
+} PropertyAccessRec, *PropertyAccessPtr;
+
+static PropertyAccessPtr PropertyAccessList = NULL;
+static char SecurityDefaultAction = SecurityErrorOperation;
+static char *SecurityPolicyFile = DEFAULTPOLICYFILE;
+static ATOM SecurityMaxPropertyName = 0;
+
+static char *SecurityKeywords[] = {
+#define SecurityKeywordComment 0
+ "#",
+#define SecurityKeywordProperty 1
+ "property",
+#define SecurityKeywordSitePolicy 2
+ "sitepolicy",
+#define SecurityKeywordRoot 3
+ "root",
+#define SecurityKeywordAny 4
+ "any"
+};
+
+#define NUMKEYWORDS (sizeof(SecurityKeywords) / sizeof(char *))
+
+#undef PROPDEBUG
+/*#define PROPDEBUG 1*/
+
+static void
+SecurityFreePropertyAccessList(void)
+{
+ while (PropertyAccessList)
+ {
+ PropertyAccessPtr freeit = PropertyAccessList;
+ PropertyAccessList = PropertyAccessList->next;
+ xfree(freeit);
+ }
+} /* SecurityFreePropertyAccessList */
+
+#ifndef __UNIXOS2__
+#define SecurityIsWhitespace(c) ( (c == ' ') || (c == '\t') || (c == '\n') )
+#else
+#define SecurityIsWhitespace(c) ( (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r') )
+#endif
+
+static char *
+SecuritySkipWhitespace(
+ char *p)
+{
+ while (SecurityIsWhitespace(*p))
+ p++;
+ return p;
+} /* SecuritySkipWhitespace */
+
+
+static char *
+SecurityParseString(
+ char **rest)
+{
+ char *startOfString;
+ char *s = *rest;
+ char endChar = 0;
+
+ s = SecuritySkipWhitespace(s);
+
+ if (*s == '"' || *s == '\'')
+ {
+ endChar = *s++;
+ startOfString = s;
+ while (*s && (*s != endChar))
+ s++;
+ }
+ else
+ {
+ startOfString = s;
+ while (*s && !SecurityIsWhitespace(*s))
+ s++;
+ }
+ if (*s)
+ {
+ *s = '\0';
+ *rest = s + 1;
+ return startOfString;
+ }
+ else
+ {
+ *rest = s;
+ return (endChar) ? NULL : startOfString;
+ }
+} /* SecurityParseString */
+
+
+static int
+SecurityParseKeyword(
+ char **p)
+{
+ int i;
+ char *s = *p;
+ s = SecuritySkipWhitespace(s);
+ for (i = 0; i < NUMKEYWORDS; i++)
+ {
+ int len = strlen(SecurityKeywords[i]);
+ if (strncmp(s, SecurityKeywords[i], len) == 0)
+ {
+ *p = s + len;
+ return (i);
+ }
+ }
+ *p = s;
+ return -1;
+} /* SecurityParseKeyword */
+
+
+static Bool
+SecurityParsePropertyAccessRule(
+ char *p)
+{
+ char *propname;
+ char c;
+ char action = SecurityDefaultAction;
+ char readAction, writeAction, destroyAction;
+ PropertyAccessPtr pacl, prev, cur;
+ char *mustHaveProperty = NULL;
+ char *mustHaveValue = NULL;
+ Bool invalid;
+ char windowRestriction;
+ int size;
+ int keyword;
+
+ /* get property name */
+ propname = SecurityParseString(&p);
+ if (!propname || (strlen(propname) == 0))
+ return FALSE;
+
+ /* get window on which property must reside for rule to apply */
+
+ keyword = SecurityParseKeyword(&p);
+ if (keyword == SecurityKeywordRoot)
+ windowRestriction = SecurityRootWindow;
+ else if (keyword == SecurityKeywordAny)
+ windowRestriction = SecurityAnyWindow;
+ else /* not root or any, must be a property name */
+ {
+ mustHaveProperty = SecurityParseString(&p);
+ if (!mustHaveProperty || (strlen(mustHaveProperty) == 0))
+ return FALSE;
+ windowRestriction = SecurityWindowWithProperty;
+ p = SecuritySkipWhitespace(p);
+ if (*p == '=')
+ { /* property value is specified too */
+ p++; /* skip over '=' */
+ mustHaveValue = SecurityParseString(&p);
+ if (!mustHaveValue)
+ return FALSE;
+ }
+ }
+
+ /* get operations and actions */
+
+ invalid = FALSE;
+ readAction = writeAction = destroyAction = SecurityDefaultAction;
+ while ( (c = *p++) && !invalid)
+ {
+ switch (c)
+ {
+ case 'i': action = SecurityIgnoreOperation; break;
+ case 'a': action = SecurityAllowOperation; break;
+ case 'e': action = SecurityErrorOperation; break;
+
+ case 'r': readAction = action; break;
+ case 'w': writeAction = action; break;
+ case 'd': destroyAction = action; break;
+
+ default :
+ if (!SecurityIsWhitespace(c))
+ invalid = TRUE;
+ break;
+ }
+ }
+ if (invalid)
+ return FALSE;
+
+ /* We've successfully collected all the information needed for this
+ * property access rule. Now record it in a PropertyAccessRec.
+ */
+ size = sizeof(PropertyAccessRec);
+
+ /* If there is a property value string, allocate space for it
+ * right after the PropertyAccessRec.
+ */
+ if (mustHaveValue)
+ size += strlen(mustHaveValue) + 1;
+ pacl = (PropertyAccessPtr)Xalloc(size);
+ if (!pacl)
+ return FALSE;
+
+ pacl->name = MakeAtom(propname, strlen(propname), TRUE);
+ if (pacl->name == BAD_RESOURCE)
+ {
+ Xfree(pacl);
+ return FALSE;
+ }
+ if (mustHaveProperty)
+ {
+ pacl->mustHaveProperty = MakeAtom(mustHaveProperty,
+ strlen(mustHaveProperty), TRUE);
+ if (pacl->mustHaveProperty == BAD_RESOURCE)
+ {
+ Xfree(pacl);
+ return FALSE;
+ }
+ }
+ else
+ pacl->mustHaveProperty = 0;
+
+ if (mustHaveValue)
+ {
+ pacl->mustHaveValue = (char *)(pacl + 1);
+ strcpy(pacl->mustHaveValue, mustHaveValue);
+ }
+ else
+ pacl->mustHaveValue = NULL;
+
+ SecurityMaxPropertyName = max(SecurityMaxPropertyName, pacl->name);
+
+ pacl->windowRestriction = windowRestriction;
+ pacl->readAction = readAction;
+ pacl->writeAction = writeAction;
+ pacl->destroyAction = destroyAction;
+
+ /* link the new rule into the list of rules in order of increasing
+ * property name (atom) value to make searching easier
+ */
+
+ for (prev = NULL, cur = PropertyAccessList;
+ cur && cur->name <= pacl->name;
+ prev = cur, cur = cur->next)
+ ;
+ if (!prev)
+ {
+ pacl->next = cur;
+ PropertyAccessList = pacl;
+ }
+ else
+ {
+ prev->next = pacl;
+ pacl->next = cur;
+ }
+ return TRUE;
+} /* SecurityParsePropertyAccessRule */
+
+static char **SecurityPolicyStrings = NULL;
+static int nSecurityPolicyStrings = 0;
+
+static Bool
+SecurityParseSitePolicy(
+ char *p)
+{
+ char *policyStr = SecurityParseString(&p);
+ char *copyPolicyStr;
+ char **newStrings;
+
+ if (!policyStr)
+ return FALSE;
+
+ copyPolicyStr = (char *)Xalloc(strlen(policyStr) + 1);
+ if (!copyPolicyStr)
+ return TRUE;
+ strcpy(copyPolicyStr, policyStr);
+ newStrings = (char **)Xrealloc(SecurityPolicyStrings,
+ sizeof (char *) * (nSecurityPolicyStrings + 1));
+ if (!newStrings)
+ {
+ Xfree(copyPolicyStr);
+ return TRUE;
+ }
+
+ SecurityPolicyStrings = newStrings;
+ SecurityPolicyStrings[nSecurityPolicyStrings++] = copyPolicyStr;
+
+ return TRUE;
+
+} /* SecurityParseSitePolicy */
+
+
+char **
+SecurityGetSitePolicyStrings(n)
+ int *n;
+{
+ *n = nSecurityPolicyStrings;
+ return SecurityPolicyStrings;
+} /* SecurityGetSitePolicyStrings */
+
+static void
+SecurityFreeSitePolicyStrings(void)
+{
+ if (SecurityPolicyStrings)
+ {
+ assert(nSecurityPolicyStrings);
+ while (nSecurityPolicyStrings--)
+ {
+ Xfree(SecurityPolicyStrings[nSecurityPolicyStrings]);
+ }
+ Xfree(SecurityPolicyStrings);
+ SecurityPolicyStrings = NULL;
+ nSecurityPolicyStrings = 0;
+ }
+} /* SecurityFreeSitePolicyStrings */
+
+
+static void
+SecurityLoadPropertyAccessList(void)
+{
+ FILE *f;
+ int lineNumber = 0;
+
+ SecurityMaxPropertyName = 0;
+
+#ifdef NXAGENT_SERVER
+
+ if (!_NXGetPolicyFilePath(SecurityPolicyFile))
+ {
+ return;
+ }
+
+#else
+
+ if (!SecurityPolicyFile)
+ return;
+
+#endif
+
+#ifndef __UNIXOS2__
+
+#ifdef NXAGENT_SERVER
+
+ f = fopen(_NXGetPolicyFilePath(SecurityPolicyFile), "r");
+
+#else
+
+ f = fopen(SecurityPolicyFile, "r");
+
+#endif
+
+#else
+
+#ifdef NXAGENT_SERVER
+
+ f = fopen((char*)__XOS2RedirRoot( _NXGetPolicyFilePath(SecurityPolicyFile)), "r");
+
+#else
+
+ f = fopen((char*)__XOS2RedirRoot(SecurityPolicyFile), "r");
+
+#endif
+
+#endif
+
+ if (!f)
+ {
+#ifdef NXAGENT_SERVER
+
+ ErrorF("error opening security policy file %s\n",
+ _NXGetPolicyFilePath(SecurityPolicyFile));
+
+#else
+
+ ErrorF("error opening security policy file %s\n",
+ SecurityPolicyFile);
+
+#endif
+
+ return;
+ }
+
+ while (!feof(f))
+ {
+ char buf[200];
+ Bool validLine;
+ char *p;
+
+ if (!(p = fgets(buf, sizeof(buf), f)))
+ break;
+ lineNumber++;
+
+ /* if first line, check version number */
+ if (lineNumber == 1)
+ {
+ char *v = SecurityParseString(&p);
+ if (strcmp(v, SECURITY_POLICY_FILE_VERSION) != 0)
+ {
+
+#ifdef NXAGENT_SERVER
+
+ ErrorF("%s: invalid security policy file version, ignoring file\n",
+ _NXGetPolicyFilePath(SecurityPolicyFile));
+
+#else
+
+ ErrorF("%s: invalid security policy file version, ignoring file\n",
+ SecurityPolicyFile);
+
+#endif
+
+ break;
+ }
+ validLine = TRUE;
+ }
+ else
+ {
+ switch (SecurityParseKeyword(&p))
+ {
+ case SecurityKeywordComment:
+ validLine = TRUE;
+ break;
+
+ case SecurityKeywordProperty:
+ validLine = SecurityParsePropertyAccessRule(p);
+ break;
+
+ case SecurityKeywordSitePolicy:
+ validLine = SecurityParseSitePolicy(p);
+ break;
+
+ default:
+ validLine = (*p == '\0'); /* blank lines OK, others not */
+ break;
+ }
+ }
+
+#ifdef NXAGENT_SERVER
+
+ if (!validLine)
+ {
+ ErrorF("Line %d of %s invalid, ignoring\n",
+ lineNumber, _NXGetPolicyFilePath(SecurityPolicyFile));
+ }
+
+#else
+
+ if (!validLine)
+ ErrorF("Line %d of %s invalid, ignoring\n",
+ lineNumber, SecurityPolicyFile);
+
+#endif
+
+ } /* end while more input */
+
+#ifdef PROPDEBUG
+ {
+ PropertyAccessPtr pacl;
+ char *op = "aie";
+ for (pacl = PropertyAccessList; pacl; pacl = pacl->next)
+ {
+ ErrorF("property %s ", NameForAtom(pacl->name));
+ switch (pacl->windowRestriction)
+ {
+ case SecurityAnyWindow: ErrorF("any "); break;
+ case SecurityRootWindow: ErrorF("root "); break;
+ case SecurityWindowWithProperty:
+ {
+ ErrorF("%s ", NameForAtom(pacl->mustHaveProperty));
+ if (pacl->mustHaveValue)
+ ErrorF(" = \"%s\" ", pacl->mustHaveValue);
+
+ }
+ break;
+ }
+ ErrorF("%cr %cw %cd\n", op[pacl->readAction],
+ op[pacl->writeAction], op[pacl->destroyAction]);
+ }
+ }
+#endif /* PROPDEBUG */
+
+ fclose(f);
+} /* SecurityLoadPropertyAccessList */
+
+
+static Bool
+SecurityMatchString(
+ char *ws,
+ char *cs)
+{
+ while (*ws && *cs)
+ {
+ if (*ws == '*')
+ {
+ Bool match = FALSE;
+ ws++;
+ while (!(match = SecurityMatchString(ws, cs)) && *cs)
+ {
+ cs++;
+ }
+ return match;
+ }
+ else if (*ws == *cs)
+ {
+ ws++;
+ cs++;
+ }
+ else break;
+ }
+ return ( ( (*ws == '\0') || ((*ws == '*') && *(ws+1) == '\0') )
+ && (*cs == '\0') );
+} /* SecurityMatchString */
+
+#ifdef PROPDEBUG
+#include <sys/types.h>
+#include <sys/stat.h>
+#endif
+
+
+char
+SecurityCheckPropertyAccess(client, pWin, propertyName, access_mode)
+ ClientPtr client;
+ WindowPtr pWin;
+ ATOM propertyName;
+ Mask access_mode;
+{
+ PropertyAccessPtr pacl;
+ char action = SecurityDefaultAction;
+
+ /* if client trusted or window untrusted, allow operation */
+
+ if ( (client->trustLevel == XSecurityClientTrusted) ||
+ (wClient(pWin)->trustLevel != XSecurityClientTrusted) )
+ return SecurityAllowOperation;
+
+#ifdef PROPDEBUG
+ /* For testing, it's more convenient if the property rules file gets
+ * reloaded whenever it changes, so we can rapidly try things without
+ * having to reset the server.
+ */
+ {
+ struct stat buf;
+ static time_t lastmod = 0;
+
+#ifdef NXAGENT_SERVER
+
+ int ret = stat(_NXGetPolicyFilePath(SecurityPolicyFile), &buf);
+
+#else
+
+ int ret = stat(SecurityPolicyFile , &buf);
+
+#endif
+
+ if ( (ret == 0) && (buf.st_mtime > lastmod) )
+ {
+ ErrorF("reloading property rules\n");
+ SecurityFreePropertyAccessList();
+ SecurityLoadPropertyAccessList();
+ lastmod = buf.st_mtime;
+ }
+ }
+#endif
+
+ /* If the property atom is bigger than any atoms on the list,
+ * we know we won't find it, so don't even bother looking.
+ */
+ if (propertyName <= SecurityMaxPropertyName)
+ {
+ /* untrusted client operating on trusted window; see if it's allowed */
+
+ for (pacl = PropertyAccessList; pacl; pacl = pacl->next)
+ {
+ if (pacl->name < propertyName)
+ continue;
+ if (pacl->name > propertyName)
+ break;
+
+ /* pacl->name == propertyName, so see if it applies to this window */
+
+ switch (pacl->windowRestriction)
+ {
+ case SecurityAnyWindow: /* always applies */
+ break;
+
+ case SecurityRootWindow:
+ {
+ /* if not a root window, this rule doesn't apply */
+ if (pWin->parent)
+ continue;
+ }
+ break;
+
+ case SecurityWindowWithProperty:
+ {
+ PropertyPtr pProp = wUserProps (pWin);
+ Bool match = FALSE;
+ char *p;
+ char *pEndData;
+
+ while (pProp)
+ {
+ if (pProp->propertyName == pacl->mustHaveProperty)
+ break;
+ pProp = pProp->next;
+ }
+ if (!pProp)
+ continue;
+ if (!pacl->mustHaveValue)
+ break;
+ if (pProp->type != XA_STRING || pProp->format != 8)
+ continue;
+
+ p = pProp->data;
+ pEndData = ((char *)pProp->data) + pProp->size;
+ while (!match && p < pEndData)
+ {
+ if (SecurityMatchString(pacl->mustHaveValue, p))
+ match = TRUE;
+ else
+ { /* skip to the next string */
+ while (*p++ && p < pEndData)
+ ;
+ }
+ }
+ if (!match)
+ continue;
+ }
+ break; /* end case SecurityWindowWithProperty */
+ } /* end switch on windowRestriction */
+
+ /* If we get here, the property access rule pacl applies.
+ * If pacl doesn't apply, something above should have
+ * executed a continue, which will skip the follwing code.
+ */
+ action = SecurityAllowOperation;
+ if (access_mode & SecurityReadAccess)
+ action = max(action, pacl->readAction);
+ if (access_mode & SecurityWriteAccess)
+ action = max(action, pacl->writeAction);
+ if (access_mode & SecurityDestroyAccess)
+ action = max(action, pacl->destroyAction);
+ break;
+ } /* end for each pacl */
+ } /* end if propertyName <= SecurityMaxPropertyName */
+
+ if (SecurityAllowOperation != action)
+ { /* audit the access violation */
+ int cid = CLIENT_ID(pWin->drawable.id);
+ int reqtype = ((xReq *)client->requestBuffer)->reqType;
+ char *actionstr = (SecurityIgnoreOperation == action) ?
+ "ignored" : "error";
+ SecurityAudit("client %d attempted request %d with window 0x%x property %s (atom 0x%x) of client %d, %s\n",
+ client->index, reqtype, pWin->drawable.id,
+ NameForAtom(propertyName), propertyName, cid, actionstr);
+ }
+ return action;
+} /* SecurityCheckPropertyAccess */
+
+
+/* SecurityResetProc
+ *
+ * Arguments:
+ * extEntry is the extension information for the security extension.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Performs any cleanup needed by Security at server shutdown time.
+ */
+
+static void
+SecurityResetProc(
+ ExtensionEntry *extEntry)
+{
+ SecurityFreePropertyAccessList();
+ SecurityFreeSitePolicyStrings();
+} /* SecurityResetProc */
+
+
+int
+XSecurityOptions(argc, argv, i)
+ int argc;
+ char **argv;
+ int i;
+{
+ if (strcmp(argv[i], "-sp") == 0)
+ {
+ if (i < argc)
+ SecurityPolicyFile = argv[++i];
+ return (i + 1);
+ }
+ return (i);
+} /* XSecurityOptions */
+
+
+
+/* SecurityExtensionInit
+ *
+ * Arguments: none.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Enables the Security extension if possible.
+ */
+
+void
+SecurityExtensionInit(INITARGS)
+{
+ ExtensionEntry *extEntry;
+ int i;
+
+ SecurityAuthorizationResType =
+ CreateNewResourceType(SecurityDeleteAuthorization);
+
+ RTEventClient = CreateNewResourceType(
+ SecurityDeleteAuthorizationEventClient);
+
+ if (!SecurityAuthorizationResType || !RTEventClient)
+ return;
+
+ RTEventClient |= RC_NEVERRETAIN;
+
+ if (!AddCallback(&ClientStateCallback, SecurityClientStateCallback, NULL))
+ return;
+
+ extEntry = AddExtension(SECURITY_EXTENSION_NAME,
+ XSecurityNumberEvents, XSecurityNumberErrors,
+ ProcSecurityDispatch, SProcSecurityDispatch,
+ SecurityResetProc, StandardMinorOpcode);
+
+ SecurityErrorBase = extEntry->errorBase;
+ SecurityEventBase = extEntry->eventBase;
+
+ EventSwapVector[SecurityEventBase + XSecurityAuthorizationRevoked] =
+ (EventSwapPtr)SwapSecurityAuthorizationRevokedEvent;
+
+ /* initialize untrusted proc vectors */
+
+ for (i = 0; i < 128; i++)
+ {
+ UntrustedProcVector[i] = ProcVector[i];
+ SwappedUntrustedProcVector[i] = SwappedProcVector[i];
+ }
+
+ /* make sure insecure extensions are not allowed */
+
+ for (i = 128; i < 256; i++)
+ {
+ if (!UntrustedProcVector[i])
+ {
+ UntrustedProcVector[i] = ProcBadRequest;
+ SwappedUntrustedProcVector[i] = ProcBadRequest;
+ }
+ }
+
+ SecurityLoadPropertyAccessList();
+
+} /* SecurityExtensionInit */
diff --git a/nx-X11/programs/Xserver/Xext/security.c.NX.original b/nx-X11/programs/Xserver/Xext/security.c.NX.original
new file mode 100644
index 000000000..f37be696b
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/security.c.NX.original
@@ -0,0 +1,2241 @@
+/* $XdotOrg: xc/programs/Xserver/Xext/security.c,v 1.5 2005/07/03 07:01:04 daniels Exp $ */
+/* $Xorg: security.c,v 1.4 2001/02/09 02:04:32 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/Xext/security.c,v 1.16tsi Exp $ */
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "windowstr.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "colormapst.h"
+#include "propertyst.h"
+#define _SECURITY_SERVER
+#include <X11/extensions/securstr.h>
+#include <assert.h>
+#include <stdarg.h>
+#ifdef LBX
+#define _XLBX_SERVER_
+#include <X11/extensions/XLbx.h>
+extern unsigned char LbxReqCode;
+#endif
+#ifdef XAPPGROUP
+#include <X11/extensions/Xagsrv.h>
+#endif
+#include <stdio.h> /* for file reading operations */
+#include <X11/Xatom.h> /* for XA_STRING */
+
+#ifdef NXAGENT_SERVER
+
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#endif
+
+#ifndef DEFAULTPOLICYFILE
+# define DEFAULTPOLICYFILE NULL
+#endif
+
+#ifdef NXAGENT_SERVER
+
+#define NX_ALTERNATIVEPOLICYFILE "/usr/lib/xserver/SecurityPolicy"
+
+#endif
+
+#if defined(WIN32) || defined(__CYGWIN__)
+#include <X11/Xos.h>
+#undef index
+#endif
+
+/*
+ * Set here the required NX log level.
+ */
+
+#ifdef NXAGENT_SERVER
+
+#define PANIC
+#define WARNING
+#undef TEST
+#undef DEBUG
+
+#endif
+
+#ifdef NXAGENT_SERVER
+
+static char _NXPolicyFilePath[1024];
+
+#endif
+
+#include "modinit.h"
+
+static int SecurityErrorBase; /* first Security error number */
+static int SecurityEventBase; /* first Security event number */
+
+CallbackListPtr SecurityValidateGroupCallback = NULL; /* see security.h */
+
+RESTYPE SecurityAuthorizationResType; /* resource type for authorizations */
+
+static RESTYPE RTEventClient;
+
+/* Proc vectors for untrusted clients, swapped and unswapped versions.
+ * These are the same as the normal proc vectors except that extensions
+ * that haven't declared themselves secure will have ProcBadRequest plugged
+ * in for their major opcode dispatcher. This prevents untrusted clients
+ * from guessing extension major opcodes and using the extension even though
+ * the extension can't be listed or queried.
+ */
+int (*UntrustedProcVector[256])(
+ ClientPtr /*client*/
+);
+int (*SwappedUntrustedProcVector[256])(
+ ClientPtr /*client*/
+);
+
+#ifdef NXAGENT_SERVER
+
+/*
+ * This function returns the SecurityPolicy
+ * file full path. This path is referred by
+ * SecurityPolicyFile variable (generally it
+ * contains the hardcoded path at compile time).
+ * If the path does not exist, the function will
+ * try a set of well known paths.
+ */
+
+const char *_NXGetPolicyFilePath(const char *path)
+{
+
+ struct stat SecurityPolicyStat;
+
+ /*
+ * Check the policy file path only once.
+ */
+
+ if (*_NXPolicyFilePath != '\0')
+ {
+ return _NXPolicyFilePath;
+ }
+
+ if (stat(path, &SecurityPolicyStat) == 0)
+ {
+ if (strlen(path) + 1 > 1024)
+ {
+ #ifdef WARNING
+ fprintf(stderr, "_NXGetPolicyFilePath: WARNING! Maximum length of SecurityPolicy file path exceeded.\n");
+ #endif
+
+ goto _NXGetPolicyFilePathError;
+ }
+
+ strcpy(_NXPolicyFilePath, path);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetPolicyFilePath: Using SecurityPolicy file path [%s].\n",
+ _NXPolicyFilePath);
+ #endif
+
+ return _NXPolicyFilePath;
+ }
+
+ if (stat(DEFAULTPOLICYFILE, &SecurityPolicyStat) == 0)
+ {
+ if (strlen(DEFAULTPOLICYFILE) + 1 > 1024)
+ {
+ #ifdef WARNING
+ fprintf(stderr, "_NXGetPolicyFilePath: WARNING! Maximum length of SecurityPolicy file path exceeded.\n");
+ #endif
+
+ goto _NXGetPolicyFilePathError;
+ }
+
+ strcpy(_NXPolicyFilePath, DEFAULTPOLICYFILE);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetPolicyFilePath: Using SecurityPolicy file path [%s].\n",
+ _NXPolicyFilePath);
+ #endif
+
+ return _NXPolicyFilePath;
+ }
+
+ if (stat(NX_ALTERNATIVEPOLICYFILE, &SecurityPolicyStat) == 0)
+ {
+ if (strlen(NX_ALTERNATIVEPOLICYFILE) + 1 > 1024)
+ {
+ #ifdef WARNING
+ fprintf(stderr, "_NXGetPolicyFilePath: WARNING! Maximum length of SecurityPolicy file path exceeded.\n");
+ #endif
+
+ goto _NXGetPolicyFilePathError;
+ }
+
+ strcpy(_NXPolicyFilePath, NX_ALTERNATIVEPOLICYFILE);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetPolicyFilePath: Using SecurityPolicy file path [%s].\n",
+ _NXPolicyFilePath);
+ #endif
+
+ return _NXPolicyFilePath;
+ }
+
+_NXGetPolicyFilePathError:
+
+ if (strlen(path) + 1 > 1024)
+ {
+ #ifdef WARNING
+ fprintf(stderr, "_NXGetPolicyFilePath: WARNING! Maximum length of SecurityPolicy file exceeded.\n");
+ #endif
+ }
+
+ strcpy(_NXPolicyFilePath, path);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetPolicyFilePath: Using default SecurityPolicy file path [%s].\n",
+ _NXPolicyFilePath);
+ #endif
+
+ return _NXPolicyFilePath;
+}
+
+#endif
+
+/* SecurityAudit
+ *
+ * Arguments:
+ * format is the formatting string to be used to interpret the
+ * remaining arguments.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Writes the message to the log file if security logging is on.
+ */
+
+void
+SecurityAudit(char *format, ...)
+{
+ va_list args;
+
+ if (auditTrailLevel < SECURITY_AUDIT_LEVEL)
+ return;
+ va_start(args, format);
+ VAuditF(format, args);
+ va_end(args);
+} /* SecurityAudit */
+
+#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
+
+/* SecurityDeleteAuthorization
+ *
+ * Arguments:
+ * value is the authorization to delete.
+ * id is its resource ID.
+ *
+ * Returns: Success.
+ *
+ * Side Effects:
+ * Frees everything associated with the authorization.
+ */
+
+static int
+SecurityDeleteAuthorization(
+ pointer value,
+ XID id)
+{
+ SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)value;
+ unsigned short name_len, data_len;
+ char *name, *data;
+ int status;
+ int i;
+ OtherClientsPtr pEventClient;
+
+ /* Remove the auth using the os layer auth manager */
+
+ status = AuthorizationFromID(pAuth->id, &name_len, &name,
+ &data_len, &data);
+ assert(status);
+ status = RemoveAuthorization(name_len, name, data_len, data);
+ assert(status);
+ (void)status;
+
+ /* free the auth timer if there is one */
+
+ if (pAuth->timer) TimerFree(pAuth->timer);
+
+ /* send revoke events */
+
+ while ((pEventClient = pAuth->eventClients))
+ {
+ /* send revocation event event */
+ ClientPtr client = rClient(pEventClient);
+
+ if (!client->clientGone)
+ {
+ xSecurityAuthorizationRevokedEvent are;
+ are.type = SecurityEventBase + XSecurityAuthorizationRevoked;
+ are.sequenceNumber = client->sequence;
+ are.authId = pAuth->id;
+ WriteEventsToClient(client, 1, (xEvent *)&are);
+ }
+ FreeResource(pEventClient->resource, RT_NONE);
+ }
+
+ /* kill all clients using this auth */
+
+ for (i = 1; i<currentMaxClients; i++)
+ {
+ if (clients[i] && (clients[i]->authId == pAuth->id))
+ CloseDownClient(clients[i]);
+ }
+
+ SecurityAudit("revoked authorization ID %d\n", pAuth->id);
+ xfree(pAuth);
+ return Success;
+
+} /* SecurityDeleteAuthorization */
+
+
+/* resource delete function for RTEventClient */
+static int
+SecurityDeleteAuthorizationEventClient(
+ pointer value,
+ XID id)
+{
+ OtherClientsPtr pEventClient, prev = NULL;
+ SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)value;
+
+ for (pEventClient = pAuth->eventClients;
+ pEventClient;
+ pEventClient = pEventClient->next)
+ {
+ if (pEventClient->resource == id)
+ {
+ if (prev)
+ prev->next = pEventClient->next;
+ else
+ pAuth->eventClients = pEventClient->next;
+ xfree(pEventClient);
+ return(Success);
+ }
+ prev = pEventClient;
+ }
+ /*NOTREACHED*/
+ return -1; /* make compiler happy */
+} /* SecurityDeleteAuthorizationEventClient */
+
+
+/* SecurityComputeAuthorizationTimeout
+ *
+ * Arguments:
+ * pAuth is the authorization for which we are computing the timeout
+ * seconds is the number of seconds we want to wait
+ *
+ * Returns:
+ * the number of milliseconds that the auth timer should be set to
+ *
+ * Side Effects:
+ * Sets pAuth->secondsRemaining to any "overflow" amount of time
+ * that didn't fit in 32 bits worth of milliseconds
+ */
+
+static CARD32
+SecurityComputeAuthorizationTimeout(
+ SecurityAuthorizationPtr pAuth,
+ unsigned int seconds)
+{
+ /* maxSecs is the number of full seconds that can be expressed in
+ * 32 bits worth of milliseconds
+ */
+ CARD32 maxSecs = (CARD32)(~0) / (CARD32)MILLI_PER_SECOND;
+
+ if (seconds > maxSecs)
+ { /* only come here if we want to wait more than 49 days */
+ pAuth->secondsRemaining = seconds - maxSecs;
+ return maxSecs * MILLI_PER_SECOND;
+ }
+ else
+ { /* by far the common case */
+ pAuth->secondsRemaining = 0;
+ return seconds * MILLI_PER_SECOND;
+ }
+} /* SecurityStartAuthorizationTimer */
+
+/* SecurityAuthorizationExpired
+ *
+ * This function is passed as an argument to TimerSet and gets called from
+ * the timer manager in the os layer when its time is up.
+ *
+ * Arguments:
+ * timer is the timer for this authorization.
+ * time is the current time.
+ * pval is the authorization whose time is up.
+ *
+ * Returns:
+ * A new time delay in milliseconds if the timer should wait some
+ * more, else zero.
+ *
+ * Side Effects:
+ * Frees the authorization resource if the timeout period is really
+ * over, otherwise recomputes pAuth->secondsRemaining.
+ */
+
+static CARD32
+SecurityAuthorizationExpired(
+ OsTimerPtr timer,
+ CARD32 time,
+ pointer pval)
+{
+ SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)pval;
+
+ assert(pAuth->timer == timer);
+
+ if (pAuth->secondsRemaining)
+ {
+ return SecurityComputeAuthorizationTimeout(pAuth,
+ pAuth->secondsRemaining);
+ }
+ else
+ {
+ FreeResource(pAuth->id, RT_NONE);
+ return 0;
+ }
+} /* SecurityAuthorizationExpired */
+
+/* SecurityStartAuthorizationTimer
+ *
+ * Arguments:
+ * pAuth is the authorization whose timer should be started.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * A timer is started, set to expire after the timeout period for
+ * this authorization. When it expires, the function
+ * SecurityAuthorizationExpired will be called.
+ */
+
+static void
+SecurityStartAuthorizationTimer(
+ SecurityAuthorizationPtr pAuth)
+{
+ pAuth->timer = TimerSet(pAuth->timer, 0,
+ SecurityComputeAuthorizationTimeout(pAuth, pAuth->timeout),
+ SecurityAuthorizationExpired, pAuth);
+} /* SecurityStartAuthorizationTimer */
+
+
+/* Proc functions all take a client argument, execute the request in
+ * client->requestBuffer, and return a protocol error status.
+ */
+
+static int
+ProcSecurityQueryVersion(
+ ClientPtr client)
+{
+ /* REQUEST(xSecurityQueryVersionReq); */
+ xSecurityQueryVersionReply rep;
+
+ /* paranoia: this "can't happen" because this extension is hidden
+ * from untrusted clients, but just in case...
+ */
+ if (client->trustLevel != XSecurityClientTrusted)
+ return BadRequest;
+
+ REQUEST_SIZE_MATCH(xSecurityQueryVersionReq);
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.majorVersion = SECURITY_MAJOR_VERSION;
+ rep.minorVersion = SECURITY_MINOR_VERSION;
+ if(client->swapped)
+ {
+ register char n;
+ swaps(&rep.sequenceNumber, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ }
+ (void)WriteToClient(client, SIZEOF(xSecurityQueryVersionReply),
+ (char *)&rep);
+ return (client->noClientException);
+} /* ProcSecurityQueryVersion */
+
+
+static int
+SecurityEventSelectForAuthorization(
+ SecurityAuthorizationPtr pAuth,
+ ClientPtr client,
+ Mask mask)
+{
+ OtherClients *pEventClient;
+
+ for (pEventClient = pAuth->eventClients;
+ pEventClient;
+ pEventClient = pEventClient->next)
+ {
+ if (SameClient(pEventClient, client))
+ {
+ if (mask == 0)
+ FreeResource(pEventClient->resource, RT_NONE);
+ else
+ pEventClient->mask = mask;
+ return Success;
+ }
+ }
+
+ pEventClient = (OtherClients *) xalloc(sizeof(OtherClients));
+ if (!pEventClient)
+ return BadAlloc;
+ pEventClient->mask = mask;
+ pEventClient->resource = FakeClientID(client->index);
+ pEventClient->next = pAuth->eventClients;
+ if (!AddResource(pEventClient->resource, RTEventClient,
+ (pointer)pAuth))
+ {
+ xfree(pEventClient);
+ return BadAlloc;
+ }
+ pAuth->eventClients = pEventClient;
+
+ return Success;
+} /* SecurityEventSelectForAuthorization */
+
+
+static int
+ProcSecurityGenerateAuthorization(
+ ClientPtr client)
+{
+ REQUEST(xSecurityGenerateAuthorizationReq);
+ int len; /* request length in CARD32s*/
+ Bool removeAuth = FALSE; /* if bailout, call RemoveAuthorization? */
+ SecurityAuthorizationPtr pAuth = NULL; /* auth we are creating */
+ int err; /* error to return from this function */
+ XID authId; /* authorization ID assigned by os layer */
+ xSecurityGenerateAuthorizationReply rep; /* reply struct */
+ unsigned int trustLevel; /* trust level of new auth */
+ XID group; /* group of new auth */
+ CARD32 timeout; /* timeout of new auth */
+ CARD32 *values; /* list of supplied attributes */
+ char *protoname; /* auth proto name sent in request */
+ char *protodata; /* auth proto data sent in request */
+ unsigned int authdata_len; /* # bytes of generated auth data */
+ char *pAuthdata; /* generated auth data */
+ Mask eventMask; /* what events on this auth does client want */
+
+ /* paranoia: this "can't happen" because this extension is hidden
+ * from untrusted clients, but just in case...
+ */
+ if (client->trustLevel != XSecurityClientTrusted)
+ return BadRequest;
+
+ /* check request length */
+
+ REQUEST_AT_LEAST_SIZE(xSecurityGenerateAuthorizationReq);
+ len = SIZEOF(xSecurityGenerateAuthorizationReq) >> 2;
+ len += (stuff->nbytesAuthProto + (unsigned)3) >> 2;
+ len += (stuff->nbytesAuthData + (unsigned)3) >> 2;
+ values = ((CARD32 *)stuff) + len;
+ len += Ones(stuff->valueMask);
+ if (client->req_len != len)
+ return BadLength;
+
+ /* check valuemask */
+ if (stuff->valueMask & ~XSecurityAllAuthorizationAttributes)
+ {
+ client->errorValue = stuff->valueMask;
+ return BadValue;
+ }
+
+ /* check timeout */
+ timeout = 60;
+ if (stuff->valueMask & XSecurityTimeout)
+ {
+ timeout = *values++;
+ }
+
+ /* check trustLevel */
+ trustLevel = XSecurityClientUntrusted;
+ if (stuff->valueMask & XSecurityTrustLevel)
+ {
+ trustLevel = *values++;
+ if (trustLevel != XSecurityClientTrusted &&
+ trustLevel != XSecurityClientUntrusted)
+ {
+ client->errorValue = trustLevel;
+ return BadValue;
+ }
+ }
+
+ /* check group */
+ group = None;
+ if (stuff->valueMask & XSecurityGroup)
+ {
+ group = *values++;
+ if (SecurityValidateGroupCallback)
+ {
+ SecurityValidateGroupInfoRec vgi;
+ vgi.group = group;
+ vgi.valid = FALSE;
+ CallCallbacks(&SecurityValidateGroupCallback, (pointer)&vgi);
+
+ /* if nobody said they recognized it, it's an error */
+
+ if (!vgi.valid)
+ {
+ client->errorValue = group;
+ return BadValue;
+ }
+ }
+ }
+
+ /* check event mask */
+ eventMask = 0;
+ if (stuff->valueMask & XSecurityEventMask)
+ {
+ eventMask = *values++;
+ if (eventMask & ~XSecurityAllEventMasks)
+ {
+ client->errorValue = eventMask;
+ return BadValue;
+ }
+ }
+
+ protoname = (char *)&stuff[1];
+ protodata = protoname + ((stuff->nbytesAuthProto + (unsigned)3) >> 2);
+
+ /* call os layer to generate the authorization */
+
+ authId = GenerateAuthorization(stuff->nbytesAuthProto, protoname,
+ stuff->nbytesAuthData, protodata,
+ &authdata_len, &pAuthdata);
+ if ((XID) ~0L == authId)
+ {
+ err = SecurityErrorBase + XSecurityBadAuthorizationProtocol;
+ goto bailout;
+ }
+
+ /* now that we've added the auth, remember to remove it if we have to
+ * abort the request for some reason (like allocation failure)
+ */
+ removeAuth = TRUE;
+
+ /* associate additional information with this auth ID */
+
+ pAuth = (SecurityAuthorizationPtr)xalloc(sizeof(SecurityAuthorizationRec));
+ if (!pAuth)
+ {
+ err = BadAlloc;
+ goto bailout;
+ }
+
+ /* fill in the auth fields */
+
+ pAuth->id = authId;
+ pAuth->timeout = timeout;
+ pAuth->group = group;
+ pAuth->trustLevel = trustLevel;
+ pAuth->refcnt = 0; /* the auth was just created; nobody's using it yet */
+ pAuth->secondsRemaining = 0;
+ pAuth->timer = NULL;
+ pAuth->eventClients = NULL;
+
+ /* handle event selection */
+ if (eventMask)
+ {
+ err = SecurityEventSelectForAuthorization(pAuth, client, eventMask);
+ if (err != Success)
+ goto bailout;
+ }
+
+ if (!AddResource(authId, SecurityAuthorizationResType, pAuth))
+ {
+ err = BadAlloc;
+ goto bailout;
+ }
+
+ /* start the timer ticking */
+
+ if (pAuth->timeout != 0)
+ SecurityStartAuthorizationTimer(pAuth);
+
+ /* tell client the auth id and data */
+
+ rep.type = X_Reply;
+ rep.length = (authdata_len + 3) >> 2;
+ rep.sequenceNumber = client->sequence;
+ rep.authId = authId;
+ rep.dataLength = authdata_len;
+
+ if (client->swapped)
+ {
+ register char n;
+ swapl(&rep.length, n);
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.authId, n);
+ swaps(&rep.dataLength, n);
+ }
+
+ WriteToClient(client, SIZEOF(xSecurityGenerateAuthorizationReply),
+ (char *)&rep);
+ WriteToClient(client, authdata_len, pAuthdata);
+
+ SecurityAudit("client %d generated authorization %d trust %d timeout %d group %d events %d\n",
+ client->index, pAuth->id, pAuth->trustLevel, pAuth->timeout,
+ pAuth->group, eventMask);
+
+ /* the request succeeded; don't call RemoveAuthorization or free pAuth */
+
+ removeAuth = FALSE;
+ pAuth = NULL;
+ err = client->noClientException;
+
+bailout:
+ if (removeAuth)
+ RemoveAuthorization(stuff->nbytesAuthProto, protoname,
+ authdata_len, pAuthdata);
+ if (pAuth) xfree(pAuth);
+ return err;
+
+} /* ProcSecurityGenerateAuthorization */
+
+static int
+ProcSecurityRevokeAuthorization(
+ ClientPtr client)
+{
+ REQUEST(xSecurityRevokeAuthorizationReq);
+ SecurityAuthorizationPtr pAuth;
+
+ /* paranoia: this "can't happen" because this extension is hidden
+ * from untrusted clients, but just in case...
+ */
+ if (client->trustLevel != XSecurityClientTrusted)
+ return BadRequest;
+
+ REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq);
+
+ pAuth = (SecurityAuthorizationPtr)SecurityLookupIDByType(client,
+ stuff->authId, SecurityAuthorizationResType, SecurityDestroyAccess);
+ if (!pAuth)
+ return SecurityErrorBase + XSecurityBadAuthorization;
+
+ FreeResource(stuff->authId, RT_NONE);
+ return Success;
+} /* ProcSecurityRevokeAuthorization */
+
+
+static int
+ProcSecurityDispatch(
+ ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_SecurityQueryVersion:
+ return ProcSecurityQueryVersion(client);
+ case X_SecurityGenerateAuthorization:
+ return ProcSecurityGenerateAuthorization(client);
+ case X_SecurityRevokeAuthorization:
+ return ProcSecurityRevokeAuthorization(client);
+ default:
+ return BadRequest;
+ }
+} /* ProcSecurityDispatch */
+
+static int
+SProcSecurityQueryVersion(
+ ClientPtr client)
+{
+ REQUEST(xSecurityQueryVersionReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSecurityQueryVersionReq);
+ swaps(&stuff->majorVersion, n);
+ swaps(&stuff->minorVersion,n);
+ return ProcSecurityQueryVersion(client);
+} /* SProcSecurityQueryVersion */
+
+
+static int
+SProcSecurityGenerateAuthorization(
+ ClientPtr client)
+{
+ REQUEST(xSecurityGenerateAuthorizationReq);
+ register char n;
+ CARD32 *values;
+ unsigned long nvalues;
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSecurityGenerateAuthorizationReq);
+ swaps(&stuff->nbytesAuthProto, n);
+ swaps(&stuff->nbytesAuthData, n);
+ swapl(&stuff->valueMask, n);
+ values = (CARD32 *)(&stuff[1]) +
+ ((stuff->nbytesAuthProto + (unsigned)3) >> 2) +
+ ((stuff->nbytesAuthData + (unsigned)3) >> 2);
+ nvalues = (((CARD32 *)stuff) + stuff->length) - values;
+ SwapLongs(values, nvalues);
+ return ProcSecurityGenerateAuthorization(client);
+} /* SProcSecurityGenerateAuthorization */
+
+
+static int
+SProcSecurityRevokeAuthorization(
+ ClientPtr client)
+{
+ REQUEST(xSecurityRevokeAuthorizationReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq);
+ swapl(&stuff->authId, n);
+ return ProcSecurityRevokeAuthorization(client);
+} /* SProcSecurityRevokeAuthorization */
+
+
+static int
+SProcSecurityDispatch(
+ ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_SecurityQueryVersion:
+ return SProcSecurityQueryVersion(client);
+ case X_SecurityGenerateAuthorization:
+ return SProcSecurityGenerateAuthorization(client);
+ case X_SecurityRevokeAuthorization:
+ return SProcSecurityRevokeAuthorization(client);
+ default:
+ return BadRequest;
+ }
+} /* SProcSecurityDispatch */
+
+static void
+SwapSecurityAuthorizationRevokedEvent(
+ xSecurityAuthorizationRevokedEvent *from,
+ xSecurityAuthorizationRevokedEvent *to)
+{
+ to->type = from->type;
+ to->detail = from->detail;
+ cpswaps(from->sequenceNumber, to->sequenceNumber);
+ cpswapl(from->authId, to->authId);
+}
+
+/* SecurityDetermineEventPropogationLimits
+ *
+ * This is a helper function for SecurityCheckDeviceAccess.
+ *
+ * Arguments:
+ * dev is the device for which the starting and stopping windows for
+ * event propogation should be determined.
+ * The values pointed to by ppWin and ppStopWin are not used.
+ *
+ * Returns:
+ * ppWin is filled in with a pointer to the window at which event
+ * propogation for the given device should start given the current
+ * state of the server (pointer position, window layout, etc.)
+ * ppStopWin is filled in with the window at which event propogation
+ * should stop; events should not go to ppStopWin.
+ *
+ * Side Effects: none.
+ */
+
+static void
+SecurityDetermineEventPropogationLimits(
+ DeviceIntPtr dev,
+ WindowPtr *ppWin,
+ WindowPtr *ppStopWin)
+{
+ WindowPtr pFocusWin = dev->focus ? dev->focus->win : NoneWin;
+
+ if (pFocusWin == NoneWin)
+ { /* no focus -- events don't go anywhere */
+ *ppWin = *ppStopWin = NULL;
+ return;
+ }
+
+ if (pFocusWin == PointerRootWin)
+ { /* focus follows the pointer */
+ *ppWin = GetSpriteWindow();
+ *ppStopWin = NULL; /* propogate all the way to the root */
+ }
+ else
+ { /* a real window is set for the focus */
+ WindowPtr pSpriteWin = GetSpriteWindow();
+ *ppStopWin = pFocusWin->parent; /* don't go past the focus window */
+
+ /* if the pointer is in a subwindow of the focus window, start
+ * at that subwindow, else start at the focus window itself
+ */
+ if (IsParent(pFocusWin, pSpriteWin))
+ *ppWin = pSpriteWin;
+ else *ppWin = pFocusWin;
+ }
+} /* SecurityDetermineEventPropogationLimits */
+
+
+/* SecurityCheckDeviceAccess
+ *
+ * Arguments:
+ * client is the client attempting to access a device.
+ * dev is the device being accessed.
+ * fromRequest is TRUE if the device access is a direct result of
+ * the client executing some request and FALSE if it is a
+ * result of the server trying to send an event (e.g. KeymapNotify)
+ * to the client.
+ * Returns:
+ * TRUE if the device access should be allowed, else FALSE.
+ *
+ * Side Effects:
+ * An audit message is generated if access is denied.
+ */
+
+Bool
+SecurityCheckDeviceAccess(client, dev, fromRequest)
+ ClientPtr client;
+ DeviceIntPtr dev;
+ Bool fromRequest;
+{
+ WindowPtr pWin, pStopWin;
+ Bool untrusted_got_event;
+ Bool found_event_window;
+ Mask eventmask;
+ int reqtype = 0;
+
+ /* trusted clients always allowed to do anything */
+ if (client->trustLevel == XSecurityClientTrusted)
+ return TRUE;
+
+ /* device security other than keyboard is not implemented yet */
+ if (dev != inputInfo.keyboard)
+ return TRUE;
+
+ /* some untrusted client wants access */
+
+ if (fromRequest)
+ {
+ reqtype = ((xReq *)client->requestBuffer)->reqType;
+ switch (reqtype)
+ {
+ /* never allow these */
+ case X_ChangeKeyboardMapping:
+ case X_ChangeKeyboardControl:
+ case X_SetModifierMapping:
+ SecurityAudit("client %d attempted request %d\n",
+ client->index, reqtype);
+ return FALSE;
+ default:
+ break;
+ }
+ }
+
+ untrusted_got_event = FALSE;
+ found_event_window = FALSE;
+
+ if (dev->grab)
+ {
+ untrusted_got_event =
+ ((rClient(dev->grab))->trustLevel != XSecurityClientTrusted);
+ }
+ else
+ {
+ SecurityDetermineEventPropogationLimits(dev, &pWin, &pStopWin);
+
+ eventmask = KeyPressMask | KeyReleaseMask;
+ while ( (pWin != pStopWin) && !found_event_window)
+ {
+ OtherClients *other;
+
+ if (pWin->eventMask & eventmask)
+ {
+ found_event_window = TRUE;
+ client = wClient(pWin);
+ if (client->trustLevel != XSecurityClientTrusted)
+ {
+ untrusted_got_event = TRUE;
+ }
+ }
+ if (wOtherEventMasks(pWin) & eventmask)
+ {
+ found_event_window = TRUE;
+ for (other = wOtherClients(pWin); other; other = other->next)
+ {
+ if (other->mask & eventmask)
+ {
+ client = rClient(other);
+ if (client->trustLevel != XSecurityClientTrusted)
+ {
+ untrusted_got_event = TRUE;
+ break;
+ }
+ }
+ }
+ }
+ if (wDontPropagateMask(pWin) & eventmask)
+ break;
+ pWin = pWin->parent;
+ } /* while propogating the event */
+ }
+
+ /* allow access by untrusted clients only if an event would have gone
+ * to an untrusted client
+ */
+
+ if (!untrusted_got_event)
+ {
+ char *devname = dev->name;
+ if (!devname) devname = "unnamed";
+ if (fromRequest)
+ SecurityAudit("client %d attempted request %d device %d (%s)\n",
+ client->index, reqtype, dev->id, devname);
+ else
+ SecurityAudit("client %d attempted to access device %d (%s)\n",
+ client->index, dev->id, devname);
+ }
+ return untrusted_got_event;
+} /* SecurityCheckDeviceAccess */
+
+
+
+/* SecurityAuditResourceIDAccess
+ *
+ * Arguments:
+ * client is the client doing the resource access.
+ * id is the resource id.
+ *
+ * Returns: NULL
+ *
+ * Side Effects:
+ * An audit message is generated with details of the denied
+ * resource access.
+ */
+
+static pointer
+SecurityAuditResourceIDAccess(
+ ClientPtr client,
+ XID id)
+{
+ int cid = CLIENT_ID(id);
+ int reqtype = ((xReq *)client->requestBuffer)->reqType;
+ switch (reqtype)
+ {
+ case X_ChangeProperty:
+ case X_DeleteProperty:
+ case X_GetProperty:
+ {
+ xChangePropertyReq *req =
+ (xChangePropertyReq *)client->requestBuffer;
+ int propertyatom = req->property;
+ char *propertyname = NameForAtom(propertyatom);
+
+ SecurityAudit("client %d attempted request %d with window 0x%x property %s of client %d\n",
+ client->index, reqtype, id, propertyname, cid);
+ break;
+ }
+ default:
+ {
+ SecurityAudit("client %d attempted request %d with resource 0x%x of client %d\n",
+ client->index, reqtype, id, cid);
+ break;
+ }
+ }
+ return NULL;
+} /* SecurityAuditResourceIDAccess */
+
+
+/* SecurityCheckResourceIDAccess
+ *
+ * This function gets plugged into client->CheckAccess and is called from
+ * SecurityLookupIDByType/Class to determine if the client can access the
+ * resource.
+ *
+ * Arguments:
+ * client is the client doing the resource access.
+ * id is the resource id.
+ * rtype is its type or class.
+ * access_mode represents the intended use of the resource; see
+ * resource.h.
+ * rval is a pointer to the resource structure for this resource.
+ *
+ * Returns:
+ * If access is granted, the value of rval that was passed in, else NULL.
+ *
+ * Side Effects:
+ * Disallowed resource accesses are audited.
+ */
+
+static pointer
+SecurityCheckResourceIDAccess(
+ ClientPtr client,
+ XID id,
+ RESTYPE rtype,
+ Mask access_mode,
+ pointer rval)
+{
+ int cid = CLIENT_ID(id);
+ int reqtype = ((xReq *)client->requestBuffer)->reqType;
+
+ if (SecurityUnknownAccess == access_mode)
+ return rval; /* for compatibility, we have to allow access */
+
+ switch (reqtype)
+ { /* these are always allowed */
+ case X_QueryTree:
+ case X_TranslateCoords:
+ case X_GetGeometry:
+ /* property access is controlled in SecurityCheckPropertyAccess */
+ case X_GetProperty:
+ case X_ChangeProperty:
+ case X_DeleteProperty:
+ case X_RotateProperties:
+ case X_ListProperties:
+ return rval;
+ default:
+ break;
+ }
+
+ if (cid != 0)
+ { /* not a server-owned resource */
+ /*
+ * The following 'if' restricts clients to only access resources at
+ * the same trustLevel. Since there are currently only two trust levels,
+ * and trusted clients never call this function, this degenerates into
+ * saying that untrusted clients can only access resources of other
+ * untrusted clients. One way to add the notion of groups would be to
+ * allow values other than Trusted (0) and Untrusted (1) for this field.
+ * Clients at the same trust level would be able to use each other's
+ * resources, but not those of clients at other trust levels. I haven't
+ * tried it, but this probably mostly works already. The obvious
+ * competing alternative for grouping clients for security purposes is to
+ * use app groups. dpw
+ */
+ if (client->trustLevel == clients[cid]->trustLevel
+#ifdef XAPPGROUP
+ || (RT_COLORMAP == rtype &&
+ XagDefaultColormap (client) == (Colormap) id)
+#endif
+ )
+ return rval;
+ else
+ return SecurityAuditResourceIDAccess(client, id);
+ }
+ else /* server-owned resource - probably a default colormap or root window */
+ {
+ if (RT_WINDOW == rtype || RC_DRAWABLE == rtype)
+ {
+ switch (reqtype)
+ { /* the following operations are allowed on root windows */
+ case X_CreatePixmap:
+ case X_CreateGC:
+ case X_CreateWindow:
+ case X_CreateColormap:
+ case X_ListProperties:
+ case X_GrabPointer:
+ case X_UngrabButton:
+ case X_QueryBestSize:
+ case X_GetWindowAttributes:
+ break;
+ case X_SendEvent:
+ { /* see if it is an event specified by the ICCCM */
+ xSendEventReq *req = (xSendEventReq *)
+ (client->requestBuffer);
+ if (req->propagate == xTrue
+ ||
+ (req->eventMask != ColormapChangeMask &&
+ req->eventMask != StructureNotifyMask &&
+ req->eventMask !=
+ (SubstructureRedirectMask|SubstructureNotifyMask)
+ )
+ ||
+ (req->event.u.u.type != UnmapNotify &&
+ req->event.u.u.type != ConfigureRequest &&
+ req->event.u.u.type != ClientMessage
+ )
+ )
+ { /* not an ICCCM event */
+ return SecurityAuditResourceIDAccess(client, id);
+ }
+ break;
+ } /* case X_SendEvent on root */
+
+ case X_ChangeWindowAttributes:
+ { /* Allow selection of PropertyNotify and StructureNotify
+ * events on the root.
+ */
+ xChangeWindowAttributesReq *req =
+ (xChangeWindowAttributesReq *)(client->requestBuffer);
+ if (req->valueMask == CWEventMask)
+ {
+ CARD32 value = *((CARD32 *)(req + 1));
+ if ( (value &
+ ~(PropertyChangeMask|StructureNotifyMask)) == 0)
+ break;
+ }
+ return SecurityAuditResourceIDAccess(client, id);
+ } /* case X_ChangeWindowAttributes on root */
+
+ default:
+ {
+#ifdef LBX
+ /* XXX really need per extension dispatching */
+ if (reqtype == LbxReqCode) {
+ switch (((xReq *)client->requestBuffer)->data) {
+ case X_LbxGetProperty:
+ case X_LbxChangeProperty:
+ return rval;
+ default:
+ break;
+ }
+ }
+#endif
+ /* others not allowed */
+ return SecurityAuditResourceIDAccess(client, id);
+ }
+ }
+ } /* end server-owned window or drawable */
+ else if (SecurityAuthorizationResType == rtype)
+ {
+ SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)rval;
+ if (pAuth->trustLevel != client->trustLevel)
+ return SecurityAuditResourceIDAccess(client, id);
+ }
+ else if (RT_COLORMAP != rtype)
+ { /* don't allow anything else besides colormaps */
+ return SecurityAuditResourceIDAccess(client, id);
+ }
+ }
+ return rval;
+} /* SecurityCheckResourceIDAccess */
+
+
+/* SecurityClientStateCallback
+ *
+ * Arguments:
+ * pcbl is &ClientStateCallback.
+ * nullata is NULL.
+ * calldata is a pointer to a NewClientInfoRec (include/dixstruct.h)
+ * which contains information about client state changes.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ *
+ * If a new client is connecting, its authorization ID is copied to
+ * client->authID. If this is a generated authorization, its reference
+ * count is bumped, its timer is cancelled if it was running, and its
+ * trustlevel is copied to client->trustLevel.
+ *
+ * If a client is disconnecting and the client was using a generated
+ * authorization, the authorization's reference count is decremented, and
+ * if it is now zero, the timer for this authorization is started.
+ */
+
+static void
+SecurityClientStateCallback(
+ CallbackListPtr *pcbl,
+ pointer nulldata,
+ pointer calldata)
+{
+ NewClientInfoRec *pci = (NewClientInfoRec *)calldata;
+ ClientPtr client = pci->client;
+
+ switch (client->clientState)
+ {
+ case ClientStateRunning:
+ {
+ XID authId = AuthorizationIDOfClient(client);
+ SecurityAuthorizationPtr pAuth;
+
+ client->authId = authId;
+ pAuth = (SecurityAuthorizationPtr)LookupIDByType(authId,
+ SecurityAuthorizationResType);
+ if (pAuth)
+ { /* it is a generated authorization */
+ pAuth->refcnt++;
+ if (pAuth->refcnt == 1)
+ {
+ if (pAuth->timer) TimerCancel(pAuth->timer);
+ }
+ client->trustLevel = pAuth->trustLevel;
+ if (client->trustLevel != XSecurityClientTrusted)
+ {
+ client->CheckAccess = SecurityCheckResourceIDAccess;
+ client->requestVector = client->swapped ?
+ SwappedUntrustedProcVector : UntrustedProcVector;
+ }
+ }
+ break;
+ }
+ case ClientStateGone:
+ case ClientStateRetained: /* client disconnected */
+ {
+ XID authId = client->authId;
+ SecurityAuthorizationPtr pAuth;
+
+ pAuth = (SecurityAuthorizationPtr)LookupIDByType(authId,
+ SecurityAuthorizationResType);
+ if (pAuth)
+ { /* it is a generated authorization */
+ pAuth->refcnt--;
+ if (pAuth->refcnt == 0)
+ {
+ SecurityStartAuthorizationTimer(pAuth);
+ }
+ }
+ break;
+ }
+ default: break;
+ }
+} /* SecurityClientStateCallback */
+
+#ifdef LBX
+Bool
+SecuritySameLevel(client, authId)
+ ClientPtr client;
+ XID authId;
+{
+ SecurityAuthorizationPtr pAuth;
+
+ pAuth = (SecurityAuthorizationPtr)LookupIDByType(authId,
+ SecurityAuthorizationResType);
+ if (pAuth)
+ return client->trustLevel == pAuth->trustLevel;
+ return client->trustLevel == XSecurityClientTrusted;
+}
+#endif
+
+/* SecurityCensorImage
+ *
+ * Called after pScreen->GetImage to prevent pieces or trusted windows from
+ * being returned in image data from an untrusted window.
+ *
+ * Arguments:
+ * client is the client doing the GetImage.
+ * pVisibleRegion is the visible region of the window.
+ * widthBytesLine is the width in bytes of one horizontal line in pBuf.
+ * pDraw is the source window.
+ * x, y, w, h is the rectangle of image data from pDraw in pBuf.
+ * format is the format of the image data in pBuf: ZPixmap or XYPixmap.
+ * pBuf is the image data.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Any part of the rectangle (x, y, w, h) that is outside the visible
+ * region of the window will be destroyed (overwritten) in pBuf.
+ */
+void
+SecurityCensorImage(client, pVisibleRegion, widthBytesLine, pDraw, x, y, w, h,
+ format, pBuf)
+ ClientPtr client;
+ RegionPtr pVisibleRegion;
+ long widthBytesLine;
+ DrawablePtr pDraw;
+ int x, y, w, h;
+ unsigned int format;
+ char * pBuf;
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ RegionRec imageRegion; /* region representing x,y,w,h */
+ RegionRec censorRegion; /* region to obliterate */
+ BoxRec imageBox;
+ int nRects;
+
+ imageBox.x1 = x;
+ imageBox.y1 = y;
+ imageBox.x2 = x + w;
+ imageBox.y2 = y + h;
+ REGION_INIT(pScreen, &imageRegion, &imageBox, 1);
+ REGION_NULL(pScreen, &censorRegion);
+
+ /* censorRegion = imageRegion - visibleRegion */
+ REGION_SUBTRACT(pScreen, &censorRegion, &imageRegion, pVisibleRegion);
+ nRects = REGION_NUM_RECTS(&censorRegion);
+ if (nRects > 0)
+ { /* we have something to censor */
+ GCPtr pScratchGC = NULL;
+ PixmapPtr pPix = NULL;
+ xRectangle *pRects = NULL;
+ Bool failed = FALSE;
+ int depth = 1;
+ int bitsPerPixel = 1;
+ int i;
+ BoxPtr pBox;
+
+ /* convert region to list-of-rectangles for PolyFillRect */
+
+ pRects = (xRectangle *)ALLOCATE_LOCAL(nRects * sizeof(xRectangle *));
+ if (!pRects)
+ {
+ failed = TRUE;
+ goto failSafe;
+ }
+ for (pBox = REGION_RECTS(&censorRegion), i = 0;
+ i < nRects;
+ i++, pBox++)
+ {
+ pRects[i].x = pBox->x1;
+ pRects[i].y = pBox->y1 - imageBox.y1;
+ pRects[i].width = pBox->x2 - pBox->x1;
+ pRects[i].height = pBox->y2 - pBox->y1;
+ }
+
+ /* use pBuf as a fake pixmap */
+
+ if (format == ZPixmap)
+ {
+ depth = pDraw->depth;
+ bitsPerPixel = pDraw->bitsPerPixel;
+ }
+
+ pPix = GetScratchPixmapHeader(pDraw->pScreen, w, h,
+ depth, bitsPerPixel,
+ widthBytesLine, (pointer)pBuf);
+ if (!pPix)
+ {
+ failed = TRUE;
+ goto failSafe;
+ }
+
+ pScratchGC = GetScratchGC(depth, pPix->drawable.pScreen);
+ if (!pScratchGC)
+ {
+ failed = TRUE;
+ goto failSafe;
+ }
+
+ ValidateGC(&pPix->drawable, pScratchGC);
+ (* pScratchGC->ops->PolyFillRect)(&pPix->drawable,
+ pScratchGC, nRects, pRects);
+
+ failSafe:
+ if (failed)
+ {
+ /* Censoring was not completed above. To be safe, wipe out
+ * all the image data so that nothing trusted gets out.
+ */
+ bzero(pBuf, (int)(widthBytesLine * h));
+ }
+ if (pRects) DEALLOCATE_LOCAL(pRects);
+ if (pScratchGC) FreeScratchGC(pScratchGC);
+ if (pPix) FreeScratchPixmapHeader(pPix);
+ }
+ REGION_UNINIT(pScreen, &imageRegion);
+ REGION_UNINIT(pScreen, &censorRegion);
+} /* SecurityCensorImage */
+
+/**********************************************************************/
+
+typedef struct _PropertyAccessRec {
+ ATOM name;
+ ATOM mustHaveProperty;
+ char *mustHaveValue;
+ char windowRestriction;
+#define SecurityAnyWindow 0
+#define SecurityRootWindow 1
+#define SecurityWindowWithProperty 2
+ char readAction;
+ char writeAction;
+ char destroyAction;
+ struct _PropertyAccessRec *next;
+} PropertyAccessRec, *PropertyAccessPtr;
+
+static PropertyAccessPtr PropertyAccessList = NULL;
+static char SecurityDefaultAction = SecurityErrorOperation;
+static char *SecurityPolicyFile = DEFAULTPOLICYFILE;
+static ATOM SecurityMaxPropertyName = 0;
+
+static char *SecurityKeywords[] = {
+#define SecurityKeywordComment 0
+ "#",
+#define SecurityKeywordProperty 1
+ "property",
+#define SecurityKeywordSitePolicy 2
+ "sitepolicy",
+#define SecurityKeywordRoot 3
+ "root",
+#define SecurityKeywordAny 4
+ "any"
+};
+
+#define NUMKEYWORDS (sizeof(SecurityKeywords) / sizeof(char *))
+
+#undef PROPDEBUG
+/*#define PROPDEBUG 1*/
+
+static void
+SecurityFreePropertyAccessList(void)
+{
+ while (PropertyAccessList)
+ {
+ PropertyAccessPtr freeit = PropertyAccessList;
+ PropertyAccessList = PropertyAccessList->next;
+ xfree(freeit);
+ }
+} /* SecurityFreePropertyAccessList */
+
+#ifndef __UNIXOS2__
+#define SecurityIsWhitespace(c) ( (c == ' ') || (c == '\t') || (c == '\n') )
+#else
+#define SecurityIsWhitespace(c) ( (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r') )
+#endif
+
+static char *
+SecuritySkipWhitespace(
+ char *p)
+{
+ while (SecurityIsWhitespace(*p))
+ p++;
+ return p;
+} /* SecuritySkipWhitespace */
+
+
+static char *
+SecurityParseString(
+ char **rest)
+{
+ char *startOfString;
+ char *s = *rest;
+ char endChar = 0;
+
+ s = SecuritySkipWhitespace(s);
+
+ if (*s == '"' || *s == '\'')
+ {
+ endChar = *s++;
+ startOfString = s;
+ while (*s && (*s != endChar))
+ s++;
+ }
+ else
+ {
+ startOfString = s;
+ while (*s && !SecurityIsWhitespace(*s))
+ s++;
+ }
+ if (*s)
+ {
+ *s = '\0';
+ *rest = s + 1;
+ return startOfString;
+ }
+ else
+ {
+ *rest = s;
+ return (endChar) ? NULL : startOfString;
+ }
+} /* SecurityParseString */
+
+
+static int
+SecurityParseKeyword(
+ char **p)
+{
+ int i;
+ char *s = *p;
+ s = SecuritySkipWhitespace(s);
+ for (i = 0; i < NUMKEYWORDS; i++)
+ {
+ int len = strlen(SecurityKeywords[i]);
+ if (strncmp(s, SecurityKeywords[i], len) == 0)
+ {
+ *p = s + len;
+ return (i);
+ }
+ }
+ *p = s;
+ return -1;
+} /* SecurityParseKeyword */
+
+
+static Bool
+SecurityParsePropertyAccessRule(
+ char *p)
+{
+ char *propname;
+ char c;
+ char action = SecurityDefaultAction;
+ char readAction, writeAction, destroyAction;
+ PropertyAccessPtr pacl, prev, cur;
+ char *mustHaveProperty = NULL;
+ char *mustHaveValue = NULL;
+ Bool invalid;
+ char windowRestriction;
+ int size;
+ int keyword;
+
+ /* get property name */
+ propname = SecurityParseString(&p);
+ if (!propname || (strlen(propname) == 0))
+ return FALSE;
+
+ /* get window on which property must reside for rule to apply */
+
+ keyword = SecurityParseKeyword(&p);
+ if (keyword == SecurityKeywordRoot)
+ windowRestriction = SecurityRootWindow;
+ else if (keyword == SecurityKeywordAny)
+ windowRestriction = SecurityAnyWindow;
+ else /* not root or any, must be a property name */
+ {
+ mustHaveProperty = SecurityParseString(&p);
+ if (!mustHaveProperty || (strlen(mustHaveProperty) == 0))
+ return FALSE;
+ windowRestriction = SecurityWindowWithProperty;
+ p = SecuritySkipWhitespace(p);
+ if (*p == '=')
+ { /* property value is specified too */
+ p++; /* skip over '=' */
+ mustHaveValue = SecurityParseString(&p);
+ if (!mustHaveValue)
+ return FALSE;
+ }
+ }
+
+ /* get operations and actions */
+
+ invalid = FALSE;
+ readAction = writeAction = destroyAction = SecurityDefaultAction;
+ while ( (c = *p++) && !invalid)
+ {
+ switch (c)
+ {
+ case 'i': action = SecurityIgnoreOperation; break;
+ case 'a': action = SecurityAllowOperation; break;
+ case 'e': action = SecurityErrorOperation; break;
+
+ case 'r': readAction = action; break;
+ case 'w': writeAction = action; break;
+ case 'd': destroyAction = action; break;
+
+ default :
+ if (!SecurityIsWhitespace(c))
+ invalid = TRUE;
+ break;
+ }
+ }
+ if (invalid)
+ return FALSE;
+
+ /* We've successfully collected all the information needed for this
+ * property access rule. Now record it in a PropertyAccessRec.
+ */
+ size = sizeof(PropertyAccessRec);
+
+ /* If there is a property value string, allocate space for it
+ * right after the PropertyAccessRec.
+ */
+ if (mustHaveValue)
+ size += strlen(mustHaveValue) + 1;
+ pacl = (PropertyAccessPtr)Xalloc(size);
+ if (!pacl)
+ return FALSE;
+
+ pacl->name = MakeAtom(propname, strlen(propname), TRUE);
+ if (pacl->name == BAD_RESOURCE)
+ {
+ Xfree(pacl);
+ return FALSE;
+ }
+ if (mustHaveProperty)
+ {
+ pacl->mustHaveProperty = MakeAtom(mustHaveProperty,
+ strlen(mustHaveProperty), TRUE);
+ if (pacl->mustHaveProperty == BAD_RESOURCE)
+ {
+ Xfree(pacl);
+ return FALSE;
+ }
+ }
+ else
+ pacl->mustHaveProperty = 0;
+
+ if (mustHaveValue)
+ {
+ pacl->mustHaveValue = (char *)(pacl + 1);
+ strcpy(pacl->mustHaveValue, mustHaveValue);
+ }
+ else
+ pacl->mustHaveValue = NULL;
+
+ SecurityMaxPropertyName = max(SecurityMaxPropertyName, pacl->name);
+
+ pacl->windowRestriction = windowRestriction;
+ pacl->readAction = readAction;
+ pacl->writeAction = writeAction;
+ pacl->destroyAction = destroyAction;
+
+ /* link the new rule into the list of rules in order of increasing
+ * property name (atom) value to make searching easier
+ */
+
+ for (prev = NULL, cur = PropertyAccessList;
+ cur && cur->name <= pacl->name;
+ prev = cur, cur = cur->next)
+ ;
+ if (!prev)
+ {
+ pacl->next = cur;
+ PropertyAccessList = pacl;
+ }
+ else
+ {
+ prev->next = pacl;
+ pacl->next = cur;
+ }
+ return TRUE;
+} /* SecurityParsePropertyAccessRule */
+
+static char **SecurityPolicyStrings = NULL;
+static int nSecurityPolicyStrings = 0;
+
+static Bool
+SecurityParseSitePolicy(
+ char *p)
+{
+ char *policyStr = SecurityParseString(&p);
+ char *copyPolicyStr;
+ char **newStrings;
+
+ if (!policyStr)
+ return FALSE;
+
+ copyPolicyStr = (char *)Xalloc(strlen(policyStr) + 1);
+ if (!copyPolicyStr)
+ return TRUE;
+ strcpy(copyPolicyStr, policyStr);
+ newStrings = (char **)Xrealloc(SecurityPolicyStrings,
+ sizeof (char *) * (nSecurityPolicyStrings + 1));
+ if (!newStrings)
+ {
+ Xfree(copyPolicyStr);
+ return TRUE;
+ }
+
+ SecurityPolicyStrings = newStrings;
+ SecurityPolicyStrings[nSecurityPolicyStrings++] = copyPolicyStr;
+
+ return TRUE;
+
+} /* SecurityParseSitePolicy */
+
+
+char **
+SecurityGetSitePolicyStrings(n)
+ int *n;
+{
+ *n = nSecurityPolicyStrings;
+ return SecurityPolicyStrings;
+} /* SecurityGetSitePolicyStrings */
+
+static void
+SecurityFreeSitePolicyStrings(void)
+{
+ if (SecurityPolicyStrings)
+ {
+ assert(nSecurityPolicyStrings);
+ while (nSecurityPolicyStrings--)
+ {
+ Xfree(SecurityPolicyStrings[nSecurityPolicyStrings]);
+ }
+ Xfree(SecurityPolicyStrings);
+ SecurityPolicyStrings = NULL;
+ nSecurityPolicyStrings = 0;
+ }
+} /* SecurityFreeSitePolicyStrings */
+
+
+static void
+SecurityLoadPropertyAccessList(void)
+{
+ FILE *f;
+ int lineNumber = 0;
+
+ SecurityMaxPropertyName = 0;
+
+#ifdef NXAGENT_SERVER
+
+ if (!_NXGetPolicyFilePath(SecurityPolicyFile))
+ {
+ return;
+ }
+
+#else
+
+ if (!SecurityPolicyFile)
+ return;
+
+#endif
+
+#ifndef __UNIXOS2__
+
+#ifdef NXAGENT_SERVER
+
+ f = fopen(_NXGetPolicyFilePath(SecurityPolicyFile), "r");
+
+#else
+
+ f = fopen(SecurityPolicyFile, "r");
+
+#endif
+
+#else
+
+#ifdef NXAGENT_SERVER
+
+ f = fopen((char*)__XOS2RedirRoot( _NXGetPolicyFilePath(SecurityPolicyFile)), "r");
+
+#else
+
+ f = fopen((char*)__XOS2RedirRoot(SecurityPolicyFile), "r");
+
+#endif
+
+#endif
+
+ if (!f)
+ {
+#ifdef NXAGENT_SERVER
+
+ ErrorF("error opening security policy file %s\n",
+ _NXGetPolicyFilePath(SecurityPolicyFile));
+
+#else
+
+ ErrorF("error opening security policy file %s\n",
+ SecurityPolicyFile);
+
+#endif
+
+ return;
+ }
+
+ while (!feof(f))
+ {
+ char buf[200];
+ Bool validLine;
+ char *p;
+
+ if (!(p = fgets(buf, sizeof(buf), f)))
+ break;
+ lineNumber++;
+
+ /* if first line, check version number */
+ if (lineNumber == 1)
+ {
+ char *v = SecurityParseString(&p);
+ if (strcmp(v, SECURITY_POLICY_FILE_VERSION) != 0)
+ {
+
+#ifdef NXAGENT_SERVER
+
+ ErrorF("%s: invalid security policy file version, ignoring file\n",
+ _NXGetPolicyFilePath(SecurityPolicyFile));
+
+#else
+
+ ErrorF("%s: invalid security policy file version, ignoring file\n",
+ SecurityPolicyFile);
+
+#endif
+
+ break;
+ }
+ validLine = TRUE;
+ }
+ else
+ {
+ switch (SecurityParseKeyword(&p))
+ {
+ case SecurityKeywordComment:
+ validLine = TRUE;
+ break;
+
+ case SecurityKeywordProperty:
+ validLine = SecurityParsePropertyAccessRule(p);
+ break;
+
+ case SecurityKeywordSitePolicy:
+ validLine = SecurityParseSitePolicy(p);
+ break;
+
+ default:
+ validLine = (*p == '\0'); /* blank lines OK, others not */
+ break;
+ }
+ }
+
+#ifdef NXAGENT_SERVER
+
+ if (!validLine)
+ {
+ ErrorF("Line %d of %s invalid, ignoring\n",
+ lineNumber, _NXGetPolicyFilePath(SecurityPolicyFile));
+ }
+
+#else
+
+ if (!validLine)
+ ErrorF("Line %d of %s invalid, ignoring\n",
+ lineNumber, SecurityPolicyFile);
+
+#endif
+
+ } /* end while more input */
+
+#ifdef PROPDEBUG
+ {
+ PropertyAccessPtr pacl;
+ char *op = "aie";
+ for (pacl = PropertyAccessList; pacl; pacl = pacl->next)
+ {
+ ErrorF("property %s ", NameForAtom(pacl->name));
+ switch (pacl->windowRestriction)
+ {
+ case SecurityAnyWindow: ErrorF("any "); break;
+ case SecurityRootWindow: ErrorF("root "); break;
+ case SecurityWindowWithProperty:
+ {
+ ErrorF("%s ", NameForAtom(pacl->mustHaveProperty));
+ if (pacl->mustHaveValue)
+ ErrorF(" = \"%s\" ", pacl->mustHaveValue);
+
+ }
+ break;
+ }
+ ErrorF("%cr %cw %cd\n", op[pacl->readAction],
+ op[pacl->writeAction], op[pacl->destroyAction]);
+ }
+ }
+#endif /* PROPDEBUG */
+
+ fclose(f);
+} /* SecurityLoadPropertyAccessList */
+
+
+static Bool
+SecurityMatchString(
+ char *ws,
+ char *cs)
+{
+ while (*ws && *cs)
+ {
+ if (*ws == '*')
+ {
+ Bool match = FALSE;
+ ws++;
+ while (!(match = SecurityMatchString(ws, cs)) && *cs)
+ {
+ cs++;
+ }
+ return match;
+ }
+ else if (*ws == *cs)
+ {
+ ws++;
+ cs++;
+ }
+ else break;
+ }
+ return ( ( (*ws == '\0') || ((*ws == '*') && *(ws+1) == '\0') )
+ && (*cs == '\0') );
+} /* SecurityMatchString */
+
+#ifdef PROPDEBUG
+#include <sys/types.h>
+#include <sys/stat.h>
+#endif
+
+
+char
+SecurityCheckPropertyAccess(client, pWin, propertyName, access_mode)
+ ClientPtr client;
+ WindowPtr pWin;
+ ATOM propertyName;
+ Mask access_mode;
+{
+ PropertyAccessPtr pacl;
+ char action = SecurityDefaultAction;
+
+ /* if client trusted or window untrusted, allow operation */
+
+ if ( (client->trustLevel == XSecurityClientTrusted) ||
+ (wClient(pWin)->trustLevel != XSecurityClientTrusted) )
+ return SecurityAllowOperation;
+
+#ifdef PROPDEBUG
+ /* For testing, it's more convenient if the property rules file gets
+ * reloaded whenever it changes, so we can rapidly try things without
+ * having to reset the server.
+ */
+ {
+ struct stat buf;
+ static time_t lastmod = 0;
+
+#ifdef NXAGENT_SERVER
+
+ int ret = stat(_NXGetPolicyFilePath(SecurityPolicyFile), &buf);
+
+#else
+
+ int ret = stat(SecurityPolicyFile , &buf);
+
+#endif
+
+ if ( (ret == 0) && (buf.st_mtime > lastmod) )
+ {
+ ErrorF("reloading property rules\n");
+ SecurityFreePropertyAccessList();
+ SecurityLoadPropertyAccessList();
+ lastmod = buf.st_mtime;
+ }
+ }
+#endif
+
+ /* If the property atom is bigger than any atoms on the list,
+ * we know we won't find it, so don't even bother looking.
+ */
+ if (propertyName <= SecurityMaxPropertyName)
+ {
+ /* untrusted client operating on trusted window; see if it's allowed */
+
+ for (pacl = PropertyAccessList; pacl; pacl = pacl->next)
+ {
+ if (pacl->name < propertyName)
+ continue;
+ if (pacl->name > propertyName)
+ break;
+
+ /* pacl->name == propertyName, so see if it applies to this window */
+
+ switch (pacl->windowRestriction)
+ {
+ case SecurityAnyWindow: /* always applies */
+ break;
+
+ case SecurityRootWindow:
+ {
+ /* if not a root window, this rule doesn't apply */
+ if (pWin->parent)
+ continue;
+ }
+ break;
+
+ case SecurityWindowWithProperty:
+ {
+ PropertyPtr pProp = wUserProps (pWin);
+ Bool match = FALSE;
+ char *p;
+ char *pEndData;
+
+ while (pProp)
+ {
+ if (pProp->propertyName == pacl->mustHaveProperty)
+ break;
+ pProp = pProp->next;
+ }
+ if (!pProp)
+ continue;
+ if (!pacl->mustHaveValue)
+ break;
+ if (pProp->type != XA_STRING || pProp->format != 8)
+ continue;
+
+ p = pProp->data;
+ pEndData = ((char *)pProp->data) + pProp->size;
+ while (!match && p < pEndData)
+ {
+ if (SecurityMatchString(pacl->mustHaveValue, p))
+ match = TRUE;
+ else
+ { /* skip to the next string */
+ while (*p++ && p < pEndData)
+ ;
+ }
+ }
+ if (!match)
+ continue;
+ }
+ break; /* end case SecurityWindowWithProperty */
+ } /* end switch on windowRestriction */
+
+ /* If we get here, the property access rule pacl applies.
+ * If pacl doesn't apply, something above should have
+ * executed a continue, which will skip the follwing code.
+ */
+ action = SecurityAllowOperation;
+ if (access_mode & SecurityReadAccess)
+ action = max(action, pacl->readAction);
+ if (access_mode & SecurityWriteAccess)
+ action = max(action, pacl->writeAction);
+ if (access_mode & SecurityDestroyAccess)
+ action = max(action, pacl->destroyAction);
+ break;
+ } /* end for each pacl */
+ } /* end if propertyName <= SecurityMaxPropertyName */
+
+ if (SecurityAllowOperation != action)
+ { /* audit the access violation */
+ int cid = CLIENT_ID(pWin->drawable.id);
+ int reqtype = ((xReq *)client->requestBuffer)->reqType;
+ char *actionstr = (SecurityIgnoreOperation == action) ?
+ "ignored" : "error";
+ SecurityAudit("client %d attempted request %d with window 0x%x property %s (atom 0x%x) of client %d, %s\n",
+ client->index, reqtype, pWin->drawable.id,
+ NameForAtom(propertyName), propertyName, cid, actionstr);
+ }
+ return action;
+} /* SecurityCheckPropertyAccess */
+
+
+/* SecurityResetProc
+ *
+ * Arguments:
+ * extEntry is the extension information for the security extension.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Performs any cleanup needed by Security at server shutdown time.
+ */
+
+static void
+SecurityResetProc(
+ ExtensionEntry *extEntry)
+{
+ SecurityFreePropertyAccessList();
+ SecurityFreeSitePolicyStrings();
+} /* SecurityResetProc */
+
+
+int
+XSecurityOptions(argc, argv, i)
+ int argc;
+ char **argv;
+ int i;
+{
+ if (strcmp(argv[i], "-sp") == 0)
+ {
+ if (i < argc)
+ SecurityPolicyFile = argv[++i];
+ return (i + 1);
+ }
+ return (i);
+} /* XSecurityOptions */
+
+
+
+/* SecurityExtensionInit
+ *
+ * Arguments: none.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Enables the Security extension if possible.
+ */
+
+void
+SecurityExtensionInit(INITARGS)
+{
+ ExtensionEntry *extEntry;
+ int i;
+
+ SecurityAuthorizationResType =
+ CreateNewResourceType(SecurityDeleteAuthorization);
+
+ RTEventClient = CreateNewResourceType(
+ SecurityDeleteAuthorizationEventClient);
+
+ if (!SecurityAuthorizationResType || !RTEventClient)
+ return;
+
+ RTEventClient |= RC_NEVERRETAIN;
+
+ if (!AddCallback(&ClientStateCallback, SecurityClientStateCallback, NULL))
+ return;
+
+ extEntry = AddExtension(SECURITY_EXTENSION_NAME,
+ XSecurityNumberEvents, XSecurityNumberErrors,
+ ProcSecurityDispatch, SProcSecurityDispatch,
+ SecurityResetProc, StandardMinorOpcode);
+
+ SecurityErrorBase = extEntry->errorBase;
+ SecurityEventBase = extEntry->eventBase;
+
+ EventSwapVector[SecurityEventBase + XSecurityAuthorizationRevoked] =
+ (EventSwapPtr)SwapSecurityAuthorizationRevokedEvent;
+
+ /* initialize untrusted proc vectors */
+
+ for (i = 0; i < 128; i++)
+ {
+ UntrustedProcVector[i] = ProcVector[i];
+ SwappedUntrustedProcVector[i] = SwappedProcVector[i];
+ }
+
+ /* make sure insecure extensions are not allowed */
+
+ for (i = 128; i < 256; i++)
+ {
+ if (!UntrustedProcVector[i])
+ {
+ UntrustedProcVector[i] = ProcBadRequest;
+ SwappedUntrustedProcVector[i] = ProcBadRequest;
+ }
+ }
+
+ SecurityLoadPropertyAccessList();
+
+} /* SecurityExtensionInit */
diff --git a/nx-X11/programs/Xserver/Xext/security.c.X.original b/nx-X11/programs/Xserver/Xext/security.c.X.original
new file mode 100644
index 000000000..26c842855
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/security.c.X.original
@@ -0,0 +1,2004 @@
+/* $XdotOrg: xc/programs/Xserver/Xext/security.c,v 1.5 2005/07/03 07:01:04 daniels Exp $ */
+/* $Xorg: security.c,v 1.4 2001/02/09 02:04:32 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/Xext/security.c,v 1.16tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "windowstr.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "colormapst.h"
+#include "propertyst.h"
+#define _SECURITY_SERVER
+#include <X11/extensions/securstr.h>
+#include <assert.h>
+#include <stdarg.h>
+#ifdef LBX
+#define _XLBX_SERVER_
+#include <X11/extensions/XLbx.h>
+extern unsigned char LbxReqCode;
+#endif
+#ifdef XAPPGROUP
+#include <X11/extensions/Xagsrv.h>
+#endif
+#include <stdio.h> /* for file reading operations */
+#include <X11/Xatom.h> /* for XA_STRING */
+
+#ifndef DEFAULTPOLICYFILE
+# define DEFAULTPOLICYFILE NULL
+#endif
+#if defined(WIN32) || defined(__CYGWIN__)
+#include <X11/Xos.h>
+#undef index
+#endif
+
+#include "modinit.h"
+
+static int SecurityErrorBase; /* first Security error number */
+static int SecurityEventBase; /* first Security event number */
+
+CallbackListPtr SecurityValidateGroupCallback = NULL; /* see security.h */
+
+RESTYPE SecurityAuthorizationResType; /* resource type for authorizations */
+
+static RESTYPE RTEventClient;
+
+/* Proc vectors for untrusted clients, swapped and unswapped versions.
+ * These are the same as the normal proc vectors except that extensions
+ * that haven't declared themselves secure will have ProcBadRequest plugged
+ * in for their major opcode dispatcher. This prevents untrusted clients
+ * from guessing extension major opcodes and using the extension even though
+ * the extension can't be listed or queried.
+ */
+int (*UntrustedProcVector[256])(
+ ClientPtr /*client*/
+);
+int (*SwappedUntrustedProcVector[256])(
+ ClientPtr /*client*/
+);
+
+/* SecurityAudit
+ *
+ * Arguments:
+ * format is the formatting string to be used to interpret the
+ * remaining arguments.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Writes the message to the log file if security logging is on.
+ */
+
+void
+SecurityAudit(char *format, ...)
+{
+ va_list args;
+
+ if (auditTrailLevel < SECURITY_AUDIT_LEVEL)
+ return;
+ va_start(args, format);
+ VAuditF(format, args);
+ va_end(args);
+} /* SecurityAudit */
+
+#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
+
+/* SecurityDeleteAuthorization
+ *
+ * Arguments:
+ * value is the authorization to delete.
+ * id is its resource ID.
+ *
+ * Returns: Success.
+ *
+ * Side Effects:
+ * Frees everything associated with the authorization.
+ */
+
+static int
+SecurityDeleteAuthorization(
+ pointer value,
+ XID id)
+{
+ SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)value;
+ unsigned short name_len, data_len;
+ char *name, *data;
+ int status;
+ int i;
+ OtherClientsPtr pEventClient;
+
+ /* Remove the auth using the os layer auth manager */
+
+ status = AuthorizationFromID(pAuth->id, &name_len, &name,
+ &data_len, &data);
+ assert(status);
+ status = RemoveAuthorization(name_len, name, data_len, data);
+ assert(status);
+ (void)status;
+
+ /* free the auth timer if there is one */
+
+ if (pAuth->timer) TimerFree(pAuth->timer);
+
+ /* send revoke events */
+
+ while ((pEventClient = pAuth->eventClients))
+ {
+ /* send revocation event event */
+ ClientPtr client = rClient(pEventClient);
+
+ if (!client->clientGone)
+ {
+ xSecurityAuthorizationRevokedEvent are;
+ are.type = SecurityEventBase + XSecurityAuthorizationRevoked;
+ are.sequenceNumber = client->sequence;
+ are.authId = pAuth->id;
+ WriteEventsToClient(client, 1, (xEvent *)&are);
+ }
+ FreeResource(pEventClient->resource, RT_NONE);
+ }
+
+ /* kill all clients using this auth */
+
+ for (i = 1; i<currentMaxClients; i++)
+ {
+ if (clients[i] && (clients[i]->authId == pAuth->id))
+ CloseDownClient(clients[i]);
+ }
+
+ SecurityAudit("revoked authorization ID %d\n", pAuth->id);
+ xfree(pAuth);
+ return Success;
+
+} /* SecurityDeleteAuthorization */
+
+
+/* resource delete function for RTEventClient */
+static int
+SecurityDeleteAuthorizationEventClient(
+ pointer value,
+ XID id)
+{
+ OtherClientsPtr pEventClient, prev = NULL;
+ SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)value;
+
+ for (pEventClient = pAuth->eventClients;
+ pEventClient;
+ pEventClient = pEventClient->next)
+ {
+ if (pEventClient->resource == id)
+ {
+ if (prev)
+ prev->next = pEventClient->next;
+ else
+ pAuth->eventClients = pEventClient->next;
+ xfree(pEventClient);
+ return(Success);
+ }
+ prev = pEventClient;
+ }
+ /*NOTREACHED*/
+ return -1; /* make compiler happy */
+} /* SecurityDeleteAuthorizationEventClient */
+
+
+/* SecurityComputeAuthorizationTimeout
+ *
+ * Arguments:
+ * pAuth is the authorization for which we are computing the timeout
+ * seconds is the number of seconds we want to wait
+ *
+ * Returns:
+ * the number of milliseconds that the auth timer should be set to
+ *
+ * Side Effects:
+ * Sets pAuth->secondsRemaining to any "overflow" amount of time
+ * that didn't fit in 32 bits worth of milliseconds
+ */
+
+static CARD32
+SecurityComputeAuthorizationTimeout(
+ SecurityAuthorizationPtr pAuth,
+ unsigned int seconds)
+{
+ /* maxSecs is the number of full seconds that can be expressed in
+ * 32 bits worth of milliseconds
+ */
+ CARD32 maxSecs = (CARD32)(~0) / (CARD32)MILLI_PER_SECOND;
+
+ if (seconds > maxSecs)
+ { /* only come here if we want to wait more than 49 days */
+ pAuth->secondsRemaining = seconds - maxSecs;
+ return maxSecs * MILLI_PER_SECOND;
+ }
+ else
+ { /* by far the common case */
+ pAuth->secondsRemaining = 0;
+ return seconds * MILLI_PER_SECOND;
+ }
+} /* SecurityStartAuthorizationTimer */
+
+/* SecurityAuthorizationExpired
+ *
+ * This function is passed as an argument to TimerSet and gets called from
+ * the timer manager in the os layer when its time is up.
+ *
+ * Arguments:
+ * timer is the timer for this authorization.
+ * time is the current time.
+ * pval is the authorization whose time is up.
+ *
+ * Returns:
+ * A new time delay in milliseconds if the timer should wait some
+ * more, else zero.
+ *
+ * Side Effects:
+ * Frees the authorization resource if the timeout period is really
+ * over, otherwise recomputes pAuth->secondsRemaining.
+ */
+
+static CARD32
+SecurityAuthorizationExpired(
+ OsTimerPtr timer,
+ CARD32 time,
+ pointer pval)
+{
+ SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)pval;
+
+ assert(pAuth->timer == timer);
+
+ if (pAuth->secondsRemaining)
+ {
+ return SecurityComputeAuthorizationTimeout(pAuth,
+ pAuth->secondsRemaining);
+ }
+ else
+ {
+ FreeResource(pAuth->id, RT_NONE);
+ return 0;
+ }
+} /* SecurityAuthorizationExpired */
+
+/* SecurityStartAuthorizationTimer
+ *
+ * Arguments:
+ * pAuth is the authorization whose timer should be started.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * A timer is started, set to expire after the timeout period for
+ * this authorization. When it expires, the function
+ * SecurityAuthorizationExpired will be called.
+ */
+
+static void
+SecurityStartAuthorizationTimer(
+ SecurityAuthorizationPtr pAuth)
+{
+ pAuth->timer = TimerSet(pAuth->timer, 0,
+ SecurityComputeAuthorizationTimeout(pAuth, pAuth->timeout),
+ SecurityAuthorizationExpired, pAuth);
+} /* SecurityStartAuthorizationTimer */
+
+
+/* Proc functions all take a client argument, execute the request in
+ * client->requestBuffer, and return a protocol error status.
+ */
+
+static int
+ProcSecurityQueryVersion(
+ ClientPtr client)
+{
+ /* REQUEST(xSecurityQueryVersionReq); */
+ xSecurityQueryVersionReply rep;
+
+ /* paranoia: this "can't happen" because this extension is hidden
+ * from untrusted clients, but just in case...
+ */
+ if (client->trustLevel != XSecurityClientTrusted)
+ return BadRequest;
+
+ REQUEST_SIZE_MATCH(xSecurityQueryVersionReq);
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.majorVersion = SECURITY_MAJOR_VERSION;
+ rep.minorVersion = SECURITY_MINOR_VERSION;
+ if(client->swapped)
+ {
+ register char n;
+ swaps(&rep.sequenceNumber, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ }
+ (void)WriteToClient(client, SIZEOF(xSecurityQueryVersionReply),
+ (char *)&rep);
+ return (client->noClientException);
+} /* ProcSecurityQueryVersion */
+
+
+static int
+SecurityEventSelectForAuthorization(
+ SecurityAuthorizationPtr pAuth,
+ ClientPtr client,
+ Mask mask)
+{
+ OtherClients *pEventClient;
+
+ for (pEventClient = pAuth->eventClients;
+ pEventClient;
+ pEventClient = pEventClient->next)
+ {
+ if (SameClient(pEventClient, client))
+ {
+ if (mask == 0)
+ FreeResource(pEventClient->resource, RT_NONE);
+ else
+ pEventClient->mask = mask;
+ return Success;
+ }
+ }
+
+ pEventClient = (OtherClients *) xalloc(sizeof(OtherClients));
+ if (!pEventClient)
+ return BadAlloc;
+ pEventClient->mask = mask;
+ pEventClient->resource = FakeClientID(client->index);
+ pEventClient->next = pAuth->eventClients;
+ if (!AddResource(pEventClient->resource, RTEventClient,
+ (pointer)pAuth))
+ {
+ xfree(pEventClient);
+ return BadAlloc;
+ }
+ pAuth->eventClients = pEventClient;
+
+ return Success;
+} /* SecurityEventSelectForAuthorization */
+
+
+static int
+ProcSecurityGenerateAuthorization(
+ ClientPtr client)
+{
+ REQUEST(xSecurityGenerateAuthorizationReq);
+ int len; /* request length in CARD32s*/
+ Bool removeAuth = FALSE; /* if bailout, call RemoveAuthorization? */
+ SecurityAuthorizationPtr pAuth = NULL; /* auth we are creating */
+ int err; /* error to return from this function */
+ XID authId; /* authorization ID assigned by os layer */
+ xSecurityGenerateAuthorizationReply rep; /* reply struct */
+ unsigned int trustLevel; /* trust level of new auth */
+ XID group; /* group of new auth */
+ CARD32 timeout; /* timeout of new auth */
+ CARD32 *values; /* list of supplied attributes */
+ char *protoname; /* auth proto name sent in request */
+ char *protodata; /* auth proto data sent in request */
+ unsigned int authdata_len; /* # bytes of generated auth data */
+ char *pAuthdata; /* generated auth data */
+ Mask eventMask; /* what events on this auth does client want */
+
+ /* paranoia: this "can't happen" because this extension is hidden
+ * from untrusted clients, but just in case...
+ */
+ if (client->trustLevel != XSecurityClientTrusted)
+ return BadRequest;
+
+ /* check request length */
+
+ REQUEST_AT_LEAST_SIZE(xSecurityGenerateAuthorizationReq);
+ len = SIZEOF(xSecurityGenerateAuthorizationReq) >> 2;
+ len += (stuff->nbytesAuthProto + (unsigned)3) >> 2;
+ len += (stuff->nbytesAuthData + (unsigned)3) >> 2;
+ values = ((CARD32 *)stuff) + len;
+ len += Ones(stuff->valueMask);
+ if (client->req_len != len)
+ return BadLength;
+
+ /* check valuemask */
+ if (stuff->valueMask & ~XSecurityAllAuthorizationAttributes)
+ {
+ client->errorValue = stuff->valueMask;
+ return BadValue;
+ }
+
+ /* check timeout */
+ timeout = 60;
+ if (stuff->valueMask & XSecurityTimeout)
+ {
+ timeout = *values++;
+ }
+
+ /* check trustLevel */
+ trustLevel = XSecurityClientUntrusted;
+ if (stuff->valueMask & XSecurityTrustLevel)
+ {
+ trustLevel = *values++;
+ if (trustLevel != XSecurityClientTrusted &&
+ trustLevel != XSecurityClientUntrusted)
+ {
+ client->errorValue = trustLevel;
+ return BadValue;
+ }
+ }
+
+ /* check group */
+ group = None;
+ if (stuff->valueMask & XSecurityGroup)
+ {
+ group = *values++;
+ if (SecurityValidateGroupCallback)
+ {
+ SecurityValidateGroupInfoRec vgi;
+ vgi.group = group;
+ vgi.valid = FALSE;
+ CallCallbacks(&SecurityValidateGroupCallback, (pointer)&vgi);
+
+ /* if nobody said they recognized it, it's an error */
+
+ if (!vgi.valid)
+ {
+ client->errorValue = group;
+ return BadValue;
+ }
+ }
+ }
+
+ /* check event mask */
+ eventMask = 0;
+ if (stuff->valueMask & XSecurityEventMask)
+ {
+ eventMask = *values++;
+ if (eventMask & ~XSecurityAllEventMasks)
+ {
+ client->errorValue = eventMask;
+ return BadValue;
+ }
+ }
+
+ protoname = (char *)&stuff[1];
+ protodata = protoname + ((stuff->nbytesAuthProto + (unsigned)3) >> 2);
+
+ /* call os layer to generate the authorization */
+
+ authId = GenerateAuthorization(stuff->nbytesAuthProto, protoname,
+ stuff->nbytesAuthData, protodata,
+ &authdata_len, &pAuthdata);
+ if ((XID) ~0L == authId)
+ {
+ err = SecurityErrorBase + XSecurityBadAuthorizationProtocol;
+ goto bailout;
+ }
+
+ /* now that we've added the auth, remember to remove it if we have to
+ * abort the request for some reason (like allocation failure)
+ */
+ removeAuth = TRUE;
+
+ /* associate additional information with this auth ID */
+
+ pAuth = (SecurityAuthorizationPtr)xalloc(sizeof(SecurityAuthorizationRec));
+ if (!pAuth)
+ {
+ err = BadAlloc;
+ goto bailout;
+ }
+
+ /* fill in the auth fields */
+
+ pAuth->id = authId;
+ pAuth->timeout = timeout;
+ pAuth->group = group;
+ pAuth->trustLevel = trustLevel;
+ pAuth->refcnt = 0; /* the auth was just created; nobody's using it yet */
+ pAuth->secondsRemaining = 0;
+ pAuth->timer = NULL;
+ pAuth->eventClients = NULL;
+
+ /* handle event selection */
+ if (eventMask)
+ {
+ err = SecurityEventSelectForAuthorization(pAuth, client, eventMask);
+ if (err != Success)
+ goto bailout;
+ }
+
+ if (!AddResource(authId, SecurityAuthorizationResType, pAuth))
+ {
+ err = BadAlloc;
+ goto bailout;
+ }
+
+ /* start the timer ticking */
+
+ if (pAuth->timeout != 0)
+ SecurityStartAuthorizationTimer(pAuth);
+
+ /* tell client the auth id and data */
+
+ rep.type = X_Reply;
+ rep.length = (authdata_len + 3) >> 2;
+ rep.sequenceNumber = client->sequence;
+ rep.authId = authId;
+ rep.dataLength = authdata_len;
+
+ if (client->swapped)
+ {
+ register char n;
+ swapl(&rep.length, n);
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.authId, n);
+ swaps(&rep.dataLength, n);
+ }
+
+ WriteToClient(client, SIZEOF(xSecurityGenerateAuthorizationReply),
+ (char *)&rep);
+ WriteToClient(client, authdata_len, pAuthdata);
+
+ SecurityAudit("client %d generated authorization %d trust %d timeout %d group %d events %d\n",
+ client->index, pAuth->id, pAuth->trustLevel, pAuth->timeout,
+ pAuth->group, eventMask);
+
+ /* the request succeeded; don't call RemoveAuthorization or free pAuth */
+
+ removeAuth = FALSE;
+ pAuth = NULL;
+ err = client->noClientException;
+
+bailout:
+ if (removeAuth)
+ RemoveAuthorization(stuff->nbytesAuthProto, protoname,
+ authdata_len, pAuthdata);
+ if (pAuth) xfree(pAuth);
+ return err;
+
+} /* ProcSecurityGenerateAuthorization */
+
+static int
+ProcSecurityRevokeAuthorization(
+ ClientPtr client)
+{
+ REQUEST(xSecurityRevokeAuthorizationReq);
+ SecurityAuthorizationPtr pAuth;
+
+ /* paranoia: this "can't happen" because this extension is hidden
+ * from untrusted clients, but just in case...
+ */
+ if (client->trustLevel != XSecurityClientTrusted)
+ return BadRequest;
+
+ REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq);
+
+ pAuth = (SecurityAuthorizationPtr)SecurityLookupIDByType(client,
+ stuff->authId, SecurityAuthorizationResType, SecurityDestroyAccess);
+ if (!pAuth)
+ return SecurityErrorBase + XSecurityBadAuthorization;
+
+ FreeResource(stuff->authId, RT_NONE);
+ return Success;
+} /* ProcSecurityRevokeAuthorization */
+
+
+static int
+ProcSecurityDispatch(
+ ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_SecurityQueryVersion:
+ return ProcSecurityQueryVersion(client);
+ case X_SecurityGenerateAuthorization:
+ return ProcSecurityGenerateAuthorization(client);
+ case X_SecurityRevokeAuthorization:
+ return ProcSecurityRevokeAuthorization(client);
+ default:
+ return BadRequest;
+ }
+} /* ProcSecurityDispatch */
+
+static int
+SProcSecurityQueryVersion(
+ ClientPtr client)
+{
+ REQUEST(xSecurityQueryVersionReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSecurityQueryVersionReq);
+ swaps(&stuff->majorVersion, n);
+ swaps(&stuff->minorVersion,n);
+ return ProcSecurityQueryVersion(client);
+} /* SProcSecurityQueryVersion */
+
+
+static int
+SProcSecurityGenerateAuthorization(
+ ClientPtr client)
+{
+ REQUEST(xSecurityGenerateAuthorizationReq);
+ register char n;
+ CARD32 *values;
+ unsigned long nvalues;
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSecurityGenerateAuthorizationReq);
+ swaps(&stuff->nbytesAuthProto, n);
+ swaps(&stuff->nbytesAuthData, n);
+ swapl(&stuff->valueMask, n);
+ values = (CARD32 *)(&stuff[1]) +
+ ((stuff->nbytesAuthProto + (unsigned)3) >> 2) +
+ ((stuff->nbytesAuthData + (unsigned)3) >> 2);
+ nvalues = (((CARD32 *)stuff) + stuff->length) - values;
+ SwapLongs(values, nvalues);
+ return ProcSecurityGenerateAuthorization(client);
+} /* SProcSecurityGenerateAuthorization */
+
+
+static int
+SProcSecurityRevokeAuthorization(
+ ClientPtr client)
+{
+ REQUEST(xSecurityRevokeAuthorizationReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq);
+ swapl(&stuff->authId, n);
+ return ProcSecurityRevokeAuthorization(client);
+} /* SProcSecurityRevokeAuthorization */
+
+
+static int
+SProcSecurityDispatch(
+ ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_SecurityQueryVersion:
+ return SProcSecurityQueryVersion(client);
+ case X_SecurityGenerateAuthorization:
+ return SProcSecurityGenerateAuthorization(client);
+ case X_SecurityRevokeAuthorization:
+ return SProcSecurityRevokeAuthorization(client);
+ default:
+ return BadRequest;
+ }
+} /* SProcSecurityDispatch */
+
+static void
+SwapSecurityAuthorizationRevokedEvent(
+ xSecurityAuthorizationRevokedEvent *from,
+ xSecurityAuthorizationRevokedEvent *to)
+{
+ to->type = from->type;
+ to->detail = from->detail;
+ cpswaps(from->sequenceNumber, to->sequenceNumber);
+ cpswapl(from->authId, to->authId);
+}
+
+/* SecurityDetermineEventPropogationLimits
+ *
+ * This is a helper function for SecurityCheckDeviceAccess.
+ *
+ * Arguments:
+ * dev is the device for which the starting and stopping windows for
+ * event propogation should be determined.
+ * The values pointed to by ppWin and ppStopWin are not used.
+ *
+ * Returns:
+ * ppWin is filled in with a pointer to the window at which event
+ * propogation for the given device should start given the current
+ * state of the server (pointer position, window layout, etc.)
+ * ppStopWin is filled in with the window at which event propogation
+ * should stop; events should not go to ppStopWin.
+ *
+ * Side Effects: none.
+ */
+
+static void
+SecurityDetermineEventPropogationLimits(
+ DeviceIntPtr dev,
+ WindowPtr *ppWin,
+ WindowPtr *ppStopWin)
+{
+ WindowPtr pFocusWin = dev->focus ? dev->focus->win : NoneWin;
+
+ if (pFocusWin == NoneWin)
+ { /* no focus -- events don't go anywhere */
+ *ppWin = *ppStopWin = NULL;
+ return;
+ }
+
+ if (pFocusWin == PointerRootWin)
+ { /* focus follows the pointer */
+ *ppWin = GetSpriteWindow();
+ *ppStopWin = NULL; /* propogate all the way to the root */
+ }
+ else
+ { /* a real window is set for the focus */
+ WindowPtr pSpriteWin = GetSpriteWindow();
+ *ppStopWin = pFocusWin->parent; /* don't go past the focus window */
+
+ /* if the pointer is in a subwindow of the focus window, start
+ * at that subwindow, else start at the focus window itself
+ */
+ if (IsParent(pFocusWin, pSpriteWin))
+ *ppWin = pSpriteWin;
+ else *ppWin = pFocusWin;
+ }
+} /* SecurityDetermineEventPropogationLimits */
+
+
+/* SecurityCheckDeviceAccess
+ *
+ * Arguments:
+ * client is the client attempting to access a device.
+ * dev is the device being accessed.
+ * fromRequest is TRUE if the device access is a direct result of
+ * the client executing some request and FALSE if it is a
+ * result of the server trying to send an event (e.g. KeymapNotify)
+ * to the client.
+ * Returns:
+ * TRUE if the device access should be allowed, else FALSE.
+ *
+ * Side Effects:
+ * An audit message is generated if access is denied.
+ */
+
+Bool
+SecurityCheckDeviceAccess(client, dev, fromRequest)
+ ClientPtr client;
+ DeviceIntPtr dev;
+ Bool fromRequest;
+{
+ WindowPtr pWin, pStopWin;
+ Bool untrusted_got_event;
+ Bool found_event_window;
+ Mask eventmask;
+ int reqtype = 0;
+
+ /* trusted clients always allowed to do anything */
+ if (client->trustLevel == XSecurityClientTrusted)
+ return TRUE;
+
+ /* device security other than keyboard is not implemented yet */
+ if (dev != inputInfo.keyboard)
+ return TRUE;
+
+ /* some untrusted client wants access */
+
+ if (fromRequest)
+ {
+ reqtype = ((xReq *)client->requestBuffer)->reqType;
+ switch (reqtype)
+ {
+ /* never allow these */
+ case X_ChangeKeyboardMapping:
+ case X_ChangeKeyboardControl:
+ case X_SetModifierMapping:
+ SecurityAudit("client %d attempted request %d\n",
+ client->index, reqtype);
+ return FALSE;
+ default:
+ break;
+ }
+ }
+
+ untrusted_got_event = FALSE;
+ found_event_window = FALSE;
+
+ if (dev->grab)
+ {
+ untrusted_got_event =
+ ((rClient(dev->grab))->trustLevel != XSecurityClientTrusted);
+ }
+ else
+ {
+ SecurityDetermineEventPropogationLimits(dev, &pWin, &pStopWin);
+
+ eventmask = KeyPressMask | KeyReleaseMask;
+ while ( (pWin != pStopWin) && !found_event_window)
+ {
+ OtherClients *other;
+
+ if (pWin->eventMask & eventmask)
+ {
+ found_event_window = TRUE;
+ client = wClient(pWin);
+ if (client->trustLevel != XSecurityClientTrusted)
+ {
+ untrusted_got_event = TRUE;
+ }
+ }
+ if (wOtherEventMasks(pWin) & eventmask)
+ {
+ found_event_window = TRUE;
+ for (other = wOtherClients(pWin); other; other = other->next)
+ {
+ if (other->mask & eventmask)
+ {
+ client = rClient(other);
+ if (client->trustLevel != XSecurityClientTrusted)
+ {
+ untrusted_got_event = TRUE;
+ break;
+ }
+ }
+ }
+ }
+ if (wDontPropagateMask(pWin) & eventmask)
+ break;
+ pWin = pWin->parent;
+ } /* while propogating the event */
+ }
+
+ /* allow access by untrusted clients only if an event would have gone
+ * to an untrusted client
+ */
+
+ if (!untrusted_got_event)
+ {
+ char *devname = dev->name;
+ if (!devname) devname = "unnamed";
+ if (fromRequest)
+ SecurityAudit("client %d attempted request %d device %d (%s)\n",
+ client->index, reqtype, dev->id, devname);
+ else
+ SecurityAudit("client %d attempted to access device %d (%s)\n",
+ client->index, dev->id, devname);
+ }
+ return untrusted_got_event;
+} /* SecurityCheckDeviceAccess */
+
+
+
+/* SecurityAuditResourceIDAccess
+ *
+ * Arguments:
+ * client is the client doing the resource access.
+ * id is the resource id.
+ *
+ * Returns: NULL
+ *
+ * Side Effects:
+ * An audit message is generated with details of the denied
+ * resource access.
+ */
+
+static pointer
+SecurityAuditResourceIDAccess(
+ ClientPtr client,
+ XID id)
+{
+ int cid = CLIENT_ID(id);
+ int reqtype = ((xReq *)client->requestBuffer)->reqType;
+ switch (reqtype)
+ {
+ case X_ChangeProperty:
+ case X_DeleteProperty:
+ case X_GetProperty:
+ {
+ xChangePropertyReq *req =
+ (xChangePropertyReq *)client->requestBuffer;
+ int propertyatom = req->property;
+ char *propertyname = NameForAtom(propertyatom);
+
+ SecurityAudit("client %d attempted request %d with window 0x%x property %s of client %d\n",
+ client->index, reqtype, id, propertyname, cid);
+ break;
+ }
+ default:
+ {
+ SecurityAudit("client %d attempted request %d with resource 0x%x of client %d\n",
+ client->index, reqtype, id, cid);
+ break;
+ }
+ }
+ return NULL;
+} /* SecurityAuditResourceIDAccess */
+
+
+/* SecurityCheckResourceIDAccess
+ *
+ * This function gets plugged into client->CheckAccess and is called from
+ * SecurityLookupIDByType/Class to determine if the client can access the
+ * resource.
+ *
+ * Arguments:
+ * client is the client doing the resource access.
+ * id is the resource id.
+ * rtype is its type or class.
+ * access_mode represents the intended use of the resource; see
+ * resource.h.
+ * rval is a pointer to the resource structure for this resource.
+ *
+ * Returns:
+ * If access is granted, the value of rval that was passed in, else NULL.
+ *
+ * Side Effects:
+ * Disallowed resource accesses are audited.
+ */
+
+static pointer
+SecurityCheckResourceIDAccess(
+ ClientPtr client,
+ XID id,
+ RESTYPE rtype,
+ Mask access_mode,
+ pointer rval)
+{
+ int cid = CLIENT_ID(id);
+ int reqtype = ((xReq *)client->requestBuffer)->reqType;
+
+ if (SecurityUnknownAccess == access_mode)
+ return rval; /* for compatibility, we have to allow access */
+
+ switch (reqtype)
+ { /* these are always allowed */
+ case X_QueryTree:
+ case X_TranslateCoords:
+ case X_GetGeometry:
+ /* property access is controlled in SecurityCheckPropertyAccess */
+ case X_GetProperty:
+ case X_ChangeProperty:
+ case X_DeleteProperty:
+ case X_RotateProperties:
+ case X_ListProperties:
+ return rval;
+ default:
+ break;
+ }
+
+ if (cid != 0)
+ { /* not a server-owned resource */
+ /*
+ * The following 'if' restricts clients to only access resources at
+ * the same trustLevel. Since there are currently only two trust levels,
+ * and trusted clients never call this function, this degenerates into
+ * saying that untrusted clients can only access resources of other
+ * untrusted clients. One way to add the notion of groups would be to
+ * allow values other than Trusted (0) and Untrusted (1) for this field.
+ * Clients at the same trust level would be able to use each other's
+ * resources, but not those of clients at other trust levels. I haven't
+ * tried it, but this probably mostly works already. The obvious
+ * competing alternative for grouping clients for security purposes is to
+ * use app groups. dpw
+ */
+ if (client->trustLevel == clients[cid]->trustLevel
+#ifdef XAPPGROUP
+ || (RT_COLORMAP == rtype &&
+ XagDefaultColormap (client) == (Colormap) id)
+#endif
+ )
+ return rval;
+ else
+ return SecurityAuditResourceIDAccess(client, id);
+ }
+ else /* server-owned resource - probably a default colormap or root window */
+ {
+ if (RT_WINDOW == rtype || RC_DRAWABLE == rtype)
+ {
+ switch (reqtype)
+ { /* the following operations are allowed on root windows */
+ case X_CreatePixmap:
+ case X_CreateGC:
+ case X_CreateWindow:
+ case X_CreateColormap:
+ case X_ListProperties:
+ case X_GrabPointer:
+ case X_UngrabButton:
+ case X_QueryBestSize:
+ case X_GetWindowAttributes:
+ break;
+ case X_SendEvent:
+ { /* see if it is an event specified by the ICCCM */
+ xSendEventReq *req = (xSendEventReq *)
+ (client->requestBuffer);
+ if (req->propagate == xTrue
+ ||
+ (req->eventMask != ColormapChangeMask &&
+ req->eventMask != StructureNotifyMask &&
+ req->eventMask !=
+ (SubstructureRedirectMask|SubstructureNotifyMask)
+ )
+ ||
+ (req->event.u.u.type != UnmapNotify &&
+ req->event.u.u.type != ConfigureRequest &&
+ req->event.u.u.type != ClientMessage
+ )
+ )
+ { /* not an ICCCM event */
+ return SecurityAuditResourceIDAccess(client, id);
+ }
+ break;
+ } /* case X_SendEvent on root */
+
+ case X_ChangeWindowAttributes:
+ { /* Allow selection of PropertyNotify and StructureNotify
+ * events on the root.
+ */
+ xChangeWindowAttributesReq *req =
+ (xChangeWindowAttributesReq *)(client->requestBuffer);
+ if (req->valueMask == CWEventMask)
+ {
+ CARD32 value = *((CARD32 *)(req + 1));
+ if ( (value &
+ ~(PropertyChangeMask|StructureNotifyMask)) == 0)
+ break;
+ }
+ return SecurityAuditResourceIDAccess(client, id);
+ } /* case X_ChangeWindowAttributes on root */
+
+ default:
+ {
+#ifdef LBX
+ /* XXX really need per extension dispatching */
+ if (reqtype == LbxReqCode) {
+ switch (((xReq *)client->requestBuffer)->data) {
+ case X_LbxGetProperty:
+ case X_LbxChangeProperty:
+ return rval;
+ default:
+ break;
+ }
+ }
+#endif
+ /* others not allowed */
+ return SecurityAuditResourceIDAccess(client, id);
+ }
+ }
+ } /* end server-owned window or drawable */
+ else if (SecurityAuthorizationResType == rtype)
+ {
+ SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)rval;
+ if (pAuth->trustLevel != client->trustLevel)
+ return SecurityAuditResourceIDAccess(client, id);
+ }
+ else if (RT_COLORMAP != rtype)
+ { /* don't allow anything else besides colormaps */
+ return SecurityAuditResourceIDAccess(client, id);
+ }
+ }
+ return rval;
+} /* SecurityCheckResourceIDAccess */
+
+
+/* SecurityClientStateCallback
+ *
+ * Arguments:
+ * pcbl is &ClientStateCallback.
+ * nullata is NULL.
+ * calldata is a pointer to a NewClientInfoRec (include/dixstruct.h)
+ * which contains information about client state changes.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ *
+ * If a new client is connecting, its authorization ID is copied to
+ * client->authID. If this is a generated authorization, its reference
+ * count is bumped, its timer is cancelled if it was running, and its
+ * trustlevel is copied to client->trustLevel.
+ *
+ * If a client is disconnecting and the client was using a generated
+ * authorization, the authorization's reference count is decremented, and
+ * if it is now zero, the timer for this authorization is started.
+ */
+
+static void
+SecurityClientStateCallback(
+ CallbackListPtr *pcbl,
+ pointer nulldata,
+ pointer calldata)
+{
+ NewClientInfoRec *pci = (NewClientInfoRec *)calldata;
+ ClientPtr client = pci->client;
+
+ switch (client->clientState)
+ {
+ case ClientStateRunning:
+ {
+ XID authId = AuthorizationIDOfClient(client);
+ SecurityAuthorizationPtr pAuth;
+
+ client->authId = authId;
+ pAuth = (SecurityAuthorizationPtr)LookupIDByType(authId,
+ SecurityAuthorizationResType);
+ if (pAuth)
+ { /* it is a generated authorization */
+ pAuth->refcnt++;
+ if (pAuth->refcnt == 1)
+ {
+ if (pAuth->timer) TimerCancel(pAuth->timer);
+ }
+ client->trustLevel = pAuth->trustLevel;
+ if (client->trustLevel != XSecurityClientTrusted)
+ {
+ client->CheckAccess = SecurityCheckResourceIDAccess;
+ client->requestVector = client->swapped ?
+ SwappedUntrustedProcVector : UntrustedProcVector;
+ }
+ }
+ break;
+ }
+ case ClientStateGone:
+ case ClientStateRetained: /* client disconnected */
+ {
+ XID authId = client->authId;
+ SecurityAuthorizationPtr pAuth;
+
+ pAuth = (SecurityAuthorizationPtr)LookupIDByType(authId,
+ SecurityAuthorizationResType);
+ if (pAuth)
+ { /* it is a generated authorization */
+ pAuth->refcnt--;
+ if (pAuth->refcnt == 0)
+ {
+ SecurityStartAuthorizationTimer(pAuth);
+ }
+ }
+ break;
+ }
+ default: break;
+ }
+} /* SecurityClientStateCallback */
+
+#ifdef LBX
+Bool
+SecuritySameLevel(client, authId)
+ ClientPtr client;
+ XID authId;
+{
+ SecurityAuthorizationPtr pAuth;
+
+ pAuth = (SecurityAuthorizationPtr)LookupIDByType(authId,
+ SecurityAuthorizationResType);
+ if (pAuth)
+ return client->trustLevel == pAuth->trustLevel;
+ return client->trustLevel == XSecurityClientTrusted;
+}
+#endif
+
+/* SecurityCensorImage
+ *
+ * Called after pScreen->GetImage to prevent pieces or trusted windows from
+ * being returned in image data from an untrusted window.
+ *
+ * Arguments:
+ * client is the client doing the GetImage.
+ * pVisibleRegion is the visible region of the window.
+ * widthBytesLine is the width in bytes of one horizontal line in pBuf.
+ * pDraw is the source window.
+ * x, y, w, h is the rectangle of image data from pDraw in pBuf.
+ * format is the format of the image data in pBuf: ZPixmap or XYPixmap.
+ * pBuf is the image data.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Any part of the rectangle (x, y, w, h) that is outside the visible
+ * region of the window will be destroyed (overwritten) in pBuf.
+ */
+void
+SecurityCensorImage(client, pVisibleRegion, widthBytesLine, pDraw, x, y, w, h,
+ format, pBuf)
+ ClientPtr client;
+ RegionPtr pVisibleRegion;
+ long widthBytesLine;
+ DrawablePtr pDraw;
+ int x, y, w, h;
+ unsigned int format;
+ char * pBuf;
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ RegionRec imageRegion; /* region representing x,y,w,h */
+ RegionRec censorRegion; /* region to obliterate */
+ BoxRec imageBox;
+ int nRects;
+
+ imageBox.x1 = x;
+ imageBox.y1 = y;
+ imageBox.x2 = x + w;
+ imageBox.y2 = y + h;
+ REGION_INIT(pScreen, &imageRegion, &imageBox, 1);
+ REGION_NULL(pScreen, &censorRegion);
+
+ /* censorRegion = imageRegion - visibleRegion */
+ REGION_SUBTRACT(pScreen, &censorRegion, &imageRegion, pVisibleRegion);
+ nRects = REGION_NUM_RECTS(&censorRegion);
+ if (nRects > 0)
+ { /* we have something to censor */
+ GCPtr pScratchGC = NULL;
+ PixmapPtr pPix = NULL;
+ xRectangle *pRects = NULL;
+ Bool failed = FALSE;
+ int depth = 1;
+ int bitsPerPixel = 1;
+ int i;
+ BoxPtr pBox;
+
+ /* convert region to list-of-rectangles for PolyFillRect */
+
+ pRects = (xRectangle *)ALLOCATE_LOCAL(nRects * sizeof(xRectangle *));
+ if (!pRects)
+ {
+ failed = TRUE;
+ goto failSafe;
+ }
+ for (pBox = REGION_RECTS(&censorRegion), i = 0;
+ i < nRects;
+ i++, pBox++)
+ {
+ pRects[i].x = pBox->x1;
+ pRects[i].y = pBox->y1 - imageBox.y1;
+ pRects[i].width = pBox->x2 - pBox->x1;
+ pRects[i].height = pBox->y2 - pBox->y1;
+ }
+
+ /* use pBuf as a fake pixmap */
+
+ if (format == ZPixmap)
+ {
+ depth = pDraw->depth;
+ bitsPerPixel = pDraw->bitsPerPixel;
+ }
+
+ pPix = GetScratchPixmapHeader(pDraw->pScreen, w, h,
+ depth, bitsPerPixel,
+ widthBytesLine, (pointer)pBuf);
+ if (!pPix)
+ {
+ failed = TRUE;
+ goto failSafe;
+ }
+
+ pScratchGC = GetScratchGC(depth, pPix->drawable.pScreen);
+ if (!pScratchGC)
+ {
+ failed = TRUE;
+ goto failSafe;
+ }
+
+ ValidateGC(&pPix->drawable, pScratchGC);
+ (* pScratchGC->ops->PolyFillRect)(&pPix->drawable,
+ pScratchGC, nRects, pRects);
+
+ failSafe:
+ if (failed)
+ {
+ /* Censoring was not completed above. To be safe, wipe out
+ * all the image data so that nothing trusted gets out.
+ */
+ bzero(pBuf, (int)(widthBytesLine * h));
+ }
+ if (pRects) DEALLOCATE_LOCAL(pRects);
+ if (pScratchGC) FreeScratchGC(pScratchGC);
+ if (pPix) FreeScratchPixmapHeader(pPix);
+ }
+ REGION_UNINIT(pScreen, &imageRegion);
+ REGION_UNINIT(pScreen, &censorRegion);
+} /* SecurityCensorImage */
+
+/**********************************************************************/
+
+typedef struct _PropertyAccessRec {
+ ATOM name;
+ ATOM mustHaveProperty;
+ char *mustHaveValue;
+ char windowRestriction;
+#define SecurityAnyWindow 0
+#define SecurityRootWindow 1
+#define SecurityWindowWithProperty 2
+ char readAction;
+ char writeAction;
+ char destroyAction;
+ struct _PropertyAccessRec *next;
+} PropertyAccessRec, *PropertyAccessPtr;
+
+static PropertyAccessPtr PropertyAccessList = NULL;
+static char SecurityDefaultAction = SecurityErrorOperation;
+static char *SecurityPolicyFile = DEFAULTPOLICYFILE;
+static ATOM SecurityMaxPropertyName = 0;
+
+static char *SecurityKeywords[] = {
+#define SecurityKeywordComment 0
+ "#",
+#define SecurityKeywordProperty 1
+ "property",
+#define SecurityKeywordSitePolicy 2
+ "sitepolicy",
+#define SecurityKeywordRoot 3
+ "root",
+#define SecurityKeywordAny 4
+ "any"
+};
+
+#define NUMKEYWORDS (sizeof(SecurityKeywords) / sizeof(char *))
+
+#undef PROPDEBUG
+/*#define PROPDEBUG 1*/
+
+static void
+SecurityFreePropertyAccessList(void)
+{
+ while (PropertyAccessList)
+ {
+ PropertyAccessPtr freeit = PropertyAccessList;
+ PropertyAccessList = PropertyAccessList->next;
+ xfree(freeit);
+ }
+} /* SecurityFreePropertyAccessList */
+
+#ifndef __UNIXOS2__
+#define SecurityIsWhitespace(c) ( (c == ' ') || (c == '\t') || (c == '\n') )
+#else
+#define SecurityIsWhitespace(c) ( (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r') )
+#endif
+
+static char *
+SecuritySkipWhitespace(
+ char *p)
+{
+ while (SecurityIsWhitespace(*p))
+ p++;
+ return p;
+} /* SecuritySkipWhitespace */
+
+
+static char *
+SecurityParseString(
+ char **rest)
+{
+ char *startOfString;
+ char *s = *rest;
+ char endChar = 0;
+
+ s = SecuritySkipWhitespace(s);
+
+ if (*s == '"' || *s == '\'')
+ {
+ endChar = *s++;
+ startOfString = s;
+ while (*s && (*s != endChar))
+ s++;
+ }
+ else
+ {
+ startOfString = s;
+ while (*s && !SecurityIsWhitespace(*s))
+ s++;
+ }
+ if (*s)
+ {
+ *s = '\0';
+ *rest = s + 1;
+ return startOfString;
+ }
+ else
+ {
+ *rest = s;
+ return (endChar) ? NULL : startOfString;
+ }
+} /* SecurityParseString */
+
+
+static int
+SecurityParseKeyword(
+ char **p)
+{
+ int i;
+ char *s = *p;
+ s = SecuritySkipWhitespace(s);
+ for (i = 0; i < NUMKEYWORDS; i++)
+ {
+ int len = strlen(SecurityKeywords[i]);
+ if (strncmp(s, SecurityKeywords[i], len) == 0)
+ {
+ *p = s + len;
+ return (i);
+ }
+ }
+ *p = s;
+ return -1;
+} /* SecurityParseKeyword */
+
+
+static Bool
+SecurityParsePropertyAccessRule(
+ char *p)
+{
+ char *propname;
+ char c;
+ char action = SecurityDefaultAction;
+ char readAction, writeAction, destroyAction;
+ PropertyAccessPtr pacl, prev, cur;
+ char *mustHaveProperty = NULL;
+ char *mustHaveValue = NULL;
+ Bool invalid;
+ char windowRestriction;
+ int size;
+ int keyword;
+
+ /* get property name */
+ propname = SecurityParseString(&p);
+ if (!propname || (strlen(propname) == 0))
+ return FALSE;
+
+ /* get window on which property must reside for rule to apply */
+
+ keyword = SecurityParseKeyword(&p);
+ if (keyword == SecurityKeywordRoot)
+ windowRestriction = SecurityRootWindow;
+ else if (keyword == SecurityKeywordAny)
+ windowRestriction = SecurityAnyWindow;
+ else /* not root or any, must be a property name */
+ {
+ mustHaveProperty = SecurityParseString(&p);
+ if (!mustHaveProperty || (strlen(mustHaveProperty) == 0))
+ return FALSE;
+ windowRestriction = SecurityWindowWithProperty;
+ p = SecuritySkipWhitespace(p);
+ if (*p == '=')
+ { /* property value is specified too */
+ p++; /* skip over '=' */
+ mustHaveValue = SecurityParseString(&p);
+ if (!mustHaveValue)
+ return FALSE;
+ }
+ }
+
+ /* get operations and actions */
+
+ invalid = FALSE;
+ readAction = writeAction = destroyAction = SecurityDefaultAction;
+ while ( (c = *p++) && !invalid)
+ {
+ switch (c)
+ {
+ case 'i': action = SecurityIgnoreOperation; break;
+ case 'a': action = SecurityAllowOperation; break;
+ case 'e': action = SecurityErrorOperation; break;
+
+ case 'r': readAction = action; break;
+ case 'w': writeAction = action; break;
+ case 'd': destroyAction = action; break;
+
+ default :
+ if (!SecurityIsWhitespace(c))
+ invalid = TRUE;
+ break;
+ }
+ }
+ if (invalid)
+ return FALSE;
+
+ /* We've successfully collected all the information needed for this
+ * property access rule. Now record it in a PropertyAccessRec.
+ */
+ size = sizeof(PropertyAccessRec);
+
+ /* If there is a property value string, allocate space for it
+ * right after the PropertyAccessRec.
+ */
+ if (mustHaveValue)
+ size += strlen(mustHaveValue) + 1;
+ pacl = (PropertyAccessPtr)Xalloc(size);
+ if (!pacl)
+ return FALSE;
+
+ pacl->name = MakeAtom(propname, strlen(propname), TRUE);
+ if (pacl->name == BAD_RESOURCE)
+ {
+ Xfree(pacl);
+ return FALSE;
+ }
+ if (mustHaveProperty)
+ {
+ pacl->mustHaveProperty = MakeAtom(mustHaveProperty,
+ strlen(mustHaveProperty), TRUE);
+ if (pacl->mustHaveProperty == BAD_RESOURCE)
+ {
+ Xfree(pacl);
+ return FALSE;
+ }
+ }
+ else
+ pacl->mustHaveProperty = 0;
+
+ if (mustHaveValue)
+ {
+ pacl->mustHaveValue = (char *)(pacl + 1);
+ strcpy(pacl->mustHaveValue, mustHaveValue);
+ }
+ else
+ pacl->mustHaveValue = NULL;
+
+ SecurityMaxPropertyName = max(SecurityMaxPropertyName, pacl->name);
+
+ pacl->windowRestriction = windowRestriction;
+ pacl->readAction = readAction;
+ pacl->writeAction = writeAction;
+ pacl->destroyAction = destroyAction;
+
+ /* link the new rule into the list of rules in order of increasing
+ * property name (atom) value to make searching easier
+ */
+
+ for (prev = NULL, cur = PropertyAccessList;
+ cur && cur->name <= pacl->name;
+ prev = cur, cur = cur->next)
+ ;
+ if (!prev)
+ {
+ pacl->next = cur;
+ PropertyAccessList = pacl;
+ }
+ else
+ {
+ prev->next = pacl;
+ pacl->next = cur;
+ }
+ return TRUE;
+} /* SecurityParsePropertyAccessRule */
+
+static char **SecurityPolicyStrings = NULL;
+static int nSecurityPolicyStrings = 0;
+
+static Bool
+SecurityParseSitePolicy(
+ char *p)
+{
+ char *policyStr = SecurityParseString(&p);
+ char *copyPolicyStr;
+ char **newStrings;
+
+ if (!policyStr)
+ return FALSE;
+
+ copyPolicyStr = (char *)Xalloc(strlen(policyStr) + 1);
+ if (!copyPolicyStr)
+ return TRUE;
+ strcpy(copyPolicyStr, policyStr);
+ newStrings = (char **)Xrealloc(SecurityPolicyStrings,
+ sizeof (char *) * (nSecurityPolicyStrings + 1));
+ if (!newStrings)
+ {
+ Xfree(copyPolicyStr);
+ return TRUE;
+ }
+
+ SecurityPolicyStrings = newStrings;
+ SecurityPolicyStrings[nSecurityPolicyStrings++] = copyPolicyStr;
+
+ return TRUE;
+
+} /* SecurityParseSitePolicy */
+
+
+char **
+SecurityGetSitePolicyStrings(n)
+ int *n;
+{
+ *n = nSecurityPolicyStrings;
+ return SecurityPolicyStrings;
+} /* SecurityGetSitePolicyStrings */
+
+static void
+SecurityFreeSitePolicyStrings(void)
+{
+ if (SecurityPolicyStrings)
+ {
+ assert(nSecurityPolicyStrings);
+ while (nSecurityPolicyStrings--)
+ {
+ Xfree(SecurityPolicyStrings[nSecurityPolicyStrings]);
+ }
+ Xfree(SecurityPolicyStrings);
+ SecurityPolicyStrings = NULL;
+ nSecurityPolicyStrings = 0;
+ }
+} /* SecurityFreeSitePolicyStrings */
+
+
+static void
+SecurityLoadPropertyAccessList(void)
+{
+ FILE *f;
+ int lineNumber = 0;
+
+ SecurityMaxPropertyName = 0;
+
+ if (!SecurityPolicyFile)
+ return;
+
+#ifndef __UNIXOS2__
+ f = fopen(SecurityPolicyFile, "r");
+#else
+ f = fopen((char*)__XOS2RedirRoot(SecurityPolicyFile), "r");
+#endif
+ if (!f)
+ {
+ ErrorF("error opening security policy file %s\n",
+ SecurityPolicyFile);
+ return;
+ }
+
+ while (!feof(f))
+ {
+ char buf[200];
+ Bool validLine;
+ char *p;
+
+ if (!(p = fgets(buf, sizeof(buf), f)))
+ break;
+ lineNumber++;
+
+ /* if first line, check version number */
+ if (lineNumber == 1)
+ {
+ char *v = SecurityParseString(&p);
+ if (strcmp(v, SECURITY_POLICY_FILE_VERSION) != 0)
+ {
+ ErrorF("%s: invalid security policy file version, ignoring file\n",
+ SecurityPolicyFile);
+ break;
+ }
+ validLine = TRUE;
+ }
+ else
+ {
+ switch (SecurityParseKeyword(&p))
+ {
+ case SecurityKeywordComment:
+ validLine = TRUE;
+ break;
+
+ case SecurityKeywordProperty:
+ validLine = SecurityParsePropertyAccessRule(p);
+ break;
+
+ case SecurityKeywordSitePolicy:
+ validLine = SecurityParseSitePolicy(p);
+ break;
+
+ default:
+ validLine = (*p == '\0'); /* blank lines OK, others not */
+ break;
+ }
+ }
+
+ if (!validLine)
+ ErrorF("Line %d of %s invalid, ignoring\n",
+ lineNumber, SecurityPolicyFile);
+ } /* end while more input */
+
+#ifdef PROPDEBUG
+ {
+ PropertyAccessPtr pacl;
+ char *op = "aie";
+ for (pacl = PropertyAccessList; pacl; pacl = pacl->next)
+ {
+ ErrorF("property %s ", NameForAtom(pacl->name));
+ switch (pacl->windowRestriction)
+ {
+ case SecurityAnyWindow: ErrorF("any "); break;
+ case SecurityRootWindow: ErrorF("root "); break;
+ case SecurityWindowWithProperty:
+ {
+ ErrorF("%s ", NameForAtom(pacl->mustHaveProperty));
+ if (pacl->mustHaveValue)
+ ErrorF(" = \"%s\" ", pacl->mustHaveValue);
+
+ }
+ break;
+ }
+ ErrorF("%cr %cw %cd\n", op[pacl->readAction],
+ op[pacl->writeAction], op[pacl->destroyAction]);
+ }
+ }
+#endif /* PROPDEBUG */
+
+ fclose(f);
+} /* SecurityLoadPropertyAccessList */
+
+
+static Bool
+SecurityMatchString(
+ char *ws,
+ char *cs)
+{
+ while (*ws && *cs)
+ {
+ if (*ws == '*')
+ {
+ Bool match = FALSE;
+ ws++;
+ while (!(match = SecurityMatchString(ws, cs)) && *cs)
+ {
+ cs++;
+ }
+ return match;
+ }
+ else if (*ws == *cs)
+ {
+ ws++;
+ cs++;
+ }
+ else break;
+ }
+ return ( ( (*ws == '\0') || ((*ws == '*') && *(ws+1) == '\0') )
+ && (*cs == '\0') );
+} /* SecurityMatchString */
+
+#ifdef PROPDEBUG
+#include <sys/types.h>
+#include <sys/stat.h>
+#endif
+
+
+char
+SecurityCheckPropertyAccess(client, pWin, propertyName, access_mode)
+ ClientPtr client;
+ WindowPtr pWin;
+ ATOM propertyName;
+ Mask access_mode;
+{
+ PropertyAccessPtr pacl;
+ char action = SecurityDefaultAction;
+
+ /* if client trusted or window untrusted, allow operation */
+
+ if ( (client->trustLevel == XSecurityClientTrusted) ||
+ (wClient(pWin)->trustLevel != XSecurityClientTrusted) )
+ return SecurityAllowOperation;
+
+#ifdef PROPDEBUG
+ /* For testing, it's more convenient if the property rules file gets
+ * reloaded whenever it changes, so we can rapidly try things without
+ * having to reset the server.
+ */
+ {
+ struct stat buf;
+ static time_t lastmod = 0;
+ int ret = stat(SecurityPolicyFile , &buf);
+ if ( (ret == 0) && (buf.st_mtime > lastmod) )
+ {
+ ErrorF("reloading property rules\n");
+ SecurityFreePropertyAccessList();
+ SecurityLoadPropertyAccessList();
+ lastmod = buf.st_mtime;
+ }
+ }
+#endif
+
+ /* If the property atom is bigger than any atoms on the list,
+ * we know we won't find it, so don't even bother looking.
+ */
+ if (propertyName <= SecurityMaxPropertyName)
+ {
+ /* untrusted client operating on trusted window; see if it's allowed */
+
+ for (pacl = PropertyAccessList; pacl; pacl = pacl->next)
+ {
+ if (pacl->name < propertyName)
+ continue;
+ if (pacl->name > propertyName)
+ break;
+
+ /* pacl->name == propertyName, so see if it applies to this window */
+
+ switch (pacl->windowRestriction)
+ {
+ case SecurityAnyWindow: /* always applies */
+ break;
+
+ case SecurityRootWindow:
+ {
+ /* if not a root window, this rule doesn't apply */
+ if (pWin->parent)
+ continue;
+ }
+ break;
+
+ case SecurityWindowWithProperty:
+ {
+ PropertyPtr pProp = wUserProps (pWin);
+ Bool match = FALSE;
+ char *p;
+ char *pEndData;
+
+ while (pProp)
+ {
+ if (pProp->propertyName == pacl->mustHaveProperty)
+ break;
+ pProp = pProp->next;
+ }
+ if (!pProp)
+ continue;
+ if (!pacl->mustHaveValue)
+ break;
+ if (pProp->type != XA_STRING || pProp->format != 8)
+ continue;
+
+ p = pProp->data;
+ pEndData = ((char *)pProp->data) + pProp->size;
+ while (!match && p < pEndData)
+ {
+ if (SecurityMatchString(pacl->mustHaveValue, p))
+ match = TRUE;
+ else
+ { /* skip to the next string */
+ while (*p++ && p < pEndData)
+ ;
+ }
+ }
+ if (!match)
+ continue;
+ }
+ break; /* end case SecurityWindowWithProperty */
+ } /* end switch on windowRestriction */
+
+ /* If we get here, the property access rule pacl applies.
+ * If pacl doesn't apply, something above should have
+ * executed a continue, which will skip the follwing code.
+ */
+ action = SecurityAllowOperation;
+ if (access_mode & SecurityReadAccess)
+ action = max(action, pacl->readAction);
+ if (access_mode & SecurityWriteAccess)
+ action = max(action, pacl->writeAction);
+ if (access_mode & SecurityDestroyAccess)
+ action = max(action, pacl->destroyAction);
+ break;
+ } /* end for each pacl */
+ } /* end if propertyName <= SecurityMaxPropertyName */
+
+ if (SecurityAllowOperation != action)
+ { /* audit the access violation */
+ int cid = CLIENT_ID(pWin->drawable.id);
+ int reqtype = ((xReq *)client->requestBuffer)->reqType;
+ char *actionstr = (SecurityIgnoreOperation == action) ?
+ "ignored" : "error";
+ SecurityAudit("client %d attempted request %d with window 0x%x property %s (atom 0x%x) of client %d, %s\n",
+ client->index, reqtype, pWin->drawable.id,
+ NameForAtom(propertyName), propertyName, cid, actionstr);
+ }
+ return action;
+} /* SecurityCheckPropertyAccess */
+
+
+/* SecurityResetProc
+ *
+ * Arguments:
+ * extEntry is the extension information for the security extension.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Performs any cleanup needed by Security at server shutdown time.
+ */
+
+static void
+SecurityResetProc(
+ ExtensionEntry *extEntry)
+{
+ SecurityFreePropertyAccessList();
+ SecurityFreeSitePolicyStrings();
+} /* SecurityResetProc */
+
+
+int
+XSecurityOptions(argc, argv, i)
+ int argc;
+ char **argv;
+ int i;
+{
+ if (strcmp(argv[i], "-sp") == 0)
+ {
+ if (i < argc)
+ SecurityPolicyFile = argv[++i];
+ return (i + 1);
+ }
+ return (i);
+} /* XSecurityOptions */
+
+
+
+/* SecurityExtensionInit
+ *
+ * Arguments: none.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Enables the Security extension if possible.
+ */
+
+void
+SecurityExtensionInit(INITARGS)
+{
+ ExtensionEntry *extEntry;
+ int i;
+
+ SecurityAuthorizationResType =
+ CreateNewResourceType(SecurityDeleteAuthorization);
+
+ RTEventClient = CreateNewResourceType(
+ SecurityDeleteAuthorizationEventClient);
+
+ if (!SecurityAuthorizationResType || !RTEventClient)
+ return;
+
+ RTEventClient |= RC_NEVERRETAIN;
+
+ if (!AddCallback(&ClientStateCallback, SecurityClientStateCallback, NULL))
+ return;
+
+ extEntry = AddExtension(SECURITY_EXTENSION_NAME,
+ XSecurityNumberEvents, XSecurityNumberErrors,
+ ProcSecurityDispatch, SProcSecurityDispatch,
+ SecurityResetProc, StandardMinorOpcode);
+
+ SecurityErrorBase = extEntry->errorBase;
+ SecurityEventBase = extEntry->eventBase;
+
+ EventSwapVector[SecurityEventBase + XSecurityAuthorizationRevoked] =
+ (EventSwapPtr)SwapSecurityAuthorizationRevokedEvent;
+
+ /* initialize untrusted proc vectors */
+
+ for (i = 0; i < 128; i++)
+ {
+ UntrustedProcVector[i] = ProcVector[i];
+ SwappedUntrustedProcVector[i] = SwappedProcVector[i];
+ }
+
+ /* make sure insecure extensions are not allowed */
+
+ for (i = 128; i < 256; i++)
+ {
+ if (!UntrustedProcVector[i])
+ {
+ UntrustedProcVector[i] = ProcBadRequest;
+ SwappedUntrustedProcVector[i] = ProcBadRequest;
+ }
+ }
+
+ SecurityLoadPropertyAccessList();
+
+} /* SecurityExtensionInit */
diff --git a/nx-X11/programs/Xserver/Xext/shape.c b/nx-X11/programs/Xserver/Xext/shape.c
new file mode 100644
index 000000000..3fa16081a
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/shape.c
@@ -0,0 +1,1335 @@
+/* $XdotOrg: xc/programs/Xserver/Xext/shape.c,v 1.9 2005/07/03 08:53:36 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/Xext/shape.c,v 3.18 2003/10/28 23:08:43 tsi Exp $ */
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+********************************************************/
+
+/* $Xorg: shape.c,v 1.4 2001/02/09 02:04:32 xorgcvs Exp $ */
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "opaque.h"
+#define _SHAPE_SERVER_ /* don't want Xlib structures */
+#include <X11/extensions/shapestr.h>
+#include "regionstr.h"
+#include "gcstruct.h"
+#ifdef EXTMODULE
+#include "xf86_ansic.h"
+#endif
+#include "modinit.h"
+
+typedef RegionPtr (*CreateDftPtr)(
+ WindowPtr /* pWin */
+ );
+
+static int ShapeFreeClient(
+ pointer /* data */,
+ XID /* id */
+ );
+static int ShapeFreeEvents(
+ pointer /* data */,
+ XID /* id */
+ );
+static void ShapeResetProc(
+ ExtensionEntry * /* extEntry */
+ );
+static void SShapeNotifyEvent(
+ xShapeNotifyEvent * /* from */,
+ xShapeNotifyEvent * /* to */
+ );
+static int
+RegionOperate (
+ ClientPtr /* client */,
+ WindowPtr /* pWin */,
+ int /* kind */,
+ RegionPtr * /* destRgnp */,
+ RegionPtr /* srcRgn */,
+ int /* op */,
+ int /* xoff */,
+ int /* yoff */,
+ CreateDftPtr /* create */
+ );
+
+/* SendShapeNotify, CreateBoundingShape and CreateClipShape are used
+ * externally by the Xfixes extension and are now defined in window.h
+ */
+
+static DISPATCH_PROC(ProcShapeCombine);
+static DISPATCH_PROC(ProcShapeDispatch);
+static DISPATCH_PROC(ProcShapeGetRectangles);
+static DISPATCH_PROC(ProcShapeInputSelected);
+static DISPATCH_PROC(ProcShapeMask);
+static DISPATCH_PROC(ProcShapeOffset);
+static DISPATCH_PROC(ProcShapeQueryExtents);
+static DISPATCH_PROC(ProcShapeQueryVersion);
+static DISPATCH_PROC(ProcShapeRectangles);
+static DISPATCH_PROC(ProcShapeSelectInput);
+static DISPATCH_PROC(SProcShapeCombine);
+static DISPATCH_PROC(SProcShapeDispatch);
+static DISPATCH_PROC(SProcShapeGetRectangles);
+static DISPATCH_PROC(SProcShapeInputSelected);
+static DISPATCH_PROC(SProcShapeMask);
+static DISPATCH_PROC(SProcShapeOffset);
+static DISPATCH_PROC(SProcShapeQueryExtents);
+static DISPATCH_PROC(SProcShapeQueryVersion);
+static DISPATCH_PROC(SProcShapeRectangles);
+static DISPATCH_PROC(SProcShapeSelectInput);
+
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+
+#if 0
+static unsigned char ShapeReqCode = 0;
+#endif
+static int ShapeEventBase = 0;
+static RESTYPE ClientType, EventType; /* resource types for event masks */
+
+/*
+ * each window has a list of clients requesting
+ * ShapeNotify events. Each client has a resource
+ * for each window it selects ShapeNotify input for,
+ * this resource is used to delete the ShapeNotifyRec
+ * entry from the per-window queue.
+ */
+
+typedef struct _ShapeEvent *ShapeEventPtr;
+
+typedef struct _ShapeEvent {
+ ShapeEventPtr next;
+ ClientPtr client;
+ WindowPtr window;
+ XID clientResource;
+} ShapeEventRec;
+
+/****************
+ * ShapeExtensionInit
+ *
+ * Called from InitExtensions in main() or from QueryExtension() if the
+ * extension is dynamically loaded.
+ *
+ ****************/
+
+void
+ShapeExtensionInit(INITARGS)
+{
+ ExtensionEntry *extEntry;
+
+ ClientType = CreateNewResourceType(ShapeFreeClient);
+ EventType = CreateNewResourceType(ShapeFreeEvents);
+ if (ClientType && EventType &&
+ (extEntry = AddExtension(SHAPENAME, ShapeNumberEvents, 0,
+ ProcShapeDispatch, SProcShapeDispatch,
+ ShapeResetProc, StandardMinorOpcode)))
+ {
+#if 0
+ ShapeReqCode = (unsigned char)extEntry->base;
+#endif
+ ShapeEventBase = extEntry->eventBase;
+ EventSwapVector[ShapeEventBase] = (EventSwapPtr) SShapeNotifyEvent;
+ }
+}
+
+/*ARGSUSED*/
+static void
+ShapeResetProc (extEntry)
+ExtensionEntry *extEntry;
+{
+}
+
+static int
+RegionOperate (client, pWin, kind, destRgnp, srcRgn, op, xoff, yoff, create)
+ ClientPtr client;
+ WindowPtr pWin;
+ int kind;
+ RegionPtr *destRgnp, srcRgn;
+ int op;
+ int xoff, yoff;
+ CreateDftPtr create; /* creates a reasonable *destRgnp */
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ if (srcRgn && (xoff || yoff))
+ REGION_TRANSLATE(pScreen, srcRgn, xoff, yoff);
+ if (!pWin->parent)
+ {
+ if (srcRgn)
+ REGION_DESTROY(pScreen, srcRgn);
+ return Success;
+ }
+
+ /* May/30/2001:
+ * The shape.PS specs say if src is None, existing shape is to be
+ * removed (and so the op-code has no meaning in such removal);
+ * see shape.PS, page 3, ShapeMask.
+ */
+ if (srcRgn == NULL) {
+ if (*destRgnp != NULL) {
+ REGION_DESTROY (pScreen, *destRgnp);
+ *destRgnp = 0;
+ /* go on to remove shape and generate ShapeNotify */
+ }
+ else {
+ /* May/30/2001:
+ * The target currently has no shape in effect, so nothing to
+ * do here. The specs say that ShapeNotify is generated whenever
+ * the client region is "modified"; since no modification is done
+ * here, we do not generate that event. The specs does not say
+ * "it is an error to request removal when there is no shape in
+ * effect", so we return good status.
+ */
+ return Success;
+ }
+ }
+ else switch (op) {
+ case ShapeSet:
+ if (*destRgnp)
+ REGION_DESTROY(pScreen, *destRgnp);
+ *destRgnp = srcRgn;
+ srcRgn = 0;
+ break;
+ case ShapeUnion:
+ if (*destRgnp)
+ REGION_UNION(pScreen, *destRgnp, *destRgnp, srcRgn);
+ break;
+ case ShapeIntersect:
+ if (*destRgnp)
+ REGION_INTERSECT(pScreen, *destRgnp, *destRgnp, srcRgn);
+ else {
+ *destRgnp = srcRgn;
+ srcRgn = 0;
+ }
+ break;
+ case ShapeSubtract:
+ if (!*destRgnp)
+ *destRgnp = (*create)(pWin);
+ REGION_SUBTRACT(pScreen, *destRgnp, *destRgnp, srcRgn);
+ break;
+ case ShapeInvert:
+ if (!*destRgnp)
+ *destRgnp = REGION_CREATE(pScreen, (BoxPtr) 0, 0);
+ else
+ REGION_SUBTRACT(pScreen, *destRgnp, srcRgn, *destRgnp);
+ break;
+ default:
+ client->errorValue = op;
+ return BadValue;
+ }
+ if (srcRgn)
+ REGION_DESTROY(pScreen, srcRgn);
+ (*pScreen->SetShape) (pWin);
+ SendShapeNotify (pWin, kind);
+ return Success;
+}
+
+RegionPtr
+CreateBoundingShape (pWin)
+ WindowPtr pWin;
+{
+ BoxRec extents;
+
+ extents.x1 = -wBorderWidth (pWin);
+ extents.y1 = -wBorderWidth (pWin);
+ extents.x2 = pWin->drawable.width + wBorderWidth (pWin);
+ extents.y2 = pWin->drawable.height + wBorderWidth (pWin);
+ return REGION_CREATE(pWin->drawable.pScreen, &extents, 1);
+}
+
+RegionPtr
+CreateClipShape (pWin)
+ WindowPtr pWin;
+{
+ BoxRec extents;
+
+ extents.x1 = 0;
+ extents.y1 = 0;
+ extents.x2 = pWin->drawable.width;
+ extents.y2 = pWin->drawable.height;
+ return REGION_CREATE(pWin->drawable.pScreen, &extents, 1);
+}
+
+static int
+ProcShapeQueryVersion (client)
+ register ClientPtr client;
+{
+ xShapeQueryVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH (xShapeQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = SHAPE_MAJOR_VERSION;
+ rep.minorVersion = SHAPE_MINOR_VERSION;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof (xShapeQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+/*****************
+ * ProcShapeRectangles
+ *
+ *****************/
+
+static int
+ProcShapeRectangles (client)
+ register ClientPtr client;
+{
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ REQUEST(xShapeRectanglesReq);
+ xRectangle *prects;
+ int nrects, ctype;
+ RegionPtr srcRgn;
+ RegionPtr *destRgn;
+ CreateDftPtr createDefault;
+
+ REQUEST_AT_LEAST_SIZE (xShapeRectanglesReq);
+ UpdateCurrentTime();
+ pWin = LookupWindow (stuff->dest, client);
+ if (!pWin)
+ return BadWindow;
+ switch (stuff->destKind) {
+ case ShapeBounding:
+ createDefault = CreateBoundingShape;
+ break;
+ case ShapeClip:
+ createDefault = CreateClipShape;
+ break;
+ case ShapeInput:
+ createDefault = CreateBoundingShape;
+ break;
+ default:
+ client->errorValue = stuff->destKind;
+ return BadValue;
+ }
+ if ((stuff->ordering != Unsorted) && (stuff->ordering != YSorted) &&
+ (stuff->ordering != YXSorted) && (stuff->ordering != YXBanded))
+ {
+ client->errorValue = stuff->ordering;
+ return BadValue;
+ }
+ pScreen = pWin->drawable.pScreen;
+ nrects = ((stuff->length << 2) - sizeof(xShapeRectanglesReq));
+ if (nrects & 4)
+ return BadLength;
+ nrects >>= 3;
+ prects = (xRectangle *) &stuff[1];
+ ctype = VerifyRectOrder(nrects, prects, (int)stuff->ordering);
+ if (ctype < 0)
+ return BadMatch;
+ srcRgn = RECTS_TO_REGION(pScreen, nrects, prects, ctype);
+
+ if (!pWin->optional)
+ MakeWindowOptional (pWin);
+ switch (stuff->destKind) {
+ case ShapeBounding:
+ destRgn = &pWin->optional->boundingShape;
+ break;
+ case ShapeClip:
+ destRgn = &pWin->optional->clipShape;
+ break;
+ case ShapeInput:
+ destRgn = &pWin->optional->inputShape;
+ break;
+ default:
+ return BadValue;
+ }
+
+ return RegionOperate (client, pWin, (int)stuff->destKind,
+ destRgn, srcRgn, (int)stuff->op,
+ stuff->xOff, stuff->yOff, createDefault);
+}
+
+#ifdef PANORAMIX
+static int
+ProcPanoramiXShapeRectangles(
+ register ClientPtr client)
+{
+ REQUEST(xShapeRectanglesReq);
+ PanoramiXRes *win;
+ int j, result = 0;
+
+ REQUEST_AT_LEAST_SIZE (xShapeRectanglesReq);
+
+ if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->dest, XRT_WINDOW, SecurityWriteAccess)))
+ return BadWindow;
+
+ FOR_NSCREENS(j) {
+ stuff->dest = win->info[j].id;
+ result = ProcShapeRectangles (client);
+ BREAK_IF(result != Success);
+ }
+ return (result);
+}
+#endif
+
+
+/**************
+ * ProcShapeMask
+ **************/
+
+
+static int
+ProcShapeMask (client)
+ register ClientPtr client;
+{
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ REQUEST(xShapeMaskReq);
+ RegionPtr srcRgn;
+ RegionPtr *destRgn;
+ PixmapPtr pPixmap;
+ CreateDftPtr createDefault;
+
+ REQUEST_SIZE_MATCH (xShapeMaskReq);
+ UpdateCurrentTime();
+ pWin = SecurityLookupWindow (stuff->dest, client, SecurityWriteAccess);
+ if (!pWin)
+ return BadWindow;
+ switch (stuff->destKind) {
+ case ShapeBounding:
+ createDefault = CreateBoundingShape;
+ break;
+ case ShapeClip:
+ createDefault = CreateClipShape;
+ break;
+ case ShapeInput:
+ createDefault = CreateBoundingShape;
+ break;
+ default:
+ client->errorValue = stuff->destKind;
+ return BadValue;
+ }
+ pScreen = pWin->drawable.pScreen;
+ if (stuff->src == None)
+ srcRgn = 0;
+ else {
+ pPixmap = (PixmapPtr) SecurityLookupIDByType(client, stuff->src,
+ RT_PIXMAP, SecurityReadAccess);
+ if (!pPixmap)
+ return BadPixmap;
+ if (pPixmap->drawable.pScreen != pScreen ||
+ pPixmap->drawable.depth != 1)
+ return BadMatch;
+ srcRgn = BITMAP_TO_REGION(pScreen, pPixmap);
+ if (!srcRgn)
+ return BadAlloc;
+ }
+
+ if (!pWin->optional)
+ MakeWindowOptional (pWin);
+ switch (stuff->destKind) {
+ case ShapeBounding:
+ destRgn = &pWin->optional->boundingShape;
+ break;
+ case ShapeClip:
+ destRgn = &pWin->optional->clipShape;
+ break;
+ case ShapeInput:
+ destRgn = &pWin->optional->inputShape;
+ break;
+ default:
+ return BadValue;
+ }
+
+ return RegionOperate (client, pWin, (int)stuff->destKind,
+ destRgn, srcRgn, (int)stuff->op,
+ stuff->xOff, stuff->yOff, createDefault);
+}
+
+#ifdef PANORAMIX
+static int
+ProcPanoramiXShapeMask(
+ register ClientPtr client)
+{
+ REQUEST(xShapeMaskReq);
+ PanoramiXRes *win, *pmap;
+ int j, result = 0;
+
+ REQUEST_SIZE_MATCH (xShapeMaskReq);
+
+ if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->dest, XRT_WINDOW, SecurityWriteAccess)))
+ return BadWindow;
+
+ if(stuff->src != None) {
+ if(!(pmap = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->src, XRT_PIXMAP, SecurityReadAccess)))
+ return BadPixmap;
+ } else
+ pmap = NULL;
+
+ FOR_NSCREENS(j) {
+ stuff->dest = win->info[j].id;
+ if(pmap)
+ stuff->src = pmap->info[j].id;
+ result = ProcShapeMask (client);
+ BREAK_IF(result != Success);
+ }
+ return (result);
+}
+#endif
+
+
+/************
+ * ProcShapeCombine
+ ************/
+
+static int
+ProcShapeCombine (client)
+ register ClientPtr client;
+{
+ WindowPtr pSrcWin, pDestWin;
+ ScreenPtr pScreen;
+ REQUEST(xShapeCombineReq);
+ RegionPtr srcRgn;
+ RegionPtr *destRgn;
+ CreateDftPtr createDefault;
+ CreateDftPtr createSrc;
+ RegionPtr tmp;
+
+ REQUEST_SIZE_MATCH (xShapeCombineReq);
+ UpdateCurrentTime();
+ pDestWin = LookupWindow (stuff->dest, client);
+ if (!pDestWin)
+ return BadWindow;
+ if (!pDestWin->optional)
+ MakeWindowOptional (pDestWin);
+ switch (stuff->destKind) {
+ case ShapeBounding:
+ createDefault = CreateBoundingShape;
+ break;
+ case ShapeClip:
+ createDefault = CreateClipShape;
+ break;
+ case ShapeInput:
+ createDefault = CreateBoundingShape;
+ break;
+ default:
+ client->errorValue = stuff->destKind;
+ return BadValue;
+ }
+ pScreen = pDestWin->drawable.pScreen;
+
+ pSrcWin = LookupWindow (stuff->src, client);
+ if (!pSrcWin)
+ return BadWindow;
+ switch (stuff->srcKind) {
+ case ShapeBounding:
+ srcRgn = wBoundingShape (pSrcWin);
+ createSrc = CreateBoundingShape;
+ break;
+ case ShapeClip:
+ srcRgn = wClipShape (pSrcWin);
+ createSrc = CreateClipShape;
+ break;
+ case ShapeInput:
+ srcRgn = wInputShape (pSrcWin);
+ createSrc = CreateBoundingShape;
+ break;
+ default:
+ client->errorValue = stuff->srcKind;
+ return BadValue;
+ }
+ if (pSrcWin->drawable.pScreen != pScreen)
+ {
+ return BadMatch;
+ }
+
+ if (srcRgn) {
+ tmp = REGION_CREATE(pScreen, (BoxPtr) 0, 0);
+ REGION_COPY(pScreen, tmp, srcRgn);
+ srcRgn = tmp;
+ } else
+ srcRgn = (*createSrc) (pSrcWin);
+
+ if (!pDestWin->optional)
+ MakeWindowOptional (pDestWin);
+ switch (stuff->destKind) {
+ case ShapeBounding:
+ destRgn = &pDestWin->optional->boundingShape;
+ break;
+ case ShapeClip:
+ destRgn = &pDestWin->optional->clipShape;
+ break;
+ case ShapeInput:
+ destRgn = &pDestWin->optional->inputShape;
+ break;
+ default:
+ return BadValue;
+ }
+
+ return RegionOperate (client, pDestWin, (int)stuff->destKind,
+ destRgn, srcRgn, (int)stuff->op,
+ stuff->xOff, stuff->yOff, createDefault);
+}
+
+
+#ifdef PANORAMIX
+static int
+ProcPanoramiXShapeCombine(
+ register ClientPtr client)
+{
+ REQUEST(xShapeCombineReq);
+ PanoramiXRes *win, *win2;
+ int j, result = 0;
+
+ REQUEST_AT_LEAST_SIZE (xShapeCombineReq);
+
+ if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->dest, XRT_WINDOW, SecurityWriteAccess)))
+ return BadWindow;
+
+ if(!(win2 = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->src, XRT_WINDOW, SecurityReadAccess)))
+ return BadWindow;
+
+ FOR_NSCREENS(j) {
+ stuff->dest = win->info[j].id;
+ stuff->src = win2->info[j].id;
+ result = ProcShapeCombine (client);
+ BREAK_IF(result != Success);
+ }
+ return (result);
+}
+#endif
+
+/*************
+ * ProcShapeOffset
+ *************/
+
+static int
+ProcShapeOffset (client)
+ register ClientPtr client;
+{
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ REQUEST(xShapeOffsetReq);
+ RegionPtr srcRgn;
+
+ REQUEST_SIZE_MATCH (xShapeOffsetReq);
+ UpdateCurrentTime();
+ pWin = LookupWindow (stuff->dest, client);
+ if (!pWin)
+ return BadWindow;
+ switch (stuff->destKind) {
+ case ShapeBounding:
+ srcRgn = wBoundingShape (pWin);
+ break;
+ case ShapeClip:
+ srcRgn = wClipShape(pWin);
+ break;
+ case ShapeInput:
+ srcRgn = wInputShape (pWin);
+ break;
+ default:
+ client->errorValue = stuff->destKind;
+ return BadValue;
+ }
+ pScreen = pWin->drawable.pScreen;
+ if (srcRgn)
+ {
+ REGION_TRANSLATE(pScreen, srcRgn, stuff->xOff, stuff->yOff);
+ (*pScreen->SetShape) (pWin);
+ }
+ SendShapeNotify (pWin, (int)stuff->destKind);
+ return Success;
+}
+
+
+#ifdef PANORAMIX
+static int
+ProcPanoramiXShapeOffset(
+ register ClientPtr client)
+{
+ REQUEST(xShapeOffsetReq);
+ PanoramiXRes *win;
+ int j, result = 0;
+
+ REQUEST_AT_LEAST_SIZE (xShapeOffsetReq);
+
+ if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->dest, XRT_WINDOW, SecurityWriteAccess)))
+ return BadWindow;
+
+ FOR_NSCREENS(j) {
+ stuff->dest = win->info[j].id;
+ result = ProcShapeOffset (client);
+ if(result != Success) break;
+ }
+ return (result);
+}
+#endif
+
+
+static int
+ProcShapeQueryExtents (client)
+ register ClientPtr client;
+{
+ REQUEST(xShapeQueryExtentsReq);
+ WindowPtr pWin;
+ xShapeQueryExtentsReply rep;
+ BoxRec extents, *pExtents;
+ register int n;
+ RegionPtr region;
+
+ REQUEST_SIZE_MATCH (xShapeQueryExtentsReq);
+ pWin = LookupWindow (stuff->window, client);
+ if (!pWin)
+ return BadWindow;
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.boundingShaped = (wBoundingShape(pWin) != 0);
+ rep.clipShaped = (wClipShape(pWin) != 0);
+ if ((region = wBoundingShape(pWin))) {
+ /* this is done in two steps because of a compiler bug on SunOS 4.1.3 */
+ pExtents = REGION_EXTENTS(pWin->drawable.pScreen, region);
+ extents = *pExtents;
+ } else {
+ extents.x1 = -wBorderWidth (pWin);
+ extents.y1 = -wBorderWidth (pWin);
+ extents.x2 = pWin->drawable.width + wBorderWidth (pWin);
+ extents.y2 = pWin->drawable.height + wBorderWidth (pWin);
+ }
+ rep.xBoundingShape = extents.x1;
+ rep.yBoundingShape = extents.y1;
+ rep.widthBoundingShape = extents.x2 - extents.x1;
+ rep.heightBoundingShape = extents.y2 - extents.y1;
+ if ((region = wClipShape(pWin))) {
+ /* this is done in two steps because of a compiler bug on SunOS 4.1.3 */
+ pExtents = REGION_EXTENTS(pWin->drawable.pScreen, region);
+ extents = *pExtents;
+ } else {
+ extents.x1 = 0;
+ extents.y1 = 0;
+ extents.x2 = pWin->drawable.width;
+ extents.y2 = pWin->drawable.height;
+ }
+ rep.xClipShape = extents.x1;
+ rep.yClipShape = extents.y1;
+ rep.widthClipShape = extents.x2 - extents.x1;
+ rep.heightClipShape = extents.y2 - extents.y1;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.xBoundingShape, n);
+ swaps(&rep.yBoundingShape, n);
+ swaps(&rep.widthBoundingShape, n);
+ swaps(&rep.heightBoundingShape, n);
+ swaps(&rep.xClipShape, n);
+ swaps(&rep.yClipShape, n);
+ swaps(&rep.widthClipShape, n);
+ swaps(&rep.heightClipShape, n);
+ }
+ WriteToClient(client, sizeof (xShapeQueryExtentsReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+/*ARGSUSED*/
+static int
+ShapeFreeClient (data, id)
+ pointer data;
+ XID id;
+{
+ ShapeEventPtr pShapeEvent;
+ WindowPtr pWin;
+ ShapeEventPtr *pHead, pCur, pPrev;
+
+ pShapeEvent = (ShapeEventPtr) data;
+ pWin = pShapeEvent->window;
+ pHead = (ShapeEventPtr *) LookupIDByType(pWin->drawable.id, EventType);
+ if (pHead) {
+ pPrev = 0;
+ for (pCur = *pHead; pCur && pCur != pShapeEvent; pCur=pCur->next)
+ pPrev = pCur;
+ if (pCur)
+ {
+ if (pPrev)
+ pPrev->next = pShapeEvent->next;
+ else
+ *pHead = pShapeEvent->next;
+ }
+ }
+ xfree ((pointer) pShapeEvent);
+ return 1;
+}
+
+/*ARGSUSED*/
+static int
+ShapeFreeEvents (data, id)
+ pointer data;
+ XID id;
+{
+ ShapeEventPtr *pHead, pCur, pNext;
+
+ pHead = (ShapeEventPtr *) data;
+ for (pCur = *pHead; pCur; pCur = pNext) {
+ pNext = pCur->next;
+ FreeResource (pCur->clientResource, ClientType);
+ xfree ((pointer) pCur);
+ }
+ xfree ((pointer) pHead);
+ return 1;
+}
+
+static int
+ProcShapeSelectInput (client)
+ register ClientPtr client;
+{
+ REQUEST(xShapeSelectInputReq);
+ WindowPtr pWin;
+ ShapeEventPtr pShapeEvent, pNewShapeEvent, *pHead;
+ XID clientResource;
+
+ REQUEST_SIZE_MATCH (xShapeSelectInputReq);
+ pWin = SecurityLookupWindow (stuff->window, client, SecurityWriteAccess);
+ if (!pWin)
+ return BadWindow;
+ pHead = (ShapeEventPtr *)SecurityLookupIDByType(client,
+ pWin->drawable.id, EventType, SecurityWriteAccess);
+ switch (stuff->enable) {
+ case xTrue:
+ if (pHead) {
+
+ /* check for existing entry. */
+ for (pShapeEvent = *pHead;
+ pShapeEvent;
+ pShapeEvent = pShapeEvent->next)
+ {
+ if (pShapeEvent->client == client)
+ return Success;
+ }
+ }
+
+ /* build the entry */
+ pNewShapeEvent = (ShapeEventPtr)
+ xalloc (sizeof (ShapeEventRec));
+ if (!pNewShapeEvent)
+ return BadAlloc;
+ pNewShapeEvent->next = 0;
+ pNewShapeEvent->client = client;
+ pNewShapeEvent->window = pWin;
+ /*
+ * add a resource that will be deleted when
+ * the client goes away
+ */
+ clientResource = FakeClientID (client->index);
+ pNewShapeEvent->clientResource = clientResource;
+ if (!AddResource (clientResource, ClientType, (pointer)pNewShapeEvent))
+ return BadAlloc;
+ /*
+ * create a resource to contain a pointer to the list
+ * of clients selecting input. This must be indirect as
+ * the list may be arbitrarily rearranged which cannot be
+ * done through the resource database.
+ */
+ if (!pHead)
+ {
+ pHead = (ShapeEventPtr *) xalloc (sizeof (ShapeEventPtr));
+ if (!pHead ||
+ !AddResource (pWin->drawable.id, EventType, (pointer)pHead))
+ {
+ FreeResource (clientResource, RT_NONE);
+ return BadAlloc;
+ }
+ *pHead = 0;
+ }
+ pNewShapeEvent->next = *pHead;
+ *pHead = pNewShapeEvent;
+ break;
+ case xFalse:
+ /* delete the interest */
+ if (pHead) {
+ pNewShapeEvent = 0;
+ for (pShapeEvent = *pHead; pShapeEvent; pShapeEvent = pShapeEvent->next) {
+ if (pShapeEvent->client == client)
+ break;
+ pNewShapeEvent = pShapeEvent;
+ }
+ if (pShapeEvent) {
+ FreeResource (pShapeEvent->clientResource, ClientType);
+ if (pNewShapeEvent)
+ pNewShapeEvent->next = pShapeEvent->next;
+ else
+ *pHead = pShapeEvent->next;
+ xfree (pShapeEvent);
+ }
+ }
+ break;
+ default:
+ client->errorValue = stuff->enable;
+ return BadValue;
+ }
+ return Success;
+}
+
+/*
+ * deliver the event
+ */
+
+void
+SendShapeNotify (pWin, which)
+ WindowPtr pWin;
+ int which;
+{
+ ShapeEventPtr *pHead, pShapeEvent;
+ ClientPtr client;
+ xShapeNotifyEvent se;
+ BoxRec extents;
+ RegionPtr region;
+ BYTE shaped;
+
+ pHead = (ShapeEventPtr *) LookupIDByType(pWin->drawable.id, EventType);
+ if (!pHead)
+ return;
+ switch (which) {
+ case ShapeBounding:
+ region = wBoundingShape(pWin);
+ if (region) {
+ extents = *REGION_EXTENTS(pWin->drawable.pScreen, region);
+ shaped = xTrue;
+ } else {
+ extents.x1 = -wBorderWidth (pWin);
+ extents.y1 = -wBorderWidth (pWin);
+ extents.x2 = pWin->drawable.width + wBorderWidth (pWin);
+ extents.y2 = pWin->drawable.height + wBorderWidth (pWin);
+ shaped = xFalse;
+ }
+ break;
+ case ShapeClip:
+ region = wClipShape(pWin);
+ if (region) {
+ extents = *REGION_EXTENTS(pWin->drawable.pScreen, region);
+ shaped = xTrue;
+ } else {
+ extents.x1 = 0;
+ extents.y1 = 0;
+ extents.x2 = pWin->drawable.width;
+ extents.y2 = pWin->drawable.height;
+ shaped = xFalse;
+ }
+ break;
+ case ShapeInput:
+ region = wInputShape(pWin);
+ if (region) {
+ extents = *REGION_EXTENTS(pWin->drawable.pScreen, region);
+ shaped = xTrue;
+ } else {
+ extents.x1 = -wBorderWidth (pWin);
+ extents.y1 = -wBorderWidth (pWin);
+ extents.x2 = pWin->drawable.width + wBorderWidth (pWin);
+ extents.y2 = pWin->drawable.height + wBorderWidth (pWin);
+ shaped = xFalse;
+ }
+ break;
+ default:
+ return;
+ }
+ for (pShapeEvent = *pHead; pShapeEvent; pShapeEvent = pShapeEvent->next) {
+ client = pShapeEvent->client;
+ if (client == serverClient || client->clientGone)
+ continue;
+ se.type = ShapeNotify + ShapeEventBase;
+ se.kind = which;
+ se.window = pWin->drawable.id;
+ se.sequenceNumber = client->sequence;
+ se.x = extents.x1;
+ se.y = extents.y1;
+ se.width = extents.x2 - extents.x1;
+ se.height = extents.y2 - extents.y1;
+ se.time = currentTime.milliseconds;
+ se.shaped = shaped;
+ WriteEventsToClient (client, 1, (xEvent *) &se);
+ }
+}
+
+static int
+ProcShapeInputSelected (client)
+ register ClientPtr client;
+{
+ REQUEST(xShapeInputSelectedReq);
+ WindowPtr pWin;
+ ShapeEventPtr pShapeEvent, *pHead;
+ int enabled;
+ xShapeInputSelectedReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH (xShapeInputSelectedReq);
+ pWin = LookupWindow (stuff->window, client);
+ if (!pWin)
+ return BadWindow;
+ pHead = (ShapeEventPtr *) SecurityLookupIDByType(client,
+ pWin->drawable.id, EventType, SecurityReadAccess);
+ enabled = xFalse;
+ if (pHead) {
+ for (pShapeEvent = *pHead;
+ pShapeEvent;
+ pShapeEvent = pShapeEvent->next)
+ {
+ if (pShapeEvent->client == client) {
+ enabled = xTrue;
+ break;
+ }
+ }
+ }
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.enabled = enabled;
+ if (client->swapped) {
+ swaps (&rep.sequenceNumber, n);
+ swapl (&rep.length, n);
+ }
+ WriteToClient (client, sizeof (xShapeInputSelectedReply), (char *) &rep);
+ return (client->noClientException);
+}
+
+static int
+ProcShapeGetRectangles (client)
+ register ClientPtr client;
+{
+ REQUEST(xShapeGetRectanglesReq);
+ WindowPtr pWin;
+ xShapeGetRectanglesReply rep;
+ xRectangle *rects;
+ int nrects, i;
+ RegionPtr region;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xShapeGetRectanglesReq);
+ pWin = LookupWindow (stuff->window, client);
+ if (!pWin)
+ return BadWindow;
+ switch (stuff->kind) {
+ case ShapeBounding:
+ region = wBoundingShape(pWin);
+ break;
+ case ShapeClip:
+ region = wClipShape(pWin);
+ break;
+ case ShapeInput:
+ region = wInputShape (pWin);
+ break;
+ default:
+ client->errorValue = stuff->kind;
+ return BadValue;
+ }
+ if (!region) {
+ nrects = 1;
+ rects = (xRectangle *) ALLOCATE_LOCAL (sizeof (xRectangle));
+ if (!rects)
+ return BadAlloc;
+ switch (stuff->kind) {
+ case ShapeBounding:
+ rects->x = - (int) wBorderWidth (pWin);
+ rects->y = - (int) wBorderWidth (pWin);
+ rects->width = pWin->drawable.width + wBorderWidth (pWin);
+ rects->height = pWin->drawable.height + wBorderWidth (pWin);
+ break;
+ case ShapeClip:
+ rects->x = 0;
+ rects->y = 0;
+ rects->width = pWin->drawable.width;
+ rects->height = pWin->drawable.height;
+ break;
+ case ShapeInput:
+ rects->x = - (int) wBorderWidth (pWin);
+ rects->y = - (int) wBorderWidth (pWin);
+ rects->width = pWin->drawable.width + wBorderWidth (pWin);
+ rects->height = pWin->drawable.height + wBorderWidth (pWin);
+ break;
+ }
+ } else {
+ BoxPtr box;
+ nrects = REGION_NUM_RECTS(region);
+ box = REGION_RECTS(region);
+ rects = (xRectangle *) ALLOCATE_LOCAL (nrects * sizeof (xRectangle));
+ if (!rects && nrects)
+ return BadAlloc;
+ for (i = 0; i < nrects; i++, box++) {
+ rects[i].x = box->x1;
+ rects[i].y = box->y1;
+ rects[i].width = box->x2 - box->x1;
+ rects[i].height = box->y2 - box->y1;
+ }
+ }
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = (nrects * sizeof (xRectangle)) >> 2;
+ rep.ordering = YXBanded;
+ rep.nrects = nrects;
+ if (client->swapped) {
+ swaps (&rep.sequenceNumber, n);
+ swapl (&rep.length, n);
+ swapl (&rep.nrects, n);
+ SwapShorts ((short *)rects, (unsigned long)nrects * 4);
+ }
+ WriteToClient (client, sizeof (rep), (char *) &rep);
+ WriteToClient (client, nrects * sizeof (xRectangle), (char *) rects);
+ DEALLOCATE_LOCAL (rects);
+ return client->noClientException;
+}
+
+static int
+ProcShapeDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data) {
+ case X_ShapeQueryVersion:
+ return ProcShapeQueryVersion (client);
+ case X_ShapeRectangles:
+#ifdef PANORAMIX
+ if ( !noPanoramiXExtension )
+ return ProcPanoramiXShapeRectangles (client);
+ else
+#endif
+ return ProcShapeRectangles (client);
+ case X_ShapeMask:
+#ifdef PANORAMIX
+ if ( !noPanoramiXExtension )
+ return ProcPanoramiXShapeMask (client);
+ else
+#endif
+ return ProcShapeMask (client);
+ case X_ShapeCombine:
+#ifdef PANORAMIX
+ if ( !noPanoramiXExtension )
+ return ProcPanoramiXShapeCombine (client);
+ else
+#endif
+ return ProcShapeCombine (client);
+ case X_ShapeOffset:
+#ifdef PANORAMIX
+ if ( !noPanoramiXExtension )
+ return ProcPanoramiXShapeOffset (client);
+ else
+#endif
+ return ProcShapeOffset (client);
+ case X_ShapeQueryExtents:
+ return ProcShapeQueryExtents (client);
+ case X_ShapeSelectInput:
+ return ProcShapeSelectInput (client);
+ case X_ShapeInputSelected:
+ return ProcShapeInputSelected (client);
+ case X_ShapeGetRectangles:
+ return ProcShapeGetRectangles (client);
+ default:
+ return BadRequest;
+ }
+}
+
+static void
+SShapeNotifyEvent(from, to)
+ xShapeNotifyEvent *from, *to;
+{
+ to->type = from->type;
+ to->kind = from->kind;
+ cpswapl (from->window, to->window);
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswaps (from->x, to->x);
+ cpswaps (from->y, to->y);
+ cpswaps (from->width, to->width);
+ cpswaps (from->height, to->height);
+ cpswapl (from->time, to->time);
+ to->shaped = from->shaped;
+}
+
+static int
+SProcShapeQueryVersion (client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST (xShapeQueryVersionReq);
+
+ swaps (&stuff->length, n);
+ return ProcShapeQueryVersion (client);
+}
+
+static int
+SProcShapeRectangles (client)
+ register ClientPtr client;
+{
+ register char n;
+ REQUEST (xShapeRectanglesReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE (xShapeRectanglesReq);
+ swapl (&stuff->dest, n);
+ swaps (&stuff->xOff, n);
+ swaps (&stuff->yOff, n);
+ SwapRestS(stuff);
+ return ProcShapeRectangles (client);
+}
+
+static int
+SProcShapeMask (client)
+ register ClientPtr client;
+{
+ register char n;
+ REQUEST (xShapeMaskReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH (xShapeMaskReq);
+ swapl (&stuff->dest, n);
+ swaps (&stuff->xOff, n);
+ swaps (&stuff->yOff, n);
+ swapl (&stuff->src, n);
+ return ProcShapeMask (client);
+}
+
+static int
+SProcShapeCombine (client)
+ register ClientPtr client;
+{
+ register char n;
+ REQUEST (xShapeCombineReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH (xShapeCombineReq);
+ swapl (&stuff->dest, n);
+ swaps (&stuff->xOff, n);
+ swaps (&stuff->yOff, n);
+ swapl (&stuff->src, n);
+ return ProcShapeCombine (client);
+}
+
+static int
+SProcShapeOffset (client)
+ register ClientPtr client;
+{
+ register char n;
+ REQUEST (xShapeOffsetReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH (xShapeOffsetReq);
+ swapl (&stuff->dest, n);
+ swaps (&stuff->xOff, n);
+ swaps (&stuff->yOff, n);
+ return ProcShapeOffset (client);
+}
+
+static int
+SProcShapeQueryExtents (client)
+ register ClientPtr client;
+{
+ register char n;
+ REQUEST (xShapeQueryExtentsReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH (xShapeQueryExtentsReq);
+ swapl (&stuff->window, n);
+ return ProcShapeQueryExtents (client);
+}
+
+static int
+SProcShapeSelectInput (client)
+ register ClientPtr client;
+{
+ register char n;
+ REQUEST (xShapeSelectInputReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH (xShapeSelectInputReq);
+ swapl (&stuff->window, n);
+ return ProcShapeSelectInput (client);
+}
+
+static int
+SProcShapeInputSelected (client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST (xShapeInputSelectedReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH (xShapeInputSelectedReq);
+ swapl (&stuff->window, n);
+ return ProcShapeInputSelected (client);
+}
+
+static int
+SProcShapeGetRectangles (client)
+ register ClientPtr client;
+{
+ REQUEST(xShapeGetRectanglesReq);
+ register char n;
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xShapeGetRectanglesReq);
+ swapl (&stuff->window, n);
+ return ProcShapeGetRectangles (client);
+}
+
+static int
+SProcShapeDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data) {
+ case X_ShapeQueryVersion:
+ return SProcShapeQueryVersion (client);
+ case X_ShapeRectangles:
+ return SProcShapeRectangles (client);
+ case X_ShapeMask:
+ return SProcShapeMask (client);
+ case X_ShapeCombine:
+ return SProcShapeCombine (client);
+ case X_ShapeOffset:
+ return SProcShapeOffset (client);
+ case X_ShapeQueryExtents:
+ return SProcShapeQueryExtents (client);
+ case X_ShapeSelectInput:
+ return SProcShapeSelectInput (client);
+ case X_ShapeInputSelected:
+ return SProcShapeInputSelected (client);
+ case X_ShapeGetRectangles:
+ return SProcShapeGetRectangles (client);
+ default:
+ return BadRequest;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xext/shm.c b/nx-X11/programs/Xserver/Xext/shm.c
new file mode 100644
index 000000000..806008c60
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/shm.c
@@ -0,0 +1,1267 @@
+/* $XFree86: xc/programs/Xserver/Xext/shm.c,v 3.41 2003/12/17 23:28:56 alanh Exp $ */
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+********************************************************/
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */
+
+/* $Xorg: shm.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
+
+#define SHM
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <sys/types.h>
+#ifndef Lynx
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#else
+#include <ipc.h>
+#include <shm.h>
+#endif
+#include <unistd.h>
+#include <sys/stat.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "gcstruct.h"
+#include "extnsionst.h"
+#include "servermd.h"
+#define _XSHM_SERVER_
+#include <X11/extensions/shmstr.h>
+#include <X11/Xfuncproto.h>
+#ifdef EXTMODULE
+#include "xf86_ansic.h"
+#endif
+
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+
+#include "modinit.h"
+
+typedef struct _ShmDesc {
+ struct _ShmDesc *next;
+ int shmid;
+ int refcnt;
+ char *addr;
+ Bool writable;
+ unsigned long size;
+} ShmDescRec, *ShmDescPtr;
+
+static void miShmPutImage(XSHM_PUT_IMAGE_ARGS);
+static void fbShmPutImage(XSHM_PUT_IMAGE_ARGS);
+static PixmapPtr fbShmCreatePixmap(XSHM_CREATE_PIXMAP_ARGS);
+static int ShmDetachSegment(
+ pointer /* value */,
+ XID /* shmseg */
+ );
+static void ShmResetProc(
+ ExtensionEntry * /* extEntry */
+ );
+static void SShmCompletionEvent(
+ xShmCompletionEvent * /* from */,
+ xShmCompletionEvent * /* to */
+ );
+
+static Bool ShmDestroyPixmap (PixmapPtr pPixmap);
+
+static DISPATCH_PROC(ProcShmAttach);
+static DISPATCH_PROC(ProcShmCreatePixmap);
+static DISPATCH_PROC(ProcShmDetach);
+static DISPATCH_PROC(ProcShmDispatch);
+static DISPATCH_PROC(ProcShmGetImage);
+static DISPATCH_PROC(ProcShmPutImage);
+static DISPATCH_PROC(ProcShmQueryVersion);
+static DISPATCH_PROC(SProcShmAttach);
+static DISPATCH_PROC(SProcShmCreatePixmap);
+static DISPATCH_PROC(SProcShmDetach);
+static DISPATCH_PROC(SProcShmDispatch);
+static DISPATCH_PROC(SProcShmGetImage);
+static DISPATCH_PROC(SProcShmPutImage);
+static DISPATCH_PROC(SProcShmQueryVersion);
+
+static unsigned char ShmReqCode;
+int ShmCompletionCode;
+int BadShmSegCode;
+RESTYPE ShmSegType;
+static ShmDescPtr Shmsegs;
+static Bool sharedPixmaps;
+static int pixmapFormat;
+static int shmPixFormat[MAXSCREENS];
+static ShmFuncsPtr shmFuncs[MAXSCREENS];
+static DestroyPixmapProcPtr destroyPixmap[MAXSCREENS];
+#ifdef PIXPRIV
+static int shmPixmapPrivate;
+#endif
+static ShmFuncs miFuncs = {NULL, miShmPutImage};
+static ShmFuncs fbFuncs = {fbShmCreatePixmap, fbShmPutImage};
+
+#define VERIFY_SHMSEG(shmseg,shmdesc,client) \
+{ \
+ shmdesc = (ShmDescPtr)LookupIDByType(shmseg, ShmSegType); \
+ if (!shmdesc) \
+ { \
+ client->errorValue = shmseg; \
+ return BadShmSegCode; \
+ } \
+}
+
+#define VERIFY_SHMPTR(shmseg,offset,needwrite,shmdesc,client) \
+{ \
+ VERIFY_SHMSEG(shmseg, shmdesc, client); \
+ if ((offset & 3) || (offset > shmdesc->size)) \
+ { \
+ client->errorValue = offset; \
+ return BadValue; \
+ } \
+ if (needwrite && !shmdesc->writable) \
+ return BadAccess; \
+}
+
+#define VERIFY_SHMSIZE(shmdesc,offset,len,client) \
+{ \
+ if ((offset + len) > shmdesc->size) \
+ { \
+ return BadAccess; \
+ } \
+}
+
+
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__)
+#include <sys/signal.h>
+
+static Bool badSysCall = FALSE;
+
+static void
+SigSysHandler(signo)
+int signo;
+{
+ badSysCall = TRUE;
+}
+
+static Bool CheckForShmSyscall()
+{
+ void (*oldHandler)();
+ int shmid = -1;
+
+ /* If no SHM support in the kernel, the bad syscall will generate SIGSYS */
+ oldHandler = signal(SIGSYS, SigSysHandler);
+
+ badSysCall = FALSE;
+ shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT);
+
+ if (shmid != -1)
+ {
+ /* Successful allocation - clean up */
+ shmctl(shmid, IPC_RMID, (struct shmid_ds *)NULL);
+ }
+ else
+ {
+ /* Allocation failed */
+ badSysCall = TRUE;
+ }
+ signal(SIGSYS, oldHandler);
+ return(!badSysCall);
+}
+
+#define MUST_CHECK_FOR_SHM_SYSCALL
+
+#endif
+
+void
+ShmExtensionInit(INITARGS)
+{
+ ExtensionEntry *extEntry;
+ int i;
+
+#ifdef MUST_CHECK_FOR_SHM_SYSCALL
+ if (!CheckForShmSyscall())
+ {
+ ErrorF("MIT-SHM extension disabled due to lack of kernel support\n");
+ return;
+ }
+#endif
+
+ sharedPixmaps = xFalse;
+ pixmapFormat = 0;
+ {
+ sharedPixmaps = xTrue;
+ pixmapFormat = shmPixFormat[0];
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ if (!shmFuncs[i])
+ shmFuncs[i] = &miFuncs;
+ if (!shmFuncs[i]->CreatePixmap)
+ sharedPixmaps = xFalse;
+ if (shmPixFormat[i] && (shmPixFormat[i] != pixmapFormat))
+ {
+ sharedPixmaps = xFalse;
+ pixmapFormat = 0;
+ }
+ }
+ if (!pixmapFormat)
+ pixmapFormat = ZPixmap;
+ if (sharedPixmaps)
+ {
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ destroyPixmap[i] = screenInfo.screens[i]->DestroyPixmap;
+ screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap;
+ }
+#ifdef PIXPRIV
+ shmPixmapPrivate = AllocatePixmapPrivateIndex();
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ if (!AllocatePixmapPrivate(screenInfo.screens[i],
+ shmPixmapPrivate, 0))
+ return;
+ }
+#endif
+ }
+ }
+ ShmSegType = CreateNewResourceType(ShmDetachSegment);
+ if (ShmSegType &&
+ (extEntry = AddExtension(SHMNAME, ShmNumberEvents, ShmNumberErrors,
+ ProcShmDispatch, SProcShmDispatch,
+ ShmResetProc, StandardMinorOpcode)))
+ {
+ ShmReqCode = (unsigned char)extEntry->base;
+ ShmCompletionCode = extEntry->eventBase;
+ BadShmSegCode = extEntry->errorBase;
+ EventSwapVector[ShmCompletionCode] = (EventSwapPtr) SShmCompletionEvent;
+ }
+}
+
+/*ARGSUSED*/
+static void
+ShmResetProc (extEntry)
+ExtensionEntry *extEntry;
+{
+ int i;
+
+ for (i = 0; i < MAXSCREENS; i++)
+ {
+ shmFuncs[i] = (ShmFuncsPtr)NULL;
+ shmPixFormat[i] = 0;
+ }
+}
+
+void
+ShmRegisterFuncs(
+ ScreenPtr pScreen,
+ ShmFuncsPtr funcs)
+{
+ shmFuncs[pScreen->myNum] = funcs;
+}
+
+void
+ShmSetPixmapFormat(
+ ScreenPtr pScreen,
+ int format)
+{
+ shmPixFormat[pScreen->myNum] = format;
+}
+
+static Bool
+ShmDestroyPixmap (PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ Bool ret;
+ if (pPixmap->refcnt == 1)
+ {
+ ShmDescPtr shmdesc;
+#ifdef PIXPRIV
+ shmdesc = (ShmDescPtr) pPixmap->devPrivates[shmPixmapPrivate].ptr;
+#else
+ char *base = (char *) pPixmap->devPrivate.ptr;
+
+ if (base != (pointer) (pPixmap + 1))
+ {
+ for (shmdesc = Shmsegs; shmdesc; shmdesc = shmdesc->next)
+ {
+ if (shmdesc->addr <= base && base <= shmdesc->addr + shmdesc->size)
+ break;
+ }
+ }
+ else
+ shmdesc = 0;
+#endif
+ if (shmdesc)
+ ShmDetachSegment ((pointer) shmdesc, pPixmap->drawable.id);
+ }
+
+ pScreen->DestroyPixmap = destroyPixmap[pScreen->myNum];
+ ret = (*pScreen->DestroyPixmap) (pPixmap);
+ destroyPixmap[pScreen->myNum] = pScreen->DestroyPixmap;
+ pScreen->DestroyPixmap = ShmDestroyPixmap;
+ return ret;
+}
+
+void
+ShmRegisterFbFuncs(pScreen)
+ ScreenPtr pScreen;
+{
+ shmFuncs[pScreen->myNum] = &fbFuncs;
+}
+
+static int
+ProcShmQueryVersion(client)
+ register ClientPtr client;
+{
+ xShmQueryVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xShmQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.sharedPixmaps = sharedPixmaps;
+ rep.pixmapFormat = pixmapFormat;
+ rep.majorVersion = SHM_MAJOR_VERSION;
+ rep.minorVersion = SHM_MINOR_VERSION;
+ rep.uid = geteuid();
+ rep.gid = getegid();
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ swaps(&rep.uid, n);
+ swaps(&rep.gid, n);
+ }
+ WriteToClient(client, sizeof(xShmQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+/*
+ * Simulate the access() system call for a shared memory segement,
+ * using the credentials from the client if available
+ */
+static int
+shm_access(ClientPtr client, struct ipc_perm *perm, int readonly)
+{
+ int uid, gid;
+ mode_t mask;
+
+ if (LocalClientCred(client, &uid, &gid) != -1) {
+
+ /* User id 0 always gets access */
+ if (uid == 0) {
+ return 0;
+ }
+ /* Check the owner */
+ if (perm->uid == uid || perm->cuid == uid) {
+ mask = S_IRUSR;
+ if (!readonly) {
+ mask |= S_IWUSR;
+ }
+ return (perm->mode & mask) == mask ? 0 : -1;
+ }
+ /* Check the group */
+ if (perm->gid == gid || perm->cgid == gid) {
+ mask = S_IRGRP;
+ if (!readonly) {
+ mask |= S_IWGRP;
+ }
+ return (perm->mode & mask) == mask ? 0 : -1;
+ }
+ }
+ /* Otherwise, check everyone else */
+ mask = S_IROTH;
+ if (!readonly) {
+ mask |= S_IWOTH;
+ }
+ return (perm->mode & mask) == mask ? 0 : -1;
+}
+
+static int
+ProcShmAttach(client)
+ register ClientPtr client;
+{
+ struct shmid_ds buf;
+ ShmDescPtr shmdesc;
+ REQUEST(xShmAttachReq);
+
+ REQUEST_SIZE_MATCH(xShmAttachReq);
+ LEGAL_NEW_RESOURCE(stuff->shmseg, client);
+ if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse))
+ {
+ client->errorValue = stuff->readOnly;
+ return(BadValue);
+ }
+ for (shmdesc = Shmsegs;
+ shmdesc && (shmdesc->shmid != stuff->shmid);
+ shmdesc = shmdesc->next)
+ ;
+ if (shmdesc)
+ {
+ if (!stuff->readOnly && !shmdesc->writable)
+ return BadAccess;
+ shmdesc->refcnt++;
+ }
+ else
+ {
+ shmdesc = (ShmDescPtr) xalloc(sizeof(ShmDescRec));
+ if (!shmdesc)
+ return BadAlloc;
+ shmdesc->addr = shmat(stuff->shmid, 0,
+ stuff->readOnly ? SHM_RDONLY : 0);
+ if ((shmdesc->addr == ((char *)-1)) ||
+ shmctl(stuff->shmid, IPC_STAT, &buf))
+ {
+ xfree(shmdesc);
+ return BadAccess;
+ }
+
+ /* The attach was performed with root privs. We must
+ * do manual checking of access rights for the credentials
+ * of the client */
+
+ if (shm_access(client, &(buf.shm_perm), stuff->readOnly) == -1) {
+ shmdt(shmdesc->addr);
+ xfree(shmdesc);
+ return BadAccess;
+ }
+
+ shmdesc->shmid = stuff->shmid;
+ shmdesc->refcnt = 1;
+ shmdesc->writable = !stuff->readOnly;
+ shmdesc->size = buf.shm_segsz;
+ shmdesc->next = Shmsegs;
+ Shmsegs = shmdesc;
+ }
+ if (!AddResource(stuff->shmseg, ShmSegType, (pointer)shmdesc))
+ return BadAlloc;
+ return(client->noClientException);
+}
+
+/*ARGSUSED*/
+static int
+ShmDetachSegment(value, shmseg)
+ pointer value; /* must conform to DeleteType */
+ XID shmseg;
+{
+ ShmDescPtr shmdesc = (ShmDescPtr)value;
+ ShmDescPtr *prev;
+
+ if (--shmdesc->refcnt)
+ return TRUE;
+ shmdt(shmdesc->addr);
+ for (prev = &Shmsegs; *prev != shmdesc; prev = &(*prev)->next)
+ ;
+ *prev = shmdesc->next;
+ xfree(shmdesc);
+ return Success;
+}
+
+static int
+ProcShmDetach(client)
+ register ClientPtr client;
+{
+ ShmDescPtr shmdesc;
+ REQUEST(xShmDetachReq);
+
+ REQUEST_SIZE_MATCH(xShmDetachReq);
+ VERIFY_SHMSEG(stuff->shmseg, shmdesc, client);
+ FreeResource(stuff->shmseg, RT_NONE);
+ return(client->noClientException);
+}
+
+static void
+miShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data)
+ DrawablePtr dst;
+ GCPtr pGC;
+ int depth, w, h, sx, sy, sw, sh, dx, dy;
+ unsigned int format;
+ char *data;
+{
+ PixmapPtr pmap;
+ GCPtr putGC;
+
+ putGC = GetScratchGC(depth, dst->pScreen);
+ if (!putGC)
+ return;
+ pmap = (*dst->pScreen->CreatePixmap)(dst->pScreen, sw, sh, depth);
+ if (!pmap)
+ {
+ FreeScratchGC(putGC);
+ return;
+ }
+ ValidateGC((DrawablePtr)pmap, putGC);
+ (*putGC->ops->PutImage)((DrawablePtr)pmap, putGC, depth, -sx, -sy, w, h, 0,
+ (format == XYPixmap) ? XYPixmap : ZPixmap, data);
+ FreeScratchGC(putGC);
+ if (format == XYBitmap)
+ (void)(*pGC->ops->CopyPlane)((DrawablePtr)pmap, dst, pGC, 0, 0, sw, sh,
+ dx, dy, 1L);
+ else
+ (void)(*pGC->ops->CopyArea)((DrawablePtr)pmap, dst, pGC, 0, 0, sw, sh,
+ dx, dy);
+ (*pmap->drawable.pScreen->DestroyPixmap)(pmap);
+}
+
+static void
+fbShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data)
+ DrawablePtr dst;
+ GCPtr pGC;
+ int depth, w, h, sx, sy, sw, sh, dx, dy;
+ unsigned int format;
+ char *data;
+{
+ if ((format == ZPixmap) || (depth == 1))
+ {
+ PixmapPtr pPixmap;
+
+ pPixmap = GetScratchPixmapHeader(dst->pScreen, w, h, depth,
+ BitsPerPixel(depth), PixmapBytePad(w, depth), (pointer)data);
+ if (!pPixmap)
+ return;
+ if (format == XYBitmap)
+ (void)(*pGC->ops->CopyPlane)((DrawablePtr)pPixmap, dst, pGC,
+ sx, sy, sw, sh, dx, dy, 1L);
+ else
+ (void)(*pGC->ops->CopyArea)((DrawablePtr)pPixmap, dst, pGC,
+ sx, sy, sw, sh, dx, dy);
+ FreeScratchPixmapHeader(pPixmap);
+ }
+ else
+ miShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy,
+ data);
+}
+
+
+#ifdef PANORAMIX
+static int
+ProcPanoramiXShmPutImage(register ClientPtr client)
+{
+ int j, result = 0, orig_x, orig_y;
+ PanoramiXRes *draw, *gc;
+ Bool sendEvent, isRoot;
+
+ REQUEST(xShmPutImageReq);
+ REQUEST_SIZE_MATCH(xShmPutImageReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ orig_x = stuff->dstX;
+ orig_y = stuff->dstY;
+ sendEvent = stuff->sendEvent;
+ stuff->sendEvent = 0;
+ FOR_NSCREENS(j) {
+ if(!j) stuff->sendEvent = sendEvent;
+ stuff->drawable = draw->info[j].id;
+ stuff->gc = gc->info[j].id;
+ if (isRoot) {
+ stuff->dstX = orig_x - panoramiXdataPtr[j].x;
+ stuff->dstY = orig_y - panoramiXdataPtr[j].y;
+ }
+ result = ProcShmPutImage(client);
+ if(result != client->noClientException) break;
+ }
+ return(result);
+}
+
+static int
+ProcPanoramiXShmGetImage(ClientPtr client)
+{
+ PanoramiXRes *draw;
+ DrawablePtr drawables[MAXSCREENS];
+ DrawablePtr pDraw;
+ xShmGetImageReply xgi;
+ ShmDescPtr shmdesc;
+ int i, x, y, w, h, format;
+ Mask plane = 0, planemask;
+ long lenPer = 0, length, widthBytesLine;
+ Bool isRoot;
+
+ REQUEST(xShmGetImageReq);
+
+ REQUEST_SIZE_MATCH(xShmGetImageReq);
+
+ if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) {
+ client->errorValue = stuff->format;
+ return(BadValue);
+ }
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if (draw->type == XRT_PIXMAP)
+ return ProcShmGetImage(client);
+
+ VERIFY_DRAWABLE(pDraw, stuff->drawable, client);
+
+ VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
+
+ x = stuff->x;
+ y = stuff->y;
+ w = stuff->width;
+ h = stuff->height;
+ format = stuff->format;
+ planemask = stuff->planeMask;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ if(isRoot) {
+ if( /* check for being onscreen */
+ x < 0 || x + w > PanoramiXPixWidth ||
+ y < 0 || y + h > PanoramiXPixHeight )
+ return(BadMatch);
+ } else {
+ if( /* check for being onscreen */
+ panoramiXdataPtr[0].x + pDraw->x + x < 0 ||
+ panoramiXdataPtr[0].x + pDraw->x + x + w > PanoramiXPixWidth ||
+ panoramiXdataPtr[0].y + pDraw->y + y < 0 ||
+ panoramiXdataPtr[0].y + pDraw->y + y + h > PanoramiXPixHeight ||
+ /* check for being inside of border */
+ x < - wBorderWidth((WindowPtr)pDraw) ||
+ x + w > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
+ y < -wBorderWidth((WindowPtr)pDraw) ||
+ y + h > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height)
+ return(BadMatch);
+ }
+
+ drawables[0] = pDraw;
+ for(i = 1; i < PanoramiXNumScreens; i++)
+ VERIFY_DRAWABLE(drawables[i], draw->info[i].id, client);
+
+ xgi.visual = wVisual(((WindowPtr)pDraw));
+ xgi.type = X_Reply;
+ xgi.length = 0;
+ xgi.sequenceNumber = client->sequence;
+ xgi.depth = pDraw->depth;
+
+ if(format == ZPixmap) {
+ widthBytesLine = PixmapBytePad(w, pDraw->depth);
+ length = widthBytesLine * h;
+ } else {
+ widthBytesLine = PixmapBytePad(w, 1);
+ lenPer = widthBytesLine * h;
+ plane = ((Mask)1) << (pDraw->depth - 1);
+ length = lenPer * Ones(planemask & (plane | (plane - 1)));
+ }
+
+ VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client);
+ xgi.size = length;
+
+ if (length == 0) {/* nothing to do */ }
+ else if (format == ZPixmap) {
+ XineramaGetImageData(drawables, x, y, w, h, format, planemask,
+ shmdesc->addr + stuff->offset,
+ widthBytesLine, isRoot);
+ } else {
+
+ length = stuff->offset;
+ for (; plane; plane >>= 1) {
+ if (planemask & plane) {
+ XineramaGetImageData(drawables, x, y, w, h,
+ format, plane, shmdesc->addr + length,
+ widthBytesLine, isRoot);
+ length += lenPer;
+ }
+ }
+ }
+
+ if (client->swapped) {
+ register int n;
+ swaps(&xgi.sequenceNumber, n);
+ swapl(&xgi.length, n);
+ swapl(&xgi.visual, n);
+ swapl(&xgi.size, n);
+ }
+ WriteToClient(client, sizeof(xShmGetImageReply), (char *)&xgi);
+
+ return(client->noClientException);
+}
+
+static int
+ProcPanoramiXShmCreatePixmap(
+ register ClientPtr client)
+{
+ ScreenPtr pScreen = NULL;
+ PixmapPtr pMap = NULL;
+ DrawablePtr pDraw;
+ DepthPtr pDepth;
+ int i, j, result;
+ ShmDescPtr shmdesc;
+ REQUEST(xShmCreatePixmapReq);
+ PanoramiXRes *newPix;
+
+ REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
+ client->errorValue = stuff->pid;
+ if (!sharedPixmaps)
+ return BadImplementation;
+ LEGAL_NEW_RESOURCE(stuff->pid, client);
+ VERIFY_GEOMETRABLE(pDraw, stuff->drawable, client);
+ VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
+ if (!stuff->width || !stuff->height)
+ {
+ client->errorValue = 0;
+ return BadValue;
+ }
+ if (stuff->depth != 1)
+ {
+ pDepth = pDraw->pScreen->allowedDepths;
+ for (i=0; i<pDraw->pScreen->numDepths; i++, pDepth++)
+ if (pDepth->depth == stuff->depth)
+ goto CreatePmap;
+ client->errorValue = stuff->depth;
+ return BadValue;
+ }
+CreatePmap:
+ VERIFY_SHMSIZE(shmdesc, stuff->offset,
+ PixmapBytePad(stuff->width, stuff->depth) * stuff->height,
+ client);
+
+ if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
+ return BadAlloc;
+
+ newPix->type = XRT_PIXMAP;
+ newPix->u.pix.shared = TRUE;
+ newPix->info[0].id = stuff->pid;
+ for(j = 1; j < PanoramiXNumScreens; j++)
+ newPix->info[j].id = FakeClientID(client->index);
+
+ result = (client->noClientException);
+
+ FOR_NSCREENS(j) {
+ pScreen = screenInfo.screens[j];
+
+ pMap = (*shmFuncs[j]->CreatePixmap)(pScreen,
+ stuff->width, stuff->height, stuff->depth,
+ shmdesc->addr + stuff->offset);
+
+ if (pMap) {
+#ifdef PIXPRIV
+ pMap->devPrivates[shmPixmapPrivate].ptr = (pointer) shmdesc;
+#endif
+ shmdesc->refcnt++;
+ pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pMap->drawable.id = newPix->info[j].id;
+ if (!AddResource(newPix->info[j].id, RT_PIXMAP, (pointer)pMap)) {
+ (*pScreen->DestroyPixmap)(pMap);
+ result = BadAlloc;
+ break;
+ }
+ } else {
+ result = BadAlloc;
+ break;
+ }
+ }
+
+ if(result == BadAlloc) {
+ while(j--) {
+ (*pScreen->DestroyPixmap)(pMap);
+ FreeResource(newPix->info[j].id, RT_NONE);
+ }
+ xfree(newPix);
+ } else
+ AddResource(stuff->pid, XRT_PIXMAP, newPix);
+
+ return result;
+}
+
+#endif
+
+static int
+ProcShmPutImage(client)
+ register ClientPtr client;
+{
+ register GCPtr pGC;
+ register DrawablePtr pDraw;
+ long length;
+ ShmDescPtr shmdesc;
+ REQUEST(xShmPutImageReq);
+
+ REQUEST_SIZE_MATCH(xShmPutImageReq);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VERIFY_SHMPTR(stuff->shmseg, stuff->offset, FALSE, shmdesc, client);
+ if ((stuff->sendEvent != xTrue) && (stuff->sendEvent != xFalse))
+ return BadValue;
+ if (stuff->format == XYBitmap)
+ {
+ if (stuff->depth != 1)
+ return BadMatch;
+ length = PixmapBytePad(stuff->totalWidth, 1);
+ }
+ else if (stuff->format == XYPixmap)
+ {
+ if (pDraw->depth != stuff->depth)
+ return BadMatch;
+ length = PixmapBytePad(stuff->totalWidth, 1);
+ length *= stuff->depth;
+ }
+ else if (stuff->format == ZPixmap)
+ {
+ if (pDraw->depth != stuff->depth)
+ return BadMatch;
+ length = PixmapBytePad(stuff->totalWidth, stuff->depth);
+ }
+ else
+ {
+ client->errorValue = stuff->format;
+ return BadValue;
+ }
+
+ VERIFY_SHMSIZE(shmdesc, stuff->offset, length * stuff->totalHeight,
+ client);
+ if (stuff->srcX > stuff->totalWidth)
+ {
+ client->errorValue = stuff->srcX;
+ return BadValue;
+ }
+ if (stuff->srcY > stuff->totalHeight)
+ {
+ client->errorValue = stuff->srcY;
+ return BadValue;
+ }
+ if ((stuff->srcX + stuff->srcWidth) > stuff->totalWidth)
+ {
+ client->errorValue = stuff->srcWidth;
+ return BadValue;
+ }
+ if ((stuff->srcY + stuff->srcHeight) > stuff->totalHeight)
+ {
+ client->errorValue = stuff->srcHeight;
+ return BadValue;
+ }
+
+ if ((((stuff->format == ZPixmap) && (stuff->srcX == 0)) ||
+ ((stuff->format != ZPixmap) &&
+ (stuff->srcX < screenInfo.bitmapScanlinePad) &&
+ ((stuff->format == XYBitmap) ||
+ ((stuff->srcY == 0) &&
+ (stuff->srcHeight == stuff->totalHeight))))) &&
+ ((stuff->srcX + stuff->srcWidth) == stuff->totalWidth))
+ (*pGC->ops->PutImage) (pDraw, pGC, stuff->depth,
+ stuff->dstX, stuff->dstY,
+ stuff->totalWidth, stuff->srcHeight,
+ stuff->srcX, stuff->format,
+ shmdesc->addr + stuff->offset +
+ (stuff->srcY * length));
+ else
+ (*shmFuncs[pDraw->pScreen->myNum]->PutImage)(
+ pDraw, pGC, stuff->depth, stuff->format,
+ stuff->totalWidth, stuff->totalHeight,
+ stuff->srcX, stuff->srcY,
+ stuff->srcWidth, stuff->srcHeight,
+ stuff->dstX, stuff->dstY,
+ shmdesc->addr + stuff->offset);
+
+ if (stuff->sendEvent)
+ {
+ xShmCompletionEvent ev;
+
+ ev.type = ShmCompletionCode;
+ ev.drawable = stuff->drawable;
+ ev.sequenceNumber = client->sequence;
+ ev.minorEvent = X_ShmPutImage;
+ ev.majorEvent = ShmReqCode;
+ ev.shmseg = stuff->shmseg;
+ ev.offset = stuff->offset;
+ WriteEventsToClient(client, 1, (xEvent *) &ev);
+ }
+
+ return (client->noClientException);
+}
+
+
+
+static int
+ProcShmGetImage(client)
+ register ClientPtr client;
+{
+ register DrawablePtr pDraw;
+ long lenPer = 0, length;
+ Mask plane = 0;
+ xShmGetImageReply xgi;
+ ShmDescPtr shmdesc;
+ int n;
+
+ REQUEST(xShmGetImageReq);
+
+ REQUEST_SIZE_MATCH(xShmGetImageReq);
+ if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap))
+ {
+ client->errorValue = stuff->format;
+ return(BadValue);
+ }
+ VERIFY_DRAWABLE(pDraw, stuff->drawable, client);
+ VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
+ if (pDraw->type == DRAWABLE_WINDOW)
+ {
+ if( /* check for being viewable */
+ !((WindowPtr) pDraw)->realized ||
+ /* check for being on screen */
+ pDraw->x + stuff->x < 0 ||
+ pDraw->x + stuff->x + (int)stuff->width > pDraw->pScreen->width ||
+ pDraw->y + stuff->y < 0 ||
+ pDraw->y + stuff->y + (int)stuff->height > pDraw->pScreen->height ||
+ /* check for being inside of border */
+ stuff->x < - wBorderWidth((WindowPtr)pDraw) ||
+ stuff->x + (int)stuff->width >
+ wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
+ stuff->y < -wBorderWidth((WindowPtr)pDraw) ||
+ stuff->y + (int)stuff->height >
+ wBorderWidth((WindowPtr)pDraw) + (int)pDraw->height
+ )
+ return(BadMatch);
+ xgi.visual = wVisual(((WindowPtr)pDraw));
+ }
+ else
+ {
+ if (stuff->x < 0 ||
+ stuff->x+(int)stuff->width > pDraw->width ||
+ stuff->y < 0 ||
+ stuff->y+(int)stuff->height > pDraw->height
+ )
+ return(BadMatch);
+ xgi.visual = None;
+ }
+ xgi.type = X_Reply;
+ xgi.length = 0;
+ xgi.sequenceNumber = client->sequence;
+ xgi.depth = pDraw->depth;
+ if(stuff->format == ZPixmap)
+ {
+ length = PixmapBytePad(stuff->width, pDraw->depth) * stuff->height;
+ }
+ else
+ {
+ lenPer = PixmapBytePad(stuff->width, 1) * stuff->height;
+ plane = ((Mask)1) << (pDraw->depth - 1);
+ /* only planes asked for */
+ length = lenPer * Ones(stuff->planeMask & (plane | (plane - 1)));
+ }
+
+ VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client);
+ xgi.size = length;
+
+ if (length == 0)
+ {
+ /* nothing to do */
+ }
+ else if (stuff->format == ZPixmap)
+ {
+ (*pDraw->pScreen->GetImage)(pDraw, stuff->x, stuff->y,
+ stuff->width, stuff->height,
+ stuff->format, stuff->planeMask,
+ shmdesc->addr + stuff->offset);
+ }
+ else
+ {
+
+ length = stuff->offset;
+ for (; plane; plane >>= 1)
+ {
+ if (stuff->planeMask & plane)
+ {
+ (*pDraw->pScreen->GetImage)(pDraw,
+ stuff->x, stuff->y,
+ stuff->width, stuff->height,
+ stuff->format, plane,
+ shmdesc->addr + length);
+ length += lenPer;
+ }
+ }
+ }
+
+ if (client->swapped) {
+ swaps(&xgi.sequenceNumber, n);
+ swapl(&xgi.length, n);
+ swapl(&xgi.visual, n);
+ swapl(&xgi.size, n);
+ }
+ WriteToClient(client, sizeof(xShmGetImageReply), (char *)&xgi);
+
+ return(client->noClientException);
+}
+
+static PixmapPtr
+fbShmCreatePixmap (pScreen, width, height, depth, addr)
+ ScreenPtr pScreen;
+ int width;
+ int height;
+ int depth;
+ char *addr;
+{
+ register PixmapPtr pPixmap;
+
+ pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, pScreen->rootDepth);
+ if (!pPixmap)
+ return NullPixmap;
+
+ if (!(*pScreen->ModifyPixmapHeader)(pPixmap, width, height, depth,
+ BitsPerPixel(depth), PixmapBytePad(width, depth), (pointer)addr)) {
+ (*pScreen->DestroyPixmap)(pPixmap);
+ return NullPixmap;
+ }
+ return pPixmap;
+}
+
+static int
+ProcShmCreatePixmap(client)
+ register ClientPtr client;
+{
+ PixmapPtr pMap;
+ register DrawablePtr pDraw;
+ DepthPtr pDepth;
+ register int i;
+ ShmDescPtr shmdesc;
+ REQUEST(xShmCreatePixmapReq);
+
+ REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
+ client->errorValue = stuff->pid;
+ if (!sharedPixmaps)
+ return BadImplementation;
+ LEGAL_NEW_RESOURCE(stuff->pid, client);
+ VERIFY_GEOMETRABLE(pDraw, stuff->drawable, client);
+ VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
+ if (!stuff->width || !stuff->height)
+ {
+ client->errorValue = 0;
+ return BadValue;
+ }
+ if (stuff->depth != 1)
+ {
+ pDepth = pDraw->pScreen->allowedDepths;
+ for (i=0; i<pDraw->pScreen->numDepths; i++, pDepth++)
+ if (pDepth->depth == stuff->depth)
+ goto CreatePmap;
+ client->errorValue = stuff->depth;
+ return BadValue;
+ }
+CreatePmap:
+ VERIFY_SHMSIZE(shmdesc, stuff->offset,
+ PixmapBytePad(stuff->width, stuff->depth) * stuff->height,
+ client);
+ pMap = (*shmFuncs[pDraw->pScreen->myNum]->CreatePixmap)(
+ pDraw->pScreen, stuff->width,
+ stuff->height, stuff->depth,
+ shmdesc->addr + stuff->offset);
+ if (pMap)
+ {
+#ifdef PIXPRIV
+ pMap->devPrivates[shmPixmapPrivate].ptr = (pointer) shmdesc;
+#endif
+ shmdesc->refcnt++;
+ pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pMap->drawable.id = stuff->pid;
+ if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap))
+ {
+ return(client->noClientException);
+ }
+ }
+ return (BadAlloc);
+}
+
+static int
+ProcShmDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_ShmQueryVersion:
+ return ProcShmQueryVersion(client);
+ case X_ShmAttach:
+ return ProcShmAttach(client);
+ case X_ShmDetach:
+ return ProcShmDetach(client);
+ case X_ShmPutImage:
+#ifdef PANORAMIX
+ if ( !noPanoramiXExtension )
+ return ProcPanoramiXShmPutImage(client);
+#endif
+ return ProcShmPutImage(client);
+ case X_ShmGetImage:
+#ifdef PANORAMIX
+ if ( !noPanoramiXExtension )
+ return ProcPanoramiXShmGetImage(client);
+#endif
+ return ProcShmGetImage(client);
+ case X_ShmCreatePixmap:
+#ifdef PANORAMIX
+ if ( !noPanoramiXExtension )
+ return ProcPanoramiXShmCreatePixmap(client);
+#endif
+ return ProcShmCreatePixmap(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static void
+SShmCompletionEvent(from, to)
+ xShmCompletionEvent *from, *to;
+{
+ to->type = from->type;
+ cpswaps(from->sequenceNumber, to->sequenceNumber);
+ cpswapl(from->drawable, to->drawable);
+ cpswaps(from->minorEvent, to->minorEvent);
+ to->majorEvent = from->majorEvent;
+ cpswapl(from->shmseg, to->shmseg);
+ cpswapl(from->offset, to->offset);
+}
+
+static int
+SProcShmQueryVersion(client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST(xShmQueryVersionReq);
+
+ swaps(&stuff->length, n);
+ return ProcShmQueryVersion(client);
+}
+
+static int
+SProcShmAttach(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xShmAttachReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xShmAttachReq);
+ swapl(&stuff->shmseg, n);
+ swapl(&stuff->shmid, n);
+ return ProcShmAttach(client);
+}
+
+static int
+SProcShmDetach(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xShmDetachReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xShmDetachReq);
+ swapl(&stuff->shmseg, n);
+ return ProcShmDetach(client);
+}
+
+static int
+SProcShmPutImage(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xShmPutImageReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xShmPutImageReq);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->totalWidth, n);
+ swaps(&stuff->totalHeight, n);
+ swaps(&stuff->srcX, n);
+ swaps(&stuff->srcY, n);
+ swaps(&stuff->srcWidth, n);
+ swaps(&stuff->srcHeight, n);
+ swaps(&stuff->dstX, n);
+ swaps(&stuff->dstY, n);
+ swapl(&stuff->shmseg, n);
+ swapl(&stuff->offset, n);
+ return ProcShmPutImage(client);
+}
+
+static int
+SProcShmGetImage(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xShmGetImageReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xShmGetImageReq);
+ swapl(&stuff->drawable, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ swapl(&stuff->planeMask, n);
+ swapl(&stuff->shmseg, n);
+ swapl(&stuff->offset, n);
+ return ProcShmGetImage(client);
+}
+
+static int
+SProcShmCreatePixmap(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xShmCreatePixmapReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
+ swapl(&stuff->pid, n);
+ swapl(&stuff->drawable, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ swapl(&stuff->shmseg, n);
+ swapl(&stuff->offset, n);
+ return ProcShmCreatePixmap(client);
+}
+
+static int
+SProcShmDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_ShmQueryVersion:
+ return SProcShmQueryVersion(client);
+ case X_ShmAttach:
+ return SProcShmAttach(client);
+ case X_ShmDetach:
+ return SProcShmDetach(client);
+ case X_ShmPutImage:
+ return SProcShmPutImage(client);
+ case X_ShmGetImage:
+ return SProcShmGetImage(client);
+ case X_ShmCreatePixmap:
+ return SProcShmCreatePixmap(client);
+ default:
+ return BadRequest;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xext/sleepuntil.c b/nx-X11/programs/Xserver/Xext/sleepuntil.c
new file mode 100644
index 000000000..8e0008cab
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/sleepuntil.c
@@ -0,0 +1,239 @@
+/*
+ * $Xorg: sleepuntil.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $
+ *
+Copyright 1992, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/programs/Xserver/Xext/sleepuntil.c,v 3.6 2003/07/16 01:38:30 dawes Exp $ */
+
+/* dixsleep.c - implement millisecond timeouts for X clients */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "sleepuntil.h"
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "misc.h"
+#include "windowstr.h"
+#include "dixstruct.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+typedef struct _Sertafied {
+ struct _Sertafied *next;
+ TimeStamp revive;
+ ClientPtr pClient;
+ XID id;
+ void (*notifyFunc)(
+ ClientPtr /* client */,
+ pointer /* closure */
+ );
+
+ pointer closure;
+} SertafiedRec, *SertafiedPtr;
+
+static SertafiedPtr pPending;
+static RESTYPE SertafiedResType;
+static Bool BlockHandlerRegistered;
+static int SertafiedGeneration;
+
+static void ClientAwaken(
+ ClientPtr /* client */,
+ pointer /* closure */
+);
+static int SertafiedDelete(
+ pointer /* value */,
+ XID /* id */
+);
+static void SertafiedBlockHandler(
+ pointer /* data */,
+ OSTimePtr /* wt */,
+ pointer /* LastSelectMask */
+);
+static void SertafiedWakeupHandler(
+ pointer /* data */,
+ int /* i */,
+ pointer /* LastSelectMask */
+);
+
+int
+ClientSleepUntil (client, revive, notifyFunc, closure)
+ ClientPtr client;
+ TimeStamp *revive;
+ void (*notifyFunc)(
+ ClientPtr /* client */,
+ pointer /* closure */);
+ pointer closure;
+{
+ SertafiedPtr pRequest, pReq, pPrev;
+
+ if (SertafiedGeneration != serverGeneration)
+ {
+ SertafiedResType = CreateNewResourceType (SertafiedDelete);
+ if (!SertafiedResType)
+ return FALSE;
+ SertafiedGeneration = serverGeneration;
+ BlockHandlerRegistered = FALSE;
+ }
+ pRequest = (SertafiedPtr) xalloc (sizeof (SertafiedRec));
+ if (!pRequest)
+ return FALSE;
+ pRequest->pClient = client;
+ pRequest->revive = *revive;
+ pRequest->id = FakeClientID (client->index);
+ pRequest->closure = closure;
+ if (!BlockHandlerRegistered)
+ {
+ if (!RegisterBlockAndWakeupHandlers (SertafiedBlockHandler,
+ SertafiedWakeupHandler,
+ (pointer) 0))
+ {
+ xfree (pRequest);
+ return FALSE;
+ }
+ BlockHandlerRegistered = TRUE;
+ }
+ pRequest->notifyFunc = 0;
+ if (!AddResource (pRequest->id, SertafiedResType, (pointer) pRequest))
+ return FALSE;
+ if (!notifyFunc)
+ notifyFunc = ClientAwaken;
+ pRequest->notifyFunc = notifyFunc;
+ /* Insert into time-ordered queue, with earliest activation time coming first. */
+ pPrev = 0;
+ for (pReq = pPending; pReq; pReq = pReq->next)
+ {
+ if (CompareTimeStamps (pReq->revive, *revive) == LATER)
+ break;
+ pPrev = pReq;
+ }
+ if (pPrev)
+ pPrev->next = pRequest;
+ else
+ pPending = pRequest;
+ pRequest->next = pReq;
+ IgnoreClient (client);
+ return TRUE;
+}
+
+static void
+ClientAwaken (client, closure)
+ ClientPtr client;
+ pointer closure;
+{
+ if (!client->clientGone)
+ AttendClient (client);
+}
+
+
+static int
+SertafiedDelete (value, id)
+ pointer value;
+ XID id;
+{
+ SertafiedPtr pRequest = (SertafiedPtr)value;
+ SertafiedPtr pReq, pPrev;
+
+ pPrev = 0;
+ for (pReq = pPending; pReq; pPrev = pReq, pReq = pReq->next)
+ if (pReq == pRequest)
+ {
+ if (pPrev)
+ pPrev->next = pReq->next;
+ else
+ pPending = pReq->next;
+ break;
+ }
+ if (pRequest->notifyFunc)
+ (*pRequest->notifyFunc) (pRequest->pClient, pRequest->closure);
+ xfree (pRequest);
+ return TRUE;
+}
+
+static void
+SertafiedBlockHandler (data, wt, LastSelectMask)
+ pointer data; /* unused */
+ OSTimePtr wt; /* wait time */
+ pointer LastSelectMask;
+{
+ SertafiedPtr pReq, pNext;
+ unsigned long delay;
+ TimeStamp now;
+
+ if (!pPending)
+ return;
+ now.milliseconds = GetTimeInMillis ();
+ now.months = currentTime.months;
+ if ((int) (now.milliseconds - currentTime.milliseconds) < 0)
+ now.months++;
+ for (pReq = pPending; pReq; pReq = pNext)
+ {
+ pNext = pReq->next;
+ if (CompareTimeStamps (pReq->revive, now) == LATER)
+ break;
+ FreeResource (pReq->id, RT_NONE);
+
+ /* AttendClient() may have been called via the resource delete
+ * function so a client may have input to be processed and so
+ * set delay to 0 to prevent blocking in WaitForSomething().
+ */
+ AdjustWaitForDelay (wt, 0);
+ }
+ pReq = pPending;
+ if (!pReq)
+ return;
+ delay = pReq->revive.milliseconds - now.milliseconds;
+ AdjustWaitForDelay (wt, delay);
+}
+
+static void
+SertafiedWakeupHandler (data, i, LastSelectMask)
+ pointer data;
+ int i;
+ pointer LastSelectMask;
+{
+ SertafiedPtr pReq, pNext;
+ TimeStamp now;
+
+ now.milliseconds = GetTimeInMillis ();
+ now.months = currentTime.months;
+ if ((int) (now.milliseconds - currentTime.milliseconds) < 0)
+ now.months++;
+ for (pReq = pPending; pReq; pReq = pNext)
+ {
+ pNext = pReq->next;
+ if (CompareTimeStamps (pReq->revive, now) == LATER)
+ break;
+ FreeResource (pReq->id, RT_NONE);
+ }
+ if (!pPending)
+ {
+ RemoveBlockAndWakeupHandlers (SertafiedBlockHandler,
+ SertafiedWakeupHandler,
+ (pointer) 0);
+ BlockHandlerRegistered = FALSE;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xext/sleepuntil.h b/nx-X11/programs/Xserver/Xext/sleepuntil.h
new file mode 100644
index 000000000..0b99148a4
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/sleepuntil.h
@@ -0,0 +1,47 @@
+/* $XFree86: xc/programs/Xserver/Xext/sleepuntil.h,v 1.2 2003/11/17 22:20:27 dawes Exp $ */
+/*
+ * Copyright (C) 2001 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _SLEEPUNTIL_H_
+#define _SLEEPUNTIL_H_ 1
+
+#include "dix.h"
+
+extern int ClientSleepUntil(
+ ClientPtr client,
+ TimeStamp *revive,
+ void (*notifyFunc)(
+ ClientPtr /* client */,
+ pointer /* closure */
+ ),
+ pointer Closure
+);
+
+#endif
diff --git a/nx-X11/programs/Xserver/Xext/sync.c b/nx-X11/programs/Xserver/Xext/sync.c
new file mode 100644
index 000000000..0e0df8305
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/sync.c
@@ -0,0 +1,2513 @@
+/* $Xorg: sync.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
+/*
+
+Copyright 1991, 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+
+Copyright 1991, 1993 by Digital Equipment Corporation, Maynard, Massachusetts,
+and Olivetti Research Limited, Cambridge, England.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Digital or Olivetti
+not be used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission. Digital and Olivetti
+make no representations about the suitability of this software
+for any purpose. It is provided "as is" without express or implied warranty.
+
+DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+
+*/
+/* $XFree86: xc/programs/Xserver/Xext/sync.c,v 3.13 2003/09/02 18:19:01 tsi Exp $ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xmd.h>
+#include "misc.h"
+#include "os.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "opaque.h"
+#define _SYNC_SERVER
+#include <X11/extensions/sync.h>
+#include <X11/extensions/syncstr.h>
+
+#ifdef EXTMODULE
+#include "xf86_ansic.h"
+#else
+#include <stdio.h>
+#if !defined(WIN32) && !defined(Lynx)
+#include <sys/time.h>
+#endif
+#endif
+
+#include "modinit.h"
+
+/*
+ * Local Global Variables
+ */
+static int SyncEventBase;
+static int SyncErrorBase;
+static RESTYPE RTCounter = 0;
+static RESTYPE RTAwait;
+static RESTYPE RTAlarm;
+static RESTYPE RTAlarmClient;
+static int SyncNumSystemCounters = 0;
+static SyncCounter **SysCounterList = NULL;
+
+#define IsSystemCounter(pCounter) \
+ (pCounter && (pCounter->client == NULL))
+
+/* these are all the alarm attributes that pertain to the alarm's trigger */
+#define XSyncCAAllTrigger \
+ (XSyncCACounter | XSyncCAValueType | XSyncCAValue | XSyncCATestType)
+
+static int
+FreeAlarm(
+ pointer /* addr */,
+ XID /* id */
+);
+
+static int
+FreeAlarmClient(
+ pointer /* value */,
+ XID /* id */
+);
+
+static int
+FreeAwait(
+ pointer /* addr */,
+ XID /* id */
+);
+
+static void
+ServertimeBracketValues(
+ pointer /* pCounter */,
+ CARD64 * /* pbracket_less */,
+ CARD64 * /* pbracket_greater */
+);
+
+static void
+ServertimeQueryValue(
+ pointer /* pCounter */,
+ CARD64 * /* pValue_return */
+);
+
+static void
+ServertimeWakeupHandler(
+ pointer /* env */,
+ int /* rc */,
+ pointer /* LastSelectMask */
+);
+
+static int
+SyncInitTrigger(
+ ClientPtr /* client */,
+ SyncTrigger * /* pTrigger */,
+ XSyncCounter /* counter */,
+ Mask /* changes */
+);
+
+static void
+SAlarmNotifyEvent(
+ xSyncAlarmNotifyEvent * /* from */,
+ xSyncAlarmNotifyEvent * /* to */
+);
+
+static void
+SCounterNotifyEvent(
+ xSyncCounterNotifyEvent * /* from */,
+ xSyncCounterNotifyEvent * /* to */
+);
+
+static void
+ServertimeBlockHandler(
+ pointer /* env */,
+ struct timeval ** /* wt */,
+ pointer /* LastSelectMask */
+);
+
+static int
+SyncAddTriggerToCounter(
+ SyncTrigger * /* pTrigger */
+);
+
+extern void
+SyncAlarmCounterDestroyed(
+ SyncTrigger * /* pTrigger */
+);
+
+static void
+SyncAlarmTriggerFired(
+ SyncTrigger * /* pTrigger */
+);
+
+static void
+SyncAwaitTriggerFired(
+ SyncTrigger * /* pTrigger */
+);
+
+static int
+SyncChangeAlarmAttributes(
+ ClientPtr /* client */,
+ SyncAlarm * /* pAlarm */,
+ Mask /* mask */,
+ CARD32 * /* values */
+);
+
+static Bool
+SyncCheckTriggerNegativeComparison(
+ SyncTrigger * /* pTrigger */,
+ CARD64 /* oldval */
+);
+
+static Bool
+SyncCheckTriggerNegativeTransition(
+ SyncTrigger * /* pTrigger */,
+ CARD64 /* oldval */
+);
+
+static Bool
+SyncCheckTriggerPositiveComparison(
+ SyncTrigger * /* pTrigger */,
+ CARD64 /* oldval */
+);
+
+static Bool
+SyncCheckTriggerPositiveTransition(
+ SyncTrigger * /* pTrigger */,
+ CARD64 /* oldval */
+);
+
+static SyncCounter *
+SyncCreateCounter(
+ ClientPtr /* client */,
+ XSyncCounter /* id */,
+ CARD64 /* initialvalue */
+);
+
+static void SyncComputeBracketValues(
+ SyncCounter * /* pCounter */,
+ Bool /* startOver */
+);
+
+static void
+SyncDeleteTriggerFromCounter(
+ SyncTrigger * /* pTrigger */
+);
+
+static Bool
+SyncEventSelectForAlarm(
+ SyncAlarm * /* pAlarm */,
+ ClientPtr /* client */,
+ Bool /* wantevents */
+);
+
+static void
+SyncInitServerTime(
+ void
+);
+
+static void
+SyncResetProc(
+ ExtensionEntry * /* extEntry */
+);
+
+static void
+SyncSendAlarmNotifyEvents(
+ SyncAlarm * /* pAlarm */
+);
+
+static void
+SyncSendCounterNotifyEvents(
+ ClientPtr /* client */,
+ SyncAwait ** /* ppAwait */,
+ int /* num_events */
+);
+
+static DISPATCH_PROC(ProcSyncAwait);
+static DISPATCH_PROC(ProcSyncChangeAlarm);
+static DISPATCH_PROC(ProcSyncChangeCounter);
+static DISPATCH_PROC(ProcSyncCreateAlarm);
+static DISPATCH_PROC(ProcSyncCreateCounter);
+static DISPATCH_PROC(ProcSyncDestroyAlarm);
+static DISPATCH_PROC(ProcSyncDestroyCounter);
+static DISPATCH_PROC(ProcSyncDispatch);
+static DISPATCH_PROC(ProcSyncGetPriority);
+static DISPATCH_PROC(ProcSyncInitialize);
+static DISPATCH_PROC(ProcSyncListSystemCounters);
+static DISPATCH_PROC(ProcSyncQueryAlarm);
+static DISPATCH_PROC(ProcSyncQueryCounter);
+static DISPATCH_PROC(ProcSyncSetCounter);
+static DISPATCH_PROC(ProcSyncSetPriority);
+static DISPATCH_PROC(SProcSyncAwait);
+static DISPATCH_PROC(SProcSyncChangeAlarm);
+static DISPATCH_PROC(SProcSyncChangeCounter);
+static DISPATCH_PROC(SProcSyncCreateAlarm);
+static DISPATCH_PROC(SProcSyncCreateCounter);
+static DISPATCH_PROC(SProcSyncDestroyAlarm);
+static DISPATCH_PROC(SProcSyncDestroyCounter);
+static DISPATCH_PROC(SProcSyncDispatch);
+static DISPATCH_PROC(SProcSyncGetPriority);
+static DISPATCH_PROC(SProcSyncInitialize);
+static DISPATCH_PROC(SProcSyncListSystemCounters);
+static DISPATCH_PROC(SProcSyncQueryAlarm);
+static DISPATCH_PROC(SProcSyncQueryCounter);
+static DISPATCH_PROC(SProcSyncSetCounter);
+static DISPATCH_PROC(SProcSyncSetPriority);
+
+/* Each counter maintains a simple linked list of triggers that are
+ * interested in the counter. The two functions below are used to
+ * delete and add triggers on this list.
+ */
+static void
+SyncDeleteTriggerFromCounter(pTrigger)
+ SyncTrigger *pTrigger;
+{
+ SyncTriggerList *pCur, *pPrev = NULL;
+
+ /* pCounter needs to be stored in pTrigger before calling here. */
+
+ if (!pTrigger->pCounter)
+ return;
+
+ for (pCur = pTrigger->pCounter->pTriglist; pCur; pCur = pCur->next)
+ {
+ if (pCur->pTrigger == pTrigger)
+ {
+ if (pPrev)
+ pPrev->next = pCur->next;
+ else
+ pTrigger->pCounter->pTriglist = pCur->next;
+ xfree(pCur);
+ break;
+ }
+ }
+
+ if (IsSystemCounter(pTrigger->pCounter))
+ SyncComputeBracketValues(pTrigger->pCounter, /*startOver*/ TRUE);
+}
+
+
+static int
+SyncAddTriggerToCounter(pTrigger)
+ SyncTrigger *pTrigger;
+{
+ SyncTriggerList *pCur;
+
+ if (!pTrigger->pCounter)
+ return Success;
+
+ /* don't do anything if it's already there */
+ for (pCur = pTrigger->pCounter->pTriglist; pCur; pCur = pCur->next)
+ {
+ if (pCur->pTrigger == pTrigger)
+ return Success;
+ }
+
+ if (!(pCur = (SyncTriggerList *)xalloc(sizeof(SyncTriggerList))))
+ return BadAlloc;
+
+ pCur->pTrigger = pTrigger;
+ pCur->next = pTrigger->pCounter->pTriglist;
+ pTrigger->pCounter->pTriglist = pCur;
+
+ if (IsSystemCounter(pTrigger->pCounter))
+ SyncComputeBracketValues(pTrigger->pCounter, /*startOver*/ TRUE);
+
+ return Success;
+}
+
+
+/* Below are four possible functions that can be plugged into
+ * pTrigger->CheckTrigger, corresponding to the four possible
+ * test-types. These functions are called after the counter's
+ * value changes but are also passed the old counter value
+ * so they can inspect both the old and new values.
+ * (PositiveTransition and NegativeTransition need to see both
+ * pieces of information.) These functions return the truth value
+ * of the trigger.
+ *
+ * All of them include the condition pTrigger->pCounter == NULL.
+ * This is because the spec says that a trigger with a counter value
+ * of None is always TRUE.
+ */
+
+static Bool
+SyncCheckTriggerPositiveComparison(pTrigger, oldval)
+ SyncTrigger *pTrigger;
+ CARD64 oldval;
+{
+ return (pTrigger->pCounter == NULL ||
+ XSyncValueGreaterOrEqual(pTrigger->pCounter->value,
+ pTrigger->test_value));
+}
+
+static Bool
+SyncCheckTriggerNegativeComparison(pTrigger, oldval)
+ SyncTrigger *pTrigger;
+ CARD64 oldval;
+{
+ return (pTrigger->pCounter == NULL ||
+ XSyncValueLessOrEqual(pTrigger->pCounter->value,
+ pTrigger->test_value));
+}
+
+static Bool
+SyncCheckTriggerPositiveTransition(pTrigger, oldval)
+ SyncTrigger *pTrigger;
+ CARD64 oldval;
+{
+ return (pTrigger->pCounter == NULL ||
+ (XSyncValueLessThan(oldval, pTrigger->test_value) &&
+ XSyncValueGreaterOrEqual(pTrigger->pCounter->value,
+ pTrigger->test_value)));
+}
+
+static Bool
+SyncCheckTriggerNegativeTransition(pTrigger, oldval)
+ SyncTrigger *pTrigger;
+ CARD64 oldval;
+{
+ return (pTrigger->pCounter == NULL ||
+ (XSyncValueGreaterThan(oldval, pTrigger->test_value) &&
+ XSyncValueLessOrEqual(pTrigger->pCounter->value,
+ pTrigger->test_value)));
+}
+
+
+
+static int
+SyncInitTrigger(client, pTrigger, counter, changes)
+ ClientPtr client; /* so we can set errorValue */
+ SyncTrigger *pTrigger;
+ XSyncCounter counter;
+ Mask changes;
+{
+ SyncCounter *pCounter = pTrigger->pCounter;
+ int status;
+ Bool newcounter = FALSE;
+
+ if (changes & XSyncCACounter)
+ {
+ if (counter == None)
+ pCounter = NULL;
+ else if (!(pCounter = (SyncCounter *)SecurityLookupIDByType(
+ client, counter, RTCounter, SecurityReadAccess)))
+ {
+ client->errorValue = counter;
+ return SyncErrorBase + XSyncBadCounter;
+ }
+ if (pCounter != pTrigger->pCounter)
+ { /* new counter for trigger */
+ SyncDeleteTriggerFromCounter(pTrigger);
+ pTrigger->pCounter = pCounter;
+ newcounter = TRUE;
+ }
+ }
+
+ /* if system counter, ask it what the current value is */
+
+ if (IsSystemCounter(pCounter))
+ {
+ (*pCounter->pSysCounterInfo->QueryValue) ((pointer) pCounter,
+ &pCounter->value);
+ }
+
+ if (changes & XSyncCAValueType)
+ {
+ if (pTrigger->value_type != XSyncRelative &&
+ pTrigger->value_type != XSyncAbsolute)
+ {
+ client->errorValue = pTrigger->value_type;
+ return BadValue;
+ }
+ }
+
+ if (changes & XSyncCATestType)
+ {
+ if (pTrigger->test_type != XSyncPositiveTransition &&
+ pTrigger->test_type != XSyncNegativeTransition &&
+ pTrigger->test_type != XSyncPositiveComparison &&
+ pTrigger->test_type != XSyncNegativeComparison)
+ {
+ client->errorValue = pTrigger->test_type;
+ return BadValue;
+ }
+ /* select appropriate CheckTrigger function */
+
+ switch (pTrigger->test_type)
+ {
+ case XSyncPositiveTransition:
+ pTrigger->CheckTrigger = SyncCheckTriggerPositiveTransition;
+ break;
+ case XSyncNegativeTransition:
+ pTrigger->CheckTrigger = SyncCheckTriggerNegativeTransition;
+ break;
+ case XSyncPositiveComparison:
+ pTrigger->CheckTrigger = SyncCheckTriggerPositiveComparison;
+ break;
+ case XSyncNegativeComparison:
+ pTrigger->CheckTrigger = SyncCheckTriggerNegativeComparison;
+ break;
+ }
+ }
+
+ if (changes & (XSyncCAValueType | XSyncCAValue))
+ {
+ if (pTrigger->value_type == XSyncAbsolute)
+ pTrigger->test_value = pTrigger->wait_value;
+ else /* relative */
+ {
+ Bool overflow;
+ if (pCounter == NULL)
+ return BadMatch;
+
+ XSyncValueAdd(&pTrigger->test_value, pCounter->value,
+ pTrigger->wait_value, &overflow);
+ if (overflow)
+ {
+ client->errorValue = XSyncValueHigh32(pTrigger->wait_value);
+ return BadValue;
+ }
+ }
+ }
+
+ /* we wait until we're sure there are no errors before registering
+ * a new counter on a trigger
+ */
+ if (newcounter)
+ {
+ if ((status = SyncAddTriggerToCounter(pTrigger)) != Success)
+ return status;
+ }
+ else if (IsSystemCounter(pCounter))
+ {
+ SyncComputeBracketValues(pCounter, /*startOver*/ TRUE);
+ }
+
+ return Success;
+}
+
+/* AlarmNotify events happen in response to actions taken on an Alarm or
+ * the counter used by the alarm. AlarmNotify may be sent to multiple
+ * clients. The alarm maintains a list of clients interested in events.
+ */
+static void
+SyncSendAlarmNotifyEvents(pAlarm)
+ SyncAlarm *pAlarm;
+{
+ SyncAlarmClientList *pcl;
+ xSyncAlarmNotifyEvent ane;
+ SyncTrigger *pTrigger = &pAlarm->trigger;
+
+ UpdateCurrentTime();
+
+ ane.type = SyncEventBase + XSyncAlarmNotify;
+ ane.kind = XSyncAlarmNotify;
+ ane.sequenceNumber = pAlarm->client->sequence;
+ ane.alarm = pAlarm->alarm_id;
+ if (pTrigger->pCounter)
+ {
+ ane.counter_value_hi = XSyncValueHigh32(pTrigger->pCounter->value);
+ ane.counter_value_lo = XSyncValueLow32(pTrigger->pCounter->value);
+ }
+ else
+ { /* XXX what else can we do if there's no counter? */
+ ane.counter_value_hi = ane.counter_value_lo = 0;
+ }
+
+ ane.alarm_value_hi = XSyncValueHigh32(pTrigger->test_value);
+ ane.alarm_value_lo = XSyncValueLow32(pTrigger->test_value);
+ ane.time = currentTime.milliseconds;
+ ane.state = pAlarm->state;
+
+ /* send to owner */
+ if (pAlarm->events && !pAlarm->client->clientGone)
+ WriteEventsToClient(pAlarm->client, 1, (xEvent *) &ane);
+
+ /* send to other interested clients */
+ for (pcl = pAlarm->pEventClients; pcl; pcl = pcl->next)
+ {
+ if (!pAlarm->client->clientGone)
+ {
+ ane.sequenceNumber = pcl->client->sequence;
+ WriteEventsToClient(pcl->client, 1, (xEvent *) &ane);
+ }
+ }
+}
+
+
+/* CounterNotify events only occur in response to an Await. The events
+ * go only to the Awaiting client.
+ */
+static void
+SyncSendCounterNotifyEvents(client, ppAwait, num_events)
+ ClientPtr client;
+ SyncAwait **ppAwait;
+ int num_events;
+{
+ xSyncCounterNotifyEvent *pEvents, *pev;
+ int i;
+
+ if (client->clientGone)
+ return;
+ pev = pEvents = (xSyncCounterNotifyEvent *)
+ ALLOCATE_LOCAL(num_events * sizeof(xSyncCounterNotifyEvent));
+ if (!pEvents)
+ return;
+ UpdateCurrentTime();
+ for (i = 0; i < num_events; i++, ppAwait++, pev++)
+ {
+ SyncTrigger *pTrigger = &(*ppAwait)->trigger;
+ pev->type = SyncEventBase + XSyncCounterNotify;
+ pev->kind = XSyncCounterNotify;
+ pev->sequenceNumber = client->sequence;
+ pev->counter = pTrigger->pCounter->id;
+ pev->wait_value_lo = XSyncValueLow32(pTrigger->test_value);
+ pev->wait_value_hi = XSyncValueHigh32(pTrigger->test_value);
+ pev->counter_value_lo = XSyncValueLow32(pTrigger->pCounter->value);
+ pev->counter_value_hi = XSyncValueHigh32(pTrigger->pCounter->value);
+ pev->time = currentTime.milliseconds;
+ pev->count = num_events - i - 1; /* events remaining */
+ pev->destroyed = pTrigger->pCounter->beingDestroyed;
+ }
+ /* swapping will be taken care of by this */
+ WriteEventsToClient(client, num_events, (xEvent *)pEvents);
+ DEALLOCATE_LOCAL(pEvents);
+}
+
+
+/* This function is called when an alarm's counter is destroyed.
+ * It is plugged into pTrigger->CounterDestroyed (for alarm triggers).
+ */
+void
+SyncAlarmCounterDestroyed(pTrigger)
+ SyncTrigger *pTrigger;
+{
+ SyncAlarm *pAlarm = (SyncAlarm *)pTrigger;
+
+ pAlarm->state = XSyncAlarmInactive;
+ SyncSendAlarmNotifyEvents(pAlarm);
+ pTrigger->pCounter = NULL;
+}
+
+
+/* This function is called when an alarm "goes off."
+ * It is plugged into pTrigger->TriggerFired (for alarm triggers).
+ */
+static void
+SyncAlarmTriggerFired(pTrigger)
+ SyncTrigger *pTrigger;
+{
+ SyncAlarm *pAlarm = (SyncAlarm *)pTrigger;
+ CARD64 new_test_value;
+
+ /* no need to check alarm unless it's active */
+ if (pAlarm->state != XSyncAlarmActive)
+ return;
+
+ /* " if the counter value is None, or if the delta is 0 and
+ * the test-type is PositiveComparison or NegativeComparison,
+ * no change is made to value (test-value) and the alarm
+ * state is changed to Inactive before the event is generated."
+ */
+ if (pAlarm->trigger.pCounter == NULL
+ || (XSyncValueIsZero(pAlarm->delta)
+ && (pAlarm->trigger.test_type == XSyncPositiveComparison
+ || pAlarm->trigger.test_type == XSyncNegativeComparison)))
+ pAlarm->state = XSyncAlarmInactive;
+
+ new_test_value = pAlarm->trigger.test_value;
+
+ if (pAlarm->state == XSyncAlarmActive)
+ {
+ Bool overflow;
+ CARD64 oldvalue;
+ SyncTrigger *paTrigger = &pAlarm->trigger;
+
+ /* "The alarm is updated by repeatedly adding delta to the
+ * value of the trigger and re-initializing it until it
+ * becomes FALSE."
+ */
+ oldvalue = paTrigger->test_value;
+
+ /* XXX really should do something smarter here */
+
+ do
+ {
+ XSyncValueAdd(&paTrigger->test_value, paTrigger->test_value,
+ pAlarm->delta, &overflow);
+ } while (!overflow &&
+ (*paTrigger->CheckTrigger)(paTrigger,
+ paTrigger->pCounter->value));
+
+ new_test_value = paTrigger->test_value;
+ paTrigger->test_value = oldvalue;
+
+ /* "If this update would cause value to fall outside the range
+ * for an INT64...no change is made to value (test-value) and
+ * the alarm state is changed to Inactive before the event is
+ * generated."
+ */
+ if (overflow)
+ {
+ new_test_value = oldvalue;
+ pAlarm->state = XSyncAlarmInactive;
+ }
+ }
+ /* The AlarmNotify event has to have the "new state of the alarm"
+ * which we can't be sure of until this point. However, it has
+ * to have the "old" trigger test value. That's the reason for
+ * all the newvalue/oldvalue shuffling above. After we send the
+ * events, give the trigger its new test value.
+ */
+ SyncSendAlarmNotifyEvents(pAlarm);
+ pTrigger->test_value = new_test_value;
+}
+
+
+/* This function is called when an Await unblocks, either as a result
+ * of the trigger firing OR the counter being destroyed.
+ * It goes into pTrigger->TriggerFired AND pTrigger->CounterDestroyed
+ * (for Await triggers).
+ */
+static void
+SyncAwaitTriggerFired(pTrigger)
+ SyncTrigger *pTrigger;
+{
+ SyncAwait *pAwait = (SyncAwait *)pTrigger;
+ int numwaits;
+ SyncAwaitUnion *pAwaitUnion;
+ SyncAwait **ppAwait;
+ int num_events = 0;
+
+ pAwaitUnion = (SyncAwaitUnion *)pAwait->pHeader;
+ numwaits = pAwaitUnion->header.num_waitconditions;
+ ppAwait = (SyncAwait **)ALLOCATE_LOCAL(numwaits * sizeof(SyncAwait *));
+ if (!ppAwait)
+ goto bail;
+
+ pAwait = &(pAwaitUnion+1)->await;
+
+ /* "When a client is unblocked, all the CounterNotify events for
+ * the Await request are generated contiguously. If count is 0
+ * there are no more events to follow for this request. If
+ * count is n, there are at least n more events to follow."
+ *
+ * Thus, it is best to find all the counters for which events
+ * need to be sent first, so that an accurate count field can
+ * be stored in the events.
+ */
+ for ( ; numwaits; numwaits--, pAwait++)
+ {
+ CARD64 diff;
+ Bool overflow, diffgreater, diffequal;
+
+ /* "A CounterNotify event with the destroyed flag set to TRUE is
+ * always generated if the counter for one of the triggers is
+ * destroyed."
+ */
+ if (pAwait->trigger.pCounter->beingDestroyed)
+ {
+ ppAwait[num_events++] = pAwait;
+ continue;
+ }
+
+ /* "The difference between the counter and the test value is
+ * calculated by subtracting the test value from the value of
+ * the counter."
+ */
+ XSyncValueSubtract(&diff, pAwait->trigger.pCounter->value,
+ pAwait->trigger.test_value, &overflow);
+
+ /* "If the difference lies outside the range for an INT64, an
+ * event is not generated."
+ */
+ if (overflow)
+ continue;
+ diffgreater = XSyncValueGreaterThan(diff, pAwait->event_threshold);
+ diffequal = XSyncValueEqual(diff, pAwait->event_threshold);
+
+ /* "If the test-type is PositiveTransition or
+ * PositiveComparison, a CounterNotify event is generated if
+ * the difference is at least event-threshold. If the test-type
+ * is NegativeTransition or NegativeComparison, a CounterNotify
+ * event is generated if the difference is at most
+ * event-threshold."
+ */
+
+ if ( ((pAwait->trigger.test_type == XSyncPositiveComparison ||
+ pAwait->trigger.test_type == XSyncPositiveTransition)
+ && (diffgreater || diffequal))
+ ||
+ ((pAwait->trigger.test_type == XSyncNegativeComparison ||
+ pAwait->trigger.test_type == XSyncNegativeTransition)
+ && (!diffgreater) /* less or equal */
+ )
+ )
+ {
+ ppAwait[num_events++] = pAwait;
+ }
+ }
+ if (num_events)
+ SyncSendCounterNotifyEvents(pAwaitUnion->header.client, ppAwait,
+ num_events);
+ DEALLOCATE_LOCAL(ppAwait);
+
+bail:
+ /* unblock the client */
+ AttendClient(pAwaitUnion->header.client);
+ /* delete the await */
+ FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
+}
+
+
+/* This function should always be used to change a counter's value so that
+ * any triggers depending on the counter will be checked.
+ */
+void
+SyncChangeCounter(pCounter, newval)
+ SyncCounter *pCounter;
+ CARD64 newval;
+{
+ SyncTriggerList *ptl, *pnext;
+ CARD64 oldval;
+
+ oldval = pCounter->value;
+ pCounter->value = newval;
+
+ /* run through triggers to see if any become true */
+ for (ptl = pCounter->pTriglist; ptl; ptl = pnext)
+ {
+ pnext = ptl->next;
+ if ((*ptl->pTrigger->CheckTrigger)(ptl->pTrigger, oldval))
+ (*ptl->pTrigger->TriggerFired)(ptl->pTrigger);
+ }
+
+ if (IsSystemCounter(pCounter))
+ {
+ SyncComputeBracketValues(pCounter, /* startOver */ FALSE);
+ }
+}
+
+
+/* loosely based on dix/events.c/EventSelectForWindow */
+static Bool
+SyncEventSelectForAlarm(pAlarm, client, wantevents)
+ SyncAlarm *pAlarm;
+ ClientPtr client;
+ Bool wantevents;
+{
+ SyncAlarmClientList *pClients;
+
+ if (client == pAlarm->client) /* alarm owner */
+ {
+ pAlarm->events = wantevents;
+ return Success;
+ }
+
+ /* see if the client is already on the list (has events selected) */
+
+ for (pClients = pAlarm->pEventClients; pClients;
+ pClients = pClients->next)
+ {
+ if (pClients->client == client)
+ {
+ /* client's presence on the list indicates desire for
+ * events. If the client doesn't want events, remove it
+ * from the list. If the client does want events, do
+ * nothing, since it's already got them.
+ */
+ if (!wantevents)
+ {
+ FreeResource(pClients->delete_id, RT_NONE);
+ }
+ return Success;
+ }
+ }
+
+ /* if we get here, this client does not currently have
+ * events selected on the alarm
+ */
+
+ if (!wantevents)
+ /* client doesn't want events, and we just discovered that it
+ * doesn't have them, so there's nothing to do.
+ */
+ return Success;
+
+ /* add new client to pAlarm->pEventClients */
+
+ pClients = (SyncAlarmClientList *) xalloc(sizeof(SyncAlarmClientList));
+ if (!pClients)
+ return BadAlloc;
+
+ /* register it as a resource so it will be cleaned up
+ * if the client dies
+ */
+
+ pClients->delete_id = FakeClientID(client->index);
+ if (!AddResource(pClients->delete_id, RTAlarmClient, pAlarm))
+ {
+ xfree(pClients);
+ return BadAlloc;
+ }
+
+ /* link it into list after we know all the allocations succeed */
+
+ pClients->next = pAlarm->pEventClients;
+ pAlarm->pEventClients = pClients;
+ pClients->client = client;
+ return Success;
+}
+
+/*
+ * ** SyncChangeAlarmAttributes ** This is used by CreateAlarm and ChangeAlarm
+ */
+static int
+SyncChangeAlarmAttributes(client, pAlarm, mask, values)
+ ClientPtr client;
+ SyncAlarm *pAlarm;
+ Mask mask;
+ CARD32 *values;
+{
+ int status;
+ XSyncCounter counter;
+ Mask origmask = mask;
+
+ counter = pAlarm->trigger.pCounter ? pAlarm->trigger.pCounter->id : None;
+
+ while (mask)
+ {
+ int index2 = lowbit(mask);
+ mask &= ~index2;
+ switch (index2)
+ {
+ case XSyncCACounter:
+ mask &= ~XSyncCACounter;
+ /* sanity check in SyncInitTrigger */
+ counter = *values++;
+ break;
+
+ case XSyncCAValueType:
+ mask &= ~XSyncCAValueType;
+ /* sanity check in SyncInitTrigger */
+ pAlarm->trigger.value_type = *values++;
+ break;
+
+ case XSyncCAValue:
+ mask &= ~XSyncCAValue;
+ XSyncIntsToValue(&pAlarm->trigger.wait_value, values[1], values[0]);
+ values += 2;
+ break;
+
+ case XSyncCATestType:
+ mask &= ~XSyncCATestType;
+ /* sanity check in SyncInitTrigger */
+ pAlarm->trigger.test_type = *values++;
+ break;
+
+ case XSyncCADelta:
+ mask &= ~XSyncCADelta;
+ XSyncIntsToValue(&pAlarm->delta, values[1], values[0]);
+ values += 2;
+ break;
+
+ case XSyncCAEvents:
+ mask &= ~XSyncCAEvents;
+ if ((*values != xTrue) && (*values != xFalse))
+ {
+ client->errorValue = *values;
+ return BadValue;
+ }
+ status = SyncEventSelectForAlarm(pAlarm, client,
+ (Bool)(*values++));
+ if (status != Success)
+ return status;
+ break;
+
+ default:
+ client->errorValue = mask;
+ return BadValue;
+ }
+ }
+
+ /* "If the test-type is PositiveComparison or PositiveTransition
+ * and delta is less than zero, or if the test-type is
+ * NegativeComparison or NegativeTransition and delta is
+ * greater than zero, a Match error is generated."
+ */
+ if (origmask & (XSyncCADelta|XSyncCATestType))
+ {
+ CARD64 zero;
+ XSyncIntToValue(&zero, 0);
+ if ((((pAlarm->trigger.test_type == XSyncPositiveComparison) ||
+ (pAlarm->trigger.test_type == XSyncPositiveTransition))
+ && XSyncValueLessThan(pAlarm->delta, zero))
+ ||
+ (((pAlarm->trigger.test_type == XSyncNegativeComparison) ||
+ (pAlarm->trigger.test_type == XSyncNegativeTransition))
+ && XSyncValueGreaterThan(pAlarm->delta, zero))
+ )
+ {
+ return BadMatch;
+ }
+ }
+
+ /* postpone this until now, when we're sure nothing else can go wrong */
+ if ((status = SyncInitTrigger(client, &pAlarm->trigger, counter,
+ origmask & XSyncCAAllTrigger)) != Success)
+ return status;
+
+ /* XXX spec does not really say to do this - needs clarification */
+ pAlarm->state = XSyncAlarmActive;
+ return Success;
+}
+
+
+static SyncCounter *
+SyncCreateCounter(client, id, initialvalue)
+ ClientPtr client;
+ XSyncCounter id;
+ CARD64 initialvalue;
+{
+ SyncCounter *pCounter;
+
+ if (!(pCounter = (SyncCounter *) xalloc(sizeof(SyncCounter))))
+ return (SyncCounter *)NULL;
+
+ if (!AddResource(id, RTCounter, (pointer) pCounter))
+ {
+ xfree((pointer) pCounter);
+ return (SyncCounter *)NULL;
+ }
+
+ pCounter->client = client;
+ pCounter->id = id;
+ pCounter->value = initialvalue;
+ pCounter->pTriglist = NULL;
+ pCounter->beingDestroyed = FALSE;
+ pCounter->pSysCounterInfo = NULL;
+ return pCounter;
+}
+
+static int FreeCounter(
+ pointer /*env*/,
+ XID /*id*/
+);
+
+/*
+ * ***** System Counter utilities
+ */
+
+pointer
+SyncCreateSystemCounter(name, initial, resolution, counterType,
+ QueryValue, BracketValues)
+ char *name;
+ CARD64 initial;
+ CARD64 resolution;
+ SyncCounterType counterType;
+ void (*QueryValue) (
+ pointer /* pCounter */,
+ CARD64 * /* pValue_return */);
+ void (*BracketValues) (
+ pointer /* pCounter */,
+ CARD64 * /* pbracket_less */,
+ CARD64 * /* pbracket_greater */);
+{
+ SyncCounter *pCounter;
+
+ SysCounterList = (SyncCounter **)xrealloc(SysCounterList,
+ (SyncNumSystemCounters+1)*sizeof(SyncCounter *));
+ if (!SysCounterList)
+ return (pointer)NULL;
+
+ /* this function may be called before SYNC has been initialized, so we
+ * have to make sure RTCounter is created.
+ */
+ if (RTCounter == 0)
+ {
+ RTCounter = CreateNewResourceType(FreeCounter);
+ if (RTCounter == 0)
+ {
+ return (pointer)NULL;
+ }
+ }
+
+ pCounter = SyncCreateCounter((ClientPtr)NULL, FakeClientID(0), initial);
+
+ if (pCounter)
+ {
+ SysCounterInfo *psci;
+
+ psci = (SysCounterInfo *)xalloc(sizeof(SysCounterInfo));
+ if (!psci)
+ {
+ FreeResource(pCounter->id, RT_NONE);
+ return (pointer) pCounter;
+ }
+ pCounter->pSysCounterInfo = psci;
+ psci->name = name;
+ psci->resolution = resolution;
+ psci->counterType = counterType;
+ psci->QueryValue = QueryValue;
+ psci->BracketValues = BracketValues;
+ XSyncMaxValue(&psci->bracket_greater);
+ XSyncMinValue(&psci->bracket_less);
+ SysCounterList[SyncNumSystemCounters++] = pCounter;
+ }
+ return (pointer) pCounter;
+}
+
+void
+SyncDestroySystemCounter(pSysCounter)
+ pointer pSysCounter;
+{
+ SyncCounter *pCounter = (SyncCounter *)pSysCounter;
+ FreeResource(pCounter->id, RT_NONE);
+}
+
+static void
+SyncComputeBracketValues(pCounter, startOver)
+ SyncCounter *pCounter;
+ Bool startOver;
+{
+ SyncTriggerList *pCur;
+ SyncTrigger *pTrigger;
+ SysCounterInfo *psci = pCounter->pSysCounterInfo;
+ CARD64 *pnewgtval = NULL;
+ CARD64 *pnewltval = NULL;
+ SyncCounterType ct;
+
+ if (!pCounter)
+ return;
+
+ ct = pCounter->pSysCounterInfo->counterType;
+ if (ct == XSyncCounterNeverChanges)
+ return;
+
+ if (startOver)
+ {
+ XSyncMaxValue(&psci->bracket_greater);
+ XSyncMinValue(&psci->bracket_less);
+ }
+
+ for (pCur = pCounter->pTriglist; pCur; pCur = pCur->next)
+ {
+ pTrigger = pCur->pTrigger;
+
+ if (pTrigger->test_type == XSyncPositiveComparison &&
+ ct != XSyncCounterNeverIncreases)
+ {
+ if (XSyncValueLessThan(pCounter->value, pTrigger->test_value) &&
+ XSyncValueLessThan(pTrigger->test_value,
+ psci->bracket_greater))
+ {
+ psci->bracket_greater = pTrigger->test_value;
+ pnewgtval = &psci->bracket_greater;
+ }
+ }
+ else if (pTrigger->test_type == XSyncNegativeComparison &&
+ ct != XSyncCounterNeverDecreases)
+ {
+ if (XSyncValueGreaterThan(pCounter->value, pTrigger->test_value) &&
+ XSyncValueGreaterThan(pTrigger->test_value,
+ psci->bracket_less))
+ {
+ psci->bracket_less = pTrigger->test_value;
+ pnewltval = &psci->bracket_less;
+ }
+ }
+ else if ( (pTrigger->test_type == XSyncPositiveTransition &&
+ ct != XSyncCounterNeverIncreases)
+ ||
+ (pTrigger->test_type == XSyncNegativeTransition &&
+ ct != XSyncCounterNeverDecreases)
+ )
+ {
+ if (XSyncValueLessThan(pCounter->value, pTrigger->test_value))
+ {
+ if (XSyncValueLessThan(pTrigger->test_value,
+ psci->bracket_greater))
+ {
+ psci->bracket_greater = pTrigger->test_value;
+ pnewgtval = &psci->bracket_greater;
+ }
+ else
+ if (XSyncValueGreaterThan(pTrigger->test_value,
+ psci->bracket_less))
+ {
+ psci->bracket_less = pTrigger->test_value;
+ pnewltval = &psci->bracket_less;
+ }
+ }
+ }
+ } /* end for each trigger */
+
+ if (pnewgtval || pnewltval)
+ {
+ (*psci->BracketValues)((pointer)pCounter, pnewltval, pnewgtval);
+ }
+}
+
+/*
+ * ***** Resource delete functions
+ */
+
+/* ARGSUSED */
+static int
+FreeAlarm(addr, id)
+ pointer addr;
+ XID id;
+{
+ SyncAlarm *pAlarm = (SyncAlarm *) addr;
+
+ pAlarm->state = XSyncAlarmDestroyed;
+
+ SyncSendAlarmNotifyEvents(pAlarm);
+
+ /* delete event selections */
+
+ while (pAlarm->pEventClients)
+ FreeResource(pAlarm->pEventClients->delete_id, RT_NONE);
+
+ SyncDeleteTriggerFromCounter(&pAlarm->trigger);
+
+ xfree(pAlarm);
+ return Success;
+}
+
+
+/*
+ * ** Cleanup after the destruction of a Counter
+ */
+/* ARGSUSED */
+static int
+FreeCounter(env, id)
+ pointer env;
+ XID id;
+{
+ SyncCounter *pCounter = (SyncCounter *) env;
+ SyncTriggerList *ptl, *pnext;
+
+ pCounter->beingDestroyed = TRUE;
+ /* tell all the counter's triggers that the counter has been destroyed */
+ for (ptl = pCounter->pTriglist; ptl; ptl = pnext)
+ {
+ (*ptl->pTrigger->CounterDestroyed)(ptl->pTrigger);
+ pnext = ptl->next;
+ xfree(ptl); /* destroy the trigger list as we go */
+ }
+ if (IsSystemCounter(pCounter))
+ {
+ int i, found = 0;
+
+ xfree(pCounter->pSysCounterInfo);
+
+ /* find the counter in the list of system counters and remove it */
+
+ if (SysCounterList)
+ {
+ for (i = 0; i < SyncNumSystemCounters; i++)
+ {
+ if (SysCounterList[i] == pCounter)
+ {
+ found = i;
+ break;
+ }
+ }
+ if (found < (SyncNumSystemCounters-1))
+ {
+ for (i = found; i < SyncNumSystemCounters-1; i++)
+ {
+ SysCounterList[i] = SysCounterList[i+1];
+ }
+ }
+ }
+ SyncNumSystemCounters--;
+ }
+ xfree(pCounter);
+ return Success;
+}
+
+/*
+ * ** Cleanup after Await
+ */
+/* ARGSUSED */
+static int
+FreeAwait(addr, id)
+ pointer addr;
+ XID id;
+{
+ SyncAwaitUnion *pAwaitUnion = (SyncAwaitUnion *) addr;
+ SyncAwait *pAwait;
+ int numwaits;
+
+ pAwait = &(pAwaitUnion+1)->await; /* first await on list */
+
+ /* remove triggers from counters */
+
+ for (numwaits = pAwaitUnion->header.num_waitconditions; numwaits;
+ numwaits--, pAwait++)
+ {
+ /* If the counter is being destroyed, FreeCounter will delete
+ * the trigger list itself, so don't do it here.
+ */
+ SyncCounter *pCounter = pAwait->trigger.pCounter;
+ if (pCounter && !pCounter->beingDestroyed)
+ SyncDeleteTriggerFromCounter(&pAwait->trigger);
+ }
+ xfree(pAwaitUnion);
+ return Success;
+}
+
+/* loosely based on dix/events.c/OtherClientGone */
+static int
+FreeAlarmClient(value, id)
+ pointer value; /* must conform to DeleteType */
+ XID id;
+{
+ SyncAlarm *pAlarm = (SyncAlarm *)value;
+ SyncAlarmClientList *pCur, *pPrev;
+
+ for (pPrev = NULL, pCur = pAlarm->pEventClients;
+ pCur;
+ pPrev = pCur, pCur = pCur->next)
+ {
+ if (pCur->delete_id == id)
+ {
+ if (pPrev)
+ pPrev->next = pCur->next;
+ else
+ pAlarm->pEventClients = pCur->next;
+ xfree(pCur);
+ return(Success);
+ }
+ }
+ FatalError("alarm client not on event list");
+ /*NOTREACHED*/
+}
+
+
+/*
+ * ***** Proc functions
+ */
+
+
+/*
+ * ** Initialize the extension
+ */
+static int
+ProcSyncInitialize(client)
+ ClientPtr client;
+{
+ xSyncInitializeReply rep;
+ int n;
+
+ REQUEST_SIZE_MATCH(xSyncInitializeReq);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = SYNC_MAJOR_VERSION;
+ rep.minorVersion = SYNC_MINOR_VERSION;
+ rep.length = 0;
+
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ }
+ WriteToClient(client, sizeof(rep), (char *) &rep);
+ return (client->noClientException);
+}
+
+/*
+ * ** Get list of system counters available through the extension
+ */
+static int
+ProcSyncListSystemCounters(client)
+ ClientPtr client;
+{
+ xSyncListSystemCountersReply rep;
+ int i, len;
+ xSyncSystemCounter *list = NULL, *walklist = NULL;
+
+ REQUEST_SIZE_MATCH(xSyncListSystemCountersReq);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.nCounters = SyncNumSystemCounters;
+
+ for (i = len = 0; i < SyncNumSystemCounters; i++)
+ {
+ char *name = SysCounterList[i]->pSysCounterInfo->name;
+ /* pad to 4 byte boundary */
+ len += (sz_xSyncSystemCounter + strlen(name) + 3) & ~3;
+ }
+
+ if (len)
+ {
+ walklist = list = (xSyncSystemCounter *) ALLOCATE_LOCAL(len);
+ if (!list)
+ return BadAlloc;
+ }
+
+ rep.length = len >> 2;
+
+ if (client->swapped)
+ {
+ register char n;
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.nCounters, n);
+ }
+
+ for (i = 0; i < SyncNumSystemCounters; i++)
+ {
+ int namelen;
+ char *pname_in_reply;
+ SysCounterInfo *psci = SysCounterList[i]->pSysCounterInfo;
+
+ walklist->counter = SysCounterList[i]->id;
+ walklist->resolution_hi = XSyncValueHigh32(psci->resolution);
+ walklist->resolution_lo = XSyncValueLow32(psci->resolution);
+ namelen = strlen(psci->name);
+ walklist->name_length = namelen;
+
+ if (client->swapped)
+ {
+ register char n;
+ swapl(&walklist->counter, n);
+ swapl(&walklist->resolution_hi, n);
+ swapl(&walklist->resolution_lo, n);
+ swaps(&walklist->name_length, n);
+ }
+
+ pname_in_reply = ((char *)walklist) + sz_xSyncSystemCounter;
+ strncpy(pname_in_reply, psci->name, namelen);
+ walklist = (xSyncSystemCounter *) (((char *)walklist) +
+ ((sz_xSyncSystemCounter + namelen + 3) & ~3));
+ }
+
+ WriteToClient(client, sizeof(rep), (char *) &rep);
+ if (len)
+ {
+ WriteToClient(client, len, (char *) list);
+ DEALLOCATE_LOCAL(list);
+ }
+
+ return (client->noClientException);
+}
+
+/*
+ * ** Set client Priority
+ */
+static int
+ProcSyncSetPriority(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncSetPriorityReq);
+ ClientPtr priorityclient;
+
+ REQUEST_SIZE_MATCH(xSyncSetPriorityReq);
+
+ if (stuff->id == None)
+ priorityclient = client;
+ else if (!(priorityclient = LookupClient(stuff->id, client)))
+ {
+ client->errorValue = stuff->id;
+ return BadMatch;
+ }
+
+ if (priorityclient->priority != stuff->priority)
+ {
+ priorityclient->priority = stuff->priority;
+
+ /* The following will force the server back into WaitForSomething
+ * so that the change in this client's priority is immediately
+ * reflected.
+ */
+ isItTimeToYield = TRUE;
+ dispatchException |= DE_PRIORITYCHANGE;
+ }
+ return Success;
+}
+
+/*
+ * ** Get client Priority
+ */
+static int
+ProcSyncGetPriority(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncGetPriorityReq);
+ xSyncGetPriorityReply rep;
+ ClientPtr priorityclient;
+
+ REQUEST_SIZE_MATCH(xSyncGetPriorityReq);
+
+ if (stuff->id == None)
+ priorityclient = client;
+ else if (!(priorityclient = LookupClient(stuff->id, client)))
+ {
+ client->errorValue = stuff->id;
+ return BadMatch;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.priority = priorityclient->priority;
+
+ if (client->swapped)
+ {
+ register char n;
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.priority, n);
+ }
+
+ WriteToClient(client, sizeof(xSyncGetPriorityReply), (char *) &rep);
+
+ return (client->noClientException);
+}
+
+/*
+ * ** Create a new counter
+ */
+static int
+ProcSyncCreateCounter(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncCreateCounterReq);
+ CARD64 initial;
+
+ REQUEST_SIZE_MATCH(xSyncCreateCounterReq);
+
+ LEGAL_NEW_RESOURCE(stuff->cid, client);
+
+ XSyncIntsToValue(&initial, stuff->initial_value_lo, stuff->initial_value_hi);
+ if (!SyncCreateCounter(client, stuff->cid, initial))
+ return BadAlloc;
+
+ return (client->noClientException);
+}
+
+/*
+ * ** Set Counter value
+ */
+static int
+ProcSyncSetCounter(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncSetCounterReq);
+ SyncCounter *pCounter;
+ CARD64 newvalue;
+
+ REQUEST_SIZE_MATCH(xSyncSetCounterReq);
+
+ pCounter = (SyncCounter *)SecurityLookupIDByType(client, stuff->cid,
+ RTCounter, SecurityWriteAccess);
+ if (pCounter == NULL)
+ {
+ client->errorValue = stuff->cid;
+ return SyncErrorBase + XSyncBadCounter;
+ }
+
+ if (IsSystemCounter(pCounter))
+ {
+ client->errorValue = stuff->cid;
+ return BadAccess;
+ }
+
+ XSyncIntsToValue(&newvalue, stuff->value_lo, stuff->value_hi);
+ SyncChangeCounter(pCounter, newvalue);
+ return Success;
+}
+
+/*
+ * ** Change Counter value
+ */
+static int
+ProcSyncChangeCounter(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncChangeCounterReq);
+ SyncCounter *pCounter;
+ CARD64 newvalue;
+ Bool overflow;
+
+ REQUEST_SIZE_MATCH(xSyncChangeCounterReq);
+
+ pCounter = (SyncCounter *) SecurityLookupIDByType(client, stuff->cid,
+ RTCounter, SecurityWriteAccess);
+ if (pCounter == NULL)
+ {
+ client->errorValue = stuff->cid;
+ return SyncErrorBase + XSyncBadCounter;
+ }
+
+ if (IsSystemCounter(pCounter))
+ {
+ client->errorValue = stuff->cid;
+ return BadAccess;
+ }
+
+ XSyncIntsToValue(&newvalue, stuff->value_lo, stuff->value_hi);
+ XSyncValueAdd(&newvalue, pCounter->value, newvalue, &overflow);
+ if (overflow)
+ {
+ /* XXX 64 bit value can't fit in 32 bits; do the best we can */
+ client->errorValue = stuff->value_hi;
+ return BadValue;
+ }
+ SyncChangeCounter(pCounter, newvalue);
+ return Success;
+}
+
+/*
+ * ** Destroy a counter
+ */
+static int
+ProcSyncDestroyCounter(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncDestroyCounterReq);
+ SyncCounter *pCounter;
+
+ REQUEST_SIZE_MATCH(xSyncDestroyCounterReq);
+
+ pCounter = (SyncCounter *)SecurityLookupIDByType(client, stuff->counter,
+ RTCounter, SecurityDestroyAccess);
+ if (pCounter == NULL)
+ {
+ client->errorValue = stuff->counter;
+ return SyncErrorBase + XSyncBadCounter;
+ }
+ if (IsSystemCounter(pCounter))
+ {
+ client->errorValue = stuff->counter;
+ return BadAccess;
+ }
+ FreeResource(pCounter->id, RT_NONE);
+ return Success;
+}
+
+
+/*
+ * ** Await
+ */
+static int
+ProcSyncAwait(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncAwaitReq);
+ int len, items;
+ int i;
+ xSyncWaitCondition *pProtocolWaitConds;
+ SyncAwaitUnion *pAwaitUnion;
+ SyncAwait *pAwait;
+ int status;
+
+ REQUEST_AT_LEAST_SIZE(xSyncAwaitReq);
+
+ len = client->req_len << 2;
+ len -= sz_xSyncAwaitReq;
+ items = len / sz_xSyncWaitCondition;
+
+ if (items * sz_xSyncWaitCondition != len)
+ {
+ return BadLength;
+ }
+ if (items == 0)
+ {
+ client->errorValue = items; /* XXX protocol change */
+ return BadValue;
+ }
+
+ pProtocolWaitConds = (xSyncWaitCondition *) & stuff[1];
+
+ /* all the memory for the entire await list is allocated
+ * here in one chunk
+ */
+ pAwaitUnion = (SyncAwaitUnion *)xalloc((items+1) * sizeof(SyncAwaitUnion));
+ if (!pAwaitUnion)
+ return BadAlloc;
+
+ /* first item is the header, remainder are real wait conditions */
+
+ pAwaitUnion->header.delete_id = FakeClientID(client->index);
+ if (!AddResource(pAwaitUnion->header.delete_id, RTAwait, pAwaitUnion))
+ {
+ xfree(pAwaitUnion);
+ return BadAlloc;
+ }
+
+ /* don't need to do any more memory allocation for this request! */
+
+ pAwaitUnion->header.client = client;
+ pAwaitUnion->header.num_waitconditions = 0;
+
+ pAwait = &(pAwaitUnion+1)->await; /* skip over header */
+ for (i = 0; i < items; i++, pProtocolWaitConds++, pAwait++)
+ {
+ if (pProtocolWaitConds->counter == None) /* XXX protocol change */
+ {
+ /* this should take care of removing any triggers created by
+ * this request that have already been registered on counters
+ */
+ FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
+ client->errorValue = pProtocolWaitConds->counter;
+ return SyncErrorBase + XSyncBadCounter;
+ }
+
+ /* sanity checks are in SyncInitTrigger */
+ pAwait->trigger.pCounter = NULL;
+ pAwait->trigger.value_type = pProtocolWaitConds->value_type;
+ XSyncIntsToValue(&pAwait->trigger.wait_value,
+ pProtocolWaitConds->wait_value_lo,
+ pProtocolWaitConds->wait_value_hi);
+ pAwait->trigger.test_type = pProtocolWaitConds->test_type;
+
+ status = SyncInitTrigger(client, &pAwait->trigger,
+ pProtocolWaitConds->counter, XSyncCAAllTrigger);
+ if (status != Success)
+ {
+ /* this should take care of removing any triggers created by
+ * this request that have already been registered on counters
+ */
+ FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
+ return status;
+ }
+ /* this is not a mistake -- same function works for both cases */
+ pAwait->trigger.TriggerFired = SyncAwaitTriggerFired;
+ pAwait->trigger.CounterDestroyed = SyncAwaitTriggerFired;
+ XSyncIntsToValue(&pAwait->event_threshold,
+ pProtocolWaitConds->event_threshold_lo,
+ pProtocolWaitConds->event_threshold_hi);
+ pAwait->pHeader = &pAwaitUnion->header;
+ pAwaitUnion->header.num_waitconditions++;
+ }
+
+ IgnoreClient(client);
+
+ /* see if any of the triggers are already true */
+
+ pAwait = &(pAwaitUnion+1)->await; /* skip over header */
+ for (i = 0; i < items; i++, pAwait++)
+ {
+ /* don't have to worry about NULL counters because the request
+ * errors before we get here out if they occur
+ */
+ if ((*pAwait->trigger.CheckTrigger)(&pAwait->trigger,
+ pAwait->trigger.pCounter->value))
+ {
+ (*pAwait->trigger.TriggerFired)(&pAwait->trigger);
+ break; /* once is enough */
+ }
+ }
+ return Success;
+}
+
+
+/*
+ * ** Query a counter
+ */
+static int
+ProcSyncQueryCounter(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncQueryCounterReq);
+ xSyncQueryCounterReply rep;
+ SyncCounter *pCounter;
+
+ REQUEST_SIZE_MATCH(xSyncQueryCounterReq);
+
+ pCounter = (SyncCounter *)SecurityLookupIDByType(client, stuff->counter,
+ RTCounter, SecurityReadAccess);
+ if (pCounter == NULL)
+ {
+ client->errorValue = stuff->counter;
+ return SyncErrorBase + XSyncBadCounter;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ /* if system counter, ask it what the current value is */
+
+ if (IsSystemCounter(pCounter))
+ {
+ (*pCounter->pSysCounterInfo->QueryValue) ((pointer) pCounter,
+ &pCounter->value);
+ }
+
+ rep.value_hi = XSyncValueHigh32(pCounter->value);
+ rep.value_lo = XSyncValueLow32(pCounter->value);
+ if (client->swapped)
+ {
+ register char n;
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.value_hi, n);
+ swapl(&rep.value_lo, n);
+ }
+ WriteToClient(client, sizeof(xSyncQueryCounterReply), (char *) &rep);
+ return (client->noClientException);
+}
+
+
+/*
+ * ** Create Alarm
+ */
+static int
+ProcSyncCreateAlarm(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncCreateAlarmReq);
+ SyncAlarm *pAlarm;
+ int status;
+ unsigned long len, vmask;
+ SyncTrigger *pTrigger;
+
+ REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq);
+
+ LEGAL_NEW_RESOURCE(stuff->id, client);
+
+ vmask = stuff->valueMask;
+ len = client->req_len - (sizeof(xSyncCreateAlarmReq) >> 2);
+ /* the "extra" call to Ones accounts for the presence of 64 bit values */
+ if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta))))
+ return BadLength;
+
+ if (!(pAlarm = (SyncAlarm *) xalloc(sizeof(SyncAlarm))))
+ {
+ return BadAlloc;
+ }
+
+ /* set up defaults */
+
+ pTrigger = &pAlarm->trigger;
+ pTrigger->pCounter = NULL;
+ pTrigger->value_type = XSyncAbsolute;
+ XSyncIntToValue(&pTrigger->wait_value, 0L);
+ pTrigger->test_type = XSyncPositiveComparison;
+ pTrigger->TriggerFired = SyncAlarmTriggerFired;
+ pTrigger->CounterDestroyed = SyncAlarmCounterDestroyed;
+ status = SyncInitTrigger(client, pTrigger, None, XSyncCAAllTrigger);
+ if (status != Success)
+ {
+ xfree(pAlarm);
+ return status;
+ }
+
+ pAlarm->client = client;
+ pAlarm->alarm_id = stuff->id;
+ XSyncIntToValue(&pAlarm->delta, 1L);
+ pAlarm->events = TRUE;
+ pAlarm->state = XSyncAlarmInactive;
+ pAlarm->pEventClients = NULL;
+ status = SyncChangeAlarmAttributes(client, pAlarm, vmask,
+ (CARD32 *)&stuff[1]);
+ if (status != Success)
+ {
+ xfree(pAlarm);
+ return status;
+ }
+
+ if (!AddResource(stuff->id, RTAlarm, pAlarm))
+ {
+ xfree(pAlarm);
+ return BadAlloc;
+ }
+
+ /* see if alarm already triggered. NULL counter will not trigger
+ * in CreateAlarm and sets alarm state to Inactive.
+ */
+
+ if (!pTrigger->pCounter)
+ {
+ pAlarm->state = XSyncAlarmInactive; /* XXX protocol change */
+ }
+ else if ((*pTrigger->CheckTrigger)(pTrigger, pTrigger->pCounter->value))
+ {
+ (*pTrigger->TriggerFired)(pTrigger);
+ }
+
+ return Success;
+}
+
+/*
+ * ** Change Alarm
+ */
+static int
+ProcSyncChangeAlarm(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncChangeAlarmReq);
+ SyncAlarm *pAlarm;
+ long vmask;
+ int len, status;
+
+ REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq);
+
+ if (!(pAlarm = (SyncAlarm *)SecurityLookupIDByType(client, stuff->alarm,
+ RTAlarm, SecurityWriteAccess)))
+ {
+ client->errorValue = stuff->alarm;
+ return SyncErrorBase + XSyncBadAlarm;
+ }
+
+ vmask = stuff->valueMask;
+ len = client->req_len - (sizeof(xSyncChangeAlarmReq) >> 2);
+ /* the "extra" call to Ones accounts for the presence of 64 bit values */
+ if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta))))
+ return BadLength;
+
+ if ((status = SyncChangeAlarmAttributes(client, pAlarm, vmask,
+ (CARD32 *)&stuff[1])) != Success)
+ return status;
+
+ /* see if alarm already triggered. NULL counter WILL trigger
+ * in ChangeAlarm.
+ */
+
+ if (!pAlarm->trigger.pCounter ||
+ (*pAlarm->trigger.CheckTrigger)(&pAlarm->trigger,
+ pAlarm->trigger.pCounter->value))
+ {
+ (*pAlarm->trigger.TriggerFired)(&pAlarm->trigger);
+ }
+ return Success;
+}
+
+static int
+ProcSyncQueryAlarm(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncQueryAlarmReq);
+ SyncAlarm *pAlarm;
+ xSyncQueryAlarmReply rep;
+ SyncTrigger *pTrigger;
+
+ REQUEST_SIZE_MATCH(xSyncQueryAlarmReq);
+
+ pAlarm = (SyncAlarm *)SecurityLookupIDByType(client, stuff->alarm,
+ RTAlarm, SecurityReadAccess);
+ if (!pAlarm)
+ {
+ client->errorValue = stuff->alarm;
+ return (SyncErrorBase + XSyncBadAlarm);
+ }
+
+ rep.type = X_Reply;
+ rep.length = (sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply)) >> 2;
+ rep.sequenceNumber = client->sequence;
+
+ pTrigger = &pAlarm->trigger;
+ rep.counter = (pTrigger->pCounter) ? pTrigger->pCounter->id : None;
+
+#if 0 /* XXX unclear what to do, depends on whether relative value-types
+ * are "consumed" immediately and are considered absolute from then
+ * on.
+ */
+ rep.value_type = pTrigger->value_type;
+ rep.wait_value_hi = XSyncValueHigh32(pTrigger->wait_value);
+ rep.wait_value_lo = XSyncValueLow32(pTrigger->wait_value);
+#else
+ rep.value_type = XSyncAbsolute;
+ rep.wait_value_hi = XSyncValueHigh32(pTrigger->test_value);
+ rep.wait_value_lo = XSyncValueLow32(pTrigger->test_value);
+#endif
+
+ rep.test_type = pTrigger->test_type;
+ rep.delta_hi = XSyncValueHigh32(pAlarm->delta);
+ rep.delta_lo = XSyncValueLow32(pAlarm->delta);
+ rep.events = pAlarm->events;
+ rep.state = pAlarm->state;
+
+ if (client->swapped)
+ {
+ register char n;
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.counter, n);
+ swapl(&rep.wait_value_hi, n);
+ swapl(&rep.wait_value_lo, n);
+ swapl(&rep.test_type, n);
+ swapl(&rep.delta_hi, n);
+ swapl(&rep.delta_lo, n);
+ }
+
+ WriteToClient(client, sizeof(xSyncQueryAlarmReply), (char *) &rep);
+ return (client->noClientException);
+}
+
+
+static int
+ProcSyncDestroyAlarm(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncDestroyAlarmReq);
+
+ REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq);
+
+ if (!((SyncAlarm *)SecurityLookupIDByType(client, stuff->alarm,
+ RTAlarm, SecurityDestroyAccess)))
+ {
+ client->errorValue = stuff->alarm;
+ return SyncErrorBase + XSyncBadAlarm;
+ }
+
+ FreeResource(stuff->alarm, RT_NONE);
+ return (client->noClientException);
+}
+
+/*
+ * ** Given an extension request, call the appropriate request procedure
+ */
+static int
+ProcSyncDispatch(client)
+ ClientPtr client;
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+
+ case X_SyncInitialize:
+ return ProcSyncInitialize(client);
+ case X_SyncListSystemCounters:
+ return ProcSyncListSystemCounters(client);
+ case X_SyncCreateCounter:
+ return ProcSyncCreateCounter(client);
+ case X_SyncSetCounter:
+ return ProcSyncSetCounter(client);
+ case X_SyncChangeCounter:
+ return ProcSyncChangeCounter(client);
+ case X_SyncQueryCounter:
+ return ProcSyncQueryCounter(client);
+ case X_SyncDestroyCounter:
+ return ProcSyncDestroyCounter(client);
+ case X_SyncAwait:
+ return ProcSyncAwait(client);
+ case X_SyncCreateAlarm:
+ return ProcSyncCreateAlarm(client);
+ case X_SyncChangeAlarm:
+ return ProcSyncChangeAlarm(client);
+ case X_SyncQueryAlarm:
+ return ProcSyncQueryAlarm(client);
+ case X_SyncDestroyAlarm:
+ return ProcSyncDestroyAlarm(client);
+ case X_SyncSetPriority:
+ return ProcSyncSetPriority(client);
+ case X_SyncGetPriority:
+ return ProcSyncGetPriority(client);
+ default:
+ return BadRequest;
+ }
+}
+
+/*
+ * Boring Swapping stuff ...
+ */
+
+static int
+SProcSyncInitialize(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncInitializeReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncInitializeReq);
+
+ return ProcSyncInitialize(client);
+}
+
+static int
+SProcSyncListSystemCounters(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncListSystemCountersReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncListSystemCountersReq);
+
+ return ProcSyncListSystemCounters(client);
+}
+
+static int
+SProcSyncCreateCounter(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncCreateCounterReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncCreateCounterReq);
+ swapl(&stuff->cid, n);
+ swapl(&stuff->initial_value_lo, n);
+ swapl(&stuff->initial_value_hi, n);
+
+ return ProcSyncCreateCounter(client);
+}
+
+static int
+SProcSyncSetCounter(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncSetCounterReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncSetCounterReq);
+ swapl(&stuff->cid, n);
+ swapl(&stuff->value_lo, n);
+ swapl(&stuff->value_hi, n);
+
+ return ProcSyncSetCounter(client);
+}
+
+static int
+SProcSyncChangeCounter(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncChangeCounterReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncChangeCounterReq);
+ swapl(&stuff->cid, n);
+ swapl(&stuff->value_lo, n);
+ swapl(&stuff->value_hi, n);
+
+ return ProcSyncChangeCounter(client);
+}
+
+static int
+SProcSyncQueryCounter(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncQueryCounterReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncQueryCounterReq);
+ swapl(&stuff->counter, n);
+
+ return ProcSyncQueryCounter(client);
+}
+
+static int
+SProcSyncDestroyCounter(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncDestroyCounterReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncDestroyCounterReq);
+ swapl(&stuff->counter, n);
+
+ return ProcSyncDestroyCounter(client);
+}
+
+static int
+SProcSyncAwait(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncAwaitReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSyncAwaitReq);
+ SwapRestL(stuff);
+
+ return ProcSyncAwait(client);
+}
+
+
+static int
+SProcSyncCreateAlarm(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncCreateAlarmReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq);
+ swapl(&stuff->id, n);
+ swapl(&stuff->valueMask, n);
+ SwapRestL(stuff);
+
+ return ProcSyncCreateAlarm(client);
+}
+
+static int
+SProcSyncChangeAlarm(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncChangeAlarmReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq);
+ swapl(&stuff->alarm, n);
+ swapl(&stuff->valueMask, n);
+ SwapRestL(stuff);
+ return ProcSyncChangeAlarm(client);
+}
+
+static int
+SProcSyncQueryAlarm(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncQueryAlarmReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncQueryAlarmReq);
+ swapl(&stuff->alarm, n);
+
+ return ProcSyncQueryAlarm(client);
+}
+
+static int
+SProcSyncDestroyAlarm(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncDestroyAlarmReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncDestroyAlarmReq);
+ swapl(&stuff->alarm, n);
+
+ return ProcSyncDestroyAlarm(client);
+}
+
+static int
+SProcSyncSetPriority(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncSetPriorityReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncSetPriorityReq);
+ swapl(&stuff->id, n);
+ swapl(&stuff->priority, n);
+
+ return ProcSyncSetPriority(client);
+}
+
+static int
+SProcSyncGetPriority(client)
+ ClientPtr client;
+{
+ REQUEST(xSyncGetPriorityReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncGetPriorityReq);
+ swapl(&stuff->id, n);
+
+ return ProcSyncGetPriority(client);
+}
+
+
+static int
+SProcSyncDispatch(client)
+ ClientPtr client;
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_SyncInitialize:
+ return SProcSyncInitialize(client);
+ case X_SyncListSystemCounters:
+ return SProcSyncListSystemCounters(client);
+ case X_SyncCreateCounter:
+ return SProcSyncCreateCounter(client);
+ case X_SyncSetCounter:
+ return SProcSyncSetCounter(client);
+ case X_SyncChangeCounter:
+ return SProcSyncChangeCounter(client);
+ case X_SyncQueryCounter:
+ return SProcSyncQueryCounter(client);
+ case X_SyncDestroyCounter:
+ return SProcSyncDestroyCounter(client);
+ case X_SyncAwait:
+ return SProcSyncAwait(client);
+ case X_SyncCreateAlarm:
+ return SProcSyncCreateAlarm(client);
+ case X_SyncChangeAlarm:
+ return SProcSyncChangeAlarm(client);
+ case X_SyncQueryAlarm:
+ return SProcSyncQueryAlarm(client);
+ case X_SyncDestroyAlarm:
+ return SProcSyncDestroyAlarm(client);
+ case X_SyncSetPriority:
+ return SProcSyncSetPriority(client);
+ case X_SyncGetPriority:
+ return SProcSyncGetPriority(client);
+ default:
+ return BadRequest;
+ }
+}
+
+/*
+ * Event Swapping
+ */
+
+static void
+SCounterNotifyEvent(from, to)
+ xSyncCounterNotifyEvent *from, *to;
+{
+ to->type = from->type;
+ to->kind = from->kind;
+ cpswaps(from->sequenceNumber, to->sequenceNumber);
+ cpswapl(from->counter, to->counter);
+ cpswapl(from->wait_value_lo, to->wait_value_lo);
+ cpswapl(from->wait_value_hi, to->wait_value_hi);
+ cpswapl(from->counter_value_lo, to->counter_value_lo);
+ cpswapl(from->counter_value_hi, to->counter_value_hi);
+ cpswapl(from->time, to->time);
+ cpswaps(from->count, to->count);
+ to->destroyed = from->destroyed;
+}
+
+
+static void
+SAlarmNotifyEvent(from, to)
+ xSyncAlarmNotifyEvent *from, *to;
+{
+ to->type = from->type;
+ to->kind = from->kind;
+ cpswaps(from->sequenceNumber, to->sequenceNumber);
+ cpswapl(from->alarm, to->alarm);
+ cpswapl(from->counter_value_lo, to->counter_value_lo);
+ cpswapl(from->counter_value_hi, to->counter_value_hi);
+ cpswapl(from->alarm_value_lo, to->alarm_value_lo);
+ cpswapl(from->alarm_value_hi, to->alarm_value_hi);
+ cpswapl(from->time, to->time);
+ to->state = from->state;
+}
+
+/*
+ * ** Close everything down. ** This is fairly simple for now.
+ */
+/* ARGSUSED */
+static void
+SyncResetProc(extEntry)
+ ExtensionEntry *extEntry;
+{
+ xfree(SysCounterList);
+ SysCounterList = NULL;
+ RTCounter = 0;
+}
+
+
+/*
+ * ** Initialise the extension.
+ */
+void
+SyncExtensionInit(INITARGS)
+{
+ ExtensionEntry *extEntry;
+
+ if (RTCounter == 0)
+ {
+ RTCounter = CreateNewResourceType(FreeCounter);
+ }
+ RTAlarm = CreateNewResourceType(FreeAlarm);
+ RTAwait = CreateNewResourceType(FreeAwait)|RC_NEVERRETAIN;
+ RTAlarmClient = CreateNewResourceType(FreeAlarmClient)|RC_NEVERRETAIN;
+
+ if (RTCounter == 0 || RTAwait == 0 || RTAlarm == 0 ||
+ RTAlarmClient == 0 ||
+ (extEntry = AddExtension(SYNC_NAME,
+ XSyncNumberEvents, XSyncNumberErrors,
+ ProcSyncDispatch, SProcSyncDispatch,
+ SyncResetProc,
+ StandardMinorOpcode)) == NULL)
+ {
+ ErrorF("Sync Extension %d.%d failed to Initialise\n",
+ SYNC_MAJOR_VERSION, SYNC_MINOR_VERSION);
+ return;
+ }
+
+ SyncEventBase = extEntry->eventBase;
+ SyncErrorBase = extEntry->errorBase;
+ EventSwapVector[SyncEventBase + XSyncCounterNotify] = (EventSwapPtr) SCounterNotifyEvent;
+ EventSwapVector[SyncEventBase + XSyncAlarmNotify] = (EventSwapPtr) SAlarmNotifyEvent;
+
+ /*
+ * Although SERVERTIME is implemented by the OS layer, we initialise it
+ * here because doing it in OsInit() is too early. The resource database
+ * is not initialised when OsInit() is called. This is just about OK
+ * because there is always a servertime counter.
+ */
+ SyncInitServerTime();
+
+#ifdef DEBUG
+ fprintf(stderr, "Sync Extension %d.%d\n",
+ SYNC_MAJOR_VERSION, SYNC_MINOR_VERSION);
+#endif
+}
+
+
+/*
+ * ***** SERVERTIME implementation - should go in its own file in OS directory?
+ */
+
+
+
+static pointer ServertimeCounter;
+static XSyncValue Now;
+static XSyncValue *pnext_time;
+
+#define GetTime()\
+{\
+ unsigned long millis = GetTimeInMillis();\
+ unsigned long maxis = XSyncValueHigh32(Now);\
+ if (millis < XSyncValueLow32(Now)) maxis++;\
+ XSyncIntsToValue(&Now, millis, maxis);\
+}
+
+/*
+*** Server Block Handler
+*** code inspired by multibuffer extension
+ */
+/*ARGSUSED*/
+static void ServertimeBlockHandler(env, wt, LastSelectMask)
+pointer env;
+struct timeval **wt;
+pointer LastSelectMask;
+{
+ XSyncValue delay;
+ unsigned long timeout;
+
+ if (pnext_time)
+ {
+ GetTime();
+
+ if (XSyncValueGreaterOrEqual(Now, *pnext_time))
+ {
+ timeout = 0;
+ }
+ else
+ {
+ Bool overflow;
+ XSyncValueSubtract(&delay, *pnext_time, Now, &overflow);
+ (void)overflow;
+ timeout = XSyncValueLow32(delay);
+ }
+ AdjustWaitForDelay(wt, timeout); /* os/utils.c */
+ }
+}
+
+/*
+*** Wakeup Handler
+ */
+/*ARGSUSED*/
+static void ServertimeWakeupHandler(env, rc, LastSelectMask)
+pointer env;
+int rc;
+pointer LastSelectMask;
+{
+ if (pnext_time)
+ {
+ GetTime();
+
+ if (XSyncValueGreaterOrEqual(Now, *pnext_time))
+ {
+ SyncChangeCounter(ServertimeCounter, Now);
+ }
+ }
+}
+
+static void
+ServertimeQueryValue(pCounter, pValue_return)
+ pointer pCounter;
+ CARD64 *pValue_return;
+{
+ GetTime();
+ *pValue_return = Now;
+}
+
+static void
+ServertimeBracketValues(pCounter, pbracket_less, pbracket_greater)
+ pointer pCounter;
+ CARD64 *pbracket_less;
+ CARD64 *pbracket_greater;
+{
+ if (!pnext_time && pbracket_greater)
+ {
+ RegisterBlockAndWakeupHandlers(ServertimeBlockHandler,
+ ServertimeWakeupHandler,
+ NULL);
+ }
+ else if (pnext_time && !pbracket_greater)
+ {
+ RemoveBlockAndWakeupHandlers(ServertimeBlockHandler,
+ ServertimeWakeupHandler,
+ NULL);
+ }
+ pnext_time = pbracket_greater;
+}
+
+static void
+SyncInitServerTime()
+{
+ CARD64 resolution;
+
+ XSyncIntsToValue(&Now, GetTimeInMillis(), 0);
+ XSyncIntToValue(&resolution, 4);
+ ServertimeCounter = SyncCreateSystemCounter("SERVERTIME", Now, resolution,
+ XSyncCounterNeverDecreases,
+ ServertimeQueryValue, ServertimeBracketValues);
+ pnext_time = NULL;
+}
diff --git a/nx-X11/programs/Xserver/Xext/vidmodeproc.h b/nx-X11/programs/Xserver/Xext/vidmodeproc.h
new file mode 100644
index 000000000..918d1e4df
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/vidmodeproc.h
@@ -0,0 +1,78 @@
+/* $XFree86: xc/programs/Xserver/Xext/vidmodeproc.h,v 1.4 1999/12/13 01:39:40 robin Exp $ */
+
+/* Prototypes for DGA functions that the DDX must provide */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _VIDMODEPROC_H_
+#define _VIDMODEPROC_H_
+
+
+typedef enum {
+ VIDMODE_H_DISPLAY,
+ VIDMODE_H_SYNCSTART,
+ VIDMODE_H_SYNCEND,
+ VIDMODE_H_TOTAL,
+ VIDMODE_H_SKEW,
+ VIDMODE_V_DISPLAY,
+ VIDMODE_V_SYNCSTART,
+ VIDMODE_V_SYNCEND,
+ VIDMODE_V_TOTAL,
+ VIDMODE_FLAGS,
+ VIDMODE_CLOCK
+} VidModeSelectMode;
+
+typedef enum {
+ VIDMODE_MON_VENDOR,
+ VIDMODE_MON_MODEL,
+ VIDMODE_MON_NHSYNC,
+ VIDMODE_MON_NVREFRESH,
+ VIDMODE_MON_HSYNC_LO,
+ VIDMODE_MON_HSYNC_HI,
+ VIDMODE_MON_VREFRESH_LO,
+ VIDMODE_MON_VREFRESH_HI
+} VidModeSelectMonitor;
+
+typedef union {
+ pointer ptr;
+ int i;
+ float f;
+} vidMonitorValue;
+
+void XFree86VidModeExtensionInit(void);
+
+Bool VidModeAvailable(int scrnIndex);
+Bool VidModeGetCurrentModeline(int scrnIndex, pointer *mode, int *dotClock);
+Bool VidModeGetFirstModeline(int scrnIndex, pointer *mode, int *dotClock);
+Bool VidModeGetNextModeline(int scrnIndex, pointer *mode, int *dotClock);
+Bool VidModeDeleteModeline(int scrnIndex, pointer mode);
+Bool VidModeZoomViewport(int scrnIndex, int zoom);
+Bool VidModeGetViewPort(int scrnIndex, int *x, int *y);
+Bool VidModeSetViewPort(int scrnIndex, int x, int y);
+Bool VidModeSwitchMode(int scrnIndex, pointer mode);
+Bool VidModeLockZoom(int scrnIndex, Bool lock);
+Bool VidModeGetMonitor(int scrnIndex, pointer *monitor);
+int VidModeGetNumOfClocks(int scrnIndex, Bool *progClock);
+Bool VidModeGetClocks(int scrnIndex, int *Clocks);
+ModeStatus VidModeCheckModeForMonitor(int scrnIndex, pointer mode);
+ModeStatus VidModeCheckModeForDriver(int scrnIndex, pointer mode);
+void VidModeSetCrtcForMode(int scrnIndex, pointer mode);
+Bool VidModeAddModeline(int scrnIndex, pointer mode);
+int VidModeGetDotClock(int scrnIndex, int Clock);
+int VidModeGetNumOfModes(int scrnIndex);
+Bool VidModeSetGamma(int scrnIndex, float red, float green, float blue);
+Bool VidModeGetGamma(int scrnIndex, float *red, float *green, float *blue);
+pointer VidModeCreateMode(void);
+void VidModeCopyMode(pointer modefrom, pointer modeto);
+int VidModeGetModeValue(pointer mode, int valtyp);
+void VidModeSetModeValue(pointer mode, int valtyp, int val);
+vidMonitorValue VidModeGetMonitorValue(pointer monitor, int valtyp, int indx);
+Bool VidModeSetGammaRamp(int, int, CARD16 *, CARD16 *, CARD16 *);
+Bool VidModeGetGammaRamp(int, int, CARD16 *, CARD16 *, CARD16 *);
+int VidModeGetGammaRampSize(int scrnIndex);
+
+#endif
+
+
diff --git a/nx-X11/programs/Xserver/Xext/xcmisc.c b/nx-X11/programs/Xserver/Xext/xcmisc.c
new file mode 100644
index 000000000..c7bb72d9b
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xcmisc.c
@@ -0,0 +1,253 @@
+/* $Xorg: xcmisc.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/Xext/xcmisc.c,v 3.7 2003/10/28 23:08:43 tsi Exp $ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "swaprep.h"
+#include <X11/extensions/xcmiscstr.h>
+#include "modinit.h"
+
+#if HAVE_STDINT_H
+#include <stdint.h>
+#elif !defined(UINT32_MAX)
+#define UINT32_MAX 0xffffffffU
+#endif
+
+#if 0
+static unsigned char XCMiscCode;
+#endif
+
+static void XCMiscResetProc(
+ ExtensionEntry * /* extEntry */
+);
+
+static DISPATCH_PROC(ProcXCMiscDispatch);
+static DISPATCH_PROC(ProcXCMiscGetVersion);
+static DISPATCH_PROC(ProcXCMiscGetXIDList);
+static DISPATCH_PROC(ProcXCMiscGetXIDRange);
+static DISPATCH_PROC(SProcXCMiscDispatch);
+static DISPATCH_PROC(SProcXCMiscGetVersion);
+static DISPATCH_PROC(SProcXCMiscGetXIDList);
+static DISPATCH_PROC(SProcXCMiscGetXIDRange);
+
+void
+XCMiscExtensionInit(INITARGS)
+{
+#if 0
+ ExtensionEntry *extEntry;
+
+ if ((extEntry = AddExtension(XCMiscExtensionName, 0, 0,
+ ProcXCMiscDispatch, SProcXCMiscDispatch,
+ XCMiscResetProc, StandardMinorOpcode)) != 0)
+ XCMiscCode = (unsigned char)extEntry->base;
+#else
+ (void) AddExtension(XCMiscExtensionName, 0, 0,
+ ProcXCMiscDispatch, SProcXCMiscDispatch,
+ XCMiscResetProc, StandardMinorOpcode);
+#endif
+
+ DeclareExtensionSecurity(XCMiscExtensionName, TRUE);
+}
+
+/*ARGSUSED*/
+static void
+XCMiscResetProc (extEntry)
+ ExtensionEntry *extEntry;
+{
+}
+
+static int
+ProcXCMiscGetVersion(client)
+ register ClientPtr client;
+{
+ xXCMiscGetVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = XCMiscMajorVersion;
+ rep.minorVersion = XCMiscMinorVersion;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof(xXCMiscGetVersionReply), (char *)&rep);
+ return(client->noClientException);
+}
+
+static int
+ProcXCMiscGetXIDRange(client)
+ register ClientPtr client;
+{
+ xXCMiscGetXIDRangeReply rep;
+ register int n;
+ XID min_id, max_id;
+
+ REQUEST_SIZE_MATCH(xXCMiscGetXIDRangeReq);
+ GetXIDRange(client->index, FALSE, &min_id, &max_id);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.start_id = min_id;
+ rep.count = max_id - min_id + 1;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.start_id, n);
+ swapl(&rep.count, n);
+ }
+ WriteToClient(client, sizeof(xXCMiscGetXIDRangeReply), (char *)&rep);
+ return(client->noClientException);
+}
+
+static int
+ProcXCMiscGetXIDList(client)
+ register ClientPtr client;
+{
+ REQUEST(xXCMiscGetXIDListReq);
+ xXCMiscGetXIDListReply rep;
+ register int n;
+ XID *pids;
+ unsigned int count;
+
+ REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);
+
+ if (stuff->count > UINT32_MAX / sizeof(XID))
+ return BadAlloc;
+
+ pids = (XID *)Xalloc(stuff->count * sizeof(XID));
+ if (!pids)
+ {
+ return BadAlloc;
+ }
+ count = GetXIDList(client, stuff->count, pids);
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = count;
+ rep.count = count;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.count, n);
+ }
+ WriteToClient(client, sizeof(xXCMiscGetXIDListReply), (char *)&rep);
+ if (count)
+ {
+ client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
+ WriteSwappedDataToClient(client, count * sizeof(XID), pids);
+ }
+ Xfree(pids);
+ return(client->noClientException);
+}
+
+static int
+ProcXCMiscDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_XCMiscGetVersion:
+ return ProcXCMiscGetVersion(client);
+ case X_XCMiscGetXIDRange:
+ return ProcXCMiscGetXIDRange(client);
+ case X_XCMiscGetXIDList:
+ return ProcXCMiscGetXIDList(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static int
+SProcXCMiscGetVersion(client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST(xXCMiscGetVersionReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
+ swaps(&stuff->majorVersion, n);
+ swaps(&stuff->minorVersion, n);
+ return ProcXCMiscGetVersion(client);
+}
+
+static int
+SProcXCMiscGetXIDRange(client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST(xReq);
+
+ swaps(&stuff->length, n);
+ return ProcXCMiscGetXIDRange(client);
+}
+
+static int
+SProcXCMiscGetXIDList(client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST(xXCMiscGetXIDListReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->count, n);
+ return ProcXCMiscGetXIDList(client);
+}
+
+static int
+SProcXCMiscDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_XCMiscGetVersion:
+ return SProcXCMiscGetVersion(client);
+ case X_XCMiscGetXIDRange:
+ return SProcXCMiscGetXIDRange(client);
+ case X_XCMiscGetXIDList:
+ return SProcXCMiscGetXIDList(client);
+ default:
+ return BadRequest;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xext/xevie.c b/nx-X11/programs/Xserver/Xext/xevie.c
new file mode 100644
index 000000000..3ec6cc4f0
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xevie.c
@@ -0,0 +1,719 @@
+/************************************************************
+
+Copyright 2003-2005 Sun Microsystems, Inc.
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+************************************************************/
+/* $XdotOrg: xc/programs/Xserver/Xext/xevie.c,v 1.11 2005/10/06 17:55:54 alanc Exp $ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#define _XEVIE_SERVER_
+#include <X11/extensions/Xeviestr.h>
+#include <X11/Xfuncproto.h>
+#include "input.h"
+#include "inputstr.h"
+#include "windowstr.h"
+#include "cursorstr.h"
+#include <X11/extensions/XKBsrv.h>
+
+#include "../os/osdep.h"
+
+#define NoSuchEvent 0x80000000
+
+extern Bool noXkbExtension;
+extern int xeviegrabState;
+
+static int ProcDispatch (), SProcDispatch ();
+static void ResetProc ();
+
+static unsigned char ReqCode = 0;
+static int ErrorBase;
+
+int xevieFlag = 0;
+int xevieClientIndex = 0;
+DeviceIntPtr xeviekb = NULL;
+DeviceIntPtr xeviemouse = NULL;
+Mask xevieMask = 0;
+int xevieEventSent = 0;
+int xevieKBEventSent = 0;
+static unsigned int xevieServerGeneration;
+static int xevieDevicePrivateIndex;
+static Bool xevieModifiersOn = FALSE;
+
+#define XEVIEINFO(dev) ((xevieDeviceInfoPtr)dev->devPrivates[xevieDevicePrivateIndex].ptr)
+
+Mask xevieFilters[128] =
+{
+ NoSuchEvent, /* 0 */
+ NoSuchEvent, /* 1 */
+ KeyPressMask, /* KeyPress */
+ KeyReleaseMask, /* KeyRelease */
+ ButtonPressMask, /* ButtonPress */
+ ButtonReleaseMask, /* ButtonRelease */
+ PointerMotionMask /* MotionNotify (initial state) */
+};
+
+typedef struct {
+ ProcessInputProc processInputProc;
+ ProcessInputProc realInputProc;
+ DeviceUnwrapProc unwrapProc;
+} xevieDeviceInfoRec, *xevieDeviceInfoPtr;
+
+typedef struct {
+ CARD32 time;
+ KeyClassPtr keyc;
+} xevieKeycQueueRec, *xevieKeycQueuePtr;
+
+#define KEYC_QUEUE_SIZE 100
+xevieKeycQueueRec keycq[KEYC_QUEUE_SIZE] = {0, NULL};
+static int keycqHead = 0, keycqTail = 0;
+
+static int ProcDispatch (ClientPtr), SProcDispatch (ClientPtr);
+static void ResetProc (ExtensionEntry*);
+
+static int ErrorBase;
+
+static Bool XevieStart(void);
+static void XevieEnd(int clientIndex);
+static void XevieClientStateCallback(CallbackListPtr *pcbl, pointer nulldata,
+ pointer calldata);
+static void XevieServerGrabStateCallback(CallbackListPtr *pcbl,
+ pointer nulldata,
+ pointer calldata);
+
+static Bool XevieAdd(DeviceIntPtr device, pointer data);
+static void XevieWrap(DeviceIntPtr device, ProcessInputProc proc);
+static Bool XevieRemove(DeviceIntPtr device, pointer data);
+static void doSendEvent(xEvent *xE, DeviceIntPtr device);
+static void XeviePointerProcessInputProc(xEvent *xE, DeviceIntPtr dev,
+ int count);
+static void XevieKbdProcessInputProc(xEvent *xE, DeviceIntPtr dev, int count);
+
+void
+XevieExtensionInit ()
+{
+ ExtensionEntry* extEntry;
+
+ if (serverGeneration != xevieServerGeneration) {
+ if ((xevieDevicePrivateIndex = AllocateDevicePrivateIndex()) == -1)
+ return;
+ xevieServerGeneration = serverGeneration;
+ }
+
+ if (!AddCallback(&ServerGrabCallback,XevieServerGrabStateCallback,NULL))
+ return;
+
+ if ((extEntry = AddExtension (XEVIENAME,
+ 0,
+ XevieNumberErrors,
+ ProcDispatch,
+ SProcDispatch,
+ ResetProc,
+ StandardMinorOpcode))) {
+ ReqCode = (unsigned char)extEntry->base;
+ ErrorBase = extEntry->errorBase;
+ }
+
+ /* PC servers initialize the desktop colors (citems) here! */
+}
+
+/*ARGSUSED*/
+static
+void ResetProc (extEntry)
+ ExtensionEntry* extEntry;
+{
+}
+
+static
+int ProcQueryVersion (client)
+ register ClientPtr client;
+{
+ REQUEST (xXevieQueryVersionReq);
+ xXevieQueryVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH (xXevieQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequence_number = client->sequence;
+ rep.server_major_version = XEVIE_MAJOR_VERSION;
+ rep.server_minor_version = XEVIE_MINOR_VERSION;
+ WriteToClient (client, sizeof (xXevieQueryVersionReply), (char *)&rep);
+ return client->noClientException;
+}
+
+static
+int ProcStart (client)
+ register ClientPtr client;
+{
+ REQUEST (xXevieStartReq);
+ xXevieStartReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH (xXevieStartReq);
+ rep.pad1 = 0;
+
+ if(!xevieFlag){
+ if (AddCallback(&ClientStateCallback,XevieClientStateCallback,NULL)) {
+ xevieFlag = 1;
+ rep.pad1 = 1;
+ xevieClientIndex = client->index;
+ if(!keycq[0].time ) {
+ int i;
+ for(i=0; i<KEYC_QUEUE_SIZE; i++) {
+ keycq[i].keyc = xalloc(sizeof(KeyClassRec));
+ keycq[i].keyc->xkbInfo = xalloc(sizeof(XkbSrvInfoRec));
+ }
+ }
+ } else
+ return BadAlloc;
+ } else
+ return BadAccess;
+ if (!noXkbExtension) {
+ if (!XevieStart()) {
+ DeleteCallback(&ClientStateCallback,XevieClientStateCallback,NULL);
+ return BadAlloc;
+ }
+ }
+
+ xevieModifiersOn = FALSE;
+
+ rep.type = X_Reply;
+ rep.sequence_number = client->sequence;
+ WriteToClient (client, sizeof (xXevieStartReply), (char *)&rep);
+ return client->noClientException;
+}
+
+static
+int ProcEnd (client)
+ register ClientPtr client;
+{
+ xXevieEndReply rep;
+
+ if (xevieFlag) {
+ if (client->index != xevieClientIndex)
+ return BadAccess;
+
+ DeleteCallback(&ClientStateCallback,XevieClientStateCallback,NULL);
+ XevieEnd(xevieClientIndex);
+ }
+
+ rep.type = X_Reply;
+ rep.sequence_number = client->sequence;
+ WriteToClient (client, sizeof (xXevieEndReply), (char *)&rep);
+ return client->noClientException;
+}
+
+static
+int ProcSend (client)
+ register ClientPtr client;
+{
+ REQUEST (xXevieSendReq);
+ xXevieSendReply rep;
+ xEvent *xE;
+ OsCommPtr oc;
+ static unsigned char lastDetail = 0, lastType = 0;
+
+ if (client->index != xevieClientIndex)
+ return BadAccess;
+
+ xE = (xEvent *)&stuff->event;
+ rep.type = X_Reply;
+ rep.sequence_number = client->sequence;
+ WriteToClient (client, sizeof (xXevieSendReply), (char *)&rep);
+
+ switch(xE->u.u.type) {
+ case KeyPress:
+ case KeyRelease:
+ xevieKBEventSent = 1;
+ if(noXkbExtension)
+ CoreProcessKeyboardEvent (xE, xeviekb, 1);
+ else
+ doSendEvent(xE, inputInfo.keyboard);
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ case MotionNotify:
+ xevieEventSent = 1;
+ if(noXkbExtension)
+ CoreProcessPointerEvent(xE, xeviemouse, 1);
+ else
+ doSendEvent(xE, inputInfo.pointer);
+ break;
+ default:
+ break;
+ }
+ lastType = xE->u.u.type;
+ lastDetail = xE->u.u.detail;
+ return client->noClientException;
+}
+
+static
+int ProcSelectInput (client)
+ register ClientPtr client;
+{
+ REQUEST (xXevieSelectInputReq);
+ xXevieSelectInputReply rep;
+
+ if (client->index != xevieClientIndex)
+ return BadAccess;
+
+ xevieMask = (long)stuff->event_mask;
+ rep.type = X_Reply;
+ rep.sequence_number = client->sequence;
+ WriteToClient (client, sizeof (xXevieSelectInputReply), (char *)&rep);
+ return client->noClientException;
+}
+
+static
+int ProcDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST (xReq);
+ switch (stuff->data)
+ {
+ case X_XevieQueryVersion:
+ return ProcQueryVersion (client);
+ case X_XevieStart:
+ return ProcStart (client);
+ case X_XevieEnd:
+ return ProcEnd (client);
+ case X_XevieSend:
+ return ProcSend (client);
+ case X_XevieSelectInput:
+ return ProcSelectInput(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static
+int SProcQueryVersion (client)
+ register ClientPtr client;
+{
+ register int n;
+
+ REQUEST(xXevieQueryVersionReq);
+ swaps(&stuff->length, n);
+ return ProcQueryVersion(client);
+}
+
+static
+int SProcStart (client)
+ ClientPtr client;
+{
+ register int n;
+
+ REQUEST (xXevieStartReq);
+ swaps (&stuff->length, n);
+ swapl (&stuff->screen, n);
+ REQUEST_AT_LEAST_SIZE (xXevieStartReq);
+ return ProcStart (client);
+}
+
+static
+int SProcEnd (client)
+ ClientPtr client;
+{
+ register int n;
+ int count;
+ xColorItem* pItem;
+
+ REQUEST (xXevieEndReq);
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE (xXevieEndReq);
+ swapl(&stuff->cmap, n);
+ return ProcEnd (client);
+}
+
+static
+int SProcSend (client)
+ ClientPtr client;
+{
+ register int n;
+ int count;
+
+ REQUEST (xXevieSendReq);
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE (xXevieSendReq);
+ swapl(&stuff->event, n);
+ return ProcSend (client);
+}
+
+static
+int SProcSelectInput (client)
+ ClientPtr client;
+{
+ register int n;
+ int count;
+
+ REQUEST (xXevieSelectInputReq);
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE (xXevieSendReq);
+ swapl(&stuff->event_mask, n);
+ return ProcSelectInput (client);
+}
+
+
+static
+int SProcDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_XevieQueryVersion:
+ return SProcQueryVersion (client);
+ case X_XevieStart:
+ return SProcStart (client);
+ case X_XevieEnd:
+ return SProcEnd (client);
+ case X_XevieSend:
+ return SProcSend (client);
+ case X_XevieSelectInput:
+ return SProcSelectInput(client);
+ default:
+ return BadRequest;
+ }
+}
+/*======================================================*/
+
+#define WRAP_INPUTPROC(dev,store,inputProc) \
+ store->processInputProc = dev->public.processInputProc; \
+ dev->public.processInputProc = inputProc; \
+ store->realInputProc = dev->public.realInputProc; \
+ dev->public.realInputProc = inputProc;
+
+#define COND_WRAP_INPUTPROC(dev,store,inputProc) \
+ if (dev->public.processInputProc == dev->public.realInputProc) \
+ dev->public.processInputProc = inputProc; \
+ store->processInputProc = \
+ store->realInputProc = dev->public.realInputProc; \
+ dev->public.realInputProc = inputProc;
+
+#define UNWRAP_INPUTPROC(dev,restore) \
+ dev->public.processInputProc = restore->processInputProc; \
+ dev->public.realInputProc = restore->realInputProc;
+
+#define UNWRAP_INPUTPROC(dev,restore) \
+ dev->public.processInputProc = restore->processInputProc; \
+ dev->public.realInputProc = restore->realInputProc;
+
+#define XEVIE_EVENT(xE) \
+ (xevieFlag \
+ && !xeviegrabState \
+ && clients[xevieClientIndex] \
+ && (xevieMask & xevieFilters[xE->u.u.type]))
+
+
+static void
+sendEvent(ClientPtr pClient, xEvent *xE)
+{
+ if(pClient->swapped) {
+ xEvent eventTo;
+
+ /* Remember to strip off the leading bit of type in case
+ this event was sent with "SendEvent." */
+ (*EventSwapVector[xE->u.u.type & 0177]) (xE, &eventTo);
+ (void)WriteToClient(pClient, sizeof(xEvent), (char *)&eventTo);
+ } else {
+ (void)WriteToClient(pClient, sizeof(xEvent), (char *) xE);
+ }
+}
+
+static void
+XevieKbdProcessInputProc(xEvent *xE, DeviceIntPtr dev, int count)
+{
+ int key, bit;
+ BYTE *kptr;
+ ProcessInputProc tmp;
+ KeyClassPtr keyc = dev->key;
+ xevieDeviceInfoPtr xeviep = XEVIEINFO(dev);
+
+ if(XEVIE_EVENT(xE)) {
+ key = xE->u.u.detail;
+ kptr = &keyc->down[key >> 3];
+ bit = 1 << (key & 7);
+
+ if (dev->key->modifierMap[xE->u.u.detail])
+ xevieModifiersOn = TRUE;
+
+ xE->u.keyButtonPointer.event = xeviewin->drawable.id;
+ xE->u.keyButtonPointer.root = GetCurrentRootWindow()->drawable.id;
+ xE->u.keyButtonPointer.child = (xeviewin->firstChild)
+ ? xeviewin->firstChild->drawable.id:0;
+ xE->u.keyButtonPointer.rootX = xeviehot.x;
+ xE->u.keyButtonPointer.rootY = xeviehot.y;
+ xE->u.keyButtonPointer.state = keyc->state | inputInfo.pointer->button->state;
+ /* fix bug: sequence lost in Xlib */
+ xE->u.u.sequenceNumber = clients[xevieClientIndex]->sequence;
+ /* fix for bug5092586 */
+ if(!noXkbExtension) {
+ switch(xE->u.u.type) {
+ case KeyPress: *kptr |= bit; break;
+ case KeyRelease: *kptr &= ~bit; break;
+ }
+ }
+ keycq[keycqHead].time = xE->u.keyButtonPointer.time;
+ memcpy(keycq[keycqHead].keyc, keyc, sizeof(KeyClassRec) - sizeof(KeyClassPtr));
+ memcpy(keycq[keycqHead].keyc->xkbInfo, keyc->xkbInfo, sizeof(XkbSrvInfoRec));
+ if(++keycqHead >=KEYC_QUEUE_SIZE)
+ keycqHead = 0;
+ sendEvent(clients[xevieClientIndex], xE);
+ return;
+ }
+
+ tmp = dev->public.realInputProc;
+ UNWRAP_INPUTPROC(dev,xeviep);
+ dev->public.processInputProc(xE,dev,count);
+ COND_WRAP_INPUTPROC(dev,xeviep,tmp);
+}
+
+static void
+XeviePointerProcessInputProc(xEvent *xE, DeviceIntPtr dev, int count)
+{
+ xevieDeviceInfoPtr xeviep = XEVIEINFO(dev);
+ ProcessInputProc tmp;
+
+ if (XEVIE_EVENT(xE)) {
+ /* fix bug: sequence lost in Xlib */
+ xE->u.u.sequenceNumber = clients[xevieClientIndex]->sequence;
+ sendEvent(clients[xevieClientIndex], xE);
+ return;
+ }
+
+ tmp = dev->public.realInputProc;
+ UNWRAP_INPUTPROC(dev,xeviep);
+ dev->public.processInputProc(xE,dev,count);
+ COND_WRAP_INPUTPROC(dev,xeviep,tmp);
+}
+
+static Bool
+XevieStart(void)
+{
+ ProcessInputProc prp;
+ prp = XevieKbdProcessInputProc;
+ if (!XevieAdd(inputInfo.keyboard,&prp))
+ return FALSE;
+ prp = XeviePointerProcessInputProc;
+ if (!XevieAdd(inputInfo.pointer,&prp))
+ return FALSE;
+
+ return TRUE;
+}
+
+
+static void
+XevieEnd(int clientIndex)
+{
+ if (!clientIndex || clientIndex == xevieClientIndex) {
+
+ if(!noXkbExtension) {
+
+ XevieRemove(inputInfo.keyboard,NULL);
+
+ inputInfo.keyboard->public.processInputProc = CoreProcessKeyboardEvent;
+ inputInfo.keyboard->public.realInputProc = CoreProcessKeyboardEvent;
+ XkbSetExtension(inputInfo.keyboard,ProcessKeyboardEvent);
+
+
+ XevieRemove(inputInfo.pointer,NULL);
+
+ inputInfo.pointer->public.processInputProc = CoreProcessPointerEvent;
+ inputInfo.pointer->public.realInputProc = CoreProcessPointerEvent;
+ XkbSetExtension(inputInfo.pointer,ProcessPointerEvent);
+ }
+
+ xevieFlag = 0;
+ xevieClientIndex = 0;
+ DeleteCallback (&ClientStateCallback, XevieClientStateCallback, NULL);
+ }
+}
+
+static void
+XevieClientStateCallback(CallbackListPtr *pcbl, pointer nulldata,
+ pointer calldata)
+{
+ NewClientInfoRec *pci = (NewClientInfoRec *)calldata;
+ ClientPtr client = pci->client;
+ if (client->clientState == ClientStateGone
+ || client->clientState == ClientStateRetained)
+ XevieEnd(client->index);
+}
+
+static void
+XevieServerGrabStateCallback(CallbackListPtr *pcbl, pointer nulldata,
+ pointer calldata)
+{
+ ServerGrabInfoRec *grbinfo = (ServerGrabInfoRec *)calldata;
+ if (grbinfo->grabstate == SERVER_GRABBED)
+ xeviegrabState = TRUE;
+ else
+ xeviegrabState = FALSE;
+}
+
+#define UNWRAP_UNWRAPPROC(device,proc_store) \
+ device->unwrapProc = proc_store;
+
+#define WRAP_UNWRAPPROC(device,proc_store,proc) \
+ proc_store = device->unwrapProc; \
+ device->unwrapProc = proc;
+
+static void
+xevieUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc, pointer data)
+{
+ xevieDeviceInfoPtr xeviep = XEVIEINFO(device);
+ ProcessInputProc tmp = device->public.processInputProc;
+
+ UNWRAP_INPUTPROC(device,xeviep);
+ UNWRAP_UNWRAPPROC(device,xeviep->unwrapProc);
+ proc(device,data);
+ WRAP_INPUTPROC(device,xeviep,tmp);
+ WRAP_UNWRAPPROC(device,xeviep->unwrapProc,xevieUnwrapProc);
+}
+
+static Bool
+XevieUnwrapAdd(DeviceIntPtr device, void* data)
+{
+ if (device->unwrapProc)
+ device->unwrapProc(device,XevieUnwrapAdd,data);
+ else {
+ ProcessInputProc *ptr = data;
+ XevieWrap(device,*ptr);
+ }
+
+ return TRUE;
+}
+
+static Bool
+XevieAdd(DeviceIntPtr device, void* data)
+{
+ xevieDeviceInfoPtr xeviep;
+
+ if (!AllocateDevicePrivate(device, xevieDevicePrivateIndex))
+ return FALSE;
+
+ xeviep = xalloc (sizeof (xevieDeviceInfoRec));
+ if (!xeviep)
+ return FALSE;
+
+ device->devPrivates[xevieDevicePrivateIndex].ptr = xeviep;
+ XevieUnwrapAdd(device, data);
+
+ return TRUE;
+}
+
+static Bool
+XevieRemove(DeviceIntPtr device,pointer data)
+{
+ xevieDeviceInfoPtr xeviep = XEVIEINFO(device);
+
+ if (!xeviep) return TRUE;
+
+ UNWRAP_INPUTPROC(device,xeviep);
+ UNWRAP_UNWRAPPROC(device,xeviep->unwrapProc);
+
+ xfree(xeviep);
+ device->devPrivates[xevieDevicePrivateIndex].ptr = NULL;
+ return TRUE;
+}
+
+static void
+XevieWrap(DeviceIntPtr device, ProcessInputProc proc)
+{
+ xevieDeviceInfoPtr xeviep = XEVIEINFO(device);
+
+ WRAP_INPUTPROC(device,xeviep,proc);
+ WRAP_UNWRAPPROC(device,xeviep->unwrapProc,xevieUnwrapProc);
+}
+
+static void
+doSendEvent(xEvent *xE, DeviceIntPtr dev)
+{
+ xevieDeviceInfoPtr xeviep = XEVIEINFO(dev);
+ ProcessInputProc tmp = dev->public.realInputProc;
+ if (((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))
+ && !xevieModifiersOn) {
+ KeyClassPtr keyc = dev->key;
+ CARD8 realModes = dev->key->modifierMap[xE->u.u.detail];
+ int notFound = 0;
+ /* if some events are consumed by client, move the queue tail pointer to the current
+ event which just comes back from Xevie client .
+ */
+ if(keycq[keycqTail].time != xE->u.keyButtonPointer.time) {
+ while(keycq[keycqTail].time != xE->u.keyButtonPointer.time) {
+ if(++keycqTail >= KEYC_QUEUE_SIZE)
+ keycqTail = 0;
+ if(keycqTail == keycqHead) {
+ notFound = 1;
+ break;
+ }
+ }
+ }
+ if(!notFound) {
+ dev->key = keycq[keycqTail].keyc;
+ if(++keycqTail >= KEYC_QUEUE_SIZE)
+ keycqTail = 0;
+ }
+ dev->key->modifierMap[xE->u.u.detail] = 0;
+
+ if(dev->key->xkbInfo->repeatKey != 0 && xE->u.u.type != KeyPress)
+ XkbLastRepeatEvent= (pointer)xE;
+ UNWRAP_INPUTPROC(dev,xeviep);
+ dev->public.processInputProc(xE,dev,1);
+ COND_WRAP_INPUTPROC(dev,xeviep,tmp);
+ XkbLastRepeatEvent= NULL;
+
+ dev->key->modifierMap[xE->u.u.detail] = realModes;
+ dev->key = keyc;
+ if(notFound) {
+ DeleteCallback(&ClientStateCallback,XevieClientStateCallback,NULL);
+ XevieEnd(xevieClientIndex);
+ ErrorF("Error: Xevie keyc queue size is not enough, disable Xevie\n");
+ }
+ } else {
+ UNWRAP_INPUTPROC(dev,xeviep);
+ dev->public.processInputProc(xE,dev,1);
+ COND_WRAP_INPUTPROC(dev,xeviep,tmp);
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/Xext/xf86bigfont.c b/nx-X11/programs/Xserver/Xext/xf86bigfont.c
new file mode 100644
index 000000000..36af17622
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xf86bigfont.c
@@ -0,0 +1,790 @@
+/* $XFree86: xc/programs/Xserver/Xext/xf86bigfont.c,v 1.17 2003/10/28 23:08:43 tsi Exp $ */
+/*
+ * BIGFONT extension for sharing font metrics between clients (if possible)
+ * and for transmitting font metrics to clients in a compressed form.
+ *
+ * Copyright (c) 1999-2000 Bruno Haible
+ * Copyright (c) 1999-2000 The XFree86 Project, Inc.
+ */
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+/*
+ * Big fonts suffer from the following: All clients that have opened a
+ * font can access the complete glyph metrics array (the XFontStruct member
+ * `per_char') directly, without going through a macro. Moreover these
+ * glyph metrics are ink metrics, i.e. are not redundant even for a
+ * fixed-width font. For a Unicode font, the size of this array is 768 KB.
+ *
+ * Problems: 1. It eats a lot of memory in each client. 2. All this glyph
+ * metrics data is piped through the socket when the font is opened.
+ *
+ * This extension addresses these two problems for local clients, by using
+ * shared memory. It also addresses the second problem for non-local clients,
+ * by compressing the data before transmit by a factor of nearly 6.
+ *
+ * If you use this extension, your OS ought to nicely support shared memory.
+ * This means: Shared memory should be swappable to the swap, and the limits
+ * should be high enough (SHMMNI at least 64, SHMMAX at least 768 KB,
+ * SHMALL at least 48 MB). It is a plus if your OS allows shmat() calls
+ * on segments that have already been marked "removed", because it permits
+ * these segments to be cleaned up by the OS if the X server is killed with
+ * signal SIGKILL.
+ *
+ * This extension is transparently exploited by Xlib (functions XQueryFont,
+ * XLoadQueryFont).
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <sys/types.h>
+#ifdef HAS_SHM
+#if defined(linux) && (!defined(__GNU_LIBRARY__) || __GNU_LIBRARY__ < 2)
+/* libc4 does not define __GNU_LIBRARY__, libc5 defines __GNU_LIBRARY__ as 1 */
+/* Linux libc4 and libc5 only (because glibc doesn't include kernel headers):
+ Linux 2.0.x and 2.2.x define SHMLBA as PAGE_SIZE, but forget to define
+ PAGE_SIZE. It is defined in <asm/page.h>. */
+#include <asm/page.h>
+#endif
+#ifdef SVR4
+#include <sys/sysmacros.h>
+#endif
+#if defined(ISC) || defined(__CYGWIN__) || defined(__SCO__)
+#include <sys/param.h>
+#include <sys/sysmacros.h>
+#endif
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+#include <errno.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "dixfontstr.h"
+#include "extnsionst.h"
+
+#define _XF86BIGFONT_SERVER_
+#include <X11/extensions/xf86bigfstr.h>
+
+static void XF86BigfontResetProc(
+ ExtensionEntry * /* extEntry */
+ );
+
+static DISPATCH_PROC(ProcXF86BigfontDispatch);
+static DISPATCH_PROC(ProcXF86BigfontQueryVersion);
+static DISPATCH_PROC(ProcXF86BigfontQueryFont);
+static DISPATCH_PROC(SProcXF86BigfontDispatch);
+static DISPATCH_PROC(SProcXF86BigfontQueryVersion);
+static DISPATCH_PROC(SProcXF86BigfontQueryFont);
+
+#if 0
+static unsigned char XF86BigfontReqCode;
+#endif
+
+#ifdef HAS_SHM
+
+/* A random signature, transmitted to the clients so they can verify that the
+ shared memory segment they are attaching to was really established by the
+ X server they are talking to. */
+static CARD32 signature;
+
+/* Index for additional information stored in a FontRec's devPrivates array. */
+static int FontShmdescIndex;
+
+static unsigned int pagesize;
+
+static Bool badSysCall = FALSE;
+
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__)
+
+#include <sys/signal.h>
+
+static void
+SigSysHandler(
+ int signo)
+{
+ badSysCall = TRUE;
+}
+
+static Bool
+CheckForShmSyscall(void)
+{
+ void (*oldHandler)(int);
+ int shmid = -1;
+
+ /* If no SHM support in the kernel, the bad syscall will generate SIGSYS */
+ oldHandler = signal(SIGSYS, SigSysHandler);
+
+ badSysCall = FALSE;
+ shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT);
+ if (shmid != -1)
+ {
+ /* Successful allocation - clean up */
+ shmctl(shmid, IPC_RMID, (struct shmid_ds *)NULL);
+ }
+ else
+ {
+ /* Allocation failed */
+ badSysCall = TRUE;
+ }
+ signal(SIGSYS, oldHandler);
+ return (!badSysCall);
+}
+
+#define MUST_CHECK_FOR_SHM_SYSCALL
+
+#endif
+
+#endif
+
+void
+XFree86BigfontExtensionInit()
+{
+#if 0
+ ExtensionEntry* extEntry;
+
+ if ((extEntry = AddExtension(XF86BIGFONTNAME,
+ XF86BigfontNumberEvents,
+ XF86BigfontNumberErrors,
+ ProcXF86BigfontDispatch,
+ SProcXF86BigfontDispatch,
+ XF86BigfontResetProc,
+ StandardMinorOpcode))) {
+ XF86BigfontReqCode = (unsigned char) extEntry->base;
+#else
+ if (AddExtension(XF86BIGFONTNAME,
+ XF86BigfontNumberEvents,
+ XF86BigfontNumberErrors,
+ ProcXF86BigfontDispatch,
+ SProcXF86BigfontDispatch,
+ XF86BigfontResetProc,
+ StandardMinorOpcode)) {
+#endif
+#ifdef HAS_SHM
+#ifdef MUST_CHECK_FOR_SHM_SYSCALL
+ /*
+ * Note: Local-clients will not be optimized without shared memory
+ * support. Remote-client optimization does not depend on shared
+ * memory support. Thus, the extension is still registered even
+ * when shared memory support is not functional.
+ */
+ if (!CheckForShmSyscall()) {
+ ErrorF(XF86BIGFONTNAME " extension local-client optimization disabled due to lack of shared memory support in the kernel\n");
+ return;
+ }
+#endif
+
+ srand((unsigned int) time(NULL));
+ signature = ((unsigned int) (65536.0/(RAND_MAX+1.0) * rand()) << 16)
+ + (unsigned int) (65536.0/(RAND_MAX+1.0) * rand());
+ /* fprintf(stderr, "signature = 0x%08X\n", signature); */
+
+ FontShmdescIndex = AllocateFontPrivateIndex();
+
+#if !defined(CSRG_BASED) && !defined(__CYGWIN__)
+ pagesize = SHMLBA;
+#else
+# ifdef _SC_PAGESIZE
+ pagesize = sysconf(_SC_PAGESIZE);
+# else
+ pagesize = getpagesize();
+# endif
+#endif
+#endif
+ }
+}
+
+
+/* ========== Management of shared memory segments ========== */
+
+#ifdef HAS_SHM
+
+#ifdef __linux__
+/* On Linux, shared memory marked as "removed" can still be attached.
+ Nice feature, because the kernel will automatically free the associated
+ storage when the server and all clients are gone. */
+#define EARLY_REMOVE
+#endif
+
+typedef struct _ShmDesc {
+ struct _ShmDesc *next;
+ struct _ShmDesc **prev;
+ int shmid;
+ char *attach_addr;
+} ShmDescRec, *ShmDescPtr;
+
+static ShmDescPtr ShmList = (ShmDescPtr) NULL;
+
+static ShmDescPtr
+shmalloc(
+ unsigned int size)
+{
+ ShmDescPtr pDesc;
+ int shmid;
+ char *addr;
+
+#ifdef MUST_CHECK_FOR_SHM_SYSCALL
+ if (pagesize == 0)
+ return (ShmDescPtr) NULL;
+#endif
+
+ /* On some older Linux systems, the number of shared memory segments
+ system-wide is 127. In Linux 2.4, it is 4095.
+ Therefore there is a tradeoff to be made between allocating a
+ shared memory segment on one hand, and allocating memory and piping
+ the glyph metrics on the other hand. If the glyph metrics size is
+ small, we prefer the traditional way. */
+ if (size < 3500)
+ return (ShmDescPtr) NULL;
+
+ pDesc = (ShmDescRec *) xalloc(sizeof(ShmDescRec));
+ if (!pDesc)
+ return (ShmDescPtr) NULL;
+
+ size = (size + pagesize-1) & -pagesize;
+ shmid = shmget(IPC_PRIVATE, size, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH);
+ if (shmid == -1) {
+ ErrorF(XF86BIGFONTNAME " extension: shmget() failed, size = %u, errno = %d\n",
+ size, errno);
+ xfree(pDesc);
+ return (ShmDescPtr) NULL;
+ }
+
+ if ((addr = shmat(shmid, 0, 0)) == (char *)-1) {
+ ErrorF(XF86BIGFONTNAME " extension: shmat() failed, size = %u, errno = %d\n",
+ size, errno);
+ shmctl(shmid, IPC_RMID, (void *) 0);
+ xfree(pDesc);
+ return (ShmDescPtr) NULL;
+ }
+
+#ifdef EARLY_REMOVE
+ shmctl(shmid, IPC_RMID, (void *) 0);
+#endif
+
+ pDesc->shmid = shmid;
+ pDesc->attach_addr = addr;
+ if (ShmList) ShmList->prev = &pDesc->next;
+ pDesc->next = ShmList;
+ pDesc->prev = &ShmList;
+ ShmList = pDesc;
+
+ return pDesc;
+}
+
+static void
+shmdealloc(
+ ShmDescPtr pDesc)
+{
+#ifndef EARLY_REMOVE
+ shmctl(pDesc->shmid, IPC_RMID, (void *) 0);
+#endif
+ shmdt(pDesc->attach_addr);
+
+ if (pDesc->next) pDesc->next->prev = pDesc->prev;
+ *pDesc->prev = pDesc->next;
+ xfree(pDesc);
+}
+
+#endif
+
+/* Called when a font is closed. */
+void
+XF86BigfontFreeFontShm(
+ FontPtr pFont)
+{
+#ifdef HAS_SHM
+ ShmDescPtr pDesc;
+
+ /* If during shutdown of the server, XF86BigfontCleanup() has already
+ * called shmdealloc() for all segments, we don't need to do it here.
+ */
+ if (!ShmList)
+ return;
+
+ pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex);
+ if (pDesc)
+ shmdealloc(pDesc);
+#endif
+}
+
+/* Called upon fatal signal. */
+void
+XF86BigfontCleanup()
+{
+#ifdef HAS_SHM
+ while (ShmList)
+ shmdealloc(ShmList);
+#endif
+}
+
+/* Called when a server generation dies. */
+static void
+XF86BigfontResetProc(
+ ExtensionEntry* extEntry)
+{
+ /* This function is normally called from CloseDownExtensions(), called
+ * from main(). It will be followed by a call to FreeAllResources(),
+ * which will call XF86BigfontFreeFontShm() for each font. Thus it
+ * appears that we do not need to do anything in this function. --
+ * But I prefer to write robust code, and not keep shared memory lying
+ * around when it's not needed any more. (Someone might close down the
+ * extension without calling FreeAllResources()...)
+ */
+ XF86BigfontCleanup();
+}
+
+
+/* ========== Handling of extension specific requests ========== */
+
+static int
+ProcXF86BigfontQueryVersion(
+ ClientPtr client)
+{
+ xXF86BigfontQueryVersionReply reply;
+
+ REQUEST_SIZE_MATCH(xXF86BigfontQueryVersionReq);
+ reply.type = X_Reply;
+ reply.length = 0;
+ reply.sequenceNumber = client->sequence;
+ reply.majorVersion = XF86BIGFONT_MAJOR_VERSION;
+ reply.minorVersion = XF86BIGFONT_MINOR_VERSION;
+ reply.uid = geteuid();
+ reply.gid = getegid();
+#ifdef HAS_SHM
+ reply.signature = signature;
+#else
+ reply.signature = 0; /* This is redundant. Avoids uninitialized memory. */
+#endif
+ reply.capabilities =
+#ifdef HAS_SHM
+ (LocalClient(client) && !client->swapped ? XF86Bigfont_CAP_LocalShm : 0)
+#else
+ 0
+#endif
+ ; /* may add more bits here in future versions */
+ if (client->swapped) {
+ char tmp;
+ swaps(&reply.sequenceNumber, tmp);
+ swapl(&reply.length, tmp);
+ swaps(&reply.majorVersion, tmp);
+ swaps(&reply.minorVersion, tmp);
+ swapl(&reply.uid, tmp);
+ swapl(&reply.gid, tmp);
+ swapl(&reply.signature, tmp);
+ }
+ WriteToClient(client,
+ sizeof(xXF86BigfontQueryVersionReply), (char *)&reply);
+ return client->noClientException;
+}
+
+static void
+swapCharInfo(
+ xCharInfo *pCI)
+{
+ char tmp;
+
+ swaps(&pCI->leftSideBearing, tmp);
+ swaps(&pCI->rightSideBearing, tmp);
+ swaps(&pCI->characterWidth, tmp);
+ swaps(&pCI->ascent, tmp);
+ swaps(&pCI->descent, tmp);
+ swaps(&pCI->attributes, tmp);
+}
+
+/* static CARD32 hashCI (xCharInfo *p); */
+#define hashCI(p) \
+ (CARD32)(((p->leftSideBearing << 27) + (p->leftSideBearing >> 5) + \
+ (p->rightSideBearing << 23) + (p->rightSideBearing >> 9) + \
+ (p->characterWidth << 16) + \
+ (p->ascent << 11) + (p->descent << 6)) ^ p->attributes)
+
+static int
+ProcXF86BigfontQueryFont(
+ ClientPtr client)
+{
+ FontPtr pFont;
+ REQUEST(xXF86BigfontQueryFontReq);
+ CARD32 stuff_flags;
+ xCharInfo* pmax;
+ xCharInfo* pmin;
+ int nCharInfos;
+ int shmid;
+#ifdef HAS_SHM
+ ShmDescPtr pDesc;
+#else
+#define pDesc 0
+#endif
+ xCharInfo* pCI;
+ CARD16* pIndex2UniqIndex;
+ CARD16* pUniqIndex2Index;
+ CARD32 nUniqCharInfos;
+
+#if 0
+ REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq);
+#else
+ switch (client->req_len) {
+ case 2: /* client with version 1.0 libX11 */
+ stuff_flags = (LocalClient(client) && !client->swapped ? XF86Bigfont_FLAGS_Shm : 0);
+ break;
+ case 3: /* client with version 1.1 libX11 */
+ stuff_flags = stuff->flags;
+ break;
+ default:
+ return BadLength;
+ }
+#endif
+ client->errorValue = stuff->id; /* EITHER font or gc */
+ pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT,
+ SecurityReadAccess);
+ if (!pFont) {
+ /* can't use VERIFY_GC because it might return BadGC */
+ GC *pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC,
+ SecurityReadAccess);
+ if (!pGC) {
+ client->errorValue = stuff->id;
+ return BadFont; /* procotol spec says only error is BadFont */
+ }
+ pFont = pGC->font;
+ }
+
+ pmax = FONTINKMAX(pFont);
+ pmin = FONTINKMIN(pFont);
+ nCharInfos =
+ (pmax->rightSideBearing == pmin->rightSideBearing
+ && pmax->leftSideBearing == pmin->leftSideBearing
+ && pmax->descent == pmin->descent
+ && pmax->ascent == pmin->ascent
+ && pmax->characterWidth == pmin->characterWidth)
+ ? 0 : N2dChars(pFont);
+ shmid = -1;
+ pCI = NULL;
+ pIndex2UniqIndex = NULL;
+ pUniqIndex2Index = NULL;
+ nUniqCharInfos = 0;
+
+ if (nCharInfos > 0) {
+#ifdef HAS_SHM
+ if (!badSysCall)
+ pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex);
+ else
+ pDesc = NULL;
+ if (pDesc) {
+ pCI = (xCharInfo *) pDesc->attach_addr;
+ if (stuff_flags & XF86Bigfont_FLAGS_Shm)
+ shmid = pDesc->shmid;
+ } else {
+ if (stuff_flags & XF86Bigfont_FLAGS_Shm && !badSysCall)
+ pDesc = shmalloc(nCharInfos * sizeof(xCharInfo)
+ + sizeof(CARD32));
+ if (pDesc) {
+ pCI = (xCharInfo *) pDesc->attach_addr;
+ shmid = pDesc->shmid;
+ } else {
+#endif
+ pCI = (xCharInfo *)
+ ALLOCATE_LOCAL(nCharInfos * sizeof(xCharInfo));
+ if (!pCI)
+ return BadAlloc;
+#ifdef HAS_SHM
+ }
+#endif
+ /* Fill nCharInfos starting at pCI. */
+ {
+ xCharInfo* prCI = pCI;
+ int ninfos = 0;
+ int ncols = pFont->info.lastCol - pFont->info.firstCol + 1;
+ int row;
+ for (row = pFont->info.firstRow;
+ row <= pFont->info.lastRow && ninfos < nCharInfos;
+ row++) {
+ unsigned char chars[512];
+ xCharInfo* tmpCharInfos[256];
+ unsigned long count;
+ int col;
+ unsigned long i;
+ i = 0;
+ for (col = pFont->info.firstCol;
+ col <= pFont->info.lastCol;
+ col++) {
+ chars[i++] = row;
+ chars[i++] = col;
+ }
+ (*pFont->get_metrics) (pFont, ncols, chars, TwoD16Bit,
+ &count, tmpCharInfos);
+ for (i = 0; i < count && ninfos < nCharInfos; i++) {
+ *prCI++ = *tmpCharInfos[i];
+ ninfos++;
+ }
+ }
+ }
+#ifdef HAS_SHM
+ if (pDesc && !badSysCall) {
+ *(CARD32 *)(pCI + nCharInfos) = signature;
+ if (!FontSetPrivate(pFont, FontShmdescIndex, pDesc)) {
+ shmdealloc(pDesc);
+ return BadAlloc;
+ }
+ }
+ }
+#endif
+ if (shmid == -1) {
+ /* Cannot use shared memory, so remove-duplicates the xCharInfos
+ using a temporary hash table. */
+ /* Note that CARD16 is suitable as index type, because
+ nCharInfos <= 0x10000. */
+ CARD32 hashModulus;
+ CARD16* pHash2UniqIndex;
+ CARD16* pUniqIndex2NextUniqIndex;
+ CARD32 NextIndex;
+ CARD32 NextUniqIndex;
+ CARD16* tmp;
+ CARD32 i, j;
+
+ hashModulus = 67;
+ if (hashModulus > nCharInfos+1)
+ hashModulus = nCharInfos+1;
+
+ tmp = (CARD16*)
+ ALLOCATE_LOCAL((4*nCharInfos+1) * sizeof(CARD16));
+ if (!tmp) {
+ if (!pDesc) DEALLOCATE_LOCAL(pCI);
+ return BadAlloc;
+ }
+ pIndex2UniqIndex = tmp;
+ /* nCharInfos elements */
+ pUniqIndex2Index = tmp + nCharInfos;
+ /* max. nCharInfos elements */
+ pUniqIndex2NextUniqIndex = tmp + 2*nCharInfos;
+ /* max. nCharInfos elements */
+ pHash2UniqIndex = tmp + 3*nCharInfos;
+ /* hashModulus (<= nCharInfos+1) elements */
+
+ /* Note that we can use 0xffff as end-of-list indicator, because
+ even if nCharInfos = 0x10000, 0xffff can not occur as valid
+ entry before the last element has been inserted. And once the
+ last element has been inserted, we don't need the hash table
+ any more. */
+ for (j = 0; j < hashModulus; j++)
+ pHash2UniqIndex[j] = (CARD16)(-1);
+
+ NextUniqIndex = 0;
+ for (NextIndex = 0; NextIndex < nCharInfos; NextIndex++) {
+ xCharInfo* p = &pCI[NextIndex];
+ CARD32 hashCode = hashCI(p) % hashModulus;
+ for (i = pHash2UniqIndex[hashCode];
+ i != (CARD16)(-1);
+ i = pUniqIndex2NextUniqIndex[i]) {
+ j = pUniqIndex2Index[i];
+ if (pCI[j].leftSideBearing == p->leftSideBearing
+ && pCI[j].rightSideBearing == p->rightSideBearing
+ && pCI[j].characterWidth == p->characterWidth
+ && pCI[j].ascent == p->ascent
+ && pCI[j].descent == p->descent
+ && pCI[j].attributes == p->attributes)
+ break;
+ }
+ if (i != (CARD16)(-1)) {
+ /* Found *p at Index j, UniqIndex i */
+ pIndex2UniqIndex[NextIndex] = i;
+ } else {
+ /* Allocate a new entry in the Uniq table */
+ if (hashModulus <= 2*NextUniqIndex
+ && hashModulus < nCharInfos+1) {
+ /* Time to increate hash table size */
+ hashModulus = 2*hashModulus+1;
+ if (hashModulus > nCharInfos+1)
+ hashModulus = nCharInfos+1;
+ for (j = 0; j < hashModulus; j++)
+ pHash2UniqIndex[j] = (CARD16)(-1);
+ for (i = 0; i < NextUniqIndex; i++)
+ pUniqIndex2NextUniqIndex[i] = (CARD16)(-1);
+ for (i = 0; i < NextUniqIndex; i++) {
+ j = pUniqIndex2Index[i];
+ p = &pCI[j];
+ hashCode = hashCI(p) % hashModulus;
+ pUniqIndex2NextUniqIndex[i] = pHash2UniqIndex[hashCode];
+ pHash2UniqIndex[hashCode] = i;
+ }
+ p = &pCI[NextIndex];
+ hashCode = hashCI(p) % hashModulus;
+ }
+ i = NextUniqIndex++;
+ pUniqIndex2NextUniqIndex[i] = pHash2UniqIndex[hashCode];
+ pHash2UniqIndex[hashCode] = i;
+ pUniqIndex2Index[i] = NextIndex;
+ pIndex2UniqIndex[NextIndex] = i;
+ }
+ }
+ nUniqCharInfos = NextUniqIndex;
+ /* fprintf(stderr, "font metrics: nCharInfos = %d, nUniqCharInfos = %d, hashModulus = %d\n", nCharInfos, nUniqCharInfos, hashModulus); */
+ }
+ }
+
+ {
+ int nfontprops = pFont->info.nprops;
+ int rlength =
+ sizeof(xXF86BigfontQueryFontReply)
+ + nfontprops * sizeof(xFontProp)
+ + (nCharInfos > 0 && shmid == -1
+ ? nUniqCharInfos * sizeof(xCharInfo)
+ + (nCharInfos+1)/2 * 2 * sizeof(CARD16)
+ : 0);
+ xXF86BigfontQueryFontReply* reply =
+ (xXF86BigfontQueryFontReply *) ALLOCATE_LOCAL(rlength);
+ char* p;
+ if (!reply) {
+ if (nCharInfos > 0) {
+ if (shmid == -1) DEALLOCATE_LOCAL(pIndex2UniqIndex);
+ if (!pDesc) DEALLOCATE_LOCAL(pCI);
+ }
+ return BadAlloc;
+ }
+ reply->type = X_Reply;
+ reply->length = (rlength - sizeof(xGenericReply)) >> 2;
+ reply->sequenceNumber = client->sequence;
+ reply->minBounds = pFont->info.ink_minbounds;
+ reply->maxBounds = pFont->info.ink_maxbounds;
+ reply->minCharOrByte2 = pFont->info.firstCol;
+ reply->maxCharOrByte2 = pFont->info.lastCol;
+ reply->defaultChar = pFont->info.defaultCh;
+ reply->nFontProps = pFont->info.nprops;
+ reply->drawDirection = pFont->info.drawDirection;
+ reply->minByte1 = pFont->info.firstRow;
+ reply->maxByte1 = pFont->info.lastRow;
+ reply->allCharsExist = pFont->info.allExist;
+ reply->fontAscent = pFont->info.fontAscent;
+ reply->fontDescent = pFont->info.fontDescent;
+ reply->nCharInfos = nCharInfos;
+ reply->nUniqCharInfos = nUniqCharInfos;
+ reply->shmid = shmid;
+ reply->shmsegoffset = 0;
+ if (client->swapped) {
+ char tmp;
+ swaps(&reply->sequenceNumber, tmp);
+ swapl(&reply->length, tmp);
+ swapCharInfo(&reply->minBounds);
+ swapCharInfo(&reply->maxBounds);
+ swaps(&reply->minCharOrByte2, tmp);
+ swaps(&reply->maxCharOrByte2, tmp);
+ swaps(&reply->defaultChar, tmp);
+ swaps(&reply->nFontProps, tmp);
+ swaps(&reply->fontAscent, tmp);
+ swaps(&reply->fontDescent, tmp);
+ swapl(&reply->nCharInfos, tmp);
+ swapl(&reply->nUniqCharInfos, tmp);
+ swapl(&reply->shmid, tmp);
+ swapl(&reply->shmsegoffset, tmp);
+ }
+ p = (char*) &reply[1];
+ {
+ FontPropPtr pFP;
+ xFontProp* prFP;
+ int i;
+ for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) p;
+ i < nfontprops;
+ i++, pFP++, prFP++) {
+ prFP->name = pFP->name;
+ prFP->value = pFP->value;
+ if (client->swapped) {
+ char tmp;
+ swapl(&prFP->name, tmp);
+ swapl(&prFP->value, tmp);
+ }
+ }
+ p = (char*) prFP;
+ }
+ if (nCharInfos > 0 && shmid == -1) {
+ xCharInfo* pci;
+ CARD16* ps;
+ int i, j;
+ pci = (xCharInfo*) p;
+ for (i = 0; i < nUniqCharInfos; i++, pci++) {
+ *pci = pCI[pUniqIndex2Index[i]];
+ if (client->swapped)
+ swapCharInfo(pci);
+ }
+ ps = (CARD16*) pci;
+ for (j = 0; j < nCharInfos; j++, ps++) {
+ *ps = pIndex2UniqIndex[j];
+ if (client->swapped) {
+ char tmp;
+ swaps(ps, tmp);
+ }
+ }
+ }
+ WriteToClient(client, rlength, (char *)reply);
+ DEALLOCATE_LOCAL(reply);
+ if (nCharInfos > 0) {
+ if (shmid == -1) DEALLOCATE_LOCAL(pIndex2UniqIndex);
+ if (!pDesc) DEALLOCATE_LOCAL(pCI);
+ }
+ return (client->noClientException);
+ }
+}
+
+static int
+ProcXF86BigfontDispatch(
+ ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data) {
+ case X_XF86BigfontQueryVersion:
+ return ProcXF86BigfontQueryVersion(client);
+ case X_XF86BigfontQueryFont:
+ return ProcXF86BigfontQueryFont(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static int
+SProcXF86BigfontQueryVersion(
+ ClientPtr client)
+{
+ REQUEST(xXF86BigfontQueryVersionReq);
+ char tmp;
+
+ swaps(&stuff->length, tmp);
+ return ProcXF86BigfontQueryVersion(client);
+}
+
+static int
+SProcXF86BigfontQueryFont(
+ ClientPtr client)
+{
+ REQUEST(xXF86BigfontQueryFontReq);
+ char tmp;
+
+ swaps(&stuff->length, tmp);
+ REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq);
+ swapl(&stuff->id, tmp);
+ return ProcXF86BigfontQueryFont(client);
+}
+
+static int
+SProcXF86BigfontDispatch(
+ ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data) {
+ case X_XF86BigfontQueryVersion:
+ return SProcXF86BigfontQueryVersion(client);
+ case X_XF86BigfontQueryFont:
+ return SProcXF86BigfontQueryFont(client);
+ default:
+ return BadRequest;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xext/xf86dga.c b/nx-X11/programs/Xserver/Xext/xf86dga.c
new file mode 100644
index 000000000..9979bfb30
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xf86dga.c
@@ -0,0 +1,307 @@
+/* $XFree86: xc/programs/Xserver/Xext/xf86dga.c,v 3.21 2000/06/30 19:06:54 keithp Exp $ */
+
+/*
+
+Copyright (c) 1995 Jon Tombs
+Copyright (c) 1995, 1996, 1999 XFree86 Inc
+
+*/
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#define _XF86DGA_SERVER_
+#include <X11/extensions/xf86dga.h>
+#include <X11/extensions/xf86dgastr.h>
+#include "swaprep.h"
+#include "dgaproc.h"
+
+#include "xf86dgaext.h"
+
+
+static DISPATCH_PROC(ProcXF86DGADirectVideo);
+static DISPATCH_PROC(ProcXF86DGAGetVidPage);
+static DISPATCH_PROC(ProcXF86DGAGetVideoLL);
+static DISPATCH_PROC(ProcXF86DGAGetViewPortSize);
+static DISPATCH_PROC(ProcXF86DGASetVidPage);
+static DISPATCH_PROC(ProcXF86DGASetViewPort);
+static DISPATCH_PROC(ProcXF86DGAInstallColormap);
+static DISPATCH_PROC(ProcXF86DGAQueryDirectVideo);
+static DISPATCH_PROC(ProcXF86DGAViewPortChanged);
+
+
+static int
+ProcXF86DGAGetVideoLL(ClientPtr client)
+{
+ REQUEST(xXF86DGAGetVideoLLReq);
+ xXF86DGAGetVideoLLReply rep;
+ XDGAModeRec mode;
+ int num, offset, flags;
+ char *name;
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86DGAGetVideoLLReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if(!DGAAvailable(stuff->screen))
+ return (DGAErrorBase + XF86DGANoDirectVideoMode);
+
+ if(!(num = DGAGetOldDGAMode(stuff->screen)))
+ return (DGAErrorBase + XF86DGANoDirectVideoMode);
+
+ /* get the parameters for the mode that best matches */
+ DGAGetModeInfo(stuff->screen, &mode, num);
+
+ if(!DGAOpenFramebuffer(stuff->screen, &name,
+ (unsigned char**)(&rep.offset),
+ (int*)(&rep.bank_size), &offset, &flags))
+ return BadAlloc;
+
+ rep.offset += mode.offset;
+ rep.width = mode.bytesPerScanline / (mode.bitsPerPixel >> 3);
+ rep.ram_size = rep.bank_size >> 10;
+
+ WriteToClient(client, SIZEOF(xXF86DGAGetVideoLLReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DGADirectVideo(ClientPtr client)
+{
+ int num;
+ PixmapPtr pix;
+ XDGAModeRec mode;
+ REQUEST(xXF86DGADirectVideoReq);
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq);
+
+ if (!DGAAvailable(stuff->screen))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
+ if (stuff->enable & XF86DGADirectGraphics) {
+ if(!(num = DGAGetOldDGAMode(stuff->screen)))
+ return (DGAErrorBase + XF86DGANoDirectVideoMode);
+ } else
+ num = 0;
+
+ if(Success != DGASetMode(stuff->screen, num, &mode, &pix))
+ return (DGAErrorBase + XF86DGAScreenNotActive);
+
+ DGASetInputMode (stuff->screen,
+ (stuff->enable & XF86DGADirectKeyb) != 0,
+ (stuff->enable & XF86DGADirectMouse) != 0);
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DGAGetViewPortSize(ClientPtr client)
+{
+ int num;
+ XDGAModeRec mode;
+ REQUEST(xXF86DGAGetViewPortSizeReq);
+ xXF86DGAGetViewPortSizeReply rep;
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86DGAGetViewPortSizeReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!DGAAvailable(stuff->screen))
+ return (DGAErrorBase + XF86DGANoDirectVideoMode);
+
+ if(!(num = DGAGetOldDGAMode(stuff->screen)))
+ return (DGAErrorBase + XF86DGANoDirectVideoMode);
+
+ DGAGetModeInfo(stuff->screen, &mode, num);
+
+ rep.width = mode.viewportWidth;
+ rep.height = mode.viewportHeight;
+
+ WriteToClient(client, SIZEOF(xXF86DGAGetViewPortSizeReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DGASetViewPort(ClientPtr client)
+{
+ REQUEST(xXF86DGASetViewPortReq);
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86DGASetViewPortReq);
+
+ if (!DGAActive(stuff->screen))
+ {
+ int num;
+ PixmapPtr pix;
+ XDGAModeRec mode;
+
+ if(!(num = DGAGetOldDGAMode(stuff->screen)))
+ return (DGAErrorBase + XF86DGANoDirectVideoMode);
+ if(Success != DGASetMode(stuff->screen, num, &mode, &pix))
+ return (DGAErrorBase + XF86DGAScreenNotActive);
+ }
+
+ if (DGASetViewport(stuff->screen, stuff->x, stuff->y, DGA_FLIP_RETRACE)
+ != Success)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DGAGetVidPage(ClientPtr client)
+{
+ REQUEST(xXF86DGAGetVidPageReq);
+ xXF86DGAGetVidPageReply rep;
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86DGAGetVidPageReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.vpage = 0; /* silently fail */
+
+ WriteToClient(client, SIZEOF(xXF86DGAGetVidPageReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+
+static int
+ProcXF86DGASetVidPage(ClientPtr client)
+{
+ REQUEST(xXF86DGASetVidPageReq);
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86DGASetVidPageReq);
+
+ /* silently fail */
+
+ return (client->noClientException);
+}
+
+
+static int
+ProcXF86DGAInstallColormap(ClientPtr client)
+{
+ ColormapPtr pcmp;
+ REQUEST(xXF86DGAInstallColormapReq);
+
+ REQUEST_SIZE_MATCH(xXF86DGAInstallColormapReq);
+
+ if (!DGAActive(stuff->screen))
+ return (DGAErrorBase + XF86DGADirectNotActivated);
+
+ pcmp = (ColormapPtr )LookupIDByType(stuff->id, RT_COLORMAP);
+ if (pcmp) {
+ DGAInstallCmap(pcmp);
+ return (client->noClientException);
+ } else {
+ client->errorValue = stuff->id;
+ return (BadColor);
+ }
+}
+
+static int
+ProcXF86DGAQueryDirectVideo(ClientPtr client)
+{
+ REQUEST(xXF86DGAQueryDirectVideoReq);
+ xXF86DGAQueryDirectVideoReply rep;
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86DGAQueryDirectVideoReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.flags = 0;
+
+ if (DGAAvailable(stuff->screen))
+ rep.flags = XF86DGADirectPresent;
+
+ WriteToClient(client, SIZEOF(xXF86DGAQueryDirectVideoReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DGAViewPortChanged(ClientPtr client)
+{
+ REQUEST(xXF86DGAViewPortChangedReq);
+ xXF86DGAViewPortChangedReply rep;
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86DGAViewPortChangedReq);
+
+ if (!DGAActive(stuff->screen))
+ return (DGAErrorBase + XF86DGADirectNotActivated);
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.result = 1;
+
+ WriteToClient(client, SIZEOF(xXF86DGAViewPortChangedReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+int
+ProcXF86DGADispatch(register ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_XF86DGAGetVideoLL:
+ return ProcXF86DGAGetVideoLL(client);
+ case X_XF86DGADirectVideo:
+ return ProcXF86DGADirectVideo(client);
+ case X_XF86DGAGetViewPortSize:
+ return ProcXF86DGAGetViewPortSize(client);
+ case X_XF86DGASetViewPort:
+ return ProcXF86DGASetViewPort(client);
+ case X_XF86DGAGetVidPage:
+ return ProcXF86DGAGetVidPage(client);
+ case X_XF86DGASetVidPage:
+ return ProcXF86DGASetVidPage(client);
+ case X_XF86DGAInstallColormap:
+ return ProcXF86DGAInstallColormap(client);
+ case X_XF86DGAQueryDirectVideo:
+ return ProcXF86DGAQueryDirectVideo(client);
+ case X_XF86DGAViewPortChanged:
+ return ProcXF86DGAViewPortChanged(client);
+ default:
+ return BadRequest;
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/Xext/xf86dga2.c b/nx-X11/programs/Xserver/Xext/xf86dga2.c
new file mode 100644
index 000000000..a5cab0f11
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xf86dga2.c
@@ -0,0 +1,775 @@
+/*
+ Copyright (c) 1999 - The XFree86 Project Inc.
+
+ Written by Mark Vojkovich
+*/
+/* $XFree86: xc/programs/Xserver/Xext/xf86dga2.c,v 1.17 2001/10/28 03:32:51 tsi Exp $ */
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "dixevents.h"
+#include "pixmapstr.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#define _XF86DGA_SERVER_
+#include <X11/extensions/xf86dga.h>
+#include <X11/extensions/xf86dgastr.h>
+#include "swaprep.h"
+#include "dgaproc.h"
+#include "xf86dgaext.h"
+
+#ifdef EXTMODULE
+#include "xf86_ansic.h"
+#else
+#include <string.h>
+#endif
+
+#include "modinit.h"
+
+static DISPATCH_PROC(ProcXDGADispatch);
+static DISPATCH_PROC(SProcXDGADispatch);
+static DISPATCH_PROC(ProcXDGAQueryVersion);
+static DISPATCH_PROC(ProcXDGAQueryModes);
+static DISPATCH_PROC(ProcXDGASetMode);
+static DISPATCH_PROC(ProcXDGAOpenFramebuffer);
+static DISPATCH_PROC(ProcXDGACloseFramebuffer);
+static DISPATCH_PROC(ProcXDGASetViewport);
+static DISPATCH_PROC(ProcXDGAInstallColormap);
+static DISPATCH_PROC(ProcXDGASelectInput);
+static DISPATCH_PROC(ProcXDGAFillRectangle);
+static DISPATCH_PROC(ProcXDGACopyArea);
+static DISPATCH_PROC(ProcXDGACopyTransparentArea);
+static DISPATCH_PROC(ProcXDGAGetViewportStatus);
+static DISPATCH_PROC(ProcXDGASync);
+static DISPATCH_PROC(ProcXDGASetClientVersion);
+static DISPATCH_PROC(ProcXDGAChangePixmapMode);
+static DISPATCH_PROC(ProcXDGACreateColormap);
+
+static void XDGAResetProc(ExtensionEntry *extEntry);
+
+static void DGAClientStateChange (CallbackListPtr*, pointer, pointer);
+
+static ClientPtr DGAClients[MAXSCREENS];
+
+unsigned char DGAReqCode = 0;
+int DGAErrorBase;
+int DGAEventBase;
+
+static int DGAGeneration = 0;
+static int DGAClientPrivateIndex;
+static int DGACallbackRefCount = 0;
+
+/* This holds the client's version information */
+typedef struct {
+ int major;
+ int minor;
+} DGAPrivRec, *DGAPrivPtr;
+
+#define DGAPRIV(c) ((c)->devPrivates[DGAClientPrivateIndex].ptr)
+
+void
+XFree86DGAExtensionInit(INITARGS)
+{
+ ExtensionEntry* extEntry;
+
+ if ((extEntry = AddExtension(XF86DGANAME,
+ XF86DGANumberEvents,
+ XF86DGANumberErrors,
+ ProcXDGADispatch,
+ SProcXDGADispatch,
+ XDGAResetProc,
+ StandardMinorOpcode))) {
+ int i;
+
+ for(i = 0; i < MAXSCREENS; i++)
+ DGAClients[i] = NULL;
+
+ DGAReqCode = (unsigned char)extEntry->base;
+ DGAErrorBase = extEntry->errorBase;
+ DGAEventBase = extEntry->eventBase;
+ for (i = KeyPress; i <= MotionNotify; i++)
+ SetCriticalEvent (DGAEventBase + i);
+ }
+
+ /*
+ * Allocate a client private index to hold the client's version
+ * information.
+ */
+ if (DGAGeneration != serverGeneration) {
+ DGAClientPrivateIndex = AllocateClientPrivateIndex();
+ /*
+ * Allocate 0 length, and use the private to hold a pointer to
+ * our DGAPrivRec.
+ */
+ if (!AllocateClientPrivate(DGAClientPrivateIndex, 0)) {
+ ErrorF("XFree86DGAExtensionInit: AllocateClientPrivate failed\n");
+ return;
+ }
+ DGAGeneration = serverGeneration;
+ }
+}
+
+
+
+static void
+XDGAResetProc (ExtensionEntry *extEntry)
+{
+ DeleteCallback (&ClientStateCallback, DGAClientStateChange, NULL);
+ DGACallbackRefCount = 0;
+}
+
+
+static int
+ProcXDGAQueryVersion(ClientPtr client)
+{
+ xXDGAQueryVersionReply rep;
+
+ REQUEST_SIZE_MATCH(xXDGAQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = XDGA_MAJOR_VERSION;
+ rep.minorVersion = XDGA_MINOR_VERSION;
+
+ WriteToClient(client, sizeof(xXDGAQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+
+static int
+ProcXDGAOpenFramebuffer(ClientPtr client)
+{
+ REQUEST(xXDGAOpenFramebufferReq);
+ xXDGAOpenFramebufferReply rep;
+ char *deviceName;
+ int nameSize;
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ if (!DGAAvailable(stuff->screen))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
+ REQUEST_SIZE_MATCH(xXDGAOpenFramebufferReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if(!DGAOpenFramebuffer(stuff->screen, &deviceName,
+ (unsigned char**)(&rep.mem1),
+ (int*)&rep.size, (int*)&rep.offset, (int*)&rep.extra))
+ {
+ return BadAlloc;
+ }
+
+ nameSize = deviceName ? (strlen(deviceName) + 1) : 0;
+ rep.length = (nameSize + 3) >> 2;
+
+ WriteToClient(client, sizeof(xXDGAOpenFramebufferReply), (char *)&rep);
+ if(rep.length)
+ WriteToClient(client, nameSize, deviceName);
+
+ return (client->noClientException);
+}
+
+
+static int
+ProcXDGACloseFramebuffer(ClientPtr client)
+{
+ REQUEST(xXDGACloseFramebufferReq);
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ if (!DGAAvailable(stuff->screen))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
+ REQUEST_SIZE_MATCH(xXDGACloseFramebufferReq);
+
+ DGACloseFramebuffer(stuff->screen);
+
+ return (client->noClientException);
+}
+
+static int
+ProcXDGAQueryModes(ClientPtr client)
+{
+ int i, num, size;
+ REQUEST(xXDGAQueryModesReq);
+ xXDGAQueryModesReply rep;
+ xXDGAModeInfo info;
+ XDGAModePtr mode;
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXDGAQueryModesReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.number = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!DGAAvailable(stuff->screen)) {
+ rep.number = 0;
+ rep.length = 0;
+ WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep);
+ return (client->noClientException);
+ }
+
+ if(!(num = DGAGetModes(stuff->screen))) {
+ WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep);
+ return (client->noClientException);
+ }
+
+ if(!(mode = (XDGAModePtr)xalloc(num * sizeof(XDGAModeRec))))
+ return BadAlloc;
+
+ for(i = 0; i < num; i++)
+ DGAGetModeInfo(stuff->screen, mode + i, i + 1);
+
+ size = num * sz_xXDGAModeInfo;
+ for(i = 0; i < num; i++)
+ size += (strlen(mode[i].name) + 4) & ~3L; /* plus NULL */
+
+ rep.number = num;
+ rep.length = size >> 2;
+
+ WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep);
+
+ for(i = 0; i < num; i++) {
+ size = strlen(mode[i].name) + 1;
+
+ info.byte_order = mode[i].byteOrder;
+ info.depth = mode[i].depth;
+ info.num = mode[i].num;
+ info.bpp = mode[i].bitsPerPixel;
+ info.name_size = (size + 3) & ~3L;
+ info.vsync_num = mode[i].VSync_num;
+ info.vsync_den = mode[i].VSync_den;
+ info.flags = mode[i].flags;
+ info.image_width = mode[i].imageWidth;
+ info.image_height = mode[i].imageHeight;
+ info.pixmap_width = mode[i].pixmapWidth;
+ info.pixmap_height = mode[i].pixmapHeight;
+ info.bytes_per_scanline = mode[i].bytesPerScanline;
+ info.red_mask = mode[i].red_mask;
+ info.green_mask = mode[i].green_mask;
+ info.blue_mask = mode[i].blue_mask;
+ info.visual_class = mode[i].visualClass;
+ info.viewport_width = mode[i].viewportWidth;
+ info.viewport_height = mode[i].viewportHeight;
+ info.viewport_xstep = mode[i].xViewportStep;
+ info.viewport_ystep = mode[i].yViewportStep;
+ info.viewport_xmax = mode[i].maxViewportX;
+ info.viewport_ymax = mode[i].maxViewportY;
+ info.viewport_flags = mode[i].viewportFlags;
+ info.reserved1 = mode[i].reserved1;
+ info.reserved2 = mode[i].reserved2;
+
+ WriteToClient(client, sz_xXDGAModeInfo, (char*)(&info));
+ WriteToClient(client, size, mode[i].name);
+ }
+
+ xfree(mode);
+
+ return (client->noClientException);
+}
+
+
+static void
+DGAClientStateChange (
+ CallbackListPtr* pcbl,
+ pointer nulldata,
+ pointer calldata
+){
+ NewClientInfoRec* pci = (NewClientInfoRec*) calldata;
+ ClientPtr client = NULL;
+ int i;
+
+ for(i = 0; i < screenInfo.numScreens; i++) {
+ if(DGAClients[i] == pci->client) {
+ client = pci->client;
+ break;
+ }
+ }
+
+ if(client &&
+ ((client->clientState == ClientStateGone) ||
+ (client->clientState == ClientStateRetained))) {
+ XDGAModeRec mode;
+ PixmapPtr pPix;
+
+ DGAClients[i] = NULL;
+ DGASelectInput(i, NULL, 0);
+ DGASetMode(i, 0, &mode, &pPix);
+
+ if(--DGACallbackRefCount == 0)
+ DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL);
+ }
+}
+
+static int
+ProcXDGASetMode(ClientPtr client)
+{
+ REQUEST(xXDGASetModeReq);
+ xXDGASetModeReply rep;
+ XDGAModeRec mode;
+ xXDGAModeInfo info;
+ PixmapPtr pPix;
+ int size;
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXDGASetModeReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.offset = 0;
+ rep.flags = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!DGAAvailable(stuff->screen))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
+ if(DGAClients[stuff->screen] &&
+ (DGAClients[stuff->screen] != client))
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
+
+ if(!stuff->mode) {
+ if(DGAClients[stuff->screen]) {
+ if(--DGACallbackRefCount == 0)
+ DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL);
+ }
+ DGAClients[stuff->screen] = NULL;
+ DGASelectInput(stuff->screen, NULL, 0);
+ DGASetMode(stuff->screen, 0, &mode, &pPix);
+ WriteToClient(client, sz_xXDGASetModeReply, (char*)&rep);
+ return (client->noClientException);
+ }
+
+ if(Success != DGASetMode(stuff->screen, stuff->mode, &mode, &pPix))
+ return BadValue;
+
+ if(!DGAClients[stuff->screen]) {
+ if(DGACallbackRefCount++ == 0)
+ AddCallback (&ClientStateCallback, DGAClientStateChange, NULL);
+ }
+
+ DGAClients[stuff->screen] = client;
+
+ if(pPix) {
+ if(AddResource(stuff->pid, RT_PIXMAP, (pointer)(pPix))) {
+ pPix->drawable.id = (int)stuff->pid;
+ rep.flags = DGA_PIXMAP_AVAILABLE;
+ }
+ }
+
+ size = strlen(mode.name) + 1;
+
+ info.byte_order = mode.byteOrder;
+ info.depth = mode.depth;
+ info.num = mode.num;
+ info.bpp = mode.bitsPerPixel;
+ info.name_size = (size + 3) & ~3L;
+ info.vsync_num = mode.VSync_num;
+ info.vsync_den = mode.VSync_den;
+ info.flags = mode.flags;
+ info.image_width = mode.imageWidth;
+ info.image_height = mode.imageHeight;
+ info.pixmap_width = mode.pixmapWidth;
+ info.pixmap_height = mode.pixmapHeight;
+ info.bytes_per_scanline = mode.bytesPerScanline;
+ info.red_mask = mode.red_mask;
+ info.green_mask = mode.green_mask;
+ info.blue_mask = mode.blue_mask;
+ info.visual_class = mode.visualClass;
+ info.viewport_width = mode.viewportWidth;
+ info.viewport_height = mode.viewportHeight;
+ info.viewport_xstep = mode.xViewportStep;
+ info.viewport_ystep = mode.yViewportStep;
+ info.viewport_xmax = mode.maxViewportX;
+ info.viewport_ymax = mode.maxViewportY;
+ info.viewport_flags = mode.viewportFlags;
+ info.reserved1 = mode.reserved1;
+ info.reserved2 = mode.reserved2;
+
+ rep.length = (sz_xXDGAModeInfo + info.name_size) >> 2;
+
+ WriteToClient(client, sz_xXDGASetModeReply, (char*)&rep);
+ WriteToClient(client, sz_xXDGAModeInfo, (char*)(&info));
+ WriteToClient(client, size, mode.name);
+
+ return (client->noClientException);
+}
+
+static int
+ProcXDGASetViewport(ClientPtr client)
+{
+ REQUEST(xXDGASetViewportReq);
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ if(DGAClients[stuff->screen] != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGASetViewportReq);
+
+ DGASetViewport(stuff->screen, stuff->x, stuff->y, stuff->flags);
+
+ return (client->noClientException);
+}
+
+static int
+ProcXDGAInstallColormap(ClientPtr client)
+{
+ ColormapPtr cmap;
+ REQUEST(xXDGAInstallColormapReq);
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ if(DGAClients[stuff->screen] != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGAInstallColormapReq);
+
+ cmap = (ColormapPtr)LookupIDByType(stuff->cmap, RT_COLORMAP);
+ if (cmap) {
+ DGAInstallCmap(cmap);
+ return (client->noClientException);
+ } else {
+ client->errorValue = stuff->cmap;
+ return (BadColor);
+ }
+
+ return (client->noClientException);
+}
+
+
+static int
+ProcXDGASelectInput(ClientPtr client)
+{
+ REQUEST(xXDGASelectInputReq);
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ if(DGAClients[stuff->screen] != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGASelectInputReq);
+
+ if(DGAClients[stuff->screen] == client)
+ DGASelectInput(stuff->screen, client, stuff->mask);
+
+ return (client->noClientException);
+}
+
+
+static int
+ProcXDGAFillRectangle(ClientPtr client)
+{
+ REQUEST(xXDGAFillRectangleReq);
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ if(DGAClients[stuff->screen] != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGAFillRectangleReq);
+
+ if(Success != DGAFillRect(stuff->screen, stuff->x, stuff->y,
+ stuff->width, stuff->height, stuff->color))
+ return BadMatch;
+
+ return (client->noClientException);
+}
+
+static int
+ProcXDGACopyArea(ClientPtr client)
+{
+ REQUEST(xXDGACopyAreaReq);
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ if(DGAClients[stuff->screen] != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGACopyAreaReq);
+
+ if(Success != DGABlitRect(stuff->screen, stuff->srcx, stuff->srcy,
+ stuff->width, stuff->height, stuff->dstx, stuff->dsty))
+ return BadMatch;
+
+ return (client->noClientException);
+}
+
+
+static int
+ProcXDGACopyTransparentArea(ClientPtr client)
+{
+ REQUEST(xXDGACopyTransparentAreaReq);
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ if(DGAClients[stuff->screen] != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGACopyTransparentAreaReq);
+
+ if(Success != DGABlitTransRect(stuff->screen, stuff->srcx, stuff->srcy,
+ stuff->width, stuff->height, stuff->dstx, stuff->dsty, stuff->key))
+ return BadMatch;
+
+ return (client->noClientException);
+}
+
+
+static int
+ProcXDGAGetViewportStatus(ClientPtr client)
+{
+ REQUEST(xXDGAGetViewportStatusReq);
+ xXDGAGetViewportStatusReply rep;
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ if(DGAClients[stuff->screen] != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGAGetViewportStatusReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ rep.status = DGAGetViewportStatus(stuff->screen);
+
+ WriteToClient(client, sizeof(xXDGAGetViewportStatusReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcXDGASync(ClientPtr client)
+{
+ REQUEST(xXDGASyncReq);
+ xXDGASyncReply rep;
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ if(DGAClients[stuff->screen] != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGASyncReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ DGASync(stuff->screen);
+
+ WriteToClient(client, sizeof(xXDGASyncReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcXDGASetClientVersion(ClientPtr client)
+{
+ REQUEST(xXDGASetClientVersionReq);
+
+ DGAPrivPtr pPriv;
+
+ REQUEST_SIZE_MATCH(xXDGASetClientVersionReq);
+ if ((pPriv = DGAPRIV(client)) == NULL) {
+ pPriv = xalloc(sizeof(DGAPrivRec));
+ /* XXX Need to look into freeing this */
+ if (!pPriv)
+ return BadAlloc;
+ DGAPRIV(client) = pPriv;
+ }
+ pPriv->major = stuff->major;
+ pPriv->minor = stuff->minor;
+
+ return (client->noClientException);
+}
+
+static int
+ProcXDGAChangePixmapMode(ClientPtr client)
+{
+ REQUEST(xXDGAChangePixmapModeReq);
+ xXDGAChangePixmapModeReply rep;
+ int x, y;
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ if(DGAClients[stuff->screen] != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGAChangePixmapModeReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ x = stuff->x;
+ y = stuff->y;
+
+ if(!DGAChangePixmapMode(stuff->screen, &x, &y, stuff->flags))
+ return BadMatch;
+
+ rep.x = x;
+ rep.y = y;
+ WriteToClient(client, sizeof(xXDGAChangePixmapModeReply), (char *)&rep);
+
+ return (client->noClientException);
+}
+
+
+static int
+ProcXDGACreateColormap(ClientPtr client)
+{
+ REQUEST(xXDGACreateColormapReq);
+ int result;
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ if(DGAClients[stuff->screen] != client)
+ return DGAErrorBase + XF86DGADirectNotActivated;
+
+ REQUEST_SIZE_MATCH(xXDGACreateColormapReq);
+
+ if(!stuff->mode)
+ return BadValue;
+
+ result = DGACreateColormap(stuff->screen, client, stuff->id,
+ stuff->mode, stuff->alloc);
+ if(result != Success)
+ return result;
+
+ return (client->noClientException);
+}
+
+
+static int
+SProcXDGADispatch (ClientPtr client)
+{
+ return DGAErrorBase + XF86DGAClientNotLocal;
+}
+
+#if 0
+#define DGA_REQ_DEBUG
+#endif
+
+#ifdef DGA_REQ_DEBUG
+static char *dgaMinor[] = {
+ "QueryVersion",
+ "GetVideoLL",
+ "DirectVideo",
+ "GetViewPortSize",
+ "SetViewPort",
+ "GetVidPage",
+ "SetVidPage",
+ "InstallColormap",
+ "QueryDirectVideo",
+ "ViewPortChanged",
+ "10",
+ "11",
+ "QueryModes",
+ "SetMode",
+ "SetViewport",
+ "InstallColormap",
+ "SelectInput",
+ "FillRectangle",
+ "CopyArea",
+ "CopyTransparentArea",
+ "GetViewportStatus",
+ "Sync",
+ "OpenFramebuffer",
+ "CloseFramebuffer",
+ "SetClientVersion",
+ "ChangePixmapMode",
+ "CreateColormap",
+};
+#endif
+
+static int
+ProcXDGADispatch (ClientPtr client)
+{
+ REQUEST(xReq);
+
+ if (!LocalClient(client))
+ return DGAErrorBase + XF86DGAClientNotLocal;
+
+#ifdef DGA_REQ_DEBUG
+ if (stuff->data <= X_XDGACreateColormap)
+ fprintf (stderr, " DGA %s\n", dgaMinor[stuff->data]);
+#endif
+
+ /* divert old protocol */
+#if 1
+ if( (stuff->data <= X_XF86DGAViewPortChanged) &&
+ (stuff->data >= X_XF86DGAGetVideoLL))
+ return ProcXF86DGADispatch(client);
+#endif
+
+ switch (stuff->data){
+ case X_XDGAQueryVersion:
+ return ProcXDGAQueryVersion(client);
+ case X_XDGAQueryModes:
+ return ProcXDGAQueryModes(client);
+ case X_XDGASetMode:
+ return ProcXDGASetMode(client);
+ case X_XDGAOpenFramebuffer:
+ return ProcXDGAOpenFramebuffer(client);
+ case X_XDGACloseFramebuffer:
+ return ProcXDGACloseFramebuffer(client);
+ case X_XDGASetViewport:
+ return ProcXDGASetViewport(client);
+ case X_XDGAInstallColormap:
+ return ProcXDGAInstallColormap(client);
+ case X_XDGASelectInput:
+ return ProcXDGASelectInput(client);
+ case X_XDGAFillRectangle:
+ return ProcXDGAFillRectangle(client);
+ case X_XDGACopyArea:
+ return ProcXDGACopyArea(client);
+ case X_XDGACopyTransparentArea:
+ return ProcXDGACopyTransparentArea(client);
+ case X_XDGAGetViewportStatus:
+ return ProcXDGAGetViewportStatus(client);
+ case X_XDGASync:
+ return ProcXDGASync(client);
+ case X_XDGASetClientVersion:
+ return ProcXDGASetClientVersion(client);
+ case X_XDGAChangePixmapMode:
+ return ProcXDGAChangePixmapMode(client);
+ case X_XDGACreateColormap:
+ return ProcXDGACreateColormap(client);
+ default:
+ return BadRequest;
+ }
+}
+
+#ifdef EXTMODULE
+void
+XFree86DGARegister(INITARGS)
+{
+ XDGAEventBase = &DGAEventBase;
+}
+#endif
diff --git a/nx-X11/programs/Xserver/Xext/xf86dgaext.h b/nx-X11/programs/Xserver/Xext/xf86dgaext.h
new file mode 100644
index 000000000..16fc4c8b2
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xf86dgaext.h
@@ -0,0 +1,12 @@
+/* $XFree86$ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _XF86DGAEXT_H_
+#define _XF86DGAEXT_H_
+
+extern DISPATCH_PROC(ProcXF86DGADispatch);
+
+#endif /* _XF86DGAEXT_H_ */
diff --git a/nx-X11/programs/Xserver/Xext/xf86misc.c b/nx-X11/programs/Xserver/Xext/xf86misc.c
new file mode 100644
index 000000000..a5dc2e212
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xf86misc.c
@@ -0,0 +1,854 @@
+/* $XFree86: xc/programs/Xserver/Xext/xf86misc.c,v 3.41 2003/11/17 22:20:27 dawes Exp $ */
+
+/*
+ * Copyright (c) 1995, 1996 The XFree86 Project, Inc
+ */
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "scrnintstr.h"
+#include "inputstr.h"
+#include "servermd.h"
+#define _XF86MISC_SERVER_
+#undef _XF86MISC_SAVER_COMPAT_
+#include <X11/extensions/xf86mscstr.h>
+#include "swaprep.h"
+#include "xf86.h"
+#include <X11/Xfuncproto.h>
+#include "xf86miscproc.h"
+
+#if 0
+#include <X11/Xtrans/Xtrans.h>
+#include "../os/osdep.h"
+#include <X11/Xauth.h>
+#ifndef USL
+#ifndef Lynx
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif
+#endif /* USL */
+#endif
+
+#ifdef EXTMODULE
+#include "xf86_ansic.h"
+#endif
+
+static int miscErrorBase;
+static int MiscGeneration = 0;
+static int MiscClientPrivateIndex;
+
+/* This holds the client's version information */
+typedef struct {
+ int major;
+ int minor;
+} MiscPrivRec, *MiscPrivPtr;
+
+#define MPRIV(c) ((c)->devPrivates[MiscClientPrivateIndex].ptr)
+
+static void XF86MiscResetProc(
+ ExtensionEntry* /* extEntry */
+);
+
+static void
+ClientVersion(ClientPtr client, int *major, int *minor)
+{
+ MiscPrivPtr pPriv;
+
+ pPriv = MPRIV(client);
+ if (!pPriv) {
+ if (major) *major = 0;
+ if (minor) *minor = 0;
+ return;
+ }
+
+ if (major) *major = pPriv->major;
+ if (minor) *minor = pPriv->minor;
+}
+
+static DISPATCH_PROC(ProcXF86MiscDispatch);
+static DISPATCH_PROC(ProcXF86MiscQueryVersion);
+static DISPATCH_PROC(ProcXF86MiscGetKbdSettings);
+static DISPATCH_PROC(ProcXF86MiscGetMouseSettings);
+static DISPATCH_PROC(ProcXF86MiscSetKbdSettings);
+static DISPATCH_PROC(ProcXF86MiscSetMouseSettings);
+static DISPATCH_PROC(ProcXF86MiscSetGrabKeysState);
+static DISPATCH_PROC(ProcXF86MiscSetClientVersion);
+static DISPATCH_PROC(ProcXF86MiscGetFilePaths);
+static DISPATCH_PROC(ProcXF86MiscPassMessage);
+#ifdef _XF86MISC_SAVER_COMPAT_
+static DISPATCH_PROC(ProcXF86MiscGetSaver);
+static DISPATCH_PROC(ProcXF86MiscSetSaver);
+#endif
+static DISPATCH_PROC(SProcXF86MiscDispatch);
+static DISPATCH_PROC(SProcXF86MiscQueryVersion);
+static DISPATCH_PROC(SProcXF86MiscGetKbdSettings);
+static DISPATCH_PROC(SProcXF86MiscGetMouseSettings);
+static DISPATCH_PROC(SProcXF86MiscSetKbdSettings);
+static DISPATCH_PROC(SProcXF86MiscSetMouseSettings);
+static DISPATCH_PROC(SProcXF86MiscSetGrabKeysState);
+static DISPATCH_PROC(SProcXF86MiscSetClientVersion);
+static DISPATCH_PROC(SProcXF86MiscGetFilePaths);
+static DISPATCH_PROC(SProcXF86MiscPassMessage);
+#ifdef _XF86MISC_SAVER_COMPAT_
+static DISPATCH_PROC(SProcXF86MiscGetSaver);
+static DISPATCH_PROC(SProcXF86MiscSetSaver);
+#endif
+
+#if 0
+static unsigned char XF86MiscReqCode = 0;
+#endif
+
+#ifdef DEBUG
+# define DEBUG_P(x) ErrorF(x"\n");
+#else
+# define DEBUG_P(x) /**/
+#endif
+
+#define MISCERR(x) (miscErrorBase + x)
+
+void
+XFree86MiscExtensionInit(void)
+{
+ ExtensionEntry* extEntry;
+
+ DEBUG_P("XFree86MiscExtensionInit");
+
+ if (!xf86GetModInDevEnabled())
+ return;
+
+ /*
+ * Allocate a client private index to hold the client's version
+ * information.
+ */
+ if (MiscGeneration != serverGeneration) {
+ MiscClientPrivateIndex = AllocateClientPrivateIndex();
+ /*
+ * Allocate 0 length, and use the private to hold a pointer to our
+ * MiscPrivRec.
+ */
+ if (!AllocateClientPrivate(MiscClientPrivateIndex, 0)) {
+ ErrorF("XFree86MiscExtensionInit: "
+ "AllocateClientPrivate failed\n");
+ return;
+ }
+ MiscGeneration = serverGeneration;
+ }
+
+ if (
+ (extEntry = AddExtension(XF86MISCNAME,
+ XF86MiscNumberEvents,
+ XF86MiscNumberErrors,
+ ProcXF86MiscDispatch,
+ SProcXF86MiscDispatch,
+ XF86MiscResetProc,
+ StandardMinorOpcode))) {
+#if 0
+ XF86MiscReqCode = (unsigned char)extEntry->base;
+#endif
+ miscErrorBase = extEntry->errorBase;
+ }
+}
+
+/*ARGSUSED*/
+static void
+XF86MiscResetProc (extEntry)
+ ExtensionEntry* extEntry;
+{
+}
+
+static int
+ProcXF86MiscQueryVersion(client)
+ register ClientPtr client;
+{
+ xXF86MiscQueryVersionReply rep;
+ register int n;
+
+ DEBUG_P("XF86MiscQueryVersion");
+
+ REQUEST_SIZE_MATCH(xXF86MiscQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = XF86MISC_MAJOR_VERSION;
+ rep.minorVersion = XF86MISC_MINOR_VERSION;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof(xXF86MiscQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+#ifdef _XF86MISC_SAVER_COMPAT_
+/* THESE HAVE NOT BEEN CONVERTED TO THE NEW DESIGN */
+
+/*
+ * This will go away, but remains for now for compatibility with older
+ * clients.
+ */
+static int
+ProcXF86MiscSetSaver(client)
+ register ClientPtr client;
+{
+ REQUEST(xXF86MiscSetSaverReq);
+ ScrnInfoPtr vptr;
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
+
+ REQUEST_SIZE_MATCH(xXF86MiscSetSaverReq);
+
+ if (stuff->suspendTime < 0)
+ return BadValue;
+ if (stuff->offTime < 0)
+ return BadValue;
+
+ return (client->noClientException);
+}
+
+/*
+ * This will go away, but remains for now for compatibility with older
+ * clients.
+ */
+static int
+ProcXF86MiscGetSaver(client)
+ register ClientPtr client;
+{
+ REQUEST(xXF86MiscGetSaverReq);
+ xXF86MiscGetSaverReply rep;
+ register int n;
+ ScrnInfoPtr vptr;
+
+ if (stuff->screen > screenInfo.numScreens)
+ return BadValue;
+
+ vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
+
+ REQUEST_SIZE_MATCH(xXF86MiscGetSaverReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.suspendTime = 0;
+ rep.offTime = 0;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.suspendTime, n);
+ swapl(&rep.offTime, n);
+ }
+ WriteToClient(client, SIZEOF(xXF86MiscGetSaverReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+#endif /* _XF86MISC_SAVER_COMPAT_ */
+
+static int
+ProcXF86MiscGetMouseSettings(client)
+ register ClientPtr client;
+{
+ xXF86MiscGetMouseSettingsReply rep;
+ char *devname;
+ pointer mouse;
+ register int n;
+
+ DEBUG_P("XF86MiscGetMouseSettings");
+
+ REQUEST_SIZE_MATCH(xXF86MiscGetMouseSettingsReq);
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+
+ if (!MiscExtGetMouseSettings(&mouse, &devname))
+ return BadValue;
+
+ rep.mousetype = MiscExtGetMouseValue(mouse, MISC_MSE_PROTO);
+ rep.baudrate = MiscExtGetMouseValue(mouse, MISC_MSE_BAUDRATE);
+ rep.samplerate = MiscExtGetMouseValue(mouse, MISC_MSE_SAMPLERATE);
+ rep.resolution = MiscExtGetMouseValue(mouse, MISC_MSE_RESOLUTION);
+ rep.buttons = MiscExtGetMouseValue(mouse, MISC_MSE_BUTTONS);
+ rep.emulate3buttons = MiscExtGetMouseValue(mouse, MISC_MSE_EM3BUTTONS);
+ rep.emulate3timeout = MiscExtGetMouseValue(mouse, MISC_MSE_EM3TIMEOUT);
+ rep.chordmiddle = MiscExtGetMouseValue(mouse, MISC_MSE_CHORDMIDDLE);
+ rep.flags = MiscExtGetMouseValue(mouse, MISC_MSE_FLAGS);
+ rep.devnamelen = (devname? strlen(devname): 0);
+ rep.length = (sizeof(xXF86MiscGetMouseSettingsReply) -
+ sizeof(xGenericReply) + ((rep.devnamelen+3) & ~3)) >> 2;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.mousetype, n);
+ swapl(&rep.baudrate, n);
+ swapl(&rep.samplerate, n);
+ swapl(&rep.resolution, n);
+ swapl(&rep.buttons, n);
+ swapl(&rep.emulate3buttons, n);
+ swapl(&rep.emulate3timeout, n);
+ swapl(&rep.chordmiddle, n);
+ swapl(&rep.flags, n);
+ }
+ WriteToClient(client, SIZEOF(xXF86MiscGetMouseSettingsReply), (char *)&rep);
+ MiscExtDestroyStruct(mouse, MISC_POINTER);
+
+ if (rep.devnamelen)
+ WriteToClient(client, rep.devnamelen, devname);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86MiscGetKbdSettings(client)
+ register ClientPtr client;
+{
+ xXF86MiscGetKbdSettingsReply rep;
+ pointer kbd;
+ register int n;
+
+ DEBUG_P("XF86MiscGetKbdSettings");
+
+ REQUEST_SIZE_MATCH(xXF86MiscGetKbdSettingsReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ if (!MiscExtGetKbdSettings(&kbd))
+ return BadValue;
+
+ rep.kbdtype = MiscExtGetKbdValue(kbd, MISC_KBD_TYPE);
+ rep.rate = MiscExtGetKbdValue(kbd, MISC_KBD_RATE);
+ rep.delay = MiscExtGetKbdValue(kbd, MISC_KBD_DELAY);
+ rep.servnumlock = MiscExtGetKbdValue(kbd, MISC_KBD_SERVNUMLOCK);
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.kbdtype, n);
+ swapl(&rep.rate, n);
+ swapl(&rep.delay, n);
+ }
+ WriteToClient(client, SIZEOF(xXF86MiscGetKbdSettingsReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86MiscSetMouseSettings(client)
+ register ClientPtr client;
+{
+ MiscExtReturn ret;
+ pointer mouse;
+ char *devname = NULL;
+ int major, minor;
+
+ REQUEST(xXF86MiscSetMouseSettingsReq);
+
+ DEBUG_P("XF86MiscSetMouseSettings");
+
+ REQUEST_AT_LEAST_SIZE(xXF86MiscSetMouseSettingsReq);
+
+ ClientVersion(client, &major, &minor);
+
+ if (xf86GetVerbosity() > 1) {
+ ErrorF("SetMouseSettings - type: %d brate: %d srate: %d chdmid: %d\n",
+ (int)stuff->mousetype, (int)stuff->baudrate,
+ (int)stuff->samplerate, stuff->chordmiddle);
+ ErrorF(" em3but: %d em3tim: %d res: %d flags: %ld\n",
+ stuff->emulate3buttons, (int)stuff->emulate3timeout,
+ (int)stuff->resolution, (unsigned long)stuff->flags);
+ }
+
+ if ((mouse = MiscExtCreateStruct(MISC_POINTER)) == (pointer) 0)
+ return BadAlloc;
+
+ MiscExtSetMouseValue(mouse, MISC_MSE_PROTO, stuff->mousetype);
+ MiscExtSetMouseValue(mouse, MISC_MSE_BAUDRATE, stuff->baudrate);
+ MiscExtSetMouseValue(mouse, MISC_MSE_SAMPLERATE, stuff->samplerate);
+ MiscExtSetMouseValue(mouse, MISC_MSE_RESOLUTION, stuff->resolution);
+ MiscExtSetMouseValue(mouse, MISC_MSE_BUTTONS, stuff->buttons);
+ MiscExtSetMouseValue(mouse, MISC_MSE_EM3BUTTONS, stuff->emulate3buttons);
+ MiscExtSetMouseValue(mouse, MISC_MSE_EM3TIMEOUT, stuff->emulate3timeout);
+ MiscExtSetMouseValue(mouse, MISC_MSE_CHORDMIDDLE, stuff->chordmiddle);
+ MiscExtSetMouseValue(mouse, MISC_MSE_FLAGS, stuff->flags);
+
+ if ((major > 0 || minor > 5) && stuff->devnamelen) {
+ int size = sizeof(xXF86MiscSetMouseSettingsReq) + stuff->devnamelen;
+ size = (size + 3) >> 2;
+ if (client->req_len < size)
+ return BadLength;
+ if (stuff->devnamelen) {
+ if (!(devname = xalloc(stuff->devnamelen)))
+ return BadAlloc;
+ strncpy(devname,(char*)(&stuff[1]),stuff->devnamelen);
+ if (xf86GetVerbosity() > 1)
+ ErrorF("SetMouseSettings - device: %s\n",devname);
+ MiscExtSetMouseDevice(mouse, devname);
+ }
+ }
+
+ ret = MiscExtApply(mouse, MISC_POINTER);
+
+ if (devname)
+ xfree(devname);
+
+ switch ((ret)) {
+ case MISC_RET_SUCCESS: break;
+ case MISC_RET_BADVAL: return BadValue;
+ case MISC_RET_BADMSEPROTO: return MISCERR(XF86MiscBadMouseProtocol);
+ case MISC_RET_BADBAUDRATE: return MISCERR(XF86MiscBadMouseBaudRate);
+ case MISC_RET_BADFLAGS: return MISCERR(XF86MiscBadMouseFlags);
+ case MISC_RET_BADCOMBO: return MISCERR(XF86MiscBadMouseCombo);
+ case MISC_RET_NOMODULE: return MISCERR(XF86MiscNoModule);
+ default:
+ ErrorF("Unexpected return from MiscExtApply(POINTER) = %d\n", ret);
+ return BadImplementation;
+ }
+
+ if (xf86GetVerbosity() > 1)
+ ErrorF("SetMouseSettings - Succeeded\n");
+ return (client->noClientException);
+}
+
+static int
+ProcXF86MiscSetKbdSettings(client)
+ register ClientPtr client;
+{
+ MiscExtReturn ret;
+ pointer kbd;
+ REQUEST(xXF86MiscSetKbdSettingsReq);
+
+ DEBUG_P("XF86MiscSetKbdSettings");
+
+ REQUEST_SIZE_MATCH(xXF86MiscSetKbdSettingsReq);
+
+ if (xf86GetVerbosity() > 1)
+ ErrorF("SetKbdSettings - type: %d rate: %d delay: %d snumlk: %d\n",
+ (int)stuff->kbdtype, (int)stuff->rate,
+ (int)stuff->delay, stuff->servnumlock);
+
+ if ((kbd = MiscExtCreateStruct(MISC_KEYBOARD)) == (pointer) 0)
+ return BadAlloc;
+
+ MiscExtSetKbdValue(kbd, MISC_KBD_TYPE, stuff->kbdtype);
+ MiscExtSetKbdValue(kbd, MISC_KBD_RATE, stuff->rate);
+ MiscExtSetKbdValue(kbd, MISC_KBD_DELAY, stuff->delay);
+ MiscExtSetKbdValue(kbd, MISC_KBD_SERVNUMLOCK, stuff->servnumlock);
+
+ switch ((ret = MiscExtApply(kbd, MISC_KEYBOARD))) {
+ case MISC_RET_SUCCESS: break;
+ case MISC_RET_BADVAL: return BadValue;
+ case MISC_RET_BADKBDTYPE: return MISCERR(XF86MiscBadKbdType);
+ default:
+ ErrorF("Unexpected return from MiscExtApply(KEYBOARD) = %d\n", ret);
+ return BadImplementation;
+ }
+
+ if (xf86GetVerbosity() > 1)
+ ErrorF("SetKbdSettings - Succeeded\n");
+ return (client->noClientException);
+}
+
+static int
+ProcXF86MiscSetGrabKeysState(client)
+ register ClientPtr client;
+{
+ int n, status;
+ xXF86MiscSetGrabKeysStateReply rep;
+ REQUEST(xXF86MiscSetGrabKeysStateReq);
+
+ DEBUG_P("XF86MiscSetGrabKeysState");
+
+ REQUEST_SIZE_MATCH(xXF86MiscSetGrabKeysStateReq);
+
+ if ((status = MiscExtSetGrabKeysState(client, stuff->enable)) == 0) {
+ if (xf86GetVerbosity() > 1)
+ ErrorF("SetGrabKeysState - %s\n",
+ stuff->enable ? "enabled" : "disabled");
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.status = status;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.status, n);
+ }
+ WriteToClient(client, SIZEOF(xXF86MiscSetGrabKeysStateReply), (char *)&rep);
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86MiscSetClientVersion(ClientPtr client)
+{
+ REQUEST(xXF86MiscSetClientVersionReq);
+
+ MiscPrivPtr pPriv;
+
+ DEBUG_P("XF86MiscSetClientVersion");
+
+ REQUEST_SIZE_MATCH(xXF86MiscSetClientVersionReq);
+
+ if ((pPriv = MPRIV(client)) == NULL) {
+ pPriv = xalloc(sizeof(MiscPrivRec));
+ if (!pPriv)
+ return BadAlloc;
+ MPRIV(client) = pPriv;
+ }
+ ErrorF("SetClientVersion: %i %i\n",stuff->major,stuff->minor);
+ pPriv->major = stuff->major;
+ pPriv->minor = stuff->minor;
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86MiscGetFilePaths(client)
+ register ClientPtr client;
+{
+ xXF86MiscGetFilePathsReply rep;
+ const char *configfile;
+ const char *modulepath;
+ const char *logfile;
+ register int n;
+
+ DEBUG_P("XF86MiscGetFilePaths");
+
+ REQUEST_SIZE_MATCH(xXF86MiscGetFilePathsReq);
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+
+ if (!MiscExtGetFilePaths(&configfile, &modulepath, &logfile))
+ return BadValue;
+
+ rep.configlen = (configfile? strlen(configfile): 0);
+ rep.modulelen = (modulepath? strlen(modulepath): 0);
+ rep.loglen = (logfile? strlen(logfile): 0);
+ rep.length = (SIZEOF(xXF86MiscGetFilePathsReply) - SIZEOF(xGenericReply) +
+ ((rep.configlen + 3) & ~3) +
+ ((rep.modulelen + 3) & ~3) +
+ ((rep.loglen + 3) & ~3) ) >> 2;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.configlen, n);
+ swaps(&rep.modulelen, n);
+ swaps(&rep.loglen, n);
+ }
+ WriteToClient(client, SIZEOF(xXF86MiscGetFilePathsReply), (char *)&rep);
+
+ if (rep.configlen)
+ WriteToClient(client, rep.configlen, (char *)configfile);
+ if (rep.modulelen)
+ WriteToClient(client, rep.modulelen, (char *)modulepath);
+ if (rep.loglen)
+ WriteToClient(client, rep.loglen, (char *)logfile);
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86MiscPassMessage(client)
+ register ClientPtr client;
+{
+ xXF86MiscPassMessageReply rep;
+ char *msgtype, *msgval, *retstr;
+ int retval, size;
+ register int n;
+
+ REQUEST(xXF86MiscPassMessageReq);
+
+ DEBUG_P("XF86MiscPassMessage");
+
+ REQUEST_AT_LEAST_SIZE(xXF86MiscPassMessageReq);
+ size = (sizeof(xXF86MiscPassMessageReq) + 3) >> 2;
+ size+= (stuff->typelen + 3) >> 2;
+ size+= (stuff->vallen + 3) >> 2;
+ if (client->req_len < size)
+ return BadLength;
+ if (stuff->typelen) {
+ if (!(msgtype = xalloc(stuff->typelen)))
+ return BadAlloc;
+ strncpy(msgtype,(char*)(&stuff[1]),stuff->typelen);
+ } else return BadValue;
+ if (stuff->vallen) {
+ if (!(msgval = xalloc(stuff->vallen))) {
+ xfree(msgtype);
+ return BadAlloc;
+ }
+ strncpy(msgval,(char*)((char*)&stuff[1] + ((stuff->typelen + 3) & ~3)),
+ stuff->vallen);
+ } else {
+ xfree(msgtype);
+ return BadValue;
+ }
+
+ if ((retval = MiscExtPassMessage(stuff->screen,msgtype,msgval,&retstr)) != 0) {
+ xfree(msgtype);
+ xfree(msgval);
+ return retval;
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.mesglen = (retstr? strlen(retstr): 0);
+ rep.length = (SIZEOF(xXF86MiscPassMessageReply) - SIZEOF(xGenericReply) +
+ ((rep.mesglen + 3) & ~3)) >> 2;
+ rep.status = 0;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.mesglen, n);
+ }
+ WriteToClient(client, SIZEOF(xXF86MiscPassMessageReply), (char *)&rep);
+
+ if (rep.mesglen)
+ WriteToClient(client, rep.mesglen, (char *)retstr);
+
+ xfree(msgtype);
+ xfree(msgval);
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86MiscDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_XF86MiscQueryVersion:
+ return ProcXF86MiscQueryVersion(client);
+#ifdef _XF86MISC_SAVER_COMPAT_
+ case X_XF86MiscGetSaver:
+ return ProcXF86MiscGetSaver(client);
+ case X_XF86MiscSetSaver:
+ return ProcXF86MiscSetSaver(client);
+#endif
+ case X_XF86MiscGetMouseSettings:
+ return ProcXF86MiscGetMouseSettings(client);
+ case X_XF86MiscGetKbdSettings:
+ return ProcXF86MiscGetKbdSettings(client);
+ case X_XF86MiscSetClientVersion:
+ return ProcXF86MiscSetClientVersion(client);
+ case X_XF86MiscGetFilePaths:
+ return ProcXF86MiscGetFilePaths(client);
+ case X_XF86MiscPassMessage:
+ return ProcXF86MiscPassMessage(client);
+ default:
+ if (!xf86GetModInDevEnabled())
+ return miscErrorBase + XF86MiscModInDevDisabled;
+ if (xf86GetModInDevAllowNonLocal() || LocalClient (client)) {
+ switch (stuff->data) {
+ case X_XF86MiscSetMouseSettings:
+ return ProcXF86MiscSetMouseSettings(client);
+ case X_XF86MiscSetKbdSettings:
+ return ProcXF86MiscSetKbdSettings(client);
+ case X_XF86MiscSetGrabKeysState:
+ return ProcXF86MiscSetGrabKeysState(client);
+ default:
+ return BadRequest;
+ }
+ } else
+ return miscErrorBase + XF86MiscModInDevClientNotLocal;
+ }
+}
+
+static int
+SProcXF86MiscQueryVersion(client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST(xXF86MiscQueryVersionReq);
+ swaps(&stuff->length, n);
+ return ProcXF86MiscQueryVersion(client);
+}
+
+#ifdef _XF86MISC_SAVER_COMPAT_
+static int
+SProcXF86MiscGetSaver(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xXF86MiscGetSaverReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86MiscGetSaverReq);
+ swaps(&stuff->screen, n);
+ return ProcXF86MiscGetSaver(client);
+}
+
+static int
+SProcXF86MiscSetSaver(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xXF86MiscSetSaverReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86MiscSetSaverReq);
+ swaps(&stuff->screen, n);
+ swapl(&stuff->suspendTime, n);
+ swapl(&stuff->offTime, n);
+ return ProcXF86MiscSetSaver(client);
+}
+#endif /* _XF86MISC_SAVER_COMPAT_ */
+
+static int
+SProcXF86MiscGetMouseSettings(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xXF86MiscGetMouseSettingsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86MiscGetMouseSettingsReq);
+ return ProcXF86MiscGetMouseSettings(client);
+}
+
+static int
+SProcXF86MiscGetKbdSettings(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xXF86MiscGetKbdSettingsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86MiscGetKbdSettingsReq);
+ return ProcXF86MiscGetKbdSettings(client);
+}
+
+static int
+SProcXF86MiscSetMouseSettings(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xXF86MiscSetMouseSettingsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86MiscSetMouseSettingsReq);
+ swapl(&stuff->mousetype, n);
+ swapl(&stuff->baudrate, n);
+ swapl(&stuff->samplerate, n);
+ swapl(&stuff->resolution, n);
+ swapl(&stuff->buttons, n);
+ swapl(&stuff->emulate3timeout, n);
+ swapl(&stuff->flags, n);
+ return ProcXF86MiscSetMouseSettings(client);
+}
+
+static int
+SProcXF86MiscSetKbdSettings(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xXF86MiscSetKbdSettingsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86MiscSetKbdSettingsReq);
+ swapl(&stuff->kbdtype, n);
+ swapl(&stuff->rate, n);
+ swapl(&stuff->delay, n);
+ return ProcXF86MiscSetKbdSettings(client);
+}
+
+static int
+SProcXF86MiscSetGrabKeysState(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xXF86MiscSetGrabKeysStateReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86MiscSetGrabKeysStateReq);
+ swaps(&stuff->enable, n);
+ return ProcXF86MiscSetGrabKeysState(client);
+}
+
+static int
+SProcXF86MiscSetClientVersion(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86MiscSetClientVersionReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86MiscSetClientVersionReq);
+ swaps(&stuff->major, n);
+ swaps(&stuff->minor, n);
+ return ProcXF86MiscSetClientVersion(client);
+}
+
+static int
+SProcXF86MiscGetFilePaths(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xXF86MiscGetFilePathsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86MiscGetFilePathsReq);
+ return ProcXF86MiscGetFilePaths(client);
+}
+
+static int
+SProcXF86MiscPassMessage(client)
+ ClientPtr client;
+{
+ register int n;
+ REQUEST(xXF86MiscPassMessageReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86MiscPassMessageReq);
+ return ProcXF86MiscPassMessage(client);
+}
+
+static int
+SProcXF86MiscDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_XF86MiscQueryVersion:
+ return SProcXF86MiscQueryVersion(client);
+#ifdef _XF86MISC_SAVER_COMPAT_
+ case X_XF86MiscGetSaver:
+ return SProcXF86MiscGetSaver(client);
+ case X_XF86MiscSetSaver:
+ return SProcXF86MiscSetSaver(client);
+#endif
+ case X_XF86MiscGetMouseSettings:
+ return SProcXF86MiscGetMouseSettings(client);
+ case X_XF86MiscGetKbdSettings:
+ return SProcXF86MiscGetKbdSettings(client);
+ case X_XF86MiscSetClientVersion:
+ return SProcXF86MiscSetClientVersion(client);
+ case X_XF86MiscGetFilePaths:
+ return SProcXF86MiscGetFilePaths(client);
+ case X_XF86MiscPassMessage:
+ return SProcXF86MiscPassMessage(client);
+ default:
+ if (!xf86GetModInDevEnabled())
+ return miscErrorBase + XF86MiscModInDevDisabled;
+ if (xf86GetModInDevAllowNonLocal() || LocalClient (client)) {
+ switch (stuff->data) {
+ case X_XF86MiscSetMouseSettings:
+ return SProcXF86MiscSetMouseSettings(client);
+ case X_XF86MiscSetKbdSettings:
+ return SProcXF86MiscSetKbdSettings(client);
+ case X_XF86MiscSetGrabKeysState:
+ return SProcXF86MiscSetGrabKeysState(client);
+ default:
+ return BadRequest;
+ }
+ } else
+ return miscErrorBase + XF86MiscModInDevClientNotLocal;
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/Xext/xf86miscproc.h b/nx-X11/programs/Xserver/Xext/xf86miscproc.h
new file mode 100644
index 000000000..87a251767
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xf86miscproc.h
@@ -0,0 +1,70 @@
+/* $XFree86: xc/programs/Xserver/Xext/xf86miscproc.h,v 1.5 2002/11/20 04:04:58 dawes Exp $ */
+
+/* Prototypes for Pointer/Keyboard functions that the DDX must provide */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _XF86MISCPROC_H_
+#define _XF86MISCPROC_H_
+
+typedef enum {
+ MISC_MSE_PROTO,
+ MISC_MSE_BAUDRATE,
+ MISC_MSE_SAMPLERATE,
+ MISC_MSE_RESOLUTION,
+ MISC_MSE_BUTTONS,
+ MISC_MSE_EM3BUTTONS,
+ MISC_MSE_EM3TIMEOUT,
+ MISC_MSE_CHORDMIDDLE,
+ MISC_MSE_FLAGS
+} MiscExtMseValType;
+
+typedef enum {
+ MISC_KBD_TYPE,
+ MISC_KBD_RATE,
+ MISC_KBD_DELAY,
+ MISC_KBD_SERVNUMLOCK
+} MiscExtKbdValType;
+
+typedef enum {
+ MISC_RET_SUCCESS,
+ MISC_RET_BADVAL,
+ MISC_RET_BADMSEPROTO,
+ MISC_RET_BADBAUDRATE,
+ MISC_RET_BADFLAGS,
+ MISC_RET_BADCOMBO,
+ MISC_RET_BADKBDTYPE,
+ MISC_RET_NOMODULE
+} MiscExtReturn;
+
+typedef enum {
+ MISC_POINTER,
+ MISC_KEYBOARD
+} MiscExtStructType;
+
+#define MISC_MSEFLAG_CLEARDTR 1
+#define MISC_MSEFLAG_CLEARRTS 2
+#define MISC_MSEFLAG_REOPEN 128
+
+void XFree86MiscExtensionInit(void);
+
+Bool MiscExtGetMouseSettings(pointer *mouse, char **devname);
+int MiscExtGetMouseValue(pointer mouse, MiscExtMseValType valtype);
+Bool MiscExtSetMouseValue(pointer mouse, MiscExtMseValType valtype, int value);
+Bool MiscExtGetKbdSettings(pointer *kbd);
+int MiscExtGetKbdValue(pointer kbd, MiscExtKbdValType valtype);
+Bool MiscExtSetKbdValue(pointer kbd, MiscExtKbdValType valtype, int value);
+int MiscExtSetGrabKeysState(ClientPtr client, int enable);
+pointer MiscExtCreateStruct(MiscExtStructType mse_or_kbd);
+void MiscExtDestroyStruct(pointer structure, MiscExtStructType mse_or_kbd);
+MiscExtReturn MiscExtApply(pointer structure, MiscExtStructType mse_or_kbd);
+Bool MiscExtSetMouseDevice(pointer mouse, char* device);
+Bool MiscExtGetFilePaths(const char **configfile, const char **modulepath,
+ const char **logfile);
+int MiscExtPassMessage(int scrn, const char *msgtype, const char *msgval,
+ char **retstr);
+
+#endif
+
diff --git a/nx-X11/programs/Xserver/Xext/xf86vmode.c b/nx-X11/programs/Xserver/Xext/xf86vmode.c
new file mode 100644
index 000000000..fa49fcd75
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xf86vmode.c
@@ -0,0 +1,2206 @@
+/* $XFree86: xc/programs/Xserver/Xext/xf86vmode.c,v 3.58 2003/11/06 18:37:57 tsi Exp $ */
+
+/*
+
+Copyright 1995 Kaleb S. KEITHLEY
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES
+OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Kaleb S. KEITHLEY
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+from Kaleb S. KEITHLEY
+
+*/
+/* $XdotOrg: xc/programs/Xserver/Xext/xf86vmode.c,v 1.8 2005/07/16 03:49:58 kem Exp $ */
+/* $Xorg: xf86vmode.c,v 1.3 2000/08/17 19:47:59 cpqbld Exp $ */
+/* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#define _XF86VIDMODE_SERVER_
+#include <X11/extensions/xf86vmstr.h>
+#include "swaprep.h"
+#include "xf86.h"
+#include "vidmodeproc.h"
+
+#ifdef EXTMODULE
+#include "xf86_ansic.h"
+#endif
+
+#define DEFAULT_XF86VIDMODE_VERBOSITY 3
+
+static int VidModeErrorBase;
+static int VidModeGeneration = 0;
+static int VidModeClientPrivateIndex;
+
+/* This holds the client's version information */
+typedef struct {
+ int major;
+ int minor;
+} VidModePrivRec, *VidModePrivPtr;
+
+#define VMPRIV(c) ((c)->devPrivates[VidModeClientPrivateIndex].ptr)
+
+static void XF86VidModeResetProc(
+ ExtensionEntry* /* extEntry */
+);
+
+static DISPATCH_PROC(ProcXF86VidModeDispatch);
+static DISPATCH_PROC(ProcXF86VidModeGetAllModeLines);
+static DISPATCH_PROC(ProcXF86VidModeGetModeLine);
+static DISPATCH_PROC(ProcXF86VidModeGetMonitor);
+static DISPATCH_PROC(ProcXF86VidModeLockModeSwitch);
+static DISPATCH_PROC(ProcXF86VidModeAddModeLine);
+static DISPATCH_PROC(ProcXF86VidModeDeleteModeLine);
+static DISPATCH_PROC(ProcXF86VidModeModModeLine);
+static DISPATCH_PROC(ProcXF86VidModeValidateModeLine);
+static DISPATCH_PROC(ProcXF86VidModeQueryVersion);
+static DISPATCH_PROC(ProcXF86VidModeSwitchMode);
+static DISPATCH_PROC(ProcXF86VidModeSwitchToMode);
+static DISPATCH_PROC(ProcXF86VidModeGetViewPort);
+static DISPATCH_PROC(ProcXF86VidModeSetViewPort);
+static DISPATCH_PROC(ProcXF86VidModeGetDotClocks);
+static DISPATCH_PROC(ProcXF86VidModeSetGamma);
+static DISPATCH_PROC(ProcXF86VidModeGetGamma);
+static DISPATCH_PROC(ProcXF86VidModeSetClientVersion);
+static DISPATCH_PROC(ProcXF86VidModeGetGammaRamp);
+static DISPATCH_PROC(ProcXF86VidModeSetGammaRamp);
+static DISPATCH_PROC(ProcXF86VidModeGetGammaRampSize);
+static DISPATCH_PROC(SProcXF86VidModeDispatch);
+static DISPATCH_PROC(SProcXF86VidModeGetAllModeLines);
+static DISPATCH_PROC(SProcXF86VidModeGetModeLine);
+static DISPATCH_PROC(SProcXF86VidModeGetMonitor);
+static DISPATCH_PROC(SProcXF86VidModeLockModeSwitch);
+static DISPATCH_PROC(SProcXF86VidModeAddModeLine);
+static DISPATCH_PROC(SProcXF86VidModeDeleteModeLine);
+static DISPATCH_PROC(SProcXF86VidModeModModeLine);
+static DISPATCH_PROC(SProcXF86VidModeValidateModeLine);
+static DISPATCH_PROC(SProcXF86VidModeQueryVersion);
+static DISPATCH_PROC(SProcXF86VidModeSwitchMode);
+static DISPATCH_PROC(SProcXF86VidModeSwitchToMode);
+static DISPATCH_PROC(SProcXF86VidModeGetViewPort);
+static DISPATCH_PROC(SProcXF86VidModeSetViewPort);
+static DISPATCH_PROC(SProcXF86VidModeGetDotClocks);
+static DISPATCH_PROC(SProcXF86VidModeSetGamma);
+static DISPATCH_PROC(SProcXF86VidModeGetGamma);
+static DISPATCH_PROC(SProcXF86VidModeSetClientVersion);
+static DISPATCH_PROC(SProcXF86VidModeGetGammaRamp);
+static DISPATCH_PROC(SProcXF86VidModeSetGammaRamp);
+static DISPATCH_PROC(SProcXF86VidModeGetGammaRampSize);
+
+#if 0
+static unsigned char XF86VidModeReqCode = 0;
+#endif
+
+/* The XF86VIDMODE_EVENTS code is far from complete */
+
+#ifdef XF86VIDMODE_EVENTS
+static int XF86VidModeEventBase = 0;
+
+static void SXF86VidModeNotifyEvent();
+ xXF86VidModeNotifyEvent * /* from */,
+ xXF86VidModeNotifyEvent * /* to */
+);
+
+extern WindowPtr *WindowTable;
+
+static RESTYPE EventType; /* resource type for event masks */
+
+typedef struct _XF86VidModeEvent *XF86VidModeEventPtr;
+
+typedef struct _XF86VidModeEvent {
+ XF86VidModeEventPtr next;
+ ClientPtr client;
+ ScreenPtr screen;
+ XID resource;
+ CARD32 mask;
+} XF86VidModeEventRec;
+
+static int XF86VidModeFreeEvents();
+
+typedef struct _XF86VidModeScreenPrivate {
+ XF86VidModeEventPtr events;
+ Bool hasWindow;
+} XF86VidModeScreenPrivateRec, *XF86VidModeScreenPrivatePtr;
+
+static int ScreenPrivateIndex;
+
+#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr)(s)->devPrivates[ScreenPrivateIndex].ptr)
+#define SetScreenPrivate(s,v) ((s)->devPrivates[ScreenPrivateIndex].ptr = (pointer) v);
+#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = GetScreenPrivate(s)
+
+#define New(t) (xalloc (sizeof (t)))
+#endif
+
+#ifdef DEBUG
+# define DEBUG_P(x) ErrorF(x"\n");
+#else
+# define DEBUG_P(x) /**/
+#endif
+
+void
+XFree86VidModeExtensionInit(void)
+{
+ ExtensionEntry* extEntry;
+ ScreenPtr pScreen;
+ int i;
+ Bool enabled = FALSE;
+
+ DEBUG_P("XFree86VidModeExtensionInit");
+
+#ifdef XF86VIDMODE_EVENTS
+ EventType = CreateNewResourceType(XF86VidModeFreeEvents);
+ ScreenPrivateIndex = AllocateScreenPrivateIndex ();
+#endif
+
+ for(i = 0; i < screenInfo.numScreens; i++) {
+ pScreen = screenInfo.screens[i];
+ if (VidModeExtensionInit(pScreen))
+ enabled = TRUE;
+#ifdef XF86VIDMODE_EVENTS
+ SetScreenPrivate (pScreen, NULL);
+#endif
+ }
+ /* This means that the DDX doesn't want the vidmode extension enabled */
+ if (!enabled)
+ return;
+
+ /*
+ * Allocate a client private index to hold the client's version
+ * information.
+ */
+ if (VidModeGeneration != serverGeneration) {
+ VidModeClientPrivateIndex = AllocateClientPrivateIndex();
+ /*
+ * Allocate 0 length, and use the private to hold a pointer to our
+ * VidModePrivRec.
+ */
+ if (!AllocateClientPrivate(VidModeClientPrivateIndex, 0)) {
+ ErrorF("XFree86VidModeExtensionInit: "
+ "AllocateClientPrivate failed\n");
+ return;
+ }
+ VidModeGeneration = serverGeneration;
+ }
+
+ if (
+#ifdef XF86VIDMODE_EVENTS
+ EventType && ScreenPrivateIndex != -1 &&
+#endif
+ (extEntry = AddExtension(XF86VIDMODENAME,
+ XF86VidModeNumberEvents,
+ XF86VidModeNumberErrors,
+ ProcXF86VidModeDispatch,
+ SProcXF86VidModeDispatch,
+ XF86VidModeResetProc,
+ StandardMinorOpcode))) {
+#if 0
+ XF86VidModeReqCode = (unsigned char)extEntry->base;
+#endif
+ VidModeErrorBase = extEntry->errorBase;
+#ifdef XF86VIDMODE_EVENTS
+ XF86VidModeEventBase = extEntry->eventBase;
+ EventSwapVector[XF86VidModeEventBase] = (EventSwapPtr)SXF86VidModeNotifyEvent;
+#endif
+ }
+}
+
+/*ARGSUSED*/
+static void
+XF86VidModeResetProc (extEntry)
+ ExtensionEntry* extEntry;
+{
+}
+
+static int
+ClientMajorVersion(ClientPtr client)
+{
+ VidModePrivPtr pPriv;
+
+ pPriv = VMPRIV(client);
+ if (!pPriv)
+ return 0;
+ else
+ return pPriv->major;
+}
+
+#ifdef XF86VIDMODE_EVENTS
+static void
+CheckScreenPrivate (pScreen)
+ ScreenPtr pScreen;
+{
+ SetupScreen (pScreen);
+
+ if (!pPriv)
+ return;
+ if (!pPriv->events && !pPriv->hasWindow) {
+ xfree (pPriv);
+ SetScreenPrivate (pScreen, NULL);
+ }
+}
+
+static XF86VidModeScreenPrivatePtr
+MakeScreenPrivate (pScreen)
+ ScreenPtr pScreen;
+{
+ SetupScreen (pScreen);
+
+ if (pPriv)
+ return pPriv;
+ pPriv = New (XF86VidModeScreenPrivateRec);
+ if (!pPriv)
+ return 0;
+ pPriv->events = 0;
+ pPriv->hasWindow = FALSE;
+ SetScreenPrivate (pScreen, pPriv);
+ return pPriv;
+}
+
+static unsigned long
+getEventMask (ScreenPtr pScreen, ClientPtr client)
+{
+ SetupScreen(pScreen);
+ XF86VidModeEventPtr pEv;
+
+ if (!pPriv)
+ return 0;
+ for (pEv = pPriv->events; pEv; pEv = pEv->next)
+ if (pEv->client == client)
+ return pEv->mask;
+ return 0;
+}
+
+static Bool
+setEventMask (ScreenPtr pScreen, ClientPtr client, unsigned long mask)
+{
+ SetupScreen(pScreen);
+ XF86VidModeEventPtr pEv, *pPrev;
+
+ if (getEventMask (pScreen, client) == mask)
+ return TRUE;
+ if (!pPriv) {
+ pPriv = MakeScreenPrivate (pScreen);
+ if (!pPriv)
+ return FALSE;
+ }
+ for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next)
+ if (pEv->client == client)
+ break;
+ if (mask == 0) {
+ *pPrev = pEv->next;
+ xfree (pEv);
+ CheckScreenPrivate (pScreen);
+ } else {
+ if (!pEv) {
+ pEv = New (ScreenSaverEventRec);
+ if (!pEv) {
+ CheckScreenPrivate (pScreen);
+ return FALSE;
+ }
+ *pPrev = pEv;
+ pEv->next = NULL;
+ pEv->client = client;
+ pEv->screen = pScreen;
+ pEv->resource = FakeClientID (client->index);
+ }
+ pEv->mask = mask;
+ }
+ return TRUE;
+}
+
+static int
+XF86VidModeFreeEvents(pointer value, XID id)
+{
+ XF86VidModeEventPtr pOld = (XF86VidModeEventPtr)value;
+ ScreenPtr pScreen = pOld->screen;
+ SetupScreen (pScreen);
+ XF86VidModeEventPtr pEv, *pPrev;
+
+ if (!pPriv)
+ return TRUE;
+ for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next)
+ if (pEv == pOld)
+ break;
+ if (!pEv)
+ return TRUE;
+ *pPrev = pEv->next;
+ xfree (pEv);
+ CheckScreenPrivate (pScreen);
+ return TRUE;
+}
+
+static void
+SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced)
+{
+ XF86VidModeScreenPrivatePtr pPriv;
+ XF86VidModeEventPtr pEv;
+ unsigned long mask;
+ xXF86VidModeNotifyEvent ev;
+ ClientPtr client;
+ int kind;
+
+ UpdateCurrentTimeIf ();
+ mask = XF86VidModeNotifyMask;
+ pScreen = screenInfo.screens[pScreen->myNum];
+ pPriv = GetScreenPrivate(pScreen);
+ if (!pPriv)
+ return;
+ kind = XF86VidModeModeChange;
+ for (pEv = pPriv->events; pEv; pEv = pEv->next)
+ {
+ client = pEv->client;
+ if (client->clientGone)
+ continue;
+ if (!(pEv->mask & mask))
+ continue;
+ ev.type = XF86VidModeNotify + XF86VidModeEventBase;
+ ev.state = state;
+ ev.sequenceNumber = client->sequence;
+ ev.timestamp = currentTime.milliseconds;
+ ev.root = WindowTable[pScreen->myNum]->drawable.id;
+ ev.kind = kind;
+ ev.forced = forced;
+ WriteEventsToClient (client, 1, (xEvent *) &ev);
+ }
+}
+
+static void
+SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent *from,
+ xXF86VidModeNotifyEvent *to)
+{
+ to->type = from->type;
+ to->state = from->state;
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswapl (from->timestamp, to->timestamp);
+ cpswapl (from->root, to->root);
+ to->kind = from->kind;
+ to->forced = from->forced;
+}
+#endif
+
+static int
+ProcXF86VidModeQueryVersion(ClientPtr client)
+{
+ xXF86VidModeQueryVersionReply rep;
+ register int n;
+
+ DEBUG_P("XF86VidModeQueryVersion");
+
+ REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = XF86VIDMODE_MAJOR_VERSION;
+ rep.minorVersion = XF86VIDMODE_MINOR_VERSION;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof(xXF86VidModeQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeGetModeLine(ClientPtr client)
+{
+ REQUEST(xXF86VidModeGetModeLineReq);
+ xXF86VidModeGetModeLineReply rep;
+ xXF86OldVidModeGetModeLineReply oldrep;
+ pointer mode;
+ register int n;
+ int dotClock;
+ int ver;
+
+ DEBUG_P("XF86VidModeGetModeline");
+
+ ver = ClientMajorVersion(client);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
+ rep.type = X_Reply;
+ if (ver < 2) {
+ rep.length = (SIZEOF(xXF86OldVidModeGetModeLineReply) -
+ SIZEOF(xGenericReply)) >> 2;
+ } else {
+ rep.length = (SIZEOF(xXF86VidModeGetModeLineReply) -
+ SIZEOF(xGenericReply)) >> 2;
+ }
+ rep.sequenceNumber = client->sequence;
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
+ return BadValue;
+
+ rep.dotclock = dotClock;
+ rep.hdisplay = VidModeGetModeValue(mode, VIDMODE_H_DISPLAY);
+ rep.hsyncstart = VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART);
+ rep.hsyncend = VidModeGetModeValue(mode, VIDMODE_H_SYNCEND);
+ rep.htotal = VidModeGetModeValue(mode, VIDMODE_H_TOTAL);
+ rep.hskew = VidModeGetModeValue(mode, VIDMODE_H_SKEW);
+ rep.vdisplay = VidModeGetModeValue(mode, VIDMODE_V_DISPLAY);
+ rep.vsyncstart = VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART);
+ rep.vsyncend = VidModeGetModeValue(mode, VIDMODE_V_SYNCEND);
+ rep.vtotal = VidModeGetModeValue(mode, VIDMODE_V_TOTAL);
+ rep.flags = VidModeGetModeValue(mode, VIDMODE_FLAGS);
+
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("GetModeLine - scrn: %d clock: %ld\n",
+ stuff->screen, (unsigned long)rep.dotclock);
+ ErrorF("GetModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ rep.hdisplay, rep.hsyncstart,
+ rep.hsyncend, rep.htotal);
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
+ rep.vdisplay, rep.vsyncstart, rep.vsyncend,
+ rep.vtotal, (unsigned long)rep.flags);
+ }
+
+ /*
+ * Older servers sometimes had server privates that the VidMode
+ * extention made available. So to be compatiable pretend that
+ * there are no server privates to pass to the client
+ */
+ rep.privsize = 0;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.dotclock, n);
+ swaps(&rep.hdisplay, n);
+ swaps(&rep.hsyncstart, n);
+ swaps(&rep.hsyncend, n);
+ swaps(&rep.htotal, n);
+ swaps(&rep.hskew, n);
+ swaps(&rep.vdisplay, n);
+ swaps(&rep.vsyncstart, n);
+ swaps(&rep.vsyncend, n);
+ swaps(&rep.vtotal, n);
+ swapl(&rep.flags, n);
+ swapl(&rep.privsize, n);
+ }
+ if (ver < 2) {
+ oldrep.type = rep.type;
+ oldrep.sequenceNumber = rep.sequenceNumber;
+ oldrep.length = rep.length;
+ oldrep.dotclock = rep.dotclock;
+ oldrep.hdisplay = rep.hdisplay;
+ oldrep.hsyncstart = rep.hsyncstart;
+ oldrep.hsyncend = rep.hsyncend;
+ oldrep.htotal = rep.htotal;
+ oldrep.vdisplay = rep.vdisplay;
+ oldrep.vsyncstart = rep.vsyncstart;
+ oldrep.vsyncend = rep.vsyncend;
+ oldrep.vtotal = rep.vtotal;
+ oldrep.flags = rep.flags;
+ oldrep.privsize = rep.privsize;
+ WriteToClient(client, sizeof(xXF86OldVidModeGetModeLineReply),
+ (char *)&oldrep);
+ } else {
+ WriteToClient(client, sizeof(xXF86VidModeGetModeLineReply),
+ (char *)&rep);
+ }
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeGetAllModeLines(ClientPtr client)
+{
+ REQUEST(xXF86VidModeGetAllModeLinesReq);
+ xXF86VidModeGetAllModeLinesReply rep;
+ xXF86VidModeModeInfo mdinf;
+ xXF86OldVidModeModeInfo oldmdinf;
+ pointer mode;
+ int modecount, dotClock;
+ register int n;
+ int ver;
+
+ DEBUG_P("XF86VidModeGetAllModelines");
+
+ REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ ver = ClientMajorVersion(client);
+
+ modecount = VidModeGetNumOfModes(stuff->screen);
+ if (modecount < 1)
+ return (VidModeErrorBase + XF86VidModeExtensionDisabled);
+
+ if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
+ return BadValue;
+
+ rep.type = X_Reply;
+ rep.length = SIZEOF(xXF86VidModeGetAllModeLinesReply) -
+ SIZEOF(xGenericReply);
+ if (ver < 2)
+ rep.length += modecount * sizeof(xXF86OldVidModeModeInfo);
+ else
+ rep.length += modecount * sizeof(xXF86VidModeModeInfo);
+ rep.length >>= 2;
+ rep.sequenceNumber = client->sequence;
+ rep.modecount = modecount;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.modecount, n);
+ }
+ WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply), (char *)&rep);
+
+ do {
+ mdinf.dotclock = dotClock;
+ mdinf.hdisplay = VidModeGetModeValue(mode, VIDMODE_H_DISPLAY);
+ mdinf.hsyncstart = VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART);
+ mdinf.hsyncend = VidModeGetModeValue(mode, VIDMODE_H_SYNCEND);
+ mdinf.htotal = VidModeGetModeValue(mode, VIDMODE_H_TOTAL);
+ mdinf.hskew = VidModeGetModeValue(mode, VIDMODE_H_SKEW);
+ mdinf.vdisplay = VidModeGetModeValue(mode, VIDMODE_V_DISPLAY);
+ mdinf.vsyncstart = VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART);
+ mdinf.vsyncend = VidModeGetModeValue(mode, VIDMODE_V_SYNCEND);
+ mdinf.vtotal = VidModeGetModeValue(mode, VIDMODE_V_TOTAL);
+ mdinf.flags = VidModeGetModeValue(mode, VIDMODE_FLAGS);
+ mdinf.privsize = 0;
+ if (client->swapped) {
+ swapl(&mdinf.dotclock, n);
+ swaps(&mdinf.hdisplay, n);
+ swaps(&mdinf.hsyncstart, n);
+ swaps(&mdinf.hsyncend, n);
+ swaps(&mdinf.htotal, n);
+ swaps(&mdinf.hskew, n);
+ swaps(&mdinf.vdisplay, n);
+ swaps(&mdinf.vsyncstart, n);
+ swaps(&mdinf.vsyncend, n);
+ swaps(&mdinf.vtotal, n);
+ swapl(&mdinf.flags, n);
+ swapl(&mdinf.privsize, n);
+ }
+ if (ver < 2) {
+ oldmdinf.dotclock = mdinf.dotclock;
+ oldmdinf.hdisplay = mdinf.hdisplay;
+ oldmdinf.hsyncstart = mdinf.hsyncstart;
+ oldmdinf.hsyncend = mdinf.hsyncend;
+ oldmdinf.htotal = mdinf.htotal;
+ oldmdinf.vdisplay = mdinf.vdisplay;
+ oldmdinf.vsyncstart = mdinf.vsyncstart;
+ oldmdinf.vsyncend = mdinf.vsyncend;
+ oldmdinf.vtotal = mdinf.vtotal;
+ oldmdinf.flags = mdinf.flags;
+ oldmdinf.privsize = mdinf.privsize;
+ WriteToClient(client, sizeof(xXF86OldVidModeModeInfo),
+ (char *)&oldmdinf);
+ } else {
+ WriteToClient(client, sizeof(xXF86VidModeModeInfo), (char *)&mdinf);
+ }
+
+ } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
+
+ return (client->noClientException);
+}
+
+#define MODEMATCH(mode,stuff) \
+ (VidModeGetModeValue(mode, VIDMODE_H_DISPLAY) == stuff->hdisplay \
+ && VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART) == stuff->hsyncstart \
+ && VidModeGetModeValue(mode, VIDMODE_H_SYNCEND) == stuff->hsyncend \
+ && VidModeGetModeValue(mode, VIDMODE_H_TOTAL) == stuff->htotal \
+ && VidModeGetModeValue(mode, VIDMODE_V_DISPLAY) == stuff->vdisplay \
+ && VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART) == stuff->vsyncstart \
+ && VidModeGetModeValue(mode, VIDMODE_V_SYNCEND) == stuff->vsyncend \
+ && VidModeGetModeValue(mode, VIDMODE_V_TOTAL) == stuff->vtotal \
+ && VidModeGetModeValue(mode, VIDMODE_FLAGS) == stuff->flags )
+
+static int
+ProcXF86VidModeAddModeLine(ClientPtr client)
+{
+ REQUEST(xXF86VidModeAddModeLineReq);
+ xXF86OldVidModeAddModeLineReq *oldstuff =
+ (xXF86OldVidModeAddModeLineReq *)client->requestBuffer;
+ xXF86VidModeAddModeLineReq newstuff;
+ pointer mode;
+ int len;
+ int dotClock;
+ int ver;
+
+ DEBUG_P("XF86VidModeAddModeline");
+
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ /* convert from old format */
+ stuff = &newstuff;
+ stuff->length = oldstuff->length;
+ stuff->screen = oldstuff->screen;
+ stuff->dotclock = oldstuff->dotclock;
+ stuff->hdisplay = oldstuff->hdisplay;
+ stuff->hsyncstart = oldstuff->hsyncstart;
+ stuff->hsyncend = oldstuff->hsyncend;
+ stuff->htotal = oldstuff->htotal;
+ stuff->hskew = 0;
+ stuff->vdisplay = oldstuff->vdisplay;
+ stuff->vsyncstart = oldstuff->vsyncstart;
+ stuff->vsyncend = oldstuff->vsyncend;
+ stuff->vtotal = oldstuff->vtotal;
+ stuff->flags = oldstuff->flags;
+ stuff->privsize = oldstuff->privsize;
+ stuff->after_dotclock = oldstuff->after_dotclock;
+ stuff->after_hdisplay = oldstuff->after_hdisplay;
+ stuff->after_hsyncstart = oldstuff->after_hsyncstart;
+ stuff->after_hsyncend = oldstuff->after_hsyncend;
+ stuff->after_htotal = oldstuff->after_htotal;
+ stuff->after_hskew = 0;
+ stuff->after_vdisplay = oldstuff->after_vdisplay;
+ stuff->after_vsyncstart = oldstuff->after_vsyncstart;
+ stuff->after_vsyncend = oldstuff->after_vsyncend;
+ stuff->after_vtotal = oldstuff->after_vtotal;
+ stuff->after_flags = oldstuff->after_flags;
+ }
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("AddModeLine - scrn: %d clock: %ld\n",
+ (int)stuff->screen, (unsigned long)stuff->dotclock);
+ ErrorF("AddModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ stuff->hdisplay, stuff->hsyncstart,
+ stuff->hsyncend, stuff->htotal);
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
+ stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
+ stuff->vtotal, (unsigned long)stuff->flags);
+ ErrorF(" after - scrn: %d clock: %ld\n",
+ (int)stuff->screen, (unsigned long)stuff->after_dotclock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ stuff->after_hdisplay, stuff->after_hsyncstart,
+ stuff->after_hsyncend, stuff->after_htotal);
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
+ stuff->after_vdisplay, stuff->after_vsyncstart,
+ stuff->after_vsyncend, stuff->after_vtotal,
+ (unsigned long)stuff->after_flags);
+ }
+
+ if (ver < 2) {
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
+ len = client->req_len - (sizeof(xXF86OldVidModeAddModeLineReq) >> 2);
+ } else {
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
+ len = client->req_len - (sizeof(xXF86VidModeAddModeLineReq) >> 2);
+ }
+ if (len != stuff->privsize)
+ return BadLength;
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (stuff->hsyncstart < stuff->hdisplay ||
+ stuff->hsyncend < stuff->hsyncstart ||
+ stuff->htotal < stuff->hsyncend ||
+ stuff->vsyncstart < stuff->vdisplay ||
+ stuff->vsyncend < stuff->vsyncstart ||
+ stuff->vtotal < stuff->vsyncend)
+ return BadValue;
+
+ if (stuff->after_hsyncstart < stuff->after_hdisplay ||
+ stuff->after_hsyncend < stuff->after_hsyncstart ||
+ stuff->after_htotal < stuff->after_hsyncend ||
+ stuff->after_vsyncstart < stuff->after_vdisplay ||
+ stuff->after_vsyncend < stuff->after_vsyncstart ||
+ stuff->after_vtotal < stuff->after_vsyncend)
+ return BadValue;
+
+ if (stuff->after_htotal != 0 || stuff->after_vtotal != 0) {
+ Bool found = FALSE;
+ if (VidModeGetFirstModeline(stuff->screen, &mode, &dotClock)) {
+ do {
+ if ((VidModeGetDotClock(stuff->screen, stuff->dotclock)
+ == dotClock) && MODEMATCH(mode, stuff)) {
+ found = TRUE;
+ break;
+ }
+ } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
+ }
+ if (!found)
+ return BadValue;
+ }
+
+
+ mode = VidModeCreateMode();
+ if (mode == NULL)
+ return BadValue;
+
+ VidModeSetModeValue(mode, VIDMODE_CLOCK, stuff->dotclock);
+ VidModeSetModeValue(mode, VIDMODE_H_DISPLAY, stuff->hdisplay);
+ VidModeSetModeValue(mode, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
+ VidModeSetModeValue(mode, VIDMODE_H_SYNCEND, stuff->hsyncend);
+ VidModeSetModeValue(mode, VIDMODE_H_TOTAL, stuff->htotal);
+ VidModeSetModeValue(mode, VIDMODE_H_SKEW, stuff->hskew);
+ VidModeSetModeValue(mode, VIDMODE_V_DISPLAY, stuff->vdisplay);
+ VidModeSetModeValue(mode, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
+ VidModeSetModeValue(mode, VIDMODE_V_SYNCEND, stuff->vsyncend);
+ VidModeSetModeValue(mode, VIDMODE_V_TOTAL, stuff->vtotal);
+ VidModeSetModeValue(mode, VIDMODE_FLAGS, stuff->flags);
+
+ if (stuff->privsize)
+ ErrorF("AddModeLine - Privates in request have been ignored\n");
+
+ /* Check that the mode is consistent with the monitor specs */
+ switch (VidModeCheckModeForMonitor(stuff->screen, mode)) {
+ case MODE_OK:
+ break;
+ case MODE_HSYNC:
+ case MODE_H_ILLEGAL:
+ xfree(mode);
+ return VidModeErrorBase + XF86VidModeBadHTimings;
+ case MODE_VSYNC:
+ case MODE_V_ILLEGAL:
+ xfree(mode);
+ return VidModeErrorBase + XF86VidModeBadVTimings;
+ default:
+ xfree(mode);
+ return VidModeErrorBase + XF86VidModeModeUnsuitable;
+ }
+
+ /* Check that the driver is happy with the mode */
+ if (VidModeCheckModeForDriver(stuff->screen, mode) != MODE_OK) {
+ xfree(mode);
+ return VidModeErrorBase + XF86VidModeModeUnsuitable;
+ }
+
+ VidModeSetCrtcForMode(stuff->screen, mode);
+
+ VidModeAddModeline(stuff->screen, mode);
+
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
+ ErrorF("AddModeLine - Succeeded\n");
+ return client->noClientException;
+}
+
+static int
+ProcXF86VidModeDeleteModeLine(ClientPtr client)
+{
+ REQUEST(xXF86VidModeDeleteModeLineReq);
+ xXF86OldVidModeDeleteModeLineReq *oldstuff =
+ (xXF86OldVidModeDeleteModeLineReq *)client->requestBuffer;
+ xXF86VidModeDeleteModeLineReq newstuff;
+ pointer mode;
+ int len, dotClock;
+ int ver;
+
+ DEBUG_P("XF86VidModeDeleteModeline");
+
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ /* convert from old format */
+ stuff = &newstuff;
+ stuff->length = oldstuff->length;
+ stuff->screen = oldstuff->screen;
+ stuff->dotclock = oldstuff->dotclock;
+ stuff->hdisplay = oldstuff->hdisplay;
+ stuff->hsyncstart = oldstuff->hsyncstart;
+ stuff->hsyncend = oldstuff->hsyncend;
+ stuff->htotal = oldstuff->htotal;
+ stuff->hskew = 0;
+ stuff->vdisplay = oldstuff->vdisplay;
+ stuff->vsyncstart = oldstuff->vsyncstart;
+ stuff->vsyncend = oldstuff->vsyncend;
+ stuff->vtotal = oldstuff->vtotal;
+ stuff->flags = oldstuff->flags;
+ stuff->privsize = oldstuff->privsize;
+ }
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("DeleteModeLine - scrn: %d clock: %ld\n",
+ (int)stuff->screen, (unsigned long)stuff->dotclock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ stuff->hdisplay, stuff->hsyncstart,
+ stuff->hsyncend, stuff->htotal);
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
+ stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
+ stuff->vtotal, (unsigned long)stuff->flags);
+ }
+
+ if (ver < 2) {
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
+ len = client->req_len - (sizeof(xXF86OldVidModeDeleteModeLineReq) >> 2);
+ } else {
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
+ len = client->req_len - (sizeof(xXF86VidModeDeleteModeLineReq) >> 2);
+ }
+ if (len != stuff->privsize) {
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("req_len = %ld, sizeof(Req) = %d, privsize = %ld, "
+ "len = %d, length = %d\n",
+ (unsigned long)client->req_len,
+ (int)sizeof(xXF86VidModeDeleteModeLineReq)>>2,
+ (unsigned long)stuff->privsize, len, stuff->length);
+ }
+ return BadLength;
+ }
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
+ return BadValue;
+
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("Checking against clock: %d (%d)\n",
+ VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
+ VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
+ VidModeGetModeValue(mode, VIDMODE_FLAGS));
+ }
+ if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
+ MODEMATCH(mode, stuff))
+ return BadValue;
+
+ if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
+ return BadValue;
+
+ do {
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("Checking against clock: %d (%d)\n",
+ VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
+ VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
+ VidModeGetModeValue(mode, VIDMODE_FLAGS));
+ }
+ if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
+ MODEMATCH(mode, stuff)) {
+ VidModeDeleteModeline(stuff->screen, mode);
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
+ ErrorF("DeleteModeLine - Succeeded\n");
+ return(client->noClientException);
+ }
+ } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
+
+ return BadValue;
+}
+
+static int
+ProcXF86VidModeModModeLine(ClientPtr client)
+{
+ REQUEST(xXF86VidModeModModeLineReq);
+ xXF86OldVidModeModModeLineReq *oldstuff =
+ (xXF86OldVidModeModModeLineReq *)client->requestBuffer;
+ xXF86VidModeModModeLineReq newstuff;
+ pointer mode, modetmp;
+ int len, dotClock;
+ int ver;
+
+ DEBUG_P("XF86VidModeModModeline");
+
+ ver = ClientMajorVersion(client);
+ if (ver < 2 ) {
+ /* convert from old format */
+ stuff = &newstuff;
+ stuff->length = oldstuff->length;
+ stuff->screen = oldstuff->screen;
+ stuff->hdisplay = oldstuff->hdisplay;
+ stuff->hsyncstart = oldstuff->hsyncstart;
+ stuff->hsyncend = oldstuff->hsyncend;
+ stuff->htotal = oldstuff->htotal;
+ stuff->hskew = 0;
+ stuff->vdisplay = oldstuff->vdisplay;
+ stuff->vsyncstart = oldstuff->vsyncstart;
+ stuff->vsyncend = oldstuff->vsyncend;
+ stuff->vtotal = oldstuff->vtotal;
+ stuff->flags = oldstuff->flags;
+ stuff->privsize = oldstuff->privsize;
+ }
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("ModModeLine - scrn: %d hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ (int)stuff->screen, stuff->hdisplay, stuff->hsyncstart,
+ stuff->hsyncend, stuff->htotal);
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
+ stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
+ stuff->vtotal, (unsigned long)stuff->flags);
+ }
+
+ if (ver < 2) {
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
+ len = client->req_len - (sizeof(xXF86OldVidModeModModeLineReq) >> 2);
+ } else {
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
+ len = client->req_len - (sizeof(xXF86VidModeModModeLineReq) >> 2);
+ }
+ if (len != stuff->privsize)
+ return BadLength;
+
+ if (stuff->hsyncstart < stuff->hdisplay ||
+ stuff->hsyncend < stuff->hsyncstart ||
+ stuff->htotal < stuff->hsyncend ||
+ stuff->vsyncstart < stuff->vdisplay ||
+ stuff->vsyncend < stuff->vsyncstart ||
+ stuff->vtotal < stuff->vsyncend)
+ return BadValue;
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
+ return BadValue;
+
+ modetmp = VidModeCreateMode();
+ VidModeCopyMode(mode, modetmp);
+
+ VidModeSetModeValue(modetmp, VIDMODE_H_DISPLAY, stuff->hdisplay);
+ VidModeSetModeValue(modetmp, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
+ VidModeSetModeValue(modetmp, VIDMODE_H_SYNCEND, stuff->hsyncend);
+ VidModeSetModeValue(modetmp, VIDMODE_H_TOTAL, stuff->htotal);
+ VidModeSetModeValue(modetmp, VIDMODE_H_SKEW, stuff->hskew);
+ VidModeSetModeValue(modetmp, VIDMODE_V_DISPLAY, stuff->vdisplay);
+ VidModeSetModeValue(modetmp, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
+ VidModeSetModeValue(modetmp, VIDMODE_V_SYNCEND, stuff->vsyncend);
+ VidModeSetModeValue(modetmp, VIDMODE_V_TOTAL, stuff->vtotal);
+ VidModeSetModeValue(modetmp, VIDMODE_FLAGS, stuff->flags);
+
+ if (stuff->privsize)
+ ErrorF("ModModeLine - Privates in request have been ignored\n");
+
+ /* Check that the mode is consistent with the monitor specs */
+ switch (VidModeCheckModeForMonitor(stuff->screen, modetmp)) {
+ case MODE_OK:
+ break;
+ case MODE_HSYNC:
+ case MODE_H_ILLEGAL:
+ xfree(modetmp);
+ return VidModeErrorBase + XF86VidModeBadHTimings;
+ case MODE_VSYNC:
+ case MODE_V_ILLEGAL:
+ xfree(modetmp);
+ return VidModeErrorBase + XF86VidModeBadVTimings;
+ default:
+ xfree(modetmp);
+ return VidModeErrorBase + XF86VidModeModeUnsuitable;
+ }
+
+ /* Check that the driver is happy with the mode */
+ if (VidModeCheckModeForDriver(stuff->screen, modetmp) != MODE_OK) {
+ xfree(modetmp);
+ return VidModeErrorBase + XF86VidModeModeUnsuitable;
+ }
+ xfree(modetmp);
+
+ VidModeSetModeValue(mode, VIDMODE_H_DISPLAY, stuff->hdisplay);
+ VidModeSetModeValue(mode, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
+ VidModeSetModeValue(mode, VIDMODE_H_SYNCEND, stuff->hsyncend);
+ VidModeSetModeValue(mode, VIDMODE_H_TOTAL, stuff->htotal);
+ VidModeSetModeValue(mode, VIDMODE_H_SKEW, stuff->hskew);
+ VidModeSetModeValue(mode, VIDMODE_V_DISPLAY, stuff->vdisplay);
+ VidModeSetModeValue(mode, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
+ VidModeSetModeValue(mode, VIDMODE_V_SYNCEND, stuff->vsyncend);
+ VidModeSetModeValue(mode, VIDMODE_V_TOTAL, stuff->vtotal);
+ VidModeSetModeValue(mode, VIDMODE_FLAGS, stuff->flags);
+
+ VidModeSetCrtcForMode(stuff->screen, mode);
+ VidModeSwitchMode(stuff->screen, mode);
+
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
+ ErrorF("ModModeLine - Succeeded\n");
+ return(client->noClientException);
+}
+
+static int
+ProcXF86VidModeValidateModeLine(ClientPtr client)
+{
+ REQUEST(xXF86VidModeValidateModeLineReq);
+ xXF86OldVidModeValidateModeLineReq *oldstuff =
+ (xXF86OldVidModeValidateModeLineReq *)client->requestBuffer;
+ xXF86VidModeValidateModeLineReq newstuff;
+ xXF86VidModeValidateModeLineReply rep;
+ pointer mode, modetmp = NULL;
+ int len, status, dotClock;
+ int ver;
+
+ DEBUG_P("XF86VidModeValidateModeline");
+
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ /* convert from old format */
+ stuff = &newstuff;
+ stuff->length = oldstuff->length;
+ stuff->screen = oldstuff->screen;
+ stuff->dotclock = oldstuff->dotclock;
+ stuff->hdisplay = oldstuff->hdisplay;
+ stuff->hsyncstart = oldstuff->hsyncstart;
+ stuff->hsyncend = oldstuff->hsyncend;
+ stuff->htotal = oldstuff->htotal;
+ stuff->hskew = 0;
+ stuff->vdisplay = oldstuff->vdisplay;
+ stuff->vsyncstart = oldstuff->vsyncstart;
+ stuff->vsyncend = oldstuff->vsyncend;
+ stuff->vtotal = oldstuff->vtotal;
+ stuff->flags = oldstuff->flags;
+ stuff->privsize = oldstuff->privsize;
+ }
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("ValidateModeLine - scrn: %d clock: %ld\n",
+ (int)stuff->screen, (unsigned long)stuff->dotclock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ stuff->hdisplay, stuff->hsyncstart,
+ stuff->hsyncend, stuff->htotal);
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
+ stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
+ stuff->vtotal, (unsigned long)stuff->flags);
+ }
+
+ if (ver < 2) {
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
+ len = client->req_len -
+ (sizeof(xXF86OldVidModeValidateModeLineReq) >> 2);
+ } else {
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
+ len = client->req_len - (sizeof(xXF86VidModeValidateModeLineReq) >> 2);
+ }
+ if (len != stuff->privsize)
+ return BadLength;
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ status = MODE_OK;
+
+ if (stuff->hsyncstart < stuff->hdisplay ||
+ stuff->hsyncend < stuff->hsyncstart ||
+ stuff->htotal < stuff->hsyncend ||
+ stuff->vsyncstart < stuff->vdisplay ||
+ stuff->vsyncend < stuff->vsyncstart ||
+ stuff->vtotal < stuff->vsyncend)
+ {
+ status = MODE_BAD;
+ goto status_reply;
+ }
+
+ if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
+ return BadValue;
+
+ modetmp = VidModeCreateMode();
+ VidModeCopyMode(mode, modetmp);
+
+ VidModeSetModeValue(modetmp, VIDMODE_H_DISPLAY, stuff->hdisplay);
+ VidModeSetModeValue(modetmp, VIDMODE_H_SYNCSTART, stuff->hsyncstart);
+ VidModeSetModeValue(modetmp, VIDMODE_H_SYNCEND, stuff->hsyncend);
+ VidModeSetModeValue(modetmp, VIDMODE_H_TOTAL, stuff->htotal);
+ VidModeSetModeValue(modetmp, VIDMODE_H_SKEW, stuff->hskew);
+ VidModeSetModeValue(modetmp, VIDMODE_V_DISPLAY, stuff->vdisplay);
+ VidModeSetModeValue(modetmp, VIDMODE_V_SYNCSTART, stuff->vsyncstart);
+ VidModeSetModeValue(modetmp, VIDMODE_V_SYNCEND, stuff->vsyncend);
+ VidModeSetModeValue(modetmp, VIDMODE_V_TOTAL, stuff->vtotal);
+ VidModeSetModeValue(modetmp, VIDMODE_FLAGS, stuff->flags);
+ if (stuff->privsize)
+ ErrorF("ValidateModeLine - Privates in request have been ignored\n");
+
+ /* Check that the mode is consistent with the monitor specs */
+ if ((status = VidModeCheckModeForMonitor(stuff->screen, modetmp)) != MODE_OK)
+ goto status_reply;
+
+ /* Check that the driver is happy with the mode */
+ status = VidModeCheckModeForDriver(stuff->screen, modetmp);
+
+status_reply:
+ if(modetmp)
+ xfree(modetmp);
+
+ rep.type = X_Reply;
+ rep.length = (SIZEOF(xXF86VidModeValidateModeLineReply)
+ - SIZEOF(xGenericReply)) >> 2;
+ rep.sequenceNumber = client->sequence;
+ rep.status = status;
+ if (client->swapped) {
+ register int n;
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.status, n);
+ }
+ WriteToClient(client, sizeof(xXF86VidModeValidateModeLineReply), (char *)&rep);
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
+ ErrorF("ValidateModeLine - Succeeded (status = %d)\n", status);
+ return(client->noClientException);
+}
+
+static int
+ProcXF86VidModeSwitchMode(ClientPtr client)
+{
+ REQUEST(xXF86VidModeSwitchModeReq);
+
+ DEBUG_P("XF86VidModeSwitchMode");
+
+ REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ VidModeZoomViewport(stuff->screen, (short)stuff->zoom);
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeSwitchToMode(ClientPtr client)
+{
+ REQUEST(xXF86VidModeSwitchToModeReq);
+ xXF86OldVidModeSwitchToModeReq *oldstuff =
+ (xXF86OldVidModeSwitchToModeReq *)client->requestBuffer;
+ xXF86VidModeSwitchToModeReq newstuff;
+ pointer mode;
+ int len, dotClock;
+ int ver;
+
+ DEBUG_P("XF86VidModeSwitchToMode");
+
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ /* convert from old format */
+ stuff = &newstuff;
+ stuff->length = oldstuff->length;
+ stuff->screen = oldstuff->screen;
+ stuff->dotclock = oldstuff->dotclock;
+ stuff->hdisplay = oldstuff->hdisplay;
+ stuff->hsyncstart = oldstuff->hsyncstart;
+ stuff->hsyncend = oldstuff->hsyncend;
+ stuff->htotal = oldstuff->htotal;
+ stuff->hskew = 0;
+ stuff->vdisplay = oldstuff->vdisplay;
+ stuff->vsyncstart = oldstuff->vsyncstart;
+ stuff->vsyncend = oldstuff->vsyncend;
+ stuff->vtotal = oldstuff->vtotal;
+ stuff->flags = oldstuff->flags;
+ stuff->privsize = oldstuff->privsize;
+ }
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("SwitchToMode - scrn: %d clock: %ld\n",
+ (int)stuff->screen, (unsigned long)stuff->dotclock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ stuff->hdisplay, stuff->hsyncstart,
+ stuff->hsyncend, stuff->htotal);
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n",
+ stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
+ stuff->vtotal, (unsigned long)stuff->flags);
+ }
+
+ if (ver < 2) {
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeSwitchToModeReq);
+ len = client->req_len - (sizeof(xXF86OldVidModeSwitchToModeReq) >> 2);
+ } else {
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeSwitchToModeReq);
+ len = client->req_len - (sizeof(xXF86VidModeSwitchToModeReq) >> 2);
+ }
+ if (len != stuff->privsize)
+ return BadLength;
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock))
+ return BadValue;
+
+ if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock)
+ && MODEMATCH(mode, stuff))
+ return (client->noClientException);
+
+ if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
+ return BadValue;
+
+ do {
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+ ErrorF("Checking against clock: %d (%d)\n",
+ VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock);
+ ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n",
+ VidModeGetModeValue(mode, VIDMODE_H_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_H_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_H_TOTAL));
+ ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n",
+ VidModeGetModeValue(mode, VIDMODE_V_DISPLAY),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART),
+ VidModeGetModeValue(mode, VIDMODE_V_SYNCEND),
+ VidModeGetModeValue(mode, VIDMODE_V_TOTAL),
+ VidModeGetModeValue(mode, VIDMODE_FLAGS));
+ }
+ if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) &&
+ MODEMATCH(mode, stuff)) {
+
+ if (!VidModeSwitchMode(stuff->screen, mode))
+ return BadValue;
+
+ if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY)
+ ErrorF("SwitchToMode - Succeeded\n");
+ return(client->noClientException);
+ }
+ } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock));
+
+ return BadValue;
+}
+
+static int
+ProcXF86VidModeLockModeSwitch(ClientPtr client)
+{
+ REQUEST(xXF86VidModeLockModeSwitchReq);
+
+ REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
+
+ DEBUG_P("XF86VidModeLockModeSwitch");
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!VidModeLockZoom(stuff->screen, (short)stuff->lock))
+ return VidModeErrorBase + XF86VidModeZoomLocked;
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeGetMonitor(ClientPtr client)
+{
+ REQUEST(xXF86VidModeGetMonitorReq);
+ xXF86VidModeGetMonitorReply rep;
+ register int n;
+ CARD32 *hsyncdata, *vsyncdata;
+ int i, nHsync, nVrefresh;
+ pointer monitor;
+
+ DEBUG_P("XF86VidModeGetMonitor");
+
+ REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!VidModeGetMonitor(stuff->screen, &monitor))
+ return BadValue;
+
+ nHsync = VidModeGetMonitorValue(monitor, VIDMODE_MON_NHSYNC, 0).i;
+ nVrefresh = VidModeGetMonitorValue(monitor, VIDMODE_MON_NVREFRESH, 0).i;
+
+ rep.type = X_Reply;
+ if ((char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr)
+ rep.vendorLength = strlen((char *)(VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_VENDOR, 0)).ptr);
+ else
+ rep.vendorLength = 0;
+ if ((char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr)
+ rep.modelLength = strlen((char *)(VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_MODEL, 0)).ptr);
+ else
+ rep.modelLength = 0;
+ rep.length = (SIZEOF(xXF86VidModeGetMonitorReply) - SIZEOF(xGenericReply) +
+ (nHsync + nVrefresh) * sizeof(CARD32) +
+ ((rep.vendorLength + 3) & ~3) +
+ ((rep.modelLength + 3) & ~3)) >> 2;
+ rep.sequenceNumber = client->sequence;
+ rep.nhsync = nHsync;
+ rep.nvsync = nVrefresh;
+ hsyncdata = ALLOCATE_LOCAL(nHsync * sizeof(CARD32));
+ if (!hsyncdata) {
+ return BadAlloc;
+ }
+
+ vsyncdata = ALLOCATE_LOCAL(nVrefresh * sizeof(CARD32));
+ if (!vsyncdata) {
+ DEALLOCATE_LOCAL(hsyncdata);
+ return BadAlloc;
+ }
+
+ for (i = 0; i < nHsync; i++) {
+ hsyncdata[i] = (unsigned short)(VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_HSYNC_LO, i)).f |
+ (unsigned short)(VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_HSYNC_HI, i)).f << 16;
+ }
+ for (i = 0; i < nVrefresh; i++) {
+ vsyncdata[i] = (unsigned short)(VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_VREFRESH_LO, i)).f |
+ (unsigned short)(VidModeGetMonitorValue(monitor,
+ VIDMODE_MON_VREFRESH_HI, i)).f << 16;
+ }
+
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ }
+ WriteToClient(client, SIZEOF(xXF86VidModeGetMonitorReply), (char *)&rep);
+ client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
+ WriteSwappedDataToClient(client, nHsync * sizeof(CARD32),
+ hsyncdata);
+ WriteSwappedDataToClient(client, nVrefresh * sizeof(CARD32),
+ vsyncdata);
+ if (rep.vendorLength)
+ WriteToClient(client, rep.vendorLength, (char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr);
+ if (rep.modelLength)
+ WriteToClient(client, rep.modelLength, (char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr);
+
+ DEALLOCATE_LOCAL(hsyncdata);
+ DEALLOCATE_LOCAL(vsyncdata);
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeGetViewPort(ClientPtr client)
+{
+ REQUEST(xXF86VidModeGetViewPortReq);
+ xXF86VidModeGetViewPortReply rep;
+ int x, y, n;
+
+ DEBUG_P("XF86VidModeGetViewPort");
+
+ REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ VidModeGetViewPort(stuff->screen, &x, &y);
+ rep.x = x;
+ rep.y = y;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.x, n);
+ swapl(&rep.y, n);
+ }
+ WriteToClient(client, SIZEOF(xXF86VidModeGetViewPortReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeSetViewPort(ClientPtr client)
+{
+ REQUEST(xXF86VidModeSetViewPortReq);
+
+ DEBUG_P("XF86VidModeSetViewPort");
+
+ REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!VidModeSetViewPort(stuff->screen, stuff->x, stuff->y))
+ return BadValue;
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeGetDotClocks(ClientPtr client)
+{
+ REQUEST(xXF86VidModeGetDotClocksReq);
+ xXF86VidModeGetDotClocksReply rep;
+ register int n;
+ int numClocks;
+ CARD32 dotclock;
+ int *Clocks = NULL;
+ Bool ClockProg;
+
+ DEBUG_P("XF86VidModeGetDotClocks");
+
+ REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ numClocks = VidModeGetNumOfClocks(stuff->screen, &ClockProg);
+
+ rep.type = X_Reply;
+ rep.length = (SIZEOF(xXF86VidModeGetDotClocksReply)
+ - SIZEOF(xGenericReply) + numClocks) >> 2;
+ rep.sequenceNumber = client->sequence;
+ rep.clocks = numClocks;
+ rep.maxclocks = MAXCLOCKS;
+ rep.flags = 0;
+
+ if (!ClockProg) {
+ Clocks = ALLOCATE_LOCAL(numClocks * sizeof(int));
+ if (!Clocks)
+ return BadValue;
+ if (!VidModeGetClocks(stuff->screen, Clocks)) {
+ DEALLOCATE_LOCAL(Clocks);
+ return BadValue;
+ }
+ }
+
+ if (ClockProg) {
+ rep.flags |= CLKFLAG_PROGRAMABLE;
+ }
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.clocks, n);
+ swapl(&rep.maxclocks, n);
+ swapl(&rep.flags, n);
+ }
+ WriteToClient(client, sizeof(xXF86VidModeGetDotClocksReply), (char *)&rep);
+ if (!ClockProg) {
+ for (n = 0; n < numClocks; n++) {
+ dotclock = *Clocks++;
+ if (client->swapped) {
+ WriteSwappedDataToClient(client, 4, (char *)&dotclock);
+ } else {
+ WriteToClient(client, 4, (char *)&dotclock);
+ }
+ }
+ }
+
+ DEALLOCATE_LOCAL(Clocks);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeSetGamma(ClientPtr client)
+{
+ REQUEST(xXF86VidModeSetGammaReq);
+
+ DEBUG_P("XF86VidModeSetGamma");
+
+ REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if (!VidModeSetGamma(stuff->screen, ((float)stuff->red)/10000.,
+ ((float)stuff->green)/10000., ((float)stuff->blue)/10000.))
+ return BadValue;
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeGetGamma(ClientPtr client)
+{
+ REQUEST(xXF86VidModeGetGammaReq);
+ xXF86VidModeGetGammaReply rep;
+ register int n;
+ float red, green, blue;
+
+ DEBUG_P("XF86VidModeGetGamma");
+
+ REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ if (!VidModeGetGamma(stuff->screen, &red, &green, &blue))
+ return BadValue;
+ rep.red = (CARD32)(red * 10000.);
+ rep.green = (CARD32)(green * 10000.);
+ rep.blue = (CARD32)(blue * 10000.);
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.red, n);
+ swapl(&rep.green, n);
+ swapl(&rep.blue, n);
+ }
+ WriteToClient(client, sizeof(xXF86VidModeGetGammaReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeSetGammaRamp(ClientPtr client)
+{
+ CARD16 *r, *g, *b;
+ int length;
+ REQUEST(xXF86VidModeSetGammaRampReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if(stuff->size != VidModeGetGammaRampSize(stuff->screen))
+ return BadValue;
+
+ length = (stuff->size + 1) & ~1;
+
+ REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length * 6);
+
+ r = (CARD16*)&stuff[1];
+ g = r + length;
+ b = g + length;
+
+ if (!VidModeSetGammaRamp(stuff->screen, stuff->size, r, g, b))
+ return BadValue;
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeGetGammaRamp(ClientPtr client)
+{
+ CARD16 *ramp = NULL;
+ int n, length, i;
+ xXF86VidModeGetGammaRampReply rep;
+ REQUEST(xXF86VidModeGetGammaRampReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ if(stuff->size != VidModeGetGammaRampSize(stuff->screen))
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
+
+ length = (stuff->size + 1) & ~1;
+
+ if(stuff->size) {
+ if(!(ramp = xalloc(length * 3 * sizeof(CARD16))))
+ return BadAlloc;
+
+ if (!VidModeGetGammaRamp(stuff->screen, stuff->size,
+ ramp, ramp + length, ramp + (length * 2)))
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = (length >> 1) * 3;
+ rep.sequenceNumber = client->sequence;
+ rep.size = stuff->size;
+ if(client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.size, n);
+ for(i = 0; i < length * 3; i++)
+ swaps(&ramp[i],n);
+ }
+ WriteToClient(client, sizeof(xXF86VidModeGetGammaRampReply), (char *)&rep);
+
+ if(stuff->size) {
+ WriteToClient(client, rep.length << 2, (char*)ramp);
+ xfree(ramp);
+ }
+
+ return (client->noClientException);
+}
+
+
+static int
+ProcXF86VidModeGetGammaRampSize(ClientPtr client)
+{
+ xXF86VidModeGetGammaRampSizeReply rep;
+ int n;
+ REQUEST(xXF86VidModeGetGammaRampSizeReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.size = VidModeGetGammaRampSize(stuff->screen);
+ if(client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.size, n);
+ }
+ WriteToClient(client,sizeof(xXF86VidModeGetGammaRampSizeReply),(char*)&rep);
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeGetPermissions(ClientPtr client)
+{
+ xXF86VidModeGetPermissionsReply rep;
+ int n;
+ REQUEST(xXF86VidModeGetPermissionsReq);
+
+ if(stuff->screen >= screenInfo.numScreens)
+ return BadValue;
+
+ REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.permissions = XF86VM_READ_PERMISSION;
+ if (xf86GetVidModeEnabled() &&
+ (xf86GetVidModeAllowNonLocal() || LocalClient (client))) {
+ rep.permissions |= XF86VM_WRITE_PERMISSION;
+ }
+ if(client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.permissions, n);
+ }
+ WriteToClient(client,sizeof(xXF86VidModeGetPermissionsReply),(char*)&rep);
+
+ return (client->noClientException);
+}
+
+
+static int
+ProcXF86VidModeSetClientVersion(ClientPtr client)
+{
+ REQUEST(xXF86VidModeSetClientVersionReq);
+
+ VidModePrivPtr pPriv;
+
+ DEBUG_P("XF86VidModeSetClientVersion");
+
+ REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
+
+ if ((pPriv = VMPRIV(client)) == NULL) {
+ pPriv = xalloc(sizeof(VidModePrivRec));
+ if (!pPriv)
+ return BadAlloc;
+ VMPRIV(client) = pPriv;
+ }
+ pPriv->major = stuff->major;
+ pPriv->minor = stuff->minor;
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86VidModeDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_XF86VidModeQueryVersion:
+ return ProcXF86VidModeQueryVersion(client);
+ case X_XF86VidModeGetModeLine:
+ return ProcXF86VidModeGetModeLine(client);
+ case X_XF86VidModeGetMonitor:
+ return ProcXF86VidModeGetMonitor(client);
+ case X_XF86VidModeGetAllModeLines:
+ return ProcXF86VidModeGetAllModeLines(client);
+ case X_XF86VidModeValidateModeLine:
+ return ProcXF86VidModeValidateModeLine(client);
+ case X_XF86VidModeGetViewPort:
+ return ProcXF86VidModeGetViewPort(client);
+ case X_XF86VidModeGetDotClocks:
+ return ProcXF86VidModeGetDotClocks(client);
+ case X_XF86VidModeSetClientVersion:
+ return ProcXF86VidModeSetClientVersion(client);
+ case X_XF86VidModeGetGamma:
+ return ProcXF86VidModeGetGamma(client);
+ case X_XF86VidModeGetGammaRamp:
+ return ProcXF86VidModeGetGammaRamp(client);
+ case X_XF86VidModeGetGammaRampSize:
+ return ProcXF86VidModeGetGammaRampSize(client);
+ case X_XF86VidModeGetPermissions:
+ return ProcXF86VidModeGetPermissions(client);
+ default:
+ if (!xf86GetVidModeEnabled())
+ return VidModeErrorBase + XF86VidModeExtensionDisabled;
+ if (xf86GetVidModeAllowNonLocal() || LocalClient (client)) {
+ switch (stuff->data) {
+ case X_XF86VidModeAddModeLine:
+ return ProcXF86VidModeAddModeLine(client);
+ case X_XF86VidModeDeleteModeLine:
+ return ProcXF86VidModeDeleteModeLine(client);
+ case X_XF86VidModeModModeLine:
+ return ProcXF86VidModeModModeLine(client);
+ case X_XF86VidModeSwitchMode:
+ return ProcXF86VidModeSwitchMode(client);
+ case X_XF86VidModeSwitchToMode:
+ return ProcXF86VidModeSwitchToMode(client);
+ case X_XF86VidModeLockModeSwitch:
+ return ProcXF86VidModeLockModeSwitch(client);
+ case X_XF86VidModeSetViewPort:
+ return ProcXF86VidModeSetViewPort(client);
+ case X_XF86VidModeSetGamma:
+ return ProcXF86VidModeSetGamma(client);
+ case X_XF86VidModeSetGammaRamp:
+ return ProcXF86VidModeSetGammaRamp(client);
+ default:
+ return BadRequest;
+ }
+ } else
+ return VidModeErrorBase + XF86VidModeClientNotLocal;
+ }
+}
+
+static int
+SProcXF86VidModeQueryVersion(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeQueryVersionReq);
+ swaps(&stuff->length, n);
+ return ProcXF86VidModeQueryVersion(client);
+}
+
+static int
+SProcXF86VidModeGetModeLine(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeGetModeLineReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
+ swaps(&stuff->screen, n);
+ return ProcXF86VidModeGetModeLine(client);
+}
+
+static int
+SProcXF86VidModeGetAllModeLines(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeGetAllModeLinesReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
+ swaps(&stuff->screen, n);
+ return ProcXF86VidModeGetAllModeLines(client);
+}
+
+static int
+SProcXF86VidModeAddModeLine(ClientPtr client)
+{
+ xXF86OldVidModeAddModeLineReq *oldstuff =
+ (xXF86OldVidModeAddModeLineReq *)client->requestBuffer;
+ int ver;
+ register int n;
+
+ REQUEST(xXF86VidModeAddModeLineReq);
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ swaps(&oldstuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
+ swapl(&oldstuff->screen, n);
+ swaps(&oldstuff->hdisplay, n);
+ swaps(&oldstuff->hsyncstart, n);
+ swaps(&oldstuff->hsyncend, n);
+ swaps(&oldstuff->htotal, n);
+ swaps(&oldstuff->vdisplay, n);
+ swaps(&oldstuff->vsyncstart, n);
+ swaps(&oldstuff->vsyncend, n);
+ swaps(&oldstuff->vtotal, n);
+ swapl(&oldstuff->flags, n);
+ swapl(&oldstuff->privsize, n);
+ SwapRestL(oldstuff);
+ } else {
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
+ swapl(&stuff->screen, n);
+ swaps(&stuff->hdisplay, n);
+ swaps(&stuff->hsyncstart, n);
+ swaps(&stuff->hsyncend, n);
+ swaps(&stuff->htotal, n);
+ swaps(&stuff->hskew, n);
+ swaps(&stuff->vdisplay, n);
+ swaps(&stuff->vsyncstart, n);
+ swaps(&stuff->vsyncend, n);
+ swaps(&stuff->vtotal, n);
+ swapl(&stuff->flags, n);
+ swapl(&stuff->privsize, n);
+ SwapRestL(stuff);
+ }
+ return ProcXF86VidModeAddModeLine(client);
+}
+
+static int
+SProcXF86VidModeDeleteModeLine(ClientPtr client)
+{
+ xXF86OldVidModeDeleteModeLineReq *oldstuff =
+ (xXF86OldVidModeDeleteModeLineReq *)client->requestBuffer;
+ int ver;
+ register int n;
+
+ REQUEST(xXF86VidModeDeleteModeLineReq);
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ swaps(&oldstuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
+ swapl(&oldstuff->screen, n);
+ swaps(&oldstuff->hdisplay, n);
+ swaps(&oldstuff->hsyncstart, n);
+ swaps(&oldstuff->hsyncend, n);
+ swaps(&oldstuff->htotal, n);
+ swaps(&oldstuff->vdisplay, n);
+ swaps(&oldstuff->vsyncstart, n);
+ swaps(&oldstuff->vsyncend, n);
+ swaps(&oldstuff->vtotal, n);
+ swapl(&oldstuff->flags, n);
+ swapl(&oldstuff->privsize, n);
+ SwapRestL(oldstuff);
+ } else {
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
+ swapl(&stuff->screen, n);
+ swaps(&stuff->hdisplay, n);
+ swaps(&stuff->hsyncstart, n);
+ swaps(&stuff->hsyncend, n);
+ swaps(&stuff->htotal, n);
+ swaps(&stuff->hskew, n);
+ swaps(&stuff->vdisplay, n);
+ swaps(&stuff->vsyncstart, n);
+ swaps(&stuff->vsyncend, n);
+ swaps(&stuff->vtotal, n);
+ swapl(&stuff->flags, n);
+ swapl(&stuff->privsize, n);
+ SwapRestL(stuff);
+ }
+ return ProcXF86VidModeDeleteModeLine(client);
+}
+
+static int
+SProcXF86VidModeModModeLine(ClientPtr client)
+{
+ xXF86OldVidModeModModeLineReq *oldstuff =
+ (xXF86OldVidModeModModeLineReq *)client->requestBuffer;
+ int ver;
+ register int n;
+
+ REQUEST(xXF86VidModeModModeLineReq);
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ swaps(&oldstuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
+ swapl(&oldstuff->screen, n);
+ swaps(&oldstuff->hdisplay, n);
+ swaps(&oldstuff->hsyncstart, n);
+ swaps(&oldstuff->hsyncend, n);
+ swaps(&oldstuff->htotal, n);
+ swaps(&oldstuff->vdisplay, n);
+ swaps(&oldstuff->vsyncstart, n);
+ swaps(&oldstuff->vsyncend, n);
+ swaps(&oldstuff->vtotal, n);
+ swapl(&oldstuff->flags, n);
+ swapl(&oldstuff->privsize, n);
+ SwapRestL(oldstuff);
+ } else {
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
+ swapl(&stuff->screen, n);
+ swaps(&stuff->hdisplay, n);
+ swaps(&stuff->hsyncstart, n);
+ swaps(&stuff->hsyncend, n);
+ swaps(&stuff->htotal, n);
+ swaps(&stuff->hskew, n);
+ swaps(&stuff->vdisplay, n);
+ swaps(&stuff->vsyncstart, n);
+ swaps(&stuff->vsyncend, n);
+ swaps(&stuff->vtotal, n);
+ swapl(&stuff->flags, n);
+ swapl(&stuff->privsize, n);
+ SwapRestL(stuff);
+ }
+ return ProcXF86VidModeModModeLine(client);
+}
+
+static int
+SProcXF86VidModeValidateModeLine(ClientPtr client)
+{
+ xXF86OldVidModeValidateModeLineReq *oldstuff =
+ (xXF86OldVidModeValidateModeLineReq *)client->requestBuffer;
+ int ver;
+ register int n;
+
+ REQUEST(xXF86VidModeValidateModeLineReq);
+ ver = ClientMajorVersion(client);
+ if (ver < 2) {
+ swaps(&oldstuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
+ swapl(&oldstuff->screen, n);
+ swaps(&oldstuff->hdisplay, n);
+ swaps(&oldstuff->hsyncstart, n);
+ swaps(&oldstuff->hsyncend, n);
+ swaps(&oldstuff->htotal, n);
+ swaps(&oldstuff->vdisplay, n);
+ swaps(&oldstuff->vsyncstart, n);
+ swaps(&oldstuff->vsyncend, n);
+ swaps(&oldstuff->vtotal, n);
+ swapl(&oldstuff->flags, n);
+ swapl(&oldstuff->privsize, n);
+ SwapRestL(oldstuff);
+ } else {
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
+ swapl(&stuff->screen, n);
+ swaps(&stuff->hdisplay, n);
+ swaps(&stuff->hsyncstart, n);
+ swaps(&stuff->hsyncend, n);
+ swaps(&stuff->htotal, n);
+ swaps(&stuff->hskew, n);
+ swaps(&stuff->vdisplay, n);
+ swaps(&stuff->vsyncstart, n);
+ swaps(&stuff->vsyncend, n);
+ swaps(&stuff->vtotal, n);
+ swapl(&stuff->flags, n);
+ swapl(&stuff->privsize, n);
+ SwapRestL(stuff);
+ }
+ return ProcXF86VidModeValidateModeLine(client);
+}
+
+static int
+SProcXF86VidModeSwitchMode(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeSwitchModeReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq);
+ swaps(&stuff->screen, n);
+ swaps(&stuff->zoom, n);
+ return ProcXF86VidModeSwitchMode(client);
+}
+
+static int
+SProcXF86VidModeSwitchToMode(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeSwitchToModeReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeSwitchToModeReq);
+ swaps(&stuff->screen, n);
+ return ProcXF86VidModeSwitchToMode(client);
+}
+
+static int
+SProcXF86VidModeLockModeSwitch(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeLockModeSwitchReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
+ swaps(&stuff->screen, n);
+ swaps(&stuff->lock, n);
+ return ProcXF86VidModeLockModeSwitch(client);
+}
+
+static int
+SProcXF86VidModeGetMonitor(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeGetMonitorReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
+ swaps(&stuff->screen, n);
+ return ProcXF86VidModeGetMonitor(client);
+}
+
+static int
+SProcXF86VidModeGetViewPort(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeGetViewPortReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
+ swaps(&stuff->screen, n);
+ return ProcXF86VidModeGetViewPort(client);
+}
+
+static int
+SProcXF86VidModeSetViewPort(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeSetViewPortReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
+ swaps(&stuff->screen, n);
+ swapl(&stuff->x, n);
+ swapl(&stuff->y, n);
+ return ProcXF86VidModeSetViewPort(client);
+}
+
+static int
+SProcXF86VidModeGetDotClocks(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeGetDotClocksReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
+ swaps(&stuff->screen, n);
+ return ProcXF86VidModeGetDotClocks(client);
+}
+
+static int
+SProcXF86VidModeSetClientVersion(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeSetClientVersionReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
+ swaps(&stuff->major, n);
+ swaps(&stuff->minor, n);
+ return ProcXF86VidModeSetClientVersion(client);
+}
+
+static int
+SProcXF86VidModeSetGamma(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeSetGammaReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq);
+ swaps(&stuff->screen, n);
+ swapl(&stuff->red, n);
+ swapl(&stuff->green, n);
+ swapl(&stuff->blue, n);
+ return ProcXF86VidModeSetGamma(client);
+}
+
+static int
+SProcXF86VidModeGetGamma(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86VidModeGetGammaReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
+ swaps(&stuff->screen, n);
+ return ProcXF86VidModeGetGamma(client);
+}
+
+static int
+SProcXF86VidModeSetGammaRamp(ClientPtr client)
+{
+ CARD16 *ramp;
+ int length, n;
+ REQUEST(xXF86VidModeSetGammaRampReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq);
+ swaps(&stuff->size, n);
+ swaps(&stuff->screen, n);
+ length = ((stuff->size + 1) & ~1) * 6;
+ REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length);
+ ramp = (CARD16*)&stuff[1];
+ while(length--) {
+ swaps(ramp, n);
+ ramp++;
+ }
+ return ProcXF86VidModeSetGammaRamp(client);
+}
+
+static int
+SProcXF86VidModeGetGammaRamp(ClientPtr client)
+{
+ int n;
+ REQUEST(xXF86VidModeGetGammaRampReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
+ swaps(&stuff->size, n);
+ swaps(&stuff->screen, n);
+ return ProcXF86VidModeGetGammaRamp(client);
+}
+
+static int
+SProcXF86VidModeGetGammaRampSize(ClientPtr client)
+{
+ int n;
+ REQUEST(xXF86VidModeGetGammaRampSizeReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
+ swaps(&stuff->screen, n);
+ return ProcXF86VidModeGetGammaRampSize(client);
+}
+
+static int
+SProcXF86VidModeGetPermissions(ClientPtr client)
+{
+ int n;
+ REQUEST(xXF86VidModeGetPermissionsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
+ swaps(&stuff->screen, n);
+ return ProcXF86VidModeGetPermissions(client);
+}
+
+
+static int
+SProcXF86VidModeDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_XF86VidModeQueryVersion:
+ return SProcXF86VidModeQueryVersion(client);
+ case X_XF86VidModeGetModeLine:
+ return SProcXF86VidModeGetModeLine(client);
+ case X_XF86VidModeGetMonitor:
+ return SProcXF86VidModeGetMonitor(client);
+ case X_XF86VidModeGetAllModeLines:
+ return SProcXF86VidModeGetAllModeLines(client);
+ case X_XF86VidModeGetViewPort:
+ return SProcXF86VidModeGetViewPort(client);
+ case X_XF86VidModeValidateModeLine:
+ return SProcXF86VidModeValidateModeLine(client);
+ case X_XF86VidModeGetDotClocks:
+ return SProcXF86VidModeGetDotClocks(client);
+ case X_XF86VidModeSetClientVersion:
+ return SProcXF86VidModeSetClientVersion(client);
+ case X_XF86VidModeGetGamma:
+ return SProcXF86VidModeGetGamma(client);
+ case X_XF86VidModeGetGammaRamp:
+ return SProcXF86VidModeGetGammaRamp(client);
+ case X_XF86VidModeGetGammaRampSize:
+ return SProcXF86VidModeGetGammaRampSize(client);
+ case X_XF86VidModeGetPermissions:
+ return SProcXF86VidModeGetPermissions(client);
+ default:
+ if (!xf86GetVidModeEnabled())
+ return VidModeErrorBase + XF86VidModeExtensionDisabled;
+ if (xf86GetVidModeAllowNonLocal() || LocalClient(client)) {
+ switch (stuff->data) {
+ case X_XF86VidModeAddModeLine:
+ return SProcXF86VidModeAddModeLine(client);
+ case X_XF86VidModeDeleteModeLine:
+ return SProcXF86VidModeDeleteModeLine(client);
+ case X_XF86VidModeModModeLine:
+ return SProcXF86VidModeModModeLine(client);
+ case X_XF86VidModeSwitchMode:
+ return SProcXF86VidModeSwitchMode(client);
+ case X_XF86VidModeSwitchToMode:
+ return SProcXF86VidModeSwitchToMode(client);
+ case X_XF86VidModeLockModeSwitch:
+ return SProcXF86VidModeLockModeSwitch(client);
+ case X_XF86VidModeSetViewPort:
+ return SProcXF86VidModeSetViewPort(client);
+ case X_XF86VidModeSetGamma:
+ return SProcXF86VidModeSetGamma(client);
+ case X_XF86VidModeSetGammaRamp:
+ return SProcXF86VidModeSetGammaRamp(client);
+ default:
+ return BadRequest;
+ }
+ } else
+ return VidModeErrorBase + XF86VidModeClientNotLocal;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xext/xprint.c b/nx-X11/programs/Xserver/Xext/xprint.c
new file mode 100644
index 000000000..60512d372
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xprint.c
@@ -0,0 +1,2760 @@
+/* $Xorg: xprint.c,v 1.5 2001/03/05 20:42:26 pookie Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: xprint.c
+** *
+** * Copyright: Copyright 1993, 1995 Hewlett-Packard Company
+** *
+** * Copyright 1989 by The Massachusetts Institute of Technology
+** *
+** * Permission to use, copy, modify, and distribute this
+** * software and its documentation for any purpose and without
+** * fee is hereby granted, provided that the above copyright
+** * notice appear in all copies and that both that copyright
+** * notice and this permission notice appear in supporting
+** * documentation, and that the name of MIT not be used in
+** * advertising or publicity pertaining to distribution of the
+** * software without specific prior written permission.
+** * M.I.T. makes no representation about the suitability of
+** * this software for any purpose. It is provided "as is"
+** * without any express or implied warranty.
+** *
+** * MIT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+** * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+** * NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MIT BE LI-
+** * ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+** * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+** * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+** * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+** * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+** *
+** *********************************************************
+**
+********************************************************************/
+/* $XFree86: xc/programs/Xserver/Xext/xprint.c,v 1.14tsi Exp $ */
+
+#define _XP_PRINT_SERVER_
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xos.h>
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#undef NEED_EVENTS
+#include "misc.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include <X11/Xatom.h>
+#include <X11/extensions/Print.h>
+#include <X11/extensions/Printstr.h>
+#include "../Xprint/DiPrint.h"
+#include "../Xprint/attributes.h"
+#include "modinit.h"
+
+static void XpResetProc(ExtensionEntry *);
+
+static int ProcXpDispatch(ClientPtr);
+static int ProcXpSwappedDispatch(ClientPtr);
+
+static int ProcXpQueryVersion(ClientPtr);
+static int ProcXpGetPrinterList(ClientPtr);
+static int ProcXpCreateContext(ClientPtr);
+static int ProcXpSetContext(ClientPtr);
+static int ProcXpGetContext(ClientPtr);
+static int ProcXpDestroyContext(ClientPtr);
+static int ProcXpGetContextScreen(ClientPtr);
+static int ProcXpStartJob(ClientPtr);
+static int ProcXpEndJob(ClientPtr);
+static int ProcXpStartDoc(ClientPtr);
+static int ProcXpEndDoc(ClientPtr);
+static int ProcXpStartPage(ClientPtr);
+static int ProcXpEndPage(ClientPtr);
+static int ProcXpSelectInput(ClientPtr);
+static int ProcXpInputSelected(ClientPtr);
+static int ProcXpPutDocumentData(ClientPtr);
+static int ProcXpGetDocumentData(ClientPtr);
+static int ProcXpGetAttributes(ClientPtr);
+static int ProcXpGetOneAttribute(ClientPtr);
+static int ProcXpSetAttributes(ClientPtr);
+static int ProcXpRehashPrinterList(ClientPtr);
+static int ProcXpQueryScreens(ClientPtr);
+static int ProcXpGetPageDimensions(ClientPtr);
+static int ProcXpSetImageResolution(ClientPtr);
+static int ProcXpGetImageResolution(ClientPtr);
+
+static void SwapXpNotifyEvent(xPrintPrintEvent *, xPrintPrintEvent *);
+static void SwapXpAttributeEvent(xPrintAttributeEvent *, xPrintAttributeEvent *);
+
+static int SProcXpGetPrinterList(ClientPtr);
+static int SProcXpCreateContext(ClientPtr);
+static int SProcXpSetContext(ClientPtr);
+static int SProcXpGetContext(ClientPtr);
+static int SProcXpDestroyContext(ClientPtr);
+static int SProcXpGetContextScreen(ClientPtr);
+static int SProcXpStartJob(ClientPtr);
+static int SProcXpEndJob(ClientPtr);
+static int SProcXpStartDoc(ClientPtr);
+static int SProcXpEndDoc(ClientPtr);
+static int SProcXpStartPage(ClientPtr);
+static int SProcXpEndPage(ClientPtr);
+static int SProcXpSelectInput(ClientPtr);
+static int SProcXpInputSelected(ClientPtr);
+static int SProcXpPutDocumentData(ClientPtr);
+static int SProcXpGetDocumentData(ClientPtr);
+static int SProcXpGetAttributes(ClientPtr);
+static int SProcXpGetOneAttribute(ClientPtr);
+static int SProcXpSetAttributes(ClientPtr);
+static int SProcXpRehashPrinterList(ClientPtr);
+static int SProcXpGetPageDimensions(ClientPtr);
+static int SProcXpSetImageResolution(ClientPtr);
+static int SProcXpGetImageResolution(ClientPtr);
+
+static void SendXpNotify(XpContextPtr, int, int);
+static void SendAttributeNotify(XpContextPtr, int);
+static int XpFreeClient(pointer, XID);
+static int XpFreeContext(pointer, XID);
+static int XpFreePage(pointer, XID);
+static Bool XpCloseScreen(int, ScreenPtr);
+static CARD32 GetAllEventMasks(XpContextPtr);
+static struct _XpClient *CreateXpClient(ClientPtr);
+static void InitContextPrivates(XpContextPtr);
+static void ResetContextPrivates(void);
+static struct _XpClient *FindClient(XpContextPtr, ClientPtr);
+static struct _XpClient *AcquireClient(XpContextPtr, ClientPtr);
+
+typedef struct _driver {
+ struct _driver *next;
+ char *name;
+ int (* CreateContext)(XpContextPtr);
+} XpDriverRec, *XpDriverPtr;
+
+typedef struct _xpScreen {
+ Bool (* CloseScreen)(int, ScreenPtr);
+ struct _driver *drivers;
+} XpScreenRec, *XpScreenPtr;
+
+/*
+ * Each context has a list of XpClients indicating which clients have
+ * associated this context with their connection.
+ * Each such client has a RTclient resource allocated for it,
+ * and this per-client
+ * resource is used to delete the XpClientRec if/when the client closes
+ * its connection.
+ * The list of XpClients is also walked if/when the context is destroyed
+ * so that the ContextPtr can be removed from the client's devPrivates.
+ */
+typedef struct _XpClient {
+ struct _XpClient *pNext;
+ ClientPtr client;
+ XpContextPtr context;
+ CARD32 eventMask;
+ XID contextClientID; /* unneeded sanity check? */
+} XpClientRec, *XpClientPtr;
+
+static void FreeXpClient(XpClientPtr, Bool);
+
+/*
+ * Each StartPage request specifies a window which forms the top level
+ * window of the page. One of the following structs is created as a
+ * RTpage resource with the same ID as the window itself. This enables
+ * us to clean up when/if the window is destroyed, and to prevent the
+ * same window from being simultaneously referenced in multiple contexts.
+ * The page resource is created at the first StartPage on a given window,
+ * and is only destroyed when/if the window is destroyed. When the
+ * EndPage is recieved (or an EndDoc or EndJob) the context field is
+ * set to NULL, but the resource remains alive.
+ */
+typedef struct _XpPage {
+ XpContextPtr context;
+} XpPageRec, *XpPagePtr;
+
+typedef struct _XpStPageRec {
+ XpContextPtr pContext;
+ Bool slept;
+ XpPagePtr pPage;
+ WindowPtr pWin;
+} XpStPageRec, *XpStPagePtr;
+
+typedef struct _XpStDocRec {
+ XpContextPtr pContext;
+ Bool slept;
+ CARD8 type;
+} XpStDocRec, *XpStDocPtr;
+
+#define QUADPAD(x) ((((x)+3)>>2)<<2)
+
+/*
+ * Possible bit-mask values in the "state" field of a XpContextRec.
+ */
+#define JOB_STARTED (1 << 0)
+#define DOC_RAW_STARTED (1 << 1)
+#define DOC_COOKED_STARTED (1 << 2)
+#define PAGE_STARTED (1 << 3)
+#define GET_DOC_DATA_STARTED (1 << 4)
+#define JOB_GET_DATA (1 << 5)
+
+static XpScreenPtr XpScreens[MAXSCREENS];
+static unsigned char XpReqCode;
+static int XpEventBase;
+static int XpErrorBase;
+static unsigned long XpGeneration = 0;
+static int XpClientPrivateIndex;
+
+/* Variables for the context private machinery.
+ * These must be initialized at compile time because
+ * main() calls InitOutput before InitExtensions, and the
+ * output drivers are likely to call AllocateContextPrivate.
+ * These variables are reset at CloseScreen time. CloseScreen
+ * is used because it occurs after FreeAllResources, and before
+ * the next InitOutput cycle.
+ */
+static int contextPrivateCount = 0;
+static int contextPrivateLen = 0;
+static unsigned *contextPrivateSizes = (unsigned *)NULL;
+static unsigned totalContextSize = sizeof(XpContextRec);
+
+/*
+ * There are three types of resources involved. One is the resource associated
+ * with the context itself, with an ID specified by a printing client. The
+ * next is a resource created by us on the client's behalf (and unknown to
+ * the client) when a client inits or sets a context which allows us to
+ * track each client's interest in events
+ * on a particular context, and also allows us to clean up this interest
+ * record when/if the client's connection is closed. Finally, there is
+ * a resource created for each window that's specified in a StartPage. This
+ * resource carries the same ID as the window itself, and enables us to
+ * easily prevent the same window being referenced in multiple contexts
+ * simultaneously, and enables us to clean up if the window is destroyed
+ * before the EndPage.
+ */
+static RESTYPE RTclient, RTcontext, RTpage;
+
+/*
+ * allEvents is the OR of all the legal event mask bits.
+ */
+static CARD32 allEvents = XPPrintMask | XPAttributeMask;
+
+
+/*******************************************************************************
+ *
+ * ExtensionInit, Driver Init functions, QueryVersion, and Dispatch procs
+ *
+ ******************************************************************************/
+
+/*
+ * XpExtensionInit
+ *
+ * Called from InitExtensions in main() usually through miinitextension
+ *
+ */
+
+void
+XpExtensionInit(INITARGS)
+{
+ ExtensionEntry *extEntry;
+ int i;
+
+ RTclient = CreateNewResourceType(XpFreeClient);
+ RTcontext = CreateNewResourceType(XpFreeContext);
+ RTpage = CreateNewResourceType(XpFreePage);
+ if (RTclient && RTcontext && RTpage &&
+ (extEntry = AddExtension(XP_PRINTNAME, XP_EVENTS, XP_ERRORS,
+ ProcXpDispatch, ProcXpSwappedDispatch,
+ XpResetProc, StandardMinorOpcode)))
+ {
+ XpReqCode = (unsigned char)extEntry->base;
+ XpEventBase = extEntry->eventBase;
+ XpErrorBase = extEntry->errorBase;
+ EventSwapVector[XpEventBase] = (EventSwapPtr) SwapXpNotifyEvent;
+ EventSwapVector[XpEventBase+1] = (EventSwapPtr) SwapXpAttributeEvent;
+ }
+
+ if(XpGeneration != serverGeneration)
+ {
+ XpClientPrivateIndex = AllocateClientPrivateIndex();
+ /*
+ * We allocate 0 length & simply stuff a pointer to the
+ * ContextRec in the DevUnion.
+ */
+ if(AllocateClientPrivate(XpClientPrivateIndex, 0) != TRUE)
+ {
+ /* we can't alloc a client private, should we bail??? XXX */
+ }
+ XpGeneration = serverGeneration;
+ }
+
+ for(i = 0; i < MAXSCREENS; i++)
+ {
+ /*
+ * If a screen has registered with our extension, then we
+ * wrap the screen's CloseScreen function to allow us to
+ * reset our ContextPrivate stuff. Note that this
+ * requires a printing DDX to call XpRegisterInitFunc
+ * _before_ this extension is initialized - i.e. at screen init
+ * time, _not_ at root window creation time.
+ */
+ if(XpScreens[i] != (XpScreenPtr)NULL)
+ {
+ XpScreens[i]->CloseScreen = screenInfo.screens[i]->CloseScreen;
+ screenInfo.screens[i]->CloseScreen = XpCloseScreen;
+ }
+ }
+ DeclareExtensionSecurity(XP_PRINTNAME, TRUE);
+}
+
+static void
+XpResetProc(ExtensionEntry *extEntry)
+{
+ /*
+ * We can't free up the XpScreens recs here, because extensions are
+ * closed before screens, and our CloseScreen function uses the XpScreens
+ * recs.
+
+ int i;
+
+ for(i = 0; i < MAXSCREENS; i++)
+ {
+ if(XpScreens[i] != (XpScreenPtr)NULL)
+ Xfree(XpScreens[i]);
+ XpScreens[i] = (XpScreenPtr)NULL;
+ }
+ */
+}
+
+static Bool
+XpCloseScreen(int index, ScreenPtr pScreen)
+{
+ Bool (* CloseScreen)(int, ScreenPtr);
+
+ CloseScreen = XpScreens[index]->CloseScreen;
+ if(XpScreens[index] != (XpScreenPtr)NULL)
+ {
+ XpDriverPtr pDriv, nextDriv;
+
+ pDriv = XpScreens[index]->drivers;
+ while(pDriv != (XpDriverPtr)NULL)
+ {
+ nextDriv = pDriv->next;
+ Xfree(pDriv);
+ pDriv = nextDriv;
+ }
+ Xfree(XpScreens[index]);
+ }
+ XpScreens[index] = (XpScreenPtr)NULL;
+
+ /*
+ * It's wasteful to call ResetContextPrivates() at every CloseScreen,
+ * but it's the best we know how to do for now. We do this because we
+ * have to wait until after all resources have been freed (so we know
+ * how to free the ContextRecs), and before the next InitOutput cycle.
+ * See dix/main.c for the order of initialization and reset.
+ */
+ ResetContextPrivates();
+ return (*CloseScreen)(index, pScreen);
+}
+
+#if 0 /* NOT USED */
+static void
+FreeScreenEntry(XpScreenPtr pScreenEntry)
+{
+ XpDriverPtr pDriver;
+
+ pDriver = pScreenEntry->drivers;
+ while(pDriver != (XpDriverPtr)NULL)
+ {
+ XpDriverPtr tmp;
+
+ tmp = pDriver->next;
+ xfree(pDriver);
+ pDriver = tmp;
+ }
+ xfree(pScreenEntry);
+}
+#endif
+
+/*
+ * XpRegisterInitFunc tells the print extension which screens
+ * are printers as opposed to displays, and what drivers are
+ * supported on each screen. This eliminates the need of
+ * allocating print-related private structures on windows on _all_ screens.
+ * It also hands the extension a pointer to the routine to be called
+ * whenever a context gets created for a particular driver on this screen.
+ */
+void
+XpRegisterInitFunc(ScreenPtr pScreen, char *driverName, int (*initContext)(struct _XpContext *))
+{
+ XpDriverPtr pDriver;
+
+ if(XpScreens[pScreen->myNum] == 0)
+ {
+ if((XpScreens[pScreen->myNum] =
+ (XpScreenPtr) Xalloc(sizeof(XpScreenRec))) == 0)
+ return;
+ XpScreens[pScreen->myNum]->CloseScreen = 0;
+ XpScreens[pScreen->myNum]->drivers = 0;
+ }
+
+ if((pDriver = (XpDriverPtr)Xalloc(sizeof(XpDriverRec))) == 0)
+ return;
+ pDriver->next = XpScreens[pScreen->myNum]->drivers;
+ pDriver->name = driverName;
+ pDriver->CreateContext = initContext;
+ XpScreens[pScreen->myNum]->drivers = pDriver;
+}
+
+static int
+ProcXpDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch(stuff->data)
+ {
+ case X_PrintQueryVersion:
+ return ProcXpQueryVersion(client);
+ case X_PrintGetPrinterList:
+ return ProcXpGetPrinterList(client);
+ case X_PrintCreateContext:
+ return ProcXpCreateContext(client);
+ case X_PrintSetContext:
+ return ProcXpSetContext(client);
+ case X_PrintGetContext:
+ return ProcXpGetContext(client);
+ case X_PrintDestroyContext:
+ return ProcXpDestroyContext(client);
+ case X_PrintGetContextScreen:
+ return ProcXpGetContextScreen(client);
+ case X_PrintStartJob:
+ return ProcXpStartJob(client);
+ case X_PrintEndJob:
+ return ProcXpEndJob(client);
+ case X_PrintStartDoc:
+ return ProcXpStartDoc(client);
+ case X_PrintEndDoc:
+ return ProcXpEndDoc(client);
+ case X_PrintStartPage:
+ return ProcXpStartPage(client);
+ case X_PrintEndPage:
+ return ProcXpEndPage(client);
+ case X_PrintSelectInput:
+ return ProcXpSelectInput(client);
+ case X_PrintInputSelected:
+ return ProcXpInputSelected(client);
+ case X_PrintPutDocumentData:
+ return ProcXpPutDocumentData(client);
+ case X_PrintGetDocumentData:
+ return ProcXpGetDocumentData(client);
+ case X_PrintSetAttributes:
+ return ProcXpSetAttributes(client);
+ case X_PrintGetAttributes:
+ return ProcXpGetAttributes(client);
+ case X_PrintGetOneAttribute:
+ return ProcXpGetOneAttribute(client);
+ case X_PrintRehashPrinterList:
+ return ProcXpRehashPrinterList(client);
+ case X_PrintQueryScreens:
+ return ProcXpQueryScreens(client);
+ case X_PrintGetPageDimensions:
+ return ProcXpGetPageDimensions(client);
+ case X_PrintSetImageResolution:
+ return ProcXpSetImageResolution(client);
+ case X_PrintGetImageResolution:
+ return ProcXpGetImageResolution(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static int
+ProcXpSwappedDispatch(ClientPtr client)
+{
+ int temp;
+ REQUEST(xReq);
+
+ switch(stuff->data)
+ {
+ case X_PrintQueryVersion:
+ swaps(&stuff->length, temp);
+ return ProcXpQueryVersion(client);
+ case X_PrintGetPrinterList:
+ return SProcXpGetPrinterList(client);
+ case X_PrintCreateContext:
+ return SProcXpCreateContext(client);
+ case X_PrintSetContext:
+ return SProcXpSetContext(client);
+ case X_PrintGetContext:
+ return SProcXpGetContext(client);
+ case X_PrintDestroyContext:
+ return SProcXpDestroyContext(client);
+ case X_PrintGetContextScreen:
+ return SProcXpGetContextScreen(client);
+ case X_PrintStartJob:
+ return SProcXpStartJob(client);
+ case X_PrintEndJob:
+ return SProcXpEndJob(client);
+ case X_PrintStartDoc:
+ return SProcXpStartDoc(client);
+ case X_PrintEndDoc:
+ return SProcXpEndDoc(client);
+ case X_PrintStartPage:
+ return SProcXpStartPage(client);
+ case X_PrintEndPage:
+ return SProcXpEndPage(client);
+ case X_PrintSelectInput:
+ return SProcXpSelectInput(client);
+ case X_PrintInputSelected:
+ return SProcXpInputSelected(client);
+ case X_PrintPutDocumentData:
+ return SProcXpPutDocumentData(client);
+ case X_PrintGetDocumentData:
+ return SProcXpGetDocumentData(client);
+ case X_PrintSetAttributes:
+ return SProcXpSetAttributes(client);
+ case X_PrintGetAttributes:
+ return SProcXpGetAttributes(client);
+ case X_PrintGetOneAttribute:
+ return SProcXpGetOneAttribute(client);
+ case X_PrintRehashPrinterList:
+ return SProcXpRehashPrinterList(client);
+ case X_PrintQueryScreens:
+ swaps(&stuff->length, temp);
+ return ProcXpQueryScreens(client);
+ case X_PrintGetPageDimensions:
+ return SProcXpGetPageDimensions(client);
+ case X_PrintSetImageResolution:
+ return SProcXpSetImageResolution(client);
+ case X_PrintGetImageResolution:
+ return SProcXpGetImageResolution(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static int
+ProcXpQueryVersion(ClientPtr client)
+{
+ /* REQUEST(xPrintQueryVersionReq); */
+ xPrintQueryVersionReply rep;
+ register int n;
+ long l;
+
+ REQUEST_SIZE_MATCH(xPrintQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = XP_MAJOR_VERSION;
+ rep.minorVersion = XP_MINOR_VERSION;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, l);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sz_xPrintQueryVersionReply, (char *)&rep);
+ return client->noClientException;
+}
+
+/*******************************************************************************
+ *
+ * GetPrinterList : Return a list of all printers associated with this
+ * server. Calls XpDiGetPrinterList, which is defined in
+ * the device-independent code in Xserver/Xprint.
+ *
+ ******************************************************************************/
+
+static int
+ProcXpGetPrinterList(ClientPtr client)
+{
+ REQUEST(xPrintGetPrinterListReq);
+ int totalSize;
+ int numEntries;
+ XpDiListEntry **pList;
+ xPrintGetPrinterListReply *rep;
+ int n, i, totalBytes;
+ long l;
+ char *curByte;
+
+ REQUEST_AT_LEAST_SIZE(xPrintGetPrinterListReq);
+
+ totalSize = ((sz_xPrintGetPrinterListReq) >> 2) +
+ ((stuff->printerNameLen + 3) >> 2) +
+ ((stuff->localeLen + 3) >> 2);
+ if(totalSize != client->req_len)
+ return BadLength;
+
+ pList = XpDiGetPrinterList(stuff->printerNameLen, (char *)(stuff + 1),
+ stuff->localeLen, (char *)((stuff + 1) +
+ QUADPAD(stuff->printerNameLen)));
+
+ for(numEntries = 0, totalBytes = sz_xPrintGetPrinterListReply;
+ pList[numEntries] != (XpDiListEntry *)NULL;
+ numEntries++)
+ {
+ totalBytes += 2 * sizeof(CARD32);
+ totalBytes += QUADPAD(strlen(pList[numEntries]->name));
+ totalBytes += QUADPAD(strlen(pList[numEntries]->description));
+ }
+
+ if((rep = (xPrintGetPrinterListReply *)xalloc(totalBytes)) ==
+ (xPrintGetPrinterListReply *)NULL)
+ return BadAlloc;
+
+ rep->type = X_Reply;
+ rep->length = (totalBytes - sz_xPrintGetPrinterListReply) >> 2;
+ rep->sequenceNumber = client->sequence;
+ rep->listCount = numEntries;
+ if (client->swapped) {
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, l);
+ swapl(&rep->listCount, l);
+ }
+
+ for(i = 0, curByte = (char *)(rep + 1); i < numEntries; i++)
+ {
+ CARD32 *pCrd;
+ int len;
+
+ pCrd = (CARD32 *)curByte;
+ len = strlen(pList[i]->name);
+ *pCrd = len;
+ if (client->swapped)
+ swapl((long *)curByte, l);
+ curByte += sizeof(CARD32);
+ strncpy(curByte, pList[i]->name, len);
+ curByte += QUADPAD(len);
+
+ pCrd = (CARD32 *)curByte;
+ len = strlen(pList[i]->description);
+ *pCrd = len;
+ if (client->swapped)
+ swapl((long *)curByte, l);
+ curByte += sizeof(CARD32);
+ strncpy(curByte, pList[i]->description, len);
+ curByte += QUADPAD(len);
+ }
+
+ XpDiFreePrinterList(pList);
+
+ WriteToClient(client, totalBytes, (char *)rep);
+ xfree(rep);
+ return client->noClientException;
+}
+
+/*******************************************************************************
+ *
+ * QueryScreens: Returns the list of screens which are associated with
+ * print drivers.
+ *
+ ******************************************************************************/
+
+static int
+ProcXpQueryScreens(ClientPtr client)
+{
+ /* REQUEST(xPrintQueryScreensReq); */
+ int i, numPrintScreens, totalSize;
+ WINDOW *pWinId;
+ xPrintQueryScreensReply *rep;
+ long l;
+
+ REQUEST_SIZE_MATCH(xPrintQueryScreensReq);
+
+ rep = (xPrintQueryScreensReply *)xalloc(sz_xPrintQueryScreensReply);
+ pWinId = (WINDOW *)(rep + 1);
+
+ for(i = 0, numPrintScreens = 0, totalSize = sz_xPrintQueryScreensReply;
+ i < MAXSCREENS; i++)
+ {
+ /*
+ * If a screen has registered with our extension, then it's
+ * a printer screen.
+ */
+ if(XpScreens[i] != (XpScreenPtr)NULL)
+ {
+ numPrintScreens++;
+ totalSize += sizeof(WINDOW);
+ rep = (xPrintQueryScreensReply *)xrealloc(rep, totalSize);
+ /* fix of bug: pWinId should be set again after reallocate rep */
+ pWinId = (WINDOW *)(rep + 1);
+ *pWinId = WindowTable[i]->drawable.id;
+ if (client->swapped)
+ swapl((long *)pWinId, l);
+ }
+ }
+
+ rep->type = X_Reply;
+ rep->sequenceNumber = client->sequence;
+ rep->length = (totalSize - sz_xPrintQueryScreensReply) >> 2;
+ rep->listCount = numPrintScreens;
+ if (client->swapped)
+ {
+ int n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, l);
+ swapl(&rep->listCount, l);
+ }
+
+ WriteToClient(client, totalSize, (char *)rep);
+ xfree(rep);
+ return client->noClientException;
+}
+
+static int
+ProcXpGetPageDimensions(ClientPtr client)
+{
+ REQUEST(xPrintGetPageDimensionsReq);
+ CARD16 width, height;
+ xRectangle rect;
+ xPrintGetPageDimensionsReply rep;
+ XpContextPtr pContext;
+ int result;
+
+ REQUEST_SIZE_MATCH(xPrintGetPageDimensionsReq);
+
+ if((pContext =(XpContextPtr)SecurityLookupIDByType(client,
+ stuff->printContext,
+ RTcontext,
+ SecurityReadAccess))
+ == (XpContextPtr)NULL)
+ {
+ client->errorValue = stuff->printContext;
+ return XpErrorBase+XPBadContext;
+ }
+
+ if((pContext->funcs.GetMediumDimensions == 0) ||
+ (pContext->funcs.GetReproducibleArea == 0))
+ return BadImplementation;
+
+ result = pContext->funcs.GetMediumDimensions(pContext, &width, &height);
+ if(result != Success)
+ return result;
+
+ result = pContext->funcs.GetReproducibleArea(pContext, &rect);
+ if(result != Success)
+ return result;
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.width = width;
+ rep.height = height;
+ rep.rx = rect.x;
+ rep.ry = rect.y;
+ rep.rwidth = rect.width;
+ rep.rheight = rect.height;
+
+ if(client->swapped)
+ {
+ int n;
+ long l;
+
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, l);
+ swaps(&rep.width, n);
+ swaps(&rep.height, n);
+ swaps(&rep.rx, n);
+ swaps(&rep.ry, n);
+ swaps(&rep.rwidth, n);
+ swaps(&rep.rheight, n);
+ }
+
+ WriteToClient(client, sz_xPrintGetPageDimensionsReply, (char *)&rep);
+ return client->noClientException;
+}
+
+static int
+ProcXpSetImageResolution(ClientPtr client)
+{
+ REQUEST(xPrintSetImageResolutionReq);
+ xPrintSetImageResolutionReply rep;
+ XpContextPtr pContext;
+ Bool status;
+ int result;
+
+ REQUEST_SIZE_MATCH(xPrintSetImageResolutionReq);
+
+ if((pContext =(XpContextPtr)SecurityLookupIDByType(client,
+ stuff->printContext,
+ RTcontext,
+ SecurityWriteAccess))
+ == (XpContextPtr)NULL)
+ {
+ client->errorValue = stuff->printContext;
+ return XpErrorBase+XPBadContext;
+ }
+
+ rep.prevRes = pContext->imageRes;
+ if(pContext->funcs.SetImageResolution != 0) {
+ result = pContext->funcs.SetImageResolution(pContext,
+ (int)stuff->imageRes,
+ &status);
+ if(result != Success)
+ status = FALSE;
+ } else
+ status = FALSE;
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.status = status;
+
+ if(client->swapped)
+ {
+ int n;
+ long l;
+
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, l);
+ swaps(&rep.prevRes, n);
+ }
+
+ WriteToClient(client, sz_xPrintSetImageResolutionReply, (char *)&rep);
+ return client->noClientException;
+}
+
+static int
+ProcXpGetImageResolution(ClientPtr client)
+{
+ REQUEST(xPrintGetImageResolutionReq);
+ xPrintGetImageResolutionReply rep;
+ XpContextPtr pContext;
+
+ REQUEST_SIZE_MATCH(xPrintGetImageResolutionReq);
+
+ if((pContext =(XpContextPtr)SecurityLookupIDByType(client,
+ stuff->printContext,
+ RTcontext,
+ SecurityReadAccess))
+ == (XpContextPtr)NULL)
+ {
+ client->errorValue = stuff->printContext;
+ return XpErrorBase+XPBadContext;
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.imageRes = pContext->imageRes;
+
+ if(client->swapped)
+ {
+ int n;
+ long l;
+
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, l);
+ swaps(&rep.imageRes, n);
+ }
+
+ WriteToClient(client, sz_xPrintGetImageResolutionReply, (char *)&rep);
+ return client->noClientException;
+}
+
+/*******************************************************************************
+ *
+ * RehashPrinterList : Cause the server's list of printers to be rebuilt.
+ * This allows new printers to be added, or old ones
+ * deleted without needing to restart the server.
+ *
+ ******************************************************************************/
+
+static int
+ProcXpRehashPrinterList(ClientPtr client)
+{
+ /* REQUEST(xPrintRehashPrinterListReq); */
+
+ REQUEST_SIZE_MATCH(xPrintRehashPrinterListReq);
+
+ return XpRehashPrinterList();
+}
+
+/******************************************************************************
+ *
+ * Context functions: Init, Set, Destroy, FreeContext
+ * AllocateContextPrivateIndex, AllocateContextPrivate
+ * and supporting functions.
+ *
+ * Init creates a context, creates a XpClientRec for the calling
+ * client, and stores the contextPtr in the client's devPrivates.
+ *
+ * Set creates a XpClientRec for the calling client, and stores the
+ * contextPtr in the client's devPrivates unless the context is None.
+ * If the context is None, then the client's connection association
+ * with any context is removed.
+ *
+ * Destroy frees any and all XpClientRecs associated with the context,
+ * frees the context itself, and removes the contextPtr from any
+ * relevant client devPrivates.
+ *
+ * FreeContext is called by FreeResource to free up a context.
+ *
+ ******************************************************************************/
+
+/*
+ * CreateContext creates and initializes the memory for the context itself.
+ * The driver's CreateContext function
+ * is then called.
+ */
+static int
+ProcXpCreateContext(ClientPtr client)
+{
+ REQUEST(xPrintCreateContextReq);
+ XpScreenPtr pPrintScreen;
+ WindowPtr pRoot;
+ char *driverName;
+ XpContextPtr pContext;
+ int result = Success;
+ XpDriverPtr pDriver;
+
+ REQUEST_AT_LEAST_SIZE(xPrintCreateContextReq);
+
+ LEGAL_NEW_RESOURCE(stuff->contextID, client);
+
+ /*
+ * Check to see if the printer name is valid.
+ */
+ if((pRoot = XpDiValidatePrinter((char *)(stuff + 1), stuff->printerNameLen)) ==
+ (WindowPtr)NULL)
+ return BadMatch;
+
+ pPrintScreen = XpScreens[pRoot->drawable.pScreen->myNum];
+
+ /*
+ * Allocate and add the context resource.
+ */
+ if((pContext = (XpContextPtr) xalloc(totalContextSize)) ==
+ (XpContextPtr) NULL)
+ return BadAlloc;
+
+ InitContextPrivates(pContext);
+
+ if(AddResource(stuff->contextID, RTcontext, (pointer) pContext)
+ != TRUE)
+ {
+ xfree(pContext);
+ return BadAlloc;
+ }
+
+ pContext->contextID = stuff->contextID;
+ pContext->clientHead = (XpClientPtr)NULL;
+ pContext->screenNum = pRoot->drawable.pScreen->myNum;
+ pContext->state = 0;
+ pContext->clientSlept = (ClientPtr)NULL;
+ pContext->imageRes = 0;
+
+ pContext->funcs.DestroyContext = 0;
+ pContext->funcs.StartJob = 0;
+ pContext->funcs.EndJob = 0;
+ pContext->funcs.StartDoc = 0;
+ pContext->funcs.EndDoc = 0;
+ pContext->funcs.StartPage = 0;
+ pContext->funcs.EndPage = 0;
+ pContext->funcs.PutDocumentData = 0;
+ pContext->funcs.GetDocumentData = 0;
+ pContext->funcs.GetAttributes = 0;
+ pContext->funcs.GetOneAttribute = 0;
+ pContext->funcs.SetAttributes = 0;
+ pContext->funcs.AugmentAttributes = 0;
+ pContext->funcs.GetMediumDimensions = 0;
+ pContext->funcs.GetReproducibleArea = 0;
+ pContext->funcs.SetImageResolution = 0;
+
+ if((pContext->printerName = (char *)xalloc(stuff->printerNameLen + 1)) ==
+ (char *)NULL)
+ {
+ /* Freeing the context also causes the XpClients to be freed. */
+ FreeResource(stuff->contextID, RT_NONE);
+ return BadAlloc;
+ }
+ strncpy(pContext->printerName, (char *)(stuff + 1), stuff->printerNameLen);
+ pContext->printerName[stuff->printerNameLen] = (char)'\0';
+
+ driverName = XpDiGetDriverName(pRoot->drawable.pScreen->myNum,
+ pContext->printerName);
+
+ for(pDriver = pPrintScreen->drivers;
+ pDriver != (XpDriverPtr)NULL;
+ pDriver = pDriver->next)
+ {
+ if(!strcmp(driverName, pDriver->name))
+ {
+ if(pDriver->CreateContext != 0)
+ pDriver->CreateContext(pContext);
+ else
+ return BadImplementation;
+ break;
+ }
+ }
+
+ if (client->noClientException != Success)
+ return client->noClientException;
+ else
+ return result;
+}
+
+/*
+ * SetContext creates the calling client's contextClient resource,
+ * and stashes the contextID in the client's devPrivate.
+ */
+static int
+ProcXpSetContext(ClientPtr client)
+{
+ REQUEST(xPrintSetContextReq);
+
+ XpContextPtr pContext;
+ XpClientPtr pPrintClient;
+ int result = Success;
+
+ REQUEST_AT_LEAST_SIZE(xPrintSetContextReq);
+
+ if((pContext = client->devPrivates[XpClientPrivateIndex].ptr) !=
+ (pointer)NULL)
+ {
+ /*
+ * Erase this client's knowledge of its old context, if any.
+ */
+ if((pPrintClient = FindClient(pContext, client)) != (XpClientPtr)NULL)
+ {
+ XpUnsetFontResFunc(client);
+
+ if(pPrintClient->eventMask == 0)
+ FreeXpClient(pPrintClient, TRUE);
+ }
+
+ client->devPrivates[XpClientPrivateIndex].ptr = (pointer)NULL;
+ }
+ if(stuff->printContext == None)
+ return Success;
+
+ /*
+ * Check to see that the supplied XID is really a valid print context
+ * in this server.
+ */
+ if((pContext =(XpContextPtr)SecurityLookupIDByType(client,
+ stuff->printContext,
+ RTcontext,
+ SecurityWriteAccess))
+ == (XpContextPtr)NULL)
+ {
+ client->errorValue = stuff->printContext;
+ return XpErrorBase+XPBadContext;
+ }
+
+ if((pPrintClient = AcquireClient(pContext, client)) == (XpClientPtr)NULL)
+ return BadAlloc;
+
+ client->devPrivates[XpClientPrivateIndex].ptr = pContext;
+
+ XpSetFontResFunc(client);
+
+ if (client->noClientException != Success)
+ return client->noClientException;
+ else
+ return result;
+}
+
+XpContextPtr
+XpGetPrintContext(ClientPtr client)
+{
+ return (client->devPrivates[XpClientPrivateIndex].ptr);
+}
+
+static int
+ProcXpGetContext(ClientPtr client)
+{
+ /* REQUEST(xPrintGetContextReq); */
+ xPrintGetContextReply rep;
+
+ XpContextPtr pContext;
+ register int n;
+ register long l;
+
+ REQUEST_SIZE_MATCH(xPrintGetContextReq);
+
+ if((pContext = client->devPrivates[XpClientPrivateIndex].ptr) ==
+ (pointer)NULL)
+ rep.printContext = None;
+ else
+ rep.printContext = pContext->contextID;
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, l);
+ swapl(&rep.printContext, l);
+ }
+ WriteToClient(client, sz_xPrintGetContextReply, (char *)&rep);
+ return client->noClientException;
+}
+
+
+/*
+ * DestroyContext frees the context associated with the calling client.
+ * It operates by freeing the context resource ID, thus causing XpFreeContext
+ * to be called.
+ */
+static int
+ProcXpDestroyContext(ClientPtr client)
+{
+ REQUEST(xPrintDestroyContextReq);
+
+ XpContextPtr pContext;
+
+ REQUEST_SIZE_MATCH(xPrintDestroyContextReq);
+
+ if((pContext =(XpContextPtr)SecurityLookupIDByType(client,
+ stuff->printContext,
+ RTcontext,
+ SecurityDestroyAccess))
+ == (XpContextPtr)NULL)
+ {
+ client->errorValue = stuff->printContext;
+ return XpErrorBase+XPBadContext;
+ }
+
+ XpUnsetFontResFunc(client);
+
+ FreeResource(pContext->contextID, RT_NONE);
+
+ return Success;
+}
+
+static int
+ProcXpGetContextScreen(ClientPtr client)
+{
+ REQUEST(xPrintGetContextScreenReq);
+ xPrintGetContextScreenReply rep;
+ XpContextPtr pContext;
+ int n;
+ long l;
+
+ if((pContext =(XpContextPtr)SecurityLookupIDByType(client,
+ stuff->printContext,
+ RTcontext,
+ SecurityReadAccess))
+ == (XpContextPtr)NULL)
+ return XpErrorBase+XPBadContext;
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.rootWindow = WindowTable[pContext->screenNum]->drawable.id;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, l);
+ swapl(&rep.rootWindow, l);
+ }
+
+ WriteToClient(client, sz_xPrintGetContextScreenReply, (char *)&rep);
+ return client->noClientException;
+}
+
+/*
+ * XpFreeContext is the routine called by dix:FreeResource when a context
+ * resource ID is freed.
+ * It checks to see if there's a partial job pending on the context, and
+ * if so it calls the appropriate End procs with the cancel flag set.
+ * It calls the driver's DestroyContext routine to allow the driver to clean
+ * up any context-related memory or state.
+ * It calls FreeXpClient to free all the
+ * associated XpClientRecs and to set all the client->devPrivates to NULL.
+ * It frees the printer name string, and frees the context
+ * itself.
+ */
+static int
+XpFreeContext(pointer data, XID id)
+{
+ XpContextPtr pContext = (XpContextPtr)data;
+
+ /* Clean up any pending job on this context */
+ if(pContext->state != 0)
+ {
+ if(pContext->state & PAGE_STARTED)
+ {
+ WindowPtr pWin = (WindowPtr )LookupIDByType(
+ pContext->pageWin, RT_WINDOW);
+ XpPagePtr pPage = (XpPagePtr)LookupIDByType(
+ pContext->pageWin, RTpage);
+
+ pContext->funcs.EndPage(pContext, pWin);
+ SendXpNotify(pContext, XPEndPageNotify, TRUE);
+ pContext->state &= ~PAGE_STARTED;
+ if(pPage)
+ pPage->context = (XpContextPtr)NULL;
+ }
+ if((pContext->state & DOC_RAW_STARTED) ||
+ (pContext->state & DOC_COOKED_STARTED))
+ {
+ pContext->funcs.EndDoc(pContext, TRUE);
+ SendXpNotify(pContext, XPEndDocNotify, TRUE);
+ pContext->state &= ~DOC_RAW_STARTED;
+ pContext->state &= ~DOC_COOKED_STARTED;
+ }
+ if(pContext->funcs.EndJob != 0)
+ {
+ pContext->funcs.EndJob(pContext, TRUE);
+ SendXpNotify(pContext, XPEndJobNotify, TRUE);
+ pContext->state &= ~JOB_STARTED;
+ pContext->state &= ~GET_DOC_DATA_STARTED;
+ }
+ }
+
+ /*
+ * Tell the driver we're destroying the context
+ * This allows the driver to free and ContextPrivate data
+ */
+ if(pContext->funcs.DestroyContext != 0)
+ pContext->funcs.DestroyContext(pContext);
+
+ /* Free up all the XpClientRecs */
+ while(pContext->clientHead != (XpClientPtr)NULL)
+ {
+ FreeXpClient(pContext->clientHead, TRUE);
+ }
+
+ xfree(pContext->printerName);
+ xfree(pContext);
+ return Success; /* ??? */
+}
+
+/*
+ * XpFreeClient is the routine called by dix:FreeResource when a RTclient
+ * is freed. It simply calls the FreeXpClient routine to do the work.
+ */
+static int
+XpFreeClient(pointer data, XID id)
+{
+ FreeXpClient((XpClientPtr)data, TRUE);
+ return Success;
+}
+
+/*
+ * FreeXpClient
+ * frees the ClientRec passed in, and sets the client->devPrivates to NULL
+ * if the client->devPrivates points to the same context as the XpClient.
+ * Called from XpFreeContext(from FreeResource), and
+ * XpFreeClient. The boolean freeResource specifies whether or not to call
+ * FreeResource for the XpClientRec's XID. We should free it except if we're
+ * called from XpFreeClient (which is itself called from FreeResource for the
+ * XpClientRec's XID).
+ */
+static void
+FreeXpClient(XpClientPtr pXpClient, Bool freeResource)
+{
+ XpClientPtr pCurrent, pPrev;
+ XpContextPtr pContext = pXpClient->context;
+
+ /*
+ * If we're freeing the clientRec associated with the context tied
+ * to the client's devPrivates, then we need to clear the devPrivates.
+ */
+ if(pXpClient->client->devPrivates[XpClientPrivateIndex].ptr ==
+ pXpClient->context)
+ {
+ pXpClient->client->devPrivates[XpClientPrivateIndex].ptr =
+ (pointer)NULL;
+ }
+
+ for(pPrev = (XpClientPtr)NULL, pCurrent = pContext->clientHead;
+ pCurrent != (XpClientPtr)NULL;
+ pCurrent = pCurrent->pNext)
+ {
+ if(pCurrent == pXpClient)
+ {
+ if(freeResource == TRUE)
+ FreeResource (pCurrent->contextClientID, RTclient);
+
+ if (pPrev != (XpClientPtr)NULL)
+ pPrev->pNext = pCurrent->pNext;
+ else
+ pContext->clientHead = pCurrent->pNext;
+
+ xfree (pCurrent);
+ break;
+ }
+ pPrev = pCurrent;
+ }
+}
+
+/*
+ * CreateXpClient takes a ClientPtr and returns a pointer to a
+ * XpClientRec which it allocates. It also initializes the Rec,
+ * including adding a resource on behalf of the client to enable the
+ * freeing of the Rec when the client's connection is closed.
+ */
+static XpClientPtr
+CreateXpClient(ClientPtr client)
+{
+ XpClientPtr pNewPrintClient;
+ XID clientResource;
+
+ if((pNewPrintClient = (XpClientPtr)xalloc(sizeof(XpClientRec))) ==
+ (XpClientPtr)NULL)
+ return (XpClientPtr)NULL;
+
+ clientResource = FakeClientID(client->index);
+ if(!AddResource(clientResource, RTclient, (pointer)pNewPrintClient))
+ {
+ xfree (pNewPrintClient);
+ return (XpClientPtr)NULL;
+ }
+
+ pNewPrintClient->pNext = (XpClientPtr)NULL;
+ pNewPrintClient->client = client;
+ pNewPrintClient->context = (XpContextPtr)NULL;
+ pNewPrintClient->eventMask = 0;
+ pNewPrintClient->contextClientID = clientResource;
+
+ return pNewPrintClient;
+}
+
+/*
+ * XpFreePage is the routine called by dix:FreeResource to free the page
+ * resource built with the same ID as a page window. It checks to see
+ * if we're in the middle of a page, and if so calls the driver's EndPage
+ * function with 'cancel' set TRUE. It frees the memory associated with
+ * the page resource.
+ */
+static int
+XpFreePage(pointer data, XID id)
+{
+ XpPagePtr page = (XpPagePtr)data;
+ int result = Success;
+ WindowPtr pWin = (WindowPtr )LookupIDByType(id, RT_WINDOW);
+
+ /* Check to see if the window's being deleted in the middle of a page */
+ if(page->context != (XpContextPtr)NULL &&
+ page->context->state & PAGE_STARTED)
+ {
+ if(page->context->funcs.EndPage != 0)
+ result = page->context->funcs.EndPage(page->context, pWin);
+ SendXpNotify(page->context, XPEndPageNotify, (int)TRUE);
+ page->context->pageWin = 0; /* None, NULL??? XXX */
+ }
+
+ xfree(page);
+ return result;
+}
+
+/*
+ * ContextPrivate machinery.
+ * Context privates are intended for use by the drivers, allowing the
+ * drivers to maintain context-specific data. The driver should free
+ * the associated data at DestroyContext time.
+ */
+
+static void
+InitContextPrivates(XpContextPtr context)
+{
+ register char *ptr;
+ DevUnion *ppriv;
+ register unsigned *sizes;
+ register unsigned size;
+ register int i;
+
+ if (totalContextSize == sizeof(XpContextRec))
+ ppriv = (DevUnion *)NULL;
+ else
+ ppriv = (DevUnion *)(context + 1);
+
+ context->devPrivates = ppriv;
+ sizes = contextPrivateSizes;
+ ptr = (char *)(ppriv + contextPrivateLen);
+ for (i = contextPrivateLen; --i >= 0; ppriv++, sizes++)
+ {
+ if ( (size = *sizes) )
+ {
+ ppriv->ptr = (pointer)ptr;
+ ptr += size;
+ }
+ else
+ ppriv->ptr = (pointer)NULL;
+ }
+}
+
+static void
+ResetContextPrivates(void)
+{
+ contextPrivateCount = 0;
+ contextPrivateLen = 0;
+ xfree(contextPrivateSizes);
+ contextPrivateSizes = (unsigned *)NULL;
+ totalContextSize = sizeof(XpContextRec);
+
+}
+
+int
+XpAllocateContextPrivateIndex(void)
+{
+ return contextPrivateCount++;
+}
+
+Bool
+XpAllocateContextPrivate(int index, unsigned amount)
+{
+ unsigned oldamount;
+
+ if (index >= contextPrivateLen)
+ {
+ unsigned *nsizes;
+ nsizes = (unsigned *)xrealloc(contextPrivateSizes,
+ (index + 1) * sizeof(unsigned));
+ if (!nsizes)
+ return FALSE;
+ while (contextPrivateLen <= index)
+ {
+ nsizes[contextPrivateLen++] = 0;
+ totalContextSize += sizeof(DevUnion);
+ }
+ contextPrivateSizes = nsizes;
+ }
+ oldamount = contextPrivateSizes[index];
+ if (amount > oldamount)
+ {
+ contextPrivateSizes[index] = amount;
+ totalContextSize += (amount - oldamount);
+ }
+ return TRUE;
+}
+
+static XpClientPtr
+AcquireClient(XpContextPtr pContext, ClientPtr client)
+{
+ XpClientPtr pXpClient;
+
+ if((pXpClient = FindClient(pContext, client)) != (XpClientPtr)NULL)
+ return pXpClient;
+
+ if((pXpClient = CreateXpClient(client)) == (XpClientPtr)NULL)
+ return (XpClientPtr)NULL;
+
+ pXpClient->context = pContext;
+ pXpClient->pNext = pContext->clientHead;
+ pContext->clientHead = pXpClient;
+
+ return pXpClient;
+}
+
+static XpClientPtr
+FindClient(XpContextPtr pContext, ClientPtr client)
+{
+ XpClientPtr pXpClient;
+
+ for(pXpClient = pContext->clientHead; pXpClient != (XpClientPtr)NULL;
+ pXpClient = pXpClient->pNext)
+ {
+ if(pXpClient->client == client) return pXpClient;
+ }
+ return (XpClientPtr)NULL;
+}
+
+
+/******************************************************************************
+ *
+ * Start/End Functions: StartJob, EndJob, StartDoc, EndDoc, StartPage, EndPage
+ *
+ ******************************************************************************/
+
+static int
+ProcXpStartJob(ClientPtr client)
+{
+ REQUEST(xPrintStartJobReq);
+ XpContextPtr pContext;
+ int result = Success;
+
+ REQUEST_SIZE_MATCH(xPrintStartJobReq);
+
+ /* Check to see that a context has been established by this client. */
+ if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
+ == (XpContextPtr)NULL)
+ return XpErrorBase+XPBadContext;
+
+ if(pContext->state != 0)
+ return XpErrorBase+XPBadSequence;
+
+ if(stuff->saveData != XPSpool && stuff->saveData != XPGetData)
+ {
+ client->errorValue = stuff->saveData;
+ return BadValue;
+ }
+
+ if(pContext->funcs.StartJob != 0)
+ result = pContext->funcs.StartJob(pContext,
+ (stuff->saveData == XPGetData)? TRUE:FALSE,
+ client);
+ else
+ return BadImplementation;
+
+ pContext->state = JOB_STARTED;
+ if(stuff->saveData == XPGetData)
+ pContext->state |= JOB_GET_DATA;
+
+ SendXpNotify(pContext, XPStartJobNotify, FALSE);
+
+ if (client->noClientException != Success)
+ return client->noClientException;
+ else
+ return result;
+}
+
+static int
+ProcXpEndJob(ClientPtr client)
+{
+ REQUEST(xPrintEndJobReq);
+ int result = Success;
+ XpContextPtr pContext;
+
+ REQUEST_SIZE_MATCH(xPrintEndJobReq);
+
+ if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
+ == (XpContextPtr)NULL)
+ return XpErrorBase+XPBadSequence;
+
+ if(!(pContext->state & JOB_STARTED))
+ return XpErrorBase+XPBadSequence;
+
+ /* Check for missing EndDoc */
+ if((pContext->state & DOC_RAW_STARTED) ||
+ (pContext->state & DOC_COOKED_STARTED))
+ {
+ if(pContext->state & PAGE_STARTED)
+ {
+ WindowPtr pWin = (WindowPtr )LookupIDByType(
+ pContext->pageWin, RT_WINDOW);
+ XpPagePtr pPage = (XpPagePtr)LookupIDByType(
+ pContext->pageWin, RTpage);
+
+ if(stuff->cancel != TRUE)
+ return XpErrorBase+XPBadSequence;
+
+ if(pContext->funcs.EndPage != 0)
+ result = pContext->funcs.EndPage(pContext, pWin);
+ else
+ return BadImplementation;
+
+ SendXpNotify(pContext, XPEndPageNotify, TRUE);
+
+ pContext->state &= ~PAGE_STARTED;
+
+ if(pPage)
+ pPage->context = (XpContextPtr)NULL;
+
+ if(result != Success) return result;
+ }
+
+ if(pContext->funcs.EndDoc != 0)
+ result = pContext->funcs.EndDoc(pContext, stuff->cancel);
+ else
+ return BadImplementation;
+
+ SendXpNotify(pContext, XPEndDocNotify, stuff->cancel);
+ }
+
+ if(pContext->funcs.EndJob != 0)
+ result = pContext->funcs.EndJob(pContext, stuff->cancel);
+ else
+ return BadImplementation;
+
+ pContext->state = 0;
+
+ SendXpNotify(pContext, XPEndJobNotify, stuff->cancel);
+
+ if (client->noClientException != Success)
+ return client->noClientException;
+ else
+ return result;
+}
+
+static Bool
+DoStartDoc(ClientPtr client, XpStDocPtr c)
+{
+ XpContextPtr pContext = c->pContext;
+
+ if(c->pContext->state & JOB_GET_DATA &&
+ !(c->pContext->state & GET_DOC_DATA_STARTED))
+ {
+ if(!c->slept)
+ {
+ c->slept = TRUE;
+ ClientSleep(client, (ClientSleepProcPtr)DoStartDoc, (pointer) c);
+ c->pContext->clientSlept = client;
+ }
+ return TRUE;
+ }
+
+ if(pContext->funcs.StartDoc != 0)
+ (void) pContext->funcs.StartDoc(pContext, c->type);
+ else
+ {
+ SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0,
+ BadImplementation);
+ return TRUE;
+ }
+
+ if(c->type == XPDocNormal)
+ pContext->state |= DOC_COOKED_STARTED;
+ else
+ pContext->state |= DOC_RAW_STARTED;
+
+ SendXpNotify(pContext, XPStartDocNotify, (int)FALSE);
+
+ xfree(c);
+ return TRUE;
+}
+
+static int
+ProcXpStartDoc(ClientPtr client)
+{
+ REQUEST(xPrintStartDocReq);
+ int result = Success;
+ XpContextPtr pContext;
+ XpStDocPtr c;
+
+ REQUEST_SIZE_MATCH(xPrintStartDocReq);
+
+ if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
+ == (XpContextPtr)NULL)
+ return XpErrorBase+XPBadSequence;
+
+ if(!(pContext->state & JOB_STARTED) ||
+ pContext->state & DOC_RAW_STARTED ||
+ pContext->state & DOC_COOKED_STARTED)
+ return XpErrorBase+XPBadSequence;
+
+ if(stuff->type != XPDocNormal && stuff->type != XPDocRaw)
+ {
+ client->errorValue = stuff->type;
+ return BadValue;
+ }
+
+ c = (XpStDocPtr)xalloc(sizeof(XpStDocRec));
+ c->pContext = pContext;
+ c->type = stuff->type;
+ c->slept = FALSE;
+ (void)DoStartDoc(client, c);
+
+ if (client->noClientException != Success)
+ return client->noClientException;
+ else
+ return result;
+}
+
+static int
+ProcXpEndDoc(ClientPtr client)
+{
+ REQUEST(xPrintEndDocReq);
+ XpContextPtr pContext;
+ int result = Success;
+
+ REQUEST_SIZE_MATCH(xPrintEndDocReq);
+
+ if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
+ == (XpContextPtr)NULL)
+ return XpErrorBase+XPBadSequence;
+
+ if(!(pContext->state & DOC_RAW_STARTED) &&
+ !(pContext->state & DOC_COOKED_STARTED))
+ return XpErrorBase+XPBadSequence;
+
+ if(pContext->state & PAGE_STARTED)
+ {
+ if(stuff->cancel == TRUE)
+ {
+ WindowPtr pWin = (WindowPtr )LookupIDByType(
+ pContext->pageWin, RT_WINDOW);
+ XpPagePtr pPage = (XpPagePtr)LookupIDByType(
+ pContext->pageWin, RTpage);
+
+ if(pContext->funcs.EndPage != 0)
+ result = pContext->funcs.EndPage(pContext, pWin);
+ else
+ return BadImplementation;
+
+ SendXpNotify(pContext, XPEndPageNotify, TRUE);
+
+ if(pPage)
+ pPage->context = (XpContextPtr)NULL;
+ }
+ else
+ return XpErrorBase+XPBadSequence;
+ if(result != Success)
+ return result;
+ }
+
+ if(pContext->funcs.EndDoc != 0)
+ result = pContext->funcs.EndDoc(pContext, stuff->cancel);
+ else
+ return BadImplementation;
+
+ pContext->state &= ~DOC_RAW_STARTED;
+ pContext->state &= ~DOC_COOKED_STARTED;
+
+ SendXpNotify(pContext, XPEndDocNotify, stuff->cancel);
+
+ if (client->noClientException != Success)
+ return client->noClientException;
+ else
+ return result;
+}
+
+static Bool
+DoStartPage(
+ ClientPtr client,
+ XpStPagePtr c)
+{
+ WindowPtr pWin = c->pWin;
+ int result = Success;
+ XpContextPtr pContext = c->pContext;
+ XpPagePtr pPage;
+
+ if(c->pContext->state & JOB_GET_DATA &&
+ !(c->pContext->state & GET_DOC_DATA_STARTED))
+ {
+ if(!c->slept)
+ {
+ c->slept = TRUE;
+ ClientSleep(client, (ClientSleepProcPtr)DoStartPage, (pointer) c);
+ c->pContext->clientSlept = client;
+ }
+ return TRUE;
+ }
+
+ if(!(pContext->state & DOC_COOKED_STARTED))
+ {
+ /* Implied StartDoc if it was omitted */
+ if(pContext->funcs.StartDoc != 0)
+ result = pContext->funcs.StartDoc(pContext, XPDocNormal);
+ else
+ {
+ SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0,
+ BadImplementation);
+ return TRUE;
+ }
+
+ if(result != Success)
+ {
+ SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0, result);
+ return TRUE;
+ }
+
+ pContext->state |= DOC_COOKED_STARTED;
+ SendXpNotify(pContext, XPStartDocNotify, (int)FALSE);
+ }
+
+ /* ensure the window's not already being used as a page */
+ if((pPage = (XpPagePtr)LookupIDByType(c->pWin->drawable.id, RTpage)) !=
+ (XpPagePtr)NULL)
+ {
+ if(pPage->context != (XpContextPtr)NULL)
+ {
+ SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0,
+ BadWindow);
+ return TRUE;
+ }
+ }
+ else
+ {
+ if((pPage = (XpPagePtr)xalloc(sizeof(XpPageRec))) == (XpPagePtr)NULL)
+ {
+ SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0,
+ BadAlloc);
+ return TRUE;
+ }
+ if(AddResource(c->pWin->drawable.id, RTpage, pPage) == FALSE)
+ {
+ xfree(pPage);
+ SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0,
+ BadAlloc);
+ return TRUE;
+ }
+ }
+
+ pPage->context = pContext;
+ pContext->pageWin = c->pWin->drawable.id;
+
+ if(pContext->funcs.StartPage != 0)
+ result = pContext->funcs.StartPage(pContext, pWin);
+ else
+ {
+ SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0,
+ BadImplementation);
+ return TRUE;
+ }
+
+ pContext->state |= PAGE_STARTED;
+
+ (void)MapWindow(pWin, client);
+
+ SendXpNotify(pContext, XPStartPageNotify, (int)FALSE);
+
+ return TRUE;
+}
+
+static int
+ProcXpStartPage(ClientPtr client)
+{
+ REQUEST(xPrintStartPageReq);
+ WindowPtr pWin;
+ int result = Success;
+ XpContextPtr pContext;
+ XpStPagePtr c;
+
+ REQUEST_SIZE_MATCH(xPrintStartPageReq);
+
+ if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
+ == (XpContextPtr)NULL)
+ return XpErrorBase+XPBadSequence;
+
+ if(!(pContext->state & JOB_STARTED))
+ return XpErrorBase+XPBadSequence;
+
+ /* can't have pages in a raw documented */
+ if(pContext->state & DOC_RAW_STARTED)
+ return XpErrorBase+XPBadSequence;
+
+ if(pContext->state & PAGE_STARTED)
+ return XpErrorBase+XPBadSequence;
+
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityWriteAccess);
+ if (!pWin || pWin->drawable.pScreen->myNum != pContext->screenNum)
+ return BadWindow;
+
+ if((c = (XpStPagePtr)xalloc(sizeof(XpStPageRec))) == (XpStPagePtr)NULL)
+ return BadAlloc;
+ c->pContext = pContext;
+ c->slept = FALSE;
+ c->pWin = pWin;
+
+ (void)DoStartPage(client, c);
+
+ if (client->noClientException != Success)
+ return client->noClientException;
+ else
+ return result;
+}
+
+static int
+ProcXpEndPage(ClientPtr client)
+{
+ REQUEST(xPrintEndPageReq);
+ int result = Success;
+ XpContextPtr pContext;
+ XpPagePtr page;
+ WindowPtr pWin;
+
+ REQUEST_SIZE_MATCH(xPrintEndPageReq);
+
+ if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
+ == (XpContextPtr)NULL)
+ return XpErrorBase+XPBadSequence;
+
+ if(!(pContext->state & PAGE_STARTED))
+ return XpErrorBase+XPBadSequence;
+
+ pWin = (WindowPtr )LookupIDByType(pContext->pageWin, RT_WINDOW);
+
+ /* Call the ddx's EndPage proc. */
+ if(pContext->funcs.EndPage != 0)
+ result = pContext->funcs.EndPage(pContext, pWin);
+ else
+ return BadImplementation;
+
+ if((page = (XpPagePtr)LookupIDByType(pContext->pageWin, RTpage)) !=
+ (XpPagePtr)NULL)
+ page->context = (XpContextPtr)NULL;
+
+ pContext->state &= ~PAGE_STARTED;
+ pContext->pageWin = 0; /* None, NULL??? XXX */
+
+ (void)UnmapWindow(pWin, FALSE);
+
+ SendXpNotify(pContext, XPEndPageNotify, stuff->cancel);
+
+ if (client->noClientException != Success)
+ return client->noClientException;
+ else
+ return result;
+}
+
+/*******************************************************************************
+ *
+ * Document Data Functions: PutDocumentData, GetDocumentData
+ *
+ ******************************************************************************/
+
+static int
+ProcXpPutDocumentData(ClientPtr client)
+{
+ REQUEST(xPrintPutDocumentDataReq);
+ XpContextPtr pContext;
+ DrawablePtr pDraw;
+ int result = Success;
+ unsigned totalSize;
+ char *pData, *pDoc_fmt, *pOptions;
+
+ REQUEST_AT_LEAST_SIZE(xPrintPutDocumentDataReq);
+
+ if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
+ == (XpContextPtr)NULL)
+ return XpErrorBase+XPBadSequence;
+
+ if(!(pContext->state & DOC_RAW_STARTED) &&
+ !(pContext->state & DOC_COOKED_STARTED))
+ return XpErrorBase+XPBadSequence;
+
+ if (stuff->drawable) {
+ if (pContext->state & DOC_RAW_STARTED)
+ return BadDrawable;
+ pDraw = (DrawablePtr)LookupDrawable(stuff->drawable, client);
+ if (!pDraw || pDraw->pScreen->myNum != pContext->screenNum)
+ return BadDrawable;
+ } else {
+ if (pContext->state & DOC_COOKED_STARTED)
+ return BadDrawable;
+ pDraw = NULL;
+ }
+
+ pData = (char *)(&stuff[1]);
+
+ totalSize = (stuff->len_data + 3) >> 2;
+ pDoc_fmt = pData + (totalSize << 2);
+
+ totalSize += (stuff->len_fmt + 3) >> 2;
+ pOptions = pData + (totalSize << 2);
+
+ totalSize += (stuff->len_options + 3) >> 2;
+ if((totalSize + (sz_xPrintPutDocumentDataReq >> 2)) != client->req_len)
+ return BadLength;
+
+ if(pContext->funcs.PutDocumentData != 0)
+ {
+ result = (*pContext->funcs.PutDocumentData)(pContext, pDraw,
+ pData, stuff->len_data,
+ pDoc_fmt, stuff->len_fmt,
+ pOptions, stuff->len_options,
+ client);
+ }
+ else
+ return BadImplementation;
+
+ if (client->noClientException != Success)
+ return client->noClientException;
+ else
+ return result;
+}
+
+static int
+ProcXpGetDocumentData(ClientPtr client)
+{
+ REQUEST(xPrintGetDocumentDataReq);
+ xPrintGetDocumentDataReply rep;
+ XpContextPtr pContext;
+ int result = Success;
+
+ REQUEST_SIZE_MATCH(xPrintGetDocumentDataReq);
+
+ if((pContext = (XpContextPtr)SecurityLookupIDByType(client,
+ stuff->printContext,
+ RTcontext,
+ SecurityWriteAccess))
+ == (XpContextPtr)NULL)
+ {
+ client->errorValue = stuff->printContext;
+ return XpErrorBase+XPBadContext;
+ }
+
+ if(pContext->funcs.GetDocumentData == 0)
+ return BadImplementation;
+
+ if(!(pContext->state & JOB_GET_DATA) ||
+ pContext->state & GET_DOC_DATA_STARTED)
+ return XpErrorBase+XPBadSequence;
+
+ if(stuff->maxBufferSize <= 0)
+ {
+ client->errorValue = stuff->maxBufferSize;
+ return BadValue; /* gotta have a positive buffer size */
+ }
+
+ result = (*pContext->funcs.GetDocumentData)(pContext, client,
+ stuff->maxBufferSize);
+ if(result != Success)
+ {
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.dataLen = 0;
+ rep.statusCode = 1;
+ rep.finishedFlag = TRUE;
+ if (client->swapped) {
+ int n;
+ long l;
+
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.statusCode, l); /* XXX Why are these longs??? */
+ swapl(&rep.finishedFlag, l); /* XXX Why are these longs??? */
+ }
+ (void)WriteToClient(client,sz_xPrintGetDocumentDataReply,(char *)&rep);
+ }
+ else
+ pContext->state |= GET_DOC_DATA_STARTED;
+
+ if(pContext->clientSlept != (ClientPtr)NULL)
+ {
+ ClientSignal(pContext->clientSlept);
+ ClientWakeup(pContext->clientSlept);
+ pContext->clientSlept = (ClientPtr)NULL;
+ }
+
+ return result;
+}
+
+/*******************************************************************************
+ *
+ * Attribute requests: GetAttributes, SetAttributes, GetOneAttribute
+ *
+ ******************************************************************************/
+
+static int
+ProcXpGetAttributes(ClientPtr client)
+{
+ REQUEST(xPrintGetAttributesReq);
+ XpContextPtr pContext;
+ char *attrs;
+ xPrintGetAttributesReply *pRep;
+ int totalSize, n;
+ unsigned long l;
+
+ REQUEST_SIZE_MATCH(xPrintGetAttributesReq);
+
+ if(stuff->type < XPJobAttr || stuff->type > XPServerAttr)
+ {
+ client->errorValue = stuff->type;
+ return BadValue;
+ }
+
+ if(stuff->type != XPServerAttr)
+ {
+ if((pContext = (XpContextPtr)SecurityLookupIDByType(
+ client,
+ stuff->printContext,
+ RTcontext,
+ SecurityReadAccess))
+ == (XpContextPtr)NULL)
+ {
+ client->errorValue = stuff->printContext;
+ return XpErrorBase+XPBadContext;
+ }
+
+ if(pContext->funcs.GetAttributes == 0)
+ return BadImplementation;
+ if((attrs = (*pContext->funcs.GetAttributes)(pContext, stuff->type)) ==
+ (char *)NULL)
+ return BadAlloc;
+ }
+ else
+ {
+ if((attrs = XpGetAttributes((XpContextPtr)NULL, XPServerAttr)) ==
+ (char *)NULL)
+ return BadAlloc;
+ }
+
+ totalSize = sz_xPrintGetAttributesReply + QUADPAD(strlen(attrs));
+ if((pRep = (xPrintGetAttributesReply *)malloc(totalSize)) ==
+ (xPrintGetAttributesReply *)NULL)
+ return BadAlloc;
+
+ pRep->type = X_Reply;
+ pRep->length = (totalSize - sz_xPrintGetAttributesReply) >> 2;
+ pRep->sequenceNumber = client->sequence;
+ pRep->stringLen = strlen(attrs);
+
+ if (client->swapped) {
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, l);
+ swapl(&pRep->stringLen, l);
+ }
+
+ strncpy((char*)(pRep + 1), attrs, strlen(attrs));
+ xfree(attrs);
+
+ WriteToClient(client, totalSize, (char *)pRep);
+
+ xfree(pRep);
+
+ return client->noClientException;
+}
+
+static int
+ProcXpSetAttributes(ClientPtr client)
+{
+ REQUEST(xPrintSetAttributesReq);
+ int result = Success;
+ XpContextPtr pContext;
+ char *attr;
+
+ REQUEST_AT_LEAST_SIZE(xPrintSetAttributesReq);
+
+ if(stuff->type < XPJobAttr || stuff->type > XPServerAttr)
+ {
+ client->errorValue = stuff->type;
+ return BadValue;
+ }
+
+ /*
+ * Disallow changing of read-only attribute pools
+ */
+ if(stuff->type == XPPrinterAttr || stuff->type == XPServerAttr)
+ return BadMatch;
+
+ if((pContext = (XpContextPtr)SecurityLookupIDByType(
+ client,
+ stuff->printContext,
+ RTcontext,
+ SecurityWriteAccess))
+ == (XpContextPtr)NULL)
+ {
+ client->errorValue = stuff->printContext;
+ return XpErrorBase+XPBadContext;
+ }
+
+ if(pContext->funcs.SetAttributes == 0)
+ return BadImplementation;
+
+ /*
+ * Check for attributes being set after their relevant phase
+ * has already begun (e.g. Job attributes set after StartJob).
+ */
+ if((pContext->state & JOB_STARTED) && stuff->type == XPJobAttr)
+ return XpErrorBase+XPBadSequence;
+ if(((pContext->state & DOC_RAW_STARTED) ||
+ (pContext->state & DOC_COOKED_STARTED)) && stuff->type == XPDocAttr)
+ return XpErrorBase+XPBadSequence;
+ if((pContext->state & PAGE_STARTED) && stuff->type == XPPageAttr)
+ return XpErrorBase+XPBadSequence;
+
+ if((attr = (char *)malloc(stuff->stringLen + 1)) == (char *)NULL)
+ return BadAlloc;
+
+ strncpy(attr, (char *)(stuff + 1), stuff->stringLen);
+ attr[stuff->stringLen] = (char)'\0';
+
+ if(stuff->rule == XPAttrReplace)
+ (*pContext->funcs.SetAttributes)(pContext, stuff->type, attr);
+ else if(stuff->rule == XPAttrMerge)
+ (*pContext->funcs.AugmentAttributes)(pContext, stuff->type, attr);
+ else
+ {
+ client->errorValue = stuff->rule;
+ result = BadValue;
+ }
+
+ xfree(attr);
+
+ SendAttributeNotify(pContext, stuff->type);
+
+ return result;
+}
+
+static int
+ProcXpGetOneAttribute(ClientPtr client)
+{
+ REQUEST(xPrintGetOneAttributeReq);
+ XpContextPtr pContext;
+ char *value, *attrName;
+ xPrintGetOneAttributeReply *pRep;
+ int totalSize;
+ int n;
+ unsigned long l;
+
+ REQUEST_AT_LEAST_SIZE(xPrintGetOneAttributeReq);
+
+ totalSize = ((sz_xPrintGetOneAttributeReq) >> 2) +
+ ((stuff->nameLen + 3) >> 2);
+ if(totalSize != client->req_len)
+ return BadLength;
+
+ if(stuff->type < XPJobAttr || stuff->type > XPServerAttr)
+ {
+ client->errorValue = stuff->type;
+ return BadValue;
+ }
+
+ if((attrName = (char *)malloc(stuff->nameLen + 1)) == (char *)NULL)
+ return BadAlloc;
+ strncpy(attrName, (char *)(stuff+1), stuff->nameLen);
+ attrName[stuff->nameLen] = (char)'\0';
+
+ if(stuff->type != XPServerAttr)
+ {
+ if((pContext = (XpContextPtr)SecurityLookupIDByType(
+ client,
+ stuff->printContext,
+ RTcontext,
+ SecurityReadAccess))
+ == (XpContextPtr)NULL)
+ {
+ client->errorValue = stuff->printContext;
+ return XpErrorBase+XPBadContext;
+ }
+
+ if(pContext->funcs.GetOneAttribute == 0)
+ return BadImplementation;
+ if((value = (*pContext->funcs.GetOneAttribute)(pContext, stuff->type,
+ attrName)) == (char *)NULL)
+ return BadAlloc;
+ }
+ else
+ {
+ if((value = XpGetOneAttribute((XpContextPtr)NULL, XPServerAttr,
+ attrName)) == (char *)NULL)
+ return BadAlloc;
+ }
+
+ free(attrName);
+
+ totalSize = sz_xPrintGetOneAttributeReply + QUADPAD(strlen(value));
+ if((pRep = (xPrintGetOneAttributeReply *)malloc(totalSize)) ==
+ (xPrintGetOneAttributeReply *)NULL)
+ return BadAlloc;
+
+ pRep->type = X_Reply;
+ pRep->length = (totalSize - sz_xPrintGetOneAttributeReply) >> 2;
+ pRep->sequenceNumber = client->sequence;
+ pRep->valueLen = strlen(value);
+
+ if (client->swapped) {
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, l);
+ swapl(&pRep->valueLen, l);
+ }
+
+ strncpy((char*)(pRep + 1), value, strlen(value));
+
+ WriteToClient(client, totalSize, (char *)pRep);
+
+ xfree(pRep);
+
+ return client->noClientException;
+}
+
+/*******************************************************************************
+ *
+ * Print Event requests: SelectInput InputSelected, SendXpNotify
+ *
+ ******************************************************************************/
+
+
+static int
+ProcXpSelectInput(ClientPtr client)
+{
+ REQUEST(xPrintSelectInputReq);
+ int result = Success;
+ XpContextPtr pContext;
+ XpClientPtr pPrintClient;
+
+ REQUEST_SIZE_MATCH(xPrintSelectInputReq);
+
+ /*
+ * Check to see that the supplied XID is really a valid print context
+ * in this server.
+ */
+ if((pContext=(XpContextPtr)SecurityLookupIDByType(client,
+ stuff->printContext,
+ RTcontext,
+ SecurityWriteAccess))
+ == (XpContextPtr)NULL)
+ {
+ client->errorValue = stuff->printContext;
+ return XpErrorBase+XPBadContext;
+ }
+
+ if(stuff->eventMask & ~allEvents)
+ {
+ client->errorValue = stuff->eventMask;
+ return BadValue; /* bogus event mask bits */
+ }
+
+ if((pPrintClient = AcquireClient(pContext, client)) == (XpClientPtr)NULL)
+ return BadAlloc;
+
+ pPrintClient->eventMask = stuff->eventMask;
+
+ return result;
+}
+
+static int
+ProcXpInputSelected(ClientPtr client)
+{
+ REQUEST(xPrintInputSelectedReq);
+ xPrintInputSelectedReply rep;
+ register int n;
+ long l;
+ XpClientPtr pXpClient;
+ XpContextPtr pContext;
+
+ REQUEST_SIZE_MATCH(xPrintInputSelectedReq);
+
+ if((pContext=(XpContextPtr)SecurityLookupIDByType(client,
+ stuff->printContext,
+ RTcontext,
+ SecurityReadAccess))
+ == (XpContextPtr)NULL)
+ {
+ client->errorValue = stuff->printContext;
+ return XpErrorBase+XPBadContext;
+ }
+
+ pXpClient = FindClient(pContext, client);
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.eventMask = (pXpClient != (XpClientPtr)NULL)? pXpClient->eventMask : 0;
+ rep.allEventsMask = GetAllEventMasks(pContext);
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, l);
+ swapl(&rep.eventMask, l);
+ swapl(&rep.allEventsMask, l);
+ }
+
+ WriteToClient(client, sz_xPrintInputSelectedReply, (char *)&rep);
+ return client->noClientException;
+}
+
+static void
+SendAttributeNotify(XpContextPtr pContext, int which)
+{
+ XpClientPtr pXpClient;
+ xPrintAttributeEvent ae;
+ ClientPtr client;
+
+ pXpClient = pContext->clientHead;
+ if(pXpClient == (XpClientPtr)NULL)
+ return; /* Nobody's interested in the events (or this context). */
+
+ for (pXpClient = pContext->clientHead;
+ pXpClient != (XpClientPtr)NULL;
+ pXpClient = pXpClient->pNext)
+ {
+ client = pXpClient->client;
+ if (client == serverClient || client->clientGone ||
+ !(pXpClient->eventMask & XPAttributeMask))
+ continue;
+ ae.type = XPAttributeNotify + XpEventBase;
+ ae.detail = which;
+ ae.printContext = pContext->contextID;
+ ae.sequenceNumber = client->sequence;
+ WriteEventsToClient (client, 1, (xEvent *) &ae);
+ }
+}
+
+static void
+SendXpNotify(XpContextPtr pContext, int which, int val)
+{
+ XpClientPtr pXpClient;
+ xPrintPrintEvent pe;
+ ClientPtr client;
+
+ pXpClient = pContext->clientHead;
+ if(pXpClient == (XpClientPtr)NULL)
+ return; /* Nobody's interested in the events (or this context). */
+
+ for (pXpClient = pContext->clientHead;
+ pXpClient != (XpClientPtr)NULL;
+ pXpClient = pXpClient->pNext)
+ {
+ client = pXpClient->client;
+ if (client == serverClient || client->clientGone ||
+ !(pXpClient->eventMask & XPPrintMask))
+ continue;
+ pe.type = XPPrintNotify + XpEventBase;
+ pe.detail = which;
+ pe.printContext = pContext->contextID;
+ pe.cancel = (Bool)val;
+ pe.sequenceNumber = client->sequence;
+ WriteEventsToClient (client, 1, (xEvent *) &pe);
+ }
+}
+
+static CARD32
+GetAllEventMasks(XpContextPtr pContext)
+{
+ XpClientPtr pPrintClient;
+ CARD32 totalMask = (CARD32)0;
+
+ for (pPrintClient = pContext->clientHead;
+ pPrintClient != (XpClientPtr)NULL;
+ pPrintClient = pPrintClient->pNext)
+ {
+ totalMask |= pPrintClient->eventMask;
+ }
+ return totalMask;
+}
+
+/*
+ * XpContextOfClient - returns the XpContextPtr to the context
+ * associated with the specified client, or NULL if the client
+ * does not currently have a context set.
+ */
+XpContextPtr
+XpContextOfClient(ClientPtr client)
+{
+ return (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr;
+}
+
+
+/*******************************************************************************
+ *
+ * Swap-request functions
+ *
+ ******************************************************************************/
+
+static int
+SProcXpCreateContext(ClientPtr client)
+{
+ int i;
+ long n;
+
+ REQUEST(xPrintCreateContextReq);
+
+ swaps(&stuff->length, i);
+ swapl(&stuff->contextID, n);
+ swapl(&stuff->printerNameLen, n);
+ swapl(&stuff->localeLen, n);
+ return ProcXpCreateContext(client);
+}
+
+static int
+SProcXpGetPrinterList(ClientPtr client)
+{
+ int i;
+ long n;
+
+ REQUEST(xPrintGetPrinterListReq);
+
+ swaps(&stuff->length, i);
+ swapl(&stuff->printerNameLen, n);
+ swapl(&stuff->localeLen, n);
+ return ProcXpGetPrinterList(client);
+}
+
+static int
+SProcXpRehashPrinterList(ClientPtr client)
+{
+ int i;
+
+ REQUEST(xPrintRehashPrinterListReq);
+ swaps(&stuff->length, i);
+ return ProcXpRehashPrinterList(client);
+}
+
+static int
+SProcXpSetContext(ClientPtr client)
+{
+ int i;
+
+ REQUEST(xPrintSetContextReq);
+ swaps(&stuff->length, i);
+ swapl(&stuff->printContext, i);
+ return ProcXpSetContext(client);
+}
+
+static int
+SProcXpGetContext(ClientPtr client)
+{
+ int i;
+
+ REQUEST(xPrintGetContextReq);
+ swaps(&stuff->length, i);
+ return ProcXpGetContext(client);
+}
+
+static int
+SProcXpDestroyContext(ClientPtr client)
+{
+ int i;
+ long n;
+
+ REQUEST(xPrintDestroyContextReq);
+ swaps(&stuff->length, i);
+ swapl(&stuff->printContext, n);
+ return ProcXpDestroyContext(client);
+}
+
+static int
+SProcXpGetContextScreen(ClientPtr client)
+{
+ int i;
+ long n;
+
+ REQUEST(xPrintGetContextScreenReq);
+ swaps(&stuff->length, i);
+ swapl(&stuff->printContext, n);
+ return ProcXpGetContextScreen(client);
+}
+
+static int
+SProcXpInputSelected(ClientPtr client)
+{
+ int i;
+ long n;
+
+ REQUEST(xPrintInputSelectedReq);
+ swaps(&stuff->length, i);
+ swapl(&stuff->printContext, n);
+ return ProcXpInputSelected(client);
+}
+
+static int
+SProcXpStartJob(ClientPtr client)
+{
+ int i;
+
+ REQUEST(xPrintStartJobReq);
+ swaps(&stuff->length, i);
+ return ProcXpStartJob(client);
+}
+
+static int
+SProcXpEndJob(ClientPtr client)
+{
+ int i;
+
+ REQUEST(xPrintEndJobReq);
+ swaps(&stuff->length, i);
+ return ProcXpEndJob(client);
+}
+
+static int
+SProcXpStartDoc(ClientPtr client)
+{
+ int i;
+
+ REQUEST(xPrintStartDocReq);
+ swaps(&stuff->length, i);
+ return ProcXpStartDoc(client);
+}
+
+static int
+SProcXpEndDoc(ClientPtr client)
+{
+ int i;
+
+ REQUEST(xPrintEndDocReq);
+ swaps(&stuff->length, i);
+ return ProcXpEndDoc(client);
+}
+
+static int
+SProcXpStartPage(ClientPtr client)
+{
+ int i;
+ long n;
+
+ REQUEST(xPrintStartPageReq);
+ swaps(&stuff->length, i);
+ swapl(&stuff->window, n);
+ return ProcXpStartPage(client);
+}
+
+static int
+SProcXpEndPage(ClientPtr client)
+{
+ int i;
+
+ REQUEST(xPrintEndPageReq);
+ swaps(&stuff->length, i);
+ return ProcXpEndPage(client);
+}
+
+static int
+SProcXpPutDocumentData(ClientPtr client)
+{
+ long n;
+ int i;
+
+ REQUEST(xPrintPutDocumentDataReq);
+ swaps(&stuff->length, i);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->len_data, n);
+ swaps(&stuff->len_fmt, i);
+ swaps(&stuff->len_options, i);
+ return ProcXpPutDocumentData(client);
+}
+
+static int
+SProcXpGetDocumentData(ClientPtr client)
+{
+ long n;
+ int i;
+
+ REQUEST(xPrintGetDocumentDataReq);
+ swaps(&stuff->length, i);
+ swapl(&stuff->printContext, n);
+ swapl(&stuff->maxBufferSize, n);
+ return ProcXpGetDocumentData(client);
+}
+
+static int
+SProcXpGetAttributes(ClientPtr client)
+{
+ long n;
+ int i;
+
+ REQUEST(xPrintGetAttributesReq);
+ swaps(&stuff->length, i);
+ swapl(&stuff->printContext, n);
+ return ProcXpGetAttributes(client);
+}
+
+static int
+SProcXpSetAttributes(ClientPtr client)
+{
+ long n;
+ int i;
+
+ REQUEST(xPrintSetAttributesReq);
+ swaps(&stuff->length, i);
+ swapl(&stuff->printContext, n);
+ swapl(&stuff->stringLen, n);
+ return ProcXpSetAttributes(client);
+}
+
+static int
+SProcXpGetOneAttribute(ClientPtr client)
+{
+ long n;
+ int i;
+
+ REQUEST(xPrintGetOneAttributeReq);
+ swaps(&stuff->length, i);
+ swapl(&stuff->printContext, n);
+ swapl(&stuff->nameLen, n);
+ return ProcXpGetOneAttribute(client);
+}
+
+static int
+SProcXpSelectInput(ClientPtr client)
+{
+ long n;
+ int i;
+
+ REQUEST(xPrintSelectInputReq);
+ swaps(&stuff->length, i);
+ swapl(&stuff->eventMask, n);
+ swapl(&stuff->printContext, n);
+ return ProcXpSelectInput(client);
+}
+
+static int
+SProcXpGetPageDimensions(ClientPtr client)
+{
+ long n;
+ int i;
+
+ REQUEST(xPrintGetPageDimensionsReq);
+ swaps(&stuff->length, i);
+ swapl(&stuff->printContext, n);
+ return ProcXpGetPageDimensions(client);
+}
+
+static int
+SProcXpSetImageResolution(ClientPtr client)
+{
+ long n;
+ int i;
+
+ REQUEST(xPrintSetImageResolutionReq);
+ swaps(&stuff->length, i);
+ swapl(&stuff->printContext, n);
+ swaps(&stuff->imageRes, i);
+ return ProcXpSetImageResolution(client);
+}
+
+static int
+SProcXpGetImageResolution(ClientPtr client)
+{
+ long n;
+ int i;
+
+ REQUEST(xPrintGetImageResolutionReq);
+ swaps(&stuff->length, i);
+ swapl(&stuff->printContext, n);
+ return ProcXpGetImageResolution(client);
+}
+
+static void
+SwapXpNotifyEvent(xPrintPrintEvent *src, xPrintPrintEvent *dst)
+{
+ /*
+ * Swap the sequence number and context fields.
+ */
+ cpswaps(src->sequenceNumber, dst->sequenceNumber);
+ cpswapl(src->printContext, dst->printContext);
+
+ /*
+ * Copy the byte-long fields.
+ */
+ dst->type = src->type;
+ dst->detail = src->detail;
+ dst->cancel = src->cancel;
+}
+
+static void
+SwapXpAttributeEvent(xPrintAttributeEvent *src, xPrintAttributeEvent *dst)
+{
+ /*
+ * Swap the sequence number and context fields.
+ */
+ cpswaps(src->sequenceNumber, dst->sequenceNumber);
+ cpswapl(src->printContext, dst->printContext);
+
+ /*
+ * Copy the byte-long fields.
+ */
+ dst->type = src->type;
+ dst->detail = src->detail;
+}
diff --git a/nx-X11/programs/Xserver/Xext/xres.c b/nx-X11/programs/Xserver/Xext/xres.c
new file mode 100644
index 000000000..d13d3368b
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xres.c
@@ -0,0 +1,339 @@
+/*
+ Copyright (c) 2002 XFree86 Inc
+*/
+/* $XFree86: xc/programs/Xserver/Xext/xres.c,v 1.7tsi Exp $ */
+/* $XdotOrg: xc/programs/Xserver/Xext/xres.c,v 1.7 2005/07/03 08:53:36 daniels Exp $ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "swaprep.h"
+#include <X11/extensions/XResproto.h>
+#include "pixmapstr.h"
+#include "modinit.h"
+
+static int
+ProcXResQueryVersion (ClientPtr client)
+{
+ REQUEST(xXResQueryVersionReq);
+ xXResQueryVersionReply rep;
+ CARD16 client_major, client_minor; /* not used */
+
+ REQUEST_SIZE_MATCH (xXResQueryVersionReq);
+
+ client_major = stuff->client_major;
+ client_minor = stuff->client_minor;
+ (void) client_major;
+ (void) client_minor;
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.server_major = XRES_MAJOR_VERSION;
+ rep.server_minor = XRES_MINOR_VERSION;
+ if (client->swapped) {
+ int n;
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.server_major, n);
+ swaps(&rep.server_minor, n);
+ }
+ WriteToClient(client, sizeof (xXResQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcXResQueryClients (ClientPtr client)
+{
+ /* REQUEST(xXResQueryClientsReq); */
+ xXResQueryClientsReply rep;
+ int *current_clients;
+ int i, num_clients;
+
+ REQUEST_SIZE_MATCH(xXResQueryClientsReq);
+
+ current_clients = ALLOCATE_LOCAL((currentMaxClients - 1) * sizeof(int));
+
+ num_clients = 0;
+ for(i = 1; i < currentMaxClients; i++) {
+ if(clients[i]) {
+ current_clients[num_clients] = i;
+ num_clients++;
+ }
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.num_clients = num_clients;
+ rep.length = rep.num_clients * sz_xXResClient >> 2;
+ if (client->swapped) {
+ int n;
+ swaps (&rep.sequenceNumber, n);
+ swapl (&rep.length, n);
+ swapl (&rep.num_clients, n);
+ }
+ WriteToClient (client, sizeof (xXResQueryClientsReply), (char *) &rep);
+
+ if(num_clients) {
+ xXResClient scratch;
+
+ for(i = 0; i < num_clients; i++) {
+ scratch.resource_base = clients[current_clients[i]]->clientAsMask;
+ scratch.resource_mask = RESOURCE_ID_MASK;
+
+ if(client->swapped) {
+ register int n;
+ swapl (&scratch.resource_base, n);
+ swapl (&scratch.resource_mask, n);
+ }
+ WriteToClient (client, sz_xXResClient, (char *) &scratch);
+ }
+ }
+
+ DEALLOCATE_LOCAL(current_clients);
+
+ return (client->noClientException);
+}
+
+
+static void
+ResFindAllRes (pointer value, XID id, RESTYPE type, pointer cdata)
+{
+ int *counts = (int *)cdata;
+
+ counts[(type & TypeMask) - 1]++;
+}
+
+static int
+ProcXResQueryClientResources (ClientPtr client)
+{
+ REQUEST(xXResQueryClientResourcesReq);
+ xXResQueryClientResourcesReply rep;
+ int i, clientID, num_types;
+ int *counts;
+
+ REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq);
+
+ clientID = CLIENT_ID(stuff->xid);
+
+ /* we could remove the (clientID == 0) check if we wanted to allow
+ probing the X-server's resource usage */
+ if(!clientID || (clientID >= currentMaxClients) || !clients[clientID]) {
+ client->errorValue = stuff->xid;
+ return BadValue;
+ }
+
+ counts = ALLOCATE_LOCAL((lastResourceType + 1) * sizeof(int));
+
+ memset(counts, 0, (lastResourceType + 1) * sizeof(int));
+
+ FindAllClientResources(clients[clientID], ResFindAllRes, counts);
+
+ num_types = 0;
+
+ for(i = 0; i <= lastResourceType; i++) {
+ if(counts[i]) num_types++;
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.num_types = num_types;
+ rep.length = rep.num_types * sz_xXResType >> 2;
+ if (client->swapped) {
+ int n;
+ swaps (&rep.sequenceNumber, n);
+ swapl (&rep.length, n);
+ swapl (&rep.num_types, n);
+ }
+ WriteToClient (client,sizeof(xXResQueryClientResourcesReply),(char*)&rep);
+
+ if(num_types) {
+ xXResType scratch;
+
+ for(i = 0; i < lastResourceType; i++) {
+ if(!counts[i]) continue;
+
+ if(!ResourceNames[i + 1]) {
+ char buf[40];
+ snprintf(buf, sizeof(buf), "Unregistered resource %i", i + 1);
+ RegisterResourceName(i + 1, buf);
+ }
+
+ scratch.resource_type = ResourceNames[i + 1];
+ scratch.count = counts[i];
+
+ if(client->swapped) {
+ register int n;
+ swapl (&scratch.resource_type, n);
+ swapl (&scratch.count, n);
+ }
+ WriteToClient (client, sz_xXResType, (char *) &scratch);
+ }
+ }
+
+ DEALLOCATE_LOCAL(counts);
+
+ return (client->noClientException);
+}
+
+static void
+ResFindPixmaps (pointer value, XID id, pointer cdata)
+{
+ unsigned long *bytes = (unsigned long *)cdata;
+ PixmapPtr pix = (PixmapPtr)value;
+
+ *bytes += (pix->devKind * pix->drawable.height);
+}
+
+static int
+ProcXResQueryClientPixmapBytes (ClientPtr client)
+{
+ REQUEST(xXResQueryClientPixmapBytesReq);
+ xXResQueryClientPixmapBytesReply rep;
+ int clientID;
+ unsigned long bytes;
+
+ REQUEST_SIZE_MATCH(xXResQueryClientPixmapBytesReq);
+
+ clientID = CLIENT_ID(stuff->xid);
+
+ /* we could remove the (clientID == 0) check if we wanted to allow
+ probing the X-server's resource usage */
+ if(!clientID || (clientID >= currentMaxClients) || !clients[clientID]) {
+ client->errorValue = stuff->xid;
+ return BadValue;
+ }
+
+ bytes = 0;
+
+ FindClientResourcesByType(clients[clientID], RT_PIXMAP, ResFindPixmaps,
+ (pointer)(&bytes));
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.bytes = bytes;
+#ifdef XSERVER64
+ rep.bytes_overflow = bytes >> 32;
+#else
+ rep.bytes_overflow = 0;
+#endif
+ if (client->swapped) {
+ int n;
+ swaps (&rep.sequenceNumber, n);
+ swapl (&rep.length, n);
+ swapl (&rep.bytes, n);
+ swapl (&rep.bytes_overflow, n);
+ }
+ WriteToClient (client,sizeof(xXResQueryClientPixmapBytesReply),(char*)&rep);
+
+ return (client->noClientException);
+}
+
+
+static void
+ResResetProc (ExtensionEntry *extEntry) { }
+
+static int
+ProcResDispatch (ClientPtr client)
+{
+ REQUEST(xReq);
+ switch (stuff->data) {
+ case X_XResQueryVersion:
+ return ProcXResQueryVersion(client);
+ case X_XResQueryClients:
+ return ProcXResQueryClients(client);
+ case X_XResQueryClientResources:
+ return ProcXResQueryClientResources(client);
+ case X_XResQueryClientPixmapBytes:
+ return ProcXResQueryClientPixmapBytes(client);
+ default: break;
+ }
+
+ return BadRequest;
+}
+
+static int
+SProcXResQueryVersion (ClientPtr client)
+{
+ REQUEST(xXResQueryVersionReq);
+ int n;
+
+ REQUEST_SIZE_MATCH (xXResQueryVersionReq);
+ swaps(&stuff->client_major,n);
+ swaps(&stuff->client_minor,n);
+ return ProcXResQueryVersion(client);
+}
+
+static int
+SProcXResQueryClientResources (ClientPtr client)
+{
+ REQUEST(xXResQueryClientResourcesReq);
+ int n;
+
+ REQUEST_SIZE_MATCH (xXResQueryClientResourcesReq);
+ swaps(&stuff->xid,n);
+ return ProcXResQueryClientResources(client);
+}
+
+static int
+SProcXResQueryClientPixmapBytes (ClientPtr client)
+{
+ REQUEST(xXResQueryClientPixmapBytesReq);
+ int n;
+
+ REQUEST_SIZE_MATCH (xXResQueryClientPixmapBytesReq);
+ swaps(&stuff->xid,n);
+ return ProcXResQueryClientPixmapBytes(client);
+}
+
+static int
+SProcResDispatch (ClientPtr client)
+{
+ REQUEST(xReq);
+ int n;
+
+ swaps(&stuff->length,n);
+
+ switch (stuff->data) {
+ case X_XResQueryVersion:
+ return SProcXResQueryVersion(client);
+ case X_XResQueryClients: /* nothing to swap */
+ return ProcXResQueryClients(client);
+ case X_XResQueryClientResources:
+ return SProcXResQueryClientResources(client);
+ case X_XResQueryClientPixmapBytes:
+ return SProcXResQueryClientPixmapBytes(client);
+ default: break;
+ }
+
+ return BadRequest;
+}
+
+void
+ResExtensionInit(INITARGS)
+{
+ (void) AddExtension(XRES_NAME, 0, 0,
+ ProcResDispatch, SProcResDispatch,
+ ResResetProc, StandardMinorOpcode);
+
+ RegisterResourceName(RT_NONE, "NONE");
+ RegisterResourceName(RT_WINDOW, "WINDOW");
+ RegisterResourceName(RT_PIXMAP, "PIXMAP");
+ RegisterResourceName(RT_GC, "GC");
+ RegisterResourceName(RT_FONT, "FONT");
+ RegisterResourceName(RT_CURSOR, "CURSOR");
+ RegisterResourceName(RT_COLORMAP, "COLORMAP");
+ RegisterResourceName(RT_CMAPENTRY, "COLORMAP ENTRY");
+ RegisterResourceName(RT_OTHERCLIENT, "OTHER CLIENT");
+ RegisterResourceName(RT_PASSIVEGRAB, "PASSIVE GRAB");
+}
diff --git a/nx-X11/programs/Xserver/Xext/xtest.c b/nx-X11/programs/Xserver/Xext/xtest.c
new file mode 100644
index 000000000..994b0c502
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xtest.c
@@ -0,0 +1,608 @@
+/* $XdotOrg: xc/programs/Xserver/Xext/xtest.c,v 1.6 2005/07/03 08:53:36 daniels Exp $ */
+/* $Xorg: xtest.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
+/*
+
+Copyright 1992, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/Xext/xtest.c,v 3.10 2003/10/28 23:08:44 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "windowstr.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "dixevents.h"
+#include "sleepuntil.h"
+#define _XTEST_SERVER_
+#include <X11/extensions/XTest.h>
+#include <X11/extensions/xteststr.h>
+#ifdef XINPUT
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#define EXTENSION_EVENT_BASE 64
+#include "extinit.h" /* LookupDeviceIntRec */
+#endif /* XINPUT */
+#ifdef EXTMODULE
+#include "xf86_ansic.h"
+#endif
+
+#include "modinit.h"
+
+#if 0
+static unsigned char XTestReqCode;
+#endif
+
+#ifdef XINPUT
+extern int DeviceValuator;
+#endif /* XINPUT */
+
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+
+static void XTestResetProc(
+ ExtensionEntry * /* extEntry */
+);
+static int XTestSwapFakeInput(
+ ClientPtr /* client */,
+ xReq * /* req */
+);
+
+static DISPATCH_PROC(ProcXTestCompareCursor);
+static DISPATCH_PROC(ProcXTestDispatch);
+static DISPATCH_PROC(ProcXTestFakeInput);
+static DISPATCH_PROC(ProcXTestGetVersion);
+static DISPATCH_PROC(ProcXTestGrabControl);
+static DISPATCH_PROC(SProcXTestCompareCursor);
+static DISPATCH_PROC(SProcXTestDispatch);
+static DISPATCH_PROC(SProcXTestFakeInput);
+static DISPATCH_PROC(SProcXTestGetVersion);
+static DISPATCH_PROC(SProcXTestGrabControl);
+
+void
+XTestExtensionInit(INITARGS)
+{
+#if 0
+ ExtensionEntry *extEntry;
+
+ if ((extEntry = AddExtension(XTestExtensionName, 0, 0,
+ ProcXTestDispatch, SProcXTestDispatch,
+ XTestResetProc, StandardMinorOpcode)) != 0)
+ XTestReqCode = (unsigned char)extEntry->base;
+#else
+ (void) AddExtension(XTestExtensionName, 0, 0,
+ ProcXTestDispatch, SProcXTestDispatch,
+ XTestResetProc, StandardMinorOpcode);
+#endif
+}
+
+/*ARGSUSED*/
+static void
+XTestResetProc (extEntry)
+ExtensionEntry *extEntry;
+{
+}
+
+static int
+ProcXTestGetVersion(client)
+ register ClientPtr client;
+{
+ xXTestGetVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xXTestGetVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = XTestMajorVersion;
+ rep.minorVersion = XTestMinorVersion;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swaps(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof(xXTestGetVersionReply), (char *)&rep);
+ return(client->noClientException);
+}
+
+static int
+ProcXTestCompareCursor(client)
+ register ClientPtr client;
+{
+ REQUEST(xXTestCompareCursorReq);
+ xXTestCompareCursorReply rep;
+ WindowPtr pWin;
+ CursorPtr pCursor;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xXTestCompareCursorReq);
+ pWin = (WindowPtr)LookupWindow(stuff->window, client);
+ if (!pWin)
+ return(BadWindow);
+ if (stuff->cursor == None)
+ pCursor = NullCursor;
+ else if (stuff->cursor == XTestCurrentCursor)
+ pCursor = GetSpriteCursor();
+ else {
+ pCursor = (CursorPtr)LookupIDByType(stuff->cursor, RT_CURSOR);
+ if (!pCursor)
+ {
+ client->errorValue = stuff->cursor;
+ return (BadCursor);
+ }
+ }
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.same = (wCursor(pWin) == pCursor);
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ }
+ WriteToClient(client, sizeof(xXTestCompareCursorReply), (char *)&rep);
+ return(client->noClientException);
+}
+
+static int
+ProcXTestFakeInput(client)
+ register ClientPtr client;
+{
+ REQUEST(xXTestFakeInputReq);
+ int nev;
+ int n;
+ xEvent *ev;
+ DeviceIntPtr dev = NULL;
+ WindowPtr root;
+ int type;
+#ifdef XINPUT
+ Bool extension = FALSE;
+ deviceValuator *dv = NULL;
+ int base;
+ int *values;
+#endif /* XINPUT */
+
+ nev = (stuff->length << 2) - sizeof(xReq);
+ if ((nev % sizeof(xEvent)) || !nev)
+ return BadLength;
+ nev /= sizeof(xEvent);
+ UpdateCurrentTime();
+ ev = (xEvent *)&((xReq *)stuff)[1];
+ type = ev->u.u.type & 0177;
+#ifdef XINPUT
+ if (type >= EXTENSION_EVENT_BASE)
+ {
+ type -= DeviceValuator;
+ switch (type) {
+ case XI_DeviceKeyPress:
+ case XI_DeviceKeyRelease:
+ case XI_DeviceButtonPress:
+ case XI_DeviceButtonRelease:
+ case XI_DeviceMotionNotify:
+ case XI_ProximityIn:
+ case XI_ProximityOut:
+ break;
+ default:
+ client->errorValue = ev->u.u.type;
+ return BadValue;
+ }
+ if (nev == 1 && type == XI_DeviceMotionNotify)
+ return BadLength;
+ if (type == XI_DeviceMotionNotify)
+ base = ((deviceValuator *)(ev+1))->first_valuator;
+ else
+ base = 0;
+ for (n = 1; n < nev; n++)
+ {
+ dv = (deviceValuator *)(ev + n);
+ if (dv->type != DeviceValuator)
+ {
+ client->errorValue = dv->type;
+ return BadValue;
+ }
+ if (dv->first_valuator != base)
+ {
+ client->errorValue = dv->first_valuator;
+ return BadValue;
+ }
+ if (!dv->num_valuators || dv->num_valuators > 6)
+ {
+ client->errorValue = dv->num_valuators;
+ return BadValue;
+ }
+ base += dv->num_valuators;
+ }
+ type = type - XI_DeviceKeyPress + KeyPress;
+ extension = TRUE;
+ }
+ else
+#endif /* XINPUT */
+ {
+ if (nev != 1)
+ return BadLength;
+ switch (type)
+ {
+ case KeyPress:
+ case KeyRelease:
+ case MotionNotify:
+ case ButtonPress:
+ case ButtonRelease:
+ break;
+ default:
+ client->errorValue = ev->u.u.type;
+ return BadValue;
+ }
+ }
+ if (ev->u.keyButtonPointer.time)
+ {
+ TimeStamp activateTime;
+ CARD32 ms;
+
+ activateTime = currentTime;
+ ms = activateTime.milliseconds + ev->u.keyButtonPointer.time;
+ if (ms < activateTime.milliseconds)
+ activateTime.months++;
+ activateTime.milliseconds = ms;
+ ev->u.keyButtonPointer.time = 0;
+
+ /* see mbuf.c:QueueDisplayRequest for code similar to this */
+
+ if (!ClientSleepUntil(client, &activateTime, NULL, NULL))
+ {
+ return BadAlloc;
+ }
+ /* swap the request back so we can simply re-execute it */
+ if (client->swapped)
+ {
+ (void) XTestSwapFakeInput(client, (xReq *)stuff);
+ swaps(&stuff->length, n);
+ }
+ ResetCurrentRequest (client);
+ client->sequence--;
+ return Success;
+ }
+#ifdef XINPUT
+ if (extension)
+ {
+ dev = LookupDeviceIntRec(stuff->deviceid & 0177);
+ if (!dev)
+ {
+ client->errorValue = stuff->deviceid & 0177;
+ return BadValue;
+ }
+ if (nev > 1)
+ {
+ dv = (deviceValuator *)(ev + 1);
+ if (!dev->valuator || dv->first_valuator >= dev->valuator->numAxes)
+ {
+ client->errorValue = dv->first_valuator;
+ return BadValue;
+ }
+ if (dv->first_valuator + dv->num_valuators >
+ dev->valuator->numAxes)
+ {
+ client->errorValue = dv->num_valuators;
+ return BadValue;
+ }
+ }
+ }
+#endif /* XINPUT */
+ switch (type)
+ {
+ case KeyPress:
+ case KeyRelease:
+#ifdef XINPUT
+ if (!extension)
+#endif /* XINPUT */
+ dev = (DeviceIntPtr)LookupKeyboardDevice();
+ if (ev->u.u.detail < dev->key->curKeySyms.minKeyCode ||
+ ev->u.u.detail > dev->key->curKeySyms.maxKeyCode)
+ {
+ client->errorValue = ev->u.u.detail;
+ return BadValue;
+ }
+ break;
+ case MotionNotify:
+#ifdef XINPUT
+ if (extension)
+ {
+ if (ev->u.u.detail != xFalse && ev->u.u.detail != xTrue)
+ {
+ client->errorValue = ev->u.u.detail;
+ return BadValue;
+ }
+ if (ev->u.u.detail == xTrue && dev->valuator->mode == Absolute)
+ {
+ values = dev->valuator->axisVal + dv->first_valuator;
+ for (n = 1; n < nev; n++)
+ {
+ dv = (deviceValuator *)(ev + n);
+ switch (dv->num_valuators)
+ {
+ case 6:
+ dv->valuator5 += values[5];
+ case 5:
+ dv->valuator4 += values[4];
+ case 4:
+ dv->valuator3 += values[3];
+ case 3:
+ dv->valuator2 += values[2];
+ case 2:
+ dv->valuator1 += values[1];
+ case 1:
+ dv->valuator0 += values[0];
+ }
+ values += 6;
+ }
+ }
+ break;
+ }
+#endif /* XINPUT */
+ dev = (DeviceIntPtr)LookupPointerDevice();
+ if (ev->u.keyButtonPointer.root == None)
+ root = GetCurrentRootWindow();
+ else
+ {
+ root = LookupWindow(ev->u.keyButtonPointer.root, client);
+ if (!root)
+ return BadWindow;
+ if (root->parent)
+ {
+ client->errorValue = ev->u.keyButtonPointer.root;
+ return BadValue;
+ }
+ }
+ if (ev->u.u.detail == xTrue)
+ {
+ int x, y;
+ GetSpritePosition(&x, &y);
+ ev->u.keyButtonPointer.rootX += x;
+ ev->u.keyButtonPointer.rootY += y;
+ }
+ else if (ev->u.u.detail != xFalse)
+ {
+ client->errorValue = ev->u.u.detail;
+ return BadValue;
+ }
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ ScreenPtr pScreen = root->drawable.pScreen;
+ BoxRec box;
+ int i;
+ int x = ev->u.keyButtonPointer.rootX + panoramiXdataPtr[0].x;
+ int y = ev->u.keyButtonPointer.rootY + panoramiXdataPtr[0].y;
+ if (!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
+ x, y, &box)) {
+ FOR_NSCREENS(i) {
+ if (i == pScreen->myNum) continue;
+ if (POINT_IN_REGION(pScreen,
+ &XineramaScreenRegions[i],
+ x, y, &box)) {
+ root = WindowTable[i];
+ x -= panoramiXdataPtr[i].x;
+ y -= panoramiXdataPtr[i].y;
+ ev->u.keyButtonPointer.rootX = x;
+ ev->u.keyButtonPointer.rootY = y;
+ break;
+ }
+ }
+ }
+ }
+#endif
+
+ if (ev->u.keyButtonPointer.rootX < 0)
+ ev->u.keyButtonPointer.rootX = 0;
+ else if (ev->u.keyButtonPointer.rootX >= root->drawable.width)
+ ev->u.keyButtonPointer.rootX = root->drawable.width - 1;
+ if (ev->u.keyButtonPointer.rootY < 0)
+ ev->u.keyButtonPointer.rootY = 0;
+ else if (ev->u.keyButtonPointer.rootY >= root->drawable.height)
+ ev->u.keyButtonPointer.rootY = root->drawable.height - 1;
+
+#ifdef PANORAMIX
+ if ((!noPanoramiXExtension
+ && root->drawable.pScreen->myNum != XineramaGetCursorScreen())
+ || (noPanoramiXExtension && root != GetCurrentRootWindow()))
+
+#else
+ if (root != GetCurrentRootWindow())
+#endif
+ {
+ NewCurrentScreen(root->drawable.pScreen,
+ ev->u.keyButtonPointer.rootX,
+ ev->u.keyButtonPointer.rootY);
+ return client->noClientException;
+ }
+ (*root->drawable.pScreen->SetCursorPosition)
+ (root->drawable.pScreen,
+ ev->u.keyButtonPointer.rootX,
+ ev->u.keyButtonPointer.rootY, FALSE);
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+#ifdef XINPUT
+ if (!extension)
+#endif /* XINPUT */
+ dev = (DeviceIntPtr)LookupPointerDevice();
+ if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons)
+ {
+ client->errorValue = ev->u.u.detail;
+ return BadValue;
+ }
+ break;
+ }
+ if (screenIsSaved == SCREEN_SAVER_ON)
+ SaveScreens(SCREEN_SAVER_OFF, ScreenSaverReset);
+ ev->u.keyButtonPointer.time = currentTime.milliseconds;
+ (*dev->public.processInputProc)(ev, dev, nev);
+ return client->noClientException;
+}
+
+static int
+ProcXTestGrabControl(client)
+ register ClientPtr client;
+{
+ REQUEST(xXTestGrabControlReq);
+
+ REQUEST_SIZE_MATCH(xXTestGrabControlReq);
+ if ((stuff->impervious != xTrue) && (stuff->impervious != xFalse))
+ {
+ client->errorValue = stuff->impervious;
+ return(BadValue);
+ }
+ if (stuff->impervious)
+ MakeClientGrabImpervious(client);
+ else
+ MakeClientGrabPervious(client);
+ return(client->noClientException);
+}
+
+static int
+ProcXTestDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_XTestGetVersion:
+ return ProcXTestGetVersion(client);
+ case X_XTestCompareCursor:
+ return ProcXTestCompareCursor(client);
+ case X_XTestFakeInput:
+ return ProcXTestFakeInput(client);
+ case X_XTestGrabControl:
+ return ProcXTestGrabControl(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static int
+SProcXTestGetVersion(client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST(xXTestGetVersionReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXTestGetVersionReq);
+ swaps(&stuff->minorVersion, n);
+ return ProcXTestGetVersion(client);
+}
+
+static int
+SProcXTestCompareCursor(client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST(xXTestCompareCursorReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXTestCompareCursorReq);
+ swapl(&stuff->window, n);
+ swapl(&stuff->cursor, n);
+ return ProcXTestCompareCursor(client);
+}
+
+static int
+XTestSwapFakeInput(client, req)
+ register ClientPtr client;
+ xReq *req;
+{
+ register int nev;
+ register xEvent *ev;
+ xEvent sev;
+ EventSwapPtr proc;
+
+ nev = ((req->length << 2) - sizeof(xReq)) / sizeof(xEvent);
+ for (ev = (xEvent *)&req[1]; --nev >= 0; ev++)
+ {
+ /* Swap event */
+ proc = EventSwapVector[ev->u.u.type & 0177];
+ /* no swapping proc; invalid event type? */
+ if (!proc || proc == NotImplemented) {
+ client->errorValue = ev->u.u.type;
+ return BadValue;
+ }
+ (*proc)(ev, &sev);
+ *ev = sev;
+ }
+ return Success;
+}
+
+static int
+SProcXTestFakeInput(client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST(xReq);
+
+ swaps(&stuff->length, n);
+ n = XTestSwapFakeInput(client, stuff);
+ if (n != Success)
+ return n;
+ return ProcXTestFakeInput(client);
+}
+
+static int
+SProcXTestGrabControl(client)
+ register ClientPtr client;
+{
+ register int n;
+ REQUEST(xXTestGrabControlReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXTestGrabControlReq);
+ return ProcXTestGrabControl(client);
+}
+
+static int
+SProcXTestDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_XTestGetVersion:
+ return SProcXTestGetVersion(client);
+ case X_XTestCompareCursor:
+ return SProcXTestCompareCursor(client);
+ case X_XTestFakeInput:
+ return SProcXTestFakeInput(client);
+ case X_XTestGrabControl:
+ return SProcXTestGrabControl(client);
+ default:
+ return BadRequest;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xext/xtest1.frags b/nx-X11/programs/Xserver/Xext/xtest1.frags
new file mode 100644
index 000000000..bdf7943b7
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xtest1.frags
@@ -0,0 +1,90 @@
+There are several code fragments that need to be placed in the device
+dependent part of the server. These are described below. These code
+fragments are device and implementation dependent.
+
+This code fragment should go in your ddx InitInput() routine:
+
+#ifdef XTESTEXT1
+extern KeyCode xtest_command_key;
+#endif
+
+#ifdef XTESTEXT1
+ xtest_command_key = <whatever-is-a-good-keycode-for-your-keyboard>;
+#endif
+
+This code fragment should go at the front of the file that handles
+keyboards:
+
+#ifdef XTESTEXT1
+/*
+ * defined in xtestext1di.c
+ */
+extern int on_steal_input;
+extern Bool XTestStealKeyData();
+#endif XTESTEXT1
+
+This code fragment should go in the function that parses input from the
+keyboard or pointer after you know what input action has occurred, but before
+you have told the server about it. If conditionalizes the actual function
+call to pass the information on:
+
+#ifdef XTESTEXT1
+ if (!on_steal_input ||
+ XTestStealKeyData(code, direction, dev_type, x, y))
+#endif /* XTESTEXT1 */
+ handle_device_event(...);
+
+This code fragment should go in the function that handles mouse motion after
+you have figured out how much the mouse has moved:
+
+#ifdef XTESTEXT1
+ if (on_steal_input)
+ XTestStealMotionData(dx, dy, dev, x, y);
+#endif XTESTEXT1
+
+
+This code fragment should go at the front of the os-specific code where
+you wait (by doing a select on the socket in our implementation) for
+something to happen:
+
+#ifdef XTESTEXT1
+extern int playback_on;
+void XTestComputeWaitTime();
+#endif XTESTEXT1
+
+These code fragments should go in the os-specific code on both sides of
+where you wait (by doing a select on the socket in our implementation)
+for something to happen:
+
+#ifdef XTESTEXT1
+ if (playback_on)
+ XTestComputeWaitTime(wt = &waittime);
+#endif XTESTEXT1
+ ... code to do select ...
+ WakeupHandler(i, LastSelectMask);
+#ifdef XTESTEXT1
+ if (playback_on)
+ i = XTestProcessInputAction(i, &waittime);
+#endif XTESTEXT1
+
+
+You also need to implement the following routines (documentation
+is needed; for now, see server/ddx/hp/hp/x_hil.c):
+
+void
+XTestGenerateEvent(dev_type, keycode, keystate, mousex, mousey)
+ int dev_type;
+ int keycode;
+ int keystate;
+ int mousex;
+ int mousey;
+
+void
+XTestGetPointerPos(fmousex, fmousey)
+ short *fmousex, *fmousey;
+
+void
+XTestJumpPointer(jx, jy, dev_type)
+ int jx;
+ int jy;
+ int dev_type;
diff --git a/nx-X11/programs/Xserver/Xext/xtest1dd.c b/nx-X11/programs/Xserver/Xext/xtest1dd.c
new file mode 100644
index 000000000..81d283c36
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xtest1dd.c
@@ -0,0 +1,1617 @@
+/* $Xorg: xtest1dd.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
+/*
+ * File: xtest1dd.c
+ *
+ * This file contains the device dependent parts of the input
+ * synthesis extension.
+ */
+
+/*
+
+
+Copyright 1986, 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1986, 1987, 1988 by Hewlett-Packard Corporation
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Hewlett-Packard not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+Hewlett-Packard makes no representations about the
+suitability of this software for any purpose. It is provided
+"as is" without express or implied warranty.
+
+This software is not subject to any license of the American
+Telephone and Telegraph Company or of the Regents of the
+University of California.
+
+*/
+/* $XFree86: xc/programs/Xserver/Xext/xtest1dd.c,v 3.6 2003/10/28 23:08:44 tsi Exp $ */
+
+/***************************************************************
+ * include files
+ ***************************************************************/
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <X11/Xos.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#define XTestSERVER_SIDE
+#include <X11/extensions/xtestext1.h>
+
+#include "xtest1dd.h"
+
+/***************************************************************
+ * defines
+ ***************************************************************/
+
+/*
+ * the size of the fake input action array
+ */
+#define ACTION_ARRAY_SIZE 100
+
+/***************************************************************
+ * externals
+ ***************************************************************/
+
+/*
+ * Holds the xTestInputAction event type code.
+ * This is defined in xtestext1di.c.
+ */
+extern int XTestInputActionType;
+/*
+ * Holds the xTestFakeAck event type code.
+ * This is defined in xtestext1di.c.
+ */
+extern int XTestFakeAckType;
+/*
+ * used in the WriteReplyToClient macro
+ */
+extern int exclusive_steal;
+
+/***************************************************************
+ * variables
+ ***************************************************************/
+
+/*
+ * array to hold fake input actions
+ */
+struct {
+ /*
+ * holds the action type, one of: XTestDELAY_ACTION,
+ * XTestKEY_ACTION, XTestMOTION_ACTION, XTestJUMP_ACTION
+ */
+ CARD8 type;
+ /*
+ * holds the device type, in the range 0 to 15
+ */
+ CARD8 device;
+ /*
+ * for XTestKEY_ACTION type, holds the keycode
+ */
+ CARD8 keycode;
+ /*
+ * for XTestKEY_ACTION type, holds the key up/down state
+ */
+ CARD8 keystate;
+ /*
+ * for XTestMOTION_ACTION and XTestJUMP_ACTION types,
+ * holds the x and y coordinates to move the mouse to
+ */
+ int x;
+ int y;
+ /*
+ * holds the time to delay (in milliseconds) before performing
+ * the action
+ */
+ CARD32 delay_time;
+}action_array[ACTION_ARRAY_SIZE];
+
+/*
+ * write index for input action array
+ */
+static int write_index = 0;
+/*
+ * read index for input action array
+ */
+static int read_index = 0;
+/*
+ * this is where the input actions are accumulated until they are sent
+ * to a client (in a wire event)
+ */
+static xTestInputActionEvent input_action_packet;
+/*
+ * holds the index (in bytes) into the input actions buffer in the
+ * current input action event
+ */
+static int packet_index;
+/*
+ * logical x position of the mouse during input action gathering
+ */
+short xtest_mousex;
+/*
+ * logical y position of the mouse during input action gathering
+ */
+short xtest_mousey;
+/*
+ * logical x position of the mouse while we are reading fake input actions
+ * from the client and putting them into the fake input action array
+ */
+static short pmousex;
+/*
+ * logical y position of the mouse while we are reading fake input actions
+ * from the client and putting them into the fake input action array
+ */
+static short pmousey;
+/*
+ * The playback_on flag is set to 1 while there are input actions in the
+ * input action array. It is set to 0 when the server has received all of
+ * the user actions.
+ */
+int playback_on = 0;
+/*
+ * identity of the client using XTestGetInput to get user input actions
+ */
+ClientPtr current_xtest_client;
+/*
+ * if 1 send multiple input actions per XTestInputAction event;
+ * if 0 send one input action per XTestInputAction event
+ */
+static char packed_mode;
+/*
+ * identity of the client using the XTestFakeInput function to send some
+ * fake input actions to the server
+ */
+ClientPtr playback_client = NULL;
+/*
+ * Set to 1 when the XTestFAKE_ACK_REQUEST flag is set in a XTestFakeInput
+ * request. Set back to 0 when all of the input actions have been sent
+ * to the server.
+ */
+static int acknowledge = 0;
+/*
+ * The server's idea of the current time is saved in these variables when
+ * a XTestFakeInput request is received. It is restored when all fake input
+ * actions are sent to the server or when the playback client disconnects.
+ */
+static int saved_sec;
+static int saved_usec;
+/*
+ * Set to 1 when there is a valid time in saved_sec and saved_usec.
+ */
+static int time_saved = 0;
+/*
+ * holds the extension's notion of what the current time is while it is
+ * sending input actions to a client
+ */
+static struct timeval current_time;
+/*
+ * holds the time when the extension should place the next fake input action
+ * into the server's normal events queue
+ */
+static struct timeval play_time;
+/*
+ * set to 1 when play_time is first set, cleared to 0 when the
+ * client using the extension disconnects, or when XTestReset is called
+ */
+static char play_clock = 0;
+/*
+ * holds the amount of time left until the next input action from the
+ * input action array can be sent to the server
+ */
+static struct timeval rtime;
+/*
+ * Set to 1 after the extension is done waiting for the correct time delay
+ * for an input action to be sent to the server. Remains a 1 until the time
+ * delay for the next input action is computed. Then set to 0 if the
+ * extension has to wait for the correct time delay.
+ */
+static int go_for_next = 1;
+/*
+ * needed to restore waitime if playback is to be aborted
+ */
+static struct timeval *restorewait;
+/*
+ * tmon special command key
+ *
+ * To use the test monitor program (called tmon) efficiently, it is
+ * desirable to have the extension be able to recognize a special "trigger"
+ * key. If the extension did not do this, tmon would have to have the
+ * extension send all keyboard user input actions exclusively to tmon,
+ * only to have tmon send them right back if they were not the command key.
+ *
+ * If the extension can recognize the command key, then tmon can let the
+ * extension handle keyboard user input actions normally until the command
+ * key is pressed (and released), and only then have the extension start
+ * sending keyboard user input actions exclusively to tmon.
+ *
+ * Any key on the keyboard can be used for this command key. It is most
+ * convenient if it is a low-frequency key. If you want to generate a
+ * normal occurrance of this key to a client, just hit it twice. Tmon
+ * will recognize the first occurrance of the key, take control of the input
+ * actions, and wait for certain keys. If it sees another occurrance of the
+ * command key, it will send one occurrance of the command key to the
+ * extension, and go back to waiting.
+ *
+ * set and also referenced in device layer
+ * XXX there should be a way to set this through the protocol
+ */
+KeyCode xtest_command_key = 0;
+
+/***************************************************************
+ * function declarations
+ ***************************************************************/
+
+static void parse_key_fake(
+ XTestKeyInfo * /* fkey */
+ );
+static void parse_motion_fake(
+ XTestMotionInfo * /* fmotion */
+ );
+static void parse_jump_fake(
+ XTestJumpInfo * /* fjump */
+ );
+static void parse_delay_fake(
+ XTestDelayInfo * /* tevent */
+ );
+static void send_ack(
+ ClientPtr /* client */
+ );
+static void start_play_clock(
+ void
+ );
+static void compute_action_time(
+ struct timeval * /* rtime */
+ );
+static int find_residual_time(
+ struct timeval * /* rtime */
+ );
+
+static CARD16 check_time_event(
+ void
+ );
+static CARD32 current_ms(
+ struct timeval * /* otime */
+ );
+static int there_is_room(
+ int /* actsize */
+ );
+
+/******************************************************************************
+ *
+ * stop_stealing_input
+ *
+ * Stop stealing input actions.
+ */
+void
+stop_stealing_input()
+{
+/*
+ * put any code that you might need to stop stealing input actions here
+ */
+ if (packet_index != 0)
+ {
+ /*
+ * if there is a partially full input action event waiting
+ * when this function is called, send it to the client
+ */
+ flush_input_actions();
+ }
+}
+
+/******************************************************************************
+ *
+ * steal_input
+ *
+ * Start stealing input actions and sending them to the passed-in client.
+ */
+void
+steal_input(client, mode)
+/*
+ * which client is to receive the input action events
+ */
+ClientPtr client;
+/*
+ * what input action packing mode to use. one of 0, XTestPACKED_MOTION,
+ * or XTestPACKED_ACTIONS; optionally 'or'ed with XTestEXCLUSIVE,
+ */
+CARD32 mode;
+{
+ if (packet_index != 0)
+ {
+ /*
+ * if there is a partially full input action event waiting
+ * when this function is called, send it to the client
+ */
+ flush_input_actions();
+ }
+ else
+ {
+ /*
+ * otherwise, set up a new input action event
+ */
+ input_action_packet.type = XTestInputActionType;
+ packet_index = 0;
+ }
+ /*
+ * set up the new input action packing mode
+ */
+ packed_mode = mode & ~(XTestEXCLUSIVE);
+ /*
+ * keep track of where the mouse is
+ */
+ XTestGetPointerPos(&xtest_mousex, &xtest_mousey);
+ /*
+ * keep track of which client is getting input actions
+ */
+ current_xtest_client = client;
+ /*
+ * find out what time it is
+ */
+ X_GETTIMEOFDAY(&current_time);
+ /*
+ * jump to the initial position of the mouse, using a device type of 0.
+ */
+ XTestStealJumpData(xtest_mousex, xtest_mousey, 0);
+}
+
+/******************************************************************************
+ *
+ * flush_input_actions
+ *
+ * Write the input actions event to the current requesting client
+ * and re-initialize the input action event.
+ */
+void
+flush_input_actions()
+{
+ /*
+ * pointer to the input action event
+ */
+ char *rep;
+ /*
+ * loop index
+ */
+ int i;
+
+ if (packet_index == 0)
+ {
+ /*
+ * empty input actions event
+ */
+ return;
+ }
+ else if (packet_index < XTestACTIONS_SIZE)
+ {
+ /*
+ * fill to the end of the input actions event with 0's
+ */
+ for (i = packet_index; i <XTestACTIONS_SIZE; i++)
+ {
+ input_action_packet.actions[i] = 0;
+ }
+ }
+ rep = (char *) (&input_action_packet);
+
+ /*
+ * set the serial number of the input action event
+ */
+ input_action_packet.sequenceNumber = current_xtest_client->sequence;
+ /*
+ * send the input action event to the client
+ */
+ WriteEventsToClient(current_xtest_client, 1, (xEvent *) rep);
+ /*
+ * re-initialize the input action event
+ */
+ input_action_packet.type = XTestInputActionType;
+ packet_index = 0;
+}
+
+/******************************************************************************
+ *
+ * XTestStealJumpData
+ *
+ * Create one or more input actions and put them in the input action
+ * event. The input actions will be an (maybe) XTestDELAY_ACTION
+ * and an XTestJUMP_ACTION.
+ */
+void
+XTestStealJumpData(jx, jy, dev_type)
+/*
+ * the x and y coordinates to jump to
+ */
+int jx;
+int jy;
+/*
+ * which device caused the jump
+ */
+int dev_type;
+{
+ XTestJumpInfo *jmp_ptr;
+ /*
+ * time delta (in ms) from previous event
+ */
+ CARD16 tchar;
+
+ /*
+ * Get the time delta from the previous event. If needed,
+ * the check_time_event routine will put an XTestDELAY_ACTION
+ * type action in the input action event.
+ */
+ tchar = check_time_event();
+ if (!there_is_room(sizeof(XTestJumpInfo)))
+ {
+ /*
+ * If there isn't room in the input action event for
+ * an XTestJUMP_ACTION, then send that event to the
+ * client and start filling an empty one.
+ */
+ flush_input_actions();
+ }
+ /*
+ * update the logical mouse position
+ */
+ xtest_mousex = jx;
+ xtest_mousey = jy;
+ /*
+ * point jmp_ptr to the correct place in the input action event
+ */
+ jmp_ptr = (XTestJumpInfo *)
+ &(input_action_packet.actions[packet_index]);
+ /*
+ * compute the input action header
+ */
+ jmp_ptr->header = (XTestPackDeviceID(dev_type) | XTestJUMP_ACTION);
+ /*
+ * set the x and y coordinates to jump to in the input action
+ */
+ jmp_ptr->jumpx = jx;
+ jmp_ptr->jumpy = jy;
+ /*
+ * set the delay time in the input action
+ */
+ jmp_ptr->delay_time = tchar;
+ /*
+ * increment the packet index by the size of the input action
+ */
+ packet_index = packet_index + sizeof(XTestJumpInfo);
+ if (packed_mode == 0)
+ {
+ /*
+ * if input actions are not packed, send the input
+ * action event to the client
+ */
+ flush_input_actions();
+ }
+}
+
+/******************************************************************************
+ *
+ * current_ms
+ *
+ * Returns the number of milliseconds from the passed-in time to the
+ * current time, and then updates the passed-in time to the current time.
+ */
+static CARD32
+current_ms(otime)
+struct timeval *otime;
+{
+ struct timeval tval;
+ unsigned long the_ms;
+ unsigned long sec;
+ unsigned long usec;
+
+ /*
+ * get the current time
+ */
+ X_GETTIMEOFDAY(&tval);
+ if (tval.tv_usec < otime->tv_usec)
+ {
+ /*
+ * borrow a second's worth of microseconds if needed
+ */
+ usec = tval.tv_usec - otime->tv_usec + 1000000;
+ sec = tval.tv_sec - 1 - otime->tv_sec;
+ }
+ else
+ {
+ usec = tval.tv_usec - otime->tv_usec;
+ sec = tval.tv_sec - otime->tv_sec;
+ }
+ /*
+ * update the passed-in time to the new time
+ */
+ *otime = tval;
+ /*
+ * compute the number of milliseconds contained in
+ * 'sec' seconds and 'usec' microseconds
+ */
+ the_ms = (sec * 1000000L + usec) / 1000L;
+ return (the_ms);
+}
+
+/******************************************************************************
+ *
+ * check_time_event
+ *
+ * If time delta is > XTestSHORT_DELAY_TIME then insert a time event
+ * and return 0; else return the delay time.
+ */
+static CARD16
+check_time_event()
+{
+ CARD32 tstamp;
+ CARD16 tchar;
+ XTestDelayInfo *tptr;
+
+ /*
+ * get the number of milliseconds between input actions
+ */
+ tstamp = current_ms(&current_time);
+ /*
+ * if the number of milliseconds is too large to fit in a CARD16,
+ * then add a XTestDELAY_ACTION to the input action event.
+ */
+ if (tstamp > XTestSHORT_DELAY_TIME)
+ {
+ /*
+ * If there isn't room in the input action event for
+ * an XTestDELAY_ACTION, then send that event to the
+ * client and start filling an empty one.
+ */
+ if (!there_is_room(sizeof(XTestDelayInfo)))
+ {
+ flush_input_actions();
+ }
+ /*
+ * point tptr to the correct place in the input action event
+ */
+ tptr = (XTestDelayInfo *)
+ (&(input_action_packet.actions[packet_index]));
+ /*
+ * compute the input action header
+ */
+ tptr->header = XTestPackDeviceID(XTestDELAY_DEVICE_ID) |
+ XTestDELAY_ACTION;
+ /*
+ * set the delay time in the input action
+ */
+ tptr->delay_time = tstamp;
+ /*
+ * increment the packet index by the size of the input action
+ */
+ packet_index = packet_index + (sizeof(XTestDelayInfo));
+ if (packed_mode != XTestPACKED_ACTIONS)
+ {
+ /*
+ * if input actions are not packed, send the input
+ * action event to the client
+ */
+ flush_input_actions();
+ }
+ /*
+ * set the returned delay time to 0
+ */
+ tchar = 0;
+ }
+ else
+ {
+ /*
+ * set the returned delay time to the computed delay time
+ */
+ tchar = tstamp;
+ }
+ return(tchar);
+}
+
+/******************************************************************************
+ *
+ * there_is_room
+ *
+ * Checks if there is room in the input_action_packet for an input action
+ * of the size actsize bytes. Returns 1 if there is space, 0 otherwise.
+ *
+ */
+static int
+there_is_room(actsize)
+/*
+ * the number of bytes of space needed
+ */
+int actsize;
+{
+ if ((packet_index + actsize) > XTestACTIONS_SIZE)
+ {
+ return(0);
+ }
+ else
+ {
+ return(1);
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestStealMotionData
+ *
+ * Put motion information from the locator into an input action.
+ *
+ * called from x_hil.c
+ */
+void
+XTestStealMotionData(dx, dy, dev_type, mx, my)
+/*
+ * the x and y delta motion of the locator
+ */
+int dx;
+int dy;
+/*
+ * which locator did the moving
+ */
+int dev_type;
+/*
+ * the x and y position of the locator before the delta motion
+ */
+int mx;
+int my;
+{
+ /*
+ * pointer to a XTestMOTION_ACTION input action
+ */
+ XTestMotionInfo *fm;
+ /*
+ * time delta from previous event
+ */
+ CARD16 tchar;
+
+ /*
+ * if the current position of the locator is not the same as
+ * the logical position, then update the logical position
+ */
+ if ((mx != xtest_mousex) || (my != xtest_mousey))
+ {
+ XTestStealJumpData(mx, my, dev_type);
+ }
+ /*
+ * if the delta motion is outside the range that can
+ * be held in a motion input action, use a jump input action
+ */
+ if ((dx > XTestMOTION_MAX) || (dx < XTestMOTION_MIN) ||
+ (dy > XTestMOTION_MAX) || (dy < XTestMOTION_MIN))
+ {
+ XTestStealJumpData((xtest_mousex + dx),
+ (xtest_mousey + dy), dev_type);
+ }
+ else
+ {
+ /*
+ * compute the new logical position of the mouse
+ */
+ xtest_mousex += dx;
+ xtest_mousey += dy;
+ /*
+ * Get the time delta from the previous event. If needed,
+ * the check_time_event routine will put an XTestDELAY_ACTION
+ * type action in the input action event.
+ */
+ tchar = check_time_event();
+ /*
+ * If there isn't room in the input action event for
+ * an XTestDELAY_ACTION, then send that event to the
+ * client and start filling an empty one.
+ */
+ if (!there_is_room(sizeof(XTestMotionInfo)))
+ {
+ flush_input_actions();
+ /*
+ * point fm to the correct place in the input action event
+ */
+ }
+ fm = (XTestMotionInfo *)
+ &(input_action_packet.actions[packet_index]);
+ /*
+ * compute the input action header
+ */
+ fm->header = XTestMOTION_ACTION;
+ if (dx < 0)
+ {
+ fm->header |= XTestX_NEGATIVE;
+ dx = abs(dx);
+ }
+ if (dy < 0)
+ {
+ fm->header |= XTestY_NEGATIVE;
+ dy = abs(dy);
+ }
+ fm->header |= XTestPackDeviceID(dev_type);
+ /*
+ * compute the motion data byte
+ */
+ fm->motion_data = XTestPackYMotionValue(dy);
+ fm->motion_data |= XTestPackXMotionValue(dx);
+ /*
+ * set the delay time in the input action
+ */
+ fm->delay_time = tchar;
+ /*
+ * increment the packet index by the size of the input action
+ */
+ packet_index = packet_index + sizeof(XTestMotionInfo);
+ if (packed_mode == 0)
+ {
+ /*
+ * if input actions are not packed, send the input
+ * action event to the client
+ */
+ flush_input_actions();
+ }
+
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestStealKeyData
+ *
+ * Place this key data in the input_action_packet.
+ *
+ */
+Bool
+XTestStealKeyData(keycode, keystate, dev_type, locx, locy)
+/*
+ * which key/button moved
+ */
+unsigned keycode;
+/*
+ * whether the key/button was pressed or released
+ */
+int keystate;
+/*
+ * which device caused the input action
+ */
+int dev_type;
+/*
+ * the x and y coordinates of the locator when the action happenned
+ */
+int locx;
+int locy;
+{
+ /*
+ * pointer to key/button motion input action
+ */
+ XTestKeyInfo *kp;
+ /*
+ * time delta from previous event
+ */
+ CARD16 tchar;
+ char keytrans = 0;
+
+ /*
+ * update the logical position of the locator if the physical position
+ * of the locator is not the same as the logical position.
+ */
+ if ((locx != xtest_mousex) || (locy != xtest_mousey))
+ {
+ XTestStealJumpData(locx, locy, dev_type);
+ }
+ /*
+ * Get the time delta from the previous event. If needed,
+ * the check_time_event routine will put an XTestDELAY_ACTION
+ * type action in the input action event.
+ */
+ tchar = check_time_event();
+ if (!there_is_room(sizeof(XTestKeyInfo)))
+ {
+ /*
+ * If there isn't room in the input action event for
+ * an XTestDELAY_ACTION, then send that event to the
+ * client and start filling an empty one.
+ */
+ flush_input_actions();
+ }
+ /*
+ * point kp to the correct place in the input action event
+ */
+ kp = (XTestKeyInfo *)
+ (&(input_action_packet.actions[packet_index]));
+ /*
+ * compute the input action header
+ */
+ kp->header = XTestPackDeviceID(dev_type);
+ if ((keystate == KeyRelease) || (keystate == ButtonRelease))
+ {
+ keytrans = XTestKEY_UP;
+ }
+ else if ((keystate == KeyPress) || (keystate == ButtonPress))
+ {
+ keytrans = XTestKEY_DOWN;
+ }
+ else
+ {
+ printf("%s: invalid key/button state %d.\n",
+ XTestEXTENSION_NAME,
+ keystate);
+ }
+ kp->header = kp->header | keytrans | XTestKEY_ACTION;
+ /*
+ * set the keycode in the input action
+ */
+ kp->keycode = keycode;
+ /*
+ * set the delay time in the input action
+ */
+ kp->delay_time = tchar;
+ /*
+ * increment the packet index by the size of the input action
+ */
+ packet_index = packet_index + sizeof(XTestKeyInfo);
+ /*
+ * if the command key has been released or input actions are not
+ * packed, send the input action event to the client
+ */
+ if(((keycode == xtest_command_key) && (keystate == KeyRelease)) ||
+ (packed_mode != XTestPACKED_ACTIONS))
+ {
+ flush_input_actions();
+ }
+ /* return TRUE if the event should be passed on to DIX */
+ if (exclusive_steal)
+ return ((keystate == KeyRelease) &&
+ (keycode == xtest_command_key));
+ else
+ return ((keystate != KeyRelease) ||
+ (keycode != xtest_command_key));
+}
+
+/******************************************************************************
+ *
+ * parse_fake_input
+ *
+ * Parsing routine for a XTestFakeInput request. It will take a request
+ * and parse its contents into the input action array. Eventually the
+ * XTestProcessInputAction routine will be called to take input actions
+ * from the input action array and send them to the server to be handled.
+ */
+void
+parse_fake_input(client, req)
+/*
+ * which client did the XTestFakeInput request
+ */
+ClientPtr client;
+/*
+ * a pointer to the xTestFakeInputReq structure sent by the client
+ */
+char *req;
+{
+ /*
+ * if set to 1, done processing input actions from the request
+ */
+ int done = 0;
+ /*
+ * type of input action
+ */
+ CARD8 action_type;
+ /*
+ * device type
+ */
+ CARD8 dev_type;
+ /*
+ * pointer to an xTestFakeInputReq structure
+ */
+ xTestFakeInputReq *request;
+ /*
+ * holds the index into the action list in the request
+ */
+ int parse_index;
+
+ /*
+ * get a correct-type pointer to the client-supplied request data
+ */
+ request = (xTestFakeInputReq *) req;
+ /*
+ * save the acknowledge requested state for use in
+ * XTestProcessInputAction
+ */
+ acknowledge = request->ack;
+ /*
+ * set up an index into the action list in the request
+ */
+ parse_index = 0;
+ if (write_index >= ACTION_ARRAY_SIZE)
+ {
+ /*
+ * if the input action array is full, don't add any more
+ */
+ done = 1;
+ }
+ while (!done)
+ {
+ /*
+ * get the type of input action in the list
+ */
+ action_type = (request->action_list[parse_index])
+ & XTestACTION_TYPE_MASK;
+ /*
+ * get the type of device in the list
+ */
+ dev_type = XTestUnpackDeviceID(request->action_list[parse_index]);
+ /*
+ * process the input action appropriately
+ */
+ switch (action_type)
+ {
+ case XTestKEY_ACTION:
+ parse_key_fake((XTestKeyInfo *)
+ &(request->action_list[parse_index]));
+ parse_index = parse_index + sizeof(XTestKeyInfo);
+ break;
+ case XTestMOTION_ACTION:
+ parse_motion_fake((XTestMotionInfo *)
+ &(request->action_list[parse_index]));
+ parse_index = parse_index + sizeof(XTestMotionInfo);
+ break;
+ case XTestJUMP_ACTION:
+ parse_jump_fake((XTestJumpInfo *)
+ &(request->action_list[parse_index]));
+ parse_index = parse_index + sizeof(XTestJumpInfo);
+ break;
+ case XTestDELAY_ACTION:
+ if (dev_type == XTestDELAY_DEVICE_ID)
+ {
+ parse_delay_fake((XTestDelayInfo *)
+ &(request->action_list[parse_index]));
+ parse_index = parse_index +
+ sizeof(XTestDelayInfo);
+ }
+ else
+ {
+ /*
+ * An invalid input action header byte has
+ * been detected, so there are no more
+ * input actions in this request.
+ * The intended invalid action header byte
+ * for this case should have a value of 0.
+ */
+ done = 1;
+ }
+ break;
+ }
+ if (parse_index >= XTestMAX_ACTION_LIST_SIZE)
+ {
+ /*
+ * entire XTestFakeInput request has been processed
+ */
+ done = 1;
+ }
+ if (write_index >= ACTION_ARRAY_SIZE)
+ {
+ /*
+ * no room in the input actions array
+ */
+ done = 1;
+ }
+ }
+ if (write_index > read_index)
+ {
+ /*
+ * there are fake input actions in the input action array
+ * to be given to the server
+ */
+ playback_on = 1;
+ playback_client = client;
+ }
+}
+
+/******************************************************************************
+ *
+ * parse_key_fake
+ *
+ * Called from parse_fake_input.
+ *
+ * Copy the fake key input action from its packed form into the array of
+ * pending input events.
+ */
+static void
+parse_key_fake(fkey)
+XTestKeyInfo *fkey;
+{
+ action_array[write_index].type = XTestKEY_ACTION;
+ action_array[write_index].device = XTestUnpackDeviceID(fkey->header);
+ action_array[write_index].keycode = fkey->keycode;
+ action_array[write_index].keystate = fkey->header & XTestKEY_STATE_MASK;
+ action_array[write_index].delay_time = fkey->delay_time;
+ write_index++;
+}
+
+/******************************************************************************
+ *
+ * parse_motion_fake
+ *
+ * Called from parse_fake_input.
+ *
+ * Copy the fake motion input action from its packed form into the array of
+ * pending input events.
+ */
+static void
+parse_motion_fake(fmotion)
+XTestMotionInfo *fmotion;
+{
+ int dx;
+ int dy;
+
+ dx = (XTestUnpackXMotionValue(fmotion->motion_data));
+ dy = (XTestUnpackYMotionValue(fmotion->motion_data));
+ if (((fmotion->header) & XTestX_SIGN_BIT_MASK) == XTestX_NEGATIVE)
+ {
+ pmousex -= dx;
+ }
+ else
+ {
+ pmousex += dx;
+ }
+ if (((fmotion->header) & XTestY_SIGN_BIT_MASK) == XTestY_NEGATIVE)
+ {
+ pmousey -= dy;
+ }
+ else
+ {
+ pmousey += dy;
+ }
+ action_array[write_index].type = XTestJUMP_ACTION;
+ action_array[write_index].device = XTestUnpackDeviceID(fmotion->header);
+ action_array[write_index].x = pmousex;
+ action_array[write_index].y = pmousey;
+ action_array[write_index].delay_time = fmotion->delay_time;
+ write_index++;
+}
+
+/******************************************************************************
+ *
+ * parse_jump_fake
+ *
+ * Called from parse_fake_input.
+ *
+ * Copy the fake jump input action from its packed form into the array of
+ * pending input events.
+ */
+static void
+parse_jump_fake(fjump)
+XTestJumpInfo *fjump;
+{
+ pmousex = fjump->jumpx;
+ pmousey = fjump->jumpy;
+ action_array[write_index].type = XTestJUMP_ACTION;
+ action_array[write_index].device = XTestUnpackDeviceID(fjump->header);
+ action_array[write_index].x = pmousex;
+ action_array[write_index].y = pmousey;
+ action_array[write_index].delay_time = fjump->delay_time;
+ write_index++;
+}
+
+/******************************************************************************
+ *
+ * parse_delay_fake
+ *
+ * Called from parse_fake_input.
+ *
+ * Copy the fake delay input action from its packed form into the array of
+ * pending input events.
+ */
+static void
+parse_delay_fake(tevent)
+XTestDelayInfo *tevent;
+{
+ action_array[write_index].type = XTestDELAY_ACTION;
+ action_array[write_index].delay_time = tevent->delay_time;
+ write_index++;
+}
+
+/******************************************************************************
+ *
+ * XTestComputeWaitTime
+ *
+ * Compute the amount of time the server should wait before sending the
+ * next monitor event in playback mode.
+ */
+void
+XTestComputeWaitTime(waittime)
+struct timeval *waittime;
+{
+ /*
+ * The playback_on flag is set to 1 in parse_fake_input. It is set to
+ * 0 in XTestProcessInputAction if the server has replayed all input
+ * actions.
+ */
+ if (playback_on)
+ {
+ if (!play_clock)
+ {
+ /*
+ * if the playback clock has never been set,
+ * then do it now
+ */
+ start_play_clock();
+ }
+ /*
+ * We need to save the waittime the first time through. This
+ * is a value the server uses, and we have to restore it when
+ * all of the input actions are processed by the server.
+ */
+ if (!time_saved)
+ {
+ saved_sec = waittime->tv_sec;
+ saved_usec = waittime->tv_usec;
+ time_saved = 1;
+ }
+ if (go_for_next)
+ {
+ /*
+ * if we just processed an input action, figure out
+ * how long to wait for the next input action
+ */
+ compute_action_time(&rtime);
+ }
+ else
+ {
+ /*
+ * else just find out how much more time to wait
+ * on the current input action
+ */
+ (void)find_residual_time(&rtime);
+ }
+ waittime->tv_sec = rtime.tv_sec;
+ waittime->tv_usec = rtime.tv_usec;
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestProcessInputAction
+ *
+ * If there are any input actions in the input action array,
+ * then take one out and process it.
+ *
+ */
+int
+XTestProcessInputAction(readable, waittime)
+/*
+ * This is the value that a 'select' function returned just before this
+ * routine was called. If the select timed out, this value will be 0.
+ *
+ * This extension modifies the select call's timeout value to cause the
+ * select to time out when the next input action is ready to given to
+ * the server. This routine is called immediately after the select, to
+ * give it a chance to process an input action. If we have an input action
+ * to process and the only reason that the select returned was because it
+ * timed out, then we change the select value to 1 and return 1 instead of 0.
+ */
+int readable;
+/*
+ * this is the timeout value that the select was called with
+ */
+struct timeval *waittime;
+{
+int mousex, mousey;
+ /*
+ * if playback_on is 0, then the input action array is empty
+ */
+ if (playback_on)
+ {
+ restorewait = waittime;
+ /*
+ * figure out if we need to wait for the next input action
+ */
+ if (find_residual_time(&rtime) > 0)
+ {
+ /*
+ * still have to wait before processing the current
+ * input action
+ */
+ go_for_next = 0;
+ }
+ else
+ {
+ /*
+ * don't have to wait any longer before processing
+ * the current input action
+ */
+ go_for_next = 1;
+ }
+ /*
+ * if we have an input action to process and the only reason
+ * that the select returned was because it timed out, then we
+ * change the select value to 1 and return 1 instead of 0
+ */
+ if (readable == 0)
+ {
+ readable++;
+ }
+ /*
+ * if we don't need to wait, then get an input action from
+ * the input action array and process it
+ */
+ if (go_for_next)
+ {
+ /*
+ * There are three possible types of input actions in
+ * the input action array (motion input actions are
+ * converted to jump input actions before being put
+ * into the input action array). Delay input actions
+ * are processed by the compute_action_time function
+ * which is called from XTestComputeWaitTime. The
+ * other two types of input actions are processed here.
+ */
+ if (action_array[read_index].type == XTestJUMP_ACTION)
+ {
+ XTestJumpPointer(
+ action_array[read_index].x,
+ action_array[read_index].y,
+ action_array[read_index].device);
+ }
+ if (action_array[read_index].type == XTestKEY_ACTION)
+ {
+ GetSpritePosition(&mousex, &mousey);
+ XTestGenerateEvent(
+ action_array[read_index].device,
+ action_array[read_index].keycode,
+ action_array[read_index].keystate,
+ mousex,
+ mousey);
+ }
+ read_index++;
+ /*
+ * if all input actions are processed, then restore
+ * the server state
+ */
+ if (read_index >= write_index)
+ {
+ waittime->tv_sec = saved_sec;
+ waittime->tv_usec = saved_usec;
+ time_saved = 0;
+ playback_on = 0;
+ if (acknowledge)
+ {
+ /*
+ * if the playback client is waiting
+ * for an xTestFakeAck event, send
+ * it to him
+ */
+ send_ack(playback_client);
+ acknowledge = 0;
+ }
+ write_index = 0;
+ read_index = 0;
+ playback_client = (ClientPtr) NULL;
+ play_clock = 0;
+ }
+ }
+ }
+ return(readable);
+}
+
+/******************************************************************************
+ *
+ * send_ack
+ *
+ * send an xTestFakeAck event to the client
+ */
+static void
+send_ack(client)
+ClientPtr client;
+{
+ xTestFakeAckEvent rep;
+
+ /*
+ * set the serial number of the xTestFakeAck event
+ */
+ rep.sequenceNumber = client->sequence;
+ rep.type = XTestFakeAckType;
+ WriteEventsToClient(client, 1, (xEvent *) &rep);
+}
+
+/******************************************************************************
+ *
+ * start_play_clock
+ *
+ * start the clock for play back.
+ */
+static void
+start_play_clock()
+{
+ X_GETTIMEOFDAY(&play_time);
+ /*
+ * flag that play_time is valid
+ */
+ play_clock = 1;
+}
+
+/******************************************************************************
+ *
+ * compute_action_time
+ *
+ * Set the play clock to the time when the next input action should be put
+ * into the server's input queue. Fill the rtime structure with values
+ * for the delta until the time for the next input action.
+ */
+static void
+compute_action_time(rtime)
+struct timeval *rtime;
+{
+ /*
+ * holds the delay time in milliseconds
+ */
+ unsigned long dtime;
+ /*
+ * holds the number of microseconds in the sum of the dtime value
+ * and the play_time value
+ */
+ unsigned long tot_usec;
+ /*
+ * holds the number of seconds and microseconds in the
+ * dtime value
+ */
+ unsigned long sec;
+ unsigned long usec;
+ /*
+ * holds the current time
+ */
+ struct timeval btime;
+
+ /*
+ * Put the time from the current input action in dtime
+ */
+ dtime = action_array[read_index].delay_time;
+ /*
+ * If the current input action is a delay input action,
+ * add in the time from the following input action.
+ */
+ if ((action_array[read_index].type == XTestDELAY_ACTION) &&
+ ((read_index + 1) < write_index))
+ {
+ read_index++;
+ dtime = dtime + action_array[read_index].delay_time;
+ }
+ /*
+ * compute the number of seconds and microseconds in the
+ * dtime value
+ */
+ sec = dtime / 1000;
+ usec = (dtime % 1000) * 1000;
+ /*
+ * get the current time in btime
+ */
+ X_GETTIMEOFDAY(&btime);
+ /*
+ * compute the number of microseconds in the sum of the dtime value
+ * and the current usec value
+ */
+ tot_usec = btime.tv_usec + usec;
+ /*
+ * if it is greater than one second's worth, adjust the seconds
+ */
+ if (tot_usec >= 1000000)
+ {
+ tot_usec -= 1000000;
+ sec++;
+ }
+ play_time.tv_usec = tot_usec;
+ play_time.tv_sec = btime.tv_sec + sec;
+ /*
+ * put the time until the next input action in rtime
+ */
+ rtime->tv_sec = sec;
+ rtime->tv_usec = usec;
+}
+
+/******************************************************************************
+ *
+ * find_residual_time
+ *
+ * Find the time interval from the current time to the value in play_time.
+ * This is the time to wait till putting the next input action into the
+ * server's input queue. If the time is already up, reset play_time to
+ * the current time.
+ */
+static int
+find_residual_time(the_residual)
+struct timeval *the_residual;
+{
+ /*
+ * if > 0, there is time to wait. If < 0, then don't wait
+ */
+ int wait = 1;
+ /*
+ * holds the current time
+ */
+ struct timeval btime;
+ /*
+ * holds the current time in seconds and microseconds
+ */
+ unsigned long bsec;
+ unsigned long busec;
+ /*
+ * holds the playback time in seconds and microseconds
+ */
+ unsigned long psec;
+ unsigned long pusec;
+
+ /*
+ * get the current time in btime
+ */
+ X_GETTIMEOFDAY(&btime);
+ /*
+ * get the current time in seconds and microseconds
+ */
+ bsec = btime.tv_sec;
+ busec = btime.tv_usec;
+ /*
+ * get the playback time in seconds and microseconds
+ */
+ psec = play_time.tv_sec;
+ pusec = play_time.tv_usec;
+ /*
+ * if the current time is already later than the playback time,
+ * we don't need to wait
+ */
+ if (bsec > psec)
+ {
+ wait = -1;
+ }
+ else
+ {
+ if (bsec == psec)
+ {
+ /*
+ * if the current and playback times have the same
+ * second value, then compare the microsecond values
+ */
+ if ( busec >= pusec)
+ {
+ /*
+ * if the current time is already later than
+ * the playback time, we don't need to wait
+ */
+ wait = -1;
+ }
+ else
+ {
+ the_residual->tv_usec = pusec - busec;
+ the_residual->tv_sec = 0;
+ }
+ }
+ else
+ {
+ if (busec > pusec)
+ {
+ /*
+ * 'borrow' a second's worth of microseconds
+ * from the seconds left to wait
+ */
+ the_residual->tv_usec = 1000000 - busec + pusec;
+ psec--;
+ the_residual->tv_sec = psec - bsec;
+ }
+ else
+ {
+ the_residual->tv_sec = psec - bsec;
+ the_residual->tv_usec = pusec - busec;
+ }
+ }
+ }
+ if (wait < 0)
+ {
+ /*
+ * if don't need to wait, set the playback time
+ * to the current time
+ */
+ X_GETTIMEOFDAY(&play_time);
+ /*
+ * set the time to wait to 0
+ */
+ the_residual->tv_sec = 0;
+ the_residual->tv_usec = 0;
+ }
+ return(wait);
+}
+
+/******************************************************************************
+ *
+ * abort_play_back
+ */
+void
+abort_play_back()
+{
+ /*
+ * If we were playing back input actions at the time of the abort,
+ * restore the original wait time for the select in the main wait
+ * loop of the server
+ */
+ if (playback_on)
+ {
+ restorewait->tv_sec = saved_sec;
+ restorewait->tv_usec = saved_usec;
+ }
+ /*
+ * make the input action array empty
+ */
+ read_index = 0;
+ write_index = 0;
+ /*
+ * we are no longer playing back anything
+ */
+ playback_on = 0;
+ play_clock = 0;
+ go_for_next = 1;
+ /*
+ * there is no valid wait time saved any more
+ */
+ time_saved = 0;
+ /*
+ * there are no valid clients using this extension
+ */
+ playback_client = (ClientPtr) NULL;
+ current_xtest_client = (ClientPtr) NULL;
+}
+
+/******************************************************************************
+ *
+ * return_input_array_size
+ *
+ * Return the number of input actions in the input action array.
+ */
+void
+return_input_array_size(client)
+/*
+ * which client to send the reply to
+ */
+ClientPtr client;
+{
+ xTestQueryInputSizeReply rep;
+
+ rep.type = X_Reply;
+ /*
+ * set the serial number of the reply
+ */
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.size_return = ACTION_ARRAY_SIZE;
+ WriteReplyToClient(client,
+ sizeof(xTestQueryInputSizeReply),
+ (pointer) &rep);
+}
diff --git a/nx-X11/programs/Xserver/Xext/xtest1dd.h b/nx-X11/programs/Xserver/Xext/xtest1dd.h
new file mode 100644
index 000000000..3130c7075
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xtest1dd.h
@@ -0,0 +1,127 @@
+/* $XFree86: xc/programs/Xserver/Xext/xtest1dd.h,v 3.2 2001/08/01 00:44:44 tsi Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef XTEST1DD_H
+#define XTEST1DD_H 1
+
+extern short xtest_mousex;
+extern short xtest_mousey;
+extern int playback_on;
+extern ClientPtr current_xtest_client;
+extern ClientPtr playback_client;
+extern KeyCode xtest_command_key;
+
+extern void stop_stealing_input(
+ void
+);
+
+extern void
+steal_input(
+ ClientPtr /* client */,
+ CARD32 /* mode */
+);
+
+extern void
+flush_input_actions(
+ void
+);
+
+extern void
+XTestStealJumpData(
+ int /* jx */,
+ int /* jy */,
+ int /* dev_type */
+);
+
+extern void
+XTestStealMotionData(
+ int /* dx */,
+ int /* dy */,
+ int /* dev_type */,
+ int /* mx */,
+ int /* my */
+);
+
+extern Bool
+XTestStealKeyData(
+ unsigned /* keycode */,
+ int /* keystate */,
+ int /* dev_type */,
+ int /* locx */,
+ int /* locy */
+);
+
+extern void
+parse_fake_input(
+ ClientPtr /* client */,
+ char * /* req */
+);
+
+extern void
+XTestComputeWaitTime(
+ struct timeval * /* waittime */
+);
+
+extern int
+XTestProcessInputAction(
+ int /* readable */,
+ struct timeval * /* waittime */
+);
+
+extern void
+abort_play_back(
+ void
+);
+
+extern void
+return_input_array_size(
+ ClientPtr /* client */
+);
+
+extern void XTestGenerateEvent(
+ int /* dev_type */,
+ int /* keycode */,
+ int /* keystate */,
+ int /* mousex */,
+ int /* mousey */
+);
+
+extern void XTestGetPointerPos(
+ short * /* fmousex */,
+ short * /* fmousey */
+);
+
+extern void XTestJumpPointer(
+ int /* jx */,
+ int /* jy */,
+ int /* dev_type */
+);
+
+#endif /* XTEST1DD_H */
diff --git a/nx-X11/programs/Xserver/Xext/xtest1di.c b/nx-X11/programs/Xserver/Xext/xtest1di.c
new file mode 100644
index 000000000..d95b30612
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xtest1di.c
@@ -0,0 +1,954 @@
+/* $XdotOrg: xc/programs/Xserver/Xext/xtest1di.c,v 1.6 2005/07/03 08:53:36 daniels Exp $ */
+/* $Xorg: xtest1di.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
+/*
+ * File: xtest1di.c
+ *
+ * This file contains the device independent parts of the input
+ * synthesis extension.
+ */
+
+/*
+
+
+Copyright 1986, 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1986, 1987, 1988 by Hewlett-Packard Corporation
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Hewlett-Packard not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+Hewlett-Packard makes no representations about the
+suitability of this software for any purpose. It is provided
+"as is" without express or implied warranty.
+
+This software is not subject to any license of the American
+Telephone and Telegraph Company or of the Regents of the
+University of California.
+
+*/
+/* $XFree86: xc/programs/Xserver/Xext/xtest1di.c,v 3.5 2003/09/13 21:33:03 dawes Exp $ */
+
+/*****************************************************************************
+ * include files
+ ****************************************************************************/
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "gcstruct.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "opaque.h"
+#define XTestSERVER_SIDE
+#include <X11/extensions/xtestext1.h>
+#include "modinit.h"
+
+#include "xtest1dd.h"
+
+/*****************************************************************************
+ * defines
+ ****************************************************************************/
+
+/*****************************************************************************
+ * variables
+ ****************************************************************************/
+
+/*
+ * Holds the request type code for this extension. The request type code
+ * for this extension may vary depending on how many extensions are installed
+ * already, so the initial value given below will be added to the base request
+ * code that is aquired when this extension is installed.
+ */
+static int XTestReqCode = 0;
+/*
+ * Holds the two event type codes for this extension. The event type codes
+ * for this extension may vary depending on how many extensions are installed
+ * already, so the initial values given below will be added to the base event
+ * code that is aquired when this extension is installed.
+ */
+int XTestInputActionType = 0;
+int XTestFakeAckType = 1;
+/*
+ * true => monitor stealing input
+ */
+int on_steal_input = FALSE;
+/*
+ * true => monitor alone getting input
+ */
+int exclusive_steal = FALSE;
+/*
+ * holds the resource type assigned to this extension
+ */
+static RESTYPE XTestType;
+/*
+ * holds the resource ID for the client currently using XTestGetInput
+ */
+static XID current_client_id;
+
+/*****************************************************************************
+ * function declarations
+ ****************************************************************************/
+
+static DISPATCH_PROC(ProcXTestDispatch);
+static DISPATCH_PROC(SProcXTestDispatch);
+static DISPATCH_PROC(ProcTestFakeInput);
+static DISPATCH_PROC(SProcTestFakeInput);
+static DISPATCH_PROC(ProcTestGetInput);
+static DISPATCH_PROC(SProcTestGetInput);
+static DISPATCH_PROC(ProcTestStopInput);
+static DISPATCH_PROC(SProcTestStopInput);
+static DISPATCH_PROC(ProcTestReset);
+static DISPATCH_PROC(SProcTestReset);
+static DISPATCH_PROC(ProcTestQueryInputSize);
+static DISPATCH_PROC(SProcTestQueryInputSize);
+
+static void XTestResetProc(
+ ExtensionEntry * /* unused */
+ );
+static void SReplyXTestDispatch(
+ ClientPtr /* client_ptr */,
+ int /* size */,
+ char * /* reply_ptr */
+ );
+static void SEventXTestDispatch(
+ xEvent * /* from */,
+ xEvent * /* to */
+ );
+
+static int XTestCurrentClientGone(
+ pointer /* value */,
+ XID /* id */
+ );
+
+/*****************************************************************************
+ *
+ * XTestExtension1Init
+ *
+ * Called from InitExtensions in main() or from QueryExtension() if the
+ * extension is dynamically loaded.
+ *
+ * XTestExtension1Init has no events or errors
+ * (other than the core errors).
+ */
+void
+XTestExtension1Init(INITARGS)
+{
+ /*
+ * holds the pointer to the extension entry structure
+ */
+ ExtensionEntry *extEntry;
+
+ extEntry = AddExtension(XTestEXTENSION_NAME,
+ XTestEVENT_COUNT,
+ 0,
+ ProcXTestDispatch,
+ SProcXTestDispatch,
+ XTestResetProc,
+ StandardMinorOpcode);
+ if (extEntry)
+ {
+ /*
+ * remember the request code assigned to this extension
+ */
+ XTestReqCode = extEntry->base;
+ /*
+ * make an atom saying that this extension is present
+ */
+ (void) MakeAtom(XTestEXTENSION_NAME,
+ strlen(XTestEXTENSION_NAME),
+ TRUE);
+ /*
+ * remember the event codes assigned to this extension
+ */
+ XTestInputActionType += extEntry->eventBase;
+ XTestFakeAckType += extEntry->eventBase;
+ /*
+ * install the routine to handle byte-swapping the replies
+ * for this extension in the ReplySwapVector table
+ */
+ ReplySwapVector[XTestReqCode] = (ReplySwapPtr) SReplyXTestDispatch;
+ /*
+ * install the routine to handle byte-swapping the events
+ * for this extension in the EventSwapVector table
+ */
+ EventSwapVector[XTestInputActionType] = SEventXTestDispatch;
+ EventSwapVector[XTestFakeAckType] = SEventXTestDispatch;
+ /*
+ * get the resource type for this extension
+ */
+ XTestType = CreateNewResourceType(XTestCurrentClientGone);
+ if (XTestType == 0)
+ {
+ FatalError("XTestExtension1Init: CreateNewResourceType failed\n");
+ }
+ }
+ else
+ {
+ FatalError("XTestExtension1Init: AddExtensions failed\n");
+ }
+}
+
+/*****************************************************************************
+ *
+ * ProcXTestDispatch
+ *
+ *
+ */
+static int
+ProcXTestDispatch(client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ if (stuff->data == X_TestFakeInput)
+ {
+ return(ProcTestFakeInput(client));
+ }
+ else if (stuff->data == X_TestGetInput)
+ {
+ return(ProcTestGetInput(client));
+ }
+ else if (stuff->data == X_TestStopInput)
+ {
+ return(ProcTestStopInput(client));
+ }
+ else if (stuff->data == X_TestReset)
+ {
+ return(ProcTestReset(client));
+ }
+ else if (stuff->data == X_TestQueryInputSize)
+ {
+ return(ProcTestQueryInputSize(client));
+ }
+ else
+ {
+ SendErrorToClient(client,
+ XTestReqCode,
+ stuff->data,
+ None,
+ BadRequest);
+ return(BadRequest);
+ }
+}
+
+/*****************************************************************************
+ *
+ * SProcXTestDispatch
+ *
+ *
+ */
+static int
+SProcXTestDispatch(client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ if (stuff->data == X_TestFakeInput)
+ {
+ return(SProcTestFakeInput(client));
+ }
+ else if (stuff->data == X_TestGetInput)
+ {
+ return(SProcTestGetInput(client));
+ }
+ else if (stuff->data == X_TestStopInput)
+ {
+ return(SProcTestStopInput(client));
+ }
+ else if (stuff->data == X_TestReset)
+ {
+ return(SProcTestReset(client));
+ }
+ else if (stuff->data == X_TestQueryInputSize)
+ {
+ return(SProcTestQueryInputSize(client));
+ }
+ else
+ {
+ SendErrorToClient(client,
+ XTestReqCode,
+ stuff->data,
+ None,
+ BadRequest);
+ return(BadRequest);
+ }
+}
+
+/*****************************************************************************
+ *
+ * SProcTestFakeInput
+ *
+ *
+ */
+static int
+SProcTestFakeInput(client)
+ register ClientPtr client;
+{
+ /*
+ * used in the swaps and swapl macros for temporary storage space
+ */
+ register char n;
+ /*
+ * index counter
+ */
+ int i;
+ /*
+ * pointer to the next input action in the request
+ */
+ CARD8 *input_action_ptr;
+ /*
+ * holds the type of the next input action in the request
+ */
+ int input_action_type;
+
+ REQUEST(xTestFakeInputReq);
+ /*
+ * byte-swap the fields in the request
+ */
+ swaps(&stuff->length, n);
+ swapl(&stuff->ack, n);
+ /*
+ * have to parse and then byte-swap the input action list here
+ */
+ for (i = 0; i < XTestMAX_ACTION_LIST_SIZE;)
+ {
+ /*
+ * point to the next input action in the request
+ */
+ input_action_ptr = &(((xTestFakeInputReq *) stuff)->action_list[i]);
+ /*
+ * figure out what type of input action it is
+ */
+ input_action_type = (*input_action_ptr) & XTestACTION_TYPE_MASK;
+ /*
+ * byte-swap the input action according to it's type
+ */
+ switch (input_action_type)
+ {
+ case XTestKEY_ACTION:
+ /*
+ * byte-swap the delay_time field
+ */
+ swaps(&(((XTestKeyInfo *) input_action_ptr)->delay_time), n);
+ /*
+ * advance to the next input action
+ */
+ i += sizeof(XTestKeyInfo);
+ break;
+ case XTestMOTION_ACTION:
+ /*
+ * byte-swap the delay_time field
+ */
+ swaps(&(((XTestMotionInfo *) input_action_ptr)->delay_time), n);
+ /*
+ * advance to the next input action
+ */
+ i += sizeof(XTestMotionInfo);
+ break;
+ case XTestJUMP_ACTION:
+ /*
+ * byte-swap the jumpx field
+ */
+ swaps(&(((XTestJumpInfo *) input_action_ptr)->jumpx), n);
+ /*
+ * byte-swap the jumpy field
+ */
+ swaps(&(((XTestJumpInfo *) input_action_ptr)->jumpy), n);
+ /*
+ * byte-swap the delay_time field
+ */
+ swaps(&(((XTestJumpInfo *) input_action_ptr)->delay_time), n);
+ /*
+ * advance to the next input action
+ */
+ i += sizeof(XTestJumpInfo);
+ break;
+ default:
+ /*
+ * if this is a delay input action, then byte-swap it,
+ * otherwise we have reached the end of the input
+ * actions in this request
+ */
+ if (XTestUnpackDeviceID(*input_action_ptr) ==
+ XTestDELAY_DEVICE_ID)
+ {
+ /*
+ * byte-swap the delay_time field
+ */
+ swapl(&(((XTestDelayInfo *) input_action_ptr)->delay_time), n);
+ /*
+ * advance to the next input action
+ */
+ i += sizeof(XTestDelayInfo);
+ }
+ else
+ {
+ /*
+ * if the input action header byte is 0 or
+ * ill-formed, then there are no more input
+ * actions in this request
+ */
+ i = XTestMAX_ACTION_LIST_SIZE;
+ }
+ break;
+ }
+ }
+ return(ProcTestFakeInput(client));
+}
+
+/*****************************************************************************
+ *
+ * SProcTestGetInput
+ *
+ *
+ */
+static int
+SProcTestGetInput(client)
+ register ClientPtr client;
+{
+ /*
+ * used in the swaps and swapl macros for temporary storage space
+ */
+ register char n;
+
+ REQUEST(xTestGetInputReq);
+ /*
+ * byte-swap the fields in the request
+ */
+ swaps(&stuff->length, n);
+ swapl(&stuff->mode, n);
+ return(ProcTestGetInput(client));
+}
+
+/*****************************************************************************
+ *
+ * SProcTestStopInput
+ *
+ *
+ */
+static int
+SProcTestStopInput(client)
+ register ClientPtr client;
+{
+ /*
+ * used in the swaps and swapl macros for temporary storage space
+ */
+ register char n;
+
+ REQUEST(xTestStopInputReq);
+ /*
+ * byte-swap the length field in the request
+ */
+ swaps(&stuff->length, n);
+ return(ProcTestStopInput(client));
+}
+
+/*****************************************************************************
+ *
+ * SProcTestReset
+ *
+ *
+ */
+static int
+SProcTestReset(client)
+ register ClientPtr client;
+{
+ /*
+ * used in the swaps and swapl macros for temporary storage space
+ */
+ register char n;
+
+ REQUEST(xTestResetReq);
+ /*
+ * byte-swap the length field in the request
+ */
+ swaps(&stuff->length, n);
+ return(ProcTestReset(client));
+}
+
+/*****************************************************************************
+ *
+ * SProcTestQueryInputSize
+ *
+ *
+ */
+static int
+SProcTestQueryInputSize(client)
+ register ClientPtr client;
+{
+ /*
+ * used in the swaps and swapl macros for temporary storage space
+ */
+ register char n;
+
+ REQUEST(xTestQueryInputSizeReq);
+ /*
+ * byte-swap the length field in the request
+ */
+ swaps(&stuff->length, n);
+ return(ProcTestQueryInputSize(client));
+}
+
+/*****************************************************************************
+ *
+ * ProcTestFakeInput
+ *
+ *
+ */
+static int
+ProcTestFakeInput(client)
+ register ClientPtr client;
+{
+ REQUEST(xTestFakeInputReq);
+ REQUEST_SIZE_MATCH(xTestFakeInputReq);
+
+ if (playback_client == NULL)
+ {
+ playback_client = client;
+ current_client_id = FakeClientID(client->index);
+ AddResource(current_client_id,
+ XTestType,
+ 0);
+ MakeClientGrabImpervious(client);
+ }
+ if (playback_client == client)
+ {
+ /*
+ * This extension does not need to clean up any
+ * server state when a client using this function
+ * "goes away". The server will just process any
+ * input actions that have already been sent to it,
+ * and will then reset its association with a client.
+ */
+ parse_fake_input(client, (char *)stuff);
+ return(Success);
+ }
+ else
+ {
+ /*
+ * this is a request by another client to send fake
+ * input while the server is still being used
+ */
+ SendErrorToClient(client,
+ XTestReqCode,
+ X_TestFakeInput,
+ None,
+ BadAccess);
+ return(BadAccess);
+ }
+}
+
+/*****************************************************************************
+ *
+ * ProcTestGetInput
+ *
+ *
+ */
+static int
+ProcTestGetInput(client)
+ register ClientPtr client;
+{
+ REQUEST(xTestGetInputReq);
+ REQUEST_SIZE_MATCH(xTestGetInputReq);
+ if (on_steal_input)
+ {
+ /*
+ * this is a request by another client to get fake input
+ * while the server is still sending input to the first client
+ */
+ SendErrorToClient(client,
+ XTestReqCode,
+ X_TestGetInput,
+ None,
+ BadAccess);
+ return(BadAccess);
+ }
+ else
+ {
+ /*
+ * Set up a resource associated with the client using this
+ * function so that this extension gets called when the
+ * client "goes away". This allows this extension to
+ * clean up the server state.
+ */
+ current_client_id = FakeClientID(client->index);
+ AddResource(current_client_id,
+ XTestType,
+ 0);
+ /*
+ * indicate that a client is stealing input
+ */
+ on_steal_input = TRUE;
+ if ((stuff->mode & XTestEXCLUSIVE) == 0)
+ {
+ exclusive_steal = FALSE;
+ }
+ else
+ {
+ exclusive_steal = TRUE;
+ }
+ steal_input(client, stuff->mode);
+ return(Success);
+ }
+}
+
+/*****************************************************************************
+ *
+ * ProcTestStopInput
+ *
+ *
+ */
+static int
+ProcTestStopInput(client)
+ register ClientPtr client;
+{
+ REQUEST_SIZE_MATCH(xTestStopInputReq);
+ if (on_steal_input && (current_xtest_client == client))
+ {
+ on_steal_input = FALSE;
+ exclusive_steal = FALSE;
+ stop_stealing_input();
+ /*
+ * remove the resource associated with this client
+ */
+ FreeResource(current_client_id, RT_NONE);
+ return(Success);
+ }
+ else
+ {
+ /*
+ * this is a request to stop fake input when fake input has
+ * never been started or from a client that hasn't started
+ * fake input
+ */
+ SendErrorToClient(client,
+ XTestReqCode,
+ X_TestStopInput,
+ None,
+ BadAccess);
+ return(BadAccess);
+ }
+}
+
+/*****************************************************************************
+ *
+ * ProcTestReset
+ *
+ *
+ */
+static int
+ProcTestReset(client)
+ register ClientPtr client;
+{
+ REQUEST_SIZE_MATCH(xTestResetReq);
+ on_steal_input = FALSE;
+ exclusive_steal = FALSE;
+ /*
+ * defined in xtest1dd.c
+ */
+ stop_stealing_input();
+ /*
+ * defined in xtest1dd.c
+ */
+ abort_play_back();
+ return(Success);
+}
+
+/*****************************************************************************
+ *
+ * ProcTestQueryInputSize
+ *
+ *
+ */
+static int
+ProcTestQueryInputSize(client)
+ register ClientPtr client;
+{
+ REQUEST_SIZE_MATCH(xTestQueryInputSizeReq);
+ /*
+ * defined in xtest1dd.c
+ */
+ return_input_array_size(client);
+ return(Success);
+}
+
+/*****************************************************************************
+ *
+ * XTestResetProc
+ *
+ * This function is called by the server when the server has no clients
+ * connected to it. It must put eveything back the way it was before
+ * this extension was installed.
+ */
+/*ARGSUSED*/
+static void
+XTestResetProc(unused)
+ ExtensionEntry * unused;
+{
+ /*
+ * remove the routine to handle byte-swapping the replies
+ * for this extension in the ReplySwapVector table
+ */
+ ReplySwapVector[XTestReqCode] = ReplyNotSwappd;
+ /*
+ * remove the routine to handle byte-swapping the events
+ * for this extension in the EventSwapVector table
+ */
+ EventSwapVector[XTestInputActionType] = NotImplemented;
+ EventSwapVector[XTestFakeAckType] = NotImplemented;
+ /*
+ * reset the variables initialized just once at load time
+ */
+ XTestReqCode = 0;
+ XTestInputActionType = 0;
+ XTestFakeAckType = 1;
+ on_steal_input = FALSE;
+ exclusive_steal = FALSE;
+ playback_client = 0; /* Don't really need this but it looks nice */
+}
+
+/*****************************************************************************
+ *
+ * PXTestCurrentClientGone
+ *
+ * This routine is called when a client that has asked for input actions
+ * to be sent to it "goes away". This routine must clean up the
+ * server state.
+ */
+/*ARGSUSED*/
+static int
+XTestCurrentClientGone(value, id)
+ pointer value;
+ XID id;
+{
+ /*
+ * defined in xtest1dd.c
+ */
+ on_steal_input = FALSE;
+ exclusive_steal = FALSE;
+ /*
+ * defined in xtestdd.c
+ */
+ playback_client = 0;
+ abort_play_back();
+ return TRUE;
+}
+
+/*****************************************************************************
+ *
+ * SReplyXTestDispatch
+ *
+ * Swap any replies defined in this extension.
+ */
+static void
+SReplyXTestDispatch(client_ptr, size, reply_ptr)
+ ClientPtr client_ptr;
+ int size;
+ char *reply_ptr;
+{
+ /*
+ * used in the swaps and swapl macros for temporary storage space
+ */
+ register char n;
+ /*
+ * pointer to xTestQueryInputSizeReply
+ */
+ xTestQueryInputSizeReply *rep_ptr;
+
+ /*
+ * there is only one reply in this extension, so byte-swap it
+ */
+ rep_ptr = (xTestQueryInputSizeReply *) reply_ptr;
+ swaps(&(rep_ptr->sequenceNumber), n);
+ swapl(&(rep_ptr->length), n);
+ swapl(&(rep_ptr->size_return), n);
+ /*
+ * now write the swapped reply to the client
+ */
+ WriteToClient(client_ptr, size, reply_ptr);
+}
+
+/*****************************************************************************
+ *
+ * SEventXTestDispatch
+ *
+ * Swap any events defined in this extension.
+ */
+static void
+SEventXTestDispatch(from, to)
+ xEvent *from;
+ xEvent *to;
+{
+ /*
+ * used in the swaps and swapl macros for temporary storage space
+ */
+ register char n;
+ /*
+ * index counter
+ */
+ int i;
+ /*
+ * pointer to the next input action in the event
+ */
+ CARD8 *input_action_ptr;
+ /*
+ * holds the type of the next input action in the event
+ */
+ int input_action_type;
+
+
+ /*
+ * copy the type information from the "from" event to the "to" event
+ */
+ ((xTestInputActionEvent *) to)->type =
+ ((xTestInputActionEvent *) from)->type;
+ /*
+ * copy the sequence number information from the "from" event to the
+ * "to" event
+ */
+ ((xTestInputActionEvent *) to)->sequenceNumber =
+ ((xTestInputActionEvent *) from)->sequenceNumber;
+ /*
+ * byte-swap the sequence number in the "to" event
+ */
+ swaps(&(((xTestInputActionEvent *) to)->sequenceNumber), n);
+ /*
+ * If the event is an xTestInputActionEvent, then it needs more
+ * processing. Otherwise, it is an xTestFakeAckEvent, which
+ * has no other information in it.
+ */
+ if ((((xTestInputActionEvent *) to)->type & 0x7f) ==
+ XTestInputActionType)
+ {
+ /*
+ * copy the input actions from the "from" event
+ * to the "to" event
+ */
+ for (i = 0; i < XTestACTIONS_SIZE; i++)
+ {
+ ((xTestInputActionEvent *) to)->actions[i] =
+ ((xTestInputActionEvent *) from)->actions[i];
+ }
+ /*
+ * byte-swap the input actions in the "to" event
+ */
+ for (i = 0; i < XTestACTIONS_SIZE; i++)
+ {
+ /*
+ * point to the next input action in the event
+ */
+ input_action_ptr = &(((xTestInputActionEvent *) to)->actions[i]);
+ /*
+ * figure out what type of input action it is
+ */
+ input_action_type = (*input_action_ptr) &
+ XTestACTION_TYPE_MASK;
+ /*
+ * byte-swap the input action according to it's type
+ */
+ switch (input_action_type)
+ {
+ case XTestKEY_ACTION:
+ /*
+ * byte-swap the delay_time field
+ */
+ swaps(&(((XTestKeyInfo *) input_action_ptr)->delay_time), n);
+ /*
+ * advance to the next input action
+ */
+ i += sizeof(XTestKeyInfo);
+ break;
+ case XTestMOTION_ACTION:
+ /*
+ * byte-swap the delay_time field
+ */
+ swaps(&(((XTestMotionInfo *) input_action_ptr)->delay_time), n);
+ /*
+ * advance to the next input action
+ */
+ i += sizeof(XTestMotionInfo);
+ break;
+ case XTestJUMP_ACTION:
+ /*
+ * byte-swap the jumpx field
+ */
+ swaps(&(((XTestJumpInfo *) input_action_ptr)->jumpx), n);
+ /*
+ * byte-swap the jumpy field
+ */
+ swaps(&(((XTestJumpInfo *) input_action_ptr)->jumpy), n);
+ /*
+ * byte-swap the delay_time field
+ */
+ swaps(&(((XTestJumpInfo *) input_action_ptr)->delay_time), n);
+ /*
+ * advance to the next input action
+ */
+ i += sizeof(XTestJumpInfo);
+ break;
+ default:
+ /*
+ * if this is a delay input action, then
+ * byte-swap it, otherwise we have reached the
+ * end of the input actions in this event
+ */
+ if (XTestUnpackDeviceID(*input_action_ptr) ==
+ XTestDELAY_DEVICE_ID)
+ {
+ /*
+ * byte-swap the delay_time field
+ */
+ swapl(&(((XTestDelayInfo *) input_action_ptr)->delay_time), n);
+ /*
+ * advance to the next input action
+ */
+ i += sizeof(XTestDelayInfo);
+ }
+ else
+ {
+ /*
+ * if the input action header byte is 0
+ * or ill-formed, then there are no
+ * more input actions in this event
+ */
+ i = XTestACTIONS_SIZE;
+ }
+ break;
+ }
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xext/xvdisp.c b/nx-X11/programs/Xserver/Xext/xvdisp.c
new file mode 100644
index 000000000..21ab0b6a0
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xvdisp.c
@@ -0,0 +1,2217 @@
+/* $XdotOrg: xc/programs/Xserver/Xext/xvdisp.c,v 1.6 2005/07/03 08:53:36 daniels Exp $ */
+/***********************************************************
+Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
+and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Digital or MIT not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/Xext/xvdisp.c,v 1.27 2003/07/16 01:38:31 dawes Exp $ */
+
+/*
+** File:
+**
+** xvdisp.c --- Xv server extension dispatch module.
+**
+** Author:
+**
+** David Carver (Digital Workstation Engineering/Project Athena)
+**
+** Revisions:
+**
+** 11.06.91 Carver
+** - changed SetPortControl to SetPortAttribute
+** - changed GetPortControl to GetPortAttribute
+** - changed QueryBestSize
+**
+** 15.05.91 Carver
+** - version 2.0 upgrade
+**
+** 24.01.91 Carver
+** - version 1.4 upgrade
+**
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "gcstruct.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "opaque.h"
+
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/Xvproto.h>
+#include "xvdix.h"
+#ifdef MITSHM
+#define _XSHM_SERVER_
+#include <X11/extensions/shmstr.h>
+#endif
+
+#ifdef EXTMODULE
+#include "xf86_ansic.h"
+#endif
+
+#include "xvdisp.h"
+
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+
+unsigned long XvXRTPort;
+
+#ifdef MITSHM
+static int XineramaXvShmPutImage(ClientPtr);
+#endif
+static int XineramaXvPutImage(ClientPtr);
+static int XineramaXvPutVideo(ClientPtr);
+static int XineramaXvPutStill(ClientPtr);
+static int XineramaXvSetPortAttribute(ClientPtr);
+static int XineramaXvStopVideo(ClientPtr);
+#endif
+
+/* INTERNAL */
+
+static int ProcXvQueryExtension(ClientPtr);
+static int ProcXvQueryAdaptors(ClientPtr);
+static int ProcXvQueryEncodings(ClientPtr);
+static int ProcXvPutVideo(ClientPtr);
+static int ProcXvPutStill(ClientPtr);
+static int ProcXvGetVideo(ClientPtr);
+static int ProcXvGetStill(ClientPtr);
+static int ProcXvGrabPort(ClientPtr);
+static int ProcXvUngrabPort(ClientPtr);
+static int ProcXvSelectVideoNotify(ClientPtr);
+static int ProcXvSelectPortNotify(ClientPtr);
+static int ProcXvStopVideo(ClientPtr);
+static int ProcXvSetPortAttribute(ClientPtr);
+static int ProcXvGetPortAttribute(ClientPtr);
+static int ProcXvQueryBestSize(ClientPtr);
+static int ProcXvQueryPortAttributes(ClientPtr);
+static int ProcXvPutImage(ClientPtr);
+#ifdef MITSHM
+static int ProcXvShmPutImage(ClientPtr);
+#endif
+static int ProcXvQueryImageAttributes(ClientPtr);
+static int ProcXvListImageFormats(ClientPtr);
+
+static int SProcXvQueryExtension(ClientPtr);
+static int SProcXvQueryAdaptors(ClientPtr);
+static int SProcXvQueryEncodings(ClientPtr);
+static int SProcXvPutVideo(ClientPtr);
+static int SProcXvPutStill(ClientPtr);
+static int SProcXvGetVideo(ClientPtr);
+static int SProcXvGetStill(ClientPtr);
+static int SProcXvGrabPort(ClientPtr);
+static int SProcXvUngrabPort(ClientPtr);
+static int SProcXvSelectVideoNotify(ClientPtr);
+static int SProcXvSelectPortNotify(ClientPtr);
+static int SProcXvStopVideo(ClientPtr);
+static int SProcXvSetPortAttribute(ClientPtr);
+static int SProcXvGetPortAttribute(ClientPtr);
+static int SProcXvQueryBestSize(ClientPtr);
+static int SProcXvQueryPortAttributes(ClientPtr);
+static int SProcXvPutImage(ClientPtr);
+#ifdef MITSHM
+static int SProcXvShmPutImage(ClientPtr);
+#endif
+static int SProcXvQueryImageAttributes(ClientPtr);
+static int SProcXvListImageFormats(ClientPtr);
+
+static int SWriteQueryAdaptorsReply(ClientPtr, xvQueryAdaptorsReply *);
+static int SWriteQueryExtensionReply(ClientPtr, xvQueryExtensionReply *);
+static int SWriteQueryEncodingsReply(ClientPtr, xvQueryEncodingsReply *);
+static int SWriteAdaptorInfo(ClientPtr, xvAdaptorInfo *);
+static int SWriteEncodingInfo(ClientPtr, xvEncodingInfo *);
+static int SWriteFormat(ClientPtr, xvFormat *);
+static int SWriteAttributeInfo(ClientPtr, xvAttributeInfo *);
+static int SWriteGrabPortReply(ClientPtr, xvGrabPortReply *);
+static int SWriteGetPortAttributeReply(ClientPtr, xvGetPortAttributeReply *);
+static int SWriteQueryBestSizeReply(ClientPtr, xvQueryBestSizeReply *);
+static int SWriteQueryPortAttributesReply(
+ ClientPtr, xvQueryPortAttributesReply *);
+static int SWriteQueryImageAttributesReply(
+ ClientPtr, xvQueryImageAttributesReply*);
+static int SWriteListImageFormatsReply(ClientPtr, xvListImageFormatsReply*);
+static int SWriteImageFormatInfo(ClientPtr, xvImageFormatInfo*);
+
+#define _WriteQueryAdaptorsReply(_c,_d) \
+ if ((_c)->swapped) SWriteQueryAdaptorsReply(_c, _d); \
+ else WriteToClient(_c, sz_xvQueryAdaptorsReply, (char*)_d)
+
+#define _WriteQueryExtensionReply(_c,_d) \
+ if ((_c)->swapped) SWriteQueryExtensionReply(_c, _d); \
+ else WriteToClient(_c, sz_xvQueryExtensionReply, (char*)_d)
+
+#define _WriteQueryEncodingsReply(_c,_d) \
+ if ((_c)->swapped) SWriteQueryEncodingsReply(_c, _d); \
+ else WriteToClient(_c, sz_xvQueryEncodingsReply, (char*)_d)
+
+#define _WriteAdaptorInfo(_c,_d) \
+ if ((_c)->swapped) SWriteAdaptorInfo(_c, _d); \
+ else WriteToClient(_c, sz_xvAdaptorInfo, (char*)_d)
+
+#define _WriteAttributeInfo(_c,_d) \
+ if ((_c)->swapped) SWriteAttributeInfo(_c, _d); \
+ else WriteToClient(_c, sz_xvAttributeInfo, (char*)_d)
+
+#define _WriteEncodingInfo(_c,_d) \
+ if ((_c)->swapped) SWriteEncodingInfo(_c, _d); \
+ else WriteToClient(_c, sz_xvEncodingInfo, (char*)_d)
+
+#define _WriteFormat(_c,_d) \
+ if ((_c)->swapped) SWriteFormat(_c, _d); \
+ else WriteToClient(_c, sz_xvFormat, (char*)_d)
+
+#define _WriteGrabPortReply(_c,_d) \
+ if ((_c)->swapped) SWriteGrabPortReply(_c, _d); \
+ else WriteToClient(_c, sz_xvGrabPortReply, (char*)_d)
+
+#define _WriteGetPortAttributeReply(_c,_d) \
+ if ((_c)->swapped) SWriteGetPortAttributeReply(_c, _d); \
+ else WriteToClient(_c, sz_xvGetPortAttributeReply, (char*)_d)
+
+#define _WriteQueryBestSizeReply(_c,_d) \
+ if ((_c)->swapped) SWriteQueryBestSizeReply(_c, _d); \
+ else WriteToClient(_c, sz_xvQueryBestSizeReply,(char*) _d)
+
+#define _WriteQueryPortAttributesReply(_c,_d) \
+ if ((_c)->swapped) SWriteQueryPortAttributesReply(_c, _d); \
+ else WriteToClient(_c, sz_xvQueryPortAttributesReply,(char*) _d)
+
+#define _WriteQueryImageAttributesReply(_c,_d) \
+ if ((_c)->swapped) SWriteQueryImageAttributesReply(_c, _d); \
+ else WriteToClient(_c, sz_xvQueryImageAttributesReply,(char*) _d)
+
+#define _WriteListImageFormatsReply(_c,_d) \
+ if ((_c)->swapped) SWriteListImageFormatsReply(_c, _d); \
+ else WriteToClient(_c, sz_xvListImageFormatsReply,(char*) _d)
+
+#define _WriteImageFormatInfo(_c,_d) \
+ if ((_c)->swapped) SWriteImageFormatInfo(_c, _d); \
+ else WriteToClient(_c, sz_xvImageFormatInfo, (char*)_d)
+
+#define _AllocatePort(_i,_p) \
+ ((_p)->id != _i) ? (* (_p)->pAdaptor->ddAllocatePort)(_i,_p,&_p) : Success
+
+/*
+** ProcXvDispatch
+**
+**
+**
+*/
+
+int
+ProcXvDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+
+ UpdateCurrentTime();
+
+ switch (stuff->data)
+ {
+ case xv_QueryExtension: return(ProcXvQueryExtension(client));
+ case xv_QueryAdaptors: return(ProcXvQueryAdaptors(client));
+ case xv_QueryEncodings: return(ProcXvQueryEncodings(client));
+ case xv_PutVideo:
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ return(XineramaXvPutVideo(client));
+ else
+#endif
+ return(ProcXvPutVideo(client));
+ case xv_PutStill:
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ return(XineramaXvPutStill(client));
+ else
+#endif
+ return(ProcXvPutStill(client));
+ case xv_GetVideo: return(ProcXvGetVideo(client));
+ case xv_GetStill: return(ProcXvGetStill(client));
+ case xv_GrabPort: return(ProcXvGrabPort(client));
+ case xv_UngrabPort: return(ProcXvUngrabPort(client));
+ case xv_SelectVideoNotify: return(ProcXvSelectVideoNotify(client));
+ case xv_SelectPortNotify: return(ProcXvSelectPortNotify(client));
+ case xv_StopVideo:
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ return(XineramaXvStopVideo(client));
+ else
+#endif
+ return(ProcXvStopVideo(client));
+ case xv_SetPortAttribute:
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ return(XineramaXvSetPortAttribute(client));
+ else
+#endif
+ return(ProcXvSetPortAttribute(client));
+ case xv_GetPortAttribute: return(ProcXvGetPortAttribute(client));
+ case xv_QueryBestSize: return(ProcXvQueryBestSize(client));
+ case xv_QueryPortAttributes: return(ProcXvQueryPortAttributes(client));
+ case xv_PutImage:
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ return(XineramaXvPutImage(client));
+ else
+#endif
+ return(ProcXvPutImage(client));
+#ifdef MITSHM
+ case xv_ShmPutImage:
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ return(XineramaXvShmPutImage(client));
+ else
+#endif
+ return(ProcXvShmPutImage(client));
+#endif
+ case xv_QueryImageAttributes: return(ProcXvQueryImageAttributes(client));
+ case xv_ListImageFormats: return(ProcXvListImageFormats(client));
+ default:
+ if (stuff->data < xvNumRequests)
+ {
+ SendErrorToClient(client, XvReqCode, stuff->data, 0,
+ BadImplementation);
+ return(BadImplementation);
+ }
+ else
+ {
+ SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest);
+ return(BadRequest);
+ }
+ }
+}
+
+int
+SProcXvDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+
+ UpdateCurrentTime();
+
+ switch (stuff->data)
+ {
+ case xv_QueryExtension: return(SProcXvQueryExtension(client));
+ case xv_QueryAdaptors: return(SProcXvQueryAdaptors(client));
+ case xv_QueryEncodings: return(SProcXvQueryEncodings(client));
+ case xv_PutVideo: return(SProcXvPutVideo(client));
+ case xv_PutStill: return(SProcXvPutStill(client));
+ case xv_GetVideo: return(SProcXvGetVideo(client));
+ case xv_GetStill: return(SProcXvGetStill(client));
+ case xv_GrabPort: return(SProcXvGrabPort(client));
+ case xv_UngrabPort: return(SProcXvUngrabPort(client));
+ case xv_SelectVideoNotify: return(SProcXvSelectVideoNotify(client));
+ case xv_SelectPortNotify: return(SProcXvSelectPortNotify(client));
+ case xv_StopVideo: return(SProcXvStopVideo(client));
+ case xv_SetPortAttribute: return(SProcXvSetPortAttribute(client));
+ case xv_GetPortAttribute: return(SProcXvGetPortAttribute(client));
+ case xv_QueryBestSize: return(SProcXvQueryBestSize(client));
+ case xv_QueryPortAttributes: return(SProcXvQueryPortAttributes(client));
+ case xv_PutImage: return(SProcXvPutImage(client));
+#ifdef MITSHM
+ case xv_ShmPutImage: return(SProcXvShmPutImage(client));
+#endif
+ case xv_QueryImageAttributes: return(SProcXvQueryImageAttributes(client));
+ case xv_ListImageFormats: return(SProcXvListImageFormats(client));
+ default:
+ if (stuff->data < xvNumRequests)
+ {
+ SendErrorToClient(client, XvReqCode, stuff->data, 0,
+ BadImplementation);
+ return(BadImplementation);
+ }
+ else
+ {
+ SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest);
+ return(BadRequest);
+ }
+ }
+}
+
+static int
+ProcXvQueryExtension(ClientPtr client)
+{
+ xvQueryExtensionReply rep;
+ /* REQUEST(xvQueryExtensionReq); */
+ REQUEST_SIZE_MATCH(xvQueryExtensionReq);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.version = XvVersion;
+ rep.revision = XvRevision;
+
+ _WriteQueryExtensionReply(client, &rep);
+
+ return Success;
+
+}
+
+static int
+ProcXvQueryAdaptors(ClientPtr client)
+{
+ xvFormat format;
+ xvAdaptorInfo ainfo;
+ xvQueryAdaptorsReply rep;
+ int totalSize;
+ int na;
+ XvAdaptorPtr pa;
+ int nf;
+ XvFormatPtr pf;
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ XvScreenPtr pxvs;
+
+ REQUEST(xvQueryAdaptorsReq);
+ REQUEST_SIZE_MATCH(xvQueryAdaptorsReq);
+
+ if(!(pWin = (WindowPtr)LookupWindow(stuff->window, client) ))
+ {
+ client->errorValue = stuff->window;
+ return (BadWindow);
+ }
+
+ pScreen = pWin->drawable.pScreen;
+ pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
+
+ if (!pxvs)
+ {
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.num_adaptors = 0;
+ rep.length = 0;
+
+ _WriteQueryAdaptorsReply(client, &rep);
+
+ return Success;
+ }
+
+ (* pxvs->ddQueryAdaptors)(pScreen, &pxvs->pAdaptors, &pxvs->nAdaptors);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.num_adaptors = pxvs->nAdaptors;
+
+ /* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */
+
+ totalSize = pxvs->nAdaptors * sz_xvAdaptorInfo;
+
+ /* FOR EACH ADPATOR ADD UP THE BYTES FOR ENCODINGS AND FORMATS */
+
+ na = pxvs->nAdaptors;
+ pa = pxvs->pAdaptors;
+ while (na--)
+ {
+ totalSize += (strlen(pa->name) + 3) & ~3;
+ totalSize += pa->nFormats * sz_xvFormat;
+ pa++;
+ }
+
+ rep.length = totalSize >> 2;
+
+ _WriteQueryAdaptorsReply(client, &rep);
+
+ na = pxvs->nAdaptors;
+ pa = pxvs->pAdaptors;
+ while (na--)
+ {
+
+ ainfo.base_id = pa->base_id;
+ ainfo.num_ports = pa->nPorts;
+ ainfo.type = pa->type;
+ ainfo.name_size = strlen(pa->name);
+ ainfo.num_formats = pa->nFormats;
+
+ _WriteAdaptorInfo(client, &ainfo);
+
+ WriteToClient(client, ainfo.name_size, pa->name);
+
+ nf = pa->nFormats;
+ pf = pa->pFormats;
+ while (nf--)
+ {
+ format.depth = pf->depth;
+ format.visual = pf->visual;
+ _WriteFormat(client, &format);
+ pf++;
+ }
+
+ pa++;
+
+ }
+
+ return (client->noClientException);
+
+}
+
+static int
+ProcXvQueryEncodings(ClientPtr client)
+{
+ xvEncodingInfo einfo;
+ xvQueryEncodingsReply rep;
+ int totalSize;
+ XvPortPtr pPort;
+ int ne;
+ XvEncodingPtr pe;
+ int status;
+
+ REQUEST(xvQueryEncodingsReq);
+ REQUEST_SIZE_MATCH(xvQueryEncodingsReq);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ if ((status = _AllocatePort(stuff->port, pPort)) != Success)
+ {
+ client->errorValue = stuff->port;
+ return (status);
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.num_encodings = pPort->pAdaptor->nEncodings;
+
+ /* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */
+
+ ne = pPort->pAdaptor->nEncodings;
+ pe = pPort->pAdaptor->pEncodings;
+ totalSize = ne * sz_xvEncodingInfo;
+ while (ne--)
+ {
+ totalSize += (strlen(pe->name) + 3) & ~3;
+ pe++;
+ }
+
+ rep.length = totalSize >> 2;
+
+ _WriteQueryEncodingsReply(client, &rep);
+
+ ne = pPort->pAdaptor->nEncodings;
+ pe = pPort->pAdaptor->pEncodings;
+ while (ne--)
+ {
+ einfo.encoding = pe->id;
+ einfo.name_size = strlen(pe->name);
+ einfo.width = pe->width;
+ einfo.height = pe->height;
+ einfo.rate.numerator = pe->rate.numerator;
+ einfo.rate.denominator = pe->rate.denominator;
+ _WriteEncodingInfo(client, &einfo);
+ WriteToClient(client, einfo.name_size, pe->name);
+ pe++;
+ }
+
+ return (client->noClientException);
+
+}
+
+static int
+ProcXvPutVideo(ClientPtr client)
+{
+ register DrawablePtr pDraw;
+ XvPortPtr pPort;
+ register GCPtr pGC;
+ int status;
+
+ REQUEST(xvPutVideoReq);
+ REQUEST_SIZE_MATCH(xvPutVideoReq);
+
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ if ((status = _AllocatePort(stuff->port, pPort)) != Success)
+ {
+ client->errorValue = stuff->port;
+ return (status);
+ }
+
+ if (!(pPort->pAdaptor->type & XvInputMask) ||
+ !(pPort->pAdaptor->type & XvVideoMask))
+ {
+ client->errorValue = stuff->port;
+ return (BadMatch);
+ }
+
+ status = XVCALL(diMatchPort)(pPort, pDraw);
+ if (status != Success)
+ {
+ return status;
+ }
+
+ return XVCALL(diPutVideo)(client, pDraw, pPort, pGC,
+ stuff->vid_x, stuff->vid_y,
+ stuff->vid_w, stuff->vid_h,
+ stuff->drw_x, stuff->drw_y,
+ stuff->drw_w, stuff->drw_h);
+
+}
+
+static int
+ProcXvPutStill(ClientPtr client)
+{
+ register DrawablePtr pDraw;
+ XvPortPtr pPort;
+ register GCPtr pGC;
+ int status;
+
+ REQUEST(xvPutStillReq);
+ REQUEST_SIZE_MATCH(xvPutStillReq);
+
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ if ((status = _AllocatePort(stuff->port, pPort)) != Success)
+ {
+ client->errorValue = stuff->port;
+ return (status);
+ }
+
+ if (!(pPort->pAdaptor->type & XvInputMask) ||
+ !(pPort->pAdaptor->type & XvStillMask))
+ {
+ client->errorValue = stuff->port;
+ return (BadMatch);
+ }
+
+ status = XVCALL(diMatchPort)(pPort, pDraw);
+ if (status != Success)
+ {
+ return status;
+ }
+
+ return XVCALL(diPutStill)(client, pDraw, pPort, pGC,
+ stuff->vid_x, stuff->vid_y,
+ stuff->vid_w, stuff->vid_h,
+ stuff->drw_x, stuff->drw_y,
+ stuff->drw_w, stuff->drw_h);
+
+}
+
+
+static int
+ProcXvGetVideo(ClientPtr client)
+{
+ register DrawablePtr pDraw;
+ XvPortPtr pPort;
+ register GCPtr pGC;
+ int status;
+
+ REQUEST(xvGetVideoReq);
+ REQUEST_SIZE_MATCH(xvGetVideoReq);
+
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ if ((status = _AllocatePort(stuff->port, pPort)) != Success)
+ {
+ client->errorValue = stuff->port;
+ return (status);
+ }
+
+ if (!(pPort->pAdaptor->type & XvOutputMask) ||
+ !(pPort->pAdaptor->type & XvVideoMask))
+ {
+ client->errorValue = stuff->port;
+ return (BadMatch);
+ }
+
+ status = XVCALL(diMatchPort)(pPort, pDraw);
+ if (status != Success)
+ {
+ return status;
+ }
+
+ return XVCALL(diGetVideo)(client, pDraw, pPort, pGC,
+ stuff->vid_x, stuff->vid_y,
+ stuff->vid_w, stuff->vid_h,
+ stuff->drw_x, stuff->drw_y,
+ stuff->drw_w, stuff->drw_h);
+
+}
+
+
+static int
+ProcXvGetStill(ClientPtr client)
+{
+ register DrawablePtr pDraw;
+ XvPortPtr pPort;
+ register GCPtr pGC;
+ int status;
+
+ REQUEST(xvGetStillReq);
+ REQUEST_SIZE_MATCH(xvGetStillReq);
+
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ if ((status = _AllocatePort(stuff->port, pPort)) != Success)
+ {
+ client->errorValue = stuff->port;
+ return (status);
+ }
+
+ if (!(pPort->pAdaptor->type & XvOutputMask) ||
+ !(pPort->pAdaptor->type & XvStillMask))
+ {
+ client->errorValue = stuff->port;
+ return (BadMatch);
+ }
+
+ status = XVCALL(diMatchPort)(pPort, pDraw);
+ if (status != Success)
+ {
+ return status;
+ }
+
+ return XVCALL(diGetStill)(client, pDraw, pPort, pGC,
+ stuff->vid_x, stuff->vid_y,
+ stuff->vid_w, stuff->vid_h,
+ stuff->drw_x, stuff->drw_y,
+ stuff->drw_w, stuff->drw_h);
+
+}
+
+static int
+ProcXvSelectVideoNotify(ClientPtr client)
+{
+ register DrawablePtr pDraw;
+ REQUEST(xvSelectVideoNotifyReq);
+ REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq);
+
+ if(!(pDraw = (DrawablePtr)LOOKUP_DRAWABLE(stuff->drawable, client) ))
+ {
+ client->errorValue = stuff->drawable;
+ return (BadWindow);
+ }
+
+ return XVCALL(diSelectVideoNotify)(client, pDraw, stuff->onoff);
+
+}
+
+static int
+ProcXvSelectPortNotify(ClientPtr client)
+{
+ int status;
+ XvPortPtr pPort;
+ REQUEST(xvSelectPortNotifyReq);
+ REQUEST_SIZE_MATCH(xvSelectPortNotifyReq);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ if ((status = _AllocatePort(stuff->port, pPort)) != Success)
+ {
+ client->errorValue = stuff->port;
+ return (status);
+ }
+
+ return XVCALL(diSelectPortNotify)(client, pPort, stuff->onoff);
+
+}
+
+static int
+ProcXvGrabPort(ClientPtr client)
+{
+ int result, status;
+ XvPortPtr pPort;
+ xvGrabPortReply rep;
+ REQUEST(xvGrabPortReq);
+ REQUEST_SIZE_MATCH(xvGrabPortReq);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ if ((status = _AllocatePort(stuff->port, pPort)) != Success)
+ {
+ client->errorValue = stuff->port;
+ return (status);
+ }
+
+ status = XVCALL(diGrabPort)(client, pPort, stuff->time, &result);
+
+ if (status != Success)
+ {
+ return status;
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.result = result;
+
+ _WriteGrabPortReply(client, &rep);
+
+ return Success;
+
+}
+
+static int
+ProcXvUngrabPort(ClientPtr client)
+{
+ int status;
+ XvPortPtr pPort;
+ REQUEST(xvGrabPortReq);
+ REQUEST_SIZE_MATCH(xvGrabPortReq);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ if ((status = _AllocatePort(stuff->port, pPort)) != Success)
+ {
+ client->errorValue = stuff->port;
+ return (status);
+ }
+
+ return XVCALL(diUngrabPort)(client, pPort, stuff->time);
+
+}
+
+
+static int
+ProcXvStopVideo(ClientPtr client)
+{
+ int status;
+ register DrawablePtr pDraw;
+ XvPortPtr pPort;
+ REQUEST(xvStopVideoReq);
+ REQUEST_SIZE_MATCH(xvStopVideoReq);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ if ((status = _AllocatePort(stuff->port, pPort)) != Success)
+ {
+ client->errorValue = stuff->port;
+ return (status);
+ }
+
+ if(!(pDraw = LOOKUP_DRAWABLE(stuff->drawable, client) ))
+ {
+ client->errorValue = stuff->drawable;
+ return (BadDrawable);
+ }
+
+ return XVCALL(diStopVideo)(client, pPort, pDraw);
+
+}
+
+static int
+ProcXvSetPortAttribute(ClientPtr client)
+{
+ int status;
+ XvPortPtr pPort;
+ REQUEST(xvSetPortAttributeReq);
+ REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ if ((status = _AllocatePort(stuff->port, pPort)) != Success)
+ {
+ client->errorValue = stuff->port;
+ return (status);
+ }
+
+ if (!ValidAtom(stuff->attribute))
+ {
+ client->errorValue = stuff->attribute;
+ return(BadAtom);
+ }
+
+ status = XVCALL(diSetPortAttribute)(client, pPort,
+ stuff->attribute, stuff->value);
+
+ if (status == BadMatch)
+ client->errorValue = stuff->attribute;
+ else
+ client->errorValue = stuff->value;
+
+ return status;
+}
+
+static int
+ProcXvGetPortAttribute(ClientPtr client)
+{
+ INT32 value;
+ int status;
+ XvPortPtr pPort;
+ xvGetPortAttributeReply rep;
+ REQUEST(xvGetPortAttributeReq);
+ REQUEST_SIZE_MATCH(xvGetPortAttributeReq);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ if ((status = _AllocatePort(stuff->port, pPort)) != Success)
+ {
+ client->errorValue = stuff->port;
+ return (status);
+ }
+
+ if (!ValidAtom(stuff->attribute))
+ {
+ client->errorValue = stuff->attribute;
+ return(BadAtom);
+ }
+
+ status = XVCALL(diGetPortAttribute)(client, pPort, stuff->attribute, &value);
+ if (status != Success)
+ {
+ client->errorValue = stuff->attribute;
+ return status;
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.value = value;
+
+ _WriteGetPortAttributeReply(client, &rep);
+
+ return Success;
+}
+
+static int
+ProcXvQueryBestSize(ClientPtr client)
+{
+ int status;
+ unsigned int actual_width, actual_height;
+ XvPortPtr pPort;
+ xvQueryBestSizeReply rep;
+ REQUEST(xvQueryBestSizeReq);
+ REQUEST_SIZE_MATCH(xvQueryBestSizeReq);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ if ((status = _AllocatePort(stuff->port, pPort)) != Success)
+ {
+ client->errorValue = stuff->port;
+ return (status);
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+
+ (* pPort->pAdaptor->ddQueryBestSize)(client, pPort, stuff->motion,
+ stuff->vid_w, stuff->vid_h,
+ stuff->drw_w, stuff->drw_h,
+ &actual_width, &actual_height);
+
+ rep.actual_width = actual_width;
+ rep.actual_height = actual_height;
+
+ _WriteQueryBestSizeReply(client, &rep);
+
+ return Success;
+}
+
+
+static int
+ProcXvQueryPortAttributes(ClientPtr client)
+{
+ int status, size, i;
+ XvPortPtr pPort;
+ XvAttributePtr pAtt;
+ xvQueryPortAttributesReply rep;
+ xvAttributeInfo Info;
+ REQUEST(xvQueryPortAttributesReq);
+ REQUEST_SIZE_MATCH(xvQueryPortAttributesReq);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ if ((status = _AllocatePort(stuff->port, pPort)) != Success)
+ {
+ client->errorValue = stuff->port;
+ return (status);
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.num_attributes = pPort->pAdaptor->nAttributes;
+ rep.text_size = 0;
+
+ for(i = 0, pAtt = pPort->pAdaptor->pAttributes;
+ i < rep.num_attributes; i++, pAtt++)
+ {
+ rep.text_size += (strlen(pAtt->name) + 1 + 3) & ~3L;
+ }
+
+ rep.length = (rep.num_attributes * sz_xvAttributeInfo) + rep.text_size;
+ rep.length >>= 2;
+
+ _WriteQueryPortAttributesReply(client, &rep);
+
+ for(i = 0, pAtt = pPort->pAdaptor->pAttributes;
+ i < rep.num_attributes; i++, pAtt++)
+ {
+ size = strlen(pAtt->name) + 1; /* pass the NULL */
+ Info.flags = pAtt->flags;
+ Info.min = pAtt->min_value;
+ Info.max = pAtt->max_value;
+ Info.size = (size + 3) & ~3L;
+
+ _WriteAttributeInfo(client, &Info);
+
+ WriteToClient(client, size, pAtt->name);
+ }
+
+ return Success;
+}
+
+
+
+static int
+ProcXvPutImage(ClientPtr client)
+{
+ DrawablePtr pDraw;
+ XvPortPtr pPort;
+ XvImagePtr pImage = NULL;
+ GCPtr pGC;
+ int status, i, size;
+ CARD16 width, height;
+
+ REQUEST(xvPutImageReq);
+ REQUEST_AT_LEAST_SIZE(xvPutImageReq);
+
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ if ((status = _AllocatePort(stuff->port, pPort)) != Success)
+ {
+ client->errorValue = stuff->port;
+ return (status);
+ }
+
+ if (!(pPort->pAdaptor->type & XvImageMask) ||
+ !(pPort->pAdaptor->type & XvInputMask))
+ {
+ client->errorValue = stuff->port;
+ return (BadMatch);
+ }
+
+ status = XVCALL(diMatchPort)(pPort, pDraw);
+ if (status != Success)
+ {
+ return status;
+ }
+
+ for(i = 0; i < pPort->pAdaptor->nImages; i++) {
+ if(pPort->pAdaptor->pImages[i].id == stuff->id) {
+ pImage = &(pPort->pAdaptor->pImages[i]);
+ break;
+ }
+ }
+
+ if(!pImage)
+ return BadMatch;
+
+ width = stuff->width;
+ height = stuff->height;
+ size = (*pPort->pAdaptor->ddQueryImageAttributes)(client,
+ pPort, pImage, &width, &height, NULL, NULL);
+ size += sizeof(xvPutImageReq);
+ size = (size + 3) >> 2;
+
+ if((width < stuff->width) || (height < stuff->height))
+ return BadValue;
+
+ if(client->req_len < size)
+ return BadLength;
+
+ return XVCALL(diPutImage)(client, pDraw, pPort, pGC,
+ stuff->src_x, stuff->src_y,
+ stuff->src_w, stuff->src_h,
+ stuff->drw_x, stuff->drw_y,
+ stuff->drw_w, stuff->drw_h,
+ pImage, (unsigned char*)(&stuff[1]), FALSE,
+ stuff->width, stuff->height);
+}
+
+#ifdef MITSHM
+/* redefined here since it's not in any header file */
+typedef struct _ShmDesc {
+ struct _ShmDesc *next;
+ int shmid;
+ int refcnt;
+ char *addr;
+ Bool writable;
+ unsigned long size;
+} ShmDescRec, *ShmDescPtr;
+
+extern RESTYPE ShmSegType;
+extern int BadShmSegCode;
+extern int ShmCompletionCode;
+
+static int
+ProcXvShmPutImage(ClientPtr client)
+{
+ ShmDescPtr shmdesc;
+ DrawablePtr pDraw;
+ XvPortPtr pPort;
+ XvImagePtr pImage = NULL;
+ GCPtr pGC;
+ int status, size_needed, i;
+ CARD16 width, height;
+
+ REQUEST(xvShmPutImageReq);
+ REQUEST_SIZE_MATCH(xvShmPutImageReq);
+
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ if ((status = _AllocatePort(stuff->port, pPort)) != Success)
+ {
+ client->errorValue = stuff->port;
+ return (status);
+ }
+
+ if (!(pPort->pAdaptor->type & XvImageMask) ||
+ !(pPort->pAdaptor->type & XvInputMask))
+ {
+ client->errorValue = stuff->port;
+ return (BadMatch);
+ }
+
+ status = XVCALL(diMatchPort)(pPort, pDraw);
+ if (status != Success)
+ {
+ return status;
+ }
+
+ for(i = 0; i < pPort->pAdaptor->nImages; i++) {
+ if(pPort->pAdaptor->pImages[i].id == stuff->id) {
+ pImage = &(pPort->pAdaptor->pImages[i]);
+ break;
+ }
+ }
+
+ if(!pImage)
+ return BadMatch;
+
+ if(!(shmdesc = (ShmDescPtr)LookupIDByType(stuff->shmseg, ShmSegType)))
+ {
+ client->errorValue = stuff->shmseg;
+ return BadShmSegCode;
+ }
+
+ width = stuff->width;
+ height = stuff->height;
+ size_needed = (*pPort->pAdaptor->ddQueryImageAttributes)(client,
+ pPort, pImage, &width, &height, NULL, NULL);
+ if((size_needed + stuff->offset) > shmdesc->size)
+ return BadAccess;
+
+ if((width < stuff->width) || (height < stuff->height))
+ return BadValue;
+
+ status = XVCALL(diPutImage)(client, pDraw, pPort, pGC,
+ stuff->src_x, stuff->src_y,
+ stuff->src_w, stuff->src_h,
+ stuff->drw_x, stuff->drw_y,
+ stuff->drw_w, stuff->drw_h, pImage,
+ (unsigned char *)shmdesc->addr + stuff->offset,
+ stuff->send_event, stuff->width, stuff->height);
+
+ if((status == Success) && stuff->send_event) {
+ xShmCompletionEvent ev;
+
+ ev.type = ShmCompletionCode;
+ ev.drawable = stuff->drawable;
+ ev.sequenceNumber = client->sequence;
+ ev.minorEvent = xv_ShmPutImage;
+ ev.majorEvent = XvReqCode;
+ ev.shmseg = stuff->shmseg;
+ ev.offset = stuff->offset;
+ WriteEventsToClient(client, 1, (xEvent *) &ev);
+ }
+
+ return status;
+}
+#endif
+
+#ifdef XvMCExtension
+#include "xvmcext.h"
+#endif
+
+static int
+ProcXvQueryImageAttributes(ClientPtr client)
+{
+ xvQueryImageAttributesReply rep;
+ int size, num_planes, i;
+ CARD16 width, height;
+ XvImagePtr pImage = NULL;
+ XvPortPtr pPort;
+ int *offsets;
+ int *pitches;
+ REQUEST(xvQueryImageAttributesReq);
+
+ REQUEST_SIZE_MATCH(xvQueryImageAttributesReq);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ for(i = 0; i < pPort->pAdaptor->nImages; i++) {
+ if(pPort->pAdaptor->pImages[i].id == stuff->id) {
+ pImage = &(pPort->pAdaptor->pImages[i]);
+ break;
+ }
+ }
+
+#ifdef XvMCExtension
+ if(!pImage)
+ pImage = XvMCFindXvImage(pPort, stuff->id);
+#endif
+
+ if(!pImage)
+ return BadMatch;
+
+ num_planes = pImage->num_planes;
+
+ if(!(offsets = xalloc(num_planes << 3)))
+ return BadAlloc;
+ pitches = offsets + num_planes;
+
+ width = stuff->width;
+ height = stuff->height;
+
+ size = (*pPort->pAdaptor->ddQueryImageAttributes)(client, pPort, pImage,
+ &width, &height, offsets, pitches);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = num_planes << 1;
+ rep.num_planes = num_planes;
+ rep.width = width;
+ rep.height = height;
+ rep.data_size = size;
+
+ _WriteQueryImageAttributesReply(client, &rep);
+ if(client->swapped)
+ SwapLongs((CARD32*)offsets, rep.length);
+ WriteToClient(client, rep.length << 2, (char*)offsets);
+
+ xfree(offsets);
+
+ return Success;
+}
+
+static int
+ProcXvListImageFormats(ClientPtr client)
+{
+ XvPortPtr pPort;
+ XvImagePtr pImage;
+ int i;
+ xvListImageFormatsReply rep;
+ xvImageFormatInfo info;
+ REQUEST(xvListImageFormatsReq);
+
+ REQUEST_SIZE_MATCH(xvListImageFormatsReq);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
+ {
+ client->errorValue = stuff->port;
+ return (_XvBadPort);
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.num_formats = pPort->pAdaptor->nImages;
+ rep.length = rep.num_formats * sz_xvImageFormatInfo >> 2;
+
+ _WriteListImageFormatsReply(client, &rep);
+
+ pImage = pPort->pAdaptor->pImages;
+
+ for(i = 0; i < rep.num_formats; i++, pImage++) {
+ info.id = pImage->id;
+ info.type = pImage->type;
+ info.byte_order = pImage->byte_order;
+ memcpy(&info.guid, pImage->guid, 16);
+ info.bpp = pImage->bits_per_pixel;
+ info.num_planes = pImage->num_planes;
+ info.depth = pImage->depth;
+ info.red_mask = pImage->red_mask;
+ info.green_mask = pImage->green_mask;
+ info.blue_mask = pImage->blue_mask;
+ info.format = pImage->format;
+ info.y_sample_bits = pImage->y_sample_bits;
+ info.u_sample_bits = pImage->u_sample_bits;
+ info.v_sample_bits = pImage->v_sample_bits;
+ info.horz_y_period = pImage->horz_y_period;
+ info.horz_u_period = pImage->horz_u_period;
+ info.horz_v_period = pImage->horz_v_period;
+ info.vert_y_period = pImage->vert_y_period;
+ info.vert_u_period = pImage->vert_u_period;
+ info.vert_v_period = pImage->vert_v_period;
+ memcpy(&info.comp_order, pImage->component_order, 32);
+ info.scanline_order = pImage->scanline_order;
+ _WriteImageFormatInfo(client, &info);
+ }
+
+ return Success;
+}
+
+
+
+/* Swapped Procs */
+
+static int
+SProcXvQueryExtension(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvQueryExtensionReq);
+ swaps(&stuff->length, n);
+ return ProcXvQueryExtension(client);
+}
+
+static int
+SProcXvQueryAdaptors(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvQueryAdaptorsReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ return ProcXvQueryAdaptors(client);
+}
+
+static int
+SProcXvQueryEncodings(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvQueryEncodingsReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->port, n);
+ return ProcXvQueryEncodings(client);
+}
+
+static int
+SProcXvGrabPort(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvGrabPortReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->port, n);
+ swapl(&stuff->time, n);
+ return ProcXvGrabPort(client);
+}
+
+static int
+SProcXvUngrabPort(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvUngrabPortReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->port, n);
+ swapl(&stuff->time, n);
+ return ProcXvUngrabPort(client);
+}
+
+static int
+SProcXvPutVideo(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvPutVideoReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->port, n);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->vid_x, n);
+ swaps(&stuff->vid_y, n);
+ swaps(&stuff->vid_w, n);
+ swaps(&stuff->vid_h, n);
+ swaps(&stuff->drw_x, n);
+ swaps(&stuff->drw_y, n);
+ swaps(&stuff->drw_w, n);
+ swaps(&stuff->drw_h, n);
+ return ProcXvPutVideo(client);
+}
+
+static int
+SProcXvPutStill(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvPutStillReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->port, n);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->vid_x, n);
+ swaps(&stuff->vid_y, n);
+ swaps(&stuff->vid_w, n);
+ swaps(&stuff->vid_h, n);
+ swaps(&stuff->drw_x, n);
+ swaps(&stuff->drw_y, n);
+ swaps(&stuff->drw_w, n);
+ swaps(&stuff->drw_h, n);
+ return ProcXvPutStill(client);
+}
+
+static int
+SProcXvGetVideo(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvGetVideoReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->port, n);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->vid_x, n);
+ swaps(&stuff->vid_y, n);
+ swaps(&stuff->vid_w, n);
+ swaps(&stuff->vid_h, n);
+ swaps(&stuff->drw_x, n);
+ swaps(&stuff->drw_y, n);
+ swaps(&stuff->drw_w, n);
+ swaps(&stuff->drw_h, n);
+ return ProcXvGetVideo(client);
+}
+
+static int
+SProcXvGetStill(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvGetStillReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->port, n);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->vid_x, n);
+ swaps(&stuff->vid_y, n);
+ swaps(&stuff->vid_w, n);
+ swaps(&stuff->vid_h, n);
+ swaps(&stuff->drw_x, n);
+ swaps(&stuff->drw_y, n);
+ swaps(&stuff->drw_w, n);
+ swaps(&stuff->drw_h, n);
+ return ProcXvGetStill(client);
+}
+
+static int
+SProcXvPutImage(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvPutImageReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->port, n);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ swapl(&stuff->id, n);
+ swaps(&stuff->src_x, n);
+ swaps(&stuff->src_y, n);
+ swaps(&stuff->src_w, n);
+ swaps(&stuff->src_h, n);
+ swaps(&stuff->drw_x, n);
+ swaps(&stuff->drw_y, n);
+ swaps(&stuff->drw_w, n);
+ swaps(&stuff->drw_h, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ return ProcXvPutImage(client);
+}
+
+#ifdef MITSHM
+static int
+SProcXvShmPutImage(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvShmPutImageReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->port, n);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ swapl(&stuff->shmseg, n);
+ swapl(&stuff->id, n);
+ swaps(&stuff->src_x, n);
+ swaps(&stuff->src_y, n);
+ swaps(&stuff->src_w, n);
+ swaps(&stuff->src_h, n);
+ swaps(&stuff->drw_x, n);
+ swaps(&stuff->drw_y, n);
+ swaps(&stuff->drw_w, n);
+ swaps(&stuff->drw_h, n);
+ swaps(&stuff->offset, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ return ProcXvShmPutImage(client);
+}
+#endif
+
+
+static int
+SProcXvSelectVideoNotify(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvSelectVideoNotifyReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->drawable, n);
+ return ProcXvSelectVideoNotify(client);
+}
+
+static int
+SProcXvSelectPortNotify(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvSelectPortNotifyReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->port, n);
+ return ProcXvSelectPortNotify(client);
+}
+
+static int
+SProcXvStopVideo(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvStopVideoReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->port, n);
+ swapl(&stuff->drawable, n);
+ return ProcXvStopVideo(client);
+}
+
+static int
+SProcXvSetPortAttribute(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvSetPortAttributeReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->port, n);
+ swapl(&stuff->attribute, n);
+ return ProcXvSetPortAttribute(client);
+}
+
+static int
+SProcXvGetPortAttribute(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvGetPortAttributeReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->port, n);
+ swapl(&stuff->attribute, n);
+ return ProcXvGetPortAttribute(client);
+}
+
+static int
+SProcXvQueryBestSize(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvQueryBestSizeReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->port, n);
+ swaps(&stuff->vid_w, n);
+ swaps(&stuff->vid_h, n);
+ swaps(&stuff->drw_w, n);
+ swaps(&stuff->drw_h, n);
+ return ProcXvQueryBestSize(client);
+}
+
+static int
+SProcXvQueryPortAttributes(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvQueryPortAttributesReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->port, n);
+ return ProcXvQueryPortAttributes(client);
+}
+
+static int
+SProcXvQueryImageAttributes(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvQueryImageAttributesReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->id, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->width, n);
+ return ProcXvQueryImageAttributes(client);
+}
+
+static int
+SProcXvListImageFormats(ClientPtr client)
+{
+ register char n;
+ REQUEST(xvListImageFormatsReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->port, n);
+ return ProcXvListImageFormats(client);
+}
+
+
+static int
+SWriteQueryExtensionReply(
+ ClientPtr client,
+ xvQueryExtensionReply *rep
+){
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ swaps(&rep->version, n);
+ swaps(&rep->revision, n);
+
+ (void)WriteToClient(client, sz_xvQueryExtensionReply, (char *)&rep);
+
+ return Success;
+}
+
+static int
+SWriteQueryAdaptorsReply(
+ ClientPtr client,
+ xvQueryAdaptorsReply *rep
+){
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ swaps(&rep->num_adaptors, n);
+
+ (void)WriteToClient(client, sz_xvQueryAdaptorsReply, (char *)&rep);
+
+ return Success;
+}
+
+static int
+SWriteQueryEncodingsReply(
+ ClientPtr client,
+ xvQueryEncodingsReply *rep
+){
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ swaps(&rep->num_encodings, n);
+
+ (void)WriteToClient(client, sz_xvQueryEncodingsReply, (char *)&rep);
+
+ return Success;
+}
+
+static int
+SWriteAdaptorInfo(
+ ClientPtr client,
+ xvAdaptorInfo *pAdaptor
+){
+ register char n;
+
+ swapl(&pAdaptor->base_id, n);
+ swaps(&pAdaptor->name_size, n);
+ swaps(&pAdaptor->num_ports, n);
+ swaps(&pAdaptor->num_formats, n);
+
+ (void)WriteToClient(client, sz_xvAdaptorInfo, (char *)pAdaptor);
+
+ return Success;
+}
+
+static int
+SWriteEncodingInfo(
+ ClientPtr client,
+ xvEncodingInfo *pEncoding
+){
+ register char n;
+
+ swapl(&pEncoding->encoding, n);
+ swaps(&pEncoding->name_size, n);
+ swaps(&pEncoding->width, n);
+ swaps(&pEncoding->height, n);
+ swapl(&pEncoding->rate.numerator, n);
+ swapl(&pEncoding->rate.denominator, n);
+ (void)WriteToClient(client, sz_xvEncodingInfo, (char *)pEncoding);
+
+ return Success;
+}
+
+static int
+SWriteFormat(
+ ClientPtr client,
+ xvFormat *pFormat
+){
+ register char n;
+
+ swapl(&pFormat->visual, n);
+ (void)WriteToClient(client, sz_xvFormat, (char *)pFormat);
+
+ return Success;
+}
+
+static int
+SWriteAttributeInfo(
+ ClientPtr client,
+ xvAttributeInfo *pAtt
+){
+ register char n;
+
+ swapl(&pAtt->flags, n);
+ swapl(&pAtt->size, n);
+ swapl(&pAtt->min, n);
+ swapl(&pAtt->max, n);
+ (void)WriteToClient(client, sz_xvAttributeInfo, (char *)pAtt);
+
+ return Success;
+}
+
+static int
+SWriteImageFormatInfo(
+ ClientPtr client,
+ xvImageFormatInfo *pImage
+){
+ register char n;
+
+ swapl(&pImage->id, n);
+ swapl(&pImage->red_mask, n);
+ swapl(&pImage->green_mask, n);
+ swapl(&pImage->blue_mask, n);
+ swapl(&pImage->y_sample_bits, n);
+ swapl(&pImage->u_sample_bits, n);
+ swapl(&pImage->v_sample_bits, n);
+ swapl(&pImage->horz_y_period, n);
+ swapl(&pImage->horz_u_period, n);
+ swapl(&pImage->horz_v_period, n);
+ swapl(&pImage->vert_y_period, n);
+ swapl(&pImage->vert_u_period, n);
+ swapl(&pImage->vert_v_period, n);
+
+ (void)WriteToClient(client, sz_xvImageFormatInfo, (char *)pImage);
+
+ return Success;
+}
+
+
+
+static int
+SWriteGrabPortReply(
+ ClientPtr client,
+ xvGrabPortReply *rep
+){
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+
+ (void)WriteToClient(client, sz_xvGrabPortReply, (char *)&rep);
+
+ return Success;
+}
+
+static int
+SWriteGetPortAttributeReply(
+ ClientPtr client,
+ xvGetPortAttributeReply *rep
+){
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ swapl(&rep->value, n);
+
+ (void)WriteToClient(client, sz_xvGetPortAttributeReply, (char *)&rep);
+
+ return Success;
+}
+
+static int
+SWriteQueryBestSizeReply(
+ ClientPtr client,
+ xvQueryBestSizeReply *rep
+){
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ swaps(&rep->actual_width, n);
+ swaps(&rep->actual_height, n);
+
+ (void)WriteToClient(client, sz_xvQueryBestSizeReply, (char *)&rep);
+
+ return Success;
+}
+
+static int
+SWriteQueryPortAttributesReply(
+ ClientPtr client,
+ xvQueryPortAttributesReply *rep
+){
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ swapl(&rep->num_attributes, n);
+ swapl(&rep->text_size, n);
+
+ (void)WriteToClient(client, sz_xvQueryPortAttributesReply, (char *)&rep);
+
+ return Success;
+}
+
+static int
+SWriteQueryImageAttributesReply(
+ ClientPtr client,
+ xvQueryImageAttributesReply *rep
+){
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ swapl(&rep->num_planes, n);
+ swapl(&rep->data_size, n);
+ swaps(&rep->width, n);
+ swaps(&rep->height, n);
+
+ (void)WriteToClient(client, sz_xvQueryImageAttributesReply, (char *)&rep);
+
+ return Success;
+}
+
+
+static int
+SWriteListImageFormatsReply(
+ ClientPtr client,
+ xvListImageFormatsReply *rep
+){
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ swapl(&rep->num_formats, n);
+
+ (void)WriteToClient(client, sz_xvListImageFormatsReply, (char *)&rep);
+
+ return Success;
+}
+
+
+#ifdef PANORAMIX
+
+
+
+
+static int
+XineramaXvStopVideo(ClientPtr client)
+{
+ int result = Success, i;
+ PanoramiXRes *draw, *port;
+ REQUEST(xvStopVideoReq);
+ REQUEST_SIZE_MATCH(xvStopVideoReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->port, XvXRTPort, SecurityReadAccess)))
+ return _XvBadPort;
+
+ FOR_NSCREENS_BACKWARD(i) {
+ if(port->info[i].id) {
+ stuff->drawable = draw->info[i].id;
+ stuff->port = port->info[i].id;
+ result = ProcXvStopVideo(client);
+ }
+ }
+
+ return result;
+}
+
+static int
+XineramaXvSetPortAttribute(ClientPtr client)
+{
+ REQUEST(xvSetPortAttributeReq);
+ PanoramiXRes *port;
+ int result = Success, i;
+
+ REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
+
+ if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->port, XvXRTPort, SecurityReadAccess)))
+ return _XvBadPort;
+
+ FOR_NSCREENS_BACKWARD(i) {
+ if(port->info[i].id) {
+ stuff->port = port->info[i].id;
+ result = ProcXvSetPortAttribute(client);
+ }
+ }
+ return result;
+}
+
+
+#ifdef MITSHM
+static int
+XineramaXvShmPutImage(ClientPtr client)
+{
+ REQUEST(xvShmPutImageReq);
+ PanoramiXRes *draw, *gc, *port;
+ Bool send_event = stuff->send_event;
+ Bool isRoot;
+ int result = Success, i, x, y;
+
+ REQUEST_SIZE_MATCH(xvShmPutImageReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->port, XvXRTPort, SecurityReadAccess)))
+ return _XvBadPort;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ x = stuff->drw_x;
+ y = stuff->drw_y;
+
+ FOR_NSCREENS_BACKWARD(i) {
+ if(port->info[i].id) {
+ stuff->drawable = draw->info[i].id;
+ stuff->port = port->info[i].id;
+ stuff->gc = gc->info[i].id;
+ stuff->drw_x = x;
+ stuff->drw_y = y;
+ if(isRoot) {
+ stuff->drw_x -= panoramiXdataPtr[i].x;
+ stuff->drw_y -= panoramiXdataPtr[i].y;
+ }
+ stuff->send_event = (send_event && !i) ? 1 : 0;
+
+ result = ProcXvShmPutImage(client);
+ }
+ }
+ return result;
+}
+#endif
+
+static int
+XineramaXvPutImage(ClientPtr client)
+{
+ REQUEST(xvPutImageReq);
+ PanoramiXRes *draw, *gc, *port;
+ Bool isRoot;
+ int result = Success, i, x, y;
+
+ REQUEST_AT_LEAST_SIZE(xvPutImageReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->port, XvXRTPort, SecurityReadAccess)))
+ return _XvBadPort;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ x = stuff->drw_x;
+ y = stuff->drw_y;
+
+ FOR_NSCREENS_BACKWARD(i) {
+ if(port->info[i].id) {
+ stuff->drawable = draw->info[i].id;
+ stuff->port = port->info[i].id;
+ stuff->gc = gc->info[i].id;
+ stuff->drw_x = x;
+ stuff->drw_y = y;
+ if(isRoot) {
+ stuff->drw_x -= panoramiXdataPtr[i].x;
+ stuff->drw_y -= panoramiXdataPtr[i].y;
+ }
+
+ result = ProcXvPutImage(client);
+ }
+ }
+ return result;
+}
+
+static int
+XineramaXvPutVideo(ClientPtr client)
+{
+ REQUEST(xvPutImageReq);
+ PanoramiXRes *draw, *gc, *port;
+ Bool isRoot;
+ int result = Success, i, x, y;
+
+ REQUEST_AT_LEAST_SIZE(xvPutVideoReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->port, XvXRTPort, SecurityReadAccess)))
+ return _XvBadPort;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ x = stuff->drw_x;
+ y = stuff->drw_y;
+
+ FOR_NSCREENS_BACKWARD(i) {
+ if(port->info[i].id) {
+ stuff->drawable = draw->info[i].id;
+ stuff->port = port->info[i].id;
+ stuff->gc = gc->info[i].id;
+ stuff->drw_x = x;
+ stuff->drw_y = y;
+ if(isRoot) {
+ stuff->drw_x -= panoramiXdataPtr[i].x;
+ stuff->drw_y -= panoramiXdataPtr[i].y;
+ }
+
+ result = ProcXvPutVideo(client);
+ }
+ }
+ return result;
+}
+
+static int
+XineramaXvPutStill(ClientPtr client)
+{
+ REQUEST(xvPutImageReq);
+ PanoramiXRes *draw, *gc, *port;
+ Bool isRoot;
+ int result = Success, i, x, y;
+
+ REQUEST_AT_LEAST_SIZE(xvPutImageReq);
+
+ if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+
+ if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->gc, XRT_GC, SecurityReadAccess)))
+ return BadGC;
+
+ if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
+ client, stuff->port, XvXRTPort, SecurityReadAccess)))
+ return _XvBadPort;
+
+ isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+
+ x = stuff->drw_x;
+ y = stuff->drw_y;
+
+ FOR_NSCREENS_BACKWARD(i) {
+ if(port->info[i].id) {
+ stuff->drawable = draw->info[i].id;
+ stuff->port = port->info[i].id;
+ stuff->gc = gc->info[i].id;
+ stuff->drw_x = x;
+ stuff->drw_y = y;
+ if(isRoot) {
+ stuff->drw_x -= panoramiXdataPtr[i].x;
+ stuff->drw_y -= panoramiXdataPtr[i].y;
+ }
+
+ result = ProcXvPutStill(client);
+ }
+ }
+ return result;
+}
+
+
+void XineramifyXv(void)
+{
+ ScreenPtr pScreen, screen0 = screenInfo.screens[0];
+ XvScreenPtr xvsp0 = (XvScreenPtr)screen0->devPrivates[XvScreenIndex].ptr;
+ XvAdaptorPtr refAdapt, pAdapt;
+ XvAttributePtr pAttr;
+ XvScreenPtr xvsp;
+ Bool isOverlay, hasOverlay;
+ PanoramiXRes *port;
+ XvAdaptorPtr MatchingAdaptors[MAXSCREENS];
+ int i, j, k, l;
+
+ XvXRTPort = CreateNewResourceType(XineramaDeleteResource);
+
+ if(!xvsp0) return;
+
+ for(i = 0; i < xvsp0->nAdaptors; i++) {
+ refAdapt = xvsp0->pAdaptors + i;
+
+ bzero(MatchingAdaptors, sizeof(XvAdaptorPtr) * MAXSCREENS);
+
+ MatchingAdaptors[0] = refAdapt;
+
+ if(!(refAdapt->type & XvInputMask)) continue;
+
+ isOverlay = FALSE;
+ for(j = 0; j < refAdapt->nAttributes; j++) {
+ pAttr = refAdapt->pAttributes + j;
+ if(!strcmp(pAttr->name, "XV_COLORKEY")) {
+ isOverlay = TRUE;
+ break;
+ }
+ }
+
+ for(j = 1; j < PanoramiXNumScreens; j++) {
+ pScreen = screenInfo.screens[j];
+ xvsp = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
+
+ /* Do not try to go on if xv is not supported on this screen */
+ if (xvsp==NULL) continue ;
+
+ /* if the adaptor has the same name it's a perfect match */
+ for(k = 0; k < xvsp->nAdaptors; k++) {
+ pAdapt = xvsp->pAdaptors + k;
+ if(!strcmp(refAdapt->name, pAdapt->name)) {
+ MatchingAdaptors[j] = pAdapt;
+ break;
+ }
+ }
+ if(MatchingAdaptors[j]) continue; /* found it */
+
+ /* otherwise we only look for XvImage adaptors */
+ if(!(refAdapt->type & XvImageMask)) continue;
+ if(refAdapt->nImages <= 0) continue;
+
+ /* prefer overlay/overlay non-overlay/non-overlay pairing */
+ for(k = 0; k < xvsp->nAdaptors; k++) {
+ pAdapt = xvsp->pAdaptors + k;
+ if((pAdapt->type & XvImageMask) && (pAdapt->nImages > 0)) {
+ hasOverlay = FALSE;
+ for(l = 0; l < pAdapt->nAttributes; l++) {
+ if(!strcmp(pAdapt->name, "XV_COLORKEY")) {
+ hasOverlay = TRUE;
+ break;
+ }
+ }
+ if(isOverlay && hasOverlay) {
+ MatchingAdaptors[j] = pAdapt;
+ break;
+ }
+ else if(!isOverlay && !hasOverlay) {
+ MatchingAdaptors[j] = pAdapt;
+ break;
+ }
+ }
+ }
+
+ if(MatchingAdaptors[j]) continue; /* found it */
+
+ /* but we'll take any XvImage pairing if we can get it */
+
+ for(k = 0; k < xvsp->nAdaptors; k++) {
+ pAdapt = xvsp->pAdaptors + k;
+ if((pAdapt->type & XvImageMask) && (pAdapt->nImages > 0)) {
+ MatchingAdaptors[j] = pAdapt;
+ break;
+ }
+ }
+ }
+
+ /* now create a resource for each port */
+ for(j = 0; j < refAdapt->nPorts; j++) {
+ if(!(port = xalloc(sizeof(PanoramiXRes))))
+ break;
+ port->info[0].id = MatchingAdaptors[0]->base_id + j;
+ AddResource(port->info[0].id, XvXRTPort, port);
+
+ for(k = 1; k < PanoramiXNumScreens; k++) {
+ if(MatchingAdaptors[k] && (MatchingAdaptors[k]->nPorts > j))
+ port->info[k].id = MatchingAdaptors[k]->base_id + j;
+ else
+ port->info[k].id = 0;
+ }
+ }
+ }
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/Xext/xvdisp.h b/nx-X11/programs/Xserver/Xext/xvdisp.h
new file mode 100644
index 000000000..00af9858b
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xvdisp.h
@@ -0,0 +1,3 @@
+/* $XFree86$ */
+
+extern void XineramifyXv(void);
diff --git a/nx-X11/programs/Xserver/Xext/xvdix.h b/nx-X11/programs/Xserver/Xext/xvdix.h
new file mode 100644
index 000000000..99d918406
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xvdix.h
@@ -0,0 +1,291 @@
+/***********************************************************
+Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
+and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Digital or MIT not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/Xext/xvdix.h,v 1.7 2001/05/07 21:37:51 tsi Exp $ */
+
+#ifndef XVDIX_H
+#define XVDIX_H
+/*
+** File:
+**
+** xvdix.h --- Xv device independent header file
+**
+** Author:
+**
+** David Carver (Digital Workstation Engineering/Project Athena)
+**
+** Revisions:
+**
+** 29.08.91 Carver
+** - removed UnrealizeWindow wrapper unrealizing windows no longer
+** preempts video
+**
+** 11.06.91 Carver
+** - changed SetPortControl to SetPortAttribute
+** - changed GetPortControl to GetPortAttribute
+** - changed QueryBestSize
+**
+** 15.05.91 Carver
+** - version 2.0 upgrade
+**
+** 24.01.91 Carver
+** - version 1.4 upgrade
+**
+*/
+
+#include "scrnintstr.h"
+#include <X11/extensions/Xvproto.h>
+
+extern int XvScreenIndex;
+extern unsigned long XvExtensionGeneration;
+extern unsigned long XvScreenGeneration;
+extern unsigned long XvResourceGeneration;
+
+extern int XvReqCode;
+extern int XvEventBase;
+extern int XvErrorBase;
+
+extern unsigned long XvRTPort;
+extern unsigned long XvRTEncoding;
+extern unsigned long XvRTGrab;
+extern unsigned long XvRTVideoNotify;
+extern unsigned long XvRTVideoNotifyList;
+extern unsigned long XvRTPortNotify;
+
+typedef struct {
+ int numerator;
+ int denominator;
+} XvRationalRec, *XvRationalPtr;
+
+typedef struct {
+ char depth;
+ unsigned long visual;
+} XvFormatRec, *XvFormatPtr;
+
+typedef struct {
+ unsigned long id;
+ ClientPtr client;
+} XvGrabRec, *XvGrabPtr;
+
+typedef struct _XvVideoNotifyRec {
+ struct _XvVideoNotifyRec *next;
+ ClientPtr client;
+ unsigned long id;
+ unsigned long mask;
+} XvVideoNotifyRec, *XvVideoNotifyPtr;
+
+typedef struct _XvPortNotifyRec {
+ struct _XvPortNotifyRec *next;
+ ClientPtr client;
+ unsigned long id;
+} XvPortNotifyRec, *XvPortNotifyPtr;
+
+typedef struct {
+ int id;
+ ScreenPtr pScreen;
+ char *name;
+ unsigned short width, height;
+ XvRationalRec rate;
+} XvEncodingRec, *XvEncodingPtr;
+
+typedef struct _XvAttributeRec {
+ int flags;
+ int min_value;
+ int max_value;
+ char *name;
+} XvAttributeRec, *XvAttributePtr;
+
+typedef struct {
+ int id;
+ int type;
+ int byte_order;
+ char guid[16];
+ int bits_per_pixel;
+ int format;
+ int num_planes;
+
+ /* for RGB formats only */
+ int depth;
+ unsigned int red_mask;
+ unsigned int green_mask;
+ unsigned int blue_mask;
+
+ /* for YUV formats only */
+ unsigned int y_sample_bits;
+ unsigned int u_sample_bits;
+ unsigned int v_sample_bits;
+ unsigned int horz_y_period;
+ unsigned int horz_u_period;
+ unsigned int horz_v_period;
+ unsigned int vert_y_period;
+ unsigned int vert_u_period;
+ unsigned int vert_v_period;
+ char component_order[32];
+ int scanline_order;
+} XvImageRec, *XvImagePtr;
+
+typedef struct {
+ unsigned long base_id;
+ unsigned char type;
+ char *name;
+ int nEncodings;
+ XvEncodingPtr pEncodings;
+ int nFormats;
+ XvFormatPtr pFormats;
+ int nAttributes;
+ XvAttributePtr pAttributes;
+ int nImages;
+ XvImagePtr pImages;
+ int nPorts;
+ struct _XvPortRec *pPorts;
+ ScreenPtr pScreen;
+ int (* ddAllocatePort)(unsigned long, struct _XvPortRec*,
+ struct _XvPortRec**);
+ int (* ddFreePort)(struct _XvPortRec*);
+ int (* ddPutVideo)(ClientPtr, DrawablePtr,struct _XvPortRec*, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+ int (* ddPutStill)(ClientPtr, DrawablePtr,struct _XvPortRec*, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+ int (* ddGetVideo)(ClientPtr, DrawablePtr,struct _XvPortRec*, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+ int (* ddGetStill)(ClientPtr, DrawablePtr,struct _XvPortRec*, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+ int (* ddStopVideo)(ClientPtr, struct _XvPortRec*, DrawablePtr);
+ int (* ddSetPortAttribute)(ClientPtr, struct _XvPortRec*, Atom, INT32);
+ int (* ddGetPortAttribute)(ClientPtr, struct _XvPortRec*, Atom, INT32*);
+ int (* ddQueryBestSize)(ClientPtr, struct _XvPortRec*, CARD8,
+ CARD16, CARD16,CARD16, CARD16,
+ unsigned int*, unsigned int*);
+ int (* ddPutImage)(ClientPtr, DrawablePtr, struct _XvPortRec*, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16,
+ XvImagePtr, unsigned char*, Bool,
+ CARD16, CARD16);
+ int (* ddQueryImageAttributes)(ClientPtr, struct _XvPortRec*, XvImagePtr,
+ CARD16*, CARD16*, int*, int*);
+ DevUnion devPriv;
+} XvAdaptorRec, *XvAdaptorPtr;
+
+typedef struct _XvPortRec {
+ unsigned long id;
+ XvAdaptorPtr pAdaptor;
+ XvPortNotifyPtr pNotify;
+ DrawablePtr pDraw;
+ ClientPtr client;
+ XvGrabRec grab;
+ TimeStamp time;
+ DevUnion devPriv;
+} XvPortRec, *XvPortPtr;
+
+#define LOOKUP_PORT(_id, client)\
+ ((XvPortPtr)LookupIDByType(_id, XvRTPort))
+
+#define LOOKUP_ENCODING(_id, client)\
+ ((XvEncodingPtr)LookupIDByType(_id, XvRTEncoding))
+
+#define LOOKUP_VIDEONOTIFY_LIST(_id, client)\
+ ((XvVideoNotifyPtr)LookupIDByType(_id, XvRTVideoNotifyList))
+
+#define LOOKUP_PORTNOTIFY_LIST(_id, client)\
+ ((XvPortNotifyPtr)LookupIDByType(_id, XvRTPortNotifyList))
+
+typedef struct {
+ int version, revision;
+ int nAdaptors;
+ XvAdaptorPtr pAdaptors;
+ DestroyWindowProcPtr DestroyWindow;
+ DestroyPixmapProcPtr DestroyPixmap;
+ CloseScreenProcPtr CloseScreen;
+ Bool (* ddCloseScreen)(int, ScreenPtr);
+ int (* ddQueryAdaptors)(ScreenPtr, XvAdaptorPtr*, int*);
+ DevUnion devPriv;
+} XvScreenRec, *XvScreenPtr;
+
+#define SCREEN_PROLOGUE(pScreen, field)\
+ ((pScreen)->field = \
+ ((XvScreenPtr) \
+ (pScreen)->devPrivates[XvScreenIndex].ptr)->field)
+
+#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
+ ((pScreen)->field = wrapper)
+
+/* Errors */
+
+#define _XvBadPort (XvBadPort+XvErrorBase)
+#define _XvBadEncoding (XvBadEncoding+XvErrorBase)
+
+extern int ProcXvDispatch(ClientPtr);
+extern int SProcXvDispatch(ClientPtr);
+
+extern void XvExtensionInit(void);
+extern int XvScreenInit(ScreenPtr);
+extern int XvGetScreenIndex(void);
+extern unsigned long XvGetRTPort(void);
+extern int XvdiSendPortNotify(XvPortPtr, Atom, INT32);
+extern int XvdiVideoStopped(XvPortPtr, int);
+
+extern int XvdiPutVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+extern int XvdiPutStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+extern int XvdiGetVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+extern int XvdiGetStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+extern int XvdiPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16,
+ XvImagePtr, unsigned char*, Bool,
+ CARD16, CARD16);
+extern int XvdiSelectVideoNotify(ClientPtr, DrawablePtr, BOOL);
+extern int XvdiSelectPortNotify(ClientPtr, XvPortPtr, BOOL);
+extern int XvdiSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32);
+extern int XvdiGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32*);
+extern int XvdiStopVideo(ClientPtr, XvPortPtr, DrawablePtr);
+extern int XvdiPreemptVideo(ClientPtr, XvPortPtr, DrawablePtr);
+extern int XvdiMatchPort(XvPortPtr, DrawablePtr);
+extern int XvdiGrabPort(ClientPtr, XvPortPtr, Time, int *);
+extern int XvdiUngrabPort( ClientPtr, XvPortPtr, Time);
+
+
+#if !defined(UNIXCPP)
+
+#define XVCALL(name) Xv##name
+
+#else
+
+#define XVCALL(name) Xv/**/name
+
+#endif
+
+
+#endif /* XVDIX_H */
+
diff --git a/nx-X11/programs/Xserver/Xext/xvmain.c b/nx-X11/programs/Xserver/Xext/xvmain.c
new file mode 100644
index 000000000..8934f77f2
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xvmain.c
@@ -0,0 +1,1203 @@
+/* $XdotOrg: xc/programs/Xserver/Xext/xvmain.c,v 1.6 2005/07/03 08:53:36 daniels Exp $ */
+/***********************************************************
+Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
+and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Digital or MIT not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/Xext/xvmain.c,v 1.15tsi Exp $ */
+
+/*
+** File:
+**
+** xvmain.c --- Xv server extension main device independent module.
+**
+** Author:
+**
+** David Carver (Digital Workstation Engineering/Project Athena)
+**
+** Revisions:
+**
+** 04.09.91 Carver
+** - change: stop video always generates an event even when video
+** wasn't active
+**
+** 29.08.91 Carver
+** - change: unrealizing windows no longer preempts video
+**
+** 11.06.91 Carver
+** - changed SetPortControl to SetPortAttribute
+** - changed GetPortControl to GetPortAttribute
+** - changed QueryBestSize
+**
+** 28.05.91 Carver
+** - fixed Put and Get requests to not preempt operations to same drawable
+**
+** 15.05.91 Carver
+** - version 2.0 upgrade
+**
+** 19.03.91 Carver
+** - fixed Put and Get requests to honor grabbed ports.
+** - fixed Video requests to update di structure with new drawable, and
+** client after calling ddx.
+**
+** 24.01.91 Carver
+** - version 1.4 upgrade
+**
+** Notes:
+**
+** Port structures reference client structures in a two different
+** ways: when grabs, or video is active. Each reference is encoded
+** as fake client resources and thus when the client is goes away so
+** does the reference (it is zeroed). No other action is taken, so
+** video doesn't necessarily stop. It probably will as a result of
+** other resources going away, but if a client starts video using
+** none of its own resources, then the video will continue to play
+** after the client disappears.
+**
+**
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "gc.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "opaque.h"
+#include "input.h"
+
+#define GLOBAL
+
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/Xvproto.h>
+#include "xvdix.h"
+
+#ifdef EXTMODULE
+#include "xf86_ansic.h"
+#endif
+
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#include "xvdisp.h"
+#endif
+
+int XvScreenIndex = -1;
+unsigned long XvExtensionGeneration = 0;
+unsigned long XvScreenGeneration = 0;
+unsigned long XvResourceGeneration = 0;
+
+int XvReqCode;
+int XvEventBase;
+int XvErrorBase;
+
+unsigned long XvRTPort;
+unsigned long XvRTEncoding;
+unsigned long XvRTGrab;
+unsigned long XvRTVideoNotify;
+unsigned long XvRTVideoNotifyList;
+unsigned long XvRTPortNotify;
+
+
+
+/* EXTERNAL */
+
+extern XID clientErrorValue;
+
+static void WriteSwappedVideoNotifyEvent(xvEvent *, xvEvent *);
+static void WriteSwappedPortNotifyEvent(xvEvent *, xvEvent *);
+static Bool CreateResourceTypes(void);
+
+static Bool XvCloseScreen(int, ScreenPtr);
+static Bool XvDestroyPixmap(PixmapPtr);
+static Bool XvDestroyWindow(WindowPtr);
+static void XvResetProc(ExtensionEntry*);
+static int XvdiDestroyGrab(pointer, XID);
+static int XvdiDestroyEncoding(pointer, XID);
+static int XvdiDestroyVideoNotify(pointer, XID);
+static int XvdiDestroyPortNotify(pointer, XID);
+static int XvdiDestroyVideoNotifyList(pointer, XID);
+static int XvdiDestroyPort(pointer, XID);
+static int XvdiSendVideoNotify(XvPortPtr, DrawablePtr, int);
+
+
+
+
+/*
+** XvExtensionInit
+**
+**
+*/
+
+void
+XvExtensionInit()
+{
+ ExtensionEntry *extEntry;
+
+ /* LOOK TO SEE IF ANY SCREENS WERE INITIALIZED; IF NOT THEN
+ INIT GLOBAL VARIABLES SO THE EXTENSION CAN FUNCTION */
+ if (XvScreenGeneration != serverGeneration)
+ {
+ if (!CreateResourceTypes())
+ {
+ ErrorF("XvExtensionInit: Unable to allocate resource types\n");
+ return;
+ }
+ XvScreenIndex = AllocateScreenPrivateIndex ();
+ if (XvScreenIndex < 0)
+ {
+ ErrorF("XvExtensionInit: Unable to allocate screen private index\n");
+ return;
+ }
+#ifdef PANORAMIX
+ XineramaRegisterConnectionBlockCallback(XineramifyXv);
+#endif
+ XvScreenGeneration = serverGeneration;
+ }
+
+ if (XvExtensionGeneration != serverGeneration)
+ {
+ XvExtensionGeneration = serverGeneration;
+
+ extEntry = AddExtension(XvName, XvNumEvents, XvNumErrors,
+ ProcXvDispatch, SProcXvDispatch,
+ XvResetProc, StandardMinorOpcode);
+ if (!extEntry)
+ {
+ FatalError("XvExtensionInit: AddExtensions failed\n");
+ }
+
+ XvReqCode = extEntry->base;
+ XvEventBase = extEntry->eventBase;
+ XvErrorBase = extEntry->errorBase;
+
+ EventSwapVector[XvEventBase+XvVideoNotify] =
+ (EventSwapPtr)WriteSwappedVideoNotifyEvent;
+ EventSwapVector[XvEventBase+XvPortNotify] =
+ (EventSwapPtr)WriteSwappedPortNotifyEvent;
+
+ (void)MakeAtom(XvName, strlen(XvName), xTrue);
+
+ }
+}
+
+static Bool
+CreateResourceTypes()
+
+{
+
+ if (XvResourceGeneration == serverGeneration) return TRUE;
+
+ XvResourceGeneration = serverGeneration;
+
+ if (!(XvRTPort = CreateNewResourceType(XvdiDestroyPort)))
+ {
+ ErrorF("CreateResourceTypes: failed to allocate port resource.\n");
+ return FALSE;
+ }
+
+ if (!(XvRTGrab = CreateNewResourceType(XvdiDestroyGrab)))
+ {
+ ErrorF("CreateResourceTypes: failed to allocate grab resource.\n");
+ return FALSE;
+ }
+
+ if (!(XvRTEncoding = CreateNewResourceType(XvdiDestroyEncoding)))
+ {
+ ErrorF("CreateResourceTypes: failed to allocate encoding resource.\n");
+ return FALSE;
+ }
+
+ if (!(XvRTVideoNotify = CreateNewResourceType(XvdiDestroyVideoNotify)))
+ {
+ ErrorF("CreateResourceTypes: failed to allocate video notify resource.\n");
+ return FALSE;
+ }
+
+ if (!(XvRTVideoNotifyList = CreateNewResourceType(XvdiDestroyVideoNotifyList)))
+ {
+ ErrorF("CreateResourceTypes: failed to allocate video notify list resource.\n");
+ return FALSE;
+ }
+
+ if (!(XvRTPortNotify = CreateNewResourceType(XvdiDestroyPortNotify)))
+ {
+ ErrorF("CreateResourceTypes: failed to allocate port notify resource.\n");
+ return FALSE;
+ }
+
+ return TRUE;
+
+}
+
+int
+XvScreenInit(ScreenPtr pScreen)
+{
+ XvScreenPtr pxvs;
+
+ if (XvScreenGeneration != serverGeneration)
+ {
+ if (!CreateResourceTypes())
+ {
+ ErrorF("XvScreenInit: Unable to allocate resource types\n");
+ return BadAlloc;
+ }
+ XvScreenIndex = AllocateScreenPrivateIndex ();
+ if (XvScreenIndex < 0)
+ {
+ ErrorF("XvScreenInit: Unable to allocate screen private index\n");
+ return BadAlloc;
+ }
+#ifdef PANORAMIX
+ XineramaRegisterConnectionBlockCallback(XineramifyXv);
+#endif
+ XvScreenGeneration = serverGeneration;
+ }
+
+ if (pScreen->devPrivates[XvScreenIndex].ptr)
+ {
+ ErrorF("XvScreenInit: screen devPrivates ptr non-NULL before init\n");
+ }
+
+ /* ALLOCATE SCREEN PRIVATE RECORD */
+
+ pxvs = (XvScreenPtr) xalloc (sizeof (XvScreenRec));
+ if (!pxvs)
+ {
+ ErrorF("XvScreenInit: Unable to allocate screen private structure\n");
+ return BadAlloc;
+ }
+
+ pScreen->devPrivates[XvScreenIndex].ptr = (pointer)pxvs;
+
+
+ pxvs->DestroyPixmap = pScreen->DestroyPixmap;
+ pxvs->DestroyWindow = pScreen->DestroyWindow;
+ pxvs->CloseScreen = pScreen->CloseScreen;
+
+ pScreen->DestroyPixmap = XvDestroyPixmap;
+ pScreen->DestroyWindow = XvDestroyWindow;
+ pScreen->CloseScreen = XvCloseScreen;
+
+ return Success;
+}
+
+static Bool
+XvCloseScreen(
+ int ii,
+ ScreenPtr pScreen
+){
+
+ XvScreenPtr pxvs;
+
+ pxvs = (XvScreenPtr) pScreen->devPrivates[XvScreenIndex].ptr;
+
+ pScreen->DestroyPixmap = pxvs->DestroyPixmap;
+ pScreen->DestroyWindow = pxvs->DestroyWindow;
+ pScreen->CloseScreen = pxvs->CloseScreen;
+
+ (* pxvs->ddCloseScreen)(ii, pScreen);
+
+ xfree(pxvs);
+
+ pScreen->devPrivates[XvScreenIndex].ptr = (pointer)NULL;
+
+ return (*pScreen->CloseScreen)(ii, pScreen);
+
+}
+
+static void
+XvResetProc(ExtensionEntry* extEntry)
+{
+}
+
+int
+XvGetScreenIndex()
+{
+ return XvScreenIndex;
+}
+
+unsigned long
+XvGetRTPort()
+{
+ return XvRTPort;
+}
+
+static Bool
+XvDestroyPixmap(PixmapPtr pPix)
+{
+ Bool status;
+ ScreenPtr pScreen;
+ XvScreenPtr pxvs;
+ XvAdaptorPtr pa;
+ int na;
+ XvPortPtr pp;
+ int np;
+
+ pScreen = pPix->drawable.pScreen;
+
+ SCREEN_PROLOGUE(pScreen, DestroyPixmap);
+
+ pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
+
+ /* CHECK TO SEE IF THIS PORT IS IN USE */
+
+ pa = pxvs->pAdaptors;
+ na = pxvs->nAdaptors;
+ while (na--)
+ {
+ np = pa->nPorts;
+ pp = pa->pPorts;
+
+ while (np--)
+ {
+ if (pp->pDraw == (DrawablePtr)pPix)
+ {
+ XvdiSendVideoNotify(pp, pp->pDraw, XvPreempted);
+
+ (void)(* pp->pAdaptor->ddStopVideo)((ClientPtr)NULL, pp,
+ pp->pDraw);
+
+ pp->pDraw = (DrawablePtr)NULL;
+ pp->client = (ClientPtr)NULL;
+ pp->time = currentTime;
+ }
+ pp++;
+ }
+ pa++;
+ }
+
+ status = (* pScreen->DestroyPixmap)(pPix);
+
+ SCREEN_EPILOGUE(pScreen, DestroyPixmap, XvDestroyPixmap);
+
+ return status;
+
+}
+
+static Bool
+XvDestroyWindow(WindowPtr pWin)
+{
+ Bool status;
+ ScreenPtr pScreen;
+ XvScreenPtr pxvs;
+ XvAdaptorPtr pa;
+ int na;
+ XvPortPtr pp;
+ int np;
+
+ pScreen = pWin->drawable.pScreen;
+
+ SCREEN_PROLOGUE(pScreen, DestroyWindow);
+
+ pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
+
+ /* CHECK TO SEE IF THIS PORT IS IN USE */
+
+ pa = pxvs->pAdaptors;
+ na = pxvs->nAdaptors;
+ while (na--)
+ {
+ np = pa->nPorts;
+ pp = pa->pPorts;
+
+ while (np--)
+ {
+ if (pp->pDraw == (DrawablePtr)pWin)
+ {
+ XvdiSendVideoNotify(pp, pp->pDraw, XvPreempted);
+
+ (void)(* pp->pAdaptor->ddStopVideo)((ClientPtr)NULL, pp,
+ pp->pDraw);
+
+ pp->pDraw = (DrawablePtr)NULL;
+ pp->client = (ClientPtr)NULL;
+ pp->time = currentTime;
+ }
+ pp++;
+ }
+ pa++;
+ }
+
+
+ status = (* pScreen->DestroyWindow)(pWin);
+
+ SCREEN_EPILOGUE(pScreen, DestroyWindow, XvDestroyWindow);
+
+ return status;
+
+}
+
+/* The XvdiVideoStopped procedure is a hook for the device dependent layer.
+ It provides a way for the dd layer to inform the di layer that video has
+ stopped in a port for reasons that the di layer had no control over; note
+ that it doesn't call back into the dd layer */
+
+int
+XvdiVideoStopped(XvPortPtr pPort, int reason)
+{
+
+ /* IF PORT ISN'T ACTIVE THEN WE'RE DONE */
+
+ if (!pPort->pDraw) return Success;
+
+ XvdiSendVideoNotify(pPort, pPort->pDraw, reason);
+
+ pPort->pDraw = (DrawablePtr)NULL;
+ pPort->client = (ClientPtr)NULL;
+ pPort->time = currentTime;
+
+ return Success;
+
+}
+
+static int
+XvdiDestroyPort(pointer pPort, XID id)
+{
+ return (* ((XvPortPtr)pPort)->pAdaptor->ddFreePort)(pPort);
+}
+
+static int
+XvdiDestroyGrab(pointer pGrab, XID id)
+{
+ ((XvGrabPtr)pGrab)->client = (ClientPtr)NULL;
+ return Success;
+}
+
+static int
+XvdiDestroyVideoNotify(pointer pn, XID id)
+{
+ /* JUST CLEAR OUT THE client POINTER FIELD */
+
+ ((XvVideoNotifyPtr)pn)->client = (ClientPtr)NULL;
+ return Success;
+}
+
+static int
+XvdiDestroyPortNotify(pointer pn, XID id)
+{
+ /* JUST CLEAR OUT THE client POINTER FIELD */
+
+ ((XvPortNotifyPtr)pn)->client = (ClientPtr)NULL;
+ return Success;
+}
+
+static int
+XvdiDestroyVideoNotifyList(pointer pn, XID id)
+{
+ XvVideoNotifyPtr npn,cpn;
+
+ /* ACTUALLY DESTROY THE NOTITY LIST */
+
+ cpn = (XvVideoNotifyPtr)pn;
+
+ while (cpn)
+ {
+ npn = cpn->next;
+ if (cpn->client) FreeResource(cpn->id, XvRTVideoNotify);
+ xfree(cpn);
+ cpn = npn;
+ }
+ return Success;
+}
+
+static int
+XvdiDestroyEncoding(pointer value, XID id)
+{
+ return Success;
+}
+
+static int
+XvdiSendVideoNotify(pPort, pDraw, reason)
+
+XvPortPtr pPort;
+DrawablePtr pDraw;
+int reason;
+
+{
+ xvEvent event;
+ XvVideoNotifyPtr pn;
+
+ pn = (XvVideoNotifyPtr)LookupIDByType(pDraw->id, XvRTVideoNotifyList);
+
+ while (pn)
+ {
+ if (pn->client)
+ {
+ event.u.u.type = XvEventBase + XvVideoNotify;
+ event.u.u.sequenceNumber = pn->client->sequence;
+ event.u.videoNotify.time = currentTime.milliseconds;
+ event.u.videoNotify.drawable = pDraw->id;
+ event.u.videoNotify.port = pPort->id;
+ event.u.videoNotify.reason = reason;
+ (void) TryClientEvents(pn->client, (xEventPtr)&event, 1, NoEventMask,
+ NoEventMask, NullGrab);
+ }
+ pn = pn->next;
+ }
+
+ return Success;
+
+}
+
+
+int
+XvdiSendPortNotify(
+ XvPortPtr pPort,
+ Atom attribute,
+ INT32 value
+){
+ xvEvent event;
+ XvPortNotifyPtr pn;
+
+ pn = pPort->pNotify;
+
+ while (pn)
+ {
+ if (pn->client)
+ {
+ event.u.u.type = XvEventBase + XvPortNotify;
+ event.u.u.sequenceNumber = pn->client->sequence;
+ event.u.portNotify.time = currentTime.milliseconds;
+ event.u.portNotify.port = pPort->id;
+ event.u.portNotify.attribute = attribute;
+ event.u.portNotify.value = value;
+ (void) TryClientEvents(pn->client, (xEventPtr)&event, 1, NoEventMask,
+ NoEventMask, NullGrab);
+ }
+ pn = pn->next;
+ }
+
+ return Success;
+
+}
+
+
+#define CHECK_SIZE(dw, dh, sw, sh) { \
+ if(!dw || !dh || !sw || !sh) return Success; \
+ /* The region code will break these if they are too large */ \
+ if((dw > 32767) || (dh > 32767) || (sw > 32767) || (sh > 32767)) \
+ return BadValue; \
+}
+
+
+int
+XvdiPutVideo(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h
+){
+ DrawablePtr pOldDraw;
+
+ CHECK_SIZE(drw_w, drw_h, vid_w, vid_h);
+
+ /* UPDATE TIME VARIABLES FOR USE IN EVENTS */
+
+ UpdateCurrentTime();
+
+ /* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
+ INFORM CLIENT OF ITS FAILURE */
+
+ if (pPort->grab.client && (pPort->grab.client != client))
+ {
+ XvdiSendVideoNotify(pPort, pDraw, XvBusy);
+ return Success;
+ }
+
+ /* CHECK TO SEE IF PORT IS IN USE; IF SO THEN WE MUST DELIVER INTERRUPTED
+ EVENTS TO ANY CLIENTS WHO WANT THEM */
+
+ pOldDraw = pPort->pDraw;
+ if ((pOldDraw) && (pOldDraw != pDraw))
+ {
+ XvdiSendVideoNotify(pPort, pPort->pDraw, XvPreempted);
+ }
+
+ (void) (* pPort->pAdaptor->ddPutVideo)(client, pDraw, pPort, pGC,
+ vid_x, vid_y, vid_w, vid_h,
+ drw_x, drw_y, drw_w, drw_h);
+
+ if ((pPort->pDraw) && (pOldDraw != pDraw))
+ {
+ pPort->client = client;
+ XvdiSendVideoNotify(pPort, pPort->pDraw, XvStarted);
+ }
+
+ pPort->time = currentTime;
+
+ return (Success);
+
+}
+
+int
+XvdiPutStill(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h
+){
+ int status;
+
+ CHECK_SIZE(drw_w, drw_h, vid_w, vid_h);
+
+ /* UPDATE TIME VARIABLES FOR USE IN EVENTS */
+
+ UpdateCurrentTime();
+
+ /* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
+ INFORM CLIENT OF ITS FAILURE */
+
+ if (pPort->grab.client && (pPort->grab.client != client))
+ {
+ XvdiSendVideoNotify(pPort, pDraw, XvBusy);
+ return Success;
+ }
+
+ pPort->time = currentTime;
+
+ status = (* pPort->pAdaptor->ddPutStill)(client, pDraw, pPort, pGC,
+ vid_x, vid_y, vid_w, vid_h,
+ drw_x, drw_y, drw_w, drw_h);
+
+ return status;
+
+}
+
+int
+XvdiPutImage(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 src_x, INT16 src_y,
+ CARD16 src_w, CARD16 src_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h,
+ XvImagePtr image,
+ unsigned char* data,
+ Bool sync,
+ CARD16 width, CARD16 height
+){
+ CHECK_SIZE(drw_w, drw_h, src_w, src_h);
+
+ /* UPDATE TIME VARIABLES FOR USE IN EVENTS */
+
+ UpdateCurrentTime();
+
+ /* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
+ INFORM CLIENT OF ITS FAILURE */
+
+ if (pPort->grab.client && (pPort->grab.client != client))
+ {
+ XvdiSendVideoNotify(pPort, pDraw, XvBusy);
+ return Success;
+ }
+
+ pPort->time = currentTime;
+
+ return (* pPort->pAdaptor->ddPutImage)(client, pDraw, pPort, pGC,
+ src_x, src_y, src_w, src_h,
+ drw_x, drw_y, drw_w, drw_h,
+ image, data, sync, width, height);
+}
+
+
+int
+XvdiGetVideo(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h
+){
+ DrawablePtr pOldDraw;
+
+ CHECK_SIZE(drw_w, drw_h, vid_w, vid_h);
+
+ /* UPDATE TIME VARIABLES FOR USE IN EVENTS */
+
+ UpdateCurrentTime();
+
+ /* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
+ INFORM CLIENT OF ITS FAILURE */
+
+ if (pPort->grab.client && (pPort->grab.client != client))
+ {
+ XvdiSendVideoNotify(pPort, pDraw, XvBusy);
+ return Success;
+ }
+
+ /* CHECK TO SEE IF PORT IS IN USE; IF SO THEN WE MUST DELIVER INTERRUPTED
+ EVENTS TO ANY CLIENTS WHO WANT THEM */
+
+ pOldDraw = pPort->pDraw;
+ if ((pOldDraw) && (pOldDraw != pDraw))
+ {
+ XvdiSendVideoNotify(pPort, pPort->pDraw, XvPreempted);
+ }
+
+ (void) (* pPort->pAdaptor->ddGetVideo)(client, pDraw, pPort, pGC,
+ vid_x, vid_y, vid_w, vid_h,
+ drw_x, drw_y, drw_w, drw_h);
+
+ if ((pPort->pDraw) && (pOldDraw != pDraw))
+ {
+ pPort->client = client;
+ XvdiSendVideoNotify(pPort, pPort->pDraw, XvStarted);
+ }
+
+ pPort->time = currentTime;
+
+ return (Success);
+
+}
+
+int
+XvdiGetStill(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h
+){
+ int status;
+
+ CHECK_SIZE(drw_w, drw_h, vid_w, vid_h);
+
+ /* UPDATE TIME VARIABLES FOR USE IN EVENTS */
+
+ UpdateCurrentTime();
+
+ /* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
+ INFORM CLIENT OF ITS FAILURE */
+
+ if (pPort->grab.client && (pPort->grab.client != client))
+ {
+ XvdiSendVideoNotify(pPort, pDraw, XvBusy);
+ return Success;
+ }
+
+ status = (* pPort->pAdaptor->ddGetStill)(client, pDraw, pPort, pGC,
+ vid_x, vid_y, vid_w, vid_h,
+ drw_x, drw_y, drw_w, drw_h);
+
+ pPort->time = currentTime;
+
+ return status;
+
+}
+
+int
+XvdiGrabPort(
+ ClientPtr client,
+ XvPortPtr pPort,
+ Time ctime,
+ int *p_result
+){
+ unsigned long id;
+ TimeStamp time;
+
+ UpdateCurrentTime();
+ time = ClientTimeToServerTime(ctime);
+
+ if (pPort->grab.client && (client != pPort->grab.client))
+ {
+ *p_result = XvAlreadyGrabbed;
+ return Success;
+ }
+
+ if ((CompareTimeStamps(time, currentTime) == LATER) ||
+ (CompareTimeStamps(time, pPort->time) == EARLIER))
+ {
+ *p_result = XvInvalidTime;
+ return Success;
+ }
+
+ if (client == pPort->grab.client)
+ {
+ *p_result = Success;
+ return Success;
+ }
+
+ id = FakeClientID(client->index);
+
+ if (!AddResource(id, XvRTGrab, &pPort->grab))
+ {
+ return BadAlloc;
+ }
+
+ /* IF THERE IS ACTIVE VIDEO THEN STOP IT */
+
+ if ((pPort->pDraw) && (client != pPort->client))
+ {
+ XVCALL(diStopVideo)((ClientPtr)NULL, pPort, pPort->pDraw);
+ }
+
+ pPort->grab.client = client;
+ pPort->grab.id = id;
+
+ pPort->time = currentTime;
+
+ *p_result = Success;
+
+ return Success;
+
+}
+
+int
+XvdiUngrabPort(
+ ClientPtr client,
+ XvPortPtr pPort,
+ Time ctime
+){
+ TimeStamp time;
+
+ UpdateCurrentTime();
+ time = ClientTimeToServerTime(ctime);
+
+ if ((!pPort->grab.client) || (client != pPort->grab.client))
+ {
+ return Success;
+ }
+
+ if ((CompareTimeStamps(time, currentTime) == LATER) ||
+ (CompareTimeStamps(time, pPort->time) == EARLIER))
+ {
+ return Success;
+ }
+
+ /* FREE THE GRAB RESOURCE; AND SET THE GRAB CLIENT TO NULL */
+
+ FreeResource(pPort->grab.id, XvRTGrab);
+ pPort->grab.client = (ClientPtr)NULL;
+
+ pPort->time = currentTime;
+
+ return Success;
+
+}
+
+
+int
+XvdiSelectVideoNotify(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ BOOL onoff
+){
+ XvVideoNotifyPtr pn,tpn,fpn;
+
+ /* FIND VideoNotify LIST */
+
+ pn = (XvVideoNotifyPtr)LookupIDByType(pDraw->id, XvRTVideoNotifyList);
+
+ /* IF ONE DONES'T EXIST AND NO MASK, THEN JUST RETURN */
+
+ if (!onoff && !pn) return Success;
+
+ /* IF ONE DOESN'T EXIST CREATE IT AND ADD A RESOURCE SO THAT THE LIST
+ WILL BE DELETED WHEN THE DRAWABLE IS DESTROYED */
+
+ if (!pn)
+ {
+ if (!(tpn = (XvVideoNotifyPtr)xalloc(sizeof(XvVideoNotifyRec))))
+ return BadAlloc;
+ tpn->next = (XvVideoNotifyPtr)NULL;
+ if (!AddResource(pDraw->id, XvRTVideoNotifyList, tpn))
+ {
+ xfree(tpn);
+ return BadAlloc;
+ }
+ }
+ else
+ {
+ /* LOOK TO SEE IF ENTRY ALREADY EXISTS */
+
+ fpn = (XvVideoNotifyPtr)NULL;
+ tpn = pn;
+ while (tpn)
+ {
+ if (tpn->client == client)
+ {
+ if (!onoff) tpn->client = (ClientPtr)NULL;
+ return Success;
+ }
+ if (!tpn->client) fpn = tpn; /* TAKE NOTE OF FREE ENTRY */
+ tpn = tpn->next;
+ }
+
+ /* IF TUNNING OFF, THEN JUST RETURN */
+
+ if (!onoff) return Success;
+
+ /* IF ONE ISN'T FOUND THEN ALLOCATE ONE AND LINK IT INTO THE LIST */
+
+ if (fpn)
+ {
+ tpn = fpn;
+ }
+ else
+ {
+ if (!(tpn = (XvVideoNotifyPtr)xalloc(sizeof(XvVideoNotifyRec))))
+ return BadAlloc;
+ tpn->next = pn->next;
+ pn->next = tpn;
+ }
+ }
+
+ /* INIT CLIENT PTR IN CASE WE CAN'T ADD RESOURCE */
+ /* ADD RESOURCE SO THAT IF CLIENT EXITS THE CLIENT PTR WILL BE CLEARED */
+
+ tpn->client = (ClientPtr)NULL;
+ tpn->id = FakeClientID(client->index);
+ AddResource(tpn->id, XvRTVideoNotify, tpn);
+
+ tpn->client = client;
+ return Success;
+
+}
+
+int
+XvdiSelectPortNotify(
+ ClientPtr client,
+ XvPortPtr pPort,
+ BOOL onoff
+){
+ XvPortNotifyPtr pn,tpn;
+
+ /* SEE IF CLIENT IS ALREADY IN LIST */
+
+ tpn = (XvPortNotifyPtr)NULL;
+ pn = pPort->pNotify;
+ while (pn)
+ {
+ if (!pn->client) tpn = pn; /* TAKE NOTE OF FREE ENTRY */
+ if (pn->client == client) break;
+ pn = pn->next;
+ }
+
+ /* IS THE CLIENT ALREADY ON THE LIST? */
+
+ if (pn)
+ {
+ /* REMOVE IT? */
+
+ if (!onoff)
+ {
+ pn->client = (ClientPtr)NULL;
+ FreeResource(pn->id, XvRTPortNotify);
+ }
+
+ return Success;
+ }
+
+ /* DIDN'T FIND IT; SO REUSE LIST ELEMENT IF ONE IS FREE OTHERWISE
+ CREATE A NEW ONE AND ADD IT TO THE BEGINNING OF THE LIST */
+
+ if (!tpn)
+ {
+ if (!(tpn = (XvPortNotifyPtr)xalloc(sizeof(XvPortNotifyRec))))
+ return BadAlloc;
+ tpn->next = pPort->pNotify;
+ pPort->pNotify = tpn;
+ }
+
+ tpn->client = client;
+ tpn->id = FakeClientID(client->index);
+ AddResource(tpn->id, XvRTPortNotify, tpn);
+
+ return Success;
+
+}
+
+int
+XvdiStopVideo(
+ ClientPtr client,
+ XvPortPtr pPort,
+ DrawablePtr pDraw
+){
+ int status;
+
+ /* IF PORT ISN'T ACTIVE THEN WE'RE DONE */
+
+ if (!pPort->pDraw || (pPort->pDraw != pDraw))
+ {
+ XvdiSendVideoNotify(pPort, pDraw, XvStopped);
+ return Success;
+ }
+
+ /* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
+ INFORM CLIENT OF ITS FAILURE */
+
+ if ((client) && (pPort->grab.client) && (pPort->grab.client != client))
+ {
+ XvdiSendVideoNotify(pPort, pDraw, XvBusy);
+ return Success;
+ }
+
+ XvdiSendVideoNotify(pPort, pDraw, XvStopped);
+
+ status = (* pPort->pAdaptor->ddStopVideo)(client, pPort, pDraw);
+
+ pPort->pDraw = (DrawablePtr)NULL;
+ pPort->client = (ClientPtr)client;
+ pPort->time = currentTime;
+
+ return status;
+
+}
+
+int
+XvdiPreemptVideo(
+ ClientPtr client,
+ XvPortPtr pPort,
+ DrawablePtr pDraw
+){
+ int status;
+
+ /* IF PORT ISN'T ACTIVE THEN WE'RE DONE */
+
+ if (!pPort->pDraw || (pPort->pDraw != pDraw)) return Success;
+
+ XvdiSendVideoNotify(pPort, pPort->pDraw, XvPreempted);
+
+ status = (* pPort->pAdaptor->ddStopVideo)(client, pPort, pPort->pDraw);
+
+ pPort->pDraw = (DrawablePtr)NULL;
+ pPort->client = (ClientPtr)client;
+ pPort->time = currentTime;
+
+ return status;
+
+}
+
+int
+XvdiMatchPort(
+ XvPortPtr pPort,
+ DrawablePtr pDraw
+){
+
+ XvAdaptorPtr pa;
+ XvFormatPtr pf;
+ int nf;
+
+ pa = pPort->pAdaptor;
+
+ if (pa->pScreen != pDraw->pScreen) return BadMatch;
+
+ nf = pa->nFormats;
+ pf = pa->pFormats;
+
+ while (nf--)
+ {
+ if ((pf->depth == pDraw->depth)
+#if 0
+ && ((pDraw->type == DRAWABLE_PIXMAP) ||
+ (wVisual(((WindowPtr)pDraw)) == pf->visual))
+#endif
+ )
+ return Success;
+ pf++;
+ }
+
+ return BadMatch;
+
+}
+
+int
+XvdiSetPortAttribute(
+ ClientPtr client,
+ XvPortPtr pPort,
+ Atom attribute,
+ INT32 value
+){
+
+ XvdiSendPortNotify(pPort, attribute, value);
+
+ return
+ (* pPort->pAdaptor->ddSetPortAttribute)(client, pPort, attribute, value);
+
+}
+
+int
+XvdiGetPortAttribute(
+ ClientPtr client,
+ XvPortPtr pPort,
+ Atom attribute,
+ INT32 *p_value
+){
+
+ return
+ (* pPort->pAdaptor->ddGetPortAttribute)(client, pPort, attribute, p_value);
+
+}
+
+static void
+WriteSwappedVideoNotifyEvent(xvEvent *from, xvEvent *to)
+
+{
+
+ to->u.u.type = from->u.u.type;
+ to->u.u.detail = from->u.u.detail;
+ cpswaps(from->u.videoNotify.sequenceNumber,
+ to->u.videoNotify.sequenceNumber);
+ cpswapl(from->u.videoNotify.time, to->u.videoNotify.time);
+ cpswapl(from->u.videoNotify.drawable, to->u.videoNotify.drawable);
+ cpswapl(from->u.videoNotify.port, to->u.videoNotify.port);
+
+}
+
+static void
+WriteSwappedPortNotifyEvent(xvEvent *from, xvEvent *to)
+
+{
+
+ to->u.u.type = from->u.u.type;
+ to->u.u.detail = from->u.u.detail;
+ cpswaps(from->u.portNotify.sequenceNumber, to->u.portNotify.sequenceNumber);
+ cpswapl(from->u.portNotify.time, to->u.portNotify.time);
+ cpswapl(from->u.portNotify.port, to->u.portNotify.port);
+ cpswapl(from->u.portNotify.value, to->u.portNotify.value);
+
+}
diff --git a/nx-X11/programs/Xserver/Xext/xvmc.c b/nx-X11/programs/Xserver/Xext/xvmc.c
new file mode 100644
index 000000000..37fb153ab
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xvmc.c
@@ -0,0 +1,796 @@
+/* $XFree86: xc/programs/Xserver/Xext/xvmc.c,v 1.8 2003/07/16 01:38:31 dawes Exp $ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "scrnintstr.h"
+#include "extnsionst.h"
+#include "servermd.h"
+#include <X11/Xfuncproto.h>
+#include "xvdix.h"
+#include <X11/extensions/XvMC.h>
+#include <X11/extensions/Xvproto.h>
+#include <X11/extensions/XvMCproto.h>
+#include "xvmcext.h"
+
+#ifdef HAS_XVMCSHM
+#ifndef Lynx
+#include <sys/ipc.h>
+#include <sys/types.h>
+#include <sys/shm.h>
+#else
+#include <ipc.h>
+#include <shm.h>
+#endif /* Lynx */
+#endif /* HAS_XVMCSHM */
+
+
+
+#define DR_CLIENT_DRIVER_NAME_SIZE 48
+#define DR_BUSID_SIZE 48
+
+int XvMCScreenIndex = -1;
+
+unsigned long XvMCGeneration = 0;
+
+int XvMCReqCode;
+int XvMCEventBase;
+int XvMCErrorBase;
+
+unsigned long XvMCRTContext;
+unsigned long XvMCRTSurface;
+unsigned long XvMCRTSubpicture;
+
+typedef struct {
+ int num_adaptors;
+ XvMCAdaptorPtr adaptors;
+ CloseScreenProcPtr CloseScreen;
+ char clientDriverName[DR_CLIENT_DRIVER_NAME_SIZE];
+ char busID[DR_BUSID_SIZE];
+ int major;
+ int minor;
+ int patchLevel;
+} XvMCScreenRec, *XvMCScreenPtr;
+
+#define XVMC_GET_PRIVATE(pScreen) \
+ (XvMCScreenPtr)((pScreen)->devPrivates[XvMCScreenIndex].ptr)
+
+
+static int
+XvMCDestroyContextRes(pointer data, XID id)
+{
+ XvMCContextPtr pContext = (XvMCContextPtr)data;
+
+ pContext->refcnt--;
+
+ if(!pContext->refcnt) {
+ XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
+ (*pScreenPriv->adaptors[pContext->adapt_num].DestroyContext)(pContext);
+ xfree(pContext);
+ }
+
+ return Success;
+}
+
+static int
+XvMCDestroySurfaceRes(pointer data, XID id)
+{
+ XvMCSurfacePtr pSurface = (XvMCSurfacePtr)data;
+ XvMCContextPtr pContext = pSurface->context;
+ XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
+
+ (*pScreenPriv->adaptors[pContext->adapt_num].DestroySurface)(pSurface);
+ xfree(pSurface);
+
+ XvMCDestroyContextRes((pointer)pContext, pContext->context_id);
+
+ return Success;
+}
+
+
+static int
+XvMCDestroySubpictureRes(pointer data, XID id)
+{
+ XvMCSubpicturePtr pSubpict = (XvMCSubpicturePtr)data;
+ XvMCContextPtr pContext = pSubpict->context;
+ XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
+
+ (*pScreenPriv->adaptors[pContext->adapt_num].DestroySubpicture)(pSubpict);
+ xfree(pSubpict);
+
+ XvMCDestroyContextRes((pointer)pContext, pContext->context_id);
+
+ return Success;
+}
+
+static void
+XvMCResetProc (ExtensionEntry *extEntry)
+{
+}
+
+
+static int
+ProcXvMCQueryVersion(ClientPtr client)
+{
+ xvmcQueryVersionReply rep;
+ /* REQUEST(xvmcQueryVersionReq); */
+ REQUEST_SIZE_MATCH(xvmcQueryVersionReq);
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.major = XvMCVersion;
+ rep.minor = XvMCRevision;
+ WriteToClient(client, sizeof(xvmcQueryVersionReply), (char*)&rep);
+ return Success;
+}
+
+
+static int
+ProcXvMCListSurfaceTypes(ClientPtr client)
+{
+ XvPortPtr pPort;
+ int i;
+ XvMCScreenPtr pScreenPriv;
+ xvmcListSurfaceTypesReply rep;
+ xvmcSurfaceInfo info;
+ XvMCAdaptorPtr adaptor = NULL;
+ XvMCSurfaceInfoPtr surface;
+ REQUEST(xvmcListSurfaceTypesReq);
+ REQUEST_SIZE_MATCH(xvmcListSurfaceTypesReq);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client))) {
+ client->errorValue = stuff->port;
+ return _XvBadPort;
+ }
+
+ if(XvMCScreenIndex >= 0) { /* any adaptors at all */
+ ScreenPtr pScreen = pPort->pAdaptor->pScreen;
+ if((pScreenPriv = XVMC_GET_PRIVATE(pScreen))) { /* any this screen */
+ for(i = 0; i < pScreenPriv->num_adaptors; i++) {
+ if(pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
+ adaptor = &(pScreenPriv->adaptors[i]);
+ break;
+ }
+ }
+ }
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.num = (adaptor) ? adaptor->num_surfaces : 0;
+ rep.length = rep.num * sizeof(xvmcSurfaceInfo) >> 2;
+
+ WriteToClient(client, sizeof(xvmcListSurfaceTypesReply), (char*)&rep);
+
+ for(i = 0; i < rep.num; i++) {
+ surface = adaptor->surfaces[i];
+ info.surface_type_id = surface->surface_type_id;
+ info.chroma_format = surface->chroma_format;
+ info.max_width = surface->max_width;
+ info.max_height = surface->max_height;
+ info.subpicture_max_width = surface->subpicture_max_width;
+ info.subpicture_max_height = surface->subpicture_max_height;
+ info.mc_type = surface->mc_type;
+ info.flags = surface->flags;
+ WriteToClient(client, sizeof(xvmcSurfaceInfo), (char*)&info);
+ }
+
+ return Success;
+}
+
+static int
+ProcXvMCCreateContext(ClientPtr client)
+{
+ XvPortPtr pPort;
+ CARD32 *data = NULL;
+ int dwords = 0;
+ int i, result, adapt_num = -1;
+ ScreenPtr pScreen;
+ XvMCContextPtr pContext;
+ XvMCScreenPtr pScreenPriv;
+ XvMCAdaptorPtr adaptor = NULL;
+ XvMCSurfaceInfoPtr surface = NULL;
+ xvmcCreateContextReply rep;
+ REQUEST(xvmcCreateContextReq);
+ REQUEST_SIZE_MATCH(xvmcCreateContextReq);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client))) {
+ client->errorValue = stuff->port;
+ return _XvBadPort;
+ }
+
+ pScreen = pPort->pAdaptor->pScreen;
+
+ if(XvMCScreenIndex < 0) /* no XvMC adaptors */
+ return BadMatch;
+
+ if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) /* none this screen */
+ return BadMatch;
+
+ for(i = 0; i < pScreenPriv->num_adaptors; i++) {
+ if(pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
+ adaptor = &(pScreenPriv->adaptors[i]);
+ adapt_num = i;
+ break;
+ }
+ }
+
+ if(adapt_num < 0) /* none this port */
+ return BadMatch;
+
+ for(i = 0; i < adaptor->num_surfaces; i++) {
+ if(adaptor->surfaces[i]->surface_type_id == stuff->surface_type_id) {
+ surface = adaptor->surfaces[i];
+ break;
+ }
+ }
+
+ /* adaptor doesn't support this suface_type_id */
+ if(!surface) return BadMatch;
+
+
+ if((stuff->width > surface->max_width) ||
+ (stuff->height > surface->max_height))
+ return BadValue;
+
+ if(!(pContext = xalloc(sizeof(XvMCContextRec)))) {
+ return BadAlloc;
+ }
+
+
+ pContext->pScreen = pScreen;
+ pContext->adapt_num = adapt_num;
+ pContext->context_id = stuff->context_id;
+ pContext->surface_type_id = stuff->surface_type_id;
+ pContext->width = stuff->width;
+ pContext->height = stuff->height;
+ pContext->flags = stuff->flags;
+ pContext->refcnt = 1;
+
+ result = (*adaptor->CreateContext)(pPort, pContext, &dwords, &data);
+
+ if(result != Success) {
+ xfree(pContext);
+ return result;
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.width_actual = pContext->width;
+ rep.height_actual = pContext->height;
+ rep.flags_return = pContext->flags;
+ rep.length = dwords;
+
+ WriteToClient(client, sizeof(xvmcCreateContextReply), (char*)&rep);
+ if(dwords)
+ WriteToClient(client, dwords << 2, (char*)data);
+ AddResource(pContext->context_id, XvMCRTContext, pContext);
+
+ if(data)
+ xfree(data);
+
+ return Success;
+}
+
+static int
+ProcXvMCDestroyContext(ClientPtr client)
+{
+ REQUEST(xvmcDestroyContextReq);
+ REQUEST_SIZE_MATCH(xvmcDestroyContextReq);
+
+ if(!LookupIDByType(stuff->context_id, XvMCRTContext))
+ return (XvMCBadContext + XvMCErrorBase);
+
+ FreeResource(stuff->context_id, RT_NONE);
+
+ return Success;
+}
+
+static int
+ProcXvMCCreateSurface(ClientPtr client)
+{
+ CARD32 *data = NULL;
+ int dwords = 0;
+ int result;
+ XvMCContextPtr pContext;
+ XvMCSurfacePtr pSurface;
+ XvMCScreenPtr pScreenPriv;
+ xvmcCreateSurfaceReply rep;
+ REQUEST(xvmcCreateSurfaceReq);
+ REQUEST_SIZE_MATCH(xvmcCreateSurfaceReq);
+
+ if(!(pContext = LookupIDByType(stuff->context_id, XvMCRTContext)))
+ return (XvMCBadContext + XvMCErrorBase);
+
+ pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
+
+ if(!(pSurface = xalloc(sizeof(XvMCSurfaceRec))))
+ return BadAlloc;
+
+ pSurface->surface_id = stuff->surface_id;
+ pSurface->surface_type_id = pContext->surface_type_id;
+ pSurface->context = pContext;
+
+ result = (*pScreenPriv->adaptors[pContext->adapt_num].CreateSurface)(
+ pSurface, &dwords, &data);
+
+ if(result != Success) {
+ xfree(pSurface);
+ return result;
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = dwords;
+
+ WriteToClient(client, sizeof(xvmcCreateSurfaceReply), (char*)&rep);
+ if(dwords)
+ WriteToClient(client, dwords << 2, (char*)data);
+ AddResource(pSurface->surface_id, XvMCRTSurface, pSurface);
+
+ if(data)
+ xfree(data);
+
+ pContext->refcnt++;
+
+ return Success;
+}
+
+static int
+ProcXvMCDestroySurface(ClientPtr client)
+{
+ REQUEST(xvmcDestroySurfaceReq);
+ REQUEST_SIZE_MATCH(xvmcDestroySurfaceReq);
+
+ if(!LookupIDByType(stuff->surface_id, XvMCRTSurface))
+ return (XvMCBadSurface + XvMCErrorBase);
+
+ FreeResource(stuff->surface_id, RT_NONE);
+
+ return Success;
+}
+
+static int
+ProcXvMCCreateSubpicture(ClientPtr client)
+{
+ Bool image_supported = FALSE;
+ CARD32 *data = NULL;
+ int i, result, dwords = 0;
+ XvMCContextPtr pContext;
+ XvMCSubpicturePtr pSubpicture;
+ XvMCScreenPtr pScreenPriv;
+ xvmcCreateSubpictureReply rep;
+ XvMCAdaptorPtr adaptor;
+ XvMCSurfaceInfoPtr surface = NULL;
+ REQUEST(xvmcCreateSubpictureReq);
+ REQUEST_SIZE_MATCH(xvmcCreateSubpictureReq);
+
+ if(!(pContext = LookupIDByType(stuff->context_id, XvMCRTContext)))
+ return (XvMCBadContext + XvMCErrorBase);
+
+ pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
+
+ adaptor = &(pScreenPriv->adaptors[pContext->adapt_num]);
+
+ /* find which surface this context supports */
+ for(i = 0; i < adaptor->num_surfaces; i++) {
+ if(adaptor->surfaces[i]->surface_type_id == pContext->surface_type_id){
+ surface = adaptor->surfaces[i];
+ break;
+ }
+ }
+
+ if(!surface) return BadMatch;
+
+ /* make sure this surface supports that xvimage format */
+ if(!surface->compatible_subpictures) return BadMatch;
+
+ for(i = 0; i < surface->compatible_subpictures->num_xvimages; i++) {
+ if(surface->compatible_subpictures->xvimage_ids[i] == stuff->xvimage_id) {
+ image_supported = TRUE;
+ break;
+ }
+ }
+
+ if(!image_supported) return BadMatch;
+
+ /* make sure the size is OK */
+ if((stuff->width > surface->subpicture_max_width) ||
+ (stuff->height > surface->subpicture_max_height))
+ return BadValue;
+
+ if(!(pSubpicture = xalloc(sizeof(XvMCSubpictureRec))))
+ return BadAlloc;
+
+ pSubpicture->subpicture_id = stuff->subpicture_id;
+ pSubpicture->xvimage_id = stuff->xvimage_id;
+ pSubpicture->width = stuff->width;
+ pSubpicture->height = stuff->height;
+ pSubpicture->num_palette_entries = 0; /* overwritten by DDX */
+ pSubpicture->entry_bytes = 0; /* overwritten by DDX */
+ pSubpicture->component_order[0] = 0; /* overwritten by DDX */
+ pSubpicture->component_order[1] = 0;
+ pSubpicture->component_order[2] = 0;
+ pSubpicture->component_order[3] = 0;
+ pSubpicture->context = pContext;
+
+ result = (*pScreenPriv->adaptors[pContext->adapt_num].CreateSubpicture)(
+ pSubpicture, &dwords, &data);
+
+ if(result != Success) {
+ xfree(pSubpicture);
+ return result;
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.width_actual = pSubpicture->width;
+ rep.height_actual = pSubpicture->height;
+ rep.num_palette_entries = pSubpicture->num_palette_entries;
+ rep.entry_bytes = pSubpicture->entry_bytes;
+ rep.component_order[0] = pSubpicture->component_order[0];
+ rep.component_order[1] = pSubpicture->component_order[1];
+ rep.component_order[2] = pSubpicture->component_order[2];
+ rep.component_order[3] = pSubpicture->component_order[3];
+ rep.length = dwords;
+
+ WriteToClient(client, sizeof(xvmcCreateSubpictureReply), (char*)&rep);
+ if(dwords)
+ WriteToClient(client, dwords << 2, (char*)data);
+ AddResource(pSubpicture->subpicture_id, XvMCRTSubpicture, pSubpicture);
+
+ if(data)
+ xfree(data);
+
+ pContext->refcnt++;
+
+ return Success;
+}
+
+static int
+ProcXvMCDestroySubpicture(ClientPtr client)
+{
+ REQUEST(xvmcDestroySubpictureReq);
+ REQUEST_SIZE_MATCH(xvmcDestroySubpictureReq);
+
+ if(!LookupIDByType(stuff->subpicture_id, XvMCRTSubpicture))
+ return (XvMCBadSubpicture + XvMCErrorBase);
+
+ FreeResource(stuff->subpicture_id, RT_NONE);
+
+ return Success;
+}
+
+
+static int
+ProcXvMCListSubpictureTypes(ClientPtr client)
+{
+ XvPortPtr pPort;
+ xvmcListSubpictureTypesReply rep;
+ XvMCScreenPtr pScreenPriv;
+ ScreenPtr pScreen;
+ XvMCAdaptorPtr adaptor = NULL;
+ XvMCSurfaceInfoPtr surface = NULL;
+ xvImageFormatInfo info;
+ XvImagePtr pImage;
+ int i, j;
+ REQUEST(xvmcListSubpictureTypesReq);
+ REQUEST_SIZE_MATCH(xvmcListSubpictureTypesReq);
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client))) {
+ client->errorValue = stuff->port;
+ return _XvBadPort;
+ }
+
+ pScreen = pPort->pAdaptor->pScreen;
+
+ if(XvMCScreenIndex < 0) /* No XvMC adaptors */
+ return BadMatch;
+
+ if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen)))
+ return BadMatch; /* None this screen */
+
+ for(i = 0; i < pScreenPriv->num_adaptors; i++) {
+ if(pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
+ adaptor = &(pScreenPriv->adaptors[i]);
+ break;
+ }
+ }
+
+ if(!adaptor) return BadMatch;
+
+ for(i = 0; i < adaptor->num_surfaces; i++) {
+ if(adaptor->surfaces[i]->surface_type_id == stuff->surface_type_id) {
+ surface = adaptor->surfaces[i];
+ break;
+ }
+ }
+
+ if(!surface) return BadMatch;
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.num = 0;
+ if(surface->compatible_subpictures)
+ rep.num = surface->compatible_subpictures->num_xvimages;
+
+ rep.length = rep.num * sizeof(xvImageFormatInfo) >> 2;
+
+ WriteToClient(client, sizeof(xvmcListSubpictureTypesReply), (char*)&rep);
+
+ for(i = 0; i < rep.num; i++) {
+ pImage = NULL;
+ for(j = 0; j < adaptor->num_subpictures; j++) {
+ if(surface->compatible_subpictures->xvimage_ids[i] ==
+ adaptor->subpictures[j]->id)
+ {
+ pImage = adaptor->subpictures[j];
+ break;
+ }
+ }
+ if(!pImage) return BadImplementation;
+
+ info.id = pImage->id;
+ info.type = pImage->type;
+ info.byte_order = pImage->byte_order;
+ memcpy(&info.guid, pImage->guid, 16);
+ info.bpp = pImage->bits_per_pixel;
+ info.num_planes = pImage->num_planes;
+ info.depth = pImage->depth;
+ info.red_mask = pImage->red_mask;
+ info.green_mask = pImage->green_mask;
+ info.blue_mask = pImage->blue_mask;
+ info.format = pImage->format;
+ info.y_sample_bits = pImage->y_sample_bits;
+ info.u_sample_bits = pImage->u_sample_bits;
+ info.v_sample_bits = pImage->v_sample_bits;
+ info.horz_y_period = pImage->horz_y_period;
+ info.horz_u_period = pImage->horz_u_period;
+ info.horz_v_period = pImage->horz_v_period;
+ info.vert_y_period = pImage->vert_y_period;
+ info.vert_u_period = pImage->vert_u_period;
+ info.vert_v_period = pImage->vert_v_period;
+ memcpy(&info.comp_order, pImage->component_order, 32);
+ info.scanline_order = pImage->scanline_order;
+ WriteToClient(client, sizeof(xvImageFormatInfo), (char*)&info);
+ }
+
+ return Success;
+}
+
+static int
+ProcXvMCGetDRInfo(ClientPtr client)
+{
+ xvmcGetDRInfoReply rep;
+ XvPortPtr pPort;
+ ScreenPtr pScreen;
+ XvMCScreenPtr pScreenPriv;
+
+#ifdef HAS_XVMCSHM
+ volatile CARD32 *patternP;
+#endif
+
+ REQUEST(xvmcGetDRInfoReq);
+ REQUEST_SIZE_MATCH(xvmcGetDRInfoReq);
+
+
+ if(!(pPort = LOOKUP_PORT(stuff->port, client))) {
+ client->errorValue = stuff->port;
+ return _XvBadPort;
+ }
+
+ pScreen = pPort->pAdaptor->pScreen;
+ pScreenPriv = XVMC_GET_PRIVATE(pScreen);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.major = pScreenPriv->major;
+ rep.minor = pScreenPriv->minor;
+ rep.patchLevel = pScreenPriv->patchLevel;
+ rep.nameLen = (strlen(pScreenPriv->clientDriverName) + 4) >> 2;
+ rep.busIDLen = (strlen(pScreenPriv->busID) + 4) >> 2;
+
+ rep.length = rep.nameLen + rep.busIDLen;
+ rep.nameLen <<=2;
+ rep.busIDLen <<=2;
+
+ /*
+ * Read back to the client what she has put in the shared memory
+ * segment she prepared for us.
+ */
+
+ rep.isLocal = 1;
+#ifdef HAS_XVMCSHM
+ patternP = (CARD32 *)shmat( stuff->shmKey, NULL, SHM_RDONLY );
+ if ( -1 != (long) patternP) {
+ register volatile CARD32 *patternC = patternP;
+ register int i;
+ CARD32 magic = stuff->magic;
+
+ rep.isLocal = 1;
+ i = 1024 / sizeof(CARD32);
+
+ while ( i-- ) {
+ if (*patternC++ != magic) {
+ rep.isLocal = 0;
+ break;
+ }
+ magic = ~magic;
+ }
+ shmdt( (char *)patternP );
+ }
+#endif /* HAS_XVMCSHM */
+
+ WriteToClient(client, sizeof(xvmcGetDRInfoReply),
+ (char*)&rep);
+ if (rep.length) {
+ WriteToClient(client, rep.nameLen,
+ pScreenPriv->clientDriverName);
+ WriteToClient(client, rep.busIDLen,
+ pScreenPriv->busID);
+ }
+ return Success;
+}
+
+
+int (*ProcXvMCVector[xvmcNumRequest])(ClientPtr) = {
+ ProcXvMCQueryVersion,
+ ProcXvMCListSurfaceTypes,
+ ProcXvMCCreateContext,
+ ProcXvMCDestroyContext,
+ ProcXvMCCreateSurface,
+ ProcXvMCDestroySurface,
+ ProcXvMCCreateSubpicture,
+ ProcXvMCDestroySubpicture,
+ ProcXvMCListSubpictureTypes,
+ ProcXvMCGetDRInfo
+};
+
+static int
+ProcXvMCDispatch (ClientPtr client)
+{
+ REQUEST(xReq);
+
+ if(stuff->data < xvmcNumRequest)
+ return (*ProcXvMCVector[stuff->data])(client);
+ else
+ return BadRequest;
+}
+
+static int
+SProcXvMCDispatch (ClientPtr client)
+{
+ /* We only support local */
+ return BadImplementation;
+}
+
+void
+XvMCExtensionInit()
+{
+ ExtensionEntry *extEntry;
+
+ if(XvMCScreenIndex < 0) /* nobody supports it */
+ return;
+
+ if(!(XvMCRTContext = CreateNewResourceType(XvMCDestroyContextRes)))
+ return;
+
+ if(!(XvMCRTSurface = CreateNewResourceType(XvMCDestroySurfaceRes)))
+ return;
+
+ if(!(XvMCRTSubpicture = CreateNewResourceType(XvMCDestroySubpictureRes)))
+ return;
+
+ extEntry = AddExtension(XvMCName, XvMCNumEvents, XvMCNumErrors,
+ ProcXvMCDispatch, SProcXvMCDispatch,
+ XvMCResetProc, StandardMinorOpcode);
+
+ if(!extEntry) return;
+
+ XvMCReqCode = extEntry->base;
+ XvMCEventBase = extEntry->eventBase;
+ XvMCErrorBase = extEntry->errorBase;
+}
+
+static Bool
+XvMCCloseScreen (int i, ScreenPtr pScreen)
+{
+ XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pScreen);
+
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+
+ xfree(pScreenPriv);
+
+ return (*pScreen->CloseScreen)(i, pScreen);
+}
+
+
+int
+XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt)
+{
+ XvMCScreenPtr pScreenPriv;
+
+ if(XvMCGeneration != serverGeneration) {
+ if((XvMCScreenIndex = AllocateScreenPrivateIndex()) < 0)
+ return BadAlloc;
+
+ XvMCGeneration = serverGeneration;
+ }
+
+ if(!(pScreenPriv = (XvMCScreenPtr)xalloc(sizeof(XvMCScreenRec))))
+ return BadAlloc;
+
+ pScreen->devPrivates[XvMCScreenIndex].ptr = (pointer)pScreenPriv;
+
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = XvMCCloseScreen;
+
+ pScreenPriv->num_adaptors = num;
+ pScreenPriv->adaptors = pAdapt;
+ pScreenPriv->clientDriverName[0] = 0;
+ pScreenPriv->busID[0] = 0;
+ pScreenPriv->major = 0;
+ pScreenPriv->minor = 0;
+ pScreenPriv->patchLevel = 0;
+
+ return Success;
+}
+
+XvImagePtr XvMCFindXvImage(XvPortPtr pPort, CARD32 id)
+{
+ XvImagePtr pImage = NULL;
+ ScreenPtr pScreen = pPort->pAdaptor->pScreen;
+ XvMCScreenPtr pScreenPriv;
+ XvMCAdaptorPtr adaptor = NULL;
+ int i;
+
+ if(XvMCScreenIndex < 0) return NULL;
+
+ if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen)))
+ return NULL;
+
+ for(i = 0; i < pScreenPriv->num_adaptors; i++) {
+ if(pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
+ adaptor = &(pScreenPriv->adaptors[i]);
+ break;
+ }
+ }
+
+ if(!adaptor) return NULL;
+
+ for(i = 0; i < adaptor->num_subpictures; i++) {
+ if(adaptor->subpictures[i]->id == id) {
+ pImage = adaptor->subpictures[i];
+ break;
+ }
+ }
+
+ return pImage;
+}
+
+int
+xf86XvMCRegisterDRInfo(ScreenPtr pScreen, char *name,
+ char *busID, int major, int minor,
+ int patchLevel)
+{
+ XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pScreen);
+ strncpy(pScreenPriv->clientDriverName, name,
+ DR_CLIENT_DRIVER_NAME_SIZE);
+ strncpy(pScreenPriv->busID, busID, DR_BUSID_SIZE);
+ pScreenPriv->major = major;
+ pScreenPriv->minor = minor;
+ pScreenPriv->patchLevel = patchLevel;
+ pScreenPriv->clientDriverName[DR_CLIENT_DRIVER_NAME_SIZE-1] = 0;
+ pScreenPriv->busID[DR_BUSID_SIZE-1] = 0;
+ return Success;
+}
+
diff --git a/nx-X11/programs/Xserver/Xext/xvmcext.h b/nx-X11/programs/Xserver/Xext/xvmcext.h
new file mode 100644
index 000000000..c7eba30ad
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xvmcext.h
@@ -0,0 +1,116 @@
+/* $XFree86: xc/programs/Xserver/Xext/xvmcext.h,v 1.1 2001/04/07 11:04:21 alanh Exp $ */
+
+#ifndef _XVMC_H
+#define _XVMC_H
+#include <X11/extensions/Xv.h>
+#include "xvdix.h"
+
+typedef struct {
+ int num_xvimages;
+ int *xvimage_ids;
+} XvMCImageIDList;
+
+typedef struct {
+ int surface_type_id;
+ int chroma_format;
+ int color_description;
+ unsigned short max_width;
+ unsigned short max_height;
+ unsigned short subpicture_max_width;
+ unsigned short subpicture_max_height;
+ int mc_type;
+ int flags;
+ XvMCImageIDList *compatible_subpictures;
+} XvMCSurfaceInfoRec, *XvMCSurfaceInfoPtr;
+
+typedef struct {
+ XID context_id;
+ ScreenPtr pScreen;
+ int adapt_num;
+ int surface_type_id;
+ unsigned short width;
+ unsigned short height;
+ CARD32 flags;
+ int refcnt;
+ pointer port_priv;
+ pointer driver_priv;
+} XvMCContextRec, *XvMCContextPtr;
+
+typedef struct {
+ XID surface_id;
+ int surface_type_id;
+ XvMCContextPtr context;
+ pointer driver_priv;
+} XvMCSurfaceRec, *XvMCSurfacePtr;
+
+
+typedef struct {
+ XID subpicture_id;
+ int xvimage_id;
+ unsigned short width;
+ unsigned short height;
+ int num_palette_entries;
+ int entry_bytes;
+ char component_order[4];
+ XvMCContextPtr context;
+ pointer driver_priv;
+} XvMCSubpictureRec, *XvMCSubpicturePtr;
+
+typedef int (*XvMCCreateContextProcPtr) (
+ XvPortPtr port,
+ XvMCContextPtr context,
+ int *num_priv,
+ CARD32 **priv
+);
+
+typedef void (*XvMCDestroyContextProcPtr) (
+ XvMCContextPtr context
+);
+
+typedef int (*XvMCCreateSurfaceProcPtr) (
+ XvMCSurfacePtr surface,
+ int *num_priv,
+ CARD32 **priv
+);
+
+typedef void (*XvMCDestroySurfaceProcPtr) (
+ XvMCSurfacePtr surface
+);
+
+typedef int (*XvMCCreateSubpictureProcPtr) (
+ XvMCSubpicturePtr subpicture,
+ int *num_priv,
+ CARD32 **priv
+);
+
+typedef void (*XvMCDestroySubpictureProcPtr) (
+ XvMCSubpicturePtr subpicture
+);
+
+
+typedef struct {
+ XvAdaptorPtr xv_adaptor;
+ int num_surfaces;
+ XvMCSurfaceInfoPtr *surfaces;
+ int num_subpictures;
+ XvImagePtr *subpictures;
+ XvMCCreateContextProcPtr CreateContext;
+ XvMCDestroyContextProcPtr DestroyContext;
+ XvMCCreateSurfaceProcPtr CreateSurface;
+ XvMCDestroySurfaceProcPtr DestroySurface;
+ XvMCCreateSubpictureProcPtr CreateSubpicture;
+ XvMCDestroySubpictureProcPtr DestroySubpicture;
+} XvMCAdaptorRec, *XvMCAdaptorPtr;
+
+void XvMCExtensionInit(void);
+
+int XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr adapt);
+
+XvImagePtr XvMCFindXvImage(XvPortPtr pPort, CARD32 id);
+
+int xf86XvMCRegisterDRInfo(ScreenPtr pScreen, char *name,
+ char *busID, int major, int minor,
+ int patchLevel);
+
+
+#endif /* _XVMC_H */
diff --git a/nx-X11/programs/Xserver/Xext/xvmod.c b/nx-X11/programs/Xserver/Xext/xvmod.c
new file mode 100644
index 000000000..7899f3a75
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xvmod.c
@@ -0,0 +1,24 @@
+/* $XFree86: xc/programs/Xserver/Xext/xvmod.c,v 1.1 1998/08/13 14:45:36 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "scrnintstr.h"
+#include "gc.h"
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/Xvproto.h>
+#include "xvdix.h"
+#include "xvmodproc.h"
+
+void
+XvRegister()
+{
+ XvScreenInitProc = XvScreenInit;
+ XvGetScreenIndexProc = XvGetScreenIndex;
+ XvGetRTPortProc = XvGetRTPort;
+ XvMCScreenInitProc = XvMCScreenInit;
+}
+
diff --git a/nx-X11/programs/Xserver/Xext/xvmodproc.h b/nx-X11/programs/Xserver/Xext/xvmodproc.h
new file mode 100644
index 000000000..b284e3f4e
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xext/xvmodproc.h
@@ -0,0 +1,14 @@
+/* $XFree86: xc/programs/Xserver/Xext/xvmodproc.h,v 1.2 2001/03/05 04:51:55 mvojkovi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xvmcext.h"
+
+extern int (*XvGetScreenIndexProc)(void);
+extern unsigned long (*XvGetRTPortProc)(void);
+extern int (*XvScreenInitProc)(ScreenPtr);
+extern int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr);
+
+extern void XvRegister(void);
diff --git a/nx-X11/programs/Xserver/Xi/Imakefile b/nx-X11/programs/Xserver/Xi/Imakefile
new file mode 100644
index 000000000..27e1f5df0
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/Imakefile
@@ -0,0 +1,94 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:47:59 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/Xi/Imakefile,v 3.2 1999/04/17 09:08:22 dawes Exp $
+
+#include <Server.tmpl>
+
+ SRCS = allowev.c \
+ chgkbd.c \
+ chgdctl.c \
+ chgfctl.c \
+ chgkmap.c \
+ chgprop.c \
+ chgptr.c \
+ closedev.c \
+ devbell.c \
+ exevents.c \
+ extinit.c \
+ getdctl.c \
+ getfctl.c \
+ getfocus.c \
+ getbmap.c \
+ getkmap.c \
+ getmmap.c \
+ getprop.c \
+ getselev.c \
+ getvers.c \
+ gtmotion.c \
+ grabdev.c \
+ grabdevb.c \
+ grabdevk.c \
+ listdev.c \
+ opendev.c \
+ queryst.c \
+ selectev.c \
+ sendexev.c \
+ setdval.c \
+ setfocus.c \
+ setmode.c \
+ setbmap.c \
+ setmmap.c \
+ stubs.c \
+ ungrdev.c \
+ ungrdevb.c \
+ ungrdevk.c
+
+ OBJS = allowev.o \
+ chgkbd.o \
+ chgdctl.o \
+ chgfctl.o \
+ chgkmap.o \
+ chgprop.o \
+ chgptr.o \
+ closedev.o \
+ devbell.o \
+ exevents.o \
+ extinit.o \
+ getdctl.o \
+ getfctl.o \
+ getfocus.o \
+ getbmap.o \
+ getkmap.o \
+ getmmap.o \
+ getprop.o \
+ getselev.o \
+ getvers.o \
+ gtmotion.o \
+ grabdev.o \
+ grabdevb.o \
+ grabdevk.o \
+ listdev.o \
+ opendev.o \
+ queryst.o \
+ selectev.o \
+ sendexev.o \
+ setdval.o \
+ setfocus.o \
+ setmode.o \
+ setbmap.o \
+ setmmap.o \
+ ungrdev.o \
+ ungrdevb.o \
+ ungrdevk.o
+ INCLUDES = -I../include -I$(EXTINCSRC) -I$(XINCLUDESRC)
+ LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+
+NormalLibraryTarget(xinput,$(OBJS))
+NormalLibraryObjectRule()
+LintLibraryTarget(xinput,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/Xi/allowev.c b/nx-X11/programs/Xserver/Xi/allowev.c
new file mode 100644
index 000000000..c1df7eb73
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/allowev.c
@@ -0,0 +1,145 @@
+/* $Xorg: allowev.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/allowev.c,v 3.3 2001/01/17 22:13:23 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Function to allow frozen events to be routed from extension input devices.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "allowev.h"
+#include "dixevents.h"
+
+/***********************************************************************
+ *
+ * This procedure allows frozen events to be routed.
+ *
+ */
+
+int
+SProcXAllowDeviceEvents(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xAllowDeviceEventsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xAllowDeviceEventsReq);
+ swapl(&stuff->time, n);
+ return(ProcXAllowDeviceEvents(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure allows frozen events to be routed.
+ *
+ */
+
+int
+ProcXAllowDeviceEvents(client)
+ register ClientPtr client;
+ {
+ TimeStamp time;
+ DeviceIntPtr thisdev;
+
+ REQUEST(xAllowDeviceEventsReq);
+ REQUEST_SIZE_MATCH(xAllowDeviceEventsReq);
+
+ thisdev = LookupDeviceIntRec (stuff->deviceid);
+ if (thisdev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_AllowDeviceEvents, 0, BadDevice);
+ return Success;
+ }
+ time = ClientTimeToServerTime(stuff->time);
+
+ switch (stuff->mode)
+ {
+ case ReplayThisDevice:
+ AllowSome(client, time, thisdev, NOT_GRABBED);
+ break;
+ case SyncThisDevice:
+ AllowSome(client, time, thisdev, FREEZE_NEXT_EVENT);
+ break;
+ case AsyncThisDevice:
+ AllowSome(client, time, thisdev, THAWED);
+ break;
+ case AsyncOtherDevices:
+ AllowSome(client, time, thisdev, THAW_OTHERS);
+ break;
+ case SyncAll:
+ AllowSome(client, time, thisdev, FREEZE_BOTH_NEXT_EVENT);
+ break;
+ case AsyncAll:
+ AllowSome(client, time, thisdev, THAWED_BOTH);
+ break;
+ default:
+ SendErrorToClient(client, IReqCode, X_AllowDeviceEvents, 0,
+ BadValue);
+ client->errorValue = stuff->mode;
+ return Success;
+ }
+ return Success;
+ }
diff --git a/nx-X11/programs/Xserver/Xi/allowev.h b/nx-X11/programs/Xserver/Xi/allowev.h
new file mode 100644
index 000000000..2d1132d3a
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/allowev.h
@@ -0,0 +1,44 @@
+/* $XFree86: xc/programs/Xserver/Xi/allowev.h,v 3.1 1996/04/15 11:18:23 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef ALLOWEV_H
+#define ALLOWEV_H 1
+
+int
+SProcXAllowDeviceEvents(
+ ClientPtr /* client */
+ );
+
+int
+ProcXAllowDeviceEvents(
+ ClientPtr /* client */
+ );
+
+#endif /* ALLOWEV_H */
diff --git a/nx-X11/programs/Xserver/Xi/chgdctl.c b/nx-X11/programs/Xserver/Xi/chgdctl.c
new file mode 100644
index 000000000..63a3c9c69
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/chgdctl.c
@@ -0,0 +1,219 @@
+/* $Xorg: chgdctl.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/chgdctl.c,v 3.3 2001/01/17 22:13:23 dawes Exp $ */
+
+/********************************************************************
+ *
+ * Change Device control attributes for an extension device.
+ *
+ */
+
+#define NEED_EVENTS /* for inputstr.h */
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h> /* control constants */
+#include "XIstubs.h"
+
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "chgdctl.h"
+
+/***********************************************************************
+ *
+ * This procedure changes the control attributes for an extension device,
+ * for clients on machines with a different byte ordering than the server.
+ *
+ */
+
+int
+SProcXChangeDeviceControl(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xChangeDeviceControlReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
+ swaps(&stuff->control, n);
+ return(ProcXChangeDeviceControl(client));
+ }
+
+/***********************************************************************
+ *
+ * Change the control attributes.
+ *
+ */
+
+int
+ProcXChangeDeviceControl(client)
+ ClientPtr client;
+ {
+ unsigned len;
+ int i, status;
+ DeviceIntPtr dev;
+ xDeviceResolutionCtl *r;
+ xChangeDeviceControlReply rep;
+ AxisInfoPtr a;
+ CARD32 *resolution;
+
+ REQUEST(xChangeDeviceControlReq);
+ REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
+
+ len = stuff->length - (sizeof(xChangeDeviceControlReq) >>2);
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0,
+ BadDevice);
+ return Success;
+ }
+
+ rep.repType = X_Reply;
+ rep.RepType = X_ChangeDeviceControl;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ switch (stuff->control)
+ {
+ case DEVICE_RESOLUTION:
+ r = (xDeviceResolutionCtl *) &stuff[1];
+ if ((len < (sizeof(xDeviceResolutionCtl)>>2)) ||
+ (len != (sizeof(xDeviceResolutionCtl)>>2) +
+ r->num_valuators))
+ {
+ SendErrorToClient (client, IReqCode, X_ChangeDeviceControl,
+ 0, BadLength);
+ return Success;
+ }
+ if (!dev->valuator)
+ {
+ SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0,
+ BadMatch);
+ return Success;
+ }
+ if ((dev->grab) && !SameClient(dev->grab, client))
+ {
+ rep.status = AlreadyGrabbed;
+ WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
+ &rep);
+ return Success;
+ }
+ resolution = (CARD32 *) (r + 1);
+ if (r->first_valuator + r->num_valuators > dev->valuator->numAxes)
+ {
+ SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0,
+ BadValue);
+ return Success;
+ }
+ status = ChangeDeviceControl(client, dev, (xDeviceCtl*) r);
+ if (status == Success)
+ {
+ a = &dev->valuator->axes[r->first_valuator];
+ for (i=0; i<r->num_valuators; i++)
+ if (*(resolution+i) < (a+i)->min_resolution ||
+ *(resolution+i) > (a+i)->max_resolution)
+ {
+ SendErrorToClient (client, IReqCode,
+ X_ChangeDeviceControl, 0, BadValue);
+ return Success;
+ }
+ for (i=0; i<r->num_valuators; i++)
+ (a++)->resolution = *resolution++;
+ }
+ else if (status == DeviceBusy)
+ {
+ rep.status = DeviceBusy;
+ WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
+ &rep);
+ return Success;
+ }
+ else
+ {
+ SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0,
+ BadMatch);
+ return Success;
+ }
+ break;
+ default:
+ SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0,
+ BadValue);
+ return Success;
+ }
+ WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the xChangeDeviceControl function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXChangeDeviceControl (client, size, rep)
+ ClientPtr client;
+ int size;
+ xChangeDeviceControlReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ WriteToClient(client, size, (char *)rep);
+ }
+
diff --git a/nx-X11/programs/Xserver/Xi/chgdctl.h b/nx-X11/programs/Xserver/Xi/chgdctl.h
new file mode 100644
index 000000000..a6a530f37
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/chgdctl.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/programs/Xserver/Xi/chgdctl.h,v 3.1 1996/04/15 11:18:25 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef CHGDCTL_H
+#define CHGDCTL_H 1
+
+int
+SProcXChangeDeviceControl(
+ ClientPtr /* client */
+ );
+
+int
+ProcXChangeDeviceControl(
+ ClientPtr /* client */
+ );
+
+void
+SRepXChangeDeviceControl (
+ ClientPtr /* client */,
+ int /* size */,
+ xChangeDeviceControlReply * /* rep */
+ );
+
+#endif /* CHGDCTL_H */
diff --git a/nx-X11/programs/Xserver/Xi/chgfctl.c b/nx-X11/programs/Xserver/Xi/chgfctl.c
new file mode 100644
index 000000000..c502db325
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/chgfctl.c
@@ -0,0 +1,663 @@
+/* $Xorg: chgfctl.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/chgfctl.c,v 3.3 2001/01/17 22:13:23 dawes Exp $ */
+
+/********************************************************************
+ *
+ * Change feedback control attributes for an extension device.
+ *
+ */
+
+#define NEED_EVENTS /* for inputstr.h */
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h> /* control constants */
+
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "chgfctl.h"
+
+#define DO_ALL (-1)
+
+/***********************************************************************
+ *
+ * This procedure changes the control attributes for an extension device,
+ * for clients on machines with a different byte ordering than the server.
+ *
+ */
+
+int
+SProcXChangeFeedbackControl(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xChangeFeedbackControlReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq);
+ swapl(&stuff->mask, n);
+ return(ProcXChangeFeedbackControl(client));
+ }
+
+/***********************************************************************
+ *
+ * Change the control attributes.
+ *
+ */
+
+int
+ProcXChangeFeedbackControl(client)
+ ClientPtr client;
+ {
+ unsigned len;
+ DeviceIntPtr dev;
+ KbdFeedbackPtr k;
+ PtrFeedbackPtr p;
+ IntegerFeedbackPtr i;
+ StringFeedbackPtr s;
+ BellFeedbackPtr b;
+ LedFeedbackPtr l;
+
+ REQUEST(xChangeFeedbackControlReq);
+ REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq);
+
+ len = stuff->length - (sizeof(xChangeFeedbackControlReq) >>2);
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl, 0,
+ BadDevice);
+ return Success;
+ }
+
+ switch (stuff->feedbackid)
+ {
+ case KbdFeedbackClass:
+ if (len != (sizeof(xKbdFeedbackCtl)>>2))
+ {
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl,
+ 0, BadLength);
+ return Success;
+ }
+ for (k=dev->kbdfeed; k; k=k->next)
+ if (k->ctrl.id == ((xKbdFeedbackCtl *) &stuff[1])->id)
+ {
+ ChangeKbdFeedback (client, dev, stuff->mask, k, (xKbdFeedbackCtl *)&stuff[1]);
+ return Success;
+ }
+ break;
+ case PtrFeedbackClass:
+ if (len != (sizeof(xPtrFeedbackCtl)>>2))
+ {
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl,
+ 0, BadLength);
+ return Success;
+ }
+ for (p=dev->ptrfeed; p; p=p->next)
+ if (p->ctrl.id == ((xPtrFeedbackCtl *) &stuff[1])->id)
+ {
+ ChangePtrFeedback (client, dev, stuff->mask, p, (xPtrFeedbackCtl *)&stuff[1]);
+ return Success;
+ }
+ break;
+ case StringFeedbackClass:
+ {
+ register char n;
+ xStringFeedbackCtl *f = ((xStringFeedbackCtl *) &stuff[1]);
+ if (client->swapped)
+ {
+ swaps(&f->num_keysyms,n);
+ }
+ if (len != ((sizeof(xStringFeedbackCtl)>>2) + f->num_keysyms))
+ {
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl,
+ 0, BadLength);
+ return Success;
+ }
+ for (s=dev->stringfeed; s; s=s->next)
+ if (s->ctrl.id == ((xStringFeedbackCtl *) &stuff[1])->id)
+ {
+ ChangeStringFeedback (client, dev, stuff->mask,s,(xStringFeedbackCtl *)&stuff[1]);
+ return Success;
+ }
+ break;
+ }
+ case IntegerFeedbackClass:
+ if (len != (sizeof(xIntegerFeedbackCtl)>>2))
+ {
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl,
+ 0, BadLength);
+ return Success;
+ }
+ for (i=dev->intfeed; i; i=i->next)
+ if (i->ctrl.id == ((xIntegerFeedbackCtl *) &stuff[1])->id)
+ {
+ ChangeIntegerFeedback (client, dev,stuff->mask,i,(xIntegerFeedbackCtl *)&stuff[1]);
+ return Success;
+ }
+ break;
+ case LedFeedbackClass:
+ if (len != (sizeof(xLedFeedbackCtl)>>2))
+ {
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl,
+ 0, BadLength);
+ return Success;
+ }
+ for (l=dev->leds; l; l=l->next)
+ if (l->ctrl.id == ((xLedFeedbackCtl *) &stuff[1])->id)
+ {
+ ChangeLedFeedback (client, dev, stuff->mask, l, (xLedFeedbackCtl *)&stuff[1]);
+ return Success;
+ }
+ break;
+ case BellFeedbackClass:
+ if (len != (sizeof(xBellFeedbackCtl)>>2))
+ {
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl,
+ 0, BadLength);
+ return Success;
+ }
+ for (b=dev->bell; b; b=b->next)
+ if (b->ctrl.id == ((xBellFeedbackCtl *) &stuff[1])->id)
+ {
+ ChangeBellFeedback (client, dev, stuff->mask, b, (xBellFeedbackCtl *)&stuff[1]);
+ return Success;
+ }
+ break;
+ default:
+ break;
+ }
+
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl, 0, BadMatch);
+ return Success;
+ }
+
+/******************************************************************************
+ *
+ * This procedure changes KbdFeedbackClass data.
+ *
+ */
+
+int
+ChangeKbdFeedback (client, dev, mask, k, f)
+ ClientPtr client;
+ DeviceIntPtr dev;
+ unsigned long mask;
+ KbdFeedbackPtr k;
+ xKbdFeedbackCtl *f;
+ {
+ register char n;
+ KeybdCtrl kctrl;
+ int t;
+ int key = DO_ALL;
+
+ if (client->swapped)
+ {
+ swaps(&f->length,n);
+ swaps(&f->pitch,n);
+ swaps(&f->duration,n);
+ swapl(&f->led_mask,n);
+ swapl(&f->led_values,n);
+ }
+
+ kctrl = k->ctrl;
+ if (mask & DvKeyClickPercent)
+ {
+ t = f->click;
+ if (t == -1)
+ t = defaultKeyboardControl.click;
+ else if (t < 0 || t > 100)
+ {
+ client->errorValue = t;
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl, 0,
+ BadValue);
+ return Success;
+ }
+ kctrl.click = t;
+ }
+
+ if (mask & DvPercent)
+ {
+ t = f->percent;
+ if (t == -1)
+ t = defaultKeyboardControl.bell;
+ else if (t < 0 || t > 100)
+ {
+ client->errorValue = t;
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl, 0,
+ BadValue);
+ return Success;
+ }
+ kctrl.bell = t;
+ }
+
+ if (mask & DvPitch)
+ {
+ t = f->pitch;
+ if (t == -1)
+ t = defaultKeyboardControl.bell_pitch;
+ else if (t < 0)
+ {
+ client->errorValue = t;
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl, 0,
+ BadValue);
+ return Success;
+ }
+ kctrl.bell_pitch = t;
+ }
+
+ if (mask & DvDuration)
+ {
+ t = f->duration;
+ if (t == -1)
+ t = defaultKeyboardControl.bell_duration;
+ else if (t < 0)
+ {
+ client->errorValue = t;
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl, 0,
+ BadValue);
+ return Success;
+ }
+ kctrl.bell_duration = t;
+ }
+
+ if (mask & DvLed)
+ {
+ kctrl.leds &= ~(f->led_mask);
+ kctrl.leds |= (f->led_mask & f->led_values);
+ }
+
+ if (mask & DvKey)
+ {
+ key = (KeyCode) f->key;
+ if (key < 8 || key > 255)
+ {
+ client->errorValue = key;
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl, 0,
+ BadValue);
+ return Success;
+ }
+ if (!(mask & DvAutoRepeatMode))
+ {
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl, 0,
+ BadMatch);
+ return Success;
+ }
+ }
+
+ if (mask & DvAutoRepeatMode)
+ {
+ int inx = (key >> 3);
+ int kmask = (1 << (key & 7));
+ t = (CARD8) f->auto_repeat_mode;
+ if (t == AutoRepeatModeOff)
+ {
+ if (key == DO_ALL)
+ kctrl.autoRepeat = FALSE;
+ else
+ kctrl.autoRepeats[inx] &= ~kmask;
+ }
+ else if (t == AutoRepeatModeOn)
+ {
+ if (key == DO_ALL)
+ kctrl.autoRepeat = TRUE;
+ else
+ kctrl.autoRepeats[inx] |= kmask;
+ }
+ else if (t == AutoRepeatModeDefault)
+ {
+ if (key == DO_ALL)
+ kctrl.autoRepeat = defaultKeyboardControl.autoRepeat;
+ else
+ kctrl.autoRepeats[inx] &= ~kmask;
+ kctrl.autoRepeats[inx] =
+ (kctrl.autoRepeats[inx] & ~kmask) |
+ (defaultKeyboardControl.autoRepeats[inx] & kmask);
+ }
+ else
+ {
+ client->errorValue = t;
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl, 0,
+ BadValue);
+ return Success;
+ }
+ }
+
+ k->ctrl = kctrl;
+ (*k->CtrlProc)(dev, &k->ctrl);
+ return Success;
+ }
+
+/******************************************************************************
+ *
+ * This procedure changes PtrFeedbackClass data.
+ *
+ */
+
+int
+ChangePtrFeedback (client, dev, mask, p, f)
+ ClientPtr client;
+ DeviceIntPtr dev;
+ unsigned long mask;
+ PtrFeedbackPtr p;
+ xPtrFeedbackCtl *f;
+ {
+ register char n;
+ PtrCtrl pctrl; /* might get BadValue part way through */
+
+ if (client->swapped)
+ {
+ swaps(&f->length,n);
+ swaps(&f->num,n);
+ swaps(&f->denom,n);
+ swaps(&f->thresh,n);
+ }
+
+ pctrl = p->ctrl;
+ if (mask & DvAccelNum)
+ {
+ int accelNum;
+
+ accelNum = f->num;
+ if (accelNum == -1)
+ pctrl.num = defaultPointerControl.num;
+ else if (accelNum < 0)
+ {
+ client->errorValue = accelNum;
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl, 0,
+ BadValue);
+ return Success;
+ }
+ else pctrl.num = accelNum;
+ }
+
+ if (mask & DvAccelDenom)
+ {
+ int accelDenom;
+
+ accelDenom = f->denom;
+ if (accelDenom == -1)
+ pctrl.den = defaultPointerControl.den;
+ else if (accelDenom <= 0)
+ {
+ client->errorValue = accelDenom;
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl, 0,
+ BadValue);
+ return Success;
+ }
+ else pctrl.den = accelDenom;
+ }
+
+ if (mask & DvThreshold)
+ {
+ int threshold;
+
+ threshold = f->thresh;
+ if (threshold == -1)
+ pctrl.threshold = defaultPointerControl.threshold;
+ else if (threshold < 0)
+ {
+ client->errorValue = threshold;
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl, 0,
+ BadValue);
+ return Success;
+ }
+ else pctrl.threshold = threshold;
+ }
+
+ p->ctrl = pctrl;
+ (*p->CtrlProc)(dev, &p->ctrl);
+ return Success;
+ }
+
+/******************************************************************************
+ *
+ * This procedure changes IntegerFeedbackClass data.
+ *
+ */
+
+int
+ChangeIntegerFeedback (client, dev, mask, i, f)
+ ClientPtr client;
+ DeviceIntPtr dev;
+ unsigned long mask;
+ IntegerFeedbackPtr i;
+ xIntegerFeedbackCtl *f;
+ {
+ register char n;
+
+ if (client->swapped)
+ {
+ swaps(&f->length,n);
+ swapl(&f->int_to_display,n);
+ }
+
+ i->ctrl.integer_displayed = f->int_to_display;
+ (*i->CtrlProc)(dev, &i->ctrl);
+ return Success;
+ }
+
+/******************************************************************************
+ *
+ * This procedure changes StringFeedbackClass data.
+ *
+ */
+
+int
+ChangeStringFeedback (client, dev, mask, s, f)
+ ClientPtr client;
+ DeviceIntPtr dev;
+ unsigned long mask;
+ StringFeedbackPtr s;
+ xStringFeedbackCtl *f;
+ {
+ register char n;
+ register long *p;
+ int i, j;
+ KeySym *syms, *sup_syms;
+
+ syms = (KeySym *) (f+1);
+ if (client->swapped)
+ {
+ swaps(&f->length,n); /* swapped num_keysyms in calling proc */
+ p = (long *) (syms);
+ for (i=0; i<f->num_keysyms; i++)
+ {
+ swapl(p, n);
+ p++;
+ }
+ }
+
+ if (f->num_keysyms > s->ctrl.max_symbols)
+ {
+ SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
+ BadValue);
+ return Success;
+ }
+ sup_syms = s->ctrl.symbols_supported;
+ for (i=0; i<f->num_keysyms; i++)
+ {
+ for (j=0; j<s->ctrl.num_symbols_supported; j++)
+ if (*(syms+i) == *(sup_syms+j))
+ break;
+ if (j==s->ctrl.num_symbols_supported)
+ {
+ SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
+ BadMatch);
+ return Success;
+ }
+ }
+
+ s->ctrl.num_symbols_displayed = f->num_keysyms;
+ for (i=0; i<f->num_keysyms; i++)
+ *(s->ctrl.symbols_displayed+i) = *(syms+i);
+ (*s->CtrlProc)(dev, &s->ctrl);
+ return Success;
+ }
+
+/******************************************************************************
+ *
+ * This procedure changes BellFeedbackClass data.
+ *
+ */
+
+int
+ChangeBellFeedback (client, dev, mask, b, f)
+ ClientPtr client;
+ DeviceIntPtr dev;
+ unsigned long mask;
+ BellFeedbackPtr b;
+ xBellFeedbackCtl *f;
+ {
+ register char n;
+ int t;
+ BellCtrl bctrl; /* might get BadValue part way through */
+
+ if (client->swapped)
+ {
+ swaps(&f->length,n);
+ swaps(&f->pitch,n);
+ swaps(&f->duration,n);
+ }
+
+ bctrl = b->ctrl;
+ if (mask & DvPercent)
+ {
+ t = f->percent;
+ if (t == -1)
+ t = defaultKeyboardControl.bell;
+ else if (t < 0 || t > 100)
+ {
+ client->errorValue = t;
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl, 0,
+ BadValue);
+ return Success;
+ }
+ bctrl.percent = t;
+ }
+
+ if (mask & DvPitch)
+ {
+ t = f->pitch;
+ if (t == -1)
+ t = defaultKeyboardControl.bell_pitch;
+ else if (t < 0)
+ {
+ client->errorValue = t;
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl, 0,
+ BadValue);
+ return Success;
+ }
+ bctrl.pitch = t;
+ }
+
+ if (mask & DvDuration)
+ {
+ t = f->duration;
+ if (t == -1)
+ t = defaultKeyboardControl.bell_duration;
+ else if (t < 0)
+ {
+ client->errorValue = t;
+ SendErrorToClient (client, IReqCode, X_ChangeFeedbackControl, 0,
+ BadValue);
+ return Success;
+ }
+ bctrl.duration = t;
+ }
+ b->ctrl = bctrl;
+ (*b->CtrlProc)(dev, &b->ctrl);
+ return Success;
+ }
+
+/******************************************************************************
+ *
+ * This procedure changes LedFeedbackClass data.
+ *
+ */
+
+int
+ChangeLedFeedback (client, dev, mask, l, f)
+ ClientPtr client;
+ DeviceIntPtr dev;
+ unsigned long mask;
+ LedFeedbackPtr l;
+ xLedFeedbackCtl *f;
+ {
+ register char n;
+ LedCtrl lctrl; /* might get BadValue part way through */
+
+ if (client->swapped)
+ {
+ swaps(&f->length,n);
+ swapl(&f->led_values,n);
+ swapl(&f->led_mask,n);
+ }
+
+ f->led_mask &= l->ctrl.led_mask; /* set only supported leds */
+ f->led_values &= l->ctrl.led_mask; /* set only supported leds */
+ if (mask & DvLed)
+ {
+ lctrl.led_mask = f->led_mask;
+ lctrl.led_values = f->led_values;
+ (*l->CtrlProc)(dev, &lctrl);
+ l->ctrl.led_values &= ~(f->led_mask); /* zero changed leds */
+ l->ctrl.led_values |= (f->led_mask & f->led_values);/* OR in set leds*/
+ }
+
+ return Success;
+ }
diff --git a/nx-X11/programs/Xserver/Xi/chgfctl.h b/nx-X11/programs/Xserver/Xi/chgfctl.h
new file mode 100644
index 000000000..94dab2814
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/chgfctl.h
@@ -0,0 +1,98 @@
+/* $XFree86: xc/programs/Xserver/Xi/chgfctl.h,v 3.1 1996/04/15 11:18:26 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef CHGFCTL_H
+#define CHGFCTL_H 1
+
+int
+SProcXChangeFeedbackControl(
+ ClientPtr /* client */
+ );
+
+int
+ProcXChangeFeedbackControl(
+ ClientPtr /* client */
+ );
+
+int
+ChangeKbdFeedback (
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ unsigned long /* mask */,
+ KbdFeedbackPtr /* k */,
+ xKbdFeedbackCtl * /* f */
+ );
+
+int
+ChangePtrFeedback (
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ unsigned long /* mask */,
+ PtrFeedbackPtr /* p */,
+ xPtrFeedbackCtl * /* f */
+ );
+
+int
+ChangeIntegerFeedback (
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ unsigned long /* mask */,
+ IntegerFeedbackPtr /* i */,
+ xIntegerFeedbackCtl * /* f */
+ );
+
+int
+ChangeStringFeedback (
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ unsigned long /* mask */,
+ StringFeedbackPtr /* s */,
+ xStringFeedbackCtl * /* f */
+ );
+
+int
+ChangeBellFeedback (
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ unsigned long /* mask */,
+ BellFeedbackPtr /* b */,
+ xBellFeedbackCtl * /* f */
+ );
+
+int
+ChangeLedFeedback (
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ unsigned long /* mask */,
+ LedFeedbackPtr /* l */,
+ xLedFeedbackCtl * /* f */
+ );
+
+#endif /* CHGFCTL_H */
diff --git a/nx-X11/programs/Xserver/Xi/chgkbd.c b/nx-X11/programs/Xserver/Xi/chgkbd.c
new file mode 100644
index 000000000..a8a6024d8
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/chgkbd.c
@@ -0,0 +1,216 @@
+/* $Xorg: chgkbd.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/chgkbd.c,v 3.5 2001/08/23 14:56:19 alanh Exp $ */
+
+/***********************************************************************
+ *
+ * Extension function to change the keyboard device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h"
+#include "globals.h"
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+
+#include "exevents.h"
+#include "exglobals.h"
+
+#include "chgkbd.h"
+#include "chgptr.h"
+
+/***********************************************************************
+ *
+ * This procedure changes the keyboard device.
+ *
+ */
+
+int
+SProcXChangeKeyboardDevice(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xChangeKeyboardDeviceReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xChangeKeyboardDeviceReq);
+ return(ProcXChangeKeyboardDevice(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure is invoked to swap the request bytes if the server and
+ * client have a different byte order.
+ *
+ */
+
+int
+ProcXChangeKeyboardDevice (client)
+ register ClientPtr client;
+ {
+ int i;
+ DeviceIntPtr xkbd = inputInfo.keyboard;
+ DeviceIntPtr dev;
+ FocusClassPtr xf = xkbd->focus;
+ FocusClassPtr df;
+ KeyClassPtr k;
+ xChangeKeyboardDeviceReply rep;
+ changeDeviceNotify ev;
+
+ REQUEST(xChangeKeyboardDeviceReq);
+ REQUEST_SIZE_MATCH(xChangeKeyboardDeviceReq);
+
+ rep.repType = X_Reply;
+ rep.RepType = X_ChangeKeyboardDevice;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ rep.status = -1;
+ SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
+ BadDevice);
+ return Success;
+ }
+
+ k = dev->key;
+ if (k == NULL)
+ {
+ rep.status = -1;
+ SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
+ BadMatch);
+ return Success;
+ }
+
+ if (((dev->grab) && !SameClient(dev->grab, client)) ||
+ ((xkbd->grab) && !SameClient(xkbd->grab, client)))
+ rep.status = AlreadyGrabbed;
+ else if ((dev->sync.frozen &&
+ dev->sync.other && !SameClient(dev->sync.other, client)) ||
+ (xkbd->sync.frozen &&
+ xkbd->sync.other && !SameClient(xkbd->sync.other, client)))
+ rep.status = GrabFrozen;
+ else
+ {
+ if (ChangeKeyboardDevice (xkbd, dev) != Success)
+ {
+ SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
+ BadDevice);
+ return Success;
+ }
+ if (!dev->focus)
+ InitFocusClassDeviceStruct (dev);
+ if (!dev->kbdfeed)
+ InitKbdFeedbackClassDeviceStruct(dev, (BellProcPtr)NoopDDA,
+ (KbdCtrlProcPtr)NoopDDA);
+ df = dev->focus;
+ df->win = xf->win;
+ df->revert = xf->revert;
+ df->time = xf->time;
+ df->traceGood = xf->traceGood;
+ if (df->traceSize != xf->traceSize)
+ {
+ Must_have_memory = TRUE; /* XXX */
+ df->trace = (WindowPtr *) xrealloc(df->trace,
+ xf->traceSize * sizeof(WindowPtr));
+ Must_have_memory = FALSE; /* XXX */
+ }
+ df->traceSize = xf->traceSize;
+ for (i=0; i<df->traceSize; i++)
+ df->trace[i] = xf->trace[i];
+ RegisterOtherDevice (xkbd);
+ RegisterKeyboardDevice (dev);
+
+ ev.type = ChangeDeviceNotify;
+ ev.deviceid = stuff->deviceid;
+ ev.time = currentTime.milliseconds;
+ ev.request = NewKeyboard;
+
+ SendEventToAllWindows (dev, ChangeDeviceNotifyMask, (xEvent *)&ev, 1);
+ SendMappingNotify (MappingKeyboard, k->curKeySyms.minKeyCode,
+ k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode + 1,client);
+
+ rep.status = 0;
+ }
+
+ WriteReplyToClient (client, sizeof (xChangeKeyboardDeviceReply),
+ &rep);
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XChangeKeyboardDevice
+ * function, if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXChangeKeyboardDevice (client, size, rep)
+ ClientPtr client;
+ int size;
+ xChangeKeyboardDeviceReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/chgkbd.h b/nx-X11/programs/Xserver/Xi/chgkbd.h
new file mode 100644
index 000000000..ddb17e3c4
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/chgkbd.h
@@ -0,0 +1,52 @@
+/* $XFree86: xc/programs/Xserver/Xi/chgkbd.h,v 3.1 1996/04/15 11:18:27 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef CHGKBD_H
+#define CHGKBD_H 1
+
+int
+SProcXChangeKeyboardDevice(
+ ClientPtr /* client */
+ );
+
+int
+ProcXChangeKeyboardDevice (
+ ClientPtr /* client */
+ );
+
+void
+SRepXChangeKeyboardDevice (
+ ClientPtr /* client */,
+ int /* size */,
+ xChangeKeyboardDeviceReply * /* rep */
+ );
+
+
+#endif /* CHGKBD_H */
diff --git a/nx-X11/programs/Xserver/Xi/chgkmap.c b/nx-X11/programs/Xserver/Xi/chgkmap.c
new file mode 100644
index 000000000..6b2a15aa2
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/chgkmap.c
@@ -0,0 +1,136 @@
+/* $Xorg: chgkmap.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/chgkmap.c,v 3.2 2001/01/17 22:13:24 dawes Exp $ */
+
+/********************************************************************
+ *
+ * Change key mapping for an extension device.
+ *
+ */
+
+#define NEED_EVENTS /* for inputstr.h */
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exevents.h"
+#include "exglobals.h"
+
+#include "chgkmap.h"
+
+/***********************************************************************
+ *
+ * This procedure swaps the request when the client and
+ * server have different byte orderings.
+ *
+ */
+
+int
+SProcXChangeDeviceKeyMapping(client)
+ register ClientPtr client;
+ {
+ register char n;
+ register long *p;
+ register int i, count;
+
+ REQUEST(xChangeDeviceKeyMappingReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xChangeDeviceKeyMappingReq);
+ p = (long *) &stuff[1];
+ count = stuff->keyCodes * stuff->keySymsPerKeyCode;
+ for (i = 0; i < count; i++)
+ {
+ swapl(p, n);
+ p++;
+ }
+ return(ProcXChangeDeviceKeyMapping(client));
+ }
+
+/***********************************************************************
+ *
+ * Change the device key mapping.
+ *
+ */
+
+int
+ProcXChangeDeviceKeyMapping(client)
+ register ClientPtr client;
+ {
+ int ret;
+ unsigned len;
+ DeviceIntPtr dev;
+
+ REQUEST(xChangeDeviceKeyMappingReq);
+ REQUEST_AT_LEAST_SIZE(xChangeDeviceKeyMappingReq);
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient (client, IReqCode, X_ChangeDeviceKeyMapping, 0,
+ BadDevice);
+ return Success;
+ }
+ len = stuff->length - (sizeof(xChangeDeviceKeyMappingReq) >> 2);
+
+ ret = ChangeKeyMapping (client, dev, len, DeviceMappingNotify,
+ stuff->firstKeyCode, stuff->keyCodes, stuff->keySymsPerKeyCode,
+ (KeySym *)&stuff[1]);
+
+ if (ret != Success)
+ SendErrorToClient (client, IReqCode, X_ChangeDeviceKeyMapping, 0,
+ ret);
+ return Success;
+ }
diff --git a/nx-X11/programs/Xserver/Xi/chgkmap.h b/nx-X11/programs/Xserver/Xi/chgkmap.h
new file mode 100644
index 000000000..5e65a5b36
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/chgkmap.h
@@ -0,0 +1,44 @@
+/* $XFree86: xc/programs/Xserver/Xi/chgkmap.h,v 3.1 1996/04/15 11:18:28 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef CHGKMAP_H
+#define CHGKMAP_H 1
+
+int
+SProcXChangeDeviceKeyMapping(
+ ClientPtr /* client */
+ );
+
+int
+ProcXChangeDeviceKeyMapping(
+ ClientPtr /* client */
+ );
+
+#endif /* CHGKMAP_H */
diff --git a/nx-X11/programs/Xserver/Xi/chgprop.c b/nx-X11/programs/Xserver/Xi/chgprop.c
new file mode 100644
index 000000000..20c654e2f
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/chgprop.c
@@ -0,0 +1,174 @@
+/* $Xorg: chgprop.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/chgprop.c,v 3.2 2001/01/17 22:13:24 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Function to modify the dont-propagate-list for an extension input device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h"
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+
+#include "exevents.h"
+#include "exglobals.h"
+
+#include "chgprop.h"
+#include "grabdev.h"
+
+/***********************************************************************
+ *
+ * This procedure returns the extension version.
+ *
+ */
+
+int
+SProcXChangeDeviceDontPropagateList(client)
+ register ClientPtr client;
+ {
+ register char n;
+ register long *p;
+ register int i;
+
+ REQUEST(xChangeDeviceDontPropagateListReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq);
+ swapl(&stuff->window, n);
+ swaps(&stuff->count, n);
+ p = (long *) &stuff[1];
+ for (i=0; i<stuff->count; i++)
+ {
+ swapl(p, n);
+ p++;
+ }
+ return(ProcXChangeDeviceDontPropagateList(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure changes the dont-propagate list for the specified window.
+ *
+ */
+
+int
+ProcXChangeDeviceDontPropagateList (client)
+ register ClientPtr client;
+ {
+ int i;
+ WindowPtr pWin;
+ struct tmask tmp[EMASKSIZE];
+ OtherInputMasks *others;
+
+ REQUEST(xChangeDeviceDontPropagateListReq);
+ REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq);
+
+ if (stuff->length !=(sizeof(xChangeDeviceDontPropagateListReq)>>2) +
+ stuff->count)
+ {
+ SendErrorToClient (client, IReqCode, X_ChangeDeviceDontPropagateList, 0,
+ BadLength);
+ return Success;
+ }
+
+ pWin = (WindowPtr) LookupWindow (stuff->window, client);
+ if (!pWin)
+ {
+ client->errorValue = stuff->window;
+ SendErrorToClient(client, IReqCode, X_ChangeDeviceDontPropagateList, 0,
+ BadWindow);
+ return Success;
+ }
+
+ if (stuff->mode != AddToList && stuff->mode != DeleteFromList)
+ {
+ client->errorValue = stuff->window;
+ SendErrorToClient(client, IReqCode, X_ChangeDeviceDontPropagateList, 0,
+ BadMode);
+ return Success;
+ }
+
+ if (CreateMaskFromList (client, (XEventClass *)&stuff[1],
+ stuff->count, tmp, NULL, X_ChangeDeviceDontPropagateList) != Success)
+ return Success;
+
+ others = wOtherInputMasks(pWin);
+ if (!others && stuff->mode == DeleteFromList)
+ return Success;
+ for (i=0; i<EMASKSIZE; i++)
+ {
+ if (tmp[i].mask == 0)
+ continue;
+
+ if (stuff->mode == DeleteFromList)
+ tmp[i].mask = (others->dontPropagateMask[i] & ~tmp[i].mask);
+ else if (others)
+ tmp[i].mask |= others->dontPropagateMask[i];
+
+ if (DeviceEventSuppressForWindow (pWin,client,tmp[i].mask,i) != Success)
+ {
+ SendErrorToClient ( client, IReqCode, X_ChangeDeviceDontPropagateList, 0,
+ BadClass);
+ return Success;
+ }
+ }
+
+ return Success;
+ }
diff --git a/nx-X11/programs/Xserver/Xi/chgprop.h b/nx-X11/programs/Xserver/Xi/chgprop.h
new file mode 100644
index 000000000..7395bc25c
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/chgprop.h
@@ -0,0 +1,44 @@
+/* $XFree86: xc/programs/Xserver/Xi/chgprop.h,v 3.1 1996/04/15 11:18:29 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef CHGPROP_H
+#define CHGPROP_H 1
+
+int
+SProcXChangeDeviceDontPropagateList (
+ ClientPtr /* client */
+ );
+
+int
+ProcXChangeDeviceDontPropagateList (
+ ClientPtr /* client */
+ );
+
+#endif /* CHGPROP_H */
diff --git a/nx-X11/programs/Xserver/Xi/chgptr.c b/nx-X11/programs/Xserver/Xi/chgptr.c
new file mode 100644
index 000000000..bf2abd6b6
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/chgptr.c
@@ -0,0 +1,262 @@
+/* $Xorg: chgptr.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/chgptr.c,v 3.6 2001/08/23 14:56:19 alanh Exp $ */
+
+/***********************************************************************
+ *
+ * Extension function to change the pointer device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h"
+#include "windowstr.h" /* window structure */
+#include "scrnintstr.h" /* screen structure */
+
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+
+#include "dixevents.h"
+#include "exevents.h"
+#include "exglobals.h"
+
+#include "chgptr.h"
+
+/***********************************************************************
+ *
+ * This procedure is invoked to swap the request bytes if the server and
+ * client have a different byte order.
+ *
+ */
+
+int
+SProcXChangePointerDevice(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xChangePointerDeviceReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xChangePointerDeviceReq);
+ return(ProcXChangePointerDevice(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure changes the device used as the X pointer.
+ *
+ */
+
+int
+ProcXChangePointerDevice (client)
+ register ClientPtr client;
+ {
+ DeviceIntPtr xptr = inputInfo.pointer;
+ DeviceIntPtr dev;
+ ValuatorClassPtr v;
+ xChangePointerDeviceReply rep;
+ changeDeviceNotify ev;
+
+ REQUEST(xChangePointerDeviceReq);
+ REQUEST_SIZE_MATCH(xChangePointerDeviceReq);
+
+ rep.repType = X_Reply;
+ rep.RepType = X_ChangePointerDevice;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ rep.status = -1;
+ SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0,
+ BadDevice);
+ return Success;
+ }
+
+ v = dev->valuator;
+ if (v == NULL || v->numAxes < 2 ||
+ stuff->xaxis >= v->numAxes ||
+ stuff->yaxis >= v->numAxes)
+ {
+ rep.status = -1;
+ SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0, BadMatch);
+ return Success;
+ }
+
+ if (((dev->grab) && !SameClient(dev->grab, client)) ||
+ ((xptr->grab) && !SameClient(xptr->grab, client)))
+ rep.status = AlreadyGrabbed;
+ else if ((dev->sync.frozen &&
+ dev->sync.other && !SameClient(dev->sync.other, client)) ||
+ (xptr->sync.frozen &&
+ xptr->sync.other && !SameClient(xptr->sync.other, client)))
+ rep.status = GrabFrozen;
+ else
+ {
+ if (ChangePointerDevice (
+ xptr, dev, stuff->xaxis, stuff->yaxis) != Success)
+ {
+ SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0,
+ BadDevice);
+ return Success;
+ }
+ if (dev->focus)
+ DeleteFocusClassDeviceStruct(dev);
+ if (!dev->button)
+ InitButtonClassDeviceStruct (dev, 0, NULL);
+ if (!dev->ptrfeed)
+ InitPtrFeedbackClassDeviceStruct(dev, (PtrCtrlProcPtr)NoopDDA);
+ RegisterOtherDevice (xptr);
+ RegisterPointerDevice (dev);
+
+ ev.type = ChangeDeviceNotify;
+ ev.deviceid = stuff->deviceid;
+ ev.time = currentTime.milliseconds;
+ ev.request = NewPointer;
+
+ SendEventToAllWindows (dev, ChangeDeviceNotifyMask, (xEvent *)&ev, 1);
+ SendMappingNotify (MappingPointer, 0, 0, client);
+
+ rep.status = 0;
+ }
+
+ WriteReplyToClient (client, sizeof (xChangePointerDeviceReply),
+ &rep);
+ return Success;
+ }
+
+void
+DeleteFocusClassDeviceStruct(dev)
+ DeviceIntPtr dev;
+ {
+ xfree(dev->focus->trace);
+ xfree(dev->focus);
+ dev->focus = NULL;
+ }
+
+/***********************************************************************
+ *
+ * Send an event to interested clients in all windows on all screens.
+ *
+ */
+
+void
+SendEventToAllWindows (dev, mask, ev, count)
+ DeviceIntPtr dev;
+ Mask mask;
+ xEvent *ev;
+ int count;
+ {
+ int i;
+ WindowPtr pWin, p1;
+
+ for (i=0; i<screenInfo.numScreens; i++)
+ {
+ pWin = WindowTable[i];
+ (void)DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, dev->id);
+ p1 = pWin->firstChild;
+ FindInterestedChildren (dev, p1, mask, ev, count);
+ }
+ }
+
+/***********************************************************************
+ *
+ * Walk through the window tree, finding all clients that want to know
+ * about the ChangeDeviceNotify Event.
+ *
+ */
+
+void
+FindInterestedChildren (dev, p1, mask, ev, count)
+ DeviceIntPtr dev;
+ WindowPtr p1;
+ Mask mask;
+ xEvent *ev;
+ int count;
+ {
+ WindowPtr p2;
+
+ while (p1)
+ {
+ p2 = p1->firstChild;
+ (void)DeliverEventsToWindow(p1, ev, count, mask, NullGrab, dev->id);
+ FindInterestedChildren (dev, p2, mask, ev, count);
+ p1 = p1->nextSib;
+ }
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XChangePointerDevice
+ * function, if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXChangePointerDevice (client, size, rep)
+ ClientPtr client;
+ int size;
+ xChangePointerDeviceReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/chgptr.h b/nx-X11/programs/Xserver/Xi/chgptr.h
new file mode 100644
index 000000000..5b85da13f
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/chgptr.h
@@ -0,0 +1,73 @@
+/* $XFree86: xc/programs/Xserver/Xi/chgptr.h,v 3.1 1996/04/15 11:18:31 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef CHGPTR_H
+#define CHGPTR_H 1
+
+int
+SProcXChangePointerDevice(
+ ClientPtr /* client */
+ );
+
+int
+ProcXChangePointerDevice (
+ ClientPtr /* client */
+ );
+
+void
+DeleteFocusClassDeviceStruct(
+ DeviceIntPtr /* dev */
+ );
+
+void
+SendEventToAllWindows (
+ DeviceIntPtr /* dev */,
+ Mask /* mask */,
+ xEvent * /* ev */,
+ int /* count */
+ );
+
+void
+FindInterestedChildren ( /* FIXME: could be static? */
+ DeviceIntPtr /* dev */,
+ WindowPtr /* p1 */,
+ Mask /* mask */,
+ xEvent * /* ev */,
+ int /* count */
+ );
+
+void
+SRepXChangePointerDevice (
+ ClientPtr /* client */,
+ int /* size */,
+ xChangePointerDeviceReply * /* rep */
+ );
+
+#endif /* CHGPTR_H */
diff --git a/nx-X11/programs/Xserver/Xi/closedev.c b/nx-X11/programs/Xserver/Xi/closedev.c
new file mode 100644
index 000000000..8a57aeeee
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/closedev.c
@@ -0,0 +1,191 @@
+/* $Xorg: closedev.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/closedev.c,v 3.3 2001/08/23 14:56:19 alanh Exp $ */
+
+/***********************************************************************
+ *
+ * Extension function to close an extension input device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
+#include "scrnintstr.h" /* screen structure */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h"
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "closedev.h"
+
+/***********************************************************************
+ *
+ * This procedure closes an input device.
+ *
+ */
+
+int
+SProcXCloseDevice(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xCloseDeviceReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCloseDeviceReq);
+ return(ProcXCloseDevice(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure closes an input device.
+ *
+ */
+
+int
+ProcXCloseDevice(client)
+ register ClientPtr client;
+ {
+ int i;
+ WindowPtr pWin, p1;
+ DeviceIntPtr d;
+
+ REQUEST(xCloseDeviceReq);
+ REQUEST_SIZE_MATCH(xCloseDeviceReq);
+
+ d = LookupDeviceIntRec (stuff->deviceid);
+ if (d == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_CloseDevice, 0, BadDevice);
+ return Success;
+ }
+
+ if (d->grab && SameClient(d->grab, client))
+ (*d->DeactivateGrab)(d); /* release active grab */
+
+ /* Remove event selections from all windows for events from this device
+ and selected by this client.
+ Delete passive grabs from all windows for this device. */
+
+ for (i=0; i<screenInfo.numScreens; i++)
+ {
+ pWin = WindowTable[i];
+ DeleteDeviceEvents (d, pWin, client);
+ p1 = pWin->firstChild;
+ DeleteEventsFromChildren (d, p1, client);
+ }
+
+ CloseInputDevice (d, client);
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * Walk througth the window tree, deleting event selections for this client
+ * from this device from all windows.
+ *
+ */
+
+void
+DeleteEventsFromChildren(dev, p1, client)
+ DeviceIntPtr dev;
+ WindowPtr p1;
+ ClientPtr client;
+ {
+ WindowPtr p2;
+
+ while (p1)
+ {
+ p2 = p1->firstChild;
+ DeleteDeviceEvents (dev, p1, client);
+ DeleteEventsFromChildren(dev, p2, client);
+ p1 = p1->nextSib;
+ }
+ }
+
+/***********************************************************************
+ *
+ * Clear out event selections and passive grabs from a window for the
+ * specified device.
+ *
+ */
+
+void
+DeleteDeviceEvents (dev, pWin, client)
+ DeviceIntPtr dev;
+ WindowPtr pWin;
+ ClientPtr client;
+ {
+ InputClientsPtr others;
+ OtherInputMasks *pOthers;
+ GrabPtr grab, next;
+
+ if ((pOthers = wOtherInputMasks(pWin)) != 0)
+ for (others=pOthers->inputClients; others;
+ others = others->next)
+ if (SameClient(others,client))
+ others->mask[dev->id] = NoEventMask;
+
+ for (grab = wPassiveGrabs(pWin); grab; grab=next)
+ {
+ next = grab->next;
+ if ((grab->device == dev) &&
+ (client->clientAsMask == CLIENT_BITS(grab->resource)))
+ FreeResource (grab->resource, RT_NONE);
+ }
+ }
diff --git a/nx-X11/programs/Xserver/Xi/closedev.h b/nx-X11/programs/Xserver/Xi/closedev.h
new file mode 100644
index 000000000..e4869c96c
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/closedev.h
@@ -0,0 +1,58 @@
+/* $XFree86: xc/programs/Xserver/Xi/closedev.h,v 3.1 1996/04/15 11:18:32 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef CLOSEDEV_H
+#define CLOSEDEV_H 1
+
+int
+SProcXCloseDevice(
+ ClientPtr /* client */
+ );
+
+int
+ProcXCloseDevice(
+ ClientPtr /* client */
+ );
+
+void
+DeleteEventsFromChildren(
+ DeviceIntPtr /* dev */,
+ WindowPtr /* p1 */,
+ ClientPtr /* client */
+ );
+
+void
+DeleteDeviceEvents (
+ DeviceIntPtr /* dev */,
+ WindowPtr /* pWin */,
+ ClientPtr /* client */
+ );
+
+#endif /* CLOSEDEV_H */
diff --git a/nx-X11/programs/Xserver/Xi/devbell.c b/nx-X11/programs/Xserver/Xi/devbell.c
new file mode 100644
index 000000000..bdc941c1c
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/devbell.c
@@ -0,0 +1,173 @@
+/* $Xorg: devbell.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/devbell.c,v 3.2 2001/01/17 22:13:24 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Extension function to change the keyboard device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "devbell.h"
+
+/***********************************************************************
+ *
+ * This procedure is invoked to swap the request bytes if the server and
+ * client have a different byte order.
+ *
+ */
+
+int
+SProcXDeviceBell(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xDeviceBellReq);
+ swaps(&stuff->length, n);
+ return(ProcXDeviceBell(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure rings a bell on an extension device.
+ *
+ */
+
+int
+ProcXDeviceBell (client)
+ register ClientPtr client;
+ {
+ DeviceIntPtr dev;
+ KbdFeedbackPtr k;
+ BellFeedbackPtr b;
+ int base;
+ int newpercent;
+ CARD8 class;
+ pointer ctrl;
+ BellProcPtr proc;
+
+ REQUEST(xDeviceBellReq);
+ REQUEST_SIZE_MATCH(xDeviceBellReq);
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ client->errorValue = stuff->deviceid;
+ SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadDevice);
+ return Success;
+ }
+
+ if (stuff->percent < -100 || stuff->percent > 100)
+ {
+ client->errorValue = stuff->percent;
+ SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue);
+ return Success;
+ }
+ if (stuff->feedbackclass == KbdFeedbackClass)
+ {
+ for (k=dev->kbdfeed; k; k=k->next)
+ if (k->ctrl.id == stuff->feedbackid)
+ break;
+ if (!k)
+ {
+ client->errorValue = stuff->feedbackid;
+ SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue);
+ return Success;
+ }
+ base = k->ctrl.bell;
+ proc = k->BellProc;
+ ctrl = (pointer) &(k->ctrl);
+ class = KbdFeedbackClass;
+ }
+ else if (stuff->feedbackclass == BellFeedbackClass)
+ {
+ for (b=dev->bell; b; b=b->next)
+ if (b->ctrl.id == stuff->feedbackid)
+ break;
+ if (!b)
+ {
+ client->errorValue = stuff->feedbackid;
+ SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue);
+ return Success;
+ }
+ base = b->ctrl.percent;
+ proc = b->BellProc;
+ ctrl = (pointer) &(b->ctrl);
+ class = BellFeedbackClass;
+ }
+ else
+ {
+ client->errorValue = stuff->feedbackclass;
+ SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue);
+ return Success;
+ }
+ newpercent = (base * stuff->percent) / 100;
+ if (stuff->percent < 0)
+ newpercent = base + newpercent;
+ else
+ newpercent = base - newpercent + stuff->percent;
+ (*proc)(newpercent, dev, ctrl, class);
+
+ return Success;
+ }
diff --git a/nx-X11/programs/Xserver/Xi/devbell.h b/nx-X11/programs/Xserver/Xi/devbell.h
new file mode 100644
index 000000000..17cac6f7f
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/devbell.h
@@ -0,0 +1,44 @@
+/* $XFree86: xc/programs/Xserver/Xi/devbell.h,v 3.1 1996/04/15 11:18:32 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef DEVBELL_H
+#define DEVBELL_H 1
+
+int
+SProcXDeviceBell (
+ ClientPtr /* client */
+ );
+
+int
+ProcXDeviceBell (
+ ClientPtr /* client */
+ );
+
+#endif /* DEVBELL_H */
diff --git a/nx-X11/programs/Xserver/Xi/exevents.c b/nx-X11/programs/Xserver/Xi/exevents.c
new file mode 100644
index 000000000..99fbb129a
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/exevents.c
@@ -0,0 +1,1366 @@
+/* $Xorg: exevents.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/exevents.c,v 3.10 2001/12/14 19:58:55 dawes Exp $ */
+
+/********************************************************************
+ *
+ * Routines to register and initialize extension input devices.
+ * This also contains ProcessOtherEvent, the routine called from DDX
+ * to route extension events.
+ *
+ */
+
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "inputstr.h"
+#include "windowstr.h"
+#include "miscstruct.h"
+#include "region.h"
+#include "exevents.h"
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+#include "dixevents.h" /* DeliverFocusedEvent */
+#include "dixgrabs.h" /* CreateGrab() */
+
+#include "chgptr.h"
+
+#define WID(w) ((w) ? ((w)->drawable.id) : 0)
+#define AllModifiersMask ( \
+ ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask | \
+ Mod3Mask | Mod4Mask | Mod5Mask )
+#define AllButtonsMask ( \
+ Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask )
+#define Motion_Filter(class) (DevicePointerMotionMask | \
+ (class)->state | (class)->motionMask)
+
+static Bool ShouldFreeInputMasks(
+ WindowPtr /* pWin */,
+ Bool /* ignoreSelectedEvents */
+ );
+static Bool MakeInputMasks (
+ WindowPtr /* pWin */
+ );
+
+/**************************************************************************
+ *
+ * Procedures for extension device event routing.
+ *
+ */
+
+void
+RegisterOtherDevice (device)
+ DeviceIntPtr device;
+ {
+ device->public.processInputProc = ProcessOtherEvent;
+ device->public.realInputProc = ProcessOtherEvent;
+ (device)->ActivateGrab = ActivateKeyboardGrab;
+ (device)->DeactivateGrab = DeactivateKeyboardGrab;
+ }
+
+/*ARGSUSED*/
+void
+ProcessOtherEvent (xE, other, count)
+ xEventPtr xE;
+ register DeviceIntPtr other;
+ int count;
+ {
+ register BYTE *kptr;
+ register int i;
+ register CARD16 modifiers;
+ register CARD16 mask;
+ GrabPtr grab = other->grab;
+ Bool deactivateDeviceGrab = FALSE;
+ int key = 0, bit = 0, rootX, rootY;
+ ButtonClassPtr b = other->button;
+ KeyClassPtr k = other->key;
+ ValuatorClassPtr v = other->valuator;
+ deviceValuator *xV = (deviceValuator *) xE;
+
+ if (xE->u.u.type != DeviceValuator) {
+ GetSpritePosition(&rootX, &rootY);
+ xE->u.keyButtonPointer.rootX = rootX;
+ xE->u.keyButtonPointer.rootY = rootY;
+ key = xE->u.u.detail;
+ NoticeEventTime(xE);
+ xE->u.keyButtonPointer.state = inputInfo.keyboard->key->state |
+ inputInfo.pointer->button->state;
+ bit = 1 << (key & 7);
+ }
+ if (DeviceEventCallback)
+ {
+ DeviceEventInfoRec eventinfo;
+ eventinfo.events = (xEventPtr) xE;
+ eventinfo.count = count;
+ CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo);
+ }
+ for (i=1; i<count; i++)
+ if ((++xV)->type == DeviceValuator)
+ {
+ int first = xV->first_valuator;
+ int *axisvals;
+
+ if (xV->num_valuators && (!v || (xV->num_valuators && (first + xV->num_valuators > v->numAxes))))
+ FatalError("Bad valuators reported for device %s\n",other->name);
+ xV->device_state = 0;
+ if (k)
+ xV->device_state |= k->state;
+ if (b)
+ xV->device_state |= b->state;
+ if (v && v->axisVal)
+ {
+ axisvals = v->axisVal;
+ switch (xV->num_valuators) {
+ case 6:
+ *(axisvals+first+5) = xV->valuator5;
+ case 5:
+ *(axisvals+first+4) = xV->valuator4;
+ case 4:
+ *(axisvals+first+3) = xV->valuator3;
+ case 3:
+ *(axisvals+first+2) = xV->valuator2;
+ case 2:
+ *(axisvals+first+1) = xV->valuator1;
+ case 1:
+ *(axisvals+first) = xV->valuator0;
+ case 0:
+ default:
+ break;
+ }
+ }
+ }
+
+ if (xE->u.u.type == DeviceKeyPress)
+ {
+ modifiers = k->modifierMap[key];
+ kptr = &k->down[key >> 3];
+ if (*kptr & bit) /* allow ddx to generate multiple downs */
+ {
+ if (!modifiers)
+ {
+ xE->u.u.type = DeviceKeyRelease;
+ ProcessOtherEvent(xE, other, count);
+ xE->u.u.type = DeviceKeyPress;
+ /* release can have side effects, don't fall through */
+ ProcessOtherEvent(xE, other, count);
+ }
+ return;
+ }
+ if (other->valuator)
+ other->valuator->motionHintWindow = NullWindow;
+ *kptr |= bit;
+ k->prev_state = k->state;
+ for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
+ {
+ if (mask & modifiers)
+ {
+ /* This key affects modifier "i" */
+ k->modifierKeyCount[i]++;
+ k->state |= mask;
+ modifiers &= ~mask;
+ }
+ }
+ if (!grab && CheckDeviceGrabs(other, xE, 0, count))
+ {
+ other->activatingKey = key;
+ return;
+ }
+ }
+ else if (xE->u.u.type == DeviceKeyRelease)
+ {
+ kptr = &k->down[key >> 3];
+ if (!(*kptr & bit)) /* guard against duplicates */
+ return;
+ modifiers = k->modifierMap[key];
+ if (other->valuator)
+ other->valuator->motionHintWindow = NullWindow;
+ *kptr &= ~bit;
+ k->prev_state = k->state;
+ for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
+ {
+ if (mask & modifiers)
+ {
+ /* This key affects modifier "i" */
+ if (--k->modifierKeyCount[i] <= 0)
+ {
+ k->modifierKeyCount[i] = 0;
+ k->state &= ~mask;
+ }
+ modifiers &= ~mask;
+ }
+ }
+
+ if (other->fromPassiveGrab && (key == other->activatingKey))
+ deactivateDeviceGrab = TRUE;
+ }
+ else if (xE->u.u.type == DeviceButtonPress)
+ {
+ kptr = &b->down[key >> 3];
+ *kptr |= bit;
+ if (other->valuator)
+ other->valuator->motionHintWindow = NullWindow;
+ b->buttonsDown++;
+ b->motionMask = DeviceButtonMotionMask;
+ xE->u.u.detail = b->map[key];
+ if (xE->u.u.detail == 0)
+ return;
+ if (xE->u.u.detail <= 5)
+ b->state |= (Button1Mask >> 1) << xE->u.u.detail;
+ SetMaskForEvent(Motion_Filter(b),DeviceMotionNotify);
+ if (!grab)
+ if (CheckDeviceGrabs(other, xE, 0, count))
+ return;
+
+ }
+ else if (xE->u.u.type == DeviceButtonRelease)
+ {
+ kptr = &b->down[key >> 3];
+ *kptr &= ~bit;
+ if (other->valuator)
+ other->valuator->motionHintWindow = NullWindow;
+ if (!--b->buttonsDown)
+ b->motionMask = 0;
+ xE->u.u.detail = b->map[key];
+ if (xE->u.u.detail == 0)
+ return;
+ if (xE->u.u.detail <= 5)
+ b->state &= ~((Button1Mask >> 1) << xE->u.u.detail);
+ SetMaskForEvent(Motion_Filter(b),DeviceMotionNotify);
+ if (!b->state && other->fromPassiveGrab)
+ deactivateDeviceGrab = TRUE;
+ }
+ else if (xE->u.u.type == ProximityIn)
+ other->valuator->mode &= ~OutOfProximity;
+ else if (xE->u.u.type == ProximityOut)
+ other->valuator->mode |= OutOfProximity;
+
+ if (grab)
+ DeliverGrabbedEvent(xE, other, deactivateDeviceGrab, count);
+ else if (other->focus)
+ DeliverFocusedEvent(other, xE, GetSpriteWindow(), count);
+ else
+ DeliverDeviceEvents(GetSpriteWindow(), xE, NullGrab, NullWindow,
+ other, count);
+
+ if (deactivateDeviceGrab == TRUE)
+ (*other->DeactivateGrab)(other);
+ }
+
+int
+InitProximityClassDeviceStruct( DeviceIntPtr dev)
+{
+ register ProximityClassPtr proxc;
+
+ proxc = (ProximityClassPtr)xalloc(sizeof(ProximityClassRec));
+ if (!proxc)
+ return FALSE;
+ dev->proximity = proxc;
+ return TRUE;
+}
+
+void
+InitValuatorAxisStruct( DeviceIntPtr dev,
+ int axnum,
+ int minval,
+ int maxval,
+ int resolution,
+ int min_res,
+ int max_res )
+{
+ register AxisInfoPtr ax = dev->valuator->axes + axnum;
+
+ ax->min_value = minval;
+ ax->max_value = maxval;
+ ax->resolution = resolution;
+ ax->min_resolution = min_res;
+ ax->max_resolution = max_res;
+}
+
+static void
+FixDeviceStateNotify (
+ DeviceIntPtr dev,
+ deviceStateNotify *ev,
+ KeyClassPtr k,
+ ButtonClassPtr b,
+ ValuatorClassPtr v,
+ int first)
+{
+ ev->type = DeviceStateNotify;
+ ev->deviceid = dev->id;
+ ev->time = currentTime.milliseconds;
+ ev->classes_reported = 0;
+ ev->num_keys = 0;
+ ev->num_buttons = 0;
+ ev->num_valuators = 0;
+
+ if (b) {
+ ev->classes_reported |= (1 << ButtonClass);
+ ev->num_buttons = b->numButtons;
+ memmove((char *) &ev->buttons[0], (char *) b->down, 4);
+ }
+ else if (k) {
+ ev->classes_reported |= (1 << KeyClass);
+ ev->num_keys = k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode;
+ memmove((char *) &ev->keys[0], (char *) k->down, 4);
+ }
+ if (v) {
+ int nval = v->numAxes - first;
+ ev->classes_reported |= (1 << ValuatorClass);
+ ev->classes_reported |= (dev->valuator->mode << ModeBitsShift);
+ ev->num_valuators = nval < 3 ? nval : 3;
+ switch (ev->num_valuators)
+ {
+ case 3:
+ ev->valuator2 = v->axisVal[first+2];
+ case 2:
+ ev->valuator1 = v->axisVal[first+1];
+ case 1:
+ ev->valuator0 = v->axisVal[first];
+ break;
+ }
+ }
+ }
+
+static void
+FixDeviceValuator (
+ DeviceIntPtr dev,
+ deviceValuator *ev,
+ ValuatorClassPtr v,
+ int first)
+{
+ int nval = v->numAxes - first;
+
+ ev->type = DeviceValuator;
+ ev->deviceid = dev->id;
+ ev->num_valuators = nval < 3 ? nval : 3;
+ ev->first_valuator = first;
+ switch (ev->num_valuators) {
+ case 3:
+ ev->valuator2 = v->axisVal[first+2];
+ case 2:
+ ev->valuator1 = v->axisVal[first+1];
+ case 1:
+ ev->valuator0 = v->axisVal[first];
+ break;
+ }
+ first += ev->num_valuators;
+ }
+
+void
+DeviceFocusEvent(dev, type, mode, detail, pWin)
+ DeviceIntPtr dev;
+ int type, mode, detail;
+ register WindowPtr pWin;
+ {
+ deviceFocus event;
+
+ if (type == FocusIn)
+ type = DeviceFocusIn;
+ else
+ type = DeviceFocusOut;
+
+ event.deviceid = dev->id;
+ event.mode = mode;
+ event.type = type;
+ event.detail = detail;
+ event.window = pWin->drawable.id;
+ event.time = currentTime.milliseconds;
+
+ (void) DeliverEventsToWindow(pWin, (xEvent *)&event, 1,
+ DeviceFocusChangeMask, NullGrab, dev->id);
+
+ if ((type == DeviceFocusIn) &&
+ (wOtherInputMasks(pWin)) &&
+ (wOtherInputMasks(pWin)->inputEvents[dev->id] & DeviceStateNotifyMask))
+ {
+ int evcount = 1;
+ deviceStateNotify *ev, *sev;
+ deviceKeyStateNotify *kev;
+ deviceButtonStateNotify *bev;
+
+ KeyClassPtr k;
+ ButtonClassPtr b;
+ ValuatorClassPtr v;
+ int nval=0, nkeys=0, nbuttons=0, first=0;
+
+ if ((b=dev->button) != NULL) {
+ nbuttons = b->numButtons;
+ if (nbuttons > 32)
+ evcount++;
+ }
+ if ((k=dev->key) != NULL) {
+ nkeys = k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode;
+ if (nkeys > 32)
+ evcount++;
+ if (nbuttons > 0) {
+ evcount++;
+ }
+ }
+ if ((v=dev->valuator) != NULL) {
+ nval = v->numAxes;
+
+ if (nval > 3)
+ evcount++;
+ if (nval > 6) {
+ if (!(k && b))
+ evcount++;
+ if (nval > 9)
+ evcount += ((nval - 7) / 3);
+ }
+ }
+
+ sev = ev = (deviceStateNotify *) xalloc(evcount * sizeof(xEvent));
+ FixDeviceStateNotify (dev, ev, NULL, NULL, NULL, first);
+
+ if (b != NULL) {
+ FixDeviceStateNotify (dev, ev++, NULL, b, v, first);
+ first += 3;
+ nval -= 3;
+ if (nbuttons > 32) {
+ (ev-1)->deviceid |= MORE_EVENTS;
+ bev = (deviceButtonStateNotify *) ev++;
+ bev->type = DeviceButtonStateNotify;
+ bev->deviceid = dev->id;
+ memmove((char *) &bev->buttons[0], (char *) &b->down[4], 28);
+ }
+ if (nval > 0) {
+ (ev-1)->deviceid |= MORE_EVENTS;
+ FixDeviceValuator (dev, (deviceValuator *) ev++, v, first);
+ first += 3;
+ nval -= 3;
+ }
+ }
+
+ if (k != NULL) {
+ FixDeviceStateNotify (dev, ev++, k, NULL, v, first);
+ first += 3;
+ nval -= 3;
+ if (nkeys > 32) {
+ (ev-1)->deviceid |= MORE_EVENTS;
+ kev = (deviceKeyStateNotify *) ev++;
+ kev->type = DeviceKeyStateNotify;
+ kev->deviceid = dev->id;
+ memmove((char *) &kev->keys[0], (char *) &k->down[4], 28);
+ }
+ if (nval > 0) {
+ (ev-1)->deviceid |= MORE_EVENTS;
+ FixDeviceValuator (dev, (deviceValuator *) ev++, v, first);
+ first += 3;
+ nval -= 3;
+ }
+ }
+
+ while (nval > 0) {
+ FixDeviceStateNotify (dev, ev++, NULL, NULL, v, first);
+ first += 3;
+ nval -= 3;
+ if (nval > 0) {
+ (ev-1)->deviceid |= MORE_EVENTS;
+ FixDeviceValuator (dev, (deviceValuator *) ev++, v, first);
+ first += 3;
+ nval -= 3;
+ }
+ }
+
+ (void) DeliverEventsToWindow(pWin, (xEvent *)sev, evcount,
+ DeviceStateNotifyMask, NullGrab, dev->id);
+ xfree (sev);
+ }
+ }
+
+int
+GrabButton(
+ ClientPtr client,
+ DeviceIntPtr dev,
+ BYTE this_device_mode,
+ BYTE other_devices_mode,
+ CARD16 modifiers,
+ DeviceIntPtr modifier_device,
+ CARD8 button,
+ Window grabWindow,
+ BOOL ownerEvents,
+ Cursor rcursor,
+ Window rconfineTo,
+ Mask eventMask)
+{
+ WindowPtr pWin, confineTo;
+ CursorPtr cursor;
+ GrabPtr grab;
+
+ if ((this_device_mode != GrabModeSync) &&
+ (this_device_mode != GrabModeAsync))
+ {
+ client->errorValue = this_device_mode;
+ return BadValue;
+ }
+ if ((other_devices_mode != GrabModeSync) &&
+ (other_devices_mode != GrabModeAsync))
+ {
+ client->errorValue = other_devices_mode;
+ return BadValue;
+ }
+ if ((modifiers != AnyModifier) &&
+ (modifiers & ~AllModifiersMask))
+ {
+ client->errorValue = modifiers;
+ return BadValue;
+ }
+ if ((ownerEvents != xFalse) && (ownerEvents != xTrue))
+ {
+ client->errorValue = ownerEvents;
+ return BadValue;
+ }
+ pWin = LookupWindow(grabWindow, client);
+ if (!pWin)
+ return BadWindow;
+ if (rconfineTo == None)
+ confineTo = NullWindow;
+ else
+ {
+ confineTo = LookupWindow(rconfineTo, client);
+ if (!confineTo)
+ return BadWindow;
+ }
+ if (rcursor == None)
+ cursor = NullCursor;
+ else
+ {
+ cursor = (CursorPtr)LookupIDByType(rcursor, RT_CURSOR);
+ if (!cursor)
+ {
+ client->errorValue = rcursor;
+ return BadCursor;
+ }
+ }
+
+ grab = CreateGrab(client->index, dev, pWin, eventMask,
+ (Bool)ownerEvents, (Bool) this_device_mode, (Bool)other_devices_mode,
+ modifier_device, modifiers, DeviceButtonPress, button, confineTo,
+ cursor);
+ if (!grab)
+ return BadAlloc;
+ return AddPassiveGrabToList(grab);
+ }
+
+int
+GrabKey(
+ ClientPtr client,
+ DeviceIntPtr dev,
+ BYTE this_device_mode,
+ BYTE other_devices_mode,
+ CARD16 modifiers,
+ DeviceIntPtr modifier_device,
+ CARD8 key,
+ Window grabWindow,
+ BOOL ownerEvents,
+ Mask mask)
+{
+ WindowPtr pWin;
+ GrabPtr grab;
+ KeyClassPtr k = dev->key;
+
+ if (k==NULL)
+ return BadMatch;
+ if ((other_devices_mode != GrabModeSync) &&
+ (other_devices_mode != GrabModeAsync))
+ {
+ client->errorValue = other_devices_mode;
+ return BadValue;
+ }
+ if ((this_device_mode != GrabModeSync) &&
+ (this_device_mode != GrabModeAsync))
+ {
+ client->errorValue = this_device_mode;
+ return BadValue;
+ }
+ if (((key > k->curKeySyms.maxKeyCode) ||
+ (key < k->curKeySyms.minKeyCode))
+ && (key != AnyKey))
+ {
+ client->errorValue = key;
+ return BadValue;
+ }
+ if ((modifiers != AnyModifier) &&
+ (modifiers & ~AllModifiersMask))
+ {
+ client->errorValue = modifiers;
+ return BadValue;
+ }
+ if ((ownerEvents != xTrue) && (ownerEvents != xFalse))
+ {
+ client->errorValue = ownerEvents;
+ return BadValue;
+ }
+ pWin = LookupWindow(grabWindow, client);
+ if (!pWin)
+ return BadWindow;
+
+ grab = CreateGrab(client->index, dev, pWin,
+ mask, ownerEvents, this_device_mode, other_devices_mode,
+ modifier_device, modifiers, DeviceKeyPress, key, NullWindow,
+ NullCursor);
+ if (!grab)
+ return BadAlloc;
+ return AddPassiveGrabToList(grab);
+ }
+
+int
+SelectForWindow(dev, pWin, client, mask, exclusivemasks, validmasks)
+ DeviceIntPtr dev;
+ WindowPtr pWin;
+ ClientPtr client;
+ Mask mask;
+ Mask exclusivemasks;
+ Mask validmasks;
+{
+ int mskidx = dev->id;
+ int i, ret;
+ Mask check;
+ InputClientsPtr others;
+
+ if (mask & ~validmasks)
+ {
+ client->errorValue = mask;
+ return BadValue;
+ }
+ check = (mask & exclusivemasks);
+ if (wOtherInputMasks(pWin))
+ {
+ if (check & wOtherInputMasks(pWin)->inputEvents[mskidx])
+ { /* It is illegal for two different
+ clients to select on any of the
+ events for maskcheck. However,
+ it is OK, for some client to
+ continue selecting on one of those
+ events. */
+ for (others = wOtherInputMasks(pWin)->inputClients; others;
+ others = others->next)
+ {
+ if (!SameClient(others, client) && (check &
+ others->mask[mskidx]))
+ return BadAccess;
+ }
+ }
+ for (others = wOtherInputMasks(pWin)->inputClients; others;
+ others = others->next)
+ {
+ if (SameClient(others, client))
+ {
+ check = others->mask[mskidx];
+ others->mask[mskidx] = mask;
+ if (mask == 0)
+ {
+ for (i=0; i<EMASKSIZE; i++)
+ if (i != mskidx && others->mask[i] != 0)
+ break;
+ if (i == EMASKSIZE)
+ {
+ RecalculateDeviceDeliverableEvents(pWin);
+ if (ShouldFreeInputMasks(pWin, FALSE))
+ FreeResource(others->resource, RT_NONE);
+ return Success;
+ }
+ }
+ goto maskSet;
+ }
+ }
+ }
+ check = 0;
+ if ((ret = AddExtensionClient (pWin, client, mask, mskidx)) != Success)
+ return ret;
+maskSet:
+ if (dev->valuator)
+ if ((dev->valuator->motionHintWindow == pWin) &&
+ (mask & DevicePointerMotionHintMask) &&
+ !(check & DevicePointerMotionHintMask) &&
+ !dev->grab)
+ dev->valuator->motionHintWindow = NullWindow;
+ RecalculateDeviceDeliverableEvents(pWin);
+ return Success;
+}
+
+int
+AddExtensionClient (pWin, client, mask, mskidx)
+ WindowPtr pWin;
+ ClientPtr client;
+ Mask mask;
+ int mskidx;
+ {
+ InputClientsPtr others;
+
+ if (!pWin->optional && !MakeWindowOptional (pWin))
+ return BadAlloc;
+ others = (InputClients *) xalloc(sizeof(InputClients));
+ if (!others)
+ return BadAlloc;
+ if (!pWin->optional->inputMasks && !MakeInputMasks (pWin))
+ return BadAlloc;
+ bzero((char *) &others->mask[0], sizeof(Mask)*EMASKSIZE);
+ others->mask[mskidx] = mask;
+ others->resource = FakeClientID(client->index);
+ others->next = pWin->optional->inputMasks->inputClients;
+ pWin->optional->inputMasks->inputClients = others;
+ if (!AddResource(others->resource, RT_INPUTCLIENT, (pointer)pWin))
+ return BadAlloc;
+ return Success;
+ }
+
+static Bool
+MakeInputMasks (pWin)
+ WindowPtr pWin;
+ {
+ struct _OtherInputMasks *imasks;
+
+ imasks = (struct _OtherInputMasks *)
+ xalloc (sizeof (struct _OtherInputMasks));
+ if (!imasks)
+ return FALSE;
+ bzero((char *) imasks, sizeof (struct _OtherInputMasks));
+ pWin->optional->inputMasks = imasks;
+ return TRUE;
+ }
+
+void
+RecalculateDeviceDeliverableEvents(pWin)
+ WindowPtr pWin;
+ {
+ register InputClientsPtr others;
+ struct _OtherInputMasks *inputMasks; /* default: NULL */
+ register WindowPtr pChild, tmp;
+ int i;
+
+ pChild = pWin;
+ while (1)
+ {
+ if ((inputMasks = wOtherInputMasks(pChild)) != 0)
+ {
+ for (others = inputMasks->inputClients; others;
+ others = others->next)
+ {
+ for (i=0; i<EMASKSIZE; i++)
+ inputMasks->inputEvents[i] |= others->mask[i];
+ }
+ for (i=0; i<EMASKSIZE; i++)
+ inputMasks->deliverableEvents[i] = inputMasks->inputEvents[i];
+ for (tmp = pChild->parent; tmp; tmp=tmp->parent)
+ if (wOtherInputMasks(tmp))
+ for (i=0; i<EMASKSIZE; i++)
+ inputMasks->deliverableEvents[i] |=
+ (wOtherInputMasks(tmp)->deliverableEvents[i]
+ & ~inputMasks->dontPropagateMask[i] & PropagateMask[i]);
+ }
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ while (!pChild->nextSib && (pChild != pWin))
+ pChild = pChild->parent;
+ if (pChild == pWin)
+ break;
+ pChild = pChild->nextSib;
+ }
+ }
+
+int
+InputClientGone(pWin, id)
+ register WindowPtr pWin;
+ XID id;
+ {
+ register InputClientsPtr other, prev;
+ if (!wOtherInputMasks(pWin))
+ return(Success);
+ prev = 0;
+ for (other = wOtherInputMasks(pWin)->inputClients; other;
+ other = other->next)
+ {
+ if (other->resource == id)
+ {
+ if (prev)
+ {
+ prev->next = other->next;
+ xfree(other);
+ }
+ else if (!(other->next))
+ {
+ if (ShouldFreeInputMasks(pWin, TRUE))
+ {
+ wOtherInputMasks(pWin)->inputClients = other->next;
+ xfree(wOtherInputMasks(pWin));
+ pWin->optional->inputMasks = (OtherInputMasks *) NULL;
+ CheckWindowOptionalNeed (pWin);
+ xfree(other);
+ }
+ else
+ {
+ other->resource = FakeClientID(0);
+ if (!AddResource(other->resource, RT_INPUTCLIENT,
+ (pointer)pWin))
+ return BadAlloc;
+ }
+ }
+ else
+ {
+ wOtherInputMasks(pWin)->inputClients = other->next;
+ xfree(other);
+ }
+ RecalculateDeviceDeliverableEvents(pWin);
+ return(Success);
+ }
+ prev = other;
+ }
+ FatalError("client not on device event list");
+ /*NOTREACHED*/
+ }
+
+int
+SendEvent (client, d, dest, propagate, ev, mask, count)
+ ClientPtr client;
+ DeviceIntPtr d;
+ Window dest;
+ Bool propagate;
+ xEvent *ev;
+ Mask mask;
+ int count;
+ {
+ WindowPtr pWin;
+ WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */
+ WindowPtr spriteWin=GetSpriteWindow();
+
+ if (dest == PointerWindow)
+ pWin = spriteWin;
+ else if (dest == InputFocus)
+ {
+ WindowPtr inputFocus;
+
+ if (!d->focus)
+ inputFocus = spriteWin;
+ else
+ inputFocus = d->focus->win;
+
+ if (inputFocus == FollowKeyboardWin)
+ inputFocus = inputInfo.keyboard->focus->win;
+
+ if (inputFocus == NoneWin)
+ return Success;
+
+ /* If the input focus is PointerRootWin, send the event to where
+ the pointer is if possible, then perhaps propogate up to root. */
+ if (inputFocus == PointerRootWin)
+ inputFocus = GetCurrentRootWindow();
+
+ if (IsParent(inputFocus, spriteWin))
+ {
+ effectiveFocus = inputFocus;
+ pWin = spriteWin;
+ }
+ else
+ effectiveFocus = pWin = inputFocus;
+ }
+ else
+ pWin = LookupWindow(dest, client);
+ if (!pWin)
+ return BadWindow;
+ if ((propagate != xFalse) && (propagate != xTrue))
+ {
+ client->errorValue = propagate;
+ return BadValue;
+ }
+ ev->u.u.type |= 0x80;
+ if (propagate)
+ {
+ for (;pWin; pWin = pWin->parent)
+ {
+ if (DeliverEventsToWindow( pWin, ev, count, mask, NullGrab, d->id))
+ return Success;
+ if (pWin == effectiveFocus)
+ return Success;
+ if (wOtherInputMasks(pWin))
+ mask &= ~wOtherInputMasks(pWin)->dontPropagateMask[d->id];
+ if (!mask)
+ break;
+ }
+ }
+ else
+ (void)(DeliverEventsToWindow( pWin, ev, count, mask, NullGrab, d->id));
+ return Success;
+ }
+
+int
+SetButtonMapping (client, dev, nElts, map)
+ ClientPtr client;
+ DeviceIntPtr dev;
+ int nElts;
+ BYTE *map;
+ {
+ register int i;
+ ButtonClassPtr b = dev->button;
+
+ if (b == NULL)
+ return BadMatch;
+
+ if (nElts != b->numButtons)
+ {
+ client->errorValue = nElts;
+ return BadValue;
+ }
+ if (BadDeviceMap(&map[0], nElts, 1, 255, &client->errorValue))
+ return BadValue;
+ for (i=0; i < nElts; i++)
+ if ((b->map[i + 1] != map[i]) &&
+ BitIsOn(b->down, i + 1))
+ return MappingBusy;
+ for (i = 0; i < nElts; i++)
+ b->map[i + 1] = map[i];
+ return Success;
+ }
+
+int
+SetModifierMapping(client, dev, len, rlen, numKeyPerModifier, inputMap, k)
+ ClientPtr client;
+ DeviceIntPtr dev;
+ int len;
+ int rlen;
+ int numKeyPerModifier;
+ KeyCode *inputMap;
+ KeyClassPtr *k;
+{
+ KeyCode *map = NULL;
+ int inputMapLen;
+ register int i;
+
+ *k = dev->key;
+ if (*k == NULL)
+ return BadMatch;
+ if (len != ((numKeyPerModifier<<1) + rlen))
+ return BadLength;
+
+ inputMapLen = 8*numKeyPerModifier;
+
+ /*
+ * Now enforce the restriction that "all of the non-zero keycodes must be
+ * in the range specified by min-keycode and max-keycode in the
+ * connection setup (else a Value error)"
+ */
+ i = inputMapLen;
+ while (i--) {
+ if (inputMap[i]
+ && (inputMap[i] < (*k)->curKeySyms.minKeyCode
+ || inputMap[i] > (*k)->curKeySyms.maxKeyCode)) {
+ client->errorValue = inputMap[i];
+ return -1; /* BadValue collides with MappingFailed */
+ }
+ }
+
+ /*
+ * Now enforce the restriction that none of the old or new
+ * modifier keys may be down while we change the mapping, and
+ * that the DDX layer likes the choice.
+ */
+ if (!AllModifierKeysAreUp (dev, (*k)->modifierKeyMap,
+ (int)(*k)->maxKeysPerModifier, inputMap, (int)numKeyPerModifier)
+ ||
+ !AllModifierKeysAreUp(dev, inputMap, (int)numKeyPerModifier,
+ (*k)->modifierKeyMap, (int)(*k)->maxKeysPerModifier)) {
+ return MappingBusy;
+ } else {
+ for (i = 0; i < inputMapLen; i++) {
+ if (inputMap[i] && !LegalModifier(inputMap[i], (DevicePtr)dev)) {
+ return MappingFailed;
+ }
+ }
+ }
+
+ /*
+ * Now build the keyboard's modifier bitmap from the
+ * list of keycodes.
+ */
+ if (inputMapLen) {
+ map = (KeyCode *)xalloc(inputMapLen);
+ if (!map)
+ return BadAlloc;
+ }
+ if ((*k)->modifierKeyMap)
+ xfree((*k)->modifierKeyMap);
+ if (inputMapLen) {
+ (*k)->modifierKeyMap = map;
+ memmove((char *)(*k)->modifierKeyMap, (char *)inputMap, inputMapLen);
+ } else
+ (*k)->modifierKeyMap = NULL;
+
+ (*k)->maxKeysPerModifier = numKeyPerModifier;
+ for (i = 0; i < MAP_LENGTH; i++)
+ (*k)->modifierMap[i] = 0;
+ for (i = 0; i < inputMapLen; i++) if (inputMap[i]) {
+ (*k)->modifierMap[inputMap[i]]
+ |= (1<<(i/ (*k)->maxKeysPerModifier));
+ }
+
+ return(MappingSuccess);
+ }
+
+void
+SendDeviceMappingNotify(
+ CARD8 request,
+ KeyCode firstKeyCode,
+ CARD8 count,
+ DeviceIntPtr dev)
+{
+ xEvent event;
+ deviceMappingNotify *ev = (deviceMappingNotify *) &event;
+
+ ev->type = DeviceMappingNotify;
+ ev->request = request;
+ ev->deviceid = dev->id;
+ ev->time = currentTime.milliseconds;
+ if (request == MappingKeyboard)
+ {
+ ev->firstKeyCode = firstKeyCode;
+ ev->count = count;
+ }
+
+ SendEventToAllWindows (dev, DeviceMappingNotifyMask, (xEvent *)ev, 1);
+ }
+
+int
+ChangeKeyMapping(
+ ClientPtr client,
+ DeviceIntPtr dev,
+ unsigned len,
+ int type,
+ KeyCode firstKeyCode,
+ CARD8 keyCodes,
+ CARD8 keySymsPerKeyCode,
+ KeySym *map)
+{
+ KeySymsRec keysyms;
+ KeyClassPtr k = dev->key;
+
+ if (k == NULL)
+ return (BadMatch);
+
+ if (len != (keyCodes * keySymsPerKeyCode))
+ return BadLength;
+
+ if ((firstKeyCode < k->curKeySyms.minKeyCode) ||
+ (firstKeyCode + keyCodes - 1 > k->curKeySyms.maxKeyCode))
+ {
+ client->errorValue = firstKeyCode;
+ return BadValue;
+ }
+ if (keySymsPerKeyCode == 0)
+ {
+ client->errorValue = 0;
+ return BadValue;
+ }
+ keysyms.minKeyCode = firstKeyCode;
+ keysyms.maxKeyCode = firstKeyCode + keyCodes - 1;
+ keysyms.mapWidth = keySymsPerKeyCode;
+ keysyms.map = map;
+ if (!SetKeySymsMap(&k->curKeySyms, &keysyms))
+ return BadAlloc;
+ SendDeviceMappingNotify(MappingKeyboard, firstKeyCode, keyCodes,
+ dev);
+ return client->noClientException;
+ }
+
+void
+DeleteWindowFromAnyExtEvents(pWin, freeResources)
+ WindowPtr pWin;
+ Bool freeResources;
+ {
+ int i;
+ DeviceIntPtr dev;
+ InputClientsPtr ic;
+ struct _OtherInputMasks *inputMasks;
+
+ for (dev=inputInfo.devices; dev; dev=dev->next)
+ {
+ if (dev == inputInfo.pointer ||
+ dev == inputInfo.keyboard)
+ continue;
+ DeleteDeviceFromAnyExtEvents(pWin, dev);
+ }
+
+ for (dev=inputInfo.off_devices; dev; dev=dev->next)
+ DeleteDeviceFromAnyExtEvents(pWin, dev);
+
+ if (freeResources)
+ while ((inputMasks = wOtherInputMasks(pWin)) != 0)
+ {
+ ic = inputMasks->inputClients;
+ for (i=0; i<EMASKSIZE; i++)
+ inputMasks->dontPropagateMask[i] = 0;
+ FreeResource(ic->resource, RT_NONE);
+ }
+ }
+
+void
+DeleteDeviceFromAnyExtEvents(pWin, dev)
+ WindowPtr pWin;
+ DeviceIntPtr dev;
+ {
+ WindowPtr parent;
+
+ /* Deactivate any grabs performed on this window, before making
+ any input focus changes.
+ Deactivating a device grab should cause focus events. */
+
+ if (dev->grab && (dev->grab->window == pWin))
+ (*dev->DeactivateGrab)(dev);
+
+ /* If the focus window is a root window (ie. has no parent)
+ then don't delete the focus from it. */
+
+ if (dev->focus && (pWin==dev->focus->win) && (pWin->parent != NullWindow))
+ {
+ int focusEventMode = NotifyNormal;
+
+ /* If a grab is in progress, then alter the mode of focus events. */
+
+ if (dev->grab)
+ focusEventMode = NotifyWhileGrabbed;
+
+ switch (dev->focus->revert)
+ {
+ case RevertToNone:
+ DoFocusEvents(dev, pWin, NoneWin, focusEventMode);
+ dev->focus->win = NoneWin;
+ dev->focus->traceGood = 0;
+ break;
+ case RevertToParent:
+ parent = pWin;
+ do
+ {
+ parent = parent->parent;
+ dev->focus->traceGood--;
+ } while (!parent->realized);
+ DoFocusEvents(dev, pWin, parent, focusEventMode);
+ dev->focus->win = parent;
+ dev->focus->revert = RevertToNone;
+ break;
+ case RevertToPointerRoot:
+ DoFocusEvents(dev, pWin, PointerRootWin, focusEventMode);
+ dev->focus->win = PointerRootWin;
+ dev->focus->traceGood = 0;
+ break;
+ case RevertToFollowKeyboard:
+ if (inputInfo.keyboard->focus->win) {
+ DoFocusEvents(dev, pWin, inputInfo.keyboard->focus->win,
+ focusEventMode);
+ dev->focus->win = FollowKeyboardWin;
+ dev->focus->traceGood = 0;
+ } else {
+ DoFocusEvents(dev, pWin, NoneWin, focusEventMode);
+ dev->focus->win = NoneWin;
+ dev->focus->traceGood = 0;
+ }
+ break;
+ }
+ }
+
+ if (dev->valuator)
+ if (dev->valuator->motionHintWindow == pWin)
+ dev->valuator->motionHintWindow = NullWindow;
+ }
+
+int
+MaybeSendDeviceMotionNotifyHint (pEvents, mask)
+ deviceKeyButtonPointer *pEvents;
+ Mask mask;
+ {
+ DeviceIntPtr dev;
+
+ dev = LookupDeviceIntRec (pEvents->deviceid & DEVICE_BITS);
+ if (pEvents->type == DeviceMotionNotify)
+ {
+ if (mask & DevicePointerMotionHintMask)
+ {
+ if (WID(dev->valuator->motionHintWindow) == pEvents->event)
+ {
+ return 1; /* don't send, but pretend we did */
+ }
+ pEvents->detail = NotifyHint;
+ }
+ else
+ {
+ pEvents->detail = NotifyNormal;
+ }
+ }
+ return (0);
+ }
+
+void
+CheckDeviceGrabAndHintWindow (pWin, type, xE, grab, client, deliveryMask)
+ WindowPtr pWin;
+ int type;
+ deviceKeyButtonPointer *xE;
+ GrabPtr grab;
+ ClientPtr client;
+ Mask deliveryMask;
+ {
+ DeviceIntPtr dev;
+
+ dev = LookupDeviceIntRec (xE->deviceid & DEVICE_BITS);
+ if (type == DeviceMotionNotify)
+ dev->valuator->motionHintWindow = pWin;
+ else if ((type == DeviceButtonPress) && (!grab) &&
+ (deliveryMask & DeviceButtonGrabMask))
+ {
+ GrabRec tempGrab;
+
+ tempGrab.device = dev;
+ tempGrab.resource = client->clientAsMask;
+ tempGrab.window = pWin;
+ tempGrab.ownerEvents = (deliveryMask & DeviceOwnerGrabButtonMask) ? TRUE : FALSE;
+ tempGrab.eventMask = deliveryMask;
+ tempGrab.keyboardMode = GrabModeAsync;
+ tempGrab.pointerMode = GrabModeAsync;
+ tempGrab.confineTo = NullWindow;
+ tempGrab.cursor = NullCursor;
+ (*dev->ActivateGrab)(dev, &tempGrab, currentTime, TRUE);
+ }
+ }
+
+Mask
+DeviceEventMaskForClient(dev, pWin, client)
+ DeviceIntPtr dev;
+ WindowPtr pWin;
+ ClientPtr client;
+ {
+ register InputClientsPtr other;
+
+ if (!wOtherInputMasks(pWin))
+ return 0;
+ for (other = wOtherInputMasks(pWin)->inputClients; other;
+ other = other->next)
+ {
+ if (SameClient(other, client))
+ return other->mask[dev->id];
+ }
+ return 0;
+ }
+
+void
+MaybeStopDeviceHint(dev, client)
+ register DeviceIntPtr dev;
+ ClientPtr client;
+{
+ WindowPtr pWin;
+ GrabPtr grab = dev->grab;
+ pWin = dev->valuator->motionHintWindow;
+
+ if ((grab && SameClient(grab, client) &&
+ ((grab->eventMask & DevicePointerMotionHintMask) ||
+ (grab->ownerEvents &&
+ (DeviceEventMaskForClient(dev, pWin, client) &
+ DevicePointerMotionHintMask)))) ||
+ (!grab &&
+ (DeviceEventMaskForClient(dev, pWin, client) &
+ DevicePointerMotionHintMask)))
+ dev->valuator->motionHintWindow = NullWindow;
+}
+
+int
+DeviceEventSuppressForWindow(pWin, client, mask, maskndx)
+ WindowPtr pWin;
+ ClientPtr client;
+ Mask mask;
+ int maskndx;
+ {
+ struct _OtherInputMasks *inputMasks = wOtherInputMasks (pWin);
+
+ if (mask & ~PropagateMask[maskndx])
+ {
+ client->errorValue = mask;
+ return BadValue;
+ }
+
+ if (mask == 0)
+ {
+ if (inputMasks)
+ inputMasks->dontPropagateMask[maskndx] = mask;
+ }
+ else
+ {
+ if (!inputMasks)
+ AddExtensionClient (pWin, client, 0, 0);
+ inputMasks = wOtherInputMasks(pWin);
+ inputMasks->dontPropagateMask[maskndx] = mask;
+ }
+ RecalculateDeviceDeliverableEvents(pWin);
+ if (ShouldFreeInputMasks(pWin, FALSE))
+ FreeResource(inputMasks->inputClients->resource, RT_NONE);
+ return Success;
+ }
+
+static Bool
+ShouldFreeInputMasks (pWin, ignoreSelectedEvents)
+ WindowPtr pWin;
+ Bool ignoreSelectedEvents;
+ {
+ int i;
+ Mask allInputEventMasks = 0;
+ struct _OtherInputMasks *inputMasks = wOtherInputMasks (pWin);
+
+ for (i=0; i<EMASKSIZE; i++)
+ allInputEventMasks |= inputMasks->dontPropagateMask[i];
+ if (!ignoreSelectedEvents)
+ for (i=0; i<EMASKSIZE; i++)
+ allInputEventMasks |= inputMasks->inputEvents[i];
+ if (allInputEventMasks == 0)
+ return TRUE;
+ else
+ return FALSE;
+ }
diff --git a/nx-X11/programs/Xserver/Xi/exglobals.h b/nx-X11/programs/Xserver/Xi/exglobals.h
new file mode 100644
index 000000000..cba6310f4
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/exglobals.h
@@ -0,0 +1,80 @@
+/* $XFree86: xc/programs/Xserver/Xi/exglobals.h,v 3.2 1996/05/06 05:56:03 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*****************************************************************
+ *
+ * Globals referenced elsewhere in the server.
+ *
+ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef EXGLOBALS_H
+#define EXGLOBALS_H 1
+
+extern int IReqCode;
+extern int BadDevice;
+extern int BadEvent;
+extern int BadMode;
+extern int DeviceBusy;
+extern int BadClass;
+
+extern Mask DevicePointerMotionMask;
+extern Mask DevicePointerMotionHintMask;
+extern Mask DeviceFocusChangeMask;
+extern Mask DeviceStateNotifyMask;
+extern Mask ChangeDeviceNotifyMask;
+extern Mask DeviceMappingNotifyMask;
+extern Mask DeviceOwnerGrabButtonMask;
+extern Mask DeviceButtonGrabMask;
+extern Mask DeviceButtonMotionMask;
+extern Mask PropagateMask[];
+
+extern int DeviceValuator;
+extern int DeviceKeyPress;
+extern int DeviceKeyRelease;
+extern int DeviceButtonPress;
+extern int DeviceButtonRelease;
+extern int DeviceMotionNotify;
+extern int DeviceFocusIn;
+extern int DeviceFocusOut;
+extern int ProximityIn;
+extern int ProximityOut;
+extern int DeviceStateNotify;
+extern int DeviceKeyStateNotify;
+extern int DeviceButtonStateNotify;
+extern int DeviceMappingNotify;
+extern int ChangeDeviceNotify;
+
+extern int RT_INPUTCLIENT;
+
+#if 0
+/* FIXME: in dix */
+extern InputInfo inputInfo;
+#endif
+
+#endif /* EXGLOBALS_H */
diff --git a/nx-X11/programs/Xserver/Xi/extinit.c b/nx-X11/programs/Xserver/Xi/extinit.c
new file mode 100644
index 000000000..0b27b5cf7
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/extinit.c
@@ -0,0 +1,1016 @@
+/* $Xorg: extinit.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/extinit.c,v 3.6 2001/12/14 19:58:55 dawes Exp $ */
+
+/********************************************************************
+ *
+ * Dispatch routines and initialization routines for the X input extension.
+ *
+ */
+
+#define NUMTYPES 15
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "inputstr.h"
+#include "gcstruct.h" /* pointer for extnsionst.h*/
+#include "extnsionst.h" /* extension entry */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+
+#include "dixevents.h"
+#include "exevents.h"
+#include "extinit.h"
+#include "exglobals.h"
+#include "swaprep.h"
+
+/* modules local to Xi */
+#include "allowev.h"
+#include "chgdctl.h"
+#include "chgfctl.h"
+#include "chgkbd.h"
+#include "chgprop.h"
+#include "chgptr.h"
+#include "closedev.h"
+#include "devbell.h"
+#include "getbmap.h"
+#include "getbmap.h"
+#include "getdctl.h"
+#include "getfctl.h"
+#include "getfocus.h"
+#include "getkmap.h"
+#include "getmmap.h"
+#include "getprop.h"
+#include "getselev.h"
+#include "getvers.h"
+#include "getvers.h"
+#include "grabdev.h"
+#include "grabdevb.h"
+#include "grabdevk.h"
+#include "gtmotion.h"
+#include "listdev.h"
+#include "opendev.h"
+#include "queryst.h"
+#include "selectev.h"
+#include "sendexev.h"
+#include "chgkmap.h"
+#include "setbmap.h"
+#include "setdval.h"
+#include "setfocus.h"
+#include "setmmap.h"
+#include "setmode.h"
+#include "ungrdev.h"
+#include "ungrdevb.h"
+#include "ungrdevk.h"
+
+static Mask lastExtEventMask = 1;
+int ExtEventIndex;
+Mask ExtValidMasks[EMASKSIZE];
+Mask ExtExclusiveMasks[EMASKSIZE];
+
+struct dev_type
+ {
+ Atom type;
+ char *name;
+ }dev_type [] = {{0,XI_KEYBOARD},
+ {0,XI_MOUSE},
+ {0,XI_TABLET},
+ {0,XI_TOUCHSCREEN},
+ {0,XI_TOUCHPAD},
+ {0,XI_BARCODE},
+ {0,XI_BUTTONBOX},
+ {0,XI_KNOB_BOX},
+ {0,XI_ONE_KNOB},
+ {0,XI_NINE_KNOB},
+ {0,XI_TRACKBALL},
+ {0,XI_QUADRATURE},
+ {0,XI_ID_MODULE},
+ {0,XI_SPACEBALL},
+ {0,XI_DATAGLOVE},
+ {0,XI_EYETRACKER},
+ {0,XI_CURSORKEYS},
+ {0,XI_FOOTMOUSE}};
+
+CARD8 event_base [numInputClasses];
+XExtEventInfo EventInfo[32];
+
+/*****************************************************************
+ *
+ * Globals referenced elsewhere in the server.
+ *
+ */
+
+int IReqCode = 0;
+int BadDevice = 0;
+int BadEvent = 1;
+int BadMode = 2;
+int DeviceBusy = 3;
+int BadClass = 4;
+
+Mask DevicePointerMotionMask;
+Mask DevicePointerMotionHintMask;
+Mask DeviceFocusChangeMask;
+Mask DeviceStateNotifyMask;
+Mask ChangeDeviceNotifyMask;
+Mask DeviceMappingNotifyMask;
+Mask DeviceOwnerGrabButtonMask;
+Mask DeviceButtonGrabMask;
+Mask DeviceButtonMotionMask;
+
+int DeviceValuator;
+int DeviceKeyPress;
+int DeviceKeyRelease;
+int DeviceButtonPress;
+int DeviceButtonRelease;
+int DeviceMotionNotify;
+int DeviceFocusIn;
+int DeviceFocusOut;
+int ProximityIn;
+int ProximityOut;
+int DeviceStateNotify;
+int DeviceKeyStateNotify;
+int DeviceButtonStateNotify;
+int DeviceMappingNotify;
+int ChangeDeviceNotify;
+
+int RT_INPUTCLIENT;
+
+/*****************************************************************
+ *
+ * Externs defined elsewhere in the X server.
+ *
+ */
+
+extern XExtensionVersion AllExtensionVersions[];
+
+Mask PropagateMask[MAX_DEVICES];
+
+/*****************************************************************
+ *
+ * Declarations of local routines.
+ *
+ */
+
+static XExtensionVersion thisversion =
+ {XI_Present,
+ XI_Add_XChangeDeviceControl_Major,
+ XI_Add_XChangeDeviceControl_Minor};
+
+/**********************************************************************
+ *
+ * IExtensionInit - initialize the input extension.
+ *
+ * Called from InitExtensions in main() or from QueryExtension() if the
+ * extension is dynamically loaded.
+ *
+ * This extension has several events and errors.
+ *
+ */
+
+void
+XInputExtensionInit()
+{
+ ExtensionEntry *extEntry;
+
+ extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch,
+ SProcIDispatch, IResetProc, StandardMinorOpcode);
+ if (extEntry)
+ {
+ IReqCode = extEntry->base;
+ AllExtensionVersions[IReqCode-128] = thisversion;
+ MakeDeviceTypeAtoms ();
+ RT_INPUTCLIENT = CreateNewResourceType((DeleteType)InputClientGone);
+ FixExtensionEvents (extEntry);
+ ReplySwapVector[IReqCode] = (ReplySwapPtr)SReplyIDispatch;
+ EventSwapVector[DeviceValuator] = SEventIDispatch;
+ EventSwapVector[DeviceKeyPress] = SEventIDispatch;
+ EventSwapVector[DeviceKeyRelease] = SEventIDispatch;
+ EventSwapVector[DeviceButtonPress] = SEventIDispatch;
+ EventSwapVector[DeviceButtonRelease] = SEventIDispatch;
+ EventSwapVector[DeviceMotionNotify] = SEventIDispatch;
+ EventSwapVector[DeviceFocusIn] = SEventIDispatch;
+ EventSwapVector[DeviceFocusOut] = SEventIDispatch;
+ EventSwapVector[ProximityIn] = SEventIDispatch;
+ EventSwapVector[ProximityOut] = SEventIDispatch;
+ EventSwapVector[DeviceStateNotify] = SEventIDispatch;
+ EventSwapVector[DeviceKeyStateNotify] = SEventIDispatch;
+ EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch;
+ EventSwapVector[DeviceMappingNotify] = SEventIDispatch;
+ EventSwapVector[ChangeDeviceNotify] = SEventIDispatch;
+ }
+ else
+ {
+ FatalError("IExtensionInit: AddExtensions failed\n");
+ }
+ }
+
+/*************************************************************************
+ *
+ * ProcIDispatch - main dispatch routine for requests to this extension.
+ * This routine is used if server and client have the same byte ordering.
+ *
+ */
+
+int
+ProcIDispatch (client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ if (stuff->data == X_GetExtensionVersion)
+ return(ProcXGetExtensionVersion(client));
+ if (stuff->data == X_ListInputDevices)
+ return(ProcXListInputDevices(client));
+ else if (stuff->data == X_OpenDevice)
+ return(ProcXOpenDevice(client));
+ else if (stuff->data == X_CloseDevice)
+ return(ProcXCloseDevice(client));
+ else if (stuff->data == X_SetDeviceMode)
+ return(ProcXSetDeviceMode(client));
+ else if (stuff->data == X_SelectExtensionEvent)
+ return(ProcXSelectExtensionEvent(client));
+ else if (stuff->data == X_GetSelectedExtensionEvents)
+ return(ProcXGetSelectedExtensionEvents(client));
+ else if (stuff->data == X_ChangeDeviceDontPropagateList)
+ return(ProcXChangeDeviceDontPropagateList(client));
+ else if (stuff->data == X_GetDeviceDontPropagateList)
+ return(ProcXGetDeviceDontPropagateList(client));
+ else if (stuff->data == X_GetDeviceMotionEvents)
+ return(ProcXGetDeviceMotionEvents(client));
+ else if (stuff->data == X_ChangeKeyboardDevice)
+ return(ProcXChangeKeyboardDevice(client));
+ else if (stuff->data == X_ChangePointerDevice)
+ return(ProcXChangePointerDevice(client));
+ else if (stuff->data == X_GrabDevice)
+ return(ProcXGrabDevice(client));
+ else if (stuff->data == X_UngrabDevice)
+ return(ProcXUngrabDevice(client));
+ else if (stuff->data == X_GrabDeviceKey)
+ return(ProcXGrabDeviceKey(client));
+ else if (stuff->data == X_UngrabDeviceKey)
+ return(ProcXUngrabDeviceKey(client));
+ else if (stuff->data == X_GrabDeviceButton)
+ return(ProcXGrabDeviceButton(client));
+ else if (stuff->data == X_UngrabDeviceButton)
+ return(ProcXUngrabDeviceButton(client));
+ else if (stuff->data == X_AllowDeviceEvents)
+ return(ProcXAllowDeviceEvents(client));
+ else if (stuff->data == X_GetDeviceFocus)
+ return(ProcXGetDeviceFocus(client));
+ else if (stuff->data == X_SetDeviceFocus)
+ return(ProcXSetDeviceFocus(client));
+ else if (stuff->data == X_GetFeedbackControl)
+ return(ProcXGetFeedbackControl(client));
+ else if (stuff->data == X_ChangeFeedbackControl)
+ return(ProcXChangeFeedbackControl(client));
+ else if (stuff->data == X_GetDeviceKeyMapping)
+ return(ProcXGetDeviceKeyMapping(client));
+ else if (stuff->data == X_ChangeDeviceKeyMapping)
+ return(ProcXChangeDeviceKeyMapping(client));
+ else if (stuff->data == X_GetDeviceModifierMapping)
+ return(ProcXGetDeviceModifierMapping(client));
+ else if (stuff->data == X_SetDeviceModifierMapping)
+ return(ProcXSetDeviceModifierMapping(client));
+ else if (stuff->data == X_GetDeviceButtonMapping)
+ return(ProcXGetDeviceButtonMapping(client));
+ else if (stuff->data == X_SetDeviceButtonMapping)
+ return(ProcXSetDeviceButtonMapping(client));
+ else if (stuff->data == X_QueryDeviceState)
+ return(ProcXQueryDeviceState(client));
+ else if (stuff->data == X_SendExtensionEvent)
+ return(ProcXSendExtensionEvent(client));
+ else if (stuff->data == X_DeviceBell)
+ return(ProcXDeviceBell(client));
+ else if (stuff->data == X_SetDeviceValuators)
+ return(ProcXSetDeviceValuators(client));
+ else if (stuff->data == X_GetDeviceControl)
+ return(ProcXGetDeviceControl(client));
+ else if (stuff->data == X_ChangeDeviceControl)
+ return(ProcXChangeDeviceControl(client));
+ else
+ {
+ SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest);
+ }
+ return(BadRequest);
+ }
+
+/*******************************************************************************
+ *
+ * SProcXDispatch
+ *
+ * Main swapped dispatch routine for requests to this extension.
+ * This routine is used if server and client do not have the same byte ordering.
+ *
+ */
+
+int
+SProcIDispatch(client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+ if (stuff->data == X_GetExtensionVersion)
+ return(SProcXGetExtensionVersion(client));
+ if (stuff->data == X_ListInputDevices)
+ return(SProcXListInputDevices(client));
+ else if (stuff->data == X_OpenDevice)
+ return(SProcXOpenDevice(client));
+ else if (stuff->data == X_CloseDevice)
+ return(SProcXCloseDevice(client));
+ else if (stuff->data == X_SetDeviceMode)
+ return(SProcXSetDeviceMode(client));
+ else if (stuff->data == X_SelectExtensionEvent)
+ return(SProcXSelectExtensionEvent(client));
+ else if (stuff->data == X_GetSelectedExtensionEvents)
+ return(SProcXGetSelectedExtensionEvents(client));
+ else if (stuff->data == X_ChangeDeviceDontPropagateList)
+ return(SProcXChangeDeviceDontPropagateList(client));
+ else if (stuff->data == X_GetDeviceDontPropagateList)
+ return(SProcXGetDeviceDontPropagateList(client));
+ else if (stuff->data == X_GetDeviceMotionEvents)
+ return(SProcXGetDeviceMotionEvents(client));
+ else if (stuff->data == X_ChangeKeyboardDevice)
+ return(SProcXChangeKeyboardDevice(client));
+ else if (stuff->data == X_ChangePointerDevice)
+ return(SProcXChangePointerDevice(client));
+ else if (stuff->data == X_GrabDevice)
+ return(SProcXGrabDevice(client));
+ else if (stuff->data == X_UngrabDevice)
+ return(SProcXUngrabDevice(client));
+ else if (stuff->data == X_GrabDeviceKey)
+ return(SProcXGrabDeviceKey(client));
+ else if (stuff->data == X_UngrabDeviceKey)
+ return(SProcXUngrabDeviceKey(client));
+ else if (stuff->data == X_GrabDeviceButton)
+ return(SProcXGrabDeviceButton(client));
+ else if (stuff->data == X_UngrabDeviceButton)
+ return(SProcXUngrabDeviceButton(client));
+ else if (stuff->data == X_AllowDeviceEvents)
+ return(SProcXAllowDeviceEvents(client));
+ else if (stuff->data == X_GetDeviceFocus)
+ return(SProcXGetDeviceFocus(client));
+ else if (stuff->data == X_SetDeviceFocus)
+ return(SProcXSetDeviceFocus(client));
+ else if (stuff->data == X_GetFeedbackControl)
+ return(SProcXGetFeedbackControl(client));
+ else if (stuff->data == X_ChangeFeedbackControl)
+ return(SProcXChangeFeedbackControl(client));
+ else if (stuff->data == X_GetDeviceKeyMapping)
+ return(SProcXGetDeviceKeyMapping(client));
+ else if (stuff->data == X_ChangeDeviceKeyMapping)
+ return(SProcXChangeDeviceKeyMapping(client));
+ else if (stuff->data == X_GetDeviceModifierMapping)
+ return(SProcXGetDeviceModifierMapping(client));
+ else if (stuff->data == X_SetDeviceModifierMapping)
+ return(SProcXSetDeviceModifierMapping(client));
+ else if (stuff->data == X_GetDeviceButtonMapping)
+ return(SProcXGetDeviceButtonMapping(client));
+ else if (stuff->data == X_SetDeviceButtonMapping)
+ return(SProcXSetDeviceButtonMapping(client));
+ else if (stuff->data == X_QueryDeviceState)
+ return(SProcXQueryDeviceState(client));
+ else if (stuff->data == X_SendExtensionEvent)
+ return(SProcXSendExtensionEvent(client));
+ else if (stuff->data == X_DeviceBell)
+ return(SProcXDeviceBell(client));
+ else if (stuff->data == X_SetDeviceValuators)
+ return(SProcXSetDeviceValuators(client));
+ else if (stuff->data == X_GetDeviceControl)
+ return(SProcXGetDeviceControl(client));
+ else if (stuff->data == X_ChangeDeviceControl)
+ return(SProcXChangeDeviceControl(client));
+ else
+ {
+ SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest);
+ }
+ return(BadRequest);
+ }
+
+/**********************************************************************
+ *
+ * SReplyIDispatch
+ * Swap any replies defined in this extension.
+ *
+ */
+
+/* FIXME: this would be more concise and readable in ANSI C */
+#define DISPATCH(code) \
+ if (rep->RepType == X_##code) \
+ SRepX##code (client, len, (x##code##Reply *) rep)
+
+void
+SReplyIDispatch (client, len, rep)
+ ClientPtr client;
+ int len;
+ xGrabDeviceReply *rep; /* All we look at is the type field */
+{ /* This is common to all replies */
+ if (rep->RepType == X_GetExtensionVersion)
+ SRepXGetExtensionVersion (client, len, (xGetExtensionVersionReply *)rep);
+ else if (rep->RepType == X_ListInputDevices)
+ SRepXListInputDevices (client, len, (xListInputDevicesReply *)rep);
+ else if (rep->RepType == X_OpenDevice)
+ SRepXOpenDevice (client, len, (xOpenDeviceReply *)rep);
+ else if (rep->RepType == X_SetDeviceMode)
+ SRepXSetDeviceMode (client, len, (xSetDeviceModeReply *) rep);
+ else if (rep->RepType == X_GetSelectedExtensionEvents)
+ SRepXGetSelectedExtensionEvents (client, len, (xGetSelectedExtensionEventsReply *) rep);
+ else if (rep->RepType == X_GetDeviceDontPropagateList)
+ SRepXGetDeviceDontPropagateList (client, len, (xGetDeviceDontPropagateListReply *)rep);
+ else if (rep->RepType == X_GetDeviceMotionEvents)
+ SRepXGetDeviceMotionEvents (client, len, (xGetDeviceMotionEventsReply *) rep);
+ else if (rep->RepType == X_ChangeKeyboardDevice)
+ SRepXChangeKeyboardDevice (client, len, (xChangeKeyboardDeviceReply *) rep);
+ else if (rep->RepType == X_ChangePointerDevice)
+ SRepXChangePointerDevice (client, len, (xChangePointerDeviceReply *)rep);
+ else if (rep->RepType == X_GrabDevice)
+ SRepXGrabDevice (client, len, (xGrabDeviceReply *)rep);
+ else if (rep->RepType == X_GetDeviceFocus)
+ SRepXGetDeviceFocus (client, len, (xGetDeviceFocusReply *)rep);
+ else if (rep->RepType == X_GetFeedbackControl)
+ SRepXGetFeedbackControl (client, len, (xGetFeedbackControlReply *)rep);
+ else if (rep->RepType == X_GetDeviceKeyMapping)
+ SRepXGetDeviceKeyMapping (client, len, (xGetDeviceKeyMappingReply *)rep);
+ else if (rep->RepType == X_GetDeviceModifierMapping)
+ SRepXGetDeviceModifierMapping (client, len, (xGetDeviceModifierMappingReply *)rep);
+ else if (rep->RepType == X_SetDeviceModifierMapping)
+ SRepXSetDeviceModifierMapping (client, len, (xSetDeviceModifierMappingReply *)rep);
+ else if (rep->RepType == X_GetDeviceButtonMapping)
+ SRepXGetDeviceButtonMapping (client, len, (xGetDeviceButtonMappingReply *)rep);
+ else if (rep->RepType == X_SetDeviceButtonMapping)
+ SRepXSetDeviceButtonMapping (client, len, (xSetDeviceButtonMappingReply *)rep);
+ else if (rep->RepType == X_QueryDeviceState)
+ SRepXQueryDeviceState (client, len, (xQueryDeviceStateReply *)rep);
+ else if (rep->RepType == X_SetDeviceValuators)
+ SRepXSetDeviceValuators (client, len, (xSetDeviceValuatorsReply *)rep);
+ else if (rep->RepType == X_GetDeviceControl)
+ SRepXGetDeviceControl (client, len, (xGetDeviceControlReply *)rep);
+ else if (rep->RepType == X_ChangeDeviceControl)
+ SRepXChangeDeviceControl (client, len, (xChangeDeviceControlReply *)rep);
+ else
+ {
+ FatalError("XINPUT confused sending swapped reply");
+ }
+ }
+
+/*****************************************************************************
+ *
+ * SEventIDispatch
+ *
+ * Swap any events defined in this extension.
+ */
+#define DO_SWAP(func,type) func ((type *)from, (type *)to)
+
+void
+SEventIDispatch (from, to)
+ xEvent *from;
+ xEvent *to;
+{
+ int type = from->u.u.type & 0177;
+
+ if (type == DeviceValuator)
+ DO_SWAP(SEventDeviceValuator, deviceValuator);
+ else if (type == DeviceKeyPress)
+ {
+ SKeyButtonPtrEvent (from, to);
+ to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
+ }
+ else if (type == DeviceKeyRelease)
+ {
+ SKeyButtonPtrEvent (from, to);
+ to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
+ }
+ else if (type == DeviceButtonPress)
+ {
+ SKeyButtonPtrEvent (from, to);
+ to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
+ }
+ else if (type == DeviceButtonRelease)
+ {
+ SKeyButtonPtrEvent (from, to);
+ to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
+ }
+ else if (type == DeviceMotionNotify)
+ {
+ SKeyButtonPtrEvent (from, to);
+ to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
+ }
+ else if (type == DeviceFocusIn)
+ DO_SWAP(SEventFocus, deviceFocus);
+ else if (type == DeviceFocusOut)
+ DO_SWAP(SEventFocus, deviceFocus);
+ else if (type == ProximityIn)
+ {
+ SKeyButtonPtrEvent (from, to);
+ to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
+ }
+ else if (type == ProximityOut)
+ {
+ SKeyButtonPtrEvent (from, to);
+ to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
+ }
+ else if (type == DeviceStateNotify)
+ DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify);
+ else if (type == DeviceKeyStateNotify)
+ DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify);
+ else if (type == DeviceButtonStateNotify)
+ DO_SWAP(SDeviceButtonStateNotifyEvent, deviceButtonStateNotify);
+ else if (type == DeviceMappingNotify)
+ DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify);
+ else if (type == ChangeDeviceNotify)
+ DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify);
+ else
+ {
+ FatalError("XInputExtension: Impossible event!\n");
+ }
+ }
+
+/************************************************************************
+ *
+ * This function swaps the DeviceValuator event.
+ *
+ */
+
+void
+SEventDeviceValuator (from, to)
+ deviceValuator *from;
+ deviceValuator *to;
+ {
+ register char n;
+ register int i;
+ INT32 *ip B32;
+
+ *to = *from;
+ swaps(&to->sequenceNumber,n);
+ swaps(&to->device_state,n);
+ ip = &to->valuator0;
+ for (i=0; i<6; i++)
+ {
+ swapl((ip+i),n); /* macro - braces are required */
+ }
+ }
+
+void
+SEventFocus (from, to)
+ deviceFocus *from;
+ deviceFocus *to;
+{
+ register char n;
+
+ *to = *from;
+ swaps(&to->sequenceNumber,n);
+ swapl(&to->time, n);
+ swapl(&to->window, n);
+ }
+
+void
+SDeviceStateNotifyEvent (from, to)
+ deviceStateNotify *from;
+ deviceStateNotify *to;
+{
+ register int i;
+ register char n;
+ INT32 *ip B32;
+
+ *to = *from;
+ swaps(&to->sequenceNumber,n);
+ swapl(&to->time, n);
+ ip = &to->valuator0;
+ for (i=0; i<3; i++)
+ {
+ swapl((ip+i),n); /* macro - braces are required */
+ }
+ }
+
+void
+SDeviceKeyStateNotifyEvent (from, to)
+ deviceKeyStateNotify *from;
+ deviceKeyStateNotify *to;
+{
+ register char n;
+
+ *to = *from;
+ swaps(&to->sequenceNumber,n);
+ }
+
+void
+SDeviceButtonStateNotifyEvent (from, to)
+ deviceButtonStateNotify *from;
+ deviceButtonStateNotify *to;
+{
+ register char n;
+
+ *to = *from;
+ swaps(&to->sequenceNumber,n);
+ }
+
+void
+SChangeDeviceNotifyEvent (from, to)
+ changeDeviceNotify *from;
+ changeDeviceNotify *to;
+{
+ register char n;
+
+ *to = *from;
+ swaps(&to->sequenceNumber,n);
+ swapl(&to->time, n);
+ }
+
+void
+SDeviceMappingNotifyEvent (from, to)
+ deviceMappingNotify *from;
+ deviceMappingNotify *to;
+{
+ register char n;
+
+ *to = *from;
+ swaps(&to->sequenceNumber,n);
+ swapl(&to->time, n);
+ }
+
+/************************************************************************
+ *
+ * This function sets up extension event types and masks.
+ *
+ */
+
+void
+FixExtensionEvents (extEntry)
+ ExtensionEntry *extEntry;
+{
+ Mask mask;
+
+ DeviceValuator = extEntry->eventBase;
+ DeviceKeyPress = DeviceValuator + 1;
+ DeviceKeyRelease = DeviceKeyPress + 1;
+ DeviceButtonPress = DeviceKeyRelease + 1;
+ DeviceButtonRelease = DeviceButtonPress + 1;
+ DeviceMotionNotify = DeviceButtonRelease + 1;
+ DeviceFocusIn = DeviceMotionNotify + 1;
+ DeviceFocusOut = DeviceFocusIn + 1;
+ ProximityIn = DeviceFocusOut + 1;
+ ProximityOut = ProximityIn + 1;
+ DeviceStateNotify = ProximityOut + 1;
+ DeviceMappingNotify = DeviceStateNotify + 1;
+ ChangeDeviceNotify = DeviceMappingNotify + 1;
+ DeviceKeyStateNotify = ChangeDeviceNotify + 1;
+ DeviceButtonStateNotify = DeviceKeyStateNotify + 1;
+
+ event_base[KeyClass] = DeviceKeyPress;
+ event_base[ButtonClass] = DeviceButtonPress;
+ event_base[ValuatorClass] = DeviceMotionNotify;
+ event_base[ProximityClass] = ProximityIn;
+ event_base[FocusClass] = DeviceFocusIn;
+ event_base[OtherClass] = DeviceStateNotify;
+
+ BadDevice += extEntry->errorBase;
+ BadEvent += extEntry->errorBase;
+ BadMode += extEntry->errorBase;
+ DeviceBusy += extEntry->errorBase;
+ BadClass += extEntry->errorBase;
+
+ mask = GetNextExtEventMask ();
+ SetMaskForExtEvent (mask, DeviceKeyPress);
+ AllowPropagateSuppress (mask);
+
+ mask = GetNextExtEventMask ();
+ SetMaskForExtEvent (mask, DeviceKeyRelease);
+ AllowPropagateSuppress (mask);
+
+ mask = GetNextExtEventMask ();
+ SetMaskForExtEvent (mask, DeviceButtonPress);
+ AllowPropagateSuppress (mask);
+
+ mask = GetNextExtEventMask ();
+ SetMaskForExtEvent (mask, DeviceButtonRelease);
+ AllowPropagateSuppress (mask);
+
+ mask = GetNextExtEventMask ();
+ SetMaskForExtEvent (mask, ProximityIn);
+ SetMaskForExtEvent (mask, ProximityOut);
+ AllowPropagateSuppress (mask);
+
+ mask = GetNextExtEventMask ();
+ DeviceStateNotifyMask = mask;
+ SetMaskForExtEvent (mask, DeviceStateNotify);
+
+ mask = GetNextExtEventMask ();
+ DevicePointerMotionMask = mask;
+ SetMaskForExtEvent (mask, DeviceMotionNotify);
+ AllowPropagateSuppress (mask);
+
+ DevicePointerMotionHintMask = GetNextExtEventMask();
+ SetEventInfo (DevicePointerMotionHintMask, _devicePointerMotionHint);
+ SetEventInfo (GetNextExtEventMask(), _deviceButton1Motion);
+ SetEventInfo (GetNextExtEventMask(), _deviceButton2Motion);
+ SetEventInfo (GetNextExtEventMask(), _deviceButton3Motion);
+ SetEventInfo (GetNextExtEventMask(), _deviceButton4Motion);
+ SetEventInfo (GetNextExtEventMask(), _deviceButton5Motion);
+ DeviceButtonMotionMask = GetNextExtEventMask();
+ SetEventInfo (DeviceButtonMotionMask, _deviceButtonMotion);
+
+ DeviceFocusChangeMask = GetNextExtEventMask ();
+ SetMaskForExtEvent (DeviceFocusChangeMask, DeviceFocusIn);
+ SetMaskForExtEvent (DeviceFocusChangeMask, DeviceFocusOut);
+
+ mask = GetNextExtEventMask ();
+ SetMaskForExtEvent (mask, DeviceMappingNotify);
+ DeviceMappingNotifyMask = mask;
+
+ mask = GetNextExtEventMask ();
+ SetMaskForExtEvent (mask, ChangeDeviceNotify);
+ ChangeDeviceNotifyMask = mask;
+
+ DeviceButtonGrabMask = GetNextExtEventMask();
+ SetEventInfo (DeviceButtonGrabMask, _deviceButtonGrab);
+ SetExclusiveAccess (DeviceButtonGrabMask);
+
+ DeviceOwnerGrabButtonMask = GetNextExtEventMask();
+ SetEventInfo (DeviceOwnerGrabButtonMask, _deviceOwnerGrabButton);
+ SetEventInfo (0, _noExtensionEvent);
+ }
+
+/************************************************************************
+ *
+ * This function restores extension event types and masks to their
+ * initial state.
+ *
+ */
+
+void
+RestoreExtensionEvents ()
+{
+ int i;
+
+ IReqCode = 0;
+
+ for (i=0; i<ExtEventIndex-1; i++)
+ {
+ if ((EventInfo[i].type >= LASTEvent) && (EventInfo[i].type < 128))
+ SetMaskForEvent(0,EventInfo[i].type);
+ EventInfo[i].mask = 0;
+ EventInfo[i].type = 0;
+ }
+ ExtEventIndex = 0;
+ lastExtEventMask = 1;
+ DeviceValuator = 0;
+ DeviceKeyPress = 1;
+ DeviceKeyRelease = 2;
+ DeviceButtonPress = 3;
+ DeviceButtonRelease = 4;
+ DeviceMotionNotify = 5;
+ DeviceFocusIn = 6;
+ DeviceFocusOut = 7;
+ ProximityIn = 8;
+ ProximityOut = 9;
+ DeviceStateNotify = 10;
+ DeviceMappingNotify = 11;
+ ChangeDeviceNotify = 12;
+ DeviceKeyStateNotify = 13;
+ DeviceButtonStateNotify = 13;
+
+ BadDevice = 0;
+ BadEvent = 1;
+ BadMode = 2;
+ DeviceBusy = 3;
+ BadClass = 4;
+
+ }
+
+/***********************************************************************
+ *
+ * IResetProc.
+ * Remove reply-swapping routine.
+ * Remove event-swapping routine.
+ *
+ */
+
+void
+IResetProc(unused)
+ ExtensionEntry *unused;
+ {
+
+ ReplySwapVector[IReqCode] = ReplyNotSwappd;
+ EventSwapVector[DeviceValuator] = NotImplemented;
+ EventSwapVector[DeviceKeyPress] = NotImplemented;
+ EventSwapVector[DeviceKeyRelease] = NotImplemented;
+ EventSwapVector[DeviceButtonPress] = NotImplemented;
+ EventSwapVector[DeviceButtonRelease] = NotImplemented;
+ EventSwapVector[DeviceMotionNotify] = NotImplemented;
+ EventSwapVector[DeviceFocusIn] = NotImplemented;
+ EventSwapVector[DeviceFocusOut] = NotImplemented;
+ EventSwapVector[ProximityIn] = NotImplemented;
+ EventSwapVector[ProximityOut] = NotImplemented;
+ EventSwapVector[DeviceStateNotify] = NotImplemented;
+ EventSwapVector[DeviceKeyStateNotify] = NotImplemented;
+ EventSwapVector[DeviceButtonStateNotify] = NotImplemented;
+ EventSwapVector[DeviceMappingNotify] = NotImplemented;
+ EventSwapVector[ChangeDeviceNotify] = NotImplemented;
+ RestoreExtensionEvents ();
+ }
+
+/***********************************************************************
+ *
+ * Assign an id and type to an input device.
+ *
+ */
+
+void
+AssignTypeAndName (dev, type, name)
+ DeviceIntPtr dev;
+ Atom type;
+ char *name;
+{
+ dev->type = type;
+ dev->name = (char *) xalloc(strlen(name)+1);
+ strcpy (dev->name, name);
+ }
+
+/***********************************************************************
+ *
+ * Make device type atoms.
+ *
+ */
+
+void
+MakeDeviceTypeAtoms ()
+ {
+ int i;
+
+ for (i=0; i<NUMTYPES; i++)
+ dev_type[i].type =
+ MakeAtom (dev_type[i].name, strlen(dev_type[i].name), 1);
+ }
+
+/**************************************************************************
+ *
+ * Return a DeviceIntPtr corresponding to a specified device id.
+ * This will not return the pointer or keyboard, or devices that are not on.
+ *
+ */
+
+DeviceIntPtr
+LookupDeviceIntRec (
+ CARD8 id)
+{
+ DeviceIntPtr dev;
+
+ for (dev=inputInfo.devices; dev; dev=dev->next)
+ {
+ if (dev->id == id)
+ {
+ if (id == inputInfo.pointer->id || id == inputInfo.keyboard->id)
+ return (NULL);
+ return (dev);
+ }
+ }
+ return (NULL);
+ }
+
+/**************************************************************************
+ *
+ * Allow the specified event to be restricted to being selected by one
+ * client at a time.
+ * The default is to allow more than one client to select the event.
+ *
+ */
+
+void
+SetExclusiveAccess (mask)
+ Mask mask;
+ {
+ int i;
+
+ for (i=0; i<MAX_DEVICES; i++)
+ ExtExclusiveMasks[i] |= mask;
+ }
+
+/**************************************************************************
+ *
+ * Allow the specified event to have its propagation suppressed.
+ * The default is to not allow suppression of propagation.
+ *
+ */
+
+void
+AllowPropagateSuppress (mask)
+ Mask mask;
+ {
+ int i;
+
+ for (i=0; i<MAX_DEVICES; i++)
+ PropagateMask[i] |= mask;
+ }
+
+/**************************************************************************
+ *
+ * Return the next available extension event mask.
+ *
+ */
+
+Mask
+GetNextExtEventMask ()
+ {
+ int i;
+ Mask mask = lastExtEventMask;
+
+ if (lastExtEventMask == 0)
+ {
+ FatalError("GetNextExtEventMask: no more events are available.");
+ }
+ lastExtEventMask <<= 1;
+
+ for (i=0; i<MAX_DEVICES; i++)
+ ExtValidMasks[i] |= mask;
+ return mask;
+ }
+
+/**************************************************************************
+ *
+ * Assign the specified mask to the specified event.
+ *
+ */
+
+void
+SetMaskForExtEvent(mask, event)
+ Mask mask;
+ int event;
+ {
+
+ EventInfo[ExtEventIndex].mask = mask;
+ EventInfo[ExtEventIndex++].type = event;
+
+ if ((event < LASTEvent) || (event >= 128))
+ FatalError("MaskForExtensionEvent: bogus event number");
+ SetMaskForEvent(mask,event);
+ }
+
+/**************************************************************************
+ *
+ * Record an event mask where there is no unique corresponding event type.
+ * We can't call SetMaskForEvent, since that would clobber the existing
+ * mask for that event. MotionHint and ButtonMotion are examples.
+ *
+ * Since extension event types will never be less than 64, we can use
+ * 0-63 in the EventInfo array as the "type" to be used to look up this
+ * mask. This means that the corresponding macros such as
+ * DevicePointerMotionHint must have access to the same constants.
+ *
+ */
+
+void
+SetEventInfo(mask, constant)
+ Mask mask;
+ int constant;
+ {
+ EventInfo[ExtEventIndex].mask = mask;
+ EventInfo[ExtEventIndex++].type = constant;
+ }
diff --git a/nx-X11/programs/Xserver/Xi/getbmap.c b/nx-X11/programs/Xserver/Xi/getbmap.c
new file mode 100644
index 000000000..a944d4cc8
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getbmap.c
@@ -0,0 +1,154 @@
+/* $Xorg: getbmap.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/getbmap.c,v 3.2 2001/01/17 22:13:24 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Extension function to return the version of the extension.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "getbmap.h"
+
+/***********************************************************************
+ *
+ * This procedure gets the button mapping for the specified device.
+ *
+ */
+
+int
+SProcXGetDeviceButtonMapping(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xGetDeviceButtonMappingReq);
+ swaps(&stuff->length, n);
+ return(ProcXGetDeviceButtonMapping(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure gets the button mapping for the specified device.
+ *
+ */
+
+int
+ProcXGetDeviceButtonMapping (client)
+ register ClientPtr client;
+ {
+ DeviceIntPtr dev;
+ xGetDeviceButtonMappingReply rep;
+ ButtonClassPtr b;
+
+ REQUEST(xGetDeviceButtonMappingReq);
+ REQUEST_SIZE_MATCH(xGetDeviceButtonMappingReq);
+
+ rep.repType = X_Reply;
+ rep.RepType = X_GetDeviceButtonMapping;
+ rep.nElts = 0;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_GetDeviceButtonMapping, 0,
+ BadDevice);
+ return Success;
+ }
+
+ b = dev->button;
+ if (b == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_GetDeviceButtonMapping, 0,
+ BadMatch);
+ return Success;
+ }
+ rep.nElts = b->numButtons;
+ rep.length = (rep.nElts + (4-1))/4;
+ WriteReplyToClient (client, sizeof (xGetDeviceButtonMappingReply), &rep);
+ (void)WriteToClient(client, rep.nElts,
+ (char *)&b->map[1]);
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XGetDeviceButtonMapping function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXGetDeviceButtonMapping (client, size, rep)
+ ClientPtr client;
+ int size;
+ xGetDeviceButtonMappingReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/getbmap.h b/nx-X11/programs/Xserver/Xi/getbmap.h
new file mode 100644
index 000000000..01cc3780a
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getbmap.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/programs/Xserver/Xi/getbmap.h,v 3.1 1996/04/15 11:18:37 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef GETBMAP_H
+#define GETBMAP_H 1
+
+int
+SProcXGetDeviceButtonMapping(
+ ClientPtr /* client */
+ );
+
+int
+ProcXGetDeviceButtonMapping (
+ ClientPtr /* client */
+ );
+
+void
+SRepXGetDeviceButtonMapping (
+ ClientPtr /* client */,
+ int /* size */,
+ xGetDeviceButtonMappingReply * /* rep */
+ );
+
+#endif /* GETBMAP_H */
diff --git a/nx-X11/programs/Xserver/Xi/getdctl.c b/nx-X11/programs/Xserver/Xi/getdctl.c
new file mode 100644
index 000000000..527273ac4
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getdctl.c
@@ -0,0 +1,230 @@
+/* $Xorg: getdctl.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/getdctl.c,v 3.3 2001/01/17 22:13:24 dawes Exp $ */
+
+/********************************************************************
+ *
+ * Get Device control attributes for an extension device.
+ *
+ */
+
+#define NEED_EVENTS /* for inputstr.h */
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "getdctl.h"
+
+/***********************************************************************
+ *
+ * This procedure gets the control attributes for an extension device,
+ * for clients on machines with a different byte ordering than the server.
+ *
+ */
+
+int
+SProcXGetDeviceControl(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xGetDeviceControlReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGetDeviceControlReq);
+ swaps(&stuff->control, n);
+ return(ProcXGetDeviceControl(client));
+ }
+
+/***********************************************************************
+ *
+ * Get the state of the specified device control.
+ *
+ */
+
+int
+ProcXGetDeviceControl(client)
+ ClientPtr client;
+ {
+ int total_length = 0;
+ char *buf, *savbuf;
+ register DeviceIntPtr dev;
+ xGetDeviceControlReply rep;
+
+ REQUEST(xGetDeviceControlReq);
+ REQUEST_SIZE_MATCH(xGetDeviceControlReq);
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient (client, IReqCode, X_GetDeviceControl, 0,
+ BadDevice);
+ return Success;
+ }
+
+ rep.repType = X_Reply;
+ rep.RepType = X_GetDeviceControl;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ switch (stuff->control)
+ {
+ case DEVICE_RESOLUTION:
+ if (!dev->valuator)
+ {
+ SendErrorToClient (client, IReqCode, X_GetDeviceControl, 0,
+ BadMatch);
+ return Success;
+ }
+ total_length = sizeof (xDeviceResolutionState) +
+ (3 * sizeof(int) * dev->valuator->numAxes);
+ break;
+ default:
+ SendErrorToClient (client, IReqCode, X_GetDeviceControl, 0,
+ BadValue);
+ return Success;
+ }
+
+ buf = (char *) xalloc (total_length);
+ if (!buf)
+ {
+ SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
+ BadAlloc);
+ return Success;
+ }
+ savbuf=buf;
+
+ switch (stuff->control)
+ {
+ case DEVICE_RESOLUTION:
+ CopySwapDeviceResolution(client, dev->valuator, buf,
+ total_length);
+ break;
+ default:
+ break;
+ }
+
+ rep.length = (total_length+3) >> 2;
+ WriteReplyToClient(client, sizeof(xGetDeviceControlReply), &rep);
+ WriteToClient(client, total_length, savbuf);
+ xfree (savbuf);
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure copies DeviceResolution data, swapping if necessary.
+ *
+ */
+
+void
+CopySwapDeviceResolution (client, v, buf, length)
+ ClientPtr client;
+ ValuatorClassPtr v;
+ char *buf;
+ int length;
+ {
+ register char n;
+ AxisInfoPtr a;
+ xDeviceResolutionState *r;
+ int i, *iptr;
+
+ r = (xDeviceResolutionState *) buf;
+ r->control = DEVICE_RESOLUTION;
+ r->length = length;
+ r->num_valuators = v->numAxes;
+ buf += sizeof (xDeviceResolutionState);
+ iptr = (int *) buf;
+ for (i=0,a=v->axes; i<v->numAxes; i++,a++)
+ *iptr++ = a->resolution;
+ for (i=0,a=v->axes; i<v->numAxes; i++,a++)
+ *iptr++ = a->min_resolution;
+ for (i=0,a=v->axes; i<v->numAxes; i++,a++)
+ *iptr++ = a->max_resolution;
+ if (client->swapped)
+ {
+ swaps (&r->control,n);
+ swaps (&r->length,n);
+ swapl (&r->num_valuators,n);
+ iptr = (int *) buf;
+ for (i=0; i < (3 * v->numAxes); i++,iptr++)
+ {
+ swapl (iptr,n);
+ }
+ }
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the xGetDeviceControl function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXGetDeviceControl (client, size, rep)
+ ClientPtr client;
+ int size;
+ xGetDeviceControlReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ WriteToClient(client, size, (char *)rep);
+ }
+
diff --git a/nx-X11/programs/Xserver/Xi/getdctl.h b/nx-X11/programs/Xserver/Xi/getdctl.h
new file mode 100644
index 000000000..168620eca
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getdctl.h
@@ -0,0 +1,59 @@
+/* $XFree86: xc/programs/Xserver/Xi/getdctl.h,v 3.1 1996/04/15 11:18:38 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef GETDCTL_H
+#define GETDCTL_H 1
+
+int
+SProcXGetDeviceControl (
+ ClientPtr /* client */
+ );
+
+int
+ProcXGetDeviceControl (
+ ClientPtr /* client */
+ );
+
+void
+CopySwapDeviceResolution (
+ ClientPtr /* client */,
+ ValuatorClassPtr /* v */,
+ char * /* buf */,
+ int /* length */
+ );
+
+void
+SRepXGetDeviceControl (
+ ClientPtr /* client */,
+ int /* size */,
+ xGetDeviceControlReply * /* rep */
+ );
+
+#endif /* GETDCTL_H */
diff --git a/nx-X11/programs/Xserver/Xi/getfctl.c b/nx-X11/programs/Xserver/Xi/getfctl.c
new file mode 100644
index 000000000..5652ad303
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getfctl.c
@@ -0,0 +1,422 @@
+/* $Xorg: getfctl.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/getfctl.c,v 3.3 2001/01/17 22:13:24 dawes Exp $ */
+
+/********************************************************************
+ *
+ * Get feedback control attributes for an extension device.
+ *
+ */
+
+#define NEED_EVENTS /* for inputstr.h */
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "getfctl.h"
+
+/***********************************************************************
+ *
+ * This procedure gets the control attributes for an extension device,
+ * for clients on machines with a different byte ordering than the server.
+ *
+ */
+
+int
+SProcXGetFeedbackControl(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xGetFeedbackControlReq);
+ swaps(&stuff->length, n);
+ return(ProcXGetFeedbackControl(client));
+ }
+
+/***********************************************************************
+ *
+ * Get the feedback control state.
+ *
+ */
+
+int
+ProcXGetFeedbackControl(client)
+ ClientPtr client;
+ {
+ int total_length = 0;
+ char *buf, *savbuf;
+ register DeviceIntPtr dev;
+ KbdFeedbackPtr k;
+ PtrFeedbackPtr p;
+ IntegerFeedbackPtr i;
+ StringFeedbackPtr s;
+ BellFeedbackPtr b;
+ LedFeedbackPtr l;
+ xGetFeedbackControlReply rep;
+
+ REQUEST(xGetFeedbackControlReq);
+ REQUEST_SIZE_MATCH(xGetFeedbackControlReq);
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient (client, IReqCode, X_GetFeedbackControl, 0,
+ BadDevice);
+ return Success;
+ }
+
+ rep.repType = X_Reply;
+ rep.RepType = X_GetFeedbackControl;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.num_feedbacks = 0;
+
+ for (k=dev->kbdfeed; k; k=k->next)
+ {
+ rep.num_feedbacks++;
+ total_length += sizeof(xKbdFeedbackState);
+ }
+ for (p=dev->ptrfeed; p; p=p->next)
+ {
+ rep.num_feedbacks++;
+ total_length += sizeof(xPtrFeedbackState);
+ }
+ for (s=dev->stringfeed; s; s=s->next)
+ {
+ rep.num_feedbacks++;
+ total_length += sizeof(xStringFeedbackState) +
+ (s->ctrl.num_symbols_supported * sizeof (KeySym));
+ }
+ for (i=dev->intfeed; i; i=i->next)
+ {
+ rep.num_feedbacks++;
+ total_length += sizeof(xIntegerFeedbackState);
+ }
+ for (l=dev->leds; l; l=l->next)
+ {
+ rep.num_feedbacks++;
+ total_length += sizeof(xLedFeedbackState);
+ }
+ for (b=dev->bell; b; b=b->next)
+ {
+ rep.num_feedbacks++;
+ total_length += sizeof(xBellFeedbackState);
+ }
+
+ if (total_length == 0)
+ {
+ SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0,
+ BadMatch);
+ return Success;
+ }
+
+ buf = (char *) xalloc (total_length);
+ if (!buf)
+ {
+ SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0,
+ BadAlloc);
+ return Success;
+ }
+ savbuf=buf;
+
+ for (k=dev->kbdfeed; k; k=k->next)
+ CopySwapKbdFeedback (client, k, &buf);
+ for (p=dev->ptrfeed; p; p=p->next)
+ CopySwapPtrFeedback (client, p, &buf);
+ for (s=dev->stringfeed; s; s=s->next)
+ CopySwapStringFeedback (client, s, &buf);
+ for (i=dev->intfeed; i; i=i->next)
+ CopySwapIntegerFeedback (client, i, &buf);
+ for (l=dev->leds; l; l=l->next)
+ CopySwapLedFeedback (client, l, &buf);
+ for (b=dev->bell; b; b=b->next)
+ CopySwapBellFeedback (client, b, &buf);
+
+ rep.length = (total_length+3) >> 2;
+ WriteReplyToClient(client, sizeof(xGetFeedbackControlReply), &rep);
+ WriteToClient(client, total_length, savbuf);
+ xfree (savbuf);
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure copies KbdFeedbackClass data, swapping if necessary.
+ *
+ */
+
+void
+CopySwapKbdFeedback (client, k, buf)
+ ClientPtr client;
+ KbdFeedbackPtr k;
+ char **buf;
+ {
+ int i;
+ register char n;
+ xKbdFeedbackState *k2;
+
+ k2 = (xKbdFeedbackState *) *buf;
+ k2->class = KbdFeedbackClass;
+ k2->length = sizeof (xKbdFeedbackState);
+ k2->id = k->ctrl.id;
+ k2->click = k->ctrl.click;
+ k2->percent = k->ctrl.bell;
+ k2->pitch = k->ctrl.bell_pitch;
+ k2->duration = k->ctrl.bell_duration;
+ k2->led_mask = k->ctrl.leds;
+ k2->global_auto_repeat = k->ctrl.autoRepeat;
+ for (i=0; i<32; i++)
+ k2->auto_repeats[i] = k->ctrl.autoRepeats[i];
+ if (client->swapped)
+ {
+ swaps(&k2->length,n);
+ swaps(&k2->pitch,n);
+ swaps(&k2->duration,n);
+ swapl(&k2->led_mask,n);
+ swapl(&k2->led_values,n);
+ }
+ *buf += sizeof (xKbdFeedbackState);
+ }
+
+/***********************************************************************
+ *
+ * This procedure copies PtrFeedbackClass data, swapping if necessary.
+ *
+ */
+
+void
+CopySwapPtrFeedback (client, p, buf)
+ ClientPtr client;
+ PtrFeedbackPtr p;
+ char **buf;
+ {
+ register char n;
+ xPtrFeedbackState *p2;
+
+ p2 = (xPtrFeedbackState *) *buf;
+ p2->class = PtrFeedbackClass;
+ p2->length = sizeof (xPtrFeedbackState);
+ p2->id = p->ctrl.id;
+ p2->accelNum = p->ctrl.num;
+ p2->accelDenom = p->ctrl.den;
+ p2->threshold = p->ctrl.threshold;
+ if (client->swapped)
+ {
+ swaps(&p2->length,n);
+ swaps(&p2->accelNum,n);
+ swaps(&p2->accelDenom,n);
+ swaps(&p2->threshold,n);
+ }
+ *buf += sizeof (xPtrFeedbackState);
+ }
+
+/***********************************************************************
+ *
+ * This procedure copies IntegerFeedbackClass data, swapping if necessary.
+ *
+ */
+
+void
+CopySwapIntegerFeedback (client, i, buf)
+ ClientPtr client;
+ IntegerFeedbackPtr i;
+ char **buf;
+ {
+ register char n;
+ xIntegerFeedbackState *i2;
+
+ i2 = (xIntegerFeedbackState *) *buf;
+ i2->class = IntegerFeedbackClass;
+ i2->length = sizeof (xIntegerFeedbackState);
+ i2->id = i->ctrl.id;
+ i2->resolution = i->ctrl.resolution;
+ i2->min_value = i->ctrl.min_value;
+ i2->max_value = i->ctrl.max_value;
+ if (client->swapped)
+ {
+ swaps(&i2->length,n);
+ swapl(&i2->resolution,n);
+ swapl(&i2->min_value,n);
+ swapl(&i2->max_value,n);
+ }
+ *buf += sizeof (xIntegerFeedbackState);
+ }
+
+/***********************************************************************
+ *
+ * This procedure copies StringFeedbackClass data, swapping if necessary.
+ *
+ */
+
+void
+CopySwapStringFeedback (client, s, buf)
+ ClientPtr client;
+ StringFeedbackPtr s;
+ char **buf;
+ {
+ int i;
+ register char n;
+ xStringFeedbackState *s2;
+ KeySym *kptr;
+
+ s2 = (xStringFeedbackState *) *buf;
+ s2->class = StringFeedbackClass;
+ s2->length = sizeof (xStringFeedbackState) +
+ s->ctrl.num_symbols_supported * sizeof (KeySym);
+ s2->id = s->ctrl.id;
+ s2->max_symbols = s->ctrl.max_symbols;
+ s2->num_syms_supported = s->ctrl.num_symbols_supported;
+ *buf += sizeof (xStringFeedbackState);
+ kptr = (KeySym *) (*buf);
+ for (i=0; i<s->ctrl.num_symbols_supported; i++)
+ *kptr++ = *(s->ctrl.symbols_supported+i);
+ if (client->swapped)
+ {
+ swaps(&s2->length,n);
+ swaps(&s2->max_symbols,n);
+ swaps(&s2->num_syms_supported,n);
+ kptr = (KeySym *) (*buf);
+ for (i=0; i<s->ctrl.num_symbols_supported; i++,kptr++)
+ {
+ swapl(kptr,n);
+ }
+ }
+ *buf += (s->ctrl.num_symbols_supported * sizeof (KeySym));
+ }
+
+/***********************************************************************
+ *
+ * This procedure copies LedFeedbackClass data, swapping if necessary.
+ *
+ */
+
+void
+CopySwapLedFeedback (client, l, buf)
+ ClientPtr client;
+ LedFeedbackPtr l;
+ char **buf;
+ {
+ register char n;
+ xLedFeedbackState *l2;
+
+ l2 = (xLedFeedbackState *) *buf;
+ l2->class = LedFeedbackClass;
+ l2->length = sizeof (xLedFeedbackState);
+ l2->id = l->ctrl.id;
+ l2->led_values = l->ctrl.led_values;
+ l2->led_mask = l->ctrl.led_mask;
+ if (client->swapped)
+ {
+ swaps(&l2->length,n);
+ swapl(&l2->led_values,n);
+ swapl(&l2->led_mask,n);
+ }
+ *buf += sizeof (xLedFeedbackState);
+ }
+
+/***********************************************************************
+ *
+ * This procedure copies BellFeedbackClass data, swapping if necessary.
+ *
+ */
+
+void
+CopySwapBellFeedback (client, b, buf)
+ ClientPtr client;
+ BellFeedbackPtr b;
+ char **buf;
+ {
+ register char n;
+ xBellFeedbackState *b2;
+
+ b2 = (xBellFeedbackState *) *buf;
+ b2->class = BellFeedbackClass;
+ b2->length = sizeof (xBellFeedbackState);
+ b2->id = b->ctrl.id;
+ b2->percent = b->ctrl.percent;
+ b2->pitch = b->ctrl.pitch;
+ b2->duration = b->ctrl.duration;
+ if (client->swapped)
+ {
+ swaps(&b2->length,n);
+ swaps(&b2->pitch,n);
+ swaps(&b2->duration,n);
+ }
+ *buf += sizeof (xBellFeedbackState);
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the xGetFeedbackControl function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXGetFeedbackControl (client, size, rep)
+ ClientPtr client;
+ int size;
+ xGetFeedbackControlReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ swaps(&rep->num_feedbacks, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/getfctl.h b/nx-X11/programs/Xserver/Xi/getfctl.h
new file mode 100644
index 000000000..97805d9af
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getfctl.h
@@ -0,0 +1,93 @@
+/* $XFree86: xc/programs/Xserver/Xi/getfctl.h,v 3.1 1996/04/15 11:18:39 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef GETFCTL_H
+#define GETFCTL_H 1
+
+int
+SProcXGetFeedbackControl(
+ ClientPtr /* client */
+ );
+
+int
+ProcXGetFeedbackControl(
+ ClientPtr /* client */
+ );
+
+void
+CopySwapKbdFeedback (
+ ClientPtr /* client */,
+ KbdFeedbackPtr /* k */,
+ char ** /* buf */
+ );
+
+void
+CopySwapPtrFeedback (
+ ClientPtr /* client */,
+ PtrFeedbackPtr /* p */,
+ char ** /* buf */
+ );
+
+void
+CopySwapIntegerFeedback (
+ ClientPtr /* client */,
+ IntegerFeedbackPtr /* i */,
+ char ** /* buf */
+ );
+
+void
+CopySwapStringFeedback (
+ ClientPtr /* client */,
+ StringFeedbackPtr /* s */,
+ char ** /* buf */
+ );
+
+void
+CopySwapLedFeedback (
+ ClientPtr /* client */,
+ LedFeedbackPtr /* l */,
+ char ** /* buf */
+ );
+
+void
+CopySwapBellFeedback (
+ ClientPtr /* client */,
+ BellFeedbackPtr /* b */,
+ char ** /* buf */
+ );
+
+void
+SRepXGetFeedbackControl (
+ ClientPtr /* client */,
+ int /* size */,
+ xGetFeedbackControlReply * /* rep */
+ );
+
+#endif /* GETFCTL_H */
diff --git a/nx-X11/programs/Xserver/Xi/getfocus.c b/nx-X11/programs/Xserver/Xi/getfocus.c
new file mode 100644
index 000000000..3c1597cc9
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getfocus.c
@@ -0,0 +1,157 @@
+/* $Xorg: getfocus.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/getfocus.c,v 3.2 2001/01/17 22:13:24 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Extension function to get the focus for an extension device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "windowstr.h" /* focus struct */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "getfocus.h"
+
+/***********************************************************************
+ *
+ * This procedure gets the focus for a device.
+ *
+ */
+
+int
+SProcXGetDeviceFocus(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xGetDeviceFocusReq);
+ swaps(&stuff->length, n);
+ return(ProcXGetDeviceFocus(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure gets the focus for a device.
+ *
+ */
+
+int
+ProcXGetDeviceFocus(client)
+ ClientPtr client;
+ {
+ DeviceIntPtr dev;
+ FocusClassPtr focus;
+ xGetDeviceFocusReply rep;
+
+ REQUEST(xGetDeviceFocusReq);
+ REQUEST_SIZE_MATCH(xGetDeviceFocusReq);
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL || !dev->focus)
+ {
+ SendErrorToClient(client, IReqCode, X_GetDeviceFocus, 0, BadDevice);
+ return Success;
+ }
+
+ rep.repType = X_Reply;
+ rep.RepType = X_GetDeviceFocus;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ focus = dev->focus;
+
+ if (focus->win == NoneWin)
+ rep.focus = None;
+ else if (focus->win == PointerRootWin)
+ rep.focus = PointerRoot;
+ else if (focus->win == FollowKeyboardWin)
+ rep.focus = FollowKeyboard;
+ else
+ rep.focus = focus->win->drawable.id;
+
+ rep.time = focus->time.milliseconds;
+ rep.revertTo = focus->revert;
+ WriteReplyToClient (client, sizeof(xGetDeviceFocusReply), &rep);
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the GetDeviceFocus function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXGetDeviceFocus (client, size, rep)
+ ClientPtr client;
+ int size;
+ xGetDeviceFocusReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ swapl(&rep->focus, n);
+ swapl(&rep->time, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/getfocus.h b/nx-X11/programs/Xserver/Xi/getfocus.h
new file mode 100644
index 000000000..5d6438e1d
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getfocus.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/programs/Xserver/Xi/getfocus.h,v 3.1 1996/04/15 11:18:40 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef GETFOCUS_H
+#define GETFOCUS_H 1
+
+int
+SProcXGetDeviceFocus(
+ ClientPtr /* client */
+ );
+
+int
+ProcXGetDeviceFocus(
+ ClientPtr /* client */
+ );
+
+void
+SRepXGetDeviceFocus (
+ ClientPtr /* client */,
+ int /* size */,
+ xGetDeviceFocusReply * /* rep */
+ );
+
+#endif /* GETFOCUS_H */
diff --git a/nx-X11/programs/Xserver/Xi/getkmap.c b/nx-X11/programs/Xserver/Xi/getkmap.c
new file mode 100644
index 000000000..4e67d9c71
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getkmap.c
@@ -0,0 +1,178 @@
+/* $Xorg: getkmap.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/getkmap.c,v 3.3 2001/01/17 22:13:24 dawes Exp $ */
+
+/********************************************************************
+ *
+ * Get the key mapping for an extension device.
+ *
+ */
+
+#define NEED_EVENTS /* for inputstr.h */
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+#include "swaprep.h"
+
+#include "getkmap.h"
+
+/***********************************************************************
+ *
+ * This procedure gets the key mapping for an extension device,
+ * for clients on machines with a different byte ordering than the server.
+ *
+ */
+
+int
+SProcXGetDeviceKeyMapping(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xGetDeviceKeyMappingReq);
+ swaps(&stuff->length, n);
+ return(ProcXGetDeviceKeyMapping(client));
+ }
+
+/***********************************************************************
+ *
+ * Get the device key mapping.
+ *
+ */
+
+int
+ProcXGetDeviceKeyMapping(client)
+ register ClientPtr client;
+ {
+ xGetDeviceKeyMappingReply rep;
+ DeviceIntPtr dev;
+ KeySymsPtr k;
+
+ REQUEST(xGetDeviceKeyMappingReq);
+ REQUEST_SIZE_MATCH(xGetDeviceKeyMappingReq);
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient (client, IReqCode, X_GetDeviceKeyMapping, 0,
+ BadDevice);
+ return Success;
+ }
+
+ if (dev->key == NULL)
+ {
+ SendErrorToClient (client, IReqCode, X_GetDeviceKeyMapping, 0,
+ BadMatch);
+ return Success;
+ }
+ k = &dev->key->curKeySyms;
+
+ if ((stuff->firstKeyCode < k->minKeyCode) ||
+ (stuff->firstKeyCode > k->maxKeyCode))
+ {
+ client->errorValue = stuff->firstKeyCode;
+ SendErrorToClient (client, IReqCode, X_GetDeviceKeyMapping, 0,
+ BadValue);
+ return Success;
+ }
+
+ if (stuff->firstKeyCode + stuff->count > k->maxKeyCode + 1)
+ {
+ client->errorValue = stuff->count;
+ SendErrorToClient (client, IReqCode, X_GetDeviceKeyMapping, 0,
+ BadValue);
+ return Success;
+ }
+
+ rep.repType = X_Reply;
+ rep.RepType = X_GetDeviceKeyMapping;
+ rep.sequenceNumber = client->sequence;
+ rep.keySymsPerKeyCode = k->mapWidth;
+ rep.length = (k->mapWidth * stuff->count); /* KeySyms are 4 bytes */
+ WriteReplyToClient(client, sizeof(xGetDeviceKeyMappingReply), &rep);
+
+ client->pSwapReplyFunc = (ReplySwapPtr)CopySwap32Write;
+ WriteSwappedDataToClient(
+ client,
+ k->mapWidth * stuff->count * sizeof(KeySym),
+ &k->map[(stuff->firstKeyCode - k->minKeyCode) *
+ k->mapWidth]);
+
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XGetDeviceKeyMapping function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXGetDeviceKeyMapping (client, size, rep)
+ ClientPtr client;
+ int size;
+ xGetDeviceKeyMappingReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ WriteToClient(client, size, (char *)rep);
+ }
+
diff --git a/nx-X11/programs/Xserver/Xi/getkmap.h b/nx-X11/programs/Xserver/Xi/getkmap.h
new file mode 100644
index 000000000..5c2e3b189
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getkmap.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/programs/Xserver/Xi/getkmap.h,v 3.1 1996/04/15 11:18:41 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef GETKMAP_H
+#define GETKMAP_H 1
+
+int
+SProcXGetDeviceKeyMapping(
+ ClientPtr /* client */
+ );
+
+int
+ProcXGetDeviceKeyMapping(
+ ClientPtr /* client */
+ );
+
+void
+SRepXGetDeviceKeyMapping (
+ ClientPtr /* client */,
+ int /* size */,
+ xGetDeviceKeyMappingReply * /* rep */
+ );
+
+#endif /* GETKMAP_H */
diff --git a/nx-X11/programs/Xserver/Xi/getmmap.c b/nx-X11/programs/Xserver/Xi/getmmap.c
new file mode 100644
index 000000000..6b2e38d0b
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getmmap.c
@@ -0,0 +1,158 @@
+/* $Xorg: getmmap.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/getmmap.c,v 3.2 2001/01/17 22:13:25 dawes Exp $ */
+
+/********************************************************************
+ *
+ * Get the modifier mapping for an extension device.
+ *
+ */
+
+#define NEED_EVENTS /* for inputstr.h */
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h> /* Request macro */
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "getmmap.h"
+
+/***********************************************************************
+ *
+ * This procedure gets the modifier mapping for an extension device,
+ * for clients on machines with a different byte ordering than the server.
+ *
+ */
+
+int
+SProcXGetDeviceModifierMapping(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xGetDeviceModifierMappingReq);
+ swaps(&stuff->length, n);
+ return(ProcXGetDeviceModifierMapping(client));
+ }
+
+/***********************************************************************
+ *
+ * Get the device Modifier mapping.
+ *
+ */
+
+int
+ProcXGetDeviceModifierMapping(client)
+ ClientPtr client;
+ {
+ CARD8 maxkeys;
+ DeviceIntPtr dev;
+ xGetDeviceModifierMappingReply rep;
+ KeyClassPtr kp;
+
+ REQUEST(xGetDeviceModifierMappingReq);
+ REQUEST_SIZE_MATCH(xGetDeviceModifierMappingReq);
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient (client, IReqCode, X_GetDeviceModifierMapping, 0,
+ BadDevice);
+ return Success;
+ }
+
+ kp = dev->key;
+ if (kp == NULL)
+ {
+ SendErrorToClient (client, IReqCode, X_GetDeviceModifierMapping, 0,
+ BadMatch);
+ return Success;
+ }
+ maxkeys = kp->maxKeysPerModifier;
+
+ rep.repType = X_Reply;
+ rep.RepType = X_GetDeviceModifierMapping;
+ rep.numKeyPerModifier = maxkeys;
+ rep.sequenceNumber = client->sequence;
+ /* length counts 4 byte quantities - there are 8 modifiers 1 byte big */
+ rep.length = 2*maxkeys;
+
+ WriteReplyToClient(client, sizeof(xGetDeviceModifierMappingReply), &rep);
+
+ /* Reply with the (modified by DDX) map that SetModifierMapping passed in */
+ WriteToClient(client, 8*maxkeys, (char *)kp->modifierKeyMap);
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XGetDeviceModifierMapping function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXGetDeviceModifierMapping (client, size, rep)
+ ClientPtr client;
+ int size;
+ xGetDeviceModifierMappingReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/getmmap.h b/nx-X11/programs/Xserver/Xi/getmmap.h
new file mode 100644
index 000000000..88e4af427
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getmmap.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/programs/Xserver/Xi/getmmap.h,v 3.1 1996/04/15 11:18:42 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef GETMMAP_H
+#define GETMMAP_H 1
+
+int
+SProcXGetDeviceModifierMapping(
+ ClientPtr /* client */
+ );
+
+int
+ProcXGetDeviceModifierMapping(
+ ClientPtr /* client */
+ );
+
+void
+SRepXGetDeviceModifierMapping (
+ ClientPtr /* client */,
+ int /* size */,
+ xGetDeviceModifierMappingReply * /* rep */
+ );
+
+#endif /* GETMMAP_H */
diff --git a/nx-X11/programs/Xserver/Xi/getprop.c b/nx-X11/programs/Xserver/Xi/getprop.c
new file mode 100644
index 000000000..2b4de1f3e
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getprop.c
@@ -0,0 +1,215 @@
+/* $Xorg: getprop.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/getprop.c,v 3.5 2001/08/23 14:56:19 alanh Exp $ */
+
+/***********************************************************************
+ *
+ * Function to return the dont-propagate-list for an extension device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structs */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+#include "swaprep.h"
+
+#include "getprop.h"
+
+extern XExtEventInfo EventInfo[];
+extern int ExtEventIndex;
+
+/***********************************************************************
+ *
+ * Handle a request from a client with a different byte order.
+ *
+ */
+
+int
+SProcXGetDeviceDontPropagateList(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xGetDeviceDontPropagateListReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGetDeviceDontPropagateListReq);
+ swapl(&stuff->window, n);
+ return(ProcXGetDeviceDontPropagateList(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure lists the input devices available to the server.
+ *
+ */
+
+int
+ProcXGetDeviceDontPropagateList (client)
+ register ClientPtr client;
+ {
+ CARD16 count = 0;
+ int i;
+ XEventClass *buf = NULL, *tbuf;
+ WindowPtr pWin;
+ xGetDeviceDontPropagateListReply rep;
+ OtherInputMasks *others;
+
+ REQUEST(xGetDeviceDontPropagateListReq);
+ REQUEST_SIZE_MATCH(xGetDeviceDontPropagateListReq);
+
+ rep.repType = X_Reply;
+ rep.RepType = X_GetDeviceDontPropagateList;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.count = 0;
+
+ pWin = (WindowPtr) LookupWindow (stuff->window, client);
+ if (!pWin)
+ {
+ client->errorValue = stuff->window;
+ SendErrorToClient(client, IReqCode, X_GetDeviceDontPropagateList, 0,
+ BadWindow);
+ return Success;
+ }
+
+ if ((others = wOtherInputMasks(pWin)) != 0)
+ {
+ for (i=0; i<EMASKSIZE; i++)
+ tbuf = ClassFromMask (NULL, others->dontPropagateMask[i], i,
+ &count, COUNT);
+ if (count)
+ {
+ rep.count = count;
+ buf = (XEventClass *) xalloc (rep.count * sizeof(XEventClass));
+ rep.length = (rep.count * sizeof (XEventClass) + 3) >> 2;
+
+ tbuf = buf;
+ for (i=0; i<EMASKSIZE; i++)
+ tbuf = ClassFromMask (tbuf, others->dontPropagateMask[i], i,
+ NULL, CREATE);
+ }
+ }
+
+ WriteReplyToClient (client, sizeof (xGetDeviceDontPropagateListReply),
+ &rep);
+
+ if (count)
+ {
+ client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write;
+ WriteSwappedDataToClient( client, count * sizeof(XEventClass), buf);
+ xfree (buf);
+ }
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure gets a list of event classes from a mask word.
+ * A single mask may translate to more than one event class.
+ *
+ */
+
+XEventClass
+*ClassFromMask (buf, mask, maskndx, count, mode)
+ XEventClass *buf;
+ Mask mask;
+ int maskndx;
+ CARD16 *count;
+ int mode;
+ {
+ int i,j;
+ int id = maskndx;
+ Mask tmask = 0x80000000;
+
+ for (i=0; i<32; i++,tmask>>=1)
+ if (tmask & mask)
+ {
+ for (j=0; j<ExtEventIndex; j++)
+ if (EventInfo[j].mask == tmask)
+ {
+ if (mode == COUNT)
+ (*count)++;
+ else
+ *buf++ = (id << 8) | EventInfo[j].type;
+ }
+ }
+ return (buf);
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XGetDeviceDontPropagateList function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXGetDeviceDontPropagateList (client, size, rep)
+ ClientPtr client;
+ int size;
+ xGetDeviceDontPropagateListReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ swaps(&rep->count, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/getprop.h b/nx-X11/programs/Xserver/Xi/getprop.h
new file mode 100644
index 000000000..a8dcc3ab2
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getprop.h
@@ -0,0 +1,60 @@
+/* $XFree86: xc/programs/Xserver/Xi/getprop.h,v 3.1 1996/04/15 11:18:44 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef GETPROP_H
+#define GETPROP_H 1
+
+int
+SProcXGetDeviceDontPropagateList(
+ ClientPtr /* client */
+ );
+
+int
+ProcXGetDeviceDontPropagateList (
+ ClientPtr /* client */
+ );
+
+XEventClass *
+ClassFromMask (
+ XEventClass * /* buf */,
+ Mask /* mask */,
+ int /* maskndx */,
+ CARD16 * /* count */,
+ int /* mode */
+ );
+
+void
+SRepXGetDeviceDontPropagateList (
+ ClientPtr /* client */,
+ int /* size */,
+ xGetDeviceDontPropagateListReply * /* rep */
+ );
+
+#endif /* GETPROP_H */
diff --git a/nx-X11/programs/Xserver/Xi/getselev.c b/nx-X11/programs/Xserver/Xi/getselev.c
new file mode 100644
index 000000000..c2ec2b9d5
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getselev.c
@@ -0,0 +1,196 @@
+/* $XFree86: xc/programs/Xserver/Xi/getselev.c,v 3.5 2001/10/28 03:32:53 tsi Exp $ */
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/* $Xorg: getselev.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/***********************************************************************
+ *
+ * Extension function to get the current selected events for a given window.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window struct */
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+#include "swaprep.h"
+
+#include "getprop.h"
+#include "getselev.h"
+
+/***********************************************************************
+ *
+ * This procedure gets the current selected extension events.
+ *
+ */
+
+int
+SProcXGetSelectedExtensionEvents(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xGetSelectedExtensionEventsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq);
+ swapl(&stuff->window, n);
+ return(ProcXGetSelectedExtensionEvents(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure gets the current device select mask,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+int
+ProcXGetSelectedExtensionEvents(client)
+ register ClientPtr client;
+ {
+ int i;
+ int total_length = 0;
+ xGetSelectedExtensionEventsReply rep;
+ WindowPtr pWin;
+ XEventClass *buf = NULL;
+ XEventClass *tclient;
+ XEventClass *aclient;
+ OtherInputMasks *pOthers;
+ InputClientsPtr others;
+
+ REQUEST(xGetSelectedExtensionEventsReq);
+ REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq);
+
+ rep.repType = X_Reply;
+ rep.RepType = X_GetSelectedExtensionEvents;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.this_client_count = 0;
+ rep.all_clients_count = 0;
+
+ if (!(pWin = LookupWindow(stuff->window, client)))
+ {
+ SendErrorToClient(client, IReqCode, X_GetSelectedExtensionEvents, 0,
+ BadWindow);
+ return Success;
+ }
+
+ if ((pOthers = wOtherInputMasks(pWin)) != 0)
+ {
+ for (others = pOthers->inputClients; others; others=others->next)
+ for (i=0; i<EMASKSIZE; i++)
+ tclient = ClassFromMask (NULL, others->mask[i], i,
+ &rep.all_clients_count, COUNT);
+
+ for (others = pOthers->inputClients; others; others=others->next)
+ if (SameClient(others, client))
+ {
+ for (i=0; i<EMASKSIZE; i++)
+ tclient = ClassFromMask (NULL, others->mask[i], i,
+ &rep.this_client_count, COUNT);
+ break;
+ }
+
+ total_length = (rep.all_clients_count + rep.this_client_count) *
+ sizeof (XEventClass);
+ rep.length = (total_length + 3) >> 2;
+ buf = (XEventClass *) xalloc (total_length);
+
+ tclient = buf;
+ aclient = buf + rep.this_client_count;
+ if (others)
+ for (i=0; i<EMASKSIZE; i++)
+ tclient = ClassFromMask (tclient, others->mask[i], i, NULL, CREATE);
+
+ for (others = pOthers->inputClients; others; others=others->next)
+ for (i=0; i<EMASKSIZE; i++)
+ aclient = ClassFromMask (aclient, others->mask[i], i, NULL, CREATE);
+ }
+
+ WriteReplyToClient (client, sizeof(xGetSelectedExtensionEventsReply), &rep);
+
+ if (total_length)
+ {
+ client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
+ WriteSwappedDataToClient( client, total_length, buf);
+ xfree (buf);
+ }
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XGetSelectedExtensionEvents function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXGetSelectedExtensionEvents (client, size, rep)
+ ClientPtr client;
+ int size;
+ xGetSelectedExtensionEventsReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ swaps(&rep->this_client_count, n);
+ swaps(&rep->all_clients_count, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/getselev.h b/nx-X11/programs/Xserver/Xi/getselev.h
new file mode 100644
index 000000000..bb0e71a11
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getselev.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/programs/Xserver/Xi/getselev.h,v 3.1 1996/04/15 11:18:49 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef GETSELEV_H
+#define GETSELEV_H 1
+
+int
+SProcXGetSelectedExtensionEvents(
+ ClientPtr /* client */
+ );
+
+int
+ProcXGetSelectedExtensionEvents(
+ ClientPtr /* client */
+ );
+
+void
+SRepXGetSelectedExtensionEvents (
+ ClientPtr /* client */,
+ int /* size */,
+ xGetSelectedExtensionEventsReply * /* rep */
+ );
+
+#endif /* GETSELEV_H */
diff --git a/nx-X11/programs/Xserver/Xi/getvers.c b/nx-X11/programs/Xserver/Xi/getvers.c
new file mode 100644
index 000000000..1ad0ce785
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getvers.c
@@ -0,0 +1,157 @@
+/* $Xorg: getvers.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/getvers.c,v 3.2 2001/01/17 22:13:25 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Extension function to return the version of the extension.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "getvers.h"
+
+XExtensionVersion AllExtensionVersions[128];
+
+/***********************************************************************
+ *
+ * Handle a request from a client with a different byte order than us.
+ *
+ */
+
+int
+SProcXGetExtensionVersion(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xGetExtensionVersionReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq);
+ swaps(&stuff->nbytes, n);
+ return(ProcXGetExtensionVersion(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure lists the input devices available to the server.
+ *
+ */
+
+int
+ProcXGetExtensionVersion (client)
+ register ClientPtr client;
+ {
+ xGetExtensionVersionReply rep;
+
+ REQUEST(xGetExtensionVersionReq);
+ REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq);
+
+ if (stuff->length != (sizeof(xGetExtensionVersionReq) +
+ stuff->nbytes + 3)>>2)
+ {
+ SendErrorToClient(client, IReqCode, X_GetExtensionVersion, 0,
+ BadLength);
+ return Success;
+ }
+
+ rep.repType = X_Reply;
+ rep.RepType = X_GetExtensionVersion;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.major_version = 0;
+ rep.minor_version = 0;
+
+ rep.present = TRUE;
+ if (rep.present)
+ {
+ rep.major_version =
+ AllExtensionVersions[IReqCode-128].major_version;
+ rep.minor_version =
+ AllExtensionVersions[IReqCode-128].minor_version;
+ }
+ WriteReplyToClient (client, sizeof (xGetExtensionVersionReply), &rep);
+
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XGetExtensionVersion function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXGetExtensionVersion (client, size, rep)
+ ClientPtr client;
+ int size;
+ xGetExtensionVersionReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ swaps(&rep->major_version, n);
+ swaps(&rep->minor_version, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/getvers.h b/nx-X11/programs/Xserver/Xi/getvers.h
new file mode 100644
index 000000000..93b7bfbec
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/getvers.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/programs/Xserver/Xi/getvers.h,v 3.1 1996/04/15 11:18:50 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef GETVERS_H
+#define GETVERS_H 1
+
+int
+SProcXGetExtensionVersion(
+ ClientPtr /* client */
+ );
+
+int
+ProcXGetExtensionVersion (
+ ClientPtr /* client */
+ );
+
+void
+SRepXGetExtensionVersion (
+ ClientPtr /* client */,
+ int /* size */,
+ xGetExtensionVersionReply * /* rep */
+ );
+
+#endif /* GETVERS_H */
diff --git a/nx-X11/programs/Xserver/Xi/grabdev.c b/nx-X11/programs/Xserver/Xi/grabdev.c
new file mode 100644
index 000000000..3b124a0f4
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/grabdev.c
@@ -0,0 +1,232 @@
+/* $Xorg: grabdev.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/grabdev.c,v 3.2 2001/01/17 22:13:25 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Extension function to grab an extension device.
+ *
+ */
+
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+#include "dixevents.h" /* GrabDevice */
+
+#include "grabdev.h"
+
+extern XExtEventInfo EventInfo[];
+extern int ExtEventIndex;
+
+/***********************************************************************
+ *
+ * Swap the request if the requestor has a different byte order than us.
+ *
+ */
+
+int
+SProcXGrabDevice(client)
+ register ClientPtr client;
+ {
+ register char n;
+ register long *p;
+ register int i;
+
+ REQUEST(xGrabDeviceReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xGrabDeviceReq);
+ swapl(&stuff->grabWindow, n);
+ swapl(&stuff->time, n);
+ swaps(&stuff->event_count, n);
+ p = (long *) &stuff[1];
+ for (i=0; i<stuff->event_count; i++)
+ {
+ swapl(p, n);
+ p++;
+ }
+
+ return(ProcXGrabDevice(client));
+ }
+
+/***********************************************************************
+ *
+ * Grab an extension device.
+ *
+ */
+
+int
+ProcXGrabDevice(client)
+ ClientPtr client;
+ {
+ int error;
+ xGrabDeviceReply rep;
+ DeviceIntPtr dev;
+ struct tmask tmp[EMASKSIZE];
+
+ REQUEST(xGrabDeviceReq);
+ REQUEST_AT_LEAST_SIZE(xGrabDeviceReq);
+
+ if (stuff->length !=(sizeof(xGrabDeviceReq)>>2) + stuff->event_count)
+ {
+ SendErrorToClient (client, IReqCode, X_GrabDevice, 0, BadLength);
+ return Success;
+ }
+
+ rep.repType = X_Reply;
+ rep.RepType = X_GrabDevice;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_GrabDevice, 0, BadDevice);
+ return Success;
+ }
+
+ if (CreateMaskFromList (client, (XEventClass *)&stuff[1],
+ stuff->event_count, tmp, dev, X_GrabDevice) != Success)
+ return Success;
+
+ error = GrabDevice (client, dev, stuff->this_device_mode,
+ stuff->other_devices_mode, stuff->grabWindow, stuff->ownerEvents,
+ stuff->time, tmp[stuff->deviceid].mask, &rep.status);
+
+ if (error != Success)
+ {
+ SendErrorToClient(client, IReqCode, X_GrabDevice, 0, error);
+ return Success;
+ }
+ WriteReplyToClient(client, sizeof(xGrabDeviceReply), &rep);
+ return Success;
+ }
+
+
+/***********************************************************************
+ *
+ * This procedure creates an event mask from a list of XEventClasses.
+ *
+ */
+
+int
+CreateMaskFromList (client, list, count, mask, dev, req)
+ ClientPtr client;
+ XEventClass *list;
+ int count;
+ struct tmask mask[];
+ DeviceIntPtr dev;
+ int req;
+ {
+ int i,j;
+ int device;
+ DeviceIntPtr tdev;
+
+ for (i=0; i<EMASKSIZE; i++)
+ {
+ mask[i].mask = 0;
+ mask[i].dev = NULL;
+ }
+
+ for (i=0; i<count; i++, list++)
+ {
+ device = *list >> 8;
+ if (device > 255)
+ {
+ SendErrorToClient(client, IReqCode, req, 0, BadClass);
+ return BadClass;
+ }
+ tdev = LookupDeviceIntRec (device);
+ if (tdev==NULL || (dev != NULL && tdev != dev))
+ {
+ SendErrorToClient(client, IReqCode, req, 0, BadClass);
+ return BadClass;
+ }
+
+ for (j=0; j<ExtEventIndex; j++)
+ if (EventInfo[j].type == (*list & 0xff))
+ {
+ mask[device].mask |= EventInfo[j].mask;
+ mask[device].dev = (Pointer) tdev;
+ break;
+ }
+ }
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XGrabDevice function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXGrabDevice (client, size, rep)
+ ClientPtr client;
+ int size;
+ xGrabDeviceReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/grabdev.h b/nx-X11/programs/Xserver/Xi/grabdev.h
new file mode 100644
index 000000000..d149da5d9
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/grabdev.h
@@ -0,0 +1,61 @@
+/* $XFree86: xc/programs/Xserver/Xi/grabdev.h,v 3.1 1996/04/15 11:18:51 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef GRABDEV_H
+#define GRABDEV_H 1
+
+int
+SProcXGrabDevice(
+ ClientPtr /* client */
+ );
+
+int
+ProcXGrabDevice(
+ ClientPtr /* client */
+ );
+
+int
+CreateMaskFromList (
+ ClientPtr /* client */,
+ XEventClass * /* list */,
+ int /* count */,
+ struct tmask /* mask */[],
+ DeviceIntPtr /* dev */,
+ int /* req */
+ );
+
+void
+SRepXGrabDevice (
+ ClientPtr /* client */,
+ int /* size */,
+ xGrabDeviceReply * /* rep */
+ );
+
+#endif /* GRABDEV_H */
diff --git a/nx-X11/programs/Xserver/Xi/grabdevb.c b/nx-X11/programs/Xserver/Xi/grabdevb.c
new file mode 100644
index 000000000..84f061086
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/grabdevb.c
@@ -0,0 +1,170 @@
+/* $Xorg: grabdevb.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/grabdevb.c,v 3.2 2001/01/17 22:13:25 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Extension function to grab a button on an extension device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "exevents.h"
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "grabdev.h"
+#include "grabdevb.h"
+
+/***********************************************************************
+ *
+ * Handle requests from clients with a different byte order.
+ *
+ */
+
+int
+SProcXGrabDeviceButton(client)
+ register ClientPtr client;
+ {
+ register char n;
+ register long *p;
+ register int i;
+
+ REQUEST(xGrabDeviceButtonReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xGrabDeviceButtonReq);
+ swapl(&stuff->grabWindow, n);
+ swaps(&stuff->modifiers, n);
+ swaps(&stuff->event_count, n);
+ p = (long *) &stuff[1];
+ for (i=0; i<stuff->event_count; i++)
+ {
+ swapl(p, n);
+ p++;
+ }
+
+ return(ProcXGrabDeviceButton(client));
+ }
+
+/***********************************************************************
+ *
+ * Grab a button on an extension device.
+ *
+ */
+
+int
+ProcXGrabDeviceButton(client)
+ ClientPtr client;
+ {
+ int ret;
+ DeviceIntPtr dev;
+ DeviceIntPtr mdev;
+ XEventClass *class;
+ struct tmask tmp[EMASKSIZE];
+
+ REQUEST(xGrabDeviceButtonReq);
+ REQUEST_AT_LEAST_SIZE(xGrabDeviceButtonReq);
+
+ if (stuff->length !=(sizeof(xGrabDeviceButtonReq)>>2) + stuff->event_count)
+ {
+ SendErrorToClient (client, IReqCode, X_GrabDeviceButton, 0, BadLength);
+ return Success;
+ }
+
+ dev = LookupDeviceIntRec (stuff->grabbed_device);
+ if (dev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0,
+ BadDevice);
+ return Success;
+ }
+ if (stuff->modifier_device != UseXKeyboard)
+ {
+ mdev = LookupDeviceIntRec (stuff->modifier_device);
+ if (mdev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0,
+ BadDevice);
+ return Success;
+ }
+ if (mdev->key == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0,
+ BadMatch);
+ return Success;
+ }
+ }
+ else
+ mdev = (DeviceIntPtr) LookupKeyboardDevice();
+
+ class = (XEventClass *) (&stuff[1]); /* first word of values */
+
+ if ((ret = CreateMaskFromList (client, class,
+ stuff->event_count, tmp, dev, X_GrabDeviceButton)) != Success)
+ return Success;
+ ret = GrabButton(client, dev, stuff->this_device_mode,
+ stuff->other_devices_mode, stuff->modifiers, mdev, stuff->button,
+ stuff->grabWindow, stuff->ownerEvents, (Cursor)0, (Window)0,
+ tmp[stuff->grabbed_device].mask);
+
+ if (ret != Success)
+ SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0, ret);
+ return(Success);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/grabdevb.h b/nx-X11/programs/Xserver/Xi/grabdevb.h
new file mode 100644
index 000000000..50929a32b
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/grabdevb.h
@@ -0,0 +1,44 @@
+/* $XFree86: xc/programs/Xserver/Xi/grabdevb.h,v 3.1 1996/04/15 11:18:52 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef GRABDEVB_H
+#define GRABDEVB_H 1
+
+int
+SProcXGrabDeviceButton(
+ ClientPtr /* client */
+ );
+
+int
+ProcXGrabDeviceButton(
+ ClientPtr /* client */
+ );
+
+#endif /* GRABDEVB_H */
diff --git a/nx-X11/programs/Xserver/Xi/grabdevk.c b/nx-X11/programs/Xserver/Xi/grabdevk.c
new file mode 100644
index 000000000..17a9a9cf6
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/grabdevk.c
@@ -0,0 +1,174 @@
+/* $Xorg: grabdevk.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/grabdevk.c,v 3.2 2001/01/17 22:13:25 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Extension function to grab a key on an extension device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "exevents.h"
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "grabdev.h"
+#include "grabdevk.h"
+
+/***********************************************************************
+ *
+ * Handle requests from clients with a different byte order.
+ *
+ */
+
+int
+SProcXGrabDeviceKey(client)
+ register ClientPtr client;
+ {
+ register char n;
+ register long *p;
+ register int i;
+
+ REQUEST(xGrabDeviceKeyReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xGrabDeviceKeyReq);
+ swapl(&stuff->grabWindow, n);
+ swaps(&stuff->modifiers, n);
+ swaps(&stuff->event_count, n);
+ p = (long *) &stuff[1];
+ for (i=0; i<stuff->event_count; i++)
+ {
+ swapl(p, n);
+ p++;
+ }
+ return(ProcXGrabDeviceKey(client));
+ }
+
+/***********************************************************************
+ *
+ * Grab a key on an extension device.
+ *
+ */
+
+int
+ProcXGrabDeviceKey(client)
+ ClientPtr client;
+ {
+ int ret;
+ DeviceIntPtr dev;
+ DeviceIntPtr mdev;
+ XEventClass *class;
+ struct tmask tmp[EMASKSIZE];
+
+ REQUEST(xGrabDeviceKeyReq);
+ REQUEST_AT_LEAST_SIZE(xGrabDeviceKeyReq);
+
+ if (stuff->length !=(sizeof(xGrabDeviceKeyReq)>>2) + stuff->event_count)
+ {
+ SendErrorToClient (client, IReqCode, X_GrabDeviceKey, 0, BadLength);
+ return Success;
+ }
+
+ dev = LookupDeviceIntRec (stuff->grabbed_device);
+ if (dev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0,
+ BadDevice);
+ return Success;
+ }
+
+ if (stuff->modifier_device != UseXKeyboard)
+ {
+ mdev = LookupDeviceIntRec (stuff->modifier_device);
+ if (mdev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0,
+ BadDevice);
+ return Success;
+ }
+ if (mdev->key == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0,
+ BadMatch);
+ return Success;
+ }
+ }
+ else
+ mdev = (DeviceIntPtr) LookupKeyboardDevice();
+
+ class = (XEventClass *) (&stuff[1]); /* first word of values */
+
+ if ((ret = CreateMaskFromList (client, class,
+ stuff->event_count, tmp, dev, X_GrabDeviceKey)) != Success)
+ return Success;
+
+ ret = GrabKey(client, dev, stuff->this_device_mode,
+ stuff->other_devices_mode, stuff->modifiers, mdev, stuff->key,
+ stuff->grabWindow, stuff->ownerEvents, tmp[stuff->grabbed_device].mask);
+
+ if (ret != Success)
+ {
+ SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0, ret);
+ return Success;
+ }
+
+ return Success;
+ }
diff --git a/nx-X11/programs/Xserver/Xi/grabdevk.h b/nx-X11/programs/Xserver/Xi/grabdevk.h
new file mode 100644
index 000000000..230461937
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/grabdevk.h
@@ -0,0 +1,44 @@
+/* $XFree86: xc/programs/Xserver/Xi/grabdevk.h,v 3.1 1996/04/15 11:18:53 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef GRABDEVK_H
+#define GRABDEVK_H 1
+
+int
+SProcXGrabDeviceKey(
+ ClientPtr /* client */
+ );
+
+int
+ProcXGrabDeviceKey(
+ ClientPtr /* client */
+ );
+
+#endif /* GRABDEVK_H */
diff --git a/nx-X11/programs/Xserver/Xi/gtmotion.c b/nx-X11/programs/Xserver/Xi/gtmotion.c
new file mode 100644
index 000000000..02b1fee32
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/gtmotion.c
@@ -0,0 +1,213 @@
+/* $Xorg: gtmotion.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/gtmotion.c,v 3.6 2001/10/28 03:32:53 tsi Exp $ */
+
+/***********************************************************************
+ *
+ * Request to get the motion history from an extension device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exevents.h"
+#include "exglobals.h"
+
+#include "gtmotion.h"
+
+/***********************************************************************
+ *
+ * Swap the request if server and client have different byte ordering.
+ *
+ */
+
+int
+SProcXGetDeviceMotionEvents(client)
+register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xGetDeviceMotionEventsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGetDeviceMotionEventsReq);
+ swapl(&stuff->start, n);
+ swapl(&stuff->stop, n);
+ return(ProcXGetDeviceMotionEvents(client));
+ }
+
+/****************************************************************************
+ *
+ * Get the motion history for an extension pointer devices.
+ *
+ */
+
+int
+ProcXGetDeviceMotionEvents(client)
+ ClientPtr client;
+{
+ INT32 *coords = NULL, *bufptr;
+ xGetDeviceMotionEventsReply rep;
+ unsigned long i;
+ int num_events, axes, size = 0, tsize;
+ unsigned long nEvents;
+ DeviceIntPtr dev;
+ TimeStamp start, stop;
+ int length = 0;
+ ValuatorClassPtr v;
+
+ REQUEST(xGetDeviceMotionEventsReq);
+
+ REQUEST_SIZE_MATCH(xGetDeviceMotionEventsReq);
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_GetDeviceMotionEvents, 0,
+ BadDevice);
+ return Success;
+ }
+ v = dev->valuator;
+ if (v==NULL || v->numAxes == 0)
+ {
+ SendErrorToClient(client, IReqCode, X_GetDeviceMotionEvents, 0,
+ BadMatch);
+ return Success;
+ }
+ if (dev->valuator->motionHintWindow)
+ MaybeStopDeviceHint(dev, client);
+ axes = v->numAxes;
+ rep.repType = X_Reply;
+ rep.RepType = X_GetDeviceMotionEvents;
+ rep.sequenceNumber = client->sequence;
+ rep.nEvents = 0;
+ rep.axes = axes;
+ rep.mode = v->mode & DeviceMode;
+ rep.length = 0;
+ start = ClientTimeToServerTime(stuff->start);
+ stop = ClientTimeToServerTime(stuff->stop);
+ if (CompareTimeStamps(start, stop) == LATER ||
+ CompareTimeStamps(start, currentTime) == LATER)
+ {
+ WriteReplyToClient(client, sizeof(xGetDeviceMotionEventsReply), &rep);
+ return Success;
+ }
+ if (CompareTimeStamps(stop, currentTime) == LATER)
+ stop = currentTime;
+ num_events = v->numMotionEvents;
+ if (num_events)
+ {
+ size = sizeof(Time) + (axes * sizeof (INT32));
+ tsize = num_events * size;
+ coords = (INT32 *) ALLOCATE_LOCAL(tsize);
+ if (!coords)
+ {
+ SendErrorToClient(client, IReqCode, X_GetDeviceMotionEvents, 0,
+ BadAlloc);
+ return Success;
+ }
+ rep.nEvents = (v->GetMotionProc) (
+ dev, (xTimecoord *)coords, /* XXX */
+ start.milliseconds, stop.milliseconds, (ScreenPtr)NULL);
+ }
+ if (rep.nEvents > 0)
+ {
+ length = (rep.nEvents * size +3) >> 2;
+ rep.length = length;
+ }
+ nEvents = rep.nEvents;
+ WriteReplyToClient(client, sizeof(xGetDeviceMotionEventsReply), &rep);
+ if (nEvents)
+ {
+ if (client->swapped)
+ {
+ register char n;
+
+ bufptr = coords;
+ for (i=0; i<nEvents * (axes+1); i++)
+ {
+ swapl(bufptr, n);
+ bufptr++;
+ }
+ }
+ WriteToClient(client, length * 4, (char *)coords);
+ }
+ if (coords)
+ DEALLOCATE_LOCAL(coords);
+ return Success;
+}
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XGetDeviceMotionEvents function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXGetDeviceMotionEvents (client, size, rep)
+ ClientPtr client;
+ int size;
+ xGetDeviceMotionEventsReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ swapl(&rep->nEvents, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/gtmotion.h b/nx-X11/programs/Xserver/Xi/gtmotion.h
new file mode 100644
index 000000000..205b19958
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/gtmotion.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/programs/Xserver/Xi/gtmotion.h,v 3.1 1996/04/15 11:18:56 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef GTMOTION_H
+#define GTMOTION_H 1
+
+int
+SProcXGetDeviceMotionEvents(
+ ClientPtr /* client */
+ );
+
+int
+ProcXGetDeviceMotionEvents(
+ ClientPtr /* client */
+ );
+
+void
+SRepXGetDeviceMotionEvents (
+ ClientPtr /* client */,
+ int /* size */,
+ xGetDeviceMotionEventsReply * /* rep */
+ );
+
+#endif /* GTMOTION_H */
diff --git a/nx-X11/programs/Xserver/Xi/listdev.c b/nx-X11/programs/Xserver/Xi/listdev.c
new file mode 100644
index 000000000..b7eed86b7
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/listdev.c
@@ -0,0 +1,407 @@
+/* $Xorg: listdev.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/listdev.c,v 3.3 2001/01/17 22:13:25 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Extension function to list the available input devices.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h"
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h" /* FIXME */
+
+#include "listdev.h"
+
+#define VPC 20 /* Max # valuators per chunk */
+
+/***********************************************************************
+ *
+ * This procedure lists the input devices available to the server.
+ *
+ */
+
+int
+SProcXListInputDevices(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xListInputDevicesReq);
+ swaps(&stuff->length, n);
+ return(ProcXListInputDevices(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure lists the input devices available to the server.
+ *
+ */
+
+int
+ProcXListInputDevices (client)
+ register ClientPtr client;
+ {
+ xListInputDevicesReply rep;
+ int numdevs;
+ int namesize = 1; /* need 1 extra byte for strcpy */
+ int size = 0;
+ int total_length;
+ char *devbuf;
+ char *classbuf;
+ char *namebuf;
+ char *savbuf;
+ xDeviceInfo *dev;
+ DeviceIntPtr d;
+
+ REQUEST_SIZE_MATCH(xListInputDevicesReq);
+
+ rep.repType = X_Reply;
+ rep.RepType = X_ListInputDevices;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ AddOtherInputDevices ();
+ numdevs = inputInfo.numDevices;
+
+ for (d=inputInfo.devices; d; d=d->next)
+ SizeDeviceInfo (d, &namesize, &size);
+ for (d=inputInfo.off_devices; d; d=d->next)
+ SizeDeviceInfo (d, &namesize, &size);
+
+ total_length = numdevs * sizeof (xDeviceInfo) + size + namesize;
+ devbuf = (char *) xalloc (total_length);
+ classbuf = devbuf + (numdevs * sizeof (xDeviceInfo));
+ namebuf = classbuf + size;
+ savbuf = devbuf;
+
+ dev = (xDeviceInfoPtr) devbuf;
+ for (d=inputInfo.devices; d; d=d->next,dev++)
+ ListDeviceInfo (client, d, dev, &devbuf, &classbuf, &namebuf);
+ for (d=inputInfo.off_devices; d; d=d->next,dev++)
+ ListDeviceInfo (client, d, dev, &devbuf, &classbuf, &namebuf);
+
+ rep.ndevices = numdevs;
+ rep.length = (total_length + 3) >> 2;
+ WriteReplyToClient (client, sizeof (xListInputDevicesReply), &rep);
+ WriteToClient(client, total_length, savbuf);
+ xfree (savbuf);
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure calculates the size of the information to be returned
+ * for an input device.
+ *
+ */
+
+void
+SizeDeviceInfo (d, namesize, size)
+ DeviceIntPtr d;
+ int *namesize;
+ int *size;
+ {
+ int chunks;
+
+ *namesize += 1;
+ if (d->name)
+ *namesize += strlen (d->name);
+ if (d->key != NULL)
+ *size += sizeof (xKeyInfo);
+ if (d->button != NULL)
+ *size += sizeof (xButtonInfo);
+ if (d->valuator != NULL)
+ {
+ chunks = ((int) d->valuator->numAxes + 19) / VPC;
+ *size += (chunks * sizeof(xValuatorInfo) +
+ d->valuator->numAxes * sizeof(xAxisInfo));
+ }
+ }
+
+/***********************************************************************
+ *
+ * This procedure lists information to be returned for an input device.
+ *
+ */
+
+void
+ListDeviceInfo (client, d, dev, devbuf, classbuf, namebuf)
+ ClientPtr client;
+ DeviceIntPtr d;
+ xDeviceInfoPtr dev;
+ char **devbuf;
+ char **classbuf;
+ char **namebuf;
+ {
+ CopyDeviceName (namebuf, d->name);
+ CopySwapDevice (client, d, 0, devbuf);
+ if (d->key != NULL)
+ {
+ CopySwapKeyClass(client, d->key, classbuf);
+ dev->num_classes++;
+ }
+ if (d->button != NULL)
+ {
+ CopySwapButtonClass(client, d->button, classbuf);
+ dev->num_classes++;
+ }
+ if (d->valuator != NULL)
+ {
+ dev->num_classes += CopySwapValuatorClass(client, d->valuator, classbuf);
+ }
+ }
+
+/***********************************************************************
+ *
+ * This procedure copies data to the DeviceInfo struct, swapping if necessary.
+ *
+ * We need the extra byte in the allocated buffer, because the trailing null
+ * hammers one extra byte, which is overwritten by the next name except for
+ * the last name copied.
+ *
+ */
+
+void
+CopyDeviceName (namebuf, name)
+ char **namebuf;
+ char *name;
+ {
+ char *nameptr = (char *) *namebuf;
+
+ if (name)
+ {
+ *nameptr++ = strlen (name);
+ strcpy (nameptr, name);
+ *namebuf += (strlen (name)+1);
+ }
+ else
+ {
+ *nameptr++ = 0;
+ *namebuf += 1;
+ }
+ }
+
+/***********************************************************************
+ *
+ * This procedure copies data to the DeviceInfo struct, swapping if necessary.
+ *
+ */
+
+void
+CopySwapDevice (client, d, num_classes, buf)
+ register ClientPtr client;
+ DeviceIntPtr d;
+ int num_classes;
+ char **buf;
+ {
+ register char n;
+ xDeviceInfoPtr dev;
+
+ dev = (xDeviceInfoPtr) *buf;
+
+ dev->id = d->id;
+ dev->type = d->type;
+ dev->num_classes = num_classes;
+ if (d == inputInfo.keyboard)
+ dev->use = IsXKeyboard;
+ else if (d == inputInfo.pointer)
+ dev->use = IsXPointer;
+ else
+ dev->use = IsXExtensionDevice;
+ if (client->swapped)
+ {
+ swapl(&dev->type, n); /* macro - braces are required */
+ }
+ *buf += sizeof (xDeviceInfo);
+ }
+
+/***********************************************************************
+ *
+ * This procedure copies KeyClass information, swapping if necessary.
+ *
+ */
+
+void
+CopySwapKeyClass (client, k, buf)
+ register ClientPtr client;
+ KeyClassPtr k;
+ char **buf;
+ {
+ register char n;
+ xKeyInfoPtr k2;
+
+ k2 = (xKeyInfoPtr) *buf;
+ k2->class = KeyClass;
+ k2->length = sizeof (xKeyInfo);
+ k2->min_keycode = k->curKeySyms.minKeyCode;
+ k2->max_keycode = k->curKeySyms.maxKeyCode;
+ k2->num_keys = k2->max_keycode - k2->min_keycode + 1;
+ if (client->swapped)
+ {
+ swaps(&k2->num_keys,n);
+ }
+ *buf += sizeof (xKeyInfo);
+ }
+
+/***********************************************************************
+ *
+ * This procedure copies ButtonClass information, swapping if necessary.
+ *
+ */
+
+void
+CopySwapButtonClass (client, b, buf)
+ register ClientPtr client;
+ ButtonClassPtr b;
+ char **buf;
+ {
+ register char n;
+ xButtonInfoPtr b2;
+
+ b2 = (xButtonInfoPtr) *buf;
+ b2->class = ButtonClass;
+ b2->length = sizeof (xButtonInfo);
+ b2->num_buttons = b->numButtons;
+ if (client->swapped)
+ {
+ swaps(&b2->num_buttons,n); /* macro - braces are required */
+ }
+ *buf += sizeof (xButtonInfo);
+ }
+
+/***********************************************************************
+ *
+ * This procedure copies ValuatorClass information, swapping if necessary.
+ *
+ * Devices may have up to 255 valuators. The length of a ValuatorClass is
+ * defined to be sizeof(ValuatorClassInfo) + num_axes * sizeof (xAxisInfo).
+ * The maximum length is therefore (8 + 255 * 12) = 3068. However, the
+ * length field is one byte. If a device has more than 20 valuators, we
+ * must therefore return multiple valuator classes to the client.
+ *
+ */
+
+int
+CopySwapValuatorClass (client, v, buf)
+ register ClientPtr client;
+ ValuatorClassPtr v;
+ char **buf;
+{
+ int i, j, axes, t_axes;
+ register char n;
+ xValuatorInfoPtr v2;
+ AxisInfo *a;
+ xAxisInfoPtr a2;
+
+ for (i=0,axes=v->numAxes; i < ((v->numAxes+19)/VPC); i++, axes-=VPC) {
+ t_axes = axes < VPC ? axes : VPC;
+ if (t_axes < 0)
+ t_axes = v->numAxes % VPC;
+ v2 = (xValuatorInfoPtr) *buf;
+ v2->class = ValuatorClass;
+ v2->length = sizeof (xValuatorInfo) + t_axes * sizeof (xAxisInfo);
+ v2->num_axes = t_axes;
+ v2->mode = v->mode & DeviceMode;
+ v2->motion_buffer_size = v->numMotionEvents;
+ if (client->swapped)
+ {
+ swapl(&v2->motion_buffer_size,n);
+ }
+ *buf += sizeof (xValuatorInfo);
+ a = v->axes + (VPC * i);
+ a2 = (xAxisInfoPtr) *buf;
+ for (j=0; j<t_axes; j++) {
+ a2->min_value = a->min_value;
+ a2->max_value = a->max_value;
+ a2->resolution = a->resolution;
+ if (client->swapped) {
+ swapl(&a2->min_value,n);
+ swapl(&a2->max_value,n);
+ swapl(&a2->resolution,n);
+ }
+ a2++;
+ a++;
+ *buf += sizeof (xAxisInfo);
+ }
+ }
+ return (i);
+}
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XListInputDevices function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXListInputDevices (client, size, rep)
+ ClientPtr client;
+ int size;
+ xListInputDevicesReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/listdev.h b/nx-X11/programs/Xserver/Xi/listdev.h
new file mode 100644
index 000000000..125ea3580
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/listdev.h
@@ -0,0 +1,103 @@
+/* $XFree86: xc/programs/Xserver/Xi/listdev.h,v 3.1 1996/04/15 11:18:57 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef LISTDEV_H
+#define LISTDEV_H 1
+
+int
+SProcXListInputDevices(
+ ClientPtr /* client */
+ );
+
+int
+ProcXListInputDevices (
+ ClientPtr /* client */
+ );
+
+void
+SizeDeviceInfo (
+ DeviceIntPtr /* d */,
+ int * /* namesize */,
+ int * /* size */
+ );
+
+void
+ListDeviceInfo (
+ ClientPtr /* client */,
+ DeviceIntPtr /* d */,
+ xDeviceInfoPtr /* dev */,
+ char ** /* devbuf */,
+ char ** /* classbuf */,
+ char ** /* namebuf */
+ );
+
+void
+CopyDeviceName (
+ char ** /* namebuf */,
+ char * /* name */
+ );
+
+void
+CopySwapDevice (
+ ClientPtr /* client */,
+ DeviceIntPtr /* d */,
+ int /* num_classes */,
+ char ** /* buf */
+ );
+
+void
+CopySwapKeyClass (
+ ClientPtr /* client */,
+ KeyClassPtr /* k */,
+ char ** /* buf */
+ );
+
+void
+CopySwapButtonClass (
+ ClientPtr /* client */,
+ ButtonClassPtr /* b */,
+ char ** /* buf */
+ );
+
+int
+CopySwapValuatorClass (
+ ClientPtr /* client */,
+ ValuatorClassPtr /* v */,
+ char ** /* buf */
+ );
+
+void
+SRepXListInputDevices (
+ ClientPtr /* client */,
+ int /* size */,
+ xListInputDevicesReply * /* rep */
+ );
+
+#endif /* LISTDEV_H */
diff --git a/nx-X11/programs/Xserver/Xi/opendev.c b/nx-X11/programs/Xserver/Xi/opendev.c
new file mode 100644
index 000000000..45bea7ae5
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/opendev.c
@@ -0,0 +1,205 @@
+/* $Xorg: opendev.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/opendev.c,v 3.2 2001/01/17 22:13:25 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Request to open an extension input device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h"
+#include "windowstr.h" /* window structure */
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "opendev.h"
+
+extern CARD8 event_base [];
+
+/***********************************************************************
+ *
+ * This procedure swaps the request if the server and client have different
+ * byte orderings.
+ *
+ */
+
+int
+SProcXOpenDevice(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xOpenDeviceReq);
+ swaps(&stuff->length, n);
+ return(ProcXOpenDevice(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure causes the server to open an input device.
+ *
+ */
+
+int
+ProcXOpenDevice(client)
+ register ClientPtr client;
+ {
+ xInputClassInfo evbase [numInputClasses];
+ Bool enableit = FALSE;
+ int j=0;
+ int status = Success;
+ xOpenDeviceReply rep;
+ DeviceIntPtr dev;
+
+ REQUEST(xOpenDeviceReq);
+ REQUEST_SIZE_MATCH(xOpenDeviceReq);
+
+ if (stuff->deviceid == inputInfo.pointer->id ||
+ stuff->deviceid == inputInfo.keyboard->id)
+ {
+ SendErrorToClient(client, IReqCode, X_OpenDevice, 0, BadDevice);
+ return Success;
+ }
+
+ if ((dev = LookupDeviceIntRec(stuff->deviceid)) == NULL) /* not open */
+ {
+ for (dev=inputInfo.off_devices; dev; dev=dev->next)
+ if (dev->id == stuff->deviceid)
+ break;
+ if (dev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_OpenDevice, 0, BadDevice);
+ return Success;
+ }
+ enableit = TRUE;
+ }
+
+ OpenInputDevice (dev, client, &status);
+ if (status != Success)
+ {
+ SendErrorToClient(client, IReqCode, X_OpenDevice, 0, status);
+ return Success;
+ }
+ if (enableit && dev->inited && dev->startup)
+ (void)EnableDevice(dev);
+
+ rep.repType = X_Reply;
+ rep.RepType = X_OpenDevice;
+ rep.sequenceNumber = client->sequence;
+ if (dev->key != NULL)
+ {
+ evbase[j].class = KeyClass;
+ evbase[j++].event_type_base = event_base[KeyClass];
+ }
+ if (dev->button != NULL)
+ {
+ evbase[j].class = ButtonClass;
+ evbase[j++].event_type_base = event_base[ButtonClass];
+ }
+ if (dev->valuator != NULL)
+ {
+ evbase[j].class = ValuatorClass;
+ evbase[j++].event_type_base = event_base[ValuatorClass];
+ }
+ if (dev->kbdfeed != NULL || dev->ptrfeed != NULL || dev->leds != NULL ||
+ dev->intfeed != NULL || dev->bell != NULL || dev->stringfeed != NULL)
+ {
+ evbase[j].class = FeedbackClass;
+ evbase[j++].event_type_base = event_base[FeedbackClass];
+ }
+ if (dev->focus != NULL)
+ {
+ evbase[j].class = FocusClass;
+ evbase[j++].event_type_base = event_base[FocusClass];
+ }
+ if (dev->proximity != NULL)
+ {
+ evbase[j].class = ProximityClass;
+ evbase[j++].event_type_base = event_base[ProximityClass];
+ }
+ evbase[j].class = OtherClass;
+ evbase[j++].event_type_base = event_base[OtherClass];
+ rep.length = (j * sizeof (xInputClassInfo) + 3) >> 2;
+ rep.num_classes = j;
+ WriteReplyToClient (client, sizeof (xOpenDeviceReply), &rep);
+ WriteToClient(client, j * sizeof (xInputClassInfo), (char *)evbase);
+ return (Success);
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XOpenDevice function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXOpenDevice (client, size, rep)
+ ClientPtr client;
+ int size;
+ xOpenDeviceReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/opendev.h b/nx-X11/programs/Xserver/Xi/opendev.h
new file mode 100644
index 000000000..94ed6f6bd
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/opendev.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/programs/Xserver/Xi/opendev.h,v 3.1 1996/04/15 11:18:58 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef OPENDEV_H
+#define OPENDEV_H 1
+
+int
+SProcXOpenDevice(
+ ClientPtr /* client */
+ );
+
+int
+ProcXOpenDevice(
+ ClientPtr /* client */
+ );
+
+void
+SRepXOpenDevice (
+ ClientPtr /* client */,
+ int /* size */,
+ xOpenDeviceReply * /* rep */
+ );
+
+#endif /* OPENDEV_H */
diff --git a/nx-X11/programs/Xserver/Xi/queryst.c b/nx-X11/programs/Xserver/Xi/queryst.c
new file mode 100644
index 000000000..34b140c8e
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/queryst.c
@@ -0,0 +1,215 @@
+/* $Xorg: queryst.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+/*
+
+Copyright 1998, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/Xi/queryst.c,v 3.4 2001/01/17 22:13:26 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Request to query the state of an extension input device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exevents.h"
+#include "exglobals.h"
+
+#include "queryst.h"
+
+/***********************************************************************
+ *
+ * This procedure allows a client to query the state of a device.
+ *
+ */
+
+int
+SProcXQueryDeviceState(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xQueryDeviceStateReq);
+ swaps(&stuff->length, n);
+ return(ProcXQueryDeviceState(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure allows frozen events to be routed.
+ *
+ */
+
+int
+ProcXQueryDeviceState(client)
+ register ClientPtr client;
+ {
+ register char n;
+ int i;
+ int num_classes = 0;
+ int total_length = 0;
+ char *buf, *savbuf;
+ KeyClassPtr k;
+ xKeyState *tk;
+ ButtonClassPtr b;
+ xButtonState *tb;
+ ValuatorClassPtr v;
+ xValuatorState *tv;
+ xQueryDeviceStateReply rep;
+ DeviceIntPtr dev;
+ int *values;
+
+ REQUEST(xQueryDeviceStateReq);
+ REQUEST_SIZE_MATCH(xQueryDeviceStateReq);
+
+ rep.repType = X_Reply;
+ rep.RepType = X_QueryDeviceState;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_QueryDeviceState, 0,
+ BadDevice);
+ return Success;
+ }
+
+ v = dev->valuator;
+ if (v != NULL && v->motionHintWindow != NULL)
+ MaybeStopDeviceHint(dev, client);
+
+ k = dev->key;
+ if (k != NULL)
+ {
+ total_length += sizeof (xKeyState);
+ num_classes++;
+ }
+
+ b = dev->button;
+ if (b != NULL)
+ {
+ total_length += sizeof (xButtonState);
+ num_classes++;
+ }
+
+ if (v != NULL)
+ {
+ total_length += (sizeof(xValuatorState) +
+ (v->numAxes * sizeof(int)));
+ num_classes++;
+ }
+ buf = (char *) xalloc (total_length);
+ if (!buf)
+ {
+ SendErrorToClient(client, IReqCode, X_QueryDeviceState, 0,
+ BadAlloc);
+ return Success;
+ }
+ savbuf = buf;
+
+ if (k != NULL)
+ {
+ tk = (xKeyState *) buf;
+ tk->class = KeyClass;
+ tk->length = sizeof (xKeyState);
+ tk->num_keys = k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode + 1;
+ for (i = 0; i<32; i++)
+ tk->keys[i] = k->down[i];
+ buf += sizeof (xKeyState);
+ }
+
+ if (b != NULL)
+ {
+ tb = (xButtonState *) buf;
+ tb->class = ButtonClass;
+ tb->length = sizeof (xButtonState);
+ tb->num_buttons = b->numButtons;
+ for (i = 0; i<32; i++)
+ tb->buttons[i] = b->down[i];
+ buf += sizeof (xButtonState);
+ }
+
+ if (v != NULL)
+ {
+ tv = (xValuatorState *) buf;
+ tv->class = ValuatorClass;
+ tv->length = sizeof (xValuatorState);
+ tv->num_valuators = v->numAxes;
+ tv->mode = v->mode;
+ buf += sizeof(xValuatorState);
+ for (i=0, values=v->axisVal; i<v->numAxes; i++)
+ {
+ *((int *) buf) = *values++;
+ if (client->swapped)
+ {
+ swapl ((int *) buf, n);/* macro - braces needed */
+ }
+ buf += sizeof(int);
+ }
+ }
+
+ rep.num_classes = num_classes;
+ rep.length = (total_length + 3) >> 2;
+ WriteReplyToClient (client, sizeof(xQueryDeviceStateReply), &rep);
+ if (total_length > 0)
+ WriteToClient (client, total_length, savbuf);
+ xfree (savbuf);
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XQueryDeviceState function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXQueryDeviceState (client, size, rep)
+ ClientPtr client;
+ int size;
+ xQueryDeviceStateReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/queryst.h b/nx-X11/programs/Xserver/Xi/queryst.h
new file mode 100644
index 000000000..bf651b4bd
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/queryst.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/programs/Xserver/Xi/queryst.h,v 3.1 1996/04/15 11:19:00 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef QUERYST_H
+#define QUERYST_H 1
+
+int
+SProcXQueryDeviceState(
+ ClientPtr /* client */
+ );
+
+int
+ProcXQueryDeviceState(
+ ClientPtr /* client */
+ );
+
+void
+SRepXQueryDeviceState (
+ ClientPtr /* client */,
+ int /* size */,
+ xQueryDeviceStateReply * /* rep */
+ );
+
+#endif /* QUERYST_H */
diff --git a/nx-X11/programs/Xserver/Xi/selectev.c b/nx-X11/programs/Xserver/Xi/selectev.c
new file mode 100644
index 000000000..c8a55f5b0
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/selectev.c
@@ -0,0 +1,159 @@
+/* $Xorg: selectev.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/selectev.c,v 3.2 2001/01/17 22:13:26 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Request to select input from an extension device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exevents.h"
+#include "exglobals.h"
+
+#include "grabdev.h"
+#include "selectev.h"
+
+extern Mask ExtExclusiveMasks[];
+extern Mask ExtValidMasks[];
+
+/***********************************************************************
+ *
+ * Handle requests from clients with a different byte order.
+ *
+ */
+
+int
+SProcXSelectExtensionEvent (client)
+register ClientPtr client;
+ {
+ register char n;
+ register long *p;
+ register int i;
+
+ REQUEST(xSelectExtensionEventReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSelectExtensionEventReq);
+ swapl(&stuff->window, n);
+ swaps(&stuff->count, n);
+ p = (long *) &stuff[1];
+ for (i=0; i<stuff->count; i++)
+ {
+ swapl(p, n);
+ p++;
+ }
+ return(ProcXSelectExtensionEvent(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure selects input from an extension device.
+ *
+ */
+
+int
+ProcXSelectExtensionEvent (client)
+ register ClientPtr client;
+ {
+ int ret;
+ int i;
+ WindowPtr pWin;
+ struct tmask tmp[EMASKSIZE];
+
+ REQUEST(xSelectExtensionEventReq);
+ REQUEST_AT_LEAST_SIZE(xSelectExtensionEventReq);
+
+ if (stuff->length !=(sizeof(xSelectExtensionEventReq)>>2) + stuff->count)
+ {
+ SendErrorToClient (client, IReqCode, X_SelectExtensionEvent, 0,
+ BadLength);
+ return Success;
+ }
+
+ pWin = (WindowPtr) LookupWindow (stuff->window, client);
+ if (!pWin)
+ {
+ client->errorValue = stuff->window;
+ SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0,
+ BadWindow);
+ return Success;
+ }
+
+ if ((ret = CreateMaskFromList (client, (XEventClass *)&stuff[1],
+ stuff->count, tmp, NULL, X_SelectExtensionEvent)) != Success)
+ return Success;
+
+ for (i=0; i<EMASKSIZE; i++)
+ if (tmp[i].dev != NULL)
+ {
+ if ((ret = SelectForWindow((DeviceIntPtr)tmp[i].dev, pWin, client, tmp[i].mask,
+ ExtExclusiveMasks[i], ExtValidMasks[i])) != Success)
+ {
+ SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0,
+ ret);
+ return Success;
+ }
+ }
+
+ return Success;
+ }
diff --git a/nx-X11/programs/Xserver/Xi/selectev.h b/nx-X11/programs/Xserver/Xi/selectev.h
new file mode 100644
index 000000000..82bdbc6c0
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/selectev.h
@@ -0,0 +1,44 @@
+/* $XFree86: xc/programs/Xserver/Xi/selectev.h,v 3.1 1996/04/15 11:19:01 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef SELECTEV_H
+#define SELECTEV_H 1
+
+int
+SProcXSelectExtensionEvent (
+ ClientPtr /* client */
+ );
+
+int
+ProcXSelectExtensionEvent (
+ ClientPtr /* client */
+ );
+
+#endif /* SELECTEV_H */
diff --git a/nx-X11/programs/Xserver/Xi/sendexev.c b/nx-X11/programs/Xserver/Xi/sendexev.c
new file mode 100644
index 000000000..c005aecab
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/sendexev.c
@@ -0,0 +1,181 @@
+/* $Xorg: sendexev.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/sendexev.c,v 3.2 2001/01/17 22:13:26 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Request to send an extension event.
+ *
+ */
+
+#define EXTENSION_EVENT_BASE 64
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* Window */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exevents.h"
+#include "exglobals.h"
+
+#include "grabdev.h"
+#include "sendexev.h"
+
+extern int lastEvent; /* Defined in extension.c */
+
+/***********************************************************************
+ *
+ * Handle requests from clients with a different byte order than us.
+ *
+ */
+
+int
+SProcXSendExtensionEvent(client)
+ register ClientPtr client;
+ {
+ register char n;
+ register long *p;
+ register int i;
+ xEvent eventT;
+ xEvent *eventP;
+ EventSwapPtr proc;
+
+ REQUEST(xSendExtensionEventReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq);
+ swapl(&stuff->destination, n);
+ swaps(&stuff->count, n);
+ eventP = (xEvent *) &stuff[1];
+ for (i=0; i<stuff->num_events; i++,eventP++)
+ {
+ proc = EventSwapVector[eventP->u.u.type & 0177];
+ if (proc == NotImplemented) /* no swapping proc; invalid event type? */
+ return (BadValue);
+ (*proc)(eventP, &eventT);
+ *eventP = eventT;
+ }
+
+ p = (long *) (((xEvent *) &stuff[1]) + stuff->num_events);
+ for (i=0; i<stuff->count; i++)
+ {
+ swapl(p, n);
+ p++;
+ }
+ return(ProcXSendExtensionEvent(client));
+ }
+
+/***********************************************************************
+ *
+ * Send an event to some client, as if it had come from an extension input
+ * device.
+ *
+ */
+
+int
+ProcXSendExtensionEvent (client)
+ register ClientPtr client;
+ {
+ int ret;
+ DeviceIntPtr dev;
+ xEvent *first;
+ XEventClass *list;
+ struct tmask tmp[EMASKSIZE];
+
+ REQUEST(xSendExtensionEventReq);
+ REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq);
+
+ if (stuff->length !=(sizeof(xSendExtensionEventReq)>>2) + stuff->count +
+ (stuff->num_events * (sizeof (xEvent) >> 2)))
+ {
+ SendErrorToClient (client, IReqCode, X_SendExtensionEvent, 0,
+ BadLength);
+ return Success;
+ }
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_SendExtensionEvent, 0,
+ BadDevice);
+ return Success;
+ }
+
+ /* The client's event type must be one defined by an extension. */
+
+ first = ((xEvent *) &stuff[1]);
+ if ( ! ((EXTENSION_EVENT_BASE <= first->u.u.type) &&
+ (first->u.u.type < lastEvent)) )
+ {
+ client->errorValue = first->u.u.type;
+ SendErrorToClient(client, IReqCode, X_SendExtensionEvent, 0,
+ BadValue);
+ return Success;
+ }
+
+ list = (XEventClass *) (first + stuff->num_events);
+ if ((ret = CreateMaskFromList (client, list, stuff->count, tmp, dev,
+ X_SendExtensionEvent)) != Success)
+ return Success;
+
+ ret = (SendEvent (client, dev, stuff->destination,
+ stuff->propagate, (xEvent *)&stuff[1], tmp[stuff->deviceid].mask,
+ stuff->num_events));
+
+ if (ret != Success)
+ SendErrorToClient(client, IReqCode, X_SendExtensionEvent, 0, ret);
+
+ return Success;
+ }
diff --git a/nx-X11/programs/Xserver/Xi/sendexev.h b/nx-X11/programs/Xserver/Xi/sendexev.h
new file mode 100644
index 000000000..e5bc185a8
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/sendexev.h
@@ -0,0 +1,44 @@
+/* $XFree86: xc/programs/Xserver/Xi/sendexev.h,v 3.1 1996/04/15 11:19:02 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef SENDEXEV_H
+#define SENDEXEV_H 1
+
+int
+SProcXSendExtensionEvent(
+ ClientPtr /* client */
+ );
+
+int
+ProcXSendExtensionEvent(
+ ClientPtr /* client */
+ );
+
+#endif /* SENDEXEV_H */
diff --git a/nx-X11/programs/Xserver/Xi/setbmap.c b/nx-X11/programs/Xserver/Xi/setbmap.c
new file mode 100644
index 000000000..37db5110d
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/setbmap.c
@@ -0,0 +1,170 @@
+/* $Xorg: setbmap.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/setbmap.c,v 3.2 2001/01/17 22:13:26 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Request to change the button mapping of an extension device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#define IsOn(ptr, bit) \
+ (((BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7)))
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "exevents.h"
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "setbmap.h"
+
+/***********************************************************************
+ *
+ * This procedure changes the button mapping.
+ *
+ */
+
+int
+SProcXSetDeviceButtonMapping(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xSetDeviceButtonMappingReq);
+ swaps(&stuff->length, n);
+ return(ProcXSetDeviceButtonMapping(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure lists the input devices available to the server.
+ *
+ */
+
+int
+ProcXSetDeviceButtonMapping (client)
+ register ClientPtr client;
+ {
+ int ret;
+ xSetDeviceButtonMappingReply rep;
+ DeviceIntPtr dev;
+
+ REQUEST(xSetDeviceButtonMappingReq);
+ REQUEST_AT_LEAST_SIZE(xSetDeviceButtonMappingReq);
+
+ if (stuff->length != (sizeof(xSetDeviceButtonMappingReq) +
+ stuff->map_length + 3)>>2)
+ {
+ SendErrorToClient(client, IReqCode, X_SetDeviceButtonMapping, 0,
+ BadLength);
+ return Success;
+ }
+
+ rep.repType = X_Reply;
+ rep.RepType = X_SetDeviceButtonMapping;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.status = MappingSuccess;
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_SetDeviceButtonMapping, 0,
+ BadDevice);
+ return Success;
+ }
+
+ ret = SetButtonMapping (client, dev, stuff->map_length, (BYTE *)&stuff[1]);
+
+ if (ret == BadValue || ret == BadMatch)
+ {
+ SendErrorToClient(client, IReqCode, X_SetDeviceButtonMapping, 0,
+ ret);
+ return Success;
+ }
+ else
+ {
+ rep.status = ret;
+ WriteReplyToClient(client, sizeof(xSetDeviceButtonMappingReply), &rep);
+ }
+
+ if (ret != MappingBusy)
+ SendDeviceMappingNotify(MappingPointer, 0, 0, dev);
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XSetDeviceButtonMapping function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXSetDeviceButtonMapping (client, size, rep)
+ ClientPtr client;
+ int size;
+ xSetDeviceButtonMappingReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/setbmap.h b/nx-X11/programs/Xserver/Xi/setbmap.h
new file mode 100644
index 000000000..dab5fcbde
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/setbmap.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/programs/Xserver/Xi/setbmap.h,v 3.1 1996/04/15 11:19:03 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef SETBMAP_H
+#define SETBMAP_H 1
+
+int
+SProcXSetDeviceButtonMapping(
+ ClientPtr /* client */
+ );
+
+int
+ProcXSetDeviceButtonMapping(
+ ClientPtr /* client */
+ );
+
+void
+SRepXSetDeviceButtonMapping(
+ ClientPtr /* client */,
+ int /* size */,
+ xSetDeviceButtonMappingReply * /* rep */
+ );
+
+#endif /* SETBMAP_H */
diff --git a/nx-X11/programs/Xserver/Xi/setdval.c b/nx-X11/programs/Xserver/Xi/setdval.c
new file mode 100644
index 000000000..9b5b1e20d
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/setdval.c
@@ -0,0 +1,174 @@
+/* $Xorg: setdval.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/setdval.c,v 3.2 2001/01/17 22:13:26 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Request to change the mode of an extension input device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h"
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "setdval.h"
+
+/***********************************************************************
+ *
+ * Handle a request from a client with a different byte order.
+ *
+ */
+
+int
+SProcXSetDeviceValuators(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xSetDeviceValuatorsReq);
+ swaps(&stuff->length, n);
+ return(ProcXSetDeviceValuators(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure sets the value of valuators on an extension input device.
+ *
+ */
+
+int
+ProcXSetDeviceValuators(client)
+ register ClientPtr client;
+ {
+ DeviceIntPtr dev;
+ xSetDeviceValuatorsReply rep;
+
+ REQUEST(xSetDeviceValuatorsReq);
+ REQUEST_AT_LEAST_SIZE(xSetDeviceValuatorsReq);
+
+ rep.repType = X_Reply;
+ rep.RepType = X_SetDeviceValuators;
+ rep.length = 0;
+ rep.status = Success;
+ rep.sequenceNumber = client->sequence;
+
+ if (stuff->length !=(sizeof(xSetDeviceValuatorsReq)>>2) +
+ stuff->num_valuators)
+ {
+ SendErrorToClient (client, IReqCode, X_SetDeviceValuators, 0,
+ BadLength);
+ return Success;
+ }
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient (client, IReqCode, X_SetDeviceValuators, 0,
+ BadDevice);
+ return Success;
+ }
+ if (dev->valuator == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0,
+ BadMatch);
+ return Success;
+ }
+
+ if (stuff->first_valuator + stuff->num_valuators > dev->valuator->numAxes)
+ {
+ SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0,
+ BadValue);
+ return Success;
+ }
+
+ if ((dev->grab) && !SameClient(dev->grab, client))
+ rep.status = AlreadyGrabbed;
+ else
+ rep.status = SetDeviceValuators (client, dev, (int *) &stuff[1],
+ stuff->first_valuator, stuff->num_valuators);
+
+ if (rep.status != Success && rep.status != AlreadyGrabbed)
+ SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0,
+ rep.status);
+ else
+ WriteReplyToClient (client, sizeof (xSetDeviceValuatorsReply), &rep);
+
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XSetDeviceValuators function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXSetDeviceValuators (client, size, rep)
+ ClientPtr client;
+ int size;
+ xSetDeviceValuatorsReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/setdval.h b/nx-X11/programs/Xserver/Xi/setdval.h
new file mode 100644
index 000000000..d475c7cc6
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/setdval.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/programs/Xserver/Xi/setdval.h,v 3.1 1996/04/15 11:19:04 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef SETDVAL_H
+#define SETDVAL_H 1
+
+int
+SProcXSetDeviceValuators(
+ ClientPtr /* client */
+ );
+
+int
+ProcXSetDeviceValuators(
+ ClientPtr /* client */
+ );
+
+void
+SRepXSetDeviceValuators(
+ ClientPtr /* client */,
+ int /* size */,
+ xSetDeviceValuatorsReply * /* rep */
+ );
+
+#endif /* SETDVAL_H */
diff --git a/nx-X11/programs/Xserver/Xi/setfocus.c b/nx-X11/programs/Xserver/Xi/setfocus.c
new file mode 100644
index 000000000..a1dd09d71
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/setfocus.c
@@ -0,0 +1,126 @@
+/* $Xorg: setfocus.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/setfocus.c,v 3.2 2001/01/17 22:13:26 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Request to set the focus for an extension device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "windowstr.h" /* focus struct */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+
+#include "dixevents.h"
+
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "setfocus.h"
+
+/***********************************************************************
+ *
+ * This procedure sets the focus for a device.
+ *
+ */
+
+int
+SProcXSetDeviceFocus(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xSetDeviceFocusReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSetDeviceFocusReq);
+ swapl(&stuff->focus, n);
+ swapl(&stuff->time, n);
+ return(ProcXSetDeviceFocus(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure sets the focus for a device.
+ *
+ */
+
+int
+ProcXSetDeviceFocus(client)
+ register ClientPtr client;
+ {
+ int ret;
+ register DeviceIntPtr dev;
+
+ REQUEST(xSetDeviceFocusReq);
+ REQUEST_SIZE_MATCH(xSetDeviceFocusReq);
+
+ dev = LookupDeviceIntRec (stuff->device);
+ if (dev==NULL || !dev->focus)
+ {
+ SendErrorToClient(client, IReqCode, X_SetDeviceFocus, 0, BadDevice);
+ return Success;
+ }
+
+ ret = SetInputFocus (client, dev, stuff->focus, stuff->revertTo,
+ stuff->time, TRUE);
+ if (ret != Success)
+ SendErrorToClient(client, IReqCode, X_SetDeviceFocus, 0, ret);
+
+ return Success;
+ }
diff --git a/nx-X11/programs/Xserver/Xi/setfocus.h b/nx-X11/programs/Xserver/Xi/setfocus.h
new file mode 100644
index 000000000..62ff181d2
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/setfocus.h
@@ -0,0 +1,44 @@
+/* $XFree86: xc/programs/Xserver/Xi/setfocus.h,v 3.1 1996/04/15 11:19:05 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef SETFOCUS_H
+#define SETFOCUS_H 1
+
+int
+SProcXSetDeviceFocus(
+ ClientPtr /* client */
+ );
+
+int
+ProcXSetDeviceFocus(
+ ClientPtr /* client */
+ );
+
+#endif /* SETFOCUS_H */
diff --git a/nx-X11/programs/Xserver/Xi/setmmap.c b/nx-X11/programs/Xserver/Xi/setmmap.c
new file mode 100644
index 000000000..3fa2c7e7e
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/setmmap.c
@@ -0,0 +1,164 @@
+/* $Xorg: setmmap.c,v 1.4 2001/02/09 02:04:35 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/setmmap.c,v 3.2 2001/01/17 22:13:26 dawes Exp $ */
+
+/********************************************************************
+ *
+ * Set modifier mapping for an extension device.
+ *
+ */
+
+#define NEED_EVENTS /* for inputstr.h */
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "exevents.h"
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "setmmap.h"
+
+/***********************************************************************
+ *
+ * This procedure sets the modifier mapping for an extension device,
+ * for clients on machines with a different byte ordering than the server.
+ *
+ */
+
+int
+SProcXSetDeviceModifierMapping(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xSetDeviceModifierMappingReq);
+ swaps(&stuff->length, n);
+ return(ProcXSetDeviceModifierMapping(client));
+ }
+
+/***********************************************************************
+ *
+ * Set the device Modifier mapping.
+ *
+ */
+
+int
+ProcXSetDeviceModifierMapping(client)
+ ClientPtr client;
+ {
+ int ret;
+ xSetDeviceModifierMappingReply rep;
+ DeviceIntPtr dev;
+ KeyClassPtr kp;
+
+ REQUEST(xSetDeviceModifierMappingReq);
+ REQUEST_AT_LEAST_SIZE(xSetDeviceModifierMappingReq);
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient (client, IReqCode, X_SetDeviceModifierMapping, 0,
+ BadDevice);
+ return Success;
+ }
+
+ rep.repType = X_Reply;
+ rep.RepType = X_SetDeviceModifierMapping;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ ret = SetModifierMapping(client, dev, stuff->length,
+ (sizeof (xSetDeviceModifierMappingReq)>>2), stuff->numKeyPerModifier,
+ (BYTE *)&stuff[1], &kp);
+
+ if (ret==MappingSuccess || ret==MappingBusy || ret==MappingFailed)
+ {
+ rep.success = ret;
+ if (ret == MappingSuccess)
+ SendDeviceMappingNotify(MappingModifier, 0, 0, dev);
+ WriteReplyToClient(client, sizeof(xSetDeviceModifierMappingReply),&rep);
+ }
+ else
+ {
+ if (ret==-1)
+ ret=BadValue;
+ SendErrorToClient (client, IReqCode, X_SetDeviceModifierMapping, 0,ret);
+ }
+
+
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XSetDeviceModifierMapping function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXSetDeviceModifierMapping (client, size, rep)
+ ClientPtr client;
+ int size;
+ xSetDeviceModifierMappingReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ WriteToClient(client, size, (char *)rep);
+ }
+
diff --git a/nx-X11/programs/Xserver/Xi/setmmap.h b/nx-X11/programs/Xserver/Xi/setmmap.h
new file mode 100644
index 000000000..c859095f8
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/setmmap.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/programs/Xserver/Xi/setmmap.h,v 3.1 1996/04/15 11:19:06 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef SETMMAP_H
+#define SETMMAP_H 1
+
+int
+SProcXSetDeviceModifierMapping(
+ ClientPtr /* client */
+ );
+
+int
+ProcXSetDeviceModifierMapping(
+ ClientPtr /* client */
+ );
+
+void
+SRepXSetDeviceModifierMapping(
+ ClientPtr /* client */,
+ int /* size */,
+ xSetDeviceModifierMappingReply * /* rep */
+ );
+
+#endif /* SETMMAP_H */
diff --git a/nx-X11/programs/Xserver/Xi/setmode.c b/nx-X11/programs/Xserver/Xi/setmode.c
new file mode 100644
index 000000000..f95ef5514
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/setmode.c
@@ -0,0 +1,158 @@
+/* $Xorg: setmode.c,v 1.4 2001/02/09 02:04:35 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/setmode.c,v 3.2 2001/01/17 22:13:26 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Request to change the mode of an extension input device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h"
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "setmode.h"
+
+/***********************************************************************
+ *
+ * Handle a request from a client with a different byte order.
+ *
+ */
+
+int
+SProcXSetDeviceMode(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xSetDeviceModeReq);
+ swaps(&stuff->length, n);
+ return(ProcXSetDeviceMode(client));
+ }
+
+/***********************************************************************
+ *
+ * This procedure sets the mode of a device.
+ *
+ */
+
+int
+ProcXSetDeviceMode(client)
+ register ClientPtr client;
+ {
+ DeviceIntPtr dev;
+ xSetDeviceModeReply rep;
+
+ REQUEST(xSetDeviceModeReq);
+ REQUEST_SIZE_MATCH(xSetDeviceModeReq);
+
+ rep.repType = X_Reply;
+ rep.RepType = X_SetDeviceMode;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient (client, IReqCode, X_SetDeviceMode, 0, BadDevice);
+ return Success;
+ }
+ if (dev->valuator == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_SetDeviceMode, 0, BadMatch);
+ return Success;
+ }
+ if ((dev->grab) && !SameClient(dev->grab, client))
+ rep.status = AlreadyGrabbed;
+ else
+ rep.status = SetDeviceMode (client, dev, stuff->mode);
+
+ if (rep.status == Success)
+ dev->valuator->mode = stuff->mode;
+ else if (rep.status != AlreadyGrabbed)
+ {
+ SendErrorToClient(client, IReqCode, X_SetDeviceMode, 0, rep.status);
+ return Success;
+ }
+
+ WriteReplyToClient (client, sizeof (xSetDeviceModeReply), &rep);
+ return Success;
+ }
+
+/***********************************************************************
+ *
+ * This procedure writes the reply for the XSetDeviceMode function,
+ * if the client and server have a different byte ordering.
+ *
+ */
+
+void
+SRepXSetDeviceMode (client, size, rep)
+ ClientPtr client;
+ int size;
+ xSetDeviceModeReply *rep;
+ {
+ register char n;
+
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ WriteToClient(client, size, (char *)rep);
+ }
diff --git a/nx-X11/programs/Xserver/Xi/setmode.h b/nx-X11/programs/Xserver/Xi/setmode.h
new file mode 100644
index 000000000..d570af7bd
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/setmode.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/programs/Xserver/Xi/setmode.h,v 3.1 1996/04/15 11:19:07 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef SETMODE_H
+#define SETMODE_H 1
+
+int
+SProcXSetDeviceMode(
+ ClientPtr /* client */
+ );
+
+int
+ProcXSetDeviceMode(
+ ClientPtr /* client */
+ );
+
+void
+SRepXSetDeviceMode(
+ ClientPtr /* client */,
+ int /* size */,
+ xSetDeviceModeReply * /* rep */
+ );
+
+#endif /* SETMODE_H */
diff --git a/nx-X11/programs/Xserver/Xi/stubs.c b/nx-X11/programs/Xserver/Xi/stubs.c
new file mode 100644
index 000000000..7ad6d903e
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/stubs.c
@@ -0,0 +1,317 @@
+/* $Xorg: stubs.c,v 1.4 2001/02/09 02:04:35 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/stubs.c,v 3.4 2001/12/14 19:58:59 dawes Exp $ */
+
+/*
+ * stubs.c -- stub routines for the X server side of the XINPUT
+ * extension. This file is mainly to be used only as documentation.
+ * There is not much code here, and you can't get a working XINPUT
+ * server just using this.
+ * The Xvfb server uses this file so it will compile with the same
+ * object files as the real X server for a platform that has XINPUT.
+ * Xnest could do the same thing.
+ */
+
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "inputstr.h"
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h"
+
+/***********************************************************************
+ *
+ * Caller: ProcXChangeKeyboardDevice
+ *
+ * This procedure does the implementation-dependent portion of the work
+ * needed to change the keyboard device.
+ *
+ * The X keyboard device has a FocusRec. If the device that has been
+ * made into the new X keyboard did not have a FocusRec,
+ * ProcXChangeKeyboardDevice will allocate one for it.
+ *
+ * If you do not want clients to be able to focus the old X keyboard
+ * device, call DeleteFocusClassDeviceStruct to free the FocusRec.
+ *
+ * If you support input devices with keys that you do not want to be
+ * used as the X keyboard, you need to check for them here and return
+ * a BadDevice error.
+ *
+ * The default implementation is to do nothing (assume you do want
+ * clients to be able to focus the old X keyboard). The commented-out
+ * sample code shows what you might do if you don't want the default.
+ *
+ */
+
+int
+ChangeKeyboardDevice (old_dev, new_dev)
+ DeviceIntPtr old_dev;
+ DeviceIntPtr new_dev;
+ {
+ /***********************************************************************
+ DeleteFocusClassDeviceStruct(old_dev); * defined in xchgptr.c *
+ **********************************************************************/
+ return BadMatch;
+ }
+
+
+/***********************************************************************
+ *
+ * Caller: ProcXChangePointerDevice
+ *
+ * This procedure does the implementation-dependent portion of the work
+ * needed to change the pointer device.
+ *
+ * The X pointer device does not have a FocusRec. If the device that
+ * has been made into the new X pointer had a FocusRec,
+ * ProcXChangePointerDevice will free it.
+ *
+ * If you want clients to be able to focus the old pointer device that
+ * has now become accessible through the input extension, you need to
+ * add a FocusRec to it here.
+ *
+ * The XChangePointerDevice protocol request also allows the client
+ * to choose which axes of the new pointer device are used to move
+ * the X cursor in the X- and Y- directions. If the axes are different
+ * than the default ones, you need to keep track of that here.
+ *
+ * If you support input devices with valuators that you do not want to be
+ * used as the X pointer, you need to check for them here and return a
+ * BadDevice error.
+ *
+ * The default implementation is to do nothing (assume you don't want
+ * clients to be able to focus the old X pointer). The commented-out
+ * sample code shows what you might do if you don't want the default.
+ *
+ */
+
+int
+ChangePointerDevice (
+ DeviceIntPtr old_dev,
+ DeviceIntPtr new_dev,
+ unsigned char x,
+ unsigned char y)
+ {
+ /***********************************************************************
+ InitFocusClassDeviceStruct(old_dev); * allow focusing old ptr*
+
+ x_axis = x; * keep track of new x-axis*
+ y_axis = y; * keep track of new y-axis*
+ if (x_axis != 0 || y_axis != 1)
+ axes_changed = TRUE; * remember axes have changed*
+ else
+ axes_changed = FALSE;
+ *************************************************************************/
+ return BadMatch;
+ }
+
+/***********************************************************************
+ *
+ * Caller: ProcXCloseDevice
+ *
+ * Take care of implementation-dependent details of closing a device.
+ * Some implementations may actually close the device, others may just
+ * remove this clients interest in that device.
+ *
+ * The default implementation is to do nothing (assume all input devices
+ * are initialized during X server initialization and kept open).
+ *
+ */
+
+void
+CloseInputDevice (d, client)
+ DeviceIntPtr d;
+ ClientPtr client;
+ {
+ }
+
+/***********************************************************************
+ *
+ * Caller: ProcXListInputDevices
+ *
+ * This is the implementation-dependent routine to initialize an input
+ * device to the point that information about it can be listed.
+ * Some implementations open all input devices when the server is first
+ * initialized, and never close them. Other implementations open only
+ * the X pointer and keyboard devices during server initialization,
+ * and only open other input devices when some client makes an
+ * XOpenDevice request. If some other process has the device open, the
+ * server may not be able to get information about the device to list it.
+ *
+ * This procedure should be used by implementations that do not initialize
+ * all input devices at server startup. It should do device-dependent
+ * initialization for any devices not previously initialized, and call
+ * AddInputDevice for each of those devices so that a DeviceIntRec will be
+ * created for them.
+ *
+ * The default implementation is to do nothing (assume all input devices
+ * are initialized during X server initialization and kept open).
+ * The commented-out sample code shows what you might do if you don't want
+ * the default.
+ *
+ */
+
+void
+AddOtherInputDevices ()
+ {
+ /**********************************************************************
+ for each uninitialized device, do something like:
+
+ DeviceIntPtr dev;
+ DeviceProc deviceProc;
+ pointer private;
+
+ dev = (DeviceIntPtr) AddInputDevice(deviceProc, TRUE);
+ dev->public.devicePrivate = private;
+ RegisterOtherDevice(dev);
+ dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
+ ************************************************************************/
+
+ }
+
+/***********************************************************************
+ *
+ * Caller: ProcXOpenDevice
+ *
+ * This is the implementation-dependent routine to open an input device.
+ * Some implementations open all input devices when the server is first
+ * initialized, and never close them. Other implementations open only
+ * the X pointer and keyboard devices during server initialization,
+ * and only open other input devices when some client makes an
+ * XOpenDevice request. This entry point is for the latter type of
+ * implementation.
+ *
+ * If the physical device is not already open, do it here. In this case,
+ * you need to keep track of the fact that one or more clients has the
+ * device open, and physically close it when the last client that has
+ * it open does an XCloseDevice.
+ *
+ * The default implementation is to do nothing (assume all input devices
+ * are opened during X server initialization and kept open).
+ *
+ */
+
+void
+OpenInputDevice (dev, client, status)
+ DeviceIntPtr dev;
+ ClientPtr client;
+ int *status;
+ {
+ }
+
+/****************************************************************************
+ *
+ * Caller: ProcXSetDeviceMode
+ *
+ * Change the mode of an extension device.
+ * This function is used to change the mode of a device from reporting
+ * relative motion to reporting absolute positional information, and
+ * vice versa.
+ * The default implementation below is that no such devices are supported.
+ *
+ */
+
+int
+SetDeviceMode (client, dev, mode)
+ register ClientPtr client;
+ DeviceIntPtr dev;
+ int mode;
+ {
+ return BadMatch;
+ }
+
+/****************************************************************************
+ *
+ * Caller: ProcXSetDeviceValuators
+ *
+ * Set the value of valuators on an extension input device.
+ * This function is used to set the initial value of valuators on
+ * those input devices that are capable of reporting either relative
+ * motion or an absolute position, and allow an initial position to be set.
+ * The default implementation below is that no such devices are supported.
+ *
+ */
+
+int
+SetDeviceValuators (client, dev, valuators, first_valuator, num_valuators)
+ register ClientPtr client;
+ DeviceIntPtr dev;
+ int *valuators;
+ int first_valuator;
+ int num_valuators;
+ {
+ return BadMatch;
+ }
+
+/****************************************************************************
+ *
+ * Caller: ProcXChangeDeviceControl
+ *
+ * Change the specified device controls on an extension input device.
+ *
+ */
+
+int
+ChangeDeviceControl (client, dev, control)
+ register ClientPtr client;
+ DeviceIntPtr dev;
+ xDeviceCtl *control;
+ {
+ switch (control->control)
+ {
+ case DEVICE_RESOLUTION:
+ return (BadMatch);
+ default:
+ return (BadMatch);
+ }
+ }
diff --git a/nx-X11/programs/Xserver/Xi/ungrdev.c b/nx-X11/programs/Xserver/Xi/ungrdev.c
new file mode 100644
index 000000000..8de4cd225
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/ungrdev.c
@@ -0,0 +1,123 @@
+/* $Xorg: ungrdev.c,v 1.4 2001/02/09 02:04:35 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/ungrdev.c,v 3.2 2001/01/17 22:13:26 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Request to release a grab of an extension device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+
+#include "ungrdev.h"
+
+/***********************************************************************
+ *
+ * Handle requests from a client with a different byte order.
+ *
+ */
+
+int
+SProcXUngrabDevice(client)
+register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xUngrabDeviceReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xUngrabDeviceReq);
+ swapl(&stuff->time, n);
+ return(ProcXUngrabDevice(client));
+ }
+
+/***********************************************************************
+ *
+ * Release a grab of an extension device.
+ *
+ */
+
+int
+ProcXUngrabDevice(client)
+register ClientPtr client;
+ {
+ DeviceIntPtr dev;
+ GrabPtr grab;
+ TimeStamp time;
+
+ REQUEST(xUngrabDeviceReq);
+ REQUEST_SIZE_MATCH(xUngrabDeviceReq);
+
+ dev = LookupDeviceIntRec (stuff->deviceid);
+ if (dev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_UngrabDevice, 0, BadDevice);
+ return Success;
+ }
+ grab = dev->grab;
+
+ time = ClientTimeToServerTime(stuff->time);
+ if ((CompareTimeStamps(time, currentTime) != LATER) &&
+ (CompareTimeStamps(time, dev->grabTime) != EARLIER) &&
+ (grab) && SameClient(grab, client))
+ (*dev->DeactivateGrab)(dev);
+ return Success;
+ }
diff --git a/nx-X11/programs/Xserver/Xi/ungrdev.h b/nx-X11/programs/Xserver/Xi/ungrdev.h
new file mode 100644
index 000000000..e8e866bc9
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/ungrdev.h
@@ -0,0 +1,44 @@
+/* $XFree86: xc/programs/Xserver/Xi/ungrdev.h,v 3.1 1996/04/15 11:19:08 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef UNGRDEV_H
+#define UNGRDEV_H 1
+
+int
+SProcXUngrabDevice(
+ ClientPtr /* client */
+ );
+
+int
+ProcXUngrabDevice(
+ ClientPtr /* client */
+ );
+
+#endif /* UNGRDEV_H */
diff --git a/nx-X11/programs/Xserver/Xi/ungrdevb.c b/nx-X11/programs/Xserver/Xi/ungrdevb.c
new file mode 100644
index 000000000..8927a5c6e
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/ungrdevb.c
@@ -0,0 +1,178 @@
+/* $Xorg: ungrdevb.c,v 1.4 2001/02/09 02:04:35 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/ungrdevb.c,v 3.3 2001/01/17 22:13:26 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Request to release a grab of a button on an extension device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+#include "dixgrabs.h"
+
+#include "ungrdevb.h"
+
+#define AllModifiersMask ( \
+ ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask | \
+ Mod3Mask | Mod4Mask | Mod5Mask )
+
+/***********************************************************************
+ *
+ * Handle requests from a client with a different byte order.
+ *
+ */
+
+int
+SProcXUngrabDeviceButton(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xUngrabDeviceButtonReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq);
+ swapl(&stuff->grabWindow, n);
+ swaps(&stuff->modifiers, n);
+ return(ProcXUngrabDeviceButton(client));
+ }
+
+/***********************************************************************
+ *
+ * Release a grab of a button on an extension device.
+ *
+ */
+
+int
+ProcXUngrabDeviceButton(client)
+ ClientPtr client;
+ {
+ DeviceIntPtr dev;
+ DeviceIntPtr mdev;
+ WindowPtr pWin;
+ GrabRec temporaryGrab;
+
+ REQUEST(xUngrabDeviceButtonReq);
+ REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq);
+
+ dev = LookupDeviceIntRec (stuff->grabbed_device);
+ if (dev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
+ BadDevice);
+ return Success;
+ }
+ if (dev->button == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
+ BadMatch);
+ return Success;
+ }
+
+ if (stuff->modifier_device != UseXKeyboard)
+ {
+ mdev = LookupDeviceIntRec (stuff->modifier_device);
+ if (mdev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
+ BadDevice);
+ return Success;
+ }
+ if (mdev->key == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
+ BadMatch);
+ return Success;
+ }
+ }
+ else
+ mdev = (DeviceIntPtr) LookupKeyboardDevice();
+
+ pWin = LookupWindow(stuff->grabWindow, client);
+ if (!pWin)
+ {
+ SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
+ BadWindow);
+ return Success;
+ }
+
+ if ((stuff->modifiers != AnyModifier) &&
+ (stuff->modifiers & ~AllModifiersMask))
+ {
+ SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
+ BadValue);
+ return Success;
+ }
+
+ temporaryGrab.resource = client->clientAsMask;
+ temporaryGrab.device = dev;
+ temporaryGrab.window = pWin;
+ temporaryGrab.type = DeviceButtonPress;
+ temporaryGrab.modifierDevice = mdev;
+ temporaryGrab.modifiersDetail.exact = stuff->modifiers;
+ temporaryGrab.modifiersDetail.pMask = NULL;
+ temporaryGrab.detail.exact = stuff->button;
+ temporaryGrab.detail.pMask = NULL;
+
+ DeletePassiveGrabFromList(&temporaryGrab);
+ return Success;
+ }
diff --git a/nx-X11/programs/Xserver/Xi/ungrdevb.h b/nx-X11/programs/Xserver/Xi/ungrdevb.h
new file mode 100644
index 000000000..238e56954
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/ungrdevb.h
@@ -0,0 +1,44 @@
+/* $XFree86: xc/programs/Xserver/Xi/ungrdevb.h,v 3.1 1996/04/15 11:19:10 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef UNGRDEVB_H
+#define UNGRDEVB_H 1
+
+int
+SProcXUngrabDeviceButton(
+ ClientPtr /* client */
+ );
+
+int
+ProcXUngrabDeviceButton(
+ ClientPtr /* client */
+ );
+
+#endif /* UNGRDEVB_H */
diff --git a/nx-X11/programs/Xserver/Xi/ungrdevk.c b/nx-X11/programs/Xserver/Xi/ungrdevk.c
new file mode 100644
index 000000000..38cfa1b71
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/ungrdevk.c
@@ -0,0 +1,184 @@
+/* $Xorg: ungrdevk.c,v 1.4 2001/02/09 02:04:35 xorgcvs Exp $ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/Xi/ungrdevk.c,v 3.3 2001/01/17 22:13:26 dawes Exp $ */
+
+/***********************************************************************
+ *
+ * Request to release a grab of a key on an extension device.
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exglobals.h"
+#include "dixgrabs.h"
+
+#include "ungrdevk.h"
+
+#define AllModifiersMask ( \
+ ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask | \
+ Mod3Mask | Mod4Mask | Mod5Mask )
+
+/***********************************************************************
+ *
+ * Handle requests from a client with a different byte order.
+ *
+ */
+
+int
+SProcXUngrabDeviceKey(client)
+ register ClientPtr client;
+ {
+ register char n;
+
+ REQUEST(xUngrabDeviceKeyReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq);
+ swapl(&stuff->grabWindow, n);
+ swaps(&stuff->modifiers, n);
+ return(ProcXUngrabDeviceKey(client));
+ }
+
+/***********************************************************************
+ *
+ * Release a grab of a key on an extension device.
+ *
+ */
+
+int
+ProcXUngrabDeviceKey(client)
+ ClientPtr client;
+ {
+ DeviceIntPtr dev;
+ DeviceIntPtr mdev;
+ WindowPtr pWin;
+ GrabRec temporaryGrab;
+
+ REQUEST(xUngrabDeviceKeyReq);
+ REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq);
+
+ dev = LookupDeviceIntRec (stuff->grabbed_device);
+ if (dev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
+ BadDevice);
+ return Success;
+ }
+ if (dev->key == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadMatch);
+ return Success;
+ }
+
+ if (stuff->modifier_device != UseXKeyboard)
+ {
+ mdev = LookupDeviceIntRec (stuff->modifier_device);
+ if (mdev == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
+ BadDevice);
+ return Success;
+ }
+ if (mdev->key == NULL)
+ {
+ SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
+ BadMatch);
+ return Success;
+ }
+ }
+ else
+ mdev = (DeviceIntPtr) LookupKeyboardDevice();
+
+ pWin = LookupWindow(stuff->grabWindow, client);
+ if (!pWin)
+ {
+ SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
+ BadWindow);
+ return Success;
+ }
+ if (((stuff->key > dev->key->curKeySyms.maxKeyCode) ||
+ (stuff->key < dev->key->curKeySyms.minKeyCode))
+ && (stuff->key != AnyKey))
+ {
+ SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
+ BadValue);
+ return Success;
+ }
+ if ((stuff->modifiers != AnyModifier) &&
+ (stuff->modifiers & ~AllModifiersMask))
+ {
+ SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
+ BadValue);
+ return Success;
+ }
+
+ temporaryGrab.resource = client->clientAsMask;
+ temporaryGrab.device = dev;
+ temporaryGrab.window = pWin;
+ temporaryGrab.type = DeviceKeyPress;
+ temporaryGrab.modifierDevice = mdev;
+ temporaryGrab.modifiersDetail.exact = stuff->modifiers;
+ temporaryGrab.modifiersDetail.pMask = NULL;
+ temporaryGrab.detail.exact = stuff->key;
+ temporaryGrab.detail.pMask = NULL;
+
+ DeletePassiveGrabFromList(&temporaryGrab);
+ return Success;
+ }
diff --git a/nx-X11/programs/Xserver/Xi/ungrdevk.h b/nx-X11/programs/Xserver/Xi/ungrdevk.h
new file mode 100644
index 000000000..ba3455882
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xi/ungrdevk.h
@@ -0,0 +1,44 @@
+/* $XFree86: xc/programs/Xserver/Xi/ungrdevk.h,v 3.1 1996/04/15 11:19:12 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef UNGRDEVK_H
+#define UNGRDEVK_H 1
+
+int
+SProcXUngrabDeviceKey(
+ ClientPtr /* client */
+ );
+
+int
+ProcXUngrabDeviceKey(
+ ClientPtr /* client */
+ );
+
+#endif /* UNGRDEVK_H */
diff --git a/nx-X11/programs/Xserver/Xnest.def b/nx-X11/programs/Xserver/Xnest.def
new file mode 100644
index 000000000..3bfef9a74
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xnest.def
@@ -0,0 +1,4 @@
+NAME Xnest WINDOWCOMPAT
+DESCRIPTION "@#XFREE86:4.4.0#@ $XFree86: xc/programs/Xserver/Xnest.def,v 3.4 2003/11/06 03:25:42 dawes Exp $"
+PROTMODE
+EXETYPE OS2
diff --git a/nx-X11/programs/Xserver/Xorg.def b/nx-X11/programs/Xserver/Xorg.def
new file mode 100644
index 000000000..fac275d35
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xorg.def
@@ -0,0 +1,5 @@
+NAME Xorg NOTWINDOWCOMPAT
+DESCRIPTION "@#XORG:4.4.0#@ $XdotOrg: xc/programs/Xserver/Xorg.def,v 1.2 2004/04/23 18:44:35 eich Exp $"
+PROTMODE
+EXETYPE OS2
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/Imakefile
new file mode 100644
index 000000000..930cc6711
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/Imakefile
@@ -0,0 +1,8 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+SUBDIRS = print
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/Imakefile
new file mode 100644
index 000000000..fe224df64
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/Imakefile
@@ -0,0 +1,23 @@
+XCOMM $Xorg: Imakefile,v 1.1 2003/11/20 04:22:52 gisburn Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+SUBDIRS = attributes ddx-config models
+
+#if HasGhostScript
+all:: Xprinters.ghostscript
+
+# Enable the "xp_pdf_spooldir_tmp_Xprintjobs" printer if we have GS
+Xprinters.ghostscript: Xprinters
+ sed <Xprinters "s/#Printer xp_pdf_spooldir_tmp_Xprintjobs/Printer xp_pdf_spooldir_tmp_Xprintjobs/" >Xprinters.ghostscript
+
+clean::
+ $(RM) Xprinters.ghostscript
+
+InstallNamedNonExec(Xprinters.ghostscript,Xprinters,$(XPRINTDIR)/C/print)
+#else
+InstallNamedNonExec(Xprinters,Xprinters,$(XPRINTDIR)/C/print)
+#endif /* HasGhostScript */
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/Xprinters b/nx-X11/programs/Xserver/XpConfig/C/print/Xprinters
new file mode 100644
index 000000000..a32c02dc2
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/Xprinters
@@ -0,0 +1,49 @@
+########################################################################
+#
+# $Xorg: Xprinters,v 1.3 2000/08/17 19:48:02 cpqbld Exp $
+#
+# X*printers sample configuration file
+#
+#
+# This file belongs in /usr/lib/X11/X*printers, where the "*" is the
+# display number of the server. For example, if the server is
+# invoked using the command X :0, then the X0printers file is used.
+########################################################################
+
+########################################################################
+# Use lpstat to augment the list of printers managed by the
+# server. (This is the default behavior if the X*printers file does
+# not exist, or if an "Augment_Printer_List" line is not specified.)
+########################################################################
+#Augment_Printer_List %(default)%
+
+########################################################################
+# Use the specified command pipeline to augment the list of printers
+# managed by the server.
+########################################################################
+#Augment_Printer_List lpstat -a | cut -d " " -f 1 # equivalent to default
+
+########################################################################
+# Do not augment the list of printers managed by the server.
+########################################################################
+#Augment_Printer_List %none%
+
+########################################################################
+# Preconfigured entry for the PSspooldir model
+# (which sends jobs to /tmp/Xprintjobs instead to a physical printer)
+########################################################################
+#Printer xp_pdf_spooldir_tmp_Xprintjobs
+Printer xp_ps_spooldir_tmp_Xprintjobs
+
+########################################################################
+# Add individual printers to the list of printers managed by the
+# server. These are aliases, determined by driver name.
+########################################################################
+
+
+# EXAMPLES
+#
+# Printer xppspr
+# Printer xppclpr
+# Printer xppclmonopr
+# Printer xprasterpr
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/attributes/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/attributes/Imakefile
new file mode 100644
index 000000000..e0daf54d2
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/attributes/Imakefile
@@ -0,0 +1,8 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $
+
+XPATTRIBUTEDIR = $(XPRINTDIR)/C/print/attributes
+
+InstallNonExecFile(document,$(XPATTRIBUTEDIR))
+InstallNonExecFile(job,$(XPATTRIBUTEDIR))
+InstallNonExecFile(printer,$(XPATTRIBUTEDIR))
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/attributes/document b/nx-X11/programs/Xserver/XpConfig/C/print/attributes/document
new file mode 100644
index 000000000..b1651bd94
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/attributes/document
@@ -0,0 +1,49 @@
+# $Xorg: document,v 1.3 2000/08/17 19:48:03 cpqbld Exp $
+# Document DPA-Object initial attribute values
+
+# Attribute IDs must be qualified by using one of the following
+# (listed in order of precedence):
+#
+# printer-name
+# Set this attribute for a specific printer.
+# Example: "dj_1.plex: duplex"
+#
+# printer-model
+# Set this attribute for all printers of a specific model.
+# Example: "HPDJ1600C.plex: duplex"
+#
+# '*'
+# Set this attribute for all printers.
+# Example: "*.plex: duplex"
+
+
+*content-orientation: portrait
+*copy-count: 1
+*default-medium: iso-a4
+*default-printer-resolution: 600
+
+# "PSspooldir" jobs should always be 300 DPI
+# (to be compatible to DPS-based PostScript viewers such as sdtimage)
+PSspooldir.default-printer-resolution: 300
+
+# "PS2PDFspooldir-GS" jobs should always be 600 DPI
+PS2PDFspooldir-GS.default-printer-resolution: 600
+
+# Some resolution defaults to make applications happy which are too lazy
+# to pick an own default in absence of "default-printer-resolution"
+HPLJ4050-PS.default-printer-resolution: 600
+SPSPARC2.default-printer-resolution: 300
+CANONBJ10E-GS.default-printer-resolution: 360
+CANONC3200-PS.default-printer-resolution: 600
+
+# EXAMPLES
+#
+# *content-orientation: landscape
+# *copy-count: 3
+# *default-input-tray: main
+# *default-medium: iso-a4
+# *default-printer-resolution: 600
+# *document-format: {PCL 5}
+# *plex: simplex
+# *xp-listfonts-modes: xp-list-internal-printer-fonts
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/attributes/job b/nx-X11/programs/Xserver/XpConfig/C/print/attributes/job
new file mode 100644
index 000000000..aa1911dcd
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/attributes/job
@@ -0,0 +1,25 @@
+# $Xorg: job,v 1.3 2000/08/17 19:48:03 cpqbld Exp $
+# Job DPA-Object initial attribute values
+
+# Attribute IDs must be qualified by using one of the following
+# (listed in order of precedence):
+#
+# printer-name
+# Set this attribute for a specific printer.
+# Example: "laser_1.job-priority: 1"
+#
+# printer-model
+# Set this attribute for all printers of a specific model.
+# Example: "HPDJ1600C.job-priority: 1"
+#
+# '*'
+# Set this attribute for all printers.
+# Example: "*.job-priority: 1"
+
+*notification-profile: {}
+
+# EXAMPLES
+#
+# *job-name: Example Job Name
+# *notification-profile: {{event-report-job-completed} electronic-mail}
+# *xp-spooler-command-options: -onb
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/attributes/printer b/nx-X11/programs/Xserver/XpConfig/C/print/attributes/printer
new file mode 100644
index 000000000..41e13b44b
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/attributes/printer
@@ -0,0 +1,96 @@
+# $Xorg: printer,v 1.3 2000/08/17 19:48:03 cpqbld Exp $
+# Printer DPA-Object initial attribute values
+
+# Attribute IDs must be qualified by using one of the following
+# (listed in order of precedence):
+#
+# printer-name
+# Set this attribute for a specific printer.
+# Example: "dj_1.document-formats-ready: {pcl 5}"
+#
+# printer-model
+# Set this attribute for all printers of a specific model.
+# Example: "HPDJ1600C.document-formats-ready: {pcl 5}"
+#
+# '*'
+# Set this attribute for all printers.
+# Example: "*.document-formats-ready: {pcl 5}"
+
+# Remove this line and replace them with per printer settings
+# if you want to use more than one DDX!!
+*xp-model-identifier: PSdefault
+
+
+# Sample entry for the "PSspooldir" model
+# Just add a printer called "xp_ps_spooldir_tmp_Xprintjobs" to "Xprinters"
+# and you will get an extra printer which files the PostScript jobs
+# in the "/tmp/Xprintjobs/" directory.
+xp_ps_spooldir_tmp_Xprintjobs.xp-model-identifier: PSspooldir
+
+# Sample entry for the "PS2PDFspooldir-GS" model
+# Just add a printer called "xp_pdf_spooldir_tmp_Xprintjobs" to "Xprinters"
+# and you will get an extra printer which convertes the PostScript jobs
+# to PDF using "ps2pdf" and files them into the "/tmp/Xprintjobs/" directory.
+# NOTE: Future versions of Xprint will use the PDF DDX instead directly
+# instead of relying on GhostScript/ps2pdf...
+xp_pdf_spooldir_tmp_Xprintjobs.xp-model-identifier: PS2PDFspooldir-GS
+
+
+# IMPORTANT EXAMPLES
+#
+# The following are examples of how a printer name is bound
+# to a model-config file and ddx driver.
+#
+# Warning: most X-Servers have a hard limit on the number of ddx
+# drivers (ie, screens) they can support at runtime (usually 3 or
+# 4). Whatever the number of printers, they cannot create a
+# dependency for more than the limit on ddx drivers. Assuming
+# "Xprinters" listed all four xp*pr printers below, X-Servers
+# with a limit of 3 would not work.
+#
+# xppspr.xp-model-identifier: HPDJ1600C
+# xppspr.xp-ddx-identifier: XP-POSTSCRIPT
+# xppspr.document-formats-ready: { PostScript 2 }
+#
+# xppclpr.xp-model-identifier: HPDJ1600C
+# xppclpr.xp-ddx-identifier: XP-PCL-COLOR
+# xppclpr.document-formats-ready: { PCL 5 }
+#
+# xppclmonopr.xp-model-identifier: HPDJ1600C
+# xppclmonopr.xp-ddx-identifier: XP-PCL-MONO
+# xppclmonopr.document-formats-ready: { PCL 5 }
+#
+# xprasterpr.xp-model-identifier: HPDJ1600C
+# xprasterpr.xp-ddx-identifier: XP-RASTER
+
+
+# MORE EXAMPLES of items often configured in this file
+#
+# *descriptor: This printer has not been given a name
+# *dt-pdm-command: dtpdm
+# *input-trays-medium: {top na-letter} {bottom iso-a4}
+# *xp-model-identifier: HPDJ1600C
+# *xp-spooler-command: /opt/mystuff/bin/mylp -p %printer-name% -c %copy-count% \
+# -j %job-name% -o %options%
+
+
+# USUALLY SET BY THE ddx driver
+#
+# *content-orientations-supported: portrait landscape reverse-portrait reverse-landscape
+
+
+# USUALLY SET BY THE model-config FILE
+#
+# *document-formats-supported: {PCL 5}
+# *medium-source-sizes-supported: \
+# { top {iso-a4 FALSE {10 200 10 287}} {iso-a5 FALSE {10 138 10 200}} } \
+# { bottom {iso-a4 FALSE {10 200 10 287}} {iso-a5 FALSE {10 138 10 200}} }
+# *plexes-supported: simplex duplex tumble
+# *printer-model: Hewlett-Packard LaserJet IV
+# *printer-resolutions-supported: 300
+# *xp-ddx-identifier: XP-PCL-COLOR
+# *xp-embedded-formats-supported: {PCL 5} {HPGL 2}
+# *xp-listfonts-modes-supported: xp-list-internal-printer-fonts
+# *xp-raw-formats-supported: {PCL 5}
+# *xp-setup-proviso: xp-setup-optional
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/Imakefile
new file mode 100644
index 000000000..71f7a7817
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/Imakefile
@@ -0,0 +1,8 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+SUBDIRS = raster
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/raster/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/raster/Imakefile
new file mode 100644
index 000000000..85950c946
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/raster/Imakefile
@@ -0,0 +1,6 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $
+
+XPDDXCONFIGRASTERDIR = $(XPRINTDIR)/C/print/ddx-config/raster
+
+InstallNonExecFile(pcl,$(XPDDXCONFIGRASTERDIR))
+InstallNonExecFile(postscript,$(XPDDXCONFIGRASTERDIR))
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/raster/pcl b/nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/raster/pcl
new file mode 100644
index 000000000..15d33e7b3
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/raster/pcl
@@ -0,0 +1,39 @@
+# $Xorg: pcl,v 1.3 2000/08/17 19:48:03 cpqbld Exp $
+# This is the file which you should customize to include the printers that
+# will print through the raster driver. The early part of this file
+# specifies some commn useful defaults. You can override them when
+# you list your printers in the second part of this file. This file is
+# an X Resource file. To learn more about this file format, consult
+# the functional specification.
+
+# Note that the reference printer for CDEnext is the HP DeskJet 1600C.
+# This driver may work for other printers, but the reference printer
+# is the only officially supported printer.
+
+
+# DEFAULTS
+# ========
+
+# The attributes below apply to all printers unless the section below
+# specifies something different for the printer.
+
+# Default printer attributes
+# --------------------------
+# Printer attributes control the choices that users will see in the
+# setup dialog for those printers.
+
+# The attributes below apply to all printes unless the section below
+# specifies something different for the printer.
+
+*.media-ready: na-letter-white
+*.descriptor: Printer supported by CDEnext DtPrint System.
+*.printer-model: HPDJ1600C
+
+# Printer Specifics
+
+# Use this section to override the defaults listed above or to override the
+# printer attributes described in the model file.
+# The lines describing "laser" are just a sample to help you get started.
+
+# laser.printer-name: laser
+# laser.spooler-name: laser
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/raster/postscript b/nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/raster/postscript
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/raster/postscript
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/Imakefile
new file mode 100644
index 000000000..59521467b
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/Imakefile
@@ -0,0 +1,15 @@
+XCOMM $Xorg: Imakefile,v 1.1 2003/02/10 05:42:52 gisburn Exp $
+
+XPMODELNAME = CANONBJ10E-GS
+
+MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME)
+
+InstallNonExecFile(model-config,$(MODELDIR))
+
+# All GhostScript-printer models should use the printer-builtin fonts from the
+# "GSdefault" printer model (unless they employ more or other builtin fonts)
+# (native PostScript printers should use the fonts from the "PSdefault" model)
+install::
+ $(RM) $(DESTDIR)$(MODELDIR)/fonts
+ $(LN) ../GSdefault/fonts $(DESTDIR)$(MODELDIR)
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/model-config b/nx-X11/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/model-config
new file mode 100644
index 000000000..97bfd8196
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/model-config
@@ -0,0 +1,23 @@
+# $Xprint.org: CANONBJ10E-GS model-config,v 1.4 2003/02/10 14:48:04 gisburn Exp $
+
+*content-orientations-supported: portrait landscape
+*descriptor: Canon BJ-10e (GhostScript)
+*document-formats-supported: {POSTSCRIPT 2}
+*input-trays-supported:
+*medium-source-sizes-supported: \
+{ '' \
+ {iso-b5 FALSE {6.35 169.65 6.35 243.65}}\
+ {iso-a4 FALSE {6.35 203.65 6.35 290.65}}\
+ {na-letter FALSE {6.35 209.55 6.35 273.05}}\
+ {na-legal FALSE {6.35 209.55 6.35 349.25}}\
+}
+
+*plexes-supported: simplex
+*printer-model: "Canon BJ-10e (GhostScript)"
+*printer-resolutions-supported: 360
+*xp-ddx-identifier: XP-POSTSCRIPT
+*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts
+*xp-embedded-formats-supported: {POSTSCRIPT 2}
+*xp-raw-formats-supported: {POSTSCRIPT 2}
+*xp-setup-proviso: setup-optional
+# EOF.
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/CANONC3200-PS/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/CANONC3200-PS/Imakefile
new file mode 100644
index 000000000..3bfbcc913
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/CANONC3200-PS/Imakefile
@@ -0,0 +1,15 @@
+XCOMM $Xorg: Imakefile,v 1.1 2004/06/24 09:25:02 gisburn Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+SUBDIRS = fonts
+
+XPMODELNAME = CANONC3200-PS
+
+MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME)
+
+InstallNonExecFile(model-config,$(MODELDIR))
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/CANONC3200-PS/fonts/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/CANONC3200-PS/fonts/Imakefile
new file mode 100644
index 000000000..b4e1b3df3
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/CANONC3200-PS/fonts/Imakefile
@@ -0,0 +1,45 @@
+XCOMM $Xorg: Imakefile,v 1.1 2004/06/24 09:25:23 gisburn Exp $
+
+XPFONTS = \
+ AvantGarde-Book.pmf \
+ AvantGarde-BookOblique.pmf \
+ AvantGarde-Demi.pmf \
+ AvantGarde-DemiOblique.pmf \
+ Courier-Bold.pmf \
+ Courier-BoldOblique.pmf \
+ Courier-Oblique.pmf \
+ Courier.pmf \
+ Helvetica-Bold.pmf \
+ Helvetica-BoldOblique.pmf \
+ Helvetica-Oblique.pmf \
+ Helvetica.pmf \
+ LubalinGraph-Book.pmf \
+ LubalinGraph-BookOblique.pmf \
+ LubalinGraph-Demi.pmf \
+ LubalinGraph-DemiOblique.pmf \
+ NewCenturySchlbk-Bold.pmf \
+ NewCenturySchlbk-BoldItalic.pmf \
+ NewCenturySchlbk-Italic.pmf \
+ NewCenturySchlbk-Roman.pmf \
+ Souvenir-Demi.pmf \
+ Souvenir-DemiItalic.pmf \
+ Souvenir-Light.pmf \
+ Souvenir-LightItalic.pmf \
+ Symbol.pmf \
+ Times-Bold.pmf \
+ Times-BoldItalic.pmf \
+ Times-Italic.pmf \
+ Times-Roman.pmf \
+ ZapfDingbats.pmf
+
+XPMODELNAME = CANONC3200-PS
+
+MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME)
+MODELFONTDIR = $(MODELDIR)/fonts
+
+# We reuse some of the PSdefault fonts
+PARENTMODELFONTDIR=../../PSdefault/fonts
+
+InstallXpMultiplePMFLinks($(XPFONTS),$(PARENTMODELFONTDIR),$(MODELFONTDIR))
+InstallXpPMFFontsDir($(MODELFONTDIR))
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/CANONC3200-PS/model-config b/nx-X11/programs/Xserver/XpConfig/C/print/models/CANONC3200-PS/model-config
new file mode 100644
index 000000000..cdb3f4958
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/CANONC3200-PS/model-config
@@ -0,0 +1,40 @@
+# $Xprint.org: CANONC3200-PS model-config,v 1.1 2004/06/24 09:18:04 gisburn Exp $
+# model-config for the PostScript DDX
+#
+# automatically generated by xpppdtomodelconfig V0.1
+#
+# DO NOT MODIFY THIS FILE!!
+#
+# Attributes supported for this printer model
+*content-orientations-supported: portrait landscape reverse-portrait reverse-landscape
+*descriptor: Canon iR C3200
+*document-formats-supported: {POSTSCRIPT 2}
+*input-trays-supported:
+*medium-source-sizes-supported: \
+{ '' \
+ {iso-a4 FALSE {4.002 206 4.002 293}}\
+ {na-letter FALSE {4.002 211.9 4.002 275.4}}\
+ {na-legal FALSE {4.002 211.9 4.002 351.6}}\
+ {iso-a3 FALSE {4.002 293 4.002 416}}\
+ {iso-a5 FALSE {4.002 144 4.002 206}}\
+ {iso-b4 FALSE {4.002 246 4.002 349}}\
+ {iso-b5 FALSE {4.002 172 4.002 246}}\
+ {executive FALSE {4.002 180.1 4.002 262.7}}\
+ {invoice FALSE {4.002 135.7 4.002 211.9}}\
+ {monarch-envelope FALSE {4.002 94.3 4.002 186.5}}\
+ {na-number-10-envelop FALSE {4.002 100.8 4.002 237.3}}\
+ {iso-c5 FALSE {4.002 158 4.002 225}}\
+}
+
+*plexes-supported: simplex duplex tumble
+*printer-model: "Canon iR C3200"
+*printer-resolutions-supported: 600
+*xp-ddx-identifier: XP-POSTSCRIPT
+*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts
+*xp-embedded-formats-supported: {POSTSCRIPT 2}
+*xp-raw-formats-supported: {POSTSCRIPT 2}
+*xp-setup-proviso: setup-optional
+# NOTE: xp-psddx-* attributes are EXPERIMENTAL for now.
+*xp-psddx-download-fonts: pfa pfb ttf ttc otf otc
+*xp-psddx-download-font-type: pstype1
+# EOF.
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/GSdefault/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/GSdefault/Imakefile
new file mode 100644
index 000000000..6ac1d0d24
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/GSdefault/Imakefile
@@ -0,0 +1,14 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $
+
+XPMODELNAME = GSdefault
+
+MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME)
+
+InstallNonExecFile(model-config,$(MODELDIR))
+
+# All PostScript-printer models should use the printer-builtin fonts from the
+# "PSdefault" printer model (unless they employ more or other builtin fonts)
+install::
+ $(RM) $(DESTDIR)$(MODELDIR)/fonts
+ $(LN) ../PSdefault/fonts $(DESTDIR)$(MODELDIR)
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/GSdefault/model-config b/nx-X11/programs/Xserver/XpConfig/C/print/models/GSdefault/model-config
new file mode 100644
index 000000000..61dac18b8
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/GSdefault/model-config
@@ -0,0 +1,137 @@
+# $Xprint.org: GSdefault model-config,v 1.1 2003/02/10 14:48:04 gisburn Exp $
+# Generic default model-config for the PostScript DDX when using GhostScript
+# as printer driver
+#
+# DO NOT MODIFY THIS FILE!!
+#
+# If you want to make customisations for your printer create a copy
+# of this printer model.
+# Example (for creating a model config "MYCOMPANYlaserxx"):
+# 1. Create model config dir:
+# % mkdir MYCOMPANYlaserxx
+# 2. Link (or copy) the PMF (printer font metrics) for the
+# printer buildin fonts:
+# % ln -s GSdefault/fonts MYCOMPANYlaserxx/.
+# 3. Copy the model config file:
+# % cp GSdefault/model-config MYCOMPANYlaserxx/.
+# 4. Customize MYCOMPANYlaserxx/model-config to match your needs.
+#
+
+# Attributes supported for this printer model
+# You may want to cut the lists here down to the attributes supported
+# by your printer.
+*content-orientations-supported: portrait landscape reverse-portrait reverse-landscape
+*descriptor: GhostScript default model
+*document-formats-supported: {POSTSCRIPT 2}
+*input-trays-supported:
+*medium-source-sizes-supported: \
+{ '' \
+ {na-letter FALSE {6.35 209.55 6.35 273.05}}\
+ {na-legal FALSE {6.35 209.55 6.35 349.25}}\
+ {executive FALSE {6.35 177.80 6.35 260.35}}\
+ {folio FALSE {6.35 204.47 6.35 323.85}}\
+ {invoice FALSE {6.35 133.35 6.35 209.55}}\
+ {ledger FALSE {6.35 273.05 6.35 425.45}}\
+ {quarto FALSE {6.35 209.55 6.35 268.732}}\
+ {a FALSE {6.35 209.55 6.35 273.05}}\
+ {b FALSE {6.35 273.05 6.35 425.45}}\
+ {c FALSE {6.35 425.45 6.35 552.45}}\
+ {d FALSE {6.35 552.45 6.35 857.25}}\
+ {e FALSE {6.35 857.25 6.35 1111.25}}\
+ {na-6x9-envelope FALSE {6.35 146.05 6.35 222.25}}\
+ {na-10x15-envelope FALSE {6.35 247.65 6.35 374.65}}\
+ {monarch-envelope FALSE {6.35 91.948 6.35 184.15}}\
+ {na-10x13-envelope FALSE {6.35 247.65 6.35 323.85}}\
+ {na-9x12-envelope FALSE {6.35 222.25 6.35 298.45}}\
+ {na-number-10-envelope FALSE {6.35 98.425 6.35 234.95}}\
+ {na-7x9-envelope FALSE {6.35 171.45 6.35 222.25}}\
+ {na-9x11-envelope FALSE {6.35 222.25 6.35 273.05}}\
+ {na-10x14-envelope FALSE {6.35 247.65 6.35 349.25}}\
+ {na-number-9-envelope FALSE {6.35 92.075 6.35 219.075}}\
+ {iso-a0 FALSE {6.35 834.65 6.35 1182.65}}\
+ {iso-a1 FALSE {6.35 587.65 6.35 834.65}}\
+ {iso-a2 FALSE {6.35 413.65 6.35 587.65}}\
+ {iso-a3 FALSE {6.35 290.65 6.35 413.65}}\
+ {iso-a4 FALSE {6.35 203.65 6.35 290.65}}\
+ {iso-a5 FALSE {6.35 141.65 6.35 203.65}}\
+ {iso-a6 FALSE {6.35 98.65 6.35 141.65}}\
+ {iso-a7 FALSE {6.35 67.65 6.35 98.65}}\
+ {iso-a8 FALSE {6.35 45.65 6.35 67.65}}\
+ {iso-a9 FALSE {6.35 30.65 6.35 45.65}}\
+ {iso-a10 FALSE {6.35 19.65 6.35 30.65}}\
+ {iso-b1 FALSE {6.35 700.65 6.35 993.65}}\
+ {iso-b2 FALSE {6.35 493.65 6.35 700.65}}\
+ {iso-b3 FALSE {6.35 346.65 6.35 493.65}}\
+ {iso-b4 FALSE {6.35 243.65 6.35 346.65}}\
+ {iso-b5 FALSE {6.35 169.65 6.35 243.65}}\
+ {iso-b6 FALSE {6.35 118.65 6.35 169.65}}\
+ {iso-b7 FALSE {6.35 81.65 6.35 118.65}}\
+ {iso-b8 FALSE {6.35 55.65 6.35 81.65}}\
+ {iso-b9 FALSE {6.35 37.65 6.35 55.65}}\
+ {iso-b10 FALSE {6.35 24.65 6.35 37.65}}\
+ {jis-b1 FALSE {6.35 721.65 6.35 1023.65}}\
+ {jis-b2 FALSE {6.35 508.65 6.35 721.65}}\
+ {jis-b3 FALSE {6.35 357.65 6.35 508.65}}\
+ {jis-b4 FALSE {6.35 250.65 6.35 357.65}}\
+ {jis-b5 FALSE {6.35 175.65 6.35 250.65}}\
+ {jis-b6 FALSE {6.35 121.65 6.35 175.65}}\
+ {jis-b7 FALSE {6.35 84.65 6.35 121.65}}\
+ {jis-b8 FALSE {6.35 57.65 6.35 84.65}}\
+ {jis-b9 FALSE {6.35 38.65 6.35 57.65}}\
+ {jis-b10 FALSE {6.35 25.65 6.35 38.65}}\
+ {iso-c3 FALSE {6.35 317.65 6.35 451.65}}\
+ {iso-c4 FALSE {6.35 222.65 6.35 317.65}}\
+ {iso-c5 FALSE {6.35 155.65 6.35 222.65}}\
+ {iso-c6 FALSE {6.35 107.65 6.35 155.65}}\
+ {iso-designated-long FALSE {6.35 103.65 6.35 213.65}}\
+ {hp-2x-postcard FALSE {6.35 141.65 6.35 193.65}}\
+ {hp-european-edp FALSE {6.35 298.45 6.35 349.25}}\
+ {hp-mini FALSE {6.35 133.35 6.35 209.55}}\
+ {hp-postcard FALSE {6.35 93.65 6.35 141.65}}\
+ {hp-tabloid FALSE {6.35 273.05 6.35 425.45}}\
+ {hp-us-edp FALSE {6.35 273.05 6.35 349.25}}\
+ {hp-us-government-legal FALSE {6.35 196.85 6.35 323.85}}\
+ {hp-us-government-letter FALSE {6.35 196.85 6.35 247.65}}\
+}
+# If you have more than one tray use the following example:
+# 1. List the supported trays
+#*input-trays-supported: main manual
+# 2. Define each tray and it's paper sizes
+#*medium-source-sizes-supported: \
+#{ main \
+# {na-letter FALSE {6.35 209.55 6.35 273.05}} \
+# {na-legal FALSE {6.35 209.55 6.35 349.25}} \
+# {iso-a4 FALSE {6.35 203.65 6.35 290.65}} \
+#} \
+#{ manual \
+# {iso-a5 FALSE {6.35 141.65 6.35 203.65}} \
+# {iso-c5 FALSE {6.35 155.65 6.35 222.65}} \
+# {iso-designated-long FALSE {6.35 103.65 6.35 213.65}} \
+# {jis-b5 FALSE {6.35 175.65 6.35 250.65}} \
+# {monarch-envelope FALSE {6.35 91.948 6.35 184.15}} \
+# {na-legal FALSE {6.35 209.55 6.35 349.25}} \
+# {na-number-10-envelope FALSE {6.35 98.425 6.35 234.95}} \
+# {executive FALSE {6.35 177.8 6.35 260.35}} \
+# {iso-a3 FALSE {6.35 290.65 6.35 413.65}} \
+# {iso-a0 FALSE {6.35 834.65 6.35 1182.65}} \
+#}
+*plexes-supported: simplex duplex tumble
+*printer-model: "GhostScript default model"
+# 75, 100, 120, 150, 180, 200, 240, 300, 360, 400, 600, 720,
+# 940, 1200 and 2440 are supported DPI values, we limit it here
+# to some common values:
+*printer-resolutions-supported: 300 360 400 600
+*xp-ddx-identifier: XP-POSTSCRIPT
+*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts
+*xp-embedded-formats-supported: {POSTSCRIPT 2}
+*xp-raw-formats-supported: {POSTSCRIPT 2}
+*xp-setup-proviso: setup-optional
+
+# NOTE: xp-psddx-* attributes are EXPERIMENTAL for now.
+# xp-psddx-download-fonts defines which fonts should be downloaded as outlines
+# (valid types are "pfa", "pfb", "ttf", "ttc", "otf", "otc")
+*xp-psddx-download-fonts: pfa pfb ttf ttc otf otc
+# xp-psddx-download-font-type defines which font type is used to download outlines
+# (valid values are "bitmap", "pstype1" and "pstype3")
+*xp-psddx-download-font-type: pstype1
+# EOF.
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/Imakefile
new file mode 100644
index 000000000..9e8c8e4dc
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/Imakefile
@@ -0,0 +1,14 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+SUBDIRS = fonts
+
+XPMODELNAME = HPDJ1600C
+
+MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME)
+
+InstallNonExecFile(model-config,$(MODELDIR))
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00051.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00051.pmf
new file mode 100644
index 000000000..09cc489a5
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00051.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00052.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00052.pmf
new file mode 100644
index 000000000..b21a9a2a8
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00052.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00053.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00053.pmf
new file mode 100644
index 000000000..485b874c5
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00053.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00054.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00054.pmf
new file mode 100644
index 000000000..524934c71
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00054.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00055.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00055.pmf
new file mode 100644
index 000000000..2ef9bc52c
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00055.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00056.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00056.pmf
new file mode 100644
index 000000000..3d69311ef
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00056.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00057.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00057.pmf
new file mode 100644
index 000000000..3833d4f54
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00057.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00058.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00058.pmf
new file mode 100644
index 000000000..289a95e5c
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00058.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00059.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00059.pmf
new file mode 100644
index 000000000..a5984bed1
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00059.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00060.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00060.pmf
new file mode 100644
index 000000000..df27cd71e
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00060.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00061.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00061.pmf
new file mode 100644
index 000000000..fb2b5a433
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00061.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00062.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00062.pmf
new file mode 100644
index 000000000..f0e58c435
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00062.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00063.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00063.pmf
new file mode 100644
index 000000000..8821ff155
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00063.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00064.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00064.pmf
new file mode 100644
index 000000000..e5980fc0e
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00064.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00065.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00065.pmf
new file mode 100644
index 000000000..d9a151d7f
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00065.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00066.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00066.pmf
new file mode 100644
index 000000000..d14fca56f
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00066.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00067.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00067.pmf
new file mode 100644
index 000000000..7a341506f
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00067.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00068.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00068.pmf
new file mode 100644
index 000000000..c20e39a21
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00068.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00069.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00069.pmf
new file mode 100644
index 000000000..4a4a35281
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00069.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00070.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00070.pmf
new file mode 100644
index 000000000..8d97d4339
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00070.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00071.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00071.pmf
new file mode 100644
index 000000000..19844c9c6
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00071.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00072.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00072.pmf
new file mode 100644
index 000000000..5415c3f44
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00072.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00073.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00073.pmf
new file mode 100644
index 000000000..038dfdb46
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00073.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00074.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00074.pmf
new file mode 100644
index 000000000..382a78575
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00074.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00075.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00075.pmf
new file mode 100644
index 000000000..1c7edf653
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00075.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00076.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00076.pmf
new file mode 100644
index 000000000..2f077f40f
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00076.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00077.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00077.pmf
new file mode 100644
index 000000000..1ce190d51
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00077.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00079.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00079.pmf
new file mode 100644
index 000000000..45d6906ba
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00079.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00080.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00080.pmf
new file mode 100644
index 000000000..b991b5edb
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00080.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00081.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00081.pmf
new file mode 100644
index 000000000..1935a9f00
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00081.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00082.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00082.pmf
new file mode 100644
index 000000000..2000dc057
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00082.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00083.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00083.pmf
new file mode 100644
index 000000000..90f0e45a8
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00083.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00084.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00084.pmf
new file mode 100644
index 000000000..52ba39b96
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00084.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00085.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00085.pmf
new file mode 100644
index 000000000..f5c9053af
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00085.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00086.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00086.pmf
new file mode 100644
index 000000000..b7586ca61
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00086.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00087.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00087.pmf
new file mode 100644
index 000000000..82f054999
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00087.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00088.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00088.pmf
new file mode 100644
index 000000000..591c96b59
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00088.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00089.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00089.pmf
new file mode 100644
index 000000000..c8160954a
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00089.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00090.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00090.pmf
new file mode 100644
index 000000000..895cfe26a
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00090.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00091.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00091.pmf
new file mode 100644
index 000000000..3bdcae4ba
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00091.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00092.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00092.pmf
new file mode 100644
index 000000000..a56d47504
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00092.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00093.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00093.pmf
new file mode 100644
index 000000000..c85f3b4de
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00093.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00094.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00094.pmf
new file mode 100644
index 000000000..875bf1df8
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00094.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/Imakefile
new file mode 100644
index 000000000..0c899365a
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/Imakefile
@@ -0,0 +1,57 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $
+
+XPFONTS = \
+ 9nb00051.pmf \
+ 9nb00052.pmf \
+ 9nb00053.pmf \
+ 9nb00054.pmf \
+ 9nb00055.pmf \
+ 9nb00056.pmf \
+ 9nb00057.pmf \
+ 9nb00058.pmf \
+ 9nb00059.pmf \
+ 9nb00060.pmf \
+ 9nb00061.pmf \
+ 9nb00062.pmf \
+ 9nb00063.pmf \
+ 9nb00064.pmf \
+ 9nb00065.pmf \
+ 9nb00066.pmf \
+ 9nb00067.pmf \
+ 9nb00068.pmf \
+ 9nb00069.pmf \
+ 9nb00070.pmf \
+ 9nb00071.pmf \
+ 9nb00072.pmf \
+ 9nb00073.pmf \
+ 9nb00074.pmf \
+ 9nb00075.pmf \
+ 9nb00076.pmf \
+ 9nb00077.pmf \
+ 9nb00079.pmf \
+ 9nb00080.pmf \
+ 9nb00081.pmf \
+ 9nb00082.pmf \
+ 9nb00083.pmf \
+ 9nb00084.pmf \
+ 9nb00085.pmf \
+ 9nb00086.pmf \
+ 9nb00087.pmf \
+ 9nb00088.pmf \
+ 9nb00089.pmf \
+ 9nb00090.pmf \
+ 9nb00091.pmf \
+ 9nb00092.pmf \
+ 9nb00093.pmf \
+ 9nb00094.pmf \
+ lpr0ye1a.pmf \
+ fonts.alias \
+ fonts.dir \
+ README
+
+XPMODELNAME = HPDJ1600C
+
+MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME)
+MODELFONTDIR = $(MODELDIR)/fonts
+InstallMultipleDest(install,$(XPFONTS),$(MODELFONTDIR))
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/README b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/README
new file mode 100644
index 000000000..cccc2be32
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/README
@@ -0,0 +1,197 @@
+$Xorg: README,v 1.3 2000/08/17 19:48:04 cpqbld Exp $
+
+This directory contains "printer metric files" for the X Print
+Server suitable for the DeskJet 1600C printer. The following
+*.pmf files were generated by the Hewlett-Packard Company.
+
+ 9nb00051.pmf
+ 9nb00052.pmf
+ 9nb00053.pmf
+ 9nb00054.pmf
+ 9nb00055.pmf
+ 9nb00056.pmf
+ 9nb00057.pmf
+ 9nb00058.pmf
+ 9nb00059.pmf
+ 9nb00060.pmf
+ 9nb00061.pmf
+ 9nb00062.pmf
+ 9nb00063.pmf
+ 9nb00064.pmf
+ 9nb00065.pmf
+ 9nb00066.pmf
+ 9nb00067.pmf
+ 9nb00068.pmf
+ 9nb00069.pmf
+ 9nb00070.pmf
+ 9nb00071.pmf
+ 9nb00072.pmf
+ 9nb00073.pmf
+ 9nb00074.pmf
+ 9nb00075.pmf
+ 9nb00076.pmf
+ 9nb00077.pmf
+ 9nb00079.pmf
+ 9nb00080.pmf
+ 9nb00081.pmf
+ 9nb00082.pmf
+ 9nb00083.pmf
+ 9nb00084.pmf
+ 9nb00085.pmf
+ 9nb00086.pmf
+ 9nb00087.pmf
+ 9nb00088.pmf
+ 9nb00089.pmf
+ 9nb00090.pmf
+ 9nb00091.pmf
+ 9nb00092.pmf
+ 9nb00093.pmf
+ 9nb00094.pmf
+ lpr0ye1a.pmf
+
+For reasons of not supporting iso8859.1 and hp-roman8, the following
+DeskJet 1600C printer fonts were not converted to *.pmf files.
+
+ 9nb00078.pmf
+ 9nb00095.pmf
+ lpr0ylga.pmf
+ lpr0ypca.pmf
+ lpr0ypda.pmf
+ lpr0ypma.pmf
+ lpr0yr8a.pmf
+
+Output from the conversion utility is as follows:
+
+ Creating iso8859 1 pmf for 9nb00051.tfm as iso8859.1/9nb00051.pmf
+ -COMPUGRAPHIC-Albertus-Extra Bold-r-Normal--8782-2500-2540-2540-P-42480-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00052.tfm as iso8859.1/9nb00052.pmf
+ -COMPUGRAPHIC-Albertus-Semi Bold-r-Normal--8782-2500-2540-2540-P-37640-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00053.tfm as iso8859.1/9nb00053.pmf
+ -COMPUGRAPHIC-Antique Olive-Bold-r-Normal--8782-2500-2540-2540-P-50490-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00054.tfm as iso8859.1/9nb00054.pmf
+ -COMPUGRAPHIC-Antique Olive-Medium-i-Normal--8782-2500-2540-2540-P-46140-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00055.tfm as iso8859.1/9nb00055.pmf
+ -COMPUGRAPHIC-Antique Olive-Medium-r-Normal--8782-2500-2540-2540-P-46380-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00056.tfm as iso8859.1/9nb00056.pmf
+ -Monotype-Arial-Bold-r-Normal--2048-2500-589-589-P-9800-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00057.tfm as iso8859.1/9nb00057.pmf
+ -Monotype-Arial-Medium-i-Normal--2048-2500-589-589-P-9040-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00058.tfm as iso8859.1/9nb00058.pmf
+ -Monotype-Arial-Bold-i-Normal--2048-2500-589-589-P-9800-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00059.tfm as iso8859.1/9nb00059.pmf
+ -Monotype-Arial-Medium-r-Normal--2048-2500-589-589-P-9040-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00060.tfm as iso8859.1/9nb00060.pmf
+ -COMPUGRAPHIC-Clarendon-Bold-r-Condensed--8782-2500-2540-2540-P-35080-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00061.tfm as iso8859.1/9nb00061.pmf
+ -COMPUGRAPHIC-Courier-Bold-r-Normal--8782-2500-2540-2540-M-52910-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00062.tfm as iso8859.1/9nb00062.pmf
+ -COMPUGRAPHIC-Courier-Medium-i-Normal--8782-2500-2540-2540-M-52910-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00063.tfm as iso8859.1/9nb00063.pmf
+ -COMPUGRAPHIC-Courier-Bold-i-Normal--8782-2500-2540-2540-M-52910-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00064.tfm as iso8859.1/9nb00064.pmf
+ -COMPUGRAPHIC-Courier-Medium-r-Normal--8782-2500-2540-2540-M-52910-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00065.tfm as iso8859.1/9nb00065.pmf
+ -COMPUGRAPHIC-Garamond-Bold-r-Normal--8782-2500-2540-2540-P-38730-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00066.tfm as iso8859.1/9nb00066.pmf
+ -COMPUGRAPHIC-Garamond-Medium-i-Normal--8782-2500-2540-2540-P-34280-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00067.tfm as iso8859.1/9nb00067.pmf
+ -COMPUGRAPHIC-Garamond-Bold-i-Normal--8782-2500-2540-2540-P-37020-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00068.tfm as iso8859.1/9nb00068.pmf
+ -COMPUGRAPHIC-Garamond-Medium-r-Normal--8782-2500-2540-2540-P-36560-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00069.tfm as iso8859.1/9nb00069.pmf
+ -COMPUGRAPHIC-Letter Gothic-Bold-r-Normal--8782-2500-2540-2540-M-44090-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00070.tfm as iso8859.1/9nb00070.pmf
+ -COMPUGRAPHIC-Letter Gothic-Medium-i-Normal--8782-2500-2540-2540-M-44090-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00071.tfm as iso8859.1/9nb00071.pmf
+ -COMPUGRAPHIC-Letter Gothic-Medium-r-Normal--8782-2500-2540-2540-M-44090-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00072.tfm as iso8859.1/9nb00072.pmf
+ -COMPUGRAPHIC-Marigold-Medium-r-Normal--8782-2500-2540-2540-P-21890-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00073.tfm as iso8859.1/9nb00073.pmf
+ -COMPUGRAPHIC-Omega-Bold-r-Normal--8782-2500-2540-2540-P-38600-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00074.tfm as iso8859.1/9nb00074.pmf
+ -COMPUGRAPHIC-Omega-Medium-i-Normal--8782-2500-2540-2540-P-37980-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00075.tfm as iso8859.1/9nb00075.pmf
+ -COMPUGRAPHIC-Omega-Bold-i-Normal--8782-2500-2540-2540-P-38560-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00076.tfm as iso8859.1/9nb00076.pmf
+ -COMPUGRAPHIC-Omega-Medium-r-Normal--8782-2500-2540-2540-P-37770-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00077.tfm as iso8859.1/9nb00077.pmf
+ -COMPUGRAPHIC-Coronet-Medium-i-Normal--8782-2500-2540-2540-P-22870-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00079.tfm as iso8859.1/9nb00079.pmf
+ -Monotype-Times New Roman-Bold-r-Normal--2048-2500-589-589-P-8740-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00080.tfm as iso8859.1/9nb00080.pmf
+ -Monotype-Times New Roman-Medium-i-Normal--2048-2500-589-589-P-8230-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00081.tfm as iso8859.1/9nb00081.pmf
+ -Monotype-Times New Roman-Bold-i-Normal--2048-2500-589-589-P-8440-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00082.tfm as iso8859.1/9nb00082.pmf
+ -Monotype-Times New Roman-Medium-r-Normal--2048-2500-589-589-P-8210-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00083.tfm as iso8859.1/9nb00083.pmf
+ -COMPUGRAPHIC-Times-Bold-r-Normal--8782-2500-2540-2540-P-38200-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00084.tfm as iso8859.1/9nb00084.pmf
+ -COMPUGRAPHIC-Times-Medium-i-Normal--8782-2500-2540-2540-P-36000-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00085.tfm as iso8859.1/9nb00085.pmf
+ -COMPUGRAPHIC-Times-Bold-i-Normal--8782-2500-2540-2540-P-36900-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00086.tfm as iso8859.1/9nb00086.pmf
+ -COMPUGRAPHIC-Times-Medium-r-Normal--8782-2500-2540-2540-P-36080-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00087.tfm as iso8859.1/9nb00087.pmf
+ -COMPUGRAPHIC-Univers-Medium-i-Condensed--8782-2500-2540-2540-P-29970-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00088.tfm as iso8859.1/9nb00088.pmf
+ -COMPUGRAPHIC-Univers-Bold-r-Normal--8782-2500-2540-2540-P-41280-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00089.tfm as iso8859.1/9nb00089.pmf
+ -COMPUGRAPHIC-Univers-Medium-r-Condensed--8782-2500-2540-2540-P-29970-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00090.tfm as iso8859.1/9nb00090.pmf
+ -COMPUGRAPHIC-Univers-Bold-r-Condensed--8782-2500-2540-2540-P-33030-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00091.tfm as iso8859.1/9nb00091.pmf
+ -COMPUGRAPHIC-Univers-Bold-i-Condensed--8782-2500-2540-2540-P-33030-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00092.tfm as iso8859.1/9nb00092.pmf
+ -COMPUGRAPHIC-Univers-Medium-i-Normal--8782-2500-2540-2540-P-41280-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00093.tfm as iso8859.1/9nb00093.pmf
+ -COMPUGRAPHIC-Univers-Bold-i-Normal--8782-2500-2540-2540-P-41280-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00094.tfm as iso8859.1/9nb00094.pmf
+ -COMPUGRAPHIC-Univers-Medium-r-Normal--8782-2500-2540-2540-P-41280-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for lpr0ye1a.tfm as iso8859.1/lpr0ye1a.pmf
+ -HP-Line Printer-Medium-r-Normal--35-85-300-300-M-180-iso8859-1
+ ------------------------------------
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.dir b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.dir
new file mode 100644
index 000000000..da702ccc1
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.dir
@@ -0,0 +1,45 @@
+44
+lpr0ye1a.pmf -hp-line printer-medium-r-normal--35-85-300-300-m-180-iso8859-1
+9nb00080.pmf -monotype-times new roman-medium-i-normal--2048-2500-589-589-p-8230-iso8859-1
+9nb00092.pmf -compugraphic-univers-medium-i-normal--8782-2500-2540-2540-p-41280-iso8859-1
+9nb00081.pmf -monotype-times new roman-bold-i-normal--2048-2500-589-589-p-8440-iso8859-1
+9nb00093.pmf -compugraphic-univers-bold-i-normal--8782-2500-2540-2540-p-41280-iso8859-1
+9nb00082.pmf -monotype-times new roman-medium-r-normal--2048-2500-589-589-p-8210-iso8859-1
+9nb00090.pmf -compugraphic-univers-bold-r-condensed--8782-2500-2540-2540-p-33030-iso8859-1
+9nb00083.pmf -compugraphic-times-bold-r-normal--8782-2500-2540-2540-p-38200-iso8859-1
+9nb00091.pmf -compugraphic-univers-bold-i-condensed--8782-2500-2540-2540-p-33030-iso8859-1
+9nb00084.pmf -compugraphic-times-medium-i-normal--8782-2500-2540-2540-p-36000-iso8859-1
+9nb00085.pmf -compugraphic-times-bold-i-normal--8782-2500-2540-2540-p-36900-iso8859-1
+9nb00086.pmf -compugraphic-times-medium-r-normal--8782-2500-2540-2540-p-36080-iso8859-1
+9nb00094.pmf -compugraphic-univers-medium-r-normal--8782-2500-2540-2540-p-41280-iso8859-1
+9nb00087.pmf -compugraphic-univers-medium-i-condensed--8782-2500-2540-2540-p-29970-iso8859-1
+9nb00088.pmf -compugraphic-univers-bold-r-normal--8782-2500-2540-2540-p-41280-iso8859-1
+9nb00089.pmf -compugraphic-univers-medium-r-condensed--8782-2500-2540-2540-p-29970-iso8859-1
+9nb00058.pmf -monotype-arial-bold-i-normal--2048-2500-589-589-p-9800-iso8859-1
+9nb00059.pmf -monotype-arial-medium-r-normal--2048-2500-589-589-p-9040-iso8859-1
+9nb00068.pmf -compugraphic-garamond-medium-r-normal--8782-2500-2540-2540-p-36560-iso8859-1
+9nb00069.pmf -compugraphic-letter gothic-bold-r-normal--8782-2500-2540-2540-m-44090-iso8859-1
+9nb00079.pmf -monotype-times new roman-bold-r-normal--2048-2500-589-589-p-8740-iso8859-1
+9nb00052.pmf -compugraphic-albertus-semi bold-r-normal--8782-2500-2540-2540-p-37640-iso8859-1
+9nb00064.pmf -compugraphic-courier-medium-r-normal--8782-2500-2540-2540-m-52910-iso8859-1
+9nb00076.pmf -compugraphic-omega-medium-r-normal--8782-2500-2540-2540-p-37770-iso8859-1
+9nb00053.pmf -compugraphic-antique olive-bold-r-normal--8782-2500-2540-2540-p-50490-iso8859-1
+9nb00065.pmf -compugraphic-garamond-bold-r-normal--8782-2500-2540-2540-p-38730-iso8859-1
+9nb00077.pmf -compugraphic-coronet-medium-i-normal--8782-2500-2540-2540-p-22870-iso8859-1
+9nb00066.pmf -compugraphic-garamond-medium-i-normal--8782-2500-2540-2540-p-34280-iso8859-1
+9nb00074.pmf -compugraphic-omega-medium-i-normal--8782-2500-2540-2540-p-37980-iso8859-1
+9nb00051.pmf -compugraphic-albertus-extra bold-r-normal--8782-2500-2540-2540-p-42480-iso8859-1
+9nb00067.pmf -compugraphic-garamond-bold-i-normal--8782-2500-2540-2540-p-37020-iso8859-1
+9nb00075.pmf -compugraphic-omega-bold-i-normal--8782-2500-2540-2540-p-38560-iso8859-1
+9nb00056.pmf -monotype-arial-bold-r-normal--2048-2500-589-589-p-9800-iso8859-1
+9nb00060.pmf -compugraphic-clarendon-bold-r-condensed--8782-2500-2540-2540-p-35080-iso8859-1
+9nb00072.pmf -compugraphic-marigold-medium-r-normal--8782-2500-2540-2540-p-21890-iso8859-1
+9nb00057.pmf -monotype-arial-medium-i-normal--2048-2500-589-589-p-9040-iso8859-1
+9nb00061.pmf -compugraphic-courier-bold-r-normal--8782-2500-2540-2540-m-52910-iso8859-1
+9nb00073.pmf -compugraphic-omega-bold-r-normal--8782-2500-2540-2540-p-38600-iso8859-1
+9nb00054.pmf -compugraphic-antique olive-medium-i-normal--8782-2500-2540-2540-p-46140-iso8859-1
+9nb00062.pmf -compugraphic-courier-medium-i-normal--8782-2500-2540-2540-m-52910-iso8859-1
+9nb00070.pmf -compugraphic-letter gothic-medium-i-normal--8782-2500-2540-2540-m-44090-iso8859-1
+9nb00055.pmf -compugraphic-antique olive-medium-r-normal--8782-2500-2540-2540-p-46380-iso8859-1
+9nb00063.pmf -compugraphic-courier-bold-i-normal--8782-2500-2540-2540-m-52910-iso8859-1
+9nb00071.pmf -compugraphic-letter gothic-medium-r-normal--8782-2500-2540-2540-m-44090-iso8859-1
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/lpr0ye1a.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/lpr0ye1a.pmf
new file mode 100644
index 000000000..483748893
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/lpr0ye1a.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/model-config b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/model-config
new file mode 100644
index 000000000..5d45d4495
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/model-config
@@ -0,0 +1,40 @@
+# $Xprint.org: HPDJ1600C model-config,v 1.4 2002/11/07 19:48:04 gisburn Exp $
+# This is the configuration file for the HP DeskJet 1600C printer.
+#
+# The CDEnext SI supports two 1600C drivers XP-PCL-MONO and
+# XP-PCL-COLOR, which work with this configuration file.
+#
+
+*content-orientations-supported: portrait landscape
+*descriptor: Hewlett-Packard DeskJet 1600C
+*document-formats-supported: {PCL 5} {PostScript 2}
+*input-trays-supported:
+# 1/4" unprintable margins
+*medium-source-sizes-supported:\
+{ '' \
+ {na-letter FALSE {6.35 209.55 6.35 273.05}}\
+ {executive FALSE {6.35 177.75 6.35 260.35}}\
+ {na-legal FALSE {6.35 209.55 6.35 349.25}}\
+ {iso-a3 FALSE {6.35 290.65 6.35 413.35}}\
+ {iso-a4 FALSE {6.35 203.65 6.35 290.65}}\
+ {jis-b4 FALSE {6.35 251.65 6.35 367.65}}\
+ {jis-b5 FALSE {6.35 175.65 6.35 250.65}}\
+ {monarch-envelope FALSE {6.35 91.94 6.35 184.15}}\
+ {iso-designated-long FALSE {6.35 103.65 6.35 213.65}}\
+ {iso-c5 FALSE {6.35 155.65 6.35 222.65}}\
+ {na-number-10-envelope FALSE {6.35 98.45 6.35 234.95}}\
+ {hp-tabloid FALSE {6.35 273.05 6.35 425.45}}\
+ {ledger FALSE {6.35 273.05 6.35 425.45}}\
+ {b FALSE {6.35 273.05 6.35 425.45}}\
+ {hp-japanese-postcard FALSE {6 94 6 142 }}\
+ {hp-japanese-doublepostcard FALSE {6 142 6 194 }}\
+}
+*plexes-supported: simplex duplex
+*printer-model: "Hewlett-Packard DeskJet 1600C"
+*printer-resolutions-supported: 300
+*xp-ddx-identifier: XP-PCL-COLOR
+*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts
+*xp-embedded-formats-supported: { PCL 5 } { PostScript 2 }
+*xp-raw-formats-supported: { PCL 5 }
+*xp-setup-proviso: setup-optional
+# EOF.
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/Imakefile
new file mode 100644
index 000000000..b62236366
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/Imakefile
@@ -0,0 +1,15 @@
+XCOMM $Xorg: Imakefile,v 1.1 2003/12/16 00:42:52 gisburn Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+SUBDIRS = fonts
+
+XPMODELNAME = HPLJ4050-PS
+
+MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME)
+
+InstallNonExecFile(model-config,$(MODELDIR))
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/fonts/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/fonts/Imakefile
new file mode 100644
index 000000000..9c9c3c1ef
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/fonts/Imakefile
@@ -0,0 +1,45 @@
+XCOMM $Xorg: Imakefile,v 1.1 2003/12/16 00:42:52 gisburn Exp $
+
+XPFONTS = \
+ AvantGarde-Book.pmf \
+ AvantGarde-BookOblique.pmf \
+ AvantGarde-Demi.pmf \
+ AvantGarde-DemiOblique.pmf \
+ Courier-Bold.pmf \
+ Courier-BoldOblique.pmf \
+ Courier-Oblique.pmf \
+ Courier.pmf \
+ Helvetica-Bold.pmf \
+ Helvetica-BoldOblique.pmf \
+ Helvetica-Oblique.pmf \
+ Helvetica.pmf \
+ LubalinGraph-Book.pmf \
+ LubalinGraph-BookOblique.pmf \
+ LubalinGraph-Demi.pmf \
+ LubalinGraph-DemiOblique.pmf \
+ NewCenturySchlbk-Bold.pmf \
+ NewCenturySchlbk-BoldItalic.pmf \
+ NewCenturySchlbk-Italic.pmf \
+ NewCenturySchlbk-Roman.pmf \
+ Souvenir-Demi.pmf \
+ Souvenir-DemiItalic.pmf \
+ Souvenir-Light.pmf \
+ Souvenir-LightItalic.pmf \
+ Symbol.pmf \
+ Times-Bold.pmf \
+ Times-BoldItalic.pmf \
+ Times-Italic.pmf \
+ Times-Roman.pmf \
+ ZapfDingbats.pmf
+
+XPMODELNAME = HPLJ4050-PS
+
+MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME)
+MODELFONTDIR = $(MODELDIR)/fonts
+
+# We reuse some of the PSdefault fonts
+PARENTMODELFONTDIR=../../PSdefault/fonts
+
+InstallXpMultiplePMFLinks($(XPFONTS),$(PARENTMODELFONTDIR),$(MODELFONTDIR))
+InstallXpPMFFontsDir($(MODELFONTDIR))
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/model-config b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/model-config
new file mode 100644
index 000000000..159206de2
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/model-config
@@ -0,0 +1,36 @@
+# $Xprint.org: HPLJ4050-PS model-config,v 1.1 2003/12/16 00:48:04 gisburn Exp $
+# model-config for the HP LaserJet 4050 PostScript printer series
+#
+*content-orientations-supported: portrait landscape reverse-portrait reverse-landscape
+*descriptor: Hewlett-Packard LaserJet 4050 PostScript printer
+*document-formats-supported: {POSTSCRIPT 2}
+*input-trays-supported:
+*medium-source-sizes-supported: \
+{ '' \
+ {na-letter FALSE {6.35 209.55 6.35 273.05}}\
+ {na-legal FALSE {6.35 209.55 6.35 349.25}}\
+ {executive FALSE {6.35 177.80 6.35 260.35}}\
+ {iso-a4 FALSE {6.35 203.65 6.35 290.65}}\
+ {iso-a5 FALSE {6.35 141.65 6.35 203.65}}\
+ {iso-b5 FALSE {6.35 169.65 6.35 243.65}}\
+ {jis-b5 FALSE {6.35 175.65 6.35 250.65}}\
+}
+
+# Duplex unit is optional for HPLJ4050 series
+*plexes-supported: simplex
+*printer-model: "Hewlett-Packard LaserJet 4050 PostScript printer"
+*printer-resolutions-supported: 600 1200
+*xp-ddx-identifier: XP-POSTSCRIPT
+*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts
+*xp-embedded-formats-supported: {POSTSCRIPT 2}
+*xp-raw-formats-supported: {POSTSCRIPT 2}
+*xp-setup-proviso: setup-optional
+
+# NOTE: xp-psddx-* attributes are EXPERIMENTAL for now.
+# xp-psddx-download-fonts defines which fonts should be downloaded as outlines
+# (valid types are "pfa", "pfb", "ttf", "ttc", "otf", "otc")
+*xp-psddx-download-fonts: pfa pfb ttf ttc otf otc
+# xp-psddx-download-font-type defines which font type is used to download outlines
+# (valid values are "bitmap", "pstype1" and "pstype3")
+*xp-psddx-download-font-type: pstype1
+# EOF.
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/Imakefile
new file mode 100644
index 000000000..28601153c
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/Imakefile
@@ -0,0 +1,14 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+SUBDIRS = fonts
+
+XPMODELNAME = HPLJ4family
+
+MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME)
+
+InstallNonExecFile(model-config,$(MODELDIR))
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00051.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00051.pmf
new file mode 100644
index 000000000..09cc489a5
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00051.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00052.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00052.pmf
new file mode 100644
index 000000000..b21a9a2a8
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00052.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00053.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00053.pmf
new file mode 100644
index 000000000..485b874c5
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00053.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00054.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00054.pmf
new file mode 100644
index 000000000..524934c71
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00054.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00055.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00055.pmf
new file mode 100644
index 000000000..2ef9bc52c
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00055.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00056.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00056.pmf
new file mode 100644
index 000000000..3d69311ef
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00056.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00057.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00057.pmf
new file mode 100644
index 000000000..3833d4f54
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00057.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00058.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00058.pmf
new file mode 100644
index 000000000..289a95e5c
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00058.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00059.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00059.pmf
new file mode 100644
index 000000000..a5984bed1
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00059.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00060.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00060.pmf
new file mode 100644
index 000000000..df27cd71e
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00060.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00061.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00061.pmf
new file mode 100644
index 000000000..fb2b5a433
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00061.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00062.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00062.pmf
new file mode 100644
index 000000000..f0e58c435
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00062.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00063.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00063.pmf
new file mode 100644
index 000000000..8821ff155
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00063.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00064.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00064.pmf
new file mode 100644
index 000000000..e5980fc0e
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00064.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00065.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00065.pmf
new file mode 100644
index 000000000..d9a151d7f
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00065.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00066.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00066.pmf
new file mode 100644
index 000000000..d14fca56f
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00066.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00067.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00067.pmf
new file mode 100644
index 000000000..7a341506f
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00067.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00068.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00068.pmf
new file mode 100644
index 000000000..c20e39a21
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00068.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00069.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00069.pmf
new file mode 100644
index 000000000..4a4a35281
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00069.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00070.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00070.pmf
new file mode 100644
index 000000000..8d97d4339
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00070.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00071.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00071.pmf
new file mode 100644
index 000000000..19844c9c6
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00071.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00072.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00072.pmf
new file mode 100644
index 000000000..5415c3f44
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00072.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00073.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00073.pmf
new file mode 100644
index 000000000..038dfdb46
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00073.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00074.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00074.pmf
new file mode 100644
index 000000000..382a78575
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00074.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00075.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00075.pmf
new file mode 100644
index 000000000..1c7edf653
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00075.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00076.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00076.pmf
new file mode 100644
index 000000000..2f077f40f
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00076.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00077.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00077.pmf
new file mode 100644
index 000000000..1ce190d51
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00077.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00079.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00079.pmf
new file mode 100644
index 000000000..45d6906ba
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00079.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00080.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00080.pmf
new file mode 100644
index 000000000..b991b5edb
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00080.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00081.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00081.pmf
new file mode 100644
index 000000000..1935a9f00
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00081.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00082.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00082.pmf
new file mode 100644
index 000000000..2000dc057
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00082.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00083.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00083.pmf
new file mode 100644
index 000000000..90f0e45a8
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00083.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00084.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00084.pmf
new file mode 100644
index 000000000..52ba39b96
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00084.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00085.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00085.pmf
new file mode 100644
index 000000000..f5c9053af
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00085.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00086.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00086.pmf
new file mode 100644
index 000000000..b7586ca61
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00086.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00087.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00087.pmf
new file mode 100644
index 000000000..82f054999
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00087.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00088.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00088.pmf
new file mode 100644
index 000000000..591c96b59
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00088.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00089.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00089.pmf
new file mode 100644
index 000000000..c8160954a
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00089.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00090.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00090.pmf
new file mode 100644
index 000000000..895cfe26a
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00090.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00091.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00091.pmf
new file mode 100644
index 000000000..3bdcae4ba
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00091.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00092.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00092.pmf
new file mode 100644
index 000000000..a56d47504
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00092.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00093.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00093.pmf
new file mode 100644
index 000000000..c85f3b4de
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00093.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00094.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00094.pmf
new file mode 100644
index 000000000..875bf1df8
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00094.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/Imakefile
new file mode 100644
index 000000000..868aa8a8c
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/Imakefile
@@ -0,0 +1,56 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $
+
+XPFONTS = \
+ 9nb00051.pmf \
+ 9nb00052.pmf \
+ 9nb00053.pmf \
+ 9nb00054.pmf \
+ 9nb00055.pmf \
+ 9nb00056.pmf \
+ 9nb00057.pmf \
+ 9nb00058.pmf \
+ 9nb00059.pmf \
+ 9nb00060.pmf \
+ 9nb00061.pmf \
+ 9nb00062.pmf \
+ 9nb00063.pmf \
+ 9nb00064.pmf \
+ 9nb00065.pmf \
+ 9nb00066.pmf \
+ 9nb00067.pmf \
+ 9nb00068.pmf \
+ 9nb00069.pmf \
+ 9nb00070.pmf \
+ 9nb00071.pmf \
+ 9nb00072.pmf \
+ 9nb00073.pmf \
+ 9nb00074.pmf \
+ 9nb00075.pmf \
+ 9nb00076.pmf \
+ 9nb00077.pmf \
+ 9nb00079.pmf \
+ 9nb00080.pmf \
+ 9nb00081.pmf \
+ 9nb00082.pmf \
+ 9nb00083.pmf \
+ 9nb00084.pmf \
+ 9nb00085.pmf \
+ 9nb00086.pmf \
+ 9nb00087.pmf \
+ 9nb00088.pmf \
+ 9nb00089.pmf \
+ 9nb00090.pmf \
+ 9nb00091.pmf \
+ 9nb00092.pmf \
+ 9nb00093.pmf \
+ 9nb00094.pmf \
+ fonts.alias \
+ fonts.dir \
+ lpr0ye1a.pmf \
+ README
+
+XPMODELNAME = HPLJ4family
+
+MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME)
+MODELFONTDIR = $(MODELDIR)/fonts
+InstallMultipleDest(install,$(XPFONTS),$(MODELFONTDIR))
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/README b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/README
new file mode 100644
index 000000000..2c9821834
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/README
@@ -0,0 +1,203 @@
+$Xorg: README,v 1.3 2000/08/17 19:48:04 cpqbld Exp $
+
+This directory contains "printer metric files" for the X Print
+Server suitable for the LaserJet 4 family of printers - 4, 4L,
+4M, 4ML, 4MP, 4P, 4Si, 4Si-MX. The following *.pmf files were
+generated by the Hewlett-Packard Company.
+
+ 9nb00051.pmf
+ 9nb00052.pmf
+ 9nb00053.pmf
+ 9nb00054.pmf
+ 9nb00055.pmf
+ * 9nb00056.pmf
+ * 9nb00057.pmf
+ * 9nb00058.pmf
+ * 9nb00059.pmf
+ * 9nb00060.pmf
+ 9nb00061.pmf
+ 9nb00062.pmf
+ 9nb00063.pmf
+ 9nb00064.pmf
+ * 9nb00065.pmf
+ * 9nb00066.pmf
+ * 9nb00067.pmf
+ * 9nb00068.pmf
+ 9nb00069.pmf
+ 9nb00070.pmf
+ 9nb00071.pmf
+ * 9nb00072.pmf
+ * 9nb00073.pmf
+ * 9nb00074.pmf
+ * 9nb00075.pmf
+ * 9nb00076.pmf
+ 9nb00077.pmf
+ * 9nb00079.pmf
+ * 9nb00080.pmf
+ * 9nb00081.pmf
+ * 9nb00082.pmf
+ 9nb00083.pmf
+ 9nb00084.pmf
+ 9nb00085.pmf
+ 9nb00086.pmf
+ 9nb00087.pmf
+ 9nb00088.pmf
+ 9nb00089.pmf
+ 9nb00090.pmf
+ 9nb00091.pmf
+ 9nb00092.pmf
+ 9nb00093.pmf
+ 9nb00094.pmf
+ lpr0ye1a.pmf
+
+
+ * note - the marked fonts are NOT supported by the 4L printer. If
+ making extensive use of the 4L, you may want to create a special
+ 4L model-config area and exclude these fonts.
+
+For reasons of not supporting iso8859.1 and hp-roman8, the following
+Laserjet 4 printer fonts were not converted to *.pmf files.
+
+ 9nb00078.pmf
+ 9nb00095.pmf
+ lpr0ylga.pmf
+ lpr0ypca.pmf
+ lpr0ypda.pmf
+ lpr0ypma.pmf
+ lpr0yr8a.pmf
+
+Output from the conversion utility is as follows:
+
+ Creating iso8859 1 pmf for 9nb00051.tfm as iso8859.1/9nb00051.pmf
+ -COMPUGRAPHIC-Albertus-Extra Bold-r-Normal--8782-2500-2540-2540-P-42480-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00052.tfm as iso8859.1/9nb00052.pmf
+ -COMPUGRAPHIC-Albertus-Semi Bold-r-Normal--8782-2500-2540-2540-P-37640-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00053.tfm as iso8859.1/9nb00053.pmf
+ -COMPUGRAPHIC-Antique Olive-Bold-r-Normal--8782-2500-2540-2540-P-50490-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00054.tfm as iso8859.1/9nb00054.pmf
+ -COMPUGRAPHIC-Antique Olive-Medium-i-Normal--8782-2500-2540-2540-P-46140-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00055.tfm as iso8859.1/9nb00055.pmf
+ -COMPUGRAPHIC-Antique Olive-Medium-r-Normal--8782-2500-2540-2540-P-46380-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00056.tfm as iso8859.1/9nb00056.pmf
+ -Monotype-Arial-Bold-r-Normal--2048-2500-589-589-P-9800-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00057.tfm as iso8859.1/9nb00057.pmf
+ -Monotype-Arial-Medium-i-Normal--2048-2500-589-589-P-9040-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00058.tfm as iso8859.1/9nb00058.pmf
+ -Monotype-Arial-Bold-i-Normal--2048-2500-589-589-P-9800-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00059.tfm as iso8859.1/9nb00059.pmf
+ -Monotype-Arial-Medium-r-Normal--2048-2500-589-589-P-9040-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00060.tfm as iso8859.1/9nb00060.pmf
+ -COMPUGRAPHIC-Clarendon-Bold-r-Condensed--8782-2500-2540-2540-P-35080-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00061.tfm as iso8859.1/9nb00061.pmf
+ -COMPUGRAPHIC-Courier-Bold-r-Normal--8782-2500-2540-2540-M-52910-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00062.tfm as iso8859.1/9nb00062.pmf
+ -COMPUGRAPHIC-Courier-Medium-i-Normal--8782-2500-2540-2540-M-52910-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00063.tfm as iso8859.1/9nb00063.pmf
+ -COMPUGRAPHIC-Courier-Bold-i-Normal--8782-2500-2540-2540-M-52910-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00064.tfm as iso8859.1/9nb00064.pmf
+ -COMPUGRAPHIC-Courier-Medium-r-Normal--8782-2500-2540-2540-M-52910-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00065.tfm as iso8859.1/9nb00065.pmf
+ -COMPUGRAPHIC-Garamond-Bold-r-Normal--8782-2500-2540-2540-P-38730-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00066.tfm as iso8859.1/9nb00066.pmf
+ -COMPUGRAPHIC-Garamond-Medium-i-Normal--8782-2500-2540-2540-P-34280-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00067.tfm as iso8859.1/9nb00067.pmf
+ -COMPUGRAPHIC-Garamond-Bold-i-Normal--8782-2500-2540-2540-P-37020-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00068.tfm as iso8859.1/9nb00068.pmf
+ -COMPUGRAPHIC-Garamond-Medium-r-Normal--8782-2500-2540-2540-P-36560-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00069.tfm as iso8859.1/9nb00069.pmf
+ -COMPUGRAPHIC-Letter Gothic-Bold-r-Normal--8782-2500-2540-2540-M-44090-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00070.tfm as iso8859.1/9nb00070.pmf
+ -COMPUGRAPHIC-Letter Gothic-Medium-i-Normal--8782-2500-2540-2540-M-44090-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00071.tfm as iso8859.1/9nb00071.pmf
+ -COMPUGRAPHIC-Letter Gothic-Medium-r-Normal--8782-2500-2540-2540-M-44090-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00072.tfm as iso8859.1/9nb00072.pmf
+ -COMPUGRAPHIC-Marigold-Medium-r-Normal--8782-2500-2540-2540-P-21890-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00073.tfm as iso8859.1/9nb00073.pmf
+ -COMPUGRAPHIC-Omega-Bold-r-Normal--8782-2500-2540-2540-P-38600-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00074.tfm as iso8859.1/9nb00074.pmf
+ -COMPUGRAPHIC-Omega-Medium-i-Normal--8782-2500-2540-2540-P-37980-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00075.tfm as iso8859.1/9nb00075.pmf
+ -COMPUGRAPHIC-Omega-Bold-i-Normal--8782-2500-2540-2540-P-38560-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00076.tfm as iso8859.1/9nb00076.pmf
+ -COMPUGRAPHIC-Omega-Medium-r-Normal--8782-2500-2540-2540-P-37770-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00077.tfm as iso8859.1/9nb00077.pmf
+ -COMPUGRAPHIC-Coronet-Medium-i-Normal--8782-2500-2540-2540-P-22870-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00079.tfm as iso8859.1/9nb00079.pmf
+ -Monotype-Times New Roman-Bold-r-Normal--2048-2500-589-589-P-8740-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00080.tfm as iso8859.1/9nb00080.pmf
+ -Monotype-Times New Roman-Medium-i-Normal--2048-2500-589-589-P-8230-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00081.tfm as iso8859.1/9nb00081.pmf
+ -Monotype-Times New Roman-Bold-i-Normal--2048-2500-589-589-P-8440-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00082.tfm as iso8859.1/9nb00082.pmf
+ -Monotype-Times New Roman-Medium-r-Normal--2048-2500-589-589-P-8210-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00083.tfm as iso8859.1/9nb00083.pmf
+ -COMPUGRAPHIC-Times-Bold-r-Normal--8782-2500-2540-2540-P-38200-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00084.tfm as iso8859.1/9nb00084.pmf
+ -COMPUGRAPHIC-Times-Medium-i-Normal--8782-2500-2540-2540-P-36000-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00085.tfm as iso8859.1/9nb00085.pmf
+ -COMPUGRAPHIC-Times-Bold-i-Normal--8782-2500-2540-2540-P-36900-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00086.tfm as iso8859.1/9nb00086.pmf
+ -COMPUGRAPHIC-Times-Medium-r-Normal--8782-2500-2540-2540-P-36080-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00087.tfm as iso8859.1/9nb00087.pmf
+ -COMPUGRAPHIC-Univers-Medium-i-Condensed--8782-2500-2540-2540-P-29970-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00088.tfm as iso8859.1/9nb00088.pmf
+ -COMPUGRAPHIC-Univers-Bold-r-Normal--8782-2500-2540-2540-P-41280-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00089.tfm as iso8859.1/9nb00089.pmf
+ -COMPUGRAPHIC-Univers-Medium-r-Condensed--8782-2500-2540-2540-P-29970-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00090.tfm as iso8859.1/9nb00090.pmf
+ -COMPUGRAPHIC-Univers-Bold-r-Condensed--8782-2500-2540-2540-P-33030-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00091.tfm as iso8859.1/9nb00091.pmf
+ -COMPUGRAPHIC-Univers-Bold-i-Condensed--8782-2500-2540-2540-P-33030-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00092.tfm as iso8859.1/9nb00092.pmf
+ -COMPUGRAPHIC-Univers-Medium-i-Normal--8782-2500-2540-2540-P-41280-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00093.tfm as iso8859.1/9nb00093.pmf
+ -COMPUGRAPHIC-Univers-Bold-i-Normal--8782-2500-2540-2540-P-41280-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for 9nb00094.tfm as iso8859.1/9nb00094.pmf
+ -COMPUGRAPHIC-Univers-Medium-r-Normal--8782-2500-2540-2540-P-41280-iso8859-1
+ ------------------------------------
+ Creating iso8859 1 pmf for lpr0ye1a.tfm as iso8859.1/lpr0ye1a.pmf
+ -HP-Line Printer-Medium-r-Normal--35-85-300-300-M-180-iso8859-1
+ ------------------------------------
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/fonts.dir b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/fonts.dir
new file mode 100644
index 000000000..da702ccc1
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/fonts.dir
@@ -0,0 +1,45 @@
+44
+lpr0ye1a.pmf -hp-line printer-medium-r-normal--35-85-300-300-m-180-iso8859-1
+9nb00080.pmf -monotype-times new roman-medium-i-normal--2048-2500-589-589-p-8230-iso8859-1
+9nb00092.pmf -compugraphic-univers-medium-i-normal--8782-2500-2540-2540-p-41280-iso8859-1
+9nb00081.pmf -monotype-times new roman-bold-i-normal--2048-2500-589-589-p-8440-iso8859-1
+9nb00093.pmf -compugraphic-univers-bold-i-normal--8782-2500-2540-2540-p-41280-iso8859-1
+9nb00082.pmf -monotype-times new roman-medium-r-normal--2048-2500-589-589-p-8210-iso8859-1
+9nb00090.pmf -compugraphic-univers-bold-r-condensed--8782-2500-2540-2540-p-33030-iso8859-1
+9nb00083.pmf -compugraphic-times-bold-r-normal--8782-2500-2540-2540-p-38200-iso8859-1
+9nb00091.pmf -compugraphic-univers-bold-i-condensed--8782-2500-2540-2540-p-33030-iso8859-1
+9nb00084.pmf -compugraphic-times-medium-i-normal--8782-2500-2540-2540-p-36000-iso8859-1
+9nb00085.pmf -compugraphic-times-bold-i-normal--8782-2500-2540-2540-p-36900-iso8859-1
+9nb00086.pmf -compugraphic-times-medium-r-normal--8782-2500-2540-2540-p-36080-iso8859-1
+9nb00094.pmf -compugraphic-univers-medium-r-normal--8782-2500-2540-2540-p-41280-iso8859-1
+9nb00087.pmf -compugraphic-univers-medium-i-condensed--8782-2500-2540-2540-p-29970-iso8859-1
+9nb00088.pmf -compugraphic-univers-bold-r-normal--8782-2500-2540-2540-p-41280-iso8859-1
+9nb00089.pmf -compugraphic-univers-medium-r-condensed--8782-2500-2540-2540-p-29970-iso8859-1
+9nb00058.pmf -monotype-arial-bold-i-normal--2048-2500-589-589-p-9800-iso8859-1
+9nb00059.pmf -monotype-arial-medium-r-normal--2048-2500-589-589-p-9040-iso8859-1
+9nb00068.pmf -compugraphic-garamond-medium-r-normal--8782-2500-2540-2540-p-36560-iso8859-1
+9nb00069.pmf -compugraphic-letter gothic-bold-r-normal--8782-2500-2540-2540-m-44090-iso8859-1
+9nb00079.pmf -monotype-times new roman-bold-r-normal--2048-2500-589-589-p-8740-iso8859-1
+9nb00052.pmf -compugraphic-albertus-semi bold-r-normal--8782-2500-2540-2540-p-37640-iso8859-1
+9nb00064.pmf -compugraphic-courier-medium-r-normal--8782-2500-2540-2540-m-52910-iso8859-1
+9nb00076.pmf -compugraphic-omega-medium-r-normal--8782-2500-2540-2540-p-37770-iso8859-1
+9nb00053.pmf -compugraphic-antique olive-bold-r-normal--8782-2500-2540-2540-p-50490-iso8859-1
+9nb00065.pmf -compugraphic-garamond-bold-r-normal--8782-2500-2540-2540-p-38730-iso8859-1
+9nb00077.pmf -compugraphic-coronet-medium-i-normal--8782-2500-2540-2540-p-22870-iso8859-1
+9nb00066.pmf -compugraphic-garamond-medium-i-normal--8782-2500-2540-2540-p-34280-iso8859-1
+9nb00074.pmf -compugraphic-omega-medium-i-normal--8782-2500-2540-2540-p-37980-iso8859-1
+9nb00051.pmf -compugraphic-albertus-extra bold-r-normal--8782-2500-2540-2540-p-42480-iso8859-1
+9nb00067.pmf -compugraphic-garamond-bold-i-normal--8782-2500-2540-2540-p-37020-iso8859-1
+9nb00075.pmf -compugraphic-omega-bold-i-normal--8782-2500-2540-2540-p-38560-iso8859-1
+9nb00056.pmf -monotype-arial-bold-r-normal--2048-2500-589-589-p-9800-iso8859-1
+9nb00060.pmf -compugraphic-clarendon-bold-r-condensed--8782-2500-2540-2540-p-35080-iso8859-1
+9nb00072.pmf -compugraphic-marigold-medium-r-normal--8782-2500-2540-2540-p-21890-iso8859-1
+9nb00057.pmf -monotype-arial-medium-i-normal--2048-2500-589-589-p-9040-iso8859-1
+9nb00061.pmf -compugraphic-courier-bold-r-normal--8782-2500-2540-2540-m-52910-iso8859-1
+9nb00073.pmf -compugraphic-omega-bold-r-normal--8782-2500-2540-2540-p-38600-iso8859-1
+9nb00054.pmf -compugraphic-antique olive-medium-i-normal--8782-2500-2540-2540-p-46140-iso8859-1
+9nb00062.pmf -compugraphic-courier-medium-i-normal--8782-2500-2540-2540-m-52910-iso8859-1
+9nb00070.pmf -compugraphic-letter gothic-medium-i-normal--8782-2500-2540-2540-m-44090-iso8859-1
+9nb00055.pmf -compugraphic-antique olive-medium-r-normal--8782-2500-2540-2540-p-46380-iso8859-1
+9nb00063.pmf -compugraphic-courier-bold-i-normal--8782-2500-2540-2540-m-52910-iso8859-1
+9nb00071.pmf -compugraphic-letter gothic-medium-r-normal--8782-2500-2540-2540-m-44090-iso8859-1
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/lpr0ye1a.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/lpr0ye1a.pmf
new file mode 100644
index 000000000..483748893
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/lpr0ye1a.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/model-config b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/model-config
new file mode 100644
index 000000000..1ac997ebe
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/model-config
@@ -0,0 +1,39 @@
+# $Xprint.org: HPLJ4family model-config,v 1.4 2002/11/07 19:48:04 gisburn Exp $
+# This is the configuration file for the HP LaserJet 4 Printers.
+#
+# Though not a deliverable for the CDEnext SI, the XP-PCL-MONO
+# driver should be able to support the LaserJet 4 printers.
+#
+*content-orientations-supported: portrait landscape
+*descriptor: Hewlett-Packard LaserJet 4 Series
+*document-formats-supported: {PCL 5} {PostScript 2}
+*input-trays-supported:
+# 1/4" unprintable margins
+*medium-source-sizes-supported:\
+{ '' \
+ {na-letter FALSE {6.35 209.55 6.35 273.05}}\
+ {executive FALSE {6.35 177.75 6.35 260.35}}\
+ {na-legal FALSE {6.35 209.55 6.35 349.25}}\
+ {iso-a3 FALSE {6.35 290.65 6.35 413.35}}\
+ {iso-a4 FALSE {6.35 203.65 6.35 290.65}}\
+ {jis-b4 FALSE {6.35 251.65 6.35 367.65}}\
+ {jis-b5 FALSE {6.35 175.65 6.35 250.65}}\
+ {monarch-envelope FALSE {6.35 91.94 6.35 184.15}}\
+ {iso-designated-long FALSE {6.35 103.65 6.35 213.65}}\
+ {iso-c5 FALSE {6.35 155.65 6.35 222.65}}\
+ {na-number-10-envelope FALSE {6.35 98.45 6.35 234.95}}\
+ {hp-tabloid FALSE {6.35 273.05 6.35 425.45}}\
+ {ledger FALSE {6.35 273.05 6.35 425.45}}\
+ {b FALSE {6.35 273.05 6.35 425.45}}\
+ {hp-japanese-postcard FALSE {6 94 6 142 }}\
+ {hp-japanese-doublepostcard FALSE {6 142 6 194 }}\
+}
+*plexes-supported: simplex duplex
+*printer-model: "Hewlett-Packard LaserJet 4 Series"
+*printer-resolutions-supported: 300 600
+*xp-ddx-identifier: XP-PCL-MONO
+*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts
+*xp-embedded-formats-supported: { PCL 5 } { PostScript 2 }
+*xp-raw-formats-supported: { PCL 5 }
+*xp-setup-proviso: setup-optional
+# EOF.
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/Imakefile
new file mode 100644
index 000000000..c8c54cef4
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/Imakefile
@@ -0,0 +1,45 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+#if XpPostScriptDDX
+PS_MODELDIRS = \
+ PSdefault \
+ SPSPARC2 \
+ HPLJ4050-PS \
+ CANONC3200-PS \
+ PSspooldir
+
+#if HasGhostScript
+XCOMM Models for printers which need GhostScript for post-processing
+GS_MODELDIRS = \
+ GSdefault \
+ CANONBJ10E-GS \
+ PS2PDFspooldir-GS
+#endif /* HasGhostScript */
+#endif /* XpPostScriptDDX */
+
+#if XpColorPclDDX
+PCL_COLOR_MODELDIRS = \
+ HPDJ1600C
+#endif
+
+#if XpMonoPclDDX
+PCL_MONO_MODELDIRS = \
+ HPLJ4family
+#endif
+
+#if XpRasterDDX
+RASTER_MODELDIRS =
+#endif
+
+SUBDIRS = \
+ $(PS_MODELDIRS) \
+ $(GS_MODELDIRS) \
+ $(PCL_COLOR_MODELDIRS) \
+ $(PCL_MONO_MODELDIRS) \
+ $(RASTER_MODELDIRS)
+
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/Imakefile
new file mode 100644
index 000000000..14f9ee59f
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/Imakefile
@@ -0,0 +1,35 @@
+XCOMM $Xorg: Imakefile,v 1.1 2003/11/20 03:42:52 gisburn Exp $
+
+XPMODELNAME = PS2PDFspooldir-GS
+
+MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME)
+
+#if BuildGISWxprintglue || BuildGISWxprint
+XCOMM Hack for Solaris's native /usr/openwin/bin/Xprt which does not
+XCOMM understand the new %xpconfigdir% modelconfig variable
+XCOMM (this is only used for the GISWxprintglue package build;
+XCOMM the GISWxprint does not need it but using it avoids confusion
+XCOMM if someone uses GISWxprint to run both Solaris native Xprt and
+XCOMM our own binary side-by-side using the same config)
+all:: model-config.SolarisXprt
+
+model-config.SolarisXprt: model-config
+ nawk <model-config " { sub(\"%xpconfigdir%/C\", \"$(XPRINTDIR)/C\") ; print \$$0 } " >model-config.SolarisXprt
+
+clean::
+ $(RM) model-config.SolarisXprt
+
+InstallNamedNonExec(model-config.SolarisXprt,model-config,$(MODELDIR))
+#else
+InstallNonExecFile(model-config,$(MODELDIR))
+#endif /* BuildGISWxprintglue || BuildGISWxprint */
+
+InstallNamedProg(ps2pdf_spooltodir.sh,ps2pdf_spooltodir.sh,$(MODELDIR))
+
+# All printer models which use GhostScript for filtering should use the
+# printer-builtin fonts from the "GSdefault" printer model
+# (unless they employ more or other builtin fonts)
+install::
+ $(RM) $(DESTDIR)$(MODELDIR)/fonts
+ $(LN) ../GSdefault/fonts $(DESTDIR)$(MODELDIR)
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/model-config b/nx-X11/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/model-config
new file mode 100644
index 000000000..1d74b8676
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/model-config
@@ -0,0 +1,72 @@
+# $Xprint.org: PS2PDFspooldir-GS model-config,v 1.1 2003/11/20 03:48:04 gisburn Exp $
+# PostScript DDX model-config which converts jobs to PDF via GhostScript's "ps2pdf"
+# and then sends them to a spool dir instead to a print queue
+#
+# This model is basically a cut-down GSdefault model with a custom *xp-spooler-command
+#
+# DO NOT MODIFY THIS FILE!!
+#
+# If you want to make customisations for your printer create a copy
+# of this printer model.
+# Example (for creating a model config "MYCOMPANYlaserxx"):
+# 1. Create model config dir:
+# % mkdir MYCOMPANYlaserxx
+# 2. Link (or copy) the PMF (printer font metrics) for the
+# printer buildin fonts:
+# % ln -s PS2PDFspooldir-GS/fonts MYCOMPANYlaserxx/.
+# 3. Copy the model config file:
+# % cp PS2PDFspooldir-GS/model-config MYCOMPANYlaserxx/.
+# 4. Customize MYCOMPANYlaserxx/model-config to match your needs.
+#
+# Attributes supported for this printer model
+*content-orientations-supported: portrait landscape reverse-portrait reverse-landscape
+*descriptor: PDF job spool dir /tmp/Xprintjobs
+*document-formats-supported: {POSTSCRIPT 2}
+*input-trays-supported:
+*medium-source-sizes-supported: \
+{ '' \
+ {na-letter FALSE {6.35 209.55 6.35 273.05}}\
+ {na-legal FALSE {6.35 209.55 6.35 349.25}}\
+ {executive FALSE {6.35 177.80 6.35 260.35}}\
+ {ledger FALSE {6.35 273.05 6.35 425.45}}\
+ {quarto FALSE {6.35 209.55 6.35 268.732}}\
+ {iso-a3 FALSE {6.35 290.65 6.35 413.65}}\
+ {iso-a4 FALSE {6.35 203.65 6.35 290.65}}\
+ {iso-a5 FALSE {6.35 141.65 6.35 203.65}}\
+ {iso-b3 FALSE {6.35 346.65 6.35 493.65}}\
+ {iso-b4 FALSE {6.35 243.65 6.35 346.65}}\
+ {iso-b5 FALSE {6.35 169.65 6.35 243.65}}\
+ {jis-b3 FALSE {6.35 357.65 6.35 508.65}}\
+ {jis-b4 FALSE {6.35 250.65 6.35 357.65}}\
+ {jis-b5 FALSE {6.35 175.65 6.35 250.65}}\
+ {iso-c3 FALSE {6.35 317.65 6.35 451.65}}\
+ {iso-c4 FALSE {6.35 222.65 6.35 317.65}}\
+ {iso-c5 FALSE {6.35 155.65 6.35 222.65}}\
+}
+
+*plexes-supported: simplex duplex tumble
+*printer-model: "PDF job spool dir /tmp/Xprintjobs"
+# 75, 100, 120, 150, 180, 200, 240, 300, 360, 400, 600, 720,
+# 940, 1200 and 2440 are supported DPI values, we limit it here
+# to some common values:
+*printer-resolutions-supported: 300 360 400 600
+*xp-ddx-identifier: XP-POSTSCRIPT
+*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts
+*xp-embedded-formats-supported: {POSTSCRIPT 2}
+*xp-raw-formats-supported: {POSTSCRIPT 2}
+*xp-setup-proviso: setup-optional
+
+# Use custom spooler script which sends the output to a dir instead to a printer queue
+# Note that "%xpconfigdir%" is currently only supported in Xprt servers build
+# from xprint.mozdev.org sources, other platforms have replace it with the
+# absolute path name to the script
+*xp-spooler-command: %xpconfigdir%/C/print/models/PS2PDFspooldir-GS/ps2pdf_spooltodir.sh -d /tmp/Xprintjobs -s .pdf -u 077 -p %printer-name% -c %copy-count% -t %job-name% -o "%options%"
+
+# NOTE: xp-psddx-* attributes are EXPERIMENTAL for now.
+# xp-psddx-download-fonts defines which fonts should be downloaded as outlines
+# (valid types are "pfa", "pfb", "ttf", "ttc", "otf", "otc")
+*xp-psddx-download-fonts: pfa pfb ttf ttc otf otc
+# xp-psddx-download-font-type defines which font type is used to download outlines
+# (valid values are "bitmap", "pstype1" and "pstype3")
+*xp-psddx-download-font-type: pstype1
+# EOF.
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/ps2pdf_spooltodir.sh b/nx-X11/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/ps2pdf_spooltodir.sh
new file mode 100755
index 000000000..5739807d8
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/ps2pdf_spooltodir.sh
@@ -0,0 +1,130 @@
+#!/bin/sh
+PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin
+export PATH
+
+verbose_msgs="false"
+DEFAULT_SPOOLDIR=/tmp/Xprintjobs
+
+usage()
+{
+ printf "Usage: ${0}: [options]\n"
+ printf "-v\tbe verbose\n"
+ printf "-d dirname\tdefine spool dir\n"
+ printf "-p string\tname of printer selected by user\n"
+ printf "-c integer\tnumber of copies\n"
+ printf "-t string\tjob title\n"
+ printf "-s string\tfile name suffix\n"
+ printf "-o string\tspooler options\n"
+ printf "-u mask\tpermission mask for new files (see umask)\n"
+ exit 2
+}
+
+verbose()
+{
+ if ${verbose_msgs} ; then
+ echo "$1"
+ fi
+}
+
+spooldir="${DEFAULT_SPOOLDIR}"
+printername=
+num_job_copies=
+job_title=
+filename_suffix=
+spooler_options=
+permmask=
+while getopts va:b:d:p:c:t:s:o:u: i
+do
+ case $i in
+ v)
+ verbose_msgs="true"
+ ;;
+ d)
+ spooldir="$OPTARG"
+ ;;
+ p)
+ printername="$OPTARG"
+ ;;
+ c)
+ num_job_copies="$OPTARG"
+ ;;
+ t)
+ job_title="$OPTARG"
+ ;;
+ s)
+ filename_suffix="$OPTARG"
+ ;;
+ o)
+ spooler_options="$OPTARG"
+ ;;
+ u)
+ permmask="$OPTARG"
+ ;;
+ ?) usage
+ ;;
+ esac
+done
+
+verbose "# spooldir=\"$spooldir\""
+verbose "# printername=\"$printername\""
+verbose "# num_job_copies=\"$num_job_copies\""
+verbose "# job_title=\"$job_title\""
+verbose "# spooler_options=\"$spooler_options\""
+verbose "# umask=\"$permmask\""
+
+if [ ! -d "${DEFAULT_SPOOLDIR}" ] ; then
+ mkdir "${DEFAULT_SPOOLDIR}"
+ chmod a+rwxt "${DEFAULT_SPOOLDIR}"
+fi
+
+if [ "${permmask}" != "" ] ; then
+ umask ${permmask}
+fi
+
+if [ ! -d "$spooldir" ] ; then
+ echo "$0: spooldir \"$spooldir\" does not exits." >&2
+ exit 1
+fi
+if [ ! -w "$spooldir" ] ; then
+ echo "$0: Cannot write to spooldir \"$spooldir\"." >&2
+ exit 1
+fi
+
+# Create first part of the output file name (prefix and an "unique"
+# id(=date and time))...
+filename="Xpjob_`date +%Y%m%d%H%M%S`"
+
+# ... then add options ...
+if [ "${printername}" != "" ] ; then
+ filename="${filename}_${printername}"
+fi
+if [ "${num_job_copies}" != "" -a "${num_job_copies}" != "1" ] ; then
+ filename="${filename}_copies_${num_job_copies}"
+fi
+if [ "${job_title}" != "" ] ; then
+ filename="${filename}_title_${job_title}"
+fi
+
+# ... mangle output file name and filter chars (like whitespaces)
+# which may screw-up further processing by other shell scripts ...
+filename="`echo \"${filename}\" | tr '[:blank:]' '_' | tr -c -d '[:alnum:]_.-'`"
+
+# ... add path and suffix ...
+filename="${spooldir}/${filename}${filename_suffix}"
+
+verbose "# File name is \"$filename\"."
+
+# ... and finally capture stdin to the file (we are using "gs" directly to
+# avoid the problem that "ps2pdf" is not available in all Linux
+# distributions by default).
+#ps2pdf - - | cat >"${filename}"
+gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite "-sOutputFile=-" -dCompatibilityLevel=1.2 -c .setpdfwrite -f - | cat >"${filename}"
+
+if ${verbose_msgs} ; then
+ printf "# File is " ; ls -l "${filename}"
+fi
+
+verbose "# Done."
+
+exit 0
+# EOF.
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/Imakefile
new file mode 100644
index 000000000..c2442f32d
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/Imakefile
@@ -0,0 +1,14 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+SUBDIRS = fonts
+
+XPMODELNAME = PSdefault
+
+MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME)
+
+InstallNonExecFile(model-config,$(MODELDIR))
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Book.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Book.pmf
new file mode 100644
index 000000000..331178985
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Book.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-BookOblique.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-BookOblique.pmf
new file mode 100644
index 000000000..61bcb22b9
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-BookOblique.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Demi.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Demi.pmf
new file mode 100644
index 000000000..88ccf0834
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Demi.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-DemiOblique.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-DemiOblique.pmf
new file mode 100644
index 000000000..45cc8857b
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-DemiOblique.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Bold.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Bold.pmf
new file mode 100644
index 000000000..ac760fdb9
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Bold.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-BoldOblique.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-BoldOblique.pmf
new file mode 100644
index 000000000..8db974018
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-BoldOblique.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Oblique.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Oblique.pmf
new file mode 100644
index 000000000..87aee16cc
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Oblique.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier.pmf
new file mode 100644
index 000000000..6109c8c11
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Bold.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Bold.pmf
new file mode 100644
index 000000000..30d462d95
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Bold.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-BoldOblique.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-BoldOblique.pmf
new file mode 100644
index 000000000..89619516f
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-BoldOblique.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Oblique.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Oblique.pmf
new file mode 100644
index 000000000..2a0de8afc
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Oblique.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica.pmf
new file mode 100644
index 000000000..b1fd475bb
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Imakefile
new file mode 100644
index 000000000..9a51ed099
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Imakefile
@@ -0,0 +1,41 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $
+
+XPFONTS = \
+ AvantGarde-Book.pmf \
+ AvantGarde-BookOblique.pmf \
+ AvantGarde-Demi.pmf \
+ AvantGarde-DemiOblique.pmf \
+ Courier-Bold.pmf \
+ Courier-BoldOblique.pmf \
+ Courier-Oblique.pmf \
+ Courier.pmf \
+ Helvetica-Bold.pmf \
+ Helvetica-BoldOblique.pmf \
+ Helvetica-Oblique.pmf \
+ Helvetica.pmf \
+ LubalinGraph-Book.pmf \
+ LubalinGraph-BookOblique.pmf \
+ LubalinGraph-Demi.pmf \
+ LubalinGraph-DemiOblique.pmf \
+ NewCenturySchlbk-Bold.pmf \
+ NewCenturySchlbk-BoldItalic.pmf \
+ NewCenturySchlbk-Italic.pmf \
+ NewCenturySchlbk-Roman.pmf \
+ Souvenir-Demi.pmf \
+ Souvenir-DemiItalic.pmf \
+ Souvenir-Light.pmf \
+ Souvenir-LightItalic.pmf \
+ Symbol.pmf \
+ Times-Bold.pmf \
+ Times-BoldItalic.pmf \
+ Times-Italic.pmf \
+ Times-Roman.pmf \
+ ZapfDingbats.pmf
+
+XPMODELNAME = PSdefault
+
+MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME)
+MODELFONTDIR = $(MODELDIR)/fonts
+InstallMultipleDest(install,$(XPFONTS),$(MODELFONTDIR))
+InstallXpPMFFontsDir($(MODELFONTDIR))
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Book.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Book.pmf
new file mode 100644
index 000000000..aff4b4949
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Book.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-BookOblique.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-BookOblique.pmf
new file mode 100644
index 000000000..b5b77f353
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-BookOblique.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Demi.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Demi.pmf
new file mode 100644
index 000000000..100339854
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Demi.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-DemiOblique.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-DemiOblique.pmf
new file mode 100644
index 000000000..a8550e70d
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-DemiOblique.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Bold.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Bold.pmf
new file mode 100644
index 000000000..ab22aabf5
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Bold.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-BoldItalic.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-BoldItalic.pmf
new file mode 100644
index 000000000..e68811eb7
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-BoldItalic.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Italic.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Italic.pmf
new file mode 100644
index 000000000..390f223cb
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Italic.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Roman.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Roman.pmf
new file mode 100644
index 000000000..655b9b6c0
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Roman.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Demi.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Demi.pmf
new file mode 100644
index 000000000..5e786ec42
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Demi.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-DemiItalic.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-DemiItalic.pmf
new file mode 100644
index 000000000..094b348cc
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-DemiItalic.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Light.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Light.pmf
new file mode 100644
index 000000000..0bb62bde6
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Light.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-LightItalic.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-LightItalic.pmf
new file mode 100644
index 000000000..3c19a7fbf
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-LightItalic.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Symbol.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Symbol.pmf
new file mode 100644
index 000000000..48925f816
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Symbol.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Bold.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Bold.pmf
new file mode 100644
index 000000000..cf46ca03f
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Bold.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-BoldItalic.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-BoldItalic.pmf
new file mode 100644
index 000000000..ffe51af80
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-BoldItalic.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Italic.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Italic.pmf
new file mode 100644
index 000000000..865433f83
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Italic.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Roman.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Roman.pmf
new file mode 100644
index 000000000..625e0c43f
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Roman.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/ZapfDingbats.pmf b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/ZapfDingbats.pmf
new file mode 100644
index 000000000..1ae9a7688
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/ZapfDingbats.pmf
Binary files differ
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/model-config b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/model-config
new file mode 100644
index 000000000..05a19d859
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/model-config
@@ -0,0 +1,136 @@
+# $Xprint.org: PSdefault model-config,v 1.2 2002/11/07 19:48:04 gisburn Exp $
+# Generic default model-config for the PostScript DDX
+#
+# DO NOT MODIFY THIS FILE!!
+#
+# If you want to make customisations for your printer create a copy
+# of this printer model.
+# Example (for creating a model config "MYCOMPANYlaserxx"):
+# 1. Create model config dir:
+# % mkdir MYCOMPANYlaserxx
+# 2. Link (or copy) the PMF (printer font metrics) for the
+# printer buildin fonts:
+# % ln -s PSdefault/fonts MYCOMPANYlaserxx/.
+# 3. Copy the model config file:
+# % cp PSdefault/model-config MYCOMPANYlaserxx/.
+# 4. Customize MYCOMPANYlaserxx/model-config to match your needs.
+#
+
+# Attributes supported for this printer model
+# You may want to cut the lists here down to the attributes supported
+# by your printer.
+*content-orientations-supported: portrait landscape reverse-portrait reverse-landscape
+*descriptor: PostScript default model
+*document-formats-supported: {POSTSCRIPT 2}
+*input-trays-supported:
+*medium-source-sizes-supported: \
+{ '' \
+ {na-letter FALSE {6.35 209.55 6.35 273.05}}\
+ {na-legal FALSE {6.35 209.55 6.35 349.25}}\
+ {executive FALSE {6.35 177.80 6.35 260.35}}\
+ {folio FALSE {6.35 204.47 6.35 323.85}}\
+ {invoice FALSE {6.35 133.35 6.35 209.55}}\
+ {ledger FALSE {6.35 273.05 6.35 425.45}}\
+ {quarto FALSE {6.35 209.55 6.35 268.732}}\
+ {a FALSE {6.35 209.55 6.35 273.05}}\
+ {b FALSE {6.35 273.05 6.35 425.45}}\
+ {c FALSE {6.35 425.45 6.35 552.45}}\
+ {d FALSE {6.35 552.45 6.35 857.25}}\
+ {e FALSE {6.35 857.25 6.35 1111.25}}\
+ {na-6x9-envelope FALSE {6.35 146.05 6.35 222.25}}\
+ {na-10x15-envelope FALSE {6.35 247.65 6.35 374.65}}\
+ {monarch-envelope FALSE {6.35 91.948 6.35 184.15}}\
+ {na-10x13-envelope FALSE {6.35 247.65 6.35 323.85}}\
+ {na-9x12-envelope FALSE {6.35 222.25 6.35 298.45}}\
+ {na-number-10-envelope FALSE {6.35 98.425 6.35 234.95}}\
+ {na-7x9-envelope FALSE {6.35 171.45 6.35 222.25}}\
+ {na-9x11-envelope FALSE {6.35 222.25 6.35 273.05}}\
+ {na-10x14-envelope FALSE {6.35 247.65 6.35 349.25}}\
+ {na-number-9-envelope FALSE {6.35 92.075 6.35 219.075}}\
+ {iso-a0 FALSE {6.35 834.65 6.35 1182.65}}\
+ {iso-a1 FALSE {6.35 587.65 6.35 834.65}}\
+ {iso-a2 FALSE {6.35 413.65 6.35 587.65}}\
+ {iso-a3 FALSE {6.35 290.65 6.35 413.65}}\
+ {iso-a4 FALSE {6.35 203.65 6.35 290.65}}\
+ {iso-a5 FALSE {6.35 141.65 6.35 203.65}}\
+ {iso-a6 FALSE {6.35 98.65 6.35 141.65}}\
+ {iso-a7 FALSE {6.35 67.65 6.35 98.65}}\
+ {iso-a8 FALSE {6.35 45.65 6.35 67.65}}\
+ {iso-a9 FALSE {6.35 30.65 6.35 45.65}}\
+ {iso-a10 FALSE {6.35 19.65 6.35 30.65}}\
+ {iso-b1 FALSE {6.35 700.65 6.35 993.65}}\
+ {iso-b2 FALSE {6.35 493.65 6.35 700.65}}\
+ {iso-b3 FALSE {6.35 346.65 6.35 493.65}}\
+ {iso-b4 FALSE {6.35 243.65 6.35 346.65}}\
+ {iso-b5 FALSE {6.35 169.65 6.35 243.65}}\
+ {iso-b6 FALSE {6.35 118.65 6.35 169.65}}\
+ {iso-b7 FALSE {6.35 81.65 6.35 118.65}}\
+ {iso-b8 FALSE {6.35 55.65 6.35 81.65}}\
+ {iso-b9 FALSE {6.35 37.65 6.35 55.65}}\
+ {iso-b10 FALSE {6.35 24.65 6.35 37.65}}\
+ {jis-b1 FALSE {6.35 721.65 6.35 1023.65}}\
+ {jis-b2 FALSE {6.35 508.65 6.35 721.65}}\
+ {jis-b3 FALSE {6.35 357.65 6.35 508.65}}\
+ {jis-b4 FALSE {6.35 250.65 6.35 357.65}}\
+ {jis-b5 FALSE {6.35 175.65 6.35 250.65}}\
+ {jis-b6 FALSE {6.35 121.65 6.35 175.65}}\
+ {jis-b7 FALSE {6.35 84.65 6.35 121.65}}\
+ {jis-b8 FALSE {6.35 57.65 6.35 84.65}}\
+ {jis-b9 FALSE {6.35 38.65 6.35 57.65}}\
+ {jis-b10 FALSE {6.35 25.65 6.35 38.65}}\
+ {iso-c3 FALSE {6.35 317.65 6.35 451.65}}\
+ {iso-c4 FALSE {6.35 222.65 6.35 317.65}}\
+ {iso-c5 FALSE {6.35 155.65 6.35 222.65}}\
+ {iso-c6 FALSE {6.35 107.65 6.35 155.65}}\
+ {iso-designated-long FALSE {6.35 103.65 6.35 213.65}}\
+ {hp-2x-postcard FALSE {6.35 141.65 6.35 193.65}}\
+ {hp-european-edp FALSE {6.35 298.45 6.35 349.25}}\
+ {hp-mini FALSE {6.35 133.35 6.35 209.55}}\
+ {hp-postcard FALSE {6.35 93.65 6.35 141.65}}\
+ {hp-tabloid FALSE {6.35 273.05 6.35 425.45}}\
+ {hp-us-edp FALSE {6.35 273.05 6.35 349.25}}\
+ {hp-us-government-legal FALSE {6.35 196.85 6.35 323.85}}\
+ {hp-us-government-letter FALSE {6.35 196.85 6.35 247.65}}\
+}
+# If you have more than one tray use the following example:
+# 1. List the supported trays
+#*input-trays-supported: main manual
+# 2. Define each tray and it's paper sizes
+#*medium-source-sizes-supported: \
+#{ main \
+# {na-letter FALSE {6.35 209.55 6.35 273.05}} \
+# {na-legal FALSE {6.35 209.55 6.35 349.25}} \
+# {iso-a4 FALSE {6.35 203.65 6.35 290.65}} \
+#} \
+#{ manual \
+# {iso-a5 FALSE {6.35 141.65 6.35 203.65}} \
+# {iso-c5 FALSE {6.35 155.65 6.35 222.65}} \
+# {iso-designated-long FALSE {6.35 103.65 6.35 213.65}} \
+# {jis-b5 FALSE {6.35 175.65 6.35 250.65}} \
+# {monarch-envelope FALSE {6.35 91.948 6.35 184.15}} \
+# {na-legal FALSE {6.35 209.55 6.35 349.25}} \
+# {na-number-10-envelope FALSE {6.35 98.425 6.35 234.95}} \
+# {executive FALSE {6.35 177.8 6.35 260.35}} \
+# {iso-a3 FALSE {6.35 290.65 6.35 413.65}} \
+# {iso-a0 FALSE {6.35 834.65 6.35 1182.65}} \
+#}
+*plexes-supported: simplex duplex tumble
+*printer-model: "PostScript default model"
+# 75, 100, 120, 150, 180, 200, 240, 300, 360, 400, 600, 720,
+# 940, 1200 and 2440 are supported DPI values, we limit it here
+# to some common values:
+*printer-resolutions-supported: 300 360 400 600
+*xp-ddx-identifier: XP-POSTSCRIPT
+*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts
+*xp-embedded-formats-supported: {POSTSCRIPT 2}
+*xp-raw-formats-supported: {POSTSCRIPT 2}
+*xp-setup-proviso: setup-optional
+
+# NOTE: xp-psddx-* attributes are EXPERIMENTAL for now.
+# xp-psddx-download-fonts defines which fonts should be downloaded as outlines
+# (valid types are "pfa", "pfb", "ttf", "ttc", "otf", "otc")
+*xp-psddx-download-fonts: pfa pfb ttf ttc otf otc
+# xp-psddx-download-font-type defines which font type is used to download outlines
+# (valid values are "bitmap", "pstype1" and "pstype3")
+*xp-psddx-download-font-type: pstype1
+# EOF.
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSspooldir/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSspooldir/Imakefile
new file mode 100644
index 000000000..65f602f7f
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSspooldir/Imakefile
@@ -0,0 +1,34 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $
+
+XPMODELNAME = PSspooldir
+
+MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME)
+
+#if BuildGISWxprintglue || BuildGISWxprint
+XCOMM Hack for Solaris's native /usr/openwin/bin/Xprt which does not
+XCOMM understand the new %xpconfigdir% modelconfig variable
+XCOMM (this is only used for the GISWxprintglue package build;
+XCOMM the GISWxprint does not need it but using it avoids confusion
+XCOMM if someone uses GISWxprint to run both Solaris native Xprt and
+XCOMM our own binary side-by-side using the same config)
+all:: model-config.SolarisXprt
+
+model-config.SolarisXprt: model-config
+ nawk <model-config " { sub(\"%xpconfigdir%/C\", \"$(XPRINTDIR)/C\") ; print \$$0 } " >model-config.SolarisXprt
+
+clean::
+ $(RM) model-config.SolarisXprt
+
+InstallNamedNonExec(model-config.SolarisXprt,model-config,$(MODELDIR))
+#else
+InstallNonExecFile(model-config,$(MODELDIR))
+#endif /* BuildGISWxprintglue || BuildGISWxprint */
+
+InstallNamedProg(spooltodir.sh,spooltodir.sh,$(MODELDIR))
+
+# All PostScript-printer models should use the printer-builtin fonts from the
+# "PSdefault" printer model (unless they employ more or other builtin fonts)
+install::
+ $(RM) $(DESTDIR)$(MODELDIR)/fonts
+ $(LN) ../PSdefault/fonts $(DESTDIR)$(MODELDIR)
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSspooldir/model-config b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSspooldir/model-config
new file mode 100644
index 000000000..6bb477767
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSspooldir/model-config
@@ -0,0 +1,71 @@
+# $Xprint.org: PSspooldir model-config,v 1.1 2002/11/25 19:48:04 gisburn Exp $
+# PostScript DDX model-config which sends jobs to a spool dir instead to a print queue
+#
+# This model is basically a cut-down PSdefault model with a custom *xp-spooler-command
+#
+# DO NOT MODIFY THIS FILE!!
+#
+# If you want to make customisations for your printer create a copy
+# of this printer model.
+# Example (for creating a model config "MYCOMPANYlaserxx"):
+# 1. Create model config dir:
+# % mkdir MYCOMPANYlaserxx
+# 2. Link (or copy) the PMF (printer font metrics) for the
+# printer buildin fonts:
+# % ln -s PSspooldir/fonts MYCOMPANYlaserxx/.
+# 3. Copy the model config file:
+# % cp PSspooldir/model-config MYCOMPANYlaserxx/.
+# 4. Customize MYCOMPANYlaserxx/model-config to match your needs.
+#
+# Attributes supported for this printer model
+*content-orientations-supported: portrait landscape reverse-portrait reverse-landscape
+*descriptor: PostScript job spool dir /tmp/Xprintjobs
+*document-formats-supported: {POSTSCRIPT 2}
+*input-trays-supported:
+*medium-source-sizes-supported: \
+{ '' \
+ {na-letter FALSE {6.35 209.55 6.35 273.05}}\
+ {na-legal FALSE {6.35 209.55 6.35 349.25}}\
+ {executive FALSE {6.35 177.80 6.35 260.35}}\
+ {ledger FALSE {6.35 273.05 6.35 425.45}}\
+ {quarto FALSE {6.35 209.55 6.35 268.732}}\
+ {iso-a3 FALSE {6.35 290.65 6.35 413.65}}\
+ {iso-a4 FALSE {6.35 203.65 6.35 290.65}}\
+ {iso-a5 FALSE {6.35 141.65 6.35 203.65}}\
+ {iso-b3 FALSE {6.35 346.65 6.35 493.65}}\
+ {iso-b4 FALSE {6.35 243.65 6.35 346.65}}\
+ {iso-b5 FALSE {6.35 169.65 6.35 243.65}}\
+ {jis-b3 FALSE {6.35 357.65 6.35 508.65}}\
+ {jis-b4 FALSE {6.35 250.65 6.35 357.65}}\
+ {jis-b5 FALSE {6.35 175.65 6.35 250.65}}\
+ {iso-c3 FALSE {6.35 317.65 6.35 451.65}}\
+ {iso-c4 FALSE {6.35 222.65 6.35 317.65}}\
+ {iso-c5 FALSE {6.35 155.65 6.35 222.65}}\
+}
+
+*plexes-supported: simplex duplex tumble
+*printer-model: "PostScript job spool dir /tmp/Xprintjobs"
+# 75, 100, 120, 150, 180, 200, 240, 300, 360, 400, 600, 720,
+# 940, 1200 and 2440 are supported DPI values, we limit it here
+# to some common values:
+*printer-resolutions-supported: 300 360 400 600
+*xp-ddx-identifier: XP-POSTSCRIPT
+*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts
+*xp-embedded-formats-supported: {POSTSCRIPT 2}
+*xp-raw-formats-supported: {POSTSCRIPT 2}
+*xp-setup-proviso: setup-optional
+
+# Use custom spooler script which sends the output to a dir instead to a printer queue
+# Note that "%xpconfigdir%" is currently only supported in Xprt servers build
+# from xprint.mozdev.org sources, other platforms have replace it with the
+# absolute path name to the script
+*xp-spooler-command: %xpconfigdir%/C/print/models/PSspooldir/spooltodir.sh -d /tmp/Xprintjobs -s .ps -u 077 -p %printer-name% -c %copy-count% -t %job-name% -o "%options%"
+
+# NOTE: xp-psddx-* attributes are EXPERIMENTAL for now.
+# xp-psddx-download-fonts defines which fonts should be downloaded as outlines
+# (valid types are "pfa", "pfb", "ttf", "ttc", "otf", "otc")
+*xp-psddx-download-fonts: pfa pfb ttf ttc otf otc
+# xp-psddx-download-font-type defines which font type is used to download outlines
+# (valid values are "bitmap", "pstype1" and "pstype3")
+*xp-psddx-download-font-type: pstype1
+# EOF.
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/PSspooldir/spooltodir.sh b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSspooldir/spooltodir.sh
new file mode 100755
index 000000000..aba14e1b3
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSspooldir/spooltodir.sh
@@ -0,0 +1,127 @@
+#!/bin/sh
+PATH=/usr/bin:/usr/sbin:/bin:/sbin
+export PATH
+
+verbose_msgs="false"
+DEFAULT_SPOOLDIR=/tmp/Xprintjobs
+
+usage()
+{
+ printf "Usage: ${0}: [options]\n"
+ printf "-v\tbe verbose\n"
+ printf "-d dirname\tdefine spool dir\n"
+ printf "-p string\tname of printer selected by user\n"
+ printf "-c integer\tnumber of copies\n"
+ printf "-t string\tjob title\n"
+ printf "-s string\tfile name suffix\n"
+ printf "-o string\tspooler options\n"
+ printf "-u mask\tpermission mask for new files (see umask)\n"
+ exit 2
+}
+
+verbose()
+{
+ if ${verbose_msgs} ; then
+ echo "$1"
+ fi
+}
+
+spooldir="${DEFAULT_SPOOLDIR}"
+printername=
+num_job_copies=
+job_title=
+filename_suffix=
+spooler_options=
+permmask=
+while getopts va:b:d:p:c:t:s:o:u: i
+do
+ case $i in
+ v)
+ verbose_msgs="true"
+ ;;
+ d)
+ spooldir="$OPTARG"
+ ;;
+ p)
+ printername="$OPTARG"
+ ;;
+ c)
+ num_job_copies="$OPTARG"
+ ;;
+ t)
+ job_title="$OPTARG"
+ ;;
+ s)
+ filename_suffix="$OPTARG"
+ ;;
+ o)
+ spooler_options="$OPTARG"
+ ;;
+ u)
+ permmask="$OPTARG"
+ ;;
+ ?) usage
+ ;;
+ esac
+done
+
+verbose "# spooldir=\"$spooldir\""
+verbose "# printername=\"$printername\""
+verbose "# num_job_copies=\"$num_job_copies\""
+verbose "# job_title=\"$job_title\""
+verbose "# spooler_options=\"$spooler_options\""
+verbose "# umask=\"$permmask\""
+
+if [ ! -d "${DEFAULT_SPOOLDIR}" ] ; then
+ mkdir "${DEFAULT_SPOOLDIR}"
+ chmod a+rwxt "${DEFAULT_SPOOLDIR}"
+fi
+
+if [ "${permmask}" != "" ] ; then
+ umask ${permmask}
+fi
+
+if [ ! -d "$spooldir" ] ; then
+ echo "$0: spooldir \"$spooldir\" does not exits." >&2
+ exit 1
+fi
+if [ ! -w "$spooldir" ] ; then
+ echo "$0: Cannot write to spooldir \"$spooldir\"." >&2
+ exit 1
+fi
+
+# Create first part of the output file name (prefix and an "unique"
+# id(=date and time))...
+filename="Xpjob_`date +%Y%m%d%H%M%S`"
+
+# ... then add options ...
+if [ "${printername}" != "" ] ; then
+ filename="${filename}_${printername}"
+fi
+if [ "${num_job_copies}" != "" -a "${num_job_copies}" != "1" ] ; then
+ filename="${filename}_copies_${num_job_copies}"
+fi
+if [ "${job_title}" != "" ] ; then
+ filename="${filename}_title_${job_title}"
+fi
+
+# ... mangle output file name and filter chars (like whitespaces)
+# which may screw-up further processing by other shell scripts ...
+filename="`echo \"${filename}\" | tr '[:blank:]' '_' | tr -c -d '[:alnum:]_.-'`"
+
+# ... add path and suffix ...
+filename="${spooldir}/${filename}${filename_suffix}"
+
+verbose "# File name is \"$filename\"."
+
+# ... and finally capture stdin to the file.
+cat >"${filename}"
+
+if ${verbose_msgs} ; then
+ printf "# File is " ; ls -l "${filename}"
+fi
+
+verbose "# Done."
+
+exit 0
+# EOF.
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/SPSPARC2/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/SPSPARC2/Imakefile
new file mode 100644
index 000000000..750fc2fb2
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/SPSPARC2/Imakefile
@@ -0,0 +1,15 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+SUBDIRS = fonts
+
+XPMODELNAME = SPSPARC2
+
+MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME)
+
+InstallNonExecFile(model-config,$(MODELDIR))
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Imakefile b/nx-X11/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Imakefile
new file mode 100644
index 000000000..649dd56b6
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Imakefile
@@ -0,0 +1,28 @@
+XCOMM $Xorg: Imakefile,v 1.1 2003/10/22 02:42:52 gisburn Exp $
+
+XPFONTS = \
+ Courier-Bold.pmf \
+ Courier-BoldOblique.pmf \
+ Courier-Oblique.pmf \
+ Courier.pmf \
+ Helvetica-Bold.pmf \
+ Helvetica-BoldOblique.pmf \
+ Helvetica-Oblique.pmf \
+ Helvetica.pmf \
+ Symbol.pmf \
+ Times-Bold.pmf \
+ Times-BoldItalic.pmf \
+ Times-Italic.pmf \
+ Times-Roman.pmf
+
+XPMODELNAME = SPSPARC2
+
+MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME)
+MODELFONTDIR = $(MODELDIR)/fonts
+
+# We reuse some of the PSdefault fonts
+PARENTMODELFONTDIR=../../PSdefault/fonts
+
+InstallXpMultiplePMFLinks($(XPFONTS),$(PARENTMODELFONTDIR),$(MODELFONTDIR))
+InstallXpPMFFontsDir($(MODELFONTDIR))
+
diff --git a/nx-X11/programs/Xserver/XpConfig/C/print/models/SPSPARC2/model-config b/nx-X11/programs/Xserver/XpConfig/C/print/models/SPSPARC2/model-config
new file mode 100644
index 000000000..9f29b9992
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/C/print/models/SPSPARC2/model-config
@@ -0,0 +1,18 @@
+# $Xprint.org: SPSPARC2 model-config,v 1.4 2002/11/07 19:48:04 gisburn Exp $
+*content-orientations-supported: portrait landscape
+*descriptor: SunPics SPARCprinter II
+*document-formats-supported: {POSTSCRIPT 2}
+*input-trays-supported:
+*medium-source-sizes-supported: \
+ { '' {na-letter FALSE {6.35 209.55 6.35 273.05}} \
+ {na-legal FALSE {6.35 209.55 6.35 349.25}} \
+ {iso-a4 FALSE {6.35 203.65 6.35 290.65}}}
+*plexes-supported: simplex
+*printer-model: "SunPics SPARCprinter II"
+*printer-resolutions-supported: 300
+*xp-ddx-identifier: XP-POSTSCRIPT
+*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts
+*xp-embedded-formats-supported: {POSTSCRIPT 2}
+*xp-raw-formats-supported: {POSTSCRIPT 2}
+*xp-setup-proviso: setup-optional
+# EOF.
diff --git a/nx-X11/programs/Xserver/XpConfig/Imakefile b/nx-X11/programs/Xserver/XpConfig/Imakefile
new file mode 100644
index 000000000..9ee5d42e8
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/Imakefile
@@ -0,0 +1,761 @@
+XCOMM $Xorg: Imakefile,v 1.3 2003/12/12 03:42:52 gisburn Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+SUBDIRS = \
+ C \
+ en_US
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+
+InstallNonExecFile(README,$(XPRINTDIR)/)
+
+## Locale mappings
+## Notes:
+## - only ASCII chars are allowed
+## - "C" and "en_US" should not be used, they are real directories
+
+# List of locales which should be linked to the "C" locale
+C_LOCALES= \
+ POSIX \
+ af \
+ af_ZA \
+ af_ZA.iso88591 \
+ af_ZA.utf8 \
+ afrikaans \
+ ar \
+ ar_AE \
+ ar_AE.iso88596 \
+ ar_AE.utf8 \
+ ar_BH \
+ ar_BH.iso88596 \
+ ar_BH.utf8 \
+ ar_DZ \
+ ar_DZ.iso88596 \
+ ar_DZ.utf8 \
+ ar_EG \
+ ar_EG.ISO8859-6 \
+ ar_EG.UTF-8 \
+ ar_EG.iso88596 \
+ ar_EG.utf8 \
+ ar_IN.utf8 \
+ ar_IQ \
+ ar_IQ.iso88596 \
+ ar_IQ.utf8 \
+ ar_JO \
+ ar_JO.iso88596 \
+ ar_JO.utf8 \
+ ar_KW \
+ ar_KW.iso88596 \
+ ar_KW.utf8 \
+ ar_LB \
+ ar_LB.iso88596 \
+ ar_LB.utf8 \
+ ar_LY \
+ ar_LY.iso88596 \
+ ar_LY.utf8 \
+ ar_MA \
+ ar_MA.iso88596 \
+ ar_MA.utf8 \
+ ar_OM \
+ ar_OM.iso88596 \
+ ar_OM.utf8 \
+ ar_QA \
+ ar_QA.iso88596 \
+ ar_QA.utf8 \
+ ar_SA \
+ ar_SA.iso88596 \
+ ar_SA.utf8 \
+ ar_SD \
+ ar_SD.iso88596 \
+ ar_SD.utf8 \
+ ar_SY \
+ ar_SY.iso88596 \
+ ar_SY.utf8 \
+ ar_TN \
+ ar_TN.iso88596 \
+ ar_TN.utf8 \
+ ar_YE \
+ ar_YE.iso88596 \
+ ar_YE.utf8 \
+ be_BY \
+ be_BY.cp1251 \
+ be_BY.utf8 \
+ bg_BG \
+ bg_BG.ISO8859-5 \
+ bg_BG.cp1251 \
+ bg_BG.utf8 \
+ bn_IN.UTF-8 \
+ bn_IN.utf8 \
+ br_FR \
+ br_FR.iso88591 \
+ bs \
+ bs_BA \
+ bs_BA.iso88592 \
+ bs_BA.ISO8859-2 \
+ bs_BA.ISO-8859-2 \
+ bs_BA.ISO_8859-2 \
+ bs_BA.UTF-8 \
+ bokmal \
+ ca \
+ ca.ISO8859-1 \
+ ca.ISO8859-15 \
+ ca_ES \
+ ca_ES.ISO8859-1 \
+ ca_ES.ISO8859-15 \
+ ca_ES.iso88591 \
+ ca_ES.iso885915@euro \
+ ca_ES.utf8 \
+ ca_ES@euro \
+ catalan \
+ croatian \
+ cs_CZ \
+ cs_CZ.ISO8859-2 \
+ cs_CZ.iso88592 \
+ cs_CZ.utf8 \
+ cy_GB \
+ cy_GB.iso885914 \
+ cz \
+ cz.ISO8859-2 \
+ czech \
+ da \
+ da.ISO8859-1 \
+ da.ISO8859-15 \
+ danish \
+ dansk \
+ da_DK \
+ da_DK.ISO8859-1 \
+ da_DK.ISO8859-15 \
+ da_DK.iso88591 \
+ da_DK.iso885915 \
+ da_DK.utf8 \
+ de \
+ de.ISO8859-1 \
+ de.ISO8859-15 \
+ de.UTF-8 \
+ deutsch \
+ de_AT \
+ de_AT.ISO8859-1 \
+ de_AT.ISO8859-15 \
+ de_AT.iso88591 \
+ de_AT.iso885915@euro \
+ de_AT.utf8 \
+ de_AT@euro \
+ de_BE \
+ de_BE.iso88591 \
+ de_BE.iso885915@euro \
+ de_BE@euro \
+ de_CH \
+ de_CH.ISO8859-1 \
+ de_CH.iso88591 \
+ de_CH.utf8 \
+ de_DE \
+ de_DE.ISO8859-1 \
+ de_DE.ISO8859-15 \
+ de_DE.UTF-8 \
+ de_DE.iso88591 \
+ de_DE.iso885915@euro \
+ de_DE.utf8 \
+ de_DE@euro \
+ de_LU \
+ de_LU.iso88591 \
+ de_LU.iso885915@euro \
+ de_LU.utf8 \
+ de_LU@euro \
+ el_GR \
+ el_GR.ISO8859-7 \
+ el_GR.ISO8859-7@euro \
+ el_GR.iso88597 \
+ el_GR.utf8 \
+ en_AU \
+ en_AU.ISO8859-1 \
+ en_AU.iso88591 \
+ en_AU.utf8 \
+ en_BW \
+ en_BW.iso88591 \
+ en_DK \
+ en_DK.iso88591 \
+ en_GB \
+ en_GB.ISO8859-1 \
+ en_GB.ISO8859-15 \
+ en_GB.iso88591 \
+ en_GB.iso885915 \
+ en_GB.utf8 \
+ en_HK \
+ en_HK.iso88591 \
+ en_IE \
+ en_IE.ISO8859-1 \
+ en_IE.ISO8859-15 \
+ en_IE.iso88591 \
+ en_IE.iso885915@euro \
+ en_IE.utf8 \
+ en_IE@euro \
+ en_IN \
+ en_IN.utf8 \
+ en_NZ \
+ en_NZ.ISO8859-1 \
+ en_NZ.iso88591 \
+ en_NZ.utf8 \
+ en_PH \
+ en_PH.iso88591 \
+ en_SG \
+ en_SG.iso88591 \
+ en_ZA \
+ en_ZA.iso88591 \
+ en_ZA.utf8 \
+ en_ZW \
+ en_ZW.iso88591 \
+ es_AR \
+ es_AR.ISO8859-1 \
+ es_AR.iso88591 \
+ es_AR.utf8 \
+ es_BO \
+ es_BO.ISO8859-1 \
+ es_BO.iso88591 \
+ es_BO.utf8 \
+ es_CL \
+ es_CL.ISO8859-1 \
+ es_CL.iso88591 \
+ es_CL.utf8 \
+ es_CO \
+ es_CO.ISO8859-1 \
+ es_CO.iso88591 \
+ es_CO.utf8 \
+ es_CR \
+ es_CR.ISO8859-1 \
+ es_CR.iso88591 \
+ es_CR.utf8 \
+ es_DO \
+ es_DO.iso88591 \
+ es_DO.utf8 \
+ es_EC \
+ es_EC.ISO8859-1 \
+ es_EC.iso88591 \
+ es_EC.utf8 \
+ es_ES \
+ es_ES.ISO8859-1 \
+ es_ES.ISO8859-15 \
+ es_ES.UTF-8 \
+ es_ES.iso88591 \
+ es_ES.iso885915@euro \
+ es_ES.utf8 \
+ es_ES@euro \
+ es_GT \
+ es_GT.ISO8859-1 \
+ es_GT.iso88591 \
+ es_GT.utf8 \
+ es_HN \
+ es_HN.iso88591 \
+ es_HN.utf8 \
+ es_MX \
+ es_MX.ISO8859-1 \
+ es_MX.iso88591 \
+ es_MX.utf8 \
+ es_NI \
+ es_NI.ISO8859-1 \
+ es_NI.iso88591 \
+ es_NI.utf8 \
+ es_PA \
+ es_PA.ISO8859-1 \
+ es_PA.iso88591 \
+ es_PA.utf8 \
+ es_PE \
+ es_PE.ISO8859-1 \
+ es_PE.iso88591 \
+ es_PE.utf8 \
+ es_PY \
+ es_PY.ISO8859-1 \
+ es_PY.iso88591 \
+ es_PY.utf8 \
+ es_SV \
+ es_SV.ISO8859-1 \
+ es_SV.iso88591 \
+ es_SV.utf8 \
+ es_UY \
+ es_UY.ISO8859-1 \
+ es_UY.iso88591 \
+ es_UY.utf8 \
+ es_VE \
+ es_VE.ISO8859-1 \
+ es_VE.iso88591 \
+ es_VE.utf8 \
+ et_EE \
+ et_EE.ISO8859-15 \
+ et_EE.iso88591 \
+ et_EE.utf8 \
+ eu_ES \
+ eu_ES.iso88591 \
+ eu_ES.iso885915@euro \
+ eu_ES@euro \
+ fa_IR.utf8 \
+ fi_FI \
+ fi_FI.ISO8859-1 \
+ fi_FI.ISO8859-15 \
+ fi_FI.UTF-8 \
+ fi_FI.iso88591 \
+ fi_FI.iso885915@euro \
+ fi_FI.utf8 \
+ fi_FI@euro \
+ fo_FO \
+ fo_FO.iso88591 \
+ fo_FO.utf8 \
+ fr_BE \
+ fr_BE.ISO8859-1 \
+ fr_BE.ISO8859-15 \
+ fr_BE.UTF-8 \
+ fr_BE.iso88591 \
+ fr_BE.iso885915@euro \
+ fr_BE.utf8 \
+ fr_BE@euro \
+ fr_CH \
+ fr_CH.ISO8859-1 \
+ fr_CH.iso88591 \
+ fr_CH.utf8 \
+ fr_FR \
+ fr_FR.ISO8859-1 \
+ fr_FR.ISO8859-15 \
+ fr_FR.UTF-8 \
+ fr_FR.iso88591 \
+ fr_FR.iso885915@euro \
+ fr_FR.utf8 \
+ fr_FR@euro \
+ fr_LU \
+ fr_LU.iso88591 \
+ fr_LU.iso885915@euro \
+ fr_LU.utf8 \
+ fr_LU@euro \
+ ga_IE \
+ ga_IE.iso88591 \
+ ga_IE.iso885915@euro \
+ ga_IE.utf8 \
+ ga_IE@euro \
+ gl_ES \
+ gl_ES.iso88591 \
+ gl_ES.iso885915@euro \
+ gl_ES.utf8 \
+ gl_ES@euro \
+ gu_IN.UTF-8 \
+ gu_IN.utf8 \
+ gv_GB \
+ gv_GB.iso88591 \
+ hebrew \
+ he \
+ he_IL \
+ he_IL.ISO8859-8 \
+ he_IL.UTF-8 \
+ he_IL.iso88598 \
+ he_IL.utf8 \
+ hi_IN.UTF-8 \
+ hi_IN.utf8 \
+ hr_HR \
+ hr_HR.ISO8859-2 \
+ hr_HR.iso88592 \
+ hr_HR.utf8 \
+ hu_HU \
+ hu_HU.ISO8859-2 \
+ hu_HU.iso88592 \
+ hu_HU.utf8 \
+ id_ID \
+ id_ID.iso88591 \
+ id_ID.utf8 \
+ is_IS \
+ is_IS.ISO8859-1 \
+ is_IS.iso88591 \
+ is_IS.utf8 \
+ it \
+ it.ISO8859-1 \
+ it.ISO8859-15 \
+ it.UTF-8 \
+ italian \
+ it_CH \
+ it_CH.iso88591 \
+ it_CH.utf8 \
+ it_IT \
+ it_IT.ISO8859-1 \
+ it_IT.ISO8859-15 \
+ it_IT.UTF-8 \
+ it_IT.iso88591 \
+ it_IT.iso885915@euro \
+ it_IT.utf8 \
+ it_IT@euro \
+ iw_IL \
+ iw_IL.iso88598 \
+ ja \
+ japan \
+ japanese \
+ japanese.euc \
+ japanese.sjis \
+ ja_JP \
+ ja_JP.EUC \
+ ja_JP.PCK \
+ ja_JP.UTF-8 \
+ ja_JP.eucJP \
+ ja_JP.eucjp \
+ ja_JP.sjis \
+ ja_JP.ujis \
+ ja_JP.utf8 \
+ ka_GE \
+ ka_GE.georgianps \
+ kl_GL \
+ kl_GL.iso88591 \
+ kl_GL.utf8 \
+ ko \
+ ko.UTF-8 \
+ korean \
+ korean.euc \
+ ko_KR \
+ ko_KR.EUC \
+ ko_KR.EUC@dict \
+ ko_KR.UTF-8 \
+ ko_KR.UTF-8@dict \
+ ko_KR.euckr \
+ ko_KR.utf8 \
+ kw_GB \
+ kw_GB.iso88591 \
+ ky_KG \
+ ky_KG.UTF-8 \
+ ky_KG.utf8 \
+ lt_LT \
+ lt_LT.ISO8859-13 \
+ lt_LT.iso885913 \
+ lt_LT.utf8 \
+ lithuanian \
+ lt \
+ lt.ISO8859-13 \
+ lv \
+ lv.ISO8859-13 \
+ lv_LV \
+ lv_LV.ISO8859-13 \
+ lv_LV.iso885913 \
+ lv_LV.utf8 \
+ mi_NZ \
+ mi_NZ.iso885913 \
+ mk_MK \
+ mk_MK.ISO8859-5 \
+ mk_MK.iso88595 \
+ mk_MK.utf8 \
+ mr_IN.utf8 \
+ ms_MY \
+ ms_MY.iso88591 \
+ mt_MT \
+ mt_MT.iso88593 \
+ nb_NO \
+ nb_NO.ISO-8859-1 \
+ nl \
+ nl.ISO8859-1 \
+ nl.ISO8859-15 \
+ nl_BE \
+ nl_BE.ISO8859-1 \
+ nl_BE.ISO8859-15 \
+ nl_BE.iso88591 \
+ nl_BE.iso885915@euro \
+ nl_BE.utf8 \
+ nl_BE@euro \
+ nl_NL \
+ nl_NL.ISO8859-1 \
+ nl_NL.ISO8859-15 \
+ nl_NL.iso88591 \
+ nl_NL.iso885915@euro \
+ nl_NL.utf8 \
+ nl_NL@euro \
+ nn_NO \
+ nn_NO.iso88591 \
+ no \
+ no.ISO8859-1 \
+ no_NO \
+ no_NO.ISO8859-1@bokmal \
+ no_NO.ISO8859-1@nynorsk \
+ no_NO.iso88591 \
+ no_NO.utf8 \
+ norwegian \
+ nr \
+ nr_ZA \
+ nr_ZA.iso88591 \
+ nr_ZA.utf8 \
+ ndebele \
+ nso \
+ nso_ZA \
+ nso_ZA.iso885915 \
+ nso_ZA.utf8 \
+ sepedi \
+ oc_FR \
+ oc_FR.iso88591 \
+ pa_IN.UTF-8 \
+ pa_IN.utf8 \
+ polish \
+ pl_PL \
+ pl_PL.ISO8859-2 \
+ pl_PL.UTF-8 \
+ pl_PL.iso88592 \
+ pl_PL.utf8 \
+ portuguese \
+ pt \
+ pt.ISO8859-1 \
+ pt.ISO8859-15 \
+ pt_BR \
+ pt_BR.ISO8859-1 \
+ pt_BR.ISO-8859-1 \
+ pt_BR.ISO_8859-1 \
+ pt_BR.iso88591 \
+ pt_BR.iso885915 \
+ pt_BR.88591 \
+ pt_BR.88591.en \
+ pt_BR.utf8 \
+ pt_BR.UTF-8 \
+ pt_PT \
+ pt_PT.ISO8859-1 \
+ pt_PT.ISO8859-15 \
+ pt_PT.iso88591 \
+ pt_PT.iso885915@euro \
+ pt_PT.utf8 \
+ pt_PT@euro \
+ ro_RO \
+ ro_RO.ISO8859-2 \
+ ro_RO.iso88592 \
+ ro_RO.utf8 \
+ ru \
+ ru.ISO8859-5 \
+ ru.UTF-8 \
+ ru.ansi1251 \
+ ru.koi8-r \
+ ru_SU \
+ russian \
+ ru_RU \
+ ru_RU.ANSI1251 \
+ ru_RU.ISO8859-5 \
+ ru_RU.KOI8-R \
+ ru_RU.UTF-8 \
+ ru_RU.iso88595 \
+ ru_RU.koi8r \
+ ru_RU.utf8 \
+ ru_UA \
+ ru_UA.koi8u \
+ romanian \
+ se_NO \
+ se_NO.utf8 \
+ si \
+ sinhala \
+ si_LK \
+ si_LK.UTF8 \
+ sk \
+ sk.ISO8859-2 \
+ slovak \
+ slovene \
+ slovenian \
+ spanish \
+ sk_SK \
+ sk_SK.ISO8859-2 \
+ sk_SK.iso88592 \
+ sk_SK.utf8 \
+ sh \
+ sh.ISO8859-2 \
+ sh_BA.ISO8859-2@bosnia \
+ sh_YU \
+ sh_YU.iso88592 \
+ sh_YU.utf8 \
+ sl_SI \
+ sl_SI.ISO8859-2 \
+ sl_SI.iso88592 \
+ sl_SI.utf8 \
+ su \
+ su.ISO8859-1 \
+ sq_AL \
+ sq_AL.ISO8859-2 \
+ sq_AL.iso88591 \
+ sq_AL.utf8 \
+ sr_SP \
+ sr_SP.ISO8859-5 \
+ sr_YU \
+ sr_YU.ISO8859-5 \
+ sr_YU.iso88592 \
+ sr_YU.iso88595@cyrillic \
+ sr_YU.utf8 \
+ sr_YU@cyrillic \
+ ss \
+ ss_ZA \
+ ss_ZA.iso88591 \
+ ss_ZA.utf8 \
+ siswati \
+ st \
+ st_ZA \
+ st_ZA.iso88591 \
+ st_ZA.utf8 \
+ sesotho \
+ sv \
+ sv.ISO8859-1 \
+ sv.ISO8859-15 \
+ sv.UTF-8 \
+ sv_FI \
+ sv_FI.iso88591 \
+ sv_FI.iso885915@euro \
+ sv_FI.utf8 \
+ sv_FI@euro \
+ sv_SE \
+ sv_SE.ISO8859-1 \
+ sv_SE.ISO8859-15 \
+ sv_SE.UTF-8 \
+ sv_SE.iso88591 \
+ sv_SE.iso885915 \
+ sv_SE.utf8 \
+ swedish \
+ ta_IN \
+ ta_IN.utf8 \
+ te_IN \
+ te_IN.utf8 \
+ tg_TJ \
+ tg_TJ.koi8t \
+ th \
+ thai \
+ th_TH \
+ th_TH.ISO8859-11 \
+ th_TH.TIS620 \
+ th_TH.UTF-8 \
+ th_TH.tis620 \
+ th_TH.utf8 \
+ tl_PH \
+ tl_PH.iso88591 \
+ tn \
+ tn_ZA \
+ tn_ZA.iso885915 \
+ tn_ZA.utf8 \
+ setswana \
+ tr \
+ tr.ISO8859-9 \
+ turkish \
+ tr_TR \
+ tr_TR.ISO8859-9 \
+ tr_TR.UTF-8 \
+ tr_TR.iso88599 \
+ tr_TR.utf8 \
+ ts \
+ ts_ZA \
+ ts_ZA.iso88591 \
+ ts_ZA.utf8 \
+ tsonga \
+ uk_UA \
+ uk_UA.koi8u \
+ uk_UA.utf8 \
+ ur_PK \
+ ur_PK.utf8 \
+ uz_UZ \
+ uz_UZ.iso88591 \
+ ve \
+ ve_ZA \
+ ve_ZA.utf8 \
+ venda \
+ vi_VN \
+ vi_VN.tcvn \
+ vi_VN.utf8 \
+ wa_BE \
+ wa_BE.iso88591 \
+ wa_BE.iso885915@euro \
+ wa_BE@euro \
+ xh \
+ xh_ZA \
+ xh_ZA.iso88591 \
+ xh_ZA.utf8 \
+ xhosa \
+ zh \
+ zh.GBK \
+ zh.UTF-8 \
+ zh_CN \
+ zh_CN.EUC \
+ zh_CN.EUC@pinyin \
+ zh_CN.EUC@radical \
+ zh_CN.EUC@stroke \
+ zh_CN.GB18030 \
+ zh_CN.GB18030@pinyin \
+ zh_CN.GB18030@radical \
+ zh_CN.GB18030@stroke \
+ zh_CN.GBK \
+ zh_CN.GBK@pinyin \
+ zh_CN.GBK@radical \
+ zh_CN.GBK@stroke \
+ zh_CN.UTF-8 \
+ zh_CN.UTF-8@pinyin \
+ zh_CN.UTF-8@radical \
+ zh_CN.UTF-8@stroke \
+ zh_CN.gb18030 \
+ zh_CN.gb2312 \
+ zh_CN.gbk \
+ zh_CN.utf8 \
+ zh_HK \
+ zh_HK.BIG5HK \
+ zh_HK.BIG5HK@radical \
+ zh_HK.BIG5HK@stroke \
+ zh_HK.UTF-8 \
+ zh_HK.UTF-8@radical \
+ zh_HK.UTF-8@stroke \
+ zh_HK.big5hkscs \
+ zh_HK.utf8 \
+ zh_TW \
+ zh_TW.BIG5 \
+ zh_TW.BIG5@pinyin \
+ zh_TW.BIG5@radical \
+ zh_TW.BIG5@stroke \
+ zh_TW.BIG5@zhuyin \
+ zh_TW.EUC \
+ zh_TW.EUC@pinyin \
+ zh_TW.EUC@radical \
+ zh_TW.EUC@stroke \
+ zh_TW.EUC@zhuyin \
+ zh_TW.UTF-8 \
+ zh_TW.UTF-8@pinyin \
+ zh_TW.UTF-8@radical \
+ zh_TW.UTF-8@stroke \
+ zh_TW.UTF-8@zhuyin \
+ zh_TW.big5 \
+ zh_TW.euctw \
+ zh_TW.utf8 \
+ zu \
+ zu_ZA \
+ zu_ZA.iso88591 \
+ zu_ZA.utf8 \
+ zulu
+
+
+# List of locales which should be linked to the "en_US" locale,
+# e.g. these locales should get the defaults (for example that
+# US-Letter is used as default papersize) mainly used in the USA
+US_LOCALES= \
+ en_CA \
+ en_CA.ISO8859-1 \
+ en_CA.iso88591 \
+ en_CA.utf8 \
+ en_US.ISO8859-1 \
+ en_US.ISO8859-15 \
+ en_US.UTF-8 \
+ en_US.iso88591 \
+ en_US.iso885915 \
+ en_US.utf8 \
+ es_PR \
+ es_PR.iso88591 \
+ es_PR.utf8 \
+ es_US \
+ es_US.iso88591 \
+ fr_CA \
+ fr_CA.ISO8859-1 \
+ fr_CA.iso88591 \
+ fr_CA.utf8 \
+ yi_US \
+ yi_US.cp1255
+
+install::
+ ( \
+ cd $(DESTDIR)$(XPRINTDIR) ; \
+ for i in $(C_LOCALES) \
+ ; do \
+ $(RM) $$i ; \
+ $(LN) C $$i ; \
+ done \
+ ) ; \
+ ( \
+ cd $(DESTDIR)$(XPRINTDIR) ; \
+ for i in $(US_LOCALES) \
+ ; do \
+ $(RM) $$i ; \
+ $(LN) en_US $$i ; \
+ done \
+ )
+
diff --git a/nx-X11/programs/Xserver/XpConfig/README b/nx-X11/programs/Xserver/XpConfig/README
new file mode 100644
index 000000000..d7447815d
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/README
@@ -0,0 +1,318 @@
+
+ --------------------------------------
+ The X Print Service - The Basics
+ --------------------------------------
+
+Index
+ - 1.0 X Print Service Overview
+
+ - 2.0 How the X Print Service Works
+
+ - 3.0 Using the X Print Service
+ - 3.1 X Print Server Configuration
+ - 3.2 Starting the X Print Service
+ - 3.3 Configuring the environment
+ - 3.4 General End-User Sequence
+
+
+1.0 X Print Service Overview
+=============================
+
+The "X Print Service" technology allows X rendering to devices such as
+printers and fax. Most of the service is available in the X11
+technology stack as Xp, with the remainder in the CDE technology stack
+as DtPrint. Modifications have also been made to the Motif technology
+stack to support Xp and DtPrint.
+
+The Xp portion consists of:
+ * Xp Extension for the X-Server (included in the X-Server Xprt)
+ * Xp Extension API for the client side (libXp)
+ * PCL ddx driver that converts core X to native PCL
+ * Postscript ddx driver that converts core X to native Postscript
+ * Raster ddx driver that generates xwd rasters which can be
+ converted to PCL or Postscript rasters
+
+The DtPrint portion consists of:
+ * A collection of print GUIs (libDtPrint)
+ * A Print Dialog Manager that can assist a client in
+ setting printing options (dtpdm, dtpdmd)
+
+From an X clients perspective, it can attach to one of two nearly
+identical X-Servers, a "Video" X-Server, and a "Print" X-Server
+which has the additional Xp capability but otherwise looks and
+behaves the same.
+
+
+
+2.0 How the X Print Service Works
+==================================
+
+The X Print Service expands on the traditional X-Server and Xlib world
+in four ways.
+
+1. Most obvious is the use of "print ddx drivers" instead of
+ "video ddx drivers". While a video ddx driver modifies pixels
+ in a video frame buffer, a print ddx driver generates "page
+ description language (PDL)" output such as PCL or Postscript.
+
+ Once a print ddx driver generates PDL output, it can be sent to
+ a spooler such as lp(1) or retrieved by the client.
+
+ Though not currently done, a single X-Server can support both
+ print and video ddx drivers.
+
+2. Since printers support "paged" output, unlike video, a portion
+ of the Xp Extension supports APIs to delineate printed output.
+ For example, XpStartPage and XpEndPage tell the X-Server where
+ a physical page starts and ends in an otherwise continuous
+ stream of X rendering primitives. Likewise, XpStartJob and
+ XpEndJob determine when a collection of pages starts and ends.
+ XpEndJob typically causes the generated PDL to be submitted to
+ a spooler, such as lp(1).
+
+3. Since printers have extensive capabilities, another portion of
+ the Xp Extension supports APIs to manipulate "print contexts".
+
+ Once a printer is selected using the Xp Extension API, a print
+ context to represent it can be created. A print context
+ embodies the printer selected - it contains the printer's
+ default capabilities, selectable range of capabilities,
+ printer state, and generated output. Some "attributes" within
+ the print context can be modified by the user, and the
+ X-Server and print ddx driver will react accordingly. For
+ example, the attribute "content-orientation" can be set to
+ "landscape" or "portrait".
+
+4. Since printers can have "built in" fonts, the Xp Extension in
+ the X-Server works with the print ddx drivers to make
+ available (for printing only) additional fonts on a per print
+ context basis.
+
+ When a print context is created and set for a given printer,
+ the X font calls may be able to access additional printer
+ fonts. To do this (typically), the X-Server must have access
+ to "printer metric files" (.pmf) that describe at minimum the
+ metrics of the built in fonts.
+
+
+
+3.0 Using the X Print Service
+==============================
+
+There are three tasks to start the X Print Service: 1) configuring the
+X Print Server, 2) starting the X Print Service, 3) configuring the user
+session so that clients can find the running X Print Service.
+
+The tasks are described in detail below.
+
+
+3.1 X Print Server Configuration
+---------------------------------
+
+The X Print Server (Xprt) can read a number of configuration files which
+control its behavior and support for printers. Each vendor platform has
+a default location for this information. Xprt can also read the
+environment variable XPCONFIGDIR to locate alternate configuration
+directories. Common settings include:
+
+ * export XPCONFIGDIR=/X11/lib/X11/XpConfig/
+
+ * export XPCONFIGDIR=/proj/x11/xc/programs/Xserver/XpConfig/
+
+Xprt has many built-in defaults, and lacking any configuration files,
+will immediately try to support all printers visible via lpstat(1).
+
+In order of importance for configuration by a system administrator, the
+configuration files for a "C" locale are as follows.
+
+ ${XPCONFIGDIR}/C/print/Xprinters
+
+ `Xprinters' is the top most configuration file. It tells
+ Xprt which specific printer names (e.g. mylaser) should
+ be supported, and whether lpstat(1) or other commands
+ should be used to automatically supplement the list of
+ printers.
+
+ ${XPCONFIGDIR}/C/print/attributes/printer
+
+ The `printer' file maps printer names to model
+ configurations (see `model-config' below). For example,
+ "mylaser" could be mapped to a "HPDJ1600C", and all other
+ arbitrary printers could be mapped to a default, such as
+ "HPLJ4SI". When depending on lpstat(1) in the Xprinters
+ file, setting up defaults in `printer' becomes all the
+ more important.
+
+ ${XPCONFIGDIR}/C/print/attributes/document
+
+ The `document' file specifies the initial document values
+ for any print jobs. For example, which paper tray to
+ use, what default resolution, etc.
+
+ ${XPCONFIGDIR}/C/print/attributes/job
+
+ The `job' file specifies the initial job values for any
+ print jobs. For example, "notification-profile" can be
+ set so that when a print job is successfully sent to a
+ printer, e-mail is sent to the user.
+
+ ${XPCONFIGDIR}/C/print/models/HPDJ1600C/model-config
+ ${XPCONFIGDIR}/C/print/models/HPDJ1600C/fonts/fonts.dir
+ ${XPCONFIGDIR}/C/print/models/HPDJ1600C/fonts/9nb00051.pmf
+ ${XPCONFIGDIR}/C/print/models/HPDJ1600C/fonts/9nb00093.pmf
+
+ The `model-config' file has attributes that describe the
+ printer model's capabilities and default settings.
+ Printer model fonts may also be present. The model-config
+ file also identifies the print ddx driver to be used.
+
+ For each printer model supported, a complete hierarchy of
+ files should exist. In most cases, these files do not
+ need to be modified.
+
+ ${XPCONFIGDIR}/C/print/ddx-config/raster/pcl
+ ${XPCONFIGDIR}/C/print/ddx-config/raster/postscript
+
+ The print ddx drivers can have highly specific
+ configuration files to control their behavior. In most
+ cases, these files do not need to be modified.
+
+
+3.2 Starting the X Print Service
+---------------------------------
+
+The summary checklist for starting the X Print Service is as follows:
+
+1. Choose an execution model for the X Print Service. The X
+ Print Service can be run on a per-user session basis, per
+ machine basis, or can be run on a few machines globally
+ available to a number of users.
+
+2. If print jobs are to be submitted to a spooler (almost always
+ the case), make sure all needed printers are available to the
+ spooler subsystem (most often lp(1)) on the same machine
+ running the X Print Service.
+
+3. Configure the X Print Server. See ``X Print Server
+ Configuration''.
+
+4. Depending on #1, start the X Print Server process "Xprt", and
+ then the Print Dialog Manager Daemon process "dtpdmd" at the
+ appropriate times.
+
+The details are described below.
+
+Because the X Print Service is based on X, it can be easily distributed.
+The most significant factors in which execution model to choose will be
+driven by:
+
+ * how many printers will be accessable through the printer
+ subsystem on any given machine. A system administrator may
+ choose to cluster printers on a few given machines, or
+ scatter them across an organization and possibly make
+ extensive use of remote spoolers to make them globally
+ available.
+
+ * how many machines will need a copy of the X Print Server
+ configuration files. The files have been architected so
+ that one super-set version of them can be maintained and
+ distributed (e.g. via NFS), and a per-machine or per-user
+ version of the `Xprinters' is all that is needed to have the
+ appropriate information in them utilized or ignored.
+
+ * how many users can demand services from a given X Print
+ Service.
+
+With the above in mind, some obvious execution models include:
+
+ * Global - in this model, the system administrator is choosing
+ to run the X Print Service on a *few* select machines with
+ appropriate printers configured, and allow clients access to
+ the global resource. This can centralize the administration
+ of printers and configuration files, but may have to be
+ monitored for performance loading.
+
+ Startup would likely be done by boot-up scripts.
+
+ * Per-machine - every machine with potential X Print Service
+ users would run the service. Printer and configuration file
+ administration is decentralized, and usage would be limited
+ to the users on the machine.
+
+ Startup would likely be done by boot-up scripts.
+
+ * Per-user session - every user would run an entire X Print
+ Service for themselves. In the future, the Video X Server
+ normally started may contain Print X Server capability, so
+ this model becomes very natural.
+
+ Startup would likely be done at session login or by
+ launching actions or processes manually once the user
+ logs in. Note: the dtpdmd must be started after Xprt.
+
+Starting of the processes is straight forward. In strict order:
+
+ [machineA] % Xprt [-XpFile <Xprinters file>] [:dispNum] &
+
+ Note that Xprt will look for configuration files in either
+ a default location or where XPCONFIGDIR points.
+
+ -XpFile specifies an alternate `Xprinters' file, rather
+ than the default one or `${XPCONFIGDIR}/C/print/Xprinters'.
+
+ [machineA] % dtpdmd -d machineA[:dispNum] [-l /tmp/dtpdmd.log] &
+
+ The dtpdmd will maintain an X-Selection on the X-Server,
+ and will start dtpdm's as required to service requests.
+
+In all but the per-user session model, the machine running the dtpdmd
+(thus dtpdm's) will need display authorization to the users video
+display.
+
+
+
+3.3 Configuring the environment
+--------------------------------
+
+Once a X Print Server and dtpdmd have been started -- many of them
+in some cases -- clients will need to find and use them. There are
+two mechanisms that allow clients to discover X Print Servers and
+printers.
+
+ * "X Print Specifier" - assuming usage of the DtPrint print
+ dialogs, the following notation is understood:
+
+ printer_name@machine[:dispNum]
+
+ For example:
+
+ colorlj7@printhub:2
+
+ In the above example, the X Print Server running at `printhub:2'
+ is assumed to support the printer named `colorlj7'.
+
+ * "XPSERVERLIST" - assuming usage of the DtPrint print dialogs,
+ the environment variable "XPSERVERLIST" can contain a list
+ of X Print Servers. For example:
+
+ XPSERVERLIST="printhub:2 printhub:3 otherdept:0"
+
+ Then in the dialogs, only a printer name needs to be entered.
+ The dialog will then search the X Print Servers in XPSERVERLIST
+ for a server than supports the printer, and then establish
+ contact.
+
+3.4 General End-User Sequence
+------------------------------
+
+From most CDEnext applications, printing is accomplished by bringing
+down the <File> menu and selecting <Print...>. This will result in
+the DtPrintSetupBox dialog, which will request the name of a printer,
+and offer limited capability to configure print options (e.g. number
+of copies). If the user wishes, they can select <Setup...>, which
+will start a dtpdm capable of modifying additional print options.
+Finally, the user should select <Print>.
+
+
+
+$Xorg: README,v 1.3 2000/08/17 19:48:02 cpqbld Exp $
diff --git a/nx-X11/programs/Xserver/XpConfig/en_US/Imakefile b/nx-X11/programs/Xserver/XpConfig/en_US/Imakefile
new file mode 100644
index 000000000..1beed3bca
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/en_US/Imakefile
@@ -0,0 +1,8 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/11/23 05:42:52 gisburn Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+SUBDIRS = print
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
diff --git a/nx-X11/programs/Xserver/XpConfig/en_US/print/Imakefile b/nx-X11/programs/Xserver/XpConfig/en_US/print/Imakefile
new file mode 100644
index 000000000..113a5456b
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/en_US/print/Imakefile
@@ -0,0 +1,26 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+SUBDIRS = attributes
+
+XPLOCALEPRINTDIR=$(XPRINTDIR)/en_US/print
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+
+MakeDirectories(install,$(XPLOCALEPRINTDIR))
+
+# We only have different values in "attributes", so link all other files
+# to the "defaults" in the C locale
+LINK_TO_C_LOCALE=Xprinters ddx-config models
+
+install::
+ ( \
+ cd $(DESTDIR)$(XPLOCALEPRINTDIR) ; \
+ for i in $(LINK_TO_C_LOCALE) \
+ ; do \
+ $(RM) $$i ; \
+ $(LN) ../../C/print/$$i $$i ; \
+ done \
+ )
diff --git a/nx-X11/programs/Xserver/XpConfig/en_US/print/attributes/Imakefile b/nx-X11/programs/Xserver/XpConfig/en_US/print/attributes/Imakefile
new file mode 100644
index 000000000..86979a31c
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/en_US/print/attributes/Imakefile
@@ -0,0 +1,18 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/11/23 05:42:52 gisburn Exp $
+
+XPATTRIBUTEDIR = $(XPRINTDIR)/en_US/print/attributes
+
+# Install the "en_US"-specific "document" attribute resources...
+InstallNonExecFile(document,$(XPATTRIBUTEDIR))
+
+# ... and reuse "job" and "printer" pools from the C locale
+install::
+ ( \
+ cd $(DESTDIR)$(XPATTRIBUTEDIR) ; \
+ for i in job printer \
+ ; do \
+ $(RM) $$i ; \
+ $(LN) ../../../C/print/attributes/$$i $$i ; \
+ done \
+ )
+
diff --git a/nx-X11/programs/Xserver/XpConfig/en_US/print/attributes/document b/nx-X11/programs/Xserver/XpConfig/en_US/print/attributes/document
new file mode 100644
index 000000000..253c46bce
--- /dev/null
+++ b/nx-X11/programs/Xserver/XpConfig/en_US/print/attributes/document
@@ -0,0 +1,13 @@
+# $Xorg: document,v 1.2 2002/11/30 22:10:03 gisburn Exp $
+# Document DPA-Object initial attribute values for en_US(-like) locales
+#
+# Note that the defaults (for all locales) are set in
+# ${XPCONFIGDIR}/C/print/attributes/document
+# Values in ${XPCONFIGDIR}/${LANG}/print/attributes/document are used to
+# set/override these defaults for a specific locale on demand
+
+# US and some other countries use US-Letter as default paper size
+# ("C"-locale default is "ISO-A4")
+*default-medium: na-letter
+
+# EOF.
diff --git a/nx-X11/programs/Xserver/Xprint/AttrValid.c b/nx-X11/programs/Xserver/Xprint/AttrValid.c
new file mode 100644
index 000000000..cf9476003
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/AttrValid.c
@@ -0,0 +1,702 @@
+/* $Xorg: AttrValid.c,v 1.4 2001/03/14 18:43:17 pookie Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <scrnintstr.h>
+
+#include "attributes.h"
+
+/*
+ * default medium-source-sizes supported = na-letter w/.25" margins
+ */
+static XpOidMediumDiscreteSize DefaultMediumSize = {
+ xpoid_val_medium_size_na_letter, xFalse, {6.35, 209.55, 6.35, 273.05}
+};
+static XpOidMediumDiscreteSizeList DefaultMediumSizeList = {
+ &DefaultMediumSize, 1
+};
+static XpOidMediumSourceSize DefaultMediumSourceSize = {
+ xpoid_unspecified, XpOidMediumSS_DISCRETE, { &DefaultMediumSizeList }
+};
+static XpOidMediumSS DefaultMediumSS = {
+ &DefaultMediumSourceSize, 1
+};
+
+/*
+ * if 'valid_oid_list' is NULL any oid found is considered valid
+ */
+XpOid
+XpGetOidAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidList* valid_oid_list)
+{
+ XpOid value_oid;
+
+ value_oid = XpOidFromString(XpGetStringAttr(pContext, pool, oid));
+ if((const XpOidList*)NULL == valid_oid_list
+ ||
+ XpOidListHasOid(valid_oid_list, value_oid))
+ {
+ return value_oid;
+ }
+ else
+ {
+ return xpoid_none;
+ }
+}
+
+void
+XpPutOidAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ XpOid value_oid)
+{
+ XpPutStringAttr(pContext, pool, oid, XpOidString(value_oid));
+}
+
+void
+XpValidateOidAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidList* valid_oids,
+ XpOid default_oid)
+{
+ XpOid value_oid;
+ value_oid = XpGetOidAttr(pContext, pool, oid, valid_oids);
+ XpPutOidAttr(pContext, pool, oid,
+ value_oid == xpoid_none ? default_oid : value_oid);
+}
+
+/*
+ * if 'valid_card_list' is NULL any cardinal found is considered valid
+ */
+unsigned long
+XpGetCardAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidCardList* valid_card_list)
+{
+ unsigned long value_card;
+
+ if(XpOidParseUnsignedValue(XpGetStringAttr(pContext, pool, oid),
+ (const char**)NULL,
+ &value_card))
+ {
+ if((const XpOidCardList*)NULL == valid_card_list
+ ||
+ XpOidCardListHasCard(valid_card_list, value_card))
+ {
+ return value_card;
+ }
+ }
+ return 0;
+}
+
+void
+XpPutCardAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ unsigned long value_card)
+{
+ if(value_card > 0)
+ {
+ char value_out[16];
+ sprintf(value_out, "%lu", value_card);
+ XpPutStringAttr(pContext, pool, oid, value_out);
+ }
+ else
+ XpPutStringAttr(pContext, pool, oid, (const char*)NULL);
+}
+
+void
+XpValidateCardAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidCardList* valid_cards,
+ unsigned long default_card)
+{
+ unsigned long value_card;
+ value_card = XpGetCardAttr(pContext, pool, oid, valid_cards);
+ XpPutCardAttr(pContext, pool, oid,
+ value_card == 0 ? default_card : value_card);
+}
+
+XpOidList*
+XpGetListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidList* valid_oid_list)
+{
+ return XpOidListNew(XpGetStringAttr(pContext, pool, oid), valid_oid_list);
+}
+
+void
+XpPutListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidList* list)
+{
+ char* value_out;
+
+ value_out = XpOidListString(list);
+ XpPutStringAttr(pContext, pool, oid, value_out);
+ XpOidFree(value_out);
+}
+
+void
+XpValidateListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidList* valid_oids,
+ const XpOidList* default_oids)
+{
+ XpOidList* list = XpGetListAttr(pContext, pool, oid, valid_oids);
+ if(XpOidListCount(list) == 0)
+ XpPutListAttr(pContext, pool, oid, default_oids);
+ else
+ XpPutListAttr(pContext, pool, oid, list);
+ XpOidListDelete(list);
+}
+
+XpOidCardList*
+XpGetCardListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidCardList* valid_card_list)
+{
+ return XpOidCardListNew(XpGetStringAttr(pContext, pool, oid),
+ valid_card_list);
+}
+
+void
+XpPutCardListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidCardList* list)
+{
+ char* value_out;
+
+ value_out = XpOidCardListString(list);
+ XpPutStringAttr(pContext, pool, oid, value_out);
+ XpOidFree(value_out);
+}
+
+void
+XpValidateCardListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidCardList* valid_cards,
+ const XpOidCardList* default_cards)
+{
+ XpOidCardList* list = XpGetCardListAttr(pContext, pool, oid, valid_cards);
+ if(XpOidCardListCount(list) == 0 && (XpOidCardList*)NULL != default_cards)
+ XpPutCardListAttr(pContext, pool, oid, default_cards);
+ else
+ XpPutCardListAttr(pContext, pool, oid, list);
+ XpOidCardListDelete(list);
+}
+
+XpOidDocFmtList*
+XpGetDocFmtListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidDocFmtList* valid_fmt_list)
+{
+ return XpOidDocFmtListNew(XpGetStringAttr(pContext, pool, oid),
+ valid_fmt_list);
+}
+
+void
+XpPutDocFmtListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidDocFmtList* list)
+{
+ char* value_out;
+
+ value_out = XpOidDocFmtListString(list);
+ XpPutStringAttr(pContext, pool, oid, value_out);
+ XpOidFree(value_out);
+}
+
+void
+XpValidateDocFmtListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidDocFmtList* valid_fmts,
+ const XpOidDocFmtList* default_fmts)
+{
+ XpOidDocFmtList* list;
+
+ list = XpGetDocFmtListAttr(pContext, pool, oid, valid_fmts);
+ if(XpOidDocFmtListCount(list) == 0
+ &&
+ (XpOidDocFmtList*)NULL != default_fmts)
+ {
+ XpPutDocFmtListAttr(pContext, pool, oid, default_fmts);
+ }
+ else
+ {
+ XpPutDocFmtListAttr(pContext, pool, oid, list);
+ }
+ XpOidDocFmtListDelete(list);
+}
+
+XpOidMediumSS*
+XpGetMediumSSAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidList* valid_trays,
+ const XpOidList* valid_sizes)
+{
+ return XpOidMediumSSNew(XpGetStringAttr(pContext, pool, oid),
+ valid_trays, valid_sizes);
+}
+
+void
+XpPutMediumSSAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidMediumSS* msss)
+{
+ char* value_out;
+
+ value_out = XpOidMediumSSString(msss);
+ XpPutStringAttr(pContext, pool, oid, value_out);
+ XpOidFree(value_out);
+}
+
+const XpOidMediumSS*
+XpGetDefaultMediumSS()
+{
+ return &DefaultMediumSS;
+}
+
+XpOidTrayMediumList*
+XpGetTrayMediumListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidList* valid_trays,
+ const XpOidMediumSS* msss)
+{
+ return XpOidTrayMediumListNew(XpGetStringAttr(pContext, pool, oid),
+ valid_trays, msss);
+}
+
+void
+XpPutTrayMediumListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidTrayMediumList* tm)
+{
+ char* value_out;
+
+ value_out = XpOidTrayMediumListString(tm);
+ XpPutStringAttr(pContext, pool, oid, value_out);
+ XpOidFree(value_out);
+}
+
+void
+XpValidatePrinterMediaAttrs(XpContextPtr pContext,
+ const XpOidList* valid_trays,
+ const XpOidList* valid_sizes)
+{
+ const XpOidMediumSS* msss;
+ XpOidMediumSS* pool_msss;
+ XpOidTrayMediumList* tm;
+
+ pool_msss = XpGetMediumSSAttr(pContext, XPPrinterAttr,
+ xpoid_att_medium_source_sizes_supported,
+ valid_trays, valid_sizes);
+ if(0 == XpOidMediumSSCount(pool_msss))
+ msss = XpGetDefaultMediumSS();
+ else
+ msss = pool_msss;
+ XpPutMediumSSAttr(pContext, XPPrinterAttr,
+ xpoid_att_medium_source_sizes_supported, msss);
+
+ tm = XpGetTrayMediumListAttr(pContext, XPPrinterAttr,
+ xpoid_att_input_trays_medium,
+ valid_trays, msss);
+ XpPutTrayMediumListAttr(pContext, XPPrinterAttr,
+ xpoid_att_input_trays_medium, tm);
+
+ XpOidMediumSSDelete(pool_msss);
+ XpOidTrayMediumListDelete(tm);
+}
+
+
+void
+XpValidatePrinterPool(XpContextPtr pContext,
+ const XpValidatePoolsRec* vpr)
+{
+ /*
+ * content-orientations-supported
+ */
+ XpValidateListAttr(pContext, XPPrinterAttr,
+ xpoid_att_content_orientations_supported,
+ vpr->valid_content_orientations_supported,
+ vpr->default_content_orientations_supported);
+ /*
+ * document-formats-supported
+ */
+ XpValidateDocFmtListAttr(pContext, XPPrinterAttr,
+ xpoid_att_document_formats_supported,
+ vpr->valid_document_formats_supported,
+ vpr->default_document_formats_supported);
+ /*
+ * plexes-supported
+ */
+ XpValidateListAttr(pContext, XPPrinterAttr, xpoid_att_plexes_supported,
+ vpr->valid_plexes_supported,
+ vpr->default_plexes_supported);
+ /*
+ * printer-resolutions-supported
+ */
+ XpValidateCardListAttr(pContext, XPPrinterAttr,
+ xpoid_att_printer_resolutions_supported,
+ vpr->valid_printer_resolutions_supported,
+ vpr->default_printer_resolutions_supported);
+ /*
+ * xp-embedded-formats-supported
+ */
+ XpValidateDocFmtListAttr(pContext, XPPrinterAttr,
+ xpoid_att_xp_embedded_formats_supported,
+ vpr->valid_xp_embedded_formats_supported,
+ vpr->default_xp_embedded_formats_supported);
+ /*
+ * xp-listfonts-modes-supported
+ */
+ XpValidateListAttr(pContext, XPPrinterAttr,
+ xpoid_att_xp_listfonts_modes_supported,
+ vpr->valid_xp_listfonts_modes_supported,
+ vpr->default_xp_listfonts_modes_supported);
+ /*
+ * xp-raw-formats-supported
+ */
+ XpValidateDocFmtListAttr(pContext, XPPrinterAttr,
+ xpoid_att_xp_raw_formats_supported,
+ vpr->valid_xp_raw_formats_supported,
+ vpr->default_xp_raw_formats_supported);
+ /*
+ * xp-setup-proviso
+ */
+ XpValidateOidAttr(pContext, XPPrinterAttr, xpoid_att_xp_setup_proviso,
+ vpr->valid_xp_setup_proviso, xpoid_none);
+ /*
+ * medium-source-sizes-supported
+ * input-trays-mdeium
+ */
+ XpValidatePrinterMediaAttrs(pContext,
+ vpr->valid_input_trays,
+ vpr->valid_medium_sizes);
+ /*
+ * available-compressions-supported
+ */
+ XpValidateListAttr(pContext, XPPrinterAttr,
+ xpoid_att_available_compressions_supported,
+ vpr->valid_available_compressions_supported,
+ vpr->default_available_compressions_supported);
+}
+
+
+void
+XpValidateNotificationProfile(XpContextPtr pContext)
+{
+ const char* value_in;
+ const char* value_out;
+
+ value_in = XpGetStringAttr(pContext, XPJobAttr,
+ xpoid_att_notification_profile);
+ value_out = XpOidNotifyString(XpOidNotifyParse(value_in));
+ XpPutStringAttr(pContext, XPJobAttr,
+ xpoid_att_notification_profile, value_out);
+}
+
+void
+XpValidateJobPool(XpContextPtr pContext,
+ const XpValidatePoolsRec* vpr)
+{
+ /*
+ * Note: the 'vpr' argument is unused in this
+ * implementation; it is reserved for future use
+ */
+ XpOidList* job_attrs_supported;
+ /*
+ * only validate attributes found in job-attributes-supported
+ */
+ job_attrs_supported = XpGetListAttr(pContext, XPPrinterAttr,
+ xpoid_att_job_attributes_supported,
+ (const XpOidList*)NULL);
+ /*
+ * notification-profile
+ */
+ if(XpOidListHasOid(job_attrs_supported, xpoid_att_notification_profile))
+ {
+ XpValidateNotificationProfile(pContext);
+ }
+ /*
+ * clean up
+ */
+ XpOidListDelete(job_attrs_supported);
+}
+
+
+static void
+XpValidateDocOrPagePool(XpContextPtr pContext,
+ XPAttributes pool, /* XPDocAttr or XPPageAttr */
+ const XpOidList* attrs_supported,
+ const XpValidatePoolsRec* vpr)
+{
+ /*
+ * content-orientation
+ */
+ if(XpOidListHasOid(attrs_supported, xpoid_att_content_orientation))
+ {
+ XpOidList* content_orientations_supported;
+ content_orientations_supported =
+ XpGetListAttr(pContext, XPPrinterAttr,
+ xpoid_att_content_orientations_supported,
+ vpr->valid_content_orientations_supported);
+ XpValidateOidAttr(pContext, pool, xpoid_att_content_orientation,
+ content_orientations_supported, xpoid_none);
+ XpOidListDelete(content_orientations_supported);
+ }
+ /*
+ * copy-count
+ */
+ if(XpOidListHasOid(attrs_supported, xpoid_att_copy_count))
+ XpValidateCardAttr(pContext, pool, xpoid_att_copy_count,
+ (const XpOidCardList*)NULL, 0);
+ /*
+ * default-printer-resolution
+ */
+ if(XpOidListHasOid(attrs_supported, xpoid_att_default_printer_resolution))
+ {
+ XpOidCardList* printer_resolutions_supported;
+ printer_resolutions_supported =
+ XpGetCardListAttr(pContext, XPPrinterAttr,
+ xpoid_att_printer_resolutions_supported,
+ vpr->valid_printer_resolutions_supported);
+ XpValidateCardAttr(pContext, pool,
+ xpoid_att_default_printer_resolution,
+ printer_resolutions_supported, 0);
+ XpOidCardListDelete(printer_resolutions_supported);
+ }
+ /*
+ * default-input-tray
+ */
+ if(XpOidListHasOid(attrs_supported, xpoid_att_default_input_tray))
+ {
+ XpOidTrayMediumList* input_trays_medium;
+ const char* value_in;
+ XpOid value_tray;
+
+ input_trays_medium =
+ XpGetTrayMediumListAttr(pContext, XPPrinterAttr,
+ xpoid_att_input_trays_medium,
+ (const XpOidList*)NULL,
+ (const XpOidMediumSS*)NULL);
+ value_in =
+ XpGetStringAttr(pContext, pool, xpoid_att_default_input_tray);
+ value_tray = XpOidFromString(value_in);
+ if(!XpOidTrayMediumListHasTray(input_trays_medium, value_tray))
+ value_tray = xpoid_none;
+ XpPutOidAttr(pContext, pool, xpoid_att_default_input_tray, value_tray);
+ XpOidTrayMediumListDelete(input_trays_medium);
+ }
+ /*
+ * default-medium
+ */
+ if(XpOidListHasOid(attrs_supported, xpoid_att_default_medium))
+ {
+ XpOidMediumSS* msss;
+ const char* value_in;
+ XpOid value_size;
+
+ msss = XpGetMediumSSAttr(pContext, XPPrinterAttr,
+ xpoid_att_medium_source_sizes_supported,
+ (const XpOidList*)NULL,
+ (const XpOidList*)NULL);
+ value_in = XpGetStringAttr(pContext, pool, xpoid_att_default_medium);
+ value_size = XpOidFromString(value_in);
+ if(!XpOidMediumSSHasSize(msss, value_size))
+ value_size = xpoid_none;
+ XpPutOidAttr(pContext, pool, xpoid_att_default_medium, value_size);
+ XpOidMediumSSDelete(msss);
+ }
+ /*
+ * document-format
+ */
+ if(XpOidListHasOid(attrs_supported, xpoid_att_document_format))
+ {
+ XpOidDocFmtList* document_formats_supported;
+ const char* value_in;
+ XpOidDocFmt* document_format;
+ const char* value_out;
+
+ document_formats_supported =
+ XpGetDocFmtListAttr(pContext, XPPrinterAttr,
+ xpoid_att_document_formats_supported,
+ vpr->valid_document_formats_supported);
+ value_in = XpGetStringAttr(pContext, pool, xpoid_att_document_format);
+ document_format = XpOidDocFmtNew(value_in);
+ if(XpOidDocFmtListHasFmt(document_formats_supported, document_format))
+ value_out = XpOidDocFmtString(document_format);
+ else
+ value_out = XpOidDocFmtString(vpr->default_document_format);
+ XpOidDocFmtListDelete(document_formats_supported);
+ XpOidDocFmtDelete(document_format);
+ XpPutStringAttr(pContext, pool, xpoid_att_document_format, value_out);
+ XpOidFree(value_out);
+ }
+ /*
+ * plex
+ */
+ if(XpOidListHasOid(attrs_supported, xpoid_att_plex))
+ {
+ XpOidList* plexes_supported;
+ plexes_supported =
+ XpGetListAttr(pContext, XPPrinterAttr, xpoid_att_plexes_supported,
+ vpr->valid_plexes_supported);
+ XpValidateOidAttr(pContext, pool, xpoid_att_plex,
+ plexes_supported, xpoid_none);
+ XpOidListDelete(plexes_supported);
+ }
+ /*
+ * xp-listfonts-modes
+ */
+ if(XpOidListHasOid(attrs_supported, xpoid_att_xp_listfonts_modes))
+ {
+ XpOidList* xp_listfonts_modes_supported;
+ xp_listfonts_modes_supported =
+ XpGetListAttr(pContext, XPPrinterAttr,
+ xpoid_att_xp_listfonts_modes_supported,
+ vpr->valid_xp_listfonts_modes_supported);
+ XpValidateListAttr(pContext, pool, xpoid_att_xp_listfonts_modes,
+ xp_listfonts_modes_supported,
+ (const XpOidList*)NULL);
+ XpOidListDelete(xp_listfonts_modes_supported);
+ }
+ /*
+ * available-compressions
+ */
+ if(XpOidListHasOid(attrs_supported, xpoid_att_available_compression))
+ {
+ XpOidList* available_compressions_supported;
+ available_compressions_supported =
+ XpGetListAttr(pContext, XPPrinterAttr,
+ xpoid_att_available_compressions_supported,
+ vpr->valid_available_compressions_supported);
+ XpValidateOidAttr(pContext, pool, xpoid_att_available_compression,
+ available_compressions_supported, xpoid_none);
+ XpOidListDelete(available_compressions_supported);
+ }
+}
+
+void
+XpValidateDocumentPool(XpContextPtr pContext,
+ const XpValidatePoolsRec* vpr)
+{
+ XpOidList* document_attrs_supported;
+ /*
+ * only validate attributes found in document-attributes-supported
+ */
+ document_attrs_supported =
+ XpGetListAttr(pContext, XPPrinterAttr,
+ xpoid_att_document_attributes_supported,
+ (const XpOidList*)NULL);
+ /*
+ * validate
+ */
+ XpValidateDocOrPagePool(pContext, XPDocAttr,
+ document_attrs_supported, vpr);
+ /*
+ * clean up
+ */
+ XpOidListDelete(document_attrs_supported);
+}
+
+void
+XpValidatePagePool(XpContextPtr pContext,
+ const XpValidatePoolsRec* vpr)
+{
+ XpOidList* page_attrs_supported;
+ /*
+ * only validate attributes found in xp-page-attributes-supported
+ */
+ page_attrs_supported =
+ XpGetListAttr(pContext, XPPrinterAttr,
+ xpoid_att_xp_page_attributes_supported,
+ (const XpOidList*)NULL);
+ /*
+ * validate
+ */
+ XpValidateDocOrPagePool(pContext, XPPageAttr,
+ page_attrs_supported, vpr);
+ /*
+ * clean up
+ */
+ XpOidListDelete(page_attrs_supported);
+}
+
+void
+XpValidateAttributePool(XpContextPtr pContext,
+ XPAttributes pool,
+ const XpValidatePoolsRec* vpr)
+{
+ switch(pool)
+ {
+ case XPPrinterAttr:
+ XpValidatePrinterPool(pContext, vpr);
+ break;
+
+ case XPDocAttr:
+ XpValidateDocumentPool(pContext, vpr);
+ break;
+
+ case XPJobAttr:
+ XpValidateJobPool(pContext, vpr);
+ break;
+
+ case XPPageAttr:
+ XpValidatePagePool(pContext, vpr);
+ break;
+
+ default:
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xprint/AttrValid.h b/nx-X11/programs/Xserver/Xprint/AttrValid.h
new file mode 100644
index 000000000..440bea06f
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/AttrValid.h
@@ -0,0 +1,216 @@
+/* $Xorg: AttrValid.h,v 1.4 2001/03/14 18:43:40 pookie Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _Xp_AttrValid_h
+#define _Xp_AttrValid_h
+
+#include <X11/extensions/Printstr.h>
+#include "Oid.h"
+
+#define XpNumber(a) (sizeof(a) / sizeof(*(a)))
+
+/*
+ * Attribute pool validation valid values and defaults
+ */
+typedef struct
+{
+ XpOidList* valid_content_orientations_supported;
+ XpOidList* default_content_orientations_supported;
+
+ XpOidDocFmtList* valid_document_formats_supported;
+ XpOidDocFmtList* default_document_formats_supported;
+
+ XpOidList* valid_input_trays;
+ XpOidList* valid_medium_sizes;
+
+ XpOidList* valid_plexes_supported;
+ XpOidList* default_plexes_supported;
+
+ XpOidCardList* valid_printer_resolutions_supported;
+ XpOidCardList* default_printer_resolutions_supported;
+
+ XpOidDocFmtList* valid_xp_embedded_formats_supported;
+ XpOidDocFmtList* default_xp_embedded_formats_supported;
+
+ XpOidList* valid_xp_listfonts_modes_supported;
+ XpOidList* default_xp_listfonts_modes_supported;
+
+ XpOidDocFmtList* valid_xp_raw_formats_supported;
+ XpOidDocFmtList* default_xp_raw_formats_supported;
+
+ XpOidList* valid_xp_setup_proviso;
+
+ XpOidDocFmt* default_document_format;
+ XpOidList* valid_available_compressions_supported;
+ XpOidList* default_available_compressions_supported;
+
+} XpValidatePoolsRec;
+
+/*
+ * XpOid resource access
+ */
+#define XpGetStringAttr(pContext, pool, oid) \
+ (const char*)XpGetOneAttribute(pContext, pool, (char*)XpOidString(oid))
+#define XpPutStringAttr(pContext, pool, oid, value) \
+ XpPutOneAttribute(pContext, pool, XpOidString(oid), value)
+
+#ifdef _XP_PRINT_SERVER_ /* needed for XpContextPtr in Printstr.h */
+
+/*
+ * XpOid-valued attribute access
+ */
+XpOid XpGetOidAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidList* valid_oid_list);
+void XpPutOidAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ XpOid value_oid);
+void XpValidateOidAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidList* valid_oids,
+ XpOid default_oid);
+/*
+ * cardinal-valued attribute access
+ */
+unsigned long XpGetCardAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidCardList* valid_card_list);
+void XpPutCardAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ unsigned long value_card);
+void XpValidateCardAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidCardList* valid_cards,
+ unsigned long default_card);
+/*
+ * XpOidList-valued attribute access
+ */
+XpOidList* XpGetListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidList* valid_oid_list);
+void XpPutListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidList* list);
+void XpValidateListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidList* valid_oids,
+ const XpOidList* default_oids);
+/*
+ * XpOidCardList-valued attribute access
+ */
+XpOidCardList* XpGetCardListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidCardList* valid_card_list);
+void XpPutCardListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidCardList* list);
+void XpValidateCardListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidCardList* valid_cards,
+ const XpOidCardList* default_cards);
+/*
+ * XpOidDocFmtList-valued attribute access
+ */
+XpOidDocFmtList* XpGetDocFmtListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidDocFmtList* valid_fmt_list);
+void XpPutDocFmtListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidDocFmtList* list);
+void XpValidateDocFmtListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidDocFmtList* valid_fmts,
+ const XpOidDocFmtList* default_fmts);
+/*
+ * XpOidMediumSS-valued attribute access
+ */
+XpOidMediumSS* XpGetMediumSSAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidList* valid_trays,
+ const XpOidList* valid_sizes);
+void XpPutMediumSSAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidMediumSS* msss);
+const XpOidMediumSS* XpGetDefaultMediumSS();
+
+/*
+ * XpOidTrayMediumList-valued attribute access
+ */
+XpOidTrayMediumList* XpGetTrayMediumListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidList* valid_trays,
+ const XpOidMediumSS* msss);
+void XpPutTrayMediumListAttr(XpContextPtr pContext,
+ XPAttributes pool,
+ XpOid oid,
+ const XpOidTrayMediumList* tm);
+/*
+ * Attribute pool validation
+ */
+void XpValidateAttributePool(XpContextPtr pContext,
+ XPAttributes pool,
+ const XpValidatePoolsRec* vpr);
+void XpValidatePrinterPool(XpContextPtr pContext,
+ const XpValidatePoolsRec* vpr);
+void XpValidateJobPool(XpContextPtr pContext,
+ const XpValidatePoolsRec* vpr);
+void XpValidateDocumentPool(XpContextPtr pContext,
+ const XpValidatePoolsRec* vpr);
+void XpValidatePagePool(XpContextPtr pContext,
+ const XpValidatePoolsRec* vpr);
+
+#endif /* _XP_PRINT_SERVER_ */
+
+#endif /* _Xp_AttrValid_h - don't add anything after this line */
diff --git a/nx-X11/programs/Xserver/Xprint/DiPrint.h b/nx-X11/programs/Xserver/Xprint/DiPrint.h
new file mode 100644
index 000000000..a26477971
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/DiPrint.h
@@ -0,0 +1,81 @@
+/* $Xorg: DiPrint.h,v 1.3 2000/08/17 19:48:04 cpqbld Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/*
+ * The XpDiListEntry struct is the type of each element of the array
+ * handed back to the extension code to handle a GetPrinterList request.
+ * We don't use the printerDb directly because of the desire to handle
+ * multiple locales. Creating this new array for each GetPrinterList
+ * request will allow us to build it with the description in the locale of
+ * the requesting client.
+ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _XpDiPrint_H_
+#define _XpDiPrint_H_ 1
+
+#include "scrnintstr.h"
+
+typedef struct _diListEntry {
+ char *name;
+ char *description;
+ char *localeName;
+ unsigned long rootWinId;
+} XpDiListEntry;
+
+extern void XpDiFreePrinterList(XpDiListEntry **list);
+
+extern XpDiListEntry **XpDiGetPrinterList(
+ int nameLen,
+ char *name,
+ int localeLen,
+ char *locale);
+
+extern char * XpDiGetDriverName(int index, char *printerName);
+
+extern WindowPtr XpDiValidatePrinter(char *printerName, int printerNameLen);
+
+extern int PrinterOptions(int argc, char **argv, int i);
+
+extern void PrinterUseMsg(void);
+
+extern void PrinterInitGlobals(void);
+
+extern void PrinterInitOutput(ScreenInfo *pScreenInfo, int argc, char **argv);
+
+extern void _XpVoidNoop(void);
+
+extern Bool _XpBoolNoop(void);
+
+#endif /* _XpDiPrint_H_ */
diff --git a/nx-X11/programs/Xserver/Xprint/Imakefile b/nx-X11/programs/Xserver/Xprint/Imakefile
new file mode 100644
index 000000000..0e66bf55d
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/Imakefile
@@ -0,0 +1,135 @@
+XCOMM $Xorg: Imakefile,v 1.4 2001/03/14 18:44:11 pookie Exp $
+#include <Server.tmpl>
+
+#ifndef XpRasterDDX
+#define XpRasterDDX YES
+#endif
+#ifndef XpColorPclDDX
+#define XpColorPclDDX YES
+#endif
+#ifndef XpMonoPclDDX
+#define XpMonoPclDDX NO
+#endif
+#ifndef XpPostScriptDDX
+#define XpPostScriptDDX YES
+#endif
+
+SRCS1 = Init.c Quarks.c spooler.c attributes.c Util.c mediaSizes.c \
+ Oid.c AttrValid.c
+
+OBJS1 = Init.o Quarks.o spooler.o attributes.o Util.o mediaSizes.o \
+ Oid.o AttrValid.o
+
+#ifdef OS2Architecture
+SRCS_OS2 = os2_stubs.c
+OBJS_OS2 = os2_stubs.o
+#endif
+
+#if XprtServer
+#if PrintOnlyServer || defined(PrintServerExtensions)
+#if PrintOnlyServer
+PO_DEFINES = -DPRINT_ONLY_SERVER
+#endif
+#endif
+#ifdef PrintServerExtensions
+XPEXT_DEFINES = PrintServerExtensions
+#else
+XPEXT_DEFINES = $(EXT_DEFINES)
+#endif
+SRCS2 = ddxInit.c
+OBJS2 = ddxInit.o
+#endif
+
+SRCS3 = miinitext.c dpmsstubs.c
+OBJS3 = miinitext.o dpmsstubs.o
+
+SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(SRCS_OS2)
+
+OBJS = $(OBJS1) $(OBJS_OS2)
+
+#if XpRasterDDX
+RASTDIR = raster
+RASTDEF = -DXPRASTERDDX
+#endif
+#if XpColorPclDDX
+PCLDIR = pcl
+PCLDEF = -DXPPCLDDX
+#endif
+#if XpMonoPclDDX
+MPCLDIR = pcl-mono
+MPCLDEF = -DXPMONOPCLDDX
+#endif
+#if XpPostScriptDDX
+PSDIR = ps
+PSDEF = -DXPPSDDX
+#endif
+
+#if HasMkstemp
+MKTMP_DEFINES = -DHAS_MKSTEMP
+#endif
+
+#if XpRasterDDX || XpColorPclDDX || XpMonoPclDDX || XpPostScriptDDX
+
+SUBDIRS = $(RASTDIR) $(PCLDIR) $(MPCLDIR) $(PSDIR) etc
+#define IHaveSubdirs
+
+#endif
+
+ INCLUDES = -I$(XINCLUDESRC) -I. -I../mfb -I../mi -I../cfb \
+ -I../include -I$(TOP)/include -I$(LIBSRC) \
+ -I$(EXTINCSRC) -I$(FONTINCSRC) -I$(XLIBSRC)
+
+
+ LINTLIBS = $(TOP)/server/dix/llib-ldix.ln $(TOP)/server/os/llib-los.ln \
+ $(TOP)/server/ddx/mfb/llib-lmfb.ln \
+ $(TOP)/server/ddx/mi/llib-lmi.ln \
+ $(TOP)/server/ddx/cfb/llib-lcfb.ln
+
+DEFINES = -DXPRINTDIR=\"$(XPRINTDIR)\" $(RASTDEF) $(PCLDEF) $(MPCLDEF) \
+ $(PSDEF) $(MKTMP_DEFINES) -UXFree86LOADER -D_XP_PRINT_SERVER_
+
+/* Go ahead: Call me paranoid ... */
+Makefiles::
+ RemoveFiles(Quark.c Xlcint.h Xresource.h Xrm.c XrmI.h)
+
+LinkSourceFile(Quarks.c,$(XLIBSRC))
+
+NormalLibraryObjectRule()
+
+#if XprtServer
+all:: $(OBJS2) $(OBJS_OS2) $(OBJS3)
+#endif
+
+NormalLibraryTarget(printer,$(OBJS))
+NormalLintTarget($(SRCS))
+
+SpecialCObjectRule(ddxInit,$(ICONFIGFILES),$(PO_DEFINES) $(OS_DEFINES) $(EXT_DEFINES))
+#if XprtServer
+LinkSourceFile(miinitext.c,$(SERVERSRC)/mi)
+SpecialCObjectRule(miinitext,$(ICONFIGFILES), -DPRINT_ONLY_SERVER $(OS_DEFINES) $(XPEXT_DEFINES) -DXPRINT)
+LinkSourceFile(dpmsstubs.c,$(SERVERSRC)/Xext)
+LinkSourceFile(dpmsproc.h,$(SERVERSRC)/Xext)
+SpecialCObjectRule(dpmsstubs,$(ICONFIGFILES),$(PO_DEFINES) $(OS_DEFINES) $(XPEXT_DEFINES) -DXPRINT)
+#endif
+
+#ifdef OS2Architecture
+LinkSourceFile(os2_stubs.c,../hw/xfree86/os-support/os2)
+SpecialCObjectRule(os2_stubs,$(ICONFIGFILES),-DOS2NULLSELECT)
+#endif
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+MakeLintLibSubdirs($(SUBDIRS))
+#endif
+
+DependTarget()
+
+InstallManPage(Xprt,$(MANDIR))
+
+#ifdef HasDocBookTools
+all:: Xprt.man Xprt.html
+
+ConvertDocBookToManPage(Xprt.sgml, Xprt.man)
+ConvertDocBookToHTML(Xprt.sgml, Xprt.html)
+#endif /* HasDocBookTools */
diff --git a/nx-X11/programs/Xserver/Xprint/Init.c b/nx-X11/programs/Xserver/Xprint/Init.c
new file mode 100644
index 000000000..0bc1cf39e
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/Init.c
@@ -0,0 +1,1934 @@
+/* $Xorg: Init.c,v 1.5 2001/03/07 17:31:33 pookie Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996-2004 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+(c) Copyright 2003-2004 Roland Mainz <roland.mainz@nrubsig.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: printer/Init.c
+** *
+** * Contents:
+** * The InitOutput routine here would presumably
+** * be called from the normal server's InitOutput
+** * after all display screens have been added.
+** * There is are ifdef'd routines suitable for
+** * use in building a printer-only server. Turn
+** * on the "PRINTER_ONLY_SERVER" define if this is
+** * to be the only ddx-level driver.
+** *
+** * Copyright: Copyright 1993,1995 Hewlett-Packard Company
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <locale.h>
+#ifdef __hpux
+#include <sys/sysmacros.h>
+#endif
+
+#include <X11/X.h>
+#define NEED_EVENTS 1
+#include <X11/Xproto.h>
+#include <servermd.h>
+
+#include "screenint.h"
+#include "input.h"
+#include "cursor.h"
+#include "misc.h"
+#include "windowstr.h"
+#include "inputstr.h"
+
+#include "gcstruct.h"
+#include <X11/fonts/fontstruct.h>
+#include "errno.h"
+
+typedef char *XPointer;
+#define HAVE_XPointer 1
+
+#define Status int
+#include <X11/Xresource.h>
+
+#include "DiPrint.h"
+#include "attributes.h"
+
+#include "os.h"
+#include "spooler.h"
+
+static void GenericScreenInit(
+ int index,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv);
+static Bool InitPrintDrivers(
+ int index,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv);
+
+/*
+ * The following two defines are used to build the name "X*printers", where
+ * the "*" is replaced by the display number. This is used to construct
+ * the name of the default printers configuration file if the -XpFile
+ * command line option was not specified.
+ */
+#define XNPRINTERSFILEPREFIX "/X"
+#define XNPRINTERSFILESUFFIX "printers"
+#define XPRINTERSFILENAME "Xprinters"
+
+#define MODELDIRNAME "/models"
+#define FONTDIRNAME "/fonts"
+
+#ifdef XPRASTERDDX
+
+static
+PixmapFormatRec RasterPixmapFormats[] = {
+ { 1, 1, BITMAP_SCANLINE_PAD }
+};
+#define NUMRASTFORMATS (sizeof RasterPixmapFormats)/(sizeof RasterPixmapFormats[0])
+
+#include "raster/Raster.h"
+
+#endif
+
+#ifdef XPPCLDDX
+
+static
+PixmapFormatRec ColorPclPixmapFormats[] = {
+ { 1, 1, BITMAP_SCANLINE_PAD },
+ { 8, 8, BITMAP_SCANLINE_PAD },
+ { 24, 32, BITMAP_SCANLINE_PAD }
+};
+
+#define NUMCPCLFORMATS (sizeof ColorPclPixmapFormats)/(sizeof ColorPclPixmapFormats[0])
+
+#endif
+
+#ifdef XPMONOPCLDDX
+
+static
+PixmapFormatRec MonoPclPixmapFormats[] = {
+ { 1, 1, BITMAP_SCANLINE_PAD }
+};
+
+#define NUMMPCLFORMATS (sizeof MonoPclPixmapFormats)/(sizeof MonoPclPixmapFormats[0])
+
+#endif
+
+#if defined(XPPCLDDX) || defined(XPMONOPCLDDX)
+#include "pcl/Pcl.h"
+#endif
+
+#ifdef XPPSDDX
+
+static
+PixmapFormatRec PSPixmapFormats[] = {
+ { 1, 1, BITMAP_SCANLINE_PAD },
+ { 8, 8, BITMAP_SCANLINE_PAD },
+ { 12, 16, BITMAP_SCANLINE_PAD },
+ { 14, 16, BITMAP_SCANLINE_PAD },
+ { 16, 16, BITMAP_SCANLINE_PAD },
+ { 24, 32, BITMAP_SCANLINE_PAD }
+};
+
+#define NUMPSFORMATS (sizeof PSPixmapFormats)/(sizeof PSPixmapFormats[0])
+
+#include "ps/Ps.h"
+
+#endif
+
+/*
+ * The driverInitArray contains an entry for each driver the
+ * server knows about. Each element contains pointers to pixmap formats, the
+ * driver's initialization routine, and pointers to the driver's
+ * attribute validation rec, and/or a driver function which
+ * returns the maximum medium width&height, and maximum resolution
+ * given a printer name. Either the validation rec OR the dimension
+ * function can be NULL. If the function is non-NULL then it
+ * will be called, and will be passed the (possibly NULL) validation rec.
+ * If the function is NULL, then XpGetMaxWidthHeightRes() is called.
+ */
+typedef struct _driverInitRec {
+ char *driverName;
+ pBFunc initFunc;
+ XpValidatePoolsRec *pValRec;
+ pVFunc dimensionsFunc;
+ PixmapFormatRec *pFmts;
+ int numFmts;
+} driverInitRec;
+
+static driverInitRec driverInits[] = {
+#ifdef XPRASTERDDX
+ {
+ "XP-RASTER",
+ InitializeRasterDriver,
+ &RasterValidatePoolsRec,
+ (pVFunc) NULL,
+ RasterPixmapFormats,
+ NUMRASTFORMATS
+ },
+#endif
+#ifdef XPPCLDDX
+ {
+ "XP-PCL-COLOR",
+ InitializeColorPclDriver,
+ &PclValidatePoolsRec,
+ (pVFunc) NULL,
+ ColorPclPixmapFormats,
+ NUMCPCLFORMATS
+ },
+#endif
+#ifdef XPMONOPCLDDX
+ {
+ "XP-PCL-MONO",
+ InitializeMonoPclDriver,
+ &PclValidatePoolsRec,
+ (pVFunc) NULL,
+ MonoPclPixmapFormats,
+ NUMMPCLFORMATS
+ },
+#endif
+#ifdef XPPSDDX
+ {
+ "XP-POSTSCRIPT",
+ InitializePsDriver,
+ &PsValidatePoolsRec,
+ (pVFunc) NULL,
+ PSPixmapFormats,
+ NUMPSFORMATS
+ },
+#endif
+};
+
+
+/*
+ * The printerDb variable points to a list of PrinterDbEntry structs
+ * which map printer names with screen numbers and driver names.
+ */
+typedef struct _printerDbEntry {
+ struct _printerDbEntry *next;
+ char *name;
+ char *qualifier;
+ int screenNum;
+ char *driverName;
+ char *desc;
+} PrinterDbEntry, *PrinterDbPtr;
+
+static PrinterDbPtr printerDb = (PrinterDbPtr)NULL;
+
+/*
+ * The nameMap is a list used in initializing the attribute store
+ * for each printer. The list is freed once the printerDb is built
+ * and the attribute stores for all printers have been initialized.
+ */
+typedef struct _nameMapEntry {
+ struct _nameMapEntry *next;
+ char *name;
+ char *qualifier;
+} NameMapEntry, *NameMapPtr;
+
+static NameMapPtr nameMap = (NameMapPtr)NULL;
+
+/*
+ * The driverMap is a list which provides the mapping between driver names
+ * and screen numbers. It is built and used
+ * by RehashPrinterList to correctly fill in the screenNum field in the
+ * printerDb entries. The list is freed before RehashPrinterList terminates.
+ */
+typedef struct _driverMapping {
+ struct _driverMapping *next;
+ char *driverName;
+ int screenNum;
+} DriverMapEntry, *DriverMapPtr;
+
+static const char configFilePath[] =
+"/etc/dt/config/print:/usr/dt/config/print";
+
+static const char printServerConfigDir[] = "XPSERVERCONFIGDIR";
+
+static int printScreenPrivIndex,
+ printWindowPrivIndex,
+ printGCPrivIndex;
+static unsigned long printGeneration = 0;
+static char *configFileName = (char *)NULL;
+static Bool freeDefaultFontPath = FALSE;
+static char *origFontPath = (char *)NULL;
+
+static Bool xprintInitGlobalsCalled = FALSE;
+/*
+ * This function is responsible for doing initalisation of any global
+ * variables at an very early point of server startup (even before
+ * |ProcessCommandLine()|.
+ */
+void PrinterInitGlobals(void)
+{
+ extern char dispatchExceptionAtReset; /* defined in Xserver/dix/dispatch.c */
+
+ xprintInitGlobalsCalled = TRUE;
+
+#ifdef DAMAGE
+ /* Disable DAMAGE extension for now as it does not work with
+ * the Postscript DDX yet (see
+ * https://bugs.freedesktop.org/show_bug.cgi?id=1660) ...
+ * (you can enable the DAMAGE extension explicitly via
+ * % X +extension DAMAGE ... #) ;-( */
+ {
+ extern Bool noDamageExtension;
+ noDamageExtension = TRUE;
+ }
+#endif /* DAMAGE */
+
+#ifdef SMART_SCHEDULE
+ /* Somehow the XF86 "smart scheduler" completely kills the Xprint DDX
+ * (see http://xprint.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=467
+ * ("Xfree86's "smart scheduler" breaks Xprt") */
+ SmartScheduleDisable = TRUE;
+#endif /* SMART_SCHEDULE */
+
+ /* Disable internal screensaver for Xprint (workaround for
+ * http://pdx.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=567 ("Xorg
+ * Xprt starts to consume 100% CPU when being idle for some time")) */
+ defaultScreenSaverTime = 0;
+
+ /* Ensure that the maximum request size for the BIGREQUESTS extension
+ * is at least 8MB (see
+ * http://xprint.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=622 - "RFE:
+ * Xprt's default BIGREQUESTS extension buffer size should be 8MB")
+ */
+ maxBigRequestSize = (8*1048576)-1;
+
+ /* Xprt should not reset by default when the last client exists
+ * (default for Xprt is |0|, video Xservers use |DE_RESET|) */
+ dispatchExceptionAtReset = 0;
+}
+
+/*
+ * PrinterUseMsg() prints usage for the Xprint-specific options
+ */
+void PrinterUseMsg(void)
+{
+ XpSpoolerTypePtr curr = xpstm;
+
+ /* Option '-XpFile' */
+ ErrorF("-XpFile file specifies an alternate `Xprinters' file, rather\n");
+ ErrorF(" than the default one (e.g.\n");
+ ErrorF(" `${XPCONFIGDIR}/${LANG}/print/Xprinters') or\n");
+ ErrorF(" `${XPCONFIGDIR}/C/print/Xprinters'.\n");
+
+ /* Option '-XpSpoolerType' */
+ ErrorF("-XpSpoolerType string specifies a spooler type.\n");
+ ErrorF(" Supported values are:\n");
+
+ while( curr->name != NULL )
+ {
+ ErrorF(" - '%s'\n", curr->name);
+ curr++;
+ }
+ ErrorF(" (multiple values can be specified, seperated by ':',\n");
+ ErrorF(" the first active spooler will be chosen).\n");
+ ErrorF(" default is '%s'.\n", XPDEFAULTSPOOLERNAMELIST);
+}
+
+/*
+ * PrinterOptions checks argv[i] to see if it is our command line
+ * option specifying a configuration file name. It returns the index
+ * of the next option to process.
+ */
+int
+PrinterOptions(
+ int argc,
+ char **argv,
+ int i)
+{
+ extern void ddxUseMsg();
+ if(strcmp(argv[i], "-XpFile") == 0)
+ {
+ if ((i + 1) >= argc) {
+ ddxUseMsg ();
+ return i + 2;
+ }
+ configFileName = argv[i + 1];
+ return i + 2;
+ }
+ else if(strcmp(argv[i], "-XpSpoolerType") == 0)
+ {
+ if ((i + 1) >= argc) {
+ ddxUseMsg ();
+ return i + 2;
+ }
+ XpSetSpoolerTypeNameList(argv[i + 1]);
+ return i + 2;
+ }
+ else
+ {
+ return i;
+ }
+}
+
+/************************************************************
+ * GetInitFunc --
+ *
+ * This routine is called from the InitPrintDrivers function.
+ * Given the name of a driver, return a pointer to the driver's
+ * initialization function.
+ *
+ * Results:
+ * Returns a pointer to the initialization function for the driver.
+ *
+ *
+ ************************************************************/
+
+/*
+typedef Bool (*pIFunc)();
+static pIFunc
+GetInitFunc(driverName)
+*/
+
+static pBFunc GetInitFunc(char *driverName)
+{
+ driverInitRec *pInitRec;
+ int numDrivers = sizeof(driverInits)/sizeof(driverInitRec);
+ int i;
+
+ for(pInitRec = driverInits, i = 0; i < numDrivers; pInitRec++, i++)
+ {
+ if( !strcmp( driverName, pInitRec->driverName ) )
+ return pInitRec->initFunc;
+ }
+
+ return 0;
+}
+
+static void
+GetDimFuncAndRec(
+ char *driverName,
+ XpValidatePoolsRec **pValRec,
+ pVFunc *dimensionsFunc)
+{
+ driverInitRec *pInitRec;
+ int numDrivers = sizeof(driverInits)/sizeof(driverInitRec);
+ int i;
+
+ for(pInitRec = driverInits, i = 0; i < numDrivers; pInitRec++, i++)
+ {
+ if( !strcmp( driverName, pInitRec->driverName ) )
+ {
+ *dimensionsFunc = pInitRec->dimensionsFunc;
+ *pValRec = pInitRec->pValRec;
+ return ;
+ }
+ }
+
+ *dimensionsFunc = 0;
+ *pValRec = 0;
+ return;
+}
+
+static void
+FreePrinterDb(void)
+{
+ PrinterDbPtr pCurEntry, pNextEntry;
+
+ for(pCurEntry = printerDb, pNextEntry = (PrinterDbPtr)NULL;
+ pCurEntry != (PrinterDbPtr)NULL; pCurEntry = pNextEntry)
+ {
+ pNextEntry = pCurEntry->next;
+ if(pCurEntry->name != (char *)NULL)
+ xfree(pCurEntry->name);
+ if(pCurEntry->desc != (char *)NULL)
+ xfree(pCurEntry->desc);
+ /*
+ * We don't free the driver name, because it's expected to simply
+ * be a pointer into the xrm database.
+ */
+ xfree(pCurEntry);
+ }
+ printerDb = (PrinterDbPtr)NULL;
+}
+
+/*
+ * AddPrinterDbName allocates an entry in the printerDb list, and
+ * initializes the "name". It returns TRUE if the element was
+ * successfully added, and FALSE if an allocation error ocurred.
+ * XXX AddPrinterDbName needs to check for (and not add) duplicate names.
+ */
+static Bool
+AddPrinterDbName(char *name, char *desc)
+{
+ PrinterDbPtr pEntry = (PrinterDbPtr)xalloc(sizeof(PrinterDbEntry));
+
+ if(pEntry == (PrinterDbPtr)NULL) return FALSE;
+ pEntry->name = (name != NULL) ? strdup(name) : NULL;
+ pEntry->desc = (desc != NULL) ? strdup(desc) : NULL;
+ pEntry->qualifier = (char *)NULL;
+
+ if(printerDb == (PrinterDbPtr)NULL)
+ {
+ pEntry->next = (PrinterDbPtr)NULL;
+ printerDb = pEntry;
+ }
+ else
+ {
+ pEntry->next = printerDb;
+ printerDb = pEntry;
+ }
+ return TRUE;
+}
+
+static int
+AugmentPrinterDb(const char *command)
+{
+ FILE *fp;
+ char name[256];
+ int num_printers = 0; /* Number of printers we found */
+ size_t namelen;
+ char *desc = NULL;
+
+ fp = popen(command, "r");
+ /* XXX is a 256 character limit overly restrictive for printer names? */
+ while(fgets(name, 256, fp) != (char *)NULL && (namelen=strlen(name)))
+ {
+ char *option = name;
+
+ name[namelen-1] = (char)'\0'; /* strip the \n */
+
+#define XP_DESCRIPTOR "xp-printerattr.descriptor="
+#define XP_DESCRIPTOR_LEN (sizeof(XP_DESCRIPTOR)-1)
+ while ((option = strchr(option, '\t'))) {
+ option++; /* Skip the '\t' */
+ if (!strncmp(option, XP_DESCRIPTOR, XP_DESCRIPTOR_LEN)) {
+ *(option-1) = '\0'; /* Kill the '\t' (only if we found a valid option) */
+ option += XP_DESCRIPTOR_LEN;
+ if (*option != '\0') {
+ desc = option;
+ }
+ }
+ else
+ {
+ /* Unknown option */
+ ErrorF("AugmentPrinterDb: Unknown option '%s'\n", option);
+ }
+ }
+ AddPrinterDbName(name, desc);
+ num_printers++;
+ }
+ pclose(fp);
+ return num_printers;
+}
+
+/*
+ * FreeNameMap frees all remaining memory associated with the nameMap.
+ */
+static void
+FreeNameMap(void)
+{
+ NameMapPtr pEntry, pTmp;
+
+ for(pEntry = nameMap, pTmp = (NameMapPtr)NULL;
+ pEntry != (NameMapPtr)NULL;
+ pEntry = pTmp)
+ {
+ if(pEntry->name != (char *)NULL)
+ xfree(pEntry->name);
+ if(pEntry->qualifier != (char *)NULL)
+ xfree(pEntry->qualifier);
+ pTmp = pEntry->next;
+ xfree(pEntry);
+ }
+ nameMap = (NameMapPtr)NULL;
+}
+
+/*
+ * AddNameMap adds an element to the nameMap linked list.
+ */
+static Bool
+AddNameMap(char *name, char *qualifier)
+{
+ NameMapPtr pEntry;
+
+ if((pEntry = (NameMapPtr)xalloc(sizeof(NameMapEntry))) == (NameMapPtr)NULL)
+ return FALSE;
+ pEntry->name = name;
+ pEntry->qualifier = qualifier;
+ pEntry->next = nameMap;
+ nameMap = pEntry;
+ return TRUE;
+}
+
+/*
+ * MergeNameMap - puts the "map" names (aka qualifiers, aliases) into
+ * the printerDb. This should be called once, after both the printerDb
+ * and nameMap lists are complete. When/if MergeNameMap finds a map for
+ * an entry in the printerDb, the qualifier is _moved_ (not copied) to
+ * the printerDb. This means that the qualifier pointer in the nameMap
+ * is NULLed out.
+ */
+static void
+MergeNameMap(void)
+{
+ NameMapPtr pMap;
+ PrinterDbPtr pDb;
+
+ for(pMap = nameMap; pMap != (NameMapPtr)NULL; pMap = pMap->next)
+ {
+ for(pDb = printerDb; pDb != (PrinterDbPtr)NULL; pDb = pDb->next)
+ {
+ if(!strcmp(pMap->name, pDb->name))
+ {
+ pDb->qualifier = pMap->qualifier;
+ pMap->qualifier = (char *)NULL;
+ }
+ }
+ }
+}
+
+/*
+ * CreatePrinterAttrs causes the attribute stores to be built for
+ * each printer in the printerDb.
+ */
+static void
+CreatePrinterAttrs(void)
+{
+ PrinterDbPtr pDb;
+
+ for(pDb = printerDb; pDb != (PrinterDbPtr)NULL; pDb = pDb->next)
+ {
+ XpBuildAttributeStore(pDb->name, (pDb->qualifier)?
+ pDb->qualifier : pDb->name);
+ }
+}
+
+#ifdef XPPSDDX
+#define defaultDriver "XP-POSTSCRIPT"
+#else
+#ifdef XPPCLDDX
+#define defaultDriver "XP-PCL-COLOR"
+#else
+#ifdef XPMONOPCLDDX
+#define defaultDriver "XP-PCL-MONO"
+#else
+#define defaultDriver "XP-RASTER"
+#endif
+#endif
+#endif
+
+/*
+ * StoreDriverNames - queries the attribute store for the ddx-identifier.
+ * if the ddx-identifier is not in the attribute database, then a default
+ * ddx-identifier is store in both the attribute store for the printer,
+ * and in the printerDb.
+ * The ddx-identifier is stored in the printerDb for use in initializing
+ * the screens.
+ */
+static void
+StoreDriverNames(void)
+{
+ PrinterDbPtr pEntry;
+
+ for(pEntry = printerDb; pEntry != (PrinterDbPtr)NULL;
+ pEntry = pEntry->next)
+ {
+ pEntry->driverName = (char*)XpGetPrinterAttribute(pEntry->name,
+ "xp-ddx-identifier");
+ if(pEntry->driverName == (char *)NULL ||
+ strlen(pEntry->driverName) == 0 ||
+ GetInitFunc(pEntry->driverName) == (Bool(*)())NULL)
+ {
+ if (pEntry->driverName && (strlen(pEntry->driverName) != 0)) {
+ ErrorF("Xp Extension: Can't load driver %s\n",
+ pEntry->driverName);
+ ErrorF(" init function missing\n");
+ }
+
+ pEntry->driverName = defaultDriver;
+ XpAddPrinterAttribute(pEntry->name,
+ (pEntry->qualifier != (char *)NULL)?
+ pEntry->qualifier : pEntry->name,
+ "*xp-ddx-identifier", pEntry->driverName);
+ }
+ }
+}
+
+/*
+ * StoreDescriptors - queries the attribute store for the descriptor.
+ * if the descriptor is not in the attribute database, then the descriptor
+ * from the printerDb is store in the attribute store for the printer.
+ */
+static void
+StoreDescriptors()
+{
+ PrinterDbPtr pEntry;
+
+ for(pEntry = printerDb; pEntry != (PrinterDbPtr)NULL;
+ pEntry = pEntry->next)
+ {
+ if (pEntry->desc != NULL)
+ {
+ XpAddPrinterAttribute(pEntry->name,
+ (pEntry->qualifier != (char *)NULL)?
+ pEntry->qualifier : pEntry->name,
+ "*descriptor", pEntry->desc);
+ }
+ }
+}
+
+static char *
+MbStrchr(
+ char *str,
+ int ch)
+{
+ size_t mbCurMax = MB_CUR_MAX;
+ wchar_t targetChar, curChar;
+ char tmpChar;
+ int i, numBytes, byteLen;
+
+ if(mbCurMax <= 1) return strchr(str, ch);
+
+ tmpChar = (char)ch;
+ mbtowc(&targetChar, &tmpChar, mbCurMax);
+ for(i = 0, numBytes = 0, byteLen = strlen(str); i < byteLen; i += numBytes)
+ {
+ numBytes = mbtowc(&curChar, &str[i], mbCurMax);
+ if(curChar == targetChar) return &str[i];
+ }
+ return (char *)NULL;
+}
+
+/*
+ * GetConfigFileName - Looks for a "Xprinters" file in
+ * $(XPRINTDIR)/$LANG/print, and then in $(XPRINTDIR)/C/print. If it
+ * finds such a file, it returns the path to the file. The returned
+ * string must be freed by the caller.
+ */
+static char *
+GetConfigFileName(void)
+{
+ /*
+ * We need to find the system-wide file, if one exists. This
+ * file can be in either $(XPRINTDIR)/$LANG/print, or in
+ * $(PRINTDIR)/C/print, and the file itself is named "Xprinters".
+ */
+ char *dirName, *filePath;
+
+ /*
+ * Check for a LANG-specific file.
+ */
+ if((dirName = XpGetConfigDir(TRUE)))
+ {
+ filePath = (char *)xalloc(strlen(dirName) +
+ strlen(XPRINTERSFILENAME) + 2);
+
+ if(filePath == (char *)NULL)
+ {
+ xfree(dirName);
+ return (char *)NULL;
+ }
+
+ sprintf(filePath, "%s/%s", dirName, XPRINTERSFILENAME);
+ xfree(dirName);
+ if(access(filePath, R_OK) == 0)
+ return filePath;
+
+ xfree(filePath);
+ }
+
+ if((dirName = XpGetConfigDir(FALSE)))
+ {
+ filePath = (char *)xalloc(strlen(dirName) +
+ strlen(XPRINTERSFILENAME) + 2);
+ if(filePath == (char *)NULL)
+ {
+ xfree(dirName);
+ return (char *)NULL;
+ }
+ sprintf(filePath, "%s/%s", dirName, XPRINTERSFILENAME);
+ xfree(dirName);
+ if(access(filePath, R_OK) == 0)
+ return filePath;
+ xfree(filePath);
+ }
+ return (char *)NULL;
+}
+
+/*
+ * BuildPrinterDb - reads the config file if it exists, and if necessary
+ * executes a command such as lpstat to generate a list of printers.
+ * XXX
+ * XXX BuildPrinterDb must be rewritten to allow 16-bit characters in
+ * XXX printer names. The will involve replacing the use of strtok() and its
+ * XXX related functions.
+ * XXX At the same time, BuildPrinterDb and it's support routines should have
+ * XXX allocation error checking added.
+ * XXX
+ */
+static PrinterDbPtr
+BuildPrinterDb(void)
+{
+ char *printerList, *augmentCmd = (char *)NULL;
+ Bool defaultAugment = TRUE, freeConfigFileName;
+
+ if(configFileName && access(configFileName, R_OK) != 0)
+ {
+ ErrorF("Xp Extension: Can't open file %s\n", configFileName);
+ }
+ if(!configFileName && (configFileName = GetConfigFileName()))
+ freeConfigFileName = TRUE;
+ else
+ freeConfigFileName = FALSE;
+
+ if(configFileName != (char *)NULL && access(configFileName, R_OK) == 0)
+ {
+ char line[256];
+ FILE *fp = fopen(configFileName, "r");
+
+ while(fgets(line, 256, fp) != (char *)NULL)
+ {
+ char *tok, *ptr;
+ if((tok = strtok(line, " \t\012")) != (char *)NULL)
+ {
+ if(tok[0] == (char)'#') continue;
+ if(strcmp(tok, "Printer") == 0)
+ {
+ while((tok = strtok((char *)NULL, " \t")) != (char *)NULL)
+ {
+ if((ptr = MbStrchr(tok, '\012')))
+ *ptr = (char)'\0';
+ AddPrinterDbName(tok, NULL);
+ }
+ }
+ else if(strcmp(tok, "Map") == 0)
+ {
+ char *name, *qualifier;
+
+ if((tok = strtok((char *)NULL, " \t\012")) == (char *)NULL)
+ continue;
+ name = strdup(tok);
+ if((tok = strtok((char *)NULL, " \t\012")) == (char *)NULL)
+ {
+ xfree(name);
+ continue;
+ }
+ qualifier = strdup(tok);
+ AddNameMap(name, qualifier);
+ }
+ else if(strcmp(tok, "Augment_Printer_List") == 0)
+ {
+ if((tok = strtok((char *)NULL, " \t\012")) == (char *)NULL)
+ continue;
+
+ if(strcmp(tok, "%default%") == 0)
+ continue;
+ defaultAugment = FALSE;
+ if(strcmp(tok, "%none%") == 0)
+ continue;
+ AugmentPrinterDb(tok);
+ }
+ else
+ break; /* XXX Generate an error? */
+ }
+ }
+ fclose(fp);
+ }
+
+ if(defaultAugment == TRUE)
+ {
+ XpSpoolerTypePtr curr_spooler_type; /* spooler we are currently probing for queues */
+ int num_printers_found; /* number of printers found by |AugmentPrinterDb()| */
+ char *tok_lasts; /* strtok_r() position token */
+ char *spnamelist; /* list of spooler names, seperated by ":" */
+ char *spname; /* spooler name */
+
+ spnamelist = strdup(XpGetSpoolerTypeNameList()); /* strtok_r() modifies string so dup' it first */
+
+ for( spname = strtok_r(spnamelist, ":", &tok_lasts) ;
+ spname != NULL ;
+ spname = strtok_r(NULL, ":", &tok_lasts) )
+ {
+ curr_spooler_type = XpSpoolerNameToXpSpoolerType(spname);
+ if(!curr_spooler_type)
+ {
+ FatalError("BuildPrinterDb: No spooler type entry found for '%s'.\n", spname);
+ }
+
+ if(curr_spooler_type->list_queues_command == NULL ||
+ strlen(curr_spooler_type->list_queues_command) == 0)
+ {
+ continue;
+ }
+
+ num_printers_found = AugmentPrinterDb(curr_spooler_type->list_queues_command);
+ /* Did we found a spooler which works ? */
+ if(num_printers_found > 0)
+ {
+ spooler_type = curr_spooler_type;
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "BuildPrinterDb: using '%s'.\n", spooler_type->name);
+#endif /* DEBUG_gisburn */
+ break;
+ }
+ }
+
+ free(spnamelist);
+ }
+
+ MergeNameMap();
+ FreeNameMap();
+
+ /* Create the attribute stores for all printers */
+ CreatePrinterAttrs();
+
+ /*
+ * Find the drivers for each printers, and store the driver names
+ * in the printerDb
+ */
+ StoreDriverNames();
+ StoreDescriptors();
+
+ if(freeConfigFileName)
+ {
+ xfree(configFileName);
+ configFileName = (char *)NULL;
+ }
+
+ return printerDb;
+}
+
+static void
+FreeDriverMap(DriverMapPtr driverMap)
+{
+ DriverMapPtr pCurEntry, pNextEntry;
+
+ for(pCurEntry = driverMap, pNextEntry = (DriverMapPtr)NULL;
+ pCurEntry != (DriverMapPtr)NULL; pCurEntry = pNextEntry)
+ {
+ pNextEntry = pCurEntry->next;
+ if(pCurEntry->driverName != (char *)NULL)
+ xfree(pCurEntry->driverName);
+ xfree(pCurEntry);
+ }
+}
+
+/*
+ * XpRehashPrinterList rebuilds the list of printers known to the
+ * server. It first walks the printerDb to build a table mapping
+ * driver names and screen numbers, since this is not an easy mapping
+ * to change in the sample server. The normal configuration files are
+ * then read & parsed to create the new list of printers. Printers
+ * which require drivers other than those already initialized are
+ * deleted from the printerDb. This leaves attribute stores in place
+ * for inaccessible printers, but those stores will be cleaned up in
+ * the next rehash or server recycle.
+ */
+int
+XpRehashPrinterList(void)
+{
+ PrinterDbPtr pEntry, pPrev;
+ DriverMapPtr driverMap = (DriverMapPtr)NULL, pDrvEnt;
+ int result;
+
+ /* Build driverMap */
+ for(pEntry = printerDb; pEntry != (PrinterDbPtr)NULL; pEntry = pEntry->next)
+ {
+ for(pDrvEnt = driverMap; pDrvEnt != (DriverMapPtr)NULL;
+ pDrvEnt = pDrvEnt->next)
+ {
+ if(!strcmp(pEntry->driverName, pDrvEnt->driverName))
+ break;
+ }
+
+ if(pDrvEnt != (DriverMapPtr)NULL)
+ continue;
+
+ if((pDrvEnt = (DriverMapPtr)xalloc(sizeof(DriverMapEntry))) ==
+ (DriverMapPtr)NULL)
+ {
+ FreeDriverMap(driverMap);
+ return BadAlloc;
+ }
+ pDrvEnt->driverName = strdup(pEntry->driverName);
+ pDrvEnt->screenNum = pEntry->screenNum;
+ pDrvEnt->next = driverMap;
+ driverMap = pDrvEnt;
+ }
+
+ /* Free the old printerDb */
+ FreePrinterDb();
+
+ /* Free/Rehash attribute stores */
+ if((result = XpRehashAttributes()) != Success)
+ return result;
+
+ /* Build a new printerDb */
+ if(BuildPrinterDb() == (PrinterDbPtr)NULL)
+ return BadAlloc;
+
+ /* Walk PrinterDb & either store screenNum, or delete printerDb entry */
+ for(pEntry = printerDb, pPrev = (PrinterDbPtr)NULL;
+ pEntry != (PrinterDbPtr)NULL; pEntry = pEntry->next)
+ {
+ for(pDrvEnt = driverMap; pDrvEnt != (DriverMapPtr)NULL;
+ pDrvEnt = pDrvEnt->next)
+ {
+ if(!strcmp(printerDb->driverName, pDrvEnt->driverName))
+ break;
+ }
+
+ /*
+ * Either store the screen number, or delete the printerDb entry.
+ * Deleting the entry leaves orphaned attribute stores, but they'll
+ * get cleaned up at the next rehash or server recycle.
+ */
+ if(pDrvEnt != (DriverMapPtr)NULL)
+ {
+ pEntry->screenNum = pDrvEnt->screenNum;
+ pPrev = pEntry;
+ }
+ else {
+ if(pPrev)
+ pPrev->next = pEntry->next;
+ else
+ pPrev = pEntry->next;
+ if(pEntry->name != (char *)NULL)
+ xfree(pEntry->name);
+ xfree(pEntry);
+ pEntry = pPrev;
+ }
+ }
+
+ FreeDriverMap(driverMap);
+
+ return Success;
+}
+
+/*
+ * ValidateFontDir looks for a valid font directory for the specified
+ * printer model within the specified configuration directory. It returns
+ * the directory name, or NULL if no valid font directory was found.
+ * It is the caller's responsibility to free the returned font directory
+ * name.
+ */
+static char *
+ValidateFontDir(
+ char *configDir,
+ char *modelName)
+{
+ char *pathName;
+
+ if(!configDir || !modelName)
+ return (char *)NULL;
+
+ pathName = (char *)xalloc(strlen(configDir) + strlen(MODELDIRNAME) +
+ strlen(modelName) + strlen(FONTDIRNAME) +
+ strlen("fonts.dir") + 5);
+ if(!pathName)
+ return (char *)NULL;
+ sprintf(pathName, "%s/%s/%s/%s/%s", configDir, MODELDIRNAME, modelName,
+ FONTDIRNAME, "fonts.dir");
+ if(access(pathName, R_OK) != 0)
+ {
+ xfree(pathName);
+ return (char *)NULL;
+ }
+ pathName[strlen(pathName) - 9] = (char)'\0'; /* erase fonts.dir */
+ return pathName;
+}
+
+/*
+ * FindFontDir returns a pointer to the path name of the font directory
+ * for the specified printer model name, if such a directory exists.
+ * The directory contents are superficially checked for validity.
+ * The caller must free the returned char *.
+ *
+ * We first look in the locale-specific model-config directory, and
+ * then fall back to the C language model-config directory.
+ */
+static char *
+FindFontDir(
+ char *modelName)
+{
+ char *configDir, *fontDir;
+
+ if(!modelName || !strlen(modelName))
+ return (char *)NULL;
+
+ configDir = XpGetConfigDir(TRUE);
+ if((fontDir = ValidateFontDir(configDir, modelName)))
+ {
+ xfree(configDir);
+ return fontDir;
+ }
+
+ if(configDir)
+ xfree(configDir);
+ configDir = XpGetConfigDir(FALSE);
+ fontDir = ValidateFontDir(configDir, modelName);
+
+ xfree(configDir);
+
+ return fontDir;
+}
+
+/*
+ * AddToFontPath adds the specified font path element to the global
+ * defaultFontPath string. It adds the keyword "PRINTER:" to the front
+ * of the path to denote that this is a printer-specific font path
+ * element.
+ */
+static char PATH_PREFIX[] = "PRINTER:";
+static int PATH_PREFIX_LEN = sizeof(PATH_PREFIX) - 1; /* same as strlen() */
+
+static void
+AddToFontPath(
+ char *pathName)
+{
+ char *newPath;
+ Bool freeOldPath;
+
+ if(defaultFontPath == origFontPath)
+ freeOldPath = FALSE;
+ else
+ freeOldPath = TRUE;
+
+ newPath = (char *)xalloc(strlen(defaultFontPath) + strlen(pathName) +
+ PATH_PREFIX_LEN + 2);
+
+ sprintf(newPath, "%s%s,%s", PATH_PREFIX, pathName, defaultFontPath);
+
+ if(freeOldPath)
+ xfree(defaultFontPath);
+
+ defaultFontPath = newPath;
+ return;
+}
+
+/*
+ * AugmentFontPath adds printer-model-specific font path elements to
+ * the front of the font path global variable "defaultFontPath" (dix/globals.c).
+ * We can't call SetFontPath() because the font code has not yet been
+ * initialized when InitOutput is called (from whence this routine is called).
+ *
+ * This utilizes the static variables origFontPath and
+ * freeDefaultFontPath to track the original contents of defaultFontPath,
+ * and to properly free the modified version upon server recycle.
+ */
+static void
+AugmentFontPath(void)
+{
+ char *newPath, *modelID, **allIDs = (char **)NULL;
+ PrinterDbPtr pDb, pDbEntry;
+ int numModels, i;
+
+ if(!origFontPath)
+ origFontPath = defaultFontPath;
+
+ if(freeDefaultFontPath)
+ {
+ xfree(defaultFontPath);
+ defaultFontPath = origFontPath;
+ freeDefaultFontPath = FALSE;
+ }
+
+ /*
+ * Build a list of printer models to check for internal fonts.
+ */
+ for(pDbEntry = printerDb, numModels = 0;
+ pDbEntry != (PrinterDbPtr)NULL;
+ pDbEntry = pDbEntry->next)
+ {
+ modelID =
+ (char*)XpGetPrinterAttribute(pDbEntry->name,
+ "xp-model-identifier");
+
+ if(modelID && strlen(modelID) != 0)
+ {
+ /* look for current model in the list of allIDs */
+ for(i = 0; i < numModels; i++)
+ {
+ if(!strcmp(modelID, allIDs[i]))
+ {
+ modelID = (char *)NULL;
+ break;
+ }
+ }
+ }
+
+ /*
+ * If this printer's model-identifier isn't in the allIDs list,
+ * then add it to allIDs.
+ */
+ if(modelID && strlen(modelID) != 0)
+ {
+ allIDs = (char **)xrealloc(allIDs, (numModels+2) * sizeof(char *));
+ if(allIDs == (char **)NULL)
+ return;
+ allIDs[numModels] = modelID;
+ allIDs[numModels + 1] = (char *)NULL;
+ numModels++;
+ }
+ }
+
+ /* for each model, check for a valid font directory, and add it to
+ * the front of defaultFontPath.
+ */
+ for(i = 0; allIDs != (char **)NULL && allIDs[i] != (char *)NULL; i ++)
+ {
+ char *fontDir;
+ if((fontDir = FindFontDir(allIDs[i])))
+ {
+ AddToFontPath(fontDir);
+ xfree(fontDir);
+ freeDefaultFontPath = TRUE;
+ }
+ }
+
+ if(allIDs)
+ xfree(allIDs);
+
+ return;
+}
+
+/*
+ * XpClientIsBitmapClient is called by the font code to find out if
+ * a particular client should be granted access to bitmap fonts.
+ * This function works by
+ * calling XpContextOfClient (in Xserver/Xext/xprint.c) to determine
+ * the context associated with the client, and then queries the context's
+ * attributes to determine whether the bitmap fonts should be visible.
+ * It looks at the value of the xp-listfonts-modes document/page attribute to
+ * see if xp-list-glyph-fonts has been left out of the mode list. Only
+ * if the xp-listfonts-modes attribute exists, and it does not contain
+ * xp-list-glyph-fonts does this function return FALSE. In any other
+ * case the funtion returns TRUE, indicating that the bitmap fonts
+ * should be visible to the client.
+ */
+Bool
+XpClientIsBitmapClient(
+ ClientPtr client)
+{
+ XpContextPtr pContext;
+ char *mode;
+
+ if(!(pContext = XpContextOfClient(client)))
+ return TRUE;
+
+ /*
+ * Check the page attributes, and if it's not defined there, then
+ * check the document attributes.
+ */
+ mode = XpGetOneAttribute(pContext, XPPageAttr, "xp-listfonts-modes");
+ if(!mode || !strlen(mode))
+ {
+ mode = XpGetOneAttribute(pContext, XPDocAttr, "xp-listfonts-modes");
+ if(!mode || !strlen(mode))
+ return TRUE;
+ }
+
+ if(!strstr(mode, "xp-list-glyph-fonts"))
+ return FALSE;
+
+ return TRUE;
+}
+
+/*
+ * XpClientIsPrintClient is called by the font code to find out if
+ * a particular client has set a context which references a printer
+ * which utilizes a particular font path.
+ * This function works by calling XpContextOfClient
+ * (in Xserver/Xext/xprint.c) to determine the context associated with
+ * the client and then looks at the value of the xp-listfonts-modes
+ * document/page attribute to see if xp-list-internal-printer-fonts has
+ * been left out of the mode list.
+ * If the xp-listfonts-modes attribute exists, and it does not contain
+ * xp-list-internal-printer-fonts this function returns FALSE.
+ * Otherwise it looks up the font directory for the context. The font
+ * directory is then compared with the directory specified in the
+ * FontPathElement which is passed in.
+ */
+Bool
+XpClientIsPrintClient(
+ ClientPtr client,
+ FontPathElementPtr fpe)
+{
+ XpContextPtr pContext;
+ char *mode;
+ char *modelID, *fontDir;
+
+ if(!(pContext = XpContextOfClient(client)))
+ return FALSE;
+
+ /*
+ * Check the page attributes, and if it's not defined there, then
+ * check the document attributes.
+ */
+ mode = XpGetOneAttribute(pContext, XPPageAttr, "xp-listfonts-modes");
+ if(!mode || !strlen(mode))
+ {
+ mode = XpGetOneAttribute(pContext, XPDocAttr, "xp-listfonts-modes");
+ }
+
+ if(mode && strlen(mode))
+ {
+ if(!strstr(mode, "xp-list-internal-printer-fonts"))
+ return FALSE;
+ }
+
+ if (!fpe)
+ return TRUE;
+
+ modelID = XpGetOneAttribute(pContext, XPPrinterAttr, "xp-model-identifier");
+ if(!modelID || !strlen(modelID))
+ return FALSE;
+
+ if(!(fontDir = FindFontDir(modelID)))
+ return FALSE;
+
+ /*
+ * The grunge here is to ignore the PATH_PREFIX at the front of the
+ * fpe->name.
+ */
+ if(fpe->name_length < PATH_PREFIX_LEN ||
+ (strlen(fontDir) != (fpe->name_length - PATH_PREFIX_LEN)) ||
+ strncmp(fontDir, fpe->name + PATH_PREFIX_LEN,
+ fpe->name_length - PATH_PREFIX_LEN))
+ {
+ xfree(fontDir);
+ return FALSE;
+ }
+ xfree(fontDir);
+ return TRUE;
+}
+
+static void
+AddFormats(ScreenInfo *pScreenInfo, char *driverName)
+{
+ int i, j;
+ driverInitRec *pInitRec;
+ int numDrivers = sizeof(driverInits)/sizeof(driverInitRec);
+ PixmapFormatRec *formats;
+ int numfmts;
+
+ for (pInitRec = driverInits, i = 0; i < numDrivers; pInitRec++, i++)
+ {
+ if ( !strcmp( driverName, pInitRec->driverName ) )
+ break;
+ }
+ if (i >= numDrivers)
+ return;
+ formats = pInitRec->pFmts;
+ numfmts = pInitRec->numFmts;
+ for (i = 0; i < numfmts && pScreenInfo->numPixmapFormats < MAXFORMATS; i++)
+ {
+ for (j = 0; j < pScreenInfo->numPixmapFormats; j++) {
+ if (pScreenInfo->formats[j].depth == formats[i].depth &&
+ pScreenInfo->formats[j].bitsPerPixel == formats[i].bitsPerPixel &&
+ pScreenInfo->formats[j].scanlinePad == formats[i].scanlinePad)
+ break;
+ }
+ if (j == pScreenInfo->numPixmapFormats) {
+ pScreenInfo->formats[j] = formats[i];
+ pScreenInfo->numPixmapFormats++;
+ }
+ }
+}
+
+/************************************************************
+ * PrinterInitOutput --
+ * This routine is to be called from a ddx's InitOutput
+ * during the server startup initialization, and when
+ * the server is to be reset. The routine creates the
+ * screens associated with configured printers by calling
+ * dix:AddScreen. The configuration information comes from a
+ * database read from the X*printers file.
+ *
+ * Results:
+ * The array of ScreenRec pointers referenced by
+ * pScreenInfo->screen is increased by the addition
+ * of the printer screen(s), as is the value of
+ * pScreenInfo->numScreens. This is done via calls
+ * to AddScreen() in dix.
+ *
+ ************************************************************/
+
+void
+PrinterInitOutput(
+ ScreenInfo *pScreenInfo,
+ int argc,
+ char **argv)
+{
+ PrinterDbPtr pDb, pDbEntry;
+ int driverCount = 0, i;
+ char **driverNames;
+ char *configDir;
+
+ /* This should NEVER happen, but... */
+ if( !xprintInitGlobalsCalled )
+ {
+ FatalError("Internal error: PrinterInitGlobals() not called.");
+ }
+#ifdef SMART_SCHEDULE
+ /* |PrinterInitGlobals| should have set |SmartScheduleDisable| to
+ * |TRUE| - if not we will trigger this safeguard. */
+ if( SmartScheduleDisable != TRUE )
+ {
+ FatalError("Internal error: XF86 smart scheduler incompatible to Xprint DDX.");
+ }
+#endif /* SMART_SCHEDULE */
+ /* Safeguard for
+ * http://pdx.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=567 ("Xorg
+ * Xprt starts to consume 100% CPU when being idle for some time")
+ * |PrinterInitGlobals| should have set |defaultScreenSaverTime| to
+ * |0| - if not we will trigger this trap. */
+ if( defaultScreenSaverTime != 0 )
+ {
+ FatalError("Internal screen saver must be OFF for printing.");
+ }
+
+ /* Print a warnung when the maximum request size of the BIGREQUESTS
+ * extension is smaller than 8MB (see
+ * http://xprint.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=622)
+ */
+ if (maxBigRequestSize < (8*1048576)-1) {
+ ErrorF("Xp Extension: BIGREQUESTS max. request is currently %ld bytes "
+ ", recommemded minimum for Xprint is 8MB.\n", (long)maxBigRequestSize);
+ }
+
+ /*
+ * this little test is just a warning at startup to make sure
+ * that the config directory exists.
+ *
+ * what this ugly looking if says is that if both ways of
+ * calling configDir works and both directories don't exist,
+ * then print an error saying we can't find the non-lang one.
+ */
+ if (((configDir = XpGetConfigDir(TRUE)) != NULL) &&
+ (access(configDir, F_OK) == 0))
+ {
+ xfree(configDir);
+ }
+ else if (((configDir = XpGetConfigDir(FALSE)) != NULL) &&
+ (access(configDir, F_OK) == 0))
+ {
+ xfree(configDir);
+ }
+ else {
+ /* Refuse to start when we do not have our config dir... */
+ FatalError("Xp Extension: could not find config dir %s\n",
+ configDir ? configDir : XPRINTDIR);
+ }
+
+ if(printerDb != (PrinterDbPtr)NULL)
+ FreePrinterDb();
+
+ /*
+ * Calling BuildPrinterDb serves to build the printer database,
+ * and to initialize the attribute store for each printer.
+ * The driver can, if it so desires, modify the attribute
+ * store at a later time.
+ */
+ if((pDb = BuildPrinterDb()) == (PrinterDbPtr)NULL) return;
+
+ /*
+ * We now have to decide how many screens to initialize, and call
+ * AddScreen for each one. The printerDb must be properly initialized
+ * for at least one screen's worth of printers prior to calling AddScreen
+ * because InitPrintDrivers reads the printerDb to determine which
+ * driver(s) to init on a particular screen.
+ * We put each driver's printers on a different
+ * screen, and call AddScreen for each screen/driver pair.
+ */
+ /* count the number of printers */
+ for(pDbEntry = pDb, driverCount = 0; pDbEntry != (PrinterDbPtr)NULL;
+ pDbEntry = pDbEntry->next, driverCount++)
+ ;
+ /*
+ * Allocate memory for the worst case - a driver per printer
+ */
+ driverNames = (char **)xalloc(sizeof(char *) * driverCount);
+
+ /*
+ * Assign the driver for the first printer to the first screen
+ */
+ pDb->screenNum = screenInfo.numScreens;
+ driverNames[0] = pDb->driverName;
+ driverCount = 1;
+ AddFormats(pScreenInfo, pDb->driverName);
+
+ /*
+ * For each printer, look to see if its driver is already assigned
+ * to a screen, and if so copy that screen number into the printerDb.
+ * Otherwise, assign a new screen number to the driver for this
+ * printer.
+ */
+ for(pDbEntry = pDb; pDbEntry != (PrinterDbPtr)NULL;
+ pDbEntry = pDbEntry->next)
+ {
+ Bool foundMatch;
+
+ for(i = 0, foundMatch = FALSE; i < driverCount; i++)
+ {
+ if(!strcmp(driverNames[i], pDbEntry->driverName))
+ {
+ foundMatch = TRUE;
+ pDbEntry->screenNum = screenInfo.numScreens + i;
+ break;
+ }
+ }
+ if(foundMatch == FALSE)
+ {
+ driverNames[driverCount] = pDbEntry->driverName;
+ pDbEntry->screenNum = screenInfo.numScreens + driverCount;
+ AddFormats(pScreenInfo, pDbEntry->driverName);
+ driverCount++;
+ }
+ }
+
+ for(i = 0; i < driverCount; i++)
+ {
+ int curScreen = screenInfo.numScreens;
+ if(AddScreen(InitPrintDrivers, argc, argv) < 0)
+ {
+ PrinterDbPtr pPrev;
+ /*
+ * AddScreen failed, so we pull the associated printers
+ * from the list.
+ */
+ ErrorF("Xp Extension: Could not add screen for driver %s\n",
+ driverNames[i]);
+ for(pPrev = pDbEntry = printerDb; pDbEntry != (PrinterDbPtr)NULL;
+ pDbEntry = pDbEntry->next)
+ {
+ if(pDbEntry->screenNum == curScreen)
+ {
+ if(pPrev == printerDb)
+ {
+ printerDb = pDbEntry->next;
+ pPrev = printerDb;
+ }
+ else
+ pPrev->next = pDbEntry->next;
+
+ xfree(pDbEntry->name);
+ xfree(pDbEntry);
+ pDbEntry = pPrev;
+ }
+ else
+ {
+ if(pDbEntry->screenNum > curScreen)
+ pDbEntry->screenNum--;
+ pPrev = pDbEntry;
+ }
+ }
+ }
+ }
+
+ xfree(driverNames);
+
+ AugmentFontPath();
+
+ if(pScreenInfo->numScreens > MAXSCREENS)
+ {
+ ErrorF("The number of printer screens requested ");
+ ErrorF("exceeds the allowable limit of %d screens.\n", MAXSCREENS);
+ ErrorF("Please reduce the number of requested printers in your ");
+ ErrorF("\nX%sprinters file.", display);
+ ErrorF("Server exiting...\n");
+ exit(-1);
+ }
+}
+
+/*
+ * InitPrintDrivers is called from dix:AddScreen. It in turn calls the
+ * driver initialization routine for any and all drivers which are
+ * implicated in supporting printers on the particular screen number
+ * specified by the "index" parameter. The printerDb variable is used
+ * to determine which printers are to be associated with a particular
+ * screen.
+ */
+static Bool
+InitPrintDrivers(
+ int index,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv)
+{
+ PrinterDbPtr pDb, pDb2;
+
+ GenericScreenInit(index, pScreen, argc, argv);
+
+ for(pDb = printerDb; pDb != (PrinterDbPtr)NULL; pDb = pDb->next)
+ {
+ if(pDb->screenNum == index)
+ {
+ Bool callInit = TRUE;
+ for(pDb2 = printerDb; pDb2 != pDb; pDb2 = pDb2->next)
+ {
+ if(!strcmp(pDb->driverName, pDb2->driverName))
+ {
+ callInit = FALSE;
+ break;
+ }
+ }
+ if(callInit == TRUE)
+ {
+ Bool (*initFunc)();
+ initFunc = GetInitFunc(pDb->driverName);
+ if(initFunc(index, pScreen, argc, argv) == FALSE)
+ {
+ /* XXX - What do I do if the driver's init fails? */
+ }
+ }
+ }
+ }
+ return TRUE;
+}
+
+void
+_XpVoidNoop(void)
+{
+ return;
+}
+
+Bool
+_XpBoolNoop(void)
+{
+ return TRUE;
+}
+
+/*
+ * GenericScreenInit - The common initializations required by all
+ * printer screens and drivers. It sets the screen's cursor functions
+ * to Noops, and computes the maximum screen (i.e. medium) dimensions.
+ */
+
+static void
+GenericScreenInit(
+ int index,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv)
+{
+ int i;
+ float fWidth, fHeight, maxWidth, maxHeight;
+ unsigned short width, height;
+ PrinterDbPtr pDb, pDb2;
+ int res, maxRes;
+
+ /*
+ * Set the cursor ops to no-op functions.
+ */
+ pScreen->DisplayCursor = (DisplayCursorProcPtr)_XpBoolNoop;
+ pScreen->RealizeCursor = (RealizeCursorProcPtr)_XpBoolNoop;
+ pScreen->UnrealizeCursor = (UnrealizeCursorProcPtr)_XpBoolNoop;
+ pScreen->SetCursorPosition = (SetCursorPositionProcPtr)_XpBoolNoop;
+ pScreen->ConstrainCursor = (ConstrainCursorProcPtr)_XpVoidNoop;
+ pScreen->CursorLimits = (CursorLimitsProcPtr)_XpVoidNoop;
+ pScreen->RecolorCursor = (RecolorCursorProcPtr)_XpVoidNoop;
+
+ /*
+ * Find the largest paper size for all the printers on the given
+ * screen.
+ */
+ maxRes = 0;
+ maxWidth = maxHeight = 0.0;
+ for( pDb = printerDb; pDb != (PrinterDbPtr)NULL; pDb = pDb->next)
+ {
+ if(pDb->screenNum == index)
+ {
+
+ XpValidatePoolsRec *pValRec;
+ pVFunc dimensionsFunc;
+
+ GetDimFuncAndRec(pDb->driverName, &pValRec, &dimensionsFunc);
+ if(dimensionsFunc != (pVFunc)NULL)
+ dimensionsFunc(pDb->name, pValRec, &fWidth, &fHeight, &res);
+ else
+ XpGetMaxWidthHeightRes(pDb->name, pValRec, &fWidth,
+ &fHeight, &res);
+ if( res > maxRes )
+ maxRes = res;
+ if( fWidth > maxWidth )
+ maxWidth = fWidth;
+ if( fHeight > maxHeight )
+ maxHeight = fHeight;
+ }
+ }
+
+ width = (unsigned short) (maxWidth * maxRes / 25.4);
+ height = (unsigned short) (maxHeight * maxRes / 25.4);
+ pScreen->width = pScreen->height = ( width > height ) ? width :
+ height;
+
+ pScreen->mmWidth = pScreen->mmHeight = ( maxWidth > maxHeight ) ?
+ (unsigned short)(maxWidth + 0.5) :
+ (unsigned short)(maxHeight + 0.5);
+}
+
+/*
+ * QualifyName - takes an unqualified file name such as X6printers and
+ * a colon-separated list of directory path names such as
+ * /etc/opt/dt:/opt/dt/config.
+ *
+ * Returns a fully qualified file path name such as /etc/opt/dt/X6printers.
+ * The returned value is malloc'd, and the caller is responsible for
+ * freeing the associated memory.
+ */
+static char *
+QualifyName(fileName, searchPath)
+ char *fileName;
+ char *searchPath;
+{
+ char * curPath = searchPath;
+ char * nextPath;
+ char * chance;
+ FILE *pFile;
+
+ if (fileName == NULL || searchPath == NULL)
+ return NULL;
+
+ while (1) {
+ if ((nextPath = strchr(curPath, ':')) != NULL)
+ *nextPath = 0;
+
+ chance = (char *)xalloc(strlen(curPath) + strlen(fileName) + 2);
+ sprintf(chance,"%s/%s",curPath,fileName);
+
+ /* see if we can read from the file */
+ if((pFile = fopen(chance, "r")) != (FILE *)NULL)
+ {
+ fclose(pFile);
+ /* ... restore the colon, .... */
+ if (nextPath)
+ *nextPath = ':';
+
+ return chance;
+ }
+
+ xfree(chance);
+
+ if (nextPath == NULL) /* End of path list? */
+ break;
+
+ /* try the next path */
+ curPath = nextPath + 1;
+ }
+ return NULL;
+}
+
+/*
+ * FillPrinterListEntry fills in a single XpDiListEntry element with data
+ * derived from the supplied PrinterDbPtr element.
+ *
+ * XXX A smarter (i.e. future) version of this routine might inspect the
+ * XXX "locale" parameter and attempt to match the "description" and
+ * XXX "localeName" elements of the XpDiListEntry to the specified locale.
+ */
+static void
+FillPrinterListEntry(
+ XpDiListEntry *pEntry,
+ PrinterDbPtr pDb,
+ int localeLen,
+ char *locale)
+{
+ static char *localeStr = (char *)NULL;
+
+ if(localeStr == (char *)NULL)
+ localeStr = strdup(setlocale(LC_ALL, (const char *)NULL));
+
+ pEntry->name = pDb->name;
+ pEntry->description =
+ (char*)XpGetPrinterAttribute(pDb->name, "descriptor");
+ pEntry->localeName = localeStr;
+ pEntry->rootWinId = WindowTable[pDb->screenNum]->drawable.id;
+}
+
+/*
+ * GetPrinterListInfo fills in the XpDiListEntry struct pointed to by the
+ * parameter pEntry with the information regarding the printer specified
+ * by the name and nameLen parameters. The pointers placed in the
+ * XpDiListEntry structure MUST NOT be freed by the caller. They are
+ * pointers into existing long-lived databases.
+ *
+ */
+static Bool
+GetPrinterListInfo(
+ XpDiListEntry *pEntry,
+ int nameLen,
+ char *name,
+ int localeLen,
+ char *locale)
+{
+ PrinterDbPtr pDb, pDb2;
+
+ for(pDb = printerDb; pDb != (PrinterDbPtr)NULL; pDb = pDb->next)
+ {
+ if(strlen(pDb->name) == nameLen && !strncmp(pDb->name, name, nameLen))
+ {
+ FillPrinterListEntry(pEntry, pDb, localeLen, locale);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/*
+ * XpDiFreePrinterList is the approved method of releasing memory used
+ * for a printer list.
+ */
+void
+XpDiFreePrinterList(XpDiListEntry **list)
+{
+ int i;
+
+ for(i = 0; list[i] != (XpDiListEntry *)NULL; i++)
+ xfree(list[i]);
+ xfree(list);
+}
+
+/*
+ * XpDiGetPrinterList returns a pointer to a NULL-terminated array of
+ * XpDiListEntry pointers. Each entry structure contains the name,
+ * description, root window, and locale of a printer. The call returns
+ * either a list of all printers configured on the server, or it returns
+ * the information for one specific printer depending on the values passed
+ * in. Non-NULL values passed in indicate that only the information for
+ * the one specific printer is desired, while NULL values indicate that
+ * the information for all printers is desired.
+ */
+XpDiListEntry **
+XpDiGetPrinterList(
+ int nameLen,
+ char *name,
+ int localeLen,
+ char *locale)
+{
+ XpDiListEntry **pList;
+
+ if(!nameLen || name == (char *)NULL)
+ {
+ int i;
+ PrinterDbPtr pDb, pDb2;
+
+ for(pDb = printerDb, i = 0; pDb != (PrinterDbPtr)NULL;
+ pDb = pDb->next, i++)
+ ;
+
+ if((pList = (XpDiListEntry **)xalloc((i+1) * sizeof(XpDiListEntry *)))
+ == (XpDiListEntry **)NULL)
+ return pList;
+
+ pList[i] = (XpDiListEntry *)NULL;
+ for(pDb = printerDb, i = 0; pDb != (PrinterDbPtr)NULL;
+ pDb = pDb->next, i++)
+ {
+ if((pList[i] = (XpDiListEntry *)xalloc(sizeof(XpDiListEntry)))==
+ (XpDiListEntry *)NULL)
+ {
+ XpDiFreePrinterList(pList);
+ return (XpDiListEntry **)NULL;
+ }
+ FillPrinterListEntry(pList[i], pDb, localeLen, locale);
+ }
+ }
+ else
+ {
+ if((pList = (XpDiListEntry **)xalloc(2 * sizeof(XpDiListEntry *))) ==
+ (XpDiListEntry **)NULL)
+ return pList;
+
+ if((pList[0] = (XpDiListEntry *)xalloc(sizeof(XpDiListEntry))) ==
+ (XpDiListEntry *)NULL)
+ {
+ xfree(pList);
+ return (XpDiListEntry **)NULL;
+ }
+ pList[1] = (XpDiListEntry *)NULL;
+ if(GetPrinterListInfo(pList[0], nameLen, name, localeLen, locale) ==
+ FALSE)
+ {
+ xfree(pList[0]);
+ pList[0] = (XpDiListEntry *)NULL;
+ }
+ }
+ return pList;
+}
+
+WindowPtr
+XpDiValidatePrinter(char *printerName, int printerNameLen)
+{
+ PrinterDbPtr pCurEntry;
+ WindowPtr pWin;
+
+ for(pCurEntry = printerDb;
+ pCurEntry != (PrinterDbPtr)NULL; pCurEntry = pCurEntry->next)
+ {
+ if(strlen(pCurEntry->name) == printerNameLen &&
+ !strncmp(pCurEntry->name, printerName, printerNameLen))
+ return WindowTable[pCurEntry->screenNum];
+ }
+ return (WindowPtr)NULL;
+}
+
+/*
+ * XpDiGetDriverName takes a screen index and a printer name, and returns
+ * a pointer to the name of the driver to be used for the specified printer
+ * on the specified screen.
+ */
+char *
+XpDiGetDriverName(int index, char *printerName)
+{
+
+ PrinterDbPtr pCurEntry;
+
+ for(pCurEntry = printerDb;
+ pCurEntry != (PrinterDbPtr)NULL; pCurEntry = pCurEntry->next)
+ {
+ if(pCurEntry->screenNum == index &&
+ !strcmp(pCurEntry->name, printerName))
+ return pCurEntry->driverName;
+ }
+
+ return (char *)NULL; /* XXX Should we supply a default driverName? */
+}
+
diff --git a/nx-X11/programs/Xserver/Xprint/Oid.c b/nx-X11/programs/Xserver/Xprint/Oid.c
new file mode 100644
index 000000000..7cb1230c7
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/Oid.c
@@ -0,0 +1,3184 @@
+/* $Xorg: Oid.c,v 1.3 2000/08/17 19:48:06 cpqbld Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "attributes.h"
+
+/*
+ * XpOidNotify value strings
+ */
+#define NOTIFY_EMAIL_STR "{{event-report-job-completed} electronic-mail}"
+#define NOTIFY_NONE_STR "{}"
+
+#define SafeStrLen(s) ((s) ? strlen((s)) : 0)
+
+/*
+ * entry type for the object identifier string map
+ */
+typedef struct _XpOidStringMapEntry
+{
+ const char* string;
+ int length;
+ int msg_set;
+ int msg_number;
+ const char* default_message;
+
+} XpOidStringMapEntry;
+
+/*
+ * include the auto-generated static XpOidStringMap
+ */
+#include "OidStrs.h"
+
+/*
+ * XpOid static function declarations
+ */
+static XpOid XpOidParse(const char* value_string,
+ const char** ptr_return);
+/*
+ * XpOidList static function declarations
+ */
+static XpOidList* XpOidListParse(const char* value_string,
+ const XpOidList* valid_oids,
+ const char** ptr_return, int i);
+
+/*
+ * XpOidList static function declarations
+ */
+static XpOidCardList* XpOidCardListParse(const char* value_string,
+ const XpOidCardList* valid_cards,
+ const char** ptr_return, int i);
+
+/*
+ * XpOidMediumSourceSize static function declarations
+ */
+static XpOidMediumSS* MediumSSParse(const char* value_string,
+ const XpOidList* valid_trays,
+ const XpOidList* valid_medium_sizes,
+ const char** ptr_return, int i);
+static XpOidMediumContinuousSize* MediumContinuousSizeParse(const char*,
+ const char**);
+static void MediumContinuousSizeDelete(XpOidMediumContinuousSize* me);
+static XpOidMediumDiscreteSizeList* MediumDiscreteSizeListParse(const char*,
+ const XpOidList*,
+ const char**,
+ int i);
+static void MediumDiscreteSizeListDelete(XpOidMediumDiscreteSizeList* list);
+
+static BOOL ParseArea(const char* value_string,
+ const char** ptr_return,
+ XpOidArea* area_return);
+static BOOL ParseRealRange(const char* value_string,
+ const char** ptr_return,
+ XpOidRealRange* range_return);
+
+/*
+ * XpOidTrayMediumList static function declarations
+ */
+static XpOidTrayMediumList* TrayMediumListParse(const char* value_string,
+ const XpOidList* valid_trays,
+ const char** ptr_return,
+ int i);
+static void TrayMediumListValidate(XpOidTrayMediumList* me,
+ const XpOidMediumSS* msss);
+
+/*
+ * XpOidDocFmt
+ */
+static BOOL XpOidDocFmtNext(XpOidDocFmt* doc_fmt,
+ const char* value_string,
+ const char** ptr_return);
+
+/*
+ * XpOidDocFmtListParse
+ */
+static XpOidDocFmtList* XpOidDocFmtListParse(const char* value_string,
+ const XpOidDocFmtList* valid_fmts,
+ const char** ptr_return, int i);
+
+/*
+ * misc. parsing static function declarations
+ */
+static BOOL ParseBoolValue(const char* value_string,
+ const char** ptr_return,
+ BOOL* bool_return);
+static BOOL ParseRealValue(const char* value_string,
+ const char** ptr_return,
+ float* real_return);
+static BOOL ParseSeqEnd(
+ const char* value_string,
+ const char** ptr_return);
+static BOOL ParseSeqStart(
+ const char* value_string,
+ const char** ptr_return);
+static BOOL ParseUnspecifiedValue(
+ const char* value_string,
+ const char** ptr_return);
+static int SpanToken(
+ const char* string);
+static int SpanWhitespace(
+ const char* string);
+
+/*
+ * String comparison function.
+ */
+#ifdef HAVE_STRCASECMP
+# define StrnCaseCmp(s1, s2, len) strncasecmp(s1, s2, len)
+#else
+static int StrnCaseCmp(const char *s1, const char *s2, size_t len);
+#endif
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidString
+ *
+ * Description:
+ *
+ * Obtain the string representation of an XpOid.
+ *
+ * Example: XpOidString(xpoid_copy_count) returns "copy-count".
+ *
+ * Return value:
+ *
+ * A const pointer to the string.
+ */
+const char*
+XpOidString(XpOid xp_oid)
+{
+ /*
+ * XpOid enum values are index values into the string map
+ */
+ return XpOidStringMap[xp_oid].string;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidStringLength
+ *
+ * Description:
+ *
+ * Obtain the length of the string representation for a given
+ * XpOid.
+ *
+ * Return value:
+ *
+ * The string length in bytes.
+ *
+ */
+int
+XpOidStringLength(XpOid xp_oid)
+{
+ /*
+ * XpOid enum values are index values into the string map
+ */
+ return XpOidStringMap[xp_oid].length;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidFromString
+ *
+ * Description:
+ *
+ * Obtains the XpOid given a string representation of an XpOid.
+ *
+ * Example: XpOidFromString("copy-count") returns 'xpoid_copy_count'.
+ *
+ * Return value:
+ *
+ * The XpOid if successful. 'xpoid_none' if the string pointed to by
+ * 'value is not recognized or if 'value' is NULL.
+ */
+XpOid
+XpOidFromString(const char* value)
+{
+ if(value == (const char*)NULL)
+ return xpoid_none;
+ else
+ return XpOidParse(value, (const char**)NULL);
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidParse
+ *
+ * Description:
+ *
+ * Parse the next whitespace-delimited string from 'value_string'
+ * updating 'ptr_return' to point to the next unparsed location in
+ * 'value_string'. 'ptr_return' can be NULL.
+ *
+ * Return value:
+ *
+ * The corresponding XpOid for the parsed name string.
+ * A return value of xpoid_none is returned if the parsed name
+ * was not a valid oid or if no name was found.
+ *
+ */
+static XpOid
+XpOidParse(const char* value_string,
+ const char** ptr_return)
+{
+ const char* ptr;
+ int length;
+ int i;
+ /*
+ * skip leading whitespace
+ */
+ ptr = value_string + SpanWhitespace(value_string);
+ /*
+ * get the whitespace-delimited token length
+ */
+ length = SpanToken(ptr);
+ /*
+ * match the oid string in the map
+ */
+ for(i = 0; i < XpOidStringMapCount; i++)
+ if(length == XpOidStringMap[i].length)
+ if(strncmp(ptr, XpOidStringMap[i].string, length) == 0)
+ break;
+ if(i == XpOidStringMapCount)
+ i = xpoid_none;
+ /*
+ * update the return pointer and return
+ */
+ if(ptr_return != (const char**)NULL)
+ *ptr_return = ptr+length;
+ return i;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidListNew
+ *
+ * Description:
+ *
+ * Creates a new XpOidList initialized from a whitespace-delimited
+ * list of recognized string representations of oids. The returned
+ * list will contain only oids found within the passed 'valid_oids'
+ * XpOidList.
+ *
+ * Note: One may notice that in order to create an XpOidList with
+ * this function, an XpOidList is needed; the 'valid_oids' list
+ * is often an statically initialized structure. XpOidListInit
+ * can also be used.
+ *
+ * Return value:
+ *
+ * NULL if the passed 'value_string' is NULL.
+ *
+ * If the list indicated by 'value_string' is empty or contains only
+ * unrecognized oid string representations, a new XpOidList
+ * containing zero elements is returned.
+ *
+ * If 'valid_oids' is NULL all oids are considered valid.
+ *
+ */
+XpOidList*
+XpOidListNew(const char* value_string,
+ const XpOidList* valid_oids)
+{
+ if(value_string == (const char*)NULL)
+ return (XpOidList*)NULL;
+ else
+ {
+ const char* ptr;
+ return XpOidListParse(value_string, valid_oids, &ptr, 0);
+ }
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidListDelete
+ *
+ * Description:
+ *
+ * Frees the memory allocated for 'list'.
+ *
+ * Return value:
+ *
+ * None.
+ *
+ */
+void
+XpOidListDelete(XpOidList* list)
+{
+ if(list != (XpOidList*)NULL)
+ {
+ XpOidFree((char*)list->list);
+ XpOidFree((char*)list);
+ }
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidListParse
+ *
+ * Description:
+ *
+ * This function recursively parses the whitespace-delimited list of
+ * oid string representations passed via 'value_string'. Oids are
+ * only added to the resulting list if they are found within the
+ * passed 'valid_oids' XpOidList.
+ *
+ * 'ptr_return' points to a char* variable allocated by the
+ * caller, and is really only of use during recursion (upon return to
+ * the original caller, it will point to the end of value_string).
+ *
+ * 'value_string' and 'ptr_return' *cannot* be NULL.
+ *
+ * Return value:
+ *
+ * A newly allocated and initialized XpOidList.
+ *
+ * If the list indicated by 'value_string' is empty or contains only
+ * unrecognized oid string representations, a new XpOidList
+ * containing zero elements is returned.
+ *
+ * If 'valid_oids' is NULL all oids are considered valid.
+ *
+ */
+static XpOidList*
+XpOidListParse(const char* value_string,
+ const XpOidList* valid_oids,
+ const char** ptr_return,
+ int i)
+{
+ XpOid oid;
+ XpOidList* list;
+ /*
+ * parse the next valid oid out of the value string
+ */
+ ptr_return = &value_string;
+ while(1)
+ {
+ if(**ptr_return == '\0')
+ {
+ /*
+ * end of value string; stop parsing
+ */
+ oid = xpoid_none;
+ break;
+ }
+ /*
+ * parse the next oid from the value
+ */
+ oid = XpOidParse(*ptr_return, ptr_return);
+ if(xpoid_none == oid)
+ {
+ /*
+ * unrecognized oid; keep parsing
+ */
+ continue;
+ }
+ if((const XpOidList*)NULL == valid_oids
+ ||
+ XpOidListHasOid(valid_oids, oid))
+ {
+ /*
+ * valid oid found; stop parsing
+ */
+ break;
+ }
+ }
+
+ if(oid == xpoid_none)
+ {
+ /*
+ * end of value string; allocate the list structure
+ */
+ list = (XpOidList*)XpOidCalloc(1, sizeof(XpOidList));
+ list->count = i;
+ list->list = (XpOid*)XpOidCalloc(i, sizeof(XpOid));
+ }
+ else
+ {
+ /*
+ * recurse
+ */
+ list = XpOidListParse(*ptr_return, valid_oids, ptr_return, i+1);
+ /*
+ * set the oid in the list
+ */
+ list->list[i] = oid;
+ }
+ /*
+ * return
+ */
+ return list;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidListHasOid
+ *
+ * Description:
+ *
+ * Determines if 'oid' is an element of 'list'.
+ *
+ * Return value:
+ *
+ * xTrue if the oid is found in the list.
+ *
+ * xFalse if the oid is not in the list, or if 'list' is NULL.
+ *
+ */
+BOOL
+XpOidListHasOid(const XpOidList* list, XpOid oid)
+{
+ int i;
+ if(list != (XpOidList*)NULL)
+ for(i = 0; i < list->count; i++)
+ if(list->list[i] == oid)
+ return xTrue;
+ return xFalse;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidListGetIndex
+ *
+ * Description:
+ *
+ * Returns the array index of 'oid' in 'list'
+ *
+ * Return value:
+ *
+ * The index of 'oid' in list.
+ *
+ * -1 if the oid is not in the list, or if 'list' is NULL.
+ *
+ */
+int
+XpOidListGetIndex(const XpOidList* list, XpOid oid)
+{
+ int i;
+ if(list != (XpOidList*)NULL)
+ for(i = 0; i < list->count; i++)
+ if(list->list[i] == oid)
+ return i;
+ return -1;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidListString
+ *
+ * Description:
+ *
+ * Creates a string representation of an XpOidList structure.
+ *
+ * Return value:
+ *
+ * A newly allocated
+ *
+ */
+char*
+XpOidListString(const XpOidList* me)
+{
+ int i;
+ int length;
+ char* str;
+ char* ptr;
+ /*
+ * allocate enough memory for the oid string representations,
+ * including intervening whitespace
+ */
+ for(i = 0, length = 0; i < XpOidListCount(me); i++)
+ length += XpOidStringLength(XpOidListGetOid(me, i)) + 1;
+ str = XpOidMalloc(length+1);
+ /*
+ * format the list
+ */
+ for(i = 0, ptr = str; i < XpOidListCount(me); i++)
+#if defined(sun) && !defined(SVR4)
+ {
+ sprintf(ptr, "%s ", XpOidString(XpOidListGetOid(me, i)));
+ ptr += strlen(ptr);
+ }
+#else
+ ptr += sprintf(ptr, "%s ", XpOidString(XpOidListGetOid(me, i)));
+#endif
+ /*
+ * chop trailing whitespace or terminate empty string
+ */
+ str[length] = '\0';
+ /*
+ * return
+ */
+ return str;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidLinkedListNew
+ *
+ * Description:
+ *
+ * Creates a new instance of an empty XpOidLinkedList.
+ *
+ * Return value:
+ *
+ * The new XpOidLinkedList.
+ *
+ */
+XpOidLinkedList*
+XpOidLinkedListNew()
+{
+ return (XpOidLinkedList*)XpOidCalloc(1, sizeof(XpOidLinkedList));
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidLinkedListDelete
+ *
+ * Description:
+ *
+ * Frees the memory allocated for a XpOidLinkedList.
+ *
+ * Return value:
+ *
+ * None.
+ *
+ */
+void
+XpOidLinkedListDelete(XpOidLinkedList* me)
+{
+ if(me != (XpOidLinkedList*)NULL)
+ {
+ while(me->head)
+ {
+ me->current = me->head;
+ me->head = me->current->next;
+ XpOidFree((char*)me->current);
+ }
+ XpOidFree((char*)me);
+ }
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidLinkedListGetOid
+ *
+ * Description:
+ *
+ * Retrieves the oid at position 'i' (zero-based) in the
+ * XpOidLinkedList 'me'.
+ *
+ * Return value:
+ *
+ * The oid at position 'i'.
+ *
+ * xpoid_none if the oid was not found, or the list is empty (or if
+ * the list contains xpoid_none at position 'i').
+ */
+XpOid
+XpOidLinkedListGetOid(XpOidLinkedList* me, int i)
+{
+ if(me == (XpOidLinkedList*)NULL || i < 0 || i >= me->count)
+ {
+ return xpoid_none;
+ }
+ else
+ {
+ me->current = me->head;
+ while(i--) me->current = me->current->next;
+ return me->current->oid;
+ }
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidLinkedListAddOid
+ *
+ * Description:
+ *
+ * Adds an oid to the end of an XpOidLinkedList.
+ *
+ * Return value:
+ *
+ * None.
+ *
+ */
+void
+XpOidLinkedListAddOid(XpOidLinkedList* me, XpOid oid)
+{
+ me->current = (XpOidNode)XpOidCalloc(1, sizeof(struct XpOidNodeStruct));
+ me->current->oid = oid;
+ ++me->count;
+ if(me->tail)
+ {
+ me->tail->next = me->current;
+ me->tail = me->current;
+ }
+ else
+ me->head = me->tail = me->current;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidLinkedListGetIndex
+ *
+ * Description:
+ *
+ * Returns the position of an oid in a XpOidLinkedList.
+ *
+ * Return value:
+ *
+ * The zero-based position of 'oid' in the list.
+ *
+ * -1 if the oid is not in the list, or if 'me' is NULL.
+ *
+ */
+int
+XpOidLinkedListGetIndex(XpOidLinkedList* me, XpOid oid)
+{
+ if((XpOidLinkedList*)NULL != me)
+ {
+ int i = 0;
+ me->current = me->head;
+ while(me->current)
+ if(me->current->oid == oid)
+ {
+ return i;
+ }
+ else
+ {
+ ++i;
+ me->current = me->current->next;
+ }
+ }
+ return -1;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidLinkedListHasOid
+ *
+ * Description:
+ *
+ * Determines if an oid is an element of a XpOidLinkedList.
+ *
+ * Return value:
+ *
+ * xTrue if the oid is found in the list.
+ *
+ * xFalse if the oid is not in the list, or if 'me' is NULL.
+ */
+BOOL
+XpOidLinkedListHasOid(XpOidLinkedList* me,
+ XpOid oid)
+{
+ if((XpOidLinkedList*)NULL != me)
+ {
+ me->current = me->head;
+ while(me->current)
+ if(me->current->oid == oid)
+ return xTrue;
+ else
+ me->current = me->current->next;
+ }
+ return xFalse;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidLinkedListFirstOid
+ *
+ * Description:
+ *
+ * Positions the XpOidLinkedList 'current' pointer to the first entry
+ * in the list.
+ *
+ * Return value:
+ *
+ * The first oid in the list, or xpoid_none if the list NULL or
+ * empty.
+ */
+XpOid
+XpOidLinkedListFirstOid(XpOidLinkedList* me)
+{
+ if((XpOidLinkedList*)NULL != me && (me->current = me->head))
+ return me->current->oid;
+ else
+ return xpoid_none;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidLinkedListNextOid
+ *
+ * Description:
+ *
+ * Positions the XpOidLinkedList 'current' pointer to the next entry
+ * in the list.
+ *
+ * Return value:
+ *
+ * The next oid, or xpoid_none if the end of the list has been
+ * reached.
+ */
+XpOid
+XpOidLinkedListNextOid(XpOidLinkedList* me)
+{
+ if(me->current ? (me->current = me->current->next) : xFalse)
+ return me->current->oid;
+ else
+ return xpoid_none;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidMediumSSNew
+ *
+ * Description:
+ *
+ * Creates a new XpOidMediumSS initialized from a string value
+ * specified using the medium-source-sizes syntax. See
+ * MediumSSParse() below for parsing details.
+ *
+ * Return value:
+ *
+ * NULL if the passed 'value_string' is NULL, or if a syntax error is
+ * encountered while parsing the medium-source-sizes value.
+ *
+ */
+XpOidMediumSS*
+XpOidMediumSSNew(const char* value_string,
+ const XpOidList* valid_trays,
+ const XpOidList* valid_medium_sizes)
+{
+ if(value_string == (const char*)NULL)
+ return (XpOidMediumSS*)NULL;
+ else
+ {
+ const char* ptr = value_string + SpanWhitespace(value_string);
+ if(*ptr == '\0')
+ return (XpOidMediumSS*)NULL;
+ else
+ return MediumSSParse(ptr, valid_trays, valid_medium_sizes,
+ &ptr, 0);
+ }
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: MediumSSParse
+ *
+ * Description:
+ *
+ * 'ptr_return' *cannot* be NULL.
+ *
+ *
+ * Return value:
+ *
+ *
+ *
+ */
+static XpOidMediumSS*
+MediumSSParse(const char* value_string,
+ const XpOidList* valid_trays,
+ const XpOidList* valid_medium_sizes,
+ const char** ptr_return,
+ int i)
+{
+ XpOidMediumSS* medium_ss;
+ XpOidMediumSourceSize mss;
+ /*
+ * check for the start of a new MediumSourceSize sequence
+ */
+ if(ParseSeqStart(value_string, ptr_return))
+ {
+ /*
+ * check for an unspecified tray value
+ */
+ if(ParseUnspecifiedValue(*ptr_return, ptr_return))
+ mss.input_tray = xpoid_unspecified;
+ else
+ {
+ const char* tray_str;
+ *ptr_return += SpanWhitespace(*ptr_return);
+ tray_str = *ptr_return;
+ /*
+ * parse out the input tray
+ */
+ mss.input_tray = XpOidParse(*ptr_return, ptr_return);
+ if((const XpOidList*)NULL != valid_trays
+ &&
+ !XpOidListHasOid(valid_trays, mss.input_tray)
+ )
+ mss.input_tray = xpoid_none;
+ if(xpoid_none == mss.input_tray)
+ {
+ char* invalid_tray_str;
+ int len = *ptr_return - tray_str;
+ if(len > 0)
+ {
+ invalid_tray_str = XpOidMalloc(len+1);
+ strncpy(invalid_tray_str, tray_str, len);
+ invalid_tray_str[len] = '\0';
+ ErrorF("%s\nInvalid tray (%s) found. Will attempt to continue parsing.\n",
+ XPMSG_WARN_MSS, invalid_tray_str);
+ XpOidFree(invalid_tray_str);
+ }
+ }
+ }
+ /*
+ * attempt to parse a Continuous MediumSize sequence
+ */
+ mss.ms.continuous_size =
+ MediumContinuousSizeParse(*ptr_return, ptr_return);
+ if(mss.ms.continuous_size != (XpOidMediumContinuousSize*)NULL)
+ {
+ mss.mstag = XpOidMediumSS_CONTINUOUS;
+ }
+ else
+ {
+ /*
+ * not continuous, try Discrete MediumSize
+ */
+ mss.ms.discrete =
+ MediumDiscreteSizeListParse(*ptr_return, valid_medium_sizes,
+ ptr_return, 0);
+ if(mss.ms.discrete == (XpOidMediumDiscreteSizeList*)NULL)
+ {
+ const char* tray_str;
+ /*
+ * syntax error (MediumDiscreteSizeListParse reports error)
+ */
+ switch(mss.input_tray)
+ {
+ case xpoid_none:
+ tray_str = "an invalid";
+ break;
+ case xpoid_unspecified:
+ tray_str = "default (tray specifier omitted)";
+ break;
+ default:
+ tray_str = XpOidString(mss.input_tray);
+ break;
+ }
+ ErrorF("%s\nError occurred while parsing medium sizes for %s tray.\n",
+ XPMSG_WARN_MSS, tray_str);
+ return NULL;
+ }
+ mss.mstag = XpOidMediumSS_DISCRETE;
+ }
+ /*
+ * parse out the MediumSourceSize sequence end
+ */
+ if(!ParseSeqEnd(*ptr_return, ptr_return))
+ {
+ /*
+ * syntax error
+ */
+ ErrorF("%s\nSequence End expected. Unparsed data: %s\n",
+ XPMSG_WARN_MSS, *ptr_return);
+ return NULL;
+ }
+ /*
+ * recurse to parse the next MediumSourceSize sequence
+ */
+ medium_ss = MediumSSParse(*ptr_return,
+ valid_trays, valid_medium_sizes,
+ ptr_return,
+ xpoid_none == mss.input_tray ? i : i+1);
+ if(medium_ss == (XpOidMediumSS*)NULL
+ ||
+ xpoid_none == mss.input_tray)
+ {
+ /*
+ * syntax error or invalid tray - clean up
+ */
+ switch(mss.mstag)
+ {
+ case XpOidMediumSS_CONTINUOUS:
+ MediumContinuousSizeDelete(mss.ms.continuous_size);
+ break;
+ case XpOidMediumSS_DISCRETE:
+ MediumDiscreteSizeListDelete(mss.ms.discrete);
+ break;
+ }
+ if(medium_ss == (XpOidMediumSS*)NULL)
+ /*
+ * syntax error - return
+ */
+ return NULL;
+ }
+ if(xpoid_none != mss.input_tray)
+ {
+ /*
+ * copy the current MediumSourceSize into the array
+ */
+ memmove((medium_ss->mss)+i, &mss, sizeof(XpOidMediumSourceSize));
+ }
+ }
+ else
+ {
+ /*
+ * MediumSourceSize sequence start not found
+ */
+ if(**ptr_return == '\0')
+ {
+ if(0 == i)
+ {
+ ErrorF("%s\nNo valid trays found.\n", XPMSG_WARN_MSS);
+ return NULL;
+ }
+ /*
+ * end of value string; allocate the MediumSS structure
+ */
+ medium_ss = (XpOidMediumSS*)XpOidCalloc(1, sizeof(XpOidMediumSS));
+ medium_ss->count = i;
+ medium_ss->mss = (XpOidMediumSourceSize*)
+ XpOidCalloc(i, sizeof(XpOidMediumSourceSize));
+ }
+ else
+ {
+ /*
+ * syntax error
+ */
+ ErrorF("%s\nSequence Start expected.\nunparsed data: %s\n",
+ XPMSG_WARN_MSS, *ptr_return);
+ return NULL;
+ }
+ }
+ return medium_ss;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidMediumSSDelete
+ *
+ * Description:
+ *
+ *
+ *
+ * Return value:
+ *
+ *
+ *
+ */
+void
+XpOidMediumSSDelete(XpOidMediumSS* me)
+{
+ if(me != (XpOidMediumSS*)NULL)
+ {
+ int i;
+ for(i = 0; i < me->count; i++)
+ {
+ switch((me->mss)[i].mstag)
+ {
+ case XpOidMediumSS_CONTINUOUS:
+ MediumContinuousSizeDelete((me->mss)[i].ms.continuous_size);
+ break;
+ case XpOidMediumSS_DISCRETE:
+ MediumDiscreteSizeListDelete((me->mss)[i].ms.discrete);
+ break;
+ }
+ }
+ XpOidFree((char*)me);
+ }
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidMediumSSHasSize
+ *
+ * Description:
+ *
+ *
+ *
+ * Return value:
+ *
+ *
+ *
+ */
+BOOL
+XpOidMediumSSHasSize(XpOidMediumSS* me, XpOid page_size)
+{
+ int i_mss, i_ds;
+ XpOidMediumDiscreteSizeList* ds_list;
+
+ if(me != (XpOidMediumSS*)NULL && page_size != xpoid_none)
+ for(i_mss = 0; i_mss < me->count; i_mss++)
+ {
+ switch((me->mss)[i_mss].mstag)
+ {
+ case XpOidMediumSS_DISCRETE:
+ ds_list = (me->mss)[i_mss].ms.discrete;
+ for(i_ds = 0; i_ds < ds_list->count; i_ds++)
+ if(page_size == (ds_list->list)[i_ds].page_size)
+ return xTrue;
+ break;
+
+ case XpOidMediumSS_CONTINUOUS:
+ /*
+ * unsupported
+ */
+ break;
+ }
+ }
+ /*
+ * return
+ */
+ return xFalse;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidMediumSSString
+ *
+ * Description:
+ *
+ * Creates a string representation of an XpOidMediumSS structure.
+ *
+ * Return value:
+ *
+ * A newly allocated
+ *
+ */
+char* XpOidMediumSSString(const XpOidMediumSS* me)
+{
+ int itray, isize;
+ int valid_size_count;
+ int length;
+ char* str;
+ char* ptr;
+ XpOidMediumDiscreteSize* ds;
+ char buf[128];
+ /*
+ * determine the size of the string representation
+ */
+ for(itray = 0, length = 0; itray < XpOidMediumSSCount(me); itray++)
+ {
+ if(xpoid_none == me->mss[itray].input_tray
+ ||
+ XpOidMediumSS_CONTINUOUS == me->mss[itray].mstag)
+ {
+ /*
+ * skip invalid tray or unsupported continuous size spec
+ */
+ continue;
+ }
+ for(isize = 0, valid_size_count = 0;
+ isize < me->mss[itray].ms.discrete->count;
+ isize++)
+ {
+ ds = me->mss[itray].ms.discrete->list+isize;
+ if(ds->page_size == xpoid_none)
+ continue;
+ ++valid_size_count;
+ length += XpOidStringLength(ds->page_size);
+ length += ds->long_edge_feeds ? 4 : 5; /* "True" or "False" */
+#if defined(sun) && !defined(SVR4)
+ sprintf(buf, "{%.4f %.4f %.4f %.4f}",
+ ds->assured_reproduction_area.minimum_x,
+ ds->assured_reproduction_area.maximum_x,
+ ds->assured_reproduction_area.minimum_y,
+ ds->assured_reproduction_area.maximum_y);
+ length += strlen(buf);
+#else
+ length += sprintf(buf, "{%.4f %.4f %.4f %.4f}",
+ ds->assured_reproduction_area.minimum_x,
+ ds->assured_reproduction_area.maximum_x,
+ ds->assured_reproduction_area.minimum_y,
+ ds->assured_reproduction_area.maximum_y);
+#endif
+ length += 5; /* "{<size> <feed> <area>} " */
+ }
+ if(valid_size_count == 0)
+ {
+ /*
+ * no valid sizes, skip
+ */
+ continue;
+ }
+ if(xpoid_unspecified == me->mss[itray].input_tray)
+ length += 2; /* "''" */
+ else
+ length += XpOidStringLength(me->mss[itray].input_tray);
+ length += 4; /* "{<tray> <sizes>} " */
+ }
+ /*
+ * allocate
+ */
+ str = XpOidMalloc(length+1);
+ /*
+ * format
+ */
+ for(itray = 0, ptr = str; itray < XpOidMediumSSCount(me); itray++)
+ {
+ if(xpoid_none == me->mss[itray].input_tray
+ ||
+ XpOidMediumSS_CONTINUOUS == me->mss[itray].mstag)
+ {
+ /*
+ * skip invalid tray or unsupported continuous size spec
+ */
+ continue;
+ }
+ /*
+ * check to ensure all of the specified sizes are valid
+ */
+ for(isize = 0, valid_size_count = 0;
+ isize < me->mss[itray].ms.discrete->count;
+ isize++)
+ {
+ ds = me->mss[itray].ms.discrete->list+isize;
+ if(ds->page_size != xpoid_none)
+ ++valid_size_count;
+ }
+ if(valid_size_count == 0)
+ {
+ /*
+ * no valid sizes, skip
+ */
+ continue;
+ }
+
+ if(xpoid_unspecified == me->mss[itray].input_tray)
+ {
+#if defined(sun) && !defined(SVR4)
+ sprintf(ptr, "{'' ");
+ ptr += strlen(ptr);
+#else
+ ptr += sprintf(ptr, "{'' ");
+#endif
+ }
+ else
+ {
+#if defined(sun) && !defined(SVR4)
+ sprintf(ptr, "{%s ", XpOidString(me->mss[itray].input_tray));
+ ptr += strlen(ptr);
+#else
+ ptr += sprintf(ptr, "{%s ",
+ XpOidString(me->mss[itray].input_tray));
+#endif
+ }
+ for(isize = 0; isize < me->mss[itray].ms.discrete->count; isize++)
+ {
+ ds = me->mss[itray].ms.discrete->list+isize;
+ if(ds->page_size != xpoid_none)
+#if defined(sun) && !defined(SVR4)
+ {
+ sprintf(ptr, "{%s %s {%.4f %.4f %.4f %.4f}} ",
+ XpOidString(ds->page_size),
+ ds->long_edge_feeds ? "True" : "False",
+ ds->assured_reproduction_area.minimum_x,
+ ds->assured_reproduction_area.maximum_x,
+ ds->assured_reproduction_area.minimum_y,
+ ds->assured_reproduction_area.maximum_y);
+ ptr += strlen(ptr);
+ }
+#else
+ ptr += sprintf(ptr, "{%s %s {%.4f %.4f %.4f %.4f}} ",
+ XpOidString(ds->page_size),
+ ds->long_edge_feeds ? "True" : "False",
+ ds->assured_reproduction_area.minimum_x,
+ ds->assured_reproduction_area.maximum_x,
+ ds->assured_reproduction_area.minimum_y,
+ ds->assured_reproduction_area.maximum_y);
+#endif
+ }
+#if defined(sun) && !defined(SVR4)
+ sprintf(ptr, "} ");
+ ptr += strlen(ptr);
+#else
+ ptr += sprintf(ptr, "} ");
+#endif
+ }
+ /*
+ * chop trailing whitespace or terminate empty string
+ */
+ str[length] = '\0';
+ /*
+ * return
+ */
+ return str;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: MediumContinuousSizeParse
+ *
+ * Description:
+ *
+ * 'ptr_return' *cannot* be NULL.
+ *
+ *
+ * Return value:
+ *
+ *
+ *
+ */
+static XpOidMediumContinuousSize*
+MediumContinuousSizeParse(const char* value_string,
+ const char** ptr_return)
+{
+ const char* first_nonws_ptr;
+ XpOidMediumContinuousSize* mcs = NULL;
+ /*
+ * skip leading whitespace
+ */
+ first_nonws_ptr = value_string + SpanWhitespace(value_string);
+ /*
+ * parse out the MediumSize sequence start char
+ */
+ if(!ParseSeqStart(first_nonws_ptr, ptr_return))
+ goto MediumContinuousSizeParse_error;
+ /*
+ * peek ahead to see if it looks like we actually have a continuous
+ * size spec (looking for the sequence start char on the 1st range spec)
+ */
+ if(!ParseSeqStart(*ptr_return, (const char**)NULL))
+ goto MediumContinuousSizeParse_error;
+ /*
+ * Ok, let's go for it
+ */
+ mcs = (XpOidMediumContinuousSize*)
+ XpOidCalloc(1, sizeof(XpOidMediumContinuousSize));
+ /*
+ * "range across the feed direction"
+ */
+ if(!ParseRealRange(*ptr_return, ptr_return, &mcs->range_across_feed))
+ goto MediumContinuousSizeParse_error;
+ /*
+ * "increment across the feed direction" (optional, default 0)
+ */
+ if(!ParseUnspecifiedValue(*ptr_return, ptr_return))
+ if(!ParseRealValue(*ptr_return, ptr_return,
+ &mcs->increment_across_feed))
+ goto MediumContinuousSizeParse_error;
+ /*
+ * "range in the feed direction"
+ */
+ if(!ParseRealRange(*ptr_return, ptr_return, &mcs->range_in_feed))
+ goto MediumContinuousSizeParse_error;
+ /*
+ * "increment in the feed direction" (optional, default 0)
+ */
+ if(!ParseUnspecifiedValue(*ptr_return, ptr_return))
+ if(!ParseRealValue(*ptr_return, ptr_return,
+ &mcs->increment_in_feed))
+ goto MediumContinuousSizeParse_error;
+ /*
+ * "long edge feeds" flag (default TRUE)
+ */
+ if(ParseUnspecifiedValue(*ptr_return, ptr_return))
+ mcs->long_edge_feeds = xTrue;
+ else
+ if(!ParseBoolValue(*ptr_return, ptr_return, &mcs->long_edge_feeds))
+ goto MediumContinuousSizeParse_error;
+ /*
+ * "generic assured reproduction area"
+ */
+ if(!ParseArea(*ptr_return, ptr_return, &mcs->assured_reproduction_area))
+ goto MediumContinuousSizeParse_error;
+ /*
+ * parse out the MediumSize sequence end character
+ */
+ if(!ParseSeqEnd(*ptr_return, ptr_return))
+ goto MediumContinuousSizeParse_error;
+ /*
+ * return
+ */
+ return mcs;
+
+
+ MediumContinuousSizeParse_error:
+ /*
+ * syntax error - don't log since this function may be called
+ * as a lookahead
+ */
+ *ptr_return = first_nonws_ptr;
+ XpOidFree((char*)mcs);
+ return NULL;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: MediumContinuousSizeDelete
+ *
+ * Description:
+ *
+ * 'ptr_return' *cannot* be NULL.
+ *
+ *
+ * Return value:
+ *
+ *
+ *
+ */
+static void
+MediumContinuousSizeDelete(XpOidMediumContinuousSize* me)
+{
+ XpOidFree((char*)me);
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: MediumDiscreteSizeListParse
+ *
+ * Description:
+ *
+ * 'ptr_return' *cannot* be NULL.
+ *
+ * Return value:
+ *
+ *
+ *
+ */
+static XpOidMediumDiscreteSizeList*
+MediumDiscreteSizeListParse(const char* value_string,
+ const XpOidList* valid_medium_sizes,
+ const char** ptr_return,
+ int i)
+{
+ XpOidMediumDiscreteSizeList* list;
+ XpOidMediumDiscreteSize mds;
+ /*
+ * check for the start of a new MediumSize sequence
+ */
+ if(ParseSeqStart(value_string, ptr_return))
+ {
+ /*
+ * "page size"
+ */
+ mds.page_size = XpOidParse(*ptr_return, ptr_return);
+ if((const XpOidList*)NULL != valid_medium_sizes
+ &&
+ !XpOidListHasOid(valid_medium_sizes, mds.page_size)
+ )
+ mds.page_size = xpoid_none;
+ /*
+ * "long edge feeds" flag (default TRUE)
+ */
+ if(ParseUnspecifiedValue(*ptr_return, ptr_return))
+ mds.long_edge_feeds = xTrue;
+ else
+ if(!ParseBoolValue(*ptr_return, ptr_return,
+ &mds.long_edge_feeds))
+ {
+ /*
+ * syntax error
+ */
+ ErrorF("%s\nBoolean expected.\nunparsed data: %s\n",
+ XPMSG_WARN_MSS, *ptr_return);
+ return (XpOidMediumDiscreteSizeList*)NULL;
+ }
+ /*
+ * "assured reproduction area"
+ */
+ if(!ParseArea(*ptr_return, ptr_return,
+ &mds.assured_reproduction_area))
+ {
+ /*
+ * syntax error
+ */
+ ErrorF("%s\nArea specification error.\nunparsed data: %s\n",
+ XPMSG_WARN_MSS, *ptr_return);
+ return (XpOidMediumDiscreteSizeList*)NULL;
+ }
+ /*
+ * parse out the MediumSize sequence end character
+ */
+ if(!ParseSeqEnd(*ptr_return, ptr_return))
+ {
+ ErrorF("%s\nSequence End expected. Unparsed data: %s\n",
+ XPMSG_WARN_MSS, *ptr_return);
+ return (XpOidMediumDiscreteSizeList*)NULL;
+ }
+ /*
+ * recurse to parse the next Discrete MediumSize sequence
+ */
+ if(mds.page_size == xpoid_none)
+ {
+ list = MediumDiscreteSizeListParse(*ptr_return, valid_medium_sizes,
+ ptr_return, i);
+ }
+ else
+ {
+ list = MediumDiscreteSizeListParse(*ptr_return, valid_medium_sizes,
+ ptr_return, i+1);
+ if(list != (XpOidMediumDiscreteSizeList*)NULL)
+ {
+ /*
+ * copy the current discrete MediumSize into the list
+ */
+ memmove((list->list)+i, &mds, sizeof(XpOidMediumDiscreteSize));
+ }
+ }
+ }
+ else
+ {
+ /*
+ * MediumSize sequence start not found; end of the discrete sizes
+ * list
+ */
+ if(0 == i)
+ {
+ ErrorF("%s\nNo valid medium sizes found for tray.\n",
+ XPMSG_WARN_MSS);
+ return (XpOidMediumDiscreteSizeList*)NULL;
+ }
+ list = (XpOidMediumDiscreteSizeList*)
+ XpOidCalloc(1, sizeof(XpOidMediumDiscreteSizeList));
+ list->count = i;
+ list->list = (XpOidMediumDiscreteSize*)
+ XpOidCalloc(i, sizeof(XpOidMediumDiscreteSize));
+ }
+ return list;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: MediumDiscreteSizeListDelete
+ *
+ * Description:
+ *
+ *
+ *
+ * Return value:
+ *
+ *
+ *
+ */
+static void
+MediumDiscreteSizeListDelete(XpOidMediumDiscreteSizeList* list)
+{
+ if(list != (XpOidMediumDiscreteSizeList*)NULL)
+ {
+ XpOidFree((char*)list->list);
+ XpOidFree((char*)list);
+ }
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidTrayMediumListNew
+ *
+ * Description:
+ *
+ * Only need the valid trays; validation requires bumping up against
+ * msss using TrayMediumListValidate; this needs valid trays
+ * because of unspecified trays ion msss, but
+ * TrayMediumListValidate will take care of invalid sizes...
+ *
+ * Return value:
+ *
+ *
+ *
+ */
+XpOidTrayMediumList*
+XpOidTrayMediumListNew(const char* value_string,
+ const XpOidList* valid_trays,
+ const XpOidMediumSS* msss)
+{
+ if(value_string == (const char*)NULL)
+ return (XpOidTrayMediumList*)NULL;
+ else
+ {
+ const char* ptr;
+ XpOidTrayMediumList* me;
+ me = TrayMediumListParse(value_string, valid_trays, &ptr, 0);
+ if((XpOidTrayMediumList*)NULL != me)
+ TrayMediumListValidate(me, msss);
+ return me;
+ }
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidTrayMediumListDelete
+ *
+ * Description:
+ *
+ *
+ *
+ * Return value:
+ *
+ *
+ *
+ */
+void
+XpOidTrayMediumListDelete(XpOidTrayMediumList* list)
+{
+ if(list != (XpOidTrayMediumList*)NULL)
+ {
+ XpOidFree((char*)list->list);
+ XpOidFree((char*)list);
+ }
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: TrayMediumListParse
+ *
+ * Description:
+ *
+ * 'ptr_return' *cannot* be NULL.
+ *
+ * Return value:
+ *
+ *
+ *
+ */
+static XpOidTrayMediumList*
+TrayMediumListParse(const char* value_string,
+ const XpOidList* valid_trays,
+ const char** ptr_return, int i)
+{
+ XpOidTrayMedium tm;
+ XpOidTrayMediumList* list;
+ /*
+ * check for the start of a new InputTrayMedium sequence
+ */
+ if(ParseSeqStart(value_string, ptr_return))
+ {
+ /*
+ * "input tray"
+ */
+ tm.input_tray = XpOidParse(*ptr_return, ptr_return);
+ if((XpOidList*)NULL != valid_trays
+ &&
+ !XpOidListHasOid(valid_trays, tm.input_tray)
+ )
+ tm.input_tray = xpoid_none;
+ /*
+ * "medium"
+ */
+ tm.medium = XpOidParse(*ptr_return, ptr_return);
+ /*
+ * parse out the InputTrayMedium sequence end character
+ */
+ if(!ParseSeqEnd(*ptr_return, ptr_return))
+ {
+ ErrorF("%s\n", XPMSG_WARN_ITM);
+ return NULL;
+ }
+ /*
+ * recurse to parse the next InputTrayMedium sequence
+ */
+ list = TrayMediumListParse(*ptr_return, valid_trays, ptr_return, i+1);
+ if(list != (XpOidTrayMediumList*)NULL)
+ {
+ /*
+ * copy the current InputTrayMedium into the list
+ */
+ memmove((list->list)+i, &tm, sizeof(XpOidTrayMedium));
+ }
+ }
+ else
+ {
+ /*
+ * InputTrayMedium sequence start not found
+ */
+ if(**ptr_return == '\0')
+ {
+ /*
+ * end of the list
+ */
+ list = (XpOidTrayMediumList*)
+ XpOidCalloc(1, sizeof(XpOidTrayMediumList));
+ list->count = i;
+ list->list = (XpOidTrayMedium*)
+ XpOidCalloc(i, sizeof(XpOidTrayMedium));
+ }
+ else
+ {
+ /*
+ * syntax error
+ */
+ ErrorF("%s\n", XPMSG_WARN_ITM);
+ return NULL;
+ }
+ }
+ /*
+ * return
+ */
+ return list;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: TrayMediumListValidate
+ *
+ * Description:
+ *
+ * Validate the input-trays-medium list based on a passed
+ * medium-source-sizes-supported structure. The validated
+ * input-trays-medium list will have the same number of entries upon
+ * return from this function. Invalid entries are indicated by
+ * setting the tray specification to xpoid_none.
+ *
+ * Return value:
+ *
+ * None.
+ *
+ */
+static void
+TrayMediumListValidate(XpOidTrayMediumList* me,
+ const XpOidMediumSS* msss)
+{
+ int i_mss, i_ds, i_itm;
+ XpOidMediumDiscreteSizeList* ds_list;
+ int tray_count;
+ XpOid current_tray, current_medium;
+ XpOidMediumDiscreteSizeList* unspecified_tray_ds;
+ XpOidMediumDiscreteSizeList* tray_ds;
+
+ if(msss == (XpOidMediumSS*)NULL
+ ||
+ me == (XpOidTrayMediumList*)NULL)
+ {
+ return;
+ }
+ /*
+ * loop through the input trays medium list
+ */
+ for(i_itm = 0; i_itm < XpOidTrayMediumListCount(me); i_itm++)
+ {
+ current_tray = XpOidTrayMediumListTray(me, i_itm);
+ if(current_tray == xpoid_none)
+ continue;
+ current_medium = XpOidTrayMediumListMedium(me, i_itm);
+ if(current_medium == xpoid_none)
+ {
+ /*
+ * no medium; invalidate this entry
+ */
+ me->list[i_itm].input_tray = xpoid_none;
+ continue;
+ }
+ /*
+ * loop through the MediumSourceSizes, looking for an appropriate
+ * discrete sizes spec for the current tray
+ */
+ unspecified_tray_ds = (XpOidMediumDiscreteSizeList*)NULL;
+ tray_ds = (XpOidMediumDiscreteSizeList*)NULL;
+ for(i_mss = 0;
+ i_mss < msss->count &&
+ tray_ds == (XpOidMediumDiscreteSizeList*)NULL;
+ i_mss++)
+ {
+ switch((msss->mss)[i_mss].mstag)
+ {
+ case XpOidMediumSS_DISCRETE:
+ if((msss->mss)[i_mss].input_tray == current_tray)
+ tray_ds = (msss->mss)[i_mss].ms.discrete;
+ else if((msss->mss)[i_mss].input_tray == xpoid_unspecified)
+ unspecified_tray_ds = (msss->mss)[i_mss].ms.discrete;
+ break;
+
+ case XpOidMediumSS_CONTINUOUS:
+ /*
+ * unsupported
+ */
+ break;
+ }
+ }
+ /*
+ * if the tray was not matched, use the unspecified tray size
+ * list
+ */
+ if(tray_ds == (XpOidMediumDiscreteSizeList*)NULL)
+ {
+ if(unspecified_tray_ds == (XpOidMediumDiscreteSizeList*)NULL)
+ {
+ /*
+ * not even an unspecified tray, invalidate this
+ * input-trays-medium entry.
+ */
+ me->list[i_itm].input_tray = xpoid_none;
+ continue;
+ }
+ else
+ tray_ds = unspecified_tray_ds;
+ }
+ /*
+ * loop through the discrete sizes list, looking for a size that
+ * matches the medium for the current input tray
+ */
+ for(i_ds = 0; i_ds < tray_ds->count; i_ds++)
+ {
+ /*
+ * check to see if the current input tray's medium size
+ * matches the current discrete size
+ *
+ * Note: in the CDEnext SI, medium identifiers coincide with
+ * medium-size identifiers. If the DP-Medium object is
+ * ever implemented, this check would need to be
+ * changed so that the input tray's medium size is
+ * obtained from the indicated Medium object, and not
+ * inferred from the medium identifier itself.
+ */
+ if((tray_ds->list)[i_ds].page_size == current_medium)
+ {
+ /*
+ * The current input tray's medium size matches the
+ * current discrete medium size.
+ */
+ break;
+ }
+ }
+ if(i_ds == tray_ds->count)
+ {
+ /*
+ * The current input tray's medium size was not found in the
+ * discrete size list; mark the input tray medium entry
+ * invalid
+ */
+ me->list[i_itm].input_tray = xpoid_none;
+ }
+
+ }
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidTrayMediumListString
+ *
+ * Description:
+ *
+ * Creates a string representation of an XpOidTrayMediumList structure.
+ *
+ * Return value:
+ *
+ * A newly allocated
+ *
+ */
+char* XpOidTrayMediumListString(const XpOidTrayMediumList* me)
+{
+ int i;
+ int length;
+ char* str;
+ char* ptr;
+ XpOid tray;
+ /*
+ * allocate enough memory for the string representation,
+ * including intervening delimiters and whitespace
+ */
+ for(i = 0, length = 0; i < XpOidTrayMediumListCount(me); i++)
+ {
+ tray = XpOidTrayMediumListTray(me, i);
+ if(xpoid_none != tray)
+ {
+ length += XpOidStringLength(tray);
+ length += XpOidStringLength(XpOidTrayMediumListMedium(me, i));
+ length += 4;
+ }
+ }
+ str = XpOidMalloc(length+1);
+ /*
+ * format the list
+ */
+ for(i = 0, ptr = str; i < XpOidTrayMediumListCount(me); i++)
+ {
+ tray = XpOidTrayMediumListTray(me, i);
+ if(xpoid_none != tray)
+ {
+#if defined(sun) && !defined(SVR4)
+ sprintf(ptr, "{%s %s} ",
+ XpOidString(tray),
+ XpOidString(XpOidTrayMediumListMedium(me, i)));
+ ptr += strlen(ptr);
+#else
+ ptr += sprintf(ptr, "{%s %s} ",
+ XpOidString(tray),
+ XpOidString(XpOidTrayMediumListMedium(me, i)));
+#endif
+ }
+ }
+ /*
+ * chop trailing whitespace or terminate empty string
+ */
+ str[length] = '\0';
+ /*
+ * return
+ */
+ return str;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidTrayMediumListHasTray
+ *
+ * Description:
+ *
+ * Determines if 'tray' is found in 'list'.
+ *
+ * Return value:
+ *
+ * xTrue if the tray is found in the list.
+ *
+ * xFalse if the tray is not in the list, or if 'list' is NULL.
+ *
+ */
+BOOL
+XpOidTrayMediumListHasTray(const XpOidTrayMediumList* list, XpOid tray)
+{
+ int i;
+ if(list != (XpOidTrayMediumList*)NULL && tray != xpoid_none)
+ for(i = 0; i < list->count; i++)
+ if(XpOidTrayMediumListTray(list, i) == tray)
+ return xTrue;
+ return xFalse;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: ParseArea
+ *
+ * Description:
+ *
+ * Skips leading whitespace and parses out and returns a XpOidArea.
+ *
+ * Return value:
+ *
+ * xTrue if the XpOidArea was successfully parsed. ptr_return is
+ * updated to point to location where the parsing ended.
+ *
+ * xFalse if a XpOidArea was not found; ptr_return is updated
+ * to point to the first non-whitespace char in value_string.
+ *
+ */
+static BOOL
+ParseArea(const char* value_string,
+ const char** ptr_return,
+ XpOidArea* area_return)
+{
+ const char* first_nonws_ptr;
+ const char* ptr;
+ /*
+ * skip leading whitespace
+ */
+ first_nonws_ptr = value_string + SpanWhitespace(value_string);
+ /*
+ * parse out the area sequence start
+ */
+ if(!ParseSeqStart(first_nonws_ptr, &ptr))
+ goto ParseArea_error;
+ /*
+ * parse the minimum x value
+ */
+ if(!ParseRealValue(ptr, &ptr,
+ area_return ? &area_return->minimum_x : NULL))
+ goto ParseArea_error;
+ /*
+ * parse the maximum x value
+ */
+ if(!ParseRealValue(ptr, &ptr,
+ area_return ? &area_return->maximum_x : NULL))
+ goto ParseArea_error;
+ /*
+ * parse the minimum y value
+ */
+ if(!ParseRealValue(ptr, &ptr,
+ area_return ? &area_return->minimum_y : NULL))
+ goto ParseArea_error;
+ /*
+ * parse the maximum y value
+ */
+ if(!ParseRealValue(ptr, &ptr,
+ area_return ? &area_return->maximum_y : NULL))
+ goto ParseArea_error;
+ /*
+ * parse out the area sequence end
+ */
+ if(!ParseSeqEnd(ptr, &ptr))
+ goto ParseArea_error;
+ /*
+ * update the return pointer
+ */
+ if(ptr_return != (const char**)NULL)
+ *ptr_return = ptr;
+ /*
+ * return
+ */
+ return xTrue;
+
+
+ ParseArea_error:
+ /*
+ * syntax error
+ */
+ if(ptr_return != (const char**)NULL)
+ *ptr_return = first_nonws_ptr;
+ return xFalse;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: ParseRealRange
+ *
+ * Description:
+ *
+ * Skips leading whitespace and parses out and returns a
+ * XpOidRealRange.
+ *
+ * Return value:
+ *
+ * xTrue if the XpOidRealRange was successfully
+ * parsed. ptr_return is updated to point to location where the
+ * parsing ended.
+ *
+ * xFalse if a XpOidRealRange was not found; ptr_return is
+ * updated to point to the first non-whitespace char in value_string.
+ *
+ */
+static BOOL
+ParseRealRange(const char* value_string,
+ const char** ptr_return,
+ XpOidRealRange* range_return)
+{
+ const char* first_nonws_ptr;
+ const char* ptr;
+ /*
+ * skip leading whitespace
+ */
+ first_nonws_ptr = value_string + SpanWhitespace(value_string);
+ /*
+ * parse out the range sequence start
+ */
+ if(!ParseSeqStart(first_nonws_ptr, &ptr))
+ goto ParseRealRange_error;
+ /*
+ * parse the lower bound
+ */
+ if(!ParseRealValue(ptr, &ptr,
+ range_return ? &range_return->lower_bound : NULL))
+ goto ParseRealRange_error;
+ /*
+ * parse the upper bound
+ */
+ if(!ParseRealValue(ptr, &ptr,
+ range_return ? &range_return->upper_bound : NULL))
+ goto ParseRealRange_error;
+ /*
+ * parse out the range sequence end
+ */
+ if(!ParseSeqEnd(ptr, &ptr))
+ goto ParseRealRange_error;
+ /*
+ * update the return pointer
+ */
+ if(ptr_return != (const char**)NULL)
+ *ptr_return = ptr;
+ /*
+ * return
+ */
+ return xTrue;
+
+
+ ParseRealRange_error:
+ /*
+ * syntax error
+ */
+ if(ptr_return != (const char**)NULL)
+ *ptr_return = first_nonws_ptr;
+ return xFalse;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidNotifyParse
+ *
+ * Description:
+ *
+ *
+ * Return value:
+ *
+ *
+ */
+XpOidNotify XpOidNotifyParse(const char* value_string)
+{
+ const char* ptr = value_string;
+
+ if(value_string == (const char*)NULL)
+ return XPOID_NOTIFY_NONE;
+ /*
+ * look for an event handling profile sequence start
+ */
+ if(!ParseSeqStart(value_string, &ptr))
+ {
+ if('\0' == *ptr)
+ /*
+ * empty value is valid
+ */
+ return XPOID_NOTIFY_NONE;
+ else
+ return XPOID_NOTIFY_UNSUPPORTED;
+ }
+ /*
+ * look for an event set sequence start
+ */
+ if(!ParseSeqStart(ptr, &ptr))
+ {
+ /*
+ * check for an empty event handling profile
+ */
+ if(ParseSeqEnd(ptr, &ptr))
+ {
+ ptr += SpanWhitespace(ptr);
+ if(*ptr == '\0')
+ /*
+ * valid empty event handling profile sequence
+ */
+ return XPOID_NOTIFY_NONE;
+ }
+ return XPOID_NOTIFY_UNSUPPORTED;
+ }
+ /*
+ * the only event in the set should be report job completed
+ */
+ if(xpoid_val_event_report_job_completed != XpOidParse(ptr, &ptr))
+ return XPOID_NOTIFY_UNSUPPORTED;
+ /*
+ * event set sequence end
+ */
+ if(!ParseSeqEnd(ptr, &ptr))
+ return XPOID_NOTIFY_UNSUPPORTED;
+ /*
+ * delivery method of electronic mail
+ */
+ if(xpoid_val_delivery_method_electronic_mail != XpOidParse(ptr, &ptr))
+ return XPOID_NOTIFY_UNSUPPORTED;
+ /*
+ * event handling profile sequence end
+ */
+ if(!ParseSeqEnd(ptr, &ptr))
+ return XPOID_NOTIFY_UNSUPPORTED;
+ /*
+ * end of value
+ */
+ ptr += SpanWhitespace(ptr);
+ if('\0' == *ptr)
+ /*
+ * valid supported notification profile
+ */
+ return XPOID_NOTIFY_EMAIL;
+ else
+ return XPOID_NOTIFY_UNSUPPORTED;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidNotifyString
+ *
+ * Description:
+ *
+ *
+ * Return value:
+ *
+ *
+ */
+const char* XpOidNotifyString(XpOidNotify notify)
+{
+ switch(notify)
+ {
+ case XPOID_NOTIFY_NONE:
+ return NOTIFY_NONE_STR;
+ case XPOID_NOTIFY_EMAIL:
+ return NOTIFY_EMAIL_STR;
+ case XPOID_NOTIFY_UNSUPPORTED:
+ return (const char *)NULL;
+ }
+
+ ErrorF("XpOidNotifyString: Unsupported notify=%ld\n", (long)notify);
+ return (const char *)NULL;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidDocFmtNew
+ *
+ * Description:
+ *
+ *
+ * Return value:
+ *
+ *
+ */
+XpOidDocFmt*
+XpOidDocFmtNew(const char* value_string)
+{
+ XpOidDocFmt* doc_fmt;
+ const char* ptr;
+
+ if((const char*)NULL == value_string)
+ return (XpOidDocFmt*)NULL;
+ ptr = value_string + SpanWhitespace(value_string);
+ if('\0' == *ptr)
+ return (XpOidDocFmt*)NULL;
+ /*
+ * get the document format from the value string
+ */
+ doc_fmt = (XpOidDocFmt*)XpOidCalloc(1, sizeof(XpOidDocFmt));
+ if(xTrue == XpOidDocFmtNext(doc_fmt, ptr, &ptr))
+ {
+ /*
+ * verify that the document format is the only value specified
+ */
+ ptr += SpanWhitespace(ptr);
+ if('\0' == *ptr)
+ /*
+ * valid document-format value
+ */
+ return doc_fmt;
+ }
+ /*
+ * invalid
+ */
+ XpOidDocFmtDelete(doc_fmt);
+ ErrorF("%s\n", XPMSG_WARN_DOC_FMT);
+ return (XpOidDocFmt*)NULL;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidDocFmtDelete
+ *
+ * Description:
+ *
+ *
+ * Return value:
+ *
+ *
+ */
+void
+XpOidDocFmtDelete(XpOidDocFmt* doc_fmt)
+{
+ if((XpOidDocFmt*)NULL != doc_fmt)
+ {
+ XpOidFree(doc_fmt->format);
+ XpOidFree(doc_fmt->variant);
+ XpOidFree(doc_fmt->version);
+ XpOidFree(doc_fmt);
+ }
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidDocFmtString
+ *
+ * Description:
+ *
+ *
+ * Return value:
+ *
+ *
+ */
+char*
+XpOidDocFmtString(XpOidDocFmt* doc_fmt)
+{
+ if((XpOidDocFmt*)NULL != doc_fmt)
+ {
+ if((char*)NULL != doc_fmt->format)
+ {
+ char* str = XpOidMalloc(1+SafeStrLen(doc_fmt->format)+
+ 1+SafeStrLen(doc_fmt->variant)+
+ 1+SafeStrLen(doc_fmt->version)+
+ 1+1);
+ sprintf(str, "{%s %s %s}", doc_fmt->format,
+ (char*)NULL != doc_fmt->variant ? doc_fmt->variant : "",
+ (char*)NULL != doc_fmt->version ? doc_fmt->version : "");
+ return str;
+ }
+ }
+ return (char*)NULL;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidDocFmtNext
+ *
+ * Description:
+ *
+ * Assumes non-NULL value string.
+ *
+ * Return value:
+ *
+ *
+ */
+static BOOL
+XpOidDocFmtNext(XpOidDocFmt* doc_fmt,
+ const char* value_string,
+ const char** ptr_return)
+{
+ const char* ptr;
+ const char* first_nonws_ptr;
+ const char* format;
+ const char* variant;
+ const char* version;
+ int format_len;
+ int variant_len;
+ int version_len;
+ /*
+ * skip leading whitespace
+ */
+ ptr = value_string + SpanWhitespace(value_string);
+ first_nonws_ptr = ptr;
+ /*
+ * sequence start
+ */
+ if(!ParseSeqStart(ptr, &ptr))
+ goto XpOidDocFmtNext_error;
+ /*
+ * skip whitepace to the start of the document format, and save the
+ * location
+ */
+ ptr += SpanWhitespace(ptr);
+ format = ptr;
+ /*
+ * document format
+ */
+ if(0 == (format_len = SpanToken(ptr)))
+ goto XpOidDocFmtNext_error;
+ ptr += format_len;
+ /*
+ * optional variant
+ */
+ ptr += SpanWhitespace(ptr);
+ variant = ptr;
+ if(0 != (variant_len = SpanToken(ptr)))
+ {
+ ptr += variant_len;
+ /*
+ * optional version
+ */
+ ptr += SpanWhitespace(ptr);
+ version = ptr;
+ version_len = SpanToken(ptr);
+ ptr += version_len;
+ }
+ else
+ version_len = 0;
+ /*
+ * sequence end
+ */
+ if(!ParseSeqEnd(ptr, &ptr))
+ goto XpOidDocFmtNext_error;
+ /*
+ * update return pointer
+ */
+ if((const char**)NULL != ptr_return)
+ *ptr_return = ptr;
+ /*
+ * update the passed document format struct
+ */
+ memset(doc_fmt, 0, sizeof(XpOidDocFmt));
+ doc_fmt->format = XpOidMalloc(format_len+1);
+ strncpy(doc_fmt->format, format, format_len);
+ doc_fmt->format[format_len] = '\0';
+ if(0 < variant_len)
+ {
+ doc_fmt->variant = XpOidMalloc(variant_len+1);
+ strncpy(doc_fmt->variant, variant, variant_len);
+ doc_fmt->variant[variant_len] = '\0';
+ if(0 < version_len)
+ {
+ doc_fmt->version = XpOidMalloc(version_len+1);
+ strncpy(doc_fmt->version, version, version_len);
+ doc_fmt->version[version_len] = '\0';
+ }
+ }
+ return xTrue;
+
+ XpOidDocFmtNext_error:
+ if((const char**)NULL != ptr_return)
+ *ptr_return = first_nonws_ptr;
+ return xFalse;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidDocFmtListNew
+ *
+ * Description:
+ *
+ *
+ * Return value:
+ *
+ *
+ */
+XpOidDocFmtList*
+XpOidDocFmtListNew(const char* value_string,
+ const XpOidDocFmtList* valid_fmts)
+{
+ if((char*)NULL != value_string)
+ {
+ const char* ptr;
+ return XpOidDocFmtListParse(value_string, valid_fmts, &ptr, 0);
+ }
+ return (XpOidDocFmtList*)NULL;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidDocFmtListDelete
+ *
+ * Description:
+ *
+ *
+ * Return value:
+ *
+ *
+ */
+void
+XpOidDocFmtListDelete(XpOidDocFmtList* list)
+{
+ if((XpOidDocFmtList*)NULL != list)
+ {
+ int i;
+ for(i = 0; i < list->count; i++)
+ {
+ XpOidFree(list->list[i].format);
+ XpOidFree(list->list[i].variant);
+ XpOidFree(list->list[i].version);
+ }
+ XpOidFree(list->list);
+ XpOidFree(list);
+ }
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidDocFmtListString
+ *
+ * Description:
+ *
+ * Assumes the passed structure is valid.
+ *
+ * Return value:
+ *
+ *
+ */
+char*
+XpOidDocFmtListString(const XpOidDocFmtList* list)
+{
+ if((XpOidDocFmtList*)NULL != list)
+ {
+ if(0 < list->count)
+ {
+ int i;
+ int str_len;
+ char* str;
+ char* ptr;
+ /*
+ * allocate the return string
+ */
+ for(i = 0, str_len = 0; i < list->count; i++)
+ {
+ str_len +=
+ 1 + SafeStrLen(list->list[i].format) +
+ 1 + SafeStrLen(list->list[i].variant) +
+ 1 + SafeStrLen(list->list[i].version) + 2;
+ }
+ str = XpOidMalloc(str_len+1);
+ /*
+ * print the list into the string and return it
+ */
+ ptr = str;
+ for(i = 0; i < list->count; i++)
+ {
+ XpOidDocFmt* df = &list->list[i];
+
+#if defined(sun) && !defined(SVR4)
+ sprintf(ptr, "{%s %s %s} ",
+ df->format,
+ (char*)NULL != df->variant ? df->variant : "",
+ (char*)NULL != df->version ? df->version : "");
+ ptr += strlen(ptr);
+#else
+ ptr +=
+ sprintf(ptr, "{%s %s %s} ",
+ df->format,
+ (char*)NULL != df->variant ? df->variant : "",
+ (char*)NULL != df->version ? df->version : "");
+#endif
+ }
+ return str;
+ }
+ }
+ return (char*)NULL;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidDocFmtListParse
+ *
+ * Description:
+ *
+ * Assumes the passed value_string and ptr_return are non-NULL.
+ *
+ * Return value:
+ *
+ *
+ */
+static XpOidDocFmtList*
+XpOidDocFmtListParse(const char* value_string,
+ const XpOidDocFmtList* valid_fmts,
+ const char** ptr_return,
+ int i)
+{
+ XpOidDocFmt doc_fmt;
+ XpOidDocFmtList* list;
+ BOOL status;
+ /*
+ * get the next document-format from the value string, skipping
+ * values not found in the passed list of valid formats
+ */
+ *ptr_return = value_string;
+ while((status = XpOidDocFmtNext(&doc_fmt, *ptr_return, ptr_return))
+ &&
+ (const XpOidDocFmtList*)NULL != valid_fmts
+ &&
+ !XpOidDocFmtListHasFmt(valid_fmts, &doc_fmt)
+ );
+
+ if(xFalse == status)
+ {
+ if('\0' == **ptr_return)
+ {
+ if(0 == i)
+ {
+ /*
+ * empty value string
+ */
+ return (XpOidDocFmtList*)NULL;
+ }
+ else
+ {
+ /*
+ * done parsing; allocate the list and return
+ */
+ list =
+ (XpOidDocFmtList*)XpOidCalloc(1, sizeof(XpOidDocFmtList));
+ list->count = i;
+ list->list = (XpOidDocFmt*)XpOidCalloc(i, sizeof(XpOidDocFmt));
+ return list;
+ }
+ }
+ else
+ {
+ /*
+ * invalid document format
+ */
+ ErrorF("%s\n", XPMSG_WARN_DOCFMT_LIST);
+ return (XpOidDocFmtList*)NULL;
+ }
+ }
+ else
+ {
+ /*
+ * recurse to parse remaining document formats
+ */
+ list = XpOidDocFmtListParse(*ptr_return, valid_fmts, ptr_return, i+1);
+ if((XpOidDocFmtList*)NULL != list)
+ {
+ /*
+ * add this doc fmt to the list
+ */
+ list->list[i].format = doc_fmt.format;
+ list->list[i].variant = doc_fmt.variant;
+ list->list[i].version = doc_fmt.version;
+ }
+ return list;
+ }
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidDocFmtListHasFmt
+ *
+ * Description:
+ *
+ * Assumes the passed structure is valid.
+ *
+ * Return value:
+ *
+ *
+ */
+BOOL
+XpOidDocFmtListHasFmt(const XpOidDocFmtList* list,
+ const XpOidDocFmt* fmt)
+{
+ int i;
+ if(list != (XpOidDocFmtList*)NULL
+ &&
+ fmt != (XpOidDocFmt*)NULL
+ &&
+ fmt->format != (char*)NULL
+ )
+ {
+ for(i = 0; i < list->count; i++)
+ {
+ /*
+ * formats must match
+ */
+ if(strcmp(fmt->format, list->list[i].format) != 0)
+ continue;
+ /*
+ * variants must both be NULL or match
+ */
+ if(fmt->variant == (char*)NULL)
+ {
+ if(list->list[i].variant == (char*)NULL)
+ return xTrue;
+ else
+ continue;
+ }
+ if(list->list[i].variant == (char*)NULL)
+ continue;
+ if(strcmp(fmt->variant, list->list[i].variant) != 0)
+ continue;
+ /*
+ * versions must both be NULL or match
+ */
+ if(fmt->version == (char*)NULL)
+ {
+ if(list->list[i].version == (char*)NULL)
+ return xTrue;
+ else
+ continue;
+ }
+ if(list->list[i].version == (char*)NULL)
+ continue;
+ if(strcmp(fmt->version, list->list[i].version) == 0)
+ return xTrue;
+ }
+ }
+ return xFalse;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidCardListNew
+ *
+ * Description:
+ *
+ *
+ * Return value:
+ *
+ *
+ */
+XpOidCardList*
+XpOidCardListNew(const char* value_string, const XpOidCardList* valid_cards)
+{
+ if((const char*)NULL != value_string)
+ {
+ const char* ptr;
+
+ return XpOidCardListParse(value_string, valid_cards, &ptr, 0);
+ }
+ else
+ return (XpOidCardList*)NULL;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidCardListDelete
+ *
+ * Description:
+ *
+ *
+ * Return value:
+ *
+ *
+ */
+void
+XpOidCardListDelete(XpOidCardList* list)
+{
+ if((XpOidCardList*)NULL != list)
+ {
+ XpOidFree(list->list);
+ XpOidFree(list);
+ }
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidCardListString
+ *
+ * Description:
+ *
+ *
+ * Return value:
+ *
+ *
+ */
+char*
+XpOidCardListString(const XpOidCardList* list)
+{
+ if((XpOidCardList*)NULL != list)
+ {
+ char buf[48];
+ int str_len;
+ char* str;
+ int i;
+ char* ptr;
+ /*
+ * allocate the output string
+ */
+ for(i = 0, str_len = 0; i < list->count; i++)
+#if defined(sun) && !defined(SVR4)
+ {
+ sprintf(buf, "%lu", list->list[i]) + 1;
+ str_len += strlen(buf);
+ }
+#else
+ str_len += sprintf(buf, "%lu", list->list[i]) + 1;
+#endif
+ str = XpOidMalloc(str_len+1);
+ /*
+ * write the list to the string
+ */
+ for(i = 0, ptr = str; i < list->count; i++)
+#if defined(sun) && !defined(SVR4)
+ {
+ sprintf(ptr, "%lu ", list->list[i]);
+ ptr += strlen(ptr);
+ }
+#else
+ ptr += sprintf(ptr, "%lu ", list->list[i]);
+#endif
+ return str;
+ }
+ else
+ return (char*)NULL;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidCardListHasCard
+ *
+ * Description:
+ *
+ * Determines if 'card' is an element of 'list'.
+ *
+ * Return value:
+ *
+ * xTrue if the card is found in the list.
+ *
+ * xFalse if the card is not in the list, or if 'list' is NULL.
+ *
+ */
+BOOL
+XpOidCardListHasCard(const XpOidCardList* list, unsigned long card)
+{
+ int i;
+ if(list != (XpOidCardList*)NULL)
+ for(i = 0; i < list->count; i++)
+ if(list->list[i] == card)
+ return xTrue;
+ return xFalse;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidCardListParse
+ *
+ * Description:
+ *
+ * Assumes the passed value_string and ptr_return are non-NULL.
+ *
+ * Return value:
+ *
+ *
+ */
+static XpOidCardList*
+XpOidCardListParse(const char* value_string,
+ const XpOidCardList* valid_cards,
+ const char** ptr_return,
+ int i)
+{
+ unsigned long card;
+ XpOidCardList* list;
+ BOOL status;
+
+ /*
+ * get the next card from the value string, skipping values not
+ * found in the passed list of valid cards
+ */
+ *ptr_return = value_string;
+ while((status = XpOidParseUnsignedValue(*ptr_return, ptr_return, &card))
+ &&
+ (const XpOidCardList*)NULL != valid_cards
+ &&
+ !XpOidCardListHasCard(valid_cards, card)
+ );
+
+ if(xFalse == status)
+ {
+ if('\0' == **ptr_return)
+ {
+ if(0 == i)
+ {
+ /*
+ * empty value string
+ */
+ return (XpOidCardList*)NULL;
+ }
+ else
+ {
+ /*
+ * done parsing; allocate the list and return
+ */
+ list = (XpOidCardList*)XpOidCalloc(1, sizeof(XpOidCardList));
+ list->count = i;
+ list->list =
+ (unsigned long*)XpOidCalloc(i, sizeof(unsigned long));
+ return list;
+ }
+ }
+ else
+ {
+ /*
+ * parsing error
+ */
+ ErrorF("%s\n", XPMSG_WARN_CARD_LIST);
+ return (XpOidCardList*)NULL;
+ }
+ }
+ else
+ {
+ /*
+ * recurse to parse remaining cardinal values
+ */
+ list = XpOidCardListParse(*ptr_return, valid_cards, ptr_return, i+1);
+ if((XpOidCardList*)NULL != list)
+ {
+ /*
+ * add this value to the list
+ */
+ list->list[i] = card;
+ }
+ return list;
+ }
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: ParseBoolValue
+ *
+ * Description:
+ *
+ *
+ * Return value:
+ *
+ *
+ */
+static BOOL
+ParseBoolValue(const char* value_string,
+ const char** ptr_return,
+ BOOL* bool_return)
+{
+ const char* ptr;
+ int length;
+ BOOL status;
+ /*
+ * skip leading whitespace
+ */
+ ptr = value_string + SpanWhitespace(value_string);
+ /*
+ * get the whitespace-delimited token length
+ */
+ length = SpanToken(ptr);
+ /*
+ * determine if true or false or bad
+ */
+ if(StrnCaseCmp(ptr, "TRUE", length) == 0)
+ {
+ if(bool_return != (BOOL*)NULL)
+ *bool_return = xTrue;
+ status = xTrue;
+ }
+ else if(StrnCaseCmp(ptr, "FALSE", length) == 0)
+ {
+ if(bool_return != (BOOL*)NULL)
+ *bool_return = xFalse;
+ status = xTrue;
+ }
+ else
+ {
+ /*
+ * syntax error
+ */
+ status = xFalse;
+ }
+ /*
+ * update the return pointer and return
+ */
+ if(ptr_return != (const char**)NULL)
+ *ptr_return = status ? ptr+length : ptr;
+ return status;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: XpOidParseUnsignedValue
+ *
+ * Description:
+ *
+ * Skips leading whitespace and parses out and returns a unsigned number.
+ *
+ * Return value:
+ *
+ * xTrue if a unsigned number was successfully parsed. ptr_return is
+ * updated to point to location where the unsigned number parsing
+ * ended.
+ *
+ * xFalse if a unsigned number was not found; ptr_return is updated
+ * to point to the first non-whitespace char in value_string.
+ *
+ */
+BOOL
+XpOidParseUnsignedValue(const char* value_string,
+ const char** ptr_return,
+ unsigned long* unsigned_return)
+{
+ long value;
+ BOOL status;
+ const char* first_nonws_ptr;
+ const char* ptr;
+ /*
+ * skip leading whitespace
+ */
+ first_nonws_ptr = value_string + SpanWhitespace(value_string);
+ value = strtol(first_nonws_ptr, (char**)(&ptr), 0);
+ if(ptr == first_nonws_ptr || value < 0)
+ status = xFalse;
+ else
+ status = xTrue;
+ /*
+ * update return parms
+ */
+ if(ptr_return != (const char**)NULL)
+ *ptr_return = ptr;
+ if(unsigned_return != (unsigned long*)NULL)
+ *unsigned_return = (unsigned long)value;
+ /*
+ * return
+ */
+ return status;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: ParseRealValue
+ *
+ * Description:
+ *
+ * Skips leading whitespace and parses out and returns a real number.
+ *
+ * Return value:
+ *
+ * xTrue if a real number was successfully parsed. ptr_return is
+ * updated to point to location where the real number parsing
+ * ended.
+ *
+ * xFalse if a real number was not found; ptr_return is updated
+ * to point to the first non-whitespace char in value_string.
+ *
+ */
+static BOOL
+ParseRealValue(const char* value_string,
+ const char** ptr_return,
+ float* real_return)
+{
+ float real_value;
+ BOOL status;
+ const char* first_nonws_ptr;
+ const char* ptr;
+ /*
+ * skip leading whitespace
+ */
+ first_nonws_ptr = value_string + SpanWhitespace(value_string);
+ real_value = (float)strtod(first_nonws_ptr, (char**)(&ptr));
+ if(ptr == first_nonws_ptr)
+ status = xFalse;
+ else
+ status = xTrue;
+ /*
+ * update return parms
+ */
+ if(ptr_return != (const char**)NULL)
+ *ptr_return = ptr;
+ if(real_return != (float*)NULL)
+ *real_return = real_value;
+ /*
+ * return
+ */
+ return status;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: ParseSeqEnd
+ *
+ * Description:
+ *
+ * Description:
+ *
+ * Skips leading whitespace and parses out the sequence end
+ * character '}'.
+ *
+ * Return value:
+ *
+ * xTrue if the sequence end character was parsed; ptr_return is
+ * updated to point to the first char following the sequence end
+ * character.
+ *
+ * xFalse if the sequence end character was not found; ptr_return is
+ * updated to point to the first non-whitespace char in value_string.
+ *
+ */
+static BOOL
+ParseSeqEnd(const char* value_string,
+ const char** ptr_return)
+{
+ const char* ptr;
+ BOOL status;
+ /*
+ * skip leading whitespace
+ */
+ ptr = value_string + SpanWhitespace(value_string);
+ /*
+ * parse out the sequence end character
+ */
+ if(*ptr == '}')
+ {
+ status = xTrue;
+ ++ptr;
+ }
+ else
+ status = xFalse;
+ /*
+ * update the return pointer
+ */
+ if(ptr_return != (const char**)NULL)
+ *ptr_return = ptr;
+ /*
+ * return
+ */
+ return status;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: ParseSeqStart
+ *
+ * Description:
+ *
+ * Skips leading whitespace and parses out the sequence start
+ * character '{'.
+ *
+ * Return value:
+ *
+ * xTrue if the sequence start character was parsed; ptr_return is
+ * updated to point to the first char following the sequence start
+ * character.
+ *
+ * xFalse if the sequence start character was not found; ptr_return is
+ * updated to point to the first non-whitespace char in value_string.
+ *
+ */
+static BOOL
+ParseSeqStart(const char* value_string,
+ const char** ptr_return)
+{
+ const char* ptr;
+ BOOL status;
+ /*
+ * skip leading whitespace
+ */
+ ptr = value_string + SpanWhitespace(value_string);
+ /*
+ * parse out the sequence start character
+ */
+ if(*ptr == '{')
+ {
+ status = xTrue;
+ ++ptr;
+ }
+ else
+ status = xFalse;
+ /*
+ * update the return pointer
+ */
+ if(ptr_return != (const char**)NULL)
+ *ptr_return = ptr;
+ /*
+ * return
+ */
+ return status;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: ParseUnspecifiedValue
+ *
+ * Description:
+ *
+ * Skips leading whitespace and parses out an unspecified optional
+ * value (i.e. matching '' or "" - skips all data between the set of
+ * quotes).
+ *
+ * Return value:
+ *
+ * xTrue if an unspecified value was parsed; ptr_return is updated to
+ * point to the first char following the trailing quote.
+ *
+ * xFalse if an unspecified value was not found; ptr_return is updated
+ * to point to the first non-whitespace char in value_string.
+ *
+ */
+static BOOL
+ParseUnspecifiedValue(const char* value_string,
+ const char** ptr_return)
+{
+ BOOL status;
+ const char* ptr;
+ /*
+ * skip leading whitespace
+ */
+ ptr = value_string + SpanWhitespace(value_string);
+ /*
+ * parse out an unspecified optional value ('' or "")
+ */
+ if(*ptr == '\'' || *ptr == '"')
+ {
+ char delim[2];
+
+ if(ptr_return != (const char**)NULL)
+ {
+ delim[0] = *ptr;
+ delim[1] = '\0';
+ /*
+ * skip over the matching delimiter
+ */
+ ++ptr;
+ ptr += strcspn(ptr, delim);
+ if(*ptr != '\0')
+ ++ptr;
+ }
+ status = xTrue;
+ }
+ else
+ status = xFalse;
+ /*
+ * update the return pointer
+ */
+ if(ptr_return != (const char**)NULL)
+ *ptr_return = ptr;
+ /*
+ * return
+ */
+ return status;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: SpanToken
+ *
+ * Description:
+ *
+ * Returns the length of the initial segment of the passed string
+ * that consists entirely of non-whitespace and non-sequence
+ * delimiter characters.
+ *
+ *
+ */
+static int
+SpanToken(const char* string)
+{
+ const char* ptr;
+ for(ptr = string;
+ *ptr != '\0' && !isspace(*ptr) && *ptr != '{' && *ptr != '}';
+ ++ptr);
+ return ptr - string;
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Name: SpanWhitespace
+ *
+ * Description:
+ *
+ * Returns the length of the initial segment of the passed string
+ * that consists entirely of whitespace characters.
+ *
+ *
+ */
+static int
+SpanWhitespace(const char* string)
+{
+ const char* ptr;
+ for(ptr = string; *ptr != '\0' && isspace(*ptr); ++ptr);
+ return ptr - string;
+}
+
+#ifndef HAVE_STRCASECMP
+/*
+ * ------------------------------------------------------------------------
+ * Name: StrnCaseCmp
+ *
+ * Description:
+ *
+ * Implements strncasecmp() for those platforms that need it.
+ *
+ *
+ */
+static int
+StrnCaseCmp(const char *s1, const char *s2, size_t len)
+{
+ char c1, c2;
+ int result;
+
+ while (len--)
+ {
+ c1 = *s1++;
+ c2 = *s2++;
+ result = tolower(c1) - tolower(c2);
+
+ if (result != 0)
+ return result;
+ }
+
+ return 0;
+}
+#endif
diff --git a/nx-X11/programs/Xserver/Xprint/Oid.h b/nx-X11/programs/Xserver/Xprint/Oid.h
new file mode 100644
index 000000000..ba9dc77f3
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/Oid.h
@@ -0,0 +1,294 @@
+/* $Xorg: Oid.h,v 1.3 2000/08/17 19:48:06 cpqbld Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _Xp_Oid_h
+#define _Xp_Oid_h
+
+#include <X11/Xproto.h>
+
+/*
+ * include the auto-generated XpOid enum definition
+ */
+#include "OidDefs.h"
+
+/*
+ * messages
+ */
+#define XPMSG_WARN_MSS "Syntax error parsing medium-source-sizes"
+#define XPMSG_WARN_ITM "Syntax error parsing input-trays-medium"
+#define XPMSG_WARN_DOC_FMT "Syntax error parsing document format"
+#define XPMSG_WARN_DOCFMT_LIST "Syntax error parsing document format list"
+#define XPMSG_WARN_CARD_LIST "Syntax error parsing cardinal list"
+
+/*
+ * macros for memory allocation
+ */
+#define XpOidMalloc(size) ((char*)Xalloc((unsigned long)(size)))
+#define XpOidCalloc(count, size) \
+ ((char*)Xcalloc((unsigned long)((count)*(size))))
+#define XpOidFree(mem) (Xfree((unsigned long*)(mem)))
+
+/*
+ * list of object identifiers
+ */
+typedef struct _XpOidList
+{
+ XpOid* list;
+ int count;
+} XpOidList;
+
+/*
+ * linked list of object identifiers
+ */
+typedef struct XpOidNodeStruct
+{
+ XpOid oid;
+ struct XpOidNodeStruct* next;
+} *XpOidNode;
+
+typedef struct _XpOidLinkedList
+{
+ XpOidNode head;
+ XpOidNode tail;
+ XpOidNode current;
+ int count;
+} XpOidLinkedList;
+
+/*
+ * XpOidMediumSourceSize and related definitions
+ */
+typedef struct
+{
+ float minimum_x;
+ float maximum_x;
+ float minimum_y;
+ float maximum_y;
+} XpOidArea;
+
+typedef struct
+{
+ float lower_bound;
+ float upper_bound;
+} XpOidRealRange;
+
+typedef struct
+{
+ XpOidRealRange range_across_feed;
+ float increment_across_feed;
+ XpOidRealRange range_in_feed;
+ float increment_in_feed;
+ BOOL long_edge_feeds;
+ XpOidArea assured_reproduction_area;
+} XpOidMediumContinuousSize;
+
+typedef struct
+{
+ XpOid page_size;
+ BOOL long_edge_feeds;
+ XpOidArea assured_reproduction_area;
+} XpOidMediumDiscreteSize;
+
+typedef struct
+{
+ XpOidMediumDiscreteSize* list;
+ int count;
+} XpOidMediumDiscreteSizeList;
+
+typedef struct
+{
+ XpOid input_tray; /* may be set to xpoid_none or xpoid_unspecified */
+ enum { XpOidMediumSS_DISCRETE, XpOidMediumSS_CONTINUOUS } mstag;
+ union
+ {
+ XpOidMediumDiscreteSizeList* discrete;
+ XpOidMediumContinuousSize* continuous_size;
+ } ms; /* "ms" is short for medium-size */
+
+} XpOidMediumSourceSize;
+
+typedef struct
+{
+ XpOidMediumSourceSize* mss;
+ int count;
+} XpOidMediumSS;
+
+
+typedef struct
+{
+ XpOid input_tray; /* may be set to xpoid_none */
+ XpOid medium;
+} XpOidTrayMedium;
+
+typedef struct
+{
+ XpOidTrayMedium* list;
+ int count;
+} XpOidTrayMediumList;
+
+typedef enum {
+ XPOID_NOTIFY_UNSUPPORTED,
+ XPOID_NOTIFY_NONE,
+ XPOID_NOTIFY_EMAIL
+} XpOidNotify;
+
+typedef struct
+{
+ unsigned long *list;
+ int count;
+} XpOidCardList;
+
+typedef struct
+{
+ char* format;
+ char* variant;
+ char* version;
+} XpOidDocFmt;
+
+typedef struct
+{
+ XpOidDocFmt* list;
+ int count;
+} XpOidDocFmtList;
+
+
+/*
+ * XpOid public methods
+ */
+const char* XpOidString(XpOid);
+int XpOidStringLength(XpOid);
+XpOid XpOidFromString(const char* value);
+BOOL XpOidTrayMediumListHasTray(const XpOidTrayMediumList* list, XpOid tray);
+
+/*
+ * XpOidList public methods
+ */
+XpOidList* XpOidListNew(const char* value_string,
+ const XpOidList* valid_oids);
+#define XpOidListInit(l, a, c) { (l)->list = (a); (l)->count = (c); }
+void XpOidListDelete(XpOidList*);
+#define XpOidListCount(l) ((l) ? (l)->count : 0)
+#define XpOidListGetOid(l, i) ((l) ? (l)->list[(i)] : xpoid_none)
+int XpOidListGetIndex(const XpOidList* list, XpOid oid);
+BOOL XpOidListHasOid(const XpOidList* list, XpOid oid);
+char* XpOidListString(const XpOidList*);
+
+
+/*
+ * XpOidLinkedList public methods
+ */
+XpOidLinkedList* XpOidLinkedListNew();
+void XpOidLinkedListDelete(XpOidLinkedList*);
+#define XpOidLinkedListCount(l) ((l) ? (l)->count : 0)
+XpOid XpOidLinkedListGetOid(XpOidLinkedList* list, int i);
+void XpOidLinkedListAddOid(XpOidLinkedList* list, XpOid oid);
+int XpOidLinkedListGetIndex(XpOidLinkedList* list, XpOid oid);
+BOOL XpOidLinkedListHasOid(XpOidLinkedList* list,
+ XpOid oid);
+XpOid XpOidLinkedListFirstOid(XpOidLinkedList* list);
+XpOid XpOidLinkedListNextOid(XpOidLinkedList* list);
+
+/*
+ * XpOidMediumSourceSize public methods
+ */
+XpOidMediumSS* XpOidMediumSSNew(const char* value_string,
+ const XpOidList* valid_trays,
+ const XpOidList* valid_medium_sizes);
+void XpOidMediumSSDelete(XpOidMediumSS*);
+#define XpOidMediumSSCount(me) ((me) ? (me)->count : 0)
+BOOL XpOidMediumSSHasSize(XpOidMediumSS*, XpOid medium_size);
+char* XpOidMediumSSString(const XpOidMediumSS*);
+
+/*
+ * XpOidTrayMediumList public methods
+ */
+XpOidTrayMediumList* XpOidTrayMediumListNew(const char* value_string,
+ const XpOidList* valid_trays,
+ const XpOidMediumSS* msss);
+void XpOidTrayMediumListDelete(XpOidTrayMediumList* me);
+#define XpOidTrayMediumListCount(me) ((me) ? (me)->count : 0)
+#define XpOidTrayMediumListTray(me, i) \
+ ((me) ? (me)->list[(i)].input_tray : xpoid_none)
+#define XpOidTrayMediumListMedium(me, i) \
+ ((me) ? (me)->list[(i)].medium : xpoid_none)
+char* XpOidTrayMediumListString(const XpOidTrayMediumList*);
+
+/*
+ * XpOidNotify public methods
+ */
+XpOidNotify XpOidNotifyParse(const char* value_string);
+const char* XpOidNotifyString(XpOidNotify notify);
+
+/*
+ * XpOidDocFmt public methods
+ */
+XpOidDocFmt* XpOidDocFmtNew(const char* value_string);
+void XpOidDocFmtDelete(XpOidDocFmt*);
+char* XpOidDocFmtString(XpOidDocFmt*);
+
+/*
+ * XpOidDocFmtList public methods
+ */
+XpOidDocFmtList* XpOidDocFmtListNew(const char* value_string,
+ const XpOidDocFmtList* valid_fmts);
+void XpOidDocFmtListDelete(XpOidDocFmtList*);
+char* XpOidDocFmtListString(const XpOidDocFmtList*);
+#define XpOidDocFmtListCount(me) ((me) ? (me)->count : 0)
+#define XpOidDocFmtListGetDocFmt(me, i) \
+ ((me) ? &(me)->list[(i)] : (XpDocFmt*)NULL)
+BOOL XpOidDocFmtListHasFmt(const XpOidDocFmtList* list,
+ const XpOidDocFmt* fmt);
+/*
+ * XpOidCardList public methods
+ */
+XpOidCardList* XpOidCardListNew(const char* value_string,
+ const XpOidCardList* valid_cards);
+#define XpOidCardListInit(l, a, c) { (l)->list = (a); (l)->count = (c); }
+void XpOidCardListDelete(XpOidCardList*);
+char* XpOidCardListString(const XpOidCardList*);
+#define XpOidCardListCount(me) ((me) ? (me)->count : 0)
+#define XpOidCardListGetCard(me, i) ((me) ? (me)->list[(i)] : 0)
+BOOL XpOidCardListHasCard(const XpOidCardList*, unsigned long);
+
+/*
+ * misc parsing functions
+ */
+BOOL XpOidParseUnsignedValue(const char* value_string,
+ const char** ptr_return,
+ unsigned long* unsigned_return);
+
+
+#endif /* _Xp_Oid_h - don't add anything after this line */
diff --git a/nx-X11/programs/Xserver/Xprint/OidDefs.h b/nx-X11/programs/Xserver/Xprint/OidDefs.h
new file mode 100644
index 000000000..55b6568f0
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/OidDefs.h
@@ -0,0 +1,171 @@
+/* $Xorg: OidDefs.h,v 1.4 2001/03/14 18:45:13 pookie Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* This is an automatically-generated file. Do not edit. */
+
+typedef enum {
+ xpoid_none,
+ xpoid_unspecified,
+ xpoid_att_descriptor,
+ xpoid_att_content_orientation,
+ xpoid_att_copy_count,
+ xpoid_att_default_printer_resolution,
+ xpoid_att_default_input_tray,
+ xpoid_att_default_medium,
+ xpoid_att_document_format,
+ xpoid_att_plex,
+ xpoid_att_xp_listfonts_modes,
+ xpoid_att_job_name,
+ xpoid_att_job_owner,
+ xpoid_att_notification_profile,
+ xpoid_att_xp_setup_state,
+ xpoid_att_xp_spooler_command_options,
+ xpoid_att_content_orientations_supported,
+ xpoid_att_document_formats_supported,
+ xpoid_att_dt_pdm_command,
+ xpoid_att_input_trays_medium,
+ xpoid_att_medium_source_sizes_supported,
+ xpoid_att_plexes_supported,
+ xpoid_att_printer_model,
+ xpoid_att_printer_name,
+ xpoid_att_printer_resolutions_supported,
+ xpoid_att_xp_embedded_formats_supported,
+ xpoid_att_xp_listfonts_modes_supported,
+ xpoid_att_xp_page_attributes_supported,
+ xpoid_att_xp_raw_formats_supported,
+ xpoid_att_xp_setup_proviso,
+ xpoid_att_document_attributes_supported,
+ xpoid_att_job_attributes_supported,
+ xpoid_att_locale,
+ xpoid_att_multiple_documents_supported,
+ xpoid_att_available_compression,
+ xpoid_att_available_compressions_supported,
+ xpoid_val_content_orientation_portrait,
+ xpoid_val_content_orientation_landscape,
+ xpoid_val_content_orientation_reverse_portrait,
+ xpoid_val_content_orientation_reverse_landscape,
+ xpoid_val_medium_size_iso_a0,
+ xpoid_val_medium_size_iso_a1,
+ xpoid_val_medium_size_iso_a2,
+ xpoid_val_medium_size_iso_a3,
+ xpoid_val_medium_size_iso_a4,
+ xpoid_val_medium_size_iso_a5,
+ xpoid_val_medium_size_iso_a6,
+ xpoid_val_medium_size_iso_a7,
+ xpoid_val_medium_size_iso_a8,
+ xpoid_val_medium_size_iso_a9,
+ xpoid_val_medium_size_iso_a10,
+ xpoid_val_medium_size_iso_b0,
+ xpoid_val_medium_size_iso_b1,
+ xpoid_val_medium_size_iso_b2,
+ xpoid_val_medium_size_iso_b3,
+ xpoid_val_medium_size_iso_b4,
+ xpoid_val_medium_size_iso_b5,
+ xpoid_val_medium_size_iso_b6,
+ xpoid_val_medium_size_iso_b7,
+ xpoid_val_medium_size_iso_b8,
+ xpoid_val_medium_size_iso_b9,
+ xpoid_val_medium_size_iso_b10,
+ xpoid_val_medium_size_na_letter,
+ xpoid_val_medium_size_na_legal,
+ xpoid_val_medium_size_executive,
+ xpoid_val_medium_size_folio,
+ xpoid_val_medium_size_invoice,
+ xpoid_val_medium_size_ledger,
+ xpoid_val_medium_size_quarto,
+ xpoid_val_medium_size_iso_c3,
+ xpoid_val_medium_size_iso_c4,
+ xpoid_val_medium_size_iso_c5,
+ xpoid_val_medium_size_iso_c6,
+ xpoid_val_medium_size_iso_designated_long,
+ xpoid_val_medium_size_na_10x13_envelope,
+ xpoid_val_medium_size_na_9x12_envelope,
+ xpoid_val_medium_size_na_number_10_envelope,
+ xpoid_val_medium_size_na_7x9_envelope,
+ xpoid_val_medium_size_na_9x11_envelope,
+ xpoid_val_medium_size_na_10x14_envelope,
+ xpoid_val_medium_size_na_number_9_envelope,
+ xpoid_val_medium_size_na_6x9_envelope,
+ xpoid_val_medium_size_na_10x15_envelope,
+ xpoid_val_medium_size_monarch_envelope,
+ xpoid_val_medium_size_a,
+ xpoid_val_medium_size_b,
+ xpoid_val_medium_size_c,
+ xpoid_val_medium_size_d,
+ xpoid_val_medium_size_e,
+ xpoid_val_medium_size_jis_b0,
+ xpoid_val_medium_size_jis_b1,
+ xpoid_val_medium_size_jis_b2,
+ xpoid_val_medium_size_jis_b3,
+ xpoid_val_medium_size_jis_b4,
+ xpoid_val_medium_size_jis_b5,
+ xpoid_val_medium_size_jis_b6,
+ xpoid_val_medium_size_jis_b7,
+ xpoid_val_medium_size_jis_b8,
+ xpoid_val_medium_size_jis_b9,
+ xpoid_val_medium_size_jis_b10,
+ xpoid_val_medium_size_hp_2x_postcard,
+ xpoid_val_medium_size_hp_european_edp,
+ xpoid_val_medium_size_hp_mini,
+ xpoid_val_medium_size_hp_postcard,
+ xpoid_val_medium_size_hp_tabloid,
+ xpoid_val_medium_size_hp_us_edp,
+ xpoid_val_medium_size_hp_us_government_legal,
+ xpoid_val_medium_size_hp_us_government_letter,
+ xpoid_val_plex_simplex,
+ xpoid_val_plex_duplex,
+ xpoid_val_plex_tumble,
+ xpoid_val_input_tray_top,
+ xpoid_val_input_tray_middle,
+ xpoid_val_input_tray_bottom,
+ xpoid_val_input_tray_envelope,
+ xpoid_val_input_tray_manual,
+ xpoid_val_input_tray_large_capacity,
+ xpoid_val_input_tray_main,
+ xpoid_val_input_tray_side,
+ xpoid_val_event_report_job_completed,
+ xpoid_val_delivery_method_electronic_mail,
+ xpoid_val_xp_setup_mandatory,
+ xpoid_val_xp_setup_optional,
+ xpoid_val_xp_setup_ok,
+ xpoid_val_xp_setup_incomplete,
+ xpoid_val_xp_list_glyph_fonts,
+ xpoid_val_xp_list_internal_printer_fonts,
+ xpoid_val_available_compressions_0,
+ xpoid_val_available_compressions_01,
+ xpoid_val_available_compressions_02,
+ xpoid_val_available_compressions_03,
+ xpoid_val_available_compressions_012,
+ xpoid_val_available_compressions_013,
+ xpoid_val_available_compressions_023,
+ xpoid_val_available_compressions_0123
+} XpOid;
diff --git a/nx-X11/programs/Xserver/Xprint/OidStrs.h b/nx-X11/programs/Xserver/Xprint/OidStrs.h
new file mode 100644
index 000000000..1792a6e16
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/OidStrs.h
@@ -0,0 +1,173 @@
+/* $Xorg: OidStrs.h,v 1.4 2001/03/14 18:45:40 pookie Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* This is an automatically-generated file. Do not edit. */
+
+static int XpOidStringMapCount = 127;
+
+static const XpOidStringMapEntry XpOidStringMap[] = {
+ { "", 0 },
+ { "", 0 },
+ { "descriptor", 10 },
+ { "content-orientation", 19 },
+ { "copy-count", 10 },
+ { "default-printer-resolution", 26 },
+ { "default-input-tray", 18 },
+ { "default-medium", 14 },
+ { "document-format", 15 },
+ { "plex", 4 },
+ { "xp-listfonts-modes", 18 },
+ { "job-name", 8 },
+ { "job-owner", 9 },
+ { "notification-profile", 20 },
+ { "xp-setup-state", 14 },
+ { "xp-spooler-command-options", 26 },
+ { "content-orientations-supported", 30 },
+ { "document-formats-supported", 26 },
+ { "dt-pdm-command", 14 },
+ { "input-trays-medium", 18 },
+ { "medium-source-sizes-supported", 29 },
+ { "plexes-supported", 16 },
+ { "printer-model", 13 },
+ { "printer-name", 12 },
+ { "printer-resolutions-supported", 29 },
+ { "xp-embedded-formats-supported", 29 },
+ { "xp-listfonts-modes-supported", 28 },
+ { "xp-page-attributes-supported", 28 },
+ { "xp-raw-formats-supported", 24 },
+ { "xp-setup-proviso", 16 },
+ { "document-attributes-supported", 29 },
+ { "job-attributes-supported", 24 },
+ { "locale", 6 },
+ { "multiple-documents-supported", 28 },
+ { "available-compression", 21 },
+ { "available-compressions-supported", 32 },
+ { "portrait", 8 },
+ { "landscape", 9 },
+ { "reverse-portrait", 16 },
+ { "reverse-landscape", 17 },
+ { "iso-a0", 6 },
+ { "iso-a1", 6 },
+ { "iso-a2", 6 },
+ { "iso-a3", 6 },
+ { "iso-a4", 6 },
+ { "iso-a5", 6 },
+ { "iso-a6", 6 },
+ { "iso-a7", 6 },
+ { "iso-a8", 6 },
+ { "iso-a9", 6 },
+ { "iso-a10", 7 },
+ { "iso-b0", 6 },
+ { "iso-b1", 6 },
+ { "iso-b2", 6 },
+ { "iso-b3", 6 },
+ { "iso-b4", 6 },
+ { "iso-b5", 6 },
+ { "iso-b6", 6 },
+ { "iso-b7", 6 },
+ { "iso-b8", 6 },
+ { "iso-b9", 6 },
+ { "iso-b10", 7 },
+ { "na-letter", 9 },
+ { "na-legal", 8 },
+ { "executive", 9 },
+ { "folio", 5 },
+ { "invoice", 7 },
+ { "ledger", 6 },
+ { "quarto", 6 },
+ { "iso-c3", 6 },
+ { "iso-c4", 6 },
+ { "iso-c5", 6 },
+ { "iso-c6", 6 },
+ { "iso-designated-long", 19 },
+ { "na-10x13-envelope", 17 },
+ { "na-9x12-envelope", 16 },
+ { "na-number-10-envelope", 21 },
+ { "na-7x9-envelope", 15 },
+ { "na-9x11-envelope", 16 },
+ { "na-10x14-envelope", 17 },
+ { "na-number-9-envelope", 20 },
+ { "na-6x9-envelope", 15 },
+ { "na-10x15-envelope", 17 },
+ { "monarch-envelope", 16 },
+ { "a", 1 },
+ { "b", 1 },
+ { "c", 1 },
+ { "d", 1 },
+ { "e", 1 },
+ { "jis-b0", 6 },
+ { "jis-b1", 6 },
+ { "jis-b2", 6 },
+ { "jis-b3", 6 },
+ { "jis-b4", 6 },
+ { "jis-b5", 6 },
+ { "jis-b6", 6 },
+ { "jis-b7", 6 },
+ { "jis-b8", 6 },
+ { "jis-b9", 6 },
+ { "jis-b10", 7 },
+ { "hp-2x-postcard", 14 },
+ { "hp-european-edp", 15 },
+ { "hp-mini", 7 },
+ { "hp-postcard", 11 },
+ { "hp-tabloid", 10 },
+ { "hp-us-edp", 9 },
+ { "hp-us-government-legal", 22 },
+ { "hp-us-government-letter", 23 },
+ { "simplex", 7 },
+ { "duplex", 6 },
+ { "tumble", 6 },
+ { "top", 3 },
+ { "middle", 6 },
+ { "bottom", 6 },
+ { "envelope", 8 },
+ { "manual", 6 },
+ { "large-capacity", 14 },
+ { "main", 4 },
+ { "side", 4 },
+ { "event-report-job-completed", 26 },
+ { "electronic-mail", 15 },
+ { "xp-setup-mandatory", 18 },
+ { "xp-setup-optional", 17 },
+ { "xp-setup-ok", 11 },
+ { "xp-setup-incomplete", 19 },
+ { "xp-list-glyph-fonts", 19 },
+ { "xp-list-internal-printer-fonts", 30 },
+ { "0", 1 },
+ { "01", 2 },
+ { "02", 2 },
+ { "03", 2 },
+ { "012", 3 },
+ { "013", 3 },
+ { "023", 3 },
+ { "0123", 4 }
+};
diff --git a/nx-X11/programs/Xserver/Xprint/Util.c b/nx-X11/programs/Xserver/Xprint/Util.c
new file mode 100644
index 000000000..069595b9a
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/Util.c
@@ -0,0 +1,372 @@
+/* $Xorg: Util.c,v 1.3 2000/08/17 19:48:06 cpqbld Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/Util.c,v 1.12 2001/08/01 00:44:45 tsi Exp $ */
+
+/* To get the tempnam() prototype in <stdio.h> */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#if defined(linux) && defined(__STRICT_ANSI__)
+#undef __STRICT_ANSI__
+#endif
+
+#include <X11/Xos.h> /* for unistd.h and string.h */
+#include <stdio.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include "misc.h"
+#include "dixstruct.h"
+
+#include <X11/extensions/Print.h>
+
+#include "attributes.h"
+
+#define IN_FILE_STRING "%(InFile)%"
+#define OUT_FILE_STRING "%(OutFile)%"
+
+/*
+ * ReplaceAnyString returns a string combining the input strings.
+ * It replaces all occurances of 'target' with the supplied
+ * 'replacement'.
+ * The original input string will generally be freed,
+ * and the caller is responsible for freeing whatever string is returned.
+ */
+char *
+ReplaceAnyString(
+ char *string,
+ char *target,
+ char *replacement)
+{
+ char *pKeyString;
+
+ if(replacement != (char *)NULL)
+ {
+ while((pKeyString = strstr(string, target)) != (char *)NULL)
+ {
+ char *newString;
+
+ newString = (char *)xalloc(strlen(string) + strlen(replacement) -
+ strlen(target) + 1);
+ strncpy(newString, string, pKeyString - string);
+ newString[pKeyString - string] = '\0';
+ strcat(newString, replacement);
+ strcat(newString, pKeyString + strlen(target));
+ xfree(string);
+ string = newString;
+ }
+ }
+
+ return string;
+}
+
+/*
+ * ReplaceFileString returns a string combining the input strings.
+ * It replaces all occurances of IN_FILE_STRING with the supplied
+ * inFileName, and all occurances of OUT_FILE_STRING with the
+ * supplied outFileName. The original input string will generally be freed,
+ * and the caller is responsible for freeing whatever string is returned.
+ */
+char *
+ReplaceFileString(
+ char *string,
+ char *inFileName,
+ char *outFileName)
+{
+ char *pKeyString,
+ *pInFileString = IN_FILE_STRING,
+ *pOutFileString = OUT_FILE_STRING;
+
+ if(inFileName != (char *)NULL)
+ {
+ while((pKeyString = strstr(string, pInFileString)) !=
+ (char *)NULL)
+ {
+ char *newString;
+
+ newString = (char *)xalloc(strlen(string) +
+ strlen(inFileName) + 1);
+ strncpy(newString, string, pKeyString - string);
+ newString[pKeyString - string] = '\0';
+ strcat(newString, inFileName);
+ strcat(newString, pKeyString + strlen(pInFileString));
+ xfree(string);
+ string = newString;
+ }
+ }
+
+ if(outFileName != (char *)NULL)
+ {
+ while((pKeyString = strstr(string, pOutFileString)) !=
+ (char *)NULL)
+ {
+ char *newString;
+
+ newString = (char *)xalloc(strlen(string) +
+ strlen(outFileName) + 1);
+ strncpy(newString, string, pKeyString - string);
+ newString[pKeyString - string] = '\0';
+ strcat(newString, outFileName);
+ strcat(newString, pKeyString + strlen(pOutFileString));
+ xfree(string);
+ string = newString;
+ }
+ }
+ return string;
+}
+
+
+/*
+ * TransferBytes reads numBytes of data from pSrcFile and writes them
+ * to pDstFile. It returns the number of bytes actually transfered,
+ * which will be numBytes if it's successful. Neither pSrcFile nor
+ * pDstFile are rewound or their pointers otherwise modified prior to
+ * beginning the transfer.
+ */
+int
+TransferBytes(
+ FILE *pSrcFile,
+ FILE *pDstFile,
+ int numBytes)
+{
+ char buf[10240];
+#define BUF_SIZE (sizeof(buf)*sizeof(char))
+ int bytesWritten = 0;
+ unsigned bytesToXfer;
+
+ for(bytesToXfer = min(BUF_SIZE, (unsigned)numBytes);
+ bytesToXfer > 0;
+ bytesToXfer = min(BUF_SIZE, (unsigned)(numBytes - bytesWritten)))
+ {
+ if(fread((void *)buf, (size_t) 1, bytesToXfer, pSrcFile) < bytesToXfer)
+ return bytesWritten;
+ if(fwrite((void *)buf, (size_t) 1, bytesToXfer, pDstFile) < bytesToXfer)
+ return bytesWritten;
+ bytesWritten += bytesToXfer;
+ }
+ return bytesWritten;
+}
+
+/*
+ * CopyContentsAndDelete - does the work of copying and deleting the
+ * pre, no, and post raster files as well as the raster file itself.
+ */
+Bool
+CopyContentsAndDelete(
+ FILE **ppSrcFile,
+ char **pSrcFileName,
+ FILE *pDstFile)
+{
+ struct stat statBuf;
+
+ if(stat(*pSrcFileName, &statBuf) < 0)
+ return FALSE;
+ rewind(*ppSrcFile);
+ if(TransferBytes(*ppSrcFile, pDstFile,
+ (int)statBuf.st_size) != (int)statBuf.st_size)
+ return FALSE;
+ fclose(*ppSrcFile);
+ *ppSrcFile = (FILE *)NULL;
+ unlink(*pSrcFileName);
+ xfree(*pSrcFileName);
+ *pSrcFileName = (char *)NULL;
+
+ return TRUE;
+}
+
+
+#define QUADPAD(x) ((((x)+3)>>2)<<2)
+
+int
+XpSendDocumentData(
+ ClientPtr client,
+ FILE *fp,
+ int fileLen,
+ int maxBufSize)
+{
+ xPrintGetDocumentDataReply *pRep;
+ int bytesWritten;
+ unsigned bytesToWrite;
+ int result = Success;
+
+ if(client->clientGone)
+ return Success;
+
+ pRep = (xPrintGetDocumentDataReply *)xalloc(sz_xPrintGetDocumentDataReply+
+ QUADPAD(maxBufSize));
+
+ for(bytesToWrite = min(maxBufSize, fileLen),
+ bytesWritten = 0;
+ bytesToWrite > 0;
+ bytesToWrite = min(maxBufSize, fileLen - bytesWritten))
+ {
+ pRep->type = X_Reply;
+ pRep->sequenceNumber = client->sequence;
+ pRep->length = (QUADPAD(bytesToWrite)) >> 2;
+ pRep->dataLen = bytesToWrite;
+
+ if(fread((void *)(pRep + 1), 1, bytesToWrite, fp) < bytesToWrite)
+ {
+ result = BadAlloc; /* XXX poor error choice? */
+ pRep->statusCode = 2; /* XXX Is this the right value??? */
+ }
+ else
+ pRep->statusCode = 0; /* XXX Ignored??? */
+
+ pRep->finishedFlag = FALSE;
+
+ if (client->swapped) {
+ int n;
+ long l;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, l);
+ swapl(&pRep->statusCode, l); /* XXX Why are these longs??? */
+ swapl(&pRep->finishedFlag, l); /* XXX Why are these longs??? */
+ swapl(&pRep->dataLen, l);
+ }
+
+ (void)WriteToClient(client,
+ sz_xPrintGetDocumentDataReply + bytesToWrite,
+ (char *)pRep);
+ bytesWritten += bytesToWrite;
+ }
+
+ xfree(pRep);
+ return result;
+}
+
+/*
+ * XpFinishDocData - send a DocumentData reply with the "finishedFlag"
+ * field set to TRUE. This routine should be called from the EndJob
+ * function of a driver after the driver has sent all required
+ * document data (presumably via XpSendDocumentData).
+ */
+int
+XpFinishDocData(
+ ClientPtr client)
+{
+ xPrintGetDocumentDataReply rep;
+
+ if(client->clientGone)
+ return Success;
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.dataLen = 0;
+ rep.finishedFlag = TRUE;
+ rep.statusCode = 0;
+
+ if (client->swapped) {
+ int n;
+ long l;
+
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, l);
+ swapl(&rep.statusCode, l); /* XXX Why are these longs??? */
+ swapl(&rep.finishedFlag, l); /* XXX Why are these longs??? */
+ swapl(&rep.dataLen, l);
+ }
+
+ (void)WriteToClient(client, sz_xPrintGetDocumentDataReply, (char *)&rep);
+ return Success;
+}
+
+#ifndef HAS_MKSTEMP
+static
+char *XpDirName(char *fname)
+{
+ char *fn, *ptr;
+
+ fn = (char *)xalloc(strlen(fname) + 1);
+ if (fn) {
+ strcpy(fn, fname);
+ ptr = strrchr(fn, '/');
+ if (!ptr) {
+ ptr = fn;
+ *ptr++ = '.';
+ } else if (ptr == fn)
+ ptr++;
+ *ptr = '\0';
+ }
+ return fn;
+}
+#endif
+
+Bool
+XpOpenTmpFile(
+ char *mode,
+ char **fname,
+ FILE **stream)
+{
+#ifndef HAS_MKSTEMP
+ char *fn = NULL;
+
+ /* note that there is a small race condition here... */
+ if (!(*fname = tempnam(NULL, NULL)) ||
+ !(fn = XpDirName(*fname)) ||
+ access(fn, W_OK) ||
+ !(*stream = fopen(*fname, mode)))
+
+ {
+ xfree(fn);
+ xfree(*fname);
+ *fname = NULL;
+ *stream = NULL;
+ return FALSE;
+ }
+ xfree(fn);
+#else
+ int fd;
+
+ *stream = NULL;
+ *fname = (char *)xalloc(14);
+ if (*fname == NULL)
+ return FALSE;
+ strcpy(*fname, "/tmp/xpXXXXXX");
+ fd = mkstemp(*fname);
+ if (fd < 0) {
+ xfree(*fname);
+ *fname = NULL;
+ return FALSE;
+ }
+ *stream = fdopen(fd, mode);
+ if (stream == NULL) {
+ xfree(*fname);
+ *fname = NULL;
+ return FALSE;
+ }
+#endif
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/ValTree.c b/nx-X11/programs/Xserver/Xprint/ValTree.c
new file mode 100644
index 000000000..6fa631617
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ValTree.c
@@ -0,0 +1,193 @@
+/* $Xorg: ValTree.c,v 1.3 2000/08/17 19:48:06 cpqbld Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86$ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "regionstr.h"
+#include "mivalidate.h"
+
+/*
+ * XpValidateTree - a validateTree routine which ignores overlapping
+ * top-level windows when computing the clip lists for such windows.
+ * This can be used by any driver which maintains a separate memory
+ * store for each top-level window (with its respective children).
+ * If the pParent is not the root window, then miValidateTree
+ * is used unmodified.
+ *
+ * The strategy if pParent is the root is to save off the
+ * current values of pParent->firstChild and pParent->lastChild,
+ * replacing both with the single child of interest. We save off
+ * pChild->prevSib and pChild->nextSib, and replace them with NullWindow.
+ * We save off pParent->clipList, and replace it with
+ * pParent->winSize - pChild->winSize. We then call miValidateTree
+ * to do the needed ComputeClips on the pChild's heirarchy.
+ * pParent's clipList is then recomputed based on the sizes
+ * of its children, and the saved pointers are restored.
+ * The trees associated with the siblings of pChild must be descended
+ * and cleaned of any marks (i.e. the valdata pointer freed, and set to NULL),
+ * and pParent' AfterValidate structure's exposed field must be updated.
+ */
+/*ARGSUSED*/
+int
+XpValidateTree (pParent, pChild, kind)
+ WindowPtr pParent; /* Parent to validate */
+ WindowPtr pChild; /* First child of pParent that was
+ * affected */
+ VTKind kind; /* What kind of configuration caused call */
+{
+ RegionRec origPrntClip; /* orig clipList for parent */
+ RegionRec childClip; /* The new borderClip for the current
+ * child */
+ RegionRec tmpPrntClip; /* parent clipList - child borderClip */
+ RegionRec exposed; /* For intermediate calculations */
+ register ScreenPtr pScreen;
+ register WindowPtr pWin;
+ Bool overlap;
+ int viewvals;
+ Bool forward;
+
+ WindowPtr origFirstChild, origLastChild, origPrevSib, origNextSib;
+
+ /*
+ * If we're validating something other than a top-level window,
+ * then just invoke miValidateTree.
+ */
+ if(pParent->parent != NullWindow)
+ return miValidateTree(pParent, pChild, kind);
+
+ /*
+ * If it's a stack change of top levels then it's a no-op for
+ * this scheme, so we just clean up any marks on windows and return.
+ */
+ if(kind == VTStack)
+ {
+ CleanMarks(pParent);
+ return 1;
+ }
+
+ pScreen = pParent->drawable.pScreen;
+ if (pChild == NullWindow)
+ pChild = pParent->firstChild;
+
+ /* Save off the existing window heirarchy */
+ origFirstChild = pParent->firstChild;
+ origLastChild = pParent->lastChild;
+ origPrevSib = pChild->prevSib;
+ origNextSib = pChild->nextSib;
+ pParent->firstChild = pChild;
+ pParent->lastChild = pChild;
+ pChild->prevSib = NullWindow;
+ pChild->nextSib = NullWindow;
+
+ /*
+ * Set pParent's clipList to be its winSize minus the pChild's
+ * borderSize.
+ */
+ origPrntClip = pParent->clipList;
+ REGION_NULL(pScreen, &tmpPrntClip);
+ REGION_SUBRACT(pScreen, &tmpPrntClip, &pParent->winSize,
+ &pChild->borderSize);
+ pParent->clipList = tmpPrntClip;
+
+ /*
+ * Call miValidateTree on the pruned tree.
+ */
+ (void) miValidateTree(pParent, pChild, kind);
+
+ /* Restore the saved heirarchy */
+ pChild->prevSib = origPrevSib;
+ pChild->nextSib = origNextSib;
+ pParent->firstChild = origFirstChild;
+ pParent->lastChild = origLastChild;
+
+ /*
+ * Compute pParent's clipList by taking its winSize and subracting
+ * the borderSize of each of its children.
+ */
+ for(pWin = pParent->firstChild,
+ REGION_COPY(pScreen, &pParent->clipList, &pParent->winSize);
+ pWin != NullWindow;
+ pWin = pWin->nextSib)
+ {
+ REGION_SUBTRACT(pScreen, &pParent->clipList, &pParent->clipList,
+ &pWin->borderSize);
+ }
+
+ /*
+ * Compute pParent's AfterValidate structure by subracting the original
+ * clipList from the newly computed clipList.
+ */
+ REGION_NULL(pScreen, &pParent->valdata->after.exposed);
+ REGION_SUBTRACT(pScreen, &pParent->valdata->after.exposed,
+ &pParent->clipList, &origPrntClip);
+
+ /*
+ * Remove the marks from all but pParent and pChild's heirarchy.
+ * i.e. from all of pChild's siblings and their children.
+ */
+ for(pWin = pParent->firstChild; pWin != NullWindow; pWin = pWin->nextSib)
+ {
+ WindowPtr pCurChild = pWin;
+
+ if(pCurChild == pChild)
+ continue;
+
+ while (1)
+ {
+ if(pCurChild->valdata)
+ {
+ xfree(pCurChild->valdata);
+ pCurChild->valdata = (ValidatePtr)NULL;
+ }
+
+ if (pCurChild->firstChild)
+ {
+ pCurChild = pCurChild->firstChild;
+ continue;
+ }
+ while (!pCurChild->nextSib && (pCurChild != pWin))
+ pCurChild = pCurChild->parent;
+ if (pCurChild == pWin)
+ break;
+ pCurChild = pCurChild->nextSib;
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xprint/Xprt.html b/nx-X11/programs/Xserver/Xprint/Xprt.html
new file mode 100644
index 000000000..f84a3c134
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/Xprt.html
@@ -0,0 +1,115 @@
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Xprt</title><meta name="generator" content="DocBook XSL Stylesheets V1.62.4"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en"><a name="Xprt"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2>Name</h2><p>Xprt &#8212; Print server for X Version 11</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><tt class="command">Xprt</tt> [<tt class="option">-ac</tt>] [<tt class="option">-audit <i class="replaceable"><tt>level</tt></i></tt>] [<tt class="option">-pn</tt>] [<tt class="option">-fp <i class="replaceable"><tt>fontpath</tt></i></tt>] [<tt class="option">-XpFile <i class="replaceable"><tt>file</tt></i></tt>] [<tt class="option">-XpSpoolerType <i class="replaceable"><tt>spoolername</tt></i></tt>] [<tt class="option">:<i class="replaceable"><tt>display</tt></i></tt>]</p></div></div><div class="refsect1" lang="en"><a name="id2804962"></a><h2>DESCRIPTION</h2><p><span><b class="command">Xprt</b></span> is the Xprint print server
+ for version 11 of the X Window system for non display devices
+ such as printers and fax machines.</p><p>Xprint is an advanced printing system which enables X11
+ applications to use devices like printers, FAX or create
+ documents in formats like PostScript, PCL or PDF. It may be used by
+ clients such as <span class="application">mozilla</span>.
+ </p><p>Xprint is a very flexible, extensible, scaleable, client/server
+ print system based on ISO 10175 (and some other specs) and the X11
+ rendering protocol.
+ Using Xprint an application can search, query and use devices like
+ printers, FAX machines or create documents in formats like PDF.
+ In particular, an application can seek a printer, query supported
+ attributes (like paper size, trays, fonts etc.), configure the printer
+ device to match it's needs and print on it like on any other X device
+ reusing parts of the code which is used for the video card Xserver.
+ </p></div><div xmlns:ns1="" class="refsect1" lang="en"><a name="id2805117"></a><h2>USAGE</h2><p>
+ Although Xprt may be invoked from the command line, it is
+ preferable to run it as a daemon via the init script
+ <tt class="filename">/etc/init.d/xprint</tt> (where this script exists).
+ </p><p>Client programs such as mozilla will require environment
+ variable <tt class="envar">${XPSERVERLIST}</tt> to be set, identifying the
+ &quot;display&quot; on which Xprt is running. This variable may be set
+ for all users via <tt class="filename">/etc/profile</tt> (or similar), using
+ <b class="userinput"><tt>/etc/init.d/xprint get_xpserverlist</tt></b>:
+ </p><div class="informalexample"><pre class="programlisting">export XPSERVERLIST=`/etc/init.d/xprint get_xpserverlist`</pre></div></div><div class="refsect1" lang="en"><a name="id2805150"></a><h2>OPTIONS</h2><p>Many of Xprt's command line options are shared in common
+ with the usual X servers (see <span class="citerefentry"><span class="refentrytitle">Xserver</span>(1x)</span>).
+ Commonly used options include:</p><div class="variablelist"><dl><dt><span class="term"><tt class="option">:<i class="replaceable"><tt>display</tt></i></tt></span></dt><dd><p> The X server runs on the given display. If multiple X
+ servers are to run simultaneously on a host, each must
+ have a unique display number. Note that the standard X
+ server (for video displays) typically runs on display
+ :0. If <tt class="filename">/etc/init.d/xprint</tt> is used
+ to invoke Xprt, it may be configured to automatically assign an available
+ display number.</p></dd><dt><span class="term"><tt class="option">-ac</tt></span></dt><dd><p>disables host-based access control mechanisms. Enables access
+ by any host, and permits any host to modify the access control
+ list. Use with extreme caution. This option exists primarily
+ for running test suites remotely.</p></dd><dt><span class="term"><tt class="option">-audit <i class="replaceable"><tt>level</tt></i></tt></span></dt><dd><p>sets the audit trail level. The default level is 1, meaning
+ only connection rejections are reported. Level 2 additionally
+ reports all successful connections and disconnects. Level 4
+ enables messages from the SECURITY extension, if present,
+ including generation and revocation of authorizations and
+ violations of the security policy. Level 0 turns off the audit
+ trail. Audit lines are sent as standard error output.</p></dd><dt><span class="term"><tt class="option">-fp <i class="replaceable"><tt>fontpath</tt></i></tt></span></dt><dd><p>sets the search path for fonts. This path is a comma
+ separated list of directories which Xprt searches for
+ font databases.</p></dd><dt><span class="term"><tt class="option">-pn</tt></span></dt><dd><p>permits the server to continue running if it fails to
+ establish all of its well-known sockets (connection
+ points for clients), but establishes at least
+ one.</p></dd><dt><span class="term"><tt class="option">-XpFile <i class="replaceable"><tt>file</tt></i></tt></span></dt><dd><p>Sets an altername Xprinters file (see section FILES).</p></dd><dt><span class="term"><tt class="option">-XpSpoolerType <i class="replaceable"><tt>spoolername</tt></i></tt></span></dt><dd xmlns:ns2=""><p>
+ Defines the spooler system to be used for print job spooling.
+ Supported values in xprint.mozdev.org release 009 are:
+ </p><table class="simplelist" border="0" summary="Simple list"><tr><td>aix</td></tr><tr><td>aix4</td></tr><tr><td>bsd</td></tr><tr><td>osf</td></tr><tr><td>solaris</td></tr><tr><td>sysv</td></tr><tr><td>uxp</td></tr><tr><td>cups</td></tr><tr><td>lprng</td></tr><tr><td>other</td></tr><tr><td>none</td></tr></table><p>
+ (multiple values can be specified, seperated by ':', the first active spooler will be chosen).
+ The default value is platform-specific and can be obtained via
+ </p><pre class="programlisting">Xprt -h</pre><p>.
+ </p></dd></dl></div></div><div xmlns:ns3="" class="refsect1" lang="en"><a name="id2805336"></a><h2>ENVIRONMENT</h2><p>
+ The following environment variables are recognized by the X print server
+ (environment variables recognized by Xprint clients are described in
+ <span class="citerefentry"><span class="refentrytitle">Xprint</span>(7)</span>):
+
+ </p><div class="variablelist"><dl><dt><span class="term"><tt class="envar">${XPCONFIGDIR}</tt></span></dt><dd><p> This environment variable points to the root
+ of the Xprint server configuration directory hierarchy.
+ If the variable is not defined, the default
+ path is be assumed. The default path may be
+ <tt class="filename">/usr/X11R6/lib/X11/xserver/</tt>,
+ <tt class="filename">/usr/lib/X11/xserver/</tt>,
+ <tt class="filename">/usr/share/Xprint/xserver/</tt> or
+ <tt class="filename">/usr/openwin/server/etc/XpConfig</tt>, depending on the
+ system, and may be configured in <tt class="filename">/etc/init.d/xprint</tt>.</p></dd><dt><span class="term"><tt class="envar">${LANG}</tt></span></dt><dd><p>
+ This environment variable selects the locale settings used by the Xprint server.
+ Xprt allows language-specific settings (stored in <tt class="filename">${XPCONFIGDIR}/${LANG}/print/</tt>)
+ which will override the default settings (stored in <tt class="filename">${XPCONFIGDIR}/C/print/</tt>).
+ If <tt class="envar">${LANG}</tt> is not set &quot;C&quot; is assumed.
+ </p></dd></dl></div></div><div class="refsect1" lang="en"><a name="id2805421"></a><h2>FILES</h2><div class="variablelist"><dl><dt><span class="term"><tt class="filename">${XPCONFIGDIR}/${LANG}/print/Xprinters</tt>, </span><span class="term"><tt class="filename">${XPCONFIGDIR}/C/print/Xprinters</tt></span></dt><dd><p>
+ `Xprinters' is the top most configuration file. It tells
+ Xprt which specific printer names (e.g. mylaser) should
+ be supported, and whether <span class="citerefentry"><span class="refentrytitle">lpstat</span>(1)</span> or other commands
+ should be used to automatically supplement the list of
+ printers.
+ </p></dd><dt><span class="term"><tt class="filename">${XPCONFIGDIR}/${LANG}/print/attributes/printer</tt>, </span><span class="term"><tt class="filename">${XPCONFIGDIR}/C/print/attributes/printer</tt></span></dt><dd><p>
+ The `printer' file maps printer names to model
+ configurations (see `model-config' below). For example,
+ &quot;mylaser&quot; could be mapped to a &quot;HPDJ1600C&quot;, and all other
+ arbitrary printers could be mapped to a default, such as
+ &quot;HPLJ4SI&quot;. When depending on <span class="citerefentry"><span class="refentrytitle">lpstat</span>(1)</span> in the Xprinters
+ file, setting up defaults in `printer' becomes all the
+ more important.
+ </p></dd><dt><span class="term"><tt class="filename">${XPCONFIGDIR}/${LANG}/print/attributes/document</tt>, </span><span class="term"><tt class="filename">${XPCONFIGDIR}/C/print/attributes/document</tt></span></dt><dd><p>
+ The `document' file specifies the initial document values
+ for any print jobs. For example, which paper tray to
+ use, what default resolution, etc.
+ </p></dd><dt><span class="term"><tt class="filename">${XPCONFIGDIR}/${LANG}/print/attributes/job</tt>, </span><span class="term"><tt class="filename">${XPCONFIGDIR}/C/print/attributes/job</tt></span></dt><dd><p>
+ The `job' file specifies the initial job values for any
+ print jobs. For example, &quot;notification-profile&quot; can be
+ set so that when a print job is successfully sent to a
+ printer, e-mail is sent to the user.
+ </p></dd><dt><span class="term"><tt class="filename">${XPCONFIGDIR}/C/print/models/PSdefault/model-config</tt>, </span><span class="term"><tt class="filename">${XPCONFIGDIR}/C/print/models/PSdefault/fonts/fonts.dir</tt>, </span><span class="term"><tt class="filename">${XPCONFIGDIR}/C/print/models/PSdefault/fonts/9nb00051.pmf</tt>, </span><span class="term"><tt class="filename">${XPCONFIGDIR}/C/print/models/PSdefault/fonts/9nb00093.pmf</tt></span></dt><dd><p>
+ The `model-config' file has attributes that describe the
+ printer model's capabilities and default settings.
+ Printer model fonts may also be present. The model-config
+ file also identifies the print ddx driver to be used.
+
+ For each printer model supported, a complete hierarchy of
+ files should exist. In most cases, these files do not
+ need to be modified.
+ </p></dd><dt><span class="term"><tt class="filename">${XPCONFIGDIR}/C/print/ddx-config/raster/pdf</tt>, </span><span class="term"><tt class="filename">${XPCONFIGDIR}/C/print/ddx-config/raster/pcl</tt>, </span><span class="term"><tt class="filename">${XPCONFIGDIR}/C/print/ddx-config/raster/postscript</tt></span></dt><dd><p>
+ The print ddx drivers can have highly specific
+ configuration files to control their behavior. In most
+ cases, these files do not need to be modified.
+ </p></dd></dl></div></div><div class="refsect1" lang="en"><a name="id2805584"></a><h2>SEE ALSO</h2><p><span class="simplelist"><span class="citerefentry"><span class="refentrytitle">Xprint</span>(7)</span>, <span class="citerefentry"><span class="refentrytitle">X11</span>(7)</span>, <span class="citerefentry"><span class="refentrytitle">xplsprinters</span>(1x)</span>, <span class="citerefentry"><span class="refentrytitle">xprehashprinterlist</span>(1x)</span>, <span class="citerefentry"><span class="refentrytitle">xphelloworld</span>(1x)</span>, <span class="citerefentry"><span class="refentrytitle">xpxmhelloworld</span>(1x)</span>, <span class="citerefentry"><span class="refentrytitle">xpawhelloworld</span>(1x)</span>, <span class="citerefentry"><span class="refentrytitle">xpxthelloworld</span>(1x)</span>, <span class="citerefentry"><span class="refentrytitle">xpsimplehelloworld</span>(1x)</span>, <span class="citerefentry"><span class="refentrytitle">Xserver</span>(1x)</span>, <span class="citerefentry"><span class="refentrytitle">libXp</span>(3x)</span>, <span class="citerefentry"><span class="refentrytitle">libXprintUtils</span>(3x)</span>, <span class="citerefentry"><span class="refentrytitle">libXprintAppUtils</span>(3x)</span>, <span class="citerefentry"><span class="refentrytitle">XmPrintShell</span>(3x)</span>, <span class="citerefentry"><span class="refentrytitle">XawPrintShell</span>(3x)</span>, Xprint FAQ (<a href="http://xprint.mozdev.org/docs/Xprint_FAQ.html" target="_top">http://xprint.mozdev.org/docs/Xprint_FAQ.html</a>), Xprint main site (<a href="http://xprint.mozdev.org/" target="_top">http://xprint.mozdev.org/</a>)</span></p></div><div class="refsect1" lang="en"><a name="id2805757"></a><h2>AUTHORS</h2><p>
+ This manual page was written by
+ Drew Parsons <tt class="email">&lt;<a href="mailto:dparsons@debian.org">dparsons@debian.org</a>&gt;</tt> and
+ Roland Mainz <tt class="email">&lt;<a href="mailto:roland.mainz@nrubsig.org">roland.mainz@nrubsig.org</a>&gt;</tt>,
+ with some help from the man page at
+ <a href="http://www.sins.com.au/unix/manpages/Xprt.html" target="_top">http://www.sins.com.au/unix/manpages/Xprt.html</a> and the XFree86
+ man page for <span class="citerefentry"><span class="refentrytitle">Xserver</span>(1)</span>.
+ </p></div></div></body></html>
diff --git a/nx-X11/programs/Xserver/Xprint/Xprt.man b/nx-X11/programs/Xserver/Xprint/Xprt.man
new file mode 100644
index 000000000..7599a1344
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/Xprt.man
@@ -0,0 +1,196 @@
+.\" -*- coding: us-ascii -*-
+.TH Xprt __appmansuffix__ "25 November 2004"
+.SH NAME
+Xprt \- Print server for X Version 11
+.SH SYNOPSIS
+.ad l
+\fBXprt\fR \kx
+.if (\nxu > (\n(.lu / 2)) .nr x (\n(.lu / 5)
+'in \n(.iu+\nxu
+[\fB\-ac\fR] [\fB\-audit \fBlevel\fR\fR] [\fB\-pn\fR] [\fB\-fp \fBfontpath\fR\fR] [\fB\-XpFile \fBfile\fR\fR] [\fB\-XpSpoolerType \fBspoolername\fR\fR] [\fB:\fBdisplay\fR\fR]
+'in \n(.iu-\nxu
+.ad b
+.SH DESCRIPTION
+Xprt is the Xprint print server
+for version 11 of the X Window system for non display devices
+such as printers and fax machines.
+.PP
+Xprint is an advanced printing system which enables X11
+applications to use devices like printers, FAX or create
+documents in formats like PostScript, PCL or PDF. It may be used by
+clients such as mozilla.
+.PP
+Xprint is a very flexible, extensible, scaleable, client/server
+print system based on ISO 10175 (and some other specs) and the X11
+rendering protocol.
+Using Xprint an application can search, query and use devices like
+printers, FAX machines or create documents in formats like PDF.
+In particular, an application can seek a printer, query supported
+attributes (like paper size, trays, fonts etc.), configure the printer
+device to match it's needs and print on it like on any other X device
+reusing parts of the code which is used for the video card Xserver.
+.SH USAGE
+Although Xprt may be invoked from the command line, it is
+preferable to run it as a daemon via the init script
+\fB/etc/init.d/xprint\fR (where this script exists).
+.PP
+Client programs such as mozilla will require environment
+variable \fB${XPSERVERLIST}\fR to be set, identifying the
+"display" on which Xprt is running. This variable may be set
+for all users via \fB/etc/profile\fR (or similar), using
+\fB/etc/init.d/xprint get_xpserverlist\fR:
+
+.nf
+export XPSERVERLIST=`/etc/init.d/xprint get_xpserverlist`
+.fi
+
+.SH OPTIONS
+Many of Xprt's command line options are shared in common
+with the usual X servers (see \fBXserver\fR(__appmansuffix__)).
+Commonly used options include:
+.TP
+\fB:\fIdisplay\fB\fR
+The X server runs on the given display. If multiple X
+servers are to run simultaneously on a host, each must
+have a unique display number. Note that the standard X
+server (for video displays) typically runs on display
+:0. If \fB/etc/init.d/xprint\fR is used
+to invoke Xprt, it may be configured to automatically assign an available
+display number.
+.TP
+\fB\-ac\fR
+disables host-based access control mechanisms. Enables access
+by any host, and permits any host to modify the access control
+list. Use with extreme caution. This option exists primarily
+for running test suites remotely.
+.TP
+\fB\-audit \fIlevel\fB\fR
+sets the audit trail level. The default level is 1, meaning
+only connection rejections are reported. Level 2 additionally
+reports all successful connections and disconnects. Level 4
+enables messages from the SECURITY extension, if present,
+including generation and revocation of authorizations and
+violations of the security policy. Level 0 turns off the audit
+trail. Audit lines are sent as standard error output.
+.TP
+\fB\-fp \fIfontpath\fB\fR
+sets the search path for fonts. This path is a comma
+separated list of directories which Xprt searches for
+font databases.
+.TP
+\fB\-pn\fR
+permits the server to continue running if it fails to
+establish all of its well-known sockets (connection
+points for clients), but establishes at least
+one.
+.TP
+\fB\-XpFile \fIfile\fB\fR
+Sets an altername Xprinters file (see section FILES).
+.TP
+\fB\-XpSpoolerType \fIspoolername\fB\fR
+Defines the spooler system to be used for print job spooling.
+Supported values in xprint.mozdev.org release 009 are:
+
+aix
+
+aix4
+
+bsd
+
+osf
+
+solaris
+
+sysv
+
+uxp
+
+cups
+
+lprng
+
+other
+
+none
+
+(multiple values can be specified, seperated by ':', the first active spooler will be chosen).
+The default value is platform-specific and can be obtained via
+
+.nf
+Xprt \-h
+.fi
+
+\&.
+.SH ENVIRONMENT
+The following environment variables are recognized by the X print server
+(environment variables recognized by Xprint clients are described in
+\fBXprint\fR(__miscmansuffix__)):
+.TP
+\fB${XPCONFIGDIR}\fR
+This environment variable points to the root
+of the Xprint server configuration directory hierarchy.
+If the variable is not defined, the default
+path is be assumed. The default path may be
+\fB/usr/X11R6/lib/X11/xserver/\fR,
+\fB/usr/lib/X11/xserver/\fR,
+\fB/usr/share/Xprint/xserver/\fR or
+\fB/usr/openwin/server/etc/XpConfig\fR, depending on the
+system, and may be configured in \fB/etc/init.d/xprint\fR.
+.TP
+\fB${LANG}\fR
+This environment variable selects the locale settings used by the Xprint server.
+Xprt allows language-specific settings (stored in \fB${XPCONFIGDIR}/${LANG}/print/\fR)
+which will override the default settings (stored in \fB${XPCONFIGDIR}/C/print/\fR).
+If \fB${LANG}\fR is not set "C" is assumed.
+.PP
+.SH FILES
+.TP
+\fB${XPCONFIGDIR}/${LANG}/print/Xprinters\fR, \fB${XPCONFIGDIR}/C/print/Xprinters\fR
+`Xprinters' is the top most configuration file. It tells
+Xprt which specific printer names (e.g. mylaser) should
+be supported, and whether \fBlpstat\fR(1) or other commands
+should be used to automatically supplement the list of
+printers.
+.TP
+\fB${XPCONFIGDIR}/${LANG}/print/attributes/printer\fR, \fB${XPCONFIGDIR}/C/print/attributes/printer\fR
+The `printer' file maps printer names to model
+configurations (see `model-config' below). For example,
+"mylaser" could be mapped to a "HPDJ1600C", and all other
+arbitrary printers could be mapped to a default, such as
+"HPLJ4SI". When depending on \fBlpstat\fR(1) in the Xprinters
+file, setting up defaults in `printer' becomes all the
+more important.
+.TP
+\fB${XPCONFIGDIR}/${LANG}/print/attributes/document\fR, \fB${XPCONFIGDIR}/C/print/attributes/document\fR
+The `document' file specifies the initial document values
+for any print jobs. For example, which paper tray to
+use, what default resolution, etc.
+.TP
+\fB${XPCONFIGDIR}/${LANG}/print/attributes/job\fR, \fB${XPCONFIGDIR}/C/print/attributes/job\fR
+The `job' file specifies the initial job values for any
+print jobs. For example, "notification-profile" can be
+set so that when a print job is successfully sent to a
+printer, e-mail is sent to the user.
+.TP
+\fB${XPCONFIGDIR}/C/print/models/PSdefault/model\-config\fR, \fB${XPCONFIGDIR}/C/print/models/PSdefault/fonts/fonts.dir\fR, \fB${XPCONFIGDIR}/C/print/models/PSdefault/fonts/9nb00051.pmf\fR, \fB${XPCONFIGDIR}/C/print/models/PSdefault/fonts/9nb00093.pmf\fR
+The `model-config' file has attributes that describe the
+printer model's capabilities and default settings.
+Printer model fonts may also be present. The model-config
+file also identifies the print ddx driver to be used.
+For each printer model supported, a complete hierarchy of
+files should exist. In most cases, these files do not
+need to be modified.
+.TP
+\fB${XPCONFIGDIR}/C/print/ddx\-config/raster/pdf\fR, \fB${XPCONFIGDIR}/C/print/ddx\-config/raster/pcl\fR, \fB${XPCONFIGDIR}/C/print/ddx\-config/raster/postscript\fR
+The print ddx drivers can have highly specific
+configuration files to control their behavior. In most
+cases, these files do not need to be modified.
+.SH "SEE ALSO"
+\fBXprint\fR(__miscmansuffix__), \fBX11\fR(__miscmansuffix__), \fBxplsprinters\fR(__appmansuffix__), \fBxprehashprinterlist\fR(__appmansuffix__), \fBxphelloworld\fR(__appmansuffix__), \fBxpxmhelloworld\fR(__appmansuffix__), \fBxpawhelloworld\fR(__appmansuffix__), \fBxpxthelloworld\fR(__appmansuffix__), \fBxpsimplehelloworld\fR(__appmansuffix__), \fBXserver\fR(__appmansuffix__), \fBlibXp\fR(__libmansuffix__), \fBlibXprintUtils\fR(__libmansuffix__), \fBlibXprintAppUtils\fR(__libmansuffix__), \fBXmPrintShell\fR(__libmansuffix__), \fBXawPrintShell\fR(__libmansuffix__), Xprint FAQ (http://xprint.mozdev.org/docs/Xprint_FAQ.html), Xprint main site (http://xprint.mozdev.org/)
+.SH AUTHORS
+This manual page was written by
+Drew Parsons <dparsons@debian.org> and
+Roland Mainz <roland.mainz@nrubsig.org>,
+with some help from the man page at
+http://www.sins.com.au/unix/manpages/Xprt.html and the XFree86
+man page for \fBXserver\fR(1).
diff --git a/nx-X11/programs/Xserver/Xprint/Xprt.sgml b/nx-X11/programs/Xserver/Xprint/Xprt.sgml
new file mode 100644
index 000000000..0ffa39fcb
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/Xprt.sgml
@@ -0,0 +1,371 @@
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.2//EN" 'http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd'>
+
+<!-- Process this file with docbook-to-man to generate an nroff manual
+ page: 'docbook-to-man manpage.sgml > manpage.1'. You may view
+ the manual page with: 'docbook-to-man manpage.sgml | nroff -man | less'.
+ A typical entry in a Makefile or Makefile.am is:
+
+manpage.1: manpage.sgml
+ docbook-to-man $< > $@
+
+HTML generation can be done like this:
+% xsltproc ==docbook /usr/share/sgml/docbook/docbook-xsl-stylesheets-1.60.1/html/docbook.xsl Xprint.sgml >Xprint.html
+ -->
+
+<refentry id="Xprt">
+ <refmeta>
+ <refentrytitle>Xprt</refentrytitle>
+ <manvolnum>__appmansuffix__</manvolnum>
+ </refmeta>
+ <refnamediv>
+ <refname>Xprt</refname>
+
+ <refpurpose>Print server for X Version 11</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>Xprt</command>
+
+ <arg><option>-ac</option></arg>
+
+ <arg><option>-audit <replaceable>level</replaceable></option></arg>
+
+ <arg><option>-pn</option></arg>
+
+ <arg><option>-fp <replaceable>fontpath</replaceable></option></arg>
+
+ <arg><option>-XpFile <replaceable>file</replaceable></option></arg>
+
+ <arg><option>-XpSpoolerType <replaceable>spoolername</replaceable></option></arg>
+
+ <arg><option>:<replaceable>display</replaceable></option></arg>
+
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>DESCRIPTION</title>
+
+ <para><command>Xprt</command> is the Xprint print server
+ for version 11 of the X Window system for non display devices
+ such as printers and fax machines.</para>
+
+ <para>Xprint is an advanced printing system which enables X11
+ applications to use devices like printers, FAX or create
+ documents in formats like PostScript, PCL or PDF. It may be used by
+ clients such as <application>mozilla</application>.
+ </para>
+
+ <para>Xprint is a very flexible, extensible, scaleable, client/server
+ print system based on ISO 10175 (and some other specs) and the X11
+ rendering protocol.
+ Using Xprint an application can search, query and use devices like
+ printers, FAX machines or create documents in formats like PDF.
+ In particular, an application can seek a printer, query supported
+ attributes (like paper size, trays, fonts etc.), configure the printer
+ device to match it's needs and print on it like on any other X device
+ reusing parts of the code which is used for the video card Xserver.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>USAGE</title>
+
+ <para>
+ Although Xprt may be invoked from the command line, it is
+ preferable to run it as a daemon via the init script
+ <filename>/etc/init.d/xprint</filename> (where this script exists).
+ </para>
+
+ <para>Client programs such as mozilla will require environment
+ variable <envar>${XPSERVERLIST}</envar> to be set, identifying the
+ "display" on which Xprt is running. This variable may be set
+ for all users via <filename>/etc/profile</filename> (or similar), using
+ <userinput>/etc/init.d/xprint get_xpserverlist</userinput>:
+ <informalexample>
+ <programlisting>export XPSERVERLIST=`/etc/init.d/xprint get_xpserverlist`</programlisting>
+ </informalexample>
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>OPTIONS</title>
+
+ <para>Many of Xprt's command line options are shared in common
+ with the usual X servers (see <citerefentry><refentrytitle>Xserver</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry>).
+ Commonly used options include:</para>
+
+ <variablelist>
+ <varlistentry>
+ <term><option>:<replaceable>display</replaceable></option>
+ </term>
+ <listitem>
+ <para> The X server runs on the given display. If multiple X
+ servers are to run simultaneously on a host, each must
+ have a unique display number. Note that the standard X
+ server (for video displays) typically runs on display
+ :0. If <filename>/etc/init.d/xprint</filename> is used
+ to invoke Xprt, it may be configured to automatically assign an available
+ display number.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-ac</option>
+ </term>
+ <listitem>
+ <para>disables host-based access control mechanisms. Enables access
+ by any host, and permits any host to modify the access control
+ list. Use with extreme caution. This option exists primarily
+ for running test suites remotely.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-audit <replaceable>level</replaceable></option>
+ </term>
+ <listitem>
+ <para>sets the audit trail level. The default level is 1, meaning
+ only connection rejections are reported. Level 2 additionally
+ reports all successful connections and disconnects. Level 4
+ enables messages from the SECURITY extension, if present,
+ including generation and revocation of authorizations and
+ violations of the security policy. Level 0 turns off the audit
+ trail. Audit lines are sent as standard error output.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-fp <replaceable>fontpath</replaceable></option>
+ </term>
+ <listitem>
+ <para>sets the search path for fonts. This path is a comma
+ separated list of directories which Xprt searches for
+ font databases.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-pn</option>
+ </term>
+ <listitem>
+ <para>permits the server to continue running if it fails to
+ establish all of its well-known sockets (connection
+ points for clients), but establishes at least
+ one.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>-XpFile <replaceable>file</replaceable></option>
+ </term>
+ <listitem>
+ <para>Sets an altername Xprinters file (see section FILES).</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-XpSpoolerType <replaceable>spoolername</replaceable></option>
+ </term>
+ <listitem>
+ <para>
+ Defines the spooler system to be used for print job spooling.
+ Supported values in xprint.mozdev.org release 009 are:
+ <simplelist type="vert">
+ <member>aix</member>
+ <member>aix4</member>
+ <member>bsd</member>
+ <member>osf</member>
+ <member>solaris</member>
+ <member>sysv</member>
+ <member>uxp</member>
+ <member>cups</member>
+ <member>lprng</member>
+ <member>other</member>
+ <member>none</member>
+ </simplelist>
+ (multiple values can be specified, seperated by ':', the first active spooler will be chosen).
+ The default value is platform-specific and can be obtained via
+ <programlisting>Xprt -h</programlisting>.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>ENVIRONMENT</title>
+ <para>
+ The following environment variables are recognized by the X print server
+ (environment variables recognized by Xprint clients are described in
+ <citerefentry><refentrytitle>Xprint</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry>):
+
+ <variablelist>
+ <varlistentry>
+ <term><envar>${XPCONFIGDIR}</envar></term>
+ <listitem>
+ <para> This environment variable points to the root
+ of the Xprint server configuration directory hierarchy.
+ If the variable is not defined, the default
+ path is be assumed. The default path may be
+ <filename>/usr/X11R6/lib/X11/xserver/</filename>,
+ <filename>/usr/lib/X11/xserver/</filename>,
+ <filename>/usr/share/Xprint/xserver/</filename> or
+ <filename>/usr/openwin/server/etc/XpConfig</filename>, depending on the
+ system, and may be configured in <filename>/etc/init.d/xprint</filename>.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><envar>${LANG}</envar></term>
+ <listitem>
+ <para>
+ This environment variable selects the locale settings used by the Xprint server.
+ Xprt allows language-specific settings (stored in <filename>${XPCONFIGDIR}/${LANG}/print/</filename>)
+ which will override the default settings (stored in <filename>${XPCONFIGDIR}/C/print/</filename>).
+ If <envar>${LANG}</envar> is not set "C" is assumed.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>FILES</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><filename>${XPCONFIGDIR}/${LANG}/print/Xprinters</filename></term>
+ <term><filename>${XPCONFIGDIR}/C/print/Xprinters</filename></term>
+ <listitem>
+ <para>
+ `Xprinters' is the top most configuration file. It tells
+ Xprt which specific printer names (e.g. mylaser) should
+ be supported, and whether <citerefentry><refentrytitle>lpstat</refentrytitle><manvolnum>1</manvolnum></citerefentry> or other commands
+ should be used to automatically supplement the list of
+ printers.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><filename>${XPCONFIGDIR}/${LANG}/print/attributes/printer</filename></term>
+ <term><filename>${XPCONFIGDIR}/C/print/attributes/printer</filename></term>
+ <listitem>
+ <para>
+ The `printer' file maps printer names to model
+ configurations (see `model-config' below). For example,
+ "mylaser" could be mapped to a "HPDJ1600C", and all other
+ arbitrary printers could be mapped to a default, such as
+ "HPLJ4SI". When depending on <citerefentry><refentrytitle>lpstat</refentrytitle><manvolnum>1</manvolnum></citerefentry> in the Xprinters
+ file, setting up defaults in `printer' becomes all the
+ more important.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><filename>${XPCONFIGDIR}/${LANG}/print/attributes/document</filename></term>
+ <term><filename>${XPCONFIGDIR}/C/print/attributes/document</filename></term>
+ <listitem>
+ <para>
+ The `document' file specifies the initial document values
+ for any print jobs. For example, which paper tray to
+ use, what default resolution, etc.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><filename>${XPCONFIGDIR}/${LANG}/print/attributes/job</filename></term>
+ <term><filename>${XPCONFIGDIR}/C/print/attributes/job</filename></term>
+ <listitem>
+ <para>
+ The `job' file specifies the initial job values for any
+ print jobs. For example, "notification-profile" can be
+ set so that when a print job is successfully sent to a
+ printer, e-mail is sent to the user.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><filename>${XPCONFIGDIR}/C/print/models/PSdefault/model-config</filename></term>
+ <term><filename>${XPCONFIGDIR}/C/print/models/PSdefault/fonts/fonts.dir</filename></term>
+ <term><filename>${XPCONFIGDIR}/C/print/models/PSdefault/fonts/9nb00051.pmf</filename></term>
+ <term><filename>${XPCONFIGDIR}/C/print/models/PSdefault/fonts/9nb00093.pmf</filename></term>
+
+ <listitem>
+ <para>
+ The `model-config' file has attributes that describe the
+ printer model's capabilities and default settings.
+ Printer model fonts may also be present. The model-config
+ file also identifies the print ddx driver to be used.
+
+ For each printer model supported, a complete hierarchy of
+ files should exist. In most cases, these files do not
+ need to be modified.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><filename>${XPCONFIGDIR}/C/print/ddx-config/raster/pdf</filename></term>
+ <term><filename>${XPCONFIGDIR}/C/print/ddx-config/raster/pcl</filename></term>
+ <term><filename>${XPCONFIGDIR}/C/print/ddx-config/raster/postscript</filename></term>
+
+ <listitem>
+ <para>
+ The print ddx drivers can have highly specific
+ configuration files to control their behavior. In most
+ cases, these files do not need to be modified.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>SEE ALSO</title>
+ <para>
+ <simplelist type="inline">
+ <!-- specific references -->
+ <!-- none -->
+
+ <!-- Xprint general references -->
+ <member><citerefentry><refentrytitle>Xprint</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>X11</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>xplsprinters</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>xprehashprinterlist</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>xphelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>xpxmhelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>xpawhelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>xpxthelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>xpsimplehelloworld</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>Xserver</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member>
+<!--
+ <member><citerefentry><refentrytitle>Xprt</refentrytitle><manvolnum>__appmansuffix__</manvolnum></citerefentry></member>
+-->
+ <!-- ToDO: Add manual pages for the single Xprint DDX implementations (PostScript/PDF/PCL/PCL-MONO/Raster/etc.) -->
+ <member><citerefentry><refentrytitle>libXp</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>libXprintUtils</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>libXprintAppUtils</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>XmPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>XawPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member>
+ <member>Xprint FAQ (<ulink url="http://xprint.mozdev.org/docs/Xprint_FAQ.html">http://xprint.mozdev.org/docs/Xprint_FAQ.html</ulink>)</member>
+ <member>Xprint main site (<ulink url="http://xprint.mozdev.org/">http://xprint.mozdev.org/</ulink>)</member>
+ </simplelist>
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>AUTHORS</title>
+ <para>
+ This manual page was written by
+ Drew Parsons <email>dparsons@debian.org</email> and
+ Roland Mainz <email>roland.mainz@nrubsig.org</email>,
+ with some help from the man page at
+ <ulink url="http://www.sins.com.au/unix/manpages/Xprt.html">http://www.sins.com.au/unix/manpages/Xprt.html</ulink> and the XFree86
+ man page for <citerefentry><refentrytitle>Xserver</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
+ </para>
+ </refsect1>
+</refentry>
+
+
+
diff --git a/nx-X11/programs/Xserver/Xprint/attributes.c b/nx-X11/programs/Xserver/Xprint/attributes.c
new file mode 100644
index 000000000..60f6803a3
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/attributes.c
@@ -0,0 +1,1740 @@
+/* $Xorg: attributes.c,v 1.3 2000/08/17 19:48:07 cpqbld Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: attributes.c
+** *
+** * Contents:
+** * Implementation of the attribute store for Xp.
+** *
+** * Copyright: Copyright 1995 Hewlett-Packard Company
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xproto.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <pwd.h>
+#include <grp.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#if (defined(sun) && defined(SVR4)) || defined(__SCO__) || defined(__UNIXWARE__)
+#include <wchar.h>
+#endif
+#include "scrnintstr.h"
+
+#include <X11/extensions/Printstr.h>
+
+#include "attributes.h"
+
+#include <X11/Xlib.h>
+#include <X11/Xresource.h>
+
+#include "spooler.h"
+
+#ifndef MIN
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#endif
+#ifndef MAX
+#define MAX(a,b) (((a)>(b))?(a):(b))
+#endif
+
+
+static XrmDatabase CopyDb(XrmDatabase inDb);
+
+extern XrmDatabase XpSpoolerGetServerAttributes(void);
+
+static int attrGeneration = 0;
+
+typedef struct {
+ XrmDatabase *pDb;
+ char *qualifier;
+ char *modelId;
+} DbEnumStruct;
+
+typedef struct {
+ char *stringDb;
+ int nextPos;
+ int space;
+} StringDbStruct;
+
+typedef struct _printerAttrs {
+ struct _printerAttrs *next;
+ char *name;
+ char *qualifier;
+ XrmDatabase printerAttrs;
+ XrmDatabase docAttrs;
+ XrmDatabase jobAttrs;
+} PrAttrs, *PrAttrPtr;
+
+static PrAttrPtr attrList = (PrAttrPtr)NULL;
+
+typedef struct _systemAttrs {
+ XrmDatabase doc;
+ XrmDatabase job;
+ XrmDatabase printers;
+ XrmDatabase server;
+} SysAttrs, *SysAttrsPtr;
+
+SysAttrs systemAttributes;
+
+/*
+ * attrCtxtPrivIndex hold the attribute store's context private index.
+ * This index is allocated at the time the attribute store is initialized.
+ */
+static int attrCtxtPrivIndex;
+
+/*
+ * The ContextAttrs structure descibes the context private space reserved
+ * by the attribute store.
+ */
+typedef struct _contextAttrs {
+ XrmDatabase printerAttrs;
+ XrmDatabase docAttrs;
+ XrmDatabase jobAttrs;
+ XrmDatabase pageAttrs;
+} ContextAttrs, *ContextAttrPtr;
+
+/*
+ * XPDIR is relative to (i.e. is a subdir of) XPRINTDIR/$LANG.
+ */
+static const char XPDIR[] = "/print";
+/*
+ * The following files/directories define or are within subdirectories of the
+ * above-defined XPDIR.
+ */
+static const char XPPRINTERATTRFILE[] = "/attributes/printer";
+static const char XPJOBATTRFILE[] = "/attributes/job";
+static const char XPDOCATTRFILE[] = "/attributes/document";
+static const char XPMODELDIR[] = "/models";
+
+static char NULL_STRING[] = "\0";
+
+/*
+ * XpGetConfigDirBase returns a string containing the path name of the base
+ * where the print server configuration directory is localed.
+ */
+static
+char *XpGetConfigDirBase()
+{
+ char *configDir;
+
+ /*
+ * If the XPCONFIGDIR environment variable is not set, then use the
+ * compile-time constant XPRINTDIR. XPRINTDIR is passed in on the
+ * compile command line, and is defined in $(TOP)/config/cf/Project.tmpl.
+ */
+ if((configDir = getenv("XPCONFIGDIR")) == (char *)NULL)
+ configDir = XPRINTDIR;
+
+ return configDir;
+}
+
+/*
+ * XpGetConfigDir returns a string containing the path name of the print
+ * server configuration directory. If the useLocale parameter is False
+ * the it returns the path to the "/C" directory. If the useLocale
+ * parameter is True it returns the path to the directory associated with
+ * $LANG. It makes no attempt to ensure that the directory actually exists.
+ */
+char *
+XpGetConfigDir(Bool useLocale)
+{
+ char *dirName, *langName, *langDir, *configDir;
+ Bool freeLangDir = False;
+
+ if(useLocale == False) langDir = "/C";
+ else
+ {
+ langName = getenv("LC_ALL");
+ if (langName == NULL) {
+ langName = getenv("LANG");
+ }
+
+ if(langName == (char *)NULL)
+ return (char *)NULL;
+ else
+ {
+ if(strcmp(langName, "C") == 0)
+ return (char *)NULL;
+ langDir = (char *)xalloc(strlen(langName) + 2);
+ sprintf(langDir, "/%s", langName);
+ freeLangDir = True;
+ }
+ }
+
+ configDir = XpGetConfigDirBase();
+
+ dirName = (char *)xalloc(strlen(configDir) + strlen(XPDIR) +
+ strlen(langDir) + 1);
+ sprintf(dirName, "%s%s%s", configDir, langDir, XPDIR);
+
+ if(freeLangDir == True)
+ xfree(langDir);
+
+ return dirName;
+}
+
+/*
+ * GetMergedDatabase reads and merges xrmdb files from the top-level printer
+ * config directory, and from the directory associated with the current
+ * locale (if other than the top-level).
+ */
+static XrmDatabase
+GetMergedDatabase(const char *attrName)
+{
+ char *dirName, *fileName;
+ XrmDatabase db;
+
+ if((dirName = XpGetConfigDir(False)) == (char *)NULL)
+ return (XrmDatabase)NULL;
+ if((fileName = (char *)xalloc(strlen(dirName) + strlen(attrName) + 1)) ==
+ (char *)NULL)
+ return (XrmDatabase)NULL;
+ sprintf(fileName, "%s%s", dirName, attrName);
+ db = XrmGetFileDatabase(fileName);
+ xfree(fileName);
+ xfree(dirName);
+
+ if((dirName = XpGetConfigDir(True)) == (char *)NULL)
+ return db;
+ if((fileName = (char *)xalloc(strlen(dirName) + strlen(attrName) + 1)) ==
+ (char *)NULL)
+ return db;
+ sprintf(fileName, "%s%s", dirName, attrName);
+ (void)XrmCombineFileDatabase(fileName, &db, True);
+ xfree(fileName);
+ xfree(dirName);
+
+ return db;
+}
+
+/*
+ * BuildSystemAttributes reads the on-disk configuration files for printers,
+ * initial job, and initial document attributes. The resulting xrm
+ * databases are then dissected as needed for each printer.
+ * It also allocates a contextPrivate space for the attributes,
+ * reserving space to store pointers to the attribute stores for
+ * the context.
+ */
+static void
+BuildSystemAttributes(void)
+{
+ if(systemAttributes.printers != (XrmDatabase)NULL)
+ XrmDestroyDatabase(systemAttributes.printers);
+ systemAttributes.printers = GetMergedDatabase(XPPRINTERATTRFILE);
+ if(systemAttributes.job != (XrmDatabase)NULL)
+ XrmDestroyDatabase(systemAttributes.job);
+ systemAttributes.job = GetMergedDatabase(XPJOBATTRFILE);
+ if(systemAttributes.doc != (XrmDatabase)NULL)
+ XrmDestroyDatabase(systemAttributes.doc);
+ systemAttributes.doc = GetMergedDatabase(XPDOCATTRFILE);
+ if(systemAttributes.server != (XrmDatabase)NULL)
+ XrmDestroyDatabase(systemAttributes.server);
+ systemAttributes.server = XpSpoolerGetServerAttributes();
+ return;
+}
+
+/*
+ * AddDbEntry is called by XrmEnumerateDatabase, and adds the supplied
+ * database entry to the database pointed to within the "DbEnumStruct"
+ * passed as the client_data (aka "closure").
+ */
+static Bool
+AddDbEntry(
+ XrmDatabase *sourceDB,
+ XrmBindingList bindings,
+ XrmQuarkList quarks,
+ XrmRepresentation *type,
+ XrmValue *value,
+ XPointer client_data)
+{
+ DbEnumStruct *pEnumStruct = (DbEnumStruct *)client_data;
+ XrmName xrm_name[5];
+ XrmClass xrm_class[5];
+ XrmBinding xrm_bind[3];
+ XrmValue realVal;
+ XrmRepresentation rep_type;
+
+ xrm_name[0] = XrmStringToQuark (pEnumStruct->qualifier);
+ xrm_class[0] = XrmStringToQuark (pEnumStruct->modelId);
+
+ for(;*quarks; quarks++)
+ xrm_name[1] = xrm_class[1] = *quarks;
+
+ xrm_name[2] = (XrmQuark)NULL;
+ xrm_class[2] = (XrmQuark)NULL;
+
+ if(XrmQGetResource (*sourceDB, xrm_name, xrm_class, &rep_type, &realVal))
+ {
+ xrm_bind[0] = XrmBindLoosely;
+
+ xrm_name[0] = xrm_name[1];
+ xrm_name[1] = NULLQUARK;
+
+ XrmQPutStringResource(pEnumStruct->pDb, xrm_bind, xrm_name,
+ (char *)realVal.addr);
+ }
+
+ return FALSE;
+}
+
+/*
+ * BuildPrinterAttrs - builds and returns an XrmDatabase for the printer
+ * of the specified name/qualifier, if we have enough information.
+ * If we don't have a model-config
+ * file, then just enumerate the systemAttributes->printers database,
+ * otherwise read in the model-config database and merge into it the
+ * systemAttributes->printers database. This database is then enumerated
+ * with the printer qualifier (and the model name as class if we have it), and
+ * the resulting elements are stored into the database for this particular
+ * printer.
+ */
+static XrmDatabase
+BuildPrinterAttrs(
+ char *printerName,
+ char *qualifierName)
+{
+ XrmDatabase printerDB = (XrmDatabase)NULL;
+
+ if(systemAttributes.printers != (XrmDatabase)NULL)
+ {
+ char *dirName, *fileName;
+ XrmDatabase modelDB = (XrmDatabase)NULL;
+ XrmName xrm_name[5], xrm_class[2];
+ XrmRepresentation rep_type;
+ XrmValue value;
+ DbEnumStruct enumStruct;
+ Bool freeModelDB = False;
+ /*
+ * Build the initial db based on the model-config files
+ */
+ xrm_name[0] = XrmStringToQuark (qualifierName);
+ xrm_name[1] = XrmStringToQuark ("xp-model-identifier");
+ xrm_name[2] = (XrmQuark)NULL;
+ XrmQGetResource (systemAttributes.printers, xrm_name, xrm_name,
+ &rep_type, &value);
+
+ if(value.addr != (XPointer)NULL)
+ {
+ fileName = (char *)xalloc(strlen(XPMODELDIR) +
+ strlen((char *)value.addr) +
+ strlen("model-config") + 3);
+ sprintf(fileName, "%s/%s/%s", XPMODELDIR, value.addr,
+ "model-config");
+ modelDB = GetMergedDatabase(fileName);
+ xfree(fileName);
+ if(modelDB != (XrmDatabase)NULL)
+ {
+ XrmDatabase tempDB = (XrmDatabase)NULL;
+ /*
+ * have to make a temp copy because MergeDatabase destroys
+ * the "source" database. Merge in the printers DB
+ */
+ tempDB = CopyDb(systemAttributes.printers);
+ XrmMergeDatabases(tempDB, &modelDB);
+ freeModelDB = True;
+ }
+ }
+
+ /*
+ * Check to see if we knew the name AND found a database file
+ */
+ if(modelDB == (XrmDatabase)NULL)
+ modelDB = systemAttributes.printers;
+
+ xrm_name[0] = XrmStringToQuark (qualifierName);
+ xrm_name[1] = (XrmQuark)NULL;
+ xrm_class[0] = XrmStringToQuark((char *)value.addr);
+ xrm_class[1] = (XrmQuark)NULL;
+ enumStruct.pDb = &printerDB;
+ enumStruct.qualifier = (char *)qualifierName;
+ enumStruct.modelId = (char *)value.addr;
+ XrmEnumerateDatabase(modelDB, xrm_name, xrm_class, XrmEnumAllLevels,
+ AddDbEntry, (XPointer) &enumStruct);
+
+ if(freeModelDB == True) XrmDestroyDatabase(modelDB);
+ }
+ XrmPutStringResource(&printerDB, "*printer-name", printerName);
+ XrmPutStringResource(&printerDB, "*qualifier", qualifierName);
+ return printerDB;
+}
+
+/*
+ * BuildABase - builds an XrmDatabase by enumerating the supplied sourceBase
+ * database for elements relevant for the printer named by printerName,
+ * and deriving a class for printerName from the model declared in the
+ * systemAttributes.printers database. If no model is defined for this
+ * printer then the printerName is used as the class as well.
+ *
+ * This is used to build the initial value document and initial value
+ * job attribute databases for each printer by searching the system
+ * level doc and job databases.
+ */
+static XrmDatabase
+BuildABase(
+ char *printerName,
+ char *qualifierName,
+ XrmDatabase sourceBase)
+{
+ XrmDatabase builtDB = (XrmDatabase)NULL;
+
+ if(sourceBase != (XrmDatabase)NULL)
+ {
+ XrmName xrm_name[5], xrm_class[2];
+ XrmRepresentation rep_type;
+ XrmValue value;
+ DbEnumStruct enumStruct;
+
+ /*
+ * Retrieve the model name for use as the class.
+ */
+ xrm_name[0] = XrmStringToQuark (printerName);
+ xrm_name[1] = XrmStringToQuark ("xp-model-identifier");
+ xrm_name[2] = (XrmQuark)NULL;
+ XrmQGetResource (systemAttributes.printers, xrm_name, xrm_name,
+ &rep_type, &value);
+ /*
+ * if we have a model name then use it as the class, otherwise
+ * just use the printer name as the class as well as the name.
+ */
+ if(value.addr != (XPointer)NULL)
+ xrm_class[0] = XrmStringToQuark((char *)value.addr);
+ else
+ xrm_class[0] = xrm_name[0];
+ xrm_class[1] = (XrmQuark)NULL;
+
+ xrm_name[1] = (XrmQuark)NULL;
+
+ enumStruct.pDb = &builtDB;
+ enumStruct.qualifier = (char *)qualifierName;
+ enumStruct.modelId = (char *)value.addr;
+ XrmEnumerateDatabase(sourceBase, xrm_name, xrm_class, XrmEnumAllLevels,
+ AddDbEntry, (XPointer) &enumStruct);
+ }
+
+ XrmPutStringResource(&builtDB, "*qualifier", qualifierName);
+
+ return builtDB;
+}
+
+/*
+ * FreeAttrList is called upon server recycle, and frees the printer
+ * databases stored in the global attrList.
+ */
+static void
+FreeAttrList(void)
+{
+ PrAttrPtr pAttr, pNext;
+
+ for(pAttr = attrList, pNext = attrList;
+ pAttr != (PrAttrPtr)NULL;
+ pAttr = pNext)
+ {
+ pNext = pAttr->next;
+ if(pAttr->printerAttrs != (XrmDatabase)NULL)
+ XrmDestroyDatabase(pAttr->printerAttrs);
+ if(pAttr->docAttrs != (XrmDatabase)NULL)
+ XrmDestroyDatabase(pAttr->docAttrs);
+ if(pAttr->jobAttrs != (XrmDatabase)NULL)
+ XrmDestroyDatabase(pAttr->jobAttrs);
+ xfree(pAttr->name);
+ xfree(pAttr->qualifier);
+ xfree(pAttr);
+ }
+ attrList = (PrAttrPtr)NULL;
+}
+
+/*
+ * XpRehashAttributes - frees the per-printer attribute list and
+ * calls BuildSystemAttributes to rebuild the overall attribute
+ * store. It is expected that a caller of this will follow it
+ * by calling XpBuildAttributeStore for a new list of printers.
+ */
+int
+XpRehashAttributes(void)
+{
+ if(attrList != (PrAttrPtr)NULL)
+ FreeAttrList();
+ BuildSystemAttributes();
+ return Success;
+}
+
+/*
+ * XpBuildAttributeStore - creates the attribute database associated
+ * with the specified printer. The first time this is called it
+ * calls BuildSystemAttributes to create the system-level databases.
+ */
+void
+XpBuildAttributeStore(
+ char *printerName,
+ char *qualifierName)
+{
+ PrAttrPtr pAttr;
+
+ if((pAttr = (PrAttrPtr)xalloc(sizeof(PrAttrs))) == (PrAttrPtr)NULL)
+ return;
+
+ if(attrGeneration != serverGeneration)
+ {
+ if(attrList != (PrAttrPtr)NULL)
+ FreeAttrList();
+ attrCtxtPrivIndex = XpAllocateContextPrivateIndex();
+ XpAllocateContextPrivate(attrCtxtPrivIndex, sizeof(ContextAttrs));
+ BuildSystemAttributes();
+
+ attrGeneration = serverGeneration;
+ }
+
+ if(attrList == (PrAttrPtr)NULL)
+ {
+ pAttr->next = (PrAttrPtr)NULL;
+ attrList = pAttr;
+ }
+ else
+ {
+ pAttr->next = attrList;
+ attrList = pAttr;
+ }
+
+ pAttr->name = strdup(printerName);
+ pAttr->qualifier = strdup(qualifierName);
+ pAttr->printerAttrs = BuildPrinterAttrs(printerName, qualifierName);
+ pAttr->docAttrs = BuildABase(printerName, qualifierName,
+ systemAttributes.doc);
+ pAttr->jobAttrs = BuildABase(printerName, qualifierName,
+ systemAttributes.job);
+}
+
+
+static Bool
+StoreEntry(
+ XrmDatabase *sourceDB,
+ XrmBindingList bindings,
+ XrmQuarkList quarks,
+ XrmRepresentation *type,
+ XrmValue *value,
+ XPointer client_data)
+{
+ XrmDatabase *outDb = (XrmDatabase *)client_data;
+
+ XrmQPutStringResource(outDb, bindings, quarks, (char *)value->addr);
+
+ return FALSE;
+}
+
+/*
+ * XpCopyDb - makes a copy of the specified XrmDatabase and returns
+ * the copy.
+ */
+static XrmDatabase
+CopyDb(XrmDatabase inDb)
+{
+ XrmDatabase outDb = (XrmDatabase)NULL;
+ XrmQuark empty = NULLQUARK;
+
+ (void)XrmEnumerateDatabase(inDb, &empty, &empty, XrmEnumAllLevels,
+ StoreEntry, (XPointer) &outDb);
+ return outDb;
+}
+
+/*
+ * XpInitAttributes - initializes the attribute store for the specified
+ * context. It does this by making copies of the printer, doc, and job
+ * attributes databases for the printer associated with the context.
+ */
+void
+XpInitAttributes(XpContextPtr pContext)
+{
+ ContextAttrPtr pCtxtAttrs;
+ PrAttrPtr pPrAttr = attrList;
+
+ /* Initialize all the pointers to NULL */
+ pCtxtAttrs = (ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ (void)memset((void *)pCtxtAttrs, 0, (size_t) sizeof(ContextAttrs));
+
+ for(pPrAttr = attrList; pPrAttr != (PrAttrPtr)NULL; pPrAttr = pPrAttr->next)
+ if(!strcmp(pPrAttr->name, pContext->printerName)) break;
+
+ if(pPrAttr != (PrAttrPtr)NULL)
+ {
+ pCtxtAttrs->printerAttrs = CopyDb(pPrAttr->printerAttrs);
+ pCtxtAttrs->docAttrs = CopyDb(pPrAttr->docAttrs);
+ pCtxtAttrs->jobAttrs = CopyDb(pPrAttr->jobAttrs);
+ }
+}
+
+void
+XpDestroyAttributes(
+ XpContextPtr pContext)
+{
+ ContextAttrPtr pCtxtAttrs;
+
+ pCtxtAttrs = (ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+
+ if(pCtxtAttrs->printerAttrs != (XrmDatabase)NULL)
+ XrmDestroyDatabase(pCtxtAttrs->printerAttrs);
+ if(pCtxtAttrs->docAttrs != (XrmDatabase)NULL)
+ XrmDestroyDatabase(pCtxtAttrs->docAttrs);
+ if(pCtxtAttrs->jobAttrs != (XrmDatabase)NULL)
+ XrmDestroyDatabase(pCtxtAttrs->jobAttrs);
+ if(pCtxtAttrs->pageAttrs != (XrmDatabase)NULL)
+ XrmDestroyDatabase(pCtxtAttrs->pageAttrs);
+}
+
+/*
+ * XpGetOneAttribute returns the string value of the specified attribute
+ * in the specified class for the specified print context. If the attribute
+ * doesn't exist in the database for this context, or if the class database
+ * doesn't exist for this context, then NULL is returned. The caller must
+ * not free the returned string, as the returned pointer points into the
+ * database. This function can also return a value from the server attributes,
+ * in which case the pContext parameter is ignored.
+ */
+char *
+XpGetOneAttribute(
+ XpContextPtr pContext,
+ XPAttributes class,
+ char *attributeName)
+{
+ ContextAttrPtr pCtxtAttrs;
+ XrmDatabase db = (XrmDatabase)NULL;
+ char *retVal;
+ XrmName xrm_name[3];
+ XrmRepresentation rep_type;
+ XrmValue value;
+
+ if(class == XPServerAttr)
+ {
+ if(systemAttributes.server == (XrmDatabase)NULL)
+ return NULL_STRING;
+
+ xrm_name[0] = XrmStringToQuark (attributeName);
+ xrm_name[1] = (XrmQuark)NULL;
+ XrmQGetResource(systemAttributes.server, xrm_name, xrm_name,
+ &rep_type, &value);
+
+ if(value.addr == (char *)NULL)
+ return NULL_STRING;
+ return (char *)value.addr;
+ }
+ else
+ {
+ pCtxtAttrs=(ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ switch(class)
+ {
+ case XPPrinterAttr:
+ db = pCtxtAttrs->printerAttrs;
+ break;
+ case XPDocAttr:
+ db = pCtxtAttrs->docAttrs;
+ break;
+ case XPJobAttr:
+ db = pCtxtAttrs->jobAttrs;
+ break;
+ case XPPageAttr:
+ db = pCtxtAttrs->pageAttrs;
+ break;
+ default:
+ break;
+ }
+ }
+ if(db == (XrmDatabase)NULL)
+ return NULL_STRING;
+
+ xrm_name[0] = XrmStringToQuark ("qualifier");
+ xrm_name[1] = (XrmQuark)NULL;
+ XrmQGetResource(db, xrm_name, xrm_name, &rep_type, &value);
+
+ xrm_name[0] = XrmStringToQuark (value.addr);
+ xrm_name[1] = XrmStringToQuark (attributeName);
+ xrm_name[2] = (XrmQuark)NULL;
+ if(XrmQGetResource(db, xrm_name, xrm_name, &rep_type, &value))
+ return (char *)value.addr;
+ else
+ return NULL_STRING;
+}
+
+/*
+ * XpPutOneAttribute updates one attribute for the specified
+ * context and class. This function is intended for use by the attribute
+ * validation module which updates the XrmDatabases directly. This
+ * function does not recognize XPServerAttr.
+ */
+void
+XpPutOneAttribute(
+ XpContextPtr pContext,
+ XPAttributes class,
+ const char* attributeName,
+ const char* value)
+{
+ ContextAttrPtr pCtxtAttrs;
+ XrmDatabase db;
+ XrmBinding bindings[1];
+ XrmQuark quarks[2];
+
+ pCtxtAttrs = (ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ switch(class)
+ {
+ case XPPrinterAttr:
+ db = pCtxtAttrs->printerAttrs;
+ break;
+ case XPDocAttr:
+ db = pCtxtAttrs->docAttrs;
+ break;
+ case XPJobAttr:
+ db = pCtxtAttrs->jobAttrs;
+ break;
+ case XPPageAttr:
+ db = pCtxtAttrs->pageAttrs;
+ break;
+ default:
+ return;
+ }
+ bindings[0] = XrmBindLoosely;
+ quarks[0] = XrmStringToQuark(attributeName);
+ quarks[1] = (XrmQuark)NULL;
+ XrmQPutStringResource(&db, bindings, quarks, value ? value : "");
+}
+
+
+
+/*******************************************************************************
+ *
+ * The following routines: ExpandSpace, PutString, PutByte, and AppendEntry
+ * form the functional core of the GetAttributes routine. Xrm does not
+ * supply a routine to form a string database from an XrmDatabase, except
+ * by writing the database to a file. This code avoids the file system
+ * overhead, but is a bit clunky in its memory management.
+ *
+ ******************************************************************************/
+
+/*
+ * ExpandSpace expands the memory allocated for the string database in
+ * the StringDbStruct passed in, and updates the "space" field of the
+ * struct to indicate the new amount of space available.
+ */
+static Bool
+ExpandSpace(
+ StringDbStruct *pStr)
+{
+ char *newSpace;
+
+ if((newSpace = (char *)xrealloc(pStr->stringDb, pStr->nextPos + pStr->space
+ + 1024)) == (char *)NULL)
+ return False;
+ pStr->space += 1024;
+ pStr->stringDb = newSpace;
+ return True;
+}
+
+/*
+ * PutString puts the contents of a null-terminated string into the string
+ * database in the StringDbStruct passed in. If there is insufficient room
+ * for the string, ExpandSpace is called, and the nextPos and space fields
+ * are updated.
+ */
+static void
+PutString(
+ StringDbStruct *pStr,
+ char *pString)
+{
+ int len = strlen(pString);
+
+ if(len >= pStr->space)
+ if(!ExpandSpace(pStr))
+ return;
+ strcpy(&pStr->stringDb[pStr->nextPos], pString);
+ pStr->nextPos += len;
+ pStr->space -= len;
+}
+
+/*
+ * PutByte puts a single byte value in to the string database in the passed-in
+ * StringDbStruct. ExpandSpace is called if there is insufficient room for
+ * the byte, and the nextPos and space fields are updated.
+ */
+static void
+PutByte(
+ StringDbStruct *pStr,
+ char byte)
+{
+ if(pStr->space <= 1)
+ if(!ExpandSpace(pStr))
+ return;
+ pStr->stringDb[pStr->nextPos] = byte;
+ pStr->nextPos++;
+ pStr->space--;
+}
+
+#define XrmQString XrmPermStringToQuark("String")
+
+/*
+ * AppendEntry is called by XrmEnumerateDatabase, and serves to append
+ * a database entry onto a string database. The passed-in "closure"
+ * struct contains a pointer to the string, and a count of the remaining
+ * bytes. If there are insufficient remaining bytes then the struct
+ * is realloced, and the count of the space remaining is updated.
+ * Database elements of types other than String are ignored!
+ * This code is based directly on that in "DumpEntry" in Xrm.c.
+ */
+static Bool
+AppendEntry(
+ XrmDatabase *db,
+ XrmBindingList bindings,
+ XrmQuarkList quarks,
+ XrmRepresentation *type,
+ XrmValuePtr value,
+ XPointer data)
+{
+ StringDbStruct *pEnumStr = (StringDbStruct *)data;
+ Bool firstNameSeen;
+ unsigned int i;
+ char *s, c;
+
+ if (*type != XrmQString)
+ return False;
+
+ for (firstNameSeen = False; *quarks; bindings++, quarks++) {
+ if (*bindings == XrmBindLoosely) {
+ PutString(pEnumStr, "*");
+ } else if (firstNameSeen) {
+ PutString(pEnumStr, ".");
+ }
+ firstNameSeen = True;
+ PutString(pEnumStr, XrmQuarkToString(*quarks));
+ }
+ s = value->addr;
+ i = value->size;
+ PutString(pEnumStr, ":\t");
+ if(i) i--;
+
+ if (i && (*s == ' ' || *s == '\t'))
+ PutByte(pEnumStr, '\\'); /* preserve leading whitespace */
+
+ while (i--) {
+ c = *s++;
+ if (c == '\n') {
+ if (i)
+ PutString(pEnumStr, "\\n\\\n");
+ else
+ PutString(pEnumStr, "\\n");
+ } else if (c == '\\')
+ PutString(pEnumStr, "\\\\");
+ else if ((c < ' ' && c != '\t') ||
+ ((unsigned char)c >= 0x7f && (unsigned char)c < 0xa0))
+ {
+ char temp[4];
+ (void) sprintf(temp, "\\%03o", (unsigned char)c);
+ PutString(pEnumStr, temp);
+ }
+ else
+ PutByte(pEnumStr, c);
+ }
+ PutByte(pEnumStr, '\n');
+ pEnumStr->stringDb[pEnumStr->nextPos] = (char)'\0';
+ return False;
+}
+
+/*
+ * XpGetAttributes returns a string database version of the Xrm database
+ * for the specified context and class. This function can also return the
+ * contents of the server attributes, in which case the pContext parameter
+ * is ignored.
+ *
+ * The caller is responsible for freeing the returned string,
+ * unlike XpGetOneAttribute, where the caller must not free the string.
+ */
+char *
+XpGetAttributes(
+ XpContextPtr pContext,
+ XPAttributes class)
+{
+ ContextAttrPtr pCtxtAttrs;
+ XrmDatabase db = (XrmDatabase)NULL;
+ char *retVal;
+ StringDbStruct enumStruct;
+ XrmQuark empty = NULLQUARK;
+
+ if(class == XPServerAttr)
+ db = systemAttributes.server;
+ else
+ {
+ pCtxtAttrs=(ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ switch(class)
+ {
+ case XPServerAttr:
+ db = systemAttributes.server;
+ break;
+ case XPPrinterAttr:
+ db = pCtxtAttrs->printerAttrs;
+ break;
+ case XPDocAttr:
+ db = pCtxtAttrs->docAttrs;
+ break;
+ case XPJobAttr:
+ db = pCtxtAttrs->jobAttrs;
+ break;
+ case XPPageAttr:
+ db = pCtxtAttrs->pageAttrs;
+ break;
+ default:
+ break;
+ }
+ }
+ if(db == (XrmDatabase)NULL)
+ {
+ char *retval = (char *)xalloc(1);
+ retval[0] = (char)'\0';
+ return retval;
+ }
+
+ if((enumStruct.stringDb = (char *)xalloc(1024)) == (char *)NULL)
+ return (char *)NULL;
+ enumStruct.stringDb[0] = (char)'\0';
+ enumStruct.nextPos = 0;
+ enumStruct.space = 1024;
+ (void)XrmEnumerateDatabase(db, &empty, &empty, XrmEnumAllLevels,
+ AppendEntry, (XPointer) &enumStruct);
+
+ return enumStruct.stringDb;
+}
+
+int
+XpAugmentAttributes(
+ XpContextPtr pContext,
+ XPAttributes class,
+ char *attributes)
+{
+ XrmDatabase db;
+ ContextAttrPtr pCtxtAttrs;
+
+ db = XrmGetStringDatabase(attributes);
+ if(db == (XrmDatabase)NULL) return BadAlloc;
+
+ pCtxtAttrs = (ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ switch(class)
+ {
+ case XPPrinterAttr:
+ XrmMergeDatabases(db, &pCtxtAttrs->printerAttrs);
+ break;
+ case XPDocAttr:
+ XrmMergeDatabases(db, &pCtxtAttrs->docAttrs);
+ break;
+ case XPJobAttr:
+ XrmMergeDatabases(db, &pCtxtAttrs->jobAttrs);
+ break;
+ case XPPageAttr:
+ XrmMergeDatabases(db, &pCtxtAttrs->pageAttrs);
+ break;
+ default:
+ break;
+ }
+ return Success;
+}
+
+/*
+ * XpSetAttributes - sets the attribute stores for a specified context.
+ */
+int
+XpSetAttributes(
+ XpContextPtr pContext,
+ XPAttributes class,
+ char *attributes)
+{
+ XrmDatabase db;
+ ContextAttrPtr pCtxtAttrs;
+
+ db = XrmGetStringDatabase(attributes);
+ if(db == (XrmDatabase)NULL) return BadAlloc;
+
+ pCtxtAttrs=(ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ switch(class)
+ {
+ case XPPrinterAttr:
+ if(pCtxtAttrs->printerAttrs != (XrmDatabase)NULL)
+ XrmDestroyDatabase(pCtxtAttrs->printerAttrs);
+ pCtxtAttrs->printerAttrs = db;
+ break;
+ case XPDocAttr:
+ if(pCtxtAttrs->docAttrs != (XrmDatabase)NULL)
+ XrmDestroyDatabase(pCtxtAttrs->docAttrs);
+ pCtxtAttrs->docAttrs = db;
+ break;
+ case XPJobAttr:
+ if(pCtxtAttrs->jobAttrs != (XrmDatabase)NULL)
+ XrmDestroyDatabase(pCtxtAttrs->jobAttrs);
+ pCtxtAttrs->jobAttrs = db;
+ break;
+ case XPPageAttr:
+ if(pCtxtAttrs->pageAttrs != (XrmDatabase)NULL)
+ XrmDestroyDatabase(pCtxtAttrs->pageAttrs);
+ pCtxtAttrs->pageAttrs = db;
+ break;
+ default:
+ break;
+ }
+ return Success;
+}
+
+void
+XpAddPrinterAttribute(
+ char *printerName,
+ char *printerQualifier,
+ char *attributeName,
+ char *attributeValue)
+{
+ PrAttrPtr pAttr;
+
+ for(pAttr = attrList; pAttr != (PrAttrPtr)NULL; pAttr = pAttr->next)
+ {
+ if(!strcmp(printerQualifier, pAttr->qualifier))
+ {
+ XrmPutStringResource(&pAttr->printerAttrs, attributeName,
+ attributeValue);
+ break;
+ }
+ }
+}
+
+const char *
+XpGetPrinterAttribute(const char *printerName,
+ const char *attribute)
+{
+ PrAttrPtr pAttr;
+ XrmValue value;
+ char *type;
+
+ for(pAttr = attrList; pAttr != (PrAttrPtr)NULL; pAttr = pAttr->next)
+ {
+ if(!strcmp(printerName, pAttr->qualifier))
+ {
+ char *attrStr;
+
+ attrStr = (char *)xalloc(strlen(printerName) + strlen(attribute) +
+ 2);
+ sprintf(attrStr, "%s.%s", printerName, attribute);
+ XrmGetResource(pAttr->printerAttrs, attrStr, attrStr,
+ &type, &value);
+ xfree(attrStr);
+ break;
+ }
+ }
+ if(value.addr != (XPointer)NULL && strlen(value.addr) != 0)
+ return value.addr;
+ else
+ return "";
+}
+
+/*******************************************************************************
+ *
+ * The following routines are not attribute routines, but are rather
+ * spooler interface functions. They should presumably move to
+ * a SpoolerIf.c of some similarly named file.
+ *
+ ******************************************************************************/
+#include <locale.h>
+
+static char serverAttrStr[] = "*document-attributes-supported: copy-count\n\
+*job-attributes-supported: job-name job-owner\
+ notification-profile xp-spooler-command-options\n\
+*multiple-documents-supported: False";
+
+XrmDatabase
+XpSpoolerGetServerAttributes(void)
+{
+ char *totalAttrs, *localeName;
+ XrmDatabase db;
+
+ localeName = setlocale(LC_CTYPE, (char *)NULL);
+ if(!localeName || strlen(localeName) == 0)
+ localeName = "C";
+
+ if((totalAttrs = (char *)xalloc(strlen(serverAttrStr) + strlen(localeName)
+ + 11)) == (char *)NULL)
+ return (XrmDatabase)NULL;
+ sprintf(totalAttrs, "%s\n%s\t%s", serverAttrStr, "*locale:", localeName);
+
+ db = XrmGetStringDatabase(totalAttrs);
+ xfree(totalAttrs);
+ return db;
+}
+
+/*
+ * Tailf() works similar to "/bin/tail -f fd_in >fd_out" until
+ * the process |child| terminates (the child status is
+ * returned in |child_status|).
+ * This function is used to copy the stdout/stderr output of a
+ * child to fd_out until the child terminates.
+ */
+static
+void Tailf(int fd_in, int fd_out, pid_t child, int *child_status)
+{
+ char b[256];
+ ssize_t sz;
+ Bool childDone = FALSE;
+ struct timeval timeout;
+ long fpos = 0; /* XXX: this is not correct for largefile support */
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 100000;
+
+ for(;;)
+ {
+ /* Check whether the child is still alive or not */
+ if (waitpid(child, child_status, WNOHANG) == child)
+ childDone = TRUE;
+
+ /* Copy traffic from |fd_in| to |fd_out|
+ * (Note we have to use |pread()| here to avoid race conditions
+ * between a child process writing to the same file using the
+ * same file pointer (|dup(2)| and |fork(2)| just duplicate the
+ * file handle but not the pointer)).
+ */
+ while ((sz = pread(fd_in, b, sizeof(b), fpos)) > 0)
+ {
+ fpos += sz;
+ write(fd_out, b, sz);
+ }
+
+ if (childDone)
+ break;
+
+ (void)select(0, NULL, NULL, NULL, &timeout);
+ }
+}
+
+/*
+ * SendFileToCommand takes three character pointers - the file name,
+ * the command to execute,
+ * and the "argv" style NULL-terminated vector of arguments for the command.
+ * The command is exec'd, and the file contents are sent to the command
+ * via stdin.
+ *
+ * WARNING: This function will try to adopt the userId of the supplied
+ * user name prior to exec'ing the supplied command.
+ */
+static void
+SendFileToCommand(
+ XpContextPtr pContext,
+ char *fileName,
+ char *pCommand,
+ char **argVector,
+ char *userName)
+{
+ pid_t childPid;
+ int pipefd[2];
+ int status;
+ struct stat statBuf;
+ FILE *fp, *outPipe;
+ FILE *resFp; /* output from launched command */
+ int resfd;
+
+ resFp = tmpfile();
+ if (resFp == NULL)
+ {
+ ErrorF("SendFileToCommand: Cannot open temporary file for command output\n");
+ return;
+ }
+ resfd = fileno(resFp);
+
+ if(pipe(pipefd))
+ {
+ ErrorF("SendFileToCommand: Cannot open pipe\n");
+ fclose(resFp);
+ return;
+ }
+
+ if(stat(fileName, &statBuf) < 0 || (int)statBuf.st_size == 0)
+ {
+ close(pipefd[0]);
+ close(pipefd[1]);
+ fclose(resFp);
+ return;
+ }
+
+ fp = fopen(fileName, "r");
+ if(fp == (FILE *)NULL)
+ {
+ ErrorF("SendFileToCommand: Cannot open scratch spool file '%s'\n", fileName);
+ close(pipefd[0]);
+ close(pipefd[1]);
+ fclose(resFp);
+ return;
+ }
+
+ if((childPid = fork()) == 0)
+ {
+ close(pipefd[1]);
+
+ /* Replace current stdin with input from the pipe */
+ close(STDIN_FILENO);
+ dup(pipefd[0]);
+ close(pipefd[0]);
+
+ /* Close current stdout and redirect it to resfd */
+ close(STDOUT_FILENO);
+ dup(resfd);
+
+ /* Close current stderr and redirect it to resfd
+ * (valgrind may not like that, in this case simply start it using
+ * % valgrind 50>/dev/tty --logfile-fd=50 <more-options> ./Xprt ... #)
+ */
+ close(STDERR_FILENO);
+ dup(resfd);
+
+ fclose(resFp);
+
+ /*
+ * If a user name is specified, try to set our uid to match that
+ * user name. This is to allow e.g. a banner page to show the
+ * name of the printing user rather than the user who started
+ * the print server.
+ */
+ if(userName)
+ {
+ uid_t myUid;
+
+ if((myUid = geteuid()) == (uid_t)0)
+ {
+ struct passwd *pPasswd;
+
+ if((pPasswd = getpwnam(userName)))
+ {
+ if (setgid((gid_t)pPasswd->pw_gid) != 0)
+ perror("SendFileToCommand: setgid() failure.");
+
+ if (initgroups(userName, (gid_t)pPasswd->pw_gid) != 0)
+ perror("SendFileToCommand: initgroups() failure.");
+
+ if (setuid((uid_t)pPasswd->pw_uid) != 0)
+ perror("SendFileToCommand: setuid() failure.");
+ }
+ }
+ }
+ /* return BadAlloc? */
+ if (execv(pCommand, argVector) == -1) {
+ FatalError("unable to exec '%s'", pCommand);
+ }
+ }
+ else
+ {
+ (void) close(pipefd[0]);
+
+ outPipe = fdopen(pipefd[1], "w");
+ (void) TransferBytes(fp, outPipe, (int)statBuf.st_size);
+
+ (void) fclose(outPipe);
+ (void) fclose(fp);
+
+ /* Wait for spooler child (and send all it's output to stderr) */
+ Tailf(resfd, STDERR_FILENO, childPid, &status);
+
+ if (status != EXIT_SUCCESS)
+ {
+ ErrorF("SendFileToCommand: spooler command returned non-zero status %d.\n", status);
+ }
+
+ /* Store "xp-spooler-command-results" XPJobAttr that the
+ * client can fetch it on demand */
+ if ((fstat(resfd, &statBuf) >= 0) && (statBuf.st_size >= 0))
+ {
+ long bufSize;
+ char *buf;
+
+ bufSize = statBuf.st_size;
+
+ /* Clamp buffer size to 4MB to prevent that we allocate giant
+ * buffers if the spooler goes mad and spams it's stdout/stderr
+ * channel. */
+ bufSize = MIN(bufSize, 4*1024*1024);
+
+ buf = xalloc(bufSize+1);
+ if (buf != NULL)
+ {
+ bufSize = pread(resfd, buf, bufSize, 0);
+ buf[bufSize]='\0';
+
+ /* XXX: This should be converted from local multibyte encoding to
+ * Compound Text encoding first */
+ XpPutOneAttribute(pContext, XPJobAttr, "xp-spooler-command-results", buf);
+
+ xfree(buf);
+ }
+ }
+ else
+ {
+ ErrorF("SendFileToCommand: fstat() failed.\n");
+ }
+
+ fclose(resFp);
+ }
+ return;
+}
+
+/*
+ * ReplaceAllKeywords causes all the predefined keywords (e.g. %options%)
+ * to be replaced with the appropriate values derived from the attribute
+ * store for the supplied print context. The ReplaceAnyString utility
+ * routine is used to perform the actual replacements.
+ */
+
+static char *
+ReplaceAllKeywords(
+ XpContextPtr pContext,
+ char *command)
+{
+ char *cmdOpt;
+
+ cmdOpt = XpGetOneAttribute(pContext, XPPrinterAttr,
+ "xp-spooler-printer-name");
+ if(cmdOpt != (char *)NULL && strlen(cmdOpt) != 0)
+ command = ReplaceAnyString(command, "%printer-name%", cmdOpt);
+ else
+ command = ReplaceAnyString(command, "%printer-name%",
+ pContext->printerName);
+
+ cmdOpt = XpGetOneAttribute(pContext, XPDocAttr, "copy-count");
+ if(cmdOpt != (char *)NULL && strlen(cmdOpt) != 0)
+ command = ReplaceAnyString(command, "%copy-count%", cmdOpt);
+ else
+ command = ReplaceAnyString(command, "%copy-count%", "1");
+
+ cmdOpt = XpGetOneAttribute(pContext, XPJobAttr, "job-name");
+ if(cmdOpt != (char *)NULL && strlen(cmdOpt) != 0)
+ command = ReplaceAnyString(command, "%job-name%", cmdOpt);
+ else
+ command = ReplaceAnyString(command, "%job-name%", "");
+
+ cmdOpt = XpGetOneAttribute(pContext, XPJobAttr, "job-owner");
+ if(cmdOpt != (char *)NULL && strlen(cmdOpt) != 0)
+ command = ReplaceAnyString(command, "%job-owner%", cmdOpt);
+ else
+ command = ReplaceAnyString(command, "%job-owner%", "");
+
+ cmdOpt = XpGetOneAttribute(pContext, XPJobAttr,
+ "xp-spooler-command-options");
+ if(cmdOpt != (char *)NULL && strlen(cmdOpt) != 0)
+ command = ReplaceAnyString(command, "%options%", cmdOpt);
+ else
+ command = ReplaceAnyString(command, "%options%", "");
+
+ /* New in xprint.mozdev.org release 007 - replace "%xpconfigdir%" with
+ * location of $XPCONFIGDIR */
+ command = ReplaceAnyString(command, "%xpconfigdir%", XpGetConfigDirBase());
+
+ return command;
+}
+
+#ifdef __QNX__
+#define toascii( c ) ((unsigned)(c) & 0x007f)
+#endif
+
+#if defined(CSRG_BASED) || \
+ defined(linux) || \
+ defined(__CYGWIN__) || \
+ (defined(sun) && !defined(SVR4)) || \
+ (defined(SVR4) && !defined(sun) && !defined(__UNIXWARE__)) || \
+ defined(__UNIXOS2__) || \
+ defined(ISC) || \
+ defined(Lynx) || \
+ defined(__QNX__) || \
+ defined(__DARWIN__)
+#define iswspace(c) (isascii(c) && isspace(toascii(c)))
+#endif
+
+/*
+ * GetToken - takes in a string and returns a malloc'd copy of the
+ * first non-white-space sequence of characters in the string.
+ * It returns the number of _bytes_ (NOT characters) parsed through
+ * the inStr to get to the end of the returned token.
+ */
+static int
+GetToken(
+ char *inStr,
+ char **outStr)
+{
+ size_t mbCurMax = MB_CUR_MAX;
+ wchar_t curChar;
+ int i, numBytes, byteLen = strlen(inStr);
+ char *tok;
+
+ /*
+ * read through any leading white space.
+ */
+ for(i = 0, numBytes = 0; i < byteLen; i += numBytes)
+ {
+ numBytes = mbtowc(&curChar, &inStr[i], mbCurMax);
+ if(!iswspace(curChar))
+ break;
+ }
+ tok = inStr + i;
+
+ /*
+ * find the end of the token.
+ */
+ byteLen = strlen(tok);
+ for(i = 0, numBytes = 0; i < byteLen; i += numBytes)
+ {
+ numBytes = mbtowc(&curChar, &tok[i], mbCurMax);
+ if(iswspace(curChar))
+ break;
+ }
+
+ if((*outStr = (char *)xalloc(i + 1)) == (char *)NULL)
+ return 0;
+ strncpy(*outStr, tok, i);
+ (*outStr)[i] = (char)'\0';
+ return (tok + i) - inStr;
+}
+
+static void
+FreeVector(
+ char **vector)
+{
+ int i;
+
+ if(vector == (char **)NULL) return;
+
+ for(i = 0; vector[i] != (char *)NULL; i++)
+ xfree(vector[i]);
+ xfree(vector);
+}
+
+
+/*
+ * AddVector appends the pAddition arg vector to the pTarget arg vector.
+ * If the pTarget cannot be realloc'd, then pTarget is set to NULL.
+ */
+static void
+AddVector(
+ char ***pTarget,
+ char **pAddition)
+{
+ int numTarget, numAdd, i;
+
+ for(numTarget = 0; (*pTarget)[numTarget] != (char *)NULL; numTarget++)
+ ;
+ for(numAdd = 0; pAddition[numAdd] != (char *)NULL; numAdd++)
+ ;
+
+ *pTarget = (char **)xrealloc((void *)*pTarget, (numTarget + numAdd + 1) *
+ sizeof(char *));
+ if(*pTarget == (char **)NULL)
+ return;
+ for(i = 0; i < numAdd; i++)
+ (*pTarget)[numTarget + i] = pAddition[i];
+
+ (*pTarget)[numTarget + numAdd] = (char *)NULL;
+}
+
+static char **
+BuildArgVector(
+ char *argString,
+ XpContextPtr pContext)
+{
+ char **pVector;
+ char *curTok;
+ int numChars, i;
+ static int beenHere = 0; /* prevent recursion on embedded %options%
+ */
+
+ pVector = (char **)xalloc(sizeof(char *));
+ pVector[0] = (char *)NULL;
+ for(i = 0; (numChars = GetToken(argString, &curTok)) != 0;
+ i++, argString += numChars)
+ {
+ if(beenHere || strcmp(curTok, "%options%"))
+ {
+ if(curTok[0] == (char)'\0')
+ {
+ xfree(curTok);
+ }
+ else
+ {
+ pVector = (char **)xrealloc((void *)pVector,
+ (i + 2)*sizeof(char *));
+ if(pVector == (char **)NULL)
+ return (char **)NULL;
+ pVector[i] = curTok;
+ pVector[i + 1] = (char *)NULL;
+ }
+ }
+ else if(!beenHere)
+ {
+ char **optionsVec;
+
+ curTok = ReplaceAllKeywords(pContext, curTok);
+ beenHere = 1;
+ optionsVec = BuildArgVector(curTok, pContext);
+ xfree(curTok);
+ beenHere = 0;
+ AddVector(&pVector, optionsVec);
+ xfree(optionsVec);
+ }
+ }
+ if(numChars == 0 && curTok != (char *)NULL)
+ xfree(curTok);
+ return pVector;
+}
+
+/*
+ * VectorizeCommand takes a string and breaks it into a command name and
+ * an array of character pointers suitable for handing to execv. The
+ * array is NULL-terminated.
+ * The returned char * is the command name, and should be freed when no
+ * longer needed. The array elements returned in the pVector parameter
+ * should be individually freed, and the array itself should also be
+ * freed when no longer needed.
+ */
+static char *
+VectorizeCommand(
+ char *command,
+ char ***pVector,
+ XpContextPtr pContext)
+{
+ char *cmdName, *curTok;
+ int i, numChars;
+
+ if(command == (char *)NULL)
+ return (char *)NULL;
+
+ numChars = GetToken(command, &cmdName);
+
+ if(cmdName == (char *)NULL)
+ return (char *)NULL;
+
+ /* Mangle the command name, too... */
+ cmdName = ReplaceAllKeywords(pContext, cmdName);
+
+ if(cmdName == (char *)NULL)
+ return (char *)NULL;
+
+ *pVector = BuildArgVector(command, pContext);
+
+ return cmdName;
+}
+
+int
+XpSubmitJob(fileName, pContext)
+ char *fileName;
+ XpContextPtr pContext;
+{
+ char **vector, *cmdNam, *cmdOpt, *command, *userName;
+ int i;
+
+ command = XpGetOneAttribute(pContext, XPPrinterAttr, "xp-spooler-command");
+ if(command == (char *)NULL || strlen(command) == 0)
+ {
+ if( spooler_type )
+ {
+ command = strdup(spooler_type->spool_command);
+ }
+ else
+ {
+ ErrorF("XpSubmitJob: No default spool command defined.\n");
+ }
+ }
+ else
+ {
+ command = strdup(command);
+ }
+ if(command == (char *)NULL)
+ {
+ ErrorF("XpSubmitJob: No spooler command found, cannot submit job.\n");
+ return BadAlloc;
+ }
+
+ cmdNam = VectorizeCommand(command, &vector, pContext);
+ xfree(command);
+
+ if(cmdNam == (char *)NULL)
+ return BadAlloc;
+
+ for(i = 0; vector[i] != (char *)NULL; i++)
+ {
+ vector[i] = ReplaceAllKeywords(pContext, vector[i]);
+ if(vector[i] == (char *)NULL)
+ {
+ xfree(cmdNam);
+ for(i = 0; vector[i] != (char *)NULL; i++)
+ xfree(vector[i]);
+ xfree(vector);
+ return BadAlloc;
+ }
+ }
+
+ userName = XpGetOneAttribute(pContext, XPJobAttr, "job-owner");
+ if(userName != (char *)NULL && strlen(userName) == 0)
+ userName = (char *)NULL;
+
+ SendFileToCommand(pContext, fileName, cmdNam, vector, userName);
+
+ FreeVector(vector);
+ xfree(cmdNam);
+
+ return Success;
+}
+
+/*
+ * SearchInputTrays()
+ *
+ * Given a tray, return the medium in the tray. Conversely, given a
+ * medium, return a tray in which it can be found. In either case,
+ * return NULL if the given tray or medium cannot be found.
+ */
+#define TRAY 0
+#define MEDIUM 1
+
+static char *
+SearchInputTrays(XpContextPtr pCon,
+ int which,
+ char *val)
+{
+ char *inputTraysMedium, tray[80], medium[80], *copy;
+ char *pS, *pE, *pLast;
+
+ inputTraysMedium = XpGetOneAttribute( pCon, XPPrinterAttr,
+ "input-trays-medium" );
+
+ copy = strdup( inputTraysMedium );
+ pS = copy;
+ pLast = copy + strlen( copy );
+
+ while( pS < pLast )
+ {
+ while( *pS && *pS != '{' )
+ pS++;
+
+ pE = ++pS;
+ while( *pE && *pE != '}' )
+ pE++;
+ *pE = '\0';
+
+ sscanf( pS, "%s %s", tray, medium );
+
+ if( which == MEDIUM && !strcmp( val, medium ) )
+ {
+ xfree( copy );
+ return strdup( tray );
+ }
+
+ if( which == TRAY && !strcmp( val, tray ) )
+ {
+ xfree( copy );
+ return strdup( medium );
+ }
+
+ pS = pE + 1;
+ }
+
+ xfree( copy );
+ return strdup( NULL_STRING );
+}
+
+/*
+ * XpGetTrayMediumFromContext()
+ *
+ * Given a print context, hit the input-trays-medium,
+ * default-input-tray and default-medium attributes to find the
+ * appropriate tray to use, and the medium in that tray.
+ */
+void
+XpGetTrayMediumFromContext(XpContextPtr pCon,
+ char **medium,
+ char **tray)
+{
+ char *defMedium, *defTray;
+ char *t, *m;
+ char *pS, *pE, *pLast;
+
+ defMedium = XpGetOneAttribute( pCon, XPPageAttr,
+ "default-medium" );
+ if( *defMedium == '\0' )
+ defMedium = XpGetOneAttribute( pCon, XPDocAttr,
+ "default-medium" );
+
+ defTray = XpGetOneAttribute( pCon, XPPageAttr,
+ "default-input-tray" );
+ if( *defTray == '\0' )
+ defTray = XpGetOneAttribute( pCon, XPDocAttr,
+ "default-input-tray" );
+
+ /*
+ * First, check to see if the default tray has the default medium
+ * installed. This is the ideal case.
+ */
+ m = SearchInputTrays( pCon, TRAY, defTray );
+ if( !strcmp( m, defMedium ) )
+ {
+ xfree( m );
+ *tray = strdup( defTray );
+ *medium = strdup( defMedium );
+ return;
+ }
+
+ /*
+ * If the default tray doesn't have the default medium, search for
+ * a tray which has the default medium.
+ */
+ t = SearchInputTrays( pCon, MEDIUM, defMedium );
+ if( t )
+ {
+ *tray = t;
+ *medium = strdup( defMedium );
+ return;
+ }
+
+ /*
+ * If all else fails, just return the default tray, and whatever
+ * medium happens to be there. Note that we simply return
+ * whatever is in the attribute store. Any further correction is
+ * left up to the DDX driver.
+ */
+ *tray = strdup( defTray );
+ *medium = m;
+ xfree( t );
+}
diff --git a/nx-X11/programs/Xserver/Xprint/attributes.h b/nx-X11/programs/Xserver/Xprint/attributes.h
new file mode 100644
index 000000000..40df4fd0b
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/attributes.h
@@ -0,0 +1,131 @@
+/* $Xorg: attributes.h,v 1.4 2001/03/14 18:42:44 pookie Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _Xp_attributes_h
+#define _Xp_attributes_h 1
+
+#include "scrnintstr.h"
+#include "AttrValid.h"
+
+#define BFuncArgs int ndx, ScreenPtr pScreen, int argc, char **argv
+typedef Bool (*pBFunc)(BFuncArgs);
+
+#define VFuncArgs char *name, XpValidatePoolsRec *pValRec, float *width, float *height, int *res
+typedef void (*pVFunc)(VFuncArgs);
+
+/*
+ * attributes.c
+ */
+void XpInitAttributes(XpContextPtr pContext);
+void XpBuildAttributeStore(char *printerName,
+ char *qualifierName);
+void XpAddPrinterAttribute(char *printerName,
+ char *printerQualifier,
+ char *attributeName,
+ char *attributeValue);
+void XpDestroyAttributes(XpContextPtr pContext);
+char *XpGetConfigDir(Bool useLocale);
+char *XpGetOneAttribute(XpContextPtr pContext,
+ XPAttributes class,
+ char *attributeName);
+void XpPutOneAttribute(XpContextPtr pContext,
+ XPAttributes class,
+ const char* attributeName,
+ const char* value);
+int XpRehashAttributes(void);
+char *XpGetAttributes(XpContextPtr pContext,
+ XPAttributes class);
+int XpAugmentAttributes(XpContextPtr pContext,
+ XPAttributes class,
+ char *attributes);
+int XpSetAttributes(XpContextPtr pContext,
+ XPAttributes class,
+ char *attributes);
+const char *XpGetPrinterAttribute(const char *printerName,
+ const char *attribute);
+void XpGetTrayMediumFromContext(XpContextPtr pCon,
+ char **medium,
+ char **tray);
+int XpSubmitJob(char *fileName, XpContextPtr pContext);
+
+/*
+ * mediaSizes.c
+ */
+int XpGetResolution(XpContextPtr pContext);
+XpOid XpGetContentOrientation(XpContextPtr pContext);
+XpOid XpGetAvailableCompression(XpContextPtr pContext);
+XpOid XpGetPlex(XpContextPtr pContext);
+XpOid XpGetPageSize(XpContextPtr pContext,
+ XpOid* pTray,
+ const XpOidMediumSS* msss);
+void XpGetMediumMillimeters(XpOid page_size,
+ float *width,
+ float *height);
+void XpGetMediumDimensions(XpContextPtr pContext,
+ unsigned short *width,
+ unsigned short *height);
+void XpGetReproductionArea(XpContextPtr pContext,
+ xRectangle *pRect);
+void XpGetMaxWidthHeightRes(const char *printer_name,
+ const XpValidatePoolsRec* vpr,
+ float *width,
+ float *height,
+ int* resolution);
+
+/* Util.c */
+char *ReplaceAnyString(char *string,
+ char *target,
+ char *replacement);
+char *ReplaceFileString(char *string,
+ char *inFileName,
+ char *outFileName);
+int TransferBytes(FILE *pSrcFile,
+ FILE *pDstFile,
+ int numBytes);
+Bool CopyContentsAndDelete(FILE **ppSrcFile,
+ char **pSrcFileName,
+ FILE *pDstFile);
+int XpSendDocumentData(ClientPtr client,
+ FILE *fp,
+ int fileLen,
+ int maxBufSize);
+int XpFinishDocData(ClientPtr client);
+Bool XpOpenTmpFile(char *mode,
+ char **fname,
+ FILE **stream);
+
+#endif /* _Xp_attributes_h */
diff --git a/nx-X11/programs/Xserver/Xprint/ddxInit.c b/nx-X11/programs/Xserver/Xprint/ddxInit.c
new file mode 100644
index 000000000..be16a3799
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ddxInit.c
@@ -0,0 +1,397 @@
+/* $Xorg: ddxInit.c,v 1.3 2000/08/17 19:48:07 cpqbld Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xos.h>
+#include <X11/Xproto.h>
+#include "windowstr.h"
+#include "servermd.h"
+#include "DiPrint.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * InitOutput --
+ * If this is built as a print-only server, then we must supply
+ * an InitOutput routine. If a normal server's real ddx InitOutput
+ * is used, then it should call PrinterInitOutput if it so desires.
+ * The ddx-level hook is needed to allow the printer stuff to
+ * create additional screens. An extension can't reliably do
+ * this for two reasons:
+ *
+ * 1) If InitOutput doesn't create any screens, then main()
+ * exits before calling InitExtensions().
+ *
+ * 2) Other extensions may rely on knowing about all screens
+ * when they initialize, and we can't guarantee the order
+ * of extension initialization.
+ *
+ * Results:
+ * ScreenInfo filled in, and PrinterInitOutput is called to create
+ * the screens associated with printers.
+ *
+ * Side Effects:
+ * None
+ *
+ *-----------------------------------------------------------------------
+ */
+
+void
+InitOutput(
+ ScreenInfo *pScreenInfo,
+ int argc,
+ char **argv)
+
+{
+ int i;
+
+ pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+ pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+
+ pScreenInfo->numPixmapFormats = 0; /* get them in PrinterInitOutput */
+ screenInfo.numVideoScreens = 0;
+}
+
+static void
+BellProc(
+ int volume,
+ DeviceIntPtr pDev)
+{
+ return;
+}
+
+static void
+KeyControlProc(
+ DeviceIntPtr pDev,
+ KeybdCtrl *ctrl)
+{
+ return;
+}
+
+static KeySym printKeyMap[256];
+static CARD8 printModMap[256];
+
+static int
+KeyboardProc(
+ DevicePtr pKbd,
+ int what,
+ int argc,
+ char *argv[])
+{
+ KeySymsRec keySyms;
+
+ keySyms.minKeyCode = 8;
+ keySyms.maxKeyCode = 8;
+ keySyms.mapWidth = 1;
+ keySyms.map = printKeyMap;
+
+ switch(what)
+ {
+ case DEVICE_INIT:
+ InitKeyboardDeviceStruct(pKbd, &keySyms, printModMap,
+ (BellProcPtr)BellProc,
+ KeyControlProc);
+ break;
+ case DEVICE_ON:
+ break;
+ case DEVICE_OFF:
+ break;
+ case DEVICE_CLOSE:
+ break;
+ }
+ return Success;
+}
+
+#include "../mi/mipointer.h"
+static int
+PointerProc(
+ DevicePtr pPtr,
+ int what,
+ int argc,
+ char *argv[])
+{
+#define NUM_BUTTONS 1
+ CARD8 map[NUM_BUTTONS];
+
+ switch(what)
+ {
+ case DEVICE_INIT:
+ {
+ map[0] = 0;
+ InitPointerDeviceStruct(pPtr, map, NUM_BUTTONS,
+ miPointerGetMotionEvents,
+ (PtrCtrlProcPtr)_XpVoidNoop,
+ miPointerGetMotionBufferSize());
+ break;
+ }
+ case DEVICE_ON:
+ break;
+ case DEVICE_OFF:
+ break;
+ case DEVICE_CLOSE:
+ break;
+ }
+ return Success;
+}
+
+void
+InitInput(
+ int argc,
+ char **argv)
+{
+ DevicePtr ptr, kbd;
+
+ ptr = AddInputDevice((DeviceProc)PointerProc, TRUE);
+ kbd = AddInputDevice((DeviceProc)KeyboardProc, TRUE);
+ RegisterPointerDevice(ptr);
+ RegisterKeyboardDevice(kbd);
+ return;
+}
+
+
+Bool
+LegalModifier(
+ unsigned int key,
+ DevicePtr dev)
+{
+ return TRUE;
+}
+
+void
+ProcessInputEvents(void)
+{
+}
+
+#ifdef __DARWIN__
+#include "micmap.h"
+
+void GlxExtensionInit(void);
+void GlxWrapInitVisuals(miInitVisualsProcPtr *procPtr);
+
+void
+DarwinHandleGUI(int argc, char *argv[])
+{
+}
+
+void DarwinGlxExtensionInit(void)
+{
+ GlxExtensionInit();
+}
+
+void DarwinGlxWrapInitVisuals(
+ miInitVisualsProcPtr *procPtr)
+{
+ GlxWrapInitVisuals(procPtr);
+}
+#endif
+
+#ifdef DDXOSINIT
+void
+OsVendorInit(void)
+{
+}
+#endif
+
+#ifdef DDXOSFATALERROR
+void
+OsVendorFatalError(void)
+{
+}
+#endif
+
+void
+ddxBeforeReset(void)
+{
+ return;
+}
+
+#ifdef DDXTIME
+CARD32
+GetTimeInMillis(void)
+{
+ struct timeval tp;
+
+ X_GETTIMEOFDAY(&tp);
+ return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);
+}
+#endif
+
+/* ddxInitGlobals - called by |InitGlobals| from os/util.c */
+void ddxInitGlobals(void)
+{
+ PrinterInitGlobals();
+}
+
+/****************************************
+* ddxUseMsg()
+*
+* Called my usemsg from os/utils/c
+*
+*****************************************/
+
+void ddxUseMsg(void)
+{
+}
+
+void AbortDDX (void)
+{
+}
+
+void ddxGiveUp(void) /* Called by GiveUp() */
+{
+}
+
+int
+ddxProcessArgument (
+ int argc,
+ char *argv[],
+ int i)
+{
+ return(0);
+}
+
+#ifdef XINPUT
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h"
+
+extern int BadDevice;
+
+int
+ChangePointerDevice (
+ DeviceIntPtr old_dev,
+ DeviceIntPtr new_dev,
+ unsigned char x,
+ unsigned char y)
+{
+ return (BadDevice);
+}
+
+int
+ChangeDeviceControl (
+ register ClientPtr client,
+ DeviceIntPtr dev,
+ xDeviceCtl *control)
+{
+ return BadMatch;
+}
+
+void
+OpenInputDevice (
+ DeviceIntPtr dev,
+ ClientPtr client,
+ int *status)
+{
+ return;
+}
+
+void
+AddOtherInputDevices (void)
+{
+ return;
+}
+
+void
+CloseInputDevice (
+ DeviceIntPtr dev,
+ ClientPtr client)
+{
+ return;
+}
+
+int
+ChangeKeyboardDevice (
+ DeviceIntPtr old_dev,
+ DeviceIntPtr new_dev)
+{
+ return (Success);
+}
+
+int
+SetDeviceMode (
+ register ClientPtr client,
+ DeviceIntPtr dev,
+ int mode)
+{
+ return BadMatch;
+}
+
+int
+SetDeviceValuators (
+ register ClientPtr client,
+ DeviceIntPtr dev,
+ int *valuators,
+ int first_valuator,
+ int num_valuators)
+{
+ return BadMatch;
+}
+
+
+#endif /* XINPUT */
+
+#ifdef XTESTEXT1
+
+void
+XTestJumpPointer(int x, int y, int dev)
+{
+ return;
+}
+
+void
+XTestGetPointerPos(int x, int y)
+{
+ return;
+}
+
+void
+XTestGenerateEvent(int dev, int keycode, int keystate, int x, int y)
+{
+ return;
+}
+
+#endif /* XTESTEXT1 */
+
+#ifdef AIXV3
+/*
+ * This is just to get the server to link on AIX, where some bits
+ * that should be in os/ are instead in hw/ibm.
+ */
+int SelectWaitTime = 10000; /* usec */
+#endif
diff --git a/nx-X11/programs/Xserver/Xprint/etc/Imakefile b/nx-X11/programs/Xserver/Xprint/etc/Imakefile
new file mode 100644
index 000000000..6a6e02a29
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/etc/Imakefile
@@ -0,0 +1,24 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/10/31 14:42:52 gisburn Exp $
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+XCOMM Check if OS has /etc/profile.d/
+XCOMM Note that Debian Linux does not have /etc/profile.d/
+#ifndef HasEtcProfileDir
+# ifdef LinuxArchitecture
+# if (LinuxDistribution != LinuxDebian) || BuildFullXprintDistrib
+# define HasEtcProfileDir YES
+# endif
+# else
+# define HasEtcProfileDir NO
+# endif
+#endif
+
+#if HasEtcProfileDir
+SUBDIRS = init.d profile.d Xsession.d
+#else
+SUBDIRS = init.d Xsession.d
+#endif
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
diff --git a/nx-X11/programs/Xserver/Xprint/etc/Xsession.d/Imakefile b/nx-X11/programs/Xserver/Xprint/etc/Xsession.d/Imakefile
new file mode 100644
index 000000000..55a07175e
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/etc/Xsession.d/Imakefile
@@ -0,0 +1,24 @@
+XCOMM $Xorg: Imakefile,v 1.1 2003/01/25 14:42:52 gisburn Exp $
+
+#if NothingOutsideProjectRoot
+#define EtcDir ProjectRoot/etc
+#else
+#define EtcDir /etc
+#endif
+
+ETCDIR = EtcDir
+
+all::
+
+XCOMM Install glue for Xprint on Solaris/CDE1.x and CDE on AIX
+#if (defined(SunArchitecture) && (OSMajorVersion > 4)) || defined(IBMArchitecture)
+InstallNamedProg(cde_xsessiond_xprint.sh,0018.xprint,/usr/dt/config/Xsession.d)
+#endif
+
+XCOMM Install xdm startup glue for Xprint on Linux. Note that not all Linux
+XCOMM platforms have /etc/X11/Xsession.d/ and/or /etc/X11/xinit/xinitrc.d
+XCOMM (see http://xprint.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=182)
+#if defined(LinuxDistribution)
+InstallNamedProg(cde_xsessiond_xprint.sh,92xprint-xpserverlist.sh,$(ETCDIR)/X11/Xsession.d)
+InstallNamedProg(cde_xsessiond_xprint.sh,92xprint-xpserverlist.sh,$(ETCDIR)/X11/xinit/xinitrc.d)
+#endif
diff --git a/nx-X11/programs/Xserver/Xprint/etc/Xsession.d/cde_xsessiond_xprint.sh b/nx-X11/programs/Xserver/Xprint/etc/Xsession.d/cde_xsessiond_xprint.sh
new file mode 100644
index 000000000..3fb6bba7c
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/etc/Xsession.d/cde_xsessiond_xprint.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+#####################################################################
+### File: 0018.xprint
+###
+### Default Location: /usr/dt/config/Xsession.d/
+###
+### Purpose: Setup Xprint env vars
+###
+### Description: This script is invoked by means of the Xsession file
+### at user login.
+###
+### Invoked by: /usr/dt/bin/Xsession
+###
+### (c) Copyright 2003-2004 Roland Mainz <roland.mainz@nrubsig.org>
+###
+### please send bugfixes or comments to http://xprint.mozdev.org/
+###
+#####################################################################
+
+
+#
+# Obtain list of Xprint servers
+#
+
+if [ -f "/etc/init.d/xprint" ] ; then
+ XPSERVERLIST="`/bin/sh /etc/init.d/xprint get_xpserverlist`"
+ export XPSERVERLIST
+fi
+
+########################## eof #####################
diff --git a/nx-X11/programs/Xserver/Xprint/etc/init.d/Imakefile b/nx-X11/programs/Xserver/Xprint/etc/init.d/Imakefile
new file mode 100644
index 000000000..dedefb199
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/etc/init.d/Imakefile
@@ -0,0 +1,97 @@
+XCOMM $Xorg: Imakefile,v 1.2 2003/01/20 17:02:01 gisburn Exp $
+
+all:: xprint
+
+#if BuildGISWxprintglue
+XPCUSTOMGLUE=GISWxprintglue
+#elif BuildGISWxprint
+XPCUSTOMGLUE = GISWxprint
+#elif BuildDebianXprintPackage
+XPCUSTOMGLUE = DebianGlue
+#else
+XPCUSTOMGLUE = default
+#endif
+
+#if defined(SunArchitecture)
+OS_DEFINES = -DOS_SOLARIS
+#elif defined(LinuxArchitecture)
+OS_DEFINES = -DOS_LINUX
+#elif defined(AIXArchitecture)
+OS_DEFINES = -DOS_AIX
+#else
+OS_DEFINES =
+#endif
+
+#if NothingOutsideProjectRoot
+#define EtcDir ProjectRoot/etc
+#else
+#define EtcDir /etc
+#endif
+
+ETCDIR = EtcDir
+
+MakeScriptFromCpp(xprint, -DDEF_XPCUSTOMGLUE=$(XPCUSTOMGLUE) $(OS_DEFINES) -DProjectRoot=$(PROJECTROOT))
+
+#if defined(FreeBSDArchitecture)
+InstallNamedProg(xprint,xprint,$(PROJECTROOT)/etc/rc.d)
+#else
+XCOMM Solaris, Linux, etc.
+InstallNamedProg(xprint,xprint,$(ETCDIR)/init.d)
+#endif
+
+XCOMM Create startup/shutdown links in /etc/init.d/ for Solaris
+#if defined(SunArchitecture) && (OSMajorVersion > 4)
+
+#define InstallStartupLink(rcdir,script,linkname) \
+ MakeDir($(DESTDIR)$(ETCDIR)/rcdir) ; \
+ RemoveFile($(DESTDIR)$(ETCDIR)/rcdir/linkname) ; \
+ ln -s ../init.d/script $(DESTDIR)$(ETCDIR)/rcdir/linkname
+
+install::
+ InstallStartupLink(rc0.d,xprint,K38xprint)
+ InstallStartupLink(rc1.d,xprint,K38xprint)
+ InstallStartupLink(rc2.d,xprint,S81xprint)
+ InstallStartupLink(rcS.d,xprint,K38xprint)
+#endif /* defined(SunArchitecture) && (OSMajorVersion > 4) */
+
+XCOMM Create startup/shutdown links in /etc/init.d/ for Linux
+#if defined(LinuxDistribution)
+# if (LinuxDistribution == LinuxSuSE) || \
+ (LinuxDistribution == LinuxDebian) || \
+ (LinuxDistribution == LinuxUnknown)
+XCOMM SuSE Linux(-like)
+
+#define InstallStartupLink(rcdir,script,linkname) \
+ MakeDir($(DESTDIR)$(ETCDIR)/rc.d/rcdir) ; \
+ ln -sf ../script $(DESTDIR)$(ETCDIR)/rc.d/rcdir/linkname
+
+install::
+ echo "# Installing /etc/init.d links for SuSE Linux(-like)"
+ InstallStartupLink(rc2.d,xprint,K21xprint)
+ InstallStartupLink(rc2.d,xprint,S21xprint)
+ InstallStartupLink(rc3.d,xprint,K21xprint)
+ InstallStartupLink(rc3.d,xprint,S21xprint)
+ InstallStartupLink(rc5.d,xprint,K21xprint)
+ InstallStartupLink(rc5.d,xprint,S21xprint)
+# elif LinuxDistribution == LinuxRedHat
+XCOMM RedHat Linux(-like)
+
+#define InstallStartupLink(rcdir,script,linkname) \
+ MakeDir($(DESTDIR)$(ETCDIR)/rcdir) ; \
+ ln -sf ../init.d/script $(DESTDIR)$(ETCDIR)/rcdir/linkname
+
+install::
+ echo "# Installing /etc/init.d links for RedHat Linux(-like)"
+ InstallStartupLink(rc0.d,xprint,K61xprint)
+ InstallStartupLink(rc1.d,xprint,K61xprint)
+ InstallStartupLink(rc2.d,xprint,S61xprint)
+ InstallStartupLink(rc3.d,xprint,S61xprint)
+ InstallStartupLink(rc4.d,xprint,S61xprint)
+ InstallStartupLink(rc5.d,xprint,S61xprint)
+ InstallStartupLink(rc6.d,xprint,K61xprint)
+# else
+install::
+ echo "WARNING: No links for /etc/init.d/xprint set."
+# endif /* LinuxDistribution == * */
+#endif /* defined(LinuxArchitecture) */
+
diff --git a/nx-X11/programs/Xserver/Xprint/etc/init.d/xprint.cpp b/nx-X11/programs/Xserver/Xprint/etc/init.d/xprint.cpp
new file mode 100644
index 000000000..dbfd1e139
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/etc/init.d/xprint.cpp
@@ -0,0 +1,1277 @@
+XCOMM!/bin/sh
+XCOMM
+XCOMM Copyright 2002-2004 by Roland Mainz <roland.mainz@nrubsig.org>.
+XCOMM
+XCOMM This script manages the Xprint server side
+
+XCOMM Basic support for IRIX-style "chkconfig"
+XCOMM chkconfig: 2345 61 61
+XCOMM description: Startup/shutdown script for Xprint server(s)
+
+XCOMM Basic support for the Linux Standard Base Specification 1.0.0
+XCOMM (Note: The Should-Start/Stop lines are there so that this works in the
+XCOMM future, when the LSB adopts these. The X-UnitedLinux lines are there
+XCOMM so that it works right now.)
+XCOMM## BEGIN INIT INFO
+XCOMM Provides: xprint
+XCOMM Required-Start: $local_fs $remote_fs $syslog $network
+XCOMM Required-Stop: $local_fs $remote_fs $syslog
+XCOMM Should-Start: cups lpd xfs
+XCOMM Should-Stop: cups lpd xfs
+XCOMM X-UnitedLinux-Should-Start: cups lpd xfs
+XCOMM X-UnitedLinux-Should-Stop: cups lpd xfs
+XCOMM Default-Start: 3 5
+XCOMM Default-Stop: 0 1 2 6
+XCOMM Description: Startup/shutdown script for Xprint server(s)
+XCOMM## END INIT INFO
+
+#undef sun
+#undef unix
+
+XCOMM###########################################################################
+XCOMM
+XCOMM This script has three main tasks:
+XCOMM 1. Start Xprint servers ("Xprt") at boot time.
+XCOMM 2. Shutdown Xprint servers when the machine is being shut down.
+XCOMM 3. Query the list of available printers.
+XCOMM
+XCOMM Additional tasks are:
+XCOMM 4. Restart ('restart'|'force-reload') and conditional restart
+XCOMM ('condrestart'/'try-restart') for Linux support
+XCOMM 5. Wrapping of application call with setting XPSERVERLIST ('wrapper')
+XCOMM
+XCOMM Usage:
+XCOMM - Start Xprint server(s) manually:
+XCOMM % /etc/init.d/xprint start
+XCOMM
+XCOMM - Stop Xprint server(s) manually:
+XCOMM % /etc/init.d/xprint stop
+XCOMM
+XCOMM - Populate $XPSERVERLIST env var (for example as part of a global
+XCOMM login script like /etc/profile or per-user login scripts like
+XCOMM $HOME/.profile (sh/ksh/bash))
+XCOMM % XPSERVERLIST="`/etc/init.d/xprint get_xpserverlist`"
+XCOMM % export XPSERVERLIST
+XCOMM
+XCOMM Installation:
+XCOMM Copy this script to /etc/init.d/xprint and make sure that it is
+XCOMM executable. If your installation is LSB-compliant, then run
+XCOMM % /usr/lib/lsb/install_initd /etc/init.d/xprint
+XCOMM to start the service on startup. Otherwise, manually create links
+XCOMM to the matching run levels.
+XCOMM Examples:
+XCOMM - Solaris 2.7/2.8/2.9:
+XCOMM % cp xprint /etc/init.d/xprint
+XCOMM % chmod a+rx /etc/init.d/xprint
+XCOMM % ln /etc/init.d/xprint /etc/rc0.d/K38xprint
+XCOMM % ln /etc/init.d/xprint /etc/rc1.d/K38xprint
+XCOMM % ln /etc/init.d/xprint /etc/rc2.d/S81xprint
+XCOMM % ln /etc/init.d/xprint /etc/rcS.d/K38xprint
+XCOMM
+XCOMM - SuSE Linux 7.3
+XCOMM % cp xprint /etc/init.d/xprint
+XCOMM % chmod a+rx /etc/init.d/xprint
+XCOMM % ln -s ../xprint /etc/init.d/rc3.d/K13xprint
+XCOMM % ln -s ../xprint /etc/init.d/rc3.d/S12xprint
+XCOMM % ln -s ../xprint /etc/init.d/rc5.d/K13xprint
+XCOMM % ln -s ../xprint /etc/init.d/rc5.d/S12xprint
+XCOMM % ln -s ../xprint /etc/init.d/rc2.d/K13xprint
+XCOMM % ln -s ../xprint /etc/init.d/rc2.d/S12xprint
+XCOMM
+XCOMM - SuSE Linux 6.4:
+XCOMM % cp xprint /sbin/init.d/xprint
+XCOMM % chmod a+rx /sbin/init.d/xprint
+XCOMM % ln -s ../xprint /sbin/init.d/rc2.d/K20xprint
+XCOMM % ln -s ../xprint /sbin/init.d/rc2.d/S20xprint
+XCOMM % ln -s ../xprint /sbin/init.d/rc3.d/K20xprint
+XCOMM % ln -s ../xprint /sbin/init.d/rc3.d/S20xprint
+XCOMM
+XCOMM Notes:
+XCOMM - The Xprint servers must be started _after_ the print
+XCOMM spooler or the server(s) may refuse to start
+XCOMM - The script should be readable by all users to ensure that they
+XCOMM can use the "get_xpserverlist"-option
+XCOMM
+XCOMM Custom configuration:
+XCOMM - Edit the function setup_config() in this script to match your needs
+XCOMM
+XCOMM Known bugs/ToDo/Notes:
+XCOMM - The shell script assumes that a Xserver can be reached via
+XCOMM "hostname:displaynum" where "hostname" is obtained from
+XCOMM "/usr/bin/hostname". It may happen that a kernel firewall
+XCOMM blocks an X connection on the same host (e.g. client && Xserver
+XCOMM are running on the same host).
+XCOMM Suggested fix: Fix the firewall config.
+XCOMM Suggested workaround: Edit this script and replace the use of
+XCOMM /usr/bin/hostname with "echo 'localhost'".
+XCOMM
+XCOMM###########################################################################
+XCOMM
+
+
+XCOMM###########################################################################
+
+fatal_error()
+{
+ echo "${0}: ## FATAL ERROR: ${1}" 1>&2
+ exit 1
+}
+
+error_echo()
+{
+ echo "${0}: ## ERROR: ${1}" 1>&2
+}
+
+warning_echo()
+{
+ echo "${0}: ## WARNING: ${1}" 1>&2
+}
+
+verbose_echo()
+{
+ echo "${0}: ${1}"
+}
+
+msg()
+{
+ echo "${1}"
+}
+
+XCOMM###########################################################################
+
+#ifndef OS_LINUX
+XCOMM Force use of a POSIX conformant sh
+XCOMM (Solaris /sbin/sh is plain Bourne shell)
+[ "$1" != "posix_sh_forced" -a -x /bin/ksh ] && exec /bin/ksh "$0" posix_sh_forced "$@"
+[ "$1" != "posix_sh_forced" -a -x /bin/bash ] && exec /bin/bash --norc --noprofile "$0" posix_sh_forced "$@"
+[ "$1" != "posix_sh_forced" -a -x /usr/local/bin/ksh ] && exec /usr/local/bin/ksh "$0" posix_sh_forced "$@"
+[ "$1" != "posix_sh_forced" -a -x /usr/local/bin/bash ] && exec /usr/local/bin/bash --norc --noprofile "$0" posix_sh_forced "$@"
+if [ "$1" != "posix_sh_forced" ] ; then
+ echo "${0}: ## FATAL ERROR: No POSIX-shell found." 1>&2
+ exit 1
+fi
+
+shift # Drop "posix_sh_forced"
+#endif /* !OS_LINUX */
+
+XCOMM#debug
+XCOMM set -x
+
+XCOMM Change current dir to a location which is writeable by everyone
+cd /tmp
+
+XCOMM Clear some environment variables
+unset TEMP TMPDIR SCREENDIR
+
+XCOMM Set search path for commands
+export PATH=/usr/bin:/bin:/usr/sbin:/sbin
+#ifdef OS_SOLARIS
+export PATH=/usr/xpg4/bin:${PATH}
+#endif
+
+XCOMM# Try to figure-out where X11 was installed
+#if defined(OS_SOLARIS)
+XPROJECTROOT=/usr/openwin
+export OPENWINHOME=/usr/openwin
+#elif defined(OS_AIX)
+XPROJECTROOT=/usr/lpp/X11
+#else
+#if defined(ProjectRoot)
+[ -d ProjectRoot/bin ] && XPROJECTROOT=ProjectRoot
+#endif
+[ -d /usr/X11/bin ] && XPROJECTROOT=/usr/X11
+[ -d /usr/X11R6/bin ] && XPROJECTROOT=/usr/X11R6
+#endif
+XPCUSTOMGLUE=DEF_XPCUSTOMGLUE # This is used for customizing this script
+export XPROJECTROOT XPCUSTOMGLUE
+
+if [ -z "${XPROJECTROOT}" ] ; then
+ fatal_error "Unknown XProjectRoot."
+fi
+
+XCOMM Set the location of the Xprt binary we want to use.
+XPRT_BIN="${XPROJECTROOT}/bin/Xprt"
+
+XCOMM Set the location of the global file where we store the locations
+XCOMM of the system-wide servers
+if [ -d /var/run ] ; then
+ XP_GLOBAL_SERVERS=/var/run/Xprint_servers
+else
+ XP_GLOBAL_SERVERS=/tmp/.Xprint_servers
+fi
+
+XCOMM ${LOGNAME} will not work if user su'ed into another account
+export CURRLOGNAME="$(id -u -n)"
+
+XCOMM Set location where we want to store the list of Xprint servers managed
+XCOMM by this user
+XCOMM - If we start as "root" use the global file
+XCOMM - If we start as normal user use a per-user file
+
+if [ "${CURRLOGNAME}" != "root" -a "${CURRLOGNAME}" != "" ] ; then
+ XP_PER_USER_SERVERS="/tmp/.Xprint_servers_${CURRLOGNAME}"
+ XP_SERVERS="${XP_PER_USER_SERVERS}"
+else
+ XP_SERVERS="${XP_GLOBAL_SERVERS}"
+fi
+
+XCOMM Set umask that owner can r/w all files and everyone else can read them
+umask 022
+
+XCOMM Bump limit for per-process open files to ensure that Xprt can open many many fonts
+ulimit -n 1024
+
+XCOMM###########################################################################
+
+XCOMM Get list of fonts for a given display
+get_fontlist_from_display()
+{
+ ${XPROJECTROOT}/bin/xset -display "${1}" q |
+ awk "/Font Path:/ { i=1 ; next } i==1 { print \$0 ; i=0 }" |
+ fontpath2fontlist
+}
+
+XCOMM Get list from a fontserver config
+get_fontlist_from_xfs_config()
+{
+ if [ ! -r "${1}" ] ; then
+ return 0
+ fi
+
+ (
+ cat "${1}" |
+ while read -r i ; do
+ for val in $i; do
+ case $val in
+ \#*) break ;;
+ ?*=*) key="${val%%=*}" ;;
+ =*) key="${tok}" ;;
+ *) [ "${key}" = "catalogue" -a "${tok}" != "" ] && echo "${tok}" ;;
+ esac
+ tok="${val#*=}"
+ done
+ done
+ ) | tr "," "\n" | fontpath2fontlist
+}
+
+get_fontlist_from_all_xfs_configs()
+{
+ get_fontlist_from_xfs_config "/etc/openwin/fs/fontserver.cfg"
+ get_fontlist_from_xfs_config "/usr/openwin/lib/X11/fontserver.cfg"
+ get_fontlist_from_xfs_config "/etc/X11/fs-xtt/config"
+ get_fontlist_from_xfs_config "/etc/X11/fs/config"
+ get_fontlist_from_xfs_config "/etc/X11/xfs/config"
+ get_fontlist_from_xfs_config "${XPROJECTROOT}/lib/X11/fs/config"
+}
+
+get_fontlist_from_xf86config()
+{
+ srcxconf=""
+
+ XCOMM see xorg.conf(5x) manual page for the list of locations used here
+ [ "${srcxconf}" = "" -a -f "/etc/X11/xorg.conf" ] && srcxconf="/etc/X11/xorg.conf"
+ [ "${srcxconf}" = "" -a -f "/usr/X11R6/etc/X11/xorg.conf" ] && srcxconf="/usr/X11R6/etc/X11/xorg.conf"
+ [ "${srcxconf}" = "" -a -f "/etc/X11/xorg.conf-4" ] && srcxconf="/etc/X11/xorg.conf-4"
+ [ "${srcxconf}" = "" -a -f "/etc/X11/xorg.conf" ] && srcxconf="/etc/X11/xorg.conf"
+ [ "${srcxconf}" = "" -a -f "/etc/xorg.conf" ] && srcxconf="/etc/xorg.conf"
+ [ "${srcxconf}" = "" -a -f "/usr/X11R6/etc/X11/xorg.conf.${hostname}" ] && srcxconf="/usr/X11R6/etc/X11/xorg.conf.${hostname}"
+ [ "${srcxconf}" = "" -a -f "/usr/X11R6/etc/X11/xorg.conf-4" ] && srcxconf="/usr/X11R6/etc/X11/xorg.conf-4"
+ [ "${srcxconf}" = "" -a -f "/usr/X11R6/etc/X11/xorg.conf" ] && srcxconf="/usr/X11R6/etc/X11/xorg.conf"
+ [ "${srcxconf}" = "" -a -f "/usr/X11R6/lib/X11/xorg.conf.${hostname}" ] && srcxconf="/usr/X11R6/lib/X11/xorg.conf.${hostname}"
+ [ "${srcxconf}" = "" -a -f "/usr/X11R6/lib/X11/xorg.conf-4" ] && srcxconf="/usr/X11R6/lib/X11/xorg.conf-4"
+ [ "${srcxconf}" = "" -a -f "/usr/X11R6/lib/X11/xorg.conf" ] && srcxconf="/usr/X11R6/lib/X11/xorg.conf"
+
+ XCOMM Xfree86 locations
+ [ "${srcxconf}" = "" -a -f "/etc/X11/XF86Config-4" ] && srcxconf="/etc/X11/XF86Config-4"
+ [ "${srcxconf}" = "" -a -f "/etc/X11/XF86Config" ] && srcxconf="/etc/X11/XF86Config"
+
+
+ if [ "${srcxconf}" = "" ] ; then
+ return 0
+ fi
+
+ currsection=""
+ cat "${srcxconf}" |
+ while read i1 i2 i3 i4 ; do
+ # Strip "\"" from I2
+ i2="${i2#\"}" ; i2="${i2%\"}"
+
+ case "${i1}" in
+ \#*)
+ continue
+ ;;
+ 'Section')
+ currsection="${i2}"
+ ;;
+ 'EndSection')
+ currsection=""
+ ;;
+ 'FontPath')
+ [ "$currsection" = "Files" ] && echo "${i2%:unscaled}"
+ ;;
+ esac
+ done | egrep -v -i "tcp/|tcp4/|tcp6/|unix/"
+
+ return 0
+}
+
+get_fontlist_from_defoma()
+{
+ # Include Debian defoma font directory where relevant
+ if [ -d "/var/lib/defoma/x-ttcidfont-conf.d/dirs" ] ; then
+ find "/var/lib/defoma/x-ttcidfont-conf.d/dirs" -name fonts.dir |
+ while read i ; do echo "${i%/fonts.dir}" ; done
+ fi
+}
+
+XCOMM Get list of system fonts
+get_system_fontlist()
+{
+#if defined(OS_SOLARIS)
+ ## List the standard X11 fonts
+ # echo "${XPROJECTROOT}/lib/X11/fonts/F3/"
+ # echo "${XPROJECTROOT}/lib/X11/fonts/F3bitmaps/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/Type1/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/Type1/outline/"
+ # We cannot use /usr/openwin/lib/X11/fonts/Type1/sun/ - see
+ # http://xprint.mozdev.org/bugs/show_bug.cgi?id=5726
+ # ("Xprint doesn't start under Solaris 2.9 due *.ps files in /usr/openwin/lib/X11/fonts/Type1/sun/fonts.dir")
+ #echo "${XPROJECTROOT}/lib/X11/fonts/Type1/sun/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/TrueType/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/Speedo/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/misc/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/75dpi/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/100dpi/"
+
+ ## List all fonts in all locales installed on this machine
+ cat /usr/openwin/lib/locale/''*/OWfontpath | tr "," "\n" | sort -u
+#elif defined(OS_LINUX)
+ (
+ get_fontlist_from_defoma
+
+ get_fontlist_from_xf86config
+
+ # Getting font paths from XFS is mainly required for compatibilty to RedHat
+ get_fontlist_from_all_xfs_configs
+
+ ## List all fonts in all locales installed on this machine
+ (
+ [ -d "/usr/share/fonts" ] && find /usr/share/fonts -name fonts.dir
+ find "${XPROJECTROOT}/lib/X11/fonts" -name fonts.dir
+ ) |
+ while read i ; do echo "${i%/fonts.dir}" ; done
+ ) | sort -u
+#else
+ ## List the standard X11 fonts
+ # (AIX should be handled like Solaris but I did not found a way to
+ # enumerate all fonts in all installed locales without scanning the
+ # dirs manually)
+ echo "${XPROJECTROOT}/lib/X11/fonts/Type1/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/TrueType/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/TTF/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/Speedo/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/misc/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/75dpi/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/100dpi/"
+ echo "${XPROJECTROOT}/lib/X11/fonts/"
+#endif
+}
+
+XCOMM Filter fonts per given extended regular expressions
+XCOMM (and make sure we filter any model-config fonts - they are managed by Xprt internally)
+filter_fontlist()
+{
+ egrep -- "${1}" | fgrep -v "/models/" | egrep -v -- "${2}"
+}
+
+XCOMM Filter font paths with unsupported font types
+XCOMM (such as CID fonts)
+filter_unsupported_fonts()
+{
+ egrep -v -i "/cid(/$|$)|/csl(/$|$)"
+}
+
+XCOMM Validate fontpath
+XCOMM Only return valid font path entries (note that these entries may
+XCOMM include non-file stuff like font server references)
+validate_fontlist()
+{
+ while read i ; do
+ case "${i}" in
+ # Check if font path entry is a font server...
+ tcp/''*|tcp4/''*|tcp6/''*|unix/''*)
+ echo "${i}"
+ ;;
+ # ... if not check if the path is accessible
+ # and has a valid "fonts.dir" index
+ *)
+ [ -f "${i}/fonts.dir" ] && echo "${i}"
+ ;;
+ esac
+ done
+}
+
+XCOMM Build a comma-seperated list of fonts (font path) from a list of fonts
+fontlist2fontpath()
+{
+ fp=""
+ read fp;
+ while read i ; do
+ fp="${fp},${i}"
+ done
+
+ echo "$fp"
+}
+
+XCOMM Build a list (one item per line) of fonts from a font path
+fontpath2fontlist()
+{
+ while read i ; do
+ echo "${i}" | tr "," "\n"
+ done
+}
+
+XCOMM Sort scaleable fonts (PS Type1 and TrueType) first in a font list
+sort_scaleable_fonts_first()
+{
+ i="$(fontlist2fontpath)"
+ # First list PS Type1 fonts...
+ echo "${i}" | fontpath2fontlist | fgrep "/Type1"
+ # ... then TrueType fonts ...
+ echo "${i}" | fontpath2fontlist | egrep -i "/TrueType|/TT(/$|$)|/TTF(/$|$)"
+ # ... then all others
+ echo "${i}" | fontpath2fontlist | egrep -v -i "/Type1|/TrueType|/TT(/$|$)|/TTF(/$|$)"
+}
+
+XCOMM Check if a X display is used by a Xserver or not
+XCOMM Known bugs:
+XCOMM - there is no way in plain bourne shell or bash (see comment about ksh93
+XCOMM below) to test if a Xserver sits only on a socket and not on a pipe
+XCOMM - some Xserver's don't cleanup their stuff in /tmp on exit which may end
+XCOMM in the problem that we don't detect possible free display numbers
+XCOMM (one problem is that only ksh93 can do stuff like
+XCOMM "cat </dev/tcp/0.0.0.0/6001")
+CheckIfDisplayIsInUse()
+{
+ id=$1
+
+ [ -r "/tmp/.X${id}-lock" ] && return 0;
+ [ -r "/tmp/.X11-unix/X${id}" ] && return 0;
+ [ -r "/tmp/.X11-pipe/X${id}" ] && return 0;
+
+ return 1;
+}
+
+lastdisplaynumreturned_store=/tmp/.Xp_last_display_returned_by_findfreexdisplaynum_${RANDOM}_${RANDOM}
+
+XCOMM Try to find a free display number
+FindFreeXDisplayNum()
+{
+ if [ -r "${lastdisplaynumreturned_store}" ] ; then
+ i="$(cat "${lastdisplaynumreturned_store}")"
+ else
+ i=32 # start at display 32
+ fi
+
+ while [ $i -lt 127 ] ; do
+ i=$(($i + 1))
+
+ if CheckIfDisplayIsInUse $i ; then
+ true
+ else
+ echo "$i"
+ echo "$i" >"${lastdisplaynumreturned_store}"
+ return 0
+ fi
+ done
+
+ # Using "magic" value of 189 here due lack of a better solution
+ echo "189"
+ echo "189" >"${lastdisplaynumreturned_store}"
+ return 0
+}
+
+XCOMM Check if a process exists or not
+pexists()
+{
+ [ "$1" = "" ] && return 1;
+
+ # Use of /proc would be better but not all platforms (like AIX) have procfs
+ [ "$(ps -p $1 | fgrep $1)" != "" ] && return 0;
+ return 1
+}
+
+XCOMM Check if there is a spooler running...
+is_spooler_running()
+{
+ # This covers Linux lpd, CUPS, Solaris and AIX 4.x - but what about
+ # AIX 5.x, HP-UX and IRIX ?
+
+ [ "$(ps -A | egrep 'lpd|lpsched|cupsd|qdaemon' | fgrep -v 'grep')" != "" ] && return 0;
+ return 1
+}
+
+XCOMM Wait until the spooler system has been started (but not more than 30secs)
+wait_for_print_spooler()
+{
+ for i in 1 2 3 4 5 6 7 8 9 10 ; do
+ is_spooler_running && return 0;
+ sleep 3
+ done
+
+ return 0
+}
+
+lock_server_registry()
+{
+ lock_counter=0 # counts in 1/100s
+ waiting_for_lock_msg_send="false"
+ while ! mkdir "${XP_SERVERS}.lock" 2>/dev/null ; do
+ # print notice after 2 seconds
+ if [ ${lock_counter} -gt 200 -a "${waiting_for_lock_msg_send}" != "true" ] ; then
+ echo "${0}: waiting for lock(=${XP_SERVERS}.lock)..."
+ waiting_for_lock_msg_send="true"
+ fi
+
+ # tread the lock as "broken" after 20 seconds
+ if [ ${lock_counter} -gt 2000 ] ; then
+ echo "${0}: WARNING: lock timeout for lock(=${XP_SERVERS}.lock)."
+ return 0
+ fi
+
+ if [ -x /bin/usleep ] ; then
+ /bin/usleep 200000
+ lock_counter=$((${lock_counter} + 20)) # 20/100s
+ else
+ sleep 1
+ lock_counter=$((${lock_counter} + 100)) # 100/100s
+ fi
+ done
+}
+
+unlock_server_registry()
+{
+ rmdir "${XP_SERVERS}.lock"
+}
+
+XCOMM Kill dead registry locks (silently!)
+kill_dead_registry_locks()
+{
+ rm -Rf "${XP_SERVERS}.lock"
+}
+
+XCOMM Start Xprint servers
+start_servers()
+{
+ # Write registry "intro" ...
+ lock_server_registry
+ echo "# Xprint server list" >>"${XP_SERVERS}"
+ echo "# File is for private use for ${0}." >>"${XP_SERVERS}"
+ echo "# Do not edit, rely on the content or file format." >>"${XP_SERVERS}"
+ unlock_server_registry
+
+ hostname="$(hostname)"
+
+ default_fontpath="$(get_system_fontlist | fontlist2fontpath)"
+ default_fontpath_acceptpattern=".*";
+ default_fontpath_rejectpattern="_No_Match_"; # Match nothing
+
+ curr=0
+ while [ $curr -lt $num_xpstart ] ; do
+ if [ "${xpstart_remote_server[$curr]}" != "" ] ; then
+ # Remote Xprt, just put the entry into the registry
+ lock_server_registry
+ echo "display=${xpstart_remote_server[$curr]}" >>"${XP_SERVERS}"
+ unlock_server_registry
+ else
+ # Run block in seperate process to avoid that changes to the
+ # xpstart_* variables affect the next cycle
+ (
+ # Use defaults if there are no special options
+ [ "${xpstart_fontpath[$curr]}" = "" ] && xpstart_fontpath[$curr]="${default_fontpath}";
+ [ "${xpstart_fontpath_acceptpattern[$curr]}" = "" ] && xpstart_fontpath_acceptpattern[$curr]="$default_fontpath_acceptpattern";
+ [ "${xpstart_fontpath_rejectpattern[$curr]}" = "" ] && xpstart_fontpath_rejectpattern[$curr]="$default_fontpath_rejectpattern";
+ [ "${xpstart_displayid[$curr]}" = "" ] && xpstart_displayid[$curr]="$(FindFreeXDisplayNum)"
+ [ "${xpstart_logger[$curr]}" = "" ] && xpstart_logger[$curr]="logger -p lpr.notice -t Xprt_${xpstart_displayid[$curr]}";
+ [ "${xpstart_logfile[$curr]}" = "" ] && xpstart_logfile[$curr]="/dev/null";
+ [ "${xpstart_xprt_binary[$curr]}" = "" ] && xpstart_xprt_binary[$curr]="${XPRT_BIN}";
+ if [ "${xpstart_xprt_binary[$curr]}" = "/usr/openwin/bin/Xprt" -o "$(uname -s)" = "SunOS" ] ; then
+ # Solaris /usr/openwin/bin/Xprt does not support "-nolisten tcp"
+ # yet nor is it possible to run a Xserver on a unix socket only
+ # in Solaris since access to the unix domain sockets in
+ # /tmp/.X11-pipe and /tmp/.X11-unix is restricted to applications
+ # with group-id "root" (e.g. the Xprt server would need to be
+ # setgid "root" that plain users can start it listening on a unix
+ # socket only)
+ [ "${xpstart_options[$curr]}" = "" ] && xpstart_options[$curr]="-ac -pn"
+ else
+ [ "${xpstart_options[$curr]}" = "" ] && xpstart_options[$curr]="-ac -pn -nolisten tcp"
+ fi
+
+ # Check if the Xprt binary is available
+ if [ ! -x "${xpstart_xprt_binary[$curr]}" ] ; then
+ error_echo "Can't find \"${xpstart_xprt_binary[$curr]}\"."
+ exit 1 # exit block
+ fi
+
+ # Verify and set location of font encodings directory file
+ if [ "${xpstart_font_encodings_dir[$curr]}" = "" ] ; then
+ if [ -f "${XPROJECTROOT}/lib/X11/fonts/xf86encodings/encodings.dir" ] ; then
+ xpstart_font_encodings_dir[$curr]="${XPROJECTROOT}/lib/X11/fonts/xf86encodings/encodings.dir"
+ else
+ xpstart_font_encodings_dir[$curr]="${XPROJECTROOT}/lib/X11/fonts/encodings/encodings.dir";
+ fi
+ fi
+
+ unset FONT_ENCODINGS_DIRECTORY
+ if [ ! -f "${xpstart_font_encodings_dir[$curr]}" ] ; then
+ warning_echo "Can't find \"${xpstart_font_encodings_dir[$curr]}\", TrueType font support may not work."
+ fi
+
+ export FONT_ENCODINGS_DIRECTORY="${xpstart_font_encodings_dir[$curr]}"
+
+ # Generate font path (containing only valid font path elements)
+ # from input font path and filter expressions
+ curr_fp=$(echo "${xpstart_fontpath[$curr]}" |
+ fontpath2fontlist |
+ filter_fontlist "${xpstart_fontpath_acceptpattern[$curr]}" "${xpstart_fontpath_rejectpattern[$curr]}" |
+ filter_unsupported_fonts |
+ sort_scaleable_fonts_first |
+ validate_fontlist |
+ fontlist2fontpath)
+
+ # Set Xserver auditing level option
+ unset curr_audit
+ if [ "${xpstart_auditlevel[$curr]}" != "" ] ; then
+ curr_audit="-audit ${xpstart_auditlevel[$curr]}"
+ fi
+
+ # Set Xprt -XpFile option
+ unset curr_xpfile
+ if [ "${xpstart_xpfile[$curr]}" != "" ] ; then
+ curr_xpfile="-XpFile ${xpstart_xpfile[$curr]}"
+ fi
+
+ # Set custom XPCONFIGDIR (if there is one)
+ unset XPCONFIGDIR
+ if [ "${xpstart_xpconfigdir[$curr]}" != "" ] ; then
+ export XPCONFIGDIR="${xpstart_xpconfigdir[$curr]}"
+ fi
+
+ # If someone uses "-nolisten tcp" make sure we do not add a hostname to force local transport
+ if [ "$(echo "${xpstart_options[$curr]}" | egrep "nolisten.*tcp")" != "" ] ; then
+ xp_display=":${xpstart_displayid[$curr]}"
+ else
+ xp_display="${hostname}:${xpstart_displayid[$curr]}"
+ fi
+
+ (
+ (
+ "${xpstart_xprt_binary[$curr]}" \
+ ${xpstart_options[$curr]} \
+ ${curr_xpfile} ${curr_audit} \
+ -fp ${curr_fp} \
+ :${xpstart_displayid[$curr]} &
+ server_pid="$!"
+
+ # Append the new server to the registry
+ lock_server_registry
+ echo "display=${xp_display} display_id=${xpstart_displayid[$curr]} pid=${server_pid}" >>"${XP_SERVERS}"
+ unlock_server_registry
+
+ wait
+ echo "Xprint server pid=${server_pid} done, exitcode=$?."
+
+ # Remove the dead server from the registry
+ # (only if the registry still exists - if /etc/init.d/xprint stop" gets called the registry
+ # will be removed - and we should not re-create it afterwards...)
+ lock_server_registry
+ if [ -f "${XP_SERVERS}" ] ; then
+ x="$(cat "${XP_SERVERS}")" # Store content of file "${XP_SERVERS}" in var "x"
+ echo "${x}" | fgrep -v "display_id=${xpstart_displayid[$curr]} pid=${server_pid}" >"${XP_SERVERS}"
+ fi
+ unlock_server_registry
+ ) 2>&1 | while read i ; do echo "$i" | tee -a "${xpstart_logfile[$curr]}" | ${xpstart_logger[$curr]} ; done
+ ) &
+ )
+ fi
+
+ curr=$(($curr + 1))
+ done
+
+ # Remove tmp. file created by |FindFreeXDisplayNum()|
+ rm -f "${lastdisplaynumreturned_store}"
+
+ # Done.
+ lock_server_registry
+ echo "# EOF." >>"${XP_SERVERS}"
+ unlock_server_registry
+ return 0
+}
+
+
+XCOMM Convenience function to check setup and start Xprt server(s)
+do_start()
+{
+ if [ -f "${XP_SERVERS}" ] ; then
+ numservers="$(do_get_xpserverlist | wc -l)"
+ if [ ${numservers} -gt 0 ] ; then
+ verbose_echo "Xprint servers are already running."
+ return 0
+ else
+ verbose_echo "Old server registry found, cleaning-up..."
+ do_stop
+ fi
+ fi
+
+ # Check if we can write the registry file
+ touch "${XP_SERVERS}" 2>/dev/null
+ if [ ! -f "${XP_SERVERS}" ] ; then
+ error_echo "Cannot create \"${XP_SERVERS}\"."
+ # exit code 4 = user had insufficient privilege (LSB)
+ exit 4
+ fi
+
+ if ! setup_config ; then
+ error_echo "setup_config failed."
+ exit 1
+ fi
+
+ # Provide two paths here - one which simply starts the Xprt servers,
+ # assuming that there is a print spooler already running (or that
+ # ${XPCONFIG}/C/print/Xprinters provides static print queue entries
+ # (like for the PSspooldir print model)) and a 2nd path which
+ # explicitly checks if the print queue daemons are running
+ if true ; then
+ msg "Starting Xprint servers: Xprt."
+ start_servers
+ else
+ # Continue in the background if there is no spooler running yet (that
+ # we don't hold off the boot process nor run in a possible race-condition
+ # when /etc/init.d/lpd was not called yet but the runlevel script waits
+ # for us to finish first ...
+ if is_spooler_running ; then
+ msg "Starting Xprint servers: Xprt."
+ start_servers
+ else
+ msg "Starting Xprint servers (in the background): Xprt."
+ (wait_for_print_spooler ; start_servers) &
+ sleep 5
+ fi
+ fi
+
+ if [ "${CURRLOGNAME}" = "root" -a -d /var/lock/subsys/ ] ; then
+ touch /var/lock/subsys/xprint
+ fi
+}
+
+XCOMM Convenience function to stop Xprt server(s)
+do_stop()
+{
+ msg "Stopping Xprint servers: Xprt."
+
+ lock_server_registry
+ if [ -f "${XP_SERVERS}" ] ; then
+ reglist="$(cat "${XP_SERVERS}")"
+ rm -f "${XP_SERVERS}"
+ fi
+ unlock_server_registry
+
+ if [ "${reglist}" != "" ] ; then
+ echo "${reglist}" |
+ grep "^display=.*:.* pid=[0-9]*$" |
+ while read i ; do
+ (
+ eval ${i}
+ if pexists ${pid} ; then
+ kill ${pid}
+ fi
+
+ # Remove the X sockets/pipes which are not in use anymore
+ # (It would be better if the Xservers would cleanup this
+ # automatically, but most Xservers do not do that... ;-(
+ # Note that this will not work on Solaris where applications
+ # must run with groupid="root" if they want to write into
+ # /tmp/.X11-unix/ and/or /tmp/.X11-pipe/)
+ if [ "${display_id}" != "" ] ; then
+ rm -f "/tmp/.X${display_id}-lock" 2>/dev/null
+ rm -f "/tmp/.X11-unix/X${display_id}" 2>/dev/null
+ rm -f "/tmp/.X11-pipe/X${display_id}" 2>/dev/null
+ fi
+ )
+ done
+ fi
+
+ if [ "${CURRLOGNAME}" = "root" -a -d /var/lock/subsys/ ] ; then
+ rm -f /var/lock/subsys/xprint
+ fi
+
+ # Remove any outstanding (dead) locks and cleanup
+ rm -f "${XP_SERVERS}"
+ kill_dead_registry_locks
+}
+
+XCOMM Convenience function to obtain a list of available Xprint servers
+do_get_xpserverlist()
+{
+ if [ -f "${XP_PER_USER_SERVERS}" -o -f "${XP_GLOBAL_SERVERS}" ] ; then
+ xpserverlist=$(
+ # Enumerate both per-user and global servers (in that order)
+ (
+ [ -f "${XP_PER_USER_SERVERS}" ] && cat "${XP_PER_USER_SERVERS}"
+ [ -f "${XP_GLOBAL_SERVERS}" ] && cat "${XP_GLOBAL_SERVERS}"
+ ) |
+ egrep "^display=.*:.* pid=[0-9]*$|^display=.*:[0-9]*$" |
+ while read i ; do
+ (
+ pid="none"
+ eval ${i}
+ # Check if the Xprt process exists (if possible)
+ if [ "$pid" != "none" ] ; then
+ if pexists ${pid} ; then
+ echo ${display}
+ fi
+ else
+ echo ${display}
+ fi
+ )
+ done | tr "\n" " "
+ )
+ # Only produce output if we have some entries...
+ [ "${xpserverlist}" != "" ] && echo "${xpserverlist}"
+ fi
+}
+
+do_restart()
+{
+ msg "Restarting Xprint server(s): Xprt."
+ do_stop
+ sleep 1
+ do_start
+}
+
+do_diag()
+{
+ echo "##### Diag start $(date)."
+
+ # General info
+ echo "## General info start."
+ (
+ echo "PATH=\"${PATH}\""
+ echo "TZ=\"${TZ}\""
+ echo "LANG=\"${LANG}\""
+ echo "uname -a=\"$(uname -a)\""
+ echo "uname -s=\"$(uname -s)\""
+ echo "uname -p=\"$(uname -p)\""
+ echo "uname -i=\"$(uname -i)\""
+ echo "uname -m=\"$(uname -m)\""
+ echo "has /etc/SuSE-release ... $([ -f "/etc/SuSE-release" ] && echo "yes" || echo "no")"
+ echo "has /etc/redhat-release ... $([ -f "/etc/redhat-release" ] && echo "yes" || echo "no")"
+ echo "has /etc/debian_version ... $([ -f "/etc/debian_version" ] && echo "yes" || echo "no")"
+ echo "how many Xprt servers are running ...$(ps -ef | fgrep Xprt | fgrep -v "grep" | wc -l)"
+ ) 2>&1 | while read i ; do echo " $i" ; done
+ echo "## General info end."
+
+ # Testing font paths
+ echo "## Testing font paths start."
+ (
+ get_system_fontlist |
+ filter_unsupported_fonts |
+ sort_scaleable_fonts_first |
+ validate_fontlist | while read d ; do
+ echo "#### Testing \"${d}\" ..."
+ if [ ! -d "$d" ] ; then
+ echo "# Error: $d does not exists."
+ continue
+ fi
+ if [ ! -r "$d" ] ; then
+ echo "# Error: $d not readable."
+ continue
+ fi
+ if [ ! -f "${d}/fonts.dir" ] ; then
+ echo "# Error: ${d}/fonts.dir not found."
+ continue
+ else
+ if [ ! -r "${d}/fonts.dir" ] ; then
+ echo "# Error: ${d}/fonts.dir not readable."
+ continue
+ fi
+ fi
+ if [ -f "${d}/fonts.alias" ] ; then
+ if [ ! -r "${d}/fonts.alias" ] ; then
+ echo "# Error: ${d}/fonts.alias not readable."
+ fi
+ fi
+
+ if [ "$(cat "${d}/fonts.dir" | fgrep 'cursor')" != "" ] ; then
+ echo "${d}/fonts.dir has cursor font."
+ fi
+ if [ "$(cat "${d}/fonts.dir" | fgrep 'fixed')" != "" ] ; then
+ echo "${d}/fonts.dir has fixed font."
+ fi
+
+ if [ -r "${d}/fonts.alias" ] ; then
+ if [ "$(cat "${d}/fonts.alias" | fgrep 'cursor')" != "" ] ; then
+ echo "${d}/fonts.alias has cursor font."
+ fi
+ if [ "$(cat "${d}/fonts.alias" | fgrep 'fixed')" != "" ] ; then
+ echo "${d}/fonts.alias has fixed font."
+ fi
+ fi
+
+ linenum=0
+ cat "${d}/fonts.dir" | while read i1 i2 i3 i4 ; do
+ linenum=$((${linenum} + 1))
+ [ ${linenum} -eq 1 ] && continue
+
+ if [ ! -f "${d}/${i1}" ] ; then
+ echo "ERROR: ${d}/fonts.dir line ${linenum} has non-exististant font \"${i1}\" (=\"${i1} ${i2} ${i3} ${i4}\")"
+ fi
+ done
+ done
+ ) 2>&1 | while read i ; do echo " $i" ; done
+ echo "## Testing font paths end."
+
+ echo "##### Diag End $(date)."
+}
+
+XCOMM Set platform-defaults for setup_config()
+setup_config_defaults()
+{
+ curr_num_xpstart="${1}"
+
+ #### Defaults for Linux/Solaris
+ # Start Xprt using builtin XPCONFIGDIR at a free display numer
+ # (Solaris(=SunOS5.x)'s /usr/openwin/bin/Xprt supports TrueType fonts,
+ # therefore we don't need to filter them)
+ xpstart_fontpath[${curr_num_xpstart}]="";
+ xpstart_fontpath_acceptpattern[${curr_num_xpstart}]=".*";
+ xpstart_fontpath_rejectpattern[${curr_num_xpstart}]="/Speedo|/F3bitmaps|/F3";
+ xpstart_displayid[${curr_num_xpstart}]="";
+ xpstart_xpconfigdir[${curr_num_xpstart}]="";
+ xpstart_xpfile[${curr_num_xpstart}]="";
+ xpstart_auditlevel[${curr_num_xpstart}]="4";
+ xpstart_options[${curr_num_xpstart}]="";
+ xpstart_logger[${curr_num_xpstart}]="";
+ # Check whether we have /dev/stderr (needed for old AIX + old Debian)
+ if [ -w "/dev/stderr" ] ; then
+ xpstart_logfile[${curr_num_xpstart}]="/dev/stderr";
+ else
+ xpstart_logfile[${curr_num_xpstart}]="/dev/tty";
+ fi
+ xpstart_xprt_binary[${curr_num_xpstart}]="";
+
+ # Custom rules for the GISWxprintglue package on Solaris
+ # (which uses Solaris's /usr/openwin/bin/Xprt but a custom config)
+ if [ "${XPCUSTOMGLUE}" = "GISWxprintglue" ] ; then
+ xpstart_xpconfigdir[${curr_num_xpstart}]="/opt/GISWxprintglue/server/etc/XpConfig"
+ xpstart_xprt_binary[${curr_num_xpstart}]="/usr/openwin/bin/Xprt"
+ fi
+ # Custom rules for the GISWxprint package on Solaris
+ # (which uses both it's own Xprt and a custom config)
+ if [ "${XPCUSTOMGLUE}" = "GISWxprint" ] ; then
+ xpstart_xpconfigdir[${curr_num_xpstart}]="/opt/GISWxprint/server/etc/XpConfig"
+ xpstart_xprt_binary[${curr_num_xpstart}]="/opt/GISWxprint/bin/Xprt"
+ xpstart_font_encodings_dir[${curr_num_xpstart}]="/opt/GISWxprint/lib/X11/fonts/encodings/encodings.dir"
+ fi
+
+ #######################################################
+ ###
+ ### Debian Xprint package default configuration
+ ###
+ if [ "${XPCUSTOMGLUE}" = "DebianGlue" ] ; then
+ # Set XPCONFIGDIR=/usr/share/Xprint/xserver
+ xpstart_xpconfigdir[${curr_num_xpstart}]="/usr/share/Xprint/xserver";
+
+ # Use fixed display ID (":64"), or else all client programs will have to be
+ # restarted simply to update XPSERVERLIST to the latest ID when upgrading,
+ # which would be a nightmare.
+ xpstart_displayid[${curr_num_xpstart}]=64;
+
+ # Do not send any messages to console
+ xpstart_logfile[${curr_num_xpstart}]="/dev/null";
+
+ # By default use binary provided by Debian's "xprt-xprintorg" package
+ # (=/usr/bin/Xprt), otherwise leave blank (e.g. use script's default
+ # (=/usr/X11R6/bin/Xprt))
+ if [ -x "/usr/bin/Xprt" ] ; then
+ xpstart_xprt_binary[${curr_num_xpstart}]="/usr/bin/Xprt";
+ fi
+ fi
+ ###
+ ### End Debian default configuration
+ ###
+ #######################################################
+}
+
+fetch_etc_initd_xprint_envvars()
+{
+ curr_num_xpstart="${1}"
+
+ ## Process some $ETC_INITD_XPRINT_* vars after all which may be used by
+ # a user to override the hardcoded values here when starting Xprt per-user
+ # (a more flexible way is to provide an own setup config script in
+ # "~./Xprint_per_user_startup" - see above)
+ if [ "${ETC_INITD_XPRINT_XPRT_PATH}" != "" ] ; then
+ xpstart_xprt_binary[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XPRT_PATH}"
+ fi
+ if [ "${ETC_INITD_XPRINT_XPCONFIGDIR}" != "" ] ; then
+ xpstart_xpconfigdir[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XPCONFIGDIR}"
+ fi
+ if [ "${ETC_INITD_XPRINT_XPFILE}" != "" ] ; then
+ xpstart_xpfile[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XPFILE}"
+ fi
+ if [ "${ETC_INITD_XPRINT_LOGFILE}" != "" ] ; then
+ xpstart_logfile[${curr_num_xpstart}]="${ETC_INITD_XPRINT_LOGFILE}"
+ fi
+ if [ "${ETC_INITD_XPRINT_DISPLAYID}" != "" ] ; then
+ xpstart_displayid[${curr_num_xpstart}]="${ETC_INITD_XPRINT_DISPLAYID}"
+ fi
+ if [ "${ETC_INITD_XPRINT_FONTPATH}" != "" ] ; then
+ xpstart_fontpath[${curr_num_xpstart}]="${ETC_INITD_XPRINT_FONTPATH}"
+ fi
+ if [ "${ETC_INITD_XPRINT_XPRT_OPTIONS}" != "" ] ; then
+ xpstart_options[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XPRT_OPTIONS}"
+ fi
+ if [ "${ETC_INITD_XPRINT_AUDITLEVEL}" != "" ] ; then
+ xpstart_auditlevel[${curr_num_xpstart}]="${ETC_INITD_XPRINT_AUDITLEVEL}"
+ fi
+ if [ "${ETC_INITD_XPRINT_XF86ENCODINGSDIR}" != "" ] ; then
+ xpstart_font_encodings_dir[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XF86ENCODINGSDIR}"
+ fi
+}
+
+XCOMM###########################################################################
+XCOMM setup_config() sets the configuration parameters used to start one
+XCOMM or more Xprint servers ("Xprt").
+XCOMM The following variables are used:
+XCOMM - "num_xpstart" - number of servers to start
+XCOMM - "xpstart_fontpath[index]" - custom font path. Leave blank if you want
+XCOMM the platform-specific default
+XCOMM - "xpstart_fontpath_acceptpattern[index]" - extended regular expression
+XCOMM (see egrep(1)) used to filter the font path - items only pass this
+XCOMM filter if they match the pattern (leave blank if you want to filter
+XCOMM nothing)
+XCOMM - "xpstart_fontpath_rejectpattern[index]" - extended regular expression
+XCOMM (see egrep(1)) used to filter the font path - items only pass this
+XCOMM filter if they do not match the pattern (leave blank if you want to
+XCOMM filter nothing)
+XCOMM - "xpstart_font_encodings_dir[index]" - location of "encodings.dir".
+XCOMM Leave blank to use the default.
+XCOMM - "xpstart_displayid[index]" - display id to use for the Xprint server
+XCOMM (leave blank to choose the next available free display id)
+XCOMM - "xpstart_xpconfigdir[index]" - value for custom XPCONFIGDIR (leave blank
+XCOMM if you don not want that that XPCONFIGDIR is set at Xprt startup)
+XCOMM - "xpstart_xpfile[index]" - value used for Xprt's "-XpFile" option (leave
+XCOMM blank if you do not want to set this option)
+XCOMM - "xpstart_auditlevel[index]" - set Xserver auditing level (leave blank to
+XCOMM use no auditing)
+XCOMM - "xpstart_options[index]" - set further Xprt options (leave blank to set
+XCOMM no further options)
+XCOMM - "xpstart_logger[index]" - utility which gets stderr/stdout messages from
+XCOMM Xprt and sends them to a logging daemon. Leave blank to use /usr/bin/logger
+XCOMM to send such messages to the lpr.notice syslog)
+XCOMM - "xpstart_logfile[index]" - log file to append stderr/stdout messages from
+XCOMM Xprt to. Leave blank to send messages to /dev/null
+XCOMM - "xpstart_xprt_binary[index]" - set custom Xprt binary (leave blank to use
+XCOMM the platform-specifc default)
+setup_config()
+{
+ num_xpstart=0;
+
+ if [ "${ETC_INITD_XPRINT_CUSTOM_SETUP_CONFIG}" != "" ] ; then
+ user_cfg="${ETC_INITD_XPRINT_CUSTOM_SETUP_CONFIG}"
+ else
+ user_cfg="${HOME}/.Xprint_per_user_startup"
+ fi
+
+ # Source per-user ~/.Xprint_per_user_startup file if there is one
+ # (and do not use the script's defaults below)
+ if [ -r "${user_cfg}" ] ; then
+ # Define API version which should be checked by ${HOME}/.Xprint_per_user_startup
+ # ${HOME}/.Xprint_per_user_startup should bail-out if the version differ
+ etc_initd_xprint_api_version=2
+
+ # Source per-user settings script
+ . "${user_cfg}"
+
+ # done with setting the config for per-user Xprt instances
+ return 0;
+ else
+ # Use /etc/init.d/xprint's builtin config
+ # Each entry should start with |setup_config_defaults| to pull the
+ # platform defaults and finish with |num_xpstart=$(($num_xpstart + 1))|
+ # to end the entry
+
+ # Set platform-defaults
+ setup_config_defaults "${num_xpstart}"
+
+ ## -- snip --
+
+ # Admins can put their stuff "in" here...
+
+ ## -- snip --
+
+ # Override script's builtin values with those a user may set via the
+ # $ETC_INIITD_XPRINT_* env vars
+ fetch_etc_initd_xprint_envvars "${num_xpstart}"
+
+ num_xpstart=$((${num_xpstart} + 1))
+
+ return 0;
+ fi
+
+ #### Sample 1:
+ # # Start Xprt on a free display ID with custom XPCONFIGDIR and without
+ # # Speedo and TrueType fonts
+ # xpstart_fontpath_rejectpattern[$num_xpstart]="/Speedo|/TrueType|/TT(/$|$)|/TTF(/$|$)";
+ # xpstart_xpconfigdir[$num_xpstart]="/home/gisburn/cwork/Xprint/Xprt_config/XpConfig";
+ # xpstart_auditlevel[$num_xpstart]="4";
+ # xpstart_options[$num_xpstart]="-ac -pn";
+ #num_xpstart=$(($num_xpstart + 1))
+
+
+ #### Sample 2:
+ # # Start Xprt without TrueType fonts on a display 55 with custom
+ # # XPCONFIGDIR
+ # xpstart_fontpath_rejectpattern[$num_xpstart]="/TrueType|/TT(/$|$)|/TTF(/$|$)";
+ # xpstart_displayid[$num_xpstart]=55;
+ # xpstart_xpconfigdir[$num_xpstart]="/home/gisburn/cwork/Xprint/Xprt_config/XpConfig";
+ # xpstart_auditlevel[$num_xpstart]=4;
+ # xpstart_options[$num_xpstart]="-ac -pn";
+ #num_xpstart=$(($num_xpstart + 1))
+
+ #### Sample 3:
+ # # Start Xprt without TrueType fonts on a display 56 with custom
+ # # XPCONFIGDIR and alternate "Xprinters" file
+ # xpstart_fontpath_rejectpattern[$num_xpstart]="/TrueType|/TT(/$|$)|/TTF(/$|$)";
+ # xpstart_displayid[$num_xpstart]=56;
+ # xpstart_xpconfigdir[$num_xpstart]="/etc/XpConfig/default";
+ # xpstart_xpfile[$num_xpstart]="/etc/XpConfig/default/Xprinters_test2"
+ # xpstart_auditlevel[$num_xpstart]="4";
+ # xpstart_options[$num_xpstart]="-ac -pn";
+ # xpstart_xprt_binary[$num_xpstart]="";
+ #num_xpstart=$(($num_xpstart + 1))
+
+ #### Sample 4:
+ # # Start Xprt with Solaris ISO-8859-7 (greek(="el") locale) fonts on
+ # # display 57
+ # xpstart_fontpath[$num_xpstart]="/usr/openwin/lib/locale/iso_8859_7/X11/fonts/75dpi,/usr/openwin/lib/locale/iso_8859_7/X11/fonts/Type1,/usr/openwin/lib/X11/fonts/misc/";
+ # xpstart_fontpath_acceptpattern[$num_xpstart]="";
+ # xpstart_fontpath_rejectpattern[$num_xpstart]="_No_Match_";
+ # xpstart_displayid[$num_xpstart]="57";
+ # xpstart_auditlevel[$num_xpstart]="4";
+ # xpstart_options[$num_xpstart]="-ac -pn";
+ #num_xpstart=$(($num_xpstart + 1))
+
+ #### Sample 5:
+ # # Start Xprt with the font list of an existing Xserver (excluding Speedo fonts) on
+ # # display 58
+ # # Note that this only works within a X session. At system boot time
+ # # there will be no $DISPLAY to fetch the information from!!
+ # xpstart_fontpath[$num_xpstart]="$(get_fontlist_from_display ${DISPLAY} | fontlist2fontpath)";
+ # xpstart_fontpath_acceptpattern[$num_xpstart]="";
+ # xpstart_fontpath_rejectpattern[$num_xpstart]="";
+ # xpstart_displayid[$num_xpstart]="58";
+ # xpstart_xpconfigdir[$num_xpstart]="";
+ # xpstart_auditlevel[$num_xpstart]="4";
+ # xpstart_options[$num_xpstart]="-ac -pn";
+ # xpstart_xprt_binary[$num_xpstart]="";
+ #num_xpstart=$(($num_xpstart + 1))
+
+ #### Sample 6:
+ # # List remote Xprt's here
+ # # (note that there is no test to check whether these DISPLAYs are valid!)
+ # xpstart_remote_server[$num_xpstart]="sera:12" ; num_xpstart=$(($num_xpstart + 1))
+ # xpstart_remote_server[$num_xpstart]="gandalf:19" ; num_xpstart=$(($num_xpstart + 1))
+}
+
+XCOMM###########################################################################
+
+XCOMM Main
+case "$1" in
+ ## Start Xprint servers
+ 'start')
+ do_start
+ ;;
+
+ ## Stop Xprint servers
+ # Note that this does _not_ kill Xprt instances started using this script
+ # by non-root users
+ 'stop')
+ do_stop
+ ;;
+
+ ## Restart Xprint servers
+ 'restart'|'force-reload')
+ do_restart
+ ;;
+
+ ## Reload configuration without stopping and restarting
+ 'reload')
+ # not supported
+ msg "reload not supported, use 'restart' or 'force-reload'"
+ exit 3
+ ;;
+
+ ## Restart Xprint only if it is already running
+ 'condrestart'|'try-restart')
+ # only restart if it is already running
+ [ -f /var/lock/subsys/xprint ] && do_restart || :
+ ;;
+
+ ## Get list of all Xprint servers for this user
+ # (incl. per-user and system-wide instances)
+ 'get_xpserverlist')
+ do_get_xpserverlist
+ ;;
+
+ ## Get status of Xprint servers, RedHat-style
+ 'status')
+ x="$(do_get_xpserverlist)"
+ if [ "${x}" != "" ] ; then
+ msg "Xprint (${x}) is running..."
+ exit 0
+ else
+ msg "Xprint is stopped"
+ exit 3
+ fi
+ ;;
+
+ ## Wrapper
+ 'wrapper')
+ cmd="${2}"
+ [ "${cmd}" = "" ] && fatal_error "No command given."
+ shift ; shift
+ export XPSERVERLIST="$(do_get_xpserverlist)"
+ [ "${XPSERVERLIST}" = "" ] && fatal_error "No Xprint servers found."
+ exec "${cmd}" "$@"
+ ;;
+
+ ## Wrapper for "xplsprinters"
+ 'lsprinters')
+ [ "${ETC_INITD_XPRINT_XPLSPRINTERS_PATH}" != "" ] && cmd="${ETC_INITD_XPRINT_XPLSPRINTERS_PATH}"
+ [ "${cmd}" = "" -a "${XPCUSTOMGLUE}" = "GISWxprintglue" ] && cmd="/opt/GISWxprintglue/bin/xplsprinters"
+ [ "${cmd}" = "" -a "${XPCUSTOMGLUE}" = "GISWxprint" ] && cmd="/opt/GISWxprint/bin/xplsprinters"
+ [ "${cmd}" = "" -a "${XPROJECTROOT}" != "" ] && cmd="${XPROJECTROOT}/bin/xplsprinters"
+ [ "${cmd}" = "" ] && cmd="xplsprinters"
+
+ shift
+ export XPSERVERLIST="$(do_get_xpserverlist)"
+ [ "${XPSERVERLIST}" = "" ] && fatal_error "No Xprint servers found."
+ exec "${cmd}" "$@"
+ ;;
+
+ ## Diagnostics
+ 'diag')
+ do_diag
+ ;;
+
+ ## Print usage
+ *)
+ msg "Usage: $0 { start | stop | restart | reload | force-reload | status | condrestart | try-restart | wrapper | lsprinters | get_xpserverlist | diag }"
+ exit 2
+esac
+exit 0
+
+XCOMM EOF.
diff --git a/nx-X11/programs/Xserver/Xprint/etc/profile.d/Imakefile b/nx-X11/programs/Xserver/Xprint/etc/profile.d/Imakefile
new file mode 100644
index 000000000..a70824c8d
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/etc/profile.d/Imakefile
@@ -0,0 +1,14 @@
+XCOMM $Xorg: Imakefile,v 1.1 2002/10/31 14:42:52 gisburn Exp $
+
+#if NothingOutsideProjectRoot
+#define EtcDir ProjectRoot/etc
+#else
+#define EtcDir /etc
+#endif
+
+ETCDIR = EtcDir
+
+all::
+
+InstallNamedProg(xprint.csh,xprint.csh,$(ETCDIR)/profile.d)
+InstallNamedProg(xprint.sh,xprint.sh,$(ETCDIR)/profile.d)
diff --git a/nx-X11/programs/Xserver/Xprint/etc/profile.d/xprint.csh b/nx-X11/programs/Xserver/Xprint/etc/profile.d/xprint.csh
new file mode 100644
index 000000000..7cc675840
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/etc/profile.d/xprint.csh
@@ -0,0 +1,16 @@
+#
+# /etc/profile.d/xprint.csh
+#
+# Copyright (c) 2002-2004 by Roland Mainz <roland.mainz@nrubsig.org>
+# please send bugfixes or comments to http://xprint.mozdev.org/
+
+
+#
+# Obtain list of Xprint servers
+#
+
+if ( -f /etc/init.d/xprint ) then
+ setenv XPSERVERLIST "`/bin/sh /etc/init.d/xprint get_xpserverlist`"
+endif
+
+# /etc/profile.d/xprint.csh ends here.
diff --git a/nx-X11/programs/Xserver/Xprint/etc/profile.d/xprint.sh b/nx-X11/programs/Xserver/Xprint/etc/profile.d/xprint.sh
new file mode 100644
index 000000000..b5b46c1e7
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/etc/profile.d/xprint.sh
@@ -0,0 +1,16 @@
+#
+# /etc/profile.d/xprint.sh
+#
+# Copyright (c) 2002-2004 by Roland Mainz <roland.mainz@nrubsig.org>
+# please send bugfixes or comments to http://xprint.mozdev.org/
+
+#
+# Obtain list of Xprint servers
+#
+
+if [ -f "/etc/init.d/xprint" ] ; then
+ XPSERVERLIST="`/bin/sh /etc/init.d/xprint get_xpserverlist`"
+ export XPSERVERLIST
+fi
+
+# /etc/profile.d/xprint.sh ends here.
diff --git a/nx-X11/programs/Xserver/Xprint/mediaSizes.c b/nx-X11/programs/Xserver/Xprint/mediaSizes.c
new file mode 100644
index 000000000..7f582199d
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/mediaSizes.c
@@ -0,0 +1,783 @@
+/* $Xorg: mediaSizes.c,v 1.4 2001/03/14 18:44:37 pookie Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: mediaSizes.c
+** *
+** * Contents:
+** * Routines to return the sizes associated
+** * with particular media and particular printers.
+** *
+** * Created: 2/19/96
+** *
+** * Copyright: Copyright 1993,1995 Hewlett-Packard Company
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <locale.h>
+
+#include <X11/X.h>
+#include "dixstruct.h"
+#include "screenint.h"
+#include "misc.h"
+#include "scrnintstr.h"
+#include <X11/fonts/fontstruct.h>
+
+#include "DiPrint.h"
+#include "attributes.h"
+
+typedef struct {
+ XpOid page_size;
+ float width;
+ float height;
+} PageDimensionsRec;
+
+static PageDimensionsRec PageDimensions[] =
+{
+ {xpoid_val_medium_size_na_letter, 215.9, 279.4},
+ {xpoid_val_medium_size_na_legal, 215.9, 355.6},
+ {xpoid_val_medium_size_executive, 184.15, 266.7},
+ {xpoid_val_medium_size_folio, 210.82, 330.2},
+ {xpoid_val_medium_size_invoice, 139.7, 215.9},
+ {xpoid_val_medium_size_ledger, 279.4, 431.8},
+ {xpoid_val_medium_size_quarto, 215.9, 275.082},
+ {xpoid_val_medium_size_a, 215.9, 279.4},
+ {xpoid_val_medium_size_b, 279.4, 431.8},
+ {xpoid_val_medium_size_c, 431.8, 558.8},
+ {xpoid_val_medium_size_d, 558.8, 863.6},
+ {xpoid_val_medium_size_e, 863.6, 1117.6},
+ {xpoid_val_medium_size_na_6x9_envelope, 152.4, 228.6},
+ {xpoid_val_medium_size_na_10x15_envelope, 254, 381},
+ {xpoid_val_medium_size_monarch_envelope, 98.298, 190.5},
+ {xpoid_val_medium_size_na_10x13_envelope, 254, 330.2},
+ {xpoid_val_medium_size_na_9x12_envelope, 228.6, 304.8},
+ {xpoid_val_medium_size_na_number_10_envelope, 104.775, 241.3},
+ {xpoid_val_medium_size_na_7x9_envelope, 177.8, 228.6},
+ {xpoid_val_medium_size_na_9x11_envelope, 228.6, 279.4},
+ {xpoid_val_medium_size_na_10x14_envelope, 254, 355.6},
+ {xpoid_val_medium_size_na_number_9_envelope, 98.425, 225.425},
+ {xpoid_val_medium_size_iso_a0, 841, 1189},
+ {xpoid_val_medium_size_iso_a1, 594, 841},
+ {xpoid_val_medium_size_iso_a2, 420, 594},
+ {xpoid_val_medium_size_iso_a3, 297, 420},
+ {xpoid_val_medium_size_iso_a4, 210, 297},
+ {xpoid_val_medium_size_iso_a5, 148, 210},
+ {xpoid_val_medium_size_iso_a6, 105, 148},
+ {xpoid_val_medium_size_iso_a7, 74, 105},
+ {xpoid_val_medium_size_iso_a8, 52, 74},
+ {xpoid_val_medium_size_iso_a9, 37, 52},
+ {xpoid_val_medium_size_iso_a10, 26, 37},
+ {xpoid_val_medium_size_iso_b0, 1000, 1414},
+ {xpoid_val_medium_size_iso_b1, 707, 1000},
+ {xpoid_val_medium_size_iso_b2, 500, 707},
+ {xpoid_val_medium_size_iso_b3, 353, 500},
+ {xpoid_val_medium_size_iso_b4, 250, 353},
+ {xpoid_val_medium_size_iso_b5, 176, 250},
+ {xpoid_val_medium_size_iso_b6, 125, 176},
+ {xpoid_val_medium_size_iso_b7, 88, 125},
+ {xpoid_val_medium_size_iso_b8, 62, 88},
+ {xpoid_val_medium_size_iso_b9, 44, 62},
+ {xpoid_val_medium_size_iso_b10, 31, 44},
+ {xpoid_val_medium_size_jis_b0, 1030, 1456},
+ {xpoid_val_medium_size_jis_b1, 728, 1030},
+ {xpoid_val_medium_size_jis_b2, 515, 728},
+ {xpoid_val_medium_size_jis_b3, 364, 515},
+ {xpoid_val_medium_size_jis_b4, 257, 364},
+ {xpoid_val_medium_size_jis_b5, 182, 257},
+ {xpoid_val_medium_size_jis_b6, 128, 182},
+ {xpoid_val_medium_size_jis_b7, 91, 128},
+ {xpoid_val_medium_size_jis_b8, 64, 91},
+ {xpoid_val_medium_size_jis_b9, 45, 64},
+ {xpoid_val_medium_size_jis_b10, 32, 45},
+ {xpoid_val_medium_size_hp_2x_postcard, 148, 200},
+ {xpoid_val_medium_size_hp_european_edp, 304.8, 355.6},
+ {xpoid_val_medium_size_hp_mini, 139.7, 215.9},
+ {xpoid_val_medium_size_hp_postcard, 100, 148},
+ {xpoid_val_medium_size_hp_tabloid, 279.4, 431.8},
+ {xpoid_val_medium_size_hp_us_edp, 279.4, 355.6},
+ {xpoid_val_medium_size_hp_us_government_legal, 203.2, 330.2},
+ {xpoid_val_medium_size_hp_us_government_letter, 203.2, 254},
+ {xpoid_val_medium_size_iso_c3, 324, 458},
+ {xpoid_val_medium_size_iso_c4, 229, 324},
+ {xpoid_val_medium_size_iso_c5, 162, 229},
+ {xpoid_val_medium_size_iso_c6, 114, 162},
+ {xpoid_val_medium_size_iso_designated_long, 110, 220}
+};
+
+/*
+ * XpGetResolution returns an integer representing the printer resolution
+ * in dots-per-inch for the specified print context.
+ *
+ * Note: This routine assumes the values found in the passed context's
+ * attributes pools have been validated.
+ */
+int
+XpGetResolution(
+ XpContextPtr pContext)
+{
+ unsigned long resolution;
+
+ resolution = XpGetCardAttr(pContext, XPPageAttr,
+ xpoid_att_default_printer_resolution,
+ (XpOidCardList*)NULL);
+ if(0 == resolution)
+ resolution = XpGetCardAttr(pContext, XPDocAttr,
+ xpoid_att_default_printer_resolution,
+ (XpOidCardList*)NULL);
+ if(0 == resolution)
+ {
+ XpOidCardList* resolutions_supported;
+ /*
+ * default-printer-resolution not specified; default to 1st entry
+ * in printer-resolutions-supported.
+ */
+ resolutions_supported =
+ XpGetCardListAttr(pContext, XPPrinterAttr,
+ xpoid_att_printer_resolutions_supported,
+ (XpOidCardList*)NULL);
+ resolution = XpOidCardListGetCard(resolutions_supported, 0);
+ XpOidCardListDelete(resolutions_supported);
+ }
+ return (int)resolution;
+}
+
+/*
+ * XpGetContentOrientation determines the content-orientation as
+ * determined by the passed context. The page and document pools are
+ * queried in turn for a specified content-orientation attribute. If none
+ * is found the first content-orientation in the
+ * content-orientations-supported printer attribute is taken as the
+ * default.
+ *
+ * Note: This routine assumes the values found in the passed context's
+ * attributes pools have been validated.
+ */
+XpOid
+XpGetContentOrientation(
+ XpContextPtr pContext)
+{
+ XpOid orientation;
+
+ orientation = XpGetOidAttr(pContext, XPPageAttr,
+ xpoid_att_content_orientation,
+ (XpOidList*)NULL);
+ if(xpoid_none == orientation)
+ orientation = XpGetOidAttr(pContext, XPDocAttr,
+ xpoid_att_content_orientation,
+ (XpOidList*)NULL);
+ if(xpoid_none == orientation)
+ {
+ XpOidList* content_orientations_supported;
+
+ content_orientations_supported =
+ XpGetListAttr(pContext, XPPrinterAttr,
+ xpoid_att_content_orientations_supported,
+ (XpOidList*)NULL);
+ orientation = XpOidListGetOid(content_orientations_supported, 0);
+ XpOidListDelete(content_orientations_supported);
+ }
+ return orientation;
+}
+
+/*
+ * XpGetAvailableCompression determines the available-compression as
+ * determined by the passed context. The page and document pools are
+ * queried in turn for a specified content-orientation attribute. If none
+ * is found the first available-compression in the
+ * avaiable-compressions-supported printer attribute is taken as the
+ * default.
+ *
+ * Note: This routine assumes the values found in the passed context's
+ * attributes pools have been validated.
+ */
+XpOid
+XpGetAvailableCompression(
+ XpContextPtr pContext)
+{
+ XpOid compression;
+
+ compression = XpGetOidAttr(pContext, XPPageAttr,
+ xpoid_att_available_compression,
+ (XpOidList*)NULL);
+ if(xpoid_none == compression)
+ compression = XpGetOidAttr(pContext, XPDocAttr,
+ xpoid_att_available_compression,
+ (XpOidList*)NULL);
+ if(xpoid_none == compression)
+ {
+ XpOidList* available_compressions_supported;
+
+ available_compressions_supported =
+ XpGetListAttr(pContext, XPPrinterAttr,
+ xpoid_att_available_compressions_supported,
+ (XpOidList*)NULL);
+ compression = XpOidListGetOid(available_compressions_supported, 0);
+ XpOidListDelete(available_compressions_supported);
+ }
+ return compression;
+}
+
+/*
+ * XpGetPlex determines the plex as determined by the passed context. The page
+ * and document pools are queried in turn for a specified plex attribute. If
+ * none is found the first plex in the plexes-supported printer attribute is
+ * taken as the default.
+ *
+ * Note: This routine assumes the values found in the passed context's
+ * attributes pools have been validated.
+ */
+XpOid
+XpGetPlex(
+ XpContextPtr pContext)
+{
+ XpOid plex;
+
+ plex = XpGetOidAttr(pContext, XPPageAttr, xpoid_att_plex,
+ (XpOidList*)NULL);
+ if(xpoid_none == plex)
+ plex = XpGetOidAttr(pContext, XPDocAttr, xpoid_att_plex,
+ (XpOidList*)NULL);
+ if(xpoid_none == plex)
+ {
+ XpOidList* plexes_supported;
+
+ plexes_supported =
+ XpGetListAttr(pContext, XPPrinterAttr,
+ xpoid_att_plexes_supported,
+ (XpOidList*)NULL);
+ plex = XpOidListGetOid(plexes_supported, 0);
+ XpOidListDelete(plexes_supported);
+ }
+ return plex;
+}
+
+/*
+ * XpGetPageSize returns the XpOid of the current page size (medium names
+ * are page sizes in this implementation) as indicated by the passed
+ * context.
+ *
+ * The relevant input-tray is returned in pTray. This parm must not be
+ * NULL. If the input-tray is not indicated or irrelevant, xpoid_none
+ * will be returned.
+ *
+ * This function optionally takes a XpOidMediumSS representation of the
+ * medium-source-sizes-supported attribute in order to avoid parsing the
+ * string value twice for calling functions that need to parse m-s-s-s
+ * anyway (e.g. XpGetReproductionArea). If the caller has no other reason
+ * to parse medium-source-sizes-supported, it is recommended that NULL be
+ * passed. This function will obtain medium-source-sizes-supported if it
+ * needs to.
+ *
+ * Note: This routine assumes the values found in the passed context's
+ * attributes pools have been validated.
+ */
+XpOid
+XpGetPageSize(XpContextPtr pContext,
+ XpOid* pTray,
+ const XpOidMediumSS* msss)
+{
+ XpOid medium;
+ /*
+ * check to see if default-medium is specified
+ */
+ medium = XpGetOidAttr(pContext, XPPageAttr, xpoid_att_default_medium,
+ (const XpOidList*)NULL);
+ if(medium == xpoid_none)
+ {
+ /*
+ * default-medium not in page pool; try the document pool
+ */
+ medium = XpGetOidAttr(pContext, XPDocAttr, xpoid_att_default_medium,
+ (const XpOidList*)NULL);
+ }
+ if(medium == xpoid_none)
+ {
+ /*
+ * default-medium not specified; try default-input-tray
+ */
+ *pTray = XpGetOidAttr(pContext, XPPageAttr,
+ xpoid_att_default_input_tray,
+ (const XpOidList*)NULL);
+ if(*pTray == xpoid_none)
+ {
+ /*
+ * default-input-tray not in page pool; try the document pool
+ */
+ *pTray = XpGetOidAttr(pContext, XPDocAttr,
+ xpoid_att_default_input_tray,
+ (const XpOidList*)NULL);
+ }
+ if(*pTray != xpoid_none)
+ {
+ /*
+ * default-input-tray found; get corresponding medium from
+ * input-trays-medium
+ */
+ XpOidTrayMediumList* input_trays_medium;
+ int i;
+
+ input_trays_medium =
+ XpGetTrayMediumListAttr(pContext, XPPrinterAttr,
+ xpoid_att_input_trays_medium,
+ (const XpOidList*)NULL,
+ (const XpOidMediumSS*)NULL);
+ for(i = 0; i < XpOidTrayMediumListCount(input_trays_medium); i++)
+ {
+ if(*pTray == XpOidTrayMediumListTray(input_trays_medium, i))
+ {
+ medium = XpOidTrayMediumListMedium(input_trays_medium, i);
+ break;
+ }
+ }
+ XpOidTrayMediumListDelete(input_trays_medium);
+ }
+ }
+ else
+ *pTray = xpoid_none;
+
+ if(medium == xpoid_none)
+ {
+ XpOidMediumSS* local_msss = (XpOidMediumSS*)NULL;
+ int i_mss, i_ds;
+ XpOidMediumDiscreteSizeList* ds_list;
+ /*
+ * no medium specified; use 1st page size found in
+ * medium-source-sizes-supported
+ */
+ if((XpOidMediumSS*)NULL == msss)
+ msss = local_msss =
+ XpGetMediumSSAttr(pContext, XPPrinterAttr,
+ xpoid_att_medium_source_sizes_supported,
+ (const XpOidList*)NULL,
+ (const XpOidList*)NULL);
+ for(i_mss = 0;
+ i_mss < XpOidMediumSSCount(msss) && xpoid_none == medium;
+ i_mss++)
+ {
+ if(XpOidMediumSS_DISCRETE == (msss->mss)[i_mss].mstag
+ &&
+ xpoid_none != (msss->mss)[i_mss].input_tray)
+ {
+ ds_list = (msss->mss)[i_mss].ms.discrete;
+ for(i_ds = 0; i_ds < ds_list->count; i_ds++)
+ {
+ if(xpoid_none != (ds_list->list)[i_ds].page_size)
+ {
+ medium = (ds_list->list)[i_ds].page_size;
+ break;
+ }
+ }
+ }
+ }
+ XpOidMediumSSDelete(local_msss);
+ }
+ return medium;
+}
+
+/*
+ * XpGetMediumMillimeters returns into the supplied float pointers the
+ * width and height in millimeters of the passed page size identifier.
+ */
+void
+XpGetMediumMillimeters(
+ XpOid page_size,
+ float *width, /* return */
+ float *height) /* return */
+{
+ int i;
+
+ *width = *height = 0;
+ for(i = 0; i < XpNumber(PageDimensions); i++)
+ {
+ if(page_size == PageDimensions[i].page_size)
+ {
+ *width = PageDimensions[i].width;
+ *height = PageDimensions[i].height;
+ return;
+ }
+ }
+}
+
+/*
+ * Converts a millimeter specification into pixels given a resolution in
+ * DPI.
+ */
+static float
+MmToPixels(float mm, int resolution)
+{
+ float f;
+
+ f = mm * resolution;
+ f /= 25.4;
+ return f;
+}
+
+/*
+ * XpGetMediumDimensions returns into the supplied short pointers the
+ * width and height in pixels of the medium associated with the specified
+ * print context. It obtains the page size associated with the current
+ * medium by calling XpGetPageSize. It passes XpGetMediumMillimeters the
+ * page size, and converts the returned millimeter dimensions into pixels
+ * using the resolution returned by XpGetResolution.
+ *
+ * Note: This routine assumes the values found in the passed context's
+ * attributes pools have been validated.
+ */
+void
+XpGetMediumDimensions(
+ XpContextPtr pContext,
+ unsigned short *width, /* return */
+ unsigned short *height) /* return */
+{
+ XpOid page_size;
+ XpOid tray;
+ XpOid orientation;
+
+ int resolution;
+ float w_mm, h_mm;
+
+ page_size = XpGetPageSize(pContext, &tray, (XpOidMediumSS*)NULL);
+ if(page_size == xpoid_none)
+ {
+ /*
+ * fail-safe: if the pools have been validated, this defaulting logic
+ * isn't needed.
+ */
+ page_size = xpoid_val_medium_size_na_letter;
+ }
+ XpGetMediumMillimeters(page_size, &w_mm, &h_mm);
+ resolution = XpGetResolution(pContext);
+ orientation = XpGetContentOrientation(pContext);
+ switch(orientation)
+ {
+ case xpoid_val_content_orientation_landscape:
+ case xpoid_val_content_orientation_reverse_landscape:
+ /*
+ * transpose width and height
+ */
+ *height = MmToPixels(w_mm, resolution);
+ *width = MmToPixels(h_mm, resolution);
+ break;
+
+ default:
+ *width = MmToPixels(w_mm, resolution);
+ *height = MmToPixels(h_mm, resolution);
+ break;
+ }
+}
+
+/*
+ * XRectangleFromXpOidArea converts an XpOidArea area specification
+ * into an XRectangle. The passed resolution is used to convert from
+ * millimeters (XpOidArea) into pixels (XRectangle).
+ */
+static void
+XRectangleFromXpOidArea(
+ xRectangle *pRect,
+ const XpOidArea* repro,
+ int resolution,
+ XpOid orientation)
+{
+ switch(orientation)
+ {
+ case xpoid_val_content_orientation_landscape:
+ case xpoid_val_content_orientation_reverse_landscape:
+ /*
+ * transpose x and y, width and height
+ */
+ pRect->y = MmToPixels(repro->minimum_x, resolution);
+ pRect->x = MmToPixels(repro->minimum_y, resolution);
+ pRect->height =
+ MmToPixels(repro->maximum_x - repro->minimum_x, resolution);
+ pRect->width =
+ MmToPixels(repro->maximum_y - repro->minimum_y, resolution);
+ break;
+
+ default:
+ pRect->x = MmToPixels(repro->minimum_x, resolution);
+ pRect->y = MmToPixels(repro->minimum_y, resolution);
+ pRect->width =
+ MmToPixels(repro->maximum_x - repro->minimum_x, resolution);
+ pRect->height =
+ MmToPixels(repro->maximum_y - repro->minimum_y, resolution);
+ break;
+ }
+}
+
+/*
+ * XpGetReproductionArea queries the current pool attribute values in
+ * order to determine the reproduction area for the currently selected
+ * medium.
+ *
+ * First the current page size (equivalent to current medium) and tray
+ * (if specified) is retrieved via XpGetPageSize. The value of the
+ * medium-source-sizes-supported attribute is interrogated until a matching
+ * entry for the current page size and tray is found. The reproduction
+ * area defined for the current entry is converted into an XRectangle
+ * using XRectangleFromXpOidArea and returned to the caller.
+ *
+ * Note: This routine assumes the values found in the passed context's
+ * attributes pools have been validated.
+ */
+void
+XpGetReproductionArea(XpContextPtr pContext,
+ xRectangle *pRect)
+{
+ XpOid page_size;
+ XpOid tray;
+ XpOidMediumSS* msss;
+ int i_mss, i_ds;
+ XpOidMediumDiscreteSizeList* ds_list;
+ XpOidArea* repro;
+ BOOL done;
+ int resolution;
+ XpOid orientation;
+ /*
+ * find the appropriate assured reproduction area for the current
+ * tray and page size in the medium-source-sizes-supported attribute.
+ */
+ msss = XpGetMediumSSAttr(pContext, XPPrinterAttr,
+ xpoid_att_medium_source_sizes_supported,
+ (const XpOidList*)NULL,
+ (const XpOidList*)NULL);
+ page_size = XpGetPageSize(pContext, &tray, msss);
+ resolution = XpGetResolution(pContext);
+ orientation = XpGetContentOrientation(pContext);
+
+ memset(pRect, 0, sizeof(xRectangle));
+
+ if(xpoid_none == tray)
+ {
+ /*
+ * no tray specified; use 1st matching page size
+ */
+ for(i_mss = 0, done = xFalse;
+ i_mss < XpOidMediumSSCount(msss) && !done;
+ i_mss++)
+ {
+ if(XpOidMediumSS_DISCRETE == (msss->mss)[i_mss].mstag
+ &&
+ xpoid_none != (msss->mss)[i_mss].input_tray)
+ {
+ ds_list = (msss->mss)[i_mss].ms.discrete;
+ for(i_ds = 0; i_ds < ds_list->count; i_ds++)
+ {
+ if(page_size == (ds_list->list)[i_ds].page_size)
+ {
+ repro =
+ &(ds_list->list)[i_ds].assured_reproduction_area;
+ XRectangleFromXpOidArea(pRect, repro,
+ resolution, orientation);
+ done = xTrue;
+ break;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ /*
+ * tray && page size specified; find matching entry
+ */
+ for(i_mss = 0, done = xFalse;
+ i_mss < XpOidMediumSSCount(msss) && !done;
+ i_mss++)
+ {
+ if(XpOidMediumSS_DISCRETE == (msss->mss)[i_mss].mstag
+ &&
+ xpoid_none != (msss->mss)[i_mss].input_tray
+ &&
+ (tray == (msss->mss)[i_mss].input_tray
+ ||
+ xpoid_unspecified == (msss->mss)[i_mss].input_tray)
+ )
+ {
+ ds_list = (msss->mss)[i_mss].ms.discrete;
+ for(i_ds = 0; i_ds < ds_list->count; i_ds++)
+ {
+ if(page_size == (ds_list->list)[i_ds].page_size)
+ {
+ repro =
+ &(ds_list->list)[i_ds].assured_reproduction_area;
+ XRectangleFromXpOidArea(pRect, repro,
+ resolution, orientation);
+ if(xpoid_unspecified != (msss->mss)[i_mss].input_tray)
+ {
+ /*
+ * exact match on tray takes precendence over
+ * unspecified tray entry in m-s-s-s
+ */
+ done = xTrue;
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ XpOidMediumSSDelete(msss);
+}
+
+/*
+ * XpGetMaxWidthHeightRes returns into the supplied width and height
+ * unsigned short pointers the dimensions in millimeters of the largest
+ * supported media for a specific printer. It looks at the
+ * medium-source-sizes-supported attribute (if it exists) to determine
+ * the list of possible media, and calls XpGetMediumMillimeters to get the
+ * dimensions for each medium. If the m-s-s-s attribute is not defined,
+ * then the dimensions for the na-letter medium is returned.
+ *
+ * This function also returns the largest resolution in DPI defined in
+ * printer-resolutions-supported. If printer-resolutions-supported is not
+ * specified, the default is obtained from the passed XpValidatePoolsRec.
+ *
+ * The passed XpValidatePoolsRec is also used to determine valid values
+ * when parsing attribute values.
+ */
+void
+XpGetMaxWidthHeightRes(
+ const char *printer_name,
+ const XpValidatePoolsRec* vpr,
+ float *width,
+ float *height,
+ int* resolution)
+{
+ const char* value;
+ const char* attr_str;
+ XpOidMediumSS* pool_msss;
+ const XpOidMediumSS* msss;
+ int i_mss, i_ds;
+ XpOidMediumDiscreteSizeList* ds_list;
+ float w, h;
+ XpOidCardList* pool_resolutions_supported;
+ const XpOidCardList* resolutions_supported;
+ int i;
+ int res;
+ /*
+ * get the max medium width and height
+ */
+ attr_str = XpOidString(xpoid_att_medium_source_sizes_supported);
+ value = XpGetPrinterAttribute(printer_name, attr_str);
+ pool_msss = XpOidMediumSSNew(value,
+ vpr->valid_input_trays,
+ vpr->valid_medium_sizes);
+ if(0 == XpOidMediumSSCount(pool_msss))
+ msss = XpGetDefaultMediumSS();
+ else
+ msss = pool_msss;
+ *width = *height = 0;
+ for(i_mss = 0; i_mss < XpOidMediumSSCount(msss); i_mss++)
+ {
+ if(XpOidMediumSS_DISCRETE == (msss->mss)[i_mss].mstag
+ &&
+ xpoid_none != (msss->mss)[i_mss].input_tray)
+ {
+ ds_list = (msss->mss)[i_mss].ms.discrete;
+ for(i_ds = 0; i_ds < ds_list->count; i_ds++)
+ {
+ if(xpoid_none != (ds_list->list)[i_ds].page_size)
+ {
+ XpGetMediumMillimeters((ds_list->list)[i_ds].page_size,
+ &w, &h);
+ if(w > *width) *width = w;
+ if(h > *height) *height = h;
+ }
+ }
+ }
+ }
+ XpOidMediumSSDelete(pool_msss);
+ /*
+ * get the maximum resolution
+ */
+ attr_str = XpOidString(xpoid_att_printer_resolutions_supported);
+ value = XpGetPrinterAttribute(printer_name, attr_str);
+ pool_resolutions_supported =
+ XpOidCardListNew(value, vpr->valid_printer_resolutions_supported);
+ if(0 == XpOidCardListCount(pool_resolutions_supported))
+ resolutions_supported = vpr->default_printer_resolutions_supported;
+ else
+ resolutions_supported = pool_resolutions_supported;
+ *resolution = 0;
+ for(i = 0; i < XpOidCardListCount(resolutions_supported); i++)
+ {
+ res = XpOidCardListGetCard(resolutions_supported, i);
+ if(res > *resolution) *resolution = res;
+ }
+ XpOidCardListDelete(pool_resolutions_supported);
+}
+
+FontResolutionPtr
+XpGetClientResolutions(client, num)
+ ClientPtr client;
+ int *num;
+{
+ static struct _FontResolution res;
+ int resolution = XpGetResolution(XpContextOfClient(client));
+
+ res.x_resolution = resolution;
+ res.y_resolution = resolution;
+
+ res.point_size = 120;
+
+ *num = 1;
+
+ return &res;
+}
+
+
+void XpSetFontResFunc(client)
+ ClientPtr client;
+{
+ client->fontResFunc = XpGetClientResolutions;
+}
+
+
+void XpUnsetFontResFunc(client)
+ ClientPtr client;
+{
+ client->fontResFunc = NULL;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl-mono/Imakefile b/nx-X11/programs/Xserver/Xprint/pcl-mono/Imakefile
new file mode 100644
index 000000000..30d577772
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl-mono/Imakefile
@@ -0,0 +1,6 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:09 cpqbld Exp $
+#define PclDriver -DXP_PCL_MONO
+#define LinkDirectory ../pcl
+
+#include "../pcl/Imakefile"
+
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/Imakefile b/nx-X11/programs/Xserver/Xprint/pcl/Imakefile
new file mode 100644
index 000000000..310ae9e20
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/Imakefile
@@ -0,0 +1,76 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:07 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/Xprint/pcl/Imakefile,v 1.7 2001/08/01 00:44:45 tsi Exp $
+
+#include <Server.tmpl>
+
+#ifndef PixelSize
+#define PixelSize 8
+#endif
+
+#ifdef PclDriver
+PCL_DRIVER = PclDriver
+#else
+PCL_DRIVER = -DXP_PCL_COLOR
+#endif
+
+SRCS1 = PclInit.c PclMisc.c PclWindow.c PclFonts.c PclPrint.c \
+ PclArea.c PclArc.c PclGC.c PclLine.c PclPixel.c PclPolygon.c \
+ PclSpans.c PclText.c PclCursor.c PclAttr.c PclPixmap.c PclSFonts.c \
+ PclColor.c PclAttVal.c
+
+OBJS1 = PclInit.o PclMisc.o PclWindow.o PclFonts.o PclPrint.o \
+ PclArea.o PclArc.o PclGC.o PclLine.o PclPixel.o PclPolygon.o \
+ PclSpans.o PclText.o PclCursor.o PclAttr.o PclPixmap.o PclSFonts.o \
+ PclColor.o PclAttVal.o
+
+SRCS = $(SRCS1)
+
+OBJS = $(OBJS1)
+
+DEFINES = -DPSZ=PixelSize $(PCL_DRIVER) -UXFree86LOADER -D_XP_PRINT_SERVER_
+
+ INCLUDES = -I. -I$(XINCLUDESRC) -I.. -I$(LIBSRC) \
+ -I../../include -I$(TOP)/include \
+ -I$(TOP)/include/extensions -I$(TOP)/include/fonts \
+ -I../../mi -I../../mfb -I../../cfb
+
+ LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln \
+ ../../mfb/llib-lmfb.ln ../../mi/llib-lmi.ln \
+ ../../cfb/llib-lcfb.ln
+
+NormalLibraryObjectRule()
+
+NormalLibraryTarget(pcl,$(OBJS))
+NormalLintTarget($(SRCS1) $(SRCS2))
+#ifdef LinkDirectory
+LinkSourceFile(Pcl.h,LinkDirectory)
+LinkSourceFile(Pclmap.h,LinkDirectory)
+LinkSourceFile(PclDef.h,LinkDirectory)
+LinkSourceFile(PclSFonts.h,LinkDirectory)
+
+LinkSourceFile(PclArc.c,LinkDirectory)
+LinkSourceFile(PclArea.c,LinkDirectory)
+LinkSourceFile(PclAttr.c,LinkDirectory)
+LinkSourceFile(PclAttVal.c,LinkDirectory)
+LinkSourceFile(PclColor.c,LinkDirectory)
+LinkSourceFile(PclCursor.c,LinkDirectory)
+LinkSourceFile(PclFonts.c,LinkDirectory)
+LinkSourceFile(PclGC.c,LinkDirectory)
+LinkSourceFile(PclInit.c,LinkDirectory)
+LinkSourceFile(PclLine.c,LinkDirectory)
+LinkSourceFile(PclMisc.c,LinkDirectory)
+LinkSourceFile(PclPixel.c,LinkDirectory)
+LinkSourceFile(PclPixmap.c,LinkDirectory)
+LinkSourceFile(PclPolygon.c,LinkDirectory)
+LinkSourceFile(PclPrint.c,LinkDirectory)
+LinkSourceFile(PclSFonts.c,LinkDirectory)
+LinkSourceFile(PclSpans.c,LinkDirectory)
+LinkSourceFile(PclText.c,LinkDirectory)
+LinkSourceFile(PclWindow.c,LinkDirectory)
+#endif
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/Pcl.h b/nx-X11/programs/Xserver/Xprint/pcl/Pcl.h
new file mode 100644
index 000000000..bb1f52b2c
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/Pcl.h
@@ -0,0 +1,625 @@
+/* $Xorg: Pcl.h,v 1.3 2000/08/17 19:48:07 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: Pcl.h
+** *
+** * Contents: defines and includes for the Pcl driver
+** * for a printing X server.
+** *
+** * Created: 1/30/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/Pcl.h,v 1.12 2001/12/21 21:02:05 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _PCL_H_
+#define _PCL_H_
+
+#include <stdio.h>
+#include "scrnintstr.h"
+
+#include "PclDef.h"
+#include "Pclmap.h"
+#include "PclSFonts.h"
+
+#include <X11/extensions/Print.h>
+#include <X11/extensions/Printstr.h>
+
+#include "regionstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+
+/*
+ * Some sleazes to force the XrmDB stuff into the server
+ */
+#ifndef HAVE_XPointer
+typedef char *XPointer;
+#endif
+#define Status int
+#define True 1
+#define False 0
+#include "misc.h"
+#include <X11/Xfuncproto.h>
+#include <X11/Xresource.h>
+#include "attributes.h"
+
+/******
+ * externally visible variables from PclInit.c
+ ******/
+extern int PclScreenPrivateIndex, PclWindowPrivateIndex;
+extern int PclContextPrivateIndex;
+extern int PclPixmapPrivateIndex;
+extern int PclGCPrivateIndex;
+
+/******
+ * externally visible variables from PclAttVal.c
+ ******/
+extern XpValidatePoolsRec PclValidatePoolsRec;
+
+/*
+ * This structure defines a mapping from an X colormap ID to a list of
+ * print contexts which use the colormap.
+ */
+typedef struct _pclcontextlist {
+ XpContextPtr context;
+ struct _pclcontextlist *next;
+} PclContextList, *PclContextListPtr;
+
+typedef struct _pclcmaptocontexts {
+ long colormapId;
+ PclContextListPtr contexts;
+ struct _pclcmaptocontexts *next;
+} PclCmapToContexts;
+
+typedef struct {
+ PclCmapToContexts *colormaps;
+ CloseScreenProcPtr CloseScreen;
+} PclScreenPrivRec, *PclScreenPrivPtr;
+
+/*
+ * This structure defines a mapping from an X colormap ID to a PCL
+ * palette ID.
+ */
+typedef struct _palettemap {
+ long colormapId;
+ int paletteId;
+ int downloaded;
+ struct _palettemap *next;
+} PclPaletteMap, *PclPaletteMapPtr;
+
+typedef struct {
+ char *jobFileName;
+ FILE *pJobFile;
+ char *pageFileName;
+ FILE *pPageFile;
+ GC lastGC;
+ unsigned char *dash;
+ int validGC;
+ ClientPtr getDocClient;
+ int getDocBufSize;
+ PclSoftFontInfoPtr pSoftFontInfo;
+ PclPaletteMapPtr palettes;
+ int currentPalette;
+ int nextPaletteId;
+ PclPaletteMap staticGrayPalette;
+ PclPaletteMap trueColorPalette;
+ PclPaletteMap specialTrueColorPalette;
+ unsigned char *ctbl;
+ int ctbldim;
+ int isRaw;
+#ifdef XP_PCL_LJ3
+ unsigned int fcount;
+ unsigned int fcount_max;
+ char *figures;
+#endif /* XP_PCL_LJ3 */
+} PclContextPrivRec, *PclContextPrivPtr;
+
+typedef struct {
+ int validContext;
+ XpContextPtr context;
+} PclWindowPrivRec, *PclWindowPrivPtr;
+
+typedef struct {
+ unsigned long stippleFg, stippleBg;
+} PclGCPrivRec, *PclGCPrivPtr;
+
+typedef struct {
+ XpContextPtr context;
+ char *tempFileName;
+ FILE *tempFile;
+ GC lastGC;
+ int validGC;
+} PclPixmapPrivRec, *PclPixmapPrivPtr;
+
+/******
+ * Defined functions
+ ******/
+#define SEND_PCL(f,c) fwrite( c, sizeof( char ), strlen( c ), f )
+#define SEND_PCL_COUNT(f,c,n) fwrite( c, sizeof( char ), n, f )
+
+#ifndef XP_PCL_LJ3
+#define SAVE_PCL(f,p,c) SEND_PCL(f,c)
+#define SAVE_PCL_COUNT(f,p,c,n) SEND_PCL_COUNT(f,c,n)
+#define MACRO_START(f,p) SEND_PCL(f, "\033&f1Y\033&f0X")
+#define MACRO_END(f) SEND_PCL(f, "\033&f1X")
+#else
+#define SAVE_PCL(f,p,c) PclSpoolFigs(p, c, strlen(c))
+#define SAVE_PCL_COUNT(f,p,c,n) PclSpoolFigs(p, c, n)
+#define MACRO_START(f,p) p->fcount = 0
+#define MACRO_END(f) /* do nothing */
+#endif /* XP_PCL_LJ3 */
+
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#ifndef MAX
+#define MAX(a,b) (((a)>(b))?(a):(b))
+#endif
+
+/******
+ * Functions in PclArc.c
+ ******/
+extern void PclPolyArc(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArcs,
+ xArc *pArcs);
+extern void PclPolyFillArc(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArcs,
+ xArc *pArcs);
+
+/******
+ * Functions in PclArea.c
+ ******/
+extern void PclPutImage(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int depth,
+ int x,
+ int y,
+ int w,
+ int h,
+ int leftPad,
+ int format,
+ char *pImage);
+extern RegionPtr PclCopyArea(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx,
+ int dsty);
+RegionPtr PclCopyPlane(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx,
+ int dsty,
+ unsigned long plane);
+
+
+/******
+ * Functions in PclAttr.c
+ ******/
+extern char *PclGetAttributes(
+ XpContextPtr pCon,
+ XPAttributes pool );
+extern char *PclGetOneAttribute(
+ XpContextPtr pCon,
+ XPAttributes pool,
+ char *attr );
+extern int PclAugmentAttributes(
+ XpContextPtr pCon,
+ XPAttributes pool,
+ char *attrs );
+extern int PclSetAttributes(
+ XpContextPtr pCon,
+ XPAttributes pool,
+ char *attrs );
+
+/******
+ * Functions in PclColor.c
+ ******/
+extern Bool PclCreateDefColormap(ScreenPtr pScreen);
+extern Bool PclCreateColormap(ColormapPtr pColor);
+extern void PclDestroyColormap(ColormapPtr pColor);
+extern void PclInstallColormap(ColormapPtr pColor);
+extern void PclUninstallColormap(ColormapPtr pColor);
+extern int PclListInstalledColormaps(ScreenPtr pScreen,
+ XID *pCmapList);
+extern void PclStoreColors(ColormapPtr pColor,
+ int ndef,
+ xColorItem *pdefs);
+extern void PclResolveColor(unsigned short *pRed,
+ unsigned short *pGreen,
+ unsigned short *pBlue,
+ VisualPtr pVisual);
+extern int PclUpdateColormap(DrawablePtr pDrawable,
+ XpContextPtr pCon,
+ GCPtr gc,
+ FILE *outFile);
+extern void PclLookUp(ColormapPtr cmap,
+ PclContextPrivPtr cPriv,
+ unsigned short *r,
+ unsigned short *g,
+ unsigned short *b);
+extern PclPaletteMapPtr PclFindPaletteMap(PclContextPrivPtr cPriv,
+ ColormapPtr cmap,
+ GCPtr gc);
+extern unsigned char *PclReadMap(char *, int *);
+
+
+/******
+ * Functions in PclCursor.c
+ ******/
+extern void PclConstrainCursor(
+ ScreenPtr pScreen,
+ BoxPtr pBox);
+extern void PclCursorLimits(
+ ScreenPtr pScreen,
+ CursorPtr pCursor,
+ BoxPtr pHotBox,
+ BoxPtr pTopLeftbox);
+extern Bool PclDisplayCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor);
+extern Bool PclRealizeCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor);
+extern Bool PclUnrealizeCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor);
+extern void PclRecolorCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor,
+ Bool displayed);
+extern Bool PclSetCursorPosition(
+ ScreenPtr pScreen,
+ int x,
+ int y,
+ Bool generateEvent);
+
+/******
+ * Functions in PclSFonts.c
+ ******/
+extern void
+PclDownloadSoftFont8(
+ FILE *fp,
+ PclSoftFontInfoPtr pSoftFontInfo,
+ PclFontHead8Ptr pfh,
+ PclCharDataPtr pcd,
+ unsigned char *code);
+extern void PclDownloadSoftFont16(
+ FILE *fp,
+ PclSoftFontInfoPtr pSoftFontInfo,
+ PclFontHead16Ptr pfh,
+ PclCharDataPtr pcd,
+ unsigned char row,
+ unsigned char col);
+extern PclSoftFontInfoPtr PclCreateSoftFontInfo(void);
+extern void PclDestroySoftFontInfo(
+ PclSoftFontInfoPtr pSoftFontInfo );
+
+/******
+ * Functions in PclGC.c
+ ******/
+extern Bool PclCreateGC(GCPtr pGC);
+extern void PclDestroyGC(GCPtr pGC);
+extern int PclUpdateDrawableGC(
+ GCPtr pGC,
+ DrawablePtr pDrawable,
+ FILE **outFile);
+extern void PclValidateGC(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDrawable);
+extern void PclSetDrawablePrivateStuff(
+ DrawablePtr pDrawable,
+ GC gc );
+extern int PclGetDrawablePrivateStuff(
+ DrawablePtr pDrawable,
+ GC *gc,
+ unsigned long *valid,
+ FILE **file );
+extern void PclSetDrawablePrivateGC(
+ DrawablePtr pDrawable,
+ GC gc);
+extern void PclComputeCompositeClip(
+ GCPtr pGC,
+ DrawablePtr pDrawable);
+
+/******
+ * Functions in PclInit.c
+ ******/
+extern Bool PclCloseScreen(
+ int index,
+ ScreenPtr pScreen);
+extern Bool InitializeColorPclDriver(
+ int ndx,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv);
+extern Bool InitializeMonoPclDriver(
+ int ndx,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv);
+extern Bool InitializeLj3PclDriver(
+ int ndx,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv);
+extern XpContextPtr PclGetContextFromWindow( WindowPtr win );
+
+/******
+ * Functions in PclLine.c
+ ******/
+extern void PclPolyLine(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int nPoints,
+ xPoint *pPoints);
+extern void PclPolySegment(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nSegments,
+ xSegment *pSegments);
+
+/******
+ * Functions in PclMisc.c
+ ******/
+extern void PclQueryBestSize(
+ int class,
+ short *pwidth,
+ short *pheight,
+ ScreenPtr pScreen);
+extern char *GetPropString(WindowPtr pWin, char *propName);
+extern int SystemCmd(char *cmdStr);
+extern int PclGetMediumDimensions(
+ XpContextPtr pCon,
+ CARD16 *pWidth,
+ CARD16 *pHeight);
+extern int PclGetReproducibleArea(
+ XpContextPtr pCon,
+ xRectangle *pRect);
+extern void PclSendData(
+ FILE *outFile,
+ PclContextPrivPtr pConPriv,
+ BoxPtr pbox,
+ int nbox,
+ double ratio);
+
+/******
+ * Functions in PclPixel.c
+ ******/
+extern void PclPolyPoint(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int nPoints,
+ xPoint *pPoints);
+extern void PclPushPixels(
+ GCPtr pGC,
+ PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int width,
+ int height,
+ int x,
+ int y);
+
+/******
+ * Functions in PclPixmap.c
+ ******/
+extern PixmapPtr PclCreatePixmap(
+ ScreenPtr pScreen,
+ int width,
+ int height,
+ int depth);
+extern Bool PclDestroyPixmap(PixmapPtr pPixmap);
+
+/******
+ * Functions in PclPolygon.c
+ ******/
+extern void PclPolyRectangle(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nRects,
+ xRectangle *pRects);
+extern void PclFillPolygon(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int nPoints,
+ DDXPointPtr pPoints);
+extern void PclPolyFillRect(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nRects,
+ xRectangle *pRects);
+
+/******
+ * Functions in PclSpans.c
+ ******/
+extern void PclFillSpans(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nSpans,
+ DDXPointPtr pPoints,
+ int *pWidths,
+ int fSorted);
+extern void PclSetSpans(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *pSrc,
+ DDXPointPtr pPoints,
+ int *pWidths,
+ int nSpans,
+ int fSorted);
+
+/******
+ * Functions in PclText.c
+ ******/
+extern int PclPolyText8(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *string);
+extern int PclPolyText16(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *string);
+extern void PclImageText8(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *string);
+extern void PclImageText16(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *string);
+extern void PclImageGlyphBlt(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nGlyphs,
+ CharInfoPtr *pCharInfo,
+ pointer pGlyphBase);
+extern void PclPolyGlyphBlt(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nGlyphs,
+ CharInfoPtr *pCharInfo,
+ pointer pGlyphBase);
+
+/******
+ * Functions in PclWindow.c
+ ******/
+extern Bool PclCreateWindow(register WindowPtr pWin);
+extern Bool PclDestroyWindow(WindowPtr pWin);
+extern Bool PclMapWindow(WindowPtr pWindow);
+extern Bool PclPositionWindow(
+ register WindowPtr pWin,
+ int x,
+ int y);
+extern Bool PclUnmapWindow(WindowPtr pWindow);
+extern void PclCopyWindow(
+ WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc);
+extern Bool PclChangeWindowAttributes(
+ register WindowPtr pWin,
+ register unsigned long mask);
+extern void PclPaintWindow(
+ WindowPtr pWin,
+ RegionPtr pRegion,
+ int what);
+
+/******
+ * Functions in PclFonts.c
+ ******/
+extern Bool PclRealizeFont(
+ ScreenPtr pscr,
+ FontPtr pFont);
+extern Bool PclUnrealizeFont(
+ ScreenPtr pscr,
+ FontPtr pFont);
+
+/******
+ * Functions in PclPrint.c
+ ******/
+extern int PclStartJob(
+ XpContextPtr pCon,
+ Bool sendClientData,
+ ClientPtr client);
+extern int PclEndJob(
+ XpContextPtr pCon,
+ Bool cancel);
+extern int PclStartPage(
+ XpContextPtr pCon,
+ WindowPtr pWin);
+extern int PclEndPage(
+ XpContextPtr pCon,
+ WindowPtr pWin);
+extern int PclStartDoc(XpContextPtr pCon,
+ XPDocumentType type);
+extern int PclEndDoc(
+ XpContextPtr pCon,
+ Bool cancel);
+extern int PclDocumentData(
+ XpContextPtr pCon,
+ DrawablePtr pDraw,
+ char *pData,
+ int len_data,
+ char *pFmt,
+ int len_fmt,
+ char *pOpt,
+ int len_opt,
+ ClientPtr client);
+extern int PclGetDocumentData(
+ XpContextPtr pCon,
+ ClientPtr client,
+ int maxBufferSize);
+
+
+#endif /* _PCL_H_ */
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclArc.c b/nx-X11/programs/Xserver/Xprint/pcl/PclArc.c
new file mode 100644
index 000000000..d675e1699
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclArc.c
@@ -0,0 +1,270 @@
+/* $Xorg: PclArc.c,v 1.3 2000/08/17 19:48:07 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclArc.c
+** *
+** * Contents:
+** * Arc-drawing code for the PCL DDX driver
+** *
+** * Created: 10/23/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclArc.c,v 1.4 1999/12/13 02:12:53 robin Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <math.h>
+#include <errno.h>
+
+#include "Pcl.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "attributes.h"
+
+static void
+PclDoArc(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArcs,
+ xArc *pArcs,
+ void (*DoIt)(FILE *, PclContextPrivPtr, double, double, xArc))
+{
+ char t[80];
+ FILE *outFile;
+ int nbox, i;
+ BoxPtr pbox;
+ BoxRec r;
+ RegionPtr drawRegion, region, transClip;
+ short fudge;
+ int xoffset, yoffset;
+ XpContextPtr pCon;
+ PclContextPrivPtr pConPriv;
+ xRectangle repro;
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return;
+
+ fudge = 3 * pGC->lineWidth;
+
+ pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
+ pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+ XpGetReproductionArea( pCon, &repro );
+
+ /*
+ * Generate the PCL code to draw the collection of arcs, by
+ * defining it as a macro which uses the HP-GL/2 arc drawing
+ * function.
+ */
+
+ xoffset = pDrawable->x;
+ yoffset = pDrawable->y;
+
+ for( i = 0; i < nArcs; i++ )
+ {
+ xArc Arc = pArcs[i];
+ double b, X, Y, ratio;
+ double angle1;
+
+ MACRO_START( outFile, pConPriv );
+ SAVE_PCL( outFile, pConPriv, "\033%0B" );
+
+ /* Calculate the start of the arc */
+ if( ( Arc.angle1 / 64 ) % 360 == 90 )
+ {
+ X = 0;
+ Y = -Arc.height / 2.0;
+ }
+ else if( ( Arc.angle1 / 64 ) % 360 == 270 )
+ {
+ X = 0;
+ Y = Arc.height / 2.0;
+ }
+ else
+ {
+ /* Convert the angle to radians */
+ angle1 = ( Arc.angle1 / 64.0 ) * 3.141592654 / 180.0;
+
+ b = (Arc.height / 2.0);
+ X = b * cos( angle1 );
+ Y = -b * sin( angle1 );
+ }
+
+ /* Change the coordinate system to scale the ellipse */
+ ratio = (double)Arc.height / (double)Arc.width;
+
+ sprintf( t, "SC%.2f,%.2f,%d,%d;",
+ (repro.x - Arc.width / 2 - xoffset - Arc.x) * ratio,
+ (repro.x - Arc.width / 2 - xoffset - Arc.x +
+ repro.width) * ratio,
+ repro.y - Arc.height / 2 - yoffset - Arc.y + repro.height,
+ repro.y - Arc.height / 2 - yoffset - Arc.y);
+ SAVE_PCL( outFile, pConPriv, t );
+
+ DoIt( outFile, pConPriv, X, Y, Arc );
+
+ /* Build the bounding box */
+ r.x1 = -Arc.width / 2 - fudge;
+ r.y1 = -Arc.height / 2 - fudge;
+ r.x2 = Arc.width / 2 + fudge;
+ r.y2 = Arc.height / 2 + fudge;
+ drawRegion = REGION_CREATE( pGC->pScreen, &r, 0 );
+
+ SAVE_PCL( outFile, pConPriv, "\033%0A" );
+ MACRO_END( outFile );
+
+ /*
+ * Intersect the bounding box with the clip region.
+ */
+ region = REGION_CREATE( pGC->pScreen, NULL, 0 );
+ transClip = REGION_CREATE( pGC->pScreen, NULL, 0 );
+ REGION_COPY( pGC->pScreen, transClip, pGC->pCompositeClip );
+ REGION_TRANSLATE( pGC->pScreen, transClip,
+ -(xoffset + Arc.x + Arc.width / 2),
+ -(yoffset + Arc.y + Arc.height / 2) );
+ REGION_INTERSECT( pGC->pScreen, region, drawRegion, transClip );
+
+ /*
+ * For each rectangle in the clip region, set the HP-GL/2 "input
+ * window" and render the collection of arcs to it.
+ */
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ PclSendData(outFile, pConPriv, pbox, nbox, ratio);
+
+ /*
+ * Restore the coordinate system
+ */
+ sprintf( t, "\033%%0BSC%d,%d,%d,%d;\033%%0A", repro.x,
+ repro.x + repro.width, repro.y + repro.height,
+ repro.y );
+ SEND_PCL( outFile, t );
+
+ /*
+ * Clean up the temporary regions
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+ REGION_DESTROY( pGC->pScreen, transClip );
+ }
+}
+
+/*
+ * Draw a simple non-filled arc, centered on the origin and starting
+ * at the given point.
+ */
+static void
+DrawArc(FILE *outFile,
+ PclContextPrivPtr pConPriv,
+ double X,
+ double Y,
+ xArc A)
+{
+ char t[80];
+
+ sprintf( t, "PU%d,%d;PD;AA0,0,%.2f;", (int)X, (int)Y,
+ (float)A.angle2 / -64.0 );
+ SAVE_PCL(outFile, pConPriv, t);
+}
+
+void
+PclPolyArc(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArcs,
+ xArc *pArcs)
+{
+ PclDoArc( pDrawable, pGC, nArcs, pArcs, DrawArc );
+}
+
+/*
+ * Draw a filled wedge, from the origin, to the given point, through
+ * the appropriate angle, and back to the origin.
+ */
+static void
+DoWedge(FILE *outFile,
+ PclContextPrivPtr pConPriv,
+ double X,
+ double Y,
+ xArc A)
+{
+ char t[80];
+
+ sprintf( t, "PU0,0;WG%.2f,%.2f,%.2f;", sqrt( X * X + Y * Y ),
+ (float)A.angle1 / -64.0,
+ (float)A.angle2 / -64.0 );
+ SAVE_PCL(outFile, pConPriv, t);
+}
+
+static void
+DoChord(FILE *outFile,
+ PclContextPrivPtr pConPriv,
+ double X,
+ double Y,
+ xArc A)
+{
+ char t[80];
+
+ sprintf( t, "PU%d,%d;PM0;AA0,0,%.2f;PA%d,%d;PM2;FP;", (int)X, (int)Y,
+ (float)A.angle2 / -64.0 , (int)X, (int)Y );
+ SAVE_PCL(outFile, pConPriv, t);
+}
+
+
+void
+PclPolyFillArc(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArcs,
+ xArc *pArcs)
+{
+ switch( pGC->arcMode )
+ {
+ case ArcChord:
+ PclDoArc( pDrawable, pGC, nArcs, pArcs, DoChord );
+ break;
+ case ArcPieSlice:
+ PclDoArc( pDrawable, pGC, nArcs, pArcs, DoWedge );
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclArea.c b/nx-X11/programs/Xserver/Xprint/pcl/PclArea.c
new file mode 100644
index 000000000..cfed7c866
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclArea.c
@@ -0,0 +1,486 @@
+/* $Xorg: PclArea.c,v 1.3 2000/08/17 19:48:07 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclArea.c
+** *
+** * Contents:
+** * Image and Area functions for the PCL DDX driver
+** *
+** * Created: 10/23/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclArea.c,v 1.8 2001/01/17 22:36:30 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "Pcl.h"
+#include "pixmapstr.h"
+#include "region.h"
+
+#include "cfb.h"
+#if 1
+#include "cfb32.h"
+#endif
+
+void
+PclPutImage(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int depth,
+ int x,
+ int y,
+ int w,
+ int h,
+ int leftPad,
+ int format,
+ char *pImage)
+{
+ PixmapPtr pPixmap;
+ unsigned long oldFg, oldBg;
+ XID gcv[3];
+ unsigned long oldPlanemask;
+ unsigned long i;
+ long bytesPer;
+
+ if( ( w == 0 ) || ( h == 0 ) )
+ return;
+
+ if( format != XYPixmap )
+ {
+ pPixmap = GetScratchPixmapHeader( pDrawable->pScreen,
+ w+leftPad, h, depth,
+ BitsPerPixel( depth ),
+ PixmapBytePad( w + leftPad,
+ depth ), (pointer)pImage );
+ if( !pPixmap )
+ return;
+
+ if( format == ZPixmap )
+ (void)(*pGC->ops->CopyArea)( (DrawablePtr)pPixmap, pDrawable, pGC,
+ leftPad, 0, w, h, x, y );
+ else
+ (void)(*pGC->ops->CopyPlane)( (DrawablePtr)pPixmap, pDrawable, pGC,
+ leftPad, 0, w, h, x, y, 1 );
+ FreeScratchPixmapHeader( pPixmap );
+ }
+ else
+ {
+ pPixmap = GetScratchPixmapHeader( pDrawable->pScreen,
+ w+leftPad, h, depth,
+ BitsPerPixel( depth ),
+ PixmapBytePad( w + leftPad,
+ depth ), (pointer)pImage );
+
+ if( !pPixmap )
+ return;
+
+ depth = pGC->depth;
+ oldPlanemask = pGC->planemask;
+ oldFg = pGC->fgPixel;
+ oldBg = pGC->bgPixel;
+ gcv[0] = ~0L;
+ gcv[1] = 0;
+ DoChangeGC( pGC, GCForeground | GCBackground, gcv, 0 );
+ bytesPer = (long)h * BitmapBytePad( w + leftPad );
+
+ for( i = 1 << (depth-1); i != 0; i >>= 1, pImage += bytesPer )
+ {
+ if( i & oldPlanemask )
+ {
+ gcv[0] = i;
+ DoChangeGC( pGC, GCPlaneMask, gcv, 0 );
+ ValidateGC( pDrawable, pGC );
+ if (pPixmap->drawable.depth <= 8 )
+ cfbPutImage( (DrawablePtr)pPixmap, pGC, 1, x, y, w, h,
+ leftPad, XYBitmap, pImage );
+ else if (pPixmap->drawable.depth <= 32 )
+ cfb32PutImage( (DrawablePtr)pPixmap, pGC, 1, x, y, w, h,
+ leftPad, XYBitmap, pImage );
+ }
+ }
+ gcv[0] = oldPlanemask;
+ gcv[1] = oldFg;
+ gcv[2] = oldBg;
+ DoChangeGC( pGC, GCPlaneMask | GCForeground | GCBackground,
+ gcv, 0 );
+
+ PclCopyArea( (DrawablePtr)pPixmap, pDrawable, pGC, leftPad,
+ 0, w, h, x, y );
+ FreeScratchPixmapHeader( pPixmap );
+ }
+}
+
+/*
+ * PclMonoPixmapFragment()
+ *
+ * Given a 1-bit-deep pixmap, send the appropriate part of it to the
+ * output file as a PCL raster graphics command.
+ */
+static void
+PclMonoPixmapFragment(FILE *outFile,
+ PixmapPtr pix,
+ short x1,
+ short y1,
+ short x2,
+ short y2,
+ short dstx,
+ short dsty)
+{
+ char *bits, t[80], *row;
+ int h, w, i;
+
+ /*
+ * Create a storage area large enough to hold the entire pixmap,
+ * then use mfbGetImage to get the appropriate bits.
+ */
+ h = y2 - y1;
+ w = BitmapBytePad( x2 - x1 );
+
+ bits = (char *)xalloc( h * w );
+ mfbGetImage( (DrawablePtr)pix, x1, y1, x2 - x1, h,
+ XYPixmap, ~0, bits );
+
+ /*
+ * Move the cursor to the appropriate place on the page. We have
+ * to jump into HP-GL/2 to do this correctly, then go back to PCL
+ * for the actual drawing.
+ */
+ sprintf( t, "\033%%0BPU%d,%d;\033%%1A", dstx, dsty );
+ SEND_PCL( outFile, t );
+
+ /*
+ * Now, wrap the raster in the appropriate PCL code. Right now,
+ * it's going to go down the wire without any compression. That
+ * will have to be good enough for the sample implementation.
+ */
+ sprintf( t, "\033*t300R\033*r%dT\033*r%dS\033*r1A\033*b0M",
+ h, x2 - x1 );
+ SEND_PCL( outFile, t );
+
+ sprintf( t, "\033*b%dW", w );
+ for( row = bits, i = 0; i <= h; i++, row += w )
+ {
+ SEND_PCL( outFile, t );
+ SEND_PCL_COUNT( outFile, row, w );
+ }
+
+ SEND_PCL( outFile, "\033*rC" );
+
+ /*
+ * Clean things up a bit
+ */
+ xfree( bits );
+}
+
+static void
+PclColorPixmapFragment(FILE *outFile,
+ PixmapPtr pix,
+ short x1,
+ short y1,
+ short x2,
+ short y2,
+ short dstx,
+ short dsty)
+{
+ char *bits, t[80], *row;
+ int h, w, i;
+
+ /*
+ * Create a storage area large enough to hold the entire pixmap,
+ * then use cfbGetImage to get the appropriate bits.
+ */
+ h = y2 - y1;
+ w = PixmapBytePad( x2 - x1, pix->drawable.depth );
+
+ bits = (char *)xalloc( h * w );
+ if (pix->drawable.depth <= 8)
+ cfbGetImage( (DrawablePtr)pix, x1, y1, x2 - x1, h,
+ ZPixmap, ~0, bits );
+ else if (pix->drawable.depth <= 32)
+ cfb32GetImage( (DrawablePtr)pix, x1, y1, x2 - x1, h,
+ ZPixmap, ~0, bits );
+
+ /*
+ * Move the cursor to the appropriate place on the page. We have
+ * to jump into HP-GL/2 to do this correctly, then go back to PCL
+ * for the actual drawing.
+ */
+ sprintf( t, "\033%%0BPU%d,%d;\033%%1A", dstx, dsty );
+ SEND_PCL( outFile, t );
+
+ /*
+ * Now, wrap the raster in the appropriate PCL code. Right now,
+ * it's going to go down the wire without any compression. That
+ * will have to be good enough for the sample implementation.
+ */
+ sprintf( t, "\033*t300R\033*r%dt%ds1A\033*b0M",
+ h, x2 - x1 );
+ SEND_PCL( outFile, t );
+
+ sprintf( t, "\033*b%dW", w );
+ for( row = bits, i = 0; i < h; i++, row += w )
+ {
+ SEND_PCL( outFile, t );
+ SEND_PCL_COUNT( outFile, row, w );
+ }
+
+ SEND_PCL( outFile, "\033*rC" );
+
+ /*
+ * Clean things up a bit
+ */
+ xfree( bits );
+}
+
+RegionPtr
+PclCopyArea(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx,
+ int dsty)
+{
+ PixmapPtr pixSrc = (PixmapPtr)pSrc;
+/*
+ FILE *srcFile;
+ GC srcGC;
+*/
+ FILE *dstFile;
+ GC dstGC;
+ unsigned long valid;
+ RegionPtr drawRegion, region, whole, ret;
+ BoxRec box;
+ BoxPtr prect;
+ int nrect;
+ void (*doFragment)(FILE *, PixmapPtr, short, short, short, short,
+ short, short );
+
+ /*
+ * Since we don't store any information on a per-window basis, we
+ * can't copy from a window.
+ */
+ if( pSrc->type == DRAWABLE_WINDOW )
+ return NULL;
+
+ /*
+ * If we're copying from a pixmap to a pixmap, we just use the
+ * mfb/cfb code to do the work.
+ */
+ if( pDst->type == DRAWABLE_PIXMAP )
+ {
+ if( pSrc->depth == 1 )
+ return mfbCopyArea( pSrc, pDst, pGC, srcx, srcy, width,
+ height, dstx, dsty );
+ else if( pSrc->depth <= 8 )
+ return cfbCopyArea( pSrc, pDst, pGC, srcx, srcy, width,
+ height, dstx, dsty );
+ else if( pSrc->depth <= 32 )
+ return cfb32CopyArea( pSrc, pDst, pGC, srcx, srcy, width,
+ height, dstx, dsty );
+ }
+
+/*
+ PclGetDrawablePrivateStuff( pSrc, &srcGC, &valid, &srcFile );
+*/
+ PclGetDrawablePrivateStuff( pDst, &dstGC, &valid, &dstFile );
+
+ /*
+ * If we're copying to a window, we have to do some actual
+ * drawing, instead of just handing it off to mfb or cfb. Start
+ * by determining the region that will be drawn.
+ */
+ box.x1 = srcx;
+ box.y1 = srcy;
+ box.x2 = srcx + width;
+ box.y2 = srcy + height;
+ drawRegion = REGION_CREATE( pGC->pScreen, &box, 0 );
+ REGION_TRANSLATE( pGC->pScreen, drawRegion, dstx, dsty );
+
+ region = REGION_CREATE( pGC->pScreen, NULL, 0 );
+ REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip );
+
+ /*
+ * Now select the operation to be performed on each box in the
+ * region.
+ */
+ if( pSrc->depth == 1 )
+ doFragment = PclMonoPixmapFragment;
+ else
+ doFragment = PclColorPixmapFragment;
+
+ /*
+ * Actually draw each section of the bitmap.
+ */
+ nrect = REGION_NUM_RECTS( region );
+ prect = REGION_RECTS( region );
+
+ while( nrect )
+ {
+ (*doFragment)( dstFile, (PixmapPtr)pSrc, prect->x1 - dstx,
+ prect->y1 - dsty, prect->x2 - dstx,
+ prect->y2 - dsty, prect->x1, prect->y1 );
+
+ nrect--;
+ prect++;
+ }
+
+ /*
+ * Update the destination's GC to the source's GC.
+ */
+/*
+ PclSetDrawablePrivateGC( pDst, srcGC );
+*/
+
+ /*
+ * Determine the region that needs to be returned. This is the
+ * region of the source that falls outside the boundary of the
+ * pixmap.
+ */
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pixSrc->drawable.width;
+ box.y2 = pixSrc->drawable.height;
+ whole = REGION_CREATE( pGC->pScreen, &box, 0 );
+ ret = REGION_CREATE( pGC->pScreen, NULL, 0 );
+
+ REGION_TRANSLATE( pGC->pScreen, drawRegion, -dstx, -dsty );
+ REGION_SUBTRACT( pGC->pScreen, ret, drawRegion, whole );
+
+ /*
+ * Clean up the regions
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+ REGION_DESTROY( pGC->pScreen, whole );
+
+ if( REGION_NOTEMPTY( pGC->pScreen, ret ) )
+ return ret;
+ else
+ {
+ REGION_DESTROY( pGC->pScreen, ret );
+ return NULL;
+ }
+}
+
+RegionPtr
+PclCopyPlane(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx,
+ int dsty,
+ unsigned long plane)
+{
+ RegionPtr reg;
+ GCPtr scratchGC;
+ PixmapPtr scratchPix;
+
+ /*
+ * Since we don't store PCL on a per-window basis, there's no good
+ * way to copy from a window.
+ */
+ if( pSrc->type == DRAWABLE_WINDOW )
+ return NULL;
+
+ /*
+ * Copying from a pixmap to a pixmap is already implemented by
+ * mfb/cfb.
+ */
+ if( pSrc->type == DRAWABLE_PIXMAP &&
+ pDst->type == DRAWABLE_PIXMAP )
+ {
+ if( pDst->depth == 1 )
+ return mfbCopyPlane( pSrc, pDst, pGC, srcx, srcy, width,
+ height, dstx, dsty, plane );
+ else if( pDst->depth <= 8 )
+ return cfbCopyPlane( pSrc, pDst, pGC, srcx, srcy, width,
+ height, dstx, dsty, plane );
+ else if( pDst->depth <= 32 )
+ return cfb32CopyPlane( pSrc, pDst, pGC, srcx, srcy, width,
+ height, dstx, dsty, plane );
+ }
+
+ /*
+ * We can use the mfb/cfbCopyPlane function to do the work of grabbing
+ * the plane and converting it to the desired visual. Once that's
+ * done, we already know how to do a CopyArea.
+ */
+ scratchPix = (*pDst->pScreen->CreatePixmap)( pDst->pScreen, width,
+ height, pDst->depth );
+
+ scratchGC = GetScratchGC( pDst->depth, pDst->pScreen );
+ CopyGC( pGC, scratchGC, ~0L );
+
+ if( pDst->depth == 1 )
+ {
+ mfbValidateGC( scratchGC, ~0L, (DrawablePtr)scratchPix );
+ mfbCopyPlane( pSrc, (DrawablePtr)scratchPix, scratchGC,
+ srcx, srcy, width, height, 0, 0, plane );
+ }
+ else if( pDst->depth <= 8 )
+ {
+ cfbValidateGC( scratchGC, ~0L, (DrawablePtr)scratchPix );
+ cfbCopyPlane( pSrc, (DrawablePtr)scratchPix, scratchGC,
+ srcx, srcy, width, height, 0, 0, plane );
+ }
+ else if( pDst->depth <= 32 )
+ {
+ cfb32ValidateGC( scratchGC, ~0L, (DrawablePtr)scratchPix );
+ cfb32CopyPlane( pSrc, (DrawablePtr)scratchPix, scratchGC,
+ srcx, srcy, width, height, 0, 0, plane );
+ }
+
+ reg = PclCopyArea( (DrawablePtr)scratchPix, pDst, pGC, 0, 0, width,
+ height, dstx, dsty );
+
+ FreeScratchGC( scratchGC );
+
+ (*pDst->pScreen->DestroyPixmap)( scratchPix );
+
+ return reg;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclAttVal.c b/nx-X11/programs/Xserver/Xprint/pcl/PclAttVal.c
new file mode 100644
index 000000000..adbd197fd
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclAttVal.c
@@ -0,0 +1,207 @@
+/*
+ * $Xorg: PclAttVal.c,v 1.3 2000/08/17 19:48:07 cpqbld Exp $
+ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Pcl.h"
+#include "AttrValid.h"
+
+/*
+ * define valid values and defaults for Printer pool
+ */
+static XpOid ValidContentOrientationsOids[] = {
+ xpoid_val_content_orientation_portrait,
+ xpoid_val_content_orientation_landscape,
+ xpoid_val_content_orientation_reverse_portrait,
+ xpoid_val_content_orientation_reverse_landscape
+};
+static XpOidList ValidContentOrientations = {
+ ValidContentOrientationsOids, XpNumber(ValidContentOrientationsOids)
+};
+
+static XpOid DefaultContentOrientationsOids[] = {
+ xpoid_val_content_orientation_portrait,
+ xpoid_val_content_orientation_landscape
+};
+static XpOidList DefaultContentOrientations = {
+ DefaultContentOrientationsOids, XpNumber(DefaultContentOrientationsOids)
+};
+
+static XpOid ValidPlexesOids[] = {
+ xpoid_val_plex_simplex, xpoid_val_plex_duplex, xpoid_val_plex_tumble
+};
+static XpOidList ValidPlexes = {
+ ValidPlexesOids, XpNumber(ValidPlexesOids)
+};
+
+static XpOid DefaultPlexesOids[] = {
+ xpoid_val_plex_simplex
+};
+static XpOidList DefaultPlexes = {
+ DefaultPlexesOids, XpNumber(DefaultPlexesOids)
+};
+
+static unsigned long ValidPrinterResolutionsCards[] = {
+ 300
+};
+static XpOidCardList ValidPrinterResolutions = {
+ ValidPrinterResolutionsCards, XpNumber(ValidPrinterResolutionsCards)
+};
+
+static unsigned long DefaultPrinterResolutionsCards[] = {
+ 300
+};
+static XpOidCardList DefaultPrinterResolutions = {
+ DefaultPrinterResolutionsCards, XpNumber(DefaultPrinterResolutionsCards)
+};
+
+static XpOid ValidListfontsModesOids[] = {
+ xpoid_val_xp_list_internal_printer_fonts, xpoid_val_xp_list_glyph_fonts
+};
+static XpOidList ValidListfontsModes = {
+ ValidListfontsModesOids, XpNumber(ValidListfontsModesOids)
+};
+
+static XpOid DefaultListfontsModesOids[] = {
+ xpoid_val_xp_list_glyph_fonts
+};
+static XpOidList DefaultListfontsModes = {
+ DefaultListfontsModesOids, XpNumber(DefaultListfontsModesOids)
+};
+
+static XpOid ValidSetupProvisoOids[] = {
+ xpoid_val_xp_setup_mandatory, xpoid_val_xp_setup_optional
+};
+static XpOidList ValidSetupProviso = {
+
+
+ ValidSetupProvisoOids, XpNumber(ValidSetupProvisoOids)
+};
+
+static XpOidDocFmt ValidDocFormatsSupportedFmts[] = {
+ { "PCL", "5", NULL },
+};
+static XpOidDocFmtList ValidDocFormatsSupported = {
+ ValidDocFormatsSupportedFmts, XpNumber(ValidDocFormatsSupportedFmts)
+};
+
+static XpOidDocFmt DefaultDocFormatsSupportedFmts[] = {
+ { "PCL", "5", NULL }
+};
+static XpOidDocFmtList DefaultDocFormatsSupported = {
+ DefaultDocFormatsSupportedFmts, XpNumber(DefaultDocFormatsSupportedFmts)
+};
+
+static XpOidDocFmt ValidEmbeddedFormatsSupportedFmts[] = {
+ { "HPGL", "2", NULL },
+};
+static XpOidDocFmtList ValidEmbeddedFormatsSupported = {
+ ValidEmbeddedFormatsSupportedFmts, XpNumber(ValidEmbeddedFormatsSupportedFmts)
+};
+
+static XpOidDocFmt DefaultEmbeddedFormatsSupportedFmts[] = {
+ { "HPGL", "2", NULL }
+};
+static XpOidDocFmtList DefaultEmbeddedFormatsSupported = {
+ DefaultEmbeddedFormatsSupportedFmts, XpNumber(DefaultEmbeddedFormatsSupportedFmts)
+};
+
+static XpOidDocFmt ValidRawFormatsSupportedFmts[] = {
+ { "PCL", "5", NULL },
+ { "Postscript", "2", NULL },
+ { "ASCII", NULL, NULL }
+
+};
+static XpOidDocFmtList ValidRawFormatsSupported = {
+ ValidRawFormatsSupportedFmts, XpNumber(ValidRawFormatsSupportedFmts)
+};
+
+static XpOidDocFmt DefaultRawFormatsSupportedFmts[] = {
+ { "PCL", "5", NULL }
+};
+static XpOidDocFmtList DefaultRawFormatsSupported = {
+ DefaultRawFormatsSupportedFmts, XpNumber(DefaultRawFormatsSupportedFmts)
+};
+
+static XpOid ValidInputTraysOids[] = {
+ xpoid_val_input_tray_manual,
+ xpoid_val_input_tray_main,
+ xpoid_val_input_tray_envelope,
+ xpoid_val_input_tray_large_capacity,
+ xpoid_val_input_tray_bottom
+};
+static XpOidList ValidInputTrays = {
+ ValidInputTraysOids, XpNumber(ValidInputTraysOids)
+};
+
+static XpOid ValidMediumSizesOids[] = {
+ xpoid_val_medium_size_iso_a3,
+ xpoid_val_medium_size_iso_a4,
+ xpoid_val_medium_size_na_letter,
+ xpoid_val_medium_size_na_legal,
+ xpoid_val_medium_size_executive,
+ xpoid_val_medium_size_ledger,
+ xpoid_val_medium_size_iso_c5,
+ xpoid_val_medium_size_iso_designated_long,
+ xpoid_val_medium_size_na_number_10_envelope,
+ xpoid_val_medium_size_monarch_envelope,
+ xpoid_val_medium_size_jis_b5,
+};
+static XpOidList ValidMediumSizes = {
+ ValidMediumSizesOids, XpNumber(ValidMediumSizesOids)
+};
+
+static XpOidDocFmt DefaultDocumentFormat = {
+ "PCL", "5", NULL
+};
+
+
+/*
+ * init struct for XpValidate*Pool
+ */
+XpValidatePoolsRec PclValidatePoolsRec = {
+ &ValidContentOrientations, &DefaultContentOrientations,
+ &ValidDocFormatsSupported, &DefaultDocFormatsSupported,
+ &ValidInputTrays, &ValidMediumSizes,
+ &ValidPlexes, &DefaultPlexes,
+ &ValidPrinterResolutions, &DefaultPrinterResolutions,
+ &ValidEmbeddedFormatsSupported, &DefaultEmbeddedFormatsSupported,
+ &ValidListfontsModes, &DefaultListfontsModes,
+ &ValidRawFormatsSupported, &DefaultRawFormatsSupported,
+ &ValidSetupProviso,
+ &DefaultDocumentFormat
+};
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclAttr.c b/nx-X11/programs/Xserver/Xprint/pcl/PclAttr.c
new file mode 100644
index 000000000..3cde053f1
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclAttr.c
@@ -0,0 +1,87 @@
+/* $Xorg: PclAttr.c,v 1.3 2000/08/17 19:48:07 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclAttr.c
+** *
+** * Contents:
+** * Attribute-handling functions for the PCL driver
+** *
+** * Created: 2/2/96
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Pcl.h"
+#include "attributes.h"
+
+char *
+PclGetAttributes(
+ XpContextPtr pCon,
+ XPAttributes pool )
+{
+ return XpGetAttributes( pCon, pool );
+}
+
+char *
+PclGetOneAttribute(
+ XpContextPtr pCon,
+ XPAttributes pool,
+ char *attr )
+{
+ return XpGetOneAttribute( pCon, pool, attr );
+}
+int
+PclAugmentAttributes(
+ XpContextPtr pCon,
+ XPAttributes pool,
+ char *attrs )
+{
+ return XpAugmentAttributes( pCon, pool, attrs );
+}
+
+int
+PclSetAttributes(
+ XpContextPtr pCon,
+ XPAttributes pool,
+ char *attrs )
+{
+ return XpSetAttributes( pCon, pool, attrs );
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclColor.c b/nx-X11/programs/Xserver/Xprint/pcl/PclColor.c
new file mode 100644
index 000000000..72c7e3f99
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclColor.c
@@ -0,0 +1,851 @@
+/* $Xorg: PclColor.c,v 1.3 2000/08/17 19:48:07 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclColorInit.c
+** *
+** * Contents:
+** * Colormap handing code of Pcl driver for the
+** * print server.
+** *
+** * Created: 4/8/96
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclColor.c,v 1.9tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <math.h>
+
+#include "colormapst.h"
+#include "windowstr.h"
+#include "resource.h"
+
+#include "Pcl.h"
+#include "cfb.h"
+
+static void lookup(unsigned char *src,
+ unsigned char *dst,
+ int num,
+ unsigned char *map,
+ int dim);
+static void trilinear(unsigned char *p,
+ unsigned char *out,
+ unsigned char *d,
+ int dim,
+ unsigned char def);
+
+
+/*
+ * This seems to be (and is) a duplication of effort; one would think
+ * that cfbCreateDefColormap would be sufficient. It almost is. The
+ * only change made in this function is that the black and white pixels
+ * are allocated with three separate variables for red, green and blue
+ * values, instead of the single variable in cfbCreateDefColormap. The
+ * single variable leads to the one value being corrected by
+ * ResolveColor three times, which leads to incorrect colors.
+ */
+
+Bool
+PclCreateDefColormap(ScreenPtr pScreen)
+{
+ unsigned short wp_red = ~0, wp_green = ~0, wp_blue = ~0;
+ unsigned short bp_red = 0, bp_green = 0, bp_blue = 0;
+ VisualPtr pVisual;
+ ColormapPtr cmap;
+ Pixel wp, bp;
+
+ for (pVisual = pScreen->visuals;
+ pVisual->vid != pScreen->rootVisual;
+ pVisual++)
+ ;
+
+ if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &cmap,
+ (pVisual->class & DynamicClass) ? AllocNone : AllocAll,
+ 0)
+ != Success)
+ return FALSE;
+ wp = pScreen->whitePixel;
+ bp = pScreen->blackPixel;
+ if ((AllocColor(cmap, &wp_red, &wp_green, &wp_blue, &wp, 0) !=
+ Success) ||
+ (AllocColor(cmap, &bp_red, &bp_green, &bp_blue, &bp, 0) !=
+ Success))
+ return FALSE;
+
+ pScreen->whitePixel = wp;
+ pScreen->blackPixel = bp;
+
+ (*pScreen->InstallColormap)(cmap);
+ return TRUE;
+}
+
+/*
+ * Add colormap to list of colormaps on screen
+ */
+Bool
+PclCreateColormap(ColormapPtr pColor)
+{
+ PclCmapToContexts *new;
+ PclScreenPrivPtr sPriv;
+
+ sPriv = (PclScreenPrivPtr)pColor->pScreen
+ ->devPrivates[PclScreenPrivateIndex].ptr;
+
+ /*
+ * Use existing code to initialize the values in the colormap
+ */
+ cfbInitializeColormap( pColor );
+
+ /*
+ * Set up the mapping between the color map and the context
+ */
+ new = (PclCmapToContexts *)xalloc( sizeof( PclCmapToContexts ) );
+
+ if( new )
+ {
+ new->colormapId = pColor->mid;
+ new->contexts = NULL;
+ new->next = sPriv->colormaps;
+ sPriv->colormaps = new;
+
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+void
+PclDestroyColormap(ColormapPtr pColor)
+{
+ PclScreenPrivPtr sPriv;
+ PclCmapToContexts *pCmap, *tCmap = 0;
+ PclContextListPtr con, tCon;
+ PclContextPrivPtr cPriv;
+ PclPaletteMapPtr pPal;
+ char t[80];
+
+ /*
+ * At DestroyContext time, colormaps may be destroyed twice, so if the
+ * pointer is NULL, just crash out.
+ */
+ if( !pColor )
+ return;
+
+ /*
+ * Find the colormap <-> contexts mapping
+ */
+ sPriv = (PclScreenPrivPtr)pColor->pScreen
+ ->devPrivates[PclScreenPrivateIndex].ptr;
+ pCmap = sPriv->colormaps;
+ while( pCmap )
+ {
+ if( pCmap->colormapId == pColor->mid )
+ break;
+ tCmap = pCmap;
+ pCmap = pCmap->next;
+ }
+
+ /*
+ * For each context, delete the palette in the printer and
+ * free the mapping.
+ */
+ if( pCmap )
+ {
+ con = pCmap->contexts;
+ while( con )
+ {
+ cPriv = con->context->devPrivates[PclContextPrivateIndex].ptr;
+
+ pPal = cPriv->palettes;
+ while( pPal )
+ {
+ if( pPal->colormapId == pColor->mid )
+ break;
+ pPal = pPal->next;
+ }
+
+ if( cPriv->pPageFile )
+ {
+ sprintf( t, "\033&p%dI\033*p2C", pPal->paletteId );
+ SEND_PCL( cPriv->pPageFile, t );
+ }
+
+ tCon = con;
+ con = con->next;
+ xfree( tCon );
+ }
+
+ /*
+ * Delete the colormap<->contexts mapping
+ */
+ if( sPriv->colormaps == pCmap )
+ /* Delete from the front */
+ sPriv->colormaps = pCmap->next;
+ else
+ /* Delete from the middle */
+ tCmap->next = pCmap->next;
+ free( pCmap );
+ }
+}
+
+void
+PclInstallColormap(ColormapPtr pColor)
+{
+}
+
+void
+PclUninstallColormap(ColormapPtr pColor)
+{
+}
+
+int
+PclListInstalledColormaps(ScreenPtr pScreen,
+ XID *pCmapList)
+{
+ return 0;
+}
+
+void
+PclStoreColors(ColormapPtr pColor,
+ int ndef,
+ xColorItem *pdefs)
+{
+ PclCmapToContexts *p;
+ PclScreenPrivPtr sPriv;
+ PclContextListPtr con;
+ PclContextPrivPtr cPriv;
+ PclPaletteMapPtr pMap;
+ char t[80];
+ int i;
+
+ sPriv = (PclScreenPrivPtr)pColor->pScreen
+ ->devPrivates[PclScreenPrivateIndex].ptr;
+ p = sPriv->colormaps;
+ while( p )
+ {
+ if( p->colormapId == pColor->mid )
+ break;
+ p = p->next;
+ }
+
+ if( p )
+ {
+ con = p->contexts;
+ while( con )
+ {
+ /*
+ * For each context, get the palette ID and update the
+ * appropriate palette.
+ */
+ cPriv = con->context
+ ->devPrivates[PclContextPrivateIndex].ptr;
+ pMap = PclFindPaletteMap( cPriv, pColor, NULL );
+
+ /*
+ * Update the palette
+ */
+ sprintf( t, "\033&p%dS", pMap->paletteId );
+ SEND_PCL( cPriv->pPageFile, t );
+
+ if( pColor->class == PseudoColor )
+ {
+ unsigned short r, g, b;
+ unsigned int pID;
+ for( i = 0; i < ndef; i++ )
+ {
+ pID = pdefs[i].pixel;
+ if ( pColor->red[i].fShared )
+ {
+ r = pColor->red[pID].co.shco.red->color;
+ g = pColor->red[pID].co.shco.green->color;
+ b = pColor->red[pID].co.shco.blue->color;
+ }
+ else
+ {
+ r = pColor->red[pID].co.local.red;
+ g = pColor->red[pID].co.local.green;
+ b = pColor->red[pID].co.local.blue;
+ }
+
+ if( pdefs[i].flags & DoRed )
+ r = pdefs[i].red;
+ if( pdefs[i].flags & DoGreen )
+ g = pdefs[i].green;
+ if( pdefs[i].flags & DoBlue )
+ b = pdefs[i].blue;
+ PclLookUp(pColor, cPriv, &r, &g, &b);
+ sprintf( t, "\033*v%ua%ub%uc%dI", r, g, b, pID);
+ SEND_PCL( cPriv->pPageFile, t );
+ }
+ }
+
+ sprintf( t, "\033&p%dS", cPriv->currentPalette );
+ SEND_PCL( cPriv->pPageFile, t );
+
+ con = con->next;
+ }
+ }
+}
+
+void
+PclResolveColor(unsigned short *pRed,
+ unsigned short *pGreen,
+ unsigned short *pBlue,
+ VisualPtr pVisual)
+{
+ /*
+ * We need to map the X color range of [0,65535] to the PCL color
+ * range of [0,32767].
+ */
+ *pRed >>= 1;
+ *pGreen >>= 1;
+ *pBlue >>= 1;
+}
+
+PclPaletteMapPtr
+PclFindPaletteMap(PclContextPrivPtr cPriv,
+ ColormapPtr cmap,
+ GCPtr gc)
+{
+ PclPaletteMapPtr p = cPriv->palettes, new;
+
+ /*
+ * If the colormap is static, grab one of the special palettes. If we come
+ * into this from StoreColors, there will be no GC, but by definition we're
+ * looking at a dynamic color map, so the special colors will not be
+ * needed.
+ */
+ if( gc )
+ {
+ if( cmap->pVisual->class == StaticGray )
+ return &( cPriv->staticGrayPalette );
+ else if( cmap->pVisual->class == TrueColor )
+ {
+ if( gc->fillStyle == FillTiled && !( gc->tileIsPixel ) )
+ return &( cPriv->specialTrueColorPalette );
+ else
+ return &( cPriv->trueColorPalette );
+ }
+ }
+
+
+ /* Look for the colormap ID <-> palette ID mapping */
+ while( p )
+ {
+ if( p->colormapId == cmap->mid )
+ return p;
+ p = p->next;
+ }
+
+ /* If the colormap isn't already there, make an entry for it */
+ new = (PclPaletteMapPtr)xalloc( sizeof( PclPaletteMap ) );
+ new->colormapId = cmap->mid;
+ new->paletteId = cPriv->nextPaletteId++;
+ new->downloaded = 0;
+ new->next = cPriv->palettes;
+ cPriv->palettes = new;
+ return new;
+}
+
+int
+PclUpdateColormap(DrawablePtr pDrawable,
+ XpContextPtr pCon,
+ GCPtr gc,
+ FILE *outFile)
+{
+ PclScreenPrivPtr sPriv;
+
+ PclContextPrivPtr cPriv;
+ PclPaletteMapPtr pMap;
+ PclCmapToContexts *pCmap;
+ PclContextListPtr new;
+ char t[80];
+ Colormap c;
+ ColormapPtr cmap;
+ WindowPtr win = (WindowPtr)pDrawable;
+ unsigned short r, g, b, rr, gg, bb;
+ int i;
+
+ cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ c = wColormap( win );
+ cmap = (ColormapPtr)LookupIDByType( c, RT_COLORMAP );
+ pMap = PclFindPaletteMap( cPriv, cmap, gc );
+
+ if( cPriv->currentPalette == pMap->paletteId )
+ /*
+ * If the requested colormap is already active, nothing needs to
+ * be done.
+ */
+ return FALSE;
+
+ /*
+ * Now we activate the palette in the printer
+ */
+ sprintf( t, "\033&p%dS", pMap->paletteId );
+ SEND_PCL( outFile, t );
+ cPriv->currentPalette = pMap->paletteId;
+
+ if( pMap->downloaded == 0 )
+ /*
+ * If the requested colormap has not been downloaded to the
+ * printer, we need to do that before activating it.
+ */
+ {
+ /*
+ * Add the colormap to the screen-level colormap<->context mapping.
+ */
+ sPriv = (PclScreenPrivPtr)cmap->pScreen
+ ->devPrivates[PclScreenPrivateIndex].ptr;
+ pCmap = sPriv->colormaps;
+ while( pCmap && ( pCmap->colormapId != cmap->mid ) )
+ pCmap = pCmap->next;
+ new = (PclContextListPtr)xalloc( sizeof( PclContextList ) );
+ new->context = pCon;
+ new->next = pCmap->contexts;
+ pCmap->contexts = new;
+
+ /*
+ * XXX Download the colormap
+ */
+ if( cmap->class == StaticGray )
+ {
+#ifdef XP_PCL_COLOR
+ sprintf( t, "\033*v18W%c%c%c%c%c%c", 0, 1, 1, 1, 1, 1 );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 12 );
+
+ /* Send the white reference point... */
+ sprintf( t, "%c%c%c%c%c%c", 0x7f, 0xff, 0x7f, 0xff,
+ 0x7f, 0xff );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ /* ... and the black reference point */
+ sprintf( t, "%c%c%c%c%c%c", 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00 );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ /* Now program the two colors */
+ sprintf( t, "\033*v0a0b0c%ldI", (long) cmap->pScreen->blackPixel );
+ SEND_PCL( cPriv->pPageFile, t );
+ sprintf( t, "\033*v32767a32767b32767c%ldI",
+ (long) cmap->pScreen->whitePixel );
+ SEND_PCL( cPriv->pPageFile, t );
+#endif /* XP_PCL_COLOR */
+ }
+ else if( cmap->class == PseudoColor )
+ {
+ sprintf( t,
+ "\033*v18W%c%c%c%c%c%c",
+ 0, 1, cmap->pVisual->nplanes, 16, 16, 16 );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 12 );
+
+ /* Send the white reference point... */
+ if ( cPriv->ctbl != NULL )
+ sprintf( t, "%c%c%c%c%c%c", 0x00, 0xff, 0x00, 0xff,
+ 0x00, 0xff );
+ else
+ sprintf( t, "%c%c%c%c%c%c", 0x7f, 0xff, 0x7f, 0xff,
+ 0x7f, 0xff );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ /* ... and the black reference point */
+ sprintf( t, "%c%c%c%c%c%c", 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00 );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ for(i = 0; i < cmap->pVisual->ColormapEntries; i++ )
+ {
+ if( cmap->red[i].fShared )
+ {
+ r = cmap->red[i].co.shco.red->color;
+ g = cmap->red[i].co.shco.green->color;
+ b = cmap->red[i].co.shco.blue->color;
+ }
+ else
+ {
+ r = cmap->red[i].co.local.red;
+ g = cmap->red[i].co.local.green;
+ b = cmap->red[i].co.local.blue;
+ }
+ PclLookUp(cmap, cPriv, &r, &g, &b);
+ sprintf( t, "\033*v%ua%ub%uc%dI", r, g, b, i );
+ SEND_PCL( outFile, t );
+ }
+ }
+ else if( cmap->class == TrueColor )
+ {
+ unsigned short lim;
+
+ if( gc->fillStyle == FillTiled && !( gc->tileIsPixel ) )
+ {
+ if( cPriv->ctbl != NULL )
+ {
+ /* Send the "special" colormap for 24-bit fills */
+ sprintf( t, "\033*v18W%c%c%c%c%c%c", 0, 1,
+ 8,
+ cmap->pVisual->bitsPerRGBValue,
+ cmap->pVisual->bitsPerRGBValue,
+ cmap->pVisual->bitsPerRGBValue );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 12 );
+
+ /* Send the white reference point... */
+ sprintf( t, "%c%c%c%c%c%c",
+ 0x00, 0xff,
+ 0x00, 0xff,
+ 0x00, 0xff );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ /* ... and the black reference point */
+ sprintf( t, "%c%c%c%c%c%c",
+ 0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00 );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ /* Now send the color entries, RRRGGGBB */
+ i=0;
+ for( r = 0; r < 8; r++ )
+ for( g = 0; g < 8; g ++ )
+ for( b = 0; b < 4; b++ )
+ {
+ rr = (r * 0xff)/7;
+ gg = (g * 0xff)/7;
+ bb = (b * 0xff)/3;
+ PclLookUp(cmap, cPriv, &rr, &gg, &bb);
+ sprintf( t, "\033*v%ua%ub%uc%dI",
+ rr, gg, bb, i );
+ SEND_PCL( outFile, t );
+ i++;
+ }
+ }
+ else
+ {
+ /* Send the "special" colormap for 24-bit fills */
+ sprintf( t, "\033*v18W%c%c%c%c%c%c", 0, 1,
+ 8,
+ cmap->pVisual->bitsPerRGBValue,
+ cmap->pVisual->bitsPerRGBValue,
+ cmap->pVisual->bitsPerRGBValue );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 12 );
+
+ /* Send the white reference point... */
+ sprintf( t, "%c%c%c%c%c%c",
+ 0x00, 0x07,
+ 0x00, 0x07,
+ 0x00, 0x03 );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ /* ... and the black reference point */
+ sprintf( t, "%c%c%c%c%c%c",
+ 0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00 );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ /* Now send the color entries, RRRGGGBB */
+ i=0;
+ for( r = 0; r < 8; r++ )
+ for( g = 0; g < 8; g ++ )
+ for( b = 0; b < 4; b++ )
+ {
+ sprintf( t, "\033*v%ua%ub%uc%dI",
+ r, g, b, i );
+ SEND_PCL( outFile, t );
+ i++;
+ }
+ }
+
+ }
+ else
+ {
+ lim = (1 << cmap->pVisual->bitsPerRGBValue) - 1;
+
+ /* Send the "special" colormap for 24-bit fills */
+ sprintf( t, "\033*v18W%c%c%c%c%c%c", 0, 3,
+ cmap->pVisual->nplanes,
+ cmap->pVisual->bitsPerRGBValue,
+ cmap->pVisual->bitsPerRGBValue,
+ cmap->pVisual->bitsPerRGBValue );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 12 );
+
+ /* Send the white reference point... */
+ sprintf( t, "%c%c%c%c%c%c",
+ (lim >> 8) & 0xff, lim & 0xff,
+ (lim >> 8) & 0xff, lim & 0xff,
+ (lim >> 8) & 0xff, lim & 0xff);
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ /* ... and the black reference point */
+ sprintf( t, "%c%c%c%c%c%c", 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00 );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+ }
+
+ }
+ pMap->downloaded = 1;
+ }
+ return TRUE;
+
+}
+
+void PclLookUp(
+ ColormapPtr cmap,
+ PclContextPrivPtr cPriv,
+ unsigned short *r,
+ unsigned short *g,
+ unsigned short *b
+)
+{
+ unsigned char cdata[3];
+
+ if( cmap->class == PseudoColor )
+ {
+ if( cPriv->ctbl != NULL )
+ {
+ cdata[0] = *r >> 8;
+ cdata[1] = *g >> 8;
+ cdata[2] = *b >> 8;
+ lookup(cdata, cdata, 1, cPriv->ctbl, cPriv->ctbldim);
+ *r = cdata[0];
+ *g = cdata[1];
+ *b = cdata[2];
+ }
+ else
+ {
+ *r >>= 1;
+ *g >>= 1;
+ *b >>= 1;
+ }
+ }
+ else if( cmap->class == TrueColor )
+ {
+ if( cPriv->ctbl != NULL )
+ {
+ cdata[0] = *r;
+ cdata[1] = *g;
+ cdata[2] = *b;
+ lookup(cdata, cdata, 1, cPriv->ctbl, cPriv->ctbldim);
+ *r = cdata[0];
+ *g = cdata[1];
+ *b = cdata[2];
+ }
+ }
+ return;
+}
+
+unsigned char *PclReadMap(char *name, int *dim)
+{
+ FILE *fp;
+ unsigned char *data;
+ long size;
+
+ if ((fp=fopen(name, "r")) == NULL) {
+ return(NULL);
+ }
+
+ fseek(fp, 0, SEEK_END);
+ size = ftell(fp);
+
+ /* Could do this with a lookup table, if the constraint is that the
+ 3 map dimensions must be equal. */
+ switch (size) {
+ case 8*8*8*3:
+ *dim = 8;
+ break;
+ case 16*16*16*3:
+ *dim = 16;
+ break;
+ case 17*17*17*3:
+ *dim = 17;
+ break;
+ case 65*65*65*3:
+ *dim = 65;
+ break;
+ default:
+ fclose(fp);
+ return(NULL);
+ }
+
+ if ((data = (unsigned char *) xalloc(sizeof(char) * size)) == NULL) {
+ fclose(fp);
+ return(NULL);
+ }
+
+ fseek(fp, 0, SEEK_SET);
+
+ if (fread(data, sizeof(char), size, fp) != (unsigned) size) {
+ fclose(fp);
+ free(data);
+ return(NULL);
+ }
+
+ fclose(fp);
+ return(data);
+}
+
+/************************************************************************
+ *
+ * Here is the mapper.
+ *
+ ************************************************************************/
+
+#define SCL(x) ((x)*(dim-1)/255)
+/* Interleaved-map lookup */
+static void lookup(unsigned char *src, unsigned char *dst, int num, unsigned char *map, int dim)
+{
+ int i;
+
+#define _INTERPOLATE
+#ifndef _INTERPOLATE
+ unsigned char *p1, *p2, *p3;
+
+ for (i=0; i<num; i++) {
+ p1 = map + (SCL(src[0])*dim*dim + SCL(src[1])*dim + SCL(src[2])) * 3;
+ *dst++ = *p1++;
+ *dst++ = *p1++;
+ *dst++ = *p1++;
+ src += 3;
+ }
+#else
+ for (i=0; i<num; i++) {
+ trilinear(src, dst, map, dim, 128);
+ src += 3;
+ dst += 3;
+ }
+#endif
+}
+
+/*
+ * C code from the article
+ * "Tri-linear Interpolation"
+ * by Steve Hill, sah@ukc.ac.uk
+ * in "Graphics Gems IV", Academic Press, 1994
+ *
+ * Fri Feb 16 14:12:43 PST 1996
+ * Modified to use for 8-bit color mapping -- A. Fitzhugh,
+ * HP Labs, Printing Technology Department
+ */
+
+/* linear interpolation from l (when a=0) to h (when a=1)*/
+/* (equal to (a*h)+((1-a)*l) */
+#define LERP(a,l,h) ((l)+((((h)-(l))*(a))>>8))
+
+static void trilinear(unsigned char *p, unsigned char *out, unsigned char *d, int dim, unsigned char def)
+{
+#define DENS(X, Y, Z, ch) d[((X*dim+Y)*dim+Z)*3+ch]
+
+ int x0, y0, z0,
+ x1, y1, z1,
+ i;
+ unsigned char *dp,
+ fx, fy, fz,
+ d000, d001, d010, d011,
+ d100, d101, d110, d111,
+ dx00, dx01, dx10, dx11,
+ dxy0, dxy1;
+ float scale;
+
+ scale = 255.0 / (dim-1);
+
+ x0 = p[0] / scale;
+ y0 = p[1] / scale;
+ z0 = p[2] / scale;
+
+ /* Fractions should range from 0-1.0 (fixed point 8-256) */
+ fx = (((int) (p[0] - x0 * scale)) << 8) / 255;
+ fy = (((int) (p[1] - y0 * scale)) << 8) / 255;
+ fz = (((int) (p[2] - z0 * scale)) << 8) / 255;
+
+ x1 = x0 + 1;
+ y1 = y0 + 1;
+ z1 = z0 + 1;
+
+ for (i=0; i<3; i++) {
+
+ if (x0 >= 0 && x1 < dim &&
+ y0 >= 0 && y1 < dim &&
+ z0 >= 0 && z1 < dim) {
+ dp = &DENS(x0, y0, z0, i);
+ d000 = dp[0];
+ d100 = dp[3];
+ dp += dim*3;
+ d010 = dp[0];
+ d110 = dp[3];
+ dp += dim*dim*3;
+ d011 = dp[0];
+ d111 = dp[3];
+ dp -= dim*3;
+ d001 = dp[0];
+ d101 = dp[3];
+ } else {
+# define INRANGE(X, Y, Z) \
+ ((X) >= 0 && (X) < dim && \
+ (Y) >= 0 && (Y) < dim && \
+ (Z) >= 0 && (Z) < dim)
+
+ d000 = INRANGE(x0, y0, z0) ? DENS(x0, y0, z0, i) : def;
+ d001 = INRANGE(x0, y0, z1) ? DENS(x0, y0, z1, i) : def;
+ d010 = INRANGE(x0, y1, z0) ? DENS(x0, y1, z0, i) : def;
+ d011 = INRANGE(x0, y1, z1) ? DENS(x0, y1, z1, i) : def;
+
+ d100 = INRANGE(x1, y0, z0) ? DENS(x1, y0, z0, i) : def;
+ d101 = INRANGE(x1, y0, z1) ? DENS(x1, y0, z1, i) : def;
+ d110 = INRANGE(x1, y1, z0) ? DENS(x1, y1, z0, i) : def;
+ d111 = INRANGE(x1, y1, z1) ? DENS(x1, y1, z1, i) : def;
+ }
+
+ dx00 = LERP(fx, d000, d100);
+ dx01 = LERP(fx, d001, d101);
+ dx10 = LERP(fx, d010, d110);
+ dx11 = LERP(fx, d011, d111);
+
+ dxy0 = LERP(fy, dx00, dx10);
+ dxy1 = LERP(fy, dx01, dx11);
+
+ out[i] = LERP(fz, dxy0, dxy1);
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclCursor.c b/nx-X11/programs/Xserver/Xprint/pcl/PclCursor.c
new file mode 100644
index 000000000..f50c355e9
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclCursor.c
@@ -0,0 +1,115 @@
+/* $Xorg: PclCursor.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclCursor.c
+** *
+** * Contents:
+** * Cursor-handling code for the PCL DDX driver
+** *
+** * Created: 1/18/96
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclCursor.c,v 1.3 1999/12/16 02:26:27 robin Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+
+#include "Pcl.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+
+void
+PclConstrainCursor(
+ ScreenPtr pScreen,
+ BoxPtr pBox)
+{
+}
+
+void
+PclCursorLimits(
+ ScreenPtr pScreen,
+ CursorPtr pCursor,
+ BoxPtr pHotBox,
+ BoxPtr pTopLeftBox)
+{
+}
+
+Bool
+PclDisplayCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ return True;
+}
+
+Bool
+PclRealizeCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ return True;
+}
+
+Bool
+PclUnrealizeCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ return True;
+}
+
+void
+PclRecolorCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor,
+ Bool displayed)
+{
+}
+
+Bool
+PclSetCursorPosition(
+ ScreenPtr pScreen,
+ int x,
+ int y,
+ Bool generateEvent)
+{
+ return True;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclDef.h b/nx-X11/programs/Xserver/Xprint/pcl/PclDef.h
new file mode 100644
index 000000000..275bd63ec
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclDef.h
@@ -0,0 +1,68 @@
+/* $Xorg: PclDef.h,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclDef.h
+** *
+** * Contents: extran defines and includes for the Pcl driver
+** * for a printing X server.
+** *
+** * Created: 7/31/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _PCLDEF_H_
+#define _PCLDEF_H_
+
+#define DT_PRINT_JOB_HEADER "DT_PRINT_JOB_HEADER"
+#define DT_PRINT_JOB_TRAILER "DT_PRINT_JOB_TRAILER"
+#define DT_PRINT_JOB_COMMAND "DT_PRINT_JOB_COMMAND"
+#define DT_PRINT_JOB_EXEC_COMMAND "DT_PRINT_JOB_EXEC_COMMAND"
+#define DT_PRINT_JOB_EXEC_OPTIONS "DT_PRINT_JOB_EXEC_OPTION"
+#define DT_PRINT_PAGE_HEADER "DT_PRINT_PAGE_HEADER"
+#define DT_PRINT_PAGE_TRAILER "DT_PRINT_PAGE_TRAILER"
+#define DT_PRINT_PAGE_COMMAND "DT_PRINT_PAGE_COMMAND"
+
+#define DT_IN_FILE_STRING "%(InFile)%"
+#define DT_OUT_FILE_STRING "%(OutFile)%"
+#define DT_ALLOWED_COMMANDS_FILE "printCommands"
+
+#endif /* _PCLDEF_H_ */
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclFonts.c b/nx-X11/programs/Xserver/Xprint/pcl/PclFonts.c
new file mode 100644
index 000000000..591435faa
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclFonts.c
@@ -0,0 +1,74 @@
+/* $Xorg: PclFonts.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclFonts.c
+** *
+** * Contents:
+** * Font code for Pcl driver.
+** *
+** * Created: 2/03/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/* $XFree86$ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "regionstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "scrnintstr.h"
+
+#include "Pcl.h"
+
+Bool
+PclRealizeFont(
+ ScreenPtr pscr,
+ FontPtr pFont)
+{
+ return TRUE;
+}
+
+Bool
+PclUnrealizeFont(
+ ScreenPtr pscr,
+ FontPtr pFont)
+{
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclGC.c b/nx-X11/programs/Xserver/Xprint/pcl/PclGC.c
new file mode 100644
index 000000000..83ebb47e1
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclGC.c
@@ -0,0 +1,1046 @@
+/* $Xorg: PclGC.c,v 1.4 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclGC.c
+** *
+** * Contents:
+** * Graphics Context handling for the PCL driver
+** *
+** * Created: 10/11/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclGC.c,v 1.9 2001/01/19 18:34:28 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "gcstruct.h"
+
+#include "Pcl.h"
+#include "pixmapstr.h"
+#include "colormapst.h"
+#include "windowstr.h"
+#include "cfb.h"
+#include "cfb32.h"
+#include "migc.h"
+#include "scrnintstr.h"
+#include "resource.h"
+
+static GCOps PclGCOps =
+{
+ PclFillSpans,
+ PclSetSpans,
+ PclPutImage,
+ PclCopyArea,
+ PclCopyPlane,
+ PclPolyPoint,
+ PclPolyLine,
+ PclPolySegment,
+ PclPolyRectangle,
+ PclPolyArc,
+ PclFillPolygon,
+ PclPolyFillRect,
+ PclPolyFillArc,
+ PclPolyText8,
+ PclPolyText16,
+ PclImageText8,
+ PclImageText16,
+ PclImageGlyphBlt,
+ PclPolyGlyphBlt,
+ PclPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+}
+;
+
+
+static GCFuncs PclGCFuncs =
+{
+ PclValidateGC,
+ miChangeGC,
+ miCopyGC,
+ PclDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip,
+}
+;
+
+Bool
+PclCreateGC(GCPtr pGC)
+{
+ if( pGC->depth == 1 )
+ {
+ if( mfbCreateGC( pGC ) == FALSE )
+ return FALSE;
+ }
+ else if( pGC->depth <= 32 )
+ {
+#if PSZ == 8
+ if( cfbCreateGC( pGC ) == FALSE )
+#else
+ if( cfb32CreateGC( pGC ) == FALSE )
+#endif
+ return FALSE;
+ }
+ else
+ return FALSE;
+
+ pGC->clientClip = NULL;
+ pGC->clientClipType = CT_NONE;
+
+ pGC->ops = &PclGCOps;
+ pGC->funcs = &PclGCFuncs;
+
+ return TRUE;
+}
+
+void
+PclDestroyGC(GCPtr pGC)
+{
+ /* Handle the mfb and cfb, which share a GC private struct */
+ miDestroyGC( pGC );
+}
+
+
+int
+PclGetDrawablePrivateStuff(
+ DrawablePtr pDrawable,
+ GC *gc,
+ unsigned long *valid,
+ FILE **file)
+{
+ XpContextPtr pCon;
+ PclContextPrivPtr cPriv;
+
+ switch( pDrawable->type )
+ {
+ case DRAWABLE_PIXMAP:
+ /*
+ * If we ever get here, something is wrong.
+ */
+ return FALSE;
+
+ case DRAWABLE_WINDOW:
+ pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
+
+ if( pCon == NULL )
+ return FALSE;
+ else
+ {
+ cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
+ *gc = cPriv->lastGC;
+ *valid = cPriv->validGC;
+ *file = cPriv->pPageFile;
+ return TRUE;
+ }
+
+ default:
+ return FALSE;
+ }
+}
+
+void
+PclSetDrawablePrivateGC(
+ DrawablePtr pDrawable,
+ GC gc)
+{
+ PixmapPtr pix;
+ XpContextPtr pCon;
+ PclPixmapPrivPtr pixPriv;
+ PclContextPrivPtr pPriv;
+ int i;
+
+ switch( pDrawable->type )
+ {
+ case DRAWABLE_PIXMAP:
+ pix = (PixmapPtr)pDrawable;
+ pixPriv = pix->devPrivates[PclPixmapPrivateIndex].ptr;
+
+ pixPriv->lastGC = gc;
+ pixPriv->validGC = 1;
+ break;
+
+ case DRAWABLE_WINDOW:
+ pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
+ pPriv = ((PclContextPrivPtr)
+ (pCon->devPrivates[PclContextPrivateIndex].ptr));
+
+ pPriv->validGC = 1;
+ pPriv->lastGC = gc;
+
+ /*
+ * Store the dash list separately, to avoid having it freed
+ * out from under us.
+ */
+ if( pPriv->dash != NULL )
+ xfree( pPriv->dash );
+ if( gc.numInDashList != 0 )
+ {
+ pPriv->dash = (unsigned char *)xalloc( sizeof( unsigned char )
+ * gc.numInDashList );
+ for( i = 0; i < gc.numInDashList; i++ )
+ pPriv->dash[i] = gc.dash[i];
+ }
+ else
+ pPriv->dash = NULL;
+
+
+ /*
+ * Store the dash list separately, to avoid having it freed
+ * out from under us.
+ */
+ if( pPriv->dash != NULL )
+ xfree( pPriv->dash );
+ if( gc.numInDashList != 0 )
+ {
+ pPriv->dash = (unsigned char *)xalloc( sizeof( unsigned char )
+ * gc.numInDashList );
+ for( i = 0; i < gc.numInDashList; i++ )
+ pPriv->dash[i] = gc.dash[i];
+ }
+ else
+ pPriv->dash = NULL;
+
+ break;
+ }
+}
+
+static void
+PclSendPattern(char *bits,
+ int sz,
+ int depth,
+ int h,
+ int w,
+ int patNum,
+ FILE *outFile)
+{
+ char t[80], *row, *mod;
+ int w2;
+ int i, j;
+
+ SEND_PCL( outFile, "\033%0A" );
+
+ if( depth == 1 )
+ {
+ /* Each row must be word-aligned */
+ w2 = ( w / 8 ) + ( ( w%8 ) ? 1 : 0 );
+/*
+ if( w2 % 2 )
+ w2++;
+*/
+
+ sprintf( t, "\033*c%dg%dW", patNum, h * w2 + 8 );
+ SEND_PCL( outFile, t );
+
+ sprintf( t, "%c%c%c%c%c%c%c%c", 0, 0, 1, 0, h>>8, h&0xff, w>>8,
+ w&0xff );
+ SEND_PCL_COUNT( outFile, t, 8 );
+
+ for( row = bits, i = 0; i < h; i++, row += BitmapBytePad( w ) )
+ SEND_PCL_COUNT( outFile, row, w2 );
+ }
+ else if( depth == 8 )
+ {
+ w2 = ( w % 2 ) ? w + 1 : w;
+
+ sprintf( t, "\033*c%dg%dW", patNum, h * w2 + 8 );
+ SEND_PCL( outFile, t );
+
+ sprintf( t, "%c%c%c%c%c%c%c%c", 1, 0, 8, 0, h>>8, h&0xff,
+ w>>8, w&0xff );
+ SEND_PCL_COUNT( outFile, t, 8 );
+
+ for( row = bits, i = 0; i < h; i++,
+ row += PixmapBytePad( w, 8 ) )
+ SEND_PCL_COUNT( outFile, row, w2 );
+ }
+ else
+ {
+ w2 = ( w % 2 ) ? w + 1 : w;
+
+ sprintf( t, "\033*c%dg%dW", patNum, h * w2 + 8 );
+ SEND_PCL( outFile, t );
+
+ sprintf( t, "%c%c%c%c%c%c%c%c", 1, 0, 8, 0, h>>8, h&0xff,
+ w>>8, w&0xff );
+ SEND_PCL_COUNT( outFile, t, 8 );
+
+ mod = (char *)xalloc( w2 );
+
+ for( row = bits, i = 0; i < h; i++,
+ row += PixmapBytePad( w, 24 ) )
+ {
+ char r, g, b;
+ for( j = 0; j < w2; j++ ) {
+ r = ((row[j*4+1] >> 5) & 0x7) << 5;
+ g = ((row[j*4+2] >> 5) & 0x7) << 2;
+ b = ((row[j*4+3] >> 6) & 0x3);
+ mod[j] = r | g | b;
+ }
+ SEND_PCL_COUNT( outFile, mod, w2 );
+ }
+
+ xfree( mod );
+ }
+
+ SEND_PCL( outFile, "\033%0B" );
+}
+
+int
+PclUpdateDrawableGC(
+ GCPtr pGC,
+ DrawablePtr pDrawable,
+ FILE **outFile)
+{
+ Mask changeMask = 0;
+ GC dGC;
+ unsigned long valid;
+ int i;
+ XpContextPtr pCon;
+ PclContextPrivPtr cPriv;
+ PclGCPrivPtr gcPriv = (PclGCPrivPtr)
+ (pGC->devPrivates[PclGCPrivateIndex].ptr);
+
+ if( !PclGetDrawablePrivateStuff( pDrawable, &dGC, &valid, outFile ) )
+ return FALSE;
+
+ pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
+ cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ /*
+ * Here's where we update the colormap. Since there can be
+ * different colormaps installed on each window, we need to check
+ * before each drawing request that the correct palette is active in
+ * the printer. This is as good a place as any.
+ */
+ if( !PclUpdateColormap( pDrawable, pCon, pGC, *outFile ) )
+ return FALSE;
+
+ /*
+ * If the drawable's last GC is NULL, this means that this is
+ * the first time the drawable is being used. Therefore, we need
+ * to emit PCL for all the GC fields.
+ */
+ if( valid == 0 )
+ changeMask = ~0;
+
+ /*
+ * If we have two different GC structures, there is no alternative
+ * but to scan through them both to determine the changeMask.
+ */
+ else
+ {
+ if( dGC.alu != pGC->alu )
+ changeMask |= GCFunction;
+ if( dGC.fgPixel != pGC->fgPixel )
+ changeMask |= GCForeground;
+ if( dGC.bgPixel != pGC->bgPixel )
+ changeMask |= GCBackground;
+ if( dGC.lineWidth != pGC->lineWidth )
+ changeMask |= GCLineWidth;
+ if( dGC.lineStyle != pGC->lineStyle )
+ changeMask |= GCLineStyle;
+ if( dGC.capStyle != pGC->capStyle )
+ changeMask |= GCCapStyle;
+ if( dGC.joinStyle != pGC->joinStyle )
+ changeMask |= GCJoinStyle;
+ if( dGC.fillStyle != pGC->fillStyle )
+ changeMask |= GCFillStyle;
+ if( dGC.tile.pixmap != pGC->tile.pixmap )
+ changeMask |= GCTile;
+ if( dGC.stipple != pGC->stipple )
+ changeMask |= GCStipple;
+ if( dGC.patOrg.x != pGC->patOrg.x )
+ changeMask |= GCTileStipXOrigin;
+ if( dGC.patOrg.y != pGC->patOrg.y )
+ changeMask |= GCTileStipYOrigin;
+
+ if( dGC.numInDashList == pGC->numInDashList )
+ {
+ for( i = 0; i < dGC.numInDashList; i++ )
+ if( cPriv->dash[i] != pGC->dash[i] )
+ {
+ changeMask |= GCDashList;
+ break;
+ }
+ }
+ else
+ changeMask |= GCDashList;
+ }
+
+ /*
+ * Once the changeMask has been determined, we scan it and emit
+ * the appropriate PCL code to set the drawing attributes.
+ */
+
+ /* Must be in HP-GL/2 mode to set attributes */
+ SEND_PCL( *outFile, "\033%0B" );
+
+ if( changeMask & GCFunction )
+ {
+#ifdef XP_PCL_COLOR
+
+ if( pGC->alu == GXclear )
+ SEND_PCL( *outFile, "SP0;" );
+ else
+ SEND_PCL( *outFile, "SP1;" );
+#else
+ if( pGC->alu == GXclear )
+ SEND_PCL( *outFile, "SP0;" );
+ else
+ SEND_PCL( *outFile, "SP1;" );
+#endif /* XP_PCL_COLOR */
+ }
+
+#if 0
+ if( changeMask & GCFunction )
+ {
+ int rop = -1;
+ char t[10];
+
+ switch( pGC->alu )
+ {
+ case GXclear:
+ rop = 1;
+ break;
+ case GXand:
+ rop = 136;
+ break;
+ case GXandReverse:
+ rop = 68;
+ break;
+ case GXcopy:
+ rop = 204;
+ break;
+ case GXandInverted:
+ rop = 34;
+ break;
+ case GXnoop:
+ rop = 170;
+ break;
+ case GXxor:
+ rop = 238;
+ break;
+ case GXor:
+ rop = 238;
+ break;
+ case GXnor:
+ rop = 17;
+ break;
+ case GXequiv:
+ rop = 153;
+ break;
+ case GXinvert:
+ rop = 85;
+ break;
+ case GXorReverse:
+ rop = 221;
+ break;
+ case GXcopyInverted:
+ rop = 51;
+ break;
+ case GXorInverted:
+ rop = 187;
+ break;
+ case GXnand:
+ rop = 119;
+ break;
+ case GXset:
+ rop = 0;
+ break;
+ }
+ if( rop != -1 )
+ {
+ sprintf( t, "MC1,%d;", rop );
+ SEND_PCL( *outFile, t );
+#endif
+
+ if( changeMask & GCForeground )
+ switch( pGC->fgPixel )
+ {
+ case 1:
+ SEND_PCL( *outFile, "SP1;" );
+ break;
+ default:
+ SEND_PCL( *outFile, "SP0;" );
+ break;
+ }
+
+ if( changeMask & GCForeground )
+ {
+#ifdef XP_PCL_COLOR
+ ColormapPtr cmap;
+ Colormap c;
+ char t[40];
+
+ c = wColormap( ((WindowPtr)pDrawable) );
+ cmap = (ColormapPtr)LookupIDByType( c, RT_COLORMAP );
+
+ if( cmap->class == TrueColor )
+ {
+ if( pGC->fillStyle != FillTiled || pGC->tileIsPixel ) {
+ unsigned short r, g, b;
+
+ r = (pGC->fgPixel & cmap->pVisual->redMask)
+ >> (cmap->pVisual->offsetRed );
+ g = (pGC->fgPixel & cmap->pVisual->greenMask)
+ >> (cmap->pVisual->offsetGreen);
+ b = (pGC->fgPixel & cmap->pVisual->blueMask)
+ >> (cmap->pVisual->offsetBlue);
+
+ PclLookUp(cmap, cPriv, &r, &g, &b);
+ sprintf( t, "\033%%0A\033*v%ua%ub%uc0I\033%%0B", r, g, b);
+ SEND_PCL( *outFile, t );
+ }
+ }
+ else /* PseudoColor or StaticGray */
+ {
+ sprintf( t, "SP%ld;", (long) pGC->fgPixel );
+ SEND_PCL( *outFile, t );
+ }
+#else
+ ScreenPtr screen;
+ screen = pDrawable->pScreen;
+ if ( pGC->fgPixel == screen->whitePixel )
+ SEND_PCL( *outFile, "SP0;");
+ else
+ SEND_PCL( *outFile, "SP1;");
+#endif /* XP_PCL_COLOR */
+ }
+
+ if( changeMask & GCJoinStyle )
+ switch( pGC->joinStyle )
+ {
+ case JoinMiter:
+ SEND_PCL( *outFile, "LA2,1;" );
+ break;
+ case JoinRound:
+ SEND_PCL( *outFile, "LA2,4;" );
+ break;
+ case JoinBevel:
+ SEND_PCL( *outFile, "LA2,5;" );
+ break;
+ }
+
+ if( changeMask & GCCapStyle )
+ switch( pGC->capStyle )
+ {
+ case CapNotLast:
+ case CapButt:
+ SEND_PCL( *outFile, "LA1,1;" );
+ break;
+ case CapRound:
+ SEND_PCL( *outFile, "LA1,4;" );
+ break;
+ case CapProjecting:
+ SEND_PCL( *outFile, "LA1,2;" );
+ break;
+ }
+
+ if( changeMask & GCLineWidth )
+ {
+ float penWidth, pixelsPerMM;
+ ScreenPtr screen;
+ char temp[30];
+
+ if( pGC->lineWidth == 0 || pGC->lineWidth == 1 )
+ /* A pen width of 0.0 mm gives a one-pixel-wide line */
+ penWidth = 0.0;
+ else
+ {
+ screen = pDrawable->pScreen;
+ pixelsPerMM = (float)screen->width / (float)screen->mmWidth;
+
+ penWidth = pGC->lineWidth / pixelsPerMM;
+ }
+ sprintf( temp, "PW%g;", penWidth );
+ SEND_PCL( *outFile, temp );
+ }
+
+ if( changeMask & GCLineStyle )
+ {
+ int i, num = pGC->numInDashList;
+ double total;
+ char t[30];
+
+ switch( pGC->lineStyle )
+ {
+ case LineSolid:
+ SEND_PCL( *outFile, "LT;" );
+ break;
+ case LineOnOffDash:
+ /*
+ * Calculate the pattern length of the dashes, in pixels,
+ * then convert to mm
+ */
+ for( i = 0, total = 0.0; i < 20 && i < num; i++ )
+ total += pGC->dash[i];
+ if( num % 2 )
+ for( i = num; i < 20 && i < num + num; i++ )
+ total += pGC->dash[i-num];
+
+ total *= ( (double)pDrawable->pScreen->mmWidth /
+ (double)pDrawable->pScreen->width );
+
+ sprintf( t, "LT8,%f,1;", total );
+ SEND_PCL( *outFile, t );
+ break;
+ }
+ }
+
+
+ if( changeMask & GCFillStyle )
+ switch( pGC->fillStyle )
+ {
+ case FillSolid:
+ SEND_PCL( *outFile, "FT1;TR0;CF;" );
+ break;
+ case FillTiled:
+ SEND_PCL( *outFile, "FT22,100;TR0;CF2,0;" );
+ break;
+ case FillOpaqueStippled:
+ SEND_PCL( *outFile, "FT22,101;TR0;CF2,0;" );
+ if( pGC->fgPixel != gcPriv->stippleFg ||
+ pGC->bgPixel != gcPriv->stippleBg )
+ changeMask |= GCStipple;
+ break;
+ case FillStippled:
+ SEND_PCL( *outFile, "FT22,102;TR1;CF2,0;" );
+ break;
+ }
+
+ if( changeMask & GCTile && !pGC->tileIsPixel )
+ {
+ char *bits;
+ int h, w, sz;
+
+ h = pGC->tile.pixmap->drawable.height;
+ w = pGC->tile.pixmap->drawable.width;
+
+ if( pGC->tile.pixmap->drawable.depth == 1 )
+ {
+ sz = h * BitmapBytePad( w );
+
+ bits = (char *)xalloc( sz );
+ mfbGetImage(&(pGC->tile.pixmap->drawable), 0, 0, w, h, XYPixmap, ~0, bits);
+ PclSendPattern( bits, sz, 1, h, w, 100, *outFile );
+ xfree( bits );
+ }
+ else if( pGC->tile.pixmap->drawable.depth == 8 )
+ {
+ sz = h * PixmapBytePad( w, 8 );
+ bits = (char *)xalloc( sz );
+ cfbGetImage(&(pGC->tile.pixmap->drawable), 0, 0, w, h, ZPixmap, ~0, bits);
+ PclSendPattern( bits, sz, 8, h, w, 100, *outFile );
+ xfree( bits );
+ }
+#if PSZ == 32
+ else
+ {
+ sz = h * PixmapBytePad( w, 24 );
+
+ bits = (char *)xalloc( sz );
+ cfb32GetImage(&(pGC->tile.pixmap->drawable), 0, 0, w, h, ZPixmap, ~0, bits);
+ PclSendPattern( bits, sz, 24, h, w, 100, *outFile );
+ xfree( bits );
+ }
+#endif
+ }
+
+ if( changeMask & ( GCTileStipXOrigin | GCTileStipYOrigin ) )
+ {
+ char t[30];
+
+ sprintf( t, "AC%d,%d;", pGC->patOrg.x, pGC->patOrg.y );
+ SEND_PCL( *outFile, t );
+ }
+
+ /*
+ * We have to resend the stipple pattern either when the stipple itself
+ * changes, or if we're in FillOpaqueStippled mode and either the
+ * foreground or the background color changes.
+ */
+ if( changeMask & GCStipple ||
+ ( pGC->fillStyle == FillOpaqueStippled &&
+ ( pGC->fgPixel != gcPriv->stippleFg ||
+ pGC->bgPixel != gcPriv->stippleBg ) ) )
+ {
+ int h, w, i, sz, w2;
+ char *bits, *row, t[30];
+ PixmapPtr scratchPix;
+ GCPtr scratchGC;
+
+ if( pGC->stipple != NULL )
+ {
+ SEND_PCL( *outFile, "\033%0A" );
+
+ h = pGC->stipple->drawable.height;
+ w = pGC->stipple->drawable.width;
+ sz = h * BitmapBytePad( w );
+
+ bits = (char *)xalloc( sz );
+ mfbGetImage( &(pGC->stipple->drawable), 0, 0, w, h, XYPixmap, ~0, bits );
+
+ w2 = ( w / 8 ) + ( ( w%8 ) ? 1 : 0 );
+ /*
+ * XXX The PCL docs say that I need to word-align each
+ * XXX row, but I get garbage when I do...
+ */
+ /*
+ if( w2 % 2 )
+ w2++;
+ */
+
+ sprintf( t, "\033*c102g%dW", h * w2 + 8 );
+ SEND_PCL( *outFile, t );
+
+ sprintf( t, "%c%c%c%c%c%c%c%c", 0, 0, 1, 0, h>>8, h&0xff, w>>8,
+ w&0xff );
+ SEND_PCL_COUNT( *outFile, t, 8 );
+
+ for( row = bits, i = 0; i < h; i++, row += BitmapBytePad( w ) )
+ SEND_PCL_COUNT( *outFile, row, w2 );
+
+ SEND_PCL( *outFile, "\033%0B" );
+
+ xfree( bits );
+
+ /*
+ * Also do the opaque stipple, as a tile
+ */
+ if( pGC->depth != 1 )
+ sz = h * PixmapBytePad( w, pGC->depth );
+ bits = (char *)xalloc( sz );
+
+ scratchPix =
+ (*pGC->pScreen->CreatePixmap)( pGC->pScreen,
+ w, h, pGC->depth );
+ scratchGC = GetScratchGC( pGC->depth, pGC->pScreen );
+ CopyGC( pGC, scratchGC, ~0L );
+
+ if( pGC->depth == 1 )
+ {
+ mfbValidateGC( scratchGC, ~0L,
+ (DrawablePtr)scratchPix );
+ mfbCopyPlane( &(pGC->stipple->drawable),
+ (DrawablePtr)scratchPix, scratchGC, 0,
+ 0, w, h, 0, 0, 1 );
+ mfbGetImage( &(scratchPix->drawable), 0, 0, w, h, XYPixmap, ~0,
+ bits );
+ }
+ else if( pGC->depth <= 32 )
+ {
+#if PSZ == 8
+ cfbValidateGC( scratchGC, ~0L,
+ (DrawablePtr)scratchPix );
+ cfbCopyPlane( &(pGC->stipple->drawable),
+ (DrawablePtr)scratchPix, scratchGC, 0,
+ 0, w, h, 0, 0, 1 );
+ cfbGetImage( &(scratchPix->drawable), 0, 0, w, h, ZPixmap, ~0,
+ bits );
+#else
+ cfb32ValidateGC( scratchGC, ~0L,
+ (DrawablePtr)scratchPix );
+ cfb32CopyPlane( pGC->stipple,
+ (DrawablePtr)scratchPix, scratchGC, 0,
+ 0, w, h, 0, 0, 1 );
+ cfb32GetImage( scratchPix, 0, 0, w, h, ZPixmap, ~0,
+ bits );
+#endif
+ }
+ PclSendPattern( bits, sz, pGC->depth, h, w, 101, *outFile );
+ FreeScratchGC( scratchGC );
+ (*pGC->pScreen->DestroyPixmap)( scratchPix );
+ xfree( bits );
+ }
+ }
+
+ if( changeMask & ( GCTileStipXOrigin | GCTileStipYOrigin ) )
+ {
+ char t[30];
+
+ sprintf( t, "AC%d,%d;", pGC->patOrg.x, pGC->patOrg.y );
+ SEND_PCL( *outFile, t );
+ }
+
+ if( changeMask & GCDashList )
+ {
+ int num = pGC->numInDashList;
+ double total;
+ char dashes[20];
+ char t[100], t2[20];
+
+ /* Make up the doubled dash list, if necessary */
+ for( i = 0; i < 20 && i < num; i++ )
+ dashes[i] = pGC->dash[i];
+
+ if( num % 2 )
+ {
+ for( i = num; i < 20 && i < num + num; i++ )
+ dashes[i] = dashes[i-num];
+ if( ( num *= 2 ) > 20 )
+ num = 20;
+ }
+
+ /* Add up dash lengths to get percentage */
+ for( i = 0, total = 0; i < num; i++ )
+ total += dashes[i];
+
+ /* Build up the HP-GL/2 for the dash list */
+ strcpy( t, "UL8" );
+ for( i = 0; i < num; i++ )
+ {
+ sprintf( t2, ",%d",
+ (int)( ( (double)dashes[i] / total * 100.0 ) + 0.5 ) );
+ strcat( t, t2 );
+ }
+ strcat( t, ";" );
+ SEND_PCL( *outFile, t );
+ }
+
+
+ /* Go back to PCL mode */
+ SEND_PCL( *outFile, "\033%0A" );
+
+ /*
+ * Update the drawable's private information, which includes
+ * erasing the drawable's private changeMask, since all the
+ * changes have been made.
+ */
+ if( changeMask )
+ PclSetDrawablePrivateGC( pDrawable, *pGC );
+
+ return TRUE;
+}
+
+/*
+ * PclComputeCompositeClip()
+ *
+ * I'd like to use the miComputeCompositeClip function, but it sticks
+ * things into the mi GC privates, where the PCL driver can't get at
+ * it. So, rather than mess around with the mi code, I ripped it out
+ * and made the appropriate changes here.
+ */
+
+
+void
+PclComputeCompositeClip(
+ GCPtr pGC,
+ DrawablePtr pDrawable)
+{
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ {
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ RegionPtr pregWin;
+ Bool freeTmpClip, freeCompClip;
+
+ if (pGC->subWindowMode == IncludeInferiors)
+ {
+ pregWin = NotClippedByChildren(pWin);
+ freeTmpClip = TRUE;
+ }
+ else
+ {
+ pregWin = &pWin->clipList;
+ freeTmpClip = FALSE;
+ }
+ freeCompClip = pGC->freeCompClip;
+
+ /*
+ * if there is no client clip, we can get by with just keeping the
+ * pointer we got, and remembering whether or not should destroy (or
+ * maybe re-use) it later. this way, we avoid unnecessary copying of
+ * regions. (this wins especially if many clients clip by children
+ * and have no client clip.)
+ */
+ if (pGC->clientClipType == CT_NONE)
+ {
+ if (freeCompClip)
+ REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
+ pGC->pCompositeClip = pregWin;
+ pGC->freeCompClip = freeTmpClip;
+ }
+ else
+ {
+ /*
+ * we need one 'real' region to put into the composite clip. if
+ * pregWin the current composite clip are real, we can get rid of
+ * one. if pregWin is real and the current composite clip isn't,
+ * use pregWin for the composite clip. if the current composite
+ * clip is real and pregWin isn't, use the current composite
+ * clip. if neither is real, create a new region.
+ */
+
+ REGION_TRANSLATE(pGC->pScreen, pGC->clientClip,
+ pDrawable->x + pGC->clipOrg.x,
+ pDrawable->y + pGC->clipOrg.y);
+
+ if (freeCompClip)
+ {
+ REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
+ pregWin, pGC->clientClip);
+ if (freeTmpClip)
+ REGION_DESTROY(pGC->pScreen, pregWin);
+ }
+ else if (freeTmpClip)
+ {
+ REGION_INTERSECT(pGC->pScreen, pregWin, pregWin,
+ pGC->clientClip);
+ pGC->pCompositeClip = pregWin;
+ }
+ else
+ {
+ pGC->pCompositeClip = REGION_CREATE(pGC->pScreen, NullBox, 0);
+ REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
+ pregWin, pGC->clientClip);
+ }
+ pGC->freeCompClip = TRUE;
+ REGION_TRANSLATE(pGC->pScreen, pGC->clientClip,
+ -(pDrawable->x + pGC->clipOrg.x),
+ -(pDrawable->y + pGC->clipOrg.y));
+ }
+ } /* end of composite clip for a window */
+ else
+ {
+ BoxRec pixbounds;
+
+ /* XXX should we translate by drawable.x/y here ? */
+ pixbounds.x1 = 0;
+ pixbounds.y1 = 0;
+ pixbounds.x2 = pDrawable->width;
+ pixbounds.y2 = pDrawable->height;
+
+ if (pGC->freeCompClip)
+ {
+ REGION_RESET(pGC->pScreen, pGC->pCompositeClip, &pixbounds);
+ }
+ else
+ {
+ pGC->freeCompClip = TRUE;
+ pGC->pCompositeClip = REGION_CREATE(pGC->pScreen, &pixbounds, 1);
+ }
+
+ if (pGC->clientClipType == CT_REGION)
+ {
+ REGION_TRANSLATE(pGC->pScreen, pGC->pCompositeClip,
+ -pGC->clipOrg.x, -pGC->clipOrg.y);
+ REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
+ pGC->pCompositeClip, pGC->clientClip);
+ REGION_TRANSLATE(pGC->pScreen, pGC->pCompositeClip,
+ pGC->clipOrg.x, pGC->clipOrg.y);
+ }
+ } /* end of composite clip for pixmap */
+}
+
+/*
+ * PclValidateGC()
+ *
+ * Unlike many screen GCValidate routines, this function should not need
+ * to mess with setting the drawing functions. Different drawing
+ * functions are usually needed to optimize such things as drawing
+ * wide or dashed lines; this functionality will be handled primarily
+ * by the printer itself, while the necessary PCL code to set the
+ * attributes will be done in PclUpdateDrawableGC().
+ */
+
+/*ARGSUSED*/
+void
+PclValidateGC(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDrawable)
+{
+ /*
+ * Pixmaps should be handled by their respective validation
+ * functions.
+ */
+ if( pDrawable->type == DRAWABLE_PIXMAP )
+ {
+ if( pDrawable->depth == 1 )
+ {
+ mfbValidateGC( pGC, ~0, pDrawable );
+ }
+ else if( pDrawable->depth <= 32 )
+ {
+#if PSZ == 8
+ cfbValidateGC( pGC, ~0, pDrawable );
+#else
+ cfb32ValidateGC( pGC, ~0, pDrawable );
+#endif
+ }
+ return;
+ }
+
+ /*
+ * Reset the drawing operations
+ */
+ pGC->ops = &PclGCOps;
+
+ /*
+ * Validate the information, and correct it if necessary.
+ */
+
+ /*
+ * If necessary, compute the composite clip region. (Code ripped
+ * from migc.c)
+ */
+ if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
+ (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
+ )
+ {
+ PclComputeCompositeClip(pGC, pDrawable);
+ }
+
+ /*
+ * PCL does not directly support the DoubleDash line style, nor is
+ * there an easy way to simulate it, so we'll just change it to a
+ * LineOnOffDash, which is supported by PCL.
+ */
+ if( ( changes & GCLineStyle ) && ( pGC->lineStyle == LineDoubleDash ) )
+ pGC->lineStyle = LineOnOffDash;
+
+ /*
+ * Update the drawable's changeMask to reflect the changes made to the GC.
+ */
+/*
+ PclSetDrawablePrivateGC( pDrawable, *pGC, changes );
+*/
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclInit.c b/nx-X11/programs/Xserver/Xprint/pcl/PclInit.c
new file mode 100644
index 000000000..8bedee7c3
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclInit.c
@@ -0,0 +1,631 @@
+/* $Xorg: PclInit.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclInit.c
+** *
+** * Contents:
+** * Initialization code of Pcl driver for the print server.
+** *
+** * Created: 1/30/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclInit.c,v 1.11 2001/12/21 21:02:05 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "Pcl.h"
+
+#include "cfb.h"
+#include <X11/Xos.h> /* for unlink() */
+
+#include "attributes.h"
+#include "DiPrint.h"
+
+#define MODELDIRNAME "/models"
+
+static void AllocatePclPrivates(ScreenPtr pScreen);
+static int PclInitContext(XpContextPtr pCon);
+static Bool PclDestroyContext(XpContextPtr pCon);
+
+int PclScreenPrivateIndex;
+int PclContextPrivateIndex;
+int PclPixmapPrivateIndex;
+int PclWindowPrivateIndex;
+int PclGCPrivateIndex;
+
+#ifdef XP_PCL_COLOR
+/*
+ * The supported visuals on this screen
+ */
+static VisualRec Visuals[] =
+{
+ { 1, StaticGray, 1, 2, 1, 0, 0, 0, 0, 0, 0 },
+ { 2, PseudoColor, 8, 256, 8, 0, 0, 0, 0, 0, 0 },
+ { 3, TrueColor, 8, 256, 24, 0xFF0000, 0xFF00, 0xFF, 16, 8, 0 }
+};
+
+/*
+ * The supported depths on this screen
+ */
+static DepthRec Depths[] =
+{
+ { 1, 1, NULL },
+ { 8, 1, NULL },
+ { 24, 1, NULL }
+};
+#else
+/*
+ * The supported visuals on this screen
+ */
+static VisualRec Visuals[] =
+{
+ { 1, StaticGray, 1, 2, 1, 0, 0, 0, 0, 0, 0}
+};
+
+/*
+ * The supported depths on this screen
+ */
+static DepthRec Depths[] =
+{
+ { 1, 1, NULL }
+};
+#endif /* XP_PCL_COLOR */
+
+
+#define NUM_VISUALS(visuals) (sizeof(visuals) / sizeof(VisualRec))
+#define NUM_DEPTHS(depths) (sizeof(depths) / sizeof(DepthRec))
+
+Bool
+PclCloseScreen(int index,
+ ScreenPtr pScreen)
+{
+ PclScreenPrivPtr pPriv = pScreen->devPrivates[PclScreenPrivateIndex].ptr;
+
+ pScreen->CloseScreen = pPriv->CloseScreen;
+ xfree( pPriv );
+
+ return (*pScreen->CloseScreen)(index, pScreen);
+}
+
+Bool
+InitializePclDriver(
+ int ndx,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv)
+{
+ int maxRes, xRes, yRes, maxDim;
+ unsigned i;
+ PclScreenPrivPtr pPriv;
+
+ /*
+ * Register this driver's InitContext function with the print
+ * extension. This is a bit sleazy, as the extension hasn't yet
+ * been initialized, but the extensionneeds to know this, and this
+ * seems the best time to provide the information.
+ */
+#ifdef XP_PCL_COLOR
+ XpRegisterInitFunc( pScreen, "XP-PCL-COLOR", PclInitContext );
+#elif XP_PCL_MONO
+ XpRegisterInitFunc( pScreen, "XP-PCL-MONO", PclInitContext );
+#else
+ XpRegisterInitFunc( pScreen, "XP-PCL-LJ3", PclInitContext );
+#endif /* XP_PCL_MONO */
+
+ /*
+ * Create and fill in the devPrivate for the PCL driver.
+ */
+ AllocatePclPrivates(pScreen);
+
+ pPriv =
+ (PclScreenPrivPtr)pScreen->devPrivates[PclScreenPrivateIndex].ptr;
+
+ maxDim = MAX( pScreen->height, pScreen->width );
+ xRes = pScreen->width / ( pScreen->mmWidth / 25.4 );
+ yRes = pScreen->height / ( pScreen->mmHeight / 25.4 );
+ maxRes = MAX( xRes, yRes );
+
+#ifdef XP_PCL_COLOR
+ cfbScreenInit( pScreen, NULL, maxDim, maxDim, maxRes, maxRes,
+ maxRes );
+ /*
+ * Clean up the fields that we stomp (code taken from cfbCloseScreen)
+ */
+ for( i = 0; (int) i < pScreen->numDepths; i++ )
+ xfree( pScreen->allowedDepths[i].vids );
+ xfree( pScreen->allowedDepths );
+ xfree( pScreen->visuals );
+#else
+ mfbScreenInit( pScreen, NULL, maxDim, maxDim, maxRes, maxRes,
+ maxRes );
+#endif /* XP_PCL_COLOR */
+
+ miInitializeBackingStore ( pScreen );
+
+ pScreen->defColormap = FakeClientID(0);
+ pScreen->blackPixel = 1;
+ pScreen->whitePixel = 0;
+
+ pPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = PclCloseScreen;
+
+ pScreen->QueryBestSize = (QueryBestSizeProcPtr)PclQueryBestSize;
+ pScreen->SaveScreen = (SaveScreenProcPtr)_XpBoolNoop;
+ pScreen->GetImage = (GetImageProcPtr)_XpVoidNoop;
+ pScreen->GetSpans = (GetSpansProcPtr)_XpVoidNoop;
+ pScreen->CreateWindow = PclCreateWindow;
+ pScreen->DestroyWindow = PclDestroyWindow;
+/*
+ pScreen->PositionWindow = PclPositionWindow;
+*/
+ pScreen->ChangeWindowAttributes = PclChangeWindowAttributes;
+/*
+ pScreen->RealizeWindow = PclMapWindow;
+ pScreen->UnrealizeWindow = PclUnmapWindow;
+*/
+ pScreen->PaintWindowBackground = PclPaintWindow;
+ pScreen->PaintWindowBorder = PclPaintWindow;
+ pScreen->CopyWindow = PclCopyWindow; /* XXX Hard routine to write! */
+
+ pScreen->CreatePixmap = PclCreatePixmap;
+ pScreen->DestroyPixmap = PclDestroyPixmap;
+ pScreen->RealizeFont = PclRealizeFont;
+ pScreen->UnrealizeFont = PclUnrealizeFont;
+ pScreen->CreateGC = PclCreateGC;
+
+ pScreen->CreateColormap = PclCreateColormap;
+ pScreen->DestroyColormap = PclDestroyColormap;
+ pScreen->InstallColormap = (InstallColormapProcPtr)NoopDDA;
+ pScreen->UninstallColormap = (UninstallColormapProcPtr)NoopDDA;
+ pScreen->ListInstalledColormaps = PclListInstalledColormaps;
+ pScreen->StoreColors = PclStoreColors;
+/*
+ pScreen->ResolveColor = PclResolveColor;
+*/
+
+ pScreen->BitmapToRegion = mfbPixmapToRegion;
+
+ pScreen->ConstrainCursor = PclConstrainCursor;
+ pScreen->CursorLimits = PclCursorLimits;
+ pScreen->DisplayCursor = PclDisplayCursor;
+ pScreen->RealizeCursor = PclRealizeCursor;
+ pScreen->UnrealizeCursor = PclUnrealizeCursor;
+ pScreen->RecolorCursor = PclRecolorCursor;
+ pScreen->SetCursorPosition = PclSetCursorPosition;
+
+ pScreen->visuals = Visuals;
+ pScreen->numVisuals = NUM_VISUALS( Visuals );
+ pScreen->allowedDepths = Depths;
+ pScreen->numDepths = NUM_DEPTHS( Depths );
+
+ for( i = 0; i < NUM_DEPTHS( Depths ); i++ )
+ {
+ pScreen->allowedDepths[i].vids =
+ (VisualID *)xalloc( sizeof(VisualID ) );
+ pScreen->allowedDepths[i].vids[0] = i + 1;
+ }
+
+#ifdef XP_PCL_COLOR
+ pScreen->rootVisual = 2;
+ pScreen->rootDepth = 8;
+#else
+ pScreen->rootVisual = 1;
+ pScreen->rootDepth = 1;
+#endif /* XP_PCL_COLOR */
+
+ pPriv->colormaps = NULL;
+ PclCreateDefColormap( pScreen );
+
+ return TRUE;
+}
+
+static void
+AllocatePclPrivates(ScreenPtr pScreen)
+{
+ static unsigned long PclGeneration = 0;
+
+ if((unsigned long) PclGeneration != serverGeneration)
+ {
+ PclScreenPrivateIndex = AllocateScreenPrivateIndex();
+
+ PclWindowPrivateIndex = AllocateWindowPrivateIndex();
+ AllocateWindowPrivate( pScreen, PclWindowPrivateIndex,
+ sizeof( PclWindowPrivRec ) );
+
+ PclContextPrivateIndex = XpAllocateContextPrivateIndex();
+ XpAllocateContextPrivate( PclContextPrivateIndex,
+ sizeof( PclContextPrivRec ) );
+
+ PclGCPrivateIndex = AllocateGCPrivateIndex();
+ AllocateGCPrivate( pScreen, PclGCPrivateIndex,
+ sizeof( PclGCPrivRec ) );
+
+ PclPixmapPrivateIndex = AllocatePixmapPrivateIndex();
+ AllocatePixmapPrivate( pScreen, PclPixmapPrivateIndex,
+ sizeof( PclPixmapPrivRec ) );
+
+ PclGeneration = serverGeneration;
+ }
+
+ pScreen->devPrivates[PclScreenPrivateIndex].ptr = (pointer)xalloc(
+ sizeof(PclScreenPrivRec));
+}
+
+/*
+ * PclInitContext
+ *
+ * Establish the appropriate values for a PrintContext used with the PCL
+ * driver.
+ */
+
+static char DOC_ATT_SUPP[]="document-attributes-supported";
+static char DOC_ATT_VAL[]="document-format xp-listfonts-modes";
+static char JOB_ATT_SUPP[]="job-attributes-supported";
+static char JOB_ATT_VAL[]="";
+static char PAGE_ATT_SUPP[]="xp-page-attributes-supported";
+static char PAGE_ATT_VAL[]="content-orientation default-printer-resolution \
+default-input-tray default-medium plex xp-listfonts-modes";
+
+static int
+PclInitContext(XpContextPtr pCon)
+{
+ XpDriverFuncsPtr pFuncs;
+ PclContextPrivPtr pConPriv;
+ char *server, *attrStr;
+ char *modelID;
+ char *configDir;
+ char *pathName;
+ int i, j;
+ float width, height;
+ XpOidMediumDiscreteSizeList* ds_list;
+ XpOidArea* repro;
+ XpOid page_size;
+ XpOidMediumSS* m;
+
+ /*
+ * Initialize the attribute store for this printer.
+ */
+ XpInitAttributes( pCon );
+
+ /*
+ * Initialize the function pointers
+ */
+ pFuncs = &( pCon->funcs );
+ pFuncs->StartJob = PclStartJob;
+ pFuncs->EndJob = PclEndJob;
+ pFuncs->StartDoc = PclStartDoc;
+ pFuncs->EndDoc = PclEndDoc;
+ pFuncs->StartPage = PclStartPage;
+ pFuncs->EndPage = PclEndPage;
+ pFuncs->PutDocumentData = PclDocumentData;
+ pFuncs->GetDocumentData = PclGetDocumentData;
+ pFuncs->GetAttributes = PclGetAttributes;
+ pFuncs->SetAttributes = PclSetAttributes;
+ pFuncs->AugmentAttributes = PclAugmentAttributes;
+ pFuncs->GetOneAttribute = PclGetOneAttribute;
+ pFuncs->DestroyContext = PclDestroyContext;
+ pFuncs->GetMediumDimensions = PclGetMediumDimensions;
+ pFuncs->GetReproducibleArea = PclGetReproducibleArea;
+
+
+ /*
+ * Set up the context privates
+ */
+ pConPriv =
+ (PclContextPrivPtr)pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ pConPriv->jobFileName = (char *)NULL;
+ pConPriv->pageFileName = (char *)NULL;
+ pConPriv->pJobFile = (FILE *)NULL;
+ pConPriv->pPageFile = (FILE *)NULL;
+ pConPriv->dash = NULL;
+ pConPriv->validGC = 0;
+
+ pConPriv->getDocClient = (ClientPtr)NULL;
+ pConPriv->getDocBufSize = 0;
+ modelID = XpGetOneAttribute(pCon, XPPrinterAttr, "xp-model-identifier");
+ if ( (configDir = XpGetConfigDir(False)) != (char *) NULL ) {
+ pathName = (char *)xalloc(strlen(configDir) + strlen(MODELDIRNAME) +
+ strlen(modelID) + strlen("color.map") + 4);
+ if (pathName) {
+ sprintf(pathName, "%s/%s/%s/%s", configDir, MODELDIRNAME, modelID,
+ "color.map");
+ pConPriv->ctbl = PclReadMap(pathName, &pConPriv->ctbldim);
+ xfree(pathName);
+
+ } else
+ pConPriv->ctbl = NULL;
+ } else
+ pConPriv->ctbl = NULL;
+
+#ifdef XP_PCL_LJ3
+ /*
+ * Initialize the spooling buffer for saving the figures temporary
+ * (LaserJet IIIs printers don't support the macro function which
+ * includes some HP-GL/2 commands.)
+ */
+ pConPriv->fcount = 0;
+ if ( !(pConPriv->figures = (char *)xalloc(1024)) )
+ pConPriv->fcount_max = 0;
+ else
+ pConPriv->fcount_max = 1024;
+#endif /* XP_PCL_LJ3 */
+
+ /*
+ * document-attributes-supported
+ */
+ server = XpGetOneAttribute( pCon, XPServerAttr, DOC_ATT_SUPP );
+ if( ( attrStr = (char *)xalloc(strlen(server) + strlen(DOC_ATT_SUPP)
+ + strlen(DOC_ATT_VAL) +
+ strlen(PAGE_ATT_VAL) + 8 ) )
+ == (char *)NULL )
+ return BadAlloc;
+ sprintf( attrStr, "*%s:\t%s %s %s", DOC_ATT_SUPP, server,
+ DOC_ATT_VAL, PAGE_ATT_VAL );
+ XpAugmentAttributes( pCon, XPPrinterAttr, attrStr );
+ xfree( attrStr );
+
+ /*
+ * job-attributes-supported
+ */
+ server = XpGetOneAttribute( pCon, XPServerAttr, JOB_ATT_SUPP );
+ if( ( attrStr = (char *)xalloc(strlen(server) + strlen(JOB_ATT_SUPP)
+ + strlen(JOB_ATT_VAL) + 8 ) )
+ == (char *)NULL )
+ return BadAlloc;
+ sprintf( attrStr, "*%s:\t%s %s", JOB_ATT_SUPP, server, JOB_ATT_VAL );
+ XpAugmentAttributes( pCon, XPPrinterAttr, attrStr );
+ xfree( attrStr );
+
+ /*
+ * xp-page-attributes-supported
+ */
+ server = XpGetOneAttribute( pCon, XPServerAttr, PAGE_ATT_SUPP );
+ if( ( attrStr = (char *)xalloc(strlen(server) + strlen(PAGE_ATT_SUPP)
+ + strlen(PAGE_ATT_VAL) + 8 ) )
+ == (char *)NULL )
+ return BadAlloc;
+ sprintf( attrStr, "*%s:\t%s %s", PAGE_ATT_SUPP, server, PAGE_ATT_VAL );
+ XpAugmentAttributes( pCon, XPPrinterAttr, attrStr );
+ xfree( attrStr );
+
+ /*
+ * Validate the attribute pools
+ */
+ XpValidateAttributePool( pCon, XPPrinterAttr, &PclValidatePoolsRec );
+
+ /*
+ * Munge the reproducible areas to reflect the fact that PCL will not let
+ * me move the right or left margins closer than .25" to the edge of the
+ * paper.
+ */
+ m = XpGetMediumSSAttr( pCon, XPPrinterAttr,
+ xpoid_att_medium_source_sizes_supported,
+ (const XpOidList*) NULL,
+ (const XpOidList*) NULL );
+ for( i = 0; i < XpOidMediumSSCount( m ); i++ )
+ {
+ if( XpOidMediumSS_DISCRETE == (m->mss)[i].mstag )
+ {
+ ds_list = (m->mss)[i].ms.discrete;
+ for( j = 0; j < ds_list->count; j++ )
+ {
+ repro = &(ds_list->list)[j].assured_reproduction_area;
+ page_size = (ds_list->list)[j].page_size;
+ XpGetMediumMillimeters( page_size, &width, &height );
+
+ if( repro->minimum_x < 6.35 )
+ repro->minimum_x = 6.35;
+ if( width - repro->maximum_x < 6.35 )
+ repro->maximum_x = width - 6.35;
+ }
+ }
+ }
+ XpPutMediumSSAttr( pCon, XPPrinterAttr,
+ xpoid_att_medium_source_sizes_supported, m );
+ XpOidMediumSSDelete( m );
+
+ /*
+ * Finish validating the attribute pools
+ */
+
+ XpValidateAttributePool( pCon, XPDocAttr, &PclValidatePoolsRec );
+ XpValidateAttributePool( pCon, XPJobAttr, &PclValidatePoolsRec );
+ XpValidateAttributePool( pCon, XPPageAttr, &PclValidatePoolsRec );
+
+ /*
+ * Clear out the colormap storage
+ */
+ pConPriv->palettes = NULL;
+
+ return Success;
+}
+
+static Bool
+PclDestroyContext(XpContextPtr pCon)
+{
+ PclContextPrivPtr pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+ PclPaletteMapPtr p, t;
+ PclCmapToContexts *pCmap;
+ ScreenPtr screen;
+ PclScreenPrivPtr sPriv;
+ PclContextListPtr con, prevCon, temp;
+
+
+ /*
+ * Clean up the temporary files
+ */
+ if( pConPriv->pPageFile != (FILE *)NULL )
+ {
+ fclose( pConPriv->pPageFile );
+ pConPriv->pPageFile = (FILE *)NULL;
+ }
+ if( pConPriv->pageFileName != (char *)NULL )
+ {
+ unlink( pConPriv->pageFileName );
+ xfree( pConPriv->pageFileName );
+ pConPriv->pageFileName = (char *)NULL;
+ }
+
+ if( pConPriv->pJobFile != (FILE *)NULL )
+ {
+ fclose( pConPriv->pJobFile );
+ pConPriv->pJobFile = NULL;
+ }
+ if( pConPriv->jobFileName != (char *)NULL )
+ {
+ unlink( pConPriv->jobFileName );
+ xfree( pConPriv->jobFileName );
+ pConPriv->jobFileName = (char *)NULL;
+ }
+
+ xfree( pConPriv->dash );
+ xfree(pConPriv->ctbl);
+ pConPriv->ctbl = NULL;
+#ifdef XP_PCL_LJ3
+ xfree( pConPriv->figures );
+#endif /* XP_PCL_LJ3 */
+
+ /*
+ * Destroy the colormap<->palette mappings
+ */
+ p = pConPriv->palettes;
+ while( p )
+ {
+ t = p;
+ p = p->next;
+ xfree( t );
+ }
+ pConPriv->palettes = NULL;
+
+ /*
+ * Remove the context from the screen-level colormap<->contexts mappings
+ */
+ screen = screenInfo.screens[pCon->screenNum];
+ sPriv = (PclScreenPrivPtr)screen->devPrivates[PclScreenPrivateIndex].ptr;
+ pCmap = sPriv->colormaps;
+ while( pCmap )
+ {
+ con = pCmap->contexts;
+ prevCon = NULL;
+
+ while( con )
+ {
+ if( con->context->contextID == pCon->contextID )
+ {
+ if( prevCon )
+ {
+ temp = con;
+ prevCon->next = con = con->next;
+ }
+ else
+ {
+ temp = pCmap->contexts;
+ pCmap->contexts = con = con->next;
+ }
+ xfree( temp );
+ }
+ else
+ con = con->next;
+ }
+
+ pCmap = pCmap->next;
+ }
+
+ XpDestroyAttributes(pCon);
+
+ return Success;
+}
+
+XpContextPtr
+PclGetContextFromWindow(WindowPtr win)
+{
+ PclWindowPrivPtr pPriv;
+
+ while( win )
+ {
+ pPriv =
+ (PclWindowPrivPtr)win->devPrivates[PclWindowPrivateIndex].ptr;
+ if( pPriv->validContext )
+ return pPriv->context;
+
+ win = win->parent;
+ }
+
+ return NULL;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclLine.c b/nx-X11/programs/Xserver/Xprint/pcl/PclLine.c
new file mode 100644
index 000000000..f2b564df8
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclLine.c
@@ -0,0 +1,316 @@
+/* $Xorg: PclLine.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclLine.c
+** *
+** * Contents:
+** * Line drawing routines for the PCL driver
+** *
+** * Created: 10/11/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclLine.c,v 1.6 1999/12/13 02:12:55 robin Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Pcl.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+
+/*
+ * PclPolyLine()
+ * PclPolySegment()
+ *
+ * Generates PCL code to draw a polyline, or a collection of distinct
+ * line segments, clipped by the current clip region. Since PCL
+ * supports clipping to a rectangle, and the clip region is
+ * represented as a collection of visible rectangles, we can draw and
+ * clip the line by repeatedly drawing the complete line, clipped to
+ * each rectangle in the clip region.
+ *
+ * Since each box in the clipping region generates approximately 30
+ * bytes of PCL code, we have to have a way to avoid having a large
+ * number of boxes. The worst problem the case where the clipping
+ * region is a collection of one-pixel-high boxes, perhaps arising
+ * from a bitmap clip mask, or a region defined by a non-rectangular
+ * polygon.
+ *
+ * To alleviate this problem, we create a second clipping region,
+ * which consists of the union of the bounding boxes of each line
+ * segment. (Each bounding box is also increased by some amount
+ * related to the current line width to allow for non-zero-width
+ * lines, and for the various end and join styles.) This region is
+ * intersected with the "real" clipping region to get the region used
+ * to actually clip the polyline. This should result in a significant
+ * reduction in the number of clip rectangles, as the region-handling
+ * code should consolidate many of the fragments of one-pixel-high
+ * rectangles into larger rectangles.
+ */
+
+void
+PclPolyLine(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int nPoints,
+ xPoint *pPoints)
+{
+ char t[80];
+ FILE *outFile;
+ int xoffset = 0, yoffset = 0;
+ int nbox;
+ BoxPtr pbox;
+ xRectangle *drawRects, *r;
+ RegionPtr drawRegion, region;
+ short fudge;
+ int i;
+ XpContextPtr pCon;
+ PclContextPrivPtr pConPriv;
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return;
+
+ pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
+ pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ /*
+ * Allocate the storage required to deal with the clipping
+ * regions.
+ */
+ region = REGION_CREATE( pGC->pScreen, NULL, 0 );
+ drawRects = (xRectangle *)
+ xalloc( ( nPoints - 1 ) * sizeof( xRectangle ) );
+
+ /*
+ * Calculate the "fudge factor" based on the line width.
+ * Multiplying by three seems to be a good first guess.
+ * XXX I need to think of a way to test this.
+ */
+ fudge = 3 * pGC->lineWidth + 1;
+
+ /*
+ * Generate the PCL code to draw the polyline, by defining it as a
+ * macro which uses the HP-GL/2 line drawing function.
+ */
+
+ MACRO_START( outFile, pConPriv );
+ SAVE_PCL( outFile, pConPriv, "\033%0B" );
+
+ sprintf( t, "PU%d,%dPD\n", pPoints[0].x + pDrawable->x,
+ pPoints[0].y + pDrawable->y );
+ SAVE_PCL( outFile, pConPriv, t ); /* Move to the start of the polyline */
+
+ switch( mode )
+ {
+ case CoordModeOrigin:
+ xoffset = pDrawable->x;
+ yoffset = pDrawable->y;
+ SAVE_PCL( outFile, pConPriv, "PA" );
+ break;
+ case CoordModePrevious:
+ xoffset = yoffset = 0;
+ SAVE_PCL( outFile, pConPriv, "PR" );
+ break;
+ }
+
+ /*
+ * Build the "drawing region" as we build the PCL to draw the
+ * line.
+ */
+ for(i = 1, r = drawRects; i < nPoints; i++, r++ )
+ {
+ if( i != 1 )
+ SAVE_PCL( outFile, pConPriv, "," );
+
+ sprintf( t, "%d,%d", pPoints[i].x + xoffset,
+ pPoints[i].y + yoffset );
+ SAVE_PCL( outFile, pConPriv, t );
+
+ r->x = MIN( pPoints[i-1].x, pPoints[i].x ) + xoffset - fudge;
+ r->y = MIN( pPoints[i-1].y, pPoints[i].y ) + yoffset - fudge;
+ r->width = abs( pPoints[i-1].x - pPoints[i].x ) + 2 * fudge;
+ r->height = abs( pPoints[i-1].y - pPoints[i].y ) + 2 * fudge;
+ }
+ SAVE_PCL( outFile, pConPriv, ";\033%0A" ); /* End the macro */
+ MACRO_END( outFile );
+
+ /*
+ * Convert the collection of rectangles into a proper region, then
+ * intersect it with the clip region.
+ */
+ drawRegion = RECTS_TO_REGION( pGC->pScreen, nPoints - 1,
+ drawRects, CT_UNSORTED );
+ if( mode == CoordModePrevious )
+ REGION_TRANSLATE( pGC->pScreen, drawRegion, pPoints[0].x, pPoints[0].y );
+ REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip );
+
+ /*
+ * For each rectangle in the clip region, set the HP-GL/2 "input
+ * window" and render the entire polyline to it.
+ */
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
+
+ /*
+ * Clean up the temporary regions
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+ xfree( drawRects );
+}
+
+void
+PclPolySegment(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nSegments,
+ xSegment *pSegments)
+{
+ FILE *outFile, *dummy;
+ char t[80];
+ int xoffset, yoffset;
+ int nbox, i;
+ unsigned long valid;
+ BoxPtr pbox;
+ xRectangle *drawRects, *r;
+ RegionPtr drawRegion, region;
+ short fudge;
+ XpContextPtr pCon;
+ PclContextPrivPtr pConPriv;
+ GC cacheGC;
+
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return;
+
+ pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
+ pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ /*
+ * Allocate the storage for the temporary regions.
+ */
+ region = REGION_CREATE( pGC->pScreen, NULL, 0 );
+ drawRects = (xRectangle *)
+ xalloc( nSegments * sizeof( xRectangle ) );
+
+ /*
+ * Calculate the fudge factor, based on the line width
+ */
+ fudge = pGC->lineWidth * 3 + 1;
+
+ /*
+ * Turn off line joining.
+ */
+ SEND_PCL( outFile, "\033%0BLA2,6;\033%0A" );
+
+ /*
+ * Generate the PCL code to draw the segments, by defining them as
+ * a macro which uses the HP-GL/2 line drawing function.
+ *
+ * XXX I wonder if this should be implemented using the Encoded
+ * XXX Polyline function. Since I'm only sending it once, it's not
+ * XXX necessarily too important.
+ */
+
+ MACRO_START( outFile, pConPriv );
+ SAVE_PCL( outFile, pConPriv, "\033%0B" );
+
+ xoffset = pDrawable->x;
+ yoffset = pDrawable->y;
+
+ for( i = 0, r = drawRects; i < nSegments; i++, r++ )
+ {
+ r->x = MIN( pSegments[i].x1, pSegments[i].x2 ) + xoffset;
+ r->y = MIN( pSegments[i].y1, pSegments[i].y2 ) + yoffset;
+ r->width = abs( pSegments[i].x1 - pSegments[i].x2 );
+ r->height = abs( pSegments[i].y1 - pSegments[i].y2 );
+
+ sprintf( t, "PU%d,%d;PD%d,%d;", pSegments[i].x1 + xoffset,
+ pSegments[i].y1 + yoffset, pSegments[i].x2 +
+ xoffset, pSegments[i].y2 + yoffset );
+ SAVE_PCL( outFile, pConPriv, t );
+
+ r->x -= fudge;
+ r->y -= fudge;
+ r->width += 2 * fudge;
+ r->height += 2 * fudge;
+ }
+ SAVE_PCL( outFile, pConPriv, "\033%0A" );
+ MACRO_END ( outFile );
+
+ /*
+ * Convert the collection of rectangles into a proper region, then
+ * intersect it with the clip region.
+ */
+ drawRegion = RECTS_TO_REGION( pGC->pScreen, nSegments,
+ drawRects, CT_UNSORTED );
+ REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip );
+
+ /*
+ * For each rectangle in the clip region, set the HP-GL/2 "input
+ * window" and render the entire set of segments to it.
+ */
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
+
+ /*
+ * Now we need to reset the line join mode to whatever it was at before.
+ * The easiest way is to force the cached GC's joinstyle to be different
+ * from the current GC's joinstyle, then re-update the GC. This way, we
+ * don't have to duplicate code unnecessarily.
+ */
+ PclGetDrawablePrivateStuff( pDrawable, &cacheGC, &valid, &dummy );
+ cacheGC.joinStyle = !cacheGC.joinStyle;
+ PclSetDrawablePrivateGC( pDrawable, cacheGC );
+ PclUpdateDrawableGC( pGC, pDrawable, &outFile );
+
+ /*
+ * Clean up
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+ xfree( drawRects );
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclMisc.c b/nx-X11/programs/Xserver/Xprint/pcl/PclMisc.c
new file mode 100644
index 000000000..3a958e783
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclMisc.c
@@ -0,0 +1,306 @@
+/* $Xorg: PclMisc.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclMisc.c
+** *
+** * Contents:
+** * Miscellaneous code for Pcl driver.
+** *
+** * Created: 2/01/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclMisc.c,v 1.10tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <X11/Xos.h> /* for SIGCLD on pre-POSIX systems */
+#include "Pcl.h"
+
+#include "cursor.h"
+#include "resource.h"
+
+#include "windowstr.h"
+#include "propertyst.h"
+#include "attributes.h"
+
+
+/*ARGSUSED*/
+void
+PclQueryBestSize(
+ int type,
+ short *pwidth,
+ short *pheight,
+ ScreenPtr pScreen)
+{
+ unsigned width, highBit;
+
+ switch(type)
+ {
+ case CursorShape:
+ *pwidth = 0;
+ *pheight = 0;
+ break;
+ case TileShape:
+ case StippleShape:
+ width = *pwidth;
+ if (!width) break;
+ /* Return the nearest power of two >= what they gave us */
+ highBit = 0x80000000;
+ /* Find the highest 1 bit in the given width */
+ while(!(highBit & width))
+ highBit >>= 1;
+ /* If greater than that then return the next power of two */
+ if((highBit - 1) & width)
+ highBit <<= 1;
+ *pwidth = highBit;
+ /* height is a don't-care */
+ break;
+ }
+}
+
+/*
+ * GetPropString searches the window heirarchy from pWin up looking for
+ * a property by the name of propName. If found, returns the property's
+ * value. If not, it returns NULL.
+ */
+char *
+GetPropString(
+ WindowPtr pWin,
+ char *propName)
+{
+ Atom atom;
+ PropertyPtr pProp = (PropertyPtr)NULL;
+ char *retVal;
+
+ atom = MakeAtom(propName, strlen(propName), FALSE);
+ if(atom != BAD_RESOURCE)
+ {
+ WindowPtr pPropWin;
+ int n;
+
+ /*
+ * The atom has been defined, but it might only exist as a
+ * property on an unrelated window.
+ */
+ for(pPropWin = pWin; pPropWin != (WindowPtr)NULL;
+ pPropWin = pPropWin->parent)
+ {
+ for(pProp = (PropertyPtr)(wUserProps(pPropWin));
+ pProp != (PropertyPtr)NULL;
+ pProp = pProp->next)
+ {
+ if (pProp->propertyName == atom)
+ break;
+ }
+ if(pProp != (PropertyPtr)NULL)
+ break;
+ }
+ if(pProp == (PropertyPtr)NULL)
+ return (char *)NULL;
+
+ n = (pProp->format/8) * pProp->size; /* size (bytes) of prop */
+ retVal = (char *)xalloc(n + 1);
+ (void)memcpy((void *)retVal, (void *)pProp->data, n);
+ retVal[n] = '\0';
+
+ return retVal;
+ }
+
+ return (char *)NULL;
+}
+
+#include <signal.h>
+#include <errno.h>
+
+/* ARGSUSED */
+static void SigchldHndlr (
+ int dummy)
+{
+ int status;
+ int olderrno = errno;
+ struct sigaction act;
+ sigfillset(&act.sa_mask);
+ act.sa_flags = 0;
+ act.sa_handler = SigchldHndlr;
+
+ (void) wait (&status);
+
+ /*
+ * Is this really necessary?
+ */
+ sigaction(SIGCHLD, &act, (struct sigaction *)NULL);
+ errno = olderrno;
+}
+
+/*
+ * SystemCmd provides a wrapper for the 'system' library call. The call
+ * appears to be sensitive to the handling of SIGCHLD, so this wrapper
+ * sets the status to SIG_DFL, and then resets the established handler
+ * after system returns.
+ */
+int
+SystemCmd(char *cmdStr)
+{
+ int status;
+ struct sigaction newAct, oldAct;
+ sigfillset(&newAct.sa_mask);
+ newAct.sa_flags = 0;
+ newAct.sa_handler = SIG_DFL;
+ sigfillset(&oldAct.sa_mask);
+ oldAct.sa_flags = 0;
+ oldAct.sa_handler = SigchldHndlr;
+
+ /*
+ * get the old handler, and set the action to IGN
+ */
+ sigaction(SIGCHLD, &newAct, &oldAct);
+
+ status = system (cmdStr);
+
+ sigaction(SIGCHLD, &oldAct, (struct sigaction *)NULL);
+ return status;
+}
+
+
+/*
+ * PclGetMediumDimensions is installed in the GetMediumDimensions field
+ * of each Pcl-initialized context.
+ */
+int
+PclGetMediumDimensions(XpContextPtr pCon,
+ CARD16 *width,
+ CARD16 *height)
+{
+ XpGetMediumDimensions(pCon, width, height);
+ return Success;
+}
+
+/*
+ * PclGetReproducibleArea is installed in the GetReproducibleArea field
+ * of each Pcl-initialized context.
+ */
+int
+PclGetReproducibleArea(XpContextPtr pCon,
+ xRectangle *pRect)
+{
+ XpGetReproductionArea(pCon, pRect);
+ return Success;
+}
+
+#ifdef XP_PCL_LJ3
+/*
+ * PclSpoolFigs spooled the rendering PCL/HP-GL2 commands into the
+ * temporary buffer pointed by figures pointer in pcl private context.
+ * LaserJet IIIs printers don't support the macro function which
+ * includes some HP-GL/2 commands.
+ */
+void
+PclSpoolFigs(PclContextPrivPtr pConPriv, char *t, int n)
+{
+char *ptr;
+
+ ptr = pConPriv->figures;
+ while ( ( pConPriv->fcount + n) > pConPriv->fcount_max ) {
+ ptr = (char *)xrealloc(ptr, 1024 + pConPriv->fcount_max);
+ if ( !ptr )
+ return;
+ pConPriv->figures = ptr;
+ pConPriv->fcount_max += 1024;
+ }
+ ptr += pConPriv->fcount;
+ pConPriv->fcount += n;
+ memcpy(ptr, t, n);
+}
+#endif /* XP_PCL_LJ3 */
+
+/*
+ * PclSendData:
+ * For XP-PCL-COLOR/XP-PCL-MONO, it executes the macro stored before
+ * in the clipped area.
+ * For XP-PCL-LJ3, it draws the spooled figures in the clipped area.
+ */
+void
+PclSendData(
+ FILE *outFile,
+ PclContextPrivPtr pConPriv,
+ BoxPtr pbox,
+ int nbox,
+ double ratio
+)
+{
+char *ptr;
+int n;
+char t[80];
+
+#ifdef XP_PCL_LJ3
+ ptr = pConPriv->figures;
+ n = pConPriv->fcount;
+#else
+ ptr = "\033&f3X";
+ n = 5;
+#endif /* XP_PCL_LJ3 */
+
+ while( nbox )
+ {
+ /*
+ * Set the HP-GL/2 input window to the current
+ * rectangle in the clip region, then send the code to
+ * execute the macro defined above.
+ */
+ if (ratio == 1.0)
+ sprintf( t, "\033%%0BIW%d,%d,%d,%d;\033%%0A",
+ pbox->x1, pbox->y1,
+ pbox->x2, pbox->y2 );
+ else
+ sprintf( t, "\033%%0BIW%g,%d,%g,%d;\033%%0A",
+ ratio * pbox->x1, pbox->y1,
+ ratio * pbox->x2, pbox->y2 );
+
+ SEND_PCL( outFile, t );
+ SEND_PCL_COUNT( outFile, ptr, n);
+
+ nbox--;
+ pbox++;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclPixel.c b/nx-X11/programs/Xserver/Xprint/pcl/PclPixel.c
new file mode 100644
index 000000000..bfad618ed
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclPixel.c
@@ -0,0 +1,159 @@
+/* $Xorg: PclPixel.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclPixel.c
+** *
+** * Contents:
+** * Pixel-drawing code for the PCL DDX driver
+** *
+** * Created: 10/23/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclPixel.c,v 1.6tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+
+#include "windowstr.h"
+#include "gcstruct.h"
+
+#include "Pcl.h"
+
+void
+PclPolyPoint( pDrawable, pGC, mode, nPoints, pPoints )
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode;
+ int nPoints;
+ xPoint *pPoints;
+{
+ char t[80];
+ FILE *outFile;
+ int xoffset, yoffset;
+ BoxRec box;
+ int xloc, yloc, i;
+#if 0
+ XpContextPtr pCon;
+ PclContextPrivPtr cPriv;
+ PclPixmapPrivPtr pPriv;
+#endif
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return;
+
+ xoffset = pDrawable->x;
+ yoffset = pDrawable->y;
+
+ /*
+ * Enter HP-GL/2 and change the line style to one in which only
+ * the vertices of the specified polyline are drawn. We must also
+ * temporarily change the line width so that only a single pixel
+ * is drawn. Then move to the first possible location.
+ */
+ xloc = pPoints[0].x + pDrawable->x;
+ yloc = pPoints[0].y + pDrawable->y;
+
+ sprintf( t, "\27%%0BPW0,0;LT0;PU;PA%d,%d", xloc, yloc );
+ SEND_PCL( outFile, t );
+
+ /*
+ * Check each point against the clip region. If it is outside the
+ * region, don't send the PCL to the printer.
+ */
+
+ for( i = 0; i < nPoints; i++ )
+ {
+ if( POINT_IN_REGION( pGC->pScreen, pGC->clientClip, xloc, yloc, &box ) )
+ {
+ sprintf( t, ",%d,%d", xloc, yloc );
+ SEND_PCL( outFile, t );
+ }
+
+ if( mode == CoordModeOrigin )
+ {
+ xloc = pPoints[i+1].x + xoffset;
+ yloc = pPoints[i+1].y + yoffset;
+ }
+ else
+ {
+ xloc += pPoints[i+1].x;
+ yloc += pPoints[i+1].y;
+ }
+ }
+
+#if 0
+ /*
+ * Change the line style and width back to what they were before
+ * this routine was called. No, this isn't pretty...
+ */
+ if( pDrawable->type == DRAWABLE_WINDOW )
+ {
+ pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
+ cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
+ cPriv->changeMask = GCLineWidth | GCLineStyle;
+ }
+ else
+ {
+ pPriv =
+ ((PixmapPtr)pDrawable)->devPrivates[PclPixmapPrivateIndex].ptr;
+ pPriv->changeMask = GCLineWidth | GCLineStyle;
+ }
+#endif
+
+ PclUpdateDrawableGC( pGC, pDrawable, &outFile );
+
+ /*
+ * Go back to PCL
+ */
+ SEND_PCL( outFile, "\27%0A" );
+}
+
+void
+PclPushPixels( pGC, pBitmap, pDrawable, width, height, x, y )
+ GCPtr pGC;
+ PixmapPtr pBitmap;
+ DrawablePtr pDrawable;
+ int width;
+ int height;
+ int x;
+ int y;
+{
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclPixmap.c b/nx-X11/programs/Xserver/Xprint/pcl/PclPixmap.c
new file mode 100644
index 000000000..9449dfdd6
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclPixmap.c
@@ -0,0 +1,85 @@
+/* $Xorg: PclPixmap.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclPixmap.c
+** *
+** * Contents:
+** * Pixmap handling code for the PCL DDX driver
+** *
+** * Created: 2/19/96
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclPixmap.c,v 1.3 1999/12/16 02:26:27 robin Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Pcl.h"
+#include "cfb.h"
+#include "cfb32.h"
+#include "mfb.h"
+#include "pixmapstr.h"
+
+PixmapPtr
+PclCreatePixmap(ScreenPtr pScreen,
+ int width,
+ int height,
+ int depth)
+{
+ if( depth == 1 )
+ return mfbCreatePixmap( pScreen, width, height, depth );
+ else if( depth <= 8 )
+ return cfbCreatePixmap( pScreen, width, height, depth );
+ else if( depth <= 32 )
+ return cfb32CreatePixmap( pScreen, width, height, depth );
+ return 0;
+}
+
+
+Bool
+PclDestroyPixmap(PixmapPtr pPixmap)
+{
+ if( pPixmap->drawable.depth == 1 )
+ return mfbDestroyPixmap( pPixmap );
+ else if( pPixmap->drawable.depth <= 8 )
+ return cfbDestroyPixmap( pPixmap );
+ else if( pPixmap->drawable.depth <= 32 )
+ return cfb32DestroyPixmap( pPixmap );
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclPolygon.c b/nx-X11/programs/Xserver/Xprint/pcl/PclPolygon.c
new file mode 100644
index 000000000..41ba4b1c0
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclPolygon.c
@@ -0,0 +1,353 @@
+/* $Xorg: PclPolygon.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclPolygon.c
+** *
+** * Contents:
+** * Draws Polygons and Rectangles for the PCL DDX
+** *
+** * Created: 10/23/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclPolygon.c,v 1.6 1999/12/13 02:12:56 robin Exp $ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Pcl.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+
+void
+PclPolyRectangle(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nRects,
+ xRectangle *pRects)
+{
+ char t[80];
+ FILE *outFile;
+ int nbox, i;
+ BoxPtr pbox;
+ xRectangle *drawRects, *r;
+ RegionPtr drawRegion, region;
+ short fudge;
+ int xoffset, yoffset;
+ XpContextPtr pCon;
+ PclContextPrivPtr pConPriv;
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return;
+
+ pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
+ pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ /*
+ * Allocate the storage required to deal with the clipping
+ * regions.
+ */
+ region = REGION_CREATE( pGC->pScreen, NULL, 0 );
+ drawRects = (xRectangle *)xalloc( nRects * sizeof( xRectangle ) );
+
+ fudge = 3 * pGC->lineWidth + 1;
+
+ /*
+ * Generate the PCL code to draw the rectangles, by defining them
+ * as a macro which uses the HP-GL/2 rectangle drawing function.
+ */
+ MACRO_START( outFile, pConPriv );
+ SAVE_PCL( outFile, pConPriv, "\033%0B" );
+
+ xoffset = pDrawable->x;
+ yoffset = pDrawable->y;
+
+ for( i = 0, r = drawRects; i < nRects; i++, r++ )
+ {
+ xRectangle rect = pRects[i];
+
+ /* Draw the rectangle */
+ sprintf( t, "PU%d,%d;ER%d,%d;", rect.x + xoffset,
+ rect.y + yoffset, rect.width, rect.height );
+ SAVE_PCL( outFile, pConPriv, t );
+
+ /* Build the bounding box */
+ r->x = MIN( rect.x, rect.x + rect.width ) + xoffset -
+ fudge;
+ r->y = MIN( rect.y, rect.y + rect.height ) + yoffset -
+ fudge;
+ r->width = rect.width + 2 * fudge;
+ r->height = rect.height + 2 * fudge;
+ }
+ SAVE_PCL( outFile, pConPriv, ";\033%0A" ); /* End the macro */
+ MACRO_END( outFile );
+
+ /*
+ * Convert the collection of rectangles to a proper region, then
+ * intersect it with the clip region.
+ */
+ drawRegion = RECTS_TO_REGION( pGC->pScreen, nRects,
+ drawRects, CT_UNSORTED );
+
+ REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip );
+
+ /*
+ * For each rectangle in the clip region, set the HP-GL/2 "input
+ * window" and render the set of rectangles to it.
+ */
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
+
+ /*
+ * Clean up the temporary regions
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+ xfree( drawRects );
+}
+
+void
+PclFillPolygon(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int nPoints,
+ DDXPointPtr pPoints)
+{
+ char t[80];
+ FILE *outFile;
+ int nbox, i;
+ BoxPtr pbox;
+ BoxRec box;
+ RegionPtr drawRegion, region;
+ int xoffset, yoffset;
+ int xtop, xbottom, yleft, yright;
+ int fillRule;
+ XpContextPtr pCon;
+ PclContextPrivPtr pConPriv;
+ char *command;
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return;
+
+ pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
+ pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ /*
+ * Generate the PCL code to draw the filled polygon, by defining
+ * it as a macro which uses the HP-GL/2 polygon drawing function.
+ */
+ MACRO_START( outFile, pConPriv );
+ SAVE_PCL( outFile, pConPriv, "\033%0B" );
+
+ if( mode == CoordModeOrigin )
+ {
+ xoffset = pDrawable->x;
+ yoffset = pDrawable->y;
+ command = "PA";
+ }
+ else
+ {
+ xoffset = yoffset = 0;
+ command = "PR";
+ }
+
+ /* Begin the polygon */
+ sprintf( t, "PU%d,%d;PM0;%s", pPoints[0].x + xoffset, pPoints[0].y
+ + yoffset, command );
+ SAVE_PCL( outFile, pConPriv, t );
+
+ /* Seed the bounding box */
+ xtop = xbottom = pPoints[0].x + xoffset;
+ yleft = yright = pPoints[0].y + yoffset;
+
+ /* Add the rest of the points to the polygon */
+ for( i = 1; i < nPoints; i++ )
+ {
+ if( i != 1 )
+ SAVE_PCL( outFile, pConPriv, "," );
+
+ sprintf( t, "%d,%d", pPoints[i].x + xoffset, pPoints[i].y +
+ yoffset );
+ SAVE_PCL( outFile, pConPriv, t );
+
+ /* Update the bounding box */
+ xtop = MIN( xtop, pPoints[i].x + xoffset );
+ xbottom = MAX( xbottom, pPoints[i].x + xoffset );
+ yleft = MIN( yleft, pPoints[i].y + yoffset );
+ yright = MAX( yright, pPoints[i].y + yoffset );
+ }
+
+ /* Close the polygon and the macro */
+
+ if( pGC->fillRule == EvenOddRule )
+ fillRule = 0;
+ else
+ fillRule = 1;
+
+ sprintf( t, ";PM2;FP%d;\033%%0A", fillRule );
+ SAVE_PCL( outFile, pConPriv, t );
+ MACRO_END ( outFile );
+
+ /*
+ * Build the bounding region from the bounding box of the polygon
+ */
+ box.x1 = xtop;
+ box.y1 = yleft;
+ box.x2 = xbottom;
+ box.y2 = yright;
+ drawRegion = REGION_CREATE( pGC->pScreen, &box, 0 );
+
+ if( mode == CoordModePrevious )
+ REGION_TRANSLATE( pGC->pScreen, drawRegion, pPoints[0].x, pPoints[0].y );
+
+ region = REGION_CREATE( pGC->pScreen, NULL, 0 );
+
+ REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip );
+
+ /*
+ * For each rectangle in the clip region, set the HP-GL/2 "input
+ * window" and render the polygon to it.
+ */
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
+
+ /*
+ * Clean up the temporary regions
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+}
+
+void
+PclPolyFillRect(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nRects,
+ xRectangle *pRects)
+{
+ char t[80];
+ FILE *outFile;
+ int nbox, i;
+ BoxPtr pbox;
+ xRectangle *drawRects, *r;
+ RegionPtr drawRegion, region;
+ int xoffset, yoffset;
+ short fudge;
+ XpContextPtr pCon;
+ PclContextPrivPtr pConPriv;
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return;
+
+ pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
+ pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ /*
+ * Allocate the storage required to deal with the clipping
+ * regions.
+ */
+ region = REGION_CREATE( pGC->pScreen, NULL, 0 );
+ drawRects = (xRectangle *)xalloc( nRects * sizeof( xRectangle ) );
+
+
+ fudge = 3 * pGC->lineWidth + 1;
+
+ /*
+ * Generate the PCL code to draw the filled rectangles, by
+ * defining them as a macro which uses the HP-GL/2 rectangle
+ * drawing function.
+ */
+ MACRO_START( outFile, pConPriv );
+ SAVE_PCL( outFile, pConPriv, "\033%0B" );
+
+ xoffset = pDrawable->x;
+ yoffset = pDrawable->y;
+
+ for( i = 0, r = drawRects; i < nRects; i++, r++ )
+ {
+ xRectangle rect = pRects[i];
+
+ /* Draw the rectangle */
+ sprintf( t, "PU%d,%d;RR%d,%d;", rect.x + xoffset, rect.y +
+ yoffset, rect.width, rect.height );
+ SAVE_PCL( outFile, pConPriv, t );
+
+ /* Build the bounding box */
+ r->x = MIN( rect.x, rect.x + rect.width ) + xoffset - fudge;
+ r->y = MIN( rect.y, rect.y + rect.height ) + yoffset -
+ fudge;
+ r->width = rect.width + 2 * fudge;
+ r->height = rect.height + 2 * fudge;
+ }
+ SAVE_PCL( outFile, pConPriv, ";\033%0A" ); /* End the macro */
+ MACRO_END( outFile );
+
+ /*
+ * Convert the collection of rectangles to a proper region, then
+ * intersect it with the clip region.
+ */
+ drawRegion = RECTS_TO_REGION( pGC->pScreen, nRects,
+ drawRects, CT_UNSORTED );
+ REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip );
+
+ /*
+ * For each rectangle in the clip region, set the HP-GL/2 "input
+ * window" and render the set of rectangles to it.
+ */
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
+
+ /*
+ * Clean up the temporary regions
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+ xfree( drawRects );
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclPrint.c b/nx-X11/programs/Xserver/Xprint/pcl/PclPrint.c
new file mode 100644
index 000000000..701710253
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclPrint.c
@@ -0,0 +1,711 @@
+/* $Xorg: PclPrint.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclPrint.c
+** *
+** * Contents: Print extension code of Pcl driver
+** *
+** * Created: 2/03/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclPrint.c,v 1.7tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <X11/Xprotostr.h>
+
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#undef NEED_EVENTS
+
+#include "Pcl.h"
+
+#include "windowstr.h"
+#include "attributes.h"
+#include "AttrValid.h"
+#include "Oid.h"
+
+int
+PclStartJob(
+ XpContextPtr pCon,
+ Bool sendClientData,
+ ClientPtr client)
+{
+ PclContextPrivPtr pConPriv =
+ (PclContextPrivPtr)pCon->devPrivates[PclContextPrivateIndex].ptr;
+ PclPaletteMap *pal;
+
+ /*
+ * Check for existing page file, and delete it if it exists.
+ */
+ if(pConPriv->pageFileName != (char *)NULL)
+ {
+ if(pConPriv->pPageFile != (FILE *)NULL)
+ {
+ fclose(pConPriv->pPageFile);
+ pConPriv->pPageFile = (FILE *)NULL;
+ }
+ unlink(pConPriv->pageFileName);
+ xfree(pConPriv->pageFileName);
+ pConPriv->pageFileName = (char *)NULL;
+ }
+
+ /*
+ * Create a temporary file to store the printer output.
+ */
+ if (!XpOpenTmpFile("w+", &pConPriv->jobFileName, &pConPriv->pJobFile))
+ return BadAlloc;
+
+ /*
+ * Create/Initialize the SoftFontInfo structure
+ */
+ pConPriv->pSoftFontInfo = PclCreateSoftFontInfo();
+
+ /*
+ * Set up the colormap handling
+ */
+ pConPriv->palettes = NULL;
+ pConPriv->nextPaletteId = 4;
+ pConPriv->currentPalette = 0;
+
+ pal = &( pConPriv->staticGrayPalette );
+ pal->paletteId = 1;
+ pal->downloaded = 0;
+
+ pal = &( pConPriv->trueColorPalette );
+ pal->paletteId = 2;
+ pal->downloaded = 0;
+
+ pal = &( pConPriv->specialTrueColorPalette );
+ pal->paletteId = 3;
+ pal->downloaded = 0;
+
+ return Success;
+}
+
+int
+PclEndJob(
+ XpContextPtr pCon,
+ Bool cancel)
+{
+ PclContextPrivPtr priv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+#ifdef CCP_DEBUG
+ FILE *xpoutput;
+#endif
+ FILE *fp;
+ int retVal;
+ char *fileName, *trailer;
+ struct stat statBuf;
+ PclPaletteMapPtr p;
+
+ trailer = "\033%-12345X@PJL RESET\n";
+
+ if( cancel == True )
+ {
+ if( priv->getDocClient != (ClientPtr)NULL ) {
+ XpFinishDocData( priv->getDocClient );
+
+ priv->getDocClient = NULL;
+ priv->getDocBufSize = 0;
+ }
+
+ return Success;
+ }
+
+ if( priv->getDocClient != (ClientPtr)NULL && priv->getDocBufSize > 0 )
+ {
+ /*
+ * We need to stash the trailer information somewhere...
+ */
+ if (!XpOpenTmpFile("w+", &fileName, &fp))
+ return BadAlloc;
+
+#ifndef XP_PCL_LJ3
+ SEND_PCL( fp, trailer );
+ rewind( fp );
+
+ retVal = XpSendDocumentData( priv->getDocClient, fp,
+ strlen( trailer ),
+ priv->getDocBufSize );
+#endif /* XP_PCL_LJ3 */
+
+ fclose( fp );
+ unlink( fileName );
+ xfree( fileName );
+
+ if( priv->getDocClient != (ClientPtr)NULL ) {
+ XpFinishDocData( priv->getDocClient );
+
+ priv->getDocClient = NULL;
+ priv->getDocBufSize = 0;
+ }
+
+ return retVal;
+ }
+
+#ifndef XP_PCL_LJ3
+ SEND_PCL( priv->pJobFile, trailer );
+#endif /* XP_PCL_LJ3 */
+
+ /*
+ * Submit the job to the spooler
+ */
+ fflush( priv->pJobFile );
+
+ /*
+ * Dump the job file to another output file, for testing
+ * purposes.
+ */
+ rewind( priv->pJobFile );
+ stat( priv->jobFileName, &statBuf );
+
+#ifdef CCP_DEBUG
+ unlink( "/users/prince/XpOutput" );
+ xpoutput = fopen( "/users/prince/XpOutput", "w" );
+
+ rewind( priv->pJobFile );
+ TransferBytes( priv->pJobFile, xpoutput,
+ (int)statBuf.st_size );
+ fclose( xpoutput );
+#endif
+
+ XpSubmitJob( priv->jobFileName, pCon );
+ fclose( priv->pJobFile );
+ unlink( priv->jobFileName );
+ xfree( priv->jobFileName );
+ priv->jobFileName = NULL;
+
+ PclDestroySoftFontInfo(priv->pSoftFontInfo);
+ priv->pSoftFontInfo = (PclSoftFontInfoPtr) NULL;
+
+ /*
+ * Clear out the colormap cache
+ */
+ p = priv->palettes;
+ while( p )
+ {
+ p->downloaded = 0;
+ p = p->next;
+ }
+
+ return Success;
+}
+
+/* StartPage
+ *
+ * If page file exists
+ * close page file
+ * set page file pointer = NULL
+ * unlink page file
+ * Create a new page file
+ * Send the page header information to the page file
+ * ClearArea the window and all descendant windows
+ */
+int
+PclStartPage(
+ XpContextPtr pCon,
+ WindowPtr pWin)
+{
+ PclContextPrivPtr pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+ PclWindowPrivPtr pWinPriv =
+ (PclWindowPrivPtr)pWin->devPrivates[PclWindowPrivateIndex].ptr;
+ xRectangle repro;
+ char t[80];
+ XpOid orient, plex, tray, medium;
+ int dir, plexNum, num;
+
+ /*
+ * Put a pointer to the context in the window private structure
+ */
+ pWinPriv->validContext = 1;
+ pWinPriv->context = pCon;
+
+ /*
+ * Clear out the old page file, if necessary
+ */
+ if(pConPriv->pPageFile != (FILE *)NULL)
+ {
+ fclose(pConPriv->pPageFile);
+ pConPriv->pPageFile = (FILE *)NULL;
+ }
+ if(pConPriv->pageFileName != (char *)NULL)
+ {
+ unlink(pConPriv->pageFileName);
+ pConPriv->pageFileName = (char *)NULL;
+ }
+
+ /*
+ * Make up a new page file.
+ */
+ if (!XpOpenTmpFile("w+", &pConPriv->pageFileName, &pConPriv->pPageFile))
+ return BadAlloc;
+
+ /*
+ * Reset the GC cached in the context private struct.
+ */
+ pConPriv->validGC = 0;
+
+ /*
+ * Set the page orientation
+ */
+ orient = XpGetContentOrientation( pCon );
+ switch( orient )
+ {
+ case xpoid_val_content_orientation_landscape:
+ dir = 1;
+ break;
+ case xpoid_val_content_orientation_reverse_portrait:
+ dir = 2;
+ break;
+ case xpoid_val_content_orientation_reverse_landscape:
+ dir = 3;
+ break;
+ case xpoid_val_content_orientation_portrait:
+ default:
+ dir = 0;
+ break;
+ }
+ sprintf( t, "\033&l%dO", dir );
+ SEND_PCL( pConPriv->pPageFile, t );
+
+ /*
+ * Set the duplexing method. Since PCL wants to think of it in
+ * terms of the "binding edge," and the attribute store thinks in
+ * "duplex/tumble," this is a little complicated.
+ *
+ * Actually, this has no bearing on the output, since the HP1600C
+ * will only print on one side of the paper, and ignore all
+ * requests to enable duplexing. But, in an attempt to keep this
+ * driver somewhat generic, we'll enable it anyway.
+ */
+ plex = XpGetPlex( pCon );
+
+ if( plex == xpoid_val_plex_duplex )
+ {
+ if( dir == 0 || dir == 2 )
+ plexNum = 1;
+ else
+ plexNum = 2;
+ }
+ else if( plex == xpoid_val_plex_tumble )
+ {
+ if( dir == 0 || dir == 2 )
+ plexNum = 2;
+ else
+ plexNum = 1;
+ }
+ else
+ plexNum = 0;
+ sprintf( t, "\033&l%dS", plexNum );
+ SEND_PCL( pConPriv->pPageFile, t );
+
+ /*
+ * Set the input tray or medium. If XpGetPageSize gives us a valid medium,
+ * we can just send that to the printer, and let the printer handle the
+ * details. Otherwise, we select the tray returned from XpGetPageSize,
+ * which will be either a tray that should contain the correct medium
+ * (possibly with operator intervention), or the default tray from the
+ * config files.
+ */
+ medium = XpGetPageSize( pCon, &tray, NULL );
+ if( medium != xpoid_none )
+ {
+ switch( medium )
+ {
+ case xpoid_val_medium_size_na_legal:
+ num = 3;
+ break;
+ case xpoid_val_medium_size_iso_a3:
+ num = 27;
+ break;
+ case xpoid_val_medium_size_iso_a4:
+ num = 26;
+ break;
+ case xpoid_val_medium_size_executive:
+ num = 1;
+ break;
+ case xpoid_val_medium_size_ledger:
+ num = 6;
+ break;
+ case xpoid_val_medium_size_monarch_envelope:
+ num = 80;
+ break;
+ case xpoid_val_medium_size_na_number_10_envelope:
+ num = 81;
+ break;
+ case xpoid_val_medium_size_iso_designated_long:
+ num = 90;
+ break;
+ case xpoid_val_medium_size_iso_c5:
+ num = 91;
+ break;
+ case xpoid_val_medium_size_iso_b5:
+ num = 100;
+ break;
+ case xpoid_val_medium_size_jis_b5:
+ num = 45;
+ break;
+ case xpoid_val_medium_size_na_letter:
+ default:
+ num = 2;
+ break;
+ }
+ sprintf( t, "\033&l%dA", num );
+ SEND_PCL( pConPriv->pPageFile, t );
+ }
+ else
+ {
+ switch( tray )
+ {
+ case xpoid_val_input_tray_manual:
+ num = 2;
+ break;
+ case xpoid_val_input_tray_envelope:
+ num = 3;
+ break;
+ case xpoid_val_input_tray_large_capacity:
+ num = 5;
+ break;
+ case xpoid_val_input_tray_bottom:
+ num = 4;
+ break;
+ case xpoid_val_input_tray_main:
+ default:
+ num = 1;
+ break;
+ }
+ sprintf( t, "\033&l%dH", num );
+ SEND_PCL( pConPriv->pPageFile, t );
+ }
+
+ /*
+ * Set the scaling factors so that the HP-GL/2 coordinate system
+ * matches the X coordinate system, both in axis orientation and
+ * in unit<->pixel conversion.
+ */
+ XpGetReproductionArea( pCon, &repro );
+
+ sprintf( t, "\033&l0E\033*p%dx%dY", repro.x - 75, repro.y );
+ SEND_PCL( pConPriv->pPageFile, t );
+
+ sprintf( t, "\033*c%dx%dY\033*c0T", (int)(repro.width / 300.0 * 720.0),
+ (int)(repro.height / 300.0 * 720.0) );
+ SEND_PCL( pConPriv->pPageFile, t );
+
+ sprintf( t, "\033%%0BSC%d,%d,%d,%d;\033%%0A", repro.x, repro.x +
+ repro.width, repro.y + repro.height, repro.y );
+ SEND_PCL( pConPriv->pPageFile, t );
+
+ return Success;
+}
+
+/*
+ * When sending the generated PCL code back to the client, we send everything
+ * that we have generated so far for the job. After sending the data, we clean
+ * out the job file, to avoid repeatedly sending the same data.
+ */
+
+static int
+SendDocData( PclContextPrivPtr pPriv )
+{
+ struct stat statBuf;
+ int ret;
+
+ rewind( pPriv->pJobFile );
+ if( stat( pPriv->jobFileName, &statBuf ) < 0 )
+ return BadAlloc;
+
+ ret = XpSendDocumentData( pPriv->getDocClient, pPriv->pJobFile,
+ (int)statBuf.st_size, pPriv->getDocBufSize );
+
+ /*
+ * Clean out the job file
+ */
+ fclose( pPriv->pJobFile );
+ unlink( pPriv->jobFileName );
+
+ xfree(pPriv->jobFileName);
+
+ if (!XpOpenTmpFile("w+", &pPriv->jobFileName, &pPriv->pJobFile))
+ return BadAlloc;
+
+ return ret;
+}
+
+/*
+ * EndPage:
+ *
+ * Write page trailer to page file
+ * Write page file to job file
+ */
+int
+PclEndPage(
+ XpContextPtr pCon,
+ WindowPtr pWin)
+{
+ PclContextPrivPtr pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ struct stat statBuf;
+
+ /*
+ * Send the page trailer to the page file.
+ */
+ SEND_PCL( pConPriv->pPageFile, "\014" );
+ fflush( pConPriv->pPageFile );
+
+ /*
+ * Write the page file contents to the job file, or to the
+ * whatever client has called GetDocumentData.
+ *
+ * pWinPriv->pPageFile must first be set to the start of the page file.
+ */
+ rewind(pConPriv->pPageFile);
+ if(stat(pConPriv->pageFileName, &statBuf) < 0)
+ return BadAlloc;
+
+ if(TransferBytes(pConPriv->pPageFile, pConPriv->pJobFile,
+ (int)statBuf.st_size) != (int)statBuf.st_size)
+ return BadAlloc;
+
+ if( pConPriv->getDocClient != (ClientPtr)NULL &&
+ pConPriv->getDocBufSize > 0 )
+ {
+ return SendDocData( pConPriv );
+ }
+
+ return Success;
+}
+
+/*
+ * The PclStartDoc() and PclEndDoc() functions serve basically as NOOP
+ * placeholders. This driver doesn't deal with the notion of multiple
+ * documents per page.
+ */
+
+int
+PclStartDoc(XpContextPtr pCon,
+ XPDocumentType type)
+{
+ PclContextPrivPtr pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+#ifndef XP_PCL_LJ3
+ /*
+ * Set the printer resolution for the page. Since we can only
+ * render color at 300dpi, we just hard-code this.
+ */
+ SEND_PCL( pConPriv->pJobFile,
+ "\033%-12345X@PJL SET RESOLUTION = 300\r\n" );
+#endif /* XP_PCL_LJ3 */
+
+ /*
+ * Initialize HP-GL/2
+ */
+ SEND_PCL( pConPriv->pJobFile, "\033E\033%0BIN,SP1,TR0;\033%0A" );
+
+ /*
+ * Stash the type of the document (used by PutDocumentData operation)
+ */
+ pConPriv->isRaw = (type == XPDocRaw);
+
+ return Success;
+}
+
+int
+PclEndDoc(
+ XpContextPtr pCon,
+ Bool cancel)
+{
+ /*
+ * XXX What should I do if I get cancel == TRUE?
+ */
+ return Success;
+}
+
+/*
+ * PclDocumentData()
+ *
+ * Hand any pre-generated PDL down to the spool files, formatting it
+ * as necessary to fit the given window.
+ *
+ */
+
+#define DOC_PCL 1
+#define DOC_HPGL 2
+
+int
+PclDocumentData(
+ XpContextPtr pCon,
+ DrawablePtr pDraw,
+ char *pData,
+ int len_data,
+ char *pFmt,
+ int len_fmt,
+ char *pOpt,
+ int len_opt,
+ ClientPtr client)
+{
+ int type = 0;
+ PclContextPrivPtr pPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+ XpOidDocFmtList *formats;
+ XpOidDocFmt *f;
+ char t[80];
+ xRectangle repro;
+
+ /*
+ * Verify the input format
+ */
+ formats = XpGetDocFmtListAttr( pCon, XPPrinterAttr,
+ (pPriv->isRaw) ?
+ xpoid_att_xp_raw_formats_supported :
+ xpoid_att_xp_embedded_formats_supported,
+ NULL );
+ f = XpOidDocFmtNew( pFmt );
+ if( !XpOidDocFmtListHasFmt( formats, f ) )
+ {
+ XpOidDocFmtListDelete( formats );
+ XpOidDocFmtDelete( f );
+ return BadMatch;
+ }
+ XpOidDocFmtListDelete( formats );
+
+ if( !(pPriv->isRaw) )
+ {
+ if( !strcmp( f->format, "PCL" ) )
+ type = DOC_PCL;
+ else if( !strcmp( f->format, "HPGL" ) )
+ type = DOC_HPGL;
+ else
+ {
+ XpOidDocFmtDelete( f );
+ return BadMatch;
+ }
+
+ switch( type )
+ {
+ case DOC_HPGL:
+ /*
+ * Move the picture frame to the appropriate place on the page,
+ * then assume that the embedded code will scale it properly.
+ */
+ sprintf( t, "\033&l0E\033*p%dx%dY",
+ pDraw->x - 75,
+ pDraw->y );
+ SEND_PCL( pPriv->pPageFile, t );
+
+ sprintf( t, "\033*c%dx%dY\033*coT",
+ (int)( pDraw->width / 300.0 * 720.0 ),
+ (int)( pDraw->height / 300.0 * 720.0 ) );
+ SEND_PCL( pPriv->pPageFile, t );
+ break;
+ }
+ }
+
+
+ /*
+ * Send the data down the pipe
+ */
+ SEND_PCL_COUNT( pPriv->pPageFile, pData, len_data );
+
+ /*
+ * If it's not a raw document, clean up the embedding
+ */
+ if( !(pPriv->isRaw) )
+ switch( type )
+ {
+ case DOC_HPGL:
+ /*
+ * Reset the picture frame
+ */
+ XpGetReproductionArea( pCon, &repro );
+
+ sprintf( t, "\033&l0E\033*p%dx%dY", repro.x - 75, repro.y );
+ SEND_PCL( pPriv->pPageFile, t );
+
+ sprintf( t, "\033*c%dx%dY\033*c0T",
+ (int)(repro.width / 300.0 * 720.0),
+ (int)(repro.height / 300.0 * 720.0) );
+ SEND_PCL( pPriv->pPageFile, t );
+
+ sprintf( t, "\033%%0BSC%d,%d,%d,%d;\033%%0A", repro.x, repro.x +
+ repro.width, repro.y + repro.height, repro.y );
+ SEND_PCL( pPriv->pPageFile, t );
+ break;
+ }
+
+ XpOidDocFmtDelete( f );
+ return Success;
+}
+
+/*
+ *
+ * PclGetDocumentData()
+ *
+ * This function allows the driver to send the generated PCL back to
+ * the client.
+ *
+ * XXX This function is barely spec'ed, much less implemented!
+ */
+
+int
+PclGetDocumentData(
+ XpContextPtr pCon,
+ ClientPtr client,
+ int maxBufferSize)
+{
+ PclContextPrivPtr pPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ pPriv->getDocClient = client;
+ pPriv->getDocBufSize = maxBufferSize;
+
+ return Success;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.c b/nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.c
new file mode 100644
index 000000000..287c5c14f
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.c
@@ -0,0 +1,429 @@
+/* $Xorg: PclSFonts.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclSFonts.c
+** *
+** * Contents:
+** * Send Soft Font Download data to the specified
+** * file pointer.
+** *
+** * Created: 3/4/96
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclSFonts.c,v 1.7tsi Exp $ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include "Pcl.h"
+
+static char tmp1;
+static short tmp2;
+#define Put1byte(fp, x) tmp1=x; fwrite((char *)&tmp1, 1, 1, fp)
+#define Put2bytes(fp, x) tmp2=x; fwrite((char *)&tmp2, 2, 1, fp)
+
+#define ESC 0x1b
+#define SYMBOL_SET 277
+
+static unsigned int PclDownloadChar(FILE *,PclCharDataPtr,unsigned short,unsigned char);
+static unsigned int PclDownloadHeader(FILE *, PclFontDescPtr, unsigned short);
+
+#ifdef PCL_FONT_COMPRESS
+static unsigned char *compress_bitmap_data(PclCharDataPtr, unsigned int *);
+#endif /* PCL_FONT_COMPRESS */
+
+/* -*- PclDownloadSoftFont8 -*-
+ * Send the Character Definition Command for 8-bit font
+ * **************************************************************************/
+void
+PclDownloadSoftFont8(
+ FILE *fp,
+ PclSoftFontInfoPtr pSoftFontInfo,
+ PclFontHead8Ptr pfh,
+ PclCharDataPtr pcd,
+ unsigned char *code
+)
+{
+ /*
+ * Check whether the font header has already been downloaded.
+ * If not, download it.
+ */
+
+ if ( !pfh->fid ) {
+ pfh->fid = pSoftFontInfo->cur_max_fid++;
+ PclDownloadHeader(fp, &(pfh->fd), pfh->fid);
+ }
+ pfh->index[*code] = *code;
+ PclDownloadChar(fp, pcd, pfh->fid, pfh->index[*code]);
+
+}
+
+/* -*- PclDownloadSoftFont16 -*-
+ * Send the Character Definition Command for 16 bit font
+ * **************************************************************************/
+void
+PclDownloadSoftFont16(
+ FILE *fp,
+ PclSoftFontInfoPtr pSoftFontInfo,
+ PclFontHead16Ptr pfh,
+ PclCharDataPtr pcd,
+ unsigned char row,
+ unsigned char col
+)
+{
+ /*
+ * Check whether the font header is already downloaded.
+ * If not, download it.
+ */
+
+ if ( !pfh->cur_cindex ) {
+ pfh->cur_fid = pSoftFontInfo->cur_max_fid++;
+ PclDownloadHeader(fp, &(pfh->fd), pfh->cur_fid);
+ }
+ pfh->index[row][col].fid = pfh->cur_fid;
+ pfh->index[row][col].cindex = pfh->cur_cindex++;
+
+ PclDownloadChar(fp, pcd, pfh->index[row][col].fid, pfh->index[row][col].cindex);
+}
+
+/* -*- PclCreateSoftFontInfo -*-
+ * Create and Initialize the structure for storing the information
+ * of the downloaded soft font.
+ * **************************************************************************/
+PclSoftFontInfoPtr
+PclCreateSoftFontInfo(void)
+{
+PclSoftFontInfoPtr pSoftFontInfo;
+
+ pSoftFontInfo = (PclSoftFontInfoPtr)xalloc(sizeof(PclSoftFontInfoRec));
+ if ( pSoftFontInfo == (PclSoftFontInfoPtr) NULL)
+ return (PclSoftFontInfoPtr) NULL;
+ pSoftFontInfo->phead8 = (PclFontHead8Ptr)NULL;
+ pSoftFontInfo->phead16 = (PclFontHead16Ptr)NULL;
+ pSoftFontInfo->pinfont = (PclInternalFontPtr)NULL;
+ pSoftFontInfo->cur_max_fid = 1;
+ return pSoftFontInfo;
+}
+
+/* -*- PclDestroySoftFontInfo -*-
+ * Destroy the soft font information structure
+ * **************************************************************************/
+void
+PclDestroySoftFontInfo( PclSoftFontInfoPtr pSoftFontInfo )
+{
+PclFontHead8Ptr pfh8, pfh8_next;
+PclFontHead16Ptr pfh16, pfh16_next;
+PclInternalFontPtr pin, pin_next;
+unsigned char nindex_row;
+int i;
+
+ if ( pSoftFontInfo == (PclSoftFontInfoPtr) NULL )
+ return;
+
+ pfh8 = pSoftFontInfo->phead8;
+ while (pfh8 != (PclFontHead8Ptr) NULL) {
+ xfree(pfh8->fontname);
+ xfree(pfh8->index);
+ pfh8_next = pfh8->next;
+ xfree(pfh8);
+ pfh8 = pfh8_next;
+ }
+
+ pfh16 = pSoftFontInfo->phead16;
+ while (pfh16 != (PclFontHead16Ptr) NULL) {
+ xfree(pfh16->fontname);
+ nindex_row = pfh16->lastRow - pfh16->firstRow + 1;
+ for (i=0; i<nindex_row; i++)
+ xfree(pfh16->index[i]);
+ xfree(pfh16->index);
+ pfh16_next = pfh16->next;
+ xfree(pfh16);
+ pfh16 = pfh16_next;
+ }
+
+ pin = pSoftFontInfo->pinfont;
+ while (pin != (PclInternalFontPtr) NULL) {
+ xfree(pin->fontname);
+ pin_next = pin->next;
+ xfree(pin);
+ pin = pin_next;
+ }
+
+ xfree(pSoftFontInfo);
+}
+
+/* -*- PclDownloadHeader -*-
+ * Send the Font Header Commnad.
+ * Format 0 : Font Header for Pcl Bitmapped Fonts
+ * Format 20 : Font Header for Resolution Specified Bitmapped Fonts
+ * **************************************************************************/
+static unsigned int
+PclDownloadHeader(
+ FILE *fp,
+ PclFontDescPtr fd,
+ unsigned short fid
+)
+{
+int nbytes;
+
+#ifdef XP_PCL_LJ3
+ nbytes = 64;
+#else
+ nbytes = 68;
+#endif /* XP_PCL_LJ3 */
+ /*
+ * Font ID Command : Esc *c#D
+ * (Default = 0, Range = 0 - 32767)
+ */
+ fprintf(fp, "%c*c%dD", ESC, fid);
+
+ /*
+ * Font Header Commnad : Esc )s#W[font header data]
+ * (Default = 0, Range = 0 - 32767)
+ */
+ fprintf(fp, "%c)s%dW", ESC, nbytes);
+
+ Put2bytes(fp, nbytes); /* Font Description Size */
+#ifdef XP_PCL_LJ3
+ Put1byte(fp, 0); /* Header Format */
+#else
+ Put1byte(fp, 20); /* Header Format */
+#endif /* XP_PCL_LJ3 */
+ Put1byte(fp, 2); /* Font Type */
+ Put2bytes(fp, 0); /* Style MSB */
+ Put2bytes(fp, fd->ascent); /* BaseLine Position */
+ Put2bytes(fp, fd->cellwidth); /* Cell Width */
+ Put2bytes(fp, fd->cellheight); /* Cell Height */
+ Put1byte(fp, 0); /* Orienation */
+ Put1byte(fp, fd->spacing); /* Spacing */
+ Put2bytes(fp, SYMBOL_SET); /* Symbol Set */
+ Put2bytes(fp, fd->pitch*4); /* font pitch */
+ Put2bytes(fp, fd->cellheight * 4); /* Height */
+ Put2bytes(fp, 0); /* x-Height */
+ Put1byte(fp, 0); /* width type (normal) */
+ Put1byte(fp, 0); /* Style LSB */
+ Put1byte(fp, 0); /* Stroke Weight */
+ Put1byte(fp, 5); /* Typeface LSB */
+ Put1byte(fp, 0); /* Typeface MSB */
+ Put1byte(fp, 0); /* Serif Style */
+ Put1byte(fp, 0); /* Quality */
+ Put1byte(fp, 0); /* Placement */
+ Put1byte(fp, 0); /* Underline Position */
+ Put1byte(fp, 0); /* Underline Thickness */
+ Put2bytes(fp, fd->cellheight*1.2); /* Text Height */
+ Put2bytes(fp, fd->cellwidth * 4); /* Text Width */
+ Put2bytes(fp, 0); /* First Code */
+ Put2bytes(fp, 255); /* Last Code */
+ Put1byte(fp, 0); /* Pitch Extend */
+ Put1byte(fp, 0); /* Height Extend */
+ Put2bytes(fp, 0); /* Cap Height */
+ Put2bytes(fp, 0); /* Font Number 1 */
+ Put2bytes(fp, 0); /* Font Number 2 */
+ Put2bytes(fp, 0); /* Font Name */
+ Put2bytes(fp, 0); /* Font Name */
+ Put2bytes(fp, 0); /* Font Name */
+ Put2bytes(fp, 0); /* Font Name */
+ Put2bytes(fp, 0); /* Font Name */
+ Put2bytes(fp, 0); /* Font Name */
+ Put2bytes(fp, 0); /* Font Name */
+ Put2bytes(fp, 0); /* Font Name */
+
+#ifdef XP_PCL_LJ3
+ return 64;
+#else
+ Put2bytes(fp, 300); /* X Resolution */
+ Put2bytes(fp, 300); /* Y Resolution */
+ return 68;
+#endif /* XP_PCL_LJ3 */
+
+}
+
+/* -*- PclDownloadCharacter -*-
+ * Send the Character Definition Command.
+ * **************************************************************************/
+static unsigned int
+PclDownloadChar(
+ FILE *fp,
+ PclCharDataPtr cd,
+ unsigned short fid,
+ unsigned char code
+)
+{
+unsigned int nbytes, n;
+unsigned char *raster;
+
+ /*
+ * Font ID Command : Esc *c#D
+ * (Default = 0, Range = 0 - 32767)
+ * Character Code Command : Esc *c#E
+ * (Default = 0, Range = 0 - 65535)
+ */
+ fprintf(fp, "%c*c%dd%dE", ESC, fid, code);
+
+ /*
+ * Character Definition Command : Esc (s#W[character descriptor and data]
+ * (Default = N/A, Range = 0 - 32767)
+ */
+
+ nbytes = n = cd->height * ((cd->width + 7) / 8);
+#ifdef PCL_FONT_COMPRESS
+ raster = compress_bitmap_data(cd, &nbytes);
+#else
+ raster = (unsigned char *)NULL;
+#endif /* PCL_FONT_COMPRESS */
+ fprintf(fp, "%c(s%dW", ESC, nbytes + 16);
+
+ Put1byte(fp, 4); /* Format */
+ Put1byte(fp, 0); /* Continuation */
+ Put1byte(fp, 14); /* Descriptor Size */
+ if (raster) { /* Class */
+ Put1byte(fp, 2);
+ } else {
+ Put1byte(fp, 1); /* Class */
+ }
+ Put2bytes(fp, 0); /* Orientation */
+ Put2bytes(fp, cd->h_offset); /* left offset */
+ Put2bytes(fp, cd->v_offset); /* top offset */
+ Put2bytes(fp, cd->width); /* character width */
+ Put2bytes(fp, cd->height); /* character height */
+ Put2bytes(fp, cd->font_pitch*4); /* delta X */
+
+ /*
+ * Raster Character Data
+ */
+ if (raster) {
+ fwrite(raster, nbytes, 1, fp);
+ xfree(raster);
+ } else
+ fwrite(cd->raster_top, nbytes, 1, fp);
+
+ return n + 16;
+}
+
+
+#ifdef PCL_FONT_COMPRESS
+/* -*- compress_bitmap_data -*-
+ * Compress Bitmap data
+ * **************************************************************************/
+static unsigned char *
+compress_bitmap_data(
+ PclCharDataPtr cd,
+ unsigned int *nbytes
+)
+{
+unsigned int byte_width;
+unsigned char *raster, *rptr_s, *rptr_e, *rptr_end;
+unsigned char *tmp_s, *tmp_ptr;
+unsigned char *p;
+unsigned char cur, pixel;
+unsigned int num;
+
+int i, j, k, w;
+
+ byte_width = (cd->width + 7) / 8;
+ *nbytes = cd->height * byte_width;
+
+ /* Create buffer for storing compress bitmap glyph */
+ raster = (unsigned char *)xalloc(*nbytes);
+ rptr_s = raster;
+ rptr_e = raster;
+ rptr_end = raster + *nbytes;
+
+ tmp_s = (unsigned char *)xalloc(cd->width * 8 + 2);
+
+ p = cd->raster_top;
+ for (i=0; i<cd->height; i++) {
+ tmp_ptr = tmp_s;
+ *tmp_ptr++ = 0;
+ if ( (*p>>7)&0x1 == 1 ) {
+ *tmp_ptr++ = 0;
+ cur = 1;
+ } else {
+ cur = 0;
+ }
+ num = 0;
+ for (j=0, w=0; j<byte_width; j++, p++) {
+ for (k=0; k<8 && w<cd->width; k++, w++) {
+ pixel = (*p>>(7-k))&0x1;
+ if ( pixel == cur ) {
+ num++;
+ } else {
+ cur = pixel;
+ while (num > 255) {
+ *tmp_ptr++ = 255;
+ *tmp_ptr++ = 0;
+ num -= 255;
+ }
+ *tmp_ptr++ = num;
+ num = 1;
+ }
+ }
+ }
+ if ( pixel == cur ) {
+ while (num > 255) {
+ *tmp_ptr++ = 255;
+ *tmp_ptr++ = 0;
+ num -= 255;
+ }
+ *tmp_ptr++ = num&0xff;
+ } else
+ *tmp_ptr++ = num;
+
+ if ( ((rptr_e - rptr_s) == (tmp_ptr - tmp_s)) &&
+ !memcmp(rptr_s+1, tmp_s+1, (tmp_ptr - tmp_s) - 1) )
+ *rptr_s += 1;
+ else {
+ if ( rptr_e + (tmp_ptr - tmp_s) > rptr_end ) {
+ xfree(raster);
+ xfree(tmp_s);
+ return (unsigned char *)NULL;
+ }
+ memcpy (rptr_e, tmp_s, tmp_ptr - tmp_s);
+ rptr_s = rptr_e;
+ rptr_e = rptr_s + (tmp_ptr - tmp_s);
+ }
+ }
+ xfree(tmp_s);
+ *nbytes = rptr_e - raster;
+
+ return raster;
+}
+#endif /* PCL_FONT_COMPRESS */
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.h b/nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.h
new file mode 100644
index 000000000..fdd62f651
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.h
@@ -0,0 +1,116 @@
+/* $Xorg: PclSFonts.h,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _PCLFONTS_H
+#define _PCLFONTS_H
+
+/* -*-H-*-
+******************************************************************************
+******************************************************************************
+*
+* File: PclFonts.h
+* Description: Send Soft Font Download data to the specified file pointer.
+*
+*
+******************************************************************************
+******************************************************************************
+*/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+
+typedef struct {
+ unsigned char fid; /* sfont font ID */
+ unsigned char cindex; /* character indext */
+} PclFontMapRec, PclFontMapPtr;
+
+typedef struct {
+ int h_offset;
+ int v_offset;
+ unsigned int width;
+ unsigned int height;
+ int font_pitch;
+ unsigned char *raster_top;
+} PclCharDataRec, *PclCharDataPtr;
+
+typedef struct {
+ unsigned char spacing;
+ unsigned int pitch;
+ unsigned int cellheight;
+ unsigned int cellwidth;
+ int ascent;
+ int descent;
+} PclFontDescRec, *PclFontDescPtr;
+
+typedef struct _PclFontHead8Rec {
+ char *fontname;
+ PclFontDescRec fd;
+ unsigned short fid;
+ unsigned char *index;
+ struct _PclFontHead8Rec *next;
+} PclFontHead8Rec, *PclFontHead8Ptr;
+
+typedef struct _PclFontHead16Rec {
+ char *fontname;
+ PclFontDescRec fd;
+ unsigned short cur_fid;
+ unsigned char cur_cindex;
+ PclFontMapRec **index;
+ unsigned short firstCol;
+ unsigned short lastCol;
+ unsigned short firstRow;
+ unsigned short lastRow;
+ struct _PclFontHead16Rec *next;
+} PclFontHead16Rec, *PclFontHead16Ptr;
+
+typedef struct _PclInternalFontRec {
+ char *fontname;
+ float pitch;
+ float height;
+ char *pcl_font_name;
+ char *spacing;
+ struct _PclInternalFontRec *next;
+} PclInternalFontRec, *PclInternalFontPtr;
+
+typedef struct {
+ PclFontHead8Ptr phead8;
+ PclFontHead16Ptr phead16;
+ PclInternalFontPtr pinfont;
+ unsigned char cur_max_fid;
+} PclSoftFontInfoRec, *PclSoftFontInfoPtr;
+
+#define MONOSPACE 0
+#define PROPSPACE 1
+
+#endif /* _PCLFONTS_H */
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclSpans.c b/nx-X11/programs/Xserver/Xprint/pcl/PclSpans.c
new file mode 100644
index 000000000..51c0137fc
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclSpans.c
@@ -0,0 +1,139 @@
+/* $Xorg: PclSpans.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclSpans.c
+** *
+** * Contents:
+** * Code to set and fill spans in the PCL DDX
+** *
+** * Created: 10/23/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclSpans.c,v 1.5 1999/12/13 02:12:57 robin Exp $ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Pcl.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+
+void
+PclFillSpans(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nSpans,
+ DDXPointPtr pPoints,
+ int *pWidths,
+ int fSorted)
+{
+ char t[80];
+ FILE *outFile;
+ int xoffset, yoffset;
+ xRectangle *rects, *r;
+ RegionPtr fillRegion, region = 0;
+ int i;
+ int nbox;
+ BoxPtr pbox;
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return;
+
+ /*
+ * Build a region out of the spans
+ */
+ rects = (xRectangle *)xalloc( nSpans * sizeof( xRectangle ) );
+ xoffset = pDrawable->x;
+ yoffset = pDrawable->y;
+
+ for( i = 0, r = rects; i < nSpans; i++, r++ )
+ {
+ r->x = pPoints[i].x + xoffset;
+ r->y = pPoints[i].y + yoffset;
+ r->width = pWidths[i];
+ r->height = 1;
+ }
+ fillRegion = RECTS_TO_REGION( pGC->pScreen, nSpans, rects, ( fSorted ) ?
+ CT_YSORTED : CT_UNSORTED );
+
+ /*
+ * Intersect this region with the clip region. Whatever's left,
+ * should be filled.
+ */
+ REGION_INTERSECT( pGC->pScreen, region, fillRegion, pGC->clientClip );
+
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ /* Enter HP-GL/2 */
+ SEND_PCL( outFile, "\27%0B" );
+
+ while( nbox )
+ {
+ sprintf( t, "PU%d,%d;RR%d,%d;", pbox->x1, pbox->y1,
+ pbox->x2, pbox->y2 );
+ SEND_PCL( outFile, t );
+
+ nbox--;
+ pbox++;
+ }
+
+ /* Go back to PCL */
+ SEND_PCL( outFile, "\27%0A" );
+
+ /*
+ * Clean up the temporary regions
+ */
+ REGION_DESTROY( pGC->pScreen, fillRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+ xfree( rects );
+}
+
+void
+PclSetSpans(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *pSrc,
+ DDXPointPtr pPoints,
+ int *pWidths,
+ int nSpans,
+ int fSorted)
+{
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclText.c b/nx-X11/programs/Xserver/Xprint/pcl/PclText.c
new file mode 100644
index 000000000..be794772c
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclText.c
@@ -0,0 +1,936 @@
+/* $Xorg: PclText.c,v 1.5 2001/03/06 16:28:48 pookie Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclText.c
+** *
+** * Contents:
+** * Character-drawing routines for the PCL DDX
+** *
+** * Created: 10/23/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclText.c,v 1.10tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef DO_TWO_BYTE_PCL
+#include "iconv.h"
+#endif /* DO_TWO_BYTE_PCL */
+#include "gcstruct.h"
+#include "windowstr.h"
+
+#include "Pcl.h"
+#include "migc.h"
+#include <X11/Xatom.h>
+
+#include "PclSFonts.h"
+
+static PclFontHead8Ptr makeFontHeader8 (FontPtr, PclSoftFontInfoPtr);
+static PclFontHead16Ptr makeFontHeader16(FontPtr, PclSoftFontInfoPtr);
+static PclInternalFontPtr makeInternalFont(FontPtr, PclSoftFontInfoPtr);
+static void fillFontDescData(FontPtr, PclFontDescPtr, unsigned int);
+static PclCharDataPtr fillCharDescData(PclCharDataPtr, CharInfoPtr);
+static void output_text(FILE *, PclContextPrivPtr, unsigned char);
+static char * getFontName(FontPtr);
+static char isInternal(FontPtr);
+static void selectInternalFont(FILE *, PclInternalFontPtr, int);
+static void selectSize(FILE *, PclContextPrivPtr, PclInternalFontPtr);
+static char t[80];
+
+#ifdef DO_TWO_BYTE_PCL
+static void code_conv(PclSoftFontInfoPtr, FontPtr, char *, char *);
+#endif /* DO_TWO_BYTE_PCL */
+
+#define ESC 0x1b
+#define PER 0x25
+#define ETX 0x3
+#define ETX_ALT 0x2a
+#define DOWNLOAD_FONT 0
+#define INTERNAL_FONT 1
+
+int
+PclPolyText8(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *string)
+{
+XpContextPtr pCon;
+PclContextPrivPtr pConPriv;
+unsigned long n, i;
+int w;
+CharInfoPtr charinfo[255], *chinfo;
+
+FILE *outFile;
+PclSoftFontInfoPtr pSoftFontInfo;
+PclFontHead8Ptr pfh8 = (PclFontHead8Ptr)NULL;
+PclInternalFontPtr pin = (PclInternalFontPtr)NULL;
+PclCharDataRec cd;
+unsigned char *p;
+unsigned char last_fid;
+int max_ascent, max_descent;
+
+int nbox;
+BoxPtr pbox;
+BoxRec box;
+RegionPtr drawRegion, region;
+char font_type;
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return x;
+
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)string,
+ Linear8Bit, &n, charinfo);
+ if ( n == 0 )
+ return x;
+
+ pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
+ pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+ pSoftFontInfo = pConPriv->pSoftFontInfo;
+ font_type = isInternal(pGC->font);
+ if ( font_type == DOWNLOAD_FONT ) {
+ /*
+ * Create Soft Font Header Information
+ */
+ pfh8 = makeFontHeader8(pGC->font, pSoftFontInfo);
+ if (!pfh8)
+ return x;
+
+ /*
+ * exec Soft Font Downloading
+ */
+ p = (unsigned char *)string;
+ for (i=0, chinfo=charinfo; i<n; i++, p++, chinfo++) {
+ if ( !pfh8->index[*p] ) {
+ fillCharDescData(&cd, *chinfo);
+ PclDownloadSoftFont8(pConPriv->pJobFile, pSoftFontInfo,
+ pfh8, &cd, p);
+ xfree(cd.raster_top);
+ }
+ }
+
+ /*
+ * print characters
+ */
+ MACRO_START( outFile, pConPriv );
+ sprintf(t, "\033%%0B;PU%d,%dPD;TD1;DT%c,1;",
+ x + pDrawable->x, y + pDrawable->y + pGC->font->info.fontAscent,
+ ETX);
+ SAVE_PCL( outFile, pConPriv, t );
+ SAVE_PCL_COUNT( outFile, pConPriv, "FI0;SS;LB", 9 );
+
+ last_fid = 0;
+ w = 0;
+ max_ascent = charinfo[0]->metrics.ascent;
+ max_descent = charinfo[0]->metrics.descent;
+ p = (unsigned char *)string;
+ for (i=0, chinfo=charinfo; i<n; i++, p++, chinfo++) {
+ if ( last_fid != pfh8->fid ) {
+ sprintf(t, "%c;FI%d;SS;LB", ETX, pfh8->fid);
+ SAVE_PCL( outFile, pConPriv, t );
+
+ last_fid = pfh8->fid;
+ }
+
+ output_text(outFile, pConPriv, pfh8->index[*p]);
+
+ w += (*chinfo)->metrics.characterWidth;
+ max_ascent = MAX(max_ascent, (*chinfo)->metrics.ascent);
+ max_descent = MAX(max_descent, (*chinfo)->metrics.descent);
+ }
+
+ sprintf(t, "%c", ETX);
+ SAVE_PCL_COUNT( outFile, pConPriv, t, 1 );
+ sprintf(t, "TD0;\033%%1A");
+ SAVE_PCL( outFile, pConPriv, t );
+ MACRO_END( outFile );
+
+ } else {
+ int fid = 0;
+
+ pin = makeInternalFont(pGC->font, pSoftFontInfo);
+ if (!pin)
+ return x;
+
+ selectInternalFont(outFile, pin, fid);
+
+ /*
+ * print characters
+ */
+ MACRO_START( outFile, pConPriv );
+ sprintf(t, "\033%%0B;PU%d,%dPD;TD1;DT%c,1;",
+ x + pDrawable->x, y + pDrawable->y + pGC->font->info.fontAscent,
+ ETX);
+ SAVE_PCL( outFile, pConPriv, t );
+ selectSize(outFile, pConPriv, pin);
+ SAVE_PCL_COUNT( outFile, pConPriv, "FI0;SS;LB", 9 );
+
+ w = 0;
+ max_ascent = charinfo[0]->metrics.ascent;
+ max_descent = charinfo[0]->metrics.descent;
+ p = (unsigned char *)string;
+ for (i=0, chinfo=charinfo; i<n; i++, p++, chinfo++) {
+ output_text(outFile, pConPriv, *p);
+
+ w += (*chinfo)->metrics.characterWidth;
+ max_ascent = MAX(max_ascent, (*chinfo)->metrics.ascent);
+ max_descent = MAX(max_descent, (*chinfo)->metrics.descent);
+ }
+ sprintf(t, "%c", ETX);
+ SAVE_PCL_COUNT( outFile, pConPriv, t, 1 );
+ sprintf(t, "TD0;\033%%1A");
+ SAVE_PCL( outFile, pConPriv, t );
+ MACRO_END( outFile );
+ }
+
+ /*
+ * Convert the collection of rectangles into a proper region, then
+ * intersect it with the clip region.
+ */
+ box.x1 = x + pDrawable->x;
+ box.y1 = y - max_ascent + pDrawable->y + pGC->font->info.fontAscent;
+ box.x2 = x + w + pDrawable->x;
+ box.y2 = y + max_descent + pDrawable->y + pGC->font->info.fontAscent;
+
+ drawRegion = miRegionCreate( &box, 0 );
+ region = miRegionCreate( NULL, 0 );
+ miIntersect( region, drawRegion, pGC->pCompositeClip );
+
+ /*
+ * For each rectangle in the clip region, set the HP-GL/2 "input
+ * window" and render the entire polyline to it.
+ */
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
+
+ /*
+ * Clean up the temporary regions
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+
+ return x+w;
+}
+
+int
+PclPolyText16(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *string)
+{
+XpContextPtr pCon;
+PclContextPrivPtr pConPriv;
+unsigned long n, i;
+int w;
+CharInfoPtr charinfo[255], *chinfo;
+
+FILE *outFile;
+PclSoftFontInfoPtr pSoftFontInfo;
+PclFontHead16Ptr pfh16 = (PclFontHead16Ptr)NULL;
+PclCharDataRec cd;
+FontInfoPtr pfi;
+unsigned char row, col;
+char *p;
+unsigned char last_fid;
+int max_ascent, max_descent;
+unsigned short def;
+
+int nbox;
+BoxPtr pbox;
+BoxRec box;
+RegionPtr drawRegion, region;
+char font_type;
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return x;
+
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)string,
+ (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
+ &n, charinfo);
+
+ pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
+ pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+ pSoftFontInfo = pConPriv->pSoftFontInfo;
+
+ font_type = isInternal(pGC->font);
+ if ( font_type == DOWNLOAD_FONT ) {
+ /*
+ * Create Soft Font Header Information
+ */
+ pfh16 = makeFontHeader16(pGC->font, pSoftFontInfo);
+ if (!pfh16)
+ return x;
+
+ /*
+ * exec Soft Font Downloading
+ */
+ pfi = (FontInfoRec *)&pGC->font->info;
+ p = (char *)string;
+ for (i=0, p=(char *)string, chinfo=charinfo; i<n; i++, p+=2, chinfo++) {
+ row = *p & 0xff;
+ col = *(p+1) & 0xff;
+ if ( (pfi->firstRow <= row) && (row <= pfi->lastRow)
+ && (pfi->firstCol <= col) && (col <= pfi->lastCol) ) {
+ row = row - pfi->firstRow;
+ col = col - pfi->firstCol;
+ } else {
+ def = pfi->defaultCh;
+ row = ((def>>8)&0xff) - pfi->firstRow;
+ col = (def&0xff) - pfi->firstCol;
+ }
+ if ( !pfh16->index[row][col].fid ) {
+ fillCharDescData(&cd, *chinfo);
+ PclDownloadSoftFont16(pConPriv->pJobFile, pSoftFontInfo,
+ pfh16, &cd, row, col);
+ xfree(cd.raster_top);
+ }
+ }
+
+ /*
+ * print characters
+ */
+ MACRO_START( outFile, pConPriv );
+ sprintf(t, "\033%%0B;PU%d,%dPD;TD1;DT%c,1;",
+ x + pDrawable->x, y + pDrawable->y + pGC->font->info.fontAscent,
+ ETX);
+ SAVE_PCL( outFile, pConPriv, t );
+ SAVE_PCL_COUNT( outFile, pConPriv, "FI0;SS;LB", 9 );
+
+ last_fid = 0;
+
+ w = 0;
+ max_ascent = charinfo[0]->metrics.ascent;
+ max_descent = charinfo[0]->metrics.descent;
+ for (i=0, p=(char *)string, chinfo=charinfo; i<n; i++, p+=2, chinfo++) {
+ row = *p & 0xff;
+ col = *(p+1) & 0xff;
+ if ( (pfi->firstRow <= row) && (row <= pfi->lastRow)
+ && (pfi->firstCol <= col) && (col <= pfi->lastCol) ) {
+ row = row - pfi->firstRow;
+ col = col - pfi->firstCol;
+ } else {
+ def = pfi->defaultCh;
+ row = ((def>>8)&0xff) - pfi->firstRow;
+ col = (def&0xff) - pfi->firstCol;
+ }
+ if ( last_fid != pfh16->index[row][col].fid ) {
+ sprintf(t, "%cFI%d;SS;LB",
+ ETX, pfh16->index[row][col].fid);
+ SAVE_PCL( outFile, pConPriv, t );
+ last_fid = pfh16->index[row][col].fid;
+ }
+
+ output_text(outFile, pConPriv, pfh16->index[row][col].cindex);
+
+ w += (*chinfo)->metrics.characterWidth;
+ max_ascent = MAX(max_ascent, (*chinfo)->metrics.ascent);
+ max_descent = MAX(max_descent, (*chinfo)->metrics.descent);
+ }
+ sprintf(t, "%c", ETX);
+ SAVE_PCL_COUNT( outFile, pConPriv, t, 1 );
+ sprintf(t, "TD0;\033%%1A");
+ SAVE_PCL( outFile, pConPriv, t );
+ MACRO_END( outFile );
+
+ } else {
+#ifdef DO_TWO_BYTE_PCL
+ PclInternalFontPtr pin;
+ int fid = 0;
+
+ pin = makeInternalFont(pGC->font, pSoftFontInfo);
+ if (!pin)
+ return x;
+
+ selectInternalFont(outFile, pin, fid);
+ fprintf(outFile, "%c&t31P", ESC);
+
+ /*
+ * print characters
+ */
+ MACRO_START( outFile, pConPriv );
+ sprintf(t, "\033%%0B;PU%d,%dPD;TD1;DT%c,1;",
+ x + pDrawable->x, y + pDrawable->y + pGC->font->info.fontAscent,
+ ETX);
+ SAVE_PCL( outFile, pConPriv, t );
+ sprintf(t, "TD0;\033%%1A");
+ SAVE_PCL( outFile, pConPriv, t );
+
+ w = 0;
+ last_fid = 0;
+ max_ascent = charinfo[0]->metrics.ascent;
+ max_descent = charinfo[0]->metrics.descent;
+ for (i=0, p=(char *)string, chinfo=charinfo; i<n; i++, p+=2, chinfo++) {
+ char tobuf[3];
+ code_conv(pSoftFontInfo, pGC->font, (char *)p, tobuf);
+ fprintf(outFile, "%c%c", tobuf[0], tobuf[1]);
+
+ w += (*chinfo)->metrics.characterWidth;
+ max_ascent = MAX(max_ascent, (*chinfo)->metrics.ascent);
+ max_descent = MAX(max_descent, (*chinfo)->metrics.descent);
+ }
+ MACRO_END( outFile );
+#else
+ return x;
+#endif /* DO_TWO_BYTE_PCL */
+ }
+
+ /*
+ * Convert the collection of rectangles into a proper region, then
+ * intersect it with the clip region.
+ */
+ box.x1 = x + pDrawable->x;
+ box.y1 = y - max_ascent + pDrawable->y + pGC->font->info.fontAscent;
+ box.x2 = x + w + pDrawable->x;
+ box.y2 = y + max_descent + pDrawable->y + pGC->font->info.fontAscent;
+
+ drawRegion = miRegionCreate( &box, 0 );
+ region = miRegionCreate( NULL, 0 );
+ miIntersect( region, drawRegion, pGC->pCompositeClip );
+
+ /*
+ * For each rectangle in the clip region, set the HP-GL/2 "input
+ * window" and render the entire polyline to it.
+ */
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
+
+ /*
+ * Clean up the temporary regions
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+
+ return x+w;
+}
+
+void
+PclImageText8(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x, int y,
+ int count,
+ char *string)
+{
+}
+
+void
+PclImageText16(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *string)
+{
+}
+
+void
+PclImageGlyphBlt(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x, int y,
+ unsigned int nGlyphs,
+ CharInfoPtr *pCharInfo,
+ pointer pGlyphBase)
+{
+}
+
+void
+PclPolyGlyphBlt(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x, int y,
+ unsigned int nGlyphs,
+ CharInfoPtr *pCharInfo,
+ pointer pGlyphBase)
+{
+}
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+static PclFontHead8Ptr
+makeFontHeader8(FontPtr pfont, PclSoftFontInfoPtr pSoftFontInfo)
+{
+PclFontHead8Ptr phead8 = pSoftFontInfo->phead8;
+PclFontHead8Ptr pfh8 = phead8;
+PclFontHead8Ptr prev = (PclFontHead8Ptr)NULL;
+FontInfoPtr pfi;
+char *fontname;
+unsigned char nindex;
+int i;
+unsigned long n;
+CharInfoPtr charinfo[1];
+unsigned int space_width;
+
+ if (pSoftFontInfo == (PclSoftFontInfoPtr) NULL)
+ return (PclFontHead8Ptr)NULL;
+
+ /*
+ * Verify it has already been created, if so, return it.
+ */
+ if ( (fontname = getFontName(pfont)) == (char *)NULL)
+ return (PclFontHead8Ptr)NULL;
+
+ while (pfh8 != (PclFontHead8Ptr) NULL) {
+ if (!strcmp(pfh8->fontname, fontname))
+ return pfh8;
+ prev = pfh8;
+ pfh8 = pfh8->next;
+ }
+
+ /*
+ * Create Font Header Information
+ */
+ pfh8 = (PclFontHead8Ptr)xalloc(sizeof(PclFontHead8Rec));
+ if (pfh8 == (PclFontHead8Ptr)NULL)
+ return (PclFontHead8Ptr)NULL;
+
+ pfi = (FontInfoRec *)&pfont->info;
+ GetGlyphs(pfont, 1, (unsigned char *)&pfi->defaultCh,
+ Linear8Bit, &n, charinfo);
+ if ( n )
+ space_width = charinfo[0]->metrics.characterWidth;
+ else
+ space_width = FONTMAXBOUNDS(pfont,characterWidth);
+
+ fillFontDescData(pfont, &(pfh8->fd), space_width);
+ pfh8->fid = 0;
+ pfh8->fontname = (char *)xalloc(strlen(fontname) + 1);
+ if (pfh8->fontname == (char *)NULL) {
+ xfree(pfh8);
+ return (PclFontHead8Ptr) NULL;
+ }
+ strcpy(pfh8->fontname, fontname);
+
+ nindex = 0xff;
+ pfh8->index = (unsigned char *)xalloc(nindex);
+ if ( pfh8->index == (unsigned char *) NULL ) {
+ xfree(pfh8->fontname);
+ xfree(pfh8);
+ return (PclFontHead8Ptr) NULL;
+ }
+
+ for (i=0; i<=nindex; i++)
+ pfh8->index[i] = 0x0;
+
+ pfh8->next = (PclFontHead8Ptr)NULL;
+
+ if ( prev == (PclFontHead8Ptr) NULL)
+ pSoftFontInfo->phead8 = pfh8;
+ else
+ prev->next = pfh8;
+
+ return pfh8;
+}
+
+static PclFontHead16Ptr
+makeFontHeader16(FontPtr pfont, PclSoftFontInfoPtr pSoftFontInfo)
+{
+PclFontHead16Ptr phead16 = pSoftFontInfo->phead16;
+PclFontHead16Ptr pfh16 = phead16;
+PclFontHead16Ptr prev = (PclFontHead16Ptr)NULL;
+PclFontMapRec ** index;
+FontInfoPtr pfi;
+char *fontname;
+unsigned char nindex_row, nindex_col;
+int i, j;
+unsigned long n;
+CharInfoPtr charinfo[1];
+unsigned int space_width;
+
+ if (pSoftFontInfo == (PclSoftFontInfoPtr) NULL)
+ return (PclFontHead16Ptr)NULL;
+
+ /*
+ * Verify it has already been created, if so, return it.
+ */
+ if ( (fontname = getFontName(pfont)) == (char *)NULL)
+ return (PclFontHead16Ptr)NULL;
+
+ while (pfh16 != (PclFontHead16Ptr) NULL) {
+ if (!strcmp(pfh16->fontname, fontname))
+ return pfh16;
+ prev = pfh16;
+ pfh16 = pfh16->next;
+ }
+
+ /*
+ * Create Font Header Information
+ */
+ pfh16 = (PclFontHead16Ptr)xalloc(sizeof(PclFontHead16Rec));
+ if (pfh16 == (PclFontHead16Ptr)NULL)
+ return (PclFontHead16Ptr)NULL;
+
+ pfi = (FontInfoRec *)&pfont->info;
+ GetGlyphs(pfont, 1, (unsigned char *)&pfi->defaultCh,
+ (FONTLASTROW(pfont) == 0) ? Linear16Bit : TwoD16Bit,
+ &n, charinfo);
+
+ if ( n )
+ space_width = charinfo[0]->metrics.characterWidth;
+ else
+ space_width = FONTMAXBOUNDS(pfont,characterWidth);
+
+ fillFontDescData(pfont, &(pfh16->fd), space_width);
+ pfh16->cur_fid = 0;
+ pfh16->cur_cindex = 0;
+ pfh16->fontname = (char *)xalloc(strlen(fontname) + 1);
+ if (pfh16->fontname == (char *)NULL) {
+ xfree(pfh16);
+ return (PclFontHead16Ptr) NULL;
+ }
+ strcpy(pfh16->fontname, fontname);
+
+ pfi = (FontInfoRec *)&pfont->info;
+ nindex_col = pfi->lastCol - pfi->firstCol + 1;
+ nindex_row = pfi->lastRow - pfi->firstRow + 1;
+ index = (PclFontMapRec **)xalloc(sizeof(PclFontMapRec *)*nindex_row);
+ if (index == (PclFontMapRec **)NULL) {
+ xfree(pfh16->fontname);
+ xfree(pfh16);
+ return (PclFontHead16Ptr) NULL;
+ }
+ for (i=0; i<nindex_row; i++) {
+ index[i] = (PclFontMapRec *)xalloc(sizeof(PclFontMapRec)*nindex_col);
+ if (index[i] == (PclFontMapRec *)NULL) {
+ for(j=0; j<i; j++)
+ xfree(index[j]);
+ xfree(pfh16->fontname);
+ xfree(pfh16);
+ return (PclFontHead16Ptr) NULL;
+ }
+ for (j=0; j<=nindex_col; j++)
+ index[i][j].fid = 0x0;
+ }
+
+ pfh16->index = index;
+ pfh16->firstCol = pfi->firstCol;
+ pfh16->lastCol = pfi->lastCol;
+ pfh16->firstRow = pfi->firstRow;
+ pfh16->lastRow = pfi->lastRow;
+ pfh16->next = (PclFontHead16Ptr)NULL;
+
+ if ( prev == (PclFontHead16Ptr) NULL)
+ pSoftFontInfo->phead16 = pfh16;
+ else
+ prev->next = pfh16;
+
+ return pfh16;
+}
+
+static PclInternalFontPtr
+makeInternalFont(FontPtr pfont, PclSoftFontInfoPtr pSoftFontInfo)
+{
+PclInternalFontPtr pinfont = pSoftFontInfo->pinfont;
+PclInternalFontPtr pin = pinfont;
+PclInternalFontPtr prev = (PclInternalFontPtr)NULL;
+FontPropPtr props;
+FontInfoPtr pfi;
+char *fontname;
+Atom xa_pcl_font_name, xa_res, xa_ave_width, xa_spacing;
+int width = 1;
+int mask;
+int i;
+
+ if (pSoftFontInfo == (PclSoftFontInfoPtr) NULL)
+ return (PclInternalFontPtr)NULL;
+
+ /*
+ * Verify it has already been created, if so, return it.
+ */
+ if ( (fontname = getFontName(pfont)) == (char *)NULL)
+ return (PclInternalFontPtr)NULL;
+
+ while (pin != (PclInternalFontPtr) NULL) {
+ if (!strcmp(pin->fontname, fontname))
+ return pin;
+ prev = pin;
+ pin = pin->next;
+ }
+
+ /*
+ * Create Internal Font Information
+ */
+ pin = (PclInternalFontPtr)xalloc(sizeof(PclInternalFontRec));
+ if (pin == (PclInternalFontPtr)NULL)
+ return (PclInternalFontPtr)NULL;
+
+ pin->fontname = (char *)xalloc(strlen(fontname) + 1);
+ if (pin->fontname == (char *)NULL) {
+ xfree(pin);
+ return (PclInternalFontPtr) NULL;
+ }
+ strcpy(pin->fontname, fontname);
+
+ xa_pcl_font_name = MakeAtom("PCL_FONT_NAME", strlen("PCL_FONT_NAME"), TRUE);
+ xa_res = MakeAtom("RESOLUTION_X", strlen("RESOLUTION_X"), TRUE);
+ xa_ave_width = MakeAtom("AVERAGE_WIDTH", strlen("AVERAGE_WIDTH"), TRUE);
+ xa_spacing = MakeAtom("SPACING", strlen("SPACING"), TRUE);
+ pfi = (FontInfoRec *)&pfont->info;
+ props = pfi->props;
+
+ mask = 0;
+ for (i=0; i<pfi->nprops; i++, props++) {
+ if ( (Atom) props->name == xa_pcl_font_name ) {
+ pin->pcl_font_name = NameForAtom(props->value);
+ mask |= 0x1;
+ } else if ( props->name == XA_POINT_SIZE ) {
+ pin->height = (float) props->value / 10.0;
+ mask |= 0x2;
+ } else if ( (Atom) props->name == xa_res ) {
+ mask |= 0x4;
+ } else if ( (Atom) props->name == xa_ave_width ) {
+ width = (int) props->value / 10;
+ mask |= 0x8;
+ } else if ( (Atom) props->name == xa_spacing ) {
+ pin->spacing = NameForAtom(props->value);
+ mask |= 0x10;
+ }
+ }
+ if ( mask != 0x1f ) {
+ xfree(pin->fontname);
+ xfree(pin);
+ return (PclInternalFontPtr) NULL;
+ }
+
+ if ( *pin->spacing != 'P' || *pin->spacing != 'p' ) {
+ if (width == 0)
+ width = 1;
+ pin->pitch = (float) 300.0 / width; /* Hard-Code: Resolution is 300 */
+ }
+
+ pin->next = (PclInternalFontPtr)NULL;
+ if ( prev == (PclInternalFontPtr) NULL)
+ pSoftFontInfo->pinfont = pin;
+ else
+ prev->next = pin;
+
+ return pin;
+}
+
+static void
+fillFontDescData(FontPtr pfont, PclFontDescPtr pfd, unsigned int space)
+{
+FontInfoPtr pfi;
+
+ pfi = (FontInfoRec *)&pfont->info;
+
+ if ( (pfi->maxbounds.leftSideBearing == pfi->minbounds.leftSideBearing)
+ && (pfi->maxbounds.rightSideBearing == pfi->minbounds.rightSideBearing)
+ && (pfi->maxbounds.characterWidth == pfi->minbounds.characterWidth)
+ && (pfi->maxbounds.ascent == pfi->minbounds.ascent)
+ && (pfi->maxbounds.descent == pfi->minbounds.descent)
+ )
+ pfd->spacing = MONOSPACE;
+ else
+ pfd->spacing = PROPSPACE;
+
+ pfd->pitch = space;
+ pfd->cellheight = FONTMAXBOUNDS(pfont,ascent)
+ + FONTMAXBOUNDS(pfont,descent);
+ pfd->cellwidth = FONTMAXBOUNDS(pfont,rightSideBearing)
+ - FONTMINBOUNDS(pfont,leftSideBearing);
+ pfd->ascent = FONTMAXBOUNDS(pfont,ascent); /*FONTASCENT(pfont);*/
+ pfd->descent = FONTMAXBOUNDS(pfont,descent); /*FONTDESCENT(pfont);*/
+}
+
+static PclCharDataPtr
+fillCharDescData(PclCharDataPtr pcd, CharInfoPtr pci)
+{
+unsigned int byte_width;
+unsigned char *p;
+register int nbyGlyphWidth;
+unsigned char *pglyph, *pg;
+unsigned int i, j;
+
+ pcd->h_offset = pci->metrics.leftSideBearing;
+ pcd->v_offset = pci->metrics.ascent;
+ pcd->width = pci->metrics.rightSideBearing
+ - pci->metrics.leftSideBearing;
+ pcd->height = pci->metrics.ascent + pci->metrics.descent;
+ pcd->font_pitch = pci->metrics.characterWidth;
+
+ byte_width = (pcd->width + 7)/8;
+ pcd->raster_top = (unsigned char *)xalloc(byte_width * pcd->height);
+ if (pcd->raster_top == (unsigned char *)NULL)
+ return (PclCharDataPtr)NULL;
+
+ p = pcd->raster_top;
+ nbyGlyphWidth = GLYPHWIDTHBYTESPADDED(pci);
+ pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ for (i=0; i<pcd->height; i++) {
+ pg = pglyph + nbyGlyphWidth * i;
+ for (j=0; j<byte_width; j++)
+ *p++ = *pg++;
+ }
+ return pcd;
+}
+
+static void
+output_text(FILE *outFile,
+ PclContextPrivPtr pConPriv,
+ unsigned char index)
+{
+ if ( index == ETX ) {
+ sprintf(t, "%c;DT%c,1;LB%c%c;DT%c,1;LB",
+ ETX, ETX_ALT, ETX, ETX_ALT, ETX);
+ SAVE_PCL( outFile, pConPriv, t );
+ } else {
+ sprintf(t, "%c", index);
+ SAVE_PCL_COUNT( outFile, pConPriv, t, 1 );
+ }
+}
+
+static char *
+getFontName(FontPtr pfont)
+{
+int i;
+FontInfoPtr pfi;
+FontPropPtr props;
+char *fontname;
+
+ pfi = (FontInfoRec *)&pfont->info;
+ props = pfi->props;
+ fontname = (char *) NULL;
+ for (i=0; i<pfi->nprops; i++, props++) {
+ if ( props->name == XA_FONT ) {
+ fontname = (char *)NameForAtom(props->value);
+ break;
+ }
+ }
+ return fontname;
+}
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* Internal Font Selection */
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+static char
+isInternal(FontPtr pfont)
+{
+int i;
+FontInfoPtr pfi;
+FontPropPtr props;
+Atom dest;
+
+ dest = MakeAtom("PRINTER_RESIDENT_FONT", strlen("PRINTER_RESIDENT_FONT"), TRUE);
+
+ pfi = (FontInfoRec *)&pfont->info;
+ props = pfi->props;
+ for (i=0; i<pfi->nprops; i++, props++) {
+ if ( (Atom) props->name == dest && props->value == 2 )
+ return INTERNAL_FONT;
+ }
+ return DOWNLOAD_FONT;
+}
+
+static void
+selectInternalFont(FILE *outFile, PclInternalFontPtr pin, int fid)
+{
+ fprintf(outFile, "%c*c%dD", ESC, fid);
+ if ( *pin->spacing == 'P' || *pin->spacing == 'p' )
+ fprintf(outFile, pin->pcl_font_name, pin->height);
+ else
+ fprintf(outFile, pin->pcl_font_name, pin->pitch);
+ fprintf(outFile, "%c*c6F", ESC);
+}
+
+static void
+selectSize(FILE *outFile,
+ PclContextPrivPtr pConPriv,
+ PclInternalFontPtr pin)
+{
+ if ( *pin->spacing == 'P' || *pin->spacing == 'p' ) {
+ sprintf(t, "SD4,%f;", pin->height);
+ SAVE_PCL( outFile, pConPriv, t );
+ } else {
+ sprintf(t, "SD3,%f;", pin->pitch);
+ SAVE_PCL( outFile, pConPriv, t );
+ }
+ return;
+}
+
+#ifdef DO_TWO_BYTE_PCL
+static void
+code_conv(
+ PclSoftFontInfoPtr pSoftFontInfo,
+ FontPtr pfont,
+ char *from,
+ char *to
+)
+{
+iconv_t cd;
+char frombuf[9], *fromptr;
+size_t inbyte = 5, outbyte=2;
+
+ fromptr = frombuf;
+ frombuf[0] = 0x1b; /* Esc */
+ frombuf[1] = 0x24; /* $ */
+ frombuf[2] = 0x42; /* B */
+ frombuf[3] = *from;
+ frombuf[4] = *(from+1);
+ frombuf[5] = 0x1b; /* Esc */
+ frombuf[6] = 0x28; /* ( */
+ frombuf[7] = 0x4a; /* J */
+ frombuf[8] = 0x0;
+ if ((cd = iconv_open("sjis", "jis")) == (iconv_t)(-1)) {
+ *to = (unsigned char)NULL;
+ return;
+ }
+
+ if ( iconv(cd, &fromptr, &inbyte, &to, &outbyte) == -1 )
+ *to = (unsigned char)NULL;
+
+ iconv_close(cd);
+ return;
+}
+#endif /* DO_TWO_BYTE_PCL */
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclWindow.c b/nx-X11/programs/Xserver/Xprint/pcl/PclWindow.c
new file mode 100644
index 000000000..cac5826e9
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclWindow.c
@@ -0,0 +1,452 @@
+/* $Xorg: PclWindow.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclWindow.c
+** *
+** * Contents:
+** * Window code for Pcl driver.
+** *
+** * Created: 2/02/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclWindow.c,v 1.10tsi Exp $ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "mistruct.h"
+#include "regionstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+
+#include "Pcl.h"
+
+#if 0
+/*
+ * The following list of strings defines the properties which will be
+ * placed on the screen's root window if the property was defined in
+ * the start-up configuration resource database.
+ */
+static /* const */ char *propStrings[] = {
+ DT_PRINT_JOB_HEADER,
+ DT_PRINT_JOB_TRAILER,
+ DT_PRINT_JOB_COMMAND, /* old-obsolete */
+ DT_PRINT_JOB_EXEC_COMMAND,
+ DT_PRINT_JOB_EXEC_OPTIONS,
+ DT_PRINT_PAGE_HEADER,
+ DT_PRINT_PAGE_TRAILER,
+ DT_PRINT_PAGE_COMMAND,
+ (char *)NULL
+};
+#endif
+
+/*
+ * PclCreateWindow - watch for the creation of the root window.
+ * When it's created, register the screen with the print extension,
+ * and put the default command/header properties on it.
+ */
+/*ARGSUSED*/
+
+Bool
+PclCreateWindow(
+ register WindowPtr pWin)
+{
+ PclWindowPrivPtr pPriv;
+
+#if 0
+ Bool status = Success;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PclScreenPrivPtr pScreenPriv = (PclScreenPrivPtr)
+ pScreen->devPrivates[PclScreenPrivateIndex].ptr;
+ PclWindowPrivPtr pWinPriv = (PclWindowPrivPtr)
+ pWin->devPrivates[PclWindowPrivateIndex].ptr;
+
+ /*
+ * Initialize this window's private struct.
+ */
+ pWinPriv->jobFileName = (char *)NULL;
+ pWinPriv->pJobFile = (FILE *)NULL;
+ pWinPriv->pageFileName = (char *)NULL;
+ pWinPriv->pPageFile = (FILE *)NULL;
+
+ if(pWin->parent == (WindowPtr)NULL) /* root window? */
+ {
+ Atom propName; /* type = XA_STRING */
+ char *propVal;
+ int i;
+ XrmDatabase rmdb = pScreenPriv->resDB;
+
+ /*
+ * Put the defaults spec'd in the config files in properties on this
+ * screen's root window.
+ */
+ for(i = 0; propStrings[i] != (char *)NULL; i++)
+ {
+ if((propVal = _DtPrintGetPrinterResource(pWin, rmdb,
+ propStrings[i])) !=
+ (char *)NULL)
+ {
+ propName = MakeAtom(propStrings[i], strlen(propStrings[i]),
+ TRUE);
+ ChangeWindowProperty(pWin, propName, XA_STRING, 8,
+ PropModeReplace, strlen(propVal),
+ (pointer)propVal, FALSE);
+ xfree(propVal);
+ }
+ }
+ }
+
+ return status;
+#endif
+
+ /*
+ * Invalidate the window's private print context.
+ */
+ pPriv = (PclWindowPrivPtr)pWin->devPrivates[PclWindowPrivateIndex].ptr;
+ pPriv->validContext = 0;
+
+ return TRUE;
+}
+
+
+/*ARGSUSED*/
+Bool PclMapWindow(
+ WindowPtr pWindow)
+{
+ return TRUE;
+}
+
+/*ARGSUSED*/
+Bool
+PclPositionWindow(
+ register WindowPtr pWin,
+ int x,
+ int y)
+{
+ return TRUE;
+}
+
+/*ARGSUSED*/
+Bool
+PclUnmapWindow(
+ WindowPtr pWindow)
+{
+ return TRUE;
+}
+
+/*ARGSUSED*/
+void
+PclCopyWindow(
+ WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc)
+{
+}
+
+/*ARGSUSED*/
+Bool
+PclChangeWindowAttributes(
+ register WindowPtr pWin,
+ register unsigned long mask)
+{
+ if( pWin->backingStore != NotUseful )
+ {
+ pWin->backingStore = NotUseful;
+ mask |= CWBackingStore;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * This function is largely ripped from miPaintWindow, but modified so
+ * that the background is not painted to the root window, and so that
+ * the backing store is not referenced.
+ */
+void
+PclPaintWindow(
+ WindowPtr pWin,
+ RegionPtr pRegion,
+ int what)
+{
+
+#define FUNCTION 0
+#define FOREGROUND 1
+#define TILE 2
+#define FILLSTYLE 3
+#define ABSX 4
+#define ABSY 5
+#define CLIPMASK 6
+#define SUBWINDOW 7
+#define COUNT_BITS 8
+
+ pointer gcval[7];
+ pointer newValues [COUNT_BITS];
+
+ BITS32 gcmask, index, mask;
+ RegionRec prgnWin;
+ DDXPointRec oldCorner;
+ BoxRec box;
+ WindowPtr pBgWin;
+ GCPtr pGC;
+ register int i;
+ register BoxPtr pbox;
+ register ScreenPtr pScreen = pWin->drawable.pScreen;
+ register xRectangle *prect;
+ int numRects;
+
+ gcmask = 0;
+
+ /*
+ * We don't want to paint a window that has no place to put the
+ * PCL output.
+ */
+ if( PclGetContextFromWindow( pWin ) == (XpContextPtr)NULL )
+ return;
+
+ if (what == PW_BACKGROUND)
+ {
+ switch (pWin->backgroundState) {
+ case None:
+ return;
+ case ParentRelative:
+ (*pWin->parent->drawable.pScreen->PaintWindowBackground)
+ (pWin->parent, pRegion, what);
+ return;
+ case BackgroundPixel:
+ newValues[FOREGROUND] = (pointer)pWin->background.pixel;
+ newValues[FILLSTYLE] = (pointer)FillSolid;
+ gcmask |= GCForeground | GCFillStyle;
+ break;
+ case BackgroundPixmap:
+ newValues[TILE] = (pointer)pWin->background.pixmap;
+ newValues[FILLSTYLE] = (pointer)FillTiled;
+ gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin |
+ GCTileStipYOrigin;
+ break;
+ }
+ }
+ else
+ {
+ if (pWin->borderIsPixel)
+ {
+ newValues[FOREGROUND] = (pointer)pWin->border.pixel;
+ newValues[FILLSTYLE] = (pointer)FillSolid;
+ gcmask |= GCForeground | GCFillStyle;
+ }
+ else
+ {
+ newValues[TILE] = (pointer)pWin->border.pixmap;
+ newValues[FILLSTYLE] = (pointer)FillTiled;
+ gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin
+ | GCTileStipYOrigin;
+ }
+ }
+
+ prect = (xRectangle *)ALLOCATE_LOCAL(REGION_NUM_RECTS(pRegion) *
+ sizeof(xRectangle));
+ if (!prect)
+ return;
+
+ newValues[FUNCTION] = (pointer)GXcopy;
+ gcmask |= GCFunction | GCClipMask;
+
+ i = pScreen->myNum;
+
+ pBgWin = pWin;
+ if (what == PW_BORDER)
+ {
+ while (pBgWin->backgroundState == ParentRelative)
+ pBgWin = pBgWin->parent;
+ }
+
+ pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
+ if (!pGC)
+ {
+ DEALLOCATE_LOCAL(prect);
+ return;
+ }
+ /*
+ * mash the clip list so we can paint the border by
+ * mangling the window in place, pretending it
+ * spans the entire screen
+ */
+ if (what == PW_BORDER)
+ {
+ prgnWin = pWin->clipList;
+ oldCorner.x = pWin->drawable.x;
+ oldCorner.y = pWin->drawable.y;
+ pWin->drawable.x = pWin->drawable.y = 0;
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pScreen->width;
+ box.y2 = pScreen->height;
+ REGION_INIT(pScreen, &pWin->clipList, &box, 1);
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ newValues[ABSX] = (pointer)(long)pBgWin->drawable.x;
+ newValues[ABSY] = (pointer)(long)pBgWin->drawable.y;
+ }
+ else
+ {
+ newValues[ABSX] = (pointer)0;
+ newValues[ABSY] = (pointer)0;
+ }
+
+/*
+ * XXX Backing store is turned off for the PCL driver
+
+ if (pWin->backStorage)
+ (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC,
+ GuaranteeVisBack);
+ */
+
+ mask = gcmask;
+ gcmask = 0;
+ i = 0;
+ while (mask) {
+ index = lowbit (mask);
+ mask &= ~index;
+ switch (index) {
+ case GCFunction:
+ if ((pointer)(long) pGC->alu != newValues[FUNCTION]) {
+ gcmask |= index;
+ gcval[i++] = newValues[FUNCTION];
+ }
+ break;
+ case GCTileStipXOrigin:
+ if ((pointer)(long) pGC->patOrg.x != newValues[ABSX]) {
+ gcmask |= index;
+ gcval[i++] = newValues[ABSX];
+ }
+ break;
+ case GCTileStipYOrigin:
+ if ((pointer)(long) pGC->patOrg.y != newValues[ABSY]) {
+ gcmask |= index;
+ gcval[i++] = newValues[ABSY];
+ }
+ break;
+ case GCClipMask:
+ if ((pointer)(long) pGC->clientClipType != (pointer)CT_NONE) {
+ gcmask |= index;
+ gcval[i++] = (pointer)CT_NONE;
+ }
+ break;
+ case GCSubwindowMode:
+ if ((pointer)(long) pGC->subWindowMode != newValues[SUBWINDOW]) {
+ gcmask |= index;
+ gcval[i++] = newValues[SUBWINDOW];
+ }
+ break;
+ case GCTile:
+ if (pGC->tileIsPixel ||
+ (pointer) pGC->tile.pixmap != newValues[TILE])
+ {
+ gcmask |= index;
+ gcval[i++] = newValues[TILE];
+ }
+ break;
+ case GCFillStyle:
+ if ((pointer)(long) pGC->fillStyle != newValues[FILLSTYLE]) {
+ gcmask |= index;
+ gcval[i++] = newValues[FILLSTYLE];
+ }
+ break;
+ case GCForeground:
+ if ((pointer) pGC->fgPixel != newValues[FOREGROUND]) {
+ gcmask |= index;
+ gcval[i++] = newValues[FOREGROUND];
+ }
+ break;
+ }
+ }
+
+ if (gcmask)
+ DoChangeGC(pGC, gcmask, (XID *)gcval, 1);
+
+ if (pWin->drawable.serialNumber != pGC->serialNumber)
+ ValidateGC((DrawablePtr)pWin, pGC);
+
+ numRects = REGION_NUM_RECTS(pRegion);
+ pbox = REGION_RECTS(pRegion);
+ for (i= numRects; --i >= 0; pbox++, prect++)
+ {
+ prect->x = pbox->x1 - pWin->drawable.x;
+ prect->y = pbox->y1 - pWin->drawable.y;
+ prect->width = pbox->x2 - pbox->x1;
+ prect->height = pbox->y2 - pbox->y1;
+ }
+ prect -= numRects;
+ (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
+ DEALLOCATE_LOCAL(prect);
+
+/*
+ * XXX Backing store is turned off for the PCL driver
+
+ if (pWin->backStorage)
+ (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC,
+ GuaranteeNothing);
+ */
+
+ if (what == PW_BORDER)
+ {
+ REGION_UNINIT(pScreen, &pWin->clipList);
+ pWin->clipList = prgnWin;
+ pWin->drawable.x = oldCorner.x;
+ pWin->drawable.y = oldCorner.y;
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ }
+ FreeScratchGC(pGC);
+
+}
+
+/*ARGSUSED*/
+Bool
+PclDestroyWindow(
+ WindowPtr pWin)
+{
+ return TRUE;
+}
+
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/Pclmap.h b/nx-X11/programs/Xserver/Xprint/pcl/Pclmap.h
new file mode 100644
index 000000000..5224fd9e3
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/Pclmap.h
@@ -0,0 +1,213 @@
+/* $Xorg: Pclmap.h,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/Pclmap.h,v 1.5 2001/07/25 15:05:00 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _PCLMAP_H_
+#define _PCLMAP_H_
+
+#ifdef XP_PCL_COLOR
+#ifdef CATNAME
+#undef CATNAME
+#endif
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define PCLNAME(subname) PclCr##subname
+#define CATNAME(prefix,subname) prefix##Color##subname
+#else
+#define PCLNAME(subname) PclCr/**/subname
+#define CATNAME(prefix,subname) prefix/**/Color/**/subname
+#endif
+#endif /* XP_PCL_COLOR */
+
+#ifdef XP_PCL_MONO
+#ifdef CATNAME
+#undef CATNAME
+#endif
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define PCLNAME(subname) PclMn##subname
+#define CATNAME(prefix,subname) prefix##Mono##subname
+#else
+#define PCLNAME(subname) PclMn/**/subname
+#define CATNAME(prefix,subname) prefix/**/Mono/**/subname
+#endif
+#endif /* XP_PCL_MONO */
+
+#ifdef XP_PCL_LJ3
+#ifdef CATNAME
+#undef CATNAME
+#endif
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define PCLNAME(subname) PclLj3##subname
+#define CATNAME(prefix,subname) prefix##Lj3##subname
+#else
+#define PCLNAME(subname) PclLj3/**/subname
+#define CATNAME(prefix,subname) prefix/**/Lj3/**/subname
+#endif
+#endif /* XP_PCL_LJ3 */
+
+#ifdef PCLNAME
+
+/* PclInit.c */
+#define InitializePclDriver CATNAME(Initialize, PclDriver)
+#define PclCloseScreen PCLNAME(CloseScreen)
+#define PclGetContextFromWindow PCLNAME(GetContextFromWindow)
+#define PclScreenPrivateIndex PCLNAME(ScreenPrivateIndex)
+#define PclWindowPrivateIndex PCLNAME(WindowPrivateIndex)
+#define PclContextPrivateIndex PCLNAME(ContextPrivateIndex)
+#define PclPixmapPrivateIndex PCLNAME(PixmapPrivateIndex)
+#define PclGCPrivateIndex PCLNAME(GCPrivateIndex)
+
+/* PclPrint.c */
+#define PclStartJob PCLNAME(StartJob)
+#define PclEndJob PCLNAME(EndJob)
+#define PclStartPage PCLNAME(StartPage)
+#define PclEndPage PCLNAME(EndPage)
+#define PclStartDoc PCLNAME(StartDoc)
+#define PclEndDoc PCLNAME(EndDoc)
+#define PclDocumentData PCLNAME(DocumentData)
+#define PclGetDocumentData PCLNAME(GetDocumentData)
+
+/* PclWindow.c */
+#define PclCreateWindow PCLNAME(CreateWindow)
+#define PclMapWindow PCLNAME(MapWindow)
+#define PclPositionWindow PCLNAME(PositionWindow)
+#define PclUnmapWindow PCLNAME(UnmapWindow)
+#define PclCopyWindow PCLNAME(CopyWindow)
+#define PclChangeWindowAttributes PCLNAME(ChangeWindowAttributes)
+#define PclPaintWindow PCLNAME(PaintWindow)
+#define PclDestroyWindow PCLNAME(DestroyWindow)
+
+/* PclGC.c */
+#define PclCreateGC PCLNAME(CreateGC)
+#define PclDestroyGC PCLNAME(DestroyGC)
+#define PclGetDrawablePrivateStuff PCLNAME(GetDrawablePrivateStuff)
+#define PclSetDrawablePrivateGC PCLNAME(SetDrawablePrivateGC)
+#define PclSendPattern PCLNAME(SendPattern)
+#define PclUpdateDrawableGC PCLNAME(UpdateDrawableGC)
+#define PclComputeCompositeClip PCLNAME(ComputeCompositeClip)
+#define PclValidateGC PCLNAME(ValidateGC)
+
+/* PclAttr.c */
+#define PclGetAttributes PCLNAME(GetAttributes)
+#define PclGetOneAttribute PCLNAME(GetOneAttribute)
+#define PclAugmentAttributes PCLNAME(AugmentAttributes)
+#define PclSetAttributes PCLNAME(SetAttributes)
+
+/* PclColor.c */
+#define PclLookUp PCLNAME(LookUp)
+#define PclCreateDefColormap PCLNAME(CreateDefColormap)
+#define PclCreateColormap PCLNAME(CreateColormap)
+#define PclDestroyColormap PCLNAME(DestroyColormap)
+#define PclInstallColormap PCLNAME(InstallColormap)
+#define PclUninstallColormap PCLNAME(UninstallColormap)
+#define PclListInstalledColormaps PCLNAME(ListInstalledColormaps)
+#define PclStoreColors PCLNAME(StoreColors)
+#define PclResolveColor PCLNAME(ResolveColor)
+#define PclFindPaletteMap PCLNAME(FindPaletteMap)
+#define PclUpdateColormap PCLNAME(UpdateColormap)
+#define PclReadMap PCLNAME(ReadMap)
+
+/* PclPixmap.c */
+#define PclCreatePixmap PCLNAME(CreatePixmap)
+#define PclDestroyPixmap PCLNAME(DestroyPixmap)
+
+/* PclArc.c */
+#define PclDoArc PCLNAME(DoArc)
+#define PclPolyArc PCLNAME(PolyArc)
+#define PclPolyFillArc PCLNAME(PolyFillArc)
+
+/* PclArea.c */
+#define PclPutImage PCLNAME(PutImage)
+#define PclCopyArea PCLNAME(CopyArea)
+#define PclCopyPlane PCLNAME(CopyPlane)
+
+/* PclLine */
+#define PclPolyLine PCLNAME(PolyLine)
+#define PclPolySegment PCLNAME(PolySegment)
+
+/* PclPixel.c */
+#define PclPolyPoint PCLNAME(PolyPoint)
+#define PclPushPixels PCLNAME(PushPixels)
+
+/* PclPolygon.c */
+#define PclPolyRectangle PCLNAME(PolyRectangle)
+#define PclFillPolygon PCLNAME(FillPolygon)
+#define PclPolyFillRect PCLNAME(PolyFillRect)
+
+/* PclSpans.c */
+#define PclFillSpans PCLNAME(FillSpans)
+#define PclSetSpans PCLNAME(SetSpans)
+
+/* PclText.c */
+#define PclPolyText8 PCLNAME(PolyText8)
+#define PclPolyText16 PCLNAME(PolyText16)
+#define PclImageText8 PCLNAME(ImageText8)
+#define PclImageText16 PCLNAME(ImageText16)
+#define PclImageGlyphBlt PCLNAME(ImageGlyphBlt)
+#define PclPolyGlyphBlt PCLNAME(PolyGlyphBlt)
+#define PclPolyGlyphBlt PCLNAME(PolyGlyphBlt)
+
+/* PclFonts.c */
+#define PclRealizeFont PCLNAME(RealizeFont)
+#define PclUnrealizeFont PCLNAME(UnrealizeFont)
+
+/* PclSFonts.c */
+#define PclDownloadSoftFont8 PCLNAME(DownloadSoftFont8)
+#define PclDownloadSoftFont16 PCLNAME(DownloadSoftFont16)
+#define PclCreateSoftFontInfo PCLNAME(CreateSoftFontInfo)
+#define PclDestroySoftFontInfo PCLNAME(DestroySoftFontInfo)
+
+/* PclMisc.c */
+#define PclQueryBestSize PCLNAME(QueryBestSize)
+#define GetPropString PCLNAME(GetPropString)
+#define SystemCmd PCLNAME(SystemCmd)
+#define PclGetMediumDimensions PCLNAME(GetMediumDimensions)
+#define PclGetReproducibleArea PCLNAME(GetReproducibleArea)
+#define PclSpoolFigs PCLNAME(SpoolFigs)
+#define PclSendData PCLNAME(SendData)
+
+/* PclCursor.c */
+#define PclConstrainCursor PCLNAME(ConstrainCursor)
+#define PclCursorLimits PCLNAME(CursorLimits)
+#define PclDisplayCursor PCLNAME(DisplayCursor)
+#define PclRealizeCursor PCLNAME(RealizeCursor)
+#define PclUnrealizeCursor PCLNAME(UnrealizeCursor)
+#define PclRecolorCursor PCLNAME(RecolorCursor)
+#define PclSetCursorPosition PCLNAME(SetCursorPosition)
+
+#endif
+
+#endif /* _PCLMAP_H_ */
diff --git a/nx-X11/programs/Xserver/Xprint/pdf/README b/nx-X11/programs/Xserver/Xprint/pdf/README
new file mode 100644
index 000000000..9f3847570
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pdf/README
@@ -0,0 +1 @@
+Tracking bug for this work is http://xprint.mozdev.org/bugs/show_bug.cgi?id=3529
diff --git a/nx-X11/programs/Xserver/Xprint/ps/Imakefile b/nx-X11/programs/Xserver/Xprint/ps/Imakefile
new file mode 100644
index 000000000..c73466fe4
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/Imakefile
@@ -0,0 +1,89 @@
+XCOMM $Xorg: Imakefile,v 1.5 2001/03/14 18:26:56 pookie Exp $
+
+#include <Server.tmpl>
+
+#if BuildFreeType || BuildFreetype2Library
+FT2SOURCEDIR = $(TOP)/extras/freetype2/src
+FT2INCDIR = $(TOP)/extras/freetype2/include
+FT2INCS = -I$(FT2INCDIR) \
+ -I$(FT2SOURCEDIR)/type42
+TTF2PT1OURCEDIR = $(TOP)/extras/ttf2pt1
+FT_DEFINES = -DXP_USE_FREETYPE
+FTSRCS = psout_ft.c psout_ftpstype1.c psout_ftpstype3.c PsFTFonts.c
+FTOBJS = psout_ft.o psout_ftpstype1.o psout_ftpstype3.o PsFTFonts.o
+
+#if !defined (LynxOSArchitecture)
+TTF2PT1SRCFILE = ttf2pt1.c
+TTF2PT1OBJFILE = ttf2pt1.o
+#else
+TTF2PT1SRCFILE = ttf2pt1wrap.c
+TTF2PT1OBJFILE = ttf2pt1wrap.o
+#endif
+
+#if defined(SCOArchitecture)
+XTRA_SYS_DEFINES = SCOBuildFlags
+#endif
+
+TTF2PT1SRCS = ft.c pt1.c runt1asm.c $(TTF2PT1SRCFILE)
+TTF2PT1OBJS = ft.o pt1.o runt1asm.o $(TTF2PT1OBJFILE)
+TTF2PT1_DEFINES = -DUSE_FREETYPE -DXP_ONLY_BLOCKS
+#endif /* BuildFreeType || BuildFreetype2Library */
+
+SRCS1 = PsInit.c PsPrint.c PsGC.c PsMisc.c PsSpans.c PsArea.c PsPixel.c \
+ PsLine.c PsPolygon.c PsArc.c PsText.c PsWindow.c PsFonts.c \
+ PsAttr.c PsAttVal.c PsColor.c PsPixmap.c psout.c PsCache.c PsImageUtil.c
+
+OBJS1 = PsInit.o PsPrint.o PsGC.o PsMisc.o PsSpans.o PsArea.o PsPixel.o \
+ PsLine.o PsPolygon.o PsArc.o PsText.o PsWindow.o PsFonts.o \
+ PsAttr.o PsAttVal.o PsColor.o PsPixmap.o psout.o PsCache.o PsImageUtil.o
+
+SRCS = $(SRCS1) $(TTF2PT1SRCS) $(FTSRCS)
+
+OBJS = $(OBJS1) $(TTF2PT1OBJS) $(FTOBJS)
+
+#if BuildFreeType || BuildFreetype2Library
+LinkSourceFile(ttf2pt1.c,$(TTF2PT1OURCEDIR)/)
+LinkSourceFile(pt1.c,$(TTF2PT1OURCEDIR)/)
+LinkSourceFile(pt1.h,$(TTF2PT1OURCEDIR)/)
+LinkSourceFile(ft.c,$(TTF2PT1OURCEDIR)/)
+LinkSourceFile(runt1asm.c,$(TTF2PT1OURCEDIR)/)
+LinkSourceFile(t1asm.c,$(TTF2PT1OURCEDIR)/)
+LinkSourceFile(ttf.h,$(TTF2PT1OURCEDIR)/)
+LinkSourceFile(global.h,$(TTF2PT1OURCEDIR)/)
+LinkSourceFile(version.h,$(TTF2PT1OURCEDIR)/)
+#endif /* BuildFreeType || BuildFreetype2Library */
+
+#ifdef XVendorString
+VENDORSTRING = XVendorString
+ VENDOR_STRING = -DVENDOR_STRING=\"$(VENDORSTRING)\"
+#endif
+
+#ifdef XVendorRelease
+VENDORRELEASE = XVendorRelease
+ VENDOR_RELEASE = -DVENDOR_RELEASE="$(VENDORRELEASE)"
+#endif
+
+VENDOR_DEFINES = $(VENDOR_STRING) $(VENDOR_RELEASE)
+
+XCOMM DEFINES = -DPIXPRIV
+
+XCOMM BM_CACHE disabled because it causes PostScript errors
+XCOMM (see http://xprint.mozdev.org/bugs/show_bug.cgi?id=1489)
+XCOMM DEFINES = -DPSOUT_USE_DEEPCOLOR -DXP_PSTEXT -DBM_CACHE $(VENDOR_DEFINES) $(TTF2PT1_DEFINES) $(FT_DEFINES)
+ DEFINES = -UXFree86LOADER -DPSOUT_USE_DEEPCOLOR -DXP_PSTEXT -D_XP_PRINT_SERVER_ $(VENDOR_DEFINES) $(TTF2PT1_DEFINES) $(FT_DEFINES) $(EXT_DEFINES) $(XTRA_SYS_DEFINES)
+
+ INCLUDES = -I. -I../../mi -I../../mfb -I$(LIBSRC) \
+ -I$(XINCLUDESRC) -I../../include -I.. -I$(TOP)/include \
+ -I$(EXTINCSRC) -I$(FONTINCSRC) -I$(FONTLIBSRC)/include \
+ $(FT2INCS) -I../../../../lib/font/FreeType
+
+ LINTLIBS = $(TOP)/server/dix/llib-ldix.ln $(TOP)/server/os/llib-los.ln \
+ $(TOP)/server/ddx/mfb/llib-lmfb.ln \
+ $(TOP)/server/ddx/mi/llib-lmi.ln
+
+NormalLibraryObjectRule()
+
+NormalLibraryTarget(ps,$(OBJS))
+NormalLintTarget($(SRCS1) $(SRCS2))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/Xprint/ps/Ps.h b/nx-X11/programs/Xserver/Xprint/ps/Ps.h
new file mode 100644
index 000000000..781161d8a
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/Ps.h
@@ -0,0 +1,590 @@
+/* $Xorg: Ps.h,v 1.5 2001/02/09 02:04:35 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: Ps.h
+** *
+** * Contents: defines and includes for the Ps driver
+** * for a printing X server.
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _PS_H_
+#define _PS_H_
+
+#include <stdio.h>
+
+#ifdef abs
+#undef abs /* this is because of a non-Spec1170ness in misc.h */
+#endif
+#include <stdlib.h>
+#include "scrnintstr.h"
+#include "dix.h"
+
+#include "PsDef.h"
+#include "psout.h"
+
+#include <X11/extensions/Print.h>
+#include <X11/extensions/Printstr.h>
+
+#include "regionstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+
+/*
+ * Some sleazes to force the XrmDB stuff into the server
+ */
+#ifndef HAVE_XPointer
+typedef char *XPointer;
+#define Status int
+#define True 1
+#define False 0
+#endif
+
+#include "misc.h"
+#include <X11/Xfuncproto.h>
+#include <X11/Xresource.h>
+#include "attributes.h"
+
+
+/*
+ * Public index variables from PsInit.c
+ */
+
+extern int PsScreenPrivateIndex;
+extern int PsWindowPrivateIndex;
+extern int PsContextPrivateIndex;
+extern int PsPixmapPrivateIndex;
+extern XpValidatePoolsRec PsValidatePoolsRec;
+
+/*
+ * Display list structures
+ */
+
+#define DPY_BLOCKSIZE 4096
+
+typedef struct
+{
+ int mode;
+ int nPoints;
+ xPoint *pPoints;
+} PsPolyPointsRec;
+
+typedef struct
+{
+ int nSegments;
+ xSegment *pSegments;
+} PsSegmentsRec;
+
+typedef struct
+{
+ int nRects;
+ xRectangle *pRects;
+} PsRectanglesRec;
+
+typedef struct
+{
+ int nArcs;
+ xArc *pArcs;
+} PsArcsRec;
+
+typedef struct
+{
+ int x;
+ int y;
+ int count;
+ char *string;
+} PsText8Rec;
+
+typedef struct
+{
+ int x;
+ int y;
+ int count;
+ unsigned short *string;
+} PsText16Rec;
+
+typedef struct
+{
+ int depth;
+ int x;
+ int y;
+ int w;
+ int h;
+ int leftPad;
+ int format;
+ int res; /* image resolution */
+ char *pData;
+} PsImageRec;
+
+typedef struct
+{
+ int x;
+ int y;
+ int w;
+ int h;
+} PsFrameRec;
+
+typedef enum
+{
+ PolyPointCmd,
+ PolyLineCmd,
+ PolySegmentCmd,
+ PolyRectangleCmd,
+ FillPolygonCmd,
+ PolyFillRectCmd,
+ PolyArcCmd,
+ PolyFillArcCmd,
+ Text8Cmd,
+ Text16Cmd,
+ TextI8Cmd,
+ TextI16Cmd,
+ PutImageCmd,
+ BeginFrameCmd,
+ EndFrameCmd
+} DisplayElmType;
+
+typedef struct _DisplayElmRec
+{
+ DisplayElmType type;
+ GCPtr gc;
+ union
+ {
+ PsPolyPointsRec polyPts;
+ PsSegmentsRec segments;
+ PsRectanglesRec rects;
+ PsArcsRec arcs;
+ PsText8Rec text8;
+ PsText16Rec text16;
+ PsImageRec image;
+ PsFrameRec frame;
+ } c;
+} DisplayElmRec;
+
+typedef DisplayElmRec *DisplayElmPtr;
+
+typedef struct _DisplayListRec
+{
+ struct _DisplayListRec *next;
+ int nelms;
+ DisplayElmRec elms[DPY_BLOCKSIZE];
+} DisplayListRec;
+
+typedef DisplayListRec *DisplayListPtr;
+
+/*
+ * Private structures
+ */
+
+typedef struct
+{
+ XrmDatabase resDB;
+ Bool (*DestroyWindow)(WindowPtr);
+} PsScreenPrivRec, *PsScreenPrivPtr;
+
+typedef struct PsFontTypeInfoRec PsFontTypeInfoRec;
+
+/* Structure to hold information about one font on disk
+ * Notes:
+ * - multiple XLFD names can refer to the same |PsFontTypeInfoRec| (if
+ * they all use the same font on the disk)
+ * - the FreeType font download code uses multiple |PsFontTypeInfoRec|
+ * records for one font on disk if they differ in the encoding being
+ * used (this is an exception from the
+ * 'one-|PsFontTypeInfoRec|-per-font-on-disk'-design; maybe it it is better
+ * to rework that in a later step and add a new per-encoding structure).
+ */
+struct PsFontTypeInfoRec
+{
+ PsFontTypeInfoRec *next; /* Next record in list... */
+ char *adobe_ps_name; /* PostScript font name (from the
+ * "_ADOBE_POSTSCRIPT_FONTNAME" atom) */
+ char *download_ps_name; /* PostScript font name used for font download */
+ char *filename; /* File name of font */
+#ifdef XP_USE_FREETYPE
+ char *ft_download_encoding; /* encoding used for download */
+ PsFTDownloadFontType ft_download_font_type; /* PS font type used for download (e.g. Type1/Type3/CID/etc.) */
+#endif /* XP_USE_FREETYPE */
+ int is_iso_encoding; /* Is this font encoded in ISO Latin 1 ? */
+ int font_type; /* See PSFTI_FONT_TYPE_* below... */
+ Bool downloadableFont; /* Font can be downloaded */
+ Bool alreadyDownloaded[256]; /* Font has been downloaded (for 256 8bit "sub"-font) */
+};
+
+#define PSFTI_FONT_TYPE_OTHER (0)
+#define PSFTI_FONT_TYPE_PMF (1)
+#define PSFTI_FONT_TYPE_PS_TYPE1_PFA (2)
+#define PSFTI_FONT_TYPE_PS_TYPE1_PFB (3)
+#define PSFTI_FONT_TYPE_TRUETYPE (4)
+/* PSFTI_FONT_TYPE_FREETYPE is means the font is handled by the freetype engine */
+#define PSFTI_FONT_TYPE_FREETYPE (5)
+
+typedef struct PsFontInfoRec PsFontInfoRec;
+
+/* Structure which represents our context info for a single XLFD font
+ * Note that multiple |PsFontInfoRec| records can share the same
+ * |PsFontTypeInfoRec| record - the |PsFontInfoRec| records represent
+ * different appearances of the same font on disk(=|PsFontTypeInfoRec|)).
+ */
+struct PsFontInfoRec
+{
+ PsFontInfoRec *next; /* Next record in list... */
+ /* |font| and |font_fontPrivate| are used by |PsFindFontInfoRec()| to
+ * identify a font */
+ FontPtr font; /* The font this record is for */
+ pointer font_fontPrivate;
+ PsFontTypeInfoRec *ftir; /* Record about the font file on disk */
+ const char *dfl_name; /* XLFD for this font */
+ int size; /* Font size. Use |mtx| if |size==0| */
+ float mtx[4]; /* Transformation matrix (see |size|) */
+};
+
+typedef struct
+{
+ char *jobFileName;
+ FILE *pJobFile;
+ GC lastGC;
+ unsigned char *dash;
+ int validGC;
+ ClientPtr getDocClient;
+ int getDocBufSize;
+ PsOutPtr pPsOut;
+ PsFontTypeInfoRec *fontTypeInfoRecords;
+ PsFontInfoRec *fontInfoRecords;
+} PsContextPrivRec, *PsContextPrivPtr;
+
+typedef struct
+{
+ int validContext;
+ XpContextPtr context;
+} PsWindowPrivRec, *PsWindowPrivPtr;
+
+typedef struct
+{
+ XpContextPtr context;
+ GC lastGC;
+ int validGC;
+ DisplayListPtr dispList;
+} PsPixmapPrivRec, *PsPixmapPrivPtr;
+
+/*
+ * Macro functions
+ */
+
+#define SEND_PS(f,c) fwrite( c, sizeof( char ), strlen( c ), f )
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#ifndef MAX
+#define MAX(a,b) (((a)>(b))?(a):(b))
+#endif
+
+/*
+ * Functions in PsInit.c
+ */
+
+extern Bool InitializePsDriver(int ndx, ScreenPtr pScreen, int argc,
+ char **argv);
+extern XpContextPtr PsGetContextFromWindow(WindowPtr win);
+
+/*
+ * Functions in PsPrint.c
+ */
+
+extern int PsStartJob(XpContextPtr pCon, Bool sendClientData, ClientPtr client);
+extern int PsEndJob(XpContextPtr pCon, Bool cancel);
+extern int PsStartPage(XpContextPtr pCon, WindowPtr pWin);
+extern int PsEndPage(XpContextPtr pCon, WindowPtr pWin);
+extern int PsStartDoc(XpContextPtr pCon, XPDocumentType type);
+extern int PsEndDoc(XpContextPtr pCon, Bool cancel);
+extern int PsDocumentData(XpContextPtr pCon, DrawablePtr pDraw, char *pData,
+ int len_data, char *pFmt, int len_fmt, char *pOpt, int len_opt,
+ ClientPtr client);
+extern int PsGetDocumentData(XpContextPtr pCon, ClientPtr client,
+ int maxBufferSize);
+
+/*
+ * Functions in PsGC.c
+ */
+
+extern Bool PsCreateGC(GCPtr pGC);
+extern PsContextPrivPtr PsGetPsContextPriv( DrawablePtr pDrawable );
+extern int PsUpdateDrawableGC(GCPtr pGC, DrawablePtr pDrawable,
+ PsOutPtr *psOut, ColormapPtr *cMap);
+extern void PsValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable);
+extern void PsChangeGC(GCPtr pGC, unsigned long changes);
+extern void PsCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
+extern void PsDestroyGC(GCPtr pGC);
+extern void PsChangeClip(GCPtr pGC, int type, pointer pValue, int nrects);
+extern void PsDestroyClip(GCPtr pGC);
+extern void PsCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
+
+extern GCPtr PsCreateAndCopyGC(DrawablePtr pDrawable, GCPtr pSrc);
+
+/*
+ * Functions in PsMisc.c
+ */
+
+extern void PsQueryBestSize(int type, short *pwidth, short *pheight,
+ ScreenPtr pScreen);
+extern Bool PsCloseScreen(int index, ScreenPtr pScreen);
+extern void PsLineAttrs(PsOutPtr psOut, GCPtr pGC, ColormapPtr cMap);
+extern int PsGetMediumDimensions(
+ XpContextPtr pCon,
+ CARD16 *pWidth,
+ CARD16 *pHeight);
+extern int PsGetReproducibleArea(
+ XpContextPtr pCon,
+ xRectangle *pRect);
+extern int PsSetImageResolution(
+ XpContextPtr pCon,
+ int imageRes,
+ Bool *status);
+
+/*
+ * Functions in PsSpans.c
+ */
+
+extern void PsFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans,
+ DDXPointPtr pPoints, int *pWidths, int fSorted);
+extern void PsSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *pSrc,
+ DDXPointPtr pPoints, int *pWidths, int nSpans,
+ int fSorted);
+
+/*
+ * Functions in PsArea.c
+ */
+
+extern void PsPutScaledImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
+ int x, int y, int w, int h, int leftPad, int format,
+ int imageRes, char *pImage);
+extern void PsPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
+ int x, int y, int w, int h, int leftPad, int format,
+ char *pImage);
+extern void PsPutImageMask(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
+ int w, int h, int leftPad, int format, char *pImage);
+extern RegionPtr PsCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int width, int height,
+ int dstx, int dsty);
+extern RegionPtr PsCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int width, int height,
+ int dstx, int dsty, unsigned long plane);
+
+/*
+ * Functions in PsPixel.c
+ */
+
+extern void PsPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode,
+ int nPoints, xPoint *pPoints);
+extern void PsPushPixels(GCPtr pGC, PixmapPtr pBitmap, DrawablePtr pDrawable,
+ int width, int height, int x, int y);
+
+/*
+ * Functions in PsLine.c
+ */
+
+extern void PsPolyLine(DrawablePtr pDrawable, GCPtr pGC, int mode,
+ int nPoints, xPoint *pPoints);
+extern void PsPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nSegments,
+ xSegment *pSegments);
+
+/*
+ * Functions in PsPolygon.c
+ */
+
+extern void PsPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nRects,
+ xRectangle *pRects);
+extern void PsFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape,
+ int mode, int nPoints, DDXPointPtr pPoints);
+extern void PsPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nRects,
+ xRectangle *pRects);
+
+/*
+ * Functions in PsPolygon.c
+ */
+
+extern void PsPolyArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs,
+ xArc *pArcs);
+extern void PsPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs,
+ xArc *pArcs);
+
+/*
+ * Functions in PsText.c
+ */
+
+extern int PsPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ int count, char *string);
+extern int PsPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ int count, unsigned short *string);
+extern void PsImageText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ int count, char *string);
+extern void PsImageText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ int count, unsigned short *string);
+extern void PsImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nGlyphs, CharInfoPtr *pCharInfo,
+ pointer pGlyphBase);
+extern void PsPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nGlyphs, CharInfoPtr *pCharInfo,
+ pointer pGlyphBase);
+
+/*
+ * Functions in PsWindow.c
+ */
+
+extern Bool PsCreateWindow(WindowPtr pWin);
+extern Bool PsMapWindow(WindowPtr pWin);
+extern Bool PsPositionWindow(WindowPtr pWin, int x, int y);
+extern Bool PsUnmapWindow(WindowPtr pWin);
+extern void PsCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc);
+extern Bool PsChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
+extern void PsPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
+extern Bool PsDestroyWindow(WindowPtr pWin);
+
+/*
+ * Functions in PsFonts.c
+ */
+
+extern Bool PsRealizeFont(ScreenPtr pscr, FontPtr pFont);
+extern Bool PsUnrealizeFont(ScreenPtr pscr, FontPtr pFont);
+extern char *PsGetFontName(FontPtr pFont);
+extern int PsGetFontSize(FontPtr pFont, float *mtx);
+extern char *PsGetPSFontName(FontPtr pFont);
+extern char *PsGetPSFaceOrFontName(FontPtr pFont);
+extern int PsIsISOLatin1Encoding(FontPtr pFont);
+extern char *PsGetEncodingName(FontPtr pFont);
+extern PsFontInfoRec *PsGetFontInfoRec(DrawablePtr pDrawable, FontPtr pFont);
+extern void PsFreeFontInfoRecords(PsContextPrivPtr priv);
+extern PsFTDownloadFontType PsGetFTDownloadFontType(void);
+
+/*
+ * Functions in PsFTFonts.c
+ */
+
+extern char *PsGetFTFontFileName(FontPtr pFont);
+extern Bool PsIsFreeTypeFont(FontPtr pFont);
+
+/*
+ * Functions in PsAttr.c
+ */
+
+extern char *PsGetAttributes(XpContextPtr pCon, XPAttributes pool);
+extern char *PsGetOneAttribute(XpContextPtr pCon, XPAttributes pool,
+ char *attr);
+extern int PsAugmentAttributes(XpContextPtr pCon, XPAttributes pool,
+ char *attrs);
+extern int PsSetAttributes(XpContextPtr pCon, XPAttributes pool, char *attrs);
+
+/*
+ * Functions in PsColor.c
+ */
+
+extern Bool PsCreateColormap(ColormapPtr pColor);
+extern void PsDestroyColormap(ColormapPtr pColor);
+extern void PsInstallColormap(ColormapPtr pColor);
+extern void PsUninstallColormap(ColormapPtr pColor);
+extern int PsListInstalledColormaps(ScreenPtr pScreen, XID *pCmapList);
+extern void PsStoreColors(ColormapPtr pColor, int ndef, xColorItem *pdefs);
+extern void PsResolveColor(unsigned short *pRed, unsigned short *pGreen,
+ unsigned short *pBlue, VisualPtr pVisual);
+extern PsOutColor PsGetPixelColor(ColormapPtr cMap, int pixval);
+extern void PsSetFillColor(DrawablePtr pDrawable, GCPtr pGC, PsOutPtr psOut,
+ ColormapPtr cMap);
+
+/*
+ * Functions in PsPixmap.c
+ */
+
+extern PixmapPtr PsCreatePixmap(ScreenPtr pScreen, int width, int height,
+ int depth);
+extern void PsScrubPixmap(PixmapPtr pPixmap);
+extern Bool PsDestroyPixmap(PixmapPtr pPixmap);
+extern DisplayListPtr PsGetFreeDisplayBlock(PsPixmapPrivPtr priv);
+extern void PsReplayPixmap(PixmapPtr pix, DrawablePtr pDrawable);
+extern int PsCloneDisplayElm(PixmapPtr dst,
+ DisplayElmPtr elm, DisplayElmPtr newElm,
+ int xoff, int yoff);
+extern void PsCopyDisplayList(PixmapPtr src, PixmapPtr dst, int xoff,
+ int yoff, int x, int y, int w, int h);
+extern PsElmPtr PsCreateFillElementList(PixmapPtr pix, int *nElms);
+extern PsElmPtr PsCloneFillElementList(int nElms, PsElmPtr elms);
+extern void PsDestroyFillElementList(int nElms, PsElmPtr elms);
+
+/*
+ * Functions in PsImageUtil.c
+ */
+
+extern unsigned long
+PsGetImagePixel(char *pImage, int depth, int w, int h, int leftPad, int format,
+ int px, int py);
+
+#endif /* _PS_H_ */
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsArc.c b/nx-X11/programs/Xserver/Xprint/ps/PsArc.c
new file mode 100644
index 000000000..511971e7a
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsArc.c
@@ -0,0 +1,182 @@
+/* $Xorg: PsArc.c,v 1.4 2001/02/09 02:04:35 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsArc.c
+** *
+** * Contents: Arc-drawing code for the PS DDX driver
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+
+#include "Ps.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+
+void
+PsPolyArc(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArcs,
+ xArc *pArcs)
+{
+ if( pDrawable->type==DRAWABLE_PIXMAP )
+ {
+ DisplayElmPtr elm;
+ PixmapPtr pix = (PixmapPtr)pDrawable;
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
+ DisplayListPtr disp;
+ GCPtr gc;
+
+ if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return;
+
+ disp = PsGetFreeDisplayBlock(priv);
+
+ elm = &disp->elms[disp->nelms];
+ elm->type = PolyArcCmd;
+ elm->gc = gc;
+ elm->c.arcs.nArcs = nArcs;
+ elm->c.arcs.pArcs = (xArc *)xalloc(nArcs*sizeof(xArc));
+ memcpy(elm->c.arcs.pArcs, pArcs, nArcs*sizeof(xArc));
+ disp->nelms += 1;
+ }
+ else
+ {
+ int i;
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return;
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ PsLineAttrs(psOut, pGC, cMap);
+ for( i=0 ; i<nArcs ; i++ )
+ {
+ PsOut_DrawArc(psOut, (int)pArcs[i].x, (int)pArcs[i].y,
+ (int)pArcs[i].width, (int)pArcs[i].height,
+ (float)pArcs[i].angle1/64.,
+ (float)pArcs[i].angle2/64.);
+ }
+ }
+}
+
+void
+PsPolyFillArc(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArcs,
+ xArc *pArcs)
+{
+ if( pDrawable->type==DRAWABLE_PIXMAP )
+ {
+ DisplayElmPtr elm;
+ PixmapPtr pix = (PixmapPtr)pDrawable;
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
+ DisplayListPtr disp;
+ GCPtr gc;
+
+ if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return;
+
+ disp = PsGetFreeDisplayBlock(priv);
+
+ elm = &disp->elms[disp->nelms];
+ elm->type = PolyFillArcCmd;
+ elm->gc = gc;
+ elm->c.arcs.nArcs = nArcs;
+ elm->c.arcs.pArcs = (xArc *)xalloc(nArcs*sizeof(xArc));
+ memcpy(elm->c.arcs.pArcs, pArcs, nArcs*sizeof(xArc));
+ disp->nelms += 1;
+ }
+ else
+ {
+ int i;
+ PsOutPtr psOut;
+ PsArcEnum styl;
+ ColormapPtr cMap;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return;
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsSetFillColor(pDrawable, pGC, psOut, cMap);
+ PsLineAttrs(psOut, pGC, cMap);
+ if( pGC->arcMode==ArcChord ) styl = PsChord;
+ else styl = PsPieSlice;
+ for( i=0 ; i<nArcs ; i++ )
+ {
+ PsOut_FillArc(psOut, (int)pArcs[i].x, (int)pArcs[i].y,
+ (int)pArcs[i].width, (int)pArcs[i].height,
+ (float)pArcs[i].angle1/64.,
+ (float)pArcs[i].angle2/64., styl);
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsArea.c b/nx-X11/programs/Xserver/Xprint/ps/PsArea.c
new file mode 100644
index 000000000..32a4d5cf4
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsArea.c
@@ -0,0 +1,393 @@
+/* $Xorg: PsArea.c,v 1.6 2001/03/14 18:27:44 pookie Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996, 2000 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsArea.c
+** *
+** * Contents: Image and Area functions for the PS DDX driver
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Ps.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+
+
+void
+PsPutScaledImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
+ int w, int h, int leftPad, int format, int imageRes, char *pImage)
+{
+ if( pDrawable->type==DRAWABLE_PIXMAP )
+ {
+ int size = PixmapBytePad(w, depth)*h;
+ DisplayElmPtr elm;
+ PixmapPtr pix = (PixmapPtr)pDrawable;
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
+ DisplayListPtr disp;
+ GCPtr gc;
+
+ if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return;
+
+ disp = PsGetFreeDisplayBlock(priv);
+ elm = &disp->elms[disp->nelms];
+ elm->type = PutImageCmd;
+ elm->gc = gc;
+ elm->c.image.depth = depth;
+ elm->c.image.x = x;
+ elm->c.image.y = y;
+ elm->c.image.w = w;
+ elm->c.image.h = h;
+ elm->c.image.leftPad = leftPad;
+ elm->c.image.format = format;
+ elm->c.image.res = imageRes;
+ elm->c.image.pData = (char *)xalloc(size);
+ memcpy(elm->c.image.pData, pImage, size);
+ disp->nelms += 1;
+ }
+ else
+ {
+ int i, j;
+ int r, c;
+ char *pt;
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+ int pageRes, sw, sh;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return;
+ if (!imageRes) {
+ sw = w;
+ sh = h;
+ } else {
+ pageRes = XpGetResolution(XpGetPrintContext(requestingClient));
+ sw = (float)w * (float)pageRes / (float)imageRes + 0.5;
+ sh = (float)h * (float)pageRes / (float)imageRes + 0.5;
+ }
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+
+ if( depth!=1 )
+ {
+ PsOut_BeginImage(psOut, 0, 0, x, y, w, h, sw, sh, 3);
+
+ for( r=0 ; r<h ; r++ )
+ {
+ for( c=0 ; c<w ; c++ )
+ {
+ unsigned long pv = PsGetImagePixel(pImage, depth, w, h, leftPad, format, c, r);
+ PsOutColor clr = PsGetPixelColor(cMap, pv);
+ /* XXX: This needs to be fixed for endian swapping and to support
+ * depths deeper than 8bit per R-,G-,B-gun... */
+ unsigned long val = PSOUTCOLOR_TO_RGB24BIT(clr);
+ char *ipt = (char *)&val;
+/* XXX: Is this the right way to detect the platform endianess ? */
+#if IMAGE_BYTE_ORDER == LSBFirst
+ {
+ long l;
+ swapl(&val, l);
+ }
+#elif IMAGE_BYTE_ORDER == MSBFirst
+#else
+#error Unsupported byte order
+#endif
+ PsOut_OutImageBytes(psOut, 3, &ipt[1]);
+ }
+ }
+
+ PsOut_EndImage(psOut);
+ }
+ else
+ {
+ int rowsiz = BitmapBytePad(w);
+ int psrsiz = (w+7)/8;
+ PsOut_BeginImage(psOut, PsGetPixelColor(cMap, pGC->bgPixel),
+ PsGetPixelColor(cMap, pGC->fgPixel),
+ x, y, w, h, sw, sh, 1);
+ for( r=0 ; r<h ; r++ )
+ {
+ char *pt = &pImage[rowsiz*r];
+ for( i=0 ; i<psrsiz ; i++ )
+ {
+ int iv_, iv = (int)pt[i]&0xFF;
+ char c;
+/* XXX: Is this the right way to detect the platform endianess ? */
+#if IMAGE_BYTE_ORDER == LSBFirst
+ { for( j=0,iv_=0 ; j<8 ; j++ ) iv_ |= (((iv>>j)&1)<<(7-j)); }
+#elif IMAGE_BYTE_ORDER == MSBFirst
+ iv_ = iv;
+#else
+#error Unsupported byte order
+#endif
+ c = iv_;
+ PsOut_OutImageBytes(psOut, 1, &c);
+ }
+ }
+ PsOut_EndImage(psOut);
+ }
+ }
+}
+
+void
+PsPutScaledImageIM(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
+ int w, int h, int leftPad, int format, int imageRes, char *pImage)
+{
+ if( pDrawable->type==DRAWABLE_PIXMAP )
+ {
+ int size = PixmapBytePad(w, depth)*h;
+ DisplayElmPtr elm;
+ PixmapPtr pix = (PixmapPtr)pDrawable;
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
+ DisplayListPtr disp;
+ GCPtr gc;
+
+ if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return;
+
+ disp = PsGetFreeDisplayBlock(priv);
+ elm = &disp->elms[disp->nelms];
+ elm->type = PutImageCmd;
+ elm->gc = gc;
+ elm->c.image.depth = depth;
+ elm->c.image.x = x;
+ elm->c.image.y = y;
+ elm->c.image.w = w;
+ elm->c.image.h = h;
+ elm->c.image.leftPad = leftPad;
+ elm->c.image.format = format;
+ elm->c.image.res = imageRes;
+ elm->c.image.pData = (char *)xalloc(size);
+ memcpy(elm->c.image.pData, pImage, size);
+ disp->nelms += 1;
+ }
+ else
+ {
+ int i, j;
+ int r, c;
+ char *pt;
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+ int pageRes, sw, sh;
+#ifdef BM_CACHE
+ long cache_id = 0;
+#endif
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return;
+ if (!imageRes) {
+ sw = w;
+ sh = h;
+ } else {
+ pageRes = XpGetResolution(XpGetPrintContext(requestingClient));
+ sw = (float)w * (float)pageRes / (float)imageRes + 0.5;
+ sh = (float)h * (float)pageRes / (float)imageRes + 0.5;
+ }
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+
+#ifdef BM_CACHE
+ cache_id = PsBmIsImageCached(w, h, pImage);
+
+ if(!cache_id)
+ {
+ cache_id = PsBmPutImageInCache(w, h, pImage);
+
+ if(!cache_id)
+ return;
+
+ PsOut_BeginImageCache(psOut, cache_id);
+#endif
+ if( depth!=1 )
+ {
+ PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3);
+
+ for( r=0 ; r<h ; r++ )
+ {
+ for( c=0 ; c<w ; c++ )
+ {
+ unsigned long pv = PsGetImagePixel(pImage, depth, w, h, leftPad, format, c, r);
+ PsOutColor clr = PsGetPixelColor(cMap, pv);
+ /* XXX: This needs to be fixed for endian swapping and to support
+ * depths deeper than 8bit per R-,G-,B-gun... */
+ unsigned long val = PSOUTCOLOR_TO_RGB24BIT(clr);
+ char *ipt = (char *)&val;
+/* XXX: Is this the right way to detect the platform endianess ? */
+#if IMAGE_BYTE_ORDER == LSBFirst
+ {
+ long l;
+ swapl(&val, l);
+ }
+#elif IMAGE_BYTE_ORDER == MSBFirst
+#else
+#error Unsupported byte order
+#endif
+ PsOut_OutImageBytes(psOut, 3, &ipt[1]);
+ }
+ }
+
+ PsOut_EndImage(psOut);
+ }
+ else
+ {
+ int rowsiz = BitmapBytePad(w);
+ int psrsiz = (w+7)/8;
+ PsOut_BeginImageIM(psOut, PsGetPixelColor(cMap, pGC->bgPixel),
+ PsGetPixelColor(cMap, pGC->fgPixel),
+ x, y, w, h, sw, sh, 1);
+ for( r=0 ; r<h ; r++ )
+ {
+ char *pt = &pImage[rowsiz*r];
+ for( i=0 ; i<psrsiz ; i++ )
+ {
+ int iv_, iv = (int)pt[i]&0xFF;
+ char c;
+/* XXX: Is this the right way to detect the platform endianess ? */
+#if IMAGE_BYTE_ORDER == LSBFirst
+ { for( j=0,iv_=0 ; j<8 ; j++ ) iv_ |= (((iv>>j)&1)<<(7-j)); }
+#elif IMAGE_BYTE_ORDER == MSBFirst
+ iv_ = iv;
+#else
+#error Unsupported byte order
+#endif
+ c = iv_;
+ PsOut_OutImageBytes(psOut, 1, &c);
+ }
+ }
+ PsOut_EndImage(psOut);
+ }
+#ifdef BM_CACHE
+ PsOut_EndImageCache(psOut);
+ }
+ PsOut_ImageCache(psOut, x, y, cache_id, PsGetPixelColor(cMap, pGC->bgPixel),
+ PsGetPixelColor(cMap, pGC->fgPixel));
+#endif
+ }
+}
+void
+PsPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
+ int w, int h, int leftPad, int format, char *pImage)
+{
+ XpContextPtr pcon;
+ if (requestingClient && (pcon = XpGetPrintContext(requestingClient)))
+ PsPutScaledImage(pDrawable, pGC, depth, x, y, w, h, leftPad, format,
+ pcon->imageRes, pImage);
+}
+void
+PsPutImageMask(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
+ int w, int h, int leftPad, int format, char *pImage)
+{
+ XpContextPtr pcon;
+ if (requestingClient && (pcon = XpGetPrintContext(requestingClient)))
+ PsPutScaledImageIM(pDrawable, pGC, depth, x, y, w, h, leftPad, format,
+ pcon->imageRes, pImage);
+}
+
+RegionPtr
+PsCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy,
+ int width, int height, int dstx, int dsty)
+{
+ PixmapPtr src = (PixmapPtr)pSrc;
+ PixmapPtr dst = (PixmapPtr)pDst;
+
+ if( pSrc->type!=DRAWABLE_PIXMAP ) return NULL;
+ if( pDst->type!=DRAWABLE_PIXMAP )
+ {
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+ if( PsUpdateDrawableGC(pGC, pDst, &psOut, &cMap)==FALSE ) return NULL;
+ PsOut_Offset(psOut, pDst->x, pDst->y);
+ PsOut_BeginFrame(psOut, dstx-srcx, dsty-srcy, dstx, dsty, width, height);
+ PsReplayPixmap(src, pDst);
+ PsOut_EndFrame(psOut);
+ }
+ else PsCopyDisplayList(src, dst, dstx-srcx, dsty-srcy, dstx, dsty,
+ width, height);
+ return NULL;
+}
+
+RegionPtr
+PsCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy,
+ int width, int height, int dstx, int dsty, unsigned long plane)
+{
+ PixmapPtr src = (PixmapPtr)pSrc;
+ PixmapPtr dst = (PixmapPtr)pDst;
+
+ if( pSrc->type!=DRAWABLE_PIXMAP ) return NULL;
+ if( pDst->type!=DRAWABLE_PIXMAP )
+ {
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+ if( PsUpdateDrawableGC(pGC, pDst, &psOut, &cMap)==FALSE ) return NULL;
+ PsOut_Offset(psOut, pDst->x, pDst->y);
+ PsOut_BeginFrame(psOut, dstx-srcx, dsty-srcy, dstx, dsty, width, height);
+ PsReplayPixmap(src, pDst);
+ PsOut_EndFrame(psOut);
+ }
+ else PsCopyDisplayList(src, dst, dstx-srcx, dsty-srcy, dstx, dsty,
+ width, height);
+ return NULL;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsAttVal.c b/nx-X11/programs/Xserver/Xprint/ps/PsAttVal.c
new file mode 100644
index 000000000..fc23ffef5
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsAttVal.c
@@ -0,0 +1,290 @@
+/*
+ * $Xorg: PsAttVal.c,v 1.5 2001/03/13 18:45:31 pookie Exp $
+ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Ps.h"
+#include "AttrValid.h"
+
+/*
+ * define valid values and defaults for Printer pool
+ */
+static XpOid ValidContentOrientationsOids[] = {
+ xpoid_val_content_orientation_portrait,
+ xpoid_val_content_orientation_landscape,
+ xpoid_val_content_orientation_reverse_portrait,
+ xpoid_val_content_orientation_reverse_landscape
+};
+static XpOidList ValidContentOrientations = {
+ ValidContentOrientationsOids, XpNumber(ValidContentOrientationsOids)
+};
+
+static XpOid DefaultContentOrientationsOids[] = {
+ xpoid_val_content_orientation_portrait,
+ xpoid_val_content_orientation_landscape
+};
+static XpOidList DefaultContentOrientations = {
+ DefaultContentOrientationsOids, XpNumber(DefaultContentOrientationsOids)
+};
+
+static XpOid ValidPlexesOids[] = {
+ xpoid_val_plex_simplex, xpoid_val_plex_duplex, xpoid_val_plex_tumble
+};
+static XpOidList ValidPlexes = {
+ ValidPlexesOids, XpNumber(ValidPlexesOids)
+};
+
+static XpOid DefaultPlexesOids[] = {
+ xpoid_val_plex_simplex
+};
+static XpOidList DefaultPlexes = {
+ DefaultPlexesOids, XpNumber(DefaultPlexesOids)
+};
+
+static unsigned long ValidPrinterResolutionsCards[] = {
+ 75,
+ 100,
+ 120,
+ 150,
+ 180,
+ 200,
+ 240,
+ 300,
+ 360,
+ 400,
+ 600,
+ 720,
+ 940,
+ 1200,
+ 1440,
+ 2400
+};
+static XpOidCardList ValidPrinterResolutions = {
+ ValidPrinterResolutionsCards, XpNumber(ValidPrinterResolutionsCards)
+};
+
+static unsigned long DefaultPrinterResolutionsCards[] = {
+ 75,
+ 100,
+ 120,
+ 150,
+ 180,
+ 200,
+ 240,
+ 300,
+ 360,
+ 400,
+ 600,
+ 720,
+ 940,
+ 1200
+};
+static XpOidCardList DefaultPrinterResolutions = {
+ DefaultPrinterResolutionsCards, XpNumber(DefaultPrinterResolutionsCards)
+};
+
+static XpOid ValidListfontsModesOids[] = {
+ xpoid_val_xp_list_internal_printer_fonts, xpoid_val_xp_list_glyph_fonts
+};
+static XpOidList ValidListfontsModes = {
+ ValidListfontsModesOids, XpNumber(ValidListfontsModesOids)
+};
+
+static XpOid DefaultListfontsModesOids[] = {
+ xpoid_val_xp_list_glyph_fonts
+};
+static XpOidList DefaultListfontsModes = {
+ DefaultListfontsModesOids, XpNumber(DefaultListfontsModesOids)
+};
+
+static XpOid ValidSetupProvisoOids[] = {
+ xpoid_val_xp_setup_mandatory, xpoid_val_xp_setup_optional
+};
+static XpOidList ValidSetupProviso = {
+
+
+ ValidSetupProvisoOids, XpNumber(ValidSetupProvisoOids)
+};
+
+static XpOidDocFmt ValidDocFormatsSupportedFmts[] = {
+ { "Postscript", "2", NULL }
+};
+static XpOidDocFmtList ValidDocFormatsSupported = {
+ ValidDocFormatsSupportedFmts, XpNumber(ValidDocFormatsSupportedFmts)
+};
+
+static XpOidDocFmt DefaultDocFormatsSupportedFmts[] = {
+ { "Postscript", "2", NULL }
+};
+static XpOidDocFmtList DefaultDocFormatsSupported = {
+ DefaultDocFormatsSupportedFmts, XpNumber(DefaultDocFormatsSupportedFmts)
+};
+
+static XpOidDocFmt ValidEmbeddedFormatsSupportedFmts[] = {
+ { "Postscript", "2", NULL }
+};
+static XpOidDocFmtList ValidEmbeddedFormatsSupported = {
+ ValidEmbeddedFormatsSupportedFmts, XpNumber(ValidEmbeddedFormatsSupportedFmts)
+};
+
+static XpOidDocFmt DefaultEmbeddedFormatsSupportedFmts[] = {
+ { "Postscript", "2", NULL }
+};
+static XpOidDocFmtList DefaultEmbeddedFormatsSupported = {
+ DefaultEmbeddedFormatsSupportedFmts, XpNumber(DefaultEmbeddedFormatsSupportedFmts)
+};
+
+static XpOidDocFmt ValidRawFormatsSupportedFmts[] = {
+ { "Postscript", "2", NULL }
+
+};
+static XpOidDocFmtList ValidRawFormatsSupported = {
+ ValidRawFormatsSupportedFmts, XpNumber(ValidRawFormatsSupportedFmts)
+};
+
+static XpOidDocFmt DefaultRawFormatsSupportedFmts[] = {
+ { "Postscript", "2", NULL }
+};
+static XpOidDocFmtList DefaultRawFormatsSupported = {
+ DefaultRawFormatsSupportedFmts, XpNumber(DefaultRawFormatsSupportedFmts)
+};
+
+static XpOid ValidInputTraysOids[] = {
+ xpoid_val_input_tray_manual,
+ xpoid_val_input_tray_main,
+ xpoid_val_input_tray_envelope,
+ xpoid_val_input_tray_large_capacity,
+ xpoid_val_input_tray_bottom
+};
+static XpOidList ValidInputTrays = {
+ ValidInputTraysOids, XpNumber(ValidInputTraysOids)
+};
+
+static XpOid ValidMediumSizesOids[] = {
+ xpoid_val_medium_size_iso_a0,
+ xpoid_val_medium_size_iso_a1,
+ xpoid_val_medium_size_iso_a2,
+ xpoid_val_medium_size_iso_a3,
+ xpoid_val_medium_size_iso_a4,
+ xpoid_val_medium_size_iso_a5,
+ xpoid_val_medium_size_iso_a6,
+ xpoid_val_medium_size_iso_a7,
+ xpoid_val_medium_size_iso_a8,
+ xpoid_val_medium_size_iso_a9,
+ xpoid_val_medium_size_iso_a10,
+ xpoid_val_medium_size_iso_b0,
+ xpoid_val_medium_size_iso_b1,
+ xpoid_val_medium_size_iso_b2,
+ xpoid_val_medium_size_iso_b3,
+ xpoid_val_medium_size_iso_b4,
+ xpoid_val_medium_size_iso_b5,
+ xpoid_val_medium_size_iso_b6,
+ xpoid_val_medium_size_iso_b7,
+ xpoid_val_medium_size_iso_b8,
+ xpoid_val_medium_size_iso_b9,
+ xpoid_val_medium_size_iso_b10,
+ xpoid_val_medium_size_na_letter,
+ xpoid_val_medium_size_na_legal,
+ xpoid_val_medium_size_executive,
+ xpoid_val_medium_size_folio,
+ xpoid_val_medium_size_invoice,
+ xpoid_val_medium_size_ledger,
+ xpoid_val_medium_size_quarto,
+ xpoid_val_medium_size_iso_c3,
+ xpoid_val_medium_size_iso_c4,
+ xpoid_val_medium_size_iso_c5,
+ xpoid_val_medium_size_iso_c6,
+ xpoid_val_medium_size_iso_designated_long,
+ xpoid_val_medium_size_na_10x13_envelope,
+ xpoid_val_medium_size_na_9x12_envelope,
+ xpoid_val_medium_size_na_number_10_envelope,
+ xpoid_val_medium_size_na_7x9_envelope,
+ xpoid_val_medium_size_na_9x11_envelope,
+ xpoid_val_medium_size_na_10x14_envelope,
+ xpoid_val_medium_size_na_number_9_envelope,
+ xpoid_val_medium_size_na_6x9_envelope,
+ xpoid_val_medium_size_na_10x15_envelope,
+ xpoid_val_medium_size_monarch_envelope,
+ xpoid_val_medium_size_a,
+ xpoid_val_medium_size_b,
+ xpoid_val_medium_size_c,
+ xpoid_val_medium_size_d,
+ xpoid_val_medium_size_e,
+ xpoid_val_medium_size_jis_b0,
+ xpoid_val_medium_size_jis_b1,
+ xpoid_val_medium_size_jis_b2,
+ xpoid_val_medium_size_jis_b3,
+ xpoid_val_medium_size_jis_b4,
+ xpoid_val_medium_size_jis_b5,
+ xpoid_val_medium_size_jis_b6,
+ xpoid_val_medium_size_jis_b7,
+ xpoid_val_medium_size_jis_b8,
+ xpoid_val_medium_size_jis_b9,
+ xpoid_val_medium_size_jis_b10,
+ xpoid_val_medium_size_hp_2x_postcard,
+ xpoid_val_medium_size_hp_european_edp,
+ xpoid_val_medium_size_hp_mini,
+ xpoid_val_medium_size_hp_postcard,
+ xpoid_val_medium_size_hp_tabloid,
+ xpoid_val_medium_size_hp_us_edp,
+ xpoid_val_medium_size_hp_us_government_legal,
+ xpoid_val_medium_size_hp_us_government_letter,
+};
+static XpOidList ValidMediumSizes = {
+ ValidMediumSizesOids, XpNumber(ValidMediumSizesOids)
+};
+
+static XpOidDocFmt DefaultDocumentFormat = {
+ "Postscript", "2", NULL
+};
+
+
+/*
+ * init struct for XpValidate*Pool
+ */
+XpValidatePoolsRec PsValidatePoolsRec = {
+ &ValidContentOrientations, &DefaultContentOrientations,
+ &ValidDocFormatsSupported, &DefaultDocFormatsSupported,
+ &ValidInputTrays, &ValidMediumSizes,
+ &ValidPlexes, &DefaultPlexes,
+ &ValidPrinterResolutions, &DefaultPrinterResolutions,
+ &ValidEmbeddedFormatsSupported, &DefaultEmbeddedFormatsSupported,
+ &ValidListfontsModes, &DefaultListfontsModes,
+ &ValidRawFormatsSupported, &DefaultRawFormatsSupported,
+ &ValidSetupProviso,
+ &DefaultDocumentFormat
+};
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsAttr.c b/nx-X11/programs/Xserver/Xprint/ps/PsAttr.c
new file mode 100644
index 000000000..74da5a0e1
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsAttr.c
@@ -0,0 +1,117 @@
+/* $Xorg: PsAttr.c,v 1.4 2001/02/09 02:04:35 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsAttr.c
+** *
+** * Contents: Attribute-handling functions for the PS driver
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Ps.h"
+#include "attributes.h"
+
+char *
+PsGetAttributes(
+ XpContextPtr pCon,
+ XPAttributes pool)
+{
+ return XpGetAttributes(pCon, pool);
+}
+
+char *
+PsGetOneAttribute(
+ XpContextPtr pCon,
+ XPAttributes pool,
+ char *attr)
+{
+ return XpGetOneAttribute(pCon, pool, attr);
+}
+
+int
+PsAugmentAttributes(
+ XpContextPtr pCon,
+ XPAttributes pool,
+ char *attrs)
+{
+ return XpAugmentAttributes(pCon, pool, attrs);
+}
+
+int
+PsSetAttributes(
+ XpContextPtr pCon,
+ XPAttributes pool,
+ char *attrs)
+{
+ return XpSetAttributes(pCon, pool, attrs);
+}
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsCache.c b/nx-X11/programs/Xserver/Xprint/ps/PsCache.c
new file mode 100644
index 000000000..e69aa2eb7
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsCache.c
@@ -0,0 +1,328 @@
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996, 2000 Sun Microsystems, Inc. All Rights Reserved.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsCache.c
+** *
+** * Contents: Character-caching routines
+** *
+** * Created By: Jay Hobson (Sun MicroSystems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Ps.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include <X11/fonts/fntfil.h>
+#include <X11/fonts/fntfilst.h>
+
+#define GET 0
+#define RESET 1
+
+struct bm_cache_list {
+ struct bm_cache_list *next;
+ struct bm_cache_list *prev;
+ int height;
+ long id;
+ char *pBuffer;
+};
+
+struct bm_cache_head {
+ struct bm_cache_list *head;
+ int width;
+ struct bm_cache_head *next;
+ struct bm_cache_head *prev;
+};
+
+static struct bm_cache_head *bm_cache = NULL;
+
+static long
+PsBmUniqueId(int func)
+{
+ static long unique_id = 0;
+
+ if(func == RESET)
+ {
+ unique_id = 0;
+ return 0;
+ }
+ else
+ return ++unique_id;
+}
+
+int
+PsBmIsImageCached(
+ int gWidth,
+ int gHeight,
+ char *pBuffer)
+{
+ int return_val = 0;
+ struct bm_cache_head *pList = bm_cache;
+
+ while(pList != NULL && !return_val)
+ {
+ if(pList->width == gWidth)
+ {
+ struct bm_cache_list *pItem = pList->head;
+
+ while(pItem != NULL)
+ {
+ if(pItem->height == gHeight)
+ {
+ int length = 4*(gWidth/32+(gWidth%32!=0))*gHeight;
+
+ if(!memcmp(pItem->pBuffer, pBuffer, sizeof(char)*length))
+ {
+ return_val = pItem->id;
+ break;
+ }
+ }
+ else if(pItem->height > gHeight)
+ break;
+
+ pItem = pItem->next;
+ }
+ }
+ else if(pList->width > gWidth)
+ break;
+
+ pList = pList->next;
+ }
+ return return_val;
+}
+
+int
+PsBmPutImageInCache(
+ int gWidth,
+ int gHeight,
+ char *pBuffer)
+{
+ int return_val = 0;
+ struct bm_cache_head *pList = bm_cache;
+ struct bm_cache_list *pNew;
+ int length = 4*(gWidth/32+(gWidth%32!=0))*gHeight;
+
+ if(gWidth == 1 && gHeight == 1 && pBuffer[0] == 0)
+ return return_val;
+
+ pNew = (struct bm_cache_list *)malloc(sizeof(struct bm_cache_list));
+ pNew->next = NULL;
+ pNew->prev = NULL;
+ pNew->height = gHeight;
+ pNew->id = PsBmUniqueId(GET);
+ pNew->pBuffer = (char *)malloc(sizeof(char)*length);
+
+ memcpy(pNew->pBuffer, pBuffer, length);
+
+ while(pList != NULL)
+ {
+ if(pList->width == gWidth)
+ {
+ struct bm_cache_list *pItem = pList->head;
+
+ while(pItem != NULL)
+ {
+ if(pItem->height >= gHeight)
+ {
+ pNew->next = pItem;
+ pNew->prev = pItem->prev;
+ if(pItem->prev != NULL)
+ pItem->prev->next = pNew;
+ else
+ pList->head = pNew;
+ pItem->prev = pNew;
+
+ return_val = pNew->id;
+
+ break;
+ }
+ else if(pItem->next == NULL)
+ {
+ pNew->prev = pItem;
+ pItem->next = pNew;
+
+ return_val = pNew->id;
+
+ break;
+ }
+
+ pItem = pItem->next;
+ }
+
+ break;
+ }
+
+ pList = pList->next;
+ }
+
+ if(pList == NULL)
+ {
+ struct bm_cache_head *pNewList;
+
+ pNewList = (struct bm_cache_head *)malloc(sizeof(struct bm_cache_head));
+
+ pNewList->next = NULL;
+ pNewList->prev = NULL;
+ pNewList->width = gWidth;
+ pNewList->head = pNew;
+
+ if(bm_cache == NULL)
+ {
+ bm_cache = pNewList;
+ return_val = pNew->id;
+ }
+ else
+ {
+ pList = bm_cache;
+
+ while(pList != NULL)
+ {
+ if(pList->width > gWidth)
+ {
+ pNewList->next = pList;
+ pNewList->prev = pList->prev;
+
+ if(pList->prev != NULL)
+ pList->prev->next = pNewList;
+ else
+ bm_cache = pNewList;
+ pList->prev = pNewList;
+
+ return_val = pNew->id;
+
+ break;
+ }
+ else if(pList->next == NULL)
+ {
+ pNewList->prev = pList;
+ pList->next = pNewList;
+
+ return_val = pNew->id;
+
+ break;
+ }
+
+ pList = pList->next;
+ }
+ }
+ }
+
+ return return_val;
+}
+
+
+static void
+PsBmClearImageCacheItem(
+ struct bm_cache_list *pItem)
+{
+ if(pItem != NULL)
+ {
+ if(pItem->pBuffer != NULL)
+ free(pItem->pBuffer);
+ pItem->pBuffer = NULL;
+
+ if(pItem->next)
+ PsBmClearImageCacheItem(pItem->next);
+ pItem->next = NULL;
+
+ free(pItem);
+ pItem = NULL;
+ }
+}
+
+static void
+PsBmClearImageCacheList(
+ struct bm_cache_head *pList)
+{
+ if(pList != NULL)
+ {
+ if(pList->head)
+ PsBmClearImageCacheItem(pList->head);
+ pList->head = NULL;
+
+ if(pList->next)
+ PsBmClearImageCacheList(pList->next);
+ pList->next = NULL;
+
+ free(pList);
+ pList = NULL;
+ }
+}
+
+void
+PsBmClearImageCache()
+{
+ PsBmClearImageCacheList(bm_cache);
+
+ bm_cache = NULL;
+
+ PsBmUniqueId(RESET);
+}
+
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsColor.c b/nx-X11/programs/Xserver/Xprint/ps/PsColor.c
new file mode 100644
index 000000000..91a44f85a
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsColor.c
@@ -0,0 +1,258 @@
+/* $Xorg: PsColor.c,v 1.4 2001/02/09 02:04:36 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsColor.c
+** *
+** * Contents: Color routines for the PS driver
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Ps.h"
+#include "mi.h"
+#include "micmap.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "colormapst.h"
+
+Bool
+PsCreateColormap(ColormapPtr pColor)
+{
+ return miInitializeColormap(pColor);
+}
+
+void
+PsDestroyColormap(ColormapPtr pColor)
+{
+ /* NO-OP */
+}
+
+void
+PsInstallColormap(ColormapPtr pColor)
+{
+ miInstallColormap(pColor);
+}
+
+void
+PsUninstallColormap(ColormapPtr pColor)
+{
+ miUninstallColormap(pColor);
+}
+
+int
+PsListInstalledColormaps(
+ ScreenPtr pScreen,
+ XID *pCmapList)
+{
+ return miListInstalledColormaps(pScreen, pCmapList);
+}
+
+void
+PsStoreColors(
+ ColormapPtr pColor,
+ int ndef,
+ xColorItem *pdefs)
+{
+ int i;
+ for( i=0 ; i<ndef ; i++ )
+ {
+ if( pdefs[i].flags&DoRed )
+ pColor->red[pdefs[i].pixel].co.local.red = pdefs[i].red;
+ if( pdefs[i].flags&DoGreen )
+ pColor->red[pdefs[i].pixel].co.local.green = pdefs[i].green;
+ if( pdefs[i].flags&DoBlue )
+ pColor->red[pdefs[i].pixel].co.local.blue = pdefs[i].blue;
+ }
+}
+
+void
+PsResolveColor(
+ unsigned short *pRed,
+ unsigned short *pGreen,
+ unsigned short *pBlue,
+ VisualPtr pVisual)
+{
+ miResolveColor(pRed, pGreen, pBlue, pVisual);
+}
+
+PsOutColor
+PsGetPixelColor(ColormapPtr cMap, int pixval)
+{
+ VisualPtr v = cMap->pVisual;
+ switch( v->class )
+ {
+ case TrueColor:
+ {
+ PsOutColor p = pixval;
+ PsOutColor r, g, b;
+
+ r = (p & v->redMask) >> v->offsetRed;
+ g = (p & v->greenMask) >> v->offsetGreen;
+ b = (p & v->blueMask) >> v->offsetBlue;
+
+ r = cMap->red[r].co.local.red;
+ g = cMap->green[g].co.local.green;
+ b = cMap->blue[b].co.local.blue;
+
+#ifdef PSOUT_USE_DEEPCOLOR
+ return((r<<32)|(g<<16)|b);
+#else
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+
+ return((r<<16)|(g<<8)|b);
+#endif /* PSOUT_USE_DEEPCOLOR */
+ }
+ case PseudoColor:
+ case GrayScale:
+ case StaticGray:
+ {
+ PsOutColor r, g, b;
+
+ if( pixval < 0 || pixval > v->ColormapEntries)
+ return(0);
+
+ r = cMap->red[pixval].co.local.red;
+ g = cMap->red[pixval].co.local.green;
+ b = cMap->red[pixval].co.local.blue;
+
+ if ((v->class | DynamicClass) == GrayScale)
+ {
+ /* rescale to gray (see |miResolveColor()|) */
+ r = g = b = (30L*r + 59L*g + 11L*b) / 100L;
+ }
+
+#ifdef PSOUT_USE_DEEPCOLOR
+ return((r<<32)|(g<<16)|b);
+#else
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+
+ return((r<<16)|(g<<8)|b);
+#endif /* PSOUT_USE_DEEPCOLOR */
+ }
+ default:
+ FatalError("PsGetPixelColor: Unsupported visual %x\n",
+ (int)cMap->pVisual->class);
+ break;
+ }
+
+ return 0; /* NO-OP*/
+}
+
+void
+PsSetFillColor(DrawablePtr pDrawable, GCPtr pGC, PsOutPtr psOut,
+ ColormapPtr cMap)
+{
+ switch(pGC->fillStyle)
+ {
+ case FillSolid:
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ break;
+ case FillTiled:
+ if( !PsOut_BeginPattern(psOut, pGC->tile.pixmap,
+ pGC->tile.pixmap->drawable.width,
+ pGC->tile.pixmap->drawable.height, PsTile, 0, 0) )
+ {
+ PsReplayPixmap(pGC->tile.pixmap, pDrawable);
+ PsOut_EndPattern(psOut);
+ }
+ PsOut_SetPattern(psOut, pGC->tile.pixmap, PsTile);
+ break;
+ case FillStippled:
+ if( !PsOut_BeginPattern(psOut, pGC->stipple,
+ pGC->stipple->drawable.width,
+ pGC->stipple->drawable.height, PsStip, 0,
+ PsGetPixelColor(cMap, pGC->fgPixel)) )
+ {
+ PsReplayPixmap(pGC->stipple, pDrawable);
+ PsOut_EndPattern(psOut);
+ }
+ PsOut_SetPattern(psOut, pGC->stipple, PsStip);
+ break;
+ case FillOpaqueStippled:
+ if( !PsOut_BeginPattern(psOut, pGC->stipple,
+ pGC->stipple->drawable.width,
+ pGC->stipple->drawable.height, PsOpStip,
+ PsGetPixelColor(cMap, pGC->bgPixel),
+ PsGetPixelColor(cMap, pGC->fgPixel)) )
+ {
+ PsReplayPixmap(pGC->stipple, pDrawable);
+ PsOut_EndPattern(psOut);
+ }
+ PsOut_SetPattern(psOut, pGC->stipple, PsOpStip);
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsDef.h b/nx-X11/programs/Xserver/Xprint/ps/PsDef.h
new file mode 100644
index 000000000..cf45c8516
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsDef.h
@@ -0,0 +1,97 @@
+/* $Xorg: PsDef.h,v 1.4 2001/02/09 02:04:36 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsDef.h
+** *
+** * Contents: extran defines and includes for the Ps driver
+** * for a printing X server.
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _PSDEF_H_
+#define _PSDEF_H_
+
+#define DT_PRINT_JOB_HEADER "DT_PRINT_JOB_HEADER"
+#define DT_PRINT_JOB_TRAILER "DT_PRINT_JOB_TRAILER"
+#define DT_PRINT_JOB_COMMAND "DT_PRINT_JOB_COMMAND"
+#define DT_PRINT_JOB_EXEC_COMMAND "DT_PRINT_JOB_EXEC_COMMAND"
+#define DT_PRINT_JOB_EXEC_OPTIONS "DT_PRINT_JOB_EXEC_OPTION"
+#define DT_PRINT_PAGE_HEADER "DT_PRINT_PAGE_HEADER"
+#define DT_PRINT_PAGE_TRAILER "DT_PRINT_PAGE_TRAILER"
+#define DT_PRINT_PAGE_COMMAND "DT_PRINT_PAGE_COMMAND"
+
+#define DT_IN_FILE_STRING "%(InFile)%"
+#define DT_OUT_FILE_STRING "%(OutFile)%"
+#define DT_ALLOWED_COMMANDS_FILE "printCommands"
+
+#endif /* _PSDEF_H_ */
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsFTFonts.c b/nx-X11/programs/Xserver/Xprint/ps/PsFTFonts.c
new file mode 100644
index 000000000..c992987d4
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsFTFonts.c
@@ -0,0 +1,85 @@
+
+/*
+Copyright (c) 2003-2004 Roland Mainz <roland.mainz@nrubsig.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <ctype.h>
+#include <limits.h>
+#include <sys/stat.h>
+
+#include "regionstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "scrnintstr.h"
+#include <X11/fonts/fontxlfd.h>
+#include <X11/fonts/fntfil.h>
+#include <X11/fonts/fntfilst.h>
+
+#include "Ps.h"
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+#include "ft.h"
+#define NOT_IN_FTFUNCS
+#include "ftfuncs.h"
+
+char *
+PsGetFTFontFileName(FontPtr pFont)
+{
+ FTFontPtr tf = (FTFontPtr)pFont->fontPrivate;
+ return tf->instance->face->filename;
+}
+
+Bool
+PsIsFreeTypeFont(FontPtr pFont)
+{
+ int i;
+ int nprops = pFont->info.nprops;
+ FontPropPtr props = pFont->info.props;
+ /* "RASTERIZER_NAME" must match the rasterizer name set in
+ * xc/lib/font/FreeType/ftfuncs.c */
+ Atom name = MakeAtom("RASTERIZER_NAME", 15, True);
+ Atom value = (Atom)0;
+ char *rv;
+
+ for( i=0 ; i<nprops ; i++ )
+ {
+ if( props[i].name==name )
+ { value = props[i].value; break; }
+ }
+ if( !value )
+ return False;
+
+ rv = NameForAtom(value);
+ if( !rv )
+ return False;
+
+ if( memcmp(rv, "FreeType", 8) == 0 )
+ return True;
+
+ return False;
+}
+
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsFonts.c b/nx-X11/programs/Xserver/Xprint/ps/PsFonts.c
new file mode 100644
index 000000000..515a31884
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsFonts.c
@@ -0,0 +1,876 @@
+/* $Xorg: PsFonts.c,v 1.6 2001/03/06 16:30:15 pookie Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsFonts.c
+** *
+** * Contents: Font code for PS driver.
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "regionstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "scrnintstr.h"
+#include <X11/fonts/fontxlfd.h>
+#include <X11/fonts/fntfil.h>
+#include <X11/fonts/fntfilst.h>
+
+#include "Ps.h"
+
+#include <ctype.h>
+#include <limits.h>
+#include <sys/stat.h>
+
+Bool
+PsRealizeFont(
+ ScreenPtr pscr,
+ FontPtr pFont)
+{
+ return TRUE;
+}
+
+Bool
+PsUnrealizeFont(
+ ScreenPtr pscr,
+ FontPtr pFont)
+{
+ return TRUE;
+}
+
+char *
+PsGetFontName(FontPtr pFont)
+{
+ int i;
+ int nprops = pFont->info.nprops;
+ FontPropPtr props = pFont->info.props;
+ Atom name = MakeAtom("FONT", 4, True);
+ Atom value = (Atom)0;
+
+ for( i=0 ; i<nprops ; i++ )
+ {
+ if( (Atom)props[i].name==name )
+ { value = props[i].value; break; }
+ }
+ if( !value ) return (char *)0;
+ return NameForAtom(value);
+}
+
+int
+PsGetFontSize(FontPtr pFont, float *mtx)
+{
+ FontScalableRec vals;
+ char *name = PsGetFontName(pFont);
+ int value = 0;
+
+ FontParseXLFDName(name, &vals, FONT_XLFD_REPLACE_NONE);
+ if( vals.values_supplied&PIXELSIZE_ARRAY )
+ {
+ int i;
+ for( i=0 ; i<4 ; i++ )
+ mtx[i] = (float)vals.pixel_matrix[i];
+ }
+ else
+ {
+ value = vals.pixel;
+ if( !value ) value = 20;
+ }
+ return value;
+}
+
+char *
+PsGetPSFontName(FontPtr pFont)
+{
+ int i;
+ int nprops = pFont->info.nprops;
+ FontPropPtr props = pFont->info.props;
+ /* "_ADOBE_POSTSCRIPT_FONTNAME" maps directly to a PMF OBJ_NAME attribute
+ * name - changing the name will break printer-builtin fonts. */
+ Atom name = MakeAtom("_ADOBE_POSTSCRIPT_FONTNAME", 26, True);
+ Atom value = (Atom)0;
+
+ for( i=0 ; i<nprops ; i++ )
+ {
+ if( (Atom)props[i].name==name )
+ { value = props[i].value; break; }
+ }
+ if( !value ) return (char *)0;
+ return NameForAtom(value);
+}
+
+int
+PsIsISOLatin1Encoding(FontPtr pFont)
+{
+ int i;
+ int nprops = pFont->info.nprops;
+ FontPropPtr props = pFont->info.props;
+ Atom reg = MakeAtom("CHARSET_REGISTRY", 16, True);
+ Atom enc = MakeAtom("CHARSET_ENCODING", 16, True);
+ Atom rv = 0, ev = 0;
+ char *rp = 0;
+ char *ep = 0;
+
+ for( i=0 ; i<nprops ; i++ )
+ {
+ if( (Atom)props[i].name==reg ) rv = props[i].value;
+ if( (Atom)props[i].name==enc ) ev = props[i].value;
+ }
+ if( rv ) rp = NameForAtom(rv);
+ if( ev ) ep = NameForAtom(ev);
+ if( (!rp) || (!ep) ) return(0);
+ if( (char)tolower(rp[0])!='i' ||
+ (char)tolower(rp[1])!='s' ||
+ (char)tolower(rp[2])!='o' ||
+ memcmp(&rp[3], "8859", 4)!=0 ||
+ ep[0]!='1' ) return(0);
+ return(1);
+}
+
+/* Return the encoding part of the XLFD (e.g. "*-iso8859-6.8x" etc.)*/
+char *PsGetEncodingName(FontPtr pFont)
+{
+ int i;
+ int nprops = pFont->info.nprops;
+ FontPropPtr props = pFont->info.props;
+ Atom fnt = MakeAtom("FONT", 4, True);
+ Atom reg = MakeAtom("CHARSET_REGISTRY", 16, True);
+ Atom enc = MakeAtom("CHARSET_ENCODING", 16, True);
+ Atom fv = 0, rv = 0, ev = 0;
+ char *fp = 0;
+ char *rp = 0;
+ char *ep = 0;
+ char *encname;
+
+ for( i=0 ; i<nprops ; i++ )
+ {
+ if( props[i].name==fnt ) fv = props[i].value;
+ if( props[i].name==reg ) rv = props[i].value;
+ if( props[i].name==enc ) ev = props[i].value;
+ }
+ if( fv ) fp = NameForAtom(fv);
+ if( rv ) rp = NameForAtom(rv);
+ if( ev ) ep = NameForAtom(ev);
+
+ if( (!rp) || (!ep) || (!fp))
+ return(0);
+
+ encname = fp;
+ encname += strlen(encname) - (strlen(rp) + strlen(ep) + 1);
+
+ return encname;
+}
+
+/* strstr(), case-insensitive */
+static
+char *str_case_str(const char *s, const char *find)
+{
+ size_t len;
+ char c,
+ sc;
+
+ if ((c = tolower(*find++)) != '\0')
+ {
+ len = strlen(find);
+ do
+ {
+ do
+ {
+ if ((sc = tolower(*s++)) == '\0')
+ return NULL;
+ } while (sc != c);
+ } while (strncasecmp(s, find, len) != 0);
+ s--;
+ }
+ return ((char *)s);
+}
+
+/* Check if the font path element is a directory which can be examined
+ * (for example the font may be from a font server
+ * (e.g. pFont->fpe->name == "tcp/:7100"))
+ */
+static
+Bool IsFPEaReadableDir(FontPtr pFont)
+{
+ const char *fpe_name = pFont->fpe->name;
+ if (!fpe_name)
+ return False;
+
+#define MODEL_FONTPATH_PREFIX "PRINTER:"
+#define MODEL_FONTPATH_PREFIX_LEN 8
+ /* Strip model-specific font path prefix if there is one... */
+ if (!strncmp(fpe_name, MODEL_FONTPATH_PREFIX, MODEL_FONTPATH_PREFIX_LEN))
+ fpe_name += MODEL_FONTPATH_PREFIX_LEN;
+
+ if (access(fpe_name, F_OK) == 0)
+ {
+ return True;
+ }
+
+ return False;
+}
+
+static
+char *getFontFilename(FontPtr pFont)
+{
+ FontDirectoryPtr dir;
+ const char *dlfnam;
+ FILE *file;
+ struct stat statb;
+ int count, i, status;
+ char buf[512];
+ char *front, *end, *fn;
+ char font_dir_fname[PATH_MAX], /* Full path of fonts.dir */
+ font_file_fname[PATH_MAX]; /* Name of font file (excluding path) */
+
+#ifdef XP_USE_FREETYPE
+ if( PsIsFreeTypeFont(pFont) )
+ {
+ const char *fontname = PsGetFTFontFileName(pFont);
+
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "getFontFilename: freetype font, file='%s'\n", fontname?fontname:"<NULL>");
+#endif /* DEBUG_gisburn */
+
+ if( !fontname )
+ return NULL;
+
+ return strdup(fontname);
+ }
+#endif /* XP_USE_FREETYPE */
+
+ if (!IsFPEaReadableDir(pFont))
+ {
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "getFontFilename: '%s' no valid font path on disk\n", pFont->fpe->name);
+#endif /* DEBUG_gisburn */
+ return NULL;
+ }
+
+ dir = pFont->fpe->private;
+ sprintf(font_dir_fname, "%s%s", dir->directory, "fonts.dir");
+
+ if (!(dlfnam = PsGetFontName(pFont)))
+ return NULL;
+
+ file = fopen(font_dir_fname, "r");
+ if (file)
+ {
+ if (fstat (fileno(file), &statb) == -1)
+ return NULL;
+
+ while( fgets(buf, sizeof(buf)-1, file) )
+ {
+ if ((fn = strstr(buf, " -")))
+ {
+ strcpy(font_file_fname, buf);
+ font_file_fname[fn - buf] = '\0';
+ fn++;
+ if ((front = str_case_str(fn, "normal-")))
+ {
+ fn[front - fn] = '\0';
+ if (str_case_str(dlfnam, fn))
+ {
+ char full_font_file_path[PATH_MAX];
+
+ fclose(file);
+
+ sprintf(full_font_file_path, "%s%s", dir->directory, font_file_fname);
+
+#ifdef xDEBUG_gisburn
+ fprintf(stderr, "getFontFilename: returning '%s'\n", full_font_file_path);
+#endif /* DEBUG_gisburn */
+ return strdup(full_font_file_path);
+ }
+ }
+ }
+ }
+ }
+ font_file_fname[0] = '\0';
+ fclose(file);
+
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "getFontFilename: returning NULL\n");
+#endif /* DEBUG_gisburn */
+
+ return NULL;
+}
+
+static
+PsFontTypeInfoRec *PsFindFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable);
+ PsFontTypeInfoRec *rec;
+ const char *psname;
+ char *font_filename;
+ char *encname;
+#ifdef XP_USE_FREETYPE
+ Bool is_freetypefont;
+#endif /* XP_USE_FREETYPE */
+
+#ifdef XP_USE_FREETYPE
+ is_freetypefont = PsIsFreeTypeFont(pFont);
+#endif /* XP_USE_FREETYPE */
+ encname = PsGetEncodingName(pFont);
+
+ /* First try: Search by PostScript font name */
+ psname = PsGetPSFontName(pFont);
+ if (psname)
+ {
+ for( rec = cPriv->fontTypeInfoRecords ; rec != NULL ; rec = rec->next )
+ {
+#ifdef XP_USE_FREETYPE
+ if (is_freetypefont)
+ {
+ if (rec->adobe_ps_name)
+ {
+ if ((rec->font_type == PSFTI_FONT_TYPE_FREETYPE) &&
+ (!strcmp(rec->adobe_ps_name, psname)) &&
+ (!strcmp(rec->ft_download_encoding, encname)))
+ {
+ return rec;
+ }
+ }
+ }
+ else
+#endif /* XP_USE_FREETYPE */
+ {
+ if (rec->adobe_ps_name)
+ {
+ if ((rec->font_type != PSFTI_FONT_TYPE_FREETYPE) &&
+ (!strcmp(rec->adobe_ps_name, psname)))
+ {
+ return rec;
+ }
+ }
+ }
+ }
+ }
+
+ /* Last attempt: Search by filename */
+ font_filename = getFontFilename(pFont);
+ if (font_filename)
+ {
+ for( rec = cPriv->fontTypeInfoRecords ; rec != NULL ; rec = rec->next )
+ {
+ if (rec->filename)
+ {
+#ifdef XP_USE_FREETYPE
+ if (is_freetypefont)
+ {
+ if ( (rec->font_type == PSFTI_FONT_TYPE_FREETYPE) &&
+ (!strcasecmp(rec->filename, font_filename)) &&
+ (!strcasecmp(rec->ft_download_encoding, encname)) )
+ {
+ free(font_filename);
+ return rec;
+ }
+ }
+ else
+#endif /* XP_USE_FREETYPE */
+ {
+ if ( (rec->font_type != PSFTI_FONT_TYPE_FREETYPE) &&
+ (!strcasecmp(rec->filename, font_filename)) )
+ {
+ free(font_filename);
+ return rec;
+ }
+ }
+ }
+ }
+
+ free(font_filename);
+ }
+
+ return NULL;
+}
+
+static
+void PsAddFontTypeInfoRec(DrawablePtr pDrawable, PsFontTypeInfoRec *add_rec)
+{
+ PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable);
+
+ /* ToDO: Always move the last used entry to the top that the list get's
+ * sorted in an efficient order... :-) */
+ add_rec->next = cPriv->fontTypeInfoRecords;
+ cPriv->fontTypeInfoRecords = add_rec;
+}
+
+static
+Bool strcaseendswith(const char *str, const char *suffix)
+{
+ const char *s;
+
+ s = str + strlen(str) - strlen(suffix);
+
+ if (!strcasecmp(s, suffix))
+ return True;
+
+ return False;
+}
+
+
+static
+int getFontFileType( const char *filename )
+{
+ int type;
+
+ /* Is this a Adobe PostScript Type 1 binary font (PFB) ? */
+ if( strcaseendswith(filename, ".pfb") )
+ {
+ type = PSFTI_FONT_TYPE_PS_TYPE1_PFB;
+ }
+ /* Is this a Adobe PostScript ASCII font (PFA) ? */
+ else if( strcaseendswith(filename, ".pfa") )
+ {
+ type = PSFTI_FONT_TYPE_PS_TYPE1_PFA;
+ }
+ /* Is this a PMF(=Printer Metrics File) ? */
+ else if( strcaseendswith(filename, ".pmf") )
+ {
+ type = PSFTI_FONT_TYPE_PMF;
+ }
+ /* Is this a TrueType font file ? */
+ else if( strcaseendswith(filename, ".ttf") ||
+ strcaseendswith(filename, ".ttc") ||
+ strcaseendswith(filename, ".otf") ||
+ strcaseendswith(filename, ".otc") )
+ {
+ type = PSFTI_FONT_TYPE_TRUETYPE;
+ }
+ else
+ {
+ type = PSFTI_FONT_TYPE_OTHER;
+ }
+
+#ifdef XP_USE_FREETYPE
+ {
+ XpContextPtr pCon;
+ char *downloadfonts;
+ pCon = XpGetPrintContext(requestingClient);
+ downloadfonts = XpGetOneAttribute(pCon, XPPrinterAttr, "xp-psddx-download-fonts");
+ if( downloadfonts )
+ {
+ /* Should we download PS Type1 fonts as PS Type1||Type3 ? */
+ if( (type == PSFTI_FONT_TYPE_PS_TYPE1_PFA) &&
+ (strstr(downloadfonts, "pfa") != NULL) )
+ {
+ type = PSFTI_FONT_TYPE_FREETYPE;
+ }
+
+ if( (type == PSFTI_FONT_TYPE_PS_TYPE1_PFB) &&
+ (strstr(downloadfonts, "pfb") != NULL) )
+ {
+ type = PSFTI_FONT_TYPE_FREETYPE;
+ }
+
+ /* Should we download TrueType fonts as PS Type1||Type3 ? */
+ if( (type == PSFTI_FONT_TYPE_TRUETYPE) &&
+ ((strstr(downloadfonts, "ttf") != NULL) ||
+ (strstr(downloadfonts, "ttc") != NULL) ||
+ (strstr(downloadfonts, "otf") != NULL) ||
+ (strstr(downloadfonts, "otc") != NULL)) )
+ {
+ type = PSFTI_FONT_TYPE_FREETYPE;
+ }
+ }
+ }
+#endif /* XP_USE_FREETYPE */
+
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "getFontFileType: '%s' is %d\n", filename, (int)type);
+#endif /* DEBUG_gisburn */
+ return type;
+}
+
+PsFTDownloadFontType PsGetFTDownloadFontType(void)
+{
+ PsFTDownloadFontType downloadfonttype;
+ XpContextPtr pCon;
+ char *psfonttype;
+
+ pCon = XpGetPrintContext(requestingClient);
+ psfonttype = XpGetOneAttribute(pCon, XPPrinterAttr, "xp-psddx-download-font-type");
+
+ if( !psfonttype || !strlen(psfonttype) )
+ {
+ return PsFontType1; /* Default download font type is PS Type1 */
+ }
+
+ if( !strcmp(psfonttype, "bitmap") )
+ {
+ downloadfonttype = PsFontBitmap;
+ }
+ else if( !strcmp(psfonttype, "pstype3") )
+ {
+ downloadfonttype = PsFontType3;
+ }
+ else if( !strcmp(psfonttype, "pstype1") )
+ {
+ downloadfonttype = PsFontType1;
+ }
+ else
+ {
+ FatalError("PS DDX: XPPrinterAttr/xp-psddx-download-freetype-font-type='%s' not implemented\n", psfonttype);
+ return 0; /* NO-OP, FatalError() will call |exit()| */
+ }
+
+ return downloadfonttype;
+}
+
+static
+PsFontTypeInfoRec *PsCreateFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ char *dlfnam;
+ PsFontTypeInfoRec *rec;
+ char *psname;
+
+ if (!(dlfnam = PsGetFontName(pFont)))
+ return NULL;
+
+ if (!(rec = (PsFontTypeInfoRec *)xalloc(sizeof(PsFontTypeInfoRec))))
+ return NULL;
+ memset(rec, 0, sizeof(PsFontTypeInfoRec));
+
+ rec->next = NULL;
+
+ if ((rec->filename = getFontFilename(pFont)))
+ {
+ rec->font_type = getFontFileType(rec->filename);
+ }
+ else
+ {
+ rec->filename = NULL;
+ rec->font_type = PSFTI_FONT_TYPE_OTHER;
+ }
+
+ rec->adobe_ps_name = PsGetPSFontName(pFont);
+#ifdef XP_USE_FREETYPE
+ rec->ft_download_encoding = PsGetEncodingName(pFont);
+ rec->ft_download_font_type = PsGetFTDownloadFontType();
+#endif /* XP_USE_FREETYPE */
+ rec->download_ps_name = NULL;
+
+#define SET_FONT_DOWNLOAD_STATUS(rec, downloaded) { int i; for (i = 0 ; i < 256 ; i++) { (rec)->alreadyDownloaded[i]=(downloaded); } }
+
+ /* Set some flags based on the font type */
+ switch( rec->font_type )
+ {
+ case PSFTI_FONT_TYPE_PS_TYPE1_PFA:
+ case PSFTI_FONT_TYPE_PS_TYPE1_PFB:
+ rec->downloadableFont = True;
+ SET_FONT_DOWNLOAD_STATUS(rec, False);
+ rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont);
+ break;
+
+ case PSFTI_FONT_TYPE_PMF:
+ rec->downloadableFont = True; /* This font is in printer's ROM */
+ SET_FONT_DOWNLOAD_STATUS(rec, True);
+ rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont);
+ break;
+
+ case PSFTI_FONT_TYPE_TRUETYPE:
+ /* Note: TrueType font download not implemented */
+ rec->downloadableFont = False;
+ SET_FONT_DOWNLOAD_STATUS(rec, False);
+ rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont);
+ break;
+
+#ifdef XP_USE_FREETYPE
+ case PSFTI_FONT_TYPE_FREETYPE:
+ if( rec->ft_download_font_type == PsFontType1 ||
+ rec->ft_download_font_type == PsFontType3 )
+ {
+ rec->downloadableFont = True;
+ }
+ else
+ {
+ rec->downloadableFont = False;
+ }
+
+ SET_FONT_DOWNLOAD_STATUS(rec, False);
+ rec->is_iso_encoding = False; /* Freetype--->PS Type1/Type3 uses always non-iso PS encoding for now */
+ break;
+#endif /* XP_USE_FREETYPE */
+
+ case PSFTI_FONT_TYPE_OTHER:
+ default:
+ rec->downloadableFont = False;
+ SET_FONT_DOWNLOAD_STATUS(rec, False);
+ rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont);
+ break;
+ }
+
+#ifdef XP_USE_FREETYPE
+ if( (rec->font_type == PSFTI_FONT_TYPE_FREETYPE) )
+ {
+ char *s;
+ register int c;
+
+ if( rec->adobe_ps_name )
+ {
+ rec->download_ps_name = malloc(strlen(rec->adobe_ps_name) + strlen(rec->ft_download_encoding) + 2);
+ sprintf(rec->download_ps_name, "%s_%s", rec->adobe_ps_name, rec->ft_download_encoding);
+ }
+ else
+ {
+ /* Unfortunately not all TTF fonts have a PostScript font name (like
+ * Solaris TTF fonts in /usr/openwin/lib/locale/ko.UTF-8/X11/fonts/TrueType,
+ * /usr/openwin/lib/locale/ko/X11/fonts/TrueType) - in this case we
+ * have to generate a font name
+ */
+ char ftfontname[64];
+ static long myfontindex = 0L;
+ sprintf(ftfontname, "psfont_%lx", myfontindex++);
+
+ rec->download_ps_name = malloc(strlen(ftfontname) + strlen(rec->ft_download_encoding) + 2);
+ sprintf(rec->download_ps_name, "%s_%s", ftfontname, rec->ft_download_encoding);
+
+ fprintf(stderr, "PsCreateFontTypeInfoRec: Note: '%s' has no PS font name, using '%s' for now.\n", dlfnam, rec->download_ps_name);
+ }
+
+ /* Make sure the font name we use for download is a valid PS font name */
+ for( s = rec->download_ps_name ; *s != '\0'; s++ )
+ {
+ c = *s;
+
+ /* Check for allowed chars, invalid ones are replaced with a '_'
+ * (and check that the first char is not a digit) */
+ if( !(isalnum(c) || c == '.' || c == '_' || c == '-') || (s==rec->download_ps_name && isdigit(c)) )
+ {
+ *s = '_';
+ }
+ }
+ }
+ else
+#endif /* XP_USE_FREETYPE */
+ {
+ if( rec->adobe_ps_name )
+ {
+ rec->download_ps_name = strdup(rec->adobe_ps_name);
+ }
+ else
+ {
+ rec->download_ps_name = NULL;
+ }
+ }
+
+ /* Safeguard - only treat font as downloadable when we have a PS font name!! */
+ if (!rec->download_ps_name && rec->downloadableFont)
+ {
+ /* XXX: Log this message to the log when the logging service has been hook'ed up */
+ fprintf(stderr, "PsCreateFontTypeInfoRec: Safeguard: No PS font name for '%s'!\n", dlfnam);
+ rec->downloadableFont = False;
+ }
+
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "PsCreateFontTypeInfoRec: Created PsFontTypeInfoRec '%s' ('%s'/'%s')\n",
+ ((rec->filename) ?(rec->filename) :("<null>")),
+ ((rec->adobe_ps_name) ?(rec->adobe_ps_name):("<null>")),
+ ((rec->download_ps_name)?(rec->download_ps_name):("<null>")));
+#endif /* DEBUG_gisburn */
+
+ return rec;
+}
+
+static
+PsFontTypeInfoRec *PsGetFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ PsFontTypeInfoRec *rec;
+ char *dlfnam;
+
+ if(!(dlfnam = PsGetFontName(pFont)))
+ return NULL;
+
+ rec = PsFindFontTypeInfoRec(pDrawable, pFont);
+ if (rec)
+ return rec;
+
+ rec = PsCreateFontTypeInfoRec(pDrawable, pFont);
+ if (!rec)
+ return NULL;
+
+ PsAddFontTypeInfoRec(pDrawable, rec);
+
+ return rec;
+}
+
+static
+void PsFreeFontTypeInfoRecords( PsContextPrivPtr priv )
+{
+ PsFontTypeInfoRec *curr, *next;
+ curr = priv->fontTypeInfoRecords;
+ while( curr != NULL )
+ {
+ if (curr->filename)
+ free(curr->filename); /* Free memory allocated by |strdup()| */
+
+ if (curr->download_ps_name)
+ free(curr->download_ps_name);
+
+ next = curr->next;
+ xfree(curr);
+ curr = next;
+ }
+}
+
+static
+PsFontInfoRec *PsFindFontInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable);
+ PsFontInfoRec *rec;
+
+ if (!pFont)
+ return NULL;
+
+ for( rec = cPriv->fontInfoRecords ; rec != NULL ; rec = rec->next )
+ {
+ if ((rec->font == pFont) &&
+ (rec->font_fontPrivate == pFont->fontPrivate))
+ return rec;
+ }
+
+ return NULL;
+}
+
+static
+void PsAddFontInfoRec(DrawablePtr pDrawable, PsFontInfoRec *add_rec)
+{
+ PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable);
+
+ /* ToDO: Always move the last used entry to the top that the list get's
+ * sorted in an efficient order... :-) */
+ add_rec->next = cPriv->fontInfoRecords;
+ cPriv->fontInfoRecords = add_rec;
+}
+
+static
+PsFontInfoRec *PsCreateFontInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ PsFontInfoRec *rec;
+ PsFontTypeInfoRec *ftir;
+
+ if (!(ftir = PsGetFontTypeInfoRec(pDrawable, pFont)))
+ return NULL;
+
+ if (!(rec = (PsFontInfoRec *)xalloc(sizeof(PsFontInfoRec))))
+ return NULL;
+ memset(rec, 0, sizeof(PsFontInfoRec));
+
+ rec->font = pFont;
+ rec->font_fontPrivate = pFont->fontPrivate;
+ rec->ftir = ftir;
+ rec->next = NULL;
+ rec->dfl_name = PsGetFontName(pFont);
+ rec->size = PsGetFontSize(pFont, rec->mtx);
+
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "PsCreateFontInfoRec: Created PsFontInfoRec '%s'\n",
+ ((rec->dfl_name)?(rec->dfl_name):("<null>")));
+#endif /* DEBUG_gisburn */
+
+ return rec;
+}
+
+PsFontInfoRec *PsGetFontInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ PsFontInfoRec *rec;
+
+ rec = PsFindFontInfoRec(pDrawable, pFont);
+ if (rec)
+ return rec;
+
+ rec = PsCreateFontInfoRec(pDrawable, pFont);
+ if (!rec)
+ return NULL;
+
+ PsAddFontInfoRec(pDrawable, rec);
+
+ return rec;
+}
+
+void PsFreeFontInfoRecords( PsContextPrivPtr priv )
+{
+ PsFontInfoRec *curr, *next;
+ curr = priv->fontInfoRecords;
+ while( curr != NULL )
+ {
+ next = curr->next;
+ xfree(curr);
+ curr = next;
+ }
+
+ PsFreeFontTypeInfoRecords(priv);
+
+ priv->fontTypeInfoRecords = NULL;
+ priv->fontInfoRecords = NULL;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsGC.c b/nx-X11/programs/Xserver/Xprint/ps/PsGC.c
new file mode 100644
index 000000000..56ff5cdae
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsGC.c
@@ -0,0 +1,419 @@
+/* $Xorg: PsGC.c,v 1.4 2001/02/09 02:04:36 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsGC.c
+** *
+** * Contents: Graphics Context handling for the PS driver
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Ps.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "migc.h"
+#include "scrnintstr.h"
+
+static GCOps PsGCOps =
+{
+ PsFillSpans,
+ PsSetSpans,
+ PsPutImage,
+ PsCopyArea,
+ PsCopyPlane,
+ PsPolyPoint,
+ PsPolyLine,
+ PsPolySegment,
+ PsPolyRectangle,
+ PsPolyArc,
+ PsFillPolygon,
+ PsPolyFillRect,
+ PsPolyFillArc,
+ PsPolyText8,
+ PsPolyText16,
+ PsImageText8,
+ PsImageText16,
+ PsImageGlyphBlt,
+ PsPolyGlyphBlt,
+ PsPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+
+static GCFuncs PsGCFuncs =
+{
+ PsValidateGC,
+ PsChangeGC,
+ PsCopyGC,
+ PsDestroyGC,
+ PsChangeClip,
+ PsDestroyClip,
+ PsCopyClip
+};
+
+Bool
+PsCreateGC(pGC)
+ GCPtr pGC;
+{
+ pGC->clientClip = NULL;
+ pGC->clientClipType = CT_NONE;
+
+ pGC->ops = &PsGCOps;
+ pGC->funcs = &PsGCFuncs;
+
+ pGC->clientClip = (pointer)xalloc(sizeof(PsClipRec));
+ memset(pGC->clientClip, 0, sizeof(PsClipRec));
+ return TRUE;
+}
+
+static int
+PsGetDrawablePrivateStuff(
+ DrawablePtr pDrawable,
+ GC *gc,
+ unsigned long *valid,
+ PsOutPtr *psOut,
+ ColormapPtr *cMap)
+{
+ XpContextPtr pCon;
+ PsContextPrivPtr cPriv;
+ PsScreenPrivPtr sPriv;
+
+ switch(pDrawable->type)
+ {
+ case DRAWABLE_PIXMAP:
+ return FALSE;
+ case DRAWABLE_WINDOW:
+ pCon = PsGetContextFromWindow((WindowPtr)pDrawable);
+ if( pCon==NULL ) return FALSE;
+ else
+ {
+ Colormap c;
+ ColormapPtr cmap;
+
+ c = wColormap((WindowPtr)pDrawable);
+ cmap = (ColormapPtr)LookupIDByType(c, RT_COLORMAP);
+
+ cPriv = pCon->devPrivates[PsContextPrivateIndex].ptr;
+ sPriv = (PsScreenPrivPtr)
+ pDrawable->pScreen->devPrivates[PsScreenPrivateIndex].ptr;
+ *gc = cPriv->lastGC;
+ *valid = cPriv->validGC;
+ *psOut = cPriv->pPsOut;
+ *cMap = cmap;
+ return TRUE;
+ }
+ default:
+ return FALSE;
+ }
+}
+
+PsContextPrivPtr
+PsGetPsContextPriv( DrawablePtr pDrawable )
+{
+ XpContextPtr pCon;
+ PsContextPrivPtr cPriv;
+
+ switch(pDrawable->type)
+ {
+ case DRAWABLE_PIXMAP:
+ return FALSE;
+ case DRAWABLE_WINDOW:
+ pCon = PsGetContextFromWindow((WindowPtr)pDrawable);
+ if (pCon != NULL)
+ {
+ return pCon->devPrivates[PsContextPrivateIndex].ptr;
+ }
+ }
+ return NULL;
+}
+
+int
+PsUpdateDrawableGC(
+ GCPtr pGC,
+ DrawablePtr pDrawable,
+ PsOutPtr *psOut,
+ ColormapPtr *cMap)
+{
+ GC dGC;
+ unsigned long valid;
+ int i;
+ PsContextPrivPtr cPriv;
+ BoxPtr boxes;
+
+ if (!PsGetDrawablePrivateStuff(pDrawable, &dGC, &valid, psOut, cMap))
+ return FALSE;
+
+ switch (pDrawable->type) {
+
+ case DRAWABLE_PIXMAP:
+ /* we don't support pixmaps yet! */
+ return FALSE;
+ break;
+ case DRAWABLE_WINDOW:
+ if( pGC )
+ {
+ RegionPtr pReg;
+ WindowPtr pWin = (WindowPtr)pDrawable;
+ Bool freeClip;
+ PsClipPtr clp = (PsClipPtr)pGC->clientClip;
+ if( clp->outterClips )
+ { xfree(clp->outterClips); clp->outterClips = 0; }
+ clp->nOutterClips = 0;
+ if( pGC->subWindowMode==IncludeInferiors )
+ {
+ pReg = NotClippedByChildren(pWin);
+ freeClip = TRUE;
+ }
+ else
+ {
+ pReg = &pWin->clipList;
+ freeClip = FALSE;
+ }
+
+ if( pReg->data )
+ {
+ boxes = (BoxPtr)((char *)pReg->data+sizeof(long)*2);
+ clp->nOutterClips = pReg->data->numRects;
+ clp->outterClips =
+ (PsRectPtr)xalloc(clp->nOutterClips*sizeof(PsRectRec));
+ for( i=0 ; i<clp->nOutterClips ; i++ )
+ {
+ clp->outterClips[i].x = boxes[i].x1;
+ clp->outterClips[i].y = boxes[i].y1;
+ clp->outterClips[i].w = (boxes[i].x2-boxes[i].x1)+1;
+ clp->outterClips[i].h = (boxes[i].y2-boxes[i].y1)+1;
+ }
+ }
+
+ if( freeClip ) REGION_DESTROY(pGC->pScreen, pReg);
+ PsOut_Offset(*psOut, pDrawable->x, pDrawable->y);
+ PsOut_Clip(*psOut, pGC->clientClipType, (PsClipPtr)pGC->clientClip);
+ }
+ cPriv = ( PsGetContextFromWindow( (WindowPtr)pDrawable ) )
+ ->devPrivates[PsContextPrivateIndex].ptr;
+ break;
+ }
+ return TRUE;
+}
+
+void
+PsValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
+{
+ pGC->ops = &PsGCOps;
+}
+
+void
+PsChangeGC(GCPtr pGC, unsigned long changes)
+{
+}
+
+void
+PsCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
+{
+}
+
+void
+PsDestroyGC(GCPtr pGC)
+{
+ PsDestroyClip(pGC);
+ xfree(pGC->clientClip);
+}
+
+void
+PsChangeClip(GCPtr pGC, int type, pointer pValue, int nrects)
+{
+ int i;
+ PsClipPtr clp = (PsClipPtr)pGC->clientClip;
+ RegionPtr rgn;
+ BoxPtr boxes;
+ xRectangle *rects;
+
+ PsDestroyClip(pGC);
+ pGC->clientClipType = type;
+ switch(type)
+ {
+ case CT_NONE: break;
+ case CT_PIXMAP:
+ clp->elms = PsCreateFillElementList((PixmapPtr)pValue, &clp->nElms);
+ (*pGC->pScreen->DestroyPixmap)((PixmapPtr)pValue);
+ break;
+ case CT_REGION:
+ rgn = (RegionPtr)pValue;
+ boxes = (BoxPtr)((char *)rgn->data+sizeof(long)*2);
+ clp->nRects = rgn->data->numRects;
+ clp->rects = (PsRectPtr)xalloc(clp->nRects*sizeof(PsRectRec));
+ for( i=0 ; i<clp->nRects ; i++ )
+ {
+ clp->rects[i].x = boxes[i].x1;
+ clp->rects[i].y = boxes[i].y1;
+ clp->rects[i].w = (boxes[i].x2-boxes[i].x1)+1;
+ clp->rects[i].h = (boxes[i].y2-boxes[i].y1)+1;
+ }
+ REGION_DESTROY(pGC->pScreen, (RegionPtr)pValue);
+ break;
+ case CT_UNSORTED:
+ case CT_YSORTED:
+ case CT_YXSORTED:
+ case CT_YXBANDED:
+ rects = (xRectangle *)pValue;
+ clp->nRects = nrects;
+ clp->rects = (PsRectPtr)xalloc(clp->nRects*sizeof(PsRectRec));
+ for( i=0 ; i<clp->nRects ; i++ )
+ {
+ clp->rects[i].x = rects[i].x;
+ clp->rects[i].y = rects[i].y;
+ clp->rects[i].w = rects[i].width;
+ clp->rects[i].h = rects[i].height;
+ }
+ xfree(pValue);
+ break;
+ }
+}
+
+void
+PsDestroyClip(GCPtr pGC)
+{
+ PsClipPtr clp = (PsClipPtr)pGC->clientClip;
+
+ if( clp->rects ) xfree(clp->rects);
+ if( clp->outterClips ) xfree(clp->outterClips);
+ clp->rects = (PsRectPtr)0;
+ clp->outterClips = (PsRectPtr)0;
+ clp->nRects = 0;
+ clp->nOutterClips = 0;
+ if( clp->elms ) PsDestroyFillElementList(clp->nElms, clp->elms);
+ clp->elms = (PsElmPtr)0;
+ clp->nElms = 0;
+ pGC->clientClipType = CT_NONE;
+}
+
+void
+PsCopyClip(GCPtr pDst, GCPtr pSrc)
+{
+ PsClipPtr src = (PsClipPtr)pSrc->clientClip;
+ PsClipPtr dst = (PsClipPtr)pDst->clientClip;
+
+ PsDestroyClip(pDst);
+ pDst->clientClipType = pSrc->clientClipType;
+ *dst = *src;
+ if( src->rects )
+ {
+ dst->rects = (PsRectPtr)xalloc(src->nRects*sizeof(PsRectRec));
+ memcpy(dst->rects, src->rects, src->nRects*sizeof(PsRectRec));
+ }
+ if( src->elms )
+ dst->elms = PsCloneFillElementList(src->nElms, src->elms);
+}
+
+
+GCPtr
+PsCreateAndCopyGC(DrawablePtr pDrawable, GCPtr pSrc)
+{
+ GCPtr pDst;
+
+ if (pSrc == NULL) {
+ /* https://freedesktop.org/bugzilla/show_bug.cgi?id=1416 ("'x11perf
+ * -copypixpix500' crashes Xprt's PostScript DDX [PsCreateAndCopyGC"):
+ * I have no clue whether this is the real fix or just wallpapering
+ * over the crash (that's why we warn here loudly when this
+ * happens) ... */
+ fprintf(stderr, "PsCreateAndCopyGC: pSrc == NULL\n");
+ return NULL;
+ }
+
+ if ((pDst =
+ CreateScratchGC(pDrawable->pScreen, pDrawable->depth)) == NULL)
+ {
+ return NULL;
+ }
+
+ if (CopyGC(pSrc, pDst,
+ GCFunction | GCPlaneMask | GCForeground | GCBackground |
+ GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle |
+ GCFillStyle | GCFillRule | GCTile | GCStipple |
+ GCTileStipXOrigin | GCTileStipYOrigin | GCFont |
+ GCSubwindowMode | GCGraphicsExposures | GCClipXOrigin |
+ GCClipYOrigin | GCClipMask | GCDashOffset | GCDashList |
+ GCArcMode) != Success)
+ {
+ (void)FreeGC(pDst, (GContext)0);
+
+ return NULL;
+ }
+
+ return pDst;
+}
+
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsImageUtil.c b/nx-X11/programs/Xserver/Xprint/ps/PsImageUtil.c
new file mode 100644
index 000000000..282786564
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsImageUtil.c
@@ -0,0 +1,329 @@
+
+/* $Xorg: PsImageUtil.c,v 1.1 2005/03/25 1:19:56 gisburn Exp $ */
+/*
+Copyright (c) 2005 Roland Mainz <roland.mainz@nrubsig.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+/* Please do not beat me for this ugly code - most of it has been stolen from
+ * xc/lib/X11/ImUtil.c */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "servermd.h"
+#include "attributes.h"
+
+static unsigned char const _reverse_byte[0x100] = {
+ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+ 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+ 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+ 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+ 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+ 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+ 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+ 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+ 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+ 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+ 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+ 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+ 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+ 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+ 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+ 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+ 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+ 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+ 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+ 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+ 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+ 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+ 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+ 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+ 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+ 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+ 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+ 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+ 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+ 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+ 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+ 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
+};
+
+static
+int XReverse_Bytes(
+ register unsigned char *bpt,
+ register int nb)
+{
+ do {
+ *bpt = _reverse_byte[*bpt];
+ bpt++;
+ } while (--nb > 0);
+ return 0;
+}
+
+/*
+ * Data structure for "image" data, used by image manipulation routines.
+ */
+typedef struct {
+ int width, height; /* size of image */
+ int xoffset; /* number of pixels offset in X direction */
+ int format; /* XYBitmap, XYPixmap, ZPixmap */
+ char *data; /* pointer to image data */
+ int byte_order; /* data byte order, LSBFirst, MSBFirst */
+ int bitmap_unit; /* quant. of scanline 8, 16, 32 */
+ int bitmap_bit_order; /* LSBFirst, MSBFirst */
+ int depth; /* depth of image */
+ int bytes_per_line; /* accelarator to next line */
+ int bits_per_pixel; /* bits per pixel (ZPixmap) */
+} TmpImage;
+
+
+static void xynormalizeimagebits (
+ register unsigned char *bp,
+ register TmpImage *img)
+{
+ register unsigned char c;
+
+ if (img->byte_order != img->bitmap_bit_order) {
+ switch (img->bitmap_unit) {
+
+ case 16:
+ c = *bp;
+ *bp = *(bp + 1);
+ *(bp + 1) = c;
+ break;
+
+ case 32:
+ c = *(bp + 3);
+ *(bp + 3) = *bp;
+ *bp = c;
+ c = *(bp + 2);
+ *(bp + 2) = *(bp + 1);
+ *(bp + 1) = c;
+ break;
+ }
+ }
+ if (img->bitmap_bit_order == MSBFirst)
+ XReverse_Bytes (bp, img->bitmap_unit >> 3);
+}
+
+static void znormalizeimagebits (
+ register unsigned char *bp,
+ register TmpImage *img)
+{
+ register unsigned char c;
+ switch (img->bits_per_pixel) {
+
+ case 4:
+ *bp = ((*bp >> 4) & 0xF) | ((*bp << 4) & ~0xF);
+ break;
+
+ case 16:
+ c = *bp;
+ *bp = *(bp + 1);
+ *(bp + 1) = c;
+ break;
+
+ case 24:
+ c = *(bp + 2);
+ *(bp + 2) = *bp;
+ *bp = c;
+ break;
+
+ case 32:
+ c = *(bp + 3);
+ *(bp + 3) = *bp;
+ *bp = c;
+ c = *(bp + 2);
+ *(bp + 2) = *(bp + 1);
+ *(bp + 1) = c;
+ break;
+ }
+}
+
+/*
+ * Macros
+ *
+ * The ROUNDUP macro rounds up a quantity to the specified boundary,
+ * then truncates to bytes.
+ *
+ * The XYNORMALIZE macro determines whether XY format data requires
+ * normalization and calls a routine to do so if needed. The logic in
+ * this module is designed for LSBFirst byte and bit order, so
+ * normalization is done as required to present the data in this order.
+ *
+ * The ZNORMALIZE macro performs byte and nibble order normalization if
+ * required for Z format data.
+ *
+ * The XYINDEX macro computes the index to the starting byte (char) boundary
+ * for a bitmap_unit containing a pixel with coordinates x and y for image
+ * data in XY format.
+ *
+ * The ZINDEX macro computes the index to the starting byte (char) boundary
+ * for a pixel with coordinates x and y for image data in ZPixmap format.
+ *
+ */
+
+#if defined(Lynx) && defined(ROUNDUP)
+#undef ROUNDUP
+#endif
+
+#define ROUNDUP(nbytes, pad) ((((nbytes) + ((pad)-1)) / (pad)) * ((pad)>>3))
+
+#define XYNORMALIZE(bp, img) \
+ if ((img->byte_order == MSBFirst) || (img->bitmap_bit_order == MSBFirst)) \
+ xynormalizeimagebits((unsigned char *)(bp), img)
+
+#define ZNORMALIZE(bp, img) \
+ if (img->byte_order == MSBFirst) \
+ znormalizeimagebits((unsigned char *)(bp), img)
+
+#define XYINDEX(x, y, img) \
+ ((y) * img->bytes_per_line) + \
+ (((x) + img->xoffset) / img->bitmap_unit) * (img->bitmap_unit >> 3)
+
+#define ZINDEX(x, y, img) ((y) * img->bytes_per_line) + \
+ (((x) * img->bits_per_pixel) >> 3)
+
+/*
+ * GetPixel
+ *
+ * Returns the specified pixel. The X and Y coordinates are relative to
+ * the origin (upper left [0,0]) of the image. The pixel value is returned
+ * in normalized format, i.e. the LSB of the long is the LSB of the pixel.
+ * The algorithm used is:
+ *
+ * copy the source bitmap_unit or Zpixel into temp
+ * normalize temp if needed
+ * extract the pixel bits into return value
+ *
+ */
+
+static unsigned long const low_bits_table[] = {
+ 0x00000000, 0x00000001, 0x00000003, 0x00000007,
+ 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
+ 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
+ 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
+ 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
+ 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
+ 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
+ 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
+ 0xffffffff
+};
+
+static unsigned long XGetPixel (TmpImage *ximage, int x, int y)
+{
+ unsigned long pixel, px;
+ register char *src;
+ register char *dst;
+ register int i, j;
+ int bits, nbytes;
+ long plane;
+
+ if ((ximage->bits_per_pixel | ximage->depth) == 1) {
+ src = &ximage->data[XYINDEX(x, y, ximage)];
+ dst = (char *)&pixel;
+ pixel = 0;
+ for (i = ximage->bitmap_unit >> 3; --i >= 0; ) *dst++ = *src++;
+ XYNORMALIZE(&pixel, ximage);
+ bits = (x + ximage->xoffset) % ximage->bitmap_unit;
+ pixel = ((((char *)&pixel)[bits>>3])>>(bits&7)) & 1;
+ } else if (ximage->format == XYPixmap) {
+ pixel = 0;
+ plane = 0;
+ nbytes = ximage->bitmap_unit >> 3;
+ for (i = ximage->depth; --i >= 0; ) {
+ src = &ximage->data[XYINDEX(x, y, ximage)+ plane];
+ dst = (char *)&px;
+ px = 0;
+ for (j = nbytes; --j >= 0; ) *dst++ = *src++;
+ XYNORMALIZE(&px, ximage);
+ bits = (x + ximage->xoffset) % ximage->bitmap_unit;
+ pixel = (pixel << 1) |
+ (((((char *)&px)[bits>>3])>>(bits&7)) & 1);
+ plane = plane + (ximage->bytes_per_line * ximage->height);
+ }
+ } else if (ximage->format == ZPixmap) {
+ src = &ximage->data[ZINDEX(x, y, ximage)];
+ dst = (char *)&px;
+ px = 0;
+ for (i = (ximage->bits_per_pixel + 7) >> 3; --i >= 0; )
+ *dst++ = *src++;
+ ZNORMALIZE(&px, ximage);
+ pixel = 0;
+ for (i=sizeof(unsigned long); --i >= 0; )
+ pixel = (pixel << 8) | ((unsigned char *)&px)[i];
+ if (ximage->bits_per_pixel == 4) {
+ if (x & 1)
+ pixel >>= 4;
+ else
+ pixel &= 0xf;
+ }
+ } else {
+ return 0; /* bad image */
+ }
+ if (ximage->bits_per_pixel == ximage->depth)
+ return pixel;
+ else
+ return (pixel & low_bits_table[ximage->depth]);
+}
+
+unsigned long
+PsGetImagePixel(char *pImage, int depth, int w, int h, int leftPad, int format,
+ int px, int py)
+{
+ TmpImage xi = {0};
+
+ xi.width = w;
+ xi.height = h;
+ xi.xoffset = 0/*leftPad*/;
+ xi.format = format;
+ xi.data = pImage;
+ xi.byte_order = IMAGE_BYTE_ORDER;
+ xi.bitmap_bit_order = BITMAP_BIT_ORDER;
+ xi.bitmap_unit = ((depth > 16)?(32):
+ ((depth > 8)?(16):
+ ((depth > 1)? (8):
+ (1))));
+ xi.depth = depth;
+ xi.bits_per_pixel = xi.bitmap_unit;
+
+ /*
+ * compute per line accelerator.
+ */
+ if (format == ZPixmap)
+ xi.bytes_per_line =
+ ROUNDUP((xi.bits_per_pixel * xi.width), 32);
+ else
+ xi.bytes_per_line =
+ ROUNDUP((xi.width + xi.xoffset), 32);
+
+ return XGetPixel(&xi, px, py);
+}
+
+
+
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsInit.c b/nx-X11/programs/Xserver/Xprint/ps/PsInit.c
new file mode 100644
index 000000000..a11a61ae4
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsInit.c
@@ -0,0 +1,667 @@
+/* $Xorg: PsInit.c,v 1.4 2001/02/09 02:04:36 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsInit.c
+** *
+** * Contents: Initialization code of Ps driver for the print server.
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+
+#include "Ps.h"
+#include "mi.h"
+#include "micmap.h"
+#include "AttrValid.h"
+#include "mfb.h"
+
+#include "windowstr.h"
+#include "DiPrint.h"
+
+static void AllocatePsPrivates(ScreenPtr pScreen);
+static int PsInitContext(XpContextPtr pCon);
+static int PsDestroyContext(XpContextPtr pCon);
+
+int PsScreenPrivateIndex;
+int PsContextPrivateIndex;
+int PsPixmapPrivateIndex;
+int PsWindowPrivateIndex;
+
+#ifdef GLXEXT
+extern void GlxWrapInitVisuals(miInitVisualsProcPtr *);
+#endif /* GLXEXT */
+
+Bool
+InitializePsDriver(ndx, pScreen, argc, argv)
+ int ndx;
+ ScreenPtr pScreen;
+ int argc;
+ char **argv;
+{
+#if 0
+ int maxXres, maxYres, maxWidth, maxHeight;
+ int maxRes, maxDim, numBytes;
+ PsScreenPrivPtr pPriv;
+#endif
+ char **printerNames;
+ int numPrinters;
+ int nv, /* total number of visuals */
+ nv_1bit, /* number of 8bit visuals */
+ nv_8bit, /* number of 8bit visuals */
+ nv_12bit, /* number of 12bit visuals */
+ nv_14bit, /* number of 14bit visuals */
+ nv_16bit, /* number of 16bit visuals */
+ nv_24bit, /* number of 24bit visuals*/
+ nv_30bit; /* number of 30bit visuals*/
+ int nd; /* number of depths */
+ int defaultVisualIndex = -1;
+ VisualID *vids_1bit,
+ *vids_8bit,
+ *vids_12bit,
+ *vids_14bit,
+ *vids_16bit,
+ *vids_24bit,
+ *vids_30bit;
+ VisualPtr visuals;
+ DepthPtr depths;
+ VisualID defaultVisual;
+ int rootDepth;
+
+/*
+ * Register this driver's InitContext function with the print
+ * extension.
+ */
+ XpRegisterInitFunc(pScreen, "XP-POSTSCRIPT", PsInitContext);
+
+/*
+ * Create and fill in the devPrivate for the PS driver.
+ */
+ AllocatePsPrivates(pScreen);
+
+#if 0
+ pPriv = (PsScreenPrivPtr)pScreen->devPrivates[PsScreenPrivateIndex].ptr;
+ pPriv->resDB = rmdb;
+#endif
+
+ pScreen->defColormap = (Colormap) FakeClientID(0);
+ pScreen->blackPixel = 1;
+ pScreen->whitePixel = 0;
+ pScreen->QueryBestSize = (QueryBestSizeProcPtr)PsQueryBestSize;
+ pScreen->SaveScreen = (SaveScreenProcPtr)_XpBoolNoop;
+ pScreen->GetImage = (GetImageProcPtr)_XpVoidNoop;
+ pScreen->GetSpans = (GetSpansProcPtr)_XpVoidNoop;
+ pScreen->CreateWindow = PsCreateWindow;
+ pScreen->DestroyWindow = PsDestroyWindow;
+ pScreen->PositionWindow = PsPositionWindow;
+ pScreen->ChangeWindowAttributes = PsChangeWindowAttributes;
+ pScreen->RealizeWindow = PsMapWindow;
+ pScreen->UnrealizeWindow = PsUnmapWindow;
+ pScreen->PaintWindowBackground = PsPaintWindow;
+ pScreen->PaintWindowBorder = PsPaintWindow;
+ pScreen->CloseScreen = PsCloseScreen;
+ pScreen->CopyWindow = PsCopyWindow;
+ /* XXX Hard routine to write! */
+
+/*
+ * These two are going to be VERY different...
+ */
+ pScreen->CreatePixmap = PsCreatePixmap;
+ pScreen->DestroyPixmap = PsDestroyPixmap;
+ pScreen->RealizeFont = PsRealizeFont;
+ pScreen->UnrealizeFont = PsUnrealizeFont;
+ pScreen->CreateGC = PsCreateGC;
+ pScreen->CreateColormap = PsCreateColormap;
+ pScreen->DestroyColormap = PsDestroyColormap;
+ pScreen->InstallColormap = PsInstallColormap;
+ pScreen->UninstallColormap = PsUninstallColormap;
+ pScreen->ListInstalledColormaps = PsListInstalledColormaps;
+ pScreen->StoreColors = PsStoreColors;
+ pScreen->ResolveColor = PsResolveColor;
+ /* Will BitmapToRegion make any difference at all? */
+ pScreen->BitmapToRegion = mfbPixmapToRegion;
+
+ visuals = (VisualPtr) xalloc(16*sizeof(VisualRec));
+ depths = (DepthPtr) xalloc(16*sizeof(DepthRec));
+ vids_1bit = (VisualID *)xalloc(16*sizeof(VisualID));
+ vids_8bit = (VisualID *)xalloc(16*sizeof(VisualID));
+ vids_12bit = (VisualID *)xalloc(16*sizeof(VisualID));
+ vids_14bit = (VisualID *)xalloc(16*sizeof(VisualID));
+ vids_16bit = (VisualID *)xalloc(16*sizeof(VisualID));
+ vids_24bit = (VisualID *)xalloc(16*sizeof(VisualID));
+ vids_30bit = (VisualID *)xalloc(16*sizeof(VisualID));
+
+ nv = nv_1bit = nv_8bit = nv_12bit = nv_14bit = nv_16bit = nv_24bit = nv_30bit = nd = 0;
+
+#ifdef PSOUT_USE_DEEPCOLOR
+/* gisburn: 30bit TrueColor has been disabled for now since it causes problems
+ * with GLX - see https://bugs.freedesktop.org/show_bug.cgi?id=2868 ("Mesa
+ * seems to be unable to handle 30bit TrueColor visuals") for details...
+ */
+#ifdef DISABLED_FOR_NOW
+ /* TrueColor, 30bit, 10bit per R-,G-,B-gun */
+ visuals[nv].vid = FakeClientID(0);
+ visuals[nv].class = TrueColor;
+ visuals[nv].bitsPerRGBValue = 10;
+ visuals[nv].ColormapEntries = 1024;
+ visuals[nv].nplanes = 30;
+ visuals[nv].redMask = 0X3FF00000;
+ visuals[nv].greenMask = 0X000FFC00;
+ visuals[nv].blueMask = 0X000003FF;
+ visuals[nv].offsetRed = 20;
+ visuals[nv].offsetGreen = 10;
+ visuals[nv].offsetBlue = 0;
+ vids_30bit[nv_30bit] = visuals[nv].vid;
+ nv++; nv_30bit++;
+#endif /* DISABLED_FOR_NOW */
+#endif /* PSOUT_USE_DEEPCOLOR */
+
+ /* TrueColor, 24bit */
+ visuals[nv].vid = FakeClientID(0);
+ visuals[nv].class = TrueColor;
+ visuals[nv].bitsPerRGBValue = 8;
+ visuals[nv].ColormapEntries = 256;
+ visuals[nv].nplanes = 24;
+ visuals[nv].redMask = 0X00FF0000;
+ visuals[nv].greenMask = 0X0000FF00;
+ visuals[nv].blueMask = 0X000000FF;
+ visuals[nv].offsetRed = 16;
+ visuals[nv].offsetGreen = 8;
+ visuals[nv].offsetBlue = 0;
+ vids_24bit[nv_24bit] = visuals[nv].vid;
+ nv++; nv_24bit++;
+
+ /* TrueColor, 16bit */
+ visuals[nv].vid = FakeClientID(0);
+ visuals[nv].class = TrueColor;
+ visuals[nv].bitsPerRGBValue = 6;
+ visuals[nv].ColormapEntries = 64;
+ visuals[nv].nplanes = 16;
+ visuals[nv].redMask = 0x0000f800;
+ visuals[nv].greenMask = 0x000007e0;
+ visuals[nv].blueMask = 0x0000001f;
+ visuals[nv].offsetRed = 11;
+ visuals[nv].offsetGreen = 5;
+ visuals[nv].offsetBlue = 0;
+ vids_16bit[nv_16bit] = visuals[nv].vid;
+ nv++; nv_16bit++;
+
+#ifdef PSOUT_USE_DEEPCOLOR
+ /* PostScript Level 2 and above, colors can have 12 bits per component
+ * (36 bit for RGB) */
+
+ /* PseudoColor, 14bit (15bit won't work as |ColormapEntries==32768|
+ * is too large for a |signed short|... xx@@!!!... ;-( ) */
+ visuals[nv].vid = FakeClientID(0);
+ visuals[nv].class = PseudoColor;
+ visuals[nv].bitsPerRGBValue = 12;
+ visuals[nv].ColormapEntries = 16384;
+ visuals[nv].nplanes = 14;
+ visuals[nv].redMask = 0x0;
+ visuals[nv].greenMask = 0x0;
+ visuals[nv].blueMask = 0x0;
+ visuals[nv].offsetRed = 0x0;
+ visuals[nv].offsetGreen = 0x0;
+ visuals[nv].offsetBlue = 0x0;
+ vids_14bit[nv_14bit] = visuals[nv].vid;
+ nv++; nv_14bit++;
+
+ /* PseudoColor, 12bit */
+ visuals[nv].vid = FakeClientID(0);
+ visuals[nv].class = PseudoColor;
+ visuals[nv].bitsPerRGBValue = 12;
+ visuals[nv].ColormapEntries = 4096;
+ visuals[nv].nplanes = 12;
+ visuals[nv].redMask = 0x0;
+ visuals[nv].greenMask = 0x0;
+ visuals[nv].blueMask = 0x0;
+ visuals[nv].offsetRed = 0x0;
+ visuals[nv].offsetGreen = 0x0;
+ visuals[nv].offsetBlue = 0x0;
+ vids_12bit[nv_12bit] = visuals[nv].vid;
+ defaultVisualIndex = nv;
+ nv++; nv_12bit++;
+
+ /* GrayScale, 12bit, 12bit per R-,G-,B-gun */
+ visuals[nv].vid = FakeClientID(0);
+ visuals[nv].class = GrayScale;
+ visuals[nv].bitsPerRGBValue = 12;
+ visuals[nv].ColormapEntries = 4096;
+ visuals[nv].nplanes = 12;
+ visuals[nv].redMask = 0x0;
+ visuals[nv].greenMask = 0x0;
+ visuals[nv].blueMask = 0x0;
+ visuals[nv].offsetRed = 0x0;
+ visuals[nv].offsetGreen = 0x0;
+ visuals[nv].offsetBlue = 0x0;
+ vids_12bit[nv_12bit] = visuals[nv].vid;
+ nv++; nv_12bit++;
+
+ /* StaticGray, 12bit, 12bit per R-,G-,B-gun */
+ visuals[nv].vid = FakeClientID(0);
+ visuals[nv].class = StaticGray;
+ visuals[nv].bitsPerRGBValue = 12;
+ visuals[nv].ColormapEntries = 4096;
+ visuals[nv].nplanes = 12;
+ visuals[nv].redMask = 0x0;
+ visuals[nv].greenMask = 0x0;
+ visuals[nv].blueMask = 0x0;
+ visuals[nv].offsetRed = 0x0;
+ visuals[nv].offsetGreen = 0x0;
+ visuals[nv].offsetBlue = 0x0;
+ vids_12bit[nv_12bit] = visuals[nv].vid;
+ nv++; nv_12bit++;
+#endif /* PSOUT_USE_DEEPCOLOR */
+
+ /* PseudoColor, 8bit */
+ visuals[nv].vid = FakeClientID(0);
+ visuals[nv].class = PseudoColor;
+ visuals[nv].bitsPerRGBValue = 8;
+ visuals[nv].ColormapEntries = 256;
+ visuals[nv].nplanes = 8;
+ visuals[nv].redMask = 0x0;
+ visuals[nv].greenMask = 0x0;
+ visuals[nv].blueMask = 0x0;
+ visuals[nv].offsetRed = 0x0;
+ visuals[nv].offsetGreen = 0x0;
+ visuals[nv].offsetBlue = 0x0;
+ vids_8bit[nv_8bit] = visuals[nv].vid;
+#ifndef PSOUT_USE_DEEPCOLOR
+ defaultVisualIndex = nv;
+#endif /* !PSOUT_USE_DEEPCOLOR */
+ nv++; nv_8bit++;
+
+ /* GrayScale, 8bit */
+ visuals[nv].vid = FakeClientID(0);
+ visuals[nv].class = GrayScale;
+ visuals[nv].bitsPerRGBValue = 8;
+ visuals[nv].ColormapEntries = 256;
+ visuals[nv].nplanes = 8;
+ visuals[nv].redMask = 0x0;
+ visuals[nv].greenMask = 0x0;
+ visuals[nv].blueMask = 0x0;
+ visuals[nv].offsetRed = 0x0;
+ visuals[nv].offsetGreen = 0x0;
+ visuals[nv].offsetBlue = 0x0;
+ vids_8bit[nv_8bit] = visuals[nv].vid;
+ nv++; nv_8bit++;
+
+ /* StaticGray, 8bit */
+ visuals[nv].vid = FakeClientID(0);
+ visuals[nv].class = StaticGray;
+ visuals[nv].bitsPerRGBValue = 8;
+ visuals[nv].ColormapEntries = 256;
+ visuals[nv].nplanes = 8;
+ visuals[nv].redMask = 0x0;
+ visuals[nv].greenMask = 0x0;
+ visuals[nv].blueMask = 0x0;
+ visuals[nv].offsetRed = 0x0;
+ visuals[nv].offsetGreen = 0x0;
+ visuals[nv].offsetBlue = 0x0;
+ vids_8bit[nv_8bit] = visuals[nv].vid;
+ nv++; nv_8bit++;
+
+ /* StaticGray, 1bit */
+ visuals[nv].vid = FakeClientID(0);
+ visuals[nv].class = StaticGray;
+ visuals[nv].bitsPerRGBValue = 1;
+ visuals[nv].ColormapEntries = 2;
+ visuals[nv].nplanes = 1;
+ visuals[nv].redMask = 0x0;
+ visuals[nv].greenMask = 0x0;
+ visuals[nv].blueMask = 0x0;
+ visuals[nv].offsetRed = 0x0;
+ visuals[nv].offsetGreen = 0x0;
+ visuals[nv].offsetBlue = 0x0;
+ vids_1bit[nv_1bit] = visuals[nv].vid;
+ nv++; nv_1bit++;
+
+ if( nv_30bit > 0 )
+ {
+ depths[nd].depth = 30;
+ depths[nd].numVids = nv_30bit;
+ depths[nd].vids = vids_30bit;
+ nd++;
+ }
+
+ if( nv_24bit > 0 )
+ {
+ depths[nd].depth = 24;
+ depths[nd].numVids = nv_24bit;
+ depths[nd].vids = vids_24bit;
+ nd++;
+ }
+
+ if( nv_16bit > 0 )
+ {
+ depths[nd].depth = 16;
+ depths[nd].numVids = nv_16bit;
+ depths[nd].vids = vids_16bit;
+ nd++;
+ }
+
+ if( nv_14bit > 0 )
+ {
+ depths[nd].depth = 14;
+ depths[nd].numVids = nv_14bit;
+ depths[nd].vids = vids_14bit;
+ nd++;
+ }
+
+ if( nv_12bit > 0 )
+ {
+ depths[nd].depth = 12;
+ depths[nd].numVids = nv_12bit;
+ depths[nd].vids = vids_12bit;
+ nd++;
+ }
+
+ if( nv_8bit > 0 )
+ {
+ depths[nd].depth = 8;
+ depths[nd].numVids = nv_8bit;
+ depths[nd].vids = vids_8bit;
+ nd++;
+ }
+
+ if( nv_1bit > 0 )
+ {
+ depths[nd].depth = 1;
+ depths[nd].numVids = nv_1bit;
+ depths[nd].vids = vids_1bit;
+ nd++;
+ }
+
+ /* Defaul visual is 12bit PseudoColor */
+ defaultVisual = visuals[defaultVisualIndex].vid;
+ rootDepth = visuals[defaultVisualIndex].nplanes;
+
+#ifdef GLXEXT
+ {
+ miInitVisualsProcPtr proc = NULL;
+
+ GlxWrapInitVisuals(&proc);
+ /* GlxInitVisuals ignores the last three arguments. */
+ proc(&visuals, &depths, &nv, &nd,
+ &rootDepth, &defaultVisual, 0, 0, 0);
+ }
+#endif /* GLXEXT */
+
+ miScreenInit(pScreen, (pointer)0,
+ pScreen->width, pScreen->height,
+ (int) (pScreen->width / (pScreen->mmWidth / 25.40)),
+ (int) (pScreen->height / (pScreen->mmHeight / 25.40)),
+ 0, rootDepth, nd,
+ depths, defaultVisual, nv, visuals);
+
+ if( miCreateDefColormap(pScreen)==FALSE ) return FALSE;
+
+/*scalingScreenInit(pScreen);*/
+
+ return TRUE;
+}
+
+static void
+AllocatePsPrivates(ScreenPtr pScreen)
+{
+ static unsigned long PsGeneration = 0;
+
+ if((unsigned long)PsGeneration != serverGeneration)
+ {
+ PsScreenPrivateIndex = AllocateScreenPrivateIndex();
+
+ PsWindowPrivateIndex = AllocateWindowPrivateIndex();
+ AllocateWindowPrivate(pScreen, PsWindowPrivateIndex,
+ sizeof(PsWindowPrivRec));
+
+ PsContextPrivateIndex = XpAllocateContextPrivateIndex();
+ XpAllocateContextPrivate(PsContextPrivateIndex,
+ sizeof(PsContextPrivRec));
+
+ PsPixmapPrivateIndex = AllocatePixmapPrivateIndex();
+ AllocatePixmapPrivate(pScreen, PsPixmapPrivateIndex,
+ sizeof(PsPixmapPrivRec));
+
+ PsGeneration = serverGeneration;
+ }
+ pScreen->devPrivates[PsScreenPrivateIndex].ptr =
+ (pointer)xalloc(sizeof(PsScreenPrivRec));
+}
+
+/*
+ * PsInitContext
+ *
+ * Establish the appropriate values for a PrintContext used with the PS
+ * driver.
+ */
+
+static char DOC_ATT_SUPP[]="document-attributes-supported";
+static char DOC_ATT_VAL[]="document-format xp-listfonts-modes";
+static char JOB_ATT_SUPP[]="job-attributes-supported";
+static char JOB_ATT_VAL[]="";
+static char PAGE_ATT_SUPP[]="xp-page-attributes-supported";
+static char PAGE_ATT_VAL[]="content-orientation default-printer-resolution \
+default-input-tray default-medium plex xp-listfonts-modes";
+
+static int
+PsInitContext(pCon)
+ XpContextPtr pCon;
+{
+ XpDriverFuncsPtr pFuncs;
+ PsContextPrivPtr pConPriv;
+ char *server, *attrStr;
+
+ /*
+ * Initialize the attribute store for this printer.
+ */
+ XpInitAttributes(pCon);
+
+ /*
+ * Initialize the function pointers
+ */
+ pFuncs = &(pCon->funcs);
+ pFuncs->StartJob = PsStartJob;
+ pFuncs->EndJob = PsEndJob;
+ pFuncs->StartDoc = PsStartDoc;
+ pFuncs->EndDoc = PsEndDoc;
+ pFuncs->StartPage = PsStartPage;
+ pFuncs->EndPage = PsEndPage;
+ pFuncs->PutDocumentData = PsDocumentData;
+ pFuncs->GetDocumentData = PsGetDocumentData;
+ pFuncs->GetAttributes = PsGetAttributes;
+ pFuncs->SetAttributes = PsSetAttributes;
+ pFuncs->AugmentAttributes = PsAugmentAttributes;
+ pFuncs->GetOneAttribute = PsGetOneAttribute;
+ pFuncs->DestroyContext = PsDestroyContext;
+ pFuncs->GetMediumDimensions = PsGetMediumDimensions;
+ pFuncs->GetReproducibleArea = PsGetReproducibleArea;
+ pFuncs->SetImageResolution = PsSetImageResolution;
+
+ /*
+ * Set up the context privates
+ */
+ pConPriv =
+ (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+
+ memset(pConPriv, 0, sizeof(PsContextPrivRec));
+ pConPriv->jobFileName = (char *)NULL;
+ pConPriv->pJobFile = (FILE *)NULL;
+ pConPriv->dash = (unsigned char *)NULL;
+ pConPriv->validGC = 0;
+ pConPriv->getDocClient = (ClientPtr)NULL;
+ pConPriv->getDocBufSize = 0;
+ pConPriv->pPsOut = NULL;
+ pConPriv->fontInfoRecords = NULL;
+ pConPriv->fontTypeInfoRecords = NULL;
+
+ /*
+ * document-attributes-supported
+ */
+ server = XpGetOneAttribute( pCon, XPServerAttr, DOC_ATT_SUPP );
+ if ((attrStr = (char *) xalloc(strlen(server) +
+ strlen(DOC_ATT_SUPP) + strlen(DOC_ATT_VAL)
+ + strlen(PAGE_ATT_VAL) + 8)) == NULL)
+ {
+ return BadAlloc;
+ }
+ sprintf(attrStr, "*%s:\t%s %s %s",
+ DOC_ATT_SUPP, server, DOC_ATT_VAL, PAGE_ATT_VAL);
+ XpAugmentAttributes( pCon, XPPrinterAttr, attrStr);
+ xfree(attrStr);
+
+ /*
+ * job-attributes-supported
+ */
+ server = XpGetOneAttribute( pCon, XPServerAttr, JOB_ATT_SUPP );
+ if ((attrStr = (char *) xalloc(strlen(server) + strlen(JOB_ATT_SUPP) +
+ strlen(JOB_ATT_VAL) + 8)) == NULL)
+ {
+ return BadAlloc;
+ }
+ sprintf(attrStr, "*%s:\t%s %s", JOB_ATT_SUPP, server, JOB_ATT_VAL);
+ XpAugmentAttributes(pCon, XPPrinterAttr, attrStr);
+ xfree(attrStr);
+
+ /*
+ * xp-page-attributes-supported
+ */
+ server = XpGetOneAttribute( pCon, XPServerAttr, PAGE_ATT_SUPP );
+ if ((attrStr = (char *) xalloc(strlen(server) + strlen(PAGE_ATT_SUPP) +
+ strlen(PAGE_ATT_VAL) + 8)) == NULL)
+ {
+ return BadAlloc;
+ }
+ sprintf(attrStr, "*%s:\t%s %s", PAGE_ATT_SUPP, server, PAGE_ATT_VAL);
+ XpAugmentAttributes(pCon, XPPrinterAttr, attrStr);
+ xfree(attrStr);
+
+ /*
+ * Validate the attribute pools
+ */
+ XpValidateAttributePool(pCon, XPPrinterAttr, &PsValidatePoolsRec);
+ XpValidateAttributePool(pCon, XPDocAttr, &PsValidatePoolsRec);
+ XpValidateAttributePool(pCon, XPJobAttr, &PsValidatePoolsRec);
+ XpValidateAttributePool(pCon, XPPageAttr, &PsValidatePoolsRec);
+
+ return Success;
+}
+
+static Bool
+PsDestroyContext(pCon)
+ XpContextPtr pCon;
+{
+ PsContextPrivPtr pConPriv =
+ (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+
+ if( pConPriv->pJobFile!=(FILE *)NULL )
+ {
+ fclose(pConPriv->pJobFile);
+ pConPriv->pJobFile = NULL;
+ }
+ if( pConPriv->jobFileName!=(char *)NULL )
+ {
+ unlink(pConPriv->jobFileName);
+ xfree(pConPriv->jobFileName);
+ pConPriv->jobFileName = (char *)NULL;
+ }
+
+ PsFreeFontInfoRecords(pConPriv);
+
+ /* Reset context to make sure we do not use any stale/invalid/obsolete data */
+ memset(pConPriv, 0, sizeof(PsContextPrivRec));
+
+/*### free up visuals/depths ###*/
+
+ return Success;
+}
+
+XpContextPtr
+PsGetContextFromWindow(win)
+ WindowPtr win;
+{
+ PsWindowPrivPtr pPriv;
+
+ while( win )
+ {
+ pPriv = (PsWindowPrivPtr)win->devPrivates[PsWindowPrivateIndex].ptr;
+ if( pPriv->validContext ) return pPriv->context;
+ win = win->parent;
+ }
+
+ return NULL;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsLine.c b/nx-X11/programs/Xserver/Xprint/ps/PsLine.c
new file mode 100644
index 000000000..2524769c8
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsLine.c
@@ -0,0 +1,192 @@
+/* $Xorg: PsLine.c,v 1.4 2001/02/09 02:04:36 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsLine.c
+** *
+** * Contents: Line drawing routines for the PS driver
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Ps.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+
+void
+PsPolyLine(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int nPoints,
+ xPoint *pPoints)
+{
+ if( pDrawable->type==DRAWABLE_PIXMAP )
+ {
+ DisplayElmPtr elm;
+ PixmapPtr pix = (PixmapPtr)pDrawable;
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
+ DisplayListPtr disp;
+ GCPtr gc;
+
+ if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return;
+
+ disp = PsGetFreeDisplayBlock(priv);
+
+ elm = &disp->elms[disp->nelms];
+ elm->type = PolyLineCmd;
+ elm->gc = gc;
+ elm->c.polyPts.mode = mode;
+ elm->c.polyPts.nPoints = nPoints;
+ elm->c.polyPts.pPoints = (xPoint *)xalloc(nPoints*sizeof(xPoint));
+ memcpy(elm->c.polyPts.pPoints, pPoints, nPoints*sizeof(xPoint));
+ disp->nelms += 1;
+ }
+ else
+ {
+ int i;
+ PsOutPtr psOut;
+ PsPointPtr pts;
+ ColormapPtr cMap;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return;
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ PsLineAttrs(psOut, pGC, cMap);
+ pts = (PsPointPtr)xalloc(sizeof(PsPointRec)*nPoints);
+ if( mode==CoordModeOrigin )
+ {
+ for( i=0 ; i<nPoints ; i++ )
+ { pts[i].x = pPoints[i].x; pts[i].y = pPoints[i].y; }
+ }
+ else
+ {
+ pts[0].x = pPoints[0].x; pts[0].y = pPoints[0].y;
+ for( i=1 ; i<nPoints ; i++ )
+ {
+ pts[i].x = pts[i-1].x+pPoints[i].x;
+ pts[i].y = pts[i-1].y+pPoints[i].y;
+ }
+ }
+ PsOut_Lines(psOut, nPoints, pts);
+ xfree(pts);
+ }
+}
+
+void
+PsPolySegment(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nSegments,
+ xSegment *pSegments)
+{
+ if( pDrawable->type==DRAWABLE_PIXMAP )
+ {
+ DisplayElmPtr elm;
+ PixmapPtr pix = (PixmapPtr)pDrawable;
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
+ DisplayListPtr disp;
+ GCPtr gc;
+
+ if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return;
+
+ disp = PsGetFreeDisplayBlock(priv);
+
+ elm = &disp->elms[disp->nelms];
+ elm->type = PolySegmentCmd;
+ elm->gc = gc;
+ elm->c.segments.nSegments = nSegments;
+ elm->c.segments.pSegments = (xSegment *)xalloc(nSegments*sizeof(xSegment));
+ memcpy(elm->c.segments.pSegments, pSegments, nSegments*sizeof(xSegment));
+ disp->nelms += 1;
+ }
+ else
+ {
+ int i;
+ PsOutPtr psOut;
+ PsPointRec pts[2];
+ ColormapPtr cMap;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return;
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ PsLineAttrs(psOut, pGC, cMap);
+ for( i=0 ; i<nSegments ; i++ )
+ {
+ pts[0].x = pSegments[i].x1;
+ pts[0].y = pSegments[i].y1;
+ pts[1].x = pSegments[i].x2;
+ pts[1].y = pSegments[i].y2;
+ PsOut_Lines(psOut, 2, pts);
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsMisc.c b/nx-X11/programs/Xserver/Xprint/ps/PsMisc.c
new file mode 100644
index 000000000..b8a3ba854
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsMisc.c
@@ -0,0 +1,324 @@
+/* $Xorg: PsMisc.c,v 1.4 2001/02/09 02:04:36 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsMisc.c
+** *
+** * Contents: Miscellaneous code for Ps driver.
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xos.h> /* for SIGCLD on pre-POSIX systems */
+#include <stdio.h>
+#include "Ps.h"
+
+#include "cursor.h"
+#include "resource.h"
+
+#include "windowstr.h"
+#include "propertyst.h"
+
+
+/*ARGSUSED*/
+void
+PsQueryBestSize(
+ int type,
+ short *pwidth,
+ short *pheight,
+ ScreenPtr pScreen)
+{
+ unsigned width, highBit;
+
+ switch(type)
+ {
+ case CursorShape:
+ *pwidth = 0;
+ *pheight = 0;
+ break;
+ case TileShape:
+ case StippleShape:
+ width = *pwidth;
+ if (!width) break;
+ /* Return the nearest power of two >= what they gave us */
+ highBit = 0x80000000;
+ /* Find the highest 1 bit in the given width */
+ while(!(highBit & width))
+ highBit >>= 1;
+ /* If greater than that then return the next power of two */
+ if((highBit - 1) & width)
+ highBit <<= 1;
+ *pwidth = highBit;
+ /* height is a don't-care */
+ break;
+ }
+}
+
+/*
+ * PsGetMediumDimensions is installed in the GetMediumDimensions field
+ * of each Ps-initialized context.
+ */
+int
+PsGetMediumDimensions(XpContextPtr pCon, CARD16 *width, CARD16 *height)
+{
+ XpGetMediumDimensions(pCon, width, height);
+ return Success;
+}
+
+/*
+ * PsGetReproducibleArea is installed in the GetReproducibleArea field
+ * of each Ps-initialized context.
+ */
+int
+PsGetReproducibleArea(XpContextPtr pCon, xRectangle *pRect)
+{
+ XpGetReproductionArea(pCon, pRect);
+ return Success;
+}
+
+/*
+ * PsSetImageResolution is installed in the SetImageResolution field
+ * of each Ps-initialized context.
+ */
+int
+PsSetImageResolution(XpContextPtr pCon, int imageRes, Bool *status)
+{
+ pCon->imageRes = imageRes;
+ *status = True;
+ return Success;
+}
+
+/*
+ * GetPropString searches the window heirarchy from pWin up looking for
+ * a property by the name of propName. If found, returns the property's
+ * value. If not, it returns NULL.
+ */
+/*
+char *
+GetPropString(
+ WindowPtr pWin,
+ char *propName)
+{
+ Atom atom;
+ PropertyPtr pProp = (PropertyPtr)NULL;
+ char *retVal;
+
+ atom = MakeAtom(propName, strlen(propName), FALSE);
+ if(atom != BAD_RESOURCE)
+ {
+ WindowPtr pPropWin;
+ int n;
+*/
+
+ /*
+ * The atom has been defined, but it might only exist as a
+ * property on an unrelated window.
+ */
+/*
+ for(pPropWin = pWin; pPropWin != (WindowPtr)NULL;
+ pPropWin = pPropWin->parent)
+ {
+ for(pProp = (PropertyPtr)(wUserProps(pPropWin));
+ pProp != (PropertyPtr)NULL;
+ pProp = pProp->next)
+ {
+ if (pProp->propertyName == atom)
+ break;
+ }
+ if(pProp != (PropertyPtr)NULL)
+ break;
+ }
+ if(pProp == (PropertyPtr)NULL)
+ return (char *)NULL;
+
+ n = (pProp->format/8) * pProp->size; *//* size (bytes) of prop */
+/*
+ retVal = (char *)xalloc(n + 1);
+ (void)memcpy((void *)retVal, (void *)pProp->data, n);
+ retVal[n] = '\0';
+
+ return retVal;
+ }
+
+ return (char *)NULL;
+}
+
+#include <signal.h>
+
+*/
+/* ARGSUSED */
+/*
+static void SigchldHndlr (int dummy)
+{
+ int status, w;
+ struct sigaction act;
+ sigfillset(&act.sa_mask);
+ act.sa_flags = 0;
+ act.sa_handler = SigchldHndlr;
+
+ w = wait (&status);
+
+*/
+ /*
+ * Is this really necessary?
+ */
+/*
+ sigaction(SIGCHLD, &act, (struct sigaction *)NULL);
+}
+*/
+
+/*
+ * SystemCmd provides a wrapper for the 'system' library call. The call
+ * appears to be sensitive to the handling of SIGCHLD, so this wrapper
+ * sets the status to SIG_DFL, and then resets the established handler
+ * after system returns.
+ */
+/*
+int
+SystemCmd(char *cmdStr)
+{
+ int status;
+ struct sigaction newAct, oldAct;
+ sigfillset(&newAct.sa_mask);
+ newAct.sa_flags = 0;
+ newAct.sa_handler = SIG_DFL;
+ sigfillset(&oldAct.sa_mask);
+ oldAct.sa_flags = 0;
+ oldAct.sa_handler = SigchldHndlr;
+
+*/
+ /*
+ * get the old handler, and set the action to IGN
+ */
+/*
+ sigaction(SIGCHLD, &newAct, &oldAct);
+
+ status = system (cmdStr);
+
+ sigaction(SIGCHLD, &oldAct, (struct sigaction *)NULL);
+ return status;
+}
+*/
+
+Bool
+PsCloseScreen(
+ int index,
+ ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+void
+PsLineAttrs(
+ PsOutPtr psOut,
+ GCPtr pGC,
+ ColormapPtr cMap)
+{
+ int i;
+ int nDsh;
+ int dshOff;
+ int *dsh;
+ PsCapEnum cap;
+ PsJoinEnum join;
+
+ switch(pGC->capStyle) {
+ case CapButt: cap = PsCButt; break;
+ case CapRound: cap = PsCRound; break;
+ case CapProjecting: cap = PsCSquare; break;
+ default: cap = PsCButt; break; }
+ switch(pGC->joinStyle) {
+ case JoinMiter: join = PsJMiter; break;
+ case JoinRound: join = PsJRound; break;
+ case JoinBevel: join = PsJBevel; break;
+ default: join = PsJBevel; break; }
+ if( pGC->lineStyle==LineSolid ) { nDsh = dshOff = 0; dsh = (int *)0; }
+ else
+ {
+ nDsh = pGC->numInDashList;
+ dshOff = pGC->dashOffset;
+ if( !nDsh ) dsh = (int *)0;
+ else
+ {
+ dsh = (int *)xalloc(sizeof(int)*nDsh);
+ for( i=0 ; i<nDsh ; i++ ) dsh[i] = (int)pGC->dash[i]&0xFF;
+ }
+ }
+
+ if( pGC->lineStyle!=LineDoubleDash )
+ PsOut_LineAttrs(psOut, (int)pGC->lineWidth,
+ cap, join, nDsh, dsh, dshOff, -1);
+ else
+ PsOut_LineAttrs(psOut, (int)pGC->lineWidth,
+ cap, join, nDsh, dsh, dshOff,
+ PsGetPixelColor(cMap, pGC->bgPixel));
+ if( nDsh && dsh ) xfree(dsh);
+}
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsPixel.c b/nx-X11/programs/Xserver/Xprint/ps/PsPixel.c
new file mode 100644
index 000000000..2197f0ab9
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsPixel.c
@@ -0,0 +1,157 @@
+/* $Xorg: PsPixel.c,v 1.4 2001/02/09 02:04:36 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsPixel.c
+** *
+** * Contents: Pixel-drawing code for the PS DDX driver
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1995 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+
+#include "windowstr.h"
+#include "gcstruct.h"
+
+#include "Ps.h"
+
+void
+PsPolyPoint(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int nPoints,
+ xPoint *pPoints)
+{
+ if( pDrawable->type==DRAWABLE_PIXMAP )
+ {
+ DisplayElmPtr elm;
+ PixmapPtr pix = (PixmapPtr)pDrawable;
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
+ DisplayListPtr disp;
+ GCPtr gc;
+
+ if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return;
+
+ disp = PsGetFreeDisplayBlock(priv);
+
+ elm = &disp->elms[disp->nelms];
+ elm->type = PolyPointCmd;
+ elm->gc = gc;
+ elm->c.polyPts.mode = mode;
+ elm->c.polyPts.nPoints = nPoints;
+ elm->c.polyPts.pPoints = (xPoint *)xalloc(nPoints*sizeof(xPoint));
+ memcpy(elm->c.polyPts.pPoints, pPoints, nPoints*sizeof(xPoint));
+ disp->nelms += 1;
+ }
+ else
+ {
+ int i;
+ PsOutPtr psOut;
+ PsPointPtr pts;
+ ColormapPtr cMap;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return;
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ pts = (PsPointPtr)xalloc(sizeof(PsPointRec)*nPoints);
+ if( mode==CoordModeOrigin )
+ {
+ for( i=0 ; i<nPoints ; i++ )
+ { pts[i].x = pPoints[i].x; pts[i].y = pPoints[i].y; }
+ }
+ else
+ {
+ pts[0].x = pPoints[0].x; pts[0].y = pPoints[0].y;
+ for( i=1 ; i<nPoints ; i++ )
+ {
+ pts[i].x = pts[i-1].x+pPoints[i].x;
+ pts[i].y = pts[i-1].y+pPoints[i].y;
+ }
+ }
+ PsOut_Points(psOut, nPoints, pts);
+ xfree(pts);
+ }
+}
+
+void
+PsPushPixels(
+ GCPtr pGC,
+ PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int width,
+ int height,
+ int x,
+ int y)
+{
+}
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsPixmap.c b/nx-X11/programs/Xserver/Xprint/ps/PsPixmap.c
new file mode 100644
index 000000000..a698b375e
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsPixmap.c
@@ -0,0 +1,617 @@
+/* $Xorg: PsPixmap.c,v 1.4 2001/02/09 02:04:36 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsPixmap.c
+** *
+** * Contents: Pixmap functions for the PS DDX driver
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1995 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "windowstr.h"
+#include "gcstruct.h"
+
+#include "Ps.h"
+
+#define _BitsPerPixel(d) (\
+ (1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
+ (PixmapWidthPaddingInfo[d].padRoundUp+1))
+
+PixmapPtr
+PsCreatePixmap(
+ ScreenPtr pScreen,
+ int width,
+ int height,
+ int depth)
+{
+ PixmapPtr pPixmap;
+
+ pPixmap = (PixmapPtr)xcalloc(1, sizeof(PixmapRec));
+ if( !pPixmap) return NullPixmap;
+ pPixmap->drawable.type = DRAWABLE_PIXMAP;
+ pPixmap->drawable.class = 0;
+ pPixmap->drawable.pScreen = pScreen;
+ pPixmap->drawable.depth = depth;
+ pPixmap->drawable.bitsPerPixel = _BitsPerPixel(depth);
+ pPixmap->drawable.id = 0;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pPixmap->drawable.x = 0;
+ pPixmap->drawable.y = 0;
+ pPixmap->drawable.width = width;
+ pPixmap->drawable.height = height;
+ pPixmap->devKind = 0;
+ pPixmap->refcnt = 1;
+
+ pPixmap->devPrivate.ptr = (PsPixmapPrivPtr)xcalloc(1, sizeof(PsPixmapPrivRec));
+ if( !pPixmap->devPrivate.ptr )
+ { xfree(pPixmap); return NullPixmap; }
+ return pPixmap;
+}
+
+/* PsScrubPixmap: Remove all content from a pixmap (used by
+ * |PsPolyFillRect()| when the "solid fill" operation covers
+ * the whole pixmap) */
+void
+PsScrubPixmap(PixmapPtr pPixmap)
+{
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pPixmap->devPrivate.ptr;
+ DisplayListPtr disp = priv->dispList;
+
+ while( disp )
+ {
+ int i;
+ DisplayListPtr oldDisp = disp;
+ disp = disp->next;
+ for( i=0 ; i<oldDisp->nelms ; i++ )
+ {
+ DisplayElmPtr elm = &oldDisp->elms[i];
+
+ switch(elm->type)
+ {
+ case PolyPointCmd:
+ case PolyLineCmd:
+ if( elm->c.polyPts.pPoints ) xfree(elm->c.polyPts.pPoints);
+ break;
+ case PolySegmentCmd:
+ if( elm->c.segments.pSegments ) xfree(elm->c.segments.pSegments);
+ break;
+ case PolyRectangleCmd:
+ if( elm->c.rects.pRects ) xfree(elm->c.rects.pRects);
+ break;
+ case FillPolygonCmd:
+ if( elm->c.polyPts.pPoints ) xfree(elm->c.polyPts.pPoints);
+ break;
+ case PolyFillRectCmd:
+ if( elm->c.rects.pRects ) xfree(elm->c.rects.pRects);
+ break;
+ case PolyArcCmd:
+ if( elm->c.arcs.pArcs ) xfree(elm->c.arcs.pArcs);
+ break;
+ case PolyFillArcCmd:
+ if( elm->c.arcs.pArcs ) xfree(elm->c.arcs.pArcs);
+ break;
+ case Text8Cmd:
+ case TextI8Cmd:
+ if( elm->c.text8.string ) xfree(elm->c.text8.string);
+ break;
+ case Text16Cmd:
+ case TextI16Cmd:
+ if( elm->c.text16.string ) xfree(elm->c.text16.string);
+ break;
+ case PutImageCmd:
+ if( elm->c.image.pData ) xfree(elm->c.image.pData);
+ break;
+ case BeginFrameCmd:
+ break;
+ case EndFrameCmd:
+ break;
+ }
+
+ if (elm->type != BeginFrameCmd && elm->type != EndFrameCmd) {
+ (void) FreeGC(elm->gc, (GContext) 0);
+ }
+ }
+ xfree(oldDisp);
+ }
+
+ priv->dispList = NULL;
+}
+
+Bool
+PsDestroyPixmap(PixmapPtr pPixmap)
+{
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pPixmap->devPrivate.ptr;
+ DisplayListPtr disp = priv->dispList;
+
+ if( --pPixmap->refcnt ) return TRUE;
+
+ PsScrubPixmap(pPixmap);
+
+ xfree(priv);
+ xfree(pPixmap);
+ return TRUE;
+}
+
+DisplayListPtr
+PsGetFreeDisplayBlock(PsPixmapPrivPtr priv)
+{
+ DisplayListPtr disp = priv->dispList;
+
+ for(; disp ; disp=disp->next )
+ {
+ if( disp->nelms>=DPY_BLOCKSIZE && disp->next ) continue;
+ if( disp->nelms<DPY_BLOCKSIZE ) return(disp);
+ disp->next = (DisplayListPtr)xcalloc(1, sizeof(DisplayListRec));
+ disp->next->next = (DisplayListPtr)0;
+ disp->next->nelms = 0;
+ }
+ disp = (DisplayListPtr)xcalloc(1, sizeof(DisplayListRec));
+ disp->next = (DisplayListPtr)0;
+ disp->nelms = 0;
+ priv->dispList = disp;
+ return(disp);
+}
+
+void
+PsReplay(DisplayElmPtr elm, DrawablePtr pDrawable)
+{
+ switch(elm->type)
+ {
+ case PolyPointCmd:
+ PsPolyPoint(pDrawable, elm->gc, elm->c.polyPts.mode,
+ elm->c.polyPts.nPoints, elm->c.polyPts.pPoints);
+ break;
+ case PolyLineCmd:
+ PsPolyLine(pDrawable, elm->gc, elm->c.polyPts.mode,
+ elm->c.polyPts.nPoints, elm->c.polyPts.pPoints);
+ break;
+ case PolySegmentCmd:
+ PsPolySegment(pDrawable, elm->gc, elm->c.segments.nSegments,
+ elm->c.segments.pSegments);
+ break;
+ case PolyRectangleCmd:
+ PsPolyRectangle(pDrawable, elm->gc, elm->c.rects.nRects,
+ elm->c.rects.pRects);
+ break;
+ case FillPolygonCmd:
+ PsFillPolygon(pDrawable, elm->gc, 0, elm->c.polyPts.mode,
+ elm->c.polyPts.nPoints, elm->c.polyPts.pPoints);
+ break;
+ case PolyFillRectCmd:
+ PsPolyFillRect(pDrawable, elm->gc, elm->c.rects.nRects,
+ elm->c.rects.pRects);
+ break;
+ case PolyArcCmd:
+ PsPolyArc(pDrawable, elm->gc, elm->c.arcs.nArcs, elm->c.arcs.pArcs);
+ break;
+ case PolyFillArcCmd:
+ PsPolyFillArc(pDrawable, elm->gc, elm->c.arcs.nArcs, elm->c.arcs.pArcs);
+ break;
+ case Text8Cmd:
+ PsPolyText8(pDrawable, elm->gc, elm->c.text8.x, elm->c.text8.y,
+ elm->c.text8.count, elm->c.text8.string);
+ break;
+ case Text16Cmd:
+ PsPolyText16(pDrawable, elm->gc, elm->c.text16.x, elm->c.text16.y,
+ elm->c.text16.count, elm->c.text16.string);
+ break;
+ case TextI8Cmd:
+ PsImageText8(pDrawable, elm->gc, elm->c.text8.x, elm->c.text8.y,
+ elm->c.text8.count, elm->c.text8.string);
+ break;
+ case TextI16Cmd:
+ PsImageText16(pDrawable, elm->gc, elm->c.text16.x, elm->c.text16.y,
+ elm->c.text16.count, elm->c.text16.string);
+ break;
+ case PutImageCmd:
+ PsPutScaledImage(pDrawable, elm->gc, elm->c.image.depth,
+ elm->c.image.x, elm->c.image.y,
+ elm->c.image.w, elm->c.image.h, elm->c.image.leftPad,
+ elm->c.image.format, elm->c.image.res,
+ elm->c.image.pData);
+ break;
+ case BeginFrameCmd:
+ {
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+ if( PsUpdateDrawableGC(NULL, pDrawable, &psOut, &cMap)==FALSE ) return;
+ PsOut_BeginFrame(psOut, 0, 0, elm->c.frame.x, elm->c.frame.y,
+ elm->c.frame.w, elm->c.frame.h);
+ }
+ break;
+ case EndFrameCmd:
+ {
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+ if( PsUpdateDrawableGC(NULL, pDrawable, &psOut, &cMap)==FALSE ) return;
+ PsOut_EndFrame(psOut);
+ }
+ break;
+ }
+}
+
+void
+PsReplayPixmap(PixmapPtr pix, DrawablePtr pDrawable)
+{
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
+ DisplayListPtr disp = priv->dispList;
+ DisplayElmPtr elm;
+
+ for(; disp ; disp=disp->next )
+ {
+ int i;
+ for( i=0,elm=disp->elms ; i<disp->nelms ; i++,elm++ )
+ PsReplay(elm, pDrawable);
+ }
+}
+
+int
+PsCloneDisplayElm(PixmapPtr dst, DisplayElmPtr elm, DisplayElmPtr newElm,
+ int xoff, int yoff)
+{
+ int i;
+ int size;
+ int status = 0;
+
+ *newElm = *elm;
+
+ /* I think this is the correct return value */
+ if ((newElm->gc = PsCreateAndCopyGC(&dst->drawable, elm->gc)) == NULL) {
+ return 1;
+ }
+
+ switch(elm->type)
+ {
+ case PolyPointCmd:
+ case PolyLineCmd:
+ newElm->c.polyPts.pPoints =
+ (xPoint *)xalloc(elm->c.polyPts.nPoints*sizeof(xPoint));
+ for( i=0 ; i<elm->c.polyPts.nPoints ; i++ )
+ {
+ newElm->c.polyPts.pPoints[i].x = elm->c.polyPts.pPoints[i].x+xoff;
+ newElm->c.polyPts.pPoints[i].y = elm->c.polyPts.pPoints[i].y+yoff;
+ }
+ break;
+ case PolySegmentCmd:
+ newElm->c.segments.pSegments =
+ (xSegment *)xalloc(elm->c.segments.nSegments*sizeof(xSegment));
+ for( i=0 ; i<elm->c.segments.nSegments ; i++ )
+ {
+ newElm->c.segments.pSegments[i].x1 =
+ elm->c.segments.pSegments[i].x1+xoff;
+ newElm->c.segments.pSegments[i].y1 =
+ elm->c.segments.pSegments[i].y1+yoff;
+ newElm->c.segments.pSegments[i].x2 =
+ elm->c.segments.pSegments[i].x2+xoff;
+ newElm->c.segments.pSegments[i].y2 =
+ elm->c.segments.pSegments[i].y2+yoff;
+ }
+ break;
+ case PolyRectangleCmd:
+ newElm->c.rects.pRects =
+ (xRectangle *)xalloc(elm->c.rects.nRects*sizeof(xRectangle));
+ for( i=0 ; i<elm->c.rects.nRects ; i++ )
+ {
+ newElm->c.rects.pRects[i].x = elm->c.rects.pRects[i].x+xoff;
+ newElm->c.rects.pRects[i].y = elm->c.rects.pRects[i].y+yoff;
+ newElm->c.rects.pRects[i].width = elm->c.rects.pRects[i].width;
+ newElm->c.rects.pRects[i].height = elm->c.rects.pRects[i].height;
+ }
+ break;
+ case FillPolygonCmd:
+ newElm->c.polyPts.pPoints =
+ (xPoint *)xalloc(elm->c.polyPts.nPoints*sizeof(xPoint));
+ for( i=0 ; i<elm->c.polyPts.nPoints ; i++ )
+ {
+ newElm->c.polyPts.pPoints[i].x = elm->c.polyPts.pPoints[i].x+xoff;
+ newElm->c.polyPts.pPoints[i].y = elm->c.polyPts.pPoints[i].y+yoff;
+ }
+ break;
+ case PolyFillRectCmd:
+ newElm->c.rects.pRects =
+ (xRectangle *)xalloc(elm->c.rects.nRects*sizeof(xRectangle));
+ for( i=0 ; i<elm->c.rects.nRects ; i++ )
+ {
+ newElm->c.rects.pRects[i].x = elm->c.rects.pRects[i].x+xoff;
+ newElm->c.rects.pRects[i].y = elm->c.rects.pRects[i].y+yoff;
+ newElm->c.rects.pRects[i].width = elm->c.rects.pRects[i].width;
+ newElm->c.rects.pRects[i].height = elm->c.rects.pRects[i].height;
+ }
+ break;
+ case PolyArcCmd:
+ newElm->c.arcs.pArcs =
+ (xArc *)xalloc(elm->c.arcs.nArcs*sizeof(xArc));
+ for( i=0 ; i<elm->c.arcs.nArcs ; i++ )
+ {
+ newElm->c.arcs.pArcs[i].x = elm->c.arcs.pArcs[i].x+xoff;
+ newElm->c.arcs.pArcs[i].y = elm->c.arcs.pArcs[i].y+yoff;
+ newElm->c.arcs.pArcs[i].width = elm->c.arcs.pArcs[i].width;
+ newElm->c.arcs.pArcs[i].height = elm->c.arcs.pArcs[i].height;
+ newElm->c.arcs.pArcs[i].angle1 = elm->c.arcs.pArcs[i].angle1;
+ newElm->c.arcs.pArcs[i].angle2 = elm->c.arcs.pArcs[i].angle2;
+ }
+ break;
+ case PolyFillArcCmd:
+ newElm->c.arcs.pArcs =
+ (xArc *)xalloc(elm->c.arcs.nArcs*sizeof(xArc));
+ for( i=0 ; i<elm->c.arcs.nArcs ; i++ )
+ {
+ newElm->c.arcs.pArcs[i].x = elm->c.arcs.pArcs[i].x+xoff;
+ newElm->c.arcs.pArcs[i].y = elm->c.arcs.pArcs[i].y+yoff;
+ newElm->c.arcs.pArcs[i].width = elm->c.arcs.pArcs[i].width;
+ newElm->c.arcs.pArcs[i].height = elm->c.arcs.pArcs[i].height;
+ newElm->c.arcs.pArcs[i].angle1 = elm->c.arcs.pArcs[i].angle1;
+ newElm->c.arcs.pArcs[i].angle2 = elm->c.arcs.pArcs[i].angle2;
+ }
+ break;
+ case Text8Cmd:
+ case TextI8Cmd:
+ newElm->c.text8.string = (char *)xalloc(elm->c.text8.count);
+ memcpy(newElm->c.text8.string, elm->c.text8.string, elm->c.text8.count);
+ newElm->c.text8.x += xoff;
+ newElm->c.text8.y += yoff;
+ break;
+ case Text16Cmd:
+ case TextI16Cmd:
+ newElm->c.text16.string =
+ (unsigned short *)xalloc(elm->c.text16.count*sizeof(unsigned short));
+ memcpy(newElm->c.text16.string, elm->c.text16.string,
+ elm->c.text16.count*sizeof(unsigned short));
+ newElm->c.text16.x += xoff;
+ newElm->c.text16.y += yoff;
+ break;
+ case PutImageCmd:
+ size = PixmapBytePad(elm->c.image.w, elm->c.image.depth)*elm->c.image.h;
+ newElm->c.image.pData = (char *)xalloc(size);
+ memcpy(newElm->c.image.pData, elm->c.image.pData, size);
+ newElm->c.image.x += xoff;
+ newElm->c.image.y += yoff;
+ break;
+ case BeginFrameCmd:
+ case EndFrameCmd:
+ status = 1;
+ break;
+ }
+ return(status);
+}
+
+void
+PsCopyDisplayList(PixmapPtr src, PixmapPtr dst, int xoff, int yoff,
+ int x, int y, int w, int h)
+{
+ PsPixmapPrivPtr sPriv = (PsPixmapPrivPtr)src->devPrivate.ptr;
+ PsPixmapPrivPtr dPriv = (PsPixmapPrivPtr)dst->devPrivate.ptr;
+ DisplayListPtr sDisp;
+ DisplayListPtr dDisp = PsGetFreeDisplayBlock(dPriv);
+ DisplayElmPtr elm = &dDisp->elms[dDisp->nelms];
+
+ elm->type = BeginFrameCmd;
+ elm->c.frame.x = x;
+ elm->c.frame.y = y;
+ elm->c.frame.w = w;
+ elm->c.frame.h = h;
+ dDisp->nelms += 1;
+
+ sDisp = sPriv->dispList;
+ for(; sDisp ; sDisp=sDisp->next )
+ {
+ int i;
+ for( i=0,elm=sDisp->elms ; i<sDisp->nelms ; i++,elm++ )
+ {
+ dDisp = PsGetFreeDisplayBlock(dPriv);
+ if (PsCloneDisplayElm(dst, elm, &dDisp->elms[dDisp->nelms],
+ xoff, yoff)==0)
+ {
+ dDisp->nelms += 1;
+ }
+ }
+ }
+
+ dDisp = PsGetFreeDisplayBlock(dPriv);
+ elm = &dDisp->elms[dDisp->nelms];
+ elm->type = EndFrameCmd;
+ dDisp->nelms += 1;
+}
+
+PsElmPtr
+PsCreateFillElementList(PixmapPtr pix, int *nElms)
+{
+ PsElmPtr elms = (PsElmPtr)0;
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
+ DisplayListPtr disp = priv->dispList;
+ PsArcEnum styl;
+
+ *nElms = 0;
+ for(; disp ; disp=disp->next )
+ {
+ int i;
+ DisplayElmPtr elm = disp->elms;
+
+ for( i=0 ; i<disp->nelms ; i++,elm++ )
+ {
+ if( !elm->gc ) continue; /* workaround for https://freedesktop.org/bugzilla/show_bug.cgi?id=1416 */
+ if( !elm->gc->fgPixel ) continue;
+ switch(elm->type)
+ {
+ case FillPolygonCmd:
+ *nElms += 1;
+ break;
+ case PolyFillRectCmd:
+ *nElms += elm->c.rects.nRects;
+ break;
+ case PolyFillArcCmd:
+ *nElms += elm->c.arcs.nArcs;
+ break;
+ }
+ }
+ }
+
+ if( (*nElms) )
+ {
+ elms = (PsElmPtr)xcalloc(1, (*nElms)*sizeof(PsElmRec));
+ if( elms )
+ {
+ disp = priv->dispList;
+ *nElms = 0;
+ for(; disp ; disp=disp->next )
+ {
+ int i, k;
+ DisplayElmPtr elm = disp->elms;
+
+ for( i=0 ; i<disp->nelms ; i++,elm++ )
+ {
+ if( !elm->gc->fgPixel ) continue;
+ switch(elm->type)
+ {
+ case FillPolygonCmd:
+ elms[*nElms].type = PSOUT_POINTS;
+ elms[*nElms].nPoints = elm->c.polyPts.nPoints;
+ elms[*nElms].c.points =
+ (PsPointPtr)xalloc(elms[*nElms].nPoints*sizeof(PsPointRec));
+ for( k=0 ; k<elms[*nElms].nPoints ; k++ )
+ {
+ elms[*nElms].c.points[k].x = elm->c.polyPts.pPoints[k].x;
+ elms[*nElms].c.points[k].y = elm->c.polyPts.pPoints[k].y;
+ }
+ *nElms += 1;
+ break;
+ case PolyFillRectCmd:
+ for( k=0 ; k<elm->c.rects.nRects ; k++ )
+ {
+ elms[*nElms].type = PSOUT_RECT;
+ elms[*nElms].nPoints = 0;
+ elms[*nElms].c.rect.x = elm->c.rects.pRects[k].x;
+ elms[*nElms].c.rect.y = elm->c.rects.pRects[k].y;
+ elms[*nElms].c.rect.w = elm->c.rects.pRects[k].width;
+ elms[*nElms].c.rect.h = elm->c.rects.pRects[k].height;
+ *nElms += 1;
+ }
+ break;
+ case PolyFillArcCmd:
+ if( elm->gc->arcMode==ArcChord ) styl = PsChord;
+ else styl = PsPieSlice;
+ for( k=0 ; k<elm->c.rects.nRects ; k++ )
+ {
+ elms[*nElms].type = PSOUT_ARC;
+ elms[*nElms].nPoints = 0;
+ elms[*nElms].c.arc.x = elm->c.arcs.pArcs[k].x;
+ elms[*nElms].c.arc.y = elm->c.arcs.pArcs[k].y;
+ elms[*nElms].c.arc.w = elm->c.arcs.pArcs[k].width;
+ elms[*nElms].c.arc.h = elm->c.arcs.pArcs[k].height;
+ elms[*nElms].c.arc.a1 = elm->c.arcs.pArcs[k].angle1;
+ elms[*nElms].c.arc.a2 = elm->c.arcs.pArcs[k].angle2;
+ elms[*nElms].c.arc.style = styl;
+ *nElms += 1;
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ return(elms);
+}
+
+PsElmPtr
+PsCloneFillElementList(int nElms, PsElmPtr elms)
+{
+ int i;
+ PsElmPtr newElms;
+
+ newElms = (PsElmPtr)xcalloc(1, nElms*sizeof(PsElmRec));
+ if( !newElms ) return(newElms);
+ for( i=0 ; i<nElms ; i++ )
+ {
+ newElms[i] = elms[i];
+
+ if( elms[i].type==PSOUT_POINTS )
+ {
+ newElms[i].c.points =
+ (PsPointPtr)xalloc(elms[i].nPoints*sizeof(PsElmRec));
+ memcpy(newElms[i].c.points, elms[i].c.points,
+ elms[i].nPoints*sizeof(PsPointRec));
+ }
+ }
+ return(newElms);
+}
+
+void
+PsDestroyFillElementList(int nElms, PsElmPtr elms)
+{
+ int i;
+
+ for( i=0 ; i<nElms ; i++ )
+ { if( elms[i].type==PSOUT_POINTS ) xfree(elms[i].c.points); }
+
+ xfree(elms);
+}
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsPolygon.c b/nx-X11/programs/Xserver/Xprint/ps/PsPolygon.c
new file mode 100644
index 000000000..a1ae67f8d
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsPolygon.c
@@ -0,0 +1,262 @@
+/* $Xorg: PsPolygon.c,v 1.4 2001/02/09 02:04:36 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsPolygon.c
+** *
+** * Contents: Draws Polygons and Rectangles for the PS DDX
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Ps.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+
+void
+PsPolyRectangle(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nRects,
+ xRectangle *pRects)
+{
+ if( pDrawable->type==DRAWABLE_PIXMAP )
+ {
+ DisplayElmPtr elm;
+ PixmapPtr pix = (PixmapPtr)pDrawable;
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
+ DisplayListPtr disp;
+ GCPtr gc;
+
+ if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return;
+
+ disp = PsGetFreeDisplayBlock(priv);
+
+ elm = &disp->elms[disp->nelms];
+ elm->type = PolyRectangleCmd;
+ elm->gc = gc;
+ elm->c.rects.nRects = nRects;
+ elm->c.rects.pRects = (xRectangle *)xalloc(nRects*sizeof(xRectangle));
+ memcpy(elm->c.rects.pRects, pRects, nRects*sizeof(xRectangle));
+ disp->nelms += 1;
+ }
+ else
+ {
+ int i;
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return;
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ PsLineAttrs(psOut, pGC, cMap);
+ for( i=0 ; i<nRects ; i++ )
+ {
+ PsOut_DrawRect(psOut, (int)pRects[i].x, (int)pRects[i].y,
+ (int)pRects[i].width, (int)pRects[i].height);
+ }
+ }
+}
+
+void
+PsFillPolygon(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int nPoints,
+ DDXPointPtr pPoints)
+{
+ if( pDrawable->type==DRAWABLE_PIXMAP )
+ {
+ DisplayElmPtr elm;
+ PixmapPtr pix = (PixmapPtr)pDrawable;
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
+ DisplayListPtr disp;
+ GCPtr gc;
+
+ if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return;
+
+ disp = PsGetFreeDisplayBlock(priv);
+
+ elm = &disp->elms[disp->nelms];
+ elm->type = FillPolygonCmd;
+ elm->gc = gc;
+ elm->c.polyPts.mode = mode;
+ elm->c.polyPts.nPoints = nPoints;
+ elm->c.polyPts.pPoints = (xPoint *)xalloc(nPoints*sizeof(xPoint));
+ memcpy(elm->c.polyPts.pPoints, pPoints, nPoints*sizeof(xPoint));
+ disp->nelms += 1;
+ }
+ else
+ {
+ int i;
+ PsOutPtr psOut;
+ PsPointPtr pts;
+ PsRuleEnum rule;
+ ColormapPtr cMap;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return;
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsSetFillColor(pDrawable, pGC, psOut, cMap);
+ if( pGC->fillRule==EvenOddRule ) rule = PsEvenOdd;
+ else rule = PsNZWinding;
+ PsOut_FillRule(psOut, rule);
+ pts = (PsPointPtr)xalloc(sizeof(PsPointRec)*nPoints);
+ if( mode==CoordModeOrigin )
+ {
+ for( i=0 ; i<nPoints ; i++ )
+ { pts[i].x = pPoints[i].x; pts[i].y = pPoints[i].y; }
+ }
+ else
+ {
+ i = 0;
+ pts[0].x = pPoints[i].x; pts[0].y = pPoints[i].y;
+ for( i=1 ; i<nPoints ; i++ )
+ {
+ pts[i].x = pts[i-1].x+pPoints[i].x;
+ pts[i].y = pts[i-1].y+pPoints[i].y;
+ }
+ }
+ PsOut_Polygon(psOut, nPoints, pts);
+ xfree(pts);
+ }
+}
+
+void
+PsPolyFillRect(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nRects,
+ xRectangle *pRects)
+{
+ if( pDrawable->type==DRAWABLE_PIXMAP )
+ {
+ DisplayElmPtr elm;
+ PixmapPtr pix = (PixmapPtr)pDrawable;
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
+ DisplayListPtr disp;
+ GCPtr gc;
+
+#ifdef DBE
+ /* Remove previous pixmap content if we render one single rect which
+ * covers the whole pixmap surface (this optimisation was added for
+ * the double-buffer extension ("DBE") which uses |PolyFillRect()|
+ * to clear the buffer - but it makes sense in other cases, too).
+ */
+ if (nRects == 1)
+ {
+ extern Bool noDbeExtension;
+
+ if ( (pRects[0].x==0) && (pRects[0].y==0) &&
+ (pRects[0].width==pDrawable->width) && (pRects[0].height==pDrawable->height) &&
+ (pGC->fillStyle == FillSolid) &&
+ (noDbeExtension == False))
+ {
+#ifdef DEBUG_gismobile
+ ErrorF("PsPolyFillRect: scrubbing pixmap...\n");
+#endif /* DEBUG_gismobile */
+ /* Remove all content from the pixmap as it would be covered
+ * by the whole rect anyway */
+ PsScrubPixmap(pDrawable);
+ }
+ }
+#endif /* DBE */
+
+ if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return;
+
+ disp = PsGetFreeDisplayBlock(priv);
+
+ elm = &disp->elms[disp->nelms];
+ elm->type = PolyFillRectCmd;
+ elm->gc = gc;
+ elm->c.rects.nRects = nRects;
+ elm->c.rects.pRects = (xRectangle *)xalloc(nRects*sizeof(xRectangle));
+ memcpy(elm->c.rects.pRects, pRects, nRects*sizeof(xRectangle));
+ disp->nelms += 1;
+ }
+ else
+ {
+ int i;
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return;
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsSetFillColor(pDrawable, pGC, psOut, cMap);
+ for( i=0 ; i<nRects ; i++ )
+ {
+ PsOut_FillRect(psOut, (int)pRects[i].x, (int)pRects[i].y,
+ (int)pRects[i].width, (int)pRects[i].height);
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsPrint.c b/nx-X11/programs/Xserver/Xprint/ps/PsPrint.c
new file mode 100644
index 000000000..05e8e2588
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsPrint.c
@@ -0,0 +1,462 @@
+/* $Xorg: PsPrint.c,v 1.7 2001/03/14 18:28:18 pookie Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996, 2000 Sun Microsystems, Inc. All rights reserved.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsPrint.c
+** *
+** * Contents: Print extension code of Ps driver
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <errno.h>
+#include <X11/Xprotostr.h>
+
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#undef NEED_EVENTS
+
+#include "Ps.h"
+
+#include "windowstr.h"
+#include "attributes.h"
+#include "Oid.h"
+
+/* static utility function to get document/page attributes */
+static void
+S_GetPageAttributes(XpContextPtr pCon,int *iorient,int *icount, int *iplex,
+ int *ires, unsigned short *iwd, unsigned short *iht)
+{
+ char *count;
+ XpOid orient, plex;
+ /*
+ * Get the orientation
+ */
+ orient = XpGetContentOrientation(pCon);
+ switch (orient) {
+ case xpoid_val_content_orientation_landscape:
+ *iorient = 1;
+ break;
+ case xpoid_val_content_orientation_reverse_portrait:
+ *iorient = 2;
+ break;
+ case xpoid_val_content_orientation_reverse_landscape:
+ *iorient = 3;
+ break;
+ case xpoid_val_content_orientation_portrait:
+ default:
+ *iorient = 0;
+ break;
+ }
+
+ /*
+ * Get the count
+ */
+ count = XpGetOneAttribute(pCon, XPDocAttr, "copy-count");
+ if( count )
+ {
+ int ii = sscanf(count, "%d", icount);
+ if( ii!=1 ) *icount = 1;
+ }
+ else *icount = 1;
+
+ /*
+ * Get the plex
+ */
+ plex = XpGetPlex(pCon);
+ switch(plex)
+ {
+ case xpoid_val_plex_duplex:
+ *iplex = 1;
+ break;
+ case xpoid_val_plex_tumble:
+ *iplex = 2;
+ break;
+ default:
+ *iplex = 0;
+ break;
+ }
+
+ /*
+ * Get the resolution and media size
+ */
+ *ires = XpGetResolution(pCon);
+ XpGetMediumDimensions(pCon, iwd, iht);
+}
+
+
+int
+PsStartJob(
+ XpContextPtr pCon,
+ Bool sendClientData,
+ ClientPtr client)
+{
+ PsContextPrivPtr pConPriv =
+ (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+
+ /*
+ * Create a temporary file to store the printer output.
+ */
+ if (!XpOpenTmpFile("w", &pConPriv->jobFileName, &pConPriv->pJobFile))
+ return BadAlloc;
+
+ return Success;
+}
+
+
+
+/* I thought about making this following code into a set of routines
+ or using a goto, or something, but in the end decided not to,
+ because the plain old listing here makes the logic clearer. */
+int
+PsEndJob(
+ XpContextPtr pCon,
+ Bool cancel)
+{
+ int r;
+ struct stat buffer;
+ int error;
+
+ PsContextPrivPtr priv =
+ (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+
+ if (cancel == True) {
+ if (priv->getDocClient != (ClientPtr) NULL) {
+ (void) XpFinishDocData( priv->getDocClient );
+
+ priv->getDocClient = NULL;
+ priv->getDocBufSize = 0;
+ }
+
+ /* job is cancelled - do we really care if we're out of space? */
+ (void) fclose(priv->pJobFile);
+ priv->pJobFile = NULL;
+
+ unlink(priv->jobFileName);
+ xfree(priv->jobFileName);
+ priv->jobFileName = (char *)NULL;
+
+ PsFreeFontInfoRecords(priv);
+
+ return Success;
+ }
+
+ /*
+ * Append any trailing information here
+ */
+ PsOut_EndFile(priv->pPsOut, 0);
+ priv->pPsOut = NULL;
+
+ /* this is where we find out if we're out of space */
+ error = (fclose(priv->pJobFile) == EOF);
+ priv->pJobFile = NULL;
+
+ /* status to the client if we have ran out of space on the disk or
+ some other resource problem with the temporary file... */
+ if (error) {
+ if (priv->getDocClient != (ClientPtr) NULL) {
+ (void) XpFinishDocData( priv->getDocClient );
+
+ priv->getDocClient = NULL;
+ priv->getDocBufSize = 0;
+ }
+
+ unlink(priv->jobFileName);
+ xfree(priv->jobFileName);
+ priv->jobFileName = (char *)NULL;
+
+ PsFreeFontInfoRecords(priv);
+
+ return BadAlloc;
+ }
+
+ /* we have finished without incident & no cancel */
+
+ if (priv->getDocClient != NULL && priv->getDocBufSize > 0) {
+ FILE *file;
+
+ file = fopen(priv->jobFileName, "r");
+ if (!file || (fstat(fileno(file), &buffer) < 0))
+ r = BadAlloc;
+ else
+ r = XpSendDocumentData(priv->getDocClient, file, buffer.st_size,
+ priv->getDocBufSize);
+ if (file)
+ fclose(file);
+
+ (void) XpFinishDocData(priv->getDocClient);
+
+ priv->getDocClient = NULL;
+ priv->getDocBufSize = 0;
+ }
+ else {
+ XpSubmitJob(priv->jobFileName, pCon);
+
+ r = Success;
+ }
+
+ unlink(priv->jobFileName);
+ xfree(priv->jobFileName);
+ priv->jobFileName = (char *)NULL;
+
+ PsFreeFontInfoRecords(priv);
+
+#ifdef BM_CACHE
+ PsBmClearImageCache();
+#endif
+
+ return r;
+}
+
+/* StartPage
+ */
+int
+PsStartPage(
+ XpContextPtr pCon,
+ WindowPtr pWin)
+{
+ int iorient, iplex, icount, ires;
+ unsigned short iwd, iht;
+ register WindowPtr pChild;
+ PsContextPrivPtr pConPriv =
+ (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+ PsWindowPrivPtr pWinPriv =
+ (PsWindowPrivPtr)pWin->devPrivates[PsWindowPrivateIndex].ptr;
+ char s[80];
+ xEvent event;
+
+/*
+ * Put a pointer to the context in the window private structure
+ */
+ pWinPriv->validContext = 1;
+ pWinPriv->context = pCon;
+
+ /* get page level attributes */
+ S_GetPageAttributes(pCon,&iorient,&icount,&iplex,&ires,&iwd,&iht);
+ /*
+ * Start the page
+ */
+ if (pConPriv->pPsOut == NULL) {
+ char *title;
+
+ /* get job level attributes */
+ title = XpGetOneAttribute(pCon, XPJobAttr, "job-name");
+
+ pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile,
+ title, iorient, icount, iplex, ires,
+ (int)iwd, (int)iht, False);
+ pConPriv->fontInfoRecords = NULL;
+ pConPriv->fontTypeInfoRecords = NULL;
+ }
+ PsOut_BeginPage(pConPriv->pPsOut, iorient, icount, iplex, ires,
+ (int)iwd, (int)iht);
+
+ return Success;
+}
+
+
+/*
+ * EndPage:
+ *
+ * Write page trailer to page file
+ * Write page file to job file
+ */
+int
+PsEndPage(
+ XpContextPtr pCon,
+ WindowPtr pWin)
+{
+ PsWindowPrivPtr pWinPriv =
+ (PsWindowPrivPtr)pWin->devPrivates[PsWindowPrivateIndex].ptr;
+ PsContextPrivPtr pConPriv =
+ (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+
+ PsOut_EndPage(pConPriv->pPsOut);
+
+ pWinPriv->validContext = 0;
+ pWinPriv->context = NULL;
+
+ /* status to the client if we have ran out of space on the disk or
+ some other resource problem with the temporary file... */
+/* if (ferror(pConPriv->pJobFile)) return BadAlloc; */
+
+ return Success;
+}
+
+/*
+ * The PsStartDoc() and PsEndDoc() functions serve basically as NOOP
+ * placeholders. This driver doesn't deal with the notion of multiple
+ * documents per page.
+ */
+
+int
+PsStartDoc(XpContextPtr pCon, XPDocumentType type)
+{
+ int iorient, iplex, icount, ires;
+ unsigned short iwd, iht;
+ char *title;
+ PsContextPrivPtr pConPriv =
+ (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+
+ /* get job level attributes */
+ title = XpGetOneAttribute(pCon, XPJobAttr, "job-name");
+
+ /* get document level attributes */
+ S_GetPageAttributes(pCon,&iorient,&icount,&iplex,&ires,&iwd,&iht);
+
+ pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile,
+ title, iorient, icount, iplex, ires,
+ (int)iwd, (int)iht, (Bool)(type == XPDocRaw));
+
+ pConPriv->fontInfoRecords = NULL;
+ pConPriv->fontTypeInfoRecords = NULL;
+
+ return Success;
+}
+
+int
+PsEndDoc(
+ XpContextPtr pCon,
+ Bool cancel)
+{
+ return Success;
+}
+
+/*
+ * PsDocumentData()
+ *
+ * Hand any pre-generated PDL down to the spool files, formatting it
+ * as necessary to fit the given window.
+ */
+
+int
+PsDocumentData(
+ XpContextPtr pCon,
+ DrawablePtr pDraw,
+ char *pData,
+ int len_data,
+ char *pFmt,
+ int len_fmt,
+ char *pOpt,
+ int len_opt,
+ ClientPtr client)
+{
+ PsContextPrivPtr cPriv;
+ PsOutPtr psOut;
+
+ if (len_fmt != 12 ||
+ strncasecmp(pFmt, "PostScript 2", len_fmt) != 0 ||
+ len_opt)
+ return BadValue;
+
+ cPriv = pCon->devPrivates[PsContextPrivateIndex].ptr;
+ psOut = cPriv->pPsOut;
+
+ if (pDraw)
+ PsOut_BeginFrame(psOut, 0, 0, pDraw->x, pDraw->y,
+ pDraw->width, pDraw->height);
+ PsOut_RawData(psOut, pData, len_data);
+ if (pDraw)
+ PsOut_EndFrame(psOut);
+
+ return Success;
+}
+
+/*
+ *
+ * PsGetDocumentData()
+ *
+ * This function allows the driver to send the generated PS back to
+ * the client.
+ */
+
+int
+PsGetDocumentData(
+ XpContextPtr pCon,
+ ClientPtr client,
+ int maxBufferSize)
+{
+ PsContextPrivPtr pPriv = (PsContextPrivPtr)
+ pCon->devPrivates[PsContextPrivateIndex].ptr;
+
+ pPriv->getDocClient = client;
+ pPriv->getDocBufSize = maxBufferSize;
+
+ return Success;
+}
+
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsSpans.c b/nx-X11/programs/Xserver/Xprint/ps/PsSpans.c
new file mode 100644
index 000000000..d7652f8fb
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsSpans.c
@@ -0,0 +1,166 @@
+/* $Xorg: PsSpans.c,v 1.4 2001/02/09 02:04:36 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsSpans.c
+** *
+** * Contents: Code to set and fill spans in the PS DDX
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+/* $XFree86: xc/programs/Xserver/Xprint/ps/PsSpans.c,v 1.8 2001/10/28 03:32:56 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Ps.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+
+void
+PsFillSpans(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nSpans,
+ DDXPointPtr pPoints,
+ int *pWidths,
+ int fSorted)
+{
+ PsOutPtr psOut;
+ int xoffset, yoffset;
+ xRectangle *rects, *r;
+ RegionPtr fillRegion, region = 0;
+ int i;
+ int nbox;
+ BoxPtr pbox;
+ ColormapPtr cMap;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return;
+
+ /*
+ * Build a region out of the spans
+ */
+ rects = (xRectangle *)xalloc(nSpans*sizeof(xRectangle));
+ xoffset = pDrawable->x;
+ yoffset = pDrawable->y;
+
+ for( i = 0, r = rects; i < nSpans; i++, r++ )
+ {
+ r->x = pPoints[i].x + xoffset;
+ r->y = pPoints[i].y + yoffset;
+ r->width = pWidths[i];
+ r->height = 1;
+ }
+ fillRegion = RECTS_TO_REGION(pGC->pScreen, nSpans, rects,
+ (fSorted)?CT_YSORTED:CT_UNSORTED);
+
+ /*
+ * Intersect this region with the clip region. Whatever's left,
+ * should be filled.
+ */
+/*REGION_INTERSECT(pGC->pScreen, region, fillRegion, pGC->clientClip);*/
+
+ pbox = REGION_RECTS(region);
+ nbox = REGION_NUM_RECTS(region);
+
+ /* Enter HP-GL/2 */
+ /*###SEND_PCL( outFile, "\27%0B" );*/
+
+ while( nbox )
+ {
+/*###
+ sprintf( t, "PU%d,%d;RR%d,%d;", pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+ SEND_PCL( outFile, t );
+*/
+ nbox--;
+ pbox++;
+ }
+
+ /* Go back to PCL */
+ /*###SEND_PCL( outFile, "\27%0A" );*/
+
+ /*
+ * Clean up the temporary regions
+ */
+ REGION_DESTROY(pGC->pScreen, fillRegion);
+ REGION_DESTROY(pGC->pScreen, region);
+ xfree(rects);
+}
+
+void
+PsSetSpans(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *pSrc,
+ DDXPointPtr pPoints,
+ int *pWidths,
+ int nSpans,
+ int fSorted)
+{
+}
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsText.c b/nx-X11/programs/Xserver/Xprint/ps/PsText.c
new file mode 100644
index 000000000..228e407dc
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsText.c
@@ -0,0 +1,586 @@
+/* $Xorg: PsText.c,v 1.7 2001/02/09 02:04:36 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsText.c
+** *
+** * Contents: Character-drawing routines for the PS DDX
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Ps.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include <X11/fonts/fntfil.h>
+#include <X11/fonts/fntfilst.h>
+#include <limits.h>
+
+int
+PsPolyText8(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *string)
+{
+ if( pDrawable->type==DRAWABLE_PIXMAP )
+ {
+ DisplayElmPtr elm;
+ PixmapPtr pix = (PixmapPtr)pDrawable;
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
+ DisplayListPtr disp;
+ GCPtr gc;
+
+ if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return x;
+
+ disp = PsGetFreeDisplayBlock(priv);
+
+ elm = &disp->elms[disp->nelms];
+ elm->type = Text8Cmd;
+ elm->gc = gc;
+ elm->c.text8.x = x;
+ elm->c.text8.y = y;
+ elm->c.text8.count = count;
+ elm->c.text8.string = (char *)xalloc(count);
+ memcpy(elm->c.text8.string, string, count);
+ disp->nelms += 1;
+
+ return x;
+ }
+ else
+ {
+ PsFontInfoRec *firec;
+
+ /* We need a context for rendering... */
+ if (PsGetPsContextPriv(pDrawable) == NULL)
+ return x;
+
+ firec = PsGetFontInfoRec(pDrawable, pGC->font);
+ if (!firec)
+ return x;
+
+#ifdef XP_USE_FREETYPE
+ if (firec->ftir->downloadableFont &&
+ (firec->ftir->font_type == PSFTI_FONT_TYPE_FREETYPE))
+ {
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE )
+ return x;
+
+ if (firec->ftir->alreadyDownloaded[0] == False)
+ {
+ PsOut_DownloadFreeType(psOut,
+ firec->ftir->ft_download_font_type,
+ firec->ftir->download_ps_name, pGC->font, 0);
+ firec->ftir->alreadyDownloaded[0] = True;
+ }
+
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ if (!firec->size)
+ PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding);
+ else
+ PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding);
+ PsOut_FreeType_Text(pGC->font, psOut, x, y, string, count);
+
+ return x;
+ }
+ else
+#endif /* XP_USE_FREETYPE */
+ if (firec->ftir->downloadableFont &&
+ (firec->ftir->font_type != PSFTI_FONT_TYPE_FREETYPE))
+ {
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE )
+ return x;
+
+ if (firec->ftir->alreadyDownloaded[0] == False)
+ {
+ PsOut_DownloadType1(psOut, "PsPolyText8",
+ firec->ftir->download_ps_name, firec->ftir->filename);
+ firec->ftir->alreadyDownloaded[0] = True;
+ }
+
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ if (!firec->size)
+ PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding);
+ else
+ PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding);
+ PsOut_Text(psOut, x, y, string, count, -1);
+
+ return x;
+ }
+
+ /* Render glyphs as bitmaps */
+ {
+ unsigned long n, i;
+ int w;
+ CharInfoPtr charinfo[255];
+
+ GetGlyphs(pGC->font, (unsigned long)count,
+ (unsigned char *)string, Linear8Bit, &n, charinfo);
+ w = 0;
+ for (i=0; i < n; i++)
+ w += charinfo[i]->metrics.characterWidth;
+
+ if (n != 0)
+ PsPolyGlyphBlt(pDrawable, pGC, x, y, n,
+ charinfo, FONTGLYPHS(pGC->font));
+ x += w;
+
+ return x;
+ }
+ }
+ return x;
+}
+
+int
+PsPolyText16(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *string)
+{
+ if( pDrawable->type==DRAWABLE_PIXMAP )
+ {
+ DisplayElmPtr elm;
+ PixmapPtr pix = (PixmapPtr)pDrawable;
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
+ DisplayListPtr disp;
+ GCPtr gc;
+
+ if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return x;
+
+ disp = PsGetFreeDisplayBlock(priv);
+
+ elm = &disp->elms[disp->nelms];
+ elm->type = Text16Cmd;
+ elm->gc = gc;
+ elm->c.text16.x = x;
+ elm->c.text16.y = y;
+ elm->c.text16.count = count;
+ elm->c.text16.string =
+ (unsigned short *)xalloc(count*sizeof(unsigned short));
+ memcpy(elm->c.text16.string, string, count*sizeof(unsigned short));
+ disp->nelms += 1;
+
+ return x;
+ }
+ else
+ {
+ PsFontInfoRec *firec;
+
+ /* We need a context for rendering... */
+ if (PsGetPsContextPriv(pDrawable) == NULL)
+ return x;
+
+ firec = PsGetFontInfoRec(pDrawable, pGC->font);
+ if (!firec)
+ return x;
+
+#ifdef XP_USE_FREETYPE
+ if (firec->ftir->downloadableFont &&
+ (firec->ftir->font_type == PSFTI_FONT_TYPE_FREETYPE))
+ {
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+ unsigned short c,
+ c_hiByte,
+ c_lowByte,
+ fontPage;
+ int i;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE )
+ return x;
+
+ /* Scan the string we want to render and download all neccesary parts
+ * of the font (one part(="font page") has 256 glyphs)
+ */
+ for( i = 0 ; i < count ; i++ )
+ {
+ c = string[i];
+#if IMAGE_BYTE_ORDER == LSBFirst
+ c_hiByte = c & 0x00FF;
+ c_lowByte = (c >> 8) & 0x00FF;
+#elif IMAGE_BYTE_ORDER == MSBFirst
+ c_hiByte = (c >> 8) & 0x00FF;
+ c_lowByte = c & 0x00FF;
+#else
+#error Unsupported byte order
+#endif
+ fontPage = c_hiByte;
+
+ if (firec->ftir->alreadyDownloaded[fontPage] == False)
+ {
+ char buffer[256];
+ const char *ps_name;
+
+ if (fontPage > 0)
+ {
+ sprintf(buffer, "%s_%x", firec->ftir->download_ps_name, (int)fontPage);
+ ps_name = buffer;
+ }
+ else
+ {
+ ps_name = firec->ftir->download_ps_name;
+ }
+
+ PsOut_DownloadFreeType(psOut,
+ firec->ftir->ft_download_font_type,
+ ps_name, pGC->font, (fontPage * 0x100)); /* same as (fontPage << 8) */
+
+ firec->ftir->alreadyDownloaded[fontPage] = True;
+ }
+ }
+
+
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ if (!firec->size)
+ PsOut_FreeType_TextAttrsMtx16(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding);
+ else
+ PsOut_FreeType_TextAttrs16(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding);
+ PsOut_FreeType_Text16(pGC->font, psOut, x, y, string, count);
+
+ return x;
+ }
+ else
+#endif /* XP_USE_FREETYPE */
+ if (firec->ftir->downloadableFont &&
+ (firec->ftir->font_type != PSFTI_FONT_TYPE_FREETYPE))
+ {
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+ unsigned short c,
+ c_hiByte,
+ c_lowByte,
+ fontPage;
+ int i;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE )
+ return x;
+
+ PsOut_DownloadType1(psOut, "PsPolyText16",
+ firec->ftir->download_ps_name, firec->ftir->filename);
+ firec->ftir->alreadyDownloaded[fontPage] = True;
+
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ if (!firec->size)
+ PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding);
+ else
+ PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding);
+ PsOut_Text16(psOut, x, y, string, count, -1);
+
+ return x;
+ }
+
+ /* Render glyphs as bitmaps */
+ {
+ unsigned long n, i;
+ int w;
+ CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */
+
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)string,
+ (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
+ &n, charinfo);
+ w = 0;
+ for (i=0; i < n; i++)
+ w += charinfo[i]->metrics.characterWidth;
+ if (n != 0)
+ PsPolyGlyphBlt(pDrawable, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font));
+ x += w;
+
+ return x;
+ }
+ }
+ return x;
+}
+
+void
+PsImageText8(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *string)
+{
+ if( pDrawable->type==DRAWABLE_PIXMAP )
+ {
+ DisplayElmPtr elm;
+ PixmapPtr pix = (PixmapPtr)pDrawable;
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
+ DisplayListPtr disp;
+ GCPtr gc;
+
+ if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return;
+
+ disp = PsGetFreeDisplayBlock(priv);
+
+ elm = &disp->elms[disp->nelms];
+ elm->type = TextI8Cmd;
+ elm->gc = gc;
+ elm->c.text8.x = x;
+ elm->c.text8.y = y;
+ elm->c.text8.count = count;
+ elm->c.text8.string = (char *)xalloc(count);
+ memcpy(elm->c.text8.string, string, count);
+ disp->nelms += 1;
+ }
+ else
+ {
+ int iso;
+ int siz;
+ float mtx[4];
+ char *fnam;
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return;
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ fnam = PsGetPSFontName(pGC->font);
+ if( !fnam ) fnam = "Times-Roman";
+ siz = PsGetFontSize(pGC->font, mtx);
+ iso = PsIsISOLatin1Encoding(pGC->font);
+ if( !siz ) PsOut_TextAttrsMtx(psOut, fnam, mtx, iso);
+ else PsOut_TextAttrs(psOut, fnam, siz, iso);
+ PsOut_Text(psOut, x, y, string, count, PsGetPixelColor(cMap, pGC->bgPixel));
+ }
+}
+
+void
+PsImageText16(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *string)
+{
+ if( pDrawable->type==DRAWABLE_PIXMAP )
+ {
+ DisplayElmPtr elm;
+ PixmapPtr pix = (PixmapPtr)pDrawable;
+ PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr;
+ DisplayListPtr disp;
+ GCPtr gc;
+
+ if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return;
+
+ disp = PsGetFreeDisplayBlock(priv);
+
+ elm = &disp->elms[disp->nelms];
+ elm->type = TextI16Cmd;
+ elm->gc = gc;
+ elm->c.text16.x = x;
+ elm->c.text16.y = y;
+ elm->c.text16.count = count;
+ elm->c.text16.string =
+ (unsigned short *)xalloc(count*sizeof(unsigned short));
+ memcpy(elm->c.text16.string, string, count*sizeof(unsigned short));
+ disp->nelms += 1;
+ }
+ else
+ {
+ int i;
+ char *str;
+ if( !count ) return;
+ str = (char *)xalloc(count);
+ for( i=0 ; i<count ; i++ ) str[i] = string[i];
+ PsImageText8(pDrawable, pGC, x, y, count, str);
+ free(str);
+ }
+}
+
+void
+PsImageGlyphBlt(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nGlyphs,
+ CharInfoPtr *pCharInfo,
+ pointer pGlyphBase)
+{
+ /* NOT TO BE IMPLEMENTED */
+}
+
+void
+PsPolyGlyphBlt(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nGlyphs,
+ CharInfoPtr *pCharInfo,
+ pointer pGlyphBase)
+{
+ int width, height;
+ PixmapPtr pPixmap;
+ int nbyLine; /* bytes per line of padded pixmap */
+ FontPtr pfont;
+ GCPtr pGCtmp;
+ register int i;
+ register int j;
+ unsigned char *pbits; /* buffer for PutImage */
+ register unsigned char *pb; /* temp pointer into buffer */
+ register CharInfoPtr pci; /* currect char info */
+ register unsigned char *pglyph; /* pointer bits in glyph */
+ int gWidth, gHeight; /* width and height of glyph */
+ register int nbyGlyphWidth; /* bytes per scanline of glyph */
+ int nbyPadGlyph; /* server padded line of glyph */
+ int w, tmpx;
+ XID gcvals[3];
+
+ pfont = pGC->font;
+ width = FONTMAXBOUNDS(pfont,rightSideBearing) -
+ FONTMINBOUNDS(pfont,leftSideBearing);
+ height = FONTMAXBOUNDS(pfont,ascent) +
+ FONTMAXBOUNDS(pfont,descent);
+
+ if ((width == 0) || (height == 0) )
+ return;
+ {
+ int i;
+ w = 0;
+ for (i=0; i < nGlyphs; i++) w += pCharInfo[i]->metrics.characterWidth;
+ }
+ pGCtmp = GetScratchGC(1, pDrawable->pScreen);
+ if (!pGCtmp)
+ {
+ (*pDrawable->pScreen->DestroyPixmap)(pPixmap);
+ return;
+ }
+
+ gcvals[0] = GXcopy;
+ gcvals[1] = pGC->fgPixel;
+ gcvals[2] = pGC->bgPixel;
+
+ DoChangeGC(pGCtmp, GCFunction|GCForeground|GCBackground, gcvals, 0);
+
+
+ nbyLine = BitmapBytePad(width);
+ pbits = (unsigned char *)ALLOCATE_LOCAL(height*nbyLine);
+ if (!pbits){
+ PsDestroyPixmap(pPixmap);
+ return;
+ }
+ tmpx = 0;
+ while(nGlyphs--)
+ {
+ pci = *pCharInfo++;
+ pglyph = FONTGLYPHBITS(pGlyphBase, pci);
+ gWidth = GLYPHWIDTHPIXELS(pci);
+ gHeight = GLYPHHEIGHTPIXELS(pci);
+ if (gWidth && gHeight)
+ {
+ nbyGlyphWidth = GLYPHWIDTHBYTESPADDED(pci);
+ nbyPadGlyph = BitmapBytePad(gWidth);
+
+ if (nbyGlyphWidth == nbyPadGlyph
+#if GLYPHPADBYTES != 4
+ && (((int) pglyph) & 3) == 0
+#endif
+ )
+ {
+ pb = pglyph;
+ }
+ else
+ {
+ for (i=0, pb = pbits; i<gHeight; i++, pb = pbits+(i*nbyPadGlyph))
+ for (j = 0; j < nbyGlyphWidth; j++)
+ *pb++ = *pglyph++;
+ pb = pbits;
+ }
+
+ PsPutImageMask((DrawablePtr)pDrawable, pGCtmp,
+ 1, x + pci->metrics.leftSideBearing,
+ y - pci->metrics.ascent, gWidth, gHeight,
+ 0, XYBitmap, (char *)pb);
+ }
+
+ x += pci->metrics.characterWidth;
+ }
+ DEALLOCATE_LOCAL(pbits);
+ FreeScratchGC(pGCtmp);
+}
diff --git a/nx-X11/programs/Xserver/Xprint/ps/PsWindow.c b/nx-X11/programs/Xserver/Xprint/ps/PsWindow.c
new file mode 100644
index 000000000..313e51f31
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/PsWindow.c
@@ -0,0 +1,462 @@
+/* $Xorg: PsWindow.c,v 1.4 2001/02/09 02:04:36 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PsWindow.c
+** *
+** * Contents: Window code for PS driver.
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/wait.h>
+
+#include "mistruct.h"
+#include "regionstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+
+#include "Ps.h"
+
+extern WindowPtr *WindowTable;
+
+/*
+ * The following list of strings defines the properties which will be
+ * placed on the screen's root window if the property was defined in
+ * the start-up configuration resource database.
+ */
+static char *propStrings[] = {
+ DT_PRINT_JOB_HEADER,
+ DT_PRINT_JOB_TRAILER,
+ DT_PRINT_JOB_COMMAND,
+ DT_PRINT_JOB_EXEC_COMMAND,
+ DT_PRINT_JOB_EXEC_OPTIONS,
+ DT_PRINT_PAGE_HEADER,
+ DT_PRINT_PAGE_TRAILER,
+ DT_PRINT_PAGE_COMMAND,
+ (char *)NULL
+};
+
+
+/*
+ * PsCreateWindow - watch for the creation of the root window.
+ * When it's created, register the screen with the print extension,
+ * and put the default command/header properties on it.
+ */
+/*ARGSUSED*/
+
+Bool
+PsCreateWindow(WindowPtr pWin)
+{
+ PsWindowPrivPtr pPriv;
+
+#if 0
+ Bool status = Success;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PsScreenPrivPtr pScreenPriv = (PsScreenPrivPtr)
+ pScreen->devPrivates[PsScreenPrivateIndex].ptr;
+ PsWindowPrivPtr pWinPriv = (PsWindowPrivPtr)
+ pWin->devPrivates[PsWindowPrivateIndex].ptr;
+
+ /*
+ * Initialize this window's private struct.
+ */
+ pWinPriv->jobFileName = (char *)NULL;
+ pWinPriv->pJobFile = (FILE *)NULL;
+ pWinPriv->pageFileName = (char *)NULL;
+ pWinPriv->pPageFile = (FILE *)NULL;
+
+ if(pWin->parent == (WindowPtr)NULL) /* root window? */
+ {
+ Atom propName; /* type = XA_STRING */
+ char *propVal;
+ int i;
+ XrmDatabase rmdb = pScreenPriv->resDB;
+
+ /*
+ * Put the defaults spec'd in the config files in properties on this
+ * screen's root window.
+ */
+ for(i = 0; propStrings[i] != (char *)NULL; i++)
+ {
+ if((propVal = _DtPrintGetPrinterResource(pWin, rmdb,
+ propStrings[i])) !=
+ (char *)NULL)
+ {
+ propName = MakeAtom(propStrings[i], strlen(propStrings[i]),
+ TRUE);
+ ChangeWindowProperty(pWin, propName, XA_STRING, 8,
+ PropModeReplace, strlen(propVal),
+ (pointer)propVal, FALSE);
+ xfree(propVal);
+ }
+ }
+ }
+
+ return status;
+#endif
+
+ pPriv = (PsWindowPrivPtr)pWin->devPrivates[PsWindowPrivateIndex].ptr;
+ pPriv->validContext = 0;
+
+ return TRUE;
+}
+
+
+/*ARGSUSED*/
+Bool PsMapWindow(WindowPtr pWindow)
+{
+ return TRUE;
+}
+
+/*ARGSUSED*/
+Bool
+PsPositionWindow(
+ WindowPtr pWin,
+ int x,
+ int y)
+{
+ return TRUE;
+}
+
+/*ARGSUSED*/
+Bool
+PsUnmapWindow(WindowPtr pWindow)
+{
+ return TRUE;
+}
+
+/*ARGSUSED*/
+void
+PsCopyWindow(
+ WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc)
+{
+}
+
+/*ARGSUSED*/
+Bool
+PsChangeWindowAttributes(
+ WindowPtr pWin,
+ unsigned long mask)
+{
+ return TRUE;
+}
+
+
+void
+PsPaintWindow(
+ WindowPtr pWin,
+ RegionPtr pRegion,
+ int what)
+{
+ int status;
+ WindowPtr pRoot;
+
+#define FUNCTION 0
+#define FOREGROUND 1
+#define TILE 2
+#define FILLSTYLE 3
+#define ABSX 4
+#define ABSY 5
+#define CLIPMASK 6
+#define SUBWINDOW 7
+#define COUNT_BITS 8
+
+ pointer gcval[7];
+ pointer newValues [COUNT_BITS];
+
+ BITS32 gcmask, index, mask;
+ RegionRec prgnWin;
+ DDXPointRec oldCorner;
+ BoxRec box;
+ WindowPtr pBgWin;
+ GCPtr pGC;
+ register int i;
+ register BoxPtr pbox;
+ register ScreenPtr pScreen = pWin->drawable.pScreen;
+ register xRectangle *prect;
+ int numRects;
+
+ gcmask = 0;
+
+ /*
+ * We don't want to paint a window that has no place to put the
+ * PS output.
+ */
+ if( PsGetContextFromWindow(pWin)==(XpContextPtr)NULL ) return;
+
+ if( what==PW_BACKGROUND )
+ {
+ switch(pWin->backgroundState)
+ {
+ case None: return;
+ case ParentRelative:
+ (*pWin->parent->drawable.pScreen->PaintWindowBackground)
+ (pWin->parent, pRegion, what);
+ return;
+ case BackgroundPixel:
+ newValues[FOREGROUND] = (pointer)pWin->background.pixel;
+ newValues[FILLSTYLE] = (pointer)FillSolid;
+ gcmask |= GCForeground | GCFillStyle;
+ break;
+ case BackgroundPixmap:
+ newValues[TILE] = (pointer)pWin->background.pixmap;
+ newValues[FILLSTYLE] = (pointer)FillTiled;
+ gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
+ break;
+ }
+ }
+ else
+ {
+ if( pWin->borderIsPixel )
+ {
+ newValues[FOREGROUND] = (pointer)pWin->border.pixel;
+ newValues[FILLSTYLE] = (pointer)FillSolid;
+ gcmask |= GCForeground | GCFillStyle;
+ }
+ else
+ {
+ newValues[TILE] = (pointer)pWin->border.pixmap;
+ newValues[FILLSTYLE] = (pointer)FillTiled;
+ gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
+ }
+ }
+
+ prect = (xRectangle *)ALLOCATE_LOCAL(REGION_NUM_RECTS(pRegion) *
+ sizeof(xRectangle));
+ if( !prect ) return;
+
+ newValues[FUNCTION] = (pointer)GXcopy;
+ gcmask |= GCFunction | GCClipMask;
+
+ i = pScreen->myNum;
+ pRoot = WindowTable[i];
+
+ pBgWin = pWin;
+ if (what == PW_BORDER)
+ {
+ while( pBgWin->backgroundState==ParentRelative ) pBgWin = pBgWin->parent;
+ }
+
+ pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
+ if( !pGC )
+ {
+ DEALLOCATE_LOCAL(prect);
+ return;
+ }
+ /*
+ * mash the clip list so we can paint the border by
+ * mangling the window in place, pretending it
+ * spans the entire screen
+ */
+ if( what==PW_BORDER )
+ {
+ prgnWin = pWin->clipList;
+ oldCorner.x = pWin->drawable.x;
+ oldCorner.y = pWin->drawable.y;
+ pWin->drawable.x = pWin->drawable.y = 0;
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pScreen->width;
+ box.y2 = pScreen->height;
+ REGION_INIT(pScreen, &pWin->clipList, &box, 1);
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ newValues[ABSX] = (pointer)(long)pBgWin->drawable.x;
+ newValues[ABSY] = (pointer)(long)pBgWin->drawable.y;
+ }
+ else
+ {
+ newValues[ABSX] = (pointer)0;
+ newValues[ABSY] = (pointer)0;
+ }
+
+/*
+ * XXX Backing store is turned off for the PS driver
+
+ if( pWin->backStorage )
+ (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack);
+ */
+
+ mask = gcmask;
+ gcmask = 0;
+ i = 0;
+ while( mask )
+ {
+ index = lowbit (mask);
+ mask &= ~index;
+ switch(index)
+ {
+ case GCFunction:
+ if( (pointer)(long)pGC->alu!=newValues[FUNCTION] )
+ {
+ gcmask |= index;
+ gcval[i++] = newValues[FUNCTION];
+ }
+ break;
+ case GCTileStipXOrigin:
+ if( (pointer)(long)pGC->patOrg.x!=newValues[ABSX] )
+ {
+ gcmask |= index;
+ gcval[i++] = newValues[ABSX];
+ }
+ break;
+ case GCTileStipYOrigin:
+ if( (pointer)(long)pGC->patOrg.y!=newValues[ABSY] )
+ {
+ gcmask |= index;
+ gcval[i++] = newValues[ABSY];
+ }
+ break;
+ case GCClipMask:
+ if( (pointer)pGC->clientClipType!=(pointer)CT_NONE )
+ {
+ gcmask |= index;
+ gcval[i++] = (pointer)CT_NONE;
+ }
+ break;
+ case GCSubwindowMode:
+ if( (pointer)pGC->subWindowMode!=newValues[SUBWINDOW] )
+ {
+ gcmask |= index;
+ gcval[i++] = newValues[SUBWINDOW];
+ }
+ break;
+ case GCTile:
+ if( pGC->tileIsPixel || (pointer)pGC->tile.pixmap!=newValues[TILE] )
+ {
+ gcmask |= index;
+ gcval[i++] = newValues[TILE];
+ }
+ break;
+ case GCFillStyle:
+ if( (pointer)pGC->fillStyle!=newValues[FILLSTYLE] )
+ {
+ gcmask |= index;
+ gcval[i++] = newValues[FILLSTYLE];
+ }
+ break;
+ case GCForeground:
+ if( (pointer)pGC->fgPixel!=newValues[FOREGROUND] )
+ {
+ gcmask |= index;
+ gcval[i++] = newValues[FOREGROUND];
+ }
+ break;
+ }
+ }
+
+ if( gcmask ) DoChangeGC(pGC, gcmask, (XID *)gcval, 1);
+
+ if( pWin->drawable.serialNumber!=pGC->serialNumber )
+ ValidateGC((DrawablePtr)pWin, pGC);
+
+ numRects = REGION_NUM_RECTS(pRegion);
+ pbox = REGION_RECTS(pRegion);
+ for( i=numRects ; --i >= 0 ; pbox++,prect++ )
+ {
+ prect->x = pbox->x1 - pWin->drawable.x;
+ prect->y = pbox->y1 - pWin->drawable.y;
+ prect->width = pbox->x2 - pbox->x1;
+ prect->height = pbox->y2 - pbox->y1;
+ }
+ prect -= numRects;
+ (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
+ DEALLOCATE_LOCAL(prect);
+
+/*
+ * XXX Backing store is turned off for the PS driver
+
+ if( pWin->backStorage )
+ (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeNothing);
+ */
+
+ if( what==PW_BORDER )
+ {
+ REGION_UNINIT(pScreen, &pWin->clipList);
+ pWin->clipList = prgnWin;
+ pWin->drawable.x = oldCorner.x;
+ pWin->drawable.y = oldCorner.y;
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ }
+ FreeScratchGC(pGC);
+}
+
+/*ARGSUSED*/
+Bool
+PsDestroyWindow(WindowPtr pWin)
+{
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/ps/psout.c b/nx-X11/programs/Xserver/Xprint/ps/psout.c
new file mode 100644
index 000000000..376feec03
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/psout.c
@@ -0,0 +1,1792 @@
+/* $Xorg: psout.c,v 1.9 2001/03/26 15:25:12 coskrey Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996, 2000 Sun Microsystems, Inc. All Rights Reserved.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: psout.c
+** *
+** * Contents: Code to output PostScript to file
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "os.h"
+#define USE_PSOUT_PRIVATE 1
+#include "psout.h"
+#ifdef XP_USE_FREETYPE
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#endif /* XP_USE_FREETYPE */
+/* For VENDOR_STRING and VENDOR_RELEASE */
+#include "site.h"
+
+extern PsElmPtr PsCloneFillElementList(int nElms, PsElmPtr elms);
+extern void PsDestroyFillElementList(int nElms, PsElmPtr elms);
+
+/*
+ * Standard definitions
+ */
+
+static char *S_StandardDefs = "\
+/d{def}bind def\
+/b{bind}bind d\
+/bd{b d}b d\
+/x{exch}bd\
+/xd{x d}bd\
+/dp{dup}bd\
+/t{true}bd\
+/f{false}bd\
+/p{pop}bd\
+/r{roll}bd\
+/c{copy}bd\
+/i{index}bd\
+/rp{repeat}bd\
+/n{newpath}bd\
+/w{setlinewidth}bd\
+/lc{setlinecap}bd\
+/lj{setlinejoin}bd\
+/sml{setmiterlimit}bd\
+/ds{setdash}bd\
+/ie{ifelse}bd\
+/len{length}bd\
+/m{moveto}bd\
+/rm{rmoveto}bd\
+/l{lineto}bd\
+/rl{rlineto}bd\
+/a{arc}bd\
+/an{arcn}bd\
+/st{stroke}bd\
+/fl{fill}bd\
+/ef{eofill}bd\
+/sp{showpage}bd\
+/cp{closepath}bd\
+/clp{clippath}bd\
+/cl{clip}bd\
+/pb{pathbbox}bd\
+/tr{translate}bd\
+/rt{rotate}bd\
+/dv{div}bd\
+/ml{mul}bd\
+/ad{add}bd\
+/ng{neg}bd\
+/scl{scale}bd\
+/sc{setrgbcolor}bd\
+/g{setgray}bd\
+/gs{gsave}bd\
+/gr{grestore}bd\
+/sv{save}bd\
+/rs{restore}bd\
+/mx{matrix}bd\
+/cm{currentmatrix}bd\
+/sm{setmatrix}bd\
+/ccm{concatmatrix}bd\
+/cc{concat}bd\
+/ff{findfont}bd\
+/mf{makefont}bd\
+/sf{setfont}bd\
+/cft{currentfont}bd\
+/fd{FontDirectory}bd\
+/sh{show}bd\
+/stw{stringwidth}bd\
+/ci{colorimage}bd\
+/ig{image}bd\
+/im{imagemask}bd\
+/cf{currentfile}bd\
+/rh{readhexstring}bd\
+/str{string}bd\
+/al{aload}bd\
+/wh{where}bd\
+/kn{known}bd\
+/stp{stopped}bd\
+/bg{begin}bd\
+/ed{end}bd\
+/fa{forall}bd\
+/pi{putinterval}bd\
+/mk{mark}bd\
+/ctm{cleartomark}bd\
+/df{definefont}bd\
+/cd{currentdict}bd\
+/db{20 dict dp bg}bd\
+/de{ed}bd\
+/languagelevel wh{p languagelevel}{1}ie\
+ 1 eq{/makepattern{p}bd/setpattern{p}bd/setpagedevice{p}bd}if\
+/mp{makepattern}bd\
+/spt{setpattern}bd\
+/spd{setpagedevice}bd\
+"
+#ifdef XP_USE_FREETYPE
+"/trmoveto{currentfont /FontMatrix get transform rm}d"
+#endif /* XP_USE_FREETYPE */
+;
+
+/*
+ * Composite definitions
+ *
+ *
+ * XYr - Return X/Y dpi for device
+ *
+ * XYr <xdpi> <ydpi>
+ *
+ * Cs - Coordinate setup (for origin upper left)
+ *
+ * <orient(0,1,2,3)> Cs
+ *
+ * P - Draw a point
+ *
+ * <x> <y> P
+ *
+ * R - Add rectangle to path
+ *
+ * <x> <y> <w> <h> R
+ *
+ * Ac - Add arc to path
+ *
+ * <x> <y> <w> <h> <ang1> <ang2> Ac
+ *
+ * An - Add arc to path (counterclockwise)
+ *
+ * <x> <y> <w> <h> <ang1> <ang2> An
+ *
+ * Tf - Set font
+ *
+ * <font_name> <size> <iso> Tf
+ *
+ * Tfm - Set font with matrix
+ *
+ * <font_name> <matrix> <iso> Tfm
+ *
+ * T - Draw text
+ *
+ * <text> <x> <y> T
+ *
+ * Tb - Draw text with background color
+ *
+ * <text> <x> <y> <bg_red> <bg_green> <bg_blue> Tb
+ *
+ * Im1 - Image 1 bit monochrome imagemask
+ *
+ * <x> <y> <w> <h> <sw> <sh> Im1
+ *
+ * Im24 - Image 24 bit RGB color
+ *
+ * <x> <y> <w> <h> <sw> <sh> Im24
+ *
+ * Im1t - Image 1 bit monochrome imagemask (in tile)
+ *
+ * <data> <x> <y> <w> <h> <sw> <sh> Im1t
+ *
+ * Im24t - Image 24 bit RGB color (in tile)
+ *
+ * <data> <x> <y> <w> <h> <sw> <sh> Im24t
+ */
+
+static char *S_CompositeDefs = "\
+/XYr{/currentpagedevice wh\
+ {p currentpagedevice dp /HWResolution kn\
+ {/HWResolution get al p}{p 300 300}ie}{300 300}ie}bd\
+/Cs{dp 0 eq{0 pHt tr XYr -1 x dv 72 ml x 1 x dv 72 ml x scl}if\
+ dp 1 eq{90 rt XYr -1 x dv 72 ml x 1 x dv 72 ml x scl}if\
+ dp 2 eq{pWd 0 tr XYr 1 x dv 72 ml x -1 x dv 72 ml x scl}if\
+ 3 eq{pHt pWd tr 90 rt XYr 1 x dv 72 ml x -1 x dv 72 ml x scl}if}bd\
+/P{gs 1 w [] 0 ds 2 c m .1 ad x .1 ad x l st gr}bd\
+/R{4 2 r m 1 i 0 rl 0 x rl ng 0 rl cp}bd\
+/Ac{mx_ cm p 6 -2 r tr 4 2 r ng scl 0 0 .5 5 3 r a mx_ sm}bd\
+/An{mx_ cm p 6 -2 r tr 4 2 r ng scl 0 0 .5 5 3 r an mx_ sm}bd\
+/ISO{dp len dict bg{1 i/FID ne{d}{p p}ie}fa\
+ /Encoding ISOLatin1Encoding d cd ed df}bd\
+/iN{dp len str cvs dp len x 1 i 3 ad str 2 c c p x p dp 3 -1 r(ISO)pi}bd\
+/Tp{{x dp iN dp fd x kn{x p dp/f_ x d ff}{dp/f_ x d x ff ISO}ie x}\
+ {x dp/f_ x d ff x}ie}bd\
+/Tf{Tp[x 0 0 2 i ng 0 0] dp/fm_ x d mf sf}bd\
+/Tfm{Tp 1 -1 tm1_ scl tm2_ ccm dp/fm_ x d mf sf}bd\
+/T{m sh}bd\
+/Tb{gs sc f_ ff sf cft/FontMatrix get 3 get\
+ cft/FontBBox get dp 1 get x 3 get 2 i ml 3 1 r ml\
+ 0 0 m 4 i stw p 4 i 4 i m fm_ cc\
+ 0 2 i rl dp 0 rl 0 2 i ng rl 0 3 i rl ng 0 rl cp fl p p\
+ gr T}bd\
+/Im1{6 4 r tr scl t [3 i 0 0 5 i 0 0]{cf str1 rh p} im}bd\
+/Im1rev{6 4 r tr scl f [3 i 0 0 5 i 0 0]{cf str1 rh p} im}bd\
+/Im24{gs 6 4 r tr scl 8 [3 i 0 0 5 i 0 0]{cf str3 rh p} f 3 ci}bd\
+/Im1t{6 4 r tr scl t [3 i 0 0 5 i 0 0]{} im}bd\
+/Im24t{gs 6 4 r tr scl 8 [3 i 0 0 5 i 0 0]{} f 3 ci}bd\
+/ck2{/currentpagedevice wh \
+{p dp currentpagedevice dp 3 -1 r kn \
+{x get al p 3 -1 r eq 3 1 r eq and } \
+{p p p p t}ie} \
+{p p p t}ie}bd \
+/ck1{/currentpagedevice wh \
+{p dp currentpagedevice dp 3 -1 r kn \
+{x get eq} {p p p t}ie} \
+{p p t}ie}bd \
+/mtx{scl t [3 i 0 0 5 i 0 0]}bd \
+";
+
+char *pg_orient[] = {"Portrait","Landscape","Reverse Portrait","Reverse Landscape"};
+/*
+ * Setup definitions
+ */
+
+static char *S_SetupDefs = "\
+ /mx_ mx d\
+ /im_ mx d\
+ /tm1_ mx d\
+ /tm2_ mx d\
+ /str3 3 str d\
+ /str1 1 str d\
+";
+
+/*******************************************************************
+ * PRIVATE FUNCTIONS *
+ *******************************************************************/
+
+void
+S_Flush(PsOutPtr self)
+{
+ int len;
+
+ if( self->Buf[0] == '\0' )
+ return;
+
+ len = strlen(self->Buf);
+
+ /* Append a newline char ('\n') if there isn't one there already */
+ if( self->Buf[len-1] != '\n' )
+ {
+ self->Buf[len++] = '\n';
+ self->Buf[len] = '\0';
+ }
+
+ (void)fwrite(self->Buf, len, 1, self->Fp);
+
+ self->Buf[0] = '\0';
+}
+
+static void
+S_Comment(PsOutPtr self, char *comment)
+{
+ S_Flush(self);
+ strcpy(self->Buf, comment);
+ S_Flush(self);
+}
+
+static void
+S_OutDefs(PsOutPtr self, char *defs)
+{
+ int i, k=0;
+ S_Flush(self);
+ memset(self->Buf, 0, sizeof(self->Buf));
+ for( i=0 ; defs[i]!='\0' ;)
+ {
+ if( k>70 && (i==0 || (i && defs[i-1]!='/')) &&
+ (defs[i]==' ' || defs[i]=='/' || defs[i]=='{') )
+ {
+ S_Flush(self);
+ k = 0;
+ memset(self->Buf, 0, sizeof(self->Buf));
+ }
+ if( k && self->Buf[k-1]==' ' && defs[i]==' ' ) { i++; continue; }
+ self->Buf[k] = defs[i];
+ k++; i++;
+ }
+ S_Flush(self);
+}
+
+void
+S_OutNum(PsOutPtr self, float num)
+{
+ int i;
+ char buf[64];
+ int len;
+
+ sprintf(buf, "%.3f", num);
+
+ /* Remove any zeros at the end */
+ for( i=strlen(buf)-1 ; buf[i]=='0' ; i-- ); buf[i+1] = '\0';
+ /* Remove '.' if it is the last character */
+ i = strlen(buf)-1; if( buf[i]=='.' ) buf[i] = '\0';
+
+ len = strlen(self->Buf);
+ if( len > 0 )
+ {
+ self->Buf[len++] = ' ';
+ self->Buf[len] = '\0';
+ }
+ strcpy(&self->Buf[len], buf);
+ if( (len+i)>70 ) S_Flush(self);
+}
+
+static void
+S_OutStr(PsOutPtr self, char *txt, int txtl)
+{
+ int i, k;
+ char buf[1024];
+ for( i=0,k=0 ; i<txtl ; i++ )
+ {
+ if( (txt[i]>=' ' && txt[i]<='~') &&
+ txt[i]!='(' && txt[i]!=')' && txt[i]!='\\' )
+ { buf[k] = txt[i]; k++; continue; }
+ buf[k] = '\\'; k++;
+ sprintf(&buf[k], "%03o", txt[i]&0xFF);
+ /* Skip to the end of the buffer */
+ while( buf[k] != '\0' )
+ k++;
+ }
+ strcat(self->Buf, "(");
+ i = strlen(self->Buf);
+ memcpy(&self->Buf[i], buf, k);
+ self->Buf[i+k] = '\0';
+ strcat(self->Buf, ")");
+ if( strlen(self->Buf)>70 ) S_Flush(self);
+}
+
+/* Same as S_OutStr() but takes |short *| instead of |char *| */
+static void
+S_OutStr16(PsOutPtr self, unsigned short *txt, int txtl)
+{
+ int i, k;
+ char buf[2048];
+ for( i=0,k=0 ; i<txtl ; i++ )
+ {
+ if( (txt[i]>=' ' && txt[i]<='~') &&
+ txt[i]!='(' && txt[i]!=')' && txt[i]!='\\' )
+ { buf[k] = txt[i]; k++; continue; }
+ buf[k] = '\\'; k++;
+ sprintf(&buf[k], "%03o", txt[i]&0xFFFF);
+ /* Skip to the end of the buffer */
+ while( buf[k] != '\0' )
+ k++;
+ }
+ strcat(self->Buf, "(");
+ i = strlen(self->Buf);
+ memcpy(&self->Buf[i], buf, k);
+ self->Buf[i+k] = '\0';
+ strcat(self->Buf, ")");
+ if( strlen(self->Buf)>70 ) S_Flush(self);
+}
+
+void
+S_OutTok(PsOutPtr self, char *tok, int cr)
+{
+ int len = strlen(self->Buf);
+ if( len > 0 )
+ {
+ self->Buf[len++] = ' ';
+ self->Buf[len] = '\0';
+ }
+ strcpy(&self->Buf[len], tok);
+ if( cr ) S_Flush(self);
+}
+
+static void
+S_Color(PsOutPtr self, PsOutColor clr)
+{
+ int ir, ig, ib;
+ ir = PSOUTCOLOR_TO_REDBITS(clr);
+ ig = PSOUTCOLOR_TO_GREENBITS(clr);
+ ib = PSOUTCOLOR_TO_BLUEBITS(clr);
+ if( ir==ig && ig==ib )
+ { S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir)); S_OutTok(self, "g", 1); }
+ else
+ {
+ S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir));
+ S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ig));
+ S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ib));
+ S_OutTok(self, "sc", 1);
+ }
+}
+
+static void
+S_SetPageDevice(PsOutPtr self, int orient, int count, int plex, int res,
+ int wd, int ht, int isPage)
+{
+ float fwd = ((float)wd/(float)res)*72.;
+ float fht = ((float)ht/(float)res)*72.;
+
+#define USE_WORKAROUND_COPY_COUNT_BUG 1
+
+#ifdef USE_WORKAROUND_COPY_COUNT_BUG
+ /* Workaround (see http://xprint.mozdev.org/bugs/show_bug.cgi?id=1861 -
+ * 'Need workaround for bug 1378 ...') to avoid that we print n^2 copies
+ * instead of n copies.
+ * The problem is that we use both /NumCopies here but pass the
+ * %copy-count% to the spooler, too.
+ * But we only have to use _one_ way...
+ *
+ * The final fix for bug 1378 (http://xprint.mozdev.org/bugs/show_bug.cgi?id=1378 -
+ * "PS DDX creates n^2 copies of a job instead of n copies") will back this
+ * workaround out and replace it with a better solution.
+ * (see mozilla.org bug 140030
+ * (http://bugzilla.mozilla.org/show_bug.cgi?id=140030 - "Setting number
+ * of copies causes too many copies to print") for the initial report for
+ * this issue...)
+ */
+ count = 1;
+#endif /* USE_WORKAROUND_COPY_COUNT_BUG */
+
+ S_OutTok(self, "/pWd", 0);
+ S_OutNum(self, fwd);
+ S_OutTok(self, "d /pHt", 0);
+ S_OutNum(self, fht);
+ S_OutTok(self, "d", 1);
+
+ /*
+ * if these are page attributes, have PostScript check to see if they
+ * have changed. If not, don't do setpagedevice, since it will cause
+ * a page flush and screw up duplex printing. Having PostScript check
+ * means we don't have to keep track ourselves.
+ */
+ if(isPage) {
+ S_OutNum(self, (float) orient);
+ S_OutTok(self, "/Orientation ck1", 0);
+ S_OutTok(self, "pWd pHt /PageSize ck2 and not {", 1);
+ }
+ S_OutTok(self, "{db", 0);
+
+ S_OutTok(self, "/Orientation", 0);
+ S_OutNum(self, (float) orient);
+ S_OutTok(self, " d ", 0);
+ S_OutTok(self, "/PageSize [pWd pHt] d", 0);
+
+ S_OutTok(self, " de spd", 0);
+ /*
+ * save a flag to show if we failed to set orientation... determined
+ * by both/either Orientation and/or PageSize, use this
+ * later to set/not set orientation using Cs command.
+ */
+ S_OutTok(self,"}stp /orientationFailed x d", 1);
+ /*
+ * if these are page attributes, have PostScript check to see if they
+ * have changed. If not, don't do setpagedevice, since it will cause
+ * a page flush and screw up duplex printing. Having PostScript check
+ * means we don't have to keep track ourselves.
+ */
+ if(isPage)
+ {
+ S_OutTok(self,"}if",1);
+
+ S_OutTok(self, (plex==0)?"f":"t", 0);
+ S_OutTok(self, "/Duplex ck1 ", 0);
+
+ S_OutTok(self, (plex==2)?"t":"f", 0);
+ S_OutTok(self, "/Tumble ck1 and ", 0);
+
+
+ S_OutNum(self, (float)res);
+ S_OutNum(self, (float)res);
+ S_OutTok(self, " /HWResolution ck2 and", 0);
+
+ if( count>1 )
+ {
+ S_OutNum(self, (float)count);
+ S_OutTok(self, " /NumCopies", 0);
+ S_OutTok(self, " ck1 and ", 0);
+ }
+ S_OutTok(self," not {",1);
+ }
+ S_OutTok(self, "{db", 0);
+
+ S_OutTok(self, "/Duplex ", 0);
+ S_OutTok(self, (plex==0)?"f":"t", 0);
+ S_OutTok(self, " d ", 0);
+
+ S_OutTok(self, "/Tumble ", 0);
+ S_OutTok(self, (plex==2)?"t":"f", 0);
+ S_OutTok(self, " d ", 0);
+
+ S_OutTok(self, " /HWResolution [", 0);
+ S_OutNum(self, (float)res);
+ S_OutNum(self, (float)res);
+ S_OutTok(self, "] d ", 0);
+
+ if( count>1 )
+ {
+ S_OutTok(self, " /NumCopies", 0);
+ S_OutNum(self, (float)count);
+ S_OutTok(self, " d ", 0);
+ }
+ S_OutTok(self, " de spd}stp p", 1);
+
+ if(isPage)
+ {
+ S_OutTok(self, "}if", 1);
+ }
+}
+
+/*******************************************************************
+ * PUBLIC FUNCTIONS *
+ *******************************************************************/
+
+FILE *
+PsOut_ChangeFile(PsOutPtr self, FILE *fp)
+{
+ FILE *nfp;
+
+ nfp = self->Fp;
+
+ self->Fp = fp;
+
+ return nfp;
+}
+
+PsOutPtr
+PsOut_BeginFile(FILE *fp, char *title, int orient, int count, int plex, int res,
+ int wd, int ht, Bool raw)
+{
+ int i;
+ char buffer[256+32]; /* enougth space for a title with 256 chars... */
+/*
+ * Get ready to output PostScript header
+ */
+ PsOutPtr psout;
+ psout = (PsOutPtr)xalloc(sizeof(PsOutRec));
+ memset(psout, 0, sizeof(PsOutRec));
+ psout->Fp = fp;
+ psout->isRaw = raw;
+ psout->pagenum = 0;
+
+ if (!raw) {
+/*
+ * Output PostScript header
+ */
+ /* GhostScript will rant about the missing BoundingBox if we use
+ * "%!PS-Adobe-3.0 EPSF-3.0" here... */
+ S_Comment(psout, "%!PS-Adobe-3.0");
+#ifdef XP_USE_FREETYPE
+ {
+ FT_Int ftmajor = 0,
+ ftminor = 0,
+ ftpatch = 0;
+ extern FT_Library ftypeLibrary; /* defined in xc/lib/font/FreeType/ftfuncs.c */
+
+ FT_Library_Version(ftypeLibrary, &ftmajor, &ftminor, &ftpatch);
+ sprintf(buffer,
+ "%%%%Creator: The X Print Server's PostScript DDX "
+ "(%s, release %d, FreeType version %d.%d.%d)",
+ VENDOR_STRING, VENDOR_RELEASE,
+ (int)ftmajor, (int)ftminor, (int)ftpatch);
+ }
+#else
+ sprintf(buffer,
+ "%%%%Creator: The X Print Server's PostScript DDX (%s, release %d)",
+ VENDOR_STRING, VENDOR_RELEASE);
+#endif /* XP_USE_FREETYPE */
+ S_Comment(psout, buffer);
+
+ if (title)
+ {
+ sprintf(buffer, "%%%%Title: %.256s", title);
+ S_Comment(psout, buffer);
+ }
+ S_Comment(psout, "%%EndComments");
+ S_Comment(psout, "%%BeginProlog");
+ S_Comment(psout, "%%BeginProcSet: XServer_PS_Functions");
+ S_OutDefs(psout, S_StandardDefs);
+ S_OutDefs(psout, S_CompositeDefs);
+ S_Comment(psout, "%%EndProcSet");
+ S_Comment(psout, "%%EndProlog");
+ S_Comment(psout, "%%BeginSetup");
+ /* set document level page attributes */
+ S_SetPageDevice(psout, orient, count, plex, res, wd, ht, 0);
+ S_Comment(psout, "%%Pages: atend");
+ S_OutDefs(psout, S_SetupDefs);
+ S_Comment(psout, "%%EndSetup");
+ }
+/*
+ * Initialize the structure
+ */
+ psout->CurColor = PSOUTCOLOR_NOCOLOR;
+ psout->LineWidth = 1;
+ psout->LineCap = PsCButt;
+ psout->LineJoin = PsJMiter;
+ psout->NDashes = 0;
+ psout->Dashes = (int *)0;
+ psout->FontName = (char *)0;
+ psout->FontSize = 0;
+ psout->start_image = 0;
+ for( i=0 ; i<4 ; i++ ) psout->FontMtx[i] = 0.;
+ psout->ImageFormat = 0;
+ return(psout);
+}
+
+void
+PsOut_EndFile(PsOutPtr self, int closeFile)
+{
+ char coms[50];
+ int i;
+
+ if (!self)
+ return;
+
+ if (!self->isRaw) {
+ S_Comment(self,"%%Trailer");
+ sprintf(coms,"%%%%Pages: %d", self->pagenum);
+ S_Comment(self, coms);
+ S_Comment(self, "%%EOF");
+ }
+ if( self->NDashes && self->Dashes ) xfree(self->Dashes);
+ if( self->FontName ) xfree(self->FontName);
+ if( self->Patterns ) xfree(self->Patterns);
+ if( self->Clip.rects ) xfree(self->Clip.rects);
+ if( closeFile ) fclose(self->Fp);
+ xfree(self);
+}
+
+void
+PsOut_BeginPage(PsOutPtr self, int orient, int count, int plex, int res,
+ int wd, int ht)
+{
+ char coms[50];
+
+/*** comment for pagenumbers *****/
+
+ S_Comment(self,"%%PageHeader");
+ self->pagenum++;
+ sprintf(coms,"%%%%Page: %d %d", self->pagenum, self->pagenum);
+ S_Comment(self, coms);
+ sprintf(coms,"%%%%PageOrientation: %s",pg_orient[orient]);
+ S_Comment(self, coms);
+
+/*** end comment *****************/
+
+ /* set page level page attributes */
+ S_SetPageDevice(self, orient, count, plex, res, wd, ht, 1);
+
+ S_OutTok(self, "gs ", 0);
+ /*
+ * check to see if we set orientation already; if it wasn't set,
+ * use Cs to set orientation here.
+ */
+ S_OutNum(self, (float)orient);
+ S_OutTok(self, "orientationFailed { ", 0);
+ S_OutNum(self, (float)orient);
+ S_OutTok(self, " } { 0 }ie Cs 100 sml gs", 1);
+}
+
+void
+PsOut_EndPage(PsOutPtr self)
+{
+ S_OutTok(self, "gr gr sp", 1);
+
+ /* did grestore: mark attributes 'dirty' so they will be re-sent */
+ PsOut_DirtyAttributes(self);
+
+/*** comment for pagenumbers *****/
+
+ S_Comment(self,"%%PageTrailer");
+
+/*** end comment *****************/
+}
+
+void
+PsOut_DirtyAttributes(PsOutPtr self)
+{
+ int i;
+ self->CurColor = PSOUTCOLOR_NOCOLOR;
+ self->LineWidth = -1;
+ self->LineCap = (PsCapEnum)-1;
+ self->LineJoin = (PsJoinEnum)-1;
+ self->NDashes = -1;
+ self->FontSize = -1;
+ for( i=0 ; i<4 ; i++ ) self->FontMtx[i] = -1.;
+ if( self->Dashes ) { xfree(self->Dashes); self->Dashes = (int *)0; }
+ if( self->FontName ) { xfree(self->FontName); self->FontName = (char *)0; }
+}
+
+void
+PsOut_Comment(PsOutPtr self, char *comment)
+{
+ S_Comment(self, comment);
+}
+
+void
+PsOut_Offset(PsOutPtr self, int x, int y)
+{
+ self->XOff = x;
+ self->YOff = y;
+}
+
+void
+PsOut_Clip(PsOutPtr self, int clpTyp, PsClipPtr clpinf)
+{
+ int i, k;
+ int changed = 0;
+ int xo = self->XOff;
+ int yo = self->YOff;
+
+ if( self->InTile ) return;
+ if( self->InFrame ) xo = yo = 0;
+ if( clpTyp!=self->ClipType ) changed = 1;
+ else
+ {
+ if( clpinf->nRects!=self->Clip.nRects ) changed = 1;
+ else
+ {
+ if( clpinf->nOutterClips!=self->Clip.nOutterClips ) changed = 1;
+ else
+ {
+ for( i=0 ; i<clpinf->nOutterClips ; i++ )
+ {
+ if( memcmp(&clpinf->outterClips[i], &self->Clip.outterClips[i],
+ sizeof(PsRectRec))!=0 ) break;
+ }
+ if( i<clpinf->nOutterClips ) changed = 1;
+ else
+ {
+ for( i=0 ; i<clpinf->nRects ; i++ )
+ {
+ if( memcmp(&clpinf->rects[i], &self->Clip.rects[i],
+ sizeof(PsRectRec))!=0 ) { changed = 1; break; }
+ }
+ }
+ }
+ }
+ if( clpinf->nElms!=self->Clip.nElms ) changed = 1;
+ else
+ {
+ for( i=0 ; i<clpinf->nElms ; i++ )
+ {
+ if( clpinf->elms[i].type!=PSOUT_POINTS )
+ {
+ if( memcmp(&clpinf->elms[i], &self->Clip.elms[i],
+ sizeof(PsElmRec))!=0 ) { changed = 1; break; }
+ }
+ else
+ {
+ if( clpinf->elms[i].type!=self->Clip.elms[i].type ||
+ clpinf->elms[i].nPoints!=self->Clip.elms[i].nPoints )
+ { changed = 1; break; }
+ else
+ {
+ for( k=0 ; k<clpinf->elms[i].nPoints ; k++ )
+ {
+ if( memcmp(&clpinf->elms[i].c.points[k],
+ &self->Clip.elms[i].c.points[k], sizeof(PsPointRec)) )
+ { changed = 1; break; }
+ }
+ if( changed ) break;
+ }
+ }
+ }
+ }
+ }
+
+ if( self->Clip.rects ) xfree(self->Clip.rects);
+ if( self->Clip.outterClips ) xfree(self->Clip.outterClips);
+ if( self->Clip.elms )
+ PsDestroyFillElementList(self->Clip.nElms, self->Clip.elms);
+ self->ClipType = clpTyp;
+ self->Clip.nRects = clpinf->nRects;
+ self->Clip.nElms = clpinf->nElms;
+ self->Clip.nOutterClips = clpinf->nOutterClips;
+ if( clpinf->nRects )
+ {
+ self->Clip.rects = (PsRectPtr)xalloc(clpinf->nRects*sizeof(PsRectRec));
+ memcpy(self->Clip.rects, clpinf->rects, clpinf->nRects*sizeof(PsRectRec));
+ }
+ else self->Clip.rects = 0;
+ if( clpinf->nOutterClips )
+ {
+ self->Clip.outterClips = (PsRectPtr)xalloc(clpinf->nOutterClips*
+ sizeof(PsRectRec));
+ memcpy(self->Clip.outterClips, clpinf->outterClips,
+ clpinf->nOutterClips*sizeof(PsRectRec));
+ }
+ else self->Clip.outterClips = 0;
+ if( clpinf->nElms )
+ self->Clip.elms = PsCloneFillElementList(clpinf->nElms, clpinf->elms);
+ else self->Clip.elms = 0;
+
+ PsOut_DirtyAttributes(self);
+ S_OutTok(self, "gr gs", 1);
+ if( self->Clip.nOutterClips )
+ {
+ for( i=0 ; i<self->Clip.nOutterClips ; i++ )
+ {
+ S_OutNum(self, (float)(self->Clip.outterClips[i].x));
+ S_OutNum(self, (float)(self->Clip.outterClips[i].y));
+ S_OutNum(self, (float)self->Clip.outterClips[i].w);
+ S_OutNum(self, (float)self->Clip.outterClips[i].h);
+ S_OutTok(self, "R", 1);
+ }
+ S_OutTok(self, "cl n", 1);
+ }
+ if( self->Clip.nRects )
+ {
+ for( i=0 ; i<self->Clip.nRects ; i++ )
+ {
+ S_OutNum(self, (float)(self->Clip.rects[i].x+xo));
+ S_OutNum(self, (float)(self->Clip.rects[i].y+yo));
+ S_OutNum(self, (float)self->Clip.rects[i].w);
+ S_OutNum(self, (float)self->Clip.rects[i].h);
+ S_OutTok(self, "R", 1);
+ }
+ S_OutTok(self, "cl n", 1);
+ }
+ if( self->Clip.nElms )
+ {
+ PsElmPtr elm = self->Clip.elms;
+ for( i=0 ; i<self->Clip.nElms ; i++,elm++ )
+ {
+ switch(elm->type)
+ {
+ case PSOUT_POINTS:
+ for( k=0 ; k<elm->nPoints ; k++ )
+ {
+ S_OutNum(self, (float)elm->c.points[k].x+xo);
+ S_OutNum(self, (float)elm->c.points[k].y+yo);
+ if( k==0 ) S_OutTok(self, "m", 0);
+ else S_OutTok(self, "l", 0);
+ }
+ S_OutTok(self, "cp", 1);
+ break;
+ case PSOUT_RECT:
+ S_OutNum(self, (float)elm->c.rect.x+xo);
+ S_OutNum(self, (float)elm->c.rect.y+yo);
+ S_OutNum(self, (float)elm->c.rect.w);
+ S_OutNum(self, (float)elm->c.rect.h);
+ S_OutTok(self, "R", 1);
+ break;
+ case PSOUT_ARC:
+ if( elm->c.arc.style==PsPieSlice )
+ {
+ S_OutNum(self, (float)elm->c.arc.x+xo+(float)elm->c.arc.w/2.);
+ S_OutNum(self, (float)elm->c.arc.y+yo+(float)elm->c.arc.h/2.);
+ S_OutTok(self, "m", 0);
+ }
+ S_OutNum(self, (float)elm->c.arc.x+xo+(float)elm->c.arc.w/2.);
+ S_OutNum(self, (float)elm->c.arc.y+yo+(float)elm->c.arc.h/2.);
+ S_OutNum(self, (float)elm->c.arc.w);
+ S_OutNum(self, (float)elm->c.arc.h);
+ S_OutNum(self, (float)elm->c.arc.a1/64.);
+ S_OutNum(self, (float)elm->c.arc.a1/64.+(float)elm->c.arc.a2/64.);
+ if( elm->c.arc.a2<0 ) S_OutTok(self, "An cp", 1);
+ else S_OutTok(self, "Ac cp", 1);
+ break;
+ }
+ }
+ S_OutTok(self, "cl n", 1);
+ }
+}
+
+void
+PsOut_Color(PsOutPtr self, PsOutColor clr)
+{
+ if( clr==self->CurColor || self->InTile>=PsStip ) return;
+ self->CurColor = clr;
+ S_Color(self, clr);
+}
+
+void
+PsOut_FillRule(PsOutPtr self, PsRuleEnum rule)
+{
+ self->FillRule = rule;
+}
+
+void
+PsOut_LineAttrs(PsOutPtr self, int wd, PsCapEnum cap, PsJoinEnum join,
+ int nDsh, int *dsh, int dshOff, PsOutColor bclr)
+{
+ int i;
+ int same = 1;
+
+ if( wd!=self->LineWidth && wd>=0 )
+ {
+ if( wd==0 ) wd = 1;
+ self->LineWidth = wd;
+ S_OutNum(self, (float)wd); S_OutTok(self, "w", 1);
+ }
+ if( cap!=self->LineCap )
+ {
+ self->LineCap = cap;
+ S_OutNum(self, (float)cap); S_OutTok(self, "lc", 1);
+ }
+ if( join!=self->LineJoin )
+ {
+ self->LineJoin = join;
+ S_OutNum(self, (float)join); S_OutTok(self, "lj", 1);
+ }
+ if( nDsh!=self->NDashes ) same = 0;
+ else if( dshOff!=self->DashOffset ) same = 0;
+ else if( nDsh )
+ {
+ for( i=0 ; i<nDsh ; i++ )
+ { if( dsh[i]!=self->Dashes[i] ) break; }
+ if( i<nDsh ) same = 0;
+ }
+ if( !same )
+ {
+ if( self->NDashes && self->Dashes )
+ { xfree(self->Dashes); self->Dashes = (int *)0; }
+ self->NDashes = nDsh;
+ self->DashOffset = dshOff;
+ if( nDsh ) self->Dashes = (int *)xalloc(sizeof(int)*nDsh);
+ S_OutTok(self, "[", 0);
+ for( i=0 ; i<nDsh ; i++ )
+ {
+ self->Dashes[i] = dsh[i];
+ S_OutNum(self, (float)dsh[i]);
+ }
+ S_OutTok(self, "]", 0);
+ S_OutNum(self, (float)dshOff);
+ S_OutTok(self, "ds", 1);
+ }
+
+ if( nDsh )
+ self->LineBClr = bclr;
+ else
+ bclr = PSOUTCOLOR_NOCOLOR;
+}
+
+void
+PsOut_TextAttrs(PsOutPtr self, char *fnam, int siz, int iso)
+{
+ int i;
+ char buf[256];
+ if( self->FontName && strcmp(fnam, self->FontName)==0 &&
+ siz==self->FontSize ) return;
+ if( self->FontName ) xfree(self->FontName);
+ self->FontName = (char *)xalloc(strlen(fnam)+1);
+ strcpy(self->FontName, fnam);
+ self->FontSize = siz;
+ for( i=0 ; i<4 ; i++ ) self->FontMtx[i] = -1.;
+ strcpy(buf, "/"); strcat(buf, fnam);
+ S_OutTok(self, buf, 0);
+ S_OutNum(self, (float)siz);
+ if( iso ) S_OutTok(self, "t", 0);
+ else S_OutTok(self, "f", 0);
+ S_OutTok(self, "Tf", 1);
+}
+
+void
+PsOut_TextAttrsMtx(PsOutPtr self, char *fnam, float *mtx, int iso)
+{
+ int i;
+ char buf[256];
+ if( self->FontName && strcmp(fnam, self->FontName)==0 &&
+ mtx[0]==self->FontMtx[0] && mtx[1]==self->FontMtx[1] &&
+ mtx[2]==self->FontMtx[2] && mtx[3]==self->FontMtx[3] ) return;
+ if( self->FontName ) xfree(self->FontName);
+ self->FontName = (char *)xalloc(strlen(fnam)+1);
+ strcpy(self->FontName, fnam);
+ for( i=0 ; i<4 ; i++ ) self->FontMtx[i] = mtx[i];
+ self->FontSize = -1;
+ strcpy(buf, "/"); strcat(buf, fnam); strcat(buf, " [");
+ S_OutTok(self, buf, 0);
+ for( i=0 ; i<4 ; i++ ) S_OutNum(self, mtx[i]);
+ S_OutTok(self, "0 0]", 0);
+ if( iso ) S_OutTok(self, "t", 0);
+ else S_OutTok(self, "f", 0);
+ S_OutTok(self, "Tfm", 1);
+}
+
+void
+PsOut_Polygon(PsOutPtr self, int nPts, PsPointPtr pts)
+{
+ int i;
+ int xo = self->XOff;
+ int yo = self->YOff;
+
+ if( self->InFrame || self->InTile ) xo = yo = 0;
+ if( nPts<=2 ) return;
+ for( i=0 ; i<nPts ; i++ )
+ {
+ S_OutNum(self, (float)(pts[i].x+xo));
+ S_OutNum(self, (float)(pts[i].y+yo));
+ if( i==0 ) S_OutTok(self, "m", 0);
+ else S_OutTok(self, "l", 0);
+ }
+ if( self->FillRule==PsEvenOdd ) S_OutTok(self, "cp ef", 1);
+ else S_OutTok(self, "cp fl", 1);
+}
+
+void
+PsOut_FillRect(PsOutPtr self, int x, int y, int w, int h)
+{
+ int xo = self->XOff;
+ int yo = self->YOff;
+
+ if( self->InFrame || self->InTile ) xo = yo = 0;
+ x += xo; y += yo;
+ S_OutNum(self, (float)x);
+ S_OutNum(self, (float)y);
+ S_OutNum(self, (float)w);
+ S_OutNum(self, (float)h);
+ S_OutTok(self, "R fl", 1);
+}
+
+void
+PsOut_FillArc(PsOutPtr self, int x, int y, int w, int h,
+ float ang1, float ang2, PsArcEnum style)
+{
+ int xo = self->XOff;
+ int yo = self->YOff;
+
+ if( self->InFrame || self->InTile ) xo = yo = 0;
+ x += xo; y += yo;
+ if( style==PsPieSlice )
+ {
+ S_OutNum(self, (float)x+(float)w/2.);
+ S_OutNum(self, (float)y+(float)h/2.);
+ S_OutTok(self, "m", 0);
+ }
+ S_OutNum(self, (float)x+(float)w/2.);
+ S_OutNum(self, (float)y+(float)h/2.);
+ S_OutNum(self, (float)w);
+ S_OutNum(self, (float)h);
+ S_OutNum(self, ang1);
+ S_OutNum(self, ang1+ang2);
+ if( ang2<0 ) S_OutTok(self, "An cp fl", 1);
+ else S_OutTok(self, "Ac cp fl", 1);
+}
+
+void
+PsOut_Lines(PsOutPtr self, int nPts, PsPointPtr pts)
+{
+ int i;
+ int xo = self->XOff;
+ int yo = self->YOff;
+
+ if( self->InFrame || self->InTile ) xo = yo = 0;
+ if( nPts<1 ) return;
+ for( i=0 ; i<nPts ; i++ )
+ {
+ S_OutNum(self, (float)(pts[i].x+xo));
+ S_OutNum(self, (float)(pts[i].y+yo));
+ if( i==0 ) S_OutTok(self, "m", 0);
+ else S_OutTok(self, "l", 0);
+ }
+ if( self->LineBClr != PSOUTCOLOR_NOCOLOR )
+ {
+ S_OutTok(self, "gs", 0);
+ S_Color(self, self->LineBClr);
+ S_OutTok(self, "[] 0 ds st gr", 0);
+ }
+ S_OutTok(self, "st", 1);
+}
+
+void
+PsOut_Points(PsOutPtr self, int nPts, PsPointPtr pts)
+{
+ int i;
+ int xo = self->XOff;
+ int yo = self->YOff;
+
+ if( self->InFrame || self->InTile ) xo = yo = 0;
+ if( nPts<1 ) return;
+ for( i=0 ; i<nPts ; i++ )
+ {
+ S_OutNum(self, (float)(pts[i].x+xo));
+ S_OutNum(self, (float)(pts[i].y+yo));
+ S_OutTok(self, "P", 1);
+ }
+}
+
+void
+PsOut_DrawRect(PsOutPtr self, int x, int y, int w, int h)
+{
+ int xo = self->XOff;
+ int yo = self->YOff;
+
+ if( self->InFrame || self->InTile ) xo = yo = 0;
+ x += xo; y += yo;
+ S_OutNum(self, (float)x);
+ S_OutNum(self, (float)y);
+ S_OutNum(self, (float)w);
+ S_OutNum(self, (float)h);
+ S_OutTok(self, "R", 0);
+ if( self->LineBClr != PSOUTCOLOR_NOCOLOR )
+ {
+ S_OutTok(self, "gs", 0);
+ S_Color(self, self->LineBClr);
+ S_OutTok(self, "[] 0 ds st gr", 0);
+ }
+ S_OutTok(self, "st", 1);
+}
+
+void
+PsOut_DrawArc(PsOutPtr self, int x, int y, int w, int h,
+ float ang1, float ang2)
+{
+ int xo = self->XOff;
+ int yo = self->YOff;
+
+ if( self->InFrame || self->InTile ) xo = yo = 0;
+ x += xo; y += yo;
+ S_OutNum(self, (float)x+(float)w/2.);
+ S_OutNum(self, (float)y+(float)h/2.);
+ S_OutNum(self, (float)w);
+ S_OutNum(self, (float)h);
+ S_OutNum(self, ang1);
+ S_OutNum(self, ang1+ang2);
+ if( ang2<0 ) S_OutTok(self, "An", 0);
+ else S_OutTok(self, "Ac", 0);
+ if( self->LineBClr != PSOUTCOLOR_NOCOLOR )
+ {
+ S_OutTok(self, "gs", 0);
+ S_Color(self, self->LineBClr);
+ S_OutTok(self, "[] 0 ds st gr", 0);
+ }
+ S_OutTok(self, "st", 1);
+}
+
+void
+PsOut_Text(PsOutPtr self, int x, int y, char *text, int textl, PsOutColor bclr)
+{
+ int xo = self->XOff;
+ int yo = self->YOff;
+
+ if( self->InFrame || self->InTile ) xo = yo = 0;
+ x += xo; y += yo;
+ S_OutStr(self, text, textl);
+ S_OutNum(self, (float)x);
+ S_OutNum(self, (float)y);
+ if( bclr == PSOUTCOLOR_NOCOLOR )
+ S_OutTok(self, "T", 1);
+ else
+ {
+ int ir = PSOUTCOLOR_TO_REDBITS(bclr);
+ int ig = PSOUTCOLOR_TO_GREENBITS(bclr);
+ int ib = PSOUTCOLOR_TO_BLUEBITS(bclr);
+
+ S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir));
+ S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ig));
+ S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ib));
+ S_OutTok(self, "Tb", 1);
+ }
+}
+
+void
+PsOut_Text16(PsOutPtr self, int x, int y, unsigned short *text, int textl, PsOutColor bclr)
+{
+ int xo = self->XOff;
+ int yo = self->YOff;
+
+ if( self->InFrame || self->InTile ) xo = yo = 0;
+ x += xo; y += yo;
+ S_OutStr16(self, text, textl);
+ S_OutNum(self, (float)x);
+ S_OutNum(self, (float)y);
+ if( bclr == PSOUTCOLOR_NOCOLOR )
+ S_OutTok(self, "T", 1);
+ else
+ {
+ int ir = PSOUTCOLOR_TO_REDBITS(bclr);
+ int ig = PSOUTCOLOR_TO_GREENBITS(bclr);
+ int ib = PSOUTCOLOR_TO_BLUEBITS(bclr);
+ S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir));
+ S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ig));
+ S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ib));
+ S_OutTok(self, "Tb", 1);
+ }
+}
+
+#ifdef BM_CACHE
+void /* new */
+PsOut_ImageCache(PsOutPtr self, int x, int y, long cache_id, PsOutColor bclr, PsOutColor fclr)
+{
+ char cacheID[10];
+ int xo = self->XOff;
+ int yo = self->YOff;
+
+ if( self->InFrame || self->InTile ) xo = yo = 0;
+ x += xo; y += yo;
+ sprintf(cacheID, "c%di", cache_id);
+
+ S_OutNum(self, (float)x);
+ S_OutNum(self, (float)y);
+
+ if( fclr==PSOUTCOLOR_WHITE )
+ {
+ int ir = PSOUTCOLOR_TO_REDBITS(bclr);
+ int ig = PSOUTCOLOR_TO_GREENBITS(bclr);
+ int ib = PSOUTCOLOR_TO_BLUEBITS(bclr);
+
+ if( ir==ig && ig==ib )
+ S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir));
+ else
+ S_OutNum(self, (float)0);
+ self->RevImage = 1;
+ }
+ else
+ {
+ int ir = PSOUTCOLOR_TO_REDBITS(fclr);
+ int ig = PSOUTCOLOR_TO_GREENBITS(fclr);
+ int ib = PSOUTCOLOR_TO_BLUEBITS(fclr);
+
+ if( ir==ig && ig==ib )
+ S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir));
+ else
+ S_OutNum(self, (float)0);
+ }
+
+ S_OutTok(self, cacheID, 1);
+} /* new */
+
+void /* new */
+PsOut_BeginImageCache(PsOutPtr self, long cache_id)
+{
+ char cacheID[10];
+
+ sprintf(cacheID, "/c%di {", cache_id);
+
+ S_OutTok(self, cacheID, 0);
+} /* new */
+
+void /* new */
+PsOut_EndImageCache(PsOutPtr self)
+{
+ S_OutTok(self, "}bd", 1);
+} /* new */
+#endif
+
+void
+PsOut_BeginImage(PsOutPtr self, PsOutColor bclr, PsOutColor fclr, int x, int y,
+ int w, int h, int sw, int sh, int format)
+{
+ PsOutColor savClr = self->CurColor;
+ int xo = self->XOff;
+ int yo = self->YOff;
+
+ if( self->InFrame || self->InTile ) xo = yo = 0;
+ x += xo; y += yo;
+ if( self->InTile )
+ {
+ if( self->InTile>=PsStip && format!=1 ) { self->ImgSkip = 1; return; }
+ self->ImgBClr = bclr; self->ImgFClr = fclr;
+ self->ImgX = x; self->ImgY = y;
+ self->ImgW = w; self->ImgH = h;
+ self->SclW = sw; self->SclH = sh;
+ S_OutTok(self, "<", 0);
+ self->ImageFormat = format;
+ self->RevImage = 0;
+ if( self->InTile==PsTile && format==1 && fclr==PSOUTCOLOR_WHITE )
+ self->RevImage = 1;
+ return;
+ }
+
+ self->RevImage = 0;
+ if( format==1 )
+ {
+ S_OutTok(self, "gs", 0);
+ if( fclr==PSOUTCOLOR_WHITE )
+ {
+ PsOut_Color(self, fclr);
+ PsOut_FillRect(self, x, y, sw, sh);
+ PsOut_Color(self, bclr);
+ self->RevImage = 1;
+ }
+ else
+ {
+ PsOut_Color(self, bclr);
+ PsOut_FillRect(self, x, y, sw, sh);
+ PsOut_Color(self, fclr);
+ }
+ }
+ S_OutNum(self, (float)x);
+ S_OutNum(self, (float)y);
+ S_OutNum(self, (float)w);
+ S_OutNum(self, (float)h);
+ S_OutNum(self, (float)sw);
+ S_OutNum(self, (float)sh);
+ if( format==1 ) {
+ if(self->RevImage)
+ S_OutTok(self, "Im1rev", 1);
+ else
+ S_OutTok(self, "Im1", 1);
+ }
+ else S_OutTok(self, "Im24", 1);
+ self->ImageFormat = format;
+ self->CurColor = savClr;
+}
+
+void
+PsOut_BeginImageIM(PsOutPtr self, PsOutColor bclr, PsOutColor fclr, int x, int y,
+ int w, int h, int sw, int sh, int format)
+{
+ PsOutColor savClr = self->CurColor;
+ int xo = self->XOff;
+ int yo = self->YOff;
+
+ if( self->InFrame || self->InTile ) xo = yo = 0;
+ x += xo; y += yo;
+ if( self->InTile )
+ {
+ if( self->InTile>=PsStip && format!=1 ) { self->ImgSkip = 1; return; }
+ self->ImgBClr = bclr; self->ImgFClr = fclr;
+ self->ImgX = x; self->ImgY = y;
+ self->ImgW = w; self->ImgH = h;
+ self->SclW = sw; self->SclH = sh;
+ S_OutTok(self, "<", 0);
+ self->ImageFormat = format;
+ self->RevImage = 0;
+ if( self->InTile==PsTile && format==1 && fclr==PSOUTCOLOR_WHITE )
+ self->RevImage = 1;
+ return;
+ }
+
+ self->RevImage = 0;
+ if( format==1 )
+ {
+ S_OutTok(self, "gs", 0);
+#ifdef BM_CACHE
+ S_OutTok(self, "g", 1);
+#else
+ if( fclr==PSOUTCOLOR_WHITE )
+ {
+ PsOut_Color(self, bclr);
+ self->RevImage = 1;
+ }
+ else
+ {
+ PsOut_Color(self, fclr);
+ }
+#endif
+ }
+
+#ifdef BM_CACHE
+ S_OutTok(self, "tr", 0); /* new */
+#else
+ S_OutNum(self, (float)x);
+ S_OutNum(self, (float)y);
+#endif
+ S_OutNum(self, (float)w);
+ S_OutNum(self, (float)h);
+ S_OutNum(self, (float)sw);
+ S_OutNum(self, (float)sh);
+#ifdef BM_CACHE
+ S_OutTok(self, "mtx", 1); /* new */
+ S_OutTok(self, "<", 0); /* new */
+ self->start_image = 1;
+#else
+ if( format==1 ){
+ if(self->RevImage)
+ S_OutTok(self, "Im1rev", 1);
+ else
+ S_OutTok(self, "Im1", 1);
+ }
+ else S_OutTok(self, "Im24", 1);
+#endif
+ self->ImageFormat = format;
+ self->CurColor = savClr;
+}
+
+void
+PsOut_EndImage(PsOutPtr self)
+{
+ if( self->ImgSkip ) { self->ImgSkip = 0; return; }
+ if( self->InTile )
+ {
+ S_OutTok(self, ">", 1);
+ if( self->ImageFormat==1 && self->InTile==PsTile )
+ {
+ if( self->ImgFClr==PSOUTCOLOR_WHITE )
+ {
+ PsOut_Color(self, self->ImgFClr);
+ PsOut_FillRect(self, self->ImgX, self->ImgY, self->SclW, self->SclH);
+ PsOut_Color(self, self->ImgBClr);
+ }
+ else
+ {
+ PsOut_Color(self, self->ImgBClr);
+ PsOut_FillRect(self, self->ImgX, self->ImgY, self->SclW, self->SclH);
+ PsOut_Color(self, self->ImgFClr);
+ }
+ }
+ S_OutNum(self, (float)self->ImgX);
+ S_OutNum(self, (float)self->ImgY);
+ S_OutNum(self, (float)self->ImgW);
+ S_OutNum(self, (float)self->ImgH);
+ S_OutNum(self, (float)self->SclW);
+ S_OutNum(self, (float)self->SclH);
+ if( self->ImageFormat==1 ) S_OutTok(self, "Im1t", 1);
+ else S_OutTok(self, "Im24t", 1);
+ self->ImageFormat = 0;
+ self->RevImage = 0;
+ return;
+ }
+ /*
+ * Bug 4639307: Move flush before "> im" to get all of bitmap into ps file.
+ */
+ S_Flush(self);
+#ifdef BM_CACHE
+ if(self->start_image)
+ S_OutTok(self, "> im", 1); /* new */
+#endif
+ self->ImageFormat = 0;
+ self->RevImage = 0;
+#ifdef BM_CACHE
+ if(self->start_image)
+ {
+ self->start_image = 0;
+ S_OutTok(self, "gr", 0);
+ }
+ else
+ S_OutTok(self, "gr", 1);
+#else
+ S_OutTok(self, "gr", 1);
+#endif
+}
+
+void
+PsOut_OutImageBytes(PsOutPtr self, int nBytes, char *bytes)
+{
+ int i;
+ int b;
+ int len;
+ const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+
+ if( (!self->ImageFormat) || self->ImgSkip ) return;
+
+ len = strlen(self->Buf);
+
+ for( i=0 ; i<nBytes ; i++ )
+ {
+ if( self->RevImage ) b = (int)((bytes[i]^0xFF)&0xFF);
+ else b = (int)(bytes[i]&0xFF);
+
+ self->Buf[len++] = hex[(b&0xF0) >> 4];
+ self->Buf[len++] = hex[(b&0x0F)];
+ self->Buf[len] = '\0';
+
+ if( len>70 )
+ {
+ S_Flush(self);
+ len = 0;
+ }
+ }
+}
+
+void
+PsOut_BeginFrame(PsOutPtr self, int xoff, int yoff, int x, int y,
+ int w, int h)
+{
+ int xo = self->XOff;
+ int yo = self->YOff;
+
+ if( self->InFrame ) xo = yo = 0;
+ S_OutTok(self, "gs", 0);
+ S_OutNum(self, (float)(x+xo));
+ S_OutNum(self, (float)(y+yo));
+ S_OutNum(self, (float)w);
+ S_OutNum(self, (float)h);
+ S_OutTok(self, "R cl n", 0);
+ xoff += xo; yoff += yo;
+ if( xoff || yoff )
+ {
+ S_OutNum(self, (float)xoff);
+ S_OutNum(self, (float)yoff);
+ S_OutTok(self, "tr", 0);
+ }
+ S_OutTok(self, "gs", 1);
+ self->InFrame += 1;
+}
+
+void
+PsOut_EndFrame(PsOutPtr self)
+{
+ self->InFrame -= 1;
+ if( self->InFrame<0 ) self->InFrame = 0;
+ S_OutTok(self, "gr gr", 1);
+ PsOut_DirtyAttributes(self);
+}
+
+int
+PsOut_BeginPattern(PsOutPtr self, void *tag, int w, int h, PsFillEnum type,
+ PsOutColor bclr, PsOutColor fclr)
+{
+ int i;
+ char key[64];
+
+ for( i=0 ; i<self->NPatterns ; i++ )
+ { if( self->Patterns[i].tag==tag && self->Patterns[i].type==type ) break; }
+ if( i<self->NPatterns ) return(1);
+ if( (self->NPatterns+1)>self->MxPatterns )
+ {
+ if( self->Patterns )
+ {
+ self->MxPatterns *= 2;
+ self->Patterns =
+ (PsPatPtr)xrealloc(self->Patterns, sizeof(PsPatRec)*self->MxPatterns);
+ }
+ else
+ {
+ self->MxPatterns = 64;
+ self->Patterns = (PsPatPtr)xalloc(sizeof(PsPatRec)*self->MxPatterns);
+ }
+ }
+ self->Patterns[self->NPatterns].tag = tag;
+ self->Patterns[self->NPatterns].type = type;
+ sprintf(key, "/ %d", (int)tag);
+ switch(type) {
+ case PsTile: key[1] = 't'; break;
+ case PsStip: key[1] = 's'; break;
+ case PsOpStip: key[1] = 'o'; break; }
+ S_OutTok(self, key, 0);
+ S_OutTok(self, "db/PatternType 1 d/PaintType 1 d", 0);
+ S_OutTok(self, "/TilingType 1 d/BBox[0 0", 0);
+ S_OutNum(self, (float)w);
+ S_OutNum(self, (float)h);
+ S_OutTok(self, "]d/XStep", 0);
+ S_OutNum(self, (float)w);
+ S_OutTok(self, "d/YStep", 0);
+ S_OutNum(self, (float)h);
+ S_OutTok(self, "d/PaintProc{bg sv", 1);
+ if( type==PsOpStip )
+ {
+ S_Color(self, bclr);
+ S_OutTok(self, "0 0", 0);
+ S_OutNum(self, (float)w);
+ S_OutNum(self, (float)h);
+ S_OutTok(self, "R fl", 1);
+ }
+ if( type!=PsTile ) S_Color(self, fclr);
+ self->NPatterns += 1;
+ self->InTile = type;
+ return(0);
+}
+
+void
+PsOut_EndPattern(PsOutPtr self)
+{
+ self->InTile = PsSolid;
+ S_OutTok(self, "rs ed}d de im_ mp d", 1);
+}
+
+void
+PsOut_SetPattern(PsOutPtr self, void *tag, PsFillEnum type)
+{
+ int i;
+ char key[64];
+
+ for( i=0 ; i<self->NPatterns ; i++ )
+ { if( tag==self->Patterns[i].tag && type==self->Patterns[i].type ) break; }
+ if( i>=self->NPatterns ) return;
+ sprintf(key, " %d", (int)tag);
+ switch(type) {
+ case PsTile: key[0] = 't'; break;
+ case PsStip: key[0] = 's'; break;
+ case PsOpStip: key[0] = 'o'; break; }
+ S_OutTok(self, key, 0);
+ S_OutTok(self, "spt", 1);
+ self->CurColor = PSOUTCOLOR_NOCOLOR;
+}
+
+void
+PsOut_RawData(PsOutPtr self, char *data, int len)
+{
+ S_Flush(self);
+ if (!ferror(self->Fp)) {
+ (void) fwrite(data, 1, len, self->Fp);
+ }
+}
+
+typedef enum PsDownfontFontType_
+{
+ PsDFT_Type1PFA=0,
+ PsDFT_Type1PFB,
+ PsDFT_TrueType /* not implemented yet */
+} PsDownfontFontType;
+
+/* Download a PS Type1 font */
+int
+PsOut_DownloadType1(PsOutPtr self, const char *auditmsg, const char *name, const char *fname)
+{
+ int i;
+ int stt;
+ char buf[256];
+ FILE *fp;
+ PsDownfontFontType type;
+
+ fp = fopen(fname, "r");
+ if( !fp )
+ return 0;
+
+#ifdef DEBUG_gisburn
+ /* This should be log-able! */
+ fprintf(stderr, "PsOut_DownloadType1: %s: Downloading '%s' from '%s'\n", auditmsg, name, fname);
+#endif /* DEBUG_gisburn */
+
+ fread(buf, 32, 1, fp);
+ fseek(fp, (long)0, 0);
+
+ /* Is this a Adobe PostScript Type 1 binary font (PFB) ? */
+ if( (buf[0]&0xFF)==0x80 && (buf[1]&0xFF)==0x01 )
+ {
+ type = PsDFT_Type1PFB;
+ }
+ /* Is this a Adobe PostScript ASCII font (PFA) ? */
+ else if (!strncmp(buf, "%!PS-AdobeFont", 14))
+ {
+ type = PsDFT_Type1PFA;
+ }
+ else
+ {
+ /* This should be log-able! */
+ fprintf(stderr, "PsOut_DownloadType1: Unknown font type for '%s'\n", fname);
+ return 0;
+ }
+
+ S_Flush(self);
+ sprintf(buf, "%%%%BeginFont: %s", name);
+ S_Comment(self, buf);
+
+ if( type == PsDFT_Type1PFB )
+ {
+ char *buf,
+ *pt;
+ int len,
+ ch,
+ stype;
+
+ ch = fgetc(fp);
+ /* Strip out the binary headers and de-binary it */
+ while( (ch&0xFF) == 0x80 )
+ {
+ stype = fgetc(fp);
+ if( stype==3 ) /* eof mark */
+ break;
+ len = fgetc(fp);
+ len |= fgetc(fp)<<8;
+ len |= fgetc(fp)<<16;
+ len |= fgetc(fp)<<24;
+ buf = (char *)xalloc(len+1);
+ if( stype==1 )
+ {
+ /* Process ASCII section */
+ len = fread(buf, 1, len, fp);
+ /* convert any lone CRs (ie Mac eol) to LFs */
+ for( pt = buf ; (pt = memchr(pt, '\r', len-(pt-buf))) != NULL ; pt++ )
+ {
+ if ( pt[1]!='\n' )
+ *pt = '\n';
+ }
+ fwrite(buf, 1, len, self->Fp);
+ }
+ else if( stype==2 )
+ {
+ int i;
+
+ /* Process binary section */
+ len = fread(buf, 1, len, fp);
+ for( i=0 ; i<len ; i++ )
+ {
+ ch = buf[i];
+ if( ((ch>>4)&0xf) <= 9 )
+ fputc('0'+((ch>>4)&0xf), self->Fp);
+ else
+ fputc('A'-10+((ch>>4)&0xf), self->Fp);
+
+ if( (ch&0xf) <= 9 )
+ fputc('0'+(ch&0xf), self->Fp);
+ else
+ fputc('A'-10+(ch&0xf), self->Fp);
+
+ if( (i&0x1f)==0x1f )
+ fputc('\n', self->Fp);
+ }
+ }
+ xfree(buf);
+
+ /* Next block... */
+ ch = fgetc(fp);
+ }
+ }
+ /* Is this a Adobe PostScript ASCII font (PFA) ? */
+ else if (type == PsDFT_Type1PFA)
+ {
+ for(;;)
+ {
+ stt = fread(buf, 1, 256, fp);
+ if( stt<=0 ) break;
+ if (!ferror(self->Fp)) {
+ (void) fwrite(buf, 1, stt, self->Fp);
+ }
+ if( stt<256 )
+ break;
+ }
+ }
+ fclose(fp);
+ S_Flush(self);
+ S_Comment(self, "%%EndFont");
+
+ /* Success... */
+ return 1;
+}
+
+
+
+
+
+
diff --git a/nx-X11/programs/Xserver/Xprint/ps/psout.h b/nx-X11/programs/Xserver/Xprint/ps/psout.h
new file mode 100644
index 000000000..8441d8d07
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/psout.h
@@ -0,0 +1,335 @@
+/* $Xorg: psout.h,v 1.6 2001/02/09 02:04:37 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * (c) Copyright 1996 Hewlett-Packard Company
+ * (c) Copyright 1996 International Business Machines Corp.
+ * (c) Copyright 1996 Sun Microsystems, Inc.
+ * (c) Copyright 1996 Novell, Inc.
+ * (c) Copyright 1996 Digital Equipment Corp.
+ * (c) Copyright 1996 Fujitsu Limited
+ * (c) Copyright 1996 Hitachi, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the copyright holders
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from said copyright holders.
+ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: psout.h
+** *
+** * Contents: Include file for psout.c
+** *
+** * Created By: Roger Helmendach (Liberty Systems)
+** *
+** * Copyright: Copyright 1996 The Open Group, Inc.
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _psout_
+#define _psout_
+
+#include <stdio.h>
+
+typedef enum PsCapEnum_ { PsCButt=0, PsCRound, PsCSquare } PsCapEnum;
+typedef enum PsJoinEnum_ { PsJMiter=0, PsJRound, PsJBevel } PsJoinEnum;
+typedef enum PsArcEnum_ { PsChord, PsPieSlice } PsArcEnum;
+typedef enum PsRuleEnum_ { PsEvenOdd, PsNZWinding } PsRuleEnum;
+typedef enum PsFillEnum_ { PsSolid=0, PsTile, PsStip, PsOpStip } PsFillEnum;
+
+typedef struct PsPointRec_
+{
+ int x;
+ int y;
+} PsPointRec;
+
+typedef PsPointRec *PsPointPtr;
+
+typedef struct PsRectRec_
+{
+ int x;
+ int y;
+ int w;
+ int h;
+} PsRectRec;
+
+typedef PsRectRec *PsRectPtr;
+
+typedef struct PsArcRec_
+{
+ int x;
+ int y;
+ int w;
+ int h;
+ int a1;
+ int a2;
+ PsArcEnum style;
+} PsArcRec;
+
+typedef PsArcRec *PsArcPtr;
+
+#define PSOUT_RECT 0
+#define PSOUT_ARC 1
+#define PSOUT_POINTS 2
+
+typedef struct PsElmRec_
+{
+ int type;
+ int nPoints;
+ union
+ {
+ PsRectRec rect;
+ PsArcRec arc;
+ PsPointPtr points;
+ } c;
+} PsElmRec;
+
+typedef PsElmRec *PsElmPtr;
+
+typedef struct PsClipRec_
+{
+ int nRects;
+ PsRectPtr rects;
+ int nElms;
+ PsElmPtr elms;
+ int nOutterClips;
+ PsRectPtr outterClips;
+} PsClipRec;
+
+typedef PsClipRec *PsClipPtr;
+
+typedef enum PsFTDownloadFontType_
+{
+ PsFontBitmap=0,
+ PsFontType1,
+ PsFontType3
+} PsFTDownloadFontType;
+
+/* Define |PsOutColor| color type which can hold one RGB value
+ * (note: this needs to be |signed| long/long long to represent
+ * special values such as |PSOUTCOLOR_NOCOLOR|)
+ */
+#ifdef PSOUT_USE_DEEPCOLOR
+/* 64bit |PsOutColor| which can hold 16bit R-,G-,B-values */
+#ifdef WIN32
+typedef signed __int64 PsOutColor;
+#else
+# if defined(__alpha__) || defined(__alpha) || \
+ defined(ia64) || defined(__ia64__) || \
+ defined(__sparc64__) || defined(_LP64) || \
+ defined(__s390x__) || \
+ defined(amd64) || defined (__amd64__) || \
+ defined (__powerpc64__) || \
+ (defined(sgi) && (_MIPS_SZLONG == 64))
+typedef signed long PsOutColor;
+# else
+typedef signed long long PsOutColor;
+# endif /* native 64bit platform */
+#endif /* WIN32 */
+
+#define PSOUTCOLOR_TO_REDBITS(clr) ((clr) >> 32)
+#define PSOUTCOLOR_TO_GREENBITS(clr) (((clr) >> 16) & 0xFFFF)
+#define PSOUTCOLOR_TO_BLUEBITS(clr) ((clr) & 0xFFFF)
+#define PSOUTCOLOR_BITS_TO_PSFLOAT(b) ((float)(b) / 65535.)
+#define PSOUTCOLOR_WHITE (0xFFFFFFFFFFFFLL)
+#define PSOUTCOLOR_NOCOLOR (-1LL)
+#define PSOUTCOLOR_TO_RGB24BIT(clr) (((PSOUTCOLOR_TO_REDBITS(clr) >> 8) << 16) | \
+ ((PSOUTCOLOR_TO_GREENBITS(clr) >> 8) << 8) | \
+ ((PSOUTCOLOR_TO_BLUEBITS(clr) >> 8) << 0))
+#else
+/* 32bit |PsOutColor| which can hold 8bit R-,G-,B-values */
+typedef signed long PsOutColor;
+#define PSOUTCOLOR_TO_REDBITS(clr) ((clr) >> 16)
+#define PSOUTCOLOR_TO_GREENBITS(clr) (((clr) >> 8) & 0xFF)
+#define PSOUTCOLOR_TO_BLUEBITS(clr) ((clr) & 0xFF)
+#define PSOUTCOLOR_BITS_TO_PSFLOAT(b) ((float)(b) / 255.)
+#define PSOUTCOLOR_WHITE (0xFFFFFF)
+#define PSOUTCOLOR_NOCOLOR (-1)
+#define PSOUTCOLOR_TO_RGB24BIT(clr) ((PSOUTCOLOR_TO_REDBITS(clr) << 16) | \
+ (PSOUTCOLOR_TO_GREENBITS(clr) << 8) | \
+ (PSOUTCOLOR_TO_BLUEBITS(clr) << 0))
+#endif /* PSOUT_USE_DEEPCOLOR */
+
+#ifdef USE_PSOUT_PRIVATE
+typedef void *voidPtr;
+
+typedef struct PsPatRec_
+{
+ PsFillEnum type;
+ voidPtr tag;
+} PsPatRec;
+
+typedef PsPatRec *PsPatPtr;
+
+typedef struct PsOutRec_
+{
+ FILE *Fp;
+ char Buf[16384];
+ PsOutColor CurColor;
+ int LineWidth;
+ PsCapEnum LineCap;
+ PsJoinEnum LineJoin;
+ int NDashes;
+ int *Dashes;
+ int DashOffset;
+ PsOutColor LineBClr;
+ PsRuleEnum FillRule;
+ char *FontName;
+ int FontSize;
+ float FontMtx[4];
+ int ImageFormat;
+ int RevImage;
+ int NPatterns;
+ int MxPatterns;
+ PsPatPtr Patterns;
+ int ClipType;
+ PsClipRec Clip;
+ int InFrame;
+ int XOff;
+ int YOff;
+
+ PsFillEnum InTile;
+ int ImgSkip;
+ PsOutColor ImgBClr;
+ PsOutColor ImgFClr;
+ int ImgX;
+ int ImgY;
+ int ImgW;
+ int ImgH;
+ int SclW;
+ int SclH;
+
+ Bool isRaw;
+
+ int pagenum;
+
+ int start_image;
+} PsOutRec;
+
+typedef struct PsOutRec_ *PsOutPtr;
+
+extern void S_Flush(PsOutPtr self);
+extern void S_OutNum(PsOutPtr self, float num);
+extern void S_OutTok(PsOutPtr self, char *tok, int cr);
+#else
+typedef struct PsOutRec_ *PsOutPtr;
+#endif /* USE_PSOUT_PRIVATE */
+
+extern PsOutPtr PsOut_BeginFile(FILE *fp, char *title, int orient, int count, int plex,
+ int res, int wd, int ht, Bool raw);
+extern void PsOut_EndFile(PsOutPtr self, int closeFile);
+extern void PsOut_BeginPage(PsOutPtr self, int orient, int count, int plex,
+ int res, int wd, int ht);
+extern void PsOut_EndPage(PsOutPtr self);
+extern void PsOut_DirtyAttributes(PsOutPtr self);
+extern void PsOut_Comment(PsOutPtr self, char *comment);
+extern void PsOut_Offset(PsOutPtr self, int x, int y);
+
+extern void PsOut_Clip(PsOutPtr self, int clpTyp, PsClipPtr clpinf);
+
+extern void PsOut_Color(PsOutPtr self, PsOutColor clr);
+extern void PsOut_FillRule(PsOutPtr self, PsRuleEnum rule);
+extern void PsOut_LineAttrs(PsOutPtr self, int wd, PsCapEnum cap,
+ PsJoinEnum join, int nDsh, int *dsh, int dshOff,
+ PsOutColor bclr);
+extern void PsOut_TextAttrs(PsOutPtr self, char *fnam, int siz, int iso);
+extern void PsOut_TextAttrsMtx(PsOutPtr self, char *fnam, float *mtx, int iso);
+
+extern void PsOut_Polygon(PsOutPtr self, int nPts, PsPointPtr pts);
+extern void PsOut_FillRect(PsOutPtr self, int x, int y, int w, int h);
+extern void PsOut_FillArc(PsOutPtr self, int x, int y, int w, int h,
+ float ang1, float ang2, PsArcEnum style);
+
+extern void PsOut_Lines(PsOutPtr self, int nPts, PsPointPtr pts);
+extern void PsOut_Points(PsOutPtr self, int nPts, PsPointPtr pts);
+extern void PsOut_DrawRect(PsOutPtr self, int x, int y, int w, int h);
+extern void PsOut_DrawArc(PsOutPtr self, int x, int y, int w, int h,
+ float ang1, float ang2);
+
+extern void PsOut_Text(PsOutPtr self, int x, int y, char *text, int textl,
+ PsOutColor bclr);
+extern void PsOut_Text16(PsOutPtr self, int x, int y, unsigned short *text, int textl, PsOutColor bclr);
+
+extern void PsOut_BeginImage(PsOutPtr self, PsOutColor bclr, PsOutColor fclr, int x, int y,
+ int w, int h, int sw, int sh, int format);
+extern void PsOut_BeginImageIM(PsOutPtr self, PsOutColor bclr, PsOutColor fclr, int x, int y,
+ int w, int h, int sw, int sh, int format);
+extern void PsOut_EndImage(PsOutPtr self);
+extern void PsOut_OutImageBytes(PsOutPtr self, int nBytes, char *bytes);
+
+extern void PsOut_BeginFrame(PsOutPtr self, int xoff, int yoff, int x, int y,
+ int w, int h);
+extern void PsOut_EndFrame(PsOutPtr self);
+
+extern int PsOut_BeginPattern(PsOutPtr self, void *tag, int w, int h,
+ PsFillEnum type, PsOutColor bclr, PsOutColor fclr);
+extern void PsOut_EndPattern(PsOutPtr self);
+extern void PsOut_SetPattern(PsOutPtr self, void *tag, PsFillEnum type);
+
+extern void PsOut_RawData(PsOutPtr self, char *data, int len);
+
+extern int PsOut_DownloadType1(PsOutPtr self, const char *auditmsg, const char *name, const char *fname);
+
+extern int PsOut_DownloadFreeType1(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset);
+extern int PsOut_DownloadFreeType3(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset);
+
+extern int PsOut_DownloadFreeType(PsOutPtr self, PsFTDownloadFontType downloadfonttype, const char *psfontname, FontPtr pFont, long block_offset);
+extern void PsOut_Get_FreeType_Glyph_Name( char *destbuf, FontPtr pFont, unsigned long x11fontindex);
+extern void PsOut_FreeType_Text(FontPtr pFont, PsOutPtr self, int x, int y, char *text, int textl);
+extern void PsOut_FreeType_Text16(FontPtr pFont, PsOutPtr self, int x, int y, unsigned short *text, int textl);
+
+extern void PsOut_FreeType_TextAttrs16(PsOutPtr self, char *fnam, int siz, int iso);
+extern void PsOut_FreeType_TextAttrsMtx16(PsOutPtr self, char *fnam, float *mtx, int iso);
+#endif
diff --git a/nx-X11/programs/Xserver/Xprint/ps/psout_ft.c b/nx-X11/programs/Xserver/Xprint/ps/psout_ft.c
new file mode 100644
index 000000000..34cb6a54d
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/psout_ft.c
@@ -0,0 +1,335 @@
+
+/*
+Copyright (c) 2003-2004 Roland Mainz <roland.mainz@nrubsig.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "os.h"
+#define USE_PSOUT_PRIVATE 1
+#include "psout.h"
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_TYPE1_TABLES_H
+
+#include <X11/Xproto.h>
+#include <X11/fonts/font.h>
+#include <X11/fonts/fontstruct.h>
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/fontutil.h>
+#include <X11/fonts/fontenc.h>
+#include "ft.h"
+#define NOT_IN_FTFUNCS
+#include "ftfuncs.h"
+#include "servermd.h" /* needed for endian test (IMAGE_BYTE_ORDER) */
+
+#define USE_FT_PS_NAMES 1
+
+#ifdef USE_FT_PS_NAMES
+void PsOut_Get_FreeType_Glyph_Name( char *destbuf, FontPtr pFont, unsigned long x11fontindex)
+{
+ FTFontPtr tf = (FTFontPtr)pFont->fontPrivate;
+ FT_Face ttface = tf->instance->face->face;
+ FT_Error error;
+ char buf[256];
+ unsigned long ftindex;
+
+ /* Remap X11 font index to FreeType font index */
+ ftindex = FTRemap(ttface, &tf->mapping, x11fontindex);
+
+ if( FT_Has_PS_Glyph_Names(ttface) )
+ {
+ error = FT_Get_Glyph_Name(ttface, ftindex, buf, 64);
+ }
+ else
+ {
+ error = 1;
+ }
+
+ if( error )
+ {
+ /* Check for unicode mapping
+ * See Adobe document "Unicode and Glyph Names"
+ * (http://partners.adobe.com/asn/tech/type/unicodegn.jsp)
+ */
+ if( (tf->mapping.mapping->type == FONT_ENCODING_UNICODE) &&
+ (ftindex < 0xFFFE) )
+ {
+ sprintf(buf, "uni%04lx", ftindex);
+ }
+ else
+ {
+ sprintf(buf, "ch%02lx", ftindex);
+ }
+ }
+
+ strcpy(destbuf, buf);
+}
+#endif /* USE_FT_PS_NAMES */
+
+int PsOut_DownloadFreeType(PsOutPtr self, PsFTDownloadFontType downloadfonttype, const char *psfontname, FontPtr pFont, long block_offset)
+{
+ switch(downloadfonttype)
+ {
+ case PsFontType3:
+ return PsOut_DownloadFreeType3(self, psfontname, pFont, block_offset);
+ case PsFontType1:
+ return PsOut_DownloadFreeType1(self, psfontname, pFont, block_offset);
+ default:
+ FatalError("PS DDX: PsOut_DownloadFreeType(downloadfonttype='%d' not implemented\n",
+ (int)downloadfonttype);
+ return 0; /* NO-OP, FatalError() will call |exit()| */
+ }
+}
+
+/* cloned from |PsOut_TextAttrs16| */
+void
+PsOut_FreeType_TextAttrs16(PsOutPtr self, char *fnam, int siz, int iso)
+{
+ int i;
+ if( self->FontName && strcmp(fnam, self->FontName)==0 &&
+ siz==self->FontSize ) return;
+ if( self->FontName ) xfree(self->FontName);
+ self->FontName = (char *)xalloc(strlen(fnam)+1);
+ strcpy(self->FontName, fnam);
+ self->FontSize = siz;
+ for( i=0 ; i<4 ; i++ ) self->FontMtx[i] = -1.;
+}
+
+/* cloned from |PsOut_TextAttrsMtx16| */
+void
+PsOut_FreeType_TextAttrsMtx16(PsOutPtr self, char *fnam, float *mtx, int iso)
+{
+ int i;
+ if( self->FontName && strcmp(fnam, self->FontName)==0 &&
+ mtx[0]==self->FontMtx[0] && mtx[1]==self->FontMtx[1] &&
+ mtx[2]==self->FontMtx[2] && mtx[3]==self->FontMtx[3] ) return;
+ if( self->FontName ) xfree(self->FontName);
+ self->FontName = (char *)xalloc(strlen(fnam)+1);
+ strcpy(self->FontName, fnam);
+ for( i=0 ; i<4 ; i++ ) self->FontMtx[i] = mtx[i];
+ self->FontSize = -1;
+}
+
+static
+int FT_Get_CharcellMetricsCharacterHeight(FontPtr pFont)
+{
+ FTFontPtr ftfont = (FTFontPtr)pFont->fontPrivate;
+
+ return ftfont->instance->charcellMetrics->ascent +
+ ftfont->instance->charcellMetrics->descent;
+}
+
+static
+int FT_Get_CharcellMetricsCharacterWidth(FontPtr pFont)
+{
+ FTFontPtr ftfont = (FTFontPtr)pFont->fontPrivate;
+
+ if( ftfont->instance->spacing != FT_PROPORTIONAL )
+ {
+ int width = ftfont->instance->charcellMetrics->characterWidth;
+
+ /* If the font uses a matrix make sure we transform the |characterWidth|
+ * back to it's original value since we download the untransformed font
+ * and use a PostScript transformation matrix to transform the font when
+ * rendering the text
+ */
+ if( ftfont->instance->transformation.nonIdentity )
+ {
+ FT_Vector v;
+
+ FT_Matrix m = ftfont->instance->transformation.matrix;
+ (void)FT_Matrix_Invert(&m); /* FixMe: We should check the return code */
+ v.x = width;
+ v.y = FT_Get_CharcellMetricsCharacterHeight(pFont);
+ FT_Vector_Transform(&v, &m);
+ width = v.x;
+ }
+
+ return width;
+ }
+
+ return 0;
+}
+
+void
+PsOut_FreeType_Text(FontPtr pFont, PsOutPtr self, int x, int y, char *text, int textl)
+{
+ int i;
+ int xo = self->XOff,
+ yo = self->YOff;
+ char buf[256];
+ int cwidth = FT_Get_CharcellMetricsCharacterWidth(pFont);
+
+ if( self->InFrame || self->InTile ) xo = yo = 0;
+ x += xo; y += yo;
+
+ S_OutNum(self, (float)x);
+ S_OutNum(self, (float)y);
+ S_OutTok(self, "moveto", 1);
+
+ S_OutTok(self, "[ ", 0);
+
+ for( i = 0 ; i < textl ; i++ )
+ {
+#ifdef USE_FT_PS_NAMES
+ char namebuf[256];
+ unsigned int ch = text[i]&0xFF;
+ unsigned long block_offset = 0;
+ PsOut_Get_FreeType_Glyph_Name(namebuf, pFont, ch+block_offset);
+
+ sprintf(buf, "/%s ", namebuf);
+#else
+ sprintf(buf, "/ch%02x ", text[i]&0xFF);
+#endif /* USE_FT_PS_NAMES */
+ S_OutTok(self, buf, 0);
+ }
+
+ /* Check whether we have any special spacing requirements (e.g. non-proportional fonts) ... */
+ if( cwidth != 0 )
+ {
+ /* If the we use a matrix to render the font (instead of using |self->FontSize|)
+ * we must apply the matrix to the "rmoveto" which is used to force the exact
+ * character width. The "trmoveto" macro will do that for us...
+ */
+ if( self->FontSize == -1 )
+ {
+ sprintf(buf, "]{gs glyphshow gr %d 0 trmoveto}fa", cwidth);
+ }
+ else
+ {
+ sprintf(buf, "]{gs glyphshow gr %d 0 rm}fa", cwidth);
+ }
+ }
+ else
+ {
+ sprintf(buf, "]{glyphshow}fa");
+ }
+ S_OutTok(self, buf, 0);
+}
+
+/* XXX: |PsOut_FreeType_Text16| should be rewritten - currently it uses lame,
+ * slow hacks and makes some risky assumtions about how |PsOut_Text16|
+ * allocates memory */
+void
+PsOut_FreeType_Text16(FontPtr pFont, PsOutPtr self, int x, int y, unsigned short *text, int textl)
+{
+ int i;
+ int xo = self->XOff,
+ yo = self->YOff;
+ unsigned short c,
+ c_hiByte,
+ c_lowByte,
+ fontPage;
+ long lastFontPage = -1;
+ char baseFontName[256];
+ char buf[256];
+
+ if( self->InFrame || self->InTile ) xo = yo = 0;
+ x += xo; y += yo;
+
+ strcpy(baseFontName, self->FontName);
+
+ S_OutNum(self, (float)x);
+ S_OutNum(self, (float)y);
+ S_OutTok(self, "moveto", 1);
+
+ for( i = 0 ; i < textl ; i++ )
+ {
+ c = text[i];
+#if IMAGE_BYTE_ORDER == LSBFirst
+ c_hiByte = c & 0x00FF;
+ c_lowByte = (c >> 8) & 0x00FF;
+#elif IMAGE_BYTE_ORDER == MSBFirst
+ c_hiByte = (c >> 8) & 0x00FF;
+ c_lowByte = c & 0x00FF;
+#else
+#error Unsupported byte order
+#endif
+ fontPage = c_hiByte;
+
+ if( fontPage != lastFontPage )
+ {
+ if( fontPage > 0 )
+ {
+ sprintf(buf, "%s_%x", baseFontName, fontPage);
+ }
+ else
+ {
+ sprintf(buf, "%s", baseFontName);
+ }
+
+ if( self->FontSize == -1 )
+ {
+ PsOut_TextAttrsMtx(self, buf, self->FontMtx, FALSE);
+ }
+ else
+ {
+ PsOut_TextAttrs(self, buf, self->FontSize, FALSE);
+ }
+ lastFontPage = fontPage;
+ }
+
+#ifdef USE_FT_PS_NAMES
+ {
+ char namebuf[256];
+ unsigned int ch = c_lowByte;
+ unsigned long block_offset = c_hiByte * 0x100 /* same as c_hiByte << 8 */;
+ int cwidth = FT_Get_CharcellMetricsCharacterWidth(pFont);
+ PsOut_Get_FreeType_Glyph_Name(namebuf, pFont, ch+block_offset);
+
+ /* Check whether we have any special spacing requirements (e.g. non-proportional fonts) ... */
+ if( cwidth != 0 )
+ {
+ /* If the we use a matrix to render the font (instead of using |self->FontSize|)
+ * we must apply the matrix to the "rmoveto" which is used to force the exact
+ * character width. The "trmoveto" macro will do that for us...
+ */
+ if( self->FontSize == -1 )
+ {
+ sprintf(buf, "gs /%s glyphshow gr %d 0 trmoveto", namebuf, cwidth);
+ }
+ else
+ {
+ sprintf(buf, "gs /%s glyphshow gr %d 0 rm", namebuf, cwidth);
+ }
+ }
+ else
+ {
+ sprintf(buf, "/%s glyphshow", namebuf);
+ }
+ }
+#else
+ sprintf(buf, "/ch%02x glyphshow", c_lowByte);
+#endif /* USE_FT_PS_NAMES */
+ S_OutTok(self, buf, 1);
+ }
+
+ if( self->FontName ) xfree(self->FontName);
+ self->FontName = (char *)xalloc(strlen(baseFontName)+1);
+ strcpy(self->FontName, baseFontName);
+}
+
diff --git a/nx-X11/programs/Xserver/Xprint/ps/psout_ftpstype1.c b/nx-X11/programs/Xserver/Xprint/ps/psout_ftpstype1.c
new file mode 100644
index 000000000..19e1bde18
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/psout_ftpstype1.c
@@ -0,0 +1,185 @@
+
+/*
+Copyright (c) 2003-2004 Roland Mainz <roland.mainz@nrubsig.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/wait.h>
+
+#include "os.h"
+#define USE_PSOUT_PRIVATE 1
+#include "psout.h"
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+#include <X11/Xproto.h>
+#include <X11/fonts/font.h>
+#include <X11/fonts/fontstruct.h>
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/fontutil.h>
+#include <X11/fonts/fontenc.h>
+#include "ft.h"
+#define NOT_IN_FTFUNCS
+#include "ftfuncs.h"
+
+int do_debug_ft2pt1 = FALSE;
+int do_enable_ft2pt1_optimizer = FALSE;
+
+/* Defined in ttf2pt1.c */
+int ft2pt1_main(int argc, char **argv,
+ FTFontPtr tf, const char *download_psfontname, unsigned long download_font_block_offset);
+
+/* Download FreeType outlines as PS Type1 font */
+int PsOut_DownloadFreeType1(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset)
+{
+ FTFontPtr tf;
+ FT_Face face;
+ int ft2pt1_numargs = 0;
+ char *ft2pt1_args[40];
+ char *pstype1filename_prefix;
+ char pstype1filename[PATH_MAX+1];
+ int ft2pt1_main_retval;
+ pid_t childpid;
+
+ tf = (FTFontPtr)pFont->fontPrivate;
+ face = tf->instance->face->face;
+
+ /* Set debugging flags */
+ do_debug_ft2pt1 = (getenv("XPRT_PSDDX_DO_DEBUG_FT2PT1") != NULL);
+ do_enable_ft2pt1_optimizer = (getenv("XPRT_PSDDX_DO_ENABLE_FT2PT1_OPTIMIZER") != NULL);
+
+ if( do_debug_ft2pt1 )
+ {
+ fprintf(stderr, "# Converting FT2 font to PS Type1 filename='%s', ttface=%lx\n", tf->instance->face->filename, (long)face);
+ }
+
+ pstype1filename_prefix = tempnam(NULL, "Xprt_");
+
+ ft2pt1_args[ft2pt1_numargs] = "ft2pt1"; ft2pt1_numargs++;
+ ft2pt1_args[ft2pt1_numargs] = "-Ob"; ft2pt1_numargs++;
+ ft2pt1_args[ft2pt1_numargs] = "-e"; ft2pt1_numargs++;
+ ft2pt1_args[ft2pt1_numargs] = "-a"; ft2pt1_numargs++;
+ ft2pt1_args[ft2pt1_numargs] = "-Ga"; ft2pt1_numargs++;
+ if( do_enable_ft2pt1_optimizer )
+ {
+ /* Scale fonts to a 1000x1000 matrix */
+ ft2pt1_args[ft2pt1_numargs] = "-Ot"; ft2pt1_numargs++;
+ }
+ else
+ {
+ /* Disable the ttf2pt1 optimisations */
+ ft2pt1_args[ft2pt1_numargs] = "-Ou"; ft2pt1_numargs++;
+ ft2pt1_args[ft2pt1_numargs] = "-Oo"; ft2pt1_numargs++;
+ ft2pt1_args[ft2pt1_numargs] = "-Os"; ft2pt1_numargs++;
+ ft2pt1_args[ft2pt1_numargs] = "-Oh"; ft2pt1_numargs++;
+ }
+
+ if( !do_debug_ft2pt1 )
+ {
+ ft2pt1_args[ft2pt1_numargs] = "-W 0"; ft2pt1_numargs++;
+ }
+ ft2pt1_args[ft2pt1_numargs] = tf->instance->face->filename; ft2pt1_numargs++;
+ ft2pt1_args[ft2pt1_numargs] = pstype1filename_prefix; ft2pt1_numargs++;
+ ft2pt1_args[ft2pt1_numargs] = NULL;
+
+/* XXX: ttf2pt1 has lots of leaks and global vars which are not cleaned-up
+ * As long this problem exists we will simply fork() and call the converter
+ * from the child process (all resources are free'ed when the child process
+ * exists) as a workaround.
+ */
+#define FT2PT1_NEEDS_SEPERATE_PROCESS 1
+
+#ifdef FT2PT1_NEEDS_SEPERATE_PROCESS
+ /* Flush internal buffer and then the stdio stream before fork()! */
+ S_Flush(self);
+ fflush(self->Fp);
+
+ childpid = fork();
+ switch(childpid)
+ {
+ case -1:
+ FatalError("PS DDX internal error: Cannot fork() converter child process, errno=%d\n", (int)errno);
+ break;
+ case 0: /* child */
+ fclose(self->Fp);
+ self->Fp = NULL;
+
+ ft2pt1_main_retval = ft2pt1_main(ft2pt1_numargs, ft2pt1_args, tf, psfontname, block_offset);
+ if( do_debug_ft2pt1 )
+ {
+ fprintf(stderr, "## ft2pt1_main returned %d (child)\n", ft2pt1_main_retval);
+ }
+ exit(ft2pt1_main_retval);
+ break;
+ default: /* parent */
+ waitpid(childpid, &ft2pt1_main_retval, 0);
+ break;
+ }
+
+ if( do_debug_ft2pt1 )
+ {
+ fprintf(stderr, "## ft2pt1_main returned %d (parent)\n", ft2pt1_main_retval);
+ }
+#else
+ S_Flush(self);
+
+ ft2pt1_main_retval = ft2pt1_main(ft2pt1_numargs, ft2pt1_args, tf, psfontname, block_offset);
+ if( do_debug_ft2pt1 )
+ {
+ fprintf(stderr, "## ft2pt1_main returned %d (child)\n", ft2pt1_main_retval);
+ }
+#endif /* FT2PT1_NEEDS_SEPERATE_PROCESS */
+
+ if( ft2pt1_main_retval != EXIT_SUCCESS )
+ {
+ FatalError("PS DDX internal error while converting FreeType font '%s' to PS Type1, error=%d\n",
+ tf->instance->face->filename, ft2pt1_main_retval);
+ }
+
+ sprintf(pstype1filename, "%s.pfa", pstype1filename_prefix);
+ if( do_debug_ft2pt1 )
+ {
+ fprintf(stderr, "# Downloading converted FT2/PS Type1 filename='%s'\n", pstype1filename);
+ }
+
+ PsOut_DownloadType1(self, "PsOut_DownloadFreeType1", psfontname, pstype1filename);
+
+ if( !do_debug_ft2pt1 )
+ {
+ unlink(pstype1filename);
+ }
+
+ free(pstype1filename_prefix);
+
+ S_Flush(self);
+
+ return 0;
+}
+
+
diff --git a/nx-X11/programs/Xserver/Xprint/ps/psout_ftpstype3.c b/nx-X11/programs/Xserver/Xprint/ps/psout_ftpstype3.c
new file mode 100644
index 000000000..e9782e499
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/psout_ftpstype3.c
@@ -0,0 +1,468 @@
+
+/*
+Copyright (c) 2003-2004 Roland Mainz <roland.mainz@nrubsig.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "os.h"
+#define USE_PSOUT_PRIVATE 1
+#include "psout.h"
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_TRUETYPE_TABLES_H
+#include FT_BBOX_H
+#include FT_GLYPH_H
+
+#include FT_CONFIG_CONFIG_H
+#include FT_CONFIG_OPTIONS_H
+#include FT_ERRORS_H
+#include FT_SYSTEM_H
+#include FT_IMAGE_H
+#include FT_TYPES_H
+#include FT_OUTLINE_H
+#include FT_MODULE_H
+#include FT_RENDER_H
+#include FT_TYPE1_TABLES_H
+#include FT_TRUETYPE_IDS_H
+#include FT_TRUETYPE_TAGS_H
+#include FT_CACHE_H
+#include FT_CACHE_IMAGE_H
+#include FT_CACHE_SMALL_BITMAPS_H
+#include FT_MULTIPLE_MASTERS_H
+#include FT_SFNT_NAMES_H
+
+#define USE_FT_INTERNALS 1
+#ifdef USE_FT_INTERNALS
+#include FT_INTERNAL_TYPE1_TYPES_H
+#include "t42types.h"
+#include FT_INTERNAL_OBJECTS_H
+#endif /* USE_FT_INTERNALS */
+
+#include <X11/Xproto.h>
+#include <X11/fonts/font.h>
+#include <X11/fonts/fontstruct.h>
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/fontutil.h>
+#include <X11/fonts/fontenc.h>
+#include "ft.h"
+#define NOT_IN_FTFUNCS
+#include "ftfuncs.h"
+
+struct ft2info
+{
+ FontPtr pFont;
+ FTFontPtr tf;
+ FT_Face ttface;
+ struct
+ {
+ char *full_name;
+ char *copyright;
+ char *family;
+ char *subfamily;
+ char *version;
+ } nameid;
+ TT_Postscript *ttpostscript;
+ TT_Header *ttheader;
+};
+
+/* Local prototypes */
+static FT_Error PSType3_createOutlineGlyphs(FILE *out, struct ft2info *ti, unsigned long unicode, const char *psglyphname);
+static int PSType3_generateOutlineFont(FILE *out, const char *psfontname, struct ft2info *ti, long block_offset);
+
+extern FT_Library ftypeLibrary; /* defined in xc/lib/font/FreeType/ftfuncs.c */
+
+#define USE_FT_PS_NAMES 1
+
+static
+FT_Error PSType3_createOutlineGlyphs( FILE *out, struct ft2info *ti, unsigned long x11fontindex, const char *psglyphname )
+{
+ unsigned long ftindex;
+ FT_BBox bbox;
+ FT_Error error;
+ FT_Outline outline;
+
+ /* Remap X11 font index to FreeType font index */
+ ftindex = FTRemap(ti->ttface, &ti->tf->mapping, x11fontindex);
+
+ error = FT_Load_Glyph(ti->ttface, ftindex, (FT_LOAD_NO_BITMAP | FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING));
+ if( error )
+ {
+ fprintf(stderr, "PSType3_createOutlineGlyphs: FT_Load_Glyph() failure, error=%d\n", (int)error);
+ return error;
+ }
+
+ outline = ti->ttface->glyph->outline;
+
+ FT_Outline_Get_CBox(&outline, &bbox);
+
+ fprintf(out, "/%s {\n", psglyphname);
+ fprintf(out, "%ld 0 %ld %ld %ld %ld setcachedevice\n",
+ (signed long)ti->ttface->glyph->metrics.horiAdvance,
+ (long)bbox.xMin,
+ (long)bbox.yMin,
+ (long)bbox.xMax,
+ (long)bbox.yMax);
+
+ if( outline.n_contours > 0 )
+ {
+ long i,
+ j,
+ k, k1,
+ cs, ce,
+ nguide,
+ contour_start,
+ contour_end,
+ last_point;
+ Bool first;
+ FT_Vector *vec;
+
+ contour_start = ce = 0;
+
+ vec = outline.points;
+ last_point = outline.n_points;
+
+ i = j = k = 0;
+ first = TRUE;
+
+ while( i <= outline.contours[outline.n_contours - 1] )
+ {
+ contour_end = outline.contours[j];
+
+ if( first )
+ {
+ fprintf(out, "%ld %ld moveto\n", vec[i].x, vec[i].y);
+ contour_start = i;
+ first = FALSE;
+ }
+ else if( outline.tags[i] & FT_CURVE_TAG_ON )
+ {
+ fprintf(out, "%ld %ld lineto\n", vec[i].x, vec[i].y);
+ }
+ else
+ {
+ Bool finished = FALSE;
+
+ cs = i-1;
+ nguide = 0;
+ while( !finished )
+ {
+ if( i == contour_end+1 )
+ {
+ ce = contour_start;
+ finished = TRUE;
+ }
+ else if( outline.tags[i] & FT_CURVE_TAG_ON )
+ {
+ ce = i;
+ finished = TRUE;
+ }
+ else
+ {
+ i++;
+ nguide++;
+ }
+ }
+
+ switch( nguide )
+ {
+ case 0:
+ fprintf(out, "%ld %ld lineto\n", vec[ce].x, vec[ce].y);
+ break;
+
+ case 1:
+ fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n",
+ (vec[cs].x+2*vec[cs+1].x)/3,
+ (vec[cs].y+2*vec[cs+1].y)/3,
+ (2*vec[cs+1].x+vec[ce].x)/3,
+ (2*vec[cs+1].y+vec[ce].y)/3,
+ vec[ce].x, vec[ce].y);
+ break;
+
+ case 2:
+ fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n",
+ (-vec[cs].x+4*vec[cs+1].x)/3,
+ (-vec[cs].y+4*vec[cs+1].y)/3,
+ (4*vec[cs+2].x-vec[ce].x)/3,
+ (4*vec[cs+2].y-vec[ce].y)/3,
+ vec[ce].x, vec[ce].y);
+ break;
+
+ case 3:
+ fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n",
+ (vec[cs].x+2*vec[cs+1].x)/3,
+ (vec[cs].y+2*vec[cs+1].y)/3,
+ (5*vec[cs+1].x+vec[cs+2].x)/6,
+ (5*vec[cs+1].y+vec[cs+2].y)/6,
+ (vec[cs+1].x+vec[cs+2].x)/2,
+ (vec[cs+1].y+vec[cs+2].y)/2);
+
+ fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n",
+ (vec[cs+1].x+5*vec[cs+2].x)/6,
+ (vec[cs+1].y+5*vec[cs+2].y)/6,
+ (5*vec[cs+2].x+vec[cs+3].x)/6,
+ (5*vec[cs+2].y+vec[cs+3].y)/6,
+ (vec[cs+3].x+vec[cs+2].x)/2,
+ (vec[cs+3].y+vec[cs+2].y)/2);
+
+ fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n",
+ (vec[cs+2].x+5*vec[cs+3].x)/6,
+ (vec[cs+2].y+5*vec[cs+3].y)/6,
+ (2*vec[cs+3].x+vec[ce].x)/3,
+ (2*vec[cs+3].y+vec[ce].y)/3,
+ vec[ce].x, vec[ce].y);
+ break;
+
+ default: /* anything |nguide > 3| */
+ k1 = cs + nguide;
+
+ fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n",
+ (vec[cs].x+2*vec[cs+1].x)/3,
+ (vec[cs].y+2*vec[cs+1].y)/3,
+ (5*vec[cs+1].x+vec[cs+2].x)/6,
+ (5*vec[cs+1].y+vec[cs+2].y)/6,
+ (vec[cs+1].x+vec[cs+2].x)/2,
+ (vec[cs+1].y+vec[cs+2].y)/2);
+
+ for( k = cs+2 ; k <= k1-1 ; k++ )
+ {
+ fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n",
+ (vec[k-1].x+5*vec[k].x)/6,
+ (vec[k-1].y+5*vec[k].y)/6,
+ (5*vec[k].x+vec[k+1].x)/6,
+ (5*vec[k].y+vec[k+1].y)/6,
+ (vec[k].x+vec[k+1].x)/2,
+ (vec[k].y+vec[k+1].y)/2);
+ }
+
+ fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n",
+ (vec[k1-1].x+5*vec[k1].x)/6,
+ (vec[k1-1].y+5*vec[k1].y)/6,
+ (2*vec[k1].x+vec[ce].x)/3,
+ (2*vec[k1].y+vec[ce].y)/3,
+ vec[ce].x, vec[ce].y);
+ break;
+ }
+ }
+
+ if( i >= contour_end )
+ {
+ fprintf(out, "closepath\n");
+ first = TRUE;
+ i = contour_end + 1;
+ j++;
+ }
+ else
+ {
+ i++;
+ }
+ }
+ }
+
+ fprintf(out, "fill } bind def\n");
+
+ return 0;
+}
+
+#ifdef USE_FT_INTERNALS
+static FT_BBox *
+FT_Get_PS_Font_BBox( FT_Face face )
+{
+ const char *driver_name;
+ FT_BBox *font_bbox = NULL;
+
+ if ( face && face->driver && face->driver->root.clazz )
+ {
+ driver_name = face->driver->root.clazz->module_name;
+ if ( ft_strcmp( driver_name, "type1" ) == 0 )
+ font_bbox = &(((T1_Face)face)->type1.font_bbox);
+ else if ( ft_strcmp( driver_name, "t1cid" ) == 0 )
+ font_bbox = &(((CID_Face)face)->cid.font_bbox);
+ else if ( ft_strcmp( driver_name, "type42" ) == 0 )
+ font_bbox = &(((T42_Face)face)->type1.font_bbox);
+ }
+
+ return font_bbox;
+}
+#endif /* USE_FT_INTERNALS */
+
+static
+int PSType3_generateOutlineFont(FILE *out, const char *psfontname, struct ft2info *ti, long block_offset)
+{
+ long i;
+ double scaler;
+ const int numchars = 256;
+#ifdef USE_FT_PS_NAMES
+ int linewidth = 0;
+#endif /* USE_FT_PS_NAMES */
+
+ fprintf(out, "%%%%BeginFont: %s\n", psfontname);
+ fprintf(out, "22 dict begin\n");
+ fprintf(out, "/FontType 3 def\n");
+ fprintf(out, "/StrokeWidth 0 def\n");
+ fprintf(out, "/PaintType 0 def\n");
+ fprintf(out, "/FontName (%s) def\n", psfontname);
+ fprintf(out, "/FontInfo 9 dict dup begin\n");
+ fprintf(out, " /FullName (%s) def\n", ti->nameid.full_name?ti->nameid.full_name:psfontname);
+ fprintf(out, " /Notice (%s) def\n", ti->nameid.copyright?ti->nameid.copyright:"nothing here");
+ fprintf(out, " /FamilyName (%s) def\n", ti->nameid.family?ti->nameid.family:psfontname);
+ fprintf(out, " /Weight (%s) def\n", ti->nameid.subfamily?ti->nameid.subfamily:"Regular");
+ fprintf(out, " /version (%s) def\n", ti->nameid.version?ti->nameid.version:"0.1");
+
+ if( ti->ttpostscript )
+ {
+ fprintf(out, " /italicAngle %.9g def\n", (double)ti->ttpostscript->italicAngle);
+ fprintf(out, " /underlineThickness %d def\n", (int)ti->ttpostscript->underlineThickness);
+ fprintf(out, " /underlinePosition %d def\n", (int)ti->ttpostscript->underlinePosition);
+ fprintf(out, " /isFixedPitch %s def\n", ((ti->ttpostscript->isFixedPitch)?("true"):("false")));
+ }
+ else
+ {
+ fprintf(out, " /italicAngle %.9g def\n", 0.0);
+ fprintf(out, " /underlineThickness %d def\n", 100);
+ fprintf(out, " /underlinePosition %d def\n", 0);
+ fprintf(out, " /isFixedPitch false def\n");
+ }
+
+ fprintf(out, "end def\n");
+
+ scaler = (1000.0 / (double)ti->ttface->units_per_EM) / 1000.0;
+ fprintf(out, "/FontMatrix [%.9g 0 0 %.9g 0 0] def\n", scaler, scaler);
+
+ if( ti->ttheader )
+ {
+ fprintf(out, "/FontBBox [%d %d %d %d] def\n",
+ (int)ti->ttheader->xMin,
+ (int)ti->ttheader->yMin,
+ (int)ti->ttheader->xMax,
+ (int)ti->ttheader->yMax);
+ }
+ else
+ {
+ FT_BBox *font_bbox = FT_Get_PS_Font_BBox(ti->ttface);
+ fprintf(out, "/FontBBox [%d %d %d %d] def\n",
+ (int)font_bbox->xMin,
+ (int)font_bbox->yMin,
+ (int)font_bbox->xMax,
+ (int)font_bbox->yMax);
+ }
+
+ fprintf(out, "/Encoding [\n");
+ for( i = 0 ; i < 256 ; i++ )
+ {
+#ifdef USE_FT_PS_NAMES
+ char namebuf[256];
+ PsOut_Get_FreeType_Glyph_Name(namebuf, ti->pFont, i+block_offset);
+ linewidth += strlen(namebuf) + 2;
+ fprintf(out, "/%s%s", namebuf, (linewidth > 70)?(linewidth = 0, "\n"):(" "));
+#else
+ fprintf(out, "/ch%02x%s", i, (((i % 10) == 9)?("\n"):(" ")));
+#endif /* USE_FT_PS_NAMES */
+ }
+ fprintf(out, "] def\n");
+
+ fprintf(out, "/CharProcs %d dict def CharProcs begin\n", (int)(numchars + 1));
+ fprintf(out, "/.notdef {\n"
+ "1000 0 0 0 0 0 setcachedevice\n"
+ "fill } bind def\n");
+ for( i = 0 ; i < numchars ; i++ )
+ {
+ char buf[32];
+#ifdef USE_FT_PS_NAMES
+ char namebuf[256];
+ PsOut_Get_FreeType_Glyph_Name(namebuf, ti->pFont, i+block_offset);
+ sprintf(buf, "%s ", namebuf);
+#else
+ sprintf(buf, "ch%02lx ", i);
+#endif /* USE_FT_PS_NAMES */
+ PSType3_createOutlineGlyphs(out, ti, i+block_offset, buf);
+ }
+ fprintf(out, "end\n"
+ "/BuildGlyph {\n"
+ " exch /CharProcs get exch\n"
+ " 2 copy known not {pop /.notdef} if get exec } bind def\n"
+ "/BuildChar { 1 index /Encoding get exch get\n"
+ " 1 index /Encoding get exec } bind def\n");
+ fprintf(out, "currentdict end /%s exch definefont pop\n", psfontname);
+ fprintf(out, "%%EndFont\n");
+
+ return 0;
+}
+
+static
+char *FT_Get_TT_NAME_ID(FT_Face ttface, int index)
+{
+ FT_SfntName name;
+ char *s;
+
+ if( index >= FT_Get_Sfnt_Name_Count(ttface) )
+ return NULL;
+
+ FT_Get_Sfnt_Name(ttface, index, &name);
+ s = (char *)malloc(name.string_len+2);
+ if( !s )
+ return NULL;
+ memcpy(s, (char *)name.string, name.string_len);
+ s[name.string_len] = '\0';
+ return s;
+}
+
+int PsOut_DownloadFreeType3(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset)
+{
+ struct ft2info cft2info = { 0 };
+ struct ft2info *ti = &cft2info;
+
+ S_Flush(self);
+
+ ti->tf = (FTFontPtr)pFont->fontPrivate;
+ ti->ttface = ti->tf->instance->face->face;
+ ti->pFont = pFont;
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "# Downloading FT2 font filename='%s', ttface=%lx\n", ti->tf->instance->face->filename, (long)ti->ttface);
+#endif /* DEBUG_gisburn */
+
+ ti->nameid.full_name = FT_Get_TT_NAME_ID(ti->ttface, TT_NAME_ID_FULL_NAME);
+ ti->nameid.copyright = FT_Get_TT_NAME_ID(ti->ttface, TT_NAME_ID_COPYRIGHT);
+ ti->nameid.family = FT_Get_TT_NAME_ID(ti->ttface, TT_NAME_ID_FONT_FAMILY);
+ ti->nameid.subfamily = FT_Get_TT_NAME_ID(ti->ttface, TT_NAME_ID_FONT_SUBFAMILY);
+ ti->nameid.version = FT_Get_TT_NAME_ID(ti->ttface, TT_NAME_ID_VERSION_STRING);
+
+ ti->ttheader = (TT_Header *)FT_Get_Sfnt_Table(ti->ttface, ft_sfnt_head);
+ ti->ttpostscript = (TT_Postscript *)FT_Get_Sfnt_Table(ti->ttface, ft_sfnt_post);
+
+ PSType3_generateOutlineFont(self->Fp, psfontname, ti, block_offset);
+
+ free(ti->nameid.full_name);
+ free(ti->nameid.copyright);
+ free(ti->nameid.family);
+ free(ti->nameid.subfamily);
+ free(ti->nameid.version);
+
+ S_Flush(self);
+
+ return 0;
+}
+
diff --git a/nx-X11/programs/Xserver/Xprint/ps/ttf2pt1wrap.c b/nx-X11/programs/Xserver/Xprint/ps/ttf2pt1wrap.c
new file mode 100644
index 000000000..57bb777d2
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/ps/ttf2pt1wrap.c
@@ -0,0 +1,14 @@
+/*
+ * Wrapper to add missing symbol to externally supplied code
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef Lynx
+extern int optind;
+extern char *optarg;
+#endif
+
+#include "ttf2pt1.c"
diff --git a/nx-X11/programs/Xserver/Xprint/raster/Imakefile b/nx-X11/programs/Xserver/Xprint/raster/Imakefile
new file mode 100644
index 000000000..e2112c00b
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/raster/Imakefile
@@ -0,0 +1,28 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:11 cpqbld Exp $
+
+#include <Server.tmpl>
+
+SRCS1 = Raster.c RasterAttVal.c
+OBJS1 = Raster.o RasterAttVal.o
+
+SRCS = $(SRCS1)
+
+OBJS = $(OBJS1)
+
+ INCLUDES = -I. -I$(XINCLUDESRC) -I.. -I$(LIBSRC) \
+ -I../../cfb -I../../mfb -I../../mi \
+ -I../../include -I$(TOP)/include -I$(FONTINCSRC)
+
+
+ LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln \
+ ../../mfb/llib-lmfb.ln ../../mi/llib-lmi.ln \
+ ../../cfb/llib-lcfb.ln
+
+ DEFINES = -D_XP_PRINT_SERVER_ -UXFree86LOADER
+
+NormalLibraryObjectRule()
+
+NormalLibraryTarget(raster,$(OBJS))
+NormalLintTarget($(SRCS1) $(SRCS2))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/Xprint/raster/Raster.c b/nx-X11/programs/Xserver/Xprint/raster/Raster.c
new file mode 100644
index 000000000..781327b33
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/raster/Raster.c
@@ -0,0 +1,1580 @@
+/* $Xorg: Raster.c,v 1.4 2001/03/14 18:46:12 pookie Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+/* $XFree86: xc/programs/Xserver/Xprint/raster/Raster.c,v 1.11tsi Exp $ */
+
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: printer/Raster.c
+** *
+** * Contents:
+** * Raster driver for the print server.
+** *
+** * Copyright: Copyright 1993, 1995 Hewlett-Packard Company
+** *
+** *********************************************************
+**
+********************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <X11/X.h>
+#include <X11/Xos.h> /* for SIGCLD on pre-POSIX systems */
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#undef NEED_EVENTS
+#include <X11/Xatom.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "scrnintstr.h"
+#include "screenint.h"
+#include "colormapst.h"
+#include "windowstr.h"
+#include "propertyst.h"
+#include "servermd.h" /* needed for IMAGE_BUFSIZE */
+#include "mfb.h"
+#include "mi.h"
+
+#include <X11/extensions/Print.h>
+#include "Raster.h"
+
+#include "attributes.h"
+#include "AttrValid.h"
+#include "DiPrint.h"
+
+static void AllocateRasterPrivates(
+ ScreenPtr pScreen);
+static Bool RasterChangeWindowAttributes(
+ WindowPtr pWin,
+ unsigned long mask);
+static int StartJob(
+ XpContextPtr pCon,
+ Bool sendClientData,
+ ClientPtr client);
+static int StartPage(
+ XpContextPtr pCon,
+ WindowPtr pWin);
+static int StartDoc(
+ XpContextPtr pCon,
+ XPDocumentType type);
+static int EndDoc(
+ XpContextPtr pCon,
+ Bool cancel);
+static int EndJob(
+ XpContextPtr pCon,
+ Bool cancel);
+static int EndPage(
+ XpContextPtr pCon,
+ WindowPtr pWin);
+static int DocumentData(
+ XpContextPtr pCon,
+ DrawablePtr pDraw,
+ char *pData,
+ int len_data,
+ char *pDoc_fmt,
+ int len_fmt,
+ char *pOptions,
+ int len_options,
+ ClientPtr client);
+static int GetDocumentData(
+ XpContextPtr pContext,
+ ClientPtr client,
+ int maxBufferSize);
+static void FreePageFiles(
+ RasterContextPrivPtr pWinPriv);
+static int SystemCmd(
+ char *pCommand);
+static Bool RasterCloseScreen(
+ int index,
+ ScreenPtr pScreen);
+static int RasterInitContext(XpContextPtr pCon);
+static Bool RasterDestroyContext(XpContextPtr pCon);
+static char *RasterGetAttributes(
+ XpContextPtr pContext,
+ XPAttributes class);
+static char *RasterGetOneAttribute(XpContextPtr pCon,
+ XPAttributes class,
+ char *attribute);
+static int RasterSetAttributes(XpContextPtr pCon,
+ XPAttributes class,
+ char *attributes);
+static int RasterAugmentAttributes(XpContextPtr pCon,
+ XPAttributes class,
+ char *attributes);
+static int RasterMediumDimensions(XpContextPtr pCon,
+ CARD16 *width,
+ CARD16 *height);
+static int RasterReproducibleArea(XpContextPtr pCon,
+ xRectangle *pRect);
+
+#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+#define DOC_PCL 1
+#define DOC_RASTER 2
+
+static int RasterScreenPrivateIndex, RasterContextPrivateIndex;
+static int RasterGeneration = 0;
+static char RASTER_DRIV_NAME[] = "XP-RASTER";
+static int doc_type = DOC_RASTER;
+
+#define ABSOLUTE_PCLCOMP_PATH1 "/usr/openwin/bin/pclcomp"
+#define ABSOLUTE_PCLCOMP_PATH2 "/usr/X11/bin/pclcomp"
+
+static char *pcl3_output_cmds[] = {
+ "xpr -device ljet -rv -landscape < %(InFile)% | pclcomp -0 > %(OutFile)%",
+ "xpr -device ljet -rv -landscape < %(InFile)% | pclcomp -01 > %(OutFile)%",
+ "xpr -device ljet -rv -landscape < %(InFile)% | pclcomp -02 > %(OutFile)%",
+ "xpr -device ljet -rv -landscape < %(InFile)% | pclcomp -03 > %(OutFile)%",
+ "xpr -device ljet -rv -landscape < %(InFile)% | pclcomp -012 > %(OutFile)%",
+ "xpr -device ljet -rv -landscape < %(InFile)% | pclcomp -013 > %(OutFile)%",
+ "xpr -device ljet -rv -landscape < %(InFile)% | pclcomp -023 > %(OutFile)%",
+ "xpr -device ljet -rv -landscape < %(InFile)% | pclcomp -0123 > %(OutFile)%",
+ "xpr -device ljet -rv -landscape < %(InFile)% > %(OutFile)%",
+ "xpr -device ljet -rv < %(InFile)% | pclcomp -0 > %(OutFile)%",
+ "xpr -device ljet -rv < %(InFile)% | pclcomp -01 > %(OutFile)%",
+ "xpr -device ljet -rv < %(InFile)% | pclcomp -02 > %(OutFile)%",
+ "xpr -device ljet -rv < %(InFile)% | pclcomp -03 > %(OutFile)%",
+ "xpr -device ljet -rv < %(InFile)% | pclcomp -012 > %(OutFile)%",
+ "xpr -device ljet -rv < %(InFile)% | pclcomp -013 > %(OutFile)%",
+ "xpr -device ljet -rv < %(InFile)% | pclcomp -023 > %(OutFile)%",
+ "xpr -device ljet -rv < %(InFile)% | pclcomp -0123 > %(OutFile)%",
+ "xpr -device ljet -rv < %(InFile)% > %(OutFile)%"};
+
+Bool
+InitializeRasterDriver(
+ int ndx,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv)
+{
+ int xRes, yRes;
+ int maxRes, maxDim, numBytes;
+ RasterScreenPrivPtr pPriv;
+
+ /*
+ * Register this driver's InitContext function with the print extension.
+ * This is a bit
+ * sleazy, as the extension hasn't yet been initialized, but the
+ * extension needs to know this, and this seems the best time to
+ * provide the information.
+ */
+ XpRegisterInitFunc( pScreen, RASTER_DRIV_NAME, RasterInitContext );
+
+ /*
+ * Create and load the devPrivate for the printer layer.
+ */
+ AllocateRasterPrivates(pScreen);
+
+ pPriv = (RasterScreenPrivPtr)
+ pScreen->devPrivates[RasterScreenPrivateIndex].ptr;
+
+ maxDim = MAX( pScreen->height, pScreen->width );
+ numBytes = maxDim + BITMAP_SCANLINE_PAD - 1; /* pixels per row */
+ numBytes *= maxDim;
+ numBytes /= 8; /* bytes per row */
+ xRes = pScreen->width / (pScreen->mmWidth / 25.4);
+ yRes = pScreen->height / (pScreen->mmHeight / 25.4);
+ maxRes = MAX( xRes, yRes );
+
+ pPriv->pBits = (char *)xalloc(numBytes);
+
+ /*
+ * Have to allocate maxDim X maxDim to allow for landscape mode.
+ */
+ mfbScreenInit(pScreen, pPriv->pBits, maxDim, maxDim, maxRes,
+ maxRes, maxDim);
+ miInitializeBackingStore(pScreen);
+ pScreen->blackPixel = 1;
+ pScreen->whitePixel = 0;
+ if(mfbCreateDefColormap(pScreen) == FALSE)
+ ; /* XXX what do I do if it fails? */
+
+ /*
+ cfbScreenInit(pScreen, pPriv->pBits, maxWidth, maxHeight, maxXres,
+ maxYres, maxWidth);
+ miInitializeBackingStore(pScreen);
+ scalingScreenInit(pScreen);
+ */
+
+ pScreen->SaveScreen = (SaveScreenProcPtr)_XpBoolNoop;
+ pPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
+ pScreen->ChangeWindowAttributes = RasterChangeWindowAttributes;
+ pPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = RasterCloseScreen;
+
+ return TRUE;
+}
+
+/*
+ * GetPropString searches the context's config database for a property
+ * by the name of propName. If found, it returns the property's
+ * value, otherwise it returns NULL unless the requested attribute
+ * is RASTER_PRINT_PAGE_COMMAND, in which case it returns a hard-coded
+ * default string to invoke xpr to produce a PostScript(tm) formatted
+ * raster.
+ */
+
+static char *
+GetPropString(
+ XpContextPtr pCon,
+ char *propName)
+{
+ RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
+ pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ char *type;
+ XrmValue val;
+ struct stat status;
+ int pclcomp_exists = 0;
+
+ if( XrmGetResource(pConPriv->config, propName, propName, &type, &val) ==
+ True )
+ return (char *)val.addr;
+
+ if( !strcmp( propName, RASTER_PRINT_PAGE_COMMAND ) )
+ if( doc_type == DOC_RASTER )
+ return "xpr -device ps %(InFile)% > %(OutFile)%";
+ else
+ {
+ XpOid orientation;
+ XpOid compression;
+ int pcl3_output_index = 0;
+
+ orientation = XpGetContentOrientation(pCon);
+ compression = XpGetAvailableCompression(pCon);
+
+ switch(orientation) {
+ case xpoid_val_content_orientation_landscape:
+ pcl3_output_index = 0;
+ break;
+ default:
+ pcl3_output_index += 9;
+ break;
+ }
+
+ if(stat(ABSOLUTE_PCLCOMP_PATH1, &status) != -1)
+ pclcomp_exists = 1;
+ else if(stat(ABSOLUTE_PCLCOMP_PATH2, &status) != -1)
+ pclcomp_exists = 1;
+
+ if(pclcomp_exists)
+ switch(compression) {
+ case xpoid_val_available_compressions_0:
+ pcl3_output_index += 0;
+ break;
+ case xpoid_val_available_compressions_01:
+ pcl3_output_index += 1;
+ break;
+ case xpoid_val_available_compressions_02:
+ pcl3_output_index += 2;
+ break;
+ case xpoid_val_available_compressions_03:
+ pcl3_output_index += 3;
+ break;
+ case xpoid_val_available_compressions_012:
+ pcl3_output_index += 4;
+ break;
+ case xpoid_val_available_compressions_013:
+ pcl3_output_index += 5;
+ break;
+ case xpoid_val_available_compressions_023:
+ pcl3_output_index += 6;
+ break;
+ default:
+ pcl3_output_index += 7;
+ break;
+ }
+ else
+ pcl3_output_index += 8;
+
+ return pcl3_output_cmds[pcl3_output_index];
+ }
+ else
+ return NULL;
+}
+
+static void
+SetDocumentType(
+ XpContextPtr pCon)
+{
+ XpOidList* attrs_supported;
+
+ /*
+ * only validate attributes found in document-attributes-supported
+ */
+ attrs_supported =
+ XpGetListAttr(pCon, XPPrinterAttr,
+ xpoid_att_document_attributes_supported,
+ (const XpOidList*)NULL);
+
+ if(XpOidListHasOid(attrs_supported, xpoid_att_document_format))
+ {
+ const char* value_in;
+ XpOidDocFmt *f;
+
+ value_in = XpGetStringAttr(pCon, XPDocAttr, xpoid_att_document_format);
+
+ f = XpOidDocFmtNew( value_in );
+
+ if( f != NULL )
+ {
+ if( !strcmp( f->format, "PCL" ) )
+ doc_type = DOC_PCL;
+ else
+ doc_type = DOC_RASTER;
+
+ XpOidDocFmtDelete( f );
+ }
+ }
+
+ /*
+ * clean up
+ */
+ XpOidListDelete(attrs_supported);
+}
+
+static int
+StartJob(
+ XpContextPtr pCon,
+ Bool sendClientData,
+ ClientPtr client)
+{
+ RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
+ pCon->devPrivates[RasterContextPrivateIndex].ptr;
+
+ SetDocumentType( pCon );
+
+ /*
+ * Check for existing page file, and delete it if it exists.
+ */
+ if(pConPriv->pageFileName != (char *)NULL)
+ {
+ if(pConPriv->pPageFile != (FILE *)NULL)
+ {
+ fclose(pConPriv->pPageFile);
+ pConPriv->pPageFile = (FILE *)NULL;
+ }
+ unlink(pConPriv->pageFileName);
+ Xfree(pConPriv->pageFileName);
+ pConPriv->pageFileName = (char *)NULL;
+ }
+
+ /*
+ * Create a temporary file to store the printer output.
+ */
+ if(!sendClientData)
+ {
+ /*
+ * Create a temporary file to store the printer output.
+ */
+ if (!XpOpenTmpFile("w", &pConPriv->jobFileName, &pConPriv->pJobFile))
+ return BadAlloc;
+ }
+
+ return Success;
+}
+
+/*
+ * StartDoc and EndDoc are just no-ops in this implementation, since
+ * our view of the spooler really doesn't recognize documents.
+ */
+
+static int
+StartDoc(
+ XpContextPtr pCon,
+ XPDocumentType type)
+{
+ return Success;
+}
+
+static int EndDoc(
+ XpContextPtr pCon,
+ Bool cancel)
+{
+ return Success;
+}
+
+#if 0
+
+/* XXX Not used. */
+
+/*
+ * BuidArgVector takes a pointer to a comma-separated list of command
+ * options and splits it out into an array of argument pointers. The
+ * caller must not free the optionList after calling this function until
+ * the returned arg vector is no longer needed, at which time the arg
+ * vector should also be freed.
+ */
+
+#define SEPARATOR_CHAR (char)','
+
+static char **
+BuildArgVector(
+ char *optionList,
+ char **argVector,
+ int argCount)
+{
+ char *curArg, *lastChar, *endArg;
+
+ curArg = optionList;
+ lastChar = optionList + strlen(optionList); /* includes final NULL */
+
+ while(curArg != (char *)NULL && curArg < lastChar)
+ {
+ /* strip leading white space */
+ while(curArg < lastChar && isascii((int)*curArg) &&
+ isspace((int)*curArg))
+ curArg++;
+
+ if(curArg < lastChar)
+ {
+ argVector = (char **)Xrealloc(argVector,
+ sizeof(char *) * (argCount + 2));
+ argVector[argCount] = curArg;
+ argVector[++argCount] = (char *)NULL;
+
+ endArg = strchr(curArg, SEPARATOR_CHAR);
+
+ /* Should I strip trailing white space ??? */
+
+ if(endArg != (char *)NULL)
+ {
+ *endArg = (char)'\0';
+ curArg = endArg + 1;
+ }
+ else
+ curArg = (char *)NULL;
+ }
+ }
+
+ return argVector;
+}
+#endif
+
+static int
+EndJob(
+ XpContextPtr pCon,
+ Bool cancel)
+{
+ RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
+ pCon->devPrivates[RasterContextPrivateIndex].ptr;
+
+ if( cancel == True )
+ {
+ if(pConPriv->getDocClient != (ClientPtr)NULL) {
+ XpFinishDocData(pConPriv->getDocClient);
+
+ pConPriv->getDocClient = (ClientPtr)NULL;
+ pConPriv->getDocBufSize = 0;
+ }
+
+ if(pConPriv->jobFileName != (char *)NULL)
+ {
+ unlink(pConPriv->jobFileName);
+ Xfree(pConPriv->jobFileName);
+ pConPriv->jobFileName = (char *)NULL;
+ }
+
+ return Success;
+ }
+
+ if(pConPriv->getDocClient != (ClientPtr)NULL&&pConPriv->getDocBufSize > 0)
+ {
+ XpFinishDocData(pConPriv->getDocClient);
+
+ pConPriv->getDocClient = (ClientPtr)NULL;
+ pConPriv->getDocBufSize = 0;
+
+ return Success;
+ }
+
+ if(pConPriv->pJobFile != (FILE *)NULL)
+ {
+ fclose(pConPriv->pJobFile);
+ pConPriv->pJobFile = (FILE *)NULL;
+
+ if(pConPriv->jobFileName != (char *)NULL)
+ {
+ XpSubmitJob( pConPriv->jobFileName, pCon );
+ unlink(pConPriv->jobFileName);
+ Xfree(pConPriv->jobFileName);
+ pConPriv->jobFileName = (char *)NULL;
+ }
+ }
+
+ return Success;
+}
+
+/* StartPage
+ *
+ * If page file exists
+ * close page file
+ * set page file pointer = NULL
+ * unlink page file
+ */
+static int
+StartPage(
+ XpContextPtr pCon,
+ WindowPtr pWin)
+{
+ RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
+ pCon->devPrivates[RasterContextPrivateIndex].ptr;
+
+ if(pConPriv->pPageFile != (FILE *)NULL)
+ {
+ fclose(pConPriv->pPageFile);
+ pConPriv->pPageFile = (FILE *)NULL;
+ }
+ if(pConPriv->pageFileName != (char *)NULL)
+ {
+ unlink(pConPriv->pageFileName);
+ pConPriv->pageFileName = (char *)NULL;
+ }
+
+ return Success;
+}
+
+#include "X11/XWDFile.h"
+
+
+#define lowbit(x) ((x) & (~(x) + 1))
+
+/*
+ * Get the XWDColors of all pixels in colormap - returns # of colors
+ */
+static XWDColor *
+Get_XWDColors(
+ ColormapPtr pCmap)
+{
+ int i, ncolors;
+ xrgb *prgbList;
+ Pixel *pPixels;
+ XWDColor *colors;
+
+ ncolors = pCmap->pVisual->ColormapEntries;
+ if (!(colors = (XWDColor *) malloc (sizeof(XWDColor) * ncolors)))
+ return (XWDColor *) NULL;
+ if (!(prgbList = (xrgb*) malloc(sizeof(xrgb) * ncolors)))
+ {
+ Xfree(colors);
+ return (XWDColor *) NULL;
+ }
+ if (!(pPixels = (Pixel*) malloc(sizeof(Pixel) * ncolors)))
+ {
+ Xfree(colors);
+ Xfree(prgbList);
+ return (XWDColor *) NULL;
+ }
+
+ if (pCmap->pVisual->class == DirectColor ||
+ pCmap->pVisual->class == TrueColor) {
+ Pixel red, green, blue, red1, green1, blue1;
+
+ red = green = blue = 0;
+ red1 = lowbit(pCmap->pVisual->redMask);
+ green1 = lowbit(pCmap->pVisual->greenMask);
+ blue1 = lowbit(pCmap->pVisual->blueMask);
+ for (i=0; i<ncolors; i++) {
+ colors[i].pixel = red|green|blue;
+ colors[i].pad = 0;
+ red += red1;
+ if (red > pCmap->pVisual->redMask)
+ red = 0;
+ green += green1;
+ if (green > pCmap->pVisual->greenMask)
+ green = 0;
+ blue += blue1;
+ if (blue > pCmap->pVisual->blueMask)
+ blue = 0;
+ }
+ } else {
+ for (i=0; i<ncolors; i++) {
+ colors[i].pixel = i;
+ colors[i].pad = 0;
+ }
+ }
+
+ for(i = 0; i < ncolors; i++)
+ pPixels[i] = colors[i].pixel;
+
+ QueryColors(pCmap, ncolors, pPixels, prgbList);
+ Xfree(pPixels);
+
+ for(i = 0; i < ncolors; i++)
+ {
+ colors[i].red = prgbList[i].red;
+ colors[i].green = prgbList[i].green;
+ colors[i].blue = prgbList[i].blue;
+ }
+ Xfree(prgbList);
+
+ return(colors);
+}
+
+static void
+_swapshort (
+ register char *bp,
+ register unsigned n)
+{
+ register char c;
+ register char *ep = bp + n;
+
+ while (bp < ep) {
+ c = *bp;
+ *bp = *(bp + 1);
+ bp++;
+ *bp++ = c;
+ }
+}
+
+static void
+_swaplong (
+ register char *bp,
+ register unsigned n)
+{
+ register char c;
+ register char *ep = bp + n;
+ register char *sp;
+
+ while (bp < ep) {
+ sp = bp + 3;
+ c = *sp;
+ *sp = *bp;
+ *bp++ = c;
+ sp = bp + 1;
+ c = *sp;
+ *sp = *bp;
+ *bp++ = c;
+ bp += 2;
+ }
+}
+static int
+WriteWindowRaster(
+ WindowPtr pWin,
+ FILE *pRasterFile)
+{
+ long widthBytesLine, length;
+ int nlines, linesPerBuf, height, linesDone;
+ char *pBuf;
+ DrawablePtr pDraw = &pWin->drawable;
+ XWDFileHeader header;
+ int win_name_size;
+ int header_size;
+ int ncolors, i;
+ char *win_name;
+ VisualPtr pVisual;
+ ColormapPtr pCmap;
+ XWDColor *pColors;
+ unsigned long swaptest = 1;
+
+ widthBytesLine = PixmapBytePad(pWin->drawable.width, pWin->drawable.depth);
+ length = widthBytesLine * pWin->drawable.height;
+ height = pWin->drawable.height;
+
+ if(length <= 0)
+ return Success;
+
+ if (widthBytesLine >= IMAGE_BUFSIZE)
+ linesPerBuf = 1;
+ else
+ {
+ linesPerBuf = IMAGE_BUFSIZE / widthBytesLine;
+ if (linesPerBuf > height)
+ linesPerBuf = height;
+ }
+ length = linesPerBuf * widthBytesLine;
+ if (linesPerBuf < height)
+ {
+ /* we have to make sure intermediate buffers don't need padding */
+ while ((linesPerBuf > 1) && (length & 3))
+ {
+ linesPerBuf--;
+ length -= widthBytesLine;
+ }
+ while (length & 3)
+ {
+ linesPerBuf++;
+ length += widthBytesLine;
+ }
+ }
+ if(!(pBuf = (char *) Xalloc(length)))
+ return (BadAlloc);
+
+ /*
+ * Start of Xwd header code.
+ */
+
+ /*
+ * XXX - Should we use the real window name???
+ */
+ win_name = "xwdump";
+ /* sizeof(char) is included for the null string terminator. */
+ win_name_size = strlen(win_name) + sizeof(char);
+
+ pCmap = (ColormapPtr)LookupIDByType(wColormap (pWin), RT_COLORMAP);
+ pVisual = pCmap->pVisual;
+ if((pColors = Get_XWDColors(pCmap)) == (XWDColor *)NULL)
+ {
+ Xfree(pBuf);
+ return (BadAlloc);
+ }
+
+ /*
+ * Write out header information.
+ */
+ header_size = sizeof(header) + win_name_size;
+ header.header_size = (CARD32) header_size;
+ header.file_version = (CARD32) XWD_FILE_VERSION;
+ header.pixmap_format = (CARD32) ZPixmap; /* Must match GetImage below */
+ header.pixmap_depth = (CARD32) pDraw->depth;
+ header.pixmap_width = (CARD32) pDraw->width;
+ header.pixmap_height = (CARD32) pDraw->height;
+ header.xoffset = (CARD32) 0;
+ header.byte_order = (CARD32) screenInfo.imageByteOrder;
+ header.bitmap_unit = (CARD32) screenInfo.bitmapScanlineUnit;
+ header.bitmap_bit_order = (CARD32) screenInfo.bitmapBitOrder;
+ header.bitmap_pad = (CARD32) screenInfo.bitmapScanlinePad;
+ header.bits_per_pixel = (CARD32) pDraw->bitsPerPixel;
+ header.bytes_per_line = (CARD32) widthBytesLine;
+ header.visual_class = (CARD32) pVisual->class;
+ header.red_mask = (CARD32) pVisual->redMask;
+ header.green_mask = (CARD32) pVisual->greenMask;
+ header.blue_mask = (CARD32) pVisual->blueMask;
+ header.bits_per_rgb = (CARD32) pVisual->bitsPerRGBValue;
+ header.colormap_entries = (CARD32) pVisual->ColormapEntries;
+ header.ncolors = ncolors = (CARD32) pVisual->ColormapEntries;
+ header.window_width = (CARD32) pDraw->width;
+ header.window_height = (CARD32) pDraw->height;
+ header.window_x = 0;
+ header.window_y = 0;
+ header.window_bdrwidth = (CARD32) 0;
+
+ if (*(char *) &swaptest) {
+ _swaplong((char *) &header, sizeof(header));
+ for (i = 0; i < ncolors; i++) {
+ _swaplong((char *) &pColors[i].pixel, sizeof(long));
+ _swapshort((char *) &pColors[i].red, 3 * sizeof(short));
+ }
+ }
+
+ (void) fwrite((char *)&header, sizeof(header), 1, pRasterFile);
+ (void) fwrite(win_name, win_name_size, 1, pRasterFile);
+ (void) fwrite((char *) pColors, sizeof(XWDColor), ncolors, pRasterFile);
+
+ Xfree(pColors);
+
+ /*
+ * End of Xwd header code.
+ */
+
+ linesDone = 0;
+ while(height - linesDone > 0)
+ {
+ nlines = min(linesPerBuf, height - linesDone);
+ (*pDraw->pScreen->GetImage) (pDraw,
+ 0,
+ linesDone,
+ pWin->drawable.width,
+ nlines,
+ ZPixmap,
+ ~0,
+ pBuf);
+
+ if(fwrite(pBuf, sizeof(char), (size_t)(nlines * widthBytesLine),
+ pRasterFile) !=
+ (size_t)(nlines * widthBytesLine))
+ {
+ Xfree(pBuf);
+ return BadAlloc;
+ }
+ linesDone += nlines;
+ }
+ Xfree(pBuf);
+ return Success;
+}
+
+
+static int
+SendPage( XpContextPtr pCon )
+{
+ struct stat statBuf;
+ RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
+ pCon->devPrivates[RasterContextPrivateIndex].ptr;
+
+ if(stat(pConPriv->pageFileName, &statBuf) < 0)
+ return BadAlloc;
+
+ return XpSendDocumentData(pConPriv->getDocClient,
+ pConPriv->pPageFile, (int)statBuf.st_size,
+ pConPriv->getDocBufSize);
+}
+
+/*
+ * EndPage:
+ *
+ * If page file doesn't exist:
+ * {
+ * Create page file
+ * Open page file
+ * Write page header to page file
+ * if(preRasterFile exists)
+ * copy preRasterFile contents to page file
+ * if(noRasterFile exists)
+ * write noRasterFile contents to page file
+ * else
+ * Create raster image file
+ * Open raster image file
+ * GetImage data
+ * Write Image data to raster image file
+ * invoke page_command on raster image file
+ * Write raster image file contents to page file
+ * Unlink tempPage file
+ * if(postRasterFile exists)
+ * write postRasterFile contents to page file
+ * Write page trailer to page file
+ * }
+ * Write page file to job file
+ */
+static int
+EndPage(
+ XpContextPtr pCon,
+ WindowPtr pWin)
+{
+ RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
+ pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ struct stat statBuf;
+ char *rasterFileName = (char *)NULL, *pCommand = (char *)NULL;
+ FILE *pRasterFile = (FILE *)NULL;
+
+ if(pConPriv->pageFileName == (char *)NULL)
+ {
+ /*
+ * Open the page file.
+ */
+ if (!XpOpenTmpFile("w+", &pConPriv->pageFileName,
+ &pConPriv->pPageFile))
+ goto BAD_PAGE_ALLOC;
+
+ /*
+ * Copy any pre-raster document data to the page file.
+ */
+ if(pConPriv->pPreRasterFile != (FILE *)NULL)
+ {
+ if(CopyContentsAndDelete(&pConPriv->pPreRasterFile,
+ &pConPriv->preRasterFileName,
+ pConPriv->pPageFile) == FALSE)
+ goto BAD_PAGE_ALLOC;
+ }
+
+ /*
+ * Copy either the no-raster document data, or the raster
+ * data itself to the page file.
+ * If the no-raster file exists, then we don't process the
+ * actual window raster bits.
+ */
+ if(pConPriv->pNoRasterFile != (FILE *)NULL)
+ {
+ if(CopyContentsAndDelete(&pConPriv->pNoRasterFile,
+ &pConPriv->noRasterFileName,
+ pConPriv->pPageFile) == FALSE)
+ goto BAD_PAGE_ALLOC;
+ }
+ else
+ {
+ /*
+ * Open the raster image file.
+ */
+ if (!XpOpenTmpFile("w", &rasterFileName, &pRasterFile))
+ goto BAD_PAGE_ALLOC;
+
+ /*
+ * Write the page image data to the raster image file.
+ */
+ if(WriteWindowRaster(pWin, pRasterFile) != Success)
+ goto BAD_PAGE_ALLOC;
+
+ /*
+ * Invoke the page_command on the raster image file.
+ */
+ if((pCommand = GetPropString(pCon, RASTER_PRINT_PAGE_COMMAND)) !=
+ (char *)NULL)
+ {
+ char *outFileName;
+ FILE *pOutFile;
+
+ if (!XpOpenTmpFile("w", &outFileName, &pOutFile))
+ goto BAD_PAGE_ALLOC;
+ fclose(pOutFile);
+
+ pCommand = ReplaceFileString(strdup(pCommand), rasterFileName,
+ outFileName);
+ fclose(pRasterFile);
+ SystemCmd(pCommand);
+ free(pCommand);
+ /*
+ * Delete the unprocessed raster file.
+ */
+ unlink(rasterFileName);
+ Xfree(rasterFileName);
+ rasterFileName = outFileName;
+ if((pRasterFile = fopen(rasterFileName, "r")) == (FILE *)NULL)
+ goto BAD_PAGE_ALLOC;
+ }
+ else
+ {
+ fclose(pRasterFile);
+ if((pRasterFile = fopen(rasterFileName, "r")) == (FILE *)NULL)
+ goto BAD_PAGE_ALLOC;
+ }
+
+ /*
+ * Copy the raster image file contents to the page file.
+ * Note that pRasterFile must be set to the start of the
+ * raster file.
+ */
+ if(CopyContentsAndDelete(&pRasterFile,
+ &rasterFileName,
+ pConPriv->pPageFile) == FALSE)
+ goto BAD_PAGE_ALLOC;
+ }
+
+ /*
+ * Copy any post-raster document data to the page file.
+ */
+ if(pConPriv->pPostRasterFile != (FILE *)NULL)
+ {
+ if(CopyContentsAndDelete(&pConPriv->pPostRasterFile,
+ &pConPriv->postRasterFileName,
+ pConPriv->pPageFile) == FALSE)
+ goto BAD_PAGE_ALLOC;
+ }
+
+ }
+
+ /*
+ * Write the page file contents to the job file or to the client
+ * performing GetDocumentData.
+ * pConPriv->pPageFile must first be set to the start of the page file.
+ */
+ rewind(pConPriv->pPageFile);
+ if(stat(pConPriv->pageFileName, &statBuf) < 0)
+ goto BAD_PAGE_ALLOC;
+
+ /*
+ * Send the page data to whatever client has called GetDocumentData.
+ */
+ if(pConPriv->getDocClient != (ClientPtr)NULL&&pConPriv->getDocBufSize > 0)
+ {
+ int retval;
+ /*
+ * We should do something like the following: suspend the
+ * caller until we can gracefully write all the data in small
+ * chunks to the receiver, but for now we'll just call WriteToClient
+ * on the huge chunk
+ */
+ retval = SendPage(pCon);
+ fclose(pConPriv->pPageFile);
+ pConPriv->pPageFile = (FILE *)NULL;
+ unlink(pConPriv->pageFileName);
+ free(pConPriv->pageFileName);
+ pConPriv->pageFileName = (char *)NULL;
+ return retval;
+ }
+
+ if(pConPriv->pJobFile == (FILE *)NULL)
+ {
+ /*
+ * This shouldn't be necessary. I believe we only get here if
+ * someone calls "EndPage" prior to "StartJob". This error
+ * condition should probably be trapped at a higher level.
+ */
+
+ if(pConPriv->jobFileName != (char *)NULL)
+ Xfree(pConPriv->jobFileName);
+ /*
+ * Create a temporary file to store the printer output.
+ */
+ if (!XpOpenTmpFile("w", &pConPriv->jobFileName, &pConPriv->pJobFile))
+ goto BAD_PAGE_ALLOC;
+ }
+
+ if(TransferBytes(pConPriv->pPageFile, pConPriv->pJobFile,
+ (int)statBuf.st_size) != (int)statBuf.st_size)
+ goto BAD_PAGE_ALLOC;
+
+ fclose(pConPriv->pPageFile);
+ pConPriv->pPageFile = (FILE *)NULL;
+ unlink(pConPriv->pageFileName);
+ free(pConPriv->pageFileName);
+ pConPriv->pageFileName = (char *)NULL;
+
+ return Success;
+
+ BAD_PAGE_ALLOC:
+
+ FreePageFiles(pConPriv);
+
+ if(pRasterFile != (FILE *)NULL)
+ fclose(pRasterFile);
+ if(rasterFileName != (char *)NULL)
+ {
+ unlink(rasterFileName);
+ Xfree(rasterFileName);
+ }
+ return BadAlloc;
+}
+
+static int
+DocumentData(
+ XpContextPtr pCon,
+ DrawablePtr pDraw,
+ char *pData,
+ int len_data,
+ char *pDoc_fmt,
+ int len_fmt,
+ char *pOptions,
+ int len_options,
+ ClientPtr client)
+{
+ RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
+ pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ char *preRasterStr = PRE_RASTER, *postRasterStr = POST_RASTER,
+ *noRasterStr = NO_RASTER;
+
+ /*
+ * Check that options equals either PRE_RASTER or POST_RASTER.
+ */
+ if(len_options == strlen(preRasterStr) &&
+ strncmp(pOptions, preRasterStr, strlen(preRasterStr)) == 0)
+ {
+ if(pConPriv->pPreRasterFile == (FILE *)NULL)
+ {
+ if (!XpOpenTmpFile("w+", &pConPriv->preRasterFileName,
+ &pConPriv->pPreRasterFile))
+ return BadAlloc;
+ }
+ if(fwrite(pData, sizeof(char), (size_t)len_data,
+ pConPriv->pPreRasterFile) != (size_t)len_data)
+ return BadAlloc;
+ fflush(pConPriv->pPreRasterFile);
+ }
+ else if(len_options == strlen(postRasterStr) &&
+ strncmp(pOptions, postRasterStr, strlen(postRasterStr)) == 0)
+ {
+ if(pConPriv->pPostRasterFile == (FILE *)NULL)
+ {
+ if (!XpOpenTmpFile("w+", &pConPriv->postRasterFileName,
+ &pConPriv->pPostRasterFile))
+ return BadAlloc;
+ }
+ if(fwrite(pData, sizeof(char), (size_t)len_data,
+ pConPriv->pPostRasterFile) != (size_t)len_data)
+ return BadAlloc;
+ fflush(pConPriv->pPostRasterFile);
+ }
+ else if(len_options == strlen(noRasterStr) &&
+ strncmp(pOptions, noRasterStr, strlen(noRasterStr)) == 0)
+ {
+ if(pConPriv->pNoRasterFile == (FILE *)NULL)
+ {
+ if (!XpOpenTmpFile("w+", &pConPriv->noRasterFileName,
+ &pConPriv->pNoRasterFile))
+ return BadAlloc;
+ }
+ if(fwrite(pData, sizeof(char), (size_t)len_data,
+ pConPriv->pNoRasterFile) != (size_t)len_data)
+ return BadAlloc;
+ fflush(pConPriv->pNoRasterFile);
+ }
+ else
+ return BadValue;
+
+ return Success;
+}
+
+/*
+ * GetDocumentData notes which client is requesting the document data for
+ * a particular context. The Raster driver's EndPage function causes the
+ * data to be written to the proper client.
+ */
+static int
+GetDocumentData(
+ XpContextPtr pContext,
+ ClientPtr client,
+ int maxBufferSize)
+{
+ RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
+ pContext->devPrivates[RasterContextPrivateIndex].ptr;
+
+ pConPriv->getDocClient = client;
+ pConPriv->getDocBufSize = maxBufferSize;
+ return Success;
+}
+
+static void
+AllocateRasterPrivates(
+ ScreenPtr pScreen)
+{
+ if(RasterGeneration != serverGeneration)
+ {
+ RasterScreenPrivateIndex = AllocateScreenPrivateIndex();
+ RasterContextPrivateIndex = XpAllocateContextPrivateIndex();
+ XpAllocateContextPrivate( RasterContextPrivateIndex,
+ sizeof( RasterContextPrivRec ) );
+
+ RasterGeneration = serverGeneration;
+ }
+ pScreen->devPrivates[RasterScreenPrivateIndex].ptr = (pointer)Xalloc(
+ sizeof(RasterScreenPrivRec));
+}
+
+/*
+ * RasterChangeWindowAttributes - Make sure that the window's backing
+ * store is turned on.
+ */
+static Bool
+RasterChangeWindowAttributes(
+ WindowPtr pWin,
+ unsigned long mask)
+{
+ Bool status = Success;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RasterScreenPrivPtr pScreenPriv = (RasterScreenPrivPtr)
+ pScreen->devPrivates[RasterScreenPrivateIndex].ptr;
+
+ if(pWin->backingStore == NotUseful)
+ {
+ pWin->backingStore = WhenMapped;
+ mask |= CWBackingStore;
+ }
+
+ if(pScreenPriv->ChangeWindowAttributes != NULL)
+ {
+ pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes;
+ status = pScreen->ChangeWindowAttributes(pWin, mask);
+ pScreen->ChangeWindowAttributes = RasterChangeWindowAttributes;
+ }
+ return status;
+}
+
+/*
+ * RasterValidateDocFormats - Inspects the files available in the
+ * ddx-config/XP-RASTER directory to find the names of PDLs for which
+ * we have processing commands. These names are then intersected with
+ * the contents of the printer's document-formats-supported attribute,
+ * and the result is stored back into document-formats-supported.
+ * We have hard-coded knowledge of how to produce PS, so we always
+ * leave that in, if it's listed in document-formats-supported,
+ * even if we don't have a configuration file. If there is a
+ * configuration file for PS, then its contents will override our default.
+ */
+static void
+RasterValidateDocFormats(
+ XpContextPtr pCon)
+{
+}
+
+/*
+ * RasterValidateAttrs - Inspects and Corrects the attribute values
+ * in the specified context.
+ */
+static void
+RasterValidateAttrs(
+ XpContextPtr pCon)
+{
+ RasterValidateDocFormats(pCon);
+ XpValidatePrinterPool(pCon, &RasterValidatePoolsRec);
+ XpValidateJobPool(pCon, &RasterValidatePoolsRec);
+ XpValidateDocumentPool(pCon, &RasterValidatePoolsRec);
+}
+
+/*
+ * RasterInitContext - Establish the appropriate values for a
+ * PrintContext used with the Raster Driver.
+ */
+static char DOC_ATT_SUPP[]="document-attributes-supported:\tdefault-medium document-format";
+static char JOB_ATT_SUPP[]="job-attributes-supported:\t";
+static char DDX_DIR[]="ddx-config";
+
+static int
+RasterInitContext(
+ XpContextPtr pCon)
+{
+ char *configFileName, *val, *attrStr;
+ RasterContextPrivPtr pConPriv;
+ XpDriverFuncsPtr pFuncs;
+
+ /*
+ * Initialize the attribute store for this printer.
+ */
+ XpInitAttributes( pCon );
+
+ /*
+ * Validate the attributes
+ */
+ RasterValidateAttrs( pCon );
+
+
+ /*
+ * Initialize the function pointers
+ */
+ pFuncs = &( pCon->funcs );
+ pFuncs->StartJob = StartJob;
+ pFuncs->EndJob = EndJob;
+ pFuncs->StartDoc = StartDoc;
+ pFuncs->EndDoc = EndDoc;
+ pFuncs->StartPage = StartPage;
+ pFuncs->EndPage = EndPage;
+ pFuncs->PutDocumentData = DocumentData;
+ pFuncs->GetDocumentData = GetDocumentData;
+ pFuncs->DestroyContext = RasterDestroyContext;
+ pFuncs->GetAttributes = RasterGetAttributes;
+ pFuncs->GetOneAttribute = RasterGetOneAttribute;
+ pFuncs->SetAttributes = RasterSetAttributes;
+ pFuncs->AugmentAttributes = RasterAugmentAttributes;
+ pFuncs->GetMediumDimensions = RasterMediumDimensions;
+ pFuncs->GetReproducibleArea = RasterReproducibleArea;
+
+ /*
+ * Set up the context privates
+ */
+ pConPriv = (RasterContextPrivPtr)
+ pCon->devPrivates[RasterContextPrivateIndex].ptr;
+
+ pConPriv->jobFileName = (char *)NULL;
+ pConPriv->pageFileName = (char *)NULL;
+ pConPriv->preRasterFileName = (char *)NULL;
+ pConPriv->postRasterFileName = (char *)NULL;
+ pConPriv->noRasterFileName = (char *)NULL;
+ pConPriv->pJobFile = (FILE *)NULL;
+ pConPriv->pPageFile = (FILE *)NULL;
+ pConPriv->pPreRasterFile = (FILE *)NULL;
+ pConPriv->pPostRasterFile = (FILE *)NULL;
+ pConPriv->pNoRasterFile = (FILE *)NULL;
+
+ pConPriv->getDocClient = (ClientPtr)NULL;
+ pConPriv->getDocBufSize = 0;
+
+ /*
+ * Get the configuration information for the context's printer
+ */
+ configFileName = XpGetOneAttribute( pCon, XPPrinterAttr,
+ "xp-ddx-config-file-name" );
+ if(configFileName && strlen(configFileName))
+ {
+ if( configFileName[0] == '/' )
+ pConPriv->config = XrmGetFileDatabase( configFileName );
+ else
+ {
+ char *configDir, *configFilePath;
+
+ configDir = XpGetConfigDir(FALSE);
+ configFilePath = (char *)malloc((strlen(configDir) +
+ strlen(DDX_DIR) +
+ strlen(RASTER_DRIV_NAME) +
+ strlen(configFileName) +
+ 4)* sizeof(char));
+ sprintf(configFilePath, "%s/%s/%s/%s", configDir, DDX_DIR,
+ RASTER_DRIV_NAME, configFileName);
+ pConPriv->config = XrmGetFileDatabase(configFilePath);
+ free(configDir);
+ free(configFilePath);
+ }
+ }
+ else
+ pConPriv->config = (XrmDatabase)NULL;
+
+ /*
+ * Add our own attribute initialization
+ */
+ /*
+ * document-attributes-supported
+ */
+ val = XpGetOneAttribute(pCon, XPServerAttr, "document-attributes-supported");
+ if((attrStr = (char *)xalloc(strlen(val) + strlen(DOC_ATT_SUPP) + 4)) ==
+ (char *)NULL)
+ return BadAlloc;
+ sprintf(attrStr, "*%s %s", DOC_ATT_SUPP, val);
+ XpAugmentAttributes(pCon, XPPrinterAttr, attrStr);
+ xfree(attrStr);
+
+ /*
+ * job-attributes-supported
+ */
+ val = XpGetOneAttribute(pCon, XPServerAttr, "job-attributes-supported");
+ if((attrStr = (char *)xalloc(strlen(val) + strlen(JOB_ATT_SUPP) + 4)) ==
+ (char *)NULL)
+ return BadAlloc;
+ sprintf(attrStr, "*%s %s", JOB_ATT_SUPP, val);
+ XpAugmentAttributes(pCon, XPPrinterAttr, attrStr);
+ xfree(attrStr);
+
+ /*
+ * PageAttributesSupported
+ */
+ XpAugmentAttributes(pCon, XPPrinterAttr, "*xp-page-attributes-supported:");
+
+ return Success;
+}
+
+
+
+static Bool
+RasterDestroyContext(
+ XpContextPtr pCon)
+{
+ RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
+ pCon->devPrivates[RasterContextPrivateIndex].ptr;
+
+ /*
+ * Clean up the temporary files
+ */
+ FreePageFiles( pConPriv );
+
+ if( pConPriv->pJobFile != (FILE *)NULL )
+ {
+ fclose( pConPriv->pJobFile );
+ pConPriv->pJobFile = (FILE *)NULL;
+ }
+ if( pConPriv->jobFileName != (char *)NULL )
+ {
+ unlink( pConPriv->jobFileName );
+ Xfree( pConPriv->jobFileName );
+ }
+ if(pConPriv->config)
+ {
+ XrmDestroyDatabase(pConPriv->config);
+ pConPriv->config = (XrmDatabase)NULL;
+ }
+
+ XpDestroyAttributes( pCon );
+ return Success;
+}
+
+static char *
+RasterGetAttributes(
+ XpContextPtr pContext,
+ XPAttributes class)
+{
+ return XpGetAttributes( pContext, class );
+}
+
+static char *
+RasterGetOneAttribute(
+ XpContextPtr pContext,
+ XPAttributes class,
+ char *attr)
+{
+ return XpGetOneAttribute( pContext, class, attr );
+}
+
+static int
+RasterSetAttributes(XpContextPtr pCon,
+ XPAttributes class,
+ char *attributes)
+{
+ return XpSetAttributes( pCon, class, attributes );
+}
+
+static int
+RasterAugmentAttributes(
+ XpContextPtr pCon,
+ XPAttributes class,
+ char *attributes)
+{
+ return XpAugmentAttributes( pCon, class, attributes );
+}
+
+static void
+FreePageFiles(
+ RasterContextPrivPtr pConPriv)
+{
+ if(pConPriv->pPageFile != (FILE *)NULL)
+ {
+ fclose(pConPriv->pPageFile);
+ pConPriv->pPageFile = (FILE *)NULL;
+ }
+ if(pConPriv->pageFileName != (char *)NULL)
+ {
+ unlink(pConPriv->pageFileName);
+ Xfree(pConPriv->pageFileName);
+ pConPriv->pageFileName = (char *)NULL;
+ }
+ if(pConPriv->pPreRasterFile != (FILE *)NULL)
+ {
+ fclose(pConPriv->pPreRasterFile);
+ pConPriv->pPreRasterFile = (FILE *)NULL;
+ }
+ if(pConPriv->preRasterFileName != (char *)NULL)
+ {
+ unlink(pConPriv->preRasterFileName);
+ Xfree(pConPriv->preRasterFileName);
+ pConPriv->preRasterFileName = (char *)NULL;
+ }
+ if(pConPriv->pPostRasterFile != (FILE *)NULL)
+ {
+ fclose(pConPriv->pPostRasterFile);
+ pConPriv->pPostRasterFile = (FILE *)NULL;
+ }
+ if(pConPriv->postRasterFileName != (char *)NULL)
+ {
+ unlink(pConPriv->postRasterFileName);
+ Xfree(pConPriv->postRasterFileName);
+ pConPriv->postRasterFileName = (char *)NULL;
+ }
+ if(pConPriv->pNoRasterFile != (FILE *)NULL)
+ {
+ fclose(pConPriv->pNoRasterFile);
+ pConPriv->pNoRasterFile = (FILE *)NULL;
+ }
+ if(pConPriv->noRasterFileName != (char *)NULL)
+ {
+ unlink(pConPriv->noRasterFileName);
+ Xfree(pConPriv->noRasterFileName);
+ pConPriv->noRasterFileName = (char *)NULL;
+ }
+}
+
+/*
+ * RasterCloseScreen - Call any wrapped CloseScreen function,
+ * and free the screen memory.
+ */
+static Bool
+RasterCloseScreen(
+ int index,
+ ScreenPtr pScreen)
+{
+ Bool status = Success;
+ RasterScreenPrivPtr pScreenPriv = (RasterScreenPrivPtr)
+ pScreen->devPrivates[RasterScreenPrivateIndex].ptr;
+
+ /*
+ * Call any wrapped CloseScreen proc.
+ */
+ if(pScreenPriv->CloseScreen != NULL)
+ {
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+ status = pScreen->CloseScreen(index, pScreen);
+ pScreen->CloseScreen = RasterCloseScreen;
+ }
+
+ Xfree(pScreenPriv->pBits);
+ Xfree(pScreenPriv);
+
+ return status;
+}
+
+#include <signal.h>
+
+/* ARGSUSED */
+static void SigchldHndlr (int dummy)
+{
+ int status;
+ int olderrno = errno;
+ struct sigaction act;
+ sigfillset(&act.sa_mask);
+ act.sa_flags = 0;
+ act.sa_handler = SigchldHndlr;
+
+ (void) wait (&status);
+
+ /*
+ * Is this really necessary?
+ */
+ sigaction(SIGCHLD, &act, (struct sigaction *)NULL);
+ errno = olderrno;
+}
+
+/*
+ * SystemCmd provides a wrapper for the 'system' library call. The call
+ * appears to be sensitive to the handling of SIGCHLD, so this wrapper
+ * sets the status to SIG_DFL, and then resets the established handler
+ * after system returns.
+ */
+static int
+SystemCmd(char *cmdStr)
+{
+ int status;
+ struct sigaction newAct, oldAct;
+ sigfillset(&newAct.sa_mask);
+ newAct.sa_flags = 0;
+ newAct.sa_handler = SIG_DFL;
+ sigfillset(&oldAct.sa_mask);
+ oldAct.sa_flags = 0;
+ oldAct.sa_handler = SigchldHndlr;
+
+ /*
+ * get the old handler, and set the action to IGN
+ */
+ sigaction(SIGCHLD, &newAct, &oldAct);
+
+ status = system (cmdStr);
+
+ sigaction(SIGCHLD, &oldAct, (struct sigaction *)NULL);
+ return status;
+}
+
+/*
+ * RasterMediumDimensions is installed in the GetMediumDimensions field
+ * of each raster-initialized context.
+ */
+static int
+RasterMediumDimensions(XpContextPtr pCon,
+ CARD16 *width,
+ CARD16 *height)
+{
+ XpGetMediumDimensions(pCon, width, height);
+ return Success;
+}
+
+/*
+ * RasterReproducibleArea is installed in the GetReproducibleArea field
+ * of each raster-initialized context.
+ */
+static int
+RasterReproducibleArea(XpContextPtr pCon,
+ xRectangle *pRect)
+{
+ XpGetReproductionArea(pCon, pRect);
+ return Success;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/raster/Raster.h b/nx-X11/programs/Xserver/Xprint/raster/Raster.h
new file mode 100644
index 000000000..25da756e5
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/raster/Raster.h
@@ -0,0 +1,118 @@
+/* $Xorg: Raster.h,v 1.3 2000/08/17 19:48:12 cpqbld Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: printer/Raster.h
+** *
+** * Contents: defines and includes for the raster layer
+** * for a printing X server.
+** *
+** * Copyright: Copyright 1993 Hewlett-Packard Company
+** *
+** *********************************************************
+**
+********************************************************************/
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _RASTER_H_
+#define _RASTER_H_
+
+/*
+ * Some sleazes to force the XrmDB stuff into the server
+ */
+#ifndef HAVE_XPointer
+#define HAVE_XPointer 1
+typedef char *XPointer;
+#endif
+#define Status int
+#define True 1
+#define False 0
+#include "misc.h"
+#include <X11/Xfuncproto.h>
+#include <X11/Xresource.h>
+#include "attributes.h"
+
+#include <X11/extensions/Printstr.h>
+
+#define MAX_TOKEN_LEN 512
+
+#define RASTER_PRINT_PAGE_COMMAND "_XP_RASTER_PAGE_PROC_COMMAND"
+
+#define RASTER_IN_FILE_STRING "%(InFile)%"
+#define RASTER_OUT_FILE_STRING "%(OutFile)%"
+
+#define RASTER_ALLOWED_COMMANDS_FILE "printCommands"
+
+/*
+ * Defines for the "options" in DtPrintDocumentData.
+ */
+#define PRE_RASTER "PRE-RASTER"
+#define POST_RASTER "POST-RASTER"
+#define NO_RASTER "NO-RASTER"
+
+
+typedef struct {
+ char *pBits;
+ CreateWindowProcPtr CreateWindow;
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+ DestroyWindowProcPtr DestroyWindow;
+ CloseScreenProcPtr CloseScreen;
+} RasterScreenPrivRec, *RasterScreenPrivPtr;
+
+typedef struct {
+ XrmDatabase config;
+ char *jobFileName;
+ FILE *pJobFile;
+ char *pageFileName;
+ FILE *pPageFile;
+ char *preRasterFileName; /* Pre-raster document data */
+ FILE *pPreRasterFile;
+ char *noRasterFileName; /* Raster replacement document data */
+ FILE *pNoRasterFile;
+ char *postRasterFileName; /* Post-raster document data */
+ FILE *pPostRasterFile;
+ ClientPtr getDocClient;
+ int getDocBufSize;
+} RasterContextPrivRec, *RasterContextPrivPtr;
+
+
+extern XpValidatePoolsRec RasterValidatePoolsRec;
+
+extern Bool InitializeRasterDriver(int ndx, ScreenPtr pScreen, int argc,
+ char **argv);
+
+#endif /* _RASTER_H_ */
diff --git a/nx-X11/programs/Xserver/Xprint/raster/RasterAttVal.c b/nx-X11/programs/Xserver/Xprint/raster/RasterAttVal.c
new file mode 100644
index 000000000..fc00cde5a
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/raster/RasterAttVal.c
@@ -0,0 +1,269 @@
+/* $Xorg: RasterAttVal.c,v 1.4 2001/03/14 18:46:34 pookie Exp $ */
+/*
+(c) Copyright 1996 Hewlett-Packard Company
+(c) Copyright 1996 International Business Machines Corp.
+(c) Copyright 1996 Sun Microsystems, Inc.
+(c) Copyright 1996 Novell, Inc.
+(c) Copyright 1996 Digital Equipment Corp.
+(c) Copyright 1996 Fujitsu Limited
+(c) Copyright 1996 Hitachi, Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/raster/RasterAttVal.c,v 1.3 2001/10/31 22:50:29 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <X11/X.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "scrnintstr.h"
+#include "screenint.h"
+#include <X11/extensions/Print.h>
+#include "Raster.h"
+
+#include "attributes.h"
+#include "AttrValid.h"
+
+/*
+ * define valid values and defaults for Printer pool
+ */
+static XpOid ValidContentOrientationsOids[] = {
+ xpoid_val_content_orientation_portrait,
+ xpoid_val_content_orientation_landscape
+};
+static XpOidList ValidContentOrientations = {
+ ValidContentOrientationsOids, XpNumber(ValidContentOrientationsOids)
+};
+
+static XpOid DefaultContentOrientationsOids[] = {
+ xpoid_val_content_orientation_portrait,
+ xpoid_val_content_orientation_landscape
+};
+static XpOidList DefaultContentOrientations = {
+ DefaultContentOrientationsOids, XpNumber(DefaultContentOrientationsOids)
+};
+
+static XpOid ValidPlexesOids[] = {
+ xpoid_val_plex_simplex
+};
+static XpOidList ValidPlexes = {
+ ValidPlexesOids, XpNumber(ValidPlexesOids)
+};
+
+static XpOid DefaultPlexesOids[] = {
+ xpoid_val_plex_simplex
+};
+static XpOidList DefaultPlexes = {
+ DefaultPlexesOids, XpNumber(DefaultPlexesOids)
+};
+
+static unsigned long ValidPrinterResolutionsCards[] = {
+ 150, 300, 600
+};
+static XpOidCardList ValidPrinterResolutions = {
+ ValidPrinterResolutionsCards, XpNumber(ValidPrinterResolutionsCards)
+};
+
+static unsigned long DefaultPrinterResolutionsCards[] = {
+ 300
+};
+static XpOidCardList DefaultPrinterResolutions = {
+ DefaultPrinterResolutionsCards, XpNumber(DefaultPrinterResolutionsCards)
+};
+
+static XpOid ValidListfontsModesOids[] = {
+ xpoid_val_xp_list_glyph_fonts
+};
+static XpOidList ValidListfontsModes = {
+ ValidListfontsModesOids, XpNumber(ValidListfontsModesOids)
+};
+
+static XpOid DefaultListfontsModesOids[] = {
+ xpoid_val_xp_list_glyph_fonts
+};
+static XpOidList DefaultListfontsModes = {
+ DefaultListfontsModesOids, XpNumber(DefaultListfontsModesOids)
+};
+
+static XpOid ValidSetupProvisoOids[] = {
+ xpoid_val_xp_setup_mandatory, xpoid_val_xp_setup_optional
+};
+static XpOidList ValidSetupProviso = {
+ ValidSetupProvisoOids, XpNumber(ValidSetupProvisoOids)
+};
+
+static XpOidDocFmt ValidDocFormatsSupportedFmts[] = {
+ { "Postscript", "2", NULL },
+ { "PCL", "3", NULL }
+};
+static XpOidDocFmtList ValidDocFormatsSupported = {
+ ValidDocFormatsSupportedFmts, XpNumber(ValidDocFormatsSupportedFmts)
+};
+
+static XpOidDocFmt DefaultDocFormatsSupportedFmts[] = {
+ { "Postscript", "2", NULL }
+};
+static XpOidDocFmtList DefaultDocFormatsSupported = {
+ DefaultDocFormatsSupportedFmts, XpNumber(DefaultDocFormatsSupportedFmts)
+};
+
+static XpOidDocFmtList ValidEmbeddedFormatsSupported = {
+ (XpOidDocFmt *)NULL, 0
+};
+
+static XpOidDocFmtList DefaultEmbeddedFormatsSupported = {
+ (XpOidDocFmt *)NULL, 0
+};
+
+static XpOidDocFmt ValidRawFormatsSupportedFmts[] = {
+ { "Postscript", "2", NULL },
+ { "PCL", "3", NULL }
+};
+static XpOidDocFmtList ValidRawFormatsSupported = {
+ ValidRawFormatsSupportedFmts, XpNumber(ValidRawFormatsSupportedFmts)
+};
+
+static XpOidDocFmt DefaultRawFormatsSupportedFmts[] = {
+ { "Postscript", "2", NULL }
+};
+static XpOidDocFmtList DefaultRawFormatsSupported = {
+ DefaultRawFormatsSupportedFmts, XpNumber(DefaultRawFormatsSupportedFmts)
+};
+
+static XpOidList ValidInputTrays = {
+ (XpOid *)NULL, 0
+};
+
+static XpOid ValidMediumSizesOids[] = {
+ xpoid_val_medium_size_iso_a0,
+ xpoid_val_medium_size_iso_a1,
+ xpoid_val_medium_size_iso_a2,
+ xpoid_val_medium_size_iso_a3,
+ xpoid_val_medium_size_iso_a4,
+ xpoid_val_medium_size_iso_a5,
+ xpoid_val_medium_size_iso_a6,
+ xpoid_val_medium_size_iso_a7,
+ xpoid_val_medium_size_iso_a8,
+ xpoid_val_medium_size_iso_a9,
+ xpoid_val_medium_size_iso_a10,
+ xpoid_val_medium_size_iso_b0,
+ xpoid_val_medium_size_iso_b1,
+ xpoid_val_medium_size_iso_b2,
+ xpoid_val_medium_size_iso_b3,
+ xpoid_val_medium_size_iso_b4,
+ xpoid_val_medium_size_iso_b5,
+ xpoid_val_medium_size_iso_b6,
+ xpoid_val_medium_size_iso_b7,
+ xpoid_val_medium_size_iso_b8,
+ xpoid_val_medium_size_iso_b9,
+ xpoid_val_medium_size_iso_b10,
+ xpoid_val_medium_size_na_letter,
+ xpoid_val_medium_size_na_legal,
+ xpoid_val_medium_size_executive,
+ xpoid_val_medium_size_folio,
+ xpoid_val_medium_size_invoice,
+ xpoid_val_medium_size_ledger,
+ xpoid_val_medium_size_quarto,
+ xpoid_val_medium_size_iso_c3,
+ xpoid_val_medium_size_iso_c4,
+ xpoid_val_medium_size_iso_c5,
+ xpoid_val_medium_size_iso_c6,
+ xpoid_val_medium_size_iso_designated_long,
+ xpoid_val_medium_size_na_10x13_envelope,
+ xpoid_val_medium_size_na_9x12_envelope,
+ xpoid_val_medium_size_na_number_10_envelope,
+ xpoid_val_medium_size_na_7x9_envelope,
+ xpoid_val_medium_size_na_9x11_envelope,
+ xpoid_val_medium_size_na_10x14_envelope,
+ xpoid_val_medium_size_na_number_9_envelope,
+ xpoid_val_medium_size_monarch_envelope,
+ xpoid_val_medium_size_a,
+ xpoid_val_medium_size_b,
+ xpoid_val_medium_size_c,
+ xpoid_val_medium_size_d,
+ xpoid_val_medium_size_e,
+ xpoid_val_medium_size_jis_b0,
+ xpoid_val_medium_size_jis_b1,
+ xpoid_val_medium_size_jis_b2,
+ xpoid_val_medium_size_jis_b3,
+ xpoid_val_medium_size_jis_b4,
+ xpoid_val_medium_size_jis_b5,
+ xpoid_val_medium_size_jis_b6,
+ xpoid_val_medium_size_jis_b7,
+ xpoid_val_medium_size_jis_b8,
+ xpoid_val_medium_size_jis_b9,
+ xpoid_val_medium_size_jis_b10
+};
+static XpOidList ValidMediumSizes = {
+ ValidMediumSizesOids, XpNumber(ValidMediumSizesOids)
+};
+
+static XpOidDocFmt DefaultDocumentFormat = {
+ "Postscript", "2", NULL
+};
+
+static XpOid ValidAvailableCompressionsOids[] = {
+ xpoid_val_available_compressions_0,
+ xpoid_val_available_compressions_01,
+ xpoid_val_available_compressions_02,
+ xpoid_val_available_compressions_03,
+ xpoid_val_available_compressions_012,
+ xpoid_val_available_compressions_013,
+ xpoid_val_available_compressions_023,
+ xpoid_val_available_compressions_0123
+};
+
+static XpOidList ValidAvailableCompressions = {
+ ValidAvailableCompressionsOids, XpNumber(ValidAvailableCompressionsOids)
+};
+
+static XpOid DefaultAvailableCompressionsOids[] = {
+ xpoid_val_available_compressions_0123,
+ xpoid_val_available_compressions_0
+};
+
+static XpOidList DefaultAvailableCompressions = {
+ DefaultAvailableCompressionsOids, XpNumber(DefaultAvailableCompressionsOids)
+};
+
+
+/*
+ * init struct for XpValidate*Pool
+ */
+XpValidatePoolsRec RasterValidatePoolsRec = {
+ &ValidContentOrientations, &DefaultContentOrientations,
+ &ValidDocFormatsSupported, &DefaultDocFormatsSupported,
+ &ValidInputTrays, &ValidMediumSizes,
+ &ValidPlexes, &DefaultPlexes,
+ &ValidPrinterResolutions, &DefaultPrinterResolutions,
+ &ValidEmbeddedFormatsSupported, &DefaultEmbeddedFormatsSupported,
+ &ValidListfontsModes, &DefaultListfontsModes,
+ &ValidRawFormatsSupported, &DefaultRawFormatsSupported,
+ &ValidSetupProviso,
+ &DefaultDocumentFormat,
+ &ValidAvailableCompressions, &DefaultAvailableCompressions
+};
diff --git a/nx-X11/programs/Xserver/Xprint/spooler.c b/nx-X11/programs/Xserver/Xprint/spooler.c
new file mode 100644
index 000000000..f709c57ab
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/spooler.c
@@ -0,0 +1,204 @@
+
+/* $Xorg: spooler.c,v 1.1 2003/09/14 1:19:56 gisburn Exp $ */
+/*
+Copyright (c) 2003-2004 Roland Mainz <roland.mainz@nrubsig.org>
+Copyright (c) 2004 Sun Microsystems, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#ifdef __hpux
+#include <sys/sysmacros.h>
+#endif
+
+#include "spooler.h"
+
+/*
+ * The string LIST_QUEUES_* is fed to a shell to generate an ordered
+ * list of available printers on the system. These string definitions
+ * are taken from the file PrintSubSys.C within the code for the
+ * dtprintinfo program.
+ */
+#define LIST_QUEUES_AIX4 \
+ "lsallq | grep -v '^bsh$' | sort | uniq"
+
+#define LIST_QUEUES_HPUX \
+ "LANG=C lpstat -v | " \
+ "awk '" \
+ " $2 == \"for\" " \
+ " { " \
+ " x = match($3, /:/); " \
+ " print substr($3, 1, x-1)" \
+ " }' | sort | uniq"
+
+#define LIST_QUEUES_OSF \
+ "LANG=C lpstat -v | " \
+ "nawk '" \
+ " $2 == \"for\" " \
+ " { print $4 }' " \
+ " | sort | uniq"
+
+#define LIST_QUEUES_UXP \
+ "LANG=C lpstat -v |" \
+ "nawk '" \
+ " $4 == \"for\" " \
+ " { " \
+ " x = match($5, /:/); " \
+ " print substr($5, 1, x-1)" \
+ " }' | sort | uniq"
+
+/* Support both normal and LPRng output of "lpc status" */
+#define LIST_QUEUES_BSD \
+ "PATH=\"${PATH}:/usr/bin:/usr/sbin:/bin:/sbin\"\n" \
+ "export PATH\n" \
+ \
+ "which_tool()\n" \
+ "{\n" \
+ " echo \"${PATH}\" | tr \":\" \"\n\" | while read i ; do ls -1ad \"${i}/${1}\" 2>/dev/null ; done\n" \
+ "}\n" \
+ \
+ "(\n" \
+ "WHICH_LPC=\"`which_tool lpc`\"\n" \
+ \
+ "if [ \"`which_tool nawk`\" != \"\" ] ; then\n" \
+ " NAWK=\"nawk\"\n" \
+ "else\n" \
+ " NAWK=\"awk\"\n" \
+ "fi\n" \
+ \
+ "[ \"${WHICH_LPC}\" != \"\" ] && (LANG=C lpc status | ${NAWK} '/^[^ ]*:$/ && !/@/ && !/ / { print $1 }' | sed -e /:/s///)\n" \
+ "[ \"${WHICH_LPC}\" != \"\" ] && (LANG=C lpc -a status | ${NAWK} '/^[^ ]*@[^ ]/ && !/:$/ { split( $1, name, \"@\" ); print name[1]; }')\n" \
+ ") | egrep -v -i \" |^all$\" | sort | uniq"
+
+#define LIST_QUEUES_SYSV \
+ "PATH=\"${PATH}:/usr/bin:/usr/sbin:/bin:/sbin\"\n" \
+ "export PATH\n" \
+ \
+ "which_tool()\n" \
+ "{\n" \
+ " echo \"${PATH}\" | tr \":\" \"\n\" | while read i ; do ls -1ad \"${i}/${1}\" 2>/dev/null ; done\n" \
+ "}\n" \
+ \
+ "(\n" \
+ "WHICH_LPSTAT=\"`which_tool lpstat`\"\n" \
+ \
+ "if [ \"`which_tool nawk`\" != \"\" ] ; then\n" \
+ " NAWK=\"nawk\"\n" \
+ "else\n" \
+ " NAWK=\"awk\"\n" \
+ "fi\n" \
+ \
+ "[ \"${WHICH_LPSTAT}\" != \"\" ] && (LANG=C lpstat -v | ${NAWK} ' $2 == \"for\" { x = match($3, /:/); print substr($3, 1, x-1) }')\n" \
+ ") | egrep -v -i \" |^all$\" | sort | uniq"
+
+#define LIST_QUEUES_SOLARIS "LANG=C lpget -k description " \
+ "`lpstat -v " \
+ "| nawk '$2 == \"for\" { x = match($3, /:/); print substr($3, 1,x-1) }' " \
+ "| sort -u` " \
+ "| nawk -F: ' NF == 2 { name=$1 } " \
+ " NF == 1 { sub(\"^.*description\\( - undefined|=\\)\",\"\"); " \
+ " printf \"%s\txp-printerattr.descriptor=%s\\n\", name, $1 } '"
+
+#define LIST_QUEUES_OTHER \
+ "LANG=C lpstat -v | " \
+ "nawk '" \
+ " $2 == \"for\" " \
+ " { " \
+ " x = match($3, /:/); " \
+ " print substr($3, 1, x-1)" \
+ " }' | sort | uniq"
+
+#define DEFAULT_SPOOL_COMMAND_HPUX "/usr/bin/lp -d %printer-name% -o raw -n %copy-count% -t %job-name% %options%"
+#define DEFAULT_SPOOL_COMMAND_BSD "/usr/bin/lpr -P %printer-name% -#%copy-count% -T %job-name% %options%"
+#define DEFAULT_SPOOL_COMMAND_SYSV "/usr/bin/lp -d %printer-name% -n %copy-count% -t %job-name% %options%"
+#define DEFAULT_SPOOL_COMMAND_SOLARIS "/usr/bin/lp -d %printer-name% -n %copy-count% -t %job-name% %options%"
+#define DEFAULT_SPOOL_COMMAND_OTHER "/usr/bin/lp -d %printer-name% -n %copy-count% -t %job-name% %options%"
+
+
+/* List of spooler types and the commands used to enumerate
+ * print queues and submit print jobs */
+XpSpoolerType xpstm[] =
+{
+ /* OS-specific spoolers */
+ { "aix", LIST_QUEUES_AIX4, DEFAULT_SPOOL_COMMAND_OTHER },
+ { "aix4", LIST_QUEUES_AIX4, DEFAULT_SPOOL_COMMAND_OTHER },
+ { "bsd", LIST_QUEUES_BSD, DEFAULT_SPOOL_COMMAND_BSD },
+ { "osf", LIST_QUEUES_OSF, DEFAULT_SPOOL_COMMAND_OTHER },
+ { "solaris", LIST_QUEUES_SOLARIS, DEFAULT_SPOOL_COMMAND_SOLARIS },
+ { "sysv", LIST_QUEUES_SYSV, DEFAULT_SPOOL_COMMAND_SYSV },
+ { "uxp", LIST_QUEUES_UXP, DEFAULT_SPOOL_COMMAND_OTHER },
+ /* crossplatform spoolers */
+ { "cups", LIST_QUEUES_SYSV, DEFAULT_SPOOL_COMMAND_SYSV },
+ { "lprng", LIST_QUEUES_BSD, DEFAULT_SPOOL_COMMAND_BSD },
+ /* misc */
+ { "other", LIST_QUEUES_OTHER, DEFAULT_SPOOL_COMMAND_OTHER },
+ { "none", NULL, NULL },
+ { NULL, NULL, NULL }
+};
+
+/* Used by Init.c and attributes.c */
+XpSpoolerTypePtr spooler_type = NULL;
+
+XpSpoolerTypePtr XpSpoolerNameToXpSpoolerType(char *name)
+{
+ XpSpoolerTypePtr curr = xpstm;
+
+ while( curr->name != NULL )
+ {
+ if( !strcasecmp(name, curr->name) )
+ return curr;
+
+ curr++;
+ }
+
+ return NULL;
+}
+
+static char *spooler_namelist = NULL;
+
+char *XpGetSpoolerTypeNameList(void)
+{
+ if( spooler_namelist )
+ return spooler_namelist;
+
+ return XPDEFAULTSPOOLERNAMELIST;
+}
+
+void XpSetSpoolerTypeNameList(char *namelist)
+{
+ spooler_namelist = namelist;
+}
+
+
diff --git a/nx-X11/programs/Xserver/Xprint/spooler.h b/nx-X11/programs/Xserver/Xprint/spooler.h
new file mode 100644
index 000000000..4e9b4aefc
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/spooler.h
@@ -0,0 +1,76 @@
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef SPOOLER_H
+#define SPOOLER_H 1
+
+/* $Xorg: spooler.h,v 1.1 2003/09/14 1:19:56 gisburn Exp $ */
+/*
+Copyright (c) 2003-2004 Roland Mainz <roland.mainz@nrubsig.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from said
+copyright holders.
+*/
+
+/*
+ * Define platform-specific default spooler type
+ */
+#if defined(sun)
+#define XPDEFAULTSPOOLERNAMELIST "solaris"
+#elif defined(AIXV4)
+#define XPDEFAULTSPOOLERNAMELIST "aix4"
+#elif defined(hpux)
+#define XPDEFAULTSPOOLERNAMELIST "hpux"
+#elif defined(__osf__)
+#define XPDEFAULTSPOOLERNAMELIST "osf"
+#elif defined(__uxp__)
+#define XPDEFAULTSPOOLERNAMELIST "uxp"
+#elif defined(CSRG_BASED) || defined(linux)
+/* ToDo: This should be "cups:bsd" in the future, but for now
+ * the search order first-bsd-then-cups is better for backwards
+ * compatibility.
+ */
+#define XPDEFAULTSPOOLERNAMELIST "bsd:cups"
+#else
+#define XPDEFAULTSPOOLERNAMELIST "other"
+#endif
+
+typedef struct
+{
+ const char *name;
+ const char *list_queues_command;
+ const char *spool_command;
+} XpSpoolerType, *XpSpoolerTypePtr;
+
+/* prototypes */
+extern XpSpoolerTypePtr XpSpoolerNameToXpSpoolerType(char *name);
+extern void XpSetSpoolerTypeNameList(char *namelist);
+extern char *XpGetSpoolerTypeNameList(void);
+
+/* global vars */
+extern XpSpoolerTypePtr spooler_type;
+extern XpSpoolerType xpstm[];
+
+#endif /* !SPOOLER_H */
+
diff --git a/nx-X11/programs/Xserver/Xprint/svg/README b/nx-X11/programs/Xserver/Xprint/svg/README
new file mode 100644
index 000000000..3ac0950c1
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/svg/README
@@ -0,0 +1 @@
+Tracking bug for this work is http://xprint.mozdev.org/bugs/show_bug.cgi?id=5401
diff --git a/nx-X11/programs/Xserver/Xprint/windows/README b/nx-X11/programs/Xserver/Xprint/windows/README
new file mode 100644
index 000000000..90cba8d04
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/windows/README
@@ -0,0 +1 @@
+Tracking bug for this work is http://xprint.mozdev.org/bugs/show_bug.cgi?id=3530
diff --git a/nx-X11/programs/Xserver/Xserver.man b/nx-X11/programs/Xserver/Xserver.man
new file mode 100644
index 000000000..bacfa4fc1
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xserver.man
@@ -0,0 +1,790 @@
+.\" $Xorg: Xserver.man,v 1.4 2001/02/09 02:04:07 xorgcvs Exp $
+.\" Copyright 1984 - 1991, 1993, 1994, 1998 The Open Group
+.\"
+.\" Permission to use, copy, modify, distribute, and sell this software and its
+.\" documentation for any purpose is hereby granted without fee, provided that
+.\" the above copyright notice appear in all copies and that both that
+.\" copyright notice and this permission notice appear in supporting
+.\" documentation.
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of The Open Group shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from The Open Group.
+.\" $XFree86: xc/programs/Xserver/Xserver.man,v 3.31 2004/01/10 22:27:46 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH XSERVER 1 __xorgversion__
+.SH NAME
+Xserver \- X Window System display server
+.SH SYNOPSIS
+.B X
+[option ...]
+.SH DESCRIPTION
+.I X
+is the generic name for the X Window System display server. It is
+frequently a link or a copy of the appropriate server binary for
+driving the most frequently used server on a given machine.
+.SH "STARTING THE SERVER"
+The X server is usually started from the X Display Manager program
+\fIxdm\fP(1) or a similar display manager program.
+This utility is run from the system boot files and takes care of keeping
+the server running, prompting for usernames and passwords, and starting up
+the user sessions.
+.PP
+Installations that run more than one window system may need to use the
+\fIxinit\fP(1) utility instead of a display manager. However, \fIxinit\fP is
+to be considered a tool for building startup scripts and is not
+intended for use by end users. Site administrators are \fBstrongly\fP
+urged to use a display manager, or build other interfaces for novice users.
+.PP
+The X server may also be started directly by the user, though this
+method is usually reserved for testing and is not recommended for
+normal operation. On some platforms, the user must have special
+permission to start the X server, often because access to certain
+devices (e.g. \fI/dev/mouse\fP) is restricted.
+.PP
+When the X server starts up, it typically takes over the display. If
+you are running on a workstation whose console is the display, you may
+not be able to log into the console while the server is running.
+.SH OPTIONS
+Many X servers have device-specific command line options. See the manual
+pages for the individual servers for more details; a list of
+server-specific manual pages is provided in the SEE ALSO section below.
+.PP
+All of the X servers accept the command line options described below.
+Some X servers may have alternative ways of providing the parameters
+described here, but the values provided via the command line options
+should override values specified via other mechanisms.
+.TP 8
+.B :\fIdisplaynumber\fP
+The X server runs as the given \fIdisplaynumber\fP, which by default is 0.
+If multiple X servers are to run simultaneously on a host, each must have
+a unique display number. See the DISPLAY
+NAMES section of the \fIX\fP(__miscmansuffix__) manual page to learn how to
+specify which display number clients should try to use.
+.TP 8
+.B \-a \fInumber\fP
+sets pointer acceleration (i.e. the ratio of how much is reported to how much
+the user actually moved the pointer).
+.TP 8
+.B \-ac
+disables host-based access control mechanisms. Enables access by any host,
+and permits any host to modify the access control list.
+Use with extreme caution.
+This option exists primarily for running test suites remotely.
+.TP 8
+.B \-audit \fIlevel\fP
+sets the audit trail level. The default level is 1, meaning only connection
+rejections are reported. Level 2 additionally reports all successful
+connections and disconnects. Level 4 enables messages from the
+SECURITY extension, if present, including generation and revocation of
+authorizations and violations of the security policy.
+Level 0 turns off the audit trail.
+Audit lines are sent as standard error output.
+.TP 8
+.B \-auth \fIauthorization-file\fP
+specifies a file which contains a collection of authorization records used
+to authenticate access. See also the \fIxdm\fP(1) and
+\fIXsecurity\fP(__miscmansuffix__) manual pages.
+.TP 8
+.B bc
+disables certain kinds of error checking, for bug compatibility with
+previous releases (e.g., to work around bugs in R2 and R3 xterms and toolkits).
+Deprecated.
+.TP 8
+.B \-bs
+disables backing store support on all screens.
+.TP 8
+.B \-br
+sets the default root window to solid black instead of the standard root weave
+pattern.
+.TP 8
+.B \-c
+turns off key-click.
+.TP 8
+.B c \fIvolume\fP
+sets key-click volume (allowable range: 0-100).
+.TP 8
+.B \-cc \fIclass\fP
+sets the visual class for the root window of color screens.
+The class numbers are as specified in the X protocol.
+Not obeyed by all servers.
+.TP 8
+.B \-co \fIfilename\fP
+sets name of RGB color database. The default is
+.IR __projectroot__/lib/X11/rgb .
+.ig
+.TP 8
+.B \-config \fIfilename\fP
+reads more options from the given file. Options in the file may be separated
+by newlines if desired. If a '#' character appears on a line, all characters
+between it and the next newline are ignored, providing a simple commenting
+facility. The \fB\-config\fP option itself may appear in the file.
+.BR NOTE :
+This option is disabled when the Xserver is run with an effective uid
+different from the user's real uid.
+..
+.TP 8
+.B \-core
+causes the server to generate a core dump on fatal errors.
+.TP 8
+.B \-deferglyphs \fIwhichfonts\fP
+specifies the types of fonts for which the server should attempt to use
+deferred glyph loading. \fIwhichfonts\fP can be all (all fonts),
+none (no fonts), or 16 (16 bit fonts only).
+.TP 8
+.B \-dpi \fIresolution\fP
+sets the resolution for all screens, in dots per inch.
+To be used when the server cannot determine the screen size(s) from the
+hardware.
+.TP 8
+.B dpms
+enables DPMS (display power management services), where supported. The
+default state is platform and configuration specific.
+.TP 8
+.B \-dpms
+disables DPMS (display power management services). The default state
+is platform and configuration specific.
+.TP 8
+.B \-f \fIvolume\fP
+sets feep (bell) volume (allowable range: 0-100).
+.TP 8
+.B \-fc \fIcursorFont\fP
+sets default cursor font.
+.TP 8
+.B \-fn \fIfont\fP
+sets the default font.
+.TP 8
+.B \-fp \fIfontPath\fP
+sets the search path for fonts. This path is a comma separated list
+of directories which the X server searches for font databases.
+See the FONTS section of this manual page for more information and the default
+list.
+.TP 8
+.B \-help
+prints a usage message.
+.TP 8
+.B \-I
+causes all remaining command line arguments to be ignored.
+.TP 8
+.B \-maxbigreqsize \fIsize\fP
+sets the maxmium big request to
+.I size
+MB.
+.TP 8
+.B \-nolisten \fItrans-type\fP
+disables a transport type. For example, TCP/IP connections can be disabled
+with
+.BR "\-nolisten tcp" .
+This option may be issued multiple times to disable listening to different
+transport types.
+.TP 8
+.B \-noreset
+prevents a server reset when the last client connection is closed. This
+overrides a previous
+.B \-terminate
+command line option.
+.TP 8
+.B \-p \fIminutes\fP
+sets screen-saver pattern cycle time in minutes.
+.TP 8
+.B \-pn
+permits the server to continue running if it fails to establish all of
+its well-known sockets (connection points for clients), but
+establishes at least one. This option is set by default.
+.TP 8
+.B \-nopn
+causes the server to exit if it fails to establish all of its well-known
+sockets (connection points for clients).
+.TP 8
+.B \-r
+turns off auto-repeat.
+.TP 8
+.B r
+turns on auto-repeat.
+.TP 8
+.B \-s \fIminutes\fP
+sets screen-saver timeout time in minutes.
+.TP 8
+.B \-su
+disables save under support on all screens.
+.TP 8
+.B \-t \fInumber\fP
+sets pointer acceleration threshold in pixels (i.e. after how many pixels
+pointer acceleration should take effect).
+.TP 8
+.B \-terminate
+causes the server to terminate at server reset, instead of continuing to run.
+This overrides a previous
+.B \-noreset
+command line option.
+.TP 8
+.B \-to \fIseconds\fP
+sets default connection timeout in seconds.
+.TP 8
+.B \-tst
+disables all testing extensions (e.g., XTEST, XTrap, XTestExtension1, RECORD).
+.TP 8
+.B tty\fIxx\fP
+ignored, for servers started the ancient way (from init).
+.TP 8
+.B v
+sets video-off screen-saver preference.
+.TP 8
+.B \-v
+sets video-on screen-saver preference.
+.TP 8
+.B \-wm
+forces the default backing-store of all windows to be WhenMapped. This
+is a backdoor way of getting backing-store to apply to all windows.
+Although all mapped windows will have backing store, the backing store
+attribute value reported by the server for a window will be the last
+value established by a client. If it has never been set by a client,
+the server will report the default value, NotUseful. This behavior is
+required by the X protocol, which allows the server to exceed the
+client's backing store expectations but does not provide a way to tell
+the client that it is doing so.
+.TP 8
+.B \-x \fIextension\fP
+loads the specified extension at init.
+This is a no-op for most implementations.
+.TP 8
+.B [+-]xinerama
+enables(+) or disables(-) the XINERAMA extension. The default state is
+platform and configuration specific.
+.SH SERVER DEPENDENT OPTIONS
+Some X servers accept the following options:
+.TP 8
+.B \-ld \fIkilobytes\fP
+sets the data space limit of the server to the specified number of kilobytes.
+A value of zero makes the data size as large as possible. The default value
+of \-1 leaves the data space limit unchanged.
+.TP 8
+.B \-lf \fIfiles\fP
+sets the number-of-open-files limit of the server to the specified number.
+A value of zero makes the limit as large as possible. The default value
+of \-1 leaves the limit unchanged.
+.TP 8
+.B \-ls \fIkilobytes\fP
+sets the stack space limit of the server to the specified number of kilobytes.
+A value of zero makes the stack size as large as possible. The default value
+of \-1 leaves the stack space limit unchanged.
+.TP 8
+.B \-logo
+turns on the X Window System logo display in the screen-saver.
+There is currently no way to change this from a client.
+.TP 8
+.B nologo
+turns off the X Window System logo display in the screen-saver.
+There is currently no way to change this from a client.
+.TP 8
+.B \-render
+.BR default | mono | gray | color
+sets the color allocation policy that will be used by the render extension.
+.RS 8
+.TP 8
+.I default
+selects the default policy defined for the display depth of the X
+server.
+.TP 8
+.I mono
+don't use any color cell.
+.TP 8
+.I gray
+use a gray map of 13 color cells for the X render extension.
+.TP 8
+.I color
+use a color cube of at most 4*4*4 colors (that is 64 color cells).
+.RE
+.TP 8
+.B \-dumbSched
+disables smart scheduling on platforms that support the smart scheduler.
+.TP
+.B \-schedInterval \fIinterval\fP
+sets the smart scheduler's scheduling interval to
+.I interval
+milliseconds.
+.SH XDMCP OPTIONS
+X servers that support XDMCP have the following options.
+See the \fIX Display Manager Control Protocol\fP specification for more
+information.
+.TP 8
+.B \-query \fIhostname\fP
+enables XDMCP and sends Query packets to the specified
+.IR hostname .
+.TP 8
+.B \-broadcast
+enable XDMCP and broadcasts BroadcastQuery packets to the network. The
+first responding display manager will be chosen for the session.
+.TP 8
+.B \-multicast [\fIaddress\fP [\fIhop count\fP]]
+Enable XDMCP and multicast BroadcastQuery packets to the network.
+The first responding display manager is chosen for the session. If an
+address is specified, the multicast is sent to that address. If no
+address is specified, the multicast is sent to the default XDMCP IPv6
+multicast group. If a hop count is specified, it is used as the maximum
+hop count for the multicast. If no hop count is specified, the multicast
+is set to a maximum of 1 hop, to prevent the multicast from being routed
+beyond the local network.
+.TP 8
+.B \-indirect \fIhostname\fP
+enables XDMCP and send IndirectQuery packets to the specified
+.IR hostname .
+.TP 8
+.B \-port \fIport-number\fP
+uses the specified \fIport-number\fP for XDMCP packets, instead of the
+default. This option must be specified before any \-query, \-broadcast,
+\-multicast, or \-indirect options.
+.TP 8
+.B \-from \fIlocal-address\fP
+specifies the local address to connect from (useful if the connecting host
+has multiple network interfaces). The \fIlocal-address\fP may be expressed
+in any form acceptable to the host platform's \fIgethostbyname\fP(3)
+implementation.
+.TP 8
+.B \-once
+causes the server to terminate (rather than reset) when the XDMCP session
+ends.
+.TP 8
+.B \-class \fIdisplay-class\fP
+XDMCP has an additional display qualifier used in resource lookup for
+display-specific options. This option sets that value, by default it
+is "MIT-Unspecified" (not a very useful value).
+.TP 8
+.B \-cookie \fIxdm-auth-bits\fP
+When testing XDM-AUTHENTICATION-1, a private key is shared between the
+server and the manager. This option sets the value of that private
+data (not that it is very private, being on the command line!).
+.TP 8
+.B \-displayID \fIdisplay-id\fP
+Yet another XDMCP specific value, this one allows the display manager to
+identify each display so that it can locate the shared key.
+.SH XKEYBOARD OPTIONS
+X servers that support the XKEYBOARD (a.k.a. \*qXKB\*q) extension accept the
+following options. All layout files specified on the command line must be
+located in the XKB base directory or a subdirectory, and specified as the
+relative path from the XKB base directory. The default XKB base directory is
+.IR __projectroot__/lib/X11/xkb .
+.TP 8
+.B [+-]kb
+enables(+) or disables(-) the XKEYBOARD extension.
+.TP 8
+.BR [+-]accessx " [ \fItimeout\fP [ \fItimeout_mask\fP [ \fIfeedback\fP [ \fIoptions_mask\fP ] ] ] ]"
+enables(+) or disables(-) AccessX key sequences.
+.TP 8
+.B \-xkbdir \fIdirectory\fP
+base directory for keyboard layout files. This option is not available
+for setuid X servers (i.e., when the X server's real and effective uids
+are different).
+.TP 8
+.B \-ar1 \fImilliseconds\fP
+sets the autorepeat delay (length of time in milliseconds that a key must
+be depressed before autorepeat starts).
+.TP 8
+.B \-ar2 \fImilliseconds\fP
+sets the autorepeat interval (length of time in milliseconds that should
+elapse between autorepeat-generated keystrokes).
+.TP 8
+.B \-noloadxkb
+disables loading of an XKB keymap description on server startup.
+.TP 8
+.B \-xkbdb \fIfilename\fP
+uses \fIfilename\fP for default keyboard keymaps.
+.TP 8
+.B \-xkbmap \fIfilename\fP
+loads keyboard description in \fIfilename\fP on server startup.
+.SH SECURITY EXTENSION OPTIONS
+X servers that support the SECURITY extension accept the following option:
+.TP 8
+.B \-sp \fIfilename\fP
+causes the server to attempt to read and interpret filename as a security
+policy file with the format described below. The file is read at server
+startup and reread at each server reset.
+.PP
+The syntax of the security policy file is as follows.
+Notation: "*" means zero or more occurrences of the preceding element,
+and "+" means one or more occurrences. To interpret <foo/bar>, ignore
+the text after the /; it is used to distinguish between instances of
+<foo> in the next section.
+.PP
+.nf
+<policy file> ::= <version line> <other line>*
+
+<version line> ::= <string/v> '\en'
+
+<other line > ::= <comment> | <access rule> | <site policy> | <blank line>
+
+<comment> ::= # <not newline>* '\en'
+
+<blank line> ::= <space> '\en'
+
+<site policy> ::= sitepolicy <string/sp> '\en'
+
+<access rule> ::= property <property/ar> <window> <perms> '\en'
+
+<property> ::= <string>
+
+<window> ::= any | root | <required property>
+
+<required property> ::= <property/rp> | <property with value>
+
+<property with value> ::= <property/rpv> = <string/rv>
+
+<perms> ::= [ <operation> | <action> | <space> ]*
+
+<operation> ::= r | w | d
+
+<action> ::= a | i | e
+
+<string> ::= <dbl quoted string> | <single quoted string> | <unqouted string>
+
+<dbl quoted string> ::= <space> " <not dqoute>* " <space>
+
+<single quoted string> ::= <space> ' <not squote>* ' <space>
+
+<unquoted string> ::= <space> <not space>+ <space>
+
+<space> ::= [ ' ' | '\et' ]*
+
+Character sets:
+
+<not newline> ::= any character except '\en'
+<not dqoute> ::= any character except "
+<not squote> ::= any character except '
+<not space> ::= any character except those in <space>
+.fi
+.PP
+The semantics associated with the above syntax are as follows.
+.PP
+<version line>, the first line in the file, specifies the file format
+version. If the server does not recognize the version <string/v>, it
+ignores the rest of the file. The version string for the file format
+described here is "version-1" .
+.PP
+Once past the <version line>, lines that do not match the above syntax
+are ignored.
+.PP
+<comment> lines are ignored.
+.PP
+<sitepolicy> lines are currently ignored. They are intended to
+specify the site policies used by the XC-QUERY-SECURITY-1
+authorization method.
+.PP
+<access rule> lines specify how the server should react to untrusted
+client requests that affect the X Window property named <property/ar>.
+The rest of this section describes the interpretation of an
+<access rule>.
+.PP
+For an <access rule> to apply to a given instance of <property/ar>,
+<property/ar> must be on a window that is in the set of windows
+specified by <window>. If <window> is any, the rule applies to
+<property/ar> on any window. If <window> is root, the rule applies to
+<property/ar> only on root windows.
+.PP
+If <window> is <required property>, the following apply. If <required
+property> is a <property/rp>, the rule applies when the window also
+has that <property/rp>, regardless of its value. If <required
+property> is a <property with value>, <property/rpv> must also have
+the value specified by <string/rv>. In this case, the property must
+have type STRING and format 8, and should contain one or more
+null-terminated strings. If any of the strings match <string/rv>, the
+rule applies.
+.PP
+The definition of string matching is simple case-sensitive string
+comparison with one elaboration: the occurrence of the character '*' in
+<string/rv> is a wildcard meaning "any string." A <string/rv> can
+contain multiple wildcards anywhere in the string. For example, "x*"
+matches strings that begin with x, "*x" matches strings that end with
+x, "*x*" matches strings containing x, and "x*y*" matches strings that
+start with x and subsequently contain y.
+.PP
+There may be multiple <access rule> lines for a given <property/ar>.
+The rules are tested in the order that they appear in the file. The
+first rule that applies is used.
+.PP
+<perms> specify operations that untrusted clients may attempt, and
+the actions that the server should take in response to those operations.
+.PP
+<operation> can be r (read), w (write), or d (delete). The following
+table shows how X Protocol property requests map to these operations
+in The Open Group server implementation.
+.PP
+.nf
+GetProperty r, or r and d if delete = True
+ChangeProperty w
+RotateProperties r and w
+DeleteProperty d
+ListProperties none, untrusted clients can always list all properties
+.fi
+.PP
+<action> can be a (allow), i (ignore), or e (error). Allow means
+execute the request as if it had been issued by a trusted client.
+Ignore means treat the request as a no-op. In the case of
+GetProperty, ignore means return an empty property value if the
+property exists, regardless of its actual value. Error means do not
+execute the request and return a BadAtom error with the atom set to
+the property name. Error is the default action for all properties,
+including those not listed in the security policy file.
+.PP
+An <action> applies to all <operation>s that follow it, until the next
+<action> is encountered. Thus, irwad means ignore read and write,
+allow delete.
+.PP
+GetProperty and RotateProperties may do multiple operations (r and d,
+or r and w). If different actions apply to the operations, the most
+severe action is applied to the whole request; there is no partial
+request execution. The severity ordering is: allow < ignore < error.
+Thus, if the <perms> for a property are ired (ignore read, error
+delete), and an untrusted client attempts GetProperty on that property
+with delete = True, an error is returned, but the property value is
+not. Similarly, if any of the properties in a RotateProperties do not
+allow both read and write, an error is returned without changing any
+property values.
+.PP
+Here is an example security policy file.
+.PP
+.ta 3i 4i
+.nf
+version-1
+
+XCOMM Allow reading of application resources, but not writing.
+property RESOURCE_MANAGER root ar iw
+property SCREEN_RESOURCES root ar iw
+
+XCOMM Ignore attempts to use cut buffers. Giving errors causes apps to crash,
+XCOMM and allowing access may give away too much information.
+property CUT_BUFFER0 root irw
+property CUT_BUFFER1 root irw
+property CUT_BUFFER2 root irw
+property CUT_BUFFER3 root irw
+property CUT_BUFFER4 root irw
+property CUT_BUFFER5 root irw
+property CUT_BUFFER6 root irw
+property CUT_BUFFER7 root irw
+
+XCOMM If you are using Motif, you probably want these.
+property _MOTIF_DEFAULT_BINDINGS root ar iw
+property _MOTIF_DRAG_WINDOW root ar iw
+property _MOTIF_DRAG_TARGETS any ar iw
+property _MOTIF_DRAG_ATOMS any ar iw
+property _MOTIF_DRAG_ATOM_PAIRS any ar iw
+
+XCOMM The next two rules let xwininfo -tree work when untrusted.
+property WM_NAME any ar
+
+XCOMM Allow read of WM_CLASS, but only for windows with WM_NAME.
+XCOMM This might be more restrictive than necessary, but demonstrates
+XCOMM the <required property> facility, and is also an attempt to
+XCOMM say "top level windows only."
+property WM_CLASS WM_NAME ar
+
+XCOMM These next three let xlsclients work untrusted. Think carefully
+XCOMM before including these; giving away the client machine name and command
+XCOMM may be exposing too much.
+property WM_STATE WM_NAME ar
+property WM_CLIENT_MACHINE WM_NAME ar
+property WM_COMMAND WM_NAME ar
+
+XCOMM To let untrusted clients use the standard colormaps created by
+XCOMM xstdcmap, include these lines.
+property RGB_DEFAULT_MAP root ar
+property RGB_BEST_MAP root ar
+property RGB_RED_MAP root ar
+property RGB_GREEN_MAP root ar
+property RGB_BLUE_MAP root ar
+property RGB_GRAY_MAP root ar
+
+XCOMM To let untrusted clients use the color management database created
+XCOMM by xcmsdb, include these lines.
+property XDCCC_LINEAR_RGB_CORRECTION root ar
+property XDCCC_LINEAR_RGB_MATRICES root ar
+property XDCCC_GRAY_SCREENWHITEPOINT root ar
+property XDCCC_GRAY_CORRECTION root ar
+
+XCOMM To let untrusted clients use the overlay visuals that many vendors
+XCOMM support, include this line.
+property SERVER_OVERLAY_VISUALS root ar
+
+XCOMM Dumb examples to show other capabilities.
+
+XCOMM oddball property names and explicit specification of error conditions
+property "property with spaces" 'property with "' aw er ed
+
+XCOMM Allow deletion of Woo-Hoo if window also has property OhBoy with value
+XCOMM ending in "son". Reads and writes will cause an error.
+property Woo-Hoo OhBoy = "*son" ad
+
+.fi
+.SH "NETWORK CONNECTIONS"
+The X server supports client connections via a platform-dependent subset of
+the following transport types: TCP\/IP, Unix Domain sockets, DECnet,
+and several varieties of SVR4 local connections. See the DISPLAY
+NAMES section of the \fIX\fP(__miscmansuffix__) manual page to learn how to
+specify which transport type clients should try to use.
+.SH GRANTING ACCESS
+The X server implements a platform-dependent subset of the following
+authorization protocols: MIT-MAGIC-COOKIE-1, XDM-AUTHORIZATION-1,
+XDM-AUTHORIZATION-2, SUN-DES-1, and MIT-KERBEROS-5. See the
+\fIXsecurity\fP(__miscmansuffix__) manual page for information on the
+operation of these protocols.
+.PP
+Authorization data required by the above protocols is passed to the
+server in a private file named with the \fB\-auth\fP command line
+option. Each time the server is about to accept the first connection
+after a reset (or when the server is starting), it reads this file.
+If this file contains any authorization records, the local host is not
+automatically allowed access to the server, and only clients which
+send one of the authorization records contained in the file in the
+connection setup information will be allowed access. See the
+\fIXau\fP manual page for a description of the binary format of this
+file. See \fIxauth\fP(1) for maintenance of this file, and distribution
+of its contents to remote hosts.
+.PP
+The X server also uses a host-based access control list for deciding
+whether or not to accept connections from clients on a particular machine.
+If no other authorization mechanism is being used,
+this list initially consists of the host on which the server is running as
+well as any machines listed in the file \fI/etc/X\fBn\fI.hosts\fR, where
+\fBn\fP is the display number of the server. Each line of the file should
+contain either an Internet hostname (e.g. expo.lcs.mit.edu) or a DECnet
+hostname in double colon format (e.g. hydra::) or a complete name in the format
+\fIfamily\fP:\fIname\fP as described in the \fIxhost\fP(1) manual page.
+There should be no leading or trailing spaces on any lines. For example:
+.sp
+.in +8
+.nf
+joesworkstation
+corporate.company.com
+star::
+inet:bigcpu
+local:
+.fi
+.in -8
+.PP
+Users can add or remove hosts from this list and enable or disable access
+control using the \fIxhost\fP command from the same machine as the server.
+.PP
+If the X FireWall Proxy (\fIxfwp\fP) is being used without a sitepolicy,
+host-based authorization must be turned on for clients to be able to
+connect to the X server via the \fIxfwp\fP. If \fIxfwp\fP is run without
+a configuration file and thus no sitepolicy is defined, if \fIxfwp\fP
+is using an X server where xhost + has been run to turn off host-based
+authorization checks, when a client tries to connect to this X server
+via \fIxfwp\fP, the X server will deny the connection. See \fIxfwp\fP(1)
+for more information about this proxy.
+.PP
+The X protocol intrinsically does not have any notion of window operation
+permissions or place any restrictions on what a client can do; if a program can
+connect to a display, it has full run of the screen.
+X servers that support the SECURITY extension fare better because clients
+can be designated untrusted via the authorization they use to connect; see
+the \fIxauth\fP(1) manual page for details. Restrictions are imposed
+on untrusted clients that curtail the mischief they can do. See the SECURITY
+extension specification for a complete list of these restrictions.
+.PP
+Sites that have better
+authentication and authorization systems might wish to make
+use of the hooks in the libraries and the server to provide additional
+security models.
+.SH SIGNALS
+The X server attaches special meaning to the following signals:
+.TP 8
+.I SIGHUP
+This signal causes the server to close all existing connections, free all
+resources, and restore all defaults. It is sent by the display manager
+whenever the main user's main application (usually an \fIxterm\fP or window
+manager) exits to force the server to clean up and prepare for the next
+user.
+.TP 8
+.I SIGTERM
+This signal causes the server to exit cleanly.
+.TP 8
+.I SIGUSR1
+This signal is used quite differently from either of the above. When the
+server starts, it checks to see if it has inherited SIGUSR1 as SIG_IGN
+instead of the usual SIG_DFL. In this case, the server sends a SIGUSR1 to
+its parent process after it has set up the various connection schemes.
+\fIXdm\fP uses this feature to recognize when connecting to the server
+is possible.
+.SH FONTS
+The X server
+can obtain fonts from directories and/or from font servers.
+The list of directories and font servers
+the X server uses when trying to open a font is controlled
+by the \fIfont path\fP.
+.LP
+The default font path is
+__default_font_path__ .
+.LP
+The font path can be set with the \fB\-fp\fP option or by \fIxset\fP(1)
+after the server has started.
+.SH FILES
+.TP 30
+.I /etc/X\fBn\fP.hosts
+Initial access control list for display number \fBn\fP
+.TP 30
+.IR __projectroot__/lib/X11/fonts/misc , __projectroot__/lib/X11/fonts/75dpi , __projectroot__/lib/X11/fonts/100dpi
+Bitmap font directories
+.TP 30
+.IR __projectroot__/lib/X11/fonts/TTF , __projectroot__/lib/X11/fonts/Type1
+Outline font directories
+.TP 30
+.I __projectroot__/lib/X11/rgb.txt
+Color database
+.TP 30
+.I /tmp/.X11-unix/X\fBn\fP
+Unix domain socket for display number \fBn\fP
+.TP 30
+.IR /tmp/rcX\fBn\fP
+Kerberos 5 replay cache for display number \fBn\fP
+.TP 30
+.I /usr/adm/X\fBn\fPmsgs
+Error log file for display number \fBn\fP if run from \fIinit\fP(__adminmansuffix__)
+.TP 30
+.I __projectroot__/lib/X11/xdm/xdm-errors
+Default error log file if the server is run from \fIxdm\fP(1)
+.SH "SEE ALSO"
+General information: \fIX\fP(__miscmansuffix__)
+.PP
+Protocols:
+.I "X Window System Protocol,"
+.I "The X Font Service Protocol,"
+.I "X Display Manager Control Protocol"
+.PP
+Fonts: \fIbdftopcf\fP(1), \fImkfontdir\fP(1), \fImkfontscale\fP(1),
+\fIxfs\fP(1), \fIxlsfonts\fP(1), \fIxfontsel\fP(1), \fIxfd\fP(1),
+.I "X Logical Font Description Conventions"
+.PP
+Security: \fIXsecurity\fP(__miscmansuffix__), \fIxauth\fP(1), \fIXau\fP(1),
+\fIxdm\fP(1), \fIxhost\fP(1), \fIxfwp\fP(1),
+.I "Security Extension Specification"
+.PP
+Starting the server: \fIxdm\fP(1), \fIxinit\fP(1)
+.PP
+Controlling the server once started: \fIxset\fP(1), \fIxsetroot\fP(1),
+\fIxhost\fP(1)
+.PP
+Server-specific man pages:
+\fIXdec\fP(1), \fIXmacII\fP(1), \fIXsun\fP(1), \fIXnest\fP(1),
+\fIXvfb\fP(1), \fIXFree86\fP(1), \fIXDarwin\fP(1).
+.PP
+Server internal documentation:
+.I "Definition of the Porting Layer for the X v11 Sample Server"
+.SH AUTHORS
+The sample server was originally written by Susan Angebranndt, Raymond
+Drewry, Philip Karlton, and Todd Newman, from Digital Equipment
+Corporation, with support from a large cast. It has since been
+extensively rewritten by Keith Packard and Bob Scheifler, from MIT.
+Dave Wiggins took over post-R5 and made substantial improvements.
diff --git a/nx-X11/programs/Xserver/Xvfb.def b/nx-X11/programs/Xserver/Xvfb.def
new file mode 100644
index 000000000..0f3d138b9
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xvfb.def
@@ -0,0 +1,4 @@
+NAME Xvfb WINDOWCOMPAT
+DESCRIPTION "@#XFREE86:4.4.0#@ $XFree86: xc/programs/Xserver/Xvfb.def,v 3.3 2002/05/31 18:45:53 dawes Exp $"
+PROTMODE
+EXETYPE OS2
diff --git a/nx-X11/programs/Xserver/afb/Imakefile b/nx-X11/programs/Xserver/afb/Imakefile
new file mode 100644
index 000000000..340f3ba2e
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/Imakefile
@@ -0,0 +1,67 @@
+XCOMM $XFree86: xc/programs/Xserver/afb/Imakefile,v 3.6 1999/08/14 10:49:26 dawes Exp $
+XCOMM $XConsortium: Imakefile,v 1.38 94/03/11 18:47:47 dpw Exp $
+#define IHaveModules
+#include <Server.tmpl>
+
+#if (defined(XFree86Version) || defined(XorgVersion))
+#if DoLoadableServer
+MODSRC = afbmodule.c
+MODOBJ = afbmodule.o
+#endif
+#endif
+
+SRCS1 = afbgc.c afbwindow.c afbfont.c afbfillrct.c afbpntwin.c afbpixmap.c \
+ afbimage.c afbline.c afbbres.c afbhrzvert.c afbbresd.c afbpushpxl.c \
+ afbzerarc.c afbfillarc.c afbfillsp.c afbsetsp.c afbscrinit.c \
+ afbclip.c afbbitblt.c afbgetsp.c afbpolypnt.c afbbltC.c afbbltX.c \
+ afbbltCI.c afbbltO.c afbbltG.c afbcmap.c afbtileC.c afbtileG.c \
+ afbmisc.c afbbstore.c
+
+SRCS = $(SRCS1) afbseg.c afbbltC.c afbbltX.c afbbltCI.c afbbltO.c afbbltG.c \
+ afbtileC.c afbtileG.c $(MODSRC)
+
+OBJS = afbgc.o afbwindow.o afbfont.o afbpixmap.o afbfillsp.o afbsetsp.o \
+ afbscrinit.o afbclip.o afbbitblt.o afbgetsp.o afbbltC.o afbbltX.o \
+ afbbltCI.o afbbltO.o afbbltG.o afbcmap.o afbimage.o afbzerarc.o \
+ afbfillarc.o afbply1rct.o afbtileC.o afbtileG.o afbfillrct.o \
+ afbpolypnt.o afbmisc.o afbbstore.o afbbresd.o afbimggblt.o \
+ afbpushpxl.o afbplygblt.o afbtegblt.o afbpntwin.o afbpntarea.o \
+ afbbres.o afbhrzvert.o afbline.o afbseg.o $(MODOBJ)
+
+INCLUDES = -I. -I../cfb -I../mfb -I../mi -I../include -I$(XINCLUDESRC) \
+ -I$(FONTINCSRC) $(EXTRAINCLUDES)
+LINTDEFS = -DMFBPOLYGLYPHBLT=afbPolyGlyphBltWhite \
+ -DMFBIMAGEGLYPHBLT=afbImageGlyphBltWhite \
+ -DEQWHOLEWORD=MFB_EQWHOLEWORD_WHITE -DOPEQ=MFB_OPEQ_WHITE
+
+LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln \
+ ../mfb/llib-lmfb.ln ../mi/llib-lmi.ln
+
+ModuleObjectRule()
+LibraryModuleTarget(afb,$(OBJS))
+LintLibraryTarget(afb,$(SRCS1))
+NormalLintTarget($(LINTDEFS) $(SRCS1))
+
+ObjectFromSpecialSource(afbseg,afbline,-DPOLYSEGMENT)
+
+ObjectFromSpecialSource(afbbltC,afbblt,-DMROP=Mcopy)
+
+ObjectFromSpecialSource(afbbltX,afbblt,-DMROP=Mxor)
+
+ObjectFromSpecialSource(afbbltCI,afbblt,-DMROP=McopyInverted)
+
+ObjectFromSpecialSource(afbbltO,afbblt,-DMROP=Mor)
+
+ObjectFromSpecialSource(afbbltG,afbblt,-DMROP=0)
+
+ObjectFromSpecialSource(afbtileC,afbtile,-DMROP=Mcopy)
+
+ObjectFromSpecialSource(afbtileG,afbtile,-DMROP=0)
+
+InstallLibraryModule(afb,$(MODULEDIR),.)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(afb,$(DRIVERSDKMODULEDIR),.)
+
+InstallDriverSDKNonExecFile(afb.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/afb/README b/nx-X11/programs/Xserver/afb/README
new file mode 100644
index 000000000..5c9586013
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/README
@@ -0,0 +1,10 @@
+
+All stuff in this directory is based on Xdaniver (read Xdaniver.doc).
+
+Actually this is the same code as in the ilbm directory, except that here the
+conversion from normal bitplanes to interleaved bitplanes didn't happen.
+
+--
+Geert Uytterhoeven Geert.Uytterhoeven@cs.kuleuven.ac.be
+Wavelets, Linux/m68k on Amiga http://www.cs.kuleuven.ac.be/~geert/
+Department of Computer Science -- Katholieke Universiteit Leuven -- Belgium
diff --git a/nx-X11/programs/Xserver/afb/Xdaniver.doc b/nx-X11/programs/Xserver/afb/Xdaniver.doc
new file mode 100644
index 000000000..1c8ad5ad4
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/Xdaniver.doc
@@ -0,0 +1,218 @@
+
+What is it?
+-----------
+
+Xdaniver is a fast, colour X11R6 server for the Amiga's custom chip set
+under NetBSD 1.0 and NetBSD-current, supporting all the Amiga's display
+depths from 1 to 4 (upto 16 colours) on ECS machines and 1 to 8 (upto 256
+colours) on AGA machines (though, not all resolutions are available, see
+General Information below).
+
+Xdaniver is designed to be a drop-in replacement for the Xmono server provided
+with the X11R6 binary distribution supplied by Bernd Ernesti available from
+ftp.uni-regensburg.de or one of its mirrors.
+
+Unlike previous colour X servers for the Amiga that emulate a chunky pixel
+screen in fast RAM, use the standard frame buffer drivers provided with the
+X11R6 source code to draw and then use a chunky to planar conversion routine
+to write the results to the screen (all very slow), Xdaniver uses a heavily
+modified mono frame buffer driver to draw directly using the Amiga's planar
+format. The net result is much faster drawing and support for all the Amiga's
+custom display depths but, as usual, the fewer planes used, the faster the
+drawing operations of the X server. Even so, on my A1200 with a 33Mhz 68030,
+I'm getting reasonable performance when using 8 bit planes in Dbl NTSC mode.
+
+Installation
+------------
+
+You will need to have first obtained and installed the X11R6 binary
+distribution available from ftp.uni-regensburg.de in
+/pub/NetBSD-Amiga/contrib/X11 or one of its mirrors. Xdaniver has been
+compiled to expect font and configuration files sitting under
+/usr/local/X11R6, if your setup is different you will need to provide a
+symbolic link from /usr/local/X11R6 to where your tree resides or supply
+several command line flags to the server.
+
+To get Xdaniver running as the default X server, copy the uncompressed binary
+into /usr/local/X11R6/bin, remove the current X file from that directory
+(which is a symbolic link to Xmono) and replace it with a link to Xdaniver:
+
+ gzip -d < X11R6.Xdaniver.1.01.tar.gz | tar xvf -
+ mv Xdaniver /usr/local/X11R6/bin
+ cd /usr/local/X11R6/bin
+ rm X
+ ln -s Xdaniver X
+
+Note that on some setups, the devices /dev/kbd, /dev/mouse and /dev/view??
+have been created to be accessable only by superuser; Xdaniver needs to open
+these devices. To workaround this problem, log on as superuser and then
+either make Xdaniver setuid root:
+
+ chown root Xdaniver
+ chmod 4755 Xdaniver
+
+or give everyone access the devices:
+
+ chmod 666 /dev/kbd /dev/mouse /dev/view??
+
+the latter option is a possible cause of a security hole if your machine is
+ever used multi-user.
+
+General Information
+-------------------
+
+The default resolution of the server is 700x430 and the default depth 4. AGA
+users might what to increase the display depth by editing the startx script
+and providing a -depth <depth> argument to Xdaniver on the xinit line of the
+script. As always, the lower the depth, the faster the drawing and window
+manipulation of the server.
+
+The resolution can be altered similarly by suppling -width <width> and
+-height <height> arguments to the server.
+
+The NetBSD kernel selects actual screen modes by picking a mode who's
+natural, non-overscanned size best-fits the requested resolution.
+Unfortunately, for AGA users, the 1.0 kernel only has support for the
+Dbl-NTSC AGA display mode and only this mode has support for depths greater
+than 4. The NetBSD-current (work-in-progress) kernel also has support for
+Dbl-PAL but still no support for the Super72 or other super-hires modes
+(perhaps some kind, kernel-hacker could add support for them ?).
+
+If you have a 2 button mouse (like me) you might want to try and use the 3
+button mouse emulation. On other systems, it is usual for the left and right
+buttons to be provided and emulate the middle button by pressing both
+buttons together, however, the middle button is tends to be used more than
+the right button so I have provided two options:
+
+-emulateright (or -3), the two physical mouse buttons act as left and middle
+and pressing them both together emulates the right button.
+
+-emulatemiddle (or -2), the two physical mouse buttons act as left and right
+and pressing them both together emulated the middle button.
+
+When using screen depths of less than 6 (4 is the maximum for ECS machines)
+the lack of possible colours on screen at once causes problems for many X
+applications. Specifying -cc 2 as a command line argument to Xdaniver
+causes the server to switch the default visual type from PsuedoColor to
+StaticColor; to put it simply, the server prefills the colormap with a
+selection of 16 colours (depth 4) and when an application asks for a
+particular colour, its gets allocated one that is closest to one from the
+selection of 16. This removes the 'WARNING: Cannot allocate colormap entry
+for "XXX"' errors but at the expense of applications not being able to get
+the precise colour they wanted. Also, some badly written X applications fail
+altogether when presented with a StaticColor visual.
+
+Bugs/Limitations
+----------------
+
+The limited choice of display resolutions for AGA/ECS machines is a real
+pain - requires a kernel change to fix. Worse still, the kernel specifies
+the maximum overscan resolution on the Dbl-NTSC to be 724x482 but selecting
+anything more than 702x430 on my machine causes the screen either sheer
+diagonally (as if the bytes per row calculation in Xdaniver or the kernel is
+wrong) or completely loose sync (suggesting a custom chip register sync
+calculation bug). As other, non-aga modes aren't affected when selection
+overscan both problems seem to point to a kernel driver bug. Also, depths
+greater than 4 for AGA users are only supported by the kernel in the Dbl-NTSC
+mode (and Dbl-PAL with the current-NetBSD kernel).
+
+I know of one bug so-far (there will be more), The PutImage request of an XY
+format image expects the bitplane order to be the reverse of that specified
+in the X protocol but since virtually all applications use the Z (chunky)
+format, you are unlikely to come across this problem.
+
+The PutImage request of Z format images is a little slow - when I have time
+I'll try and add one of the fast assembly chunky-to-planar routines developed
+for doom style games/demos. Unfortunately, the current crop all require a
+picture size that is a multiple of 32 pixels and so cannot be used out-of-the-
+box.
+
+Some extra performance could easily be squeezed out of the terminal font
+drawing code (used by xterm) - when I have time I'll add the code.
+
+The Amiga's blitter and sprites are totally unused and will remain so
+until/if someone else adds support to the kernel. The blitter would help
+speed up screen scrolling and window manipulation and sprite support could
+be used for the X pointer shape (if small enough) which would speed up all
+drawing operations (no need to remove the software based pointer shape
+first, draw, then replace the pointer shape).
+
+I removed the X image extension (XIE) from the X server as it increased the
+size of the binary by some 400k. I haven't come across any applications that
+need it yet (I haven't been looking!) so if you need the extension for some
+reason send me e-mail and I'll build a server with the extension included.
+
+The 3 button mouse emulation is very simple - to emulate the 3rd button you
+have to press both button precisely at the same moment - I've got quite good
+at it now. When I have some spare time I'll add a timer so you will have a
+few milli-seconds between one button being pressed and the next and it still
+being registered as the emulated button.
+
+AGA users don't forget to provide the -A flag to loadbsd to enable the one
+AGA mode in the 1.0 kernel but only if you have a VGA, multisync or dual-scan
+monitor, of course !
+
+Xdaniver has been tested on:
+
+A1200, 33Mhz 68030, 8Mb RAM and NetBSD 1.0 by myself.
+A4000/40, 12Mb RAM and NetBSD 1.0 by Andreas Holzhammer.
+A3000, 12Mb RAM and NetBSD 1.0 by Charlie Root, Stuart Park and others.
+A3000, 25Mhz 68040, 18Mb RAM and NetBSD-current by Michael K. Sanders.
+A2000, 8Mb RAM and NetBSD (version unknown) by Hubert Feyrer.
+
+Release and Bug Fix History
+---------------------------
+
+1.0 - First release
+
+1.01 Bugs fixed:
+ - Narrow (<32 pixels) Z format GetImage requests corrupted the stack
+ and could cause the server to core dump. (Xpaint caused this problem)
+ - Drawing dots (PolyPoint request) into a clipped window caused a
+ c pointer to go out of range, causing a core dump (xv showed this
+ problem).
+
+ New features:
+ - Simple 3 button mouse emulation using a 2 button mouse; specify
+ -emulate_middle (or -2) or -emulate_right (or -3) on the server's
+ command line and press both mouse buttons together emulate the 'missing'
+ button.
+ - Basic beep sound support added by sending bell characters to the
+ console.
+ - Source code released.
+
+Disclaimer and Copyright Notices
+--------------------------------
+
+Multi-depth planar frame buffer code:
+Copyright (c) 1995 by Daniver Limited.
+
+Large portions:
+Copyright (c) 1994 by Eduardo Horvath.
+Copyright (c) 1987-1995 by the Regents of the University of California.
+Copyright (c) 1987 by Sun Microsystems, Inc. Mountain View, CA.
+Copyright (c) 1987-1995 by X Consortium.
+Copyright (c) 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
+Copyright (c) 1989 Network Computing Devices, Inc., Mountain View, California.
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted, provided
+that the above copyright notice appear in all copies. The Daniver Limited,
+the above companies and individuals makes no representations about the
+suitability of this software for any purpose. It is provided "as is" without
+express or implied warranty.
+
+Credits
+-------
+
+Thanks to Bernd Ernesti for making the operating system server source code
+available for others to use and Eduardo Horvath and Andy Heffernan, who (I
+think) did the original Xmono server port.
+
+Also, many thanks to the first brave users who tested Xdaniver for me on other
+Amiga setups and found a few bugs in the process.
+
+Gary Henderson.
+
+Daytime: garyh@wet.sbi.com
+Home: gary@daniver.demon.co.uk
diff --git a/nx-X11/programs/Xserver/afb/afb.h b/nx-X11/programs/Xserver/afb/afb.h
new file mode 100644
index 000000000..708fe7643
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afb.h
@@ -0,0 +1,1132 @@
+/* $XFree86: xc/programs/Xserver/afb/afb.h,v 3.10 2003/10/29 22:15:19 tsi Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afb.h,v 5.31 94/04/17 20:28:15 dpw Exp $ */
+/* Monochrome Frame Buffer definitions
+ written by drewry, september 1986
+*/
+
+#include "pixmap.h"
+#include "region.h"
+#include "gc.h"
+#include "colormap.h"
+#include "regionstr.h"
+#include "mibstore.h"
+#include "mfb.h"
+
+extern int afbInverseAlu[];
+extern int afbScreenPrivateIndex;
+/* warning: PixelType definition duplicated in maskbits.h */
+#ifndef PixelType
+#define PixelType CARD32
+#endif /* PixelType */
+
+#define AFB_MAX_DEPTH 8
+
+/* afbbitblt.c */
+
+extern void afbDoBitblt(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+
+extern RegionPtr afbBitBlt(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ GCPtr /*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ void (*doBitBlt)(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+ ),
+ unsigned long /*planemask*/
+);
+
+extern RegionPtr afbCopyArea(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr/*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/
+);
+
+extern RegionPtr afbCopyPlane(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr/*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ unsigned long /*plane*/
+);
+
+extern void afbCopy1ToN(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* afbbltC.c */
+
+extern void afbDoBitbltCopy(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* afbbltCI.c */
+
+extern void afbDoBitbltCopyInverted(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* afbbltG.c */
+
+extern void afbDoBitbltGeneral(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* afbbltO.c */
+
+extern void afbDoBitbltOr(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* afbbltX.c */
+
+extern void afbDoBitbltXor(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* afbbres.c */
+
+extern void afbBresS(
+ PixelType * /*addrl*/,
+ int /*nlwidth*/,
+ int /*sizeDst*/,
+ int /*depthDst*/,
+ int /*signdx*/,
+ int /*signdy*/,
+ int /*axis*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*e*/,
+ int /*e1*/,
+ int /*e2*/,
+ int /*len*/,
+ unsigned char * /*rrops*/
+);
+/* afbbresd.c */
+
+extern void afbBresD(
+ int * /*pdashIndex*/,
+ unsigned char * /*pDash*/,
+ int /*numInDashList*/,
+ int * /*pdashOffset*/,
+ int /*isDoubleDash*/,
+ PixelType * /*addrl*/,
+ int /*nlwidth*/,
+ int /*sizeDst*/,
+ int /*depthDst*/,
+ int /*signdx*/,
+ int /*signdy*/,
+ int /*axis*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*e*/,
+ int /*e1*/,
+ int /*e2*/,
+ int /*len*/,
+ unsigned char * /*rrops*/,
+ unsigned char * /*bgrrops*/
+);
+/* afbbstore.c */
+
+extern void afbSaveAreas(
+ PixmapPtr /*pPixmap*/,
+ RegionPtr /*prgnSave*/,
+ int /*xorg*/,
+ int /*yorg*/,
+ WindowPtr /*pWin*/
+);
+
+extern void afbRestoreAreas(
+ PixmapPtr /*pPixmap*/,
+ RegionPtr /*prgnRestore*/,
+ int /*xorg*/,
+ int /*yorg*/,
+ WindowPtr /*pWin*/
+);
+/* afbclip.c */
+
+extern RegionPtr afbPixmapToRegion(
+ PixmapPtr /*pPix*/
+);
+
+/* afbcmap.c */
+
+extern int afbListInstalledColormaps(
+ ScreenPtr /*pScreen*/,
+ Colormap * /*pmaps*/
+);
+
+extern void afbInstallColormap(
+ ColormapPtr /*pmap*/
+);
+
+extern void afbUninstallColormap(
+ ColormapPtr /*pmap*/
+);
+
+extern void afbResolveColor(
+ unsigned short * /*pred*/,
+ unsigned short * /*pgreen*/,
+ unsigned short * /*pblue*/,
+ VisualPtr /*pVisual*/
+);
+
+extern Bool afbInitializeColormap(
+ ColormapPtr /*pmap*/
+);
+
+extern int afbExpandDirectColors(
+ ColormapPtr /*pmap*/,
+ int /*ndefs*/,
+ xColorItem * /*indefs*/,
+ xColorItem * /*outdefs*/
+);
+
+extern Bool afbCreateDefColormap(
+ ScreenPtr /*pScreen*/
+);
+
+extern Bool afbSetVisualTypes(
+ int /*depth*/,
+ int /*visuals*/,
+ int /*bitsPerRGB*/
+);
+
+extern Bool afbInitVisuals(
+ VisualPtr * /*visualp*/,
+ DepthPtr * /*depthp*/,
+ int * /*nvisualp*/,
+ int * /*ndepthp*/,
+ int * /*rootDepthp*/,
+ VisualID * /*defaultVisp*/,
+ unsigned long /*sizes*/,
+ int /*bitsPerRGB*/
+);
+
+/* afbfillarc.c */
+
+extern void afbPolyFillArcSolid(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+/* afbfillrct.c */
+
+extern void afbPolyFillRect(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nrectFill*/,
+ xRectangle * /*prectInit*/
+);
+
+/* afbply1rct.c */
+extern void afbFillPolygonSolid(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*shape*/,
+ int /*count*/,
+ DDXPointPtr /*ptsIn*/
+);
+
+/* afbfillsp.c */
+
+extern void afbSolidFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void afbStippleFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void afbTileFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void afbUnnaturalTileFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void afbUnnaturalStippleFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void afbOpaqueStippleFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void afbUnnaturalOpaqueStippleFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+/* afbfont.c */
+
+extern Bool afbRealizeFont(
+ ScreenPtr /*pscr*/,
+ FontPtr /*pFont*/
+);
+
+extern Bool afbUnrealizeFont(
+ ScreenPtr /*pscr*/,
+ FontPtr /*pFont*/
+);
+/* afbgc.c */
+
+extern Bool afbCreateGC(
+ GCPtr /*pGC*/
+);
+
+extern void afbValidateGC(
+ GCPtr /*pGC*/,
+ unsigned long /*changes*/,
+ DrawablePtr /*pDrawable*/
+);
+
+extern void afbDestroyGC(
+ GCPtr /*pGC*/
+);
+
+extern void afbReduceRop(
+ int /*alu*/,
+ Pixel /*src*/,
+ unsigned long /*planemask*/,
+ int /*depth*/,
+ unsigned char * /*rrops*/
+);
+
+extern void afbReduceOpaqueStipple (
+ Pixel /*fg*/,
+ Pixel /*bg*/,
+ unsigned long /*planemask*/,
+ int /*depth*/,
+ unsigned char * /*rrops*/
+);
+
+extern void afbComputeCompositeClip(
+ GCPtr /*pGC*/,
+ DrawablePtr /*pDrawable*/
+);
+
+/* afbgetsp.c */
+
+extern void afbGetSpans(
+ DrawablePtr /*pDrawable*/,
+ int /*wMax*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ int /*nspans*/,
+ char * /*pdstStart*/
+);
+/* afbhrzvert.c */
+
+extern void afbHorzS(
+ PixelType * /*addrl*/,
+ int /*nlwidth*/,
+ int /*sizeDst*/,
+ int /*depthDst*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*len*/,
+ unsigned char * /*rrops*/
+);
+
+extern void afbVertS(
+ PixelType * /*addrl*/,
+ int /*nlwidth*/,
+ int /*sizeDst*/,
+ int /*depthDst*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*len*/,
+ unsigned char * /*rrops*/
+);
+/* afbigbblak.c */
+
+extern void afbImageGlyphBlt (
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* afbigbwht.c */
+
+/* afbimage.c */
+
+extern void afbPutImage(
+ DrawablePtr /*dst*/,
+ GCPtr /*pGC*/,
+ int /*depth*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ int /*leftPad*/,
+ int /*format*/,
+ char * /*pImage*/
+);
+
+extern void afbGetImage(
+ DrawablePtr /*pDrawable*/,
+ int /*sx*/,
+ int /*sy*/,
+ int /*w*/,
+ int /*h*/,
+ unsigned int /*format*/,
+ unsigned long /*planeMask*/,
+ char * /*pdstLine*/
+);
+/* afbline.c */
+
+extern void afbLineSS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/
+);
+
+extern void afbLineSD(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/
+);
+
+/* afbmisc.c */
+
+extern void afbQueryBestSize(
+ int /*class*/,
+ unsigned short * /*pwidth*/,
+ unsigned short * /*pheight*/,
+ ScreenPtr /*pScreen*/
+);
+/* afbpntarea.c */
+
+extern void afbSolidFillArea(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ unsigned char * /*rrops*/
+);
+
+extern void afbStippleAreaPPW(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ PixmapPtr /*pstipple*/,
+ unsigned char * /*rrops*/
+);
+extern void afbStippleArea(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ PixmapPtr /*pstipple*/,
+ int /*xOff*/,
+ int /*yOff*/,
+ unsigned char * /*rrops*/
+);
+/* afbplygblt.c */
+
+extern void afbPolyGlyphBlt(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+
+/* afbpixmap.c */
+
+extern PixmapPtr afbCreatePixmap(
+ ScreenPtr /*pScreen*/,
+ int /*width*/,
+ int /*height*/,
+ int /*depth*/
+);
+
+extern Bool afbDestroyPixmap(
+ PixmapPtr /*pPixmap*/
+);
+
+extern PixmapPtr afbCopyPixmap(
+ PixmapPtr /*pSrc*/
+);
+
+extern void afbPadPixmap(
+ PixmapPtr /*pPixmap*/
+);
+
+extern void afbXRotatePixmap(
+ PixmapPtr /*pPix*/,
+ int /*rw*/
+);
+
+extern void afbYRotatePixmap(
+ PixmapPtr /*pPix*/,
+ int /*rh*/
+);
+
+extern void afbCopyRotatePixmap(
+ PixmapPtr /*psrcPix*/,
+ PixmapPtr * /*ppdstPix*/,
+ int /*xrot*/,
+ int /*yrot*/
+);
+extern void afbPaintWindow(
+ WindowPtr /*pWin*/,
+ RegionPtr /*pRegion*/,
+ int /*what*/
+);
+/* afbpolypnt.c */
+
+extern void afbPolyPoint(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ xPoint * /*pptInit*/
+);
+/* afbpushpxl.c */
+
+extern void afbPushPixels(
+ GCPtr /*pGC*/,
+ PixmapPtr /*pBitMap*/,
+ DrawablePtr /*pDrawable*/,
+ int /*dx*/,
+ int /*dy*/,
+ int /*xOrg*/,
+ int /*yOrg*/
+);
+/* afbscrclse.c */
+
+extern Bool afbCloseScreen(
+ int /*index*/,
+ ScreenPtr /*pScreen*/
+);
+/* afbscrinit.c */
+
+extern Bool afbAllocatePrivates(
+ ScreenPtr /*pScreen*/,
+ int * /*pWinIndex*/,
+ int * /*pGCIndex*/
+);
+
+extern Bool afbScreenInit(
+ ScreenPtr /*pScreen*/,
+ pointer /*pbits*/,
+ int /*xsize*/,
+ int /*ysize*/,
+ int /*dpix*/,
+ int /*dpiy*/,
+ int /*width*/
+);
+
+extern PixmapPtr afbGetWindowPixmap(
+ WindowPtr /*pWin*/
+);
+
+extern void afbSetWindowPixmap(
+ WindowPtr /*pWin*/,
+ PixmapPtr /*pPix*/
+);
+
+/* afbseg.c */
+
+extern void afbSegmentSS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSeg*/
+);
+
+extern void afbSegmentSD(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSeg*/
+);
+/* afbsetsp.c */
+
+extern void afbSetScanline(
+ int /*y*/,
+ int /*xOrigin*/,
+ int /*xStart*/,
+ int /*xEnd*/,
+ PixelType * /*psrc*/,
+ int /*alu*/,
+ PixelType * /*pdstBase*/,
+ int /*widthDst*/,
+ int /*sizeDst*/,
+ int /*depthDst*/,
+ int /*sizeSrc*/
+);
+
+extern void afbSetSpans(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ char * /*psrc*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ int /*nspans*/,
+ int /*fSorted*/
+);
+/* afbtegblt.c */
+
+extern void afbTEGlyphBlt(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* afbtileC.c */
+
+extern void afbTileAreaPPWCopy(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/,
+ unsigned long /*planemask*/
+);
+/* afbtileG.c */
+
+extern void afbTileAreaPPWGeneral(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/,
+ unsigned long /*planemask*/
+);
+
+extern void afbTileAreaCopy(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/,
+ int /*xOff*/,
+ int /*yOff*/,
+ unsigned long /*planemask*/
+);
+/* afbtileG.c */
+
+extern void afbTileAreaGeneral(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/,
+ int /*xOff*/,
+ int /*yOff*/,
+ unsigned long /*planemask*/
+);
+
+extern void afbOpaqueStippleAreaPPWCopy(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/,
+ unsigned char */*rropsOS*/,
+ unsigned long /*planemask*/
+);
+/* afbtileG.c */
+
+extern void afbOpaqueStippleAreaPPWGeneral(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/,
+ unsigned char */*rropsOS*/,
+ unsigned long /*planemask*/
+);
+
+extern void afbOpaqueStippleAreaCopy(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/,
+ int /*xOff*/,
+ int /*yOff*/,
+ unsigned char */*rropsOS*/,
+ unsigned long /*planemask*/
+);
+/* afbtileG.c */
+
+extern void afbOpaqueStippleAreaGeneral(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/,
+ int /*xOff*/,
+ int /*yOff*/,
+ unsigned char */*rropsOS*/,
+ unsigned long /*planemask*/
+);
+
+/* afbwindow.c */
+
+extern Bool afbCreateWindow(
+ WindowPtr /*pWin*/
+);
+
+extern Bool afbDestroyWindow(
+ WindowPtr /*pWin*/
+);
+
+extern Bool afbMapWindow(
+ WindowPtr /*pWindow*/
+);
+
+extern Bool afbPositionWindow(
+ WindowPtr /*pWin*/,
+ int /*x*/,
+ int /*y*/
+);
+
+extern Bool afbUnmapWindow(
+ WindowPtr /*pWindow*/
+);
+
+extern void afbCopyWindow(
+ WindowPtr /*pWin*/,
+ DDXPointRec /*ptOldOrg*/,
+ RegionPtr /*prgnSrc*/
+);
+
+extern Bool afbChangeWindowAttributes(
+ WindowPtr /*pWin*/,
+ unsigned long /*mask*/
+);
+/* afbzerarc.c */
+
+extern void afbZeroPolyArcSS(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+
+/*
+ private field of pixmap
+ pixmap.devPrivate = (PixelType *)pointer_to_bits
+ pixmap.devKind = width_of_pixmap_in_bytes
+
+ private field of screen
+ a pixmap, for which we allocate storage. devPrivate is a pointer to
+the bits in the hardware framebuffer. note that devKind can be poked to
+make the code work for framebuffers that are wider than their
+displayable screen (e.g. the early vsII, which displayed 960 pixels
+across, but was 1024 in the hardware.)
+
+ private field of GC
+*/
+
+typedef struct {
+ unsigned char rrops[AFB_MAX_DEPTH]; /* reduction of rasterop to 1 of 3 */
+ unsigned char rropOS[AFB_MAX_DEPTH]; /* rop for opaque stipple */
+} afbPrivGC;
+typedef afbPrivGC *afbPrivGCPtr;
+
+extern int afbGCPrivateIndex; /* index into GC private array */
+extern int afbWindowPrivateIndex; /* index into Window private array */
+#ifdef PIXMAP_PER_WINDOW
+extern int frameWindowPrivateIndex; /* index into Window private array */
+#endif
+
+#define afbGetGCPrivate(pGC) \
+ ((afbPrivGC *)((pGC)->devPrivates[afbGCPrivateIndex].ptr))
+
+/* private field of window */
+typedef struct {
+ unsigned char fastBorder; /* non-zero if border tile is 32 bits wide */
+ unsigned char fastBackground;
+ unsigned short unused; /* pad for alignment with Sun compiler */
+ DDXPointRec oldRotate;
+ PixmapPtr pRotatedBackground;
+ PixmapPtr pRotatedBorder;
+} afbPrivWin;
+
+/* Common macros for extracting drawing information */
+
+#define afbGetTypedWidth(pDrawable,wtype)( \
+ (((pDrawable)->type == DRAWABLE_WINDOW) ? \
+ (int)(((PixmapPtr)((pDrawable)->pScreen->devPrivates[afbScreenPrivateIndex].ptr))->devKind) : \
+ (int)(((PixmapPtr)pDrawable)->devKind)) / sizeof (wtype))
+
+#define afbGetByteWidth(pDrawable) afbGetTypedWidth(pDrawable, unsigned char)
+
+#define afbGetPixelWidth(pDrawable) afbGetTypedWidth(pDrawable, PixelType)
+
+#define afbGetTypedWidthAndPointer(pDrawable, width, pointer, wtype, ptype) {\
+ PixmapPtr _pPix; \
+ if ((pDrawable)->type == DRAWABLE_WINDOW) \
+ _pPix = (PixmapPtr)(pDrawable)->pScreen->devPrivates[afbScreenPrivateIndex].ptr; \
+ else \
+ _pPix = (PixmapPtr)(pDrawable); \
+ (pointer) = (ptype *) _pPix->devPrivate.ptr; \
+ (width) = ((int) _pPix->devKind) / sizeof (wtype); \
+}
+
+#define afbGetPixelWidthSizeDepthAndPointer(pDrawable, width, size, dep, pointer) {\
+ PixmapPtr _pPix; \
+ if ((pDrawable)->type == DRAWABLE_WINDOW) \
+ _pPix = (PixmapPtr)(pDrawable)->pScreen->devPrivates[afbScreenPrivateIndex].ptr; \
+ else \
+ _pPix = (PixmapPtr)(pDrawable); \
+ (pointer) = (PixelType *)_pPix->devPrivate.ptr; \
+ (width) = ((int)_pPix->devKind) / sizeof (PixelType); \
+ (size) = (width) * _pPix->drawable.height; \
+ (dep) = _pPix->drawable.depth; (void)(dep); \
+}
+
+#define afbGetByteWidthAndPointer(pDrawable, width, pointer) \
+ afbGetTypedWidthAndPointer(pDrawable, width, pointer, unsigned char, unsigned char)
+
+#define afbGetPixelWidthAndPointer(pDrawable, width, pointer) \
+ afbGetTypedWidthAndPointer(pDrawable, width, pointer, PixelType, PixelType)
+
+#define afbGetWindowTypedWidthAndPointer(pWin, width, pointer, wtype, ptype) {\
+ PixmapPtr _pPix = (PixmapPtr)(pWin)->drawable.pScreen->devPrivates[afbScreenPrivateIndex].ptr; \
+ (pointer) = (ptype *) _pPix->devPrivate.ptr; \
+ (width) = ((int) _pPix->devKind) / sizeof (wtype); \
+}
+
+#define afbGetWindowPixelWidthAndPointer(pWin, width, pointer) \
+ afbGetWindowTypedWidthAndPointer(pWin, width, pointer, PixelType, PixelType)
+
+#define afbGetWindowByteWidthAndPointer(pWin, width, pointer) \
+ afbGetWindowTypedWidthAndPointer(pWin, width, pointer, char, char)
+
+/* afb uses the following macros to calculate addresses in drawables.
+ * To support banked framebuffers, the macros come in four flavors.
+ * All four collapse into the same definition on unbanked devices.
+ *
+ * afbScanlineFoo - calculate address and do bank switching
+ * afbScanlineFooNoBankSwitch - calculate address, don't bank switch
+ * afbScanlineFooSrc - calculate address, switch source bank
+ * afbScanlineFooDst - calculate address, switch destination bank
+ */
+
+/* The NoBankSwitch versions are the same for banked and unbanked cases */
+
+#define afbScanlineIncNoBankSwitch(_ptr, _off) _ptr += (_off)
+#define afbScanlineOffsetNoBankSwitch(_ptr, _off) ((_ptr) + (_off))
+#define afbScanlineDeltaNoBankSwitch(_ptr, _y, _w) \
+ afbScanlineOffsetNoBankSwitch(_ptr, (_y) * (_w))
+#define afbScanlineNoBankSwitch(_ptr, _x, _y, _w) \
+ afbScanlineOffsetNoBankSwitch(_ptr, (_y) * (_w) + ((_x) >> MFB_PWSH))
+
+#ifdef MFB_LINE_BANK
+
+#include "afblinebank.h" /* get macro definitions from this file */
+
+#else /* !MFB_LINE_BANK - unbanked case */
+
+#define afbScanlineInc(_ptr, _off) afbScanlineIncNoBankSwitch(_ptr, _off)
+#define afbScanlineIncSrc(_ptr, _off) afbScanlineInc(_ptr, _off)
+#define afbScanlineIncDst(_ptr, _off) afbScanlineInc(_ptr, _off)
+
+#define afbScanlineOffset(_ptr, _off) afbScanlineOffsetNoBankSwitch(_ptr, _off)
+#define afbScanlineOffsetSrc(_ptr, _off) afbScanlineOffset(_ptr, _off)
+#define afbScanlineOffsetDst(_ptr, _off) afbScanlineOffset(_ptr, _off)
+
+#define afbScanlineSrc(_ptr, _x, _y, _w) afbScanline(_ptr, _x, _y, _w)
+#define afbScanlineDst(_ptr, _x, _y, _w) afbScanline(_ptr, _x, _y, _w)
+
+#define afbScanlineDeltaSrc(_ptr, _y, _w) afbScanlineDelta(_ptr, _y, _w)
+#define afbScanlineDeltaDst(_ptr, _y, _w) afbScanlineDelta(_ptr, _y, _w)
+
+#endif /* MFB_LINE_BANK */
+
+#define afbScanlineDelta(_ptr, _y, _w) \
+ afbScanlineOffset(_ptr, (_y) * (_w))
+
+#define afbScanline(_ptr, _x, _y, _w) \
+ afbScanlineOffset(_ptr, (_y) * (_w) + ((_x) >> MFB_PWSH))
+
+/* precomputed information about each glyph for GlyphBlt code.
+ this saves recalculating the per glyph information for each box.
+*/
+
+typedef struct _afbpos{
+ int xpos; /* xposition of glyph's origin */
+ int xchar; /* x position mod 32 */
+ int leftEdge;
+ int rightEdge;
+ int topEdge;
+ int bottomEdge;
+ PixelType *pdstBase; /* longword with character origin */
+ int widthGlyph; /* width in bytes of this glyph */
+} afbTEXTPOS;
+
+/* reduced raster ops for afb */
+#define RROP_BLACK GXclear
+#define RROP_WHITE GXset
+#define RROP_NOP GXnoop
+#define RROP_INVERT GXinvert
+#define RROP_COPY GXcopy
+
+/* macros for afbbitblt.c, afbfillsp.c
+ these let the code do one switch on the rop per call, rather
+ than a switch on the rop per item (span or rectangle.)
+*/
+
+#define fnCLEAR(src, dst) (0)
+#define fnAND(src, dst) (src & dst)
+#define fnANDREVERSE(src, dst) (src & ~dst)
+#define fnCOPY(src, dst) (src)
+#define fnANDINVERTED(src, dst) (~src & dst)
+#define fnNOOP(src, dst) (dst)
+#define fnXOR(src, dst) (src ^ dst)
+#define fnOR(src, dst) (src | dst)
+#define fnNOR(src, dst) (~(src | dst))
+#define fnEQUIV(src, dst) (~src ^ dst)
+#define fnINVERT(src, dst) (~dst)
+#define fnORREVERSE(src, dst) (src | ~dst)
+#define fnCOPYINVERTED(src, dst) (~src)
+#define fnORINVERTED(src, dst) (~src | dst)
+#define fnNAND(src, dst) (~(src & dst))
+#undef fnSET
+#define fnSET(src, dst) (~0)
+
+/* Using a "switch" statement is much faster in most cases
+ * since the compiler can do a look-up table or multi-way branch
+ * instruction, depending on the architecture. The result on
+ * A Sun 3/50 is at least 2.5 times faster, assuming a uniform
+ * distribution of RasterOp operation types.
+ *
+ * However, doing some profiling on a running system reveals
+ * GXcopy is the operation over 99.5% of the time and
+ * GXxor is the next most frequent (about .4%), so we make special
+ * checks for those first.
+ *
+ * Note that this requires a change to the "calling sequence"
+ * since we can't engineer a "switch" statement to have an lvalue.
+ */
+#undef DoRop
+#define DoRop(result, alu, src, dst) \
+{ \
+ if (alu == GXcopy) \
+ result = fnCOPY (src, dst); \
+ else if (alu == GXxor) \
+ result = fnXOR (src, dst); \
+ else \
+ switch (alu) { \
+ case GXclear: \
+ result = fnCLEAR (src, dst); \
+ break; \
+ case GXand: \
+ result = fnAND (src, dst); \
+ break; \
+ case GXandReverse: \
+ result = fnANDREVERSE (src, dst); \
+ break; \
+ case GXandInverted: \
+ result = fnANDINVERTED (src, dst); \
+ break; \
+ default: \
+ case GXnoop: \
+ result = fnNOOP (src, dst); \
+ break; \
+ case GXor: \
+ result = fnOR (src, dst); \
+ break; \
+ case GXnor: \
+ result = fnNOR (src, dst); \
+ break; \
+ case GXequiv: \
+ result = fnEQUIV (src, dst); \
+ break; \
+ case GXinvert: \
+ result = fnINVERT (src, dst); \
+ break; \
+ case GXorReverse: \
+ result = fnORREVERSE (src, dst); \
+ break; \
+ case GXcopyInverted: \
+ result = fnCOPYINVERTED (src, dst); \
+ break; \
+ case GXorInverted: \
+ result = fnORINVERTED (src, dst); \
+ break; \
+ case GXnand: \
+ result = fnNAND (src, dst); \
+ break; \
+ case GXset: \
+ result = fnSET (src, dst); \
+ break; \
+ } \
+}
+
+
+/* C expression fragments for various operations. These get passed in
+ * as -D's on the compile command line. See afb/Imakefile. This
+ * fixes XBUG 6319.
+ *
+ * This seems like a good place to point out that afb's use of the
+ * words black and white is an unfortunate misnomer. In afb code, black
+ * means zero, and white means one.
+ */
+#define MFB_OPEQ_WHITE |=
+#define MFB_OPEQ_BLACK &=~
+#define MFB_OPEQ_INVERT ^=
+#define MFB_EQWHOLEWORD_WHITE =~0
+#define MFB_EQWHOLEWORD_BLACK =0
+#define MFB_EQWHOLEWORD_INVERT ^=~0
+#define MFB_OP_WHITE /* nothing */
+#define MFB_OP_BLACK ~
+
+#ifdef XFree86LOADER
+#include "xf86_ansic.h"
+#endif
+
diff --git a/nx-X11/programs/Xserver/afb/afbbitblt.c b/nx-X11/programs/Xserver/afb/afbbitblt.c
new file mode 100644
index 000000000..0c1c6bb9f
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbbitblt.c
@@ -0,0 +1,477 @@
+/* $XFree86: xc/programs/Xserver/afb/afbbitblt.c,v 3.5tsi Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbbitblt.c,v 5.25 94/04/17 20:28:16 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "mi.h"
+
+#include "afb.h"
+#include "maskbits.h"
+
+
+static unsigned char afbRropsOS[AFB_MAX_DEPTH];
+
+/* CopyArea and CopyPlane for a monchrome frame buffer
+
+
+ clip the source rectangle to the source's available bits. (this
+avoids copying unnecessary pieces that will just get exposed anyway.)
+this becomes the new shape of the destination.
+ clip the destination region to the composite clip in the
+GC. this requires translating the destination region to (dstx, dsty).
+ build a list of source points, one for each rectangle in the
+destination. this is a simple translation.
+ go do the multiple rectangle copies
+ do graphics exposures
+*/
+/** Optimized for drawing pixmaps into windows, especially when drawing into
+ ** unobscured windows. Calls to the general-purpose region code were
+ ** replaced with rectangle-to-rectangle clipping comparisions. This is
+ ** possible, since the pixmap is a single rectangle. In an unobscured
+ ** window, the destination clip is also a single rectangle, and region
+ ** code can be avoided entirely. This is a big savings, since the region
+ ** code uses XAlloc() and makes many function calls.
+ **
+ ** In addition, if source is a pixmap, there is no need to call the
+ ** expensive miHandleExposures() routine. Instead, we simply return NULL.
+ **
+ ** Previously, drawing a pixmap into an unobscured window executed at least
+ ** 8 XAlloc()'s, 30 function calls, and hundreds of lines of code.
+ **
+ ** Now, the same operation requires no XAlloc()'s, no region function calls,
+ ** and much less overhead. Nice for drawing lots of small pixmaps.
+ */
+
+void
+afbDoBitblt(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
+ DrawablePtr pSrc, pDst;
+ int alu;
+ RegionPtr prgnDst;
+ DDXPointPtr pptSrc;
+ unsigned long planemask;
+{
+ switch (alu) {
+ case GXcopy:
+ afbDoBitbltCopy(pSrc, pDst, alu, prgnDst, pptSrc, planemask);
+ break;
+ case GXxor:
+ afbDoBitbltXor(pSrc, pDst, alu, prgnDst, pptSrc, planemask);
+ break;
+ case GXcopyInverted:
+ afbDoBitbltCopyInverted(pSrc, pDst, alu, prgnDst, pptSrc, planemask);
+ break;
+ case GXor:
+ afbDoBitbltOr(pSrc, pDst, alu, prgnDst, pptSrc, planemask);
+ break;
+ default:
+ afbDoBitbltGeneral(pSrc, pDst, alu, prgnDst, pptSrc, planemask);
+ break;
+ }
+}
+
+RegionPtr
+afbCopyArea(pSrcDrawable, pDstDrawable, pGC, srcx, srcy, width, height,
+ dstx, dsty)
+ DrawablePtr pSrcDrawable;
+ DrawablePtr pDstDrawable;
+ GC *pGC;
+ int srcx, srcy;
+ int width, height;
+ int dstx, dsty;
+{
+ void (*doBitBlt)();
+
+ switch (pGC->alu) {
+ case GXcopy:
+ doBitBlt = afbDoBitbltCopy;
+ break;
+ case GXxor:
+ doBitBlt = afbDoBitbltXor;
+ break;
+ case GXcopyInverted:
+ doBitBlt = afbDoBitbltCopyInverted;
+ break;
+ case GXor:
+ doBitBlt = afbDoBitbltOr;
+ break;
+ default:
+ doBitBlt = afbDoBitbltGeneral;
+ break;
+ }
+
+ return(afbBitBlt(pSrcDrawable, pDstDrawable, pGC, srcx, srcy,
+ width, height, dstx, dsty, doBitBlt, pGC->planemask));
+}
+
+RegionPtr
+afbBitBlt(pSrcDrawable, pDstDrawable, pGC, srcx, srcy, width, height,
+ dstx, dsty, doBitBlt, planemask)
+ register DrawablePtr pSrcDrawable;
+ register DrawablePtr pDstDrawable;
+ register GC *pGC;
+ int srcx, srcy;
+ int width, height;
+ int dstx, dsty;
+ void (*doBitBlt)();
+ unsigned long planemask;
+{
+ RegionPtr prgnSrcClip = NULL; /* may be a new region, or just a copy */
+ Bool freeSrcClip = FALSE;
+
+ RegionPtr prgnExposed;
+ RegionRec rgnDst;
+ DDXPointPtr pptSrc;
+ register DDXPointPtr ppt;
+ register BoxPtr pbox;
+ int i;
+ register int dx;
+ register int dy;
+ xRectangle origSource;
+ DDXPointRec origDest;
+ int numRects;
+ BoxRec fastBox;
+ int fastClip = 0; /* for fast clipping with pixmap source */
+ int fastExpose = 0; /* for fast exposures with pixmap source */
+
+ origSource.x = srcx;
+ origSource.y = srcy;
+ origSource.width = width;
+ origSource.height = height;
+ origDest.x = dstx;
+ origDest.y = dsty;
+
+ if ((pSrcDrawable != pDstDrawable) && pSrcDrawable->pScreen->SourceValidate)
+ (*pSrcDrawable->pScreen->SourceValidate)(pSrcDrawable, srcx, srcy, width,
+ height);
+
+ srcx += pSrcDrawable->x;
+ srcy += pSrcDrawable->y;
+
+ /* clip the source */
+
+ if (pSrcDrawable->type == DRAWABLE_PIXMAP)
+ if ((pSrcDrawable == pDstDrawable) && (pGC->clientClipType == CT_NONE))
+ prgnSrcClip = pGC->pCompositeClip;
+ else
+ fastClip = 1;
+ else if (pGC->subWindowMode == IncludeInferiors)
+ if (!((WindowPtr)pSrcDrawable)->parent)
+ /*
+ * special case bitblt from root window in
+ * IncludeInferiors mode; just like from a pixmap
+ */
+ fastClip = 1;
+ else if ((pSrcDrawable == pDstDrawable) && (pGC->clientClipType == CT_NONE))
+ prgnSrcClip = pGC->pCompositeClip;
+ else {
+ prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable);
+ freeSrcClip = TRUE;
+ }
+ else
+ prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList;
+
+ fastBox.x1 = srcx;
+ fastBox.y1 = srcy;
+ fastBox.x2 = srcx + width;
+ fastBox.y2 = srcy + height;
+
+ /* Don't create a source region if we are doing a fast clip */
+ if (fastClip) {
+ fastExpose = 1;
+ /*
+ * clip the source; if regions extend beyond the source size,
+ * make sure exposure events get sent
+ */
+ if (fastBox.x1 < pSrcDrawable->x) {
+ fastBox.x1 = pSrcDrawable->x;
+ fastExpose = 0;
+ }
+ if (fastBox.y1 < pSrcDrawable->y) {
+ fastBox.y1 = pSrcDrawable->y;
+ fastExpose = 0;
+ }
+ if (fastBox.x2 > pSrcDrawable->x + (int)pSrcDrawable->width) {
+ fastBox.x2 = pSrcDrawable->x + (int)pSrcDrawable->width;
+ fastExpose = 0;
+ }
+ if (fastBox.y2 > pSrcDrawable->y + (int)pSrcDrawable->height) {
+ fastBox.y2 = pSrcDrawable->y + (int)pSrcDrawable->height;
+ fastExpose = 0;
+ }
+ } else {
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip);
+ }
+
+ dstx += pDstDrawable->x;
+ dsty += pDstDrawable->y;
+
+ if (pDstDrawable->type == DRAWABLE_WINDOW)
+ if (!((WindowPtr)pDstDrawable)->realized) {
+ if (!fastClip)
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return NULL;
+ }
+
+ dx = srcx - dstx;
+ dy = srcy - dsty;
+
+ /* Translate and clip the dst to the destination composite clip */
+ if (fastClip) {
+ RegionPtr cclip;
+
+ /* Translate the region directly */
+ fastBox.x1 -= dx;
+ fastBox.x2 -= dx;
+ fastBox.y1 -= dy;
+ fastBox.y2 -= dy;
+
+ /* If the destination composite clip is one rectangle we can
+ do the clip directly. Otherwise we have to create a full
+ blown region and call intersect */
+ cclip = pGC->pCompositeClip;
+ if (REGION_NUM_RECTS(cclip) == 1) {
+ BoxPtr pBox = REGION_RECTS(cclip);
+
+ if (fastBox.x1 < pBox->x1)
+ fastBox.x1 = pBox->x1;
+ if (fastBox.x2 > pBox->x2)
+ fastBox.x2 = pBox->x2;
+ if (fastBox.y1 < pBox->y1)
+ fastBox.y1 = pBox->y1;
+ if (fastBox.y2 > pBox->y2)
+ fastBox.y2 = pBox->y2;
+
+ /* Check to see if the region is empty */
+ if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2) {
+ REGION_NULL(pGC->pScreen, &rgnDst);
+ } else {
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ }
+ } else {
+ /* We must turn off fastClip now, since we must create
+ a full blown region. It is intersected with the
+ composite clip below. */
+ fastClip = 0;
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox,1);
+ }
+ } else
+ REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy);
+
+ if (!fastClip) {
+ REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst,
+ pGC->pCompositeClip);
+ }
+
+ /* Do bit blitting */
+ numRects = REGION_NUM_RECTS(&rgnDst);
+ if (numRects && width && height) {
+ if(!(pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(numRects *
+ sizeof(DDXPointRec)))) {
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return NULL;
+ }
+ pbox = REGION_RECTS(&rgnDst);
+ ppt = pptSrc;
+ for (i = numRects; --i >= 0; pbox++, ppt++) {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ (*doBitBlt)(pSrcDrawable, pDstDrawable, pGC->alu, &rgnDst, pptSrc,
+ planemask);
+
+ DEALLOCATE_LOCAL(pptSrc);
+ }
+
+ prgnExposed = NULL;
+ if (pGC->fExpose) {
+ /* Pixmap sources generate a NoExposed (we return NULL to do this) */
+ if (!fastExpose)
+ prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
+ origSource.x, origSource.y,
+ (int)origSource.width,
+ (int)origSource.height, origDest.x,
+ origDest.y, (unsigned long)0);
+ }
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return prgnExposed;
+}
+
+RegionPtr
+afbCopyPlane(pSrcDrawable, pDstDrawable, pGC, srcx, srcy, width, height,
+ dstx, dsty, plane)
+DrawablePtr pSrcDrawable, pDstDrawable;
+register GC *pGC;
+int srcx, srcy;
+int width, height;
+int dstx, dsty;
+unsigned long plane;
+{
+ int alu;
+ RegionPtr prgnExposed = NULL;
+ unsigned long old_planemask;
+
+ if (pDstDrawable->depth == 1) {
+ old_planemask = pGC->planemask;
+ pGC->planemask = plane;
+ if ((pGC->fgPixel & 1) == 1 && (pGC->bgPixel & 1) == 0) {
+ prgnExposed = (*pGC->ops->CopyArea)(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+ } else if ((pGC->fgPixel & 1) == (pGC->bgPixel & 1)) {
+ unsigned char rop;
+
+ afbReduceRop(pGC->alu, pGC->fgPixel, 1, 1, &rop);
+ alu = pGC->alu;
+ pGC->alu = rop;
+ prgnExposed = (*pGC->ops->CopyArea)(pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height, dstx,
+ dsty);
+ pGC->alu = alu;
+ } else { /* need to invert the src */
+ alu = pGC->alu;
+ pGC->alu = afbInverseAlu[alu];
+ prgnExposed = (*pGC->ops->CopyArea)(pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height, dstx,
+ dsty);
+ pGC->alu = alu;
+ }
+ pGC->planemask = old_planemask;
+ } else {
+ int free_pixmap = FALSE;
+ PixmapPtr pBitmap = (PixmapPtr)pSrcDrawable;
+ ScreenPtr pScreen = pSrcDrawable->pScreen;
+ GCPtr pGC1 = NULL;
+
+ if (pSrcDrawable == pDstDrawable ||
+ pSrcDrawable->type == DRAWABLE_WINDOW || pSrcDrawable->depth != 1) {
+ /* Copy a plane from source drawable to a tmp 1-bit deep pixmap */
+ /* XXX: Range check width and height */
+ pBitmap = (*pScreen->CreatePixmap)(pScreen, width, height, 1);
+
+ if (!pBitmap)
+ return(NULL);
+ pGC1 = GetScratchGC(1, pScreen);
+ if (!pGC1) {
+ (*pScreen->DestroyPixmap)(pBitmap);
+ return(NULL);
+ }
+ ValidateGC((DrawablePtr)pBitmap, pGC1);
+ (void)afbBitBlt(pSrcDrawable, (DrawablePtr)pBitmap, pGC1, srcx, srcy,
+ width, height, 0, 0, afbDoBitbltCopy, plane);
+ free_pixmap = TRUE;
+ }
+#if 0
+ else {
+ /* XXX: could cope with N-deep pixmap source case without using tmp
+ * src bitmap by setting up a scratch pixmap header and fiddle
+ * around with the pbits pointer.
+ */
+ }
+#endif
+ afbReduceOpaqueStipple(pGC->fgPixel, pGC->bgPixel, pGC->planemask,
+ pGC->depth, afbRropsOS);
+ (void)afbBitBlt((DrawablePtr)pBitmap, pDstDrawable, pGC, 0, 0, width,
+ height, dstx, dsty, afbCopy1ToN, pGC->planemask);
+ if (free_pixmap) {
+ (*pScreen->DestroyPixmap)(pBitmap);
+ FreeScratchGC(pGC1);
+ }
+
+ if (pGC->fExpose)
+ prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC, srcx,
+ srcy, width, height, dstx, dsty,
+ plane);
+ }
+ return prgnExposed;
+}
+
+void
+afbCopy1ToN(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
+ DrawablePtr pSrc, pDst;
+ int alu;
+ RegionPtr prgnDst;
+ DDXPointPtr pptSrc;
+ unsigned long planemask;
+{
+ int numRects = REGION_NUM_RECTS(prgnDst);
+ BoxPtr pbox = REGION_RECTS(prgnDst);
+ int r;
+
+ for (r = 0; r < numRects; r++, pbox++, pptSrc++) {
+ int dx = pptSrc->x;
+ int dy = pptSrc->y;
+
+ if (alu == GXcopy)
+ afbOpaqueStippleAreaCopy(pDst, 1, pbox, alu, (PixmapPtr)pSrc, dx, dy,
+ afbRropsOS, planemask);
+ else
+ afbOpaqueStippleAreaGeneral(pDst, 1, pbox, alu, (PixmapPtr)pSrc, dx,
+ dy, afbRropsOS, planemask);
+ }
+}
diff --git a/nx-X11/programs/Xserver/afb/afbblt.c b/nx-X11/programs/Xserver/afb/afbblt.c
new file mode 100644
index 000000000..6cbb0a878
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbblt.c
@@ -0,0 +1,563 @@
+/* $XFree86: xc/programs/Xserver/afb/afbblt.c,v 3.0 1996/08/18 01:45:24 dawes Exp $ */
+/*
+ * afb copy area
+ */
+
+/*
+
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+Author: Keith Packard
+
+*/
+/* $XConsortium: afbblt.c,v 1.11 94/04/17 20:28:16 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "afb.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "maskbits.h"
+#include "fastblt.h"
+#include "mergerop.h"
+
+void
+MROP_NAME(afbDoBitblt)(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
+ DrawablePtr pSrc, pDst;
+ int alu;
+ RegionPtr prgnDst;
+ DDXPointPtr pptSrc;
+ unsigned long planemask;
+{
+ PixelType *psrcBase, *pdstBase; /* start of src and dst bitmaps */
+ int widthSrc, widthDst; /* add to get to same position in next line */
+ int sizeSrc, sizeDst;
+
+ BoxPtr pbox;
+ int nbox;
+
+ BoxPtr pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2;
+ /* temporaries for shuffling rectangles */
+ DDXPointPtr pptTmp, pptNew1, pptNew2;
+ /* shuffling boxes entails shuffling the
+ source points too */
+ int w, h;
+ int xdir; /* 1 = left right, -1 = right left/ */
+ int ydir; /* 1 = top down, -1 = bottom up */
+
+ PixelType *psrcLine, *pdstLine;
+ /* pointers to line with current src and dst */
+ register PixelType *psrc; /* pointer to current src longword */
+ register PixelType *pdst; /* pointer to current dst longword */
+
+ MROP_DECLARE_REG()
+
+ /* following used for looping through a line */
+ PixelType startmask, endmask; /* masks for writing ends of dst */
+ int nlMiddle; /* whole longwords in dst */
+ int xoffSrc, xoffDst;
+ register int leftShift, rightShift;
+ register PixelType bits;
+ register PixelType bits1;
+ register int nl; /* temp copy of nlMiddle */
+
+ int careful;
+ int depthSrc;
+ int depthDst;
+
+ MROP_INITIALIZE(alu,0);
+
+ afbGetPixelWidthSizeDepthAndPointer(pSrc, widthSrc, sizeSrc, depthSrc,
+ psrcBase);
+ afbGetPixelWidthSizeDepthAndPointer(pDst, widthDst, sizeDst, depthDst,
+ pdstBase);
+
+ /* Special case where depth of dest pixmap is 1 but source pixmap isn't
+ * Used for GetImage to copy a plane from a source pixmap to a particular
+ * dest pixmap plane.
+ * Note: planemask should have only one bit set or several planes from
+ * the source will be copied to the same dest plane.
+ */
+ if (depthDst == 1 && depthDst != depthSrc)
+ sizeDst = 0;
+
+ /* XXX we have to err on the side of safety when both are windows,
+ * because we don't know if IncludeInferiors is being used.
+ */
+ careful = ((pSrc == pDst) ||
+ ((pSrc->type == DRAWABLE_WINDOW) &&
+ (pDst->type == DRAWABLE_WINDOW)));
+
+ pbox = REGION_RECTS(prgnDst);
+ nbox = REGION_NUM_RECTS(prgnDst);
+
+ pboxNew1 = NULL;
+ pptNew1 = NULL;
+ pboxNew2 = NULL;
+ pptNew2 = NULL;
+ if (careful && (pptSrc->y < pbox->y1)) {
+ /* walk source botttom to top */
+ ydir = -1;
+ widthSrc = -widthSrc;
+ widthDst = -widthDst;
+
+ if (nbox > 1) {
+ /* keep ordering in each band, reverse order of bands */
+ pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec)*nbox);
+ if(!pboxNew1)
+ return;
+ pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec)*nbox);
+ if(!pptNew1) {
+ DEALLOCATE_LOCAL(pboxNew1);
+ return;
+ }
+ pboxBase = pboxNext = pbox+nbox-1;
+ while (pboxBase >= pbox) {
+ while ((pboxNext >= pbox) &&
+ (pboxBase->y1 == pboxNext->y1))
+ pboxNext--;
+ pboxTmp = pboxNext+1;
+ pptTmp = pptSrc + (pboxTmp - pbox);
+ while (pboxTmp <= pboxBase) {
+ *pboxNew1++ = *pboxTmp++;
+ *pptNew1++ = *pptTmp++;
+ }
+ pboxBase = pboxNext;
+ }
+ pboxNew1 -= nbox;
+ pbox = pboxNew1;
+ pptNew1 -= nbox;
+ pptSrc = pptNew1;
+ }
+ } else {
+ /* walk source top to bottom */
+ ydir = 1;
+ }
+
+ if (careful && (pptSrc->x < pbox->x1)) {
+ /* walk source right to left */
+ xdir = -1;
+
+ if (nbox > 1) {
+ /* reverse order of rects in each band */
+ pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
+ pptNew2 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox);
+ if(!pboxNew2 || !pptNew2) {
+ if (pptNew2)
+ DEALLOCATE_LOCAL(pptNew2);
+ if (pboxNew2)
+ DEALLOCATE_LOCAL(pboxNew2);
+ if (pboxNew1) {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(pboxNew1);
+ }
+ return;
+ }
+ pboxBase = pboxNext = pbox;
+ while (pboxBase < pbox+nbox) {
+ while ((pboxNext < pbox+nbox) && (pboxNext->y1 == pboxBase->y1))
+ pboxNext++;
+ pboxTmp = pboxNext;
+ pptTmp = pptSrc + (pboxTmp - pbox);
+ while (pboxTmp != pboxBase) {
+ *pboxNew2++ = *--pboxTmp;
+ *pptNew2++ = *--pptTmp;
+ }
+ pboxBase = pboxNext;
+ }
+ pboxNew2 -= nbox;
+ pbox = pboxNew2;
+ pptNew2 -= nbox;
+ pptSrc = pptNew2;
+ }
+ } else {
+ /* walk source left to right */
+ xdir = 1;
+ }
+
+ while(nbox--) {
+ int d;
+ for (d = 0; d < depthSrc; d++) {
+ PixelType *psrcB;
+ PixelType *pdstB;
+
+ if (!(planemask & (1 << d)))
+ continue;
+
+ psrcB = psrcBase + sizeSrc * d; /* @@@ NEXT PLANE @@@ */
+ pdstB = pdstBase + sizeDst * d; /* @@@ NEXT PLANE @@@ */
+
+ w = pbox->x2 - pbox->x1;
+ h = pbox->y2 - pbox->y1;
+
+ if (ydir == -1) { /* start at last scanline of rectangle */
+ psrcLine = afbScanlineDeltaSrc(psrcB, -(pptSrc->y+h-1), widthSrc);
+ pdstLine = afbScanlineDeltaDst(pdstB, -(pbox->y2-1), widthDst);
+ } else { /* start at first scanline */
+ psrcLine = afbScanlineDeltaSrc(psrcB, pptSrc->y, widthSrc);
+ pdstLine = afbScanlineDeltaDst(pdstB, pbox->y1, widthDst);
+ }
+ if ((pbox->x1 & PIM) + w <= PPW) {
+ maskpartialbits (pbox->x1, w, startmask);
+ endmask = 0;
+ nlMiddle = 0;
+ } else {
+ maskbits(pbox->x1, w, startmask, endmask, nlMiddle);
+ }
+ if (xdir == 1) {
+ xoffSrc = pptSrc->x & PIM;
+ xoffDst = pbox->x1 & PIM;
+ pdstLine += (pbox->x1 >> PWSH);
+ psrcLine += (pptSrc->x >> PWSH);
+#ifdef DO_UNALIGNED_BITBLT
+ nl = xoffSrc - xoffDst;
+ psrcLine = (PixelType *)(((unsigned char *) psrcLine) + nl);
+#else
+ if (xoffSrc == xoffDst)
+#endif
+ {
+ while (h--) {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ if (startmask) {
+ *pdst = MROP_MASK(*psrc, *pdst, startmask);
+ psrc++;
+ pdst++;
+ }
+ nl = nlMiddle;
+
+#ifdef LARGE_INSTRUCTION_CACHE
+#ifdef FAST_CONSTANT_OFFSET_MODE
+
+ psrc += nl & (UNROLL-1);
+ pdst += nl & (UNROLL-1);
+
+#define BodyOdd(n) pdst[-n] = MROP_SOLID (psrc[-n], pdst[-n]);
+#define BodyEven(n) pdst[-n] = MROP_SOLID (psrc[-n], pdst[-n]);
+
+#define LoopReset \
+pdst += UNROLL; \
+psrc += UNROLL;
+
+#else
+
+#define BodyOdd(n) *pdst = MROP_SOLID (*psrc, *pdst); pdst++; psrc++;
+#define BodyEven(n) BodyOdd(n)
+
+#define LoopReset ;
+
+#endif
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+#ifdef NOTDEF
+ /* you'd think this would be faster --
+ * a single instruction instead of 6
+ * but measurements show it to be ~15% slower
+ */
+ while ((nl -= 6) >= 0) {
+ asm ("moveml %1+,#0x0c0f;moveml#0x0c0f,%0"
+ : "=m" (*(char *)pdst)
+ : "m" (*(char *)psrc)
+ : "d0", "d1", "d2", "d3",
+ "a2", "a3");
+ pdst += 6;
+ }
+ nl += 6;
+ while (nl--)
+ *pdst++ = *psrc++;
+#endif
+ DuffL(nl, label1,
+ *pdst = MROP_SOLID (*psrc, *pdst);
+ pdst++; psrc++;)
+#endif
+
+ if (endmask)
+ *pdst = MROP_MASK(*psrc, *pdst, endmask);
+ afbScanlineIncDst(pdstLine, widthDst);
+ afbScanlineIncSrc(psrcLine, widthSrc);
+ }
+ }
+#ifndef DO_UNALIGNED_BITBLT
+ else {
+ if (xoffSrc > xoffDst) {
+ leftShift = (xoffSrc - xoffDst);
+ rightShift = PPW - leftShift;
+ } else {
+ rightShift = (xoffDst - xoffSrc);
+ leftShift = PPW - rightShift;
+ }
+ while (h--) {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ bits = 0;
+ if (xoffSrc > xoffDst)
+ bits = *psrc++;
+ if (startmask) {
+ bits1 = BitLeft(bits,leftShift);
+ bits = *psrc++;
+ bits1 |= BitRight(bits,rightShift);
+ *pdst = MROP_MASK(bits1, *pdst, startmask);
+ pdst++;
+ }
+ nl = nlMiddle;
+
+#ifdef LARGE_INSTRUCTION_CACHE
+ bits1 = bits;
+
+#ifdef FAST_CONSTANT_OFFSET_MODE
+
+ psrc += nl & (UNROLL-1);
+ pdst += nl & (UNROLL-1);
+
+#define BodyOdd(n) \
+bits = psrc[-n]; \
+pdst[-n] = MROP_SOLID(BitLeft(bits1, leftShift) | BitRight(bits, rightShift), pdst[-n]);
+
+#define BodyEven(n) \
+bits1 = psrc[-n]; \
+pdst[-n] = MROP_SOLID(BitLeft(bits, leftShift) | BitRight(bits1, rightShift), pdst[-n]);
+
+#define LoopReset \
+pdst += UNROLL; \
+psrc += UNROLL;
+
+#else
+
+#define BodyOdd(n) \
+bits = *psrc++; \
+*pdst = MROP_SOLID(BitLeft(bits1, leftShift) | BitRight(bits, rightShift), *pdst); \
+pdst++;
+
+#define BodyEven(n) \
+bits1 = *psrc++; \
+*pdst = MROP_SOLID(BitLeft(bits, leftShift) | BitRight(bits1, rightShift), *pdst); \
+pdst++;
+
+#define LoopReset ;
+
+#endif /* !FAST_CONSTANT_OFFSET_MODE */
+
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+ DuffL(nl,label2,
+ bits1 = BitLeft(bits, leftShift);
+ bits = *psrc++;
+ *pdst = MROP_SOLID (bits1 | BitRight(bits, rightShift), *pdst);
+ pdst++;
+ )
+#endif
+
+ if (endmask) {
+ bits1 = BitLeft(bits, leftShift);
+ if (BitLeft(endmask, rightShift)) {
+ bits = *psrc;
+ bits1 |= BitRight(bits, rightShift);
+ }
+ *pdst = MROP_MASK (bits1, *pdst, endmask);
+ }
+ afbScanlineIncDst(pdstLine, widthDst);
+ afbScanlineIncSrc(psrcLine, widthSrc);
+ }
+ }
+#endif /* DO_UNALIGNED_BITBLT */
+ } else { /* xdir == -1 */
+ xoffSrc = (pptSrc->x + w - 1) & PIM;
+ xoffDst = (pbox->x2 - 1) & PIM;
+ pdstLine += ((pbox->x2-1) >> PWSH) + 1;
+ psrcLine += ((pptSrc->x+w - 1) >> PWSH) + 1;
+#ifdef DO_UNALIGNED_BITBLT
+ nl = xoffSrc - xoffDst;
+ psrcLine = (PixelType *)
+ (((unsigned char *) psrcLine) + nl);
+#else
+ if (xoffSrc == xoffDst)
+#endif
+ {
+ while (h--) {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ if (endmask) {
+ pdst--;
+ psrc--;
+ *pdst = MROP_MASK (*psrc, *pdst, endmask);
+ }
+ nl = nlMiddle;
+
+#ifdef LARGE_INSTRUCTION_CACHE
+#ifdef FAST_CONSTANT_OFFSET_MODE
+ psrc -= nl & (UNROLL - 1);
+ pdst -= nl & (UNROLL - 1);
+
+#define BodyOdd(n) pdst[n-1] = MROP_SOLID (psrc[n-1], pdst[n-1]);
+
+#define BodyEven(n) BodyOdd(n)
+
+#define LoopReset \
+pdst -= UNROLL;\
+psrc -= UNROLL;
+
+#else
+
+#define BodyOdd(n) --pdst; --psrc; *pdst = MROP_SOLID(*psrc, *pdst);
+#define BodyEven(n) BodyOdd(n)
+#define LoopReset ;
+
+#endif
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+ DuffL(nl,label3,
+ --pdst; --psrc; *pdst = MROP_SOLID (*psrc, *pdst);)
+#endif
+
+ if (startmask) {
+ --pdst;
+ --psrc;
+ *pdst = MROP_MASK(*psrc, *pdst, startmask);
+ }
+ afbScanlineIncDst(pdstLine, widthDst);
+ afbScanlineIncSrc(psrcLine, widthSrc);
+ }
+ }
+#ifndef DO_UNALIGNED_BITBLT
+ else {
+ if (xoffDst > xoffSrc) {
+ rightShift = (xoffDst - xoffSrc);
+ leftShift = PPW - rightShift;
+ } else {
+ leftShift = (xoffSrc - xoffDst);
+ rightShift = PPW - leftShift;
+ }
+ while (h--) {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ bits = 0;
+ if (xoffDst > xoffSrc)
+ bits = *--psrc;
+ if (endmask) {
+ bits1 = BitRight(bits, rightShift);
+ bits = *--psrc;
+ bits1 |= BitLeft(bits, leftShift);
+ pdst--;
+ *pdst = MROP_MASK(bits1, *pdst, endmask);
+ }
+ nl = nlMiddle;
+
+#ifdef LARGE_INSTRUCTION_CACHE
+ bits1 = bits;
+#ifdef FAST_CONSTANT_OFFSET_MODE
+ psrc -= nl & (UNROLL - 1);
+ pdst -= nl & (UNROLL - 1);
+
+#define BodyOdd(n) \
+bits = psrc[n-1]; \
+pdst[n-1] = MROP_SOLID(BitRight(bits1, rightShift) | BitLeft(bits, leftShift),pdst[n-1]);
+
+#define BodyEven(n) \
+bits1 = psrc[n-1]; \
+pdst[n-1] = MROP_SOLID(BitRight(bits, rightShift) | BitLeft(bits1, leftShift),pdst[n-1]);
+
+#define LoopReset \
+pdst -= UNROLL; \
+psrc -= UNROLL;
+
+#else
+
+#define BodyOdd(n) \
+bits = *--psrc; --pdst; \
+*pdst = MROP_SOLID(BitRight(bits1, rightShift) | BitLeft(bits, leftShift),*pdst);
+
+#define BodyEven(n) \
+bits1 = *--psrc; --pdst; \
+*pdst = MROP_SOLID(BitRight(bits, rightShift) | BitLeft(bits1, leftShift),*pdst);
+
+#define LoopReset ;
+
+#endif
+
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+ DuffL(nl, label4,
+ bits1 = BitRight(bits, rightShift);
+ bits = *--psrc;
+ --pdst;
+ *pdst = MROP_SOLID(bits1 | BitLeft(bits, leftShift),*pdst);
+ )
+#endif
+
+ if (startmask) {
+ bits1 = BitRight(bits, rightShift);
+ if (BitRight (startmask, leftShift)) {
+ bits = *--psrc;
+ bits1 |= BitLeft(bits, leftShift);
+ }
+ --pdst;
+ *pdst = MROP_MASK(bits1, *pdst, startmask);
+ }
+ afbScanlineIncDst(pdstLine, widthDst);
+ afbScanlineIncSrc(psrcLine, widthSrc);
+ }
+ }
+#endif
+ }
+ }
+ pbox++;
+ pptSrc++;
+ }
+ if (pboxNew2) {
+ DEALLOCATE_LOCAL(pptNew2);
+ DEALLOCATE_LOCAL(pboxNew2);
+ }
+ if (pboxNew1) {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(pboxNew1);
+ }
+}
diff --git a/nx-X11/programs/Xserver/afb/afbbres.c b/nx-X11/programs/Xserver/afb/afbbres.c
new file mode 100644
index 000000000..6ee09b9e4
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbbres.c
@@ -0,0 +1,325 @@
+/* $XFree86$ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbbres.c,v 1.22 94/04/17 20:28:17 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "afb.h"
+#include "maskbits.h"
+#include "miline.h"
+
+/* Solid bresenham line */
+/* NOTES
+ e2 is used less often than e1, so it's not in a register
+*/
+
+void
+afbBresS(addrlbase, nlwidth, sizeDst, depthDst, signdx, signdy, axis, x1, y1,
+ e, e1, e2, len, rrops)
+PixelType *addrlbase; /* pointer to base of bitmap */
+int nlwidth; /* width in longwords of bitmap */
+int sizeDst;
+int depthDst;
+int signdx, signdy; /* signs of directions */
+int axis; /* major axis (Y_AXIS or X_AXIS) */
+int x1, y1; /* initial point */
+register int e; /* error accumulator */
+register int e1; /* bresenham increments */
+int e2;
+int len; /* length of line */
+unsigned char *rrops;
+{
+ register int yinc; /* increment to next scanline, in bytes */
+ register PixelType *addrl; /* bitmask long pointer */
+ register PixelType bit; /* current bit being set/cleared/etc. */
+ PixelType leftbit = mfbGetmask(0); /* leftmost bit to process in new word */
+ PixelType rightbit = mfbGetmask(PPW-1); /* rightmost bit to process in new word */
+
+ register int e3 = e2-e1;
+ PixelType tmp;
+ int saveE;
+ int saveLen;
+ int d;
+
+ /* point to longword containing first point */
+ yinc = signdy * nlwidth;
+ e = e-e1; /* to make looping easier */
+
+ if (!len)
+ return;
+
+ saveLen = len;
+ saveE = e;
+
+ for (d = 0; d < depthDst; d++) {
+ addrl = afbScanline(addrlbase, x1, y1, nlwidth);
+ addrlbase += sizeDst; /* @@@ NEXT PLANE @@@ */
+ len = saveLen;
+ e = saveE;
+ bit = mfbGetmask(x1 & PIM);
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ if (axis == X_AXIS) {
+ if (signdx > 0) {
+ tmp = *addrl;
+ for (;;) {
+ tmp &= ~bit;
+ if (!--len)
+ break;
+ bit = SCRRIGHT(bit,1);
+ e += e1;
+ if (e >= 0) {
+ *addrl = tmp;
+ afbScanlineInc(addrl, yinc);
+ e += e3;
+ if (!bit) {
+ bit = leftbit;
+ addrl ++;
+ }
+ tmp = *addrl;
+ } else if (!bit) {
+ *addrl = tmp;
+ bit = leftbit;
+ addrl ++;
+ tmp = *addrl;
+ }
+ }
+ *addrl = tmp;
+ } else {
+ tmp = *addrl;
+ for (;;) {
+ tmp &= ~bit;
+ if (!--len)
+ break;
+ e += e1;
+ bit = SCRLEFT(bit,1);
+ if (e >= 0) {
+ *addrl = tmp;
+ afbScanlineInc(addrl, yinc);
+ e += e3;
+ if (!bit) {
+ bit = rightbit;
+ addrl --;
+ }
+ tmp = *addrl;
+ } else if (!bit) {
+ *addrl = tmp;
+ bit = rightbit;
+ addrl --;
+ tmp = *addrl;
+ }
+ }
+ *addrl = tmp;
+ }
+ } /* if X_AXIS */ else {
+ if (signdx > 0) {
+ while(len--) {
+ *addrl &= ~bit;
+ e += e1;
+ if (e >= 0) {
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ e += e3;
+ }
+ afbScanlineInc(addrl, yinc);
+ }
+ } else {
+ while(len--) {
+ *addrl &= ~bit;
+ e += e1;
+ if (e >= 0) {
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit;addrl --; }
+ e += e3;
+ }
+ afbScanlineInc(addrl, yinc);
+ }
+ }
+ } /* else Y_AXIS */
+ break;
+
+ case RROP_WHITE:
+ if (axis == X_AXIS) {
+ if (signdx > 0) {
+ tmp = *addrl;
+ for (;;) {
+ tmp |= bit;
+ if (!--len)
+ break;
+ e += e1;
+ bit = SCRRIGHT(bit,1);
+ if (e >= 0) {
+ *addrl = tmp;
+ afbScanlineInc(addrl, yinc);
+ e += e3;
+ if (!bit) {
+ bit = leftbit;
+ addrl ++;
+ }
+ tmp = *addrl;
+ } else if (!bit) {
+ *addrl = tmp;
+ bit = leftbit;
+ addrl ++;
+ tmp = *addrl;
+ }
+ }
+ *addrl = tmp;
+ } else {
+ tmp = *addrl;
+ for (;;) {
+ tmp |= bit;
+ if (!--len)
+ break;
+ e += e1;
+ bit = SCRLEFT(bit,1);
+ if (e >= 0) {
+ *addrl = tmp;
+ afbScanlineInc(addrl, yinc);
+ e += e3;
+ if (!bit) {
+ bit = rightbit;
+ addrl --;
+ }
+ tmp = *addrl;
+ } else if (!bit) {
+ *addrl = tmp;
+ bit = rightbit;
+ addrl --;
+ tmp = *addrl;
+ }
+ }
+ *addrl = tmp;
+ }
+ } /* if X_AXIS */ else {
+ if (signdx > 0) {
+ while(len--) {
+ *addrl |= bit;
+ e += e1;
+ if (e >= 0) {
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ e += e3;
+ }
+ afbScanlineInc(addrl, yinc);
+ }
+ } else {
+ while(len--) {
+ *addrl |= bit;
+ e += e1;
+ if (e >= 0) {
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit;addrl --; }
+ e += e3;
+ }
+ afbScanlineInc(addrl, yinc);
+ }
+ }
+ } /* else Y_AXIS */
+ break;
+
+ case RROP_INVERT:
+ if (axis == X_AXIS) {
+ if (signdx > 0) {
+ while(len--) {
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0) {
+ afbScanlineInc(addrl, yinc);
+ e += e3;
+ }
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ }
+ } else {
+ while(len--) {
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0) {
+ afbScanlineInc(addrl, yinc);
+ e += e3;
+ }
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit;addrl --; }
+ }
+ }
+ } /* if X_AXIS */ else {
+ if (signdx > 0) {
+ while(len--) {
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0) {
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ e += e3;
+ }
+ afbScanlineInc(addrl, yinc);
+ }
+ } else {
+ while(len--) {
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0) {
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit; addrl --; }
+ e += e3;
+ }
+ afbScanlineInc(addrl, yinc);
+ }
+ }
+ } /* else Y_AXIS */
+ } /* switch */
+ } /* for (d = ... ) */
+}
diff --git a/nx-X11/programs/Xserver/afb/afbbresd.c b/nx-X11/programs/Xserver/afb/afbbresd.c
new file mode 100644
index 000000000..52cb62cab
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbbresd.c
@@ -0,0 +1,216 @@
+/* $XFree86$ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbbresd.c,v 1.10 94/04/17 20:28:18 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "afb.h"
+#include "maskbits.h"
+#include "miline.h"
+
+/* Dashed bresenham line */
+
+#define StepDash\
+ if (!--dashRemaining) { \
+ if (++ dashIndex == numInDashList) \
+ dashIndex = 0; \
+ dashRemaining = pDash[dashIndex]; \
+ rop = fgrop; \
+ if (dashIndex & 1) \
+ rop = bgrop; \
+ }
+
+void
+afbBresD(pdashIndex, pDash, numInDashList, pdashOffset, isDoubleDash,
+ addrlbase, nlwidth, sizeDst, depthDst,
+ signdx, signdy, axis, x1, y1, e, e1, e2, len, rrops, bgrrops)
+int *pdashIndex; /* current dash */
+unsigned char *pDash; /* dash list */
+int numInDashList; /* total length of dash list */
+int *pdashOffset; /* offset into current dash */
+int isDoubleDash;
+PixelType *addrlbase; /* pointer to base of bitmap */
+int nlwidth; /* width in longwords of bitmap */
+int sizeDst;
+int depthDst;
+int signdx, signdy; /* signs of directions */
+int axis; /* major axis (Y_AXIS or X_AXIS) */
+int x1, y1; /* initial point */
+register int e; /* error accumulator */
+register int e1; /* bresenham increments */
+int e2;
+int len; /* length of line */
+unsigned char *rrops;
+unsigned char *bgrrops;
+{
+ register int yinc; /* increment to next scanline, in bytes */
+ register PixelType *addrl;
+ register int e3 = e2-e1;
+ register unsigned long bit;
+ PixelType leftbit = mfbGetmask(0); /* leftmost bit to process in new word */
+ PixelType rightbit = mfbGetmask(PPW-1); /* rightmost bit to process in new word */
+ int dashIndex;
+ int dashOffset;
+ int dashRemaining;
+ int rop;
+ int fgrop;
+ int bgrop;
+ int saveE;
+ int saveLen;
+ int d;
+
+ dashOffset = *pdashOffset;
+ dashIndex = *pdashIndex;
+ dashRemaining = pDash[dashIndex] - dashOffset;
+ /* point to longword containing first point */
+
+ yinc = signdy * nlwidth;
+ e = e-e1; /* to make looping easier */
+
+ saveE = e;
+ saveLen = len;
+
+ for (d = 0; d < depthDst; d++) {
+ addrl = afbScanline(addrlbase, x1, y1, nlwidth);
+ addrlbase += sizeDst; /* @@@ NEXT PLANE @@@ */
+
+ fgrop = rrops[d];
+ bgrop = bgrrops[d];
+
+ e = saveE;
+ len = saveLen;
+ bit = mfbGetmask(x1 & PIM);
+
+ rop = fgrop;
+ if (!isDoubleDash)
+ bgrop = -1;
+ if (dashIndex & 1)
+ rop = bgrop;
+
+ if (axis == X_AXIS) {
+ if (signdx > 0) {
+ while(len--) {
+ if (rop == RROP_BLACK)
+ *addrl &= ~bit;
+ else if (rop == RROP_WHITE)
+ *addrl |= bit;
+ else if (rop == RROP_INVERT)
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0) {
+ afbScanlineInc(addrl, yinc);
+ e += e3;
+ }
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ StepDash
+ }
+ } else {
+ while(len--) {
+ if (rop == RROP_BLACK)
+ *addrl &= ~bit;
+ else if (rop == RROP_WHITE)
+ *addrl |= bit;
+ else if (rop == RROP_INVERT)
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0) {
+ afbScanlineInc(addrl, yinc);
+ e += e3;
+ }
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit;addrl --; }
+ StepDash
+ }
+ }
+ } /* if X_AXIS */ else {
+ if (signdx > 0) {
+ while(len--) {
+ if (rop == RROP_BLACK)
+ *addrl &= ~bit;
+ else if (rop == RROP_WHITE)
+ *addrl |= bit;
+ else if (rop == RROP_INVERT)
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0) {
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ e += e3;
+ }
+ afbScanlineInc(addrl, yinc);
+ StepDash
+ }
+ } else {
+ while(len--) {
+ if (rop == RROP_BLACK)
+ *addrl &= ~bit;
+ else if (rop == RROP_WHITE)
+ *addrl |= bit;
+ else if (rop == RROP_INVERT)
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0) {
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit;addrl --; }
+ e += e3;
+ }
+ afbScanlineInc(addrl, yinc);
+ StepDash
+ }
+ }
+ } /* else Y_AXIS */
+ } /* for (d = ...) */
+ *pdashIndex = dashIndex;
+ *pdashOffset = pDash[dashIndex] - dashRemaining;
+}
diff --git a/nx-X11/programs/Xserver/afb/afbbstore.c b/nx-X11/programs/Xserver/afb/afbbstore.c
new file mode 100644
index 000000000..a74a9d9b8
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbbstore.c
@@ -0,0 +1,156 @@
+/* $XFree86$ */
+/* $XConsortium: afbbstore.c,v 5.7 94/04/17 20:28:18 dpw Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/*
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the X Consortium.
+
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "afb.h"
+#include <X11/X.h>
+#include "mibstore.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * afbSaveAreas --
+ * Function called by miSaveAreas to actually fetch the areas to be
+ * saved into the backing pixmap. This is very simple to do, since
+ * afbDoBitblt is designed for this very thing. The region to save is
+ * already destination-relative and we're given the offset to the
+ * window origin, so we have only to create an array of points of the
+ * u.l. corners of the boxes in the region translated to the screen
+ * coordinate system and fetch the screen pixmap out of its devPrivate
+ * field....
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Data are copied from the screen into the pixmap.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+afbSaveAreas(pPixmap, prgnSave, xorg, yorg, pWin)
+ PixmapPtr pPixmap; /* Backing pixmap */
+ RegionPtr prgnSave; /* Region to save (pixmap-relative) */
+ int xorg; /* X origin of region */
+ int yorg; /* Y origin of region */
+ WindowPtr pWin;
+{
+ register DDXPointPtr pPt;
+ DDXPointPtr pPtsInit;
+ register BoxPtr pBox;
+ register int numRects;
+
+ numRects = REGION_NUM_RECTS(prgnSave);
+ pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects * sizeof(DDXPointRec));
+ if (!pPtsInit)
+ return;
+
+ pBox = REGION_RECTS(prgnSave);
+ pPt = pPtsInit;
+ while (numRects--) {
+ pPt->x = pBox->x1 + xorg;
+ pPt->y = pBox->y1 + yorg;
+ pPt++;
+ pBox++;
+ }
+
+ afbDoBitblt((DrawablePtr)pPixmap->drawable.pScreen->devPrivates[afbScreenPrivateIndex].ptr,
+ (DrawablePtr)pPixmap,
+ GXcopy,
+ prgnSave,
+ pPtsInit, wBackingBitPlanes (pWin));
+
+ DEALLOCATE_LOCAL(pPtsInit);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * afbRestoreAreas --
+ * Function called by miRestoreAreas to actually fetch the areas to be
+ * restored from the backing pixmap. This is very simple to do, since
+ * afbDoBitblt is designed for this very thing. The region to restore is
+ * already destination-relative and we're given the offset to the
+ * window origin, so we have only to create an array of points of the
+ * u.l. corners of the boxes in the region translated to the pixmap
+ * coordinate system and fetch the screen pixmap out of its devPrivate
+ * field....
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Data are copied from the pixmap into the screen.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+afbRestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin)
+ PixmapPtr pPixmap; /* Backing pixmap */
+ RegionPtr prgnRestore; /* Region to restore (screen-relative)*/
+ int xorg; /* X origin of window */
+ int yorg; /* Y origin of window */
+ WindowPtr pWin;
+{
+ register DDXPointPtr pPt;
+ DDXPointPtr pPtsInit;
+ register BoxPtr pBox;
+ register int numRects;
+
+ numRects = REGION_NUM_RECTS(prgnRestore);
+ pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects*sizeof(DDXPointRec));
+ if (!pPtsInit)
+ return;
+
+ pBox = REGION_RECTS(prgnRestore);
+ pPt = pPtsInit;
+ while (numRects--) {
+ pPt->x = pBox->x1 - xorg;
+ pPt->y = pBox->y1 - yorg;
+ pPt++;
+ pBox++;
+ }
+
+ afbDoBitblt((DrawablePtr)pPixmap,
+ (DrawablePtr)pPixmap->drawable.pScreen->devPrivates[afbScreenPrivateIndex].ptr,
+ GXcopy,
+ prgnRestore,
+ pPtsInit, wBackingBitPlanes (pWin));
+
+ DEALLOCATE_LOCAL(pPtsInit);
+}
diff --git a/nx-X11/programs/Xserver/afb/afbclip.c b/nx-X11/programs/Xserver/afb/afbclip.c
new file mode 100644
index 000000000..ea7413233
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbclip.c
@@ -0,0 +1,248 @@
+/* $XFree86: xc/programs/Xserver/afb/afbclip.c,v 3.2 2001/10/28 03:32:57 tsi Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbclip.c,v 5.6 94/04/17 20:28:19 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "regionstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "gc.h"
+#include "maskbits.h"
+#include "mi.h"
+#include "afb.h"
+
+#define ADDRECT(reg,r,fr,rx1,ry1,rx2,ry2) \
+if (((rx1) < (rx2)) && ((ry1) < (ry2)) && \
+ (!((reg)->data->numRects && \
+ ((r-1)->y1 == (ry1)) && \
+ ((r-1)->y2 == (ry2)) && \
+ ((r-1)->x1 <= (rx1)) && \
+ ((r-1)->x2 >= (rx2))))) \
+{ \
+ if ((reg)->data->numRects == (reg)->data->size) \
+ { \
+ miRectAlloc(reg, 1); \
+ fr = REGION_BOXPTR(reg); \
+ r = fr + (reg)->data->numRects; \
+ } \
+ r->x1 = (rx1); \
+ r->y1 = (ry1); \
+ r->x2 = (rx2); \
+ r->y2 = (ry2); \
+ (reg)->data->numRects++; \
+ if(r->x1 < (reg)->extents.x1) \
+ (reg)->extents.x1 = r->x1; \
+ if(r->x2 > (reg)->extents.x2) \
+ (reg)->extents.x2 = r->x2; \
+ r++; \
+}
+
+/* Convert bitmap clip mask into clipping region.
+ * First, goes through each line and makes boxes by noting the transitions
+ * from 0 to 1 and 1 to 0.
+ * Then it coalesces the current line with the previous if they have boxes
+ * at the same X coordinates.
+ */
+RegionPtr
+afbPixmapToRegion(pPix)
+ PixmapPtr pPix;
+{
+ register RegionPtr pReg;
+ register PixelType *pw, w;
+ register int ib;
+ int width, h, base, rx1 = 0, crects;
+ PixelType *pwLineEnd;
+ int irectPrevStart, irectLineStart;
+ register BoxPtr prectO, prectN;
+ BoxPtr FirstRect, rects, prectLineStart;
+ Bool fInBox, fSame;
+ register PixelType mask0 = mfbGetmask(0);
+ PixelType *pwLine;
+ int nWidth;
+
+ pReg = REGION_CREATE(pPix->drawable.pScreen, NULL, 1);
+ if(!pReg)
+ return NullRegion;
+ FirstRect = REGION_BOXPTR(pReg);
+ rects = FirstRect;
+
+ pwLine = (PixelType *) pPix->devPrivate.ptr;
+ nWidth = pPix->devKind / PGSZB;
+
+ width = pPix->drawable.width;
+ pReg->extents.x1 = width - 1;
+ pReg->extents.x2 = 0;
+ irectPrevStart = -1;
+ for(h = 0; h < pPix->drawable.height; h++) {
+ pw = pwLine;
+ pwLine += nWidth;
+ irectLineStart = rects - FirstRect;
+ /* If the Screen left most bit of the word is set, we're starting in
+ * a box */
+ if(*pw & mask0) {
+ fInBox = TRUE;
+ rx1 = 0;
+ }
+ else
+ fInBox = FALSE;
+ /* Process all words which are fully in the pixmap */
+ pwLineEnd = pw + (width >> PWSH);
+ for (base = 0; pw < pwLineEnd; base += PPW) {
+ w = *pw++;
+ if (fInBox) {
+ if (!~w)
+ continue;
+ } else {
+ if (!w)
+ continue;
+ }
+ for(ib = 0; ib < PPW; ib++) {
+ /* If the Screen left most bit of the word is set, we're
+ * starting a box */
+ if(w & mask0) {
+ if(!fInBox) {
+ rx1 = base + ib;
+ /* start new box */
+ fInBox = TRUE;
+ }
+ } else {
+ if(fInBox) {
+ /* end box */
+ ADDRECT(pReg, rects, FirstRect,
+ rx1, h, base + ib, h + 1);
+ fInBox = FALSE;
+ }
+ }
+ /* Shift the word VISUALLY left one. */
+ w = SCRLEFT(w, 1);
+ }
+ }
+ if(width & PIM) {
+ /* Process final partial word on line */
+ w = *pw++;
+ for(ib = 0; ib < (width & PIM); ib++) {
+ /* If the Screen left most bit of the word is set, we're
+ * starting a box */
+ if(w & mask0) {
+ if(!fInBox) {
+ rx1 = base + ib;
+ /* start new box */
+ fInBox = TRUE;
+ }
+ } else {
+ if(fInBox) {
+ /* end box */
+ ADDRECT(pReg, rects, FirstRect,
+ rx1, h, base + ib, h + 1);
+ fInBox = FALSE;
+ }
+ }
+ /* Shift the word VISUALLY left one. */
+ w = SCRLEFT(w, 1);
+ }
+ }
+ /* If scanline ended with last bit set, end the box */
+ if(fInBox) {
+ ADDRECT(pReg, rects, FirstRect,
+ rx1, h, base + (width & PIM), h + 1);
+ }
+ /* if all rectangles on this line have the same x-coords as
+ * those on the previous line, then add 1 to all the previous y2s and
+ * throw away all the rectangles from this line
+ */
+ fSame = FALSE;
+ if(irectPrevStart != -1) {
+ crects = irectLineStart - irectPrevStart;
+ if(crects == ((rects - FirstRect) - irectLineStart)) {
+ prectO = FirstRect + irectPrevStart;
+ prectN = prectLineStart = FirstRect + irectLineStart;
+ fSame = TRUE;
+ while(prectO < prectLineStart) {
+ if((prectO->x1 != prectN->x1) || (prectO->x2 != prectN->x2)) {
+ fSame = FALSE;
+ break;
+ }
+ prectO++;
+ prectN++;
+ }
+ if (fSame) {
+ prectO = FirstRect + irectPrevStart;
+ while(prectO < prectLineStart) {
+ prectO->y2 += 1;
+ prectO++;
+ }
+ rects -= crects;
+ pReg->data->numRects -= crects;
+ }
+ }
+ }
+ if(!fSame)
+ irectPrevStart = irectLineStart;
+ }
+ if (!pReg->data->numRects)
+ pReg->extents.x1 = pReg->extents.x2 = 0;
+ else
+ {
+ pReg->extents.y1 = REGION_BOXPTR(pReg)->y1;
+ pReg->extents.y2 = REGION_END(pReg)->y2;
+ if (pReg->data->numRects == 1) {
+ xfree(pReg->data);
+ pReg->data = (RegDataPtr)NULL;
+ }
+ }
+#ifdef DEBUG
+ if (!miValidRegion(pReg))
+ FatalError("Assertion failed file %s, line %d: expr\n", __FILE__, __LINE__);
+#endif
+ return(pReg);
+}
diff --git a/nx-X11/programs/Xserver/afb/afbcmap.c b/nx-X11/programs/Xserver/afb/afbcmap.c
new file mode 100644
index 000000000..69b5d7ca4
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbcmap.c
@@ -0,0 +1,125 @@
+/* $XFree86: xc/programs/Xserver/afb/afbcmap.c,v 3.0 1996/08/18 01:45:30 dawes Exp $ */
+/* $XConsortium: afbcmap.c,v 4.19 94/04/17 20:28:46 dpw Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "colormapst.h"
+#include "resource.h"
+#include "micmap.h"
+
+int
+afbListInstalledColormaps(pScreen, pmaps)
+ ScreenPtr pScreen;
+ Colormap *pmaps;
+{
+ return miListInstalledColormaps(pScreen, pmaps);
+}
+
+
+void
+afbInstallColormap(pmap)
+ ColormapPtr pmap;
+{
+ miInstallColormap(pmap);
+}
+
+void
+afbUninstallColormap(pmap)
+ ColormapPtr pmap;
+{
+ miUninstallColormap(pmap);
+}
+
+void
+afbResolveColor(pred, pgreen, pblue, pVisual)
+ unsigned short *pred, *pgreen, *pblue;
+ register VisualPtr pVisual;
+{
+ miResolveColor(pred, pgreen, pblue, pVisual);
+}
+
+Bool
+afbInitializeColormap(pmap)
+ register ColormapPtr pmap;
+{
+ return miInitializeColormap(pmap);
+}
+
+int
+afbExpandDirectColors(pmap, ndef, indefs, outdefs)
+ ColormapPtr pmap;
+ int ndef;
+ xColorItem *indefs, *outdefs;
+{
+ return miExpandDirectColors(pmap, ndef, indefs, outdefs);
+}
+
+Bool
+afbCreateDefColormap(pScreen)
+ ScreenPtr pScreen;
+{
+ return miCreateDefColormap(pScreen);
+}
+
+Bool
+afbSetVisualTypes(depth, visuals, bitsPerRGB)
+ int depth;
+ int visuals;
+ int bitsPerRGB;
+{
+ return miSetVisualTypes(depth, visuals, bitsPerRGB, -1);
+}
+
+/*
+ * Given a list of formats for a screen, create a list
+ * of visuals and depths for the screen which correspond to
+ * the set which can be used with this version of afb.
+ */
+
+Bool
+afbInitVisuals(visualp, depthp, nvisualp, ndepthp, rootDepthp, defaultVisp,
+ sizes, bitsPerRGB)
+ VisualPtr *visualp;
+ DepthPtr *depthp;
+ int *nvisualp, *ndepthp;
+ int *rootDepthp;
+ VisualID *defaultVisp;
+ unsigned long sizes;
+ int bitsPerRGB;
+{
+ return miInitVisuals(visualp, depthp, nvisualp, ndepthp, rootDepthp,
+ defaultVisp, sizes, bitsPerRGB, -1);
+}
diff --git a/nx-X11/programs/Xserver/afb/afbfillarc.c b/nx-X11/programs/Xserver/afb/afbfillarc.c
new file mode 100644
index 000000000..17b4902d9
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbfillarc.c
@@ -0,0 +1,359 @@
+/* $XFree86: xc/programs/Xserver/afb/afbfillarc.c,v 3.1 1998/03/20 21:04:54 hohndel Exp $ */
+/************************************************************
+
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+********************************************************/
+
+/* $XConsortium: afbfillarc.c,v 5.14 94/04/17 20:28:20 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "afb.h"
+#include "maskbits.h"
+#include "mifillarc.h"
+#include "mi.h"
+
+static void
+afbFillEllipseSolid(pDraw, arc, rrops)
+ DrawablePtr pDraw;
+ xArc *arc;
+ register unsigned char *rrops;
+{
+ int x, y, e;
+ int yk, xk, ym, xm, dx, dy, xorg, yorg;
+ register int slw;
+ miFillArcRec info;
+ PixelType *addrlt, *addrlb;
+ register PixelType *pdst;
+ PixelType *addrl;
+ register int n;
+ register int d;
+ int nlwidth;
+ register int xpos;
+ PixelType startmask, endmask;
+ int nlmiddle;
+ int depthDst;
+ int sizeDst;
+
+ afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
+ addrlt);
+ miFillArcSetup(arc, &info);
+ MIFILLARCSETUP();
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ addrlb = addrlt;
+ addrlt += nlwidth * (yorg - y);
+ addrlb += nlwidth * (yorg + y + dy);
+ while (y) {
+ addrlt += nlwidth;
+ addrlb -= nlwidth;
+ MIFILLARCSTEP(slw);
+ if (!slw)
+ continue;
+ xpos = xorg - x;
+ pdst = addrl = afbScanlineOffset(addrlt, (xpos >> PWSH));
+ if (((xpos & PIM) + slw) < PPW) {
+ maskpartialbits(xpos, slw, startmask);
+ for (d = 0; d < depthDst; d++, pdst += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ *pdst &= ~startmask;
+ break;
+ case RROP_WHITE:
+ *pdst |= startmask;
+ break;
+ case RROP_INVERT:
+ *pdst ^= startmask;
+ break;
+ case RROP_NOP:
+ break;
+ }
+ }
+ if (miFillArcLower(slw)) {
+ pdst = afbScanlineOffset(addrlb, (xpos >> PWSH));
+
+ for (d = 0; d < depthDst; d++, pdst += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ *pdst &= ~startmask;
+ break;
+ case RROP_WHITE:
+ *pdst |= startmask;
+ break;
+ case RROP_INVERT:
+ *pdst ^= startmask;
+ break;
+ case RROP_NOP:
+ break;
+ }
+ }
+ }
+ continue;
+ }
+ maskbits(xpos, slw, startmask, endmask, nlmiddle);
+ for (d = 0; d < depthDst; d++, addrl += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ n = nlmiddle;
+ pdst = addrl;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ if (startmask)
+ *pdst++ &= ~startmask;
+ while (n--)
+ *pdst++ = 0;
+ if (endmask)
+ *pdst &= ~endmask;
+ break;
+
+ case RROP_WHITE:
+ if (startmask)
+ *pdst++ |= startmask;
+ while (n--)
+ *pdst++ = ~0;
+ if (endmask)
+ *pdst |= endmask;
+ break;
+
+ case RROP_INVERT:
+ if (startmask)
+ *pdst++ ^= startmask;
+ while (n--)
+ *pdst++ ^= ~0;
+ if (endmask)
+ *pdst ^= endmask;
+ break;
+
+ case RROP_NOP:
+ break;
+ }
+ }
+ if (!miFillArcLower(slw))
+ continue;
+ addrl = afbScanlineOffset(addrlb, (xpos >> PWSH));
+ for (d = 0; d < depthDst; d++, addrl += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ n = nlmiddle;
+ pdst = addrl;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ if (startmask)
+ *pdst++ &= ~startmask;
+ while (n--)
+ *pdst++ = 0;
+ if (endmask)
+ *pdst &= ~endmask;
+ break;
+
+ case RROP_WHITE:
+ if (startmask)
+ *pdst++ |= startmask;
+ while (n--)
+ *pdst++ = ~0;
+ if (endmask)
+ *pdst |= endmask;
+ break;
+
+ case RROP_INVERT:
+ if (startmask)
+ *pdst++ ^= startmask;
+ while (n--)
+ *pdst++ ^= ~0;
+ if (endmask)
+ *pdst ^= endmask;
+ break;
+
+ case RROP_NOP:
+ break;
+ }
+ }
+ }
+}
+
+#define FILLSPAN(xl,xr,addr) \
+ if (xr >= xl) { \
+ width = xr - xl + 1; \
+ addrl = afbScanlineOffset(addr, (xl >> PWSH)); \
+ if (((xl & PIM) + width) < PPW) { \
+ maskpartialbits(xl, width, startmask); \
+ for (pdst = addrl, d = 0; d < depthDst; d++, pdst += sizeDst) { /* @@@ NEXT PLANE @@@ */ \
+ switch (rrops[d]) { \
+ case RROP_BLACK: \
+ *pdst &= ~startmask; \
+ break; \
+ case RROP_WHITE: \
+ *pdst |= startmask; \
+ break; \
+ case RROP_INVERT: \
+ *pdst ^= startmask; \
+ break; \
+ case RROP_NOP: \
+ break; \
+ } \
+ } \
+ } else { \
+ maskbits(xl, width, startmask, endmask, nlmiddle); \
+ for (d = 0; d < depthDst; d++, addrl += sizeDst) { /* @@@ NEXT PLANE @@@ */ \
+ n = nlmiddle; \
+ pdst = addrl; \
+ switch (rrops[d]) { \
+ case RROP_BLACK: \
+ if (startmask) \
+ *pdst++ &= ~startmask; \
+ while (n--) \
+ *pdst++ = 0; \
+ if (endmask) \
+ *pdst &= ~endmask; \
+ break; \
+ case RROP_WHITE: \
+ if (startmask) \
+ *pdst++ |= startmask; \
+ while (n--) \
+ *pdst++ = ~0; \
+ if (endmask) \
+ *pdst |= endmask; \
+ break; \
+ case RROP_INVERT: \
+ if (startmask) \
+ *pdst++ ^= startmask; \
+ while (n--) \
+ *pdst++ ^= ~0; \
+ if (endmask) \
+ *pdst ^= endmask; \
+ break; \
+ case RROP_NOP: \
+ break; \
+ } \
+ } \
+ } \
+ }
+
+#define FILLSLICESPANS(flip,addr) \
+ if (!flip) { \
+ FILLSPAN(xl, xr, addr); \
+ } else { \
+ xc = xorg - x; \
+ FILLSPAN(xc, xr, addr); \
+ xc += slw - 1; \
+ FILLSPAN(xl, xc, addr); \
+ }
+
+static void
+afbFillArcSliceSolidCopy(pDraw, pGC, arc, rrops)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ xArc *arc;
+ register unsigned char *rrops;
+{
+ PixelType *addrl;
+ register PixelType *pdst;
+ register int n;
+ register int d;
+ int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
+ register int x, y, e;
+ miFillArcRec info;
+ miArcSliceRec slice;
+ int xl, xr, xc;
+ PixelType *addrlt, *addrlb;
+ int nlwidth;
+ int width;
+ PixelType startmask, endmask;
+ int nlmiddle;
+ int sizeDst;
+ int depthDst;
+
+ afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
+ addrlt);
+ miFillArcSetup(arc, &info);
+ miFillArcSliceSetup(arc, &slice, pGC);
+ MIFILLARCSETUP();
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ addrlb = addrlt;
+ addrlt = afbScanlineDeltaNoBankSwitch(addrlt, yorg - y, nlwidth);
+ addrlb = afbScanlineDeltaNoBankSwitch(addrlb, yorg + y + dy, nlwidth);
+ slice.edge1.x += pDraw->x;
+ slice.edge2.x += pDraw->x;
+ while (y > 0) {
+ afbScanlineIncNoBankSwitch(addrlt, nlwidth);
+ afbScanlineIncNoBankSwitch(addrlb, -nlwidth);
+ MIFILLARCSTEP(slw);
+ MIARCSLICESTEP(slice.edge1);
+ MIARCSLICESTEP(slice.edge2);
+ if (miFillSliceUpper(slice)) {
+ MIARCSLICEUPPER(xl, xr, slice, slw);
+ FILLSLICESPANS(slice.flip_top, addrlt);
+ }
+ if (miFillSliceLower(slice)) {
+ MIARCSLICELOWER(xl, xr, slice, slw);
+ FILLSLICESPANS(slice.flip_bot, addrlb);
+ }
+ }
+}
+
+void
+afbPolyFillArcSolid(pDraw, pGC, narcs, parcs)
+ register DrawablePtr pDraw;
+ GCPtr pGC;
+ int narcs;
+ xArc *parcs;
+{
+ afbPrivGC *priv;
+ register xArc *arc;
+ register int i;
+ BoxRec box;
+ RegionPtr cclip;
+ unsigned char *rrops;
+
+ priv = (afbPrivGC *) pGC->devPrivates[afbGCPrivateIndex].ptr;
+ rrops = priv->rrops;
+ cclip = pGC->pCompositeClip;
+ for (arc = parcs, i = narcs; --i >= 0; arc++) {
+ if (miFillArcEmpty(arc))
+ continue;
+ if (miCanFillArc(arc)) {
+ box.x1 = arc->x + pDraw->x;
+ box.y1 = arc->y + pDraw->y;
+ box.x2 = box.x1 + (int)arc->width + 1;
+ box.y2 = box.y1 + (int)arc->height + 1;
+ if (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) {
+ if ((arc->angle2 >= FULLCIRCLE) ||
+ (arc->angle2 <= -FULLCIRCLE))
+ afbFillEllipseSolid(pDraw, arc, rrops);
+ else
+ afbFillArcSliceSolidCopy(pDraw, pGC, arc, rrops);
+ continue;
+ }
+ }
+ miPolyFillArc(pDraw, pGC, 1, arc);
+ }
+}
diff --git a/nx-X11/programs/Xserver/afb/afbfillrct.c b/nx-X11/programs/Xserver/afb/afbfillrct.c
new file mode 100644
index 000000000..3646d78c6
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbfillrct.c
@@ -0,0 +1,294 @@
+/* $XFree86: xc/programs/Xserver/afb/afbfillrct.c,v 3.2tsi Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbfillrct.c,v 5.10 94/04/17 20:28:21 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "pixmapstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+
+#include "afb.h"
+#include "maskbits.h"
+
+#define MODEQ(a, b) ((a) %= (b))
+void afbPaintOddSize();
+
+/*
+ filled rectangles.
+ translate the rectangles, clip them, and call the
+helper function in the GC.
+*/
+
+#define NUM_STACK_RECTS 1024
+
+void
+afbPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nrectFill; /* number of rectangles to fill */
+ xRectangle *prectInit; /* Pointer to first rectangle to fill */
+{
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ register BoxPtr pbox;
+ register BoxPtr pboxClipped;
+ BoxPtr pboxClippedBase;
+ BoxPtr pextent;
+ BoxRec stackRects[NUM_STACK_RECTS];
+ int numRects;
+ int n;
+ int xorg, yorg;
+ afbPrivGC *priv;
+ unsigned char *rrops;
+ unsigned char *rropsOS;
+
+ priv = (afbPrivGC *)pGC->devPrivates[afbGCPrivateIndex].ptr;
+ prgnClip = pGC->pCompositeClip;
+ rrops = priv->rrops;
+ rropsOS = priv->rropOS;
+
+ prect = prectInit;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ if (xorg || yorg) {
+ prect = prectInit;
+ n = nrectFill;
+ Duff(n, prect->x += xorg; prect->y += yorg; prect++);
+ }
+
+ prect = prectInit;
+
+ numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
+ if (numRects > NUM_STACK_RECTS) {
+ pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(numRects * sizeof(BoxRec));
+ if (!pboxClippedBase)
+ return;
+ }
+ else
+ pboxClippedBase = stackRects;
+
+ pboxClipped = pboxClippedBase;
+
+ if (REGION_NUM_RECTS(prgnClip) == 1) {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_RECTS(prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--) {
+ if ((pboxClipped->x1 = prect->x) < x1)
+ pboxClipped->x1 = x1;
+
+ if ((pboxClipped->y1 = prect->y) < y1)
+ pboxClipped->y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ pboxClipped->x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ pboxClipped->y2 = by2;
+
+ prect++;
+ if ((pboxClipped->x1 < pboxClipped->x2) &&
+ (pboxClipped->y1 < pboxClipped->y2)) {
+ pboxClipped++;
+ }
+ }
+ } else {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--) {
+ BoxRec box;
+
+ if ((box.x1 = prect->x) < x1)
+ box.x1 = x1;
+
+ if ((box.y1 = prect->y) < y1)
+ box.y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ box.x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ box.y2 = by2;
+
+ prect++;
+
+ if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
+ continue;
+
+ n = REGION_NUM_RECTS (prgnClip);
+ pbox = REGION_RECTS(prgnClip);
+
+ /* clip the rectangle to each box in the clip region
+ this is logically equivalent to calling Intersect()
+ */
+ while(n--) {
+ pboxClipped->x1 = max(box.x1, pbox->x1);
+ pboxClipped->y1 = max(box.y1, pbox->y1);
+ pboxClipped->x2 = min(box.x2, pbox->x2);
+ pboxClipped->y2 = min(box.y2, pbox->y2);
+ pbox++;
+
+ /* see if clipping left anything */
+ if(pboxClipped->x1 < pboxClipped->x2 &&
+ pboxClipped->y1 < pboxClipped->y2) {
+ pboxClipped++;
+ }
+ }
+ }
+ }
+ if (pboxClipped != pboxClippedBase) {
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ afbSolidFillArea(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, rrops);
+ break;
+ case FillTiled:
+ switch (pGC->alu) {
+ case GXcopy:
+ if (pGC->pRotatedPixmap)
+ afbTileAreaPPWCopy(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, GXcopy,
+ pGC->pRotatedPixmap, pGC->planemask);
+ else
+ afbTileAreaCopy (pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, GXcopy,
+ pGC->tile.pixmap,
+ pGC->patOrg.x, pGC->patOrg.y,
+ pGC->planemask);
+ break;
+
+ default:
+ if (pGC->pRotatedPixmap)
+ afbTileAreaPPWGeneral(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, pGC->alu,
+ pGC->pRotatedPixmap,
+ pGC->planemask);
+ else
+ afbTileAreaGeneral(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, pGC->alu,
+ pGC->tile.pixmap,
+ pGC->patOrg.x, pGC->patOrg.y,
+ pGC->planemask);
+ break;
+ } /* switch (alu) */
+ break;
+
+ case FillStippled:
+ if (pGC->pRotatedPixmap)
+ afbStippleAreaPPW(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, pGC->pRotatedPixmap, rrops);
+ else
+ afbStippleArea(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, pGC->stipple,
+ pGC->patOrg.x, pGC->patOrg.y, rrops);
+ break;
+
+ case FillOpaqueStippled:
+ switch (pGC->alu) {
+ case GXcopy:
+ if (pGC->pRotatedPixmap)
+ afbOpaqueStippleAreaPPWCopy(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, GXcopy,
+ pGC->pRotatedPixmap,
+ rropsOS, pGC->planemask);
+ else
+ afbOpaqueStippleAreaCopy(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, GXcopy,
+ pGC->stipple,
+ pGC->patOrg.x, pGC->patOrg.y, rropsOS,
+ pGC->planemask);
+ break;
+
+ default:
+ if (pGC->pRotatedPixmap)
+ afbOpaqueStippleAreaPPWGeneral(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, pGC->alu,
+ pGC->pRotatedPixmap,
+ rropsOS,
+ pGC->planemask);
+ else
+ afbOpaqueStippleAreaGeneral(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, pGC->alu,
+ pGC->stipple,
+ pGC->patOrg.x, pGC->patOrg.y,
+ rropsOS,
+ pGC->planemask);
+ break;
+ } /* switch (alu) */
+ break;
+ }
+ }
+ if (pboxClippedBase != stackRects)
+ DEALLOCATE_LOCAL(pboxClippedBase);
+}
diff --git a/nx-X11/programs/Xserver/afb/afbfillsp.c b/nx-X11/programs/Xserver/afb/afbfillsp.c
new file mode 100644
index 000000000..ffb633409
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbfillsp.c
@@ -0,0 +1,1131 @@
+/* $XFree86: xc/programs/Xserver/afb/afbfillsp.c,v 3.3 2000/11/22 00:58:12 tsi Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbfillsp.c,v 5.13 94/04/17 20:28:21 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "afb.h"
+
+#include "maskbits.h"
+
+#include "mergerop.h"
+
+#include "servermd.h"
+#include "mi.h"
+#include "mispans.h"
+
+/* scanline filling for monochrome frame buffer
+ written by drewry, oct 1986
+
+ these routines all clip. they assume that anything that has called
+them has already translated the points (i.e. pGC->miTranslate is
+non-zero, which is howit gets set in afbCreateGC().)
+
+ the number of new scnalines created by clipping ==
+MaxRectsPerBand * nSpans.
+
+*/
+
+
+void
+afbSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ PixelType *pBase;
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *addrl;/* pointer to current longword in bitmap */
+ register int nlmiddle;
+ register PixelType startmask;
+ register PixelType endmask;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ int depthDst;
+ int sizeDst;
+ int d;
+ unsigned char *rrops;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree) {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
+ pBase);
+ rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
+ while (n--) {
+ addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
+
+ for (d = 0; d < depthDst; d++, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ if (*pwidth) {
+ addrl = addrlBase;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ /* all bits inside same longword */
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl &= ~startmask;
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ &= ~startmask;
+ Duff (nlmiddle, *addrl++ = 0x0);
+ if (endmask)
+ *addrl &= ~endmask;
+ }
+ break;
+
+ case RROP_WHITE:
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ /* all bits inside same longword */
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl |= startmask;
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ |= startmask;
+ Duff (nlmiddle, *addrl++ = ~0);
+ if (endmask)
+ *addrl |= endmask;
+ }
+ break;
+ case RROP_INVERT:
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ /* all bits inside same longword */
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl ^= startmask;
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ ^= startmask;
+ Duff (nlmiddle, *addrl++ ^= ~0);
+ if (endmask)
+ *addrl ^= endmask;
+ }
+ break;
+ case RROP_NOP:
+ break;
+ }
+ }
+ }
+ pwidth++;
+ ppt++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+void
+afbStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ PixelType *pBase;
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *addrl;/* pointer to current longword in bitmap */
+ register PixelType src;
+ register int nlmiddle;
+ register PixelType startmask;
+ register PixelType endmask;
+ PixmapPtr pStipple;
+ PixelType *psrc;
+ int tileHeight;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ int d;
+ int depthDst;
+ int sizeDst;
+ unsigned char *rrops;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree) {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
+ pBase);
+
+ pStipple = pGC->pRotatedPixmap;
+ tileHeight = pStipple->drawable.height;
+ psrc = (PixelType *)(pStipple->devPrivate.ptr);
+
+ rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
+
+ while (n--) {
+ src = psrc[ppt->y % tileHeight];
+ addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
+ for (d = 0; d < depthDst; d++, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ addrl = addrlBase;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ /* all bits inside same longword */
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl &= ~(src & startmask);
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ &= ~(src & startmask);
+ Duff (nlmiddle, *addrl++ &= ~src);
+ if (endmask)
+ *addrl &= ~(src & endmask);
+ }
+ break;
+ case RROP_WHITE:
+ /* all bits inside same longword */
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl |= (src & startmask);
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ |= (src & startmask);
+ Duff (nlmiddle, *addrl++ |= src);
+ if (endmask)
+ *addrl |= (src & endmask);
+ }
+ break;
+ case RROP_INVERT:
+ /* all bits inside same longword */
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl ^= (src & startmask);
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ ^= (src & startmask);
+ Duff (nlmiddle, *addrl++ ^= src);
+ if (endmask)
+ *addrl ^= (src & endmask);
+ }
+ break;
+
+ case RROP_NOP:
+ break;
+ }
+ }
+ pwidth++;
+ ppt++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+void
+afbTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ PixelType *pBase;
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *addrl; /* pointer to current longword in bitmap */
+ register PixelType src;
+ register int nlmiddle;
+ register PixelType startmask;
+ register PixelType endmask;
+ PixmapPtr pTile;
+ PixelType *psrc;
+ int tileHeight;
+ int rop;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ int sizeDst;
+ int depthDst;
+ int d;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree) {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
+ pBase);
+
+ pTile = pGC->pRotatedPixmap;
+ tileHeight = pTile->drawable.height;
+ psrc = (PixelType *)(pTile->devPrivate.ptr);
+ rop = pGC->alu;
+
+ switch(rop) {
+ case GXcopy:
+#define DoMaskCopyRop(src,dst,mask) (((dst) & ~(mask)) | ((src) & (mask)))
+ while (n--) {
+ if (*pwidth) {
+ addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
+
+ for (d = 0; d < depthDst; d++, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ if (!(pGC->planemask & (1 << d)))
+ continue;
+
+ addrl = addrlBase;
+ src = psrc[ppt->y % tileHeight + tileHeight * d];
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl = DoMaskCopyRop (src, *addrl, startmask);
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask) {
+ *addrl = DoMaskCopyRop (src, *addrl, startmask);
+ addrl++;
+ }
+ while (nlmiddle--) {
+ *addrl = src;
+ addrl++;
+ }
+ if (endmask)
+ *addrl = DoMaskCopyRop (src, *addrl, endmask);
+ }
+ }
+ }
+ pwidth++;
+ ppt++;
+ }
+ break;
+
+ default:
+ {
+ register DeclareMergeRop ();
+
+ InitializeMergeRop(rop,~0);
+ while (n--) {
+ if (*pwidth) {
+ addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
+ for (d = 0; d < depthDst; d++, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ if (!(pGC->planemask & (1 << d)))
+ continue;
+
+ addrl = addrlBase;
+
+ src = psrc[ppt->y % tileHeight + tileHeight * d];
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl = DoMaskMergeRop (src, *addrl, startmask);
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask) {
+ *addrl = DoMaskMergeRop (src, *addrl, startmask);
+ addrl++;
+ }
+ while (nlmiddle--) {
+ *addrl = DoMergeRop (src, *addrl);
+ addrl++;
+ }
+ if (endmask)
+ *addrl = DoMaskMergeRop (src, *addrl, endmask);
+ }
+ }
+ }
+ pwidth++;
+ ppt++;
+ }
+ break;
+ }
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+void
+afbOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ PixelType *pBase;
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *addrl; /* pointer to current longword in bitmap */
+ register PixelType src = 0;
+ register int nlmiddle;
+ register PixelType startmask;
+ register PixelType endmask;
+ PixmapPtr pTile;
+ PixelType *psrc;
+ int tileHeight;
+ int rop;
+ unsigned char *rropsOS;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ int sizeDst;
+ int depthDst;
+ int d;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree) {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
+ pBase);
+
+ pTile = pGC->pRotatedPixmap;
+ tileHeight = pTile->drawable.height;
+ psrc = (PixelType *)(pTile->devPrivate.ptr);
+ rop = pGC->alu;
+ rropsOS = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rropOS;
+
+ switch(rop) {
+ case GXcopy:
+ while (n--) {
+ addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
+ if (*pwidth) {
+ for (d = 0; d < depthDst; d++, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ src = 0;
+ break;
+ case RROP_WHITE:
+ src = ~0;
+ break;
+ case RROP_INVERT:
+ src = ~psrc[ppt->y % tileHeight];
+ break;
+ case RROP_COPY:
+ src = psrc[ppt->y % tileHeight];
+ break;
+ case RROP_NOP:
+ continue;
+ }
+
+ addrl = addrlBase;
+
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl = DoMaskCopyRop (src, *addrl, startmask);
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask) {
+ *addrl = DoMaskCopyRop (src, *addrl, startmask);
+ addrl++;
+ }
+ while (nlmiddle--) {
+ *addrl = src;
+ addrl++;
+ }
+ if (endmask)
+ *addrl = DoMaskCopyRop (src, *addrl, endmask);
+ }
+ } /* for (d = ...) */
+ }
+
+ pwidth++;
+ ppt++;
+ }
+ break;
+
+ default:
+ {
+ register DeclareMergeRop ();
+
+ InitializeMergeRop(rop,~0);
+ while (n--) {
+ addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
+ if (*pwidth) {
+ for (d = 0; d < depthDst; d++, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ src = 0;
+ break;
+ case RROP_WHITE:
+ src = ~0;
+ break;
+ case RROP_INVERT:
+ src = ~psrc[ppt->y % tileHeight];
+ break;
+ case RROP_COPY:
+ src = psrc[ppt->y % tileHeight];
+ break;
+ case RROP_NOP:
+ continue;
+ }
+
+ addrl = addrlBase;
+
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl = DoMaskMergeRop (src, *addrl, startmask);
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask) {
+ *addrl = DoMaskMergeRop (src, *addrl, startmask);
+ addrl++;
+ }
+ while (nlmiddle--) {
+ *addrl = DoMergeRop (src, *addrl);
+ addrl++;
+ }
+ if (endmask)
+ *addrl = DoMaskMergeRop (src, *addrl, endmask);
+ }
+ } /* for (d = ...) */
+ }
+ pwidth++;
+ ppt++;
+ } /* while (n) */
+ break;
+ }
+ } /* switch (rop) */
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+/* Fill spans with tiles that aren't PPW bits wide */
+void
+afbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ int iline; /* first line of tile to use */
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ PixelType *pBase;
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *pdst;/* pointer to current word in bitmap */
+ register PixelType *psrc;/* pointer to current word in tile */
+ register int nlMiddle;
+ register int rop, nstart;
+ PixelType startmask;
+ PixmapPtr pTile; /* pointer to tile we want to fill with */
+ int w, width, x, xSrc, ySrc, srcStartOver, nend;
+ int tlwidth, rem, tileWidth, tileHeight, endinc;
+ PixelType endmask, *psrcT;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ int sizeDst;
+ int sizeTile;
+ int depthDst;
+ register int d;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree) {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ pTile = pGC->tile.pixmap;
+ tlwidth = pTile->devKind / PGSZB;
+ rop = pGC->alu;
+
+ xSrc = pDrawable->x;
+ ySrc = pDrawable->y;
+
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
+ pBase);
+
+ tileWidth = pTile->drawable.width;
+ tileHeight = pTile->drawable.height;
+ sizeTile = tlwidth * tileHeight;
+
+ /* this replaces rotating the tile. Instead we just adjust the offset
+ * at which we start grabbing bits from the tile.
+ * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
+ * so that iline and rem always stay within the tile bounds.
+ */
+ xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;
+ ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;
+
+ while (n--) {
+ iline = (ppt->y - ySrc) % tileHeight;
+ psrcT = (PixelType *) pTile->devPrivate.ptr + (iline * tlwidth);
+ addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
+
+ for (d = 0; d < depthDst; d++, psrcT += sizeTile, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ if (!(pGC->planemask & (1 << d)))
+ continue;
+
+ if (*pwidth) {
+ x = ppt->x;
+ pdst = addrlBase;
+ width = *pwidth;
+ while(width > 0) {
+ psrc = psrcT;
+ w = min(tileWidth, width);
+ if((rem = (x - xSrc) % tileWidth) != 0) {
+ /* if we're in the middle of the tile, get
+ as many bits as will finish the span, or
+ as many as will get to the left edge of the tile,
+ or a longword worth, starting at the appropriate
+ offset in the tile.
+ */
+ w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
+ endinc = rem / BITMAP_SCANLINE_PAD;
+ getandputrop((psrc+endinc), (rem&PIM), (x & PIM), w, pdst, rop);
+ if((x & PIM) + w >= PPW)
+ pdst++;
+ } else if(((x & PIM) + w) < PPW) {
+ /* doing < PPW bits is easy, and worth special-casing */
+ putbitsrop(*psrc, x & PIM, w, pdst, rop);
+ } else {
+ /* start at the left edge of the tile,
+ and put down as much as we can
+ */
+ maskbits(x, w, startmask, endmask, nlMiddle);
+
+ if (startmask)
+ nstart = PPW - (x & PIM);
+ else
+ nstart = 0;
+ if (endmask)
+ nend = (x + w) & PIM;
+ else
+ nend = 0;
+
+ srcStartOver = nstart > PLST;
+
+ if(startmask) {
+ putbitsrop(*psrc, (x & PIM), nstart, pdst, rop);
+ pdst++;
+ if(srcStartOver)
+ psrc++;
+ }
+
+ while(nlMiddle--) {
+ getandputrop0(psrc, nstart, PPW, pdst, rop);
+ pdst++;
+ psrc++;
+ }
+ if(endmask) {
+ getandputrop0(psrc, nstart, nend, pdst, rop);
+ }
+ }
+ x += w;
+ width -= w;
+ }
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+/* Fill spans with stipples that aren't PPW bits wide */
+void
+afbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ int iline; /* first line of tile to use */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ PixelType *pBase;
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *pdst; /* pointer to current word in bitmap */
+ register PixelType *psrc; /* pointer to current word in tile */
+ register int nlMiddle;
+ register int rop, nstart;
+ PixelType startmask;
+ PixmapPtr pTile; /* pointer to tile we want to fill with */
+ int w, width, x, xSrc, ySrc, srcStartOver, nend;
+ PixelType endmask, *psrcT;
+ int tlwidth, rem, tileWidth, endinc;
+ int tileHeight;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ unsigned char *rrops;
+ register int d;
+ int sizeDst;
+ int depthDst;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree) {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ pTile = pGC->stipple;
+ tlwidth = pTile->devKind / PGSZB;
+ xSrc = pDrawable->x;
+ ySrc = pDrawable->y;
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
+ pBase);
+
+ tileWidth = pTile->drawable.width;
+ tileHeight = pTile->drawable.height;
+ rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
+
+ /* this replaces rotating the stipple. Instead, we just adjust the offset
+ * at which we start grabbing bits from the stipple.
+ * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
+ * so that iline and rem always stay within the tile bounds.
+ */
+ xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;
+ ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;
+ while (n--) {
+ iline = (ppt->y - ySrc) % tileHeight;
+ psrcT = (PixelType *) pTile->devPrivate.ptr + (iline * tlwidth);
+ addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
+
+ for (d = 0; d < depthDst; d++, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ rop = rrops[d];
+ if (rop == RROP_NOP)
+ continue;
+
+ pdst = addrlBase;
+ x = ppt->x;
+
+ if (*pwidth) {
+ width = *pwidth;
+ while(width > 0) {
+ psrc = psrcT;
+ w = min(tileWidth, width);
+ if((rem = (x - xSrc) % tileWidth) != 0) {
+ /* if we're in the middle of the tile, get
+ as many bits as will finish the span, or
+ as many as will get to the left edge of the tile,
+ or a longword worth, starting at the appropriate
+ offset in the tile.
+ */
+ w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
+ endinc = rem / BITMAP_SCANLINE_PAD;
+ getandputrrop((psrc + endinc), (rem & PIM), (x & PIM),
+ w, pdst, rop)
+ if((x & PIM) + w >= PPW)
+ pdst++;
+ } else if(((x & PIM) + w) < PPW) {
+ /* doing < PPW bits is easy, and worth special-casing */
+ putbitsrrop(*psrc, x & PIM, w, pdst, rop);
+ } else {
+ /* start at the left edge of the tile,
+ and put down as much as we can
+ */
+ maskbits(x, w, startmask, endmask, nlMiddle);
+
+ if (startmask)
+ nstart = PPW - (x & PIM);
+ else
+ nstart = 0;
+ if (endmask)
+ nend = (x + w) & PIM;
+ else
+ nend = 0;
+
+ srcStartOver = nstart > PLST;
+
+ if(startmask) {
+ putbitsrrop(*psrc, (x & PIM), nstart, pdst, rop);
+ pdst++;
+ if(srcStartOver)
+ psrc++;
+ }
+
+ while(nlMiddle--) {
+ getandputrrop0(psrc, nstart, PPW, pdst, rop);
+ pdst++;
+ psrc++;
+ }
+ if(endmask) {
+ getandputrrop0(psrc, nstart, nend, pdst, rop);
+ }
+ }
+ x += w;
+ width -= w;
+ }
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+/* Fill spans with OpaqueStipples that aren't PPW bits wide */
+void
+afbUnnaturalOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ int iline; /* first line of tile to use */
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ PixelType *pBase;
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *pdst;/* pointer to current word in bitmap */
+ register PixelType *psrc;/* pointer to current word in tile */
+ register int nlMiddle;
+ register int d;
+ register PixelType tmpsrc = 0;
+ register PixelType tmpdst;
+ register int alu, nstart;
+ register unsigned char *rropsOS;
+ PixelType startmask;
+ PixmapPtr pTile; /* pointer to tile we want to fill with */
+ int w, width, x, xSrc, ySrc, srcStartOver, nend;
+ int tlwidth, rem, tileWidth, tileHeight, endinc;
+ PixelType endmask, *psrcT;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ int sizeDst;
+ int depthDst;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree) {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ pTile = pGC->stipple;
+ tlwidth = pTile->devKind / PGSZB;
+ alu = pGC->alu;
+
+ xSrc = pDrawable->x;
+ ySrc = pDrawable->y;
+
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
+ pBase);
+
+ tileWidth = pTile->drawable.width;
+ tileHeight = pTile->drawable.height;
+ rropsOS = afbGetGCPrivate(pGC)->rropOS;
+
+ /* this replaces rotating the tile. Instead we just adjust the offset
+ * at which we start grabbing bits from the tile.
+ * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
+ * so that iline and rem always stay within the tile bounds.
+ */
+ xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;
+ ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;
+
+ while (n--) {
+ iline = (ppt->y - ySrc) % tileHeight;
+ psrcT = (PixelType *) pTile->devPrivate.ptr + (iline * tlwidth);
+ addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
+
+ for (d = 0; d < depthDst; d++, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ if (!(pGC->planemask & (1 << d)))
+ continue;
+
+ if (*pwidth) {
+ x = ppt->x;
+ pdst = addrlBase;
+ width = *pwidth;
+ while(width > 0) {
+ psrc = psrcT;
+ w = min(tileWidth, width);
+ if((rem = (x - xSrc) % tileWidth) != 0) {
+ /* if we're in the middle of the tile, get
+ as many bits as will finish the span, or
+ as many as will get to the left edge of the tile,
+ or a longword worth, starting at the appropriate
+ offset in the tile.
+ */
+ w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
+ endinc = rem / BITMAP_SCANLINE_PAD;
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+
+ case RROP_COPY:
+ getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
+ break;
+
+ case RROP_INVERT:
+ getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
+ tmpsrc = ~tmpsrc;
+ break;
+ }
+
+ if (alu != GXcopy) {
+ getbits (pdst, (x & PIM), w, tmpdst);
+ DoRop (tmpsrc, alu, tmpsrc, tmpdst);
+ }
+
+ putbits (tmpsrc, (x & PIM), w, pdst);
+ if((x & PIM) + w >= PPW)
+ pdst++;
+ } else if(((x & PIM) + w) < PPW) {
+ /* doing < PPW bits is easy, and worth special-casing */
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+ case RROP_COPY:
+ tmpsrc = *psrc;
+ break;
+ case RROP_INVERT:
+ tmpsrc = ~*psrc;
+ break;
+ }
+ if (alu != GXcopy) {
+ getbits (pdst, (x & PIM), w, tmpdst);
+ DoRop (tmpsrc, alu, tmpsrc, tmpdst);
+ }
+ putbits (tmpsrc, (x & PIM), w, pdst);
+ } else {
+ /* start at the left edge of the tile,
+ and put down as much as we can
+ */
+ maskbits(x, w, startmask, endmask, nlMiddle);
+
+ if (startmask)
+ nstart = PPW - (x & PIM);
+ else
+ nstart = 0;
+ if (endmask)
+ nend = (x + w) & PIM;
+ else
+ nend = 0;
+
+ srcStartOver = nstart > PLST;
+
+ if(startmask) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+ case RROP_COPY:
+ tmpsrc = *psrc;
+ break;
+ case RROP_INVERT:
+ tmpsrc = ~*psrc;
+ break;
+ }
+ if (alu != GXcopy) {
+ getbits (pdst, (x & PIM), nstart, tmpdst);
+ DoRop (tmpsrc, alu, tmpsrc, tmpdst);
+ }
+ putbits (tmpsrc, (x & PIM), nstart, pdst);
+ pdst++;
+ if(srcStartOver)
+ psrc++;
+ }
+
+ while(nlMiddle--) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+ case RROP_COPY:
+ getbits (psrc, nstart, PPW, tmpsrc);
+ break;
+ case RROP_INVERT:
+ getbits (psrc, nstart, PPW, tmpsrc);
+ tmpsrc = ~tmpsrc;
+ break;
+ }
+ if (alu != GXcopy) {
+ tmpdst = *pdst;
+ DoRop (tmpsrc, alu, tmpsrc, tmpdst);
+ }
+ *pdst++ = tmpsrc;
+ /*putbits (tmpsrc, 0, PPW, pdst);
+ pdst++;*/
+ psrc++;
+ }
+ if(endmask) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+
+ case RROP_COPY:
+ getbits (psrc, nstart, nend, tmpsrc);
+ break;
+
+ case RROP_INVERT:
+ getbits (psrc, nstart, nend, tmpsrc);
+ tmpsrc = ~tmpsrc;
+ break;
+ }
+ if (alu != GXcopy) {
+ tmpdst = *pdst;
+ DoRop (tmpsrc, alu, tmpsrc, tmpdst);
+ }
+ putbits (tmpsrc, 0, nend, pdst);
+ }
+ }
+ x += w;
+ width -= w;
+ }
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
diff --git a/nx-X11/programs/Xserver/afb/afbfont.c b/nx-X11/programs/Xserver/afb/afbfont.c
new file mode 100644
index 000000000..bf77825f1
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbfont.c
@@ -0,0 +1,79 @@
+/* $XFree86$ */
+/*
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*/
+/* $XConsortium: afbfont.c,v 1.18 94/04/17 20:28:22 keith Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "afb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "scrnintstr.h"
+
+/*ARGSUSED*/
+Bool
+afbRealizeFont( pscr, pFont)
+ ScreenPtr pscr;
+ FontPtr pFont;
+{
+ return (TRUE);
+}
+
+/*ARGSUSED*/
+Bool
+afbUnrealizeFont( pscr, pFont)
+ ScreenPtr pscr;
+ FontPtr pFont;
+{
+ return (TRUE);
+}
diff --git a/nx-X11/programs/Xserver/afb/afbgc.c b/nx-X11/programs/Xserver/afb/afbgc.c
new file mode 100644
index 000000000..e9f4c52b7
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbgc.c
@@ -0,0 +1,711 @@
+/* $XFree86: xc/programs/Xserver/afb/afbgc.c,v 3.2 1999/06/20 15:02:46 dawes Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbgc.c,v 5.35 94/04/17 20:28:23 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "afb.h"
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "region.h"
+
+#include "mistruct.h"
+#include "migc.h"
+
+#include "maskbits.h"
+
+static GCFuncs afbFuncs = {
+ afbValidateGC,
+ miChangeGC,
+ miCopyGC,
+ afbDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip
+};
+
+static GCOps afbGCOps = {
+ afbSolidFS,
+ afbSetSpans,
+ afbPutImage,
+ afbCopyArea,
+ miCopyPlane,
+ afbPolyPoint,
+ afbLineSS,
+ afbSegmentSS,
+ miPolyRectangle,
+ afbZeroPolyArcSS,
+ afbFillPolygonSolid,
+ afbPolyFillRect,
+ afbPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ afbTEGlyphBlt,
+ afbPolyGlyphBlt,
+ afbPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+
+Bool
+afbCreateGC(pGC)
+ register GCPtr pGC;
+{
+ afbPrivGC *pPriv;
+
+ pGC->clientClip = NULL;
+ pGC->clientClipType = CT_NONE;
+
+ /* some of the output primitives aren't really necessary, since
+ they will be filled in ValidateGC because of dix/CreateGC()
+ setting all the change bits. Others are necessary because although
+ they depend on being a monochrome frame buffer, they don't change
+ */
+
+ pGC->ops = &afbGCOps;
+ pGC->funcs = &afbFuncs;
+
+ /* afb wants to translate before scan convesion */
+ pGC->miTranslate = 1;
+
+ pPriv = (afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr);
+ afbReduceRop(pGC->alu, pGC->fgPixel, pGC->planemask, pGC->depth,
+ pPriv->rrops);
+ afbReduceOpaqueStipple(pGC->fgPixel, pGC->bgPixel, pGC->planemask,
+ pGC->depth, pPriv->rropOS);
+
+ pGC->fExpose = TRUE;
+ pGC->pRotatedPixmap = NullPixmap;
+ pGC->freeCompClip = FALSE;
+ return TRUE;
+}
+
+/* Clipping conventions
+ if the drawable is a window
+ CT_REGION ==> pCompositeClip really is the composite
+ CT_other ==> pCompositeClip is the window clip region
+ if the drawable is a pixmap
+ CT_REGION ==> pCompositeClip is the translated client region
+ clipped to the pixmap boundary
+ CT_other ==> pCompositeClip is the pixmap bounding box
+*/
+
+/*ARGSUSED*/
+void
+afbValidateGC(pGC, changes, pDrawable)
+ register GCPtr pGC;
+ unsigned long changes;
+ DrawablePtr pDrawable;
+{
+ register afbPrivGCPtr devPriv;
+ int mask; /* stateChanges */
+ int index; /* used for stepping through bitfields */
+ int xrot, yrot; /* rotations for tile and stipple pattern */
+ /* flags for changing the proc vector
+ and updating things in devPriv
+ */
+ int new_rotate, new_rrop, new_line, new_text, new_fill;
+ DDXPointRec oldOrg; /* origin of thing GC was last used with */
+
+ oldOrg = pGC->lastWinOrg;
+
+ pGC->lastWinOrg.x = pDrawable->x;
+ pGC->lastWinOrg.y = pDrawable->y;
+
+ /* we need to re-rotate the tile if the previous window/pixmap
+ origin (oldOrg) differs from the new window/pixmap origin
+ (pGC->lastWinOrg)
+ */
+ new_rotate = (oldOrg.x != pGC->lastWinOrg.x) ||
+ (oldOrg.y != pGC->lastWinOrg.y);
+
+
+ devPriv = ((afbPrivGCPtr)(pGC->devPrivates[afbGCPrivateIndex].ptr));
+
+
+ /*
+ if the client clip is different or moved OR
+ the subwindowMode has changed OR
+ the window's clip has changed since the last validation
+ we need to recompute the composite clip
+ */
+ if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
+ (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS)))
+ afbComputeCompositeClip(pGC, pDrawable);
+
+ new_rrop = FALSE;
+ new_line = FALSE;
+ new_text = FALSE;
+ new_fill = FALSE;
+
+ mask = changes;
+ while (mask) {
+ index = lowbit(mask);
+ mask &= ~index;
+
+ /* this switch acculmulates a list of which procedures
+ might have to change due to changes in the GC. in
+ some cases (e.g. changing one 16 bit tile for another)
+ we might not really need a change, but the code is
+ being paranoid.
+ this sort of batching wins if, for example, the alu
+ and the font have been changed, or any other pair
+ of items that both change the same thing.
+ */
+ switch (index) {
+ case GCPlaneMask:
+ case GCFunction:
+ case GCForeground:
+ new_rrop = TRUE;
+ break;
+ case GCBackground:
+ new_rrop = TRUE; /* for opaque stipples */
+ break;
+ case GCLineStyle:
+ case GCLineWidth:
+ case GCJoinStyle:
+ new_line = TRUE;
+ break;
+ case GCCapStyle:
+ break;
+ case GCFillStyle:
+ new_fill = TRUE;
+ break;
+ case GCFillRule:
+ break;
+ case GCTile:
+ if(pGC->tileIsPixel)
+ break;
+ new_rotate = TRUE;
+ new_fill = TRUE;
+ break;
+
+ case GCStipple:
+ if(pGC->stipple == (PixmapPtr)NULL)
+ break;
+ new_rotate = TRUE;
+ new_fill = TRUE;
+ break;
+
+ case GCTileStipXOrigin:
+ new_rotate = TRUE;
+ break;
+
+ case GCTileStipYOrigin:
+ new_rotate = TRUE;
+ break;
+
+ case GCFont:
+ new_text = TRUE;
+ break;
+ case GCSubwindowMode:
+ break;
+ case GCGraphicsExposures:
+ break;
+ case GCClipXOrigin:
+ break;
+ case GCClipYOrigin:
+ break;
+ case GCClipMask:
+ break;
+ case GCDashOffset:
+ break;
+ case GCDashList:
+ break;
+ case GCArcMode:
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* deal with the changes we've collected .
+ new_rrop must be done first because subsequent things
+ depend on it.
+ */
+
+ if(new_rotate || new_fill) {
+ Bool new_pix = FALSE;
+
+ /* figure out how much to rotate */
+ xrot = pGC->patOrg.x;
+ yrot = pGC->patOrg.y;
+ xrot += pDrawable->x;
+ yrot += pDrawable->y;
+
+ switch (pGC->fillStyle) {
+ case FillTiled:
+ /* copy current tile and stipple */
+ if (!pGC->tileIsPixel &&
+ (pGC->tile.pixmap->drawable.width <= PPW) &&
+ !(pGC->tile.pixmap->drawable.width &
+ (pGC->tile.pixmap->drawable.width - 1))) {
+ afbCopyRotatePixmap(pGC->tile.pixmap, &pGC->pRotatedPixmap,
+ xrot, yrot);
+ new_pix = TRUE;
+ }
+ break;
+ case FillStippled:
+ case FillOpaqueStippled:
+ if (pGC->stipple && (pGC->stipple->drawable.width <= PPW) &&
+ !(pGC->stipple->drawable.width &
+ (pGC->stipple->drawable.width - 1))) {
+ afbCopyRotatePixmap(pGC->stipple, &pGC->pRotatedPixmap,
+ xrot, yrot);
+ new_pix = TRUE;
+ }
+ }
+ /* destroy any previously rotated tile or stipple */
+ if (!new_pix && pGC->pRotatedPixmap) {
+ (*pDrawable->pScreen->DestroyPixmap)(pGC->pRotatedPixmap);
+ pGC->pRotatedPixmap = (PixmapPtr)NULL;
+ }
+ }
+
+ /*
+ * duck out here when the GC is unchanged
+ */
+
+ if (!changes)
+ return;
+
+ if (new_rrop || new_fill) {
+ afbReduceRop(pGC->alu, pGC->fgPixel, pGC->planemask, pDrawable->depth,
+ devPriv->rrops);
+ afbReduceOpaqueStipple(pGC->fgPixel, pGC->bgPixel, pGC->planemask,
+ pGC->depth, devPriv->rropOS);
+ new_fill = TRUE;
+ }
+
+ if (new_line || new_fill || new_text) {
+ if (!pGC->ops->devPrivate.val) {
+ pGC->ops = miCreateGCOps(pGC->ops);
+ pGC->ops->devPrivate.val = 1;
+ }
+ }
+
+ if (new_line || new_fill) {
+ if (pGC->lineWidth == 0) {
+ if (pGC->lineStyle == LineSolid && pGC->fillStyle == FillSolid)
+ pGC->ops->PolyArc = afbZeroPolyArcSS;
+ else
+ pGC->ops->PolyArc = miZeroPolyArc;
+ } else
+ pGC->ops->PolyArc = miPolyArc;
+ if (pGC->lineStyle == LineSolid) {
+ if(pGC->lineWidth == 0) {
+ if (pGC->fillStyle == FillSolid) {
+ pGC->ops->PolySegment = afbSegmentSS;
+ pGC->ops->Polylines = afbLineSS;
+ }
+ else
+ {
+ pGC->ops->PolySegment = miPolySegment;
+ pGC->ops->Polylines = miZeroLine;
+ }
+ } else {
+ pGC->ops->PolySegment = miPolySegment;
+ pGC->ops->Polylines = miWideLine;
+ }
+ } else {
+ if(pGC->lineWidth == 0 && pGC->fillStyle == FillSolid) {
+ pGC->ops->PolySegment = afbSegmentSD;
+ pGC->ops->Polylines = afbLineSD;
+ } else {
+ pGC->ops->PolySegment = miPolySegment;
+ pGC->ops->Polylines = miWideDash;
+ }
+ }
+ }
+
+ if (new_text || new_fill) {
+ if ((pGC->font) &&
+ (FONTMAXBOUNDS(pGC->font,rightSideBearing) -
+ FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 ||
+ FONTMINBOUNDS(pGC->font,characterWidth) < 0)) {
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
+ } else {
+ /* special case ImageGlyphBlt for terminal emulator fonts */
+ if ((pGC->font) &&
+ TERMINALFONT(pGC->font)) {
+ pGC->ops->ImageGlyphBlt = afbTEGlyphBlt;
+ } else {
+ pGC->ops->ImageGlyphBlt = afbImageGlyphBlt;
+ }
+
+ /* now do PolyGlyphBlt */
+ if (pGC->fillStyle == FillSolid) {
+ pGC->ops->PolyGlyphBlt = afbPolyGlyphBlt;
+ } else {
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ }
+ }
+ }
+
+ if (new_fill) {
+ /* install a suitable fillspans and pushpixels */
+ pGC->ops->PushPixels = afbPushPixels;
+ pGC->ops->FillPolygon = miFillPolygon;
+ pGC->ops->PolyFillArc = miPolyFillArc;
+
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ pGC->ops->FillSpans = afbSolidFS;
+ pGC->ops->FillPolygon = afbFillPolygonSolid;
+ pGC->ops->PolyFillArc = afbPolyFillArcSolid;
+ break;
+ case FillTiled:
+ if (pGC->pRotatedPixmap)
+ pGC->ops->FillSpans = afbTileFS;
+ else
+ pGC->ops->FillSpans = afbUnnaturalTileFS;
+ break;
+ case FillOpaqueStippled:
+ if (pGC->pRotatedPixmap)
+ pGC->ops->FillSpans = afbOpaqueStippleFS;
+ else
+ pGC->ops->FillSpans = afbUnnaturalOpaqueStippleFS;
+ break;
+
+ case FillStippled:
+ if (pGC->pRotatedPixmap)
+ pGC->ops->FillSpans = afbStippleFS;
+ else
+ pGC->ops->FillSpans = afbUnnaturalStippleFS;
+ break;
+ }
+ } /* end of new_fill */
+}
+
+void
+afbDestroyGC(pGC)
+ GCPtr pGC;
+{
+ if (pGC->pRotatedPixmap)
+ (*pGC->pScreen->DestroyPixmap)(pGC->pRotatedPixmap);
+ if (pGC->freeCompClip)
+ REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
+ miDestroyGCOps(pGC->ops);
+}
+
+/* table to map alu(src, dst) to alu(~src, dst) */
+int afbInverseAlu[16] = {
+ GXclear,
+ GXandInverted,
+ GXnor,
+ GXcopyInverted,
+ GXand,
+ GXnoop,
+ GXequiv,
+ GXorInverted,
+ GXandReverse,
+ GXxor,
+ GXinvert,
+ GXnand,
+ GXcopy,
+ GXor,
+ GXorReverse,
+ GXset
+};
+
+void
+afbReduceOpaqueStipple(fg, bg, planemask, depth, rop)
+register PixelType fg;
+register PixelType bg;
+register unsigned long planemask;
+int depth;
+register unsigned char *rop;
+{
+ register int d;
+ register Pixel mask = 1;
+
+ bg ^= fg;
+
+ for (d = 0; d < depth; d++, mask <<= 1) {
+ if (!(planemask & mask))
+ rop[d] = RROP_NOP;
+ else if (!(bg & mask)) {
+ /* Both fg and bg have a 0 or 1 in this plane */
+ if (fg & mask)
+ rop[d] = RROP_WHITE;
+ else
+ rop[d] = RROP_BLACK;
+ } else {
+ /* Both fg and bg have different bits on this plane */
+ if (fg & mask)
+ rop[d] = RROP_COPY;
+ else
+ rop[d] = RROP_INVERT;
+ }
+ }
+}
+
+void
+afbReduceRop(alu, src, planemask, depth, rop)
+ register int alu;
+ register Pixel src;
+ register unsigned long planemask;
+ int depth;
+ register unsigned char *rop;
+{
+ register int d;
+ register Pixel mask = 1;
+
+ for (d = 0; d < depth; d++, mask <<= 1) {
+ if (!(planemask & mask))
+ rop[d] = RROP_NOP;
+ else if ((src & mask) == 0) /* src is black */
+ switch (alu) {
+ case GXclear:
+ rop[d] = RROP_BLACK;
+ break;
+ case GXand:
+ rop[d] = RROP_BLACK;
+ break;
+ case GXandReverse:
+ rop[d] = RROP_BLACK;
+ break;
+ case GXcopy:
+ rop[d] = RROP_BLACK;
+ break;
+ case GXandInverted:
+ rop[d] = RROP_NOP;
+ break;
+ case GXnoop:
+ rop[d] = RROP_NOP;
+ break;
+ case GXxor:
+ rop[d] = RROP_NOP;
+ break;
+ case GXor:
+ rop[d] = RROP_NOP;
+ break;
+ case GXnor:
+ rop[d] = RROP_INVERT;
+ break;
+ case GXequiv:
+ rop[d] = RROP_INVERT;
+ break;
+ case GXinvert:
+ rop[d] = RROP_INVERT;
+ break;
+ case GXorReverse:
+ rop[d] = RROP_INVERT;
+ break;
+ case GXcopyInverted:
+ rop[d] = RROP_WHITE;
+ break;
+ case GXorInverted:
+ rop[d] = RROP_WHITE;
+ break;
+ case GXnand:
+ rop[d] = RROP_WHITE;
+ break;
+ case GXset:
+ rop[d] = RROP_WHITE;
+ break;
+ }
+ else /* src is white */
+ switch (alu) {
+ case GXclear:
+ rop[d] = RROP_BLACK;
+ break;
+ case GXand:
+ rop[d] = RROP_NOP;
+ break;
+ case GXandReverse:
+ rop[d] = RROP_INVERT;
+ break;
+ case GXcopy:
+ rop[d] = RROP_WHITE;
+ break;
+ case GXandInverted:
+ rop[d] = RROP_BLACK;
+ break;
+ case GXnoop:
+ rop[d] = RROP_NOP;
+ break;
+ case GXxor:
+ rop[d] = RROP_INVERT;
+ break;
+ case GXor:
+ rop[d] = RROP_WHITE;
+ break;
+ case GXnor:
+ rop[d] = RROP_BLACK;
+ break;
+ case GXequiv:
+ rop[d] = RROP_NOP;
+ break;
+ case GXinvert:
+ rop[d] = RROP_INVERT;
+ break;
+ case GXorReverse:
+ rop[d] = RROP_WHITE;
+ break;
+ case GXcopyInverted:
+ rop[d] = RROP_BLACK;
+ break;
+ case GXorInverted:
+ rop[d] = RROP_NOP;
+ break;
+ case GXnand:
+ rop[d] = RROP_INVERT;
+ break;
+ case GXset:
+ rop[d] = RROP_WHITE;
+ break;
+ }
+ }
+}
+
+void
+afbComputeCompositeClip(pGC, pDrawable)
+ GCPtr pGC;
+ DrawablePtr pDrawable;
+{
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ RegionPtr pregWin;
+ Bool freeTmpClip, freeCompClip;
+
+ if (pGC->subWindowMode == IncludeInferiors) {
+ pregWin = NotClippedByChildren(pWin);
+ freeTmpClip = TRUE;
+ } else {
+ pregWin = &pWin->clipList;
+ freeTmpClip = FALSE;
+ }
+ freeCompClip = pGC->freeCompClip;
+
+ /*
+ * if there is no client clip, we can get by with just keeping the
+ * pointer we got, and remembering whether or not should destroy (or
+ * maybe re-use) it later. this way, we avoid unnecessary copying of
+ * regions. (this wins especially if many clients clip by children
+ * and have no client clip.)
+ */
+ if (pGC->clientClipType == CT_NONE) {
+ if (freeCompClip)
+ REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
+ pGC->pCompositeClip = pregWin;
+ pGC->freeCompClip = freeTmpClip;
+ } else {
+ /*
+ * we need one 'real' region to put into the composite clip. if
+ * pregWin the current composite clip are real, we can get rid of
+ * one. if pregWin is real and the current composite clip isn't,
+ * use pregWin for the composite clip. if the current composite
+ * clip is real and pregWin isn't, use the current composite
+ * clip. if neither is real, create a new region.
+ */
+
+ REGION_TRANSLATE(pGC->pScreen, pGC->clientClip,
+ pDrawable->x + pGC->clipOrg.x,
+ pDrawable->y + pGC->clipOrg.y);
+
+ if (freeCompClip) {
+ REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip, pregWin,
+ pGC->clientClip);
+ if (freeTmpClip)
+ REGION_DESTROY(pGC->pScreen, pregWin);
+ } else if (freeTmpClip) {
+ REGION_INTERSECT(pGC->pScreen, pregWin, pregWin, pGC->clientClip);
+ pGC->pCompositeClip = pregWin;
+ } else {
+ pGC->pCompositeClip = REGION_CREATE(pGC->pScreen, NullBox, 0);
+ REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
+ pregWin, pGC->clientClip);
+ }
+ pGC->freeCompClip = TRUE;
+ REGION_TRANSLATE(pGC->pScreen, pGC->clientClip,
+ -(pDrawable->x + pGC->clipOrg.x),
+ -(pDrawable->y + pGC->clipOrg.y));
+ }
+ } /* end of composite clip for a window */
+ else {
+ BoxRec pixbounds;
+
+ /* XXX should we translate by drawable.x/y here ? */
+ pixbounds.x1 = 0;
+ pixbounds.y1 = 0;
+ pixbounds.x2 = pDrawable->width;
+ pixbounds.y2 = pDrawable->height;
+
+ if (pGC->freeCompClip) {
+ REGION_RESET(pGC->pScreen, pGC->pCompositeClip, &pixbounds);
+ } else {
+ pGC->freeCompClip = TRUE;
+ pGC->pCompositeClip = REGION_CREATE(pGC->pScreen, &pixbounds, 1);
+ }
+
+ if (pGC->clientClipType == CT_REGION) {
+ REGION_TRANSLATE(pGC->pScreen, pGC->pCompositeClip, -pGC->clipOrg.x,
+ -pGC->clipOrg.y);
+ REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
+ pGC->pCompositeClip, pGC->clientClip);
+ REGION_TRANSLATE(pGC->pScreen, pGC->pCompositeClip, pGC->clipOrg.x,
+ pGC->clipOrg.y);
+ }
+ } /* end of composite clip for pixmap */
+} /* end afbComputeCompositeClip */
diff --git a/nx-X11/programs/Xserver/afb/afbgetsp.c b/nx-X11/programs/Xserver/afb/afbgetsp.c
new file mode 100644
index 000000000..3cc2e2f6e
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbgetsp.c
@@ -0,0 +1,167 @@
+/* $XFree86: xc/programs/Xserver/afb/afbgetsp.c,v 3.0 1996/08/18 01:45:37 dawes Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbgetsp.c,v 5.10 94/04/17 20:28:24 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "misc.h"
+#include "region.h"
+#include "gc.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "afb.h"
+#include "maskbits.h"
+
+#include "servermd.h"
+
+/* GetSpans -- for each span, gets bits from drawable starting at ppt[i]
+ * and continuing for pwidth[i] bits
+ * Each scanline returned will be server scanline padded, i.e., it will come
+ * out to an integral number of words.
+ */
+/*ARGSUSED*/
+void
+afbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pchardstStart)
+ DrawablePtr pDrawable; /* drawable from which to get bits */
+ int wMax; /* largest value of all *pwidths */
+ register DDXPointPtr ppt; /* points to start copying from */
+ int *pwidth; /* list of number of bits to copy */
+ int nspans; /* number of scanlines to copy */
+ char *pchardstStart; /* where to put the bits */
+{
+ PixelType *pdstStart = (PixelType *)pchardstStart;
+ register PixelType *pdst; /* where to put the bits */
+ register PixelType *psrc; /* where to get the bits */
+ register PixelType tmpSrc; /* scratch buffer for bits */
+ PixelType *psrcBase; /* start of src bitmap */
+ int widthSrc; /* width of pixmap in bytes */
+ int sizeSrc;
+ int depthSrc;
+ register DDXPointPtr pptLast; /* one past last point to get */
+ int xEnd; /* last pixel to copy from */
+ register int nstart;
+ register int d;
+ int nend = 0;
+ int srcStartOver;
+ PixelType startmask, endmask;
+ unsigned int srcBit;
+ int nlMiddle, nl;
+ int w;
+
+ pptLast = ppt + nspans;
+
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, widthSrc, sizeSrc, depthSrc,
+ psrcBase);
+ pdst = pdstStart;
+
+ while(ppt < pptLast) {
+ /* XXX should this really be << PWSH, or * 8, or * PGSZB? */
+ xEnd = min(ppt->x + *pwidth, widthSrc << PWSH);
+ pwidth++;
+ for (d = 0; d < depthSrc; d++) {
+ psrc = afbScanline(psrcBase, ppt->x, ppt->y, widthSrc);
+ psrcBase += sizeSrc; /* @@@ NEXT PLANE @@@ */
+ w = xEnd - ppt->x;
+ srcBit = ppt->x & PIM;
+
+ if (srcBit + w <= PPW)
+ {
+ getandputbits0(psrc, srcBit, w, pdst);
+ pdst++;
+ }
+ else
+ {
+
+ maskbits(ppt->x, w, startmask, endmask, nlMiddle);
+ if (startmask)
+ nstart = PPW - srcBit;
+ else
+ nstart = 0;
+ if (endmask)
+ nend = xEnd & PIM;
+ srcStartOver = srcBit + nstart > PLST;
+ if (startmask)
+ {
+ getandputbits0(psrc, srcBit, nstart, pdst);
+ if(srcStartOver)
+ psrc++;
+ }
+ nl = nlMiddle;
+#ifdef FASTPUTBITS
+ Duff(nl, putbits(*psrc, nstart, PPW, pdst); psrc++; pdst++;);
+#else
+ while (nl--)
+ {
+ tmpSrc = *psrc;
+ putbits(tmpSrc, nstart, PPW, pdst);
+ psrc++;
+ pdst++;
+ }
+#endif
+ if (endmask)
+ {
+ putbits(*psrc, nstart, nend, pdst);
+ if(nstart + nend > PPW)
+ pdst++;
+ }
+ if (startmask || endmask)
+ pdst++;
+ }
+ }
+ ppt++;
+ }
+}
diff --git a/nx-X11/programs/Xserver/afb/afbhrzvert.c b/nx-X11/programs/Xserver/afb/afbhrzvert.c
new file mode 100644
index 000000000..d7ddce1a1
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbhrzvert.c
@@ -0,0 +1,211 @@
+/* $XFree86: xc/programs/Xserver/afb/afbhrzvert.c,v 3.0 1996/08/18 01:45:38 dawes Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbhrzvert.c,v 1.15 94/04/17 20:28:24 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "gc.h"
+#include "window.h"
+#include "pixmap.h"
+#include "region.h"
+
+#include "afb.h"
+#include "maskbits.h"
+
+/* horizontal solid line
+ abs(len) > 1
+*/
+void
+afbHorzS(pbase, nlwidth, sizeDst, depthDst, x1, y1, len, rrops)
+PixelType *pbase; /* pointer to base of bitmap */
+register int nlwidth; /* width in longwords of bitmap */
+int sizeDst;
+int depthDst;
+int x1; /* initial point */
+int y1;
+int len; /* length of line */
+register unsigned char *rrops;
+{
+ register PixelType *addrl;
+ register PixelType startmask;
+ register PixelType endmask;
+ register int nlmiddle;
+ register int d;
+ int saveNLmiddle;
+
+ /* force the line to go left to right
+ but don't draw the last point
+ */
+ if (len < 0) {
+ x1 += len;
+ x1 += 1;
+ len = -len;
+ }
+
+ /* all bits inside same longword */
+ if ( ((x1 & PIM) + len) < PPW) {
+ maskpartialbits(x1, len, startmask);
+
+ for (d = 0; d < depthDst; d++) {
+ addrl = afbScanline(pbase, x1, y1, nlwidth);
+ pbase += sizeDst; /* @@@ NEXT PLANE @@@ */
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ *addrl &= ~startmask;
+ break;
+ case RROP_WHITE:
+ *addrl |= startmask;
+ break;
+ case RROP_INVERT:
+ *addrl ^= startmask;
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ...) */
+ } else {
+ maskbits(x1, len, startmask, endmask, nlmiddle);
+ saveNLmiddle = nlmiddle;
+
+ for (d = 0; d < depthDst; d++) {
+ addrl = afbScanline(pbase, x1, y1, nlwidth);
+ pbase += sizeDst; /* @@@ NEXT PLANE @@@ */
+ nlmiddle = saveNLmiddle;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ if (startmask)
+ *addrl++ &= ~startmask;
+ Duff (nlmiddle, *addrl++ = 0x0);
+ if (endmask)
+ *addrl &= ~endmask;
+ break;
+
+ case RROP_WHITE:
+ if (startmask)
+ *addrl++ |= startmask;
+ Duff (nlmiddle, *addrl++ = ~0);
+ if (endmask)
+ *addrl |= endmask;
+ break;
+
+ case RROP_INVERT:
+ if (startmask)
+ *addrl++ ^= startmask;
+ Duff (nlmiddle, *addrl++ ^= ~0);
+ if (endmask)
+ *addrl ^= endmask;
+ break;
+
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ... ) */
+ }
+}
+
+/* vertical solid line
+ this uses do loops because pcc (Ultrix 1.2, bsd 4.2) generates
+ better code. sigh. we know that len will never be 0 or 1, so
+ it's OK to use it.
+*/
+void
+afbVertS(pbase, nlwidth, sizeDst, depthDst, x1, y1, len, rrops)
+PixelType *pbase; /* pointer to base of bitmap */
+register int nlwidth; /* width in longwords of bitmap */
+int sizeDst;
+int depthDst;
+int x1, y1; /* initial point */
+register int len; /* length of line */
+unsigned char *rrops;
+{
+ register PixelType *addrl;
+ register PixelType bitmask;
+ int saveLen;
+ int d;
+
+ if (len < 0) {
+ nlwidth = -nlwidth;
+ len = -len;
+ }
+
+ saveLen = len;
+
+ for (d = 0; d < depthDst; d++) {
+ addrl = afbScanline(pbase, x1, y1, nlwidth);
+ pbase += sizeDst; /* @@@ NEXT PLANE @@@ */
+ len = saveLen;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ bitmask = mfbGetrmask(x1 & PIM);
+ Duff(len, *addrl &= bitmask; afbScanlineInc(addrl, nlwidth) );
+ break;
+
+ case RROP_WHITE:
+ bitmask = mfbGetmask(x1 & PIM);
+ Duff(len, *addrl |= bitmask; afbScanlineInc(addrl, nlwidth) );
+ break;
+
+ case RROP_INVERT:
+ bitmask = mfbGetmask(x1 & PIM);
+ Duff(len, *addrl ^= bitmask; afbScanlineInc(addrl, nlwidth) );
+ break;
+
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ...) */
+}
diff --git a/nx-X11/programs/Xserver/afb/afbimage.c b/nx-X11/programs/Xserver/afb/afbimage.c
new file mode 100644
index 000000000..353fd6f89
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbimage.c
@@ -0,0 +1,301 @@
+/* $XFree86: xc/programs/Xserver/afb/afbimage.c,v 3.2 1998/03/20 21:04:55 hohndel Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "afb.h"
+#include "maskbits.h"
+#include "servermd.h"
+#include "mfb.h"
+
+void
+afbPutImage(pDraw, pGC, depth, x, y, width, height, leftPad, format, pImage)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int depth, x, y, width, height;
+ int leftPad;
+ int format;
+ char *pImage;
+{
+ PixmapPtr pPixmap;
+
+ if ((width == 0) || (height == 0))
+ return;
+
+ if (format != ZPixmap || depth == 1 || pDraw->depth == 1) {
+ pPixmap = GetScratchPixmapHeader(pDraw->pScreen, width+leftPad, height,
+ depth, depth,
+ BitmapBytePad(width+leftPad),
+ (pointer)pImage);
+ if (!pPixmap)
+ return;
+
+ pGC->fExpose = FALSE;
+ if (format == XYBitmap)
+ (void)(*pGC->ops->CopyPlane)((DrawablePtr)pPixmap, pDraw, pGC, leftPad,
+ 0, width, height, x, y, 1);
+ else {
+#if 0
+ /* XXX: bit plane order wronge ! */
+ pPixmap->drawable.depth = 1;
+ pPixmap->drawable.bitsPerPixel = 1;
+
+ switch (pGC->alu) {
+ case GXcopy:
+ doBitBlt = afbDoBitbltCopy;
+ break;
+ case GXxor:
+ doBitBlt = afbDoBitbltXor;
+ break;
+ case GXcopyInverted:
+ doBitBlt = afbDoBitbltCopyInverted;
+ break;
+ case GXor:
+ doBitBlt = afbDoBitbltOr;
+ break;
+ default:
+ doBitBlt = afbDoBitbltGeneral;
+ break;
+ }
+
+ for (plane = (1L << (pPixmap->drawable.depth - 1)); plane;
+ plane >>= 1) {
+ (void)afbBitBlt((DrawablePtr)pPixmap, pDraw, pGC, leftPad, 0,
+ width, height, x, y, doBitBlt, plane);
+ /* pDraw->devKind += sizeDst; */
+ }
+#else
+ (void)(*pGC->ops->CopyArea)((DrawablePtr)pPixmap, pDraw, pGC, leftPad,
+ 0, width, height, x, y);
+#endif
+ }
+
+ pGC->fExpose = TRUE;
+ FreeScratchPixmapHeader(pPixmap);
+ } else {
+ /* Chunky to planar conversion required */
+
+ PixmapPtr pPixmap;
+ ScreenPtr pScreen = pDraw->pScreen;
+ int widthSrc;
+ int start_srcshift;
+ register int b;
+ register int dstshift;
+ register int shift_step;
+ register PixelType dst;
+ register PixelType srcbits;
+ register PixelType *pdst;
+ register PixelType *psrc;
+ int start_bit;
+ register int nl;
+ register int h;
+ register int d;
+ int sizeDst;
+ PixelType *pdstBase;
+ int widthDst;
+ int depthDst;
+
+ /* Create a tmp pixmap */
+ pPixmap = (pScreen->CreatePixmap)(pScreen, width, height, depth);
+ if (!pPixmap)
+ return;
+
+ afbGetPixelWidthSizeDepthAndPointer((DrawablePtr)pPixmap, widthDst,
+ sizeDst, depthDst, pdstBase);
+
+ widthSrc = PixmapWidthInPadUnits(width, depth);
+ /* XXX: if depth == 8, use fast chunky to planar assembly function.*/
+ if (depth > 4) {
+ start_srcshift = 24;
+ shift_step = 8;
+ } else {
+ start_srcshift = 28;
+ shift_step = 4;
+ }
+
+ for (d = 0; d < depth; d++, pdstBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ start_bit = start_srcshift + d;
+ psrc = (PixelType *)pImage;
+ pdst = pdstBase;
+ h = height;
+
+ while (h--) {
+ dstshift = PPW - 1;
+ dst = 0;
+ nl = widthSrc;
+ while (nl--) {
+ srcbits = *psrc++;
+ for (b = start_bit; b >= 0; b -= shift_step) {
+ dst |= ((srcbits >> b) & 1) << dstshift;
+ if (--dstshift < 0) {
+ dstshift = PPW - 1;
+ *pdst++ = dst;
+ dst = 0;
+ }
+ }
+ }
+ if (dstshift != PPW - 1)
+ *pdst++ = dst;
+ }
+ } /* for (d = ...) */
+
+ pGC->fExpose = FALSE;
+ (void)(*pGC->ops->CopyArea)((DrawablePtr)pPixmap, pDraw, pGC, leftPad, 0,
+ width, height, x, y);
+ pGC->fExpose = TRUE;
+ (*pScreen->DestroyPixmap)(pPixmap);
+ }
+}
+
+void
+afbGetImage(pDrawable, sx, sy, width, height, format, planemask, pdstLine)
+ DrawablePtr pDrawable;
+ int sx, sy, width, height;
+ unsigned int format;
+ unsigned long planemask;
+ char *pdstLine;
+{
+ BoxRec box;
+ DDXPointRec ptSrc;
+ RegionRec rgnDst;
+ ScreenPtr pScreen;
+ PixmapPtr pPixmap;
+
+ if ((width == 0) || (height == 0))
+ return;
+
+ pScreen = pDrawable->pScreen;
+ sx += pDrawable->x;
+ sy += pDrawable->y;
+
+ if (format == XYPixmap || pDrawable->depth == 1) {
+ pPixmap = GetScratchPixmapHeader(pScreen, width, height, 1, 1,
+ BitmapBytePad(width), (pointer)pdstLine);
+ if (!pPixmap)
+ return;
+
+ ptSrc.x = sx;
+ ptSrc.y = sy;
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = width;
+ box.y2 = height;
+ REGION_INIT(pScreen, &rgnDst, &box, 1);
+
+ pPixmap->drawable.depth = 1;
+ pPixmap->drawable.bitsPerPixel = 1;
+ /* dix layer only ever calls GetImage with 1 bit set in planemask
+ * when format is XYPixmap.
+ */
+ afbDoBitblt(pDrawable, (DrawablePtr)pPixmap, GXcopy, &rgnDst, &ptSrc,
+ planemask);
+
+ FreeScratchPixmapHeader(pPixmap);
+ REGION_UNINIT(pScreen, &rgnDst);
+ } else {
+ /* Planar to chunky conversion required */
+
+ PixelType *psrcBits;
+ PixelType *psrcLine;
+ PixelType startmask, endmask;
+ int depthSrc;
+ int widthSrc;
+ int sizeSrc;
+ int sizeDst;
+ int widthDst;
+ register PixelType *psrc;
+ register PixelType *pdst;
+ register PixelType dst;
+ register PixelType srcbits;
+ register int d;
+ register int b;
+ register int dstshift;
+ register int shift_step;
+ register int start_endbit;
+ int start_startbit;
+ register int end_endbit = 0;
+ register int start_dstshift;
+ register int nl;
+ register int h;
+ int nlmiddle;
+
+ widthDst = PixmapWidthInPadUnits(width, pDrawable->depth);
+ sizeDst = widthDst * height;
+
+ /* Clear the dest image */
+ bzero(pdstLine, sizeDst << 2);
+
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, widthSrc, sizeSrc,
+ depthSrc, psrcBits);
+
+ psrcBits = afbScanline(psrcBits, sx, sy, widthSrc);
+
+ start_startbit = PPW - 1 - (sx & PIM);
+ if ((sx & PIM) + width < PPW) {
+ maskpartialbits(sx, width, startmask);
+ nlmiddle = 0;
+ endmask = 0;
+ start_endbit = PPW - ((sx + width) & PIM);
+ } else {
+ maskbits(sx, width, startmask, endmask, nlmiddle);
+ start_endbit = 0;
+ end_endbit = PPW - ((sx + width) & PIM);
+ }
+ /* ZPixmap images have either 4 or 8 bits per pixel dependent on
+ * depth.
+ */
+ if (depthSrc > 4) {
+ start_dstshift = 24;
+ shift_step = 8;
+ } else {
+ start_dstshift = 28;
+ shift_step = 4;
+ }
+#define SHIFT_BITS(start_bit,end_bit) \
+for (b = (start_bit); b >= (end_bit); b--) { \
+ dst |= ((srcbits >> b) & 1) << dstshift; \
+ if ((dstshift -= shift_step) < 0) { \
+ dstshift = start_dstshift + d; \
+ *pdst++ = dst; \
+ dst = *pdst; \
+ } \
+} \
+
+ for (d = 0; d < depthSrc; d++, psrcBits += sizeSrc) { /* @@@ NEXT PLANE @@@ */
+ psrcLine = psrcBits;
+ pdst = (PixelType *)pdstLine;
+ h = height;
+
+ while (h--) {
+ psrc = psrcLine;
+ psrcLine += widthSrc;
+ dst = *pdst;
+ dstshift = start_dstshift + d;
+
+ if (startmask) {
+ srcbits = *psrc++ & startmask;
+ SHIFT_BITS(start_startbit, start_endbit);
+ }
+
+ nl = nlmiddle;
+ while (nl--) {
+ srcbits = *psrc++;
+ SHIFT_BITS(PPW - 1, 0);
+ }
+ if (endmask) {
+ srcbits = *psrc & endmask;
+ SHIFT_BITS(PPW - 1, end_endbit);
+ }
+
+ if (dstshift != start_dstshift + d)
+ *pdst++ = dst;
+ } /* while (h--) */
+ } /* for (d = ...) */
+ }
+}
diff --git a/nx-X11/programs/Xserver/afb/afbimggblt.c b/nx-X11/programs/Xserver/afb/afbimggblt.c
new file mode 100644
index 000000000..28113b448
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbimggblt.c
@@ -0,0 +1,474 @@
+/* $XFree86: xc/programs/Xserver/afb/afbimggblt.c,v 3.1tsi Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbimggblt.c,v 5.17 94/04/17 20:28:25 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "afb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "maskbits.h"
+
+/*
+ we should eventually special-case fixed-width fonts for ImageText.
+
+ this works for fonts with glyphs <= 32 bits wide.
+
+ the clipping calculations are done for worst-case fonts.
+we make no assumptions about the heights, widths, or bearings
+of the glyphs. if we knew that the glyphs are all the same height,
+we could clip the tops and bottoms per clipping box, rather
+than per character per clipping box. if we knew that the glyphs'
+left and right bearings were wlle-behaved, we could clip a single
+character at the start, output until the last unclipped
+character, and then clip the last one. this is all straightforward
+to determine based on max-bounds and min-bounds from the font.
+ there is some inefficiency introduced in the per-character
+clipping to make what's going on clearer.
+
+ (it is possible, for example, for a font to be defined in which the
+next-to-last character in a font would be clipped out, but the last
+one wouldn't. the code below deals with this.)
+
+ Image text looks at the bits in the glyph and the fg and bg in the
+GC. it paints a rectangle, as defined in the protocol dcoument,
+and the paints the characters.
+
+ the register allocations for startmask and endmask may not
+be the right thing. are there two other deserving candidates?
+xoff, pdst, pglyph, and tmpSrc seem like the right things, though.
+*/
+
+void
+afbImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ ExtentInfoRec info; /* used by QueryGlyphExtents() */
+ BoxRec bbox; /* string's bounding box */
+ xRectangle backrect;/* backing rectangle to paint.
+ in the general case, NOT necessarily
+ the same as the string's bounding box
+ */
+
+ CharInfoPtr pci;
+ int xorg, yorg; /* origin of drawable in bitmap */
+ int widthDst; /* width of dst in longwords */
+
+ /* these keep track of the character origin */
+ PixelType *pdstBase;
+ /* points to longword with character origin */
+ int xchar; /* xorigin of char (mod 32) */
+
+ /* these are used for placing the glyph */
+ register int xoff; /* x offset of left edge of glyph (mod 32) */
+ register PixelType *pdst;
+ /* pointer to current longword in dst */
+
+ register int d;
+ int depthDst;
+ int sizeDst;
+ int hSave;
+ int w; /* width of glyph in bits */
+ int h; /* height of glyph */
+ int widthGlyph; /* width of glyph, in bytes */
+ unsigned char rrops[AFB_MAX_DEPTH];
+ register unsigned char *pglyph;
+ /* pointer to current row of glyph */
+ unsigned char *pglyphSave;
+
+ /* used for putting down glyph */
+ register PixelType tmpSrc;
+ /* for getting bits from glyph */
+ register PixelType startmask;
+ register PixelType endmask;
+
+ register int nFirst;/* bits of glyph in current longword */
+ PixelType *pdstSave;
+ int oldFill;
+ afbPrivGC *pPriv = (afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr);
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, widthDst, sizeDst, depthDst,
+ pdstBase);
+
+ QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info);
+
+ backrect.x = x;
+ backrect.y = y - FONTASCENT(pGC->font);
+ backrect.width = info.overallWidth;
+ backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+
+ x += xorg;
+ y += yorg;
+
+ bbox.x1 = x + info.overallLeft;
+ bbox.x2 = x + info.overallRight;
+ bbox.y1 = y - info.overallAscent;
+ bbox.y2 = y + info.overallDescent;
+
+ oldFill = pGC->fillStyle;
+ pGC->fillStyle = FillSolid;
+ afbReduceRop (pGC->alu, pGC->bgPixel, pGC->planemask, pGC->depth,
+ pPriv->rrops);
+ afbPolyFillRect(pDrawable, pGC, 1, &backrect);
+ pGC->fillStyle = oldFill;
+ afbReduceRop (pGC->alu, pGC->fgPixel, pGC->planemask, pGC->depth,
+ pPriv->rrops);
+ afbReduceRop (GXcopy, pGC->fgPixel, pGC->planemask, pGC->depth, rrops);
+
+ /* the faint-hearted can open their eyes now */
+
+ switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox)) {
+ case rgnOUT:
+ break;
+ case rgnIN:
+ pdstBase = afbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
+ xchar = x & PIM;
+
+ while(nglyph--) {
+ pci = *ppci;
+ pglyphSave = FONTGLYPHBITS(pglyphBase, pci);
+ w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
+ hSave = pci->metrics.ascent + pci->metrics.descent;
+ widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
+ /* start at top scanline of glyph */
+ pdstSave = afbScanlineDelta(pdstBase, -pci->metrics.ascent,
+ widthDst);
+
+ /* find correct word in scanline and x offset within it
+ for left edge of glyph
+ */
+ xoff = xchar + pci->metrics.leftSideBearing;
+ if (xoff > PLST) {
+ pdstSave++;
+ xoff &= PIM;
+ } else if (xoff < 0) {
+ xoff += PPW;
+ pdstSave--;
+ }
+
+ for (d = 0; d < depthDst; d++) {
+ h = hSave;
+ pdst = pdstSave;
+ pdstSave += sizeDst; /* @@@ NEXT PLANE @@@ */
+ pglyph = pglyphSave;
+
+ if ((xoff + w) <= PPW) {
+ /* glyph all in one longword */
+ maskpartialbits(xoff, w, startmask);
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst |= SCRRIGHT(tmpSrc, xoff) & startmask;
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ }
+ } else {
+ /* glyph crosses longword boundary */
+ maskPPWbits(xoff, w, startmask, endmask);
+ nFirst = PPW - xoff;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) &= ~(SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst |= SCRRIGHT(tmpSrc, xoff) & startmask;
+ *(pdst+1) |= SCRLEFT(tmpSrc, nFirst) & endmask;
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ }
+ } /* glyph crosses longwords boundary */
+ } /* depth loop */
+ /* update character origin */
+ x += pci->metrics.characterWidth;
+ xchar += pci->metrics.characterWidth;
+ if (xchar > PLST) {
+ xchar -= PPW;
+ pdstBase++;
+ } else if (xchar < 0) {
+ xchar += PPW;
+ pdstBase--;
+ }
+ ppci++;
+ } /* while nglyph-- */
+ break;
+ case rgnPART:
+ {
+ afbTEXTPOS *ppos;
+ int nbox;
+ BoxPtr pbox;
+ RegionPtr cclip;
+ int xpos; /* x position of char origin */
+ int i;
+ BoxRec clip;
+ int leftEdge, rightEdge;
+ int topEdge, bottomEdge;
+ int glyphRow; /* first row of glyph not wholly
+ clipped out */
+ int glyphCol; /* leftmost visible column of glyph */
+#if GETLEFTBITS_ALIGNMENT > 1
+ int getWidth; /* bits to get from glyph */
+#endif
+
+ if(!(ppos = (afbTEXTPOS *)ALLOCATE_LOCAL(nglyph * sizeof(afbTEXTPOS))))
+ return;
+
+ pdstBase = afbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
+ xpos = x;
+ xchar = xpos & PIM;
+
+ for (i = 0; i < nglyph; i++) {
+ pci = ppci[i];
+
+ ppos[i].xpos = xpos;
+ ppos[i].xchar = xchar;
+ ppos[i].leftEdge = xpos + pci->metrics.leftSideBearing;
+ ppos[i].rightEdge = xpos + pci->metrics.rightSideBearing;
+ ppos[i].topEdge = y - pci->metrics.ascent;
+ ppos[i].bottomEdge = y + pci->metrics.descent;
+ ppos[i].pdstBase = pdstBase;
+ ppos[i].widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
+
+ xpos += pci->metrics.characterWidth;
+ xchar += pci->metrics.characterWidth;
+ if (xchar > PLST) {
+ xchar &= PIM;
+ pdstBase++;
+ } else if (xchar < 0) {
+ xchar += PPW;
+ pdstBase--;
+ }
+ }
+
+ cclip = pGC->pCompositeClip;
+ pbox = REGION_RECTS(cclip);
+ nbox = REGION_NUM_RECTS(cclip);
+
+ /* HACK ALERT
+ since we continue out of the loop below so often, it
+ is easier to increment pbox at the top than at the end.
+ don't try this at home.
+ */
+ pbox--;
+ while(nbox--) {
+ pbox++;
+ clip.x1 = max(bbox.x1, pbox->x1);
+ clip.y1 = max(bbox.y1, pbox->y1);
+ clip.x2 = min(bbox.x2, pbox->x2);
+ clip.y2 = min(bbox.y2, pbox->y2);
+ if ((clip.x2<=clip.x1) || (clip.y2<=clip.y1))
+ continue;
+
+ for(i=0; i<nglyph; i++) {
+ pci = ppci[i];
+ xchar = ppos[i].xchar;
+
+ /* clip the left and right edges */
+ if (ppos[i].leftEdge < clip.x1)
+ leftEdge = clip.x1;
+ else
+ leftEdge = ppos[i].leftEdge;
+
+ if (ppos[i].rightEdge > clip.x2)
+ rightEdge = clip.x2;
+ else
+ rightEdge = ppos[i].rightEdge;
+
+ w = rightEdge - leftEdge;
+ if (w <= 0)
+ continue;
+
+ /* clip the top and bottom edges */
+ if (ppos[i].topEdge < clip.y1)
+ topEdge = clip.y1;
+ else
+ topEdge = ppos[i].topEdge;
+
+ if (ppos[i].bottomEdge > clip.y2)
+ bottomEdge = clip.y2;
+ else
+ bottomEdge = ppos[i].bottomEdge;
+
+ hSave = bottomEdge - topEdge;
+ if (hSave <= 0)
+ continue;
+
+ glyphRow = (topEdge - y) + pci->metrics.ascent;
+ widthGlyph = ppos[i].widthGlyph;
+ pglyphSave = FONTGLYPHBITS(pglyphBase, pci);
+ pglyphSave += (glyphRow * widthGlyph);
+
+ glyphCol = (leftEdge - ppos[i].xpos) -
+ (pci->metrics.leftSideBearing);
+#if GETLEFTBITS_ALIGNMENT > 1
+ getWidth = w + glyphCol;
+#endif
+
+ pdstSave = afbScanlineDelta(ppos[i].pdstBase, -(y-topEdge),
+ widthDst);
+ xoff = xchar + (leftEdge - ppos[i].xpos);
+ if (xoff > PLST) {
+ xoff &= PIM;
+ pdstSave++;
+ } else if (xoff < 0) {
+ xoff += PPW;
+ pdstSave--;
+ }
+
+ for (d = 0; d < depthDst; d++) {
+ h = hSave;
+ pdst = pdstSave;
+ pdstSave += sizeDst; /* @@@ NEXT PLANE @@@ */
+ pglyph = pglyphSave;
+
+ if ((xoff + w) <= PPW) {
+ maskpartialbits(xoff, w, startmask);
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst |= SCRRIGHT(tmpSrc, xoff) & startmask;
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ }
+ } else {
+ maskPPWbits(xoff, w, startmask, endmask);
+ nFirst = PPW - xoff;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) &= ~(SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst |= SCRRIGHT(tmpSrc, xoff) & startmask;
+ *(pdst+1) |= SCRLEFT(tmpSrc, nFirst) & endmask;
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ }
+ }
+ } /* depth */
+ } /* for each glyph */
+ } /* while nbox-- */
+ DEALLOCATE_LOCAL(ppos);
+ break;
+ }
+
+ default:
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/afb/afbline.c b/nx-X11/programs/Xserver/afb/afbline.c
new file mode 100644
index 000000000..255ea21c1
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbline.c
@@ -0,0 +1,706 @@
+/* $XFree86: xc/programs/Xserver/afb/afbline.c,v 3.1 1998/03/20 21:04:55 hohndel Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbline.c,v 5.18 94/04/17 20:28:26 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "mistruct.h"
+
+#include "afb.h"
+#include "maskbits.h"
+#include "miline.h"
+
+/* single-pixel lines on a color frame buffer
+
+ NON-SLOPED LINES
+ horizontal lines are always drawn left to right; we have to
+move the endpoints right by one after they're swapped.
+ horizontal lines will be confined to a single band of a
+region. the code finds that band (giving up if the lower
+bound of the band is above the line we're drawing); then it
+finds the first box in that band that contains part of the
+line. we clip the line to subsequent boxes in that band.
+ vertical lines are always drawn top to bottom (y-increasing.)
+this requires adding one to the y-coordinate of each endpoint
+after swapping.
+
+ SLOPED LINES
+ when clipping a sloped line, we bring the second point inside
+the clipping box, rather than one beyond it, and then add 1 to
+the length of the line before drawing it. this lets us use
+the same box for finding the outcodes for both endpoints. since
+the equation for clipping the second endpoint to an edge gives us
+1 beyond the edge, we then have to move the point towards the
+first point by one step on the major axis.
+ eventually, there will be a diagram here to explain what's going
+on. the method uses Cohen-Sutherland outcodes to determine
+outsideness, and a method similar to Pike's layers for doing the
+actual clipping.
+
+*/
+
+void
+#ifdef POLYSEGMENT
+afbSegmentSS(pDrawable, pGC, nseg, pSeg)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nseg;
+ register xSegment *pSeg;
+#else
+afbLineSS(pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt; /* number of points */
+ DDXPointPtr pptInit;
+#endif
+{
+ int nboxInit;
+ register int nbox;
+ BoxPtr pboxInit;
+ register BoxPtr pbox;
+#ifndef POLYSEGMENT
+ register DDXPointPtr ppt; /* pointer to list of translated points */
+#endif
+
+ unsigned int oc1; /* outcode of point 1 */
+ unsigned int oc2; /* outcode of point 2 */
+
+ PixelType *addrlBase; /* pointer to start of drawable */
+ int nlwidth; /* width in longwords of destination pixmap */
+ int xorg, yorg; /* origin of window */
+
+ int adx; /* abs values of dx and dy */
+ int ady;
+ int signdx; /* sign of dx and dy */
+ int signdy;
+ int e, e1, e2; /* bresenham error and increments */
+ int len; /* length of segment */
+ int axis; /* major axis */
+ int octant;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ int depthDst;
+#ifndef POLYSEGMENT
+ PixelType *addrl; /* address of destination pixmap */
+ int d;
+#endif
+ int sizeDst;
+ unsigned char *rrops;
+
+ /* a bunch of temporaries */
+ register int y1, y2;
+ register int x1, x2;
+ RegionPtr cclip;
+
+ cclip = pGC->pCompositeClip;
+ rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
+ pboxInit = REGION_RECTS(cclip);
+ nboxInit = REGION_NUM_RECTS(cclip);
+
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
+ addrlBase);
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+#ifdef POLYSEGMENT
+ while (nseg--)
+#else
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while(--npt)
+#endif
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+#ifdef POLYSEGMENT
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious) {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+#endif
+
+ if (x1 == x2) /* vertical line */
+ {
+ /* make the line go top to bottom of screen, keeping
+ endpoint semantics
+ */
+ if (y1 > y2) {
+ register int tmp;
+
+ tmp = y2;
+ y2 = y1 + 1;
+ y1 = tmp + 1;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ y1--;
+#endif
+ }
+#ifdef POLYSEGMENT
+ else if (pGC->capStyle != CapNotLast)
+ y2++;
+#endif
+ /* get to first band that might contain part of line */
+ while ((nbox) && (pbox->y2 <= y1)) {
+ pbox++;
+ nbox--;
+ }
+
+ if (nbox) {
+ /* stop when lower edge of box is beyond end of line */
+ while((nbox) && (y2 >= pbox->y1)) {
+ if ((x1 >= pbox->x1) && (x1 < pbox->x2)) {
+ int y1t, y2t;
+ /* this box has part of the line in it */
+ y1t = max(y1, pbox->y1);
+ y2t = min(y2, pbox->y2);
+ if (y1t != y2t)
+ afbVertS(addrlBase, nlwidth, sizeDst, depthDst, x1, y1t,
+ y2t-y1t, rrops); /* @@@ NEXT PLANE PASSED @@@ */
+ }
+ nbox--;
+ pbox++;
+ }
+ }
+#ifndef POLYSEGMENT
+ y2 = ppt->y + yorg;
+#endif
+ } else if (y1 == y2) /* horizontal line */ {
+ /* force line from left to right, keeping
+ endpoint semantics
+ */
+ if (x1 > x2) {
+ register int tmp;
+
+ tmp = x2;
+ x2 = x1 + 1;
+ x1 = tmp + 1;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ x1--;
+#endif
+ }
+#ifdef POLYSEGMENT
+ else if (pGC->capStyle != CapNotLast)
+ x2++;
+#endif
+
+ /* find the correct band */
+ while( (nbox) && (pbox->y2 <= y1)) {
+ pbox++;
+ nbox--;
+ }
+
+ /* try to draw the line, if we haven't gone beyond it */
+ if ((nbox) && (pbox->y1 <= y1)) {
+ int tmp;
+
+ /* when we leave this band, we're done */
+ tmp = pbox->y1;
+ while((nbox) && (pbox->y1 == tmp)) {
+ int x1t, x2t;
+
+ if (pbox->x2 <= x1) {
+ /* skip boxes until one might contain start point */
+ nbox--;
+ pbox++;
+ continue;
+ }
+
+ /* stop if left of box is beyond right of line */
+ if (pbox->x1 >= x2) {
+ nbox = 0;
+ break;
+ }
+
+ x1t = max(x1, pbox->x1);
+ x2t = min(x2, pbox->x2);
+ if (x1t != x2t)
+ afbHorzS(addrlBase, nlwidth, sizeDst, depthDst, x1t, y1,
+ x2t-x1t, rrops); /* @@@ NEXT PLANE PASSED @@@ */
+ nbox--;
+ pbox++;
+ }
+ }
+#ifndef POLYSEGMENT
+ x2 = ppt->x + xorg;
+#endif
+ }
+ else /* sloped line */
+ {
+ CalcLineDeltas(x1, y1, x2, y2, adx, ady,
+ signdx, signdy, 1, 1, octant);
+
+ if (adx > ady) {
+ axis = X_AXIS;
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+ } else {
+ axis = Y_AXIS;
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ SetYMajorOctant(octant);
+ }
+
+ FIXUP_ERROR(e, octant, bias);
+
+ /* we have bresenham parameters and two points.
+ all we have to do now is clip and draw.
+ */
+
+ while(nbox--) {
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if ((oc1 | oc2) == 0) {
+ if (axis == X_AXIS)
+ len = adx;
+ else
+ len = ady;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ len++;
+#endif
+ afbBresS(addrlBase, nlwidth, sizeDst, depthDst, signdx, signdy,
+ axis, x1, y1, e, e1, e2, len, rrops); /* @@@ NEXT PLANE PASSED @@@ */
+ break;
+ } else if (oc1 & oc2) {
+ pbox++;
+ } else {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int clipdx, clipdy;
+ int err;
+
+ if (miZeroClipLine(pbox->x1, pbox->y1, pbox->x2-1,
+ pbox->y2-1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1) {
+ pbox++;
+ continue;
+ }
+
+ if (axis == X_AXIS)
+ len = abs(new_x2 - new_x1);
+ else
+ len = abs(new_y2 - new_y1);
+#ifdef POLYSEGMENT
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+#else
+ len += (clip2 != 0);
+#endif
+ if (len) {
+ /* unwind bresenham error term to first point */
+ if (clip1) {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ if (axis == X_AXIS)
+ err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));
+ else
+ err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));
+ }
+ else
+ err = e;
+ afbBresS(addrlBase, nlwidth, sizeDst, depthDst, signdx,
+ signdy, axis, new_x1, new_y1, err, e1, e2, len,
+ rrops); /* @@@ NEXT PLANE PASSED @@@ */
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+ } /* sloped line */
+ } /* while (nline--) */
+
+#ifndef POLYSEGMENT
+
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1))) {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--) {
+ if ((x2 >= pbox->x1) && (y2 >= pbox->y1) && (x2 < pbox->x2) &&
+ (y2 < pbox->y2)) {
+ for (d = 0; d < depthDst; d++) {
+ addrl = afbScanline(addrlBase, x2, y2, nlwidth);
+ addrlBase += sizeDst; /* @@@ NEXT PLANE @@@ */
+
+ switch(rrops[d]) {
+ case RROP_BLACK:
+ *addrl &= mfbGetrmask(x2 & PIM);
+ break;
+ case RROP_WHITE:
+ *addrl |= mfbGetmask(x2 & PIM);
+ break;
+ case RROP_INVERT:
+ *addrl ^= mfbGetmask(x2 & PIM);
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ...) */
+ break;
+ } else
+ pbox++;
+ }
+ }
+#endif
+}
+
+/*
+ * Draw dashed 1-pixel lines.
+ */
+
+void
+#ifdef POLYSEGMENT
+afbSegmentSD(pDrawable, pGC, nseg, pSeg)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int nseg;
+ register xSegment *pSeg;
+#else
+afbLineSD(pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt; /* number of points */
+ DDXPointPtr pptInit;
+#endif
+{
+ int nboxInit;
+ register int nbox;
+ BoxPtr pboxInit;
+ register BoxPtr pbox;
+#ifndef POLYSEGMENT
+ register DDXPointPtr ppt; /* pointer to list of translated points */
+#endif
+
+ register unsigned int oc1; /* outcode of point 1 */
+ register unsigned int oc2; /* outcode of point 2 */
+
+ PixelType *addrlBase; /* address of destination pixmap */
+ int nlwidth; /* width in longwords of destination pixmap */
+ int sizeDst;
+ int depthDst;
+ int xorg, yorg; /* origin of window */
+
+ int adx; /* abs values of dx and dy */
+ int ady;
+ int signdx; /* sign of dx and dy */
+ int signdy;
+ int e, e1, e2; /* bresenham error and increments */
+ int len; /* length of segment */
+ int axis; /* major axis */
+ int octant;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ int x1, x2, y1, y2;
+ RegionPtr cclip;
+ unsigned char *rrops;
+ unsigned char bgrrops[AFB_MAX_DEPTH];
+ unsigned char *pDash;
+ int dashOffset;
+ int numInDashList;
+ int dashIndex;
+ int isDoubleDash;
+ int dashIndexTmp, dashOffsetTmp;
+ int unclippedlen;
+#ifndef POLYSEGMENT
+ PixelType *addrl;
+ int d;
+#endif
+
+ cclip = pGC->pCompositeClip;
+ rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
+ pboxInit = REGION_RECTS(cclip);
+ nboxInit = REGION_NUM_RECTS(cclip);
+
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
+ addrlBase);
+
+ /* compute initial dash values */
+
+ pDash = (unsigned char *) pGC->dash;
+ numInDashList = pGC->numInDashList;
+ isDoubleDash = (pGC->lineStyle == LineDoubleDash);
+ dashIndex = 0;
+ dashOffset = 0;
+ miStepDash ((int)pGC->dashOffset, &dashIndex, pDash,
+ numInDashList, &dashOffset);
+
+ if (isDoubleDash)
+ afbReduceRop (pGC->alu, pGC->bgPixel, pGC->planemask, pGC->depth,
+ bgrrops);
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+#ifdef POLYSEGMENT
+ while (nseg--)
+#else
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while(--npt)
+#endif
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+#ifdef POLYSEGMENT
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious) {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+#endif
+
+ CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy,
+ 1, 1, octant);
+
+ if (adx > ady) {
+ axis = X_AXIS;
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+ unclippedlen = adx;
+ } else {
+ axis = Y_AXIS;
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ unclippedlen = ady;
+ SetYMajorOctant(octant);
+ }
+
+ FIXUP_ERROR(e, octant, bias);
+
+ /* we have bresenham parameters and two points.
+ all we have to do now is clip and draw.
+ */
+
+ while(nbox--) {
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if ((oc1 | oc2) == 0) {
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ unclippedlen++;
+ dashIndexTmp = dashIndex;
+ dashOffsetTmp = dashOffset;
+ afbBresD(&dashIndexTmp, pDash, numInDashList, &dashOffsetTmp,
+ isDoubleDash, addrlBase, nlwidth, sizeDst, depthDst,
+ signdx, signdy, axis, x1, y1, e, e1, e2, unclippedlen,
+ rrops, bgrrops); /* @@@ NEXT PLANE PASSED @@@ */
+ break;
+#else
+ afbBresD(&dashIndex, pDash, numInDashList, &dashOffset,
+ isDoubleDash, addrlBase, nlwidth, sizeDst, depthDst,
+ signdx, signdy, axis, x1, y1, e, e1, e2, unclippedlen,
+ rrops, bgrrops); /* @@@ NEXT PLANE PASSED @@@ */
+ goto dontStep;
+#endif
+ } else if (oc1 & oc2) {
+ pbox++;
+ } else /* have to clip */ {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int clipdx, clipdy;
+ int err;
+
+ if (miZeroClipLine(pbox->x1, pbox->y1, pbox->x2-1, pbox->y2-1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1) {
+ pbox++;
+ continue;
+ }
+ dashIndexTmp = dashIndex;
+ dashOffsetTmp = dashOffset;
+ if (clip1) {
+ int dlen;
+
+ if (axis == X_AXIS)
+ dlen = abs(new_x1 - x1);
+ else
+ dlen = abs(new_y1 - y1);
+ miStepDash (dlen, &dashIndexTmp, pDash,
+ numInDashList, &dashOffsetTmp);
+ }
+ if (axis == X_AXIS)
+ len = abs(new_x2 - new_x1);
+ else
+ len = abs(new_y2 - new_y1);
+#ifdef POLYSEGMENT
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+#else
+ len += (clip2 != 0);
+#endif
+ if (len) {
+ /* unwind bresenham error term to first point */
+ if (clip1) {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ if (axis == X_AXIS)
+ err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));
+ else
+ err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));
+ }
+ else
+ err = e;
+ afbBresD(&dashIndexTmp, pDash, numInDashList, &dashOffsetTmp,
+ isDoubleDash, addrlBase, nlwidth, sizeDst, depthDst,
+ signdx, signdy, axis, new_x1, new_y1, err, e1, e2,
+ len, rrops, bgrrops); /* @@@ NEXT PLANE PASSED @@@ */
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+#ifndef POLYSEGMENT
+ /*
+ * walk the dash list around to the next line
+ */
+ miStepDash (unclippedlen, &dashIndex, pDash,
+ numInDashList, &dashOffset);
+dontStep: ;
+#endif
+ } /* while (nline--) */
+
+#ifndef POLYSEGMENT
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((dashIndex & 1) == 0 || isDoubleDash) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1))) {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--) {
+ if ((x2 >= pbox->x1) && (y2 >= pbox->y1) && (x2 < pbox->x2) &&
+ (y2 < pbox->y2)) {
+ int rop;
+
+ for (d = 0; d < depthDst; d++) {
+ addrl = afbScanline(addrlBase, x2, y2, nlwidth);
+ addrlBase += sizeDst; /* @@@ NEXT PLANE @@@ */
+
+ rop = rrops[d];
+ if (dashIndex & 1)
+ rop = bgrrops[d];
+
+ switch (rop) {
+ case RROP_BLACK:
+ *addrl &= mfbGetrmask(x2 & PIM);
+ break;
+ case RROP_WHITE:
+ *addrl |= mfbGetmask(x2 & PIM);
+ break;
+
+ case RROP_INVERT:
+ *addrl ^= mfbGetmask(x2 & PIM);
+ break;
+
+ case RROP_NOP:
+ break;
+ }
+ } /* for (d = ...) */
+ break;
+ } else
+ pbox++;
+ }
+ }
+#endif
+}
diff --git a/nx-X11/programs/Xserver/afb/afbmisc.c b/nx-X11/programs/Xserver/afb/afbmisc.c
new file mode 100644
index 000000000..e5a4f492d
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbmisc.c
@@ -0,0 +1,96 @@
+/* $XFree86$ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbmisc.c,v 5.4 94/04/17 20:28:27 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "cursor.h"
+#include "scrnintstr.h"
+
+#include "afb.h"
+
+/*ARGSUSED*/
+void
+afbQueryBestSize(class, pwidth, pheight, pScreen)
+int class;
+unsigned short *pwidth;
+unsigned short *pheight;
+ScreenPtr pScreen;
+{
+ unsigned width, test;
+
+ switch(class) {
+ case CursorShape:
+ if (*pwidth > pScreen->width)
+ *pwidth = pScreen->width;
+ if (*pheight > pScreen->height)
+ *pheight = pScreen->height;
+ break;
+ case TileShape:
+ case StippleShape:
+ width = *pwidth;
+ if (!width) break;
+ /* Return the closes power of two not less than what they gave me */
+ test = 0x80000000;
+ /* Find the highest 1 bit in the width given */
+ while(!(test & width))
+ test >>= 1;
+ /* If their number is greater than that, bump up to the next
+ * power of two */
+ if((test - 1) & width)
+ test <<= 1;
+ *pwidth = test;
+ /* We don't care what height they use */
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/afb/afbmodule.c b/nx-X11/programs/Xserver/afb/afbmodule.c
new file mode 100644
index 000000000..d9cdbf9c3
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbmodule.c
@@ -0,0 +1,63 @@
+/* $XFree86: xc/programs/Xserver/afb/afbmodule.c,v 1.1 1999/06/13 13:47:38 dawes Exp $ */
+/*
+ * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef XFree86LOADER
+
+#include "xf86Module.h"
+#include "afb.h"
+
+static MODULESETUPPROTO(afbSetup);
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "afb",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_ANSIC, /* Only need the ansic layer */
+ ABI_ANSIC_VERSION,
+ MOD_CLASS_NONE,
+ {0,0,0,0} /* signature, to be patched into the file by a tool */
+};
+
+XF86ModuleData afbModuleData = { &VersRec, afbSetup, NULL };
+
+static pointer
+afbSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ /* This modules requires mfb, so load it */
+ return LoadSubModule(module, "mfb", NULL, NULL, NULL, NULL,
+ errmaj, errmin);
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/afb/afbpixmap.c b/nx-X11/programs/Xserver/afb/afbpixmap.c
new file mode 100644
index 000000000..c6ae8481c
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbpixmap.c
@@ -0,0 +1,300 @@
+/* $XFree86: xc/programs/Xserver/afb/afbpixmap.c,v 3.0 1996/08/18 01:45:45 dawes Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbpixmap.c,v 5.13 94/04/17 20:28:28 dpw Exp $ */
+
+/* pixmap management
+ written by drewry, september 1986
+
+ on a monchrome device, a pixmap is a bitmap.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xmd.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "maskbits.h"
+
+#include "afb.h"
+#include "mi.h"
+
+#include "servermd.h"
+#include "mfb.h"
+
+PixmapPtr
+afbCreatePixmap(pScreen, width, height, depth)
+ ScreenPtr pScreen;
+ int width;
+ int height;
+ int depth;
+{
+ PixmapPtr pPixmap;
+ size_t datasize;
+ size_t paddedWidth;
+
+ paddedWidth = BitmapBytePad(width);
+
+ if (paddedWidth > 32767 || height > 32767 || depth > 4)
+ return NullPixmap;
+
+ datasize = height * paddedWidth * depth;
+ pPixmap = AllocatePixmap(pScreen, datasize);
+ if (!pPixmap)
+ return(NullPixmap);
+ pPixmap->drawable.type = DRAWABLE_PIXMAP;
+ pPixmap->drawable.class = 0;
+ pPixmap->drawable.pScreen = pScreen;
+ pPixmap->drawable.depth = depth;
+ pPixmap->drawable.bitsPerPixel = depth;
+ pPixmap->drawable.id = 0;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pPixmap->drawable.x = 0;
+ pPixmap->drawable.y = 0;
+ pPixmap->drawable.width = width;
+ pPixmap->drawable.height = height;
+ pPixmap->devKind = paddedWidth;
+ pPixmap->refcnt = 1;
+#ifdef PIXPRIV
+ pPixmap->devPrivate.ptr = datasize ?
+ (pointer)((char *)pPixmap + pScreen->totalPixmapSize) : NULL;
+#else
+ pPixmap->devPrivate.ptr = (pointer)(pPixmap + 1);
+#endif
+ return(pPixmap);
+}
+
+Bool
+afbDestroyPixmap(pPixmap)
+ PixmapPtr pPixmap;
+{
+ if(--pPixmap->refcnt)
+ return(TRUE);
+ xfree(pPixmap);
+ return(TRUE);
+}
+
+
+PixmapPtr
+afbCopyPixmap(pSrc)
+ register PixmapPtr pSrc;
+{
+ register PixmapPtr pDst;
+ int size;
+ ScreenPtr pScreen;
+
+ size = pSrc->drawable.height * pSrc->devKind * pSrc->drawable.depth;
+ pScreen = pSrc->drawable.pScreen;
+ pDst = (*pScreen->CreatePixmap)(pScreen, pSrc->drawable.width,
+ pSrc->drawable.height, pSrc->drawable.depth);
+ if (!pDst)
+ return(NullPixmap);
+ memmove((char *)pDst->devPrivate.ptr, (char *)pSrc->devPrivate.ptr, size);
+ return(pDst);
+}
+
+
+/* replicates a pattern to be a full 32 bits wide.
+ relies on the fact that each scnaline is longword padded.
+ doesn't do anything if pixmap is not a factor of 32 wide.
+ changes width field of pixmap if successful, so that the fast
+ XRotatePixmap code gets used if we rotate the pixmap later.
+
+ calculate number of times to repeat
+ for each scanline of pattern
+ zero out area to be filled with replicate
+ left shift and or in original as many times as needed
+*/
+void
+afbPadPixmap(pPixmap)
+ PixmapPtr pPixmap;
+{
+ register int width = pPixmap->drawable.width;
+ register int h;
+ register PixelType mask;
+ register PixelType *p;
+ register PixelType bits; /* real pattern bits */
+ register int i;
+ int d;
+ int rep; /* repeat count for pattern */
+
+ if (width >= PPW)
+ return;
+
+ rep = PPW/width;
+ if (rep*width != PPW)
+ return;
+
+ mask = mfbGetendtab(width);
+
+ p = (PixelType *)(pPixmap->devPrivate.ptr);
+
+ for (d = 0; d < pPixmap->drawable.depth; d++) {
+ for (h = 0; h < pPixmap->drawable.height; h++) {
+ *p &= mask;
+ bits = *p;
+ for(i = 1; i < rep; i++) {
+ bits = SCRRIGHT(bits, width);
+ *p |= bits;
+ }
+ p++; /* @@@ NEXT PLANE @@@ */
+ }
+ }
+ pPixmap->drawable.width = PPW;
+}
+
+/* Rotates pixmap pPix by w pixels to the right on the screen. Assumes that
+ * words are PPW bits wide, and that the least significant bit appears on the
+ * left.
+ */
+void
+afbXRotatePixmap(pPix, rw)
+ PixmapPtr pPix;
+ register int rw;
+{
+ register PixelType *pw, *pwFinal;
+ register PixelType t;
+
+ if (pPix == NullPixmap)
+ return;
+
+ pw = (PixelType *)pPix->devPrivate.ptr;
+ rw %= (int)pPix->drawable.width;
+ if (rw < 0)
+ rw += (int)pPix->drawable.width;
+ if(pPix->drawable.width == PPW) {
+ pwFinal = pw + pPix->drawable.height * pPix->drawable.depth;
+ while(pw < pwFinal) {
+ t = *pw;
+ *pw++ = SCRRIGHT(t, rw) |
+ (SCRLEFT(t, (PPW-rw)) & mfbGetendtab(rw));
+ }
+ } else {
+ /* We no longer do this. Validate doesn't try to rotate odd-size
+ * tiles or stipples. afbUnnatural<tile/stipple>FS works directly off
+ * the unrotate tile/stipple in the GC
+ */
+ ErrorF("X internal error: trying to rotate odd-sized pixmap.\n");
+ }
+
+}
+
+/* Rotates pixmap pPix by h lines. Assumes that h is always less than
+ pPix->height
+ works on any width.
+ */
+void
+afbYRotatePixmap(pPix, rh)
+ register PixmapPtr pPix;
+ int rh;
+{
+ int nbyDown; /* bytes to move down to row 0; also offset of
+ row rh */
+ int nbyUp; /* bytes to move up to line rh; also
+ offset of first line moved down to 0 */
+ char *pbase;
+ char *ptmp;
+ int height;
+ int d;
+
+ if (pPix == NullPixmap)
+ return;
+ height = (int) pPix->drawable.height;
+ rh %= height;
+ if (rh < 0)
+ rh += height;
+
+ nbyDown = rh * pPix->devKind;
+ nbyUp = (pPix->devKind * height) - nbyDown;
+
+ if(!(ptmp = (char *)ALLOCATE_LOCAL(nbyUp)))
+ return;
+
+ for (d = 0; d < pPix->drawable.depth; d++) {
+ pbase = (char *)pPix->devPrivate.ptr + pPix->devKind * height * d; /* @@@ NEXT PLANE @@@ */
+
+ memmove(ptmp, pbase, nbyUp); /* save the low rows */
+ memmove(pbase, pbase+nbyUp, nbyDown); /* slide the top rows down */
+ memmove(pbase+nbyDown, ptmp, nbyUp); /* move lower rows up to row rh */
+ }
+ DEALLOCATE_LOCAL(ptmp);
+}
+
+void
+afbCopyRotatePixmap(psrcPix, ppdstPix, xrot, yrot)
+ register PixmapPtr psrcPix, *ppdstPix;
+ int xrot, yrot;
+{
+ register PixmapPtr pdstPix;
+
+ if ((pdstPix = *ppdstPix) &&
+ (pdstPix->devKind == psrcPix->devKind) &&
+ (pdstPix->drawable.height == psrcPix->drawable.height) &&
+ (pdstPix->drawable.depth == psrcPix->drawable.depth)) {
+ memmove((char *)pdstPix->devPrivate.ptr,
+ (char *)psrcPix->devPrivate.ptr,
+ psrcPix->drawable.height * psrcPix->devKind *
+ psrcPix->drawable.depth);
+ pdstPix->drawable.width = psrcPix->drawable.width;
+ pdstPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ } else {
+ if (pdstPix)
+ /* FIX XBUG 6168 */
+ (*pdstPix->drawable.pScreen->DestroyPixmap)(pdstPix);
+ *ppdstPix = pdstPix = afbCopyPixmap(psrcPix);
+ if (!pdstPix)
+ return;
+ }
+ afbPadPixmap(pdstPix);
+ if (xrot)
+ afbXRotatePixmap(pdstPix, xrot);
+ if (yrot)
+ afbYRotatePixmap(pdstPix, yrot);
+}
diff --git a/nx-X11/programs/Xserver/afb/afbply1rct.c b/nx-X11/programs/Xserver/afb/afbply1rct.c
new file mode 100644
index 000000000..90e55cf8e
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbply1rct.c
@@ -0,0 +1,300 @@
+/* $XFree86: xc/programs/Xserver/afb/afbply1rct.c,v 3.1 1998/03/20 21:04:56 hohndel Exp $ */
+/*
+ * $XConsortium: afbply1rct.c,v 1.9 94/04/17 20:28:28 dpw Exp $
+ *
+Copyright (c) 1990 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "mistruct.h"
+
+#include "afb.h"
+#include "maskbits.h"
+
+#if defined(mips) || defined(sparc)
+#define GetHighWord(x) (((int)(x)) >> 16)
+#else
+#define GetHighWord(x) (((int)(x)) / 65536)
+#endif
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define intToCoord(i,x,y) (((x) = GetHighWord(i)), ((y) = (int)((short) (i))))
+#define coordToInt(x,y) (((x) << 16) | (y))
+#define intToX(i) (GetHighWord(i))
+#define intToY(i) ((int)((short) i))
+#else
+#define intToCoord(i,x,y) (((x) = (int)((short) (i))), ((y) = GetHighWord(i)))
+#define coordToInt(x,y) (((y) << 16) | (x))
+#define intToX(i) ((int)((short) (i)))
+#define intToY(i) (GetHighWord(i))
+#endif
+
+void
+afbFillPolygonSolid (pDrawable, pGC, shape, mode, count, ptsIn)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int shape;
+ int mode;
+ int count;
+ DDXPointPtr ptsIn;
+{
+ afbPrivGCPtr devPriv;
+ int nlwidth;
+ PixelType *addrl, *addr;
+ int maxy;
+ int origin;
+ register int vertex1, vertex2;
+ int c;
+ BoxPtr extents;
+ int clip;
+ int y;
+ int *vertex1p = NULL, *vertex2p;
+ int *endp;
+ int x1 = 0, x2 = 0;
+ int dx1 = 0, dx2 = 0;
+ int dy1 = 0, dy2 = 0;
+ int e1 = 0, e2 = 0;
+ int step1 = 0, step2 = 0;
+ int sign1 = 0, sign2 = 0;
+ int h;
+ int l, r;
+ PixelType mask, bits = ~((PixelType)0);
+ int nmiddle;
+ register unsigned char *rrops;
+ register int n;
+ register int d;
+ int sizeDst;
+ int depthDst;
+ register PixelType *pdst;
+
+ devPriv = (afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr);
+
+ if (mode == CoordModePrevious || shape != Convex ||
+ REGION_NUM_RECTS(pGC->pCompositeClip) != 1) {
+ miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+ origin = *((int *) &pDrawable->x);
+ origin -= (origin & 0x8000) << 1;
+ extents = &pGC->pCompositeClip->extents;
+ vertex1 = *((int *) &extents->x1) - origin;
+ vertex2 = *((int *) &extents->x2) - origin - 0x00010001;
+ clip = 0;
+ y = 32767;
+ maxy = 0;
+ vertex2p = (int *) ptsIn;
+ endp = vertex2p + count;
+ while (count--) {
+ c = *vertex2p;
+ clip |= (c - vertex1) | (vertex2 - c);
+ c = intToY(c);
+ if (c < y) {
+ y = c;
+ vertex1p = vertex2p;
+ }
+ vertex2p++;
+ if (c > maxy)
+ maxy = c;
+ }
+ if (y == maxy)
+ return;
+
+ if (clip & 0x80008000) {
+ miFillPolygon (pDrawable, pGC, shape, mode, vertex2p - (int *) ptsIn, ptsIn);
+ return;
+ }
+
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
+ addrl);
+ rrops = devPriv->rrops;
+ addrl = afbScanlineDelta(addrl, y + pDrawable->y, nlwidth);
+ origin = intToX(origin);
+ vertex2p = vertex1p;
+ vertex2 = vertex1 = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+#define Setup(c,x,vertex,dx,dy,e,sign,step) {\
+ x = intToX(vertex); \
+ if ((dy = intToY(c) - y)) { \
+ dx = intToX(c) - x; \
+ step = 0; \
+ if (dx >= 0) { \
+ e = 0; \
+ sign = 1; \
+ if (dx >= dy) {\
+ step = dx / dy; \
+ dx = dx % dy; \
+ } \
+ } else { \
+ e = 1 - dy; \
+ sign = -1; \
+ dx = -dx; \
+ if (dx >= dy) { \
+ step = - (dx / dy); \
+ dx = dx % dy; \
+ } \
+ } \
+ } \
+ x += origin; \
+ vertex = c; \
+}
+
+#define Step(x,dx,dy,e,sign,step) {\
+ x += step; \
+ if ((e += dx) > 0) { \
+ x += sign; \
+ e -= dy; \
+ } \
+}
+ for (;;) {
+ if (y == intToY(vertex1)) {
+ do {
+ if (vertex1p == (int *) ptsIn)
+ vertex1p = endp;
+ c = *--vertex1p;
+ Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1)
+ } while (y >= intToY(vertex1));
+ h = dy1;
+ } else {
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ h = intToY(vertex1) - y;
+ }
+ if (y == intToY(vertex2)) {
+ do {
+ c = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+ Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2)
+ } while (y >= intToY(vertex2));
+ if (dy2 < h)
+ h = dy2;
+ } else {
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ if ((c = (intToY(vertex2) - y)) < h)
+ h = c;
+ }
+ /* fill spans for this segment */
+ y += h;
+ for (;;) {
+ l = x1;
+ r = x2;
+ nmiddle = x2 - x1;
+ if (nmiddle < 0) {
+ nmiddle = -nmiddle;
+ l = x2;
+ r = x1;
+ }
+ c = l & PIM;
+ l -= c;
+ l = l >> PWSH;
+ addr = addrl + l;
+ if (c + nmiddle < PPW) {
+ mask = SCRRIGHT (bits,c) ^ SCRRIGHT (bits,c+nmiddle);
+ for (pdst = addr, d = 0; d < depthDst; d++, pdst += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ *pdst &= ~mask;
+ break;
+ case RROP_WHITE:
+ *pdst |= mask;
+ break;
+ case RROP_INVERT:
+ *pdst ^= mask;
+ break;
+ case RROP_NOP:
+ break;
+ }
+ }
+ } else {
+ if (c) {
+ mask = SCRRIGHT(bits, c);
+ for (pdst = addr, d = 0; d < depthDst; d++, pdst += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ *pdst &= ~mask;
+ break;
+ case RROP_WHITE:
+ *pdst |= mask;
+ break;
+ case RROP_INVERT:
+ *pdst ^= mask;
+ break;
+ case RROP_NOP:
+ break;
+ }
+ }
+ nmiddle += c - PPW;
+ addr++;
+ }
+ nmiddle >>= PWSH;
+ mask = ~SCRRIGHT(bits, r & PIM);
+
+ for (d = 0; d < depthDst; d++, addr += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ n = nmiddle;
+ pdst = addr;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ Duff (n, *pdst++ = 0;)
+ if (mask)
+ *pdst &= ~mask;
+ break;
+ case RROP_WHITE:
+ Duff (n, *pdst++ = ~0;);
+ if (mask)
+ *pdst |= mask;
+ break;
+ case RROP_INVERT:
+ Duff (n, *pdst++ ^= ~0;);
+ if (mask)
+ *pdst ^= mask;
+ break;
+ case RROP_NOP:
+ break;
+ }
+ }
+ }
+ if (!--h)
+ break;
+ afbScanlineInc(addrl, nlwidth);
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ }
+ if (y == maxy)
+ break;
+ afbScanlineInc(addrl, nlwidth);
+ }
+}
diff --git a/nx-X11/programs/Xserver/afb/afbplygblt.c b/nx-X11/programs/Xserver/afb/afbplygblt.c
new file mode 100644
index 000000000..7d4f5ddd7
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbplygblt.c
@@ -0,0 +1,465 @@
+/* $XFree86: xc/programs/Xserver/afb/afbplygblt.c,v 3.2tsi Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbimggblt.c,v 5.17 94/04/17 20:28:25 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "afb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "maskbits.h"
+
+/*
+ this works for fonts with glyphs <= 32 bits wide.
+
+ the clipping calculations are done for worst-case fonts.
+we make no assumptions about the heights, widths, or bearings
+of the glyphs. if we knew that the glyphs are all the same height,
+we could clip the tops and bottoms per clipping box, rather
+than per character per clipping box. if we knew that the glyphs'
+left and right bearings were wlle-behaved, we could clip a single
+character at the start, output until the last unclipped
+character, and then clip the last one. this is all straightforward
+to determine based on max-bounds and min-bounds from the font.
+ there is some inefficiency introduced in the per-character
+clipping to make what's going on clearer.
+
+ (it is possible, for example, for a font to be defined in which the
+next-to-last character in a font would be clipped out, but the last
+one wouldn't. the code below deals with this.)
+
+*/
+
+void
+afbPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ ExtentInfoRec info; /* used by QueryGlyphExtents() */
+ BoxRec bbox; /* string's bounding box */
+
+ CharInfoPtr pci;
+ int xorg, yorg; /* origin of drawable in bitmap */
+ int widthDst; /* width of dst in longwords */
+
+ /* these keep track of the character origin */
+ PixelType *pdstBase;
+ /* points to longword with character origin */
+ int xchar; /* xorigin of char (mod 32) */
+
+ /* these are used for placing the glyph */
+ register int xoff; /* x offset of left edge of glyph (mod 32) */
+ register PixelType *pdst; /* pointer to current longword in dst */
+
+ register int d;
+ int depthDst;
+ int sizeDst;
+ int hSave;
+ int w; /* width of glyph in bits */
+ int h; /* height of glyph */
+ int widthGlyph; /* width of glyph, in bytes */
+ unsigned char *rrops;
+ register unsigned char *pglyph;
+ /* pointer to current row of glyph */
+ unsigned char *pglyphSave;
+
+ /* used for putting down glyph */
+ register PixelType tmpSrc;
+ /* for getting bits from glyph */
+ register PixelType startmask;
+ register PixelType endmask;
+
+ register int nFirst; /* bits of glyph in current longword */
+ PixelType *pdstSave;
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, widthDst, sizeDst, depthDst,
+ pdstBase);
+
+ QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info);
+
+ x += xorg;
+ y += yorg;
+
+ bbox.x1 = x + info.overallLeft;
+ bbox.x2 = x + info.overallRight;
+ bbox.y1 = y - info.overallAscent;
+ bbox.y2 = y + info.overallDescent;
+
+ rrops = ((afbPrivGCPtr) pGC->devPrivates[afbGCPrivateIndex].ptr)->rrops;
+
+ switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox)) {
+ case rgnOUT:
+ break;
+ case rgnIN:
+ pdstBase = afbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
+ xchar = x & PIM;
+
+ while(nglyph--) {
+ pci = *ppci;
+ pglyphSave = FONTGLYPHBITS(pglyphBase, pci);
+ w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
+ hSave = pci->metrics.ascent + pci->metrics.descent;
+ widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
+ /* start at top scanline of glyph */
+ pdstSave = afbScanlineDelta(pdstBase, -pci->metrics.ascent,
+ widthDst);
+
+ /* find correct word in scanline and x offset within it
+ for left edge of glyph
+ */
+ xoff = xchar + pci->metrics.leftSideBearing;
+ if (xoff > PLST) {
+ pdstSave++;
+ xoff &= PIM;
+ } else if (xoff < 0) {
+ xoff += PPW;
+ pdstSave--;
+ }
+
+ for (d = 0; d < depthDst; d++) {
+ h = hSave;
+ pdst = pdstSave;
+ pdstSave += sizeDst; /* @@@ NEXT PLANE @@@ */
+ pglyph = pglyphSave;
+
+ if ((xoff + w) <= PPW) {
+ /* glyph all in one longword */
+ maskpartialbits(xoff, w, startmask);
+ switch (rrops[d]) {
+ case RROP_WHITE:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst |= (SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ case RROP_BLACK:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst ^= (SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ }
+ } else {
+ /* glyph crosses longword boundary */
+ maskPPWbits(xoff, w, startmask, endmask);
+ nFirst = PPW - xoff;
+ switch (rrops[d]) {
+ case RROP_WHITE:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst |= (SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) |= (SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ case RROP_BLACK:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) &= ~(SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst ^= (SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) ^= (SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ }
+ } /* glyph crosses longwords boundary */
+ } /* depth loop */
+ /* update character origin */
+ x += pci->metrics.characterWidth;
+ xchar += pci->metrics.characterWidth;
+ if (xchar > PLST) {
+ xchar -= PPW;
+ pdstBase++;
+ } else if (xchar < 0) {
+ xchar += PPW;
+ pdstBase--;
+ }
+ ppci++;
+ } /* while nglyph-- */
+ break;
+ case rgnPART:
+ {
+ afbTEXTPOS *ppos;
+ int nbox;
+ BoxPtr pbox;
+ RegionPtr cclip;
+ int xpos; /* x position of char origin */
+ int i;
+ BoxRec clip;
+ int leftEdge, rightEdge;
+ int topEdge, bottomEdge;
+ int glyphRow; /* first row of glyph not wholly
+ clipped out */
+ int glyphCol; /* leftmost visible column of glyph */
+#if GETLEFTBITS_ALIGNMENT > 1
+ int getWidth; /* bits to get from glyph */
+#endif
+
+ if(!(ppos = (afbTEXTPOS *)ALLOCATE_LOCAL(nglyph * sizeof(afbTEXTPOS))))
+ return;
+
+ pdstBase = afbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
+ xpos = x;
+ xchar = xpos & PIM;
+
+ for (i = 0; i < nglyph; i++) {
+ pci = ppci[i];
+
+ ppos[i].xpos = xpos;
+ ppos[i].xchar = xchar;
+ ppos[i].leftEdge = xpos + pci->metrics.leftSideBearing;
+ ppos[i].rightEdge = xpos + pci->metrics.rightSideBearing;
+ ppos[i].topEdge = y - pci->metrics.ascent;
+ ppos[i].bottomEdge = y + pci->metrics.descent;
+ ppos[i].pdstBase = pdstBase;
+ ppos[i].widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
+
+ xpos += pci->metrics.characterWidth;
+ xchar += pci->metrics.characterWidth;
+ if (xchar > PLST) {
+ xchar &= PIM;
+ pdstBase++;
+ } else if (xchar < 0) {
+ xchar += PPW;
+ pdstBase--;
+ }
+ }
+
+ cclip = pGC->pCompositeClip;
+ pbox = REGION_RECTS(cclip);
+ nbox = REGION_NUM_RECTS(cclip);
+
+ /* HACK ALERT
+ since we continue out of the loop below so often, it
+ is easier to increment pbox at the top than at the end.
+ don't try this at home.
+ */
+ pbox--;
+ while(nbox--) {
+ pbox++;
+ clip.x1 = max(bbox.x1, pbox->x1);
+ clip.y1 = max(bbox.y1, pbox->y1);
+ clip.x2 = min(bbox.x2, pbox->x2);
+ clip.y2 = min(bbox.y2, pbox->y2);
+ if ((clip.x2<=clip.x1) || (clip.y2<=clip.y1))
+ continue;
+
+ for(i=0; i<nglyph; i++) {
+ pci = ppci[i];
+ xchar = ppos[i].xchar;
+
+ /* clip the left and right edges */
+ if (ppos[i].leftEdge < clip.x1)
+ leftEdge = clip.x1;
+ else
+ leftEdge = ppos[i].leftEdge;
+
+ if (ppos[i].rightEdge > clip.x2)
+ rightEdge = clip.x2;
+ else
+ rightEdge = ppos[i].rightEdge;
+
+ w = rightEdge - leftEdge;
+ if (w <= 0)
+ continue;
+
+ /* clip the top and bottom edges */
+ if (ppos[i].topEdge < clip.y1)
+ topEdge = clip.y1;
+ else
+ topEdge = ppos[i].topEdge;
+
+ if (ppos[i].bottomEdge > clip.y2)
+ bottomEdge = clip.y2;
+ else
+ bottomEdge = ppos[i].bottomEdge;
+
+ hSave = bottomEdge - topEdge;
+ if (hSave <= 0)
+ continue;
+
+ glyphRow = (topEdge - y) + pci->metrics.ascent;
+ widthGlyph = ppos[i].widthGlyph;
+ pglyphSave = FONTGLYPHBITS(pglyphBase, pci);
+ pglyphSave += (glyphRow * widthGlyph);
+
+ glyphCol = (leftEdge - ppos[i].xpos) -
+ (pci->metrics.leftSideBearing);
+#if GETLEFTBITS_ALIGNMENT > 1
+ getWidth = w + glyphCol;
+#endif
+
+ pdstSave = afbScanlineDelta(ppos[i].pdstBase, -(y-topEdge),
+ widthDst);
+ xoff = xchar + (leftEdge - ppos[i].xpos);
+ if (xoff > PLST) {
+ xoff &= PIM;
+ pdstSave++;
+ } else if (xoff < 0) {
+ xoff += PPW;
+ pdstSave--;
+ }
+
+ for (d = 0; d < depthDst; d++) {
+ h = hSave;
+ pdst = pdstSave;
+ pdstSave += sizeDst; /* @@@ NEXT PLANE @@@ */
+ pglyph = pglyphSave;
+
+ if ((xoff + w) <= PPW) {
+ maskpartialbits(xoff, w, startmask);
+ switch (rrops[d]) {
+ case RROP_WHITE:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst |= (SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ case RROP_BLACK:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst ^= (SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ }
+ } else {
+ maskPPWbits(xoff, w, startmask, endmask);
+ nFirst = PPW - xoff;
+ switch (rrops[d]) {
+ case RROP_WHITE:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst |= (SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) |= (SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ case RROP_BLACK:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) &= ~(SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst ^= (SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) ^= (SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ afbScanlineInc(pdst, widthDst);
+ }
+ break;
+ }
+ }
+ } /* depth */
+ } /* for each glyph */
+ } /* while nbox-- */
+ DEALLOCATE_LOCAL(ppos);
+ break;
+ }
+
+ default:
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/afb/afbpntarea.c b/nx-X11/programs/Xserver/afb/afbpntarea.c
new file mode 100644
index 000000000..648a2d19c
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbpntarea.c
@@ -0,0 +1,657 @@
+/* $XFree86: xc/programs/Xserver/afb/afbpntarea.c,v 3.0 1996/08/18 01:45:49 dawes Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbpntarea.c,v 5.7 94/04/17 20:28:29 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "windowstr.h"
+#include "regionstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "afb.h"
+#include "maskbits.h"
+
+/*
+ the solid fillers are called for rectangles and window backgrounds.
+ the boxes are already translated.
+ maybe this should always take a pixmap instead of a drawable?
+
+ NOTE:
+ iy = ++iy < tileHeight ? iy : 0
+is equivalent to iy%= tileheight, and saves a division.
+*/
+
+/*ARGSUSED*/
+void
+afbSolidFillArea (pDraw, nbox, pbox, rrops)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ register unsigned char *rrops;
+{
+ int nlwidth; /* width in longwords of the drawable */
+ int w; /* width of current box */
+ register int h; /* height of current box */
+ register PixelType *p; /* pointer to bits we're writing */
+ register int nlw; /* loop version of nlwMiddle */
+ register PixelType startmask;
+ register PixelType endmask;
+ /* masks for reggedy bits at either end of line */
+ register int nlwExtra;
+ /* to get from right of box to left of next span */
+ int nlwMiddle; /* number of longwords between sides of boxes */
+ PixelType *pbits; /* pointer to start of drawable */
+ PixelType *saveP;
+ int saveH;
+ int depthDst;
+ int sizeDst;
+ register int d;
+
+ afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
+ pbits);
+
+ while (nbox--) {
+ w = pbox->x2 - pbox->x1;
+ saveH = pbox->y2 - pbox->y1;
+
+ saveP = afbScanline(pbits, pbox->x1, pbox->y1, nlwidth);
+
+ if ( ((pbox->x1 & PIM) + w) < PPW) {
+ for (d = 0; d < depthDst; d++) {
+ h = saveH;
+ p = saveP;
+ saveP += sizeDst; /* @@@ NEXT PLANE @@@ */
+ maskpartialbits(pbox->x1, w, startmask);
+ nlwExtra = nlwidth;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ Duff(h, *p &= ~startmask; afbScanlineInc(p, nlwExtra));
+ break;
+ case RROP_WHITE:
+ Duff(h, *p |= startmask; afbScanlineInc(p, nlwExtra));
+ break;
+ case RROP_INVERT:
+ Duff(h, *p ^= startmask; afbScanlineInc(p, nlwExtra));
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ..) */
+ } else {
+ maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
+
+ for (d = 0; d < depthDst; d++) {
+ h = saveH;
+ p = saveP;
+ saveP += sizeDst; /* @@@ NEXT PLANE @@@ */
+ nlwExtra = nlwidth - nlwMiddle;
+
+ if (startmask && endmask) {
+ nlwExtra -= 1;
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ nlw = nlwMiddle;
+ *p &= ~startmask;
+ p++;
+ Duff(nlw, *p++ = 0);
+ *p &= ~endmask;
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ nlw = nlwMiddle;
+ *p |= startmask;
+ p++;
+ Duff(nlw, *p++ = ~0);
+ *p |= endmask;
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ nlw = nlwMiddle;
+ *p ^= startmask;
+ p++;
+ Duff(nlw, *p++ ^= ~0);
+ *p ^= endmask;
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ }
+ } else if (startmask && !endmask) {
+ nlwExtra -= 1;
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ nlw = nlwMiddle;
+ *p &= ~startmask;
+ p++;
+ Duff(nlw, *p++ = 0);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ nlw = nlwMiddle;
+ *p |= startmask;
+ p++;
+ Duff(nlw, *p++ = ~0);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ nlw = nlwMiddle;
+ *p ^= startmask;
+ p++;
+ Duff(nlw, *p++ ^= ~0);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ }
+ } else if (!startmask && endmask) {
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ = 0);
+ *p &= ~endmask;
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ = ~0);
+ *p |= endmask;
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ ^= ~0);
+ *p ^= endmask;
+ afbScanlineInc(p, nlwExtra);
+ }
+ case RROP_NOP:
+ break;
+ }
+ } else { /* no ragged bits at either end */
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ = 0);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ = ~0);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ ^= ~0);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ }
+ } /* for (d = 0 ... ) */
+ }
+ pbox++;
+ }
+}
+
+/* stipple a list of boxes -
+
+you can use the reduced rasterop for stipples. if rrop is
+black, AND the destination with (not stipple pattern). if rrop is
+white OR the destination with the stipple pattern. if rrop is invert,
+XOR the destination with the stipple pattern.
+*/
+
+/*ARGSUSED*/
+void
+afbStippleAreaPPW (pDraw, nbox, pbox, pstipple, rrops)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ PixmapPtr pstipple;
+ unsigned char *rrops;
+{
+ register PixelType *psrc;
+ /* pointer to bits in tile, if needed */
+ int tileHeight; /* height of the tile */
+ register PixelType srcpix;
+
+ int nlwidth; /* width in longwords of the drawable */
+ int w; /* width of current box */
+ register int nlw; /* loop version of nlwMiddle */
+ register PixelType *p; /* pointer to bits we're writing */
+ register int h; /* height of current box */
+ PixelType startmask;
+ PixelType endmask; /* masks for reggedy bits at either end of line */
+ int nlwMiddle; /* number of longwords between sides of boxes */
+ int nlwExtra; /* to get from right of box to left of next span */
+ int sizeDst;
+ int depthDst;
+ int d;
+ int saveIy;
+ register int iy; /* index of current scanline in tile */
+ PixelType *pbits; /* pointer to start of drawable */
+ PixelType *pBase;
+
+ afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
+ pBase);
+
+ tileHeight = pstipple->drawable.height;
+ psrc = (PixelType *)(pstipple->devPrivate.ptr);
+
+ while (nbox--) {
+ w = pbox->x2 - pbox->x1;
+ saveIy = pbox->y1 % tileHeight;
+ pbits = pBase;
+
+ if ( ((pbox->x1 & PIM) + w) < PPW) {
+ maskpartialbits(pbox->x1, w, startmask);
+ nlwExtra = nlwidth;
+ for (d = 0; d < depthDst; d++) {
+ p = afbScanline(pbits, pbox->x1, pbox->y1, nlwidth);
+ pbits += sizeDst; /* @@@ NEXT PLANE @@@ */
+ iy = saveIy;
+ h = pbox->y2 - pbox->y1;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ *p &= ~(srcpix & startmask);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ *p |= (srcpix & startmask);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ *p ^= (srcpix & startmask);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ...) */
+
+ } else {
+ maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
+
+ for (d = 0; d < depthDst; d++) {
+ nlwExtra = nlwidth - nlwMiddle;
+ p = afbScanline(pbits, pbox->x1, pbox->y1, nlwidth);
+ pbits += sizeDst; /* @@@ NEXT PLANE @@@ */
+ iy = saveIy;
+ h = pbox->y2 - pbox->y1;
+
+ if (startmask && endmask) {
+ nlwExtra -= 1;
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ *p &= ~(srcpix & startmask);
+ p++;
+ Duff (nlw, *p++ &= ~srcpix);
+ *p &= ~(srcpix & endmask);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ *p |= (srcpix & startmask);
+ p++;
+ Duff (nlw, *p++ |= srcpix);
+ *p |= (srcpix & endmask);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ *p ^= (srcpix & startmask);
+ p++;
+ Duff (nlw, *p++ ^= srcpix);
+ *p ^= (srcpix & endmask);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } else if (startmask && !endmask) {
+ nlwExtra -= 1;
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ *p &= ~(srcpix & startmask);
+ p++;
+ Duff(nlw, *p++ &= ~srcpix);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ *p |= (srcpix & startmask);
+ p++;
+ Duff(nlw, *p++ |= srcpix);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ *p ^= (srcpix & startmask);
+ p++;
+ Duff(nlw, *p++ ^= srcpix);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } else if (!startmask && endmask) {
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ &= ~srcpix);
+ *p &= ~(srcpix & endmask);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ |= srcpix);
+ *p |= (srcpix & endmask);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ ^= srcpix);
+ *p ^= (srcpix & endmask);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } else { /* no ragged bits at either end */
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ &= ~srcpix);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ |= srcpix);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ ^= srcpix);
+ afbScanlineInc(p, nlwExtra);
+ }
+ break;
+ } /* switch */
+ }
+ } /* for (d = ...) */
+ }
+ pbox++;
+ }
+}
+
+void
+afbStippleArea (pDraw, nbox, pbox, pTile, xOff, yOff, rrops)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ PixmapPtr pTile;
+ int xOff;
+ int yOff;
+ unsigned char *rrops;
+{
+ register PixelType *psrc; /* pointer to bits in tile, if needed */
+ int nlwidth; /* width in longwords of the drawable */
+ register int h; /* height of current box */
+ register PixelType *pdst; /* pointer to bits we're writing */
+ int sizeDst;
+ int depthDst;
+ int tileLine;
+ int iline;
+ int w, width, x, xSrc, ySrc, srcStartOver, nend;
+ int tlwidth, rem, tileWidth, tileHeight, endinc;
+ int saveW;
+ register int rop;
+ PixelType *psrcT;
+ int d;
+ int nstart;
+ PixelType startmask;
+ PixelType endmask; /* masks for reggedy bits at either end of line */
+ int nlMiddle; /* number of longwords between sides of boxes */
+ int iy;
+ PixelType *pBase; /* pointer to start of drawable */
+ PixelType *saveP;
+ PixelType *pStartDst;
+ PixelType *pStartTile;
+ int saveH;
+
+ afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
+ pBase);
+
+ tileHeight = pTile->drawable.height;
+ tileWidth = pTile->drawable.width;
+ tlwidth = pTile->devKind / sizeof (PixelType);
+
+ xSrc = pDraw->x + ((xOff % tileWidth) - tileWidth);
+ ySrc = pDraw->y + ((yOff % tileHeight) - tileHeight);
+
+ while (nbox--) {
+ saveW = pbox->x2 - pbox->x1;
+ iline = (pbox->y1 - ySrc) % tileHeight;
+ psrcT = (PixelType *) pTile->devPrivate.ptr;
+ tileLine = iline * tlwidth;
+ saveH = pbox->y2 - pbox->y1;
+ saveP = afbScanline(pBase, pbox->x1, pbox->y1, nlwidth);
+
+ for (d = 0; d < depthDst; d++, saveP += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ h = saveH;
+ pStartDst = saveP;
+ pStartTile = psrcT + tileLine;
+ iy = iline;
+
+ while (h--) {
+ x = pbox->x1;
+ width = saveW;
+ pdst = pStartDst;
+ rop = rrops[d];
+
+ while(width > 0) {
+ psrc = pStartTile;
+ w = min(tileWidth, width);
+ if((rem = (x - xSrc) % tileWidth) != 0) {
+ /* if we're in the middle of the tile, get
+ as many bits as will finish the span, or
+ as many as will get to the left edge of the tile,
+ or a longword worth, starting at the appropriate
+ offset in the tile.
+ */
+ w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
+ endinc = rem / BITMAP_SCANLINE_PAD;
+ getandputrrop((psrc + endinc), (rem & PIM), (x & PIM),
+ w, pdst, rop)
+ if((x & PIM) + w >= PPW)
+ pdst++;
+ } else if(((x & PIM) + w) < PPW) {
+ /* doing < PPW bits is easy, and worth special-casing */
+ putbitsrrop(*psrc, x & PIM, w, pdst, rop);
+ } else {
+ /* start at the left edge of the tile,
+ and put down as much as we can
+ */
+ maskbits(x, w, startmask, endmask, nlMiddle);
+
+ if (startmask)
+ nstart = PPW - (x & PIM);
+ else
+ nstart = 0;
+ if (endmask)
+ nend = (x + w) & PIM;
+ else
+ nend = 0;
+
+ srcStartOver = nstart > PLST;
+
+ if(startmask) {
+ putbitsrrop(*psrc, (x & PIM), nstart, pdst, rop);
+ pdst++;
+ if(srcStartOver)
+ psrc++;
+ }
+
+ while(nlMiddle--) {
+ getandputrrop0(psrc, nstart, PPW, pdst, rop);
+ pdst++;
+ psrc++;
+ }
+
+ if(endmask) {
+ getandputrrop0(psrc, nstart, nend, pdst, rop);
+ }
+ }
+ x += w;
+ width -= w;
+ } /* while (width > 0) */
+
+ pStartDst += nlwidth;
+ if (++iy >= tileHeight) {
+ iy = 0;
+ pStartTile = psrcT;
+ } else
+ pStartTile += tlwidth;
+
+ } /* while (h) */
+ } /* for (d = ... ) */
+ pbox++;
+ } /* for each box */
+}
diff --git a/nx-X11/programs/Xserver/afb/afbpntwin.c b/nx-X11/programs/Xserver/afb/afbpntwin.c
new file mode 100644
index 000000000..aaa6847a9
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbpntwin.c
@@ -0,0 +1,128 @@
+/* $XFree86$ */
+/* $XConsortium: afbpntwin.c,v 5.12 94/04/17 20:28:30 dpw Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "windowstr.h"
+#include "regionstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "afb.h"
+#include "maskbits.h"
+#include "mi.h"
+
+void
+afbPaintWindow(pWin, pRegion, what)
+ WindowPtr pWin;
+ RegionPtr pRegion;
+ int what;
+{
+ register afbPrivWin *pPrivWin;
+ unsigned char rrops[AFB_MAX_DEPTH];
+
+ pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
+
+ switch (what) {
+ case PW_BACKGROUND:
+ switch (pWin->backgroundState) {
+ case None:
+ return;
+ case ParentRelative:
+ do {
+ pWin = pWin->parent;
+ } while (pWin->backgroundState == ParentRelative);
+ (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
+ what);
+ return;
+ case BackgroundPixmap:
+ if (pPrivWin->fastBackground) {
+ afbTileAreaPPWCopy((DrawablePtr)pWin,
+ REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion), GXcopy,
+ pPrivWin->pRotatedBackground, ~0);
+ return;
+ } else {
+ afbTileAreaCopy((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion), GXcopy,
+ pWin->background.pixmap, 0, 0, ~0);
+ return;
+ }
+ break;
+ case BackgroundPixel:
+ afbReduceRop(GXcopy, pWin->background.pixel, ~0,
+ pWin->drawable.depth, rrops);
+ afbSolidFillArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion), rrops);
+ return;
+ }
+ break;
+ case PW_BORDER:
+ if (pWin->borderIsPixel) {
+ afbReduceRop(GXcopy, pWin->border.pixel, ~0, pWin->drawable.depth,
+ rrops);
+ afbSolidFillArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion), rrops);
+ return;
+ } else if (pPrivWin->fastBorder) {
+ afbTileAreaPPWCopy((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion), GXcopy,
+ pPrivWin->pRotatedBorder, ~0);
+ return;
+ }
+ break;
+ }
+ miPaintWindow(pWin, pRegion, what);
+}
diff --git a/nx-X11/programs/Xserver/afb/afbpolypnt.c b/nx-X11/programs/Xserver/afb/afbpolypnt.c
new file mode 100644
index 000000000..4e9fa0310
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbpolypnt.c
@@ -0,0 +1,148 @@
+/* $XFree86: xc/programs/Xserver/afb/afbpolypnt.c,v 3.1 1998/03/20 21:04:56 hohndel Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbpolypnt.c,v 5.6 94/04/17 20:28:30 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "pixmapstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+
+#include "afb.h"
+#include "maskbits.h"
+
+void
+afbPolyPoint(pDrawable, pGC, mode, npt, pptInit)
+ register DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt;
+ xPoint *pptInit;
+{
+
+ register BoxPtr pbox;
+ register int nbox;
+ register int d;
+
+ register PixelType *addrl;
+ PixelType *pBase;
+ PixelType *pBaseSave;
+ int nlwidth;
+ int sizeDst;
+ int depthDst;
+
+ int nptTmp;
+ register xPoint *ppt;
+
+ register int x;
+ register int y;
+ register unsigned char *rrops;
+ afbPrivGC *pGCPriv;
+
+ pGCPriv = (afbPrivGC *) pGC->devPrivates[afbGCPrivateIndex].ptr;
+
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
+ pBaseSave);
+
+ rrops = pGCPriv->rrops;
+ if ((mode == CoordModePrevious) && (npt > 1))
+ for (ppt = pptInit + 1, nptTmp = npt - 1; --nptTmp >= 0; ppt++) {
+ ppt->x += (ppt-1)->x;
+ ppt->y += (ppt-1)->y;
+ }
+
+ nbox = REGION_NUM_RECTS(pGC->pCompositeClip);
+ pbox = REGION_RECTS(pGC->pCompositeClip);
+ for (; --nbox >= 0; pbox++)
+ for (d = 0, pBase = pBaseSave; d < depthDst; d++, pBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ addrl = pBase;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ for (ppt = pptInit, nptTmp = npt; --nptTmp >= 0; ppt++) {
+ x = ppt->x + pDrawable->x;
+ y = ppt->y + pDrawable->y;
+ if ((x >= pbox->x1) && (x < pbox->x2) &&
+ (y >= pbox->y1) && (y < pbox->y2))
+ *afbScanline(addrl, x, y, nlwidth) &= mfbGetrmask(x & PIM);
+ }
+ break;
+
+ case RROP_WHITE:
+ for (ppt = pptInit, nptTmp = npt; --nptTmp >= 0; ppt++) {
+ x = ppt->x + pDrawable->x;
+ y = ppt->y + pDrawable->y;
+ if ((x >= pbox->x1) && (x < pbox->x2) &&
+ (y >= pbox->y1) && (y < pbox->y2))
+ *afbScanline(addrl, x, y, nlwidth) |= mfbGetmask(x & PIM);
+ }
+ break;
+
+ case RROP_INVERT:
+ for (ppt = pptInit, nptTmp = npt; --nptTmp >= 0; ppt++) {
+ x = ppt->x + pDrawable->x;
+ y = ppt->y + pDrawable->y;
+ if ((x >= pbox->x1) && (x < pbox->x2) &&
+ (y >= pbox->y1) && (y < pbox->y2))
+ *afbScanline(addrl, x, y, nlwidth) ^= mfbGetmask(x & PIM);
+ }
+ break;
+
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ...) */
+}
diff --git a/nx-X11/programs/Xserver/afb/afbpushpxl.c b/nx-X11/programs/Xserver/afb/afbpushpxl.c
new file mode 100644
index 000000000..e62181188
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbpushpxl.c
@@ -0,0 +1,259 @@
+/* $XFree86: xc/programs/Xserver/afb/afbpushpxl.c,v 3.1 1998/03/20 21:04:56 hohndel Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbpushpxl.c,v 5.6 94/04/17 20:28:31 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "maskbits.h"
+#include "afb.h"
+
+/* afbSolidPP is courtesy of xhacks@csri.toronto.edu
+
+ For fillStyle==FillSolid, a monochrome PushPixels can be reduced to
+ a ROP in the following way: (Note that the ROP is the same as the
+ result of ROP(src=0x3,dst=0x5))
+
+ src=0011 0000 0011
+ dst=0101 0101 0101
+ rop fg=0 fg=1
+ GXclear 0x0 0000 0100 0100 0
+ GXand 0x1 0001 0100 0101 s&d
+ GXandReverse 0x2 0010 0100 0110 s&~d
+ GXcopy 0x3 0011 0100 0111 s
+ GXandInverted 0x4 0100 0101 0100 ~s&d
+ GXnoop 0x5 0101 0101 0101 d
+ GXxor 0x6 0110 0101 0110 s^d
+ GXor 0x7 0111 0101 0111 s|d
+ GXnor 0x8 1000 0110 0100 ~s&~d
+ GXequiv 0x9 1001 0110 0101 ~s^d
+ GXinvert 0xa 1010 0110 0110 ~d
+ GXorReverse 0xb 1011 0110 0111 s|~d
+ GXcopyInverted 0xc 1100 0111 0100 ~s
+ GXorInverted 0xd 1101 0111 0101 ~s|d
+ GXnand 0xe 1110 0111 0110 ~s|~d
+ GXset 0xf 1111 0111 0111 1
+
+For src=0: newRop = 0x4|(rop>>2)
+For src=1: newRop = 0x4|(rop&3)
+*/
+
+/* afbSolidPP -- squeegees the forground color of pGC through pBitMap
+ * into pDrawable. pBitMap is a stencil (dx by dy of it is used, it may
+ * be bigger) which is placed on the drawable at xOrg, yOrg. Where a 1 bit
+ * is set in the bitmap, the fill style is put onto the drawable using
+ * the GC's logical function. The drawable is not changed where the bitmap
+ * has a zero bit or outside the area covered by the stencil.
+ */
+void
+afbSolidPP(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
+ GCPtr pGC;
+ PixmapPtr pBitMap;
+ DrawablePtr pDrawable;
+ int dx, dy, xOrg, yOrg;
+{
+ unsigned char alu;
+ RegionRec rgnDst;
+ DDXPointPtr pptSrc;
+ BoxRec srcBox;
+ register DDXPointPtr ppt;
+ register BoxPtr pbox;
+ int i;
+
+ if (!pGC->planemask & 1) return;
+
+ /* compute the reduced rop function */
+ alu = pGC->alu;
+ if (!(pGC->fgPixel&1)) alu >>= 2;
+ alu = (alu & 0x3) | 0x4;
+ if (alu == GXnoop) return;
+
+ srcBox.x1 = xOrg;
+ srcBox.y1 = yOrg;
+ srcBox.x2 = xOrg + dx;
+ srcBox.y2 = yOrg + dy;
+ REGION_INIT(pGC->pScreen, &rgnDst, &srcBox, 1);
+
+ /* clip the shape of the dst to the destination composite clip */
+ REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, pGC->pCompositeClip);
+
+ if (!REGION_NIL(&rgnDst)) {
+ i = REGION_NUM_RECTS(&rgnDst);
+ pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec));
+ if(pptSrc) {
+ for (pbox = REGION_RECTS(&rgnDst), ppt = pptSrc; --i >= 0;
+ pbox++, ppt++) {
+ ppt->x = pbox->x1 - xOrg;
+ ppt->y = pbox->y1 - yOrg;
+ }
+ afbDoBitblt((DrawablePtr)pBitMap, pDrawable, alu, &rgnDst, pptSrc,
+ pGC->planemask);
+ DEALLOCATE_LOCAL(pptSrc);
+ }
+ }
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+}
+
+#define NPT 128
+
+/* afbPushPixels -- squeegees the forground color of pGC through pBitMap
+ * into pDrawable. pBitMap is a stencil (dx by dy of it is used, it may
+ * be bigger) which is placed on the drawable at xOrg, yOrg. Where a 1 bit
+ * is set in the bitmap, the fill style is put onto the drawable using
+ * the GC's logical function. The drawable is not changed where the bitmap
+ * has a zero bit or outside the area covered by the stencil.
+ */
+void
+afbPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
+ GCPtr pGC;
+ PixmapPtr pBitMap;
+ DrawablePtr pDrawable;
+ int dx, dy, xOrg, yOrg;
+{
+ int h, dxDivPPW, ibEnd;
+ PixelType *pwLineStart;
+ register PixelType *pw, *pwEnd;
+ register PixelType mask;
+ register int ib;
+ register PixelType w;
+ register int ipt; /* index into above arrays */
+ Bool fInBox;
+ DDXPointRec pt[NPT];
+ int width[NPT];
+
+ /* Now scan convert the pixmap and use the result to call fillspans in
+ * in the drawable with the original GC */
+ ipt = 0;
+ dxDivPPW = dx/PPW;
+ for (h = 0; h < dy; h++) {
+
+ pw = (PixelType *)
+ (((char *)(pBitMap->devPrivate.ptr))+(h * pBitMap->devKind));
+ pwLineStart = pw;
+ /* Process all words which are fully in the pixmap */
+
+ fInBox = FALSE;
+ pwEnd = pwLineStart + dxDivPPW;
+ while(pw < pwEnd) {
+ w = *pw;
+ mask = mfbGetendtab(1);
+ for(ib = 0; ib < PPW; ib++) {
+ if(w & mask) {
+ if(!fInBox) {
+ pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
+ pt[ipt].y = h + yOrg;
+ /* start new box */
+ fInBox = TRUE;
+ }
+ } else {
+ if(fInBox) {
+ width[ipt] = ((pw - pwLineStart) << PWSH) +
+ ib + xOrg - pt[ipt].x;
+ if (++ipt >= NPT) {
+ (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt,
+ width, TRUE);
+ ipt = 0;
+ }
+ /* end box */
+ fInBox = FALSE;
+ }
+ }
+ mask = SCRRIGHT(mask, 1);
+ }
+ pw++;
+ }
+ ibEnd = dx & PIM;
+ if(ibEnd) {
+ /* Process final partial word on line */
+ w = *pw;
+ mask = mfbGetendtab(1);
+ for(ib = 0; ib < ibEnd; ib++) {
+ if(w & mask) {
+ if(!fInBox) {
+ /* start new box */
+ pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
+ pt[ipt].y = h + yOrg;
+ fInBox = TRUE;
+ }
+ } else {
+ if(fInBox) {
+ /* end box */
+ width[ipt] = ((pw - pwLineStart) << PWSH) +
+ ib + xOrg - pt[ipt].x;
+ if (++ipt >= NPT) {
+ (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt,
+ width, TRUE);
+ ipt = 0;
+ }
+ fInBox = FALSE;
+ }
+ }
+ mask = SCRRIGHT(mask, 1);
+ }
+ }
+ /* If scanline ended with last bit set, end the box */
+ if(fInBox) {
+ width[ipt] = dx + xOrg - pt[ipt].x;
+ if (++ipt >= NPT) {
+ (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt, width, TRUE);
+ ipt = 0;
+ }
+ }
+ }
+ /* Flush any remaining spans */
+ if (ipt) {
+ (*pGC->ops->FillSpans)(pDrawable, pGC, ipt, pt, width, TRUE);
+ }
+}
diff --git a/nx-X11/programs/Xserver/afb/afbscrinit.c b/nx-X11/programs/Xserver/afb/afbscrinit.c
new file mode 100644
index 000000000..2e10ad885
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbscrinit.c
@@ -0,0 +1,248 @@
+/* $XFree86: xc/programs/Xserver/afb/afbscrinit.c,v 3.4 1998/07/25 08:50:27 dawes Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbscrinit.c,v 5.17 94/04/17 20:28:34 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h> /* for xColorItem */
+#include <X11/Xmd.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "resource.h"
+#include "colormap.h"
+#include "afb.h"
+#include "mistruct.h"
+#include "dix.h"
+#include "mi.h"
+#include "mibstore.h"
+#include "migc.h"
+#include "servermd.h"
+
+#ifdef PIXMAP_PER_WINDOW
+int frameWindowPrivateIndex;
+#endif
+int afbWindowPrivateIndex;
+int afbGCPrivateIndex;
+int afbScreenPrivateIndex;
+
+static unsigned long afbGeneration = 0;
+
+BSFuncRec afbBSFuncRec = {
+ afbSaveAreas,
+ afbRestoreAreas,
+ (BackingStoreSetClipmaskRgnProcPtr) 0,
+ (BackingStoreGetImagePixmapProcPtr) 0,
+ (BackingStoreGetSpansPixmapProcPtr) 0,
+};
+
+Bool
+afbCloseScreen(index, pScreen)
+ int index;
+ ScreenPtr pScreen;
+{
+ int d;
+ DepthPtr depths = pScreen->allowedDepths;
+
+ for (d = 0; d < pScreen->numDepths; d++)
+ xfree(depths[d].vids);
+ xfree(depths);
+ xfree(pScreen->visuals);
+ xfree(pScreen->devPrivates[afbScreenPrivateIndex].ptr);
+ return(TRUE);
+}
+
+Bool
+afbCreateScreenResources(pScreen)
+ ScreenPtr pScreen;
+{
+ Bool retval;
+
+ pointer oldDevPrivate = pScreen->devPrivate;
+
+ pScreen->devPrivate = pScreen->devPrivates[afbScreenPrivateIndex].ptr;
+ retval = miCreateScreenResources(pScreen);
+
+ /* Modify screen's pixmap devKind value stored off devPrivate to
+ * be the width of a single plane in longs rather than the width
+ * of a chunky screen in longs as incorrectly setup by the mi routine.
+ */
+ ((PixmapPtr)pScreen->devPrivate)->devKind = BitmapBytePad(pScreen->width);
+ pScreen->devPrivates[afbScreenPrivateIndex].ptr = pScreen->devPrivate;
+ pScreen->devPrivate = oldDevPrivate;
+ return(retval);
+}
+
+Bool
+afbAllocatePrivates(pScreen, pWinIndex, pGCIndex)
+ ScreenPtr pScreen;
+ int *pWinIndex, *pGCIndex;
+{
+ if (afbGeneration != serverGeneration) {
+#ifdef PIXMAP_PER_WINDOW
+ frameWindowPrivateIndex = AllocateWindowPrivateIndex();
+#endif
+ afbWindowPrivateIndex = AllocateWindowPrivateIndex();
+ afbGCPrivateIndex = AllocateGCPrivateIndex();
+ afbGeneration = serverGeneration;
+ }
+ if (pWinIndex)
+ *pWinIndex = afbWindowPrivateIndex;
+ if (pGCIndex)
+ *pGCIndex = afbGCPrivateIndex;
+
+ afbScreenPrivateIndex = AllocateScreenPrivateIndex();
+ pScreen->GetWindowPixmap = afbGetWindowPixmap;
+ pScreen->SetWindowPixmap = afbSetWindowPixmap;
+ return(AllocateWindowPrivate(pScreen, afbWindowPrivateIndex, sizeof(afbPrivWin)) &&
+ AllocateGCPrivate(pScreen, afbGCPrivateIndex, sizeof(afbPrivGC)));
+}
+
+/* dts * (inch/dot) * (25.4 mm / inch) = mm */
+Bool
+afbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+{
+ VisualPtr visuals;
+ DepthPtr depths;
+ int nvisuals;
+ int ndepths;
+ int rootdepth;
+ VisualID defaultVisual;
+ pointer oldDevPrivate;
+
+ rootdepth = 0;
+ if (!afbInitVisuals(&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
+ &defaultVisual, 256, 8)) {
+ ErrorF("afbInitVisuals: FALSE\n");
+ return FALSE;
+ }
+ if (!afbAllocatePrivates(pScreen,(int *)NULL, (int *)NULL)) {
+ ErrorF("afbAllocatePrivates: FALSE\n");
+ return FALSE;
+ }
+
+ pScreen->defColormap = (Colormap)FakeClientID(0);
+ /* whitePixel, blackPixel */
+ pScreen->blackPixel = 0;
+ pScreen->whitePixel = 0;
+ pScreen->QueryBestSize = afbQueryBestSize;
+ /* SaveScreen */
+ pScreen->GetImage = afbGetImage;
+ pScreen->GetSpans = afbGetSpans;
+ pScreen->CreateWindow = afbCreateWindow;
+ pScreen->DestroyWindow = afbDestroyWindow;
+ pScreen->PositionWindow = afbPositionWindow;
+ pScreen->ChangeWindowAttributes = afbChangeWindowAttributes;
+ pScreen->RealizeWindow = afbMapWindow;
+ pScreen->UnrealizeWindow = afbUnmapWindow;
+ pScreen->PaintWindowBackground = afbPaintWindow;
+ pScreen->PaintWindowBorder = afbPaintWindow;
+ pScreen->CopyWindow = afbCopyWindow;
+ pScreen->CreatePixmap = afbCreatePixmap;
+ pScreen->DestroyPixmap = afbDestroyPixmap;
+ pScreen->RealizeFont = afbRealizeFont;
+ pScreen->UnrealizeFont = afbUnrealizeFont;
+ pScreen->CreateGC = afbCreateGC;
+ pScreen->CreateColormap = afbInitializeColormap;
+ pScreen->DestroyColormap = (void (*)())NoopDDA;
+ pScreen->InstallColormap = afbInstallColormap;
+ pScreen->UninstallColormap = afbUninstallColormap;
+ pScreen->ListInstalledColormaps = afbListInstalledColormaps;
+ pScreen->StoreColors = (void (*)())NoopDDA;
+ pScreen->ResolveColor = afbResolveColor;
+ pScreen->BitmapToRegion = afbPixmapToRegion;
+ oldDevPrivate = pScreen->devPrivate;
+ if (!miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, rootdepth,
+ ndepths, depths, defaultVisual, nvisuals, visuals)) {
+ ErrorF("miScreenInit: FALSE\n");
+ return FALSE;
+ }
+
+ pScreen->CloseScreen = afbCloseScreen;
+ pScreen->CreateScreenResources = afbCreateScreenResources;
+ pScreen->BackingStoreFuncs = afbBSFuncRec;
+
+ pScreen->devPrivates[afbScreenPrivateIndex].ptr = pScreen->devPrivate;
+ pScreen->devPrivate = oldDevPrivate;
+
+ return TRUE;
+}
+
+PixmapPtr
+afbGetWindowPixmap(pWin)
+ WindowPtr pWin;
+{
+#ifdef PIXMAP_PER_WINDOW
+ return (PixmapPtr)(pWin->devPrivates[frameWindowPrivateIndex].ptr);
+#else
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ return (* pScreen->GetScreenPixmap)(pScreen);
+#endif
+}
+
+void
+afbSetWindowPixmap(pWin, pPix)
+ WindowPtr pWin;
+ PixmapPtr pPix;
+{
+#ifdef PIXMAP_PER_WINDOW
+ pWin->devPrivates[frameWindowPrivateIndex].ptr = (pointer)pPix;
+#else
+ (* pWin->drawable.pScreen->SetScreenPixmap)(pPix);
+#endif
+}
diff --git a/nx-X11/programs/Xserver/afb/afbsetsp.c b/nx-X11/programs/Xserver/afb/afbsetsp.c
new file mode 100644
index 000000000..3a078ffa9
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbsetsp.c
@@ -0,0 +1,269 @@
+/* $XFree86: xc/programs/Xserver/afb/afbsetsp.c,v 3.2 2001/08/01 00:44:47 tsi Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbsetsp.c,v 5.8 94/04/17 20:28:34 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "misc.h"
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "afb.h"
+#include "maskbits.h"
+
+#include "servermd.h"
+
+
+/* afbSetScanline -- copies the bits from psrc to the drawable starting at
+ * (xStart, y) and continuing to (xEnd, y). xOrigin tells us where psrc
+ * starts on the scanline. (I.e., if this scanline passes through multiple
+ * boxes, we may not want to start grabbing bits at psrc but at some offset
+ * further on.)
+ */
+void
+afbSetScanline(y, xOrigin, xStart, xEnd, psrc, alu, pdstBase, widthDst,
+ sizeDst, depthDst, sizeSrc)
+ int y;
+ int xOrigin; /* where this scanline starts */
+ int xStart; /* first bit to use from scanline */
+ int xEnd; /* last bit to use from scanline + 1 */
+ register PixelType *psrc;
+ register int alu; /* raster op */
+ PixelType *pdstBase; /* start of the drawable */
+ int widthDst; /* width of drawable in words */
+ int sizeDst;
+ int depthDst;
+ int sizeSrc;
+{
+ int w; /* width of scanline in bits */
+ register PixelType *pdst; /* where to put the bits */
+ register PixelType tmpSrc; /* scratch buffer to collect bits in */
+ int dstBit; /* offset in bits from beginning of
+ * word */
+ register int nstart; /* number of bits from first partial */
+ register int nend; /* " " last partial word */
+ int offSrc;
+ PixelType startmask, endmask;
+ PixelType *savePsrc = psrc + ((xStart - xOrigin) >> PWSH);
+ int nlMiddle, nl;
+ int d;
+
+ for (d = 0; d < depthDst; d++) {
+ pdst = afbScanline(pdstBase, xStart, y, widthDst) + sizeDst * d; /* @@@ NEXT PLANE @@@ */
+ psrc = savePsrc + sizeSrc * d; /* @@@ NEXT PLANE @@@ */
+ offSrc = (xStart - xOrigin) & PIM;
+ w = xEnd - xStart;
+ dstBit = xStart & PIM;
+
+ if (dstBit + w <= PPW) {
+ getandputrop(psrc, offSrc, dstBit, w, pdst, alu)
+ } else {
+ maskbits(xStart, w, startmask, endmask, nlMiddle);
+ if (startmask)
+ nstart = PPW - dstBit;
+ else
+ nstart = 0;
+ if (endmask)
+ nend = xEnd & PIM;
+ else
+ nend = 0;
+ if (startmask) {
+ getandputrop(psrc, offSrc, dstBit, nstart, pdst, alu)
+ pdst++;
+ offSrc += nstart;
+ if (offSrc > PLST) {
+ psrc++;
+ offSrc -= PPW;
+ }
+ }
+ nl = nlMiddle;
+ while (nl--) {
+ getbits(psrc, offSrc, PPW, tmpSrc);
+ DoRop(*pdst, alu, tmpSrc, *pdst);
+ pdst++;
+ psrc++;
+ }
+ if (endmask) {
+ getandputrop0(psrc, offSrc, nend, pdst, alu);
+ }
+ }
+ }
+}
+
+
+
+/* SetSpans -- for each span copy pwidth[i] bits from psrc to pDrawable at
+ * ppt[i] using the raster op from the GC. If fSorted is TRUE, the scanlines
+ * are in increasing Y order.
+ * Source bit lines are server scanline padded so that they always begin
+ * on a word boundary.
+ */
+void
+afbSetSpans(pDrawable, pGC, pcharsrc, ppt, pwidth, nspans, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ char *pcharsrc;
+ register DDXPointPtr ppt;
+ int *pwidth;
+ int nspans;
+ int fSorted;
+{
+ PixelType *psrc = (PixelType *)pcharsrc;
+ PixelType *pdstBase; /* start of dst bitmap */
+ int widthDst; /* width of bitmap in words */
+ int sizeDst;
+ int depthDst;
+ int sizeSrc = 0;
+ register BoxPtr pbox, pboxLast, pboxTest;
+ register DDXPointPtr pptLast;
+ int alu;
+ RegionPtr prgnDst;
+ int xStart, xEnd;
+ int yMax;
+
+ alu = pGC->alu;
+ prgnDst = pGC->pCompositeClip;
+
+ pptLast = ppt + nspans;
+
+ yMax = pDrawable->y + (int) pDrawable->height;
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, widthDst, sizeDst, depthDst,
+ pdstBase);
+
+ pbox = REGION_RECTS(prgnDst);
+ pboxLast = pbox + REGION_NUM_RECTS(prgnDst);
+
+ if(fSorted) {
+ /* scan lines sorted in ascending order. Because they are sorted, we
+ * don't have to check each scanline against each clip box. We can be
+ * sure that this scanline only has to be clipped to boxes at or after the
+ * beginning of this y-band
+ */
+ pboxTest = pbox;
+ while(ppt < pptLast) {
+ pbox = pboxTest;
+ if(ppt->y >= yMax)
+ break;
+ while(pbox < pboxLast) {
+ if(pbox->y1 > ppt->y) {
+ /* scanline is before clip box */
+ break;
+ } else if(pbox->y2 <= ppt->y) {
+ /* clip box is before scanline */
+ pboxTest = ++pbox;
+ continue;
+ } else if(pbox->x1 > ppt->x + *pwidth) {
+ /* clip box is to right of scanline */
+ break;
+ } else if(pbox->x2 <= ppt->x) {
+ /* scanline is to right of clip box */
+ pbox++;
+ continue;
+ }
+
+ /* at least some of the scanline is in the current clip box */
+ xStart = max(pbox->x1, ppt->x);
+ xEnd = min(ppt->x + *pwidth, pbox->x2);
+ sizeSrc = PixmapWidthInPadUnits(*pwidth, 1);
+ afbSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu, pdstBase,
+ widthDst, sizeDst, depthDst, sizeSrc);
+ if(ppt->x + *pwidth <= pbox->x2) {
+ /* End of the line, as it were */
+ break;
+ } else
+ pbox++;
+ }
+ /* We've tried this line against every box; it must be outside them
+ * all. move on to the next point */
+ ppt++;
+ psrc += sizeSrc * depthDst;
+ pwidth++;
+ }
+ } else {
+ /* scan lines not sorted. We must clip each line against all the boxes */
+ while(ppt < pptLast) {
+ if(ppt->y >= 0 && ppt->y < yMax) {
+ for(pbox = REGION_RECTS(prgnDst); pbox< pboxLast; pbox++) {
+ if(pbox->y1 > ppt->y) {
+ /* rest of clip region is above this scanline,
+ * skip it */
+ break;
+ }
+ if(pbox->y2 <= ppt->y) {
+ /* clip box is below scanline */
+ pbox++;
+ break;
+ }
+ if(pbox->x1 <= ppt->x + *pwidth &&
+ pbox->x2 > ppt->x) {
+ xStart = max(pbox->x1, ppt->x);
+ xEnd = min(pbox->x2, ppt->x + *pwidth);
+ sizeSrc = PixmapWidthInPadUnits(*pwidth, 1);
+ afbSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu,
+ pdstBase, widthDst, sizeDst, depthDst,
+ sizeSrc);
+ }
+
+ }
+ }
+ psrc += sizeSrc * depthDst;
+ ppt++;
+ pwidth++;
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/afb/afbtegblt.c b/nx-X11/programs/Xserver/afb/afbtegblt.c
new file mode 100644
index 000000000..16f6ca4ea
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbtegblt.c
@@ -0,0 +1,588 @@
+/* $XFree86: xc/programs/Xserver/afb/afbtegblt.c,v 3.1 1998/03/20 21:04:57 hohndel Exp $ */
+/* $XConsortium: afbtegblt.c,v 5.14 94/04/17 20:28:35 dpw Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "afb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "maskbits.h"
+
+/*
+ this works for fonts with glyphs <= PPW bits wide.
+
+ This should be called only with a terminal-emulator font;
+this means that the FIXED_METRICS flag is set, and that
+glyphbounds == charbounds.
+
+ in theory, this goes faster; even if it doesn't, it reduces the
+flicker caused by writing a string over itself with image text (since
+the background gets repainted per character instead of per string.)
+this seems to be important for some converted X10 applications.
+
+ Image text looks at the bits in the glyph and the fg and bg in the
+GC. it paints a rectangle, as defined in the protocol dcoument,
+and the paints the characters.
+
+*/
+
+#if defined(NO_3_60_CG4) && defined(FASTPUTBITS) && defined(FASTGETBITS)
+#define FASTCHARS
+#endif
+
+/*
+ * this macro "knows" that only characters <= 8 bits wide will
+ * fit this case (which is why it is independent of GLYPHPADBYTES)
+ */
+
+#if (BITMAP_BIT_ORDER == MSBFirst) && (GLYPHPADBYTES != 4)
+#if GLYPHPADBYTES == 1
+#define ShiftAmnt 24
+#else
+#define ShiftAmnt 16
+#endif
+
+/*
+ * Note: for BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER, SCRRIGHT() evaluates its
+ * first argument more than once. Thus the imbedded char++ have to be moved.
+ * (DHD)
+ */
+#if BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER
+#if PPW == 32
+#define GetBits4 c = (*char1++ << ShiftAmnt) | \
+ SCRRIGHT (*char2++ << ShiftAmnt, xoff2) | \
+ SCRRIGHT (*char3++ << ShiftAmnt, xoff3) | \
+ SCRRIGHT (*char4++ << ShiftAmnt, xoff4);
+#else /* PPW */
+#define GetBits4 c = ((unsigned long)(*char1++ << ShiftAmnt) << 32 ) | \
+ (SCRRIGHT (*char2++ << ShiftAmnt, xoff2) << 32 ) | \
+ (SCRRIGHT (*char3++ << ShiftAmnt, xoff3) << 32 ) | \
+ (SCRRIGHT (*char4++ << ShiftAmnt, xoff4) << 32 ) | \
+ (*char5++ << ShiftAmnt) | \
+ SCRRIGHT (*char6++ << ShiftAmnt, xoff6) | \
+ SCRRIGHT (*char7++ << ShiftAmnt, xoff7) | \
+ SCRRIGHT (*char8++ << ShiftAmnt, xoff8);
+#endif /* PPW */
+#else /* BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER */
+#if PPW == 32
+#define GetBits4 c = (*char1++ << ShiftAmnt) | \
+ SCRRIGHT (*char2 << ShiftAmnt, xoff2) | \
+ SCRRIGHT (*char3 << ShiftAmnt, xoff3) | \
+ SCRRIGHT (*char4 << ShiftAmnt, xoff4); \
+ char2++; char3++; char4++;
+#else /* PPW == 64 */
+#define GetBits4 c = ((unsigned long)(*char1++ << ShiftAmnt) << 32 ) | \
+ (SCRRIGHT (*char2 << ShiftAmnt, xoff2) << 32 ) | \
+ (SCRRIGHT (*char3 << ShiftAmnt, xoff3) << 32 ) | \
+ (SCRRIGHT (*char4 << ShiftAmnt, xoff4) << 32 ) | \
+ (*char5++ << ShiftAmnt) | \
+ SCRRIGHT (*char6 << ShiftAmnt, xoff6) | \
+ SCRRIGHT (*char7 << ShiftAmnt, xoff7) | \
+ SCRRIGHT (*char8 << ShiftAmnt, xoff8); \
+ char2++; char3++; char4++; char6++; char7++; char8++;
+#endif /* PPW */
+#endif /* BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER */
+
+#else /* (BITMAP_BIT_ORDER != MSBFirst) || (GLYPHPADBYTES == 4) */
+
+#if BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER
+#if PPW == 32
+#define GetBits4 c = *char1++ | \
+ SCRRIGHT (*char2++, xoff2) | \
+ SCRRIGHT (*char3++, xoff3) | \
+ SCRRIGHT (*char4++, xoff4);
+#else /* PPW == 64 */
+#define GetBits4 c = (unsigned long)(((*char1++) << 64 ) | \
+ (SCRRIGHT (*char2++, xoff2) << 64 ) | \
+ (SCRRIGHT (*char3++, xoff3) << 64 ) | \
+ (SCRRIGHT (*char4++, xoff4) << 64 ) | \
+ SCRRIGHT (*char5++, xoff5) | \
+ SCRRIGHT (*char6++, xoff6) | \
+ SCRRIGHT (*char7++, xoff7) | \
+ SCRRIGHT (*char8++, xoff8));
+#endif /* PPW */
+#else /* BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER */
+#if PPW == 32
+#define GetBits4 c = *char1++ | \
+ SCRRIGHT (*char2, xoff2) | \
+ SCRRIGHT (*char3, xoff3) | \
+ SCRRIGHT (*char4, xoff4); \
+ char2++; char3++; char4++;
+#else /* PPW == 64 */
+#define GetBits4 c = (unsigned long)(((*char1++) << 64 ) | \
+ (SCRRIGHT (*char2, xoff2) << 64 ) | \
+ (SCRRIGHT (*char3, xoff3) << 64 ) | \
+ (SCRRIGHT (*char4, xoff4) << 64 ) | \
+ SCRRIGHT (*char5, xoff5) | \
+ SCRRIGHT (*char6, xoff6) | \
+ SCRRIGHT (*char7, xoff7) | \
+ SCRRIGHT (*char8, xoff8)); \
+ char2++; char3++; char4++; \
+ char5++; char6++; char7++; char8++;
+#endif /* PPW */
+#endif /* BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER */
+
+#endif /* BITMAP_BIT_ORDER && GLYPHPADBYTES */
+
+
+#if GLYPHPADBYTES == 1
+typedef unsigned char *glyphPointer;
+#define USE_LEFTBITS
+#endif
+
+#if GLYPHPADBYTES == 2
+typedef unsigned short *glyphPointer;
+#define USE_LEFTBITS
+#endif
+
+#if GLYPHPADBYTES == 4
+typedef unsigned int *glyphPointer;
+#endif
+
+#ifdef USE_LEFTBITS
+#define GetBits1 getleftbits (char1, widthGlyph, c); \
+ c &= glyphMask; \
+ char1 = (glyphPointer) (((char *) char1) + glyphBytes);
+#else
+#define GetBits1 c = *char1++;
+#endif
+
+void
+afbTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ FontPtr pfont = pGC->font;
+ int widthDst;
+ PixelType *pdstBase; /* pointer to longword with top row
+ of current glyph */
+
+ int h; /* height of glyph and char */
+ register int xpos; /* current x */
+ int ypos; /* current y */
+ int widthGlyph;
+
+ int hTmp; /* counter for height */
+ register PixelType startmask, endmask;
+ int nfirst; /* used if glyphs spans a longword boundary */
+ BoxRec bbox; /* for clipping */
+ int widthGlyphs;
+ int sizeDst;
+ int depthDst;
+ PixelType *saveDst;
+ register PixelType *dst;
+ register PixelType c;
+ register int d;
+ register int xoff1, xoff2, xoff3, xoff4;
+ register glyphPointer char1, char2, char3, char4;
+ glyphPointer schar1, schar2, schar3, schar4;
+#if PPW == 64
+ register int xoff5, xoff6, xoff7, xoff8;
+ register glyphPointer char5, char6, char7, char8;
+ glyphPointer schar5, schar6, schar7, schar8;
+#endif /* PPW */
+
+ unsigned char *rrops;
+#ifdef USE_LEFTBITS
+ register PixelType glyphMask;
+ register PixelType tmpSrc;
+ register int glyphBytes;
+#endif
+
+ afbGetPixelWidthSizeDepthAndPointer(pDrawable, widthDst, sizeDst, depthDst,
+ pdstBase);
+
+ xpos = x + pDrawable->x;
+ ypos = y + pDrawable->y;
+
+ widthGlyph = FONTMAXBOUNDS(pfont,characterWidth);
+ h = FONTASCENT(pfont) + FONTDESCENT(pfont);
+
+ xpos += FONTMAXBOUNDS(pfont,leftSideBearing);
+ ypos -= FONTASCENT(pfont);
+
+ rrops = ((afbPrivGCPtr) pGC->devPrivates[afbGCPrivateIndex].ptr)->rropOS;
+
+ bbox.x1 = xpos;
+ bbox.x2 = xpos + (widthGlyph * nglyph);
+ bbox.y1 = ypos;
+ bbox.y2 = ypos + h;
+
+ switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox)) {
+ case rgnPART:
+ /* this is the WRONG thing to do, but it works.
+ calling the non-terminal text is easy, but slow, given
+ what we know about the font.
+
+ the right thing to do is something like:
+ for each clip rectangle
+ compute at which row the glyph starts to be in it,
+ and at which row the glyph ceases to be in it
+ compute which is the first glyph inside the left
+ edge, and the last one inside the right edge
+ draw a fractional first glyph, using only
+ the rows we know are in
+ draw all the whole glyphs, using the appropriate rows
+ draw any pieces of the last glyph, using the right rows
+
+ this way, the code would take advantage of knowing that
+ all glyphs are the same height and don't overlap.
+
+ one day...
+ */
+ afbImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ case rgnOUT:
+ return;
+ }
+ pdstBase = afbScanlineDeltaNoBankSwitch(pdstBase, ypos, widthDst);
+ widthGlyphs = widthGlyph * PGSZB;
+
+#ifdef USE_LEFTBITS
+ glyphMask = mfbGetendtab(widthGlyph);
+ glyphBytes = GLYPHWIDTHBYTESPADDED(*ppci);
+#endif
+
+ if (nglyph >= PGSZB && widthGlyphs <= PPW) {
+ while (nglyph >= PGSZB) {
+ nglyph -= PGSZB;
+ xoff1 = xpos & PIM;
+ xoff2 = widthGlyph;
+ xoff3 = xoff2 + widthGlyph;
+ xoff4 = xoff3 + widthGlyph;
+#if PPW == 64
+ xoff5 = xoff4 + widthGlyph;
+ xoff6 = xoff5 + widthGlyph;
+ xoff7 = xoff6 + widthGlyph;
+ xoff8 = xoff7 + widthGlyph;
+#endif /* PPW */
+ schar1 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
+ schar2 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
+ schar3 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
+ schar4 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
+#if PPW == 64
+ schar5 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
+ schar6 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
+ schar7 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
+ schar8 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
+#endif /* PPW */
+
+ hTmp = h;
+ saveDst = afbScanlineOffset(pdstBase, (xpos >> PWSH)); /* switch now */
+
+#ifndef FASTCHARS
+ if (xoff1 + widthGlyphs <= PPW) {
+ maskpartialbits (xoff1, widthGlyphs, startmask);
+#endif
+ for (d = 0; d < depthDst; d++) {
+ hTmp = h;
+ dst = saveDst;
+ saveDst += sizeDst; /* @@@ NEXT PLANE @@@ */
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (hTmp--) {
+#ifdef FASTCHARS
+ FASTPUTBITS(0, xoff1, widthGlyphs, dst);
+#else
+ *(dst) &= ~startmask;
+#endif
+ afbScanlineInc(dst, widthDst);
+ }
+ break;
+ case RROP_WHITE:
+ while (hTmp--) {
+#ifdef FASTCHARS
+ FASTPUTBITS(~0, xoff1, widthGlyphs, dst);
+#else
+ *(dst) |= startmask;
+#endif
+ afbScanlineInc(dst, widthDst);
+ }
+ break;
+ case RROP_INVERT:
+ char1 = schar1;
+ char2 = schar2;
+ char3 = schar3;
+ char4 = schar4;
+ /* XXX */
+ while (hTmp--) {
+ GetBits4
+#ifdef FASTCHARS
+# if BITMAP_BIT_ORDER == MSBFirst
+ c >>= PPW - widthGlyphs;
+# endif
+ FASTPUTBITS(~c, xoff1, widthGlyphs, dst);
+#else
+ *(dst) = ((*dst) & ~startmask) | (~SCRRIGHT(c, xoff1) & startmask);
+#endif
+ afbScanlineInc(dst, widthDst);
+ }
+ break;
+ case RROP_COPY:
+ char1 = schar1;
+ char2 = schar2;
+ char3 = schar3;
+ char4 = schar4;
+
+ while (hTmp--) {
+ GetBits4
+#ifdef FASTCHARS
+# if BITMAP_BIT_ORDER == MSBFirst
+ c >>= PPW - widthGlyphs;
+#endif
+ FASTPUTBITS(c, xoff1, widthGlyphs, dst);
+#else
+ *(dst) = ((*dst) & ~startmask) | (SCRRIGHT(c, xoff1) & startmask);
+#endif
+ afbScanlineInc(dst, widthDst);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch (rrops[d]) */
+ } /* for (d = ... ) */
+#ifndef FASTCHARS
+ } else {
+ maskPPWbits (xoff1, widthGlyphs, startmask, endmask);
+ nfirst = PPW - xoff1;
+ for (d = 0; d < depthDst; d++) {
+ hTmp = h;
+ dst = saveDst;
+ saveDst += sizeDst; /* @@@ NEXT PLANE @@@ */
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (hTmp--) {
+ dst[0] &= ~startmask;
+ dst[1] &= ~endmask;
+ afbScanlineInc(dst, widthDst);
+ }
+ break;
+ case RROP_WHITE:
+ while (hTmp--) {
+ dst[0] |= startmask;
+ dst[1] |= endmask;
+ afbScanlineInc(dst, widthDst);
+ }
+ break;
+ case RROP_INVERT:
+ char1 = schar1;
+ char2 = schar2;
+ char3 = schar3;
+ char4 = schar4;
+
+ while (hTmp--) {
+ GetBits4
+ dst[0] = (dst[0] & ~startmask) | (~SCRRIGHT(c,xoff1) & startmask);
+ dst[1] = (dst[1] & ~endmask) | (~SCRLEFT(c,nfirst) & endmask);
+ afbScanlineInc(dst, widthDst);
+ }
+ break;
+ case RROP_COPY:
+ char1 = schar1;
+ char2 = schar2;
+ char3 = schar3;
+ char4 = schar4;
+
+ while (hTmp--) {
+ GetBits4
+ dst[0] = (dst[0] & ~startmask) | (SCRRIGHT(c,xoff1) & startmask);
+ dst[1] = (dst[1] & ~endmask) | (SCRLEFT(c,nfirst) & endmask);
+ afbScanlineInc(dst, widthDst);
+ }
+ break;
+
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ... ) */
+ }
+#endif
+ xpos += widthGlyphs;
+ }
+ }
+
+ while(nglyph--) {
+ xoff1 = xpos & PIM;
+ schar1 = (glyphPointer) FONTGLYPHBITS(pglyphBase,(*ppci++));
+ hTmp = h;
+ saveDst = afbScanlineOffset(pdstBase, (xpos >> PWSH));
+
+ if (xoff1 + widthGlyph <= PPW) {
+ maskpartialbits (xoff1, widthGlyph, startmask);
+
+ for (d = 0; d < depthDst; d++) {
+ hTmp = h;
+ dst = saveDst;
+ saveDst += sizeDst; /* @@@ NEXT PLANE @@@ */
+ char1 = schar1;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (hTmp--) {
+ (*dst) &= ~startmask;
+ afbScanlineInc(dst, widthDst);
+ }
+ break;
+ case RROP_WHITE:
+ while (hTmp--) {
+ (*dst) |= startmask;
+ afbScanlineInc(dst, widthDst);
+ }
+ break;
+ case RROP_INVERT:
+ while (hTmp--) {
+#ifdef FASTCHARS
+#ifdef USE_LEFTBITS
+ FASTGETBITS (char1,0,widthGlyph,c);
+ char1 = (glyphPointer) (((char *) char1) + glyphBytes);
+#else
+ c = *char1++;
+#if BITMAP_BIT_ORDER == MSBFirst
+ c >>= PPW - widthGlyph;
+#endif
+#endif
+ FASTPUTBITS (~c,xoff1,widthGlyph,dst);
+#else
+ GetBits1
+ (*dst) = ((*dst) & ~startmask) | (~SCRRIGHT(c, xoff1) & startmask);
+#endif
+ afbScanlineInc(dst, widthDst);
+ }
+ break;
+ case RROP_COPY:
+ while (hTmp--) {
+#ifdef FASTCHARS
+#ifdef USE_LEFTBITS
+ FASTGETBITS (char1,0,widthGlyph,c);
+ char1 = (glyphPointer) (((char *) char1) + glyphBytes);
+#else
+ c = *char1++;
+#if BITMAP_BIT_ORDER == MSBFirst
+ c >>= PPW - widthGlyph;
+#endif
+#endif
+ FASTPUTBITS (c,xoff1,widthGlyph,dst);
+#else
+ GetBits1
+ (*dst) = ((*dst) & ~startmask) | (SCRRIGHT(c, xoff1) & startmask);
+#endif
+ afbScanlineInc(dst, widthDst);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ...) */
+ } else {
+ maskPPWbits (xoff1, widthGlyph, startmask, endmask);
+ nfirst = PPW - xoff1;
+
+ for (d = 0; d < depthDst; d++) {
+ hTmp = h;
+ dst = saveDst;
+ saveDst += sizeDst; /* @@@ NEXT PLANE @@@ */
+ char1 = schar1;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (hTmp--) {
+ dst[0] &= ~startmask;
+ dst[1] &= ~endmask;
+ afbScanlineInc(dst, widthDst);
+ }
+ break;
+ case RROP_WHITE:
+ while (hTmp--) {
+ dst[0] |= startmask;
+ dst[1] |= endmask;
+ afbScanlineInc(dst, widthDst);
+ }
+ break;
+ case RROP_INVERT:
+ while (hTmp--) {
+ GetBits1
+ dst[0] = (dst[0] & ~startmask) | (~SCRRIGHT(c,xoff1) & startmask);
+ dst[1] = (dst[1] & ~endmask) | (~SCRLEFT(c,nfirst) & endmask);
+ afbScanlineInc(dst, widthDst);
+ }
+ break;
+ case RROP_COPY:
+ while (hTmp--) {
+ GetBits1
+ dst[0] = (dst[0] & ~startmask) | (SCRRIGHT(c,xoff1) & startmask);
+ dst[1] = (dst[1] & ~endmask) | (SCRLEFT(c,nfirst) & endmask);
+ afbScanlineInc(dst, widthDst);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ...) */
+ }
+
+ xpos += widthGlyph;
+ }
+}
diff --git a/nx-X11/programs/Xserver/afb/afbtile.c b/nx-X11/programs/Xserver/afb/afbtile.c
new file mode 100644
index 000000000..11d76abdf
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbtile.c
@@ -0,0 +1,859 @@
+/* $XFree86: xc/programs/Xserver/afb/afbtile.c,v 3.3tsi Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: afbtile.c,v 5.8 94/04/17 20:28:36 dpw Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "windowstr.h"
+#include "regionstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "afb.h"
+
+#include "maskbits.h"
+
+#include "mergerop.h"
+/*
+
+ the boxes are already translated.
+
+ NOTE:
+ iy = ++iy < tileHeight ? iy : 0
+is equivalent to iy%= tileheight, and saves a division.
+*/
+
+/*
+ tile area with a PPW bit wide pixmap
+*/
+void
+MROP_NAME(afbTileAreaPPW)(pDraw, nbox, pbox, alu, ptile, planemask)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ int alu;
+ PixmapPtr ptile;
+ unsigned long planemask;
+{
+ register PixelType *psrc;
+ /* pointer to bits in tile, if needed */
+ int tileHeight; /* height of the tile */
+ register PixelType srcpix;
+ int nlwidth; /* width in longwords of the drawable */
+ int w; /* width of current box */
+ MROP_DECLARE_REG ()
+ register int h; /* height of current box */
+ register int nlw; /* loop version of nlwMiddle */
+ register PixelType *p; /* pointer to bits we're writing */
+ int sizeDst;
+ int depthDst;
+ register int d;
+ PixelType startmask;
+ PixelType endmask; /* masks for reggedy bits at either end of line */
+ int nlwMiddle; /* number of longwords between sides of boxes */
+ int nlwExtra; /* to get from right of box to left of next span */
+ register int iy; /* index of current scanline in tile */
+ PixelType *pbits; /* pointer to start of drawable */
+ PixelType *saveP;
+ PixelType *pSaveSrc;
+ int saveH;
+ int saveIY;
+
+ afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
+ pbits);
+
+ MROP_INITIALIZE(alu,~0)
+
+ tileHeight = ptile->drawable.height;
+ pSaveSrc = (PixelType *)(ptile->devPrivate.ptr);
+
+ while (nbox--) {
+ w = pbox->x2 - pbox->x1;
+ saveH = pbox->y2 - pbox->y1;
+ saveIY = pbox->y1 % tileHeight;
+ saveP = afbScanline(pbits, pbox->x1, pbox->y1, nlwidth);
+ psrc = pSaveSrc;
+
+ if (((pbox->x1 & PIM) + w) < PPW) {
+ maskpartialbits(pbox->x1, w, startmask);
+ nlwExtra = nlwidth;
+ for (d = 0; d < depthDst; d++, saveP += sizeDst, psrc += tileHeight) { /* @@@ NEXT PLANE @@@ */
+ if (!(planemask & (1 << d)))
+ continue;
+
+ p = saveP;
+ h = saveH;
+ iy = saveIY;
+
+ while (h--) {
+ srcpix = psrc[iy];
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ *p = MROP_MASK(srcpix,*p,startmask);
+ afbScanlineInc(p, nlwExtra);
+ }
+ }
+ } else {
+ maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
+
+ for (d = 0; d < depthDst; d++, saveP += sizeDst, psrc += tileHeight) { /* @@@ NEXT PLANE @@@ */
+ if (!(planemask & (1 << d)))
+ continue;
+
+ p = saveP;
+ h = saveH;
+ iy = saveIY;
+ nlwExtra = nlwidth - nlwMiddle;
+
+ if (startmask && endmask) {
+ nlwExtra -= 1;
+ while (h--) {
+ srcpix = psrc[iy];
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ *p = MROP_MASK (srcpix,*p,startmask);
+ p++;
+ while (nlw--) {
+ *p = MROP_SOLID(srcpix,*p);
+ p++;
+ }
+
+ *p = MROP_MASK(srcpix,*p,endmask);
+ afbScanlineInc(p, nlwExtra);
+ }
+ } else if (startmask && !endmask) {
+ nlwExtra -= 1;
+ while (h--) {
+ srcpix = psrc[iy];
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ *p = MROP_MASK(srcpix,*p,startmask);
+ p++;
+ while (nlw--) {
+ *p = MROP_SOLID(srcpix,*p);
+ p++;
+ }
+ afbScanlineInc(p, nlwExtra);
+ }
+ } else if (!startmask && endmask) {
+ while (h--) {
+ srcpix = psrc[iy];
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ while (nlw--) {
+ *p = MROP_SOLID(srcpix,*p);
+ p++;
+ }
+
+ *p = MROP_MASK(srcpix,*p,endmask);
+ afbScanlineInc(p, nlwExtra);
+ }
+ } else { /* no ragged bits at either end */
+ while (h--) {
+ srcpix = psrc[iy];
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ while (nlw--) {
+ *p = MROP_SOLID (srcpix,*p);
+ p++;
+ }
+ afbScanlineInc(p, nlwExtra);
+ }
+ }
+ } /* for (d = ...) */
+ }
+ pbox++;
+ }
+}
+
+void
+MROP_NAME(afbTileArea)(pDraw, nbox, pbox, alu, pTile, xOff, yOff, planemask)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ int alu;
+ PixmapPtr pTile;
+ int xOff;
+ int yOff;
+ unsigned long planemask;
+{
+ register PixelType *psrc;
+ /* pointer to bits in tile, if needed */
+ int nlwidth; /* width in longwords of the drawable */
+ MROP_DECLARE_REG ()
+ register int h; /* height of current box */
+ register PixelType *pdst; /* pointer to bits we're writing */
+ register PixelType tmpsrc;
+#if (MROP) != Mcopy
+ register PixelType tmpdst;
+#endif
+ int sizeDst;
+ int depthDst;
+ int sizeTile;
+ int tileLine;
+ int iline;
+ int w, width, x, xSrc, ySrc, srcStartOver, nend;
+ int tlwidth, rem, tileWidth, tileHeight, endinc;
+ int saveW;
+ PixelType *psrcT;
+ int d;
+ int nstart;
+ PixelType startmask;
+ PixelType endmask; /* masks for reggedy bits at either end of line */
+ int nlMiddle; /* number of longwords between sides of boxes */
+ int iy;
+ PixelType *pBase; /* pointer to start of drawable */
+ PixelType *saveP;
+ PixelType *pStartDst;
+ PixelType *pStartTile;
+ int saveH;
+
+ afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
+ pBase);
+
+ MROP_INITIALIZE(alu,~0)
+
+ tileHeight = pTile->drawable.height;
+ tileWidth = pTile->drawable.width;
+ tlwidth = pTile->devKind / sizeof (PixelType);
+ sizeTile = tlwidth * tileHeight;
+
+ xSrc = pDraw->x + ((xOff % tileWidth) - tileWidth);
+ ySrc = pDraw->y + ((yOff % tileHeight) - tileHeight);
+
+ while (nbox--) {
+ saveW = pbox->x2 - pbox->x1;
+ iline = (pbox->y1 - ySrc) % tileHeight;
+ psrcT = (PixelType *) pTile->devPrivate.ptr;
+ tileLine = iline * tlwidth;
+ saveH = pbox->y2 - pbox->y1;
+ saveP = afbScanline(pBase, pbox->x1, pbox->y1, nlwidth);
+
+ for (d = 0; d < depthDst; d++, psrcT += sizeTile, saveP += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ if (!(planemask & (1 << d)))
+ continue;
+
+ h = saveH;
+ pStartDst = saveP;
+ pStartTile = psrcT + tileLine;
+ iy = iline;
+
+ while (h--) {
+ x = pbox->x1;
+ width = saveW;
+ pdst = pStartDst;
+ while(width > 0) {
+ psrc = pStartTile;
+ w = min(tileWidth, width);
+ if((rem = (x - xSrc) % tileWidth) != 0) {
+ /* if we're in the middle of the tile, get
+ as many bits as will finish the span, or
+ as many as will get to the left edge of the tile,
+ or a longword worth, starting at the appropriate
+ offset in the tile.
+ */
+ w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
+ endinc = rem / BITMAP_SCANLINE_PAD;
+
+ getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
+#if (MROP) != Mcopy
+ getbits (pdst, (x & PIM), w, tmpdst);
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ putbits (tmpsrc, (x & PIM), w, pdst);
+
+ if((x & PIM) + w >= PPW)
+ pdst++;
+ } else if(((x & PIM) + w) < PPW) {
+ /* doing < PPW bits is easy, and worth special-casing */
+ tmpsrc = *psrc;
+#if (MROP) != Mcopy
+ getbits (pdst, (x & PIM), w, tmpdst);
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ putbits (tmpsrc, (x & PIM), w, pdst);
+ } else {
+ /* start at the left edge of the tile,
+ and put down as much as we can
+ */
+ maskbits(x, w, startmask, endmask, nlMiddle);
+
+ if (startmask)
+ nstart = PPW - (x & PIM);
+ else
+ nstart = 0;
+ if (endmask)
+ nend = (x + w) & PIM;
+ else
+ nend = 0;
+
+ srcStartOver = nstart > PLST;
+
+ if(startmask) {
+ tmpsrc = *psrc;
+#if (MROP) != Mcopy
+ getbits (pdst, (x & PIM), nstart, tmpdst);
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ putbits (tmpsrc, (x & PIM), nstart, pdst);
+ pdst++;
+ if(srcStartOver)
+ psrc++;
+ }
+
+ while(nlMiddle--) {
+ getbits (psrc, nstart, PPW, tmpsrc);
+#if (MROP) != Mcopy
+ tmpdst = *pdst;
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ *pdst++ = tmpsrc;
+ /*putbits (tmpsrc, 0, PPW, pdst);
+ pdst++;*/
+ psrc++;
+ }
+
+ if(endmask) {
+ getbits (psrc, nstart, nend, tmpsrc);
+#if (MROP) != Mcopy
+ tmpdst = *pdst;
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ putbits (tmpsrc, 0, nend, pdst);
+ }
+ }
+ x += w;
+ width -= w;
+ } /* while (width > 0) */
+
+ pStartDst += nlwidth;
+ if (++iy >= tileHeight) {
+ iy = 0;
+ pStartTile = psrcT;
+ } else
+ pStartTile += tlwidth;
+
+ } /* while (h) */
+ } /* for (d = ... ) */
+ pbox++;
+ } /* for each box */
+}
+
+void
+MROP_NAME(afbOpaqueStippleAreaPPW)(pDraw, nbox, pbox, alu, ptile,
+ rropsOS, planemask)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ int alu;
+ PixmapPtr ptile;
+ register unsigned char *rropsOS;
+ unsigned long planemask;
+{
+ register PixelType *psrc;
+ /* pointer to bits in tile, if needed */
+ int tileHeight; /* height of the tile */
+ register PixelType srcpix = 0;
+ int nlwidth; /* width in longwords of the drawable */
+ int w; /* width of current box */
+ MROP_DECLARE_REG ()
+ register int h; /* height of current box */
+ register int nlw; /* loop version of nlwMiddle */
+ register PixelType *p; /* pointer to bits we're writing */
+ int sizeDst;
+ int depthDst;
+ register int d;
+ PixelType startmask;
+ PixelType endmask; /* masks for reggedy bits at either end of line */
+ int nlwMiddle; /* number of longwords between sides of boxes */
+ int nlwExtra; /* to get from right of box to left of next span */
+ register int iy; /* index of current scanline in tile */
+ PixelType *pbits; /* pointer to start of drawable */
+ PixelType *saveP;
+ int saveH;
+ int saveIY;
+
+ afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
+ pbits);
+
+ MROP_INITIALIZE(alu,~0)
+
+ tileHeight = ptile->drawable.height;
+ psrc = (PixelType *)(ptile->devPrivate.ptr);
+
+ while (nbox--) {
+ w = pbox->x2 - pbox->x1;
+ saveH = pbox->y2 - pbox->y1;
+ saveIY = pbox->y1 % tileHeight;
+ saveP = afbScanline(pbits, pbox->x1, pbox->y1, nlwidth);
+
+ if ( ((pbox->x1 & PIM) + w) < PPW) {
+ maskpartialbits(pbox->x1, w, startmask);
+ nlwExtra = nlwidth;
+ for (d = 0; d < depthDst; d++, saveP += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ if (!(planemask & (1 << d)))
+ continue;
+
+ p = saveP;
+ h = saveH;
+ iy = saveIY;
+
+ while (h--) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ srcpix = 0;
+ break;
+ case RROP_WHITE:
+ srcpix = ~0;
+ break;
+ case RROP_COPY:
+ srcpix = psrc[iy];
+ break;
+ case RROP_INVERT:
+ srcpix = ~psrc[iy];
+ break;
+ }
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ *p = MROP_MASK(srcpix,*p,startmask);
+ afbScanlineInc(p, nlwExtra);
+ }
+ }
+ } else {
+ maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
+
+ for (d = 0; d < depthDst; d++, saveP += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ if (!(planemask & (1 << d)))
+ continue;
+
+ p = saveP;
+ h = saveH;
+ iy = saveIY;
+ nlwExtra = nlwidth - nlwMiddle;
+
+ if (startmask && endmask) {
+ nlwExtra -= 1;
+ while (h--) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ srcpix = 0;
+ break;
+ case RROP_WHITE:
+ srcpix = ~0;
+ break;
+ case RROP_COPY:
+ srcpix = psrc[iy];
+ break;
+ case RROP_INVERT:
+ srcpix = ~psrc[iy];
+ break;
+ }
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ *p = MROP_MASK (srcpix,*p,startmask);
+ p++;
+ while (nlw--) {
+ *p = MROP_SOLID(srcpix,*p);
+ p++;
+ }
+
+ *p = MROP_MASK(srcpix,*p,endmask);
+ afbScanlineInc(p, nlwExtra);
+ }
+ } else if (startmask && !endmask) {
+ nlwExtra -= 1;
+ while (h--) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ srcpix = 0;
+ break;
+ case RROP_WHITE:
+ srcpix = ~0;
+ break;
+ case RROP_COPY:
+ srcpix = psrc[iy];
+ break;
+ case RROP_INVERT:
+ srcpix = ~psrc[iy];
+ break;
+ }
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ *p = MROP_MASK(srcpix,*p,startmask);
+ p++;
+ while (nlw--) {
+ *p = MROP_SOLID(srcpix,*p);
+ p++;
+ }
+ afbScanlineInc(p, nlwExtra);
+ }
+ } else if (!startmask && endmask) {
+ while (h--) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ srcpix = 0;
+ break;
+ case RROP_WHITE:
+ srcpix = ~0;
+ break;
+ case RROP_COPY:
+ srcpix = psrc[iy];
+ break;
+ case RROP_INVERT:
+ srcpix = ~psrc[iy];
+ break;
+ }
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ while (nlw--) {
+ *p = MROP_SOLID(srcpix,*p);
+ p++;
+ }
+
+ *p = MROP_MASK(srcpix,*p,endmask);
+ afbScanlineInc(p, nlwExtra);
+ }
+ } else { /* no ragged bits at either end */
+ while (h--) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ srcpix = 0;
+ break;
+ case RROP_WHITE:
+ srcpix = ~0;
+ break;
+ case RROP_COPY:
+ srcpix = psrc[iy];
+ break;
+ case RROP_INVERT:
+ srcpix = ~psrc[iy];
+ break;
+ }
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ while (nlw--) {
+ *p = MROP_SOLID (srcpix,*p);
+ p++;
+ }
+ afbScanlineInc(p, nlwExtra);
+ }
+ }
+ } /* for (d = ...) */
+ }
+ pbox++;
+ }
+}
+
+void
+MROP_NAME(afbOpaqueStippleArea)(pDraw, nbox, pbox, alu, pTile, xOff, yOff,
+ rropsOS, planemask)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ int alu;
+ PixmapPtr pTile;
+ int xOff;
+ int yOff;
+ register unsigned char *rropsOS;
+ unsigned long planemask;
+{
+ register PixelType *psrc;
+ /* pointer to bits in tile, if needed */
+ int nlwidth; /* width in longwords of the drawable */
+ MROP_DECLARE_REG ()
+ register int h; /* height of current box */
+ register PixelType *pdst; /* pointer to bits we're writing */
+ register PixelType tmpsrc = 0;
+#if (MROP) != Mcopy
+ register PixelType tmpdst;
+#endif
+ int sizeDst;
+ int depthDst;
+ int tileLine;
+ int iline;
+ int w, width, x, xSrc, ySrc, srcStartOver, nend;
+ int tlwidth, rem, tileWidth, tileHeight, endinc;
+ int saveW;
+ PixelType *psrcT;
+ int d;
+ int nstart;
+ PixelType startmask;
+ PixelType endmask; /* masks for reggedy bits at either end of line */
+ int nlMiddle; /* number of longwords between sides of boxes */
+ int iy;
+ PixelType *pBase; /* pointer to start of drawable */
+ PixelType *saveP;
+ PixelType *pStartDst;
+ PixelType *pStartTile;
+ int saveH;
+
+ afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
+ pBase);
+
+ MROP_INITIALIZE(alu,~0)
+
+ tileHeight = pTile->drawable.height;
+ tileWidth = pTile->drawable.width;
+ tlwidth = pTile->devKind / sizeof (PixelType);
+
+ xSrc = pDraw->x + ((xOff % tileWidth) - tileWidth);
+ ySrc = pDraw->y + ((yOff % tileHeight) - tileHeight);
+
+ while (nbox--) {
+ saveW = pbox->x2 - pbox->x1;
+ iline = (pbox->y1 - ySrc) % tileHeight;
+ psrcT = (PixelType *) pTile->devPrivate.ptr;
+ tileLine = iline * tlwidth;
+ saveH = pbox->y2 - pbox->y1;
+ saveP = afbScanline(pBase, pbox->x1, pbox->y1, nlwidth);
+
+ for (d = 0; d < depthDst; d++, saveP += sizeDst) { /* @@@ NEXT PLANE @@@ */
+ if (!(planemask & (1 << d)))
+ continue;
+
+ h = saveH;
+ pStartDst = saveP;
+ pStartTile = psrcT + tileLine;
+ iy = iline;
+
+ while (h--) {
+ x = pbox->x1;
+ width = saveW;
+ pdst = pStartDst;
+ while(width > 0) {
+ psrc = pStartTile;
+ w = min(tileWidth, width);
+ if((rem = (x - xSrc) % tileWidth) != 0) {
+ /* if we're in the middle of the tile, get
+ as many bits as will finish the span, or
+ as many as will get to the left edge of the tile,
+ or a longword worth, starting at the appropriate
+ offset in the tile.
+ */
+ w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
+ endinc = rem / BITMAP_SCANLINE_PAD;
+
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+
+ case RROP_COPY:
+ getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
+ break;
+
+ case RROP_INVERT:
+ getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
+ tmpsrc = ~tmpsrc;
+ break;
+ }
+#if (MROP) != Mcopy
+ getbits (pdst, (x & PIM), w, tmpdst);
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ putbits (tmpsrc, (x & PIM), w, pdst);
+
+ if((x & PIM) + w >= PPW)
+ pdst++;
+ } else if(((x & PIM) + w) < PPW) {
+ /* doing < PPW bits is easy, and worth special-casing */
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+ case RROP_COPY:
+ tmpsrc = *psrc;
+ break;
+ case RROP_INVERT:
+ tmpsrc = ~*psrc;
+ break;
+ }
+#if (MROP) != Mcopy
+ getbits (pdst, (x & PIM), w, tmpdst);
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ putbits (tmpsrc, (x & PIM), w, pdst);
+ } else {
+ /* start at the left edge of the tile,
+ and put down as much as we can
+ */
+ maskbits(x, w, startmask, endmask, nlMiddle);
+
+ if (startmask)
+ nstart = PPW - (x & PIM);
+ else
+ nstart = 0;
+ if (endmask)
+ nend = (x + w) & PIM;
+ else
+ nend = 0;
+
+ srcStartOver = nstart > PLST;
+
+ if(startmask) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+ case RROP_COPY:
+ tmpsrc = *psrc;
+ break;
+ case RROP_INVERT:
+ tmpsrc = ~*psrc;
+ break;
+ }
+#if (MROP) != Mcopy
+ getbits (pdst, (x & PIM), nstart, tmpdst);
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ putbits (tmpsrc, (x & PIM), nstart, pdst);
+ pdst++;
+ if(srcStartOver)
+ psrc++;
+ }
+
+ while(nlMiddle--) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+ case RROP_COPY:
+ getbits (psrc, nstart, PPW, tmpsrc);
+ break;
+ case RROP_INVERT:
+ getbits (psrc, nstart, PPW, tmpsrc);
+ tmpsrc = ~tmpsrc;
+ break;
+ }
+#if (MROP) != Mcopy
+ tmpdst = *pdst;
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ *pdst++ = tmpsrc;
+ /*putbits (tmpsrc, 0, PPW, pdst);
+ pdst++; */
+ psrc++;
+ }
+
+ if(endmask) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+
+ case RROP_COPY:
+ getbits (psrc, nstart, nend, tmpsrc);
+ break;
+
+ case RROP_INVERT:
+ getbits (psrc, nstart, nend, tmpsrc);
+ tmpsrc = ~tmpsrc;
+ break;
+ }
+#if (MROP) != Mcopy
+ tmpdst = *pdst;
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ putbits (tmpsrc, 0, nend, pdst);
+ }
+ }
+ x += w;
+ width -= w;
+ } /* while (width > 0) */
+
+ pStartDst += nlwidth;
+ if (++iy >= tileHeight) {
+ iy = 0;
+ pStartTile = psrcT;
+ } else
+ pStartTile += tlwidth;
+
+ } /* while (h) */
+ } /* for (d = ... ) */
+ pbox++;
+ } /* for each box */
+}
diff --git a/nx-X11/programs/Xserver/afb/afbwindow.c b/nx-X11/programs/Xserver/afb/afbwindow.c
new file mode 100644
index 000000000..443dd5aed
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbwindow.c
@@ -0,0 +1,318 @@
+/* $XFree86: xc/programs/Xserver/afb/afbwindow.c,v 3.0 1996/08/18 01:45:58 dawes Exp $ */
+/* $XConsortium: afbwindow.c,v 5.14 94/04/17 20:28:36 dpw Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "afb.h"
+#include "mistruct.h"
+#include "regionstr.h"
+#include "maskbits.h"
+
+Bool
+afbCreateWindow(pWin)
+ register WindowPtr pWin;
+{
+ register afbPrivWin *pPrivWin;
+
+ pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
+ pPrivWin->pRotatedBorder = NullPixmap;
+ pPrivWin->pRotatedBackground = NullPixmap;
+ pPrivWin->fastBackground = FALSE;
+ pPrivWin->fastBorder = FALSE;
+#ifdef PIXMAP_PER_WINDOW
+ pWin->devPrivates[frameWindowPrivateIndex].ptr =
+ pWin->pDrawable.pScreen->devPrivates[afbScreenPrivateIndex].ptr;
+#endif
+
+ return (TRUE);
+}
+
+/* This always returns true, because Xfree can't fail. It might be possible
+ * on some devices for Destroy to fail */
+Bool
+afbDestroyWindow(pWin)
+ WindowPtr pWin;
+{
+ register afbPrivWin *pPrivWin;
+
+ pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
+
+ if (pPrivWin->pRotatedBorder)
+ (*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
+ if (pPrivWin->pRotatedBackground)
+ (*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBackground);
+
+ return (TRUE);
+}
+
+/*ARGSUSED*/
+Bool
+afbMapWindow(pWindow)
+ WindowPtr pWindow;
+{
+ return (TRUE);
+}
+
+/* (x, y) is the upper left corner of the window on the screen
+ do we really need to pass this? (is it a;ready in pWin->absCorner?)
+ we only do the rotation for pixmaps that are 32 bits wide (padded
+or otherwise.)
+ afbChangeWindowAttributes() has already put a copy of the pixmap
+in pPrivWin->pRotated*
+*/
+
+/*ARGSUSED*/
+Bool
+afbPositionWindow(pWin, x, y)
+ WindowPtr pWin;
+ int x, y;
+{
+ register afbPrivWin *pPrivWin;
+ int reset = 0;
+
+ pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
+ if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground) {
+ afbXRotatePixmap(pPrivWin->pRotatedBackground,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ afbYRotatePixmap(pPrivWin->pRotatedBackground,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ reset = 1;
+ }
+
+ if (!pWin->borderIsPixel && pPrivWin->fastBorder) {
+ while (pWin->backgroundState == ParentRelative)
+ pWin = pWin->parent;
+ afbXRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ afbYRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ reset = 1;
+ }
+ if (reset) {
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ }
+
+ /* This is the "wrong" fix to the right problem, but it doesn't really
+ * cost very much. When the window is moved, we need to invalidate any
+ * RotatedPixmap that exists in any GC currently validated against this
+ * window.
+ */
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+ /* Again, we have no failure modes indicated by any of the routines
+ * we've called, so we have to assume it worked */
+ return (TRUE);
+}
+
+/*ARGSUSED*/
+Bool
+afbUnmapWindow(pWindow)
+ WindowPtr pWindow;
+{
+ return (TRUE);
+}
+
+/* UNCLEAN!
+ this code calls the bitblt helper code directly.
+
+ afbCopyWindow copies only the parts of the destination that are
+visible in the source.
+*/
+
+
+void
+afbCopyWindow(pWin, ptOldOrg, prgnSrc)
+ WindowPtr pWin;
+ DDXPointRec ptOldOrg;
+ RegionPtr prgnSrc;
+{
+ DDXPointPtr pptSrc;
+ register DDXPointPtr ppt;
+ RegionPtr prgnDst;
+ register BoxPtr pbox;
+ register int dx, dy;
+ register int i, nbox;
+ WindowPtr pwinRoot;
+
+ pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
+
+ prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+ REGION_INTERSECT(pWin->drawable.pScreen, prgnDst, &pWin->borderClip,
+ prgnSrc);
+
+ pbox = REGION_RECTS(prgnDst);
+ nbox = REGION_NUM_RECTS(prgnDst);
+ if(!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
+ return;
+ ppt = pptSrc;
+
+ for (i=nbox; --i >= 0; ppt++, pbox++) {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ afbDoBitblt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, GXcopy, prgnDst,
+ pptSrc, ~0);
+ DEALLOCATE_LOCAL(pptSrc);
+ REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
+}
+
+
+
+/* swap in correct PaintWindow* routine. If we can use a fast output
+routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
+of it in devPrivate.
+*/
+Bool
+afbChangeWindowAttributes(pWin, mask)
+ register WindowPtr pWin;
+ register unsigned long mask;
+{
+ register unsigned long index;
+ register afbPrivWin *pPrivWin;
+ WindowPtr pBgWin;
+
+ pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
+ /*
+ * When background state changes from ParentRelative and
+ * we had previously rotated the fast border pixmap to match
+ * the parent relative origin, rerotate to match window
+ */
+ if (mask & (CWBackPixmap | CWBackPixel) &&
+ pWin->backgroundState != ParentRelative && pPrivWin->fastBorder &&
+ (pPrivWin->oldRotate.x != pWin->drawable.x ||
+ pPrivWin->oldRotate.y != pWin->drawable.y)) {
+ afbXRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ afbYRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ }
+ while(mask) {
+ index = lowbit (mask);
+ mask &= ~index;
+ switch(index) {
+ case CWBackPixmap:
+ if (pWin->backgroundState == None)
+ pPrivWin->fastBackground = FALSE;
+ else if (pWin->backgroundState == ParentRelative) {
+ pPrivWin->fastBackground = FALSE;
+ /* Rotate border to match parent origin */
+ if (pPrivWin->pRotatedBorder) {
+ for (pBgWin = pWin->parent;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+ afbXRotatePixmap(pPrivWin->pRotatedBorder,
+ pBgWin->drawable.x - pPrivWin->oldRotate.x);
+ afbYRotatePixmap(pPrivWin->pRotatedBorder,
+ pBgWin->drawable.y - pPrivWin->oldRotate.y);
+ pPrivWin->oldRotate.x = pBgWin->drawable.x;
+ pPrivWin->oldRotate.y = pBgWin->drawable.y;
+ }
+ } else if ((pWin->background.pixmap->drawable.width <= PPW) &&
+ !(pWin->background.pixmap->drawable.width &
+ (pWin->background.pixmap->drawable.width - 1))) {
+ afbCopyRotatePixmap(pWin->background.pixmap,
+ &pPrivWin->pRotatedBackground,
+ pWin->drawable.x, pWin->drawable.y);
+ if (pPrivWin->pRotatedBackground) {
+ pPrivWin->fastBackground = TRUE;
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ } else
+ pPrivWin->fastBackground = FALSE;
+ } else
+ pPrivWin->fastBackground = FALSE;
+ break;
+
+ case CWBackPixel:
+ pPrivWin->fastBackground = FALSE;
+ break;
+
+ case CWBorderPixmap:
+ if ((pWin->border.pixmap->drawable.width <= PPW) &&
+ !(pWin->border.pixmap->drawable.width &
+ (pWin->border.pixmap->drawable.width - 1))) {
+ for (pBgWin = pWin;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+ afbCopyRotatePixmap(pWin->border.pixmap,
+ &pPrivWin->pRotatedBorder,
+ pBgWin->drawable.x, pBgWin->drawable.y);
+ if (pPrivWin->pRotatedBorder) {
+ pPrivWin->fastBorder = TRUE;
+ pPrivWin->oldRotate.x = pBgWin->drawable.x;
+ pPrivWin->oldRotate.y = pBgWin->drawable.y;
+ } else
+ pPrivWin->fastBorder = FALSE;
+ } else
+ pPrivWin->fastBorder = FALSE;
+ break;
+ case CWBorderPixel:
+ pPrivWin->fastBorder = FALSE;
+ break;
+ }
+ }
+ /* Again, we have no failure modes indicated by any of the routines
+ * we've called, so we have to assume it worked */
+ return (TRUE);
+}
diff --git a/nx-X11/programs/Xserver/afb/afbzerarc.c b/nx-X11/programs/Xserver/afb/afbzerarc.c
new file mode 100644
index 000000000..ef62238db
--- /dev/null
+++ b/nx-X11/programs/Xserver/afb/afbzerarc.c
@@ -0,0 +1,210 @@
+/* $XFree86: xc/programs/Xserver/afb/afbzerarc.c,v 3.2 2001/10/28 03:32:59 tsi Exp $ */
+/************************************************************
+
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+********************************************************/
+
+/* $XConsortium: afbzerarc.c,v 5.19 94/04/17 20:28:37 dpw Exp $ */
+
+/* Derived from:
+ * "Algorithm for drawing ellipses or hyperbolae with a digital plotter"
+ * by M. L. V. Pitteway
+ * The Computer Journal, November 1967, Volume 10, Number 3, pp. 282-289
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "afb.h"
+#include "maskbits.h"
+#include "mizerarc.h"
+#include "mi.h"
+
+/*
+ * Note: LEFTMOST must be the bit leftmost in the actual screen
+ * representation. This depends also on the IMAGE_BYTE_ORDER.
+ * LONG2CHARS() takes care of the re-ordering as required. (DHD)
+ */
+#if (BITMAP_BIT_ORDER == MSBFirst)
+#define LEFTMOST ((PixelType) LONG2CHARS((1 << PLST)))
+#else
+#define LEFTMOST ((PixelType) LONG2CHARS(1))
+#endif
+
+#define Pixelate(base,yoff,xoff) \
+{ \
+ paddr = afbScanlineOffset(base, (yoff) + ((xoff)>>PWSH)); \
+ pmask = SCRRIGHT(LEFTMOST, (xoff) & PIM); \
+ for (de = 0; de < depthDst; de++, paddr += sizeDst) /* @@@ NEXT PLANE @@@ */ \
+ switch (rrops[de]) { \
+ case RROP_BLACK: \
+ *paddr &= ~pmask; \
+ break; \
+ case RROP_WHITE: \
+ *paddr |= pmask; \
+ break; \
+ case RROP_INVERT: \
+ *paddr ^= pmask; \
+ break; \
+ case RROP_NOP: \
+ break; \
+ } \
+}
+
+#define DoPix(bit,base,yoff,xoff) if (mask & bit) Pixelate(base,yoff,xoff);
+
+static void
+afbZeroArcSS(pDraw, pGC, arc)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ xArc *arc;
+{
+ miZeroArcRec info;
+ Bool do360;
+ register int de;
+ register int x, y, a, b, d, mask;
+ register int k1, k3, dx, dy;
+ PixelType *addrl;
+ PixelType *yorgl, *yorgol;
+ int nlwidth, yoffset, dyoffset;
+ int sizeDst, depthDst;
+ PixelType pmask;
+ register PixelType *paddr;
+ register unsigned char *rrops;
+
+ rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
+
+ afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
+ addrl);
+ do360 = miZeroArcSetup(arc, &info, TRUE);
+ yorgl = addrl + ((info.yorg + pDraw->y) * nlwidth);
+ yorgol = addrl + ((info.yorgo + pDraw->y) * nlwidth);
+ info.xorg += pDraw->x;
+ info.xorgo += pDraw->x;
+ MIARCSETUP();
+ yoffset = y ? nlwidth : 0;
+ dyoffset = 0;
+ mask = info.initialMask;
+ if (!(arc->width & 1)) {
+ DoPix(2, yorgl, 0, info.xorgo);
+ DoPix(8, yorgol, 0, info.xorgo);
+ }
+ if (!info.end.x || !info.end.y) {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ if (do360 && (arc->width == arc->height) && !(arc->width & 1)) {
+ int xoffset = nlwidth;
+ PixelType *yorghl = afbScanlineDeltaNoBankSwitch(yorgl, info.h, nlwidth);
+ int xorghp = info.xorg + info.h;
+ int xorghn = info.xorg - info.h;
+
+ while (1) {
+ Pixelate(yorgl, yoffset, info.xorg + x);
+ Pixelate(yorgl, yoffset, info.xorg - x);
+ Pixelate(yorgol, -yoffset, info.xorg - x);
+ Pixelate(yorgol, -yoffset, info.xorg + x);
+ if (a < 0)
+ break;
+ Pixelate(yorghl, -xoffset, xorghp - y);
+ Pixelate(yorghl, -xoffset, xorghn + y);
+ Pixelate(yorghl, xoffset, xorghn + y);
+ Pixelate(yorghl, xoffset, xorghp - y);
+ xoffset += nlwidth;
+ MIARCCIRCLESTEP(yoffset += nlwidth;);
+ }
+ x = info.w;
+ yoffset = info.h * nlwidth;
+ } else if (do360) {
+ while (y < info.h || x < info.w) {
+ MIARCOCTANTSHIFT(dyoffset = nlwidth;);
+ Pixelate(yorgl, yoffset, info.xorg + x);
+ Pixelate(yorgl, yoffset, info.xorgo - x);
+ Pixelate(yorgol, -yoffset, info.xorgo - x);
+ Pixelate(yorgol, -yoffset, info.xorg + x);
+ MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;);
+ }
+ } else {
+ while (y < info.h || x < info.w) {
+ MIARCOCTANTSHIFT(dyoffset = nlwidth;);
+ if ((x == info.start.x) || (y == info.start.y)) {
+ mask = info.start.mask;
+ info.start = info.altstart;
+ }
+ DoPix(1, yorgl, yoffset, info.xorg + x);
+ DoPix(2, yorgl, yoffset, info.xorgo - x);
+ DoPix(4, yorgol, -yoffset, info.xorgo - x);
+ DoPix(8, yorgol, -yoffset, info.xorg + x);
+ if ((x == info.end.x) || (y == info.end.y)) {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;);
+ }
+ }
+ if ((x == info.start.x) || (y == info.start.y))
+ mask = info.start.mask;
+ DoPix(1, yorgl, yoffset, info.xorg + x);
+ DoPix(4, yorgol, -yoffset, info.xorgo - x);
+ if (arc->height & 1) {
+ DoPix(2, yorgl, yoffset, info.xorgo - x);
+ DoPix(8, yorgol, -yoffset, info.xorg + x);
+ }
+}
+
+void
+afbZeroPolyArcSS(pDraw, pGC, narcs, parcs)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int narcs;
+ xArc *parcs;
+{
+ register xArc *arc;
+ register int i;
+ BoxRec box;
+ RegionPtr cclip;
+
+ cclip = pGC->pCompositeClip;
+ for (arc = parcs, i = narcs; --i >= 0; arc++) {
+ if (miCanZeroArc(arc)) {
+ box.x1 = arc->x + pDraw->x;
+ box.y1 = arc->y + pDraw->y;
+ box.x2 = box.x1 + (int)arc->width + 1;
+ box.y2 = box.y1 + (int)arc->height + 1;
+ if (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN)
+ afbZeroArcSS(pDraw, pGC, arc);
+ else
+ miZeroPolyArc(pDraw, pGC, 1, arc);
+ } else
+ miPolyArc(pDraw, pGC, 1, arc);
+ }
+}
diff --git a/nx-X11/programs/Xserver/cfb/Imakefile b/nx-X11/programs/Xserver/cfb/Imakefile
new file mode 100644
index 000000000..5295c35da
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/Imakefile
@@ -0,0 +1,6 @@
+XCOMM $XFree86: xc/programs/Xserver/cfb/Imakefile,v 3.27 2002/05/31 15:12:55 dawes Exp $
+
+#define PixelSize 8
+
+#include "Imakefile.inc"
+
diff --git a/nx-X11/programs/Xserver/cfb/Imakefile.inc b/nx-X11/programs/Xserver/cfb/Imakefile.inc
new file mode 100644
index 000000000..bfb6c315e
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/Imakefile.inc
@@ -0,0 +1,303 @@
+XCOMM $XdotOrg: xc/programs/Xserver/cfb/Imakefile.inc,v 1.5 2005/07/11 19:13:26 ajax Exp $
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:12 cpqbld Exp $
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/cfb/Imakefile.inc,v 1.3tsi Exp $
+
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+#include <Server.tmpl>
+
+#ifndef PixelSize
+#define PixelSize 8
+#endif
+
+#if PixelSize == 8
+PSZSRCS = cfb8bit.c cfbteblt8.c cfbglrop8.c cfbpush8.c cfbrctstp8.c
+PSZOBJS = cfb8bit.o cfbteblt8.o cfbglrop8.o cfbpush8.o cfbrctstp8.o
+#ifdef MipsArchitecture
+#ifndef ArcArchitecture
+#ifndef Mips64Architecture
+STIPPLESRC = stipmips.s stipmipste.s
+STIPPLEOBJ = stipmips.o stipmipste.o
+STIPPLEDEF = -DHAS_STIPPLE_CODE
+#endif
+#endif
+#endif
+#ifdef SparcArchitecture
+#ifndef Sparc64Architecture
+STIPPLESRC = stipsparc.s stipsparcte.s
+STIPPLEOBJ = stipsparc.o stipsparcte.o
+STIPPLEDEF = -DHAS_STIPPLE_CODE
+#endif
+#endif
+#endif
+
+#if PixelSize == 32
+#ifdef SparcArchitecture
+#ifndef Sparc64Architecture
+STIPPLESRC = stipsprc32.s stipsprcte32.s
+STIPPLEOBJ = stipsprc32.o stipsprcte32.o
+STIPPLEDEF = -DHAS_STIPPLE_CODE
+#endif
+#endif
+#endif
+
+#ifdef SparcArchitecture
+# if DoLoadableServer && MakeDllModules
+# define SharedAsmDefines -DSHAREDCODE
+# else
+# define SharedAsmDefines /**/
+# endif
+ASMDEFINES = AsmDefines SharedAsmDefines
+#endif
+
+#if defined(IHaveModules)
+XFMODSRC = cfbmodule.c
+XFMODOBJ = cfbmodule.o
+#endif
+
+XCOMM THIS IS STUPID
+#if !(defined(IHaveModules) && defined(LinkDirectory))
+CFBCMAP = cfbcmap.o
+#endif
+
+SRCS = cfbgc.c cfbrrop.c cfbwindow.c \
+ cfbpntwin.c cfbmskbits.c cfbpixmap.c cfbbitblt.c \
+ cfbfillsp.c cfbsetsp.c cfbscrinit.c cfballpriv.c \
+ cfbgetsp.c cfbfillrct.c \
+ cfbsolidC.c cfbsolidX.c cfbsolidG.c \
+ cfbtileoddC.c cfbtileoddG.c cfbtile32C.c cfbtile32G.c \
+ cfbcmap.c cfbzerarcC.c cfbzerarcX.c cfbzerarcG.c \
+ cfbfillarcC.c cfbfillarcG.c \
+ cfbigblt8.c cfbglblt8.c cfbtegblt.c cfbbstore.c \
+ cfbbltC.c cfbbltX.c cfbbltO.c cfbbltG.c \
+ cfbpolypnt.c \
+ cfbbres.c cfbline.c cfbhrzvert.c cfbbresd.c cfbimage.c cfbseg.c \
+ cfb8lineCO.c cfb8lineX.c cfb8lineG.c cfb8lineCP.c \
+ cfb8segC.c cfb8segX.c cfb8segG.c cfb8segCS.c \
+ cfbply1rctC.c cfbply1rctG.c cfbcppl.c $(PSZSRCS) $(XFMODSRC)
+
+OBJS = cfbgc.o cfbrrop.o cfbwindow.o \
+ cfbgetsp.o cfbfillrct.o \
+ cfbsolidC.o cfbsolidX.o cfbsolidG.o \
+ cfbtileoddC.o cfbtileoddG.o cfbtile32C.o cfbtile32G.o \
+ cfbfillsp.o cfbsetsp.o cfbscrinit.o cfballpriv.o \
+ cfbpntwin.o cfbmskbits.o cfbpixmap.o \
+ cfbcmap.o cfbzerarcC.o cfbzerarcX.o cfbzerarcG.o \
+ cfbfillarcC.o cfbfillarcG.o \
+ cfbigblt8.o cfbglblt8.o cfbtegblt.o cfbbstore.o \
+ cfbpolypnt.o \
+ cfbbres.o cfbline.o cfbhrzvert.o cfbbresd.o cfbimage.o cfbseg.o \
+ cfb8lineCO.o cfb8lineX.o cfb8lineG.o cfb8lineCP.o \
+ cfb8segCS.o cfb8segX.o cfb8segG.o cfb8segC.o \
+ cfbbitblt.o cfbbltC.o cfbbltX.o cfbbltO.o cfbbltG.o \
+ cfbply1rctC.o cfbply1rctG.o cfbcppl.o $(PSZOBJS) $(STIPPLEOBJ) \
+ $(XFMODOBJ)
+
+#if (defined(XFree86Version) || defined(XorgVersion))
+PLATFORMDEFS = -DXFREE86
+#endif
+
+ INCLUDES = -I$(SERVERSRC)/cfb -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \
+ -I$(SERVERSRC)/cfb24 -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(FONTINCSRC) -I$(EXTINCSRC) -I$(SERVERSRC)/Xext
+ LINTLIBS = $(SERVERSRC)/dix/llib-ldix.ln $(SERVERSRC)/os/llib-los.ln \
+ $(SERVERSRC)/mfb/llib-lmfb.ln $(SERVERSRC)/mi/llib-lmi.ln
+ DEFINES = $(LMDEFINES) -DPSZ=PixelSize $(PLATFORMDEFS)
+
+#if PixelSize == 8
+CFBNAME = cfb
+#elif PixelSize == 16
+CFBNAME = cfb16
+#elif PixelSize == 24
+CFBNAME = cfb24
+#elif PixelSize == 32
+CFBNAME = cfb32
+#endif
+
+#ifdef IHaveModules
+ModuleObjectRule()
+LibraryModuleTarget($(CFBNAME),$(OBJS))
+#else
+NormalLibraryObjectRule()
+NormalLibraryTarget($(CFBNAME),$(OBJS))
+#endif
+
+LintLibraryTarget($(CFBNAME),$(SRCS))
+
+NormalLintTarget($(SRCS))
+
+#ifdef LinkDirectory
+
+LinkSourceFile(cfballpriv.c,LinkDirectory)
+LinkSourceFile(cfbbitblt.c,LinkDirectory)
+LinkSourceFile(cfbblt.c,LinkDirectory)
+LinkSourceFile(cfbbres.c,LinkDirectory)
+LinkSourceFile(cfbbresd.c,LinkDirectory)
+LinkSourceFile(cfbbstore.c,LinkDirectory)
+LinkSourceFile(cfbcmap.c,LinkDirectory)
+LinkSourceFile(cfbcppl.c,LinkDirectory)
+LinkSourceFile(cfbfillarc.c,LinkDirectory)
+LinkSourceFile(cfbfillrct.c,LinkDirectory)
+LinkSourceFile(cfbfillsp.c,LinkDirectory)
+LinkSourceFile(cfbgc.c,LinkDirectory)
+LinkSourceFile(cfbgetsp.c,LinkDirectory)
+LinkSourceFile(cfbhrzvert.c,LinkDirectory)
+LinkSourceFile(cfbimage.c,LinkDirectory)
+LinkSourceFile(cfbline.c,LinkDirectory)
+LinkSourceFile(cfb8line.c,LinkDirectory)
+LinkSourceFile(cfbmskbits.c,LinkDirectory)
+LinkSourceFile(cfbpixmap.c,LinkDirectory)
+LinkSourceFile(cfbply1rct.c,LinkDirectory)
+LinkSourceFile(cfbpntwin.c,LinkDirectory)
+LinkSourceFile(cfbpolypnt.c,LinkDirectory)
+LinkSourceFile(cfbrrop.c,LinkDirectory)
+LinkSourceFile(cfbscrinit.c,LinkDirectory)
+LinkSourceFile(cfbsetsp.c,LinkDirectory)
+LinkSourceFile(cfbsolid.c,LinkDirectory)
+LinkSourceFile(cfbigblt8.c,LinkDirectory)
+LinkSourceFile(cfbglblt8.c,LinkDirectory)
+LinkSourceFile(cfbtegblt.c,LinkDirectory)
+LinkSourceFile(cfbtileodd.c,LinkDirectory)
+LinkSourceFile(cfbtile32.c,LinkDirectory)
+LinkSourceFile(cfbwindow.c,LinkDirectory)
+LinkSourceFile(cfbzerarc.c,LinkDirectory)
+#if PixelSize == 8
+LinkSourceFile(cfb8bit.c,LinkDirectory)
+LinkSourceFile(cfbpush8.c,LinkDirectory)
+LinkSourceFile(cfbrctstp8.c,LinkDirectory)
+LinkSourceFile(cfbteblt8.c,LinkDirectory)
+#ifdef MipsArchitecture
+LinkSourceFile(stipmips.s,LinkDirectory)
+#endif
+#ifdef SparcArchitecture
+LinkSourceFile(stipsparc.s,LinkDirectory)
+#endif
+#endif
+#if PixelSize == 32
+#ifdef SparcArchitecture
+LinkSourceFile(stipsprc32.s,LinkDirectory)
+#endif
+#endif
+#endif
+
+#if defined(IHaveModules) && BuildModuleInSubdir
+LinkSourceFile(cfbmodule.c,..)
+#endif
+
+ObjectFromSpecialSource(cfbseg,cfbline,-DPOLYSEGMENT)
+
+ObjectFromSpecialSource(cfbfillarcC,cfbfillarc,-DRROP=GXcopy)
+ObjectFromSpecialSource(cfbfillarcG,cfbfillarc,-DRROP=GXset)
+
+ObjectFromSpecialSource(cfbzerarcC,cfbzerarc,-DRROP=GXcopy)
+ObjectFromSpecialSource(cfbzerarcX,cfbzerarc,-DRROP=GXxor)
+ObjectFromSpecialSource(cfbzerarcG,cfbzerarc,-DRROP=GXset)
+
+ObjectFromSpecialSource(cfbbltC,cfbblt,-DMROP=Mcopy)
+ObjectFromSpecialSource(cfbbltX,cfbblt,-DMROP=Mxor)
+ObjectFromSpecialSource(cfbbltO,cfbblt,-DMROP=Mor)
+ObjectFromSpecialSource(cfbbltG,cfbblt,-DMROP=0)
+
+ObjectFromSpecialSource(cfbsolidC,cfbsolid,-DRROP=GXcopy)
+ObjectFromSpecialSource(cfbsolidX,cfbsolid,-DRROP=GXxor)
+ObjectFromSpecialSource(cfbsolidG,cfbsolid,-DRROP=GXset)
+
+ObjectFromSpecialSource(cfbtileoddC,cfbtileodd,-DMROP=Mcopy)
+ObjectFromSpecialSource(cfbtileoddG,cfbtileodd,-DMROP=0)
+
+ObjectFromSpecialSource(cfbtile32C,cfbtile32,-DMROP=Mcopy)
+ObjectFromSpecialSource(cfbtile32G,cfbtile32,-DMROP=0)
+
+ObjectFromSpecialSource(cfb8lineCO,cfb8line,-DRROP=GXcopy)
+ObjectFromSpecialSource(cfb8lineCP,cfb8line,-DRROP=GXcopy -DPREVIOUS)
+ObjectFromSpecialSource(cfb8lineX,cfb8line,-DRROP=GXxor)
+ObjectFromSpecialSource(cfb8lineG,cfb8line,-DRROP=GXset)
+
+ObjectFromSpecialSource(cfb8segCS,cfb8line,-DRROP=GXcopy -DPOLYSEGMENT -DWIDTH_SHIFT)
+ObjectFromSpecialSource(cfb8segC,cfb8line,-DRROP=GXcopy -DPOLYSEGMENT)
+ObjectFromSpecialSource(cfb8segX,cfb8line,-DRROP=GXxor -DPOLYSEGMENT)
+ObjectFromSpecialSource(cfb8segG,cfb8line,-DRROP=GXset -DPOLYSEGMENT)
+
+ObjectFromSpecialSource(cfbply1rctC,cfbply1rct,-DRROP=GXcopy)
+ObjectFromSpecialSource(cfbply1rctG,cfbply1rct,-DRROP=GXset)
+
+SpecialCObjectRule(cfbglblt8,$(_NOOP_),$(STIPPLEDEF))
+SpecialCObjectRule(cfbpixmap,$(ICONFIGFILES),$(_NOOP_))
+SpecialCObjectRule(cfbcmap,$(ICONFIGFILES),$(EXT_DEFINES) $(GLX_DEFINES))
+
+#if PixelSize == 8
+ObjectFromSpecialSource(cfbglrop8,cfbglblt8,-DGLYPHROP)
+
+#ifdef MipsArchitecture
+stipmipste.s: stipmips.s
+ $(RM) $@
+ $(LN) stipmips.s stipmipste.s
+clean::
+ $(RM) stipmipste.s
+
+stipmipste.o: stipmipste.s
+ $(AS) -o $@ -DTETEXT stipmipste.s
+#endif
+
+#ifdef SparcArchitecture
+stipsparcte.s: stipsparc.s
+ $(RM) $@
+ $(LN) stipsparc.s stipsparcte.s
+clean::
+ $(RM) stipsparcte.s
+
+stipsparc.o: stipsparc.s
+ $(CPP) stipsparc.s $(ASMDEFINES) | $(AS) -o $@ -
+
+stipsparcte.o: stipsparcte.s
+ $(CPP) -DTETEXT stipsparcte.s $(ASMDEFINES) | $(AS) -o $@ -
+#endif
+#endif
+
+#if PixelSize == 32
+#ifdef SparcArchitecture
+stipsprcte32.s: stipsprc32.s
+ $(RM) $@
+ $(LN) stipsprc32.s stipsprcte32.s
+clean::
+ $(RM) stipsprcte32.s
+
+stipsprc32.o: stipsprc32.s
+ $(CPP) stipsprc32.s $(ASMDEFINES) | $(AS) -o $@ -
+
+stipsprcte32.o: stipsprcte32.s
+ $(CPP) -DTETEXT stipsprcte32.s $(ASMDEFINES) | $(AS) -o $@ -
+#endif
+#endif
+
+#ifdef IHaveModules
+InstallLibraryModule($(CFBNAME),$(MODULEDIR),.)
+#endif
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+InstallDriverSDKLibraryModule($(CFBNAME),$(DRIVERSDKMODULEDIR),.)
+
+#if PixelSize == 8
+InstallDriverSDKNonExecFile(cfb.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(cfb16.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(cfb24.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(cfb32.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(cfbmap.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(cfbunmap.h,$(DRIVERSDKINCLUDEDIR))
+#endif
diff --git a/nx-X11/programs/Xserver/cfb/cfb.h b/nx-X11/programs/Xserver/cfb/cfb.h
new file mode 100644
index 000000000..960f6756b
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfb.h
@@ -0,0 +1,1327 @@
+/* $Xorg: cfb.h,v 1.3 2000/08/17 19:48:12 cpqbld Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/cfb/cfb.h,v 3.29tsi Exp $ */
+
+#if !defined(__CFB_H__) || defined(CFB_PROTOTYPES_ONLY)
+
+#include <X11/X.h>
+#include "globals.h"
+#include "pixmap.h"
+#include "region.h"
+#include "gc.h"
+#include "colormap.h"
+#include "miscstruct.h"
+#include "servermd.h"
+#include "windowstr.h"
+#include "mfb.h"
+#undef PixelType
+
+#include "cfbmap.h"
+
+#ifndef CfbBits
+#define CfbBits CARD32
+#endif
+
+#ifndef CFB_PROTOTYPES_ONLY
+#define __CFB_H__
+/*
+ private filed of pixmap
+ pixmap.devPrivate = (unsigned int *)pointer_to_bits
+ pixmap.devKind = width_of_pixmap_in_bytes
+*/
+
+extern int cfbGCPrivateIndex;
+extern int cfbWindowPrivateIndex;
+
+/* private field of GC */
+typedef struct {
+ unsigned char rop; /* special case rop values */
+ /* next two values unused in cfb, included for compatibility with mfb */
+ unsigned char ropOpStip; /* rop for opaque stipple */
+ /* this value is ropFillArea in mfb, usurped for cfb */
+ unsigned char oneRect; /* drawable has one clip rect */
+ CfbBits xor, and; /* reduced rop values */
+ } cfbPrivGC;
+
+typedef cfbPrivGC *cfbPrivGCPtr;
+
+#define cfbGetGCPrivate(pGC) ((cfbPrivGCPtr)\
+ (pGC)->devPrivates[cfbGCPrivateIndex].ptr)
+
+#define cfbGetCompositeClip(pGC) ((pGC)->pCompositeClip)
+
+/* way to carry RROP info around */
+typedef struct {
+ unsigned char rop;
+ CfbBits xor, and;
+} cfbRRopRec, *cfbRRopPtr;
+
+/* private field of window */
+typedef struct {
+ unsigned char fastBorder; /* non-zero if border is 32 bits wide */
+ unsigned char fastBackground;
+ unsigned short unused; /* pad for alignment with Sun compiler */
+ DDXPointRec oldRotate;
+ PixmapPtr pRotatedBackground;
+ PixmapPtr pRotatedBorder;
+ } cfbPrivWin;
+
+#define cfbGetWindowPrivate(_pWin) ((cfbPrivWin *)\
+ (_pWin)->devPrivates[cfbWindowPrivateIndex].ptr)
+
+
+/* cfb8bit.c */
+
+extern int cfbSetStipple(
+ int /*alu*/,
+ CfbBits /*fg*/,
+ CfbBits /*planemask*/
+);
+
+extern int cfbSetOpaqueStipple(
+ int /*alu*/,
+ CfbBits /*fg*/,
+ CfbBits /*bg*/,
+ CfbBits /*planemask*/
+);
+
+extern int cfbComputeClipMasks32(
+ BoxPtr /*pBox*/,
+ int /*numRects*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ CARD32 * /*clips*/
+);
+#endif /* !CFB_PROTOTYPES_ONLY */
+/* cfb8cppl.c */
+
+extern void cfbCopyImagePlane(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ int /*rop*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+
+#ifndef CFB_PROTOTYPES_ONLY
+extern void cfbCopyPlane8to1(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ int /*rop*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/,
+ unsigned long /*bitPlane*/
+);
+
+extern void cfbCopyPlane16to1(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ int /*rop*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/,
+ unsigned long /*bitPlane*/
+);
+
+extern void cfbCopyPlane24to1(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ int /*rop*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/,
+ unsigned long /*bitPlane*/
+);
+
+extern void cfbCopyPlane32to1(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ int /*rop*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/,
+ unsigned long /*bitPlane*/
+);
+#endif
+
+/* cfb8lineCO.c */
+
+extern int cfb8LineSS1RectCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/,
+ DDXPointPtr /*pptInitOrig*/,
+ int * /*x1p*/,
+ int * /*y1p*/,
+ int * /*x2p*/,
+ int * /*y2p*/
+);
+
+extern void cfb8LineSS1Rect(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/
+);
+
+extern void cfb8ClippedLineCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*x2*/,
+ int /*y2*/,
+ BoxPtr /*boxp*/,
+ Bool /*shorten*/
+);
+/* cfb8lineCP.c */
+
+extern int cfb8LineSS1RectPreviousCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/,
+ DDXPointPtr /*pptInitOrig*/,
+ int * /*x1p*/,
+ int * /*y1p*/,
+ int * /*x2p*/,
+ int * /*y2p*/
+);
+/* cfb8lineG.c */
+
+extern int cfb8LineSS1RectGeneral(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/,
+ DDXPointPtr /*pptInitOrig*/,
+ int * /*x1p*/,
+ int * /*y1p*/,
+ int * /*x2p*/,
+ int * /*y2p*/
+);
+
+extern void cfb8ClippedLineGeneral(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*x2*/,
+ int /*y2*/,
+ BoxPtr /*boxp*/,
+ Bool /*shorten*/
+);
+/* cfb8lineX.c */
+
+extern int cfb8LineSS1RectXor(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/,
+ DDXPointPtr /*pptInitOrig*/,
+ int * /*x1p*/,
+ int * /*y1p*/,
+ int * /*x2p*/,
+ int * /*y2p*/
+);
+
+extern void cfb8ClippedLineXor(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*x2*/,
+ int /*y2*/,
+ BoxPtr /*boxp*/,
+ Bool /*shorten*/
+);
+/* cfb8segC.c */
+
+extern int cfb8SegmentSS1RectCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSegInit*/
+);
+/* cfb8segCS.c */
+
+extern int cfb8SegmentSS1RectShiftCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSegInit*/
+);
+
+extern void cfb8SegmentSS1Rect(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSegInit*/
+);
+/* cfb8segG.c */
+
+extern int cfb8SegmentSS1RectGeneral(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSegInit*/
+);
+/* cfbsegX.c */
+
+extern int cfb8SegmentSS1RectXor(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSegInit*/
+);
+/* cfballpriv.c */
+
+extern Bool cfbAllocatePrivates(
+ ScreenPtr /*pScreen*/,
+ int * /*window_index*/,
+ int * /*gc_index*/
+);
+/* cfbbitblt.c */
+
+extern RegionPtr cfbBitBlt(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr/*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ void (* /*doBitBlt*/)(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+ ),
+ unsigned long /*bitPlane*/
+);
+
+#define cfbCopyPlaneExpand cfbBitBlt
+
+extern RegionPtr cfbCopyPlaneReduce(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr /*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ void (* /*doCopyPlane*/)(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/,
+ unsigned long /*bitPlane*/ /* We must know which plane to reduce! */
+ ),
+ unsigned long /*bitPlane*/
+);
+
+extern void cfbDoBitblt(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+
+extern RegionPtr cfbCopyArea(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr/*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/
+);
+
+#ifndef CFB_PROTOTYPES_ONLY
+extern void cfbCopyPlane1to8(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ int /*rop*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+#endif
+
+extern RegionPtr cfbCopyPlane(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr /*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ unsigned long /*bitPlane*/
+);
+/* cfbbltC.c */
+
+extern void cfbDoBitbltCopy(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* cfbbltG.c */
+
+extern void cfbDoBitbltGeneral(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* cfbbltO.c */
+
+extern void cfbDoBitbltOr(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* cfbbltX.c */
+
+extern void cfbDoBitbltXor(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* cfbbres.c */
+
+extern void cfbBresS(
+ int /*rop*/,
+ CfbBits /*and*/,
+ CfbBits /*xor*/,
+ CfbBits * /*addrl*/,
+ int /*nlwidth*/,
+ int /*signdx*/,
+ int /*signdy*/,
+ int /*axis*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*e*/,
+ int /*e1*/,
+ int /*e2*/,
+ int /*len*/
+);
+/* cfbbresd.c */
+
+extern void cfbBresD(
+ cfbRRopPtr /*rrops*/,
+ int * /*pdashIndex*/,
+ unsigned char * /*pDash*/,
+ int /*numInDashList*/,
+ int * /*pdashOffset*/,
+ int /*isDoubleDash*/,
+ CfbBits * /*addrl*/,
+ int /*nlwidth*/,
+ int /*signdx*/,
+ int /*signdy*/,
+ int /*axis*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*e*/,
+ int /*e1*/,
+ int /*e2*/,
+ int /*len*/
+);
+/* cfbbstore.c */
+
+extern void cfbSaveAreas(
+ PixmapPtr /*pPixmap*/,
+ RegionPtr /*prgnSave*/,
+ int /*xorg*/,
+ int /*yorg*/,
+ WindowPtr /*pWin*/
+);
+
+extern void cfbRestoreAreas(
+ PixmapPtr /*pPixmap*/,
+ RegionPtr /*prgnRestore*/,
+ int /*xorg*/,
+ int /*yorg*/,
+ WindowPtr /*pWin*/
+);
+/* cfbcmap.c */
+
+#ifndef CFB_PROTOTYPES_ONLY
+extern int cfbListInstalledColormaps(
+ ScreenPtr /*pScreen*/,
+ Colormap * /*pmaps*/
+);
+
+extern void cfbInstallColormap(
+ ColormapPtr /*pmap*/
+);
+
+extern void cfbUninstallColormap(
+ ColormapPtr /*pmap*/
+);
+
+extern void cfbResolveColor(
+ unsigned short * /*pred*/,
+ unsigned short * /*pgreen*/,
+ unsigned short * /*pblue*/,
+ VisualPtr /*pVisual*/
+);
+
+extern Bool cfbInitializeColormap(
+ ColormapPtr /*pmap*/
+);
+
+extern int cfbExpandDirectColors(
+ ColormapPtr /*pmap*/,
+ int /*ndef*/,
+ xColorItem * /*indefs*/,
+ xColorItem * /*outdefs*/
+);
+
+extern Bool cfbCreateDefColormap(
+ ScreenPtr /*pScreen*/
+);
+
+extern Bool cfbSetVisualTypes(
+ int /*depth*/,
+ int /*visuals*/,
+ int /*bitsPerRGB*/
+);
+
+extern void cfbClearVisualTypes(void);
+
+extern Bool cfbInitVisuals(
+ VisualPtr * /*visualp*/,
+ DepthPtr * /*depthp*/,
+ int * /*nvisualp*/,
+ int * /*ndepthp*/,
+ int * /*rootDepthp*/,
+ VisualID * /*defaultVisp*/,
+ unsigned long /*sizes*/,
+ int /*bitsPerRGB*/
+);
+#endif
+/* cfbfillarcC.c */
+
+extern void cfbPolyFillArcSolidCopy(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+/* cfbfillarcG.c */
+
+extern void cfbPolyFillArcSolidGeneral(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+/* cfbfillrct.c */
+
+extern void cfbFillBoxTileOdd(
+ DrawablePtr /*pDrawable*/,
+ int /*n*/,
+ BoxPtr /*rects*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/
+);
+
+extern void cfbFillRectTileOdd(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+
+extern void cfbPolyFillRect(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nrectFill*/,
+ xRectangle * /*prectInit*/
+);
+/* cfbfillsp.c */
+
+extern void cfbUnnaturalTileFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void cfbUnnaturalStippleFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+#ifndef CFB_PROTOTYPES_ONLY
+extern void cfb8Stipple32FS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void cfb8OpaqueStipple32FS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+#endif
+/* cfbgc.c */
+
+extern GCOpsPtr cfbMatchCommon(
+ GCPtr /*pGC*/,
+ cfbPrivGCPtr /*devPriv*/
+);
+
+extern Bool cfbCreateGC(
+ GCPtr /*pGC*/
+);
+
+extern void cfbValidateGC(
+ GCPtr /*pGC*/,
+ unsigned long /*changes*/,
+ DrawablePtr /*pDrawable*/
+);
+
+/* cfbgetsp.c */
+
+extern void cfbGetSpans(
+ DrawablePtr /*pDrawable*/,
+ int /*wMax*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ int /*nspans*/,
+ char * /*pdstStart*/
+);
+/* cfbglblt8.c */
+
+extern void cfbPolyGlyphBlt8(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* cfbglrop8.c */
+
+extern void cfbPolyGlyphRop8(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* cfbhrzvert.c */
+
+extern void cfbHorzS(
+ int /*rop*/,
+ CfbBits /*and*/,
+ CfbBits /*xor*/,
+ CfbBits * /*addrl*/,
+ int /*nlwidth*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*len*/
+);
+
+extern void cfbVertS(
+ int /*rop*/,
+ CfbBits /*and*/,
+ CfbBits /*xor*/,
+ CfbBits * /*addrl*/,
+ int /*nlwidth*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*len*/
+);
+/* cfbigblt8.c */
+
+extern void cfbImageGlyphBlt8(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* cfbimage.c */
+
+extern void cfbPutImage(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*depth*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ int /*leftPad*/,
+ int /*format*/,
+ char * /*pImage*/
+);
+
+extern void cfbGetImage(
+ DrawablePtr /*pDrawable*/,
+ int /*sx*/,
+ int /*sy*/,
+ int /*w*/,
+ int /*h*/,
+ unsigned int /*format*/,
+ unsigned long /*planeMask*/,
+ char * /*pdstLine*/
+);
+/* cfbline.c */
+
+extern void cfbLineSS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/
+);
+
+extern void cfbLineSD(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/
+);
+/* cfbmskbits.c */
+/* cfbpixmap.c */
+
+extern PixmapPtr cfbCreatePixmap(
+ ScreenPtr /*pScreen*/,
+ int /*width*/,
+ int /*height*/,
+ int /*depth*/
+);
+
+extern Bool cfbDestroyPixmap(
+ PixmapPtr /*pPixmap*/
+);
+
+extern PixmapPtr cfbCopyPixmap(
+ PixmapPtr /*pSrc*/
+);
+
+extern void cfbPadPixmap(
+ PixmapPtr /*pPixmap*/
+);
+
+extern void cfbXRotatePixmap(
+ PixmapPtr /*pPix*/,
+ int /*rw*/
+);
+
+extern void cfbYRotatePixmap(
+ PixmapPtr /*pPix*/,
+ int /*rh*/
+);
+
+extern void cfbCopyRotatePixmap(
+ PixmapPtr /*psrcPix*/,
+ PixmapPtr * /*ppdstPix*/,
+ int /*xrot*/,
+ int /*yrot*/
+);
+/* cfbply1rctC.c */
+
+extern void cfbFillPoly1RectCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*shape*/,
+ int /*mode*/,
+ int /*count*/,
+ DDXPointPtr /*ptsIn*/
+);
+/* cfbply1rctG.c */
+
+extern void cfbFillPoly1RectGeneral(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*shape*/,
+ int /*mode*/,
+ int /*count*/,
+ DDXPointPtr /*ptsIn*/
+);
+/* cfbpntwin.c */
+
+extern void cfbPaintWindow(
+ WindowPtr /*pWin*/,
+ RegionPtr /*pRegion*/,
+ int /*what*/
+);
+
+extern void cfbFillBoxSolid(
+ DrawablePtr /*pDrawable*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/,
+ unsigned long /*pixel*/
+);
+
+extern void cfbFillBoxTile32(
+ DrawablePtr /*pDrawable*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/,
+ PixmapPtr /*tile*/
+);
+/* cfbpolypnt.c */
+
+extern void cfbPolyPoint(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ xPoint * /*pptInit*/
+);
+/* cfbpush8.c */
+
+#ifndef CFB_PROTOTYPES_ONLY
+extern void cfbPushPixels8(
+ GCPtr /*pGC*/,
+ PixmapPtr /*pBitmap*/,
+ DrawablePtr /*pDrawable*/,
+ int /*dx*/,
+ int /*dy*/,
+ int /*xOrg*/,
+ int /*yOrg*/
+);
+/* cfbrctstp8.c */
+
+extern void cfb8FillRectOpaqueStippled32(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+
+extern void cfb8FillRectTransparentStippled32(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+
+extern void cfb8FillRectStippledUnnatural(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+#endif
+/* cfbrrop.c */
+
+extern int cfbReduceRasterOp(
+ int /*rop*/,
+ CfbBits /*fg*/,
+ CfbBits /*pm*/,
+ CfbBits * /*andp*/,
+ CfbBits * /*xorp*/
+);
+/* cfbscrinit.c */
+
+extern Bool cfbCloseScreen(
+ int /*index*/,
+ ScreenPtr /*pScreen*/
+);
+
+extern Bool cfbSetupScreen(
+ ScreenPtr /*pScreen*/,
+ pointer /*pbits*/,
+ int /*xsize*/,
+ int /*ysize*/,
+ int /*dpix*/,
+ int /*dpiy*/,
+ int /*width*/
+);
+
+extern Bool cfbFinishScreenInit(
+ ScreenPtr /*pScreen*/,
+ pointer /*pbits*/,
+ int /*xsize*/,
+ int /*ysize*/,
+ int /*dpix*/,
+ int /*dpiy*/,
+ int /*width*/
+);
+
+extern Bool cfbScreenInit(
+ ScreenPtr /*pScreen*/,
+ pointer /*pbits*/,
+ int /*xsize*/,
+ int /*ysize*/,
+ int /*dpix*/,
+ int /*dpiy*/,
+ int /*width*/
+);
+
+extern PixmapPtr cfbGetScreenPixmap(
+ ScreenPtr /*pScreen*/
+);
+
+extern void cfbSetScreenPixmap(
+ PixmapPtr /*pPix*/
+);
+
+/* cfbseg.c */
+
+extern void cfbSegmentSS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSeg*/
+);
+
+extern void cfbSegmentSD(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSeg*/
+);
+/* cfbsetsp.c */
+
+extern void cfbSetScanline(
+ int /*y*/,
+ int /*xOrigin*/,
+ int /*xStart*/,
+ int /*xEnd*/,
+ unsigned int * /*psrc*/,
+ int /*alu*/,
+ int * /*pdstBase*/,
+ int /*widthDst*/,
+ unsigned long /*planemask*/
+);
+
+extern void cfbSetSpans(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ char * /*psrc*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ int /*nspans*/,
+ int /*fSorted*/
+);
+/* cfbsolidC.c */
+
+extern void cfbFillRectSolidCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+
+extern void cfbSolidSpansCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+/* cfbsolidG.c */
+
+extern void cfbFillRectSolidGeneral(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+
+extern void cfbSolidSpansGeneral(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+/* cfbsolidX.c */
+
+extern void cfbFillRectSolidXor(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+
+extern void cfbSolidSpansXor(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+/* cfbteblt8.c */
+
+#ifndef CFB_PROTOTYPES_ONLY
+extern void cfbTEGlyphBlt8(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*xInit*/,
+ int /*yInit*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+#endif
+/* cfbtegblt.c */
+
+extern void cfbTEGlyphBlt(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* cfbtile32C.c */
+
+extern void cfbFillRectTile32Copy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+
+extern void cfbTile32FSCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+/* cfbtile32G.c */
+
+extern void cfbFillRectTile32General(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+
+extern void cfbTile32FSGeneral(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+/* cfbtileoddC.c */
+
+extern void cfbFillBoxTileOddCopy(
+ DrawablePtr /*pDrawable*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/,
+ int /*alu*/,
+ unsigned long /*planemask*/
+);
+
+extern void cfbFillSpanTileOddCopy(
+ DrawablePtr /*pDrawable*/,
+ int /*n*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/,
+ int /*alu*/,
+ unsigned long /*planemask*/
+);
+
+extern void cfbFillBoxTile32sCopy(
+ DrawablePtr /*pDrawable*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/,
+ int /*alu*/,
+ unsigned long /*planemask*/
+);
+
+extern void cfbFillSpanTile32sCopy(
+ DrawablePtr /*pDrawable*/,
+ int /*n*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/,
+ int /*alu*/,
+ unsigned long /*planemask*/
+);
+/* cfbtileoddG.c */
+
+extern void cfbFillBoxTileOddGeneral(
+ DrawablePtr /*pDrawable*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/,
+ int /*alu*/,
+ unsigned long /*planemask*/
+);
+
+extern void cfbFillSpanTileOddGeneral(
+ DrawablePtr /*pDrawable*/,
+ int /*n*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/,
+ int /*alu*/,
+ unsigned long /*planemask*/
+);
+
+extern void cfbFillBoxTile32sGeneral(
+ DrawablePtr /*pDrawable*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/,
+ int /*alu*/,
+ unsigned long /*planemask*/
+);
+
+extern void cfbFillSpanTile32sGeneral(
+ DrawablePtr /*pDrawable*/,
+ int /*n*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/,
+ int /*alu*/,
+ unsigned long /*planemask*/
+);
+/* cfbwindow.c */
+
+extern Bool cfbCreateWindow(
+ WindowPtr /*pWin*/
+);
+
+extern Bool cfbDestroyWindow(
+ WindowPtr /*pWin*/
+);
+
+extern Bool cfbMapWindow(
+ WindowPtr /*pWindow*/
+);
+
+extern Bool cfbPositionWindow(
+ WindowPtr /*pWin*/,
+ int /*x*/,
+ int /*y*/
+);
+
+extern Bool cfbUnmapWindow(
+ WindowPtr /*pWindow*/
+);
+
+extern void cfbCopyWindow(
+ WindowPtr /*pWin*/,
+ DDXPointRec /*ptOldOrg*/,
+ RegionPtr /*prgnSrc*/
+);
+
+extern Bool cfbChangeWindowAttributes(
+ WindowPtr /*pWin*/,
+ unsigned long /*mask*/
+);
+/* cfbzerarcC.c */
+
+extern void cfbZeroPolyArcSS8Copy(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+/* cfbzerarcG.c */
+
+extern void cfbZeroPolyArcSS8General(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+/* cfbzerarcX.c */
+
+extern void cfbZeroPolyArcSS8Xor(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+
+#if (!defined(SINGLEDEPTH) && PSZ != 8) || defined(FORCE_SEPARATE_PRIVATE)
+
+#define CFB_NEED_SCREEN_PRIVATE
+
+extern int cfbScreenPrivateIndex;
+#endif
+
+#ifndef CFB_PROTOTYPES_ONLY
+
+/* Common macros for extracting drawing information */
+
+#define cfbGetWindowPixmap(d) \
+ ((* ((DrawablePtr)(d))->pScreen->GetWindowPixmap)((WindowPtr)(d)))
+
+#define cfbGetTypedWidth(pDrawable,wtype) (\
+ (((pDrawable)->type != DRAWABLE_PIXMAP) ? \
+ (int) (cfbGetWindowPixmap(pDrawable)->devKind) : \
+ (int)(((PixmapPtr)pDrawable)->devKind)) / sizeof (wtype))
+
+#define cfbGetByteWidth(pDrawable) cfbGetTypedWidth(pDrawable, unsigned char)
+
+#define cfbGetPixelWidth(pDrawable) cfbGetTypedWidth(pDrawable, PixelType)
+
+#define cfbGetLongWidth(pDrawable) cfbGetTypedWidth(pDrawable, CfbBits)
+
+#define cfbGetTypedWidthAndPointer(pDrawable, width, pointer, wtype, ptype) {\
+ PixmapPtr _pPix; \
+ if ((pDrawable)->type != DRAWABLE_PIXMAP) \
+ _pPix = cfbGetWindowPixmap(pDrawable); \
+ else \
+ _pPix = (PixmapPtr) (pDrawable); \
+ (pointer) = (ptype *) _pPix->devPrivate.ptr; \
+ (width) = ((int) _pPix->devKind) / sizeof (wtype); \
+}
+
+#define cfbGetByteWidthAndPointer(pDrawable, width, pointer) \
+ cfbGetTypedWidthAndPointer(pDrawable, width, pointer, unsigned char, unsigned char)
+
+#define cfbGetLongWidthAndPointer(pDrawable, width, pointer) \
+ cfbGetTypedWidthAndPointer(pDrawable, width, pointer, CfbBits, CfbBits)
+
+#define cfbGetPixelWidthAndPointer(pDrawable, width, pointer) \
+ cfbGetTypedWidthAndPointer(pDrawable, width, pointer, PixelType, PixelType)
+
+#define cfbGetWindowTypedWidthAndPointer(pWin, width, pointer, wtype, ptype) {\
+ PixmapPtr _pPix = cfbGetWindowPixmap((DrawablePtr) (pWin)); \
+ (pointer) = (ptype *) _pPix->devPrivate.ptr; \
+ (width) = ((int) _pPix->devKind) / sizeof (wtype); \
+}
+
+#define cfbGetWindowLongWidthAndPointer(pWin, width, pointer) \
+ cfbGetWindowTypedWidthAndPointer(pWin, width, pointer, CfbBits, CfbBits)
+
+#define cfbGetWindowByteWidthAndPointer(pWin, width, pointer) \
+ cfbGetWindowTypedWidthAndPointer(pWin, width, pointer, unsigned char, unsigned char)
+
+#define cfbGetWindowPixelWidthAndPointer(pDrawable, width, pointer) \
+ cfbGetWindowTypedWidthAndPointer(pDrawable, width, pointer, PixelType, PixelType)
+
+/*
+ * XFree86 empties the root BorderClip when the VT is inactive,
+ * here's a macro which uses that to disable GetImage and GetSpans
+ */
+#define cfbWindowEnabled(pWin) \
+ REGION_NOTEMPTY((pWin)->drawable.pScreen, \
+ &WindowTable[(pWin)->drawable.pScreen->myNum]->borderClip)
+
+#define cfbDrawableEnabled(pDrawable) \
+ ((pDrawable)->type == DRAWABLE_PIXMAP ? \
+ TRUE : cfbWindowEnabled((WindowPtr) pDrawable))
+
+#include "micoord.h"
+
+/*
+ * if CFB is built as a module, it shouldn't call libc functions.
+ */
+#ifdef XFree86LOADER
+#include "xf86_ansic.h"
+#endif
+#endif /* !CFB_PROTOTYPES_ONLY */
+
+#endif
diff --git a/nx-X11/programs/Xserver/cfb/cfb16.h b/nx-X11/programs/Xserver/cfb/cfb16.h
new file mode 100644
index 000000000..3d51cd142
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfb16.h
@@ -0,0 +1,94 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfb16.h,v 1.4 1998/11/28 10:42:50 dawes Exp $ */
+/*
+ * Copyright (C) 1994-1998 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+#ifndef _CFB16_H_
+#define _CFB16_H_
+
+/*
+ * C's preprocessing language substitutes >text<, not values...
+ */
+
+#ifdef OLDPSZ
+# undef OLDPSZ
+#endif
+
+#ifdef PSZ
+
+# if (PSZ == 8)
+# define OLDPSZ 8
+# endif
+
+# if (PSZ == 16)
+# define OLDPSZ 16
+# endif
+
+# if (PSZ == 24)
+# define OLDPSZ 24
+# endif
+
+# if (PSZ == 32)
+# define OLDPSZ 32
+# endif
+
+# ifndef OLDPSZ
+ /* Maybe an #error here ? */
+# endif
+
+# undef PSZ
+
+#endif
+
+#define PSZ 16
+#define CFB_PROTOTYPES_ONLY
+#include "cfb.h"
+#undef CFB_PROTOTYPES_ONLY
+#include "cfbunmap.h"
+
+#undef PSZ
+#ifdef OLDPSZ
+
+# if (OLDPSZ == 8)
+# define PSZ 8
+# endif
+
+# if (OLDPSZ == 16)
+# define PSZ 16
+# endif
+
+# if (OLDPSZ == 24)
+# define PSZ 24
+# endif
+
+# if (OLDPSZ == 32)
+# define PSZ 32
+# endif
+
+# undef OLDPSZ
+
+#endif
+
+#endif /* _CFB16_H_ */
diff --git a/nx-X11/programs/Xserver/cfb/cfb24.h b/nx-X11/programs/Xserver/cfb/cfb24.h
new file mode 100644
index 000000000..3a99934b7
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfb24.h
@@ -0,0 +1,98 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfb24.h,v 1.4 1998/11/28 10:42:51 dawes Exp $ */
+/*
+ * Copyright (C) 1994-1998 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _CFB24_H_
+#define _CFB24_H_
+
+/*
+ * C's preprocessing language substitutes >text<, not values...
+ */
+
+#ifdef OLDPSZ
+# undef OLDPSZ
+#endif
+
+#ifdef PSZ
+
+# if (PSZ == 8)
+# define OLDPSZ 8
+# endif
+
+# if (PSZ == 16)
+# define OLDPSZ 16
+# endif
+
+# if (PSZ == 24)
+# define OLDPSZ 24
+# endif
+
+# if (PSZ == 32)
+# define OLDPSZ 32
+# endif
+
+# ifndef OLDPSZ
+ /* Maybe an #error here ? */
+# endif
+
+# undef PSZ
+
+#endif
+
+#define PSZ 24
+#define CFB_PROTOTYPES_ONLY
+#include "cfb.h"
+#undef CFB_PROTOTYPES_ONLY
+#include "cfbunmap.h"
+
+#undef PSZ
+#ifdef OLDPSZ
+
+# if (OLDPSZ == 8)
+# define PSZ 8
+# endif
+
+# if (OLDPSZ == 16)
+# define PSZ 16
+# endif
+
+# if (OLDPSZ == 24)
+# define PSZ 24
+# endif
+
+# if (OLDPSZ == 32)
+# define PSZ 32
+# endif
+
+# undef OLDPSZ
+
+#endif
+
+#endif /* _CFB24_H_ */
diff --git a/nx-X11/programs/Xserver/cfb/cfb32.h b/nx-X11/programs/Xserver/cfb/cfb32.h
new file mode 100644
index 000000000..5ea4c13c8
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfb32.h
@@ -0,0 +1,94 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfb32.h,v 1.4 1998/11/28 10:42:51 dawes Exp $ */
+/*
+ * Copyright (C) 1994-1998 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+#ifndef _CFB32_H_
+#define _CFB32_H_
+
+/*
+ * C's preprocessing language substitutes >text<, not values...
+ */
+
+#ifdef OLDPSZ
+# undef OLDPSZ
+#endif
+
+#ifdef PSZ
+
+# if (PSZ == 8)
+# define OLDPSZ 8
+# endif
+
+# if (PSZ == 16)
+# define OLDPSZ 16
+# endif
+
+# if (PSZ == 24)
+# define OLDPSZ 24
+# endif
+
+# if (PSZ == 32)
+# define OLDPSZ 32
+# endif
+
+# ifndef OLDPSZ
+ /* Maybe an #error here ? */
+# endif
+
+# undef PSZ
+
+#endif
+
+#define PSZ 32
+#define CFB_PROTOTYPES_ONLY
+#include "cfb.h"
+#undef CFB_PROTOTYPES_ONLY
+#include "cfbunmap.h"
+
+#undef PSZ
+#ifdef OLDPSZ
+
+# if (OLDPSZ == 8)
+# define PSZ 8
+# endif
+
+# if (OLDPSZ == 16)
+# define PSZ 16
+# endif
+
+# if (OLDPSZ == 24)
+# define PSZ 24
+# endif
+
+# if (OLDPSZ == 32)
+# define PSZ 32
+# endif
+
+# undef OLDPSZ
+
+#endif
+
+#endif /* _CFB32_H_ */
diff --git a/nx-X11/programs/Xserver/cfb/cfb8bit.c b/nx-X11/programs/Xserver/cfb/cfb8bit.c
new file mode 100644
index 000000000..0bc5debbb
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfb8bit.c
@@ -0,0 +1,471 @@
+/* $Xorg: cfb8bit.c,v 1.4 2001/02/09 02:04:37 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/cfb/cfb8bit.c,v 1.4 2001/01/17 22:36:34 dawes Exp $ */
+
+/*
+ * cfb8bit.c
+ *
+ * 8 bit color frame buffer utility routines
+ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#if PSZ == 8
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "cfb8bit.h"
+
+PixelGroup cfb8StippleMasks[NUM_MASKS] = {
+#if NUM_MASKS == 16
+ 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff,
+ 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff,
+ 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff,
+ 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff
+#else /* NUM_MASKS == 256 */
+ 0x0000000000000000, 0x00000000000000ff,
+ 0x000000000000ff00, 0x000000000000ffff,
+ 0x0000000000ff0000, 0x0000000000ff00ff,
+ 0x0000000000ffff00, 0x0000000000ffffff,
+ 0x00000000ff000000, 0x00000000ff0000ff,
+ 0x00000000ff00ff00, 0x00000000ff00ffff,
+ 0x00000000ffff0000, 0x00000000ffff00ff,
+ 0x00000000ffffff00, 0x00000000ffffffff,
+ 0x000000ff00000000, 0x000000ff000000ff,
+ 0x000000ff0000ff00, 0x000000ff0000ffff,
+ 0x000000ff00ff0000, 0x000000ff00ff00ff,
+ 0x000000ff00ffff00, 0x000000ff00ffffff,
+ 0x000000ffff000000, 0x000000ffff0000ff,
+ 0x000000ffff00ff00, 0x000000ffff00ffff,
+ 0x000000ffffff0000, 0x000000ffffff00ff,
+ 0x000000ffffffff00, 0x000000ffffffffff,
+ 0x0000ff0000000000, 0x0000ff00000000ff,
+ 0x0000ff000000ff00, 0x0000ff000000ffff,
+ 0x0000ff0000ff0000, 0x0000ff0000ff00ff,
+ 0x0000ff0000ffff00, 0x0000ff0000ffffff,
+ 0x0000ff00ff000000, 0x0000ff00ff0000ff,
+ 0x0000ff00ff00ff00, 0x0000ff00ff00ffff,
+ 0x0000ff00ffff0000, 0x0000ff00ffff00ff,
+ 0x0000ff00ffffff00, 0x0000ff00ffffffff,
+ 0x0000ffff00000000, 0x0000ffff000000ff,
+ 0x0000ffff0000ff00, 0x0000ffff0000ffff,
+ 0x0000ffff00ff0000, 0x0000ffff00ff00ff,
+ 0x0000ffff00ffff00, 0x0000ffff00ffffff,
+ 0x0000ffffff000000, 0x0000ffffff0000ff,
+ 0x0000ffffff00ff00, 0x0000ffffff00ffff,
+ 0x0000ffffffff0000, 0x0000ffffffff00ff,
+ 0x0000ffffffffff00, 0x0000ffffffffffff,
+ 0x00ff000000000000, 0x00ff0000000000ff,
+ 0x00ff00000000ff00, 0x00ff00000000ffff,
+ 0x00ff000000ff0000, 0x00ff000000ff00ff,
+ 0x00ff000000ffff00, 0x00ff000000ffffff,
+ 0x00ff0000ff000000, 0x00ff0000ff0000ff,
+ 0x00ff0000ff00ff00, 0x00ff0000ff00ffff,
+ 0x00ff0000ffff0000, 0x00ff0000ffff00ff,
+ 0x00ff0000ffffff00, 0x00ff0000ffffffff,
+ 0x00ff00ff00000000, 0x00ff00ff000000ff,
+ 0x00ff00ff0000ff00, 0x00ff00ff0000ffff,
+ 0x00ff00ff00ff0000, 0x00ff00ff00ff00ff,
+ 0x00ff00ff00ffff00, 0x00ff00ff00ffffff,
+ 0x00ff00ffff000000, 0x00ff00ffff0000ff,
+ 0x00ff00ffff00ff00, 0x00ff00ffff00ffff,
+ 0x00ff00ffffff0000, 0x00ff00ffffff00ff,
+ 0x00ff00ffffffff00, 0x00ff00ffffffffff,
+ 0x00ffff0000000000, 0x00ffff00000000ff,
+ 0x00ffff000000ff00, 0x00ffff000000ffff,
+ 0x00ffff0000ff0000, 0x00ffff0000ff00ff,
+ 0x00ffff0000ffff00, 0x00ffff0000ffffff,
+ 0x00ffff00ff000000, 0x00ffff00ff0000ff,
+ 0x00ffff00ff00ff00, 0x00ffff00ff00ffff,
+ 0x00ffff00ffff0000, 0x00ffff00ffff00ff,
+ 0x00ffff00ffffff00, 0x00ffff00ffffffff,
+ 0x00ffffff00000000, 0x00ffffff000000ff,
+ 0x00ffffff0000ff00, 0x00ffffff0000ffff,
+ 0x00ffffff00ff0000, 0x00ffffff00ff00ff,
+ 0x00ffffff00ffff00, 0x00ffffff00ffffff,
+ 0x00ffffffff000000, 0x00ffffffff0000ff,
+ 0x00ffffffff00ff00, 0x00ffffffff00ffff,
+ 0x00ffffffffff0000, 0x00ffffffffff00ff,
+ 0x00ffffffffffff00, 0x00ffffffffffffff,
+ 0xff00000000000000, 0xff000000000000ff,
+ 0xff0000000000ff00, 0xff0000000000ffff,
+ 0xff00000000ff0000, 0xff00000000ff00ff,
+ 0xff00000000ffff00, 0xff00000000ffffff,
+ 0xff000000ff000000, 0xff000000ff0000ff,
+ 0xff000000ff00ff00, 0xff000000ff00ffff,
+ 0xff000000ffff0000, 0xff000000ffff00ff,
+ 0xff000000ffffff00, 0xff000000ffffffff,
+ 0xff0000ff00000000, 0xff0000ff000000ff,
+ 0xff0000ff0000ff00, 0xff0000ff0000ffff,
+ 0xff0000ff00ff0000, 0xff0000ff00ff00ff,
+ 0xff0000ff00ffff00, 0xff0000ff00ffffff,
+ 0xff0000ffff000000, 0xff0000ffff0000ff,
+ 0xff0000ffff00ff00, 0xff0000ffff00ffff,
+ 0xff0000ffffff0000, 0xff0000ffffff00ff,
+ 0xff0000ffffffff00, 0xff0000ffffffffff,
+ 0xff00ff0000000000, 0xff00ff00000000ff,
+ 0xff00ff000000ff00, 0xff00ff000000ffff,
+ 0xff00ff0000ff0000, 0xff00ff0000ff00ff,
+ 0xff00ff0000ffff00, 0xff00ff0000ffffff,
+ 0xff00ff00ff000000, 0xff00ff00ff0000ff,
+ 0xff00ff00ff00ff00, 0xff00ff00ff00ffff,
+ 0xff00ff00ffff0000, 0xff00ff00ffff00ff,
+ 0xff00ff00ffffff00, 0xff00ff00ffffffff,
+ 0xff00ffff00000000, 0xff00ffff000000ff,
+ 0xff00ffff0000ff00, 0xff00ffff0000ffff,
+ 0xff00ffff00ff0000, 0xff00ffff00ff00ff,
+ 0xff00ffff00ffff00, 0xff00ffff00ffffff,
+ 0xff00ffffff000000, 0xff00ffffff0000ff,
+ 0xff00ffffff00ff00, 0xff00ffffff00ffff,
+ 0xff00ffffffff0000, 0xff00ffffffff00ff,
+ 0xff00ffffffffff00, 0xff00ffffffffffff,
+ 0xffff000000000000, 0xffff0000000000ff,
+ 0xffff00000000ff00, 0xffff00000000ffff,
+ 0xffff000000ff0000, 0xffff000000ff00ff,
+ 0xffff000000ffff00, 0xffff000000ffffff,
+ 0xffff0000ff000000, 0xffff0000ff0000ff,
+ 0xffff0000ff00ff00, 0xffff0000ff00ffff,
+ 0xffff0000ffff0000, 0xffff0000ffff00ff,
+ 0xffff0000ffffff00, 0xffff0000ffffffff,
+ 0xffff00ff00000000, 0xffff00ff000000ff,
+ 0xffff00ff0000ff00, 0xffff00ff0000ffff,
+ 0xffff00ff00ff0000, 0xffff00ff00ff00ff,
+ 0xffff00ff00ffff00, 0xffff00ff00ffffff,
+ 0xffff00ffff000000, 0xffff00ffff0000ff,
+ 0xffff00ffff00ff00, 0xffff00ffff00ffff,
+ 0xffff00ffffff0000, 0xffff00ffffff00ff,
+ 0xffff00ffffffff00, 0xffff00ffffffffff,
+ 0xffffff0000000000, 0xffffff00000000ff,
+ 0xffffff000000ff00, 0xffffff000000ffff,
+ 0xffffff0000ff0000, 0xffffff0000ff00ff,
+ 0xffffff0000ffff00, 0xffffff0000ffffff,
+ 0xffffff00ff000000, 0xffffff00ff0000ff,
+ 0xffffff00ff00ff00, 0xffffff00ff00ffff,
+ 0xffffff00ffff0000, 0xffffff00ffff00ff,
+ 0xffffff00ffffff00, 0xffffff00ffffffff,
+ 0xffffffff00000000, 0xffffffff000000ff,
+ 0xffffffff0000ff00, 0xffffffff0000ffff,
+ 0xffffffff00ff0000, 0xffffffff00ff00ff,
+ 0xffffffff00ffff00, 0xffffffff00ffffff,
+ 0xffffffffff000000, 0xffffffffff0000ff,
+ 0xffffffffff00ff00, 0xffffffffff00ffff,
+ 0xffffffffffff0000, 0xffffffffffff00ff,
+ 0xffffffffffffff00, 0xffffffffffffffff
+#endif
+};
+
+int cfb8StippleMode, cfb8StippleAlu, cfb8StippleRRop;
+PixelGroup cfb8StippleFg, cfb8StippleBg, cfb8StipplePm;
+PixelGroup cfb8StippleAnd[NUM_MASKS], cfb8StippleXor[NUM_MASKS];
+
+int
+cfb8SetStipple (alu, fg, planemask)
+int alu;
+CfbBits fg, planemask;
+{
+ CfbBits and, xor, rrop;
+ int s;
+ CfbBits c;
+
+ cfb8StippleMode = FillStippled;
+ cfb8StippleAlu = alu;
+ cfb8StippleFg = fg & PMSK;
+ cfb8StipplePm = planemask & PMSK;
+ rrop = cfbReduceRasterOp (alu, fg, planemask, &and, &xor);
+ cfb8StippleRRop = rrop;
+ /*
+ * create the appropriate pixel-fill bits for current
+ * foreground
+ */
+ for (s = 0; s < NUM_MASKS; s++)
+ {
+ c = cfb8StippleMasks[s];
+ cfb8StippleAnd[s] = and | ~c;
+ cfb8StippleXor[s] = xor & c;
+ }
+ return TRUE;
+}
+
+
+int
+cfb8SetOpaqueStipple (alu, fg, bg, planemask)
+int alu;
+CfbBits fg, bg, planemask;
+{
+ CfbBits andfg, xorfg, andbg, xorbg, rropfg, rropbg;
+ int s;
+ CfbBits c;
+
+ cfb8StippleMode = FillOpaqueStippled;
+ cfb8StippleAlu = alu;
+ cfb8StippleFg = fg & PMSK;
+ cfb8StippleBg = bg & PMSK;
+ cfb8StipplePm = planemask & PMSK;
+ rropfg = cfbReduceRasterOp (alu, cfb8StippleFg, cfb8StipplePm, &andfg, &xorfg);
+ rropbg = cfbReduceRasterOp (alu, cfb8StippleBg, cfb8StipplePm, &andbg, &xorbg);
+ if (rropfg == rropbg)
+ cfb8StippleRRop = rropfg;
+ else
+ cfb8StippleRRop = GXset;
+ /*
+ * create the appropriate pixel-fill bits for current
+ * foreground
+ */
+ for (s = 0; s < NUM_MASKS; s++)
+ {
+ c = cfb8StippleMasks[s];
+ cfb8StippleAnd[s] = (andfg | ~c) & (andbg | c);
+ cfb8StippleXor[s] = (xorfg & c) | (xorbg & ~c);
+ }
+ return TRUE;
+}
+
+/*
+ * a grungy little routine. This computes clip masks
+ * for partial character blts. Returns rgnOUT if the
+ * entire character is clipped; returns rgnIN if the entire
+ * character is unclipped; returns rgnPART if a portion of
+ * the character is visible. Computes clip masks for each
+ * longword of the character -- and those with the
+ * contents of the glyph to compute the visible bits.
+ */
+
+#if PGSZ == 32
+#if (BITMAP_BIT_ORDER == MSBFirst)
+PixelGroup cfb8BitLenMasks[PGSZ] = {
+ 0xffffffff, 0x7fffffff, 0x3fffffff, 0x1fffffff,
+ 0x0fffffff, 0x07ffffff, 0x03ffffff, 0x01ffffff,
+ 0x00ffffff, 0x007fffff, 0x003fffff, 0x001fffff,
+ 0x000fffff, 0x0007ffff, 0x0003ffff, 0x0001ffff,
+ 0x0000ffff, 0x00007fff, 0x00003fff, 0x00001fff,
+ 0x00000fff, 0x000007ff, 0x000003ff, 0x000001ff,
+ 0x000000ff, 0x0000007f, 0x0000003f, 0x0000001f,
+ 0x0000000f, 0x00000007, 0x00000003, 0x00000001,
+};
+#else
+PixelGroup cfb8BitLenMasks[PGSZ] = {
+ 0xffffffff, 0xfffffffe, 0xfffffffc, 0xfffffff8,
+ 0xfffffff0, 0xffffffe0, 0xffffffc0, 0xffffff80,
+ 0xffffff00, 0xfffffe00, 0xfffffc00, 0xfffff800,
+ 0xfffff000, 0xffffe000, 0xffffc000, 0xffff8000,
+ 0xffff0000, 0xfffe0000, 0xfffc0000, 0xfff80000,
+ 0xfff00000, 0xffe00000, 0xffc00000, 0xff800000,
+ 0xff000000, 0xfe000000, 0xfc000000, 0xf8000000,
+ 0xf0000000, 0xe0000000, 0xc0000000, 0x80000000,
+};
+#endif /* BITMAP_BIT_ORDER */
+#else /* PGSZ == 64 */
+#if (BITMAP_BIT_ORDER == MSBFirst)
+PixelGroup cfb8BitLenMasks[PGSZ] = {
+ 0xffffffffffffffff, 0x7fffffffffffffff,
+ 0x3fffffffffffffff, 0x1fffffffffffffff,
+ 0x0fffffffffffffff, 0x07ffffffffffffff,
+ 0x03ffffffffffffff, 0x01ffffffffffffff,
+ 0x00ffffffffffffff, 0x007fffffffffffff,
+ 0x003fffffffffffff, 0x001fffffffffffff,
+ 0x000fffffffffffff, 0x0007ffffffffffff,
+ 0x0003ffffffffffff, 0x0001ffffffffffff,
+ 0x0000ffffffffffff, 0x00007fffffffffff,
+ 0x00003fffffffffff, 0x00001fffffffffff,
+ 0x00000fffffffffff, 0x000007ffffffffff,
+ 0x000003ffffffffff, 0x000001ffffffffff,
+ 0x000000ffffffffff, 0x0000007fffffffff,
+ 0x0000003fffffffff, 0x0000001fffffffff,
+ 0x0000000fffffffff, 0x00000007ffffffff,
+ 0x00000003ffffffff, 0x00000001ffffffff,
+ 0x00000000ffffffff, 0x000000007fffffff,
+ 0x000000003fffffff, 0x000000001fffffff,
+ 0x000000000fffffff, 0x0000000007ffffff,
+ 0x0000000003ffffff, 0x0000000001ffffff,
+ 0x0000000000ffffff, 0x00000000007fffff,
+ 0x00000000003fffff, 0x00000000001fffff,
+ 0x00000000000fffff, 0x000000000007ffff,
+ 0x000000000003ffff, 0x000000000001ffff,
+ 0x000000000000ffff, 0x0000000000007fff,
+ 0x0000000000003fff, 0x0000000000001fff,
+ 0x0000000000000fff, 0x00000000000007ff,
+ 0x00000000000003ff, 0x00000000000001ff,
+ 0x00000000000000ff, 0x000000000000007f,
+ 0x000000000000003f, 0x000000000000001f,
+ 0x000000000000000f, 0x0000000000000007,
+ 0x0000000000000003, 0x0000000000000001
+};
+#else
+PixelGroup cfb8BitLenMasks[PGSZ] = {
+ 0xffffffffffffffff, 0xfffffffffffffffe,
+ 0xfffffffffffffffc, 0xfffffffffffffff8,
+ 0xfffffffffffffff0, 0xffffffffffffffe0,
+ 0xffffffffffffffc0, 0xffffffffffffff80,
+ 0xffffffffffffff00, 0xfffffffffffffe00,
+ 0xfffffffffffffc00, 0xfffffffffffff800,
+ 0xfffffffffffff000, 0xffffffffffffe000,
+ 0xffffffffffffc000, 0xffffffffffff8000,
+ 0xffffffffffff0000, 0xfffffffffffe0000,
+ 0xfffffffffffc0000, 0xfffffffffff80000,
+ 0xfffffffffff00000, 0xffffffffffe00000,
+ 0xffffffffffc00000, 0xffffffffff800000,
+ 0xffffffffff000000, 0xfffffffffe000000,
+ 0xfffffffffc000000, 0xfffffffff8000000,
+ 0xfffffffff0000000, 0xffffffffe0000000,
+ 0xffffffffc0000000, 0xffffffff80000000,
+ 0xffffffff00000000, 0xfffffffe00000000,
+ 0xfffffffc00000000, 0xfffffff800000000,
+ 0xfffffff000000000, 0xffffffe000000000,
+ 0xffffffc000000000, 0xffffff8000000000,
+ 0xffffff0000000000, 0xfffffe0000000000,
+ 0xfffffc0000000000, 0xfffff80000000000,
+ 0xfffff00000000000, 0xffffe00000000000,
+ 0xffffc00000000000, 0xffff800000000000,
+ 0xffff000000000000, 0xfffe000000000000,
+ 0xfffc000000000000, 0xfff8000000000000,
+ 0xfff0000000000000, 0xffe0000000000000,
+ 0xffc0000000000000, 0xff80000000000000,
+ 0xff00000000000000, 0xfe00000000000000,
+ 0xfc00000000000000, 0xf800000000000000,
+ 0xf000000000000000, 0xe000000000000000,
+ 0xc000000000000000, 0x8000000000000000
+};
+#endif /* BITMAP_BIT_ORDER */
+#endif /* PGSZ */
+
+
+
+int
+cfb8ComputeClipMasks32 (pBox, numRects, x, y, w, h, clips)
+ BoxPtr pBox;
+ int numRects;
+ int x, y, w, h;
+ CARD32 *clips;
+{
+ int yBand, yBandBot;
+ int ch;
+ CfbBits clip;
+ int partIN = FALSE, partOUT = FALSE;
+ int result;
+
+ if (numRects == 0)
+ return rgnOUT;
+ while (numRects && pBox->y2 <= y)
+ {
+ --numRects;
+ ++pBox;
+ }
+ if (!numRects || pBox->y1 >= y + h)
+ return rgnOUT;
+ yBand = pBox->y1;
+ while (numRects && pBox->y1 == yBand && pBox->x2 <= x)
+ {
+ --numRects;
+ ++pBox;
+ }
+ if (!numRects || pBox->y1 >= y + h)
+ return rgnOUT;
+ if (numRects &&
+ x >= pBox->x1 &&
+ x + w <= pBox->x2 &&
+ y >= pBox->y1 &&
+ y + h <= pBox->y2)
+ {
+ return rgnIN;
+ }
+ ch = 0;
+ while (numRects && pBox->y1 < y + h)
+ {
+ yBand = pBox->y1;
+ yBandBot = pBox->y2;
+ while (ch < h && y + ch < yBand)
+ {
+ partOUT = TRUE;
+ clips[ch++] = 0;
+ }
+ if (ch >= h)
+ break;
+ while (numRects && pBox->y1 == yBand && pBox->x2 <= x)
+ {
+ --numRects;
+ ++pBox;
+ }
+ if (!numRects)
+ break;
+ clip = 0;
+ while (numRects && pBox->y1 == yBand && pBox->x1 < x + w)
+ {
+ if (x < pBox->x1)
+ if (pBox->x2 < x + w)
+ clip |= cfb8BitLenMasks[pBox->x1 - x] & ~cfb8BitLenMasks[pBox->x2 - x];
+ else
+ clip |= cfb8BitLenMasks[pBox->x1 - x];
+ else
+ if (pBox->x2 < x + w)
+ clip |= ~cfb8BitLenMasks[pBox->x2 - x];
+ else
+ clip = ~0;
+ --numRects;
+ ++pBox;
+ }
+ if (clip != 0)
+ partIN = TRUE;
+ if (clip != ~0)
+ partOUT = TRUE;
+ while (ch < h && y + ch < yBandBot)
+ clips[ch++] = clip;
+ while (numRects && pBox->y1 == yBand)
+ {
+ --numRects;
+ ++pBox;
+ }
+ }
+ while (ch < h)
+ {
+ partOUT = TRUE;
+ clips[ch++] = 0;
+ }
+ result = rgnOUT;
+ if (partIN)
+ {
+ if (partOUT)
+ result = rgnPART;
+ else
+ result = rgnIN;
+ }
+ return result;
+}
+
+#endif /* PSZ == 8 */
diff --git a/nx-X11/programs/Xserver/cfb/cfb8bit.h b/nx-X11/programs/Xserver/cfb/cfb8bit.h
new file mode 100644
index 000000000..767549af7
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfb8bit.h
@@ -0,0 +1,1572 @@
+/*
+ * cfb8bit.h
+ *
+ * Defines which are only useful to 8 bit color frame buffers
+ *
+ * That doesn't seem to be true any more. Some of the macros in here
+ * are used for depths other than 8. Perhaps the file should be
+ * renamed. dpw
+ */
+/* $XFree86: xc/programs/Xserver/cfb/cfb8bit.h,v 3.7 2001/12/14 19:59:20 dawes Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+
+/* $Xorg: cfb8bit.h,v 1.4 2001/02/09 02:04:37 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "servermd.h"
+
+#if (BITMAP_BIT_ORDER == MSBFirst)
+#define GetBitGroup(x) (((PixelGroup) (x)) >> (PGSZ - PGSZB))
+#define NextBitGroup(x) ((x) <<= PGSZB)
+#define NextSomeBits(x,n) ((x) <<= (n))
+#else
+#define GetBitGroup(x) ((x) & PGSZBMSK)
+#define NextBitGroup(x) ((x) >>= PGSZB)
+#define NextSomeBits(x,n) ((x) >>= (n))
+#endif
+
+#define RotBitsLeft(x,k) ((x) = BitLeft (x,k) | \
+ BitRight (x, PGSZ-(k)))
+
+#if defined(__GNUC__) && defined(mc68020)
+#undef RotBitsLeft
+#define RotBitsLeft(x,k) asm("rol%.l %2,%0" \
+ : "=d" (x) \
+ : "0" (x), "dI" (k))
+#endif
+
+#if PSZ == 8
+
+#define GetPixelGroup(x) (cfb8StippleXor[GetBitGroup(x)])
+#define RRopPixels(dst,x) (DoRRop(dst,cfb8StippleAnd[x], cfb8StippleXor[x]))
+#define RRopPixelGroup(dst,x) (RRopPixels(dst,GetBitGroup(x)))
+#define MaskRRopPixels(dst,x,mask) (DoMaskRRop(dst,cfb8StippleAnd[x], cfb8StippleXor[x], mask))
+
+#define NUM_MASKS (1<<PPW) /* XXX goes in cfbmskbits.h? */
+extern int cfb8StippleMode, cfb8StippleAlu;
+extern PixelGroup cfb8StippleFg, cfb8StippleBg, cfb8StipplePm;
+extern PixelGroup cfb8StippleMasks[NUM_MASKS];
+extern PixelGroup cfb8StippleAnd[NUM_MASKS], cfb8StippleXor[NUM_MASKS];
+extern int cfb8StippleRRop;
+
+#define cfb8PixelMasks cfb8StippleMasks
+#define cfb8Pixels cfb8StippleXor
+
+#define cfb8CheckPixels(fg, bg) \
+ (FillOpaqueStippled == cfb8StippleMode && \
+ GXcopy == cfb8StippleAlu && \
+ ((fg) & PMSK) == cfb8StippleFg && \
+ ((bg) & PMSK) == cfb8StippleBg && \
+ PMSK == cfb8StipplePm)
+
+#define cfb8CheckOpaqueStipple(alu,fg,bg,pm) \
+ ((FillOpaqueStippled == cfb8StippleMode && \
+ (alu) == cfb8StippleAlu && \
+ ((fg) & PMSK) == cfb8StippleFg && \
+ ((bg) & PMSK) == cfb8StippleBg && \
+ ((pm) & PMSK) == cfb8StipplePm) ? 0 : cfb8SetOpaqueStipple(alu,fg,bg,pm))
+
+#define cfb8CheckStipple(alu,fg,pm) \
+ ((FillStippled == cfb8StippleMode && \
+ (alu) == cfb8StippleAlu && \
+ ((fg) & PMSK) == cfb8StippleFg && \
+ ((pm) & PMSK) == cfb8StipplePm) ? 0 : cfb8SetStipple(alu,fg,pm))
+
+#define cfb8SetPixels(fg,bg) cfb8SetOpaqueStipple(GXcopy,fg,bg,PMSK)
+
+/*
+ * These macros are shared between the unnatural spans code
+ * and the unnatural rectangle code. No reasonable person
+ * would attempt to use them anyplace else.
+ */
+
+#define NextUnnaturalStippleWord \
+ if (bitsLeft >= MFB_PPW) \
+ { \
+ inputBits = *srcTemp++; \
+ bitsLeft -= MFB_PPW; \
+ partBitsLeft = MFB_PPW; \
+ } \
+ else \
+ { \
+ inputBits = 0; \
+ if (bitsLeft) \
+ inputBits = *srcTemp & ~cfb8BitLenMasks[bitsLeft]; \
+ srcTemp = srcStart; \
+ partBitsLeft = bitsLeft; \
+ bitsLeft = bitsWhole; \
+ }
+
+#define NextUnnaturalStippleBits \
+ if (partBitsLeft >= PPW) { \
+ bits = GetBitGroup (inputBits); \
+ NextBitGroup (inputBits); \
+ partBitsLeft -= PPW; \
+ } else { \
+ bits = GetBitGroup (inputBits); \
+ nextPartBits = PPW - partBitsLeft; \
+ NextUnnaturalStippleWord \
+ if (partBitsLeft < nextPartBits) { \
+ if (partBitsLeft) {\
+ bits |= BitRight (GetBitGroup (inputBits), \
+ PPW - nextPartBits) & PPWMSK;\
+ nextPartBits -= partBitsLeft; \
+ } \
+ NextUnnaturalStippleWord \
+ } \
+ bits |= BitRight (GetBitGroup (inputBits), \
+ PPW - nextPartBits) & PPWMSK; \
+ NextSomeBits (inputBits, nextPartBits); \
+ partBitsLeft -= nextPartBits; \
+ }
+
+#define NextUnnaturalStippleBitsFast \
+ if (partBitsLeft >= PPW) { \
+ bits = GetBitGroup(inputBits); \
+ NextBitGroup(inputBits); \
+ partBitsLeft -= PPW; \
+ } else { \
+ bits = GetBitGroup (inputBits); \
+ nextPartBits = PPW - partBitsLeft; \
+ inputBits = *srcTemp++; \
+ bits |= BitRight (GetBitGroup (inputBits), \
+ partBitsLeft) & PPWMSK; \
+ NextSomeBits (inputBits, nextPartBits); \
+ partBitsLeft = MFB_PPW - nextPartBits; \
+ }
+
+/*
+ * WriteBitGroup takes the destination address, a pixel
+ * value (which must be 8 bits duplicated 4 time with PFILL)
+ * and the PPW bits to write, which must be in the low order
+ * bits of the register (probably from GetBitGroup) and writes
+ * the appropriate locations in memory with the pixel value. This
+ * is a copy-mode only operation.
+ */
+
+#define RRopBitGroup(dst,bits) \
+ { \
+ *(dst) = RRopPixels(*(dst),bits); \
+ }
+
+#define MaskRRopBitGroup(dst,bits,mask) \
+ { \
+ *(dst) = MaskRRopPixels(*(dst),bits,mask); \
+ }
+#endif /* PSZ == 8 */
+
+#if !defined(AVOID_MEMORY_READ) && PSZ == 8
+
+#define WriteBitGroup(dst,pixel,bits) \
+ { \
+ register PixelGroup _maskTmp = cfb8PixelMasks[(bits)]; \
+ *(dst) = (*(dst) & ~_maskTmp) | ((pixel) & _maskTmp); \
+ }
+
+#define SwitchBitGroup(dst,pixel,bits) \
+ { \
+ register PixelGroup _maskTmp = cfb8PixelMasks[(bits)]; \
+ register PixelGroup _pixTmp = ((pixel) & _maskTmp); \
+ _maskTmp = ~_maskTmp; \
+ SwitchBitsLoop (*(dst) = (*(dst) & _maskTmp) | _pixTmp;) \
+ }
+
+#else /* AVOID_MEMORY_READ */
+
+#if PGSZ == 32
+#if (BITMAP_BIT_ORDER == MSBFirst)
+#define SinglePixel0 3
+#define SinglePixel1 2
+#define SinglePixel2 1
+#define SinglePixel3 0
+#define SinglePixel4 7
+#define SinglePixel5 6
+#define SinglePixel6 5
+#define SinglePixel7 4
+#define SinglePixel8 0xB
+#define SinglePixel9 0xA
+#define DoublePixel0 1
+#define DoublePixel1 0
+#define DoublePixel2 3
+#define DoublePixel3 2
+#define DoublePixel4 5
+#define DoublePixel5 4
+#else
+#define SinglePixel0 0
+#define SinglePixel1 1
+#define SinglePixel2 2
+#define SinglePixel3 3
+#define SinglePixel4 4
+#define SinglePixel5 5
+#define SinglePixel6 6
+#define SinglePixel7 7
+#define SinglePixel8 8
+#define SinglePixel9 9
+#define DoublePixel0 0
+#define DoublePixel1 1
+#define DoublePixel2 2
+#define DoublePixel3 3
+#define DoublePixel4 4
+#define DoublePixel5 5
+#endif
+#define QuadPixel0 0
+#define QuadPixel1 1
+#define QuadPixel2 2
+#else /* PGSZ == 64 */
+#if (BITMAP_BIT_ORDER == MSBFirst)
+#define SinglePixel0 7
+#define SinglePixel1 6
+#define SinglePixel2 5
+#define SinglePixel3 4
+#define SinglePixel4 3
+#define SinglePixel5 2
+#define SinglePixel6 1
+#define SinglePixel7 0
+#define DoublePixel0 3
+#define DoublePixel1 2
+#define DoublePixel2 1
+#define DoublePixel3 0
+#define QuadPixel0 1
+#define QuadPixel1 0
+#else
+#define SinglePixel0 0
+#define SinglePixel1 1
+#define SinglePixel2 2
+#define SinglePixel3 3
+#define SinglePixel4 4
+#define SinglePixel5 5
+#define SinglePixel6 6
+#define SinglePixel7 7
+#define DoublePixel0 0
+#define DoublePixel1 1
+#define DoublePixel2 2
+#define DoublePixel3 3
+#define QuadPixel0 0
+#define QuadPixel1 1
+#endif
+#define OctaPixel0 0
+#endif /* PGSZ == 64 */
+
+#if PSZ == 8
+
+#if PGSZ == 32
+#define WriteBitGroup(dst,pixel,bits) \
+ switch (bits) { \
+ case 0: \
+ break; \
+ case 1: \
+ ((CARD8 *) (dst))[SinglePixel0] = (pixel); \
+ break; \
+ case 2: \
+ ((CARD8 *) (dst))[SinglePixel1] = (pixel); \
+ break; \
+ case 3: \
+ ((CARD16 *) (dst))[DoublePixel0] = (pixel); \
+ break; \
+ case 4: \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 5: \
+ ((CARD8 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 6: \
+ ((CARD8 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 7: \
+ ((CARD16 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 8: \
+ ((CARD8 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 9: \
+ ((CARD8 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 10: \
+ ((CARD8 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 11: \
+ ((CARD16 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 12: \
+ ((CARD16 *) (dst))[DoublePixel1] = (pixel); \
+ break; \
+ case 13: \
+ ((CARD8 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel1] = (pixel); \
+ break; \
+ case 14: \
+ ((CARD8 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel1] = (pixel); \
+ break; \
+ case 15: \
+ ((CARD32 *) (dst))[0] = (pixel); \
+ break; \
+ }
+#else /* PGSZ == 64 */
+#define WriteBitGroup(dst,pixel,bits) \
+ if ( bits == 0xff ) \
+ ((PixelGroup *) (dst))[OctaPixel0] = (pixel); \
+ else { \
+ switch (bits & 0x0f) { \
+ case 0: \
+ break; \
+ case 1: \
+ ((CARD8 *) (dst))[SinglePixel0] = (pixel); \
+ break; \
+ case 2: \
+ ((CARD8 *) (dst))[SinglePixel1] = (pixel); \
+ break; \
+ case 3: \
+ ((CARD16 *) (dst))[DoublePixel0] = (pixel); \
+ break; \
+ case 4: \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 5: \
+ ((CARD8 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 6: \
+ ((CARD8 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 7: \
+ ((CARD16 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 8: \
+ ((CARD8 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 9: \
+ ((CARD8 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 10: \
+ ((CARD8 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 11: \
+ ((CARD16 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 12: \
+ ((CARD16 *) (dst))[DoublePixel1] = (pixel); \
+ break; \
+ case 13: \
+ ((CARD8 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel1] = (pixel); \
+ break; \
+ case 14: \
+ ((CARD8 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel1] = (pixel); \
+ break; \
+ case 15: \
+ ((CARD32 *) (dst))[QuadPixel0] = (pixel); \
+ break; \
+ } \
+ switch ((bits & 0xf0) >> 4) { \
+ case 0: \
+ break; \
+ case 1: \
+ ((CARD8 *) (dst))[SinglePixel4] = (pixel); \
+ break; \
+ case 2: \
+ ((CARD8 *) (dst))[SinglePixel5] = (pixel); \
+ break; \
+ case 3: \
+ ((CARD16 *) (dst))[DoublePixel2] = (pixel); \
+ break; \
+ case 4: \
+ ((CARD8 *) (dst))[SinglePixel6] = (pixel); \
+ break; \
+ case 5: \
+ ((CARD8 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel6] = (pixel); \
+ break; \
+ case 6: \
+ ((CARD8 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel6] = (pixel); \
+ break; \
+ case 7: \
+ ((CARD16 *) (dst))[DoublePixel2] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel6] = (pixel); \
+ break; \
+ case 8: \
+ ((CARD8 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 9: \
+ ((CARD8 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 10: \
+ ((CARD8 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 11: \
+ ((CARD16 *) (dst))[DoublePixel2] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 12: \
+ ((CARD16 *) (dst))[DoublePixel3] = (pixel); \
+ break; \
+ case 13: \
+ ((CARD8 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel3] = (pixel); \
+ break; \
+ case 14: \
+ ((CARD8 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel3] = (pixel); \
+ break; \
+ case 15: \
+ ((CARD32 *) (dst))[QuadPixel1] = (pixel); \
+ break; \
+ } \
+ }
+#endif /* PGSZ == 64 */
+
+#if PGSZ == 32
+#define SwitchBitGroup(dst,pixel,bits) { \
+ switch (bits) { \
+ case 0: \
+ break; \
+ case 1: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel0] = (pixel);) \
+ break; \
+ case 2: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel1] = (pixel);) \
+ break; \
+ case 3: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel);) \
+ break; \
+ case 4: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 5: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 6: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 7: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 8: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 9: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 10: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 11: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 12: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel1] = (pixel);) \
+ break; \
+ case 13: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel1] = (pixel);) \
+ break; \
+ case 14: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel1] = (pixel);) \
+ break; \
+ case 15: \
+ SwitchBitsLoop (((CARD32 *) (dst))[0] = (pixel);) \
+ break; \
+ } \
+}
+#else /* PGSZ == 64 */
+#define SwitchBitGroup(dst,pixel,bits) { \
+ if ( bits == 0xff ) \
+ SwitchBitsLoop (((PixelGroup *) (dst))[OctaPixel0] = (pixel);) \
+ else { \
+ switch (bits & 0x0f) { \
+ case 0: \
+ break; \
+ case 1: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel0] = (pixel);) \
+ break; \
+ case 2: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel1] = (pixel);) \
+ break; \
+ case 3: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel);)\
+ break; \
+ case 4: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 5: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 6: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 7: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 8: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 9: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 10: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 11: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 12: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel1] = (pixel);)\
+ break; \
+ case 13: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel1] = (pixel);)\
+ break; \
+ case 14: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel1] = (pixel);)\
+ break; \
+ case 15: \
+ SwitchBitsLoop (((CARD32 *) (dst))[QuadPixel0] = (pixel);) \
+ break; \
+ } \
+ switch ((bits & 0xf0) >> 4) { \
+ case 0: \
+ break; \
+ case 1: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel4] = (pixel);) \
+ break; \
+ case 2: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel5] = (pixel);) \
+ break; \
+ case 3: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel2] = (pixel);)\
+ break; \
+ case 4: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel6] = (pixel);) \
+ break; \
+ case 5: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel6] = (pixel);) \
+ break; \
+ case 6: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel6] = (pixel);) \
+ break; \
+ case 7: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel2] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel6] = (pixel);) \
+ break; \
+ case 8: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel7] = (pixel);) \
+ break; \
+ case 9: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel7] = (pixel);) \
+ break; \
+ case 10: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel7] = (pixel);) \
+ break; \
+ case 11: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel2] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel7] = (pixel);) \
+ break; \
+ case 12: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel3] = (pixel);)\
+ break; \
+ case 13: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel3] = (pixel);)\
+ break; \
+ case 14: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel3] = (pixel);)\
+ break; \
+ case 15: \
+ SwitchBitsLoop (((CARD32 *) (dst))[QuadPixel1] = (pixel);) \
+ break; \
+ } \
+ } \
+}
+#endif /* PGSZ == 64 */
+#endif /* PSZ == 8 */
+
+#if PSZ == 16
+
+#if PGSZ == 32
+#define WriteBitGroup(dst,pixel,bits) \
+ switch (bits) { \
+ case 0: \
+ break; \
+ case 1: \
+ ((CARD16 *) (dst))[SinglePixel0] = (pixel); \
+ break; \
+ case 2: \
+ ((CARD16 *) (dst))[SinglePixel1] = (pixel); \
+ break; \
+ case 3: \
+ ((CARD32 *) (dst))[DoublePixel0] = (pixel); \
+ break; \
+ case 4: \
+ ((CARD16 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 5: \
+ ((CARD16 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 6: \
+ ((CARD16 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 7: \
+ ((CARD32 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 8: \
+ ((CARD16 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 9: \
+ ((CARD16 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 10: \
+ ((CARD16 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 11: \
+ ((CARD32 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 12: \
+ ((CARD32 *) (dst))[DoublePixel1] = (pixel); \
+ break; \
+ case 13: \
+ ((CARD16 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[DoublePixel1] = (pixel); \
+ break; \
+ case 14: \
+ ((CARD16 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[DoublePixel1] = (pixel); \
+ break; \
+ case 15: \
+ ((CARD32 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD32 *) (dst))[DoublePixel1] = (pixel); \
+ break; \
+ }
+#else /* PGSZ == 64 */
+#define WriteBitGroup(dst,pixel,bits) \
+ if ( bits == 0xff ) { \
+ ((PixelGroup *) (dst))[QuadPixel0] = (pixel); \
+ ((PixelGroup *) (dst))[QuadPixel1] = (pixel); \
+ } \
+ else { \
+ switch (bits & 0x0f) { \
+ case 0: \
+ break; \
+ case 1: \
+ ((CARD16 *) (dst))[SinglePixel0] = (pixel); \
+ break; \
+ case 2: \
+ ((CARD16 *) (dst))[SinglePixel1] = (pixel); \
+ break; \
+ case 3: \
+ ((CARD32 *) (dst))[DoublePixel0] = (pixel); \
+ break; \
+ case 4: \
+ ((CARD16 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 5: \
+ ((CARD16 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 6: \
+ ((CARD16 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 7: \
+ ((CARD32 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 8: \
+ ((CARD16 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 9: \
+ ((CARD16 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 10: \
+ ((CARD16 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 11: \
+ ((CARD32 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 12: \
+ ((CARD32 *) (dst))[DoublePixel1] = (pixel); \
+ break; \
+ case 13: \
+ ((CARD16 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[DoublePixel1] = (pixel); \
+ break; \
+ case 14: \
+ ((CARD16 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[DoublePixel1] = (pixel); \
+ break; \
+ case 15: \
+ ((CARD32 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD32 *) (dst))[DoublePixel1] = (pixel); \
+ break; \
+ } \
+ switch ((bits & 0xf0) >> 4) { \
+ case 0: \
+ break; \
+ case 1: \
+ ((CARD16 *) (dst))[SinglePixel4] = (pixel); \
+ break; \
+ case 2: \
+ ((CARD16 *) (dst))[SinglePixel5] = (pixel); \
+ break; \
+ case 3: \
+ ((CARD32 *) (dst))[DoublePixel2] = (pixel); \
+ break; \
+ case 4: \
+ ((CARD16 *) (dst))[SinglePixel6] = (pixel); \
+ break; \
+ case 5: \
+ ((CARD16 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel6] = (pixel); \
+ break; \
+ case 6: \
+ ((CARD16 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel6] = (pixel); \
+ break; \
+ case 7: \
+ ((CARD32 *) (dst))[DoublePixel2] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel6] = (pixel); \
+ break; \
+ case 8: \
+ ((CARD16 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 9: \
+ ((CARD16 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 10: \
+ ((CARD16 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 11: \
+ ((CARD32 *) (dst))[DoublePixel2] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 12: \
+ ((CARD32 *) (dst))[DoublePixel3] = (pixel); \
+ break; \
+ case 13: \
+ ((CARD16 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD32 *) (dst))[DoublePixel3] = (pixel); \
+ break; \
+ case 14: \
+ ((CARD16 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD32 *) (dst))[DoublePixel3] = (pixel); \
+ break; \
+ case 15: \
+ ((CARD32 *) (dst))[DoublePixel2] = (pixel); \
+ ((CARD32 *) (dst))[DoublePixel3] = (pixel); \
+ break; \
+ } \
+ }
+#endif /* PGSZ */
+
+#if PGSZ == 32
+#define SwitchBitGroup(dst,pixel,bits) { \
+ switch (bits) { \
+ case 0: \
+ break; \
+ case 1: \
+ SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel0] = (pixel);) \
+ break; \
+ case 2: \
+ SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel1] = (pixel);) \
+ break; \
+ case 3: \
+ SwitchBitsLoop (((CARD32 *) (dst))[DoublePixel0] = (pixel);) \
+ break; \
+ case 4: \
+ SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 5: \
+ SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 6: \
+ SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 7: \
+ SwitchBitsLoop (((CARD32 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 8: \
+ SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 9: \
+ SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 10: \
+ SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 11: \
+ SwitchBitsLoop (((CARD32 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD16 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 12: \
+ SwitchBitsLoop (((CARD32 *) (dst))[DoublePixel1] = (pixel);) \
+ break; \
+ case 13: \
+ SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[DoublePixel1] = (pixel);) \
+ break; \
+ case 14: \
+ SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[DoublePixel1] = (pixel);) \
+ break; \
+ case 15: \
+ SwitchBitsLoop (((CARD32 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD32 *) (dst))[DoublePixel1] = (pixel);) \
+ break; \
+ } \
+}
+#else /* PGSZ == 64 */
+#define SwitchBitGroup(dst,pixel,bits) { \
+ cfb cannot hack 64-bit SwitchBitGroup psz=PSZ
+#endif /* PGSZ */
+
+#endif /* PSZ == 16 */
+
+#if PSZ == 24
+/* 32 000011112222*/
+/* 24 000111222333*/
+/* 16 001122334455*/
+/* 8 0123456789AB*/
+#if PGSZ == 32
+#define WriteBitGroup(dst,pixel,bits) \
+ { \
+ register CARD32 reg_pixel = (pixel); \
+ switch (bits) { \
+ case 0: \
+ break; \
+ case 1: \
+ ((CARD16 *) (dst))[DoublePixel0] = reg_pixel; \
+ ((CARD8 *) (dst))[SinglePixel2] = ((reg_pixel>>16)&0xFF); \
+ break; \
+ case 2: \
+ ((CARD8 *) (dst))[SinglePixel3] = reg_pixel&0xFF; \
+ ((CARD16 *) (dst))[DoublePixel2] = (reg_pixel>>8)&0xFFFF; \
+ break; \
+ case 3: \
+ ((CARD8 *) (dst))[SinglePixel3] = reg_pixel & 0xFF; \
+ ((CARD16 *) (dst))[DoublePixel0] = reg_pixel; \
+ ((CARD16 *) (dst))[DoublePixel2] = (reg_pixel>>8)&0xFFFF; \
+ ((CARD8 *) (dst))[SinglePixel2] = (reg_pixel>>16&0xFF); \
+ break; \
+ case 4: \
+ ((CARD16 *) (dst))[DoublePixel3] = reg_pixel; \
+ ((CARD8 *) (dst))[SinglePixel8] = (reg_pixel>>16)&0xFF; \
+ break; \
+ case 5: \
+ ((CARD16 *) (dst))[DoublePixel0] = \
+ ((CARD16 *) (dst))[DoublePixel3] = reg_pixel; \
+ reg_pixel >>= 16; \
+ ((CARD8 *) (dst))[SinglePixel2] = \
+ ((CARD8 *) (dst))[SinglePixel8] = reg_pixel&0xFF; \
+ break; \
+ case 6: \
+ ((CARD8 *) (dst))[SinglePixel3] = reg_pixel; \
+ ((CARD16 *) (dst))[DoublePixel3] = reg_pixel; \
+ reg_pixel >>= 8; \
+ ((CARD16 *) (dst))[DoublePixel2] = reg_pixel; \
+ reg_pixel >>= 8; \
+ ((CARD8 *) (dst))[SinglePixel8] = reg_pixel&0xFF; \
+ break; \
+ case 7: \
+ ((CARD16 *) (dst))[DoublePixel0] = \
+ ((CARD16 *) (dst))[DoublePixel3] = reg_pixel; \
+ ((CARD8 *) (dst))[SinglePixel3] = reg_pixel&0xFF; \
+ reg_pixel >>= 8; \
+ ((CARD16 *) (dst))[DoublePixel2] = reg_pixel; \
+ reg_pixel >>= 8; \
+ ((CARD8 *) (dst))[SinglePixel2] = \
+ ((CARD8 *) (dst))[SinglePixel8] = reg_pixel&0xFF; \
+ break; \
+ case 8: \
+ ((CARD8 *) (dst))[SinglePixel9] = reg_pixel&0xFF; \
+ ((CARD16 *) (dst))[DoublePixel5] = (reg_pixel>>8); \
+ break; \
+ case 9: \
+ ((CARD16 *) (dst))[DoublePixel0] = reg_pixel; \
+ ((CARD8 *) (dst))[SinglePixel9] = reg_pixel&0xFF; \
+ reg_pixel >>= 8; \
+ ((CARD16 *) (dst))[DoublePixel5] = reg_pixel; \
+ reg_pixel >>= 8; \
+ ((CARD8 *) (dst))[SinglePixel2] = reg_pixel&0xFF; \
+ break; \
+ case 10: \
+ ((CARD8 *) (dst))[SinglePixel3] = \
+ ((CARD8 *) (dst))[SinglePixel9] = reg_pixel&0xFF; \
+ reg_pixel >>= 8; \
+ ((CARD16 *) (dst))[DoublePixel2] = \
+ ((CARD16 *) (dst))[DoublePixel5] = reg_pixel; \
+ break; \
+ case 11: \
+ ((CARD8 *) (dst))[SinglePixel3] = \
+ ((CARD8 *) (dst))[SinglePixel9] = reg_pixel; \
+ ((CARD16 *) (dst))[DoublePixel0] = reg_pixel; \
+ reg_pixel >>= 8; \
+ ((CARD16 *) (dst))[DoublePixel2] = \
+ ((CARD16 *) (dst))[DoublePixel5] = reg_pixel; \
+ reg_pixel >>= 8; \
+ ((CARD8 *) (dst))[SinglePixel2] = reg_pixel; \
+ break; \
+ case 12: \
+ ((CARD16 *) (dst))[DoublePixel3] = reg_pixel; \
+ ((CARD8 *) (dst))[SinglePixel9] = reg_pixel; \
+ reg_pixel >>= 8; \
+ ((CARD16 *) (dst))[DoublePixel5] = reg_pixel; \
+ reg_pixel >>= 8; \
+ ((CARD8 *) (dst))[SinglePixel8] = reg_pixel; \
+ break; \
+ case 13: \
+ ((CARD16 *) (dst))[DoublePixel0] = \
+ ((CARD16 *) (dst))[DoublePixel3] = reg_pixel; \
+ ((CARD8 *) (dst))[SinglePixel9] = reg_pixel; \
+ reg_pixel >>= 8; \
+ ((CARD16 *) (dst))[DoublePixel5] = reg_pixel; \
+ reg_pixel >>= 8; \
+ ((CARD8 *) (dst))[SinglePixel2] = \
+ ((CARD8 *) (dst))[SinglePixel8] = reg_pixel; \
+ break; \
+ case 14: \
+ ((CARD8 *) (dst))[SinglePixel3] = \
+ ((CARD8 *) (dst))[SinglePixel9] = reg_pixel; \
+ ((CARD16 *) (dst))[DoublePixel3] = reg_pixel; \
+ reg_pixel >>= 8; \
+ ((CARD16 *) (dst))[DoublePixel2] = \
+ ((CARD16 *) (dst))[DoublePixel5] = reg_pixel; \
+ reg_pixel >>= 8; \
+ ((CARD8 *) (dst))[SinglePixel8] = reg_pixel; \
+ break; \
+ case 15: \
+ ((CARD16 *) (dst))[DoublePixel0] = \
+ ((CARD16 *) (dst))[DoublePixel3] = reg_pixel; \
+ ((CARD8 *) (dst))[SinglePixel3] = \
+ ((CARD8 *) (dst))[SinglePixel9] = reg_pixel; \
+ reg_pixel >>= 8; \
+ ((CARD16 *) (dst))[DoublePixel2] = \
+ ((CARD16 *) (dst))[DoublePixel5] = reg_pixel; \
+ reg_pixel >>= 8; \
+ ((CARD8 *) (dst))[SinglePixel8] = \
+ ((CARD8 *) (dst))[SinglePixel2] = reg_pixel; \
+ break; \
+ } \
+ }
+#else /* PGSZ == 64 */
+#define WriteBitGroup(dst,pixel,bits) \
+ if ( bits == 0xff ) { \
+ ((PixelGroup *) (dst))[DoublePixel0] = (pixel); \
+ ((PixelGroup *) (dst))[DoublePixel1] = (pixel); \
+ ((PixelGroup *) (dst))[DoublePixel2] = (pixel); \
+ ((PixelGroup *) (dst))[DoublePixel3] = (pixel); \
+ } \
+ else { \
+ switch (bits & 0x0f) { \
+ case 0: \
+ break; \
+ case 1: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ break; \
+ case 2: \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ break; \
+ case 3: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ break; \
+ case 4: \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 5: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 6: \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 7: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 8: \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 9: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 10: \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 11: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 12: \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 13: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 14: \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 15: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ } \
+ switch ((bits & 0xf0) >> 4) { \
+ case 0: \
+ break; \
+ case 1: \
+ ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
+ break; \
+ case 2: \
+ ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
+ break; \
+ case 3: \
+ ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
+ break; \
+ case 4: \
+ ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
+ break; \
+ case 5: \
+ ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
+ break; \
+ case 6: \
+ ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
+ break; \
+ case 7: \
+ ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
+ break; \
+ case 8: \
+ ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 9: \
+ ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 10: \
+ ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 11: \
+ ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 12: \
+ ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 13: \
+ ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 14: \
+ ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 15: \
+ ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ } \
+ }
+#endif /* PGSZ */
+
+#if PGSZ == 32
+#define SwitchBitGroup(dst,pixel,bits) { \
+ switch (bits) { \
+ case 0: \
+ break; \
+ case 1: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 2: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel3] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel2] = (pixel);) \
+ break; \
+ case 3: \
+ SwitchBitsLoop (((CARD32 *) (dst))[QuadPixel0] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel2] = (pixel);) \
+ break; \
+ case 4: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel3] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel8] = (pixel);) \
+ break; \
+ case 5: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel3] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel8] = (pixel);) \
+ break; \
+ case 6: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel3] = (pixel); \
+ ((CARD32 *) (dst))[QuadPixel2] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel8] = (pixel);) \
+ break; \
+ case 7: \
+ SwitchBitsLoop (((CARD32 *) (dst))[QuadPixel0] = (pixel); \
+ ((CARD32 *) (dst))[QuadPixel1] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel8] = (pixel);) \
+ break; \
+ case 8: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel9] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel5] = (pixel);) \
+ break; \
+ case 9: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel9] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel5] = (pixel);) \
+ break; \
+ case 10: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel3] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel2] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel9] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel5] = (pixel);) \
+ break; \
+ case 11: \
+ SwitchBitsLoop (((CARD32 *) (dst))[QuadPixel0] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel3] = (pixel);) \
+ ((CARD8 *) (dst))[SinglePixel9] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel5] = (pixel);) \
+ break; \
+ case 12: \
+ SwitchBitsLoop (((CARD16 *) (dst))[DoublePixel3] = (pixel); \
+ ((CARD32 *) (dst))[QuadPixel2] = (pixel);) \
+ break; \
+ case 13: \
+ SwitchBitsLoop (((CARD16 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD8 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD16 *) (dst))[DoublePixel3] = (pixel); \
+ ((CARD32 *) (dst))[QuadPixel2] = (pixel);) \
+ break; \
+ case 14: \
+ SwitchBitsLoop (((CARD8 *) (dst))[SinglePixel3] = (pixel); \
+ ((CARD32 *) (dst))[QuadPixel1] = (pixel); \
+ ((CARD32 *) (dst))[QuadPixel2] = (pixel);) \
+ break; \
+ case 15: \
+ SwitchBitsLoop (((CARD32 *) (dst))[QuadPixel0] = (pixel); \
+ ((CARD32 *) (dst))[QuadPixel1] = (pixel); \
+ ((CARD32 *) (dst))[QuadPixel2] = (pixel);) \
+ break; \
+ } \
+}
+#else /* PGSZ == 64 */
+#define SwitchBitGroup(dst,pixel,bits) { \
+ cfb cannot hack 64-bit SwitchBitGroup psz=PSZ
+#endif /* PGSZ */
+
+#endif /* PSZ == 24 */
+
+#if PSZ == 32
+
+#if PGSZ == 32
+#define WriteBitGroup(dst,pixel,bits) \
+ switch (bits) { \
+ case 0: \
+ break; \
+ case 1: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ break; \
+ case 2: \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ break; \
+ case 3: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ break; \
+ case 4: \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 5: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 6: \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 7: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 8: \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 9: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 10: \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 11: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 12: \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 13: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 14: \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 15: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ }
+#else /* PGSZ == 64 */
+#define WriteBitGroup(dst,pixel,bits) \
+ if ( bits == 0xff ) { \
+ ((PixelGroup *) (dst))[DoublePixel0] = (pixel); \
+ ((PixelGroup *) (dst))[DoublePixel1] = (pixel); \
+ ((PixelGroup *) (dst))[DoublePixel2] = (pixel); \
+ ((PixelGroup *) (dst))[DoublePixel3] = (pixel); \
+ } \
+ else { \
+ switch (bits & 0x0f) { \
+ case 0: \
+ break; \
+ case 1: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ break; \
+ case 2: \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ break; \
+ case 3: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ break; \
+ case 4: \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 5: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 6: \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 7: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ break; \
+ case 8: \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 9: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 10: \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 11: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 12: \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 13: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 14: \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ case 15: \
+ ((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel); \
+ break; \
+ } \
+ switch ((bits & 0xf0) >> 4) { \
+ case 0: \
+ break; \
+ case 1: \
+ ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
+ break; \
+ case 2: \
+ ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
+ break; \
+ case 3: \
+ ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
+ break; \
+ case 4: \
+ ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
+ break; \
+ case 5: \
+ ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
+ break; \
+ case 6: \
+ ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
+ break; \
+ case 7: \
+ ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
+ break; \
+ case 8: \
+ ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 9: \
+ ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 10: \
+ ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 11: \
+ ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 12: \
+ ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 13: \
+ ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 14: \
+ ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ case 15: \
+ ((CARD32 *) (dst))[SinglePixel4] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel5] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel6] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel7] = (pixel); \
+ break; \
+ } \
+ }
+#endif /* PGSZ */
+
+#if PGSZ == 32
+#define SwitchBitGroup(dst,pixel,bits) { \
+ switch (bits) { \
+ case 0: \
+ break; \
+ case 1: \
+ SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel0] = (pixel);) \
+ break; \
+ case 2: \
+ SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel1] = (pixel);) \
+ break; \
+ case 3: \
+ SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel);) \
+ break; \
+ case 4: \
+ SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 5: \
+ SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 6: \
+ SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 7: \
+ SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel);) \
+ break; \
+ case 8: \
+ SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 9: \
+ SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 10: \
+ SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 11: \
+ SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 12: \
+ SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 13: \
+ SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 14: \
+ SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ case 15: \
+ SwitchBitsLoop (((CARD32 *) (dst))[SinglePixel0] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel1] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel2] = (pixel); \
+ ((CARD32 *) (dst))[SinglePixel3] = (pixel);) \
+ break; \
+ } \
+}
+#else /* PGSZ == 64 */
+#define SwitchBitGroup(dst,pixel,bits) { \
+ cfb cannot hack 64-bit SwitchBitGroup psz=PSZ
+#endif /* PGSZ */
+
+#endif /* PSZ == 32 */
+#endif /* AVOID_MEMORY_READ */
+
+extern PixelGroup cfb8BitLenMasks[PGSZ];
+
+extern int cfb8SetStipple (
+ int /*alu*/,
+ CfbBits /*fg*/,
+ CfbBits /*planemask*/
+);
+
+extern int cfb8SetOpaqueStipple (
+ int /*alu*/,
+ CfbBits /*fg*/,
+ CfbBits /*bg*/,
+ CfbBits /*planemask*/
+);
+
+extern int cfb8ComputeClipMasks32 (
+ BoxPtr /*pBox*/,
+ int /*numRects*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ CARD32 * /*clips*/
+);
diff --git a/nx-X11/programs/Xserver/cfb/cfb8line.c b/nx-X11/programs/Xserver/cfb/cfb8line.c
new file mode 100644
index 000000000..0f27f1d47
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfb8line.c
@@ -0,0 +1,1504 @@
+/*
+ * $Xorg: cfb8line.c,v 1.4 2001/02/09 02:04:37 xorgcvs Exp $
+ *
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ *
+ * $XFree86: xc/programs/Xserver/cfb/cfb8line.c,v 3.18tsi Exp $
+ * Jeff Anton'x fixes: cfb8line.c 97/02/07
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "mistruct.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "cfbrrop.h"
+#include "miline.h"
+
+#ifdef PIXEL_ADDR
+
+#if defined(__GNUC__) && defined(mc68020)
+#define STUPID volatile
+#define REARRANGE
+#else
+#define STUPID
+#endif
+
+#ifdef __GNUC__
+/* lame compiler doesn't even look at 'register' attributes */
+#define I_H do{
+#define I_T }while(0);
+#define IMPORTANT_START I_H I_H I_H I_H I_H I_H I_H I_H I_H I_H
+#define IMPORTANT_END I_T I_T I_T I_T I_T I_T I_T I_T I_T I_T
+#else
+#define IMPORTANT_START
+#define IMPORTANT_END
+#endif
+
+#define isClipped(c,ul,lr) ((((c) - (ul)) | ((lr) - (c))) & ClipMask)
+
+#ifdef POLYSEGMENT
+
+# if (defined(sun) || defined(__bsdi__)) && \
+ (defined(sparc) || defined(__sparc__))
+# define WIDTH_FAST 1152
+# endif
+
+# ifdef ultrix
+# define WIDTH_FAST 1024
+# endif
+
+# ifdef Mips
+# define WIDTH_FAST 4096
+# endif
+# ifdef WIDTH_FAST
+# if WIDTH_FAST == 1024
+# define FAST_MUL(y) ((y) << 10)
+# endif
+
+# if WIDTH_FAST == 1152
+# define FAST_MUL(y) (((y) << 10) + ((y) << 7))
+# endif
+
+# if WIDTH_FAST == 1280
+# define FAST_MUL(y) (((y) << 10) + ((y) << 8))
+# endif
+
+# if WIDTH_FAST == 2048
+# define FAST_MUL(y) ((y) << 11)
+# endif
+
+# if WIDTH_FAST == 4096
+# define FAST_MUL(y) ((y) << 12)
+# endif
+# endif
+
+# if defined(WIDTH_SHIFT)
+# ifdef FAST_MUL
+# define FUNC_NAME(e) RROP_NAME(RROP_NAME_CAT(e,Shift))
+# if RROP == GXcopy
+# define INCLUDE_OTHERS
+# define SERIOUS_UNROLLING
+# endif
+# define INCLUDE_DRAW
+# define NWIDTH(nwidth) WIDTH_FAST
+# define WIDTH_MUL(y,w) FAST_MUL(y)
+# endif
+# else
+# define FUNC_NAME(e) RROP_NAME(e)
+# define WIDTH_MUL(y,w) ((y) * (w))
+# define NWIDTH(nwidth) (nwidth)
+# define INCLUDE_DRAW
+# if !defined (FAST_MUL) && RROP == GXcopy
+# define INCLUDE_OTHERS
+# define SERIOUS_UNROLLING
+# endif
+# endif
+#else
+
+# define INCLUDE_DRAW
+# define WIDTH_MUL(y,w) ((y) * (w))
+# define NWIDTH(nwidth) nwidth
+# ifdef PREVIOUS
+# define FUNC_NAME(e) RROP_NAME(RROP_NAME_CAT(e,Previous))
+# else
+# define FUNC_NAME(e) RROP_NAME(e)
+# if RROP == GXcopy
+# define INCLUDE_OTHERS
+# ifdef PLENTIFUL_REGISTERS
+# define SAVE_X2Y2
+# endif
+# define ORIGIN
+# define SERIOUS_UNROLLING
+# else
+# define EITHER_MODE
+# endif
+# endif
+#endif
+
+#if PSZ == 24
+#define PXL2ADR(x) ((x)*3 >> 2)
+
+#if RROP == GXcopy
+#define body_rop \
+ addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
+ switch((unsigned long)addrb & 3){ \
+ case 0: \
+ *addrp = (*addrp & 0xFF000000)|(piQxelXor[0] & 0xFFFFFF); \
+ break; \
+ case 1: \
+ *addrp = (*addrp & 0xFF)|(piQxelXor[2] & 0xFFFFFF00); \
+ break; \
+ case 3: \
+ *addrp = (*addrp & 0xFFFFFF)|(piQxelXor[0] & 0xFF000000); \
+ *(addrp+1)=(*(addrp+1) & 0xFFFF0000)|(piQxelXor[1] & 0xFFFF); \
+ break; \
+ case 2: \
+ *addrp = (*addrp & 0xFFFF)|(piQxelXor[1] & 0xFFFF0000); \
+ *(addrp+1)=(*(addrp+1) & 0xFFFFFF00)|(piQxelXor[2] & 0xFF); \
+ break; \
+ }
+#endif
+#if RROP == GXxor
+#define body_rop \
+ addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
+ switch((unsigned long)addrb & 3){ \
+ case 0: \
+ *addrp ^= piQxelXor[0] & 0xFFFFFF; \
+ break; \
+ case 1: \
+ *addrp ^= piQxelXor[2] & 0xFFFFFF00; \
+ break; \
+ case 3: \
+ *addrp ^= piQxelXor[0] & 0xFF000000; \
+ *(addrp+1) ^= piQxelXor[1] & 0xFFFF; \
+ break; \
+ case 2: \
+ *addrp ^= piQxelXor[1] & 0xFFFF0000; \
+ *(addrp+1) ^= piQxelXor[2] & 0xFF; \
+ break; \
+ }
+#endif
+#if RROP == GXand
+#define body_rop \
+ addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
+ switch((unsigned long)addrb & 3){ \
+ case 0: \
+ *addrp &= piQxelAnd[0] | 0xFF000000; \
+ break; \
+ case 1: \
+ *addrp &= piQxelAnd[2] | 0xFF; \
+ break; \
+ case 3: \
+ *addrp &= 0xFFFFFF | piQxelAnd[0]; \
+ *(addrp+1) &= 0xFFFF0000 | piQxelAnd[1]; \
+ break; \
+ case 2: \
+ *addrp &= 0xFFFF | piQxelAnd[1]; \
+ *(addrp+1) &= 0xFFFFFF00 | piQxelAnd[2]; \
+ break; \
+ }
+#endif
+#if RROP == GXor
+#define body_rop \
+ addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
+ switch((unsigned long)addrb & 3){ \
+ case 0: \
+ *addrp |= piQxelOr[0] & 0xFFFFFF; \
+ break; \
+ case 1: \
+ *addrp |= piQxelOr[2] & 0xFFFFFF00; \
+ break; \
+ case 3: \
+ *addrp |= piQxelOr[0] & 0xFF000000; \
+ *(addrp+1) |= piQxelOr[1] & 0xFFFF; \
+ break; \
+ case 2: \
+ *addrp |= piQxelOr[1] & 0xFFFF0000; \
+ *(addrp+1) |= piQxelOr[2] & 0xFF; \
+ break; \
+ }
+#endif
+#if RROP == GXset
+#define body_rop \
+ addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
+ switch((unsigned long)addrb & 3){ \
+ case 0: \
+ *addrp = (*addrp & (piQxelAnd[0]|0xFF000000)) \
+ ^ (piQxelXor[0] & 0xFFFFFF); \
+ break; \
+ case 1: \
+ *addrp = (*addrp & (piQxelAnd[2]|0xFF)) \
+ ^ (piQxelXor[2] & 0xFFFFFF00); \
+ break; \
+ case 3: \
+ *addrp = (*addrp & (piQxelAnd[0]|0xFFFFFF)) \
+ ^ (piQxelXor[0] & 0xFF000000); \
+ *(addrp+1) = (*(addrp+1) & (piQxelAnd[1]|0xFFFF0000)) \
+ ^ (piQxelXor[1] & 0xFFFF); \
+ break; \
+ case 2: \
+ *addrp = (*addrp & (piQxelAnd[1]|0xFFFF)) \
+ ^ (piQxelXor[1] & 0xFFFF0000); \
+ *(addrp+1) = (*(addrp+1) & (piQxelAnd[2]|0xFFFFFF00)) \
+ ^ (piQxelXor[2] & 0xFF); \
+ break; \
+ }
+#endif
+#endif /* PSZ == 24 */
+
+#define BUGFIX_clip
+
+#ifdef INCLUDE_DRAW
+
+int
+#ifdef POLYSEGMENT
+FUNC_NAME(cfb8SegmentSS1Rect) (pDrawable, pGC, nseg, pSegInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nseg;
+ xSegment *pSegInit;
+#else
+FUNC_NAME(cfb8LineSS1Rect) (pDrawable, pGC, mode, npt, pptInit, pptInitOrig,
+ x1p,y1p,x2p,y2p)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt; /* number of points */
+ DDXPointPtr pptInit, pptInitOrig;
+ int *x1p, *y1p, *x2p, *y2p;
+#endif /* POLYSEGMENT */
+{
+ register long e;
+ register int y1_or_e1;
+ register PixelType *addrp;
+ register int stepmajor;
+ register int stepminor;
+#ifndef REARRANGE
+ register long e3;
+#endif
+#ifdef mc68000
+ register short x1_or_len;
+#else
+ register int x1_or_len;
+#endif
+ RROP_DECLARE
+
+#ifdef SAVE_X2Y2
+# define c2 y2
+#else
+ register int c2;
+#endif
+#if !defined(ORIGIN) && !defined(POLYSEGMENT)
+ register int _x1 = 0, _y1 = 0, _x2 = 0, _y2 = 0;
+ int extents_x1, extents_y1, extents_x2, extents_y2;
+#endif /* !ORIGIN */
+#ifndef PREVIOUS
+ register int upperleft, lowerright;
+ CARD32 ClipMask = 0x80008000;
+#endif /* !PREVIOUS */
+#ifdef POLYSEGMENT
+ register int capStyle;
+#endif /* POLYSEGMENT */
+#ifdef SAVE_X2Y2
+ register int x2, y2;
+# define X1 x1_or_len
+# define Y1 y1_or_e1
+# define X2 x2
+# define Y2 y2
+#else
+# ifdef POLYSEGMENT
+# define X1 x1_or_len
+# define Y1 y1_or_e1
+# else
+# define X1 intToX(y1_or_e1)
+# define Y1 intToY(y1_or_e1)
+# endif /* POLYSEGMENT */
+# define X2 intToX(c2)
+# define Y2 intToY(c2)
+#endif /* SAVE_X2Y2 */
+ PixelType *addr;
+ int nwidth;
+ cfbPrivGCPtr devPriv;
+ BoxPtr extents;
+ int *ppt;
+#if PSZ == 24
+ int xBase; /* x of addr */
+ int xOffset; /* x of addrp */
+ PixelType *addrLineEnd;
+ char *addrb;
+ int stepmajor3, stepminor3, majordx, minordx;
+#endif
+#ifndef POLYSEGMENT
+#ifndef ORIGIN
+#ifdef BUGFIX_clip
+ int ex_x1, ex_y1, ex_x2, ex_y2;
+#endif
+#endif
+#endif
+ int octant;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+
+ devPriv = cfbGetGCPrivate(pGC);
+ cfbGetPixelWidthAndPointer (pDrawable, nwidth, addr);
+#ifndef REARRANGE
+ RROP_FETCH_GCPRIV(devPriv);
+#endif
+ extents = &pGC->pCompositeClip->extents;
+#ifndef PREVIOUS
+ c2 = *((int *) &pDrawable->x);
+ c2 -= (c2 & 0x8000) << 1;
+ upperleft = *((int *) &extents->x1) - c2;
+ lowerright = *((int *) &extents->x2) - c2 - 0x00010001;
+#endif /* !PREVIOUS */
+#ifndef POLYSEGMENT
+#ifndef ORIGIN
+#ifdef BUGFIX_clip
+ ex_x1 = extents->x1 - pDrawable->x;
+ ex_y1 = extents->y1 - pDrawable->y;
+ ex_x2 = extents->x2 - pDrawable->x;
+ ex_y2 = extents->y2 - pDrawable->y;
+#endif
+#endif
+#endif
+#if PSZ == 24
+ xBase = pDrawable->x;
+ addr += WIDTH_MUL(pDrawable->y,nwidth);
+#else
+ addr = addr + WIDTH_MUL(pDrawable->y,nwidth) + pDrawable->x;
+#endif
+#ifdef POLYSEGMENT
+ capStyle = pGC->capStyle - CapNotLast;
+ ppt = (int *) pSegInit;
+ while (nseg--)
+#else /* POLYSEGMENT */
+#ifdef EITHER_MODE
+ mode -= CoordModePrevious;
+ if (!mode)
+#endif /* EITHER_MODE */
+#ifndef ORIGIN
+ { /* CoordModePrevious */
+ ppt = (int *)pptInit + 1;
+ _x1 = *x1p;
+ _y1 = *y1p;
+ extents_x1 = extents->x1 - pDrawable->x;
+ extents_x2 = extents->x2 - pDrawable->x;
+ extents_y1 = extents->y1 - pDrawable->y;
+ extents_y2 = extents->y2 - pDrawable->y;
+ if (_x1 < extents_x1 || _x1 >= extents_x2 ||
+ _y1 < extents_y1 || _y1 >= extents_y2)
+ {
+ c2 = *ppt++;
+ intToCoord(c2, _x2, _y2);
+ *x2p = _x1 + _x2;
+ *y2p = _y1 + _y2;
+ return 1;
+ }
+#if PSZ == 24
+ addrLineEnd = addr + WIDTH_MUL(_y1, nwidth);
+ xOffset = xBase + _x1;
+ addrb = (char *)addrLineEnd + xOffset * 3;
+ addrp = (PixelType *)((unsigned long)addrb & ~0x03);
+#else
+ addrp = addr + WIDTH_MUL(_y1, nwidth) + _x1;
+#endif
+ _x2 = _x1;
+ _y2 = _y1;
+ }
+#endif /* !ORIGIN */
+#ifdef EITHER_MODE
+ else
+#endif /* EITHER_MODE */
+#ifndef PREVIOUS
+ {
+ ppt = (int *) pptInit;
+ c2 = *ppt++;
+ if (isClipped (c2, upperleft, lowerright))
+ {
+ return 1;
+ }
+#ifdef SAVE_X2Y2
+ intToCoord(c2,x2,y2);
+#endif
+#if PSZ == 24
+ addrLineEnd = addr + WIDTH_MUL(Y2, nwidth);
+ xOffset = xBase + X2;
+ addrb = (char *)addrLineEnd + xOffset * 3;
+ addrp = (PixelType *)((unsigned long)addrb & ~0x03);
+#else
+ addrp = addr + WIDTH_MUL(Y2, nwidth) + X2;
+#endif
+ }
+#endif /* !PREVIOUS */
+ while (--npt)
+#endif /* POLYSEGMENT */
+ {
+#ifdef POLYSEGMENT
+ y1_or_e1 = ppt[0];
+ c2 = ppt[1];
+ ppt += 2;
+ if (isClipped(y1_or_e1,upperleft,lowerright)|isClipped(c2,upperleft,lowerright))
+ break;
+ intToCoord(y1_or_e1,x1_or_len,y1_or_e1);
+ /* compute now to avoid needing x1, y1 later */
+#if PSZ == 24
+ addrLineEnd = addr + WIDTH_MUL(y1_or_e1, nwidth);
+ xOffset = xBase + x1_or_len;
+ addrb = (char *)addrLineEnd + xOffset * 3;
+ addrp = (PixelType *)((unsigned long)addrb & ~0x03);
+#else
+ addrp = addr + WIDTH_MUL(y1_or_e1, nwidth) + x1_or_len;
+#endif
+#else /* !POLYSEGMENT */
+#ifdef EITHER_MODE
+ if (!mode)
+#endif /* EITHER_MODE */
+#ifndef ORIGIN
+ {
+ /* CoordModePrevious */
+ _x1 = _x2;
+ _y1 = _y2;
+ c2 = *ppt++;
+ intToCoord(c2, _x2, _y2);
+ _x2 = _x1 + _x2;
+ _y2 = _y1 + _y2;
+
+#ifdef BUGFIX_clip
+ if (_x2 < ex_x1 || _x2 >= ex_x2 ||
+ _y2 < ex_y1 || _y2 >= ex_y2)
+#else
+ if (_x2 < extents_x1 || _x2 >= extents_x2 ||
+ _y2 < extents_y1 || _y2 >= extents_y2)
+#endif
+ {
+ break;
+ }
+ CalcLineDeltas(_x1, _y1, _x2, _y2, x1_or_len, y1_or_e1,
+ stepmajor, stepminor, 1, NWIDTH(nwidth), octant);
+ }
+#endif /* !ORIGIN */
+#ifdef EITHER_MODE
+ else
+#endif /* EITHER_MODE */
+#ifndef PREVIOUS
+ {
+#ifndef SAVE_X2Y2
+ y1_or_e1 = c2;
+#else
+ y1_or_e1 = y2;
+ x1_or_len = x2;
+#endif /* SAVE_X2Y2 */
+ c2 = *ppt++;
+
+ if (isClipped (c2, upperleft, lowerright))
+ break;
+#ifdef SAVE_X2Y2
+ intToCoord(c2,x2,y2);
+#endif
+ CalcLineDeltas(X1, Y1, X2, Y2, x1_or_len, y1_or_e1,
+ stepmajor, stepminor, 1, NWIDTH(nwidth), octant);
+ }
+#endif /* !PREVIOUS */
+#endif /* POLYSEGMENT */
+
+#ifdef POLYSEGMENT
+ CalcLineDeltas(X1, Y1, X2, Y2, x1_or_len, y1_or_e1,
+ stepmajor, stepminor, 1, NWIDTH(nwidth), octant);
+ /*
+ * although the horizontal code works for polyline, it
+ * slows down 10 pixel lines by 15%. Thus, this
+ * code is optimized for horizontal segments and
+ * random orientation lines, which seems like a reasonable
+ * assumption
+ */
+ if (y1_or_e1 != 0)
+ {
+#endif /* POLYSEGMENT */
+ if (x1_or_len < y1_or_e1)
+ {
+#ifdef REARRANGE
+ register int e3;
+#endif
+
+ e3 = x1_or_len;
+ x1_or_len = y1_or_e1;
+ y1_or_e1 = e3;
+
+ e3 = stepminor;
+ stepminor = stepmajor;
+ stepmajor = e3;
+ SetYMajorOctant(octant);
+ }
+
+ e = -x1_or_len;
+#ifdef POLYSEGMENT
+ if (!capStyle)
+ x1_or_len--;
+#endif
+
+ {
+#ifdef REARRANGE
+ register int e3;
+ RROP_DECLARE
+ RROP_FETCH_GCPRIV(devPriv);
+#endif
+
+ y1_or_e1 = y1_or_e1 << 1;
+ e3 = e << 1;
+
+ FIXUP_ERROR(e, octant, bias);
+
+#if PSZ == 24
+ if (stepmajor == 1 || stepmajor == -1){
+ stepmajor3 = stepmajor * 3;
+ stepminor3 = stepminor * sizeof (CfbBits);
+ majordx = stepmajor; minordx = 0;
+ } else {
+ stepmajor3 = stepmajor * sizeof (CfbBits);
+ stepminor3 = stepminor * 3;
+ majordx = 0; minordx = stepminor;
+ }
+#endif
+
+#if PSZ == 24
+#define body {\
+ body_rop \
+ addrb += stepmajor3; \
+ xOffset += majordx; \
+ e += y1_or_e1; \
+ if (e >= 0){ \
+ addrb += stepminor3; \
+ xOffset += minordx; \
+ e += e3; \
+ } \
+ }
+#else /* PSZ == 24 */
+
+#define body {\
+ RROP_SOLID(addrp); \
+ addrp += stepmajor; \
+ e += y1_or_e1; \
+ if (e >= 0) \
+ { \
+ addrp += stepminor; \
+ e += e3; \
+ } \
+ }
+#endif /* PSZ == 24 */
+
+#ifdef LARGE_INSTRUCTION_CACHE
+
+# ifdef SERIOUS_UNROLLING
+# define UNROLL 16
+# else
+# define UNROLL 4
+# endif
+#define CASE(n) case -n: body
+
+ while ((x1_or_len -= UNROLL) >= 0)
+ {
+ body body body body
+# if UNROLL >= 8
+ body body body body
+# endif
+# if UNROLL >= 12
+ body body body body
+# endif
+# if UNROLL >= 16
+ body body body body
+# endif
+ }
+ switch (x1_or_len)
+ {
+ CASE(1) CASE(2) CASE(3)
+# if UNROLL >= 8
+ CASE(4) CASE(5) CASE(6) CASE(7)
+# endif
+# if UNROLL >= 12
+ CASE(8) CASE(9) CASE(10) CASE(11)
+# endif
+# if UNROLL >= 16
+ CASE(12) CASE(13) CASE(14) CASE(15)
+# endif
+ }
+#else /* !LARGE_INSTRUCTION_CACHE */
+
+ IMPORTANT_START
+ IMPORTANT_START
+
+ if (x1_or_len & 1)
+ body
+ x1_or_len >>= 1;
+ while (x1_or_len--) {
+ body body
+ }
+
+ IMPORTANT_END
+ IMPORTANT_END
+#endif /* LARGE_INSTRUCTION_CACHE */
+
+#ifdef POLYSEGMENT
+#if PSZ == 24
+ body_rop
+#else
+ RROP_SOLID(addrp);
+#endif
+#endif
+#if PSZ == 24
+ addrp = (PixelType *)((unsigned long)addrb & ~0x03);
+#endif
+ }
+#undef body
+#ifdef POLYSEGMENT
+ }
+ else /* Polysegment horizontal line optimization */
+ {
+# ifdef REARRANGE
+ register int e3;
+ RROP_DECLARE
+ RROP_FETCH_GCPRIV(devPriv);
+# endif /* REARRANGE */
+ if (stepmajor < 0)
+ {
+#if PSZ == 24
+ xOffset -= x1_or_len;
+ addrp = addrLineEnd + PXL2ADR(xOffset);
+#else
+ addrp -= x1_or_len;
+#endif
+ if (capStyle)
+ x1_or_len++;
+ else
+#if PSZ == 24
+ xOffset++;
+ addrp = addrLineEnd + PXL2ADR(xOffset);
+#else
+ addrp++;
+#endif
+ }
+ else
+ {
+#if PSZ == 24
+ addrp = addrLineEnd + PXL2ADR(xOffset);
+#endif
+ if (capStyle)
+ x1_or_len++;
+ }
+# if PSZ == 24
+ y1_or_e1 = xOffset & 3;
+# else
+# if PGSZ == 64 /* PIM value from <cfbmskbits.h> is not it! (for 16/32 PSZ)*/
+ y1_or_e1 = ((long) addrp) & 0x7;
+ addrp = (PixelType *) (((unsigned char *) addrp) - y1_or_e1);
+# else
+ y1_or_e1 = ((long) addrp) & PIM;
+ addrp = (PixelType *) (((unsigned char *) addrp) - y1_or_e1);
+# endif
+#if PGSZ == 32
+# if PWSH != 2
+ y1_or_e1 >>= (2 - PWSH);
+# endif
+#else /* PGSZ == 64 */
+# if PWSH != 3
+ y1_or_e1 >>= (3 - PWSH);
+# endif
+#endif /* PGSZ */
+# endif /* PSZ == 24 */
+#if PSZ == 24
+ {
+#if RROP == GXcopy
+ register int nlmiddle;
+ int leftIndex = xOffset & 3;
+ int rightIndex = (xOffset + x1_or_len) & 3;
+#else
+ register int pidx;
+#endif
+
+#if RROP == GXcopy
+ nlmiddle = x1_or_len;
+ if(leftIndex){
+ nlmiddle -= (4 - leftIndex);
+ }
+ if(rightIndex){
+ nlmiddle -= rightIndex;
+ }
+
+ nlmiddle >>= 2;
+ switch(leftIndex+x1_or_len){
+ case 4:
+ switch(leftIndex){
+ case 0:
+ *addrp++ = piQxelXor[0];
+ *addrp++ = piQxelXor[1];
+ *addrp = piQxelXor[2];
+ break;
+ case 1:
+ *addrp = ((*addrp) & 0xFFFFFF) | (piQxelXor[0] & 0xFF000000);
+ addrp++;
+ *addrp = piQxelXor[1];
+ addrp++;
+ *addrp = piQxelXor[2];
+ break;
+ case 2:
+ *addrp = ((*addrp) & 0xFFFF) | (piQxelXor[1] & 0xFFFF0000);
+ addrp++;
+ *addrp = piQxelXor[2];
+ break;
+ case 3:
+ *addrp = ((*addrp) & 0xFF) | (piQxelXor[2] & 0xFFFFFF00);
+ break;
+ }
+ break;
+ case 3:
+ switch(leftIndex){
+ case 0:
+ *addrp++ = piQxelXor[0];
+ *addrp++ = piQxelXor[1];
+ *addrp = ((*addrp) & 0xFFFFFF00) | (piQxelXor[2] & 0xFF);
+ break;
+ case 1:
+ *addrp = ((*addrp) & 0xFFFFFF) | (piQxelXor[0] & 0xFF000000);
+ addrp++;
+ *addrp = piQxelXor[1];
+ addrp++;
+ *addrp = ((*addrp) & 0xFFFFFF00) | (piQxelXor[2] & 0xFF);
+ break;
+ case 2:
+ *addrp = ((*addrp) & 0xFFFF) | (piQxelXor[1] & 0xFFFF0000);
+ addrp++;
+ *addrp = ((*addrp) & 0xFFFFFF00) | (piQxelXor[2] & 0xFF);
+ break;
+ }
+ break;
+ case 2:
+ switch(leftIndex){
+/*
+ case 2:
+ *addrp = ((*addrp) & 0xFFFF) | (piQxelXor[1] & 0xFFFF0000);
+ addrp++;
+ *addrp = ((*addrp) & 0xFFFFFF00) | (piQxelXor[2] & 0xFF);
+ break;
+*/
+ case 1:
+ *addrp = ((*addrp) & 0xFFFFFF) | (piQxelXor[0] & 0xFF000000);
+ addrp++;
+ *addrp = ((*addrp) & 0xFFFF0000) | (piQxelXor[1] & 0xFFFF);
+ break;
+ case 0:
+ *addrp++ = piQxelXor[0];
+ *addrp = ((*addrp) & 0xFFFF0000) | (piQxelXor[1] & 0xFFFF);
+ break;
+ }
+ break;
+ case 1: /*only if leftIndex = 0 and w = 1*/
+ if(x1_or_len){
+ *addrp = ((*addrp) & 0xFF000000) | (piQxelXor[0] & 0xFFFFFF);
+ }
+/*
+ else{
+ *addrp = ((*addrp) & 0xFFFFFF) | (piQxelXor[0] & 0xFF000000);
+ addrp++;
+ *addrp = ((*addrp) & 0xFFFF0000) | (piQxelXor[1] & 0xFFFF);
+ }
+*/
+ break;
+ case 0: /*never*/
+ break;
+ default:
+ {
+/*
+ maskbits(y1_or_e1, x1_or_len, e, e3, x1_or_len)
+*/
+ switch(leftIndex){
+ case 0:
+ break;
+ case 1:
+ *addrp = ((*addrp) & 0xFFFFFF) | (piQxelXor[0] & 0xFF000000);
+ addrp++;
+ *addrp = piQxelXor[1];
+ addrp++;
+ *addrp = piQxelXor[2];
+ addrp++;
+ break;
+ case 2:
+ *addrp = ((*addrp) & 0xFFFF) | (piQxelXor[1] & 0xFFFF0000);
+ addrp++;
+ *addrp = piQxelXor[2];
+ addrp++;
+ break;
+ case 3:
+ *addrp = ((*addrp) & 0xFF) | (piQxelXor[2] & 0xFFFFFF00);
+ addrp++;
+ break;
+ }
+ while(nlmiddle--){
+ *addrp++ = piQxelXor[0];
+ *addrp++ = piQxelXor[1];
+ *addrp++ = piQxelXor[2];
+ }
+ switch(rightIndex++){
+ case 0:
+ break;
+ case 1:
+ *addrp = ((*addrp) & 0xFF000000) | (piQxelXor[0] & 0xFFFFFF);
+ break;
+ case 2:
+ *addrp++ = piQxelXor[0];
+ *addrp = ((*addrp) & 0xFFFF0000) | (piQxelXor[1] & 0xFFFF);
+ break;
+ case 3:
+ *addrp++ = piQxelXor[0];
+ *addrp++ = piQxelXor[1];
+ *addrp = ((*addrp) & 0xFFFFFF00) | (piQxelXor[2] & 0xFF);
+ break;
+ }
+/*
+ if (e3){
+ e3 &= 0xFFFFFF;
+ switch(rightIndex&3){
+ case 0:
+ *addrp = ((*addrp) & (0xFF000000 | ~e3))
+ | (piQxelXor[0] & 0xFFFFFF & e3);
+ break;
+ case 1:
+ *addrp = ((*addrp) & (0xFFFFFF | ~(e3<<24)))
+ + (piQxelXor[0] & 0xFF000000 & (e3<<24));
+ addrp++;
+ *addrp = ((*addrp) & (0xFFFF0000|~(e3 >> 8)))
+ | (piQxelXor[1] & 0xFFFF & (e3 >> 8));
+ break;
+ case 2:
+ *addrp = ((*addrp) & (0xFFFF|~(e3 << 16)))
+ | (piQxelXor[1] & 0xFFFF0000 & (e3 << 16));
+ addrp++;
+ *addrp = ((*addrp) & (0xFFFFFF00|~(e3>>16)))
+ | (piQxelXor[2] & 0xFF & (e3 >> 16));
+ break;
+ case 3:
+ *addrp = ((*addrp) & (0xFF|~(e3<<8)))
+ | (piQxelXor[2] & 0xFFFFFF00 & (e3<<8));
+ addrp++;
+ break;
+ }
+ }
+*/
+ }
+ }
+#else /* GXcopy */
+ addrp = (PixelType *)((char *)addrLineEnd + ((xOffset * 3) & ~0x03));
+ if (x1_or_len <= 1){
+ if (x1_or_len)
+ RROP_SOLID24(addrp, xOffset);
+ } else {
+ maskbits(xOffset, x1_or_len, e, e3, x1_or_len);
+ pidx = xOffset & 3;
+ if (e){
+ RROP_SOLID_MASK(addrp, e, pidx-1);
+ addrp++;
+ if (pidx == 3)
+ pidx = 0;
+ }
+ while (--x1_or_len >= 0){
+ RROP_SOLID(addrp, pidx);
+ addrp++;
+ if (++pidx == 3)
+ pidx = 0;
+ }
+ if (e3)
+ RROP_SOLID_MASK(addrp, e3, pidx);
+ }
+#endif /* GXcopy */
+ }
+#else /* PSZ == 24 */
+ if (y1_or_e1 + x1_or_len <= PPW)
+ {
+ if (x1_or_len)
+ {
+ maskpartialbits(y1_or_e1, x1_or_len, e)
+ RROP_SOLID_MASK((CfbBits *) addrp, e);
+ }
+ }
+ else
+ {
+ maskbits(y1_or_e1, x1_or_len, e, e3, x1_or_len)
+ if (e)
+ {
+ RROP_SOLID_MASK((CfbBits *) addrp, e);
+ addrp += PPW;
+ }
+ RROP_SPAN(addrp, x1_or_len)
+ if (e3)
+ RROP_SOLID_MASK((CfbBits *) addrp, e3);
+ }
+#endif /* PSZ == 24 */
+ }
+#endif /* POLYSEGMENT */
+ }
+#ifdef POLYSEGMENT
+ if (nseg >= 0)
+ return (xSegment *) ppt - pSegInit;
+#else
+ if (npt)
+ {
+#ifdef EITHER_MODE
+ if (!mode)
+#endif /* EITHER_MODE */
+#ifndef ORIGIN
+ {
+ *x1p = _x1;
+ *y1p = _y1;
+ *x2p = _x2;
+ *y2p = _y2;
+ }
+#endif /* !ORIGIN */
+ return ((DDXPointPtr) ppt - pptInit) - 1;
+ }
+
+# ifndef ORIGIN
+# define C2 c2
+# else
+# define C2 ppt[-1]
+# endif
+#ifdef EITHER_MODE
+ if (pGC->capStyle != CapNotLast &&
+ ((mode ? (C2 != *((int *) pptInitOrig))
+ : ((_x2 != pptInitOrig->x) ||
+ (_y2 != pptInitOrig->y)))
+ || (ppt == ((int *)pptInitOrig) + 2)))
+#endif /* EITHER_MODE */
+#ifdef PREVIOUS
+ if (pGC->capStyle != CapNotLast &&
+ ((_x2 != pptInitOrig->x) ||
+ (_y2 != pptInitOrig->y) ||
+ (ppt == ((int *)pptInitOrig) + 2)))
+#endif /* PREVIOUS */
+#ifdef ORIGIN
+ if (pGC->capStyle != CapNotLast &&
+ ((C2 != *((int *) pptInitOrig)) ||
+ (ppt == ((int *)pptInitOrig) + 2)))
+#endif /* !PREVIOUS */
+ {
+# ifdef REARRANGE
+ RROP_DECLARE
+
+ RROP_FETCH_GCPRIV(devPriv);
+# endif
+#if PSZ == 24
+#if RROP == GXcopy
+ switch(xOffset & 3){
+ case 0:
+ *addrp = ((*addrp)&0xFF000000)|(piQxelXor[0] & 0xFFFFFF);
+ break;
+ case 3:
+ *addrp = ((*addrp)&0xFF)|(piQxelXor[2] & 0xFFFFFF00);
+ break;
+ case 1:
+ *addrp = ((*addrp)&0xFFFFFF)|(piQxelXor[0] & 0xFF000000);
+ *(addrp+1) = ((*(addrp+1))&0xFFFF0000)|(piQxelXor[1] & 0xFFFF);
+ break;
+ case 2:
+ *addrp = ((*addrp)&0xFFFF)|(piQxelXor[1] & 0xFFFF0000);
+ *(addrp+1) = ((*(addrp+1))&0xFFFFFF00)|(piQxelXor[2] & 0xFF);
+ break;
+ }
+#endif
+#if RROP == GXxor
+ switch(xOffset & 3){
+ case 0:
+ *addrp ^= (piQxelXor[0] & 0xFFFFFF);
+ break;
+ case 3:
+ *addrp ^= (piQxelXor[2] & 0xFFFFFF00);
+ break;
+ case 1:
+ *addrp ^= (piQxelXor[0] & 0xFF000000);
+ *(addrp+1) ^= (piQxelXor[1] & 0xFFFF);
+ break;
+ case 2:
+ *addrp ^= (piQxelXor[1] & 0xFFFF0000);
+ *(addrp+1) ^= (piQxelXor[2] & 0xFF);
+ break;
+ }
+#endif
+#if RROP == GXand
+ switch(xOffset & 3){
+ case 0:
+ *addrp &= (piQxelAnd[0] | 0xFF000000);
+ break;
+ case 3:
+ *addrp &= (piQxelAnd[2] | 0xFF);
+ break;
+ case 1:
+ *addrp &= (0xFFFFFF|piQxelAnd[0]);
+ *(addrp+1) &= (0xFFFF0000|piQxelAnd[1]);
+ break;
+ case 2:
+ *addrp &= (0xFFFF|piQxelAnd[1]);
+ *(addrp+1) &= (0xFFFFFF00|piQxelAnd[2]);
+ break;
+ }
+#endif
+#if RROP == GXor
+ switch(xOffset & 3){
+ case 0:
+ *addrp |= (piQxelOr[0] & 0xFFFFFF);
+ break;
+ case 3:
+ *addrp |= (piQxelOr[2] & 0xFFFFFF00);
+ break;
+ case 1:
+ *addrp |= (piQxelOr[0] & 0xFF000000);
+ *(addrp+1) |= (piQxelOr[1] & 0xFFFF);
+ break;
+ case 2:
+ *addrp |= (piQxelOr[1] & 0xFFFF0000);
+ *(addrp+1) |= (piQxelOr[2] & 0xFF);
+ break;
+ }
+#endif
+#if RROP == GXset
+ switch(xOffset & 3){
+ case 0:
+ *addrp = (((*addrp)&(piQxelAnd[0] |0xFF000000))^(piQxelXor[0] & 0xFFFFFF));
+ break;
+ case 3:
+ *addrp = (((*addrp)&(piQxelAnd[2]|0xFF))^(piQxelXor[2] & 0xFFFFFF00));
+ break;
+ case 1:
+ *addrp = (((*addrp)&(piQxelAnd[0]|0xFFFFFF))^(piQxelXor[0] & 0xFF000000));
+ *(addrp+1) = (((*(addrp+1))&(piQxelAnd[1]|0xFFFF0000))^(piQxelXor[1] & 0xFFFF));
+ break;
+ case 2:
+ *addrp = (((*addrp)&(piQxelAnd[1]|0xFFFF))^(piQxelXor[1] & 0xFFFF0000));
+ *(addrp+1) = (((*(addrp+1))&(piQxelAnd[2]|0xFFFFFF00))^(piQxelXor[2] & 0xFF));
+ break;
+ }
+#endif
+#else
+ RROP_SOLID (addrp);
+# endif
+ }
+#endif /* !POLYSEGMENT */
+ RROP_UNDECLARE;
+ return -1;
+}
+
+#endif /* INCLUDE_DRAW */
+
+
+#ifdef INCLUDE_OTHERS
+
+#ifdef POLYSEGMENT
+
+void
+cfb8SegmentSS1Rect (pDrawable, pGC, nseg, pSegInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nseg;
+ xSegment *pSegInit;
+{
+ int (*func)(DrawablePtr, GCPtr, int, xSegment *);
+ void (*clip)(DrawablePtr, GCPtr, int, int, int, int, BoxPtr, Bool);
+ int drawn;
+ cfbPrivGCPtr devPriv;
+
+#if defined(__arm32__) && PSZ != 8
+ /* XXX -JJK */
+ /* There is a painting bug when PSZ != 8; I need to track it down! */
+ cfbSegmentSS(pDrawable, pGC, nseg, pSegInit);
+ return;
+#endif
+
+ devPriv = cfbGetGCPrivate(pGC);
+#ifdef NO_ONE_RECT
+ if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1)
+ {
+ cfbSegmentSS(pDrawable, pGC, nseg, pSegInit);
+ return;
+ }
+#endif
+ switch (devPriv->rop)
+ {
+ case GXcopy:
+ func = cfb8SegmentSS1RectCopy;
+ clip = cfb8ClippedLineCopy;
+#ifdef FAST_MUL
+ if (cfbGetPixelWidth (pDrawable) == WIDTH_FAST)
+ func = cfb8SegmentSS1RectShiftCopy;
+#endif
+ break;
+ case GXxor:
+ func = cfb8SegmentSS1RectXor;
+ clip = cfb8ClippedLineXor;
+ break;
+ default:
+ func = cfb8SegmentSS1RectGeneral;
+ clip = cfb8ClippedLineGeneral;
+ break;
+ }
+ while (nseg)
+ {
+ drawn = (*func) (pDrawable, pGC, nseg, pSegInit);
+ if (drawn == -1)
+ break;
+ (*clip) (pDrawable, pGC,
+ pSegInit[drawn-1].x1, pSegInit[drawn-1].y1,
+ pSegInit[drawn-1].x2, pSegInit[drawn-1].y2,
+ &pGC->pCompositeClip->extents,
+ pGC->capStyle == CapNotLast);
+ pSegInit += drawn;
+ nseg -= drawn;
+ }
+}
+
+#else /* POLYSEGMENT */
+
+void
+cfb8LineSS1Rect (pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode;
+ int npt;
+ DDXPointPtr pptInit;
+{
+ int (*func)(DrawablePtr, GCPtr, int, int,
+ DDXPointPtr, DDXPointPtr,
+ int *, int *, int *, int *);
+ void (*clip)(DrawablePtr, GCPtr, int, int, int, int, BoxPtr, Bool);
+ int drawn;
+ cfbPrivGCPtr devPriv;
+ int x1, y1, x2, y2;
+ DDXPointPtr pptInitOrig = pptInit;
+
+#if defined(__arm32__) && PSZ != 8
+ /* XXX -JJK */
+ /* There is a painting bug when PSZ != 8; I need to track it down! */
+ cfbLineSS(pDrawable, pGC, mode, npt, pptInit);
+ return;
+#endif
+
+ devPriv = cfbGetGCPrivate(pGC);
+#ifdef NO_ONE_RECT
+ if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1)
+ {
+ cfbLineSS(pDrawable, pGC, mode, npt, pptInit);
+ return;
+ }
+#endif
+ switch (devPriv->rop)
+ {
+ case GXcopy:
+ func = cfb8LineSS1RectCopy;
+ clip = cfb8ClippedLineCopy;
+ if (mode == CoordModePrevious)
+ func = cfb8LineSS1RectPreviousCopy;
+ break;
+ case GXxor:
+ func = cfb8LineSS1RectXor;
+ clip = cfb8ClippedLineXor;
+ break;
+ default:
+ func = cfb8LineSS1RectGeneral;
+ clip = cfb8ClippedLineGeneral;
+ break;
+ }
+ if (mode == CoordModePrevious)
+ {
+ x1 = pptInit->x;
+ y1 = pptInit->y;
+ while (npt > 1)
+ {
+ drawn = (*func) (pDrawable, pGC, mode, npt, pptInit, pptInitOrig,
+ &x1, &y1, &x2, &y2);
+ if (drawn == -1)
+ break;
+ (*clip) (pDrawable, pGC, x1, y1, x2, y2,
+ &pGC->pCompositeClip->extents,
+ drawn != npt - 1 || pGC->capStyle == CapNotLast);
+ pptInit += drawn;
+ npt -= drawn;
+ x1 = x2;
+ y1 = y2;
+ }
+ }
+ else
+ {
+ while (npt > 1)
+ {
+ drawn = (*func) (pDrawable, pGC, mode, npt, pptInit, pptInitOrig,
+ &x1, &y1, &x2, &y2);
+ if (drawn == -1)
+ break;
+ (*clip) (pDrawable, pGC,
+ pptInit[drawn-1].x, pptInit[drawn-1].y,
+ pptInit[drawn].x, pptInit[drawn].y,
+ &pGC->pCompositeClip->extents,
+ drawn != npt - 1 || pGC->capStyle == CapNotLast);
+ pptInit += drawn;
+ npt -= drawn;
+ }
+ }
+}
+
+#endif /* else POLYSEGMENT */
+#endif /* INCLUDE_OTHERS */
+
+#if !defined(POLYSEGMENT) && !defined (PREVIOUS)
+
+void
+RROP_NAME (cfb8ClippedLine) (pDrawable, pGC, x1, y1, x2, y2, boxp, shorten)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int x1, y1, x2, y2;
+ BoxPtr boxp;
+ Bool shorten;
+{
+ int oc1, oc2;
+ int e, e1, e3, len;
+ int adx, ady;
+
+ PixelType *addr;
+ int nwidth;
+ int stepx, stepy;
+ int xorg, yorg;
+ int new_x1, new_y1, new_x2, new_y2;
+ Bool pt1_clipped, pt2_clipped;
+ int changex, changey, result;
+#if PSZ == 24
+ PixelType *addrLineEnd;
+ char *addrb;
+ int stepx3, stepy3;
+#endif
+ int octant;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+
+ cfbGetPixelWidthAndPointer(pDrawable, nwidth, addr);
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ x1 += xorg;
+ y1 += yorg;
+ x2 += xorg;
+ y2 += yorg;
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES (oc1, x1, y1, boxp);
+ OUTCODES (oc2, x2, y2, boxp);
+
+ if (oc1 & oc2)
+ return;
+
+ CalcLineDeltas(x1, y1, x2, y2, adx, ady, stepx, stepy, 1, nwidth, octant);
+
+ if (adx <= ady)
+ {
+ int t;
+
+ t = adx;
+ adx = ady;
+ ady = t;
+
+ t = stepx;
+ stepx = stepy;
+ stepy = t;
+
+ SetYMajorOctant(octant);
+ }
+ e = - adx;
+ e1 = ady << 1;
+ e3 = - (adx << 1);
+
+ FIXUP_ERROR(e, octant, bias);
+
+ new_x1 = x1;
+ new_y1 = y1;
+ new_x2 = x2;
+ new_y2 = y2;
+ pt1_clipped = 0;
+ pt2_clipped = 0;
+
+ if (IsXMajorOctant(octant))
+ {
+ result = miZeroClipLine(boxp->x1, boxp->y1, boxp->x2 - 1, boxp->y2 - 1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady,
+ &pt1_clipped, &pt2_clipped,
+ octant, bias, oc1, oc2);
+ if (result == -1)
+ return;
+
+ len = abs(new_x2 - new_x1) - 1; /* this routine needs the "-1" */
+
+ /* if we've clipped the endpoint, always draw the full length
+ * of the segment, because then the capstyle doesn't matter
+ * if x2,y2 isn't clipped, use the capstyle
+ * (shorten == TRUE <--> CapNotLast)
+ */
+ if (pt2_clipped || !shorten)
+ len++;
+
+ if (pt1_clipped)
+ {
+ /* must calculate new error terms */
+ changex = abs(new_x1 - x1);
+ changey = abs(new_y1 - y1);
+ e = e + changey * e3 + changex * e1;
+ }
+ }
+ else /* Y_AXIS */
+ {
+ result = miZeroClipLine(boxp->x1, boxp->y1, boxp->x2 - 1, boxp->y2 - 1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ ady, adx,
+ &pt1_clipped, &pt2_clipped,
+ octant, bias, oc1, oc2);
+ if (result == -1)
+ return;
+
+ len = abs(new_y2 - new_y1) - 1; /* this routine needs the "-1" */
+
+ /* if we've clipped the endpoint, always draw the full length
+ * of the segment, because then the capstyle doesn't matter
+ * if x2,y2 isn't clipped, use the capstyle
+ * (shorten == TRUE <--> CapNotLast)
+ */
+ if (pt2_clipped || !shorten)
+ len++;
+
+ if (pt1_clipped)
+ {
+ /* must calculate new error terms */
+ changex = abs(new_x1 - x1);
+ changey = abs(new_y1 - y1);
+ e = e + changex * e3 + changey * e1;
+ }
+ }
+ x1 = new_x1;
+ y1 = new_y1;
+ {
+ register PixelType *addrp;
+ RROP_DECLARE
+
+ RROP_FETCH_GC(pGC);
+
+#if PSZ == 24
+ addrLineEnd = addr + (y1 * nwidth);
+ addrb = (char *)addrLineEnd + x1 * 3;
+ if (stepx == 1 || stepx == -1){
+ stepx3 = stepx * 3;
+ stepy3 = stepy * sizeof (CfbBits);
+ } else {
+ stepx3 = stepx * sizeof (CfbBits);
+ stepy3 = stepy * 3;
+ }
+#else
+ addrp = addr + (y1 * nwidth) + x1;
+#endif
+
+#ifndef REARRANGE
+ if (!ady)
+ {
+#if PSZ == 24
+#define body {\
+ body_rop \
+ addrb += stepx3; \
+ }
+#else
+#define body { RROP_SOLID(addrp); addrp += stepx; }
+#endif
+ while (len >= PGSZB)
+ {
+ body body body body
+#if PGSZ == 64
+ body body body body
+#endif
+ len -= PGSZB;
+ }
+ switch (len)
+ {
+#if PGSZ == 64
+ case 7: body case 6: body case 5: body case 4: body
+#endif
+ case 3: body case 2: body case 1: body
+ }
+#undef body
+ }
+ else
+#endif /* !REARRANGE */
+ {
+#if PSZ == 24
+#define body {\
+ body_rop \
+ addrb += stepx3; \
+ e += e1; \
+ if (e >= 0) \
+ { \
+ addrb += stepy3; \
+ e += e3; \
+ } \
+ }
+#else
+#define body {\
+ RROP_SOLID(addrp); \
+ addrp += stepx; \
+ e += e1; \
+ if (e >= 0) \
+ { \
+ addrp += stepy; \
+ e += e3; \
+ } \
+ }
+#endif
+
+#ifdef LARGE_INSTRUCTION_CACHE
+ while ((len -= PGSZB) >= 0)
+ {
+ body body body body
+#if PGSZ == 64
+ body body body body
+#endif
+ }
+ switch (len)
+ {
+ case -1: body case -2: body case -3: body
+#if PGSZ == 64
+ case -4: body case -5: body case -6: body case -7: body
+#endif
+ }
+#else /* !LARGE_INSTRUCTION_CACHE */
+ IMPORTANT_START;
+
+ while ((len -= 2) >= 0)
+ {
+ body body;
+ }
+ if (len & 1)
+ body;
+
+ IMPORTANT_END;
+#endif /* LARGE_INSTRUCTION_CACHE */
+ }
+#if PSZ == 24
+ body_rop
+#else
+ RROP_SOLID(addrp);
+#endif
+#undef body
+ RROP_UNDECLARE
+ }
+}
+
+#endif /* !POLYSEGMENT && !PREVIOUS */
+#endif /* PIXEL_ADDR */
diff --git a/nx-X11/programs/Xserver/cfb/cfballpriv.c b/nx-X11/programs/Xserver/cfb/cfballpriv.c
new file mode 100644
index 000000000..68edb281b
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfballpriv.c
@@ -0,0 +1,94 @@
+/*
+ * $Xorg: cfballpriv.c,v 1.4 2001/02/09 02:04:37 xorgcvs Exp $
+ *
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/programs/Xserver/cfb/cfballpriv.c,v 1.11 2001/01/30 22:06:15 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "resource.h"
+#include "colormap.h"
+#include "colormapst.h"
+#include "cfb.h"
+#include "mi.h"
+#include "mistruct.h"
+#include "dix.h"
+#include "cfbmskbits.h"
+#include "mibstore.h"
+
+#if 1 || PSZ==8
+int cfbWindowPrivateIndex = -1;
+int cfbGCPrivateIndex = -1;
+#endif
+#ifdef CFB_NEED_SCREEN_PRIVATE
+int cfbScreenPrivateIndex = -1;
+static unsigned long cfbGeneration = 0;
+#endif
+
+
+Bool
+cfbAllocatePrivates(pScreen, window_index, gc_index)
+ ScreenPtr pScreen;
+ int *window_index, *gc_index;
+{
+ if (!window_index || !gc_index ||
+ (*window_index == -1 && *gc_index == -1))
+ {
+ if (!mfbAllocatePrivates(pScreen,
+ &cfbWindowPrivateIndex, &cfbGCPrivateIndex))
+ return FALSE;
+ if (window_index)
+ *window_index = cfbWindowPrivateIndex;
+ if (gc_index)
+ *gc_index = cfbGCPrivateIndex;
+ }
+ else
+ {
+ cfbWindowPrivateIndex = *window_index;
+ cfbGCPrivateIndex = *gc_index;
+ }
+ if (!AllocateWindowPrivate(pScreen, cfbWindowPrivateIndex,
+ sizeof(cfbPrivWin)) ||
+ !AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC)))
+ return FALSE;
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ if (cfbGeneration != serverGeneration)
+ {
+ cfbScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ cfbGeneration = serverGeneration;
+ }
+ if (cfbScreenPrivateIndex == -1)
+ return FALSE;
+#endif
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbbitblt.c b/nx-X11/programs/Xserver/cfb/cfbbitblt.c
new file mode 100644
index 000000000..a9dd438fe
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbbitblt.c
@@ -0,0 +1,1454 @@
+/*
+ * cfb copy area
+ */
+
+/* $XFree86: xc/programs/Xserver/cfb/cfbbitblt.c,v 1.19tsi Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Author: Keith Packard
+
+*/
+/* $Xorg: cfbbitblt.c,v 1.4 2001/02/09 02:04:37 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mi.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "cfb8bit.h"
+#include "fastblt.h"
+#define MFB_CONSTS_ONLY
+#include "maskbits.h"
+
+#if PSZ == 8
+#define cfbCopyPlane1toN cfbCopyPlane1to8
+#define cfbCopyPlaneNto1 cfbCopyPlane8to1
+#else
+static unsigned int FgPixel, BgPixel;
+# if PSZ == 16
+#define cfbCopyPlane1toN cfbCopyPlane1to16
+#define cfbCopyPlaneNto1 cfbCopyPlane16to1
+# endif
+# if PSZ == 24
+#define cfbCopyPlane1toN cfbCopyPlane1to24
+#define cfbCopyPlaneNto1 cfbCopyPlane24to1
+# endif
+# if PSZ == 32
+#define cfbCopyPlane1toN cfbCopyPlane1to32
+#define cfbCopyPlaneNto1 cfbCopyPlane32to1
+# endif
+#endif
+
+/* cfbBitBltcfb == cfbCopyPlaneExpand */
+RegionPtr
+cfbBitBlt (
+ register DrawablePtr pSrcDrawable,
+ register DrawablePtr pDstDrawable,
+ GC *pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty,
+ void (*doBitBlt)(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/),
+ unsigned long bitPlane)
+{
+ RegionPtr prgnSrcClip = NULL; /* may be a new region, or just a copy */
+ Bool freeSrcClip = FALSE;
+
+ RegionPtr prgnExposed;
+ RegionRec rgnDst;
+ DDXPointPtr pptSrc;
+ register DDXPointPtr ppt;
+ register BoxPtr pbox;
+ int i;
+ register int dx;
+ register int dy;
+ xRectangle origSource;
+ DDXPointRec origDest;
+ int numRects;
+ BoxRec fastBox;
+ int fastClip = 0; /* for fast clipping with pixmap source */
+ int fastExpose = 0; /* for fast exposures with pixmap source */
+
+ origSource.x = srcx;
+ origSource.y = srcy;
+ origSource.width = width;
+ origSource.height = height;
+ origDest.x = dstx;
+ origDest.y = dsty;
+
+ if ((pSrcDrawable != pDstDrawable) &&
+ pSrcDrawable->pScreen->SourceValidate)
+ {
+ (*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, srcx, srcy, width, height);
+ }
+
+ srcx += pSrcDrawable->x;
+ srcy += pSrcDrawable->y;
+
+ /* clip the source */
+
+ if (pSrcDrawable->type == DRAWABLE_PIXMAP)
+ {
+ if ((pSrcDrawable == pDstDrawable) &&
+ (pGC->clientClipType == CT_NONE))
+ {
+ prgnSrcClip = cfbGetCompositeClip(pGC);
+ }
+ else
+ {
+ fastClip = 1;
+ }
+ }
+ else
+ {
+ if (pGC->subWindowMode == IncludeInferiors)
+ {
+ /*
+ * XFree86 DDX empties the border clip when the
+ * VT is inactive
+ */
+ if (!((WindowPtr) pSrcDrawable)->parent &&
+ REGION_NOTEMPTY (pSrcDrawable->pScreen,
+ &((WindowPtr) pSrcDrawable)->borderClip))
+ {
+ /*
+ * special case bitblt from root window in
+ * IncludeInferiors mode; just like from a pixmap
+ */
+ fastClip = 1;
+ }
+ else if ((pSrcDrawable == pDstDrawable) &&
+ (pGC->clientClipType == CT_NONE))
+ {
+ prgnSrcClip = cfbGetCompositeClip(pGC);
+ }
+ else
+ {
+ prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable);
+ freeSrcClip = TRUE;
+ }
+ }
+ else
+ {
+ prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList;
+ }
+ }
+
+ fastBox.x1 = srcx;
+ fastBox.y1 = srcy;
+ fastBox.x2 = srcx + width;
+ fastBox.y2 = srcy + height;
+
+ /* Don't create a source region if we are doing a fast clip */
+ if (fastClip)
+ {
+ fastExpose = 1;
+ /*
+ * clip the source; if regions extend beyond the source size,
+ * make sure exposure events get sent
+ */
+ if (fastBox.x1 < pSrcDrawable->x)
+ {
+ fastBox.x1 = pSrcDrawable->x;
+ fastExpose = 0;
+ }
+ if (fastBox.y1 < pSrcDrawable->y)
+ {
+ fastBox.y1 = pSrcDrawable->y;
+ fastExpose = 0;
+ }
+ if (fastBox.x2 > pSrcDrawable->x + (int) pSrcDrawable->width)
+ {
+ fastBox.x2 = pSrcDrawable->x + (int) pSrcDrawable->width;
+ fastExpose = 0;
+ }
+ if (fastBox.y2 > pSrcDrawable->y + (int) pSrcDrawable->height)
+ {
+ fastBox.y2 = pSrcDrawable->y + (int) pSrcDrawable->height;
+ fastExpose = 0;
+ }
+ }
+ else
+ {
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip);
+ }
+
+ dstx += pDstDrawable->x;
+ dsty += pDstDrawable->y;
+
+ if (pDstDrawable->type == DRAWABLE_WINDOW)
+ {
+ if (!((WindowPtr)pDstDrawable)->realized)
+ {
+ if (!fastClip)
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return NULL;
+ }
+ }
+
+ dx = srcx - dstx;
+ dy = srcy - dsty;
+
+ /* Translate and clip the dst to the destination composite clip */
+ if (fastClip)
+ {
+ RegionPtr cclip;
+
+ /* Translate the region directly */
+ fastBox.x1 -= dx;
+ fastBox.x2 -= dx;
+ fastBox.y1 -= dy;
+ fastBox.y2 -= dy;
+
+ /* If the destination composite clip is one rectangle we can
+ do the clip directly. Otherwise we have to create a full
+ blown region and call intersect */
+
+ /* XXX because CopyPlane uses this routine for 8-to-1 bit
+ * copies, this next line *must* also correctly fetch the
+ * composite clip from an mfb gc
+ */
+
+ cclip = cfbGetCompositeClip(pGC);
+ if (REGION_NUM_RECTS(cclip) == 1)
+ {
+ BoxPtr pBox = REGION_RECTS(cclip);
+
+ if (fastBox.x1 < pBox->x1) fastBox.x1 = pBox->x1;
+ if (fastBox.x2 > pBox->x2) fastBox.x2 = pBox->x2;
+ if (fastBox.y1 < pBox->y1) fastBox.y1 = pBox->y1;
+ if (fastBox.y2 > pBox->y2) fastBox.y2 = pBox->y2;
+
+ /* Check to see if the region is empty */
+ if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2)
+ {
+ REGION_NULL(pGC->pScreen, &rgnDst);
+ }
+ else
+ {
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ }
+ }
+ else
+ {
+ /* We must turn off fastClip now, since we must create
+ a full blown region. It is intersected with the
+ composite clip below. */
+ fastClip = 0;
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox,1);
+ }
+ }
+ else
+ {
+ REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy);
+ }
+
+ if (!fastClip)
+ {
+ REGION_INTERSECT(pGC->pScreen, &rgnDst,
+ &rgnDst,
+ cfbGetCompositeClip(pGC));
+ }
+
+ /* Do bit blitting */
+ numRects = REGION_NUM_RECTS(&rgnDst);
+ if (numRects && width && height)
+ {
+ if(!(pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(numRects *
+ sizeof(DDXPointRec))))
+ {
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return NULL;
+ }
+ pbox = REGION_RECTS(&rgnDst);
+ ppt = pptSrc;
+ for (i = numRects; --i >= 0; pbox++, ppt++)
+ {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ (*doBitBlt) (pSrcDrawable, pDstDrawable, pGC->alu, &rgnDst, pptSrc, pGC->planemask);
+ DEALLOCATE_LOCAL(pptSrc);
+ }
+
+ prgnExposed = NULL;
+ if (pGC->fExpose)
+ {
+ /* Pixmap sources generate a NoExposed (we return NULL to do this) */
+ if (!fastExpose)
+ prgnExposed =
+ miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
+ origSource.x, origSource.y,
+ (int)origSource.width,
+ (int)origSource.height,
+ origDest.x, origDest.y, bitPlane);
+ }
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return prgnExposed;
+}
+
+
+RegionPtr
+cfbCopyPlaneReduce (
+ register DrawablePtr pSrcDrawable,
+ register DrawablePtr pDstDrawable,
+ GC *pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty,
+ void (*doCopyPlane)(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/,
+ unsigned long /*bitPlane*/),
+ unsigned long bitPlane)
+{
+ RegionPtr prgnSrcClip = NULL; /* may be a new region, or just a copy */
+ Bool freeSrcClip = FALSE;
+
+ RegionPtr prgnExposed;
+ RegionRec rgnDst;
+ DDXPointPtr pptSrc;
+ register DDXPointPtr ppt;
+ register BoxPtr pbox;
+ int i;
+ register int dx;
+ register int dy;
+ xRectangle origSource;
+ DDXPointRec origDest;
+ int numRects;
+ BoxRec fastBox;
+ int fastClip = 0; /* for fast clipping with pixmap source */
+ int fastExpose = 0; /* for fast exposures with pixmap source */
+
+ origSource.x = srcx;
+ origSource.y = srcy;
+ origSource.width = width;
+ origSource.height = height;
+ origDest.x = dstx;
+ origDest.y = dsty;
+
+ if ((pSrcDrawable != pDstDrawable) &&
+ pSrcDrawable->pScreen->SourceValidate)
+ {
+ (*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, srcx, srcy, width, height);
+ }
+
+ srcx += pSrcDrawable->x;
+ srcy += pSrcDrawable->y;
+
+ /* clip the source */
+
+ if (pSrcDrawable->type == DRAWABLE_PIXMAP)
+ {
+ if ((pSrcDrawable == pDstDrawable) &&
+ (pGC->clientClipType == CT_NONE))
+ {
+ prgnSrcClip = cfbGetCompositeClip(pGC);
+ }
+ else
+ {
+ fastClip = 1;
+ }
+ }
+ else
+ {
+ if (pGC->subWindowMode == IncludeInferiors)
+ {
+ /*
+ * XFree86 DDX empties the border clip when the
+ * VT is inactive
+ */
+ if (!((WindowPtr) pSrcDrawable)->parent &&
+ REGION_NOTEMPTY (pSrcDrawable->pScreen,
+ &((WindowPtr) pSrcDrawable)->borderClip))
+ {
+ /*
+ * special case bitblt from root window in
+ * IncludeInferiors mode; just like from a pixmap
+ */
+ fastClip = 1;
+ }
+ else if ((pSrcDrawable == pDstDrawable) &&
+ (pGC->clientClipType == CT_NONE))
+ {
+ prgnSrcClip = cfbGetCompositeClip(pGC);
+ }
+ else
+ {
+ prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable);
+ freeSrcClip = TRUE;
+ }
+ }
+ else
+ {
+ prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList;
+ }
+ }
+
+ fastBox.x1 = srcx;
+ fastBox.y1 = srcy;
+ fastBox.x2 = srcx + width;
+ fastBox.y2 = srcy + height;
+
+ /* Don't create a source region if we are doing a fast clip */
+ if (fastClip)
+ {
+ fastExpose = 1;
+ /*
+ * clip the source; if regions extend beyond the source size,
+ * make sure exposure events get sent
+ */
+ if (fastBox.x1 < pSrcDrawable->x)
+ {
+ fastBox.x1 = pSrcDrawable->x;
+ fastExpose = 0;
+ }
+ if (fastBox.y1 < pSrcDrawable->y)
+ {
+ fastBox.y1 = pSrcDrawable->y;
+ fastExpose = 0;
+ }
+ if (fastBox.x2 > pSrcDrawable->x + (int) pSrcDrawable->width)
+ {
+ fastBox.x2 = pSrcDrawable->x + (int) pSrcDrawable->width;
+ fastExpose = 0;
+ }
+ if (fastBox.y2 > pSrcDrawable->y + (int) pSrcDrawable->height)
+ {
+ fastBox.y2 = pSrcDrawable->y + (int) pSrcDrawable->height;
+ fastExpose = 0;
+ }
+ }
+ else
+ {
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip);
+ }
+
+ dstx += pDstDrawable->x;
+ dsty += pDstDrawable->y;
+
+ if (pDstDrawable->type == DRAWABLE_WINDOW)
+ {
+ if (!((WindowPtr)pDstDrawable)->realized)
+ {
+ if (!fastClip)
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return NULL;
+ }
+ }
+
+ dx = srcx - dstx;
+ dy = srcy - dsty;
+
+ /* Translate and clip the dst to the destination composite clip */
+ if (fastClip)
+ {
+ RegionPtr cclip;
+
+ /* Translate the region directly */
+ fastBox.x1 -= dx;
+ fastBox.x2 -= dx;
+ fastBox.y1 -= dy;
+ fastBox.y2 -= dy;
+
+ /* If the destination composite clip is one rectangle we can
+ do the clip directly. Otherwise we have to create a full
+ blown region and call intersect */
+
+ /* XXX because CopyPlane uses this routine for 8-to-1 bit
+ * copies, this next line *must* also correctly fetch the
+ * composite clip from an mfb gc
+ */
+
+ cclip = cfbGetCompositeClip(pGC);
+ if (REGION_NUM_RECTS(cclip) == 1)
+ {
+ BoxPtr pBox = REGION_RECTS(cclip);
+
+ if (fastBox.x1 < pBox->x1) fastBox.x1 = pBox->x1;
+ if (fastBox.x2 > pBox->x2) fastBox.x2 = pBox->x2;
+ if (fastBox.y1 < pBox->y1) fastBox.y1 = pBox->y1;
+ if (fastBox.y2 > pBox->y2) fastBox.y2 = pBox->y2;
+
+ /* Check to see if the region is empty */
+ if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2)
+ {
+ REGION_NULL(pGC->pScreen, &rgnDst);
+ }
+ else
+ {
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ }
+ }
+ else
+ {
+ /* We must turn off fastClip now, since we must create
+ a full blown region. It is intersected with the
+ composite clip below. */
+ fastClip = 0;
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ }
+ }
+ else
+ {
+ REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy);
+ }
+
+ if (!fastClip)
+ {
+ REGION_INTERSECT(pGC->pScreen, &rgnDst,
+ &rgnDst,
+ cfbGetCompositeClip(pGC));
+ }
+
+ /* Do bit blitting */
+ numRects = REGION_NUM_RECTS(&rgnDst);
+ if (numRects && width && height)
+ {
+ if(!(pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(numRects *
+ sizeof(DDXPointRec))))
+ {
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return NULL;
+ }
+ pbox = REGION_RECTS(&rgnDst);
+ ppt = pptSrc;
+ for (i = numRects; --i >= 0; pbox++, ppt++)
+ {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ (*doCopyPlane) (pSrcDrawable, pDstDrawable, pGC->alu, &rgnDst, pptSrc, pGC->planemask, bitPlane);
+ DEALLOCATE_LOCAL(pptSrc);
+ }
+
+ prgnExposed = NULL;
+ if (pGC->fExpose)
+ {
+ /* Pixmap sources generate a NoExposed (we return NULL to do this) */
+ if (!fastExpose)
+ prgnExposed =
+ miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
+ origSource.x, origSource.y,
+ (int)origSource.width,
+ (int)origSource.height,
+ origDest.x, origDest.y, bitPlane);
+ }
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return prgnExposed;
+}
+
+
+void
+cfbDoBitblt (pSrc, pDst, alu, prgnDst, pptSrc, planemask)
+ DrawablePtr pSrc, pDst;
+ int alu;
+ RegionPtr prgnDst;
+ DDXPointPtr pptSrc;
+ unsigned long planemask;
+{
+ void (*doBitBlt)(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/)
+ = cfbDoBitbltGeneral;
+
+ if ((planemask & PMSK) == PMSK) {
+ switch (alu) {
+ case GXcopy:
+ doBitBlt = cfbDoBitbltCopy;
+ break;
+ case GXxor:
+ doBitBlt = cfbDoBitbltXor;
+ break;
+ case GXor:
+ doBitBlt = cfbDoBitbltOr;
+ break;
+ }
+ }
+ (*doBitBlt) (pSrc, pDst, alu, prgnDst, pptSrc, planemask);
+}
+
+RegionPtr
+cfbCopyArea(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty)
+ register DrawablePtr pSrcDrawable;
+ register DrawablePtr pDstDrawable;
+ GC *pGC;
+ int srcx, srcy;
+ int width, height;
+ int dstx, dsty;
+{
+ void (*doBitBlt) (
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/);
+
+ doBitBlt = cfbDoBitbltCopy;
+ if (pGC->alu != GXcopy || (pGC->planemask & PMSK) != PMSK)
+ {
+ doBitBlt = cfbDoBitbltGeneral;
+ if ((pGC->planemask & PMSK) == PMSK)
+ {
+ switch (pGC->alu) {
+ case GXxor:
+ doBitBlt = cfbDoBitbltXor;
+ break;
+ case GXor:
+ doBitBlt = cfbDoBitbltOr;
+ break;
+ }
+ }
+ }
+ return cfbBitBlt (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, doBitBlt, 0L);
+}
+
+#if PSZ == 8
+void
+cfbCopyPlane1to8 (pSrcDrawable, pDstDrawable, rop, prgnDst, pptSrc, planemask)
+ DrawablePtr pSrcDrawable; /* must be a bitmap */
+ DrawablePtr pDstDrawable; /* must be depth 8 drawable */
+ int rop; /* not used; caller must call cfb8CheckOpaqueStipple
+ * beforehand to get cfb8StippleRRop set correctly */
+ RegionPtr prgnDst; /* region in destination to draw to;
+ * screen relative coords. if dest is a window;
+ * drawable relative if dest is a pixmap */
+ DDXPointPtr pptSrc; /* drawable relative src coords to copy from;
+ * must be one point for each box in prgnDst */
+ unsigned long planemask; /* to apply to destination writes */
+{
+ int srcx, srcy; /* upper left corner of box being copied in source */
+ int dstx, dsty; /* upper left corner of box being copied in dest */
+ int width, height; /* in pixels, unpadded, of box being copied */
+ int xoffSrc; /* bit # in leftmost word of row from which copying starts */
+ int xoffDst; /* byte # in leftmost word of row from which copying starts */
+ CfbBits *psrcBase, *pdstBase; /* start of drawable's pixel data */
+ int widthSrc; /* # of groups of 32 pixels (1 bit/pixel) in src bitmap*/
+ int widthDst; /* # of groups of 4 pixels (8 bits/pixel) in dst */
+ CfbBits *psrcLine, *pdstLine; /* steps a row at a time thru src/dst;
+ * may point into middle of row */
+ register CfbBits *psrc, *pdst; /* steps within the row */
+ register CfbBits bits, tmp; /* bits from source */
+ register int leftShift;
+ register int rightShift;
+ CfbBits startmask; /* left edge pixel mask */
+ CfbBits endmask; /* right edge pixel mask */
+ register int nlMiddle; /* number of words in middle of the row to draw */
+ register int nl;
+ int firstoff = 0;
+ int secondoff = 0;
+ CfbBits src;
+ int nbox; /* number of boxes in region to copy */
+ BoxPtr pbox; /* steps thru boxes in region */
+ int pixelsRemainingOnRightEdge; /* # pixels to be drawn on a row after
+ * the main "middle" loop */
+
+ cfbGetLongWidthAndPointer (pSrcDrawable, widthSrc, psrcBase)
+ cfbGetLongWidthAndPointer (pDstDrawable, widthDst, pdstBase)
+
+ nbox = REGION_NUM_RECTS(prgnDst);
+ pbox = REGION_RECTS(prgnDst);
+ while (nbox--)
+ {
+ dstx = pbox->x1;
+ dsty = pbox->y1;
+ srcx = pptSrc->x;
+ srcy = pptSrc->y;
+ width = pbox->x2 - pbox->x1;
+ height = pbox->y2 - pbox->y1;
+ pbox++;
+ pptSrc++;
+
+ psrcLine = psrcBase + srcy * widthSrc + (srcx >> MFB_PWSH);
+ pdstLine = pdstBase + dsty * widthDst + (dstx >> PWSH);
+ xoffSrc = srcx & MFB_PIM; /* finds starting bit in src */
+ xoffDst = dstx & PIM; /* finds starting byte in dst */
+
+ /* compute startmask, endmask, nlMiddle */
+
+ if (xoffDst + width < PPW) /* XXX should this be '<= PPW' ? */
+ { /* the copy only affects one word per row in destination */
+ maskpartialbits(dstx, width, startmask);
+ endmask = 0; /* nothing on right edge */
+ nlMiddle = 0; /* nothing in middle */
+ }
+ else
+ { /* the copy will affect multiple words per row in destination */
+ maskbits(dstx, width, startmask, endmask, nlMiddle);
+ }
+
+ /*
+ * compute constants for the first four bits to be
+ * copied. This avoids troubles with partial first
+ * writes, and difficult shift computation
+ */
+ if (startmask)
+ {
+ firstoff = xoffSrc - xoffDst;
+ if (firstoff > (MFB_PPW-PPW))
+ secondoff = MFB_PPW - firstoff;
+ if (xoffDst)
+ {
+ srcx += (PPW-xoffDst);
+ xoffSrc = srcx & MFB_PIM;
+ }
+ }
+ leftShift = xoffSrc;
+ rightShift = MFB_PPW - leftShift;
+
+ pixelsRemainingOnRightEdge = (nlMiddle & 7) * PPW +
+ ((dstx + width) & PIM);
+
+ /* setup is done; now let's move some bits */
+
+ /* caller must call cfb8CheckOpaqueStipple before this function
+ * to set cfb8StippleRRop!
+ */
+
+ if (cfb8StippleRRop == GXcopy)
+ {
+ while (height--)
+ { /* one iteration of this loop copies one row */
+ psrc = psrcLine;
+ pdst = pdstLine;
+ psrcLine += widthSrc;
+ pdstLine += widthDst;
+ bits = *psrc++;
+ if (startmask)
+ {
+ if (firstoff < 0)
+ tmp = BitRight (bits, -firstoff);
+ else
+ {
+ tmp = BitLeft (bits, firstoff);
+ /*
+ * need a more cautious test for partialmask
+ * case...
+ */
+ if (firstoff >= (MFB_PPW-PPW))
+ {
+ bits = *psrc++;
+ if (firstoff != (MFB_PPW-PPW))
+ tmp |= BitRight (bits, secondoff);
+ }
+ }
+ *pdst = (*pdst & ~startmask) | (GetPixelGroup(tmp) & startmask);
+ pdst++;
+ }
+ nl = nlMiddle;
+ while (nl >= 8)
+ {
+ nl -= 8;
+ tmp = BitLeft(bits, leftShift);
+ bits = *psrc++;
+ if (rightShift != MFB_PPW)
+ tmp |= BitRight(bits, rightShift);
+
+#ifdef FAST_CONSTANT_OFFSET_MODE
+# define StorePixels(pdst,o,pixels) (pdst)[o] = (pixels)
+# define EndStep(pdst,o) (pdst) += (o)
+# define StoreRopPixels(pdst,o,and,xor) (pdst)[o] = DoRRop((pdst)[o],and,xor);
+#else
+# define StorePixels(pdst,o,pixels) *(pdst)++ = (pixels)
+# define EndStep(pdst,o)
+# define StoreRopPixels(pdst,o,and,xor) *(pdst) = DoRRop(*(pdst),and,xor); (pdst)++;
+#endif
+
+#define Step(c) NextBitGroup(c);
+#define StoreBitsPlain(o,c) StorePixels(pdst,o,GetPixelGroup(c))
+#define StoreRopBitsPlain(o,c) StoreRopPixels(pdst,o,\
+ cfb8StippleAnd[GetBitGroup(c)], \
+ cfb8StippleXor[GetBitGroup(c)])
+#define StoreBits0(c) StoreBitsPlain(0,c)
+#define StoreRopBits0(c) StoreRopBitsPlain(0,c)
+
+#if (BITMAP_BIT_ORDER == MSBFirst)
+# define StoreBits(o,c) StoreBitsPlain(o,c)
+# define StoreRopBits(o,c) StoreRopBitsPlain(o,c)
+# define FirstStep(c) Step(c)
+#else /* BITMAP_BIT_ORDER == LSBFirst */
+#if PGSZ == 64
+# define StoreBits(o,c) StorePixels(pdst,o, (cfb8Pixels[c & 0xff]))
+# define StoreRopBits(o,c) StoreRopPixels(pdst,o, \
+ (cfb8StippleAnd[c & 0xff]), \
+ (cfb8StippleXor[c & 0xff]))
+# define FirstStep(c) c = BitLeft (c, 8);
+#else
+/* 0x3c is 0xf << 2 (4 bits, long word) */
+# define StoreBits(o,c) StorePixels(pdst,o,*((CfbBits *)\
+ (((char *) cfb8Pixels) + (c & 0x3c))))
+# define StoreRopBits(o,c) StoreRopPixels(pdst,o, \
+ *((CfbBits *) (((char *) cfb8StippleAnd) + (c & 0x3c))), \
+ *((CfbBits *) (((char *) cfb8StippleXor) + (c & 0x3c))))
+# define FirstStep(c) c = BitLeft (c, 2);
+#endif /* PGSZ */
+#endif /* BITMAP_BIT_ORDER */
+
+ StoreBits0(tmp); FirstStep(tmp);
+ StoreBits(1,tmp); Step(tmp);
+ StoreBits(2,tmp); Step(tmp);
+ StoreBits(3,tmp); Step(tmp);
+ StoreBits(4,tmp); Step(tmp);
+ StoreBits(5,tmp); Step(tmp);
+ StoreBits(6,tmp); Step(tmp);
+ StoreBits(7,tmp); EndStep (pdst,8);
+ }
+
+ /* do rest of middle and partial word on right edge */
+
+ if (pixelsRemainingOnRightEdge)
+ {
+ tmp = BitLeft(bits, leftShift);
+
+ if (pixelsRemainingOnRightEdge > rightShift)
+ {
+ bits = *psrc++;
+ tmp |= BitRight (bits, rightShift);
+ }
+ EndStep (pdst, nl);
+ switch (nl)
+ {
+ case 7:
+ StoreBitsPlain(-7,tmp); Step(tmp);
+ case 6:
+ StoreBitsPlain(-6,tmp); Step(tmp);
+ case 5:
+ StoreBitsPlain(-5,tmp); Step(tmp);
+ case 4:
+ StoreBitsPlain(-4,tmp); Step(tmp);
+ case 3:
+ StoreBitsPlain(-3,tmp); Step(tmp);
+ case 2:
+ StoreBitsPlain(-2,tmp); Step(tmp);
+ case 1:
+ StoreBitsPlain(-1,tmp); Step(tmp);
+ }
+ if (endmask)
+ *pdst = (*pdst & ~endmask) | (GetPixelGroup(tmp) & endmask);
+ }
+ }
+ }
+ else /* cfb8StippleRRop != GXcopy */
+ {
+ while (height--)
+ { /* one iteration of this loop copies one row */
+ psrc = psrcLine;
+ pdst = pdstLine;
+ psrcLine += widthSrc;
+ pdstLine += widthDst;
+ bits = *psrc++;
+
+ /* do partial word on left edge */
+
+ if (startmask)
+ {
+ if (firstoff < 0)
+ tmp = BitRight (bits, -firstoff);
+ else
+ {
+ tmp = BitLeft (bits, firstoff);
+ if (firstoff >= (MFB_PPW-PPW))
+ {
+ bits = *psrc++;
+ if (firstoff != (MFB_PPW-PPW))
+ tmp |= BitRight (bits, secondoff);
+ }
+ }
+ src = GetBitGroup(tmp);
+ *pdst = MaskRRopPixels (*pdst, src, startmask);
+ pdst++;
+ }
+
+ /* do middle of row */
+
+ nl = nlMiddle;
+ while (nl >= 8)
+ {
+ nl -= 8;
+ tmp = BitLeft(bits, leftShift);
+ bits = *psrc++;
+ if (rightShift != MFB_PPW)
+ tmp |= BitRight(bits, rightShift);
+ StoreRopBits0(tmp); FirstStep(tmp);
+ StoreRopBits(1,tmp); Step(tmp);
+ StoreRopBits(2,tmp); Step(tmp);
+ StoreRopBits(3,tmp); Step(tmp);
+ StoreRopBits(4,tmp); Step(tmp);
+ StoreRopBits(5,tmp); Step(tmp);
+ StoreRopBits(6,tmp); Step(tmp);
+ StoreRopBits(7,tmp); EndStep(pdst,8);
+ }
+
+ /* do rest of middle and partial word on right edge */
+
+ if (pixelsRemainingOnRightEdge)
+ {
+ tmp = BitLeft(bits, leftShift);
+
+ if (pixelsRemainingOnRightEdge > rightShift)
+ {
+ bits = *psrc++; /* XXX purify abr here */
+ tmp |= BitRight (bits, rightShift);
+ }
+ while (nl--)
+ {
+ src = GetBitGroup (tmp);
+ *pdst = RRopPixels (*pdst, src);
+ pdst++;
+ NextBitGroup(tmp);
+ }
+ if (endmask)
+ {
+ src = GetBitGroup (tmp);
+ *pdst = MaskRRopPixels (*pdst, src, endmask);
+ }
+ }
+ } /* end copy one row */
+ } /* end alu is non-copy-mode case */
+ } /* end iteration over region boxes */
+}
+
+#else /* PSZ == 8 */
+
+#define mfbmaskbits(x, w, startmask, endmask, nlw) \
+ startmask = mfbGetstarttab((x)&0x1f); \
+ endmask = mfbGetendtab(((x)+(w)) & 0x1f); \
+ if (startmask) \
+ nlw = (((w) - (32 - ((x)&0x1f))) >> 5); \
+ else \
+ nlw = (w) >> 5;
+
+#define mfbmaskpartialbits(x, w, mask) \
+ mask = mfbGetpartmasks((x)&0x1f,(w)&0x1f);
+
+#define LeftMost 0
+#define StepBit(bit, inc) ((bit) += (inc))
+
+
+#define GetBits(psrc, nBits, curBit, bitPos, bits) {\
+ bits = 0; \
+ while (nBits--) \
+ { \
+ bits |= ((*psrc++ >> bitPos) & 1) << curBit; \
+ StepBit (curBit, 1); \
+ } \
+}
+
+/******************************************************************/
+
+static void
+#if PSZ == 16
+cfbCopyPlane1to16
+#endif
+#if PSZ == 24
+cfbCopyPlane1to24
+#endif
+#if PSZ == 32
+cfbCopyPlane1to32
+#endif
+(
+ DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ int rop,
+ RegionPtr prgnDst,
+ DDXPointPtr pptSrc,
+ unsigned long planemask)
+{
+ int srcx, srcy, dstx, dsty;
+ int width, height;
+ int xoffSrc;
+ CfbBits *psrcBase, *pdstBase;
+ int widthSrc, widthDst;
+ unsigned int *psrcLine;
+ register unsigned int *psrc;
+#if PSZ == 16
+ unsigned short *pdstLine;
+ register unsigned short *pdst;
+#endif
+#if PSZ == 32
+ unsigned int *pdstLine;
+ register unsigned int *pdst;
+#endif
+#if PSZ == 24
+ unsigned char *pdstLine;
+ register unsigned char *pdst;
+#endif
+ register unsigned int bits, tmp;
+ register unsigned int fgpixel, bgpixel;
+ register unsigned int src;
+#if PSZ == 24
+ register unsigned int dst;
+#endif
+ register int leftShift, rightShift;
+ register int i, nl;
+ int nbox;
+ BoxPtr pbox;
+ int result;
+
+#if PSZ == 16
+ unsigned int doublet[4]; /* Pixel values for 16bpp expansion. */
+#endif
+#if PSZ == 32
+ unsigned int doublet[8]; /* Pixel values for 32bpp expansion */
+#endif
+
+ fgpixel = FgPixel & planemask;
+ bgpixel = BgPixel & planemask;
+
+#if PSZ == 16
+ if (rop == GXcopy && (planemask & PMSK) == PMSK) {
+ doublet[0] = bgpixel | (bgpixel << 16);
+ doublet[1] = fgpixel | (bgpixel << 16);
+ doublet[2] = bgpixel | (fgpixel << 16);
+ doublet[3] = fgpixel | (fgpixel << 16);
+ }
+#endif
+#if PSZ == 32
+ if (rop == GXcopy && (planemask & PMSK) == PMSK) {
+ doublet[0] = bgpixel; doublet[1] = bgpixel;
+ doublet[2] = fgpixel; doublet[3] = bgpixel;
+ doublet[4] = bgpixel; doublet[5] = fgpixel;
+ doublet[6] = fgpixel; doublet[7] = fgpixel;
+ }
+#endif
+
+ /* must explicitly ask for "int" widths, as code below expects it */
+ /* on some machines (Alpha), "long" and "int" are not the same size */
+ cfbGetTypedWidthAndPointer (pSrcDrawable, widthSrc, psrcBase, int, CfbBits)
+ cfbGetTypedWidthAndPointer (pDstDrawable, widthDst, pdstBase, int, CfbBits)
+
+#if PSZ == 16
+ widthDst <<= 1;
+#endif
+#if PSZ == 24
+ widthDst <<= 2;
+#endif
+
+ nbox = REGION_NUM_RECTS(prgnDst);
+ pbox = REGION_RECTS(prgnDst);
+
+ while (nbox--)
+ {
+ dstx = pbox->x1;
+ dsty = pbox->y1;
+ srcx = pptSrc->x;
+ srcy = pptSrc->y;
+ width = pbox->x2 - pbox->x1;
+ height = pbox->y2 - pbox->y1;
+ pbox++;
+ pptSrc++;
+ psrcLine = (unsigned int *)psrcBase + srcy * widthSrc + (srcx >> 5);
+#if PSZ == 16
+ pdstLine = (unsigned short *)pdstBase + dsty * widthDst + dstx;
+#endif
+#if PSZ == 24
+ pdstLine = (unsigned char *)pdstBase + dsty * widthDst + dstx * 3;
+#endif
+#if PSZ == 32
+ pdstLine = (unsigned int *)pdstBase + dsty * widthDst + dstx;
+#endif
+ xoffSrc = srcx & 0x1f;
+
+ /*
+ * compute constants for the first four bits to be
+ * copied. This avoids troubles with partial first
+ * writes, and difficult shift computation
+ */
+ leftShift = xoffSrc;
+ rightShift = 32 - leftShift;
+
+ if (rop == GXcopy && (planemask & PMSK) == PMSK)
+ {
+ while (height--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ psrcLine += widthSrc;
+ pdstLine += widthDst;
+ bits = *psrc++;
+ nl = width;
+ while (nl >= 32)
+ {
+ tmp = BitLeft(bits, leftShift);
+ bits = *psrc++;
+ if (rightShift != 32)
+ tmp |= BitRight(bits, rightShift);
+ i = 0;
+#if PSZ == 16
+ /*
+ * I've thrown in some optimization to at least write
+ * some aligned 32-bit words instead of 16-bit shorts.
+ */
+ if ((unsigned long)psrc & 2) {
+ /* Write unaligned 16-bit word at left edge. */
+ if (tmp & 0x01)
+ *pdst = fgpixel;
+ else
+ *pdst = bgpixel;
+ pdst++;
+ i++;
+ }
+ while (i <= 24)
+ {
+ unsigned tmpbits = tmp >> i;
+ *(unsigned int *)pdst = doublet[tmpbits & 0x03];
+ *(unsigned int *)(pdst + 2) =
+ doublet[(tmpbits >> 2) & 0x03];
+ *(unsigned int *)(pdst + 4) =
+ doublet[(tmpbits >> 4) & 0x03];
+ *(unsigned int *)(pdst + 6) =
+ doublet[(tmpbits >> 6) & 0x03];
+ pdst += 8; /* Advance four 32-bit words. */
+ i += 8;
+ }
+ while (i <= 30)
+ {
+ *(unsigned int *)pdst =
+ doublet[(tmp >> i) & 0x03];
+ pdst += 2; /* Advance one 32-bit word. */
+ i += 2;
+ }
+ if (i == 31) {
+ if ((tmp >> 31) & 0x01)
+ *pdst = fgpixel;
+ else
+ *pdst = bgpixel;
+ pdst++;
+ }
+#endif
+#if PSZ == 24
+ while (i < 32) {
+ if ((tmp >> i) & 0x01) {
+ *pdst = fgpixel;
+ *(pdst + 1) = fgpixel >> 8;
+ *(pdst + 2) = fgpixel >> 16;
+ }
+ else {
+ *pdst = bgpixel;
+ *(pdst + 1) = bgpixel >> 8;
+ *(pdst + 2) = bgpixel >> 16;
+ }
+ pdst += 3;
+ i++;
+ }
+#endif
+#if PSZ == 32
+ while (i <= 28) {
+ int pair;
+ pair = (tmp >> i) & 0x03;
+ *pdst = doublet[pair * 2];
+ *(pdst + 1) = doublet[pair * 2 + 1];
+ pair = (tmp >> (i + 2)) & 0x03;
+ *(pdst + 2) = doublet[pair * 2];
+ *(pdst + 3) = doublet[pair * 2 + 1];
+ pdst += 4;
+ i += 4;
+ }
+ while (i < 32) {
+ *pdst = ((tmp >> i) & 0x01) ? fgpixel : bgpixel;
+ pdst++;
+ i++;
+ }
+#endif
+ nl -= 32;
+ }
+
+ if (nl)
+ {
+ tmp = BitLeft(bits, leftShift);
+ /*
+ * better condition needed -- mustn't run
+ * off the end of the source...
+ */
+ if (rightShift != 32)
+ {
+ bits = *psrc++;
+ tmp |= BitRight (bits, rightShift);
+ }
+ i = 32;
+ while (nl--)
+ {
+ --i;
+#if PSZ == 24
+ if ((tmp >> (31 - i)) & 0x01) {
+ *pdst = fgpixel;
+ *(pdst + 1) = fgpixel >> 8;
+ *(pdst + 2) = fgpixel >> 16;
+ }
+ else {
+ *pdst = bgpixel;
+ *(pdst + 1) = bgpixel >> 8;
+ *(pdst + 2) = bgpixel >> 16;
+ }
+ pdst += 3;
+#else
+ *pdst = ((tmp >> (31 - i)) & 0x01) ? fgpixel : bgpixel;
+ pdst++;
+#endif
+ }
+ }
+ }
+ }
+ else
+ {
+ while (height--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ psrcLine += widthSrc;
+ pdstLine += widthDst;
+ bits = *psrc++;
+ nl = width;
+ while (nl >= 32)
+ {
+ tmp = BitLeft(bits, leftShift);
+ bits = *psrc++;
+ if (rightShift != 32)
+ tmp |= BitRight(bits, rightShift);
+ i = 32;
+ while (i--)
+ {
+ src = ((tmp >> (31 - i)) & 0x01) ? fgpixel : bgpixel;
+#if PSZ == 24
+ dst = *pdst;
+ dst |= (*(pdst + 1)) << 8;
+ dst |= (*(pdst + 2)) << 16;
+ DoRop (result, rop, src, dst);
+ *pdst = (dst & ~planemask) |
+ (result & planemask);
+ *(pdst+1) = ((dst & ~planemask) >> 8) |
+ ((result & planemask) >> 8);
+ *(pdst+2) = ((dst & ~planemask) >> 16) |
+ ((result & planemask) >> 16);
+ pdst += 3;
+#else
+ DoRop (result, rop, src, *pdst);
+
+ *pdst = (*pdst & ~planemask) |
+ (result & planemask);
+ pdst++;
+#endif
+ }
+ nl -= 32;
+ }
+
+ if (nl)
+ {
+ tmp = BitLeft(bits, leftShift);
+ /*
+ * better condition needed -- mustn't run
+ * off the end of the source...
+ */
+ if (rightShift != 32)
+ {
+ bits = *psrc++;
+ tmp |= BitRight (bits, rightShift);
+ }
+ i = 32;
+ while (nl--)
+ {
+ --i;
+ src = ((tmp >> (31 - i)) & 0x01) ? fgpixel : bgpixel;
+#if PSZ == 24
+ dst = *pdst;
+ dst |= (*(pdst + 1)) << 8;
+ dst |= (*(pdst + 2)) << 16;
+ DoRop (result, rop, src, dst);
+ *pdst = (dst & ~planemask) |
+ (result & planemask);
+ *(pdst+1) = ((dst & ~planemask) >> 8) |
+ ((result & planemask) >> 8);
+ *(pdst+2) = ((dst & ~planemask) >> 16) |
+ ((result & planemask) >> 16);
+ pdst += 3;
+#else
+ DoRop (result, rop, src, *pdst);
+
+ *pdst = (*pdst & ~planemask) |
+ (result & planemask);
+ pdst++;
+#endif
+ }
+ }
+ }
+ }
+ }
+}
+
+#endif /* PSZ == 8 */
+
+/* shared among all different cfb depths through linker magic */
+
+RegionPtr cfbCopyPlane(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, bitPlane)
+ DrawablePtr pSrcDrawable;
+ DrawablePtr pDstDrawable;
+ GCPtr pGC;
+ int srcx, srcy;
+ int width, height;
+ int dstx, dsty;
+ unsigned long bitPlane;
+{
+ RegionPtr ret;
+
+#if IMAGE_BYTE_ORDER == LSBFirst
+
+ void (*doCopyPlaneExpand)(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/);
+
+ if (pSrcDrawable->bitsPerPixel == 1 && pDstDrawable->bitsPerPixel == PSZ)
+ {
+ if (bitPlane == 1)
+ {
+ doCopyPlaneExpand = cfbCopyPlane1toN;
+#if PSZ == 8
+ cfb8CheckOpaqueStipple (pGC->alu,
+ pGC->fgPixel, pGC->bgPixel,
+ pGC->planemask);
+#else
+ FgPixel = pGC->fgPixel;
+ BgPixel = pGC->bgPixel;
+#endif
+ ret = cfbCopyPlaneExpand (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, doCopyPlaneExpand, bitPlane);
+ }
+ else
+ ret = miHandleExposures (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
+ }
+ else if (pSrcDrawable->bitsPerPixel == PSZ && pDstDrawable->bitsPerPixel == 1)
+ {
+ int oldalu;
+
+ oldalu = pGC->alu;
+ if ((pGC->fgPixel & 1) == 0 && (pGC->bgPixel&1) == 1)
+ pGC->alu = mfbGetInverseAlu(pGC->alu);
+ else if ((pGC->fgPixel & 1) == (pGC->bgPixel & 1))
+ pGC->alu = mfbReduceRop(pGC->alu, pGC->fgPixel);
+ ret = cfbCopyPlaneReduce(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty,
+ cfbCopyPlaneNto1, bitPlane);
+ pGC->alu = oldalu;
+ }
+ else if (pSrcDrawable->bitsPerPixel == PSZ && pDstDrawable->bitsPerPixel == PSZ)
+ {
+ PixmapPtr pBitmap;
+ ScreenPtr pScreen = pSrcDrawable->pScreen;
+ GCPtr pGC1;
+
+ pBitmap = (*pScreen->CreatePixmap) (pScreen, width, height, 1);
+ if (!pBitmap)
+ return NULL;
+ pGC1 = GetScratchGC (1, pScreen);
+ if (!pGC1)
+ {
+ (*pScreen->DestroyPixmap) (pBitmap);
+ return NULL;
+ }
+ /*
+ * don't need to set pGC->fgPixel,bgPixel as copyPlaneNto1
+ * ignores pixel values, expecting the rop to "do the
+ * right thing", which GXcopy will.
+ */
+ ValidateGC ((DrawablePtr) pBitmap, pGC1);
+ /* no exposures here, scratch GC's don't get graphics expose */
+ cfbCopyPlaneReduce(pSrcDrawable, (DrawablePtr) pBitmap,
+ pGC1, srcx, srcy, width, height, 0, 0,
+ cfbCopyPlaneNto1, bitPlane);
+#if PSZ == 8
+ cfb8CheckOpaqueStipple (pGC->alu,
+ pGC->fgPixel, pGC->bgPixel,
+ pGC->planemask);
+#else
+ FgPixel = pGC->fgPixel;
+ BgPixel = pGC->bgPixel;
+#endif
+ /* no exposures here, copy bits from inside a pixmap */
+ cfbCopyPlaneExpand((DrawablePtr) pBitmap, pDstDrawable, pGC,
+ 0, 0, width, height, dstx, dsty, cfbCopyPlane1toN, 1);
+ FreeScratchGC (pGC1);
+ (*pScreen->DestroyPixmap) (pBitmap);
+ /* compute resultant exposures */
+ ret = miHandleExposures (pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height,
+ dstx, dsty, bitPlane);
+ }
+ else
+#endif
+ ret = miCopyPlane (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
+ return ret;
+}
+
+
diff --git a/nx-X11/programs/Xserver/cfb/cfbblt.c b/nx-X11/programs/Xserver/cfb/cfbblt.c
new file mode 100644
index 000000000..7a0b192cc
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbblt.c
@@ -0,0 +1,933 @@
+/*
+ * cfb copy area
+ */
+/* $XFree86: xc/programs/Xserver/cfb/cfbblt.c,v 3.13tsi Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Author: Keith Packard
+
+*/
+/* $Xorg: cfbblt.c,v 1.4 2001/02/09 02:04:37 xorgcvs Exp $ */
+
+/* 24-bit bug fixes: Peter Wainwright, 1998/11/28 */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "cfb8bit.h"
+#include "fastblt.h"
+#include "mergerop.h"
+
+#ifdef notdef /* XXX fails right now, walks off end of pixmaps */
+#if defined (FAST_UNALIGNED_READS) && PSZ == 8
+#define DO_UNALIGNED_BITBLT
+#endif
+#endif
+
+#if defined(FAST_MEMCPY) && (MROP == Mcopy) && PSZ == 8
+#define DO_MEMCPY
+#endif
+
+/* ................................................. */
+/* SPECIAL CODE FOR 24 BITS by Peter Wainwright */
+
+#if PSZ == 24 && (MROP) == 0
+
+/* The default macros are defined in mergerop.h, and none of them are
+ really appropriate for what we want to do.
+
+ There are two ways of fixing this: either define SLOW_24BIT_COPY
+ to copy pixel by pixel, or (by default) use the following macros
+ modified from mergerop.h
+
+ MROP_SOLID and MROP_MASK are defined for each of the operations,
+ i.e. each value of MROP.
+
+ There are special cases for Mcopy, McopyInverted, Mxor, and Mor.
+ There is a completely generic version for MROP=0, and a simplified
+ generic version which works for (Mcopy|Mxor|MandReverse|Mor).
+
+ However, the generic version does not work for the 24-bit case
+ because the pixels cannot be packed exactly into a machine word (32
+ bits).
+
+ Alternative macros MROP_SOLID24 and MROP_MASK24 are provided for
+ the 24-bit case. However, these each copy a single *pixel*, not a
+ single machine word. They take an rvalue source pixel, an lvalue
+ destination, and the pixel index. The latter is used to find the
+ position of the pixel data within the two words *dst and *(dst+1).
+
+ Further macros MROP_SOLID24P and MROP_MASK24P are used to copy from
+ an lvalue source to an lvalue destination. MROP_PIXEL24 is used to
+ assemble the source pixel from the adjacent words *src and
+ *(src+1), and this is then split between the destination words
+ using the non-P macros above.
+
+ But we want to copy entire words for the sake of efficiency.
+ Unfortunately if a plane mask is specified this must be shifted
+ from one word to the next. Fortunately the pattern repeats after 3
+ words, so we unroll the planemask here and redefine MROP_SOLID
+ and MROP_MASK. */
+
+
+#endif /* MROP == 0 && PSZ == 24 */
+
+/* ................................................. */
+
+#if PSZ == 24
+#define BYPP 3
+#if PGSZ == 32
+#define P3W 4 /* pixels in 3 machine words */
+#define PAM 3 /* pixel align mask; PAM = P3W -1 */
+#define P2WSH 2
+#else
+#define P3W 8 /* pixels in 3 machine words */
+#define PAM 7 /* pixel align mask; PAM = P3W -1 */
+#define P2WSH 3
+#endif
+#endif
+
+void
+MROP_NAME(cfbDoBitblt)(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ int alu,
+ RegionPtr prgnDst,
+ DDXPointPtr pptSrc,
+ unsigned long planemask)
+{
+ CfbBits *psrcBase, *pdstBase;
+ /* start of src and dst bitmaps */
+ int widthSrc, widthDst; /* add to get to same position in next line */
+
+ BoxPtr pbox;
+ int nbox;
+
+ BoxPtr pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2;
+ /* temporaries for shuffling rectangles */
+ DDXPointPtr pptTmp, pptNew1, pptNew2;
+ /* shuffling boxes entails shuffling the
+ source points too */
+ int w, h;
+ int xdir; /* 1 = left right, -1 = right left/ */
+ int ydir; /* 1 = top down, -1 = bottom up */
+
+ CfbBits *psrcLine, *pdstLine;
+ /* pointers to line with current src and dst */
+ register CfbBits *psrc;/* pointer to current src longword */
+ register CfbBits *pdst;/* pointer to current dst longword */
+
+ MROP_DECLARE_REG()
+
+ /* following used for looping through a line */
+ CfbBits startmask, endmask; /* masks for writing ends of dst */
+ int nlMiddle; /* whole longwords in dst */
+ int xoffSrc, xoffDst;
+ register int nl; /* temp copy of nlMiddle */
+ int careful;
+
+#if (PSZ != 24) || (MROP != 0)
+ register int leftShift, rightShift;
+ register CfbBits bits;
+ register CfbBits bits1;
+#endif
+
+#if PSZ == 24
+#ifdef DO_MEMCPY
+ int w2;
+#endif
+
+#if MROP == 0
+ int widthSrcBytes = cfbGetByteWidth(pSrc);
+ int widthDstBytes = cfbGetByteWidth(pDst);
+#endif
+#endif
+
+ MROP_INITIALIZE(alu,planemask)
+
+ cfbGetLongWidthAndPointer (pSrc, widthSrc, psrcBase)
+
+ cfbGetLongWidthAndPointer (pDst, widthDst, pdstBase)
+
+ /* XXX we have to err on the side of safety when both are windows,
+ * because we don't know if IncludeInferiors is being used.
+ */
+ careful = ((pSrc == pDst) ||
+ ((pSrc->type == DRAWABLE_WINDOW) &&
+ (pDst->type == DRAWABLE_WINDOW)));
+
+ pbox = REGION_RECTS(prgnDst);
+ nbox = REGION_NUM_RECTS(prgnDst);
+
+ pboxNew1 = NULL;
+ pptNew1 = NULL;
+ pboxNew2 = NULL;
+ pptNew2 = NULL;
+ if (careful && (pptSrc->y < pbox->y1))
+ {
+ /* walk source botttom to top */
+ ydir = -1;
+ widthSrc = -widthSrc;
+ widthDst = -widthDst;
+
+ if (nbox > 1)
+ {
+ /* keep ordering in each band, reverse order of bands */
+ pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
+ if(!pboxNew1)
+ return;
+ pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox);
+ if(!pptNew1)
+ {
+ DEALLOCATE_LOCAL(pboxNew1);
+ return;
+ }
+ pboxBase = pboxNext = pbox+nbox-1;
+ while (pboxBase >= pbox)
+ {
+ while ((pboxNext >= pbox) &&
+ (pboxBase->y1 == pboxNext->y1))
+ pboxNext--;
+ pboxTmp = pboxNext+1;
+ pptTmp = pptSrc + (pboxTmp - pbox);
+ while (pboxTmp <= pboxBase)
+ {
+ *pboxNew1++ = *pboxTmp++;
+ *pptNew1++ = *pptTmp++;
+ }
+ pboxBase = pboxNext;
+ }
+ pboxNew1 -= nbox;
+ pbox = pboxNew1;
+ pptNew1 -= nbox;
+ pptSrc = pptNew1;
+ }
+ }
+ else
+ {
+ /* walk source top to bottom */
+ ydir = 1;
+ }
+
+ if (careful && (pptSrc->x < pbox->x1))
+ {
+ /* walk source right to left */
+ xdir = -1;
+
+ if (nbox > 1)
+ {
+ /* reverse order of rects in each band */
+ pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
+ pptNew2 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox);
+ if(!pboxNew2 || !pptNew2)
+ {
+ if (pptNew2) DEALLOCATE_LOCAL(pptNew2);
+ if (pboxNew2) DEALLOCATE_LOCAL(pboxNew2);
+ if (pboxNew1)
+ {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(pboxNew1);
+ }
+ return;
+ }
+ pboxBase = pboxNext = pbox;
+ while (pboxBase < pbox+nbox)
+ {
+ while ((pboxNext < pbox+nbox) &&
+ (pboxNext->y1 == pboxBase->y1))
+ pboxNext++;
+ pboxTmp = pboxNext;
+ pptTmp = pptSrc + (pboxTmp - pbox);
+ while (pboxTmp != pboxBase)
+ {
+ *pboxNew2++ = *--pboxTmp;
+ *pptNew2++ = *--pptTmp;
+ }
+ pboxBase = pboxNext;
+ }
+ pboxNew2 -= nbox;
+ pbox = pboxNew2;
+ pptNew2 -= nbox;
+ pptSrc = pptNew2;
+ }
+ }
+ else
+ {
+ /* walk source left to right */
+ xdir = 1;
+ }
+
+ while(nbox--)
+ {
+ w = pbox->x2 - pbox->x1;
+ h = pbox->y2 - pbox->y1;
+
+#if PSZ == 24
+#ifdef DO_MEMCPY
+ w2 = w * BYPP;
+#endif
+#endif
+ if (ydir == -1) /* start at last scanline of rectangle */
+ {
+ psrcLine = psrcBase + ((pptSrc->y+h-1) * -widthSrc);
+ pdstLine = pdstBase + ((pbox->y2-1) * -widthDst);
+ }
+ else /* start at first scanline */
+ {
+ psrcLine = psrcBase + (pptSrc->y * widthSrc);
+ pdstLine = pdstBase + (pbox->y1 * widthDst);
+ }
+#if PSZ == 24
+ if (w == 1 && ((pbox->x1 & PAM) == 0 || (pbox->x1 & PAM) == PAM))
+#else
+ if ((pbox->x1 & PIM) + w <= PPW)
+#endif
+ {
+ maskpartialbits (pbox->x1, w, endmask);
+ startmask = 0;
+ nlMiddle = 0;
+ }
+ else
+ {
+ maskbits(pbox->x1, w, startmask, endmask, nlMiddle);
+ }
+
+#if PSZ == 24
+#if 0
+ nlMiddle = w - (pbox->x2 &PAM);;
+ if(pbox->x1 & PAM){
+ nlMiddle -= (PAM+1 - (pbox->x1 &PAM));
+ }
+ nlMiddle >>= P2WSH;
+ if(nlMiddle < 0)
+ nlMiddle = 0;
+#endif
+#endif
+
+#ifdef DO_MEMCPY
+ /* If the src and dst scanline don't overlap, do forward case. */
+
+ if ((xdir == 1) || (pptSrc->y != pbox->y1)
+ || (pptSrc->x + w <= pbox->x1))
+ {
+#if PSZ == 24
+ char *psrc = (char *) psrcLine + (pptSrc->x * BYPP);
+ char *pdst = (char *) pdstLine + (pbox->x1 * BYPP);
+#else
+ char *psrc = (char *) psrcLine + pptSrc->x;
+ char *pdst = (char *) pdstLine + pbox->x1;
+#endif
+ while (h--)
+ {
+#if PSZ == 24
+ memcpy(pdst, psrc, w2);
+#else
+ memcpy(pdst, psrc, w);
+#endif
+ pdst += widthDst << PWSH;
+ psrc += widthSrc << PWSH;
+ }
+ }
+#else /* ! DO_MEMCPY */
+ if (xdir == 1)
+ {
+#if PSZ == 24 && MROP == 0
+ /* Note: x is a pixel number; the byte offset is 3*x;
+ therefore the offset within a word is (3*x) & 3 ==
+ (4*x-x) & 3 == (-x) & 3. The offsets therefore
+ DECREASE by 1 for each pixel.
+ */
+ xoffSrc = ( - pptSrc->x) & PAM;
+ xoffDst = ( - pbox->x1) & PAM;
+#if 1
+ if((int)xoffSrc != (int)xoffDst /* Alignments must be same. */
+ || ((widthDstBytes & PAM) != (widthSrcBytes & PAM) && h > 1))
+#else
+ if(1)
+#endif
+ /* Width also must be same, if hight > 1 */
+ {
+ /* ...otherwise, pixel by pixel operation */
+ while (h--)
+ {
+ register int i, si, sii, di;
+
+ for (i = 0, si = pptSrc->x, di = pbox->x1;
+ i < w;
+ i++, si++, di++) {
+ psrc = psrcLine + ((si * BYPP) >> P2WSH);
+ pdst = pdstLine + ((di * BYPP) >> P2WSH);
+ sii = (si & 3);
+ MROP_SOLID24P(psrc, pdst, sii, di);
+ }
+ pdstLine += widthDst;
+ psrcLine += widthSrc;
+ }
+ }
+ else
+#endif
+ {
+
+#if PSZ == 24
+
+#if MROP != 0
+ xoffSrc = ( - pptSrc->x) & PAM;
+ xoffDst = ( - pbox->x1) & PAM;
+#endif
+ pdstLine += (pbox->x1 * BYPP) >> P2WSH;
+ psrcLine += (pptSrc->x * BYPP) >> P2WSH;
+#else
+ xoffSrc = pptSrc->x & PIM;
+ xoffDst = pbox->x1 & PIM;
+ pdstLine += (pbox->x1 >> PWSH);
+ psrcLine += (pptSrc->x >> PWSH);
+#endif
+#ifdef DO_UNALIGNED_BITBLT
+ nl = xoffSrc - xoffDst;
+ psrcLine = (CfbBits *)
+ (((unsigned char *) psrcLine) + nl);
+#else
+#if PSZ == 24 && MROP == 0
+ /* alredy satisfied */
+#else
+ if (xoffSrc == xoffDst)
+#endif
+#endif
+ {
+ while (h--)
+ {
+#if PSZ == 24 && MROP == 0
+ register int index;
+ register int im3;
+#endif /* PSZ == 24 && MROP == 0 */
+ psrc = psrcLine;
+ pdst = pdstLine;
+ pdstLine += widthDst;
+ psrcLine += widthSrc;
+#if PSZ == 24 && MROP == 0
+ index = (int)(pdst - pdstBase);
+ im3 = index % 3;
+#endif /* PSZ == 24 && MROP == 0 */
+ if (startmask)
+ {
+#if PSZ == 24 && MROP == 0
+ *pdst = DoMaskMergeRop24u(*psrc, *pdst, startmask, im3);
+ index++;
+ im3 = index % 3;
+#else /* PSZ != 24 || MROP != 0 */
+ *pdst = MROP_MASK(*psrc, *pdst, startmask);
+#endif /* PSZ == 24 && MROP == 0 */
+ psrc++;
+ pdst++;
+ }
+
+ nl = nlMiddle;
+#ifdef LARGE_INSTRUCTION_CACHE
+#ifdef FAST_CONSTANT_OFFSET_MODE
+
+ psrc += nl & (UNROLL-1);
+ pdst += nl & (UNROLL-1);
+
+#if PSZ == 24 && MROP == 0
+#define BodyOdd(n) pdst[-n] = DoMergeRop24u(psrc[-n], pdst[-n], ((int)(pdst - n - pdstBase))%3);
+#define BodyEven(n) pdst[-n] = DoMergeRop24u(psrc[-n], pdst[-n], ((int)(pdst - n - pdstBase))%3);
+#else /* PSZ != 24 || MROP != 0 */
+#define BodyOdd(n) pdst[-n] = MROP_SOLID (psrc[-n], pdst[-n]);
+#define BodyEven(n) pdst[-n] = MROP_SOLID (psrc[-n], pdst[-n]);
+#endif /* PSZ == 24 && MROP == 0 */
+
+#define LoopReset \
+pdst += UNROLL; \
+psrc += UNROLL;
+
+#else
+
+#if PSZ == 24 && MROP == 0
+#define BodyOdd(n) *pdst = DoMergeRop24u(*psrc, *pdst, im3); pdst++; psrc++; index++; im3 = index % 3;
+#define BodyEven(n) BodyOdd(n)
+#else /* PSZ != 24 || MROP != 0 */
+#define BodyOdd(n) *pdst = MROP_SOLID (*psrc, *pdst); pdst++; psrc++;
+#define BodyEven(n) BodyOdd(n)
+#endif /* PSZ == 24 && MROP == 0 */
+
+#define LoopReset ;
+
+#endif
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+#ifdef NOTDEF
+ /* you'd think this would be faster --
+ * a single instruction instead of 6
+ * but measurements show it to be ~15% slower
+ */
+ while ((nl -= 6) >= 0)
+ {
+ asm ("moveml %1+,#0x0c0f;moveml#0x0c0f,%0"
+ : "=m" (*(char *)pdst)
+ : "m" (*(char *)psrc)
+ : "d0", "d1", "d2", "d3",
+ "a2", "a3");
+ pdst += 6;
+ }
+ nl += 6;
+ while (nl--)
+ *pdst++ = *psrc++;
+#endif
+#if 0 /*PSZ == 24 && MROP == 0*/
+ DuffL(nl, label1,
+ *pdst = DoMergeRop24u(*psrc, *pdst, im3);
+ pdst++; psrc++; index++;im3 = index % 3;)
+#else /* !(PSZ == 24 && MROP == 0) */
+ DuffL(nl, label1,
+ *pdst = MROP_SOLID (*psrc, *pdst);
+ pdst++; psrc++;)
+#endif /* PSZ == 24 && MROP == 0 */
+#endif
+
+ if (endmask)
+#if PSZ == 24 && MROP == 0
+ *pdst = DoMaskMergeRop24u(*psrc, *pdst, endmask, (int)(pdst - pdstBase) % 3);
+#else /* !(PSZ == 24 && MROP == 0) */
+ *pdst = MROP_MASK(*psrc, *pdst, endmask);
+#endif /* PSZ == 24 && MROP == 0 */
+ }
+ }
+#ifndef DO_UNALIGNED_BITBLT
+#if PSZ == 24 && MROP == 0
+ /* can not happen */
+#else /* !(PSZ == 24 && MROP == 0) */
+ else /* xoffSrc != xoffDst */
+ {
+ if (xoffSrc > xoffDst)
+ {
+#if PSZ == 24
+ leftShift = (xoffSrc - xoffDst) << 3;
+#else
+#if PGSZ == 32
+ leftShift = (xoffSrc - xoffDst) << (5 - PWSH);
+#else /* PGSZ == 64 */
+ leftShift = (xoffSrc - xoffDst) << (6 - PWSH);
+#endif /* PGSZ */
+#endif
+ rightShift = PGSZ - leftShift;
+ }
+ else
+ {
+#if PSZ == 24
+ rightShift = (xoffDst - xoffSrc) << 3;
+#else
+#if PGSZ == 32
+ rightShift = (xoffDst - xoffSrc) << (5 - PWSH);
+#else /* PGSZ == 64 */
+ rightShift = (xoffDst - xoffSrc) << (6 - PWSH);
+#endif /* PGSZ */
+#endif
+ leftShift = PGSZ - rightShift;
+ }
+ while (h--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ pdstLine += widthDst;
+ psrcLine += widthSrc;
+ bits = 0;
+ if (xoffSrc > xoffDst)
+ bits = *psrc++;
+ if (startmask)
+ {
+ bits1 = BitLeft(bits,leftShift);
+ bits = *psrc++;
+ bits1 |= BitRight(bits,rightShift);
+ *pdst = MROP_MASK(bits1, *pdst, startmask);
+ pdst++;
+ }
+ nl = nlMiddle;
+#ifdef LARGE_INSTRUCTION_CACHE
+ bits1 = bits;
+
+#ifdef FAST_CONSTANT_OFFSET_MODE
+
+ psrc += nl & (UNROLL-1);
+ pdst += nl & (UNROLL-1);
+
+#define BodyOdd(n) \
+bits = psrc[-n]; \
+pdst[-n] = MROP_SOLID(BitLeft(bits1, leftShift) | BitRight(bits, rightShift), pdst[-n]);
+
+#define BodyEven(n) \
+bits1 = psrc[-n]; \
+pdst[-n] = MROP_SOLID(BitLeft(bits, leftShift) | BitRight(bits1, rightShift), pdst[-n]);
+
+#define LoopReset \
+pdst += UNROLL; \
+psrc += UNROLL;
+
+#else
+
+#define BodyOdd(n) \
+bits = *psrc++; \
+*pdst = MROP_SOLID(BitLeft(bits1, leftShift) | BitRight(bits, rightShift), *pdst); \
+pdst++;
+
+#define BodyEven(n) \
+bits1 = *psrc++; \
+*pdst = MROP_SOLID(BitLeft(bits, leftShift) | BitRight(bits1, rightShift), *pdst); \
+pdst++;
+
+#define LoopReset ;
+
+#endif /* !FAST_CONSTANT_OFFSET_MODE */
+
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+ DuffL (nl,label2,
+ bits1 = BitLeft(bits, leftShift);
+ bits = *psrc++;
+ *pdst = MROP_SOLID (bits1 | BitRight(bits, rightShift), *pdst);
+ pdst++;
+ )
+#endif
+
+ if (endmask)
+ {
+ bits1 = BitLeft(bits, leftShift);
+ if (BitLeft(endmask, rightShift))
+ {
+ bits = *psrc;
+ bits1 |= BitRight(bits, rightShift);
+ }
+ *pdst = MROP_MASK (bits1, *pdst, endmask);
+ }
+ }
+ }
+#endif /* (PSZ == 24 && MROP == 0) */
+#endif /* DO_UNALIGNED_BITBLT */
+
+ }
+ }
+#endif /* ! DO_MEMCPY */
+ else /* xdir == -1 */
+ {
+#if PSZ == 24 && MROP == 0
+ xoffSrc = (-(pptSrc->x + w)) & PAM;
+ xoffDst = (-pbox->x2) & PAM;
+#if 1
+ if(xoffSrc != xoffDst /* Alignments must be same. */
+ || ((widthDstBytes & PAM) != (widthSrcBytes & PAM) && h > 1))
+#else
+ if(1)
+#endif
+ /* Width also must be same, if hight > 1 */
+ {
+ /* ...otherwise, pixel by pixel operation */
+ while (h--)
+ {
+ register int i, si, sii, di;
+
+ for (i = 0, si = pptSrc->x + w - 1, di = pbox->x2 - 1;
+ i < w;
+ i++, si--, di--) {
+ psrc = psrcLine + ((si * BYPP) >> P2WSH);
+ pdst = pdstLine + ((di * BYPP) >> P2WSH);
+ sii = (si & PAM);
+ MROP_SOLID24P(psrc, pdst, sii, di);
+ }
+ psrcLine += widthSrc;
+ pdstLine += widthDst;
+ }
+ }else
+#endif /* MROP == 0 && PSZ == 24 */
+ {
+
+#if PSZ == 24
+#if MROP == 0
+ /* already calculated */
+#else
+ xoffSrc = (pptSrc->x + w) & PAM;
+ xoffDst = pbox->x2 & PAM;
+#endif
+ pdstLine += ((pbox->x2 * BYPP - 1) >> P2WSH) + 1;
+ psrcLine += (((pptSrc->x+w) * BYPP - 1) >> P2WSH) + 1;
+#else
+ xoffSrc = (pptSrc->x + w - 1) & PIM;
+ xoffDst = (pbox->x2 - 1) & PIM;
+ pdstLine += ((pbox->x2-1) >> PWSH) + 1;
+ psrcLine += ((pptSrc->x+w - 1) >> PWSH) + 1;
+#endif
+#ifdef DO_UNALIGNED_BITBLT
+#if PSZ == 24
+ nl = xoffDst - xoffSrc;
+#else
+ nl = xoffSrc - xoffDst;
+#endif
+ psrcLine = (CfbBits *)
+ (((unsigned char *) psrcLine) + nl);
+#else
+#if PSZ == 24 && MROP == 0
+ /* already satisfied */
+#else
+ if (xoffSrc == xoffDst)
+#endif
+#endif
+ {
+ while (h--)
+ {
+#if PSZ == 24 && MROP == 0
+ register int index;
+ register int im3;
+#endif /* PSZ == 24 && MROP == 0 */
+ psrc = psrcLine;
+ pdst = pdstLine;
+ pdstLine += widthDst;
+ psrcLine += widthSrc;
+#if PSZ == 24 && MROP == 0
+ index = (int)(pdst - pdstBase);
+#endif /* PSZ == 24 && MROP == 0 */
+
+ if (endmask)
+ {
+ pdst--;
+ psrc--;
+#if PSZ == 24 && MROP == 0
+ index--;
+ im3 = index % 3;
+ *pdst = DoMaskMergeRop24u(*psrc, *pdst, endmask, im3);
+#else /* !(PSZ == 24 && MROP == 0) */
+ *pdst = MROP_MASK (*psrc, *pdst, endmask);
+#endif /* PSZ == 24 && MROP == 0 */
+ }
+ nl = nlMiddle;
+#ifdef LARGE_INSTRUCTION_CACHE
+#ifdef FAST_CONSTANT_OFFSET_MODE
+ psrc -= nl & (UNROLL - 1);
+ pdst -= nl & (UNROLL - 1);
+
+#if PSZ == 24 && MROP == 0
+#define BodyOdd(n) pdst[n-1] = DoMergeRop24u(psrc[n-1], pdst[n-1], ((int)(pdst - (n - 1) -pdstBase)) % 3);
+#else /* !(PSZ == 24 && MROP == 0) */
+#define BodyOdd(n) pdst[n-1] = MROP_SOLID (psrc[n-1], pdst[n-1]);
+#endif /* PSZ == 24 && MROP == 0 */
+
+#define BodyEven(n) BodyOdd(n)
+
+#define LoopReset \
+pdst -= UNROLL;\
+psrc -= UNROLL;
+
+#else
+
+#if PSZ == 24 && MROP == 0
+#define BodyOdd(n) --pdst; --psrc; --index; im3 = index % 3;*pdst = DoMergeRop24u(*psrc, *pdst, im3);
+#else /* !(PSZ == 24 && MROP == 0) */
+#define BodyOdd(n) --pdst; --psrc; *pdst = MROP_SOLID(*psrc, *pdst);
+#endif /* PSZ == 24 && MROP == 0 */
+#define BodyEven(n) BodyOdd(n)
+#define LoopReset ;
+
+#endif
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+#if PSZ == 24 && MROP == 0
+ DuffL(nl,label3,
+ --pdst; --psrc; --index; im3= index%3;*pdst = DoMergeRop24u(*psrc, *pdst, im3);)
+#else /* !(PSZ == 24 && MROP == 0) */
+ DuffL(nl,label3,
+ --pdst; --psrc; *pdst = MROP_SOLID (*psrc, *pdst);)
+#endif /* PSZ == 24 && MROP == 0 */
+#endif
+
+ if (startmask)
+ {
+ --pdst;
+ --psrc;
+#if PSZ == 24 && MROP == 0
+ *pdst = DoMaskMergeRop24u(*psrc, *pdst, startmask, (int)(pdst - pdstBase) % 3);
+#else /* !(PSZ == 24 && MROP == 0) */
+ *pdst = MROP_MASK(*psrc, *pdst, startmask);
+#endif /* PSZ == 24 && MROP == 0 */
+ }
+ }
+ }
+#ifndef DO_UNALIGNED_BITBLT
+#if PSZ == 24 && MROP == 0
+ /* can not happen */
+#else /* !( PSZ == 24 && MROP == 0) */
+ else
+ {
+ if (xoffDst > xoffSrc)
+ {
+#if PSZ == 24
+ leftShift = (xoffDst - xoffSrc) << 3;
+ rightShift = PGSZ - leftShift;
+#else
+#if PGSZ == 32
+ rightShift = (xoffDst - xoffSrc) << (5 - PWSH);
+#else /* PGSZ == 64 */
+ rightShift = (xoffDst - xoffSrc) << (6 - PWSH);
+#endif /* PGSZ */
+ leftShift = PGSZ - rightShift;
+#endif
+ }
+ else
+ {
+#if PSZ == 24
+ rightShift = (xoffSrc - xoffDst) << 3;
+ leftShift = PGSZ - rightShift;
+#else
+#if PGSZ == 32
+ leftShift = (xoffSrc - xoffDst) << (5 - PWSH);
+#else /* PGSZ == 64 */
+ leftShift = (xoffSrc - xoffDst) << (6 - PWSH);
+#endif /* PGSZ */
+ rightShift = PGSZ - leftShift;
+#endif
+ }
+ while (h--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ pdstLine += widthDst;
+ psrcLine += widthSrc;
+ bits = 0;
+#if PSZ == 24
+ if (xoffSrc > xoffDst)
+#else
+ if (xoffDst > xoffSrc)
+#endif
+ bits = *--psrc;
+ if (endmask)
+ {
+ bits1 = BitRight(bits, rightShift);
+ bits = *--psrc;
+ bits1 |= BitLeft(bits, leftShift);
+ pdst--;
+ *pdst = MROP_MASK(bits1, *pdst, endmask);
+ }
+ nl = nlMiddle;
+#ifdef LARGE_INSTRUCTION_CACHE
+ bits1 = bits;
+#ifdef FAST_CONSTANT_OFFSET_MODE
+ psrc -= nl & (UNROLL - 1);
+ pdst -= nl & (UNROLL - 1);
+
+#define BodyOdd(n) \
+bits = psrc[n-1]; \
+pdst[n-1] = MROP_SOLID(BitRight(bits1, rightShift) | BitLeft(bits, leftShift),pdst[n-1]);
+
+#define BodyEven(n) \
+bits1 = psrc[n-1]; \
+pdst[n-1] = MROP_SOLID(BitRight(bits, rightShift) | BitLeft(bits1, leftShift),pdst[n-1]);
+
+#define LoopReset \
+pdst -= UNROLL; \
+psrc -= UNROLL;
+
+#else
+
+#define BodyOdd(n) \
+bits = *--psrc; --pdst; \
+*pdst = MROP_SOLID(BitRight(bits1, rightShift) | BitLeft(bits, leftShift),*pdst);
+
+#define BodyEven(n) \
+bits1 = *--psrc; --pdst; \
+*pdst = MROP_SOLID(BitRight(bits, rightShift) | BitLeft(bits1, leftShift),*pdst);
+
+#define LoopReset ;
+
+#endif
+
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+ DuffL (nl, label4,
+ bits1 = BitRight(bits, rightShift);
+ bits = *--psrc;
+ --pdst;
+ *pdst = MROP_SOLID(bits1 | BitLeft(bits, leftShift),*pdst);
+ )
+#endif
+
+ if (startmask)
+ {
+ bits1 = BitRight(bits, rightShift);
+ if (BitRight (startmask, leftShift))
+ {
+ bits = *--psrc;
+ bits1 |= BitLeft(bits, leftShift);
+ }
+ --pdst;
+ *pdst = MROP_MASK(bits1, *pdst, startmask);
+ }
+ }
+ }
+#endif /* PSZ == 24 && MROP == 0 */
+#endif
+ }
+ }
+ pbox++;
+ pptSrc++;
+ }
+ if (pboxNew2)
+ {
+ DEALLOCATE_LOCAL(pptNew2);
+ DEALLOCATE_LOCAL(pboxNew2);
+ }
+ if (pboxNew1)
+ {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(pboxNew1);
+ }
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbbres.c b/nx-X11/programs/Xserver/cfb/cfbbres.c
new file mode 100644
index 000000000..2251fb885
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbbres.c
@@ -0,0 +1,342 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfbbres.c,v 3.4 2001/01/17 22:36:34 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: cfbbres.c,v 1.4 2001/02/09 02:04:37 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "servermd.h"
+#include "miline.h"
+
+/* Solid bresenham line */
+/* NOTES
+ e2 is used less often than e1, so it's not in a register
+*/
+
+void
+cfbBresS(rop, and, xor, addrl, nlwidth, signdx, signdy, axis, x1, y1, e, e1,
+ e2, len)
+ int rop;
+ CfbBits and, xor;
+ CfbBits *addrl; /* pointer to base of bitmap */
+ int nlwidth; /* width in longwords of bitmap */
+ register int signdx;
+ int signdy; /* signs of directions */
+ int axis; /* major axis (Y_AXIS or X_AXIS) */
+ int x1, y1; /* initial point */
+ register int e; /* error accumulator */
+ register int e1; /* bresenham increments */
+ int e2;
+ int len; /* length of line */
+{
+ register int e3 = e2-e1;
+#if PSZ == 24
+ CfbBits piQxelXor[3],piQxelAnd[3];
+ char *addrb;
+ int nlwidth3, signdx3;
+#endif
+#ifdef PIXEL_ADDR
+ register PixelType *addrp; /* Pixel pointer */
+
+ if (len == 0)
+ return;
+ /* point to first point */
+ nlwidth <<= PWSH;
+#if PSZ == 24
+ addrp = (PixelType *)(addrl) + (y1 * nlwidth);
+ addrb = (char *)addrp + x1 * 3;
+
+ piQxelXor[0] = (xor << 24) | xor;
+ piQxelXor[1] = (xor << 16)| (xor >> 8);
+ piQxelXor[2] = (xor << 8) | (xor >> 16);
+ piQxelAnd[0] = (and << 24) | and;
+ piQxelAnd[1] = (and << 16)| (and >> 8);
+ piQxelAnd[2] = (and << 8) | (and >> 16);
+#else
+ addrp = (PixelType *)(addrl) + (y1 * nlwidth) + x1;
+#endif
+ if (signdy < 0)
+ nlwidth = -nlwidth;
+ e = e-e1; /* to make looping easier */
+#if PSZ == 24
+ nlwidth3 = nlwidth * sizeof (CfbBits);
+ signdx3 = signdx * 3;
+#endif
+
+ if (axis == Y_AXIS)
+ {
+ int t;
+
+ t = nlwidth;
+ nlwidth = signdx;
+ signdx = t;
+#if PSZ == 24
+ t = nlwidth3;
+ nlwidth3 = signdx3;
+ signdx3 = t;
+#endif
+ }
+ if (rop == GXcopy)
+ {
+ --len;
+#if PSZ == 24
+#define body_copy \
+ addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
+ switch((unsigned long)addrb & 3){ \
+ case 0: \
+ *addrp = ((*addrp)&0xFF000000)|(piQxelXor[0] & 0xFFFFFF); \
+ break; \
+ case 1: \
+ *addrp = ((*addrp)&0xFF)|(piQxelXor[2] & 0xFFFFFF00); \
+ break; \
+ case 3: \
+ *addrp = ((*addrp)&0xFFFFFF)|(piQxelXor[0] & 0xFF000000); \
+ *(addrp+1) = ((*(addrp+1))&0xFFFF0000)|(piQxelXor[1] & 0xFFFF); \
+ break; \
+ case 2: \
+ *addrp = ((*addrp)&0xFFFF)|(piQxelXor[1] & 0xFFFF0000); \
+ *(addrp+1) = ((*(addrp+1))&0xFFFFFF00)|(piQxelXor[2] & 0xFF); \
+ break; \
+ }
+#define body {\
+ body_copy \
+ addrb += signdx3; \
+ e += e1; \
+ if (e >= 0) \
+ { \
+ addrb += nlwidth3; \
+ e += e3; \
+ } \
+ }
+#else /* PSZ == 24 */
+#define body {\
+ *addrp = xor; \
+ addrp += signdx; \
+ e += e1; \
+ if (e >= 0) \
+ { \
+ addrp += nlwidth; \
+ e += e3; \
+ } \
+ }
+#endif /* PSZ == 24 */
+ while (len >= 4)
+ {
+ body body body body
+ len -= 4;
+ }
+ switch (len)
+ {
+ case 3: body case 2: body case 1: body
+ }
+#undef body
+#if PSZ == 24
+ body_copy
+# undef body_copy
+#else
+ *addrp = xor;
+#endif
+ }
+ else /* not GXcopy */
+ {
+ while(len--)
+ {
+#if PSZ == 24
+ addrp = (PixelType *)((unsigned long)addrb & ~0x03);
+ switch((unsigned long)addrb & 3){
+ case 0:
+ *addrp = (*addrp & (piQxelAnd[0]|0xFF000000))
+ ^ (piQxelXor[0] & 0xFFFFFF);
+ break;
+ case 1:
+ *addrp = (*addrp & (piQxelAnd[2]|0xFF))
+ ^ (piQxelXor[2] & 0xFFFFFF00);
+ break;
+ case 3:
+ *addrp = (*addrp & (piQxelAnd[0]|0xFFFFFF))
+ ^ (piQxelXor[0] & 0xFF000000);
+ *(addrp+1) = (*(addrp+1) & (piQxelAnd[1]|0xFFFF0000))
+ ^ (piQxelXor[1] & 0xFFFF);
+ break;
+ case 2:
+ *addrp = (*addrp & (piQxelAnd[1]|0xFFFF))
+ ^ (piQxelXor[1] & 0xFFFF0000);
+ *(addrp+1) = (*(addrp+1) & (piQxelAnd[2]|0xFFFFFF00))
+ ^ (piQxelXor[2] & 0xFF);
+ break;
+ }
+ e += e1;
+ if (e >= 0)
+ {
+ addrb += nlwidth3;
+ e += e3;
+ }
+ addrb += signdx3;
+#else /* PSZ == 24 */
+ *addrp = DoRRop (*addrp, and, xor);
+ e += e1;
+ if (e >= 0)
+ {
+ addrp += nlwidth;
+ e += e3;
+ }
+ addrp += signdx;
+#endif /* PSZ == 24 */
+ }
+ }
+#else /* !PIXEL_ADDR */
+ register CfbBits tmp, bit;
+ CfbBits leftbit, rightbit;
+
+ /* point to longword containing first point */
+#if PSZ == 24
+ addrl = (addrl + (y1 * nlwidth) + ((x1 * 3) >>2);
+#else
+ addrl = (addrl + (y1 * nlwidth) + (x1 >> PWSH));
+#endif
+ if (signdy < 0)
+ nlwidth = -nlwidth;
+ e = e-e1; /* to make looping easier */
+
+ leftbit = cfbmask[0];
+#if PSZ == 24
+ rightbit = cfbmask[(PPW-1)<<1];
+ bit = cfbmask[(x1 & 3)<<1];
+#else
+ rightbit = cfbmask[PPW-1];
+ bit = cfbmask[x1 & PIM];
+#endif
+
+ if (axis == X_AXIS)
+ {
+ if (signdx > 0)
+ {
+ while (len--)
+ {
+ *addrl = DoMaskRRop (*addrl, and, xor, bit);
+ bit = SCRRIGHT(bit,1);
+ e += e1;
+ if (e >= 0)
+ {
+ addrl += nlwidth;
+ e += e3;
+ }
+ if (!bit)
+ {
+ bit = leftbit;
+ addrl++;
+ }
+ }
+ }
+ else
+ {
+ while (len--)
+ {
+ *addrl = DoMaskRRop (*addrl, and, xor, bit);
+ e += e1;
+ bit = SCRLEFT(bit,1);
+ if (e >= 0)
+ {
+ addrl += nlwidth;
+ e += e3;
+ }
+ if (!bit)
+ {
+ bit = rightbit;
+ addrl--;
+ }
+ }
+ }
+ } /* if X_AXIS */
+ else
+ {
+ if (signdx > 0)
+ {
+ while(len--)
+ {
+ *addrl = DoMaskRRop (*addrl, and, xor, bit);
+ e += e1;
+ if (e >= 0)
+ {
+ bit = SCRRIGHT(bit,1);
+ if (!bit)
+ {
+ bit = leftbit;
+ addrl++;
+ }
+ e += e3;
+ }
+ addrl += nlwidth;
+ }
+ }
+ else
+ {
+ while(len--)
+ {
+ *addrl = DoMaskRRop (*addrl, and, xor, bit);
+ e += e1;
+ if (e >= 0)
+ {
+ bit = SCRLEFT(bit,1);
+ if (!bit)
+ {
+ bit = rightbit;
+ addrl--;
+ }
+ e += e3;
+ }
+ addrl += nlwidth;
+ }
+ }
+ } /* else Y_AXIS */
+#endif
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbbresd.c b/nx-X11/programs/Xserver/cfb/cfbbresd.c
new file mode 100644
index 000000000..cc27eb5dc
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbbresd.c
@@ -0,0 +1,406 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfbbresd.c,v 3.5 2001/01/17 22:36:34 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: cfbbresd.c,v 1.4 2001/02/09 02:04:37 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "miline.h"
+
+/* Dashed bresenham line */
+
+void
+cfbBresD(rrops,
+ pdashIndex, pDash, numInDashList, pdashOffset, isDoubleDash,
+ addrl, nlwidth,
+ signdx, signdy, axis, x1, y1, e, e1, e2, len)
+ cfbRRopPtr rrops;
+ int *pdashIndex; /* current dash */
+ unsigned char *pDash; /* dash list */
+ int numInDashList; /* total length of dash list */
+ int *pdashOffset; /* offset into current dash */
+ int isDoubleDash;
+ CfbBits *addrl; /* pointer to base of bitmap */
+ int nlwidth; /* width in longwords of bitmap */
+ int signdx, signdy; /* signs of directions */
+ int axis; /* major axis (Y_AXIS or X_AXIS) */
+ int x1, y1; /* initial point */
+ register int e; /* error accumulator */
+ register int e1; /* bresenham increments */
+ int e2;
+ int len; /* length of line */
+{
+#ifdef PIXEL_ADDR
+ register PixelType *addrp;
+#endif
+ register int e3 = e2-e1;
+ int dashIndex;
+ int dashOffset;
+ int dashRemaining;
+ CfbBits xorFg, andFg, xorBg, andBg;
+ Bool isCopy;
+ int thisDash;
+#if PSZ == 24
+ CfbBits xorPiQxlFg[3], andPiQxlFg[3], xorPiQxlBg[3], andPiQxlBg[3];
+ char *addrb;
+ int signdx3, signdy3;
+#endif
+
+ dashOffset = *pdashOffset;
+ dashIndex = *pdashIndex;
+ isCopy = (rrops[0].rop == GXcopy && rrops[1].rop == GXcopy);
+#if PSZ == 24
+ xorFg = rrops[0].xor & 0xffffff;
+ andFg = rrops[0].and & 0xffffff;
+ xorBg = rrops[1].xor & 0xffffff;
+ andBg = rrops[1].and & 0xffffff;
+ xorPiQxlFg[0] = xorFg | (xorFg << 24);
+ xorPiQxlFg[1] = (xorFg >> 8) | (xorFg << 16);
+ xorPiQxlFg[2] = (xorFg >> 16) | (xorFg << 8);
+ andPiQxlFg[0] = andFg | (andFg << 24);
+ andPiQxlFg[1] = (andFg >> 8) | (andFg << 16);
+ andPiQxlFg[2] = (andFg >> 16) | (andFg << 8);
+ xorPiQxlBg[0] = xorBg | (xorBg << 24);
+ xorPiQxlBg[1] = (xorBg >> 8) | (xorBg << 16);
+ xorPiQxlBg[2] = (xorBg >> 16) | (xorBg << 8);
+ andPiQxlBg[0] = andBg | (andBg << 24);
+ andPiQxlBg[1] = (andBg >> 8) | (andBg << 16);
+ andPiQxlBg[2] = (andFg >> 16) | (andBg << 8);
+#else
+ xorFg = rrops[0].xor;
+ andFg = rrops[0].and;
+ xorBg = rrops[1].xor;
+ andBg = rrops[1].and;
+#endif
+ dashRemaining = pDash[dashIndex] - dashOffset;
+ if ((thisDash = dashRemaining) >= len)
+ {
+ thisDash = len;
+ dashRemaining -= len;
+ }
+ e = e-e1; /* to make looping easier */
+
+#define BresStep(minor,major) {if ((e += e1) >= 0) { e += e3; minor; } major;}
+
+#define NextDash {\
+ dashIndex++; \
+ if (dashIndex == numInDashList) \
+ dashIndex = 0; \
+ dashRemaining = pDash[dashIndex]; \
+ if ((thisDash = dashRemaining) >= len) \
+ { \
+ dashRemaining -= len; \
+ thisDash = len; \
+ } \
+}
+
+#ifdef PIXEL_ADDR
+
+#if PSZ == 24
+#define Loop(store) while (thisDash--) {\
+ store; \
+ BresStep(addrb+=signdy3,addrb+=signdx3) \
+ }
+ /* point to first point */
+ nlwidth <<= PWSH;
+ addrp = (PixelType *)(addrl) + (y1 * nlwidth);
+ addrb = (char *)addrp + x1 * 3;
+
+#else
+#define Loop(store) while (thisDash--) {\
+ store; \
+ BresStep(addrp+=signdy,addrp+=signdx) \
+ }
+ /* point to first point */
+ nlwidth <<= PWSH;
+ addrp = (PixelType *)(addrl) + (y1 * nlwidth) + x1;
+#endif
+ signdy *= nlwidth;
+#if PSZ == 24
+ signdx3 = signdx * 3;
+ signdy3 = signdy * sizeof (CfbBits);
+#endif
+ if (axis == Y_AXIS)
+ {
+ int t;
+
+ t = signdx;
+ signdx = signdy;
+ signdy = t;
+#if PSZ == 24
+ t = signdx3;
+ signdx3 = signdy3;
+ signdy3 = t;
+#endif
+ }
+
+ if (isCopy)
+ {
+#if PSZ == 24
+#define body_copy(pix) { \
+ addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
+ switch((unsigned long)addrb & 3){ \
+ case 0: \
+ *addrp = (*addrp & 0xFF000000)|((pix)[0] & 0xFFFFFF); \
+ break; \
+ case 1: \
+ *addrp = (*addrp & 0xFF)|((pix)[2] & 0xFFFFFF00); \
+ break; \
+ case 3: \
+ *addrp = (*addrp & 0xFFFFFF)|((pix)[0] & 0xFF000000); \
+ *(addrp+1) = (*(addrp+1) & 0xFFFF0000)|((pix)[1] & 0xFFFF); \
+ break; \
+ case 2: \
+ *addrp = (*addrp & 0xFFFF)|((pix)[1] & 0xFFFF0000); \
+ *(addrp+1) = (*(addrp+1) & 0xFFFFFF00)|((pix)[2] & 0xFF); \
+ break; \
+ } \
+}
+#endif /* PSZ == 24 */
+
+ for (;;)
+ {
+ len -= thisDash;
+ if (dashIndex & 1) {
+ if (isDoubleDash) {
+#if PSZ == 24
+ Loop(body_copy(xorPiQxlBg))
+#else
+ Loop(*addrp = xorBg)
+#endif
+ } else {
+ Loop(;)
+ }
+ } else {
+#if PSZ == 24
+ Loop(body_copy(xorPiQxlFg))
+#else
+ Loop(*addrp = xorFg)
+#endif
+ }
+ if (!len)
+ break;
+ NextDash
+ }
+#undef body_copy
+ }
+ else
+ {
+#define body_set(and, xor) { \
+ addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
+ switch((unsigned long)addrb & 3){ \
+ case 0: \
+ *addrp = (*addrp & ((and)[0]|0xFF000000)) ^ ((xor)[0] & 0xFFFFFF); \
+ break; \
+ case 1: \
+ *addrp = (*addrp & ((and)[2]|0xFF)) ^ ((xor)[2] & 0xFFFFFF00); \
+ break; \
+ case 3: \
+ *addrp = (*addrp & ((and)[0]|0xFFFFFF)) ^ ((xor)[0] & 0xFF000000); \
+ *(addrp+1)=(*(addrp+1)&((and)[1]|0xFFFF0000)) ^ ((xor)[1]&0xFFFF); \
+ break; \
+ case 2: \
+ *addrp = (*addrp & ((and)[1]|0xFFFF)) ^ ((xor)[1] & 0xFFFF0000); \
+ *(addrp+1)=(*(addrp+1)&((and)[2]|0xFFFFFF00)) ^ ((xor)[2] & 0xFF); \
+ break; \
+ } \
+}
+
+ for (;;)
+ {
+ len -= thisDash;
+ if (dashIndex & 1) {
+ if (isDoubleDash) {
+#if PSZ == 24
+ Loop(body_set(andPiQxlBg, xorPiQxlBg))
+#else
+ Loop(*addrp = DoRRop(*addrp,andBg, xorBg))
+#endif
+ } else {
+ Loop(;)
+ }
+ } else {
+#if PSZ == 24
+ Loop(body_set(andPiQxlFg, xorPiQxlFg))
+#else
+ Loop(*addrp = DoRRop(*addrp,andFg, xorFg))
+#endif
+ }
+ if (!len)
+ break;
+ NextDash
+ }
+#undef body_set
+ }
+#else /* !PIXEL_ADDR */
+ {
+ register CfbBits tmp;
+ CfbBits startbit, bit;
+
+ /* point to longword containing first point */
+#if PSZ == 24
+ addrl = (addrl + (y1 * nlwidth) + ((x1*3) >> 2);
+#else
+ addrl = (addrl + (y1 * nlwidth) + (x1 >> PWSH));
+#endif
+ signdy = signdy * nlwidth;
+
+ if (signdx > 0)
+ startbit = cfbmask[0];
+ else
+#if PSZ == 24
+ startbit = cfbmask[(PPW-1)<<1];
+ bit = cfbmask[(x1 & 3)<<1];
+#else
+ startbit = cfbmask[PPW-1];
+ bit = cfbmask[x1 & PIM];
+#endif
+
+#if PSZ == 24
+#define X_Loop(store) while(thisDash--) {\
+ store; \
+ BresStep(addrl += signdy, \
+ if (signdx > 0) \
+ bit = SCRRIGHT(bit,1); \
+ else \
+ bit = SCRLEFT(bit,1); \
+ if (!bit) \
+ { \
+ bit = startbit; \
+ addrl += signdx; \
+ }) \
+ }
+#define Y_Loop(store) while(thisDash--) {\
+ store; \
+ BresStep(if (signdx > 0) \
+ bit = SCRRIGHT(bit,1); \
+ else \
+ bit = SCRLEFT(bit,1); \
+ if (!bit) \
+ { \
+ bit = startbit; \
+ addrl += signdx; \
+ }, \
+ addrl += signdy) \
+ }
+#else
+#define X_Loop(store) while(thisDash--) {\
+ store; \
+ BresStep(addrl += signdy, \
+ if (signdx > 0) \
+ bit = SCRRIGHT(bit,1); \
+ else \
+ bit = SCRLEFT(bit,1); \
+ if (!bit) \
+ { \
+ bit = startbit; \
+ addrl += signdx; \
+ }) \
+ }
+#define Y_Loop(store) while(thisDash--) {\
+ store; \
+ BresStep(if (signdx > 0) \
+ bit = SCRRIGHT(bit,1); \
+ else \
+ bit = SCRLEFT(bit,1); \
+ if (!bit) \
+ { \
+ bit = startbit; \
+ addrl += signdx; \
+ }, \
+ addrl += signdy) \
+ }
+#endif
+
+ if (axis == X_AXIS)
+ {
+ for (;;)
+ {
+ len -= thisDash;
+ if (dashIndex & 1) {
+ if (isDoubleDash) {
+ X_Loop(*addrl = DoMaskRRop(*addrl, andBg, xorBg, bit));
+ } else {
+ X_Loop(;)
+ }
+ } else {
+ X_Loop(*addrl = DoMaskRRop(*addrl, andFg, xorFg, bit));
+ }
+ if (!len)
+ break;
+ NextDash
+ }
+ } /* if X_AXIS */
+ else
+ {
+ for (;;)
+ {
+ len -= thisDash;
+ if (dashIndex & 1) {
+ if (isDoubleDash) {
+ Y_Loop(*addrl = DoMaskRRop(*addrl, andBg, xorBg, bit));
+ } else {
+ Y_Loop(;)
+ }
+ } else {
+ Y_Loop(*addrl = DoMaskRRop(*addrl, andFg, xorFg, bit));
+ }
+ if (!len)
+ break;
+ NextDash
+ }
+ } /* else Y_AXIS */
+ }
+#endif
+ *pdashIndex = dashIndex;
+ *pdashOffset = pDash[dashIndex] - dashRemaining;
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbbstore.c b/nx-X11/programs/Xserver/cfb/cfbbstore.c
new file mode 100644
index 000000000..64adc4050
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbbstore.c
@@ -0,0 +1,145 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfbbstore.c,v 1.4 1999/01/31 12:21:41 dawes Exp $ */
+/*-
+ * cfbbstore.c --
+ * Functions required by the backing-store implementation in MI.
+ *
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+/* $Xorg: cfbbstore.c,v 1.3 2000/08/17 19:48:13 cpqbld Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "cfb.h"
+#include <X11/X.h>
+#include "mibstore.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * cfbSaveAreas --
+ * Function called by miSaveAreas to actually fetch the areas to be
+ * saved into the backing pixmap. This is very simple to do, since
+ * cfbDoBitblt is designed for this very thing. The region to save is
+ * already destination-relative and we're given the offset to the
+ * window origin, so we have only to create an array of points of the
+ * u.l. corners of the boxes in the region translated to the screen
+ * coordinate system and fetch the screen pixmap out of its devPrivate
+ * field....
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Data are copied from the screen into the pixmap.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+cfbSaveAreas(pPixmap, prgnSave, xorg, yorg, pWin)
+ PixmapPtr pPixmap; /* Backing pixmap */
+ RegionPtr prgnSave; /* Region to save (pixmap-relative) */
+ int xorg; /* X origin of region */
+ int yorg; /* Y origin of region */
+ WindowPtr pWin;
+{
+ register DDXPointPtr pPt;
+ DDXPointPtr pPtsInit;
+ register BoxPtr pBox;
+ register int i;
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ PixmapPtr pScrPix;
+
+ i = REGION_NUM_RECTS(prgnSave);
+ pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec));
+ if (!pPtsInit)
+ return;
+
+ pBox = REGION_RECTS(prgnSave);
+ pPt = pPtsInit;
+ while (--i >= 0) {
+ pPt->x = pBox->x1 + xorg;
+ pPt->y = pBox->y1 + yorg;
+ pPt++;
+ pBox++;
+ }
+
+ pScrPix = (*pScreen->GetWindowPixmap)(pWin);
+
+
+ cfbDoBitbltCopy((DrawablePtr) pScrPix, (DrawablePtr)pPixmap,
+ GXcopy, prgnSave, pPtsInit, ~0L);
+
+ DEALLOCATE_LOCAL (pPtsInit);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * cfbRestoreAreas --
+ * Function called by miRestoreAreas to actually fetch the areas to be
+ * restored from the backing pixmap. This is very simple to do, since
+ * cfbDoBitblt is designed for this very thing. The region to restore is
+ * already destination-relative and we're given the offset to the
+ * window origin, so we have only to create an array of points of the
+ * u.l. corners of the boxes in the region translated to the pixmap
+ * coordinate system and fetch the screen pixmap out of its devPrivate
+ * field....
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Data are copied from the pixmap into the screen.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+cfbRestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin)
+ PixmapPtr pPixmap; /* Backing pixmap */
+ RegionPtr prgnRestore; /* Region to restore (screen-relative)*/
+ int xorg; /* X origin of window */
+ int yorg; /* Y origin of window */
+ WindowPtr pWin;
+{
+ register DDXPointPtr pPt;
+ DDXPointPtr pPtsInit;
+ register BoxPtr pBox;
+ register int i;
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ PixmapPtr pScrPix;
+
+ i = REGION_NUM_RECTS(prgnRestore);
+ pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i*sizeof(DDXPointRec));
+ if (!pPtsInit)
+ return;
+
+ pBox = REGION_RECTS(prgnRestore);
+ pPt = pPtsInit;
+ while (--i >= 0) {
+ pPt->x = pBox->x1 - xorg;
+ pPt->y = pBox->y1 - yorg;
+ pPt++;
+ pBox++;
+ }
+
+ pScrPix = (*pScreen->GetWindowPixmap)(pWin);
+
+ cfbDoBitbltCopy((DrawablePtr)pPixmap, (DrawablePtr) pScrPix,
+ GXcopy, prgnRestore, pPtsInit, ~0L);
+
+ DEALLOCATE_LOCAL (pPtsInit);
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbcmap.c b/nx-X11/programs/Xserver/cfb/cfbcmap.c
new file mode 100644
index 000000000..a7777eda8
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbcmap.c
@@ -0,0 +1,121 @@
+/* $Xorg: cfbcmap.c,v 1.3 2000/08/17 19:48:13 cpqbld Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/cfb/cfbcmap.c,v 3.12 2000/02/12 03:39:23 dawes Exp $ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "colormapst.h"
+#include "resource.h"
+#include "micmap.h"
+#include "cfb.h"
+
+int
+cfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
+{
+ return miListInstalledColormaps(pScreen, pmaps);
+}
+
+void
+cfbInstallColormap(ColormapPtr pmap)
+{
+ miInstallColormap(pmap);
+}
+
+void
+cfbUninstallColormap(ColormapPtr pmap)
+{
+ miUninstallColormap(pmap);
+}
+
+void
+cfbResolveColor(unsigned short *pred,
+ unsigned short *pgreen,
+ unsigned short *pblue,
+ VisualPtr pVisual)
+{
+ miResolveColor(pred, pgreen, pblue, pVisual);
+}
+
+Bool
+cfbInitializeColormap(ColormapPtr pmap)
+{
+ return miInitializeColormap(pmap);
+}
+
+int
+cfbExpandDirectColors (ColormapPtr pmap, int ndef,
+ xColorItem *indefs, xColorItem *outdefs)
+{
+ return miExpandDirectColors(pmap, ndef, indefs, outdefs);
+}
+
+Bool
+cfbCreateDefColormap(ScreenPtr pScreen)
+{
+ return miCreateDefColormap(pScreen);
+}
+
+void
+cfbClearVisualTypes(void)
+{
+ miClearVisualTypes();
+}
+
+Bool
+cfbSetVisualTypes (int depth, int visuals, int bitsPerRGB)
+{
+ return miSetVisualTypes(depth, visuals, bitsPerRGB, -1);
+}
+
+/*
+ * Given a list of formats for a screen, create a list
+ * of visuals and depths for the screen which coorespond to
+ * the set which can be used with this version of cfb.
+ */
+
+Bool
+cfbInitVisuals (VisualPtr *visualp,
+ DepthPtr *depthp,
+ int *nvisualp,
+ int *ndepthp,
+ int *rootDepthp,
+ VisualID *defaultVisp,
+ unsigned long sizes,
+ int bitsPerRGB)
+{
+ return miInitVisuals(visualp, depthp, nvisualp, ndepthp, rootDepthp,
+ defaultVisp, sizes, bitsPerRGB, -1);
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbcppl.c b/nx-X11/programs/Xserver/cfb/cfbcppl.c
new file mode 100644
index 000000000..037a516f2
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbcppl.c
@@ -0,0 +1,490 @@
+/*
+ * $TOG: cfb8cppl.c /main/16 1998/02/09 14:04:13 kaleb $
+ *
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/programs/Xserver/cfb/cfbcppl.c,v 1.6 2001/12/14 19:59:22 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "cfb.h"
+#if PSZ == 8
+#undef PSZ /* for maskbits.h */
+#include "maskbits.h"
+#define PSZ 8
+#include "mergerop.h"
+#else /* PSZ==8 */
+#include "cfbtab.h" /* provides starttab, endttab, partmasks */
+#endif /* PSZ==8 */
+
+
+void
+cfbCopyImagePlane(
+ DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ int rop,
+ RegionPtr prgnDst,
+ DDXPointPtr pptSrc,
+ unsigned long planemask)
+{
+ /* note: there must be some sort of trick behind,
+ passing a planemask value with all bits set
+ whilst using the current planemask for the bitPlane value. */
+#if PSZ == 8
+ cfbCopyPlane8to1 (pSrcDrawable, pDstDrawable, rop, prgnDst, pptSrc,
+ (unsigned long) ~0L, planemask);
+#endif
+#if PSZ == 16
+ cfbCopyPlane16to1 (pSrcDrawable, pDstDrawable, rop, prgnDst, pptSrc,
+ (unsigned long) ~0L, planemask);
+#endif
+#if PSZ == 24
+ cfbCopyPlane24to1 (pSrcDrawable, pDstDrawable, rop, prgnDst, pptSrc,
+ (unsigned long) ~0L, planemask);
+#endif
+#if PSZ == 32
+ cfbCopyPlane32to1 (pSrcDrawable, pDstDrawable, rop, prgnDst, pptSrc,
+ (unsigned long) ~0L, planemask);
+#endif
+}
+
+#if PSZ == 8
+
+#if BITMAP_BIT_ORDER == MSBFirst
+#define LeftMost (MFB_PPW-1)
+#define StepBit(bit, inc) ((bit) -= (inc))
+#else
+#define LeftMost 0
+#define StepBit(bit, inc) ((bit) += (inc))
+#endif
+
+#define GetBits(psrc, nBits, curBit, bitPos, bits) {\
+ bits = 0; \
+ while (nBits--) \
+ { \
+ bits |= (PixelType)(((*psrc++ >> bitPos) & 1)) << curBit; \
+ StepBit (curBit, 1); \
+ } \
+}
+
+void
+cfbCopyPlane8to1(
+ DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ int rop,
+ RegionPtr prgnDst,
+ DDXPointPtr pptSrc,
+ unsigned long planemask,
+ unsigned long bitPlane)
+{
+ int srcx, srcy, dstx, dsty, width, height;
+ unsigned char *psrcBase;
+ PixelType *pdstBase;
+ int widthSrc, widthDst;
+ unsigned char *psrcLine;
+ PixelType *pdstLine;
+ register unsigned char *psrc;
+ register int i;
+ register int curBit;
+ register int bitPos;
+ register CfbBits bits;
+ register PixelType *pdst;
+ PixelType startmask, endmask;
+ int niStart = 0, niEnd = 0;
+ int bitStart = 0, bitEnd = 0;
+ int nl, nlMiddle;
+ int nbox;
+ BoxPtr pbox;
+ MROP_DECLARE()
+
+ if (!(planemask & 1))
+ return;
+
+ if (rop != GXcopy)
+ MROP_INITIALIZE (rop, planemask);
+
+ cfbGetByteWidthAndPointer (pSrcDrawable, widthSrc, psrcBase)
+
+ mfbGetPixelWidthAndPointer (pDstDrawable, widthDst, pdstBase)
+
+ bitPos = ffs (bitPlane) - 1;
+
+ nbox = REGION_NUM_RECTS(prgnDst);
+ pbox = REGION_RECTS(prgnDst);
+ while (nbox--)
+ {
+ dstx = pbox->x1;
+ dsty = pbox->y1;
+ srcx = pptSrc->x;
+ srcy = pptSrc->y;
+ width = pbox->x2 - pbox->x1;
+ height = pbox->y2 - pbox->y1;
+ pbox++;
+ pptSrc++;
+ psrcLine = psrcBase + srcy * widthSrc + srcx;
+ pdstLine = mfbScanline(pdstBase, dstx, dsty, widthDst);
+ dstx &= MFB_PIM;
+ if (dstx + width <= MFB_PPW)
+ {
+ maskpartialbits(dstx, width, startmask);
+ nlMiddle = 0;
+ endmask = 0;
+ }
+ else
+ {
+ maskbits (dstx, width, startmask, endmask, nlMiddle);
+ }
+ if (startmask)
+ {
+ niStart = min(MFB_PPW - dstx, width);
+ bitStart = LeftMost;
+ StepBit (bitStart, dstx);
+ }
+ if (endmask)
+ {
+ niEnd = (dstx + width) & MFB_PIM;
+ bitEnd = LeftMost;
+ }
+ if (rop == GXcopy)
+ {
+ while (height--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ psrcLine += widthSrc;
+ mfbScanlineInc(pdstLine, widthDst);
+ if (startmask)
+ {
+ i = niStart;
+ curBit = bitStart;
+ GetBits (psrc, i, curBit, bitPos, bits);
+ *pdst = (*pdst & ~startmask) | bits;
+ pdst++;
+ }
+ nl = nlMiddle;
+ while (nl--)
+ {
+ i = MFB_PPW;
+ curBit = LeftMost;
+ GetBits (psrc, i, curBit, bitPos, bits);
+ *pdst++ = bits;
+ }
+ if (endmask)
+ {
+ i = niEnd;
+ curBit = bitEnd;
+ GetBits (psrc, i, curBit, bitPos, bits);
+ *pdst = (*pdst & ~endmask) | bits;
+ }
+ }
+ }
+ else
+ {
+ while (height--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ psrcLine += widthSrc;
+ mfbScanlineInc(pdstLine, widthDst);
+ if (startmask)
+ {
+ i = niStart;
+ curBit = bitStart;
+ GetBits (psrc, i, curBit, bitPos, bits);
+ *pdst = MROP_MASK(bits, *pdst, startmask);
+ pdst++;
+ }
+ nl = nlMiddle;
+ while (nl--)
+ {
+ i = MFB_PPW;
+ curBit = LeftMost;
+ GetBits (psrc, i, curBit, bitPos, bits);
+ *pdst = MROP_SOLID(bits, *pdst);
+ pdst++;
+ }
+ if (endmask)
+ {
+ i = niEnd;
+ curBit = bitEnd;
+ GetBits (psrc, i, curBit, bitPos, bits);
+ *pdst = MROP_MASK (bits, *pdst, endmask);
+ }
+ }
+ }
+ }
+}
+
+#else /* PSZ == 8 */
+
+#define mfbmaskbits(x, w, startmask, endmask, nlw) \
+ startmask = mfbGetstarttab((x)&0x1f); \
+ endmask = mfbGetendtab(((x)+(w)) & 0x1f); \
+ if (startmask) \
+ nlw = (((w) - (32 - ((x)&0x1f))) >> 5); \
+ else \
+ nlw = (w) >> 5;
+
+#define mfbmaskpartialbits(x, w, mask) \
+ mask = mfbGetpartmasks((x)&0x1f,(w)&0x1f);
+
+#define LeftMost 0
+#define StepBit(bit, inc) ((bit) += (inc))
+
+
+#if PSZ == 24
+#define GetBits(psrc, nBits, curBit, bitPos, bits) {\
+ bits = 0; \
+ while (nBits--) \
+ { \
+ if (bitPos < 8) \
+ { \
+ bits |= ((*psrc++ >> bitPos) & 1) << curBit; \
+ psrc += 2; \
+ } \
+ else if (bitPos < 16) \
+ { \
+ psrc++; \
+ bits |= ((*psrc++ >> (bitPos - 8)) & 1) << curBit; \
+ psrc++; \
+ } \
+ else \
+ { \
+ psrc += 2; \
+ bits |= ((*psrc++ >> (bitPos - 16)) & 1) << curBit; \
+ } \
+ StepBit (curBit, 1); \
+ } \
+}
+#else
+#define GetBits(psrc, nBits, curBit, bitPos, bits) {\
+ bits = 0; \
+ while (nBits--) \
+ { \
+ bits |= ((*psrc++ >> bitPos) & 1) << curBit; \
+ StepBit (curBit, 1); \
+ } \
+}
+#endif
+
+void
+#if PSZ == 16
+cfbCopyPlane16to1
+#endif
+#if PSZ == 24
+cfbCopyPlane24to1
+#endif
+#if PSZ == 32
+cfbCopyPlane32to1
+#endif
+(
+ DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ int rop,
+ RegionPtr prgnDst,
+ DDXPointPtr pptSrc,
+ unsigned long planemask,
+ unsigned long bitPlane)
+{
+ int srcx, srcy, dstx, dsty, width, height;
+ CfbBits *psrcBase;
+ CfbBits *pdstBase;
+ int widthSrc, widthDst;
+#if PSZ == 16
+ unsigned short *psrcLine;
+ register unsigned short *psrc;
+#endif
+#if PSZ == 24
+ unsigned char *psrcLine;
+ register unsigned char *psrc;
+#endif
+#if PSZ == 32
+ unsigned int *psrcLine;
+ register unsigned int *psrc;
+#endif
+ unsigned int *pdstLine;
+ register unsigned int *pdst;
+ register int i;
+ register int curBit;
+ register int bitPos;
+ register unsigned int bits;
+ unsigned int startmask = 0, endmask = 0;
+ int niStart = 0, niEnd = 0;
+ int bitStart = 0, bitEnd = 0;
+ int nl, nlMiddle;
+ int nbox;
+ BoxPtr pbox;
+ int result;
+
+
+ if (!(planemask & 1))
+ return;
+
+ /* must explicitly ask for "int" widths, as code below expects it */
+ /* on some machines (Alpha), "long" and "int" are not the same size */
+ cfbGetTypedWidthAndPointer (pSrcDrawable, widthSrc, psrcBase, int, CfbBits)
+ cfbGetTypedWidthAndPointer (pDstDrawable, widthDst, pdstBase, int, CfbBits)
+
+#if PSZ == 16
+ widthSrc <<= 1;
+#endif
+#if PSZ == 24
+ widthSrc <<= 2;
+#endif
+
+ bitPos = ffs (bitPlane) - 1;
+
+ nbox = REGION_NUM_RECTS(prgnDst);
+ pbox = REGION_RECTS(prgnDst);
+ while (nbox--)
+ {
+ dstx = pbox->x1;
+ dsty = pbox->y1;
+ srcx = pptSrc->x;
+ srcy = pptSrc->y;
+ width = pbox->x2 - pbox->x1;
+ height = pbox->y2 - pbox->y1;
+ pbox++;
+ pptSrc++;
+#if PSZ == 16
+ psrcLine = (unsigned short *)psrcBase + srcy * widthSrc + srcx;
+#endif
+#if PSZ == 24
+ psrcLine = (unsigned char *)psrcBase + srcy * widthSrc + srcx * 3;
+#endif
+#if PSZ == 32
+ psrcLine = (unsigned int *)psrcBase + srcy * widthSrc + srcx;
+#endif
+ pdstLine = (unsigned int *)pdstBase + dsty * widthDst + (dstx >> 5);
+ if (dstx + width <= 32)
+ {
+ mfbmaskpartialbits(dstx, width, startmask);
+ nlMiddle = 0;
+ endmask = 0;
+ }
+ else
+ {
+ mfbmaskbits (dstx, width, startmask, endmask, nlMiddle);
+ }
+ if (startmask)
+ {
+ niStart = 32 - (dstx & 0x1f);
+ bitStart = LeftMost;
+ StepBit (bitStart, (dstx & 0x1f));
+ }
+ if (endmask)
+ {
+ niEnd = (dstx + width) & 0x1f;
+ bitEnd = LeftMost;
+ }
+ if (rop == GXcopy)
+ {
+ while (height--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ psrcLine += widthSrc;
+ pdstLine += widthDst;
+ if (startmask)
+ {
+ i = niStart;
+ curBit = bitStart;
+ GetBits (psrc, i, curBit, bitPos, bits);
+
+ *pdst = (*pdst & ~startmask) | bits;
+ pdst++;
+ }
+ nl = nlMiddle;
+ while (nl--)
+ {
+ i = 32;
+ curBit = LeftMost;
+ GetBits (psrc, i, curBit, bitPos, bits);
+ *pdst++ = bits;
+ }
+ if (endmask)
+ {
+ i = niEnd;
+ curBit = bitEnd;
+ GetBits (psrc, i, curBit, bitPos, bits);
+
+ *pdst = (*pdst & ~endmask) | bits;
+ }
+ }
+ }
+ else
+ {
+ while (height--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ psrcLine += widthSrc;
+ pdstLine += widthDst;
+ if (startmask)
+ {
+ i = niStart;
+ curBit = bitStart;
+ GetBits (psrc, i, curBit, bitPos, bits);
+ DoRop (result, rop, bits, *pdst);
+
+ *pdst = (*pdst & ~startmask) |
+ (result & startmask);
+ pdst++;
+ }
+ nl = nlMiddle;
+ while (nl--)
+ {
+ i = 32;
+ curBit = LeftMost;
+ GetBits (psrc, i, curBit, bitPos, bits);
+ DoRop (result, rop, bits, *pdst);
+ *pdst = result;
+ ++pdst;
+ }
+ if (endmask)
+ {
+ i = niEnd;
+ curBit = bitEnd;
+ GetBits (psrc, i, curBit, bitPos, bits);
+ DoRop (result, rop, bits, *pdst);
+
+ *pdst = (*pdst & ~endmask) |
+ (result & endmask);
+ }
+ }
+ }
+ }
+}
+
+#endif /* PSZ == 8 */
diff --git a/nx-X11/programs/Xserver/cfb/cfbfillarc.c b/nx-X11/programs/Xserver/cfb/cfbfillarc.c
new file mode 100644
index 000000000..6fb6bb728
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbfillarc.c
@@ -0,0 +1,374 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfbfillarc.c,v 3.6tsi Exp $ */
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+********************************************************/
+
+/* $Xorg: cfbfillarc.c,v 1.4 2001/02/09 02:04:37 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "mifillarc.h"
+#include "cfbrrop.h"
+#include "mi.h"
+
+/* gcc 1.35 is stupid */
+#if defined(__GNUC__) && __GNUC__ < 2 && defined(mc68020)
+#define STUPID volatile
+#else
+#define STUPID
+#endif
+
+static void
+RROP_NAME(cfbFillEllipseSolid)(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ xArc *arc)
+{
+ STUPID int x, y, e;
+ STUPID int yk, xk, ym, xm, dx, dy, xorg, yorg;
+ miFillArcRec info;
+#if PSZ == 24
+ unsigned char *addrlt, *addrlb;
+#else
+ CfbBits *addrlt, *addrlb;
+#endif
+ register CfbBits *addrl;
+ register int n;
+ int nlwidth;
+ RROP_DECLARE
+ register int xpos;
+ register int slw;
+ CfbBits startmask, endmask;
+ int nlmiddle;
+#if PSZ == 24
+ register int pidx;
+ int xpos3;
+#endif
+
+#if PSZ == 24
+ cfbGetByteWidthAndPointer (pDraw, nlwidth, addrlt)
+#else
+ cfbGetLongWidthAndPointer (pDraw, nlwidth, addrlt)
+#endif
+
+ RROP_FETCH_GC(pGC);
+ miFillArcSetup(arc, &info);
+ MIFILLARCSETUP();
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ addrlb = addrlt;
+ addrlt += nlwidth * (yorg - y);
+ addrlb += nlwidth * (yorg + y + dy);
+ while (y)
+ {
+ addrlt += nlwidth;
+ addrlb -= nlwidth;
+ MIFILLARCSTEP(slw);
+ if (!slw)
+ continue;
+ xpos = xorg - x;
+#if PSZ == 24
+ xpos3 = (xpos * 3) & ~0x03;
+ addrl = (CfbBits *)((char *)addrlt + xpos3);
+ if (slw == 1){
+ RROP_SOLID24(addrl, xpos);
+ if (miFillArcLower(slw)){
+ addrl = (CfbBits *)((char *)addrlb + xpos3);
+ RROP_SOLID24(addrl, xpos);
+ }
+ continue;
+ }
+ maskbits(xpos, slw, startmask, endmask, nlmiddle);
+ xpos &= 3;
+ pidx = xpos;
+ if (startmask){
+ RROP_SOLID_MASK(addrl, startmask, pidx-1);
+ addrl++;
+ if (pidx == 3)
+ pidx = 0;
+ }
+ n = nlmiddle;
+ while (--n >= 0){
+ RROP_SOLID(addrl, pidx);
+ addrl++;
+ if (++pidx == 3)
+ pidx = 0;
+ }
+ if (endmask)
+ RROP_SOLID_MASK(addrl, endmask, pidx);
+ if (!miFillArcLower(slw))
+ continue;
+ addrl = (CfbBits *)((char *)addrlb + xpos3);
+ pidx = xpos;
+ if (startmask){
+ RROP_SOLID_MASK(addrl, startmask, pidx-1);
+ addrl++;
+ if (pidx == 3)
+ pidx = 0;
+ }
+ n = nlmiddle;
+ while (--n >= 0){
+ RROP_SOLID(addrl, pidx);
+ addrl++;
+ if (++pidx == 3)
+ pidx = 0;
+ }
+ if (endmask)
+ RROP_SOLID_MASK(addrl, endmask, pidx);
+#else /* PSZ == 24 */
+ addrl = addrlt + (xpos >> PWSH);
+ if (((xpos & PIM) + slw) <= PPW)
+ {
+ maskpartialbits(xpos, slw, startmask);
+ RROP_SOLID_MASK(addrl,startmask);
+ if (miFillArcLower(slw))
+ {
+ addrl = addrlb + (xpos >> PWSH);
+ RROP_SOLID_MASK(addrl, startmask);
+ }
+ continue;
+ }
+ maskbits(xpos, slw, startmask, endmask, nlmiddle);
+ if (startmask)
+ {
+ RROP_SOLID_MASK(addrl, startmask);
+ addrl++;
+ }
+ n = nlmiddle;
+ RROP_SPAN(addrl,n)
+
+ if (endmask)
+ RROP_SOLID_MASK(addrl, endmask);
+ if (!miFillArcLower(slw))
+ continue;
+ addrl = addrlb + (xpos >> PWSH);
+ if (startmask)
+ {
+ RROP_SOLID_MASK(addrl, startmask);
+ addrl++;
+ }
+ n = nlmiddle;
+ RROP_SPAN(addrl, n);
+ if (endmask)
+ RROP_SOLID_MASK(addrl, endmask);
+#endif /* PSZ == 24 */
+ }
+ RROP_UNDECLARE
+}
+
+#if PSZ == 24
+#define FILLSPAN(xl,xr,addr) \
+ if (xr >= xl){ \
+ n = xr - xl + 1; \
+ addrl = (CfbBits *)((char *)addr + ((xl * 3) & ~0x03)); \
+ if (n <= 1){ \
+ if (n) \
+ RROP_SOLID24(addrl, xl); \
+ } else { \
+ maskbits(xl, n, startmask, endmask, n); \
+ pidx = xl & 3; \
+ if (startmask){ \
+ RROP_SOLID_MASK(addrl, startmask, pidx-1); \
+ addrl++; \
+ if (pidx == 3) \
+ pidx = 0; \
+ } \
+ while (--n >= 0){ \
+ RROP_SOLID(addrl, pidx); \
+ addrl++; \
+ if (++pidx == 3) \
+ pidx = 0; \
+ } \
+ if (endmask) \
+ RROP_SOLID_MASK(addrl, endmask, pidx); \
+ } \
+ }
+#else /* PSZ == 24 */
+#define FILLSPAN(xl,xr,addr) \
+ if (xr >= xl) \
+ { \
+ n = xr - xl + 1; \
+ addrl = addr + (xl >> PWSH); \
+ if (((xl & PIM) + n) <= PPW) \
+ { \
+ maskpartialbits(xl, n, startmask); \
+ RROP_SOLID_MASK(addrl, startmask); \
+ } \
+ else \
+ { \
+ maskbits(xl, n, startmask, endmask, n); \
+ if (startmask) \
+ { \
+ RROP_SOLID_MASK(addrl, startmask); \
+ addrl++; \
+ } \
+ while (n--) \
+ { \
+ RROP_SOLID(addrl); \
+ ++addrl; \
+ } \
+ if (endmask) \
+ RROP_SOLID_MASK(addrl, endmask); \
+ } \
+ }
+#endif /* PSZ == 24 */
+
+#define FILLSLICESPANS(flip,addr) \
+ if (!flip) \
+ { \
+ FILLSPAN(xl, xr, addr); \
+ } \
+ else \
+ { \
+ xc = xorg - x; \
+ FILLSPAN(xc, xr, addr); \
+ xc += slw - 1; \
+ FILLSPAN(xl, xc, addr); \
+ }
+
+static void
+RROP_NAME(cfbFillArcSliceSolid)(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ xArc *arc)
+{
+ int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
+ register int x, y, e;
+ miFillArcRec info;
+ miArcSliceRec slice;
+ int xl, xr, xc;
+#if PSZ == 24
+ unsigned char *addrlt, *addrlb;
+#else
+ CfbBits *addrlt, *addrlb;
+#endif
+ register CfbBits *addrl;
+ register int n;
+ int nlwidth;
+ RROP_DECLARE
+ CfbBits startmask, endmask;
+#if PSZ == 24
+ register int pidx;
+#endif /* PSZ == 24 */
+
+#if PSZ == 24
+ cfbGetByteWidthAndPointer (pDraw, nlwidth, addrlt)
+#else
+ cfbGetLongWidthAndPointer (pDraw, nlwidth, addrlt)
+#endif
+
+ RROP_FETCH_GC(pGC);
+ miFillArcSetup(arc, &info);
+ miFillArcSliceSetup(arc, &slice, pGC);
+ MIFILLARCSETUP();
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ addrlb = addrlt;
+ addrlt += nlwidth * (yorg - y);
+ addrlb += nlwidth * (yorg + y + dy);
+ slice.edge1.x += pDraw->x;
+ slice.edge2.x += pDraw->x;
+ while (y > 0)
+ {
+ addrlt += nlwidth;
+ addrlb -= nlwidth;
+ MIFILLARCSTEP(slw);
+ MIARCSLICESTEP(slice.edge1);
+ MIARCSLICESTEP(slice.edge2);
+ if (miFillSliceUpper(slice))
+ {
+ MIARCSLICEUPPER(xl, xr, slice, slw);
+ FILLSLICESPANS(slice.flip_top, addrlt);
+ }
+ if (miFillSliceLower(slice))
+ {
+ MIARCSLICELOWER(xl, xr, slice, slw);
+ FILLSLICESPANS(slice.flip_bot, addrlb);
+ }
+ }
+ RROP_UNDECLARE
+}
+
+void
+RROP_NAME(cfbPolyFillArcSolid) (pDraw, pGC, narcs, parcs)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int narcs;
+ xArc *parcs;
+{
+ register xArc *arc;
+ register int i;
+ int x2, y2;
+ BoxRec box;
+ RegionPtr cclip;
+
+ cclip = cfbGetCompositeClip(pGC);
+ for (arc = parcs, i = narcs; --i >= 0; arc++)
+ {
+ if (miFillArcEmpty(arc))
+ continue;
+ if (miCanFillArc(arc))
+ {
+ box.x1 = arc->x + pDraw->x;
+ box.y1 = arc->y + pDraw->y;
+ /*
+ * Because box.x2 and box.y2 get truncated to 16 bits, and the
+ * RECT_IN_REGION test treats the resulting number as a signed
+ * integer, the RECT_IN_REGION test alone can go the wrong way.
+ * This can result in a server crash because the rendering
+ * routines in this file deal directly with cpu addresses
+ * of pixels to be stored, and do not clip or otherwise check
+ * that all such addresses are within their respective pixmaps.
+ * So we only allow the RECT_IN_REGION test to be used for
+ * values that can be expressed correctly in a signed short.
+ */
+ x2 = box.x1 + (int)arc->width + 1;
+ box.x2 = x2;
+ y2 = box.y1 + (int)arc->height + 1;
+ box.y2 = y2;
+ if ( (x2 <= MAXSHORT) && (y2 <= MAXSHORT) &&
+ (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) )
+ {
+ if ((arc->angle2 >= FULLCIRCLE) ||
+ (arc->angle2 <= -FULLCIRCLE))
+ RROP_NAME(cfbFillEllipseSolid)(pDraw, pGC, arc);
+ else
+ RROP_NAME(cfbFillArcSliceSolid)(pDraw, pGC, arc);
+ continue;
+ }
+ }
+ miPolyFillArc(pDraw, pGC, 1, arc);
+ }
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbfillrct.c b/nx-X11/programs/Xserver/cfb/cfbfillrct.c
new file mode 100644
index 000000000..657865114
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbfillrct.c
@@ -0,0 +1,307 @@
+/*
+ * Fill rectangles.
+ */
+/* $XFree86: xc/programs/Xserver/cfb/cfbfillrct.c,v 3.7 2001/01/17 22:36:35 dawes Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+
+/* $Xorg: cfbfillrct.c,v 1.4 2001/02/09 02:04:37 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "mergerop.h"
+
+
+void
+cfbFillBoxTileOdd (pDrawable, n, rects, tile, xrot, yrot)
+ DrawablePtr pDrawable;
+ int n;
+ BoxPtr rects;
+ PixmapPtr tile;
+ int xrot, yrot;
+{
+#if PSZ == 24
+ if (tile->drawable.width & 3)
+#else
+ if (tile->drawable.width & PIM)
+#endif
+ cfbFillBoxTileOddCopy (pDrawable, n, rects, tile, xrot, yrot, GXcopy, ~0L);
+ else
+ cfbFillBoxTile32sCopy (pDrawable, n, rects, tile, xrot, yrot, GXcopy, ~0L);
+}
+
+void
+cfbFillRectTileOdd (pDrawable, pGC, nBox, pBox)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nBox;
+ BoxPtr pBox;
+{
+ int xrot, yrot;
+ void (*fill)(DrawablePtr, int, BoxPtr, PixmapPtr, int, int, int, unsigned long);
+
+ xrot = pDrawable->x + pGC->patOrg.x;
+ yrot = pDrawable->y + pGC->patOrg.y;
+#if PSZ == 24
+ if (pGC->tile.pixmap->drawable.width & 3)
+#else
+ if (pGC->tile.pixmap->drawable.width & PIM)
+#endif
+ {
+ fill = cfbFillBoxTileOddGeneral;
+ if ((pGC->planemask & PMSK) == PMSK)
+ {
+ if (pGC->alu == GXcopy)
+ fill = cfbFillBoxTileOddCopy;
+ }
+ }
+ else
+ {
+ fill = cfbFillBoxTile32sGeneral;
+ if ((pGC->planemask & PMSK) == PMSK)
+ {
+ if (pGC->alu == GXcopy)
+ fill = cfbFillBoxTile32sCopy;
+ }
+ }
+ (*fill) (pDrawable, nBox, pBox, pGC->tile.pixmap, xrot, yrot, pGC->alu, pGC->planemask);
+}
+
+#define NUM_STACK_RECTS 1024
+
+void
+cfbPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int nrectFill; /* number of rectangles to fill */
+ xRectangle *prectInit; /* Pointer to first rectangle to fill */
+{
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ register BoxPtr pbox;
+ register BoxPtr pboxClipped;
+ BoxPtr pboxClippedBase;
+ BoxPtr pextent;
+ BoxRec stackRects[NUM_STACK_RECTS];
+ cfbPrivGC *priv;
+ int numRects;
+ void (*BoxFill)(DrawablePtr, GCPtr, int, BoxPtr);
+ int n;
+ int xorg, yorg;
+
+#if PSZ != 8
+ if ((pGC->fillStyle == FillStippled) ||
+ (pGC->fillStyle == FillOpaqueStippled)) {
+ miPolyFillRect(pDrawable, pGC, nrectFill, prectInit);
+ return;
+ }
+#endif
+
+ priv = cfbGetGCPrivate(pGC);
+ prgnClip = pGC->pCompositeClip;
+
+ BoxFill = 0;
+ switch (pGC->fillStyle)
+ {
+ case FillSolid:
+ switch (priv->rop) {
+ case GXcopy:
+ BoxFill = cfbFillRectSolidCopy;
+ break;
+ case GXxor:
+ BoxFill = cfbFillRectSolidXor;
+ break;
+ default:
+ BoxFill = cfbFillRectSolidGeneral;
+ break;
+ }
+ break;
+ case FillTiled:
+ if (!pGC->pRotatedPixmap)
+ BoxFill = cfbFillRectTileOdd;
+ else
+ {
+ if (pGC->alu == GXcopy && (pGC->planemask & PMSK) == PMSK)
+ BoxFill = cfbFillRectTile32Copy;
+ else
+ BoxFill = cfbFillRectTile32General;
+ }
+ break;
+#if PSZ == 8
+ case FillStippled:
+ if (!pGC->pRotatedPixmap)
+ BoxFill = cfb8FillRectStippledUnnatural;
+ else
+ BoxFill = cfb8FillRectTransparentStippled32;
+ break;
+ case FillOpaqueStippled:
+ if (!pGC->pRotatedPixmap)
+ BoxFill = cfb8FillRectStippledUnnatural;
+ else
+ BoxFill = cfb8FillRectOpaqueStippled32;
+ break;
+#endif
+ }
+ prect = prectInit;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ if (xorg || yorg)
+ {
+ prect = prectInit;
+ n = nrectFill;
+ while(n--)
+ {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+ prect = prectInit;
+
+ numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
+ if (numRects > NUM_STACK_RECTS)
+ {
+ pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(numRects * sizeof(BoxRec));
+ if (!pboxClippedBase)
+ return;
+ }
+ else
+ pboxClippedBase = stackRects;
+
+ pboxClipped = pboxClippedBase;
+
+ if (REGION_NUM_RECTS(prgnClip) == 1)
+ {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_RECTS(prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--)
+ {
+ if ((pboxClipped->x1 = prect->x) < x1)
+ pboxClipped->x1 = x1;
+
+ if ((pboxClipped->y1 = prect->y) < y1)
+ pboxClipped->y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ pboxClipped->x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ pboxClipped->y2 = by2;
+
+ prect++;
+ if ((pboxClipped->x1 < pboxClipped->x2) &&
+ (pboxClipped->y1 < pboxClipped->y2))
+ {
+ pboxClipped++;
+ }
+ }
+ }
+ else
+ {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--)
+ {
+ BoxRec box;
+
+ if ((box.x1 = prect->x) < x1)
+ box.x1 = x1;
+
+ if ((box.y1 = prect->y) < y1)
+ box.y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ box.x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ box.y2 = by2;
+
+ prect++;
+
+ if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
+ continue;
+
+ n = REGION_NUM_RECTS (prgnClip);
+ pbox = REGION_RECTS(prgnClip);
+
+ /* clip the rectangle to each box in the clip region
+ this is logically equivalent to calling Intersect()
+ */
+ while(n--)
+ {
+ pboxClipped->x1 = max(box.x1, pbox->x1);
+ pboxClipped->y1 = max(box.y1, pbox->y1);
+ pboxClipped->x2 = min(box.x2, pbox->x2);
+ pboxClipped->y2 = min(box.y2, pbox->y2);
+ pbox++;
+
+ /* see if clipping left anything */
+ if(pboxClipped->x1 < pboxClipped->x2 &&
+ pboxClipped->y1 < pboxClipped->y2)
+ {
+ pboxClipped++;
+ }
+ }
+ }
+ }
+ if (pboxClipped != pboxClippedBase)
+ (*BoxFill) (pDrawable, pGC,
+ pboxClipped-pboxClippedBase, pboxClippedBase);
+ if (pboxClippedBase != stackRects)
+ DEALLOCATE_LOCAL(pboxClippedBase);
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbfillsp.c b/nx-X11/programs/Xserver/cfb/cfbfillsp.c
new file mode 100644
index 000000000..efb462b6c
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbfillsp.c
@@ -0,0 +1,1006 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfbfillsp.c,v 3.7tsi Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* $Xorg: cfbfillsp.c,v 1.4 2001/02/09 02:04:37 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+
+#include "mergerop.h"
+
+#if PSZ == 8
+#include "cfb8bit.h"
+#endif
+
+#define MFB_CONSTS_ONLY
+#include "maskbits.h"
+
+#include "mi.h"
+#include "mispans.h"
+
+/* scanline filling for color frame buffer
+ written by drewry, oct 1986 modified by smarks
+ changes for compatibility with Little-endian systems Jul 1987; MIT:yba.
+
+ these routines all clip. they assume that anything that has called
+them has already translated the points (i.e. pGC->miTranslate is
+non-zero, which is howit gets set in cfbCreateGC().)
+
+ the number of new scnalines created by clipping ==
+MaxRectsPerBand * nSpans.
+
+ FillSolid is overloaded to be used for OpaqueStipple as well,
+if fgPixel == bgPixel.
+Note that for solids, PrivGC.rop == PrivGC.ropOpStip
+
+
+ FillTiled is overloaded to be used for OpaqueStipple, if
+fgPixel != bgPixel. based on the fill style, it uses
+{RotatedTile, gc.alu} or {RotatedStipple, PrivGC.ropOpStip}
+*/
+
+#ifdef notdef
+#include <stdio.h>
+static
+dumpspans(n, ppt, pwidth)
+ int n;
+ DDXPointPtr ppt;
+ int *pwidth;
+{
+ fprintf(stderr,"%d spans\n", n);
+ while (n--) {
+ fprintf(stderr, "[%d,%d] %d\n", ppt->x, ppt->y, *pwidth);
+ ppt++;
+ pwidth++;
+ }
+ fprintf(stderr, "\n");
+}
+#endif
+
+/* Fill spans with tiles that aren't 32 bits wide */
+void
+cfbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+DrawablePtr pDrawable;
+GC *pGC;
+int nInit; /* number of spans to fill */
+DDXPointPtr pptInit; /* pointer to list of start points */
+int *pwidthInit; /* pointer to list of n widths */
+int fSorted;
+{
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ void (*fill)(DrawablePtr, int, DDXPointPtr, int *, PixmapPtr, int, int, int, unsigned long);
+ int xrot, yrot;
+
+ if (!(pGC->planemask))
+ return;
+
+#if PSZ == 24
+ if (pGC->tile.pixmap->drawable.width & 3)
+#else
+ if (pGC->tile.pixmap->drawable.width & PIM)
+#endif
+ {
+ fill = cfbFillSpanTileOddGeneral;
+ if ((pGC->planemask & PMSK) == PMSK)
+ {
+ if (pGC->alu == GXcopy)
+ fill = cfbFillSpanTileOddCopy;
+ }
+ }
+ else
+ {
+ fill = cfbFillSpanTile32sGeneral;
+ if ((pGC->planemask & PMSK) == PMSK)
+ {
+ if (pGC->alu == GXcopy)
+ fill = cfbFillSpanTile32sCopy;
+ }
+ }
+ n = nInit * miFindMaxBand( cfbGetCompositeClip(pGC) );
+ if ( n == 0 )
+ return;
+ pwidth = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ ppt = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!ppt || !pwidth)
+ {
+ if (ppt) DEALLOCATE_LOCAL(ppt);
+ if (pwidth) DEALLOCATE_LOCAL(pwidth);
+ return;
+ }
+ n = miClipSpans( cfbGetCompositeClip(pGC),
+ pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ xrot = pDrawable->x + pGC->patOrg.x;
+ yrot = pDrawable->y + pGC->patOrg.y;
+
+ (*fill) (pDrawable, n, ppt, pwidth, pGC->tile.pixmap, xrot, yrot, pGC->alu, pGC->planemask);
+
+ DEALLOCATE_LOCAL(ppt);
+ DEALLOCATE_LOCAL(pwidth);
+}
+
+#if PSZ == 8
+
+void
+cfbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+DrawablePtr pDrawable;
+GC *pGC;
+int nInit; /* number of spans to fill */
+DDXPointPtr pptInit; /* pointer to list of start points */
+int *pwidthInit; /* pointer to list of n widths */
+int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ DDXPointPtr ppt; /* pointer to list of start points */
+ int *pwidth; /* pointer to list of n widths */
+ int *pwidthFree;/* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ CfbBits *pdstBase; /* pointer to start of bitmap */
+ int nlwDst; /* width in longwords of bitmap */
+ register CfbBits *pdst; /* pointer to current word in bitmap */
+ PixmapPtr pStipple; /* pointer to stipple we want to fill with */
+ int nlw;
+ int x, y, w, xrem, xSrc, ySrc;
+ int stwidth, stippleWidth;
+ int stippleHeight;
+ register CfbBits bits, inputBits;
+ register int partBitsLeft;
+ int nextPartBits;
+ int bitsLeft, bitsWhole;
+ CfbBits *srcTemp, *srcStart;
+ CfbBits *psrcBase;
+ CfbBits startmask, endmask;
+
+ if (pGC->fillStyle == FillStippled)
+ cfb8CheckStipple (pGC->alu, pGC->fgPixel, pGC->planemask);
+ else
+ cfb8CheckOpaqueStipple (pGC->alu, pGC->fgPixel, pGC->bgPixel, pGC->planemask);
+
+ if (cfb8StippleRRop == GXnoop)
+ return;
+
+ n = nInit * miFindMaxBand( cfbGetCompositeClip(pGC) );
+ if ( n == 0 )
+ return;
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans( cfbGetCompositeClip(pGC),
+ pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ /*
+ * OK, so what's going on here? We have two Drawables:
+ *
+ * The Stipple:
+ * Depth = 1
+ * Width = stippleWidth
+ * Words per scanline = stwidth
+ * Pointer to pixels = pStipple->devPrivate.ptr
+ */
+
+ pStipple = pGC->stipple;
+
+ stwidth = pStipple->devKind >> PWSH;
+ stippleWidth = pStipple->drawable.width;
+ stippleHeight = pStipple->drawable.height;
+ psrcBase = (CfbBits *) pStipple->devPrivate.ptr;
+
+ /*
+ * The Target:
+ * Depth = PSZ
+ * Width = determined from *pwidth
+ * Words per scanline = nlwDst
+ * Pointer to pixels = addrlBase
+ */
+
+ cfbGetLongWidthAndPointer (pDrawable, nlwDst, pdstBase)
+
+ /* this replaces rotating the stipple. Instead we just adjust the offset
+ * at which we start grabbing bits from the stipple.
+ * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
+ * so that iline and xrem always stay within the stipple bounds.
+ */
+
+ modulus (pGC->patOrg.x, stippleWidth, xSrc);
+ xSrc += pDrawable->x - stippleWidth;
+ modulus (pGC->patOrg.y, stippleHeight, ySrc);
+ ySrc += pDrawable->y - stippleHeight;
+
+ bitsWhole = stippleWidth;
+
+ while (n--)
+ {
+ x = ppt->x;
+ y = ppt->y;
+ ppt++;
+ w = *pwidth++;
+ pdst = pdstBase + y * nlwDst + (x >> PWSH);
+ y = (y - ySrc) % stippleHeight;
+ srcStart = psrcBase + y * stwidth;
+ xrem = ((x & ~(PGSZB-1)) - xSrc) % stippleWidth;
+ srcTemp = srcStart + (xrem >> MFB_PWSH);
+ bitsLeft = stippleWidth - (xrem & ~MFB_PIM);
+ xrem &= MFB_PIM;
+ NextUnnaturalStippleWord
+ if (partBitsLeft < xrem)
+ FatalError ("cfbUnnaturalStippleFS bad partBitsLeft %d xrem %d",
+ partBitsLeft, xrem);
+ NextSomeBits (inputBits, xrem);
+ partBitsLeft -= xrem;
+ if (((x & PIM) + w) <= PPW)
+ {
+ maskpartialbits (x, w, startmask)
+ NextUnnaturalStippleBits
+ *pdst = MaskRRopPixels(*pdst,bits,startmask);
+ }
+ else
+ {
+ maskbits (x, w, startmask, endmask, nlw);
+ nextPartBits = (x & (PGSZB-1)) + w;
+ if (nextPartBits < partBitsLeft)
+ {
+ if (startmask)
+ {
+ MaskRRopBitGroup(pdst,GetBitGroup(inputBits),startmask)
+ pdst++;
+ NextBitGroup (inputBits);
+ }
+ while (nlw--)
+ {
+ RRopBitGroup (pdst, GetBitGroup (inputBits));
+ pdst++;
+ NextBitGroup (inputBits);
+ }
+ if (endmask)
+ {
+ MaskRRopBitGroup(pdst,GetBitGroup(inputBits),endmask)
+ }
+ }
+ else if (bitsLeft != bitsWhole && nextPartBits < partBitsLeft + bitsLeft)
+ {
+ NextUnnaturalStippleBitsFast
+ if (startmask)
+ {
+ *pdst = MaskRRopPixels(*pdst,bits,startmask);
+ pdst++;
+ NextUnnaturalStippleBitsFast
+ }
+ while (nlw--)
+ {
+ *pdst = RRopPixels(*pdst,bits);
+ pdst++;
+ NextUnnaturalStippleBitsFast
+ }
+ if (endmask)
+ *pdst = MaskRRopPixels (*pdst,bits,endmask);
+ }
+ else
+ {
+ NextUnnaturalStippleBits
+ if (startmask)
+ {
+ *pdst = MaskRRopPixels(*pdst,bits,startmask);
+ pdst++;
+ NextUnnaturalStippleBits
+ }
+ while (nlw--)
+ {
+ *pdst = RRopPixels(*pdst,bits);
+ pdst++;
+ NextUnnaturalStippleBits
+ }
+ if (endmask)
+ *pdst = MaskRRopPixels(*pdst,bits,endmask);
+ }
+ }
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+#else /* PSZ != 8 */
+
+/* Fill spans with stipples that aren't 32 bits wide */
+void
+cfbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+DrawablePtr pDrawable;
+GC *pGC;
+int nInit; /* number of spans to fill */
+DDXPointPtr pptInit; /* pointer to list of start points */
+int *pwidthInit; /* pointer to list of n widths */
+int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ int iline; /* first line of tile to use */
+ CfbBits *addrlBase; /* pointer to start of bitmap */
+ int nlwidth; /* width in longwords of bitmap */
+ register CfbBits *pdst; /* pointer to current word in bitmap */
+ PixmapPtr pStipple; /* pointer to stipple we want to fill with */
+ register int w;
+ int width, x, xrem, xSrc, ySrc;
+ CfbBits tmpSrc, tmpDst1, tmpDst2;
+ int stwidth, stippleWidth;
+ CfbBits *psrcS;
+ int rop, stiprop = 0;
+ int stippleHeight;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ CfbBits fgfill, bgfill;
+
+ if (!(pGC->planemask))
+ return;
+
+ n = nInit * miFindMaxBand( cfbGetCompositeClip(pGC) );
+ if ( n == 0 )
+ return;
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans( cfbGetCompositeClip(pGC),
+ pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+ rop = pGC->alu;
+ if (pGC->fillStyle == FillStippled) {
+ switch (rop) {
+ case GXand:
+ case GXcopy:
+ case GXnoop:
+ case GXor:
+ stiprop = rop;
+ break;
+ default:
+ stiprop = rop;
+ rop = GXcopy;
+ }
+ }
+ fgfill = PFILL(pGC->fgPixel);
+ bgfill = PFILL(pGC->bgPixel);
+
+ /*
+ * OK, so what's going on here? We have two Drawables:
+ *
+ * The Stipple:
+ * Depth = 1
+ * Width = stippleWidth
+ * Words per scanline = stwidth
+ * Pointer to pixels = pStipple->devPrivate.ptr
+ */
+ pStipple = pGC->stipple;
+
+ stwidth = pStipple->devKind / PGSZB;
+ stippleWidth = pStipple->drawable.width;
+ stippleHeight = pStipple->drawable.height;
+
+ /*
+ * The Target:
+ * Depth = PSZ
+ * Width = determined from *pwidth
+ * Words per scanline = nlwidth
+ * Pointer to pixels = addrlBase
+ */
+
+ cfbGetLongWidthAndPointer (pDrawable, nlwidth, addrlBase)
+
+ /* this replaces rotating the stipple. Instead we just adjust the offset
+ * at which we start grabbing bits from the stipple.
+ * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
+ * so that iline and xrem always stay within the stipple bounds.
+ */
+ modulus (pGC->patOrg.x, stippleWidth, xSrc);
+ xSrc += pDrawable->x - stippleWidth;
+ modulus (pGC->patOrg.y, stippleHeight, ySrc);
+ ySrc += pDrawable->y - stippleHeight;
+
+ while (n--)
+ {
+ iline = (ppt->y - ySrc) % stippleHeight;
+ x = ppt->x;
+ pdst = addrlBase + (ppt->y * nlwidth);
+ psrcS = (CfbBits *) pStipple->devPrivate.ptr + (iline * stwidth);
+
+ if (*pwidth)
+ {
+ width = *pwidth;
+ while(width > 0)
+ {
+ int xtemp;
+#if PSZ != 32 || PPW != 1
+ int tmpx;
+#endif
+ register CfbBits *ptemp;
+ register CfbBits *pdsttmp;
+ /*
+ * Do a stripe through the stipple & destination w pixels
+ * wide. w is not more than:
+ * - the width of the destination
+ * - the width of the stipple
+ * - the distance between x and the next word
+ * boundary in the destination
+ * - the distance between x and the next word
+ * boundary in the stipple
+ */
+
+ /* width of dest/stipple */
+ xrem = (x - xSrc) % stippleWidth;
+#if PSZ == 24
+ w = 1;
+#else
+ w = min((stippleWidth - xrem), width);
+ /* dist to word bound in dest */
+ w = min(w, PPW - (x & PIM));
+ /* dist to word bound in stip */
+ w = min(w, MFB_PPW - (x & MFB_PIM));
+#endif
+
+ xtemp = (xrem & MFB_PIM);
+ ptemp = (CfbBits *)(psrcS + (xrem >> MFB_PWSH));
+#if PSZ == 24
+ tmpx = x & 3;
+ pdsttmp = pdst + ((x * 3)>>2);
+#else
+#if PSZ != 32 || PPW != 1
+ tmpx = x & PIM;
+#endif
+ pdsttmp = pdst + (x>>PWSH);
+#endif
+ switch ( pGC->fillStyle ) {
+ case FillOpaqueStippled:
+#if PSZ == 24
+ getstipplepixels24(ptemp, xtemp, 0, &bgfill, &tmpDst1, xrem);
+ getstipplepixels24(ptemp, xtemp, 1, &fgfill, &tmpDst2, xrem);
+#else
+ getstipplepixels(ptemp, xtemp, w, 0, &bgfill, &tmpDst1);
+ getstipplepixels(ptemp, xtemp, w, 1, &fgfill, &tmpDst2);
+#endif
+ break;
+ case FillStippled:
+ /* Fill tmpSrc with the source pixels */
+#if PSZ == 24
+ getbits24(pdsttmp, tmpSrc, x);
+ getstipplepixels24(ptemp, xtemp, 0, &tmpSrc, &tmpDst1, xrem);
+#else
+ getbits(pdsttmp, tmpx, w, tmpSrc);
+ getstipplepixels(ptemp, xtemp, w, 0, &tmpSrc, &tmpDst1);
+#endif
+ if (rop != stiprop) {
+#if PSZ == 24
+ putbitsrop24(fgfill, 0, &tmpSrc, pGC->planemask, stiprop);
+#else
+ putbitsrop(fgfill, 0, w, &tmpSrc, pGC->planemask, stiprop);
+#endif
+ } else {
+ tmpSrc = fgfill;
+ }
+#if PSZ == 24
+ getstipplepixels24(ptemp, xtemp, 1, &tmpSrc, &tmpDst2, xrem);
+#else
+ getstipplepixels(ptemp, xtemp, w, 1, &tmpSrc, &tmpDst2);
+#endif
+ break;
+ }
+ tmpDst2 |= tmpDst1;
+#if PSZ == 24
+ putbitsrop24(tmpDst2, tmpx, pdsttmp, pGC->planemask, rop);
+#else
+ putbitsrop(tmpDst2, tmpx, w, pdsttmp, pGC->planemask, rop);
+#endif
+ x += w;
+ width -= w;
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+#endif /* PSZ == 8 */
+
+#if PSZ == 8
+
+void
+cfb8Stipple32FS (pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ DDXPointPtr ppt; /* pointer to list of start points */
+ int *pwidth; /* pointer to list of n widths */
+ CfbBits *src; /* pointer to bits in stipple, if needed */
+ int stippleHeight; /* height of the stipple */
+ PixmapPtr stipple;
+
+ int nlwDst; /* width in longwords of the dest pixmap */
+ int x,y,w; /* current span */
+ CfbBits startmask;
+ CfbBits endmask;
+ register CfbBits *dst; /* pointer to bits we're writing */
+ register int nlw;
+ CfbBits *dstTmp;
+ int nlwTmp;
+
+ CfbBits *pbits; /* pointer to start of pixmap */
+ register CfbBits xor;
+ register CfbBits mask;
+ register CfbBits bits; /* bits from stipple */
+ int wEnd;
+
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ cfbPrivGCPtr devPriv;
+
+ devPriv = cfbGetGCPrivate(pGC);
+ cfb8CheckStipple (pGC->alu, pGC->fgPixel, pGC->planemask);
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ if ( n == 0 )
+ return;
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ stipple = pGC->pRotatedPixmap;
+ src = (CfbBits *)stipple->devPrivate.ptr;
+ stippleHeight = stipple->drawable.height;
+
+ cfbGetLongWidthAndPointer (pDrawable, nlwDst, pbits)
+
+ while (n--)
+ {
+ w = *pwidth++;
+ x = ppt->x;
+ y = ppt->y;
+ ppt++;
+ dst = pbits + (y * nlwDst) + (x >> PWSH);
+ if (((x & PIM) + w) <= PPW)
+ {
+ maskpartialbits(x, w, startmask);
+ endmask = 0;
+ nlw = 0;
+ }
+ else
+ {
+ maskbits (x, w, startmask, endmask, nlw);
+ }
+ bits = src[y % stippleHeight];
+ RotBitsLeft (bits, (x & ((PGSZ-1) & ~PIM)));
+#if PPW == 4
+ if (cfb8StippleRRop == GXcopy)
+ {
+ xor = devPriv->xor;
+ if (w < (PGSZ*2))
+ {
+ if (startmask)
+ {
+ mask = cfb8PixelMasks[GetBitGroup(bits)];
+ *dst = (*dst & ~(mask & startmask)) |
+ (xor & (mask & startmask));
+ dst++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ while (nlw--)
+ {
+ WriteBitGroup (dst,xor,GetBitGroup(bits))
+ dst++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ if (endmask)
+ {
+ mask = cfb8PixelMasks[GetBitGroup(bits)];
+ *dst = (*dst & ~(mask & endmask)) |
+ (xor & (mask & endmask));
+ }
+ }
+ else
+ { /* XXX constants probably not OK here */
+ wEnd = 7 - (nlw & 7);
+ nlw = (nlw >> 3) + 1;
+ dstTmp = dst;
+ nlwTmp = nlw;
+ if (startmask)
+ {
+ mask = cfb8PixelMasks[GetBitGroup(bits)];
+ *dstTmp = (*dstTmp & ~(mask & startmask)) |
+ (xor & (mask & startmask));
+ dstTmp++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ w = 7 - wEnd;
+ while (w--)
+ {
+ dst = dstTmp;
+ dstTmp++;
+ nlw = nlwTmp;
+#if defined(__GNUC__) && defined(mc68020)
+ mask = cfb8PixelMasks[GetBitGroup(bits)];
+ xor = xor & mask;
+ mask = ~mask;
+ while (nlw--)
+ {
+ *dst = (*dst & mask) | xor;
+ dst += 8;
+ }
+ xor = devPriv->xor;
+#else
+#define SwitchBitsLoop(body) \
+ while (nlw--) \
+ { \
+ body \
+ dst += 8; \
+ }
+ SwitchBitGroup(dst, xor, GetBitGroup(bits));
+#undef SwitchBitsLoop
+#endif
+ NextBitGroup (bits);
+ }
+ nlwTmp--;
+ w = wEnd + 1;
+ if (endmask)
+ {
+ mask = cfb8PixelMasks[GetBitGroup(bits)];
+ dst = dstTmp + (nlwTmp << 3);
+ *dst = (*dst & ~(mask & endmask)) |
+ (xor & (mask & endmask));
+ }
+ while (w--)
+ {
+ nlw = nlwTmp;
+ dst = dstTmp;
+ dstTmp++;
+#if defined(__GNUC__) && defined(mc68020)
+ mask = cfb8PixelMasks[GetBitGroup(bits)];
+ xor = xor & mask;
+ mask = ~mask;
+ while (nlw--)
+ {
+ *dst = (*dst & mask) | xor;
+ dst += 8;
+ }
+ xor = devPriv->xor;
+#else
+#define SwitchBitsLoop(body) \
+ while (nlw--) \
+ { \
+ body \
+ dst += 8; \
+ }
+ SwitchBitGroup(dst, xor, GetBitGroup(bits));
+#undef SwitchBitsLoop
+#endif
+ NextBitGroup (bits);
+ }
+ }
+ }
+ else
+#endif /* PPW == 4 */
+ {
+ if (startmask)
+ {
+ xor = GetBitGroup(bits);
+ *dst = MaskRRopPixels(*dst, xor, startmask);
+ dst++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ while (nlw--)
+ {
+ RRopBitGroup(dst, GetBitGroup(bits));
+ dst++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ if (endmask)
+ {
+ xor = GetBitGroup(bits);
+ *dst = MaskRRopPixels(*dst, xor, endmask);
+ }
+ }
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+void
+cfb8OpaqueStipple32FS (pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ DDXPointPtr ppt; /* pointer to list of start points */
+ int *pwidth; /* pointer to list of n widths */
+ CfbBits *src; /* pointer to bits in stipple, if needed */
+ int stippleHeight; /* height of the stipple */
+ PixmapPtr stipple;
+
+ int nlwDst; /* width in longwords of the dest pixmap */
+ int x,y,w; /* current span */
+ CfbBits startmask;
+ CfbBits endmask;
+ register CfbBits *dst; /* pointer to bits we're writing */
+ register int nlw;
+ CfbBits *dstTmp;
+ int nlwTmp;
+
+ CfbBits *pbits; /* pointer to start of pixmap */
+ register CfbBits xor;
+ register CfbBits bits; /* bits from stipple */
+ int wEnd;
+
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ cfbPrivGCPtr devPriv;
+
+ devPriv = cfbGetGCPrivate(pGC);
+
+ cfb8CheckOpaqueStipple(pGC->alu, pGC->fgPixel, pGC->bgPixel, pGC->planemask);
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ if ( n == 0 )
+ return;
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ stipple = pGC->pRotatedPixmap;
+ src = (CfbBits *)stipple->devPrivate.ptr;
+ stippleHeight = stipple->drawable.height;
+
+ cfbGetLongWidthAndPointer (pDrawable, nlwDst, pbits)
+
+ while (n--)
+ {
+ w = *pwidth++;
+ x = ppt->x;
+ y = ppt->y;
+ ppt++;
+ dst = pbits + (y * nlwDst) + (x >> PWSH);
+ if (((x & PIM) + w) <= PPW)
+ {
+ maskpartialbits(x, w, startmask);
+ endmask = 0;
+ nlw = 0;
+ }
+ else
+ {
+ maskbits (x, w, startmask, endmask, nlw);
+ }
+ bits = src[y % stippleHeight];
+ RotBitsLeft (bits, (x & ((PGSZ-1) & ~PIM)));
+#if PPW == 4
+ if (cfb8StippleRRop == GXcopy)
+ {
+ xor = devPriv->xor;
+ if (w < PGSZ*2)
+ {
+ if (startmask)
+ {
+ *dst = (*dst & ~startmask) |
+ (GetPixelGroup (bits) & startmask);
+ dst++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ while (nlw--)
+ {
+ *dst++ = GetPixelGroup(bits);
+ RotBitsLeft (bits, PGSZB);
+ }
+ if (endmask)
+ {
+ *dst = (*dst & ~endmask) |
+ (GetPixelGroup (bits) & endmask);
+ }
+ }
+ else
+ { /* XXX consts probably not OK here */
+ wEnd = 7 - (nlw & 7);
+ nlw = (nlw >> 3) + 1;
+ dstTmp = dst;
+ nlwTmp = nlw;
+ if (startmask)
+ {
+ *dstTmp = (*dstTmp & ~startmask) |
+ (GetPixelGroup (bits) & startmask);
+ dstTmp++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ w = 7 - wEnd;
+ while (w--)
+ {
+ nlw = nlwTmp;
+ dst = dstTmp;
+ dstTmp++;
+ xor = GetPixelGroup (bits);
+ while (nlw--)
+ {
+ *dst = xor;
+ dst += 8;
+ }
+ NextBitGroup (bits);
+ }
+ nlwTmp--;
+ w = wEnd + 1;
+ if (endmask)
+ {
+ dst = dstTmp + (nlwTmp << 3);
+ *dst = (*dst & ~endmask) |
+ (GetPixelGroup (bits) & endmask);
+ }
+ while (w--)
+ {
+ nlw = nlwTmp;
+ dst = dstTmp;
+ dstTmp++;
+ xor = GetPixelGroup (bits);
+ while (nlw--)
+ {
+ *dst = xor;
+ dst += 8;
+ }
+ NextBitGroup (bits);
+ }
+ }
+ }
+ else
+#endif /* PPW == 4 */
+ {
+ if (startmask)
+ {
+ xor = GetBitGroup(bits);
+ *dst = MaskRRopPixels(*dst, xor, startmask);
+ dst++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ while (nlw--)
+ {
+ RRopBitGroup(dst, GetBitGroup(bits));
+ dst++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ if (endmask)
+ {
+ xor = GetBitGroup(bits);
+ *dst = MaskRRopPixels(*dst, xor, endmask);
+ }
+ }
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+#endif /* PSZ == 8 */
diff --git a/nx-X11/programs/Xserver/cfb/cfbgc.c b/nx-X11/programs/Xserver/cfb/cfbgc.c
new file mode 100644
index 000000000..9cf53d35b
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbgc.c
@@ -0,0 +1,811 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfbgc.c,v 1.5 2001/01/17 22:36:35 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* $Xorg: cfbgc.c,v 1.4 2001/02/09 02:04:37 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "cfb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "region.h"
+
+#include "mistruct.h"
+#include "mibstore.h"
+#include "migc.h"
+
+#include "cfbmskbits.h"
+#include "cfb8bit.h"
+
+#if PSZ == 8
+# define useTEGlyphBlt cfbTEGlyphBlt8
+#else
+# ifdef WriteBitGroup
+# define useTEGlyphBlt cfbImageGlyphBlt8
+# else
+# define useTEGlyphBlt cfbTEGlyphBlt
+# endif
+#endif
+
+#ifdef WriteBitGroup
+# define useImageGlyphBlt cfbImageGlyphBlt8
+# define usePolyGlyphBlt cfbPolyGlyphBlt8
+#else
+# define useImageGlyphBlt miImageGlyphBlt
+# define usePolyGlyphBlt miPolyGlyphBlt
+#endif
+
+static void cfbUnPushPixels (GCPtr, PixmapPtr, DrawablePtr, int, int, int, int);
+
+#ifdef FOUR_BIT_CODE
+# define usePushPixels cfbPushPixels8
+#else
+# define usePushPixels cfbUnPushPixels
+#endif
+
+#ifdef PIXEL_ADDR
+# define ZeroPolyArc cfbZeroPolyArcSS8Copy
+#else
+# define ZeroPolyArc miZeroPolyArc
+#endif
+
+GCFuncs cfbGCFuncs = {
+ cfbValidateGC,
+ miChangeGC,
+ miCopyGC,
+ miDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip,
+};
+
+GCOps cfbTEOps1Rect = {
+ cfbSolidSpansCopy,
+ cfbSetSpans,
+ cfbPutImage,
+ cfbCopyArea,
+ cfbCopyPlane,
+ cfbPolyPoint,
+#ifdef PIXEL_ADDR
+ cfb8LineSS1Rect,
+ cfb8SegmentSS1Rect,
+#else
+ cfbLineSS,
+ cfbSegmentSS,
+#endif
+ miPolyRectangle,
+ ZeroPolyArc,
+ cfbFillPoly1RectCopy,
+ cfbPolyFillRect,
+ cfbPolyFillArcSolidCopy,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ useTEGlyphBlt,
+ usePolyGlyphBlt,
+ usePushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps cfbNonTEOps1Rect = {
+ cfbSolidSpansCopy,
+ cfbSetSpans,
+ cfbPutImage,
+ cfbCopyArea,
+ cfbCopyPlane,
+ cfbPolyPoint,
+#ifdef PIXEL_ADDR
+ cfb8LineSS1Rect,
+ cfb8SegmentSS1Rect,
+#else
+ cfbLineSS,
+ cfbSegmentSS,
+#endif
+ miPolyRectangle,
+ ZeroPolyArc,
+ cfbFillPoly1RectCopy,
+ cfbPolyFillRect,
+ cfbPolyFillArcSolidCopy,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ useImageGlyphBlt,
+ usePolyGlyphBlt,
+ usePushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps cfbTEOps = {
+ cfbSolidSpansCopy,
+ cfbSetSpans,
+ cfbPutImage,
+ cfbCopyArea,
+ cfbCopyPlane,
+ cfbPolyPoint,
+ cfbLineSS,
+ cfbSegmentSS,
+ miPolyRectangle,
+ ZeroPolyArc,
+ miFillPolygon,
+ cfbPolyFillRect,
+ cfbPolyFillArcSolidCopy,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ useTEGlyphBlt,
+ usePolyGlyphBlt,
+ usePushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps cfbNonTEOps = {
+ cfbSolidSpansCopy,
+ cfbSetSpans,
+ cfbPutImage,
+ cfbCopyArea,
+ cfbCopyPlane,
+ cfbPolyPoint,
+ cfbLineSS,
+ cfbSegmentSS,
+ miPolyRectangle,
+#ifdef PIXEL_ADDR
+ cfbZeroPolyArcSS8Copy,
+#else
+ miZeroPolyArc,
+#endif
+ miFillPolygon,
+ cfbPolyFillRect,
+ cfbPolyFillArcSolidCopy,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ useImageGlyphBlt,
+ usePolyGlyphBlt,
+ usePushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps *
+cfbMatchCommon (pGC, devPriv)
+ GCPtr pGC;
+ cfbPrivGCPtr devPriv;
+{
+ if (pGC->lineWidth != 0)
+ return 0;
+ if (pGC->lineStyle != LineSolid)
+ return 0;
+ if (pGC->fillStyle != FillSolid)
+ return 0;
+ if (devPriv->rop != GXcopy)
+ return 0;
+ if (pGC->font &&
+ FONTMAXBOUNDS(pGC->font,rightSideBearing) -
+ FONTMINBOUNDS(pGC->font,leftSideBearing) <= 32 &&
+ FONTMINBOUNDS(pGC->font,characterWidth) >= 0)
+ {
+ if (TERMINALFONT(pGC->font)
+#ifdef FOUR_BIT_CODE
+ && FONTMAXBOUNDS(pGC->font,characterWidth) >= PGSZB
+#endif
+ )
+#ifdef NO_ONE_RECT
+ return &cfbTEOps1Rect;
+#else
+ if (devPriv->oneRect)
+ return &cfbTEOps1Rect;
+ else
+ return &cfbTEOps;
+#endif
+ else
+#ifdef NO_ONE_RECT
+ return &cfbNonTEOps1Rect;
+#else
+ if (devPriv->oneRect)
+ return &cfbNonTEOps1Rect;
+ else
+ return &cfbNonTEOps;
+#endif
+ }
+ return 0;
+}
+
+Bool
+cfbCreateGC(pGC)
+ register GCPtr pGC;
+{
+ cfbPrivGC *pPriv;
+
+ if (PixmapWidthPaddingInfo[pGC->depth].padPixelsLog2 == LOG2_BITMAP_PAD)
+ return (mfbCreateGC(pGC));
+ pGC->clientClip = NULL;
+ pGC->clientClipType = CT_NONE;
+
+ if (cfbNonTEOps.PushPixels == cfbUnPushPixels)
+ {
+ cfbTEOps1Rect.PushPixels = mfbPushPixelsWeak();
+ cfbNonTEOps1Rect.PushPixels = mfbPushPixelsWeak();
+ cfbTEOps.PushPixels = mfbPushPixelsWeak();
+ cfbNonTEOps.PushPixels = mfbPushPixelsWeak();
+ }
+
+ /*
+ * some of the output primitives aren't really necessary, since they
+ * will be filled in ValidateGC because of dix/CreateGC() setting all
+ * the change bits. Others are necessary because although they depend
+ * on being a color frame buffer, they don't change
+ */
+
+ pGC->ops = &cfbNonTEOps;
+ pGC->funcs = &cfbGCFuncs;
+
+ /* cfb wants to translate before scan conversion */
+ pGC->miTranslate = 1;
+
+ pPriv = cfbGetGCPrivate(pGC);
+ pPriv->rop = pGC->alu;
+ pPriv->oneRect = FALSE;
+ pGC->fExpose = TRUE;
+ pGC->freeCompClip = FALSE;
+ pGC->pRotatedPixmap = (PixmapPtr) NULL;
+ return TRUE;
+}
+
+/* Clipping conventions
+ if the drawable is a window
+ CT_REGION ==> pCompositeClip really is the composite
+ CT_other ==> pCompositeClip is the window clip region
+ if the drawable is a pixmap
+ CT_REGION ==> pCompositeClip is the translated client region
+ clipped to the pixmap boundary
+ CT_other ==> pCompositeClip is the pixmap bounding box
+*/
+
+void
+cfbValidateGC(pGC, changes, pDrawable)
+ register GCPtr pGC;
+ unsigned long changes;
+ DrawablePtr pDrawable;
+{
+ int mask; /* stateChanges */
+ int index; /* used for stepping through bitfields */
+ int new_rrop;
+ int new_line, new_text, new_fillspans, new_fillarea;
+ int new_rotate;
+ int xrot, yrot;
+ /* flags for changing the proc vector */
+ cfbPrivGCPtr devPriv;
+ int oneRect;
+
+ new_rotate = pGC->lastWinOrg.x != pDrawable->x ||
+ pGC->lastWinOrg.y != pDrawable->y;
+
+ pGC->lastWinOrg.x = pDrawable->x;
+ pGC->lastWinOrg.y = pDrawable->y;
+ devPriv = cfbGetGCPrivate(pGC);
+
+ new_rrop = FALSE;
+ new_line = FALSE;
+ new_text = FALSE;
+ new_fillspans = FALSE;
+ new_fillarea = FALSE;
+
+ /*
+ * if the client clip is different or moved OR the subwindowMode has
+ * changed OR the window's clip has changed since the last validation
+ * we need to recompute the composite clip
+ */
+
+ if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
+ (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
+ )
+ {
+ miComputeCompositeClip (pGC, pDrawable);
+#ifdef NO_ONE_RECT
+ devPriv->oneRect = FALSE;
+#else
+ oneRect = REGION_NUM_RECTS(pGC->pCompositeClip) == 1;
+ if (oneRect != devPriv->oneRect)
+ new_line = TRUE;
+ devPriv->oneRect = oneRect;
+#endif
+ }
+
+ mask = changes;
+ while (mask) {
+ index = lowbit (mask);
+ mask &= ~index;
+
+ /*
+ * this switch acculmulates a list of which procedures might have
+ * to change due to changes in the GC. in some cases (e.g.
+ * changing one 16 bit tile for another) we might not really need
+ * a change, but the code is being paranoid. this sort of batching
+ * wins if, for example, the alu and the font have been changed,
+ * or any other pair of items that both change the same thing.
+ */
+ switch (index) {
+ case GCFunction:
+ case GCForeground:
+ new_rrop = TRUE;
+ break;
+ case GCPlaneMask:
+ new_rrop = TRUE;
+ new_text = TRUE;
+ break;
+ case GCBackground:
+ break;
+ case GCLineStyle:
+ case GCLineWidth:
+ new_line = TRUE;
+ break;
+ case GCJoinStyle:
+ case GCCapStyle:
+ break;
+ case GCFillStyle:
+ new_text = TRUE;
+ new_fillspans = TRUE;
+ new_line = TRUE;
+ new_fillarea = TRUE;
+ break;
+ case GCFillRule:
+ break;
+ case GCTile:
+ new_fillspans = TRUE;
+ new_fillarea = TRUE;
+ break;
+
+ case GCStipple:
+ if (pGC->stipple)
+ {
+ int width = pGC->stipple->drawable.width;
+ PixmapPtr nstipple;
+
+ if ((width <= PGSZ) && !(width & (width - 1)) &&
+ (nstipple = cfbCopyPixmap(pGC->stipple)))
+ {
+ cfbPadPixmap(nstipple);
+ (*pGC->pScreen->DestroyPixmap)(pGC->stipple);
+ pGC->stipple = nstipple;
+ }
+ }
+ new_fillspans = TRUE;
+ new_fillarea = TRUE;
+ break;
+
+ case GCTileStipXOrigin:
+ new_rotate = TRUE;
+ break;
+
+ case GCTileStipYOrigin:
+ new_rotate = TRUE;
+ break;
+
+ case GCFont:
+ new_text = TRUE;
+ break;
+ case GCSubwindowMode:
+ break;
+ case GCGraphicsExposures:
+ break;
+ case GCClipXOrigin:
+ break;
+ case GCClipYOrigin:
+ break;
+ case GCClipMask:
+ break;
+ case GCDashOffset:
+ break;
+ case GCDashList:
+ break;
+ case GCArcMode:
+ break;
+ default:
+ break;
+ }
+ }
+
+ /*
+ * If the drawable has changed, ensure suitable
+ * entries are in the proc vector.
+ */
+ if (pDrawable->serialNumber != (pGC->serialNumber & (DRAWABLE_SERIAL_BITS))) {
+ new_fillspans = TRUE; /* deal with FillSpans later */
+ }
+
+ if (new_rotate || new_fillspans)
+ {
+ Bool new_pix = FALSE;
+
+ xrot = pGC->patOrg.x + pDrawable->x;
+ yrot = pGC->patOrg.y + pDrawable->y;
+
+ switch (pGC->fillStyle)
+ {
+ case FillTiled:
+ if (!pGC->tileIsPixel)
+ {
+ int width = pGC->tile.pixmap->drawable.width * PSZ;
+
+ if ((width <= PGSZ) && !(width & (width - 1)))
+ {
+ cfbCopyRotatePixmap(pGC->tile.pixmap, &pGC->pRotatedPixmap,
+ xrot, yrot);
+ new_pix = TRUE;
+ }
+ }
+ break;
+#ifdef FOUR_BIT_CODE
+ case FillStippled:
+ case FillOpaqueStippled:
+ {
+ int width = pGC->stipple->drawable.width;
+
+ if ((width <= PGSZ) && !(width & (width - 1)))
+ {
+ mfbCopyRotatePixmap(pGC->stipple, &pGC->pRotatedPixmap,
+ xrot, yrot);
+ new_pix = TRUE;
+ }
+ }
+ break;
+#endif
+ }
+ if (!new_pix && pGC->pRotatedPixmap)
+ {
+ (*pGC->pScreen->DestroyPixmap)(pGC->pRotatedPixmap);
+ pGC->pRotatedPixmap = (PixmapPtr) NULL;
+ }
+ }
+
+ if (new_rrop)
+ {
+ int old_rrop;
+
+ old_rrop = devPriv->rop;
+ devPriv->rop = cfbReduceRasterOp (pGC->alu, pGC->fgPixel,
+ pGC->planemask,
+ &devPriv->and, &devPriv->xor);
+ if (old_rrop == devPriv->rop)
+ new_rrop = FALSE;
+ else
+ {
+#ifdef PIXEL_ADDR
+ new_line = TRUE;
+#endif
+#ifdef WriteBitGroup
+ new_text = TRUE;
+#endif
+ new_fillspans = TRUE;
+ new_fillarea = TRUE;
+ }
+ }
+
+ if (new_rrop || new_fillspans || new_text || new_fillarea || new_line)
+ {
+ GCOps *newops;
+
+ if ((newops = cfbMatchCommon (pGC, devPriv)))
+ {
+ if (pGC->ops->devPrivate.val)
+ miDestroyGCOps (pGC->ops);
+ pGC->ops = newops;
+ new_rrop = new_line = new_fillspans = new_text = new_fillarea = 0;
+ }
+ else
+ {
+ if (!pGC->ops->devPrivate.val)
+ {
+ pGC->ops = miCreateGCOps (pGC->ops);
+ pGC->ops->devPrivate.val = 1;
+ }
+ }
+ }
+
+ /* deal with the changes we've collected */
+ if (new_line)
+ {
+ pGC->ops->FillPolygon = miFillPolygon;
+#ifdef NO_ONE_RECT
+ if (pGC->fillStyle == FillSolid)
+ {
+ switch (devPriv->rop) {
+ case GXcopy:
+ pGC->ops->FillPolygon = cfbFillPoly1RectCopy;
+ break;
+ default:
+ pGC->ops->FillPolygon = cfbFillPoly1RectGeneral;
+ break;
+ }
+ }
+#else
+ if (devPriv->oneRect && pGC->fillStyle == FillSolid)
+ {
+ switch (devPriv->rop) {
+ case GXcopy:
+ pGC->ops->FillPolygon = cfbFillPoly1RectCopy;
+ break;
+ default:
+ pGC->ops->FillPolygon = cfbFillPoly1RectGeneral;
+ break;
+ }
+ }
+#endif
+ if (pGC->lineWidth == 0)
+ {
+#ifdef PIXEL_ADDR
+ if ((pGC->lineStyle == LineSolid) && (pGC->fillStyle == FillSolid))
+ {
+ switch (devPriv->rop)
+ {
+ case GXxor:
+ pGC->ops->PolyArc = cfbZeroPolyArcSS8Xor;
+ break;
+ case GXcopy:
+ pGC->ops->PolyArc = cfbZeroPolyArcSS8Copy;
+ break;
+ default:
+ pGC->ops->PolyArc = cfbZeroPolyArcSS8General;
+ break;
+ }
+ }
+ else
+#endif
+ pGC->ops->PolyArc = miZeroPolyArc;
+ }
+ else
+ pGC->ops->PolyArc = miPolyArc;
+ pGC->ops->PolySegment = miPolySegment;
+ switch (pGC->lineStyle)
+ {
+ case LineSolid:
+ if(pGC->lineWidth == 0)
+ {
+ if (pGC->fillStyle == FillSolid)
+ {
+#if defined(PIXEL_ADDR) && !defined(NO_ONE_RECT)
+ if (devPriv->oneRect &&
+ ((pDrawable->x >= pGC->pScreen->width - 32768) &&
+ (pDrawable->y >= pGC->pScreen->height - 32768)))
+ {
+ pGC->ops->Polylines = cfb8LineSS1Rect;
+ pGC->ops->PolySegment = cfb8SegmentSS1Rect;
+ } else
+#endif
+#ifdef NO_ONE_RECT
+ {
+ pGC->ops->Polylines = cfb8LineSS1Rect;
+ pGC->ops->PolySegment = cfb8SegmentSS1Rect;
+ }
+#else
+ {
+ pGC->ops->Polylines = cfbLineSS;
+ pGC->ops->PolySegment = cfbSegmentSS;
+ }
+#endif
+ }
+ else
+ pGC->ops->Polylines = miZeroLine;
+ }
+ else
+ pGC->ops->Polylines = miWideLine;
+ break;
+ case LineOnOffDash:
+ case LineDoubleDash:
+ if (pGC->lineWidth == 0 && pGC->fillStyle == FillSolid)
+ {
+ pGC->ops->Polylines = cfbLineSD;
+ pGC->ops->PolySegment = cfbSegmentSD;
+ } else
+ pGC->ops->Polylines = miWideDash;
+ break;
+ }
+ }
+
+ if (new_text && (pGC->font))
+ {
+ if (FONTMAXBOUNDS(pGC->font,rightSideBearing) -
+ FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 ||
+ FONTMINBOUNDS(pGC->font,characterWidth) < 0)
+ {
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
+ }
+ else
+ {
+#ifdef WriteBitGroup
+ if (pGC->fillStyle == FillSolid)
+ {
+ if (devPriv->rop == GXcopy)
+ pGC->ops->PolyGlyphBlt = cfbPolyGlyphBlt8;
+ else
+#ifdef FOUR_BIT_CODE
+ pGC->ops->PolyGlyphBlt = cfbPolyGlyphRop8;
+#else
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+#endif
+ }
+ else
+#endif
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ /* special case ImageGlyphBlt for terminal emulator fonts */
+#if !defined(WriteBitGroup) || PSZ == 8
+ if (TERMINALFONT(pGC->font) &&
+ (pGC->planemask & PMSK) == PMSK
+#ifdef FOUR_BIT_CODE
+ && FONTMAXBOUNDS(pGC->font,characterWidth) >= PGSZB
+#endif
+ )
+ {
+ pGC->ops->ImageGlyphBlt = useTEGlyphBlt;
+ }
+ else
+#endif
+ {
+#ifdef WriteBitGroup
+ if (devPriv->rop == GXcopy &&
+ pGC->fillStyle == FillSolid &&
+ (pGC->planemask & PMSK) == PMSK)
+ pGC->ops->ImageGlyphBlt = cfbImageGlyphBlt8;
+ else
+#endif
+ pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
+ }
+ }
+ }
+
+
+ if (new_fillspans) {
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ switch (devPriv->rop) {
+ case GXcopy:
+ pGC->ops->FillSpans = cfbSolidSpansCopy;
+ break;
+ case GXxor:
+ pGC->ops->FillSpans = cfbSolidSpansXor;
+ break;
+ default:
+ pGC->ops->FillSpans = cfbSolidSpansGeneral;
+ break;
+ }
+ break;
+ case FillTiled:
+ if (pGC->pRotatedPixmap)
+ {
+ if (pGC->alu == GXcopy && (pGC->planemask & PMSK) == PMSK)
+ pGC->ops->FillSpans = cfbTile32FSCopy;
+ else
+ pGC->ops->FillSpans = cfbTile32FSGeneral;
+ }
+ else
+ pGC->ops->FillSpans = cfbUnnaturalTileFS;
+ break;
+ case FillStippled:
+#ifdef FOUR_BIT_CODE
+ if (pGC->pRotatedPixmap)
+ pGC->ops->FillSpans = cfb8Stipple32FS;
+ else
+#endif
+ pGC->ops->FillSpans = cfbUnnaturalStippleFS;
+ break;
+ case FillOpaqueStippled:
+#ifdef FOUR_BIT_CODE
+ if (pGC->pRotatedPixmap)
+ pGC->ops->FillSpans = cfb8OpaqueStipple32FS;
+ else
+#endif
+ pGC->ops->FillSpans = cfbUnnaturalStippleFS;
+ break;
+ default:
+ FatalError("cfbValidateGC: illegal fillStyle\n");
+ }
+ } /* end of new_fillspans */
+
+ if (new_fillarea) {
+#ifndef FOUR_BIT_CODE
+ pGC->ops->PolyFillRect = miPolyFillRect;
+ if (pGC->fillStyle == FillSolid || pGC->fillStyle == FillTiled)
+ {
+ pGC->ops->PolyFillRect = cfbPolyFillRect;
+ }
+#endif
+#ifdef FOUR_BIT_CODE
+ pGC->ops->PushPixels = mfbPushPixelsWeak();
+ if (pGC->fillStyle == FillSolid && devPriv->rop == GXcopy)
+ pGC->ops->PushPixels = cfbPushPixels8;
+#endif
+ pGC->ops->PolyFillArc = miPolyFillArc;
+ if (pGC->fillStyle == FillSolid)
+ {
+ switch (devPriv->rop)
+ {
+ case GXcopy:
+ pGC->ops->PolyFillArc = cfbPolyFillArcSolidCopy;
+ break;
+ default:
+ pGC->ops->PolyFillArc = cfbPolyFillArcSolidGeneral;
+ break;
+ }
+ }
+ }
+}
+
+/*
+ * this is never called, it just exists to have its address
+ * taken in mfbCreateGC.
+ */
+static void
+cfbUnPushPixels (pGC, pBitmap, pDrawable, dx, dy, xOrg, yOrg)
+ GCPtr pGC;
+ PixmapPtr pBitmap;
+ DrawablePtr pDrawable;
+ int dx, dy, xOrg, yOrg;
+{
+ return;
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbgetsp.c b/nx-X11/programs/Xserver/cfb/cfbgetsp.c
new file mode 100644
index 000000000..44e31a241
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbgetsp.c
@@ -0,0 +1,215 @@
+/* $Xorg: cfbgetsp.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/cfb/cfbgetsp.c,v 3.9tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+
+#include "misc.h"
+#include "region.h"
+#include "gc.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+
+/* GetSpans -- for each span, gets bits from drawable starting at ppt[i]
+ * and continuing for pwidth[i] bits
+ * Each scanline returned will be server scanline padded, i.e., it will come
+ * out to an integral number of words.
+ */
+void
+cfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pchardstStart)
+ DrawablePtr pDrawable; /* drawable from which to get bits */
+ int wMax; /* largest value of all *pwidths */
+ register DDXPointPtr ppt; /* points to start copying from */
+ int *pwidth; /* list of number of bits to copy */
+ int nspans; /* number of scanlines to copy */
+ char *pchardstStart; /* where to put the bits */
+{
+ PixelGroup *pdstStart = (PixelGroup *)pchardstStart;
+ register PixelGroup *pdst; /* where to put the bits */
+ register PixelGroup *psrc; /* where to get the bits */
+ register PixelGroup tmpSrc; /* scratch buffer for bits */
+ PixelGroup *psrcBase; /* start of src bitmap */
+ int widthSrc; /* width of pixmap in bytes */
+ register DDXPointPtr pptLast; /* one past last point to get */
+ int xEnd; /* last pixel to copy from */
+ int nl, srcBit;
+ int w;
+ PixelGroup *pdstNext;
+#if PSZ == 24
+ register char *psrcb, *pdstb;
+ register int xIndex = 0;
+#else
+ register int nstart;
+#if PSZ != 32 || PPW != 1
+ int nend;
+#endif
+ PixelGroup startmask, endmask;
+ int nlMiddle;
+#endif
+
+ switch (pDrawable->bitsPerPixel) {
+ case 1:
+ mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pchardstStart);
+ return;
+ case PSZ:
+ break;
+ default:
+ FatalError("cfbGetSpans: invalid depth\n");
+ }
+
+ /*
+ * XFree86 DDX empties the root borderClip when the VT is
+ * switched away; this checks for that case
+ */
+ if (!cfbDrawableEnabled(pDrawable))
+ return;
+
+ cfbGetLongWidthAndPointer (pDrawable, widthSrc, psrcBase)
+
+#ifdef PIXEL_ADDR
+# if PSZ != 24
+ if ((nspans == 1) && (*pwidth == 1))
+ {
+ tmpSrc = *((PixelType *)(psrcBase + (ppt->y * widthSrc))
+ + ppt->x);
+#if BITMAP_BIT_ORDER == MSBFirst
+ tmpSrc <<= (sizeof (CfbBits) - sizeof (PixelType)) * 8;
+#endif
+ *pdstStart = tmpSrc;
+ return;
+ }
+# endif /* PSZ != 24 */
+#endif
+ pdst = pdstStart;
+ pptLast = ppt + nspans;
+ while(ppt < pptLast)
+ {
+#if PSZ == 24
+ xEnd = min(ppt->x + *pwidth, widthSrc * sizeof(CfbBits) / 3);
+ w = xEnd - ppt->x;
+ psrc = psrcBase + ppt->y * widthSrc;
+ srcBit = ppt->x;
+ psrcb = (char *)psrc + (ppt->x * 3);
+ xIndex = 0;
+ pdstb = (char *)pdst;
+ pdstNext = pdst + ((w * 3 + 3) >> 2);
+#else
+ xEnd = min(ppt->x + *pwidth, widthSrc << PWSH);
+ w = xEnd - ppt->x;
+ psrc = psrcBase + ppt->y * widthSrc + (ppt->x >> PWSH);
+ srcBit = ppt->x & PIM;
+ pdstNext = pdst + ((w + PPW - 1) >> PWSH);
+#endif
+
+#if PSZ == 24
+ if (w < 0)
+ FatalError("cfb24GetSpans: Internal error (w < 0)\n");
+ nl = w;
+ while (nl--){
+ psrc = (PixelGroup *)((unsigned long)psrcb & ~0x03);
+ getbits24(psrc, tmpSrc, srcBit);
+ pdst = (PixelGroup *)((unsigned long)pdstb & ~0x03);
+ putbits24(tmpSrc, PPW, pdst, ~((CfbBits)0), xIndex);
+ srcBit++;
+ psrcb += 3;
+ xIndex++;
+ pdstb += 3;
+ }
+ pdst = pdstNext;
+#else /* PSZ == 24 */
+ if (srcBit + w <= PPW)
+ {
+ getbits(psrc, srcBit, w, tmpSrc);
+ putbits(tmpSrc, 0, w, pdst, ~((CfbBits)0));
+ pdst++;
+ }
+ else
+ {
+ maskbits(ppt->x, w, startmask, endmask, nlMiddle);
+ nstart = 0;
+ if (startmask)
+ {
+ nstart = PPW - srcBit;
+ getbits(psrc, srcBit, nstart, tmpSrc);
+ putbits(tmpSrc, 0, nstart, pdst, ~((CfbBits)0));
+ if(srcBit + nstart >= PPW)
+ psrc++;
+ }
+ nl = nlMiddle;
+ while (nl--)
+ {
+ tmpSrc = *psrc;
+ putbits(tmpSrc, nstart, PPW, pdst, ~((CfbBits)0));
+ psrc++;
+ pdst++;
+ }
+ if (endmask)
+ {
+#if PSZ != 32 || PPW != 1
+ nend = xEnd & PIM;
+#endif
+ getbits(psrc, 0, nend, tmpSrc);
+ putbits(tmpSrc, nstart, nend, pdst, ~((CfbBits)0));
+ }
+ pdst = pdstNext;
+ }
+#endif /* PSZ == 24 */
+ ppt++;
+ pwidth++;
+ }
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbglblt8.c b/nx-X11/programs/Xserver/cfb/cfbglblt8.c
new file mode 100644
index 000000000..fda848fde
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbglblt8.c
@@ -0,0 +1,479 @@
+/* $Xorg: cfbglblt8.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+/* $XFree86: xc/programs/Xserver/cfb/cfbglblt8.c,v 3.7 2003/07/16 01:38:37 dawes Exp $ */
+
+/*
+ * Poly glyph blt. Accepts an arbitrary font <= 32 bits wide, in Copy mode
+ * only.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "cfb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "cfbmskbits.h"
+#include "cfb8bit.h"
+
+#define BOX_OVERLAP(box1, box2, xoffset, yoffset) \
+ ((box1)->x1 <= ((int) (box2)->x2 + (xoffset)) && \
+ ((int) (box2)->x1 + (xoffset)) <= (box1)->x2 && \
+ (box1)->y1 <= ((int) (box2)->y2 + (yoffset)) && \
+ ((int) (box2)->y1 + (yoffset)) <= (box1)->y2)
+
+#define BOX_CONTAINS(box1, box2, xoffset, yoffset) \
+ ((box1)->x1 <= ((int) (box2)->x1 + (xoffset)) && \
+ ((int) (box2)->x2 + (xoffset)) <= (box1)->x2 && \
+ (box1)->y1 <= ((int) (box2)->y1 + (yoffset)) && \
+ ((int) (box2)->y2 + (yoffset)) <= (box1)->y2)
+
+#if defined(FOUR_BIT_CODE) || defined(WriteBitGroup) && !defined(GLYPHROP)
+
+#if GLYPHPADBYTES != 4
+#define USE_LEFTBITS
+#endif
+
+#ifdef USE_LEFTBITS
+typedef unsigned char *glyphPointer;
+
+#define GlyphBits(bits,width,dst) getleftbits(bits,width,dst); \
+ (dst) &= widthMask; \
+ (bits) += widthGlyph;
+#define GlyphBitsS(bits,width,dst,off) GlyphBits(bits,width,dst); \
+ dst = BitRight (dst, off);
+#else
+typedef CARD32 *glyphPointer;
+
+#define GlyphBits(bits,width,dst) dst = *bits++;
+#define GlyphBitsS(bits,width,dst,off) dst = BitRight(*bits++, off);
+#endif
+
+#ifdef GLYPHROP
+#define cfbPolyGlyphBlt8 cfbPolyGlyphRop8
+#define cfbPolyGlyphBlt8Clipped cfbPolyGlyphRop8Clipped
+
+#undef WriteBitGroup
+#define WriteBitGroup(dst,pixel,bits) RRopBitGroup(dst,bits)
+
+#endif
+
+static void cfbPolyGlyphBlt8Clipped(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci, /* array of character info */
+ unsigned char *pglyphBase); /* start of array of glyphs */
+
+#if defined(HAS_STIPPLE_CODE) && !defined(GLYPHROP) && !defined(USE_LEFTBITS)
+#define USE_STIPPLE_CODE
+#endif
+
+#if defined(__GNUC__) && !defined(GLYPHROP) && (defined(mc68020) || defined(mc68000) || defined(__mc68000__)) && PSZ == 8 && !defined(USE_LEFTBITS)
+#ifdef USE_STIPPLE_CODE
+#undef USE_STIPPLE_CODE
+#endif
+#include "stip68kgnu.h"
+#endif
+
+#if PSZ == 24
+#define DST_INC 3
+#else
+#define DST_INC (PGSZB >> PWSH)
+#endif
+
+/* cfbStippleStack/cfbStippleStackTE are coded in assembly language.
+ * They are only provided on some architecures.
+ */
+#ifdef USE_STIPPLE_CODE
+extern void cfbStippleStack (), cfbStippleStackTE ();
+#endif
+
+void
+cfbPolyGlyphBlt8 (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+#ifndef GLYPHROP
+ register CfbBits pixel;
+#endif
+#if !defined(STIPPLE) && !defined(USE_STIPPLE_CODE)
+ register CfbBits c;
+ register CfbBits *dst;
+#endif
+ register glyphPointer glyphBits;
+ register int xoff;
+
+ FontPtr pfont = pGC->font;
+ CharInfoPtr pci;
+ CfbBits *dstLine;
+ CfbBits *pdstBase;
+ int hTmp;
+ int bwidthDst;
+ int widthDst;
+ int h;
+ BoxRec bbox; /* for clipping */
+ int w;
+ RegionPtr clip;
+ BoxPtr extents;
+#ifdef USE_LEFTBITS
+ int widthGlyph;
+ CfbBits widthMask;
+#endif
+#ifndef STIPPLE
+#ifdef USE_STIPPLE_CODE
+ void (*stipple)();
+
+ stipple = cfbStippleStack;
+ if (FONTCONSTMETRICS(pfont))
+ stipple = cfbStippleStackTE;
+#endif
+#endif
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ /* compute an approximate (but covering) bounding box */
+ bbox.x1 = 0;
+ if ((ppci[0]->metrics.leftSideBearing < 0))
+ bbox.x1 = ppci[0]->metrics.leftSideBearing;
+ h = nglyph - 1;
+ w = ppci[h]->metrics.rightSideBearing;
+ while (--h >= 0)
+ w += ppci[h]->metrics.characterWidth;
+ bbox.x2 = w;
+ bbox.y1 = -FONTMAXBOUNDS(pfont,ascent);
+ bbox.y2 = FONTMAXBOUNDS(pfont,descent);
+
+ clip = cfbGetCompositeClip(pGC);
+ extents = &clip->extents;
+
+ if (!clip->data)
+ {
+ if (!BOX_CONTAINS(extents, &bbox, x, y))
+ {
+ if (BOX_OVERLAP (extents, &bbox, x, y))
+ cfbPolyGlyphBlt8Clipped(pDrawable, pGC, x, y,
+ nglyph, ppci, pglyphBase);
+ return;
+ }
+ }
+ else
+ {
+ /* check to make sure some of the text appears on the screen */
+ if (!BOX_OVERLAP (extents, &bbox, x, y))
+ return;
+
+ bbox.x1 += x;
+ bbox.x2 += x;
+ bbox.y1 += y;
+ bbox.y2 += y;
+
+ switch (RECT_IN_REGION(pGC->pScreen, clip, &bbox))
+ {
+ case rgnPART:
+ cfbPolyGlyphBlt8Clipped(pDrawable, pGC, x, y,
+ nglyph, ppci, pglyphBase);
+ case rgnOUT:
+ return;
+ }
+ }
+
+#ifdef GLYPHROP
+ cfb8CheckStipple (pGC->alu, pGC->fgPixel, pGC->planemask);
+#else
+ pixel = cfbGetGCPrivate(pGC)->xor;
+#endif
+
+ cfbGetTypedWidthAndPointer (pDrawable, bwidthDst, pdstBase, char, CfbBits)
+
+ widthDst = bwidthDst / PGSZB;
+ while (nglyph--)
+ {
+ pci = *ppci++;
+ glyphBits = (glyphPointer) FONTGLYPHBITS(pglyphBase,pci);
+ xoff = x + pci->metrics.leftSideBearing;
+#if PSZ == 24
+ dstLine = pdstBase + (y - pci->metrics.ascent) * widthDst +((xoff>> 2)*3);
+#else
+ dstLine = pdstBase +
+ (y - pci->metrics.ascent) * widthDst + (xoff >> PWSH);
+#endif
+ x += pci->metrics.characterWidth;
+ if ((hTmp = pci->metrics.descent + pci->metrics.ascent))
+ {
+#if PSZ == 24
+ xoff &= 0x03;
+#else
+ xoff &= PIM;
+#endif /* PSZ == 24 */
+#ifdef STIPPLE
+ STIPPLE(dstLine,glyphBits,pixel,bwidthDst,hTmp,xoff);
+#else
+#ifdef USE_STIPPLE_CODE
+ (*stipple)(dstLine,glyphBits,pixel,bwidthDst,hTmp,xoff);
+#else
+#ifdef USE_LEFTBITS
+ w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
+ widthGlyph = PADGLYPHWIDTHBYTES(w);
+ widthMask = mfbGetendtab(w);
+#endif
+ do {
+ dst = dstLine;
+ dstLine = (CfbBits *) (((char *) dstLine) + bwidthDst);
+ GlyphBits(glyphBits, w, c)
+ WriteBitGroup(dst, pixel, GetBitGroup(BitRight(c,xoff)));
+ dst += DST_INC;
+ c = BitLeft(c,PGSZB - xoff);
+ while (c)
+ {
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst += DST_INC;
+ }
+ } while (--hTmp);
+#endif /* USE_STIPPLE_CODE else */
+#endif /* STIPPLE else */
+ }
+ }
+}
+
+static void
+cfbPolyGlyphBlt8Clipped(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci, /* array of character info */
+ unsigned char *pglyphBase) /* start of array of glyphs */
+{
+#ifndef GLYPHROP
+ register CfbBits pixel;
+#endif
+#if !defined(STIPPLE) && !defined(USE_STIPPLE_CODE)
+ register CfbBits c;
+#endif
+ register glyphPointer glyphBits;
+ register int xoff;
+#if defined(USE_LEFTBITS) || (!defined(STIPPLE) && !defined(USE_STIPPLE_CODE))
+ register CfbBits *dst;
+#endif
+
+ CharInfoPtr pci;
+ FontPtr pfont = pGC->font;
+ CfbBits *dstLine;
+ CfbBits *pdstBase;
+#ifdef USE_LEFTBITS
+ CARD32 *cTmp;
+#endif
+ CARD32 *clips;
+ int maxAscent, maxDescent;
+ int minLeftBearing;
+ int hTmp;
+ int widthDst;
+ int bwidthDst;
+ int xG, yG;
+ BoxPtr pBox;
+ int numRects;
+ int w;
+ RegionPtr pRegion;
+ int yBand;
+#ifdef GLYPHROP
+ CfbBits bits;
+#endif
+#ifdef USE_LEFTBITS
+ int widthGlyph;
+ CfbBits widthMask;
+#endif
+
+#ifdef GLYPHROP
+ cfb8CheckStipple (pGC->alu, pGC->fgPixel, pGC->planemask);
+#else
+ pixel = cfbGetGCPrivate(pGC)->xor;
+#endif
+
+ cfbGetTypedWidthAndPointer (pDrawable, bwidthDst, pdstBase, char, CfbBits)
+
+ widthDst = bwidthDst / PGSZB;
+ maxAscent = FONTMAXBOUNDS(pfont,ascent);
+ maxDescent = FONTMAXBOUNDS(pfont,descent);
+ minLeftBearing = FONTMINBOUNDS(pfont,leftSideBearing);
+
+ pRegion = cfbGetCompositeClip(pGC);
+
+ pBox = REGION_RECTS(pRegion);
+ numRects = REGION_NUM_RECTS (pRegion);
+ while (numRects && pBox->y2 <= y - maxAscent)
+ {
+ ++pBox;
+ --numRects;
+ }
+ if (!numRects || pBox->y1 >= y + maxDescent)
+ return;
+ yBand = pBox->y1;
+ while (numRects && pBox->y1 == yBand && pBox->x2 <= x + minLeftBearing)
+ {
+ ++pBox;
+ --numRects;
+ }
+ if (!numRects)
+ return;
+ clips = (CARD32 *)ALLOCATE_LOCAL ((maxAscent + maxDescent) *
+ sizeof (CARD32));
+ while (nglyph--)
+ {
+ pci = *ppci++;
+ glyphBits = (glyphPointer) FONTGLYPHBITS(pglyphBase,pci);
+ w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
+ xG = x + pci->metrics.leftSideBearing;
+ yG = y - pci->metrics.ascent;
+ x += pci->metrics.characterWidth;
+ if ((hTmp = pci->metrics.descent + pci->metrics.ascent))
+ {
+#if PSZ == 24
+ dstLine = pdstBase + yG * widthDst + ((xG>> 2)*3);
+ /* never use (xG*3)>>2 */
+#else
+ dstLine = pdstBase + yG * widthDst + (xG >> PWSH);
+#endif
+#if PSZ == 24
+ xoff = xG & 3;
+#else
+ xoff = xG & PIM;
+#endif
+#ifdef USE_LEFTBITS
+ w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
+ widthGlyph = PADGLYPHWIDTHBYTES(w);
+ widthMask = mfbGetendtab(w);
+#endif
+ switch (cfb8ComputeClipMasks32 (pBox, numRects, xG, yG, w, hTmp, clips))
+ {
+ case rgnPART:
+#ifdef USE_LEFTBITS
+ cTmp = clips;
+ do {
+ dst = dstLine;
+ dstLine = (CfbBits *) (((char *) dstLine) + bwidthDst);
+ GlyphBits(glyphBits, w, c)
+ c &= *cTmp++;
+ if (c)
+ {
+ WriteBitGroup(dst, pixel, GetBitGroup(BitRight(c,xoff)));
+ c = BitLeft(c,PGSZB - xoff);
+ dst += DST_INC;
+ while (c)
+ {
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst += DST_INC;
+ }
+ }
+ } while (--hTmp);
+ break;
+#else /* !USE_LEFTBITS */
+ {
+ int h;
+
+ h = hTmp;
+ do
+ {
+ --h;
+ clips[h] = clips[h] & glyphBits[h];
+ } while (h);
+ }
+ glyphBits = clips;
+ /* fall through */
+#endif /* USE_LEFTBITS */
+ case rgnIN:
+#ifdef STIPPLE
+ STIPPLE(dstLine,glyphBits,pixel,bwidthDst,hTmp,xoff);
+#else
+#ifdef USE_STIPPLE_CODE
+ cfbStippleStackTE(dstLine,glyphBits,pixel,bwidthDst,hTmp,xoff);
+#else
+ do {
+ dst = dstLine;
+ dstLine = (CfbBits *) (((char *) dstLine) + bwidthDst);
+ GlyphBits(glyphBits, w, c)
+ if (c)
+ {
+ /* This code originally could read memory locations
+ * that were not mapped. Hence we have to check the
+ * trailing bits to see whether they are zero and if
+ * then skip them correctly. This is no problem for
+ * the GXcopy case, since there only the pixels that
+ * are non-zero are written ...
+ */
+#ifndef GLYPHROP
+ WriteBitGroup(dst, pixel, GetBitGroup(BitRight(c,xoff)));
+ c = BitLeft(c,PGSZB - xoff);
+ dst += DST_INC;
+#else /* GLYPHROP */
+ if ((bits = GetBitGroup(BitRight(c,xoff))))
+ WriteBitGroup(dst, pixel, bits);
+ c = BitLeft(c,PGSZB - xoff);
+ dst += DST_INC;
+
+ while (c && ((bits = GetBitGroup(c)) == 0))
+ {
+ NextBitGroup(c);
+ dst += DST_INC;
+ }
+#endif /* GLYPHROP */
+ while (c)
+ {
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst += DST_INC;
+ }
+ }
+ } while (--hTmp);
+#endif /* USE_STIPPLE_CODE else */
+#endif /* STIPPLE else */
+ break;
+ }
+ }
+ }
+ DEALLOCATE_LOCAL (clips);
+}
+
+#endif /* FOUR_BIT_CODE */
diff --git a/nx-X11/programs/Xserver/cfb/cfbhrzvert.c b/nx-X11/programs/Xserver/cfb/cfbhrzvert.c
new file mode 100644
index 000000000..4df991b00
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbhrzvert.c
@@ -0,0 +1,556 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfbhrzvert.c,v 3.6 2001/10/28 03:33:00 tsi Exp $ */
+/***********************************************************
+
+Copyright 1987,1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: cfbhrzvert.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "gc.h"
+#include "window.h"
+#include "pixmap.h"
+#include "region.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+
+/* horizontal solid line
+ abs(len) > 1
+*/
+void
+cfbHorzS(rop, and, xor, addrl, nlwidth, x1, y1, len)
+register int rop;
+register CfbBits and;
+register CfbBits xor;
+register CfbBits *addrl; /* pointer to base of bitmap */
+int nlwidth; /* width in longwords of bitmap */
+int x1; /* initial point */
+int y1;
+int len; /* length of line */
+{
+ register int nlmiddle;
+
+#if PSZ == 24
+
+ int leftIndex, rightIndex;
+ CfbBits piQxelAnd[3], piQxelXor[3];
+ piQxelAnd[0] = (and & 0xFFFFFF) | ((and<<24) & 0xFF000000);
+ piQxelAnd[1] = ((and>>8) & 0xFFFF)| ((and<<16) & 0xFFFF0000);
+ piQxelAnd[2] = ((and<<8) & 0xFFFFFF00) | ((and>>16) & 0xFF);
+
+ piQxelXor[0] = (xor & 0xFFFFFF) | ((xor<<24) & 0xFF000000);
+ piQxelXor[1] = ((xor>>8) & 0xFFFF)| ((xor<<16) & 0xFFFF0000);
+ piQxelXor[2] = ((xor<<8) & 0xFFFFFF00) | ((xor>>16) & 0xFF);
+
+ leftIndex = x1 & 3;
+ rightIndex = ((x1 + len) < 5)?0:(x1 + len)&3;
+ nlmiddle = len;
+ if(leftIndex){
+ nlmiddle -= (4 - leftIndex);
+ }
+ if(rightIndex){
+ nlmiddle -= rightIndex;
+ }
+ if (nlmiddle < 0)
+ nlmiddle = 0;
+
+ nlmiddle >>= 2;
+
+ addrl += (y1 * nlwidth) + (x1 >> 2)*3 + (leftIndex?leftIndex-1:0);
+
+ switch(leftIndex+len){
+ case 4:
+ switch(leftIndex){
+ case 0:
+ *addrl = DoRRop (*addrl, piQxelAnd[0], piQxelXor[0]);
+ addrl++;
+ *addrl = DoRRop (*addrl, piQxelAnd[1], piQxelXor[1]);
+ addrl++;
+ *addrl = DoRRop (*addrl, piQxelAnd[2], piQxelXor[2]);
+ break;
+ case 1:
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[0], piQxelXor[0], 0xFF000000);
+ addrl++;
+ *addrl = DoRRop (*addrl, piQxelAnd[1], piQxelXor[1]);
+ addrl++;
+ *addrl = DoRRop (*addrl, piQxelAnd[2], piQxelXor[2]);
+ break;
+ case 2:
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[1], piQxelXor[1], 0xFFFF0000);
+ addrl++;
+ *addrl = DoRRop (*addrl, piQxelAnd[2], piQxelXor[2]);
+ break;
+ case 3:
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[2], piQxelXor[2], 0xFFFFFF00);
+ break;
+ }
+ break;
+ case 3:
+ switch(leftIndex){
+ case 0:
+ *addrl = DoRRop (*addrl, piQxelAnd[0], piQxelXor[0]);
+ addrl++;
+ *addrl = DoRRop (*addrl, piQxelAnd[1], piQxelXor[1]);
+ addrl++;
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[2], piQxelXor[2], 0xFF);
+ break;
+ case 1:
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[0], piQxelXor[0], 0xFF000000);
+ addrl++;
+ *addrl = DoRRop (*addrl, piQxelAnd[1], piQxelXor[1]);
+ addrl++;
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[2], piQxelXor[2], 0xFF);
+ break;
+ case 2:
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[1], piQxelXor[1], 0xFFFF0000);
+ addrl++;
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[2], piQxelXor[2], 0xFF);
+ break;
+ }
+ break;
+ case 2:
+ if(leftIndex){
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[0], piQxelXor[0], 0xFF000000);
+ addrl++;
+ }
+ else{
+ *addrl = DoRRop (*addrl, piQxelAnd[0], piQxelXor[0]);
+ addrl++;
+ }
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[1], piQxelXor[1], 0xFFFF);
+ break;
+ case 1: /*only if leftIndex = 0 and w = 1*/
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[0], piQxelXor[0], 0xFFFFFF);
+ break;
+ case 0: /*never*/
+ break;
+ default:
+ {
+ if (rop == GXcopy){
+ switch(leftIndex){
+ case 0:
+ break;
+ case 1:
+ *addrl = ((*addrl) & 0xFFFFFF) | (piQxelXor[0] & 0xFF000000);
+ addrl++;
+ *addrl++ = piQxelXor[1];
+ *addrl++ = piQxelXor[2];
+ break;
+ case 2:
+ *addrl = ((*addrl) & 0xFFFF) | (piQxelXor[1] & 0xFFFF0000);
+ addrl++;
+ *addrl++ = piQxelXor[2];
+ break;
+ case 3:
+ *addrl = ((*addrl) & 0xFF) | (piQxelXor[2] & 0xFFFFFF00);
+ addrl++;
+ break;
+ }
+ while(nlmiddle--){
+ *addrl++ = piQxelXor[0];
+ *addrl++ = piQxelXor[1];
+ *addrl++ = piQxelXor[2];
+ }
+ switch(rightIndex){
+ case 0:
+ break;
+ case 1:
+ *addrl = ((*addrl) & 0xFF000000) | (piQxelXor[0] & 0xFFFFFF);
+ break;
+ case 2:
+ *addrl++ = piQxelXor[0];
+ *addrl = ((*addrl) & 0xFFFF0000) | (piQxelXor[1] & 0xFFFF);
+ break;
+ case 3:
+ *addrl++ = piQxelXor[0];
+ *addrl++ = piQxelXor[1];
+ *addrl = ((*addrl) & 0xFFFFFF00) | (piQxelXor[2] & 0xFF);
+ break;
+ }
+ }
+ else{
+ if(rop == GXxor){
+ switch(leftIndex){
+ case 0:
+ break;
+ case 1:
+ *addrl++ ^= (piQxelXor[0]&0xFF000000);
+ *addrl++ ^= piQxelXor[1];
+ *addrl++ ^= piQxelXor[2];
+ break;
+ case 2:
+ *addrl++ ^= (piQxelXor[1]& 0xFFFF0000);
+ *addrl++ ^= piQxelXor[2];
+ break;
+ case 3:
+ *addrl++ ^= (piQxelXor[2]& 0xFFFFFF00);
+ break;
+ }
+ while(nlmiddle--){
+ *addrl++ ^= piQxelXor[0];
+ *addrl++ ^= piQxelXor[1];
+ *addrl++ ^= piQxelXor[2];
+ }
+ switch(rightIndex){
+ case 0:
+ break;
+ case 1:
+ *addrl ^= (piQxelXor[0]& 0xFFFFFF);
+ break;
+ case 2:
+ *addrl++ ^= piQxelXor[0];
+ *addrl ^= (piQxelXor[1]&0xFFFF);
+ break;
+ case 3:
+ *addrl++ ^= piQxelXor[0];
+ *addrl++ ^= piQxelXor[1];
+ *addrl ^= (piQxelXor[2]&0xFF);
+ break;
+ }
+ }
+ else{
+ switch(leftIndex){
+ case 0:
+ break;
+ case 1:
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[0], piQxelXor[0], 0xFF000000);
+ addrl++;
+ *addrl = DoRRop (*addrl, piQxelAnd[1], piQxelXor[1]);
+ addrl++;
+ *addrl = DoRRop (*addrl, piQxelAnd[2], piQxelXor[2]);
+ addrl++;
+ break;
+ case 2:
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[1], piQxelXor[1], 0xFFFF0000);
+ addrl++;
+ *addrl = DoRRop (*addrl, piQxelAnd[2], piQxelXor[2]);
+ addrl++;
+ break;
+ case 3:
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[2], piQxelXor[2], 0xFFFFFF00);
+ addrl++;
+ break;
+ }
+ while(nlmiddle--){
+ *addrl = DoRRop (*addrl, piQxelAnd[0], piQxelXor[0]);
+ addrl++;
+ *addrl = DoRRop (*addrl, piQxelAnd[1], piQxelXor[1]);
+ addrl++;
+ *addrl = DoRRop (*addrl, piQxelAnd[2], piQxelXor[2]);
+ addrl++;
+ }
+ switch(rightIndex){
+ case 0:
+ break;
+ case 1:
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[0], piQxelXor[0], 0xFFFFFF);
+ addrl++;
+ break;
+ case 2:
+ *addrl = DoRRop (*addrl, piQxelAnd[0], piQxelXor[0]);
+ addrl++;
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[1], piQxelXor[1], 0xFFFF);
+ break;
+ case 3:
+ *addrl = DoRRop (*addrl, piQxelAnd[0], piQxelXor[0]);
+ addrl++;
+ *addrl = DoRRop (*addrl, piQxelAnd[1], piQxelXor[1]);
+ addrl++;
+ *addrl = DoMaskRRop (*addrl, piQxelAnd[2], piQxelXor[2], 0xFF);
+ break;
+ }
+
+ }
+ }
+ }
+ }
+#else
+ register CfbBits startmask;
+ register CfbBits endmask;
+
+ addrl = addrl + (y1 * nlwidth) + (x1 >> PWSH);
+
+ /* all bits inside same longword */
+ if ( ((x1 & PIM) + len) < PPW)
+ {
+ maskpartialbits(x1, len, startmask);
+ *addrl = DoMaskRRop (*addrl, and, xor, startmask);
+ }
+ else
+ {
+ maskbits(x1, len, startmask, endmask, nlmiddle);
+ if (rop == GXcopy)
+ {
+ if (startmask)
+ {
+ *addrl = (*addrl & ~startmask) | (xor & startmask);
+ addrl++;
+ }
+ while (nlmiddle--)
+ *addrl++ = xor;
+ if (endmask)
+ *addrl = (*addrl & ~endmask) | (xor & endmask);
+ }
+ else
+ {
+ if (startmask)
+ {
+ *addrl = DoMaskRRop (*addrl, and, xor, startmask);
+ addrl++;
+ }
+ if (rop == GXxor)
+ {
+ while (nlmiddle--)
+ *addrl++ ^= xor;
+ }
+ else
+ {
+ while (nlmiddle--)
+ {
+ *addrl = DoRRop (*addrl, and, xor);
+ addrl++;
+ }
+ }
+ if (endmask)
+ *addrl = DoMaskRRop (*addrl, and, xor, endmask);
+ }
+ }
+#endif
+}
+
+/* vertical solid line */
+
+void
+cfbVertS(rop, and, xor, addrl, nlwidth, x1, y1, len)
+int rop;
+register CfbBits and, xor;
+register CfbBits *addrl; /* pointer to base of bitmap */
+register int nlwidth; /* width in longwords of bitmap */
+int x1, y1; /* initial point */
+register int len; /* length of line */
+{
+#if PSZ == 24
+ int xIdx;
+ CfbBits and2 = 0, xor2 = 0, mask = 0, mask2;
+#endif
+#ifdef PIXEL_ADDR
+ register PixelType *bits = (PixelType *) addrl;
+
+#if PSZ == 24
+ nlwidth <<= PWSH;
+ xIdx = x1 & 3;
+ bits = (PixelType *)(addrl + (y1 * nlwidth) + ((x1*3) >> 2));
+#else
+ nlwidth <<= PWSH;
+ bits = bits + (y1 * nlwidth) + x1;
+#endif
+#if PSZ == 24
+ mask2 = 0;
+ switch(xIdx){
+ case 0:
+ mask = 0xFF000000;
+ xor &= 0xFFFFFF;
+ and |= 0xFF000000;
+ break;
+ case 3:
+ mask = 0xFF;
+ xor &= 0xFFFFFF;
+ xor <<= 8;
+ and <<= 8;
+ and |= 0xFF;
+ break;
+ case 1:
+ mask = 0xFFFFFF;
+ mask2 = 0xFFFF0000;
+ xor2 = (xor>>8) & 0xFFFF;
+ xor &= 0xFF;
+ xor <<= 24;
+ and2 = (and >> 8 ) | 0xFFFF0000;
+ and <<= 24;
+ and |= 0xFFFFFF;
+ break;
+ case 2:
+ mask = 0x0000FFFF;
+ mask2 = 0xFFFFFF00;
+ xor2 = (xor >> 16) & 0xFF;
+ xor <<= 16;
+ xor &= 0xFFFF0000;
+ and2 = (and >> 16) | 0xFFFFFF00;
+ and <<= 16;
+ and |= 0xFFFF;
+ break;
+ }
+#endif
+
+ /*
+ * special case copy and xor to avoid a test per pixel
+ */
+ if (rop == GXcopy)
+ {
+#if PSZ == 24
+ switch(xIdx){
+ case 0:
+ case 3:
+ while (len--){
+ *bits = (*bits & mask)| xor;
+ bits += nlwidth;
+ }
+ break;
+ case 1:
+ case 2:
+ while (len--){
+ *bits = (*bits & mask)| xor;
+ bits++;
+ *bits = (*bits & mask2)| xor2;
+ bits--;
+ bits += nlwidth;
+ }
+ break;
+ }
+#else
+ while (len--)
+ {
+ *bits = xor;
+ bits += nlwidth;
+ }
+#endif
+ }
+ else if (rop == GXxor)
+ {
+#if PSZ == 24
+ switch(xIdx){
+ case 0:
+ case 3:
+ while (len--){
+ *bits ^= xor;
+ bits += nlwidth;
+ }
+ break;
+ case 1:
+ case 2:
+ while (len--){
+ *bits ^= xor;
+ bits++;
+ *bits ^= xor2;
+ bits--;
+ bits += nlwidth;
+ }
+ break;
+ }
+#else
+ while (len--)
+ {
+ *bits ^= xor;
+ bits += nlwidth;
+ }
+#endif
+ }
+ else
+ {
+#if PSZ == 24
+ switch(xIdx){
+ case 0:
+ while (len--){
+ *bits = DoMaskRRop(*bits, and, xor, 0x00FFFFFF);
+ bits += nlwidth;
+ }
+ break;
+ case 3:
+ while (len--){
+ *bits = DoMaskRRop(*bits, and, xor, 0xFFFFFF00);
+ bits += nlwidth;
+ }
+ break;
+ case 1:
+ while (len--){
+ *bits = DoMaskRRop(*bits, and, xor, 0xFF000000);
+ bits++;
+ *bits = DoMaskRRop(*bits, and2, xor2, 0x0000FFFF);
+ bits--;
+ bits += nlwidth;
+ }
+ break;
+ case 2:
+ while (len--){
+ *bits = DoMaskRRop(*bits, and, xor, 0xFFFF0000);
+ bits++;
+ *bits = DoMaskRRop(*bits, and2, xor2, 0x000000FF);
+ bits--;
+ bits += nlwidth;
+ }
+ break;
+ }
+#else
+ while (len--)
+ {
+ *bits = DoRRop(*bits, and, xor);
+ bits += nlwidth;
+ }
+#endif
+ }
+#else /* !PIXEL_ADDR */
+#if PSZ == 24
+ addrl = addrl + (y1 * nlwidth) + ((x1*3) >>2);
+
+ and |= ~cfbmask[(x1 & 3)<<1];
+ xor &= cfbmask[(x1 & 3)<<1];
+#else
+ addrl = addrl + (y1 * nlwidth) + (x1 >> PWSH);
+
+ and |= ~cfbmask[x1 & PIM];
+ xor &= cfbmask[x1 & PIM];
+#endif
+
+ while (len--)
+ {
+ *addrl = DoRRop (*addrl, and, xor);
+ addrl += nlwidth;
+ }
+#endif
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbigblt8.c b/nx-X11/programs/Xserver/cfb/cfbigblt8.c
new file mode 100644
index 000000000..97356e8bd
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbigblt8.c
@@ -0,0 +1,108 @@
+/*
+ * $Xorg: cfbigblt8.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $
+ *
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/programs/Xserver/cfb/cfbigblt8.c,v 1.5 2001/10/28 03:33:01 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "mi.h"
+#include "cfb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "cfbmskbits.h"
+#include "cfb8bit.h"
+
+void
+cfbImageGlyphBlt8 (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci;
+ pointer pglyphBase;
+{
+ ExtentInfoRec info; /* used by QueryGlyphExtents() */
+ xRectangle backrect;
+ int fgPixel;
+ cfbPrivGC *priv;
+
+ /*
+ * We can't avoid GC validations if calling mi functions.
+ */
+ if ((pGC->ops->PolyFillRect == miPolyFillRect) ||
+ (pGC->ops->PolyGlyphBlt == miPolyGlyphBlt))
+ {
+ miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ return;
+ }
+
+ QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info);
+
+ if (info.overallWidth >= 0)
+ {
+ backrect.x = x;
+ backrect.width = info.overallWidth;
+ }
+ else
+ {
+ backrect.x = x + info.overallWidth;
+ backrect.width = -info.overallWidth;
+ }
+ backrect.y = y - FONTASCENT(pGC->font);
+ backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+
+ priv = cfbGetGCPrivate(pGC);
+
+ /* this code cheats by knowing that ValidateGC isn't
+ * necessary for PolyFillRect
+ */
+
+ fgPixel = pGC->fgPixel;
+
+ pGC->fgPixel = pGC->bgPixel;
+ priv->xor = PFILL(pGC->bgPixel);
+
+ (*pGC->ops->PolyFillRect) (pDrawable, pGC, 1, &backrect);
+
+ pGC->fgPixel = fgPixel;
+
+ priv->xor = PFILL(pGC->fgPixel);
+
+ (*pGC->ops->PolyGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbimage.c b/nx-X11/programs/Xserver/cfb/cfbimage.c
new file mode 100644
index 000000000..ce3909e63
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbimage.c
@@ -0,0 +1,206 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfbimage.c,v 1.12 2001/10/28 03:33:01 tsi Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: cfbimage.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "servermd.h"
+#include "mi.h"
+
+void
+cfbPutImage(pDraw, pGC, depth, x, y, w, h, leftPad, format, pImage)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int depth, x, y, w, h;
+ int leftPad;
+ int format;
+ char *pImage;
+{
+ PixmapPtr pPixmap;
+
+ if ((w == 0) || (h == 0))
+ return;
+
+ if (format != XYPixmap)
+ {
+ pPixmap = GetScratchPixmapHeader(pDraw->pScreen, w+leftPad, h, depth,
+ BitsPerPixel(depth), PixmapBytePad(w+leftPad, depth),
+ (pointer)pImage);
+ if (!pPixmap)
+ return;
+
+ pGC->fExpose = FALSE;
+ if (format == ZPixmap)
+ (void)(*pGC->ops->CopyArea)((DrawablePtr)pPixmap, pDraw, pGC,
+ leftPad, 0, w, h, x, y);
+ else
+ (void)(*pGC->ops->CopyPlane)((DrawablePtr)pPixmap, pDraw, pGC,
+ leftPad, 0, w, h, x, y, 1);
+ pGC->fExpose = TRUE;
+ FreeScratchPixmapHeader(pPixmap);
+ }
+ else
+ {
+ CfbBits oldFg, oldBg;
+ XID gcv[3];
+ CfbBits oldPlanemask;
+ unsigned long i;
+ long bytesPer;
+
+ depth = pGC->depth;
+ oldPlanemask = pGC->planemask;
+ oldFg = pGC->fgPixel;
+ oldBg = pGC->bgPixel;
+ gcv[0] = ~0L;
+ gcv[1] = 0;
+ DoChangeGC(pGC, GCForeground | GCBackground, gcv, 0);
+ bytesPer = (long)h * BitmapBytePad(w + leftPad);
+
+ for (i = 1 << (depth-1); i != 0; i >>= 1, pImage += bytesPer)
+ {
+ if (i & oldPlanemask)
+ {
+ gcv[0] = i;
+ DoChangeGC(pGC, GCPlaneMask, gcv, 0);
+ ValidateGC(pDraw, pGC);
+ (*pGC->ops->PutImage)(pDraw, pGC, 1, x, y, w, h, leftPad,
+ XYBitmap, pImage);
+ }
+ }
+ gcv[0] = oldPlanemask;
+ gcv[1] = oldFg;
+ gcv[2] = oldBg;
+ DoChangeGC(pGC, GCPlaneMask | GCForeground | GCBackground, gcv, 0);
+ ValidateGC(pDraw, pGC);
+ }
+}
+
+void
+cfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine)
+ DrawablePtr pDrawable;
+ int sx, sy, w, h;
+ unsigned int format;
+ unsigned long planeMask;
+ char *pdstLine;
+{
+ BoxRec box;
+ DDXPointRec ptSrc;
+ RegionRec rgnDst;
+ ScreenPtr pScreen;
+ PixmapPtr pPixmap;
+
+ if ((w == 0) || (h == 0))
+ return;
+ if (pDrawable->bitsPerPixel == 1)
+ {
+ mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+ return;
+ }
+ pScreen = pDrawable->pScreen;
+ /*
+ * XFree86 DDX empties the root borderClip when the VT is
+ * switched away; this checks for that case
+ */
+ if (!cfbDrawableEnabled (pDrawable))
+ return;
+ if (format == ZPixmap)
+ {
+ pPixmap = GetScratchPixmapHeader(pScreen, w, h,
+ pDrawable->depth, pDrawable->bitsPerPixel,
+ PixmapBytePad(w,pDrawable->depth), (pointer)pdstLine);
+ if (!pPixmap)
+ return;
+ if ((planeMask & PMSK) != PMSK)
+ bzero((char *)pdstLine, pPixmap->devKind * h);
+ ptSrc.x = sx + pDrawable->x;
+ ptSrc.y = sy + pDrawable->y;
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = w;
+ box.y2 = h;
+ REGION_INIT(pScreen, &rgnDst, &box, 1);
+ cfbDoBitblt(pDrawable, (DrawablePtr)pPixmap, GXcopy, &rgnDst,
+ &ptSrc, planeMask);
+ REGION_UNINIT(pScreen, &rgnDst);
+ FreeScratchPixmapHeader(pPixmap);
+ }
+ else
+ {
+
+#if IMAGE_BYTE_ORDER == LSBFirst
+
+ pPixmap = GetScratchPixmapHeader(pScreen, w, h, /*depth*/ 1,
+ /*bpp*/ 1, BitmapBytePad(w), (pointer)pdstLine);
+ if (!pPixmap)
+ return;
+
+ ptSrc.x = sx + pDrawable->x;
+ ptSrc.y = sy + pDrawable->y;
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = w;
+ box.y2 = h;
+ REGION_INIT(pScreen, &rgnDst, &box, 1);
+ cfbCopyImagePlane (pDrawable, (DrawablePtr)pPixmap, GXcopy, &rgnDst,
+ &ptSrc, planeMask);
+ REGION_UNINIT(pScreen, &rgnDst);
+ FreeScratchPixmapHeader(pPixmap);
+#else
+ miGetImage (pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+#endif
+ }
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbline.c b/nx-X11/programs/Xserver/cfb/cfbline.c
new file mode 100644
index 000000000..392fe483e
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbline.c
@@ -0,0 +1,757 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfbline.c,v 3.5 2001/10/28 03:33:01 tsi Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: cfbline.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "mistruct.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "miline.h"
+
+/* single-pixel lines on a color frame buffer
+
+ NON-SLOPED LINES
+ horizontal lines are always drawn left to right; we have to
+move the endpoints right by one after they're swapped.
+ horizontal lines will be confined to a single band of a
+region. the code finds that band (giving up if the lower
+bound of the band is above the line we're drawing); then it
+finds the first box in that band that contains part of the
+line. we clip the line to subsequent boxes in that band.
+ vertical lines are always drawn top to bottom (y-increasing.)
+this requires adding one to the y-coordinate of each endpoint
+after swapping.
+
+ SLOPED LINES
+ when clipping a sloped line, we bring the second point inside
+the clipping box, rather than one beyond it, and then add 1 to
+the length of the line before drawing it. this lets us use
+the same box for finding the outcodes for both endpoints. since
+the equation for clipping the second endpoint to an edge gives us
+1 beyond the edge, we then have to move the point towards the
+first point by one step on the major axis.
+ eventually, there will be a diagram here to explain what's going
+on. the method uses Cohen-Sutherland outcodes to determine
+outsideness, and a method similar to Pike's layers for doing the
+actual clipping.
+
+*/
+
+void
+#ifdef POLYSEGMENT
+cfbSegmentSS (pDrawable, pGC, nseg, pSeg)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nseg;
+ register xSegment *pSeg;
+#else
+cfbLineSS (pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt; /* number of points */
+ DDXPointPtr pptInit;
+#endif
+{
+ int nboxInit;
+ register int nbox;
+ BoxPtr pboxInit;
+ register BoxPtr pbox;
+#ifndef POLYSEGMENT
+ register DDXPointPtr ppt; /* pointer to list of translated points */
+#endif
+
+ unsigned int oc1; /* outcode of point 1 */
+ unsigned int oc2; /* outcode of point 2 */
+
+ CfbBits *addrl; /* address of destination pixmap */
+ int nlwidth; /* width in longwords of destination pixmap */
+ int xorg, yorg; /* origin of window */
+
+ int adx; /* abs values of dx and dy */
+ int ady;
+ int signdx; /* sign of dx and dy */
+ int signdy;
+ int e, e1, e2; /* bresenham error and increments */
+ int len; /* length of segment */
+ int axis; /* major axis */
+ int octant;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+
+ /* a bunch of temporaries */
+ int tmp;
+ register int y1, y2;
+ register int x1, x2;
+ RegionPtr cclip;
+ cfbPrivGCPtr devPriv;
+ CfbBits xor, and;
+ int alu;
+
+ devPriv = cfbGetGCPrivate(pGC);
+ cclip = pGC->pCompositeClip;
+ pboxInit = REGION_RECTS(cclip);
+ nboxInit = REGION_NUM_RECTS(cclip);
+
+ cfbGetLongWidthAndPointer (pDrawable, nlwidth, addrl)
+
+ alu = devPriv->rop;
+ xor = devPriv->xor;
+ and = devPriv->and;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+#ifdef POLYSEGMENT
+ while (nseg--)
+#else
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while(--npt)
+#endif
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+#ifdef POLYSEGMENT
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious)
+ {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+#endif
+
+ if (x1 == x2) /* vertical line */
+ {
+ /* make the line go top to bottom of screen, keeping
+ endpoint semantics
+ */
+ if (y1 > y2)
+ {
+ register int tmp;
+
+ tmp = y2;
+ y2 = y1 + 1;
+ y1 = tmp + 1;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ y1--;
+#endif
+ }
+#ifdef POLYSEGMENT
+ else if (pGC->capStyle != CapNotLast)
+ y2++;
+#endif
+ /* get to first band that might contain part of line */
+ while ((nbox) && (pbox->y2 <= y1))
+ {
+ pbox++;
+ nbox--;
+ }
+
+ if (nbox)
+ {
+ /* stop when lower edge of box is beyond end of line */
+ while((nbox) && (y2 >= pbox->y1))
+ {
+ if ((x1 >= pbox->x1) && (x1 < pbox->x2))
+ {
+ int y1t, y2t;
+ /* this box has part of the line in it */
+ y1t = max(y1, pbox->y1);
+ y2t = min(y2, pbox->y2);
+ if (y1t != y2t)
+ {
+ cfbVertS (alu, and, xor,
+ addrl, nlwidth,
+ x1, y1t, y2t-y1t);
+ }
+ }
+ nbox--;
+ pbox++;
+ }
+ }
+#ifndef POLYSEGMENT
+ y2 = ppt->y + yorg;
+#endif
+ }
+ else if (y1 == y2) /* horizontal line */
+ {
+ /* force line from left to right, keeping
+ endpoint semantics
+ */
+ if (x1 > x2)
+ {
+ register int tmp;
+
+ tmp = x2;
+ x2 = x1 + 1;
+ x1 = tmp + 1;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ x1--;
+#endif
+ }
+#ifdef POLYSEGMENT
+ else if (pGC->capStyle != CapNotLast)
+ x2++;
+#endif
+
+ /* find the correct band */
+ while( (nbox) && (pbox->y2 <= y1))
+ {
+ pbox++;
+ nbox--;
+ }
+
+ /* try to draw the line, if we haven't gone beyond it */
+ if ((nbox) && (pbox->y1 <= y1))
+ {
+ /* when we leave this band, we're done */
+ tmp = pbox->y1;
+ while((nbox) && (pbox->y1 == tmp))
+ {
+ int x1t, x2t;
+
+ if (pbox->x2 <= x1)
+ {
+ /* skip boxes until one might contain start point */
+ nbox--;
+ pbox++;
+ continue;
+ }
+
+ /* stop if left of box is beyond right of line */
+ if (pbox->x1 >= x2)
+ {
+ nbox = 0;
+ break;
+ }
+
+ x1t = max(x1, pbox->x1);
+ x2t = min(x2, pbox->x2);
+ if (x1t != x2t)
+ {
+ cfbHorzS (alu, and, xor,
+ addrl, nlwidth,
+ x1t, y1, x2t-x1t);
+ }
+ nbox--;
+ pbox++;
+ }
+ }
+#ifndef POLYSEGMENT
+ x2 = ppt->x + xorg;
+#endif
+ }
+ else /* sloped line */
+ {
+ CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy,
+ 1, 1, octant);
+
+ if (adx > ady)
+ {
+ axis = X_AXIS;
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+ }
+ else
+ {
+ axis = Y_AXIS;
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ SetYMajorOctant(octant);
+ }
+
+ FIXUP_ERROR(e, octant, bias);
+
+ /* we have bresenham parameters and two points.
+ all we have to do now is clip and draw.
+ */
+
+ while(nbox--)
+ {
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if ((oc1 | oc2) == 0)
+ {
+ if (axis == X_AXIS)
+ len = adx;
+ else
+ len = ady;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ len++;
+#endif
+ cfbBresS (alu, and, xor,
+ addrl, nlwidth,
+ signdx, signdy, axis, x1, y1,
+ e, e1, e2, len);
+ break;
+ }
+ else if (oc1 & oc2)
+ {
+ pbox++;
+ }
+ else
+ {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int clipdx, clipdy;
+ int err;
+
+ if (miZeroClipLine(pbox->x1, pbox->y1, pbox->x2-1,
+ pbox->y2-1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1)
+ {
+ pbox++;
+ continue;
+ }
+
+ if (axis == X_AXIS)
+ len = abs(new_x2 - new_x1);
+ else
+ len = abs(new_y2 - new_y1);
+#ifdef POLYSEGMENT
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+#else
+ len += (clip2 != 0);
+#endif
+ if (len)
+ {
+ /* unwind bresenham error term to first point */
+ if (clip1)
+ {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ if (axis == X_AXIS)
+ err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));
+ else
+ err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));
+ }
+ else
+ err = e;
+ cfbBresS(alu, and, xor,
+ addrl, nlwidth,
+ signdx, signdy, axis, new_x1, new_y1,
+ err, e1, e2, len);
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+ } /* sloped line */
+ } /* while (nline--) */
+
+#ifndef POLYSEGMENT
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1)))
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--)
+ {
+ if ((x2 >= pbox->x1) &&
+ (y2 >= pbox->y1) &&
+ (x2 < pbox->x2) &&
+ (y2 < pbox->y2))
+ {
+ CfbBits mask;
+ CfbBits scrbits;
+
+#if PSZ == 24
+ mask = cfbmask[(x2 & 3)<<1];
+ addrl += (y2 * nlwidth) + ((x2*3) >> 2);
+#else
+ mask = cfbmask[x2 & PIM];
+ addrl += (y2 * nlwidth) + (x2 >> PWSH);
+#endif
+ scrbits = *addrl;
+ *addrl = (scrbits & ~mask) |
+ (DoRRop (scrbits, and, xor) & mask);
+ break;
+ }
+ else
+ pbox++;
+ }
+ }
+#endif
+}
+
+/*
+ * Draw dashed 1-pixel lines.
+ */
+
+void
+#ifdef POLYSEGMENT
+cfbSegmentSD (pDrawable, pGC, nseg, pSeg)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int nseg;
+ register xSegment *pSeg;
+#else
+cfbLineSD( pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt; /* number of points */
+ DDXPointPtr pptInit;
+#endif
+{
+ int nboxInit;
+ register int nbox;
+ BoxPtr pboxInit;
+ register BoxPtr pbox;
+#ifndef POLYSEGMENT
+ register DDXPointPtr ppt; /* pointer to list of translated points */
+#endif
+
+ register unsigned int oc1; /* outcode of point 1 */
+ register unsigned int oc2; /* outcode of point 2 */
+
+ CfbBits *addrl; /* address of destination pixmap */
+ int nlwidth; /* width in longwords of destination pixmap */
+ int xorg, yorg; /* origin of window */
+
+ int adx; /* abs values of dx and dy */
+ int ady;
+ int signdx; /* sign of dx and dy */
+ int signdy;
+ int e, e1, e2; /* bresenham error and increments */
+ int len; /* length of segment */
+ int axis; /* major axis */
+ int octant;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ int x1, x2, y1, y2;
+ RegionPtr cclip;
+ cfbRRopRec rrops[2];
+ unsigned char *pDash;
+ int dashOffset;
+ int numInDashList;
+ int dashIndex;
+ int isDoubleDash;
+ int dashIndexTmp, dashOffsetTmp;
+ int unclippedlen;
+ cfbPrivGCPtr devPriv;
+
+ devPriv = cfbGetGCPrivate(pGC);
+ cclip = pGC->pCompositeClip;
+ rrops[0].rop = devPriv->rop;
+ rrops[0].and = devPriv->and;
+ rrops[0].xor = devPriv->xor;
+ if (pGC->alu == GXcopy)
+ {
+ rrops[1].rop = GXcopy;
+ rrops[1].and = 0;
+ rrops[1].xor = PFILL (pGC->bgPixel);
+ }
+ else
+ {
+ rrops[1].rop = cfbReduceRasterOp (pGC->alu,
+ pGC->bgPixel, pGC->planemask,
+ &rrops[1].and, &rrops[1].xor);
+ }
+ pboxInit = REGION_RECTS(cclip);
+ nboxInit = REGION_NUM_RECTS(cclip);
+
+ cfbGetLongWidthAndPointer (pDrawable, nlwidth, addrl)
+
+ /* compute initial dash values */
+
+ pDash = (unsigned char *) pGC->dash;
+ numInDashList = pGC->numInDashList;
+ isDoubleDash = (pGC->lineStyle == LineDoubleDash);
+ dashIndex = 0;
+ dashOffset = 0;
+ miStepDash ((int)pGC->dashOffset, &dashIndex, pDash,
+ numInDashList, &dashOffset);
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+#ifdef POLYSEGMENT
+ while (nseg--)
+#else
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while(--npt)
+#endif
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+#ifdef POLYSEGMENT
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious)
+ {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+#endif
+
+ CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy, 1, 1, octant);
+
+ if (adx > ady)
+ {
+ axis = X_AXIS;
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+ unclippedlen = adx;
+ }
+ else
+ {
+ axis = Y_AXIS;
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ unclippedlen = ady;
+ SetYMajorOctant(octant);
+ }
+
+ FIXUP_ERROR(e, octant, bias);
+
+ /* we have bresenham parameters and two points.
+ all we have to do now is clip and draw.
+ */
+
+ while(nbox--)
+ {
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if ((oc1 | oc2) == 0)
+ {
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ unclippedlen++;
+ dashIndexTmp = dashIndex;
+ dashOffsetTmp = dashOffset;
+ cfbBresD (rrops,
+ &dashIndexTmp, pDash, numInDashList,
+ &dashOffsetTmp, isDoubleDash,
+ addrl, nlwidth,
+ signdx, signdy, axis, x1, y1,
+ e, e1, e2, unclippedlen);
+ break;
+#else
+ cfbBresD (rrops,
+ &dashIndex, pDash, numInDashList,
+ &dashOffset, isDoubleDash,
+ addrl, nlwidth,
+ signdx, signdy, axis, x1, y1,
+ e, e1, e2, unclippedlen);
+ goto dontStep;
+#endif
+ }
+ else if (oc1 & oc2)
+ {
+ pbox++;
+ }
+ else /* have to clip */
+ {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int clipdx, clipdy;
+ int err;
+
+ if (miZeroClipLine(pbox->x1, pbox->y1, pbox->x2-1,
+ pbox->y2-1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1)
+ {
+ pbox++;
+ continue;
+ }
+
+ dashIndexTmp = dashIndex;
+ dashOffsetTmp = dashOffset;
+
+ if (clip1)
+ {
+ int dlen;
+
+ if (axis == X_AXIS)
+ dlen = abs(new_x1 - x1);
+ else
+ dlen = abs(new_y1 - y1);
+ miStepDash (dlen, &dashIndexTmp, pDash,
+ numInDashList, &dashOffsetTmp);
+ }
+
+ if (axis == X_AXIS)
+ len = abs(new_x2 - new_x1);
+ else
+ len = abs(new_y2 - new_y1);
+#ifdef POLYSEGMENT
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+#else
+ len += (clip2 != 0);
+#endif
+ if (len)
+ {
+ /* unwind bresenham error term to first point */
+ if (clip1)
+ {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ if (axis == X_AXIS)
+ err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));
+ else
+ err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));
+ }
+ else
+ err = e;
+ cfbBresD (rrops,
+ &dashIndexTmp, pDash, numInDashList,
+ &dashOffsetTmp, isDoubleDash,
+ addrl, nlwidth,
+ signdx, signdy, axis, new_x1, new_y1,
+ err, e1, e2, len);
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+#ifndef POLYSEGMENT
+ /*
+ * walk the dash list around to the next line
+ */
+ miStepDash (unclippedlen, &dashIndex, pDash,
+ numInDashList, &dashOffset);
+dontStep: ;
+#endif
+ } /* while (nline--) */
+
+#ifndef POLYSEGMENT
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((dashIndex & 1) == 0 || isDoubleDash) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1)))
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--)
+ {
+ if ((x2 >= pbox->x1) &&
+ (y2 >= pbox->y1) &&
+ (x2 < pbox->x2) &&
+ (y2 < pbox->y2))
+ {
+ CfbBits mask;
+ int pix;
+
+ pix = 0;
+ if (dashIndex & 1)
+ pix = 1;
+#if PSZ == 24
+ mask = cfbmask[(x2 & 3)<<1];
+ addrl += (y2 * nlwidth) + ((x2 *3)>> 2);
+#else
+ mask = cfbmask[x2 & PIM];
+ addrl += (y2 * nlwidth) + (x2 >> PWSH);
+#endif
+ *addrl = DoMaskRRop (*addrl, rrops[pix].and, rrops[pix].xor, mask);
+ break;
+ }
+ else
+ pbox++;
+ }
+ }
+#endif
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbmap.h b/nx-X11/programs/Xserver/cfb/cfbmap.h
new file mode 100644
index 000000000..802517aac
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbmap.h
@@ -0,0 +1,344 @@
+/*
+ * $Xorg: cfbmap.h,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $
+ *
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/programs/Xserver/cfb/cfbmap.h,v 3.11tsi Exp $ */
+
+/*
+ * Map names around so that multiple depths can be supported simultaneously
+ */
+
+#if 0
+#undef QuartetBitsTable
+#undef QuartetPixelMaskTable
+#undef cfb8ClippedLineCopy
+#undef cfb8ClippedLineGeneral
+#undef cfb8ClippedLineXor
+#undef cfb8LineSS1Rect
+#undef cfb8LineSS1RectCopy
+#undef cfb8LineSS1RectGeneral
+#undef cfb8LineSS1RectPreviousCopy
+#undef cfb8LineSS1RectXor
+#undef cfb8SegmentSS1Rect
+#undef cfb8SegmentSS1RectCopy
+#undef cfb8SegmentSS1RectGeneral
+#undef cfb8SegmentSS1RectShiftCopy
+#undef cfb8SegmentSS1RectXor
+#undef cfbAllocatePrivates
+#undef cfbBSFuncRec
+#undef cfbBitBlt
+#undef cfbBresD
+#undef cfbBresS
+#undef cfbChangeWindowAttributes
+#undef cfbCloseScreen
+#undef cfbCopyArea
+#undef cfbCopyImagePlane
+#undef cfbCopyPixmap
+#undef cfbCopyPlane
+#undef cfbCopyPlaneReduce
+#undef cfbCopyRotatePixmap
+#undef cfbCopyWindow
+#undef cfbCreateGC
+#undef cfbCreatePixmap
+#undef cfbCreateScreenResources
+#undef cfbCreateWindow
+#undef cfbDestroyPixmap
+#undef cfbDestroyWindow
+#undef cfbDoBitblt
+#undef cfbDoBitbltCopy
+#undef cfbDoBitbltGeneral
+#undef cfbDoBitbltOr
+#undef cfbDoBitbltXor
+#undef cfbFillBoxSolid
+#undef cfbFillBoxTile32
+#undef cfbFillBoxTile32sCopy
+#undef cfbFillBoxTile32sGeneral
+#undef cfbFillBoxTileOdd
+#undef cfbFillBoxTileOddCopy
+#undef cfbFillBoxTileOddGeneral
+#undef cfbFillPoly1RectCopy
+#undef cfbFillPoly1RectGeneral
+#undef cfbFillRectSolidCopy
+#undef cfbFillRectSolidGeneral
+#undef cfbFillRectSolidXor
+#undef cfbFillRectTile32Copy
+#undef cfbFillRectTile32General
+#undef cfbFillRectTileOdd
+#undef cfbFillSpanTile32sCopy
+#undef cfbFillSpanTile32sGeneral
+#undef cfbFillSpanTileOddCopy
+#undef cfbFillSpanTileOddGeneral
+#undef cfbFinishScreenInit
+#undef cfbGCFuncs
+#undef cfbGCPrivateIndex
+#undef cfbGetImage
+#undef cfbGetScreenPixmap
+#undef cfbGetSpans
+#undef cfbHorzS
+#undef cfbImageGlyphBlt8
+#undef cfbInitializeColormap
+#undef cfbInstallColormap
+#undef cfbLineSD
+#undef cfbLineSS
+#undef cfbListInstalledColormaps
+#undef cfbMapWindow
+#undef cfbMatchCommon
+#undef cfbNonTEOps
+#undef cfbNonTEOps1Rect
+#undef cfbPadPixmap
+#undef cfbPaintWindow
+#undef cfbPolyFillArcSolidCopy
+#undef cfbPolyFillArcSolidGeneral
+#undef cfbPolyFillRect
+#undef cfbPolyGlyphBlt8
+#undef cfbPolyGlyphRop8
+#undef cfbPolyPoint
+#undef cfbPositionWindow
+#undef cfbPutImage
+#undef cfbReduceRasterOp
+#undef cfbResolveColor
+#undef cfbRestoreAreas
+#undef cfbSaveAreas
+#undef cfbScreenInit
+#undef cfbScreenPrivateIndex
+#undef cfbSegmentSD
+#undef cfbSegmentSS
+#undef cfbSetScanline
+#undef cfbSetScreenPixmap
+#undef cfbSetSpans
+#undef cfbSetupScreen
+#undef cfbSolidSpansCopy
+#undef cfbSolidSpansGeneral
+#undef cfbSolidSpansXor
+#undef cfbStippleStack
+#undef cfbStippleStackTE
+#undef cfbTEGlyphBlt
+#undef cfbTEOps
+#undef cfbTEOps1Rect
+#undef cfbTile32FSCopy
+#undef cfbTile32FSGeneral
+#undef cfbUninstallColormap
+#undef cfbUnmapWindow
+#undef cfbUnnaturalStippleFS
+#undef cfbUnnaturalTileFS
+#undef cfbValidateGC
+#undef cfbVertS
+#undef cfbWindowPrivateIndex
+#undef cfbXRotatePixmap
+#undef cfbYRotatePixmap
+#undef cfbZeroPolyArcSS8Copy
+#undef cfbZeroPolyArcSS8General
+#undef cfbZeroPolyArcSS8Xor
+#undef cfbendpartial
+#undef cfbendtab
+#undef cfbmask
+#undef cfbrmask
+#undef cfbstartpartial
+#undef cfbstarttab
+#endif
+
+/* a losing vendor cpp dumps core if we define CFBNAME in terms of CATNAME */
+
+#if PSZ != 8
+
+#if PSZ == 32
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define CFBNAME(subname) cfb32##subname
+#else
+#define CFBNAME(subname) cfb32/**/subname
+#endif
+#endif
+
+#if PSZ == 24
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define CFBNAME(subname) cfb24##subname
+#else
+#define CFBNAME(subname) cfb24/**/subname
+#endif
+#endif
+
+#if PSZ == 16
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define CFBNAME(subname) cfb16##subname
+#else
+#define CFBNAME(subname) cfb16/**/subname
+#endif
+#endif
+
+#if PSZ == 4
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define CFBNAME(subname) cfb4##subname
+#else
+#define CFBNAME(subname) cfb4/**/subname
+#endif
+#endif
+
+#ifndef CFBNAME
+cfb can not hack PSZ yet
+#endif
+
+#undef CATNAME
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define CATNAME(prefix,subname) prefix##subname
+#else
+#define CATNAME(prefix,subname) prefix/**/subname
+#endif
+
+#define QuartetBitsTable CFBNAME(QuartetBitsTable)
+#define QuartetPixelMaskTable CFBNAME(QuartetPixelMaskTable)
+#define cfb8ClippedLineCopy CFBNAME(ClippedLineCopy)
+#define cfb8ClippedLineGeneral CFBNAME(ClippedLineGeneral )
+#define cfb8ClippedLineXor CFBNAME(ClippedLineXor)
+#define cfb8LineSS1Rect CFBNAME(LineSS1Rect)
+#define cfb8LineSS1RectCopy CFBNAME(LineSS1RectCopy)
+#define cfb8LineSS1RectGeneral CFBNAME(LineSS1RectGeneral )
+#define cfb8LineSS1RectPreviousCopy CFBNAME(LineSS1RectPreviousCopy)
+#define cfb8LineSS1RectXor CFBNAME(LineSS1RectXor)
+#define cfb8SegmentSS1Rect CFBNAME(SegmentSS1Rect)
+#define cfb8SegmentSS1RectCopy CFBNAME(SegmentSS1RectCopy)
+#define cfb8SegmentSS1RectGeneral CFBNAME(SegmentSS1RectGeneral )
+#define cfb8SegmentSS1RectShiftCopy CFBNAME(SegmentSS1RectShiftCopy)
+#define cfb8SegmentSS1RectXor CFBNAME(SegmentSS1RectXor)
+#define cfbAllocatePrivates CFBNAME(AllocatePrivates)
+#define cfbBSFuncRec CFBNAME(BSFuncRec)
+#define cfbBitBlt CFBNAME(BitBlt)
+#define cfbBresD CFBNAME(BresD)
+#define cfbBresS CFBNAME(BresS)
+#define cfbChangeWindowAttributes CFBNAME(ChangeWindowAttributes)
+#define cfbClearVisualTypes CFBNAME(cfbClearVisualTypes)
+#define cfbCloseScreen CFBNAME(CloseScreen)
+#define cfbCreateDefColormap CFBNAME (cfbCreateDefColormap)
+#define cfbCopyArea CFBNAME(CopyArea)
+#define cfbCopyImagePlane CFBNAME(CopyImagePlane)
+#define cfbCopyPixmap CFBNAME(CopyPixmap)
+#define cfbCopyPlane CFBNAME(CopyPlane)
+#define cfbCopyPlaneReduce CFBNAME(CopyPlaneReduce)
+#define cfbCopyRotatePixmap CFBNAME(CopyRotatePixmap)
+#define cfbCopyWindow CFBNAME(CopyWindow)
+#define cfbCreateGC CFBNAME(CreateGC)
+#define cfbCreatePixmap CFBNAME(CreatePixmap)
+#define cfbCreateScreenResources CFBNAME(CreateScreenResources)
+#define cfbCreateWindow CFBNAME(CreateWindow)
+#define cfbDestroyPixmap CFBNAME(DestroyPixmap)
+#define cfbDestroyWindow CFBNAME(DestroyWindow)
+#define cfbDoBitblt CFBNAME(DoBitblt)
+#define cfbDoBitbltCopy CFBNAME(DoBitbltCopy)
+#define cfbDoBitbltGeneral CFBNAME(DoBitbltGeneral)
+#define cfbDoBitbltOr CFBNAME(DoBitbltOr)
+#define cfbDoBitbltXor CFBNAME(DoBitbltXor)
+#define cfbExpandDirectColors CFBNAME(cfbExpandDirectColors)
+#define cfbFillBoxSolid CFBNAME(FillBoxSolid)
+#define cfbFillBoxTile32 CFBNAME(FillBoxTile32)
+#define cfbFillBoxTile32sCopy CFBNAME(FillBoxTile32sCopy)
+#define cfbFillBoxTile32sGeneral CFBNAME(FillBoxTile32sGeneral)
+#define cfbFillBoxTileOdd CFBNAME(FillBoxTileOdd)
+#define cfbFillBoxTileOddCopy CFBNAME(FillBoxTileOddCopy)
+#define cfbFillBoxTileOddGeneral CFBNAME(FillBoxTileOddGeneral)
+#define cfbFillPoly1RectCopy CFBNAME(FillPoly1RectCopy)
+#define cfbFillPoly1RectGeneral CFBNAME(FillPoly1RectGeneral)
+#define cfbFillRectSolidCopy CFBNAME(FillRectSolidCopy)
+#define cfbFillRectSolidGeneral CFBNAME(FillRectSolidGeneral)
+#define cfbFillRectSolidXor CFBNAME(FillRectSolidXor)
+#define cfbFillRectTile32Copy CFBNAME(FillRectTile32Copy)
+#define cfbFillRectTile32General CFBNAME(FillRectTile32General)
+#define cfbFillRectTileOdd CFBNAME(FillRectTileOdd)
+#define cfbFillSpanTile32sCopy CFBNAME(FillSpanTile32sCopy)
+#define cfbFillSpanTile32sGeneral CFBNAME(FillSpanTile32sGeneral)
+#define cfbFillSpanTileOddCopy CFBNAME(FillSpanTileOddCopy)
+#define cfbFillSpanTileOddGeneral CFBNAME(FillSpanTileOddGeneral)
+#define cfbFinishScreenInit CFBNAME(FinishScreenInit)
+#define cfbGCFuncs CFBNAME(GCFuncs)
+#define cfbGCPrivateIndex CFBNAME(GCPrivateIndex)
+#define cfbGetImage CFBNAME(GetImage)
+#define cfbGetScreenPixmap CFBNAME(GetScreenPixmap)
+#define cfbGetSpans CFBNAME(GetSpans)
+#define cfbHorzS CFBNAME(HorzS)
+#define cfbImageGlyphBlt8 CFBNAME(ImageGlyphBlt8)
+#define cfbInitializeColormap CFBNAME(InitializeColormap)
+#define cfbInitVisuals CFBNAME(cfbInitVisuals)
+#define cfbInstallColormap CFBNAME(InstallColormap)
+#define cfbLineSD CFBNAME(LineSD)
+#define cfbLineSS CFBNAME(LineSS)
+#define cfbListInstalledColormaps CFBNAME(ListInstalledColormaps)
+#define cfbMapWindow CFBNAME(MapWindow)
+#define cfbMatchCommon CFBNAME(MatchCommon)
+#define cfbNonTEOps CFBNAME(NonTEOps)
+#define cfbNonTEOps1Rect CFBNAME(NonTEOps1Rect)
+#define cfbPadPixmap CFBNAME(PadPixmap)
+#define cfbPaintWindow CFBNAME(PaintWindow)
+#define cfbPolyFillArcSolidCopy CFBNAME(PolyFillArcSolidCopy)
+#define cfbPolyFillArcSolidGeneral CFBNAME(PolyFillArcSolidGeneral)
+#define cfbPolyFillRect CFBNAME(PolyFillRect)
+#define cfbPolyGlyphBlt8 CFBNAME(PolyGlyphBlt8)
+#define cfbPolyGlyphRop8 CFBNAME(PolyGlyphRop8)
+#define cfbPolyPoint CFBNAME(PolyPoint)
+#define cfbPositionWindow CFBNAME(PositionWindow)
+#define cfbPutImage CFBNAME(PutImage)
+#define cfbReduceRasterOp CFBNAME(ReduceRasterOp)
+#define cfbResolveColor CFBNAME(ResolveColor)
+#define cfbRestoreAreas CFBNAME(RestoreAreas)
+#define cfbSaveAreas CFBNAME(SaveAreas)
+#define cfbScreenInit CFBNAME(ScreenInit)
+#define cfbScreenPrivateIndex CFBNAME(ScreenPrivateIndex)
+#define cfbSegmentSD CFBNAME(SegmentSD)
+#define cfbSegmentSS CFBNAME(SegmentSS)
+#define cfbSetScanline CFBNAME(SetScanline)
+#define cfbSetScreenPixmap CFBNAME(SetScreenPixmap)
+#define cfbSetSpans CFBNAME(SetSpans)
+#define cfbSetVisualTypes CFBNAME(cfbSetVisualTypes)
+#define cfbSetupScreen CFBNAME(SetupScreen)
+#define cfbSolidSpansCopy CFBNAME(SolidSpansCopy)
+#define cfbSolidSpansGeneral CFBNAME(SolidSpansGeneral)
+#define cfbSolidSpansXor CFBNAME(SolidSpansXor)
+#define cfbStippleStack CFBNAME(StippleStack)
+#define cfbStippleStackTE CFBNAME(StippleStackTE)
+#define cfbTEGlyphBlt CFBNAME(TEGlyphBlt)
+#define cfbTEOps CFBNAME(TEOps)
+#define cfbTEOps1Rect CFBNAME(TEOps1Rect)
+#define cfbTile32FSCopy CFBNAME(Tile32FSCopy)
+#define cfbTile32FSGeneral CFBNAME(Tile32FSGeneral)
+#define cfbUninstallColormap CFBNAME(UninstallColormap)
+#define cfbUnmapWindow CFBNAME(UnmapWindow)
+#define cfbUnnaturalStippleFS CFBNAME(UnnaturalStippleFS)
+#define cfbUnnaturalTileFS CFBNAME(UnnaturalTileFS)
+#define cfbValidateGC CFBNAME(ValidateGC)
+#define cfbVertS CFBNAME(VertS)
+#define cfbWindowPrivateIndex CFBNAME(WindowPrivateIndex)
+#define cfbXRotatePixmap CFBNAME(XRotatePixmap)
+#define cfbYRotatePixmap CFBNAME(YRotatePixmap)
+#define cfbZeroPolyArcSS8Copy CFBNAME(ZeroPolyArcSSCopy)
+#define cfbZeroPolyArcSS8General CFBNAME(ZeroPolyArcSSGeneral)
+#define cfbZeroPolyArcSS8Xor CFBNAME(ZeroPolyArcSSXor)
+#define cfbendpartial CFBNAME(endpartial)
+#define cfbendtab CFBNAME(endtab)
+#define cfbmask CFBNAME(mask)
+#define cfbrmask CFBNAME(rmask)
+#define cfbstartpartial CFBNAME(startpartial)
+#define cfbstarttab CFBNAME(starttab)
+
+#endif /* PSZ != 8 */
diff --git a/nx-X11/programs/Xserver/cfb/cfbmodule.c b/nx-X11/programs/Xserver/cfb/cfbmodule.c
new file mode 100644
index 000000000..095bc8416
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbmodule.c
@@ -0,0 +1,65 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfbmodule.c,v 1.8 1999/01/26 05:53:48 dawes Exp $ */
+/*
+ * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#define PSZ 8
+
+#ifdef XFree86LOADER
+
+#include "xf86Module.h"
+#include "cfb.h"
+
+static MODULESETUPPROTO(cfbSetup);
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "cfb",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_ANSIC, /* Only need the ansic layer */
+ ABI_ANSIC_VERSION,
+ MOD_CLASS_NONE,
+ {0,0,0,0} /* signature, to be patched into the file by a tool */
+};
+
+XF86ModuleData cfbModuleData = { &VersRec, cfbSetup, NULL };
+
+static pointer
+cfbSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ /* This modules requires mfb, so load it */
+ return LoadSubModule(module, "mfb", NULL, NULL, NULL, NULL,
+ errmaj, errmin);
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/cfb/cfbmskbits.c b/nx-X11/programs/Xserver/cfb/cfbmskbits.c
new file mode 100644
index 000000000..05954e62c
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbmskbits.c
@@ -0,0 +1,1402 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfbmskbits.c,v 3.1 1998/10/04 09:37:46 dawes Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/* $Xorg: cfbmskbits.c,v 1.3 2000/08/17 19:48:14 cpqbld Exp $ */
+
+/*
+ * ==========================================================================
+ * Converted to Color Frame Buffer by smarks@sun, April-May 1987. The "bit
+ * numbering" in the doc below really means "byte numbering" now.
+ * ==========================================================================
+ */
+
+/*
+ these tables are used by several macros in the cfb code.
+
+ the vax numbers everything left to right, so bit indices on the
+screen match bit indices in longwords. the pc-rt and Sun number
+bits on the screen the way they would be written on paper,
+(i.e. msb to the left), and so a bit index n on the screen is
+bit index 32-n in a longword
+
+ see also cfbmskbits.h
+*/
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <servermd.h>
+#include "cfb.h"
+#include "cfbmskbits.h"
+
+#define _cfbBits(a) (PixelGroup)(a)
+
+#if (BITMAP_BIT_ORDER == MSBFirst)
+#define cfbBits(v) _cfbBits(v)
+#else /* BITMAP_BIT_ORDER == LSBFirst */
+#define cfbFlip2(a) ((((a) & 0x1) << 1) | (((a) & 0x2) >> 1))
+#define cfbFlip4(a) ((cfbFlip2(a) << 2) | cfbFlip2(a >> 2))
+#define cfbFlip8(a) ((cfbFlip4(a) << 4) | cfbFlip4(a >> 4))
+#define cfbFlip16(a) ((cfbFlip8(a) << 8) | cfbFlip8(a >> 8))
+#define cfbFlip32(a) ((cfbFlip16(a) << 16) | cfbFlip16(a >> 16))
+#if PGSZ == 32
+#define cfbBits(a) cfbFlip32(_cfbBits(a))
+#else /* PGSZ == 64 */
+#define cfbFlip64(a) ((cfbFlip32(a) << 32) | cfbFlip32(a >> 32))
+#define cfbBits(a) cfbFlip64(_cfbBits(a))
+#endif /* PGSZ */
+#endif /* BITMAP_BIT_ORDER */
+
+/* NOTE:
+the first element in starttab could be 0xffffffff. making it 0
+lets us deal with a full first word in the middle loop, rather
+than having to do the multiple reads and masks that we'd
+have to do if we thought it was partial.
+*/
+#if PSZ == 4
+#if PGSZ == 32
+PixelGroup cfbstarttab[] =
+ {
+ cfbBits(0x00000000),
+ cfbBits(0x0FFFFFFF),
+ cfbBits(0x00FFFFFF),
+ cfbBits(0x000FFFFF),
+ cfbBits(0x0000FFFF),
+ cfbBits(0x00000FFF),
+ cfbBits(0x000000FF),
+ cfbBits(0x0000000F)
+ };
+PixelGroup cfbendtab[] =
+ {
+ cfbBits(0x00000000),
+ cfbBits(0xF0000000),
+ cfbBits(0xFF000000),
+ cfbBits(0xFFF00000),
+ cfbBits(0xFFFF0000),
+ cfbBits(0xFFFFF000),
+ cfbBits(0xFFFFFF00),
+ cfbBits(0xFFFFFFF0)
+ };
+#else /* PGSZ == 64 */
+PixelGroup cfbstarttab[] =
+ {
+ cfbBits(0x0000000000000000),
+ cfbBits(0x0FFFFFFFFFFFFFFF),
+ cfbBits(0x00FFFFFFFFFFFFFF),
+ cfbBits(0x000FFFFFFFFFFFFF),
+ cfbBits(0x0000FFFFFFFFFFFF),
+ cfbBits(0x00000FFFFFFFFFFF),
+ cfbBits(0x000000FFFFFFFFFF),
+ cfbBits(0x0000000FFFFFFFFF),
+ cfbBits(0x00000000FFFFFFFF),
+ cfbBits(0x000000000FFFFFFF),
+ cfbBits(0x0000000000FFFFFF),
+ cfbBits(0x00000000000FFFFF),
+ cfbBits(0x000000000000FFFF),
+ cfbBits(0x0000000000000FFF),
+ cfbBits(0x00000000000000FF),
+ cfbBits(0x000000000000000F),
+ };
+PixelGroup cfbendtab[] =
+ {
+ cfbBits(0x0000000000000000),
+ cfbBits(0xF000000000000000),
+ cfbBits(0xFF00000000000000),
+ cfbBits(0xFFF0000000000000),
+ cfbBits(0xFFFF000000000000),
+ cfbBits(0xFFFFF00000000000),
+ cfbBits(0xFFFFFF0000000000),
+ cfbBits(0xFFFFFFF000000000),
+ cfbBits(0xFFFFFFFF00000000),
+ cfbBits(0xFFFFFFFFF0000000),
+ cfbBits(0xFFFFFFFFFF000000),
+ cfbBits(0xFFFFFFFFFFF00000),
+ cfbBits(0xFFFFFFFFFFFF0000),
+ cfbBits(0xFFFFFFFFFFFFF000),
+ cfbBits(0xFFFFFFFFFFFFFF00),
+ cfbBits(0xFFFFFFFFFFFFFFF0),
+ };
+#endif /* PGSZ */
+#endif /* PSZ == 4 */
+
+#if PSZ == 8
+#if PGSZ == 32
+PixelGroup cfbstarttab[] =
+ {
+ cfbBits(0x00000000),
+ cfbBits(0x00FFFFFF),
+ cfbBits(0x0000FFFF),
+ cfbBits(0x000000FF)
+ };
+PixelGroup cfbendtab[] =
+ {
+ cfbBits(0x00000000),
+ cfbBits(0xFF000000),
+ cfbBits(0xFFFF0000),
+ cfbBits(0xFFFFFF00)
+ };
+#else /* PGSZ == 64 */
+PixelGroup cfbstarttab[] =
+ {
+ cfbBits(0x0000000000000000),
+ cfbBits(0x00FFFFFFFFFFFFFF),
+ cfbBits(0x0000FFFFFFFFFFFF),
+ cfbBits(0x000000FFFFFFFFFF),
+ cfbBits(0x00000000FFFFFFFF),
+ cfbBits(0x0000000000FFFFFF),
+ cfbBits(0x000000000000FFFF),
+ cfbBits(0x00000000000000FF)
+ };
+PixelGroup cfbendtab[] =
+ {
+ cfbBits(0x0000000000000000),
+ cfbBits(0xFF00000000000000),
+ cfbBits(0xFFFF000000000000),
+ cfbBits(0xFFFFFF0000000000),
+ cfbBits(0xFFFFFFFF00000000),
+ cfbBits(0xFFFFFFFFFF000000),
+ cfbBits(0xFFFFFFFFFFFF0000),
+ cfbBits(0xFFFFFFFFFFFFFF00)
+ };
+#endif /* PGSZ */
+#endif /* PSZ == 8 */
+
+#if PSZ == 16
+#if PGSZ == 32
+PixelGroup cfbstarttab[] =
+ {
+ cfbBits(0x00000000),
+ cfbBits(0x0000FFFF),
+ };
+PixelGroup cfbendtab[] =
+ {
+ cfbBits(0x00000000),
+ cfbBits(0xFFFF0000),
+ };
+#else /* PGSZ == 64 */
+PixelGroup cfbstarttab[] =
+ {
+ cfbBits(0x0000000000000000),
+ cfbBits(0x0000FFFFFFFFFFFF),
+ cfbBits(0x00000000FFFFFFFF),
+ cfbBits(0x000000000000FFFF),
+ };
+PixelGroup cfbendtab[] =
+ {
+ cfbBits(0x0000000000000000),
+ cfbBits(0xFFFF000000000000),
+ cfbBits(0xFFFFFFFF00000000),
+ cfbBits(0xFFFFFFFFFFFF0000),
+ };
+#endif /* PGSZ */
+#endif
+
+#if PSZ == 24
+#if PGSZ == 32
+PixelGroup cfbstarttab[] =
+ {
+ cfbBits(0x00000000),
+ cfbBits(0x000000FF),
+ cfbBits(0x0000FFFF),
+ cfbBits(0x00FFFFFF),
+ };
+PixelGroup cfbendtab[] =
+ {
+ cfbBits(0x00000000),
+ cfbBits(0xFFFFFF00),
+ cfbBits(0xFFFF0000),
+ cfbBits(0xFF000000),
+ };
+#else /* PGSZ == 64 */
+PixelGroup cfbstarttab[] =
+ {
+ cfbBits(0x0000000000000000),
+ cfbBits(0x000000FFFFFFFFFF),
+ cfbBits(0x000000000000FFFF),
+ };
+PixelGroup cfbendtab[] =
+ {
+ cfbBits(0x0000000000000000),
+ cfbBits(0xFFFFFFFFFF000000),
+ cfbBits(0xFFFF000000000000),
+ };
+#endif /* PGSZ */
+#endif /* PSZ == 24 */
+
+#if PSZ == 32
+#if PGSZ == 32
+PixelGroup cfbstarttab[] =
+ {
+ cfbBits(0x00000000),
+ };
+PixelGroup cfbendtab[] =
+ {
+ cfbBits(0x00000000),
+ };
+#else /* PGSZ == 64 */
+PixelGroup cfbstarttab[] =
+ {
+ cfbBits(0x0000000000000000),
+ cfbBits(0x00000000FFFFFFFF),
+ };
+PixelGroup cfbendtab[] =
+ {
+ cfbBits(0x0000000000000000),
+ cfbBits(0xFFFFFFFF00000000),
+ };
+#endif /* PGSZ */
+#endif /* PSZ == 32 */
+
+/* a hack, for now, since the entries for 0 need to be all
+ 1 bits, not all zeros.
+ this means the code DOES NOT WORK for segments of length
+ 0 (which is only a problem in the horizontal line code.)
+*/
+#if PSZ == 4
+#if PGSZ == 32
+PixelGroup cfbstartpartial[] =
+ {
+ cfbBits(0xFFFFFFFF),
+ cfbBits(0x0FFFFFFF),
+ cfbBits(0x00FFFFFF),
+ cfbBits(0x000FFFFF),
+ cfbBits(0x0000FFFF),
+ cfbBits(0x00000FFF),
+ cfbBits(0x000000FF),
+ cfbBits(0x0000000F)
+ };
+
+PixelGroup cfbendpartial[] =
+ {
+ cfbBits(0xFFFFFFFF),
+ cfbBits(0xF0000000),
+ cfbBits(0xFF000000),
+ cfbBits(0xFFF00000),
+ cfbBits(0xFFFF0000),
+ cfbBits(0xFFFFF000),
+ cfbBits(0xFFFFFF00),
+ cfbBits(0xFFFFFFF0)
+ };
+#else /* PGSZ == 64 */
+PixelGroup cfbstartpartial[] =
+ {
+ cfbBits(0xFFFFFFFFFFFFFFFF),
+ cfbBits(0x0FFFFFFFFFFFFFFF),
+ cfbBits(0x00FFFFFFFFFFFFFF),
+ cfbBits(0x000FFFFFFFFFFFFF),
+ cfbBits(0x0000FFFFFFFFFFFF),
+ cfbBits(0x00000FFFFFFFFFFF),
+ cfbBits(0x000000FFFFFFFFFF),
+ cfbBits(0x0000000FFFFFFFFF),
+ cfbBits(0x00000000FFFFFFFF),
+ cfbBits(0x000000000FFFFFFF),
+ cfbBits(0x0000000000FFFFFF),
+ cfbBits(0x00000000000FFFFF),
+ cfbBits(0x000000000000FFFF),
+ cfbBits(0x0000000000000FFF),
+ cfbBits(0x00000000000000FF),
+ cfbBits(0x000000000000000F),
+ };
+
+PixelGroup cfbendpartial[] =
+ {
+ cfbBits(0xFFFFFFFFFFFFFFFF),
+ cfbBits(0xF000000000000000),
+ cfbBits(0xFF00000000000000),
+ cfbBits(0xFFF0000000000000),
+ cfbBits(0xFFFF000000000000),
+ cfbBits(0xFFFFF00000000000),
+ cfbBits(0xFFFFFF0000000000),
+ cfbBits(0xFFFFFFF000000000),
+ cfbBits(0xFFFFFFFF00000000),
+ cfbBits(0xFFFFFFFFF0000000),
+ cfbBits(0xFFFFFFFFFF000000),
+ cfbBits(0xFFFFFFFFFFF00000),
+ cfbBits(0xFFFFFFFFFFFF0000),
+ cfbBits(0xFFFFFFFFFFFFF000),
+ cfbBits(0xFFFFFFFFFFFFFF00),
+ cfbBits(0xFFFFFFFFFFFFFFF0),
+ };
+#endif /* PGSZ */
+#endif /* PSZ == 4 */
+
+#if PSZ == 8
+#if PGSZ == 32
+PixelGroup cfbstartpartial[] =
+ {
+ cfbBits(0xFFFFFFFF),
+ cfbBits(0x00FFFFFF),
+ cfbBits(0x0000FFFF),
+ cfbBits(0x000000FF)
+ };
+
+PixelGroup cfbendpartial[] =
+ {
+ cfbBits(0xFFFFFFFF),
+ cfbBits(0xFF000000),
+ cfbBits(0xFFFF0000),
+ cfbBits(0xFFFFFF00)
+ };
+#else /* PGSZ == 64 */
+PixelGroup cfbstartpartial[] =
+ {
+ cfbBits(0xFFFFFFFFFFFFFFFF),
+ cfbBits(0x00FFFFFFFFFFFFFF),
+ cfbBits(0x0000FFFFFFFFFFFF),
+ cfbBits(0x000000FFFFFFFFFF),
+ cfbBits(0x00000000FFFFFFFF),
+ cfbBits(0x0000000000FFFFFF),
+ cfbBits(0x000000000000FFFF),
+ cfbBits(0x00000000000000FF),
+ };
+
+PixelGroup cfbendpartial[] =
+ {
+ cfbBits(0xFFFFFFFFFFFFFFFF),
+ cfbBits(0xFF00000000000000),
+ cfbBits(0xFFFF000000000000),
+ cfbBits(0xFFFFFF0000000000),
+ cfbBits(0xFFFFFFFF00000000),
+ cfbBits(0xFFFFFFFFFF000000),
+ cfbBits(0xFFFFFFFFFFFF0000),
+ cfbBits(0xFFFFFFFFFFFFFF00),
+ };
+#endif /* PGSZ */
+#endif /* PSZ == 8 */
+
+#if PSZ == 16
+#if PGSZ == 32
+PixelGroup cfbstartpartial[] =
+ {
+ cfbBits(0xFFFFFFFF),
+ cfbBits(0x0000FFFF),
+ };
+
+PixelGroup cfbendpartial[] =
+ {
+ cfbBits(0xFFFFFFFF),
+ cfbBits(0xFFFF0000),
+ };
+#else /* PGSZ == 64 */
+PixelGroup cfbstartpartial[] =
+ {
+ cfbBits(0xFFFFFFFFFFFFFFFF),
+ cfbBits(0x0000FFFFFFFFFFFF),
+ cfbBits(0x00000000FFFFFFFF),
+ cfbBits(0x000000000000FFFF),
+ };
+
+PixelGroup cfbendpartial[] =
+ {
+ cfbBits(0xFFFFFFFFFFFFFFFF),
+ cfbBits(0xFFFF000000000000),
+ cfbBits(0xFFFFFFFF00000000),
+ cfbBits(0xFFFFFFFFFFFF0000),
+ };
+#endif /* PGSZ */
+#endif /* PSZ == 16 */
+
+#if PSZ == 24
+#if PGSZ == 32
+PixelGroup cfbstartpartial[] =
+ {
+ cfbBits(0xFFFFFFFF),
+ cfbBits(0x000000FF),
+ cfbBits(0x0000FFFF),
+ cfbBits(0x00FFFFFF),
+ };
+
+PixelGroup cfbendpartial[] =
+ {
+ cfbBits(0xFFFFFFFF),
+ cfbBits(0xFFFFFF00),
+ cfbBits(0xFFFF0000),
+ cfbBits(0xFF000000),
+ };
+#else /* PGSZ == 64 */
+PixelGroup cfbstartpartial[] =
+ {
+ cfbBits(0xFFFFFFFFFFFFFFFF),
+ cfbBits(0x0000FFFFFFFFFFFF),
+ cfbBits(0x000000FFFFFFFFFF),
+ cfbBits(0x00000000FFFFFFFF),
+ cfbBits(0x0000000000FFFFFF),
+ cfbBits(0x000000000000FFFF),
+ cfbBits(0x00000000000000FF),
+ };
+
+PixelGroup cfbendpartial[] =
+ {
+ cfbBits(0xFFFFFFFFFFFFFFFF),
+ cfbBits(0xFFFFFFFFFFFF0000),
+ cfbBits(0xFFFFFFFFFF000000),
+ cfbBits(0xFFFFFFFF00000000),
+ cfbBits(0xFFFFFF0000000000),
+ cfbBits(0xFFFF000000000000),
+ cfbBits(0xFF00000000000000),
+ };
+#endif /* PGSZ */
+#endif /* PSZ == 24 */
+
+#if PSZ == 32
+#if PGSZ == 32
+PixelGroup cfbstartpartial[] =
+ {
+ cfbBits(0xFFFFFFFF),
+ };
+
+PixelGroup cfbendpartial[] =
+ {
+ cfbBits(0xFFFFFFFF),
+ };
+#else /* PGSZ == 64 */
+PixelGroup cfbstartpartial[] =
+ {
+ cfbBits(0xFFFFFFFFFFFFFFFF),
+ cfbBits(0x00000000FFFFFFFF),
+ };
+
+PixelGroup cfbendpartial[] =
+ {
+ cfbBits(0xFFFFFFFFFFFFFFFF),
+ cfbBits(0xFFFFFFFF00000000),
+ };
+#endif /* PGSZ */
+#endif /* PSZ == 32 */
+
+/* used for masking bits in bresenham lines
+ mask[n] is used to mask out all but bit n in a longword (n is a
+screen position).
+ rmask[n] is used to mask out the single bit at position n (n
+is a screen posiotion.)
+*/
+
+#if PSZ == 4
+#if PGSZ == 32
+PixelGroup cfbmask[] =
+ {
+ cfbBits(0xF0000000),
+ cfbBits(0x0F000000),
+ cfbBits(0x00F00000),
+ cfbBits(0x000F0000),
+ cfbBits(0x0000F000),
+ cfbBits(0x00000F00),
+ cfbBits(0x000000F0),
+ cfbBits(0x0000000F)
+ };
+PixelGroup cfbrmask[] =
+ {
+ cfbBits(0x0FFFFFFF),
+ cfbBits(0xF0FFFFFF),
+ cfbBits(0xFF0FFFFF),
+ cfbBits(0xFFF0FFFF),
+ cfbBits(0xFFFF0FFF),
+ cfbBits(0xFFFFF0FF),
+ cfbBits(0xFFFFFF0F),
+ cfbBits(0xFFFFFFF0)
+ };
+#else /* PGSZ == 64 */
+PixelGroup cfbmask[] =
+ {
+ cfbBits(0xF000000000000000),
+ cfbBits(0x0F00000000000000),
+ cfbBits(0x00F0000000000000),
+ cfbBits(0x000F000000000000),
+ cfbBits(0x0000F00000000000),
+ cfbBits(0x00000F0000000000),
+ cfbBits(0x000000F000000000),
+ cfbBits(0x0000000F00000000),
+ cfbBits(0x00000000F0000000),
+ cfbBits(0x000000000F000000),
+ cfbBits(0x0000000000F00000),
+ cfbBits(0x00000000000F0000),
+ cfbBits(0x000000000000F000),
+ cfbBits(0x0000000000000F00),
+ cfbBits(0x00000000000000F0),
+ cfbBits(0x000000000000000F),
+ };
+PixelGroup cfbrmask[] =
+ {
+ cfbBits(0x0FFFFFFFFFFFFFFF),
+ cfbBits(0xF0FFFFFFFFFFFFFF),
+ cfbBits(0xFF0FFFFFFFFFFFFF),
+ cfbBits(0xFFF0FFFFFFFFFFFF),
+ cfbBits(0xFFFF0FFFFFFFFFFF),
+ cfbBits(0xFFFFF0FFFFFFFFFF),
+ cfbBits(0xFFFFFF0FFFFFFFFF),
+ cfbBits(0xFFFFFFF0FFFFFFFF),
+ cfbBits(0xFFFFFFFF0FFFFFFF),
+ cfbBits(0xFFFFFFFFF0FFFFFF),
+ cfbBits(0xFFFFFFFFFF0FFFFF),
+ cfbBits(0xFFFFFFFFFFF0FFFF),
+ cfbBits(0xFFFFFFFFFFFF0FFF),
+ cfbBits(0xFFFFFFFFFFFFF0FF),
+ cfbBits(0xFFFFFFFFFFFFFF0F),
+ cfbBits(0xFFFFFFFFFFFFFFF0),
+ };
+#endif /* PGSZ */
+#endif /* PSZ == 4 */
+
+#if PSZ == 8
+#if PGSZ == 32
+PixelGroup cfbmask[] =
+ {
+ cfbBits(0xFF000000),
+ cfbBits(0x00FF0000),
+ cfbBits(0x0000FF00),
+ cfbBits(0x000000FF)
+ };
+PixelGroup cfbrmask[] =
+ {
+ cfbBits(0x00FFFFFF),
+ cfbBits(0xFF00FFFF),
+ cfbBits(0xFFFF00FF),
+ cfbBits(0xFFFFFF00)
+ };
+#else /* PGSZ == 64 */
+PixelGroup cfbmask[] =
+ {
+ cfbBits(0xFF00000000000000),
+ cfbBits(0x00FF000000000000),
+ cfbBits(0x0000FF0000000000),
+ cfbBits(0x000000FF00000000),
+ cfbBits(0x00000000FF000000),
+ cfbBits(0x0000000000FF0000),
+ cfbBits(0x000000000000FF00),
+ cfbBits(0x00000000000000FF),
+ };
+PixelGroup cfbrmask[] =
+ {
+ cfbBits(0x00FFFFFFFFFFFFFF),
+ cfbBits(0xFF00FFFFFFFFFFFF),
+ cfbBits(0xFFFF00FFFFFFFFFF),
+ cfbBits(0xFFFFFF00FFFFFFFF),
+ cfbBits(0xFFFFFFFF00FFFFFF),
+ cfbBits(0xFFFFFFFFFF00FFFF),
+ cfbBits(0xFFFFFFFFFFFF00FF),
+ cfbBits(0xFFFFFFFFFFFFFF00),
+ };
+#endif /* PGSZ */
+#endif /* PSZ == 8 */
+
+#if PSZ == 16
+#if PGSZ == 32
+PixelGroup cfbmask[] =
+ {
+ cfbBits(0xFFFF0000),
+ cfbBits(0x0000FFFF),
+ };
+PixelGroup cfbrmask[] =
+ {
+ cfbBits(0x0000FFFF),
+ cfbBits(0xFFFF0000),
+ };
+#else /* PGSZ == 64 */
+PixelGroup cfbmask[] =
+ {
+ cfbBits(0xFFFF000000000000),
+ cfbBits(0x0000FFFF00000000),
+ cfbBits(0x00000000FFFF0000),
+ cfbBits(0x000000000000FFFF),
+ };
+PixelGroup cfbrmask[] =
+ {
+ cfbBits(0x0000FFFFFFFFFFFF),
+ cfbBits(0xFFFF0000FFFFFFFF),
+ cfbBits(0xFFFFFFFF0000FFFF),
+ cfbBits(0xFFFFFFFFFFFF0000),
+ };
+#endif /* PGSZ */
+#endif /* PSZ == 16 */
+
+#if PSZ == 24
+#if PGSZ == 32
+PixelGroup cfbmask[] =
+ {
+ cfbBits(0xFFFFFF00),
+ cfbBits(0x00000000),
+ cfbBits(0x000000FF),
+ cfbBits(0xFFFF0000),
+ cfbBits(0x0000FFFF),
+ cfbBits(0xFF000000),
+ cfbBits(0x00FFFFFF),
+ cfbBits(0x00000000),
+ };
+PixelGroup cfbrmask[] =
+ {
+ cfbBits(0x000000FF),
+ cfbBits(0xFFFFFFFF),
+ cfbBits(0xFFFFFF00),
+ cfbBits(0x0000FFFF),
+ cfbBits(0xFFFF0000),
+ cfbBits(0x00FFFFFF),
+ cfbBits(0xFF000000),
+ cfbBits(0xFFFFFFFF),
+ };
+#else /* PGSZ == 64 */
+PixelGroup cfbmask[] =
+ {
+ cfbBits(0xFFFFFF0000000000),
+ cfbBits(0x000000FFFFFF0000),
+ cfbBits(0x000000000000FFFF),
+ };
+PixelGroup cfbmask2[] =
+ {
+ cfbBits(0x0000000000000000),
+ cfbBits(0x0000000000000000),
+ cfbBits(0xFF00000000000000),
+ };
+PixelGroup cfbrmask[] =
+ {
+ cfbBits(0x000000FFFFFFFFFF),
+ cfbBits(0xFFFFFF000000FFFF),
+ cfbBits(0xFFFFFFFFFFFF0000),
+ };
+PixelGroup cfbrmask2[] =
+ {
+ cfbBits(0x0000000000000000),
+ cfbBits(0x0000000000000000),
+ cfbBits(0x00FFFFFFFFFFFFFF),
+ };
+#endif /* PGSZ */
+#endif /* PSZ == 24 */
+
+#if PSZ == 32
+#if PGSZ == 32
+PixelGroup cfbmask[] =
+ {
+ cfbBits(0xFFFFFFFF),
+ };
+PixelGroup cfbrmask[] =
+ {
+ cfbBits(0xFFFFFFFF),
+ };
+#else /* PGSZ == 64 */
+PixelGroup cfbmask[] =
+ {
+ cfbBits(0xFFFFFFFF00000000),
+ cfbBits(0x00000000FFFFFFFF),
+ };
+PixelGroup cfbrmask[] =
+ {
+ cfbBits(0x00000000FFFFFFFF),
+ cfbBits(0xFFFFFFFF00000000),
+ };
+#endif /* PGSZ */
+#endif /* PSZ == 32 */
+
+/*
+ * QuartetBitsTable contains PPW+1 masks whose binary values are masks in the
+ * low order quartet that contain the number of bits specified in the
+ * index. This table is used by getstipplepixels.
+ */
+#if PSZ == 4
+PixelGroup QuartetBitsTable[] = {
+#if PGSZ == 32
+#if (BITMAP_BIT_ORDER == MSBFirst)
+ 0x00000000, /* 0 - 00000000 */
+ 0x00000080, /* 1 - 10000000 */
+ 0x000000C0, /* 2 - 11000000 */
+ 0x000000E0, /* 3 - 11100000 */
+ 0x000000F0, /* 4 - 11110000 */
+ 0x000000F8, /* 5 - 11111000 */
+ 0x000000FC, /* 6 - 11111100 */
+ 0x000000FE, /* 7 - 11111110 */
+ 0x000000FF /* 8 - 11111111 */
+#else /* (BITMAP_BIT_ORDER == LSBFirst */
+ 0x00000000, /* 0 - 00000000 */
+ 0x00000001, /* 1 - 00000001 */
+ 0x00000003, /* 2 - 00000011 */
+ 0x00000007, /* 3 - 00000111 */
+ 0x0000000F, /* 4 - 00001111 */
+ 0x0000001F, /* 5 - 00011111 */
+ 0x0000003F, /* 6 - 00111111 */
+ 0x0000007F, /* 7 - 01111111 */
+ 0x000000FF /* 8 - 11111111 */
+#endif /* (BITMAP_BIT_ORDER == MSBFirst) */
+#else /* PGSZ == 64 */
+#if (BITMAP_BIT_ORDER == MSBFirst)
+ 0x00000000, /* 0 - 0000000000000000 */
+ 0x00008000, /* 1 - 1000000000000000 */
+ 0x0000C000, /* 2 - 1100000000000000 */
+ 0x0000E000, /* 3 - 1110000000000000 */
+ 0x0000F000, /* 4 - 1111000000000000 */
+ 0x0000F800, /* 5 - 1111100000000000 */
+ 0x0000FC00, /* 6 - 1111110000000000 */
+ 0x0000FE00, /* 7 - 1111111000000000 */
+ 0x0000FF00, /* 8 - 1111111100000000 */
+ 0x0000FF80, /* 9 - 1111111110000000 */
+ 0x0000FFC0, /* 10- 1111111111000000 */
+ 0x0000FFE0, /* 11- 1111111111100000 */
+ 0x0000FFF0, /* 12- 1111111111110000 */
+ 0x0000FFF8, /* 13- 1111111111111000 */
+ 0x0000FFFC, /* 14- 1111111111111100 */
+ 0x0000FFFE, /* 15- 1111111111111110 */
+ 0x0000FFFF, /* 16- 1111111111111111 */
+#else /* (BITMAP_BIT_ORDER == LSBFirst */
+ 0x00000000, /* 0 - 0000000000000000 */
+ 0x00000001, /* 1 - 0000000000000001 */
+ 0x00000003, /* 2 - 0000000000000011 */
+ 0x00000007, /* 3 - 0000000000000111 */
+ 0x0000000F, /* 4 - 0000000000001111 */
+ 0x0000001F, /* 5 - 0000000000011111 */
+ 0x0000003F, /* 6 - 0000000000111111 */
+ 0x0000007F, /* 7 - 0000000001111111 */
+ 0x000000FF, /* 8 - 0000000011111111 */
+ 0x000001FF, /* 9 - 0000000111111111 */
+ 0x000003FF, /* 10- 0000001111111111 */
+ 0x000007FF, /* 11- 0000011111111111 */
+ 0x00000FFF, /* 12- 0000111111111111 */
+ 0x00001FFF, /* 13- 0001111111111111 */
+ 0x00003FFF, /* 14- 0011111111111111 */
+ 0x00007FFF, /* 15- 0111111111111111 */
+ 0x0000FFFF, /* 16- 1111111111111111 */
+#endif /* (BITMAP_BIT_ORDER == MSBFirst) */
+#endif /* PGSZ */
+};
+#endif /* PSZ == 4 */
+
+#if PSZ == 8
+PixelGroup QuartetBitsTable[] = {
+#if PGSZ == 32
+#if (BITMAP_BIT_ORDER == MSBFirst)
+ 0x00000000, /* 0 - 0000 */
+ 0x00000008, /* 1 - 1000 */
+ 0x0000000C, /* 2 - 1100 */
+ 0x0000000E, /* 3 - 1110 */
+ 0x0000000F /* 4 - 1111 */
+#else /* (BITMAP_BIT_ORDER == LSBFirst */
+ 0x00000000, /* 0 - 0000 */
+ 0x00000001, /* 1 - 0001 */
+ 0x00000003, /* 2 - 0011 */
+ 0x00000007, /* 3 - 0111 */
+ 0x0000000F /* 4 - 1111 */
+#endif /* (BITMAP_BIT_ORDER == MSBFirst) */
+#else /* PGSZ == 64 */
+#if (BITMAP_BIT_ORDER == MSBFirst)
+ 0x00000000, /* 0 - 00000000 */
+ 0x00000080, /* 1 - 10000000 */
+ 0x000000C0, /* 2 - 11000000 */
+ 0x000000E0, /* 3 - 11100000 */
+ 0x000000F0, /* 4 - 11110000 */
+ 0x000000F8, /* 5 - 11111000 */
+ 0x000000FC, /* 6 - 11111100 */
+ 0x000000FE, /* 7 - 11111110 */
+ 0x000000FF /* 8 - 11111111 */
+#else /* (BITMAP_BIT_ORDER == LSBFirst */
+ 0x00000000, /* 0 - 00000000 */
+ 0x00000001, /* 1 - 00000001 */
+ 0x00000003, /* 2 - 00000011 */
+ 0x00000007, /* 3 - 00000111 */
+ 0x0000000F, /* 4 - 10000111 */
+ 0x0000001F, /* 5 - 00011111 */
+ 0x0000003F, /* 6 - 00111111 */
+ 0x0000007F, /* 7 - 01111111 */
+ 0x000000FF /* 8 - 11111111 */
+#endif /* (BITMAP_BIT_ORDER == MSBFirst) */
+#endif /* PGSZ */
+};
+#endif /* PSZ == 8 */
+
+#if PSZ == 16
+PixelGroup QuartetBitsTable[] = {
+#if PGSZ == 32
+#if (BITMAP_BIT_ORDER == MSBFirst)
+ 0x00000000, /* 0 - 00 */
+ 0x00000002, /* 1 - 10 */
+ 0x00000003, /* 2 - 11 */
+#else /* (BITMAP_BIT_ORDER == LSBFirst */
+ 0x00000000, /* 0 - 00 */
+ 0x00000001, /* 1 - 01 */
+ 0x00000003, /* 2 - 11 */
+#endif /* (BITMAP_BIT_ORDER == MSBFirst) */
+#else /* PGSZ == 64 */
+#if (BITMAP_BIT_ORDER == MSBFirst)
+ 0x00000000, /* 0 - 0000 */
+ 0x00000008, /* 1 - 1000 */
+ 0x0000000C, /* 2 - 1100 */
+ 0x0000000E, /* 3 - 1110 */
+ 0x0000000F, /* 4 - 1111 */
+#else /* (BITMAP_BIT_ORDER == LSBFirst */
+ 0x00000000, /* 0 - 0000 */
+ 0x00000001, /* 1 - 0001 */
+ 0x00000003, /* 2 - 0011 */
+ 0x00000007, /* 3 - 0111 */
+ 0x0000000F, /* 4 - 1111 */
+#endif /* (BITMAP_BIT_ORDER == MSBFirst) */
+#endif /* PGSZ */
+};
+#endif /* PSZ == 16 */
+
+#if PSZ == 24
+PixelGroup QuartetBitsTable[] = {
+#if PGSZ == 32
+#if (BITMAP_BIT_ORDER == MSBFirst)
+ 0x00000000, /* 0 - 0 */
+ 0x00000001, /* 1 - 1 */
+#else /* (BITMAP_BIT_ORDER == LSBFirst */
+ 0x00000000, /* 0 - 0 */
+ 0x00000001, /* 1 - 1 */
+#endif /* (BITMAP_BIT_ORDER == MSBFirst) */
+#else /* PGSZ == 64 */
+#if (BITMAP_BIT_ORDER == MSBFirst)
+ 0x00000000, /* 0 - 00 */
+ 0x00000002, /* 1 - 10 */
+ 0x00000003, /* 2 - 11*/
+#else /* (BITMAP_BIT_ORDER == LSBFirst */
+ 0x00000000, /* 0 - 00 */
+ 0x00000001, /* 1 - 01 */
+ 0x00000003, /* 2 - 11 */
+#endif /* (BITMAP_BIT_ORDER == MSBFirst) */
+#endif /* PGSZ */
+};
+#endif /* PSZ == 24 */
+
+#if PSZ == 32
+PixelGroup QuartetBitsTable[] = {
+#if PGSZ == 32
+#if (BITMAP_BIT_ORDER == MSBFirst)
+ 0x00000000, /* 0 - 0 */
+ 0x00000001, /* 1 - 1 */
+#else /* (BITMAP_BIT_ORDER == LSBFirst */
+ 0x00000000, /* 0 - 0 */
+ 0x00000001, /* 1 - 1 */
+#endif /* (BITMAP_BIT_ORDER == MSBFirst) */
+#else /* PGSZ == 64 */
+#if (BITMAP_BIT_ORDER == MSBFirst)
+ 0x00000000, /* 0 - 00 */
+ 0x00000002, /* 1 - 10 */
+ 0x00000003, /* 2 - 11*/
+#else /* (BITMAP_BIT_ORDER == LSBFirst */
+ 0x00000000, /* 0 - 00 */
+ 0x00000001, /* 1 - 01 */
+ 0x00000003, /* 2 - 11 */
+#endif /* (BITMAP_BIT_ORDER == MSBFirst) */
+#endif /* PGSZ */
+};
+#endif /* PSZ == 32 */
+
+/*
+ * QuartetPixelMaskTable is used by getstipplepixels to get a pixel mask
+ * corresponding to a quartet of bits. Note: the bit/byte order dependency
+ * is handled by QuartetBitsTable above.
+ */
+#if PSZ == 4
+#if PGSZ == 32
+PixelGroup QuartetPixelMaskTable[] = {
+ 0x00000000,
+ 0x0000000F,
+ 0x000000F0,
+ 0x000000FF,
+ 0x00000F00,
+ 0x00000F0F,
+ 0x00000FF0,
+ 0x00000FFF,
+ 0x0000F000,
+ 0x0000F00F,
+ 0x0000F0F0,
+ 0x0000F0FF,
+ 0x0000FF00,
+ 0x0000FF0F,
+ 0x0000FFF0,
+ 0x0000FFFF,
+ 0x000F0000,
+ 0x000F000F,
+ 0x000F00F0,
+ 0x000F00FF,
+ 0x000F0F00,
+ 0x000F0F0F,
+ 0x000F0FF0,
+ 0x000F0FFF,
+ 0x000FF000,
+ 0x000FF00F,
+ 0x000FF0F0,
+ 0x000FF0FF,
+ 0x000FFF00,
+ 0x000FFF0F,
+ 0x000FFFF0,
+ 0x000FFFFF,
+ 0x00F00000,
+ 0x00F0000F,
+ 0x00F000F0,
+ 0x00F000FF,
+ 0x00F00F00,
+ 0x00F00F0F,
+ 0x00F00FF0,
+ 0x00F00FFF,
+ 0x00F0F000,
+ 0x00F0F00F,
+ 0x00F0F0F0,
+ 0x00F0F0FF,
+ 0x00F0FF00,
+ 0x00F0FF0F,
+ 0x00F0FFF0,
+ 0x00F0FFFF,
+ 0x00FF0000,
+ 0x00FF000F,
+ 0x00FF00F0,
+ 0x00FF00FF,
+ 0x00FF0F00,
+ 0x00FF0F0F,
+ 0x00FF0FF0,
+ 0x00FF0FFF,
+ 0x00FFF000,
+ 0x00FFF00F,
+ 0x00FFF0F0,
+ 0x00FFF0FF,
+ 0x00FFFF00,
+ 0x00FFFF0F,
+ 0x00FFFFF0,
+ 0x00FFFFFF,
+ 0x0F000000,
+ 0x0F00000F,
+ 0x0F0000F0,
+ 0x0F0000FF,
+ 0x0F000F00,
+ 0x0F000F0F,
+ 0x0F000FF0,
+ 0x0F000FFF,
+ 0x0F00F000,
+ 0x0F00F00F,
+ 0x0F00F0F0,
+ 0x0F00F0FF,
+ 0x0F00FF00,
+ 0x0F00FF0F,
+ 0x0F00FFF0,
+ 0x0F00FFFF,
+ 0x0F0F0000,
+ 0x0F0F000F,
+ 0x0F0F00F0,
+ 0x0F0F00FF,
+ 0x0F0F0F00,
+ 0x0F0F0F0F,
+ 0x0F0F0FF0,
+ 0x0F0F0FFF,
+ 0x0F0FF000,
+ 0x0F0FF00F,
+ 0x0F0FF0F0,
+ 0x0F0FF0FF,
+ 0x0F0FFF00,
+ 0x0F0FFF0F,
+ 0x0F0FFFF0,
+ 0x0F0FFFFF,
+ 0x0FF00000,
+ 0x0FF0000F,
+ 0x0FF000F0,
+ 0x0FF000FF,
+ 0x0FF00F00,
+ 0x0FF00F0F,
+ 0x0FF00FF0,
+ 0x0FF00FFF,
+ 0x0FF0F000,
+ 0x0FF0F00F,
+ 0x0FF0F0F0,
+ 0x0FF0F0FF,
+ 0x0FF0FF00,
+ 0x0FF0FF0F,
+ 0x0FF0FFF0,
+ 0x0FF0FFFF,
+ 0x0FFF0000,
+ 0x0FFF000F,
+ 0x0FFF00F0,
+ 0x0FFF00FF,
+ 0x0FFF0F00,
+ 0x0FFF0F0F,
+ 0x0FFF0FF0,
+ 0x0FFF0FFF,
+ 0x0FFFF000,
+ 0x0FFFF00F,
+ 0x0FFFF0F0,
+ 0x0FFFF0FF,
+ 0x0FFFFF00,
+ 0x0FFFFF0F,
+ 0x0FFFFFF0,
+ 0x0FFFFFFF,
+ 0xF0000000,
+ 0xF000000F,
+ 0xF00000F0,
+ 0xF00000FF,
+ 0xF0000F00,
+ 0xF0000F0F,
+ 0xF0000FF0,
+ 0xF0000FFF,
+ 0xF000F000,
+ 0xF000F00F,
+ 0xF000F0F0,
+ 0xF000F0FF,
+ 0xF000FF00,
+ 0xF000FF0F,
+ 0xF000FFF0,
+ 0xF000FFFF,
+ 0xF00F0000,
+ 0xF00F000F,
+ 0xF00F00F0,
+ 0xF00F00FF,
+ 0xF00F0F00,
+ 0xF00F0F0F,
+ 0xF00F0FF0,
+ 0xF00F0FFF,
+ 0xF00FF000,
+ 0xF00FF00F,
+ 0xF00FF0F0,
+ 0xF00FF0FF,
+ 0xF00FFF00,
+ 0xF00FFF0F,
+ 0xF00FFFF0,
+ 0xF00FFFFF,
+ 0xF0F00000,
+ 0xF0F0000F,
+ 0xF0F000F0,
+ 0xF0F000FF,
+ 0xF0F00F00,
+ 0xF0F00F0F,
+ 0xF0F00FF0,
+ 0xF0F00FFF,
+ 0xF0F0F000,
+ 0xF0F0F00F,
+ 0xF0F0F0F0,
+ 0xF0F0F0FF,
+ 0xF0F0FF00,
+ 0xF0F0FF0F,
+ 0xF0F0FFF0,
+ 0xF0F0FFFF,
+ 0xF0FF0000,
+ 0xF0FF000F,
+ 0xF0FF00F0,
+ 0xF0FF00FF,
+ 0xF0FF0F00,
+ 0xF0FF0F0F,
+ 0xF0FF0FF0,
+ 0xF0FF0FFF,
+ 0xF0FFF000,
+ 0xF0FFF00F,
+ 0xF0FFF0F0,
+ 0xF0FFF0FF,
+ 0xF0FFFF00,
+ 0xF0FFFF0F,
+ 0xF0FFFFF0,
+ 0xF0FFFFFF,
+ 0xFF000000,
+ 0xFF00000F,
+ 0xFF0000F0,
+ 0xFF0000FF,
+ 0xFF000F00,
+ 0xFF000F0F,
+ 0xFF000FF0,
+ 0xFF000FFF,
+ 0xFF00F000,
+ 0xFF00F00F,
+ 0xFF00F0F0,
+ 0xFF00F0FF,
+ 0xFF00FF00,
+ 0xFF00FF0F,
+ 0xFF00FFF0,
+ 0xFF00FFFF,
+ 0xFF0F0000,
+ 0xFF0F000F,
+ 0xFF0F00F0,
+ 0xFF0F00FF,
+ 0xFF0F0F00,
+ 0xFF0F0F0F,
+ 0xFF0F0FF0,
+ 0xFF0F0FFF,
+ 0xFF0FF000,
+ 0xFF0FF00F,
+ 0xFF0FF0F0,
+ 0xFF0FF0FF,
+ 0xFF0FFF00,
+ 0xFF0FFF0F,
+ 0xFF0FFFF0,
+ 0xFF0FFFFF,
+ 0xFFF00000,
+ 0xFFF0000F,
+ 0xFFF000F0,
+ 0xFFF000FF,
+ 0xFFF00F00,
+ 0xFFF00F0F,
+ 0xFFF00FF0,
+ 0xFFF00FFF,
+ 0xFFF0F000,
+ 0xFFF0F00F,
+ 0xFFF0F0F0,
+ 0xFFF0F0FF,
+ 0xFFF0FF00,
+ 0xFFF0FF0F,
+ 0xFFF0FFF0,
+ 0xFFF0FFFF,
+ 0xFFFF0000,
+ 0xFFFF000F,
+ 0xFFFF00F0,
+ 0xFFFF00FF,
+ 0xFFFF0F00,
+ 0xFFFF0F0F,
+ 0xFFFF0FF0,
+ 0xFFFF0FFF,
+ 0xFFFFF000,
+ 0xFFFFF00F,
+ 0xFFFFF0F0,
+ 0xFFFFF0FF,
+ 0xFFFFFF00,
+ 0xFFFFFF0F,
+ 0xFFFFFFF0,
+ 0xFFFFFFFF,
+};
+#else /* PGSZ == 64 */
+No QuartetPixelMaskTable for psz=PSZ
+this would be a 64K entry table, a bit much I think.
+Try breaking things in two:
+mask = table[index&0xff00]<<32 | table[index&0xff]
+#endif /* PGSZ */
+#endif /* PSZ == 4 */
+
+#if PSZ == 8
+PixelGroup QuartetPixelMaskTable[] = {
+#if PGSZ == 32
+ 0x00000000,
+ 0x000000FF,
+ 0x0000FF00,
+ 0x0000FFFF,
+ 0x00FF0000,
+ 0x00FF00FF,
+ 0x00FFFF00,
+ 0x00FFFFFF,
+ 0xFF000000,
+ 0xFF0000FF,
+ 0xFF00FF00,
+ 0xFF00FFFF,
+ 0xFFFF0000,
+ 0xFFFF00FF,
+ 0xFFFFFF00,
+ 0xFFFFFFFF
+#else /* PGSZ == 64 */
+ 0x0000000000000000, 0x00000000000000FF,
+ 0x000000000000FF00, 0x000000000000FFFF,
+ 0x0000000000FF0000, 0x0000000000FF00FF,
+ 0x0000000000FFFF00, 0x0000000000FFFFFF,
+ 0x00000000FF000000, 0x00000000FF0000FF,
+ 0x00000000FF00FF00, 0x00000000FF00FFFF,
+ 0x00000000FFFF0000, 0x00000000FFFF00FF,
+ 0x00000000FFFFFF00, 0x00000000FFFFFFFF,
+ 0x000000FF00000000, 0x000000FF000000FF,
+ 0x000000FF0000FF00, 0x000000FF0000FFFF,
+ 0x000000FF00FF0000, 0x000000FF00FF00FF,
+ 0x000000FF00FFFF00, 0x000000FF00FFFFFF,
+ 0x000000FFFF000000, 0x000000FFFF0000FF,
+ 0x000000FFFF00FF00, 0x000000FFFF00FFFF,
+ 0x000000FFFFFF0000, 0x000000FFFFFF00FF,
+ 0x000000FFFFFFFF00, 0x000000FFFFFFFFFF,
+ 0x0000FF0000000000, 0x0000FF00000000FF,
+ 0x0000FF000000FF00, 0x0000FF000000FFFF,
+ 0x0000FF0000FF0000, 0x0000FF0000FF00FF,
+ 0x0000FF0000FFFF00, 0x0000FF0000FFFFFF,
+ 0x0000FF00FF000000, 0x0000FF00FF0000FF,
+ 0x0000FF00FF00FF00, 0x0000FF00FF00FFFF,
+ 0x0000FF00FFFF0000, 0x0000FF00FFFF00FF,
+ 0x0000FF00FFFFFF00, 0x0000FF00FFFFFFFF,
+ 0x0000FFFF00000000, 0x0000FFFF000000FF,
+ 0x0000FFFF0000FF00, 0x0000FFFF0000FFFF,
+ 0x0000FFFF00FF0000, 0x0000FFFF00FF00FF,
+ 0x0000FFFF00FFFF00, 0x0000FFFF00FFFFFF,
+ 0x0000FFFFFF000000, 0x0000FFFFFF0000FF,
+ 0x0000FFFFFF00FF00, 0x0000FFFFFF00FFFF,
+ 0x0000FFFFFFFF0000, 0x0000FFFFFFFF00FF,
+ 0x0000FFFFFFFFFF00, 0x0000FFFFFFFFFFFF,
+ 0x00FF000000000000, 0x00FF0000000000FF,
+ 0x00FF00000000FF00, 0x00FF00000000FFFF,
+ 0x00FF000000FF0000, 0x00FF000000FF00FF,
+ 0x00FF000000FFFF00, 0x00FF000000FFFFFF,
+ 0x00FF0000FF000000, 0x00FF0000FF0000FF,
+ 0x00FF0000FF00FF00, 0x00FF0000FF00FFFF,
+ 0x00FF0000FFFF0000, 0x00FF0000FFFF00FF,
+ 0x00FF0000FFFFFF00, 0x00FF0000FFFFFFFF,
+ 0x00FF00FF00000000, 0x00FF00FF000000FF,
+ 0x00FF00FF0000FF00, 0x00FF00FF0000FFFF,
+ 0x00FF00FF00FF0000, 0x00FF00FF00FF00FF,
+ 0x00FF00FF00FFFF00, 0x00FF00FF00FFFFFF,
+ 0x00FF00FFFF000000, 0x00FF00FFFF0000FF,
+ 0x00FF00FFFF00FF00, 0x00FF00FFFF00FFFF,
+ 0x00FF00FFFFFF0000, 0x00FF00FFFFFF00FF,
+ 0x00FF00FFFFFFFF00, 0x00FF00FFFFFFFFFF,
+ 0x00FFFF0000000000, 0x00FFFF00000000FF,
+ 0x00FFFF000000FF00, 0x00FFFF000000FFFF,
+ 0x00FFFF0000FF0000, 0x00FFFF0000FF00FF,
+ 0x00FFFF0000FFFF00, 0x00FFFF0000FFFFFF,
+ 0x00FFFF00FF000000, 0x00FFFF00FF0000FF,
+ 0x00FFFF00FF00FF00, 0x00FFFF00FF00FFFF,
+ 0x00FFFF00FFFF0000, 0x00FFFF00FFFF00FF,
+ 0x00FFFF00FFFFFF00, 0x00FFFF00FFFFFFFF,
+ 0x00FFFFFF00000000, 0x00FFFFFF000000FF,
+ 0x00FFFFFF0000FF00, 0x00FFFFFF0000FFFF,
+ 0x00FFFFFF00FF0000, 0x00FFFFFF00FF00FF,
+ 0x00FFFFFF00FFFF00, 0x00FFFFFF00FFFFFF,
+ 0x00FFFFFFFF000000, 0x00FFFFFFFF0000FF,
+ 0x00FFFFFFFF00FF00, 0x00FFFFFFFF00FFFF,
+ 0x00FFFFFFFFFF0000, 0x00FFFFFFFFFF00FF,
+ 0x00FFFFFFFFFFFF00, 0x00FFFFFFFFFFFFFF,
+ 0xFF00000000000000, 0xFF000000000000FF,
+ 0xFF0000000000FF00, 0xFF0000000000FFFF,
+ 0xFF00000000FF0000, 0xFF00000000FF00FF,
+ 0xFF00000000FFFF00, 0xFF00000000FFFFFF,
+ 0xFF000000FF000000, 0xFF000000FF0000FF,
+ 0xFF000000FF00FF00, 0xFF000000FF00FFFF,
+ 0xFF000000FFFF0000, 0xFF000000FFFF00FF,
+ 0xFF000000FFFFFF00, 0xFF000000FFFFFFFF,
+ 0xFF0000FF00000000, 0xFF0000FF000000FF,
+ 0xFF0000FF0000FF00, 0xFF0000FF0000FFFF,
+ 0xFF0000FF00FF0000, 0xFF0000FF00FF00FF,
+ 0xFF0000FF00FFFF00, 0xFF0000FF00FFFFFF,
+ 0xFF0000FFFF000000, 0xFF0000FFFF0000FF,
+ 0xFF0000FFFF00FF00, 0xFF0000FFFF00FFFF,
+ 0xFF0000FFFFFF0000, 0xFF0000FFFFFF00FF,
+ 0xFF0000FFFFFFFF00, 0xFF0000FFFFFFFFFF,
+ 0xFF00FF0000000000, 0xFF00FF00000000FF,
+ 0xFF00FF000000FF00, 0xFF00FF000000FFFF,
+ 0xFF00FF0000FF0000, 0xFF00FF0000FF00FF,
+ 0xFF00FF0000FFFF00, 0xFF00FF0000FFFFFF,
+ 0xFF00FF00FF000000, 0xFF00FF00FF0000FF,
+ 0xFF00FF00FF00FF00, 0xFF00FF00FF00FFFF,
+ 0xFF00FF00FFFF0000, 0xFF00FF00FFFF00FF,
+ 0xFF00FF00FFFFFF00, 0xFF00FF00FFFFFFFF,
+ 0xFF00FFFF00000000, 0xFF00FFFF000000FF,
+ 0xFF00FFFF0000FF00, 0xFF00FFFF0000FFFF,
+ 0xFF00FFFF00FF0000, 0xFF00FFFF00FF00FF,
+ 0xFF00FFFF00FFFF00, 0xFF00FFFF00FFFFFF,
+ 0xFF00FFFFFF000000, 0xFF00FFFFFF0000FF,
+ 0xFF00FFFFFF00FF00, 0xFF00FFFFFF00FFFF,
+ 0xFF00FFFFFFFF0000, 0xFF00FFFFFFFF00FF,
+ 0xFF00FFFFFFFFFF00, 0xFF00FFFFFFFFFFFF,
+ 0xFFFF000000000000, 0xFFFF0000000000FF,
+ 0xFFFF00000000FF00, 0xFFFF00000000FFFF,
+ 0xFFFF000000FF0000, 0xFFFF000000FF00FF,
+ 0xFFFF000000FFFF00, 0xFFFF000000FFFFFF,
+ 0xFFFF0000FF000000, 0xFFFF0000FF0000FF,
+ 0xFFFF0000FF00FF00, 0xFFFF0000FF00FFFF,
+ 0xFFFF0000FFFF0000, 0xFFFF0000FFFF00FF,
+ 0xFFFF0000FFFFFF00, 0xFFFF0000FFFFFFFF,
+ 0xFFFF00FF00000000, 0xFFFF00FF000000FF,
+ 0xFFFF00FF0000FF00, 0xFFFF00FF0000FFFF,
+ 0xFFFF00FF00FF0000, 0xFFFF00FF00FF00FF,
+ 0xFFFF00FF00FFFF00, 0xFFFF00FF00FFFFFF,
+ 0xFFFF00FFFF000000, 0xFFFF00FFFF0000FF,
+ 0xFFFF00FFFF00FF00, 0xFFFF00FFFF00FFFF,
+ 0xFFFF00FFFFFF0000, 0xFFFF00FFFFFF00FF,
+ 0xFFFF00FFFFFFFF00, 0xFFFF00FFFFFFFFFF,
+ 0xFFFFFF0000000000, 0xFFFFFF00000000FF,
+ 0xFFFFFF000000FF00, 0xFFFFFF000000FFFF,
+ 0xFFFFFF0000FF0000, 0xFFFFFF0000FF00FF,
+ 0xFFFFFF0000FFFF00, 0xFFFFFF0000FFFFFF,
+ 0xFFFFFF00FF000000, 0xFFFFFF00FF0000FF,
+ 0xFFFFFF00FF00FF00, 0xFFFFFF00FF00FFFF,
+ 0xFFFFFF00FFFF0000, 0xFFFFFF00FFFF00FF,
+ 0xFFFFFF00FFFFFF00, 0xFFFFFF00FFFFFFFF,
+ 0xFFFFFFFF00000000, 0xFFFFFFFF000000FF,
+ 0xFFFFFFFF0000FF00, 0xFFFFFFFF0000FFFF,
+ 0xFFFFFFFF00FF0000, 0xFFFFFFFF00FF00FF,
+ 0xFFFFFFFF00FFFF00, 0xFFFFFFFF00FFFFFF,
+ 0xFFFFFFFFFF000000, 0xFFFFFFFFFF0000FF,
+ 0xFFFFFFFFFF00FF00, 0xFFFFFFFFFF00FFFF,
+ 0xFFFFFFFFFFFF0000, 0xFFFFFFFFFFFF00FF,
+ 0xFFFFFFFFFFFFFF00, 0xFFFFFFFFFFFFFFFF,
+#endif /* PGSZ */
+};
+#endif /* PSZ == 8 */
+
+#if PSZ == 16
+PixelGroup QuartetPixelMaskTable[] = {
+#if PGSZ == 32
+ 0x00000000,
+ 0x0000FFFF,
+ 0xFFFF0000,
+ 0xFFFFFFFF,
+#else /* PGSZ == 64 */
+ 0x0000000000000000, 0x000000000000FFFF,
+ 0x00000000FFFF0000, 0x00000000FFFFFFFF,
+ 0x0000FFFF00000000, 0x0000FFFF0000FFFF,
+ 0x0000FFFFFFFF0000, 0x0000FFFFFFFFFFFF,
+ 0xFFFF000000000000, 0xFFFF00000000FFFF,
+ 0xFFFF0000FFFF0000, 0xFFFF0000FFFFFFFF,
+ 0xFFFFFFFF00000000, 0xFFFFFFFF0000FFFF,
+ 0xFFFFFFFFFFFF0000, 0xFFFFFFFFFFFFFFFF,
+#endif /* PGSZ */
+};
+#endif /* PSZ == 16 */
+
+#if PSZ == 24
+PixelGroup QuartetPixelMaskTable[] = {
+#if PGSZ == 32
+/* Four pixels consist three pixel groups....*/
+ 0x00000000, 0x00FFFFFF, /*0x00000000, *//*0*/
+/* 0x00000000, 0x00000000, 0x00000000,*/ /*0*/
+/* 0x00FFFFFF, 0x00000000, 0x00000000,*/ /*1*/
+/* 0xFF000000, 0x0000FFFF, 0x00000000,*/ /*2*/
+/* 0xFFFFFFFF, 0x0000FFFF, 0x00000000,*/ /*3*/
+/* 0x00000000, 0xFFFF0000, 0x000000FF,*/ /*4*/
+/* 0x00FFFFFF, 0xFFFF0000, 0x000000FF,*/ /*5*/
+/* 0xFF000000, 0xFFFFFFFF, 0x000000FF,*/ /*6*/
+/* 0xFFFFFFFF, 0xFFFFFFFF, 0x000000FF,*/ /*7*/
+/* 0x00000000, 0x00000000, 0xFFFFFF00,*/ /*8*/
+/* 0x00FFFFFF, 0x00000000, 0xFFFFFF00,*/ /*9*/
+/* 0xFF000000, 0x0000FFFF, 0xFFFFFF00,*/ /*10*/
+/* 0xFFFFFFFF, 0x0000FFFF, 0xFFFFFF00,*/ /*11*/
+/* 0x00000000, 0xFFFF0000, 0xFFFFFFFF,*/ /*12*/
+/* 0x00FFFFFF, 0xFFFF0000, 0xFFFFFFFF,*/ /*13*/
+/* 0xFF000000, 0xFFFFFFFF, 0xFFFFFFFF,*/ /*14*/
+/* 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,*/ /*15*/
+#else /* PGSZ == 64 */
+ 0x0000000000000000, 0x0000000000FFFFFF,
+ 0x0000FFFFFF000000, 0xFFFFFFFFFFFFFFFF
+#endif /* PGSZ */
+};
+#endif /* PSZ == 24 */
+
+#if PSZ == 32
+PixelGroup QuartetPixelMaskTable[] = {
+#if PGSZ == 32
+ 0x00000000,
+ 0xFFFFFFFF,
+#else /* PGSZ == 64 */
+ 0x0000000000000000,
+ 0x00000000FFFFFFFF,
+ 0xFFFFFFFF00000000,
+ 0xFFFFFFFFFFFFFFFF
+#endif /* PGSZ */
+};
+#endif /* PSZ == 32 */
+
+#if PSZ == 24
+int cfb24Shift[] =
+#if (BITMAP_BIT_ORDER == MSBFirst)
+{8,0,16,16,8,24,0,0};
+#else /* (BITMAP_BIT_ORDER == LSBFirst) */
+{0,0,24,8,16,16,8,0};
+#endif /* (BITMAP_BIT_ORDER == MSBFirst) */
+#endif
diff --git a/nx-X11/programs/Xserver/cfb/cfbmskbits.h b/nx-X11/programs/Xserver/cfb/cfbmskbits.h
new file mode 100644
index 000000000..a803cac72
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbmskbits.h
@@ -0,0 +1,897 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfbmskbits.h,v 3.13tsi Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/* $Xorg: cfbmskbits.h,v 1.3 2000/08/17 19:48:14 cpqbld Exp $ */
+/* Optimizations for PSZ == 32 added by Kyle Marvin (marvin@vitec.com) */
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#if defined(XFREE86) || ( defined(__OpenBSD__) && defined(__alpha__) ) \
+ || (defined(__bsdi__))
+#include "xf86_ansic.h"
+#include "compiler.h"
+#endif
+
+/*
+ * ==========================================================================
+ * Converted from mfb to support memory-mapped color framebuffer by smarks@sun,
+ * April-May 1987.
+ *
+ * The way I did the conversion was to consider each longword as an
+ * array of four bytes instead of an array of 32 one-bit pixels. So
+ * getbits() and putbits() retain much the same calling sequence, but
+ * they move bytes around instead of bits. Of course, this entails the
+ * removal of all of the one-bit-pixel dependencies from the other
+ * files, but the major bit-hacking stuff should be covered here.
+ *
+ * I've created some new macros that make it easier to understand what's
+ * going on in the pixel calculations, and that make it easier to change the
+ * pixel size.
+ *
+ * name explanation
+ * ---- -----------
+ * PSZ pixel size (in bits)
+ * PGSZ pixel group size (in bits)
+ * PGSZB pixel group size (in bytes)
+ * PGSZBMSK mask with lowest PGSZB bits set to 1
+ * PPW pixels per word (pixels per pixel group)
+ * PPWMSK mask with lowest PPW bits set to 1
+ * PLST index of last pixel in a word (should be PPW-1)
+ * PIM pixel index mask (index within a pixel group)
+ * PWSH pixel-to-word shift (should be log2(PPW))
+ * PMSK mask with lowest PSZ bits set to 1
+ *
+ *
+ * Here are some sample values. In the notation cfbA,B: A is PSZ, and
+ * B is PGSZB. All the other values are derived from these
+ * two. This table does not show all combinations!
+ *
+ * name cfb8,4 cfb24,4 cfb32,4 cfb8,8 cfb24,8 cfb32,8
+ * ---- ------ ------- ------ ------ ------ -------
+ * PSZ 8 24 32 8 24 32
+ * PGSZ 32 32 32 64 64 64
+ * PGSZB 4 4 4 8 8 8
+ * PGSZBMSK 0xF 0xF? 0xF 0xFF 0xFF 0xFF
+ * PPW 4 1 1 8 2 2
+ * PPWMSK 0xF 0x1 0x1 0xFF 0x3? 0x3
+ * PLST 3 0 0 7 1 1
+ * PIM 0x3 0x0 0x0 0x7 0x1? 0x1
+ * PWSH 2 0 0 3 1 1
+ * PMSK 0xFF 0xFFFFFF 0xFFFFFFFF 0xFF 0xFFFFFF 0xFFFFFFFF
+ *
+ *
+ * I have also added a new macro, PFILL, that takes one pixel and
+ * replicates it throughout a word. This macro definition is dependent
+ * upon pixel and word size; it doesn't use macros like PPW and so
+ * forth. Examples: for monochrome, PFILL(1) => 0xffffffff, PFILL(0) =>
+ * 0x00000000. For 8-bit color, PFILL(0x5d) => 0x5d5d5d5d. This macro
+ * is used primarily for replicating a plane mask into a word.
+ *
+ * Color framebuffers operations also support the notion of a plane
+ * mask. This mask determines which planes of the framebuffer can be
+ * altered; the others are left unchanged. I have added another
+ * parameter to the putbits and putbitsrop macros that is the plane
+ * mask.
+ * ==========================================================================
+ *
+ * Keith Packard (keithp@suse.com)
+ * 64bit code is no longer supported; it requires DIX support
+ * for repadding images which significantly impacts performance
+ */
+
+/*
+ * PSZ needs to be defined before we get here. Usually it comes from a
+ * -DPSZ=foo on the compilation command line.
+ */
+
+#ifndef PSZ
+#define PSZ 8
+#endif
+
+/*
+ * PixelGroup is the data type used to operate on groups of pixels.
+ * We typedef it here to CARD32 with the assumption that you
+ * want to manipulate 32 bits worth of pixels at a time as you can. If CARD32
+ * is not appropriate for your server, define it to something else
+ * before including this file. In this case you will also have to define
+ * PGSZB to the size in bytes of PixelGroup.
+ */
+#ifndef PixelGroup
+#define PixelGroup CARD32
+#define PGSZB 4
+#endif /* PixelGroup */
+
+#ifndef CfbBits
+#define CfbBits CARD32
+#endif
+
+#define PGSZ (PGSZB << 3)
+#define PPW (PGSZ/PSZ)
+#define PLST (PPW-1)
+#define PIM PLST
+#define PMSK (((PixelGroup)1 << PSZ) - 1)
+#define PPWMSK (((PixelGroup)1 << PPW) - 1) /* instead of BITMSK */
+#define PGSZBMSK (((PixelGroup)1 << PGSZB) - 1)
+
+/* set PWSH = log2(PPW) using brute force */
+
+#if PPW == 1
+#define PWSH 0
+#else
+#if PPW == 2
+#define PWSH 1
+#else
+#if PPW == 4
+#define PWSH 2
+#else
+#if PPW == 8
+#define PWSH 3
+#else
+#if PPW == 16
+#define PWSH 4
+#endif /* PPW == 16 */
+#endif /* PPW == 8 */
+#endif /* PPW == 4 */
+#endif /* PPW == 2 */
+#endif /* PPW == 1 */
+
+/* Defining PIXEL_ADDR means that individual pixels are addressable by this
+ * machine (as type PixelType). A possible CFB architecture which supported
+ * 8-bits-per-pixel on a non byte-addressable machine would not have this
+ * defined.
+ *
+ * Defining FOUR_BIT_CODE means that cfb knows how to stipple on this machine;
+ * eventually, stippling code for 16 and 32 bit devices should be written
+ * which would allow them to also use FOUR_BIT_CODE. There isn't that
+ * much to do in those cases, but it would make them quite a bit faster.
+ */
+
+#if PSZ == 8
+#define PIXEL_ADDR
+typedef CARD8 PixelType;
+#define FOUR_BIT_CODE
+#endif
+
+#if PSZ == 16
+#define PIXEL_ADDR
+typedef CARD16 PixelType;
+#endif
+
+#if PSZ == 24
+#undef PMSK
+#define PMSK 0xFFFFFF
+/*#undef PIM
+#define PIM 3*/
+#define PIXEL_ADDR
+typedef CARD32 PixelType;
+#endif
+
+#if PSZ == 32
+#undef PMSK
+#define PMSK 0xFFFFFFFF
+#define PIXEL_ADDR
+typedef CARD32 PixelType;
+#endif
+
+
+/* the following notes use the following conventions:
+SCREEN LEFT SCREEN RIGHT
+in this file and maskbits.c, left and right refer to screen coordinates,
+NOT bit numbering in registers.
+
+cfbstarttab[n]
+ pixels[0,n-1] = 0's pixels[n,PPW-1] = 1's
+cfbendtab[n] =
+ pixels[0,n-1] = 1's pixels[n,PPW-1] = 0's
+
+cfbstartpartial[], cfbendpartial[]
+ these are used as accelerators for doing putbits and masking out
+bits that are all contained between longword boudaries. the extra
+256 bytes of data seems a small price to pay -- code is smaller,
+and narrow things (e.g. window borders) go faster.
+
+the names may seem misleading; they are derived not from which end
+of the word the bits are turned on, but at which end of a scanline
+the table tends to be used.
+
+look at the tables and macros to understand boundary conditions.
+(careful readers will note that starttab[n] = ~endtab[n] for n != 0)
+
+-----------------------------------------------------------------------
+these two macros depend on the screen's bit ordering.
+in both of them x is a screen position. they are used to
+combine bits collected from multiple longwords into a
+single destination longword, and to unpack a single
+source longword into multiple destinations.
+
+SCRLEFT(dst, x)
+ takes dst[x, PPW] and moves them to dst[0, PPW-x]
+ the contents of the rest of dst are 0 ONLY IF
+ dst is UNSIGNED.
+ is cast as an unsigned.
+ this is a right shift on the VAX, left shift on
+ Sun and pc-rt.
+
+SCRRIGHT(dst, x)
+ takes dst[0,x] and moves them to dst[PPW-x, PPW]
+ the contents of the rest of dst are 0 ONLY IF
+ dst is UNSIGNED.
+ this is a left shift on the VAX, right shift on
+ Sun and pc-rt.
+
+
+the remaining macros are cpu-independent; all bit order dependencies
+are built into the tables and the two macros above.
+
+maskbits(x, w, startmask, endmask, nlw)
+ for a span of width w starting at position x, returns
+a mask for ragged pixels at start, mask for ragged pixels at end,
+and the number of whole longwords between the ends.
+
+maskpartialbits(x, w, mask)
+ works like maskbits(), except all the pixels are in the
+ same longword (i.e. (x&0xPIM + w) <= PPW)
+
+mask32bits(x, w, startmask, endmask, nlw)
+ as maskbits, but does not calculate nlw. it is used by
+ cfbGlyphBlt to put down glyphs <= PPW bits wide.
+
+getbits(psrc, x, w, dst)
+ starting at position x in psrc (x < PPW), collect w
+ pixels and put them in the screen left portion of dst.
+ psrc is a longword pointer. this may span longword boundaries.
+ it special-cases fetching all w bits from one longword.
+
+ +--------+--------+ +--------+
+ | | m |n| | ==> | m |n| |
+ +--------+--------+ +--------+
+ x x+w 0 w
+ psrc psrc+1 dst
+ m = PPW - x
+ n = w - m
+
+ implementation:
+ get m pixels, move to screen-left of dst, zeroing rest of dst;
+ get n pixels from next word, move screen-right by m, zeroing
+ lower m pixels of word.
+ OR the two things together.
+
+putbits(src, x, w, pdst, planemask)
+ starting at position x in pdst, put down the screen-leftmost
+ w bits of src. pdst is a longword pointer. this may
+ span longword boundaries.
+ it special-cases putting all w bits into the same longword.
+
+ +--------+ +--------+--------+
+ | m |n| | ==> | | m |n| |
+ +--------+ +--------+--------+
+ 0 w x x+w
+ dst pdst pdst+1
+ m = PPW - x
+ n = w - m
+
+ implementation:
+ get m pixels, shift screen-right by x, zero screen-leftmost x
+ pixels; zero rightmost m bits of *pdst and OR in stuff
+ from before the semicolon.
+ shift src screen-left by m, zero bits n-32;
+ zero leftmost n pixels of *(pdst+1) and OR in the
+ stuff from before the semicolon.
+
+putbitsrop(src, x, w, pdst, planemask, ROP)
+ like putbits but calls DoRop with the rasterop ROP (see cfb.h for
+ DoRop)
+
+getleftbits(psrc, w, dst)
+ get the leftmost w (w<=PPW) bits from *psrc and put them
+ in dst. this is used by the cfbGlyphBlt code for glyphs
+ <=PPW bits wide.
+*/
+
+#if (BITMAP_BIT_ORDER == MSBFirst)
+#define BitRight(lw,n) ((lw) >> (n))
+#define BitLeft(lw,n) ((lw) << (n))
+#else /* (BITMAP_BIT_ORDER == LSBFirst) */
+#define BitRight(lw,n) ((lw) << (n))
+#define BitLeft(lw,n) ((lw) >> (n))
+#endif /* (BITMAP_BIT_ORDER == MSBFirst) */
+
+#define SCRLEFT(lw, n) BitLeft (lw, (n) * PSZ)
+#define SCRRIGHT(lw, n) BitRight(lw, (n) * PSZ)
+
+/*
+ * Note that the shift direction is independent of the byte ordering of the
+ * machine. The following is portable code.
+ */
+#if PPW == 16
+#define PFILL(p) ( ((p)&PMSK) | \
+ ((p)&PMSK) << PSZ | \
+ ((p)&PMSK) << 2*PSZ | \
+ ((p)&PMSK) << 3*PSZ | \
+ ((p)&PMSK) << 4*PSZ | \
+ ((p)&PMSK) << 5*PSZ | \
+ ((p)&PMSK) << 6*PSZ | \
+ ((p)&PMSK) << 7*PSZ | \
+ ((p)&PMSK) << 8*PSZ | \
+ ((p)&PMSK) << 9*PSZ | \
+ ((p)&PMSK) << 10*PSZ | \
+ ((p)&PMSK) << 11*PSZ | \
+ ((p)&PMSK) << 12*PSZ | \
+ ((p)&PMSK) << 13*PSZ | \
+ ((p)&PMSK) << 14*PSZ | \
+ ((p)&PMSK) << 15*PSZ )
+#define PFILL2(p, pf) { \
+ pf = (p) & PMSK; \
+ pf |= (pf << PSZ); \
+ pf |= (pf << 2*PSZ); \
+ pf |= (pf << 4*PSZ); \
+ pf |= (pf << 8*PSZ); \
+}
+#endif /* PPW == 16 */
+#if PPW == 8
+#define PFILL(p) ( ((p)&PMSK) | \
+ ((p)&PMSK) << PSZ | \
+ ((p)&PMSK) << 2*PSZ | \
+ ((p)&PMSK) << 3*PSZ | \
+ ((p)&PMSK) << 4*PSZ | \
+ ((p)&PMSK) << 5*PSZ | \
+ ((p)&PMSK) << 6*PSZ | \
+ ((p)&PMSK) << 7*PSZ )
+#define PFILL2(p, pf) { \
+ pf = (p) & PMSK; \
+ pf |= (pf << PSZ); \
+ pf |= (pf << 2*PSZ); \
+ pf |= (pf << 4*PSZ); \
+}
+#endif
+#if PPW == 4
+#define PFILL(p) ( ((p)&PMSK) | \
+ ((p)&PMSK) << PSZ | \
+ ((p)&PMSK) << 2*PSZ | \
+ ((p)&PMSK) << 3*PSZ )
+#define PFILL2(p, pf) { \
+ pf = (p) & PMSK; \
+ pf |= (pf << PSZ); \
+ pf |= (pf << 2*PSZ); \
+}
+#endif
+#if PPW == 2
+#define PFILL(p) ( ((p)&PMSK) | \
+ ((p)&PMSK) << PSZ )
+#define PFILL2(p, pf) { \
+ pf = (p) & PMSK; \
+ pf |= (pf << PSZ); \
+}
+#endif
+#if PPW == 1
+#define PFILL(p) (p)
+#define PFILL2(p,pf) (pf = (p))
+#endif
+
+/*
+ * Reduced raster op - using precomputed values, perform the above
+ * in three instructions
+ */
+
+#define DoRRop(dst, and, xor) (((dst) & (and)) ^ (xor))
+
+#define DoMaskRRop(dst, and, xor, mask) \
+ (((dst) & ((and) | ~(mask))) ^ (xor & mask))
+
+#if PSZ != 32 || PPW != 1
+
+# if (PSZ == 24 && PPW == 1)
+#define maskbits(x, w, startmask, endmask, nlw) {\
+ startmask = cfbstarttab[(x)&3]; \
+ endmask = cfbendtab[((x)+(w)) & 3]; \
+ nlw = ((((x)+(w))*3)>>2) - (((x)*3 +3)>>2); \
+}
+
+#define mask32bits(x, w, startmask, endmask) \
+ startmask = cfbstarttab[(x)&3]; \
+ endmask = cfbendtab[((x)+(w)) & 3];
+
+#define maskpartialbits(x, w, mask) \
+ mask = cfbstartpartial[(x) & 3] & cfbendpartial[((x)+(w)) & 3];
+
+#define maskbits24(x, w, startmask, endmask, nlw) \
+ startmask = cfbstarttab24[(x) & 3]; \
+ endmask = cfbendtab24[((x)+(w)) & 3]; \
+ if (startmask){ \
+ nlw = (((w) - (4 - ((x) & 3))) >> 2); \
+ } else { \
+ nlw = (w) >> 2; \
+ }
+
+#define getbits24(psrc, dst, index) {\
+ register int idx; \
+ switch(idx = ((index)&3)<<1){ \
+ case 0: \
+ dst = (*(psrc) &cfbmask[idx]); \
+ break; \
+ case 6: \
+ dst = BitLeft((*(psrc) &cfbmask[idx]), cfb24Shift[idx]); \
+ break; \
+ default: \
+ dst = BitLeft((*(psrc) &cfbmask[idx]), cfb24Shift[idx]) | \
+ BitRight(((*((psrc)+1)) &cfbmask[idx+1]), cfb24Shift[idx+1]); \
+ }; \
+}
+
+#define putbits24(src, w, pdst, planemask, index) {\
+ register PixelGroup dstpixel; \
+ register unsigned int idx; \
+ switch(idx = ((index)&3)<<1){ \
+ case 0: \
+ dstpixel = (*(pdst) &cfbmask[idx]); \
+ break; \
+ case 6: \
+ dstpixel = BitLeft((*(pdst) &cfbmask[idx]), cfb24Shift[idx]); \
+ break; \
+ default: \
+ dstpixel = BitLeft((*(pdst) &cfbmask[idx]), cfb24Shift[idx])| \
+ BitRight(((*((pdst)+1)) &cfbmask[idx+1]), cfb24Shift[idx+1]); \
+ }; \
+ dstpixel &= ~(planemask); \
+ dstpixel |= (src & planemask); \
+ *(pdst) &= cfbrmask[idx]; \
+ switch(idx){ \
+ case 0: \
+ *(pdst) |= (dstpixel & cfbmask[idx]); \
+ break; \
+ case 2: \
+ case 4: \
+ pdst++;idx++; \
+ *(pdst) = ((*(pdst)) & cfbrmask[idx]) | \
+ (BitLeft(dstpixel, cfb24Shift[idx]) & cfbmask[idx]); \
+ pdst--;idx--; \
+ case 6: \
+ *(pdst) |= (BitRight(dstpixel, cfb24Shift[idx]) & cfbmask[idx]); \
+ break; \
+ }; \
+}
+
+#define putbitsrop24(src, x, pdst, planemask, rop) \
+{ \
+ register PixelGroup t1, dstpixel; \
+ register unsigned int idx; \
+ switch(idx = (x)<<1){ \
+ case 0: \
+ dstpixel = (*(pdst) &cfbmask[idx]); \
+ break; \
+ case 6: \
+ dstpixel = BitLeft((*(pdst) &cfbmask[idx]), cfb24Shift[idx]); \
+ break; \
+ default: \
+ dstpixel = BitLeft((*(pdst) &cfbmask[idx]), cfb24Shift[idx])| \
+ BitRight(((*((pdst)+1)) &cfbmask[idx+1]), cfb24Shift[idx+1]); \
+ }; \
+ DoRop(t1, rop, (src), dstpixel); \
+ dstpixel &= ~planemask; \
+ dstpixel |= (t1 & planemask); \
+ *(pdst) &= cfbrmask[idx]; \
+ switch(idx){ \
+ case 0: \
+ *(pdst) |= (dstpixel & cfbmask[idx]); \
+ break; \
+ case 2: \
+ case 4: \
+ *((pdst)+1) = ((*((pdst)+1)) & cfbrmask[idx+1]) | \
+ (BitLeft(dstpixel, cfb24Shift[idx+1]) & (cfbmask[idx+1])); \
+ case 6: \
+ *(pdst) |= (BitRight(dstpixel, cfb24Shift[idx]) & cfbmask[idx]); \
+ }; \
+}
+# else /* PSZ == 24 && PPW == 1 */
+#define maskbits(x, w, startmask, endmask, nlw) \
+ startmask = cfbstarttab[(x)&PIM]; \
+ endmask = cfbendtab[((x)+(w)) & PIM]; \
+ if (startmask) \
+ nlw = (((w) - (PPW - ((x)&PIM))) >> PWSH); \
+ else \
+ nlw = (w) >> PWSH;
+
+#define maskpartialbits(x, w, mask) \
+ mask = cfbstartpartial[(x) & PIM] & cfbendpartial[((x) + (w)) & PIM];
+
+#define mask32bits(x, w, startmask, endmask) \
+ startmask = cfbstarttab[(x)&PIM]; \
+ endmask = cfbendtab[((x)+(w)) & PIM];
+
+/* FIXME */
+#define maskbits24(x, w, startmask, endmask, nlw) \
+ abort()
+#define getbits24(psrc, dst, index) \
+ abort()
+#define putbits24(src, w, pdst, planemask, index) \
+ abort()
+#define putbitsrop24(src, x, pdst, planemask, rop) \
+ abort()
+
+#endif /* PSZ == 24 && PPW == 1 */
+
+#define getbits(psrc, x, w, dst) \
+if ( ((x) + (w)) <= PPW) \
+{ \
+ dst = SCRLEFT(*(psrc), (x)); \
+} \
+else \
+{ \
+ int m; \
+ m = PPW-(x); \
+ dst = (SCRLEFT(*(psrc), (x)) & cfbendtab[m]) | \
+ (SCRRIGHT(*((psrc)+1), m) & cfbstarttab[m]); \
+}
+
+
+#define putbits(src, x, w, pdst, planemask) \
+if ( ((x)+(w)) <= PPW) \
+{ \
+ PixelGroup tmpmask; \
+ maskpartialbits((x), (w), tmpmask); \
+ tmpmask &= PFILL(planemask); \
+ *(pdst) = (*(pdst) & ~tmpmask) | (SCRRIGHT(src, x) & tmpmask); \
+} \
+else \
+{ \
+ unsigned int m; \
+ unsigned int n; \
+ PixelGroup pm = PFILL(planemask); \
+ m = PPW-(x); \
+ n = (w) - m; \
+ *(pdst) = (*(pdst) & (cfbendtab[x] | ~pm)) | \
+ (SCRRIGHT(src, x) & (cfbstarttab[x] & pm)); \
+ *((pdst)+1) = (*((pdst)+1) & (cfbstarttab[n] | ~pm)) | \
+ (SCRLEFT(src, m) & (cfbendtab[n] & pm)); \
+}
+#if defined(__GNUC__) && defined(mc68020)
+#undef getbits
+#define FASTGETBITS(psrc, x, w, dst) \
+ asm ("bfextu %3{%1:%2},%0" \
+ : "=d" (dst) : "di" (x), "di" (w), "o" (*(char *)(psrc)))
+
+#define getbits(psrc,x,w,dst) \
+{ \
+ FASTGETBITS(psrc, (x) * PSZ, (w) * PSZ, dst); \
+ dst = SCRLEFT(dst,PPW-(w)); \
+}
+
+#define FASTPUTBITS(src, x, w, pdst) \
+ asm ("bfins %3,%0{%1:%2}" \
+ : "=o" (*(char *)(pdst)) \
+ : "di" (x), "di" (w), "d" (src), "0" (*(char *) (pdst)))
+
+#undef putbits
+#define putbits(src, x, w, pdst, planemask) \
+{ \
+ if (planemask != PMSK) { \
+ PixelGroup _m, _pm; \
+ FASTGETBITS(pdst, (x) * PSZ , (w) * PSZ, _m); \
+ PFILL2(planemask, _pm); \
+ _m &= (~_pm); \
+ _m |= (SCRRIGHT(src, PPW-(w)) & _pm); \
+ FASTPUTBITS(_m, (x) * PSZ, (w) * PSZ, pdst); \
+ } else { \
+ FASTPUTBITS(SCRRIGHT(src, PPW-(w)), (x) * PSZ, (w) * PSZ, pdst); \
+ } \
+}
+
+
+#endif /* mc68020 */
+
+#define putbitsrop(src, x, w, pdst, planemask, rop) \
+if ( ((x)+(w)) <= PPW) \
+{ \
+ PixelGroup tmpmask; \
+ PixelGroup t1, t2; \
+ maskpartialbits((x), (w), tmpmask); \
+ PFILL2(planemask, t1); \
+ tmpmask &= t1; \
+ t1 = SCRRIGHT((src), (x)); \
+ DoRop(t2, rop, t1, *(pdst)); \
+ *(pdst) = (*(pdst) & ~tmpmask) | (t2 & tmpmask); \
+} \
+else \
+{ \
+ CfbBits m; \
+ CfbBits n; \
+ PixelGroup t1, t2; \
+ PixelGroup pm; \
+ PFILL2(planemask, pm); \
+ m = PPW-(x); \
+ n = (w) - m; \
+ t1 = SCRRIGHT((src), (x)); \
+ DoRop(t2, rop, t1, *(pdst)); \
+ *(pdst) = (*(pdst) & (cfbendtab[x] | ~pm)) | (t2 & (cfbstarttab[x] & pm));\
+ t1 = SCRLEFT((src), m); \
+ DoRop(t2, rop, t1, *((pdst) + 1)); \
+ *((pdst)+1) = (*((pdst)+1) & (cfbstarttab[n] | ~pm)) | \
+ (t2 & (cfbendtab[n] & pm)); \
+}
+
+#else /* PSZ == 32 && PPW == 1*/
+
+/*
+ * These macros can be optimized for 32-bit pixels since there is no
+ * need to worry about left/right edge masking. These macros were
+ * derived from the above using the following reductions:
+ *
+ * - x & PIW = 0 [since PIW = 0]
+ * - all masking tables are only indexed by 0 [ due to above ]
+ * - cfbstartab[0] and cfbendtab[0] = 0 [ no left/right edge masks]
+ * - cfbstartpartial[0] and cfbendpartial[0] = ~0 [no partial pixel mask]
+ *
+ * Macro reduction based upon constants cannot be performed automatically
+ * by the compiler since it does not know the contents of the masking
+ * arrays in cfbmskbits.c.
+ */
+#define maskbits(x, w, startmask, endmask, nlw) \
+ startmask = endmask = 0; \
+ nlw = (w);
+
+#define maskpartialbits(x, w, mask) \
+ mask = 0xFFFFFFFF;
+
+#define mask32bits(x, w, startmask, endmask) \
+ startmask = endmask = 0;
+
+/*
+ * For 32-bit operations, getbits(), putbits(), and putbitsrop()
+ * will only be invoked with x = 0 and w = PPW (1). The getbits()
+ * macro is only called within left/right edge logic, which doesn't
+ * happen for 32-bit pixels.
+ */
+#define getbits(psrc, x, w, dst) (dst) = *(psrc)
+
+#define putbits(src, x, w, pdst, planemask) \
+ *(pdst) = (*(pdst) & ~planemask) | (src & planemask);
+
+#define putbitsrop(src, x, w, pdst, planemask, rop) \
+{ \
+ PixelGroup t1; \
+ DoRop(t1, rop, (src), *(pdst)); \
+ *(pdst) = (*(pdst) & ~planemask) | (t1 & planemask); \
+}
+
+#endif /* PSZ != 32 */
+
+/*
+ * Use these macros only when you're using the MergeRop stuff
+ * in ../mfb/mergerop.h
+ */
+
+/* useful only when not spanning destination longwords */
+#if PSZ == 24
+#define putbitsmropshort24(src,x,w,pdst,index) {\
+ PixelGroup _tmpmask; \
+ PixelGroup _t1; \
+ maskpartialbits ((x), (w), _tmpmask); \
+ _t1 = SCRRIGHT((src), (x)); \
+ DoMaskMergeRop24(_t1, pdst, _tmpmask, index); \
+}
+#endif
+#define putbitsmropshort(src,x,w,pdst) {\
+ PixelGroup _tmpmask; \
+ PixelGroup _t1; \
+ maskpartialbits ((x), (w), _tmpmask); \
+ _t1 = SCRRIGHT((src), (x)); \
+ *pdst = DoMaskMergeRop(_t1, *pdst, _tmpmask); \
+}
+
+/* useful only when spanning destination longwords */
+#define putbitsmroplong(src,x,w,pdst) { \
+ PixelGroup _startmask, _endmask; \
+ int _m; \
+ PixelGroup _t1; \
+ _m = PPW - (x); \
+ _startmask = cfbstarttab[x]; \
+ _endmask = cfbendtab[(w) - _m]; \
+ _t1 = SCRRIGHT((src), (x)); \
+ pdst[0] = DoMaskMergeRop(_t1,pdst[0],_startmask); \
+ _t1 = SCRLEFT ((src),_m); \
+ pdst[1] = DoMaskMergeRop(_t1,pdst[1],_endmask); \
+}
+
+#define putbitsmrop(src,x,w,pdst) \
+if ((x) + (w) <= PPW) {\
+ putbitsmropshort(src,x,w,pdst); \
+} else { \
+ putbitsmroplong(src,x,w,pdst); \
+}
+
+#if GETLEFTBITS_ALIGNMENT == 1
+#define getleftbits(psrc, w, dst) dst = *((unsigned int *) psrc)
+#define getleftbits24(psrc, w, dst, idx){ \
+ regiseter int index; \
+ switch(index = ((idx)&3)<<1){ \
+ case 0: \
+ dst = (*((unsigned int *) psrc))&cfbmask[index]; \
+ break; \
+ case 2: \
+ case 4: \
+ dst = BitLeft(((*((unsigned int *) psrc))&cfbmask[index]), cfb24Shift[index]); \
+ dst |= BitRight(((*((unsigned int *) psrc)+1)&cfbmask[index]), cfb4Shift[index]); \
+ break; \
+ case 6: \
+ dst = BitLeft((*((unsigned int *) psrc)),cfb24Shift[index]); \
+ break; \
+ }; \
+}
+#endif /* GETLEFTBITS_ALIGNMENT == 1 */
+
+#define getglyphbits(psrc, x, w, dst) \
+{ \
+ dst = BitLeft((unsigned) *(psrc), (x)); \
+ if ( ((x) + (w)) > 32) \
+ dst |= (BitRight((unsigned) *((psrc)+1), 32-(x))); \
+}
+#if GETLEFTBITS_ALIGNMENT == 2
+#define getleftbits(psrc, w, dst) \
+ { \
+ if ( ((int)(psrc)) & 0x01 ) \
+ getglyphbits( ((unsigned int *)(((char *)(psrc))-1)), 8, (w), (dst) ); \
+ else \
+ dst = *((unsigned int *) psrc); \
+ }
+#endif /* GETLEFTBITS_ALIGNMENT == 2 */
+
+#if GETLEFTBITS_ALIGNMENT == 4
+#define getleftbits(psrc, w, dst) \
+ { \
+ int off, off_b; \
+ off_b = (off = ( ((int)(psrc)) & 0x03)) << 3; \
+ getglyphbits( \
+ (unsigned int *)( ((char *)(psrc)) - off), \
+ (off_b), (w), (dst) \
+ ); \
+ }
+#endif /* GETLEFTBITS_ALIGNMENT == 4 */
+
+/*
+ * getstipplepixels( psrcstip, x, w, ones, psrcpix, destpix )
+ *
+ * Converts bits to pixels in a reasonable way. Takes w (1 <= w <= PPW)
+ * bits from *psrcstip, starting at bit x; call this a quartet of bits.
+ * Then, takes the pixels from *psrcpix corresponding to the one-bits (if
+ * ones is TRUE) or the zero-bits (if ones is FALSE) of the quartet
+ * and puts these pixels into destpix.
+ *
+ * Example:
+ *
+ * getstipplepixels( &(0x08192A3B), 17, 4, 1, &(0x4C5D6E7F), dest )
+ *
+ * 0x08192A3B = 0000 1000 0001 1001 0010 1010 0011 1011
+ *
+ * This will take 4 bits starting at bit 17, so the quartet is 0x5 = 0101.
+ * It will take pixels from 0x4C5D6E7F corresponding to the one-bits in this
+ * quartet, so dest = 0x005D007F.
+ *
+ * XXX Works with both byte order.
+ * XXX This works for all values of x and w within a doubleword.
+ */
+#if (BITMAP_BIT_ORDER == MSBFirst)
+#define getstipplepixels( psrcstip, x, w, ones, psrcpix, destpix ) \
+{ \
+ PixelGroup q; \
+ int m; \
+ if ((m = ((x) - ((PPW*PSZ)-PPW))) > 0) { \
+ q = (*(psrcstip)) << m; \
+ if ( (x)+(w) > (PPW*PSZ) ) \
+ q |= *((psrcstip)+1) >> ((PPW*PSZ)-m); \
+ } \
+ else \
+ q = (*(psrcstip)) >> -m; \
+ q = QuartetBitsTable[(w)] & ((ones) ? q : ~q); \
+ *(destpix) = (*(psrcpix)) & QuartetPixelMaskTable[q]; \
+}
+/* I just copied this to get the linker satisfied on PowerPC,
+ * so this may not be correct at all.
+ */
+#define getstipplepixels24(psrcstip,xt,ones,psrcpix,destpix,stipindex) \
+{ \
+ PixelGroup q; \
+ q = *(psrcstip) >> (xt); \
+ q = ((ones) ? q : ~q) & 1; \
+ *(destpix) = (*(psrcpix)) & QuartetPixelMaskTable[q]; \
+}
+#else /* BITMAP_BIT_ORDER == LSB */
+
+/* this must load 32 bits worth; for most machines, thats an int */
+#define CfbFetchUnaligned(x) ldl_u(x)
+
+#define getstipplepixels( psrcstip, xt, w, ones, psrcpix, destpix ) \
+{ \
+ PixelGroup q; \
+ q = CfbFetchUnaligned(psrcstip) >> (xt); \
+ if ( ((xt)+(w)) > (PPW*PSZ) ) \
+ q |= (CfbFetchUnaligned((psrcstip)+1)) << ((PPW*PSZ)-(xt)); \
+ q = QuartetBitsTable[(w)] & ((ones) ? q : ~q); \
+ *(destpix) = (*(psrcpix)) & QuartetPixelMaskTable[q]; \
+}
+#if PSZ == 24
+# if 0
+#define getstipplepixels24(psrcstip,xt,w,ones,psrcpix,destpix,stipindex,srcindex,dstindex) \
+{ \
+ PixelGroup q; \
+ CfbBits src; \
+ register unsigned int sidx; \
+ register unsigned int didx; \
+ sidx = ((srcindex) & 3)<<1; \
+ didx = ((dstindex) & 3)<<1; \
+ q = *(psrcstip) >> (xt); \
+/* if((srcindex)!=0)*/ \
+/* src = (((*(psrcpix)) << cfb24Shift[sidx]) & (cfbmask[sidx])) |*/ \
+/* (((*((psrcpix)+1)) << cfb24Shift[sidx+1]) & (cfbmask[sidx+1])); */\
+/* else */\
+ src = (*(psrcpix))&0xFFFFFF; \
+ if ( ((xt)+(w)) > PGSZ ) \
+ q |= (*((psrcstip)+1)) << (PGSZ -(xt)); \
+ q = QuartetBitsTable[(w)] & ((ones) ? q : ~q); \
+ src &= QuartetPixelMaskTable[q]; \
+ *(destpix) &= cfbrmask[didx]; \
+ switch(didx) {\
+ case 0: \
+ *(destpix) |= (src &cfbmask[didx]); \
+ break; \
+ case 2: \
+ case 4: \
+ destpix++;didx++; \
+ *(destpix) = ((*(destpix)) & (cfbrmask[didx]))| \
+ (BitLeft(src, cfb24Shift[didx]) & (cfbmask[didx])); \
+ destpix--; didx--;\
+ case 6: \
+ *(destpix) |= (BitRight(src, cfb24Shift[didx]) & cfbmask[didx]); \
+ break; \
+ }; \
+}
+# else
+#define getstipplepixels24(psrcstip,xt,ones,psrcpix,destpix,stipindex) \
+{ \
+ PixelGroup q; \
+ q = *(psrcstip) >> (xt); \
+ q = ((ones) ? q : ~q) & 1; \
+ *(destpix) = (*(psrcpix)) & QuartetPixelMaskTable[q]; \
+}
+# endif
+#endif /* PSZ == 24 */
+#endif
+
+extern PixelGroup cfbstarttab[];
+extern PixelGroup cfbendtab[];
+extern PixelGroup cfbstartpartial[];
+extern PixelGroup cfbendpartial[];
+extern PixelGroup cfbrmask[];
+extern PixelGroup cfbmask[];
+extern PixelGroup QuartetBitsTable[];
+extern PixelGroup QuartetPixelMaskTable[];
+#if PSZ == 24
+extern int cfb24Shift[];
+#endif
diff --git a/nx-X11/programs/Xserver/cfb/cfbpixmap.c b/nx-X11/programs/Xserver/cfb/cfbpixmap.c
new file mode 100644
index 000000000..704ab4eda
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbpixmap.c
@@ -0,0 +1,376 @@
+/* $Xorg: cfbpixmap.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/cfb/cfbpixmap.c,v 1.4 2001/01/17 22:36:36 dawes Exp $ */
+/* pixmap management
+ written by drewry, september 1986
+
+ on a monchrome device, a pixmap is a bitmap.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "mi.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+
+PixmapPtr
+cfbCreatePixmap (pScreen, width, height, depth)
+ ScreenPtr pScreen;
+ int width;
+ int height;
+ int depth;
+{
+ PixmapPtr pPixmap;
+ size_t datasize;
+ size_t paddedWidth;
+
+ paddedWidth = PixmapBytePad(width, depth);
+
+ if (paddedWidth / 4 > 32767 || height > 32767)
+ return NullPixmap;
+ datasize = height * paddedWidth;
+ pPixmap = AllocatePixmap(pScreen, datasize);
+ if (!pPixmap)
+ return NullPixmap;
+ pPixmap->drawable.type = DRAWABLE_PIXMAP;
+ pPixmap->drawable.class = 0;
+ pPixmap->drawable.pScreen = pScreen;
+ pPixmap->drawable.depth = depth;
+ pPixmap->drawable.bitsPerPixel = BitsPerPixel(depth);
+ pPixmap->drawable.id = 0;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pPixmap->drawable.x = 0;
+ pPixmap->drawable.y = 0;
+ pPixmap->drawable.width = width;
+ pPixmap->drawable.height = height;
+ pPixmap->devKind = paddedWidth;
+ pPixmap->refcnt = 1;
+#ifdef PIXPRIV
+ pPixmap->devPrivate.ptr = datasize ?
+ (pointer)((char *)pPixmap + pScreen->totalPixmapSize) : NULL;
+#else
+ pPixmap->devPrivate.ptr = (pointer)(pPixmap + 1);
+#endif
+ return pPixmap;
+}
+
+Bool
+cfbDestroyPixmap(pPixmap)
+ PixmapPtr pPixmap;
+{
+ if(--pPixmap->refcnt)
+ return TRUE;
+ xfree(pPixmap);
+ return TRUE;
+}
+
+PixmapPtr
+cfbCopyPixmap(pSrc)
+ register PixmapPtr pSrc;
+{
+ register PixmapPtr pDst;
+ int size;
+ ScreenPtr pScreen;
+
+ size = pSrc->drawable.height * pSrc->devKind;
+ pScreen = pSrc->drawable.pScreen;
+ pDst = (*pScreen->CreatePixmap) (pScreen, pSrc->drawable.width,
+ pSrc->drawable.height, pSrc->drawable.depth);
+ if (!pDst)
+ return NullPixmap;
+ memmove((char *)pDst->devPrivate.ptr, (char *)pSrc->devPrivate.ptr, size);
+ return pDst;
+}
+
+
+/* replicates a pattern to be a full 32 bits wide.
+ relies on the fact that each scnaline is longword padded.
+ doesn't do anything if pixmap is not a factor of 32 wide.
+ changes width field of pixmap if successful, so that the fast
+ cfbXRotatePixmap code gets used if we rotate the pixmap later.
+ cfbYRotatePixmap code gets used if we rotate the pixmap later.
+
+ calculate number of times to repeat
+ for each scanline of pattern
+ zero out area to be filled with replicate
+ left shift and or in original as many times as needed
+*/
+void
+cfbPadPixmap(pPixmap)
+ PixmapPtr pPixmap;
+{
+ register int width = (pPixmap->drawable.width) * (pPixmap->drawable.bitsPerPixel);
+ register int h;
+ register CfbBits mask;
+ register CfbBits *p;
+ register CfbBits bits; /* real pattern bits */
+ register int i;
+ int rep; /* repeat count for pattern */
+
+ if (width >= PGSZ)
+ return;
+
+ rep = PGSZ/width;
+ if (rep*width != PGSZ)
+ return;
+
+ mask = mfbGetendtab(width);
+
+ p = (CfbBits *)(pPixmap->devPrivate.ptr);
+ for (h=0; h < pPixmap->drawable.height; h++)
+ {
+ *p &= mask;
+ bits = *p;
+ for(i=1; i<rep; i++)
+ {
+#if (BITMAP_BIT_ORDER == MSBFirst)
+ bits >>= width;
+#else
+ bits <<= width;
+#endif
+ *p |= bits;
+ }
+ p++;
+ }
+ pPixmap->drawable.width = PGSZ/(pPixmap->drawable.bitsPerPixel);
+}
+
+
+#ifdef notdef
+/*
+ * cfb debugging routine -- assumes pixmap is 1 byte deep
+ */
+static cfbdumppixmap(pPix)
+ PixmapPtr pPix;
+{
+ unsigned int *pw;
+ char *psrc, *pdst;
+ int i, j;
+ char line[66];
+
+ ErrorF( "pPixmap: 0x%x\n", pPix);
+ ErrorF( "%d wide %d high\n", pPix->drawable.width, pPix->drawable.height);
+ if (pPix->drawable.width > 64)
+ {
+ ErrorF( "too wide to see\n");
+ return;
+ }
+
+ pw = (unsigned int *) pPix->devPrivate.ptr;
+ psrc = (char *) pw;
+
+/*
+ for ( i=0; i<pPix->drawable.height; ++i )
+ ErrorF( "0x%x\n", pw[i] );
+*/
+
+ for ( i = 0; i < pPix->drawable.height; ++i ) {
+ pdst = line;
+ for(j = 0; j < pPix->drawable.width; j++) {
+ *pdst++ = *psrc++ ? 'X' : ' ' ;
+ }
+ *pdst++ = '\n';
+ *pdst++ = '\0';
+ ErrorF( "%s", line);
+ }
+}
+#endif /* notdef */
+
+/* Rotates pixmap pPix by w pixels to the right on the screen. Assumes that
+ * words are PGSZ bits wide, and that the least significant bit appears on the
+ * left.
+ */
+void
+cfbXRotatePixmap(pPix, rw)
+ PixmapPtr pPix;
+ register int rw;
+{
+ register CfbBits *pw, *pwFinal;
+ register CfbBits t;
+ int rot;
+
+ if (pPix == NullPixmap)
+ return;
+
+ switch (((DrawablePtr) pPix)->bitsPerPixel) {
+ case PSZ:
+ break;
+ case 1:
+ mfbXRotatePixmap(pPix, rw);
+ return;
+ default:
+ ErrorF("cfbXRotatePixmap: unsupported bitsPerPixel %d\n", ((DrawablePtr) pPix)->bitsPerPixel);
+ return;
+ }
+ pw = (CfbBits *)pPix->devPrivate.ptr;
+ modulus (rw, (int) pPix->drawable.width, rot);
+ if(pPix->drawable.width == PPW)
+ {
+ pwFinal = pw + pPix->drawable.height;
+ while(pw < pwFinal)
+ {
+ t = *pw;
+ *pw++ = SCRRIGHT(t, rot) |
+ (SCRLEFT(t, (PPW-rot)) & cfbendtab[rot]);
+ }
+ }
+ else
+ {
+ ErrorF("cfb internal error: trying to rotate odd-sized pixmap.\n");
+#ifdef notdef
+ register CfbBits *pwTmp;
+ int size, tsize;
+
+ tsize = PixmapBytePad(pPix->drawable.width - rot, pPix->drawable.depth);
+ pwTmp = (CfbBits *) ALLOCATE_LOCAL(pPix->drawable.height * tsize);
+ if (!pwTmp)
+ return;
+ /* divide pw (the pixmap) in two vertically at (w - rot) and swap */
+ tsize >>= 2;
+ size = pPix->devKind >> SIZE0F(PixelGroup);
+ cfbQuickBlt((CfbBits *)pw, (CfbBits *)pwTmp,
+ 0, 0, 0, 0,
+ (int)pPix->drawable.width - rot, (int)pPix->drawable.height,
+ size, tsize);
+ cfbQuickBlt((CfbBits *)pw, (CfbBits *)pw,
+ (int)pPix->drawable.width - rot, 0, 0, 0,
+ rot, (int)pPix->drawable.height,
+ size, size);
+ cfbQuickBlt((CfbBits *)pwTmp, (CfbBits *)pw,
+ 0, 0, rot, 0,
+ (int)pPix->drawable.width - rot, (int)pPix->drawable.height,
+ tsize, size);
+ DEALLOCATE_LOCAL(pwTmp);
+#endif
+ }
+}
+
+/* Rotates pixmap pPix by h lines. Assumes that h is always less than
+ pPix->drawable.height
+ works on any width.
+ */
+void
+cfbYRotatePixmap(pPix, rh)
+ register PixmapPtr pPix;
+ int rh;
+{
+ int nbyDown; /* bytes to move down to row 0; also offset of
+ row rh */
+ int nbyUp; /* bytes to move up to line rh; also
+ offset of first line moved down to 0 */
+ char *pbase;
+ char *ptmp;
+ int rot;
+
+ if (pPix == NullPixmap)
+ return;
+ switch (((DrawablePtr) pPix)->bitsPerPixel) {
+ case PSZ:
+ break;
+ case 1:
+ mfbYRotatePixmap(pPix, rh);
+ return;
+ default:
+ ErrorF("cfbYRotatePixmap: unsupported bitsPerPixel %d\n", ((DrawablePtr) pPix)->bitsPerPixel);
+ return;
+ }
+
+ modulus (rh, (int) pPix->drawable.height, rot);
+ pbase = (char *)pPix->devPrivate.ptr;
+
+ nbyDown = rot * pPix->devKind;
+ nbyUp = (pPix->devKind * pPix->drawable.height) - nbyDown;
+ if(!(ptmp = (char *)ALLOCATE_LOCAL(nbyUp)))
+ return;
+
+ memmove(ptmp, pbase, nbyUp); /* save the low rows */
+ memmove(pbase, pbase+nbyUp, nbyDown); /* slide the top rows down */
+ memmove(pbase+nbyDown, ptmp, nbyUp); /* move lower rows up to row rot */
+ DEALLOCATE_LOCAL(ptmp);
+}
+
+void
+cfbCopyRotatePixmap(psrcPix, ppdstPix, xrot, yrot)
+ register PixmapPtr psrcPix, *ppdstPix;
+ int xrot, yrot;
+{
+ register PixmapPtr pdstPix;
+
+ if ((pdstPix = *ppdstPix) &&
+ (pdstPix->devKind == psrcPix->devKind) &&
+ (pdstPix->drawable.height == psrcPix->drawable.height))
+ {
+ memmove((char *)pdstPix->devPrivate.ptr,
+ (char *)psrcPix->devPrivate.ptr,
+ psrcPix->drawable.height * psrcPix->devKind);
+ pdstPix->drawable.width = psrcPix->drawable.width;
+ pdstPix->drawable.depth = psrcPix->drawable.depth;
+ pdstPix->drawable.bitsPerPixel = psrcPix->drawable.bitsPerPixel;
+ pdstPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ }
+ else
+ {
+ if (pdstPix)
+ /* FIX XBUG 6168 */
+ (*pdstPix->drawable.pScreen->DestroyPixmap)(pdstPix);
+ *ppdstPix = pdstPix = cfbCopyPixmap(psrcPix);
+ if (!pdstPix)
+ return;
+ }
+ cfbPadPixmap(pdstPix);
+ if (xrot)
+ cfbXRotatePixmap(pdstPix, xrot);
+ if (yrot)
+ cfbYRotatePixmap(pdstPix, yrot);
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbply1rct.c b/nx-X11/programs/Xserver/cfb/cfbply1rct.c
new file mode 100644
index 000000000..99a2379c9
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbply1rct.c
@@ -0,0 +1,363 @@
+/*
+ * $Xorg: cfbply1rct.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $
+ *
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/programs/Xserver/cfb/cfbply1rct.c,v 3.10 2003/10/29 22:44:53 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "mistruct.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "cfbrrop.h"
+
+void
+RROP_NAME(cfbFillPoly1Rect) (pDrawable, pGC, shape, mode, count, ptsIn)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int shape;
+ int mode;
+ int count;
+ DDXPointPtr ptsIn;
+{
+ cfbPrivGCPtr devPriv;
+ int nwidth;
+ CfbBits *addrl, *addr;
+#if PSZ == 24
+ CfbBits startmask, endmask;
+ register int pidx;
+#else
+#if PPW > 1
+ CfbBits mask, bits = ~((CfbBits)0);
+#endif
+#endif
+ int maxy;
+ int origin;
+ register int vertex1, vertex2;
+ int c = 0;
+ BoxPtr extents;
+ int clip;
+ int y;
+ int *vertex1p = NULL, *vertex2p;
+ int *endp;
+ int x1 = 0, x2 = 0;
+ int dx1 = 0, dx2 = 0;
+ int dy1 = 0, dy2 = 0;
+ int e1 = 0, e2 = 0;
+ int step1 = 0, step2 = 0;
+ int sign1 = 0, sign2 = 0;
+ int h;
+ int l;
+#if PSZ != 24 && PPW > 1
+ int r;
+#endif
+ int nmiddle;
+ RROP_DECLARE
+
+ if (mode == CoordModePrevious)
+ {
+ miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ devPriv = cfbGetGCPrivate(pGC);
+#ifdef NO_ONE_RECT
+ if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1)
+ {
+ miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+#endif
+ origin = *((int *) &pDrawable->x);
+ vertex2 = origin - ((origin & 0x8000) << 1);
+ extents = &pGC->pCompositeClip->extents;
+ RROP_FETCH_GCPRIV(devPriv);
+ vertex1 = *((int *) &extents->x1) - vertex2;
+ vertex2 = *((int *) &extents->x2) - vertex2 - 0x00010001;
+ clip = 0;
+ y = 32767;
+ maxy = 0;
+ vertex2p = (int *) ptsIn;
+ endp = vertex2p + count;
+ if (shape == Convex)
+ {
+ while (count--)
+ {
+ c = *vertex2p;
+ clip |= (c - vertex1) | (vertex2 - c);
+ c = intToY(c);
+ if (c < y)
+ {
+ y = c;
+ vertex1p = vertex2p;
+ }
+ vertex2p++;
+ if (c > maxy)
+ maxy = c;
+ }
+ }
+ else
+ {
+ int yFlip = 0;
+ dx1 = 1;
+ x2 = -1;
+ x1 = -1;
+ while (count--)
+ {
+ c = *vertex2p;
+ clip |= (c - vertex1) | (vertex2 - c);
+ c = intToY(c);
+ if (c < y)
+ {
+ y = c;
+ vertex1p = vertex2p;
+ }
+ vertex2p++;
+ if (c > maxy)
+ maxy = c;
+ if (c == x1)
+ continue;
+ if (dx1 > 0)
+ {
+ if (x2 < 0)
+ x2 = c;
+ else
+ dx2 = dx1 = (c - x1) >> 31;
+ }
+ else
+ if ((c - x1) >> 31 != dx1)
+ {
+ dx1 = ~dx1;
+ yFlip++;
+ }
+ x1 = c;
+ }
+ x1 = (x2 - c) >> 31;
+ if (x1 != dx1)
+ yFlip++;
+ if (x1 != dx2)
+ yFlip++;
+ if (yFlip != 2)
+ clip = 0x8000;
+ }
+ if (y == maxy)
+ return;
+
+ if (clip & 0x80008000)
+ {
+ miFillPolygon (pDrawable, pGC, shape, mode, vertex2p - (int *) ptsIn, ptsIn);
+ return;
+ }
+
+#define AddrYPlus(a,y) (CfbBits *) (((unsigned char *) (a)) + (y) * nwidth)
+
+ cfbGetTypedWidthAndPointer(pDrawable, nwidth, addrl, unsigned char, CfbBits);
+ addrl = AddrYPlus(addrl,y + pDrawable->y);
+ origin = intToX(origin);
+ vertex2p = vertex1p;
+ vertex2 = vertex1 = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+#define Setup(c,x,vertex,dx,dy,e,sign,step) {\
+ x = intToX(vertex); \
+ if ((dy = intToY(c) - y)) { \
+ dx = intToX(c) - x; \
+ step = 0; \
+ if (dx >= 0) \
+ { \
+ e = 0; \
+ sign = 1; \
+ if (dx >= dy) {\
+ step = dx / dy; \
+ dx = dx % dy; \
+ } \
+ } \
+ else \
+ { \
+ e = 1 - dy; \
+ sign = -1; \
+ dx = -dx; \
+ if (dx >= dy) { \
+ step = - (dx / dy); \
+ dx = dx % dy; \
+ } \
+ } \
+ } \
+ x += origin; \
+ vertex = c; \
+}
+
+#define Step(x,dx,dy,e,sign,step) {\
+ x += step; \
+ if ((e += dx) > 0) \
+ { \
+ x += sign; \
+ e -= dy; \
+ } \
+}
+ for (;;)
+ {
+ if (y == intToY(vertex1))
+ {
+ do
+ {
+ if (vertex1p == (int *) ptsIn)
+ vertex1p = endp;
+ c = *--vertex1p;
+ Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1)
+ } while (y >= intToY(vertex1));
+ h = dy1;
+ }
+ else
+ {
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ h = intToY(vertex1) - y;
+ }
+ if (y == intToY(vertex2))
+ {
+ do
+ {
+ c = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+ Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2)
+ } while (y >= intToY(vertex2));
+ if (dy2 < h)
+ h = dy2;
+ }
+ else
+ {
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ if ((c = (intToY(vertex2) - y)) < h)
+ h = c;
+ }
+ /* fill spans for this segment */
+ y += h;
+ for (;;)
+ {
+ l = x1;
+#if PSZ != 24 && PPW > 1
+ r = x2;
+#endif
+ nmiddle = x2 - x1;
+ if (nmiddle < 0)
+ {
+ nmiddle = -nmiddle;
+ l = x2;
+#if PSZ != 24 && PPW > 1
+ r = x1;
+#endif
+ }
+#if PPW > 1
+ c = l & PIM;
+ l -= c;
+#endif
+
+#if PGSZ == 32
+#define LWRD_SHIFT 2
+#else /* PGSZ == 64 */
+#define LWRD_SHIFT 3
+#endif /* PGSZ */
+
+#if PSZ == 24
+ addr = (CfbBits *)((char *)addrl + ((l * 3) & ~0x03));
+ if (nmiddle <= 1){
+ if (nmiddle)
+ RROP_SOLID24(addr, l);
+ } else {
+ maskbits(l, nmiddle, startmask, endmask, nmiddle);
+ pidx = l & 3;
+ if (startmask){
+ RROP_SOLID_MASK(addr, startmask, pidx-1);
+ addr++;
+ if (pidx == 3)
+ pidx = 0;
+ }
+ while (--nmiddle >= 0){
+ RROP_SOLID(addr, pidx);
+ addr++;
+ if (++pidx == 3)
+ pidx = 0;
+ }
+ if (endmask)
+ RROP_SOLID_MASK(addr, endmask, pidx);
+ }
+#else /* PSZ == 24 */
+#if PWSH > LWRD_SHIFT
+ l = l >> (PWSH - LWRD_SHIFT);
+#endif
+#if PWSH < LWRD_SHIFT
+ l = l << (LWRD_SHIFT - PWSH);
+#endif
+ addr = (CfbBits *) (((char *) addrl) + l);
+#if PPW > 1
+ if (c + nmiddle < PPW)
+ {
+ mask = SCRRIGHT (bits,c) ^ SCRRIGHT (bits,c+nmiddle);
+ RROP_SOLID_MASK(addr,mask);
+ }
+ else
+ {
+ if (c)
+ {
+ mask = SCRRIGHT(bits, c);
+ RROP_SOLID_MASK(addr,mask);
+ nmiddle += c - PPW;
+ addr++;
+ }
+#endif
+ nmiddle >>= PWSH;
+ while (--nmiddle >= 0) {
+ RROP_SOLID(addr); addr++;
+ }
+#if PPW > 1
+ if ((mask = ~SCRRIGHT(bits, r & PIM)))
+ RROP_SOLID_MASK(addr,mask);
+ }
+#endif
+#endif /* PSZ == 24 */
+ if (!--h)
+ break;
+ addrl = AddrYPlus (addrl, 1);
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ }
+ if (y == maxy)
+ break;
+ addrl = AddrYPlus (addrl, 1);
+ }
+ RROP_UNDECLARE
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbpntwin.c b/nx-X11/programs/Xserver/cfb/cfbpntwin.c
new file mode 100644
index 000000000..01b948361
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbpntwin.c
@@ -0,0 +1,771 @@
+/* $XdotOrg: xc/programs/Xserver/cfb/cfbpntwin.c,v 1.5 2005/07/03 07:01:15 daniels Exp $ */
+/* $Xorg: cfbpntwin.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/cfb/cfbpntwin.c,v 3.7tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "windowstr.h"
+#include "regionstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "mi.h"
+
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+
+void
+cfbPaintWindow(pWin, pRegion, what)
+ WindowPtr pWin;
+ RegionPtr pRegion;
+ int what;
+{
+ register cfbPrivWin *pPrivWin;
+ WindowPtr pBgWin;
+
+ pPrivWin = cfbGetWindowPrivate(pWin);
+
+
+ switch (what) {
+ case PW_BACKGROUND:
+ switch (pWin->backgroundState) {
+ case None:
+ break;
+ case ParentRelative:
+ do {
+ pWin = pWin->parent;
+ } while (pWin->backgroundState == ParentRelative);
+ (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
+ what);
+ break;
+ case BackgroundPixmap:
+ if (pPrivWin->fastBackground)
+ {
+ cfbFillBoxTile32 ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pPrivWin->pRotatedBackground);
+ }
+ else
+ {
+ int xorg = pWin->drawable.x;
+ int yorg = pWin->drawable.y;
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ int index = pWin->drawable.pScreen->myNum;
+ if(WindowTable[index] == pWin) {
+ xorg -= panoramiXdataPtr[index].x;
+ yorg -= panoramiXdataPtr[index].y;
+ }
+ }
+#endif
+ cfbFillBoxTileOdd ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->background.pixmap,
+ xorg, yorg);
+ }
+ break;
+ case BackgroundPixel:
+ cfbFillBoxSolid ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->background.pixel);
+ break;
+ }
+ break;
+ case PW_BORDER:
+ if (pWin->borderIsPixel)
+ {
+ cfbFillBoxSolid ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->border.pixel);
+ }
+ else if (pPrivWin->fastBorder)
+ {
+ cfbFillBoxTile32 ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pPrivWin->pRotatedBorder);
+ }
+ else
+ {
+ int xorg, yorg;
+
+ for (pBgWin = pWin;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+
+ xorg = pBgWin->drawable.x;
+ yorg = pBgWin->drawable.y;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ int index = pWin->drawable.pScreen->myNum;
+ if(WindowTable[index] == pBgWin) {
+ xorg -= panoramiXdataPtr[index].x;
+ yorg -= panoramiXdataPtr[index].y;
+ }
+ }
+#endif
+
+ cfbFillBoxTileOdd ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->border.pixmap,
+ xorg, yorg);
+ }
+ break;
+ }
+}
+
+/*
+ * Use the RROP macros in copy mode
+ */
+
+#define RROP GXcopy
+#include "cfbrrop.h"
+
+#ifdef RROP_UNROLL
+# define Expand(left,right,leftAdjust) {\
+ int part = nmiddle & RROP_UNROLL_MASK; \
+ int widthStep; \
+ widthStep = widthDst - nmiddle - leftAdjust; \
+ nmiddle >>= RROP_UNROLL_SHIFT; \
+ while (h--) { \
+ left \
+ pdst += part; \
+ switch (part) { \
+ RROP_UNROLL_CASE(pdst) \
+ } \
+ m = nmiddle; \
+ while (m) { \
+ pdst += RROP_UNROLL; \
+ RROP_UNROLL_LOOP(pdst) \
+ m--; \
+ } \
+ right \
+ pdst += widthStep; \
+ } \
+}
+
+#else
+# define Expand(left, right, leftAdjust) { \
+ int widthStep; \
+ widthStep = widthDst - nmiddle - leftAdjust; \
+ while (h--) { \
+ left \
+ m = nmiddle; \
+ while (m--) {\
+ RROP_SOLID(pdst); \
+ pdst++; \
+ } \
+ right \
+ pdst += widthStep; \
+ } \
+}
+#endif
+
+void
+cfbFillBoxSolid (pDrawable, nBox, pBox, pixel)
+ DrawablePtr pDrawable;
+ int nBox;
+ BoxPtr pBox;
+ unsigned long pixel;
+{
+ CfbBits *pdstBase;
+ int widthDst;
+ register int h;
+ register CfbBits *pdst;
+ int nmiddle;
+ int w;
+#if PSZ == 24
+ int leftIndex, rightIndex;
+ CfbBits piQxelArray[3], *pdstULC; /*upper left corner*/
+
+ piQxelArray[0] = (pixel&0xFFFFFF) | ((pixel&0xFF)<<24);
+ piQxelArray[1] = ((pixel&0xFFFF00)>>8) | ((pixel&0xFFFF)<<16);
+ piQxelArray[2] = ((pixel&0xFFFFFF)<<8) | ((pixel&0xFF0000)>>16);
+#else
+ register CfbBits rrop_xor;
+ register CfbBits leftMask, rightMask;
+ register int m;
+#endif
+
+ cfbGetLongWidthAndPointer(pDrawable, widthDst, pdstBase);
+
+#if PSZ != 24
+ rrop_xor = PFILL(pixel);
+#endif
+ for (; nBox; nBox--, pBox++)
+ {
+ pdst = pdstBase + pBox->y1 * widthDst;
+ h = pBox->y2 - pBox->y1;
+ w = pBox->x2 - pBox->x1;
+#if PSZ == 8
+ if (w == 1)
+ {
+ register char *pdstb = ((char *) pdst) + pBox->x1;
+ int incr = widthDst * PGSZB;
+
+ while (h--)
+ {
+ *pdstb = rrop_xor;
+ pdstb += incr;
+ }
+ }
+ else
+ {
+#endif
+#if PSZ == 24
+/* _Box has x1, y1, x2, y2*/
+ leftIndex = pBox->x1 & 3;
+ rightIndex = ((leftIndex+w)<5)?0:(pBox->x2 &3);
+ nmiddle = w - rightIndex;
+ if(leftIndex){
+ nmiddle -= (4 - leftIndex);
+ }
+ nmiddle >>= 2;
+ if(nmiddle < 0)
+ nmiddle = 0;
+
+ pdst = pdstBase + pBox->y1 * widthDst + ((pBox->x1*3) >> 2);
+
+ switch(leftIndex+w){
+ case 4:
+ switch(leftIndex){
+ case 0:
+ while(h--){
+ *pdst++ = piQxelArray[0];
+ *pdst++ = piQxelArray[1];
+ *pdst = piQxelArray[2];
+ pdst -=2;
+ pdst += widthDst;
+ }
+ break;
+ case 1:
+ while(h--){
+ *pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
+ pdst++;
+ *pdst++ = piQxelArray[1];
+ *pdst = piQxelArray[2];
+ pdst -=2;
+ pdst += widthDst;
+ }
+ break;
+ case 2:
+ while(h--){
+ *pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
+ pdst++;
+ *pdst-- = piQxelArray[2];
+ pdst += widthDst;
+ }
+ break;
+ case 3:
+ while(h--){
+ *pdst = ((*pdst) & 0xFF) | (piQxelArray[2] & 0xFFFFFF00);
+ pdst += widthDst;
+ }
+ break;
+ }
+ break;
+ case 3:
+ switch(leftIndex){
+ case 0:
+ while(h--){
+ *pdst++ = piQxelArray[0];
+ *pdst++ = piQxelArray[1];
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
+ pdst--;
+ pdst--;
+ pdst += widthDst;
+ }
+ break;
+ case 1:
+ while(h--){
+ *pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
+ pdst++;
+ *pdst++ = piQxelArray[1];
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
+ pdst--;
+ pdst--;
+ pdst += widthDst;
+ }
+ break;
+ case 2:
+ while(h--){
+ *pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
+ pdst++;
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
+ pdst--;
+ pdst += widthDst;
+ }
+ break;
+ }
+ break;
+ case 2:
+ while(h--){
+ if(leftIndex){
+ *pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
+ pdst++;
+ }
+ else{
+ *pdst++ = piQxelArray[0];
+ }
+ *pdst = ((*pdst) & 0xFFFF0000) | (piQxelArray[1] & 0xFFFF);
+ pdst--;
+ pdst += widthDst;
+ }
+ break;
+ case 1: /*only if leftIndex = 0 and w = 1*/
+ while(h--){
+ *pdst = ((*pdst) & 0xFF000000) | (piQxelArray[0] & 0xFFFFFF);
+ pdst += widthDst;
+ }
+ break;
+ case 0: /*never*/
+ break;
+ default:
+ {
+ w = nmiddle;
+ pdstULC = pdst;
+/* maskbits (pBox->x1, w, leftMask, rightMask, nmiddle);*/
+ while(h--){
+ nmiddle = w;
+ pdst = pdstULC;
+ switch(leftIndex){
+ case 0:
+ break;
+ case 1:
+ *pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
+ pdst++;
+ *pdst++ = piQxelArray[1];
+ *pdst++ = piQxelArray[2];
+ break;
+ case 2:
+ *pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
+ pdst++;
+ *pdst++ = piQxelArray[2];
+ break;
+ case 3:
+ *pdst = ((*pdst) & 0xFF) | (piQxelArray[2] & 0xFFFFFF00);
+ pdst++;
+ break;
+ }
+ while(nmiddle--){
+ *pdst++ = piQxelArray[0];
+ *pdst++ = piQxelArray[1];
+ *pdst++ = piQxelArray[2];
+ }
+ switch(rightIndex){
+ case 0:
+ break;
+ case 1:
+ *pdst = ((*pdst) & 0xFF000000) | (piQxelArray[0] & 0xFFFFFF);
+ break;
+ case 2:
+ *pdst++ = piQxelArray[0];
+ *pdst = ((*pdst) & 0xFFFF0000) | (piQxelArray[1] & 0xFFFF);
+ break;
+ case 3:
+ *pdst++ = piQxelArray[0];
+ *pdst++ = piQxelArray[1];
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
+ break;
+ }
+ pdstULC += widthDst;
+ }
+
+ }
+ }
+#else
+ pdst += (pBox->x1 >> PWSH);
+ if ((pBox->x1 & PIM) + w <= PPW)
+ {
+ maskpartialbits(pBox->x1, w, leftMask);
+ while (h--) {
+ *pdst = (*pdst & ~leftMask) | (rrop_xor & leftMask);
+ pdst += widthDst;
+ }
+ }
+ else
+ {
+ maskbits (pBox->x1, w, leftMask, rightMask, nmiddle);
+ if (leftMask)
+ {
+ if (rightMask)
+ {
+ Expand (RROP_SOLID_MASK (pdst, leftMask); pdst++; ,
+ RROP_SOLID_MASK (pdst, rightMask); ,
+ 1)
+ }
+ else
+ {
+ Expand (RROP_SOLID_MASK (pdst, leftMask); pdst++;,
+ ;,
+ 1)
+ }
+ }
+ else
+ {
+ if (rightMask)
+ {
+ Expand (;,
+ RROP_SOLID_MASK (pdst, rightMask);,
+ 0)
+ }
+ else
+ {
+ Expand (;,
+ ;,
+ 0)
+ }
+ }
+ }
+#endif
+#if PSZ == 8
+ }
+#endif
+ }
+}
+
+void
+cfbFillBoxTile32 (pDrawable, nBox, pBox, tile)
+ DrawablePtr pDrawable;
+ int nBox; /* number of boxes to fill */
+ BoxPtr pBox; /* pointer to list of boxes to fill */
+ PixmapPtr tile; /* rotated, expanded tile */
+{
+ register CfbBits *pdst;
+ CfbBits *psrc;
+ int tileHeight;
+
+ int widthDst;
+ int w;
+ int h;
+ int nmiddle;
+ int y;
+ int srcy;
+
+ CfbBits *pdstBase;
+#if PSZ == 24
+ int leftIndex, rightIndex;
+ CfbBits piQxelArray[3], *pdstULC;
+#else
+ register CfbBits rrop_xor;
+ register CfbBits leftMask;
+ register CfbBits rightMask;
+ register int m;
+#endif
+
+ tileHeight = tile->drawable.height;
+ psrc = (CfbBits *)tile->devPrivate.ptr;
+
+ cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase);
+
+ while (nBox--)
+ {
+#if PSZ == 24
+ w = pBox->x2 - pBox->x1;
+ h = pBox->y2 - pBox->y1;
+ y = pBox->y1;
+ leftIndex = pBox->x1 & 3;
+/* rightIndex = ((leftIndex+w)<5)?0:pBox->x2 &3;*/
+ rightIndex = pBox->x2 &3;
+ nmiddle = w - rightIndex;
+ if(leftIndex){
+ nmiddle -= (4 - leftIndex);
+ }
+ nmiddle >>= 2;
+ if(nmiddle < 0)
+ nmiddle = 0;
+
+ pdst = pdstBase + ((pBox->x1 *3)>> 2) + pBox->y1 * widthDst;
+ srcy = y % tileHeight;
+
+#define StepTile piQxelArray[0] = (psrc[srcy] & 0xFFFFFF) | ((psrc[srcy] & 0xFF)<<24); \
+ piQxelArray[1] = (psrc[srcy] & 0xFFFF00) | ((psrc[srcy] & 0xFFFF)<<16); \
+ piQxelArray[2] = ((psrc[srcy] & 0xFF0000)>>16) | \
+ ((psrc[srcy] & 0xFFFFFF)<<8); \
+ /*rrop_xor = psrc[srcy];*/ \
+ ++srcy; \
+ if (srcy == tileHeight) \
+ srcy = 0;
+
+ switch(leftIndex+w){
+ case 4:
+ switch(leftIndex){
+ case 0:
+ while(h--){
+ StepTile
+ *pdst++ = piQxelArray[0];
+ *pdst++ = piQxelArray[1];
+ *pdst = piQxelArray[2];
+ pdst-=2;
+ pdst += widthDst;
+ }
+ break;
+ case 1:
+ while(h--){
+ StepTile
+ *pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
+ pdst++;
+ *pdst++ = piQxelArray[1];
+ *pdst = piQxelArray[2];
+ pdst-=2;
+ pdst += widthDst;
+ }
+ break;
+ case 2:
+ while(h--){
+ StepTile
+ *pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
+ pdst++;
+ *pdst-- = piQxelArray[2];
+ pdst += widthDst;
+ }
+ break;
+ case 3:
+ while(h--){
+ StepTile
+ *pdst = ((*pdst) & 0xFF) | (piQxelArray[2] & 0xFFFFFF00);
+ pdst += widthDst;
+ }
+ break;
+ }
+ break;
+ case 3:
+ switch(leftIndex){
+ case 0:
+ while(h--){
+ StepTile
+ *pdst++ = piQxelArray[0];
+ *pdst++ = piQxelArray[1];
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
+ pdst--;
+ pdst--;
+ pdst += widthDst;
+ }
+ break;
+ case 1:
+ while(h--){
+ StepTile
+ *pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
+ pdst++;
+ *pdst++ = piQxelArray[1];
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
+ pdst--;
+ pdst--;
+ pdst += widthDst;
+ }
+ break;
+ case 2:
+ while(h--){
+ StepTile
+ *pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
+ pdst++;
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
+ pdst--;
+ pdst += widthDst;
+ }
+ break;
+ }
+ break;
+ case 2:
+ while(h--){
+ StepTile
+ if(leftIndex){
+ *pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
+ pdst++;
+ }
+ else{
+ *pdst++ = piQxelArray[0];
+ }
+ *pdst = ((*pdst) & 0xFFFF0000) | (piQxelArray[1] & 0xFFFF);
+ pdst--;
+ pdst += widthDst;
+ }
+ break;
+ case 1: /*only if leftIndex = 0 and w = 1*/
+ while(h--){
+ StepTile
+ *pdst = ((*pdst) & 0xFF000000) | (piQxelArray[0] & 0xFFFFFF);
+ pdst += widthDst;
+ }
+ break;
+ case 0: /*never*/
+ break;
+ default:
+ {
+ w = nmiddle;
+ pdstULC = pdst;
+
+ while(h--){
+ StepTile
+ nmiddle = w;
+ pdst = pdstULC;
+ switch(leftIndex){
+ case 0:
+ break;
+ case 1:
+ *pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
+ pdst++;
+ *pdst++ = piQxelArray[1];
+ *pdst++ = piQxelArray[2];
+ break;
+ case 2:
+ *pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
+ pdst++;
+ *pdst++ = piQxelArray[2];
+ break;
+ case 3:
+ *pdst = ((*pdst) & 0xFF) | (piQxelArray[2] & 0xFFFFFF00);
+ pdst++;
+ break;
+ }
+ while(nmiddle--){
+ *pdst++ = piQxelArray[0];
+ *pdst++ = piQxelArray[1];
+ *pdst++ = piQxelArray[2];
+ }
+ switch(rightIndex){
+ case 0:
+ break;
+ case 1:
+ *pdst = ((*pdst) & 0xFF000000) | (piQxelArray[0] & 0xFFFFFF);
+ break;
+ case 2:
+ *pdst++ = piQxelArray[0];
+ *pdst = ((*pdst) & 0xFFFF0000) | (piQxelArray[1] & 0xFFFF);
+ break;
+ case 3:
+ *pdst++ = piQxelArray[0];
+ *pdst++ = piQxelArray[1];
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
+ break;
+ }
+ pdstULC += widthDst;
+ }
+ }
+ }
+#else
+ w = pBox->x2 - pBox->x1;
+ h = pBox->y2 - pBox->y1;
+ y = pBox->y1;
+ pdst = pdstBase + (pBox->y1 * widthDst) + (pBox->x1 >> PWSH);
+ srcy = y % tileHeight;
+
+#define StepTile rrop_xor = psrc[srcy]; \
+ ++srcy; \
+ if (srcy == tileHeight) \
+ srcy = 0;
+
+ if ( ((pBox->x1 & PIM) + w) < PPW)
+ {
+ maskpartialbits(pBox->x1, w, leftMask);
+ rightMask = ~leftMask;
+ while (h--)
+ {
+ StepTile
+ *pdst = (*pdst & rightMask) | (rrop_xor & leftMask);
+ pdst += widthDst;
+ }
+ }
+ else
+ {
+ maskbits(pBox->x1, w, leftMask, rightMask, nmiddle);
+
+ if (leftMask)
+ {
+ if (rightMask)
+ {
+ Expand (StepTile
+ RROP_SOLID_MASK(pdst, leftMask); pdst++;,
+ RROP_SOLID_MASK(pdst, rightMask);,
+ 1)
+ }
+ else
+ {
+ Expand (StepTile
+ RROP_SOLID_MASK(pdst, leftMask); pdst++;,
+ ;,
+ 1)
+ }
+ }
+ else
+ {
+ if (rightMask)
+ {
+ Expand (StepTile
+ ,
+ RROP_SOLID_MASK(pdst, rightMask);,
+ 0)
+ }
+ else
+ {
+ Expand (StepTile
+ ,
+ ;,
+ 0)
+ }
+ }
+ }
+#endif
+ pBox++;
+ }
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbpolypnt.c b/nx-X11/programs/Xserver/cfb/cfbpolypnt.c
new file mode 100644
index 000000000..59ef0cf89
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbpolypnt.c
@@ -0,0 +1,204 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfbpolypnt.c,v 3.5 2001/10/28 03:33:01 tsi Exp $ */
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+********************************************************/
+
+/* $Xorg: cfbpolypnt.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+
+#define isClipped(c,ul,lr) ((((c) - (ul)) | ((lr) - (c))) & ClipMask)
+
+/* WARNING: pbox contains two shorts. This code assumes they are packed
+ * and can be referenced together as an INT32.
+ */
+
+#define PointLoop(fill) { \
+ for (nbox = REGION_NUM_RECTS(cclip), pbox = REGION_RECTS(cclip); \
+ --nbox >= 0; \
+ pbox++) \
+ { \
+ c1 = *((INT32 *) &pbox->x1) - off; \
+ c2 = *((INT32 *) &pbox->x2) - off - 0x00010001; \
+ for (ppt = (INT32 *) pptInit, i = npt; --i >= 0;) \
+ { \
+ pt = *ppt++; \
+ if (!isClipped(pt,c1,c2)) { \
+ fill \
+ } \
+ } \
+ } \
+}
+
+#if PSZ == 24
+# include "cfbrrop24.h"
+#endif
+
+void
+cfbPolyPoint(pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode;
+ int npt;
+ xPoint *pptInit;
+{
+ register INT32 pt;
+ register INT32 c1, c2;
+ register CARD32 ClipMask = 0x80008000;
+ register CfbBits xor;
+#ifdef PIXEL_ADDR
+ register PixelType *addrp;
+ register int npwidth;
+#if PSZ != 24
+ PixelType *addrpt;
+#endif
+#else
+ register CfbBits *addrl;
+ register int nlwidth;
+ register int xoffset;
+ CfbBits *addrlt;
+#endif
+#if PSZ == 24
+ RROP_DECLARE
+ register int xtmp;
+ register PixelType *p;
+#endif
+ register INT32 *ppt;
+ RegionPtr cclip;
+ int nbox;
+ register int i;
+ register BoxPtr pbox;
+ CfbBits and;
+ int rop = pGC->alu;
+ int off;
+ cfbPrivGCPtr devPriv;
+ xPoint *pptPrev;
+
+ devPriv =cfbGetGCPrivate(pGC);
+ rop = devPriv->rop;
+ if (rop == GXnoop)
+ return;
+ cclip = pGC->pCompositeClip;
+ xor = devPriv->xor;
+ if ((mode == CoordModePrevious) && (npt > 1))
+ {
+ for (pptPrev = pptInit + 1, i = npt - 1; --i >= 0; pptPrev++)
+ {
+ pptPrev->x += (pptPrev-1)->x;
+ pptPrev->y += (pptPrev-1)->y;
+ }
+ }
+ off = *((int *) &pDrawable->x);
+ off -= (off & 0x8000) << 1;
+#ifdef PIXEL_ADDR
+ cfbGetPixelWidthAndPointer(pDrawable, npwidth, addrp);
+#if PSZ == 24
+ addrp = addrp + pDrawable->y * npwidth;
+#else
+ addrp = addrp + pDrawable->y * npwidth + pDrawable->x;
+#endif
+ if (rop == GXcopy)
+ {
+#if PSZ == 24
+ RROP_COPY_SETUP(xor)
+#endif
+ if (!(npwidth & (npwidth - 1)))
+ {
+ npwidth = ffs(npwidth) - 1;
+#if PSZ == 24
+ PointLoop(
+ xtmp = pDrawable->x + intToX(pt);
+ p = addrp + (intToY(pt) << npwidth) + ((xtmp * 3) >>2);
+ RROP_SOLID24_COPY(p, xtmp))
+#else
+ PointLoop(*(addrp + (intToY(pt) << npwidth) + intToX(pt)) = xor;)
+#endif
+ }
+#ifdef sun
+ else if (npwidth == 1152)
+ {
+ register int y;
+ PointLoop(y = intToY(pt); *(addrp + (y << 10) + (y << 7) + intToX(pt)) = xor;)
+ }
+#endif
+ else
+ {
+#if PSZ == 24
+ PointLoop(
+ xtmp = pDrawable->x + intToX(pt);
+ p = addrp + intToY(pt) * npwidth + ((xtmp * 3) >> 2);
+ RROP_SOLID24_COPY(p, xtmp))
+#else
+ PointLoop(*(addrp + intToY(pt) * npwidth + intToX(pt)) = xor;)
+#endif
+ }
+ }
+ else
+ {
+ and = devPriv->and;
+#if PSZ == 24
+ RROP_SET_SETUP(xor, and)
+ PointLoop(
+ xtmp = pDrawable->x + intToX(pt);
+ p = addrp + intToY(pt) * npwidth + ((xtmp * 3) >> 2);
+ RROP_SOLID24_SET(p, xtmp))
+#else
+ PointLoop( addrpt = addrp + intToY(pt) * npwidth + intToX(pt);
+ *addrpt = DoRRop (*addrpt, and, xor);)
+#endif
+ }
+#else /* !PIXEL_ADDR */
+ cfbGetLongWidthAndPointer(pDrawable, nlwidth, addrl);
+ addrl = addrl + pDrawable->y * nlwidth + (pDrawable->x >> PWSH);
+ xoffset = pDrawable->x & PIM;
+ and = devPriv->and;
+#if PSZ == 24
+ PointLoop( addrlt = addrl + intToY(pt) * nlwidth
+ + ((intToX(pt) + xoffset) >> PWSH);
+ *addrlt = DoRRop (*addrlt,
+ and | ~cfbmask[(intToX(pt) + xoffset) & PIM],
+ xor & cfbmask[(intToX(pt) + xoffset) & PIM]);
+ )
+#else
+ PointLoop( addrlt = addrl + intToY(pt) * nlwidth
+ + ((intToX(pt) + xoffset) >> PWSH);
+ *addrlt = DoRRop (*addrlt,
+ and | ~cfbmask[((intToX(pt) + xoffset) & 3)<<1],
+ xor & cfbmask[((intToX(pt) + xoffset) & 3)<<1]);
+ )
+#endif
+#endif /* PIXEL_ADDR */
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbpush8.c b/nx-X11/programs/Xserver/cfb/cfbpush8.c
new file mode 100644
index 000000000..3492c8e25
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbpush8.c
@@ -0,0 +1,186 @@
+/*
+ * Push Pixels for 8 bit displays.
+ */
+
+/* $XFree86: xc/programs/Xserver/cfb/cfbpush8.c,v 1.5 2001/01/17 22:36:36 dawes Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+/* $Xorg: cfbpush8.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#if PSZ == 8
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "cfb8bit.h"
+#define MFB_CONSTS_ONLY
+#include "maskbits.h"
+
+void
+cfbPushPixels8 (pGC, pBitmap, pDrawable, dx, dy, xOrg, yOrg)
+ GCPtr pGC;
+ PixmapPtr pBitmap;
+ DrawablePtr pDrawable;
+ int dx, dy, xOrg, yOrg;
+{
+ register CfbBits *src, *dst;
+ register CfbBits pixel;
+ register CfbBits c, bits;
+ CfbBits *pdstLine, *psrcLine;
+ CfbBits *pdstBase;
+ int srcWidth;
+ int dstWidth;
+ int xoff;
+ int nBitmapLongs, nPixmapLongs;
+ int nBitmapTmp, nPixmapTmp;
+ CfbBits rightMask;
+ BoxRec bbox;
+ cfbPrivGCPtr devPriv;
+
+ bbox.x1 = xOrg;
+ bbox.y1 = yOrg;
+ bbox.x2 = bbox.x1 + dx;
+ bbox.y2 = bbox.y1 + dy;
+ devPriv = cfbGetGCPrivate(pGC);
+
+ switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox))
+ {
+ case rgnPART:
+ mfbPushPixels(pGC, pBitmap, pDrawable, dx, dy, xOrg, yOrg);
+ case rgnOUT:
+ return;
+ }
+
+ cfbGetLongWidthAndPointer (pDrawable, dstWidth, pdstBase)
+
+ psrcLine = (CfbBits *) pBitmap->devPrivate.ptr;
+ srcWidth = (int) pBitmap->devKind >> PWSH;
+
+ pixel = devPriv->xor;
+ xoff = xOrg & PIM;
+ nBitmapLongs = (dx + xoff) >> MFB_PWSH;
+ nPixmapLongs = (dx + PGSZB + xoff) >> PWSH;
+
+ rightMask = ~cfb8BitLenMasks[((dx + xoff) & MFB_PIM)];
+
+ pdstLine = pdstBase + (yOrg * dstWidth) + (xOrg >> PWSH);
+
+ while (dy--)
+ {
+ c = 0;
+ nPixmapTmp = nPixmapLongs;
+ nBitmapTmp = nBitmapLongs;
+ src = psrcLine;
+ dst = pdstLine;
+ while (nBitmapTmp--)
+ {
+ bits = *src++;
+ c |= BitRight (bits, xoff);
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst++;
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst++;
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst++;
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst++;
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst++;
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst++;
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst++;
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst++;
+ nPixmapTmp -= 8;
+ c = 0;
+ if (xoff)
+ c = BitLeft (bits, PGSZ - xoff);
+ }
+ if (BitLeft (rightMask, xoff))
+ c |= BitRight (*src, xoff);
+ c &= rightMask;
+ switch (nPixmapTmp) {
+ case 8:
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst++;
+ case 7:
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst++;
+ case 6:
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst++;
+ case 5:
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst++;
+ case 4:
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst++;
+ case 3:
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst++;
+ case 2:
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst++;
+ case 1:
+ WriteBitGroup(dst, pixel, GetBitGroup(c));
+ NextBitGroup(c);
+ dst++;
+ case 0:
+ break;
+ }
+ pdstLine += dstWidth;
+ psrcLine += srcWidth;
+ }
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/cfb/cfbrctstp8.c b/nx-X11/programs/Xserver/cfb/cfbrctstp8.c
new file mode 100644
index 000000000..9f753cdd7
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbrctstp8.c
@@ -0,0 +1,595 @@
+/*
+ * Fill 32 bit stippled rectangles for 8 bit frame buffers
+ */
+/* $XFree86: xc/programs/Xserver/cfb/cfbrctstp8.c,v 3.5 2001/10/28 03:33:01 tsi Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Author: Keith Packard, MIT X Consortium
+
+*/
+
+/* $Xorg: cfbrctstp8.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#if PSZ == 8
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "cfb8bit.h"
+
+#define MFB_CONSTS_ONLY
+#include "maskbits.h"
+
+void
+cfb8FillRectOpaqueStippled32 (pDrawable, pGC, nBox, pBox)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nBox; /* number of boxes to fill */
+ register BoxPtr pBox; /* pointer to list of boxes to fill */
+{
+ CfbBits *src;
+ int stippleHeight;
+
+ int nlwDst; /* width in longwords of the dest pixmap */
+ int w; /* width of current box */
+ register int h; /* height of current box */
+ CfbBits startmask;
+ CfbBits endmask; /* masks for reggedy bits at either end of line */
+ int nlwMiddle; /* number of longwords between sides of boxes */
+ register int nlw; /* loop version of nlwMiddle */
+ CfbBits *dstLine;
+ register CfbBits *dst; /* pointer to bits we're writing */
+ CfbBits *dstTmp;
+ int y; /* current scan line */
+
+ CfbBits *pbits;/* pointer to start of pixmap */
+ register CfbBits bits; /* bits from stipple */
+ int rot;
+ register CfbBits xor;
+ PixmapPtr stipple;
+ int wEnd;
+
+ stipple = pGC->pRotatedPixmap;
+
+ cfb8CheckOpaqueStipple(pGC->alu, pGC->fgPixel, pGC->bgPixel, pGC->planemask);
+
+ stippleHeight = stipple->drawable.height;
+ src = (CfbBits *)stipple->devPrivate.ptr;
+
+ cfbGetLongWidthAndPointer (pDrawable, nlwDst, pbits)
+
+ while (nBox--)
+ {
+ w = pBox->x2 - pBox->x1;
+ h = pBox->y2 - pBox->y1;
+ y = pBox->y1;
+ dstLine = pbits + (pBox->y1 * nlwDst) + ((pBox->x1 & ~PIM) >> PWSH);
+ if (((pBox->x1 & PIM) + w) <= PPW)
+ {
+ maskpartialbits(pBox->x1, w, startmask);
+ nlwMiddle = 0;
+ endmask = 0;
+ }
+ else
+ {
+ maskbits (pBox->x1, w, startmask, endmask, nlwMiddle);
+ }
+ rot = (pBox->x1 & ((PGSZ-1) & ~PIM));
+ pBox++;
+ y = y % stippleHeight;
+#if PPW == 4
+ if (cfb8StippleRRop == GXcopy)
+ {
+ if (w < PGSZ*2)
+ {
+ while (h--)
+ {
+ bits = src[y];
+ y++;
+ if (y == stippleHeight)
+ y = 0;
+ if (rot)
+ RotBitsLeft(bits,rot);
+ dst = dstLine;
+ dstLine += nlwDst;
+ if (startmask)
+ {
+ *dst = (*dst & ~startmask) |
+ (GetPixelGroup (bits) & startmask);
+ dst++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ nlw = nlwMiddle;
+ while (nlw--)
+ {
+ *dst++ = GetPixelGroup(bits);
+ RotBitsLeft (bits, PGSZB);
+ }
+ if (endmask)
+ {
+ *dst = (*dst & ~endmask) |
+ (GetPixelGroup (bits) & endmask);
+ }
+ }
+ }
+ else
+ {
+ wEnd = 7 - (nlwMiddle & 7);
+ nlwMiddle = (nlwMiddle >> 3) + 1;
+ while (h--)
+ {
+ bits = src[y];
+ y++;
+ if (y == stippleHeight)
+ y = 0;
+ if (rot != 0)
+ RotBitsLeft (bits, rot);
+ dstTmp = dstLine;
+ dstLine += nlwDst;
+ if (startmask)
+ {
+ *dstTmp = (*dstTmp & ~startmask) |
+ (GetPixelGroup (bits) & startmask);
+ dstTmp++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ w = 7 - wEnd;
+ while (w--)
+ {
+ nlw = nlwMiddle;
+ dst = dstTmp;
+ dstTmp++;
+ xor = GetPixelGroup (bits);
+ while (nlw--)
+ {
+ *dst = xor;
+ dst += 8;
+ }
+ NextBitGroup (bits);
+ }
+ nlwMiddle--;
+ w = wEnd + 1;
+ if (endmask)
+ {
+ dst = dstTmp + (nlwMiddle << 3);
+ *dst = (*dst & ~endmask) |
+ (GetPixelGroup(bits) & endmask);
+ }
+ while (w--)
+ {
+ nlw = nlwMiddle;
+ dst = dstTmp;
+ dstTmp++;
+ xor = GetPixelGroup (bits);
+ while (nlw--)
+ {
+ *dst = xor;
+ dst += 8;
+ }
+ NextBitGroup (bits);
+ }
+ nlwMiddle++;
+ }
+ }
+ }
+ else
+#endif /* PPW == 4 */
+ {
+ while (h--)
+ {
+ bits = src[y];
+ y++;
+ if (y == stippleHeight)
+ y = 0;
+ if (rot)
+ RotBitsLeft(bits,rot);
+ dst = dstLine;
+ dstLine += nlwDst;
+ if (startmask)
+ {
+ xor = GetBitGroup(bits);
+ *dst = MaskRRopPixels(*dst, xor, startmask);
+ dst++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ nlw = nlwMiddle;
+ while (nlw--)
+ {
+ RRopBitGroup(dst, GetBitGroup(bits));
+ dst++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ if (endmask)
+ {
+ xor = GetBitGroup(bits);
+ *dst = MaskRRopPixels(*dst, xor, endmask);
+ }
+ }
+ }
+ }
+}
+
+void
+cfb8FillRectTransparentStippled32 (pDrawable, pGC, nBox, pBox)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nBox; /* number of boxes to fill */
+ BoxPtr pBox; /* pointer to list of boxes to fill */
+{
+ int x, y, w, h;
+ int nlwMiddle, nlwDst;
+ CfbBits startmask, endmask;
+ register CfbBits *dst;
+ CfbBits *dstLine, *pbits, *dstTmp;
+ CfbBits *src;
+ register CfbBits xor;
+ register CfbBits bits, mask;
+ int rot;
+ int wEnd;
+ cfbPrivGCPtr devPriv;
+ PixmapPtr stipple;
+ int stippleHeight;
+ register int nlw;
+
+ devPriv = cfbGetGCPrivate(pGC);
+ stipple = pGC->pRotatedPixmap;
+ src = (CfbBits *)stipple->devPrivate.ptr;
+ stippleHeight = stipple->drawable.height;
+
+ cfb8CheckStipple (pGC->alu, pGC->fgPixel, pGC->planemask);
+
+ cfbGetLongWidthAndPointer (pDrawable, nlwDst, pbits)
+
+ while (nBox--)
+ {
+ x = pBox->x1;
+ w = pBox->x2 - x;
+ if (((x & PIM) + w) <= PPW)
+ {
+ maskpartialbits(x, w, startmask);
+ endmask = 0;
+ nlwMiddle = 0;
+ }
+ else
+ {
+ maskbits (x, w, startmask, endmask, nlwMiddle);
+ }
+ rot = (x & ((PGSZ-1) & ~PIM));
+ y = pBox->y1;
+ dstLine = pbits + (y * nlwDst) + (x >> PWSH);
+ h = pBox->y2 - y;
+ pBox++;
+ y %= stippleHeight;
+#if PPW == 4
+ if (cfb8StippleRRop == GXcopy)
+ {
+ xor = devPriv->xor;
+ if (w < PGSZ*2)
+ {
+ while (h--)
+ {
+ bits = src[y];
+ y++;
+ if (y == stippleHeight)
+ y = 0;
+ if (rot != 0)
+ RotBitsLeft (bits, rot);
+ dst = dstLine;
+ dstLine += nlwDst;
+ if (startmask)
+ {
+ mask = cfb8PixelMasks[GetBitGroup(bits)];
+ *dst = (*dst & ~(mask & startmask)) |
+ (xor & (mask & startmask));
+ dst++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ nlw = nlwMiddle;
+ while (nlw--)
+ {
+ WriteBitGroup (dst,xor,GetBitGroup(bits))
+ dst++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ if (endmask)
+ {
+ mask = cfb8PixelMasks[GetBitGroup(bits)];
+ *dst = (*dst & ~(mask & endmask)) |
+ (xor & (mask & endmask));
+ }
+ }
+ }
+ else
+ {
+ wEnd = 7 - (nlwMiddle & 7);
+ nlwMiddle = (nlwMiddle >> 3) + 1;
+ while (h--)
+ {
+ bits = src[y];
+ y++;
+ if (y == stippleHeight)
+ y = 0;
+ if (rot != 0)
+ RotBitsLeft (bits, rot);
+ dstTmp = dstLine;
+ dstLine += nlwDst;
+ if (startmask)
+ {
+ mask = cfb8PixelMasks[GetBitGroup(bits)];
+ *dstTmp = (*dstTmp & ~(mask & startmask)) |
+ (xor & (mask & startmask));
+ dstTmp++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ w = 7 - wEnd;
+ while (w--)
+ {
+ nlw = nlwMiddle;
+ dst = dstTmp;
+ dstTmp++;
+#if defined(__GNUC__) && defined(mc68020)
+ mask = cfb8PixelMasks[GetBitGroup(bits)];
+ xor = xor & mask;
+ mask = ~mask;
+ while (nlw--)
+ {
+ *dst = (*dst & mask) | xor;
+ dst += 8;
+ }
+ xor = devPriv->xor;
+#else
+#define SwitchBitsLoop(body) \
+ while (nlw--) \
+ { \
+ body \
+ dst += 8; \
+ }
+ SwitchBitGroup(dst, xor, GetBitGroup(bits));
+#undef SwitchBitsLoop
+#endif
+ NextBitGroup (bits);
+ }
+ nlwMiddle--;
+ w = wEnd + 1;
+ if (endmask)
+ {
+ mask = cfb8PixelMasks[GetBitGroup(bits)];
+ dst = dstTmp + (nlwMiddle << 3);
+ *dst = (*dst & ~(mask & endmask)) |
+ (xor & (mask & endmask));
+ }
+ while (w--)
+ {
+ nlw = nlwMiddle;
+ dst = dstTmp;
+ dstTmp++;
+#if defined(__GNUC__) && defined(mc68020)
+ mask = cfb8PixelMasks[GetBitGroup(bits)];
+ xor = xor & mask;
+ mask = ~mask;
+ while (nlw--)
+ {
+ *dst = (*dst & mask) | xor;
+ dst += 8;
+ }
+ xor = devPriv->xor;
+#else
+#define SwitchBitsLoop(body) \
+ while (nlw--) \
+ { \
+ body \
+ dst += 8; \
+ }
+ SwitchBitGroup(dst, xor, GetBitGroup(bits));
+#undef SwitchBitsLoop
+#endif
+ NextBitGroup (bits);
+ }
+ nlwMiddle++;
+ }
+ }
+ }
+ else
+#endif /* PPW == 4 */
+ {
+ while (h--)
+ {
+ bits = src[y];
+ y++;
+ if (y == stippleHeight)
+ y = 0;
+ if (rot != 0)
+ RotBitsLeft (bits, rot);
+ dst = dstLine;
+ dstLine += nlwDst;
+ if (startmask)
+ {
+ xor = GetBitGroup(bits);
+ *dst = MaskRRopPixels(*dst, xor, startmask);
+ dst++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ nlw = nlwMiddle;
+ while (nlw--)
+ {
+ RRopBitGroup(dst, GetBitGroup(bits));
+ dst++;
+ RotBitsLeft (bits, PGSZB);
+ }
+ if (endmask)
+ {
+ xor = GetBitGroup(bits);
+ *dst = MaskRRopPixels(*dst, xor, endmask);
+ }
+ }
+ }
+ }
+}
+
+
+void
+cfb8FillRectStippledUnnatural (pDrawable, pGC, nBox, pBox)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nBox;
+ register BoxPtr pBox;
+{
+ CfbBits *pdstBase; /* pointer to start of bitmap */
+ CfbBits *pdstLine; /* current destination line */
+ int nlwDst; /* width in longwords of bitmap */
+ PixmapPtr pStipple; /* pointer to stipple we want to fill with */
+ int nlwMiddle;
+ register int nlw;
+ int x, y, w, h, xrem, xSrc, ySrc;
+ int stwidth, stippleWidth;
+ int stippleHeight;
+ register CfbBits bits, inputBits;
+ register int partBitsLeft;
+ int nextPartBits;
+ int bitsLeft, bitsWhole;
+ register CfbBits *pdst; /* pointer to current word in bitmap */
+ CfbBits *srcTemp, *srcStart;
+ CfbBits *psrcBase;
+ CfbBits startmask, endmask;
+
+ if (pGC->fillStyle == FillStippled)
+ cfb8CheckStipple (pGC->alu, pGC->fgPixel, pGC->planemask);
+ else
+ cfb8CheckOpaqueStipple (pGC->alu, pGC->fgPixel, pGC->bgPixel, pGC->planemask);
+
+ if (cfb8StippleRRop == GXnoop)
+ return;
+
+ /*
+ * OK, so what's going on here? We have two Drawables:
+ *
+ * The Stipple:
+ * Depth = 1
+ * Width = stippleWidth
+ * Words per scanline = stwidth
+ * Pointer to pixels = pStipple->devPrivate.ptr
+ */
+
+ pStipple = pGC->stipple;
+
+ stwidth = pStipple->devKind >> PWSH;
+ stippleWidth = pStipple->drawable.width;
+ stippleHeight = pStipple->drawable.height;
+ psrcBase = (CfbBits *) pStipple->devPrivate.ptr;
+
+ /*
+ * The Target:
+ * Depth = PSZ
+ * Width = determined from *pwidth
+ * Words per scanline = nlwDst
+ * Pointer to pixels = addrlBase
+ */
+
+ xSrc = pDrawable->x;
+ ySrc = pDrawable->y;
+
+ cfbGetLongWidthAndPointer (pDrawable, nlwDst, pdstBase)
+
+ /* this replaces rotating the stipple. Instead we just adjust the offset
+ * at which we start grabbing bits from the stipple.
+ * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
+ * so that iline and xrem always stay within the stipple bounds.
+ */
+
+ xSrc += (pGC->patOrg.x % stippleWidth) - stippleWidth;
+ ySrc += (pGC->patOrg.y % stippleHeight) - stippleHeight;
+
+ bitsWhole = stippleWidth;
+
+ while (nBox--)
+ {
+ x = pBox->x1;
+ y = pBox->y1;
+ w = pBox->x2 - x;
+ h = pBox->y2 - y;
+ pBox++;
+ pdstLine = pdstBase + y * nlwDst + (x >> PWSH);
+ y = (y - ySrc) % stippleHeight;
+ srcStart = psrcBase + y * stwidth;
+ xrem = ((x & ~PIM) - xSrc) % stippleWidth;
+ if (((x & PIM) + w) < PPW)
+ {
+ maskpartialbits (x, w, startmask);
+ nlwMiddle = 0;
+ endmask = 0;
+ }
+ else
+ {
+ maskbits (x, w, startmask, endmask, nlwMiddle);
+ }
+ while (h--)
+ {
+ srcTemp = srcStart + (xrem >> MFB_PWSH);
+ bitsLeft = stippleWidth - (xrem & ~MFB_PIM);
+ NextUnnaturalStippleWord
+ NextSomeBits (inputBits, (xrem & MFB_PIM));
+ partBitsLeft -= (xrem & MFB_PIM);
+ NextUnnaturalStippleBits
+ nlw = nlwMiddle;
+ pdst = pdstLine;
+ if (startmask)
+ {
+ *pdst = MaskRRopPixels(*pdst,bits,startmask);
+ pdst++;
+ NextUnnaturalStippleBits
+ }
+ while (nlw--)
+ {
+ *pdst = RRopPixels(*pdst,bits);
+ pdst++;
+ NextUnnaturalStippleBits
+ }
+ if (endmask)
+ *pdst = MaskRRopPixels(*pdst,bits,endmask);
+ pdstLine += nlwDst;
+ y++;
+ srcStart += stwidth;
+ if (y == stippleHeight)
+ {
+ y = 0;
+ srcStart = psrcBase;
+ }
+ }
+ }
+}
+
+#endif /* PSZ == 8 */
diff --git a/nx-X11/programs/Xserver/cfb/cfbrrop.c b/nx-X11/programs/Xserver/cfb/cfbrrop.c
new file mode 100644
index 000000000..77487bc6a
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbrrop.c
@@ -0,0 +1,229 @@
+/*
+ * $Xorg: cfbrrop.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/programs/Xserver/cfb/cfbrrop.c,v 1.5 2001/10/28 03:33:02 tsi Exp $ */
+
+/* cfb reduced rasterop computations */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "cfb.h"
+#include "cfbmskbits.h"
+
+/* A description:
+ *
+ * There are four possible operations on each bit in the destination word,
+ *
+ * 1 2 3 4
+ *
+ * 0 0 0 1 1
+ * 1 0 1 0 1
+ *
+ * On examination of the reduced rop equation (dst = (dst & and) ^ xor),
+ * these four fall to reduced rops as follows:
+ *
+ * and 0 1 1 0
+ * xor 0 0 1 1
+ *
+ * or, (if 'and' is expensive) (dst = (dst | or) ^ xor)
+ *
+ * or 1 0 0 1
+ * xor 1 0 1 0
+ *
+ * The trouble with using this later equation is that trivial
+ * rasterop reduction is more difficult; some common rasterops
+ * use complicated expressions of xor/and instead of the simple
+ * ones while other common rasterops are not made any simpler:
+ *
+ * GXcopy: *dst = ~xor instead of *dst = xor
+ * GXand: *dst = *dst & ~or instead of *dst = *dst & and
+ * GXor: *dst = *dst | or instead of *dst = *dst | xor
+ * GXxor: *dst = *dst ^ xor instead of *dst = *dst ^ xor
+ *
+ * If you're really set on using this second mechanism, the changes
+ * are pretty simple.
+ *
+ * All that remains is to provide a mechanism for computing and/xor values
+ * based on the raster op and foreground value.
+ *
+ * The 16 rops fall as follows, with the associated reduced
+ * rop and/xor and or/xor values. The values in parenthesis following the
+ * reduced values gives an equation using the source value for
+ * the reduced value, and is one of {0, src, ~src, 1} as appropriate.
+ *
+ * clear and andReverse copy
+ * src 0 1 0 1 0 1 0 1
+ * dst 0 0 0 0 0 0 0 0 1 0 0 1
+ * 1 0 0 1 0 1 1 0 0 1 0 1
+ *
+ * and 0 0 (0) 0 1 (src) 0 1 (src) 0 0 (0)
+ * xor 0 0 (0) 0 0 (0) 0 1 (src) 0 1 (src)
+ *
+ * or 1 1 (1) 1 0 (~src) 1 0 (~src) 1 1 (1)
+ * xor 1 1 (1) 1 0 (~src) 1 1 (1) 1 0 (~src)
+ *
+ * andInverted noop xor or
+ * src 0 1 0 1 0 1 0 1
+ * dst 0 0 0 0 0 0 0 0 1 0 0 1
+ * 1 1 0 1 1 1 1 1 0 1 1 1
+ *
+ * and 1 0 (~src) 1 1 (1) 1 1 (1) 1 0 (~src)
+ * xor 0 0 (0) 0 0 (0) 0 1 (src) 0 1 (src)
+ *
+ * or 0 1 (src) 0 0 (0) 0 0 (0) 0 1 (src)
+ * xor 0 1 (src) 0 0 (0) 0 1 (src) 0 0 (0)
+ *
+ * nor equiv invert orReverse
+ * src 0 1 0 1 0 1 0 1
+ * dst 0 1 0 0 1 0 0 1 1 0 1 1
+ * 1 0 0 1 0 1 1 0 0 1 0 1
+ *
+ * and 1 0 (~src) 1 1 (1) 1 1 (1) 1 0 (~src)
+ * xor 1 0 (~src) 1 0 (~src) 1 1 (1) 1 1 (1)
+ *
+ * or 0 1 (src) 0 0 (0) 0 0 (0) 0 1 (src)
+ * xor 1 1 (1) 1 0 (~src) 1 1 (1) 1 0 (~src)
+ *
+ * copyInverted orInverted nand set
+ * src 0 1 0 1 0 1 0 1
+ * dst 0 1 0 0 1 0 0 1 1 0 1 1
+ * 1 1 0 1 1 1 1 1 0 1 1 1
+ *
+ * and 0 0 (0) 0 1 (src) 0 1 (src) 0 0 (0)
+ * xor 1 0 (~src) 1 0 (~src) 1 1 (1) 1 1 (1)
+ *
+ * or 1 1 (1) 1 0 (~src) 1 0 (~src) 1 1 (1)
+ * xor 0 1 (src) 0 0 (0) 0 1 (src) 0 0 (0)
+ */
+
+int
+cfbReduceRasterOp (rop, fg, pm, andp, xorp)
+ int rop;
+ CfbBits fg, pm;
+ CfbBits *andp, *xorp;
+{
+ CfbBits and, xor;
+ int rrop;
+
+ fg = PFILL (fg);
+ pm = PFILL (pm);
+ switch (rop)
+ {
+ case GXclear:
+ and = 0;
+ xor = 0;
+ break;
+ case GXand:
+ and = fg;
+ xor = 0;
+ break;
+ case GXandReverse:
+ and = fg;
+ xor = fg;
+ break;
+ case GXcopy:
+ and = 0;
+ xor = fg;
+ break;
+ case GXandInverted:
+ and = ~fg;
+ xor = 0;
+ break;
+ case GXnoop:
+ and = ~0;
+ xor = 0;
+ break;
+ case GXxor:
+ and = ~0;
+ xor = fg;
+ break;
+ case GXor:
+ and = ~fg;
+ xor = fg;
+ break;
+ case GXnor:
+ and = ~fg;
+ xor = ~fg;
+ break;
+ case GXequiv:
+ and = ~0;
+ xor = ~fg;
+ break;
+ case GXinvert:
+ and = ~0;
+ xor = ~0;
+ break;
+ case GXorReverse:
+ and = ~fg;
+ xor = ~0;
+ break;
+ case GXcopyInverted:
+ and = 0;
+ xor = ~fg;
+ break;
+ case GXorInverted:
+ and = fg;
+ xor = ~fg;
+ break;
+ case GXnand:
+ and = fg;
+ xor = ~0;
+ break;
+ case GXset:
+ and = 0;
+ xor = ~0;
+ break;
+ default:
+ and = xor = 0;
+ break;
+ }
+ and |= ~pm;
+ xor &= pm;
+ *andp = and;
+ *xorp = xor;
+ /* check for some special cases to reduce computation */
+ if (and == 0)
+ rrop = GXcopy;
+ /* nothing checks for GXnoop
+ else if (and == ~0 && xor == 0)
+ rrop = GXnoop;
+ */
+ else if (and == ~0)
+ rrop = GXxor;
+ else if (xor == 0)
+ rrop = GXand;
+ else if ( (and ^ xor) == ~0) /* fix XBUG 6541 */
+ rrop = GXor;
+ else
+ rrop = GXset; /* rop not reduced */
+ return rrop;
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbrrop.h b/nx-X11/programs/Xserver/cfb/cfbrrop.h
new file mode 100644
index 000000000..6deb7b899
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbrrop.h
@@ -0,0 +1,343 @@
+/*
+ * $Xorg: cfbrrop.h,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/programs/Xserver/cfb/cfbrrop.h,v 3.10tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef GXcopy
+#include <X11/X.h>
+#endif
+
+#define RROP_FETCH_GC(gc) \
+ RROP_FETCH_GCPRIV(((cfbPrivGCPtr)(gc)->devPrivates[cfbGCPrivateIndex].ptr))
+
+#ifndef RROP
+#define RROP GXset
+#endif
+
+#if RROP == GXcopy
+#if PSZ == 24
+#define RROP_DECLARE register CfbBits rrop_xor; \
+ CfbBits piQxelXor[3], spiQxelXor[8];
+#define RROP_FETCH_GCPRIV(devPriv) rrop_xor = (devPriv)->xor; \
+ spiQxelXor[0] = rrop_xor & 0xFFFFFF; \
+ spiQxelXor[2] = rrop_xor << 24; \
+ spiQxelXor[3] = (rrop_xor & 0xFFFF00)>> 8; \
+ spiQxelXor[4] = rrop_xor << 16; \
+ spiQxelXor[5] = (rrop_xor & 0xFF0000)>> 16; \
+ spiQxelXor[6] = rrop_xor << 8; \
+ spiQxelXor[1] = spiQxelXor[7] = 0; \
+ piQxelXor[0] = (rrop_xor & 0xFFFFFF)|(rrop_xor << 24); \
+ piQxelXor[1] = (rrop_xor << 16)|((rrop_xor & 0xFFFF00)>> 8); \
+ piQxelXor[2] = (rrop_xor << 8)|((rrop_xor & 0xFF0000)>> 16);
+#define RROP_SOLID24(dst,index) {\
+ register int idx = ((index) & 3)<< 1; \
+ *(dst) = (*(dst) & cfbrmask[idx])|spiQxelXor[idx]; \
+ if (idx == 2 || idx == 4){ \
+ idx++; \
+ *((dst)+1) = (*((dst)+1) & cfbrmask[idx])|spiQxelXor[idx]; \
+ } \
+ }
+#define RROP_SOLID(dst, idx) \
+ (*(dst) = piQxelXor[(idx)])
+#define RROP_SOLID_MASK(dst,mask,idx) \
+ (*(dst) = (*(dst) & ~(mask))|(piQxelXor[(idx)] & (mask)))
+#define RROP_UNDECLARE (void)piQxelXor; (void)spiQxelXor;
+#else
+#define RROP_FETCH_GCPRIV(devPriv) rrop_xor = (devPriv)->xor;
+#define RROP_DECLARE register CfbBits rrop_xor;
+#define RROP_SOLID(dst) (*(dst) = (rrop_xor))
+#define RROP_SOLID_MASK(dst,mask) (*(dst) = (*(dst) & ~(mask)) | ((rrop_xor) & (mask)))
+#define RROP_UNDECLARE
+#endif
+#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,Copy)
+#endif /* GXcopy */
+
+#if RROP == GXxor
+#if PSZ == 24
+#define RROP_DECLARE register CfbBits rrop_xor; \
+ CfbBits piQxelXor[3], spiQxelXor[8];
+#define RROP_FETCH_GCPRIV(devPriv) rrop_xor = (devPriv)->xor; \
+ spiQxelXor[0] = rrop_xor & 0xFFFFFF; \
+ spiQxelXor[2] = rrop_xor << 24; \
+ spiQxelXor[3] = (rrop_xor & 0xFFFF00)>> 8; \
+ spiQxelXor[4] = rrop_xor << 16; \
+ spiQxelXor[5] = (rrop_xor & 0xFF0000)>> 16; \
+ spiQxelXor[6] = rrop_xor << 8; \
+ spiQxelXor[1] = spiQxelXor[7] = 0; \
+ piQxelXor[0] = (rrop_xor & 0xFFFFFF)|(rrop_xor << 24); \
+ piQxelXor[1] = (rrop_xor << 16)|((rrop_xor & 0xFFFF00)>> 8); \
+ piQxelXor[2] = (rrop_xor << 8)|((rrop_xor & 0xFF0000)>> 16);
+#define RROP_SOLID24(dst,index) {\
+ register int idx = ((index) & 3)<< 1; \
+ *(dst) ^= spiQxelXor[idx]; \
+ if (idx == 2 || idx == 4) \
+ *((dst)+1) ^= spiQxelXor[idx+1]; \
+ }
+#define RROP_SOLID(dst,idx) \
+ (*(dst) ^= piQxelXor[(idx)])
+#define RROP_SOLID_MASK(dst,mask,idx) \
+ (*(dst) ^= (piQxelXor[(idx)] & (mask)))
+#define RROP_UNDECLARE (void)piQxelXor; (void)spiQxelXor;
+#else
+#define RROP_DECLARE register CfbBits rrop_xor;
+#define RROP_FETCH_GCPRIV(devPriv) rrop_xor = (devPriv)->xor;
+#define RROP_SOLID(dst) (*(dst) ^= (rrop_xor))
+#define RROP_SOLID_MASK(dst,mask) (*(dst) ^= ((rrop_xor) & (mask)))
+#define RROP_UNDECLARE
+#endif
+#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,Xor)
+#endif /* GXxor */
+
+#if RROP == GXand
+#if PSZ == 24
+#define RROP_DECLARE register CfbBits rrop_and; \
+ CfbBits piQxelAnd[3], spiQxelAnd[6];
+#define RROP_FETCH_GCPRIV(devPriv) rrop_and = (devPriv)->and; \
+ spiQxelAnd[0] = (rrop_and & 0xFFFFFF) | 0xFF000000; \
+ spiQxelAnd[2] = (rrop_and << 24) | 0xFFFFFF; \
+ spiQxelAnd[3] = ((rrop_and & 0xFFFF00)>> 8) | 0xFFFF0000; \
+ spiQxelAnd[4] = (rrop_and << 16) | 0xFFFF; \
+ spiQxelAnd[5] = ((rrop_and & 0xFF0000)>> 16) | 0xFFFFFF00; \
+ spiQxelAnd[1] = (rrop_and << 8) | 0xFF; \
+ piQxelAnd[0] = (rrop_and & 0xFFFFFF)|(rrop_and << 24); \
+ piQxelAnd[1] = (rrop_and << 16)|((rrop_and & 0xFFFF00)>> 8); \
+ piQxelAnd[2] = (rrop_and << 8)|((rrop_and & 0xFF0000)>> 16);
+#define RROP_SOLID24(dst,index) {\
+ switch((index) & 3){ \
+ case 0: \
+ *(dst) &= spiQxelAnd[0]; \
+ break; \
+ case 3: \
+ *(dst) &= spiQxelAnd[1]; \
+ break; \
+ case 1: \
+ *(dst) &= spiQxelAnd[2]; \
+ *((dst)+1) &= spiQxelAnd[3]; \
+ break; \
+ case 2: \
+ *(dst) &= spiQxelAnd[4]; \
+ *((dst)+1) &= spiQxelAnd[5]; \
+ break; \
+ } \
+ }
+#define RROP_SOLID(dst,idx) \
+ (*(dst) &= piQxelAnd[(idx)])
+#define RROP_SOLID_MASK(dst,mask,idx) \
+ (*(dst) &= (piQxelAnd[(idx)] | ~(mask)))
+#define RROP_UNDECLARE (void)piQxelAnd; (void)spiQxelAnd;
+#else
+#define RROP_DECLARE register CfbBits rrop_and;
+#define RROP_FETCH_GCPRIV(devPriv) rrop_and = (devPriv)->and;
+#define RROP_SOLID(dst) (*(dst) &= (rrop_and))
+#define RROP_SOLID_MASK(dst,mask) (*(dst) &= ((rrop_and) | ~(mask)))
+#define RROP_UNDECLARE
+#endif
+#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,And)
+#endif /* GXand */
+
+#if RROP == GXor
+#if PSZ == 24
+#define RROP_DECLARE register CfbBits rrop_or; \
+ CfbBits piQxelOr[3], spiQxelOr[6];
+#define RROP_FETCH_GCPRIV(devPriv) rrop_or = (devPriv)->xor; \
+ spiQxelOr[0] = rrop_or & 0xFFFFFF; \
+ spiQxelOr[1] = rrop_or << 24; \
+ spiQxelOr[2] = rrop_or << 16; \
+ spiQxelOr[3] = rrop_or << 8; \
+ spiQxelOr[4] = (rrop_or & 0xFFFF00)>> 8; \
+ spiQxelOr[5] = (rrop_or & 0xFF0000)>> 16; \
+ piQxelOr[0] = (rrop_or & 0xFFFFFF)|(rrop_or << 24); \
+ piQxelOr[1] = (rrop_or << 16)|((rrop_or & 0xFFFF00)>> 8); \
+ piQxelOr[2] = (rrop_or << 8)|((rrop_or & 0xFF0000)>> 16);
+#define RROP_SOLID24(dst,index) {\
+ switch((index) & 3){ \
+ case 0: \
+ *(dst) |= spiQxelOr[0]; \
+ break; \
+ case 3: \
+ *(dst) |= spiQxelOr[3]; \
+ break; \
+ case 1: \
+ *(dst) |= spiQxelOr[1]; \
+ *((dst)+1) |= spiQxelOr[4]; \
+ break; \
+ case 2: \
+ *(dst) |= spiQxelOr[2]; \
+ *((dst)+1) |= spiQxelOr[5]; \
+ break; \
+ } \
+ }
+#define RROP_SOLID(dst,idx) \
+ (*(dst) |= piQxelOr[(idx)])
+#define RROP_SOLID_MASK(dst,mask,idx) \
+ (*(dst) |= (piQxelOr[(idx)] & (mask)))
+#define RROP_UNDECLARE (void)piQxelOr; (void)spiQxelOr;
+#else
+#define RROP_DECLARE register CfbBits rrop_or;
+#define RROP_FETCH_GCPRIV(devPriv) rrop_or = (devPriv)->xor;
+#define RROP_SOLID(dst) (*(dst) |= (rrop_or))
+#define RROP_SOLID_MASK(dst,mask) (*(dst) |= ((rrop_or) & (mask)))
+#define RROP_UNDECLARE
+#endif
+#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,Or)
+#endif /* GXor */
+
+#if RROP == GXnoop
+#define RROP_DECLARE
+#define RROP_FETCH_GCPRIV(devPriv)
+#define RROP_SOLID(dst)
+#define RROP_SOLID_MASK(dst,mask)
+#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,Noop)
+#define RROP_UNDECLARE
+#endif /* GXnoop */
+
+#if RROP == GXset
+#if PSZ == 24
+#define RROP_DECLARE register CfbBits rrop_and, rrop_xor; \
+ CfbBits piQxelAnd[3], piQxelXor[3], spiQxelAnd[6], spiQxelXor[6];
+#define RROP_FETCH_GCPRIV(devPriv) rrop_and = (devPriv)->and; \
+ rrop_xor = (devPriv)->xor; \
+ spiQxelXor[0] = rrop_xor & 0xFFFFFF; \
+ spiQxelXor[1] = rrop_xor << 24; \
+ spiQxelXor[2] = rrop_xor << 16; \
+ spiQxelXor[3] = rrop_xor << 8; \
+ spiQxelXor[4] = (rrop_xor & 0xFFFF00)>> 8; \
+ spiQxelXor[5] = (rrop_xor & 0xFF0000)>> 16; \
+ spiQxelAnd[0] = (rrop_and & 0xFFFFFF) | 0xFF000000; \
+ spiQxelAnd[1] = (rrop_and << 24) | 0xFFFFFF; \
+ spiQxelAnd[2] = (rrop_and << 16) | 0xFFFF; \
+ spiQxelAnd[3] = (rrop_and << 8) | 0xFF; \
+ spiQxelAnd[4] = ((rrop_and & 0xFFFF00)>> 8) | 0xFFFF0000; \
+ spiQxelAnd[5] = ((rrop_and & 0xFF0000)>> 16) | 0xFFFFFF00; \
+ piQxelAnd[0] = (rrop_and & 0xFFFFFF)|(rrop_and << 24); \
+ piQxelAnd[1] = (rrop_and << 16)|((rrop_and & 0xFFFF00)>> 8); \
+ piQxelAnd[2] = (rrop_and << 8)|((rrop_and & 0xFF0000)>> 16); \
+ piQxelXor[0] = (rrop_xor & 0xFFFFFF)|(rrop_xor << 24); \
+ piQxelXor[1] = (rrop_xor << 16)|((rrop_xor & 0xFFFF00)>> 8); \
+ piQxelXor[2] = (rrop_xor << 8)|((rrop_xor & 0xFF0000)>> 16);
+#define RROP_SOLID24(dst,index) {\
+ switch((index) & 3){ \
+ case 0: \
+ *(dst) = ((*(dst) & (piQxelAnd[0] |0xFF000000))^(piQxelXor[0] & 0xFFFFFF)); \
+ break; \
+ case 3: \
+ *(dst) = ((*(dst) & (piQxelAnd[2]|0xFF))^(piQxelXor[2] & 0xFFFFFF00)); \
+ break; \
+ case 1: \
+ *(dst) = ((*(dst) & (piQxelAnd[0]|0xFFFFFF))^(piQxelXor[0] & 0xFF000000)); \
+ *((dst)+1) = ((*((dst)+1) & (piQxelAnd[1]|0xFFFF0000))^(piQxelXor[1] & 0xFFFF)); \
+ break; \
+ case 2: \
+ *(dst) = ((*(dst) & (piQxelAnd[1]|0xFFFF))^(piQxelXor[1] & 0xFFFF0000)); \
+ *((dst)+1) = ((*((dst)+1) & (piQxelAnd[2]|0xFFFFFF00))^(piQxelXor[2] & 0xFF)); \
+ break; \
+ } \
+ }
+#define RROP_SOLID(dst,idx) \
+ (*(dst) = DoRRop (*(dst), piQxelAnd[(idx)], piQxelXor[(idx)]))
+#define RROP_SOLID_MASK(dst,mask,idx) \
+ (*(dst) = DoMaskRRop (*(dst), piQxelAnd[(idx)], piQxelXor[(idx)], (mask)))
+#define RROP_UNDECLARE (void)piQxelAnd; (void)piQxelXor; \
+ (void)spiQxelAnd; (void)spiQxelXor;
+#else
+#define RROP_DECLARE register CfbBits rrop_and, rrop_xor;
+#define RROP_FETCH_GCPRIV(devPriv) rrop_and = (devPriv)->and; \
+ rrop_xor = (devPriv)->xor;
+#define RROP_SOLID(dst) (*(dst) = DoRRop (*(dst), rrop_and, rrop_xor))
+#define RROP_SOLID_MASK(dst,mask) (*(dst) = DoMaskRRop (*(dst), rrop_and, rrop_xor, (mask)))
+#define RROP_UNDECLARE
+#endif
+#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,General)
+#endif /* GXset */
+
+#define RROP_UNROLL_CASE1(p,i) case (i): RROP_SOLID((p) - (i));
+#define RROP_UNROLL_CASE2(p,i) RROP_UNROLL_CASE1(p,(i)+1) RROP_UNROLL_CASE1(p,i)
+#define RROP_UNROLL_CASE4(p,i) RROP_UNROLL_CASE2(p,(i)+2) RROP_UNROLL_CASE2(p,i)
+#define RROP_UNROLL_CASE8(p,i) RROP_UNROLL_CASE4(p,(i)+4) RROP_UNROLL_CASE4(p,i)
+#define RROP_UNROLL_CASE16(p,i) RROP_UNROLL_CASE8(p,(i)+8) RROP_UNROLL_CASE8(p,i)
+#define RROP_UNROLL_CASE3(p) RROP_UNROLL_CASE2(p,2) RROP_UNROLL_CASE1(p,1)
+#define RROP_UNROLL_CASE7(p) RROP_UNROLL_CASE4(p,4) RROP_UNROLL_CASE3(p)
+#define RROP_UNROLL_CASE15(p) RROP_UNROLL_CASE8(p,8) RROP_UNROLL_CASE7(p)
+#define RROP_UNROLL_CASE31(p) RROP_UNROLL_CASE16(p,16) RROP_UNROLL_CASE15(p)
+#ifdef LONG64
+#define RROP_UNROLL_CASE63(p) RROP_UNROLL_CASE32(p,32) RROP_UNROLL_CASE31(p)
+#endif /* LONG64 */
+
+#define RROP_UNROLL_LOOP1(p,i) RROP_SOLID((p) + (i));
+#define RROP_UNROLL_LOOP2(p,i) RROP_UNROLL_LOOP1(p,(i)) RROP_UNROLL_LOOP1(p,(i)+1)
+#define RROP_UNROLL_LOOP4(p,i) RROP_UNROLL_LOOP2(p,(i)) RROP_UNROLL_LOOP2(p,(i)+2)
+#define RROP_UNROLL_LOOP8(p,i) RROP_UNROLL_LOOP4(p,(i)) RROP_UNROLL_LOOP4(p,(i)+4)
+#define RROP_UNROLL_LOOP16(p,i) RROP_UNROLL_LOOP8(p,(i)) RROP_UNROLL_LOOP8(p,(i)+8)
+#define RROP_UNROLL_LOOP32(p,i) RROP_UNROLL_LOOP16(p,(i)) RROP_UNROLL_LOOP16(p,(i)+16)
+#ifdef LONG64
+#define RROP_UNROLL_LOOP64(p,i) RROP_UNROLL_LOOP32(p,(i)) RROP_UNROLL_LOOP32(p,(i)+32)
+#endif /* LONG64 */
+
+#if defined (FAST_CONSTANT_OFFSET_MODE) && defined (SHARED_IDCACHE) && (RROP == GXcopy)
+
+#ifdef LONG64
+#define RROP_UNROLL_SHIFT 6
+#define RROP_UNROLL_CASE(p) RROP_UNROLL_CASE63(p)
+#define RROP_UNROLL_LOOP(p) RROP_UNROLL_LOOP64(p,-64)
+#else /* not LONG64 */
+#define RROP_UNROLL_SHIFT 5
+#define RROP_UNROLL_CASE(p) RROP_UNROLL_CASE31(p)
+#define RROP_UNROLL_LOOP(p) RROP_UNROLL_LOOP32(p,-32)
+#endif /* LONG64 */
+#define RROP_UNROLL (1<<RROP_UNROLL_SHIFT)
+#define RROP_UNROLL_MASK (RROP_UNROLL-1)
+
+#define RROP_SPAN(pdst,nmiddle) {\
+ int part = (nmiddle) & RROP_UNROLL_MASK; \
+ (nmiddle) >>= RROP_UNROLL_SHIFT; \
+ (pdst) += part * (sizeof (CfbBits) / sizeof (*pdst)); \
+ switch (part) {\
+ RROP_UNROLL_CASE((CfbBits *) (pdst)) \
+ } \
+ while (--(nmiddle) >= 0) { \
+ (pdst) += RROP_UNROLL * (sizeof (CfbBits) / sizeof (*pdst)); \
+ RROP_UNROLL_LOOP((CfbBits *) (pdst)) \
+ } \
+}
+#else
+#define RROP_SPAN(pdst,nmiddle) \
+ while (--(nmiddle) >= 0) { \
+ RROP_SOLID((CfbBits *) (pdst)); \
+ (pdst) += sizeof (CfbBits) / sizeof (*pdst); \
+ }
+#endif
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define RROP_NAME_CAT(prefix,suffix) prefix##suffix
+#else
+#define RROP_NAME_CAT(prefix,suffix) prefix/**/suffix
+#endif
diff --git a/nx-X11/programs/Xserver/cfb/cfbscrinit.c b/nx-X11/programs/Xserver/cfb/cfbscrinit.c
new file mode 100644
index 000000000..7299bbdf8
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbscrinit.c
@@ -0,0 +1,232 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfbscrinit.c,v 1.19 2001/01/17 22:36:36 dawes Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $Xorg: cfbscrinit.c,v 1.3 2000/08/17 19:48:15 cpqbld Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "resource.h"
+#include "colormap.h"
+#include "colormapst.h"
+#include "cfb.h"
+#include "mi.h"
+#include "mistruct.h"
+#include "dix.h"
+#include "cfbmskbits.h"
+#include "mibstore.h"
+
+BSFuncRec cfbBSFuncRec = {
+ cfbSaveAreas,
+ cfbRestoreAreas,
+ (BackingStoreSetClipmaskRgnProcPtr) 0,
+ (BackingStoreGetImagePixmapProcPtr) 0,
+ (BackingStoreGetSpansPixmapProcPtr) 0,
+};
+
+Bool
+cfbCloseScreen (index, pScreen)
+ int index;
+ ScreenPtr pScreen;
+{
+ int d;
+ DepthPtr depths = pScreen->allowedDepths;
+
+ for (d = 0; d < pScreen->numDepths; d++)
+ xfree (depths[d].vids);
+ xfree (depths);
+ xfree (pScreen->visuals);
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ xfree (pScreen->devPrivates[cfbScreenPrivateIndex].ptr);
+#else
+ xfree (pScreen->devPrivate);
+#endif
+ return TRUE;
+}
+
+static void DestroyColormapNoop(
+ ColormapPtr pColormap)
+{
+ /* NOOP */
+}
+
+static void StoreColorsNoop(
+ ColormapPtr pColormap,
+ int ndef,
+ xColorItem * pdef)
+{
+ /* NOOP */
+}
+
+Bool
+cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+{
+ if (!cfbAllocatePrivates(pScreen, (int *) 0, (int *) 0))
+ return FALSE;
+ pScreen->defColormap = FakeClientID(0);
+ /* let CreateDefColormap do whatever it wants for pixels */
+ pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
+ pScreen->QueryBestSize = mfbQueryBestSizeWeak();
+ /* SaveScreen */
+ pScreen->GetImage = cfbGetImage;
+ pScreen->GetSpans = cfbGetSpans;
+ pScreen->CreateWindow = cfbCreateWindow;
+ pScreen->DestroyWindow = cfbDestroyWindow;
+ pScreen->PositionWindow = cfbPositionWindow;
+ pScreen->ChangeWindowAttributes = cfbChangeWindowAttributes;
+ pScreen->RealizeWindow = cfbMapWindow;
+ pScreen->UnrealizeWindow = cfbUnmapWindow;
+ pScreen->PaintWindowBackground = cfbPaintWindow;
+ pScreen->PaintWindowBorder = cfbPaintWindow;
+ pScreen->CopyWindow = cfbCopyWindow;
+ pScreen->CreatePixmap = cfbCreatePixmap;
+ pScreen->DestroyPixmap = cfbDestroyPixmap;
+ pScreen->RealizeFont = mfbRealizeFontWeak();
+ pScreen->UnrealizeFont = mfbUnrealizeFontWeak();
+ pScreen->CreateGC = cfbCreateGC;
+ pScreen->CreateColormap = cfbInitializeColormap;
+ pScreen->DestroyColormap = DestroyColormapNoop;
+ pScreen->InstallColormap = cfbInstallColormap;
+ pScreen->UninstallColormap = cfbUninstallColormap;
+ pScreen->ListInstalledColormaps = cfbListInstalledColormaps;
+ pScreen->StoreColors = StoreColorsNoop;
+ pScreen->ResolveColor = cfbResolveColor;
+ pScreen->BitmapToRegion = mfbPixmapToRegionWeak();
+
+ mfbRegisterCopyPlaneProc (pScreen, cfbCopyPlane);
+ return TRUE;
+}
+
+#ifdef CFB_NEED_SCREEN_PRIVATE
+Bool
+cfbCreateScreenResources(pScreen)
+ ScreenPtr pScreen;
+{
+ Bool retval;
+
+ pointer oldDevPrivate = pScreen->devPrivate;
+ pScreen->devPrivate = pScreen->devPrivates[cfbScreenPrivateIndex].ptr;
+ retval = miCreateScreenResources(pScreen);
+ pScreen->devPrivates[cfbScreenPrivateIndex].ptr = pScreen->devPrivate;
+ pScreen->devPrivate = oldDevPrivate;
+ return retval;
+}
+#endif
+
+Bool
+cfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+{
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ pointer oldDevPrivate;
+#endif
+ VisualPtr visuals;
+ DepthPtr depths;
+ int nvisuals;
+ int ndepths;
+ int rootdepth;
+ VisualID defaultVisual;
+
+ rootdepth = 0;
+ if (!cfbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
+ &defaultVisual,((unsigned long)1<<(PSZ-1)), 8))
+ return FALSE;
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ oldDevPrivate = pScreen->devPrivate;
+#endif
+ if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
+ rootdepth, ndepths, depths,
+ defaultVisual, nvisuals, visuals))
+ return FALSE;
+ /* overwrite miCloseScreen with our own */
+ pScreen->CloseScreen = cfbCloseScreen;
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ pScreen->CreateScreenResources = cfbCreateScreenResources;
+ pScreen->devPrivates[cfbScreenPrivateIndex].ptr = pScreen->devPrivate;
+ pScreen->devPrivate = oldDevPrivate;
+#endif
+ pScreen->BackingStoreFuncs = cfbBSFuncRec;
+ pScreen->GetScreenPixmap = cfbGetScreenPixmap;
+ pScreen->SetScreenPixmap = cfbSetScreenPixmap;
+ return TRUE;
+}
+
+/* dts * (inch/dot) * (25.4 mm / inch) = mm */
+Bool
+cfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+{
+ if (!cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width))
+ return FALSE;
+ return cfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
+}
+
+PixmapPtr
+cfbGetScreenPixmap(pScreen)
+ ScreenPtr pScreen;
+{
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ return (PixmapPtr)pScreen->devPrivates[cfbScreenPrivateIndex].ptr;
+#else
+ return (PixmapPtr)pScreen->devPrivate;
+#endif
+}
+
+void
+cfbSetScreenPixmap(pPix)
+ PixmapPtr pPix;
+{
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ if (pPix)
+ pPix->drawable.pScreen->devPrivates[cfbScreenPrivateIndex].ptr =
+ (pointer)pPix;
+#else
+ if (pPix)
+ pPix->drawable.pScreen->devPrivate = (pointer)pPix;
+#endif
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbsetsp.c b/nx-X11/programs/Xserver/cfb/cfbsetsp.c
new file mode 100644
index 000000000..56317cb91
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbsetsp.c
@@ -0,0 +1,318 @@
+/* $Xorg: cfbsetsp.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/cfb/cfbsetsp.c,v 3.5tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+
+#include "misc.h"
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include <mergerop.h>
+
+/* cfbSetScanline -- copies the bits from psrc to the drawable starting at
+ * (xStart, y) and continuing to (xEnd, y). xOrigin tells us where psrc
+ * starts on the scanline. (I.e., if this scanline passes through multiple
+ * boxes, we may not want to start grabbing bits at psrc but at some offset
+ * further on.)
+ */
+void
+cfbSetScanline(y, xOrigin, xStart, xEnd, psrc, alu, pdstBase, widthDst, planemask)
+ int y;
+ int xOrigin; /* where this scanline starts */
+ int xStart; /* first bit to use from scanline */
+ int xEnd; /* last bit to use from scanline + 1 */
+ register unsigned int *psrc;
+ register int alu; /* raster op */
+ int *pdstBase; /* start of the drawable */
+ int widthDst; /* width of drawable in words */
+ unsigned long planemask;
+{
+ int w; /* width of scanline in bits */
+ register int *pdst; /* where to put the bits */
+ register int tmpSrc; /* scratch buffer to collect bits in */
+ int offSrc;
+ int nl;
+#if PSZ == 24
+ register char *psrcb, *pdstb;
+ register int xIndex;
+#else
+ int dstBit; /* offset in bits from beginning of
+ * word */
+ register int nstart; /* number of bits from first partial */
+#if PSZ != 32 || PPW != 1
+ register int nend; /* " " last partial word */
+#endif
+ int startmask, endmask, nlMiddle;
+#endif
+ DeclareMergeRop()
+
+ InitializeMergeRop(alu,planemask);
+#if PSZ == 24
+ pdst = pdstBase + (y * widthDst);
+ xIndex = xStart;
+ pdstb = (char *)pdst + (xStart * 3);
+ offSrc = xStart - xOrigin;
+ psrcb = (char *)psrc + (offSrc * 3);
+#else
+ pdst = pdstBase + (y * widthDst) + (xStart >> PWSH);
+ psrc += (xStart - xOrigin) >> PWSH;
+ offSrc = (xStart - xOrigin) & PIM;
+#endif
+ w = xEnd - xStart;
+
+#if PSZ == 24
+ nl = w;
+ while (nl--){
+ psrc = (unsigned int *)((unsigned long)psrcb & ~0x03);
+ getbits24(psrc, tmpSrc, offSrc);
+ pdst = (int *)((unsigned long)pdstb & ~0x03);
+ DoMergeRop24(tmpSrc, pdst, xIndex);
+ offSrc++;
+ psrcb += 3;
+ xIndex++;
+ pdstb += 3;
+ }
+#else /* PSZ == 24 */
+ dstBit = xStart & PIM;
+ if (dstBit + w <= PPW)
+ {
+ maskpartialbits(dstBit, w, startmask);
+ endmask = 0;
+ nlMiddle = 0;
+ }
+ else
+ {
+ maskbits(xStart, w, startmask, endmask, nlMiddle);
+ }
+ if (startmask)
+ nstart = PPW - dstBit;
+ else
+ nstart = 0;
+#if PSZ != 32 || PPW != 1
+ if (endmask)
+ nend = xEnd & PIM;
+ else
+ nend = 0;
+#endif
+ if (startmask)
+ {
+ getbits(psrc, offSrc, nstart, tmpSrc);
+ putbitsmropshort(tmpSrc, dstBit, nstart, pdst);
+ pdst++;
+ offSrc += nstart;
+ if (offSrc > PLST)
+ {
+ psrc++;
+ offSrc -= PPW;
+ }
+ }
+ nl = nlMiddle;
+ while (nl--)
+ {
+ getbits(psrc, offSrc, PPW, tmpSrc);
+ *pdst = DoMergeRop(tmpSrc, *pdst);
+ pdst++;
+ psrc++;
+ }
+ if (endmask)
+ {
+ getbits(psrc, offSrc, nend, tmpSrc);
+ putbitsmropshort(tmpSrc, 0, nend, pdst);
+ }
+#endif /* PSZ == 24 */
+}
+
+
+
+/* SetSpans -- for each span copy pwidth[i] bits from psrc to pDrawable at
+ * ppt[i] using the raster op from the GC. If fSorted is TRUE, the scanlines
+ * are in increasing Y order.
+ * Source bit lines are server scanline padded so that they always begin
+ * on a word boundary.
+ */
+void
+cfbSetSpans(pDrawable, pGC, pcharsrc, ppt, pwidth, nspans, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ char *pcharsrc;
+ register DDXPointPtr ppt;
+ int *pwidth;
+ int nspans;
+ int fSorted;
+{
+ unsigned int *psrc = (unsigned int *)pcharsrc;
+ CfbBits *pdstBase; /* start of dst bitmap */
+ int widthDst; /* width of bitmap in words */
+ register BoxPtr pbox, pboxLast, pboxTest;
+ register DDXPointPtr pptLast;
+ int alu;
+ RegionPtr prgnDst;
+ int xStart, xEnd;
+ int yMax;
+
+ alu = pGC->alu;
+ prgnDst = cfbGetCompositeClip(pGC);
+ pptLast = ppt + nspans;
+
+ cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase)
+
+ yMax = (int) pDrawable->y + (int) pDrawable->height;
+
+ pbox = REGION_RECTS(prgnDst);
+ pboxLast = pbox + REGION_NUM_RECTS(prgnDst);
+
+ if(fSorted)
+ {
+ /* scan lines sorted in ascending order. Because they are sorted, we
+ * don't have to check each scanline against each clip box. We can be
+ * sure that this scanline only has to be clipped to boxes at or after the
+ * beginning of this y-band
+ */
+ pboxTest = pbox;
+ while(ppt < pptLast)
+ {
+ pbox = pboxTest;
+ if(ppt->y >= yMax)
+ break;
+ while(pbox < pboxLast)
+ {
+ if(pbox->y1 > ppt->y)
+ {
+ /* scanline is before clip box */
+ break;
+ }
+ else if(pbox->y2 <= ppt->y)
+ {
+ /* clip box is before scanline */
+ pboxTest = ++pbox;
+ continue;
+ }
+ else if(pbox->x1 > ppt->x + *pwidth)
+ {
+ /* clip box is to right of scanline */
+ break;
+ }
+ else if(pbox->x2 <= ppt->x)
+ {
+ /* scanline is to right of clip box */
+ pbox++;
+ continue;
+ }
+
+ /* at least some of the scanline is in the current clip box */
+ xStart = max(pbox->x1, ppt->x);
+ xEnd = min(ppt->x + *pwidth, pbox->x2);
+ cfbSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu,
+ (int *)pdstBase, widthDst, pGC->planemask);
+ if(ppt->x + *pwidth <= pbox->x2)
+ {
+ /* End of the line, as it were */
+ break;
+ }
+ else
+ pbox++;
+ }
+ /* We've tried this line against every box; it must be outside them
+ * all. move on to the next point */
+ ppt++;
+ psrc += PixmapWidthInPadUnits(*pwidth, pDrawable->depth);
+ pwidth++;
+ }
+ }
+ else
+ {
+ /* scan lines not sorted. We must clip each line against all the boxes */
+ while(ppt < pptLast)
+ {
+ if(ppt->y >= 0 && ppt->y < yMax)
+ {
+
+ for(pbox = REGION_RECTS(prgnDst); pbox< pboxLast; pbox++)
+ {
+ if(pbox->y1 > ppt->y)
+ {
+ /* rest of clip region is above this scanline,
+ * skip it */
+ break;
+ }
+ if(pbox->y2 <= ppt->y)
+ {
+ /* clip box is below scanline */
+ pbox++;
+ break;
+ }
+ if(pbox->x1 <= ppt->x + *pwidth &&
+ pbox->x2 > ppt->x)
+ {
+ xStart = max(pbox->x1, ppt->x);
+ xEnd = min(pbox->x2, ppt->x + *pwidth);
+ cfbSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu,
+ (int *)pdstBase, widthDst, pGC->planemask);
+ }
+
+ }
+ }
+ psrc += PixmapWidthInPadUnits(*pwidth, pDrawable->depth);
+ ppt++;
+ pwidth++;
+ }
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/cfb/cfbsolid.c b/nx-X11/programs/Xserver/cfb/cfbsolid.c
new file mode 100644
index 000000000..9f9093647
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbsolid.c
@@ -0,0 +1,1367 @@
+/*
+ * $Xorg: cfbsolid.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $
+ *
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/programs/Xserver/cfb/cfbsolid.c,v 3.8tsi Exp $ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "cfbrrop.h"
+
+#include "mi.h"
+#include "mispans.h"
+
+#if defined(FAST_CONSTANT_OFFSET_MODE) && (RROP != GXcopy)
+# define Expand(left,right,leftAdjust) {\
+ int part = nmiddle & 3; \
+ int widthStep; \
+ widthStep = widthDst - nmiddle - leftAdjust; \
+ nmiddle >>= 2; \
+ pdst = pdstRect; \
+ while (h--) { \
+ left \
+ pdst += part; \
+ switch (part) { \
+ RROP_UNROLL_CASE3(pdst) \
+ } \
+ m = nmiddle; \
+ while (m) { \
+ pdst += 4; \
+ RROP_UNROLL_LOOP4(pdst,-4) \
+ m--; \
+ } \
+ right \
+ pdst += widthStep; \
+ } \
+}
+#else
+# ifdef RROP_UNROLL
+# define Expand(left,right,leftAdjust) {\
+ int part = nmiddle & RROP_UNROLL_MASK; \
+ int widthStep; \
+ widthStep = widthDst - nmiddle - leftAdjust; \
+ nmiddle >>= RROP_UNROLL_SHIFT; \
+ pdst = pdstRect; \
+ while (h--) { \
+ left \
+ pdst += part; \
+ switch (part) { \
+ RROP_UNROLL_CASE(pdst) \
+ } \
+ m = nmiddle; \
+ while (m) { \
+ pdst += RROP_UNROLL; \
+ RROP_UNROLL_LOOP(pdst) \
+ m--; \
+ } \
+ right \
+ pdst += widthStep; \
+ } \
+}
+
+# else
+# define Expand(left, right, leftAdjust) { \
+ while (h--) { \
+ pdst = pdstRect; \
+ left \
+ m = nmiddle; \
+ while (m--) {\
+ RROP_SOLID(pdst); \
+ pdst++; \
+ } \
+ right \
+ pdstRect += widthDst; \
+ } \
+}
+# endif
+#endif
+
+
+void
+RROP_NAME(cfbFillRectSolid) (pDrawable, pGC, nBox, pBox)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nBox;
+ BoxPtr pBox;
+{
+ register int m;
+ register CfbBits *pdst;
+ RROP_DECLARE
+ CfbBits *pdstBase, *pdstRect;
+ int nmiddle;
+ int h;
+ int w;
+ int widthDst;
+#if PSZ == 24
+ int leftIndex, rightIndex;
+#else
+ register CfbBits leftMask, rightMask;
+#endif
+
+ cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase)
+
+ RROP_FETCH_GC(pGC)
+
+ for (; nBox; nBox--, pBox++)
+ {
+ pdstRect = pdstBase + pBox->y1 * widthDst;
+ h = pBox->y2 - pBox->y1;
+ w = pBox->x2 - pBox->x1;
+#if PSZ == 8
+ if (w == 1)
+ {
+ register char *pdstb = ((char *) pdstRect) + pBox->x1;
+ int incr = widthDst * PGSZB;
+
+ while (h--)
+ {
+ RROP_SOLID (pdstb);
+ pdstb += incr;
+ }
+ }
+ else
+ {
+#endif
+#if PSZ == 24
+ leftIndex = pBox->x1 &3;
+/* rightIndex = ((leftIndex+w)<5)?0:pBox->x2 &3;*/
+ rightIndex = pBox->x2 &3;
+
+ nmiddle = w - rightIndex;
+ if(leftIndex){
+ nmiddle -= (4 - leftIndex);
+ }
+ nmiddle >>= 2;
+ if(nmiddle < 0)
+ nmiddle = 0;
+
+ pdstRect += (pBox->x1 * 3) >> 2;
+ pdst = pdstRect;
+ switch(leftIndex+w){
+ case 4:
+ switch(leftIndex){
+ case 0:
+ while(h--){
+#if RROP == GXcopy
+ *pdst++ = piQxelXor[0];
+ *pdst++ = piQxelXor[1];
+ *pdst-- = piQxelXor[2];
+#endif
+#if RROP == GXxor
+ *pdst++ ^= piQxelXor[0];
+ *pdst++ ^= piQxelXor[1];
+ *pdst-- ^= piQxelXor[2];
+#endif
+#if RROP == GXand
+ *pdst++ &= piQxelAnd[0];
+ *pdst++ &= piQxelAnd[1];
+ *pdst-- &= piQxelAnd[2];
+#endif
+#if RROP == GXor
+ *pdst++ |= piQxelOr[0];
+ *pdst++ |= piQxelOr[1];
+ *pdst-- |= piQxelOr[2];
+#endif
+#if RROP == GXset
+ *pdst = DoRRop((*pdst), piQxelAnd[0], piQxelXor[0]);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[1], piQxelXor[1]);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[2], piQxelXor[2]);
+ pdst--;
+#endif
+ pdst--;
+ pdst += widthDst;
+ }
+ break;
+ case 1:
+ while(h--){
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFFFFFF) | (piQxelXor[0] & 0xFF000000);
+ pdst++;
+ *pdst++ = piQxelXor[1];
+ *pdst-- = piQxelXor[2];
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[0] & 0xFF000000);
+ *pdst++ ^= piQxelXor[1];
+ *pdst-- ^= piQxelXor[2];
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[0] | 0x00FFFFFF);
+ *pdst++ &= piQxelAnd[1];
+ *pdst-- &= piQxelAnd[2];
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[0] & 0xFF000000);
+ *pdst++ |= piQxelOr[1];
+ *pdst-- |= piQxelOr[2];
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[0], piQxelXor[0], 0xFF000000);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[1], piQxelXor[1]);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[2], piQxelXor[2]);
+ pdst--;
+#endif
+ pdst--;
+ pdst += widthDst;
+ }
+ break;
+ case 2:
+ while(h--){
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFFFF) | (piQxelXor[1] & 0xFFFF0000);
+ pdst++;
+ *pdst-- = piQxelXor[2];
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[1] & 0xFFFF0000);
+ *pdst-- ^= piQxelXor[2];
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[1] | 0xFFFF);
+ *pdst-- &= piQxelAnd[2];
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[1] & 0xFFFF0000);
+ *pdst-- |= piQxelOr[2];
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[1], piQxelXor[1], 0xFFFF0000);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[2], piQxelXor[2]);
+ pdst--;
+#endif
+ pdst += widthDst;
+ }
+ break;
+ case 3:
+ while(h--){
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFF) | (piQxelXor[2] & 0xFFFFFF00);
+#endif
+#if RROP == GXxor
+ *pdst ^= (piQxelXor[2] & 0xFFFFFF00);
+#endif
+#if RROP == GXand
+ *pdst &= (piQxelAnd[2] | 0xFF);
+#endif
+#if RROP == GXor
+ *pdst |= (piQxelOr[2] & 0xFFFFFF00);
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[2], piQxelXor[2], 0xFFFFFF00);
+#endif
+ pdst += widthDst;
+ }
+ break;
+ }
+ break;
+ case 3:
+ switch(leftIndex){
+ case 0:
+ while(h--){
+#if RROP == GXcopy
+ *pdst++ = piQxelXor[0];
+ *pdst++ = piQxelXor[1];
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelXor[2] & 0xFF);
+ pdst--;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= piQxelXor[0];
+ *pdst++ ^= piQxelXor[1];
+ *pdst-- ^= (piQxelXor[2] & 0xFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= piQxelAnd[0];
+ *pdst++ &= piQxelAnd[1];
+ *pdst-- &= (piQxeAnd[2] | 0xFFFFFF00);
+#endif
+#if RROP == GXor
+ *pdst++ |= piQxelOr[0];
+ *pdst++ |= piQxelOr[1];
+ *pdst-- |= (piQxelOr[2] & 0xFF);
+#endif
+#if RROP == GXset
+ *pdst = DoRRop((*pdst), piQxelAnd[0], piQxelXor[0]);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[1], piQxelXor[1]);
+ pdst++;
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[2], piQxelXor[2], 0xFF);
+ pdst--;
+#endif
+ pdst--;
+ pdst += widthDst;
+ }
+ break;
+ case 1:
+ while(h--){
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFFFFFF) | (piQxelXor[0] & 0xFF000000);
+ pdst++;
+ *pdst++ = piQxelXor[1];
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelXor[2] & 0xFF);
+ pdst--;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[0] & 0xFF000000);
+ *pdst++ ^= piQxelXor[1];
+ *pdst-- ^= (piQxelXor[2] & 0xFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[0] | 0x00FFFFFF);
+ *pdst++ &= piQxelAnd[1];
+ *pdst-- &= (piQxelAnd[2] | 0xFFFFFF00);
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[0] & 0xFF000000);
+ *pdst++ |= piQxelOr[1];
+ *pdst-- |= (piQxelOr[2] & 0xFF);
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[0], piQxelXor[0], 0xFF000000);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[1], piQxelXor[1]);
+ pdst++;
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[2], piQxelXor[2], 0xFF);
+ pdst--;
+#endif
+ pdst--;
+ pdst += widthDst;
+ }
+ break;
+ case 2:
+ while(h--){
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFFFF) | (piQxelXor[1] & 0xFFFF0000);
+ pdst++;
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelXor[2] & 0xFF);
+ pdst--;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[1] & 0xFFFF0000);
+ *pdst-- ^= (piQxelXor[2] & 0xFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[1] | 0xFFFF);
+ *pdst-- &= (piQxelAnd[2] | 0xFFFFFF00);
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[1] & 0xFFFF0000);
+ *pdst-- |= (piQxelOr[2] & 0xFF);
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[1], piQxelXor[1], 0xFFFF0000);
+ pdst++;
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[2], piQxelXor[2], 0xFF);
+ pdst--;
+#endif
+ pdst += widthDst;
+ }
+ break;
+ case 3:
+ while(h--){
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFF) | (piQxelXor[2] & 0xFFFFFF00);
+#endif
+#if RROP == GXxor
+ *pdst ^= (piQxelXor[2] & 0xFFFFFF00);
+#endif
+#if RROP == GXand
+ *pdst &= (piQxelAnd[2] | 0xFF);
+#endif
+#if RROP == GXor
+ *pdst |= (piQxelOr[2] & 0xFFFFFF00);
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[2], piQxelXor[2], 0xFFFFFF00);
+#endif
+ pdst += widthDst;
+ }
+ break;
+ }
+ break;
+ case 2: /* leftIndex + w = 2*/
+ switch(leftIndex){
+ case 2:
+ while(h--){
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFFFF) | (piQxelXor[1] & 0xFFFF0000);
+ pdst++;
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelXor[2] & 0xFF);
+ pdst--;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[1] & 0xFFFF0000);
+ *pdst-- ^= (piQxelXor[2] & 0xFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[1] | 0xFFFF0000);
+ *pdst-- &= (piQxelAnd[2] | 0xFF);
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[1] & 0xFFFF0000);
+ *pdst-- |= (piQxelOr[2] & 0xFF);
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[1], piQxelXor[1], 0xFFFF0000);
+ pdst++;
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[2], piQxelXor[2], 0xFF);
+ pdst--;
+#endif
+ pdst += widthDst;
+ }
+ break;
+ case 1:
+ while(h--){
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFFFFFF) | (piQxelXor[0] & 0xFF000000);
+ pdst++;
+ *pdst = ((*pdst) & 0xFFFF0000) | (piQxelXor[1] & 0xFFFF);
+ pdst--;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[0] & 0xFF000000);
+ *pdst-- ^= (piQxelXor[1] & 0xFFFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[0] | 0xFFFFFF);
+ *pdst-- &= (piQxelAnd[1] | 0xFFFF0000);
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[0] & 0xFF000000);
+ *pdst-- |= (piQxelOr[1] & 0xFFFF);
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[0], piQxelXor[0], 0xFF000000);
+ pdst++;
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[1], piQxelXor[1], 0xFFFF);
+ pdst--;
+#endif
+ pdst += widthDst;
+ }
+ break;
+ case 0: /*case 2 leftIndex == 0 */
+ while(h--){
+#if RROP == GXcopy
+ *pdst++ = piQxelXor[0];
+ *pdst = ((*pdst) & 0xFFFF0000) | (piQxelXor[1] & 0xFFFF);
+ pdst--;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= piQxelXor[0];
+ *pdst-- ^= (piQxelXor[1] & 0xFFFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= piQxelAnd[0];
+ *pdst-- &= (piQxelAnd[1] | 0xFFFF0000);
+#endif
+#if RROP == GXor
+ *pdst++ |= piQxelOr[0];
+ *pdst-- |= (piQxelOr[1] & 0xFFFF);
+#endif
+#if RROP == GXset
+ *pdst = DoRRop((*pdst), piQxelAnd[0], piQxelXor[0]);
+ pdst++;
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[1], piQxelXor[1], 0xFFFF);
+ pdst--;
+#endif
+ pdst += widthDst;
+ }
+ break;
+ }
+ break;
+ case 1: /*only if leftIndex = 0 and w = 1*/
+ while(h--){
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFF000000) | (piQxelXor[0] & 0xFFFFFF);
+#endif
+#if RROP == GXxor
+ *pdst ^= (piQxelXor[0] & 0xFFFFFF);
+#endif
+#if RROP == GXand
+ *pdst &= (piQxelAnd[0] | 0xFF000000);
+#endif
+#if RROP == GXor
+ *pdst |= (piQxelOr[0] & 0xFFFFFF);
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[0], piQxelXor[0], 0xFFFFFF);
+#endif
+ pdst += widthDst;
+ }
+ break;
+ case 0: /*never*/
+ break;
+ default:
+ {
+ while(h--){
+ pdst = pdstRect;
+ switch(leftIndex){
+ case 0:
+ break;
+ case 1:
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFFFFFF) | (piQxelXor[0] & 0xFF000000);
+ pdst++;
+ *pdst++ = piQxelXor[1];
+ *pdst++ = piQxelXor[2];
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[0] & 0xFF000000);
+ *pdst++ ^= piQxelXor[1];
+ *pdst++ ^= piQxelXor[2];
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[0] | 0xFFFFFF);
+ *pdst++ &= piQxelAnd[1];
+ *pdst++ &= piQxelAnd[2];
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[0] & 0xFF000000);
+ *pdst++ |= piQxelOr[1];
+ *pdst++ |= piQxelOr[2];
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[0], piQxelXor[0], 0xFF000000);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[1], piQxelXor[1]);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[2], piQxelXor[2]);
+ pdst++;
+#endif
+ break;
+ case 2:
+#if RROP == GXcopy
+ *pdst = (((*pdst) & 0xFFFF) | (piQxelXor[1] & 0xFFFF0000));
+ pdst++;
+ *pdst++ = piQxelXor[2];
+#endif
+#if RROP == GXxor
+ *pdst++ ^=(piQxelXor[1] & 0xFFFF0000);
+ *pdst++ ^= piQxelXor[2];
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[1] | 0xFFFF);
+ *pdst++ &= piQxelAnd[2];
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[1] & 0xFFFF0000);
+ *pdst++ |= piQxelOr[2];
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[1], piQxelXor[1], 0xFFFF0000);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[2], piQxelXor[2]);
+ pdst++;
+#endif
+ break;
+ case 3:
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFF) | (piQxelXor[2] & 0xFFFFFF00);
+ pdst++;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[2] & 0xFFFFFF00);
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[2] | 0xFF);
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[2] & 0xFFFFFF00);
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[2], piQxelXor[2], 0xFFFFFF00);
+ pdst++;
+#endif
+ break;
+ }
+ m = nmiddle;
+ while(m--){
+#if RROP == GXcopy
+ *pdst++ = piQxelXor[0];
+ *pdst++ = piQxelXor[1];
+ *pdst++ = piQxelXor[2];
+#endif
+#if RROP == GXxor
+ *pdst++ ^= piQxelXor[0];
+ *pdst++ ^= piQxelXor[1];
+ *pdst++ ^= piQxelXor[2];
+#endif
+#if RROP == GXand
+ *pdst++ &= piQxelAnd[0];
+ *pdst++ &= piQxelAnd[1];
+ *pdst++ &= piQxelAnd[2];
+#endif
+#if RROP == GXor
+ *pdst++ |= piQxelOr[0];
+ *pdst++ |= piQxelOr[1];
+ *pdst++ |= piQxelOr[2];
+#endif
+#if RROP == GXset
+ *pdst = DoRRop((*pdst), piQxelAnd[0], piQxelXor[0]);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[1], piQxelXor[1]);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[2], piQxelXor[2]);
+ pdst++;
+#endif
+ }
+ switch(rightIndex){
+ case 0:
+ break;
+ case 1:
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFF000000) | (piQxelXor[0] & 0xFFFFFF);
+ pdst++;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[0] & 0xFFFFFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[0] | 0xFF);
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[0] & 0xFFFFFF);
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[0], piQxelXor[0], 0xFFFFFF);
+ pdst++;
+#endif
+ break;
+ case 2:
+#if RROP == GXcopy
+ *pdst++ = piQxelXor[0];
+ *pdst = ((*pdst) & 0xFFFF0000) | (piQxelXor[1] & 0xFFFF);
+ pdst++;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= piQxelXor[0];
+ *pdst++ ^= (piQxelXor[1] & 0xFFFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= piQxelAnd[0];
+ *pdst++ &= (piQxelAnd[1] | 0xFFFF0000);
+#endif
+#if RROP == GXor
+ *pdst++ |= piQxelOr[0];
+ *pdst++ |= (piQxelOr[1] & 0xFFFF);
+#endif
+#if RROP == GXset
+ *pdst = DoRRop((*pdst), piQxelAnd[0], piQxelXor[0]);
+ pdst++;
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[1], piQxelXor[1], 0xFFFF);
+ pdst++;
+#endif
+ break;
+ case 3:
+#if RROP == GXcopy
+ *pdst++ = piQxelXor[0];
+ *pdst++ = piQxelXor[1];
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelXor[2] & 0xFF);
+ pdst++;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= piQxelXor[0];
+ *pdst++ ^= piQxelXor[1];
+ *pdst++ ^= (piQxelXor[2] & 0xFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= piQxelAnd[0];
+ *pdst++ &= piQxelAnd[1];
+ *pdst++ &= (piQxelAnd[2] | 0xFFFFFF00);
+#endif
+#if RROP == GXor
+ *pdst++ |= piQxelOr[0];
+ *pdst++ |= piQxelOr[1];
+ *pdst++ |= (piQxelOr[2] & 0xFF);
+#endif
+#if RROP == GXset
+ *pdst = DoRRop((*pdst), piQxelAnd[0], piQxelXor[0]);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[1], piQxelXor[1]);
+ pdst++;
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[2], piQxelXor[2], 0xFF);
+ pdst++;
+#endif
+ break;
+ }
+ pdstRect += widthDst;
+ }
+ }
+ }
+#else /* PSZ != 24 */
+ pdstRect += (pBox->x1 >> PWSH);
+ if ((pBox->x1 & PIM) + w <= PPW)
+ {
+ maskpartialbits(pBox->x1, w, leftMask);
+ pdst = pdstRect;
+ while (h--) {
+ RROP_SOLID_MASK (pdst, leftMask);
+ pdst += widthDst;
+ }
+ }
+ else
+ {
+ maskbits (pBox->x1, w, leftMask, rightMask, nmiddle);
+ if (leftMask)
+ {
+ if (rightMask) /* left mask and right mask */
+ {
+ Expand(RROP_SOLID_MASK (pdst, leftMask); pdst++;,
+ RROP_SOLID_MASK (pdst, rightMask);, 1)
+ }
+ else /* left mask and no right mask */
+ {
+ Expand(RROP_SOLID_MASK (pdst, leftMask); pdst++;,
+ ;, 1)
+ }
+ }
+ else
+ {
+ if (rightMask) /* no left mask and right mask */
+ {
+ Expand(;,
+ RROP_SOLID_MASK (pdst, rightMask);, 0)
+ }
+ else /* no left mask and no right mask */
+ {
+ Expand(;,
+ ;, 0)
+ }
+ }
+ }
+#endif
+#if PSZ == 8
+ }
+#endif
+ }
+ RROP_UNDECLARE
+}
+
+void
+RROP_NAME(cfbSolidSpans) (pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ CfbBits *pdstBase;
+ int widthDst;
+
+ RROP_DECLARE
+
+ register CfbBits *pdst;
+ register int nlmiddle;
+ register int w;
+ int x;
+
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ DDXPointPtr ppt; /* pointer to list of start points */
+ int *pwidthFree;/* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ int *pwidth;
+ cfbPrivGCPtr devPriv;
+#if PSZ == 24
+ int leftIndex, rightIndex;
+#else
+ register CfbBits startmask, endmask;
+#endif
+
+ devPriv = cfbGetGCPrivate(pGC);
+ RROP_FETCH_GCPRIV(devPriv)
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase)
+
+ while (n--)
+ {
+ x = ppt->x;
+ pdst = pdstBase + (ppt->y * widthDst);
+ ++ppt;
+ w = *pwidth++;
+ if (!w)
+ continue;
+#if PSZ == 24
+ leftIndex = x &3;
+/* rightIndex = ((leftIndex+w)<5)?0:(x+w)&3;*/
+ rightIndex = (x+w)&3;
+
+ nlmiddle = w - rightIndex;
+ if(leftIndex){
+ nlmiddle -= (4 - leftIndex);
+ }
+/* nlmiddle += 3;*/
+ nlmiddle >>= 2;
+ if(nlmiddle < 0)
+ nlmiddle = 0;
+
+ pdst += (x >> 2)*3;
+ pdst += leftIndex? (leftIndex -1):0;
+ switch(leftIndex+w){
+ case 4:
+ switch(leftIndex){
+ case 0:
+#if RROP == GXcopy
+ *pdst++ = piQxelXor[0];
+ *pdst++ = piQxelXor[1];
+ *pdst-- = piQxelXor[2];
+#endif
+#if RROP == GXxor
+ *pdst++ ^= piQxelXor[0];
+ *pdst++ ^= piQxelXor[1];
+ *pdst-- ^= piQxelXor[2];
+#endif
+#if RROP == GXand
+ *pdst++ &= piQxelAnd[0];
+ *pdst++ &= piQxelAnd[1];
+ *pdst-- &= piQxelAnd[2];
+#endif
+#if RROP == GXor
+ *pdst++ |= piQxelOr[0];
+ *pdst++ |= piQxelOr[1];
+ *pdst-- |= piQxelOr[2];
+#endif
+#if RROP == GXset
+ *pdst = DoRRop((*pdst), piQxelAnd[0], piQxelXor[0]);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[1], piQxelXor[1]);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[2], piQxelXor[2]);
+ pdst--;
+#endif
+ pdst--;
+ break;
+ case 1:
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFFFFFF) | (piQxelXor[0] & 0xFF000000);
+ pdst++;
+ *pdst++ = piQxelXor[1];
+ *pdst-- = piQxelXor[2];
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[0] & 0xFF000000);
+ *pdst++ ^= piQxelXor[1];
+ *pdst-- ^= piQxelXor[2];
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[0] | 0x00FFFFFF);
+ *pdst++ &= piQxelAnd[1];
+ *pdst-- &= piQxelAnd[2];
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[0] & 0xFF000000);
+ *pdst++ |= piQxelOr[1];
+ *pdst-- |= piQxelOr[2];
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[0], piQxelXor[0], 0xFF000000);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[1], piQxelXor[1]);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[2], piQxelXor[2]);
+ pdst--;
+#endif
+ pdst--;
+ break;
+ case 2:
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFFFF) | (piQxelXor[1] & 0xFFFF0000);
+ pdst++;
+ *pdst-- = piQxelXor[2];
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[1] & 0xFFFF0000);
+ *pdst-- ^= piQxelXor[2];
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[1] | 0xFFFF);
+ *pdst-- &= piQxelAnd[2];
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[1] & 0xFFFF0000);
+ *pdst-- |= piQxelOr[2];
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[1], piQxelXor[1], 0xFFFF0000);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[2], piQxelXor[2]);
+ pdst--;
+#endif
+ break;
+ case 3:
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFF) | (piQxelXor[2] & 0xFFFFFF00);
+#endif
+#if RROP == GXxor
+ *pdst ^= (piQxelXor[2] & 0xFFFFFF00);
+#endif
+#if RROP == GXand
+ *pdst &= (piQxelAnd[2] | 0xFF);
+#endif
+#if RROP == GXor
+ *pdst |= (piQxelOr[2] & 0xFFFFFF00);
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[2], piQxelXor[2], 0xFFFFFF00);
+#endif
+ break;
+ }
+ break;
+ case 3:
+ switch(leftIndex){
+ case 0:
+#if RROP == GXcopy
+ *pdst++ = piQxelXor[0];
+ *pdst++ = piQxelXor[1];
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelXor[2] & 0xFF);
+ pdst--;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= piQxelXor[0];
+ *pdst++ ^= piQxelXor[1];
+ *pdst-- ^= (piQxelXor[2] & 0xFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= piQxelAnd[0];
+ *pdst++ &= piQxelAnd[1];
+ *pdst-- &= (piQxelAnd[2] | 0xFFFFFF00);
+#endif
+#if RROP == GXor
+ *pdst++ |= piQxelOr[0];
+ *pdst++ |= piQxelOr[1];
+
+ *pdst-- |= (piQxelOr[2] & 0xFF);
+#endif
+#if RROP == GXset
+ *pdst = DoRRop((*pdst), piQxelAnd[0], piQxelXor[0]);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[1], piQxelXor[1]);
+ pdst++;
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[2], piQxelXor[2], 0xFF);
+ pdst--;
+#endif
+ pdst--;
+ break;
+ case 1:
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFFFFFF) | (piQxelXor[0] & 0xFF000000);
+ pdst++;
+ *pdst++ = piQxelXor[1];
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelXor[2] & 0xFF);
+ pdst--;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[0] & 0xFF000000);
+ *pdst++ ^= piQxelXor[1];
+ *pdst-- ^= (piQxelXor[2] & 0xFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[0] | 0x00FFFFFF);
+ *pdst++ &= piQxelAnd[1];
+ *pdst-- &= (piQxelAnd[2] | 0xFFFFFF00);
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[0] & 0xFF000000);
+ *pdst++ |= piQxelOr[1];
+ *pdst-- |= (piQxelOr[2] & 0xFF);
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[0], piQxelXor[0], 0xFF000000);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[1], piQxelXor[1]);
+ pdst++;
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[2], piQxelXor[2], 0xFF);
+ pdst--;
+#endif
+ pdst--;
+ break;
+ case 2:
+/* pdst++;*/
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFFFF) | (piQxelXor[1] & 0xFFFF0000);
+ pdst++;
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelXor[2] & 0xFF);
+ pdst--;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[1] & 0xFFFF0000);
+ *pdst-- ^= (piQxelXor[2] & 0xFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[1] | 0xFFFF);
+ *pdst-- &= (piQxelAnd[2] | 0xFFFFFF00);
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[1] & 0xFFFF0000);
+ *pdst-- |= (piQxelOr[2] & 0xFF);
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[1], piQxelXor[1], 0xFFFF0000);
+ pdst++;
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[2], piQxelXor[2], 0xFF);
+ pdst--;
+#endif
+ break;
+ }
+ break;
+ case 2: /* leftIndex + w = 2*/
+ if(leftIndex){
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFFFFFF) | (piQxelXor[0] & 0xFF000000);
+ pdst++;
+ *pdst = ((*pdst) & 0xFFFF0000) | (piQxelXor[1] & 0xFFFF);
+ pdst--;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[0] & 0xFF000000);
+ *pdst-- ^= (piQxelXor[1] & 0xFFFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[0] | 0xFFFFFF);
+ *pdst-- &= (piQxelAnd[1] | 0xFFFF0000);
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[0] & 0xFF000000);
+ *pdst-- |= (piQxelOr[1] & 0xFFFF);
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[0], piQxelXor[0], 0xFF000000);
+ pdst++;
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[1], piQxelXor[1], 0xFFFF);
+ pdst--;
+#endif
+ }
+ else{ /*case 2 leftIndex === 0 */
+#if RROP == GXcopy
+ *pdst++ = piQxelXor[0];
+ *pdst = ((*pdst) & 0xFFFF0000) | (piQxelXor[1] & 0xFFFF);
+ pdst--;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= piQxelXor[0];
+ *pdst-- ^= (piQxelXor[1] & 0xFFFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= piQxelAnd[0];
+ *pdst-- &= (piQxelAnd[1] | 0xFFFF0000);
+#endif
+#if RROP == GXor
+ *pdst++ |= piQxelOr[0];
+ *pdst-- |= (piQxelOr[1] & 0xFFFF);
+#endif
+#if RROP == GXset
+ *pdst = DoRRop((*pdst), piQxelAnd[0], piQxelXor[0]);
+ pdst++;
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[1], piQxelXor[1], 0xFFFF);
+ pdst--;
+#endif
+ }
+ break;
+ case 1: /*only if leftIndex = 0 and w = 1*/
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFF000000) | (piQxelXor[0] & 0xFFFFFF);
+#endif
+#if RROP == GXxor
+ *pdst ^= (piQxelXor[0] & 0xFFFFFF);
+#endif
+#if RROP == GXand
+ *pdst &= (piQxelAnd[0] | 0xFF000000);
+#endif
+#if RROP == GXor
+ *pdst |= (piQxelOr[0] & 0xFFFFFF);
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[0], piQxelXor[0], 0xFFFFFF);
+#endif
+ break;
+ case 0: /*never*/
+ break;
+ default:
+ {
+ switch(leftIndex){
+ case 0:
+ break;
+ case 1:
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFFFFFF) | (piQxelXor[0] & 0xFF000000);
+ pdst++;
+ *pdst++ = piQxelXor[1];
+ *pdst++ = piQxelXor[2];
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[0] & 0xFF000000);
+ *pdst++ ^= piQxelXor[1];
+ *pdst++ ^= piQxelXor[2];
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[0] | 0xFFFFFF);
+ *pdst++ &= piQxelAnd[1];
+ *pdst++ &= piQxelAnd[2];
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[0] & 0xFF000000);
+ *pdst++ |= piQxelOr[1];
+ *pdst++ |= piQxelOr[2];
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[0], piQxelXor[0], 0xFF000000);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[1], piQxelXor[1]);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[2], piQxelXor[2]);
+ pdst++;
+#endif
+ break;
+ case 2:
+#if RROP == GXcopy
+ *pdst = (((*pdst) & 0xFFFF) | (piQxelXor[1] & 0xFFFF0000));
+ pdst++;
+ *pdst++ = piQxelXor[2];
+#endif
+#if RROP == GXxor
+ *pdst++ ^=(piQxelXor[1] & 0xFFFF0000);
+ *pdst++ ^= piQxelXor[2];
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[1] | 0xFFFF);
+ *pdst++ &= piQxelAnd[2];
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[1] & 0xFFFF0000);
+ *pdst++ |= piQxelOr[2];
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[1], piQxelXor[1], 0xFFFF0000);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[2], piQxelXor[2]);
+ pdst++;
+#endif
+ break;
+ case 3:
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFF) | (piQxelXor[2] & 0xFFFFFF00);
+ pdst++;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[2] & 0xFFFFFF00);
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[2] | 0xFF);
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[2] & 0xFFFFFF00);
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[2], piQxelXor[2], 0xFFFFFF00);
+ pdst++;
+#endif
+ break;
+ }
+ while(nlmiddle--){
+#if RROP == GXcopy
+ *pdst++ = piQxelXor[0];
+ *pdst++ = piQxelXor[1];
+ *pdst++ = piQxelXor[2];
+#endif
+#if RROP == GXxor
+ *pdst++ ^= piQxelXor[0];
+ *pdst++ ^= piQxelXor[1];
+ *pdst++ ^= piQxelXor[2];
+#endif
+#if RROP == GXand
+ *pdst++ &= piQxelAnd[0];
+ *pdst++ &= piQxelAnd[1];
+ *pdst++ &= piQxelAnd[2];
+#endif
+#if RROP == GXor
+ *pdst++ |= piQxelOr[0];
+ *pdst++ |= piQxelOr[1];
+ *pdst++ |= piQxelOr[2];
+#endif
+#if RROP == GXset
+ *pdst = DoRRop((*pdst), piQxelAnd[0], piQxelXor[0]);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[1], piQxelXor[1]);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[2], piQxelXor[2]);
+ pdst++;
+#endif
+ }
+ switch(rightIndex){
+ case 0:
+ break;
+ case 1:
+#if RROP == GXcopy
+ *pdst = ((*pdst) & 0xFF000000) | (piQxelXor[0] & 0xFFFFFF);
+ pdst++;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= (piQxelXor[0] & 0xFFFFFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= (piQxelAnd[0] | 0xFF);
+#endif
+#if RROP == GXor
+ *pdst++ |= (piQxelOr[0] & 0xFFFFFF);
+#endif
+#if RROP == GXset
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[0], piQxelXor[0], 0xFFFFFF);
+#endif
+ break;
+ case 2:
+#if RROP == GXcopy
+ *pdst++ = piQxelXor[0];
+ *pdst = ((*pdst) & 0xFFFF0000) | (piQxelXor[1] & 0xFFFF);
+ pdst++;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= piQxelXor[0];
+ *pdst++ ^= (piQxelXor[1] & 0xFFFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= piQxelAnd[0];
+ *pdst++ &= (piQxelAnd[1] | 0xFFFF0000);
+#endif
+#if RROP == GXor
+ *pdst++ |= piQxelOr[0];
+ *pdst++ |= (piQxelOr[1] & 0xFFFF);
+#endif
+#if RROP == GXset
+ *pdst = DoRRop((*pdst), piQxelAnd[0], piQxelXor[0]);
+ pdst++;
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[1], piQxelXor[1], 0xFFFF);
+ pdst++;
+#endif
+ break;
+ case 3:
+#if RROP == GXcopy
+ *pdst++ = piQxelXor[0];
+ *pdst++ = piQxelXor[1];
+ *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelXor[2] & 0xFF);
+ pdst++;
+#endif
+#if RROP == GXxor
+ *pdst++ ^= piQxelXor[0];
+ *pdst++ ^= piQxelXor[1];
+ *pdst++ ^= (piQxelXor[2] & 0xFF);
+#endif
+#if RROP == GXand
+ *pdst++ &= piQxelAnd[0];
+ *pdst++ &= piQxelAnd[1];
+ *pdst++ &= (piQxelAnd[2] | 0xFFFFFF00);
+#endif
+#if RROP == GXor
+ *pdst++ |= piQxelOr[0];
+ *pdst++ |= piQxelOr[1];
+ *pdst++ |= (piQxelOr[2] & 0xFF);
+#endif
+#if RROP == GXset
+ *pdst = DoRRop((*pdst), piQxelAnd[0], piQxelXor[0]);
+ pdst++;
+ *pdst = DoRRop((*pdst), piQxelAnd[1], piQxelXor[1]);
+ pdst++;
+ *pdst = DoMaskRRop((*pdst), piQxelAnd[2], piQxelXor[2], 0xFF);
+ pdst++;
+#endif
+ break;
+ }
+ }
+}
+#else
+#if PSZ == 8
+ if (w <= PGSZB)
+ {
+ register char *addrb;
+
+ addrb = ((char *) pdst) + x;
+ while (w--)
+ {
+ RROP_SOLID (addrb);
+ addrb++;
+ }
+ }
+#else
+ if ((x & PIM) + w <= PPW)
+ {
+ pdst += x >> PWSH;
+ maskpartialbits (x, w, startmask);
+ RROP_SOLID_MASK (pdst, startmask);
+ }
+#endif
+ else
+ {
+ pdst += x >> PWSH;
+ maskbits (x, w, startmask, endmask, nlmiddle);
+ if (startmask)
+ {
+ RROP_SOLID_MASK (pdst, startmask);
+ ++pdst;
+ }
+
+ RROP_SPAN(pdst,nlmiddle)
+ if (endmask)
+ {
+ RROP_SOLID_MASK (pdst, endmask);
+ }
+ }
+#endif
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+ RROP_UNDECLARE
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbtab.h b/nx-X11/programs/Xserver/cfb/cfbtab.h
new file mode 100644
index 000000000..d95efd66d
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbtab.h
@@ -0,0 +1,16 @@
+/* $XFree86$ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _CFBTAB_H_
+#define _CFBTAB_H_
+
+/* prototypes */
+#if 0
+extern int starttab[32], endtab[32];
+extern unsigned int partmasks[32][32];
+#endif
+
+#endif /* _CFBTAB_H_ */
diff --git a/nx-X11/programs/Xserver/cfb/cfbteblt8.c b/nx-X11/programs/Xserver/cfb/cfbteblt8.c
new file mode 100644
index 000000000..f58a07dc6
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbteblt8.c
@@ -0,0 +1,591 @@
+/*
+ * TEGblt - ImageText expanded glyph fonts only. For
+ * 8 bit displays, in Copy mode with no clipping.
+ */
+
+/* $XFree86: xc/programs/Xserver/cfb/cfbteblt8.c,v 1.5 2001/10/28 03:33:02 tsi Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+
+/* $Xorg: cfbteblt8.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#if PSZ == 8
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "cfb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "cfbmskbits.h"
+#include "cfb8bit.h"
+
+/*
+ * this code supports up to 5 characters at a time. The performance
+ * differences between 4 and 5 is usually small (~7% on PMAX) and
+ * frequently negative (SPARC and Sun3), so this file is compiled
+ * only once for now. If you want to use the other options, you'll
+ * need to hack cfbgc.c as well.
+ */
+
+#ifndef NGLYPHS
+#define NGLYPHS 4
+#define DO_COMMON
+#endif
+
+#ifdef DO_COMMON
+#define CFBTEGBLT8 cfbTEGlyphBlt8
+#endif
+
+/*
+ * On little-endian machines (or where fonts are padded to 32-bit
+ * boundaries) we can use some magic to avoid the expense of getleftbits
+ */
+
+#if ((BITMAP_BIT_ORDER == LSBFirst && NGLYPHS >= 4) || GLYPHPADBYTES == 4)
+
+#if GLYPHPADBYTES == 1
+typedef unsigned char *glyphPointer;
+#define USE_LEFTBITS
+#endif
+
+#if GLYPHPADBYTES == 2
+typedef unsigned short *glyphPointer;
+#define USE_LEFTBITS
+#endif
+
+#if GLYPHPADBYTES == 4
+typedef unsigned int *glyphPointer;
+#endif
+
+#define GetBitsL c = BitLeft (*leftChar++, lshift)
+#define NGetBits1S(r) c = BitRight(*char1++ r, xoff1)
+#define NGetBits1L(r) GetBitsL | BitRight(*char1++ r, xoff1)
+#define NGetBits1U(r) c = *char1++ r
+#define NGetBits2S(r) NGetBits1S(| BitRight(*char2++ r, widthGlyph))
+#define NGetBits2L(r) NGetBits1L(| BitRight(*char2++ r, widthGlyph))
+#define NGetBits2U(r) NGetBits1U(| BitRight(*char2++ r, widthGlyph))
+#define NGetBits3S(r) NGetBits2S(| BitRight(*char3++ r, widthGlyph))
+#define NGetBits3L(r) NGetBits2L(| BitRight(*char3++ r, widthGlyph))
+#define NGetBits3U(r) NGetBits2U(| BitRight(*char3++ r, widthGlyph))
+#define NGetBits4S(r) NGetBits3S(| BitRight(*char4++ r, widthGlyph))
+#define NGetBits4L(r) NGetBits3L(| BitRight(*char4++ r, widthGlyph))
+#define NGetBits4U(r) NGetBits3U(| BitRight(*char4++ r, widthGlyph))
+#define NGetBits5S(r) NGetBits4S(| BitRight(*char5++ r, widthGlyph))
+#define NGetBits5L(r) NGetBits4L(| BitRight(*char5++ r, widthGlyph))
+#define NGetBits5U(r) NGetBits4U(| BitRight(*char5++ r, widthGlyph))
+#define GetBits1S c = BitRight(*char1++, xoff1)
+#define GetBits1L GetBitsL | BitRight(*char1++, xoff1)
+#define GetBits1U c = *char1++
+#define GetBits2S NGetBits1S(| BitRight(*char2++, widthGlyph))
+#define GetBits2L NGetBits1L(| BitRight(*char2++, widthGlyph))
+#define GetBits2U NGetBits1U(| BitRight(*char2++, widthGlyph))
+#define GetBits3S NGetBits2S(| BitRight(*char3++, widthGlyph))
+#define GetBits3L NGetBits2L(| BitRight(*char3++, widthGlyph))
+#define GetBits3U NGetBits2U(| BitRight(*char3++, widthGlyph))
+#define GetBits4S NGetBits3S(| BitRight(*char4++, widthGlyph))
+#define GetBits4L NGetBits3L(| BitRight(*char4++, widthGlyph))
+#define GetBits4U NGetBits3U(| BitRight(*char4++, widthGlyph))
+#define GetBits5S NGetBits4S(| BitRight(*char5++, widthGlyph))
+#define GetBits5L NGetBits4L(| BitRight(*char5++, widthGlyph))
+#define GetBits5U NGetBits4U(| BitRight(*char5++, widthGlyph))
+
+#else
+
+typedef unsigned int *glyphPointer;
+
+#define USE_LEFTBITS
+#define ALL_LEFTBITS
+
+#define GetBitsL WGetBitsL
+#define GetBits1S WGetBits1S
+#define GetBits1L WGetBits1L
+#define GetBits1U WGetBits1U
+
+#define GetBits2S GetBits1S Get1Bits (char2, tmpSrc) \
+ c |= BitRight(tmpSrc, xoff2);
+#define GetBits2L GetBits1L Get1Bits (char2, tmpSrc) \
+ c |= BitRight(tmpSrc, xoff2);
+#define GetBits2U GetBits1U Get1Bits (char2, tmpSrc) \
+ c |= BitRight(tmpSrc, xoff2);
+
+#define GetBits3S GetBits2S Get1Bits (char3, tmpSrc) \
+ c |= BitRight(tmpSrc, xoff3);
+#define GetBits3L GetBits2L Get1Bits (char3, tmpSrc) \
+ c |= BitRight(tmpSrc, xoff3);
+#define GetBits3U GetBits2U Get1Bits (char3, tmpSrc) \
+ c |= BitRight(tmpSrc, xoff3);
+
+#define GetBits4S GetBits3S Get1Bits (char4, tmpSrc) \
+ c |= BitRight(tmpSrc, xoff4);
+#define GetBits4L GetBits3L Get1Bits (char4, tmpSrc) \
+ c |= BitRight(tmpSrc, xoff4);
+#define GetBits4U GetBits3U Get1Bits (char4, tmpSrc) \
+ c |= BitRight(tmpSrc, xoff4);
+
+#define GetBits5S GetBits4S Get1Bits (char5, tmpSrc) \
+ c |= BitRight(tmpSrc, xoff5);
+#define GetBits5L GetBits4L Get1Bits (char5, tmpSrc) \
+ c |= BitRight(tmpSrc, xoff5);
+#define GetBits5U GetBits4U Get1Bits (char5, tmpSrc) \
+ c |= BitRight(tmpSrc, xoff5);
+
+#endif
+
+#ifdef USE_LEFTBITS
+
+#define IncChar(c) (c = (glyphPointer) (((char *) c) + glyphBytes))
+
+#define Get1Bits(ch,dst) glyphbits (ch, widthGlyph, glyphMask, dst); \
+ IncChar (ch);
+
+#define glyphbits(bits,width,mask,dst) getleftbits(bits,width,dst); \
+ dst &= mask;
+
+#define WGetBitsL Get1Bits(leftChar,c); \
+ c = BitLeft (c, lshift);
+#define WGetBits1S Get1Bits (char1, c) \
+ c = BitRight (c, xoff1);
+#define WGetBits1L WGetBitsL Get1Bits (char1, tmpSrc) \
+ c |= BitRight (tmpSrc, xoff1);
+#define WGetBits1U Get1Bits (char1, c)
+
+#else
+#define WGetBitsL GetBitsL
+#define WGetBits1S GetBits1S
+#define WGetBits1L GetBits1L
+#define WGetBits1U GetBits1U
+#endif
+
+#if NGLYPHS == 2
+# define GetBitsNS GetBits2S
+# define GetBitsNL GetBits2L
+# define GetBitsNU GetBits2U
+# define LastChar char2
+#ifndef CFBTEGBLT8
+# define CFBTEGBLT8 cfbTEGlyphBlt8x2
+#endif
+#endif
+#if NGLYPHS == 3
+# define GetBitsNS GetBits3S
+# define GetBitsNL GetBits3L
+# define GetBitsNU GetBits3U
+# define LastChar char3
+#ifndef CFBTEGBLT8
+# define CFBTEGBLT8 cfbTEGlyphBlt8x3
+#endif
+#endif
+#if NGLYPHS == 4
+# define GetBitsNS GetBits4S
+# define GetBitsNL GetBits4L
+# define GetBitsNU GetBits4U
+# define LastChar char4
+#ifndef CFBTEGBLT8
+# define CFBTEGBLT8 cfbTEGlyphBlt8x4
+#endif
+#endif
+#if NGLYPHS == 5
+# define GetBitsNS GetBits5S
+# define GetBitsNL GetBits5L
+# define GetBitsNU GetBits5U
+# define LastChar char5
+#ifndef CFBTEGBLT8
+# define CFBTEGBLT8 cfbTEGlyphBlt8x5
+#endif
+#endif
+
+/* another ugly giant macro */
+#define SwitchEm switch (ew) \
+ { \
+ case 0: \
+ break; \
+ case 1: \
+ while (hTmp--) { \
+ GetBits; \
+ StoreBits0 \
+ Loop \
+ } \
+ break; \
+ case 2: \
+ while (hTmp--) { \
+ GetBits; \
+ StoreBits0 FirstStep StoreBits(1) \
+ Loop \
+ } \
+ break; \
+ case 3: \
+ while (hTmp--) { \
+ GetBits; \
+ StoreBits0 FirstStep StoreBits(1) Step StoreBits(2) \
+ Loop \
+ } \
+ break; \
+ case 4: \
+ while (hTmp--) { \
+ GetBits; \
+ StoreBits0 FirstStep StoreBits(1) Step \
+ StoreBits(2) Step StoreBits(3) \
+ Loop \
+ } \
+ break; \
+ case 5: \
+ while (hTmp--) { \
+ GetBits; \
+ StoreBits0 FirstStep StoreBits(1) Step \
+ StoreBits(2) Step StoreBits(3) Step \
+ StoreBits(4) \
+ Loop \
+ } \
+ break; \
+ case 6: \
+ while (hTmp--) { \
+ GetBits; \
+ StoreBits0 FirstStep StoreBits(1) Step \
+ StoreBits(2) Step StoreBits(3) Step \
+ StoreBits(4) Step StoreBits(5) \
+ Loop \
+ } \
+ break; \
+ case 7: \
+ while (hTmp--) { \
+ GetBits; \
+ StoreBits0 FirstStep StoreBits(1) Step \
+ StoreBits(2) Step StoreBits(3) Step \
+ StoreBits(4) Step StoreBits(5) Step \
+ StoreBits(6) \
+ Loop \
+ } \
+ break; \
+ case 8: \
+ while (hTmp--) { \
+ GetBits; \
+ StoreBits0 FirstStep StoreBits(1) Step \
+ StoreBits(2) Step StoreBits(3) Step \
+ StoreBits(4) Step StoreBits(5) Step \
+ StoreBits(6) Step StoreBits(7) \
+ Loop \
+ } \
+ break; \
+ }
+
+#ifdef FAST_CONSTANT_OFFSET_MODE
+#define StorePixels(o,p) dst[o] = p
+#define Loop dst += widthDst;
+#else
+#define StorePixels(o,p) *dst++ = (p)
+#define Loop dst += widthLeft;
+#endif
+
+#define Step NextBitGroup(c);
+
+#if (BITMAP_BIT_ORDER == MSBFirst)
+#define StoreBits(o) StorePixels(o,GetPixelGroup(c));
+#define FirstStep Step
+#else
+#if PGSZ == 64
+#define StoreBits(o) StorePixels(o,cfb8Pixels[(c) & PGSZBMSK]);
+#define FirstStep Step
+#else /* PGSZ == 32 */
+#define StoreBits(o) StorePixels(o,*((CfbBits *) (((char *) cfb8Pixels) + (c & 0x3c))));
+#define FirstStep c = BitLeft (c, 2);
+#endif /* PGSZ */
+#endif /* BITMAP_BIT_ORDER */
+
+
+void
+CFBTEGBLT8 (pDrawable, pGC, xInit, yInit, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int xInit, yInit;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ register CfbBits c;
+ register CfbBits *dst;
+ register CfbBits leftMask, rightMask;
+ register int hTmp;
+ register int xoff1;
+ register glyphPointer char1;
+ register glyphPointer char2;
+#if NGLYPHS >= 3
+ register glyphPointer char3;
+#endif
+#if NGLYPHS >= 4
+ register glyphPointer char4;
+#endif
+#if NGLYPHS >= 5
+ register glyphPointer char5;
+#endif
+#ifdef ALL_LEFTBITS
+ int xoff2, xoff3, xoff4, xoff5;
+#endif
+
+ FontPtr pfont = pGC->font;
+ CfbBits *dstLine;
+ glyphPointer oldRightChar;
+ CfbBits *pdstBase;
+ glyphPointer leftChar;
+ int widthDst;
+#ifndef FAST_CONSTANT_OFFSET_MODE
+ int widthLeft;
+#endif
+ int widthGlyph;
+ int h;
+ int ew;
+ int x, y;
+ BoxRec bbox; /* for clipping */
+ int lshift;
+ int widthGlyphs;
+#ifdef USE_LEFTBITS
+ register CfbBits glyphMask;
+ register CfbBits tmpSrc;
+ register int glyphBytes;
+#endif
+
+ widthGlyph = FONTMAXBOUNDS(pfont,characterWidth);
+ h = FONTASCENT(pfont) + FONTDESCENT(pfont);
+ if (!h)
+ return;
+ x = xInit + FONTMAXBOUNDS(pfont,leftSideBearing) + pDrawable->x;
+ y = yInit - FONTASCENT(pfont) + pDrawable->y;
+ bbox.x1 = x;
+ bbox.x2 = x + (widthGlyph * nglyph);
+ bbox.y1 = y;
+ bbox.y2 = y + h;
+
+ switch (RECT_IN_REGION(pGC->pScreen, cfbGetCompositeClip(pGC), &bbox))
+ {
+ case rgnPART:
+ cfbImageGlyphBlt8(pDrawable, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
+ case rgnOUT:
+ return;
+ }
+
+ if (!cfb8CheckPixels (pGC->fgPixel, pGC->bgPixel))
+ cfb8SetPixels (pGC->fgPixel, pGC->bgPixel);
+
+ leftChar = 0;
+
+ cfbGetLongWidthAndPointer(pDrawable, widthDst, pdstBase)
+
+#if NGLYPHS == 2
+ widthGlyphs = widthGlyph << 1;
+#else
+#if NGLYPHS == 4
+ widthGlyphs = widthGlyph << 2;
+#else
+ widthGlyphs = widthGlyph * NGLYPHS;
+#endif
+#endif
+
+#ifdef USE_LEFTBITS
+ glyphMask = mfbGetendtab(widthGlyph);
+ glyphBytes = GLYPHWIDTHBYTESPADDED(*ppci);
+#endif
+
+ pdstBase += y * widthDst;
+#ifdef DO_COMMON
+ if (widthGlyphs <= 32)
+#endif
+ while (nglyph >= NGLYPHS)
+ {
+ nglyph -= NGLYPHS;
+ hTmp = h;
+ dstLine = pdstBase + (x >> PWSH);
+ xoff1 = x & PIM;
+ char1 = (glyphPointer) FONTGLYPHBITS(pglyphBase, *ppci++);
+ char2 = (glyphPointer) FONTGLYPHBITS(pglyphBase, *ppci++);
+#ifdef ALL_LEFTBITS
+ xoff2 = xoff1 + widthGlyph;
+#endif
+#if NGLYPHS >= 3
+ char3 = (glyphPointer) FONTGLYPHBITS(pglyphBase, *ppci++);
+#ifdef ALL_LEFTBITS
+ xoff3 = xoff2 + widthGlyph;
+#endif
+#endif
+#if NGLYPHS >= 4
+ char4 = (glyphPointer) FONTGLYPHBITS(pglyphBase, *ppci++);
+#ifdef ALL_LEFTBITS
+ xoff4 = xoff3 + widthGlyph;
+#endif
+#endif
+#if NGLYPHS >= 5
+ char5 = (glyphPointer) FONTGLYPHBITS(pglyphBase, *ppci++);
+#ifdef ALL_LEFTBITS
+ xoff5 = xoff4 + widthGlyph;
+#endif
+#endif
+ oldRightChar = LastChar;
+ dst = dstLine;
+ if (xoff1)
+ {
+ ew = ((widthGlyphs - (PGSZB - xoff1)) >> PWSH) + 1;
+#ifndef FAST_CONSTANT_OFFSET_MODE
+ widthLeft = widthDst - ew;
+#endif
+ if (!leftChar)
+ {
+ leftMask = cfbendtab[xoff1];
+ rightMask = cfbstarttab[xoff1];
+
+#define StoreBits0 StorePixels (0, (dst[0] & leftMask) | \
+ (GetPixelGroup(c) & rightMask));
+#define GetBits GetBitsNS
+
+ SwitchEm
+
+#undef GetBits
+#undef StoreBits0
+
+ }
+ else
+ {
+ lshift = widthGlyph - xoff1;
+
+#define StoreBits0 StorePixels (0,GetPixelGroup(c));
+#define GetBits GetBitsNL
+
+ SwitchEm
+
+#undef GetBits
+#undef StoreBits0
+
+ }
+ }
+ else
+ {
+#if NGLYPHS == 4 && PGSZ == 32
+ ew = widthGlyph; /* widthGlyphs >> 2 */
+#else
+ ew = widthGlyphs >> PWSH;
+#endif
+#ifndef FAST_CONSTANT_OFFSET_MODE
+ widthLeft = widthDst - ew;
+#endif
+
+#define StoreBits0 StorePixels (0,GetPixelGroup(c));
+#define GetBits GetBitsNU
+
+ SwitchEm
+
+#undef GetBits
+#undef StoreBits0
+
+ }
+ x += widthGlyphs;
+ leftChar = oldRightChar;
+ }
+ while (nglyph--)
+ {
+ xoff1 = x & PIM;
+ char1 = (glyphPointer) FONTGLYPHBITS(pglyphBase, *ppci++);
+ hTmp = h;
+ dstLine = pdstBase + (x >> PWSH);
+ oldRightChar = char1;
+ dst = dstLine;
+ if (xoff1)
+ {
+ ew = ((widthGlyph - (PGSZB - xoff1)) >> PWSH) + 1;
+#ifndef FAST_CONSTANT_OFFSET_MODE
+ widthLeft = widthDst - ew;
+#endif
+ if (!leftChar)
+ {
+ leftMask = cfbendtab[xoff1];
+ rightMask = cfbstarttab[xoff1];
+
+#define StoreBits0 StorePixels (0, (dst[0] & leftMask) | \
+ (GetPixelGroup(c) & rightMask));
+#define GetBits WGetBits1S
+
+ SwitchEm
+#undef GetBits
+#undef StoreBits0
+
+ }
+ else
+ {
+ lshift = widthGlyph - xoff1;
+
+#define StoreBits0 StorePixels (0,GetPixelGroup(c));
+#define GetBits WGetBits1L
+
+ SwitchEm
+#undef GetBits
+#undef StoreBits0
+
+ }
+ }
+ else
+ {
+ ew = widthGlyph >> PWSH;
+
+#ifndef FAST_CONSTANT_OFFSET_MODE
+ widthLeft = widthDst - ew;
+#endif
+
+#define StoreBits0 StorePixels (0,GetPixelGroup(c));
+#define GetBits WGetBits1U
+
+ SwitchEm
+
+#undef GetBits
+#undef StoreBits0
+
+ }
+ x += widthGlyph;
+ leftChar = oldRightChar;
+ }
+ /*
+ * draw the tail of the last character
+ */
+ xoff1 = x & PIM;
+ if (xoff1)
+ {
+ rightMask = cfbstarttab[xoff1];
+ leftMask = cfbendtab[xoff1];
+ lshift = widthGlyph - xoff1;
+ dst = pdstBase + (x >> PWSH);
+ hTmp = h;
+ while (hTmp--)
+ {
+ GetBitsL;
+ *dst = (*dst & rightMask) | (GetPixelGroup(c) & leftMask);
+ dst += widthDst;
+ }
+ }
+}
+#endif /* PSZ == 8 */
diff --git a/nx-X11/programs/Xserver/cfb/cfbtegblt.c b/nx-X11/programs/Xserver/cfb/cfbtegblt.c
new file mode 100644
index 000000000..e3fb06f59
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbtegblt.c
@@ -0,0 +1,220 @@
+/* $Xorg: cfbtegblt.c,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/cfb/cfbtegblt.c,v 3.6tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "cfb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "cfbmskbits.h"
+#include "mi.h"
+#define MFB_CONSTS_ONLY
+#include "maskbits.h"
+
+/*
+ this works for fonts with glyphs <= 32 bits wide, on an
+ arbitrarily deep display. Use cfbTEGlyphBlt8 for 8 bit displays.
+
+ This should be called only with a terminal-emulator font;
+this means that the FIXED_METRICS flag is set, and that
+glyphbounds == charbounds.
+
+ in theory, this goes faster; even if it doesn't, it reduces the
+flicker caused by writing a string over itself with image text (since
+the background gets repainted per character instead of per string.)
+this seems to be important for some converted X10 applications.
+
+ Image text looks at the bits in the glyph and the fg and bg in the
+GC. it paints a rectangle, as defined in the protocol dcoument,
+and the paints the characters.
+
+*/
+
+void
+cfbTEGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ FontPtr pfont = pGC->font;
+ int widthDst;
+ CfbBits *pdstBase; /* pointer to longword with top row
+ of current glyph */
+
+ int w; /* width of glyph and char */
+ int h; /* height of glyph and char */
+ register int xpos=x; /* current x%32 */
+ int ypos=y; /* current y%32 */
+ register unsigned char *pglyph;
+ int widthGlyph;
+
+ register CfbBits *pdst;/* pointer to current longword in dst */
+ int hTmp; /* counter for height */
+ BoxRec bbox; /* for clipping */
+
+ register int wtmp,xtemp,width;
+ CfbBits bgfill,fgfill,*ptemp,tmpDst1,tmpDst2,*pdtmp;
+#if PSZ != 24
+ int tmpx;
+#endif
+
+ xpos += pDrawable->x;
+ ypos += pDrawable->y;
+
+ cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase)
+
+ wtmp = FONTMAXBOUNDS(pfont,characterWidth);
+ h = FONTASCENT(pfont) + FONTDESCENT(pfont);
+ widthGlyph = GLYPHWIDTHBYTESPADDED(*ppci);
+
+ xpos += FONTMAXBOUNDS(pfont,leftSideBearing);
+ ypos -= FONTASCENT(pfont);
+
+ bbox.x1 = xpos;
+ bbox.x2 = xpos + (wtmp * nglyph);
+ bbox.y1 = ypos;
+ bbox.y2 = ypos + h;
+
+ fgfill = PFILL(pGC->fgPixel);
+ bgfill = PFILL(pGC->bgPixel);
+
+ switch (RECT_IN_REGION(pGC->pScreen, cfbGetCompositeClip(pGC), &bbox))
+ {
+ case rgnOUT:
+ break;
+ case rgnPART:
+ /* this is the WRONG thing to do, but it works.
+ calling the non-terminal text is easy, but slow, given
+ what we know about the font.
+
+ the right thing to do is something like:
+ for each clip rectangle
+ compute at which row the glyph starts to be in it,
+ and at which row the glyph ceases to be in it
+ compute which is the first glyph inside the left
+ edge, and the last one inside the right edge
+ draw a fractional first glyph, using only
+ the rows we know are in
+ draw all the whole glyphs, using the appropriate rows
+ draw any pieces of the last glyph, using the right rows
+
+ this way, the code would take advantage of knowing that
+ all glyphs are the same height and don't overlap.
+
+ one day...
+ */
+ cfbImageGlyphBlt8(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ break;
+ case rgnIN:
+
+ pdtmp = pdstBase + (widthDst * ypos);
+ while(nglyph--)
+ {
+
+ pglyph = FONTGLYPHBITS(pglyphBase, *ppci++);
+ pdst = pdtmp;
+ hTmp = h;
+
+ while (hTmp--)
+ {
+ x = xpos;
+ width = wtmp;
+ xtemp = 0;
+
+ while (width > 0)
+ {
+#if PSZ == 24
+ w = 1;
+ ptemp = (CfbBits *)(pglyph + ((xtemp *3)>> 2));
+ getstipplepixels24(ptemp,xtemp,0,&bgfill,&tmpDst1, xtemp);
+ getstipplepixels24(ptemp,xtemp,1,&fgfill,&tmpDst2, xtemp);
+#else
+ tmpx = x & PIM;
+ w = min(width, PPW - tmpx);
+ w = min(w, (PGSZ - xtemp));
+ ptemp = (CfbBits *)(pglyph + (xtemp >> MFB_PWSH));
+ getstipplepixels(ptemp,xtemp,w,0,&bgfill,&tmpDst1);
+ getstipplepixels(ptemp,xtemp,w,1,&fgfill,&tmpDst2);
+#endif
+
+ {
+ CfbBits tmpDst = tmpDst1 | tmpDst2;
+#if PSZ == 24
+ CfbBits *pdsttmp = pdst + ((x*3) >> 2);
+ putbits24(tmpDst,w,pdsttmp,pGC->planemask,x);
+#else
+ CfbBits *pdsttmp = pdst + (x >> PWSH);
+ putbits(tmpDst,tmpx,w,pdsttmp,pGC->planemask);
+#endif
+ }
+ x += w;
+ xtemp += w;
+ width -= w;
+ }
+ pglyph += widthGlyph;
+ pdst += widthDst;
+ }
+ xpos += wtmp;
+ }
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbtile32.c b/nx-X11/programs/Xserver/cfb/cfbtile32.c
new file mode 100644
index 000000000..96e5620b7
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbtile32.c
@@ -0,0 +1,519 @@
+/*
+ * Fill 32 bit tiled rectangles. Used by both PolyFillRect and PaintWindow.
+ * no depth dependencies.
+ */
+/* $XFree86: xc/programs/Xserver/cfb/cfbtile32.c,v 3.6tsi Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+
+/* $Xorg: cfbtile32.c,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "cfb8bit.h"
+
+#include "mergerop.h"
+
+#include "mi.h"
+#include "mispans.h"
+
+#ifdef sparc
+#define SHARED_IDCACHE
+#endif
+
+#if PSZ == 24
+#define STORE(p) (*(p) = MROP_PREBUILT_SOLID(srcpix,*(p)))
+/*#define STORE24(p,index) {\
+ register int idx = ((index) & 3)<< 1; \
+ *(p) = (((MROP_PREBUILT_SOLID(srcpix,*(p))<<cfb24Shift[idx])&cfbmask[idx])| \
+ (*(p)&cfbrmask[idx])); \
+ idx++; \
+ (p)++; \
+ *(p) = (((MROP_PREBUILT_SOLID(srcpix,*(p))>>cfb24Shift[idx])&cfbmask[idx])| \
+ (*(p)&cfbrmask[idx])); \
+ (p)--; \
+ }*/
+#define STORE24(p,index) MROP_PREBUILT_SOLID24(srcpix, (p), index)
+
+#define STORE_MASK(p,mask) (*(p) = MROP_PREBUILT_MASK(srcpix,*(p),(mask)))
+#define QSTORE(p) ((*(p) = MROP_PREBUILT_SOLID(((srcpix<<24)|srcpix),*(p))), \
+ (p)++,(*(p) = MROP_PREBUILT_SOLID(((srcpix<<16)|(srcpix>>8)),*(p))), \
+ (p)++,(*(p) = MROP_PREBUILT_SOLID(((srcpix<<8)|(srcpix>>16)),*(p))))
+
+#if (MROP == Mcopy) && defined(FAST_CONSTANT_OFFSET_MODE) && defined(SHARED_IDCACHE)
+# define Expand(left,right) {\
+ int part = nlwMiddle & ((PGSZB*2)-1); \
+ nlwMiddle *= 3; \
+ nlwMiddle >>= PWSH + 3; \
+ while (h--) { \
+ srcpix = psrc[srcy]; \
+ MROP_PREBUILD(srcpix); \
+ ++srcy; \
+ if (srcy == tileHeight) \
+ srcy = 0; \
+ left \
+ p += part; \
+ switch (part) { \
+ case 7: \
+ STORE24(p - 7, xtmp - 7); \
+ case 6: \
+ STORE24(p - 6, xtmp - 6); \
+ case 5: \
+ STORE24(p - 5, xtmp - 5); \
+ case 4: \
+ STORE24(p - 4, xtmp - 4); \
+ case 3: \
+ STORE24(p - 3, xtmp - 3); \
+ case 2: \
+ STORE24(p - 2, xtmp - 2); \
+ case 1: \
+ STORE24(p - 1, xtmp - 1); \
+ } \
+ nlw = nlwMiddle; \
+ while (nlw) { \
+ STORE24 (p + 0, xtmp + 0); \
+ STORE24 (p + 1, xtmp + 1); \
+ STORE24 (p + 2, xtmp + 2); \
+ STORE24 (p + 3, xtmp + 3); \
+ STORE24 (p + 4, xtmp + 4); \
+ STORE24 (p + 5, xtmp + 5); \
+ STORE24 (p + 6, xtmp + 6); \
+ STORE24 (p + 7, xtmp + 7); \
+ p += 8; \
+ xtmp += 8; \
+ nlw--; \
+ } \
+ right \
+ p += nlwExtra; \
+ } \
+}
+#else
+#define Expand(left,right) {\
+ while (h--) { \
+ srcpix = psrc[srcy]; \
+ MROP_PREBUILD(srcpix); \
+ ++srcy; \
+ if (srcy == tileHeight) \
+ srcy = 0; \
+ left \
+ while (nlw--) \
+ { \
+ STORE24(p,xtmp); \
+ if(xtmp&3) p++; \
+ xtmp++; \
+ } \
+ right \
+ p += nlwExtra; \
+ } \
+}
+#endif
+#else /*PSZ != 24*/
+#define STORE(p) (*(p) = MROP_PREBUILT_SOLID(srcpix,*(p)))
+
+#if (MROP == Mcopy) && defined(FAST_CONSTANT_OFFSET_MODE) && defined(SHARED_IDCACHE)
+# define Expand(left,right) {\
+ int part = nlwMiddle & ((PGSZB*2)-1); \
+ nlwMiddle >>= PWSH + 1; \
+ while (h--) { \
+ srcpix = psrc[srcy]; \
+ MROP_PREBUILD(srcpix); \
+ ++srcy; \
+ if (srcy == tileHeight) \
+ srcy = 0; \
+ left \
+ p += part; \
+ switch (part) { \
+ case 7: \
+ STORE(p - 7); \
+ case 6: \
+ STORE(p - 6); \
+ case 5: \
+ STORE(p - 5); \
+ case 4: \
+ STORE(p - 4); \
+ case 3: \
+ STORE(p - 3); \
+ case 2: \
+ STORE(p - 2); \
+ case 1: \
+ STORE(p - 1); \
+ } \
+ nlw = nlwMiddle; \
+ while (nlw) { \
+ STORE (p + 0); \
+ STORE (p + 1); \
+ STORE (p + 2); \
+ STORE (p + 3); \
+ STORE (p + 4); \
+ STORE (p + 5); \
+ STORE (p + 6); \
+ STORE (p + 7); \
+ p += 8; \
+ nlw--; \
+ } \
+ right \
+ p += nlwExtra; \
+ } \
+}
+#else
+#define Expand(left,right) {\
+ while (h--) { \
+ srcpix = psrc[srcy]; \
+ MROP_PREBUILD(srcpix); \
+ ++srcy; \
+ if (srcy == tileHeight) \
+ srcy = 0; \
+ left \
+ nlw = nlwMiddle; \
+ while (nlw--) \
+ { \
+ STORE(p); \
+ p++; \
+ } \
+ right \
+ p += nlwExtra; \
+ } \
+}
+#endif
+#endif /*PSZ == 24*/
+
+void
+MROP_NAME(cfbFillRectTile32) (pDrawable, pGC, nBox, pBox)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nBox; /* number of boxes to fill */
+ BoxPtr pBox; /* pointer to list of boxes to fill */
+{
+ register CfbBits srcpix;
+ CfbBits *psrc; /* pointer to bits in tile, if needed */
+ int tileHeight; /* height of the tile */
+
+ int nlwDst; /* width in longwords of the dest pixmap */
+ int w; /* width of current box */
+ register int h; /* height of current box */
+ register CfbBits startmask;
+ register CfbBits endmask; /* masks for reggedy bits at either end of line */
+ int nlwMiddle; /* number of longwords between sides of boxes */
+ int nlwExtra; /* to get from right of box to left of next span */
+ register int nlw = 0; /* loop version of nlwMiddle */
+ register CfbBits *p; /* pointer to bits we're writing */
+ int y; /* current scan line */
+ int srcy; /* current tile position */
+
+ CfbBits *pbits;/* pointer to start of pixmap */
+ PixmapPtr tile; /* rotated, expanded tile */
+#if MROP == 0 && PSZ == 24
+ DeclareMergeRop()
+#else
+ MROP_DECLARE_REG()
+#endif
+ MROP_PREBUILT_DECLARE()
+#if PSZ == 24
+ CfbBits xtmp;
+#endif
+
+ tile = pGC->pRotatedPixmap;
+ tileHeight = tile->drawable.height;
+ psrc = (CfbBits *)tile->devPrivate.ptr;
+
+#if MROP == 0 && PSZ == 24
+ InitializeMergeRop(pGC->alu, pGC->planemask);
+#else
+ MROP_INITIALIZE(pGC->alu, pGC->planemask);
+#endif
+
+ cfbGetLongWidthAndPointer (pDrawable, nlwDst, pbits)
+
+ while (nBox--)
+ {
+ w = pBox->x2 - pBox->x1;
+ h = pBox->y2 - pBox->y1;
+ y = pBox->y1;
+#if PSZ == 24
+ xtmp = pBox->x1;
+ p = pbits + (y * nlwDst) + ((pBox->x1*3) >> 2);
+/* p = pbits + (y * nlwDst) + ((pBox->x1>> 2)*3);*/
+#else
+ p = pbits + (y * nlwDst) + (pBox->x1 >> PWSH);
+#endif
+ srcy = y % tileHeight;
+
+#if PSZ == 24
+ if (w == 1 && ((pBox->x1 & 3) == 0 || (pBox->x1 & 3) == 3))
+#else
+ if ( ((pBox->x1 & PIM) + w) <= PPW)
+#endif
+ {
+ maskpartialbits(pBox->x1, w, startmask);
+ nlwExtra = nlwDst;
+ while (h--)
+ {
+ srcpix = psrc[srcy];
+ MROP_PREBUILD(srcpix);
+ ++srcy;
+ if (srcy == tileHeight)
+ srcy = 0;
+ *p = MROP_PREBUILT_MASK (srcpix, *p, startmask);
+ p += nlwExtra;
+ }
+ }
+ else
+ {
+ maskbits(pBox->x1, w, startmask, endmask, nlwMiddle);
+ nlwExtra = nlwDst - nlwMiddle;
+
+ if (startmask)
+ {
+ nlwExtra -= 1;
+ if (endmask)
+ {
+ Expand(*p = MROP_PREBUILT_MASK(srcpix, *p, startmask); p++;,
+ *p = MROP_PREBUILT_MASK(srcpix, *p, endmask);)
+ }
+ else
+ {
+ Expand(*p = MROP_PREBUILT_MASK(srcpix, *p, startmask); p++;,
+ ;)
+ }
+ }
+ else
+ {
+ if (endmask)
+ {
+ Expand(;,
+ *p = MROP_PREBUILT_MASK(srcpix, *p, endmask);)
+ }
+ else
+ {
+ Expand(;,
+ ;)
+ }
+ }
+ }
+ pBox++;
+ }
+}
+
+void
+MROP_NAME(cfbTile32FS)(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ DDXPointPtr ppt; /* pointer to list of start points */
+ int *pwidth;/* pointer to list of n widths */
+ CfbBits *pbits; /* pointer to start of bitmap */
+ int nlwDst; /* width in longwords of bitmap */
+ register CfbBits *p; /* pointer to current longword in bitmap */
+ register int w; /* current span width */
+ register int nlw;
+ register int x;
+ register CfbBits startmask;
+ register CfbBits endmask;
+ register CfbBits srcpix;
+ int y;
+ int *pwidthFree;/* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ PixmapPtr tile;
+ CfbBits *psrc; /* pointer to bits in tile */
+ int tileHeight;/* height of the tile */
+#if MROP == 0 && PSZ == 24
+ DeclareMergeRop()
+#else
+ MROP_DECLARE_REG()
+#endif
+ MROP_PREBUILT_DECLARE()
+#if PSZ == 24
+ CfbBits xtmp;
+#endif
+
+ n = nInit * miFindMaxBand( cfbGetCompositeClip(pGC) );
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans( cfbGetCompositeClip(pGC),
+ pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ tile = pGC->pRotatedPixmap;
+ tileHeight = tile->drawable.height;
+ psrc = (CfbBits *)tile->devPrivate.ptr;
+
+#if MROP == 0 && PSZ == 24
+ InitializeMergeRop(pGC->alu, pGC->planemask);
+#else
+ MROP_INITIALIZE(pGC->alu, pGC->planemask);
+#endif
+
+ cfbGetLongWidthAndPointer (pDrawable, nlwDst, pbits)
+
+#if MROP == Mcopy
+ if (!(tileHeight & (tileHeight-1)))
+ {
+ tileHeight--;
+ while (n--)
+ {
+ x = ppt->x;
+ y = ppt->y;
+ ++ppt;
+ w = *pwidth++;
+#if PSZ == 24
+/* p = pbits + (y * nlwDst) + ((x*3) >> 2);*/
+ xtmp = x;
+ p = pbits + (y * nlwDst) + ((x >> 2)*3);
+#else
+ p = pbits + (y * nlwDst) + (x >> PWSH);
+#endif
+ srcpix = psrc[y & tileHeight];
+ MROP_PREBUILD(srcpix);
+
+#if PSZ == 24
+ if ((x & 3) + w < 5)
+#else
+ if ((x & PIM) + w < PPW)
+#endif
+ {
+ maskpartialbits(x, w, startmask);
+ *p = MROP_PREBUILT_MASK (srcpix, *p, startmask);
+ }
+ else
+ {
+ maskbits(x, w, startmask, endmask, nlw);
+ if (startmask)
+ {
+ *p = MROP_PREBUILT_MASK(srcpix, *p, startmask);
+#if PSZ == 24
+ if(xtmp&3) p++;
+ xtmp++;
+#else
+ p++;
+#endif
+ }
+ while (nlw--)
+ {
+#if PSZ == 24
+ STORE24(p,xtmp);
+ if(xtmp&3) p++;
+ ++xtmp;
+#else
+ STORE(p);
+ ++p;
+#endif
+ }
+ if (endmask)
+ {
+ *p = MROP_PREBUILT_MASK(srcpix, *p, endmask);
+ }
+ }
+ }
+ }
+ else
+#endif
+ {
+ while (n--)
+ {
+ x = ppt->x;
+ y = ppt->y;
+ ++ppt;
+ w = *pwidth++;
+#if PSZ == 24
+/* p = pbits + (y * nlwDst) + ((x *3)>> 2);*/
+ p = pbits + (y * nlwDst) + ((x >> 2)*3);
+ xtmp = x;
+#else
+ p = pbits + (y * nlwDst) + (x >> PWSH);
+#endif
+ srcpix = psrc[y % tileHeight];
+ MROP_PREBUILD(srcpix);
+
+#if PSZ == 24
+ if ((x & 3) + w < 5)
+#else
+ if ((x & PIM) + w < PPW)
+#endif
+ {
+ maskpartialbits(x, w, startmask);
+ *p = MROP_PREBUILT_MASK (srcpix, *p, startmask);
+ }
+ else
+ {
+ maskbits(x, w, startmask, endmask, nlw);
+ if (startmask)
+ {
+ *p = MROP_PREBUILT_MASK(srcpix, *p, startmask);
+#if PSZ == 24
+ if(xtmp&3)p++;
+ xtmp++;
+#else
+ p++;
+#endif
+ }
+ while (nlw--)
+ {
+#if PSZ == 24
+ STORE24(p,xtmp);
+ if(xtmp&3)p++;
+ xtmp++;
+#else
+ STORE(p);
+ ++p;
+#endif
+ }
+ if (endmask)
+ {
+ *p = MROP_PREBUILT_MASK(srcpix, *p, endmask);
+ }
+ }
+ }
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbtileodd.c b/nx-X11/programs/Xserver/cfb/cfbtileodd.c
new file mode 100644
index 000000000..6c46aa4db
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbtileodd.c
@@ -0,0 +1,1247 @@
+/*
+ * Fill odd tiled rectangles and spans.
+ * no depth dependencies.
+ */
+/* $XFree86: xc/programs/Xserver/cfb/cfbtileodd.c,v 3.6tsi Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+
+/* $Xorg: cfbtileodd.c,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "cfb8bit.h"
+
+#include "mergerop.h"
+
+#if PSZ == 24
+#define LEFTSHIFT_AMT (3)
+#else /* PSZ != 24 */
+#define LEFTSHIFT_AMT (5 - PWSH)
+#endif /* PSZ == 24*/
+
+#define LastTileBits {\
+ tmp = bits; \
+ if (tileEndPart) \
+ bits = (*pSrc & tileEndMask) | BitRight (*pSrcLine, tileEndLeftShift); \
+ else \
+ bits = *pSrc; \
+}
+
+#if PSZ == 24
+#define ResetTileBits {\
+ pSrc = pSrcLine; \
+ nlwSrc = widthSrc;\
+ if (tileEndPart) { \
+ if (4 - xoff + tileEndPart <= 4) {\
+ bits = *pSrc++; \
+ nlwSrc--; \
+ } else \
+ bits = BitLeft(tmp, tileEndLeftShift) | \
+ BitRight(bits, tileEndRightShift); \
+ xoff = (xoff + xoffStep) & 3; \
+ leftShift = xoff << LEFTSHIFT_AMT; \
+ rightShift = PGSZ - leftShift; \
+ }\
+}
+#else
+#define ResetTileBits {\
+ pSrc = pSrcLine; \
+ nlwSrc = widthSrc;\
+ if (tileEndPart) { \
+ if (PPW - xoff + tileEndPart <= PPW) {\
+ bits = *pSrc++; \
+ nlwSrc--; \
+ } else \
+ bits = BitLeft(tmp, tileEndLeftShift) | \
+ BitRight(bits, tileEndRightShift); \
+ xoff = (xoff + xoffStep) & PIM; \
+ leftShift = xoff << LEFTSHIFT_AMT; \
+ rightShift = PGSZ - leftShift; \
+ }\
+}
+#endif
+
+#define NextTileBits {\
+ if (nlwSrc == 1) {\
+ LastTileBits\
+ } else { \
+ if (nlwSrc == 0) {\
+ ResetTileBits\
+ } \
+ if (nlwSrc == 1) {\
+ LastTileBits\
+ } else {\
+ tmp = bits; \
+ bits = *pSrc++; \
+ }\
+ }\
+ nlwSrc--; \
+}
+
+void
+MROP_NAME(cfbFillBoxTileOdd) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, planemask)
+ DrawablePtr pDrawable;
+ int nBox; /* number of boxes to fill */
+ register BoxPtr pBox; /* pointer to list of boxes to fill */
+ PixmapPtr tile; /* tile */
+ int xrot, yrot;
+ int alu;
+ unsigned long planemask;
+{
+ int tileWidth; /* width of tile in pixels */
+ int tileHeight; /* height of the tile */
+ int widthSrc;
+
+ int widthDst; /* width in longwords of the dest pixmap */
+ int w; /* width of current box */
+ int h; /* height of current box */
+ CfbBits startmask;
+ CfbBits endmask;/* masks for reggedy bits at either end of line */
+ int nlwMiddle; /* number of longwords between sides of boxes */
+ int nlwSrc; /* number of whole longwords in source */
+
+ register int nlw; /* loop version of nlwMiddle */
+ int srcy; /* current tile y position */
+ int srcx; /* current tile x position */
+ int xoffDst, xoffSrc;
+ int leftShift, rightShift;
+
+#if MROP == 0 && PSZ == 24
+ DeclareMergeRop24()
+#else
+ MROP_DECLARE_REG()
+#endif
+
+ CfbBits *pdstBase; /* pointer to start of dest */
+ CfbBits *pDstLine; /* poitner to start of dest box */
+ CfbBits *pSrcBase; /* pointer to start of source */
+ CfbBits *pSrcLine; /* pointer to start of source line */
+ register CfbBits *pDst;
+ register CfbBits *pSrc;
+ register CfbBits bits, tmp = 0;
+ int xoffStart, xoff;
+ int leftShiftStart, rightShiftStart, nlwSrcStart;
+ CfbBits tileEndMask;
+ int tileEndLeftShift, tileEndRightShift;
+ int xoffStep;
+ int tileEndPart;
+ int needFirst;
+ CfbBits narrow[2];
+ CfbBits narrowMask = 0;
+ int narrowShift = 0;
+ Bool narrowTile;
+
+#if MROP == 0 && PSZ == 24
+ InitializeMergeRop24 (alu, planemask)
+#else
+ MROP_INITIALIZE (alu, planemask)
+#endif
+
+ tileHeight = tile->drawable.height;
+ tileWidth = tile->drawable.width;
+ widthSrc = tile->devKind / PGSZB;
+ narrowTile = FALSE;
+ if (widthSrc == 1)
+ {
+ narrowShift = tileWidth;
+ narrowMask = cfbendpartial [tileWidth];
+ tileWidth *= 2;
+ widthSrc = 2;
+ narrowTile = TRUE;
+ }
+ pSrcBase = (CfbBits *)tile->devPrivate.ptr;
+
+ cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase)
+
+#if PSZ == 24
+ tileEndPart = (4 - tileWidth) & 3;
+ tileEndMask = cfbendpartial[tileWidth & 3];
+#else
+ tileEndPart = tileWidth & PIM;
+ tileEndMask = cfbendpartial[tileEndPart];
+#endif /* PSZ == 24 */
+ tileEndLeftShift = (tileEndPart) << LEFTSHIFT_AMT;
+ tileEndRightShift = PGSZ - tileEndLeftShift;
+#if PSZ == 24
+ xoffStep = 4 - tileEndPart;
+#else
+ xoffStep = PPW - tileEndPart;
+#endif /* PSZ == 24 */
+ /*
+ * current assumptions: tile > 32 bits wide.
+ */
+ while (nBox--)
+ {
+ w = pBox->x2 - pBox->x1;
+ h = pBox->y2 - pBox->y1;
+ modulus (pBox->x1 - xrot, tileWidth, srcx);
+ modulus (pBox->y1 - yrot, tileHeight, srcy);
+#if PSZ == 24
+ xoffDst = (4 - pBox->x1) & 3;
+ if (w == 1 && (xoffDst == 0 || xoffDst == 1))
+#else
+ xoffDst = pBox->x1 & PIM;
+ if (xoffDst + w < PPW)
+#endif
+ {
+ maskpartialbits(pBox->x1, w, startmask);
+ endmask = 0;
+ nlwMiddle = 0;
+ }
+ else
+ {
+ maskbits (pBox->x1, w, startmask, endmask, nlwMiddle)
+ }
+#if PSZ == 24
+ pDstLine = pdstBase + (pBox->y1 * widthDst) + ((pBox->x1*3) >> 2);
+#else
+ pDstLine = pdstBase + (pBox->y1 * widthDst) + (pBox->x1 >> PWSH);
+#endif
+ pSrcLine = pSrcBase + (srcy * widthSrc);
+#if PSZ == 24
+ xoffSrc = (4 - srcx) & 3;
+#else
+ xoffSrc = srcx & PIM;
+#endif
+ if (xoffSrc >= xoffDst)
+ {
+ xoffStart = xoffSrc - xoffDst;
+ needFirst = 1;
+ }
+ else
+ {
+#if PSZ == 24
+ xoffStart = 4 - (xoffDst - xoffSrc);
+#else
+ xoffStart = PPW - (xoffDst - xoffSrc);
+#endif
+ needFirst = 0;
+ }
+ leftShiftStart = (xoffStart) << LEFTSHIFT_AMT;
+ rightShiftStart = PGSZ - leftShiftStart;
+#if PSZ == 24
+ nlwSrcStart = widthSrc - ((srcx*3) >> 2);
+#else
+ nlwSrcStart = widthSrc - (srcx >> PWSH);
+#endif
+ while (h--)
+ {
+ /* XXX only works when narrowShift >= PPW/2 */
+ if (narrowTile)
+ {
+ tmp = pSrcBase[srcy] & narrowMask; /* source width == 1 */
+ narrow[0] = tmp | SCRRIGHT (tmp, narrowShift);
+#if PSZ == 24
+ narrow[1] = BitLeft (tmp, 8) |
+ BitRight(tmp, 16);
+#else
+ narrow[1] = SCRLEFT (tmp, PPW - narrowShift) |
+ SCRRIGHT(tmp, 2 * narrowShift - PPW);
+#endif
+ pSrcLine = narrow;
+ }
+ xoff = xoffStart;
+ leftShift = leftShiftStart;
+ rightShift = rightShiftStart;
+ nlwSrc = nlwSrcStart;
+#if PSZ == 24
+ pSrc = pSrcLine + ((srcx * 3) >> 2);
+#else
+ pSrc = pSrcLine + (srcx >> PWSH);
+#endif
+ pDst = pDstLine;
+ bits = 0;
+ if (needFirst)
+ {
+ NextTileBits
+ }
+ if (startmask)
+ {
+ NextTileBits
+ tmp = BitLeft(tmp, leftShift);
+ if (rightShift != PGSZ)
+ tmp |= BitRight(bits,rightShift);
+ *pDst = MROP_MASK (tmp, *pDst, startmask);
+ ++pDst;
+ }
+ nlw = nlwMiddle;
+ while (nlw)
+ {
+#if MROP == Mcopy
+ if (nlwSrc > 1)
+ {
+ int nlwPart = nlw;
+
+ if (nlwPart >= nlwSrc)
+ nlwPart = nlwSrc - 1;
+ nlw -= nlwPart;
+ nlwSrc -= nlwPart;
+ if (rightShift != PGSZ)
+ {
+ while (nlwPart--)
+ {
+ tmp = bits;
+ bits = *pSrc++;
+ *pDst = MROP_SOLID(BitLeft(tmp, leftShift) |
+ BitRight (bits, rightShift),
+ *pDst);
+ ++pDst;
+ }
+ }
+ else
+ {
+ if (nlwPart)
+ {
+ *pDst = MROP_SOLID (bits, *pDst);
+ ++pDst;
+ nlwPart--;
+ while (nlwPart--)
+ {
+ *pDst = MROP_SOLID(*pSrc, *pDst);
+ ++pDst; ++pSrc;
+ }
+ bits = *pSrc++;
+ }
+ }
+ }
+ else
+#endif
+ {
+ NextTileBits
+ if (rightShift != PGSZ)
+ {
+ *pDst = MROP_SOLID(BitLeft(tmp, leftShift) |
+ BitRight(bits, rightShift),
+ *pDst);
+ }
+ else
+ {
+ *pDst = MROP_SOLID (tmp, *pDst);
+ }
+ ++pDst;
+ nlw--;
+ }
+ }
+ if (endmask)
+ {
+ NextTileBits
+ if (rightShift == PGSZ)
+ bits = 0;
+ *pDst = MROP_MASK (BitLeft(tmp, leftShift) |
+ BitRight(bits,rightShift),
+ *pDst, endmask);
+ }
+ pDstLine += widthDst;
+ pSrcLine += widthSrc;
+ if (++srcy == tileHeight)
+ {
+ srcy = 0;
+ pSrcLine = pSrcBase;
+ }
+ }
+ pBox++;
+ }
+}
+
+void
+MROP_NAME(cfbFillSpanTileOdd) (pDrawable, n, ppt, pwidth, tile, xrot, yrot, alu, planemask)
+ DrawablePtr pDrawable;
+ int n;
+ DDXPointPtr ppt;
+ int *pwidth;
+ PixmapPtr tile;
+ int xrot, yrot;
+ int alu;
+ unsigned long planemask;
+{
+ int tileWidth; /* width of tile in pixels */
+ int tileHeight; /* height of the tile */
+ int widthSrc;
+
+ int widthDst; /* width in longwords of the dest pixmap */
+ int w; /* width of current span */
+ CfbBits startmask;
+ CfbBits endmask; /* masks for reggedy bits at either end of line */
+ int nlwSrc; /* number of whole longwords in source */
+
+ register int nlw; /* loop version of nlwMiddle */
+ int srcy; /* current tile y position */
+ int srcx; /* current tile x position */
+ int xoffDst, xoffSrc;
+ int leftShift, rightShift;
+
+#if MROP == 0 && PSZ == 24
+ DeclareMergeRop24()
+#else
+ MROP_DECLARE_REG()
+#endif
+
+ CfbBits *pdstBase; /* pointer to start of dest */
+ CfbBits *pDstLine; /* poitner to start of dest box */
+ CfbBits *pSrcBase; /* pointer to start of source */
+ CfbBits *pSrcLine; /* pointer to start of source line */
+ register CfbBits *pDst;
+ register CfbBits *pSrc;
+ register CfbBits bits, tmp = 0;
+ int xoffStart, xoff;
+ int leftShiftStart, rightShiftStart, nlwSrcStart;
+ CfbBits tileEndMask;
+ int tileEndLeftShift, tileEndRightShift;
+ int xoffStep;
+ int tileEndPart;
+ int needFirst;
+ CfbBits narrow[2];
+ CfbBits narrowMask = 0;
+ int narrowShift = 0;
+ Bool narrowTile;
+
+#if MROP == 0 && PSZ == 24
+ InitializeMergeRop24 (alu, planemask)
+#else
+ MROP_INITIALIZE (alu, planemask)
+#endif
+
+ tileHeight = tile->drawable.height;
+ tileWidth = tile->drawable.width;
+ widthSrc = tile->devKind / PGSZB;
+ narrowTile = FALSE;
+ if (widthSrc == 1)
+ {
+ narrowShift = tileWidth;
+ narrowMask = cfbendpartial [tileWidth];
+ tileWidth *= 2;
+ widthSrc = 2;
+ narrowTile = TRUE;
+ }
+ pSrcBase = (CfbBits *)tile->devPrivate.ptr;
+
+ cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase)
+
+#if PSZ == 24
+ tileEndPart = (4 - tileWidth) & 3;
+ tileEndMask = cfbendpartial[tileWidth & 3];
+#else
+ tileEndPart = tileWidth & PIM;
+ tileEndMask = cfbendpartial[tileEndPart];
+#endif
+ tileEndLeftShift = (tileEndPart) << LEFTSHIFT_AMT;
+ tileEndRightShift = PGSZ - tileEndLeftShift;
+#if PSZ == 24
+ xoffStep = 4 - tileEndPart;
+#else
+ xoffStep = PPW - tileEndPart;
+#endif
+ while (n--)
+ {
+ w = *pwidth++;
+ modulus (ppt->x - xrot, tileWidth, srcx);
+ modulus (ppt->y - yrot, tileHeight, srcy);
+#if PSZ == 24
+ xoffDst = (4 - ppt->x) & 3;
+ if (w == 1 && (xoffDst == 0 || xoffDst == 1))
+#else
+ xoffDst = ppt->x & PIM;
+ if (xoffDst + w < PPW)
+#endif
+ {
+ maskpartialbits(ppt->x, w, startmask);
+ endmask = 0;
+ nlw = 0;
+ }
+ else
+ {
+ maskbits (ppt->x, w, startmask, endmask, nlw)
+ }
+#if PSZ == 24
+ pDstLine = pdstBase + (ppt->y * widthDst) + ((ppt->x *3)>> 2);
+#else
+ pDstLine = pdstBase + (ppt->y * widthDst) + (ppt->x >> PWSH);
+#endif
+ pSrcLine = pSrcBase + (srcy * widthSrc);
+#if PSZ == 24
+ xoffSrc = (4 - srcx) & 3;
+#else
+ xoffSrc = srcx & PIM;
+#endif
+ if (xoffSrc >= xoffDst)
+ {
+ xoffStart = xoffSrc - xoffDst;
+ needFirst = 1;
+ }
+ else
+ {
+#if PSZ == 24
+ xoffStart = 4 - (xoffDst - xoffSrc);
+#else
+ xoffStart = PPW - (xoffDst - xoffSrc);
+#endif
+ needFirst = 0;
+ }
+ leftShiftStart = (xoffStart) << LEFTSHIFT_AMT;
+ rightShiftStart = PGSZ - leftShiftStart;
+#if PSZ == 24
+ nlwSrcStart = widthSrc - ((srcx*3) >> 2);
+#else
+ nlwSrcStart = widthSrc - (srcx >> PWSH);
+#endif
+ /* XXX only works when narrowShift >= PPW/2 */
+ if (narrowTile)
+ {
+ tmp = pSrcBase[srcy] & narrowMask; /* source width == 1 */
+ narrow[0] = tmp | SCRRIGHT (tmp, narrowShift);
+#if PSZ == 24
+ narrow[1] = BitLeft (tmp, 8) |
+ BitRight(tmp, 16);
+#else
+ narrow[1] = SCRLEFT (tmp, PPW - narrowShift) |
+ SCRRIGHT(tmp, 2 * narrowShift - PPW);
+#endif
+ pSrcLine = narrow;
+ }
+ xoff = xoffStart;
+ leftShift = leftShiftStart;
+ rightShift = rightShiftStart;
+ nlwSrc = nlwSrcStart;
+#if PSZ == 24
+ pSrc = pSrcLine + ((srcx * 3) >> 2);
+#else
+ pSrc = pSrcLine + (srcx >> PWSH);
+#endif
+ pDst = pDstLine;
+ bits = 0;
+ if (needFirst)
+ {
+ NextTileBits
+ }
+ if (startmask)
+ {
+ NextTileBits
+ tmp = BitLeft(tmp, leftShift);
+ if (rightShift != PGSZ)
+ tmp |= BitRight(bits,rightShift);
+ *pDst = MROP_MASK (tmp, *pDst, startmask);
+ ++pDst;
+ }
+ while (nlw)
+ {
+#if MROP == Mcopy
+ if (nlwSrc > 1)
+ {
+ int nlwPart = nlw;
+
+ if (nlwPart >= nlwSrc)
+ nlwPart = nlwSrc - 1;
+ nlw -= nlwPart;
+ nlwSrc -= nlwPart;
+ if (rightShift != PGSZ)
+ {
+ while (nlwPart--)
+ {
+ tmp = bits;
+ bits = *pSrc++;
+ *pDst = MROP_SOLID(BitLeft(tmp, leftShift) |
+ BitRight (bits, rightShift),
+ *pDst);
+ ++pDst;
+ }
+ }
+ else
+ {
+ if (nlwPart)
+ {
+ *pDst = MROP_SOLID (bits, *pDst);
+ ++pDst;
+ nlwPart--;
+ while (nlwPart--)
+ {
+ *pDst = MROP_SOLID(*pSrc, *pDst);
+ ++pDst; ++pSrc;
+ }
+ bits = *pSrc++;
+ }
+ }
+ }
+ else
+#endif
+ {
+ NextTileBits
+ if (rightShift != PGSZ)
+ {
+ *pDst = MROP_SOLID(BitLeft(tmp, leftShift) |
+ BitRight(bits, rightShift),
+ *pDst);
+ ++pDst;
+ }
+ else
+ {
+ *pDst = MROP_SOLID (tmp, *pDst);
+ ++pDst;
+ }
+ nlw--;
+ }
+ }
+ if (endmask)
+ {
+ NextTileBits
+ if (rightShift == PGSZ)
+ bits = 0;
+ *pDst = MROP_MASK (BitLeft(tmp, leftShift) |
+ BitRight(bits,rightShift),
+ *pDst, endmask);
+ }
+ ppt++;
+ }
+}
+
+# include "fastblt.h"
+
+#define IncSrcPtr psrc++; if (!--srcRemaining) { srcRemaining = widthSrc; psrc = psrcStart; }
+
+void
+MROP_NAME(cfbFillBoxTile32s) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, planemask)
+ DrawablePtr pDrawable;
+ int nBox; /* number of boxes to fill */
+ register BoxPtr pBox; /* pointer to list of boxes to fill */
+ PixmapPtr tile; /* tile */
+ int xrot, yrot;
+ int alu;
+ unsigned long planemask;
+{
+ int tileWidth; /* width of tile */
+ int tileHeight; /* height of the tile */
+ int widthSrc; /* width in longwords of the source tile */
+
+ int widthDst; /* width in longwords of the dest pixmap */
+ int w; /* width of current box */
+ int h; /* height of current box */
+ CfbBits startmask;
+ CfbBits endmask;/* masks for reggedy bits at either end of line */
+ int nlMiddle; /* number of longwords between sides of boxes */
+
+ register int nl; /* loop version of nlMiddle */
+ int srcy; /* current tile y position */
+ int srcx; /* current tile x position */
+ int srcRemaining; /* number of longwords remaining in source */
+ int xoffDst, xoffSrc;
+ int srcStart; /* number of longwords source offset at left of box */
+ int leftShift, rightShift;
+
+#if MROP == 0 && PSZ == 24
+ DeclareMergeRop24()
+#else
+ MROP_DECLARE_REG()
+#endif
+
+ CfbBits *pdstBase; /* pointer to start of dest */
+ CfbBits *pdstLine; /* poitner to start of dest box */
+ CfbBits *psrcBase; /* pointer to start of source */
+ CfbBits *psrcLine; /* pointer to fetch point of source */
+ CfbBits *psrcStart; /* pointer to start of source line */
+ register CfbBits *pdst;
+ register CfbBits *psrc;
+ register CfbBits bits, bits1;
+ register int nlTemp;
+
+#if MROP == 0 && PSZ == 24
+ InitializeMergeRop24 (alu, planemask)
+#else
+ MROP_INITIALIZE (alu, planemask)
+#endif
+
+ psrcBase = (CfbBits *)tile->devPrivate.ptr;
+ tileHeight = tile->drawable.height;
+ tileWidth = tile->drawable.width;
+#if PSZ == 24
+ widthSrc = tile->devKind / PGSZB;
+#else
+ widthSrc = tileWidth >> PWSH;
+#endif
+
+ cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase)
+
+ while (nBox--)
+ {
+ w = pBox->x2 - pBox->x1;
+ h = pBox->y2 - pBox->y1;
+
+ /* set up source */
+ modulus (pBox->x1 - xrot, tileWidth, srcx);
+ modulus (pBox->y1 - yrot, tileHeight, srcy);
+#if PSZ == 24
+ xoffSrc = (4 - srcx) & 3;
+ srcStart = (srcx * 3) >> 2;
+#else
+ xoffSrc = srcx & PIM;
+ srcStart = (srcx >> PWSH);
+#endif
+ psrcStart = psrcBase + (srcy * widthSrc);
+ psrcLine = psrcStart + srcStart;
+
+ /* set up dest */
+#if PSZ == 24
+ xoffDst = (4 - pBox->x1) & 3;
+ pdstLine = pdstBase + (pBox->y1 * widthDst) + ((pBox->x1*3) >> 2);
+#else
+ xoffDst = pBox->x1 & PIM;
+ pdstLine = pdstBase + (pBox->y1 * widthDst) + (pBox->x1 >> PWSH);
+#endif
+ /* set up masks */
+#if PSZ == 24
+ if (w == 1 && (xoffDst == 0 || xoffDst == 1))
+#else
+ if (xoffDst + w < PPW)
+#endif
+ {
+ maskpartialbits(pBox->x1, w, startmask);
+ endmask = 0;
+ nlMiddle = 0;
+ }
+ else
+ {
+ maskbits (pBox->x1, w, startmask, endmask, nlMiddle)
+ }
+ if (xoffSrc == xoffDst)
+ {
+ while (h--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ srcRemaining = widthSrc - srcStart;
+ if (startmask)
+ {
+ *pdst = MROP_MASK (*psrc, *pdst, startmask);
+ pdst++;
+ IncSrcPtr
+ }
+ nlTemp = nlMiddle;
+ while (nlTemp)
+ {
+ nl = nlTemp;
+ if (nl > srcRemaining)
+ nl = srcRemaining;
+
+ nlTemp -= nl;
+ srcRemaining -= nl;
+
+#if MROP == Mcopy
+#ifdef LARGE_INSTRUCTION_CACHE
+#ifdef FAST_CONSTANT_OFFSET_MODE
+
+ psrc += nl & (UNROLL-1);
+ pdst += nl & (UNROLL-1);
+
+#define BodyOdd(n) pdst[-n] = MROP_SOLID (psrc[-n], pdst[-n]);
+#define BodyEven(n) pdst[-n] = MROP_SOLID (psrc[-n], pdst[-n]);
+
+#define LoopReset \
+pdst += UNROLL; \
+psrc += UNROLL;
+
+#else
+
+#define BodyOdd(n) *pdst = MROP_SOLID (*psrc, *pdst); pdst++; psrc++;
+#define BodyEven(n) BodyOdd(n)
+
+#define LoopReset ;
+
+#endif
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+ DuffL(nl, label1,
+ *pdst = MROP_SOLID (*psrc, *pdst);
+ pdst++; psrc++;)
+#endif
+#else
+ while (nl--) {
+ *pdst = MROP_SOLID (*psrc, *pdst);
+ pdst++; psrc++;
+ }
+#endif
+ if (!srcRemaining)
+ {
+ srcRemaining = widthSrc;
+ psrc = psrcStart;
+ }
+ }
+ if (endmask)
+ {
+ *pdst = MROP_MASK (*psrc, *pdst, endmask);
+ }
+ pdstLine += widthDst;
+ psrcLine += widthSrc;
+ psrcStart += widthSrc;
+ if (++srcy == tileHeight)
+ {
+ psrcStart = psrcBase;
+ psrcLine = psrcStart + srcStart;
+ srcy = 0;
+ }
+ }
+ }
+ else
+ {
+ if (xoffSrc > xoffDst)
+ {
+ leftShift = (xoffSrc - xoffDst) << LEFTSHIFT_AMT;
+ rightShift = PGSZ - leftShift;
+ }
+ else
+ {
+ rightShift = (xoffDst - xoffSrc) << LEFTSHIFT_AMT;
+ leftShift = PGSZ - rightShift;
+ }
+ while (h--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ bits = 0;
+ srcRemaining = widthSrc - srcStart;
+ if (xoffSrc > xoffDst)
+ {
+ bits = *psrc;
+ IncSrcPtr
+ }
+ if (startmask)
+ {
+ bits1 = BitLeft(bits,leftShift);
+ bits = *psrc;
+ IncSrcPtr
+ bits1 |= BitRight(bits,rightShift);
+ *pdst = MROP_MASK(bits1, *pdst, startmask);
+ pdst++;
+ }
+ nlTemp = nlMiddle;
+ while (nlTemp)
+ {
+ nl = nlTemp;
+ if (nl > srcRemaining)
+ nl = srcRemaining;
+
+ nlTemp -= nl;
+ srcRemaining -= nl;
+
+#if MROP == Mcopy
+#ifdef LARGE_INSTRUCTION_CACHE
+ bits1 = bits;
+
+#ifdef FAST_CONSTANT_OFFSET_MODE
+
+ psrc += nl & (UNROLL-1);
+ pdst += nl & (UNROLL-1);
+
+#define BodyOdd(n) \
+ bits = psrc[-n]; \
+ pdst[-n] = MROP_SOLID(BitLeft(bits1, leftShift) | BitRight(bits, rightShift), pdst[-n]);
+
+#define BodyEven(n) \
+ bits1 = psrc[-n]; \
+ pdst[-n] = MROP_SOLID(BitLeft(bits, leftShift) | BitRight(bits1, rightShift), pdst[-n]);
+
+#define LoopReset \
+ pdst += UNROLL; \
+ psrc += UNROLL;
+
+#else
+
+#define BodyOdd(n) \
+ bits = *psrc++; \
+ *pdst = MROP_SOLID(BitLeft(bits1, leftShift) | BitRight(bits, rightShift), *pdst); \
+ pdst++;
+
+#define BodyEven(n) \
+ bits1 = *psrc++; \
+ *pdst = MROP_SOLID(BitLeft(bits, leftShift) | BitRight(bits1, rightShift), *pdst); \
+ pdst++;
+
+#define LoopReset ;
+
+#endif /* !FAST_CONSTANT_OFFSET_MODE */
+
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+ DuffL (nl,label2,
+ bits1 = BitLeft(bits, leftShift);
+ bits = *psrc++;
+ *pdst = MROP_SOLID (bits1 | BitRight(bits, rightShift), *pdst);
+ pdst++;
+ )
+#endif
+#else
+ while (nl--) {
+ bits1 = BitLeft(bits, leftShift);
+ bits = *psrc++;
+ *pdst = MROP_SOLID (bits1 | BitRight(bits, rightShift), *pdst);
+ pdst++;
+ }
+#endif
+ if (!srcRemaining)
+ {
+ srcRemaining = widthSrc;
+ psrc = psrcStart;
+ }
+ }
+
+ if (endmask)
+ {
+ bits1 = BitLeft(bits, leftShift);
+ if (BitLeft(endmask, rightShift))
+ {
+ bits = *psrc;
+ bits1 |= BitRight(bits, rightShift);
+ }
+ *pdst = MROP_MASK (bits1, *pdst, endmask);
+ }
+ pdstLine += widthDst;
+ psrcLine += widthSrc;
+ psrcStart += widthSrc;
+ if (++srcy == tileHeight)
+ {
+ psrcStart = psrcBase;
+ psrcLine = psrcStart + srcStart;
+ srcy = 0;
+ }
+ }
+ }
+ pBox++;
+ }
+}
+
+void
+MROP_NAME(cfbFillSpanTile32s) (pDrawable, n, ppt, pwidth, tile, xrot, yrot, alu, planemask)
+ DrawablePtr pDrawable;
+ int n;
+ DDXPointPtr ppt;
+ int *pwidth;
+ PixmapPtr tile;
+ int xrot, yrot;
+ int alu;
+ unsigned long planemask;
+{
+ int tileWidth; /* width of tile */
+ int tileHeight; /* height of the tile */
+ int widthSrc; /* width in longwords of the source tile */
+
+ int widthDst; /* width in longwords of the dest pixmap */
+ int w; /* width of current box */
+ CfbBits startmask;
+ CfbBits endmask;/* masks for reggedy bits at either end of line */
+ int nlMiddle; /* number of longwords between sides of boxes */
+
+ register int nl; /* loop version of nlMiddle */
+ int srcy; /* current tile y position */
+ int srcx; /* current tile x position */
+ int srcRemaining; /* number of longwords remaining in source */
+ int xoffDst, xoffSrc;
+ int srcStart; /* number of longwords source offset at left of box */
+ int leftShift, rightShift;
+
+#if MROP == 0 && PSZ == 24
+ DeclareMergeRop24()
+#else
+ MROP_DECLARE_REG()
+#endif
+
+ CfbBits *pdstBase; /* pointer to start of dest */
+ CfbBits *pdstLine; /* poitner to start of dest box */
+ CfbBits *psrcBase; /* pointer to start of source */
+ CfbBits *psrcLine; /* pointer to fetch point of source */
+ CfbBits *psrcStart; /* pointer to start of source line */
+ register CfbBits *pdst;
+ register CfbBits *psrc;
+ register CfbBits bits, bits1;
+ register int nlTemp;
+
+#if MROP == 0 && PSZ == 24
+ InitializeMergeRop24 (alu, planemask)
+#else
+ MROP_INITIALIZE (alu, planemask)
+#endif
+
+ psrcBase = (CfbBits *)tile->devPrivate.ptr;
+ tileHeight = tile->drawable.height;
+ tileWidth = tile->drawable.width;
+#if PSZ == 24
+ widthSrc = tile->devKind / PGSZB;
+#else
+ widthSrc = tileWidth >> PWSH;
+#endif
+
+ cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase)
+
+ while (n--)
+ {
+ w = *pwidth++;
+
+ /* set up source */
+ modulus (ppt->x - xrot, tileWidth, srcx);
+ modulus (ppt->y - yrot, tileHeight, srcy);
+#if PSZ == 24
+ xoffSrc = (4 - srcx) & 3;
+ srcStart = (srcx * 3) >> 2;
+#else
+ xoffSrc = srcx & PIM;
+ srcStart = (srcx >> PWSH);
+#endif
+ psrcStart = psrcBase + (srcy * widthSrc);
+ psrcLine = psrcStart + srcStart;
+
+ /* set up dest */
+#if PSZ == 24
+ xoffDst = (4 - ppt->x) & 3;
+ pdstLine = pdstBase + (ppt->y * widthDst) + ((ppt->x *3) >> 2);
+ /* set up masks */
+ if (w == 1 && (xoffDst == 0 || xoffDst == 1))
+#else
+ xoffDst = ppt->x & PIM;
+ pdstLine = pdstBase + (ppt->y * widthDst) + (ppt->x >> PWSH);
+ /* set up masks */
+ if (xoffDst + w < PPW)
+#endif
+ {
+ maskpartialbits(ppt->x, w, startmask);
+ endmask = 0;
+ nlMiddle = 0;
+ }
+ else
+ {
+ maskbits (ppt->x, w, startmask, endmask, nlMiddle)
+ }
+
+ if (xoffSrc == xoffDst)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ srcRemaining = widthSrc - srcStart;
+ if (startmask)
+ {
+ *pdst = MROP_MASK (*psrc, *pdst, startmask);
+ pdst++;
+ IncSrcPtr
+ }
+ nlTemp = nlMiddle;
+ while (nlTemp)
+ {
+ nl = nlTemp;
+ if (nl > srcRemaining)
+ nl = srcRemaining;
+
+ nlTemp -= nl;
+ srcRemaining -= nl;
+
+#if MROP == Mcopy
+#ifdef LARGE_INSTRUCTION_CACHE
+#ifdef FAST_CONSTANT_OFFSET_MODE
+
+ psrc += nl & (UNROLL-1);
+ pdst += nl & (UNROLL-1);
+
+#define BodyOdd(n) pdst[-n] = MROP_SOLID (psrc[-n], pdst[-n]);
+#define BodyEven(n) pdst[-n] = MROP_SOLID (psrc[-n], pdst[-n]);
+
+#define LoopReset \
+pdst += UNROLL; \
+psrc += UNROLL;
+
+#else
+
+#define BodyOdd(n) *pdst = MROP_SOLID (*psrc, *pdst); pdst++; psrc++;
+#define BodyEven(n) BodyOdd(n)
+
+#define LoopReset ;
+
+#endif
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+ DuffL(nl, label1,
+ *pdst = MROP_SOLID (*psrc, *pdst);
+ pdst++; psrc++;)
+#endif
+#else
+ while (nl--) {
+ *pdst = MROP_SOLID (*psrc, *pdst);
+ pdst++; psrc++;
+ }
+#endif
+ if (!srcRemaining)
+ {
+ srcRemaining = widthSrc;
+ psrc = psrcStart;
+ }
+ }
+ if (endmask)
+ {
+ *pdst = MROP_MASK (*psrc, *pdst, endmask);
+ }
+ }
+ else
+ {
+ if (xoffSrc > xoffDst)
+ {
+ leftShift = (xoffSrc - xoffDst) << LEFTSHIFT_AMT;
+ rightShift = PGSZ - leftShift;
+ }
+ else
+ {
+ rightShift = (xoffDst - xoffSrc) << LEFTSHIFT_AMT;
+ leftShift = PGSZ - rightShift;
+ }
+ psrc = psrcLine;
+ pdst = pdstLine;
+ bits = 0;
+ srcRemaining = widthSrc - srcStart;
+ if (xoffSrc > xoffDst)
+ {
+ bits = *psrc;
+ IncSrcPtr
+ }
+ if (startmask)
+ {
+ bits1 = BitLeft(bits,leftShift);
+ bits = *psrc;
+ IncSrcPtr
+ bits1 |= BitRight(bits,rightShift);
+ *pdst = MROP_MASK(bits1, *pdst, startmask);
+ pdst++;
+ }
+ nlTemp = nlMiddle;
+ while (nlTemp)
+ {
+ nl = nlTemp;
+ if (nl > srcRemaining)
+ nl = srcRemaining;
+
+ nlTemp -= nl;
+ srcRemaining -= nl;
+
+#if MROP == Mcopy
+#ifdef LARGE_INSTRUCTION_CACHE
+ bits1 = bits;
+
+#ifdef FAST_CONSTANT_OFFSET_MODE
+
+ psrc += nl & (UNROLL-1);
+ pdst += nl & (UNROLL-1);
+
+#define BodyOdd(n) \
+bits = psrc[-n]; \
+pdst[-n] = MROP_SOLID(BitLeft(bits1, leftShift) | BitRight(bits, rightShift), pdst[-n]);
+
+#define BodyEven(n) \
+bits1 = psrc[-n]; \
+pdst[-n] = MROP_SOLID(BitLeft(bits, leftShift) | BitRight(bits1, rightShift), pdst[-n]);
+
+#define LoopReset \
+pdst += UNROLL; \
+psrc += UNROLL;
+
+#else
+
+#define BodyOdd(n) \
+bits = *psrc++; \
+*pdst = MROP_SOLID(BitLeft(bits1, leftShift) | BitRight(bits, rightShift), *pdst); \
+pdst++;
+
+#define BodyEven(n) \
+bits1 = *psrc++; \
+*pdst = MROP_SOLID(BitLeft(bits, leftShift) | BitRight(bits1, rightShift), *pdst); \
+pdst++;
+
+#define LoopReset ;
+
+#endif /* !FAST_CONSTANT_OFFSET_MODE */
+
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+ DuffL (nl,label2,
+ bits1 = BitLeft(bits, leftShift);
+ bits = *psrc++;
+ *pdst = MROP_SOLID (bits1 | BitRight(bits, rightShift), *pdst);
+ pdst++;
+ )
+#endif
+#else
+ while (nl--) {
+ bits1 = BitLeft(bits,leftShift);
+ bits = *psrc++;
+ *pdst = MROP_SOLID(bits1|BitRight(bits,rightShift), *pdst);
+ pdst++;
+ }
+#endif
+ if (!srcRemaining)
+ {
+ srcRemaining = widthSrc;
+ psrc = psrcStart;
+ }
+ }
+
+ if (endmask)
+ {
+ bits1 = BitLeft(bits, leftShift);
+ if (BitLeft(endmask, rightShift))
+ {
+ bits = *psrc;
+ bits1 |= BitRight(bits, rightShift);
+ }
+ *pdst = MROP_MASK (bits1, *pdst, endmask);
+ }
+ }
+ ppt++;
+ }
+}
diff --git a/nx-X11/programs/Xserver/cfb/cfbunmap.h b/nx-X11/programs/Xserver/cfb/cfbunmap.h
new file mode 100644
index 000000000..bccdf0f0f
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbunmap.h
@@ -0,0 +1,165 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfbunmap.h,v 1.6 2003/07/19 13:22:28 tsi Exp $ */
+/*
+ * Copyright (C) 1994-1998 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+/*
+ * Unmap names
+ */
+
+#undef CFBNAME
+#undef CATNAME
+
+#undef QuartetBitsTable
+#undef QuartetPixelMaskTable
+#undef cfb8ClippedLineCopy
+#undef cfb8ClippedLineGeneral
+#undef cfb8ClippedLineXor
+#undef cfb8LineSS1Rect
+#undef cfb8LineSS1RectCopy
+#undef cfb8LineSS1RectGeneral
+#undef cfb8LineSS1RectPreviousCopy
+#undef cfb8LineSS1RectXor
+#undef cfb8SegmentSS1Rect
+#undef cfb8SegmentSS1RectCopy
+#undef cfb8SegmentSS1RectGeneral
+#undef cfb8SegmentSS1RectShiftCopy
+#undef cfb8SegmentSS1RectXor
+#undef cfbAllocatePrivates
+#undef cfbBSFuncRec
+#undef cfbBitBlt
+#undef cfbBresD
+#undef cfbBresS
+#undef cfbChangeWindowAttributes
+#undef cfbClearVisualTypes
+#undef cfbCloseScreen
+#undef cfbCreateDefColormap
+#undef cfbCopyArea
+#undef cfbCopyImagePlane
+#undef cfbCopyPixmap
+#undef cfbCopyPlane
+#undef cfbCopyPlaneReduce
+#undef cfbCopyRotatePixmap
+#undef cfbCopyWindow
+#undef cfbCreateGC
+#undef cfbCreatePixmap
+#undef cfbCreateScreenResources
+#undef cfbCreateWindow
+#undef cfbDestroyPixmap
+#undef cfbDestroyWindow
+#undef cfbDoBitblt
+#undef cfbDoBitbltCopy
+#undef cfbDoBitbltGeneral
+#undef cfbDoBitbltOr
+#undef cfbDoBitbltXor
+#undef cfbExpandDirectColors
+#undef cfbFillBoxSolid
+#undef cfbFillBoxTile32
+#undef cfbFillBoxTile32sCopy
+#undef cfbFillBoxTile32sGeneral
+#undef cfbFillBoxTileOdd
+#undef cfbFillBoxTileOddCopy
+#undef cfbFillBoxTileOddGeneral
+#undef cfbFillPoly1RectCopy
+#undef cfbFillPoly1RectGeneral
+#undef cfbFillRectSolidCopy
+#undef cfbFillRectSolidGeneral
+#undef cfbFillRectSolidXor
+#undef cfbFillRectTile32Copy
+#undef cfbFillRectTile32General
+#undef cfbFillRectTileOdd
+#undef cfbFillSpanTile32sCopy
+#undef cfbFillSpanTile32sGeneral
+#undef cfbFillSpanTileOddCopy
+#undef cfbFillSpanTileOddGeneral
+#undef cfbFinishScreenInit
+#undef cfbGCFuncs
+#undef cfbGCPrivateIndex
+#undef cfbGetImage
+#undef cfbGetScreenPixmap
+#undef cfbGetSpans
+#undef cfbHorzS
+#undef cfbImageGlyphBlt8
+#undef cfbInitializeColormap
+#undef cfbInitVisuals
+#undef cfbInstallColormap
+#undef cfbLineSD
+#undef cfbLineSS
+#undef cfbListInstalledColormaps
+#undef cfbMapWindow
+#undef cfbMatchCommon
+#undef cfbNonTEOps
+#undef cfbNonTEOps1Rect
+#undef cfbPadPixmap
+#undef cfbPaintWindow
+#undef cfbPolyFillArcSolidCopy
+#undef cfbPolyFillArcSolidGeneral
+#undef cfbPolyFillRect
+#undef cfbPolyGlyphBlt8
+#undef cfbPolyGlyphRop8
+#undef cfbPolyPoint
+#undef cfbPositionWindow
+#undef cfbPutImage
+#undef cfbReduceRasterOp
+#undef cfbResolveColor
+#undef cfbRestoreAreas
+#undef cfbSaveAreas
+#undef cfbScreenInit
+#undef cfbScreenPrivateIndex
+#undef cfbSegmentSD
+#undef cfbSegmentSS
+#undef cfbSetScanline
+#undef cfbSetScreenPixmap
+#undef cfbSetSpans
+#undef cfbSetVisualTypes
+#undef cfbSetupScreen
+#undef cfbSolidSpansCopy
+#undef cfbSolidSpansGeneral
+#undef cfbSolidSpansXor
+#undef cfbStippleStack
+#undef cfbStippleStackTE
+#undef cfbTEGlyphBlt
+#undef cfbTEOps
+#undef cfbTEOps1Rect
+#undef cfbTile32FSCopy
+#undef cfbTile32FSGeneral
+#undef cfbUninstallColormap
+#undef cfbUnmapWindow
+#undef cfbUnnaturalStippleFS
+#undef cfbUnnaturalTileFS
+#undef cfbValidateGC
+#undef cfbVertS
+#undef cfbWindowPrivateIndex
+#undef cfbXRotatePixmap
+#undef cfbYRotatePixmap
+#undef cfbZeroPolyArcSS8Copy
+#undef cfbZeroPolyArcSS8General
+#undef cfbZeroPolyArcSS8Xor
+#undef cfbendpartial
+#undef cfbendtab
+#undef cfbmask
+#undef cfbrmask
+#undef cfbstartpartial
+#undef cfbstarttab
diff --git a/nx-X11/programs/Xserver/cfb/cfbwindow.c b/nx-X11/programs/Xserver/cfb/cfbwindow.c
new file mode 100644
index 000000000..7160f5436
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbwindow.c
@@ -0,0 +1,337 @@
+/* $Xorg: cfbwindow.c,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/cfb/cfbwindow.c,v 1.5tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "cfb.h"
+#include "mistruct.h"
+#include "regionstr.h"
+#include "cfbmskbits.h"
+
+Bool
+cfbCreateWindow(pWin)
+ WindowPtr pWin;
+{
+ cfbPrivWin *pPrivWin;
+
+ pPrivWin = cfbGetWindowPrivate(pWin);
+ pPrivWin->pRotatedBorder = NullPixmap;
+ pPrivWin->pRotatedBackground = NullPixmap;
+ pPrivWin->fastBackground = FALSE;
+ pPrivWin->fastBorder = FALSE;
+ pPrivWin->oldRotate.x = 0;
+ pPrivWin->oldRotate.y = 0;
+
+#ifdef PIXMAP_PER_WINDOW
+ /* Setup pointer to Screen pixmap */
+ pWin->devPrivates[frameWindowPrivateIndex].ptr =
+ (pointer) cfbGetScreenPixmap(pWin->drawable.pScreen);
+#endif
+
+ return TRUE;
+}
+
+Bool
+cfbDestroyWindow(pWin)
+ WindowPtr pWin;
+{
+ cfbPrivWin *pPrivWin;
+
+ pPrivWin = cfbGetWindowPrivate(pWin);
+
+ if (pPrivWin->pRotatedBorder)
+ (*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
+ if (pPrivWin->pRotatedBackground)
+ (*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBackground);
+ return(TRUE);
+}
+
+/*ARGSUSED*/
+Bool
+cfbMapWindow(pWindow)
+ WindowPtr pWindow;
+{
+ return(TRUE);
+}
+
+/* (x, y) is the upper left corner of the window on the screen
+ do we really need to pass this? (is it a;ready in pWin->absCorner?)
+ we only do the rotation for pixmaps that are 32 bits wide (padded
+or otherwise.)
+ cfbChangeWindowAttributes() has already put a copy of the pixmap
+in pPrivWin->pRotated*
+*/
+/*ARGSUSED*/
+Bool
+cfbPositionWindow(pWin, x, y)
+ WindowPtr pWin;
+ int x, y;
+{
+ cfbPrivWin *pPrivWin;
+ int setxy = 0;
+
+ pPrivWin = cfbGetWindowPrivate(pWin);
+ if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground)
+ {
+ cfbXRotatePixmap(pPrivWin->pRotatedBackground,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ cfbYRotatePixmap(pPrivWin->pRotatedBackground,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ setxy = 1;
+ }
+
+ if (!pWin->borderIsPixel && pPrivWin->fastBorder)
+ {
+ while (pWin->backgroundState == ParentRelative)
+ pWin = pWin->parent;
+ cfbXRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ cfbYRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ setxy = 1;
+ }
+ if (setxy)
+ {
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ }
+ return (TRUE);
+}
+
+/*ARGSUSED*/
+Bool
+cfbUnmapWindow(pWindow)
+ WindowPtr pWindow;
+{
+ return (TRUE);
+}
+
+/* UNCLEAN!
+ this code calls the bitblt helper code directly.
+
+ cfbCopyWindow copies only the parts of the destination that are
+visible in the source.
+*/
+
+
+void
+cfbCopyWindow(pWin, ptOldOrg, prgnSrc)
+ WindowPtr pWin;
+ DDXPointRec ptOldOrg;
+ RegionPtr prgnSrc;
+{
+ DDXPointPtr pptSrc;
+ register DDXPointPtr ppt;
+ RegionRec rgnDst;
+ register BoxPtr pbox;
+ register int dx, dy;
+ register int i, nbox;
+ WindowPtr pwinRoot;
+
+ pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
+
+ REGION_NULL(pWin->drawable.pScreen, &rgnDst);
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+ REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+
+ pbox = REGION_RECTS(&rgnDst);
+ nbox = REGION_NUM_RECTS(&rgnDst);
+ if(!nbox || !(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
+ {
+ REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+ return;
+ }
+ ppt = pptSrc;
+
+ for (i = nbox; --i >= 0; ppt++, pbox++)
+ {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ cfbDoBitbltCopy((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
+ GXcopy, &rgnDst, pptSrc, ~0L);
+ DEALLOCATE_LOCAL(pptSrc);
+ REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+}
+
+
+
+/* swap in correct PaintWindow* routine. If we can use a fast output
+routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
+of it in devPrivates[cfbWindowPrivateIndex].ptr.
+*/
+Bool
+cfbChangeWindowAttributes(pWin, mask)
+ WindowPtr pWin;
+ unsigned long mask;
+{
+ register unsigned long index;
+ register cfbPrivWin *pPrivWin;
+ int width;
+ WindowPtr pBgWin;
+
+ pPrivWin = cfbGetWindowPrivate(pWin);
+
+ /*
+ * When background state changes from ParentRelative and
+ * we had previously rotated the fast border pixmap to match
+ * the parent relative origin, rerotate to match window
+ */
+ if (mask & (CWBackPixmap | CWBackPixel) &&
+ pWin->backgroundState != ParentRelative &&
+ pPrivWin->fastBorder &&
+ (pPrivWin->oldRotate.x != pWin->drawable.x ||
+ pPrivWin->oldRotate.y != pWin->drawable.y))
+ {
+ cfbXRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ cfbYRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ }
+ while(mask)
+ {
+ index = lowbit (mask);
+ mask &= ~index;
+ switch(index)
+ {
+ case CWBackPixmap:
+ if (pWin->backgroundState == None)
+ {
+ pPrivWin->fastBackground = FALSE;
+ }
+ else if (pWin->backgroundState == ParentRelative)
+ {
+ pPrivWin->fastBackground = FALSE;
+ /* Rotate border to match parent origin */
+ if (pPrivWin->pRotatedBorder) {
+ for (pBgWin = pWin->parent;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+ cfbXRotatePixmap(pPrivWin->pRotatedBorder,
+ pBgWin->drawable.x - pPrivWin->oldRotate.x);
+ cfbYRotatePixmap(pPrivWin->pRotatedBorder,
+ pBgWin->drawable.y - pPrivWin->oldRotate.y);
+ pPrivWin->oldRotate.x = pBgWin->drawable.x;
+ pPrivWin->oldRotate.y = pBgWin->drawable.y;
+ }
+ }
+ else if (((width = (pWin->background.pixmap->drawable.width * PSZ))
+ <= PGSZ) && !(width & (width - 1)))
+ {
+ cfbCopyRotatePixmap(pWin->background.pixmap,
+ &pPrivWin->pRotatedBackground,
+ pWin->drawable.x,
+ pWin->drawable.y);
+ if (pPrivWin->pRotatedBackground)
+ {
+ pPrivWin->fastBackground = TRUE;
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ }
+ else
+ {
+ pPrivWin->fastBackground = FALSE;
+ }
+ }
+ else
+ {
+ pPrivWin->fastBackground = FALSE;
+ }
+ break;
+
+ case CWBackPixel:
+ pPrivWin->fastBackground = FALSE;
+ break;
+
+ case CWBorderPixmap:
+ if (((width = (pWin->border.pixmap->drawable.width * PSZ)) <= PGSZ) &&
+ !(width & (width - 1)))
+ {
+ for (pBgWin = pWin;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+ cfbCopyRotatePixmap(pWin->border.pixmap,
+ &pPrivWin->pRotatedBorder,
+ pBgWin->drawable.x,
+ pBgWin->drawable.y);
+ if (pPrivWin->pRotatedBorder)
+ {
+ pPrivWin->fastBorder = TRUE;
+ pPrivWin->oldRotate.x = pBgWin->drawable.x;
+ pPrivWin->oldRotate.y = pBgWin->drawable.y;
+ }
+ else
+ {
+ pPrivWin->fastBorder = FALSE;
+ }
+ }
+ else
+ {
+ pPrivWin->fastBorder = FALSE;
+ }
+ break;
+ case CWBorderPixel:
+ pPrivWin->fastBorder = FALSE;
+ break;
+ }
+ }
+ return (TRUE);
+}
+
diff --git a/nx-X11/programs/Xserver/cfb/cfbzerarc.c b/nx-X11/programs/Xserver/cfb/cfbzerarc.c
new file mode 100644
index 000000000..a9e0b2f9d
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/cfbzerarc.c
@@ -0,0 +1,322 @@
+/* $XFree86: xc/programs/Xserver/cfb/cfbzerarc.c,v 3.4tsi Exp $ */
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+********************************************************/
+
+/* $Xorg: cfbzerarc.c,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $ */
+
+/* Derived from:
+ * "Algorithm for drawing ellipses or hyperbolae with a digital plotter"
+ * by M. L. V. Pitteway
+ * The Computer Journal, November 1967, Volume 10, Number 3, pp. 282-289
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "mizerarc.h"
+#include "cfbrrop.h"
+#include "mi.h"
+
+#ifdef PIXEL_ADDR
+
+static void
+RROP_NAME(cfbZeroArcSS8)(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ xArc *arc)
+{
+ miZeroArcRec info;
+ Bool do360;
+ register int x;
+ PixelType *addrp;
+ register PixelType *yorgp, *yorgop;
+#if PSZ == 24
+ int xorg, xorg3, xorgo, xorgo3;
+ register int xtmp;
+#endif
+ RROP_DECLARE
+ register int yoffset;
+ int npwidth, dyoffset;
+ register int y, a, b, d, mask;
+ register int k1, k3, dx, dy;
+
+ cfbGetPixelWidthAndPointer(pDraw,npwidth, addrp)
+
+ RROP_FETCH_GC (pGC);
+ do360 = miZeroArcSetup(arc, &info, TRUE);
+ yorgp = addrp + ((info.yorg + pDraw->y) * npwidth);
+ yorgop = addrp + ((info.yorgo + pDraw->y) * npwidth);
+ info.xorg += pDraw->x;
+ info.xorgo += pDraw->x;
+#if PSZ == 24
+ xorg = info.xorg;
+ xorg3 = xorg * 3;
+ info.xorg = (info.xorg * 3) >> 2;
+ xorgo = info.xorgo;
+ xorgo3 = xorgo * 3;
+ info.xorgo = (info.xorgo * 3) >> 2;
+#endif
+ MIARCSETUP();
+ yoffset = y ? npwidth : 0;
+ dyoffset = 0;
+ mask = info.initialMask;
+ if (!(arc->width & 1))
+ {
+#if PSZ == 24
+ if (mask & 2)
+ RROP_SOLID24((yorgp + info.xorgo), xorgo);
+ if (mask & 8)
+ RROP_SOLID24((yorgop + info.xorgo), xorgo);
+#else
+ if (mask & 2)
+ RROP_SOLID((yorgp + info.xorgo));
+ if (mask & 8)
+ RROP_SOLID((yorgop + info.xorgo));
+#endif /* PSZ == 24 */
+ }
+ if (!info.end.x || !info.end.y)
+ {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ if (do360 && (arc->width == arc->height) && !(arc->width & 1))
+ {
+ register int xoffset = npwidth;
+#if PSZ == 24
+ PixelType *yorghb = yorgp + (info.h * npwidth);
+ register int tmp1, tmp2, tmp1_3, tmp2_3;
+
+ tmp1 = xorg + info.h;
+ tmp1_3 = tmp1 * 3;
+ tmp2 = xorg - info.h;
+ tmp2_3 = tmp2 * 3;
+ while (1)
+ {
+ xtmp = (xorg3 + x * 3) >> 2;
+ RROP_SOLID24(yorgp + yoffset + xtmp, xorg + x);
+ RROP_SOLID24(yorgop - yoffset + xtmp, xorg + x);
+ xtmp = (xorg3 - x * 3) >> 2;
+ RROP_SOLID24(yorgp + yoffset + xtmp, xorg - x);
+ RROP_SOLID24(yorgop - yoffset + xtmp, xorg - x);
+ if (a < 0)
+ break;
+ xtmp = (tmp1_3 - y * 3) >> 2;
+ RROP_SOLID24(yorghb - xoffset + xtmp, tmp1 - y);
+ RROP_SOLID24(yorghb + xoffset + xtmp, tmp1 - y);
+ xtmp = (tmp2_3 + y * 3) >> 2;
+ RROP_SOLID24(yorghb - xoffset + xtmp, tmp2 + y);
+ RROP_SOLID24(yorghb + xoffset + xtmp, tmp2 + y);
+ xoffset += npwidth;
+ MIARCCIRCLESTEP(yoffset += npwidth;);
+ }
+#else
+ PixelType *yorghb = yorgp + (info.h * npwidth) + info.xorg;
+ PixelType *yorgohb = yorghb - info.h;
+
+ yorgp += info.xorg;
+ yorgop += info.xorg;
+ yorghb += info.h;
+ while (1)
+ {
+ RROP_SOLID(yorgp + yoffset + x);
+ RROP_SOLID(yorgp + yoffset - x);
+ RROP_SOLID(yorgop - yoffset - x);
+ RROP_SOLID(yorgop - yoffset + x);
+ if (a < 0)
+ break;
+ RROP_SOLID(yorghb - xoffset - y);
+ RROP_SOLID(yorgohb - xoffset + y);
+ RROP_SOLID(yorgohb + xoffset + y);
+ RROP_SOLID(yorghb + xoffset - y);
+ xoffset += npwidth;
+ MIARCCIRCLESTEP(yoffset += npwidth;);
+ }
+ yorgp -= info.xorg;
+ yorgop -= info.xorg;
+#endif /* PSZ == 24 */
+ x = info.w;
+ yoffset = info.h * npwidth;
+ }
+ else if (do360)
+ {
+ while (y < info.h || x < info.w)
+ {
+ MIARCOCTANTSHIFT(dyoffset = npwidth;);
+#if PSZ == 24
+ xtmp = (xorg3 + x * 3) >> 2;
+ RROP_SOLID24(yorgp + yoffset + xtmp, xorg + x);
+ RROP_SOLID24(yorgop - yoffset + xtmp, xorg + x);
+ xtmp = (xorgo3 - x * 3) >> 2;
+ RROP_SOLID24(yorgp + yoffset + xtmp, xorgo - x);
+ RROP_SOLID24(yorgop - yoffset + xtmp, xorgo - x);
+#else
+ RROP_SOLID(yorgp + yoffset + info.xorg + x);
+ RROP_SOLID(yorgp + yoffset + info.xorgo - x);
+ RROP_SOLID(yorgop - yoffset + info.xorgo - x);
+ RROP_SOLID(yorgop - yoffset + info.xorg + x);
+#endif
+ MIARCSTEP(yoffset += dyoffset;, yoffset += npwidth;);
+ }
+ }
+ else
+ {
+ while (y < info.h || x < info.w)
+ {
+ MIARCOCTANTSHIFT(dyoffset = npwidth;);
+ if ((x == info.start.x) || (y == info.start.y))
+ {
+ mask = info.start.mask;
+ info.start = info.altstart;
+ }
+#if PSZ == 24
+ if (mask & 1){
+ xtmp = (xorg3 + x * 3) >> 2;
+ RROP_SOLID24(yorgp + yoffset + xtmp, xorg + x);
+ }
+ if (mask & 2){
+ xtmp = (xorgo3 - x * 3) >> 2;
+ RROP_SOLID24(yorgp + yoffset + xtmp, xorgo - x);
+ }
+ if (mask & 4){
+ xtmp = (xorgo3 - x * 3) >> 2;
+ RROP_SOLID24(yorgop - yoffset + xtmp, xorgo - x);
+ }
+ if (mask & 8){
+ xtmp = (xorg3 + x * 3) >> 2;
+ RROP_SOLID24(yorgop - yoffset + xtmp, xorg + x);
+ }
+#else
+ if (mask & 1)
+ RROP_SOLID(yorgp + yoffset + info.xorg + x);
+ if (mask & 2)
+ RROP_SOLID(yorgp + yoffset + info.xorgo - x);
+ if (mask & 4)
+ RROP_SOLID(yorgop - yoffset + info.xorgo - x);
+ if (mask & 8)
+ RROP_SOLID(yorgop - yoffset + info.xorg + x);
+#endif /* PSZ == 24 */
+ if ((x == info.end.x) || (y == info.end.y))
+ {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ MIARCSTEP(yoffset += dyoffset;, yoffset += npwidth;);
+ }
+ }
+ if ((x == info.start.x) || (y == info.start.y))
+ mask = info.start.mask;
+#if PSZ == 24
+ if (mask & 1){
+ xtmp = (xorg3 + x * 3) >> 2;
+ RROP_SOLID24(yorgp + yoffset + xtmp, xorg + x);
+ }
+ if (mask & 4){
+ xtmp = (xorgo3 - x * 3) >> 2;
+ RROP_SOLID24(yorgop - yoffset + xtmp, xorgo - x);
+ }
+#else
+ if (mask & 1)
+ RROP_SOLID(yorgp + yoffset + info.xorg + x);
+ if (mask & 4)
+ RROP_SOLID(yorgop - yoffset + info.xorgo - x);
+#endif /* PSZ == 24 */
+ if (arc->height & 1)
+ {
+#if PSZ == 24
+ if (mask & 2){
+ xtmp = (xorgo3 - x * 3) >> 2;
+ RROP_SOLID24(yorgp + yoffset + xtmp, xorgo - x);
+ }
+ if (mask & 8){
+ xtmp = (xorg3 + x * 3) >> 2;
+ RROP_SOLID24(yorgop - yoffset + xtmp, xorg + x);
+ }
+#else
+ if (mask & 2)
+ RROP_SOLID(yorgp + yoffset + info.xorgo - x);
+ if (mask & 8)
+ RROP_SOLID(yorgop - yoffset + info.xorg + x);
+#endif /* PSZ == 24 */
+ }
+ RROP_UNDECLARE
+}
+
+void
+RROP_NAME (cfbZeroPolyArcSS8) (pDraw, pGC, narcs, parcs)
+ register DrawablePtr pDraw;
+ GCPtr pGC;
+ int narcs;
+ xArc *parcs;
+{
+ register xArc *arc;
+ register int i;
+ BoxRec box;
+ int x2, y2;
+ RegionPtr cclip;
+
+ cclip = cfbGetCompositeClip(pGC);
+ for (arc = parcs, i = narcs; --i >= 0; arc++)
+ {
+ if (miCanZeroArc(arc))
+ {
+ box.x1 = arc->x + pDraw->x;
+ box.y1 = arc->y + pDraw->y;
+ /*
+ * Because box.x2 and box.y2 get truncated to 16 bits, and the
+ * RECT_IN_REGION test treats the resulting number as a signed
+ * integer, the RECT_IN_REGION test alone can go the wrong way.
+ * This can result in a server crash because the rendering
+ * routines in this file deal directly with cpu addresses
+ * of pixels to be stored, and do not clip or otherwise check
+ * that all such addresses are within their respective pixmaps.
+ * So we only allow the RECT_IN_REGION test to be used for
+ * values that can be expressed correctly in a signed short.
+ */
+ x2 = box.x1 + (int)arc->width + 1;
+ box.x2 = x2;
+ y2 = box.y1 + (int)arc->height + 1;
+ box.y2 = y2;
+ if ( (x2 <= MAXSHORT) && (y2 <= MAXSHORT) &&
+ (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) )
+ RROP_NAME (cfbZeroArcSS8) (pDraw, pGC, arc);
+ else
+ miZeroPolyArc(pDraw, pGC, 1, arc);
+ }
+ else
+ miPolyArc(pDraw, pGC, 1, arc);
+ }
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/cfb/module/Imakefile b/nx-X11/programs/Xserver/cfb/module/Imakefile
new file mode 100644
index 000000000..feb27baa3
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/module/Imakefile
@@ -0,0 +1,11 @@
+XCOMM $XFree86: xc/programs/Xserver/cfb/module/Imakefile,v 1.1 2002/05/31 15:12:56 dawes Exp $
+
+#define IHaveModules
+
+#define PixelSize 8
+#define LinkDirectory ..
+#ifdef OS2Architecture
+CFBCMAP = cfbcmap.o
+#endif
+
+#include "../Imakefile.inc"
diff --git a/nx-X11/programs/Xserver/cfb/stip68kgnu.h b/nx-X11/programs/Xserver/cfb/stip68kgnu.h
new file mode 100644
index 000000000..01bb939e8
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/stip68kgnu.h
@@ -0,0 +1,123 @@
+/*
+ * $Xorg: stip68kgnu.h,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $
+ *
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/programs/Xserver/cfb/stip68kgnu.h,v 3.3 2001/01/17 22:36:37 dawes Exp $ */
+
+/*
+ * Stipple stack macro for 68k GCC
+ */
+
+#define STIPPLE(addr,stipple,value,width,count,shift) \
+ __asm volatile ( \
+ "lea 5f,%/a1\n\
+ moveq #28,%/d2\n\
+ addl %2,%/d2\n\
+ moveq #28,%/d3\n\
+ subql #4,%2\n\
+ negl %2\n\
+1:\n\
+ movel %0,%/a0\n\
+ addl %6,%0\n\
+ movel %3@+,%/d1\n\
+ jeq 3f\n\
+ movel %/d1,%/d0\n\
+ lsrl %/d2,%/d0\n\
+ lsll #5,%/d0\n\
+ lsll %2,%/d1\n\
+ jmp %/a1@(%/d0:l)\n\
+2:\n\
+ addl #4,%/a0\n\
+ movel %/d1,%/d0\n\
+ lsrl %/d3,%/d0\n\
+ lsll #5,%/d0\n\
+ lsll #4,%/d1\n\
+ jmp %/a1@(%/d0:l)\n\
+5:\n\
+ jne 2b ; dbra %1,1b ; jra 4f\n\
+ . = 5b + 0x20\n\
+ moveb %5,%/a0@(3)\n\
+ andl %/d1,%/d1 ; jne 2b ; dbra %1,1b ; jra 4f\n\
+ . = 5b + 0x40\n\
+ moveb %5,%/a0@(2)\n\
+ andl %/d1,%/d1 ; jne 2b ; dbra %1,1b ; jra 4f\n\
+ . = 5b + 0x60\n\
+ movew %5,%/a0@(2)\n\
+ andl %/d1,%/d1 ; jne 2b ; dbra %1,1b ; jra 4f\n\
+ . = 5b + 0x80\n\
+ moveb %5,%/a0@(1)\n\
+ andl %/d1,%/d1 ; jne 2b ; dbra %1,1b ; jra 4f ;\n\
+ . = 5b + 0xa0\n\
+ moveb %5,%/a0@(3) ; moveb %5,%/a0@(1)\n\
+ andl %/d1,%/d1 ; jne 2b ; dbra %1,1b ; jra 4f ;\n\
+ . = 5b + 0xc0\n\
+ movew %5,%/a0@(1)\n\
+ andl %/d1,%/d1 ; jne 2b ; dbra %1,1b ; jra 4f ;\n\
+ . = 5b + 0xe0\n\
+ movew %5,%/a0@(2) ; moveb %5,%/a0@(1)\n\
+ andl %/d1,%/d1 ; jne 2b ; dbra %1,1b ; jra 4f ;\n\
+ . = 5b + 0x100\n\
+ moveb %5,%/a0@\n\
+ andl %/d1,%/d1 ; jne 2b ; dbra %1,1b ; jra 4f ;\n\
+ . = 5b + 0x120\n\
+ moveb %5,%/a0@(3) ; moveb %5,%/a0@\n\
+ andl %/d1,%/d1 ; jne 2b ; dbra %1,1b ; jra 4f ;\n\
+ . = 5b + 0x140\n\
+ moveb %5,%/a0@(2) ; moveb %5,%/a0@\n\
+ andl %/d1,%/d1 ; jne 2b ; dbra %1,1b ; jra 4f ;\n\
+ . = 5b + 0x160\n\
+ movew %5,%/a0@(2) ; moveb %5,%/a0@\n\
+ andl %/d1,%/d1 ; jne 2b ; dbra %1,1b ; jra 4f ;\n\
+ . = 5b + 0x180\n\
+ movew %5,%/a0@\n\
+ andl %/d1,%/d1 ; jne 2b ; dbra %1,1b ; jra 4f ;\n\
+ . = 5b + 0x1a0\n\
+ moveb %5,%/a0@(3) ; movew %5,%/a0@\n\
+ andl %/d1,%/d1 ; jne 2b ; dbra %1,1b ; jra 4f ;\n\
+ . = 5b + 0x1c0\n\
+ moveb %5,%/a0@(2) ; movew %5,%/a0@\n\
+ andl %/d1,%/d1 ; jne 2b ; dbra %1,1b ; jra 4f ;\n\
+ . = 5b + 0x1e0\n\
+ movel %5,%/a0@\n\
+ andl %/d1,%/d1 ; jne 2b ; \n\
+3: dbra %1,1b ; \n\
+4:\n"\
+ : "=a" (addr), /* %0 */ \
+ "=d" (count), /* %1 */ \
+ "=d" (shift), /* %2 */ \
+ "=a" (stipple) /* %3 */ \
+ : "0" (addr), /* %4 */ \
+ "d" (value), /* %5 */ \
+ "a" (width), /* %6 */ \
+ "1" (count-1), /* %7 */ \
+ "2" (shift), /* %8 */ \
+ "3" (stipple) /* %9 */ \
+ : /* ctemp */ "d0", \
+ /* c */ "d1", \
+ /* lshift */ "d2", \
+ /* rshift */ "d3", \
+ /* atemp */ "a0", \
+ /* case */ "a1")
diff --git a/nx-X11/programs/Xserver/cfb/stipmips.s b/nx-X11/programs/Xserver/cfb/stipmips.s
new file mode 100644
index 000000000..c42d9b5ae
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/stipmips.s
@@ -0,0 +1,281 @@
+/*
+ * $Xorg: stipmips.s,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $
+ *
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/*
+ * MIPS assembly code for optimized text rendering.
+ *
+ * Other stippling could be done in assembly, but the payoff is
+ * not nearly as large. Mostly because large areas are heavily
+ * optimized already.
+ */
+
+#ifdef MIPSEL
+# define BitsR sll
+# define BitsL srl
+# define BO(o) o
+# define HO(o) o
+# define WO(o) o
+# define FourBits(dest,bits) and dest, bits, 0xf
+#else
+# define BitsR srl
+# define BitsL sll
+# define BO(o) 3-o
+# define HO(o) 2-o
+# define WO(o) o
+# define FourBits(dest,bits) srl dest, bits, 28
+#endif
+
+/* reordering instructions would be fatal here */
+ .set noreorder
+
+
+/*
+ * cfbStippleStack(addr, stipple, value, stride, Count, Shift)
+ * 4 5 6 7 16(sp) 20(sp)
+ *
+ * Apply successive 32-bit stipples starting at addr, addr+stride, ...
+ *
+ * Used for text rendering, but only when no data could be lost
+ * when the stipple is shifted left by Shift bits
+ */
+/* arguments */
+#define addr $4
+#define stipple $5
+#define value $6
+#define stride $7
+#define Count 16($sp)
+#define Shift 20($sp)
+
+/* local variables */
+#define count $14
+#define shift $13
+#define atemp $12
+#define bits $11
+#define lshift $9
+#define sbase $8
+#define stemp $2
+
+#define CASE_SIZE 5 /* case blocks are 2^5 bytes each */
+#define CASE_MASK 0x1e0 /* first case mask */
+
+#define ForEachLine $200
+#define NextLine $201
+#define NextLine1 $202
+#define CaseBegin $203
+#define ForEachBits $204
+#define ForEachBits1 $205
+#define NextBits $206
+
+#ifdef TETEXT
+#define cfbStippleStack cfbStippleStackTE
+#endif
+
+ .globl cfbStippleStack
+ .ent cfbStippleStack 2
+cfbStippleStack:
+ .frame $sp, 0, $31
+ lw count, Count /* fetch stack params */
+ la sbase,CaseBegin /* load up switch table */
+ lw shift, Shift
+ li lshift, 4 /* compute offset within */
+ subu lshift, lshift, shift /* stipple of remaining bits */
+#ifdef MIPSEL
+ addu shift, shift, CASE_SIZE /* first shift for LSB */
+#else
+ addu shift, shift, 28-CASE_SIZE /* first shift for MSB */
+#endif
+ /* do ... while (--count > 0); */
+ForEachLine:
+ lw bits, 0(stipple) /* get stipple bits */
+ move atemp, addr /* set up for this line */
+#ifdef TETEXT
+ /* Terminal emulator fonts are expanded and have many 0 rows */
+ beqz bits, NextLine /* skip out early on 0 */
+#endif
+ addu addr, addr, stride /* step for the loop */
+ BitsR stemp, bits, shift /* get first bits */
+ and stemp, stemp, CASE_MASK /* compute first branch */
+ addu stemp, stemp, sbase /* ... */
+ j stemp /* ... */
+ BitsL bits, bits, lshift /* set remaining bits */
+
+ForEachBits:
+ addu atemp, atemp, 4
+ForEachBits1:
+ FourBits(stemp, bits) /* compute jump for */
+ sll stemp, stemp, CASE_SIZE /* next four bits */
+ addu stemp, stemp, sbase /* ... */
+ j stemp /* ... */
+ BitsL bits, bits, 4 /* step for remaining bits */
+CaseBegin:
+ bnez bits, ForEachBits1 /* 0 */
+ addu atemp, atemp, 4
+NextLine:
+ addu count, count, -1
+ bnez count, ForEachLine
+ addu stipple, stipple, 4
+ j $31
+ nop
+ nop
+
+ bnez bits, ForEachBits /* 1 */
+ sb value, BO(0)(atemp)
+ addu count, count, -1
+ bnez count, ForEachLine
+ addu stipple, stipple, 4
+ j $31
+ nop
+ nop
+
+ bnez bits, ForEachBits /* 2 */
+ sb value, BO(1)(atemp)
+ addu count, count, -1
+ bnez count, ForEachLine
+ addu stipple, stipple, 4
+ j $31
+ nop
+ nop
+
+ bnez bits, ForEachBits /* 3 */
+ sh value, HO(0)(atemp)
+ addu count, count, -1
+ bnez count, ForEachLine
+ addu stipple, stipple, 4
+ j $31
+ nop
+ nop
+
+ bnez bits, ForEachBits /* 4 */
+ sb value, BO(2)(atemp)
+ addu count, count, -1
+ bnez count, ForEachLine
+ addu stipple, stipple, 4
+ j $31
+ nop
+ nop
+
+ sb value, BO(0)(atemp) /* 5 */
+ bnez bits, ForEachBits
+ sb value, BO(2)(atemp)
+ addu count, count, -1
+ bnez count, ForEachLine
+ addu stipple, stipple, 4
+ j $31
+ nop
+
+ sb value, BO(1)(atemp) /* 6 */
+ bnez bits, ForEachBits
+ sb value, BO(2)(atemp)
+ addu count, count, -1
+ bnez count, ForEachLine
+ addu stipple, stipple, 4
+ j $31
+ nop
+
+ bnez bits, ForEachBits /* 7 */
+ swl value, BO(2)(atemp) /* untested on MSB */
+ addu count, count, -1
+ bnez count, ForEachLine
+ addu stipple, stipple, 4
+ j $31
+ nop
+ nop
+
+ bnez bits, ForEachBits /* 8 */
+ sb value, BO(3)(atemp)
+ addu count, count, -1
+ bnez count, ForEachLine
+ addu stipple, stipple, 4
+ j $31
+ nop
+ nop
+
+ sb value, BO(0)(atemp) /* 9 */
+ bnez bits, ForEachBits
+ sb value, BO(3)(atemp)
+ addu count, count, -1
+ bnez count, ForEachLine
+ addu stipple, stipple, 4
+ j $31
+ nop
+
+ sb value, BO(1)(atemp) /* a */
+ bnez bits, ForEachBits
+ sb value, BO(3)(atemp)
+ addu count, count, -1
+ bnez count, ForEachLine
+ addu stipple, stipple, 4
+ j $31
+ nop
+
+ sh value, HO(0)(atemp) /* b */
+ bnez bits, ForEachBits
+ sb value, BO(3)(atemp)
+ addu count, count, -1
+ bnez count, ForEachLine
+ addu stipple, stipple, 4
+ j $31
+ nop
+
+ bnez bits, ForEachBits /* c */
+ sh value, HO(2)(atemp)
+ addu count, count, -1
+ bnez count, ForEachLine
+ addu stipple, stipple, 4
+ j $31
+ nop
+ nop
+
+ sb value, BO(0)(atemp) /* d */
+ bnez bits, ForEachBits
+ sh value, HO(2)(atemp)
+ addu count, count, -1
+ bnez count, ForEachLine
+ addu stipple, stipple, 4
+ j $31
+ nop
+
+ bnez bits, ForEachBits /* e */
+ swr value, BO(1)(atemp) /* untested on MSB */
+ addu count, count, -1
+ bnez count, ForEachLine
+ addu stipple, stipple, 4
+ j $31
+ nop
+ nop
+
+ bnez bits, ForEachBits /* f */
+ sw value, WO(0)(atemp)
+ addu count, count, -1
+ bnez count, ForEachLine
+ addu stipple, stipple, 4
+ j $31
+ nop
+ nop
+
+ .end cfbStippleStack
diff --git a/nx-X11/programs/Xserver/cfb/stipple68k.s b/nx-X11/programs/Xserver/cfb/stipple68k.s
new file mode 100644
index 000000000..2f892b386
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/stipple68k.s
@@ -0,0 +1,231 @@
+/*
+ * $Xorg: stipple68k.s,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $
+ *
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/programs/Xserver/cfb/stipple68k.s,v 3.2 2001/01/17 22:36:38 dawes Exp $ */
+
+/*
+ * Stipple code for 68k processors
+ */
+
+#ifdef __ELF__
+#ifdef TETEXT
+#define _cfbStippleStack cfbStippleStackTE
+#else
+#define _cfbStippleStack cfbStippleStack
+#endif
+#else
+#ifdef TETEXT
+#define _cfbStippleStack _cfbStippleStackTE
+#endif
+#endif
+
+
+#define atemp a0
+#define addr a1
+#define stipple a2
+#define stride a3
+#define case a4
+
+#define ctemp d0
+#define value d1
+#define count d2
+#define shift d3
+#define c d4
+#define lshift d5
+#define rshift d6
+
+#define PushMask #0x3e38
+#define PopMask #0x1c7c
+#define NumReg 8
+#define arg0 36
+#define arg1 40
+#define arg2 44
+#define arg3 48
+#define arg4 52
+#define arg5 56
+#define arg6 60
+
+#ifdef __ELF__
+#define ForEachLine .L2
+#define ForEachBits .L5
+#define a0 %A0
+#define a1 %A1
+#define a2 %A2
+#define a3 %A3
+#define a4 %A4
+#define a5 %A5
+#define a6 %A6
+#define sp %SP
+#define d0 %D0
+#define d1 %D1
+#define d2 %D2
+#define d3 %D3
+#define d4 %D4
+#define d5 %D5
+#define d6 %D6
+#define d7 %D7
+#else
+#define ForEachLine L2
+#define ForEachBits L5
+#endif
+#define CASE_SIZE 5
+
+.text
+ .even
+ .globl _cfbStippleStack
+_cfbStippleStack:
+ moveml PushMask,sp@-
+ movel sp@(arg0),addr
+ movel sp@(arg1),stipple
+ movel sp@(arg2),value
+ movel sp@(arg3),stride
+ movew sp@(arg4+2),count
+ movel sp@(arg5),shift
+ subqw #1,count /* predecrement count */
+ lea CaseBegin,case
+ movew #28,lshift
+ addl shift,lshift
+ movew #28,rshift
+ subql #4,shift
+ negl shift
+ForEachLine:
+ movel addr,atemp
+ addl stride,addr
+ movel stipple@+,c
+#ifdef TETEXT
+ jeq NextLine
+#endif
+ /* Get first few bits */
+ movel c,ctemp
+ lsrl lshift,ctemp
+ lsll #CASE_SIZE,ctemp
+ lsll shift,c /* set up for next bits */
+ jmp case@(ctemp:l)
+
+ForEachBits:
+ addl #4,atemp
+ movel c,ctemp
+ lsrl rshift,ctemp /* better than lsrl, andi */
+ lsll #CASE_SIZE,ctemp
+ lsll #4,c /* set up for next bits */
+ jmp case@(ctemp:l)
+
+#define Break \
+ andl c,c ; \
+ jne ForEachBits ; \
+ dbra count,ForEachLine ; \
+ moveml sp@+,PopMask ; \
+ rts ;
+
+CaseBegin:
+ jne ForEachBits /* 0 */
+NextLine:
+ dbra count,ForEachLine
+ moveml sp@+,PopMask
+ rts
+
+ . = CaseBegin + 0x20
+
+ moveb value,atemp@(3) /* 1 */
+ Break
+
+ . = CaseBegin + 0x40
+
+ moveb value,atemp@(2) /* 2 */
+ Break
+
+ . = CaseBegin + 0x60
+
+ movew value,atemp@(2) /* 3 */
+ Break
+
+ . = CaseBegin + 0x80
+
+ moveb value,atemp@(1) /* 4 */
+ Break
+
+ . = CaseBegin + 0xa0
+
+ moveb value,atemp@(3) /* 5 */
+ moveb value,atemp@(1)
+ Break
+
+ . = CaseBegin + 0xc0
+
+ movew value,atemp@(1) /* 6 */
+ Break
+
+ . = CaseBegin + 0xe0
+
+ movew value,atemp@(2) /* 7 */
+ moveb value,atemp@(1)
+ Break
+
+ . = CaseBegin + 0x100
+
+ moveb value,atemp@ /* 8 */
+ Break
+
+ . = CaseBegin + 0x120
+
+ moveb value,atemp@(3) /* 9 */
+ moveb value,atemp@
+ Break
+
+ . = CaseBegin + 0x140
+
+ moveb value,atemp@(2) /* a */
+ moveb value,atemp@
+ Break
+
+ . = CaseBegin + 0x160
+
+ movew value,atemp@(2) /* b */
+ moveb value,atemp@
+ Break
+
+ . = CaseBegin + 0x180
+
+ movew value,atemp@ /* c */
+ Break
+
+ . = CaseBegin + 0x1a0
+
+ moveb value,atemp@(3) /* d */
+ movew value,atemp@
+ Break
+
+ . = CaseBegin + 0x1c0
+
+ moveb value,atemp@(2) /* e */
+ movew value,atemp@
+ Break
+
+ . = CaseBegin + 0x1e0
+
+ movel value,atemp@ /* f */
+ Break
diff --git a/nx-X11/programs/Xserver/cfb/stipsparc.s b/nx-X11/programs/Xserver/cfb/stipsparc.s
new file mode 100644
index 000000000..8ee5e2698
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/stipsparc.s
@@ -0,0 +1,290 @@
+/*
+ * $Xorg: stipsparc.s,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $
+ * $XdotOrg: xc/programs/Xserver/cfb/stipsparc.s,v 1.3 2004/04/26 02:39:58 alanc Exp $
+ *
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/programs/Xserver/cfb/stipsparc.s,v 1.4 2001/01/17 22:36:38 dawes Exp $ */
+
+/*
+ * SPARC assembly code for optimized text rendering.
+ *
+ * Other stippling could be done in assembly, but the payoff is
+ * not nearly as large. Mostly because large areas are heavily
+ * optimized already.
+ */
+
+/* not that I expect to ever see an LSB SPARC, but ... */
+#ifdef LITTLE_ENDIAN
+# define BitsR sll
+# define BitsL srl
+# define BO(o) o
+# define HO(o) o
+# define WO(o) o
+# define FourBits(dest,bits) and bits, 0xf, dest
+#else
+# define BitsR srl
+# define BitsL sll
+# define BO(o) 3-o
+# define HO(o) 2-o
+# define WO(o) o
+# define FourBits(dest,bits) srl bits, 28, dest
+#endif
+
+/*
+ * cfbStippleStack(addr, stipple, value, stride, Count, Shift)
+ * 4 5 6 7 16(sp) 20(sp)
+ *
+ * Apply successive 32-bit stipples starting at addr, addr+stride, ...
+ *
+ * Used for text rendering, but only when no data could be lost
+ * when the stipple is shifted left by Shift bits
+ */
+/* arguments */
+#define addr %i0
+#define stipple %i1
+#define value %i2
+#define stride %i3
+#define count %i4
+#define shift %i5
+
+/* local variables */
+#define atemp %l0
+#define bits %l1
+#define lshift %l2
+#define sbase %l3
+#define stemp %l4
+
+#define CASE_SIZE 5 /* case blocks are 2^5 bytes each */
+#define CASE_MASK 0x1e0 /* first case mask */
+
+#define ForEachLine LY1
+#define NextLine LY2
+#define CaseBegin LY3
+#define ForEachBits LY4
+#define NextBits LY5
+
+#if defined(SVR4) || defined(__ELF__)
+#ifdef TETEXT
+#define _cfbStippleStack cfbStippleStackTE
+#else
+#define _cfbStippleStack cfbStippleStack
+#endif
+#else
+#ifdef TETEXT
+#define _cfbStippleStack _cfbStippleStackTE
+#endif
+#endif
+ .seg "text"
+ .proc 16
+ .globl _cfbStippleStack
+_cfbStippleStack:
+ save %sp,-64,%sp
+#ifdef SHAREDCODE
+1:
+ call 2f
+ nop
+2:
+ mov %o7,sbase /* sbase = 1b(1:) */
+ add sbase, CaseBegin-1b, sbase
+#else /* !SHAREDCODE */
+ sethi %hi(CaseBegin),sbase /* load up switch table */
+ or sbase,%lo(CaseBegin),sbase
+#endif /* SHAREDCODE */
+ mov 4,lshift /* compute offset within */
+ sub lshift, shift, lshift /* stipple of remaining bits */
+#ifdef LITTLE_ENDIAN
+ inc CASE_SIZE, shift /* first shift for LSB */
+#else
+ inc 28-CASE_SIZE, shift /* first shift for MSB */
+#endif
+ /* do ... while (--count > 0); */
+ForEachLine:
+ ld [stipple],bits /* get stipple bits */
+ mov addr,atemp /* set up for this line */
+#ifdef TETEXT
+ /* Terminal emulator fonts are expanded and have many 0 rows */
+ tst bits
+ bz NextLine /* skip out early on 0 */
+#endif
+ add addr, stride, addr /* step for the loop */
+ BitsR bits, shift, stemp /* get first bits */
+ and stemp, CASE_MASK, stemp /* compute first jump */
+ BitsL bits, lshift, bits /* set remaining bits */
+ jmp sbase+stemp /* ... */
+ tst bits
+
+ForEachBits:
+ inc 4, atemp
+ForEachBits1:
+ FourBits(stemp, bits) /* compute jump for */
+ sll stemp, CASE_SIZE, stemp /* these four bits */
+ BitsL bits, 4, bits /* step for remaining bits */
+ jmp sbase+stemp /* jump */
+ tst bits
+CaseBegin:
+ bnz,a ForEachBits1 /* 0 */
+ inc 4, atemp
+NextLine:
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+ nop
+
+ bnz ForEachBits /* 1 */
+ stb value, [atemp+BO(0)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+ nop
+
+ bnz ForEachBits /* 2 */
+ stb value, [atemp+BO(1)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+ nop
+
+ bnz ForEachBits /* 3 */
+ sth value, [atemp+HO(0)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+ nop
+
+ bnz ForEachBits /* 4 */
+ stb value, [atemp+BO(2)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+ nop
+
+ stb value, [atemp+BO(0)] /* 5 */
+ bnz ForEachBits
+ stb value, [atemp+BO(2)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+
+ stb value, [atemp+BO(1)] /* 6 */
+ bnz ForEachBits
+ stb value, [atemp+BO(2)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+
+ sth value, [atemp+HO(0)] /* 7 */
+ bnz ForEachBits
+ stb value, [atemp+BO(2)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+
+ bnz ForEachBits /* 8 */
+ stb value, [atemp+BO(3)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+ nop
+
+ stb value, [atemp+BO(0)] /* 9 */
+ bnz ForEachBits
+ stb value, [atemp+BO(3)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+
+ stb value, [atemp+BO(1)] /* a */
+ bnz ForEachBits
+ stb value, [atemp+BO(3)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+
+ sth value, [atemp+HO(0)] /* b */
+ bnz ForEachBits
+ stb value, [atemp+BO(3)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+
+ bnz ForEachBits /* c */
+ sth value, [atemp+HO(2)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+ nop
+
+ stb value, [atemp+BO(0)] /* d */
+ bnz ForEachBits
+ sth value, [atemp+HO(2)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+
+ stb value, [atemp+BO(1)] /* e */
+ bnz ForEachBits
+ sth value, [atemp+HO(2)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+
+ bnz ForEachBits /* f */
+ st value, [atemp+WO(0)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
diff --git a/nx-X11/programs/Xserver/cfb/stipsprc32.s b/nx-X11/programs/Xserver/cfb/stipsprc32.s
new file mode 100644
index 000000000..59d953f3b
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb/stipsprc32.s
@@ -0,0 +1,291 @@
+/*
+ * $Xorg: stipsprc32.s,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $
+ * $XdotOrg: xc/programs/Xserver/cfb/stipsprc32.s,v 1.3 2004/04/26 02:39:58 alanc Exp $
+ *
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/programs/Xserver/cfb/stipsprc32.s,v 1.4 2001/01/17 22:36:38 dawes Exp $ */
+
+/*
+ * SPARC assembly code for optimized text rendering.
+ *
+ * Other stippling could be done in assembly, but the payoff is
+ * not nearly as large. Mostly because large areas are heavily
+ * optimized already.
+ */
+
+/* not that I expect to ever see an LSB SPARC, but ... */
+#ifdef LITTLE_ENDIAN
+# define BitsR sll
+# define BitsL srl
+# define WO(o) 3-o
+# define FourBits(dest,bits) and bits, 0xf, dest
+#else
+# define BitsR srl
+# define BitsL sll
+# define WO(o) o
+# define FourBits(dest,bits) srl bits, 28, dest
+#endif
+
+/*
+ * cfb32StippleStack(addr, stipple, value, stride, Count, Shift)
+ * 4 5 6 7 16(sp) 20(sp)
+ *
+ * Apply successive 32-bit stipples starting at addr, addr+stride, ...
+ *
+ * Used for text rendering, but only when no data could be lost
+ * when the stipple is shifted left by Shift bits
+ */
+/* arguments */
+#define addr %i0
+#define stipple %i1
+#define value %i2
+#define stride %i3
+#define count %i4
+#define shift %i5
+
+/* local variables */
+#define atemp %l0
+#define bits %l1
+#define lshift %l2
+#define sbase %l3
+#define stemp %l4
+
+#define CASE_SIZE 5 /* case blocks are 2^5 bytes each */
+#define CASE_MASK 0x1e0 /* first case mask */
+
+#define ForEachLine LY1
+#define NextLine LY2
+#define CaseBegin LY3
+#define ForEachBits LY4
+#define NextBits LY5
+
+#if defined(SVR4) || defined(__ELF__)
+#ifdef TETEXT
+#define _cfb32StippleStack cfb32StippleStackTE
+#else
+#define _cfb32StippleStack cfb32StippleStack
+#endif
+#else
+#ifdef TETEXT
+#define _cfb32StippleStack _cfb32StippleStackTE
+#endif
+#endif
+
+ .seg "text"
+ .proc 16
+ .globl _cfb32StippleStack
+_cfb32StippleStack:
+ save %sp,-64,%sp
+#ifdef SHAREDCODE
+1:
+ call 2f
+ nop
+2:
+ mov %o7,sbase /* sbase = 1b(1:) */
+ add sbase, CaseBegin-1b, sbase
+#else /* !SHAREDCODE */
+ sethi %hi(CaseBegin),sbase /* load up switch table */
+ or sbase,%lo(CaseBegin),sbase
+#endif /* !SHAREDCODE */
+ mov 4,lshift /* compute offset within */
+ sub lshift, shift, lshift /* stipple of remaining bits */
+#ifdef LITTLE_ENDIAN
+ inc CASE_SIZE, shift /* first shift for LSB */
+#else
+ inc 28-CASE_SIZE, shift /* first shift for MSB */
+#endif
+ /* do ... while (--count > 0); */
+ForEachLine:
+ ld [stipple],bits /* get stipple bits */
+ mov addr,atemp /* set up for this line */
+#ifdef TETEXT
+ /* Terminal emulator fonts are expanded and have many 0 rows */
+ tst bits
+ bz NextLine /* skip out early on 0 */
+#endif
+ add addr, stride, addr /* step for the loop */
+ BitsR bits, shift, stemp /* get first bits */
+ and stemp, CASE_MASK, stemp /* compute first jump */
+ BitsL bits, lshift, bits /* set remaining bits */
+ jmp sbase+stemp /* ... */
+ tst bits
+
+ForEachBits:
+ inc 16, atemp
+ForEachBits1:
+ FourBits(stemp, bits) /* compute jump for */
+ sll stemp, CASE_SIZE, stemp /* these four bits */
+ BitsL bits, 4, bits /* step for remaining bits */
+ jmp sbase+stemp /* jump */
+ tst bits
+CaseBegin:
+ bnz,a ForEachBits1 /* 0 */
+ inc 16, atemp
+NextLine:
+ deccc 1, count
+NextLine1:
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+ nop
+
+ bnz ForEachBits /* 1 */
+ st value, [atemp+WO(12)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+ nop
+
+ bnz ForEachBits /* 2 */
+ st value, [atemp+WO(8)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+ nop
+
+ st value, [atemp+WO(8)] /* 3 */
+ bnz ForEachBits
+ st value, [atemp+WO(12)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+
+ bnz ForEachBits /* 4 */
+ st value, [atemp+WO(4)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+ nop
+
+ st value, [atemp+WO(4)] /* 5 */
+ bnz ForEachBits
+ st value, [atemp+WO(12)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+
+ st value, [atemp+WO(4)] /* 6 */
+ bnz ForEachBits
+ st value, [atemp+WO(8)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+
+ st value, [atemp+WO(4)] /* 7 */
+ st value, [atemp+WO(8)]
+ bnz ForEachBits
+ st value, [atemp+WO(12)]
+ b NextLine1
+ deccc 1, count
+ nop
+ nop
+
+ bnz ForEachBits /* 8 */
+ st value, [atemp+WO(0)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+ nop
+
+ st value, [atemp+WO(0)] /* 9 */
+ bnz ForEachBits
+ st value, [atemp+WO(12)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+
+ st value, [atemp+WO(0)] /* a */
+ bnz ForEachBits
+ st value, [atemp+WO(8)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+
+ st value, [atemp+WO(0)] /* b */
+ st value, [atemp+WO(8)]
+ bnz ForEachBits
+ st value, [atemp+WO(12)]
+ b NextLine1
+ deccc 1, count
+ nop
+ nop
+
+ st value, [atemp+WO(0)] /* c */
+ bnz ForEachBits
+ st value, [atemp+WO(4)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
+
+ st value, [atemp+WO(0)] /* d */
+ st value, [atemp+WO(4)]
+ bnz ForEachBits
+ st value, [atemp+WO(12)]
+ b NextLine1
+ deccc 1, count
+ nop
+ nop
+
+ st value, [atemp+WO(0)] /* e */
+ st value, [atemp+WO(4)]
+ bnz ForEachBits
+ st value, [atemp+WO(8)]
+ b NextLine1
+ deccc 1, count
+ nop
+ nop
+
+ st value, [atemp+WO(0)] /* f */
+ st value, [atemp+WO(4)]
+ st value, [atemp+WO(8)]
+ bnz ForEachBits
+ st value, [atemp+WO(12)]
+ deccc 1, count
+ bnz,a ForEachLine
+ inc 4, stipple
+ ret
+ restore
diff --git a/nx-X11/programs/Xserver/cfb16/Imakefile b/nx-X11/programs/Xserver/cfb16/Imakefile
new file mode 100644
index 000000000..06f129986
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb16/Imakefile
@@ -0,0 +1,10 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:16 cpqbld Exp $
+
+
+
+XCOMM $XFree86$
+
+#define PixelSize 16
+#define LinkDirectory ../cfb
+
+#include "../cfb/Imakefile.inc"
diff --git a/nx-X11/programs/Xserver/cfb16/cfbmodule.c b/nx-X11/programs/Xserver/cfb16/cfbmodule.c
new file mode 100644
index 000000000..f5ad48f4d
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb16/cfbmodule.c
@@ -0,0 +1,65 @@
+/* $XFree86: xc/programs/Xserver/cfb16/cfbmodule.c,v 1.8 1999/01/26 05:53:49 dawes Exp $ */
+/*
+ * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#define PSZ 16
+
+#ifdef XFree86LOADER
+
+#include "xf86Module.h"
+#include "cfb.h"
+
+static MODULESETUPPROTO(cfb16Setup);
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "cfb16",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_ANSIC, /* Only need the ansic layer */
+ ABI_ANSIC_VERSION,
+ MOD_CLASS_NONE,
+ {0,0,0,0} /* signature, to be patched into the file by a tool */
+};
+
+XF86ModuleData cfb16ModuleData = { &VersRec, cfb16Setup, NULL };
+
+static pointer
+cfb16Setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ /* This modules requires cfb, so load it */
+ return LoadSubModule(module, "cfb", NULL, NULL, NULL, NULL,
+ errmaj, errmin);
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/cfb16/module/Imakefile b/nx-X11/programs/Xserver/cfb16/module/Imakefile
new file mode 100644
index 000000000..55105034f
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb16/module/Imakefile
@@ -0,0 +1,12 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:16 cpqbld Exp $
+
+
+
+XCOMM $XFree86$
+
+#define IHaveModules
+
+#define PixelSize 16
+#define LinkDirectory ../../cfb
+
+#include "../../cfb/Imakefile.inc"
diff --git a/nx-X11/programs/Xserver/cfb24/Imakefile b/nx-X11/programs/Xserver/cfb24/Imakefile
new file mode 100644
index 000000000..af31096be
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb24/Imakefile
@@ -0,0 +1,6 @@
+XCOMM $XFree86: xc/programs/Xserver/cfb24/Imakefile,v 3.1 2002/05/31 15:12:56 dawes Exp $
+
+#define PixelSize 24
+#define LinkDirectory ../cfb
+
+#include "../cfb/Imakefile.inc"
diff --git a/nx-X11/programs/Xserver/cfb24/cfbmodule.c b/nx-X11/programs/Xserver/cfb24/cfbmodule.c
new file mode 100644
index 000000000..c2fb2bcf5
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb24/cfbmodule.c
@@ -0,0 +1,65 @@
+/* $XFree86: xc/programs/Xserver/cfb24/cfbmodule.c,v 1.8 1999/01/26 05:53:49 dawes Exp $ */
+/*
+ * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#define PSZ 24
+
+#ifdef XFree86LOADER
+
+#include "xf86Module.h"
+#include "cfb.h"
+
+static MODULESETUPPROTO(cfb24Setup);
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "cfb24",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_ANSIC, /* Only need the ansic layer */
+ ABI_ANSIC_VERSION,
+ MOD_CLASS_NONE,
+ {0,0,0,0} /* signature, to be patched into the file by a tool */
+};
+
+XF86ModuleData cfb24ModuleData = { &VersRec, cfb24Setup, NULL };
+
+static pointer
+cfb24Setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ /* This modules requires cfb, so load it */
+ return LoadSubModule(module, "cfb", NULL, NULL, NULL, NULL,
+ errmaj, errmin);
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/cfb24/cfbrrop24.h b/nx-X11/programs/Xserver/cfb24/cfbrrop24.h
new file mode 100644
index 000000000..9f15d1a82
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb24/cfbrrop24.h
@@ -0,0 +1,54 @@
+/* $XFree86: xc/programs/Xserver/cfb24/cfbrrop24.h,v 3.1tsi Exp $ */
+
+#define RROP_DECLARE \
+ unsigned long piQxelAnd[3], piQxelXor[3], spiQxelXor[8];
+
+#define RROP_COPY_SETUP(ptn) \
+ spiQxelXor[0] = ptn & 0xFFFFFF; \
+ spiQxelXor[2] = ptn << 24; \
+ spiQxelXor[3] = (ptn & 0xFFFF00)>> 8; \
+ spiQxelXor[4] = ptn << 16; \
+ spiQxelXor[5] = (ptn & 0xFF0000)>> 16; \
+ spiQxelXor[6] = ptn << 8; \
+ spiQxelXor[1] = spiQxelXor[7] = 0;
+
+#define RROP_SOLID24_COPY(dst,index) {\
+ register int idx = ((index) & 3)<< 1; \
+ *(dst) = (*(dst) & cfbrmask[idx])|spiQxelXor[idx]; \
+ idx++; \
+ *((dst)+1) = (*((dst)+1) & cfbrmask[idx])|spiQxelXor[idx]; \
+ }
+
+#define RROP_SET_SETUP(xor, and) \
+ spiQxelXor[0] = xor & 0xFFFFFF; \
+ spiQxelXor[1] = xor << 24; \
+ spiQxelXor[2] = xor << 16; \
+ spiQxelXor[3] = xor << 8; \
+ spiQxelXor[4] = (xor >> 8) & 0xFFFF; \
+ spiQxelXor[5] = (xor >> 16) & 0xFF; \
+ piQxelAnd[0] = (and & 0xFFFFFF)|(and << 24); \
+ piQxelAnd[1] = (and << 16)|((and >> 8) & 0xFFFF); \
+ piQxelAnd[2] = (and << 8)|((and >> 16) & 0xFF); \
+ piQxelXor[0] = (xor & 0xFFFFFF)|(xor << 24); \
+ piQxelXor[1] = (xor << 16)|((xor >> 8) & 0xFFFF); \
+ piQxelXor[2] = (xor << 8)|((xor >> 16) & 0xFF);
+
+
+#define RROP_SOLID24_SET(dst,index) {\
+ switch((index) & 3){ \
+ case 0: \
+ *(dst) = ((*(dst) & (piQxelAnd[0] |0xFF000000))^(piQxelXor[0] & 0xFFFFFF)); \
+ break; \
+ case 3: \
+ *(dst) = ((*(dst) & (piQxelAnd[2]|0xFF))^(piQxelXor[2] & 0xFFFFFF00)); \
+ break; \
+ case 1: \
+ *(dst) = ((*(dst) & (piQxelAnd[0]|0xFFFFFF))^(piQxelXor[0] & 0xFF000000)); \
+ *((dst)+1) = ((*((dst)+1) & (piQxelAnd[1]|0xFFFF0000))^(piQxelXor[1] & 0xFFFF)); \
+ break; \
+ case 2: \
+ *(dst) = ((*(dst) & (piQxelAnd[1]|0xFFFF))^(piQxelXor[1] & 0xFFFF0000)); \
+ *((dst)+1) = ((*((dst)+1) & (piQxelAnd[2]|0xFFFFFF00))^(piQxelXor[2] & 0xFF)); \
+ break; \
+ } \
+ }
diff --git a/nx-X11/programs/Xserver/cfb24/module/Imakefile b/nx-X11/programs/Xserver/cfb24/module/Imakefile
new file mode 100644
index 000000000..d9da99214
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb24/module/Imakefile
@@ -0,0 +1,12 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:16 cpqbld Exp $
+
+
+
+XCOMM $XFree86$
+
+#define IHaveModules
+
+#define PixelSize 24
+#define LinkDirectory ../../cfb
+
+#include "../../cfb/Imakefile.inc"
diff --git a/nx-X11/programs/Xserver/cfb32/Imakefile b/nx-X11/programs/Xserver/cfb32/Imakefile
new file mode 100644
index 000000000..865b714ea
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb32/Imakefile
@@ -0,0 +1,10 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:16 cpqbld Exp $
+
+
+
+XCOMM $XFree86$
+
+#define PixelSize 32
+#define LinkDirectory ../cfb
+
+#include "../cfb/Imakefile.inc"
diff --git a/nx-X11/programs/Xserver/cfb32/cfbmodule.c b/nx-X11/programs/Xserver/cfb32/cfbmodule.c
new file mode 100644
index 000000000..0ead3ef93
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb32/cfbmodule.c
@@ -0,0 +1,65 @@
+/* $XFree86: xc/programs/Xserver/cfb32/cfbmodule.c,v 1.8 1999/01/26 05:53:49 dawes Exp $ */
+/*
+ * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#define PSZ 32
+
+#ifdef XFree86LOADER
+
+#include "xf86Module.h"
+#include "cfb.h"
+
+static MODULESETUPPROTO(cfb32Setup);
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "cfb32",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_ANSIC, /* Only need the ansic layer */
+ ABI_ANSIC_VERSION,
+ MOD_CLASS_NONE,
+ {0,0,0,0} /* signature, to be patched into the file by a tool */
+};
+
+XF86ModuleData cfb32ModuleData = { &VersRec, cfb32Setup, NULL };
+
+static pointer
+cfb32Setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ /* This modules requires cfb, so load it */
+ return LoadSubModule(module, "cfb", NULL, NULL, NULL, NULL,
+ errmaj, errmin);
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/cfb32/module/Imakefile b/nx-X11/programs/Xserver/cfb32/module/Imakefile
new file mode 100644
index 000000000..58c6a6f06
--- /dev/null
+++ b/nx-X11/programs/Xserver/cfb32/module/Imakefile
@@ -0,0 +1,12 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:16 cpqbld Exp $
+
+
+
+XCOMM $XFree86$
+
+#define IHaveModules
+
+#define PixelSize 32
+#define LinkDirectory ../../cfb
+
+#include "../../cfb/Imakefile.inc"
diff --git a/nx-X11/programs/Xserver/composite/Imakefile b/nx-X11/programs/Xserver/composite/Imakefile
new file mode 100644
index 000000000..9d3edcf8c
--- /dev/null
+++ b/nx-X11/programs/Xserver/composite/Imakefile
@@ -0,0 +1,18 @@
+#include <Server.tmpl>
+
+ SRCS = compalloc.c compext.c compinit.c compwindow.c
+
+ OBJS = compalloc.o compext.o compinit.o compwindow.o
+
+ INCLUDES = -I../include -I../mi -I../Xext -I../render -I../xfixes \
+ -I../damageext -I../miext/damage -I$(EXTINCSRC) \
+ -I$(XINCLUDESRC) -I$(FONTINCSRC)
+
+ LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+
+NormalLibraryTarget(composite,$(OBJS))
+NormalLibraryObjectRule()
+LintLibraryTarget(composite,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/composite/compalloc.c b/nx-X11/programs/Xserver/composite/compalloc.c
new file mode 100644
index 000000000..d496ee9ba
--- /dev/null
+++ b/nx-X11/programs/Xserver/composite/compalloc.c
@@ -0,0 +1,553 @@
+/*
+ * $Id: compalloc.c,v 1.7 2005/07/03 07:37:34 daniels Exp $
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "compint.h"
+
+void
+compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
+{
+ WindowPtr pWin = (WindowPtr) closure;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ cs->damaged = TRUE;
+ cw->damaged = TRUE;
+}
+
+static void
+compDestroyDamage (DamagePtr pDamage, void *closure)
+{
+ WindowPtr pWin = (WindowPtr) closure;
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ cw->damage = 0;
+}
+
+/*
+ * Redirect one window for one client
+ */
+int
+compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ CompClientWindowPtr ccw;
+ Bool wasMapped = pWin->mapped;
+
+ /*
+ * Only one Manual update is allowed
+ */
+ if (cw && update == CompositeRedirectManual)
+ for (ccw = cw->clients; ccw; ccw = ccw->next)
+ if (ccw->update == CompositeRedirectManual)
+ return BadAccess;
+
+ /*
+ * Allocate per-client per-window structure
+ * The client *could* allocate multiple, but while supported,
+ * it is not expected to be common
+ */
+ ccw = xalloc (sizeof (CompClientWindowRec));
+ if (!ccw)
+ return BadAlloc;
+ ccw->id = FakeClientID (pClient->index);
+ ccw->update = update;
+ /*
+ * Now make sure there's a per-window structure to hang this from
+ */
+ if (!cw)
+ {
+ cw = xalloc (sizeof (CompWindowRec));
+ if (!cw)
+ {
+ xfree (ccw);
+ return BadAlloc;
+ }
+ cw->damage = DamageCreate (compReportDamage,
+ compDestroyDamage,
+ DamageReportNonEmpty,
+ FALSE,
+ pWin->drawable.pScreen,
+ pWin);
+ if (!cw->damage)
+ {
+ xfree (ccw);
+ xfree (cw);
+ return BadAlloc;
+ }
+ if (wasMapped)
+ UnmapWindow (pWin, FALSE);
+
+ REGION_NULL (pScreen, &cw->borderClip);
+ cw->update = CompositeRedirectAutomatic;
+ cw->clients = 0;
+ cw->oldx = COMP_ORIGIN_INVALID;
+ cw->oldy = COMP_ORIGIN_INVALID;
+ cw->damageRegistered = FALSE;
+ cw->damaged = FALSE;
+ pWin->devPrivates[CompWindowPrivateIndex].ptr = cw;
+ }
+ ccw->next = cw->clients;
+ cw->clients = ccw;
+ if (!AddResource (ccw->id, CompositeClientWindowType, pWin))
+ return BadAlloc;
+ if (ccw->update == CompositeRedirectManual)
+ {
+ if (cw->damageRegistered)
+ {
+ DamageUnregister (&pWin->drawable, cw->damage);
+ cw->damageRegistered = FALSE;
+ }
+ cw->update = CompositeRedirectManual;
+ }
+
+ if (!compCheckRedirect (pWin))
+ {
+ FreeResource (ccw->id, RT_NONE);
+ return BadAlloc;
+ }
+ if (wasMapped && !pWin->mapped)
+ {
+ Bool overrideRedirect = pWin->overrideRedirect;
+ pWin->overrideRedirect = TRUE;
+ MapWindow (pWin, pClient);
+ pWin->overrideRedirect = overrideRedirect;
+ }
+
+ return Success;
+}
+
+/*
+ * Free one of the per-client per-window resources, clearing
+ * redirect and the per-window pointer as appropriate
+ */
+void
+compFreeClientWindow (WindowPtr pWin, XID id)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ CompClientWindowPtr ccw, *prev;
+ Bool wasMapped = pWin->mapped;
+
+ if (!cw)
+ return;
+ for (prev = &cw->clients; (ccw = *prev); prev = &ccw->next)
+ {
+ if (ccw->id == id)
+ {
+ *prev = ccw->next;
+ if (ccw->update == CompositeRedirectManual)
+ cw->update = CompositeRedirectAutomatic;
+ xfree (ccw);
+ break;
+ }
+ }
+ if (!cw->clients)
+ {
+ if (wasMapped)
+ UnmapWindow (pWin, FALSE);
+
+ if (pWin->redirectDraw)
+ compFreePixmap (pWin);
+
+ if (cw->damage)
+ DamageDestroy (cw->damage);
+
+ REGION_UNINIT (pScreen, &cw->borderClip);
+
+ pWin->devPrivates[CompWindowPrivateIndex].ptr = 0;
+ xfree (cw);
+ }
+ else if (cw->update == CompositeRedirectAutomatic &&
+ !cw->damageRegistered && pWin->redirectDraw)
+ {
+ DamageRegister (&pWin->drawable, cw->damage);
+ cw->damageRegistered = TRUE;
+ DamageDamageRegion (&pWin->drawable, &pWin->borderSize);
+ }
+ if (wasMapped && !pWin->mapped)
+ {
+ Bool overrideRedirect = pWin->overrideRedirect;
+ pWin->overrideRedirect = TRUE;
+ MapWindow (pWin, clients[CLIENT_ID(id)]);
+ pWin->overrideRedirect = overrideRedirect;
+ }
+}
+
+/*
+ * This is easy, just free the appropriate resource.
+ */
+
+int
+compUnredirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ CompClientWindowPtr ccw;
+
+ if (!cw)
+ return BadValue;
+
+ for (ccw = cw->clients; ccw; ccw = ccw->next)
+ if (ccw->update == update && CLIENT_ID(ccw->id) == pClient->index)
+ {
+ FreeResource (ccw->id, RT_NONE);
+ return Success;
+ }
+ return BadValue;
+}
+
+/*
+ * Redirect all subwindows for one client
+ */
+
+int
+compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update)
+{
+ CompSubwindowsPtr csw = GetCompSubwindows (pWin);
+ CompClientWindowPtr ccw;
+ WindowPtr pChild;
+
+ /*
+ * Only one Manual update is allowed
+ */
+ if (csw && update == CompositeRedirectManual)
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ if (ccw->update == CompositeRedirectManual)
+ return BadAccess;
+ /*
+ * Allocate per-client per-window structure
+ * The client *could* allocate multiple, but while supported,
+ * it is not expected to be common
+ */
+ ccw = xalloc (sizeof (CompClientWindowRec));
+ if (!ccw)
+ return BadAlloc;
+ ccw->id = FakeClientID (pClient->index);
+ ccw->update = update;
+ /*
+ * Now make sure there's a per-window structure to hang this from
+ */
+ if (!csw)
+ {
+ csw = xalloc (sizeof (CompSubwindowsRec));
+ if (!csw)
+ {
+ xfree (ccw);
+ return BadAlloc;
+ }
+ csw->update = CompositeRedirectAutomatic;
+ csw->clients = 0;
+ pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = csw;
+ }
+ /*
+ * Redirect all existing windows
+ */
+ for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
+ {
+ int ret = compRedirectWindow (pClient, pChild, update);
+ if (ret != Success)
+ {
+ for (pChild = pChild->nextSib; pChild; pChild = pChild->nextSib)
+ (void) compUnredirectWindow (pClient, pChild, update);
+ if (!csw->clients)
+ {
+ xfree (csw);
+ pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = 0;
+ }
+ xfree (ccw);
+ return ret;
+ }
+ }
+ /*
+ * Hook into subwindows list
+ */
+ ccw->next = csw->clients;
+ csw->clients = ccw;
+ if (!AddResource (ccw->id, CompositeClientSubwindowsType, pWin))
+ return BadAlloc;
+ if (ccw->update == CompositeRedirectManual)
+ {
+ csw->update = CompositeRedirectManual;
+ /*
+ * tell damage extension that damage events for this client are
+ * critical output
+ */
+ DamageExtSetCritical (pClient, TRUE);
+ }
+ return Success;
+}
+
+/*
+ * Free one of the per-client per-subwindows resources,
+ * which frees one redirect per subwindow
+ */
+void
+compFreeClientSubwindows (WindowPtr pWin, XID id)
+{
+ CompSubwindowsPtr csw = GetCompSubwindows (pWin);
+ CompClientWindowPtr ccw, *prev;
+ WindowPtr pChild;
+
+ if (!csw)
+ return;
+ for (prev = &csw->clients; (ccw = *prev); prev = &ccw->next)
+ {
+ if (ccw->id == id)
+ {
+ ClientPtr pClient = clients[CLIENT_ID(id)];
+
+ *prev = ccw->next;
+ if (ccw->update == CompositeRedirectManual)
+ {
+ /*
+ * tell damage extension that damage events for this client are
+ * critical output
+ */
+ DamageExtSetCritical (pClient, FALSE);
+ csw->update = CompositeRedirectAutomatic;
+ if (pWin->mapped)
+ (*pWin->drawable.pScreen->ClearToBackground)(pWin, 0, 0, 0, 0, TRUE);
+ }
+
+ /*
+ * Unredirect all existing subwindows
+ */
+ for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
+ (void) compUnredirectWindow (pClient, pChild, ccw->update);
+
+ xfree (ccw);
+ break;
+ }
+ }
+
+ /*
+ * Check if all of the per-client records are gone
+ */
+ if (!csw->clients)
+ {
+ pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = 0;
+ xfree (csw);
+ }
+}
+
+/*
+ * This is easy, just free the appropriate resource.
+ */
+
+int
+compUnredirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update)
+{
+ CompSubwindowsPtr csw = GetCompSubwindows (pWin);
+ CompClientWindowPtr ccw;
+
+ if (!csw)
+ return BadValue;
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ if (ccw->update == update && CLIENT_ID(ccw->id) == pClient->index)
+ {
+ FreeResource (ccw->id, RT_NONE);
+ return Success;
+ }
+ return BadValue;
+}
+
+/*
+ * Add redirection information for one subwindow (during reparent)
+ */
+
+int
+compRedirectOneSubwindow (WindowPtr pParent, WindowPtr pWin)
+{
+ CompSubwindowsPtr csw = GetCompSubwindows (pParent);
+ CompClientWindowPtr ccw;
+
+ if (!csw)
+ return Success;
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ {
+ int ret = compRedirectWindow (clients[CLIENT_ID(ccw->id)],
+ pWin, ccw->update);
+ if (ret != Success)
+ return ret;
+ }
+ return Success;
+}
+
+/*
+ * Remove redirection information for one subwindow (during reparent)
+ */
+
+int
+compUnredirectOneSubwindow (WindowPtr pParent, WindowPtr pWin)
+{
+ CompSubwindowsPtr csw = GetCompSubwindows (pParent);
+ CompClientWindowPtr ccw;
+
+ if (!csw)
+ return Success;
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ {
+ int ret = compUnredirectWindow (clients[CLIENT_ID(ccw->id)],
+ pWin, ccw->update);
+ if (ret != Success)
+ return ret;
+ }
+ return Success;
+}
+
+static PixmapPtr
+compNewPixmap (WindowPtr pWin, int x, int y, int w, int h)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pParent = pWin->parent;
+ PixmapPtr pPixmap;
+ GCPtr pGC;
+
+ pPixmap = (*pScreen->CreatePixmap) (pScreen, w, h, pWin->drawable.depth);
+
+ if (!pPixmap)
+ return 0;
+
+ pPixmap->screen_x = x;
+ pPixmap->screen_y = y;
+
+ pGC = GetScratchGC (pWin->drawable.depth, pScreen);
+
+ /*
+ * Copy bits from the parent into the new pixmap so that it will
+ * have "reasonable" contents in case for background None areas.
+ */
+ if (pGC)
+ {
+ XID val = IncludeInferiors;
+
+ ValidateGC(&pPixmap->drawable, pGC);
+ dixChangeGC (serverClient, pGC, GCSubwindowMode, &val, NULL);
+ (*pGC->ops->CopyArea) (&pParent->drawable,
+ &pPixmap->drawable,
+ pGC,
+ x - pParent->drawable.x,
+ y - pParent->drawable.y,
+ w, h, 0, 0);
+ FreeScratchGC (pGC);
+ }
+ return pPixmap;
+}
+
+Bool
+compAllocPixmap (WindowPtr pWin)
+{
+ int bw = (int) pWin->borderWidth;
+ int x = pWin->drawable.x - bw;
+ int y = pWin->drawable.y - bw;
+ int w = pWin->drawable.width + (bw << 1);
+ int h = pWin->drawable.height + (bw << 1);
+ PixmapPtr pPixmap = compNewPixmap (pWin, x, y, w, h);
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ if (!pPixmap)
+ return FALSE;
+ pWin->redirectDraw = TRUE;
+ compSetPixmap (pWin, pPixmap);
+ cw->oldx = COMP_ORIGIN_INVALID;
+ cw->oldy = COMP_ORIGIN_INVALID;
+ cw->damageRegistered = FALSE;
+ if (cw->update == CompositeRedirectAutomatic)
+ {
+ DamageRegister (&pWin->drawable, cw->damage);
+ cw->damageRegistered = TRUE;
+ }
+ return TRUE;
+}
+
+void
+compFreePixmap (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PixmapPtr pRedirectPixmap, pParentPixmap;
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ if (cw->damageRegistered)
+ {
+ DamageUnregister (&pWin->drawable, cw->damage);
+ cw->damageRegistered = FALSE;
+ DamageEmpty (cw->damage);
+ }
+ /*
+ * Move the parent-constrained border clip region back into
+ * the window so that ValidateTree will handle the unmap
+ * case correctly. Unmap adds the window borderClip to the
+ * parent exposed area; regions beyond the parent cause crashes
+ */
+ REGION_COPY (pScreen, &pWin->borderClip, &cw->borderClip);
+ pRedirectPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ pParentPixmap = (*pScreen->GetWindowPixmap) (pWin->parent);
+ pWin->redirectDraw = FALSE;
+ compSetPixmap (pWin, pParentPixmap);
+ (*pScreen->DestroyPixmap) (pRedirectPixmap);
+}
+
+/*
+ * Make sure the pixmap is the right size and offset. Allocate a new
+ * pixmap to change size, adjust origin to change offset, leaving the
+ * old pixmap in cw->pOldPixmap so bits can be recovered
+ */
+Bool
+compReallocPixmap (WindowPtr pWin, int draw_x, int draw_y,
+ unsigned int w, unsigned int h, int bw)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PixmapPtr pOld = (*pScreen->GetWindowPixmap) (pWin);
+ PixmapPtr pNew;
+ CompWindowPtr cw = GetCompWindow (pWin);
+ int pix_x, pix_y;
+ int pix_w, pix_h;
+
+ assert (cw && pWin->redirectDraw);
+ cw->oldx = pOld->screen_x;
+ cw->oldy = pOld->screen_y;
+ pix_x = draw_x - bw;
+ pix_y = draw_y - bw;
+ pix_w = w + (bw << 1);
+ pix_h = h + (bw << 1);
+ if (pix_w != pOld->drawable.width || pix_h != pOld->drawable.height)
+ {
+ pNew = compNewPixmap (pWin, pix_x, pix_y, pix_w, pix_h);
+ if (!pNew)
+ return FALSE;
+ cw->pOldPixmap = pOld;
+ compSetPixmap (pWin, pNew);
+ }
+ else
+ {
+ pNew = pOld;
+ cw->pOldPixmap = 0;
+ }
+ pNew->screen_x = pix_x;
+ pNew->screen_y = pix_y;
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/composite/compext.c b/nx-X11/programs/Xserver/composite/compext.c
new file mode 100644
index 000000000..657ed9bdc
--- /dev/null
+++ b/nx-X11/programs/Xserver/composite/compext.c
@@ -0,0 +1,409 @@
+/*
+ * $Id: compext.c,v 1.5 2005/07/03 07:37:34 daniels Exp $
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "compint.h"
+
+static CARD8 CompositeReqCode;
+int CompositeClientPrivateIndex;
+RESTYPE CompositeClientWindowType;
+RESTYPE CompositeClientSubwindowsType;
+
+typedef struct _CompositeClient {
+ int major_version;
+ int minor_version;
+} CompositeClientRec, *CompositeClientPtr;
+
+#define GetCompositeClient(pClient) ((CompositeClientPtr) (pClient)->devPrivates[CompositeClientPrivateIndex].ptr)
+
+static void
+CompositeClientCallback (CallbackListPtr *list,
+ pointer closure,
+ pointer data)
+{
+ NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
+ ClientPtr pClient = clientinfo->client;
+ CompositeClientPtr pCompositeClient = GetCompositeClient (pClient);
+
+ pCompositeClient->major_version = 0;
+ pCompositeClient->minor_version = 0;
+}
+
+static void
+CompositeResetProc (ExtensionEntry *extEntry)
+{
+}
+
+static int
+FreeCompositeClientWindow (pointer value, XID ccwid)
+{
+ WindowPtr pWin = value;
+
+ compFreeClientWindow (pWin, ccwid);
+ return Success;
+}
+
+static int
+FreeCompositeClientSubwindows (pointer value, XID ccwid)
+{
+ WindowPtr pWin = value;
+
+ compFreeClientSubwindows (pWin, ccwid);
+ return Success;
+}
+
+static int
+ProcCompositeQueryVersion (ClientPtr client)
+{
+ CompositeClientPtr pCompositeClient = GetCompositeClient (client);
+ xCompositeQueryVersionReply rep;
+ register int n;
+ REQUEST(xCompositeQueryVersionReq);
+
+ REQUEST_SIZE_MATCH(xCompositeQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ if (stuff->majorVersion < COMPOSITE_MAJOR) {
+ rep.majorVersion = stuff->majorVersion;
+ rep.minorVersion = stuff->minorVersion;
+ } else {
+ rep.majorVersion = COMPOSITE_MAJOR;
+ if (stuff->majorVersion == COMPOSITE_MAJOR &&
+ stuff->minorVersion < COMPOSITE_MINOR)
+ rep.minorVersion = stuff->minorVersion;
+ else
+ rep.minorVersion = COMPOSITE_MINOR;
+ }
+ pCompositeClient->major_version = rep.majorVersion;
+ pCompositeClient->minor_version = rep.minorVersion;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.majorVersion, n);
+ swapl(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof(xCompositeQueryVersionReply), (char *)&rep);
+ return(client->noClientException);
+}
+
+static int
+ProcCompositeRedirectWindow (ClientPtr client)
+{
+ WindowPtr pWin;
+ REQUEST(xCompositeRedirectWindowReq);
+
+ REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq);
+ pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
+ if (!pWin)
+ {
+ client->errorValue = stuff->window;
+ return BadWindow;
+ }
+ return compRedirectWindow (client, pWin, stuff->update);
+}
+
+static int
+ProcCompositeRedirectSubwindows (ClientPtr client)
+{
+ WindowPtr pWin;
+ REQUEST(xCompositeRedirectSubwindowsReq);
+
+ REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq);
+ pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
+ if (!pWin)
+ {
+ client->errorValue = stuff->window;
+ return BadWindow;
+ }
+ return compRedirectSubwindows (client, pWin, stuff->update);
+}
+
+static int
+ProcCompositeUnredirectWindow (ClientPtr client)
+{
+ WindowPtr pWin;
+ REQUEST(xCompositeUnredirectWindowReq);
+
+ REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq);
+ pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
+ if (!pWin)
+ {
+ client->errorValue = stuff->window;
+ return BadWindow;
+ }
+ return compUnredirectWindow (client, pWin, stuff->update);
+}
+
+static int
+ProcCompositeUnredirectSubwindows (ClientPtr client)
+{
+ WindowPtr pWin;
+ REQUEST(xCompositeUnredirectSubwindowsReq);
+
+ REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq);
+ pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
+ if (!pWin)
+ {
+ client->errorValue = stuff->window;
+ return BadWindow;
+ }
+ return compUnredirectSubwindows (client, pWin, stuff->update);
+}
+
+static int
+ProcCompositeCreateRegionFromBorderClip (ClientPtr client)
+{
+ WindowPtr pWin;
+ CompWindowPtr cw;
+ RegionPtr pBorderClip, pRegion;
+ REQUEST(xCompositeCreateRegionFromBorderClipReq);
+
+ REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq);
+ pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
+ if (!pWin)
+ {
+ client->errorValue = stuff->window;
+ return BadWindow;
+ }
+
+ LEGAL_NEW_RESOURCE (stuff->region, client);
+
+ cw = GetCompWindow (pWin);
+ if (cw)
+ pBorderClip = &cw->borderClip;
+ else
+ pBorderClip = &pWin->borderClip;
+ pRegion = XFixesRegionCopy (pBorderClip);
+ if (!pRegion)
+ return BadAlloc;
+ REGION_TRANSLATE (pScreen, pRegion, -pWin->drawable.x, -pWin->drawable.y);
+
+ if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
+ return BadAlloc;
+
+ return(client->noClientException);
+}
+
+static int
+ProcCompositeNameWindowPixmap (ClientPtr client)
+{
+ WindowPtr pWin;
+ CompWindowPtr cw;
+ PixmapPtr pPixmap;
+ REQUEST(xCompositeNameWindowPixmapReq);
+
+ REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
+ pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
+ if (!pWin)
+ {
+ client->errorValue = stuff->window;
+ return BadWindow;
+ }
+
+ LEGAL_NEW_RESOURCE (stuff->pixmap, client);
+
+ cw = GetCompWindow (pWin);
+ if (!cw)
+ return BadMatch;
+
+ pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);
+ if (!pPixmap)
+ return BadMatch;
+
+ ++pPixmap->refcnt;
+
+ if (!AddResource (stuff->pixmap, RT_PIXMAP, (pointer) pPixmap))
+ return BadAlloc;
+
+ return(client->noClientException);
+}
+
+int (*ProcCompositeVector[CompositeNumberRequests])(ClientPtr) = {
+ ProcCompositeQueryVersion,
+ ProcCompositeRedirectWindow,
+ ProcCompositeRedirectSubwindows,
+ ProcCompositeUnredirectWindow,
+ ProcCompositeUnredirectSubwindows,
+ ProcCompositeCreateRegionFromBorderClip,
+ ProcCompositeNameWindowPixmap,
+};
+
+static int
+ProcCompositeDispatch (ClientPtr client)
+{
+ REQUEST(xReq);
+
+ if (stuff->data < CompositeNumberRequests)
+ return (*ProcCompositeVector[stuff->data]) (client);
+ else
+ return BadRequest;
+}
+
+static int
+SProcCompositeQueryVersion (ClientPtr client)
+{
+ int n;
+ REQUEST(xCompositeQueryVersionReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCompositeQueryVersionReq);
+ swapl(&stuff->majorVersion, n);
+ swapl(&stuff->minorVersion, n);
+ return (*ProcCompositeVector[stuff->compositeReqType]) (client);
+}
+
+static int
+SProcCompositeRedirectWindow (ClientPtr client)
+{
+ int n;
+ REQUEST(xCompositeRedirectWindowReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq);
+ swapl (&stuff->window, n);
+ return (*ProcCompositeVector[stuff->compositeReqType]) (client);
+}
+
+static int
+SProcCompositeRedirectSubwindows (ClientPtr client)
+{
+ int n;
+ REQUEST(xCompositeRedirectSubwindowsReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq);
+ swapl (&stuff->window, n);
+ return (*ProcCompositeVector[stuff->compositeReqType]) (client);
+}
+
+static int
+SProcCompositeUnredirectWindow (ClientPtr client)
+{
+ int n;
+ REQUEST(xCompositeUnredirectWindowReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq);
+ swapl (&stuff->window, n);
+ return (*ProcCompositeVector[stuff->compositeReqType]) (client);
+}
+
+static int
+SProcCompositeUnredirectSubwindows (ClientPtr client)
+{
+ int n;
+ REQUEST(xCompositeUnredirectSubwindowsReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq);
+ swapl (&stuff->window, n);
+ return (*ProcCompositeVector[stuff->compositeReqType]) (client);
+}
+
+static int
+SProcCompositeCreateRegionFromBorderClip (ClientPtr client)
+{
+ int n;
+ REQUEST(xCompositeCreateRegionFromBorderClipReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq);
+ swapl (&stuff->region, n);
+ swapl (&stuff->window, n);
+ return (*ProcCompositeVector[stuff->compositeReqType]) (client);
+}
+
+static int
+SProcCompositeNameWindowPixmap (ClientPtr client)
+{
+ int n;
+ REQUEST(xCompositeNameWindowPixmapReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
+ swapl (&stuff->window, n);
+ swapl (&stuff->pixmap, n);
+ return (*ProcCompositeVector[stuff->compositeReqType]) (client);
+}
+
+int (*SProcCompositeVector[CompositeNumberRequests])(ClientPtr) = {
+ SProcCompositeQueryVersion,
+ SProcCompositeRedirectWindow,
+ SProcCompositeRedirectSubwindows,
+ SProcCompositeUnredirectWindow,
+ SProcCompositeUnredirectSubwindows,
+ SProcCompositeCreateRegionFromBorderClip,
+ SProcCompositeNameWindowPixmap,
+};
+
+static int
+SProcCompositeDispatch (ClientPtr client)
+{
+ REQUEST(xReq);
+
+ if (stuff->data < CompositeNumberRequests)
+ return (*SProcCompositeVector[stuff->data]) (client);
+ else
+ return BadRequest;
+}
+
+void
+CompositeExtensionInit (void)
+{
+ ExtensionEntry *extEntry;
+ int s;
+
+ CompositeClientWindowType = CreateNewResourceType (FreeCompositeClientWindow);
+ if (!CompositeClientWindowType)
+ return;
+
+ CompositeClientSubwindowsType = CreateNewResourceType (FreeCompositeClientSubwindows);
+ if (!CompositeClientSubwindowsType)
+ return;
+
+ CompositeClientPrivateIndex = AllocateClientPrivateIndex ();
+ if (!AllocateClientPrivate (CompositeClientPrivateIndex,
+ sizeof (CompositeClientRec)))
+ return;
+ if (!AddCallback (&ClientStateCallback, CompositeClientCallback, 0))
+ return;
+
+ extEntry = AddExtension (COMPOSITE_NAME, 0, 0,
+ ProcCompositeDispatch, SProcCompositeDispatch,
+ CompositeResetProc, StandardMinorOpcode);
+ if (!extEntry)
+ return;
+ CompositeReqCode = (CARD8) extEntry->base;
+
+
+ for (s = 0; s < screenInfo.numScreens; s++)
+ if (!compScreenInit (screenInfo.screens[s]))
+ return;
+ miRegisterRedirectBorderClipProc (compSetRedirectBorderClip,
+ compGetRedirectBorderClip);
+}
diff --git a/nx-X11/programs/Xserver/composite/compinit.c b/nx-X11/programs/Xserver/composite/compinit.c
new file mode 100644
index 000000000..d76885c43
--- /dev/null
+++ b/nx-X11/programs/Xserver/composite/compinit.c
@@ -0,0 +1,390 @@
+/*
+ * $Id: compinit.c,v 1.9 2005/07/03 07:37:34 daniels Exp $
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "compint.h"
+
+int CompScreenPrivateIndex;
+int CompWindowPrivateIndex;
+int CompSubwindowsPrivateIndex;
+int CompGeneration;
+
+static Bool
+compCloseScreen (int index, ScreenPtr pScreen)
+{
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret;
+
+ pScreen->CloseScreen = cs->CloseScreen;
+ pScreen->BlockHandler = cs->BlockHandler;
+ pScreen->InstallColormap = cs->InstallColormap;
+ pScreen->ReparentWindow = cs->ReparentWindow;
+ pScreen->MoveWindow = cs->MoveWindow;
+ pScreen->ResizeWindow = cs->ResizeWindow;
+ pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
+
+ pScreen->ClipNotify = cs->ClipNotify;
+ pScreen->PaintWindowBackground = cs->PaintWindowBackground;
+ pScreen->UnrealizeWindow = cs->UnrealizeWindow;
+ pScreen->RealizeWindow = cs->RealizeWindow;
+ pScreen->DestroyWindow = cs->DestroyWindow;
+ pScreen->CreateWindow = cs->CreateWindow;
+ pScreen->CopyWindow = cs->CopyWindow;
+ pScreen->PositionWindow = cs->PositionWindow;
+ xfree (cs);
+ pScreen->devPrivates[CompScreenPrivateIndex].ptr = 0;
+ ret = (*pScreen->CloseScreen) (index, pScreen);
+ return ret;
+}
+
+static void
+compInstallColormap (ColormapPtr pColormap)
+{
+ VisualPtr pVisual = pColormap->pVisual;
+ ScreenPtr pScreen = pColormap->pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ int a;
+
+ for (a = 0; a < NUM_COMP_ALTERNATE_VISUALS; a++)
+ if (pVisual->vid == cs->alternateVisuals[a])
+ return;
+ pScreen->InstallColormap = cs->InstallColormap;
+ (*pScreen->InstallColormap) (pColormap);
+ cs->InstallColormap = pScreen->InstallColormap;
+ pScreen->InstallColormap = compInstallColormap;
+}
+
+static void
+compScreenUpdate (ScreenPtr pScreen)
+{
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ compCheckTree (pScreen);
+ if (cs->damaged)
+ {
+ compWindowUpdate (WindowTable[pScreen->myNum]);
+ cs->damaged = FALSE;
+ }
+}
+
+static void
+compBlockHandler (int i,
+ pointer blockData,
+ pointer pTimeout,
+ pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[i];
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ pScreen->BlockHandler = cs->BlockHandler;
+ compScreenUpdate (pScreen);
+ (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
+ cs->BlockHandler = pScreen->BlockHandler;
+ pScreen->BlockHandler = compBlockHandler;
+}
+
+/*
+ * Add alternate visuals -- always expose an ARGB32 and RGB24 visual
+ */
+
+static DepthPtr
+compFindVisuallessDepth (ScreenPtr pScreen, int d)
+{
+ int i;
+
+ for (i = 0; i < pScreen->numDepths; i++)
+ {
+ DepthPtr depth = &pScreen->allowedDepths[i];
+ if (depth->depth == d)
+ {
+ /*
+ * Make sure it doesn't have visuals already
+ */
+ if (depth->numVids)
+ return 0;
+ /*
+ * looks fine
+ */
+ return depth;
+ }
+ }
+ /*
+ * If there isn't one, then it's gonna be hard to have
+ * an associated visual
+ */
+ return 0;
+}
+
+typedef struct _alternateVisual {
+ int depth;
+ CARD32 format;
+} CompAlternateVisual;
+
+static CompAlternateVisual altVisuals[NUM_COMP_ALTERNATE_VISUALS] = {
+#if COMP_INCLUDE_RGB24_VISUAL
+ { 24, PICT_r8g8b8 },
+#endif
+ { 32, PICT_a8r8g8b8 },
+};
+
+static Bool
+compAddAlternateVisuals (ScreenPtr pScreen, CompScreenPtr cs)
+{
+ VisualPtr visuals;
+ DepthPtr depths[NUM_COMP_ALTERNATE_VISUALS];
+ PictFormatPtr pPictFormats[NUM_COMP_ALTERNATE_VISUALS];
+ int i;
+ int numVisuals;
+ VisualID *vids[NUM_COMP_ALTERNATE_VISUALS];
+ XID *installedCmaps;
+ ColormapPtr installedCmap;
+ int numInstalledCmaps;
+ int numAlternate = 0;
+ int alt;
+
+ memset (cs->alternateVisuals, '\0', sizeof (cs->alternateVisuals));
+
+ for (alt = 0; alt < NUM_COMP_ALTERNATE_VISUALS; alt++)
+ {
+ DepthPtr depth;
+ PictFormatPtr pPictFormat;
+
+ depth = compFindVisuallessDepth (pScreen, altVisuals[alt].depth);
+ if (!depth)
+ continue;
+ /*
+ * Find the right picture format
+ */
+ pPictFormat = PictureMatchFormat (pScreen, altVisuals[alt].depth,
+ altVisuals[alt].format);
+ if (!pPictFormat)
+ continue;
+
+ /*
+ * Allocate vid list for this depth
+ */
+ vids[numAlternate] = xalloc (sizeof (VisualID));
+ if (!vids[numAlternate])
+ continue;
+ depths[numAlternate] = depth;
+ pPictFormats[numAlternate] = pPictFormat;
+ numAlternate++;
+ }
+
+ if (!numAlternate)
+ return TRUE;
+
+ /*
+ * Find the installed colormaps
+ */
+ installedCmaps = xalloc (pScreen->maxInstalledCmaps * sizeof (XID));
+ if (!installedCmaps)
+ {
+ for (alt = 0; alt < numAlternate; alt++)
+ xfree (vids[alt]);
+ return FALSE;
+ }
+ numInstalledCmaps = (*pScreen->ListInstalledColormaps) (pScreen,
+ installedCmaps);
+
+ /*
+ * realloc the visual array to fit the new one in place
+ */
+ numVisuals = pScreen->numVisuals;
+ visuals = xrealloc (pScreen->visuals,
+ (numVisuals + numAlternate) * sizeof (VisualRec));
+ if (!visuals)
+ {
+ for (alt = 0; alt < numAlternate; alt++)
+ xfree (vids[alt]);
+ xfree (installedCmaps);
+ return FALSE;
+ }
+
+ /*
+ * Fix up any existing installed colormaps -- we'll assume that
+ * the only ones created so far have been installed. If this
+ * isn't true, we'll have to walk the resource database looking
+ * for all colormaps.
+ */
+ for (i = 0; i < numInstalledCmaps; i++)
+ {
+ int j;
+
+ installedCmap = LookupIDByType (installedCmaps[i], RT_COLORMAP);
+ if (!installedCmap)
+ continue;
+ j = installedCmap->pVisual - pScreen->visuals;
+ installedCmap->pVisual = &visuals[j];
+ }
+
+ xfree (installedCmaps);
+
+ pScreen->visuals = visuals;
+ pScreen->numVisuals = numVisuals + numAlternate;
+
+ for (alt = 0; alt < numAlternate; alt++)
+ {
+ DepthPtr depth = depths[alt];
+ PictFormatPtr pPictFormat = pPictFormats[alt];
+ VisualPtr visual = &visuals[numVisuals + alt];
+ unsigned long alphaMask;
+
+ /*
+ * Initialize the visual
+ */
+ visual->class = TrueColor;
+ visual->bitsPerRGBValue = 8;
+
+ visual->vid = FakeClientID (0);
+ visual->redMask = (((unsigned long) pPictFormat->direct.redMask) <<
+ pPictFormat->direct.red);
+ visual->greenMask = (((unsigned long) pPictFormat->direct.greenMask) <<
+ pPictFormat->direct.green);
+ visual->blueMask = (((unsigned long) pPictFormat->direct.blueMask) <<
+ pPictFormat->direct.blue);
+ alphaMask = (((unsigned long) pPictFormat->direct.alphaMask) <<
+ pPictFormat->direct.alpha);
+ visual->offsetRed = pPictFormat->direct.red;
+ visual->offsetGreen = pPictFormat->direct.green;
+ visual->offsetBlue = pPictFormat->direct.blue;
+ /*
+ * Include A bits in this (unlike GLX which includes only RGB)
+ * This lets DIX compute suitable masks for colormap allocations
+ */
+ visual->nplanes = Ones (visual->redMask |
+ visual->greenMask |
+ visual->blueMask |
+ alphaMask);
+ /*
+ * find widest component
+ */
+ visual->ColormapEntries = (1 << max (Ones (visual->redMask),
+ max (Ones (visual->greenMask),
+ Ones (visual->blueMask))));
+
+ /*
+ * remember the visual ID to detect auto-update windows
+ */
+ cs->alternateVisuals[alt] = visual->vid;
+
+ /*
+ * Fix up the depth
+ */
+ vids[alt][0] = visual->vid;
+ depth->numVids = 1;
+ depth->vids = vids[alt];
+ }
+ return TRUE;
+}
+
+Bool
+compScreenInit (ScreenPtr pScreen)
+{
+ CompScreenPtr cs;
+
+ if (CompGeneration != serverGeneration)
+ {
+ CompScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ if (CompScreenPrivateIndex == -1)
+ return FALSE;
+ CompWindowPrivateIndex = AllocateWindowPrivateIndex ();
+ if (CompWindowPrivateIndex == -1)
+ return FALSE;
+ CompSubwindowsPrivateIndex = AllocateWindowPrivateIndex ();
+ if (CompSubwindowsPrivateIndex == -1)
+ return FALSE;
+ CompGeneration = serverGeneration;
+ }
+ if (!AllocateWindowPrivate (pScreen, CompWindowPrivateIndex, 0))
+ return FALSE;
+
+ if (!AllocateWindowPrivate (pScreen, CompSubwindowsPrivateIndex, 0))
+ return FALSE;
+
+ if (GetCompScreen (pScreen))
+ return TRUE;
+ cs = (CompScreenPtr) xalloc (sizeof (CompScreenRec));
+ if (!cs)
+ return FALSE;
+
+ cs->damaged = FALSE;
+
+ if (!compAddAlternateVisuals (pScreen, cs))
+ {
+ xfree (cs);
+ return FALSE;
+ }
+
+ cs->PositionWindow = pScreen->PositionWindow;
+ pScreen->PositionWindow = compPositionWindow;
+
+ cs->CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = compCopyWindow;
+
+ cs->CreateWindow = pScreen->CreateWindow;
+ pScreen->CreateWindow = compCreateWindow;
+
+ cs->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = compDestroyWindow;
+
+ cs->RealizeWindow = pScreen->RealizeWindow;
+ pScreen->RealizeWindow = compRealizeWindow;
+
+ cs->UnrealizeWindow = pScreen->UnrealizeWindow;
+ pScreen->UnrealizeWindow = compUnrealizeWindow;
+
+ cs->PaintWindowBackground = pScreen->PaintWindowBackground;
+ pScreen->PaintWindowBackground = compPaintWindowBackground;
+
+ cs->ClipNotify = pScreen->ClipNotify;
+ pScreen->ClipNotify = compClipNotify;
+
+ cs->MoveWindow = pScreen->MoveWindow;
+ pScreen->MoveWindow = compMoveWindow;
+
+ cs->ResizeWindow = pScreen->ResizeWindow;
+ pScreen->ResizeWindow = compResizeWindow;
+
+ cs->ChangeBorderWidth = pScreen->ChangeBorderWidth;
+ pScreen->ChangeBorderWidth = compChangeBorderWidth;
+
+ cs->ReparentWindow = pScreen->ReparentWindow;
+ pScreen->ReparentWindow = compReparentWindow;
+
+ cs->InstallColormap = pScreen->InstallColormap;
+ pScreen->InstallColormap = compInstallColormap;
+
+ cs->BlockHandler = pScreen->BlockHandler;
+ pScreen->BlockHandler = compBlockHandler;
+
+ cs->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = compCloseScreen;
+
+ pScreen->devPrivates[CompScreenPrivateIndex].ptr = (pointer) cs;
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/composite/compint.h b/nx-X11/programs/Xserver/composite/compint.h
new file mode 100644
index 000000000..9a6a22f48
--- /dev/null
+++ b/nx-X11/programs/Xserver/composite/compint.h
@@ -0,0 +1,260 @@
+/*
+ * $Id: compint.h,v 1.8 2005/07/03 08:53:37 daniels Exp $
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _COMPINT_H_
+#define _COMPINT_H_
+
+#include "misc.h"
+#include "scrnintstr.h"
+#include "os.h"
+#include "regionstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "input.h"
+#include "resource.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#include "dixevents.h"
+#include "globals.h"
+#include "picturestr.h"
+#include "extnsionst.h"
+#include "mi.h"
+#include "damage.h"
+#include "damageextint.h"
+#include "xfixes.h"
+#include <X11/extensions/compositeproto.h>
+#include <assert.h>
+
+/*
+ * enable this for debugging
+
+ #define COMPOSITE_DEBUG
+ */
+
+typedef struct _CompClientWindow {
+ struct _CompClientWindow *next;
+ XID id;
+ int update;
+} CompClientWindowRec, *CompClientWindowPtr;
+
+typedef struct _CompWindow {
+ RegionRec borderClip;
+ DamagePtr damage; /* for automatic update mode */
+ Bool damageRegistered;
+ Bool damaged;
+ int update;
+ CompClientWindowPtr clients;
+ int oldx;
+ int oldy;
+ PixmapPtr pOldPixmap;
+ int borderClipX, borderClipY;
+} CompWindowRec, *CompWindowPtr;
+
+#define COMP_ORIGIN_INVALID 0x80000000
+
+typedef struct _CompSubwindows {
+ int update;
+ CompClientWindowPtr clients;
+} CompSubwindowsRec, *CompSubwindowsPtr;
+
+#ifndef COMP_INCLUDE_RGB24_VISUAL
+#define COMP_INCLUDE_RGB24_VISUAL 0
+#endif
+
+#if COMP_INCLUDE_RGB24_VISUAL
+#define NUM_COMP_ALTERNATE_VISUALS 2
+#else
+#define NUM_COMP_ALTERNATE_VISUALS 1
+#endif
+
+typedef struct _CompScreen {
+ PositionWindowProcPtr PositionWindow;
+ CopyWindowProcPtr CopyWindow;
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ PaintWindowProcPtr PaintWindowBackground;
+ ClipNotifyProcPtr ClipNotify;
+ /*
+ * Called from ConfigureWindow, these
+ * three track changes to the offscreen storage
+ * geometry
+ */
+ MoveWindowProcPtr MoveWindow;
+ ResizeWindowProcPtr ResizeWindow;
+ ChangeBorderWidthProcPtr ChangeBorderWidth;
+ /*
+ * Reparenting has an effect on Subwindows redirect
+ */
+ ReparentWindowProcPtr ReparentWindow;
+
+ /*
+ * Colormaps for new visuals better not get installed
+ */
+ InstallColormapProcPtr InstallColormap;
+
+ ScreenBlockHandlerProcPtr BlockHandler;
+ CloseScreenProcPtr CloseScreen;
+ Bool damaged;
+ XID alternateVisuals[NUM_COMP_ALTERNATE_VISUALS];
+} CompScreenRec, *CompScreenPtr;
+
+extern int CompScreenPrivateIndex;
+extern int CompWindowPrivateIndex;
+extern int CompSubwindowsPrivateIndex;
+
+#define GetCompScreen(s) ((CompScreenPtr) ((s)->devPrivates[CompScreenPrivateIndex].ptr))
+#define GetCompWindow(w) ((CompWindowPtr) ((w)->devPrivates[CompWindowPrivateIndex].ptr))
+#define GetCompSubwindows(w) ((CompSubwindowsPtr) ((w)->devPrivates[CompSubwindowsPrivateIndex].ptr))
+
+extern RESTYPE CompositeClientWindowType;
+extern RESTYPE CompositeClientSubwindowsType;
+
+/*
+ * compalloc.c
+ */
+
+void
+compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure);
+
+Bool
+compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update);
+
+void
+compFreeClientWindow (WindowPtr pWin, XID id);
+
+int
+compUnredirectWindow (ClientPtr pClient, WindowPtr pWin, int update);
+
+int
+compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update);
+
+void
+compFreeClientSubwindows (WindowPtr pWin, XID id);
+
+int
+compUnredirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update);
+
+int
+compRedirectOneSubwindow (WindowPtr pParent, WindowPtr pWin);
+
+int
+compUnredirectOneSubwindow (WindowPtr pParent, WindowPtr pWin);
+
+Bool
+compAllocPixmap (WindowPtr pWin);
+
+void
+compFreePixmap (WindowPtr pWin);
+
+Bool
+compReallocPixmap (WindowPtr pWin, int x, int y,
+ unsigned int w, unsigned int h, int bw);
+
+/*
+ * compext.c
+ */
+
+void
+CompositeExtensionInit (void);
+
+/*
+ * compinit.c
+ */
+
+Bool
+compScreenInit (ScreenPtr pScreen);
+
+/*
+ * compwindow.c
+ */
+
+#ifdef COMPOSITE_DEBUG
+void
+compCheckTree (ScreenPtr pScreen);
+#else
+#define compCheckTree(s)
+#endif
+
+void
+compSetPixmap (WindowPtr pWin, PixmapPtr pPixmap);
+
+Bool
+compCheckRedirect (WindowPtr pWin);
+
+Bool
+compPositionWindow (WindowPtr pWin, int x, int y);
+
+Bool
+compRealizeWindow (WindowPtr pWin);
+
+Bool
+compUnrealizeWindow (WindowPtr pWin);
+
+void
+compPaintWindowBackground (WindowPtr pWin, RegionPtr pRegion, int what);
+
+void
+compClipNotify (WindowPtr pWin, int dx, int dy);
+
+void
+compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind);
+
+void
+compResizeWindow (WindowPtr pWin, int x, int y,
+ unsigned int w, unsigned int h, WindowPtr pSib);
+
+void
+compChangeBorderWidth (WindowPtr pWin, unsigned int border_width);
+
+void
+compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent);
+
+Bool
+compCreateWindow (WindowPtr pWin);
+
+Bool
+compDestroyWindow (WindowPtr pWin);
+
+void
+compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion);
+
+RegionPtr
+compGetRedirectBorderClip (WindowPtr pWin);
+
+void
+compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
+
+void
+compWindowUpdate (WindowPtr pWin);
+
+#endif /* _COMPINT_H_ */
diff --git a/nx-X11/programs/Xserver/composite/compwindow.c b/nx-X11/programs/Xserver/composite/compwindow.c
new file mode 100644
index 000000000..2093095f0
--- /dev/null
+++ b/nx-X11/programs/Xserver/composite/compwindow.c
@@ -0,0 +1,755 @@
+/*
+ * $Id: compwindow.c,v 1.11 2005/07/03 07:37:34 daniels Exp $
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "compint.h"
+
+#ifdef COMPOSITE_DEBUG
+static int
+compCheckWindow (WindowPtr pWin, pointer data)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PixmapPtr pWinPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ PixmapPtr pParentPixmap = pWin->parent ? (*pScreen->GetWindowPixmap) (pWin->parent) : 0;
+ PixmapPtr pScreenPixmap = (*pScreen->GetScreenPixmap) (pScreen);
+
+ if (!pWin->parent)
+ {
+ assert (!pWin->redirectDraw);
+ assert (pWinPixmap == pScreenPixmap);
+ }
+ else if (pWin->redirectDraw)
+ {
+ assert (pWinPixmap != pParentPixmap);
+ assert (pWinPixmap != pScreenPixmap);
+ }
+ else
+ {
+ assert (pWinPixmap == pParentPixmap);
+ }
+ assert (0 < pWinPixmap->refcnt && pWinPixmap->refcnt < 3);
+ assert (0 < pScreenPixmap->refcnt && pScreenPixmap->refcnt < 3);
+ if (pParentPixmap)
+ assert (0 <= pParentPixmap->refcnt && pParentPixmap->refcnt < 3);
+ return WT_WALKCHILDREN;
+}
+
+void
+compCheckTree (ScreenPtr pScreen)
+{
+ WalkTree (pScreen, compCheckWindow, 0);
+}
+#endif
+
+typedef struct _compPixmapVisit {
+ WindowPtr pWindow;
+ PixmapPtr pPixmap;
+} CompPixmapVisitRec, *CompPixmapVisitPtr;
+
+static Bool
+compRepaintBorder (ClientPtr pClient, pointer closure)
+{
+ WindowPtr pWindow = LookupWindow ((XID) closure, pClient);
+
+ if (pWindow)
+ {
+ RegionRec exposed;
+
+ REGION_NULL(pScreen, &exposed);
+ REGION_SUBTRACT(pScreen, &exposed, &pWindow->borderClip, &pWindow->winSize);
+ (*pWindow->drawable.pScreen->PaintWindowBorder)(pWindow, &exposed, PW_BORDER);
+ REGION_UNINIT(pScreen, &exposed);
+ }
+ return TRUE;
+}
+
+static int
+compSetPixmapVisitWindow (WindowPtr pWindow, pointer data)
+{
+ CompPixmapVisitPtr pVisit = (CompPixmapVisitPtr) data;
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+
+ if (pWindow != pVisit->pWindow && pWindow->redirectDraw)
+ return WT_DONTWALKCHILDREN;
+ (*pScreen->SetWindowPixmap) (pWindow, pVisit->pPixmap);
+ /*
+ * Recompute winSize and borderSize. This is duplicate effort
+ * when resizing pixmaps, but necessary when changing redirection.
+ * Might be nice to fix this.
+ */
+ SetWinSize (pWindow);
+ SetBorderSize (pWindow);
+ if (HasBorder (pWindow))
+ QueueWorkProc (compRepaintBorder, serverClient,
+ (pointer) pWindow->drawable.id);
+ return WT_WALKCHILDREN;
+}
+
+void
+compSetPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
+{
+ CompPixmapVisitRec visitRec;
+
+ visitRec.pWindow = pWindow;
+ visitRec.pPixmap = pPixmap;
+ TraverseTree (pWindow, compSetPixmapVisitWindow, (pointer) &visitRec);
+ compCheckTree (pWindow->drawable.pScreen);
+}
+
+Bool
+compCheckRedirect (WindowPtr pWin)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ Bool should;
+
+ should = pWin->realized && (pWin->drawable.class != InputOnly) &&
+ (cw != NULL);
+
+ if (should != pWin->redirectDraw)
+ {
+ if (should)
+ return compAllocPixmap (pWin);
+ else
+ compFreePixmap (pWin);
+ }
+ return TRUE;
+}
+
+Bool
+compPositionWindow (WindowPtr pWin, int x, int y)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = TRUE;
+
+ pScreen->PositionWindow = cs->PositionWindow;
+ /*
+ * "Shouldn't need this as all possible places should be wrapped
+ *
+ compCheckRedirect (pWin);
+ */
+#ifdef COMPOSITE_DEBUG
+ if (pWin->redirectDraw != (pWin->viewable && (GetCompWindow(pWin) != NULL)))
+ abort ();
+#endif
+ if (pWin->redirectDraw)
+ {
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ int bw = wBorderWidth (pWin);
+ int nx = pWin->drawable.x - bw;
+ int ny = pWin->drawable.y - bw;
+
+ if (pPixmap->screen_x != nx || pPixmap->screen_y != ny)
+ {
+ pPixmap->screen_x = nx;
+ pPixmap->screen_y = ny;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ }
+ }
+
+ if (!(*pScreen->PositionWindow) (pWin, x, y))
+ ret = FALSE;
+ cs->PositionWindow = pScreen->PositionWindow;
+ pScreen->PositionWindow = compPositionWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+Bool
+compRealizeWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = TRUE;
+
+ pScreen->RealizeWindow = cs->RealizeWindow;
+ compCheckRedirect (pWin);
+ if (!(*pScreen->RealizeWindow) (pWin))
+ ret = FALSE;
+ cs->RealizeWindow = pScreen->RealizeWindow;
+ pScreen->RealizeWindow = compRealizeWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+Bool
+compUnrealizeWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret = TRUE;
+
+ pScreen->UnrealizeWindow = cs->UnrealizeWindow;
+ compCheckRedirect (pWin);
+ if (!(*pScreen->UnrealizeWindow) (pWin))
+ ret = FALSE;
+ cs->UnrealizeWindow = pScreen->UnrealizeWindow;
+ pScreen->UnrealizeWindow = compUnrealizeWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+void
+compPaintWindowBackground (WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompSubwindowsPtr csw = GetCompSubwindows (pWin);
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ if (csw && csw->update == CompositeRedirectManual)
+ return;
+ pScreen->PaintWindowBackground = cs->PaintWindowBackground;
+ (*pScreen->PaintWindowBackground) (pWin, pRegion, what);
+ cs->PaintWindowBackground = pScreen->PaintWindowBackground;
+ pScreen->PaintWindowBackground = compPaintWindowBackground;
+}
+
+/*
+ * Called after the borderClip for the window has settled down
+ * We use this to make sure our extra borderClip has the right origin
+ */
+
+void
+compClipNotify (WindowPtr pWin, int dx, int dy)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ if (cw)
+ {
+ if (cw->borderClipX != pWin->drawable.x ||
+ cw->borderClipY != pWin->drawable.y)
+ {
+ REGION_TRANSLATE (pScreen, &cw->borderClip,
+ pWin->drawable.x - cw->borderClipX,
+ pWin->drawable.y - cw->borderClipY);
+ cw->borderClipX = pWin->drawable.x;
+ cw->borderClipY = pWin->drawable.y;
+ }
+ }
+ if (cs->ClipNotify)
+ {
+ pScreen->ClipNotify = cs->ClipNotify;
+ (*pScreen->ClipNotify) (pWin, dx, dy);
+ cs->ClipNotify = pScreen->ClipNotify;
+ pScreen->ClipNotify = compClipNotify;
+ }
+}
+
+/*
+ * Returns TRUE if the window needs server-provided automatic redirect,
+ * which is true if the child and parent aren't both regular or ARGB visuals
+ */
+
+static Bool
+compIsAlternateVisual (ScreenPtr pScreen,
+ XID visual)
+{
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ int i;
+
+ for (i = 0; i < NUM_COMP_ALTERNATE_VISUALS; i++)
+ if (cs->alternateVisuals[i] == visual)
+ return TRUE;
+ return FALSE;
+}
+
+static Bool
+compImplicitRedirect (WindowPtr pWin, WindowPtr pParent)
+{
+ if (pParent)
+ {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XID winVisual = wVisual (pWin);
+ XID parentVisual = wVisual (pParent);
+
+ if (winVisual != parentVisual &&
+ (compIsAlternateVisual (pScreen, winVisual) ||
+ compIsAlternateVisual (pScreen, parentVisual)))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void
+compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ compCheckTree (pScreen);
+ if (pWin->redirectDraw)
+ {
+ WindowPtr pParent;
+ int draw_x, draw_y;
+ unsigned int w, h, bw;
+
+ /* if this is a root window, can't be moved */
+ if (!(pParent = pWin->parent))
+ return;
+
+ bw = wBorderWidth (pWin);
+ draw_x = pParent->drawable.x + x + (int)bw;
+ draw_y = pParent->drawable.y + y + (int)bw;
+ w = pWin->drawable.width;
+ h = pWin->drawable.height;
+ compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
+ }
+ compCheckTree (pScreen);
+
+ pScreen->MoveWindow = cs->MoveWindow;
+ (*pScreen->MoveWindow) (pWin, x, y, pSib, kind);
+ cs->MoveWindow = pScreen->MoveWindow;
+ pScreen->MoveWindow = compMoveWindow;
+
+ if (pWin->redirectDraw)
+ {
+ CompWindowPtr cw = GetCompWindow (pWin);
+ if (cw->pOldPixmap)
+ {
+ (*pScreen->DestroyPixmap) (cw->pOldPixmap);
+ cw->pOldPixmap = NullPixmap;
+ }
+ }
+
+ compCheckTree (pScreen);
+}
+
+void
+compResizeWindow (WindowPtr pWin, int x, int y,
+ unsigned int w, unsigned int h, WindowPtr pSib)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ compCheckTree (pScreen);
+ if (pWin->redirectDraw)
+ {
+ WindowPtr pParent;
+ int draw_x, draw_y;
+ unsigned int bw;
+
+ /* if this is a root window, can't be moved */
+ if (!(pParent = pWin->parent))
+ return;
+
+ bw = wBorderWidth (pWin);
+ draw_x = pParent->drawable.x + x + (int)bw;
+ draw_y = pParent->drawable.y + y + (int)bw;
+ compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
+ }
+ compCheckTree (pScreen);
+
+ pScreen->ResizeWindow = cs->ResizeWindow;
+ (*pScreen->ResizeWindow) (pWin, x, y, w, h, pSib);
+ cs->ResizeWindow = pScreen->ResizeWindow;
+ pScreen->ResizeWindow = compResizeWindow;
+ if (pWin->redirectDraw)
+ {
+ CompWindowPtr cw = GetCompWindow (pWin);
+ if (cw->pOldPixmap)
+ {
+ (*pScreen->DestroyPixmap) (cw->pOldPixmap);
+ cw->pOldPixmap = NullPixmap;
+ }
+ }
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+void
+compChangeBorderWidth (WindowPtr pWin, unsigned int bw)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ compCheckTree (pScreen);
+ if (pWin->redirectDraw)
+ {
+ WindowPtr pParent;
+ int draw_x, draw_y;
+ unsigned int w, h;
+
+ /* if this is a root window, can't be moved */
+ if (!(pParent = pWin->parent))
+ return;
+
+ draw_x = pWin->drawable.x;
+ draw_y = pWin->drawable.y;
+ w = pWin->drawable.width;
+ h = pWin->drawable.height;
+ compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
+ }
+ compCheckTree (pScreen);
+
+ pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
+ (*pScreen->ChangeBorderWidth) (pWin, bw);
+ cs->ChangeBorderWidth = pScreen->ChangeBorderWidth;
+ pScreen->ChangeBorderWidth = compChangeBorderWidth;
+ if (pWin->redirectDraw)
+ {
+ CompWindowPtr cw = GetCompWindow (pWin);
+ if (cw->pOldPixmap)
+ {
+ (*pScreen->DestroyPixmap) (cw->pOldPixmap);
+ cw->pOldPixmap = NullPixmap;
+ }
+ }
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+void
+compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+
+ pScreen->ReparentWindow = cs->ReparentWindow;
+ /*
+ * Remove any implicit redirect due to synthesized visual
+ */
+ if (compImplicitRedirect (pWin, pPriorParent))
+ compUnredirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+ /*
+ * Handle subwindows redirection
+ */
+ compUnredirectOneSubwindow (pPriorParent, pWin);
+ compRedirectOneSubwindow (pWin->parent, pWin);
+ /*
+ * Add any implict redirect due to synthesized visual
+ */
+ if (compImplicitRedirect (pWin, pWin->parent))
+ compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+
+ /*
+ * Allocate any necessary redirect pixmap
+ * (this actually should never be true; pWin is always unmapped)
+ */
+ compCheckRedirect (pWin);
+
+ /*
+ * Reset pixmap pointers as appropriate
+ */
+ if (pWin->parent && !pWin->redirectDraw)
+ compSetPixmap (pWin, (*pScreen->GetWindowPixmap) (pWin->parent));
+ /*
+ * Call down to next function
+ */
+ if (pScreen->ReparentWindow)
+ (*pScreen->ReparentWindow) (pWin, pPriorParent);
+ cs->ReparentWindow = pScreen->ReparentWindow;
+ pScreen->ReparentWindow = compReparentWindow;
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+void
+compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ int dx = 0, dy = 0;
+
+ if (pWin->redirectDraw)
+ {
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ assert (cw->oldx != COMP_ORIGIN_INVALID);
+ assert (cw->oldy != COMP_ORIGIN_INVALID);
+ if (cw->pOldPixmap)
+ {
+ /*
+ * Ok, the old bits are available in pOldPixmap and
+ * need to be copied to pNewPixmap.
+ */
+ RegionRec rgnDst;
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ GCPtr pGC;
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+
+ REGION_NULL (pWin->drawable.pScreen, &rgnDst);
+
+ REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst,
+ &pWin->borderClip, prgnSrc);
+
+ REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst,
+ -pPixmap->screen_x, -pPixmap->screen_y);
+
+ dx = dx + pPixmap->screen_x - cw->oldx;
+ dy = dy + pPixmap->screen_y - cw->oldy;
+ pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
+ if (pGC)
+ {
+ BoxPtr pBox = REGION_RECTS (&rgnDst);
+ int nBox = REGION_NUM_RECTS (&rgnDst);
+
+ ValidateGC(&pPixmap->drawable, pGC);
+ while (nBox--)
+ {
+ (void) (*pGC->ops->CopyArea) (&cw->pOldPixmap->drawable,
+ &pPixmap->drawable,
+ pGC,
+ pBox->x1 + dx, pBox->y1 + dy,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1,
+ pBox->x1, pBox->y1);
+ pBox++;
+ }
+ FreeScratchGC (pGC);
+ }
+ return;
+ }
+ dx = pPixmap->screen_x - cw->oldx;
+ dy = pPixmap->screen_y - cw->oldy;
+ ptOldOrg.x += dx;
+ ptOldOrg.y += dy;
+ }
+
+ pScreen->CopyWindow = cs->CopyWindow;
+ if (ptOldOrg.x != pWin->drawable.x || ptOldOrg.y != pWin->drawable.y)
+ {
+ if (dx || dy)
+ REGION_TRANSLATE (pScreen, prgnSrc, dx, dy);
+ (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
+ if (dx || dy)
+ REGION_TRANSLATE (pScreen, prgnSrc, -dx, -dy);
+ }
+ else
+ {
+ ptOldOrg.x -= dx;
+ ptOldOrg.y -= dy;
+ REGION_TRANSLATE (prgnSrc, prgnSrc,
+ pWin->drawable.x - ptOldOrg.x,
+ pWin->drawable.y - ptOldOrg.y);
+ DamageDamageRegion (&pWin->drawable, prgnSrc);
+ }
+ cs->CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = compCopyWindow;
+ compCheckTree (pWin->drawable.pScreen);
+}
+
+Bool
+compCreateWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ Bool ret;
+
+ pScreen->CreateWindow = cs->CreateWindow;
+ ret = (*pScreen->CreateWindow) (pWin);
+ if (pWin->parent && ret)
+ {
+ CompSubwindowsPtr csw = GetCompSubwindows (pWin->parent);
+ CompClientWindowPtr ccw;
+
+ (*pScreen->SetWindowPixmap) (pWin, (*pScreen->GetWindowPixmap) (pWin->parent));
+ if (csw)
+ for (ccw = csw->clients; ccw; ccw = ccw->next)
+ compRedirectWindow (clients[CLIENT_ID(ccw->id)],
+ pWin, ccw->update);
+ if (compImplicitRedirect (pWin, pWin->parent))
+ compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+ }
+ cs->CreateWindow = pScreen->CreateWindow;
+ pScreen->CreateWindow = compCreateWindow;
+ compCheckTree (pWin->drawable.pScreen);
+ return ret;
+}
+
+Bool
+compDestroyWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CompScreenPtr cs = GetCompScreen (pScreen);
+ CompWindowPtr cw;
+ CompSubwindowsPtr csw;
+ Bool ret;
+
+ pScreen->DestroyWindow = cs->DestroyWindow;
+ while ((cw = GetCompWindow (pWin)))
+ FreeResource (cw->clients->id, RT_NONE);
+ while ((csw = GetCompSubwindows (pWin)))
+ FreeResource (csw->clients->id, RT_NONE);
+
+ if (pWin->redirectDraw)
+ compFreePixmap (pWin);
+ ret = (*pScreen->DestroyWindow) (pWin);
+ cs->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = compDestroyWindow;
+/* compCheckTree (pWin->drawable.pScreen); can't check -- tree isn't good*/
+ return ret;
+}
+
+void
+compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ RegionRec damage;
+
+ REGION_NULL (pScreen, &damage);
+ /*
+ * Align old border clip with new border clip
+ */
+ REGION_TRANSLATE (pScreen, &cw->borderClip,
+ pWin->drawable.x - cw->borderClipX,
+ pWin->drawable.y - cw->borderClipY);
+ /*
+ * Compute newly visible portion of window for repaint
+ */
+ REGION_SUBTRACT (pScreen, &damage, pRegion, &cw->borderClip);
+ /*
+ * Report that as damaged so it will be redrawn
+ */
+ DamageDamageRegion (&pWin->drawable, &damage);
+ REGION_UNINIT (pScreen, &damage);
+ /*
+ * Save the new border clip region
+ */
+ REGION_COPY (pScreen, &cw->borderClip, pRegion);
+ cw->borderClipX = pWin->drawable.x;
+ cw->borderClipY = pWin->drawable.y;
+}
+
+RegionPtr
+compGetRedirectBorderClip (WindowPtr pWin)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+
+ return &cw->borderClip;
+}
+
+static VisualPtr
+compGetWindowVisual (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ VisualID vid = wVisual (pWin);
+ int i;
+
+ for (i = 0; i < pScreen->numVisuals; i++)
+ if (pScreen->visuals[i].vid == vid)
+ return &pScreen->visuals[i];
+ return 0;
+}
+
+static PictFormatPtr
+compWindowFormat (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ return PictureMatchVisual (pScreen, pWin->drawable.depth,
+ compGetWindowVisual (pWin));
+}
+
+static void
+compWindowUpdateAutomatic (WindowPtr pWin)
+{
+ CompWindowPtr cw = GetCompWindow (pWin);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pParent = pWin->parent;
+ PixmapPtr pSrcPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ PictFormatPtr pSrcFormat = compWindowFormat (pWin);
+ PictFormatPtr pDstFormat = compWindowFormat (pWin->parent);
+ int error;
+ RegionPtr pRegion = DamageRegion (cw->damage);
+ PicturePtr pSrcPicture = CreatePicture (0, &pSrcPixmap->drawable,
+ pSrcFormat,
+ 0, 0,
+ serverClient,
+ &error);
+ XID subwindowMode = IncludeInferiors;
+ PicturePtr pDstPicture = CreatePicture (0, &pParent->drawable,
+ pDstFormat,
+ CPSubwindowMode,
+ &subwindowMode,
+ serverClient,
+ &error);
+
+ /*
+ * First move the region from window to screen coordinates
+ */
+ REGION_TRANSLATE (pScreen, pRegion,
+ pWin->drawable.x, pWin->drawable.y);
+
+ /*
+ * Clip against the "real" border clip
+ */
+ REGION_INTERSECT (pScreen, pRegion, pRegion, &cw->borderClip);
+
+ /*
+ * Now translate from screen to dest coordinates
+ */
+ REGION_TRANSLATE (pScreen, pRegion,
+ -pParent->drawable.x, -pParent->drawable.y);
+
+ /*
+ * Clip the picture
+ */
+ SetPictureClipRegion (pDstPicture, 0, 0, pRegion);
+
+ /*
+ * And paint
+ */
+ CompositePicture (PictOpSrc,
+ pSrcPicture,
+ 0,
+ pDstPicture,
+ 0, 0, /* src_x, src_y */
+ 0, 0, /* msk_x, msk_y */
+ pSrcPixmap->screen_x - pParent->drawable.x,
+ pSrcPixmap->screen_y - pParent->drawable.y,
+ pSrcPixmap->drawable.width,
+ pSrcPixmap->drawable.height);
+ FreePicture (pSrcPicture, 0);
+ FreePicture (pDstPicture, 0);
+ /*
+ * Empty the damage region. This has the nice effect of
+ * rendering the translations above harmless
+ */
+ DamageEmpty (cw->damage);
+}
+
+void
+compWindowUpdate (WindowPtr pWin)
+{
+ WindowPtr pChild;
+
+ for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
+ compWindowUpdate (pChild);
+ if (pWin->redirectDraw)
+ {
+ CompWindowPtr cw = GetCompWindow(pWin);
+
+ if (cw->damaged)
+ {
+ compWindowUpdateAutomatic (pWin);
+ cw->damaged = FALSE;
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/damageext/Imakefile b/nx-X11/programs/Xserver/damageext/Imakefile
new file mode 100644
index 000000000..f7ce4573b
--- /dev/null
+++ b/nx-X11/programs/Xserver/damageext/Imakefile
@@ -0,0 +1,17 @@
+#include <Server.tmpl>
+
+ SRCS = damageext.c
+
+ OBJS = damageext.o
+
+ INCLUDES = -I../include -I../Xext -I../render -I../xfixes -I../miext/damage \
+ -I$(EXTINCSRC) -I$(XINCLUDESRC)
+
+ LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+
+NormalLibraryTarget(damage,$(OBJS))
+NormalLibraryObjectRule()
+LintLibraryTarget(damage,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/damageext/damageext.c b/nx-X11/programs/Xserver/damageext/damageext.c
new file mode 100755
index 000000000..24809347a
--- /dev/null
+++ b/nx-X11/programs/Xserver/damageext/damageext.c
@@ -0,0 +1,481 @@
+/*
+ * $Id: damageext.c,v 1.6 2005/07/03 07:37:35 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "damageextint.h"
+
+unsigned char DamageReqCode;
+int DamageEventBase;
+int DamageErrorBase;
+int DamageClientPrivateIndex;
+RESTYPE DamageExtType;
+RESTYPE DamageExtWinType;
+
+#define prScreen screenInfo.screens[0]
+
+static void
+DamageExtNotify (DamageExtPtr pDamageExt, BoxPtr pBoxes, int nBoxes)
+{
+ ClientPtr pClient = pDamageExt->pClient;
+ DamageClientPtr pDamageClient = GetDamageClient (pClient);
+ DrawablePtr pDrawable = pDamageExt->pDrawable;
+ xDamageNotifyEvent ev;
+ int i;
+
+ UpdateCurrentTimeIf ();
+ ev.type = DamageEventBase + XDamageNotify;
+ ev.level = pDamageExt->level;
+ ev.sequenceNumber = pClient->sequence;
+ ev.drawable = pDrawable->id;
+ ev.damage = pDamageExt->id;
+ ev.timestamp = currentTime.milliseconds;
+ ev.geometry.x = pDrawable->x;
+ ev.geometry.y = pDrawable->y;
+ ev.geometry.width = pDrawable->width;
+ ev.geometry.height = pDrawable->height;
+ if (pBoxes)
+ {
+ for (i = 0; i < nBoxes; i++)
+ {
+ ev.level = pDamageExt->level;
+ if (i < nBoxes - 1)
+ ev.level |= DamageNotifyMore;
+ ev.area.x = pBoxes[i].x1;
+ ev.area.y = pBoxes[i].y1;
+ ev.area.width = pBoxes[i].x2 - pBoxes[i].x1;
+ ev.area.height = pBoxes[i].y2 - pBoxes[i].y1;
+ if (!pClient->clientGone)
+ WriteEventsToClient (pClient, 1, (xEvent *) &ev);
+ }
+ }
+ else
+ {
+ ev.area.x = 0;
+ ev.area.y = 0;
+ ev.area.width = pDrawable->width;
+ ev.area.height = pDrawable->height;
+ if (!pClient->clientGone)
+ WriteEventsToClient (pClient, 1, (xEvent *) &ev);
+ }
+ /* Composite extension marks clients with manual Subwindows as critical */
+ if (pDamageClient->critical > 0)
+ {
+ SetCriticalOutputPending ();
+#ifdef SMART_SCHEDULE
+ pClient->smart_priority = SMART_MAX_PRIORITY;
+#endif
+ }
+}
+
+static void
+DamageExtReport (DamagePtr pDamage, RegionPtr pRegion, void *closure)
+{
+ DamageExtPtr pDamageExt = closure;
+
+ switch (pDamageExt->level) {
+ case DamageReportRawRegion:
+ case DamageReportDeltaRegion:
+ DamageExtNotify (pDamageExt, REGION_RECTS(pRegion), REGION_NUM_RECTS(pRegion));
+ break;
+ case DamageReportBoundingBox:
+ DamageExtNotify (pDamageExt, REGION_EXTENTS(prScreen, pRegion), 1);
+ break;
+ case DamageReportNonEmpty:
+ DamageExtNotify (pDamageExt, NullBox, 0);
+ break;
+ case DamageReportNone:
+ break;
+ }
+}
+
+static void
+DamageExtDestroy (DamagePtr pDamage, void *closure)
+{
+ DamageExtPtr pDamageExt = closure;
+
+ pDamageExt->pDamage = 0;
+ if (pDamageExt->id)
+ FreeResource (pDamageExt->id, RT_NONE);
+}
+
+void
+DamageExtSetCritical (ClientPtr pClient, Bool critical)
+{
+ DamageClientPtr pDamageClient = GetDamageClient (pClient);
+
+ if (pDamageClient)
+ pDamageClient->critical += critical ? 1 : -1;
+}
+
+static int
+ProcDamageQueryVersion(ClientPtr client)
+{
+ DamageClientPtr pDamageClient = GetDamageClient (client);
+ xDamageQueryVersionReply rep;
+ register int n;
+ REQUEST(xDamageQueryVersionReq);
+
+ REQUEST_SIZE_MATCH(xDamageQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ if (stuff->majorVersion < DAMAGE_MAJOR) {
+ rep.majorVersion = stuff->majorVersion;
+ rep.minorVersion = stuff->minorVersion;
+ } else {
+ rep.majorVersion = DAMAGE_MAJOR;
+ if (stuff->majorVersion == DAMAGE_MAJOR &&
+ stuff->minorVersion < DAMAGE_MINOR)
+ rep.minorVersion = stuff->minorVersion;
+ else
+ rep.minorVersion = DAMAGE_MINOR;
+ }
+ pDamageClient->major_version = rep.majorVersion;
+ pDamageClient->minor_version = rep.minorVersion;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.majorVersion, n);
+ swapl(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof(xDamageQueryVersionReply), (char *)&rep);
+ return(client->noClientException);
+}
+
+static int
+ProcDamageCreate (ClientPtr client)
+{
+ DrawablePtr pDrawable;
+ DamageExtPtr pDamageExt;
+ DamageReportLevel level;
+ RegionPtr pRegion;
+
+ REQUEST(xDamageCreateReq);
+
+ REQUEST_SIZE_MATCH(xDamageCreateReq);
+ LEGAL_NEW_RESOURCE(stuff->damage, client);
+ SECURITY_VERIFY_DRAWABLE (pDrawable, stuff->drawable, client,
+ SecurityReadAccess);
+ switch (stuff->level) {
+ case XDamageReportRawRectangles:
+ level = DamageReportRawRegion;
+ break;
+ case XDamageReportDeltaRectangles:
+ level = DamageReportDeltaRegion;
+ break;
+ case XDamageReportBoundingBox:
+ level = DamageReportBoundingBox;
+ break;
+ case XDamageReportNonEmpty:
+ level = DamageReportNonEmpty;
+ break;
+ default:
+ client->errorValue = stuff->level;
+ return BadValue;
+ }
+
+ pDamageExt = xalloc (sizeof (DamageExtRec));
+ if (!pDamageExt)
+ return BadAlloc;
+ pDamageExt->id = stuff->damage;
+ pDamageExt->pDrawable = pDrawable;
+ pDamageExt->level = level;
+ pDamageExt->pClient = client;
+ pDamageExt->pDamage = DamageCreate (DamageExtReport,
+ DamageExtDestroy,
+ level,
+ FALSE,
+ pDrawable->pScreen,
+ pDamageExt);
+ if (!pDamageExt->pDamage)
+ {
+ xfree (pDamageExt);
+ return BadAlloc;
+ }
+ if (!AddResource (stuff->damage, DamageExtType, (pointer) pDamageExt))
+ return BadAlloc;
+
+ DamageRegister (pDamageExt->pDrawable, pDamageExt->pDamage);
+
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ {
+ pRegion = &((WindowPtr) pDrawable)->borderClip;
+ DamageDamageRegion (pDrawable, pRegion);
+ }
+
+ return (client->noClientException);
+}
+
+static int
+ProcDamageDestroy (ClientPtr client)
+{
+ REQUEST(xDamageDestroyReq);
+ DamageExtPtr pDamageExt;
+
+ REQUEST_SIZE_MATCH(xDamageDestroyReq);
+ VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, SecurityWriteAccess);
+ FreeResource (stuff->damage, RT_NONE);
+ return (client->noClientException);
+}
+
+static int
+ProcDamageSubtract (ClientPtr client)
+{
+ REQUEST(xDamageSubtractReq);
+ DamageExtPtr pDamageExt;
+ RegionPtr pRepair;
+ RegionPtr pParts;
+
+ REQUEST_SIZE_MATCH(xDamageSubtractReq);
+ VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, SecurityWriteAccess);
+ VERIFY_REGION_OR_NONE(pRepair, stuff->repair, client, SecurityWriteAccess);
+ VERIFY_REGION_OR_NONE(pParts, stuff->parts, client, SecurityWriteAccess);
+
+ if (pDamageExt->level != DamageReportRawRegion)
+ {
+ DamagePtr pDamage = pDamageExt->pDamage;
+ if (pRepair)
+ {
+ if (pParts)
+ REGION_INTERSECT (prScreen, pParts, DamageRegion (pDamage), pRepair);
+ if (DamageSubtract (pDamage, pRepair))
+ DamageExtReport (pDamage, DamageRegion (pDamage), (void *) pDamageExt);
+ }
+ else
+ {
+ if (pParts)
+ REGION_COPY (prScreen, pParts, DamageRegion (pDamage));
+ DamageEmpty (pDamage);
+ }
+ }
+ return (client->noClientException);
+}
+
+/* Major version controls available requests */
+static const int version_requests[] = {
+ X_DamageQueryVersion, /* before client sends QueryVersion */
+ X_DamageSubtract, /* Version 1 */
+};
+
+#define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0]))
+
+int (*ProcDamageVector[XDamageNumberRequests])(ClientPtr) = {
+/*************** Version 1 ******************/
+ ProcDamageQueryVersion,
+ ProcDamageCreate,
+ ProcDamageDestroy,
+ ProcDamageSubtract,
+};
+
+
+static int
+ProcDamageDispatch (ClientPtr client)
+{
+ REQUEST(xDamageReq);
+ DamageClientPtr pDamageClient = GetDamageClient (client);
+
+ if (pDamageClient->major_version > NUM_VERSION_REQUESTS)
+ return BadRequest;
+ if (stuff->damageReqType > version_requests[pDamageClient->major_version])
+ return BadRequest;
+ return (*ProcDamageVector[stuff->damageReqType]) (client);
+}
+
+static int
+SProcDamageQueryVersion(ClientPtr client)
+{
+ register int n;
+ REQUEST(xDamageQueryVersionReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDamageQueryVersionReq);
+ swapl(&stuff->majorVersion, n);
+ swapl(&stuff->minorVersion, n);
+ return (*ProcDamageVector[stuff->damageReqType]) (client);
+}
+
+static int
+SProcDamageCreate (ClientPtr client)
+{
+ register int n;
+ REQUEST(xDamageCreateReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDamageCreateReq);
+ swapl (&stuff->damage, n);
+ swapl (&stuff->drawable, n);
+ return (*ProcDamageVector[stuff->damageReqType]) (client);
+}
+
+static int
+SProcDamageDestroy (ClientPtr client)
+{
+ register int n;
+ REQUEST(xDamageDestroyReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDamageDestroyReq);
+ swapl (&stuff->damage, n);
+ return (*ProcDamageVector[stuff->damageReqType]) (client);
+}
+
+static int
+SProcDamageSubtract (ClientPtr client)
+{
+ register int n;
+ REQUEST(xDamageSubtractReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDamageSubtractReq);
+ swapl (&stuff->damage, n);
+ swapl (&stuff->repair, n);
+ swapl (&stuff->parts, n);
+ return (*ProcDamageVector[stuff->damageReqType]) (client);
+}
+
+int (*SProcDamageVector[XDamageNumberRequests])(ClientPtr) = {
+/*************** Version 1 ******************/
+ SProcDamageQueryVersion,
+ SProcDamageCreate,
+ SProcDamageDestroy,
+ SProcDamageSubtract,
+};
+
+static int
+SProcDamageDispatch (ClientPtr client)
+{
+ REQUEST(xDamageReq);
+ if (stuff->damageReqType >= XDamageNumberRequests)
+ return BadRequest;
+ return (*SProcDamageVector[stuff->damageReqType]) (client);
+}
+
+static void
+DamageClientCallback (CallbackListPtr *list,
+ pointer closure,
+ pointer data)
+{
+ NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
+ ClientPtr pClient = clientinfo->client;
+ DamageClientPtr pDamageClient = GetDamageClient (pClient);
+
+ pDamageClient->critical = 0;
+ pDamageClient->major_version = 0;
+ pDamageClient->minor_version = 0;
+}
+
+/*ARGSUSED*/
+static void
+DamageResetProc (ExtensionEntry *extEntry)
+{
+ DeleteCallback (&ClientStateCallback, DamageClientCallback, 0);
+}
+
+static int
+FreeDamageExt (pointer value, XID did)
+{
+ DamageExtPtr pDamageExt = (DamageExtPtr) value;
+
+ /*
+ * Get rid of the resource table entry hanging from the window id
+ */
+ pDamageExt->id = 0;
+ if (WindowDrawable(pDamageExt->pDrawable->type))
+ FreeResourceByType (pDamageExt->pDrawable->id, DamageExtWinType, TRUE);
+ if (pDamageExt->pDamage)
+ {
+ DamageUnregister (pDamageExt->pDrawable, pDamageExt->pDamage);
+ DamageDestroy (pDamageExt->pDamage);
+ }
+ xfree (pDamageExt);
+ return Success;
+}
+
+static int
+FreeDamageExtWin (pointer value, XID wid)
+{
+ DamageExtPtr pDamageExt = (DamageExtPtr) value;
+
+ if (pDamageExt->id)
+ FreeResource (pDamageExt->id, RT_NONE);
+ return Success;
+}
+
+void
+SDamageNotifyEvent (xDamageNotifyEvent *from,
+ xDamageNotifyEvent *to)
+{
+ to->type = from->type;
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswapl (from->drawable, to->drawable);
+ cpswapl (from->damage, to->damage);
+ cpswaps (from->area.x, to->area.x);
+ cpswaps (from->area.y, to->area.y);
+ cpswaps (from->area.width, to->area.width);
+ cpswaps (from->area.height, to->area.height);
+ cpswaps (from->geometry.x, to->geometry.x);
+ cpswaps (from->geometry.y, to->geometry.y);
+ cpswaps (from->geometry.width, to->geometry.width);
+ cpswaps (from->geometry.height, to->geometry.height);
+}
+
+void
+DamageExtensionInit(void)
+{
+ ExtensionEntry *extEntry;
+ int s;
+
+ for (s = 0; s < screenInfo.numScreens; s++)
+ DamageSetup (screenInfo.screens[s]);
+
+ DamageExtType = CreateNewResourceType (FreeDamageExt);
+ if (!DamageExtType)
+ return;
+
+ DamageExtWinType = CreateNewResourceType (FreeDamageExtWin);
+ if (!DamageExtWinType)
+ return;
+
+ DamageClientPrivateIndex = AllocateClientPrivateIndex ();
+ if (!AllocateClientPrivate (DamageClientPrivateIndex,
+ sizeof (DamageClientRec)))
+ return;
+ if (!AddCallback (&ClientStateCallback, DamageClientCallback, 0))
+ return;
+
+ if ((extEntry = AddExtension(DAMAGE_NAME, XDamageNumberEvents,
+ XDamageNumberErrors,
+ ProcDamageDispatch, SProcDamageDispatch,
+ DamageResetProc, StandardMinorOpcode)) != 0)
+ {
+ DamageReqCode = (unsigned char)extEntry->base;
+ DamageEventBase = extEntry->eventBase;
+ DamageErrorBase = extEntry->errorBase;
+ EventSwapVector[DamageEventBase + XDamageNotify] =
+ (EventSwapPtr) SDamageNotifyEvent;
+ }
+}
diff --git a/nx-X11/programs/Xserver/damageext/damageext.h b/nx-X11/programs/Xserver/damageext/damageext.h
new file mode 100644
index 000000000..3d748eedf
--- /dev/null
+++ b/nx-X11/programs/Xserver/damageext/damageext.h
@@ -0,0 +1,35 @@
+/*
+ * $Id: damageext.h,v 1.5 2005/07/03 07:01:17 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _DAMAGEEXT_H_
+#define _DAMAGEEXT_H_
+
+void
+DamageExtensionInit(void);
+
+#endif /* _DAMAGEEXT_H_ */
diff --git a/nx-X11/programs/Xserver/damageext/damageextint.h b/nx-X11/programs/Xserver/damageext/damageextint.h
new file mode 100644
index 000000000..ab00effe3
--- /dev/null
+++ b/nx-X11/programs/Xserver/damageext/damageextint.h
@@ -0,0 +1,88 @@
+/*
+ * $Id: damageextint.h,v 1.6 2005/07/03 08:53:38 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _DAMAGEEXTINT_H_
+#define _DAMAGEEXTINT_H_
+
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include <X11/extensions/damageproto.h>
+#include "windowstr.h"
+#include "selection.h"
+#include "scrnintstr.h"
+#include "damageext.h"
+#include "damage.h"
+#include "xfixes.h"
+
+extern unsigned char DamageReqCode;
+extern int DamageEventBase;
+extern int DamageErrorBase;
+extern int DamageClientPrivateIndex;
+extern RESTYPE DamageExtType;
+extern RESTYPE DamageExtWinType;
+
+typedef struct _DamageClient {
+ CARD32 major_version;
+ CARD32 minor_version;
+ int critical;
+} DamageClientRec, *DamageClientPtr;
+
+#define GetDamageClient(pClient) ((DamageClientPtr) (pClient)->devPrivates[DamageClientPrivateIndex].ptr)
+
+typedef struct _DamageExt {
+ DamagePtr pDamage;
+ DrawablePtr pDrawable;
+ DamageReportLevel level;
+ ClientPtr pClient;
+ XID id;
+} DamageExtRec, *DamageExtPtr;
+
+extern int (*ProcDamageVector[/*XDamageNumberRequests*/])(ClientPtr);
+extern int (*SProcDamageVector[/*XDamageNumberRequests*/])(ClientPtr);
+
+#define VERIFY_DAMAGEEXT(pDamageExt, rid, client, mode) { \
+ pDamageExt = SecurityLookupIDByType (client, rid, DamageExtType, mode); \
+ if (!pDamageExt) { \
+ client->errorValue = rid; \
+ return DamageErrorBase + BadDamage; \
+ } \
+}
+
+void
+SDamageNotifyEvent (xDamageNotifyEvent *from,
+ xDamageNotifyEvent *to);
+
+void
+DamageExtSetCritical (ClientPtr pClient, Bool critical);
+
+#endif /* _DAMAGEEXTINT_H_ */
diff --git a/nx-X11/programs/Xserver/dbe/Imakefile b/nx-X11/programs/Xserver/dbe/Imakefile
new file mode 100644
index 000000000..9d9c3fd67
--- /dev/null
+++ b/nx-X11/programs/Xserver/dbe/Imakefile
@@ -0,0 +1,36 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:16 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/dbe/Imakefile,v 3.10 2001/01/17 22:36:41 dawes Exp $
+
+#if DoLoadableServer
+#define IHaveSubdirs
+#endif
+
+#include <Server.tmpl>
+
+#if DoLoadableServer
+ SUBDIRS = module
+#endif
+
+ SRCS = dbe.c midbe.c
+ OBJS = dbe.o midbe.o
+ INCLUDES = -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(EXTINCSRC) $(EXTRAINCLUDES)
+ LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+
+NormalLibraryObjectRule()
+
+NormalLibraryTarget(dbe,$(OBJS))
+
+LintLibraryTarget(dbe,$(SRCS))
+NormalLintTarget($(SRCS))
+
+#if DoLoadableServer
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/programs/Xserver/dbe/dbe.c b/nx-X11/programs/Xserver/dbe/dbe.c
new file mode 100644
index 000000000..c0d6131b7
--- /dev/null
+++ b/nx-X11/programs/Xserver/dbe/dbe.c
@@ -0,0 +1,1999 @@
+/* $XdotOrg: xc/programs/Xserver/dbe/dbe.c,v 1.5 2005/07/03 07:01:17 daniels Exp $ */
+/* $Xorg: dbe.c,v 1.3 2000/08/17 19:48:16 cpqbld Exp $ */
+/******************************************************************************
+ *
+ * Copyright (c) 1994, 1995 Hewlett-Packard Company
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Hewlett-Packard
+ * Company shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the Hewlett-Packard Company.
+ *
+ * DIX DBE code
+ *
+ *****************************************************************************/
+/* $XFree86: xc/programs/Xserver/dbe/dbe.c,v 3.10 2001/08/23 14:19:24 alanh Exp $ */
+
+
+/* INCLUDES */
+
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "extnsionst.h"
+#include "gcstruct.h"
+#include "dixstruct.h"
+#define NEED_DBE_PROTOCOL
+#include "dbestruct.h"
+#include "midbe.h"
+
+#ifdef XFree86LOADER
+#include "xf86_ansic.h"
+#endif
+
+#if !defined(UINT32_MAX)
+#define UINT32_MAX 0xffffffffU
+#endif
+
+/* GLOBALS */
+
+/* Per-screen initialization functions [init'ed by DbeRegisterFunction()] */
+static Bool (* DbeInitFunct[MAXSCREENS])(); /* pScreen, pDbeScreenPriv */
+
+/* These are static globals copied to DBE's screen private for use by DDX */
+static int dbeScreenPrivIndex;
+static int dbeWindowPrivIndex;
+
+/* These are static globals copied to DBE's screen private for use by DDX */
+static RESTYPE dbeDrawableResType;
+static RESTYPE dbeWindowPrivResType;
+
+/* This global is used by DbeAllocWinPrivPrivIndex() */
+static int winPrivPrivCount = 0;
+
+/* Used to generate DBE's BadBuffer error. */
+static int dbeErrorBase;
+
+/* Used by DbeRegisterFunction() to initialize the initialization function
+ * table only once per server lifetime.
+ */
+static Bool firstRegistrationPass = TRUE;
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeValidateBuffer
+ *
+ * Description:
+ *
+ * This function is called from VALIDATE_DRAWABLE_AND_GC and from
+ * various places in dispatch.c if the server has been compiled with
+ * the flags -DNEED_DBE_BUF_BITS and -DNEED_DBE_BUF_VALIDATE.
+ * When pWin->dstBuffer changes, this function will be called with pWin
+ * as the first argument, the drawable ID that was specified as the
+ * second argument (could be a back buffer id), and True for the third
+ * argument.
+ * When pWin->srcBuffer changes, the third argument will be False, and
+ * the first two arguments are as described for dstBuffer.
+ *
+ * This function should prepare the hardware to access the specified
+ * buffer for reads (if dstbuf is False) or writes (if dstbuf is True).
+ *
+ *****************************************************************************/
+
+void
+DbeValidateBuffer(pWin, drawID, dstbuf)
+ WindowPtr pWin;
+ XID drawID;
+ Bool dstbuf;
+{
+ DbeScreenPrivPtr pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(pWin);
+ if (pDbeScreenPriv->ValidateBuffer)
+ (*pDbeScreenPriv->ValidateBuffer)(pWin, drawID, dstbuf);
+}
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeRegisterFunction
+ *
+ * Description:
+ *
+ * This function registers the DBE init function for the specified screen.
+ *
+ *****************************************************************************/
+
+void
+DbeRegisterFunction(pScreen, funct)
+ ScreenPtr pScreen;
+ Bool (*funct)();
+{
+ int i;
+
+ /* Initialize the initialization function table if it has not been
+ * initialized already.
+ */
+ if (firstRegistrationPass)
+ {
+ for (i = 0; i < MAXSCREENS; i++)
+ {
+ DbeInitFunct[i] = NULL;
+ }
+
+ firstRegistrationPass = FALSE;
+ }
+
+ DbeInitFunct[pScreen->myNum] = funct;
+
+} /* DbeRegisterFunction() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeAllocWinPriv
+ *
+ * Description:
+ *
+ * This function was cloned from AllocateWindow() in window.c.
+ * This function allocates a window priv structure to be associated
+ * with a double-buffered window.
+ *
+ *****************************************************************************/
+static DbeWindowPrivPtr
+DbeAllocWinPriv(pScreen)
+ ScreenPtr pScreen;
+{
+ DbeWindowPrivPtr pDbeWindowPriv;
+ DbeScreenPrivPtr pDbeScreenPriv;
+ register char *ptr;
+ register DevUnion *ppriv;
+ register unsigned int *sizes;
+ register unsigned int size;
+ register int i;
+
+ pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+ pDbeWindowPriv = (DbeWindowPrivPtr)xalloc(pDbeScreenPriv->totalWinPrivSize);
+
+ if (pDbeWindowPriv)
+ {
+ ppriv = (DevUnion *)(pDbeWindowPriv + 1);
+ pDbeWindowPriv->devPrivates = ppriv;
+ sizes = pDbeScreenPriv->winPrivPrivSizes;
+ ptr = (char *)(ppriv + pDbeScreenPriv->winPrivPrivLen);
+ for (i = pDbeScreenPriv->winPrivPrivLen; --i >= 0; ppriv++, sizes++)
+ {
+ if ((size = *sizes))
+ {
+ ppriv->ptr = (pointer)ptr;
+ ptr += size;
+ }
+ else
+ ppriv->ptr = (pointer)NULL;
+ }
+ }
+
+ return(pDbeWindowPriv);
+
+} /* DbeAllocWinPriv() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeFallbackAllocWinPriv
+ *
+ * Description:
+ *
+ * This is a fallback function for AllocWinPriv().
+ *
+ *****************************************************************************/
+
+#if 0 /* NOT USED */
+static DbeWindowPrivPtr
+DbeFallbackAllocWinPriv(pScreen)
+ ScreenPtr pScreen;
+{
+ return (NULL);
+} /* DbeFallbackAllocWinPriv() */
+#endif
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeAllocWinPrivPrivIndex
+ *
+ * Description:
+ *
+ * This function was cloned from AllocateWindowPrivateIndex() in window.c.
+ * This function allocates a new window priv priv index by simply returning
+ * an incremented private counter.
+ *
+ *****************************************************************************/
+
+static int
+DbeAllocWinPrivPrivIndex()
+{
+ return winPrivPrivCount++;
+
+} /* DbeAllocWinPrivPrivIndex() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeAllocWinPrivPriv
+ *
+ * Description:
+ *
+ * This function was cloned from AllocateWindowPrivate() in privates.c.
+ * This function allocates a private structure to be hung off
+ * a window private.
+ *
+ *****************************************************************************/
+
+static Bool
+DbeAllocWinPrivPriv(pScreen, index, amount)
+ register ScreenPtr pScreen;
+ int index;
+ unsigned int amount;
+{
+ DbeScreenPrivPtr pDbeScreenPriv;
+ unsigned int oldamount;
+
+
+ pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+
+ if (index >= pDbeScreenPriv->winPrivPrivLen)
+ {
+ unsigned *nsizes;
+ nsizes = (unsigned *)xrealloc(pDbeScreenPriv->winPrivPrivSizes,
+ (index + 1) * sizeof(unsigned));
+ if (!nsizes)
+ {
+ return(FALSE);
+ }
+
+ while (pDbeScreenPriv->winPrivPrivLen <= index)
+ {
+ nsizes[pDbeScreenPriv->winPrivPrivLen++] = 0;
+ pDbeScreenPriv->totalWinPrivSize += sizeof(DevUnion);
+ }
+
+ pDbeScreenPriv->winPrivPrivSizes = nsizes;
+ }
+
+ oldamount = pDbeScreenPriv->winPrivPrivSizes[index];
+
+ if (amount > oldamount)
+ {
+ pDbeScreenPriv->winPrivPrivSizes[index] = amount;
+ pDbeScreenPriv->totalWinPrivSize += (amount - oldamount);
+ }
+ return(TRUE);
+
+} /* DbeAllocWinPrivPriv() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeStubScreen
+ *
+ * Description:
+ *
+ * This is function stubs the function pointers in the given DBE screen
+ * private and increments the number of stubbed screens.
+ *
+ *****************************************************************************/
+
+static void
+DbeStubScreen(pDbeScreenPriv, nStubbedScreens)
+ DbeScreenPrivPtr pDbeScreenPriv;
+ int *nStubbedScreens;
+{
+ /* Stub DIX. */
+ pDbeScreenPriv->SetupBackgroundPainter = NULL;
+ pDbeScreenPriv->AllocWinPriv = NULL;
+ pDbeScreenPriv->AllocWinPrivPrivIndex = NULL;
+ pDbeScreenPriv->AllocWinPrivPriv = NULL;
+
+ /* Do not unwrap PositionWindow nor DestroyWindow. If the DDX
+ * initialization function failed, we assume that it did not wrap
+ * PositionWindow. Also, DestroyWindow is only wrapped if the DDX
+ * initialization function succeeded.
+ */
+
+ /* Stub DDX. */
+ pDbeScreenPriv->GetVisualInfo = NULL;
+ pDbeScreenPriv->AllocBackBufferName = NULL;
+ pDbeScreenPriv->SwapBuffers = NULL;
+ pDbeScreenPriv->BeginIdiom = NULL;
+ pDbeScreenPriv->EndIdiom = NULL;
+ pDbeScreenPriv->WinPrivDelete = NULL;
+ pDbeScreenPriv->ResetProc = NULL;
+ pDbeScreenPriv->ValidateBuffer = NULL;
+
+ (*nStubbedScreens)++;
+
+} /* DbeStubScreen() */
+
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: ProcDbeGetVersion
+ *
+ * Description:
+ *
+ * This function is for processing a DbeGetVersion request.
+ * This request returns the major and minor version numbers of this
+ * extension.
+ *
+ * Return Values:
+ *
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+ProcDbeGetVersion(client)
+ ClientPtr client;
+{
+ /* REQUEST(xDbeGetVersionReq); */
+ xDbeGetVersionReply rep;
+ register int n;
+
+
+ REQUEST_SIZE_MATCH(xDbeGetVersionReq);
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = DBE_MAJOR_VERSION;
+ rep.minorVersion = DBE_MINOR_VERSION;
+
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ }
+
+ WriteToClient(client, sizeof(xDbeGetVersionReply), (char *)&rep);
+
+ return(client->noClientException);
+
+} /* ProcDbeGetVersion() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: ProcDbeAllocateBackBufferName
+ *
+ * Description:
+ *
+ * This function is for processing a DbeAllocateBackBufferName request.
+ * This request allocates a drawable ID used to refer to the back buffer
+ * of a window.
+ *
+ * Return Values:
+ *
+ * BadAlloc - server can not allocate resources
+ * BadIDChoice - id is out of range for client; id is already in use
+ * BadMatch - window is not an InputOutput window;
+ * visual of window is not on list returned by
+ * DBEGetVisualInfo;
+ * BadValue - invalid swap action is specified
+ * BadWindow - window is not a valid window
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+ProcDbeAllocateBackBufferName(client)
+ ClientPtr client;
+{
+ REQUEST(xDbeAllocateBackBufferNameReq);
+ WindowPtr pWin;
+ DbeScreenPrivPtr pDbeScreenPriv;
+ DbeWindowPrivPtr pDbeWindowPriv;
+ XdbeScreenVisualInfo scrVisInfo;
+ register int i;
+ Bool visualMatched = FALSE;
+ xDbeSwapAction swapAction;
+ VisualID visual;
+ int status;
+
+
+ REQUEST_SIZE_MATCH(xDbeAllocateBackBufferNameReq);
+
+ /* The window must be valid. */
+ if (!(pWin = SecurityLookupWindow(stuff->window, client,
+ SecurityWriteAccess)))
+ {
+ return(BadWindow);
+ }
+
+ /* The window must be InputOutput. */
+ if (pWin->drawable.class != InputOutput)
+ {
+ return(BadMatch);
+ }
+
+ /* The swap action must be valid. */
+ swapAction = stuff->swapAction; /* use local var for performance. */
+ if ((swapAction != XdbeUndefined ) &&
+ (swapAction != XdbeBackground) &&
+ (swapAction != XdbeUntouched ) &&
+ (swapAction != XdbeCopied ))
+ {
+ return(BadValue);
+ }
+
+ /* The id must be in range and not already in use. */
+ LEGAL_NEW_RESOURCE(stuff->buffer, client);
+
+ /* The visual of the window must be in the list returned by
+ * GetVisualInfo.
+ */
+ pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(pWin);
+ if (!pDbeScreenPriv->GetVisualInfo)
+ return(BadMatch); /* screen doesn't support double buffering */
+
+ if (!(*pDbeScreenPriv->GetVisualInfo)(pWin->drawable.pScreen, &scrVisInfo))
+ {
+ /* GetVisualInfo() failed to allocate visual info data. */
+ return(BadAlloc);
+ }
+
+ /* See if the window's visual is on the list. */
+ visual = wVisual(pWin);
+ for (i = 0; (i < scrVisInfo.count) && !visualMatched; i++)
+ {
+ if (scrVisInfo.visinfo[i].visual == visual)
+ {
+ visualMatched = TRUE;
+ }
+ }
+
+ /* Free what was allocated by the GetVisualInfo() call above. */
+ xfree(scrVisInfo.visinfo);
+
+ if (!visualMatched)
+ {
+ return(BadMatch);
+ }
+
+ if ((pDbeWindowPriv = DBE_WINDOW_PRIV(pWin)) == NULL)
+ {
+ /* There is no buffer associated with the window.
+ * Allocate a window priv.
+ */
+
+ if (!(pDbeWindowPriv =
+ (*pDbeScreenPriv->AllocWinPriv)(pWin->drawable.pScreen)))
+ {
+ return(BadAlloc);
+ }
+
+ /* Make the window priv a DBE window priv resource. */
+ if (!AddResource(stuff->buffer, dbeWindowPrivResType,
+ (pointer)pDbeWindowPriv))
+ {
+ xfree(pDbeWindowPriv);
+ return(BadAlloc);
+ }
+
+ /* Fill out window priv information. */
+ pDbeWindowPriv->pWindow = pWin;
+ pDbeWindowPriv->width = pWin->drawable.width;
+ pDbeWindowPriv->height = pWin->drawable.height;
+ pDbeWindowPriv->x = pWin->drawable.x;
+ pDbeWindowPriv->y = pWin->drawable.y;
+ pDbeWindowPriv->nBufferIDs = 0;
+
+ /* Set the buffer ID array pointer to the initial (static) array). */
+ pDbeWindowPriv->IDs = pDbeWindowPriv->initIDs;
+
+ /* Initialize the buffer ID list. */
+ pDbeWindowPriv->maxAvailableIDs = DBE_INIT_MAX_IDS;
+ pDbeWindowPriv->IDs[0] = stuff->buffer;
+ for (i = 1; i < DBE_INIT_MAX_IDS; i++)
+ {
+ pDbeWindowPriv->IDs[i] = DBE_FREE_ID_ELEMENT;
+ }
+
+
+ /* Actually connect the window priv to the window. */
+ pWin->devPrivates[dbeWindowPrivIndex].ptr = (pointer)pDbeWindowPriv;
+
+ } /* if -- There is no buffer associated with the window. */
+
+ else
+ {
+ /* A buffer is already associated with the window.
+ * Add the new buffer ID to the array, reallocating the array memory
+ * if necessary.
+ */
+
+ /* Determine if there is a free element in the ID array. */
+ for (i = 0; i < pDbeWindowPriv->maxAvailableIDs; i++)
+ {
+ if (pDbeWindowPriv->IDs[i] == DBE_FREE_ID_ELEMENT)
+ {
+ /* There is still room in the ID array. */
+ break;
+ }
+ }
+
+ if (i == pDbeWindowPriv->maxAvailableIDs)
+ {
+ /* No more room in the ID array -- reallocate another array. */
+ XID *pIDs;
+
+
+ /* Setup an array pointer for the realloc operation below. */
+ if (pDbeWindowPriv->maxAvailableIDs == DBE_INIT_MAX_IDS)
+ {
+ /* We will malloc a new array. */
+ pIDs = NULL;
+ }
+ else
+ {
+ /* We will realloc a new array. */
+ pIDs = pDbeWindowPriv->IDs;
+ }
+
+ /* malloc/realloc a new array and initialize all elements to 0. */
+ pDbeWindowPriv->IDs = (XID *)xrealloc(pIDs,
+ (pDbeWindowPriv->maxAvailableIDs+DBE_INCR_MAX_IDS)*sizeof(XID));
+ if (!pDbeWindowPriv->IDs)
+ {
+ return(BadAlloc);
+ }
+ memset(&pDbeWindowPriv->IDs[pDbeWindowPriv->nBufferIDs], 0,
+ (pDbeWindowPriv->maxAvailableIDs + DBE_INCR_MAX_IDS -
+ pDbeWindowPriv->nBufferIDs) * sizeof(XID));
+
+ if (pDbeWindowPriv->maxAvailableIDs == DBE_INIT_MAX_IDS)
+ {
+ /* We just went from using the initial (static) array to a
+ * newly allocated array. Copy the IDs from the initial array
+ * to the new array.
+ */
+ memcpy(pDbeWindowPriv->IDs, pDbeWindowPriv->initIDs,
+ DBE_INIT_MAX_IDS * sizeof(XID));
+ }
+
+ pDbeWindowPriv->maxAvailableIDs += DBE_INCR_MAX_IDS;
+ }
+
+ /* Finally, record the buffer ID in the array. */
+ pDbeWindowPriv->IDs[i] = stuff->buffer;
+
+ /* Associate the new ID with an existing window priv. */
+ if (!AddResource(stuff->buffer, dbeWindowPrivResType,
+ (pointer)pDbeWindowPriv))
+ {
+ pDbeWindowPriv->IDs[i] = DBE_FREE_ID_ELEMENT;
+ return(BadAlloc);
+ }
+
+ } /* else -- A buffer is already associated with the window. */
+
+
+ /* Call the DDX routine to allocate the back buffer. */
+ status = (*pDbeScreenPriv->AllocBackBufferName)(pWin, stuff->buffer,
+ stuff->swapAction);
+
+ if ((status != Success) && (pDbeWindowPriv->nBufferIDs == 0))
+ {
+ /* The DDX buffer allocation routine failed for the first buffer of
+ * this window.
+ */
+ xfree(pDbeWindowPriv);
+ return(status);
+ }
+
+ /* Increment the number of buffers (XIDs) associated with this window. */
+ pDbeWindowPriv->nBufferIDs++;
+
+ /* Set swap action on all calls. */
+ pDbeWindowPriv->swapAction = stuff->swapAction;
+
+
+ return(status);
+
+} /* ProcDbeAllocateBackBufferName() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: ProcDbeDeallocateBackBufferName
+ *
+ * Description:
+ *
+ * This function is for processing a DbeDeallocateBackBufferName request.
+ * This request frees a drawable ID that was obtained by a
+ * DbeAllocateBackBufferName request.
+ *
+ * Return Values:
+ *
+ * BadBuffer - buffer to deallocate is not associated with a window
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+ProcDbeDeallocateBackBufferName(client)
+ ClientPtr client;
+{
+ REQUEST(xDbeDeallocateBackBufferNameReq);
+ DbeWindowPrivPtr pDbeWindowPriv;
+ int i;
+
+
+ REQUEST_SIZE_MATCH(xDbeDeallocateBackBufferNameReq);
+
+ /* Buffer name must be valid */
+ if (!(pDbeWindowPriv = (DbeWindowPrivPtr)SecurityLookupIDByType(client,
+ stuff->buffer, dbeWindowPrivResType, SecurityDestroyAccess)) ||
+ !(SecurityLookupIDByType(client, stuff->buffer, dbeDrawableResType,
+ SecurityDestroyAccess)))
+ {
+ client->errorValue = stuff->buffer;
+ return(dbeErrorBase + DbeBadBuffer);
+ }
+
+ /* Make sure that the id is valid for the window.
+ * This is paranoid code since we already looked up the ID by type
+ * above.
+ */
+
+ for (i = 0; i < pDbeWindowPriv->nBufferIDs; i++)
+ {
+ /* Loop through the ID list to find the ID. */
+ if (pDbeWindowPriv->IDs[i] == stuff->buffer)
+ {
+ break;
+ }
+ }
+
+ if (i == pDbeWindowPriv->nBufferIDs)
+ {
+ /* We did not find the ID in the ID list. */
+ client->errorValue = stuff->buffer;
+ return(dbeErrorBase + DbeBadBuffer);
+ }
+
+ FreeResource(stuff->buffer, RT_NONE);
+
+ return(Success);
+
+} /* ProcDbeDeallocateBackBufferName() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: ProcDbeSwapBuffers
+ *
+ * Description:
+ *
+ * This function is for processing a DbeSwapBuffers request.
+ * This request swaps the buffers for all windows listed, applying the
+ * appropriate swap action for each window.
+ *
+ * Return Values:
+ *
+ * BadAlloc - local allocation failed; this return value is not defined
+ * by the protocol
+ * BadMatch - a window in request is not double-buffered; a window in
+ * request is listed more than once
+ * BadValue - invalid swap action is specified; no swap action is
+ * specified
+ * BadWindow - a window in request is not valid
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+ProcDbeSwapBuffers(client)
+ ClientPtr client;
+{
+ REQUEST(xDbeSwapBuffersReq);
+ WindowPtr pWin;
+ DbeScreenPrivPtr pDbeScreenPriv;
+ DbeSwapInfoPtr swapInfo;
+ xDbeSwapInfo *dbeSwapInfo;
+ int error;
+ register int i, j;
+ int nStuff;
+
+
+ REQUEST_AT_LEAST_SIZE(xDbeSwapBuffersReq);
+ nStuff = stuff->n; /* use local variable for performance. */
+
+ if (nStuff == 0)
+ {
+ return(Success);
+ }
+
+ if (nStuff > UINT32_MAX / sizeof(DbeSwapInfoRec))
+ return BadAlloc;
+
+ /* Get to the swap info appended to the end of the request. */
+ dbeSwapInfo = (xDbeSwapInfo *)&stuff[1];
+
+ /* Allocate array to record swap information. */
+ swapInfo = (DbeSwapInfoPtr)Xalloc(nStuff * sizeof(DbeSwapInfoRec));
+ if (swapInfo == NULL)
+ {
+ return(BadAlloc);
+ }
+
+
+ for (i = 0; i < nStuff; i++)
+ {
+ /* Check all windows to swap. */
+
+ /* Each window must be a valid window - BadWindow. */
+ if (!(pWin = SecurityLookupWindow(dbeSwapInfo[i].window, client,
+ SecurityWriteAccess)))
+ {
+ Xfree(swapInfo);
+ return(BadWindow);
+ }
+
+ /* Each window must be double-buffered - BadMatch. */
+ if (DBE_WINDOW_PRIV(pWin) == NULL)
+ {
+ Xfree(swapInfo);
+ return(BadMatch);
+ }
+
+ /* Each window must only be specified once - BadMatch. */
+ for (j = i + 1; j < nStuff; j++)
+ {
+ if (dbeSwapInfo[i].window == dbeSwapInfo[j].window)
+ {
+ Xfree(swapInfo);
+ return(BadMatch);
+ }
+ }
+
+ /* Each swap action must be valid - BadValue. */
+ if ((dbeSwapInfo[i].swapAction != XdbeUndefined ) &&
+ (dbeSwapInfo[i].swapAction != XdbeBackground) &&
+ (dbeSwapInfo[i].swapAction != XdbeUntouched ) &&
+ (dbeSwapInfo[i].swapAction != XdbeCopied ))
+ {
+ Xfree(swapInfo);
+ return(BadValue);
+ }
+
+ /* Everything checks out OK. Fill in the swap info array. */
+ swapInfo[i].pWindow = pWin;
+ swapInfo[i].swapAction = dbeSwapInfo[i].swapAction;
+
+ } /* for (i = 0; i < nStuff; i++) */
+
+
+ /* Call the DDX routine to perform the swap(s). The DDX routine should
+ * scan the swap list (swap info), swap any buffers that it knows how to
+ * handle, delete them from the list, and update nStuff to indicate how
+ * many windows it did not handle.
+ *
+ * This scheme allows a range of sophistication in the DDX SwapBuffers()
+ * implementation. Naive implementations could just swap the first buffer
+ * in the list, move the last buffer to the front, decrement nStuff, and
+ * return. The next level of sophistication could be to scan the whole
+ * list for windows on the same screen. Up another level, the DDX routine
+ * could deal with cross-screen synchronization.
+ */
+
+ while (nStuff > 0)
+ {
+ pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(swapInfo[0].pWindow);
+ error = (*pDbeScreenPriv->SwapBuffers)(client, &nStuff, swapInfo);
+ if (error != Success)
+ {
+ Xfree(swapInfo);
+ return(error);
+ }
+ }
+
+ Xfree(swapInfo);
+ return(Success);
+
+} /* ProcDbeSwapBuffers() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: ProcDbeBeginIdiom
+ *
+ * Description:
+ *
+ * This function is for processing a DbeBeginIdiom request.
+ * This request informs the server that a complex swap will immediately
+ * follow this request.
+ *
+ * Return Values:
+ *
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+ProcDbeBeginIdiom(client)
+ ClientPtr client;
+{
+ /* REQUEST(xDbeBeginIdiomReq); */
+ DbeScreenPrivPtr pDbeScreenPriv;
+ register int i;
+
+
+ REQUEST_SIZE_MATCH(xDbeBeginIdiomReq);
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ pDbeScreenPriv = DBE_SCREEN_PRIV(screenInfo.screens[i]);
+
+ /* Call the DDX begin idiom procedure if there is one. */
+ if (pDbeScreenPriv->BeginIdiom)
+ {
+ (*pDbeScreenPriv->BeginIdiom)(client);
+ }
+ }
+
+ return(Success);
+
+} /* ProcDbeBeginIdiom() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: ProcDbeGetVisualInfo
+ *
+ * Description:
+ *
+ * This function is for processing a ProcDbeGetVisualInfo request.
+ * This request returns information about which visuals support
+ * double buffering.
+ *
+ * Return Values:
+ *
+ * BadDrawable - value in screen specifiers is not a valid drawable
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+ProcDbeGetVisualInfo(client)
+ ClientPtr client;
+{
+ REQUEST(xDbeGetVisualInfoReq);
+ DbeScreenPrivPtr pDbeScreenPriv;
+ xDbeGetVisualInfoReply rep;
+ Drawable *drawables;
+ DrawablePtr *pDrawables = NULL;
+ register int i, j, n;
+ register int count; /* number of visual infos in reply */
+ register int length; /* length of reply */
+ ScreenPtr pScreen;
+ XdbeScreenVisualInfo *pScrVisInfo;
+
+
+ REQUEST_AT_LEAST_SIZE(xDbeGetVisualInfoReq);
+
+ if (stuff->n > UINT32_MAX / sizeof(DrawablePtr))
+ return BadAlloc;
+ /* Make sure any specified drawables are valid. */
+ if (stuff->n != 0)
+ {
+ if (!(pDrawables = (DrawablePtr *)Xalloc(stuff->n *
+ sizeof(DrawablePtr))))
+ {
+ return(BadAlloc);
+ }
+
+ drawables = (Drawable *)&stuff[1];
+
+ for (i = 0; i < stuff->n; i++)
+ {
+ if (!(pDrawables[i] = (DrawablePtr)SecurityLookupDrawable(
+ drawables[i], client, SecurityReadAccess)))
+ {
+ Xfree(pDrawables);
+ return(BadDrawable);
+ }
+ }
+ }
+
+ count = (stuff->n == 0) ? screenInfo.numScreens : stuff->n;
+ if (!(pScrVisInfo = (XdbeScreenVisualInfo *)xalloc(count *
+ sizeof(XdbeScreenVisualInfo))))
+ {
+ if (pDrawables)
+ {
+ Xfree(pDrawables);
+ }
+
+ return(BadAlloc);
+ }
+
+ length = 0;
+
+ for (i = 0; i < count; i++)
+ {
+ pScreen = (stuff->n == 0) ? screenInfo.screens[i] :
+ pDrawables[i]->pScreen;
+ pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+
+ if (!(*pDbeScreenPriv->GetVisualInfo)(pScreen, &pScrVisInfo[i]))
+ {
+ /* We failed to alloc pScrVisInfo[i].visinfo. */
+
+ /* Free visinfos that we allocated for previous screen infos.*/
+ for (j = 0; j < i; j++)
+ {
+ xfree(pScrVisInfo[j].visinfo);
+ }
+
+ /* Free pDrawables if we needed to allocate it above. */
+ if (pDrawables)
+ {
+ Xfree(pDrawables);
+ }
+
+ return(BadAlloc);
+ }
+
+ /* Account for n, number of xDbeVisInfo items in list. */
+ length += sizeof(CARD32);
+
+ /* Account for n xDbeVisInfo items */
+ length += pScrVisInfo[i].count * sizeof(xDbeVisInfo);
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = length >> 2;
+ rep.m = count;
+
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.m, n);
+ }
+
+ /* Send off reply. */
+ WriteToClient(client, sizeof(xDbeGetVisualInfoReply), (char *)&rep);
+
+ for (i = 0; i < count; i++)
+ {
+ CARD32 data32;
+
+ /* For each screen in the reply, send off the visual info */
+
+ /* Send off number of visuals. */
+ data32 = (CARD32)pScrVisInfo[i].count;
+
+ if (client->swapped)
+ {
+ swapl(&data32, n);
+ }
+
+ WriteToClient(client, sizeof(CARD32), (char *)&data32);
+
+ /* Now send off visual info items. */
+ for (j = 0; j < pScrVisInfo[i].count; j++)
+ {
+ xDbeVisInfo visInfo;
+
+ /* Copy the data in the client data structure to a protocol
+ * data structure. We will send data to the client from the
+ * protocol data structure.
+ */
+
+ visInfo.visualID = (CARD32)pScrVisInfo[i].visinfo[j].visual;
+ visInfo.depth = (CARD8) pScrVisInfo[i].visinfo[j].depth;
+ visInfo.perfLevel = (CARD8) pScrVisInfo[i].visinfo[j].perflevel;
+
+ if (client->swapped)
+ {
+ swapl(&visInfo.visualID, n);
+
+ /* We do not need to swap depth and perfLevel since they are
+ * already 1 byte quantities.
+ */
+ }
+
+ /* Write visualID(32), depth(8), perfLevel(8), and pad(16). */
+ WriteToClient(client, 2*sizeof(CARD32), (char *)&visInfo.visualID);
+ }
+ }
+
+ /* Clean up memory. */
+ for (i = 0; i < count; i++)
+ {
+ xfree(pScrVisInfo[i].visinfo);
+ }
+ xfree(pScrVisInfo);
+
+ if (pDrawables)
+ {
+ Xfree(pDrawables);
+ }
+
+ return(client->noClientException);
+
+} /* ProcDbeGetVisualInfo() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: ProcDbeGetbackBufferAttributes
+ *
+ * Description:
+ *
+ * This function is for processing a ProcDbeGetbackBufferAttributes
+ * request. This request returns information about a back buffer.
+ *
+ * Return Values:
+ *
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+ProcDbeGetBackBufferAttributes(client)
+ ClientPtr client;
+{
+ REQUEST(xDbeGetBackBufferAttributesReq);
+ xDbeGetBackBufferAttributesReply rep;
+ DbeWindowPrivPtr pDbeWindowPriv;
+ int n;
+
+
+ REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq);
+
+ if (!(pDbeWindowPriv = (DbeWindowPrivPtr)SecurityLookupIDByType(client,
+ stuff->buffer, dbeWindowPrivResType, SecurityReadAccess)))
+ {
+ rep.attributes = None;
+ }
+ else
+ {
+ rep.attributes = pDbeWindowPriv->pWindow->drawable.id;
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.attributes, n);
+ }
+
+ WriteToClient(client, sizeof(xDbeGetBackBufferAttributesReply),
+ (char *)&rep);
+ return(client->noClientException);
+
+} /* ProcDbeGetbackBufferAttributes() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: ProcDbeDispatch
+ *
+ * Description:
+ *
+ * This function dispatches DBE requests.
+ *
+ *****************************************************************************/
+
+static int
+ProcDbeDispatch(client)
+ ClientPtr client;
+{
+ REQUEST(xReq);
+
+
+ switch (stuff->data)
+ {
+ case X_DbeGetVersion:
+ return(ProcDbeGetVersion(client));
+
+ case X_DbeAllocateBackBufferName:
+ return(ProcDbeAllocateBackBufferName(client));
+
+ case X_DbeDeallocateBackBufferName:
+ return(ProcDbeDeallocateBackBufferName(client));
+
+ case X_DbeSwapBuffers:
+ return(ProcDbeSwapBuffers(client));
+
+ case X_DbeBeginIdiom:
+ return(ProcDbeBeginIdiom(client));
+
+ case X_DbeEndIdiom:
+ return(Success);
+
+ case X_DbeGetVisualInfo:
+ return(ProcDbeGetVisualInfo(client));
+
+ case X_DbeGetBackBufferAttributes:
+ return(ProcDbeGetBackBufferAttributes(client));
+
+ default:
+ return(BadRequest);
+ }
+
+} /* ProcDbeDispatch() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: SProcDbeGetVersion
+ *
+ * Description:
+ *
+ * This function is for processing a DbeGetVersion request on a swapped
+ * server. This request returns the major and minor version numbers of
+ * this extension.
+ *
+ * Return Values:
+ *
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+SProcDbeGetVersion(client)
+ ClientPtr client;
+{
+ REQUEST(xDbeGetVersionReq);
+ register int n;
+
+
+ swaps(&stuff->length, n);
+ return(ProcDbeGetVersion(client));
+
+} /* SProcDbeGetVersion() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: SProcDbeAllocateBackBufferName
+ *
+ * Description:
+ *
+ * This function is for processing a DbeAllocateBackBufferName request on
+ * a swapped server. This request allocates a drawable ID used to refer
+ * to the back buffer of a window.
+ *
+ * Return Values:
+ *
+ * BadAlloc - server can not allocate resources
+ * BadIDChoice - id is out of range for client; id is already in use
+ * BadMatch - window is not an InputOutput window;
+ * visual of window is not on list returned by
+ * DBEGetVisualInfo;
+ * BadValue - invalid swap action is specified
+ * BadWindow - window is not a valid window
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+SProcDbeAllocateBackBufferName(client)
+ ClientPtr client;
+{
+ REQUEST(xDbeAllocateBackBufferNameReq);
+ register int n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDbeAllocateBackBufferNameReq);
+
+ swapl(&stuff->window, n);
+ swapl(&stuff->buffer, n);
+ /* stuff->swapAction is a byte. We do not need to swap this field. */
+
+ return(ProcDbeAllocateBackBufferName(client));
+
+} /* SProcDbeAllocateBackBufferName() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: SProcDbeDeallocateBackBufferName
+ *
+ * Description:
+ *
+ * This function is for processing a DbeDeallocateBackBufferName request
+ * on a swapped server. This request frees a drawable ID that was
+ * obtained by a DbeAllocateBackBufferName request.
+ *
+ * Return Values:
+ *
+ * BadBuffer - buffer to deallocate is not associated with a window
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+SProcDbeDeallocateBackBufferName(client)
+ ClientPtr client;
+{
+ REQUEST (xDbeDeallocateBackBufferNameReq);
+ register int n;
+
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDbeDeallocateBackBufferNameReq);
+
+ swapl(&stuff->buffer, n);
+
+ return(ProcDbeDeallocateBackBufferName(client));
+
+} /* SProcDbeDeallocateBackBufferName() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: SProcDbeSwapBuffers
+ *
+ * Description:
+ *
+ * This function is for processing a DbeSwapBuffers request on a swapped
+ * server. This request swaps the buffers for all windows listed,
+ * applying the appropriate swap action for each window.
+ *
+ * Return Values:
+ *
+ * BadMatch - a window in request is not double-buffered; a window in
+ * request is listed more than once; all windows in request do
+ * not have the same root
+ * BadValue - invalid swap action is specified
+ * BadWindow - a window in request is not valid
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+SProcDbeSwapBuffers(client)
+ ClientPtr client;
+{
+ REQUEST(xDbeSwapBuffersReq);
+ register int i, n;
+ xDbeSwapInfo *pSwapInfo;
+
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xDbeSwapBuffersReq);
+
+ swapl(&stuff->n, n);
+
+ if (stuff->n != 0)
+ {
+ pSwapInfo = (xDbeSwapInfo *)stuff+1;
+
+ /* The swap info following the fix part of this request is a window(32)
+ * followed by a 1 byte swap action and then 3 pad bytes. We only need
+ * to swap the window information.
+ */
+ for (i = 0; i < stuff->n; i++)
+ {
+ swapl(&pSwapInfo->window, n);
+ }
+ }
+
+ return(ProcDbeSwapBuffers(client));
+
+} /* SProcDbeSwapBuffers() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: SProcDbeBeginIdiom
+ *
+ * Description:
+ *
+ * This function is for processing a DbeBeginIdiom request on a swapped
+ * server. This request informs the server that a complex swap will
+ * immediately follow this request.
+ *
+ * Return Values:
+ *
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+SProcDbeBeginIdiom(client)
+ ClientPtr client;
+{
+ REQUEST(xDbeBeginIdiomReq);
+ register int n;
+
+ swaps(&stuff->length, n);
+ return(ProcDbeBeginIdiom(client));
+
+} /* SProcDbeBeginIdiom() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: SProcDbeGetVisualInfo
+ *
+ * Description:
+ *
+ * This function is for processing a ProcDbeGetVisualInfo request on a
+ * swapped server. This request returns information about which visuals
+ * support double buffering.
+ *
+ * Return Values:
+ *
+ * BadDrawable - value in screen specifiers is not a valid drawable
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+SProcDbeGetVisualInfo(client)
+ ClientPtr client;
+{
+ REQUEST(xDbeGetVisualInfoReq);
+ register int n;
+
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xDbeGetVisualInfoReq);
+
+ swapl(&stuff->n, n);
+ SwapRestL(stuff);
+
+ return(ProcDbeGetVisualInfo(client));
+
+} /* SProcDbeGetVisualInfo() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: SProcDbeGetbackBufferAttributes
+ *
+ * Description:
+ *
+ * This function is for processing a ProcDbeGetbackBufferAttributes
+ * request on a swapped server. This request returns information about a
+ * back buffer.
+ *
+ * Return Values:
+ *
+ * Success
+ *
+ *****************************************************************************/
+
+static int
+SProcDbeGetBackBufferAttributes(client)
+ ClientPtr client;
+{
+ REQUEST (xDbeGetBackBufferAttributesReq);
+ register int n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq);
+
+ swapl(&stuff->buffer, n);
+
+ return(ProcDbeGetBackBufferAttributes(client));
+
+} /* SProcDbeGetBackBufferAttributes() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: SProcDbeDispatch
+ *
+ * Description:
+ *
+ * This function dispatches DBE requests on a swapped server.
+ *
+ *****************************************************************************/
+
+static int
+SProcDbeDispatch(client)
+ ClientPtr client;
+{
+ REQUEST(xReq);
+
+
+ switch (stuff->data)
+ {
+ case X_DbeGetVersion:
+ return(SProcDbeGetVersion(client));
+
+ case X_DbeAllocateBackBufferName:
+ return(SProcDbeAllocateBackBufferName(client));
+
+ case X_DbeDeallocateBackBufferName:
+ return(SProcDbeDeallocateBackBufferName(client));
+
+ case X_DbeSwapBuffers:
+ return(SProcDbeSwapBuffers(client));
+
+ case X_DbeBeginIdiom:
+ return(SProcDbeBeginIdiom(client));
+
+ case X_DbeEndIdiom:
+ return(Success);
+
+ case X_DbeGetVisualInfo:
+ return(SProcDbeGetVisualInfo(client));
+
+ case X_DbeGetBackBufferAttributes:
+ return(SProcDbeGetBackBufferAttributes(client));
+
+ default:
+ return (BadRequest);
+ }
+
+} /* SProcDbeDispatch() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeSetupBackgroundPainter
+ *
+ * Description:
+ *
+ * This function sets up pGC to clear pixmaps.
+ *
+ * Return Values:
+ *
+ * TRUE - setup was successful
+ * FALSE - the window's background state is NONE
+ *
+ *****************************************************************************/
+
+static Bool
+DbeSetupBackgroundPainter(pWin, pGC)
+ WindowPtr pWin;
+ GCPtr pGC;
+{
+ pointer gcvalues[4];
+ int ts_x_origin, ts_y_origin;
+ PixUnion background;
+ int backgroundState;
+ Mask gcmask;
+
+
+ /* First take care of any ParentRelative stuff by altering the
+ * tile/stipple origin to match the coordinates of the upper-left
+ * corner of the first ancestor without a ParentRelative background.
+ * This coordinate is, of course, negative.
+ */
+ ts_x_origin = ts_y_origin = 0;
+ while (pWin->backgroundState == ParentRelative)
+ {
+ ts_x_origin -= pWin->origin.x;
+ ts_y_origin -= pWin->origin.y;
+
+ pWin = pWin->parent;
+ }
+ backgroundState = pWin->backgroundState;
+ background = pWin->background;
+
+ switch (backgroundState)
+ {
+ case BackgroundPixel:
+ gcvalues[0] = (pointer)background.pixel;
+ gcvalues[1] = (pointer)FillSolid;
+ gcmask = GCForeground|GCFillStyle;
+ break;
+
+ case BackgroundPixmap:
+ gcvalues[0] = (pointer)FillTiled;
+ gcvalues[1] = (pointer)background.pixmap;
+ gcvalues[2] = (pointer)(long)ts_x_origin;
+ gcvalues[3] = (pointer)(long)ts_y_origin;
+ gcmask = GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin;
+ break;
+
+ default:
+ /* pWin->backgroundState == None */
+ return(FALSE);
+ }
+
+ if (DoChangeGC(pGC, gcmask, (XID *)gcvalues, TRUE) != 0)
+ {
+ return(FALSE);
+ }
+
+ return(TRUE);
+
+} /* DbeSetupBackgroundPainter() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeDrawableDelete
+ *
+ * Description:
+ *
+ * This is the resource delete function for dbeDrawableResType.
+ * It is registered when the drawable resource type is created in
+ * DbeExtensionInit().
+ *
+ * To make resource deletion simple, we do not do anything in this function
+ * and leave all resource deleteion to DbeWindowPrivDelete(), which will
+ * eventually be called or already has been called. Deletion functions are
+ * not guaranteed to be called in any particular order.
+ *
+ *****************************************************************************/
+static int
+DbeDrawableDelete(pDrawable, id)
+ pointer pDrawable;
+ XID id;
+{
+ return(Success);
+
+} /* DbeDrawableDelete() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeWindowPrivDelete
+ *
+ * Description:
+ *
+ * This is the resource delete function for dbeWindowPrivResType.
+ * It is registered when the drawable resource type is created in
+ * DbeExtensionInit().
+ *
+ *****************************************************************************/
+static int
+DbeWindowPrivDelete(pDbeWinPriv, id)
+ pointer pDbeWinPriv;
+ XID id;
+{
+ DbeScreenPrivPtr pDbeScreenPriv;
+ DbeWindowPrivPtr pDbeWindowPriv = (DbeWindowPrivPtr)pDbeWinPriv;
+ int i;
+
+
+ /*
+ **************************************************************************
+ ** Remove the buffer ID from the ID array.
+ **************************************************************************
+ */
+
+ /* Find the ID in the ID array. */
+ i = 0;
+ while ((i < pDbeWindowPriv->nBufferIDs) && (pDbeWindowPriv->IDs[i] != id))
+ {
+ i++;
+ }
+
+ if (i == pDbeWindowPriv->nBufferIDs)
+ {
+ /* We did not find the ID in the array. We should never get here. */
+ return(BadValue);
+ }
+
+ /* Remove the ID from the array. */
+
+ if (i < (pDbeWindowPriv->nBufferIDs - 1))
+ {
+ /* Compress the buffer ID array, overwriting the ID in the process. */
+ memmove(&pDbeWindowPriv->IDs[i], &pDbeWindowPriv->IDs[i+1],
+ (pDbeWindowPriv->nBufferIDs - i - 1) * sizeof(XID));
+ }
+ else
+ {
+ /* We are removing the last ID in the array, in which case, the
+ * assignement below is all that we need to do.
+ */
+ }
+ pDbeWindowPriv->IDs[pDbeWindowPriv->nBufferIDs - 1] = DBE_FREE_ID_ELEMENT;
+
+ pDbeWindowPriv->nBufferIDs--;
+
+ /* If an extended array was allocated, then check to see if the remaining
+ * buffer IDs will fit in the static array.
+ */
+
+ if ((pDbeWindowPriv->maxAvailableIDs > DBE_INIT_MAX_IDS) &&
+ (pDbeWindowPriv->nBufferIDs == DBE_INIT_MAX_IDS))
+ {
+ /* Copy the IDs back into the static array. */
+ memcpy(pDbeWindowPriv->initIDs, pDbeWindowPriv->IDs,
+ DBE_INIT_MAX_IDS * sizeof(XID));
+
+ /* Free the extended array; use the static array. */
+ xfree(pDbeWindowPriv->IDs);
+ pDbeWindowPriv->IDs = pDbeWindowPriv->initIDs;
+ pDbeWindowPriv->maxAvailableIDs = DBE_INIT_MAX_IDS;
+ }
+
+
+ /*
+ **************************************************************************
+ ** Perform DDX level tasks.
+ **************************************************************************
+ */
+
+ pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW_PRIV(
+ (DbeWindowPrivPtr)pDbeWindowPriv);
+ (*pDbeScreenPriv->WinPrivDelete)((DbeWindowPrivPtr)pDbeWindowPriv, id);
+
+
+ /*
+ **************************************************************************
+ ** Perform miscellaneous tasks if this is the last buffer associated
+ ** with the window.
+ **************************************************************************
+ */
+
+ if (pDbeWindowPriv->nBufferIDs == 0)
+ {
+ /* Reset the DBE window priv pointer. */
+ pDbeWindowPriv->pWindow->devPrivates[dbeWindowPrivIndex].ptr =
+ (pointer)NULL;
+
+ /* We are done with the window priv. */
+ xfree(pDbeWindowPriv);
+ }
+
+ return(Success);
+
+} /* DbeWindowPrivDelete() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeResetProc
+ *
+ * Description:
+ *
+ * This routine is called at the end of every server generation.
+ * It deallocates any memory reserved for the extension and performs any
+ * other tasks related to shutting down the extension.
+ *
+ *****************************************************************************/
+static void
+DbeResetProc(extEntry)
+ ExtensionEntry *extEntry;
+{
+ int i;
+ ScreenPtr pScreen;
+ DbeScreenPrivPtr pDbeScreenPriv;
+
+
+ if (dbeScreenPrivIndex < 0)
+ {
+ return;
+ }
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ pScreen = screenInfo.screens[i];
+ pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+
+ if (pDbeScreenPriv)
+ {
+ /* Unwrap DestroyWindow, which was wrapped in DbeExtensionInit().*/
+ pScreen->DestroyWindow = pDbeScreenPriv->DestroyWindow;
+
+ if (pDbeScreenPriv->ResetProc)
+ (*pDbeScreenPriv->ResetProc)(pScreen);
+
+ if (pDbeScreenPriv->winPrivPrivSizes)
+ {
+ xfree(pDbeScreenPriv->winPrivPrivSizes);
+ }
+
+ xfree(pDbeScreenPriv);
+ }
+ }
+
+ /* We want to init the initialization function table after every server
+ * reset in DbeRegisterFunction().
+ */
+ firstRegistrationPass = TRUE;
+
+} /* DbeResetProc() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeDestroyWindow
+ *
+ * Description:
+ *
+ * This is the wrapper for pScreen->DestroyWindow.
+ * This function frees buffer resources for a window before it is
+ * destroyed.
+ *
+ *****************************************************************************/
+
+static Bool
+DbeDestroyWindow(pWin)
+ WindowPtr pWin;
+{
+ DbeScreenPrivPtr pDbeScreenPriv;
+ DbeWindowPrivPtr pDbeWindowPriv;
+ ScreenPtr pScreen;
+ Bool ret;
+
+
+ /*
+ **************************************************************************
+ ** 1. Unwrap the member routine.
+ **************************************************************************
+ */
+
+ pScreen = pWin->drawable.pScreen;
+ pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+ pScreen->DestroyWindow = pDbeScreenPriv->DestroyWindow;
+
+ /*
+ **************************************************************************
+ ** 2. Do any work necessary before the member routine is called.
+ **
+ ** Call the window priv delete function for all buffer IDs associated
+ ** with this window.
+ **************************************************************************
+ */
+
+ if ((pDbeWindowPriv = DBE_WINDOW_PRIV(pWin)))
+ {
+ while (pDbeWindowPriv)
+ {
+ /* *DbeWinPrivDelete() will free the window private and set it to
+ * NULL if there are no more buffer IDs associated with this
+ * window.
+ */
+ FreeResource(pDbeWindowPriv->IDs[0], RT_NONE);
+ pDbeWindowPriv = DBE_WINDOW_PRIV(pWin);
+ }
+ }
+
+ /*
+ **************************************************************************
+ ** 3. Call the member routine, saving its result if necessary.
+ **************************************************************************
+ */
+
+ ret = (*pScreen->DestroyWindow)(pWin);
+
+ /*
+ **************************************************************************
+ ** 4. Rewrap the member routine, restoring the wrapper value first in case
+ ** the wrapper (or something that it wrapped) change this value.
+ **************************************************************************
+ */
+
+ pDbeScreenPriv->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = DbeDestroyWindow;
+
+ /*
+ **************************************************************************
+ ** 5. Do any work necessary after the member routine has been called.
+ **
+ ** In this case we do not need to do anything.
+ **************************************************************************
+ */
+
+ return(ret);
+
+} /* DbeDestroyWindow() */
+
+
+/******************************************************************************
+ *
+ * DBE DIX Procedure: DbeExtensionInit
+ *
+ * Description:
+ *
+ * Called from InitExtensions in main()
+ *
+ *****************************************************************************/
+
+void
+DbeExtensionInit()
+{
+ ExtensionEntry *extEntry;
+ register int i, j;
+ ScreenPtr pScreen = NULL;
+ DbeScreenPrivPtr pDbeScreenPriv;
+ int nStubbedScreens = 0;
+ Bool ddxInitSuccess;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) return;
+#endif
+
+ /* Allocate private pointers in windows and screens. */
+
+ if ((dbeScreenPrivIndex = AllocateScreenPrivateIndex()) < 0)
+ {
+ return;
+ }
+
+ if ((dbeWindowPrivIndex = AllocateWindowPrivateIndex()) < 0)
+ {
+ return;
+ }
+
+ /* Initialize the priv priv counts between server generations. */
+ winPrivPrivCount = 0;
+
+ /* Create the resource types. */
+ dbeDrawableResType =
+ CreateNewResourceType(DbeDrawableDelete) | RC_CACHED | RC_DRAWABLE;
+ dbeWindowPrivResType =
+ CreateNewResourceType(DbeWindowPrivDelete);
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ /* For each screen, set up DBE screen privates and init DIX and DDX
+ * interface.
+ */
+
+ pScreen = screenInfo.screens[i];
+
+ if (!AllocateWindowPrivate(pScreen, dbeWindowPrivIndex, 0) ||
+ !(pDbeScreenPriv =
+ (DbeScreenPrivPtr)Xcalloc(sizeof(DbeScreenPrivRec))))
+ {
+ /* If we can not alloc a window or screen private,
+ * then free any privates that we already alloc'ed and return
+ */
+
+ for (j = 0; j < i; j++)
+ {
+ xfree(screenInfo.screens[j]->devPrivates[dbeScreenPrivIndex].ptr);
+ screenInfo.screens[j]->devPrivates[dbeScreenPrivIndex].ptr = NULL;
+ }
+ return;
+ }
+
+ pScreen->devPrivates[dbeScreenPrivIndex].ptr = (pointer)pDbeScreenPriv;
+
+ /* Store the DBE priv priv size info for later use when allocating
+ * priv privs at the driver level.
+ */
+ pDbeScreenPriv->winPrivPrivLen = 0;
+ pDbeScreenPriv->winPrivPrivSizes = (unsigned *)NULL;
+ pDbeScreenPriv->totalWinPrivSize = sizeof(DbeWindowPrivRec);
+
+ /* Copy the resource types */
+ pDbeScreenPriv->dbeDrawableResType = dbeDrawableResType;
+ pDbeScreenPriv->dbeWindowPrivResType = dbeWindowPrivResType;
+
+ /* Copy the private indices */
+ pDbeScreenPriv->dbeScreenPrivIndex = dbeScreenPrivIndex;
+ pDbeScreenPriv->dbeWindowPrivIndex = dbeWindowPrivIndex;
+
+ if(DbeInitFunct[i])
+ {
+ /* This screen supports DBE. */
+
+ /* Setup DIX. */
+ pDbeScreenPriv->SetupBackgroundPainter = DbeSetupBackgroundPainter;
+ pDbeScreenPriv->AllocWinPriv = DbeAllocWinPriv;
+ pDbeScreenPriv->AllocWinPrivPrivIndex = DbeAllocWinPrivPrivIndex;
+ pDbeScreenPriv->AllocWinPrivPriv = DbeAllocWinPrivPriv;
+
+ /* Setup DDX. */
+ ddxInitSuccess = (*DbeInitFunct[i])(pScreen, pDbeScreenPriv);
+
+ /* DDX DBE initialization may have the side affect of
+ * reallocating pDbeScreenPriv, so we need to update it.
+ */
+ pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+
+ if (ddxInitSuccess)
+ {
+ /* Wrap DestroyWindow. The DDX initialization function
+ * already wrapped PositionWindow for us.
+ */
+
+ pDbeScreenPriv->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = DbeDestroyWindow;
+ }
+ else
+ {
+ /* DDX initialization failed. Stub the screen. */
+ DbeStubScreen(pDbeScreenPriv, &nStubbedScreens);
+ }
+ }
+ else
+ {
+ /* This screen does not support DBE. */
+
+#ifndef DISABLE_MI_DBE_BY_DEFAULT
+ /* Setup DIX. */
+ pDbeScreenPriv->SetupBackgroundPainter = DbeSetupBackgroundPainter;
+ pDbeScreenPriv->AllocWinPriv = DbeAllocWinPriv;
+ pDbeScreenPriv->AllocWinPrivPrivIndex = DbeAllocWinPrivPrivIndex;
+ pDbeScreenPriv->AllocWinPrivPriv = DbeAllocWinPrivPriv;
+
+ /* Setup DDX. */
+ ddxInitSuccess = miDbeInit(pScreen, pDbeScreenPriv);
+
+ /* DDX DBE initialization may have the side affect of
+ * reallocating pDbeScreenPriv, so we need to update it.
+ */
+ pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+
+ if (ddxInitSuccess)
+ {
+ /* Wrap DestroyWindow. The DDX initialization function
+ * already wrapped PositionWindow for us.
+ */
+
+ pDbeScreenPriv->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = DbeDestroyWindow;
+ }
+ else
+ {
+ /* DDX initialization failed. Stub the screen. */
+ DbeStubScreen(pDbeScreenPriv, &nStubbedScreens);
+ }
+#else
+ DbeStubScreen(pDbeScreenPriv, &nStubbedScreens);
+#endif
+
+ } /* else -- this screen does not support DBE. */
+
+ } /* for (i = 0; i < screenInfo.numScreens; i++) */
+
+
+ if (nStubbedScreens == screenInfo.numScreens)
+ {
+ /* All screens stubbed. Clean up and return. */
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ xfree(screenInfo.screens[i]->devPrivates[dbeScreenPrivIndex].ptr);
+ pScreen->devPrivates[dbeScreenPrivIndex].ptr = NULL;
+ }
+ return;
+ }
+
+
+ /* Now add the extension. */
+ extEntry = AddExtension(DBE_PROTOCOL_NAME, DbeNumberEvents,
+ DbeNumberErrors, ProcDbeDispatch, SProcDbeDispatch,
+ DbeResetProc, StandardMinorOpcode);
+
+ dbeErrorBase = extEntry->errorBase;
+
+} /* DbeExtensionInit() */
+
diff --git a/nx-X11/programs/Xserver/dbe/dbemodule.c b/nx-X11/programs/Xserver/dbe/dbemodule.c
new file mode 100644
index 000000000..62fbcfd21
--- /dev/null
+++ b/nx-X11/programs/Xserver/dbe/dbemodule.c
@@ -0,0 +1,48 @@
+/* $XFree86: xc/programs/Xserver/dbe/dbemodule.c,v 1.6 1999/01/26 05:53:50 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Module.h"
+#include "globals.h"
+
+static MODULESETUPPROTO(dbeSetup);
+
+extern void DbeExtensionInit(INITARGS);
+
+ExtensionModule dbeExt = {
+ DbeExtensionInit,
+ "DOUBLE-BUFFER",
+ &noDbeExtension,
+ NULL,
+ NULL
+};
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "dbe",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_EXTENSION,
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_EXTENSION,
+ {0,0,0,0}
+};
+
+/*
+ * Data for the loader
+ */
+XF86ModuleData dbeModuleData = { &VersRec, dbeSetup, NULL };
+
+static pointer
+dbeSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ LoadExtension(&dbeExt, FALSE);
+
+ /* Need a non-NULL return value to indicate success */
+ return (pointer)1;
+}
diff --git a/nx-X11/programs/Xserver/dbe/dbestruct.h b/nx-X11/programs/Xserver/dbe/dbestruct.h
new file mode 100644
index 000000000..69135a837
--- /dev/null
+++ b/nx-X11/programs/Xserver/dbe/dbestruct.h
@@ -0,0 +1,237 @@
+/* $Xorg: dbestruct.h,v 1.3 2000/08/17 19:48:16 cpqbld Exp $ */
+/******************************************************************************
+ *
+ * Copyright (c) 1994, 1995 Hewlett-Packard Company
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Hewlett-Packard
+ * Company shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the Hewlett-Packard Company.
+ *
+ * Header file for DIX-related DBE
+ *
+ *****************************************************************************/
+/* $XFree86$ */
+
+#ifndef DBE_STRUCT_H
+#define DBE_STRUCT_H
+
+
+/* INCLUDES */
+
+#define NEED_DBE_PROTOCOL
+#include <X11/extensions/Xdbeproto.h>
+#include "windowstr.h"
+
+
+/* DEFINES */
+
+#define DBE_SCREEN_PRIV(pScreen) \
+ ((dbeScreenPrivIndex < 0) ? \
+ NULL : \
+ ((DbeScreenPrivPtr)((pScreen)->devPrivates[dbeScreenPrivIndex].ptr)))
+
+#define DBE_SCREEN_PRIV_FROM_DRAWABLE(pDrawable) \
+ DBE_SCREEN_PRIV((pDrawable)->pScreen)
+
+#define DBE_SCREEN_PRIV_FROM_WINDOW_PRIV(pDbeWindowPriv) \
+ DBE_SCREEN_PRIV((pDbeWindowPriv)->pWindow->drawable.pScreen)
+
+#define DBE_SCREEN_PRIV_FROM_WINDOW(pWindow) \
+ DBE_SCREEN_PRIV((pWindow)->drawable.pScreen)
+
+#define DBE_SCREEN_PRIV_FROM_PIXMAP(pPixmap) \
+ DBE_SCREEN_PRIV((pPixmap)->drawable.pScreen)
+
+#define DBE_SCREEN_PRIV_FROM_GC(pGC)\
+ DBE_SCREEN_PRIV((pGC)->pScreen)
+
+#define DBE_WINDOW_PRIV(pWindow)\
+ ((dbeWindowPrivIndex < 0) ? \
+ NULL : \
+ ((DbeWindowPrivPtr)(pWindow->devPrivates[dbeWindowPrivIndex].ptr)))
+
+/* Initial size of the buffer ID array in the window priv. */
+#define DBE_INIT_MAX_IDS 2
+
+/* Reallocation increment for the buffer ID array. */
+#define DBE_INCR_MAX_IDS 4
+
+/* Marker for free elements in the buffer ID array. */
+#define DBE_FREE_ID_ELEMENT 0
+
+
+/* TYPEDEFS */
+
+/* Record used to pass swap information between DIX and DDX swapping
+ * procedures.
+ */
+typedef struct _DbeSwapInfoRec
+{
+ WindowPtr pWindow;
+ unsigned char swapAction;
+
+} DbeSwapInfoRec, *DbeSwapInfoPtr;
+
+/*
+ ******************************************************************************
+ ** Per-window data
+ ******************************************************************************
+ */
+
+typedef struct _DbeWindowPrivRec
+{
+ /* A pointer to the window with which the DBE window private (buffer) is
+ * associated.
+ */
+ WindowPtr pWindow;
+
+ /* Last known swap action for this buffer. Legal values for this field
+ * are XdbeUndefined, XdbeBackground, XdbeUntouched, and XdbeCopied.
+ */
+ unsigned char swapAction;
+
+ /* Last known buffer size.
+ */
+ unsigned short width, height;
+
+ /* Coordinates used for static gravity when the window is positioned.
+ */
+ short x, y;
+
+ /* Number of XIDs associated with this buffer.
+ */
+ int nBufferIDs;
+
+ /* Capacity of the current buffer ID array, IDs. */
+ int maxAvailableIDs;
+
+ /* Pointer to the array of buffer IDs. This initially points to initIDs.
+ * When the static limit of the initIDs array is reached, the array is
+ * reallocated and this pointer is set to the new array instead of initIDs.
+ */
+ XID *IDs;
+
+ /* Initial array of buffer IDs. We are defining the XID array within the
+ * window priv to optimize for data locality. In most cases, only one
+ * buffer will be associated with a window. Having the array declared
+ * here can prevent us from accessing the data in another memory page,
+ * possibly resulting in a page swap and loss of performance. Initially we
+ * will use this array to store buffer IDs. For situations where we have
+ * more IDs than can fit in this static array, we will allocate a larger
+ * array to use, possibly suffering a performance loss.
+ */
+ XID initIDs[DBE_INIT_MAX_IDS];
+
+ /* Device-specific private information.
+ */
+ DevUnion *devPrivates;
+
+} DbeWindowPrivRec, *DbeWindowPrivPtr;
+
+
+/*
+ ******************************************************************************
+ ** Per-screen data
+ ******************************************************************************
+ */
+
+typedef struct _DbeScreenPrivRec
+{
+ /* Info for creating window privs */
+ int winPrivPrivLen; /* Length of privs in DbeWindowPrivRec */
+ unsigned int *winPrivPrivSizes; /* Array of private record sizes */
+ unsigned int totalWinPrivSize; /* PrivRec + size of all priv priv ptrs */
+
+ /* Resources created by DIX to be used by DDX */
+ RESTYPE dbeDrawableResType;
+ RESTYPE dbeWindowPrivResType;
+
+ /* Private indices created by DIX to be used by DDX */
+ int dbeScreenPrivIndex;
+ int dbeWindowPrivIndex;
+
+ /* Wrapped functions
+ * It is the responsibilty of the DDX layer to wrap PositionWindow().
+ * DbeExtensionInit wraps DestroyWindow().
+ */
+ PositionWindowProcPtr PositionWindow;
+ DestroyWindowProcPtr DestroyWindow;
+
+ /* Per-screen DIX routines */
+ Bool (*SetupBackgroundPainter)(
+ WindowPtr /*pWin*/,
+ GCPtr /*pGC*/
+);
+ DbeWindowPrivPtr (*AllocWinPriv)(
+ ScreenPtr /*pScreen*/
+);
+ int (*AllocWinPrivPrivIndex)(
+ void
+);
+ Bool (*AllocWinPrivPriv)(
+ ScreenPtr /*pScreen*/,
+ int /*index*/,
+ unsigned /*amount*/
+);
+
+ /* Per-screen DDX routines */
+ Bool (*GetVisualInfo)(
+ ScreenPtr /*pScreen*/,
+ XdbeScreenVisualInfo * /*pVisInfo*/
+);
+ int (*AllocBackBufferName)(
+ WindowPtr /*pWin*/,
+ XID /*bufId*/,
+ int /*swapAction*/
+);
+ int (*SwapBuffers)(
+ ClientPtr /*client*/,
+ int * /*pNumWindows*/,
+ DbeSwapInfoPtr /*swapInfo*/
+);
+ void (*BeginIdiom)(
+ ClientPtr /*client*/
+);
+ void (*EndIdiom)(
+ ClientPtr /*client*/
+);
+ void (*WinPrivDelete)(
+ DbeWindowPrivPtr /*pDbeWindowPriv*/,
+ XID /*bufId*/
+);
+ void (*ResetProc)(
+ ScreenPtr /*pScreen*/
+);
+ void (*ValidateBuffer)(
+ WindowPtr /*pWin*/,
+ XID /*bufId*/,
+ Bool /*dstbuffer*/
+);
+
+ /* Device-specific private information.
+ */
+ DevUnion *devPrivates;
+
+} DbeScreenPrivRec, *DbeScreenPrivPtr;
+
+#endif /* DBE_STRUCT_H */
diff --git a/nx-X11/programs/Xserver/dbe/midbe.c b/nx-X11/programs/Xserver/dbe/midbe.c
new file mode 100644
index 000000000..235693bb2
--- /dev/null
+++ b/nx-X11/programs/Xserver/dbe/midbe.c
@@ -0,0 +1,855 @@
+/* $Xorg: midbe.c,v 1.3 2000/08/17 19:48:16 cpqbld Exp $ */
+/******************************************************************************
+ *
+ * Copyright (c) 1994, 1995 Hewlett-Packard Company
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Hewlett-Packard
+ * Company shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the Hewlett-Packard Company.
+ *
+ * Machine-independent DBE code
+ *
+ *****************************************************************************/
+/* $XFree86: xc/programs/Xserver/dbe/midbe.c,v 3.4 2001/03/06 17:31:34 dawes Exp $ */
+
+
+/* INCLUDES */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "opaque.h"
+#include "dbestruct.h"
+#include "midbestr.h"
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "inputstr.h"
+
+#ifndef IN_MODULE
+#include <stdio.h>
+#else
+#include "xf86_ansic.h"
+#endif
+
+/* DEFINES */
+
+
+/* TYPEDEFS */
+
+
+/* GLOBALS */
+
+static int miDbePrivPrivGeneration = 0;
+static int miDbeWindowPrivPrivIndex = -1;
+RESTYPE dbeDrawableResType;
+RESTYPE dbeWindowPrivResType;
+int dbeScreenPrivIndex = -1;
+int dbeWindowPrivIndex = -1;
+
+
+
+/******************************************************************************
+ *
+ * DBE MI Procedure: miDbeGetVisualInfo
+ *
+ * Description:
+ *
+ * This is the MI function for the DbeGetVisualInfo request. This function
+ * is called through pDbeScreenPriv->GetVisualInfo. This function is also
+ * called for the DbeAllocateBackBufferName request at the extension level;
+ * it is called by ProcDbeAllocateBackBufferName() in dbe.c.
+ *
+ * If memory allocation fails or we can not get the visual info, this
+ * function returns FALSE. Otherwise, it returns TRUE for success.
+ *
+ *****************************************************************************/
+
+static Bool
+miDbeGetVisualInfo(pScreen, pScrVisInfo)
+ ScreenPtr pScreen;
+ XdbeScreenVisualInfo *pScrVisInfo;
+{
+ register int i, j, k;
+ register int count;
+ DepthPtr pDepth;
+ XdbeVisualInfo *visInfo;
+
+
+ /* Determine number of visuals for this screen. */
+ for (i = 0, count = 0; i < pScreen->numDepths; i++)
+ {
+ count += pScreen->allowedDepths[i].numVids;
+ }
+
+ /* Allocate an array of XdbeVisualInfo items. */
+ if (!(visInfo = (XdbeVisualInfo *)xalloc(count * sizeof(XdbeVisualInfo))))
+ {
+ return(FALSE); /* memory alloc failure */
+ }
+
+ for (i = 0, k = 0; i < pScreen->numDepths; i++)
+ {
+ /* For each depth of this screen, get visual information. */
+
+ pDepth = &pScreen->allowedDepths[i];
+
+ for (j = 0; j < pDepth->numVids; j++)
+ {
+ /* For each visual for this depth of this screen, get visual ID
+ * and visual depth. Since this is MI code, we will always return
+ * the same performance level for all visuals (0). A higher
+ * performance level value indicates higher performance.
+ */
+ visInfo[k].visual = pDepth->vids[j];
+ visInfo[k].depth = pDepth->depth;
+ visInfo[k].perflevel = 0;
+ k++;
+ }
+ }
+
+ /* Record the number of visuals and point visual_depth to
+ * the array of visual info.
+ */
+ pScrVisInfo->count = count;
+ pScrVisInfo->visinfo = visInfo;
+
+ return(TRUE); /* success */
+
+} /* miDbeGetVisualInfo() */
+
+
+/******************************************************************************
+ *
+ * DBE MI Procedure: miAllocBackBufferName
+ *
+ * Description:
+ *
+ * This is the MI function for the DbeAllocateBackBufferName request.
+ *
+ *****************************************************************************/
+
+static int
+miDbeAllocBackBufferName(pWin, bufId, swapAction)
+ WindowPtr pWin;
+ XID bufId;
+ int swapAction;
+{
+ ScreenPtr pScreen;
+ DbeWindowPrivPtr pDbeWindowPriv;
+ MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
+ DbeScreenPrivPtr pDbeScreenPriv;
+ GCPtr pGC;
+ xRectangle clearRect;
+
+
+ pScreen = pWin->drawable.pScreen;
+ pDbeWindowPriv = DBE_WINDOW_PRIV(pWin);
+
+ if (pDbeWindowPriv->nBufferIDs == 0)
+ {
+ /* There is no buffer associated with the window.
+ * We have to create the window priv priv. Remember, the window
+ * priv was created at the DIX level, so all we need to do is
+ * create the priv priv and attach it to the priv.
+ */
+
+ pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+
+ /* Setup the window priv priv. */
+ pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
+ pDbeWindowPrivPriv->pDbeWindowPriv = pDbeWindowPriv;
+
+ /* Get a front pixmap. */
+ if (!(pDbeWindowPrivPriv->pFrontBuffer =
+ (*pScreen->CreatePixmap)(pScreen, pDbeWindowPriv->width,
+ pDbeWindowPriv->height,
+ pWin->drawable.depth)))
+ {
+ return(BadAlloc);
+ }
+
+ /* Get a back pixmap. */
+ if (!(pDbeWindowPrivPriv->pBackBuffer =
+ (*pScreen->CreatePixmap)(pScreen, pDbeWindowPriv->width,
+ pDbeWindowPriv->height,
+ pWin->drawable.depth)))
+ {
+ (*pScreen->DestroyPixmap)(pDbeWindowPrivPriv->pFrontBuffer);
+ return(BadAlloc);
+ }
+
+
+ /* Make the back pixmap a DBE drawable resource. */
+ if (!AddResource(bufId, dbeDrawableResType,
+ (pointer)pDbeWindowPrivPriv->pBackBuffer))
+ {
+ /* free the buffer and the drawable resource */
+ FreeResource(bufId, RT_NONE);
+ return(BadAlloc);
+ }
+
+
+ /* Attach the priv priv to the priv. */
+ pDbeWindowPriv->devPrivates[miDbeWindowPrivPrivIndex].ptr =
+ (pointer)pDbeWindowPrivPriv;
+
+
+ /* Clear the back buffer. */
+ pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
+ if ((*pDbeScreenPriv->SetupBackgroundPainter)(pWin, pGC))
+ {
+ ValidateGC((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer, pGC);
+ clearRect.x = clearRect.y = 0;
+ clearRect.width = pDbeWindowPrivPriv->pBackBuffer->drawable.width;
+ clearRect.height = pDbeWindowPrivPriv->pBackBuffer->drawable.height;
+ (*pGC->ops->PolyFillRect)(
+ (DrawablePtr)pDbeWindowPrivPriv->pBackBuffer, pGC, 1,
+ &clearRect);
+ }
+ FreeScratchGC(pGC);
+
+ } /* if no buffer associated with the window */
+
+ else
+ {
+ /* A buffer is already associated with the window.
+ * Place the new buffer ID information at the head of the ID list.
+ */
+
+ /* Associate the new ID with an existing pixmap. */
+ pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
+ if (!AddResource(bufId, dbeDrawableResType,
+ (pointer)pDbeWindowPrivPriv->pBackBuffer))
+ {
+ return(BadAlloc);
+ }
+
+ }
+
+ return(Success);
+
+} /* miDbeAllocBackBufferName() */
+
+
+/******************************************************************************
+ *
+ * DBE MI Procedure: miDbeAliasBuffers
+ *
+ * Description:
+ *
+ * This function associates all XIDs of a buffer with the back pixmap
+ * stored in the window priv.
+ *
+ *****************************************************************************/
+
+static void
+miDbeAliasBuffers(pDbeWindowPriv)
+ DbeWindowPrivPtr pDbeWindowPriv;
+{
+ int i;
+ MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv =
+ MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
+
+ for (i = 0; i < pDbeWindowPriv->nBufferIDs; i++)
+ {
+ ChangeResourceValue(pDbeWindowPriv->IDs[i], dbeDrawableResType,
+ (pointer)pDbeWindowPrivPriv->pBackBuffer);
+ }
+
+} /* miDbeAliasBuffers() */
+
+
+/******************************************************************************
+ *
+ * DBE MI Procedure: miDbeSwapBuffers
+ *
+ * Description:
+ *
+ * This is the MI function for the DbeSwapBuffers request.
+ *
+ *****************************************************************************/
+
+static int
+miDbeSwapBuffers(client, pNumWindows, swapInfo)
+ ClientPtr client;
+ int *pNumWindows;
+ DbeSwapInfoPtr swapInfo;
+{
+ DbeScreenPrivPtr pDbeScreenPriv;
+ GCPtr pGC;
+ WindowPtr pWin;
+ MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
+ PixmapPtr pTmpBuffer;
+ xRectangle clearRect;
+
+
+ pWin = swapInfo[0].pWindow;
+ pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(pWin);
+ pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV_FROM_WINDOW(pWin);
+ pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
+
+ /*
+ **********************************************************************
+ ** Setup before swap.
+ **********************************************************************
+ */
+
+ switch(swapInfo[0].swapAction)
+ {
+ case XdbeUndefined:
+ break;
+
+ case XdbeBackground:
+ break;
+
+ case XdbeUntouched:
+ ValidateGC((DrawablePtr)pDbeWindowPrivPriv->pFrontBuffer, pGC);
+ (*pGC->ops->CopyArea)((DrawablePtr)pWin,
+ (DrawablePtr)pDbeWindowPrivPriv->pFrontBuffer,
+ pGC, 0, 0, pWin->drawable.width,
+ pWin->drawable.height, 0, 0);
+ break;
+
+ case XdbeCopied:
+ break;
+
+ }
+
+ /*
+ **********************************************************************
+ ** Swap.
+ **********************************************************************
+ */
+
+ ValidateGC((DrawablePtr)pWin, pGC);
+ (*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer,
+ (DrawablePtr)pWin, pGC, 0, 0,
+ pWin->drawable.width, pWin->drawable.height,
+ 0, 0);
+
+ /*
+ **********************************************************************
+ ** Tasks after swap.
+ **********************************************************************
+ */
+
+ switch(swapInfo[0].swapAction)
+ {
+ case XdbeUndefined:
+ break;
+
+ case XdbeBackground:
+ if ((*pDbeScreenPriv->SetupBackgroundPainter)(pWin, pGC))
+ {
+ ValidateGC((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer, pGC);
+ clearRect.x = 0;
+ clearRect.y = 0;
+ clearRect.width =
+ pDbeWindowPrivPriv->pBackBuffer->drawable.width;
+ clearRect.height =
+ pDbeWindowPrivPriv->pBackBuffer->drawable.height;
+ (*pGC->ops->PolyFillRect)(
+ (DrawablePtr)pDbeWindowPrivPriv->pBackBuffer,
+ pGC, 1, &clearRect);
+ }
+ break;
+
+ case XdbeUntouched:
+ /* Swap pixmap pointers. */
+ pTmpBuffer = pDbeWindowPrivPriv->pBackBuffer;
+ pDbeWindowPrivPriv->pBackBuffer =
+ pDbeWindowPrivPriv->pFrontBuffer;
+ pDbeWindowPrivPriv->pFrontBuffer = pTmpBuffer;
+
+ miDbeAliasBuffers(pDbeWindowPrivPriv->pDbeWindowPriv);
+
+ break;
+
+ case XdbeCopied:
+ break;
+
+ }
+
+ /* Remove the swapped window from the swap information array and decrement
+ * pNumWindows to indicate to the DIX level how many windows were actually
+ * swapped.
+ */
+
+ if (*pNumWindows > 1)
+ {
+ /* We were told to swap more than one window, but we only swapped the
+ * first one. Remove the first window in the list by moving the last
+ * window to the beginning.
+ */
+ swapInfo[0].pWindow = swapInfo[*pNumWindows - 1].pWindow;
+ swapInfo[0].swapAction = swapInfo[*pNumWindows - 1].swapAction;
+
+ /* Clear the last window information just to be safe. */
+ swapInfo[*pNumWindows - 1].pWindow = (WindowPtr)NULL;
+ swapInfo[*pNumWindows - 1].swapAction = 0;
+ }
+ else
+ {
+ /* Clear the window information just to be safe. */
+ swapInfo[0].pWindow = (WindowPtr)NULL;
+ swapInfo[0].swapAction = 0;
+ }
+
+ (*pNumWindows)--;
+
+ FreeScratchGC(pGC);
+
+ return(Success);
+
+} /* miSwapBuffers() */
+
+
+/******************************************************************************
+ *
+ * DBE MI Procedure: miDbeWinPrivDelete
+ *
+ * Description:
+ *
+ * This is the MI function for deleting the dbeWindowPrivResType resource.
+ * This function is invoked indirectly by calling FreeResource() to free
+ * the resources associated with a DBE buffer ID. There are 5 ways that
+ * miDbeWinPrivDelete() can be called by FreeResource(). They are:
+ *
+ * - A DBE window is destroyed, in which case the DbeDestroyWindow()
+ * wrapper is invoked. The wrapper calls FreeResource() for all DBE
+ * buffer IDs.
+ *
+ * - miDbeAllocBackBufferName() calls FreeResource() to clean up resources
+ * after a buffer allocation failure.
+ *
+ * - The PositionWindow wrapper, miDbePositionWindow(), calls
+ * FreeResource() when it fails to create buffers of the new size.
+ * FreeResource() is called for all DBE buffer IDs.
+ *
+ * - FreeClientResources() calls FreeResource() when a client dies or the
+ * the server resets.
+ *
+ * When FreeResource() is called for a DBE buffer ID, the delete function
+ * for the only other type of DBE resource, dbeDrawableResType, is also
+ * invoked. This delete function (DbeDrawableDelete) is a NOOP to make
+ * resource deletion easier. It is not guaranteed which delete function is
+ * called first. Hence, we will let miDbeWinPrivDelete() free all DBE
+ * resources.
+ *
+ * This function deletes/frees the following stuff associated with
+ * the window private:
+ *
+ * - the ID node in the ID list representing the passed in ID.
+ *
+ * In addition, pDbeWindowPriv->nBufferIDs is decremented.
+ *
+ * If this function is called for the last/only buffer ID for a window,
+ * these are additionally deleted/freed:
+ *
+ * - the front and back pixmaps
+ * - the window priv itself
+ *
+ *****************************************************************************/
+
+static void
+miDbeWinPrivDelete(pDbeWindowPriv, bufId)
+ DbeWindowPrivPtr pDbeWindowPriv;
+ XID bufId;
+{
+ MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
+
+
+ if (pDbeWindowPriv->nBufferIDs != 0)
+ {
+ /* We still have at least one more buffer ID associated with this
+ * window.
+ */
+ return;
+ }
+
+
+ /* We have no more buffer IDs associated with this window. We need to
+ * free some stuff.
+ */
+
+ pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
+
+ /* Destroy the front and back pixmaps. */
+ if (pDbeWindowPrivPriv->pFrontBuffer)
+ {
+ (*pDbeWindowPriv->pWindow->drawable.pScreen->DestroyPixmap)(
+ pDbeWindowPrivPriv->pFrontBuffer);
+ }
+ if (pDbeWindowPrivPriv->pBackBuffer)
+ {
+ (*pDbeWindowPriv->pWindow->drawable.pScreen->DestroyPixmap)(
+ pDbeWindowPrivPriv->pBackBuffer);
+ }
+
+} /* miDbeWinPrivDelete() */
+
+
+/******************************************************************************
+ *
+ * DBE MI Procedure: miDbePositionWindow
+ *
+ * Description:
+ *
+ * This function was cloned from miMbxPositionWindow() in mimultibuf.c.
+ * This function resizes the buffer when the window is resized.
+ *
+ *****************************************************************************/
+
+static Bool
+miDbePositionWindow(pWin, x, y)
+ WindowPtr pWin;
+ int x;
+ int y;
+{
+ ScreenPtr pScreen;
+ DbeScreenPrivPtr pDbeScreenPriv;
+ DbeWindowPrivPtr pDbeWindowPriv;
+ int width, height;
+ int dx, dy, dw, dh;
+ int sourcex, sourcey;
+ int destx, desty;
+ int savewidth, saveheight;
+ PixmapPtr pFrontBuffer;
+ PixmapPtr pBackBuffer;
+ Bool clear;
+ GCPtr pGC;
+ xRectangle clearRect;
+ Bool ret;
+
+
+ /*
+ **************************************************************************
+ ** 1. Unwrap the member routine.
+ **************************************************************************
+ */
+
+ pScreen = pWin->drawable.pScreen;
+ pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+ pScreen->PositionWindow = pDbeScreenPriv->PositionWindow;
+
+ /*
+ **************************************************************************
+ ** 2. Do any work necessary before the member routine is called.
+ **
+ ** In this case we do not need to do anything.
+ **************************************************************************
+ */
+
+ /*
+ **************************************************************************
+ ** 3. Call the member routine, saving its result if necessary.
+ **************************************************************************
+ */
+
+ ret = (*pScreen->PositionWindow)(pWin, x, y);
+
+ /*
+ **************************************************************************
+ ** 4. Rewrap the member routine, restoring the wrapper value first in case
+ ** the wrapper (or something that it wrapped) change this value.
+ **************************************************************************
+ */
+
+ pDbeScreenPriv->PositionWindow = pScreen->PositionWindow;
+ pScreen->PositionWindow = miDbePositionWindow;
+
+ /*
+ **************************************************************************
+ ** 5. Do any work necessary after the member routine has been called.
+ **************************************************************************
+ */
+
+ if (!(pDbeWindowPriv = DBE_WINDOW_PRIV(pWin)))
+ {
+ return(ret);
+ }
+
+ if (pDbeWindowPriv->width == pWin->drawable.width &&
+ pDbeWindowPriv->height == pWin->drawable.height)
+ {
+ return(ret);
+ }
+
+ width = pWin->drawable.width;
+ height = pWin->drawable.height;
+
+ dx = pWin->drawable.x - pDbeWindowPriv->x;
+ dy = pWin->drawable.y - pDbeWindowPriv->y;
+ dw = width - pDbeWindowPriv->width;
+ dh = height - pDbeWindowPriv->height;
+
+ GravityTranslate (0, 0, -dx, -dy, dw, dh, pWin->bitGravity, &destx, &desty);
+
+ clear = ((pDbeWindowPriv->width < (unsigned short)width ) ||
+ (pDbeWindowPriv->height < (unsigned short)height) ||
+ (pWin->bitGravity == ForgetGravity));
+
+ sourcex = 0;
+ sourcey = 0;
+ savewidth = pDbeWindowPriv->width;
+ saveheight = pDbeWindowPriv->height;
+
+ /* Clip rectangle to source and destination. */
+ if (destx < 0)
+ {
+ savewidth += destx;
+ sourcex -= destx;
+ destx = 0;
+ }
+
+ if (destx + savewidth > width)
+ {
+ savewidth = width - destx;
+ }
+
+ if (desty < 0)
+ {
+ saveheight += desty;
+ sourcey -= desty;
+ desty = 0;
+ }
+
+ if (desty + saveheight > height)
+ {
+ saveheight = height - desty;
+ }
+
+ pDbeWindowPriv->width = width;
+ pDbeWindowPriv->height = height;
+ pDbeWindowPriv->x = pWin->drawable.x;
+ pDbeWindowPriv->y = pWin->drawable.y;
+
+ pGC = GetScratchGC (pWin->drawable.depth, pScreen);
+
+ if (clear)
+ {
+ if ((*pDbeScreenPriv->SetupBackgroundPainter)(pWin, pGC))
+ {
+ clearRect.x = 0;
+ clearRect.y = 0;
+ clearRect.width = width;
+ clearRect.height = height;
+ }
+ else
+ {
+ clear = FALSE;
+ }
+ }
+
+ /* Create DBE buffer pixmaps equal to size of resized window. */
+ pFrontBuffer = (*pScreen->CreatePixmap)(pScreen, width, height,
+ pWin->drawable.depth);
+
+ pBackBuffer = (*pScreen->CreatePixmap)(pScreen, width, height,
+ pWin->drawable.depth);
+
+ if (!pFrontBuffer || !pBackBuffer)
+ {
+ /* We failed at creating 1 or 2 of the pixmaps. */
+
+ if (pFrontBuffer)
+ {
+ (*pScreen->DestroyPixmap)(pFrontBuffer);
+ }
+
+ if (pBackBuffer)
+ {
+ (*pScreen->DestroyPixmap)(pBackBuffer);
+ }
+
+ /* Destroy all buffers for this window. */
+ while (pDbeWindowPriv)
+ {
+ /* DbeWindowPrivDelete() will free the window private if there no
+ * more buffer IDs associated with this window.
+ */
+ FreeResource(pDbeWindowPriv->IDs[0], RT_NONE);
+ pDbeWindowPriv = DBE_WINDOW_PRIV(pWin);
+ }
+
+ FreeScratchGC(pGC);
+ return(FALSE);
+ }
+
+ else
+ {
+ /* Clear out the new DBE buffer pixmaps. */
+
+ MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
+
+
+ pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
+ ValidateGC((DrawablePtr)pFrontBuffer, pGC);
+
+ /* I suppose this could avoid quite a bit of work if
+ * it computed the minimal area required.
+ */
+ if (clear)
+ {
+ (*pGC->ops->PolyFillRect)((DrawablePtr)pFrontBuffer, pGC, 1,
+ &clearRect);
+ (*pGC->ops->PolyFillRect)((DrawablePtr)pBackBuffer , pGC, 1,
+ &clearRect);
+ }
+
+ /* Copy the contents of the old DBE pixmaps to the new pixmaps. */
+ if (pWin->bitGravity != ForgetGravity)
+ {
+ (*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pFrontBuffer,
+ (DrawablePtr)pFrontBuffer, pGC, sourcex,
+ sourcey, savewidth, saveheight, destx, desty);
+ (*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer,
+ (DrawablePtr)pBackBuffer, pGC, sourcex,
+ sourcey, savewidth, saveheight, destx, desty);
+ }
+
+ /* Destroy the old pixmaps, and point the DBE window priv to the new
+ * pixmaps.
+ */
+
+ (*pScreen->DestroyPixmap)(pDbeWindowPrivPriv->pFrontBuffer);
+ (*pScreen->DestroyPixmap)(pDbeWindowPrivPriv->pBackBuffer);
+
+ pDbeWindowPrivPriv->pFrontBuffer = pFrontBuffer;
+ pDbeWindowPrivPriv->pBackBuffer = pBackBuffer;
+
+ /* Make sure all XID are associated with the new back pixmap. */
+ miDbeAliasBuffers(pDbeWindowPriv);
+
+ FreeScratchGC(pGC);
+ }
+
+ return(ret);
+
+} /* miDbePositionWindow() */
+
+
+/******************************************************************************
+ *
+ * DBE MI Procedure: miDbeResetProc
+ *
+ * Description:
+ *
+ * This function is called from DbeResetProc(), which is called at the end
+ * of every server generation. This function peforms any MI-specific
+ * shutdown tasks.
+ *
+ *****************************************************************************/
+
+static void
+miDbeResetProc(pScreen)
+ ScreenPtr pScreen;
+{
+ DbeScreenPrivPtr pDbeScreenPriv;
+
+
+ pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+
+ /* Unwrap wrappers */
+ pScreen->PositionWindow = pDbeScreenPriv->PositionWindow;
+
+} /* miDbeResetProc() */
+
+
+/******************************************************************************
+ *
+ * DBE MI Procedure: miDbeInit
+ *
+ * Description:
+ *
+ * This is the MI initialization function called by DbeExtensionInit().
+ *
+ *****************************************************************************/
+
+Bool
+miDbeInit(pScreen, pDbeScreenPriv)
+ ScreenPtr pScreen;
+ DbeScreenPrivPtr pDbeScreenPriv;
+{
+ /* Copy resource types created by DIX */
+ dbeDrawableResType = pDbeScreenPriv->dbeDrawableResType;
+ dbeWindowPrivResType = pDbeScreenPriv->dbeWindowPrivResType;
+
+ /* Copy private indices created by DIX */
+ dbeScreenPrivIndex = pDbeScreenPriv->dbeScreenPrivIndex;
+ dbeWindowPrivIndex = pDbeScreenPriv->dbeWindowPrivIndex;
+
+ /* Reset the window priv privs if generations do not match. */
+ if (miDbePrivPrivGeneration != serverGeneration)
+ {
+ /*
+ **********************************************************************
+ ** Allocate the window priv priv.
+ **********************************************************************
+ */
+
+ miDbeWindowPrivPrivIndex = (*pDbeScreenPriv->AllocWinPrivPrivIndex)();
+
+ /* Make sure we only do this code once. */
+ miDbePrivPrivGeneration = serverGeneration;
+
+ } /* if -- Reset priv privs. */
+
+ if (!(*pDbeScreenPriv->AllocWinPrivPriv)(pScreen,
+ miDbeWindowPrivPrivIndex, sizeof(MiDbeWindowPrivPrivRec)))
+ {
+ return(FALSE);
+ }
+
+ /* Wrap functions. */
+ pDbeScreenPriv->PositionWindow = pScreen->PositionWindow;
+ pScreen->PositionWindow = miDbePositionWindow;
+
+ /* Initialize the per-screen DBE function pointers. */
+ pDbeScreenPriv->GetVisualInfo = miDbeGetVisualInfo;
+ pDbeScreenPriv->AllocBackBufferName = miDbeAllocBackBufferName;
+ pDbeScreenPriv->SwapBuffers = miDbeSwapBuffers;
+ pDbeScreenPriv->BeginIdiom = 0;
+ pDbeScreenPriv->EndIdiom = 0;
+ pDbeScreenPriv->ResetProc = miDbeResetProc;
+ pDbeScreenPriv->WinPrivDelete = miDbeWinPrivDelete;
+
+ /* The mi implementation doesn't need buffer validation. */
+ pDbeScreenPriv->ValidateBuffer = (void (*)())NoopDDA;
+
+ return(TRUE);
+
+} /* miDbeInit() */
diff --git a/nx-X11/programs/Xserver/dbe/midbe.h b/nx-X11/programs/Xserver/dbe/midbe.h
new file mode 100644
index 000000000..1110578cd
--- /dev/null
+++ b/nx-X11/programs/Xserver/dbe/midbe.h
@@ -0,0 +1,51 @@
+/* $Xorg: midbe.h,v 1.3 2000/08/17 19:48:16 cpqbld Exp $ */
+/******************************************************************************
+ *
+ * Copyright (c) 1994, 1995 Hewlett-Packard Company
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Hewlett-Packard
+ * Company shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the Hewlett-Packard Company.
+ *
+ * Header file for users of machine-independent DBE code
+ *
+ *****************************************************************************/
+/* $XFree86$ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef MIDBE_H
+#define MIDBE_H
+
+/* EXTERNS */
+
+extern Bool miDbeInit(
+ ScreenPtr pScreen,
+ DbeScreenPrivPtr pDbeScreenPriv
+);
+
+#endif /* MIDBE_H */
+
diff --git a/nx-X11/programs/Xserver/dbe/midbestr.h b/nx-X11/programs/Xserver/dbe/midbestr.h
new file mode 100644
index 000000000..248b44857
--- /dev/null
+++ b/nx-X11/programs/Xserver/dbe/midbestr.h
@@ -0,0 +1,100 @@
+/* $Xorg: midbestr.h,v 1.3 2000/08/17 19:48:16 cpqbld Exp $ */
+/******************************************************************************
+ *
+ * Copyright (c) 1994, 1995 Hewlett-Packard Company
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Hewlett-Packard
+ * Company shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the Hewlett-Packard Company.
+ *
+ * Header file for users of machine-independent DBE code
+ *
+ *****************************************************************************/
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef MIDBE_STRUCT_H
+#define MIDBE_STRUCT_H
+
+
+/* DEFINES */
+
+#define MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv) \
+ (((miDbeWindowPrivPrivIndex < 0) || (!pDbeWindowPriv)) ? \
+ NULL : \
+ ((MiDbeWindowPrivPrivPtr) \
+ ((pDbeWindowPriv)->devPrivates[miDbeWindowPrivPrivIndex].ptr)))
+
+#define MI_DBE_WINDOW_PRIV_PRIV_FROM_WINDOW(pWin)\
+ MI_DBE_WINDOW_PRIV_PRIV(DBE_WINDOW_PRIV(pWin))
+
+#define MI_DBE_SCREEN_PRIV_PRIV(pDbeScreenPriv) \
+ (((miDbeScreenPrivPrivIndex < 0) || (!pDbeScreenPriv)) ? \
+ NULL : \
+ ((MiDbeScreenPrivPrivPtr) \
+ ((pDbeScreenPriv)->devPrivates[miDbeScreenPrivPrivIndex].ptr)))
+
+
+/* TYPEDEFS */
+
+typedef struct _MiDbeWindowPrivPrivRec
+{
+ /* Place machine-specific fields in here.
+ * Since this is mi code, we do not really have machine-specific fields.
+ */
+
+ /* Pointer to a drawable that contains the contents of the back buffer.
+ */
+ PixmapPtr pBackBuffer;
+
+ /* Pointer to a drawable that contains the contents of the front buffer.
+ * This pointer is only used for the XdbeUntouched swap action. For that
+ * swap action, we need to copy the front buffer (window) contents into
+ * this drawable, copy the contents of current back buffer drawable (the
+ * back buffer) into the window, swap the front and back drawable pointers,
+ * and then swap the drawable/resource associations in the resource
+ * database.
+ */
+ PixmapPtr pFrontBuffer;
+
+ /* Pointer back to our window private with which we are associated. */
+ DbeWindowPrivPtr pDbeWindowPriv;
+
+} MiDbeWindowPrivPrivRec, *MiDbeWindowPrivPrivPtr;
+
+typedef struct _MiDbeScreenPrivPrivRec
+{
+ /* Place machine-specific fields in here.
+ * Since this is mi code, we do not really have machine-specific fields.
+ */
+
+ /* Pointer back to our screen private with which we are associated. */
+ DbeScreenPrivPtr pDbeScreenPriv;
+
+} MiDbeScreenPrivPrivRec, *MiDbeScreenPrivPrivPtr;
+
+#endif /* MIDBE_STRUCT_H */
+
diff --git a/nx-X11/programs/Xserver/dbe/module/Imakefile b/nx-X11/programs/Xserver/dbe/module/Imakefile
new file mode 100644
index 000000000..a2a4c6144
--- /dev/null
+++ b/nx-X11/programs/Xserver/dbe/module/Imakefile
@@ -0,0 +1,34 @@
+XCOMM $XConsortium: Imakefile /main/2 1996/09/28 17:06:40 rws $
+
+XCOMM $XFree86: xc/programs/Xserver/dbe/module/Imakefile,v 1.1 2000/04/06 15:35:03 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#if DoLoadableServer
+ MSRCS = dbemodule.c
+ MOBJS = dbemodule.o
+#endif
+
+ SRCS = dbe.c midbe.c $(MSRCS)
+ OBJS = dbe.o midbe.o $(MOBJS)
+ INCLUDES = -I.. -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(EXTINCSRC) $(EXTRAINCLUDES)
+ LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln
+ DEFINES = $(EXT_DEFINES)
+
+LinkSourceFile(dbemodule.c,..)
+LinkSourceFile(midbe.c,..)
+LinkSourceFile(dbe.c,..)
+
+ModuleObjectRule()
+
+LibraryModuleTarget(dbe,$(OBJS))
+
+LintLibraryTarget(dbe,$(SRCS))
+NormalLintTarget($(SRCS))
+
+InstallLibraryModule(dbe,$(MODULEDIR),extensions)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(dbe,$(DRIVERSDKMODULEDIR),extensions)
diff --git a/nx-X11/programs/Xserver/dix/BuiltInAtoms b/nx-X11/programs/Xserver/dix/BuiltInAtoms
new file mode 100644
index 000000000..910c62706
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/BuiltInAtoms
@@ -0,0 +1,329 @@
+File: .../x11/server/dix/BuiltInAtoms
+
+This file is of a fixed format and is used to generate both the file
+include/XAtom.h and dix/initatoms.c. Neither of those files should be
+edited directly. Changing the atoms in this file, or even the order in
+which they occur, is equivalent to forcing a new (minor) version number
+on the server. Take care.
+
+The format of the file is that each built in atom starts in column 1
+with no text, other than spaces and tabs, on that line other than a
+mandatory trailing "@" at the end of the line. For each atom (Foo)
+below the defines will be of the form
+ #define XA_Foo <n>
+and the string value of the atom will be "Foo".
+
+The comment lines in this file are not guaranteed to be accurate. To see the
+current truth, look at the Xlib documentation as well as the protocol spec.
+
+Atoms occur in five distinct name spaces within the protocol. Any particular
+atom may or may not have some client interpretation within each of the name
+spaces. For each of the built in atoms, the intended semantics and the space
+within which it is defined is indicated.
+
+Those name spaces are
+ Property names
+ Property types
+ Selections
+ Font properties
+ Type of a ClientMessage event (none built into server)
+
+For the font properties mentioned here, see the spec for more information.
+
+ -- Selections --
+
+PRIMARY @
+ Selection.
+SECONDARY @
+ Selection.
+
+ -- Property types and names --
+
+ARC @
+ Property type:
+ x, y: INT16
+ width, height: CARD16,
+ angle1, angle2: INT16
+ATOM @
+ Property type:
+ atom: ATOM
+BITMAP @
+ Property type:
+ bitmap: PIXMAP
+ This is asserted to be of depth 1.
+CARDINAL @
+ Property type:
+ card: CARD32 or CARD16 or CARD8
+ the datum size is dependent on the property format
+COLORMAP @
+ Property type:
+ colormap: COLORMAP
+CURSOR @
+ Property type:
+ cursor: CURSOR
+CUT_BUFFER0 @
+CUT_BUFFER1 @
+CUT_BUFFER2 @
+CUT_BUFFER3 @
+CUT_BUFFER4 @
+CUT_BUFFER5 @
+CUT_BUFFER6 @
+CUT_BUFFER7 @
+ Property name: (type: STRING)
+ Used to implement cut buffer ring, in particular Andrew uses
+ this mechanism. Anyone else using this sort of IPC mechanism
+ should use these properties.
+
+ Data is normally fetched and stored out of CUT_BUFFER0; the
+ RotateProperties request is used to rotate these buffers.
+DRAWABLE @
+ Property type:
+ drawable: DRAWABLE
+FONT @
+ Property type:
+ font: FONT
+INTEGER @
+ Property type:
+ card: INT32 or INT16 or INT8
+ the datum size is dependent on the property format
+PIXMAP @
+ Property type:
+ pixmap: PIXMAP
+POINT @
+ Property type:
+ x, y: INT16
+RECTANGLE @
+ Property type:
+ x, y: INT16
+ width, height: CARD16
+RESOURCE_MANAGER @
+ Property name: (type: STRING)
+ Contents of the user's resource manager data base.
+RGB_COLOR_MAP @
+ Property type:
+ colormap: COLORMAP
+ red-max: CARD32
+ red-mult: CARD32
+ green-max: CARD32
+ green-mult: CARD32
+ blue-max: CARD32
+ blue-mult: CARD32
+ base-pixel: CARD32
+
+ The fields `red_max', `green_max', and `blue_max' give the maximum
+ red, green, and blue values, respectively. Each color
+ coefficient ranges from 0 to its max, inclusive. For example,
+ a common colormap allocation is 3/3/2: 3 planes for red, 3
+ planes for green, and 2 planes for blue. Such a colormap would
+ have red_max == 7, green_max = 7, and blue_max = 3. An alternate
+ allocation that uses only 216 colors is red_max = 5, green_max =
+ 5, and blue_max = 5.
+
+ The fields `red_mult', `green_mult', and `blue_mult' give the
+ scale factors used to compose a full pixel value. (See next
+ paragraph.) For a 3/3/2 allocation red_mult might be 32,
+ green_mult might be 4, and blue_mult might be 1. For a
+ 6-colors-each allocation, red_mult might be 36, green_mult might
+ be 6, and blue_mult might be 1.
+
+ The field `base_pixel' gives the base pixel value used to
+ compose a full pixel value. Normally base_pixel is obtained
+ from a call to XAllocColorPlanes(). Given integer red, green,
+ and blue coefficients in their appropriate ranges, one can
+ compute a corresponding pixel value with the expression:
+
+ r * red_mult + g * green_mult + b * blue_mult + base_pixel
+
+ For gray-scale colormaps, only the colormap, red_max, red_mult,
+ and base_pixel fields are defined; the other fields are
+ ignored. To compute a gray-scale pixel value, use:
+
+ gray * red_mult + base_pixel
+
+ This is provided to allow applications to share color maps.
+
+RGB_BEST_MAP @
+RGB_BLUE_MAP @
+RGB_DEFAULT_MAP @
+RGB_GRAY_MAP @
+RGB_GREEN_MAP @
+RGB_RED_MAP @
+ Property name: (type: RGB_COLOR_MAP)
+ The needs of most applications can be met with five colormaps.
+ Polite applications may need only a small RGB space, and can
+ use a portion of the default color map. Applications doing
+ high-quality RGB rendering will need an entire colormap,
+ filled with as large an RGB space as possible, e.g. 332. For
+ color separations, an application may need maximum device
+ resolution for each of red, green, and blue, even if this
+ requires three renderings with three colormaps.
+
+ Each of the above five names would be used for sharing color
+ maps.
+STRING @
+ Property type:
+ sequence of Bytes
+VISUALID @
+ Property type:
+ visual: VISUALID
+WINDOW @
+ Property type:
+ window: WINDOW
+WM_COMMAND @
+ Property name: (type: STRING)
+ Command line arguments used to invoke this application. The
+ arguments are delimited by null characters (ASCII 0).
+WM_HINTS @
+ Property type:
+ flags: CARD32
+ input: BOOL32
+ initial-state: CARD32
+ icon-pixmap: PIXMAP
+ icon-window: WINDOW
+ icon_mask: BITMAP
+ icon-x, icon-y: INT32
+ flags contains the following bits
+ 0x00000001 input hint
+ 0x00000002 state hint
+ 0x00000004 icon pixmap hint
+ 0x00000008 icon window hint
+ 0x00000010 icon position hint
+ values for initial-state
+ 0 unspecified -> application does not
+ care and WM should pick one.
+ 1 normal
+ 2 zoomed
+ 3 iconic
+ 4 inactive -> application believes
+ itself to be seldomly used. WM may wish to
+ place it on an inactive menu.
+ This type is potentially extensible. The order is critical;
+ append to the end only.
+ Property name: (type: WM_HINTS)
+ Additional hints set by the client for use by the window
+ manager.
+WM_CLIENT_MACHINE @
+ Property name: (type: STRING)
+ used to communicate with the window manager. The host name
+ of the machine the client is running on may be set here.
+WM_ICON_NAME @
+ Property name: (type: STRING)
+ what the application would like the label to be for
+ the iconic form of the window.
+WM_ICON_SIZE @
+ Property type:
+ minWidth, min-height: CARD32
+ maxWidth, max-height: CARD32
+ widthInc, height-inc: CARD32
+ Property name: (type: ICON_SIZE)
+ The window manager may set this property on the root window
+ to specify the icon sizes it allows.
+WM_NAME @
+ Property name: (type: STRING)
+ used to communicate with the window manager. This is
+ what the application would like the label for the window.
+WM_NORMAL_HINTS @
+ Property name: (type: SIZE_HINTS)
+ used to communicate with the window manager. This is size
+ hints for a window in its "normal" state.
+WM_SIZE_HINTS @
+ Property type:
+ flags: CARD32
+ x, y: INT32
+ width, height: CARD32
+ min-width, min-height: CARD32
+ max-width, max-height: CARD32
+ width-inc, height-inc: CARD32
+ min-aspect-x, min-aspect-y: CARD32
+ max-aspect-x, max-aspect-y: CARD32
+ flags contains the following bits
+ 0x00000001 user specified x and y
+ 0x00000002 user specified width and height
+ 0x00000004 program specified position
+ 0x00000008 program specified size
+ 0x00000010 program specified minimum size
+ 0x00000020 program specified maximum size
+ 0x00000040 program specified resize increment
+ 0x00000080 program specified aspect ratio
+ This type is potentially extensible. The order is critical;
+ append to the end only.
+WM_ZOOM_HINTS @
+ Property name: (type: SIZE_HINTS)
+ used to communicate with the window manager. This is size
+ hints for a window in its "zoomed" state.
+
+ -- Font properties --
+
+MIN_SPACE @
+ Font property: CARD32
+NORM_SPACE @
+ Font property: CARD32
+MAX_SPACE @
+ Font property: CARD32
+END_SPACE @
+ Font property: CARD32
+SUPERSCRIPT_X @
+ Font property: INT32
+SUPERSCRIPT_Y @
+ Font property: INT32
+SUBSCRIPT_X @
+ Font property: INT32
+SUBSCRIPT_Y @
+ Font property: INT32
+UNDERLINE_POSITION @
+ Font property: INT32
+UNDERLINE_THICKNESS @
+ Font property: CARD32
+STRIKEOUT_ASCENT @
+ Font property: INT32
+STRIKEOUT_DESCENT @
+ Font property: INT32
+ITALIC_ANGLE @
+ Font property: INT32
+X_HEIGHT @
+ Font property: INT32
+QUAD_WIDTH @
+ Font property: INT32
+WEIGHT @
+ Font property: CARD32
+POINT_SIZE @
+ Font property: CARD32
+RESOLUTION @
+ Font property: CARD32
+
+The following optional properties on fonts have values that are atoms. The
+atom print name is the useful information.
+
+COPYRIGHT @
+ of the font distribution
+NOTICE @
+ trademark/copyright of the character shapes
+FONT_NAME @
+ name of this particular instance of a font
+FAMILY_NAME @
+ name of the 'font family' to which it belongs
+FULL_NAME @
+ full text name of the font
+
+The following aren't in order but putting them at the end avoids encoding
+changes.
+
+CAP_HEIGHT @
+ Font property: CARD32
+
+
+WM_CLASS @
+ Property name: (type: STRING)
+ Used (possibly by some window managers; definitely by
+ session managers) to look up resources in the resource
+ data base on behalf of the client who set this property.
+ There are 2 elements:
+ {char *resource_name; char *resource_class;}
+ delimited by a null character (ascii 0)
+
+WM_TRANSIENT_FOR @
+ Property name: (type: WINDOW)
+ Used by transient top-level windows, such as dialog
+ boxes, to point to their logical "parents". The window
+ manager can then take down the dialog boxes when the
+ "parent" gets iconified, for instance.
diff --git a/nx-X11/programs/Xserver/dix/CHANGES b/nx-X11/programs/Xserver/dix/CHANGES
new file mode 100644
index 000000000..d8fb7c31a
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/CHANGES
@@ -0,0 +1,17 @@
+The following changes have been made to this directory since R3 (for
+a full description, see doc/Server/r4.tbl.ms):
+
+ o Windows restructured (memory reduction, devPrivates and speedups)
+ o GCs restructured (memory reduction, devPrivates and wrappers)
+ o Screens restructured (window ops merged in, devPrivates)
+ o Pixmaps restructured (drawable changes mostly)
+ o Cursors restructured (shares glyph bits now)
+ o Visuals restructured (screen index removed, fields rearranged)
+ o Devices restructured (input extension changes)
+ o Out of memory changes. Many interfaces now return OutOfMemory
+ status.
+ o Synchronous grab code rewritten. Should conform to our
+ understanding of the protocol now. Be careful when time
+ stamping events (don't allow time to run backwards).
+ o Resource types redesigned and rewritten.
+ o Internal fake color allocation routine for software cursors.
diff --git a/nx-X11/programs/Xserver/dix/Imakefile b/nx-X11/programs/Xserver/dix/Imakefile
new file mode 100644
index 000000000..529e5623e
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/Imakefile
@@ -0,0 +1,101 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:16 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/dix/Imakefile,v 3.17 2003/04/15 18:30:43 alanh Exp $
+
+#include <Server.tmpl>
+
+#if !BuildXprint || PrintOnlyServer
+XPSRC = xpstubs.c
+XPOBJ = xpstubs.o
+#endif
+
+#if !HasFfs
+FFS_SRC = ffs.c
+FFS_OBJ = ffs.o
+#endif
+
+SRCS = atom.c colormap.c cursor.c devices.c dispatch.c dixutils.c events.c \
+ extension.c gc.c globals.c glyphcurs.c grabs.c \
+ main.c property.c resource.c swaprep.c swapreq.c \
+ tables.c window.c initatoms.c dixfonts.c privates.c pixmap.c $(FFS_SRC)
+OBJS = atom.o colormap.o cursor.o devices.o dispatch.o dixutils.o events.o \
+ extension.o gc.o globals.o glyphcurs.o grabs.o \
+ main.o property.o resource.o swaprep.o swapreq.o \
+ tables.o window.o initatoms.o dixfonts.o privates.o pixmap.o $(FFS_OBJ)
+
+ INCLUDES = -I../include -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(EXTINCSRC) \
+ -I$(SERVERSRC)/Xext -I$(SERVERSRC)/lbx -I../Xprint
+ LINTLIBS = ../os/llib-los.ln
+
+/*
+ * The following configuration parameters may be set in the appropriate
+ * .macros files or site.def in the directory util/imake.includes/:
+ *
+ * DefaultFontPath COMPILEDDEFAULTFONTPATH
+ * DefaultRGBDatabase RGB_DB
+ *
+ * The sample util/imake.includes/Imake.tmpl will provide generic defaults.
+ * The values in site.h are simply a last line of defense and should not be
+ * changed.
+ */
+
+#ifdef DefaultFontPath
+DEFAULTFONTPATH = DefaultFontPath
+SITE_FONT_PATH = -DCOMPILEDDEFAULTFONTPATH=\"$(DEFAULTFONTPATH)\"
+#endif
+
+#ifdef DefaultRGBDatabase
+DEFAULTRGBDATABASE = DefaultRGBDatabase
+ SITE_RGB_DB = -DRGB_DB=\"$(DEFAULTRGBDATABASE)\"
+#endif
+
+#ifdef DefaultDisplayClass
+DEFAULTDISPLAYCLASS = DefaultDisplayClass
+ SITE_DISPLAY_CLASS = -DCOMPILEDDISPLAYCLASS=\"$(DEFAULTDISPLAYCLASS)\"
+#endif
+
+#ifdef XVendorString
+VENDORSTRING = XVendorString
+ VENDOR_STRING = -DVENDOR_STRING=\"$(VENDORSTRING)\"
+#endif
+
+#ifdef XVendorRelease
+VENDORRELEASE = XVendorRelease
+ VENDOR_RELEASE = -DVENDOR_RELEASE="$(VENDORRELEASE)"
+#endif
+
+#if HasKrb5
+ K5DEFS = Krb5Defines
+#endif
+
+#ifdef DarwinArchitecture
+#if DarwinQuartzSupport
+ QUARTZ_DEFINES = -DDARWIN_WITH_QUARTZ
+#endif
+#endif
+
+SITE_DEFINES = $(SITE_FONT_PATH) $(SITE_RGB_DB) $(SITE_DISPLAY_CLASS)
+
+VENDOR_DEFINES = $(VENDOR_STRING) $(VENDOR_RELEASE) $(QUARTZ_DEFINES)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(dix,$(OBJS))
+LintLibraryTarget(dix,$(SRCS) $(XPSRC))
+NormalLintTarget($(SRCS) $(XPSRC))
+
+SpecialCObjectRule(globals,$(ICONFIGFILES),$(SITE_DEFINES))
+SpecialCObjectRule(tables,$(ICONFIGFILES),$(K5DEFS))
+SpecialCObjectRule(dispatch,$(ICONFIGFILES),$(K5DEFS))
+SpecialCObjectRule(main,$(ICONFIGFILES),$(VENDOR_DEFINES))
+SpecialCObjectRule(pixmap,$(ICONFIGFILES),$(_NOOP_))
+SpecialCObjectRule(privates,$(ICONFIGFILES),$(_NOOP_))
+SpecialCObjectRule(window,$(ICONFIGFILES),$(QUARTZ_DEFINES))
+
+#if !BuildXprint || PrintOnlyServer
+NormalLibraryTarget(xpstubs,$(XPOBJ))
+#endif
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/dix/atom.c b/nx-X11/programs/Xserver/dix/atom.c
new file mode 100644
index 000000000..207174280
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/atom.c
@@ -0,0 +1,213 @@
+/* $XFree86: xc/programs/Xserver/dix/atom.c,v 3.3 2001/12/14 19:59:29 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* $Xorg: atom.c,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xatom.h>
+#include "misc.h"
+#include "resource.h"
+#include "dix.h"
+
+#define InitialTableSize 100
+
+typedef struct _Node {
+ struct _Node *left, *right;
+ Atom a;
+ unsigned int fingerPrint;
+ char *string;
+} NodeRec, *NodePtr;
+
+static Atom lastAtom = None;
+static NodePtr atomRoot = (NodePtr)NULL;
+static unsigned long tableLength;
+static NodePtr *nodeTable;
+
+void FreeAtom(NodePtr patom);
+
+Atom
+MakeAtom(char *string, unsigned len, Bool makeit)
+{
+ register NodePtr * np;
+ unsigned i;
+ int comp;
+ register unsigned int fp = 0;
+
+ np = &atomRoot;
+ for (i = 0; i < (len+1)/2; i++)
+ {
+ fp = fp * 27 + string[i];
+ fp = fp * 27 + string[len - 1 - i];
+ }
+ while (*np != (NodePtr) NULL)
+ {
+ if (fp < (*np)->fingerPrint)
+ np = &((*np)->left);
+ else if (fp > (*np)->fingerPrint)
+ np = &((*np)->right);
+ else
+ { /* now start testing the strings */
+ comp = strncmp(string, (*np)->string, (int)len);
+ if ((comp < 0) || ((comp == 0) && (len < strlen((*np)->string))))
+ np = &((*np)->left);
+ else if (comp > 0)
+ np = &((*np)->right);
+ else
+ return(*np)->a;
+ }
+ }
+ if (makeit)
+ {
+ register NodePtr nd;
+
+ nd = (NodePtr) xalloc(sizeof(NodeRec));
+ if (!nd)
+ return BAD_RESOURCE;
+ if (lastAtom < XA_LAST_PREDEFINED)
+ {
+ nd->string = string;
+ }
+ else
+ {
+ nd->string = (char *) xalloc(len + 1);
+ if (!nd->string) {
+ xfree(nd);
+ return BAD_RESOURCE;
+ }
+ strncpy(nd->string, string, (int)len);
+ nd->string[len] = 0;
+ }
+ if ((lastAtom + 1) >= tableLength) {
+ NodePtr *table;
+
+ table = (NodePtr *) xrealloc(nodeTable,
+ tableLength * (2 * sizeof(NodePtr)));
+ if (!table) {
+ if (nd->string != string)
+ xfree(nd->string);
+ xfree(nd);
+ return BAD_RESOURCE;
+ }
+ tableLength <<= 1;
+ nodeTable = table;
+ }
+ *np = nd;
+ nd->left = nd->right = (NodePtr) NULL;
+ nd->fingerPrint = fp;
+ nd->a = (++lastAtom);
+ *(nodeTable+lastAtom) = nd;
+ return nd->a;
+ }
+ else
+ return None;
+}
+
+Bool
+ValidAtom(Atom atom)
+{
+ return (atom != None) && (atom <= lastAtom);
+}
+
+char *
+NameForAtom(Atom atom)
+{
+ NodePtr node;
+ if (atom > lastAtom) return 0;
+ if ((node = nodeTable[atom]) == (NodePtr)NULL) return 0;
+ return node->string;
+}
+
+void
+AtomError()
+{
+ FatalError("initializing atoms");
+}
+
+void
+FreeAtom(NodePtr patom)
+{
+ if(patom->left)
+ FreeAtom(patom->left);
+ if(patom->right)
+ FreeAtom(patom->right);
+ if (patom->a > XA_LAST_PREDEFINED)
+ xfree(patom->string);
+ xfree(patom);
+}
+
+void
+FreeAllAtoms()
+{
+ if(atomRoot == (NodePtr)NULL)
+ return;
+ FreeAtom(atomRoot);
+ atomRoot = (NodePtr)NULL;
+ xfree(nodeTable);
+ nodeTable = (NodePtr *)NULL;
+ lastAtom = None;
+}
+
+void
+InitAtoms()
+{
+ FreeAllAtoms();
+ tableLength = InitialTableSize;
+ nodeTable = (NodePtr *)xalloc(InitialTableSize*sizeof(NodePtr));
+ if (!nodeTable)
+ AtomError();
+ nodeTable[None] = (NodePtr)NULL;
+ MakePredeclaredAtoms();
+ if (lastAtom != XA_LAST_PREDEFINED)
+ AtomError ();
+}
+
+
diff --git a/nx-X11/programs/Xserver/dix/buildatoms b/nx-X11/programs/Xserver/dix/buildatoms
new file mode 100644
index 000000000..dfbbca8a9
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/buildatoms
@@ -0,0 +1,43 @@
+#!/bin/sh
+hfile=../../../include/Xatom.h
+cfile=initatoms.c
+rm -f $hfile $cfile
+umask 222
+awk '
+BEGIN {
+ hfile = "'$hfile'";
+ cfile = "'$cfile'";
+ hformat = "#define XA_%s ((Atom) %d)\n";
+ printf("#ifndef XATOM_H\n") > hfile;
+ printf("#define XATOM_H 1\n\n") > hfile;
+ printf("/* THIS IS A GENERATED FILE\n") > hfile;
+ printf(" *\n") > hfile;
+ printf(" * Do not change! Changing this file implies a protocol change!\n") > hfile;
+ printf(" */\n\n") > hfile;
+
+ printf("/* THIS IS A GENERATED FILE\n") > cfile;
+ printf(" *\n") > cfile;
+ printf(" * Do not change! Changing this file implies a protocol change!\n") > cfile;
+ printf(" */\n\n") > cfile;
+ printf("#include \"X.h\"\n") > cfile;
+ printf("#include \"Xatom.h\"\n") > cfile;
+ printf("#include \"misc.h\"\n") > cfile;
+ printf("#include \"dix.h\"\n") > cfile;
+ printf("void MakePredeclaredAtoms()\n") > cfile;
+ printf("{\n") > cfile;
+
+ }
+
+NF == 2 && $2 == "@" {
+ printf(hformat, $1, ++atomno) > hfile ;
+ printf(" if (MakeAtom(\"%s\", %d, 1) != XA_%s) AtomError();\n", $1, length($1), $1) > cfile ;
+ }
+
+END {
+ printf("\n") > hfile;
+ printf(hformat, "LAST_PREDEFINED", atomno) > hfile ;
+ printf("#endif /* XATOM_H */\n") > hfile;
+ printf("}\n") > cfile ;
+ }
+' BuiltInAtoms
+exit 0
diff --git a/nx-X11/programs/Xserver/dix/colormap.c b/nx-X11/programs/Xserver/dix/colormap.c
new file mode 100644
index 000000000..210bc2731
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/colormap.c
@@ -0,0 +1,2793 @@
+/* $XdotOrg: xc/programs/Xserver/dix/colormap.c,v 1.11 2005/09/05 07:40:50 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/dix/colormap.c,v 3.11 2003/11/03 05:10:59 tsi Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* $Xorg: colormap.c,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dix.h"
+#include "colormapst.h"
+#include "os.h"
+#include "scrnintstr.h"
+#include "resource.h"
+#include "windowstr.h"
+#ifdef LBX
+#include "lbxserve.h"
+#endif
+
+extern XID clientErrorValue;
+extern int colormapPrivateCount;
+
+static Pixel FindBestPixel(
+ EntryPtr /*pentFirst*/,
+ int /*size*/,
+ xrgb * /*prgb*/,
+ int /*channel*/
+);
+
+static int AllComp(
+ EntryPtr /*pent*/,
+ xrgb * /*prgb*/
+);
+
+static int RedComp(
+ EntryPtr /*pent*/,
+ xrgb * /*prgb*/
+);
+
+static int GreenComp(
+ EntryPtr /*pent*/,
+ xrgb * /*prgb*/
+);
+
+static int BlueComp(
+ EntryPtr /*pent*/,
+ xrgb * /*prgb*/
+);
+
+static void FreePixels(
+ register ColormapPtr /*pmap*/,
+ register int /*client*/
+);
+
+static void CopyFree(
+ int /*channel*/,
+ int /*client*/,
+ ColormapPtr /*pmapSrc*/,
+ ColormapPtr /*pmapDst*/
+);
+
+static void FreeCell(
+ ColormapPtr /*pmap*/,
+ Pixel /*i*/,
+ int /*channel*/
+);
+
+static void UpdateColors(
+ ColormapPtr /*pmap*/
+);
+
+static int AllocDirect(
+ int /*client*/,
+ ColormapPtr /*pmap*/,
+ int /*c*/,
+ int /*r*/,
+ int /*g*/,
+ int /*b*/,
+ Bool /*contig*/,
+ Pixel * /*pixels*/,
+ Pixel * /*prmask*/,
+ Pixel * /*pgmask*/,
+ Pixel * /*pbmask*/
+);
+
+static int AllocPseudo(
+ int /*client*/,
+ ColormapPtr /*pmap*/,
+ int /*c*/,
+ int /*r*/,
+ Bool /*contig*/,
+ Pixel * /*pixels*/,
+ Pixel * /*pmask*/,
+ Pixel ** /*pppixFirst*/
+);
+
+static Bool AllocCP(
+ ColormapPtr /*pmap*/,
+ EntryPtr /*pentFirst*/,
+ int /*count*/,
+ int /*planes*/,
+ Bool /*contig*/,
+ Pixel * /*pixels*/,
+ Pixel * /*pMask*/
+);
+
+static Bool AllocShared(
+ ColormapPtr /*pmap*/,
+ Pixel * /*ppix*/,
+ int /*c*/,
+ int /*r*/,
+ int /*g*/,
+ int /*b*/,
+ Pixel /*rmask*/,
+ Pixel /*gmask*/,
+ Pixel /*bmask*/,
+ Pixel * /*ppixFirst*/
+);
+
+static int FreeCo(
+ ColormapPtr /*pmap*/,
+ int /*client*/,
+ int /*color*/,
+ int /*npixIn*/,
+ Pixel * /*ppixIn*/,
+ Pixel /*mask*/
+);
+
+static int TellNoMap(
+ WindowPtr /*pwin*/,
+ Colormap * /*pmid*/
+);
+
+static void FindColorInRootCmap (
+ ColormapPtr /* pmap */,
+ EntryPtr /* pentFirst */,
+ int /* size */,
+ xrgb* /* prgb */,
+ Pixel* /* pPixel */,
+ int /* channel */,
+ ColorCompareProcPtr /* comp */
+);
+
+#define NUMRED(vis) ((vis->redMask >> vis->offsetRed) + 1)
+#define NUMGREEN(vis) ((vis->greenMask >> vis->offsetGreen) + 1)
+#define NUMBLUE(vis) ((vis->blueMask >> vis->offsetBlue) + 1)
+#if COMPOSITE
+#define ALPHAMASK(vis) ((vis)->nplanes < 32 ? 0 : \
+ (CARD32) ~((vis)->redMask|(vis)->greenMask|(vis)->blueMask))
+#else
+#define ALPHAMASK(vis) 0
+#endif
+
+#define RGBMASK(vis) (vis->redMask | vis->greenMask | vis->blueMask | ALPHAMASK(vis))
+
+/* GetNextBitsOrBreak(bits, mask, base) --
+ * (Suggestion: First read the macro, then read this explanation.
+ *
+ * Either generate the next value to OR in to a pixel or break out of this
+ * while loop
+ *
+ * This macro is used when we're trying to generate all 2^n combinations of
+ * bits in mask. What we're doing here is counting in binary, except that
+ * the bits we use to count may not be contiguous. This macro will be
+ * called 2^n times, returning a different value in bits each time. Then
+ * it will cause us to break out of a surrounding loop. (It will always be
+ * called from within a while loop.)
+ * On call: mask is the value we want to find all the combinations for
+ * base has 1 bit set where the least significant bit of mask is set
+ *
+ * For example,if mask is 01010, base should be 0010 and we count like this:
+ * 00010 (see this isn't so hard),
+ * then we add base to bits and get 0100. (bits & ~mask) is (0100 & 0100) so
+ * we add that to bits getting (0100 + 0100) =
+ * 01000 for our next value.
+ * then we add 0010 to get
+ * 01010 and we're done (easy as 1, 2, 3)
+ */
+#define GetNextBitsOrBreak(bits, mask, base) \
+ if((bits) == (mask)) \
+ break; \
+ (bits) += (base); \
+ while((bits) & ~(mask)) \
+ (bits) += ((bits) & ~(mask));
+/* ID of server as client */
+#define SERVER_ID 0
+
+typedef struct _colorResource
+{
+ Colormap mid;
+ int client;
+} colorResource;
+
+/* Invariants:
+ * refcnt == 0 means entry is empty
+ * refcnt > 0 means entry is useable by many clients, so it can't be changed
+ * refcnt == AllocPrivate means entry owned by one client only
+ * fShared should only be set if refcnt == AllocPrivate, and only in red map
+ */
+
+
+/**
+ * Create and initialize the color map
+ *
+ * \param mid resource to use for this colormap
+ * \param alloc 1 iff all entries are allocated writable
+ */
+int
+CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
+ ColormapPtr *ppcmap, int alloc, int client)
+{
+ int class, size;
+ unsigned long sizebytes;
+ ColormapPtr pmap;
+ register EntryPtr pent;
+ int i;
+ register Pixel *ppix, **pptr;
+
+ class = pVisual->class;
+ if(!(class & DynamicClass) && (alloc != AllocNone) && (client != SERVER_ID))
+ return (BadMatch);
+
+ size = pVisual->ColormapEntries;
+ sizebytes = (size * sizeof(Entry)) +
+ (MAXCLIENTS * sizeof(Pixel *)) +
+ (MAXCLIENTS * sizeof(int));
+ if ((class | DynamicClass) == DirectColor)
+ sizebytes *= 3;
+ sizebytes += sizeof(ColormapRec);
+ pmap = (ColormapPtr) xalloc(sizebytes);
+ if (!pmap)
+ return (BadAlloc);
+ pmap->red = (EntryPtr)((char *)pmap + sizeof(ColormapRec));
+ sizebytes = size * sizeof(Entry);
+ pmap->clientPixelsRed = (Pixel **)((char *)pmap->red + sizebytes);
+ pmap->numPixelsRed = (int *)((char *)pmap->clientPixelsRed +
+ (MAXCLIENTS * sizeof(Pixel *)));
+ pmap->mid = mid;
+ pmap->flags = 0; /* start out with all flags clear */
+ if(mid == pScreen->defColormap)
+ pmap->flags |= IsDefault;
+ pmap->pScreen = pScreen;
+ pmap->pVisual = pVisual;
+ pmap->class = class;
+ if ((class | DynamicClass) == DirectColor)
+ size = NUMRED(pVisual);
+ pmap->freeRed = size;
+ bzero ((char *) pmap->red, (int)sizebytes);
+ bzero((char *) pmap->numPixelsRed, MAXCLIENTS * sizeof(int));
+ for (pptr = &pmap->clientPixelsRed[MAXCLIENTS]; --pptr >= pmap->clientPixelsRed; )
+ *pptr = (Pixel *)NULL;
+ if (alloc == AllocAll)
+ {
+ if (class & DynamicClass)
+ pmap->flags |= AllAllocated;
+ for (pent = &pmap->red[size - 1]; pent >= pmap->red; pent--)
+ pent->refcnt = AllocPrivate;
+ pmap->freeRed = 0;
+ ppix = (Pixel *)xalloc(size * sizeof(Pixel));
+ if (!ppix)
+ {
+ xfree(pmap);
+ return (BadAlloc);
+ }
+ pmap->clientPixelsRed[client] = ppix;
+ for(i = 0; i < size; i++)
+ ppix[i] = i;
+ pmap->numPixelsRed[client] = size;
+ }
+
+ if ((class | DynamicClass) == DirectColor)
+ {
+ pmap->freeGreen = NUMGREEN(pVisual);
+ pmap->green = (EntryPtr)((char *)pmap->numPixelsRed +
+ (MAXCLIENTS * sizeof(int)));
+ pmap->clientPixelsGreen = (Pixel **)((char *)pmap->green + sizebytes);
+ pmap->numPixelsGreen = (int *)((char *)pmap->clientPixelsGreen +
+ (MAXCLIENTS * sizeof(Pixel *)));
+ pmap->freeBlue = NUMBLUE(pVisual);
+ pmap->blue = (EntryPtr)((char *)pmap->numPixelsGreen +
+ (MAXCLIENTS * sizeof(int)));
+ pmap->clientPixelsBlue = (Pixel **)((char *)pmap->blue + sizebytes);
+ pmap->numPixelsBlue = (int *)((char *)pmap->clientPixelsBlue +
+ (MAXCLIENTS * sizeof(Pixel *)));
+
+ bzero ((char *) pmap->green, (int)sizebytes);
+ bzero ((char *) pmap->blue, (int)sizebytes);
+
+ memmove((char *) pmap->clientPixelsGreen,
+ (char *) pmap->clientPixelsRed,
+ MAXCLIENTS * sizeof(Pixel *));
+ memmove((char *) pmap->clientPixelsBlue,
+ (char *) pmap->clientPixelsRed,
+ MAXCLIENTS * sizeof(Pixel *));
+ bzero((char *) pmap->numPixelsGreen, MAXCLIENTS * sizeof(int));
+ bzero((char *) pmap->numPixelsBlue, MAXCLIENTS * sizeof(int));
+
+ /* If every cell is allocated, mark its refcnt */
+ if (alloc == AllocAll)
+ {
+ size = pmap->freeGreen;
+ for(pent = &pmap->green[size-1]; pent >= pmap->green; pent--)
+ pent->refcnt = AllocPrivate;
+ pmap->freeGreen = 0;
+ ppix = (Pixel *) xalloc(size * sizeof(Pixel));
+ if (!ppix)
+ {
+ xfree(pmap->clientPixelsRed[client]);
+ xfree(pmap);
+ return(BadAlloc);
+ }
+ pmap->clientPixelsGreen[client] = ppix;
+ for(i = 0; i < size; i++)
+ ppix[i] = i;
+ pmap->numPixelsGreen[client] = size;
+
+ size = pmap->freeBlue;
+ for(pent = &pmap->blue[size-1]; pent >= pmap->blue; pent--)
+ pent->refcnt = AllocPrivate;
+ pmap->freeBlue = 0;
+ ppix = (Pixel *) xalloc(size * sizeof(Pixel));
+ if (!ppix)
+ {
+ xfree(pmap->clientPixelsGreen[client]);
+ xfree(pmap->clientPixelsRed[client]);
+ xfree(pmap);
+ return(BadAlloc);
+ }
+ pmap->clientPixelsBlue[client] = ppix;
+ for(i = 0; i < size; i++)
+ ppix[i] = i;
+ pmap->numPixelsBlue[client] = size;
+ }
+ }
+ if (!AddResource(mid, RT_COLORMAP, (pointer)pmap))
+ return (BadAlloc);
+ /* If the device wants a chance to initialize the colormap in any way,
+ * this is it. In specific, if this is a Static colormap, this is the
+ * time to fill in the colormap's values */
+ pmap->flags |= BeingCreated;
+
+
+ /*
+ * Allocate the array of devPrivate's for this colormap.
+ */
+
+ if (colormapPrivateCount == 0)
+ pmap->devPrivates = NULL;
+ else
+ {
+ pmap->devPrivates = (DevUnion *) xcalloc (
+ sizeof(DevUnion), colormapPrivateCount);
+ if (!pmap->devPrivates)
+ {
+ FreeResource (mid, RT_NONE);
+ return BadAlloc;
+ }
+ }
+
+ if (!(*pScreen->CreateColormap)(pmap))
+ {
+ FreeResource (mid, RT_NONE);
+ return BadAlloc;
+ }
+ pmap->flags &= ~BeingCreated;
+ *ppcmap = pmap;
+ return (Success);
+}
+
+/**
+ *
+ * \param value must conform to DeleteType
+ */
+int
+FreeColormap (pointer value, XID mid)
+{
+ int i;
+ register EntryPtr pent;
+ ColormapPtr pmap = (ColormapPtr)value;
+
+ if(CLIENT_ID(mid) != SERVER_ID)
+ {
+ (*pmap->pScreen->UninstallColormap) (pmap);
+ WalkTree(pmap->pScreen, (VisitWindowProcPtr)TellNoMap, (pointer) &mid);
+ }
+
+ /* This is the device's chance to undo anything it needs to, especially
+ * to free any storage it allocated */
+ (*pmap->pScreen->DestroyColormap)(pmap);
+
+ if(pmap->clientPixelsRed)
+ {
+ for(i = 0; i < MAXCLIENTS; i++)
+ xfree(pmap->clientPixelsRed[i]);
+ }
+
+ if ((pmap->class == PseudoColor) || (pmap->class == GrayScale))
+ {
+ for(pent = &pmap->red[pmap->pVisual->ColormapEntries - 1];
+ pent >= pmap->red;
+ pent--)
+ {
+ if(pent->fShared)
+ {
+ if (--pent->co.shco.red->refcnt == 0)
+ xfree(pent->co.shco.red);
+ if (--pent->co.shco.green->refcnt == 0)
+ xfree(pent->co.shco.green);
+ if (--pent->co.shco.blue->refcnt == 0)
+ xfree(pent->co.shco.blue);
+ }
+ }
+ }
+ if((pmap->class | DynamicClass) == DirectColor)
+ {
+ for(i = 0; i < MAXCLIENTS; i++)
+ {
+ xfree(pmap->clientPixelsGreen[i]);
+ xfree(pmap->clientPixelsBlue[i]);
+ }
+ }
+
+ if (pmap->devPrivates)
+ xfree(pmap->devPrivates);
+
+ xfree(pmap);
+ return(Success);
+}
+
+/* Tell window that pmid has disappeared */
+static int
+TellNoMap (WindowPtr pwin, Colormap *pmid)
+{
+ xEvent xE;
+
+ if (wColormap(pwin) == *pmid)
+ {
+ /* This should be call to DeliverEvent */
+ xE.u.u.type = ColormapNotify;
+ xE.u.colormap.window = pwin->drawable.id;
+ xE.u.colormap.colormap = None;
+ xE.u.colormap.new = TRUE;
+ xE.u.colormap.state = ColormapUninstalled;
+#ifdef PANORAMIX
+ if(noPanoramiXExtension || !pwin->drawable.pScreen->myNum)
+#endif
+ DeliverEvents(pwin, &xE, 1, (WindowPtr)NULL);
+ if (pwin->optional) {
+ pwin->optional->colormap = None;
+ CheckWindowOptionalNeed (pwin);
+ }
+ }
+
+ return (WT_WALKCHILDREN);
+}
+
+/* Tell window that pmid got uninstalled */
+int
+TellLostMap (WindowPtr pwin, pointer value)
+{
+ Colormap *pmid = (Colormap *)value;
+ xEvent xE;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && pwin->drawable.pScreen->myNum)
+ return WT_STOPWALKING;
+#endif
+ if (wColormap(pwin) == *pmid)
+ {
+ /* This should be call to DeliverEvent */
+ xE.u.u.type = ColormapNotify;
+ xE.u.colormap.window = pwin->drawable.id;
+ xE.u.colormap.colormap = *pmid;
+ xE.u.colormap.new = FALSE;
+ xE.u.colormap.state = ColormapUninstalled;
+ DeliverEvents(pwin, &xE, 1, (WindowPtr)NULL);
+ }
+
+ return (WT_WALKCHILDREN);
+}
+
+/* Tell window that pmid got installed */
+int
+TellGainedMap (WindowPtr pwin, pointer value)
+{
+ Colormap *pmid = (Colormap *)value;
+ xEvent xE;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && pwin->drawable.pScreen->myNum)
+ return WT_STOPWALKING;
+#endif
+ if (wColormap (pwin) == *pmid)
+ {
+ /* This should be call to DeliverEvent */
+ xE.u.u.type = ColormapNotify;
+ xE.u.colormap.window = pwin->drawable.id;
+ xE.u.colormap.colormap = *pmid;
+ xE.u.colormap.new = FALSE;
+ xE.u.colormap.state = ColormapInstalled;
+ DeliverEvents(pwin, &xE, 1, (WindowPtr)NULL);
+ }
+
+ return (WT_WALKCHILDREN);
+}
+
+
+int
+CopyColormapAndFree (Colormap mid, ColormapPtr pSrc, int client)
+{
+ ColormapPtr pmap = (ColormapPtr) NULL;
+ int result, alloc, size;
+ Colormap midSrc;
+ ScreenPtr pScreen;
+ VisualPtr pVisual;
+
+ pScreen = pSrc->pScreen;
+ pVisual = pSrc->pVisual;
+ midSrc = pSrc->mid;
+ alloc = ((pSrc->flags & AllAllocated) && CLIENT_ID(midSrc) == client) ?
+ AllocAll : AllocNone;
+ size = pVisual->ColormapEntries;
+
+ /* If the create returns non-0, it failed */
+ result = CreateColormap (mid, pScreen, pVisual, &pmap, alloc, client);
+ if(result != Success)
+ return(result);
+ if(alloc == AllocAll)
+ {
+ memmove((char *)pmap->red, (char *)pSrc->red, size * sizeof(Entry));
+ if((pmap->class | DynamicClass) == DirectColor)
+ {
+ memmove((char *)pmap->green, (char *)pSrc->green, size * sizeof(Entry));
+ memmove((char *)pmap->blue, (char *)pSrc->blue, size * sizeof(Entry));
+ }
+ pSrc->flags &= ~AllAllocated;
+ FreePixels(pSrc, client);
+ UpdateColors(pmap);
+ return(Success);
+ }
+
+ CopyFree(REDMAP, client, pSrc, pmap);
+ if ((pmap->class | DynamicClass) == DirectColor)
+ {
+ CopyFree(GREENMAP, client, pSrc, pmap);
+ CopyFree(BLUEMAP, client, pSrc, pmap);
+ }
+ if (pmap->class & DynamicClass)
+ UpdateColors(pmap);
+ /* XXX should worry about removing any RT_CMAPENTRY resource */
+ return(Success);
+}
+
+/* Helper routine for freeing large numbers of cells from a map */
+static void
+CopyFree (int channel, int client, ColormapPtr pmapSrc, ColormapPtr pmapDst)
+{
+ int z, npix;
+ EntryPtr pentSrcFirst, pentDstFirst;
+ EntryPtr pentSrc, pentDst;
+ Pixel *ppix;
+ int nalloc;
+
+ switch(channel)
+ {
+ default: /* so compiler can see that everything gets initialized */
+ case REDMAP:
+ ppix = (pmapSrc->clientPixelsRed)[client];
+ npix = (pmapSrc->numPixelsRed)[client];
+ pentSrcFirst = pmapSrc->red;
+ pentDstFirst = pmapDst->red;
+ break;
+ case GREENMAP:
+ ppix = (pmapSrc->clientPixelsGreen)[client];
+ npix = (pmapSrc->numPixelsGreen)[client];
+ pentSrcFirst = pmapSrc->green;
+ pentDstFirst = pmapDst->green;
+ break;
+ case BLUEMAP:
+ ppix = (pmapSrc->clientPixelsBlue)[client];
+ npix = (pmapSrc->numPixelsBlue)[client];
+ pentSrcFirst = pmapSrc->blue;
+ pentDstFirst = pmapDst->blue;
+ break;
+ }
+ nalloc = 0;
+ if (pmapSrc->class & DynamicClass)
+ {
+ for(z = npix; --z >= 0; ppix++)
+ {
+ /* Copy entries */
+ pentSrc = pentSrcFirst + *ppix;
+ pentDst = pentDstFirst + *ppix;
+ if (pentDst->refcnt > 0)
+ {
+ pentDst->refcnt++;
+ }
+ else
+ {
+ *pentDst = *pentSrc;
+ nalloc++;
+ if (pentSrc->refcnt > 0)
+ pentDst->refcnt = 1;
+ else
+ pentSrc->fShared = FALSE;
+ }
+ FreeCell(pmapSrc, *ppix, channel);
+ }
+ }
+
+ /* Note that FreeCell has already fixed pmapSrc->free{Color} */
+ switch(channel)
+ {
+ case REDMAP:
+ pmapDst->freeRed -= nalloc;
+ (pmapDst->clientPixelsRed)[client] =
+ (pmapSrc->clientPixelsRed)[client];
+ (pmapSrc->clientPixelsRed)[client] = (Pixel *) NULL;
+ (pmapDst->numPixelsRed)[client] = (pmapSrc->numPixelsRed)[client];
+ (pmapSrc->numPixelsRed)[client] = 0;
+ break;
+ case GREENMAP:
+ pmapDst->freeGreen -= nalloc;
+ (pmapDst->clientPixelsGreen)[client] =
+ (pmapSrc->clientPixelsGreen)[client];
+ (pmapSrc->clientPixelsGreen)[client] = (Pixel *) NULL;
+ (pmapDst->numPixelsGreen)[client] = (pmapSrc->numPixelsGreen)[client];
+ (pmapSrc->numPixelsGreen)[client] = 0;
+ break;
+ case BLUEMAP:
+ pmapDst->freeBlue -= nalloc;
+ pmapDst->clientPixelsBlue[client] = pmapSrc->clientPixelsBlue[client];
+ pmapSrc->clientPixelsBlue[client] = (Pixel *) NULL;
+ pmapDst->numPixelsBlue[client] = pmapSrc->numPixelsBlue[client];
+ pmapSrc->numPixelsBlue[client] = 0;
+ break;
+ }
+}
+
+/* Free the ith entry in a color map. Must handle freeing of
+ * colors allocated through AllocColorPlanes */
+static void
+FreeCell (ColormapPtr pmap, Pixel i, int channel)
+{
+ EntryPtr pent;
+ int *pCount;
+
+
+ switch (channel)
+ {
+ default: /* so compiler can see that everything gets initialized */
+ case PSEUDOMAP:
+ case REDMAP:
+ pent = (EntryPtr) &pmap->red[i];
+ pCount = &pmap->freeRed;
+ break;
+ case GREENMAP:
+ pent = (EntryPtr) &pmap->green[i];
+ pCount = &pmap->freeGreen;
+ break;
+ case BLUEMAP:
+ pent = (EntryPtr) &pmap->blue[i];
+ pCount = &pmap->freeBlue;
+ break;
+ }
+ /* If it's not privately allocated and it's not time to free it, just
+ * decrement the count */
+ if (pent->refcnt > 1)
+ pent->refcnt--;
+ else
+ {
+ /* If the color type is shared, find the sharedcolor. If decremented
+ * refcnt is 0, free the shared cell. */
+ if (pent->fShared)
+ {
+ if(--pent->co.shco.red->refcnt == 0)
+ xfree(pent->co.shco.red);
+ if(--pent->co.shco.green->refcnt == 0)
+ xfree(pent->co.shco.green);
+ if(--pent->co.shco.blue->refcnt == 0)
+ xfree(pent->co.shco.blue);
+ pent->fShared = FALSE;
+ }
+ pent->refcnt = 0;
+ *pCount += 1;
+ }
+}
+
+static void
+UpdateColors (ColormapPtr pmap)
+{
+ xColorItem *defs;
+ register xColorItem *pdef;
+ register EntryPtr pent;
+ register VisualPtr pVisual;
+ int i, n, size;
+
+ pVisual = pmap->pVisual;
+ size = pVisual->ColormapEntries;
+ defs = (xColorItem *)ALLOCATE_LOCAL(size * sizeof(xColorItem));
+ if (!defs)
+ return;
+ n = 0;
+ pdef = defs;
+ if (pmap->class == DirectColor)
+ {
+ for (i = 0; i < size; i++)
+ {
+ if (!pmap->red[i].refcnt &&
+ !pmap->green[i].refcnt &&
+ !pmap->blue[i].refcnt)
+ continue;
+ pdef->pixel = ((Pixel)i << pVisual->offsetRed) |
+ ((Pixel)i << pVisual->offsetGreen) |
+ ((Pixel)i << pVisual->offsetBlue);
+ pdef->red = pmap->red[i].co.local.red;
+ pdef->green = pmap->green[i].co.local.green;
+ pdef->blue = pmap->blue[i].co.local.blue;
+ pdef->flags = DoRed|DoGreen|DoBlue;
+ pdef++;
+ n++;
+ }
+ }
+ else
+ {
+ for (i = 0, pent = pmap->red; i < size; i++, pent++)
+ {
+ if (!pent->refcnt)
+ continue;
+ pdef->pixel = i;
+ if(pent->fShared)
+ {
+ pdef->red = pent->co.shco.red->color;
+ pdef->green = pent->co.shco.green->color;
+ pdef->blue = pent->co.shco.blue->color;
+ }
+ else
+ {
+ pdef->red = pent->co.local.red;
+ pdef->green = pent->co.local.green;
+ pdef->blue = pent->co.local.blue;
+ }
+ pdef->flags = DoRed|DoGreen|DoBlue;
+ pdef++;
+ n++;
+ }
+ }
+ if (n)
+ (*pmap->pScreen->StoreColors)(pmap, n, defs);
+ DEALLOCATE_LOCAL(defs);
+}
+
+/* Get a read-only color from a ColorMap (probably slow for large maps)
+ * Returns by changing the value in pred, pgreen, pblue and pPix
+ */
+int
+AllocColor (ColormapPtr pmap,
+ unsigned short *pred, unsigned short *pgreen, unsigned short *pblue,
+ Pixel *pPix, int client)
+{
+ Pixel pixR, pixG, pixB;
+ int entries;
+ xrgb rgb;
+ int class;
+ VisualPtr pVisual;
+ int npix;
+ Pixel *ppix;
+
+ pVisual = pmap->pVisual;
+ (*pmap->pScreen->ResolveColor) (pred, pgreen, pblue, pVisual);
+ rgb.red = *pred;
+ rgb.green = *pgreen;
+ rgb.blue = *pblue;
+ class = pmap->class;
+ entries = pVisual->ColormapEntries;
+
+ /* If the colormap is being created, then we want to be able to change
+ * the colormap, even if it's a static type. Otherwise, we'd never be
+ * able to initialize static colormaps
+ */
+ if(pmap->flags & BeingCreated)
+ class |= DynamicClass;
+
+ /* If this is one of the static storage classes, and we're not initializing
+ * it, the best we can do is to find the closest color entry to the
+ * requested one and return that.
+ */
+ switch (class) {
+ case StaticColor:
+ case StaticGray:
+ /* Look up all three components in the same pmap */
+ *pPix = pixR = FindBestPixel(pmap->red, entries, &rgb, PSEUDOMAP);
+ *pred = pmap->red[pixR].co.local.red;
+ *pgreen = pmap->red[pixR].co.local.green;
+ *pblue = pmap->red[pixR].co.local.blue;
+ npix = pmap->numPixelsRed[client];
+ ppix = (Pixel *) xrealloc(pmap->clientPixelsRed[client],
+ (npix + 1) * sizeof(Pixel));
+ if (!ppix)
+ return (BadAlloc);
+ ppix[npix] = pixR;
+ pmap->clientPixelsRed[client] = ppix;
+ pmap->numPixelsRed[client]++;
+ break;
+
+ case TrueColor:
+ /* Look up each component in its own map, then OR them together */
+ pixR = FindBestPixel(pmap->red, NUMRED(pVisual), &rgb, REDMAP);
+ pixG = FindBestPixel(pmap->green, NUMGREEN(pVisual), &rgb, GREENMAP);
+ pixB = FindBestPixel(pmap->blue, NUMBLUE(pVisual), &rgb, BLUEMAP);
+ *pPix = (pixR << pVisual->offsetRed) |
+ (pixG << pVisual->offsetGreen) |
+ (pixB << pVisual->offsetBlue) |
+ ALPHAMASK(pVisual);
+
+ *pred = pmap->red[pixR].co.local.red;
+ *pgreen = pmap->green[pixG].co.local.green;
+ *pblue = pmap->blue[pixB].co.local.blue;
+ npix = pmap->numPixelsRed[client];
+ ppix = (Pixel *) xrealloc(pmap->clientPixelsRed[client],
+ (npix + 1) * sizeof(Pixel));
+ if (!ppix)
+ return (BadAlloc);
+ ppix[npix] = pixR;
+ pmap->clientPixelsRed[client] = ppix;
+ npix = pmap->numPixelsGreen[client];
+ ppix = (Pixel *) xrealloc(pmap->clientPixelsGreen[client],
+ (npix + 1) * sizeof(Pixel));
+ if (!ppix)
+ return (BadAlloc);
+ ppix[npix] = pixG;
+ pmap->clientPixelsGreen[client] = ppix;
+ npix = pmap->numPixelsBlue[client];
+ ppix = (Pixel *) xrealloc(pmap->clientPixelsBlue[client],
+ (npix + 1) * sizeof(Pixel));
+ if (!ppix)
+ return (BadAlloc);
+ ppix[npix] = pixB;
+ pmap->clientPixelsBlue[client] = ppix;
+ pmap->numPixelsRed[client]++;
+ pmap->numPixelsGreen[client]++;
+ pmap->numPixelsBlue[client]++;
+ break;
+
+ case GrayScale:
+ case PseudoColor:
+ if (pmap->mid != pmap->pScreen->defColormap &&
+ pmap->pVisual->vid == pmap->pScreen->rootVisual)
+ {
+ ColormapPtr prootmap = (ColormapPtr)
+ SecurityLookupIDByType (clients[client], pmap->pScreen->defColormap,
+ RT_COLORMAP, SecurityReadAccess);
+
+ if (pmap->class == prootmap->class)
+ FindColorInRootCmap (prootmap, prootmap->red, entries, &rgb,
+ pPix, PSEUDOMAP, AllComp);
+ }
+ if (FindColor(pmap, pmap->red, entries, &rgb, pPix, PSEUDOMAP,
+ client, AllComp) != Success)
+ return (BadAlloc);
+ break;
+
+ case DirectColor:
+ if (pmap->mid != pmap->pScreen->defColormap &&
+ pmap->pVisual->vid == pmap->pScreen->rootVisual)
+ {
+ ColormapPtr prootmap = (ColormapPtr)
+ SecurityLookupIDByType (clients[client], pmap->pScreen->defColormap,
+ RT_COLORMAP, SecurityReadAccess);
+
+ if (pmap->class == prootmap->class)
+ {
+ pixR = (*pPix & pVisual->redMask) >> pVisual->offsetRed;
+ FindColorInRootCmap (prootmap, prootmap->red, entries, &rgb,
+ &pixR, REDMAP, RedComp);
+ pixG = (*pPix & pVisual->greenMask) >> pVisual->offsetGreen;
+ FindColorInRootCmap (prootmap, prootmap->green, entries, &rgb,
+ &pixG, GREENMAP, GreenComp);
+ pixB = (*pPix & pVisual->blueMask) >> pVisual->offsetBlue;
+ FindColorInRootCmap (prootmap, prootmap->blue, entries, &rgb,
+ &pixB, BLUEMAP, BlueComp);
+ *pPix = pixR | pixG | pixB;
+ }
+ }
+
+ pixR = (*pPix & pVisual->redMask) >> pVisual->offsetRed;
+ if (FindColor(pmap, pmap->red, NUMRED(pVisual), &rgb, &pixR, REDMAP,
+ client, RedComp) != Success)
+ return (BadAlloc);
+ pixG = (*pPix & pVisual->greenMask) >> pVisual->offsetGreen;
+ if (FindColor(pmap, pmap->green, NUMGREEN(pVisual), &rgb, &pixG,
+ GREENMAP, client, GreenComp) != Success)
+ {
+ (void)FreeCo(pmap, client, REDMAP, 1, &pixR, (Pixel)0);
+ return (BadAlloc);
+ }
+ pixB = (*pPix & pVisual->blueMask) >> pVisual->offsetBlue;
+ if (FindColor(pmap, pmap->blue, NUMBLUE(pVisual), &rgb, &pixB, BLUEMAP,
+ client, BlueComp) != Success)
+ {
+ (void)FreeCo(pmap, client, GREENMAP, 1, &pixG, (Pixel)0);
+ (void)FreeCo(pmap, client, REDMAP, 1, &pixR, (Pixel)0);
+ return (BadAlloc);
+ }
+ *pPix = pixR | pixG | pixB | ALPHAMASK(pVisual);
+
+ break;
+ }
+
+ /* if this is the client's first pixel in this colormap, tell the
+ * resource manager that the client has pixels in this colormap which
+ * should be freed when the client dies */
+ if ((pmap->numPixelsRed[client] == 1) &&
+ (CLIENT_ID(pmap->mid) != client) &&
+ !(pmap->flags & BeingCreated))
+ {
+ colorResource *pcr;
+
+ pcr = (colorResource *) xalloc(sizeof(colorResource));
+ if (!pcr)
+ {
+ (void)FreeColors(pmap, client, 1, pPix, (Pixel)0);
+ return (BadAlloc);
+ }
+ pcr->mid = pmap->mid;
+ pcr->client = client;
+ if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr))
+ return (BadAlloc);
+ }
+ return (Success);
+}
+
+/*
+ * FakeAllocColor -- fake an AllocColor request by
+ * returning a free pixel if availible, otherwise returning
+ * the closest matching pixel. This is used by the mi
+ * software sprite code to recolor cursors. A nice side-effect
+ * is that this routine will never return failure.
+ */
+
+void
+FakeAllocColor (register ColormapPtr pmap, register xColorItem *item)
+{
+ Pixel pixR, pixG, pixB;
+ Pixel temp;
+ int entries;
+ xrgb rgb;
+ int class;
+ register VisualPtr pVisual;
+
+ pVisual = pmap->pVisual;
+ rgb.red = item->red;
+ rgb.green = item->green;
+ rgb.blue = item->blue;
+ (*pmap->pScreen->ResolveColor) (&rgb.red, &rgb.green, &rgb.blue, pVisual);
+ class = pmap->class;
+ entries = pVisual->ColormapEntries;
+
+ switch (class) {
+ case GrayScale:
+ case PseudoColor:
+ item->pixel = 0;
+ if (FindColor(pmap, pmap->red, entries, &rgb, &temp, PSEUDOMAP,
+ -1, AllComp) == Success) {
+ item->pixel = temp;
+ break;
+ }
+ /* fall through ... */
+ case StaticColor:
+ case StaticGray:
+ item->pixel = FindBestPixel(pmap->red, entries, &rgb, PSEUDOMAP);
+ break;
+
+ case DirectColor:
+ /* Look up each component in its own map, then OR them together */
+ pixR = (item->pixel & pVisual->redMask) >> pVisual->offsetRed;
+ pixG = (item->pixel & pVisual->greenMask) >> pVisual->offsetGreen;
+ pixB = (item->pixel & pVisual->blueMask) >> pVisual->offsetBlue;
+ if (FindColor(pmap, pmap->red, NUMRED(pVisual), &rgb, &pixR, REDMAP,
+ -1, RedComp) != Success)
+ pixR = FindBestPixel(pmap->red, NUMRED(pVisual), &rgb, REDMAP)
+ << pVisual->offsetRed;
+ if (FindColor(pmap, pmap->green, NUMGREEN(pVisual), &rgb, &pixG,
+ GREENMAP, -1, GreenComp) != Success)
+ pixG = FindBestPixel(pmap->green, NUMGREEN(pVisual), &rgb,
+ GREENMAP) << pVisual->offsetGreen;
+ if (FindColor(pmap, pmap->blue, NUMBLUE(pVisual), &rgb, &pixB, BLUEMAP,
+ -1, BlueComp) != Success)
+ pixB = FindBestPixel(pmap->blue, NUMBLUE(pVisual), &rgb, BLUEMAP)
+ << pVisual->offsetBlue;
+ item->pixel = pixR | pixG | pixB;
+ break;
+
+ case TrueColor:
+ /* Look up each component in its own map, then OR them together */
+ pixR = FindBestPixel(pmap->red, NUMRED(pVisual), &rgb, REDMAP);
+ pixG = FindBestPixel(pmap->green, NUMGREEN(pVisual), &rgb, GREENMAP);
+ pixB = FindBestPixel(pmap->blue, NUMBLUE(pVisual), &rgb, BLUEMAP);
+ item->pixel = (pixR << pVisual->offsetRed) |
+ (pixG << pVisual->offsetGreen) |
+ (pixB << pVisual->offsetBlue);
+ break;
+ }
+}
+
+/* free a pixel value obtained from FakeAllocColor */
+void
+FakeFreeColor(register ColormapPtr pmap, Pixel pixel)
+{
+ register VisualPtr pVisual;
+ Pixel pixR, pixG, pixB;
+
+ switch (pmap->class) {
+ case GrayScale:
+ case PseudoColor:
+ if (pmap->red[pixel].refcnt == AllocTemporary)
+ pmap->red[pixel].refcnt = 0;
+ break;
+ case DirectColor:
+ pVisual = pmap->pVisual;
+ pixR = (pixel & pVisual->redMask) >> pVisual->offsetRed;
+ pixG = (pixel & pVisual->greenMask) >> pVisual->offsetGreen;
+ pixB = (pixel & pVisual->blueMask) >> pVisual->offsetBlue;
+ if (pmap->red[pixR].refcnt == AllocTemporary)
+ pmap->red[pixR].refcnt = 0;
+ if (pmap->green[pixG].refcnt == AllocTemporary)
+ pmap->green[pixG].refcnt = 0;
+ if (pmap->blue[pixB].refcnt == AllocTemporary)
+ pmap->blue[pixB].refcnt = 0;
+ break;
+ }
+}
+
+typedef unsigned short BigNumUpper;
+typedef unsigned long BigNumLower;
+
+#define BIGNUMLOWERBITS 24
+#define BIGNUMUPPERBITS 16
+#define BIGNUMLOWER (1 << BIGNUMLOWERBITS)
+#define BIGNUMUPPER (1 << BIGNUMUPPERBITS)
+#define UPPERPART(i) ((i) >> BIGNUMLOWERBITS)
+#define LOWERPART(i) ((i) & (BIGNUMLOWER - 1))
+
+typedef struct _bignum {
+ BigNumUpper upper;
+ BigNumLower lower;
+} BigNumRec, *BigNumPtr;
+
+#define BigNumGreater(x,y) (((x)->upper > (y)->upper) ||\
+ ((x)->upper == (y)->upper && (x)->lower > (y)->lower))
+
+#define UnsignedToBigNum(u,r) (((r)->upper = UPPERPART(u)), \
+ ((r)->lower = LOWERPART(u)))
+
+#define MaxBigNum(r) (((r)->upper = BIGNUMUPPER-1), \
+ ((r)->lower = BIGNUMLOWER-1))
+
+static void
+BigNumAdd (BigNumPtr x, BigNumPtr y, BigNumPtr r)
+{
+ BigNumLower lower, carry = 0;
+
+ lower = x->lower + y->lower;
+ if (lower >= BIGNUMLOWER) {
+ lower -= BIGNUMLOWER;
+ carry = 1;
+ }
+ r->lower = lower;
+ r->upper = x->upper + y->upper + carry;
+}
+
+static Pixel
+FindBestPixel(EntryPtr pentFirst, int size, xrgb *prgb, int channel)
+{
+ EntryPtr pent;
+ Pixel pixel, final;
+ long dr, dg, db;
+ unsigned long sq;
+ BigNumRec minval, sum, temp;
+
+ final = 0;
+ MaxBigNum(&minval);
+ /* look for the minimal difference */
+ for (pent = pentFirst, pixel = 0; pixel < size; pent++, pixel++)
+ {
+ dr = dg = db = 0;
+ switch(channel)
+ {
+ case PSEUDOMAP:
+ dg = (long) pent->co.local.green - prgb->green;
+ db = (long) pent->co.local.blue - prgb->blue;
+ case REDMAP:
+ dr = (long) pent->co.local.red - prgb->red;
+ break;
+ case GREENMAP:
+ dg = (long) pent->co.local.green - prgb->green;
+ break;
+ case BLUEMAP:
+ db = (long) pent->co.local.blue - prgb->blue;
+ break;
+ }
+ sq = dr * dr;
+ UnsignedToBigNum (sq, &sum);
+ sq = dg * dg;
+ UnsignedToBigNum (sq, &temp);
+ BigNumAdd (&sum, &temp, &sum);
+ sq = db * db;
+ UnsignedToBigNum (sq, &temp);
+ BigNumAdd (&sum, &temp, &sum);
+ if (BigNumGreater (&minval, &sum))
+ {
+ final = pixel;
+ minval = sum;
+ }
+ }
+ return(final);
+}
+
+static void
+FindColorInRootCmap (ColormapPtr pmap, EntryPtr pentFirst, int size,
+ xrgb *prgb, Pixel *pPixel, int channel,
+ ColorCompareProcPtr comp)
+{
+ EntryPtr pent;
+ Pixel pixel;
+ int count;
+
+ if ((pixel = *pPixel) >= size)
+ pixel = 0;
+ for (pent = pentFirst + pixel, count = size; --count >= 0; pent++, pixel++)
+ {
+ if (pent->refcnt > 0 && (*comp) (pent, prgb))
+ {
+ switch (channel)
+ {
+ case REDMAP:
+ pixel <<= pmap->pVisual->offsetRed;
+ break;
+ case GREENMAP:
+ pixel <<= pmap->pVisual->offsetGreen;
+ break;
+ case BLUEMAP:
+ pixel <<= pmap->pVisual->offsetBlue;
+ break;
+ default: /* PSEUDOMAP */
+ break;
+ }
+ *pPixel = pixel;
+ }
+ }
+}
+
+/* Tries to find a color in pmap that exactly matches the one requested in prgb
+ * if it can't it allocates one.
+ * Starts looking at pentFirst + *pPixel, so if you want a specific pixel,
+ * load *pPixel with that value, otherwise set it to 0
+ */
+int
+FindColor (ColormapPtr pmap, EntryPtr pentFirst, int size, xrgb *prgb,
+ Pixel *pPixel, int channel, int client,
+ ColorCompareProcPtr comp)
+{
+ EntryPtr pent;
+ Bool foundFree;
+ Pixel pixel, Free = 0;
+ int npix, count, *nump = NULL;
+ Pixel **pixp = NULL, *ppix;
+ xColorItem def;
+
+ foundFree = FALSE;
+
+ if((pixel = *pPixel) >= size)
+ pixel = 0;
+ /* see if there is a match, and also look for a free entry */
+ for (pent = pentFirst + pixel, count = size; --count >= 0; )
+ {
+ if (pent->refcnt > 0)
+ {
+ if ((*comp) (pent, prgb))
+ {
+ if (client >= 0)
+ pent->refcnt++;
+ *pPixel = pixel;
+ switch(channel)
+ {
+ case REDMAP:
+ *pPixel <<= pmap->pVisual->offsetRed;
+ case PSEUDOMAP:
+ break;
+ case GREENMAP:
+ *pPixel <<= pmap->pVisual->offsetGreen;
+ break;
+ case BLUEMAP:
+ *pPixel <<= pmap->pVisual->offsetBlue;
+ break;
+ }
+ goto gotit;
+ }
+ }
+ else if (!foundFree && pent->refcnt == 0)
+ {
+ Free = pixel;
+ foundFree = TRUE;
+ /* If we're initializing the colormap, then we are looking for
+ * the first free cell we can find, not to minimize the number
+ * of entries we use. So don't look any further. */
+ if(pmap->flags & BeingCreated)
+ break;
+ }
+ pixel++;
+ if(pixel >= size)
+ {
+ pent = pentFirst;
+ pixel = 0;
+ }
+ else
+ pent++;
+ }
+
+ /* If we got here, we didn't find a match. If we also didn't find
+ * a free entry, we're out of luck. Otherwise, we'll usurp a free
+ * entry and fill it in */
+ if (!foundFree)
+ return (BadAlloc);
+ pent = pentFirst + Free;
+ pent->fShared = FALSE;
+ pent->refcnt = (client >= 0) ? 1 : AllocTemporary;
+
+ switch (channel)
+ {
+ case PSEUDOMAP:
+ pent->co.local.red = prgb->red;
+ pent->co.local.green = prgb->green;
+ pent->co.local.blue = prgb->blue;
+ def.red = prgb->red;
+ def.green = prgb->green;
+ def.blue = prgb->blue;
+ def.flags = (DoRed|DoGreen|DoBlue);
+ if (client >= 0)
+ pmap->freeRed--;
+ def.pixel = Free;
+ break;
+
+ case REDMAP:
+ pent->co.local.red = prgb->red;
+ def.red = prgb->red;
+ def.green = pmap->green[0].co.local.green;
+ def.blue = pmap->blue[0].co.local.blue;
+ def.flags = DoRed;
+ if (client >= 0)
+ pmap->freeRed--;
+ def.pixel = Free << pmap->pVisual->offsetRed;
+ break;
+
+ case GREENMAP:
+ pent->co.local.green = prgb->green;
+ def.red = pmap->red[0].co.local.red;
+ def.green = prgb->green;
+ def.blue = pmap->blue[0].co.local.blue;
+ def.flags = DoGreen;
+ if (client >= 0)
+ pmap->freeGreen--;
+ def.pixel = Free << pmap->pVisual->offsetGreen;
+ break;
+
+ case BLUEMAP:
+ pent->co.local.blue = prgb->blue;
+ def.red = pmap->red[0].co.local.red;
+ def.green = pmap->green[0].co.local.green;
+ def.blue = prgb->blue;
+ def.flags = DoBlue;
+ if (client >= 0)
+ pmap->freeBlue--;
+ def.pixel = Free << pmap->pVisual->offsetBlue;
+ break;
+ }
+ (*pmap->pScreen->StoreColors) (pmap, 1, &def);
+ pixel = Free;
+ *pPixel = def.pixel;
+
+gotit:
+ if (pmap->flags & BeingCreated || client == -1)
+ return(Success);
+ /* Now remember the pixel, for freeing later */
+ switch (channel)
+ {
+ case PSEUDOMAP:
+ case REDMAP:
+ nump = pmap->numPixelsRed;
+ pixp = pmap->clientPixelsRed;
+ break;
+
+ case GREENMAP:
+ nump = pmap->numPixelsGreen;
+ pixp = pmap->clientPixelsGreen;
+ break;
+
+ case BLUEMAP:
+ nump = pmap->numPixelsBlue;
+ pixp = pmap->clientPixelsBlue;
+ break;
+ }
+ npix = nump[client];
+ ppix = (Pixel *) xrealloc (pixp[client], (npix + 1) * sizeof(Pixel));
+ if (!ppix)
+ {
+ pent->refcnt--;
+ if (!pent->fShared)
+ switch (channel)
+ {
+ case PSEUDOMAP:
+ case REDMAP:
+ pmap->freeRed++;
+ break;
+ case GREENMAP:
+ pmap->freeGreen++;
+ break;
+ case BLUEMAP:
+ pmap->freeBlue++;
+ break;
+ }
+ return(BadAlloc);
+ }
+ ppix[npix] = pixel;
+ pixp[client] = ppix;
+ nump[client]++;
+
+ return(Success);
+}
+
+/* Comparison functions -- passed to FindColor to determine if an
+ * entry is already the color we're looking for or not */
+static int
+AllComp (EntryPtr pent, xrgb *prgb)
+{
+ if((pent->co.local.red == prgb->red) &&
+ (pent->co.local.green == prgb->green) &&
+ (pent->co.local.blue == prgb->blue) )
+ return (1);
+ return (0);
+}
+
+static int
+RedComp (EntryPtr pent, xrgb *prgb)
+{
+ if (pent->co.local.red == prgb->red)
+ return (1);
+ return (0);
+}
+
+static int
+GreenComp (EntryPtr pent, xrgb *prgb)
+{
+ if (pent->co.local.green == prgb->green)
+ return (1);
+ return (0);
+}
+
+static int
+BlueComp (EntryPtr pent, xrgb *prgb)
+{
+ if (pent->co.local.blue == prgb->blue)
+ return (1);
+ return (0);
+}
+
+
+/* Read the color value of a cell */
+
+int
+QueryColors (ColormapPtr pmap, int count, Pixel *ppixIn, xrgb *prgbList)
+{
+ Pixel *ppix, pixel;
+ xrgb *prgb;
+ VisualPtr pVisual;
+ EntryPtr pent;
+ Pixel i;
+ int errVal = Success;
+
+ pVisual = pmap->pVisual;
+ if ((pmap->class | DynamicClass) == DirectColor)
+ {
+ int numred, numgreen, numblue;
+ Pixel rgbbad;
+
+ numred = NUMRED(pVisual);
+ numgreen = NUMGREEN(pVisual);
+ numblue = NUMBLUE(pVisual);
+ rgbbad = ~RGBMASK(pVisual);
+ for( ppix = ppixIn, prgb = prgbList; --count >= 0; ppix++, prgb++)
+ {
+ pixel = *ppix;
+ if (pixel & rgbbad) {
+ clientErrorValue = pixel;
+ errVal = BadValue;
+ continue;
+ }
+ i = (pixel & pVisual->redMask) >> pVisual->offsetRed;
+ if (i >= numred)
+ {
+ clientErrorValue = pixel;
+ errVal = BadValue;
+ continue;
+ }
+ prgb->red = pmap->red[i].co.local.red;
+ i = (pixel & pVisual->greenMask) >> pVisual->offsetGreen;
+ if (i >= numgreen)
+ {
+ clientErrorValue = pixel;
+ errVal = BadValue;
+ continue;
+ }
+ prgb->green = pmap->green[i].co.local.green;
+ i = (pixel & pVisual->blueMask) >> pVisual->offsetBlue;
+ if (i >= numblue)
+ {
+ clientErrorValue = pixel;
+ errVal = BadValue;
+ continue;
+ }
+ prgb->blue = pmap->blue[i].co.local.blue;
+ }
+ }
+ else
+ {
+ for( ppix = ppixIn, prgb = prgbList; --count >= 0; ppix++, prgb++)
+ {
+ pixel = *ppix;
+ if (pixel >= pVisual->ColormapEntries)
+ {
+ clientErrorValue = pixel;
+ errVal = BadValue;
+ }
+ else
+ {
+ pent = (EntryPtr)&pmap->red[pixel];
+ if (pent->fShared)
+ {
+ prgb->red = pent->co.shco.red->color;
+ prgb->green = pent->co.shco.green->color;
+ prgb->blue = pent->co.shco.blue->color;
+ }
+ else
+ {
+ prgb->red = pent->co.local.red;
+ prgb->green = pent->co.local.green;
+ prgb->blue = pent->co.local.blue;
+ }
+ }
+ }
+ }
+ return (errVal);
+}
+
+static void
+FreePixels(register ColormapPtr pmap, register int client)
+{
+ register Pixel *ppix, *ppixStart;
+ register int n;
+ int class;
+#ifdef LBX
+ Bool grabbed;
+ Bool zeroRefCount;
+ Bool anyRefCountReachedZero = 0;
+#endif
+
+ class = pmap->class;
+ ppixStart = pmap->clientPixelsRed[client];
+ if (class & DynamicClass)
+ {
+ n = pmap->numPixelsRed[client];
+#ifdef LBX
+ grabbed = LbxCheckCmapGrabbed (pmap);
+ if (grabbed)
+ {
+ /*
+ * If the colormap is grabbed by a proxy, the server must
+ * notify the proxy of all cells that are freed (the refcount
+ * has reached zero on these cells).
+ */
+
+ LbxBeginFreeCellsEvent (pmap);
+ LbxSortPixelList (ppixStart, n);
+ }
+#endif
+ for (ppix = ppixStart; --n >= 0; )
+ {
+ FreeCell(pmap, *ppix, REDMAP);
+#ifdef LBX
+ /*
+ * Only PSEUDO colormaps are grabbed by LBX proxies.
+ * Check if the ref count reached zero on this pixel.
+ */
+
+ zeroRefCount = pmap->red[*ppix].refcnt == 0;
+ if (zeroRefCount)
+ anyRefCountReachedZero = 1;
+
+ if (grabbed && zeroRefCount)
+ LbxAddFreeCellToEvent (pmap, *ppix);
+#endif
+ ppix++;
+ }
+#ifdef LBX
+ if (grabbed)
+ LbxEndFreeCellsEvent (pmap);
+ else if (anyRefCountReachedZero)
+ {
+ /*
+ * We only send LbxFreeCell events to a proxy that has the colormap
+ * grabbed. If the colormap is not grabbed, the proxy that last
+ * had the colormap grabbed will not be able to do a smart grab
+ * in the future. A smart grab can only occur if the proxy is kept
+ * up to date on every alloc/free change in the colormap.
+ */
+
+ LbxDisableSmartGrab (pmap);
+ }
+#endif
+ }
+
+ xfree(ppixStart);
+ pmap->clientPixelsRed[client] = (Pixel *) NULL;
+ pmap->numPixelsRed[client] = 0;
+ if ((class | DynamicClass) == DirectColor)
+ {
+ ppixStart = pmap->clientPixelsGreen[client];
+ if (class & DynamicClass)
+ for (ppix = ppixStart, n = pmap->numPixelsGreen[client]; --n >= 0;)
+ FreeCell(pmap, *ppix++, GREENMAP);
+ xfree(ppixStart);
+ pmap->clientPixelsGreen[client] = (Pixel *) NULL;
+ pmap->numPixelsGreen[client] = 0;
+
+ ppixStart = pmap->clientPixelsBlue[client];
+ if (class & DynamicClass)
+ for (ppix = ppixStart, n = pmap->numPixelsBlue[client]; --n >= 0; )
+ FreeCell(pmap, *ppix++, BLUEMAP);
+ xfree(ppixStart);
+ pmap->clientPixelsBlue[client] = (Pixel *) NULL;
+ pmap->numPixelsBlue[client] = 0;
+ }
+}
+
+/**
+ * Frees all of a client's colors and cells.
+ *
+ * \param value must conform to DeleteType
+ * \unused fakeid
+ */
+int
+FreeClientPixels (pointer value, XID fakeid)
+{
+ ColormapPtr pmap;
+ colorResource *pcr = (colorResource *)value;
+
+ pmap = (ColormapPtr) LookupIDByType(pcr->mid, RT_COLORMAP);
+ if (pmap)
+ FreePixels(pmap, pcr->client);
+ xfree(pcr);
+ return Success;
+}
+
+int
+AllocColorCells (int client, ColormapPtr pmap, int colors, int planes,
+ Bool contig, Pixel *ppix, Pixel *masks)
+{
+ Pixel rmask, gmask, bmask, *ppixFirst, r, g, b;
+ int n, class;
+ int ok;
+ int oldcount;
+ colorResource *pcr = (colorResource *)NULL;
+
+ class = pmap->class;
+ if (!(class & DynamicClass))
+ return (BadAlloc); /* Shouldn't try on this type */
+ oldcount = pmap->numPixelsRed[client];
+ if (pmap->class == DirectColor)
+ oldcount += pmap->numPixelsGreen[client] + pmap->numPixelsBlue[client];
+ if (!oldcount && (CLIENT_ID(pmap->mid) != client))
+ {
+ pcr = (colorResource *) xalloc(sizeof(colorResource));
+ if (!pcr)
+ return (BadAlloc);
+ }
+
+ if (pmap->class == DirectColor)
+ {
+ ok = AllocDirect (client, pmap, colors, planes, planes, planes,
+ contig, ppix, &rmask, &gmask, &bmask);
+ if(ok == Success)
+ {
+ for (r = g = b = 1, n = planes; --n >= 0; r += r, g += g, b += b)
+ {
+ while(!(rmask & r))
+ r += r;
+ while(!(gmask & g))
+ g += g;
+ while(!(bmask & b))
+ b += b;
+ *masks++ = r | g | b;
+ }
+ }
+ }
+ else
+ {
+ ok = AllocPseudo (client, pmap, colors, planes, contig, ppix, &rmask,
+ &ppixFirst);
+ if(ok == Success)
+ {
+ for (r = 1, n = planes; --n >= 0; r += r)
+ {
+ while(!(rmask & r))
+ r += r;
+ *masks++ = r;
+ }
+ }
+ }
+
+ /* if this is the client's first pixels in this colormap, tell the
+ * resource manager that the client has pixels in this colormap which
+ * should be freed when the client dies */
+ if ((ok == Success) && pcr)
+ {
+ pcr->mid = pmap->mid;
+ pcr->client = client;
+ if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr))
+ ok = BadAlloc;
+ } else if (pcr)
+ xfree(pcr);
+
+ return (ok);
+}
+
+
+int
+AllocColorPlanes (int client, ColormapPtr pmap, int colors,
+ int r, int g, int b, Bool contig, Pixel *pixels,
+ Pixel *prmask, Pixel *pgmask, Pixel *pbmask)
+{
+ int ok;
+ Pixel mask, *ppixFirst;
+ register Pixel shift;
+ register int i;
+ int class;
+ int oldcount;
+ colorResource *pcr = (colorResource *)NULL;
+
+ class = pmap->class;
+ if (!(class & DynamicClass))
+ return (BadAlloc); /* Shouldn't try on this type */
+ oldcount = pmap->numPixelsRed[client];
+ if (class == DirectColor)
+ oldcount += pmap->numPixelsGreen[client] + pmap->numPixelsBlue[client];
+ if (!oldcount && (CLIENT_ID(pmap->mid) != client))
+ {
+ pcr = (colorResource *) xalloc(sizeof(colorResource));
+ if (!pcr)
+ return (BadAlloc);
+ }
+
+ if (class == DirectColor)
+ {
+ ok = AllocDirect (client, pmap, colors, r, g, b, contig, pixels,
+ prmask, pgmask, pbmask);
+ }
+ else
+ {
+ /* Allocate the proper pixels */
+ /* XXX This is sort of bad, because of contig is set, we force all
+ * r + g + b bits to be contiguous. Should only force contiguity
+ * per mask
+ */
+ ok = AllocPseudo (client, pmap, colors, r + g + b, contig, pixels,
+ &mask, &ppixFirst);
+
+ if(ok == Success)
+ {
+ /* now split that mask into three */
+ *prmask = *pgmask = *pbmask = 0;
+ shift = 1;
+ for (i = r; --i >= 0; shift += shift)
+ {
+ while (!(mask & shift))
+ shift += shift;
+ *prmask |= shift;
+ }
+ for (i = g; --i >= 0; shift += shift)
+ {
+ while (!(mask & shift))
+ shift += shift;
+ *pgmask |= shift;
+ }
+ for (i = b; --i >= 0; shift += shift)
+ {
+ while (!(mask & shift))
+ shift += shift;
+ *pbmask |= shift;
+ }
+
+ /* set up the shared color cells */
+ if (!AllocShared(pmap, pixels, colors, r, g, b,
+ *prmask, *pgmask, *pbmask, ppixFirst))
+ {
+ (void)FreeColors(pmap, client, colors, pixels, mask);
+ ok = BadAlloc;
+ }
+ }
+ }
+
+ /* if this is the client's first pixels in this colormap, tell the
+ * resource manager that the client has pixels in this colormap which
+ * should be freed when the client dies */
+ if ((ok == Success) && pcr)
+ {
+ pcr->mid = pmap->mid;
+ pcr->client = client;
+ if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr))
+ ok = BadAlloc;
+ } else if (pcr)
+ xfree(pcr);
+
+ return (ok);
+}
+
+static int
+AllocDirect (int client, ColormapPtr pmap, int c, int r, int g, int b, Bool contig,
+ Pixel *pixels, Pixel *prmask, Pixel *pgmask, Pixel *pbmask)
+{
+ Pixel *ppixRed, *ppixGreen, *ppixBlue;
+ Pixel *ppix, *pDst, *p;
+ int npix, npixR, npixG, npixB;
+ Bool okR, okG, okB;
+ Pixel *rpix = 0, *gpix = 0, *bpix = 0;
+
+ npixR = c << r;
+ npixG = c << g;
+ npixB = c << b;
+ if ((r >= 32) || (g >= 32) || (b >= 32) ||
+ (npixR > pmap->freeRed) || (npixR < c) ||
+ (npixG > pmap->freeGreen) || (npixG < c) ||
+ (npixB > pmap->freeBlue) || (npixB < c))
+ return BadAlloc;
+
+ /* start out with empty pixels */
+ for(p = pixels; p < pixels + c; p++)
+ *p = 0;
+
+ ppixRed = (Pixel *)ALLOCATE_LOCAL(npixR * sizeof(Pixel));
+ ppixGreen = (Pixel *)ALLOCATE_LOCAL(npixG * sizeof(Pixel));
+ ppixBlue = (Pixel *)ALLOCATE_LOCAL(npixB * sizeof(Pixel));
+ if (!ppixRed || !ppixGreen || !ppixBlue)
+ {
+ if (ppixBlue) DEALLOCATE_LOCAL(ppixBlue);
+ if (ppixGreen) DEALLOCATE_LOCAL(ppixGreen);
+ if (ppixRed) DEALLOCATE_LOCAL(ppixRed);
+ return(BadAlloc);
+ }
+
+ okR = AllocCP(pmap, pmap->red, c, r, contig, ppixRed, prmask);
+ okG = AllocCP(pmap, pmap->green, c, g, contig, ppixGreen, pgmask);
+ okB = AllocCP(pmap, pmap->blue, c, b, contig, ppixBlue, pbmask);
+
+ if (okR && okG && okB)
+ {
+ rpix = (Pixel *) xrealloc(pmap->clientPixelsRed[client],
+ (pmap->numPixelsRed[client] + (c << r)) *
+ sizeof(Pixel));
+ if (rpix)
+ pmap->clientPixelsRed[client] = rpix;
+ gpix = (Pixel *) xrealloc(pmap->clientPixelsGreen[client],
+ (pmap->numPixelsGreen[client] + (c << g)) *
+ sizeof(Pixel));
+ if (gpix)
+ pmap->clientPixelsGreen[client] = gpix;
+ bpix = (Pixel *) xrealloc(pmap->clientPixelsBlue[client],
+ (pmap->numPixelsBlue[client] + (c << b)) *
+ sizeof(Pixel));
+ if (bpix)
+ pmap->clientPixelsBlue[client] = bpix;
+ }
+
+ if (!okR || !okG || !okB || !rpix || !gpix || !bpix)
+ {
+ if (okR)
+ for(ppix = ppixRed, npix = npixR; --npix >= 0; ppix++)
+ pmap->red[*ppix].refcnt = 0;
+ if (okG)
+ for(ppix = ppixGreen, npix = npixG; --npix >= 0; ppix++)
+ pmap->green[*ppix].refcnt = 0;
+ if (okB)
+ for(ppix = ppixBlue, npix = npixB; --npix >= 0; ppix++)
+ pmap->blue[*ppix].refcnt = 0;
+ DEALLOCATE_LOCAL(ppixBlue);
+ DEALLOCATE_LOCAL(ppixGreen);
+ DEALLOCATE_LOCAL(ppixRed);
+ return(BadAlloc);
+ }
+
+ *prmask <<= pmap->pVisual->offsetRed;
+ *pgmask <<= pmap->pVisual->offsetGreen;
+ *pbmask <<= pmap->pVisual->offsetBlue;
+
+ ppix = rpix + pmap->numPixelsRed[client];
+ for (pDst = pixels, p = ppixRed; p < ppixRed + npixR; p++)
+ {
+ *ppix++ = *p;
+ if(p < ppixRed + c)
+ *pDst++ |= *p << pmap->pVisual->offsetRed;
+ }
+ pmap->numPixelsRed[client] += npixR;
+ pmap->freeRed -= npixR;
+
+ ppix = gpix + pmap->numPixelsGreen[client];
+ for (pDst = pixels, p = ppixGreen; p < ppixGreen + npixG; p++)
+ {
+ *ppix++ = *p;
+ if(p < ppixGreen + c)
+ *pDst++ |= *p << pmap->pVisual->offsetGreen;
+ }
+ pmap->numPixelsGreen[client] += npixG;
+ pmap->freeGreen -= npixG;
+
+ ppix = bpix + pmap->numPixelsBlue[client];
+ for (pDst = pixels, p = ppixBlue; p < ppixBlue + npixB; p++)
+ {
+ *ppix++ = *p;
+ if(p < ppixBlue + c)
+ *pDst++ |= *p << pmap->pVisual->offsetBlue;
+ }
+ pmap->numPixelsBlue[client] += npixB;
+ pmap->freeBlue -= npixB;
+
+
+ for (pDst = pixels; pDst < pixels + c; pDst++)
+ *pDst |= ALPHAMASK(pmap->pVisual);
+
+ DEALLOCATE_LOCAL(ppixBlue);
+ DEALLOCATE_LOCAL(ppixGreen);
+ DEALLOCATE_LOCAL(ppixRed);
+
+ return (Success);
+}
+
+static int
+AllocPseudo (int client, ColormapPtr pmap, int c, int r, Bool contig,
+ Pixel *pixels, Pixel *pmask, Pixel **pppixFirst)
+{
+ Pixel *ppix, *p, *pDst, *ppixTemp;
+ int npix;
+ Bool ok;
+
+ npix = c << r;
+ if ((r >= 32) || (npix > pmap->freeRed) || (npix < c))
+ return(BadAlloc);
+ if(!(ppixTemp = (Pixel *)ALLOCATE_LOCAL(npix * sizeof(Pixel))))
+ return(BadAlloc);
+ ok = AllocCP(pmap, pmap->red, c, r, contig, ppixTemp, pmask);
+
+ if (ok)
+ {
+
+ /* all the allocated pixels are added to the client pixel list,
+ * but only the unique ones are returned to the client */
+ ppix = (Pixel *)xrealloc(pmap->clientPixelsRed[client],
+ (pmap->numPixelsRed[client] + npix) * sizeof(Pixel));
+ if (!ppix)
+ {
+ for (p = ppixTemp; p < ppixTemp + npix; p++)
+ pmap->red[*p].refcnt = 0;
+ return (BadAlloc);
+ }
+ pmap->clientPixelsRed[client] = ppix;
+ ppix += pmap->numPixelsRed[client];
+ *pppixFirst = ppix;
+ pDst = pixels;
+ for (p = ppixTemp; p < ppixTemp + npix; p++)
+ {
+ *ppix++ = *p;
+ if(p < ppixTemp + c)
+ *pDst++ = *p;
+ }
+ pmap->numPixelsRed[client] += npix;
+ pmap->freeRed -= npix;
+ }
+ DEALLOCATE_LOCAL(ppixTemp);
+ return (ok ? Success : BadAlloc);
+}
+
+/* Allocates count << planes pixels from colormap pmap for client. If
+ * contig, then the plane mask is made of consecutive bits. Returns
+ * all count << pixels in the array pixels. The first count of those
+ * pixels are the unique pixels. *pMask has the mask to Or with the
+ * unique pixels to get the rest of them.
+ *
+ * Returns True iff all pixels could be allocated
+ * All cells allocated will have refcnt set to AllocPrivate and shared to FALSE
+ * (see AllocShared for why we care)
+ */
+static Bool
+AllocCP (ColormapPtr pmap, EntryPtr pentFirst, int count, int planes,
+ Bool contig, Pixel *pixels, Pixel *pMask)
+{
+ EntryPtr ent;
+ Pixel pixel, base, entries, maxp, save;
+ int dplanes, found;
+ Pixel *ppix;
+ Pixel mask;
+ Pixel finalmask;
+
+ dplanes = pmap->pVisual->nplanes;
+
+ /* Easy case. Allocate pixels only */
+ if (planes == 0)
+ {
+ /* allocate writable entries */
+ ppix = pixels;
+ ent = pentFirst;
+ pixel = 0;
+ while (--count >= 0)
+ {
+ /* Just find count unallocated cells */
+ while (ent->refcnt)
+ {
+ ent++;
+ pixel++;
+ }
+ ent->refcnt = AllocPrivate;
+ *ppix++ = pixel;
+ ent->fShared = FALSE;
+ }
+ *pMask = 0;
+ return (TRUE);
+ }
+ else if (planes > dplanes)
+ {
+ return (FALSE);
+ }
+
+ /* General case count pixels * 2 ^ planes cells to be allocated */
+
+ /* make room for new pixels */
+ ent = pentFirst;
+
+ /* first try for contiguous planes, since it's fastest */
+ for (mask = (((Pixel)1) << planes) - 1, base = 1, dplanes -= (planes - 1);
+ --dplanes >= 0;
+ mask += mask, base += base)
+ {
+ ppix = pixels;
+ found = 0;
+ pixel = 0;
+ entries = pmap->pVisual->ColormapEntries - mask;
+ while (pixel < entries)
+ {
+ save = pixel;
+ maxp = pixel + mask + base;
+ /* check if all are free */
+ while (pixel != maxp && ent[pixel].refcnt == 0)
+ pixel += base;
+ if (pixel == maxp)
+ {
+ /* this one works */
+ *ppix++ = save;
+ found++;
+ if (found == count)
+ {
+ /* found enough, allocate them all */
+ while (--count >= 0)
+ {
+ pixel = pixels[count];
+ maxp = pixel + mask;
+ while (1)
+ {
+ ent[pixel].refcnt = AllocPrivate;
+ ent[pixel].fShared = FALSE;
+ if (pixel == maxp)
+ break;
+ pixel += base;
+ *ppix++ = pixel;
+ }
+ }
+ *pMask = mask;
+ return (TRUE);
+ }
+ }
+ pixel = save + 1;
+ if (pixel & mask)
+ pixel += mask;
+ }
+ }
+
+ dplanes = pmap->pVisual->nplanes;
+ if (contig || planes == 1 || dplanes < 3)
+ return (FALSE);
+
+ /* this will be very slow for large maps, need a better algorithm */
+
+ /*
+ we can generate the smallest and largest numbers that fits in dplanes
+ bits and contain exactly planes bits set as follows. First, we need to
+ check that it is possible to generate such a mask at all.
+ (Non-contiguous masks need one more bit than contiguous masks). Then
+ the smallest such mask consists of the rightmost planes-1 bits set, then
+ a zero, then a one in position planes + 1. The formula is
+ (3 << (planes-1)) -1
+ The largest such masks consists of the leftmost planes-1 bits set, then
+ a zero, then a one bit in position dplanes-planes-1. If dplanes is
+ smaller than 32 (the number of bits in a word) then the formula is:
+ (1<<dplanes) - (1<<(dplanes-planes+1) + (1<<dplanes-planes-1)
+ If dplanes = 32, then we can't calculate (1<<dplanes) and we have
+ to use:
+ ( (1<<(planes-1)) - 1) << (dplanes-planes+1) + (1<<(dplanes-planes-1))
+
+ << Thank you, Loretta>>>
+
+ */
+
+ finalmask =
+ (((((Pixel)1)<<(planes-1)) - 1) << (dplanes-planes+1)) +
+ (((Pixel)1)<<(dplanes-planes-1));
+ for (mask = (((Pixel)3) << (planes -1)) - 1; mask <= finalmask; mask++)
+ {
+ /* next 3 magic statements count number of ones (HAKMEM #169) */
+ pixel = (mask >> 1) & 033333333333;
+ pixel = mask - pixel - ((pixel >> 1) & 033333333333);
+ if ((((pixel + (pixel >> 3)) & 030707070707) % 077) != planes)
+ continue;
+ ppix = pixels;
+ found = 0;
+ entries = pmap->pVisual->ColormapEntries - mask;
+ base = lowbit (mask);
+ for (pixel = 0; pixel < entries; pixel++)
+ {
+ if (pixel & mask)
+ continue;
+ maxp = 0;
+ /* check if all are free */
+ while (ent[pixel + maxp].refcnt == 0)
+ {
+ GetNextBitsOrBreak(maxp, mask, base);
+ }
+ if ((maxp < mask) || (ent[pixel + mask].refcnt != 0))
+ continue;
+ /* this one works */
+ *ppix++ = pixel;
+ found++;
+ if (found < count)
+ continue;
+ /* found enough, allocate them all */
+ while (--count >= 0)
+ {
+ pixel = (pixels)[count];
+ maxp = 0;
+ while (1)
+ {
+ ent[pixel + maxp].refcnt = AllocPrivate;
+ ent[pixel + maxp].fShared = FALSE;
+ GetNextBitsOrBreak(maxp, mask, base);
+ *ppix++ = pixel + maxp;
+ }
+ }
+
+ *pMask = mask;
+ return (TRUE);
+ }
+ }
+ return (FALSE);
+}
+
+/**
+ *
+ * \param ppixFirst First of the client's new pixels
+ */
+static Bool
+AllocShared (ColormapPtr pmap, Pixel *ppix, int c, int r, int g, int b,
+ Pixel rmask, Pixel gmask, Pixel bmask, Pixel *ppixFirst)
+{
+ Pixel *pptr, *cptr;
+ int npix, z, npixClientNew, npixShared;
+ Pixel basemask, base, bits, common;
+ SHAREDCOLOR *pshared, **ppshared, **psharedList;
+
+ npixClientNew = c << (r + g + b);
+ npixShared = (c << r) + (c << g) + (c << b);
+ psharedList = (SHAREDCOLOR **)ALLOCATE_LOCAL(npixShared *
+ sizeof(SHAREDCOLOR *));
+ if (!psharedList)
+ return FALSE;
+ ppshared = psharedList;
+ for (z = npixShared; --z >= 0; )
+ {
+ if (!(ppshared[z] = (SHAREDCOLOR *)xalloc(sizeof(SHAREDCOLOR))))
+ {
+ for (z++ ; z < npixShared; z++)
+ xfree(ppshared[z]);
+ return FALSE;
+ }
+ }
+ for(pptr = ppix, npix = c; --npix >= 0; pptr++)
+ {
+ basemask = ~(gmask | bmask);
+ common = *pptr & basemask;
+ if (rmask)
+ {
+ bits = 0;
+ base = lowbit (rmask);
+ while(1)
+ {
+ pshared = *ppshared++;
+ pshared->refcnt = 1 << (g + b);
+ for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++)
+ {
+ if ((*cptr & basemask) == (common | bits))
+ {
+ pmap->red[*cptr].fShared = TRUE;
+ pmap->red[*cptr].co.shco.red = pshared;
+ }
+ }
+ GetNextBitsOrBreak(bits, rmask, base);
+ }
+ }
+ else
+ {
+ pshared = *ppshared++;
+ pshared->refcnt = 1 << (g + b);
+ for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++)
+ {
+ if ((*cptr & basemask) == common)
+ {
+ pmap->red[*cptr].fShared = TRUE;
+ pmap->red[*cptr].co.shco.red = pshared;
+ }
+ }
+ }
+ basemask = ~(rmask | bmask);
+ common = *pptr & basemask;
+ if (gmask)
+ {
+ bits = 0;
+ base = lowbit (gmask);
+ while(1)
+ {
+ pshared = *ppshared++;
+ pshared->refcnt = 1 << (r + b);
+ for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++)
+ {
+ if ((*cptr & basemask) == (common | bits))
+ {
+ pmap->red[*cptr].co.shco.green = pshared;
+ }
+ }
+ GetNextBitsOrBreak(bits, gmask, base);
+ }
+ }
+ else
+ {
+ pshared = *ppshared++;
+ pshared->refcnt = 1 << (g + b);
+ for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++)
+ {
+ if ((*cptr & basemask) == common)
+ {
+ pmap->red[*cptr].co.shco.green = pshared;
+ }
+ }
+ }
+ basemask = ~(rmask | gmask);
+ common = *pptr & basemask;
+ if (bmask)
+ {
+ bits = 0;
+ base = lowbit (bmask);
+ while(1)
+ {
+ pshared = *ppshared++;
+ pshared->refcnt = 1 << (r + g);
+ for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++)
+ {
+ if ((*cptr & basemask) == (common | bits))
+ {
+ pmap->red[*cptr].co.shco.blue = pshared;
+ }
+ }
+ GetNextBitsOrBreak(bits, bmask, base);
+ }
+ }
+ else
+ {
+ pshared = *ppshared++;
+ pshared->refcnt = 1 << (g + b);
+ for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++)
+ {
+ if ((*cptr & basemask) == common)
+ {
+ pmap->red[*cptr].co.shco.blue = pshared;
+ }
+ }
+ }
+ }
+ DEALLOCATE_LOCAL(psharedList);
+ return TRUE;
+}
+
+
+/** FreeColors
+ * Free colors and/or cells (probably slow for large numbers)
+ */
+int
+FreeColors (ColormapPtr pmap, int client, int count, Pixel *pixels, Pixel mask)
+{
+ int rval, result, class;
+ Pixel rmask;
+
+ class = pmap->class;
+ if (pmap->flags & AllAllocated)
+ return(BadAccess);
+ if ((class | DynamicClass) == DirectColor)
+ {
+ rmask = mask & RGBMASK(pmap->pVisual);
+ result = FreeCo(pmap, client, REDMAP, count, pixels,
+ mask & pmap->pVisual->redMask);
+ /* If any of the three calls fails, we must report that, if more
+ * than one fails, it's ok that we report the last one */
+ rval = FreeCo(pmap, client, GREENMAP, count, pixels,
+ mask & pmap->pVisual->greenMask);
+ if(rval != Success)
+ result = rval;
+ rval = FreeCo(pmap, client, BLUEMAP, count, pixels,
+ mask & pmap->pVisual->blueMask);
+ if(rval != Success)
+ result = rval;
+ }
+ else
+ {
+ rmask = mask & ((((Pixel)1) << pmap->pVisual->nplanes) - 1);
+ result = FreeCo(pmap, client, PSEUDOMAP, count, pixels, rmask);
+ }
+ if ((mask != rmask) && count)
+ {
+ clientErrorValue = *pixels | mask;
+ result = BadValue;
+ }
+ /* XXX should worry about removing any RT_CMAPENTRY resource */
+ return (result);
+}
+
+/**
+ * Helper for FreeColors -- frees all combinations of *newpixels and mask bits
+ * which the client has allocated in channel colormap cells of pmap.
+ * doesn't change newpixels if it doesn't need to
+ *
+ * \param pmap which colormap head
+ * \param color which sub-map, eg, RED, BLUE, PSEUDO
+ * \param npixIn number of pixels passed in
+ * \param ppixIn number of base pixels
+ * \param mask mask client gave us
+ */
+static int
+FreeCo (ColormapPtr pmap, int client, int color, int npixIn, Pixel *ppixIn, Pixel mask)
+{
+ Pixel *ppixClient, pixTest;
+ int npixClient, npixNew, npix;
+ Pixel bits, base, cmask, rgbbad;
+ Pixel *pptr, *cptr;
+ int n, zapped;
+ int errVal = Success;
+ int offset, numents;
+#ifdef LBX
+ Bool grabbed;
+ Bool zeroRefCount;
+ Bool anyRefCountReachedZero = 0;
+#endif
+
+ if (npixIn == 0)
+ return (errVal);
+ bits = 0;
+ zapped = 0;
+ base = lowbit (mask);
+
+ switch(color)
+ {
+ case REDMAP:
+ cmask = pmap->pVisual->redMask;
+ rgbbad = ~RGBMASK(pmap->pVisual);
+ offset = pmap->pVisual->offsetRed;
+ numents = (cmask >> offset) + 1;
+ ppixClient = pmap->clientPixelsRed[client];
+ npixClient = pmap->numPixelsRed[client];
+ break;
+ case GREENMAP:
+ cmask = pmap->pVisual->greenMask;
+ rgbbad = ~RGBMASK(pmap->pVisual);
+ offset = pmap->pVisual->offsetGreen;
+ numents = (cmask >> offset) + 1;
+ ppixClient = pmap->clientPixelsGreen[client];
+ npixClient = pmap->numPixelsGreen[client];
+ break;
+ case BLUEMAP:
+ cmask = pmap->pVisual->blueMask;
+ rgbbad = ~RGBMASK(pmap->pVisual);
+ offset = pmap->pVisual->offsetBlue;
+ numents = (cmask >> offset) + 1;
+ ppixClient = pmap->clientPixelsBlue[client];
+ npixClient = pmap->numPixelsBlue[client];
+ break;
+ default: /* so compiler can see that everything gets initialized */
+ case PSEUDOMAP:
+ cmask = ~((Pixel)0);
+ rgbbad = 0;
+ offset = 0;
+ numents = pmap->pVisual->ColormapEntries;
+ ppixClient = pmap->clientPixelsRed[client];
+ npixClient = pmap->numPixelsRed[client];
+ break;
+ }
+
+#ifdef LBX
+ grabbed = LbxCheckCmapGrabbed (pmap);
+
+ if (grabbed)
+ {
+ /*
+ * If the colormap is grabbed by a proxy, the server must
+ * notify the proxy of all cells that are freed (the refcount
+ * has reached zero on these cells).
+ */
+
+ LbxBeginFreeCellsEvent (pmap);
+ LbxSortPixelList (ppixIn, npixIn);
+ }
+#endif
+
+ /* zap all pixels which match */
+ while (1)
+ {
+ /* go through pixel list */
+ for (pptr = ppixIn, n = npixIn; --n >= 0; pptr++)
+ {
+ pixTest = ((*pptr | bits) & cmask) >> offset;
+ if ((pixTest >= numents) || (*pptr & rgbbad))
+ {
+ clientErrorValue = *pptr | bits;
+ errVal = BadValue;
+ continue;
+ }
+
+ /* find match in client list */
+ for (cptr = ppixClient, npix = npixClient;
+ --npix >= 0 && *cptr != pixTest;
+ cptr++) ;
+
+ if (npix >= 0)
+ {
+ if (pmap->class & DynamicClass)
+ {
+ FreeCell(pmap, pixTest, color);
+#ifdef LBX
+ /*
+ * Only PSEUDO colormaps are grabbed by LBX proxies.
+ * Check if the ref count reached zero on this pixel.
+ */
+
+ zeroRefCount = pmap->red[pixTest].refcnt == 0;
+ if (zeroRefCount)
+ anyRefCountReachedZero = 1;
+
+ if (grabbed && zeroRefCount)
+ LbxAddFreeCellToEvent (pmap, pixTest);
+#endif
+ }
+ *cptr = ~((Pixel)0);
+ zapped++;
+ }
+ else
+ errVal = BadAccess;
+ }
+ /* generate next bits value */
+ GetNextBitsOrBreak(bits, mask, base);
+ }
+
+#ifdef LBX
+ if (grabbed)
+ LbxEndFreeCellsEvent (pmap);
+ else if (anyRefCountReachedZero)
+ {
+ /*
+ * We only send LbxFreeCell events to a proxy that has the colormap
+ * grabbed. If the colormap is not grabbed, the proxy that last
+ * had the colormap grabbed will not be able to do a smart grab
+ * in the future. A smart grab can only occur if the proxy is kept
+ * up to date on every alloc/free change in the colormap.
+ */
+
+ LbxDisableSmartGrab (pmap);
+ }
+#endif
+
+ /* delete freed pixels from client pixel list */
+ if (zapped)
+ {
+ npixNew = npixClient - zapped;
+ if (npixNew)
+ {
+ /* Since the list can only get smaller, we can do a copy in
+ * place and then realloc to a smaller size */
+ pptr = cptr = ppixClient;
+
+ /* If we have all the new pixels, we don't have to examine the
+ * rest of the old ones */
+ for(npix = 0; npix < npixNew; cptr++)
+ {
+ if (*cptr != ~((Pixel)0))
+ {
+ *pptr++ = *cptr;
+ npix++;
+ }
+ }
+ pptr = (Pixel *)xrealloc(ppixClient, npixNew * sizeof(Pixel));
+ if (pptr)
+ ppixClient = pptr;
+ npixClient = npixNew;
+ }
+ else
+ {
+ npixClient = 0;
+ xfree(ppixClient);
+ ppixClient = (Pixel *)NULL;
+ }
+ switch(color)
+ {
+ case PSEUDOMAP:
+ case REDMAP:
+ pmap->clientPixelsRed[client] = ppixClient;
+ pmap->numPixelsRed[client] = npixClient;
+ break;
+ case GREENMAP:
+ pmap->clientPixelsGreen[client] = ppixClient;
+ pmap->numPixelsGreen[client] = npixClient;
+ break;
+ case BLUEMAP:
+ pmap->clientPixelsBlue[client] = ppixClient;
+ pmap->numPixelsBlue[client] = npixClient;
+ break;
+ }
+ }
+ return (errVal);
+}
+
+
+
+/* Redefine color values */
+int
+StoreColors (ColormapPtr pmap, int count, xColorItem *defs)
+{
+ register Pixel pix;
+ register xColorItem *pdef;
+ register EntryPtr pent, pentT, pentLast;
+ register VisualPtr pVisual;
+ SHAREDCOLOR *pred, *pgreen, *pblue;
+ int n, ChgRed, ChgGreen, ChgBlue, idef;
+ int class, errVal = Success;
+ int ok;
+
+
+ class = pmap->class;
+ if(!(class & DynamicClass) && !(pmap->flags & BeingCreated))
+ {
+ return(BadAccess);
+ }
+ pVisual = pmap->pVisual;
+
+ idef = 0;
+ if((class | DynamicClass) == DirectColor)
+ {
+ int numred, numgreen, numblue;
+ Pixel rgbbad;
+
+ numred = NUMRED(pVisual);
+ numgreen = NUMGREEN(pVisual);
+ numblue = NUMBLUE(pVisual);
+ rgbbad = ~RGBMASK(pVisual);
+ for (pdef = defs, n = 0; n < count; pdef++, n++)
+ {
+ ok = TRUE;
+ (*pmap->pScreen->ResolveColor)
+ (&pdef->red, &pdef->green, &pdef->blue, pmap->pVisual);
+
+ if (pdef->pixel & rgbbad)
+ {
+ errVal = BadValue;
+ clientErrorValue = pdef->pixel;
+ continue;
+ }
+ pix = (pdef->pixel & pVisual->redMask) >> pVisual->offsetRed;
+ if (pix >= numred)
+ {
+ errVal = BadValue;
+ ok = FALSE;
+ }
+ else if (pmap->red[pix].refcnt != AllocPrivate)
+ {
+ errVal = BadAccess;
+ ok = FALSE;
+ }
+ else if (pdef->flags & DoRed)
+ {
+ pmap->red[pix].co.local.red = pdef->red;
+ }
+ else
+ {
+ pdef->red = pmap->red[pix].co.local.red;
+ }
+
+ pix = (pdef->pixel & pVisual->greenMask) >> pVisual->offsetGreen;
+ if (pix >= numgreen)
+ {
+ errVal = BadValue;
+ ok = FALSE;
+ }
+ else if (pmap->green[pix].refcnt != AllocPrivate)
+ {
+ errVal = BadAccess;
+ ok = FALSE;
+ }
+ else if (pdef->flags & DoGreen)
+ {
+ pmap->green[pix].co.local.green = pdef->green;
+ }
+ else
+ {
+ pdef->green = pmap->green[pix].co.local.green;
+ }
+
+ pix = (pdef->pixel & pVisual->blueMask) >> pVisual->offsetBlue;
+ if (pix >= numblue)
+ {
+ errVal = BadValue;
+ ok = FALSE;
+ }
+ else if (pmap->blue[pix].refcnt != AllocPrivate)
+ {
+ errVal = BadAccess;
+ ok = FALSE;
+ }
+ else if (pdef->flags & DoBlue)
+ {
+ pmap->blue[pix].co.local.blue = pdef->blue;
+ }
+ else
+ {
+ pdef->blue = pmap->blue[pix].co.local.blue;
+ }
+ /* If this is an o.k. entry, then it gets added to the list
+ * to be sent to the hardware. If not, skip it. Once we've
+ * skipped one, we have to copy all the others.
+ */
+ if(ok)
+ {
+ if(idef != n)
+ defs[idef] = defs[n];
+ idef++;
+ } else
+ clientErrorValue = pdef->pixel;
+ }
+ }
+ else
+ {
+ for (pdef = defs, n = 0; n < count; pdef++, n++)
+ {
+
+ ok = TRUE;
+ if (pdef->pixel >= pVisual->ColormapEntries)
+ {
+ clientErrorValue = pdef->pixel;
+ errVal = BadValue;
+ ok = FALSE;
+ }
+ else if (pmap->red[pdef->pixel].refcnt != AllocPrivate)
+ {
+ errVal = BadAccess;
+ ok = FALSE;
+ }
+
+ /* If this is an o.k. entry, then it gets added to the list
+ * to be sent to the hardware. If not, skip it. Once we've
+ * skipped one, we have to copy all the others.
+ */
+ if(ok)
+ {
+ if(idef != n)
+ defs[idef] = defs[n];
+ idef++;
+ }
+ else
+ continue;
+
+ (*pmap->pScreen->ResolveColor)
+ (&pdef->red, &pdef->green, &pdef->blue, pmap->pVisual);
+
+ pent = &pmap->red[pdef->pixel];
+
+ if(pdef->flags & DoRed)
+ {
+ if(pent->fShared)
+ {
+ pent->co.shco.red->color = pdef->red;
+ if (pent->co.shco.red->refcnt > 1)
+ ok = FALSE;
+ }
+ else
+ pent->co.local.red = pdef->red;
+ }
+ else
+ {
+ if(pent->fShared)
+ pdef->red = pent->co.shco.red->color;
+ else
+ pdef->red = pent->co.local.red;
+ }
+ if(pdef->flags & DoGreen)
+ {
+ if(pent->fShared)
+ {
+ pent->co.shco.green->color = pdef->green;
+ if (pent->co.shco.green->refcnt > 1)
+ ok = FALSE;
+ }
+ else
+ pent->co.local.green = pdef->green;
+ }
+ else
+ {
+ if(pent->fShared)
+ pdef->green = pent->co.shco.green->color;
+ else
+ pdef->green = pent->co.local.green;
+ }
+ if(pdef->flags & DoBlue)
+ {
+ if(pent->fShared)
+ {
+ pent->co.shco.blue->color = pdef->blue;
+ if (pent->co.shco.blue->refcnt > 1)
+ ok = FALSE;
+ }
+ else
+ pent->co.local.blue = pdef->blue;
+ }
+ else
+ {
+ if(pent->fShared)
+ pdef->blue = pent->co.shco.blue->color;
+ else
+ pdef->blue = pent->co.local.blue;
+ }
+
+ if(!ok)
+ {
+ /* have to run through the colormap and change anybody who
+ * shares this value */
+ pred = pent->co.shco.red;
+ pgreen = pent->co.shco.green;
+ pblue = pent->co.shco.blue;
+ ChgRed = pdef->flags & DoRed;
+ ChgGreen = pdef->flags & DoGreen;
+ ChgBlue = pdef->flags & DoBlue;
+ pentLast = pmap->red + pVisual->ColormapEntries;
+
+ for(pentT = pmap->red; pentT < pentLast; pentT++)
+ {
+ if(pentT->fShared && (pentT != pent))
+ {
+ xColorItem defChg;
+
+ /* There are, alas, devices in this world too dumb
+ * to read their own hardware colormaps. Sick, but
+ * true. So we're going to be really nice and load
+ * the xColorItem with the proper value for all the
+ * fields. We will only set the flags for those
+ * fields that actually change. Smart devices can
+ * arrange to change only those fields. Dumb devices
+ * can rest assured that we have provided for them,
+ * and can change all three fields */
+
+ defChg.flags = 0;
+ if(ChgRed && pentT->co.shco.red == pred)
+ {
+ defChg.flags |= DoRed;
+ }
+ if(ChgGreen && pentT->co.shco.green == pgreen)
+ {
+ defChg.flags |= DoGreen;
+ }
+ if(ChgBlue && pentT->co.shco.blue == pblue)
+ {
+ defChg.flags |= DoBlue;
+ }
+ if(defChg.flags != 0)
+ {
+ defChg.pixel = pentT - pmap->red;
+ defChg.red = pentT->co.shco.red->color;
+ defChg.green = pentT->co.shco.green->color;
+ defChg.blue = pentT->co.shco.blue->color;
+ (*pmap->pScreen->StoreColors) (pmap, 1, &defChg);
+ }
+ }
+ }
+
+ }
+ }
+ }
+ /* Note that we use idef, the count of acceptable entries, and not
+ * count, the count of proposed entries */
+ if (idef != 0)
+ ( *pmap->pScreen->StoreColors) (pmap, idef, defs);
+ return (errVal);
+}
+
+int
+IsMapInstalled(Colormap map, WindowPtr pWin)
+{
+ Colormap *pmaps;
+ int imap, nummaps, found;
+
+ pmaps = (Colormap *) ALLOCATE_LOCAL(
+ pWin->drawable.pScreen->maxInstalledCmaps * sizeof(Colormap));
+ if(!pmaps)
+ return(FALSE);
+ nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps)
+ (pWin->drawable.pScreen, pmaps);
+ found = FALSE;
+ for(imap = 0; imap < nummaps; imap++)
+ {
+ if(pmaps[imap] == map)
+ {
+ found = TRUE;
+ break;
+ }
+ }
+ DEALLOCATE_LOCAL(pmaps);
+ return (found);
+}
diff --git a/nx-X11/programs/Xserver/dix/cursor.c b/nx-X11/programs/Xserver/dix/cursor.c
new file mode 100644
index 000000000..f4d6c6419
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/cursor.c
@@ -0,0 +1,459 @@
+/* $XFree86: xc/programs/Xserver/dix/cursor.c,v 3.8 2003/01/12 02:44:26 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+
+/* $Xorg: cursor.c,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "scrnintstr.h"
+#include "dixstruct.h"
+#include "cursorstr.h"
+#include "dixfontstr.h"
+#include "opaque.h"
+
+typedef struct _GlyphShare {
+ FontPtr font;
+ unsigned short sourceChar;
+ unsigned short maskChar;
+ CursorBitsPtr bits;
+ struct _GlyphShare *next;
+} GlyphShare, *GlyphSharePtr;
+
+static GlyphSharePtr sharedGlyphs = (GlyphSharePtr)NULL;
+
+#ifdef XFIXES
+static CARD32 cursorSerial;
+#endif
+
+static void
+FreeCursorBits(CursorBitsPtr bits)
+{
+ if (--bits->refcnt > 0)
+ return;
+ xfree(bits->source);
+ xfree(bits->mask);
+#ifdef ARGB_CURSOR
+ xfree(bits->argb);
+#endif
+ if (bits->refcnt == 0)
+ {
+ register GlyphSharePtr *prev, this;
+
+ for (prev = &sharedGlyphs;
+ (this = *prev) && (this->bits != bits);
+ prev = &this->next)
+ ;
+ if (this)
+ {
+ *prev = this->next;
+ CloseFont(this->font, (Font)0);
+ xfree(this);
+ }
+ xfree(bits);
+ }
+}
+
+/**
+ * To be called indirectly by DeleteResource; must use exactly two args.
+ *
+ * \param value must conform to DeleteType
+ */
+int
+FreeCursor(pointer value, XID cid)
+{
+ int nscr;
+ CursorPtr pCurs = (CursorPtr)value;
+
+ ScreenPtr pscr;
+
+ if ( --pCurs->refcnt > 0)
+ return(Success);
+
+ for (nscr = 0; nscr < screenInfo.numScreens; nscr++)
+ {
+ pscr = screenInfo.screens[nscr];
+ (void)( *pscr->UnrealizeCursor)( pscr, pCurs);
+ }
+ FreeCursorBits(pCurs->bits);
+ xfree( pCurs);
+ return(Success);
+}
+
+
+/*
+ * We check for empty cursors so that we won't have to display them
+ */
+static void
+CheckForEmptyMask(CursorBitsPtr bits)
+{
+ register unsigned char *msk = bits->mask;
+ int n = BitmapBytePad(bits->width) * bits->height;
+
+ bits->emptyMask = FALSE;
+ while(n--)
+ if(*(msk++) != 0) return;
+#ifdef ARGB_CURSOR
+ if (bits->argb)
+ {
+ CARD32 *argb = bits->argb;
+ int n = bits->width * bits->height;
+ while (n--)
+ if (*argb++ & 0xff000000) return;
+ }
+#endif
+ bits->emptyMask = TRUE;
+}
+
+/**
+ * does nothing about the resource table, just creates the data structure.
+ * does not copy the src and mask bits
+ *
+ * \param psrcbits server-defined padding
+ * \param pmaskbits server-defined padding
+ * \param argb no padding
+ */
+CursorPtr
+AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb,
+ CursorMetricPtr cm,
+ unsigned foreRed, unsigned foreGreen, unsigned foreBlue,
+ unsigned backRed, unsigned backGreen, unsigned backBlue)
+{
+ CursorBitsPtr bits;
+ CursorPtr pCurs;
+ int nscr;
+ ScreenPtr pscr;
+
+ pCurs = (CursorPtr)xalloc(sizeof(CursorRec) + sizeof(CursorBits));
+ if (!pCurs)
+ {
+ xfree(psrcbits);
+ xfree(pmaskbits);
+ return (CursorPtr)NULL;
+ }
+ bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec));
+ bits->source = psrcbits;
+ bits->mask = pmaskbits;
+#ifdef ARGB_CURSOR
+ bits->argb = argb;
+#endif
+ bits->width = cm->width;
+ bits->height = cm->height;
+ bits->xhot = cm->xhot;
+ bits->yhot = cm->yhot;
+ bits->refcnt = -1;
+ CheckForEmptyMask(bits);
+
+ pCurs->bits = bits;
+ pCurs->refcnt = 1;
+#ifdef XFIXES
+ pCurs->serialNumber = ++cursorSerial;
+ pCurs->name = None;
+#endif
+
+ pCurs->foreRed = foreRed;
+ pCurs->foreGreen = foreGreen;
+ pCurs->foreBlue = foreBlue;
+
+ pCurs->backRed = backRed;
+ pCurs->backGreen = backGreen;
+ pCurs->backBlue = backBlue;
+
+ /*
+ * realize the cursor for every screen
+ */
+ for (nscr = 0; nscr < screenInfo.numScreens; nscr++)
+ {
+ pscr = screenInfo.screens[nscr];
+ if (!( *pscr->RealizeCursor)( pscr, pCurs))
+ {
+ while (--nscr >= 0)
+ {
+ pscr = screenInfo.screens[nscr];
+ ( *pscr->UnrealizeCursor)( pscr, pCurs);
+ }
+ FreeCursorBits(bits);
+ xfree(pCurs);
+ return (CursorPtr)NULL;
+ }
+ }
+ return pCurs;
+}
+
+/**
+ *
+ * \param psrcbits server-defined padding
+ * \param pmaskbits server-defined padding
+ */
+CursorPtr
+AllocCursor(unsigned char *psrcbits, unsigned char *pmaskbits,
+ CursorMetricPtr cm,
+ unsigned foreRed, unsigned foreGreen, unsigned foreBlue,
+ unsigned backRed, unsigned backGreen, unsigned backBlue)
+{
+ return AllocCursorARGB (psrcbits, pmaskbits, (CARD32 *) 0, cm,
+ foreRed, foreGreen, foreBlue,
+ backRed, backGreen, backBlue);
+}
+
+int
+AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
+ unsigned foreRed, unsigned foreGreen, unsigned foreBlue,
+ unsigned backRed, unsigned backGreen, unsigned backBlue,
+ CursorPtr *ppCurs, ClientPtr client)
+{
+ FontPtr sourcefont, maskfont;
+ unsigned char *srcbits;
+ unsigned char *mskbits;
+ CursorMetricRec cm;
+ int res;
+ CursorBitsPtr bits;
+ CursorPtr pCurs;
+ int nscr;
+ ScreenPtr pscr;
+ GlyphSharePtr pShare;
+
+ sourcefont = (FontPtr) SecurityLookupIDByType(client, source, RT_FONT,
+ SecurityReadAccess);
+ maskfont = (FontPtr) SecurityLookupIDByType(client, mask, RT_FONT,
+ SecurityReadAccess);
+
+ if (!sourcefont)
+ {
+ client->errorValue = source;
+ return(BadFont);
+ }
+ if (!maskfont && (mask != None))
+ {
+ client->errorValue = mask;
+ return(BadFont);
+ }
+ if (sourcefont != maskfont)
+ pShare = (GlyphSharePtr)NULL;
+ else
+ {
+ for (pShare = sharedGlyphs;
+ pShare &&
+ ((pShare->font != sourcefont) ||
+ (pShare->sourceChar != sourceChar) ||
+ (pShare->maskChar != maskChar));
+ pShare = pShare->next)
+ ;
+ }
+ if (pShare)
+ {
+ pCurs = (CursorPtr)xalloc(sizeof(CursorRec));
+ if (!pCurs)
+ return BadAlloc;
+ bits = pShare->bits;
+ bits->refcnt++;
+ }
+ else
+ {
+ if (!CursorMetricsFromGlyph(sourcefont, sourceChar, &cm))
+ {
+ client->errorValue = sourceChar;
+ return BadValue;
+ }
+ if (!maskfont)
+ {
+ register long n;
+ register unsigned char *mskptr;
+
+ n = BitmapBytePad(cm.width)*(long)cm.height;
+ mskptr = mskbits = (unsigned char *)xalloc(n);
+ if (!mskptr)
+ return BadAlloc;
+ while (--n >= 0)
+ *mskptr++ = ~0;
+ }
+ else
+ {
+ if (!CursorMetricsFromGlyph(maskfont, maskChar, &cm))
+ {
+ client->errorValue = maskChar;
+ return BadValue;
+ }
+ if ((res = ServerBitsFromGlyph(maskfont, maskChar, &cm, &mskbits)) != 0)
+ return res;
+ }
+ if ((res = ServerBitsFromGlyph(sourcefont, sourceChar, &cm, &srcbits)) != 0)
+ {
+ xfree(mskbits);
+ return res;
+ }
+ if (sourcefont != maskfont)
+ {
+ pCurs = (CursorPtr)xalloc(sizeof(CursorRec) + sizeof(CursorBits));
+ if (pCurs)
+ bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec));
+ else
+ bits = (CursorBitsPtr)NULL;
+ }
+ else
+ {
+ pCurs = (CursorPtr)xalloc(sizeof(CursorRec));
+ if (pCurs)
+ bits = (CursorBitsPtr)xalloc(sizeof(CursorBits));
+ else
+ bits = (CursorBitsPtr)NULL;
+ }
+ if (!bits)
+ {
+ xfree(pCurs);
+ xfree(mskbits);
+ xfree(srcbits);
+ return BadAlloc;
+ }
+ bits->source = srcbits;
+ bits->mask = mskbits;
+#ifdef ARGB_CURSOR
+ bits->argb = 0;
+#endif
+ bits->width = cm.width;
+ bits->height = cm.height;
+ bits->xhot = cm.xhot;
+ bits->yhot = cm.yhot;
+ if (sourcefont != maskfont)
+ bits->refcnt = -1;
+ else
+ {
+ bits->refcnt = 1;
+ pShare = (GlyphSharePtr)xalloc(sizeof(GlyphShare));
+ if (!pShare)
+ {
+ FreeCursorBits(bits);
+ return BadAlloc;
+ }
+ pShare->font = sourcefont;
+ sourcefont->refcnt++;
+ pShare->sourceChar = sourceChar;
+ pShare->maskChar = maskChar;
+ pShare->bits = bits;
+ pShare->next = sharedGlyphs;
+ sharedGlyphs = pShare;
+ }
+ }
+ CheckForEmptyMask(bits);
+ pCurs->bits = bits;
+ pCurs->refcnt = 1;
+#ifdef XFIXES
+ pCurs->serialNumber = ++cursorSerial;
+ pCurs->name = None;
+#endif
+
+ pCurs->foreRed = foreRed;
+ pCurs->foreGreen = foreGreen;
+ pCurs->foreBlue = foreBlue;
+
+ pCurs->backRed = backRed;
+ pCurs->backGreen = backGreen;
+ pCurs->backBlue = backBlue;
+
+ /*
+ * realize the cursor for every screen
+ */
+ for (nscr = 0; nscr < screenInfo.numScreens; nscr++)
+ {
+ pscr = screenInfo.screens[nscr];
+ if (!( *pscr->RealizeCursor)( pscr, pCurs))
+ {
+ while (--nscr >= 0)
+ {
+ pscr = screenInfo.screens[nscr];
+ ( *pscr->UnrealizeCursor)( pscr, pCurs);
+ }
+ FreeCursorBits(pCurs->bits);
+ xfree(pCurs);
+ return BadAlloc;
+ }
+ }
+ *ppCurs = pCurs;
+ return Success;
+}
+
+/** CreateRootCursor
+ *
+ * look up the name of a font
+ * open the font
+ * add the font to the resource table
+ * make a cursor from the glyphs
+ * add the cursor to the resource table
+ *************************************************************/
+
+CursorPtr
+CreateRootCursor(char *pfilename, unsigned glyph)
+{
+ CursorPtr curs;
+ FontPtr cursorfont;
+ int err;
+ XID fontID;
+
+ fontID = FakeClientID(0);
+ err = OpenFont(serverClient, fontID, FontLoadAll | FontOpenSync,
+ (unsigned)strlen( pfilename), pfilename);
+ if (err != Success)
+ return NullCursor;
+
+ cursorfont = (FontPtr)LookupIDByType(fontID, RT_FONT);
+ if (!cursorfont)
+ return NullCursor;
+ if (AllocGlyphCursor(fontID, glyph, fontID, glyph + 1,
+ 0, 0, 0, ~0, ~0, ~0, &curs, serverClient) != Success)
+ return NullCursor;
+
+ if (!AddResource(FakeClientID(0), RT_CURSOR, (pointer)curs))
+ return NullCursor;
+
+ return curs;
+}
diff --git a/nx-X11/programs/Xserver/dix/devices.c b/nx-X11/programs/Xserver/dix/devices.c
new file mode 100644
index 000000000..e26879f28
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/devices.c
@@ -0,0 +1,1665 @@
+/* $XFree86: xc/programs/Xserver/dix/devices.c,v 3.20 2001/12/14 19:59:30 dawes Exp $ */
+/************************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+
+/* $Xorg: devices.c,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $ */
+/* $XdotOrg: xc/programs/Xserver/dix/devices.c,v 1.8 2005/07/03 08:53:38 daniels Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "resource.h"
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#include "windowstr.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "cursorstr.h"
+#include "dixstruct.h"
+#include "site.h"
+#define XKB_IN_SERVER
+#ifdef XKB
+#include <X11/extensions/XKBsrv.h>
+#endif
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+#ifdef LBX
+#include "lbxserve.h"
+#endif
+
+#include "dispatch.h"
+#include "swaprep.h"
+#include "dixevents.h"
+
+DeviceIntPtr
+_AddInputDevice(DeviceProc deviceProc, Bool autoStart)
+{
+ register DeviceIntPtr dev;
+
+ if (inputInfo.numDevices >= MAX_DEVICES)
+ return (DeviceIntPtr)NULL;
+ dev = (DeviceIntPtr) xalloc(sizeof(DeviceIntRec));
+ if (!dev)
+ return (DeviceIntPtr)NULL;
+ dev->name = (char *)NULL;
+ dev->type = 0;
+ dev->id = inputInfo.numDevices;
+ inputInfo.numDevices++;
+ dev->public.on = FALSE;
+ dev->public.processInputProc = (ProcessInputProc)NoopDDA;
+ dev->public.realInputProc = (ProcessInputProc)NoopDDA;
+ dev->public.enqueueInputProc = EnqueueEvent;
+ dev->deviceProc = deviceProc;
+ dev->startup = autoStart;
+ dev->sync.frozen = FALSE;
+ dev->sync.other = NullGrab;
+ dev->sync.state = NOT_GRABBED;
+ dev->sync.event = (xEvent *) NULL;
+ dev->sync.evcount = 0;
+ dev->grab = NullGrab;
+ dev->grabTime = currentTime;
+ dev->fromPassiveGrab = FALSE;
+ dev->key = (KeyClassPtr)NULL;
+ dev->valuator = (ValuatorClassPtr)NULL;
+ dev->button = (ButtonClassPtr)NULL;
+ dev->focus = (FocusClassPtr)NULL;
+ dev->proximity = (ProximityClassPtr)NULL;
+ dev->kbdfeed = (KbdFeedbackPtr)NULL;
+ dev->ptrfeed = (PtrFeedbackPtr)NULL;
+ dev->intfeed = (IntegerFeedbackPtr)NULL;
+ dev->stringfeed = (StringFeedbackPtr)NULL;
+ dev->bell = (BellFeedbackPtr)NULL;
+ dev->leds = (LedFeedbackPtr)NULL;
+ dev->next = inputInfo.off_devices;
+#ifdef XKB
+ dev->xkb_interest= NULL;
+#endif
+ dev->nPrivates = 0;
+ dev->devPrivates = dev->unwrapProc = NULL;
+ inputInfo.off_devices = dev;
+ return dev;
+}
+
+Bool
+EnableDevice(register DeviceIntPtr dev)
+{
+ register DeviceIntPtr *prev;
+
+ for (prev = &inputInfo.off_devices;
+ *prev && (*prev != dev);
+ prev = &(*prev)->next)
+ ;
+ if ((*prev != dev) || !dev->inited ||
+ ((*dev->deviceProc)(dev, DEVICE_ON) != Success))
+ return FALSE;
+ *prev = dev->next;
+ dev->next = inputInfo.devices;
+ inputInfo.devices = dev;
+ return TRUE;
+}
+
+Bool
+DisableDevice(register DeviceIntPtr dev)
+{
+ register DeviceIntPtr *prev;
+
+ for (prev = &inputInfo.devices;
+ *prev && (*prev != dev);
+ prev = &(*prev)->next)
+ ;
+ if (*prev != dev)
+ return FALSE;
+ (void)(*dev->deviceProc)(dev, DEVICE_OFF);
+ *prev = dev->next;
+ dev->next = inputInfo.off_devices;
+ inputInfo.off_devices = dev;
+ return TRUE;
+}
+
+int
+InitAndStartDevices()
+{
+ register DeviceIntPtr dev, next;
+
+ for (dev = inputInfo.off_devices; dev; dev = dev->next)
+ dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
+ for (dev = inputInfo.off_devices; dev; dev = next)
+ {
+ next = dev->next;
+ if (dev->inited && dev->startup)
+ (void)EnableDevice(dev);
+ }
+ for (dev = inputInfo.devices;
+ dev && (dev != inputInfo.keyboard);
+ dev = dev->next)
+ ;
+ if (!dev || (dev != inputInfo.keyboard)) {
+ ErrorF("No core keyboard\n");
+ return BadImplementation;
+ }
+ for (dev = inputInfo.devices;
+ dev && (dev != inputInfo.pointer);
+ dev = dev->next)
+ ;
+ if (!dev || (dev != inputInfo.pointer)) {
+ ErrorF("No core pointer\n");
+ return BadImplementation;
+ }
+ return Success;
+}
+
+static void
+CloseDevice(register DeviceIntPtr dev)
+{
+ KbdFeedbackPtr k, knext;
+ PtrFeedbackPtr p, pnext;
+ IntegerFeedbackPtr i, inext;
+ StringFeedbackPtr s, snext;
+ BellFeedbackPtr b, bnext;
+ LedFeedbackPtr l, lnext;
+
+ if (dev->inited)
+ (void)(*dev->deviceProc)(dev, DEVICE_CLOSE);
+ xfree(dev->name);
+ if (dev->key)
+ {
+#ifdef XKB
+ if (dev->key->xkbInfo)
+ XkbFreeInfo(dev->key->xkbInfo);
+#endif
+ xfree(dev->key->curKeySyms.map);
+ xfree(dev->key->modifierKeyMap);
+ xfree(dev->key);
+ }
+ xfree(dev->valuator);
+#ifdef XKB
+ if ((dev->button)&&(dev->button->xkb_acts))
+ xfree(dev->button->xkb_acts);
+#endif
+ xfree(dev->button);
+ if (dev->focus)
+ {
+ xfree(dev->focus->trace);
+ xfree(dev->focus);
+ }
+ xfree(dev->proximity);
+ for (k=dev->kbdfeed; k; k=knext)
+ {
+ knext = k->next;
+#ifdef XKB
+ if (k->xkb_sli)
+ XkbFreeSrvLedInfo(k->xkb_sli);
+#endif
+ xfree(k);
+ }
+ for (p=dev->ptrfeed; p; p=pnext)
+ {
+ pnext = p->next;
+ xfree(p);
+ }
+ for (i=dev->intfeed; i; i=inext)
+ {
+ inext = i->next;
+ xfree(i);
+ }
+ for (s=dev->stringfeed; s; s=snext)
+ {
+ snext = s->next;
+ xfree(s->ctrl.symbols_supported);
+ xfree(s->ctrl.symbols_displayed);
+ xfree(s);
+ }
+ for (b=dev->bell; b; b=bnext)
+ {
+ bnext = b->next;
+ xfree(b);
+ }
+ for (l=dev->leds; l; l=lnext)
+ {
+ lnext = l->next;
+#ifdef XKB
+ if (l->xkb_sli)
+ XkbFreeSrvLedInfo(l->xkb_sli);
+#endif
+ xfree(l);
+ }
+#ifdef XKB
+ while (dev->xkb_interest) {
+ XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource);
+ }
+#endif
+ xfree(dev->sync.event);
+ xfree(dev);
+}
+
+void
+CloseDownDevices()
+{
+ register DeviceIntPtr dev, next;
+
+ for (dev = inputInfo.devices; dev; dev = next)
+ {
+ next = dev->next;
+ CloseDevice(dev);
+ }
+ for (dev = inputInfo.off_devices; dev; dev = next)
+ {
+ next = dev->next;
+ CloseDevice(dev);
+ }
+ inputInfo.devices = NULL;
+ inputInfo.off_devices = NULL;
+ inputInfo.keyboard = NULL;
+ inputInfo.pointer = NULL;
+}
+
+void
+RemoveDevice(register DeviceIntPtr dev)
+{
+ register DeviceIntPtr prev,tmp,next;
+
+ prev= NULL;
+ for (tmp= inputInfo.devices; tmp; (prev = tmp), (tmp = next)) {
+ next = tmp->next;
+ if (tmp==dev) {
+ CloseDevice(tmp);
+ if (prev==NULL)
+ inputInfo.devices = next;
+ else
+ prev->next = next;
+ inputInfo.numDevices--;
+ if (inputInfo.keyboard == tmp)
+ inputInfo.keyboard = NULL;
+ else if (inputInfo.pointer == tmp)
+ inputInfo.pointer = NULL;
+ return;
+ }
+ }
+
+ prev= NULL;
+ for (tmp= inputInfo.off_devices; tmp; (prev = tmp), (tmp = next)) {
+ next = tmp->next;
+ if (tmp==dev) {
+ CloseDevice(tmp);
+ if (prev==NULL)
+ inputInfo.off_devices = next;
+ else
+ prev->next = next;
+ inputInfo.numDevices--;
+ if (inputInfo.keyboard == tmp)
+ inputInfo.keyboard = NULL;
+ else if (inputInfo.pointer == tmp)
+ inputInfo.pointer = NULL;
+ return;
+ }
+ }
+ ErrorF("Internal Error! Attempt to remove a non-existent device\n");
+ return;
+}
+
+int
+NumMotionEvents()
+{
+ return inputInfo.pointer->valuator->numMotionEvents;
+}
+
+void
+_RegisterPointerDevice(DeviceIntPtr device)
+{
+ inputInfo.pointer = device;
+#ifdef XKB
+ device->public.processInputProc = CoreProcessPointerEvent;
+ device->public.realInputProc = CoreProcessPointerEvent;
+ if (!noXkbExtension)
+ XkbSetExtension(device,ProcessPointerEvent);
+#else
+ device->public.processInputProc = ProcessPointerEvent;
+ device->public.realInputProc = ProcessPointerEvent;
+#endif
+ device->ActivateGrab = ActivatePointerGrab;
+ device->DeactivateGrab = DeactivatePointerGrab;
+ if (!device->name)
+ {
+ char *p = "pointer";
+ device->name = (char *)xalloc(strlen(p) + 1);
+ strcpy(device->name, p);
+ }
+}
+
+void
+_RegisterKeyboardDevice(DeviceIntPtr device)
+{
+ inputInfo.keyboard = device;
+#ifdef XKB
+ device->public.processInputProc = CoreProcessKeyboardEvent;
+ device->public.realInputProc = CoreProcessKeyboardEvent;
+ if (!noXkbExtension)
+ XkbSetExtension(device,ProcessKeyboardEvent);
+#else
+ device->public.processInputProc = ProcessKeyboardEvent;
+ device->public.realInputProc = ProcessKeyboardEvent;
+#endif
+ device->ActivateGrab = ActivateKeyboardGrab;
+ device->DeactivateGrab = DeactivateKeyboardGrab;
+ if (!device->name)
+ {
+ char *k = "keyboard";
+ device->name = (char *)xalloc(strlen(k) + 1);
+ strcpy(device->name, k);
+ }
+}
+
+DevicePtr
+LookupKeyboardDevice()
+{
+ return inputInfo.keyboard ? &inputInfo.keyboard->public : NULL;
+}
+
+DevicePtr
+LookupPointerDevice()
+{
+ return inputInfo.pointer ? &inputInfo.pointer->public : NULL;
+}
+
+DevicePtr
+LookupDevice(int id)
+{
+ DeviceIntPtr dev;
+
+ for (dev=inputInfo.devices; dev; dev=dev->next) {
+ if (dev->id == (CARD8)id)
+ return (DevicePtr)dev;
+ }
+ for (dev=inputInfo.off_devices; dev; dev=dev->next) {
+ if (dev->id == (CARD8)id)
+ return (DevicePtr)dev;
+ }
+ return NULL;
+}
+
+void
+QueryMinMaxKeyCodes(KeyCode *minCode, KeyCode *maxCode)
+{
+ if (inputInfo.keyboard) {
+ *minCode = inputInfo.keyboard->key->curKeySyms.minKeyCode;
+ *maxCode = inputInfo.keyboard->key->curKeySyms.maxKeyCode;
+ }
+}
+
+Bool
+SetKeySymsMap(register KeySymsPtr dst, register KeySymsPtr src)
+{
+ int i, j;
+ int rowDif = src->minKeyCode - dst->minKeyCode;
+ /* if keysym map size changes, grow map first */
+
+ if (src->mapWidth < dst->mapWidth)
+ {
+ for (i = src->minKeyCode; i <= src->maxKeyCode; i++)
+ {
+#define SI(r, c) (((r-src->minKeyCode)*src->mapWidth) + (c))
+#define DI(r, c) (((r - dst->minKeyCode)*dst->mapWidth) + (c))
+ for (j = 0; j < src->mapWidth; j++)
+ dst->map[DI(i, j)] = src->map[SI(i, j)];
+ for (j = src->mapWidth; j < dst->mapWidth; j++)
+ dst->map[DI(i, j)] = NoSymbol;
+#undef SI
+#undef DI
+ }
+ return TRUE;
+ }
+ else if (src->mapWidth > dst->mapWidth)
+ {
+ KeySym *map;
+ int bytes = sizeof(KeySym) * src->mapWidth *
+ (dst->maxKeyCode - dst->minKeyCode + 1);
+ map = (KeySym *)xalloc(bytes);
+ if (!map)
+ return FALSE;
+ bzero((char *)map, bytes);
+ if (dst->map)
+ {
+ for (i = 0; i <= dst->maxKeyCode-dst->minKeyCode; i++)
+ memmove((char *)&map[i*src->mapWidth],
+ (char *)&dst->map[i*dst->mapWidth],
+ dst->mapWidth * sizeof(KeySym));
+ xfree(dst->map);
+ }
+ dst->mapWidth = src->mapWidth;
+ dst->map = map;
+ }
+ memmove((char *)&dst->map[rowDif * dst->mapWidth],
+ (char *)src->map,
+ (int)(src->maxKeyCode - src->minKeyCode + 1) *
+ dst->mapWidth * sizeof(KeySym));
+ return TRUE;
+}
+
+static Bool
+InitModMap(register KeyClassPtr keyc)
+{
+ int i, j;
+ CARD8 keysPerModifier[8];
+ CARD8 mask;
+
+ keyc->maxKeysPerModifier = 0;
+ for (i = 0; i < 8; i++)
+ keysPerModifier[i] = 0;
+ for (i = 8; i < MAP_LENGTH; i++)
+ {
+ for (j = 0, mask = 1; j < 8; j++, mask <<= 1)
+ {
+ if (mask & keyc->modifierMap[i])
+ {
+ if (++keysPerModifier[j] > keyc->maxKeysPerModifier)
+ keyc->maxKeysPerModifier = keysPerModifier[j];
+ }
+ }
+ }
+ keyc->modifierKeyMap = (KeyCode *)xalloc(8*keyc->maxKeysPerModifier);
+ if (!keyc->modifierKeyMap && keyc->maxKeysPerModifier)
+ return (FALSE);
+ bzero((char *)keyc->modifierKeyMap, 8*(int)keyc->maxKeysPerModifier);
+ for (i = 0; i < 8; i++)
+ keysPerModifier[i] = 0;
+ for (i = 8; i < MAP_LENGTH; i++)
+ {
+ for (j = 0, mask = 1; j < 8; j++, mask <<= 1)
+ {
+ if (mask & keyc->modifierMap[i])
+ {
+ keyc->modifierKeyMap[(j*keyc->maxKeysPerModifier) +
+ keysPerModifier[j]] = i;
+ keysPerModifier[j]++;
+ }
+ }
+ }
+ return TRUE;
+}
+
+Bool
+InitKeyClassDeviceStruct(DeviceIntPtr dev, KeySymsPtr pKeySyms, CARD8 pModifiers[])
+{
+ int i;
+ register KeyClassPtr keyc;
+
+ keyc = (KeyClassPtr)xalloc(sizeof(KeyClassRec));
+ if (!keyc)
+ return FALSE;
+ keyc->curKeySyms.map = (KeySym *)NULL;
+ keyc->curKeySyms.mapWidth = 0;
+ keyc->curKeySyms.minKeyCode = pKeySyms->minKeyCode;
+ keyc->curKeySyms.maxKeyCode = pKeySyms->maxKeyCode;
+ keyc->modifierKeyMap = (KeyCode *)NULL;
+ keyc->state = 0;
+ keyc->prev_state = 0;
+ if (pModifiers)
+ memmove((char *)keyc->modifierMap, (char *)pModifiers, MAP_LENGTH);
+ else
+ bzero((char *)keyc->modifierMap, MAP_LENGTH);
+ bzero((char *)keyc->down, DOWN_LENGTH);
+ for (i = 0; i < 8; i++)
+ keyc->modifierKeyCount[i] = 0;
+ if (!SetKeySymsMap(&keyc->curKeySyms, pKeySyms) || !InitModMap(keyc))
+ {
+ xfree(keyc->curKeySyms.map);
+ xfree(keyc->modifierKeyMap);
+ xfree(keyc);
+ return FALSE;
+ }
+ dev->key = keyc;
+#ifdef XKB
+ dev->key->xkbInfo= NULL;
+ if (!noXkbExtension) XkbInitDevice(dev);
+#endif
+ return TRUE;
+}
+
+Bool
+InitButtonClassDeviceStruct(register DeviceIntPtr dev, int numButtons,
+ CARD8 *map)
+{
+ register ButtonClassPtr butc;
+ int i;
+
+ butc = (ButtonClassPtr)xalloc(sizeof(ButtonClassRec));
+ if (!butc)
+ return FALSE;
+ butc->numButtons = numButtons;
+ for (i = 1; i <= numButtons; i++)
+ butc->map[i] = map[i];
+ butc->buttonsDown = 0;
+ butc->state = 0;
+ butc->motionMask = 0;
+ bzero((char *)butc->down, DOWN_LENGTH);
+#ifdef XKB
+ butc->xkb_acts= NULL;
+#endif
+ dev->button = butc;
+ return TRUE;
+}
+
+Bool
+InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes,
+ ValuatorMotionProcPtr motionProc,
+ int numMotionEvents, int mode)
+{
+ int i;
+ register ValuatorClassPtr valc;
+
+ valc = (ValuatorClassPtr)xalloc(sizeof(ValuatorClassRec) +
+ numAxes * sizeof(AxisInfo) +
+ numAxes * sizeof(unsigned int));
+ if (!valc)
+ return FALSE;
+ valc->GetMotionProc = motionProc;
+ valc->numMotionEvents = numMotionEvents;
+ valc->motionHintWindow = NullWindow;
+ valc->numAxes = numAxes;
+ valc->mode = mode;
+ valc->axes = (AxisInfoPtr)(valc + 1);
+ valc->axisVal = (int *)(valc->axes + numAxes);
+ for (i=0; i<numAxes; i++)
+ valc->axisVal[i]=0;
+ dev->valuator = valc;
+ return TRUE;
+}
+
+Bool
+InitFocusClassDeviceStruct(DeviceIntPtr dev)
+{
+ register FocusClassPtr focc;
+
+ focc = (FocusClassPtr)xalloc(sizeof(FocusClassRec));
+ if (!focc)
+ return FALSE;
+ focc->win = PointerRootWin;
+ focc->revert = None;
+ focc->time = currentTime;
+ focc->trace = (WindowPtr *)NULL;
+ focc->traceSize = 0;
+ focc->traceGood = 0;
+ dev->focus = focc;
+ return TRUE;
+}
+
+Bool
+InitKbdFeedbackClassDeviceStruct(DeviceIntPtr dev, BellProcPtr bellProc,
+ KbdCtrlProcPtr controlProc)
+{
+ register KbdFeedbackPtr feedc;
+
+ feedc = (KbdFeedbackPtr)xalloc(sizeof(KbdFeedbackClassRec));
+ if (!feedc)
+ return FALSE;
+ feedc->BellProc = bellProc;
+ feedc->CtrlProc = controlProc;
+#ifdef XKB
+ defaultKeyboardControl.autoRepeat = TRUE;
+#endif
+ feedc->ctrl = defaultKeyboardControl;
+ feedc->ctrl.id = 0;
+ if ((feedc->next = dev->kbdfeed) != 0)
+ feedc->ctrl.id = dev->kbdfeed->ctrl.id + 1;
+ dev->kbdfeed = feedc;
+#ifdef XKB
+ feedc->xkb_sli= NULL;
+ if (!noXkbExtension)
+ XkbFinishDeviceInit(dev);
+#endif
+ (*dev->kbdfeed->CtrlProc)(dev,&dev->kbdfeed->ctrl);
+ return TRUE;
+}
+
+Bool
+InitPtrFeedbackClassDeviceStruct(DeviceIntPtr dev, PtrCtrlProcPtr controlProc)
+{
+ register PtrFeedbackPtr feedc;
+
+ feedc = (PtrFeedbackPtr)xalloc(sizeof(PtrFeedbackClassRec));
+ if (!feedc)
+ return FALSE;
+ feedc->CtrlProc = controlProc;
+#ifdef sgi
+ feedc->ctrl.num = 1;
+ feedc->ctrl.den = 1;
+ feedc->ctrl.threshold = 1;
+#else
+ feedc->ctrl = defaultPointerControl;
+#endif
+ feedc->ctrl.id = 0;
+ if ( (feedc->next = dev->ptrfeed) )
+ feedc->ctrl.id = dev->ptrfeed->ctrl.id + 1;
+ dev->ptrfeed = feedc;
+ (*controlProc)(dev, &feedc->ctrl);
+ return TRUE;
+}
+
+
+LedCtrl defaultLedControl = {
+ DEFAULT_LEDS, DEFAULT_LEDS_MASK, 0};
+
+BellCtrl defaultBellControl = {
+ DEFAULT_BELL,
+ DEFAULT_BELL_PITCH,
+ DEFAULT_BELL_DURATION,
+ 0};
+
+IntegerCtrl defaultIntegerControl = {
+ DEFAULT_INT_RESOLUTION,
+ DEFAULT_INT_MIN_VALUE,
+ DEFAULT_INT_MAX_VALUE,
+ DEFAULT_INT_DISPLAYED,
+ 0};
+
+Bool
+InitStringFeedbackClassDeviceStruct (
+ DeviceIntPtr dev, StringCtrlProcPtr controlProc,
+ int max_symbols, int num_symbols_supported, KeySym *symbols)
+{
+ int i;
+ register StringFeedbackPtr feedc;
+
+ feedc = (StringFeedbackPtr)xalloc(sizeof(StringFeedbackClassRec));
+ if (!feedc)
+ return FALSE;
+ feedc->CtrlProc = controlProc;
+ feedc->ctrl.num_symbols_supported = num_symbols_supported;
+ feedc->ctrl.num_symbols_displayed = 0;
+ feedc->ctrl.max_symbols = max_symbols;
+ feedc->ctrl.symbols_supported = (KeySym *)
+ xalloc (sizeof (KeySym) * num_symbols_supported);
+ feedc->ctrl.symbols_displayed = (KeySym *)
+ xalloc (sizeof (KeySym) * max_symbols);
+ if (!feedc->ctrl.symbols_supported || !feedc->ctrl.symbols_displayed)
+ {
+ if (feedc->ctrl.symbols_supported)
+ xfree(feedc->ctrl.symbols_supported);
+ if (feedc->ctrl.symbols_displayed)
+ xfree(feedc->ctrl.symbols_displayed);
+ xfree(feedc);
+ return FALSE;
+ }
+ for (i=0; i<num_symbols_supported; i++)
+ *(feedc->ctrl.symbols_supported+i) = *symbols++;
+ for (i=0; i<max_symbols; i++)
+ *(feedc->ctrl.symbols_displayed+i) = (KeySym) NULL;
+ feedc->ctrl.id = 0;
+ if ( (feedc->next = dev->stringfeed) )
+ feedc->ctrl.id = dev->stringfeed->ctrl.id + 1;
+ dev->stringfeed = feedc;
+ (*controlProc)(dev, &feedc->ctrl);
+ return TRUE;
+}
+
+Bool
+InitBellFeedbackClassDeviceStruct (DeviceIntPtr dev, BellProcPtr bellProc,
+ BellCtrlProcPtr controlProc)
+{
+ register BellFeedbackPtr feedc;
+
+ feedc = (BellFeedbackPtr)xalloc(sizeof(BellFeedbackClassRec));
+ if (!feedc)
+ return FALSE;
+ feedc->CtrlProc = controlProc;
+ feedc->BellProc = bellProc;
+ feedc->ctrl = defaultBellControl;
+ feedc->ctrl.id = 0;
+ if ( (feedc->next = dev->bell) )
+ feedc->ctrl.id = dev->bell->ctrl.id + 1;
+ dev->bell = feedc;
+ (*controlProc)(dev, &feedc->ctrl);
+ return TRUE;
+}
+
+Bool
+InitLedFeedbackClassDeviceStruct (DeviceIntPtr dev, LedCtrlProcPtr controlProc)
+{
+ register LedFeedbackPtr feedc;
+
+ feedc = (LedFeedbackPtr)xalloc(sizeof(LedFeedbackClassRec));
+ if (!feedc)
+ return FALSE;
+ feedc->CtrlProc = controlProc;
+ feedc->ctrl = defaultLedControl;
+ feedc->ctrl.id = 0;
+ if ( (feedc->next = dev->leds) )
+ feedc->ctrl.id = dev->leds->ctrl.id + 1;
+#ifdef XKB
+ feedc->xkb_sli= NULL;
+#endif
+ dev->leds = feedc;
+ (*controlProc)(dev, &feedc->ctrl);
+ return TRUE;
+}
+
+Bool
+InitIntegerFeedbackClassDeviceStruct (DeviceIntPtr dev, IntegerCtrlProcPtr controlProc)
+{
+ register IntegerFeedbackPtr feedc;
+
+ feedc = (IntegerFeedbackPtr)xalloc(sizeof(IntegerFeedbackClassRec));
+ if (!feedc)
+ return FALSE;
+ feedc->CtrlProc = controlProc;
+ feedc->ctrl = defaultIntegerControl;
+ feedc->ctrl.id = 0;
+ if ( (feedc->next = dev->intfeed) )
+ feedc->ctrl.id = dev->intfeed->ctrl.id + 1;
+ dev->intfeed = feedc;
+ (*controlProc)(dev, &feedc->ctrl);
+ return TRUE;
+}
+
+Bool
+InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons,
+ ValuatorMotionProcPtr motionProc,
+ PtrCtrlProcPtr controlProc, int numMotionEvents)
+{
+ DeviceIntPtr dev = (DeviceIntPtr)device;
+
+ return(InitButtonClassDeviceStruct(dev, numButtons, map) &&
+ InitValuatorClassDeviceStruct(dev, 2, motionProc,
+ numMotionEvents, 0) &&
+ InitPtrFeedbackClassDeviceStruct(dev, controlProc));
+}
+
+Bool
+InitKeyboardDeviceStruct(DevicePtr device, KeySymsPtr pKeySyms,
+ CARD8 pModifiers[], BellProcPtr bellProc,
+ KbdCtrlProcPtr controlProc)
+{
+ DeviceIntPtr dev = (DeviceIntPtr)device;
+
+ return(InitKeyClassDeviceStruct(dev, pKeySyms, pModifiers) &&
+ InitFocusClassDeviceStruct(dev) &&
+ InitKbdFeedbackClassDeviceStruct(dev, bellProc, controlProc));
+}
+
+void
+SendMappingNotify(unsigned request, unsigned firstKeyCode, unsigned count,
+ ClientPtr client)
+{
+ int i;
+ xEvent event;
+
+ event.u.u.type = MappingNotify;
+ event.u.mappingNotify.request = request;
+ if (request == MappingKeyboard)
+ {
+ event.u.mappingNotify.firstKeyCode = firstKeyCode;
+ event.u.mappingNotify.count = count;
+ }
+#ifdef XKB
+ if (!noXkbExtension &&
+ ((request == MappingKeyboard) || (request == MappingModifier))) {
+ XkbApplyMappingChange(inputInfo.keyboard,request,firstKeyCode,count,
+ client);
+ }
+#endif
+
+ /* 0 is the server client */
+ for (i=1; i<currentMaxClients; i++)
+ {
+ if (clients[i] && clients[i]->clientState == ClientStateRunning)
+ {
+#ifdef XKB
+ if (!noXkbExtension &&
+ (request == MappingKeyboard) &&
+ (clients[i]->xkbClientFlags != 0) &&
+ (clients[i]->mapNotifyMask&XkbKeySymsMask))
+ continue;
+#endif
+ event.u.u.sequenceNumber = clients[i]->sequence;
+ WriteEventsToClient(clients[i], 1, &event);
+ }
+ }
+}
+
+/*
+ * n-squared algorithm. n < 255 and don't want to copy the whole thing and
+ * sort it to do the checking. How often is it called? Just being lazy?
+ */
+Bool
+BadDeviceMap(register BYTE *buff, int length, unsigned low, unsigned high, XID *errval)
+{
+ register int i, j;
+
+ for (i = 0; i < length; i++)
+ if (buff[i]) /* only check non-zero elements */
+ {
+ if ((low > buff[i]) || (high < buff[i]))
+ {
+ *errval = buff[i];
+ return TRUE;
+ }
+ for (j = i + 1; j < length; j++)
+ if (buff[i] == buff[j])
+ {
+ *errval = buff[i];
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+Bool
+AllModifierKeysAreUp(dev, map1, per1, map2, per2)
+ register DeviceIntPtr dev;
+ register CARD8 *map1, *map2;
+ int per1, per2;
+{
+ register int i, j, k;
+ register CARD8 *down = dev->key->down;
+
+ for (i = 8; --i >= 0; map2 += per2)
+ {
+ for (j = per1; --j >= 0; map1++)
+ {
+ if (*map1 && BitIsOn(down, *map1))
+ {
+ for (k = per2; (--k >= 0) && (*map1 != map2[k]);)
+ ;
+ if (k < 0)
+ return FALSE;
+ }
+ }
+ }
+ return TRUE;
+}
+
+int
+ProcSetModifierMapping(ClientPtr client)
+{
+ xSetModifierMappingReply rep;
+ REQUEST(xSetModifierMappingReq);
+ KeyCode *inputMap;
+ int inputMapLen;
+ register int i;
+ DeviceIntPtr keybd = inputInfo.keyboard;
+ register KeyClassPtr keyc = keybd->key;
+
+ REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq);
+
+ if (client->req_len != ((stuff->numKeyPerModifier<<1) +
+ (sizeof (xSetModifierMappingReq)>>2)))
+ return BadLength;
+
+ inputMapLen = 8*stuff->numKeyPerModifier;
+ inputMap = (KeyCode *)&stuff[1];
+
+ /*
+ * Now enforce the restriction that "all of the non-zero keycodes must be
+ * in the range specified by min-keycode and max-keycode in the
+ * connection setup (else a Value error)"
+ */
+ i = inputMapLen;
+ while (i--)
+ {
+ if (inputMap[i]
+ && (inputMap[i] < keyc->curKeySyms.minKeyCode
+ || inputMap[i] > keyc->curKeySyms.maxKeyCode))
+ {
+ client->errorValue = inputMap[i];
+ return BadValue;
+ }
+ }
+
+#ifdef XCSECURITY
+ if (!SecurityCheckDeviceAccess(client, keybd, TRUE))
+ return BadAccess;
+#endif
+
+#ifdef LBX
+ LbxFlushModifierMapTag();
+#endif
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.success = MappingSuccess;
+
+ /*
+ * Now enforce the restriction that none of the old or new
+ * modifier keys may be down while we change the mapping, and
+ * that the DDX layer likes the choice.
+ */
+ if (!AllModifierKeysAreUp(keybd, keyc->modifierKeyMap,
+ (int)keyc->maxKeysPerModifier,
+ inputMap, (int)stuff->numKeyPerModifier)
+ ||
+ !AllModifierKeysAreUp(keybd, inputMap, (int)stuff->numKeyPerModifier,
+ keyc->modifierKeyMap,
+ (int)keyc->maxKeysPerModifier))
+ {
+ rep.success = MappingBusy;
+ }
+ else
+ {
+ for (i = 0; i < inputMapLen; i++)
+ {
+ if (inputMap[i] && !LegalModifier(inputMap[i], (DevicePtr)keybd))
+ {
+ rep.success = MappingFailed;
+ break;
+ }
+ }
+ }
+
+ if (rep.success == MappingSuccess)
+ {
+ KeyCode *map;
+ /*
+ * Now build the keyboard's modifier bitmap from the
+ * list of keycodes.
+ */
+ map = (KeyCode *)xalloc(inputMapLen);
+ if (!map && inputMapLen)
+ return BadAlloc;
+ if (keyc->modifierKeyMap)
+ xfree(keyc->modifierKeyMap);
+ keyc->modifierKeyMap = map;
+ memmove((char *)map, (char *)inputMap, inputMapLen);
+
+ keyc->maxKeysPerModifier = stuff->numKeyPerModifier;
+ for (i = 0; i < MAP_LENGTH; i++)
+ keyc->modifierMap[i] = 0;
+ for (i = 0; i < inputMapLen; i++)
+ {
+ if (inputMap[i])
+ keyc->modifierMap[inputMap[i]] |=
+ (1<<(((unsigned int)i)/keyc->maxKeysPerModifier));
+ }
+ }
+
+ if (rep.success == MappingSuccess)
+ SendMappingNotify(MappingModifier, 0, 0, client);
+
+ WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep);
+
+ return(client->noClientException);
+}
+
+int
+ProcGetModifierMapping(ClientPtr client)
+{
+ xGetModifierMappingReply rep;
+ register KeyClassPtr keyc = inputInfo.keyboard->key;
+
+ REQUEST_SIZE_MATCH(xReq);
+ rep.type = X_Reply;
+ rep.numKeyPerModifier = keyc->maxKeysPerModifier;
+ rep.sequenceNumber = client->sequence;
+ /* length counts 4 byte quantities - there are 8 modifiers 1 byte big */
+ rep.length = keyc->maxKeysPerModifier << 1;
+
+ WriteReplyToClient(client, sizeof(xGetModifierMappingReply), &rep);
+
+ /* Use the (modified by DDX) map that SetModifierMapping passed in */
+ (void)WriteToClient(client, (int)(keyc->maxKeysPerModifier << 3),
+ (char *)keyc->modifierKeyMap);
+ return client->noClientException;
+}
+
+int
+ProcChangeKeyboardMapping(ClientPtr client)
+{
+ REQUEST(xChangeKeyboardMappingReq);
+ unsigned len;
+ KeySymsRec keysyms;
+ register KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms;
+ REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq);
+
+ len = client->req_len - (sizeof(xChangeKeyboardMappingReq) >> 2);
+ if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode))
+ return BadLength;
+ if ((stuff->firstKeyCode < curKeySyms->minKeyCode) ||
+ (stuff->firstKeyCode > curKeySyms->maxKeyCode))
+ {
+ client->errorValue = stuff->firstKeyCode;
+ return BadValue;
+ }
+ if ( ((unsigned)(stuff->firstKeyCode + stuff->keyCodes - 1) >
+ curKeySyms->maxKeyCode) ||
+ (stuff->keySymsPerKeyCode == 0))
+ {
+ client->errorValue = stuff->keySymsPerKeyCode;
+ return BadValue;
+ }
+#ifdef XCSECURITY
+ if (!SecurityCheckDeviceAccess(client, inputInfo.keyboard,
+ TRUE))
+ return BadAccess;
+#endif
+ keysyms.minKeyCode = stuff->firstKeyCode;
+ keysyms.maxKeyCode = stuff->firstKeyCode + stuff->keyCodes - 1;
+ keysyms.mapWidth = stuff->keySymsPerKeyCode;
+ keysyms.map = (KeySym *)&stuff[1];
+ if (!SetKeySymsMap(curKeySyms, &keysyms))
+ return BadAlloc;
+#ifdef LBX
+ LbxFlushKeyboardMapTag();
+#endif
+ SendMappingNotify(MappingKeyboard, stuff->firstKeyCode, stuff->keyCodes,
+ client);
+ return client->noClientException;
+
+}
+
+int
+ProcSetPointerMapping(ClientPtr client)
+{
+ REQUEST(xSetPointerMappingReq);
+ BYTE *map;
+ xSetPointerMappingReply rep;
+ register unsigned int i;
+ DeviceIntPtr mouse = inputInfo.pointer;
+
+ REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq);
+ if (client->req_len != (sizeof(xSetPointerMappingReq)+stuff->nElts+3) >> 2)
+ return BadLength;
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.success = MappingSuccess;
+ map = (BYTE *)&stuff[1];
+ if (stuff->nElts != mouse->button->numButtons)
+ {
+ client->errorValue = stuff->nElts;
+ return BadValue;
+ }
+ if (BadDeviceMap(&map[0], (int)stuff->nElts, 1, 255, &client->errorValue))
+ return BadValue;
+ for (i=0; i < stuff->nElts; i++)
+ if ((mouse->button->map[i + 1] != map[i]) &&
+ BitIsOn(mouse->button->down, i + 1))
+ {
+ rep.success = MappingBusy;
+ WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep);
+ return Success;
+ }
+ for (i = 0; i < stuff->nElts; i++)
+ mouse->button->map[i + 1] = map[i];
+ SendMappingNotify(MappingPointer, 0, 0, client);
+ WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep);
+ return Success;
+}
+
+int
+ProcGetKeyboardMapping(ClientPtr client)
+{
+ xGetKeyboardMappingReply rep;
+ REQUEST(xGetKeyboardMappingReq);
+ KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms;
+
+ REQUEST_SIZE_MATCH(xGetKeyboardMappingReq);
+
+ if ((stuff->firstKeyCode < curKeySyms->minKeyCode) ||
+ (stuff->firstKeyCode > curKeySyms->maxKeyCode))
+ {
+ client->errorValue = stuff->firstKeyCode;
+ return BadValue;
+ }
+ if (stuff->firstKeyCode + stuff->count >
+ (unsigned)(curKeySyms->maxKeyCode + 1))
+ {
+ client->errorValue = stuff->count;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.keySymsPerKeyCode = curKeySyms->mapWidth;
+ /* length is a count of 4 byte quantities and KeySyms are 4 bytes */
+ rep.length = (curKeySyms->mapWidth * stuff->count);
+ WriteReplyToClient(client, sizeof(xGetKeyboardMappingReply), &rep);
+ client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
+ WriteSwappedDataToClient(
+ client,
+ curKeySyms->mapWidth * stuff->count * sizeof(KeySym),
+ &curKeySyms->map[(stuff->firstKeyCode - curKeySyms->minKeyCode) *
+ curKeySyms->mapWidth]);
+
+ return client->noClientException;
+}
+
+int
+ProcGetPointerMapping(ClientPtr client)
+{
+ xGetPointerMappingReply rep;
+ ButtonClassPtr butc = inputInfo.pointer->button;
+
+ REQUEST_SIZE_MATCH(xReq);
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.nElts = butc->numButtons;
+ rep.length = ((unsigned)rep.nElts + (4-1))/4;
+ WriteReplyToClient(client, sizeof(xGetPointerMappingReply), &rep);
+ (void)WriteToClient(client, (int)rep.nElts, (char *)&butc->map[1]);
+ return Success;
+}
+
+void
+NoteLedState(DeviceIntPtr keybd, int led, Bool on)
+{
+ KeybdCtrl *ctrl = &keybd->kbdfeed->ctrl;
+ if (on)
+ ctrl->leds |= ((Leds)1 << (led - 1));
+ else
+ ctrl->leds &= ~((Leds)1 << (led - 1));
+}
+
+int
+Ones(unsigned long mask) /* HACKMEM 169 */
+{
+ register unsigned long y;
+
+ y = (mask >> 1) &033333333333;
+ y = mask - y - ((y >>1) & 033333333333);
+ return (((y + (y >> 3)) & 030707070707) % 077);
+}
+
+int
+ProcChangeKeyboardControl (ClientPtr client)
+{
+#define DO_ALL (-1)
+ KeybdCtrl ctrl;
+ DeviceIntPtr keybd = inputInfo.keyboard;
+ XID *vlist;
+ int t;
+ int led = DO_ALL;
+ int key = DO_ALL;
+ BITS32 vmask, index2;
+ int mask, i;
+ REQUEST(xChangeKeyboardControlReq);
+
+ REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
+ vmask = stuff->mask;
+ if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask))
+ return BadLength;
+#ifdef XCSECURITY
+ if (!SecurityCheckDeviceAccess(client, keybd, TRUE))
+ return BadAccess;
+#endif
+ vlist = (XID *)&stuff[1]; /* first word of values */
+ ctrl = keybd->kbdfeed->ctrl;
+ while (vmask)
+ {
+ index2 = (BITS32) lowbit (vmask);
+ vmask &= ~index2;
+ switch (index2)
+ {
+ case KBKeyClickPercent:
+ t = (INT8)*vlist;
+ vlist++;
+ if (t == -1)
+ t = defaultKeyboardControl.click;
+ else if (t < 0 || t > 100)
+ {
+ client->errorValue = t;
+ return BadValue;
+ }
+ ctrl.click = t;
+ break;
+ case KBBellPercent:
+ t = (INT8)*vlist;
+ vlist++;
+ if (t == -1)
+ t = defaultKeyboardControl.bell;
+ else if (t < 0 || t > 100)
+ {
+ client->errorValue = t;
+ return BadValue;
+ }
+ ctrl.bell = t;
+ break;
+ case KBBellPitch:
+ t = (INT16)*vlist;
+ vlist++;
+ if (t == -1)
+ t = defaultKeyboardControl.bell_pitch;
+ else if (t < 0)
+ {
+ client->errorValue = t;
+ return BadValue;
+ }
+ ctrl.bell_pitch = t;
+ break;
+ case KBBellDuration:
+ t = (INT16)*vlist;
+ vlist++;
+ if (t == -1)
+ t = defaultKeyboardControl.bell_duration;
+ else if (t < 0)
+ {
+ client->errorValue = t;
+ return BadValue;
+ }
+ ctrl.bell_duration = t;
+ break;
+ case KBLed:
+ led = (CARD8)*vlist;
+ vlist++;
+ if (led < 1 || led > 32)
+ {
+ client->errorValue = led;
+ return BadValue;
+ }
+ if (!(stuff->mask & KBLedMode))
+ return BadMatch;
+ break;
+ case KBLedMode:
+ t = (CARD8)*vlist;
+ vlist++;
+ if (t == LedModeOff)
+ {
+ if (led == DO_ALL)
+ ctrl.leds = 0x0;
+ else
+ ctrl.leds &= ~(((Leds)(1)) << (led - 1));
+ }
+ else if (t == LedModeOn)
+ {
+ if (led == DO_ALL)
+ ctrl.leds = ~0L;
+ else
+ ctrl.leds |= (((Leds)(1)) << (led - 1));
+ }
+ else
+ {
+ client->errorValue = t;
+ return BadValue;
+ }
+#ifdef XKB
+ if (!noXkbExtension) {
+ XkbEventCauseRec cause;
+ XkbSetCauseCoreReq(&cause,X_ChangeKeyboardControl,client);
+ XkbSetIndicators(keybd,((led == DO_ALL) ? ~0L : (1L<<(led-1))),
+ ctrl.leds, &cause);
+ ctrl.leds = keybd->kbdfeed->ctrl.leds;
+ }
+#endif
+ break;
+ case KBKey:
+ key = (KeyCode)*vlist;
+ vlist++;
+ if ((KeyCode)key < inputInfo.keyboard->key->curKeySyms.minKeyCode ||
+ (KeyCode)key > inputInfo.keyboard->key->curKeySyms.maxKeyCode)
+ {
+ client->errorValue = key;
+ return BadValue;
+ }
+ if (!(stuff->mask & KBAutoRepeatMode))
+ return BadMatch;
+ break;
+ case KBAutoRepeatMode:
+ i = (key >> 3);
+ mask = (1 << (key & 7));
+ t = (CARD8)*vlist;
+ vlist++;
+#ifdef XKB
+ if (!noXkbExtension && key != DO_ALL)
+ XkbDisableComputedAutoRepeats(keybd,key);
+#endif
+ if (t == AutoRepeatModeOff)
+ {
+ if (key == DO_ALL)
+ ctrl.autoRepeat = FALSE;
+ else
+ ctrl.autoRepeats[i] &= ~mask;
+ }
+ else if (t == AutoRepeatModeOn)
+ {
+ if (key == DO_ALL)
+ ctrl.autoRepeat = TRUE;
+ else
+ ctrl.autoRepeats[i] |= mask;
+ }
+ else if (t == AutoRepeatModeDefault)
+ {
+ if (key == DO_ALL)
+ ctrl.autoRepeat = defaultKeyboardControl.autoRepeat;
+ else
+ ctrl.autoRepeats[i] =
+ (ctrl.autoRepeats[i] & ~mask) |
+ (defaultKeyboardControl.autoRepeats[i] & mask);
+ }
+ else
+ {
+ client->errorValue = t;
+ return BadValue;
+ }
+ break;
+ default:
+ client->errorValue = stuff->mask;
+ return BadValue;
+ }
+ }
+ keybd->kbdfeed->ctrl = ctrl;
+#ifdef XKB
+ /* The XKB RepeatKeys control and core protocol global autorepeat */
+ /* value are linked */
+ if (!noXkbExtension) {
+ XkbSetRepeatKeys(keybd,key,keybd->kbdfeed->ctrl.autoRepeat);
+ }
+ else
+#endif
+ (*keybd->kbdfeed->CtrlProc)(keybd, &keybd->kbdfeed->ctrl);
+ return Success;
+#undef DO_ALL
+}
+
+int
+ProcGetKeyboardControl (ClientPtr client)
+{
+ int i;
+ register KeybdCtrl *ctrl = &inputInfo.keyboard->kbdfeed->ctrl;
+ xGetKeyboardControlReply rep;
+
+ REQUEST_SIZE_MATCH(xReq);
+ rep.type = X_Reply;
+ rep.length = 5;
+ rep.sequenceNumber = client->sequence;
+ rep.globalAutoRepeat = ctrl->autoRepeat;
+ rep.keyClickPercent = ctrl->click;
+ rep.bellPercent = ctrl->bell;
+ rep.bellPitch = ctrl->bell_pitch;
+ rep.bellDuration = ctrl->bell_duration;
+ rep.ledMask = ctrl->leds;
+ for (i = 0; i < 32; i++)
+ rep.map[i] = ctrl->autoRepeats[i];
+ WriteReplyToClient(client, sizeof(xGetKeyboardControlReply), &rep);
+ return Success;
+}
+
+int
+ProcBell(ClientPtr client)
+{
+ register DeviceIntPtr keybd = inputInfo.keyboard;
+ int base = keybd->kbdfeed->ctrl.bell;
+ int newpercent;
+ REQUEST(xBellReq);
+ REQUEST_SIZE_MATCH(xBellReq);
+ if (stuff->percent < -100 || stuff->percent > 100)
+ {
+ client->errorValue = stuff->percent;
+ return BadValue;
+ }
+ newpercent = (base * stuff->percent) / 100;
+ if (stuff->percent < 0)
+ newpercent = base + newpercent;
+ else
+ newpercent = base - newpercent + stuff->percent;
+#ifdef XKB
+ if (!noXkbExtension)
+ XkbHandleBell(FALSE,FALSE, keybd, newpercent, &keybd->kbdfeed->ctrl, 0,
+ None, NULL, client);
+ else
+#endif
+ (*keybd->kbdfeed->BellProc)(newpercent, keybd,
+ (pointer) &keybd->kbdfeed->ctrl, 0);
+ return Success;
+}
+
+int
+ProcChangePointerControl(ClientPtr client)
+{
+ DeviceIntPtr mouse = inputInfo.pointer;
+ PtrCtrl ctrl; /* might get BadValue part way through */
+ REQUEST(xChangePointerControlReq);
+
+ REQUEST_SIZE_MATCH(xChangePointerControlReq);
+ ctrl = mouse->ptrfeed->ctrl;
+ if ((stuff->doAccel != xTrue) && (stuff->doAccel != xFalse))
+ {
+ client->errorValue = stuff->doAccel;
+ return(BadValue);
+ }
+ if ((stuff->doThresh != xTrue) && (stuff->doThresh != xFalse))
+ {
+ client->errorValue = stuff->doThresh;
+ return(BadValue);
+ }
+ if (stuff->doAccel)
+ {
+ if (stuff->accelNum == -1)
+ ctrl.num = defaultPointerControl.num;
+ else if (stuff->accelNum < 0)
+ {
+ client->errorValue = stuff->accelNum;
+ return BadValue;
+ }
+ else ctrl.num = stuff->accelNum;
+ if (stuff->accelDenum == -1)
+ ctrl.den = defaultPointerControl.den;
+ else if (stuff->accelDenum <= 0)
+ {
+ client->errorValue = stuff->accelDenum;
+ return BadValue;
+ }
+ else ctrl.den = stuff->accelDenum;
+ }
+ if (stuff->doThresh)
+ {
+ if (stuff->threshold == -1)
+ ctrl.threshold = defaultPointerControl.threshold;
+ else if (stuff->threshold < 0)
+ {
+ client->errorValue = stuff->threshold;
+ return BadValue;
+ }
+ else ctrl.threshold = stuff->threshold;
+ }
+ mouse->ptrfeed->ctrl = ctrl;
+ (*mouse->ptrfeed->CtrlProc)(mouse, &mouse->ptrfeed->ctrl);
+ return Success;
+}
+
+int
+ProcGetPointerControl(ClientPtr client)
+{
+ register PtrCtrl *ctrl = &inputInfo.pointer->ptrfeed->ctrl;
+ xGetPointerControlReply rep;
+
+ REQUEST_SIZE_MATCH(xReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.threshold = ctrl->threshold;
+ rep.accelNumerator = ctrl->num;
+ rep.accelDenominator = ctrl->den;
+ WriteReplyToClient(client, sizeof(xGenericReply), &rep);
+ return Success;
+}
+
+void
+MaybeStopHint(register DeviceIntPtr dev, ClientPtr client)
+{
+ GrabPtr grab = dev->grab;
+
+ if ((grab && SameClient(grab, client) &&
+ ((grab->eventMask & PointerMotionHintMask) ||
+ (grab->ownerEvents &&
+ (EventMaskForClient(dev->valuator->motionHintWindow, client) &
+ PointerMotionHintMask)))) ||
+ (!grab &&
+ (EventMaskForClient(dev->valuator->motionHintWindow, client) &
+ PointerMotionHintMask)))
+ dev->valuator->motionHintWindow = NullWindow;
+}
+
+int
+ProcGetMotionEvents(ClientPtr client)
+{
+ WindowPtr pWin;
+ xTimecoord * coords = (xTimecoord *) NULL;
+ xGetMotionEventsReply rep;
+ int i, count, xmin, xmax, ymin, ymax;
+ unsigned long nEvents;
+ DeviceIntPtr mouse = inputInfo.pointer;
+ TimeStamp start, stop;
+ REQUEST(xGetMotionEventsReq);
+
+ REQUEST_SIZE_MATCH(xGetMotionEventsReq);
+ pWin = SecurityLookupWindow(stuff->window, client, TRUE);
+ if (!pWin)
+ return BadWindow;
+ if (mouse->valuator->motionHintWindow)
+ MaybeStopHint(mouse, client);
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ nEvents = 0;
+ start = ClientTimeToServerTime(stuff->start);
+ stop = ClientTimeToServerTime(stuff->stop);
+ if ((CompareTimeStamps(start, stop) != LATER) &&
+ (CompareTimeStamps(start, currentTime) != LATER) &&
+ mouse->valuator->numMotionEvents)
+ {
+ if (CompareTimeStamps(stop, currentTime) == LATER)
+ stop = currentTime;
+ coords = (xTimecoord *)ALLOCATE_LOCAL(mouse->valuator->numMotionEvents
+ * sizeof(xTimecoord));
+ if (!coords)
+ return BadAlloc;
+ count = (*mouse->valuator->GetMotionProc) (mouse, coords,
+ start.milliseconds,
+ stop.milliseconds,
+ pWin->drawable.pScreen);
+ xmin = pWin->drawable.x - wBorderWidth (pWin);
+ xmax = pWin->drawable.x + (int)pWin->drawable.width +
+ wBorderWidth (pWin);
+ ymin = pWin->drawable.y - wBorderWidth (pWin);
+ ymax = pWin->drawable.y + (int)pWin->drawable.height +
+ wBorderWidth (pWin);
+ for (i = 0; i < count; i++)
+ if ((xmin <= coords[i].x) && (coords[i].x < xmax) &&
+ (ymin <= coords[i].y) && (coords[i].y < ymax))
+ {
+ coords[nEvents].time = coords[i].time;
+ coords[nEvents].x = coords[i].x - pWin->drawable.x;
+ coords[nEvents].y = coords[i].y - pWin->drawable.y;
+ nEvents++;
+ }
+ }
+ rep.length = nEvents * (sizeof(xTimecoord) >> 2);
+ rep.nEvents = nEvents;
+ WriteReplyToClient(client, sizeof(xGetMotionEventsReply), &rep);
+ if (nEvents)
+ {
+ client->pSwapReplyFunc = (ReplySwapPtr) SwapTimeCoordWrite;
+ WriteSwappedDataToClient(client, nEvents * sizeof(xTimecoord),
+ (char *)coords);
+ }
+ if (coords)
+ DEALLOCATE_LOCAL(coords);
+ return Success;
+}
+
+int
+ProcQueryKeymap(ClientPtr client)
+{
+ xQueryKeymapReply rep;
+ int i;
+ CARD8 *down = inputInfo.keyboard->key->down;
+
+ REQUEST_SIZE_MATCH(xReq);
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 2;
+#ifdef XCSECURITY
+ if (!SecurityCheckDeviceAccess(client, inputInfo.keyboard, TRUE))
+ {
+ bzero((char *)&rep.map[0], 32);
+ }
+ else
+#endif
+ for (i = 0; i<32; i++)
+ rep.map[i] = down[i];
+ WriteReplyToClient(client, sizeof(xQueryKeymapReply), &rep);
+ return Success;
+}
+
+/******************************************************************************
+ * The following entrypoints are provided for binary compatibility with
+ * previous versions (they make casts, where the current version changes types
+ * for more stringent prototype checking).
+ ******************************************************************************/
+#ifdef AddInputDevice
+#undef AddInputDevice
+
+DevicePtr
+AddInputDevice(DeviceProc deviceProc, Bool autoStart)
+{
+ return (DevicePtr)_AddInputDevice(deviceProc, autoStart);
+}
+#endif /* AddInputDevice */
+
+#ifdef RegisterPointerDevice
+#undef RegisterPointerDevice
+
+void
+RegisterPointerDevice(DevicePtr device)
+{
+ _RegisterPointerDevice((DeviceIntPtr)device);
+}
+#endif /* RegisterPointerDevice */
+
+#ifdef RegisterKeyboardDevice
+#undef RegisterKeyboardDevice
+
+void
+RegisterKeyboardDevice(DevicePtr device)
+{
+ _RegisterKeyboardDevice((DeviceIntPtr)device);
+}
+#endif /* RegisterKeyboardDevice */
diff --git a/nx-X11/programs/Xserver/dix/dispatch.c b/nx-X11/programs/Xserver/dix/dispatch.c
new file mode 100644
index 000000000..6941456de
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/dispatch.c
@@ -0,0 +1,4035 @@
+/* $XdotOrg: xc/programs/Xserver/dix/dispatch.c,v 1.13 2005/09/13 01:33:19 daniels Exp $ */
+/* $Xorg: dispatch.c,v 1.5 2001/02/09 02:04:40 xorgcvs Exp $ */
+/************************************************************
+
+Copyright 1987, 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/* The panoramix components contained the following notice */
+/*****************************************************************
+
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+
+/* $XFree86: xc/programs/Xserver/dix/dispatch.c,v 3.32 2003/11/10 18:21:45 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef PANORAMIX_DEBUG
+#include <stdio.h>
+int ProcInitialConnection();
+#endif
+
+#include "windowstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "selection.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "opaque.h"
+#include "input.h"
+#include "servermd.h"
+#include "extnsionst.h"
+#include "dixfont.h"
+#include "dispatch.h"
+#include "swaprep.h"
+#include "swapreq.h"
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+#ifdef XAPPGROUP
+#include <X11/extensions/Xagsrv.h>
+#endif
+#ifdef XKB
+#define XKB_IN_SERVER
+#include "inputstr.h"
+#include <X11/extensions/XKBsrv.h>
+#endif
+#ifdef LBX
+#include "lbxserve.h"
+#endif
+
+#define mskcnt ((MAXCLIENTS + 31) / 32)
+#define BITMASK(i) (1U << ((i) & 31))
+#define MASKIDX(i) ((i) >> 5)
+#define MASKWORD(buf, i) buf[MASKIDX(i)]
+#define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
+#define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
+#define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
+
+extern xConnSetupPrefix connSetupPrefix;
+extern char *ConnectionInfo;
+
+Selection *CurrentSelections;
+int NumCurrentSelections;
+CallbackListPtr SelectionCallback = NULL;
+
+static ClientPtr grabClient;
+#define GrabNone 0
+#define GrabActive 1
+#define GrabKickout 2
+static int grabState = GrabNone;
+static long grabWaiters[mskcnt];
+CallbackListPtr ServerGrabCallback = NULL;
+HWEventQueuePtr checkForInput[2];
+extern int connBlockScreenStart;
+
+static void KillAllClients(void);
+
+static void DeleteClientFromAnySelections(ClientPtr client);
+
+static int nextFreeClientID; /* always MIN free client ID */
+
+static int nClients; /* number of authorized clients */
+
+CallbackListPtr ClientStateCallback;
+
+/* dispatchException & isItTimeToYield must be declared volatile since they
+ * are modified by signal handlers - otherwise optimizer may assume it doesn't
+ * need to actually check value in memory when used and may miss changes from
+ * signal handlers.
+ */
+volatile char dispatchException = 0;
+volatile char isItTimeToYield;
+
+/* Various of the DIX function interfaces were not designed to allow
+ * the client->errorValue to be set on BadValue and other errors.
+ * Rather than changing interfaces and breaking untold code we introduce
+ * a new global that dispatch can use.
+ */
+XID clientErrorValue; /* XXX this is a kludge */
+
+#define SAME_SCREENS(a, b) (\
+ (a.pScreen == b.pScreen))
+
+void
+SetInputCheck(HWEventQueuePtr c0, HWEventQueuePtr c1)
+{
+ checkForInput[0] = c0;
+ checkForInput[1] = c1;
+}
+
+void
+UpdateCurrentTime()
+{
+ TimeStamp systime;
+
+ /* To avoid time running backwards, we must call GetTimeInMillis before
+ * calling ProcessInputEvents.
+ */
+ systime.months = currentTime.months;
+ systime.milliseconds = GetTimeInMillis();
+ if (systime.milliseconds < currentTime.milliseconds)
+ systime.months++;
+ if (*checkForInput[0] != *checkForInput[1])
+ ProcessInputEvents();
+ if (CompareTimeStamps(systime, currentTime) == LATER)
+ currentTime = systime;
+}
+
+/* Like UpdateCurrentTime, but can't call ProcessInputEvents */
+void
+UpdateCurrentTimeIf()
+{
+ TimeStamp systime;
+
+ systime.months = currentTime.months;
+ systime.milliseconds = GetTimeInMillis();
+ if (systime.milliseconds < currentTime.milliseconds)
+ systime.months++;
+ if (*checkForInput[0] == *checkForInput[1])
+ currentTime = systime;
+}
+
+void
+InitSelections()
+{
+ if (CurrentSelections)
+ xfree(CurrentSelections);
+ CurrentSelections = (Selection *)NULL;
+ NumCurrentSelections = 0;
+}
+
+void
+FlushClientCaches(XID id)
+{
+ int i;
+ register ClientPtr client;
+
+ client = clients[CLIENT_ID(id)];
+ if (client == NullClient)
+ return ;
+ for (i=0; i<currentMaxClients; i++)
+ {
+ client = clients[i];
+ if (client != NullClient)
+ {
+ if (client->lastDrawableID == id)
+ {
+ client->lastDrawableID = WindowTable[0]->drawable.id;
+ client->lastDrawable = (DrawablePtr)WindowTable[0];
+ }
+ else if (client->lastGCID == id)
+ {
+ client->lastGCID = INVALID;
+ client->lastGC = (GCPtr)NULL;
+ }
+ }
+ }
+}
+#ifdef SMART_SCHEDULE
+
+#undef SMART_DEBUG
+
+#define SMART_SCHEDULE_DEFAULT_INTERVAL 20 /* ms */
+#define SMART_SCHEDULE_MAX_SLICE 200 /* ms */
+
+Bool SmartScheduleDisable = FALSE;
+long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL;
+long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL;
+long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE;
+long SmartScheduleTime;
+ClientPtr SmartLastClient;
+int SmartLastIndex[SMART_MAX_PRIORITY-SMART_MIN_PRIORITY+1];
+int SmartScheduleClient(int *clientReady, int nready);
+
+#ifdef SMART_DEBUG
+long SmartLastPrint;
+#endif
+
+void Dispatch(void);
+void InitProcVectors(void);
+
+int
+SmartScheduleClient (int *clientReady, int nready)
+{
+ ClientPtr pClient;
+ int i;
+ int client;
+ int bestPrio, best = 0;
+ int bestRobin, robin;
+ long now = SmartScheduleTime;
+ long idle;
+
+ bestPrio = -0x7fffffff;
+ bestRobin = 0;
+ idle = 2 * SmartScheduleSlice;
+ for (i = 0; i < nready; i++)
+ {
+ client = clientReady[i];
+ pClient = clients[client];
+ /* Praise clients which are idle */
+ if ((now - pClient->smart_check_tick) >= idle)
+ {
+ if (pClient->smart_priority < 0)
+ pClient->smart_priority++;
+ }
+ pClient->smart_check_tick = now;
+
+ /* check priority to select best client */
+ robin = (pClient->index - SmartLastIndex[pClient->smart_priority-SMART_MIN_PRIORITY]) & 0xff;
+ if (pClient->smart_priority > bestPrio ||
+ (pClient->smart_priority == bestPrio && robin > bestRobin))
+ {
+ bestPrio = pClient->smart_priority;
+ bestRobin = robin;
+ best = client;
+ }
+#ifdef SMART_DEBUG
+ if ((now - SmartLastPrint) >= 5000)
+ fprintf (stderr, " %2d: %3d", client, pClient->smart_priority);
+#endif
+ }
+#ifdef SMART_DEBUG
+ if ((now - SmartLastPrint) >= 5000)
+ {
+ fprintf (stderr, " use %2d\n", best);
+ SmartLastPrint = now;
+ }
+#endif
+ pClient = clients[best];
+ SmartLastIndex[bestPrio-SMART_MIN_PRIORITY] = pClient->index;
+ /*
+ * Set current client pointer
+ */
+ if (SmartLastClient != pClient)
+ {
+ pClient->smart_start_tick = now;
+ SmartLastClient = pClient;
+ }
+ /*
+ * Adjust slice
+ */
+ if (nready == 1)
+ {
+ /*
+ * If it's been a long time since another client
+ * has run, bump the slice up to get maximal
+ * performance from a single client
+ */
+ if ((now - pClient->smart_start_tick) > 1000 &&
+ SmartScheduleSlice < SmartScheduleMaxSlice)
+ {
+ SmartScheduleSlice += SmartScheduleInterval;
+ }
+ }
+ else
+ {
+ SmartScheduleSlice = SmartScheduleInterval;
+ }
+ return best;
+}
+#endif
+
+#define MAJOROP ((xReq *)client->requestBuffer)->reqType
+
+void
+Dispatch(void)
+{
+ register int *clientReady; /* array of request ready clients */
+ register int result;
+ register ClientPtr client;
+ register int nready;
+ register HWEventQueuePtr* icheck = checkForInput;
+#ifdef SMART_SCHEDULE
+ long start_tick;
+#endif
+
+ nextFreeClientID = 1;
+ InitSelections();
+ nClients = 0;
+
+ clientReady = (int *) ALLOCATE_LOCAL(sizeof(int) * MaxClients);
+ if (!clientReady)
+ return;
+
+ while (!dispatchException)
+ {
+ if (*icheck[0] != *icheck[1])
+ {
+ ProcessInputEvents();
+ FlushIfCriticalOutputPending();
+ }
+
+ nready = WaitForSomething(clientReady);
+
+#ifdef SMART_SCHEDULE
+ if (nready && !SmartScheduleDisable)
+ {
+ clientReady[0] = SmartScheduleClient (clientReady, nready);
+ nready = 1;
+ }
+#endif
+ /*****************
+ * Handle events in round robin fashion, doing input between
+ * each round
+ *****************/
+
+ while (!dispatchException && (--nready >= 0))
+ {
+ client = clients[clientReady[nready]];
+ if (! client)
+ {
+ /* KillClient can cause this to happen */
+ continue;
+ }
+ /* GrabServer activation can cause this to be true */
+ if (grabState == GrabKickout)
+ {
+ grabState = GrabActive;
+ break;
+ }
+ isItTimeToYield = FALSE;
+
+ requestingClient = client;
+#ifdef SMART_SCHEDULE
+ start_tick = SmartScheduleTime;
+#endif
+ while (!isItTimeToYield)
+ {
+ if (*icheck[0] != *icheck[1])
+ {
+ ProcessInputEvents();
+ FlushIfCriticalOutputPending();
+ }
+#ifdef SMART_SCHEDULE
+ if (!SmartScheduleDisable &&
+ (SmartScheduleTime - start_tick) >= SmartScheduleSlice)
+ {
+ /* Penalize clients which consume ticks */
+ if (client->smart_priority > SMART_MIN_PRIORITY)
+ client->smart_priority--;
+ break;
+ }
+#endif
+ /* now, finally, deal with client requests */
+
+ result = ReadRequestFromClient(client);
+ if (result <= 0)
+ {
+ if (result < 0)
+ CloseDownClient(client);
+ break;
+ }
+
+ client->sequence++;
+#ifdef DEBUG
+ if (client->requestLogIndex == MAX_REQUEST_LOG)
+ client->requestLogIndex = 0;
+ client->requestLog[client->requestLogIndex] = MAJOROP;
+ client->requestLogIndex++;
+#endif
+ if (result > (maxBigRequestSize << 2))
+ result = BadLength;
+ else
+ result = (* client->requestVector[MAJOROP])(client);
+
+ if (result != Success)
+ {
+ if (client->noClientException != Success)
+ CloseDownClient(client);
+ else
+ SendErrorToClient(client, MAJOROP,
+ MinorOpcodeOfRequest(client),
+ client->errorValue, result);
+ break;
+ }
+#ifdef DAMAGEEXT
+ FlushIfCriticalOutputPending ();
+#endif
+ }
+ FlushAllOutput();
+#ifdef SMART_SCHEDULE
+ client = clients[clientReady[nready]];
+ if (client)
+ client->smart_stop_tick = SmartScheduleTime;
+#endif
+ requestingClient = NULL;
+ }
+ dispatchException &= ~DE_PRIORITYCHANGE;
+ }
+#if defined(DDXBEFORERESET)
+ ddxBeforeReset ();
+#endif
+ KillAllClients();
+ DEALLOCATE_LOCAL(clientReady);
+ dispatchException &= ~DE_RESET;
+}
+
+#undef MAJOROP
+
+int
+ProcBadRequest(ClientPtr client)
+{
+ return (BadRequest);
+}
+
+int
+ProcCreateWindow(ClientPtr client)
+{
+ register WindowPtr pParent, pWin;
+ REQUEST(xCreateWindowReq);
+ int result;
+ int len;
+
+ REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
+
+ LEGAL_NEW_RESOURCE(stuff->wid, client);
+ if (!(pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client,
+ SecurityWriteAccess)))
+ return BadWindow;
+ len = client->req_len - (sizeof(xCreateWindowReq) >> 2);
+ if (Ones(stuff->mask) != len)
+ return BadLength;
+ if (!stuff->width || !stuff->height)
+ {
+ client->errorValue = 0;
+ return BadValue;
+ }
+ pWin = CreateWindow(stuff->wid, pParent, stuff->x,
+ stuff->y, stuff->width, stuff->height,
+ stuff->borderWidth, stuff->class,
+ stuff->mask, (XID *) &stuff[1],
+ (int)stuff->depth,
+ client, stuff->visual, &result);
+ if (pWin)
+ {
+ Mask mask = pWin->eventMask;
+
+ pWin->eventMask = 0; /* subterfuge in case AddResource fails */
+ if (!AddResource(stuff->wid, RT_WINDOW, (pointer)pWin))
+ return BadAlloc;
+ pWin->eventMask = mask;
+ }
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return(result);
+}
+
+int
+ProcChangeWindowAttributes(register ClientPtr client)
+{
+ register WindowPtr pWin;
+ REQUEST(xChangeWindowAttributesReq);
+ register int result;
+ int len;
+
+ REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityWriteAccess);
+ if (!pWin)
+ return(BadWindow);
+ len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2);
+ if (len != Ones(stuff->valueMask))
+ return BadLength;
+ result = ChangeWindowAttributes(pWin,
+ stuff->valueMask,
+ (XID *) &stuff[1],
+ client);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return(result);
+}
+
+int
+ProcGetWindowAttributes(register ClientPtr client)
+{
+ register WindowPtr pWin;
+ REQUEST(xResourceReq);
+ xGetWindowAttributesReply wa;
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ GetWindowAttributes(pWin, client, &wa);
+ WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa);
+ return(client->noClientException);
+}
+
+int
+ProcDestroyWindow(register ClientPtr client)
+{
+ register WindowPtr pWin;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+ SecurityDestroyAccess);
+ if (!pWin)
+ return(BadWindow);
+ if (pWin->parent)
+ FreeResource(stuff->id, RT_NONE);
+ return(client->noClientException);
+}
+
+int
+ProcDestroySubwindows(register ClientPtr client)
+{
+ register WindowPtr pWin;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+ SecurityDestroyAccess);
+ if (!pWin)
+ return(BadWindow);
+ DestroySubwindows(pWin, client);
+ return(client->noClientException);
+}
+
+int
+ProcChangeSaveSet(register ClientPtr client)
+{
+ register WindowPtr pWin;
+ REQUEST(xChangeSaveSetReq);
+ register int result;
+
+ REQUEST_SIZE_MATCH(xChangeSaveSetReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id)))
+ return BadMatch;
+ if ((stuff->mode == SetModeInsert) || (stuff->mode == SetModeDelete))
+ {
+ result = AlterSaveSetForClient(client, pWin, stuff->mode, FALSE, TRUE);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return(result);
+ }
+ else
+ {
+ client->errorValue = stuff->mode;
+ return( BadValue );
+ }
+}
+
+int
+ProcReparentWindow(register ClientPtr client)
+{
+ register WindowPtr pWin, pParent;
+ REQUEST(xReparentWindowReq);
+ register int result;
+
+ REQUEST_SIZE_MATCH(xReparentWindowReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityWriteAccess);
+ if (!pWin)
+ return(BadWindow);
+ pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client,
+ SecurityWriteAccess);
+ if (!pParent)
+ return(BadWindow);
+ if (SAME_SCREENS(pWin->drawable, pParent->drawable))
+ {
+ if ((pWin->backgroundState == ParentRelative) &&
+ (pParent->drawable.depth != pWin->drawable.depth))
+ return BadMatch;
+ if ((pWin->drawable.class != InputOnly) &&
+ (pParent->drawable.class == InputOnly))
+ return BadMatch;
+ result = ReparentWindow(pWin, pParent,
+ (short)stuff->x, (short)stuff->y, client);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return(result);
+ }
+ else
+ return (BadMatch);
+}
+
+int
+ProcMapWindow(register ClientPtr client)
+{
+ register WindowPtr pWin;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ MapWindow(pWin, client);
+ /* update cache to say it is mapped */
+ return(client->noClientException);
+}
+
+int
+ProcMapSubwindows(register ClientPtr client)
+{
+ register WindowPtr pWin;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ MapSubwindows(pWin, client);
+ /* update cache to say it is mapped */
+ return(client->noClientException);
+}
+
+int
+ProcUnmapWindow(register ClientPtr client)
+{
+ register WindowPtr pWin;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ UnmapWindow(pWin, FALSE);
+ /* update cache to say it is mapped */
+ return(client->noClientException);
+}
+
+int
+ProcUnmapSubwindows(register ClientPtr client)
+{
+ register WindowPtr pWin;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ UnmapSubwindows(pWin);
+ return(client->noClientException);
+}
+
+int
+ProcConfigureWindow(register ClientPtr client)
+{
+ register WindowPtr pWin;
+ REQUEST(xConfigureWindowReq);
+ register int result;
+ int len;
+
+ REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
+ pWin = (WindowPtr)SecurityLookupWindow( stuff->window, client,
+ SecurityWriteAccess);
+ if (!pWin)
+ return(BadWindow);
+ len = client->req_len - (sizeof(xConfigureWindowReq) >> 2);
+ if (Ones((Mask)stuff->mask) != len)
+ return BadLength;
+ result = ConfigureWindow(pWin, (Mask)stuff->mask, (XID *) &stuff[1],
+ client);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return(result);
+}
+
+int
+ProcCirculateWindow(register ClientPtr client)
+{
+ register WindowPtr pWin;
+ REQUEST(xCirculateWindowReq);
+
+ REQUEST_SIZE_MATCH(xCirculateWindowReq);
+ if ((stuff->direction != RaiseLowest) &&
+ (stuff->direction != LowerHighest))
+ {
+ client->errorValue = stuff->direction;
+ return BadValue;
+ }
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityWriteAccess);
+ if (!pWin)
+ return(BadWindow);
+ CirculateWindow(pWin, (int)stuff->direction, client);
+ return(client->noClientException);
+}
+
+int
+GetGeometry(register ClientPtr client, xGetGeometryReply *rep)
+{
+ register DrawablePtr pDraw;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->id, client, SecurityReadAccess);
+ rep->type = X_Reply;
+ rep->length = 0;
+ rep->sequenceNumber = client->sequence;
+ rep->root = WindowTable[pDraw->pScreen->myNum]->drawable.id;
+ rep->depth = pDraw->depth;
+ rep->width = pDraw->width;
+ rep->height = pDraw->height;
+
+ /* XXX - Because the pixmap-implementation of the multibuffer extension
+ * may have the buffer-id's drawable resource value be a pointer
+ * to the buffer's window instead of the buffer itself
+ * (this happens if the buffer is the displayed buffer),
+ * we also have to check that the id matches before we can
+ * truly say that it is a DRAWABLE_WINDOW.
+ */
+
+ if ((pDraw->type == UNDRAWABLE_WINDOW) ||
+ ((pDraw->type == DRAWABLE_WINDOW) && (stuff->id == pDraw->id)))
+ {
+ register WindowPtr pWin = (WindowPtr)pDraw;
+ rep->x = pWin->origin.x - wBorderWidth (pWin);
+ rep->y = pWin->origin.y - wBorderWidth (pWin);
+ rep->borderWidth = pWin->borderWidth;
+ }
+ else /* DRAWABLE_PIXMAP or DRAWABLE_BUFFER */
+ {
+ rep->x = rep->y = rep->borderWidth = 0;
+ }
+
+ return Success;
+}
+
+
+int
+ProcGetGeometry(register ClientPtr client)
+{
+ xGetGeometryReply rep;
+ int status;
+
+ if ((status = GetGeometry(client, &rep)) != Success)
+ return status;
+
+ WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep);
+ return(client->noClientException);
+}
+
+
+int
+ProcQueryTree(register ClientPtr client)
+{
+ xQueryTreeReply reply;
+ int numChildren = 0;
+ register WindowPtr pChild, pWin, pHead;
+ Window *childIDs = (Window *)NULL;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ reply.type = X_Reply;
+ reply.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
+ reply.sequenceNumber = client->sequence;
+ if (pWin->parent)
+ reply.parent = pWin->parent->drawable.id;
+ else
+ reply.parent = (Window)None;
+ pHead = RealChildHead(pWin);
+ for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
+ numChildren++;
+ if (numChildren)
+ {
+ int curChild = 0;
+
+ childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window));
+ if (!childIDs)
+ return BadAlloc;
+ for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
+ childIDs[curChild++] = pChild->drawable.id;
+ }
+
+ reply.nChildren = numChildren;
+ reply.length = (numChildren * sizeof(Window)) >> 2;
+
+ WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply);
+ if (numChildren)
+ {
+ client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
+ WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs);
+ DEALLOCATE_LOCAL(childIDs);
+ }
+
+ return(client->noClientException);
+}
+
+int
+ProcInternAtom(register ClientPtr client)
+{
+ Atom atom;
+ char *tchar;
+ REQUEST(xInternAtomReq);
+
+ REQUEST_FIXED_SIZE(xInternAtomReq, stuff->nbytes);
+ if ((stuff->onlyIfExists != xTrue) && (stuff->onlyIfExists != xFalse))
+ {
+ client->errorValue = stuff->onlyIfExists;
+ return(BadValue);
+ }
+ tchar = (char *) &stuff[1];
+ atom = MakeAtom(tchar, stuff->nbytes, !stuff->onlyIfExists);
+ if (atom != BAD_RESOURCE)
+ {
+ xInternAtomReply reply;
+ reply.type = X_Reply;
+ reply.length = 0;
+ reply.sequenceNumber = client->sequence;
+ reply.atom = atom;
+ WriteReplyToClient(client, sizeof(xInternAtomReply), &reply);
+ return(client->noClientException);
+ }
+ else
+ return (BadAlloc);
+}
+
+int
+ProcGetAtomName(register ClientPtr client)
+{
+ char *str;
+ xGetAtomNameReply reply;
+ int len;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ if ( (str = NameForAtom(stuff->id)) )
+ {
+ len = strlen(str);
+ reply.type = X_Reply;
+ reply.length = (len + 3) >> 2;
+ reply.sequenceNumber = client->sequence;
+ reply.nameLength = len;
+ WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply);
+ (void)WriteToClient(client, len, str);
+ return(client->noClientException);
+ }
+ else
+ {
+ client->errorValue = stuff->id;
+ return (BadAtom);
+ }
+}
+
+#ifdef K5AUTH
+extern int k5_bad();
+#endif
+
+int
+ProcSetSelectionOwner(register ClientPtr client)
+{
+ WindowPtr pWin;
+ TimeStamp time;
+ REQUEST(xSetSelectionOwnerReq);
+
+ REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
+ UpdateCurrentTime();
+ time = ClientTimeToServerTime(stuff->time);
+
+ /* If the client's time stamp is in the future relative to the server's
+ time stamp, do not set the selection, just return success. */
+ if (CompareTimeStamps(time, currentTime) == LATER)
+ return Success;
+ if (stuff->window != None)
+ {
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ }
+ else
+ pWin = (WindowPtr)None;
+ if (ValidAtom(stuff->selection))
+ {
+ int i = 0;
+
+ /*
+ * First, see if the selection is already set...
+ */
+ while ((i < NumCurrentSelections) &&
+ CurrentSelections[i].selection != stuff->selection)
+ i++;
+ if (i < NumCurrentSelections)
+ {
+ xEvent event;
+
+ /* If the timestamp in client's request is in the past relative
+ to the time stamp indicating the last time the owner of the
+ selection was set, do not set the selection, just return
+ success. */
+ if (CompareTimeStamps(time, CurrentSelections[i].lastTimeChanged)
+ == EARLIER)
+ return Success;
+ if (CurrentSelections[i].client &&
+ (!pWin || (CurrentSelections[i].client != client)))
+ {
+ event.u.u.type = SelectionClear;
+ event.u.selectionClear.time = time.milliseconds;
+ event.u.selectionClear.window = CurrentSelections[i].window;
+ event.u.selectionClear.atom = CurrentSelections[i].selection;
+ (void) TryClientEvents (CurrentSelections[i].client, &event, 1,
+ NoEventMask, NoEventMask /* CantBeFiltered */,
+ NullGrab);
+ }
+ }
+ else
+ {
+ /*
+ * It doesn't exist, so add it...
+ */
+ Selection *newsels;
+
+ if (i == 0)
+ newsels = (Selection *)xalloc(sizeof(Selection));
+ else
+ newsels = (Selection *)xrealloc(CurrentSelections,
+ (NumCurrentSelections + 1) * sizeof(Selection));
+ if (!newsels)
+ return BadAlloc;
+ NumCurrentSelections++;
+ CurrentSelections = newsels;
+ CurrentSelections[i].selection = stuff->selection;
+ }
+ CurrentSelections[i].lastTimeChanged = time;
+ CurrentSelections[i].window = stuff->window;
+ CurrentSelections[i].pWin = pWin;
+ CurrentSelections[i].client = (pWin ? client : NullClient);
+ if (SelectionCallback)
+ {
+ SelectionInfoRec info;
+
+ info.selection = &CurrentSelections[i];
+ info.kind= SelectionSetOwner;
+ CallCallbacks(&SelectionCallback, &info);
+ }
+ return (client->noClientException);
+ }
+ else
+ {
+ client->errorValue = stuff->selection;
+ return (BadAtom);
+ }
+}
+
+int
+ProcGetSelectionOwner(register ClientPtr client)
+{
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ if (ValidAtom(stuff->id))
+ {
+ int i;
+ xGetSelectionOwnerReply reply;
+
+ i = 0;
+ while ((i < NumCurrentSelections) &&
+ CurrentSelections[i].selection != stuff->id) i++;
+ reply.type = X_Reply;
+ reply.length = 0;
+ reply.sequenceNumber = client->sequence;
+ if (i < NumCurrentSelections)
+ reply.owner = CurrentSelections[i].window;
+ else
+ reply.owner = None;
+ WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply);
+ return(client->noClientException);
+ }
+ else
+ {
+ client->errorValue = stuff->id;
+ return (BadAtom);
+ }
+}
+
+int
+ProcConvertSelection(register ClientPtr client)
+{
+ Bool paramsOkay;
+ xEvent event;
+ WindowPtr pWin;
+ REQUEST(xConvertSelectionReq);
+
+ REQUEST_SIZE_MATCH(xConvertSelectionReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->requestor, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+
+ paramsOkay = (ValidAtom(stuff->selection) && ValidAtom(stuff->target));
+ if (stuff->property != None)
+ paramsOkay &= ValidAtom(stuff->property);
+ if (paramsOkay)
+ {
+ int i;
+
+ i = 0;
+ while ((i < NumCurrentSelections) &&
+ CurrentSelections[i].selection != stuff->selection) i++;
+ if ((i < NumCurrentSelections) &&
+ (CurrentSelections[i].window != None)
+#ifdef XCSECURITY
+ && (!client->CheckAccess ||
+ (* client->CheckAccess)(client, CurrentSelections[i].window,
+ RT_WINDOW, SecurityReadAccess,
+ CurrentSelections[i].pWin))
+#endif
+ )
+ {
+ event.u.u.type = SelectionRequest;
+ event.u.selectionRequest.time = stuff->time;
+ event.u.selectionRequest.owner =
+ CurrentSelections[i].window;
+ event.u.selectionRequest.requestor = stuff->requestor;
+ event.u.selectionRequest.selection = stuff->selection;
+ event.u.selectionRequest.target = stuff->target;
+ event.u.selectionRequest.property = stuff->property;
+ if (TryClientEvents(
+ CurrentSelections[i].client, &event, 1, NoEventMask,
+ NoEventMask /* CantBeFiltered */, NullGrab))
+ return (client->noClientException);
+ }
+ event.u.u.type = SelectionNotify;
+ event.u.selectionNotify.time = stuff->time;
+ event.u.selectionNotify.requestor = stuff->requestor;
+ event.u.selectionNotify.selection = stuff->selection;
+ event.u.selectionNotify.target = stuff->target;
+ event.u.selectionNotify.property = None;
+ (void) TryClientEvents(client, &event, 1, NoEventMask,
+ NoEventMask /* CantBeFiltered */, NullGrab);
+ return (client->noClientException);
+ }
+ else
+ {
+ client->errorValue = stuff->property;
+ return (BadAtom);
+ }
+}
+
+int
+ProcGrabServer(register ClientPtr client)
+{
+ REQUEST_SIZE_MATCH(xReq);
+ if (grabState != GrabNone && client != grabClient)
+ {
+ ResetCurrentRequest(client);
+ client->sequence--;
+ BITSET(grabWaiters, client->index);
+ IgnoreClient(client);
+ return(client->noClientException);
+ }
+ OnlyListenToOneClient(client);
+ grabState = GrabKickout;
+ grabClient = client;
+
+ if (ServerGrabCallback)
+ {
+ ServerGrabInfoRec grabinfo;
+ grabinfo.client = client;
+ grabinfo.grabstate = SERVER_GRABBED;
+ CallCallbacks(&ServerGrabCallback, (pointer)&grabinfo);
+ }
+
+ return(client->noClientException);
+}
+
+static void
+UngrabServer(ClientPtr client)
+{
+ int i;
+
+ grabState = GrabNone;
+ ListenToAllClients();
+ for (i = mskcnt; --i >= 0 && !grabWaiters[i]; )
+ ;
+ if (i >= 0)
+ {
+ i <<= 5;
+ while (!GETBIT(grabWaiters, i))
+ i++;
+ BITCLEAR(grabWaiters, i);
+ AttendClient(clients[i]);
+ }
+
+ if (ServerGrabCallback)
+ {
+ ServerGrabInfoRec grabinfo;
+ grabinfo.client = client;
+ grabinfo.grabstate = SERVER_UNGRABBED;
+ CallCallbacks(&ServerGrabCallback, (pointer)&grabinfo);
+ }
+}
+
+int
+ProcUngrabServer(register ClientPtr client)
+{
+ REQUEST_SIZE_MATCH(xReq);
+ UngrabServer(client);
+ return(client->noClientException);
+}
+
+int
+ProcTranslateCoords(register ClientPtr client)
+{
+ REQUEST(xTranslateCoordsReq);
+
+ register WindowPtr pWin, pDst;
+ xTranslateCoordsReply rep;
+
+ REQUEST_SIZE_MATCH(xTranslateCoordsReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->srcWid, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ pDst = (WindowPtr)SecurityLookupWindow(stuff->dstWid, client,
+ SecurityReadAccess);
+ if (!pDst)
+ return(BadWindow);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ if (!SAME_SCREENS(pWin->drawable, pDst->drawable))
+ {
+ rep.sameScreen = xFalse;
+ rep.child = None;
+ rep.dstX = rep.dstY = 0;
+ }
+ else
+ {
+ INT16 x, y;
+ rep.sameScreen = xTrue;
+ rep.child = None;
+ /* computing absolute coordinates -- adjust to destination later */
+ x = pWin->drawable.x + stuff->srcX;
+ y = pWin->drawable.y + stuff->srcY;
+ pWin = pDst->firstChild;
+ while (pWin)
+ {
+#ifdef SHAPE
+ BoxRec box;
+#endif
+ if ((pWin->mapped) &&
+ (x >= pWin->drawable.x - wBorderWidth (pWin)) &&
+ (x < pWin->drawable.x + (int)pWin->drawable.width +
+ wBorderWidth (pWin)) &&
+ (y >= pWin->drawable.y - wBorderWidth (pWin)) &&
+ (y < pWin->drawable.y + (int)pWin->drawable.height +
+ wBorderWidth (pWin))
+#ifdef SHAPE
+ /* When a window is shaped, a further check
+ * is made to see if the point is inside
+ * borderSize
+ */
+ && (!wBoundingShape(pWin) ||
+ POINT_IN_REGION(pWin->drawable.pScreen,
+ &pWin->borderSize, x, y, &box))
+
+ && (!wInputShape(pWin) ||
+ POINT_IN_REGION(pWin->drawable.pScreen,
+ wInputShape(pWin),
+ x - pWin->drawable.x,
+ y - pWin->drawable.y, &box))
+#endif
+ )
+ {
+ rep.child = pWin->drawable.id;
+ pWin = (WindowPtr) NULL;
+ }
+ else
+ pWin = pWin->nextSib;
+ }
+ /* adjust to destination coordinates */
+ rep.dstX = x - pDst->drawable.x;
+ rep.dstY = y - pDst->drawable.y;
+ }
+ WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep);
+ return(client->noClientException);
+}
+
+int
+ProcOpenFont(register ClientPtr client)
+{
+ int err;
+ REQUEST(xOpenFontReq);
+
+ REQUEST_FIXED_SIZE(xOpenFontReq, stuff->nbytes);
+ client->errorValue = stuff->fid;
+ LEGAL_NEW_RESOURCE(stuff->fid, client);
+ err = OpenFont(client, stuff->fid, (Mask) 0,
+ stuff->nbytes, (char *)&stuff[1]);
+ if (err == Success)
+ {
+ return(client->noClientException);
+ }
+ else
+ return err;
+}
+
+int
+ProcCloseFont(register ClientPtr client)
+{
+ FontPtr pFont;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT,
+ SecurityDestroyAccess);
+ if ( pFont != (FontPtr)NULL) /* id was valid */
+ {
+ FreeResource(stuff->id, RT_NONE);
+ return(client->noClientException);
+ }
+ else
+ {
+ client->errorValue = stuff->id;
+ return (BadFont);
+ }
+}
+
+int
+ProcQueryFont(register ClientPtr client)
+{
+ xQueryFontReply *reply;
+ FontPtr pFont;
+ register GC *pGC;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ client->errorValue = stuff->id; /* EITHER font or gc */
+ pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT,
+ SecurityReadAccess);
+ if (!pFont)
+ {
+ /* can't use VERIFY_GC because it might return BadGC */
+ pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC,
+ SecurityReadAccess);
+ if (!pGC)
+ {
+ client->errorValue = stuff->id;
+ return(BadFont); /* procotol spec says only error is BadFont */
+ }
+ pFont = pGC->font;
+ }
+
+ {
+ xCharInfo *pmax = FONTINKMAX(pFont);
+ xCharInfo *pmin = FONTINKMIN(pFont);
+ int nprotoxcistructs;
+ int rlength;
+
+ nprotoxcistructs = (
+ pmax->rightSideBearing == pmin->rightSideBearing &&
+ pmax->leftSideBearing == pmin->leftSideBearing &&
+ pmax->descent == pmin->descent &&
+ pmax->ascent == pmin->ascent &&
+ pmax->characterWidth == pmin->characterWidth) ?
+ 0 : N2dChars(pFont);
+
+ rlength = sizeof(xQueryFontReply) +
+ FONTINFONPROPS(FONTCHARSET(pFont)) * sizeof(xFontProp) +
+ nprotoxcistructs * sizeof(xCharInfo);
+ reply = (xQueryFontReply *)ALLOCATE_LOCAL(rlength);
+ if(!reply)
+ {
+ return(BadAlloc);
+ }
+
+ reply->type = X_Reply;
+ reply->length = (rlength - sizeof(xGenericReply)) >> 2;
+ reply->sequenceNumber = client->sequence;
+ QueryFont( pFont, reply, nprotoxcistructs);
+
+ WriteReplyToClient(client, rlength, reply);
+ DEALLOCATE_LOCAL(reply);
+ return(client->noClientException);
+ }
+}
+
+int
+ProcQueryTextExtents(register ClientPtr client)
+{
+ REQUEST(xQueryTextExtentsReq);
+ xQueryTextExtentsReply reply;
+ FontPtr pFont;
+ GC *pGC;
+ ExtentInfoRec info;
+ unsigned long length;
+
+ REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq);
+
+ pFont = (FontPtr)SecurityLookupIDByType(client, stuff->fid, RT_FONT,
+ SecurityReadAccess);
+ if (!pFont)
+ {
+ pGC = (GC *)SecurityLookupIDByType(client, stuff->fid, RT_GC,
+ SecurityReadAccess);
+ if (!pGC)
+ {
+ client->errorValue = stuff->fid;
+ return(BadFont);
+ }
+ pFont = pGC->font;
+ }
+ length = client->req_len - (sizeof(xQueryTextExtentsReq) >> 2);
+ length = length << 1;
+ if (stuff->oddLength)
+ {
+ if (length == 0)
+ return(BadLength);
+ length--;
+ }
+ if (!QueryTextExtents(pFont, length, (unsigned char *)&stuff[1], &info))
+ return(BadAlloc);
+ reply.type = X_Reply;
+ reply.length = 0;
+ reply.sequenceNumber = client->sequence;
+ reply.drawDirection = info.drawDirection;
+ reply.fontAscent = info.fontAscent;
+ reply.fontDescent = info.fontDescent;
+ reply.overallAscent = info.overallAscent;
+ reply.overallDescent = info.overallDescent;
+ reply.overallWidth = info.overallWidth;
+ reply.overallLeft = info.overallLeft;
+ reply.overallRight = info.overallRight;
+ WriteReplyToClient(client, sizeof(xQueryTextExtentsReply), &reply);
+ return(client->noClientException);
+}
+
+int
+ProcListFonts(register ClientPtr client)
+{
+ REQUEST(xListFontsReq);
+
+ REQUEST_FIXED_SIZE(xListFontsReq, stuff->nbytes);
+
+ return ListFonts(client, (unsigned char *) &stuff[1], stuff->nbytes,
+ stuff->maxNames);
+}
+
+int
+ProcListFontsWithInfo(register ClientPtr client)
+{
+ REQUEST(xListFontsWithInfoReq);
+
+ REQUEST_FIXED_SIZE(xListFontsWithInfoReq, stuff->nbytes);
+
+ return StartListFontsWithInfo(client, stuff->nbytes,
+ (unsigned char *) &stuff[1], stuff->maxNames);
+}
+
+/**
+ *
+ * \param value must conform to DeleteType
+ */
+int
+dixDestroyPixmap(pointer value, XID pid)
+{
+ PixmapPtr pPixmap = (PixmapPtr)value;
+ return (*pPixmap->drawable.pScreen->DestroyPixmap)(pPixmap);
+}
+
+int
+ProcCreatePixmap(register ClientPtr client)
+{
+ PixmapPtr pMap;
+ register DrawablePtr pDraw;
+ REQUEST(xCreatePixmapReq);
+ DepthPtr pDepth;
+ register int i;
+
+ REQUEST_SIZE_MATCH(xCreatePixmapReq);
+ client->errorValue = stuff->pid;
+ LEGAL_NEW_RESOURCE(stuff->pid, client);
+ SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client,
+ SecurityReadAccess);
+ if (!stuff->width || !stuff->height)
+ {
+ client->errorValue = 0;
+ return BadValue;
+ }
+ if (stuff->width > 32767 || stuff->height > 32767)
+ {
+ /* It is allowed to try and allocate a pixmap which is larger than
+ * 32767 in either dimension. However, all of the framebuffer code
+ * is buggy and does not reliably draw to such big pixmaps, basically
+ * because the Region data structure operates with signed shorts
+ * for the rectangles in it.
+ *
+ * Furthermore, several places in the X server computes the
+ * size in bytes of the pixmap and tries to store it in an
+ * integer. This integer can overflow and cause the allocated size
+ * to be much smaller.
+ *
+ * So, such big pixmaps are rejected here with a BadAlloc
+ */
+ return BadAlloc;
+ }
+ if (stuff->depth != 1)
+ {
+ pDepth = pDraw->pScreen->allowedDepths;
+ for (i=0; i<pDraw->pScreen->numDepths; i++, pDepth++)
+ if (pDepth->depth == stuff->depth)
+ goto CreatePmap;
+ client->errorValue = stuff->depth;
+ return BadValue;
+ }
+CreatePmap:
+ pMap = (PixmapPtr)(*pDraw->pScreen->CreatePixmap)
+ (pDraw->pScreen, stuff->width,
+ stuff->height, stuff->depth);
+ if (pMap)
+ {
+ pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pMap->drawable.id = stuff->pid;
+ if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap))
+ return(client->noClientException);
+ }
+ return (BadAlloc);
+}
+
+int
+ProcFreePixmap(register ClientPtr client)
+{
+ PixmapPtr pMap;
+
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pMap = (PixmapPtr)SecurityLookupIDByType(client, stuff->id, RT_PIXMAP,
+ SecurityDestroyAccess);
+ if (pMap)
+ {
+ FreeResource(stuff->id, RT_NONE);
+ return(client->noClientException);
+ }
+ else
+ {
+ client->errorValue = stuff->id;
+ return (BadPixmap);
+ }
+}
+
+int
+ProcCreateGC(register ClientPtr client)
+{
+ int error;
+ GC *pGC;
+ register DrawablePtr pDraw;
+ unsigned len;
+ REQUEST(xCreateGCReq);
+
+ REQUEST_AT_LEAST_SIZE(xCreateGCReq);
+ client->errorValue = stuff->gc;
+ LEGAL_NEW_RESOURCE(stuff->gc, client);
+ SECURITY_VERIFY_DRAWABLE (pDraw, stuff->drawable, client,
+ SecurityReadAccess);
+ len = client->req_len - (sizeof(xCreateGCReq) >> 2);
+ if (len != Ones(stuff->mask))
+ return BadLength;
+ pGC = (GC *)CreateGC(pDraw, stuff->mask,
+ (XID *) &stuff[1], &error);
+ if (error != Success)
+ return error;
+ if (!AddResource(stuff->gc, RT_GC, (pointer)pGC))
+ return (BadAlloc);
+ return(client->noClientException);
+}
+
+int
+ProcChangeGC(register ClientPtr client)
+{
+ GC *pGC;
+ REQUEST(xChangeGCReq);
+ int result;
+ unsigned len;
+
+ REQUEST_AT_LEAST_SIZE(xChangeGCReq);
+ SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityWriteAccess);
+ len = client->req_len - (sizeof(xChangeGCReq) >> 2);
+ if (len != Ones(stuff->mask))
+ return BadLength;
+
+ result = dixChangeGC(client, pGC, stuff->mask, (CARD32 *) &stuff[1], 0);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ {
+ client->errorValue = clientErrorValue;
+ return(result);
+ }
+}
+
+int
+ProcCopyGC(register ClientPtr client)
+{
+ register GC *dstGC;
+ register GC *pGC;
+ int result;
+ REQUEST(xCopyGCReq);
+
+ REQUEST_SIZE_MATCH(xCopyGCReq);
+ SECURITY_VERIFY_GC( pGC, stuff->srcGC, client, SecurityReadAccess);
+ SECURITY_VERIFY_GC( dstGC, stuff->dstGC, client, SecurityWriteAccess);
+ if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth))
+ return (BadMatch);
+ result = CopyGC(pGC, dstGC, stuff->mask);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ {
+ client->errorValue = clientErrorValue;
+ return(result);
+ }
+}
+
+int
+ProcSetDashes(register ClientPtr client)
+{
+ register GC *pGC;
+ int result;
+ REQUEST(xSetDashesReq);
+
+ REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes);
+ if (stuff->nDashes == 0)
+ {
+ client->errorValue = 0;
+ return BadValue;
+ }
+
+ SECURITY_VERIFY_GC(pGC,stuff->gc, client, SecurityWriteAccess);
+
+ result = SetDashes(pGC, stuff->dashOffset, stuff->nDashes,
+ (unsigned char *)&stuff[1]);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ {
+ client->errorValue = clientErrorValue;
+ return(result);
+ }
+}
+
+int
+ProcSetClipRectangles(register ClientPtr client)
+{
+ int nr;
+ int result;
+ register GC *pGC;
+ REQUEST(xSetClipRectanglesReq);
+
+ REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq);
+ if ((stuff->ordering != Unsorted) && (stuff->ordering != YSorted) &&
+ (stuff->ordering != YXSorted) && (stuff->ordering != YXBanded))
+ {
+ client->errorValue = stuff->ordering;
+ return BadValue;
+ }
+ SECURITY_VERIFY_GC(pGC,stuff->gc, client, SecurityWriteAccess);
+
+ nr = (client->req_len << 2) - sizeof(xSetClipRectanglesReq);
+ if (nr & 4)
+ return(BadLength);
+ nr >>= 3;
+ result = SetClipRects(pGC, stuff->xOrigin, stuff->yOrigin,
+ nr, (xRectangle *)&stuff[1], (int)stuff->ordering);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return(result);
+}
+
+int
+ProcFreeGC(register ClientPtr client)
+{
+ register GC *pGC;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ SECURITY_VERIFY_GC(pGC, stuff->id, client, SecurityDestroyAccess);
+ FreeResource(stuff->id, RT_NONE);
+ return(client->noClientException);
+}
+
+int
+ProcClearToBackground(register ClientPtr client)
+{
+ REQUEST(xClearAreaReq);
+ register WindowPtr pWin;
+
+ REQUEST_SIZE_MATCH(xClearAreaReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityWriteAccess);
+ if (!pWin)
+ return(BadWindow);
+ if (pWin->drawable.class == InputOnly)
+ {
+ client->errorValue = stuff->window;
+ return (BadMatch);
+ }
+ if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse))
+ {
+ client->errorValue = stuff->exposures;
+ return(BadValue);
+ }
+ (*pWin->drawable.pScreen->ClearToBackground)(pWin, stuff->x, stuff->y,
+ stuff->width, stuff->height,
+ (Bool)stuff->exposures);
+ return(client->noClientException);
+}
+
+int
+ProcCopyArea(register ClientPtr client)
+{
+ register DrawablePtr pDst;
+ register DrawablePtr pSrc;
+ register GC *pGC;
+ REQUEST(xCopyAreaReq);
+ RegionPtr pRgn;
+
+ REQUEST_SIZE_MATCH(xCopyAreaReq);
+
+ VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client);
+ if (stuff->dstDrawable != stuff->srcDrawable)
+ {
+ SECURITY_VERIFY_DRAWABLE(pSrc, stuff->srcDrawable, client,
+ SecurityReadAccess);
+ if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth))
+ {
+ client->errorValue = stuff->dstDrawable;
+ return (BadMatch);
+ }
+ }
+ else
+ pSrc = pDst;
+
+ SET_DBE_SRCBUF(pSrc, stuff->srcDrawable);
+
+ pRgn = (*pGC->ops->CopyArea)(pSrc, pDst, pGC, stuff->srcX, stuff->srcY,
+ stuff->width, stuff->height,
+ stuff->dstX, stuff->dstY);
+ if (pGC->graphicsExposures)
+ {
+ (*pDst->pScreen->SendGraphicsExpose)
+ (client, pRgn, stuff->dstDrawable, X_CopyArea, 0);
+ if (pRgn)
+ REGION_DESTROY(pDst->pScreen, pRgn);
+ }
+
+ return(client->noClientException);
+}
+
+int
+ProcCopyPlane(register ClientPtr client)
+{
+ register DrawablePtr psrcDraw, pdstDraw;
+ register GC *pGC;
+ REQUEST(xCopyPlaneReq);
+ RegionPtr pRgn;
+
+ REQUEST_SIZE_MATCH(xCopyPlaneReq);
+
+ VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, pGC, client);
+ if (stuff->dstDrawable != stuff->srcDrawable)
+ {
+ SECURITY_VERIFY_DRAWABLE(psrcDraw, stuff->srcDrawable, client,
+ SecurityReadAccess);
+ if (pdstDraw->pScreen != psrcDraw->pScreen)
+ {
+ client->errorValue = stuff->dstDrawable;
+ return (BadMatch);
+ }
+ }
+ else
+ psrcDraw = pdstDraw;
+
+ SET_DBE_SRCBUF(psrcDraw, stuff->srcDrawable);
+
+ /* Check to see if stuff->bitPlane has exactly ONE good bit set */
+ if(stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) ||
+ (stuff->bitPlane > (1L << (psrcDraw->depth - 1))))
+ {
+ client->errorValue = stuff->bitPlane;
+ return(BadValue);
+ }
+
+ pRgn = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC, stuff->srcX, stuff->srcY,
+ stuff->width, stuff->height,
+ stuff->dstX, stuff->dstY, stuff->bitPlane);
+ if (pGC->graphicsExposures)
+ {
+ (*pdstDraw->pScreen->SendGraphicsExpose)
+ (client, pRgn, stuff->dstDrawable, X_CopyPlane, 0);
+ if (pRgn)
+ REGION_DESTROY(pdstDraw->pScreen, pRgn);
+ }
+ return(client->noClientException);
+}
+
+int
+ProcPolyPoint(register ClientPtr client)
+{
+ int npoint;
+ register GC *pGC;
+ register DrawablePtr pDraw;
+ REQUEST(xPolyPointReq);
+
+ REQUEST_AT_LEAST_SIZE(xPolyPointReq);
+ if ((stuff->coordMode != CoordModeOrigin) &&
+ (stuff->coordMode != CoordModePrevious))
+ {
+ client->errorValue = stuff->coordMode;
+ return BadValue;
+ }
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2;
+ if (npoint)
+ (*pGC->ops->PolyPoint)(pDraw, pGC, stuff->coordMode, npoint,
+ (xPoint *) &stuff[1]);
+ return (client->noClientException);
+}
+
+int
+ProcPolyLine(register ClientPtr client)
+{
+ int npoint;
+ register GC *pGC;
+ register DrawablePtr pDraw;
+ REQUEST(xPolyLineReq);
+
+ REQUEST_AT_LEAST_SIZE(xPolyLineReq);
+ if ((stuff->coordMode != CoordModeOrigin) &&
+ (stuff->coordMode != CoordModePrevious))
+ {
+ client->errorValue = stuff->coordMode;
+ return BadValue;
+ }
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2;
+ if (npoint > 1)
+ (*pGC->ops->Polylines)(pDraw, pGC, stuff->coordMode, npoint,
+ (DDXPointPtr) &stuff[1]);
+ return(client->noClientException);
+}
+
+int
+ProcPolySegment(register ClientPtr client)
+{
+ int nsegs;
+ register GC *pGC;
+ register DrawablePtr pDraw;
+ REQUEST(xPolySegmentReq);
+
+ REQUEST_AT_LEAST_SIZE(xPolySegmentReq);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq);
+ if (nsegs & 4)
+ return(BadLength);
+ nsegs >>= 3;
+ if (nsegs)
+ (*pGC->ops->PolySegment)(pDraw, pGC, nsegs, (xSegment *) &stuff[1]);
+ return (client->noClientException);
+}
+
+int
+ProcPolyRectangle (register ClientPtr client)
+{
+ int nrects;
+ register GC *pGC;
+ register DrawablePtr pDraw;
+ REQUEST(xPolyRectangleReq);
+
+ REQUEST_AT_LEAST_SIZE(xPolyRectangleReq);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq);
+ if (nrects & 4)
+ return(BadLength);
+ nrects >>= 3;
+ if (nrects)
+ (*pGC->ops->PolyRectangle)(pDraw, pGC,
+ nrects, (xRectangle *) &stuff[1]);
+ return(client->noClientException);
+}
+
+int
+ProcPolyArc(register ClientPtr client)
+{
+ int narcs;
+ register GC *pGC;
+ register DrawablePtr pDraw;
+ REQUEST(xPolyArcReq);
+
+ REQUEST_AT_LEAST_SIZE(xPolyArcReq);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ narcs = (client->req_len << 2) - sizeof(xPolyArcReq);
+ if (narcs % sizeof(xArc))
+ return(BadLength);
+ narcs /= sizeof(xArc);
+ if (narcs)
+ (*pGC->ops->PolyArc)(pDraw, pGC, narcs, (xArc *) &stuff[1]);
+ return (client->noClientException);
+}
+
+int
+ProcFillPoly(register ClientPtr client)
+{
+ int things;
+ register GC *pGC;
+ register DrawablePtr pDraw;
+ REQUEST(xFillPolyReq);
+
+ REQUEST_AT_LEAST_SIZE(xFillPolyReq);
+ if ((stuff->shape != Complex) && (stuff->shape != Nonconvex) &&
+ (stuff->shape != Convex))
+ {
+ client->errorValue = stuff->shape;
+ return BadValue;
+ }
+ if ((stuff->coordMode != CoordModeOrigin) &&
+ (stuff->coordMode != CoordModePrevious))
+ {
+ client->errorValue = stuff->coordMode;
+ return BadValue;
+ }
+
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ things = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2;
+ if (things)
+ (*pGC->ops->FillPolygon) (pDraw, pGC, stuff->shape,
+ stuff->coordMode, things,
+ (DDXPointPtr) &stuff[1]);
+ return(client->noClientException);
+}
+
+int
+ProcPolyFillRectangle(register ClientPtr client)
+{
+ int things;
+ register GC *pGC;
+ register DrawablePtr pDraw;
+ REQUEST(xPolyFillRectangleReq);
+
+ REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq);
+ if (things & 4)
+ return(BadLength);
+ things >>= 3;
+
+ if (things)
+ (*pGC->ops->PolyFillRect) (pDraw, pGC, things,
+ (xRectangle *) &stuff[1]);
+ return (client->noClientException);
+}
+
+int
+ProcPolyFillArc(register ClientPtr client)
+{
+ int narcs;
+ register GC *pGC;
+ register DrawablePtr pDraw;
+ REQUEST(xPolyFillArcReq);
+
+ REQUEST_AT_LEAST_SIZE(xPolyFillArcReq);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq);
+ if (narcs % sizeof(xArc))
+ return(BadLength);
+ narcs /= sizeof(xArc);
+ if (narcs)
+ (*pGC->ops->PolyFillArc) (pDraw, pGC, narcs, (xArc *) &stuff[1]);
+ return (client->noClientException);
+}
+
+#ifdef MATCH_CLIENT_ENDIAN
+
+int
+ServerOrder (void)
+{
+ int whichbyte = 1;
+
+ if (*((char *) &whichbyte))
+ return LSBFirst;
+ return MSBFirst;
+}
+
+#define ClientOrder(client) ((client)->swapped ? !ServerOrder() : ServerOrder())
+
+void
+ReformatImage (char *base, int nbytes, int bpp, int order)
+{
+ switch (bpp) {
+ case 1: /* yuck */
+ if (BITMAP_BIT_ORDER != order)
+ BitOrderInvert ((unsigned char *) base, nbytes);
+#if IMAGE_BYTE_ORDER != BITMAP_BIT_ORDER && BITMAP_SCANLINE_UNIT != 8
+ ReformatImage (base, nbytes, BITMAP_SCANLINE_UNIT, order);
+#endif
+ break;
+ case 4:
+ break; /* yuck */
+ case 8:
+ break;
+ case 16:
+ if (IMAGE_BYTE_ORDER != order)
+ TwoByteSwap ((unsigned char *) base, nbytes);
+ break;
+ case 32:
+ if (IMAGE_BYTE_ORDER != order)
+ FourByteSwap ((unsigned char *) base, nbytes);
+ break;
+ }
+}
+#else
+#define ReformatImage(b,n,bpp,o)
+#endif
+
+/* 64-bit server notes: the protocol restricts padding of images to
+ * 8-, 16-, or 32-bits. We would like to have 64-bits for the server
+ * to use internally. Removes need for internal alignment checking.
+ * All of the PutImage functions could be changed individually, but
+ * as currently written, they call other routines which require things
+ * to be 64-bit padded on scanlines, so we changed things here.
+ * If an image would be padded differently for 64- versus 32-, then
+ * copy each scanline to a 64-bit padded scanline.
+ * Also, we need to make sure that the image is aligned on a 64-bit
+ * boundary, even if the scanlines are padded to our satisfaction.
+ */
+int
+ProcPutImage(register ClientPtr client)
+{
+ register GC *pGC;
+ register DrawablePtr pDraw;
+ long length; /* length of scanline server padded */
+ long lengthProto; /* length of scanline protocol padded */
+ char *tmpImage;
+ REQUEST(xPutImageReq);
+
+ REQUEST_AT_LEAST_SIZE(xPutImageReq);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ if (stuff->format == XYBitmap)
+ {
+ if ((stuff->depth != 1) ||
+ (stuff->leftPad >= (unsigned int)screenInfo.bitmapScanlinePad))
+ return BadMatch;
+ length = BitmapBytePad(stuff->width + stuff->leftPad);
+ }
+ else if (stuff->format == XYPixmap)
+ {
+ if ((pDraw->depth != stuff->depth) ||
+ (stuff->leftPad >= (unsigned int)screenInfo.bitmapScanlinePad))
+ return BadMatch;
+ length = BitmapBytePad(stuff->width + stuff->leftPad);
+ length *= stuff->depth;
+ }
+ else if (stuff->format == ZPixmap)
+ {
+ if ((pDraw->depth != stuff->depth) || (stuff->leftPad != 0))
+ return BadMatch;
+ length = PixmapBytePad(stuff->width, stuff->depth);
+ }
+ else
+ {
+ client->errorValue = stuff->format;
+ return BadValue;
+ }
+
+ tmpImage = (char *)&stuff[1];
+ lengthProto = length;
+
+ if (((((lengthProto * stuff->height) + (unsigned)3) >> 2) +
+ (sizeof(xPutImageReq) >> 2)) != client->req_len)
+ return BadLength;
+
+ ReformatImage (tmpImage, lengthProto * stuff->height,
+ stuff->format == ZPixmap ? BitsPerPixel (stuff->depth) : 1,
+ ClientOrder(client));
+
+ (*pGC->ops->PutImage) (pDraw, pGC, stuff->depth, stuff->dstX, stuff->dstY,
+ stuff->width, stuff->height,
+ stuff->leftPad, stuff->format, tmpImage);
+
+ return (client->noClientException);
+}
+
+
+int
+DoGetImage(register ClientPtr client, int format, Drawable drawable,
+ int x, int y, int width, int height,
+ Mask planemask, xGetImageReply **im_return)
+{
+ register DrawablePtr pDraw;
+ int nlines, linesPerBuf;
+ register int linesDone;
+ long widthBytesLine, length;
+ Mask plane = 0;
+ char *pBuf;
+ xGetImageReply xgi;
+#ifdef XCSECURITY
+ RegionPtr pVisibleRegion = NULL;
+#endif
+
+ if ((format != XYPixmap) && (format != ZPixmap))
+ {
+ client->errorValue = format;
+ return(BadValue);
+ }
+ SECURITY_VERIFY_DRAWABLE(pDraw, drawable, client, SecurityReadAccess);
+ if(pDraw->type == DRAWABLE_WINDOW)
+ {
+ if( /* check for being viewable */
+ !((WindowPtr) pDraw)->realized ||
+ /* check for being on screen */
+ pDraw->x + x < 0 ||
+ pDraw->x + x + width > pDraw->pScreen->width ||
+ pDraw->y + y < 0 ||
+ pDraw->y + y + height > pDraw->pScreen->height ||
+ /* check for being inside of border */
+ x < - wBorderWidth((WindowPtr)pDraw) ||
+ x + width > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
+ y < -wBorderWidth((WindowPtr)pDraw) ||
+ y + height > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height
+ )
+ return(BadMatch);
+ xgi.visual = wVisual (((WindowPtr) pDraw));
+ }
+ else
+ {
+ if(x < 0 ||
+ x+width > (int)pDraw->width ||
+ y < 0 ||
+ y+height > (int)pDraw->height
+ )
+ return(BadMatch);
+ xgi.visual = None;
+ }
+
+ SET_DBE_SRCBUF(pDraw, drawable);
+
+ xgi.type = X_Reply;
+ xgi.sequenceNumber = client->sequence;
+ xgi.depth = pDraw->depth;
+ if(format == ZPixmap)
+ {
+ widthBytesLine = PixmapBytePad(width, pDraw->depth);
+ length = widthBytesLine * height;
+
+ }
+ else
+ {
+ widthBytesLine = BitmapBytePad(width);
+ plane = ((Mask)1) << (pDraw->depth - 1);
+ /* only planes asked for */
+ length = widthBytesLine * height *
+ Ones(planemask & (plane | (plane - 1)));
+
+ }
+
+ xgi.length = length;
+
+ if (im_return) {
+ pBuf = (char *)xalloc(sz_xGetImageReply + length);
+ if (!pBuf)
+ return (BadAlloc);
+ if (widthBytesLine == 0)
+ linesPerBuf = 0;
+ else
+ linesPerBuf = height;
+ *im_return = (xGetImageReply *)pBuf;
+ *(xGetImageReply *)pBuf = xgi;
+ pBuf += sz_xGetImageReply;
+ } else {
+ xgi.length = (xgi.length + 3) >> 2;
+ if (widthBytesLine == 0 || height == 0)
+ linesPerBuf = 0;
+ else if (widthBytesLine >= IMAGE_BUFSIZE)
+ linesPerBuf = 1;
+ else
+ {
+ linesPerBuf = IMAGE_BUFSIZE / widthBytesLine;
+ if (linesPerBuf > height)
+ linesPerBuf = height;
+ }
+ length = linesPerBuf * widthBytesLine;
+ if (linesPerBuf < height)
+ {
+ /* we have to make sure intermediate buffers don't need padding */
+ while ((linesPerBuf > 1) &&
+ (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD)-1)))
+ {
+ linesPerBuf--;
+ length -= widthBytesLine;
+ }
+ while (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD)-1))
+ {
+ linesPerBuf++;
+ length += widthBytesLine;
+ }
+ }
+ if(!(pBuf = (char *) ALLOCATE_LOCAL(length)))
+ return (BadAlloc);
+ WriteReplyToClient(client, sizeof (xGetImageReply), &xgi);
+ }
+
+#ifdef XCSECURITY
+ if (client->trustLevel != XSecurityClientTrusted &&
+ pDraw->type == DRAWABLE_WINDOW)
+ {
+ pVisibleRegion = NotClippedByChildren((WindowPtr)pDraw);
+ if (pVisibleRegion)
+ {
+ REGION_TRANSLATE(pDraw->pScreen, pVisibleRegion, -pDraw->x, -pDraw->y);
+ }
+ }
+#endif
+
+ if (linesPerBuf == 0)
+ {
+ /* nothing to do */
+ }
+ else if (format == ZPixmap)
+ {
+ linesDone = 0;
+ while (height - linesDone > 0)
+ {
+ nlines = min(linesPerBuf, height - linesDone);
+ (*pDraw->pScreen->GetImage) (pDraw,
+ x,
+ y + linesDone,
+ width,
+ nlines,
+ format,
+ planemask,
+ (pointer) pBuf);
+#ifdef XCSECURITY
+ if (pVisibleRegion)
+ SecurityCensorImage(client, pVisibleRegion, widthBytesLine,
+ pDraw, x, y + linesDone, width,
+ nlines, format, pBuf);
+#endif
+
+ /* Note that this is NOT a call to WriteSwappedDataToClient,
+ as we do NOT byte swap */
+ if (!im_return)
+ {
+ ReformatImage (pBuf, (int)(nlines * widthBytesLine),
+ BitsPerPixel (pDraw->depth),
+ ClientOrder(client));
+
+/* Don't split me, gcc pukes when you do */
+ (void)WriteToClient(client,
+ (int)(nlines * widthBytesLine),
+ pBuf);
+ }
+ linesDone += nlines;
+ }
+ }
+ else /* XYPixmap */
+ {
+ for (; plane; plane >>= 1)
+ {
+ if (planemask & plane)
+ {
+ linesDone = 0;
+ while (height - linesDone > 0)
+ {
+ nlines = min(linesPerBuf, height - linesDone);
+ (*pDraw->pScreen->GetImage) (pDraw,
+ x,
+ y + linesDone,
+ width,
+ nlines,
+ format,
+ plane,
+ (pointer)pBuf);
+#ifdef XCSECURITY
+ if (pVisibleRegion)
+ SecurityCensorImage(client, pVisibleRegion,
+ widthBytesLine,
+ pDraw, x, y + linesDone, width,
+ nlines, format, pBuf);
+#endif
+
+ /* Note: NOT a call to WriteSwappedDataToClient,
+ as we do NOT byte swap */
+ if (im_return) {
+ pBuf += nlines * widthBytesLine;
+ } else {
+ ReformatImage (pBuf,
+ (int)(nlines * widthBytesLine),
+ 1,
+ ClientOrder (client));
+
+/* Don't split me, gcc pukes when you do */
+ (void)WriteToClient(client,
+ (int)(nlines * widthBytesLine),
+ pBuf);
+ }
+ linesDone += nlines;
+ }
+ }
+ }
+ }
+#ifdef XCSECURITY
+ if (pVisibleRegion)
+ REGION_DESTROY(pDraw->pScreen, pVisibleRegion);
+#endif
+ if (!im_return)
+ DEALLOCATE_LOCAL(pBuf);
+ return (client->noClientException);
+}
+
+int
+ProcGetImage(register ClientPtr client)
+{
+ REQUEST(xGetImageReq);
+
+ REQUEST_SIZE_MATCH(xGetImageReq);
+
+ return DoGetImage(client, stuff->format, stuff->drawable,
+ stuff->x, stuff->y,
+ (int)stuff->width, (int)stuff->height,
+ stuff->planeMask, (xGetImageReply **)NULL);
+}
+
+int
+ProcPolyText(register ClientPtr client)
+{
+ int err;
+ REQUEST(xPolyTextReq);
+ DrawablePtr pDraw;
+ GC *pGC;
+
+ REQUEST_AT_LEAST_SIZE(xPolyTextReq);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+
+ err = PolyText(client,
+ pDraw,
+ pGC,
+ (unsigned char *)&stuff[1],
+ ((unsigned char *) stuff) + (client->req_len << 2),
+ stuff->x,
+ stuff->y,
+ stuff->reqType,
+ stuff->drawable);
+
+ if (err == Success)
+ {
+ return(client->noClientException);
+ }
+ else
+ return err;
+}
+
+int
+ProcImageText8(register ClientPtr client)
+{
+ int err;
+ register DrawablePtr pDraw;
+ register GC *pGC;
+
+ REQUEST(xImageTextReq);
+
+ REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+
+ err = ImageText(client,
+ pDraw,
+ pGC,
+ stuff->nChars,
+ (unsigned char *)&stuff[1],
+ stuff->x,
+ stuff->y,
+ stuff->reqType,
+ stuff->drawable);
+
+ if (err == Success)
+ {
+ return(client->noClientException);
+ }
+ else
+ return err;
+}
+
+int
+ProcImageText16(register ClientPtr client)
+{
+ int err;
+ register DrawablePtr pDraw;
+ register GC *pGC;
+
+ REQUEST(xImageTextReq);
+
+ REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+
+ err = ImageText(client,
+ pDraw,
+ pGC,
+ stuff->nChars,
+ (unsigned char *)&stuff[1],
+ stuff->x,
+ stuff->y,
+ stuff->reqType,
+ stuff->drawable);
+
+ if (err == Success)
+ {
+ return(client->noClientException);
+ }
+ else
+ return err;
+}
+
+
+int
+ProcCreateColormap(register ClientPtr client)
+{
+ VisualPtr pVisual;
+ ColormapPtr pmap;
+ Colormap mid;
+ register WindowPtr pWin;
+ ScreenPtr pScreen;
+ REQUEST(xCreateColormapReq);
+ int i, result;
+
+ REQUEST_SIZE_MATCH(xCreateColormapReq);
+
+ if ((stuff->alloc != AllocNone) && (stuff->alloc != AllocAll))
+ {
+ client->errorValue = stuff->alloc;
+ return(BadValue);
+ }
+ mid = stuff->mid;
+ LEGAL_NEW_RESOURCE(mid, client);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+
+ pScreen = pWin->drawable.pScreen;
+ for (i = 0, pVisual = pScreen->visuals;
+ i < pScreen->numVisuals;
+ i++, pVisual++)
+ {
+ if (pVisual->vid != stuff->visual)
+ continue;
+ result = CreateColormap(mid, pScreen, pVisual, &pmap,
+ (int)stuff->alloc, client->index);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return(result);
+ }
+ client->errorValue = stuff->visual;
+ return(BadValue);
+}
+
+int
+ProcFreeColormap(register ClientPtr client)
+{
+ ColormapPtr pmap;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pmap = (ColormapPtr )SecurityLookupIDByType(client, stuff->id, RT_COLORMAP,
+ SecurityDestroyAccess);
+ if (pmap)
+ {
+ /* Freeing a default colormap is a no-op */
+ if (!(pmap->flags & IsDefault))
+ FreeResource(stuff->id, RT_NONE);
+ return (client->noClientException);
+ }
+ else
+ {
+ client->errorValue = stuff->id;
+ return (BadColor);
+ }
+}
+
+
+int
+ProcCopyColormapAndFree(register ClientPtr client)
+{
+ Colormap mid;
+ ColormapPtr pSrcMap;
+ REQUEST(xCopyColormapAndFreeReq);
+ int result;
+
+ REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
+ mid = stuff->mid;
+ LEGAL_NEW_RESOURCE(mid, client);
+ if( (pSrcMap = (ColormapPtr )SecurityLookupIDByType(client, stuff->srcCmap,
+ RT_COLORMAP, SecurityReadAccess|SecurityWriteAccess)) )
+ {
+ result = CopyColormapAndFree(mid, pSrcMap, client->index);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return(result);
+ }
+ else
+ {
+ client->errorValue = stuff->srcCmap;
+ return(BadColor);
+ }
+}
+
+int
+ProcInstallColormap(register ClientPtr client)
+{
+ ColormapPtr pcmp;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id,
+ RT_COLORMAP, SecurityReadAccess);
+ if (pcmp)
+ {
+ (*(pcmp->pScreen->InstallColormap)) (pcmp);
+ return (client->noClientException);
+ }
+ else
+ {
+ client->errorValue = stuff->id;
+ return (BadColor);
+ }
+}
+
+int
+ProcUninstallColormap(register ClientPtr client)
+{
+ ColormapPtr pcmp;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id,
+ RT_COLORMAP, SecurityReadAccess);
+ if (pcmp)
+ {
+ if(pcmp->mid != pcmp->pScreen->defColormap)
+ (*(pcmp->pScreen->UninstallColormap)) (pcmp);
+ return (client->noClientException);
+ }
+ else
+ {
+ client->errorValue = stuff->id;
+ return (BadColor);
+ }
+}
+
+int
+ProcListInstalledColormaps(register ClientPtr client)
+{
+ xListInstalledColormapsReply *preply;
+ int nummaps;
+ WindowPtr pWin;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+ SecurityReadAccess);
+
+ if (!pWin)
+ return(BadWindow);
+
+ preply = (xListInstalledColormapsReply *)
+ ALLOCATE_LOCAL(sizeof(xListInstalledColormapsReply) +
+ pWin->drawable.pScreen->maxInstalledCmaps *
+ sizeof(Colormap));
+ if(!preply)
+ return(BadAlloc);
+
+ preply->type = X_Reply;
+ preply->sequenceNumber = client->sequence;
+ nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps)
+ (pWin->drawable.pScreen, (Colormap *)&preply[1]);
+ preply->nColormaps = nummaps;
+ preply->length = nummaps;
+ WriteReplyToClient(client, sizeof (xListInstalledColormapsReply), preply);
+ client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
+ WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]);
+ DEALLOCATE_LOCAL(preply);
+ return(client->noClientException);
+}
+
+int
+ProcAllocColor (register ClientPtr client)
+{
+ ColormapPtr pmap;
+ int retval;
+ xAllocColorReply acr;
+ REQUEST(xAllocColorReq);
+
+ REQUEST_SIZE_MATCH(xAllocColorReq);
+ pmap = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+ RT_COLORMAP, SecurityWriteAccess);
+ if (pmap)
+ {
+#ifdef LBX
+ /*
+ * If the colormap is grabbed by a proxy, the server will have
+ * to regain control over the colormap. This AllocColor request
+ * will be handled after the server gets back the colormap control.
+ */
+ if (LbxCheckColorRequest (client, pmap, (xReq *) stuff))
+ return Success;
+#endif
+ acr.type = X_Reply;
+ acr.length = 0;
+ acr.sequenceNumber = client->sequence;
+ acr.red = stuff->red;
+ acr.green = stuff->green;
+ acr.blue = stuff->blue;
+ acr.pixel = 0;
+ if( (retval = AllocColor(pmap, &acr.red, &acr.green, &acr.blue,
+ &acr.pixel, client->index)) )
+ {
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return (retval);
+ }
+#ifdef PANORAMIX
+ if (noPanoramiXExtension || !pmap->pScreen->myNum)
+#endif
+ WriteReplyToClient(client, sizeof(xAllocColorReply), &acr);
+ return (client->noClientException);
+
+ }
+ else
+ {
+ client->errorValue = stuff->cmap;
+ return (BadColor);
+ }
+}
+
+int
+ProcAllocNamedColor (register ClientPtr client)
+{
+ ColormapPtr pcmp;
+ REQUEST(xAllocNamedColorReq);
+
+ REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes);
+ pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+ RT_COLORMAP, SecurityWriteAccess);
+ if (pcmp)
+ {
+ int retval;
+
+ xAllocNamedColorReply ancr;
+
+#ifdef LBX
+ /*
+ * If the colormap is grabbed by a proxy, the server will have
+ * to regain control over the colormap. This AllocNamedColor request
+ * will be handled after the server gets back the colormap control.
+ */
+ if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff))
+ return Success;
+#endif
+ ancr.type = X_Reply;
+ ancr.length = 0;
+ ancr.sequenceNumber = client->sequence;
+
+ if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], stuff->nbytes,
+ &ancr.exactRed, &ancr.exactGreen, &ancr.exactBlue))
+ {
+ ancr.screenRed = ancr.exactRed;
+ ancr.screenGreen = ancr.exactGreen;
+ ancr.screenBlue = ancr.exactBlue;
+ ancr.pixel = 0;
+ if( (retval = AllocColor(pcmp,
+ &ancr.screenRed, &ancr.screenGreen, &ancr.screenBlue,
+ &ancr.pixel, client->index)) )
+ {
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return(retval);
+ }
+#ifdef PANORAMIX
+ if (noPanoramiXExtension || !pcmp->pScreen->myNum)
+#endif
+ WriteReplyToClient(client, sizeof (xAllocNamedColorReply), &ancr);
+ return (client->noClientException);
+ }
+ else
+ return(BadName);
+
+ }
+ else
+ {
+ client->errorValue = stuff->cmap;
+ return (BadColor);
+ }
+}
+
+int
+ProcAllocColorCells (register ClientPtr client)
+{
+ ColormapPtr pcmp;
+ REQUEST(xAllocColorCellsReq);
+
+ REQUEST_SIZE_MATCH(xAllocColorCellsReq);
+ pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+ RT_COLORMAP, SecurityWriteAccess);
+ if (pcmp)
+ {
+ xAllocColorCellsReply accr;
+ int npixels, nmasks, retval;
+ long length;
+ Pixel *ppixels, *pmasks;
+
+#ifdef LBX
+ /*
+ * If the colormap is grabbed by a proxy, the server will have
+ * to regain control over the colormap. This AllocColorCells request
+ * will be handled after the server gets back the colormap control.
+ */
+ if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff))
+ return Success;
+#endif
+ npixels = stuff->colors;
+ if (!npixels)
+ {
+ client->errorValue = npixels;
+ return (BadValue);
+ }
+ if (stuff->contiguous != xTrue && stuff->contiguous != xFalse)
+ {
+ client->errorValue = stuff->contiguous;
+ return (BadValue);
+ }
+ nmasks = stuff->planes;
+ length = ((long)npixels + (long)nmasks) * sizeof(Pixel);
+ ppixels = (Pixel *)ALLOCATE_LOCAL(length);
+ if(!ppixels)
+ return(BadAlloc);
+ pmasks = ppixels + npixels;
+
+ if( (retval = AllocColorCells(client->index, pcmp, npixels, nmasks,
+ (Bool)stuff->contiguous, ppixels, pmasks)) )
+ {
+ DEALLOCATE_LOCAL(ppixels);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return(retval);
+ }
+#ifdef PANORAMIX
+ if (noPanoramiXExtension || !pcmp->pScreen->myNum)
+#endif
+ {
+ accr.type = X_Reply;
+ accr.length = length >> 2;
+ accr.sequenceNumber = client->sequence;
+ accr.nPixels = npixels;
+ accr.nMasks = nmasks;
+ WriteReplyToClient(client, sizeof (xAllocColorCellsReply), &accr);
+ client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
+ WriteSwappedDataToClient(client, length, ppixels);
+ }
+ DEALLOCATE_LOCAL(ppixels);
+ return (client->noClientException);
+ }
+ else
+ {
+ client->errorValue = stuff->cmap;
+ return (BadColor);
+ }
+}
+
+int
+ProcAllocColorPlanes(register ClientPtr client)
+{
+ ColormapPtr pcmp;
+ REQUEST(xAllocColorPlanesReq);
+
+ REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
+ pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+ RT_COLORMAP, SecurityWriteAccess);
+ if (pcmp)
+ {
+ xAllocColorPlanesReply acpr;
+ int npixels, retval;
+ long length;
+ Pixel *ppixels;
+
+#ifdef LBX
+ /*
+ * If the colormap is grabbed by a proxy, the server will have
+ * to regain control over the colormap. This AllocColorPlanes request
+ * will be handled after the server gets back the colormap control.
+ */
+ if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff))
+ return Success;
+#endif
+ npixels = stuff->colors;
+ if (!npixels)
+ {
+ client->errorValue = npixels;
+ return (BadValue);
+ }
+ if (stuff->contiguous != xTrue && stuff->contiguous != xFalse)
+ {
+ client->errorValue = stuff->contiguous;
+ return (BadValue);
+ }
+ acpr.type = X_Reply;
+ acpr.sequenceNumber = client->sequence;
+ acpr.nPixels = npixels;
+ length = (long)npixels * sizeof(Pixel);
+ ppixels = (Pixel *)ALLOCATE_LOCAL(length);
+ if(!ppixels)
+ return(BadAlloc);
+ if( (retval = AllocColorPlanes(client->index, pcmp, npixels,
+ (int)stuff->red, (int)stuff->green, (int)stuff->blue,
+ (Bool)stuff->contiguous, ppixels,
+ &acpr.redMask, &acpr.greenMask, &acpr.blueMask)) )
+ {
+ DEALLOCATE_LOCAL(ppixels);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return(retval);
+ }
+ acpr.length = length >> 2;
+#ifdef PANORAMIX
+ if (noPanoramiXExtension || !pcmp->pScreen->myNum)
+#endif
+ {
+ WriteReplyToClient(client, sizeof(xAllocColorPlanesReply), &acpr);
+ client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
+ WriteSwappedDataToClient(client, length, ppixels);
+ }
+ DEALLOCATE_LOCAL(ppixels);
+ return (client->noClientException);
+ }
+ else
+ {
+ client->errorValue = stuff->cmap;
+ return (BadColor);
+ }
+}
+
+int
+ProcFreeColors(register ClientPtr client)
+{
+ ColormapPtr pcmp;
+ REQUEST(xFreeColorsReq);
+
+ REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
+ pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+ RT_COLORMAP, SecurityWriteAccess);
+ if (pcmp)
+ {
+ int count;
+ int retval;
+
+ if(pcmp->flags & AllAllocated)
+ return(BadAccess);
+ count = ((client->req_len << 2)- sizeof(xFreeColorsReq)) >> 2;
+ retval = FreeColors(pcmp, client->index, count,
+ (Pixel *)&stuff[1], (Pixel)stuff->planeMask);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ {
+ client->errorValue = clientErrorValue;
+ return(retval);
+ }
+
+ }
+ else
+ {
+ client->errorValue = stuff->cmap;
+ return (BadColor);
+ }
+}
+
+int
+ProcStoreColors (ClientPtr client)
+{
+ ColormapPtr pcmp;
+ REQUEST(xStoreColorsReq);
+
+ REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
+ pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+ RT_COLORMAP, SecurityWriteAccess);
+ if (pcmp)
+ {
+ int count;
+ int retval;
+
+ count = (client->req_len << 2) - sizeof(xStoreColorsReq);
+ if (count % sizeof(xColorItem))
+ return(BadLength);
+ count /= sizeof(xColorItem);
+ retval = StoreColors(pcmp, count, (xColorItem *)&stuff[1]);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ {
+ client->errorValue = clientErrorValue;
+ return(retval);
+ }
+ }
+ else
+ {
+ client->errorValue = stuff->cmap;
+ return (BadColor);
+ }
+}
+
+int
+ProcStoreNamedColor (register ClientPtr client)
+{
+ ColormapPtr pcmp;
+ REQUEST(xStoreNamedColorReq);
+
+ REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes);
+ pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+ RT_COLORMAP, SecurityWriteAccess);
+ if (pcmp)
+ {
+ xColorItem def;
+ int retval;
+
+ if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1],
+ stuff->nbytes, &def.red, &def.green, &def.blue))
+ {
+ def.flags = stuff->flags;
+ def.pixel = stuff->pixel;
+ retval = StoreColors(pcmp, 1, &def);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return(retval);
+ }
+ return (BadName);
+ }
+ else
+ {
+ client->errorValue = stuff->cmap;
+ return (BadColor);
+ }
+}
+
+int
+ProcQueryColors(register ClientPtr client)
+{
+ ColormapPtr pcmp;
+ REQUEST(xQueryColorsReq);
+
+ REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
+ pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+ RT_COLORMAP, SecurityReadAccess);
+ if (pcmp)
+ {
+ int count, retval;
+ xrgb *prgbs;
+ xQueryColorsReply qcr;
+
+ count = ((client->req_len << 2) - sizeof(xQueryColorsReq)) >> 2;
+ prgbs = (xrgb *)ALLOCATE_LOCAL(count * sizeof(xrgb));
+ if(!prgbs && count)
+ return(BadAlloc);
+ if( (retval = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs)) )
+ {
+ if (prgbs) DEALLOCATE_LOCAL(prgbs);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ {
+ client->errorValue = clientErrorValue;
+ return (retval);
+ }
+ }
+ qcr.type = X_Reply;
+ qcr.length = (count * sizeof(xrgb)) >> 2;
+ qcr.sequenceNumber = client->sequence;
+ qcr.nColors = count;
+ WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr);
+ if (count)
+ {
+ client->pSwapReplyFunc = (ReplySwapPtr) SQColorsExtend;
+ WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs);
+ }
+ if (prgbs) DEALLOCATE_LOCAL(prgbs);
+ return(client->noClientException);
+
+ }
+ else
+ {
+ client->errorValue = stuff->cmap;
+ return (BadColor);
+ }
+}
+
+int
+ProcLookupColor(register ClientPtr client)
+{
+ ColormapPtr pcmp;
+ REQUEST(xLookupColorReq);
+
+ REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes);
+ pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
+ RT_COLORMAP, SecurityReadAccess);
+ if (pcmp)
+ {
+ xLookupColorReply lcr;
+
+ if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], stuff->nbytes,
+ &lcr.exactRed, &lcr.exactGreen, &lcr.exactBlue))
+ {
+ lcr.type = X_Reply;
+ lcr.length = 0;
+ lcr.sequenceNumber = client->sequence;
+ lcr.screenRed = lcr.exactRed;
+ lcr.screenGreen = lcr.exactGreen;
+ lcr.screenBlue = lcr.exactBlue;
+ (*pcmp->pScreen->ResolveColor)(&lcr.screenRed,
+ &lcr.screenGreen,
+ &lcr.screenBlue,
+ pcmp->pVisual);
+ WriteReplyToClient(client, sizeof(xLookupColorReply), &lcr);
+ return(client->noClientException);
+ }
+ return (BadName);
+ }
+ else
+ {
+ client->errorValue = stuff->cmap;
+ return (BadColor);
+ }
+}
+
+int
+ProcCreateCursor (register ClientPtr client)
+{
+ CursorPtr pCursor;
+
+ register PixmapPtr src;
+ register PixmapPtr msk;
+ unsigned char * srcbits;
+ unsigned char * mskbits;
+ unsigned short width, height;
+ long n;
+ CursorMetricRec cm;
+
+
+ REQUEST(xCreateCursorReq);
+
+ REQUEST_SIZE_MATCH(xCreateCursorReq);
+ LEGAL_NEW_RESOURCE(stuff->cid, client);
+
+ src = (PixmapPtr)SecurityLookupIDByType(client, stuff->source,
+ RT_PIXMAP, SecurityReadAccess);
+ msk = (PixmapPtr)SecurityLookupIDByType(client, stuff->mask,
+ RT_PIXMAP, SecurityReadAccess);
+ if ( src == (PixmapPtr)NULL)
+ {
+ client->errorValue = stuff->source;
+ return (BadPixmap);
+ }
+ if ( msk == (PixmapPtr)NULL)
+ {
+ if (stuff->mask != None)
+ {
+ client->errorValue = stuff->mask;
+ return (BadPixmap);
+ }
+ }
+ else if ( src->drawable.width != msk->drawable.width
+ || src->drawable.height != msk->drawable.height
+ || src->drawable.depth != 1
+ || msk->drawable.depth != 1)
+ return (BadMatch);
+
+ width = src->drawable.width;
+ height = src->drawable.height;
+
+ if ( stuff->x > width
+ || stuff->y > height )
+ return (BadMatch);
+
+ n = BitmapBytePad(width)*height;
+ srcbits = (unsigned char *)xalloc(n);
+ if (!srcbits)
+ return (BadAlloc);
+ mskbits = (unsigned char *)xalloc(n);
+ if (!mskbits)
+ {
+ xfree(srcbits);
+ return (BadAlloc);
+ }
+
+ /* zeroing the (pad) bits helps some ddx cursor handling */
+ bzero((char *)srcbits, n);
+ (* src->drawable.pScreen->GetImage)( (DrawablePtr)src, 0, 0, width, height,
+ XYPixmap, 1, (pointer)srcbits);
+ if ( msk == (PixmapPtr)NULL)
+ {
+ register unsigned char *bits = mskbits;
+ while (--n >= 0)
+ *bits++ = ~0;
+ }
+ else
+ {
+ /* zeroing the (pad) bits helps some ddx cursor handling */
+ bzero((char *)mskbits, n);
+ (* msk->drawable.pScreen->GetImage)( (DrawablePtr)msk, 0, 0, width,
+ height, XYPixmap, 1, (pointer)mskbits);
+ }
+ cm.width = width;
+ cm.height = height;
+ cm.xhot = stuff->x;
+ cm.yhot = stuff->y;
+ pCursor = AllocCursor( srcbits, mskbits, &cm,
+ stuff->foreRed, stuff->foreGreen, stuff->foreBlue,
+ stuff->backRed, stuff->backGreen, stuff->backBlue);
+
+ if (pCursor && AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
+ return (client->noClientException);
+ return BadAlloc;
+}
+
+int
+ProcCreateGlyphCursor (register ClientPtr client)
+{
+ CursorPtr pCursor;
+ int res;
+
+ REQUEST(xCreateGlyphCursorReq);
+
+ REQUEST_SIZE_MATCH(xCreateGlyphCursorReq);
+ LEGAL_NEW_RESOURCE(stuff->cid, client);
+
+ res = AllocGlyphCursor(stuff->source, stuff->sourceChar,
+ stuff->mask, stuff->maskChar,
+ stuff->foreRed, stuff->foreGreen, stuff->foreBlue,
+ stuff->backRed, stuff->backGreen, stuff->backBlue,
+ &pCursor, client);
+ if (res != Success)
+ return res;
+ if (AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
+ return client->noClientException;
+ return BadAlloc;
+}
+
+
+int
+ProcFreeCursor (register ClientPtr client)
+{
+ CursorPtr pCursor;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->id,
+ RT_CURSOR, SecurityDestroyAccess);
+ if (pCursor)
+ {
+ FreeResource(stuff->id, RT_NONE);
+ return (client->noClientException);
+ }
+ else
+ {
+ client->errorValue = stuff->id;
+ return (BadCursor);
+ }
+}
+
+int
+ProcQueryBestSize (register ClientPtr client)
+{
+ xQueryBestSizeReply reply;
+ register DrawablePtr pDraw;
+ ScreenPtr pScreen;
+ REQUEST(xQueryBestSizeReq);
+
+ REQUEST_SIZE_MATCH(xQueryBestSizeReq);
+ if ((stuff->class != CursorShape) &&
+ (stuff->class != TileShape) &&
+ (stuff->class != StippleShape))
+ {
+ client->errorValue = stuff->class;
+ return(BadValue);
+ }
+ SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client,
+ SecurityReadAccess);
+ if (stuff->class != CursorShape && pDraw->type == UNDRAWABLE_WINDOW)
+ return (BadMatch);
+ pScreen = pDraw->pScreen;
+ (* pScreen->QueryBestSize)(stuff->class, &stuff->width,
+ &stuff->height, pScreen);
+ reply.type = X_Reply;
+ reply.length = 0;
+ reply.sequenceNumber = client->sequence;
+ reply.width = stuff->width;
+ reply.height = stuff->height;
+ WriteReplyToClient(client, sizeof(xQueryBestSizeReply), &reply);
+ return (client->noClientException);
+}
+
+
+int
+ProcSetScreenSaver (register ClientPtr client)
+{
+ int blankingOption, exposureOption;
+ REQUEST(xSetScreenSaverReq);
+
+ REQUEST_SIZE_MATCH(xSetScreenSaverReq);
+ blankingOption = stuff->preferBlank;
+ if ((blankingOption != DontPreferBlanking) &&
+ (blankingOption != PreferBlanking) &&
+ (blankingOption != DefaultBlanking))
+ {
+ client->errorValue = blankingOption;
+ return BadValue;
+ }
+ exposureOption = stuff->allowExpose;
+ if ((exposureOption != DontAllowExposures) &&
+ (exposureOption != AllowExposures) &&
+ (exposureOption != DefaultExposures))
+ {
+ client->errorValue = exposureOption;
+ return BadValue;
+ }
+ if (stuff->timeout < -1)
+ {
+ client->errorValue = stuff->timeout;
+ return BadValue;
+ }
+ if (stuff->interval < -1)
+ {
+ client->errorValue = stuff->interval;
+ return BadValue;
+ }
+
+ if (blankingOption == DefaultBlanking)
+ ScreenSaverBlanking = defaultScreenSaverBlanking;
+ else
+ ScreenSaverBlanking = blankingOption;
+ if (exposureOption == DefaultExposures)
+ ScreenSaverAllowExposures = defaultScreenSaverAllowExposures;
+ else
+ ScreenSaverAllowExposures = exposureOption;
+
+ if (stuff->timeout >= 0)
+ ScreenSaverTime = stuff->timeout * MILLI_PER_SECOND;
+ else
+ ScreenSaverTime = defaultScreenSaverTime;
+ if (stuff->interval >= 0)
+ ScreenSaverInterval = stuff->interval * MILLI_PER_SECOND;
+ else
+ ScreenSaverInterval = defaultScreenSaverInterval;
+
+ SetScreenSaverTimer();
+ return (client->noClientException);
+}
+
+int
+ProcGetScreenSaver(register ClientPtr client)
+{
+ xGetScreenSaverReply rep;
+
+ REQUEST_SIZE_MATCH(xReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.timeout = ScreenSaverTime / MILLI_PER_SECOND;
+ rep.interval = ScreenSaverInterval / MILLI_PER_SECOND;
+ rep.preferBlanking = ScreenSaverBlanking;
+ rep.allowExposures = ScreenSaverAllowExposures;
+ WriteReplyToClient(client, sizeof(xGetScreenSaverReply), &rep);
+ return (client->noClientException);
+}
+
+int
+ProcChangeHosts(register ClientPtr client)
+{
+ REQUEST(xChangeHostsReq);
+ int result;
+
+ REQUEST_FIXED_SIZE(xChangeHostsReq, stuff->hostLength);
+
+ if(stuff->mode == HostInsert)
+ result = AddHost(client, (int)stuff->hostFamily,
+ stuff->hostLength, (pointer)&stuff[1]);
+ else if (stuff->mode == HostDelete)
+ result = RemoveHost(client, (int)stuff->hostFamily,
+ stuff->hostLength, (pointer)&stuff[1]);
+ else
+ {
+ client->errorValue = stuff->mode;
+ return BadValue;
+ }
+ if (!result)
+ result = client->noClientException;
+ return (result);
+}
+
+int
+ProcListHosts(register ClientPtr client)
+{
+ xListHostsReply reply;
+ int len, nHosts, result;
+ pointer pdata;
+ /* REQUEST(xListHostsReq); */
+
+ REQUEST_SIZE_MATCH(xListHostsReq);
+#ifdef XCSECURITY
+ /* untrusted clients can't list hosts */
+ if (client->trustLevel != XSecurityClientTrusted)
+ {
+ SecurityAudit("client %d attempted to list hosts\n", client->index);
+ return BadAccess;
+ }
+#endif
+ result = GetHosts(&pdata, &nHosts, &len, &reply.enabled);
+ if (result != Success)
+ return(result);
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.nHosts = nHosts;
+ reply.length = len >> 2;
+ WriteReplyToClient(client, sizeof(xListHostsReply), &reply);
+ if (nHosts)
+ {
+ client->pSwapReplyFunc = (ReplySwapPtr) SLHostsExtend;
+ WriteSwappedDataToClient(client, len, pdata);
+ }
+ xfree(pdata);
+ return (client->noClientException);
+}
+
+int
+ProcChangeAccessControl(register ClientPtr client)
+{
+ int result;
+ REQUEST(xSetAccessControlReq);
+
+ REQUEST_SIZE_MATCH(xSetAccessControlReq);
+ if ((stuff->mode != EnableAccess) && (stuff->mode != DisableAccess))
+ {
+ client->errorValue = stuff->mode;
+ return BadValue;
+ }
+ result = ChangeAccessControl(client, stuff->mode == EnableAccess);
+ if (!result)
+ result = client->noClientException;
+ return (result);
+}
+
+int
+ProcKillClient(register ClientPtr client)
+{
+ REQUEST(xResourceReq);
+ ClientPtr killclient;
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ if (stuff->id == AllTemporary)
+ {
+ CloseDownRetainedResources();
+ return (client->noClientException);
+ }
+
+ if ((killclient = LookupClient(stuff->id, client)))
+ {
+ CloseDownClient(killclient);
+ /* if an LBX proxy gets killed, isItTimeToYield will be set */
+ if (isItTimeToYield || (client == killclient))
+ {
+ /* force yield and return Success, so that Dispatch()
+ * doesn't try to touch client
+ */
+ isItTimeToYield = TRUE;
+ return (Success);
+ }
+ return (client->noClientException);
+ }
+ else
+ {
+ client->errorValue = stuff->id;
+ return (BadValue);
+ }
+}
+
+int
+ProcSetFontPath(register ClientPtr client)
+{
+ unsigned char *ptr;
+ unsigned long nbytes, total;
+ long nfonts;
+ int n, result;
+ int error;
+ REQUEST(xSetFontPathReq);
+
+ REQUEST_AT_LEAST_SIZE(xSetFontPathReq);
+
+ nbytes = (client->req_len << 2) - sizeof(xSetFontPathReq);
+ total = nbytes;
+ ptr = (unsigned char *)&stuff[1];
+ nfonts = stuff->nFonts;
+ while (--nfonts >= 0)
+ {
+ if ((total == 0) || (total < (n = (*ptr + 1))))
+ return(BadLength);
+ total -= n;
+ ptr += n;
+ }
+ if (total >= 4)
+ return(BadLength);
+ result = SetFontPath(client, stuff->nFonts, (unsigned char *)&stuff[1],
+ &error);
+ if (!result)
+ {
+ result = client->noClientException;
+ client->errorValue = error;
+ }
+ return (result);
+}
+
+int
+ProcGetFontPath(register ClientPtr client)
+{
+ xGetFontPathReply reply;
+ int stringLens, numpaths;
+ unsigned char *bufferStart;
+ /* REQUEST (xReq); */
+
+ REQUEST_SIZE_MATCH(xReq);
+ bufferStart = GetFontPath(&numpaths, &stringLens);
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = (stringLens + numpaths + 3) >> 2;
+ reply.nPaths = numpaths;
+
+ WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply);
+ if (stringLens || numpaths)
+ (void)WriteToClient(client, stringLens + numpaths, (char *)bufferStart);
+ return(client->noClientException);
+}
+
+int
+ProcChangeCloseDownMode(register ClientPtr client)
+{
+ REQUEST(xSetCloseDownModeReq);
+
+ REQUEST_SIZE_MATCH(xSetCloseDownModeReq);
+ if ((stuff->mode == AllTemporary) ||
+ (stuff->mode == RetainPermanent) ||
+ (stuff->mode == RetainTemporary))
+ {
+ client->closeDownMode = stuff->mode;
+ return (client->noClientException);
+ }
+ else
+ {
+ client->errorValue = stuff->mode;
+ return (BadValue);
+ }
+}
+
+int ProcForceScreenSaver(register ClientPtr client)
+{
+ REQUEST(xForceScreenSaverReq);
+
+ REQUEST_SIZE_MATCH(xForceScreenSaverReq);
+
+ if ((stuff->mode != ScreenSaverReset) &&
+ (stuff->mode != ScreenSaverActive))
+ {
+ client->errorValue = stuff->mode;
+ return BadValue;
+ }
+ SaveScreens(SCREEN_SAVER_FORCER, (int)stuff->mode);
+ return client->noClientException;
+}
+
+int ProcNoOperation(register ClientPtr client)
+{
+ REQUEST_AT_LEAST_SIZE(xReq);
+
+ /* noop -- don't do anything */
+ return(client->noClientException);
+}
+
+void
+InitProcVectors(void)
+{
+ int i;
+ for (i = 0; i<256; i++)
+ {
+ if(!ProcVector[i])
+ {
+ ProcVector[i] = SwappedProcVector[i] = ProcBadRequest;
+ ReplySwapVector[i] = ReplyNotSwappd;
+ }
+#ifdef K5AUTH
+ if (!k5_Vector[i])
+ {
+ k5_Vector[i] = k5_bad;
+ }
+#endif
+ }
+ for(i = LASTEvent; i < 128; i++)
+ {
+ EventSwapVector[i] = NotImplemented;
+ }
+
+}
+
+/**********************
+ * CloseDownClient
+ *
+ * Client can either mark his resources destroy or retain. If retained and
+ * then killed again, the client is really destroyed.
+ *********************/
+
+char dispatchExceptionAtReset = DE_RESET;
+
+void
+CloseDownClient(register ClientPtr client)
+{
+ Bool really_close_down = client->clientGone ||
+ client->closeDownMode == DestroyAll;
+
+ if (!client->clientGone)
+ {
+ /* ungrab server if grabbing client dies */
+ if (grabState != GrabNone && grabClient == client)
+ {
+ UngrabServer(client);
+ }
+ BITCLEAR(grabWaiters, client->index);
+ DeleteClientFromAnySelections(client);
+ ReleaseActiveGrabs(client);
+ DeleteClientFontStuff(client);
+ if (!really_close_down)
+ {
+ /* This frees resources that should never be retained
+ * no matter what the close down mode is. Actually we
+ * could do this unconditionally, but it's probably
+ * better not to traverse all the client's resources
+ * twice (once here, once a few lines down in
+ * FreeClientResources) in the common case of
+ * really_close_down == TRUE.
+ */
+ FreeClientNeverRetainResources(client);
+ client->clientState = ClientStateRetained;
+ if (ClientStateCallback)
+ {
+ NewClientInfoRec clientinfo;
+
+ clientinfo.client = client;
+ clientinfo.prefix = (xConnSetupPrefix *)NULL;
+ clientinfo.setup = (xConnSetup *) NULL;
+ CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
+ }
+ }
+ client->clientGone = TRUE; /* so events aren't sent to client */
+ if (ClientIsAsleep(client))
+ ClientSignal (client);
+ ProcessWorkQueueZombies();
+#ifdef LBX
+ ProcessQTagZombies();
+#endif
+ CloseDownConnection(client);
+
+ /* If the client made it to the Running stage, nClients has
+ * been incremented on its behalf, so we need to decrement it
+ * now. If it hasn't gotten to Running, nClients has *not*
+ * been incremented, so *don't* decrement it.
+ */
+ if (client->clientState != ClientStateInitial &&
+ client->clientState != ClientStateAuthenticating )
+ {
+ --nClients;
+ }
+ }
+
+ if (really_close_down)
+ {
+ if (client->clientState == ClientStateRunning && nClients == 0)
+ dispatchException |= dispatchExceptionAtReset;
+
+ client->clientState = ClientStateGone;
+ if (ClientStateCallback)
+ {
+ NewClientInfoRec clientinfo;
+
+ clientinfo.client = client;
+ clientinfo.prefix = (xConnSetupPrefix *)NULL;
+ clientinfo.setup = (xConnSetup *) NULL;
+ CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
+ }
+ FreeClientResources(client);
+ if (client->index < nextFreeClientID)
+ nextFreeClientID = client->index;
+ clients[client->index] = NullClient;
+#ifdef SMART_SCHEDULE
+ SmartLastClient = NullClient;
+#endif
+ xfree(client);
+
+ while (!clients[currentMaxClients-1])
+ currentMaxClients--;
+ }
+}
+
+static void
+KillAllClients()
+{
+ int i;
+ for (i=1; i<currentMaxClients; i++)
+ if (clients[i]) {
+ /* Make sure Retained clients are released. */
+ clients[i]->closeDownMode = DestroyAll;
+ CloseDownClient(clients[i]);
+ }
+}
+
+/*********************
+ * CloseDownRetainedResources
+ *
+ * Find all clients that are gone and have terminated in RetainTemporary
+ * and destroy their resources.
+ *********************/
+
+void
+CloseDownRetainedResources()
+{
+ register int i;
+ register ClientPtr client;
+
+ for (i=1; i<currentMaxClients; i++)
+ {
+ client = clients[i];
+ if (client && (client->closeDownMode == RetainTemporary)
+ && (client->clientGone))
+ CloseDownClient(client);
+ }
+}
+
+void InitClient(ClientPtr client, int i, pointer ospriv)
+{
+ client->index = i;
+ client->sequence = 0;
+ client->clientAsMask = ((Mask)i) << CLIENTOFFSET;
+ client->clientGone = FALSE;
+ if (i)
+ {
+ client->closeDownMode = DestroyAll;
+ client->lastDrawable = (DrawablePtr)WindowTable[0];
+ client->lastDrawableID = WindowTable[0]->drawable.id;
+ }
+ else
+ {
+ client->closeDownMode = RetainPermanent;
+ client->lastDrawable = (DrawablePtr)NULL;
+ client->lastDrawableID = INVALID;
+ }
+ client->lastGC = (GCPtr) NULL;
+ client->lastGCID = INVALID;
+ client->numSaved = 0;
+ client->saveSet = (SaveSetElt *)NULL;
+ client->noClientException = Success;
+#ifdef DEBUG
+ client->requestLogIndex = 0;
+#endif
+ client->requestVector = InitialVector;
+ client->osPrivate = ospriv;
+ client->swapped = FALSE;
+ client->big_requests = FALSE;
+ client->priority = 0;
+ client->clientState = ClientStateInitial;
+#ifdef XKB
+ if (!noXkbExtension) {
+ client->xkbClientFlags = 0;
+ client->mapNotifyMask = 0;
+ QueryMinMaxKeyCodes(&client->minKC,&client->maxKC);
+ }
+#endif
+ client->replyBytesRemaining = 0;
+#ifdef LBX
+ client->readRequest = StandardReadRequestFromClient;
+#endif
+#ifdef XCSECURITY
+ client->trustLevel = XSecurityClientTrusted;
+ client->CheckAccess = NULL;
+ client->authId = 0;
+#endif
+#ifdef XAPPGROUP
+ client->appgroup = NULL;
+#endif
+ client->fontResFunc = NULL;
+#ifdef SMART_SCHEDULE
+ client->smart_priority = 0;
+ client->smart_start_tick = SmartScheduleTime;
+ client->smart_stop_tick = SmartScheduleTime;
+ client->smart_check_tick = SmartScheduleTime;
+#endif
+}
+
+extern int clientPrivateLen;
+extern unsigned *clientPrivateSizes;
+extern unsigned totalClientSize;
+
+int
+InitClientPrivates(ClientPtr client)
+{
+ register char *ptr;
+ DevUnion *ppriv;
+ register unsigned *sizes;
+ register unsigned size;
+ register int i;
+
+ if (totalClientSize == sizeof(ClientRec))
+ ppriv = (DevUnion *)NULL;
+ else if (client->index)
+ ppriv = (DevUnion *)(client + 1);
+ else
+ {
+ ppriv = (DevUnion *)xalloc(totalClientSize - sizeof(ClientRec));
+ if (!ppriv)
+ return 0;
+ }
+ client->devPrivates = ppriv;
+ sizes = clientPrivateSizes;
+ ptr = (char *)(ppriv + clientPrivateLen);
+ for (i = clientPrivateLen; --i >= 0; ppriv++, sizes++)
+ {
+ if ( (size = *sizes) )
+ {
+ ppriv->ptr = (pointer)ptr;
+ ptr += size;
+ }
+ else
+ ppriv->ptr = (pointer)NULL;
+ }
+ return 1;
+}
+
+/************************
+ * int NextAvailableClient(ospriv)
+ *
+ * OS dependent portion can't assign client id's because of CloseDownModes.
+ * Returns NULL if there are no free clients.
+ *************************/
+
+ClientPtr NextAvailableClient(pointer ospriv)
+{
+ register int i;
+ register ClientPtr client;
+ xReq data;
+
+ i = nextFreeClientID;
+ if (i == MAXCLIENTS)
+ return (ClientPtr)NULL;
+ clients[i] = client = (ClientPtr)xalloc(totalClientSize);
+ if (!client)
+ return (ClientPtr)NULL;
+ InitClient(client, i, ospriv);
+ InitClientPrivates(client);
+ if (!InitClientResources(client))
+ {
+ xfree(client);
+ return (ClientPtr)NULL;
+ }
+ data.reqType = 1;
+ data.length = (sz_xReq + sz_xConnClientPrefix) >> 2;
+ if (!InsertFakeRequest(client, (char *)&data, sz_xReq))
+ {
+ FreeClientResources(client);
+ xfree(client);
+ return (ClientPtr)NULL;
+ }
+ if (i == currentMaxClients)
+ currentMaxClients++;
+ while ((nextFreeClientID < MAXCLIENTS) && clients[nextFreeClientID])
+ nextFreeClientID++;
+ if (ClientStateCallback)
+ {
+ NewClientInfoRec clientinfo;
+
+ clientinfo.client = client;
+ clientinfo.prefix = (xConnSetupPrefix *)NULL;
+ clientinfo.setup = (xConnSetup *) NULL;
+ CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
+ }
+ return(client);
+}
+
+int
+ProcInitialConnection(register ClientPtr client)
+{
+ REQUEST(xReq);
+ register xConnClientPrefix *prefix;
+ int whichbyte = 1;
+
+ prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq);
+ if ((prefix->byteOrder != 'l') && (prefix->byteOrder != 'B'))
+ return (client->noClientException = -1);
+ if (((*(char *) &whichbyte) && (prefix->byteOrder == 'B')) ||
+ (!(*(char *) &whichbyte) && (prefix->byteOrder == 'l')))
+ {
+ client->swapped = TRUE;
+ SwapConnClientPrefix(prefix);
+ }
+ stuff->reqType = 2;
+ stuff->length += ((prefix->nbytesAuthProto + (unsigned)3) >> 2) +
+ ((prefix->nbytesAuthString + (unsigned)3) >> 2);
+ if (client->swapped)
+ {
+ swaps(&stuff->length, whichbyte);
+ }
+ ResetCurrentRequest(client);
+ return (client->noClientException);
+}
+
+#ifdef LBX
+void
+IncrementClientCount()
+{
+ nClients++;
+}
+#endif
+
+int
+SendConnSetup(register ClientPtr client, char *reason)
+{
+ register xWindowRoot *root;
+ register int i;
+ int numScreens;
+ char* lConnectionInfo;
+ xConnSetupPrefix* lconnSetupPrefix;
+
+ if (reason)
+ {
+ xConnSetupPrefix csp;
+
+ csp.success = xFalse;
+ csp.lengthReason = strlen(reason);
+ csp.length = (csp.lengthReason + (unsigned)3) >> 2;
+ csp.majorVersion = X_PROTOCOL;
+ csp.minorVersion = X_PROTOCOL_REVISION;
+ if (client->swapped)
+ WriteSConnSetupPrefix(client, &csp);
+ else
+ (void)WriteToClient(client, sz_xConnSetupPrefix, (char *) &csp);
+ (void)WriteToClient(client, (int)csp.lengthReason, reason);
+ return (client->noClientException = -1);
+ }
+
+ numScreens = screenInfo.numScreens;
+ lConnectionInfo = ConnectionInfo;
+ lconnSetupPrefix = &connSetupPrefix;
+
+ /* We're about to start speaking X protocol back to the client by
+ * sending the connection setup info. This means the authorization
+ * step is complete, and we can count the client as an
+ * authorized one.
+ */
+ nClients++;
+
+ client->requestVector = client->swapped ? SwappedProcVector : ProcVector;
+ client->sequence = 0;
+#ifdef XAPPGROUP
+ XagConnectionInfo (client, &lconnSetupPrefix, &lConnectionInfo, &numScreens);
+#endif
+ ((xConnSetup *)lConnectionInfo)->ridBase = client->clientAsMask;
+ ((xConnSetup *)lConnectionInfo)->ridMask = RESOURCE_ID_MASK;
+#ifdef MATCH_CLIENT_ENDIAN
+ ((xConnSetup *)lConnectionInfo)->imageByteOrder = ClientOrder (client);
+ ((xConnSetup *)lConnectionInfo)->bitmapBitOrder = ClientOrder (client);
+#endif
+ /* fill in the "currentInputMask" */
+ root = (xWindowRoot *)(lConnectionInfo + connBlockScreenStart);
+#ifdef PANORAMIX
+ if (noPanoramiXExtension)
+ numScreens = screenInfo.numScreens;
+ else
+ numScreens = ((xConnSetup *)ConnectionInfo)->numRoots;
+#endif
+
+ for (i=0; i<numScreens; i++)
+ {
+ register unsigned int j;
+ register xDepth *pDepth;
+
+ root->currentInputMask = WindowTable[i]->eventMask |
+ wOtherEventMasks (WindowTable[i]);
+ pDepth = (xDepth *)(root + 1);
+ for (j = 0; j < root->nDepths; j++)
+ {
+ pDepth = (xDepth *)(((char *)(pDepth + 1)) +
+ pDepth->nVisuals * sizeof(xVisualType));
+ }
+ root = (xWindowRoot *)pDepth;
+ }
+
+ if (client->swapped)
+ {
+ WriteSConnSetupPrefix(client, lconnSetupPrefix);
+ WriteSConnectionInfo(client,
+ (unsigned long)(lconnSetupPrefix->length << 2),
+ lConnectionInfo);
+ }
+ else
+ {
+ (void)WriteToClient(client, sizeof(xConnSetupPrefix),
+ (char *) lconnSetupPrefix);
+ (void)WriteToClient(client, (int)(lconnSetupPrefix->length << 2),
+ lConnectionInfo);
+ }
+ client->clientState = ClientStateRunning;
+ if (ClientStateCallback)
+ {
+ NewClientInfoRec clientinfo;
+
+ clientinfo.client = client;
+ clientinfo.prefix = lconnSetupPrefix;
+ clientinfo.setup = (xConnSetup *)lConnectionInfo;
+ CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
+ }
+ return (client->noClientException);
+}
+
+int
+ProcEstablishConnection(register ClientPtr client)
+{
+ char *reason, *auth_proto, *auth_string;
+ register xConnClientPrefix *prefix;
+ REQUEST(xReq);
+
+ prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq);
+ auth_proto = (char *)prefix + sz_xConnClientPrefix;
+ auth_string = auth_proto + ((prefix->nbytesAuthProto + 3) & ~3);
+ if ((prefix->majorVersion != X_PROTOCOL) ||
+ (prefix->minorVersion != X_PROTOCOL_REVISION))
+ reason = "Protocol version mismatch";
+ else
+ reason = ClientAuthorized(client,
+ (unsigned short)prefix->nbytesAuthProto,
+ auth_proto,
+ (unsigned short)prefix->nbytesAuthString,
+ auth_string);
+ /*
+ * If Kerberos is being used for this client, the clientState
+ * will be set to ClientStateAuthenticating at this point.
+ * More messages need to be exchanged among the X server, Kerberos
+ * server, and client to figure out if everyone is authorized.
+ * So we don't want to send the connection setup info yet, since
+ * the auth step isn't really done.
+ */
+ if (client->clientState == ClientStateCheckingSecurity)
+ client->clientState = ClientStateCheckedSecurity;
+ else if (client->clientState != ClientStateAuthenticating)
+ return(SendConnSetup(client, reason));
+ return(client->noClientException);
+}
+
+void
+SendErrorToClient(ClientPtr client, unsigned majorCode, unsigned minorCode,
+ XID resId, int errorCode)
+{
+ xError rep;
+
+ rep.type = X_Error;
+ rep.sequenceNumber = client->sequence;
+ rep.errorCode = errorCode;
+ rep.majorCode = majorCode;
+ rep.minorCode = minorCode;
+ rep.resourceID = resId;
+
+ WriteEventsToClient (client, 1, (xEvent *)&rep);
+}
+
+void
+DeleteWindowFromAnySelections(WindowPtr pWin)
+{
+ register int i;
+
+ for (i = 0; i< NumCurrentSelections; i++)
+ if (CurrentSelections[i].pWin == pWin)
+ {
+ if (SelectionCallback)
+ {
+ SelectionInfoRec info;
+
+ info.selection = &CurrentSelections[i];
+ info.kind = SelectionWindowDestroy;
+ CallCallbacks(&SelectionCallback, &info);
+ }
+ CurrentSelections[i].pWin = (WindowPtr)NULL;
+ CurrentSelections[i].window = None;
+ CurrentSelections[i].client = NullClient;
+ }
+}
+
+static void
+DeleteClientFromAnySelections(ClientPtr client)
+{
+ register int i;
+
+ for (i = 0; i< NumCurrentSelections; i++)
+ if (CurrentSelections[i].client == client)
+ {
+ if (SelectionCallback)
+ {
+ SelectionInfoRec info;
+
+ info.selection = &CurrentSelections[i];
+ info.kind = SelectionWindowDestroy;
+ CallCallbacks(&SelectionCallback, &info);
+ }
+ CurrentSelections[i].pWin = (WindowPtr)NULL;
+ CurrentSelections[i].window = None;
+ CurrentSelections[i].client = NullClient;
+ }
+}
+
+void
+MarkClientException(ClientPtr client)
+{
+ client->noClientException = -1;
+}
diff --git a/nx-X11/programs/Xserver/dix/dispatch.h b/nx-X11/programs/Xserver/dix/dispatch.h
new file mode 100644
index 000000000..89ea2dd7e
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/dispatch.h
@@ -0,0 +1,147 @@
+/* $XFree86: xc/programs/Xserver/dix/dispatch.h,v 3.2 2001/08/01 00:44:48 tsi Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*
+ * This prototypes the dispatch.c module (except for functions declared in
+ * global headers), plus related dispatch procedures from devices.c, events.c,
+ * extension.c, property.c.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef DISPATCH_H
+#define DISPATCH_H 1
+
+DISPATCH_PROC(InitClientPrivates);
+DISPATCH_PROC(ProcAllocColor);
+DISPATCH_PROC(ProcAllocColorCells);
+DISPATCH_PROC(ProcAllocColorPlanes);
+DISPATCH_PROC(ProcAllocNamedColor);
+DISPATCH_PROC(ProcBell);
+DISPATCH_PROC(ProcChangeAccessControl);
+DISPATCH_PROC(ProcChangeCloseDownMode);
+DISPATCH_PROC(ProcChangeGC);
+DISPATCH_PROC(ProcChangeHosts);
+DISPATCH_PROC(ProcChangeKeyboardControl);
+DISPATCH_PROC(ProcChangeKeyboardMapping);
+DISPATCH_PROC(ProcChangePointerControl);
+DISPATCH_PROC(ProcChangeProperty);
+DISPATCH_PROC(ProcChangeSaveSet);
+DISPATCH_PROC(ProcChangeWindowAttributes);
+DISPATCH_PROC(ProcCirculateWindow);
+DISPATCH_PROC(ProcClearToBackground);
+DISPATCH_PROC(ProcCloseFont);
+DISPATCH_PROC(ProcConfigureWindow);
+DISPATCH_PROC(ProcConvertSelection);
+DISPATCH_PROC(ProcCopyArea);
+DISPATCH_PROC(ProcCopyColormapAndFree);
+DISPATCH_PROC(ProcCopyGC);
+DISPATCH_PROC(ProcCopyPlane);
+DISPATCH_PROC(ProcCreateColormap);
+DISPATCH_PROC(ProcCreateCursor);
+DISPATCH_PROC(ProcCreateGC);
+DISPATCH_PROC(ProcCreateGlyphCursor);
+DISPATCH_PROC(ProcCreatePixmap);
+DISPATCH_PROC(ProcCreateWindow);
+DISPATCH_PROC(ProcDeleteProperty);
+DISPATCH_PROC(ProcDestroySubwindows);
+DISPATCH_PROC(ProcDestroyWindow);
+DISPATCH_PROC(ProcEstablishConnection);
+DISPATCH_PROC(ProcFillPoly);
+DISPATCH_PROC(ProcForceScreenSaver);
+DISPATCH_PROC(ProcFreeColormap);
+DISPATCH_PROC(ProcFreeColors);
+DISPATCH_PROC(ProcFreeCursor);
+DISPATCH_PROC(ProcFreeGC);
+DISPATCH_PROC(ProcFreePixmap);
+DISPATCH_PROC(ProcGetAtomName);
+DISPATCH_PROC(ProcGetFontPath);
+DISPATCH_PROC(ProcGetGeometry);
+DISPATCH_PROC(ProcGetImage);
+DISPATCH_PROC(ProcGetKeyboardControl);
+DISPATCH_PROC(ProcGetKeyboardMapping);
+DISPATCH_PROC(ProcGetModifierMapping);
+DISPATCH_PROC(ProcGetMotionEvents);
+DISPATCH_PROC(ProcGetPointerControl);
+DISPATCH_PROC(ProcGetPointerMapping);
+DISPATCH_PROC(ProcGetProperty);
+DISPATCH_PROC(ProcGetScreenSaver);
+DISPATCH_PROC(ProcGetSelectionOwner);
+DISPATCH_PROC(ProcGetWindowAttributes);
+DISPATCH_PROC(ProcGrabServer);
+DISPATCH_PROC(ProcImageText16);
+DISPATCH_PROC(ProcImageText8);
+DISPATCH_PROC(ProcInitialConnection);
+DISPATCH_PROC(ProcInstallColormap);
+DISPATCH_PROC(ProcInternAtom);
+DISPATCH_PROC(ProcKillClient);
+DISPATCH_PROC(ProcListExtensions);
+DISPATCH_PROC(ProcListFonts);
+DISPATCH_PROC(ProcListFontsWithInfo);
+DISPATCH_PROC(ProcListHosts);
+DISPATCH_PROC(ProcListInstalledColormaps);
+DISPATCH_PROC(ProcListProperties);
+DISPATCH_PROC(ProcLookupColor);
+DISPATCH_PROC(ProcMapSubwindows);
+DISPATCH_PROC(ProcMapWindow);
+DISPATCH_PROC(ProcNoOperation);
+DISPATCH_PROC(ProcOpenFont);
+DISPATCH_PROC(ProcPolyArc);
+DISPATCH_PROC(ProcPolyFillArc);
+DISPATCH_PROC(ProcPolyFillRectangle);
+DISPATCH_PROC(ProcPolyLine);
+DISPATCH_PROC(ProcPolyPoint);
+DISPATCH_PROC(ProcPolyRectangle);
+DISPATCH_PROC(ProcPolySegment);
+DISPATCH_PROC(ProcPolyText);
+DISPATCH_PROC(ProcPutImage);
+DISPATCH_PROC(ProcQueryBestSize);
+DISPATCH_PROC(ProcQueryColors);
+DISPATCH_PROC(ProcQueryExtension);
+DISPATCH_PROC(ProcQueryFont);
+DISPATCH_PROC(ProcQueryKeymap);
+DISPATCH_PROC(ProcQueryTextExtents);
+DISPATCH_PROC(ProcQueryTree);
+DISPATCH_PROC(ProcReparentWindow);
+DISPATCH_PROC(ProcRotateProperties);
+DISPATCH_PROC(ProcSetClipRectangles);
+DISPATCH_PROC(ProcSetDashes);
+DISPATCH_PROC(ProcSetFontPath);
+DISPATCH_PROC(ProcSetModifierMapping);
+DISPATCH_PROC(ProcSetPointerMapping);
+DISPATCH_PROC(ProcSetScreenSaver);
+DISPATCH_PROC(ProcSetSelectionOwner);
+DISPATCH_PROC(ProcStoreColors);
+DISPATCH_PROC(ProcStoreNamedColor);
+DISPATCH_PROC(ProcTranslateCoords);
+DISPATCH_PROC(ProcUngrabServer);
+DISPATCH_PROC(ProcUninstallColormap);
+DISPATCH_PROC(ProcUnmapSubwindows);
+DISPATCH_PROC(ProcUnmapWindow);
+
+#endif /* DISPATCH_H */
diff --git a/nx-X11/programs/Xserver/dix/dixfonts.c b/nx-X11/programs/Xserver/dix/dixfonts.c
new file mode 100644
index 000000000..e62f61432
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/dixfonts.c
@@ -0,0 +1,2208 @@
+/* $XdotOrg: xc/programs/Xserver/dix/dixfonts.c,v 1.8 2005/07/03 08:53:38 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/dix/dixfonts.c,v 3.28 2003/11/08 02:02:03 dawes Exp $ */
+/************************************************************************
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+************************************************************************/
+/* The panoramix components contained the following notice */
+/*
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+/* $Xorg: dixfonts.c,v 1.4 2000/08/17 19:48:18 cpqbld Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "resource.h"
+#include "dixstruct.h"
+#include "cursorstr.h"
+#include "misc.h"
+#include "opaque.h"
+#include "dixfontstr.h"
+#include "closestr.h"
+
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
+#ifdef NX_TRANS_SOCKET
+
+char _NXFontPath[1024];
+
+/*
+ * Override the default font path and make
+ * it configurable at run time, based on
+ * the NX_FONT environment.
+ */
+
+static const char *_NXGetFontPath(const char *path)
+{
+ const char *fontEnv;
+
+ /*
+ * Check the environment only once.
+ */
+
+ if (*_NXFontPath != '\0')
+ {
+ return _NXFontPath;
+ }
+
+ fontEnv = getenv("NX_FONT");
+
+ if (fontEnv != NULL && *fontEnv != '\0')
+ {
+ if (strlen(fontEnv) + 1 > 1024)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetFontPath: WARNING! Maximum length of font path exceeded.\n");
+#endif
+ goto _NXGetFontPathError;
+ }
+
+ strcpy(_NXFontPath, fontEnv);
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetFontPath: Using NX font path [%s].\n", _NXFontPath);
+#endif
+
+ return _NXFontPath;
+ }
+
+_NXGetFontPathError:
+
+ strcpy(_NXFontPath, path);
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetFontPath: Using default font path [%s].\n", _NXFontPath);
+#endif
+
+ return _NXFontPath;
+}
+
+#endif
+
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#endif
+
+#ifdef LBX
+#include "lbxserve.h"
+#endif
+
+#ifdef XF86BIGFONT
+#define _XF86BIGFONT_SERVER_
+#include <X11/extensions/xf86bigfont.h>
+#endif
+
+#define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics
+
+extern pointer fosNaturalParams;
+extern FontPtr defaultFont;
+
+static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0;
+static int num_fpes = 0;
+FPEFunctions *fpe_functions = (FPEFunctions *) 0;
+static int num_fpe_types = 0;
+
+static unsigned char *font_path_string;
+
+static int num_slept_fpes = 0;
+static int size_slept_fpes = 0;
+static FontPathElementPtr *slept_fpes = (FontPathElementPtr *) 0;
+static FontPatternCachePtr patternCache;
+
+int
+FontToXError(err)
+ int err;
+{
+ switch (err) {
+ case Successful:
+ return Success;
+ case AllocError:
+ return BadAlloc;
+ case BadFontName:
+ return BadName;
+ case BadFontPath:
+ case BadFontFormat: /* is there something better? */
+ case BadCharRange:
+ return BadValue;
+ default:
+ return err;
+ }
+}
+
+
+/*
+ * adding RT_FONT prevents conflict with default cursor font
+ */
+Bool
+SetDefaultFont(char *defaultfontname)
+{
+ int err;
+ FontPtr pf;
+ XID fid;
+
+ fid = FakeClientID(0);
+ err = OpenFont(serverClient, fid, FontLoadAll | FontOpenSync,
+ (unsigned) strlen(defaultfontname), defaultfontname);
+ if (err != Success)
+ return FALSE;
+ pf = (FontPtr) LookupIDByType(fid, RT_FONT);
+ if (pf == (FontPtr) NULL)
+ return FALSE;
+ defaultFont = pf;
+ return TRUE;
+}
+
+/*
+ * note that the font wakeup queue is not refcounted. this is because
+ * an fpe needs to be added when it's inited, and removed when it's finally
+ * freed, in order to handle any data that isn't requested, like FS events.
+ *
+ * since the only thing that should call these routines is the renderer's
+ * init_fpe() and free_fpe(), there shouldn't be any problem in using
+ * freed data.
+ */
+void
+QueueFontWakeup(FontPathElementPtr fpe)
+{
+ int i;
+ FontPathElementPtr *new;
+
+ for (i = 0; i < num_slept_fpes; i++) {
+ if (slept_fpes[i] == fpe) {
+
+#ifdef DEBUG
+ fprintf(stderr, "re-queueing fpe wakeup\n");
+#endif
+
+ return;
+ }
+ }
+ if (num_slept_fpes == size_slept_fpes) {
+ new = (FontPathElementPtr *)
+ xrealloc(slept_fpes,
+ sizeof(FontPathElementPtr) * (size_slept_fpes + 4));
+ if (!new)
+ return;
+ slept_fpes = new;
+ size_slept_fpes += 4;
+ }
+ slept_fpes[num_slept_fpes] = fpe;
+ num_slept_fpes++;
+}
+
+void
+RemoveFontWakeup(FontPathElementPtr fpe)
+{
+ int i,
+ j;
+
+ for (i = 0; i < num_slept_fpes; i++) {
+ if (slept_fpes[i] == fpe) {
+ for (j = i; j < num_slept_fpes; j++) {
+ slept_fpes[j] = slept_fpes[j + 1];
+ }
+ num_slept_fpes--;
+ return;
+ }
+ }
+}
+
+void
+FontWakeup(pointer data, int count, pointer LastSelectMask)
+{
+ int i;
+ FontPathElementPtr fpe;
+
+ if (count < 0)
+ return;
+ /* wake up any fpe's that may be waiting for information */
+ for (i = 0; i < num_slept_fpes; i++) {
+ fpe = slept_fpes[i];
+ (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask);
+ }
+}
+
+/* XXX -- these two funcs may want to be broken into macros */
+static void
+UseFPE(FontPathElementPtr fpe)
+{
+ fpe->refcount++;
+}
+
+static void
+FreeFPE (FontPathElementPtr fpe)
+{
+ fpe->refcount--;
+ if (fpe->refcount == 0) {
+ (*fpe_functions[fpe->type].free_fpe) (fpe);
+ xfree(fpe->name);
+ xfree(fpe);
+ }
+}
+
+static Bool
+doOpenFont(ClientPtr client, OFclosurePtr c)
+{
+ FontPtr pfont = NullFont;
+ FontPathElementPtr fpe = NULL;
+ ScreenPtr pScr;
+ int err = Successful;
+ int i;
+ char *alias,
+ *newname;
+ int newlen;
+ int aliascount = 20;
+ /*
+ * Decide at runtime what FontFormat to use.
+ */
+ Mask FontFormat =
+
+ ((screenInfo.imageByteOrder == LSBFirst) ?
+ BitmapFormatByteOrderLSB : BitmapFormatByteOrderMSB) |
+
+ ((screenInfo.bitmapBitOrder == LSBFirst) ?
+ BitmapFormatBitOrderLSB : BitmapFormatBitOrderMSB) |
+
+ BitmapFormatImageRectMin |
+
+#if GLYPHPADBYTES == 1
+ BitmapFormatScanlinePad8 |
+#endif
+
+#if GLYPHPADBYTES == 2
+ BitmapFormatScanlinePad16 |
+#endif
+
+#if GLYPHPADBYTES == 4
+ BitmapFormatScanlinePad32 |
+#endif
+
+#if GLYPHPADBYTES == 8
+ BitmapFormatScanlinePad64 |
+#endif
+
+ BitmapFormatScanlineUnit8;
+
+ if (client->clientGone)
+ {
+ if (c->current_fpe < c->num_fpes)
+ {
+ fpe = c->fpe_list[c->current_fpe];
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ }
+ err = Successful;
+ goto bail;
+ }
+ while (c->current_fpe < c->num_fpes) {
+ fpe = c->fpe_list[c->current_fpe];
+ err = (*fpe_functions[fpe->type].open_font)
+ ((pointer) client, fpe, c->flags,
+ c->fontname, c->fnamelen, FontFormat,
+ BitmapFormatMaskByte |
+ BitmapFormatMaskBit |
+ BitmapFormatMaskImageRectangle |
+ BitmapFormatMaskScanLinePad |
+ BitmapFormatMaskScanLineUnit,
+ c->fontid, &pfont, &alias,
+ c->non_cachable_font && c->non_cachable_font->fpe == fpe ?
+ c->non_cachable_font :
+ (FontPtr)0);
+
+ if (err == FontNameAlias && alias) {
+ newlen = strlen(alias);
+ newname = (char *) xrealloc(c->fontname, newlen);
+ if (!newname) {
+ err = AllocError;
+ break;
+ }
+ memmove(newname, alias, newlen);
+ c->fontname = newname;
+ c->fnamelen = newlen;
+ c->current_fpe = 0;
+ if (--aliascount <= 0)
+ break;
+ continue;
+ }
+ if (err == BadFontName) {
+ c->current_fpe++;
+ continue;
+ }
+ if (err == Suspended) {
+ if (!c->slept) {
+ c->slept = TRUE;
+ ClientSleep(client, (ClientSleepProcPtr)doOpenFont, (pointer) c);
+ }
+ return TRUE;
+ }
+ break;
+ }
+
+ if (err != Successful)
+ goto bail;
+ if (!pfont) {
+ err = BadFontName;
+ goto bail;
+ }
+ if (!pfont->fpe)
+ pfont->fpe = fpe;
+ pfont->refcnt++;
+ if (pfont->refcnt == 1) {
+ UseFPE(pfont->fpe);
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ pScr = screenInfo.screens[i];
+ if (pScr->RealizeFont)
+ {
+ if (!(*pScr->RealizeFont) (pScr, pfont))
+ {
+ CloseFont (pfont, (Font) 0);
+ err = AllocError;
+ goto bail;
+ }
+ }
+ }
+ }
+ if (!AddResource(c->fontid, RT_FONT, (pointer) pfont)) {
+ err = AllocError;
+ goto bail;
+ }
+ if (patternCache && pfont != c->non_cachable_font)
+ CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen,
+ pfont);
+bail:
+ if (err != Successful && c->client != serverClient) {
+ SendErrorToClient(c->client, X_OpenFont, 0,
+ c->fontid, FontToXError(err));
+ }
+ if (c->slept)
+ ClientWakeup(c->client);
+ for (i = 0; i < c->num_fpes; i++) {
+ FreeFPE(c->fpe_list[i]);
+ }
+ xfree(c->fpe_list);
+ xfree(c->fontname);
+ xfree(c);
+ return TRUE;
+}
+
+int
+OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontname)
+{
+ OFclosurePtr c;
+ int i;
+ FontPtr cached = (FontPtr)0;
+
+#ifdef FONTDEBUG
+ char *f;
+ f = (char *)xalloc(lenfname + 1);
+ memmove(f, pfontname, lenfname);
+ f[lenfname] = '\0';
+ ErrorF("OpenFont: fontname is \"%s\"\n", f);
+ xfree(f);
+#endif
+ if (!lenfname || lenfname > XLFDMAXFONTNAMELEN)
+ return BadName;
+ if (patternCache)
+ {
+
+ /*
+ ** Check name cache. If we find a cached version of this font that
+ ** is cachable, immediately satisfy the request with it. If we find
+ ** a cached version of this font that is non-cachable, we do not
+ ** satisfy the request with it. Instead, we pass the FontPtr to the
+ ** FPE's open_font code (the fontfile FPE in turn passes the
+ ** information to the rasterizer; the fserve FPE ignores it).
+ **
+ ** Presumably, the font is marked non-cachable because the FPE has
+ ** put some licensing restrictions on it. If the FPE, using
+ ** whatever logic it relies on, determines that it is willing to
+ ** share this existing font with the client, then it has the option
+ ** to return the FontPtr we passed it as the newly-opened font.
+ ** This allows the FPE to exercise its licensing logic without
+ ** having to create another instance of a font that already exists.
+ */
+
+ cached = FindCachedFontPattern(patternCache, pfontname, lenfname);
+ if (cached && cached->info.cachable)
+ {
+ if (!AddResource(fid, RT_FONT, (pointer) cached))
+ return BadAlloc;
+ cached->refcnt++;
+ return Success;
+ }
+ }
+ c = (OFclosurePtr) xalloc(sizeof(OFclosureRec));
+ if (!c)
+ return BadAlloc;
+ c->fontname = (char *) xalloc(lenfname);
+ c->origFontName = pfontname;
+ c->origFontNameLen = lenfname;
+ if (!c->fontname) {
+ xfree(c);
+ return BadAlloc;
+ }
+ /*
+ * copy the current FPE list, so that if it gets changed by another client
+ * while we're blocking, the request still appears atomic
+ */
+ c->fpe_list = (FontPathElementPtr *)
+ xalloc(sizeof(FontPathElementPtr) * num_fpes);
+ if (!c->fpe_list) {
+ xfree(c->fontname);
+ xfree(c);
+ return BadAlloc;
+ }
+ memmove(c->fontname, pfontname, lenfname);
+ for (i = 0; i < num_fpes; i++) {
+ c->fpe_list[i] = font_path_elements[i];
+ UseFPE(c->fpe_list[i]);
+ }
+ c->client = client;
+ c->fontid = fid;
+ c->current_fpe = 0;
+ c->num_fpes = num_fpes;
+ c->fnamelen = lenfname;
+ c->slept = FALSE;
+ c->flags = flags;
+ c->non_cachable_font = cached;
+
+ (void) doOpenFont(client, c);
+ return Success;
+}
+
+/**
+ * Decrement font's ref count, and free storage if ref count equals zero
+ *
+ * \param value must conform to DeleteType
+ */
+int
+CloseFont(pointer value, XID fid)
+{
+ int nscr;
+ ScreenPtr pscr;
+ FontPathElementPtr fpe;
+ FontPtr pfont = (FontPtr)value;
+
+ if (pfont == NullFont)
+ return (Success);
+ if (--pfont->refcnt == 0) {
+ if (patternCache)
+ RemoveCachedFontPattern (patternCache, pfont);
+ /*
+ * since the last reference is gone, ask each screen to free any
+ * storage it may have allocated locally for it.
+ */
+ for (nscr = 0; nscr < screenInfo.numScreens; nscr++) {
+ pscr = screenInfo.screens[nscr];
+ if (pscr->UnrealizeFont)
+ (*pscr->UnrealizeFont) (pscr, pfont);
+ }
+ if (pfont == defaultFont)
+ defaultFont = NULL;
+#ifdef LBX
+ LbxFreeFontTag(pfont);
+#endif
+#ifdef XF86BIGFONT
+ XF86BigfontFreeFontShm(pfont);
+#endif
+ fpe = pfont->fpe;
+ (*fpe_functions[fpe->type].close_font) (fpe, pfont);
+ FreeFPE(fpe);
+ }
+ return (Success);
+}
+
+
+/***====================================================================***/
+
+/**
+ * Sets up pReply as the correct QueryFontReply for pFont with the first
+ * nProtoCCIStructs char infos.
+ *
+ * \param pReply caller must allocate this storage
+ */
+void
+QueryFont(FontPtr pFont, xQueryFontReply *pReply, int nProtoCCIStructs)
+{
+ FontPropPtr pFP;
+ int r,
+ c,
+ i;
+ xFontProp *prFP;
+ xCharInfo *prCI;
+ xCharInfo *charInfos[256];
+ unsigned char chars[512];
+ int ninfos;
+ unsigned long ncols;
+ unsigned long count;
+
+ /* pr->length set in dispatch */
+ pReply->minCharOrByte2 = pFont->info.firstCol;
+ pReply->defaultChar = pFont->info.defaultCh;
+ pReply->maxCharOrByte2 = pFont->info.lastCol;
+ pReply->drawDirection = pFont->info.drawDirection;
+ pReply->allCharsExist = pFont->info.allExist;
+ pReply->minByte1 = pFont->info.firstRow;
+ pReply->maxByte1 = pFont->info.lastRow;
+ pReply->fontAscent = pFont->info.fontAscent;
+ pReply->fontDescent = pFont->info.fontDescent;
+
+ pReply->minBounds = pFont->info.ink_minbounds;
+ pReply->maxBounds = pFont->info.ink_maxbounds;
+
+ pReply->nFontProps = pFont->info.nprops;
+ pReply->nCharInfos = nProtoCCIStructs;
+
+ for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) (&pReply[1]);
+ i < pFont->info.nprops;
+ i++, pFP++, prFP++) {
+ prFP->name = pFP->name;
+ prFP->value = pFP->value;
+ }
+
+ ninfos = 0;
+ ncols = (unsigned long) (pFont->info.lastCol - pFont->info.firstCol + 1);
+ prCI = (xCharInfo *) (prFP);
+ for (r = pFont->info.firstRow;
+ ninfos < nProtoCCIStructs && r <= (int)pFont->info.lastRow;
+ r++) {
+ i = 0;
+ for (c = pFont->info.firstCol; c <= (int)pFont->info.lastCol; c++) {
+ chars[i++] = r;
+ chars[i++] = c;
+ }
+ (*pFont->get_metrics) (pFont, ncols, chars,
+ TwoD16Bit, &count, charInfos);
+ i = 0;
+ for (i = 0; i < (int) count && ninfos < nProtoCCIStructs; i++) {
+ *prCI = *charInfos[i];
+ prCI++;
+ ninfos++;
+ }
+ }
+ return;
+}
+
+static Bool
+doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
+{
+ FontPathElementPtr fpe;
+ int err = Successful;
+ FontNamesPtr names = NULL;
+ char *name, *resolved=NULL;
+ int namelen, resolvedlen;
+ int nnames;
+ int stringLens;
+ int i;
+ xListFontsReply reply;
+ char *bufptr;
+ char *bufferStart;
+ int aliascount = 0;
+
+ if (client->clientGone)
+ {
+ if (c->current.current_fpe < c->num_fpes)
+ {
+ fpe = c->fpe_list[c->current.current_fpe];
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ }
+ err = Successful;
+ goto bail;
+ }
+
+ if (!c->current.patlen)
+ goto finish;
+
+ while (c->current.current_fpe < c->num_fpes) {
+ fpe = c->fpe_list[c->current.current_fpe];
+ err = Successful;
+
+ if (!fpe_functions[fpe->type].start_list_fonts_and_aliases)
+ {
+ /* This FPE doesn't support/require list_fonts_and_aliases */
+
+ err = (*fpe_functions[fpe->type].list_fonts)
+ ((pointer) c->client, fpe, c->current.pattern,
+ c->current.patlen, c->current.max_names - c->names->nnames,
+ c->names);
+
+ if (err == Suspended) {
+ if (!c->slept) {
+ c->slept = TRUE;
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsAndAliases,
+ (pointer) c);
+ }
+ return TRUE;
+ }
+
+ err = BadFontName;
+ }
+ else
+ {
+ /* Start of list_fonts_and_aliases functionality. Modeled
+ after list_fonts_with_info in that it resolves aliases,
+ except that the information collected from FPEs is just
+ names, not font info. Each list_next_font_or_alias()
+ returns either a name into name/namelen or an alias into
+ name/namelen and its target name into resolved/resolvedlen.
+ The code at this level then resolves the alias by polling
+ the FPEs. */
+
+ if (!c->current.list_started) {
+ err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases)
+ ((pointer) c->client, fpe, c->current.pattern,
+ c->current.patlen, c->current.max_names - c->names->nnames,
+ &c->current.private);
+ if (err == Suspended) {
+ if (!c->slept) {
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsAndAliases,
+ (pointer) c);
+ c->slept = TRUE;
+ }
+ return TRUE;
+ }
+ if (err == Successful)
+ c->current.list_started = TRUE;
+ }
+ if (err == Successful) {
+ char *tmpname;
+ name = 0;
+ err = (*fpe_functions[fpe->type].list_next_font_or_alias)
+ ((pointer) c->client, fpe, &name, &namelen, &tmpname,
+ &resolvedlen, c->current.private);
+ if (err == Suspended) {
+ if (!c->slept) {
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsAndAliases,
+ (pointer) c);
+ c->slept = TRUE;
+ }
+ return TRUE;
+ }
+ if (err == FontNameAlias) {
+ if (resolved) xfree(resolved);
+ resolved = (char *) xalloc(resolvedlen + 1);
+ if (resolved)
+ memmove(resolved, tmpname, resolvedlen + 1);
+ }
+ }
+
+ if (err == Successful)
+ {
+ if (c->haveSaved)
+ {
+ if (c->savedName)
+ (void)AddFontNamesName(c->names, c->savedName,
+ c->savedNameLen);
+ }
+ else
+ (void)AddFontNamesName(c->names, name, namelen);
+ }
+
+ /*
+ * When we get an alias back, save our state and reset back to
+ * the start of the FPE looking for the specified name. As
+ * soon as a real font is found for the alias, pop back to the
+ * old state
+ */
+ else if (err == FontNameAlias) {
+ char tmp_pattern[XLFDMAXFONTNAMELEN];
+ /*
+ * when an alias recurses, we need to give
+ * the last FPE a chance to clean up; so we call
+ * it again, and assume that the error returned
+ * is BadFontName, indicating the alias resolution
+ * is complete.
+ */
+ memmove(tmp_pattern, resolved, resolvedlen);
+ if (c->haveSaved)
+ {
+ char *tmpname;
+ int tmpnamelen;
+
+ tmpname = 0;
+ (void) (*fpe_functions[fpe->type].list_next_font_or_alias)
+ ((pointer) c->client, fpe, &tmpname, &tmpnamelen,
+ &tmpname, &tmpnamelen, c->current.private);
+ if (--aliascount <= 0)
+ {
+ err = BadFontName;
+ goto ContBadFontName;
+ }
+ }
+ else
+ {
+ c->saved = c->current;
+ c->haveSaved = TRUE;
+ if (c->savedName)
+ xfree(c->savedName);
+ c->savedName = (char *)xalloc(namelen + 1);
+ if (c->savedName)
+ memmove(c->savedName, name, namelen + 1);
+ c->savedNameLen = namelen;
+ aliascount = 20;
+ }
+ memmove(c->current.pattern, tmp_pattern, resolvedlen);
+ c->current.patlen = resolvedlen;
+ c->current.max_names = c->names->nnames + 1;
+ c->current.current_fpe = -1;
+ c->current.private = 0;
+ err = BadFontName;
+ }
+ }
+ /*
+ * At the end of this FPE, step to the next. If we've finished
+ * processing an alias, pop state back. If we've collected enough
+ * font names, quit.
+ */
+ if (err == BadFontName) {
+ ContBadFontName: ;
+ c->current.list_started = FALSE;
+ c->current.current_fpe++;
+ err = Successful;
+ if (c->haveSaved)
+ {
+ if (c->names->nnames == c->current.max_names ||
+ c->current.current_fpe == c->num_fpes) {
+ c->haveSaved = FALSE;
+ c->current = c->saved;
+ /* Give the saved namelist a chance to clean itself up */
+ continue;
+ }
+ }
+ if (c->names->nnames == c->current.max_names)
+ break;
+ }
+ }
+
+ /*
+ * send the reply
+ */
+ if (err != Successful) {
+ SendErrorToClient(client, X_ListFonts, 0, 0, FontToXError(err));
+ goto bail;
+ }
+
+finish:
+
+ names = c->names;
+ nnames = names->nnames;
+ client = c->client;
+ stringLens = 0;
+ for (i = 0; i < nnames; i++)
+ stringLens += (names->length[i] <= 255) ? names->length[i] : 0;
+
+ reply.type = X_Reply;
+ reply.length = (stringLens + nnames + 3) >> 2;
+ reply.nFonts = nnames;
+ reply.sequenceNumber = client->sequence;
+
+ bufptr = bufferStart = (char *) ALLOCATE_LOCAL(reply.length << 2);
+
+ if (!bufptr && reply.length) {
+ SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc);
+ goto bail;
+ }
+ /*
+ * since WriteToClient long word aligns things, copy to temp buffer and
+ * write all at once
+ */
+ for (i = 0; i < nnames; i++) {
+ if (names->length[i] > 255)
+ reply.nFonts--;
+ else
+ {
+ *bufptr++ = names->length[i];
+ memmove( bufptr, names->names[i], names->length[i]);
+ bufptr += names->length[i];
+ }
+ }
+ nnames = reply.nFonts;
+ reply.length = (stringLens + nnames + 3) >> 2;
+ client->pSwapReplyFunc = ReplySwapVector[X_ListFonts];
+ WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply);
+ (void) WriteToClient(client, stringLens + nnames, bufferStart);
+ DEALLOCATE_LOCAL(bufferStart);
+
+bail:
+ if (c->slept)
+ ClientWakeup(client);
+ for (i = 0; i < c->num_fpes; i++)
+ FreeFPE(c->fpe_list[i]);
+ xfree(c->fpe_list);
+ if (c->savedName) xfree(c->savedName);
+ FreeFontNames(names);
+ xfree(c);
+ if (resolved) xfree(resolved);
+ return TRUE;
+}
+
+int
+ListFonts(ClientPtr client, unsigned char *pattern, unsigned length,
+ unsigned max_names)
+{
+ int i;
+ LFclosurePtr c;
+
+ /*
+ * The right error to return here would be BadName, however the
+ * specification does not allow for a Name error on this request.
+ * Perhaps a better solution would be to return a nil list, i.e.
+ * a list containing zero fontnames.
+ */
+ if (length > XLFDMAXFONTNAMELEN)
+ return BadAlloc;
+
+ if (!(c = (LFclosurePtr) xalloc(sizeof *c)))
+ return BadAlloc;
+ c->fpe_list = (FontPathElementPtr *)
+ xalloc(sizeof(FontPathElementPtr) * num_fpes);
+ if (!c->fpe_list) {
+ xfree(c);
+ return BadAlloc;
+ }
+ c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100);
+ if (!c->names)
+ {
+ xfree(c->fpe_list);
+ xfree(c);
+ return BadAlloc;
+ }
+ memmove( c->current.pattern, pattern, length);
+ for (i = 0; i < num_fpes; i++) {
+ c->fpe_list[i] = font_path_elements[i];
+ UseFPE(c->fpe_list[i]);
+ }
+ c->client = client;
+ c->num_fpes = num_fpes;
+ c->current.patlen = length;
+ c->current.current_fpe = 0;
+ c->current.max_names = max_names;
+ c->current.list_started = FALSE;
+ c->current.private = 0;
+ c->haveSaved = FALSE;
+ c->slept = FALSE;
+ c->savedName = 0;
+ doListFontsAndAliases(client, c);
+ return Success;
+}
+
+int
+doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
+{
+ FontPathElementPtr fpe;
+ int err = Successful;
+ char *name;
+ int namelen;
+ int numFonts;
+ FontInfoRec fontInfo,
+ *pFontInfo;
+ xListFontsWithInfoReply *reply;
+ int length;
+ xFontProp *pFP;
+ int i;
+ int aliascount = 0;
+ xListFontsWithInfoReply finalReply;
+
+ if (client->clientGone)
+ {
+ if (c->current.current_fpe < c->num_fpes)
+ {
+ fpe = c->fpe_list[c->current.current_fpe];
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ }
+ err = Successful;
+ goto bail;
+ }
+ client->pSwapReplyFunc = ReplySwapVector[X_ListFontsWithInfo];
+ if (!c->current.patlen)
+ goto finish;
+ while (c->current.current_fpe < c->num_fpes)
+ {
+ fpe = c->fpe_list[c->current.current_fpe];
+ err = Successful;
+ if (!c->current.list_started)
+ {
+ err = (*fpe_functions[fpe->type].start_list_fonts_with_info)
+ (client, fpe, c->current.pattern, c->current.patlen,
+ c->current.max_names, &c->current.private);
+ if (err == Suspended)
+ {
+ if (!c->slept)
+ {
+ ClientSleep(client, (ClientSleepProcPtr)doListFontsWithInfo, c);
+ c->slept = TRUE;
+ }
+ return TRUE;
+ }
+ if (err == Successful)
+ c->current.list_started = TRUE;
+ }
+ if (err == Successful)
+ {
+ name = 0;
+ pFontInfo = &fontInfo;
+ err = (*fpe_functions[fpe->type].list_next_font_with_info)
+ (client, fpe, &name, &namelen, &pFontInfo,
+ &numFonts, c->current.private);
+ if (err == Suspended)
+ {
+ if (!c->slept)
+ {
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsWithInfo,
+ c);
+ c->slept = TRUE;
+ }
+ return TRUE;
+ }
+ }
+ /*
+ * When we get an alias back, save our state and reset back to the
+ * start of the FPE looking for the specified name. As soon as a real
+ * font is found for the alias, pop back to the old state
+ */
+ if (err == FontNameAlias)
+ {
+ /*
+ * when an alias recurses, we need to give
+ * the last FPE a chance to clean up; so we call
+ * it again, and assume that the error returned
+ * is BadFontName, indicating the alias resolution
+ * is complete.
+ */
+ if (c->haveSaved)
+ {
+ char *tmpname;
+ int tmpnamelen;
+ FontInfoPtr tmpFontInfo;
+
+ tmpname = 0;
+ tmpFontInfo = &fontInfo;
+ (void) (*fpe_functions[fpe->type].list_next_font_with_info)
+ (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo,
+ &numFonts, c->current.private);
+ if (--aliascount <= 0)
+ {
+ err = BadFontName;
+ goto ContBadFontName;
+ }
+ }
+ else
+ {
+ c->saved = c->current;
+ c->haveSaved = TRUE;
+ c->savedNumFonts = numFonts;
+ if (c->savedName)
+ xfree(c->savedName);
+ c->savedName = (char *)xalloc(namelen + 1);
+ if (c->savedName)
+ memmove(c->savedName, name, namelen + 1);
+ aliascount = 20;
+ }
+ memmove(c->current.pattern, name, namelen);
+ c->current.patlen = namelen;
+ c->current.max_names = 1;
+ c->current.current_fpe = 0;
+ c->current.private = 0;
+ c->current.list_started = FALSE;
+ }
+ /*
+ * At the end of this FPE, step to the next. If we've finished
+ * processing an alias, pop state back. If we've sent enough font
+ * names, quit. Always wait for BadFontName to let the FPE
+ * have a chance to clean up.
+ */
+ else if (err == BadFontName)
+ {
+ ContBadFontName: ;
+ c->current.list_started = FALSE;
+ c->current.current_fpe++;
+ err = Successful;
+ if (c->haveSaved)
+ {
+ if (c->current.max_names == 0 ||
+ c->current.current_fpe == c->num_fpes)
+ {
+ c->haveSaved = FALSE;
+ c->saved.max_names -= (1 - c->current.max_names);
+ c->current = c->saved;
+ }
+ }
+ else if (c->current.max_names == 0)
+ break;
+ }
+ else if (err == Successful)
+ {
+ length = sizeof(*reply) + pFontInfo->nprops * sizeof(xFontProp);
+ reply = c->reply;
+ if (c->length < length)
+ {
+ reply = (xListFontsWithInfoReply *) xrealloc(c->reply, length);
+ if (!reply)
+ {
+ err = AllocError;
+ break;
+ }
+ c->reply = reply;
+ c->length = length;
+ }
+ if (c->haveSaved)
+ {
+ numFonts = c->savedNumFonts;
+ name = c->savedName;
+ namelen = strlen(name);
+ }
+ reply->type = X_Reply;
+ reply->length = (sizeof *reply - sizeof(xGenericReply) +
+ pFontInfo->nprops * sizeof(xFontProp) +
+ namelen + 3) >> 2;
+ reply->sequenceNumber = client->sequence;
+ reply->nameLength = namelen;
+ reply->minBounds = pFontInfo->ink_minbounds;
+ reply->maxBounds = pFontInfo->ink_maxbounds;
+ reply->minCharOrByte2 = pFontInfo->firstCol;
+ reply->maxCharOrByte2 = pFontInfo->lastCol;
+ reply->defaultChar = pFontInfo->defaultCh;
+ reply->nFontProps = pFontInfo->nprops;
+ reply->drawDirection = pFontInfo->drawDirection;
+ reply->minByte1 = pFontInfo->firstRow;
+ reply->maxByte1 = pFontInfo->lastRow;
+ reply->allCharsExist = pFontInfo->allExist;
+ reply->fontAscent = pFontInfo->fontAscent;
+ reply->fontDescent = pFontInfo->fontDescent;
+ reply->nReplies = numFonts;
+ pFP = (xFontProp *) (reply + 1);
+ for (i = 0; i < pFontInfo->nprops; i++)
+ {
+ pFP->name = pFontInfo->props[i].name;
+ pFP->value = pFontInfo->props[i].value;
+ pFP++;
+ }
+ WriteSwappedDataToClient(client, length, reply);
+ (void) WriteToClient(client, namelen, name);
+ if (pFontInfo == &fontInfo)
+ {
+ xfree(fontInfo.props);
+ xfree(fontInfo.isStringProp);
+ }
+ --c->current.max_names;
+ }
+ }
+finish:
+ length = sizeof(xListFontsWithInfoReply);
+ bzero((char *) &finalReply, sizeof(xListFontsWithInfoReply));
+ finalReply.type = X_Reply;
+ finalReply.sequenceNumber = client->sequence;
+ finalReply.length = (sizeof(xListFontsWithInfoReply)
+ - sizeof(xGenericReply)) >> 2;
+ WriteSwappedDataToClient(client, length, &finalReply);
+bail:
+ if (c->slept)
+ ClientWakeup(client);
+ for (i = 0; i < c->num_fpes; i++)
+ FreeFPE(c->fpe_list[i]);
+ xfree(c->reply);
+ xfree(c->fpe_list);
+ if (c->savedName) xfree(c->savedName);
+ xfree(c);
+ return TRUE;
+}
+
+int
+StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
+ int max_names)
+{
+ int i;
+ LFWIclosurePtr c;
+
+ /*
+ * The right error to return here would be BadName, however the
+ * specification does not allow for a Name error on this request.
+ * Perhaps a better solution would be to return a nil list, i.e.
+ * a list containing zero fontnames.
+ */
+ if (length > XLFDMAXFONTNAMELEN)
+ return BadAlloc;
+
+ if (!(c = (LFWIclosurePtr) xalloc(sizeof *c)))
+ goto badAlloc;
+ c->fpe_list = (FontPathElementPtr *)
+ xalloc(sizeof(FontPathElementPtr) * num_fpes);
+ if (!c->fpe_list)
+ {
+ xfree(c);
+ goto badAlloc;
+ }
+ memmove(c->current.pattern, pattern, length);
+ for (i = 0; i < num_fpes; i++)
+ {
+ c->fpe_list[i] = font_path_elements[i];
+ UseFPE(c->fpe_list[i]);
+ }
+ c->client = client;
+ c->num_fpes = num_fpes;
+ c->reply = 0;
+ c->length = 0;
+ c->current.patlen = length;
+ c->current.current_fpe = 0;
+ c->current.max_names = max_names;
+ c->current.list_started = FALSE;
+ c->current.private = 0;
+ c->savedNumFonts = 0;
+ c->haveSaved = FALSE;
+ c->slept = FALSE;
+ c->savedName = 0;
+ doListFontsWithInfo(client, c);
+ return Success;
+badAlloc:
+ return BadAlloc;
+}
+
+#define TextEltHeader 2
+#define FontShiftSize 5
+static XID clearGC[] = { CT_NONE };
+#define clearGCmask (GCClipMask)
+
+int
+doPolyText(ClientPtr client, register PTclosurePtr c)
+{
+ register FontPtr pFont = c->pGC->font, oldpFont;
+ Font fid, oldfid;
+ int err = Success, lgerr; /* err is in X error, not font error, space */
+ enum { NEVER_SLEPT, START_SLEEP, SLEEPING } client_state = NEVER_SLEPT;
+ FontPathElementPtr fpe;
+ GC *origGC = NULL;
+
+ if (client->clientGone)
+ {
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+
+ if (c->slept)
+ {
+ /* Client has died, but we cannot bail out right now. We
+ need to clean up after the work we did when going to
+ sleep. Setting the drawable pointer to 0 makes this
+ happen without any attempts to render or perform other
+ unnecessary activities. */
+ c->pDraw = (DrawablePtr)0;
+ }
+ else
+ {
+ err = Success;
+ goto bail;
+ }
+ }
+
+ /* Make sure our drawable hasn't disappeared while we slept. */
+ if (c->slept &&
+ c->pDraw &&
+ c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
+ RC_DRAWABLE, SecurityWriteAccess))
+ {
+ /* Our drawable has disappeared. Treat like client died... ask
+ the FPE code to clean up after client and avoid further
+ rendering while we clean up after ourself. */
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ c->pDraw = (DrawablePtr)0;
+ }
+
+ client_state = c->slept ? SLEEPING : NEVER_SLEPT;
+
+ while (c->endReq - c->pElt > TextEltHeader)
+ {
+ if (*c->pElt == FontChange)
+ {
+ if (c->endReq - c->pElt < FontShiftSize)
+ {
+ err = BadLength;
+ goto bail;
+ }
+
+ oldpFont = pFont;
+ oldfid = fid;
+
+ fid = ((Font)*(c->pElt+4)) /* big-endian */
+ | ((Font)*(c->pElt+3)) << 8
+ | ((Font)*(c->pElt+2)) << 16
+ | ((Font)*(c->pElt+1)) << 24;
+ pFont = (FontPtr)SecurityLookupIDByType(client, fid, RT_FONT,
+ SecurityReadAccess);
+ if (!pFont)
+ {
+ client->errorValue = fid;
+ err = BadFont;
+ /* restore pFont and fid for step 4 (described below) */
+ pFont = oldpFont;
+ fid = oldfid;
+
+ /* If we're in START_SLEEP mode, the following step
+ shortens the request... in the unlikely event that
+ the fid somehow becomes valid before we come through
+ again to actually execute the polytext, which would
+ then mess up our refcounting scheme badly. */
+ c->err = err;
+ c->endReq = c->pElt;
+
+ goto bail;
+ }
+
+ /* Step 3 (described below) on our new font */
+ if (client_state == START_SLEEP)
+ pFont->refcnt++;
+ else
+ {
+ if (pFont != c->pGC->font && c->pDraw)
+ {
+ ChangeGC( c->pGC, GCFont, &fid);
+ ValidateGC(c->pDraw, c->pGC);
+ if (c->reqType == X_PolyText8)
+ c->polyText = (PolyTextPtr) c->pGC->ops->PolyText8;
+ else
+ c->polyText = (PolyTextPtr) c->pGC->ops->PolyText16;
+ }
+
+ /* Undo the refcnt++ we performed when going to sleep */
+ if (client_state == SLEEPING)
+ (void)CloseFont(c->pGC->font, (Font)0);
+ }
+ c->pElt += FontShiftSize;
+ }
+ else /* print a string */
+ {
+ unsigned char *pNextElt;
+ pNextElt = c->pElt + TextEltHeader + (*c->pElt)*c->itemSize;
+ if ( pNextElt > c->endReq)
+ {
+ err = BadLength;
+ goto bail;
+ }
+ if (client_state == START_SLEEP)
+ {
+ c->pElt = pNextElt;
+ continue;
+ }
+ if (c->pDraw)
+ {
+ lgerr = LoadGlyphs(client, c->pGC->font, *c->pElt, c->itemSize,
+ c->pElt + TextEltHeader);
+ }
+ else lgerr = Successful;
+
+ if (lgerr == Suspended)
+ {
+ if (!c->slept) {
+ int len;
+ GC *pGC;
+ PTclosurePtr new_closure;
+
+ /* We're putting the client to sleep. We need to do a few things
+ to ensure successful and atomic-appearing execution of the
+ remainder of the request. First, copy the remainder of the
+ request into a safe malloc'd area. Second, create a scratch GC
+ to use for the remainder of the request. Third, mark all fonts
+ referenced in the remainder of the request to prevent their
+ deallocation. Fourth, make the original GC look like the
+ request has completed... set its font to the final font value
+ from this request. These GC manipulations are for the unlikely
+ (but possible) event that some other client is using the GC.
+ Steps 3 and 4 are performed by running this procedure through
+ the remainder of the request in a special no-render mode
+ indicated by client_state = START_SLEEP. */
+
+ /* Step 1 */
+ /* Allocate a malloc'd closure structure to replace
+ the local one we were passed */
+ new_closure = (PTclosurePtr) xalloc(sizeof(PTclosureRec));
+ if (!new_closure)
+ {
+ err = BadAlloc;
+ goto bail;
+ }
+ *new_closure = *c;
+ c = new_closure;
+
+ len = c->endReq - c->pElt;
+ c->data = (unsigned char *)xalloc(len);
+ if (!c->data)
+ {
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ memmove(c->data, c->pElt, len);
+ c->pElt = c->data;
+ c->endReq = c->pElt + len;
+
+ /* Step 2 */
+
+ pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
+ if (!pGC)
+ {
+ xfree(c->data);
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ if ((err = CopyGC(c->pGC, pGC, GCFunction |
+ GCPlaneMask | GCForeground |
+ GCBackground | GCFillStyle |
+ GCTile | GCStipple |
+ GCTileStipXOrigin |
+ GCTileStipYOrigin | GCFont |
+ GCSubwindowMode | GCClipXOrigin |
+ GCClipYOrigin | GCClipMask)) !=
+ Success)
+ {
+ FreeScratchGC(pGC);
+ xfree(c->data);
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ origGC = c->pGC;
+ c->pGC = pGC;
+ ValidateGC(c->pDraw, c->pGC);
+
+ c->slept = TRUE;
+ ClientSleep(client,
+ (ClientSleepProcPtr)doPolyText,
+ (pointer) c);
+
+ /* Set up to perform steps 3 and 4 */
+ client_state = START_SLEEP;
+ continue; /* on to steps 3 and 4 */
+ }
+ return TRUE;
+ }
+ else if (lgerr != Successful)
+ {
+ err = FontToXError(lgerr);
+ goto bail;
+ }
+ if (c->pDraw)
+ {
+ c->xorg += *((INT8 *)(c->pElt + 1)); /* must be signed */
+ c->xorg = (* c->polyText)(c->pDraw, c->pGC, c->xorg, c->yorg,
+ *c->pElt, c->pElt + TextEltHeader);
+ }
+ c->pElt = pNextElt;
+ }
+ }
+
+bail:
+
+ if (client_state == START_SLEEP)
+ {
+ /* Step 4 */
+ if (pFont != origGC->font)
+ {
+ ChangeGC(origGC, GCFont, &fid);
+ ValidateGC(c->pDraw, origGC);
+ }
+
+ /* restore pElt pointer for execution of remainder of the request */
+ c->pElt = c->data;
+ return TRUE;
+ }
+
+ if (c->err != Success) err = c->err;
+ if (err != Success && c->client != serverClient) {
+#ifdef PANORAMIX
+ if (noPanoramiXExtension || !c->pGC->pScreen->myNum)
+#endif
+ SendErrorToClient(c->client, c->reqType, 0, 0, err);
+ }
+ if (c->slept)
+ {
+ ClientWakeup(c->client);
+ ChangeGC(c->pGC, clearGCmask, clearGC);
+
+ /* Unreference the font from the scratch GC */
+ CloseFont(c->pGC->font, (Font)0);
+ c->pGC->font = NullFont;
+
+ FreeScratchGC(c->pGC);
+ xfree(c->data);
+ xfree(c);
+ }
+ return TRUE;
+}
+
+int
+PolyText(ClientPtr client, DrawablePtr pDraw, GC *pGC, unsigned char *pElt,
+ unsigned char *endReq, int xorg, int yorg, int reqType, XID did)
+{
+ PTclosureRec local_closure;
+
+ local_closure.pElt = pElt;
+ local_closure.endReq = endReq;
+ local_closure.client = client;
+ local_closure.pDraw = pDraw;
+ local_closure.xorg = xorg;
+ local_closure.yorg = yorg;
+ if ((local_closure.reqType = reqType) == X_PolyText8)
+ {
+ local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText8;
+ local_closure.itemSize = 1;
+ }
+ else
+ {
+ local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText16;
+ local_closure.itemSize = 2;
+ }
+ local_closure.pGC = pGC;
+ local_closure.did = did;
+ local_closure.err = Success;
+ local_closure.slept = FALSE;
+
+ (void) doPolyText(client, &local_closure);
+ return Success;
+}
+
+
+#undef TextEltHeader
+#undef FontShiftSize
+
+int
+doImageText(ClientPtr client, register ITclosurePtr c)
+{
+ int err = Success, lgerr; /* err is in X error, not font error, space */
+ FontPathElementPtr fpe;
+
+ if (client->clientGone)
+ {
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ err = Success;
+ goto bail;
+ }
+
+ /* Make sure our drawable hasn't disappeared while we slept. */
+ if (c->slept &&
+ c->pDraw &&
+ c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
+ RC_DRAWABLE, SecurityWriteAccess))
+ {
+ /* Our drawable has disappeared. Treat like client died... ask
+ the FPE code to clean up after client. */
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ err = Success;
+ goto bail;
+ }
+
+ lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, c->itemSize, c->data);
+ if (lgerr == Suspended)
+ {
+ if (!c->slept) {
+ GC *pGC;
+ unsigned char *data;
+ ITclosurePtr new_closure;
+
+ /* We're putting the client to sleep. We need to
+ save some state. Similar problem to that handled
+ in doPolyText, but much simpler because the
+ request structure is much simpler. */
+
+ new_closure = (ITclosurePtr) xalloc(sizeof(ITclosureRec));
+ if (!new_closure)
+ {
+ err = BadAlloc;
+ goto bail;
+ }
+ *new_closure = *c;
+ c = new_closure;
+
+ data = (unsigned char *)xalloc(c->nChars * c->itemSize);
+ if (!data)
+ {
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ memmove(data, c->data, c->nChars * c->itemSize);
+ c->data = data;
+
+ pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
+ if (!pGC)
+ {
+ xfree(c->data);
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ if ((err = CopyGC(c->pGC, pGC, GCFunction | GCPlaneMask |
+ GCForeground | GCBackground | GCFillStyle |
+ GCTile | GCStipple | GCTileStipXOrigin |
+ GCTileStipYOrigin | GCFont |
+ GCSubwindowMode | GCClipXOrigin |
+ GCClipYOrigin | GCClipMask)) != Success)
+ {
+ FreeScratchGC(pGC);
+ xfree(c->data);
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ c->pGC = pGC;
+ ValidateGC(c->pDraw, c->pGC);
+
+ c->slept = TRUE;
+ ClientSleep(client, (ClientSleepProcPtr)doImageText, (pointer) c);
+ }
+ return TRUE;
+ }
+ else if (lgerr != Successful)
+ {
+ err = FontToXError(lgerr);
+ goto bail;
+ }
+ if (c->pDraw)
+ {
+ (* c->imageText)(c->pDraw, c->pGC, c->xorg, c->yorg,
+ c->nChars, c->data);
+ }
+
+bail:
+
+ if (err != Success && c->client != serverClient) {
+ SendErrorToClient(c->client, c->reqType, 0, 0, err);
+ }
+ if (c->slept)
+ {
+ ClientWakeup(c->client);
+ ChangeGC(c->pGC, clearGCmask, clearGC);
+
+ /* Unreference the font from the scratch GC */
+ CloseFont(c->pGC->font, (Font)0);
+ c->pGC->font = NullFont;
+
+ FreeScratchGC(c->pGC);
+ xfree(c->data);
+ xfree(c);
+ }
+ return TRUE;
+}
+
+int
+ImageText(ClientPtr client, DrawablePtr pDraw, GC *pGC, int nChars,
+ unsigned char *data, int xorg, int yorg, int reqType, XID did)
+{
+ ITclosureRec local_closure;
+
+ local_closure.client = client;
+ local_closure.pDraw = pDraw;
+ local_closure.pGC = pGC;
+ local_closure.nChars = nChars;
+ local_closure.data = data;
+ local_closure.xorg = xorg;
+ local_closure.yorg = yorg;
+ if ((local_closure.reqType = reqType) == X_ImageText8)
+ {
+ local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText8;
+ local_closure.itemSize = 1;
+ }
+ else
+ {
+ local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText16;
+ local_closure.itemSize = 2;
+ }
+ local_closure.did = did;
+ local_closure.slept = FALSE;
+
+ (void) doImageText(client, &local_closure);
+ return Success;
+}
+
+
+/* does the necessary magic to figure out the fpe type */
+static int
+DetermineFPEType(char *pathname)
+{
+ int i;
+
+ for (i = 0; i < num_fpe_types; i++) {
+ if ((*fpe_functions[i].name_check) (pathname))
+ return i;
+ }
+ return -1;
+}
+
+
+static void
+FreeFontPath(FontPathElementPtr *list, int n, Bool force)
+{
+ int i;
+
+ for (i = 0; i < n; i++) {
+ if (force) {
+ /* Sanity check that all refcounts will be 0 by the time
+ we get to the end of the list. */
+ int found = 1; /* the first reference is us */
+ int j;
+ for (j = i+1; j < n; j++) {
+ if (list[j] == list[i])
+ found++;
+ }
+ if (list[i]->refcount != found) {
+ ErrorF("FreeFontPath: FPE \"%.*s\" refcount is %d, should be %d; fixing.\n",
+ list[i]->name_length, list[i]->name,
+ list[i]->refcount, found);
+ list[i]->refcount = found; /* ensure it will get freed */
+ }
+ }
+ FreeFPE(list[i]);
+ }
+ xfree((char *) list);
+}
+
+static FontPathElementPtr
+find_existing_fpe(FontPathElementPtr *list, int num, unsigned char *name, int len)
+{
+ FontPathElementPtr fpe;
+ int i;
+
+ for (i = 0; i < num; i++) {
+ fpe = list[i];
+ if (fpe->name_length == len && memcmp(name, fpe->name, len) == 0)
+ return fpe;
+ }
+ return (FontPathElementPtr) 0;
+}
+
+
+static int
+SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
+{
+ int i, err = 0;
+ int valid_paths = 0;
+ unsigned int len;
+ unsigned char *cp = paths;
+ FontPathElementPtr fpe = NULL, *fplist;
+
+ fplist = (FontPathElementPtr *)
+ xalloc(sizeof(FontPathElementPtr) * npaths);
+ if (!fplist) {
+ *bad = 0;
+ return BadAlloc;
+ }
+ for (i = 0; i < num_fpe_types; i++) {
+ if (fpe_functions[i].set_path_hook)
+ (*fpe_functions[i].set_path_hook) ();
+ }
+ for (i = 0; i < npaths; i++)
+ {
+ len = (unsigned int) (*cp++);
+
+ if (len == 0)
+ {
+ if (persist)
+ ErrorF ("Removing empty element from the valid list of fontpaths\n");
+ err = BadValue;
+ }
+ else
+ {
+ /* if it's already in our active list, just reset it */
+ /*
+ * note that this can miss FPE's in limbo -- may be worth catching
+ * them, though it'd muck up refcounting
+ */
+ fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len);
+ if (fpe)
+ {
+ err = (*fpe_functions[fpe->type].reset_fpe) (fpe);
+ if (err == Successful)
+ {
+ UseFPE(fpe);/* since it'll be decref'd later when freed
+ * from the old list */
+ }
+ else
+ fpe = 0;
+ }
+ /* if error or can't do it, act like it's a new one */
+ if (!fpe)
+ {
+ fpe = (FontPathElementPtr) xalloc(sizeof(FontPathElementRec));
+ if (!fpe)
+ {
+ err = BadAlloc;
+ goto bail;
+ }
+ fpe->name = (char *) xalloc(len + 1);
+ if (!fpe->name)
+ {
+ xfree(fpe);
+ err = BadAlloc;
+ goto bail;
+ }
+ fpe->refcount = 1;
+
+ strncpy(fpe->name, (char *) cp, (int) len);
+ fpe->name[len] = '\0';
+ fpe->name_length = len;
+ fpe->type = DetermineFPEType(fpe->name);
+ if (fpe->type == -1)
+ err = BadValue;
+ else
+ err = (*fpe_functions[fpe->type].init_fpe) (fpe);
+ if (err != Successful)
+ {
+ if (persist)
+ {
+ ErrorF("Could not init font path element %s, removing from list!\n",
+ fpe->name);
+ }
+ xfree (fpe->name);
+ xfree (fpe);
+ }
+ }
+ }
+ if (err != Successful)
+ {
+ if (!persist)
+ goto bail;
+ }
+ else
+ {
+ fplist[valid_paths++] = fpe;
+ }
+ cp += len;
+ }
+
+ FreeFontPath(font_path_elements, num_fpes, FALSE);
+ font_path_elements = fplist;
+ if (patternCache)
+ EmptyFontPatternCache(patternCache);
+ num_fpes = valid_paths;
+
+ return Success;
+bail:
+ *bad = i;
+ while (--valid_paths >= 0)
+ FreeFPE(fplist[valid_paths]);
+ xfree(fplist);
+ return FontToXError(err);
+}
+
+/* XXX -- do we need to pass error down to each renderer? */
+int
+SetFontPath(ClientPtr client, int npaths, unsigned char *paths, int *error)
+{
+ int err = Success;
+
+ if (npaths == 0) {
+ if (SetDefaultFontPath(defaultFontPath) != Success)
+ return BadValue;
+ } else {
+ err = SetFontPathElements(npaths, paths, error, FALSE);
+ }
+ return err;
+}
+
+int
+SetDefaultFontPath(char *path)
+{
+ unsigned char *cp,
+ *pp,
+ *nump,
+ *newpath;
+ int num = 1,
+ len,
+ err,
+ size = 0,
+ bad;
+
+ /* get enough for string, plus values -- use up commas */
+#ifdef NX_TRANS_SOCKET
+ len = strlen(_NXGetFontPath(path)) + 1;
+#else
+ len = strlen(path) + 1;
+#endif
+ nump = cp = newpath = (unsigned char *) ALLOCATE_LOCAL(len);
+ if (!newpath)
+ return BadAlloc;
+#ifdef NX_TRANS_SOCKET
+ pp = (unsigned char *) _NXGetFontPath(path);
+#else
+ pp = (unsigned char *) path;
+#endif
+ cp++;
+ while (*pp) {
+ if (*pp == ',') {
+ *nump = (unsigned char) size;
+ nump = cp++;
+ pp++;
+ num++;
+ size = 0;
+ } else {
+ *cp++ = *pp++;
+ size++;
+ }
+ }
+ *nump = (unsigned char) size;
+
+ err = SetFontPathElements(num, newpath, &bad, TRUE);
+
+ DEALLOCATE_LOCAL(newpath);
+
+ return err;
+}
+
+unsigned char *
+GetFontPath(int *count, int *length)
+{
+ int i;
+ unsigned char *c;
+ int len;
+ FontPathElementPtr fpe;
+
+ len = 0;
+ for (i = 0; i < num_fpes; i++) {
+ fpe = font_path_elements[i];
+ len += fpe->name_length + 1;
+ }
+ font_path_string = (unsigned char *) xrealloc(font_path_string, len);
+ if (!font_path_string)
+ return NULL;
+
+ c = font_path_string;
+ *length = 0;
+ for (i = 0; i < num_fpes; i++) {
+ fpe = font_path_elements[i];
+ *c = fpe->name_length;
+ *length += *c++;
+ memmove(c, fpe->name, fpe->name_length);
+ c += fpe->name_length;
+ }
+ *count = num_fpes;
+ return font_path_string;
+}
+
+int
+LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size, unsigned char *data)
+{
+ if (fpe_functions[pfont->fpe->type].load_glyphs)
+ return (*fpe_functions[pfont->fpe->type].load_glyphs)
+ (client, pfont, 0, nchars, item_size, data);
+ else
+ return Successful;
+}
+
+void
+DeleteClientFontStuff(ClientPtr client)
+{
+ int i;
+ FontPathElementPtr fpe;
+
+ for (i = 0; i < num_fpes; i++)
+ {
+ fpe = font_path_elements[i];
+ if (fpe_functions[fpe->type].client_died)
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ }
+}
+
+void
+InitFonts ()
+{
+ patternCache = MakeFontPatternCache();
+
+#ifndef KDRIVESERVER
+ if (screenInfo.numScreens > screenInfo.numVideoScreens) {
+ PrinterFontRegisterFpeFunctions();
+ FontFileCheckRegisterFpeFunctions();
+ check_fs_register_fpe_functions();
+ } else
+#endif
+ {
+#ifdef KDRIVESERVER
+ BuiltinRegisterFpeFunctions();
+#endif
+ FontFileRegisterFpeFunctions();
+#ifndef NOFONTSERVERACCESS
+ fs_register_fpe_functions();
+#endif
+ }
+}
+
+int
+GetDefaultPointSize ()
+{
+ return 120;
+}
+
+
+FontResolutionPtr
+GetClientResolutions (int *num)
+{
+ if (requestingClient && requestingClient->fontResFunc != NULL &&
+ !requestingClient->clientGone)
+ {
+ return (*requestingClient->fontResFunc)(requestingClient, num);
+ }
+ else {
+ static struct _FontResolution res;
+ ScreenPtr pScreen;
+
+ pScreen = screenInfo.screens[0];
+ res.x_resolution = (pScreen->width * 25.4) / pScreen->mmWidth;
+ /*
+ * XXX - we'll want this as long as bitmap instances are prevalent
+ so that we can match them from scalable fonts
+ */
+ if (res.x_resolution < 88)
+ res.x_resolution = 75;
+ else
+ res.x_resolution = 100;
+ res.y_resolution = (pScreen->height * 25.4) / pScreen->mmHeight;
+ if (res.y_resolution < 88)
+ res.y_resolution = 75;
+ else
+ res.y_resolution = 100;
+ res.point_size = 120;
+ *num = 1;
+ return &res;
+ }
+}
+
+/*
+ * returns the type index of the new fpe
+ *
+ * should be called (only once!) by each type of fpe when initialized
+ */
+
+int
+RegisterFPEFunctions(NameCheckFunc name_func,
+ InitFpeFunc init_func,
+ FreeFpeFunc free_func,
+ ResetFpeFunc reset_func,
+ OpenFontFunc open_func,
+ CloseFontFunc close_func,
+ ListFontsFunc list_func,
+ StartLfwiFunc start_lfwi_func,
+ NextLfwiFunc next_lfwi_func,
+ WakeupFpeFunc wakeup_func,
+ ClientDiedFunc client_died,
+ LoadGlyphsFunc load_glyphs,
+ StartLaFunc start_list_alias_func,
+ NextLaFunc next_list_alias_func,
+ SetPathFunc set_path_func)
+{
+ FPEFunctions *new;
+
+ /* grow the list */
+ new = (FPEFunctions *) xrealloc(fpe_functions,
+ (num_fpe_types + 1) * sizeof(FPEFunctions));
+ if (!new)
+ return -1;
+ fpe_functions = new;
+
+ fpe_functions[num_fpe_types].name_check = name_func;
+ fpe_functions[num_fpe_types].open_font = open_func;
+ fpe_functions[num_fpe_types].close_font = close_func;
+ fpe_functions[num_fpe_types].wakeup_fpe = wakeup_func;
+ fpe_functions[num_fpe_types].list_fonts = list_func;
+ fpe_functions[num_fpe_types].start_list_fonts_with_info =
+ start_lfwi_func;
+ fpe_functions[num_fpe_types].list_next_font_with_info =
+ next_lfwi_func;
+ fpe_functions[num_fpe_types].init_fpe = init_func;
+ fpe_functions[num_fpe_types].free_fpe = free_func;
+ fpe_functions[num_fpe_types].reset_fpe = reset_func;
+ fpe_functions[num_fpe_types].client_died = client_died;
+ fpe_functions[num_fpe_types].load_glyphs = load_glyphs;
+ fpe_functions[num_fpe_types].start_list_fonts_and_aliases =
+ start_list_alias_func;
+ fpe_functions[num_fpe_types].list_next_font_or_alias =
+ next_list_alias_func;
+ fpe_functions[num_fpe_types].set_path_hook = set_path_func;
+
+ return num_fpe_types++;
+}
+
+void
+FreeFonts()
+{
+ if (patternCache) {
+ FreeFontPatternCache(patternCache);
+ patternCache = 0;
+ }
+ FreeFontPath(font_path_elements, num_fpes, TRUE);
+ font_path_elements = 0;
+ num_fpes = 0;
+ xfree(fpe_functions);
+ num_fpe_types = 0;
+ fpe_functions = (FPEFunctions *) 0;
+}
+
+/* convenience functions for FS interface */
+
+FontPtr
+find_old_font(XID id)
+{
+ return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE,
+ SecurityUnknownAccess);
+}
+
+Font
+GetNewFontClientID()
+{
+ return FakeClientID(0);
+}
+
+int
+StoreFontClientFont(FontPtr pfont, Font id)
+{
+ return AddResource(id, RT_NONE, (pointer) pfont);
+}
+
+void
+DeleteFontClientID(Font id)
+{
+ FreeResource(id, RT_NONE);
+}
+
+int
+client_auth_generation(ClientPtr client)
+{
+ return 0;
+}
+
+static int fs_handlers_installed = 0;
+static unsigned int last_server_gen;
+
+int
+init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler)
+{
+ /* if server has reset, make sure the b&w handlers are reinstalled */
+ if (last_server_gen < serverGeneration) {
+ last_server_gen = serverGeneration;
+ fs_handlers_installed = 0;
+ }
+ if (fs_handlers_installed == 0) {
+
+#ifdef DEBUG
+ fprintf(stderr, "adding FS b & w handlers\n");
+#endif
+
+ if (!RegisterBlockAndWakeupHandlers(block_handler,
+ FontWakeup, (pointer) 0))
+ return AllocError;
+ fs_handlers_installed++;
+ }
+ QueueFontWakeup(fpe);
+ return Successful;
+}
+
+void
+remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all)
+{
+ if (all) {
+ /* remove the handlers if no one else is using them */
+ if (--fs_handlers_installed == 0) {
+
+#ifdef DEBUG
+ fprintf(stderr, "removing FS b & w handlers\n");
+#endif
+
+ RemoveBlockAndWakeupHandlers(block_handler, FontWakeup,
+ (pointer) 0);
+ }
+ }
+ RemoveFontWakeup(fpe);
+}
+
+#ifdef DEBUG
+#define GLWIDTHBYTESPADDED(bits,nbytes) \
+ ((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \
+ :(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \
+ :(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \
+ :(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \
+ : 0)
+
+#define GLYPH_SIZE(ch, nbytes) \
+ GLWIDTHBYTESPADDED((ch)->metrics.rightSideBearing - \
+ (ch)->metrics.leftSideBearing, (nbytes))
+void
+dump_char_ascii(CharInfoPtr cip)
+{
+ int r,
+ l;
+ int bpr;
+ int byte;
+ static unsigned maskTab[] = {
+ (1 << 7), (1 << 6), (1 << 5), (1 << 4),
+ (1 << 3), (1 << 2), (1 << 1), (1 << 0),
+ };
+
+ bpr = GLYPH_SIZE(cip, 4);
+ for (r = 0; r < (cip->metrics.ascent + cip->metrics.descent); r++) {
+ pointer row = (pointer) cip->bits + r * bpr;
+
+ byte = 0;
+ for (l = 0; l <= (cip->metrics.rightSideBearing -
+ cip->metrics.leftSideBearing); l++) {
+ if (maskTab[l & 7] & row[l >> 3])
+ putchar('X');
+ else
+ putchar('.');
+ }
+ putchar('\n');
+ }
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/dix/dixfonts.c.NX.original b/nx-X11/programs/Xserver/dix/dixfonts.c.NX.original
new file mode 100644
index 000000000..e62f61432
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/dixfonts.c.NX.original
@@ -0,0 +1,2208 @@
+/* $XdotOrg: xc/programs/Xserver/dix/dixfonts.c,v 1.8 2005/07/03 08:53:38 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/dix/dixfonts.c,v 3.28 2003/11/08 02:02:03 dawes Exp $ */
+/************************************************************************
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+************************************************************************/
+/* The panoramix components contained the following notice */
+/*
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+/* $Xorg: dixfonts.c,v 1.4 2000/08/17 19:48:18 cpqbld Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "resource.h"
+#include "dixstruct.h"
+#include "cursorstr.h"
+#include "misc.h"
+#include "opaque.h"
+#include "dixfontstr.h"
+#include "closestr.h"
+
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
+#ifdef NX_TRANS_SOCKET
+
+char _NXFontPath[1024];
+
+/*
+ * Override the default font path and make
+ * it configurable at run time, based on
+ * the NX_FONT environment.
+ */
+
+static const char *_NXGetFontPath(const char *path)
+{
+ const char *fontEnv;
+
+ /*
+ * Check the environment only once.
+ */
+
+ if (*_NXFontPath != '\0')
+ {
+ return _NXFontPath;
+ }
+
+ fontEnv = getenv("NX_FONT");
+
+ if (fontEnv != NULL && *fontEnv != '\0')
+ {
+ if (strlen(fontEnv) + 1 > 1024)
+ {
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetFontPath: WARNING! Maximum length of font path exceeded.\n");
+#endif
+ goto _NXGetFontPathError;
+ }
+
+ strcpy(_NXFontPath, fontEnv);
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetFontPath: Using NX font path [%s].\n", _NXFontPath);
+#endif
+
+ return _NXFontPath;
+ }
+
+_NXGetFontPathError:
+
+ strcpy(_NXFontPath, path);
+
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetFontPath: Using default font path [%s].\n", _NXFontPath);
+#endif
+
+ return _NXFontPath;
+}
+
+#endif
+
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#endif
+
+#ifdef LBX
+#include "lbxserve.h"
+#endif
+
+#ifdef XF86BIGFONT
+#define _XF86BIGFONT_SERVER_
+#include <X11/extensions/xf86bigfont.h>
+#endif
+
+#define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics
+
+extern pointer fosNaturalParams;
+extern FontPtr defaultFont;
+
+static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0;
+static int num_fpes = 0;
+FPEFunctions *fpe_functions = (FPEFunctions *) 0;
+static int num_fpe_types = 0;
+
+static unsigned char *font_path_string;
+
+static int num_slept_fpes = 0;
+static int size_slept_fpes = 0;
+static FontPathElementPtr *slept_fpes = (FontPathElementPtr *) 0;
+static FontPatternCachePtr patternCache;
+
+int
+FontToXError(err)
+ int err;
+{
+ switch (err) {
+ case Successful:
+ return Success;
+ case AllocError:
+ return BadAlloc;
+ case BadFontName:
+ return BadName;
+ case BadFontPath:
+ case BadFontFormat: /* is there something better? */
+ case BadCharRange:
+ return BadValue;
+ default:
+ return err;
+ }
+}
+
+
+/*
+ * adding RT_FONT prevents conflict with default cursor font
+ */
+Bool
+SetDefaultFont(char *defaultfontname)
+{
+ int err;
+ FontPtr pf;
+ XID fid;
+
+ fid = FakeClientID(0);
+ err = OpenFont(serverClient, fid, FontLoadAll | FontOpenSync,
+ (unsigned) strlen(defaultfontname), defaultfontname);
+ if (err != Success)
+ return FALSE;
+ pf = (FontPtr) LookupIDByType(fid, RT_FONT);
+ if (pf == (FontPtr) NULL)
+ return FALSE;
+ defaultFont = pf;
+ return TRUE;
+}
+
+/*
+ * note that the font wakeup queue is not refcounted. this is because
+ * an fpe needs to be added when it's inited, and removed when it's finally
+ * freed, in order to handle any data that isn't requested, like FS events.
+ *
+ * since the only thing that should call these routines is the renderer's
+ * init_fpe() and free_fpe(), there shouldn't be any problem in using
+ * freed data.
+ */
+void
+QueueFontWakeup(FontPathElementPtr fpe)
+{
+ int i;
+ FontPathElementPtr *new;
+
+ for (i = 0; i < num_slept_fpes; i++) {
+ if (slept_fpes[i] == fpe) {
+
+#ifdef DEBUG
+ fprintf(stderr, "re-queueing fpe wakeup\n");
+#endif
+
+ return;
+ }
+ }
+ if (num_slept_fpes == size_slept_fpes) {
+ new = (FontPathElementPtr *)
+ xrealloc(slept_fpes,
+ sizeof(FontPathElementPtr) * (size_slept_fpes + 4));
+ if (!new)
+ return;
+ slept_fpes = new;
+ size_slept_fpes += 4;
+ }
+ slept_fpes[num_slept_fpes] = fpe;
+ num_slept_fpes++;
+}
+
+void
+RemoveFontWakeup(FontPathElementPtr fpe)
+{
+ int i,
+ j;
+
+ for (i = 0; i < num_slept_fpes; i++) {
+ if (slept_fpes[i] == fpe) {
+ for (j = i; j < num_slept_fpes; j++) {
+ slept_fpes[j] = slept_fpes[j + 1];
+ }
+ num_slept_fpes--;
+ return;
+ }
+ }
+}
+
+void
+FontWakeup(pointer data, int count, pointer LastSelectMask)
+{
+ int i;
+ FontPathElementPtr fpe;
+
+ if (count < 0)
+ return;
+ /* wake up any fpe's that may be waiting for information */
+ for (i = 0; i < num_slept_fpes; i++) {
+ fpe = slept_fpes[i];
+ (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask);
+ }
+}
+
+/* XXX -- these two funcs may want to be broken into macros */
+static void
+UseFPE(FontPathElementPtr fpe)
+{
+ fpe->refcount++;
+}
+
+static void
+FreeFPE (FontPathElementPtr fpe)
+{
+ fpe->refcount--;
+ if (fpe->refcount == 0) {
+ (*fpe_functions[fpe->type].free_fpe) (fpe);
+ xfree(fpe->name);
+ xfree(fpe);
+ }
+}
+
+static Bool
+doOpenFont(ClientPtr client, OFclosurePtr c)
+{
+ FontPtr pfont = NullFont;
+ FontPathElementPtr fpe = NULL;
+ ScreenPtr pScr;
+ int err = Successful;
+ int i;
+ char *alias,
+ *newname;
+ int newlen;
+ int aliascount = 20;
+ /*
+ * Decide at runtime what FontFormat to use.
+ */
+ Mask FontFormat =
+
+ ((screenInfo.imageByteOrder == LSBFirst) ?
+ BitmapFormatByteOrderLSB : BitmapFormatByteOrderMSB) |
+
+ ((screenInfo.bitmapBitOrder == LSBFirst) ?
+ BitmapFormatBitOrderLSB : BitmapFormatBitOrderMSB) |
+
+ BitmapFormatImageRectMin |
+
+#if GLYPHPADBYTES == 1
+ BitmapFormatScanlinePad8 |
+#endif
+
+#if GLYPHPADBYTES == 2
+ BitmapFormatScanlinePad16 |
+#endif
+
+#if GLYPHPADBYTES == 4
+ BitmapFormatScanlinePad32 |
+#endif
+
+#if GLYPHPADBYTES == 8
+ BitmapFormatScanlinePad64 |
+#endif
+
+ BitmapFormatScanlineUnit8;
+
+ if (client->clientGone)
+ {
+ if (c->current_fpe < c->num_fpes)
+ {
+ fpe = c->fpe_list[c->current_fpe];
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ }
+ err = Successful;
+ goto bail;
+ }
+ while (c->current_fpe < c->num_fpes) {
+ fpe = c->fpe_list[c->current_fpe];
+ err = (*fpe_functions[fpe->type].open_font)
+ ((pointer) client, fpe, c->flags,
+ c->fontname, c->fnamelen, FontFormat,
+ BitmapFormatMaskByte |
+ BitmapFormatMaskBit |
+ BitmapFormatMaskImageRectangle |
+ BitmapFormatMaskScanLinePad |
+ BitmapFormatMaskScanLineUnit,
+ c->fontid, &pfont, &alias,
+ c->non_cachable_font && c->non_cachable_font->fpe == fpe ?
+ c->non_cachable_font :
+ (FontPtr)0);
+
+ if (err == FontNameAlias && alias) {
+ newlen = strlen(alias);
+ newname = (char *) xrealloc(c->fontname, newlen);
+ if (!newname) {
+ err = AllocError;
+ break;
+ }
+ memmove(newname, alias, newlen);
+ c->fontname = newname;
+ c->fnamelen = newlen;
+ c->current_fpe = 0;
+ if (--aliascount <= 0)
+ break;
+ continue;
+ }
+ if (err == BadFontName) {
+ c->current_fpe++;
+ continue;
+ }
+ if (err == Suspended) {
+ if (!c->slept) {
+ c->slept = TRUE;
+ ClientSleep(client, (ClientSleepProcPtr)doOpenFont, (pointer) c);
+ }
+ return TRUE;
+ }
+ break;
+ }
+
+ if (err != Successful)
+ goto bail;
+ if (!pfont) {
+ err = BadFontName;
+ goto bail;
+ }
+ if (!pfont->fpe)
+ pfont->fpe = fpe;
+ pfont->refcnt++;
+ if (pfont->refcnt == 1) {
+ UseFPE(pfont->fpe);
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ pScr = screenInfo.screens[i];
+ if (pScr->RealizeFont)
+ {
+ if (!(*pScr->RealizeFont) (pScr, pfont))
+ {
+ CloseFont (pfont, (Font) 0);
+ err = AllocError;
+ goto bail;
+ }
+ }
+ }
+ }
+ if (!AddResource(c->fontid, RT_FONT, (pointer) pfont)) {
+ err = AllocError;
+ goto bail;
+ }
+ if (patternCache && pfont != c->non_cachable_font)
+ CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen,
+ pfont);
+bail:
+ if (err != Successful && c->client != serverClient) {
+ SendErrorToClient(c->client, X_OpenFont, 0,
+ c->fontid, FontToXError(err));
+ }
+ if (c->slept)
+ ClientWakeup(c->client);
+ for (i = 0; i < c->num_fpes; i++) {
+ FreeFPE(c->fpe_list[i]);
+ }
+ xfree(c->fpe_list);
+ xfree(c->fontname);
+ xfree(c);
+ return TRUE;
+}
+
+int
+OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontname)
+{
+ OFclosurePtr c;
+ int i;
+ FontPtr cached = (FontPtr)0;
+
+#ifdef FONTDEBUG
+ char *f;
+ f = (char *)xalloc(lenfname + 1);
+ memmove(f, pfontname, lenfname);
+ f[lenfname] = '\0';
+ ErrorF("OpenFont: fontname is \"%s\"\n", f);
+ xfree(f);
+#endif
+ if (!lenfname || lenfname > XLFDMAXFONTNAMELEN)
+ return BadName;
+ if (patternCache)
+ {
+
+ /*
+ ** Check name cache. If we find a cached version of this font that
+ ** is cachable, immediately satisfy the request with it. If we find
+ ** a cached version of this font that is non-cachable, we do not
+ ** satisfy the request with it. Instead, we pass the FontPtr to the
+ ** FPE's open_font code (the fontfile FPE in turn passes the
+ ** information to the rasterizer; the fserve FPE ignores it).
+ **
+ ** Presumably, the font is marked non-cachable because the FPE has
+ ** put some licensing restrictions on it. If the FPE, using
+ ** whatever logic it relies on, determines that it is willing to
+ ** share this existing font with the client, then it has the option
+ ** to return the FontPtr we passed it as the newly-opened font.
+ ** This allows the FPE to exercise its licensing logic without
+ ** having to create another instance of a font that already exists.
+ */
+
+ cached = FindCachedFontPattern(patternCache, pfontname, lenfname);
+ if (cached && cached->info.cachable)
+ {
+ if (!AddResource(fid, RT_FONT, (pointer) cached))
+ return BadAlloc;
+ cached->refcnt++;
+ return Success;
+ }
+ }
+ c = (OFclosurePtr) xalloc(sizeof(OFclosureRec));
+ if (!c)
+ return BadAlloc;
+ c->fontname = (char *) xalloc(lenfname);
+ c->origFontName = pfontname;
+ c->origFontNameLen = lenfname;
+ if (!c->fontname) {
+ xfree(c);
+ return BadAlloc;
+ }
+ /*
+ * copy the current FPE list, so that if it gets changed by another client
+ * while we're blocking, the request still appears atomic
+ */
+ c->fpe_list = (FontPathElementPtr *)
+ xalloc(sizeof(FontPathElementPtr) * num_fpes);
+ if (!c->fpe_list) {
+ xfree(c->fontname);
+ xfree(c);
+ return BadAlloc;
+ }
+ memmove(c->fontname, pfontname, lenfname);
+ for (i = 0; i < num_fpes; i++) {
+ c->fpe_list[i] = font_path_elements[i];
+ UseFPE(c->fpe_list[i]);
+ }
+ c->client = client;
+ c->fontid = fid;
+ c->current_fpe = 0;
+ c->num_fpes = num_fpes;
+ c->fnamelen = lenfname;
+ c->slept = FALSE;
+ c->flags = flags;
+ c->non_cachable_font = cached;
+
+ (void) doOpenFont(client, c);
+ return Success;
+}
+
+/**
+ * Decrement font's ref count, and free storage if ref count equals zero
+ *
+ * \param value must conform to DeleteType
+ */
+int
+CloseFont(pointer value, XID fid)
+{
+ int nscr;
+ ScreenPtr pscr;
+ FontPathElementPtr fpe;
+ FontPtr pfont = (FontPtr)value;
+
+ if (pfont == NullFont)
+ return (Success);
+ if (--pfont->refcnt == 0) {
+ if (patternCache)
+ RemoveCachedFontPattern (patternCache, pfont);
+ /*
+ * since the last reference is gone, ask each screen to free any
+ * storage it may have allocated locally for it.
+ */
+ for (nscr = 0; nscr < screenInfo.numScreens; nscr++) {
+ pscr = screenInfo.screens[nscr];
+ if (pscr->UnrealizeFont)
+ (*pscr->UnrealizeFont) (pscr, pfont);
+ }
+ if (pfont == defaultFont)
+ defaultFont = NULL;
+#ifdef LBX
+ LbxFreeFontTag(pfont);
+#endif
+#ifdef XF86BIGFONT
+ XF86BigfontFreeFontShm(pfont);
+#endif
+ fpe = pfont->fpe;
+ (*fpe_functions[fpe->type].close_font) (fpe, pfont);
+ FreeFPE(fpe);
+ }
+ return (Success);
+}
+
+
+/***====================================================================***/
+
+/**
+ * Sets up pReply as the correct QueryFontReply for pFont with the first
+ * nProtoCCIStructs char infos.
+ *
+ * \param pReply caller must allocate this storage
+ */
+void
+QueryFont(FontPtr pFont, xQueryFontReply *pReply, int nProtoCCIStructs)
+{
+ FontPropPtr pFP;
+ int r,
+ c,
+ i;
+ xFontProp *prFP;
+ xCharInfo *prCI;
+ xCharInfo *charInfos[256];
+ unsigned char chars[512];
+ int ninfos;
+ unsigned long ncols;
+ unsigned long count;
+
+ /* pr->length set in dispatch */
+ pReply->minCharOrByte2 = pFont->info.firstCol;
+ pReply->defaultChar = pFont->info.defaultCh;
+ pReply->maxCharOrByte2 = pFont->info.lastCol;
+ pReply->drawDirection = pFont->info.drawDirection;
+ pReply->allCharsExist = pFont->info.allExist;
+ pReply->minByte1 = pFont->info.firstRow;
+ pReply->maxByte1 = pFont->info.lastRow;
+ pReply->fontAscent = pFont->info.fontAscent;
+ pReply->fontDescent = pFont->info.fontDescent;
+
+ pReply->minBounds = pFont->info.ink_minbounds;
+ pReply->maxBounds = pFont->info.ink_maxbounds;
+
+ pReply->nFontProps = pFont->info.nprops;
+ pReply->nCharInfos = nProtoCCIStructs;
+
+ for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) (&pReply[1]);
+ i < pFont->info.nprops;
+ i++, pFP++, prFP++) {
+ prFP->name = pFP->name;
+ prFP->value = pFP->value;
+ }
+
+ ninfos = 0;
+ ncols = (unsigned long) (pFont->info.lastCol - pFont->info.firstCol + 1);
+ prCI = (xCharInfo *) (prFP);
+ for (r = pFont->info.firstRow;
+ ninfos < nProtoCCIStructs && r <= (int)pFont->info.lastRow;
+ r++) {
+ i = 0;
+ for (c = pFont->info.firstCol; c <= (int)pFont->info.lastCol; c++) {
+ chars[i++] = r;
+ chars[i++] = c;
+ }
+ (*pFont->get_metrics) (pFont, ncols, chars,
+ TwoD16Bit, &count, charInfos);
+ i = 0;
+ for (i = 0; i < (int) count && ninfos < nProtoCCIStructs; i++) {
+ *prCI = *charInfos[i];
+ prCI++;
+ ninfos++;
+ }
+ }
+ return;
+}
+
+static Bool
+doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
+{
+ FontPathElementPtr fpe;
+ int err = Successful;
+ FontNamesPtr names = NULL;
+ char *name, *resolved=NULL;
+ int namelen, resolvedlen;
+ int nnames;
+ int stringLens;
+ int i;
+ xListFontsReply reply;
+ char *bufptr;
+ char *bufferStart;
+ int aliascount = 0;
+
+ if (client->clientGone)
+ {
+ if (c->current.current_fpe < c->num_fpes)
+ {
+ fpe = c->fpe_list[c->current.current_fpe];
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ }
+ err = Successful;
+ goto bail;
+ }
+
+ if (!c->current.patlen)
+ goto finish;
+
+ while (c->current.current_fpe < c->num_fpes) {
+ fpe = c->fpe_list[c->current.current_fpe];
+ err = Successful;
+
+ if (!fpe_functions[fpe->type].start_list_fonts_and_aliases)
+ {
+ /* This FPE doesn't support/require list_fonts_and_aliases */
+
+ err = (*fpe_functions[fpe->type].list_fonts)
+ ((pointer) c->client, fpe, c->current.pattern,
+ c->current.patlen, c->current.max_names - c->names->nnames,
+ c->names);
+
+ if (err == Suspended) {
+ if (!c->slept) {
+ c->slept = TRUE;
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsAndAliases,
+ (pointer) c);
+ }
+ return TRUE;
+ }
+
+ err = BadFontName;
+ }
+ else
+ {
+ /* Start of list_fonts_and_aliases functionality. Modeled
+ after list_fonts_with_info in that it resolves aliases,
+ except that the information collected from FPEs is just
+ names, not font info. Each list_next_font_or_alias()
+ returns either a name into name/namelen or an alias into
+ name/namelen and its target name into resolved/resolvedlen.
+ The code at this level then resolves the alias by polling
+ the FPEs. */
+
+ if (!c->current.list_started) {
+ err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases)
+ ((pointer) c->client, fpe, c->current.pattern,
+ c->current.patlen, c->current.max_names - c->names->nnames,
+ &c->current.private);
+ if (err == Suspended) {
+ if (!c->slept) {
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsAndAliases,
+ (pointer) c);
+ c->slept = TRUE;
+ }
+ return TRUE;
+ }
+ if (err == Successful)
+ c->current.list_started = TRUE;
+ }
+ if (err == Successful) {
+ char *tmpname;
+ name = 0;
+ err = (*fpe_functions[fpe->type].list_next_font_or_alias)
+ ((pointer) c->client, fpe, &name, &namelen, &tmpname,
+ &resolvedlen, c->current.private);
+ if (err == Suspended) {
+ if (!c->slept) {
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsAndAliases,
+ (pointer) c);
+ c->slept = TRUE;
+ }
+ return TRUE;
+ }
+ if (err == FontNameAlias) {
+ if (resolved) xfree(resolved);
+ resolved = (char *) xalloc(resolvedlen + 1);
+ if (resolved)
+ memmove(resolved, tmpname, resolvedlen + 1);
+ }
+ }
+
+ if (err == Successful)
+ {
+ if (c->haveSaved)
+ {
+ if (c->savedName)
+ (void)AddFontNamesName(c->names, c->savedName,
+ c->savedNameLen);
+ }
+ else
+ (void)AddFontNamesName(c->names, name, namelen);
+ }
+
+ /*
+ * When we get an alias back, save our state and reset back to
+ * the start of the FPE looking for the specified name. As
+ * soon as a real font is found for the alias, pop back to the
+ * old state
+ */
+ else if (err == FontNameAlias) {
+ char tmp_pattern[XLFDMAXFONTNAMELEN];
+ /*
+ * when an alias recurses, we need to give
+ * the last FPE a chance to clean up; so we call
+ * it again, and assume that the error returned
+ * is BadFontName, indicating the alias resolution
+ * is complete.
+ */
+ memmove(tmp_pattern, resolved, resolvedlen);
+ if (c->haveSaved)
+ {
+ char *tmpname;
+ int tmpnamelen;
+
+ tmpname = 0;
+ (void) (*fpe_functions[fpe->type].list_next_font_or_alias)
+ ((pointer) c->client, fpe, &tmpname, &tmpnamelen,
+ &tmpname, &tmpnamelen, c->current.private);
+ if (--aliascount <= 0)
+ {
+ err = BadFontName;
+ goto ContBadFontName;
+ }
+ }
+ else
+ {
+ c->saved = c->current;
+ c->haveSaved = TRUE;
+ if (c->savedName)
+ xfree(c->savedName);
+ c->savedName = (char *)xalloc(namelen + 1);
+ if (c->savedName)
+ memmove(c->savedName, name, namelen + 1);
+ c->savedNameLen = namelen;
+ aliascount = 20;
+ }
+ memmove(c->current.pattern, tmp_pattern, resolvedlen);
+ c->current.patlen = resolvedlen;
+ c->current.max_names = c->names->nnames + 1;
+ c->current.current_fpe = -1;
+ c->current.private = 0;
+ err = BadFontName;
+ }
+ }
+ /*
+ * At the end of this FPE, step to the next. If we've finished
+ * processing an alias, pop state back. If we've collected enough
+ * font names, quit.
+ */
+ if (err == BadFontName) {
+ ContBadFontName: ;
+ c->current.list_started = FALSE;
+ c->current.current_fpe++;
+ err = Successful;
+ if (c->haveSaved)
+ {
+ if (c->names->nnames == c->current.max_names ||
+ c->current.current_fpe == c->num_fpes) {
+ c->haveSaved = FALSE;
+ c->current = c->saved;
+ /* Give the saved namelist a chance to clean itself up */
+ continue;
+ }
+ }
+ if (c->names->nnames == c->current.max_names)
+ break;
+ }
+ }
+
+ /*
+ * send the reply
+ */
+ if (err != Successful) {
+ SendErrorToClient(client, X_ListFonts, 0, 0, FontToXError(err));
+ goto bail;
+ }
+
+finish:
+
+ names = c->names;
+ nnames = names->nnames;
+ client = c->client;
+ stringLens = 0;
+ for (i = 0; i < nnames; i++)
+ stringLens += (names->length[i] <= 255) ? names->length[i] : 0;
+
+ reply.type = X_Reply;
+ reply.length = (stringLens + nnames + 3) >> 2;
+ reply.nFonts = nnames;
+ reply.sequenceNumber = client->sequence;
+
+ bufptr = bufferStart = (char *) ALLOCATE_LOCAL(reply.length << 2);
+
+ if (!bufptr && reply.length) {
+ SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc);
+ goto bail;
+ }
+ /*
+ * since WriteToClient long word aligns things, copy to temp buffer and
+ * write all at once
+ */
+ for (i = 0; i < nnames; i++) {
+ if (names->length[i] > 255)
+ reply.nFonts--;
+ else
+ {
+ *bufptr++ = names->length[i];
+ memmove( bufptr, names->names[i], names->length[i]);
+ bufptr += names->length[i];
+ }
+ }
+ nnames = reply.nFonts;
+ reply.length = (stringLens + nnames + 3) >> 2;
+ client->pSwapReplyFunc = ReplySwapVector[X_ListFonts];
+ WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply);
+ (void) WriteToClient(client, stringLens + nnames, bufferStart);
+ DEALLOCATE_LOCAL(bufferStart);
+
+bail:
+ if (c->slept)
+ ClientWakeup(client);
+ for (i = 0; i < c->num_fpes; i++)
+ FreeFPE(c->fpe_list[i]);
+ xfree(c->fpe_list);
+ if (c->savedName) xfree(c->savedName);
+ FreeFontNames(names);
+ xfree(c);
+ if (resolved) xfree(resolved);
+ return TRUE;
+}
+
+int
+ListFonts(ClientPtr client, unsigned char *pattern, unsigned length,
+ unsigned max_names)
+{
+ int i;
+ LFclosurePtr c;
+
+ /*
+ * The right error to return here would be BadName, however the
+ * specification does not allow for a Name error on this request.
+ * Perhaps a better solution would be to return a nil list, i.e.
+ * a list containing zero fontnames.
+ */
+ if (length > XLFDMAXFONTNAMELEN)
+ return BadAlloc;
+
+ if (!(c = (LFclosurePtr) xalloc(sizeof *c)))
+ return BadAlloc;
+ c->fpe_list = (FontPathElementPtr *)
+ xalloc(sizeof(FontPathElementPtr) * num_fpes);
+ if (!c->fpe_list) {
+ xfree(c);
+ return BadAlloc;
+ }
+ c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100);
+ if (!c->names)
+ {
+ xfree(c->fpe_list);
+ xfree(c);
+ return BadAlloc;
+ }
+ memmove( c->current.pattern, pattern, length);
+ for (i = 0; i < num_fpes; i++) {
+ c->fpe_list[i] = font_path_elements[i];
+ UseFPE(c->fpe_list[i]);
+ }
+ c->client = client;
+ c->num_fpes = num_fpes;
+ c->current.patlen = length;
+ c->current.current_fpe = 0;
+ c->current.max_names = max_names;
+ c->current.list_started = FALSE;
+ c->current.private = 0;
+ c->haveSaved = FALSE;
+ c->slept = FALSE;
+ c->savedName = 0;
+ doListFontsAndAliases(client, c);
+ return Success;
+}
+
+int
+doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
+{
+ FontPathElementPtr fpe;
+ int err = Successful;
+ char *name;
+ int namelen;
+ int numFonts;
+ FontInfoRec fontInfo,
+ *pFontInfo;
+ xListFontsWithInfoReply *reply;
+ int length;
+ xFontProp *pFP;
+ int i;
+ int aliascount = 0;
+ xListFontsWithInfoReply finalReply;
+
+ if (client->clientGone)
+ {
+ if (c->current.current_fpe < c->num_fpes)
+ {
+ fpe = c->fpe_list[c->current.current_fpe];
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ }
+ err = Successful;
+ goto bail;
+ }
+ client->pSwapReplyFunc = ReplySwapVector[X_ListFontsWithInfo];
+ if (!c->current.patlen)
+ goto finish;
+ while (c->current.current_fpe < c->num_fpes)
+ {
+ fpe = c->fpe_list[c->current.current_fpe];
+ err = Successful;
+ if (!c->current.list_started)
+ {
+ err = (*fpe_functions[fpe->type].start_list_fonts_with_info)
+ (client, fpe, c->current.pattern, c->current.patlen,
+ c->current.max_names, &c->current.private);
+ if (err == Suspended)
+ {
+ if (!c->slept)
+ {
+ ClientSleep(client, (ClientSleepProcPtr)doListFontsWithInfo, c);
+ c->slept = TRUE;
+ }
+ return TRUE;
+ }
+ if (err == Successful)
+ c->current.list_started = TRUE;
+ }
+ if (err == Successful)
+ {
+ name = 0;
+ pFontInfo = &fontInfo;
+ err = (*fpe_functions[fpe->type].list_next_font_with_info)
+ (client, fpe, &name, &namelen, &pFontInfo,
+ &numFonts, c->current.private);
+ if (err == Suspended)
+ {
+ if (!c->slept)
+ {
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsWithInfo,
+ c);
+ c->slept = TRUE;
+ }
+ return TRUE;
+ }
+ }
+ /*
+ * When we get an alias back, save our state and reset back to the
+ * start of the FPE looking for the specified name. As soon as a real
+ * font is found for the alias, pop back to the old state
+ */
+ if (err == FontNameAlias)
+ {
+ /*
+ * when an alias recurses, we need to give
+ * the last FPE a chance to clean up; so we call
+ * it again, and assume that the error returned
+ * is BadFontName, indicating the alias resolution
+ * is complete.
+ */
+ if (c->haveSaved)
+ {
+ char *tmpname;
+ int tmpnamelen;
+ FontInfoPtr tmpFontInfo;
+
+ tmpname = 0;
+ tmpFontInfo = &fontInfo;
+ (void) (*fpe_functions[fpe->type].list_next_font_with_info)
+ (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo,
+ &numFonts, c->current.private);
+ if (--aliascount <= 0)
+ {
+ err = BadFontName;
+ goto ContBadFontName;
+ }
+ }
+ else
+ {
+ c->saved = c->current;
+ c->haveSaved = TRUE;
+ c->savedNumFonts = numFonts;
+ if (c->savedName)
+ xfree(c->savedName);
+ c->savedName = (char *)xalloc(namelen + 1);
+ if (c->savedName)
+ memmove(c->savedName, name, namelen + 1);
+ aliascount = 20;
+ }
+ memmove(c->current.pattern, name, namelen);
+ c->current.patlen = namelen;
+ c->current.max_names = 1;
+ c->current.current_fpe = 0;
+ c->current.private = 0;
+ c->current.list_started = FALSE;
+ }
+ /*
+ * At the end of this FPE, step to the next. If we've finished
+ * processing an alias, pop state back. If we've sent enough font
+ * names, quit. Always wait for BadFontName to let the FPE
+ * have a chance to clean up.
+ */
+ else if (err == BadFontName)
+ {
+ ContBadFontName: ;
+ c->current.list_started = FALSE;
+ c->current.current_fpe++;
+ err = Successful;
+ if (c->haveSaved)
+ {
+ if (c->current.max_names == 0 ||
+ c->current.current_fpe == c->num_fpes)
+ {
+ c->haveSaved = FALSE;
+ c->saved.max_names -= (1 - c->current.max_names);
+ c->current = c->saved;
+ }
+ }
+ else if (c->current.max_names == 0)
+ break;
+ }
+ else if (err == Successful)
+ {
+ length = sizeof(*reply) + pFontInfo->nprops * sizeof(xFontProp);
+ reply = c->reply;
+ if (c->length < length)
+ {
+ reply = (xListFontsWithInfoReply *) xrealloc(c->reply, length);
+ if (!reply)
+ {
+ err = AllocError;
+ break;
+ }
+ c->reply = reply;
+ c->length = length;
+ }
+ if (c->haveSaved)
+ {
+ numFonts = c->savedNumFonts;
+ name = c->savedName;
+ namelen = strlen(name);
+ }
+ reply->type = X_Reply;
+ reply->length = (sizeof *reply - sizeof(xGenericReply) +
+ pFontInfo->nprops * sizeof(xFontProp) +
+ namelen + 3) >> 2;
+ reply->sequenceNumber = client->sequence;
+ reply->nameLength = namelen;
+ reply->minBounds = pFontInfo->ink_minbounds;
+ reply->maxBounds = pFontInfo->ink_maxbounds;
+ reply->minCharOrByte2 = pFontInfo->firstCol;
+ reply->maxCharOrByte2 = pFontInfo->lastCol;
+ reply->defaultChar = pFontInfo->defaultCh;
+ reply->nFontProps = pFontInfo->nprops;
+ reply->drawDirection = pFontInfo->drawDirection;
+ reply->minByte1 = pFontInfo->firstRow;
+ reply->maxByte1 = pFontInfo->lastRow;
+ reply->allCharsExist = pFontInfo->allExist;
+ reply->fontAscent = pFontInfo->fontAscent;
+ reply->fontDescent = pFontInfo->fontDescent;
+ reply->nReplies = numFonts;
+ pFP = (xFontProp *) (reply + 1);
+ for (i = 0; i < pFontInfo->nprops; i++)
+ {
+ pFP->name = pFontInfo->props[i].name;
+ pFP->value = pFontInfo->props[i].value;
+ pFP++;
+ }
+ WriteSwappedDataToClient(client, length, reply);
+ (void) WriteToClient(client, namelen, name);
+ if (pFontInfo == &fontInfo)
+ {
+ xfree(fontInfo.props);
+ xfree(fontInfo.isStringProp);
+ }
+ --c->current.max_names;
+ }
+ }
+finish:
+ length = sizeof(xListFontsWithInfoReply);
+ bzero((char *) &finalReply, sizeof(xListFontsWithInfoReply));
+ finalReply.type = X_Reply;
+ finalReply.sequenceNumber = client->sequence;
+ finalReply.length = (sizeof(xListFontsWithInfoReply)
+ - sizeof(xGenericReply)) >> 2;
+ WriteSwappedDataToClient(client, length, &finalReply);
+bail:
+ if (c->slept)
+ ClientWakeup(client);
+ for (i = 0; i < c->num_fpes; i++)
+ FreeFPE(c->fpe_list[i]);
+ xfree(c->reply);
+ xfree(c->fpe_list);
+ if (c->savedName) xfree(c->savedName);
+ xfree(c);
+ return TRUE;
+}
+
+int
+StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
+ int max_names)
+{
+ int i;
+ LFWIclosurePtr c;
+
+ /*
+ * The right error to return here would be BadName, however the
+ * specification does not allow for a Name error on this request.
+ * Perhaps a better solution would be to return a nil list, i.e.
+ * a list containing zero fontnames.
+ */
+ if (length > XLFDMAXFONTNAMELEN)
+ return BadAlloc;
+
+ if (!(c = (LFWIclosurePtr) xalloc(sizeof *c)))
+ goto badAlloc;
+ c->fpe_list = (FontPathElementPtr *)
+ xalloc(sizeof(FontPathElementPtr) * num_fpes);
+ if (!c->fpe_list)
+ {
+ xfree(c);
+ goto badAlloc;
+ }
+ memmove(c->current.pattern, pattern, length);
+ for (i = 0; i < num_fpes; i++)
+ {
+ c->fpe_list[i] = font_path_elements[i];
+ UseFPE(c->fpe_list[i]);
+ }
+ c->client = client;
+ c->num_fpes = num_fpes;
+ c->reply = 0;
+ c->length = 0;
+ c->current.patlen = length;
+ c->current.current_fpe = 0;
+ c->current.max_names = max_names;
+ c->current.list_started = FALSE;
+ c->current.private = 0;
+ c->savedNumFonts = 0;
+ c->haveSaved = FALSE;
+ c->slept = FALSE;
+ c->savedName = 0;
+ doListFontsWithInfo(client, c);
+ return Success;
+badAlloc:
+ return BadAlloc;
+}
+
+#define TextEltHeader 2
+#define FontShiftSize 5
+static XID clearGC[] = { CT_NONE };
+#define clearGCmask (GCClipMask)
+
+int
+doPolyText(ClientPtr client, register PTclosurePtr c)
+{
+ register FontPtr pFont = c->pGC->font, oldpFont;
+ Font fid, oldfid;
+ int err = Success, lgerr; /* err is in X error, not font error, space */
+ enum { NEVER_SLEPT, START_SLEEP, SLEEPING } client_state = NEVER_SLEPT;
+ FontPathElementPtr fpe;
+ GC *origGC = NULL;
+
+ if (client->clientGone)
+ {
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+
+ if (c->slept)
+ {
+ /* Client has died, but we cannot bail out right now. We
+ need to clean up after the work we did when going to
+ sleep. Setting the drawable pointer to 0 makes this
+ happen without any attempts to render or perform other
+ unnecessary activities. */
+ c->pDraw = (DrawablePtr)0;
+ }
+ else
+ {
+ err = Success;
+ goto bail;
+ }
+ }
+
+ /* Make sure our drawable hasn't disappeared while we slept. */
+ if (c->slept &&
+ c->pDraw &&
+ c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
+ RC_DRAWABLE, SecurityWriteAccess))
+ {
+ /* Our drawable has disappeared. Treat like client died... ask
+ the FPE code to clean up after client and avoid further
+ rendering while we clean up after ourself. */
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ c->pDraw = (DrawablePtr)0;
+ }
+
+ client_state = c->slept ? SLEEPING : NEVER_SLEPT;
+
+ while (c->endReq - c->pElt > TextEltHeader)
+ {
+ if (*c->pElt == FontChange)
+ {
+ if (c->endReq - c->pElt < FontShiftSize)
+ {
+ err = BadLength;
+ goto bail;
+ }
+
+ oldpFont = pFont;
+ oldfid = fid;
+
+ fid = ((Font)*(c->pElt+4)) /* big-endian */
+ | ((Font)*(c->pElt+3)) << 8
+ | ((Font)*(c->pElt+2)) << 16
+ | ((Font)*(c->pElt+1)) << 24;
+ pFont = (FontPtr)SecurityLookupIDByType(client, fid, RT_FONT,
+ SecurityReadAccess);
+ if (!pFont)
+ {
+ client->errorValue = fid;
+ err = BadFont;
+ /* restore pFont and fid for step 4 (described below) */
+ pFont = oldpFont;
+ fid = oldfid;
+
+ /* If we're in START_SLEEP mode, the following step
+ shortens the request... in the unlikely event that
+ the fid somehow becomes valid before we come through
+ again to actually execute the polytext, which would
+ then mess up our refcounting scheme badly. */
+ c->err = err;
+ c->endReq = c->pElt;
+
+ goto bail;
+ }
+
+ /* Step 3 (described below) on our new font */
+ if (client_state == START_SLEEP)
+ pFont->refcnt++;
+ else
+ {
+ if (pFont != c->pGC->font && c->pDraw)
+ {
+ ChangeGC( c->pGC, GCFont, &fid);
+ ValidateGC(c->pDraw, c->pGC);
+ if (c->reqType == X_PolyText8)
+ c->polyText = (PolyTextPtr) c->pGC->ops->PolyText8;
+ else
+ c->polyText = (PolyTextPtr) c->pGC->ops->PolyText16;
+ }
+
+ /* Undo the refcnt++ we performed when going to sleep */
+ if (client_state == SLEEPING)
+ (void)CloseFont(c->pGC->font, (Font)0);
+ }
+ c->pElt += FontShiftSize;
+ }
+ else /* print a string */
+ {
+ unsigned char *pNextElt;
+ pNextElt = c->pElt + TextEltHeader + (*c->pElt)*c->itemSize;
+ if ( pNextElt > c->endReq)
+ {
+ err = BadLength;
+ goto bail;
+ }
+ if (client_state == START_SLEEP)
+ {
+ c->pElt = pNextElt;
+ continue;
+ }
+ if (c->pDraw)
+ {
+ lgerr = LoadGlyphs(client, c->pGC->font, *c->pElt, c->itemSize,
+ c->pElt + TextEltHeader);
+ }
+ else lgerr = Successful;
+
+ if (lgerr == Suspended)
+ {
+ if (!c->slept) {
+ int len;
+ GC *pGC;
+ PTclosurePtr new_closure;
+
+ /* We're putting the client to sleep. We need to do a few things
+ to ensure successful and atomic-appearing execution of the
+ remainder of the request. First, copy the remainder of the
+ request into a safe malloc'd area. Second, create a scratch GC
+ to use for the remainder of the request. Third, mark all fonts
+ referenced in the remainder of the request to prevent their
+ deallocation. Fourth, make the original GC look like the
+ request has completed... set its font to the final font value
+ from this request. These GC manipulations are for the unlikely
+ (but possible) event that some other client is using the GC.
+ Steps 3 and 4 are performed by running this procedure through
+ the remainder of the request in a special no-render mode
+ indicated by client_state = START_SLEEP. */
+
+ /* Step 1 */
+ /* Allocate a malloc'd closure structure to replace
+ the local one we were passed */
+ new_closure = (PTclosurePtr) xalloc(sizeof(PTclosureRec));
+ if (!new_closure)
+ {
+ err = BadAlloc;
+ goto bail;
+ }
+ *new_closure = *c;
+ c = new_closure;
+
+ len = c->endReq - c->pElt;
+ c->data = (unsigned char *)xalloc(len);
+ if (!c->data)
+ {
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ memmove(c->data, c->pElt, len);
+ c->pElt = c->data;
+ c->endReq = c->pElt + len;
+
+ /* Step 2 */
+
+ pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
+ if (!pGC)
+ {
+ xfree(c->data);
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ if ((err = CopyGC(c->pGC, pGC, GCFunction |
+ GCPlaneMask | GCForeground |
+ GCBackground | GCFillStyle |
+ GCTile | GCStipple |
+ GCTileStipXOrigin |
+ GCTileStipYOrigin | GCFont |
+ GCSubwindowMode | GCClipXOrigin |
+ GCClipYOrigin | GCClipMask)) !=
+ Success)
+ {
+ FreeScratchGC(pGC);
+ xfree(c->data);
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ origGC = c->pGC;
+ c->pGC = pGC;
+ ValidateGC(c->pDraw, c->pGC);
+
+ c->slept = TRUE;
+ ClientSleep(client,
+ (ClientSleepProcPtr)doPolyText,
+ (pointer) c);
+
+ /* Set up to perform steps 3 and 4 */
+ client_state = START_SLEEP;
+ continue; /* on to steps 3 and 4 */
+ }
+ return TRUE;
+ }
+ else if (lgerr != Successful)
+ {
+ err = FontToXError(lgerr);
+ goto bail;
+ }
+ if (c->pDraw)
+ {
+ c->xorg += *((INT8 *)(c->pElt + 1)); /* must be signed */
+ c->xorg = (* c->polyText)(c->pDraw, c->pGC, c->xorg, c->yorg,
+ *c->pElt, c->pElt + TextEltHeader);
+ }
+ c->pElt = pNextElt;
+ }
+ }
+
+bail:
+
+ if (client_state == START_SLEEP)
+ {
+ /* Step 4 */
+ if (pFont != origGC->font)
+ {
+ ChangeGC(origGC, GCFont, &fid);
+ ValidateGC(c->pDraw, origGC);
+ }
+
+ /* restore pElt pointer for execution of remainder of the request */
+ c->pElt = c->data;
+ return TRUE;
+ }
+
+ if (c->err != Success) err = c->err;
+ if (err != Success && c->client != serverClient) {
+#ifdef PANORAMIX
+ if (noPanoramiXExtension || !c->pGC->pScreen->myNum)
+#endif
+ SendErrorToClient(c->client, c->reqType, 0, 0, err);
+ }
+ if (c->slept)
+ {
+ ClientWakeup(c->client);
+ ChangeGC(c->pGC, clearGCmask, clearGC);
+
+ /* Unreference the font from the scratch GC */
+ CloseFont(c->pGC->font, (Font)0);
+ c->pGC->font = NullFont;
+
+ FreeScratchGC(c->pGC);
+ xfree(c->data);
+ xfree(c);
+ }
+ return TRUE;
+}
+
+int
+PolyText(ClientPtr client, DrawablePtr pDraw, GC *pGC, unsigned char *pElt,
+ unsigned char *endReq, int xorg, int yorg, int reqType, XID did)
+{
+ PTclosureRec local_closure;
+
+ local_closure.pElt = pElt;
+ local_closure.endReq = endReq;
+ local_closure.client = client;
+ local_closure.pDraw = pDraw;
+ local_closure.xorg = xorg;
+ local_closure.yorg = yorg;
+ if ((local_closure.reqType = reqType) == X_PolyText8)
+ {
+ local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText8;
+ local_closure.itemSize = 1;
+ }
+ else
+ {
+ local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText16;
+ local_closure.itemSize = 2;
+ }
+ local_closure.pGC = pGC;
+ local_closure.did = did;
+ local_closure.err = Success;
+ local_closure.slept = FALSE;
+
+ (void) doPolyText(client, &local_closure);
+ return Success;
+}
+
+
+#undef TextEltHeader
+#undef FontShiftSize
+
+int
+doImageText(ClientPtr client, register ITclosurePtr c)
+{
+ int err = Success, lgerr; /* err is in X error, not font error, space */
+ FontPathElementPtr fpe;
+
+ if (client->clientGone)
+ {
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ err = Success;
+ goto bail;
+ }
+
+ /* Make sure our drawable hasn't disappeared while we slept. */
+ if (c->slept &&
+ c->pDraw &&
+ c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
+ RC_DRAWABLE, SecurityWriteAccess))
+ {
+ /* Our drawable has disappeared. Treat like client died... ask
+ the FPE code to clean up after client. */
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ err = Success;
+ goto bail;
+ }
+
+ lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, c->itemSize, c->data);
+ if (lgerr == Suspended)
+ {
+ if (!c->slept) {
+ GC *pGC;
+ unsigned char *data;
+ ITclosurePtr new_closure;
+
+ /* We're putting the client to sleep. We need to
+ save some state. Similar problem to that handled
+ in doPolyText, but much simpler because the
+ request structure is much simpler. */
+
+ new_closure = (ITclosurePtr) xalloc(sizeof(ITclosureRec));
+ if (!new_closure)
+ {
+ err = BadAlloc;
+ goto bail;
+ }
+ *new_closure = *c;
+ c = new_closure;
+
+ data = (unsigned char *)xalloc(c->nChars * c->itemSize);
+ if (!data)
+ {
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ memmove(data, c->data, c->nChars * c->itemSize);
+ c->data = data;
+
+ pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
+ if (!pGC)
+ {
+ xfree(c->data);
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ if ((err = CopyGC(c->pGC, pGC, GCFunction | GCPlaneMask |
+ GCForeground | GCBackground | GCFillStyle |
+ GCTile | GCStipple | GCTileStipXOrigin |
+ GCTileStipYOrigin | GCFont |
+ GCSubwindowMode | GCClipXOrigin |
+ GCClipYOrigin | GCClipMask)) != Success)
+ {
+ FreeScratchGC(pGC);
+ xfree(c->data);
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ c->pGC = pGC;
+ ValidateGC(c->pDraw, c->pGC);
+
+ c->slept = TRUE;
+ ClientSleep(client, (ClientSleepProcPtr)doImageText, (pointer) c);
+ }
+ return TRUE;
+ }
+ else if (lgerr != Successful)
+ {
+ err = FontToXError(lgerr);
+ goto bail;
+ }
+ if (c->pDraw)
+ {
+ (* c->imageText)(c->pDraw, c->pGC, c->xorg, c->yorg,
+ c->nChars, c->data);
+ }
+
+bail:
+
+ if (err != Success && c->client != serverClient) {
+ SendErrorToClient(c->client, c->reqType, 0, 0, err);
+ }
+ if (c->slept)
+ {
+ ClientWakeup(c->client);
+ ChangeGC(c->pGC, clearGCmask, clearGC);
+
+ /* Unreference the font from the scratch GC */
+ CloseFont(c->pGC->font, (Font)0);
+ c->pGC->font = NullFont;
+
+ FreeScratchGC(c->pGC);
+ xfree(c->data);
+ xfree(c);
+ }
+ return TRUE;
+}
+
+int
+ImageText(ClientPtr client, DrawablePtr pDraw, GC *pGC, int nChars,
+ unsigned char *data, int xorg, int yorg, int reqType, XID did)
+{
+ ITclosureRec local_closure;
+
+ local_closure.client = client;
+ local_closure.pDraw = pDraw;
+ local_closure.pGC = pGC;
+ local_closure.nChars = nChars;
+ local_closure.data = data;
+ local_closure.xorg = xorg;
+ local_closure.yorg = yorg;
+ if ((local_closure.reqType = reqType) == X_ImageText8)
+ {
+ local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText8;
+ local_closure.itemSize = 1;
+ }
+ else
+ {
+ local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText16;
+ local_closure.itemSize = 2;
+ }
+ local_closure.did = did;
+ local_closure.slept = FALSE;
+
+ (void) doImageText(client, &local_closure);
+ return Success;
+}
+
+
+/* does the necessary magic to figure out the fpe type */
+static int
+DetermineFPEType(char *pathname)
+{
+ int i;
+
+ for (i = 0; i < num_fpe_types; i++) {
+ if ((*fpe_functions[i].name_check) (pathname))
+ return i;
+ }
+ return -1;
+}
+
+
+static void
+FreeFontPath(FontPathElementPtr *list, int n, Bool force)
+{
+ int i;
+
+ for (i = 0; i < n; i++) {
+ if (force) {
+ /* Sanity check that all refcounts will be 0 by the time
+ we get to the end of the list. */
+ int found = 1; /* the first reference is us */
+ int j;
+ for (j = i+1; j < n; j++) {
+ if (list[j] == list[i])
+ found++;
+ }
+ if (list[i]->refcount != found) {
+ ErrorF("FreeFontPath: FPE \"%.*s\" refcount is %d, should be %d; fixing.\n",
+ list[i]->name_length, list[i]->name,
+ list[i]->refcount, found);
+ list[i]->refcount = found; /* ensure it will get freed */
+ }
+ }
+ FreeFPE(list[i]);
+ }
+ xfree((char *) list);
+}
+
+static FontPathElementPtr
+find_existing_fpe(FontPathElementPtr *list, int num, unsigned char *name, int len)
+{
+ FontPathElementPtr fpe;
+ int i;
+
+ for (i = 0; i < num; i++) {
+ fpe = list[i];
+ if (fpe->name_length == len && memcmp(name, fpe->name, len) == 0)
+ return fpe;
+ }
+ return (FontPathElementPtr) 0;
+}
+
+
+static int
+SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
+{
+ int i, err = 0;
+ int valid_paths = 0;
+ unsigned int len;
+ unsigned char *cp = paths;
+ FontPathElementPtr fpe = NULL, *fplist;
+
+ fplist = (FontPathElementPtr *)
+ xalloc(sizeof(FontPathElementPtr) * npaths);
+ if (!fplist) {
+ *bad = 0;
+ return BadAlloc;
+ }
+ for (i = 0; i < num_fpe_types; i++) {
+ if (fpe_functions[i].set_path_hook)
+ (*fpe_functions[i].set_path_hook) ();
+ }
+ for (i = 0; i < npaths; i++)
+ {
+ len = (unsigned int) (*cp++);
+
+ if (len == 0)
+ {
+ if (persist)
+ ErrorF ("Removing empty element from the valid list of fontpaths\n");
+ err = BadValue;
+ }
+ else
+ {
+ /* if it's already in our active list, just reset it */
+ /*
+ * note that this can miss FPE's in limbo -- may be worth catching
+ * them, though it'd muck up refcounting
+ */
+ fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len);
+ if (fpe)
+ {
+ err = (*fpe_functions[fpe->type].reset_fpe) (fpe);
+ if (err == Successful)
+ {
+ UseFPE(fpe);/* since it'll be decref'd later when freed
+ * from the old list */
+ }
+ else
+ fpe = 0;
+ }
+ /* if error or can't do it, act like it's a new one */
+ if (!fpe)
+ {
+ fpe = (FontPathElementPtr) xalloc(sizeof(FontPathElementRec));
+ if (!fpe)
+ {
+ err = BadAlloc;
+ goto bail;
+ }
+ fpe->name = (char *) xalloc(len + 1);
+ if (!fpe->name)
+ {
+ xfree(fpe);
+ err = BadAlloc;
+ goto bail;
+ }
+ fpe->refcount = 1;
+
+ strncpy(fpe->name, (char *) cp, (int) len);
+ fpe->name[len] = '\0';
+ fpe->name_length = len;
+ fpe->type = DetermineFPEType(fpe->name);
+ if (fpe->type == -1)
+ err = BadValue;
+ else
+ err = (*fpe_functions[fpe->type].init_fpe) (fpe);
+ if (err != Successful)
+ {
+ if (persist)
+ {
+ ErrorF("Could not init font path element %s, removing from list!\n",
+ fpe->name);
+ }
+ xfree (fpe->name);
+ xfree (fpe);
+ }
+ }
+ }
+ if (err != Successful)
+ {
+ if (!persist)
+ goto bail;
+ }
+ else
+ {
+ fplist[valid_paths++] = fpe;
+ }
+ cp += len;
+ }
+
+ FreeFontPath(font_path_elements, num_fpes, FALSE);
+ font_path_elements = fplist;
+ if (patternCache)
+ EmptyFontPatternCache(patternCache);
+ num_fpes = valid_paths;
+
+ return Success;
+bail:
+ *bad = i;
+ while (--valid_paths >= 0)
+ FreeFPE(fplist[valid_paths]);
+ xfree(fplist);
+ return FontToXError(err);
+}
+
+/* XXX -- do we need to pass error down to each renderer? */
+int
+SetFontPath(ClientPtr client, int npaths, unsigned char *paths, int *error)
+{
+ int err = Success;
+
+ if (npaths == 0) {
+ if (SetDefaultFontPath(defaultFontPath) != Success)
+ return BadValue;
+ } else {
+ err = SetFontPathElements(npaths, paths, error, FALSE);
+ }
+ return err;
+}
+
+int
+SetDefaultFontPath(char *path)
+{
+ unsigned char *cp,
+ *pp,
+ *nump,
+ *newpath;
+ int num = 1,
+ len,
+ err,
+ size = 0,
+ bad;
+
+ /* get enough for string, plus values -- use up commas */
+#ifdef NX_TRANS_SOCKET
+ len = strlen(_NXGetFontPath(path)) + 1;
+#else
+ len = strlen(path) + 1;
+#endif
+ nump = cp = newpath = (unsigned char *) ALLOCATE_LOCAL(len);
+ if (!newpath)
+ return BadAlloc;
+#ifdef NX_TRANS_SOCKET
+ pp = (unsigned char *) _NXGetFontPath(path);
+#else
+ pp = (unsigned char *) path;
+#endif
+ cp++;
+ while (*pp) {
+ if (*pp == ',') {
+ *nump = (unsigned char) size;
+ nump = cp++;
+ pp++;
+ num++;
+ size = 0;
+ } else {
+ *cp++ = *pp++;
+ size++;
+ }
+ }
+ *nump = (unsigned char) size;
+
+ err = SetFontPathElements(num, newpath, &bad, TRUE);
+
+ DEALLOCATE_LOCAL(newpath);
+
+ return err;
+}
+
+unsigned char *
+GetFontPath(int *count, int *length)
+{
+ int i;
+ unsigned char *c;
+ int len;
+ FontPathElementPtr fpe;
+
+ len = 0;
+ for (i = 0; i < num_fpes; i++) {
+ fpe = font_path_elements[i];
+ len += fpe->name_length + 1;
+ }
+ font_path_string = (unsigned char *) xrealloc(font_path_string, len);
+ if (!font_path_string)
+ return NULL;
+
+ c = font_path_string;
+ *length = 0;
+ for (i = 0; i < num_fpes; i++) {
+ fpe = font_path_elements[i];
+ *c = fpe->name_length;
+ *length += *c++;
+ memmove(c, fpe->name, fpe->name_length);
+ c += fpe->name_length;
+ }
+ *count = num_fpes;
+ return font_path_string;
+}
+
+int
+LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size, unsigned char *data)
+{
+ if (fpe_functions[pfont->fpe->type].load_glyphs)
+ return (*fpe_functions[pfont->fpe->type].load_glyphs)
+ (client, pfont, 0, nchars, item_size, data);
+ else
+ return Successful;
+}
+
+void
+DeleteClientFontStuff(ClientPtr client)
+{
+ int i;
+ FontPathElementPtr fpe;
+
+ for (i = 0; i < num_fpes; i++)
+ {
+ fpe = font_path_elements[i];
+ if (fpe_functions[fpe->type].client_died)
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ }
+}
+
+void
+InitFonts ()
+{
+ patternCache = MakeFontPatternCache();
+
+#ifndef KDRIVESERVER
+ if (screenInfo.numScreens > screenInfo.numVideoScreens) {
+ PrinterFontRegisterFpeFunctions();
+ FontFileCheckRegisterFpeFunctions();
+ check_fs_register_fpe_functions();
+ } else
+#endif
+ {
+#ifdef KDRIVESERVER
+ BuiltinRegisterFpeFunctions();
+#endif
+ FontFileRegisterFpeFunctions();
+#ifndef NOFONTSERVERACCESS
+ fs_register_fpe_functions();
+#endif
+ }
+}
+
+int
+GetDefaultPointSize ()
+{
+ return 120;
+}
+
+
+FontResolutionPtr
+GetClientResolutions (int *num)
+{
+ if (requestingClient && requestingClient->fontResFunc != NULL &&
+ !requestingClient->clientGone)
+ {
+ return (*requestingClient->fontResFunc)(requestingClient, num);
+ }
+ else {
+ static struct _FontResolution res;
+ ScreenPtr pScreen;
+
+ pScreen = screenInfo.screens[0];
+ res.x_resolution = (pScreen->width * 25.4) / pScreen->mmWidth;
+ /*
+ * XXX - we'll want this as long as bitmap instances are prevalent
+ so that we can match them from scalable fonts
+ */
+ if (res.x_resolution < 88)
+ res.x_resolution = 75;
+ else
+ res.x_resolution = 100;
+ res.y_resolution = (pScreen->height * 25.4) / pScreen->mmHeight;
+ if (res.y_resolution < 88)
+ res.y_resolution = 75;
+ else
+ res.y_resolution = 100;
+ res.point_size = 120;
+ *num = 1;
+ return &res;
+ }
+}
+
+/*
+ * returns the type index of the new fpe
+ *
+ * should be called (only once!) by each type of fpe when initialized
+ */
+
+int
+RegisterFPEFunctions(NameCheckFunc name_func,
+ InitFpeFunc init_func,
+ FreeFpeFunc free_func,
+ ResetFpeFunc reset_func,
+ OpenFontFunc open_func,
+ CloseFontFunc close_func,
+ ListFontsFunc list_func,
+ StartLfwiFunc start_lfwi_func,
+ NextLfwiFunc next_lfwi_func,
+ WakeupFpeFunc wakeup_func,
+ ClientDiedFunc client_died,
+ LoadGlyphsFunc load_glyphs,
+ StartLaFunc start_list_alias_func,
+ NextLaFunc next_list_alias_func,
+ SetPathFunc set_path_func)
+{
+ FPEFunctions *new;
+
+ /* grow the list */
+ new = (FPEFunctions *) xrealloc(fpe_functions,
+ (num_fpe_types + 1) * sizeof(FPEFunctions));
+ if (!new)
+ return -1;
+ fpe_functions = new;
+
+ fpe_functions[num_fpe_types].name_check = name_func;
+ fpe_functions[num_fpe_types].open_font = open_func;
+ fpe_functions[num_fpe_types].close_font = close_func;
+ fpe_functions[num_fpe_types].wakeup_fpe = wakeup_func;
+ fpe_functions[num_fpe_types].list_fonts = list_func;
+ fpe_functions[num_fpe_types].start_list_fonts_with_info =
+ start_lfwi_func;
+ fpe_functions[num_fpe_types].list_next_font_with_info =
+ next_lfwi_func;
+ fpe_functions[num_fpe_types].init_fpe = init_func;
+ fpe_functions[num_fpe_types].free_fpe = free_func;
+ fpe_functions[num_fpe_types].reset_fpe = reset_func;
+ fpe_functions[num_fpe_types].client_died = client_died;
+ fpe_functions[num_fpe_types].load_glyphs = load_glyphs;
+ fpe_functions[num_fpe_types].start_list_fonts_and_aliases =
+ start_list_alias_func;
+ fpe_functions[num_fpe_types].list_next_font_or_alias =
+ next_list_alias_func;
+ fpe_functions[num_fpe_types].set_path_hook = set_path_func;
+
+ return num_fpe_types++;
+}
+
+void
+FreeFonts()
+{
+ if (patternCache) {
+ FreeFontPatternCache(patternCache);
+ patternCache = 0;
+ }
+ FreeFontPath(font_path_elements, num_fpes, TRUE);
+ font_path_elements = 0;
+ num_fpes = 0;
+ xfree(fpe_functions);
+ num_fpe_types = 0;
+ fpe_functions = (FPEFunctions *) 0;
+}
+
+/* convenience functions for FS interface */
+
+FontPtr
+find_old_font(XID id)
+{
+ return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE,
+ SecurityUnknownAccess);
+}
+
+Font
+GetNewFontClientID()
+{
+ return FakeClientID(0);
+}
+
+int
+StoreFontClientFont(FontPtr pfont, Font id)
+{
+ return AddResource(id, RT_NONE, (pointer) pfont);
+}
+
+void
+DeleteFontClientID(Font id)
+{
+ FreeResource(id, RT_NONE);
+}
+
+int
+client_auth_generation(ClientPtr client)
+{
+ return 0;
+}
+
+static int fs_handlers_installed = 0;
+static unsigned int last_server_gen;
+
+int
+init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler)
+{
+ /* if server has reset, make sure the b&w handlers are reinstalled */
+ if (last_server_gen < serverGeneration) {
+ last_server_gen = serverGeneration;
+ fs_handlers_installed = 0;
+ }
+ if (fs_handlers_installed == 0) {
+
+#ifdef DEBUG
+ fprintf(stderr, "adding FS b & w handlers\n");
+#endif
+
+ if (!RegisterBlockAndWakeupHandlers(block_handler,
+ FontWakeup, (pointer) 0))
+ return AllocError;
+ fs_handlers_installed++;
+ }
+ QueueFontWakeup(fpe);
+ return Successful;
+}
+
+void
+remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all)
+{
+ if (all) {
+ /* remove the handlers if no one else is using them */
+ if (--fs_handlers_installed == 0) {
+
+#ifdef DEBUG
+ fprintf(stderr, "removing FS b & w handlers\n");
+#endif
+
+ RemoveBlockAndWakeupHandlers(block_handler, FontWakeup,
+ (pointer) 0);
+ }
+ }
+ RemoveFontWakeup(fpe);
+}
+
+#ifdef DEBUG
+#define GLWIDTHBYTESPADDED(bits,nbytes) \
+ ((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \
+ :(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \
+ :(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \
+ :(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \
+ : 0)
+
+#define GLYPH_SIZE(ch, nbytes) \
+ GLWIDTHBYTESPADDED((ch)->metrics.rightSideBearing - \
+ (ch)->metrics.leftSideBearing, (nbytes))
+void
+dump_char_ascii(CharInfoPtr cip)
+{
+ int r,
+ l;
+ int bpr;
+ int byte;
+ static unsigned maskTab[] = {
+ (1 << 7), (1 << 6), (1 << 5), (1 << 4),
+ (1 << 3), (1 << 2), (1 << 1), (1 << 0),
+ };
+
+ bpr = GLYPH_SIZE(cip, 4);
+ for (r = 0; r < (cip->metrics.ascent + cip->metrics.descent); r++) {
+ pointer row = (pointer) cip->bits + r * bpr;
+
+ byte = 0;
+ for (l = 0; l <= (cip->metrics.rightSideBearing -
+ cip->metrics.leftSideBearing); l++) {
+ if (maskTab[l & 7] & row[l >> 3])
+ putchar('X');
+ else
+ putchar('.');
+ }
+ putchar('\n');
+ }
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/dix/dixfonts.c.X.original b/nx-X11/programs/Xserver/dix/dixfonts.c.X.original
new file mode 100644
index 000000000..9de998417
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/dixfonts.c.X.original
@@ -0,0 +1,2143 @@
+/* $XdotOrg: xc/programs/Xserver/dix/dixfonts.c,v 1.8 2005/07/03 08:53:38 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/dix/dixfonts.c,v 3.28 2003/11/08 02:02:03 dawes Exp $ */
+/************************************************************************
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+************************************************************************/
+/* The panoramix components contained the following notice */
+/*
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+/* $Xorg: dixfonts.c,v 1.4 2000/08/17 19:48:18 cpqbld Exp $ */
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "resource.h"
+#include "dixstruct.h"
+#include "cursorstr.h"
+#include "misc.h"
+#include "opaque.h"
+#include "dixfontstr.h"
+#include "closestr.h"
+
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#endif
+
+#ifdef LBX
+#include "lbxserve.h"
+#endif
+
+#ifdef XF86BIGFONT
+#define _XF86BIGFONT_SERVER_
+#include <X11/extensions/xf86bigfont.h>
+#endif
+
+#define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics
+
+extern pointer fosNaturalParams;
+extern FontPtr defaultFont;
+
+static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0;
+static int num_fpes = 0;
+FPEFunctions *fpe_functions = (FPEFunctions *) 0;
+static int num_fpe_types = 0;
+
+static unsigned char *font_path_string;
+
+static int num_slept_fpes = 0;
+static int size_slept_fpes = 0;
+static FontPathElementPtr *slept_fpes = (FontPathElementPtr *) 0;
+static FontPatternCachePtr patternCache;
+
+int
+FontToXError(err)
+ int err;
+{
+ switch (err) {
+ case Successful:
+ return Success;
+ case AllocError:
+ return BadAlloc;
+ case BadFontName:
+ return BadName;
+ case BadFontPath:
+ case BadFontFormat: /* is there something better? */
+ case BadCharRange:
+ return BadValue;
+ default:
+ return err;
+ }
+}
+
+
+/*
+ * adding RT_FONT prevents conflict with default cursor font
+ */
+Bool
+SetDefaultFont(char *defaultfontname)
+{
+ int err;
+ FontPtr pf;
+ XID fid;
+
+ fid = FakeClientID(0);
+ err = OpenFont(serverClient, fid, FontLoadAll | FontOpenSync,
+ (unsigned) strlen(defaultfontname), defaultfontname);
+ if (err != Success)
+ return FALSE;
+ pf = (FontPtr) LookupIDByType(fid, RT_FONT);
+ if (pf == (FontPtr) NULL)
+ return FALSE;
+ defaultFont = pf;
+ return TRUE;
+}
+
+/*
+ * note that the font wakeup queue is not refcounted. this is because
+ * an fpe needs to be added when it's inited, and removed when it's finally
+ * freed, in order to handle any data that isn't requested, like FS events.
+ *
+ * since the only thing that should call these routines is the renderer's
+ * init_fpe() and free_fpe(), there shouldn't be any problem in using
+ * freed data.
+ */
+void
+QueueFontWakeup(FontPathElementPtr fpe)
+{
+ int i;
+ FontPathElementPtr *new;
+
+ for (i = 0; i < num_slept_fpes; i++) {
+ if (slept_fpes[i] == fpe) {
+
+#ifdef DEBUG
+ fprintf(stderr, "re-queueing fpe wakeup\n");
+#endif
+
+ return;
+ }
+ }
+ if (num_slept_fpes == size_slept_fpes) {
+ new = (FontPathElementPtr *)
+ xrealloc(slept_fpes,
+ sizeof(FontPathElementPtr) * (size_slept_fpes + 4));
+ if (!new)
+ return;
+ slept_fpes = new;
+ size_slept_fpes += 4;
+ }
+ slept_fpes[num_slept_fpes] = fpe;
+ num_slept_fpes++;
+}
+
+void
+RemoveFontWakeup(FontPathElementPtr fpe)
+{
+ int i,
+ j;
+
+ for (i = 0; i < num_slept_fpes; i++) {
+ if (slept_fpes[i] == fpe) {
+ for (j = i; j < num_slept_fpes; j++) {
+ slept_fpes[j] = slept_fpes[j + 1];
+ }
+ num_slept_fpes--;
+ return;
+ }
+ }
+}
+
+void
+FontWakeup(pointer data, int count, pointer LastSelectMask)
+{
+ int i;
+ FontPathElementPtr fpe;
+
+ if (count < 0)
+ return;
+ /* wake up any fpe's that may be waiting for information */
+ for (i = 0; i < num_slept_fpes; i++) {
+ fpe = slept_fpes[i];
+ (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask);
+ }
+}
+
+/* XXX -- these two funcs may want to be broken into macros */
+static void
+UseFPE(FontPathElementPtr fpe)
+{
+ fpe->refcount++;
+}
+
+static void
+FreeFPE (FontPathElementPtr fpe)
+{
+ fpe->refcount--;
+ if (fpe->refcount == 0) {
+ (*fpe_functions[fpe->type].free_fpe) (fpe);
+ xfree(fpe->name);
+ xfree(fpe);
+ }
+}
+
+static Bool
+doOpenFont(ClientPtr client, OFclosurePtr c)
+{
+ FontPtr pfont = NullFont;
+ FontPathElementPtr fpe = NULL;
+ ScreenPtr pScr;
+ int err = Successful;
+ int i;
+ char *alias,
+ *newname;
+ int newlen;
+ int aliascount = 20;
+ /*
+ * Decide at runtime what FontFormat to use.
+ */
+ Mask FontFormat =
+
+ ((screenInfo.imageByteOrder == LSBFirst) ?
+ BitmapFormatByteOrderLSB : BitmapFormatByteOrderMSB) |
+
+ ((screenInfo.bitmapBitOrder == LSBFirst) ?
+ BitmapFormatBitOrderLSB : BitmapFormatBitOrderMSB) |
+
+ BitmapFormatImageRectMin |
+
+#if GLYPHPADBYTES == 1
+ BitmapFormatScanlinePad8 |
+#endif
+
+#if GLYPHPADBYTES == 2
+ BitmapFormatScanlinePad16 |
+#endif
+
+#if GLYPHPADBYTES == 4
+ BitmapFormatScanlinePad32 |
+#endif
+
+#if GLYPHPADBYTES == 8
+ BitmapFormatScanlinePad64 |
+#endif
+
+ BitmapFormatScanlineUnit8;
+
+ if (client->clientGone)
+ {
+ if (c->current_fpe < c->num_fpes)
+ {
+ fpe = c->fpe_list[c->current_fpe];
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ }
+ err = Successful;
+ goto bail;
+ }
+ while (c->current_fpe < c->num_fpes) {
+ fpe = c->fpe_list[c->current_fpe];
+ err = (*fpe_functions[fpe->type].open_font)
+ ((pointer) client, fpe, c->flags,
+ c->fontname, c->fnamelen, FontFormat,
+ BitmapFormatMaskByte |
+ BitmapFormatMaskBit |
+ BitmapFormatMaskImageRectangle |
+ BitmapFormatMaskScanLinePad |
+ BitmapFormatMaskScanLineUnit,
+ c->fontid, &pfont, &alias,
+ c->non_cachable_font && c->non_cachable_font->fpe == fpe ?
+ c->non_cachable_font :
+ (FontPtr)0);
+
+ if (err == FontNameAlias && alias) {
+ newlen = strlen(alias);
+ newname = (char *) xrealloc(c->fontname, newlen);
+ if (!newname) {
+ err = AllocError;
+ break;
+ }
+ memmove(newname, alias, newlen);
+ c->fontname = newname;
+ c->fnamelen = newlen;
+ c->current_fpe = 0;
+ if (--aliascount <= 0)
+ break;
+ continue;
+ }
+ if (err == BadFontName) {
+ c->current_fpe++;
+ continue;
+ }
+ if (err == Suspended) {
+ if (!c->slept) {
+ c->slept = TRUE;
+ ClientSleep(client, (ClientSleepProcPtr)doOpenFont, (pointer) c);
+ }
+ return TRUE;
+ }
+ break;
+ }
+
+ if (err != Successful)
+ goto bail;
+ if (!pfont) {
+ err = BadFontName;
+ goto bail;
+ }
+ if (!pfont->fpe)
+ pfont->fpe = fpe;
+ pfont->refcnt++;
+ if (pfont->refcnt == 1) {
+ UseFPE(pfont->fpe);
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ pScr = screenInfo.screens[i];
+ if (pScr->RealizeFont)
+ {
+ if (!(*pScr->RealizeFont) (pScr, pfont))
+ {
+ CloseFont (pfont, (Font) 0);
+ err = AllocError;
+ goto bail;
+ }
+ }
+ }
+ }
+ if (!AddResource(c->fontid, RT_FONT, (pointer) pfont)) {
+ err = AllocError;
+ goto bail;
+ }
+ if (patternCache && pfont != c->non_cachable_font)
+ CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen,
+ pfont);
+bail:
+ if (err != Successful && c->client != serverClient) {
+ SendErrorToClient(c->client, X_OpenFont, 0,
+ c->fontid, FontToXError(err));
+ }
+ if (c->slept)
+ ClientWakeup(c->client);
+ for (i = 0; i < c->num_fpes; i++) {
+ FreeFPE(c->fpe_list[i]);
+ }
+ xfree(c->fpe_list);
+ xfree(c->fontname);
+ xfree(c);
+ return TRUE;
+}
+
+int
+OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontname)
+{
+ OFclosurePtr c;
+ int i;
+ FontPtr cached = (FontPtr)0;
+
+#ifdef FONTDEBUG
+ char *f;
+ f = (char *)xalloc(lenfname + 1);
+ memmove(f, pfontname, lenfname);
+ f[lenfname] = '\0';
+ ErrorF("OpenFont: fontname is \"%s\"\n", f);
+ xfree(f);
+#endif
+ if (!lenfname || lenfname > XLFDMAXFONTNAMELEN)
+ return BadName;
+ if (patternCache)
+ {
+
+ /*
+ ** Check name cache. If we find a cached version of this font that
+ ** is cachable, immediately satisfy the request with it. If we find
+ ** a cached version of this font that is non-cachable, we do not
+ ** satisfy the request with it. Instead, we pass the FontPtr to the
+ ** FPE's open_font code (the fontfile FPE in turn passes the
+ ** information to the rasterizer; the fserve FPE ignores it).
+ **
+ ** Presumably, the font is marked non-cachable because the FPE has
+ ** put some licensing restrictions on it. If the FPE, using
+ ** whatever logic it relies on, determines that it is willing to
+ ** share this existing font with the client, then it has the option
+ ** to return the FontPtr we passed it as the newly-opened font.
+ ** This allows the FPE to exercise its licensing logic without
+ ** having to create another instance of a font that already exists.
+ */
+
+ cached = FindCachedFontPattern(patternCache, pfontname, lenfname);
+ if (cached && cached->info.cachable)
+ {
+ if (!AddResource(fid, RT_FONT, (pointer) cached))
+ return BadAlloc;
+ cached->refcnt++;
+ return Success;
+ }
+ }
+ c = (OFclosurePtr) xalloc(sizeof(OFclosureRec));
+ if (!c)
+ return BadAlloc;
+ c->fontname = (char *) xalloc(lenfname);
+ c->origFontName = pfontname;
+ c->origFontNameLen = lenfname;
+ if (!c->fontname) {
+ xfree(c);
+ return BadAlloc;
+ }
+ /*
+ * copy the current FPE list, so that if it gets changed by another client
+ * while we're blocking, the request still appears atomic
+ */
+ c->fpe_list = (FontPathElementPtr *)
+ xalloc(sizeof(FontPathElementPtr) * num_fpes);
+ if (!c->fpe_list) {
+ xfree(c->fontname);
+ xfree(c);
+ return BadAlloc;
+ }
+ memmove(c->fontname, pfontname, lenfname);
+ for (i = 0; i < num_fpes; i++) {
+ c->fpe_list[i] = font_path_elements[i];
+ UseFPE(c->fpe_list[i]);
+ }
+ c->client = client;
+ c->fontid = fid;
+ c->current_fpe = 0;
+ c->num_fpes = num_fpes;
+ c->fnamelen = lenfname;
+ c->slept = FALSE;
+ c->flags = flags;
+ c->non_cachable_font = cached;
+
+ (void) doOpenFont(client, c);
+ return Success;
+}
+
+/**
+ * Decrement font's ref count, and free storage if ref count equals zero
+ *
+ * \param value must conform to DeleteType
+ */
+int
+CloseFont(pointer value, XID fid)
+{
+ int nscr;
+ ScreenPtr pscr;
+ FontPathElementPtr fpe;
+ FontPtr pfont = (FontPtr)value;
+
+ if (pfont == NullFont)
+ return (Success);
+ if (--pfont->refcnt == 0) {
+ if (patternCache)
+ RemoveCachedFontPattern (patternCache, pfont);
+ /*
+ * since the last reference is gone, ask each screen to free any
+ * storage it may have allocated locally for it.
+ */
+ for (nscr = 0; nscr < screenInfo.numScreens; nscr++) {
+ pscr = screenInfo.screens[nscr];
+ if (pscr->UnrealizeFont)
+ (*pscr->UnrealizeFont) (pscr, pfont);
+ }
+ if (pfont == defaultFont)
+ defaultFont = NULL;
+#ifdef LBX
+ LbxFreeFontTag(pfont);
+#endif
+#ifdef XF86BIGFONT
+ XF86BigfontFreeFontShm(pfont);
+#endif
+ fpe = pfont->fpe;
+ (*fpe_functions[fpe->type].close_font) (fpe, pfont);
+ FreeFPE(fpe);
+ }
+ return (Success);
+}
+
+
+/***====================================================================***/
+
+/**
+ * Sets up pReply as the correct QueryFontReply for pFont with the first
+ * nProtoCCIStructs char infos.
+ *
+ * \param pReply caller must allocate this storage
+ */
+void
+QueryFont(FontPtr pFont, xQueryFontReply *pReply, int nProtoCCIStructs)
+{
+ FontPropPtr pFP;
+ int r,
+ c,
+ i;
+ xFontProp *prFP;
+ xCharInfo *prCI;
+ xCharInfo *charInfos[256];
+ unsigned char chars[512];
+ int ninfos;
+ unsigned long ncols;
+ unsigned long count;
+
+ /* pr->length set in dispatch */
+ pReply->minCharOrByte2 = pFont->info.firstCol;
+ pReply->defaultChar = pFont->info.defaultCh;
+ pReply->maxCharOrByte2 = pFont->info.lastCol;
+ pReply->drawDirection = pFont->info.drawDirection;
+ pReply->allCharsExist = pFont->info.allExist;
+ pReply->minByte1 = pFont->info.firstRow;
+ pReply->maxByte1 = pFont->info.lastRow;
+ pReply->fontAscent = pFont->info.fontAscent;
+ pReply->fontDescent = pFont->info.fontDescent;
+
+ pReply->minBounds = pFont->info.ink_minbounds;
+ pReply->maxBounds = pFont->info.ink_maxbounds;
+
+ pReply->nFontProps = pFont->info.nprops;
+ pReply->nCharInfos = nProtoCCIStructs;
+
+ for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) (&pReply[1]);
+ i < pFont->info.nprops;
+ i++, pFP++, prFP++) {
+ prFP->name = pFP->name;
+ prFP->value = pFP->value;
+ }
+
+ ninfos = 0;
+ ncols = (unsigned long) (pFont->info.lastCol - pFont->info.firstCol + 1);
+ prCI = (xCharInfo *) (prFP);
+ for (r = pFont->info.firstRow;
+ ninfos < nProtoCCIStructs && r <= (int)pFont->info.lastRow;
+ r++) {
+ i = 0;
+ for (c = pFont->info.firstCol; c <= (int)pFont->info.lastCol; c++) {
+ chars[i++] = r;
+ chars[i++] = c;
+ }
+ (*pFont->get_metrics) (pFont, ncols, chars,
+ TwoD16Bit, &count, charInfos);
+ i = 0;
+ for (i = 0; i < (int) count && ninfos < nProtoCCIStructs; i++) {
+ *prCI = *charInfos[i];
+ prCI++;
+ ninfos++;
+ }
+ }
+ return;
+}
+
+static Bool
+doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
+{
+ FontPathElementPtr fpe;
+ int err = Successful;
+ FontNamesPtr names = NULL;
+ char *name, *resolved=NULL;
+ int namelen, resolvedlen;
+ int nnames;
+ int stringLens;
+ int i;
+ xListFontsReply reply;
+ char *bufptr;
+ char *bufferStart;
+ int aliascount = 0;
+
+ if (client->clientGone)
+ {
+ if (c->current.current_fpe < c->num_fpes)
+ {
+ fpe = c->fpe_list[c->current.current_fpe];
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ }
+ err = Successful;
+ goto bail;
+ }
+
+ if (!c->current.patlen)
+ goto finish;
+
+ while (c->current.current_fpe < c->num_fpes) {
+ fpe = c->fpe_list[c->current.current_fpe];
+ err = Successful;
+
+ if (!fpe_functions[fpe->type].start_list_fonts_and_aliases)
+ {
+ /* This FPE doesn't support/require list_fonts_and_aliases */
+
+ err = (*fpe_functions[fpe->type].list_fonts)
+ ((pointer) c->client, fpe, c->current.pattern,
+ c->current.patlen, c->current.max_names - c->names->nnames,
+ c->names);
+
+ if (err == Suspended) {
+ if (!c->slept) {
+ c->slept = TRUE;
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsAndAliases,
+ (pointer) c);
+ }
+ return TRUE;
+ }
+
+ err = BadFontName;
+ }
+ else
+ {
+ /* Start of list_fonts_and_aliases functionality. Modeled
+ after list_fonts_with_info in that it resolves aliases,
+ except that the information collected from FPEs is just
+ names, not font info. Each list_next_font_or_alias()
+ returns either a name into name/namelen or an alias into
+ name/namelen and its target name into resolved/resolvedlen.
+ The code at this level then resolves the alias by polling
+ the FPEs. */
+
+ if (!c->current.list_started) {
+ err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases)
+ ((pointer) c->client, fpe, c->current.pattern,
+ c->current.patlen, c->current.max_names - c->names->nnames,
+ &c->current.private);
+ if (err == Suspended) {
+ if (!c->slept) {
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsAndAliases,
+ (pointer) c);
+ c->slept = TRUE;
+ }
+ return TRUE;
+ }
+ if (err == Successful)
+ c->current.list_started = TRUE;
+ }
+ if (err == Successful) {
+ char *tmpname;
+ name = 0;
+ err = (*fpe_functions[fpe->type].list_next_font_or_alias)
+ ((pointer) c->client, fpe, &name, &namelen, &tmpname,
+ &resolvedlen, c->current.private);
+ if (err == Suspended) {
+ if (!c->slept) {
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsAndAliases,
+ (pointer) c);
+ c->slept = TRUE;
+ }
+ return TRUE;
+ }
+ if (err == FontNameAlias) {
+ if (resolved) xfree(resolved);
+ resolved = (char *) xalloc(resolvedlen + 1);
+ if (resolved)
+ memmove(resolved, tmpname, resolvedlen + 1);
+ }
+ }
+
+ if (err == Successful)
+ {
+ if (c->haveSaved)
+ {
+ if (c->savedName)
+ (void)AddFontNamesName(c->names, c->savedName,
+ c->savedNameLen);
+ }
+ else
+ (void)AddFontNamesName(c->names, name, namelen);
+ }
+
+ /*
+ * When we get an alias back, save our state and reset back to
+ * the start of the FPE looking for the specified name. As
+ * soon as a real font is found for the alias, pop back to the
+ * old state
+ */
+ else if (err == FontNameAlias) {
+ char tmp_pattern[XLFDMAXFONTNAMELEN];
+ /*
+ * when an alias recurses, we need to give
+ * the last FPE a chance to clean up; so we call
+ * it again, and assume that the error returned
+ * is BadFontName, indicating the alias resolution
+ * is complete.
+ */
+ memmove(tmp_pattern, resolved, resolvedlen);
+ if (c->haveSaved)
+ {
+ char *tmpname;
+ int tmpnamelen;
+
+ tmpname = 0;
+ (void) (*fpe_functions[fpe->type].list_next_font_or_alias)
+ ((pointer) c->client, fpe, &tmpname, &tmpnamelen,
+ &tmpname, &tmpnamelen, c->current.private);
+ if (--aliascount <= 0)
+ {
+ err = BadFontName;
+ goto ContBadFontName;
+ }
+ }
+ else
+ {
+ c->saved = c->current;
+ c->haveSaved = TRUE;
+ if (c->savedName)
+ xfree(c->savedName);
+ c->savedName = (char *)xalloc(namelen + 1);
+ if (c->savedName)
+ memmove(c->savedName, name, namelen + 1);
+ c->savedNameLen = namelen;
+ aliascount = 20;
+ }
+ memmove(c->current.pattern, tmp_pattern, resolvedlen);
+ c->current.patlen = resolvedlen;
+ c->current.max_names = c->names->nnames + 1;
+ c->current.current_fpe = -1;
+ c->current.private = 0;
+ err = BadFontName;
+ }
+ }
+ /*
+ * At the end of this FPE, step to the next. If we've finished
+ * processing an alias, pop state back. If we've collected enough
+ * font names, quit.
+ */
+ if (err == BadFontName) {
+ ContBadFontName: ;
+ c->current.list_started = FALSE;
+ c->current.current_fpe++;
+ err = Successful;
+ if (c->haveSaved)
+ {
+ if (c->names->nnames == c->current.max_names ||
+ c->current.current_fpe == c->num_fpes) {
+ c->haveSaved = FALSE;
+ c->current = c->saved;
+ /* Give the saved namelist a chance to clean itself up */
+ continue;
+ }
+ }
+ if (c->names->nnames == c->current.max_names)
+ break;
+ }
+ }
+
+ /*
+ * send the reply
+ */
+ if (err != Successful) {
+ SendErrorToClient(client, X_ListFonts, 0, 0, FontToXError(err));
+ goto bail;
+ }
+
+finish:
+
+ names = c->names;
+ nnames = names->nnames;
+ client = c->client;
+ stringLens = 0;
+ for (i = 0; i < nnames; i++)
+ stringLens += (names->length[i] <= 255) ? names->length[i] : 0;
+
+ reply.type = X_Reply;
+ reply.length = (stringLens + nnames + 3) >> 2;
+ reply.nFonts = nnames;
+ reply.sequenceNumber = client->sequence;
+
+ bufptr = bufferStart = (char *) ALLOCATE_LOCAL(reply.length << 2);
+
+ if (!bufptr && reply.length) {
+ SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc);
+ goto bail;
+ }
+ /*
+ * since WriteToClient long word aligns things, copy to temp buffer and
+ * write all at once
+ */
+ for (i = 0; i < nnames; i++) {
+ if (names->length[i] > 255)
+ reply.nFonts--;
+ else
+ {
+ *bufptr++ = names->length[i];
+ memmove( bufptr, names->names[i], names->length[i]);
+ bufptr += names->length[i];
+ }
+ }
+ nnames = reply.nFonts;
+ reply.length = (stringLens + nnames + 3) >> 2;
+ client->pSwapReplyFunc = ReplySwapVector[X_ListFonts];
+ WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply);
+ (void) WriteToClient(client, stringLens + nnames, bufferStart);
+ DEALLOCATE_LOCAL(bufferStart);
+
+bail:
+ if (c->slept)
+ ClientWakeup(client);
+ for (i = 0; i < c->num_fpes; i++)
+ FreeFPE(c->fpe_list[i]);
+ xfree(c->fpe_list);
+ if (c->savedName) xfree(c->savedName);
+ FreeFontNames(names);
+ xfree(c);
+ if (resolved) xfree(resolved);
+ return TRUE;
+}
+
+int
+ListFonts(ClientPtr client, unsigned char *pattern, unsigned length,
+ unsigned max_names)
+{
+ int i;
+ LFclosurePtr c;
+
+ /*
+ * The right error to return here would be BadName, however the
+ * specification does not allow for a Name error on this request.
+ * Perhaps a better solution would be to return a nil list, i.e.
+ * a list containing zero fontnames.
+ */
+ if (length > XLFDMAXFONTNAMELEN)
+ return BadAlloc;
+
+ if (!(c = (LFclosurePtr) xalloc(sizeof *c)))
+ return BadAlloc;
+ c->fpe_list = (FontPathElementPtr *)
+ xalloc(sizeof(FontPathElementPtr) * num_fpes);
+ if (!c->fpe_list) {
+ xfree(c);
+ return BadAlloc;
+ }
+ c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100);
+ if (!c->names)
+ {
+ xfree(c->fpe_list);
+ xfree(c);
+ return BadAlloc;
+ }
+ memmove( c->current.pattern, pattern, length);
+ for (i = 0; i < num_fpes; i++) {
+ c->fpe_list[i] = font_path_elements[i];
+ UseFPE(c->fpe_list[i]);
+ }
+ c->client = client;
+ c->num_fpes = num_fpes;
+ c->current.patlen = length;
+ c->current.current_fpe = 0;
+ c->current.max_names = max_names;
+ c->current.list_started = FALSE;
+ c->current.private = 0;
+ c->haveSaved = FALSE;
+ c->slept = FALSE;
+ c->savedName = 0;
+ doListFontsAndAliases(client, c);
+ return Success;
+}
+
+int
+doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
+{
+ FontPathElementPtr fpe;
+ int err = Successful;
+ char *name;
+ int namelen;
+ int numFonts;
+ FontInfoRec fontInfo,
+ *pFontInfo;
+ xListFontsWithInfoReply *reply;
+ int length;
+ xFontProp *pFP;
+ int i;
+ int aliascount = 0;
+ xListFontsWithInfoReply finalReply;
+
+ if (client->clientGone)
+ {
+ if (c->current.current_fpe < c->num_fpes)
+ {
+ fpe = c->fpe_list[c->current.current_fpe];
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ }
+ err = Successful;
+ goto bail;
+ }
+ client->pSwapReplyFunc = ReplySwapVector[X_ListFontsWithInfo];
+ if (!c->current.patlen)
+ goto finish;
+ while (c->current.current_fpe < c->num_fpes)
+ {
+ fpe = c->fpe_list[c->current.current_fpe];
+ err = Successful;
+ if (!c->current.list_started)
+ {
+ err = (*fpe_functions[fpe->type].start_list_fonts_with_info)
+ (client, fpe, c->current.pattern, c->current.patlen,
+ c->current.max_names, &c->current.private);
+ if (err == Suspended)
+ {
+ if (!c->slept)
+ {
+ ClientSleep(client, (ClientSleepProcPtr)doListFontsWithInfo, c);
+ c->slept = TRUE;
+ }
+ return TRUE;
+ }
+ if (err == Successful)
+ c->current.list_started = TRUE;
+ }
+ if (err == Successful)
+ {
+ name = 0;
+ pFontInfo = &fontInfo;
+ err = (*fpe_functions[fpe->type].list_next_font_with_info)
+ (client, fpe, &name, &namelen, &pFontInfo,
+ &numFonts, c->current.private);
+ if (err == Suspended)
+ {
+ if (!c->slept)
+ {
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsWithInfo,
+ c);
+ c->slept = TRUE;
+ }
+ return TRUE;
+ }
+ }
+ /*
+ * When we get an alias back, save our state and reset back to the
+ * start of the FPE looking for the specified name. As soon as a real
+ * font is found for the alias, pop back to the old state
+ */
+ if (err == FontNameAlias)
+ {
+ /*
+ * when an alias recurses, we need to give
+ * the last FPE a chance to clean up; so we call
+ * it again, and assume that the error returned
+ * is BadFontName, indicating the alias resolution
+ * is complete.
+ */
+ if (c->haveSaved)
+ {
+ char *tmpname;
+ int tmpnamelen;
+ FontInfoPtr tmpFontInfo;
+
+ tmpname = 0;
+ tmpFontInfo = &fontInfo;
+ (void) (*fpe_functions[fpe->type].list_next_font_with_info)
+ (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo,
+ &numFonts, c->current.private);
+ if (--aliascount <= 0)
+ {
+ err = BadFontName;
+ goto ContBadFontName;
+ }
+ }
+ else
+ {
+ c->saved = c->current;
+ c->haveSaved = TRUE;
+ c->savedNumFonts = numFonts;
+ if (c->savedName)
+ xfree(c->savedName);
+ c->savedName = (char *)xalloc(namelen + 1);
+ if (c->savedName)
+ memmove(c->savedName, name, namelen + 1);
+ aliascount = 20;
+ }
+ memmove(c->current.pattern, name, namelen);
+ c->current.patlen = namelen;
+ c->current.max_names = 1;
+ c->current.current_fpe = 0;
+ c->current.private = 0;
+ c->current.list_started = FALSE;
+ }
+ /*
+ * At the end of this FPE, step to the next. If we've finished
+ * processing an alias, pop state back. If we've sent enough font
+ * names, quit. Always wait for BadFontName to let the FPE
+ * have a chance to clean up.
+ */
+ else if (err == BadFontName)
+ {
+ ContBadFontName: ;
+ c->current.list_started = FALSE;
+ c->current.current_fpe++;
+ err = Successful;
+ if (c->haveSaved)
+ {
+ if (c->current.max_names == 0 ||
+ c->current.current_fpe == c->num_fpes)
+ {
+ c->haveSaved = FALSE;
+ c->saved.max_names -= (1 - c->current.max_names);
+ c->current = c->saved;
+ }
+ }
+ else if (c->current.max_names == 0)
+ break;
+ }
+ else if (err == Successful)
+ {
+ length = sizeof(*reply) + pFontInfo->nprops * sizeof(xFontProp);
+ reply = c->reply;
+ if (c->length < length)
+ {
+ reply = (xListFontsWithInfoReply *) xrealloc(c->reply, length);
+ if (!reply)
+ {
+ err = AllocError;
+ break;
+ }
+ c->reply = reply;
+ c->length = length;
+ }
+ if (c->haveSaved)
+ {
+ numFonts = c->savedNumFonts;
+ name = c->savedName;
+ namelen = strlen(name);
+ }
+ reply->type = X_Reply;
+ reply->length = (sizeof *reply - sizeof(xGenericReply) +
+ pFontInfo->nprops * sizeof(xFontProp) +
+ namelen + 3) >> 2;
+ reply->sequenceNumber = client->sequence;
+ reply->nameLength = namelen;
+ reply->minBounds = pFontInfo->ink_minbounds;
+ reply->maxBounds = pFontInfo->ink_maxbounds;
+ reply->minCharOrByte2 = pFontInfo->firstCol;
+ reply->maxCharOrByte2 = pFontInfo->lastCol;
+ reply->defaultChar = pFontInfo->defaultCh;
+ reply->nFontProps = pFontInfo->nprops;
+ reply->drawDirection = pFontInfo->drawDirection;
+ reply->minByte1 = pFontInfo->firstRow;
+ reply->maxByte1 = pFontInfo->lastRow;
+ reply->allCharsExist = pFontInfo->allExist;
+ reply->fontAscent = pFontInfo->fontAscent;
+ reply->fontDescent = pFontInfo->fontDescent;
+ reply->nReplies = numFonts;
+ pFP = (xFontProp *) (reply + 1);
+ for (i = 0; i < pFontInfo->nprops; i++)
+ {
+ pFP->name = pFontInfo->props[i].name;
+ pFP->value = pFontInfo->props[i].value;
+ pFP++;
+ }
+ WriteSwappedDataToClient(client, length, reply);
+ (void) WriteToClient(client, namelen, name);
+ if (pFontInfo == &fontInfo)
+ {
+ xfree(fontInfo.props);
+ xfree(fontInfo.isStringProp);
+ }
+ --c->current.max_names;
+ }
+ }
+finish:
+ length = sizeof(xListFontsWithInfoReply);
+ bzero((char *) &finalReply, sizeof(xListFontsWithInfoReply));
+ finalReply.type = X_Reply;
+ finalReply.sequenceNumber = client->sequence;
+ finalReply.length = (sizeof(xListFontsWithInfoReply)
+ - sizeof(xGenericReply)) >> 2;
+ WriteSwappedDataToClient(client, length, &finalReply);
+bail:
+ if (c->slept)
+ ClientWakeup(client);
+ for (i = 0; i < c->num_fpes; i++)
+ FreeFPE(c->fpe_list[i]);
+ xfree(c->reply);
+ xfree(c->fpe_list);
+ if (c->savedName) xfree(c->savedName);
+ xfree(c);
+ return TRUE;
+}
+
+int
+StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
+ int max_names)
+{
+ int i;
+ LFWIclosurePtr c;
+
+ /*
+ * The right error to return here would be BadName, however the
+ * specification does not allow for a Name error on this request.
+ * Perhaps a better solution would be to return a nil list, i.e.
+ * a list containing zero fontnames.
+ */
+ if (length > XLFDMAXFONTNAMELEN)
+ return BadAlloc;
+
+ if (!(c = (LFWIclosurePtr) xalloc(sizeof *c)))
+ goto badAlloc;
+ c->fpe_list = (FontPathElementPtr *)
+ xalloc(sizeof(FontPathElementPtr) * num_fpes);
+ if (!c->fpe_list)
+ {
+ xfree(c);
+ goto badAlloc;
+ }
+ memmove(c->current.pattern, pattern, length);
+ for (i = 0; i < num_fpes; i++)
+ {
+ c->fpe_list[i] = font_path_elements[i];
+ UseFPE(c->fpe_list[i]);
+ }
+ c->client = client;
+ c->num_fpes = num_fpes;
+ c->reply = 0;
+ c->length = 0;
+ c->current.patlen = length;
+ c->current.current_fpe = 0;
+ c->current.max_names = max_names;
+ c->current.list_started = FALSE;
+ c->current.private = 0;
+ c->savedNumFonts = 0;
+ c->haveSaved = FALSE;
+ c->slept = FALSE;
+ c->savedName = 0;
+ doListFontsWithInfo(client, c);
+ return Success;
+badAlloc:
+ return BadAlloc;
+}
+
+#define TextEltHeader 2
+#define FontShiftSize 5
+static XID clearGC[] = { CT_NONE };
+#define clearGCmask (GCClipMask)
+
+int
+doPolyText(ClientPtr client, register PTclosurePtr c)
+{
+ register FontPtr pFont = c->pGC->font, oldpFont;
+ Font fid, oldfid;
+ int err = Success, lgerr; /* err is in X error, not font error, space */
+ enum { NEVER_SLEPT, START_SLEEP, SLEEPING } client_state = NEVER_SLEPT;
+ FontPathElementPtr fpe;
+ GC *origGC = NULL;
+
+ if (client->clientGone)
+ {
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+
+ if (c->slept)
+ {
+ /* Client has died, but we cannot bail out right now. We
+ need to clean up after the work we did when going to
+ sleep. Setting the drawable pointer to 0 makes this
+ happen without any attempts to render or perform other
+ unnecessary activities. */
+ c->pDraw = (DrawablePtr)0;
+ }
+ else
+ {
+ err = Success;
+ goto bail;
+ }
+ }
+
+ /* Make sure our drawable hasn't disappeared while we slept. */
+ if (c->slept &&
+ c->pDraw &&
+ c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
+ RC_DRAWABLE, SecurityWriteAccess))
+ {
+ /* Our drawable has disappeared. Treat like client died... ask
+ the FPE code to clean up after client and avoid further
+ rendering while we clean up after ourself. */
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ c->pDraw = (DrawablePtr)0;
+ }
+
+ client_state = c->slept ? SLEEPING : NEVER_SLEPT;
+
+ while (c->endReq - c->pElt > TextEltHeader)
+ {
+ if (*c->pElt == FontChange)
+ {
+ if (c->endReq - c->pElt < FontShiftSize)
+ {
+ err = BadLength;
+ goto bail;
+ }
+
+ oldpFont = pFont;
+ oldfid = fid;
+
+ fid = ((Font)*(c->pElt+4)) /* big-endian */
+ | ((Font)*(c->pElt+3)) << 8
+ | ((Font)*(c->pElt+2)) << 16
+ | ((Font)*(c->pElt+1)) << 24;
+ pFont = (FontPtr)SecurityLookupIDByType(client, fid, RT_FONT,
+ SecurityReadAccess);
+ if (!pFont)
+ {
+ client->errorValue = fid;
+ err = BadFont;
+ /* restore pFont and fid for step 4 (described below) */
+ pFont = oldpFont;
+ fid = oldfid;
+
+ /* If we're in START_SLEEP mode, the following step
+ shortens the request... in the unlikely event that
+ the fid somehow becomes valid before we come through
+ again to actually execute the polytext, which would
+ then mess up our refcounting scheme badly. */
+ c->err = err;
+ c->endReq = c->pElt;
+
+ goto bail;
+ }
+
+ /* Step 3 (described below) on our new font */
+ if (client_state == START_SLEEP)
+ pFont->refcnt++;
+ else
+ {
+ if (pFont != c->pGC->font && c->pDraw)
+ {
+ ChangeGC( c->pGC, GCFont, &fid);
+ ValidateGC(c->pDraw, c->pGC);
+ if (c->reqType == X_PolyText8)
+ c->polyText = (PolyTextPtr) c->pGC->ops->PolyText8;
+ else
+ c->polyText = (PolyTextPtr) c->pGC->ops->PolyText16;
+ }
+
+ /* Undo the refcnt++ we performed when going to sleep */
+ if (client_state == SLEEPING)
+ (void)CloseFont(c->pGC->font, (Font)0);
+ }
+ c->pElt += FontShiftSize;
+ }
+ else /* print a string */
+ {
+ unsigned char *pNextElt;
+ pNextElt = c->pElt + TextEltHeader + (*c->pElt)*c->itemSize;
+ if ( pNextElt > c->endReq)
+ {
+ err = BadLength;
+ goto bail;
+ }
+ if (client_state == START_SLEEP)
+ {
+ c->pElt = pNextElt;
+ continue;
+ }
+ if (c->pDraw)
+ {
+ lgerr = LoadGlyphs(client, c->pGC->font, *c->pElt, c->itemSize,
+ c->pElt + TextEltHeader);
+ }
+ else lgerr = Successful;
+
+ if (lgerr == Suspended)
+ {
+ if (!c->slept) {
+ int len;
+ GC *pGC;
+ PTclosurePtr new_closure;
+
+ /* We're putting the client to sleep. We need to do a few things
+ to ensure successful and atomic-appearing execution of the
+ remainder of the request. First, copy the remainder of the
+ request into a safe malloc'd area. Second, create a scratch GC
+ to use for the remainder of the request. Third, mark all fonts
+ referenced in the remainder of the request to prevent their
+ deallocation. Fourth, make the original GC look like the
+ request has completed... set its font to the final font value
+ from this request. These GC manipulations are for the unlikely
+ (but possible) event that some other client is using the GC.
+ Steps 3 and 4 are performed by running this procedure through
+ the remainder of the request in a special no-render mode
+ indicated by client_state = START_SLEEP. */
+
+ /* Step 1 */
+ /* Allocate a malloc'd closure structure to replace
+ the local one we were passed */
+ new_closure = (PTclosurePtr) xalloc(sizeof(PTclosureRec));
+ if (!new_closure)
+ {
+ err = BadAlloc;
+ goto bail;
+ }
+ *new_closure = *c;
+ c = new_closure;
+
+ len = c->endReq - c->pElt;
+ c->data = (unsigned char *)xalloc(len);
+ if (!c->data)
+ {
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ memmove(c->data, c->pElt, len);
+ c->pElt = c->data;
+ c->endReq = c->pElt + len;
+
+ /* Step 2 */
+
+ pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
+ if (!pGC)
+ {
+ xfree(c->data);
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ if ((err = CopyGC(c->pGC, pGC, GCFunction |
+ GCPlaneMask | GCForeground |
+ GCBackground | GCFillStyle |
+ GCTile | GCStipple |
+ GCTileStipXOrigin |
+ GCTileStipYOrigin | GCFont |
+ GCSubwindowMode | GCClipXOrigin |
+ GCClipYOrigin | GCClipMask)) !=
+ Success)
+ {
+ FreeScratchGC(pGC);
+ xfree(c->data);
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ origGC = c->pGC;
+ c->pGC = pGC;
+ ValidateGC(c->pDraw, c->pGC);
+
+ c->slept = TRUE;
+ ClientSleep(client,
+ (ClientSleepProcPtr)doPolyText,
+ (pointer) c);
+
+ /* Set up to perform steps 3 and 4 */
+ client_state = START_SLEEP;
+ continue; /* on to steps 3 and 4 */
+ }
+ return TRUE;
+ }
+ else if (lgerr != Successful)
+ {
+ err = FontToXError(lgerr);
+ goto bail;
+ }
+ if (c->pDraw)
+ {
+ c->xorg += *((INT8 *)(c->pElt + 1)); /* must be signed */
+ c->xorg = (* c->polyText)(c->pDraw, c->pGC, c->xorg, c->yorg,
+ *c->pElt, c->pElt + TextEltHeader);
+ }
+ c->pElt = pNextElt;
+ }
+ }
+
+bail:
+
+ if (client_state == START_SLEEP)
+ {
+ /* Step 4 */
+ if (pFont != origGC->font)
+ {
+ ChangeGC(origGC, GCFont, &fid);
+ ValidateGC(c->pDraw, origGC);
+ }
+
+ /* restore pElt pointer for execution of remainder of the request */
+ c->pElt = c->data;
+ return TRUE;
+ }
+
+ if (c->err != Success) err = c->err;
+ if (err != Success && c->client != serverClient) {
+#ifdef PANORAMIX
+ if (noPanoramiXExtension || !c->pGC->pScreen->myNum)
+#endif
+ SendErrorToClient(c->client, c->reqType, 0, 0, err);
+ }
+ if (c->slept)
+ {
+ ClientWakeup(c->client);
+ ChangeGC(c->pGC, clearGCmask, clearGC);
+
+ /* Unreference the font from the scratch GC */
+ CloseFont(c->pGC->font, (Font)0);
+ c->pGC->font = NullFont;
+
+ FreeScratchGC(c->pGC);
+ xfree(c->data);
+ xfree(c);
+ }
+ return TRUE;
+}
+
+int
+PolyText(ClientPtr client, DrawablePtr pDraw, GC *pGC, unsigned char *pElt,
+ unsigned char *endReq, int xorg, int yorg, int reqType, XID did)
+{
+ PTclosureRec local_closure;
+
+ local_closure.pElt = pElt;
+ local_closure.endReq = endReq;
+ local_closure.client = client;
+ local_closure.pDraw = pDraw;
+ local_closure.xorg = xorg;
+ local_closure.yorg = yorg;
+ if ((local_closure.reqType = reqType) == X_PolyText8)
+ {
+ local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText8;
+ local_closure.itemSize = 1;
+ }
+ else
+ {
+ local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText16;
+ local_closure.itemSize = 2;
+ }
+ local_closure.pGC = pGC;
+ local_closure.did = did;
+ local_closure.err = Success;
+ local_closure.slept = FALSE;
+
+ (void) doPolyText(client, &local_closure);
+ return Success;
+}
+
+
+#undef TextEltHeader
+#undef FontShiftSize
+
+int
+doImageText(ClientPtr client, register ITclosurePtr c)
+{
+ int err = Success, lgerr; /* err is in X error, not font error, space */
+ FontPathElementPtr fpe;
+
+ if (client->clientGone)
+ {
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ err = Success;
+ goto bail;
+ }
+
+ /* Make sure our drawable hasn't disappeared while we slept. */
+ if (c->slept &&
+ c->pDraw &&
+ c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
+ RC_DRAWABLE, SecurityWriteAccess))
+ {
+ /* Our drawable has disappeared. Treat like client died... ask
+ the FPE code to clean up after client. */
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ err = Success;
+ goto bail;
+ }
+
+ lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, c->itemSize, c->data);
+ if (lgerr == Suspended)
+ {
+ if (!c->slept) {
+ GC *pGC;
+ unsigned char *data;
+ ITclosurePtr new_closure;
+
+ /* We're putting the client to sleep. We need to
+ save some state. Similar problem to that handled
+ in doPolyText, but much simpler because the
+ request structure is much simpler. */
+
+ new_closure = (ITclosurePtr) xalloc(sizeof(ITclosureRec));
+ if (!new_closure)
+ {
+ err = BadAlloc;
+ goto bail;
+ }
+ *new_closure = *c;
+ c = new_closure;
+
+ data = (unsigned char *)xalloc(c->nChars * c->itemSize);
+ if (!data)
+ {
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ memmove(data, c->data, c->nChars * c->itemSize);
+ c->data = data;
+
+ pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
+ if (!pGC)
+ {
+ xfree(c->data);
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ if ((err = CopyGC(c->pGC, pGC, GCFunction | GCPlaneMask |
+ GCForeground | GCBackground | GCFillStyle |
+ GCTile | GCStipple | GCTileStipXOrigin |
+ GCTileStipYOrigin | GCFont |
+ GCSubwindowMode | GCClipXOrigin |
+ GCClipYOrigin | GCClipMask)) != Success)
+ {
+ FreeScratchGC(pGC);
+ xfree(c->data);
+ xfree(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ c->pGC = pGC;
+ ValidateGC(c->pDraw, c->pGC);
+
+ c->slept = TRUE;
+ ClientSleep(client, (ClientSleepProcPtr)doImageText, (pointer) c);
+ }
+ return TRUE;
+ }
+ else if (lgerr != Successful)
+ {
+ err = FontToXError(lgerr);
+ goto bail;
+ }
+ if (c->pDraw)
+ {
+ (* c->imageText)(c->pDraw, c->pGC, c->xorg, c->yorg,
+ c->nChars, c->data);
+ }
+
+bail:
+
+ if (err != Success && c->client != serverClient) {
+ SendErrorToClient(c->client, c->reqType, 0, 0, err);
+ }
+ if (c->slept)
+ {
+ ClientWakeup(c->client);
+ ChangeGC(c->pGC, clearGCmask, clearGC);
+
+ /* Unreference the font from the scratch GC */
+ CloseFont(c->pGC->font, (Font)0);
+ c->pGC->font = NullFont;
+
+ FreeScratchGC(c->pGC);
+ xfree(c->data);
+ xfree(c);
+ }
+ return TRUE;
+}
+
+int
+ImageText(ClientPtr client, DrawablePtr pDraw, GC *pGC, int nChars,
+ unsigned char *data, int xorg, int yorg, int reqType, XID did)
+{
+ ITclosureRec local_closure;
+
+ local_closure.client = client;
+ local_closure.pDraw = pDraw;
+ local_closure.pGC = pGC;
+ local_closure.nChars = nChars;
+ local_closure.data = data;
+ local_closure.xorg = xorg;
+ local_closure.yorg = yorg;
+ if ((local_closure.reqType = reqType) == X_ImageText8)
+ {
+ local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText8;
+ local_closure.itemSize = 1;
+ }
+ else
+ {
+ local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText16;
+ local_closure.itemSize = 2;
+ }
+ local_closure.did = did;
+ local_closure.slept = FALSE;
+
+ (void) doImageText(client, &local_closure);
+ return Success;
+}
+
+
+/* does the necessary magic to figure out the fpe type */
+static int
+DetermineFPEType(char *pathname)
+{
+ int i;
+
+ for (i = 0; i < num_fpe_types; i++) {
+ if ((*fpe_functions[i].name_check) (pathname))
+ return i;
+ }
+ return -1;
+}
+
+
+static void
+FreeFontPath(FontPathElementPtr *list, int n, Bool force)
+{
+ int i;
+
+ for (i = 0; i < n; i++) {
+ if (force) {
+ /* Sanity check that all refcounts will be 0 by the time
+ we get to the end of the list. */
+ int found = 1; /* the first reference is us */
+ int j;
+ for (j = i+1; j < n; j++) {
+ if (list[j] == list[i])
+ found++;
+ }
+ if (list[i]->refcount != found) {
+ ErrorF("FreeFontPath: FPE \"%.*s\" refcount is %d, should be %d; fixing.\n",
+ list[i]->name_length, list[i]->name,
+ list[i]->refcount, found);
+ list[i]->refcount = found; /* ensure it will get freed */
+ }
+ }
+ FreeFPE(list[i]);
+ }
+ xfree((char *) list);
+}
+
+static FontPathElementPtr
+find_existing_fpe(FontPathElementPtr *list, int num, unsigned char *name, int len)
+{
+ FontPathElementPtr fpe;
+ int i;
+
+ for (i = 0; i < num; i++) {
+ fpe = list[i];
+ if (fpe->name_length == len && memcmp(name, fpe->name, len) == 0)
+ return fpe;
+ }
+ return (FontPathElementPtr) 0;
+}
+
+
+static int
+SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
+{
+ int i, err = 0;
+ int valid_paths = 0;
+ unsigned int len;
+ unsigned char *cp = paths;
+ FontPathElementPtr fpe = NULL, *fplist;
+
+ fplist = (FontPathElementPtr *)
+ xalloc(sizeof(FontPathElementPtr) * npaths);
+ if (!fplist) {
+ *bad = 0;
+ return BadAlloc;
+ }
+ for (i = 0; i < num_fpe_types; i++) {
+ if (fpe_functions[i].set_path_hook)
+ (*fpe_functions[i].set_path_hook) ();
+ }
+ for (i = 0; i < npaths; i++)
+ {
+ len = (unsigned int) (*cp++);
+
+ if (len == 0)
+ {
+ if (persist)
+ ErrorF ("Removing empty element from the valid list of fontpaths\n");
+ err = BadValue;
+ }
+ else
+ {
+ /* if it's already in our active list, just reset it */
+ /*
+ * note that this can miss FPE's in limbo -- may be worth catching
+ * them, though it'd muck up refcounting
+ */
+ fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len);
+ if (fpe)
+ {
+ err = (*fpe_functions[fpe->type].reset_fpe) (fpe);
+ if (err == Successful)
+ {
+ UseFPE(fpe);/* since it'll be decref'd later when freed
+ * from the old list */
+ }
+ else
+ fpe = 0;
+ }
+ /* if error or can't do it, act like it's a new one */
+ if (!fpe)
+ {
+ fpe = (FontPathElementPtr) xalloc(sizeof(FontPathElementRec));
+ if (!fpe)
+ {
+ err = BadAlloc;
+ goto bail;
+ }
+ fpe->name = (char *) xalloc(len + 1);
+ if (!fpe->name)
+ {
+ xfree(fpe);
+ err = BadAlloc;
+ goto bail;
+ }
+ fpe->refcount = 1;
+
+ strncpy(fpe->name, (char *) cp, (int) len);
+ fpe->name[len] = '\0';
+ fpe->name_length = len;
+ fpe->type = DetermineFPEType(fpe->name);
+ if (fpe->type == -1)
+ err = BadValue;
+ else
+ err = (*fpe_functions[fpe->type].init_fpe) (fpe);
+ if (err != Successful)
+ {
+ if (persist)
+ {
+ ErrorF("Could not init font path element %s, removing from list!\n",
+ fpe->name);
+ }
+ xfree (fpe->name);
+ xfree (fpe);
+ }
+ }
+ }
+ if (err != Successful)
+ {
+ if (!persist)
+ goto bail;
+ }
+ else
+ {
+ fplist[valid_paths++] = fpe;
+ }
+ cp += len;
+ }
+
+ FreeFontPath(font_path_elements, num_fpes, FALSE);
+ font_path_elements = fplist;
+ if (patternCache)
+ EmptyFontPatternCache(patternCache);
+ num_fpes = valid_paths;
+
+ return Success;
+bail:
+ *bad = i;
+ while (--valid_paths >= 0)
+ FreeFPE(fplist[valid_paths]);
+ xfree(fplist);
+ return FontToXError(err);
+}
+
+/* XXX -- do we need to pass error down to each renderer? */
+int
+SetFontPath(ClientPtr client, int npaths, unsigned char *paths, int *error)
+{
+ int err = Success;
+
+ if (npaths == 0) {
+ if (SetDefaultFontPath(defaultFontPath) != Success)
+ return BadValue;
+ } else {
+ err = SetFontPathElements(npaths, paths, error, FALSE);
+ }
+ return err;
+}
+
+int
+SetDefaultFontPath(char *path)
+{
+ unsigned char *cp,
+ *pp,
+ *nump,
+ *newpath;
+ int num = 1,
+ len,
+ err,
+ size = 0,
+ bad;
+
+ /* get enough for string, plus values -- use up commas */
+ len = strlen(path) + 1;
+ nump = cp = newpath = (unsigned char *) ALLOCATE_LOCAL(len);
+ if (!newpath)
+ return BadAlloc;
+ pp = (unsigned char *) path;
+ cp++;
+ while (*pp) {
+ if (*pp == ',') {
+ *nump = (unsigned char) size;
+ nump = cp++;
+ pp++;
+ num++;
+ size = 0;
+ } else {
+ *cp++ = *pp++;
+ size++;
+ }
+ }
+ *nump = (unsigned char) size;
+
+ err = SetFontPathElements(num, newpath, &bad, TRUE);
+
+ DEALLOCATE_LOCAL(newpath);
+
+ return err;
+}
+
+unsigned char *
+GetFontPath(int *count, int *length)
+{
+ int i;
+ unsigned char *c;
+ int len;
+ FontPathElementPtr fpe;
+
+ len = 0;
+ for (i = 0; i < num_fpes; i++) {
+ fpe = font_path_elements[i];
+ len += fpe->name_length + 1;
+ }
+ font_path_string = (unsigned char *) xrealloc(font_path_string, len);
+ if (!font_path_string)
+ return NULL;
+
+ c = font_path_string;
+ *length = 0;
+ for (i = 0; i < num_fpes; i++) {
+ fpe = font_path_elements[i];
+ *c = fpe->name_length;
+ *length += *c++;
+ memmove(c, fpe->name, fpe->name_length);
+ c += fpe->name_length;
+ }
+ *count = num_fpes;
+ return font_path_string;
+}
+
+int
+LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size, unsigned char *data)
+{
+ if (fpe_functions[pfont->fpe->type].load_glyphs)
+ return (*fpe_functions[pfont->fpe->type].load_glyphs)
+ (client, pfont, 0, nchars, item_size, data);
+ else
+ return Successful;
+}
+
+void
+DeleteClientFontStuff(ClientPtr client)
+{
+ int i;
+ FontPathElementPtr fpe;
+
+ for (i = 0; i < num_fpes; i++)
+ {
+ fpe = font_path_elements[i];
+ if (fpe_functions[fpe->type].client_died)
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ }
+}
+
+void
+InitFonts ()
+{
+ patternCache = MakeFontPatternCache();
+
+#ifndef KDRIVESERVER
+ if (screenInfo.numScreens > screenInfo.numVideoScreens) {
+ PrinterFontRegisterFpeFunctions();
+ FontFileCheckRegisterFpeFunctions();
+ check_fs_register_fpe_functions();
+ } else
+#endif
+ {
+#ifdef KDRIVESERVER
+ BuiltinRegisterFpeFunctions();
+#endif
+ FontFileRegisterFpeFunctions();
+#ifndef NOFONTSERVERACCESS
+ fs_register_fpe_functions();
+#endif
+ }
+}
+
+int
+GetDefaultPointSize ()
+{
+ return 120;
+}
+
+
+FontResolutionPtr
+GetClientResolutions (int *num)
+{
+ if (requestingClient && requestingClient->fontResFunc != NULL &&
+ !requestingClient->clientGone)
+ {
+ return (*requestingClient->fontResFunc)(requestingClient, num);
+ }
+ else {
+ static struct _FontResolution res;
+ ScreenPtr pScreen;
+
+ pScreen = screenInfo.screens[0];
+ res.x_resolution = (pScreen->width * 25.4) / pScreen->mmWidth;
+ /*
+ * XXX - we'll want this as long as bitmap instances are prevalent
+ so that we can match them from scalable fonts
+ */
+ if (res.x_resolution < 88)
+ res.x_resolution = 75;
+ else
+ res.x_resolution = 100;
+ res.y_resolution = (pScreen->height * 25.4) / pScreen->mmHeight;
+ if (res.y_resolution < 88)
+ res.y_resolution = 75;
+ else
+ res.y_resolution = 100;
+ res.point_size = 120;
+ *num = 1;
+ return &res;
+ }
+}
+
+/*
+ * returns the type index of the new fpe
+ *
+ * should be called (only once!) by each type of fpe when initialized
+ */
+
+int
+RegisterFPEFunctions(NameCheckFunc name_func,
+ InitFpeFunc init_func,
+ FreeFpeFunc free_func,
+ ResetFpeFunc reset_func,
+ OpenFontFunc open_func,
+ CloseFontFunc close_func,
+ ListFontsFunc list_func,
+ StartLfwiFunc start_lfwi_func,
+ NextLfwiFunc next_lfwi_func,
+ WakeupFpeFunc wakeup_func,
+ ClientDiedFunc client_died,
+ LoadGlyphsFunc load_glyphs,
+ StartLaFunc start_list_alias_func,
+ NextLaFunc next_list_alias_func,
+ SetPathFunc set_path_func)
+{
+ FPEFunctions *new;
+
+ /* grow the list */
+ new = (FPEFunctions *) xrealloc(fpe_functions,
+ (num_fpe_types + 1) * sizeof(FPEFunctions));
+ if (!new)
+ return -1;
+ fpe_functions = new;
+
+ fpe_functions[num_fpe_types].name_check = name_func;
+ fpe_functions[num_fpe_types].open_font = open_func;
+ fpe_functions[num_fpe_types].close_font = close_func;
+ fpe_functions[num_fpe_types].wakeup_fpe = wakeup_func;
+ fpe_functions[num_fpe_types].list_fonts = list_func;
+ fpe_functions[num_fpe_types].start_list_fonts_with_info =
+ start_lfwi_func;
+ fpe_functions[num_fpe_types].list_next_font_with_info =
+ next_lfwi_func;
+ fpe_functions[num_fpe_types].init_fpe = init_func;
+ fpe_functions[num_fpe_types].free_fpe = free_func;
+ fpe_functions[num_fpe_types].reset_fpe = reset_func;
+ fpe_functions[num_fpe_types].client_died = client_died;
+ fpe_functions[num_fpe_types].load_glyphs = load_glyphs;
+ fpe_functions[num_fpe_types].start_list_fonts_and_aliases =
+ start_list_alias_func;
+ fpe_functions[num_fpe_types].list_next_font_or_alias =
+ next_list_alias_func;
+ fpe_functions[num_fpe_types].set_path_hook = set_path_func;
+
+ return num_fpe_types++;
+}
+
+void
+FreeFonts()
+{
+ if (patternCache) {
+ FreeFontPatternCache(patternCache);
+ patternCache = 0;
+ }
+ FreeFontPath(font_path_elements, num_fpes, TRUE);
+ font_path_elements = 0;
+ num_fpes = 0;
+ xfree(fpe_functions);
+ num_fpe_types = 0;
+ fpe_functions = (FPEFunctions *) 0;
+}
+
+/* convenience functions for FS interface */
+
+FontPtr
+find_old_font(XID id)
+{
+ return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE,
+ SecurityUnknownAccess);
+}
+
+Font
+GetNewFontClientID()
+{
+ return FakeClientID(0);
+}
+
+int
+StoreFontClientFont(FontPtr pfont, Font id)
+{
+ return AddResource(id, RT_NONE, (pointer) pfont);
+}
+
+void
+DeleteFontClientID(Font id)
+{
+ FreeResource(id, RT_NONE);
+}
+
+int
+client_auth_generation(ClientPtr client)
+{
+ return 0;
+}
+
+static int fs_handlers_installed = 0;
+static unsigned int last_server_gen;
+
+int
+init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler)
+{
+ /* if server has reset, make sure the b&w handlers are reinstalled */
+ if (last_server_gen < serverGeneration) {
+ last_server_gen = serverGeneration;
+ fs_handlers_installed = 0;
+ }
+ if (fs_handlers_installed == 0) {
+
+#ifdef DEBUG
+ fprintf(stderr, "adding FS b & w handlers\n");
+#endif
+
+ if (!RegisterBlockAndWakeupHandlers(block_handler,
+ FontWakeup, (pointer) 0))
+ return AllocError;
+ fs_handlers_installed++;
+ }
+ QueueFontWakeup(fpe);
+ return Successful;
+}
+
+void
+remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all)
+{
+ if (all) {
+ /* remove the handlers if no one else is using them */
+ if (--fs_handlers_installed == 0) {
+
+#ifdef DEBUG
+ fprintf(stderr, "removing FS b & w handlers\n");
+#endif
+
+ RemoveBlockAndWakeupHandlers(block_handler, FontWakeup,
+ (pointer) 0);
+ }
+ }
+ RemoveFontWakeup(fpe);
+}
+
+#ifdef DEBUG
+#define GLWIDTHBYTESPADDED(bits,nbytes) \
+ ((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \
+ :(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \
+ :(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \
+ :(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \
+ : 0)
+
+#define GLYPH_SIZE(ch, nbytes) \
+ GLWIDTHBYTESPADDED((ch)->metrics.rightSideBearing - \
+ (ch)->metrics.leftSideBearing, (nbytes))
+void
+dump_char_ascii(CharInfoPtr cip)
+{
+ int r,
+ l;
+ int bpr;
+ int byte;
+ static unsigned maskTab[] = {
+ (1 << 7), (1 << 6), (1 << 5), (1 << 4),
+ (1 << 3), (1 << 2), (1 << 1), (1 << 0),
+ };
+
+ bpr = GLYPH_SIZE(cip, 4);
+ for (r = 0; r < (cip->metrics.ascent + cip->metrics.descent); r++) {
+ pointer row = (pointer) cip->bits + r * bpr;
+
+ byte = 0;
+ for (l = 0; l <= (cip->metrics.rightSideBearing -
+ cip->metrics.leftSideBearing); l++) {
+ if (maskTab[l & 7] & row[l >> 3])
+ putchar('X');
+ else
+ putchar('.');
+ }
+ putchar('\n');
+ }
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/dix/dixutils.c b/nx-X11/programs/Xserver/dix/dixutils.c
new file mode 100644
index 000000000..e7d4ccd4d
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/dixutils.c
@@ -0,0 +1,962 @@
+/* $XFree86: xc/programs/Xserver/dix/dixutils.c,v 3.13 2003/01/12 02:44:26 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+
+(c)Copyright 1988,1991 Adobe Systems Incorporated. All rights reserved.
+
+Permission to use, copy, modify, distribute, and sublicense this software and its
+documentation for any purpose and without fee is hereby granted, provided that
+the above copyright notices appear in all copies and that both those copyright
+notices and this permission notice appear in supporting documentation and that
+the name of Adobe Systems Incorporated not be used in advertising or publicity
+pertaining to distribution of the software without specific, written prior
+permission. No trademark license to use the Adobe trademarks is hereby
+granted. If the Adobe trademark "Display PostScript"(tm) is used to describe
+this software, its functionality or for any other purpose, such use shall be
+limited to a statement that this software works in conjunction with the Display
+PostScript system. Proper trademark attribution to reflect Adobe's ownership
+of the trademark shall be given whenever any such reference to the Display
+PostScript system is made.
+
+ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR ANY
+PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. ADOBE
+DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-
+INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE TO YOU
+OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
+DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,NEGLIGENCE, STRICT
+LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT PROVIDE ANY TRAINING OR OTHER
+SUPPORT FOR THE SOFTWARE.
+
+Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+Incorporated which may be registered in certain jurisdictions.
+
+Author: Adobe Systems Incorporated
+
+*/
+
+/* $Xorg: dixutils.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "misc.h"
+#include "windowstr.h"
+#include "dixstruct.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#define XK_LATIN1
+#include <X11/keysymdef.h>
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+
+/*
+ * CompareTimeStamps returns -1, 0, or +1 depending on if the first
+ * argument is less than, equal to or greater than the second argument.
+ */
+
+int
+CompareTimeStamps(TimeStamp a, TimeStamp b)
+{
+ if (a.months < b.months)
+ return EARLIER;
+ if (a.months > b.months)
+ return LATER;
+ if (a.milliseconds < b.milliseconds)
+ return EARLIER;
+ if (a.milliseconds > b.milliseconds)
+ return LATER;
+ return SAMETIME;
+}
+
+/*
+ * convert client times to server TimeStamps
+ */
+
+#define HALFMONTH ((unsigned long) 1<<31)
+TimeStamp
+ClientTimeToServerTime(CARD32 c)
+{
+ TimeStamp ts;
+ if (c == CurrentTime)
+ return currentTime;
+ ts.months = currentTime.months;
+ ts.milliseconds = c;
+ if (c > currentTime.milliseconds)
+ {
+ if (((unsigned long) c - currentTime.milliseconds) > HALFMONTH)
+ ts.months -= 1;
+ }
+ else if (c < currentTime.milliseconds)
+ {
+ if (((unsigned long)currentTime.milliseconds - c) > HALFMONTH)
+ ts.months += 1;
+ }
+ return ts;
+}
+
+/*
+ * ISO Latin-1 case conversion routine
+ *
+ * this routine always null-terminates the result, so
+ * beware of too-small buffers
+ */
+
+static unsigned char
+ISOLatin1ToLower (unsigned char source)
+{
+ unsigned char dest;
+ if ((source >= XK_A) && (source <= XK_Z))
+ dest = source + (XK_a - XK_A);
+ else if ((source >= XK_Agrave) && (source <= XK_Odiaeresis))
+ dest = source + (XK_agrave - XK_Agrave);
+ else if ((source >= XK_Ooblique) && (source <= XK_Thorn))
+ dest = source + (XK_oslash - XK_Ooblique);
+ else
+ dest = source;
+ return dest;
+}
+
+
+void
+CopyISOLatin1Lowered(unsigned char *dest, unsigned char *source, int length)
+{
+ register int i;
+
+ for (i = 0; i < length; i++, source++, dest++)
+ *dest = ISOLatin1ToLower (*source);
+ *dest = '\0';
+}
+
+int
+CompareISOLatin1Lowered(unsigned char *s1, int s1len,
+ unsigned char *s2, int s2len)
+{
+ unsigned char c1, c2;
+
+ for (;;)
+ {
+ /* note -- compare against zero so that -1 ignores len */
+ c1 = s1len-- ? *s1++ : '\0';
+ c2 = s2len-- ? *s2++ : '\0';
+ if (!c1 ||
+ (c1 != c2 &&
+ (c1 = ISOLatin1ToLower (c1)) != (c2 = ISOLatin1ToLower (c2))))
+ break;
+ }
+ return (int) c1 - (int) c2;
+}
+
+#ifdef XCSECURITY
+
+/* SecurityLookupWindow and SecurityLookupDrawable:
+ * Look up the window/drawable taking into account the client doing
+ * the lookup and the type of access desired. Return the window/drawable
+ * if it exists and the client is allowed access, else return NULL.
+ * Most Proc* functions should be calling these instead of
+ * LookupWindow and LookupDrawable, which do no access checks.
+ */
+
+WindowPtr
+SecurityLookupWindow(XID rid, ClientPtr client, Mask access_mode)
+{
+ WindowPtr pWin;
+
+ client->errorValue = rid;
+ if(rid == INVALID)
+ return NULL;
+ if (client->trustLevel != XSecurityClientTrusted)
+ return (WindowPtr)SecurityLookupIDByType(client, rid, RT_WINDOW, access_mode);
+ if (client->lastDrawableID == rid)
+ {
+ if (client->lastDrawable->type == DRAWABLE_WINDOW)
+ return ((WindowPtr) client->lastDrawable);
+ return (WindowPtr) NULL;
+ }
+ pWin = (WindowPtr)SecurityLookupIDByType(client, rid, RT_WINDOW, access_mode);
+ if (pWin && pWin->drawable.type == DRAWABLE_WINDOW) {
+ client->lastDrawable = (DrawablePtr) pWin;
+ client->lastDrawableID = rid;
+ client->lastGCID = INVALID;
+ client->lastGC = (GCPtr)NULL;
+ }
+ return pWin;
+}
+
+
+pointer
+SecurityLookupDrawable(XID rid, ClientPtr client, Mask access_mode)
+{
+ register DrawablePtr pDraw;
+
+ if(rid == INVALID)
+ return (pointer) NULL;
+ if (client->trustLevel != XSecurityClientTrusted)
+ return (DrawablePtr)SecurityLookupIDByClass(client, rid, RC_DRAWABLE,
+ access_mode);
+ if (client->lastDrawableID == rid)
+ return ((pointer) client->lastDrawable);
+ pDraw = (DrawablePtr)SecurityLookupIDByClass(client, rid, RC_DRAWABLE,
+ access_mode);
+ if (pDraw && (pDraw->type != UNDRAWABLE_WINDOW))
+ return (pointer)pDraw;
+ return (pointer)NULL;
+}
+
+/* We can't replace the LookupWindow and LookupDrawable functions with
+ * macros because of compatibility with loadable servers.
+ */
+
+WindowPtr
+LookupWindow(XID rid, ClientPtr client)
+{
+ return SecurityLookupWindow(rid, client, SecurityUnknownAccess);
+}
+
+pointer
+LookupDrawable(XID rid, ClientPtr client)
+{
+ return SecurityLookupDrawable(rid, client, SecurityUnknownAccess);
+}
+
+#else /* not XCSECURITY */
+
+WindowPtr
+LookupWindow(XID rid, ClientPtr client)
+{
+ WindowPtr pWin;
+
+ client->errorValue = rid;
+ if(rid == INVALID)
+ return NULL;
+ if (client->lastDrawableID == rid)
+ {
+ if (client->lastDrawable->type == DRAWABLE_WINDOW)
+ return ((WindowPtr) client->lastDrawable);
+ return (WindowPtr) NULL;
+ }
+ pWin = (WindowPtr)LookupIDByType(rid, RT_WINDOW);
+ if (pWin && pWin->drawable.type == DRAWABLE_WINDOW) {
+ client->lastDrawable = (DrawablePtr) pWin;
+ client->lastDrawableID = rid;
+ client->lastGCID = INVALID;
+ client->lastGC = (GCPtr)NULL;
+ }
+ return pWin;
+}
+
+
+pointer
+LookupDrawable(XID rid, ClientPtr client)
+{
+ register DrawablePtr pDraw;
+
+ if(rid == INVALID)
+ return (pointer) NULL;
+ if (client->lastDrawableID == rid)
+ return ((pointer) client->lastDrawable);
+ pDraw = (DrawablePtr)LookupIDByClass(rid, RC_DRAWABLE);
+ if (pDraw && (pDraw->type != UNDRAWABLE_WINDOW))
+ return (pointer)pDraw;
+ return (pointer)NULL;
+}
+
+#endif /* XCSECURITY */
+
+ClientPtr
+LookupClient(XID rid, ClientPtr client)
+{
+ pointer pRes = (pointer)SecurityLookupIDByClass(client, rid, RC_ANY,
+ SecurityReadAccess);
+ int clientIndex = CLIENT_ID(rid);
+
+ if (clientIndex && pRes && clients[clientIndex] && !(rid & SERVER_BIT))
+ {
+ return clients[clientIndex];
+ }
+ return (ClientPtr)NULL;
+}
+
+
+int
+AlterSaveSetForClient(ClientPtr client, WindowPtr pWin, unsigned mode,
+ Bool toRoot, Bool remap)
+{
+ int numnow;
+ SaveSetElt *pTmp = NULL;
+ int j;
+
+ numnow = client->numSaved;
+ j = 0;
+ if (numnow)
+ {
+ pTmp = client->saveSet;
+ while ((j < numnow) && (SaveSetWindow(pTmp[j]) != (pointer)pWin))
+ j++;
+ }
+ if (mode == SetModeInsert)
+ {
+ if (j < numnow) /* duplicate */
+ return(Success);
+ numnow++;
+ pTmp = (SaveSetElt *)xrealloc(client->saveSet, sizeof(*pTmp) * numnow);
+ if (!pTmp)
+ return(BadAlloc);
+ client->saveSet = pTmp;
+ client->numSaved = numnow;
+ SaveSetAssignWindow(client->saveSet[numnow - 1], pWin);
+ SaveSetAssignToRoot(client->saveSet[numnow - 1], toRoot);
+ SaveSetAssignRemap(client->saveSet[numnow - 1], remap);
+ return(Success);
+ }
+ else if ((mode == SetModeDelete) && (j < numnow))
+ {
+ while (j < numnow-1)
+ {
+ pTmp[j] = pTmp[j+1];
+ j++;
+ }
+ numnow--;
+ if (numnow)
+ {
+ pTmp = (SaveSetElt *)xrealloc(client->saveSet, sizeof(*pTmp) * numnow);
+ if (pTmp)
+ client->saveSet = pTmp;
+ }
+ else
+ {
+ xfree(client->saveSet);
+ client->saveSet = (SaveSetElt *)NULL;
+ }
+ client->numSaved = numnow;
+ return(Success);
+ }
+ return(Success);
+}
+
+void
+DeleteWindowFromAnySaveSet(WindowPtr pWin)
+{
+ register int i;
+ register ClientPtr client;
+
+ for (i = 0; i< currentMaxClients; i++)
+ {
+ client = clients[i];
+ if (client && client->numSaved)
+ (void)AlterSaveSetForClient(client, pWin, SetModeDelete, FALSE, TRUE);
+ }
+}
+
+/* No-op Don't Do Anything : sometimes we need to be able to call a procedure
+ * that doesn't do anything. For example, on screen with only static
+ * colormaps, if someone calls install colormap, it's easier to have a dummy
+ * procedure to call than to check if there's a procedure
+ */
+void
+NoopDDA(void)
+{
+}
+
+typedef struct _BlockHandler {
+ BlockHandlerProcPtr BlockHandler;
+ WakeupHandlerProcPtr WakeupHandler;
+ pointer blockData;
+ Bool deleted;
+} BlockHandlerRec, *BlockHandlerPtr;
+
+static BlockHandlerPtr handlers;
+static int numHandlers;
+static int sizeHandlers;
+static Bool inHandler;
+static Bool handlerDeleted;
+
+/**
+ *
+ * \param pTimeout DIX doesn't want to know how OS represents time
+ * \param pReadMask nor how it represents the det of descriptors
+ */
+void
+BlockHandler(pointer pTimeout, pointer pReadmask)
+{
+ register int i, j;
+
+ ++inHandler;
+ for (i = 0; i < screenInfo.numScreens; i++)
+ (* screenInfo.screens[i]->BlockHandler)(i,
+ screenInfo.screens[i]->blockData,
+ pTimeout, pReadmask);
+ for (i = 0; i < numHandlers; i++)
+ (*handlers[i].BlockHandler) (handlers[i].blockData,
+ pTimeout, pReadmask);
+ if (handlerDeleted)
+ {
+ for (i = 0; i < numHandlers;)
+ if (handlers[i].deleted)
+ {
+ for (j = i; j < numHandlers - 1; j++)
+ handlers[j] = handlers[j+1];
+ numHandlers--;
+ }
+ else
+ i++;
+ handlerDeleted = FALSE;
+ }
+ --inHandler;
+}
+
+/**
+ *
+ * \param result 32 bits of undefined result from the wait
+ * \param pReadmask the resulting descriptor mask
+ */
+void
+WakeupHandler(int result, pointer pReadmask)
+{
+ register int i, j;
+
+ ++inHandler;
+ for (i = numHandlers - 1; i >= 0; i--)
+ (*handlers[i].WakeupHandler) (handlers[i].blockData,
+ result, pReadmask);
+ for (i = 0; i < screenInfo.numScreens; i++)
+ (* screenInfo.screens[i]->WakeupHandler)(i,
+ screenInfo.screens[i]->wakeupData,
+ result, pReadmask);
+ if (handlerDeleted)
+ {
+ for (i = 0; i < numHandlers;)
+ if (handlers[i].deleted)
+ {
+ for (j = i; j < numHandlers - 1; j++)
+ handlers[j] = handlers[j+1];
+ numHandlers--;
+ }
+ else
+ i++;
+ handlerDeleted = FALSE;
+ }
+ --inHandler;
+}
+
+/**
+ * Reentrant with BlockHandler and WakeupHandler, except wakeup won't
+ * get called until next time
+ */
+Bool
+RegisterBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler,
+ WakeupHandlerProcPtr wakeupHandler,
+ pointer blockData)
+{
+ BlockHandlerPtr new;
+
+ if (numHandlers >= sizeHandlers)
+ {
+ new = (BlockHandlerPtr) xrealloc (handlers, (numHandlers + 1) *
+ sizeof (BlockHandlerRec));
+ if (!new)
+ return FALSE;
+ handlers = new;
+ sizeHandlers = numHandlers + 1;
+ }
+ handlers[numHandlers].BlockHandler = blockHandler;
+ handlers[numHandlers].WakeupHandler = wakeupHandler;
+ handlers[numHandlers].blockData = blockData;
+ handlers[numHandlers].deleted = FALSE;
+ numHandlers = numHandlers + 1;
+ return TRUE;
+}
+
+void
+RemoveBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler,
+ WakeupHandlerProcPtr wakeupHandler,
+ pointer blockData)
+{
+ int i;
+
+ for (i = 0; i < numHandlers; i++)
+ if (handlers[i].BlockHandler == blockHandler &&
+ handlers[i].WakeupHandler == wakeupHandler &&
+ handlers[i].blockData == blockData)
+ {
+ if (inHandler)
+ {
+ handlerDeleted = TRUE;
+ handlers[i].deleted = TRUE;
+ }
+ else
+ {
+ for (; i < numHandlers - 1; i++)
+ handlers[i] = handlers[i+1];
+ numHandlers--;
+ }
+ break;
+ }
+}
+
+void
+InitBlockAndWakeupHandlers ()
+{
+ xfree (handlers);
+ handlers = (BlockHandlerPtr) 0;
+ numHandlers = 0;
+ sizeHandlers = 0;
+}
+
+/*
+ * A general work queue. Perform some task before the server
+ * sleeps for input.
+ */
+
+WorkQueuePtr workQueue;
+static WorkQueuePtr *workQueueLast = &workQueue;
+
+void
+ProcessWorkQueue(void)
+{
+ WorkQueuePtr q, *p;
+
+ p = &workQueue;
+ /*
+ * Scan the work queue once, calling each function. Those
+ * which return TRUE are removed from the queue, otherwise
+ * they will be called again. This must be reentrant with
+ * QueueWorkProc.
+ */
+ while ((q = *p))
+ {
+ if ((*q->function) (q->client, q->closure))
+ {
+ /* remove q from the list */
+ *p = q->next; /* don't fetch until after func called */
+ xfree (q);
+ }
+ else
+ {
+ p = &q->next; /* don't fetch until after func called */
+ }
+ }
+ workQueueLast = p;
+}
+
+void
+ProcessWorkQueueZombies(void)
+{
+ WorkQueuePtr q, *p;
+
+ p = &workQueue;
+ while ((q = *p))
+ {
+ if (q->client && q->client->clientGone)
+ {
+ (void) (*q->function) (q->client, q->closure);
+ /* remove q from the list */
+ *p = q->next; /* don't fetch until after func called */
+ xfree (q);
+ }
+ else
+ {
+ p = &q->next; /* don't fetch until after func called */
+ }
+ }
+ workQueueLast = p;
+}
+
+Bool
+QueueWorkProc (
+ Bool (*function)(ClientPtr /* pClient */, pointer /* closure */),
+ ClientPtr client, pointer closure)
+{
+ WorkQueuePtr q;
+
+ q = (WorkQueuePtr) xalloc (sizeof *q);
+ if (!q)
+ return FALSE;
+ q->function = function;
+ q->client = client;
+ q->closure = closure;
+ q->next = NULL;
+ *workQueueLast = q;
+ workQueueLast = &q->next;
+ return TRUE;
+}
+
+/*
+ * Manage a queue of sleeping clients, awakening them
+ * when requested, by using the OS functions IgnoreClient
+ * and AttendClient. Note that this *ignores* the troubles
+ * with request data interleaving itself with events, but
+ * we'll leave that until a later time.
+ */
+
+typedef struct _SleepQueue {
+ struct _SleepQueue *next;
+ ClientPtr client;
+ ClientSleepProcPtr function;
+ pointer closure;
+} SleepQueueRec, *SleepQueuePtr;
+
+static SleepQueuePtr sleepQueue = NULL;
+
+Bool
+ClientSleep (ClientPtr client, ClientSleepProcPtr function, pointer closure)
+{
+ SleepQueuePtr q;
+
+ q = (SleepQueuePtr) xalloc (sizeof *q);
+ if (!q)
+ return FALSE;
+
+ IgnoreClient (client);
+ q->next = sleepQueue;
+ q->client = client;
+ q->function = function;
+ q->closure = closure;
+ sleepQueue = q;
+ return TRUE;
+}
+
+Bool
+ClientSignal (ClientPtr client)
+{
+ SleepQueuePtr q;
+
+ for (q = sleepQueue; q; q = q->next)
+ if (q->client == client)
+ {
+ return QueueWorkProc (q->function, q->client, q->closure);
+ }
+ return FALSE;
+}
+
+void
+ClientWakeup (ClientPtr client)
+{
+ SleepQueuePtr q, *prev;
+
+ prev = &sleepQueue;
+ while ( (q = *prev) )
+ {
+ if (q->client == client)
+ {
+ *prev = q->next;
+ xfree (q);
+ if (client->clientGone)
+ /* Oops -- new zombie cleanup code ensures this only
+ * happens from inside CloseDownClient; don't want to
+ * recurse here...
+ */
+ /* CloseDownClient(client) */;
+ else
+ AttendClient (client);
+ break;
+ }
+ prev = &q->next;
+ }
+}
+
+Bool
+ClientIsAsleep (ClientPtr client)
+{
+ SleepQueuePtr q;
+
+ for (q = sleepQueue; q; q = q->next)
+ if (q->client == client)
+ return TRUE;
+ return FALSE;
+}
+
+/*
+ * Generic Callback Manager
+ */
+
+/* ===== Private Procedures ===== */
+
+static int numCallbackListsToCleanup = 0;
+static CallbackListPtr **listsToCleanup = NULL;
+
+static Bool
+_AddCallback(
+ CallbackListPtr *pcbl,
+ CallbackProcPtr callback,
+ pointer data)
+{
+ CallbackPtr cbr;
+
+ cbr = (CallbackPtr) xalloc(sizeof(CallbackRec));
+ if (!cbr)
+ return FALSE;
+ cbr->proc = callback;
+ cbr->data = data;
+ cbr->next = (*pcbl)->list;
+ cbr->deleted = FALSE;
+ (*pcbl)->list = cbr;
+ return TRUE;
+}
+
+static Bool
+_DeleteCallback(
+ CallbackListPtr *pcbl,
+ CallbackProcPtr callback,
+ pointer data)
+{
+ CallbackListPtr cbl = *pcbl;
+ CallbackPtr cbr, pcbr;
+
+ for (pcbr = NULL, cbr = cbl->list;
+ cbr != NULL;
+ pcbr = cbr, cbr = cbr->next)
+ {
+ if ((cbr->proc == callback) && (cbr->data == data))
+ break;
+ }
+ if (cbr != NULL)
+ {
+ if (cbl->inCallback)
+ {
+ ++(cbl->numDeleted);
+ cbr->deleted = TRUE;
+ }
+ else
+ {
+ if (pcbr == NULL)
+ cbl->list = cbr->next;
+ else
+ pcbr->next = cbr->next;
+ xfree(cbr);
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static void
+_CallCallbacks(
+ CallbackListPtr *pcbl,
+ pointer call_data)
+{
+ CallbackListPtr cbl = *pcbl;
+ CallbackPtr cbr, pcbr;
+
+ ++(cbl->inCallback);
+ for (cbr = cbl->list; cbr != NULL; cbr = cbr->next)
+ {
+ (*(cbr->proc)) (pcbl, cbr->data, call_data);
+ }
+ --(cbl->inCallback);
+
+ if (cbl->inCallback) return;
+
+ /* Was the entire list marked for deletion? */
+
+ if (cbl->deleted)
+ {
+ DeleteCallbackList(pcbl);
+ return;
+ }
+
+ /* Were some individual callbacks on the list marked for deletion?
+ * If so, do the deletions.
+ */
+
+ if (cbl->numDeleted)
+ {
+ for (pcbr = NULL, cbr = cbl->list; (cbr != NULL) && cbl->numDeleted; )
+ {
+ if (cbr->deleted)
+ {
+ if (pcbr)
+ {
+ cbr = cbr->next;
+ xfree(pcbr->next);
+ pcbr->next = cbr;
+ } else
+ {
+ cbr = cbr->next;
+ xfree(cbl->list);
+ cbl->list = cbr;
+ }
+ cbl->numDeleted--;
+ }
+ else /* this one wasn't deleted */
+ {
+ pcbr = cbr;
+ cbr = cbr->next;
+ }
+ }
+ }
+}
+
+static void
+_DeleteCallbackList(
+ CallbackListPtr *pcbl)
+{
+ CallbackListPtr cbl = *pcbl;
+ CallbackPtr cbr, nextcbr;
+ int i;
+
+ if (cbl->inCallback)
+ {
+ cbl->deleted = TRUE;
+ return;
+ }
+
+ for (i = 0; i < numCallbackListsToCleanup; i++)
+ {
+ if ((listsToCleanup[i] = pcbl) != 0)
+ {
+ listsToCleanup[i] = NULL;
+ break;
+ }
+ }
+
+ for (cbr = cbl->list; cbr != NULL; cbr = nextcbr)
+ {
+ nextcbr = cbr->next;
+ xfree(cbr);
+ }
+ xfree(cbl);
+ *pcbl = NULL;
+}
+
+static CallbackFuncsRec default_cbfuncs =
+{
+ _AddCallback,
+ _DeleteCallback,
+ _CallCallbacks,
+ _DeleteCallbackList
+};
+
+/* ===== Public Procedures ===== */
+
+Bool
+CreateCallbackList(CallbackListPtr *pcbl, CallbackFuncsPtr cbfuncs)
+{
+ CallbackListPtr cbl;
+ int i;
+
+ if (!pcbl) return FALSE;
+ cbl = (CallbackListPtr) xalloc(sizeof(CallbackListRec));
+ if (!cbl) return FALSE;
+ cbl->funcs = cbfuncs ? *cbfuncs : default_cbfuncs;
+ cbl->inCallback = 0;
+ cbl->deleted = FALSE;
+ cbl->numDeleted = 0;
+ cbl->list = NULL;
+ *pcbl = cbl;
+
+ for (i = 0; i < numCallbackListsToCleanup; i++)
+ {
+ if (!listsToCleanup[i])
+ {
+ listsToCleanup[i] = pcbl;
+ return TRUE;
+ }
+ }
+
+ listsToCleanup = (CallbackListPtr **)xnfrealloc(listsToCleanup,
+ sizeof(CallbackListPtr *) * (numCallbackListsToCleanup+1));
+ listsToCleanup[numCallbackListsToCleanup] = pcbl;
+ numCallbackListsToCleanup++;
+ return TRUE;
+}
+
+Bool
+AddCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, pointer data)
+{
+ if (!pcbl) return FALSE;
+ if (!*pcbl)
+ { /* list hasn't been created yet; go create it */
+ if (!CreateCallbackList(pcbl, (CallbackFuncsPtr)NULL))
+ return FALSE;
+ }
+ return ((*(*pcbl)->funcs.AddCallback) (pcbl, callback, data));
+}
+
+Bool
+DeleteCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, pointer data)
+{
+ if (!pcbl || !*pcbl) return FALSE;
+ return ((*(*pcbl)->funcs.DeleteCallback) (pcbl, callback, data));
+}
+
+void
+CallCallbacks(CallbackListPtr *pcbl, pointer call_data)
+{
+ if (!pcbl || !*pcbl) return;
+ (*(*pcbl)->funcs.CallCallbacks) (pcbl, call_data);
+}
+
+void
+DeleteCallbackList(CallbackListPtr *pcbl)
+{
+ if (!pcbl || !*pcbl) return;
+ (*(*pcbl)->funcs.DeleteCallbackList) (pcbl);
+}
+
+void
+InitCallbackManager()
+{
+ int i;
+
+ for (i = 0; i < numCallbackListsToCleanup; i++)
+ {
+ DeleteCallbackList(listsToCleanup[i]);
+ }
+ if (listsToCleanup) xfree(listsToCleanup);
+
+ numCallbackListsToCleanup = 0;
+ listsToCleanup = NULL;
+}
diff --git a/nx-X11/programs/Xserver/dix/events.c b/nx-X11/programs/Xserver/dix/events.c
new file mode 100644
index 000000000..4373673f9
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/events.c
@@ -0,0 +1,4670 @@
+/* $XdotOrg: xc/programs/Xserver/dix/events.c,v 1.17 2005/08/25 22:11:04 anholt Exp $ */
+/* $XFree86: xc/programs/Xserver/dix/events.c,v 3.51 2004/01/12 17:04:52 tsi Exp $ */
+/************************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/* The panoramix components contained the following notice */
+/*****************************************************************
+
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+
+/*****************************************************************
+
+Copyright 2003-2005 Sun Microsystems, Inc.
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+******************************************************************/
+
+/* $Xorg: events.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "resource.h"
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#include "windowstr.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "cursorstr.h"
+
+#include "dixstruct.h"
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+#include "globals.h"
+
+#ifdef XKB
+#include <X11/extensions/XKBsrv.h>
+extern Bool XkbFilterEvents(ClientPtr, int, xEvent *);
+#endif
+
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+
+#ifdef XEVIE
+extern WindowPtr *WindowTable;
+extern int xevieFlag;
+extern int xevieClientIndex;
+extern DeviceIntPtr xeviemouse;
+extern DeviceIntPtr xeviekb;
+extern Mask xevieMask;
+extern Mask xevieFilters[128];
+extern int xevieEventSent;
+extern int xevieKBEventSent;
+int xeviegrabState = 0;
+xEvent *xeviexE;
+#endif
+
+#include <X11/extensions/XIproto.h>
+#include "exevents.h"
+#include "extnsionst.h"
+
+#include "dixevents.h"
+#include "dixgrabs.h"
+#include "dispatch.h"
+
+#define EXTENSION_EVENT_BASE 64
+
+#define NoSuchEvent 0x80000000 /* so doesn't match NoEventMask */
+#define StructureAndSubMask ( StructureNotifyMask | SubstructureNotifyMask )
+#define AllButtonsMask ( \
+ Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask )
+#define MotionMask ( \
+ PointerMotionMask | Button1MotionMask | \
+ Button2MotionMask | Button3MotionMask | Button4MotionMask | \
+ Button5MotionMask | ButtonMotionMask )
+#define PropagateMask ( \
+ KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | \
+ MotionMask )
+#define PointerGrabMask ( \
+ ButtonPressMask | ButtonReleaseMask | \
+ EnterWindowMask | LeaveWindowMask | \
+ PointerMotionHintMask | KeymapStateMask | \
+ MotionMask )
+#define AllModifiersMask ( \
+ ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask | \
+ Mod3Mask | Mod4Mask | Mod5Mask )
+#define AllEventMasks (lastEventMask|(lastEventMask-1))
+/*
+ * The following relies on the fact that the Button<n>MotionMasks are equal
+ * to the corresponding Button<n>Masks from the current modifier/button state.
+ */
+#define Motion_Filter(class) (PointerMotionMask | \
+ (class)->state | (class)->motionMask)
+
+
+#define WID(w) ((w) ? ((w)->drawable.id) : 0)
+
+#define XE_KBPTR (xE->u.keyButtonPointer)
+
+
+#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
+
+CallbackListPtr EventCallback;
+CallbackListPtr DeviceEventCallback;
+
+#define DNPMCOUNT 8
+
+Mask DontPropagateMasks[DNPMCOUNT];
+static int DontPropagateRefCnts[DNPMCOUNT];
+
+#ifdef DEBUG
+static debug_events = 0;
+#endif
+InputInfo inputInfo;
+
+static struct {
+ QdEventPtr pending, *pendtail;
+ DeviceIntPtr replayDev; /* kludgy rock to put flag for */
+ WindowPtr replayWin; /* ComputeFreezes */
+ Bool playingEvents;
+ TimeStamp time;
+} syncEvents;
+
+/*
+ * The window trace information is used to avoid having to compute all the
+ * windows between the root and the current pointer window each time a button
+ * or key goes down. The grabs on each of those windows must be checked.
+ */
+static WindowPtr *spriteTrace = (WindowPtr *)NULL;
+#define ROOT spriteTrace[0]
+static int spriteTraceSize = 0;
+static int spriteTraceGood;
+
+static struct {
+ CursorPtr current;
+ BoxRec hotLimits; /* logical constraints of hot spot */
+ Bool confined; /* confined to screen */
+#if defined(SHAPE) || defined(PANORAMIX)
+ RegionPtr hotShape; /* additional logical shape constraint */
+#endif
+ BoxRec physLimits; /* physical constraints of hot spot */
+ WindowPtr win; /* window of logical position */
+ HotSpot hot; /* logical pointer position */
+ HotSpot hotPhys; /* physical pointer position */
+#ifdef PANORAMIX
+ ScreenPtr screen; /* all others are in Screen 0 coordinates */
+ RegionRec Reg1; /* Region 1 for confining motion */
+ RegionRec Reg2; /* Region 2 for confining virtual motion */
+ WindowPtr windows[MAXSCREENS];
+ WindowPtr confineWin; /* confine window */
+#endif
+} sprite; /* info about the cursor sprite */
+
+#ifdef XEVIE
+WindowPtr xeviewin;
+HotSpot xeviehot;
+#endif
+
+static void DoEnterLeaveEvents(
+ WindowPtr fromWin,
+ WindowPtr toWin,
+ int mode
+);
+
+static WindowPtr XYToWindow(
+ int x,
+ int y
+);
+
+extern int lastEvent;
+
+static Mask lastEventMask;
+
+#ifdef XINPUT
+extern int DeviceMotionNotify;
+#endif
+
+#define CantBeFiltered NoEventMask
+static Mask filters[128] =
+{
+ NoSuchEvent, /* 0 */
+ NoSuchEvent, /* 1 */
+ KeyPressMask, /* KeyPress */
+ KeyReleaseMask, /* KeyRelease */
+ ButtonPressMask, /* ButtonPress */
+ ButtonReleaseMask, /* ButtonRelease */
+ PointerMotionMask, /* MotionNotify (initial state) */
+ EnterWindowMask, /* EnterNotify */
+ LeaveWindowMask, /* LeaveNotify */
+ FocusChangeMask, /* FocusIn */
+ FocusChangeMask, /* FocusOut */
+ KeymapStateMask, /* KeymapNotify */
+ ExposureMask, /* Expose */
+ CantBeFiltered, /* GraphicsExpose */
+ CantBeFiltered, /* NoExpose */
+ VisibilityChangeMask, /* VisibilityNotify */
+ SubstructureNotifyMask, /* CreateNotify */
+ StructureAndSubMask, /* DestroyNotify */
+ StructureAndSubMask, /* UnmapNotify */
+ StructureAndSubMask, /* MapNotify */
+ SubstructureRedirectMask, /* MapRequest */
+ StructureAndSubMask, /* ReparentNotify */
+ StructureAndSubMask, /* ConfigureNotify */
+ SubstructureRedirectMask, /* ConfigureRequest */
+ StructureAndSubMask, /* GravityNotify */
+ ResizeRedirectMask, /* ResizeRequest */
+ StructureAndSubMask, /* CirculateNotify */
+ SubstructureRedirectMask, /* CirculateRequest */
+ PropertyChangeMask, /* PropertyNotify */
+ CantBeFiltered, /* SelectionClear */
+ CantBeFiltered, /* SelectionRequest */
+ CantBeFiltered, /* SelectionNotify */
+ ColormapChangeMask, /* ColormapNotify */
+ CantBeFiltered, /* ClientMessage */
+ CantBeFiltered /* MappingNotify */
+};
+
+static CARD8 criticalEvents[32] =
+{
+ 0x7c /* key and button events */
+};
+
+#ifdef PANORAMIX
+
+static void ConfineToShape(RegionPtr shape, int *px, int *py);
+static void SyntheticMotion(int x, int y);
+static void PostNewCursor(void);
+
+static Bool
+XineramaSetCursorPosition(
+ int x,
+ int y,
+ Bool generateEvent
+){
+ ScreenPtr pScreen;
+ BoxRec box;
+ int i;
+
+ /* x,y are in Screen 0 coordinates. We need to decide what Screen
+ to send the message too and what the coordinates relative to
+ that screen are. */
+
+ pScreen = sprite.screen;
+ x += panoramiXdataPtr[0].x;
+ y += panoramiXdataPtr[0].y;
+
+ if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
+ x, y, &box))
+ {
+ FOR_NSCREENS(i)
+ {
+ if(i == pScreen->myNum)
+ continue;
+ if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i], x, y, &box))
+ {
+ pScreen = screenInfo.screens[i];
+ break;
+ }
+ }
+ }
+
+ sprite.screen = pScreen;
+ sprite.hotPhys.x = x - panoramiXdataPtr[0].x;
+ sprite.hotPhys.y = y - panoramiXdataPtr[0].y;
+ x -= panoramiXdataPtr[pScreen->myNum].x;
+ y -= panoramiXdataPtr[pScreen->myNum].y;
+
+ return (*pScreen->SetCursorPosition)(pScreen, x, y, generateEvent);
+}
+
+
+static void
+XineramaConstrainCursor(void)
+{
+ ScreenPtr pScreen = sprite.screen;
+ BoxRec newBox = sprite.physLimits;
+
+ /* Translate the constraining box to the screen
+ the sprite is actually on */
+ newBox.x1 += panoramiXdataPtr[0].x - panoramiXdataPtr[pScreen->myNum].x;
+ newBox.x2 += panoramiXdataPtr[0].x - panoramiXdataPtr[pScreen->myNum].x;
+ newBox.y1 += panoramiXdataPtr[0].y - panoramiXdataPtr[pScreen->myNum].y;
+ newBox.y2 += panoramiXdataPtr[0].y - panoramiXdataPtr[pScreen->myNum].y;
+
+ (* pScreen->ConstrainCursor)(pScreen, &newBox);
+}
+
+static void
+XineramaCheckPhysLimits(
+ CursorPtr cursor,
+ Bool generateEvents
+){
+ HotSpot new;
+
+ if (!cursor)
+ return;
+
+ new = sprite.hotPhys;
+
+ /* I don't care what the DDX has to say about it */
+ sprite.physLimits = sprite.hotLimits;
+
+ /* constrain the pointer to those limits */
+ if (new.x < sprite.physLimits.x1)
+ new.x = sprite.physLimits.x1;
+ else
+ if (new.x >= sprite.physLimits.x2)
+ new.x = sprite.physLimits.x2 - 1;
+ if (new.y < sprite.physLimits.y1)
+ new.y = sprite.physLimits.y1;
+ else
+ if (new.y >= sprite.physLimits.y2)
+ new.y = sprite.physLimits.y2 - 1;
+
+ if (sprite.hotShape) /* more work if the shape is a mess */
+ ConfineToShape(sprite.hotShape, &new.x, &new.y);
+
+ if((new.x != sprite.hotPhys.x) || (new.y != sprite.hotPhys.y))
+ {
+ XineramaSetCursorPosition (new.x, new.y, generateEvents);
+ if (!generateEvents)
+ SyntheticMotion(new.x, new.y);
+ }
+
+ /* Tell DDX what the limits are */
+ XineramaConstrainCursor();
+}
+
+
+static Bool
+XineramaSetWindowPntrs(WindowPtr pWin)
+{
+ if(pWin == WindowTable[0]) {
+ memcpy(sprite.windows, WindowTable,
+ PanoramiXNumScreens*sizeof(WindowPtr));
+ } else {
+ PanoramiXRes *win;
+ int i;
+
+ win = (PanoramiXRes*)LookupIDByType(pWin->drawable.id, XRT_WINDOW);
+
+ if(!win)
+ return FALSE;
+
+ for(i = 0; i < PanoramiXNumScreens; i++) {
+ sprite.windows[i] = LookupIDByType(win->info[i].id, RT_WINDOW);
+ if(!sprite.windows[i]) /* window is being unmapped */
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+static void
+XineramaCheckVirtualMotion(
+ QdEventPtr qe,
+ WindowPtr pWin
+){
+
+ if (qe)
+ {
+ sprite.hot.pScreen = qe->pScreen; /* should always be Screen 0 */
+#ifdef XEVIE
+ xeviehot.x =
+#endif
+ sprite.hot.x = qe->event->u.keyButtonPointer.rootX;
+#ifdef XEVIE
+ xeviehot.y =
+#endif
+ sprite.hot.y = qe->event->u.keyButtonPointer.rootY;
+ pWin = inputInfo.pointer->grab ? inputInfo.pointer->grab->confineTo :
+ NullWindow;
+ }
+ if (pWin)
+ {
+ int x, y, off_x, off_y, i;
+ BoxRec lims;
+
+ if(!XineramaSetWindowPntrs(pWin))
+ return;
+
+ i = PanoramiXNumScreens - 1;
+
+ REGION_COPY(sprite.screen, &sprite.Reg2,
+ &sprite.windows[i]->borderSize);
+ off_x = panoramiXdataPtr[i].x;
+ off_y = panoramiXdataPtr[i].y;
+
+ while(i--) {
+ x = off_x - panoramiXdataPtr[i].x;
+ y = off_y - panoramiXdataPtr[i].y;
+
+ if(x || y)
+ REGION_TRANSLATE(sprite.screen, &sprite.Reg2, x, y);
+
+ REGION_UNION(sprite.screen, &sprite.Reg2, &sprite.Reg2,
+ &sprite.windows[i]->borderSize);
+
+ off_x = panoramiXdataPtr[i].x;
+ off_y = panoramiXdataPtr[i].y;
+ }
+
+ lims = *REGION_EXTENTS(sprite.screen, &sprite.Reg2);
+
+ if (sprite.hot.x < lims.x1)
+#ifdef XEVIE
+ xeviehot.x =
+#endif
+ sprite.hot.x = lims.x1;
+ else if (sprite.hot.x >= lims.x2)
+#ifdef XEVIE
+ xeviehot.x =
+#endif
+ sprite.hot.x = lims.x2 - 1;
+ if (sprite.hot.y < lims.y1)
+#ifdef XEVIE
+ xeviehot.y =
+#endif
+ sprite.hot.y = lims.y1;
+ else if (sprite.hot.y >= lims.y2)
+#ifdef XEVIE
+ xeviehot.y =
+#endif
+ sprite.hot.y = lims.y2 - 1;
+
+ if (REGION_NUM_RECTS(&sprite.Reg2) > 1)
+ ConfineToShape(&sprite.Reg2, &sprite.hot.x, &sprite.hot.y);
+
+ if (qe)
+ {
+ qe->pScreen = sprite.hot.pScreen;
+ qe->event->u.keyButtonPointer.rootX = sprite.hot.x;
+ qe->event->u.keyButtonPointer.rootY = sprite.hot.y;
+ }
+ }
+}
+
+
+static Bool
+XineramaCheckMotion(xEvent *xE)
+{
+ WindowPtr prevSpriteWin = sprite.win;
+
+ if (xE && !syncEvents.playingEvents)
+ {
+ /* Motion events entering DIX get translated to Screen 0
+ coordinates. Replayed events have already been
+ translated since they've entered DIX before */
+ XE_KBPTR.rootX += panoramiXdataPtr[sprite.screen->myNum].x -
+ panoramiXdataPtr[0].x;
+ XE_KBPTR.rootY += panoramiXdataPtr[sprite.screen->myNum].y -
+ panoramiXdataPtr[0].y;
+#ifdef XEVIE
+ xeviehot.x =
+#endif
+ sprite.hot.x = XE_KBPTR.rootX;
+#ifdef XEVIE
+ xeviehot.y =
+#endif
+ sprite.hot.y = XE_KBPTR.rootY;
+ if (sprite.hot.x < sprite.physLimits.x1)
+#ifdef XEVIE
+ xeviehot.x =
+#endif
+ sprite.hot.x = sprite.physLimits.x1;
+ else if (sprite.hot.x >= sprite.physLimits.x2)
+#ifdef XEVIE
+ xeviehot.x =
+#endif
+ sprite.hot.x = sprite.physLimits.x2 - 1;
+ if (sprite.hot.y < sprite.physLimits.y1)
+#ifdef XEVIE
+ xeviehot.y =
+#endif
+ sprite.hot.y = sprite.physLimits.y1;
+ else if (sprite.hot.y >= sprite.physLimits.y2)
+#ifdef XEVIE
+ xeviehot.y =
+#endif
+ sprite.hot.y = sprite.physLimits.y2 - 1;
+
+ if (sprite.hotShape)
+ ConfineToShape(sprite.hotShape, &sprite.hot.x, &sprite.hot.y);
+
+ sprite.hotPhys = sprite.hot;
+ if ((sprite.hotPhys.x != XE_KBPTR.rootX) ||
+ (sprite.hotPhys.y != XE_KBPTR.rootY))
+ {
+ XineramaSetCursorPosition(
+ sprite.hotPhys.x, sprite.hotPhys.y, FALSE);
+ }
+ XE_KBPTR.rootX = sprite.hot.x;
+ XE_KBPTR.rootY = sprite.hot.y;
+ }
+
+#ifdef XEVIE
+ xeviewin =
+#endif
+ sprite.win = XYToWindow(sprite.hot.x, sprite.hot.y);
+
+ if (sprite.win != prevSpriteWin)
+ {
+ if (prevSpriteWin != NullWindow) {
+ if (!xE)
+ UpdateCurrentTimeIf();
+ DoEnterLeaveEvents(prevSpriteWin, sprite.win, NotifyNormal);
+ }
+ PostNewCursor();
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+static void
+XineramaConfineCursorToWindow(WindowPtr pWin, Bool generateEvents)
+{
+
+ if (syncEvents.playingEvents)
+ {
+ XineramaCheckVirtualMotion((QdEventPtr)NULL, pWin);
+ SyntheticMotion(sprite.hot.x, sprite.hot.y);
+ }
+ else
+ {
+ int x, y, off_x, off_y, i;
+
+ if(!XineramaSetWindowPntrs(pWin))
+ return;
+
+ i = PanoramiXNumScreens - 1;
+
+ REGION_COPY(sprite.screen, &sprite.Reg1,
+ &sprite.windows[i]->borderSize);
+ off_x = panoramiXdataPtr[i].x;
+ off_y = panoramiXdataPtr[i].y;
+
+ while(i--) {
+ x = off_x - panoramiXdataPtr[i].x;
+ y = off_y - panoramiXdataPtr[i].y;
+
+ if(x || y)
+ REGION_TRANSLATE(sprite.screen, &sprite.Reg1, x, y);
+
+ REGION_UNION(sprite.screen, &sprite.Reg1, &sprite.Reg1,
+ &sprite.windows[i]->borderSize);
+
+ off_x = panoramiXdataPtr[i].x;
+ off_y = panoramiXdataPtr[i].y;
+ }
+
+ sprite.hotLimits = *REGION_EXTENTS(sprite.screen, &sprite.Reg1);
+
+ if(REGION_NUM_RECTS(&sprite.Reg1) > 1)
+ sprite.hotShape = &sprite.Reg1;
+ else
+ sprite.hotShape = NullRegion;
+
+ sprite.confined = FALSE;
+ sprite.confineWin = (pWin == WindowTable[0]) ? NullWindow : pWin;
+
+ XineramaCheckPhysLimits(sprite.current, generateEvents);
+ }
+}
+
+
+static void
+XineramaChangeToCursor(CursorPtr cursor)
+{
+ if (cursor != sprite.current)
+ {
+ if ((sprite.current->bits->xhot != cursor->bits->xhot) ||
+ (sprite.current->bits->yhot != cursor->bits->yhot))
+ XineramaCheckPhysLimits(cursor, FALSE);
+ (*sprite.screen->DisplayCursor)(sprite.screen, cursor);
+ FreeCursor(sprite.current, (Cursor)0);
+ sprite.current = cursor;
+ sprite.current->refcnt++;
+ }
+}
+
+
+#endif /* PANORAMIX */
+
+void
+SetMaskForEvent(Mask mask, int event)
+{
+ if ((event < LASTEvent) || (event >= 128))
+ FatalError("SetMaskForEvent: bogus event number");
+ filters[event] = mask;
+}
+
+void
+SetCriticalEvent(int event)
+{
+ if (event >= 128)
+ FatalError("SetCriticalEvent: bogus event number");
+ criticalEvents[event >> 3] |= 1 << (event & 7);
+}
+
+static void
+SyntheticMotion(int x, int y)
+{
+ xEvent xE;
+
+#ifdef PANORAMIX
+ /* Translate back to the sprite screen since processInputProc
+ will translate from sprite screen to screen 0 upon reentry
+ to the DIX layer */
+ if(!noPanoramiXExtension) {
+ x += panoramiXdataPtr[0].x - panoramiXdataPtr[sprite.screen->myNum].x;
+ y += panoramiXdataPtr[0].y - panoramiXdataPtr[sprite.screen->myNum].y;
+ }
+#endif
+ xE.u.keyButtonPointer.rootX = x;
+ xE.u.keyButtonPointer.rootY = y;
+ if (syncEvents.playingEvents)
+ xE.u.keyButtonPointer.time = syncEvents.time.milliseconds;
+ else
+ xE.u.keyButtonPointer.time = currentTime.milliseconds;
+ xE.u.u.type = MotionNotify;
+ (*inputInfo.pointer->public.processInputProc)(&xE, inputInfo.pointer, 1);
+}
+
+#ifdef SHAPE
+static void
+ConfineToShape(RegionPtr shape, int *px, int *py)
+{
+ BoxRec box;
+ int x = *px, y = *py;
+ int incx = 1, incy = 1;
+
+ if (POINT_IN_REGION(sprite.hot.pScreen, shape, x, y, &box))
+ return;
+ box = *REGION_EXTENTS(sprite.hot.pScreen, shape);
+ /* this is rather crude */
+ do {
+ x += incx;
+ if (x >= box.x2)
+ {
+ incx = -1;
+ x = *px - 1;
+ }
+ else if (x < box.x1)
+ {
+ incx = 1;
+ x = *px;
+ y += incy;
+ if (y >= box.y2)
+ {
+ incy = -1;
+ y = *py - 1;
+ }
+ else if (y < box.y1)
+ return; /* should never get here! */
+ }
+ } while (!POINT_IN_REGION(sprite.hot.pScreen, shape, x, y, &box));
+ *px = x;
+ *py = y;
+}
+#endif
+
+static void
+CheckPhysLimits(
+ CursorPtr cursor,
+ Bool generateEvents,
+ Bool confineToScreen,
+ ScreenPtr pScreen)
+{
+ HotSpot new;
+
+ if (!cursor)
+ return;
+ new = sprite.hotPhys;
+ if (pScreen)
+ new.pScreen = pScreen;
+ else
+ pScreen = new.pScreen;
+ (*pScreen->CursorLimits) (pScreen, cursor, &sprite.hotLimits,
+ &sprite.physLimits);
+ sprite.confined = confineToScreen;
+ (* pScreen->ConstrainCursor)(pScreen, &sprite.physLimits);
+ if (new.x < sprite.physLimits.x1)
+ new.x = sprite.physLimits.x1;
+ else
+ if (new.x >= sprite.physLimits.x2)
+ new.x = sprite.physLimits.x2 - 1;
+ if (new.y < sprite.physLimits.y1)
+ new.y = sprite.physLimits.y1;
+ else
+ if (new.y >= sprite.physLimits.y2)
+ new.y = sprite.physLimits.y2 - 1;
+#ifdef SHAPE
+ if (sprite.hotShape)
+ ConfineToShape(sprite.hotShape, &new.x, &new.y);
+#endif
+ if ((pScreen != sprite.hotPhys.pScreen) ||
+ (new.x != sprite.hotPhys.x) || (new.y != sprite.hotPhys.y))
+ {
+ if (pScreen != sprite.hotPhys.pScreen)
+ sprite.hotPhys = new;
+ (*pScreen->SetCursorPosition) (pScreen, new.x, new.y, generateEvents);
+ if (!generateEvents)
+ SyntheticMotion(new.x, new.y);
+ }
+}
+
+static void
+CheckVirtualMotion(
+ register QdEventPtr qe,
+ register WindowPtr pWin)
+{
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ XineramaCheckVirtualMotion(qe, pWin);
+ return;
+ }
+#endif
+ if (qe)
+ {
+ sprite.hot.pScreen = qe->pScreen;
+#ifdef XEVIE
+ xeviehot.x =
+#endif
+ sprite.hot.x = qe->event->u.keyButtonPointer.rootX;
+#ifdef XEVIE
+ xeviehot.y =
+#endif
+ sprite.hot.y = qe->event->u.keyButtonPointer.rootY;
+ pWin = inputInfo.pointer->grab ? inputInfo.pointer->grab->confineTo :
+ NullWindow;
+ }
+ if (pWin)
+ {
+ BoxRec lims;
+
+ if (sprite.hot.pScreen != pWin->drawable.pScreen)
+ {
+ sprite.hot.pScreen = pWin->drawable.pScreen;
+#ifdef XEVIE
+ xeviehot.x = xeviehot.y = 0;
+#endif
+ sprite.hot.x = sprite.hot.y = 0;
+ }
+ lims = *REGION_EXTENTS(pWin->drawable.pScreen, &pWin->borderSize);
+ if (sprite.hot.x < lims.x1)
+#ifdef XEVIE
+ xeviehot.x =
+#endif
+ sprite.hot.x = lims.x1;
+ else if (sprite.hot.x >= lims.x2)
+#ifdef XEVIE
+ xeviehot.x =
+#endif
+ sprite.hot.x = lims.x2 - 1;
+ if (sprite.hot.y < lims.y1)
+#ifdef XEVIE
+ xeviehot.y =
+#endif
+ sprite.hot.y = lims.y1;
+ else if (sprite.hot.y >= lims.y2)
+#ifdef XEVIE
+ xeviehot.y =
+#endif
+ sprite.hot.y = lims.y2 - 1;
+#ifdef SHAPE
+ if (wBoundingShape(pWin))
+ ConfineToShape(&pWin->borderSize, &sprite.hot.x, &sprite.hot.y);
+#endif
+ if (qe)
+ {
+ qe->pScreen = sprite.hot.pScreen;
+ qe->event->u.keyButtonPointer.rootX = sprite.hot.x;
+ qe->event->u.keyButtonPointer.rootY = sprite.hot.y;
+ }
+ }
+ ROOT = WindowTable[sprite.hot.pScreen->myNum];
+}
+
+static void
+ConfineCursorToWindow(WindowPtr pWin, Bool generateEvents, Bool confineToScreen)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ XineramaConfineCursorToWindow(pWin, generateEvents);
+ return;
+ }
+#endif
+
+ if (syncEvents.playingEvents)
+ {
+ CheckVirtualMotion((QdEventPtr)NULL, pWin);
+ SyntheticMotion(sprite.hot.x, sprite.hot.y);
+ }
+ else
+ {
+ sprite.hotLimits = *REGION_EXTENTS( pScreen, &pWin->borderSize);
+#ifdef SHAPE
+ sprite.hotShape = wBoundingShape(pWin) ? &pWin->borderSize
+ : NullRegion;
+#endif
+ CheckPhysLimits(sprite.current, generateEvents, confineToScreen,
+ pScreen);
+ }
+}
+
+Bool
+PointerConfinedToScreen()
+{
+ return sprite.confined;
+}
+
+static void
+ChangeToCursor(CursorPtr cursor)
+{
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ XineramaChangeToCursor(cursor);
+ return;
+ }
+#endif
+
+ if (cursor != sprite.current)
+ {
+ if ((sprite.current->bits->xhot != cursor->bits->xhot) ||
+ (sprite.current->bits->yhot != cursor->bits->yhot))
+ CheckPhysLimits(cursor, FALSE, sprite.confined,
+ (ScreenPtr)NULL);
+ (*sprite.hotPhys.pScreen->DisplayCursor) (sprite.hotPhys.pScreen,
+ cursor);
+ FreeCursor(sprite.current, (Cursor)0);
+ sprite.current = cursor;
+ sprite.current->refcnt++;
+ }
+}
+
+/* returns true if b is a descendent of a */
+Bool
+IsParent(register WindowPtr a, register WindowPtr b)
+{
+ for (b = b->parent; b; b = b->parent)
+ if (b == a) return TRUE;
+ return FALSE;
+}
+
+static void
+PostNewCursor(void)
+{
+ register WindowPtr win;
+ register GrabPtr grab = inputInfo.pointer->grab;
+
+ if (syncEvents.playingEvents)
+ return;
+ if (grab)
+ {
+ if (grab->cursor)
+ {
+ ChangeToCursor(grab->cursor);
+ return;
+ }
+ if (IsParent(grab->window, sprite.win))
+ win = sprite.win;
+ else
+ win = grab->window;
+ }
+ else
+ win = sprite.win;
+ for (; win; win = win->parent)
+ if (win->optional && win->optional->cursor != NullCursor)
+ {
+ ChangeToCursor(win->optional->cursor);
+ return;
+ }
+}
+
+WindowPtr
+GetCurrentRootWindow()
+{
+ return ROOT;
+}
+
+WindowPtr
+GetSpriteWindow()
+{
+ return sprite.win;
+}
+
+CursorPtr
+GetSpriteCursor()
+{
+ return sprite.current;
+}
+
+void
+GetSpritePosition(int *px, int *py)
+{
+ *px = sprite.hotPhys.x;
+ *py = sprite.hotPhys.y;
+}
+
+#ifdef PANORAMIX
+int
+XineramaGetCursorScreen()
+{
+ if(!noPanoramiXExtension) {
+ return sprite.screen->myNum;
+ } else {
+ return 0;
+ }
+}
+#endif /* PANORAMIX */
+
+#define TIMESLOP (5 * 60 * 1000) /* 5 minutes */
+
+static void
+MonthChangedOrBadTime(register xEvent *xE)
+{
+ /* If the ddx/OS is careless about not processing timestamped events from
+ * different sources in sorted order, then it's possible for time to go
+ * backwards when it should not. Here we ensure a decent time.
+ */
+ if ((currentTime.milliseconds - XE_KBPTR.time) > TIMESLOP)
+ currentTime.months++;
+ else
+ XE_KBPTR.time = currentTime.milliseconds;
+}
+
+#define NoticeTime(xE) { \
+ if ((xE)->u.keyButtonPointer.time < currentTime.milliseconds) \
+ MonthChangedOrBadTime(xE); \
+ currentTime.milliseconds = (xE)->u.keyButtonPointer.time; \
+ lastDeviceEventTime = currentTime; }
+
+void
+NoticeEventTime(register xEvent *xE)
+{
+ if (!syncEvents.playingEvents)
+ NoticeTime(xE);
+}
+
+/**************************************************************************
+ * The following procedures deal with synchronous events *
+ **************************************************************************/
+
+void
+EnqueueEvent(xEvent *xE, DeviceIntPtr device, int count)
+{
+ register QdEventPtr tail = *syncEvents.pendtail;
+ register QdEventPtr qe;
+ xEvent *qxE;
+
+ NoticeTime(xE);
+
+#ifdef XKB
+ /* Fix for key repeating bug. */
+ if (device->key != NULL && device->key->xkbInfo != NULL &&
+ xE->u.u.type == KeyRelease)
+ AccessXCancelRepeatKey(device->key->xkbInfo, xE->u.u.detail);
+#endif
+
+ if (DeviceEventCallback)
+ {
+ DeviceEventInfoRec eventinfo;
+ /* The RECORD spec says that the root window field of motion events
+ * must be valid. At this point, it hasn't been filled in yet, so
+ * we do it here. The long expression below is necessary to get
+ * the current root window; the apparently reasonable alternative
+ * GetCurrentRootWindow()->drawable.id doesn't give you the right
+ * answer on the first motion event after a screen change because
+ * the data that GetCurrentRootWindow relies on hasn't been
+ * updated yet.
+ */
+ if (xE->u.u.type == MotionNotify)
+ XE_KBPTR.root =
+ WindowTable[sprite.hotPhys.pScreen->myNum]->drawable.id;
+ eventinfo.events = xE;
+ eventinfo.count = count;
+ CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo);
+ }
+ if (xE->u.u.type == MotionNotify)
+ {
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ XE_KBPTR.rootX += panoramiXdataPtr[sprite.screen->myNum].x -
+ panoramiXdataPtr[0].x;
+ XE_KBPTR.rootY += panoramiXdataPtr[sprite.screen->myNum].y -
+ panoramiXdataPtr[0].y;
+ }
+#endif
+ sprite.hotPhys.x = XE_KBPTR.rootX;
+ sprite.hotPhys.y = XE_KBPTR.rootY;
+ /* do motion compression */
+ if (tail &&
+ (tail->event->u.u.type == MotionNotify) &&
+ (tail->pScreen == sprite.hotPhys.pScreen))
+ {
+ tail->event->u.keyButtonPointer.rootX = sprite.hotPhys.x;
+ tail->event->u.keyButtonPointer.rootY = sprite.hotPhys.y;
+ tail->event->u.keyButtonPointer.time = XE_KBPTR.time;
+ tail->months = currentTime.months;
+ return;
+ }
+ }
+ qe = (QdEventPtr)xalloc(sizeof(QdEventRec) + (count * sizeof(xEvent)));
+ if (!qe)
+ return;
+ qe->next = (QdEventPtr)NULL;
+ qe->device = device;
+ qe->pScreen = sprite.hotPhys.pScreen;
+ qe->months = currentTime.months;
+ qe->event = (xEvent *)(qe + 1);
+ qe->evcount = count;
+ for (qxE = qe->event; --count >= 0; qxE++, xE++)
+ *qxE = *xE;
+ if (tail)
+ syncEvents.pendtail = &tail->next;
+ *syncEvents.pendtail = qe;
+}
+
+static void
+PlayReleasedEvents(void)
+{
+ register QdEventPtr *prev, qe;
+ register DeviceIntPtr dev;
+
+ prev = &syncEvents.pending;
+ while ( (qe = *prev) )
+ {
+ if (!qe->device->sync.frozen)
+ {
+ *prev = qe->next;
+ if (*syncEvents.pendtail == *prev)
+ syncEvents.pendtail = prev;
+ if (qe->event->u.u.type == MotionNotify)
+ CheckVirtualMotion(qe, NullWindow);
+ syncEvents.time.months = qe->months;
+ syncEvents.time.milliseconds = qe->event->u.keyButtonPointer.time;
+#ifdef PANORAMIX
+ /* Translate back to the sprite screen since processInputProc
+ will translate from sprite screen to screen 0 upon reentry
+ to the DIX layer */
+ if(!noPanoramiXExtension) {
+ qe->event->u.keyButtonPointer.rootX +=
+ panoramiXdataPtr[0].x -
+ panoramiXdataPtr[sprite.screen->myNum].x;
+ qe->event->u.keyButtonPointer.rootY +=
+ panoramiXdataPtr[0].y -
+ panoramiXdataPtr[sprite.screen->myNum].y;
+ }
+#endif
+ (*qe->device->public.processInputProc)(qe->event, qe->device,
+ qe->evcount);
+ xfree(qe);
+ for (dev = inputInfo.devices; dev && dev->sync.frozen; dev = dev->next)
+ ;
+ if (!dev)
+ break;
+ /* Playing the event may have unfrozen another device. */
+ /* So to play it safe, restart at the head of the queue */
+ prev = &syncEvents.pending;
+ }
+ else
+ prev = &qe->next;
+ }
+}
+
+static void
+FreezeThaw(register DeviceIntPtr dev, Bool frozen)
+{
+ dev->sync.frozen = frozen;
+ if (frozen)
+ dev->public.processInputProc = dev->public.enqueueInputProc;
+ else
+ dev->public.processInputProc = dev->public.realInputProc;
+}
+
+void
+ComputeFreezes()
+{
+ register DeviceIntPtr replayDev = syncEvents.replayDev;
+ register int i;
+ WindowPtr w;
+ register xEvent *xE;
+ int count;
+ GrabPtr grab;
+ register DeviceIntPtr dev;
+
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ FreezeThaw(dev, dev->sync.other || (dev->sync.state >= FROZEN));
+ if (syncEvents.playingEvents || (!replayDev && !syncEvents.pending))
+ return;
+ syncEvents.playingEvents = TRUE;
+ if (replayDev)
+ {
+ xE = replayDev->sync.event;
+ count = replayDev->sync.evcount;
+ syncEvents.replayDev = (DeviceIntPtr)NULL;
+
+ w = XYToWindow( XE_KBPTR.rootX, XE_KBPTR.rootY);
+ for (i = 0; i < spriteTraceGood; i++)
+ {
+ if (syncEvents.replayWin == spriteTrace[i])
+ {
+ if (!CheckDeviceGrabs(replayDev, xE, i+1, count)) {
+ if (replayDev->focus)
+ DeliverFocusedEvent(replayDev, xE, w, count);
+ else
+ DeliverDeviceEvents(w, xE, NullGrab, NullWindow,
+ replayDev, count);
+ }
+ goto playmore;
+ }
+ }
+ /* must not still be in the same stack */
+ if (replayDev->focus)
+ DeliverFocusedEvent(replayDev, xE, w, count);
+ else
+ DeliverDeviceEvents(w, xE, NullGrab, NullWindow, replayDev, count);
+ }
+playmore:
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (!dev->sync.frozen)
+ {
+ PlayReleasedEvents();
+ break;
+ }
+ }
+ syncEvents.playingEvents = FALSE;
+ /* the following may have been skipped during replay, so do it now */
+ if ((grab = inputInfo.pointer->grab) && grab->confineTo)
+ {
+ if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen)
+ sprite.hotPhys.x = sprite.hotPhys.y = 0;
+ ConfineCursorToWindow(grab->confineTo, TRUE, TRUE);
+ }
+ else
+ ConfineCursorToWindow(WindowTable[sprite.hotPhys.pScreen->myNum],
+ TRUE, FALSE);
+ PostNewCursor();
+}
+
+#ifdef RANDR
+void
+ScreenRestructured (ScreenPtr pScreen)
+{
+ GrabPtr grab;
+
+ if ((grab = inputInfo.pointer->grab) && grab->confineTo)
+ {
+ if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen)
+ sprite.hotPhys.x = sprite.hotPhys.y = 0;
+ ConfineCursorToWindow(grab->confineTo, TRUE, TRUE);
+ }
+ else
+ ConfineCursorToWindow(WindowTable[sprite.hotPhys.pScreen->myNum],
+ TRUE, FALSE);
+}
+#endif
+
+void
+CheckGrabForSyncs(register DeviceIntPtr thisDev, Bool thisMode, Bool otherMode)
+{
+ register GrabPtr grab = thisDev->grab;
+ register DeviceIntPtr dev;
+
+ if (thisMode == GrabModeSync)
+ thisDev->sync.state = FROZEN_NO_EVENT;
+ else
+ { /* free both if same client owns both */
+ thisDev->sync.state = THAWED;
+ if (thisDev->sync.other &&
+ (CLIENT_BITS(thisDev->sync.other->resource) ==
+ CLIENT_BITS(grab->resource)))
+ thisDev->sync.other = NullGrab;
+ }
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (dev != thisDev)
+ {
+ if (otherMode == GrabModeSync)
+ dev->sync.other = grab;
+ else
+ { /* free both if same client owns both */
+ if (dev->sync.other &&
+ (CLIENT_BITS(dev->sync.other->resource) ==
+ CLIENT_BITS(grab->resource)))
+ dev->sync.other = NullGrab;
+ }
+ }
+ }
+ ComputeFreezes();
+}
+
+void
+ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab,
+ TimeStamp time, Bool autoGrab)
+{
+ WindowPtr oldWin = (mouse->grab) ? mouse->grab->window
+ : sprite.win;
+
+ if (grab->confineTo)
+ {
+ if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen)
+ sprite.hotPhys.x = sprite.hotPhys.y = 0;
+ ConfineCursorToWindow(grab->confineTo, FALSE, TRUE);
+ }
+ DoEnterLeaveEvents(oldWin, grab->window, NotifyGrab);
+ mouse->valuator->motionHintWindow = NullWindow;
+ if (syncEvents.playingEvents)
+ mouse->grabTime = syncEvents.time;
+ else
+ mouse->grabTime = time;
+ if (grab->cursor)
+ grab->cursor->refcnt++;
+ mouse->activeGrab = *grab;
+ mouse->grab = &mouse->activeGrab;
+ mouse->fromPassiveGrab = autoGrab;
+ PostNewCursor();
+ CheckGrabForSyncs(mouse,(Bool)grab->pointerMode, (Bool)grab->keyboardMode);
+}
+
+void
+DeactivatePointerGrab(register DeviceIntPtr mouse)
+{
+ register GrabPtr grab = mouse->grab;
+ register DeviceIntPtr dev;
+
+ mouse->valuator->motionHintWindow = NullWindow;
+ mouse->grab = NullGrab;
+ mouse->sync.state = NOT_GRABBED;
+ mouse->fromPassiveGrab = FALSE;
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (dev->sync.other == grab)
+ dev->sync.other = NullGrab;
+ }
+ DoEnterLeaveEvents(grab->window, sprite.win, NotifyUngrab);
+ if (grab->confineTo)
+ ConfineCursorToWindow(ROOT, FALSE, FALSE);
+ PostNewCursor();
+ if (grab->cursor)
+ FreeCursor(grab->cursor, (Cursor)0);
+ ComputeFreezes();
+}
+
+void
+ActivateKeyboardGrab(register DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, Bool passive)
+{
+ WindowPtr oldWin;
+
+ if (keybd->grab)
+ oldWin = keybd->grab->window;
+ else if (keybd->focus)
+ oldWin = keybd->focus->win;
+ else
+ oldWin = sprite.win;
+ if (oldWin == FollowKeyboardWin)
+ oldWin = inputInfo.keyboard->focus->win;
+ if (keybd->valuator)
+ keybd->valuator->motionHintWindow = NullWindow;
+ DoFocusEvents(keybd, oldWin, grab->window, NotifyGrab);
+ if (syncEvents.playingEvents)
+ keybd->grabTime = syncEvents.time;
+ else
+ keybd->grabTime = time;
+ keybd->activeGrab = *grab;
+ keybd->grab = &keybd->activeGrab;
+ keybd->fromPassiveGrab = passive;
+ CheckGrabForSyncs(keybd, (Bool)grab->keyboardMode, (Bool)grab->pointerMode);
+}
+
+void
+DeactivateKeyboardGrab(register DeviceIntPtr keybd)
+{
+ register GrabPtr grab = keybd->grab;
+ register DeviceIntPtr dev;
+ register WindowPtr focusWin = keybd->focus ? keybd->focus->win
+ : sprite.win;
+
+ if (focusWin == FollowKeyboardWin)
+ focusWin = inputInfo.keyboard->focus->win;
+ if (keybd->valuator)
+ keybd->valuator->motionHintWindow = NullWindow;
+ keybd->grab = NullGrab;
+ keybd->sync.state = NOT_GRABBED;
+ keybd->fromPassiveGrab = FALSE;
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (dev->sync.other == grab)
+ dev->sync.other = NullGrab;
+ }
+ DoFocusEvents(keybd, grab->window, focusWin, NotifyUngrab);
+ ComputeFreezes();
+}
+
+void
+AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState)
+{
+ Bool thisGrabbed, otherGrabbed, othersFrozen, thisSynced;
+ TimeStamp grabTime;
+ register DeviceIntPtr dev;
+
+ thisGrabbed = thisDev->grab && SameClient(thisDev->grab, client);
+ thisSynced = FALSE;
+ otherGrabbed = FALSE;
+ othersFrozen = TRUE;
+ grabTime = thisDev->grabTime;
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (dev == thisDev)
+ continue;
+ if (dev->grab && SameClient(dev->grab, client))
+ {
+ if (!(thisGrabbed || otherGrabbed) ||
+ (CompareTimeStamps(dev->grabTime, grabTime) == LATER))
+ grabTime = dev->grabTime;
+ otherGrabbed = TRUE;
+ if (thisDev->sync.other == dev->grab)
+ thisSynced = TRUE;
+ if (dev->sync.state < FROZEN)
+ othersFrozen = FALSE;
+ }
+ else if (!dev->sync.other || !SameClient(dev->sync.other, client))
+ othersFrozen = FALSE;
+ }
+ if (!((thisGrabbed && thisDev->sync.state >= FROZEN) || thisSynced))
+ return;
+ if ((CompareTimeStamps(time, currentTime) == LATER) ||
+ (CompareTimeStamps(time, grabTime) == EARLIER))
+ return;
+ switch (newState)
+ {
+ case THAWED: /* Async */
+ if (thisGrabbed)
+ thisDev->sync.state = THAWED;
+ if (thisSynced)
+ thisDev->sync.other = NullGrab;
+ ComputeFreezes();
+ break;
+ case FREEZE_NEXT_EVENT: /* Sync */
+ if (thisGrabbed)
+ {
+ thisDev->sync.state = FREEZE_NEXT_EVENT;
+ if (thisSynced)
+ thisDev->sync.other = NullGrab;
+ ComputeFreezes();
+ }
+ break;
+ case THAWED_BOTH: /* AsyncBoth */
+ if (othersFrozen)
+ {
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (dev->grab && SameClient(dev->grab, client))
+ dev->sync.state = THAWED;
+ if (dev->sync.other && SameClient(dev->sync.other, client))
+ dev->sync.other = NullGrab;
+ }
+ ComputeFreezes();
+ }
+ break;
+ case FREEZE_BOTH_NEXT_EVENT: /* SyncBoth */
+ if (othersFrozen)
+ {
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (dev->grab && SameClient(dev->grab, client))
+ dev->sync.state = FREEZE_BOTH_NEXT_EVENT;
+ if (dev->sync.other && SameClient(dev->sync.other, client))
+ dev->sync.other = NullGrab;
+ }
+ ComputeFreezes();
+ }
+ break;
+ case NOT_GRABBED: /* Replay */
+ if (thisGrabbed && thisDev->sync.state == FROZEN_WITH_EVENT)
+ {
+ if (thisSynced)
+ thisDev->sync.other = NullGrab;
+ syncEvents.replayDev = thisDev;
+ syncEvents.replayWin = thisDev->grab->window;
+ (*thisDev->DeactivateGrab)(thisDev);
+ syncEvents.replayDev = (DeviceIntPtr)NULL;
+ }
+ break;
+ case THAW_OTHERS: /* AsyncOthers */
+ if (othersFrozen)
+ {
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (dev == thisDev)
+ continue;
+ if (dev->grab && SameClient(dev->grab, client))
+ dev->sync.state = THAWED;
+ if (dev->sync.other && SameClient(dev->sync.other, client))
+ dev->sync.other = NullGrab;
+ }
+ ComputeFreezes();
+ }
+ break;
+ }
+}
+
+int
+ProcAllowEvents(register ClientPtr client)
+{
+ TimeStamp time;
+ DeviceIntPtr mouse = inputInfo.pointer;
+ DeviceIntPtr keybd = inputInfo.keyboard;
+ REQUEST(xAllowEventsReq);
+
+ REQUEST_SIZE_MATCH(xAllowEventsReq);
+ time = ClientTimeToServerTime(stuff->time);
+ switch (stuff->mode)
+ {
+ case ReplayPointer:
+ AllowSome(client, time, mouse, NOT_GRABBED);
+ break;
+ case SyncPointer:
+ AllowSome(client, time, mouse, FREEZE_NEXT_EVENT);
+ break;
+ case AsyncPointer:
+ AllowSome(client, time, mouse, THAWED);
+ break;
+ case ReplayKeyboard:
+ AllowSome(client, time, keybd, NOT_GRABBED);
+ break;
+ case SyncKeyboard:
+ AllowSome(client, time, keybd, FREEZE_NEXT_EVENT);
+ break;
+ case AsyncKeyboard:
+ AllowSome(client, time, keybd, THAWED);
+ break;
+ case SyncBoth:
+ AllowSome(client, time, keybd, FREEZE_BOTH_NEXT_EVENT);
+ break;
+ case AsyncBoth:
+ AllowSome(client, time, keybd, THAWED_BOTH);
+ break;
+ default:
+ client->errorValue = stuff->mode;
+ return BadValue;
+ }
+ return Success;
+}
+
+void
+ReleaseActiveGrabs(ClientPtr client)
+{
+ register DeviceIntPtr dev;
+ Bool done;
+
+ /* XXX CloseDownClient should remove passive grabs before
+ * releasing active grabs.
+ */
+ do {
+ done = TRUE;
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (dev->grab && SameClient(dev->grab, client))
+ {
+ (*dev->DeactivateGrab)(dev);
+ done = FALSE;
+ }
+ }
+ } while (!done);
+}
+
+/**************************************************************************
+ * The following procedures deal with delivering events *
+ **************************************************************************/
+
+int
+TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask,
+ Mask filter, GrabPtr grab)
+{
+ int i;
+ int type;
+
+#ifdef DEBUG
+ if (debug_events) ErrorF(
+ "Event([%d, %d], mask=0x%x), client=%d",
+ pEvents->u.u.type, pEvents->u.u.detail, mask, client->index);
+#endif
+ if ((client) && (client != serverClient) && (!client->clientGone) &&
+ ((filter == CantBeFiltered) || (mask & filter)))
+ {
+ if (grab && !SameClient(grab, client))
+ return -1; /* don't send, but notify caller */
+ type = pEvents->u.u.type;
+ if (type == MotionNotify)
+ {
+ if (mask & PointerMotionHintMask)
+ {
+ if (WID(inputInfo.pointer->valuator->motionHintWindow) ==
+ pEvents->u.keyButtonPointer.event)
+ {
+#ifdef DEBUG
+ if (debug_events) ErrorF("\n");
+ fprintf(stderr,"motionHintWindow == keyButtonPointer.event\n");
+#endif
+ return 1; /* don't send, but pretend we did */
+ }
+ pEvents->u.u.detail = NotifyHint;
+ }
+ else
+ {
+ pEvents->u.u.detail = NotifyNormal;
+ }
+ }
+#ifdef XINPUT
+ else
+ {
+ if ((type == DeviceMotionNotify) &&
+ MaybeSendDeviceMotionNotifyHint
+ ((deviceKeyButtonPointer*)pEvents, mask) != 0)
+ return 1;
+ }
+#endif
+ type &= 0177;
+ if (type != KeymapNotify)
+ {
+ /* all extension events must have a sequence number */
+ for (i = 0; i < count; i++)
+ pEvents[i].u.u.sequenceNumber = client->sequence;
+ }
+
+ if (BitIsOn(criticalEvents, type))
+ {
+#ifdef SMART_SCHEDULE
+ if (client->smart_priority < SMART_MAX_PRIORITY)
+ client->smart_priority++;
+#endif
+ SetCriticalOutputPending();
+ }
+
+ WriteEventsToClient(client, count, pEvents);
+#ifdef DEBUG
+ if (debug_events) ErrorF( " delivered\n");
+#endif
+ return 1;
+ }
+ else
+ {
+#ifdef DEBUG
+ if (debug_events) ErrorF("\n");
+#endif
+ return 0;
+ }
+}
+
+int
+DeliverEventsToWindow(register WindowPtr pWin, xEvent *pEvents, int count,
+ Mask filter, GrabPtr grab, int mskidx)
+{
+ int deliveries = 0, nondeliveries = 0;
+ int attempt;
+ register InputClients *other;
+ ClientPtr client = NullClient;
+ Mask deliveryMask = 0; /* If a grab occurs due to a button press, then
+ this mask is the mask of the grab. */
+ int type = pEvents->u.u.type;
+
+ /* CantBeFiltered means only window owner gets the event */
+ if ((filter == CantBeFiltered) || !(type & EXTENSION_EVENT_BASE))
+ {
+ /* if nobody ever wants to see this event, skip some work */
+ if (filter != CantBeFiltered &&
+ !((wOtherEventMasks(pWin)|pWin->eventMask) & filter))
+ return 0;
+ if ( (attempt = TryClientEvents(wClient(pWin), pEvents, count,
+ pWin->eventMask, filter, grab)) )
+ {
+ if (attempt > 0)
+ {
+ deliveries++;
+ client = wClient(pWin);
+ deliveryMask = pWin->eventMask;
+ } else
+ nondeliveries--;
+ }
+ }
+ if (filter != CantBeFiltered)
+ {
+ if (type & EXTENSION_EVENT_BASE)
+ {
+ OtherInputMasks *inputMasks;
+
+ inputMasks = wOtherInputMasks(pWin);
+ if (!inputMasks ||
+ !(inputMasks->inputEvents[mskidx] & filter))
+ return 0;
+ other = inputMasks->inputClients;
+ }
+ else
+ other = (InputClients *)wOtherClients(pWin);
+ for (; other; other = other->next)
+ {
+ if ( (attempt = TryClientEvents(rClient(other), pEvents, count,
+ other->mask[mskidx], filter, grab)) )
+ {
+ if (attempt > 0)
+ {
+ deliveries++;
+ client = rClient(other);
+ deliveryMask = other->mask[mskidx];
+ } else
+ nondeliveries--;
+ }
+ }
+ }
+ if ((type == ButtonPress) && deliveries && (!grab))
+ {
+ GrabRec tempGrab;
+
+ tempGrab.device = inputInfo.pointer;
+ tempGrab.resource = client->clientAsMask;
+ tempGrab.window = pWin;
+ tempGrab.ownerEvents = (deliveryMask & OwnerGrabButtonMask) ? TRUE : FALSE;
+ tempGrab.eventMask = deliveryMask;
+ tempGrab.keyboardMode = GrabModeAsync;
+ tempGrab.pointerMode = GrabModeAsync;
+ tempGrab.confineTo = NullWindow;
+ tempGrab.cursor = NullCursor;
+ (*inputInfo.pointer->ActivateGrab)(inputInfo.pointer, &tempGrab,
+ currentTime, TRUE);
+ }
+ else if ((type == MotionNotify) && deliveries)
+ inputInfo.pointer->valuator->motionHintWindow = pWin;
+#ifdef XINPUT
+ else
+ {
+ if (((type == DeviceMotionNotify)
+#ifdef XKB
+ || (type == DeviceButtonPress)
+#endif
+ ) && deliveries)
+ CheckDeviceGrabAndHintWindow (pWin, type,
+ (deviceKeyButtonPointer*) pEvents,
+ grab, client, deliveryMask);
+ }
+#endif
+ if (deliveries)
+ return deliveries;
+ return nondeliveries;
+}
+
+/* If the event goes to dontClient, don't send it and return 0. if
+ send works, return 1 or if send didn't work, return 2.
+ Only works for core events.
+*/
+
+#ifdef PANORAMIX
+static int
+XineramaTryClientEventsResult(
+ ClientPtr client,
+ GrabPtr grab,
+ Mask mask,
+ Mask filter
+){
+ if ((client) && (client != serverClient) && (!client->clientGone) &&
+ ((filter == CantBeFiltered) || (mask & filter)))
+ {
+ if (grab && !SameClient(grab, client)) return -1;
+ else return 1;
+ }
+ return 0;
+}
+#endif
+
+int
+MaybeDeliverEventsToClient(register WindowPtr pWin, xEvent *pEvents,
+ int count, Mask filter, ClientPtr dontClient)
+{
+ register OtherClients *other;
+
+
+ if (pWin->eventMask & filter)
+ {
+ if (wClient(pWin) == dontClient)
+ return 0;
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
+ return XineramaTryClientEventsResult(
+ wClient(pWin), NullGrab, pWin->eventMask, filter);
+#endif
+ return TryClientEvents(wClient(pWin), pEvents, count,
+ pWin->eventMask, filter, NullGrab);
+ }
+ for (other = wOtherClients(pWin); other; other = other->next)
+ {
+ if (other->mask & filter)
+ {
+ if (SameClient(other, dontClient))
+ return 0;
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
+ return XineramaTryClientEventsResult(
+ rClient(other), NullGrab, other->mask, filter);
+#endif
+ return TryClientEvents(rClient(other), pEvents, count,
+ other->mask, filter, NullGrab);
+ }
+ }
+ return 2;
+}
+
+static void
+FixUpEventFromWindow(
+ xEvent *xE,
+ WindowPtr pWin,
+ Window child,
+ Bool calcChild)
+{
+ if (calcChild)
+ {
+ WindowPtr w=spriteTrace[spriteTraceGood-1];
+ /* If the search ends up past the root should the child field be
+ set to none or should the value in the argument be passed
+ through. It probably doesn't matter since everyone calls
+ this function with child == None anyway. */
+
+ while (w)
+ {
+ /* If the source window is same as event window, child should be
+ none. Don't bother going all all the way back to the root. */
+
+ if (w == pWin)
+ {
+ child = None;
+ break;
+ }
+
+ if (w->parent == pWin)
+ {
+ child = w->drawable.id;
+ break;
+ }
+ w = w->parent;
+ }
+ }
+ XE_KBPTR.root = ROOT->drawable.id;
+ XE_KBPTR.event = pWin->drawable.id;
+ if (sprite.hot.pScreen == pWin->drawable.pScreen)
+ {
+ XE_KBPTR.sameScreen = xTrue;
+ XE_KBPTR.child = child;
+ XE_KBPTR.eventX =
+ XE_KBPTR.rootX - pWin->drawable.x;
+ XE_KBPTR.eventY =
+ XE_KBPTR.rootY - pWin->drawable.y;
+ }
+ else
+ {
+ XE_KBPTR.sameScreen = xFalse;
+ XE_KBPTR.child = None;
+ XE_KBPTR.eventX = 0;
+ XE_KBPTR.eventY = 0;
+ }
+}
+
+int
+DeliverDeviceEvents(register WindowPtr pWin, register xEvent *xE, GrabPtr grab,
+ register WindowPtr stopAt, DeviceIntPtr dev, int count)
+{
+ Window child = None;
+ int type = xE->u.u.type;
+ Mask filter = filters[type];
+ int deliveries = 0;
+
+ if (type & EXTENSION_EVENT_BASE)
+ {
+ register OtherInputMasks *inputMasks;
+ int mskidx = dev->id;
+
+ inputMasks = wOtherInputMasks(pWin);
+ if (inputMasks && !(filter & inputMasks->deliverableEvents[mskidx]))
+ return 0;
+ while (pWin)
+ {
+ if (inputMasks && (inputMasks->inputEvents[mskidx] & filter))
+ {
+ FixUpEventFromWindow(xE, pWin, child, FALSE);
+ deliveries = DeliverEventsToWindow(pWin, xE, count, filter,
+ grab, mskidx);
+ if (deliveries > 0)
+ return deliveries;
+ }
+ if ((deliveries < 0) ||
+ (pWin == stopAt) ||
+ (inputMasks &&
+ (filter & inputMasks->dontPropagateMask[mskidx])))
+ return 0;
+ child = pWin->drawable.id;
+ pWin = pWin->parent;
+ if (pWin)
+ inputMasks = wOtherInputMasks(pWin);
+ }
+ }
+ else
+ {
+ if (!(filter & pWin->deliverableEvents))
+ return 0;
+ while (pWin)
+ {
+ if ((wOtherEventMasks(pWin)|pWin->eventMask) & filter)
+ {
+ FixUpEventFromWindow(xE, pWin, child, FALSE);
+ deliveries = DeliverEventsToWindow(pWin, xE, count, filter,
+ grab, 0);
+ if (deliveries > 0)
+ return deliveries;
+ }
+ if ((deliveries < 0) ||
+ (pWin == stopAt) ||
+ (filter & wDontPropagateMask(pWin)))
+ return 0;
+ child = pWin->drawable.id;
+ pWin = pWin->parent;
+ }
+ }
+ return 0;
+}
+
+/* not useful for events that propagate up the tree or extension events */
+int
+DeliverEvents(register WindowPtr pWin, register xEvent *xE, int count,
+ register WindowPtr otherParent)
+{
+ Mask filter;
+ int deliveries;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
+ return count;
+#endif
+
+ if (!count)
+ return 0;
+ filter = filters[xE->u.u.type];
+ if ((filter & SubstructureNotifyMask) && (xE->u.u.type != CreateNotify))
+ xE->u.destroyNotify.event = pWin->drawable.id;
+ if (filter != StructureAndSubMask)
+ return DeliverEventsToWindow(pWin, xE, count, filter, NullGrab, 0);
+ deliveries = DeliverEventsToWindow(pWin, xE, count, StructureNotifyMask,
+ NullGrab, 0);
+ if (pWin->parent)
+ {
+ xE->u.destroyNotify.event = pWin->parent->drawable.id;
+ deliveries += DeliverEventsToWindow(pWin->parent, xE, count,
+ SubstructureNotifyMask, NullGrab,
+ 0);
+ if (xE->u.u.type == ReparentNotify)
+ {
+ xE->u.destroyNotify.event = otherParent->drawable.id;
+ deliveries += DeliverEventsToWindow(otherParent, xE, count,
+ SubstructureNotifyMask,
+ NullGrab, 0);
+ }
+ }
+ return deliveries;
+}
+
+
+static Bool
+PointInBorderSize(WindowPtr pWin, int x, int y)
+{
+ BoxRec box;
+
+ if(POINT_IN_REGION(pWin->drawable.pScreen, &pWin->borderSize, x, y, &box))
+ return TRUE;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && XineramaSetWindowPntrs(pWin)) {
+ int i;
+
+ for(i = 1; i < PanoramiXNumScreens; i++) {
+ if(POINT_IN_REGION(sprite.screen,
+ &sprite.windows[i]->borderSize,
+ x + panoramiXdataPtr[0].x - panoramiXdataPtr[i].x,
+ y + panoramiXdataPtr[0].y - panoramiXdataPtr[i].y,
+ &box))
+ return TRUE;
+ }
+ }
+#endif
+ return FALSE;
+}
+
+static WindowPtr
+XYToWindow(int x, int y)
+{
+ register WindowPtr pWin;
+ BoxRec box;
+
+ spriteTraceGood = 1; /* root window still there */
+ pWin = ROOT->firstChild;
+ while (pWin)
+ {
+ if ((pWin->mapped) &&
+ (x >= pWin->drawable.x - wBorderWidth (pWin)) &&
+ (x < pWin->drawable.x + (int)pWin->drawable.width +
+ wBorderWidth(pWin)) &&
+ (y >= pWin->drawable.y - wBorderWidth (pWin)) &&
+ (y < pWin->drawable.y + (int)pWin->drawable.height +
+ wBorderWidth (pWin))
+#ifdef SHAPE
+ /* When a window is shaped, a further check
+ * is made to see if the point is inside
+ * borderSize
+ */
+ && (!wBoundingShape(pWin) || PointInBorderSize(pWin, x, y))
+ && (!wInputShape(pWin) ||
+ POINT_IN_REGION(pWin->drawable.pScreen,
+ wInputShape(pWin),
+ x - pWin->drawable.x,
+ y - pWin->drawable.y, &box))
+#endif
+ )
+ {
+ if (spriteTraceGood >= spriteTraceSize)
+ {
+ spriteTraceSize += 10;
+ Must_have_memory = TRUE; /* XXX */
+ spriteTrace = (WindowPtr *)xrealloc(
+ spriteTrace, spriteTraceSize*sizeof(WindowPtr));
+ Must_have_memory = FALSE; /* XXX */
+ }
+ spriteTrace[spriteTraceGood++] = pWin;
+ pWin = pWin->firstChild;
+ }
+ else
+ pWin = pWin->nextSib;
+ }
+ return spriteTrace[spriteTraceGood-1];
+}
+
+static Bool
+CheckMotion(xEvent *xE)
+{
+ WindowPtr prevSpriteWin = sprite.win;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ return XineramaCheckMotion(xE);
+#endif
+
+ if (xE && !syncEvents.playingEvents)
+ {
+ if (sprite.hot.pScreen != sprite.hotPhys.pScreen)
+ {
+ sprite.hot.pScreen = sprite.hotPhys.pScreen;
+ ROOT = WindowTable[sprite.hot.pScreen->myNum];
+ }
+#ifdef XEVIE
+ xeviehot.x =
+#endif
+ sprite.hot.x = XE_KBPTR.rootX;
+#ifdef XEVIE
+ xeviehot.y =
+#endif
+ sprite.hot.y = XE_KBPTR.rootY;
+ if (sprite.hot.x < sprite.physLimits.x1)
+#ifdef XEVIE
+ xeviehot.x =
+#endif
+ sprite.hot.x = sprite.physLimits.x1;
+ else if (sprite.hot.x >= sprite.physLimits.x2)
+#ifdef XEVIE
+ xeviehot.x =
+#endif
+ sprite.hot.x = sprite.physLimits.x2 - 1;
+ if (sprite.hot.y < sprite.physLimits.y1)
+#ifdef XEVIE
+ xeviehot.y =
+#endif
+ sprite.hot.y = sprite.physLimits.y1;
+ else if (sprite.hot.y >= sprite.physLimits.y2)
+#ifdef XEVIE
+ xeviehot.y =
+#endif
+ sprite.hot.y = sprite.physLimits.y2 - 1;
+#ifdef SHAPE
+ if (sprite.hotShape)
+ ConfineToShape(sprite.hotShape, &sprite.hot.x, &sprite.hot.y);
+#endif
+ sprite.hotPhys = sprite.hot;
+ if ((sprite.hotPhys.x != XE_KBPTR.rootX) ||
+ (sprite.hotPhys.y != XE_KBPTR.rootY))
+ {
+ (*sprite.hotPhys.pScreen->SetCursorPosition)(
+ sprite.hotPhys.pScreen,
+ sprite.hotPhys.x, sprite.hotPhys.y, FALSE);
+ }
+ XE_KBPTR.rootX = sprite.hot.x;
+ XE_KBPTR.rootY = sprite.hot.y;
+ }
+
+#ifdef XEVIE
+ xeviewin =
+#endif
+ sprite.win = XYToWindow(sprite.hot.x, sprite.hot.y);
+#ifdef notyet
+ if (!(sprite.win->deliverableEvents &
+ Motion_Filter(inputInfo.pointer->button))
+ !syncEvents.playingEvents)
+ {
+ /* XXX Do PointerNonInterestBox here */
+ }
+#endif
+ if (sprite.win != prevSpriteWin)
+ {
+ if (prevSpriteWin != NullWindow) {
+ if (!xE)
+ UpdateCurrentTimeIf();
+ DoEnterLeaveEvents(prevSpriteWin, sprite.win, NotifyNormal);
+ }
+ PostNewCursor();
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void
+WindowsRestructured()
+{
+ (void) CheckMotion((xEvent *)NULL);
+}
+
+#ifdef PANORAMIX
+/* This was added to support reconfiguration under Xdmx. The problem is
+ * that if the 0th screen (i.e., WindowTable[0]) is moved to an origin
+ * other than 0,0, the information in the private sprite structure must
+ * be updated accordingly, or XYToWindow (and other routines) will not
+ * compute correctly. */
+void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff)
+{
+ ScreenPtr pScreen = win->drawable.pScreen;
+ GrabPtr grab;
+
+ if (noPanoramiXExtension) return;
+
+ sprite.hot.x -= xoff;
+ sprite.hot.y -= yoff;
+
+ sprite.hotPhys.x -= xoff;
+ sprite.hotPhys.y -= yoff;
+
+ sprite.hotLimits.x1 -= xoff;
+ sprite.hotLimits.y1 -= yoff;
+ sprite.hotLimits.x2 -= xoff;
+ sprite.hotLimits.y2 -= yoff;
+
+ if (REGION_NOTEMPTY(sprite.screen, &sprite.Reg1))
+ REGION_TRANSLATE(sprite.screen, &sprite.Reg1, xoff, yoff);
+ if (REGION_NOTEMPTY(sprite.screen, &sprite.Reg2))
+ REGION_TRANSLATE(sprite.screen, &sprite.Reg2, xoff, yoff);
+
+ /* FIXME: if we call ConfineCursorToWindow, must we do anything else? */
+ if ((grab = inputInfo.pointer->grab) && grab->confineTo) {
+ if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen)
+ sprite.hotPhys.x = sprite.hotPhys.y = 0;
+ ConfineCursorToWindow(grab->confineTo, TRUE, TRUE);
+ } else
+ ConfineCursorToWindow(WindowTable[sprite.hotPhys.pScreen->myNum],
+ TRUE, FALSE);
+}
+#endif
+
+void
+DefineInitialRootWindow(register WindowPtr win)
+{
+ register ScreenPtr pScreen = win->drawable.pScreen;
+
+ sprite.hotPhys.pScreen = pScreen;
+ sprite.hotPhys.x = pScreen->width / 2;
+ sprite.hotPhys.y = pScreen->height / 2;
+ sprite.hot = sprite.hotPhys;
+ sprite.hotLimits.x2 = pScreen->width;
+ sprite.hotLimits.y2 = pScreen->height;
+#ifdef XEVIE
+ xeviewin =
+#endif
+ sprite.win = win;
+ sprite.current = wCursor (win);
+ sprite.current->refcnt++;
+ spriteTraceGood = 1;
+ ROOT = win;
+ (*pScreen->CursorLimits) (
+ pScreen, sprite.current, &sprite.hotLimits, &sprite.physLimits);
+ sprite.confined = FALSE;
+ (*pScreen->ConstrainCursor) (pScreen, &sprite.physLimits);
+ (*pScreen->SetCursorPosition) (pScreen, sprite.hot.x, sprite.hot.y, FALSE);
+ (*pScreen->DisplayCursor) (pScreen, sprite.current);
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ sprite.hotLimits.x1 = -panoramiXdataPtr[0].x;
+ sprite.hotLimits.y1 = -panoramiXdataPtr[0].y;
+ sprite.hotLimits.x2 = PanoramiXPixWidth - panoramiXdataPtr[0].x;
+ sprite.hotLimits.y2 = PanoramiXPixHeight - panoramiXdataPtr[0].y;
+ sprite.physLimits = sprite.hotLimits;
+ sprite.confineWin = NullWindow;
+#ifdef SHAPE
+ sprite.hotShape = NullRegion;
+#endif
+ sprite.screen = pScreen;
+ /* gotta UNINIT these someplace */
+ REGION_NULL(pScreen, &sprite.Reg1);
+ REGION_NULL(pScreen, &sprite.Reg2);
+ }
+#endif
+}
+
+/*
+ * This does not take any shortcuts, and even ignores its argument, since
+ * it does not happen very often, and one has to walk up the tree since
+ * this might be a newly instantiated cursor for an intermediate window
+ * between the one the pointer is in and the one that the last cursor was
+ * instantiated from.
+ */
+void
+WindowHasNewCursor(WindowPtr pWin)
+{
+ PostNewCursor();
+}
+
+void
+NewCurrentScreen(ScreenPtr newScreen, int x, int y)
+{
+ sprite.hotPhys.x = x;
+ sprite.hotPhys.y = y;
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ sprite.hotPhys.x += panoramiXdataPtr[newScreen->myNum].x -
+ panoramiXdataPtr[0].x;
+ sprite.hotPhys.y += panoramiXdataPtr[newScreen->myNum].y -
+ panoramiXdataPtr[0].y;
+ if (newScreen != sprite.screen) {
+ sprite.screen = newScreen;
+ /* Make sure we tell the DDX to update its copy of the screen */
+ if(sprite.confineWin)
+ XineramaConfineCursorToWindow(sprite.confineWin, TRUE);
+ else
+ XineramaConfineCursorToWindow(WindowTable[0], TRUE);
+ /* if the pointer wasn't confined, the DDX won't get
+ told of the pointer warp so we reposition it here */
+ if(!syncEvents.playingEvents)
+ (*sprite.screen->SetCursorPosition)(sprite.screen,
+ sprite.hotPhys.x + panoramiXdataPtr[0].x -
+ panoramiXdataPtr[sprite.screen->myNum].x,
+ sprite.hotPhys.y + panoramiXdataPtr[0].y -
+ panoramiXdataPtr[sprite.screen->myNum].y, FALSE);
+ }
+ } else
+#endif
+ if (newScreen != sprite.hotPhys.pScreen)
+ ConfineCursorToWindow(WindowTable[newScreen->myNum], TRUE, FALSE);
+}
+
+#ifdef PANORAMIX
+
+static Bool
+XineramaPointInWindowIsVisible(
+ WindowPtr pWin,
+ int x,
+ int y
+)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ BoxRec box;
+ int i, xoff, yoff;
+
+ if (!pWin->realized) return FALSE;
+
+ if (POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box))
+ return TRUE;
+
+ if(!XineramaSetWindowPntrs(pWin)) return FALSE;
+
+ xoff = x + panoramiXdataPtr[0].x;
+ yoff = y + panoramiXdataPtr[0].y;
+
+ for(i = 1; i < PanoramiXNumScreens; i++) {
+ pWin = sprite.windows[i];
+ pScreen = pWin->drawable.pScreen;
+ x = xoff - panoramiXdataPtr[i].x;
+ y = yoff - panoramiXdataPtr[i].y;
+
+ if(POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box)
+ && (!wInputShape(pWin) ||
+ POINT_IN_REGION(pWin->drawable.pScreen,
+ wInputShape(pWin),
+ x - pWin->drawable.x,
+ y - pWin->drawable.y, &box)))
+ return TRUE;
+
+ }
+
+ return FALSE;
+}
+
+static int
+XineramaWarpPointer(ClientPtr client)
+{
+ WindowPtr dest = NULL;
+ int x, y;
+
+ REQUEST(xWarpPointerReq);
+
+
+ if (stuff->dstWid != None)
+ {
+ dest = SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess);
+ if (!dest)
+ return BadWindow;
+ }
+ x = sprite.hotPhys.x;
+ y = sprite.hotPhys.y;
+
+ if (stuff->srcWid != None)
+ {
+ int winX, winY;
+ XID winID = stuff->srcWid;
+ WindowPtr source;
+
+ source = SecurityLookupWindow(winID, client, SecurityReadAccess);
+ if (!source) return BadWindow;
+
+ winX = source->drawable.x;
+ winY = source->drawable.y;
+ if(source == WindowTable[0]) {
+ winX -= panoramiXdataPtr[0].x;
+ winY -= panoramiXdataPtr[0].y;
+ }
+ if (x < winX + stuff->srcX ||
+ y < winY + stuff->srcY ||
+ (stuff->srcWidth != 0 &&
+ winX + stuff->srcX + (int)stuff->srcWidth < x) ||
+ (stuff->srcHeight != 0 &&
+ winY + stuff->srcY + (int)stuff->srcHeight < y) ||
+ !XineramaPointInWindowIsVisible(source, x, y))
+ return Success;
+ }
+ if (dest) {
+ x = dest->drawable.x;
+ y = dest->drawable.y;
+ if(dest == WindowTable[0]) {
+ x -= panoramiXdataPtr[0].x;
+ y -= panoramiXdataPtr[0].y;
+ }
+ }
+
+ x += stuff->dstX;
+ y += stuff->dstY;
+
+ if (x < sprite.physLimits.x1)
+ x = sprite.physLimits.x1;
+ else if (x >= sprite.physLimits.x2)
+ x = sprite.physLimits.x2 - 1;
+ if (y < sprite.physLimits.y1)
+ y = sprite.physLimits.y1;
+ else if (y >= sprite.physLimits.y2)
+ y = sprite.physLimits.y2 - 1;
+ if (sprite.hotShape)
+ ConfineToShape(sprite.hotShape, &x, &y);
+
+ XineramaSetCursorPosition(x, y, TRUE);
+
+ return Success;
+}
+
+#endif
+
+
+int
+ProcWarpPointer(ClientPtr client)
+{
+ WindowPtr dest = NULL;
+ int x, y;
+ ScreenPtr newScreen;
+
+ REQUEST(xWarpPointerReq);
+
+ REQUEST_SIZE_MATCH(xWarpPointerReq);
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ return XineramaWarpPointer(client);
+#endif
+
+ if (stuff->dstWid != None)
+ {
+ dest = SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess);
+ if (!dest)
+ return BadWindow;
+ }
+ x = sprite.hotPhys.x;
+ y = sprite.hotPhys.y;
+
+ if (stuff->srcWid != None)
+ {
+ int winX, winY;
+ XID winID = stuff->srcWid;
+ WindowPtr source;
+
+ source = SecurityLookupWindow(winID, client, SecurityReadAccess);
+ if (!source) return BadWindow;
+
+ winX = source->drawable.x;
+ winY = source->drawable.y;
+ if (source->drawable.pScreen != sprite.hotPhys.pScreen ||
+ x < winX + stuff->srcX ||
+ y < winY + stuff->srcY ||
+ (stuff->srcWidth != 0 &&
+ winX + stuff->srcX + (int)stuff->srcWidth < x) ||
+ (stuff->srcHeight != 0 &&
+ winY + stuff->srcY + (int)stuff->srcHeight < y) ||
+ !PointInWindowIsVisible(source, x, y))
+ return Success;
+ }
+ if (dest)
+ {
+ x = dest->drawable.x;
+ y = dest->drawable.y;
+ newScreen = dest->drawable.pScreen;
+ } else
+ newScreen = sprite.hotPhys.pScreen;
+
+ x += stuff->dstX;
+ y += stuff->dstY;
+
+ if (x < 0)
+ x = 0;
+ else if (x >= newScreen->width)
+ x = newScreen->width - 1;
+ if (y < 0)
+ y = 0;
+ else if (y >= newScreen->height)
+ y = newScreen->height - 1;
+
+ if (newScreen == sprite.hotPhys.pScreen)
+ {
+ if (x < sprite.physLimits.x1)
+ x = sprite.physLimits.x1;
+ else if (x >= sprite.physLimits.x2)
+ x = sprite.physLimits.x2 - 1;
+ if (y < sprite.physLimits.y1)
+ y = sprite.physLimits.y1;
+ else if (y >= sprite.physLimits.y2)
+ y = sprite.physLimits.y2 - 1;
+#if defined(SHAPE)
+ if (sprite.hotShape)
+ ConfineToShape(sprite.hotShape, &x, &y);
+#endif
+ (*newScreen->SetCursorPosition)(newScreen, x, y, TRUE);
+ }
+ else if (!PointerConfinedToScreen())
+ {
+ NewCurrentScreen(newScreen, x, y);
+ }
+ return Success;
+}
+
+static Bool
+BorderSizeNotEmpty(WindowPtr pWin)
+{
+ if(REGION_NOTEMPTY(sprite.hotPhys.pScreen, &pWin->borderSize))
+ return TRUE;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && XineramaSetWindowPntrs(pWin)) {
+ int i;
+
+ for(i = 1; i < PanoramiXNumScreens; i++) {
+ if(REGION_NOTEMPTY(sprite.screen, &sprite.windows[i]->borderSize))
+ return TRUE;
+ }
+ }
+#endif
+ return FALSE;
+}
+
+/* "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a
+ passive grab set on the window to be activated. */
+
+static Bool
+CheckPassiveGrabsOnWindow(
+ WindowPtr pWin,
+ register DeviceIntPtr device,
+ register xEvent *xE,
+ int count)
+{
+ register GrabPtr grab = wPassiveGrabs(pWin);
+ GrabRec tempGrab;
+ register xEvent *dxE;
+
+ if (!grab)
+ return FALSE;
+ tempGrab.window = pWin;
+ tempGrab.device = device;
+ tempGrab.type = xE->u.u.type;
+ tempGrab.detail.exact = xE->u.u.detail;
+ tempGrab.detail.pMask = NULL;
+ tempGrab.modifiersDetail.pMask = NULL;
+ for (; grab; grab = grab->next)
+ {
+#ifdef XKB
+ DeviceIntPtr gdev;
+ XkbSrvInfoPtr xkbi;
+
+ gdev= grab->modifierDevice;
+ xkbi= gdev->key->xkbInfo;
+#endif
+ tempGrab.modifierDevice = grab->modifierDevice;
+ if ((device == grab->modifierDevice) &&
+ ((xE->u.u.type == KeyPress)
+#if defined(XINPUT) && defined(XKB)
+ || (xE->u.u.type == DeviceKeyPress)
+#endif
+ ))
+ tempGrab.modifiersDetail.exact =
+#ifdef XKB
+ (noXkbExtension?gdev->key->prev_state:xkbi->state.grab_mods);
+#else
+ grab->modifierDevice->key->prev_state;
+#endif
+ else
+ tempGrab.modifiersDetail.exact =
+#ifdef XKB
+ (noXkbExtension ? gdev->key->state : xkbi->state.grab_mods);
+#else
+ grab->modifierDevice->key->state;
+#endif
+ if (GrabMatchesSecond(&tempGrab, grab) &&
+ (!grab->confineTo ||
+ (grab->confineTo->realized &&
+ BorderSizeNotEmpty(grab->confineTo))))
+ {
+#ifdef XCSECURITY
+ if (!SecurityCheckDeviceAccess(wClient(pWin), device, FALSE))
+ return FALSE;
+#endif
+#ifdef XKB
+ if (!noXkbExtension) {
+ XE_KBPTR.state &= 0x1f00;
+ XE_KBPTR.state |=
+ tempGrab.modifiersDetail.exact&(~0x1f00);
+ }
+#endif
+ (*device->ActivateGrab)(device, grab, currentTime, TRUE);
+
+ FixUpEventFromWindow(xE, grab->window, None, TRUE);
+
+ (void) TryClientEvents(rClient(grab), xE, count,
+ filters[xE->u.u.type],
+ filters[xE->u.u.type], grab);
+
+ if (device->sync.state == FROZEN_NO_EVENT)
+ {
+ if (device->sync.evcount < count)
+ {
+ Must_have_memory = TRUE; /* XXX */
+ device->sync.event = (xEvent *)xrealloc(device->sync.event,
+ count*
+ sizeof(xEvent));
+ Must_have_memory = FALSE; /* XXX */
+ }
+ device->sync.evcount = count;
+ for (dxE = device->sync.event; --count >= 0; dxE++, xE++)
+ *dxE = *xE;
+ device->sync.state = FROZEN_WITH_EVENT;
+ }
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/**
+"CheckDeviceGrabs" handles both keyboard and pointer events that may cause
+a passive grab to be activated. If the event is a keyboard event, the
+ancestors of the focus window are traced down and tried to see if they have
+any passive grabs to be activated. If the focus window itself is reached and
+it's descendants contain they pointer, the ancestors of the window that the
+pointer is in are then traced down starting at the focus window, otherwise no
+grabs are activated. If the event is a pointer event, the ancestors of the
+window that the pointer is in are traced down starting at the root until
+CheckPassiveGrabs causes a passive grab to activate or all the windows are
+tried. PRH
+*/
+
+Bool
+CheckDeviceGrabs(register DeviceIntPtr device, register xEvent *xE,
+ int checkFirst, int count)
+{
+ register int i;
+ register WindowPtr pWin = NULL;
+ register FocusClassPtr focus = device->focus;
+
+ if (((xE->u.u.type == ButtonPress)
+#if defined(XINPUT) && defined(XKB)
+ || (xE->u.u.type == DeviceButtonPress)
+#endif
+ ) && (device->button->buttonsDown != 1))
+ return FALSE;
+
+ i = checkFirst;
+
+ if (focus)
+ {
+ for (; i < focus->traceGood; i++)
+ {
+ pWin = focus->trace[i];
+ if (pWin->optional &&
+ CheckPassiveGrabsOnWindow(pWin, device, xE, count))
+ return TRUE;
+ }
+
+ if ((focus->win == NoneWin) ||
+ (i >= spriteTraceGood) ||
+ ((i > checkFirst) && (pWin != spriteTrace[i-1])))
+ return FALSE;
+ }
+
+ for (; i < spriteTraceGood; i++)
+ {
+ pWin = spriteTrace[i];
+ if (pWin->optional &&
+ CheckPassiveGrabsOnWindow(pWin, device, xE, count))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+void
+DeliverFocusedEvent(DeviceIntPtr keybd, xEvent *xE, WindowPtr window, int count)
+{
+ WindowPtr focus = keybd->focus->win;
+ int mskidx = 0;
+
+ if (focus == FollowKeyboardWin)
+ focus = inputInfo.keyboard->focus->win;
+ if (!focus)
+ return;
+ if (focus == PointerRootWin)
+ {
+ DeliverDeviceEvents(window, xE, NullGrab, NullWindow, keybd, count);
+ return;
+ }
+ if ((focus == window) || IsParent(focus, window))
+ {
+ if (DeliverDeviceEvents(window, xE, NullGrab, focus, keybd, count))
+ return;
+ }
+ /* just deliver it to the focus window */
+ FixUpEventFromWindow(xE, focus, None, FALSE);
+ if (xE->u.u.type & EXTENSION_EVENT_BASE)
+ mskidx = keybd->id;
+ (void)DeliverEventsToWindow(focus, xE, count, filters[xE->u.u.type],
+ NullGrab, mskidx);
+}
+
+void
+DeliverGrabbedEvent(register xEvent *xE, register DeviceIntPtr thisDev,
+ Bool deactivateGrab, int count)
+{
+ register GrabPtr grab = thisDev->grab;
+ int deliveries = 0;
+ register DeviceIntPtr dev;
+ register xEvent *dxE;
+
+ if (grab->ownerEvents)
+ {
+ WindowPtr focus;
+
+ if (thisDev->focus)
+ {
+ focus = thisDev->focus->win;
+ if (focus == FollowKeyboardWin)
+ focus = inputInfo.keyboard->focus->win;
+ }
+ else
+ focus = PointerRootWin;
+ if (focus == PointerRootWin)
+ deliveries = DeliverDeviceEvents(sprite.win, xE, grab, NullWindow,
+ thisDev, count);
+ else if (focus && (focus == sprite.win || IsParent(focus, sprite.win)))
+ deliveries = DeliverDeviceEvents(sprite.win, xE, grab, focus,
+ thisDev, count);
+ else if (focus)
+ deliveries = DeliverDeviceEvents(focus, xE, grab, focus,
+ thisDev, count);
+ }
+ if (!deliveries)
+ {
+ FixUpEventFromWindow(xE, grab->window, None, TRUE);
+ deliveries = TryClientEvents(rClient(grab), xE, count,
+ (Mask)grab->eventMask,
+ filters[xE->u.u.type], grab);
+ if (deliveries && (xE->u.u.type == MotionNotify
+#ifdef XINPUT
+ || xE->u.u.type == DeviceMotionNotify
+#endif
+ ))
+ thisDev->valuator->motionHintWindow = grab->window;
+ }
+ if (deliveries && !deactivateGrab && (xE->u.u.type != MotionNotify
+#ifdef XINPUT
+ && xE->u.u.type != DeviceMotionNotify
+#endif
+ ))
+ switch (thisDev->sync.state)
+ {
+ case FREEZE_BOTH_NEXT_EVENT:
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (dev == thisDev)
+ continue;
+ FreezeThaw(dev, TRUE);
+ if ((dev->sync.state == FREEZE_BOTH_NEXT_EVENT) &&
+ (CLIENT_BITS(dev->grab->resource) ==
+ CLIENT_BITS(thisDev->grab->resource)))
+ dev->sync.state = FROZEN_NO_EVENT;
+ else
+ dev->sync.other = thisDev->grab;
+ }
+ /* fall through */
+ case FREEZE_NEXT_EVENT:
+ thisDev->sync.state = FROZEN_WITH_EVENT;
+ FreezeThaw(thisDev, TRUE);
+ if (thisDev->sync.evcount < count)
+ {
+ Must_have_memory = TRUE; /* XXX */
+ thisDev->sync.event = (xEvent *)xrealloc(thisDev->sync.event,
+ count*sizeof(xEvent));
+ Must_have_memory = FALSE; /* XXX */
+ }
+ thisDev->sync.evcount = count;
+ for (dxE = thisDev->sync.event; --count >= 0; dxE++, xE++)
+ *dxE = *xE;
+ break;
+ }
+}
+
+void
+#ifdef XKB
+CoreProcessKeyboardEvent (register xEvent *xE, register DeviceIntPtr keybd, int count)
+#else
+ProcessKeyboardEvent (register xEvent *xE, register DeviceIntPtr keybd, int count)
+#endif
+{
+ int key, bit;
+ register BYTE *kptr;
+ register int i;
+ register CARD8 modifiers;
+ register CARD16 mask;
+ GrabPtr grab = keybd->grab;
+ Bool deactivateGrab = FALSE;
+ register KeyClassPtr keyc = keybd->key;
+#ifdef XEVIE
+ static Window rootWin = 0;
+
+ if(!xeviegrabState && xevieFlag && clients[xevieClientIndex] &&
+ (xevieMask & xevieFilters[xE->u.u.type])) {
+ key = xE->u.u.detail;
+ kptr = &keyc->down[key >> 3];
+ bit = 1 << (key & 7);
+ if((xE->u.u.type == KeyPress && (*kptr & bit)) ||
+ (xE->u.u.type == KeyRelease && !(*kptr & bit)))
+ {} else {
+#ifdef XKB
+ if(!noXkbExtension)
+ xevieKBEventSent = 1;
+#endif
+ if(!xevieKBEventSent)
+ {
+ xeviekb = keybd;
+ if(!rootWin) {
+ rootWin = GetCurrentRootWindow()->drawable.id;
+ }
+ xE->u.keyButtonPointer.event = xeviewin->drawable.id;
+ xE->u.keyButtonPointer.root = rootWin;
+ xE->u.keyButtonPointer.child = (xeviewin->firstChild) ? xeviewin->firstChild->
+drawable.id:0;
+ xE->u.keyButtonPointer.rootX = xeviehot.x;
+ xE->u.keyButtonPointer.rootY = xeviehot.y;
+ xE->u.keyButtonPointer.state = keyc->state;
+ WriteToClient(clients[xevieClientIndex], sizeof(xEvent), (char *)xE);
+#ifdef XKB
+ if(noXkbExtension)
+#endif
+ return;
+ } else {
+ xevieKBEventSent = 0;
+ }
+ }
+ }
+#endif
+
+ if (!syncEvents.playingEvents)
+ {
+ NoticeTime(xE);
+ if (DeviceEventCallback)
+ {
+ DeviceEventInfoRec eventinfo;
+ eventinfo.events = xE;
+ eventinfo.count = count;
+ CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo);
+ }
+ }
+#ifdef XEVIE
+ /* fix for bug5094030: don't change the state bit if the event is from XEvIE client */
+ if(!(!xeviegrabState && xevieFlag && clients[xevieClientIndex] &&
+ (xevieMask & xevieFilters[xE->u.u.type]
+#ifdef XKB
+ && !noXkbExtension
+#endif
+ )))
+#endif
+ XE_KBPTR.state = (keyc->state | inputInfo.pointer->button->state);
+ XE_KBPTR.rootX = sprite.hot.x;
+ XE_KBPTR.rootY = sprite.hot.y;
+ key = xE->u.u.detail;
+ kptr = &keyc->down[key >> 3];
+ bit = 1 << (key & 7);
+ modifiers = keyc->modifierMap[key];
+#if defined(XKB) && defined(XEVIE)
+ if(!noXkbExtension && !xeviegrabState &&
+ xevieFlag && clients[xevieClientIndex] &&
+ (xevieMask & xevieFilters[xE->u.u.type])) {
+ switch(xE->u.u.type) {
+ case KeyPress: *kptr &= ~bit; break;
+ case KeyRelease: *kptr |= bit; break;
+ }
+ }
+#endif
+
+#ifdef DEBUG
+ if ((xkbDebugFlags&0x4)&&
+ ((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) {
+ ErrorF("CoreProcessKbdEvent: Key %d %s\n",key,
+ (xE->u.u.type==KeyPress?"down":"up"));
+ }
+#endif
+ switch (xE->u.u.type)
+ {
+ case KeyPress:
+ if (*kptr & bit) /* allow ddx to generate multiple downs */
+ {
+ if (!modifiers)
+ {
+ xE->u.u.type = KeyRelease;
+ (*keybd->public.processInputProc)(xE, keybd, count);
+ xE->u.u.type = KeyPress;
+ /* release can have side effects, don't fall through */
+ (*keybd->public.processInputProc)(xE, keybd, count);
+ }
+ return;
+ }
+ inputInfo.pointer->valuator->motionHintWindow = NullWindow;
+ *kptr |= bit;
+ keyc->prev_state = keyc->state;
+ for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
+ {
+ if (mask & modifiers)
+ {
+ /* This key affects modifier "i" */
+ keyc->modifierKeyCount[i]++;
+ keyc->state |= mask;
+ modifiers &= ~mask;
+ }
+ }
+ if (!grab && CheckDeviceGrabs(keybd, xE, 0, count))
+ {
+ keybd->activatingKey = key;
+ return;
+ }
+ break;
+ case KeyRelease:
+ if (!(*kptr & bit)) /* guard against duplicates */
+ return;
+ inputInfo.pointer->valuator->motionHintWindow = NullWindow;
+ *kptr &= ~bit;
+ keyc->prev_state = keyc->state;
+ for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
+ {
+ if (mask & modifiers) {
+ /* This key affects modifier "i" */
+ if (--keyc->modifierKeyCount[i] <= 0) {
+ keyc->state &= ~mask;
+ keyc->modifierKeyCount[i] = 0;
+ }
+ modifiers &= ~mask;
+ }
+ }
+ if (keybd->fromPassiveGrab && (key == keybd->activatingKey))
+ deactivateGrab = TRUE;
+ break;
+ default:
+ FatalError("Impossible keyboard event");
+ }
+ if (grab)
+ DeliverGrabbedEvent(xE, keybd, deactivateGrab, count);
+ else
+ DeliverFocusedEvent(keybd, xE, sprite.win, count);
+ if (deactivateGrab)
+ (*keybd->DeactivateGrab)(keybd);
+}
+
+#ifdef XKB
+/* This function is used to set the key pressed or key released state -
+ this is only used when the pressing of keys does not cause
+ CoreProcessKeyEvent to be called, as in for example Mouse Keys.
+*/
+void
+FixKeyState (register xEvent *xE, register DeviceIntPtr keybd)
+{
+ int key, bit;
+ register BYTE *kptr;
+ register KeyClassPtr keyc = keybd->key;
+
+ key = xE->u.u.detail;
+ kptr = &keyc->down[key >> 3];
+ bit = 1 << (key & 7);
+#ifdef DEBUG
+ if ((xkbDebugFlags&0x4)&&
+ ((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) {
+ ErrorF("FixKeyState: Key %d %s\n",key,
+ (xE->u.u.type==KeyPress?"down":"up"));
+ }
+#endif
+ switch (xE->u.u.type)
+ {
+ case KeyPress:
+ *kptr |= bit;
+ break;
+ case KeyRelease:
+ *kptr &= ~bit;
+ break;
+ default:
+ FatalError("Impossible keyboard event");
+ }
+}
+#endif
+
+void
+#ifdef XKB
+CoreProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count)
+#else
+ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count)
+#endif
+{
+ register GrabPtr grab = mouse->grab;
+ Bool deactivateGrab = FALSE;
+ register ButtonClassPtr butc = mouse->button;
+#ifdef XKB
+ XkbSrvInfoPtr xkbi= inputInfo.keyboard->key->xkbInfo;
+#endif
+#ifdef XEVIE
+ if(xevieFlag && clients[xevieClientIndex] && !xeviegrabState &&
+ (xevieMask & xevieFilters[xE->u.u.type])) {
+ if(xevieEventSent)
+ xevieEventSent = 0;
+ else {
+ xeviemouse = mouse;
+ WriteToClient(clients[xevieClientIndex], sizeof(xEvent), (char *)xE);
+ return;
+ }
+ }
+#endif
+
+ if (!syncEvents.playingEvents)
+ NoticeTime(xE)
+ XE_KBPTR.state = (butc->state | (
+#ifdef XKB
+ (noXkbExtension ?
+ inputInfo.keyboard->key->state :
+ xkbi->state.grab_mods)
+#else
+ inputInfo.keyboard->key->state
+#endif
+ ));
+ {
+ NoticeTime(xE);
+ if (DeviceEventCallback)
+ {
+ DeviceEventInfoRec eventinfo;
+ /* see comment in EnqueueEvents regarding the next three lines */
+ if (xE->u.u.type == MotionNotify)
+ XE_KBPTR.root =
+ WindowTable[sprite.hotPhys.pScreen->myNum]->drawable.id;
+ eventinfo.events = xE;
+ eventinfo.count = count;
+ CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo);
+ }
+ }
+ if (xE->u.u.type != MotionNotify)
+ {
+ register int key;
+ register BYTE *kptr;
+ int bit;
+
+ XE_KBPTR.rootX = sprite.hot.x;
+ XE_KBPTR.rootY = sprite.hot.y;
+
+ key = xE->u.u.detail;
+ kptr = &butc->down[key >> 3];
+ bit = 1 << (key & 7);
+ switch (xE->u.u.type)
+ {
+ case ButtonPress:
+ mouse->valuator->motionHintWindow = NullWindow;
+ if (!(*kptr & bit))
+ butc->buttonsDown++;
+ butc->motionMask = ButtonMotionMask;
+ *kptr |= bit;
+#if !defined(XFree86Server) || !defined(XINPUT)
+ xE->u.u.detail = butc->map[key];
+#endif
+ if (xE->u.u.detail == 0)
+ return;
+ if (xE->u.u.detail <= 5)
+ butc->state |= (Button1Mask >> 1) << xE->u.u.detail;
+ filters[MotionNotify] = Motion_Filter(butc);
+ if (!grab)
+ if (CheckDeviceGrabs(mouse, xE, 0, count))
+ return;
+ break;
+ case ButtonRelease:
+ mouse->valuator->motionHintWindow = NullWindow;
+ if (*kptr & bit)
+ --butc->buttonsDown;
+ if (!butc->buttonsDown)
+ butc->motionMask = 0;
+ *kptr &= ~bit;
+#if !defined(XFree86Server) || !defined(XINPUT)
+ xE->u.u.detail = butc->map[key];
+#endif
+ if (xE->u.u.detail == 0)
+ return;
+ if (xE->u.u.detail <= 5)
+ butc->state &= ~((Button1Mask >> 1) << xE->u.u.detail);
+ filters[MotionNotify] = Motion_Filter(butc);
+ if (!butc->state && mouse->fromPassiveGrab)
+ deactivateGrab = TRUE;
+ break;
+ default:
+ FatalError("bogus pointer event from ddx");
+ }
+ }
+ else if (!CheckMotion(xE))
+ return;
+ if (grab)
+ DeliverGrabbedEvent(xE, mouse, deactivateGrab, count);
+ else
+ DeliverDeviceEvents(sprite.win, xE, NullGrab, NullWindow,
+ mouse, count);
+ if (deactivateGrab)
+ (*mouse->DeactivateGrab)(mouse);
+}
+
+#define AtMostOneClient \
+ (SubstructureRedirectMask | ResizeRedirectMask | ButtonPressMask)
+
+void
+RecalculateDeliverableEvents(pWin)
+ register WindowPtr pWin;
+{
+ register OtherClients *others;
+ register WindowPtr pChild;
+
+ pChild = pWin;
+ while (1)
+ {
+ if (pChild->optional)
+ {
+ pChild->optional->otherEventMasks = 0;
+ for (others = wOtherClients(pChild); others; others = others->next)
+ {
+ pChild->optional->otherEventMasks |= others->mask;
+ }
+ }
+ pChild->deliverableEvents = pChild->eventMask|
+ wOtherEventMasks(pChild);
+ if (pChild->parent)
+ pChild->deliverableEvents |=
+ (pChild->parent->deliverableEvents &
+ ~wDontPropagateMask(pChild) & PropagateMask);
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ while (!pChild->nextSib && (pChild != pWin))
+ pChild = pChild->parent;
+ if (pChild == pWin)
+ break;
+ pChild = pChild->nextSib;
+ }
+}
+
+/**
+ *
+ * \param value must conform to DeleteType
+ */
+int
+OtherClientGone(pointer value, XID id)
+{
+ register OtherClientsPtr other, prev;
+ register WindowPtr pWin = (WindowPtr)value;
+
+ prev = 0;
+ for (other = wOtherClients(pWin); other; other = other->next)
+ {
+ if (other->resource == id)
+ {
+ if (prev)
+ prev->next = other->next;
+ else
+ {
+ if (!(pWin->optional->otherClients = other->next))
+ CheckWindowOptionalNeed (pWin);
+ }
+ xfree(other);
+ RecalculateDeliverableEvents(pWin);
+ return(Success);
+ }
+ prev = other;
+ }
+ FatalError("client not on event list");
+ /*NOTREACHED*/
+ return -1; /* make compiler happy */
+}
+
+int
+EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask mask)
+{
+ Mask check;
+ OtherClients * others;
+
+ if (mask & ~AllEventMasks)
+ {
+ client->errorValue = mask;
+ return BadValue;
+ }
+ check = (mask & AtMostOneClient);
+ if (check & (pWin->eventMask|wOtherEventMasks(pWin)))
+ { /* It is illegal for two different
+ clients to select on any of the
+ events for AtMostOneClient. However,
+ it is OK, for some client to
+ continue selecting on one of those
+ events. */
+ if ((wClient(pWin) != client) && (check & pWin->eventMask))
+ return BadAccess;
+ for (others = wOtherClients (pWin); others; others = others->next)
+ {
+ if (!SameClient(others, client) && (check & others->mask))
+ return BadAccess;
+ }
+ }
+ if (wClient (pWin) == client)
+ {
+ check = pWin->eventMask;
+#ifdef SGIMISC
+ pWin->eventMask =
+ (mask & ~SGIMiscSpecialDestroyMask) | (pWin->eventMask & SGIMiscSpecialDestroyMask);
+#else
+ pWin->eventMask = mask;
+#endif
+ }
+ else
+ {
+ for (others = wOtherClients (pWin); others; others = others->next)
+ {
+ if (SameClient(others, client))
+ {
+ check = others->mask;
+#ifdef SGIMISC
+ mask = (mask & ~SGIMiscSpecialDestroyMask) | (others->mask & SGIMiscSpecialDestroyMask);
+#endif
+ if (mask == 0)
+ {
+ FreeResource(others->resource, RT_NONE);
+ return Success;
+ }
+ else
+ others->mask = mask;
+ goto maskSet;
+ }
+ }
+ check = 0;
+ if (!pWin->optional && !MakeWindowOptional (pWin))
+ return BadAlloc;
+ others = (OtherClients *) xalloc(sizeof(OtherClients));
+ if (!others)
+ return BadAlloc;
+ others->mask = mask;
+ others->resource = FakeClientID(client->index);
+ others->next = pWin->optional->otherClients;
+ pWin->optional->otherClients = others;
+ if (!AddResource(others->resource, RT_OTHERCLIENT, (pointer)pWin))
+ return BadAlloc;
+ }
+maskSet:
+ if ((inputInfo.pointer->valuator->motionHintWindow == pWin) &&
+ (mask & PointerMotionHintMask) &&
+ !(check & PointerMotionHintMask) &&
+ !inputInfo.pointer->grab)
+ inputInfo.pointer->valuator->motionHintWindow = NullWindow;
+ RecalculateDeliverableEvents(pWin);
+ return Success;
+}
+
+int
+EventSuppressForWindow(register WindowPtr pWin, register ClientPtr client,
+ Mask mask, Bool *checkOptional)
+{
+ register int i, free;
+
+ if ((mask & ~PropagateMask) && !permitOldBugs)
+ {
+ client->errorValue = mask;
+ return BadValue;
+ }
+ if (pWin->dontPropagate)
+ DontPropagateRefCnts[pWin->dontPropagate]--;
+ if (!mask)
+ i = 0;
+ else
+ {
+ for (i = DNPMCOUNT, free = 0; --i > 0; )
+ {
+ if (!DontPropagateRefCnts[i])
+ free = i;
+ else if (mask == DontPropagateMasks[i])
+ break;
+ }
+ if (!i && free)
+ {
+ i = free;
+ DontPropagateMasks[i] = mask;
+ }
+ }
+ if (i || !mask)
+ {
+ pWin->dontPropagate = i;
+ if (i)
+ DontPropagateRefCnts[i]++;
+ if (pWin->optional)
+ {
+ pWin->optional->dontPropagateMask = mask;
+ *checkOptional = TRUE;
+ }
+ }
+ else
+ {
+ if (!pWin->optional && !MakeWindowOptional (pWin))
+ {
+ if (pWin->dontPropagate)
+ DontPropagateRefCnts[pWin->dontPropagate]++;
+ return BadAlloc;
+ }
+ pWin->dontPropagate = 0;
+ pWin->optional->dontPropagateMask = mask;
+ }
+ RecalculateDeliverableEvents(pWin);
+ return Success;
+}
+
+static WindowPtr
+CommonAncestor(
+ register WindowPtr a,
+ register WindowPtr b)
+{
+ for (b = b->parent; b; b = b->parent)
+ if (IsParent(b, a)) return b;
+ return NullWindow;
+}
+
+static void
+EnterLeaveEvent(
+ int type,
+ int mode,
+ int detail,
+ register WindowPtr pWin,
+ Window child)
+{
+ xEvent event;
+ register DeviceIntPtr keybd = inputInfo.keyboard;
+ WindowPtr focus;
+ register DeviceIntPtr mouse = inputInfo.pointer;
+ register GrabPtr grab = mouse->grab;
+ Mask mask;
+
+ if ((pWin == mouse->valuator->motionHintWindow) &&
+ (detail != NotifyInferior))
+ mouse->valuator->motionHintWindow = NullWindow;
+ if (grab)
+ {
+ mask = (pWin == grab->window) ? grab->eventMask : 0;
+ if (grab->ownerEvents)
+ mask |= EventMaskForClient(pWin, rClient(grab));
+ }
+ else
+ {
+ mask = pWin->eventMask | wOtherEventMasks(pWin);
+ }
+ if (mask & filters[type])
+ {
+ event.u.u.type = type;
+ event.u.u.detail = detail;
+ event.u.enterLeave.time = currentTime.milliseconds;
+ event.u.enterLeave.rootX = sprite.hot.x;
+ event.u.enterLeave.rootY = sprite.hot.y;
+ /* Counts on the same initial structure of crossing & button events! */
+ FixUpEventFromWindow(&event, pWin, None, FALSE);
+ /* Enter/Leave events always set child */
+ event.u.enterLeave.child = child;
+ event.u.enterLeave.flags = event.u.keyButtonPointer.sameScreen ?
+ ELFlagSameScreen : 0;
+#ifdef XKB
+ if (!noXkbExtension) {
+ event.u.enterLeave.state = mouse->button->state & 0x1f00;
+ event.u.enterLeave.state |=
+ XkbGrabStateFromRec(&keybd->key->xkbInfo->state);
+ } else
+#endif
+ event.u.enterLeave.state = keybd->key->state | mouse->button->state;
+ event.u.enterLeave.mode = mode;
+ focus = keybd->focus->win;
+ if ((focus != NoneWin) &&
+ ((pWin == focus) || (focus == PointerRootWin) ||
+ IsParent(focus, pWin)))
+ event.u.enterLeave.flags |= ELFlagFocus;
+ if (grab)
+ (void)TryClientEvents(rClient(grab), &event, 1, mask,
+ filters[type], grab);
+ else
+ (void)DeliverEventsToWindow(pWin, &event, 1, filters[type],
+ NullGrab, 0);
+ }
+ if ((type == EnterNotify) && (mask & KeymapStateMask))
+ {
+ xKeymapEvent ke;
+
+#ifdef XCSECURITY
+ ClientPtr client = grab ? rClient(grab)
+ : clients[CLIENT_ID(pWin->drawable.id)];
+ if (!SecurityCheckDeviceAccess(client, keybd, FALSE))
+ {
+ bzero((char *)&ke.map[0], 31);
+ }
+ else
+#endif
+ memmove((char *)&ke.map[0], (char *)&keybd->key->down[1], 31);
+ ke.type = KeymapNotify;
+ if (grab)
+ (void)TryClientEvents(rClient(grab), (xEvent *)&ke, 1, mask,
+ KeymapStateMask, grab);
+ else
+ (void)DeliverEventsToWindow(pWin, (xEvent *)&ke, 1,
+ KeymapStateMask, NullGrab, 0);
+ }
+}
+
+static void
+EnterNotifies(WindowPtr ancestor, WindowPtr child, int mode, int detail)
+{
+ WindowPtr parent = child->parent;
+
+ if (ancestor == parent)
+ return;
+ EnterNotifies(ancestor, parent, mode, detail);
+ EnterLeaveEvent(EnterNotify, mode, detail, parent, child->drawable.id);
+}
+
+static void
+LeaveNotifies(WindowPtr child, WindowPtr ancestor, int mode, int detail)
+{
+ register WindowPtr pWin;
+
+ if (ancestor == child)
+ return;
+ for (pWin = child->parent; pWin != ancestor; pWin = pWin->parent)
+ {
+ EnterLeaveEvent(LeaveNotify, mode, detail, pWin, child->drawable.id);
+ child = pWin;
+ }
+}
+
+static void
+DoEnterLeaveEvents(WindowPtr fromWin, WindowPtr toWin, int mode)
+{
+ if (fromWin == toWin)
+ return;
+ if (IsParent(fromWin, toWin))
+ {
+ EnterLeaveEvent(LeaveNotify, mode, NotifyInferior, fromWin, None);
+ EnterNotifies(fromWin, toWin, mode, NotifyVirtual);
+ EnterLeaveEvent(EnterNotify, mode, NotifyAncestor, toWin, None);
+ }
+ else if (IsParent(toWin, fromWin))
+ {
+ EnterLeaveEvent(LeaveNotify, mode, NotifyAncestor, fromWin, None);
+ LeaveNotifies(fromWin, toWin, mode, NotifyVirtual);
+ EnterLeaveEvent(EnterNotify, mode, NotifyInferior, toWin, None);
+ }
+ else
+ { /* neither fromWin nor toWin is descendent of the other */
+ WindowPtr common = CommonAncestor(toWin, fromWin);
+ /* common == NullWindow ==> different screens */
+ EnterLeaveEvent(LeaveNotify, mode, NotifyNonlinear, fromWin, None);
+ LeaveNotifies(fromWin, common, mode, NotifyNonlinearVirtual);
+ EnterNotifies(common, toWin, mode, NotifyNonlinearVirtual);
+ EnterLeaveEvent(EnterNotify, mode, NotifyNonlinear, toWin, None);
+ }
+}
+
+static void
+FocusEvent(DeviceIntPtr dev, int type, int mode, int detail, register WindowPtr pWin)
+{
+ xEvent event;
+
+#ifdef XINPUT
+ if (dev != inputInfo.keyboard)
+ {
+ DeviceFocusEvent(dev, type, mode, detail, pWin);
+ return;
+ }
+#endif
+ event.u.focus.mode = mode;
+ event.u.u.type = type;
+ event.u.u.detail = detail;
+ event.u.focus.window = pWin->drawable.id;
+ (void)DeliverEventsToWindow(pWin, &event, 1, filters[type], NullGrab,
+ 0);
+ if ((type == FocusIn) &&
+ ((pWin->eventMask | wOtherEventMasks(pWin)) & KeymapStateMask))
+ {
+ xKeymapEvent ke;
+#ifdef XCSECURITY
+ ClientPtr client = clients[CLIENT_ID(pWin->drawable.id)];
+ if (!SecurityCheckDeviceAccess(client, dev, FALSE))
+ {
+ bzero((char *)&ke.map[0], 31);
+ }
+ else
+#endif
+ memmove((char *)&ke.map[0], (char *)&dev->key->down[1], 31);
+ ke.type = KeymapNotify;
+ (void)DeliverEventsToWindow(pWin, (xEvent *)&ke, 1,
+ KeymapStateMask, NullGrab, 0);
+ }
+}
+
+ /*
+ * recursive because it is easier
+ * no-op if child not descended from ancestor
+ */
+static Bool
+FocusInEvents(
+ DeviceIntPtr dev,
+ WindowPtr ancestor, WindowPtr child, WindowPtr skipChild,
+ int mode, int detail,
+ Bool doAncestor)
+{
+ if (child == NullWindow)
+ return ancestor == NullWindow;
+ if (ancestor == child)
+ {
+ if (doAncestor)
+ FocusEvent(dev, FocusIn, mode, detail, child);
+ return TRUE;
+ }
+ if (FocusInEvents(dev, ancestor, child->parent, skipChild, mode, detail,
+ doAncestor))
+ {
+ if (child != skipChild)
+ FocusEvent(dev, FocusIn, mode, detail, child);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/* dies horribly if ancestor is not an ancestor of child */
+static void
+FocusOutEvents(
+ DeviceIntPtr dev,
+ WindowPtr child, WindowPtr ancestor,
+ int mode, int detail,
+ Bool doAncestor)
+{
+ register WindowPtr pWin;
+
+ for (pWin = child; pWin != ancestor; pWin = pWin->parent)
+ FocusEvent(dev, FocusOut, mode, detail, pWin);
+ if (doAncestor)
+ FocusEvent(dev, FocusOut, mode, detail, ancestor);
+}
+
+void
+DoFocusEvents(DeviceIntPtr dev, WindowPtr fromWin, WindowPtr toWin, int mode)
+{
+ int out, in; /* for holding details for to/from
+ PointerRoot/None */
+ int i;
+
+ if (fromWin == toWin)
+ return;
+ out = (fromWin == NoneWin) ? NotifyDetailNone : NotifyPointerRoot;
+ in = (toWin == NoneWin) ? NotifyDetailNone : NotifyPointerRoot;
+ /* wrong values if neither, but then not referenced */
+
+ if ((toWin == NullWindow) || (toWin == PointerRootWin))
+ {
+ if ((fromWin == NullWindow) || (fromWin == PointerRootWin))
+ {
+ if (fromWin == PointerRootWin)
+ FocusOutEvents(dev, sprite.win, ROOT, mode, NotifyPointer,
+ TRUE);
+ /* Notify all the roots */
+#ifdef PANORAMIX
+ if ( !noPanoramiXExtension )
+ FocusEvent(dev, FocusOut, mode, out, WindowTable[0]);
+ else
+#endif
+ for (i=0; i<screenInfo.numScreens; i++)
+ FocusEvent(dev, FocusOut, mode, out, WindowTable[i]);
+ }
+ else
+ {
+ if (IsParent(fromWin, sprite.win))
+ FocusOutEvents(dev, sprite.win, fromWin, mode, NotifyPointer,
+ FALSE);
+ FocusEvent(dev, FocusOut, mode, NotifyNonlinear, fromWin);
+ /* next call catches the root too, if the screen changed */
+ FocusOutEvents(dev, fromWin->parent, NullWindow, mode,
+ NotifyNonlinearVirtual, FALSE);
+ }
+ /* Notify all the roots */
+#ifdef PANORAMIX
+ if ( !noPanoramiXExtension )
+ FocusEvent(dev, FocusIn, mode, in, WindowTable[0]);
+ else
+#endif
+ for (i=0; i<screenInfo.numScreens; i++)
+ FocusEvent(dev, FocusIn, mode, in, WindowTable[i]);
+ if (toWin == PointerRootWin)
+ (void)FocusInEvents(dev, ROOT, sprite.win, NullWindow, mode,
+ NotifyPointer, TRUE);
+ }
+ else
+ {
+ if ((fromWin == NullWindow) || (fromWin == PointerRootWin))
+ {
+ if (fromWin == PointerRootWin)
+ FocusOutEvents(dev, sprite.win, ROOT, mode, NotifyPointer,
+ TRUE);
+#ifdef PANORAMIX
+ if ( !noPanoramiXExtension )
+ FocusEvent(dev, FocusOut, mode, out, WindowTable[0]);
+ else
+#endif
+ for (i=0; i<screenInfo.numScreens; i++)
+ FocusEvent(dev, FocusOut, mode, out, WindowTable[i]);
+ if (toWin->parent != NullWindow)
+ (void)FocusInEvents(dev, ROOT, toWin, toWin, mode,
+ NotifyNonlinearVirtual, TRUE);
+ FocusEvent(dev, FocusIn, mode, NotifyNonlinear, toWin);
+ if (IsParent(toWin, sprite.win))
+ (void)FocusInEvents(dev, toWin, sprite.win, NullWindow, mode,
+ NotifyPointer, FALSE);
+ }
+ else
+ {
+ if (IsParent(toWin, fromWin))
+ {
+ FocusEvent(dev, FocusOut, mode, NotifyAncestor, fromWin);
+ FocusOutEvents(dev, fromWin->parent, toWin, mode,
+ NotifyVirtual, FALSE);
+ FocusEvent(dev, FocusIn, mode, NotifyInferior, toWin);
+ if ((IsParent(toWin, sprite.win)) &&
+ (sprite.win != fromWin) &&
+ (!IsParent(fromWin, sprite.win)) &&
+ (!IsParent(sprite.win, fromWin)))
+ (void)FocusInEvents(dev, toWin, sprite.win, NullWindow,
+ mode, NotifyPointer, FALSE);
+ }
+ else
+ if (IsParent(fromWin, toWin))
+ {
+ if ((IsParent(fromWin, sprite.win)) &&
+ (sprite.win != fromWin) &&
+ (!IsParent(toWin, sprite.win)) &&
+ (!IsParent(sprite.win, toWin)))
+ FocusOutEvents(dev, sprite.win, fromWin, mode,
+ NotifyPointer, FALSE);
+ FocusEvent(dev, FocusOut, mode, NotifyInferior, fromWin);
+ (void)FocusInEvents(dev, fromWin, toWin, toWin, mode,
+ NotifyVirtual, FALSE);
+ FocusEvent(dev, FocusIn, mode, NotifyAncestor, toWin);
+ }
+ else
+ {
+ /* neither fromWin or toWin is child of other */
+ WindowPtr common = CommonAncestor(toWin, fromWin);
+ /* common == NullWindow ==> different screens */
+ if (IsParent(fromWin, sprite.win))
+ FocusOutEvents(dev, sprite.win, fromWin, mode,
+ NotifyPointer, FALSE);
+ FocusEvent(dev, FocusOut, mode, NotifyNonlinear, fromWin);
+ if (fromWin->parent != NullWindow)
+ FocusOutEvents(dev, fromWin->parent, common, mode,
+ NotifyNonlinearVirtual, FALSE);
+ if (toWin->parent != NullWindow)
+ (void)FocusInEvents(dev, common, toWin, toWin, mode,
+ NotifyNonlinearVirtual, FALSE);
+ FocusEvent(dev, FocusIn, mode, NotifyNonlinear, toWin);
+ if (IsParent(toWin, sprite.win))
+ (void)FocusInEvents(dev, toWin, sprite.win, NullWindow,
+ mode, NotifyPointer, FALSE);
+ }
+ }
+ }
+}
+
+int
+SetInputFocus(
+ ClientPtr client,
+ DeviceIntPtr dev,
+ Window focusID,
+ CARD8 revertTo,
+ Time ctime,
+ Bool followOK)
+{
+ register FocusClassPtr focus;
+ register WindowPtr focusWin;
+ int mode;
+ TimeStamp time;
+
+ UpdateCurrentTime();
+ if ((revertTo != RevertToParent) &&
+ (revertTo != RevertToPointerRoot) &&
+ (revertTo != RevertToNone) &&
+ ((revertTo != RevertToFollowKeyboard) || !followOK))
+ {
+ client->errorValue = revertTo;
+ return BadValue;
+ }
+ time = ClientTimeToServerTime(ctime);
+ if ((focusID == None) || (focusID == PointerRoot))
+ focusWin = (WindowPtr)(long)focusID;
+ else if ((focusID == FollowKeyboard) && followOK)
+ focusWin = inputInfo.keyboard->focus->win;
+ else if (!(focusWin = SecurityLookupWindow(focusID, client,
+ SecurityReadAccess)))
+ return BadWindow;
+ else
+ {
+ /* It is a match error to try to set the input focus to an
+ unviewable window. */
+
+ if(!focusWin->realized)
+ return(BadMatch);
+ }
+ focus = dev->focus;
+ if ((CompareTimeStamps(time, currentTime) == LATER) ||
+ (CompareTimeStamps(time, focus->time) == EARLIER))
+ return Success;
+ mode = (dev->grab) ? NotifyWhileGrabbed : NotifyNormal;
+ if (focus->win == FollowKeyboardWin)
+ DoFocusEvents(dev, inputInfo.keyboard->focus->win, focusWin, mode);
+ else
+ DoFocusEvents(dev, focus->win, focusWin, mode);
+ focus->time = time;
+ focus->revert = revertTo;
+ if (focusID == FollowKeyboard)
+ focus->win = FollowKeyboardWin;
+ else
+ focus->win = focusWin;
+ if ((focusWin == NoneWin) || (focusWin == PointerRootWin))
+ focus->traceGood = 0;
+ else
+ {
+ int depth = 0;
+ register WindowPtr pWin;
+
+ for (pWin = focusWin; pWin; pWin = pWin->parent) depth++;
+ if (depth > focus->traceSize)
+ {
+ focus->traceSize = depth+1;
+ Must_have_memory = TRUE; /* XXX */
+ focus->trace = (WindowPtr *)xrealloc(focus->trace,
+ focus->traceSize *
+ sizeof(WindowPtr));
+ Must_have_memory = FALSE; /* XXX */
+ }
+ focus->traceGood = depth;
+ for (pWin = focusWin, depth--; pWin; pWin = pWin->parent, depth--)
+ focus->trace[depth] = pWin;
+ }
+ return Success;
+}
+
+int
+ProcSetInputFocus(client)
+ ClientPtr client;
+{
+ REQUEST(xSetInputFocusReq);
+
+ REQUEST_SIZE_MATCH(xSetInputFocusReq);
+#ifdef XCSECURITY
+ if (!SecurityCheckDeviceAccess(client, inputInfo.keyboard, TRUE))
+ return Success;
+#endif
+ return SetInputFocus(client, inputInfo.keyboard, stuff->focus,
+ stuff->revertTo, stuff->time, FALSE);
+}
+
+int
+ProcGetInputFocus(ClientPtr client)
+{
+ xGetInputFocusReply rep;
+ /* REQUEST(xReq); */
+ FocusClassPtr focus = inputInfo.keyboard->focus;
+
+ REQUEST_SIZE_MATCH(xReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ if (focus->win == NoneWin)
+ rep.focus = None;
+ else if (focus->win == PointerRootWin)
+ rep.focus = PointerRoot;
+ else rep.focus = focus->win->drawable.id;
+ rep.revertTo = focus->revert;
+ WriteReplyToClient(client, sizeof(xGetInputFocusReply), &rep);
+ return Success;
+}
+
+int
+ProcGrabPointer(ClientPtr client)
+{
+ xGrabPointerReply rep;
+ DeviceIntPtr device = inputInfo.pointer;
+ GrabPtr grab;
+ WindowPtr pWin, confineTo;
+ CursorPtr cursor, oldCursor;
+ REQUEST(xGrabPointerReq);
+ TimeStamp time;
+
+ REQUEST_SIZE_MATCH(xGrabPointerReq);
+ UpdateCurrentTime();
+ if ((stuff->pointerMode != GrabModeSync) &&
+ (stuff->pointerMode != GrabModeAsync))
+ {
+ client->errorValue = stuff->pointerMode;
+ return BadValue;
+ }
+ if ((stuff->keyboardMode != GrabModeSync) &&
+ (stuff->keyboardMode != GrabModeAsync))
+ {
+ client->errorValue = stuff->keyboardMode;
+ return BadValue;
+ }
+ if ((stuff->ownerEvents != xFalse) && (stuff->ownerEvents != xTrue))
+ {
+ client->errorValue = stuff->ownerEvents;
+ return BadValue;
+ }
+ if ((stuff->eventMask & ~PointerGrabMask) && !permitOldBugs)
+ {
+ client->errorValue = stuff->eventMask;
+ return BadValue;
+ }
+ pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
+ if (!pWin)
+ return BadWindow;
+ if (stuff->confineTo == None)
+ confineTo = NullWindow;
+ else
+ {
+ confineTo = SecurityLookupWindow(stuff->confineTo, client,
+ SecurityReadAccess);
+ if (!confineTo)
+ return BadWindow;
+ }
+ if (stuff->cursor == None)
+ cursor = NullCursor;
+ else
+ {
+ cursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
+ RT_CURSOR, SecurityReadAccess);
+ if (!cursor)
+ {
+ client->errorValue = stuff->cursor;
+ return BadCursor;
+ }
+ }
+ /* at this point, some sort of reply is guaranteed. */
+ time = ClientTimeToServerTime(stuff->time);
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ grab = device->grab;
+ if ((grab) && !SameClient(grab, client))
+ rep.status = AlreadyGrabbed;
+ else if ((!pWin->realized) ||
+ (confineTo &&
+ !(confineTo->realized && BorderSizeNotEmpty(confineTo))))
+ rep.status = GrabNotViewable;
+ else if (device->sync.frozen &&
+ device->sync.other && !SameClient(device->sync.other, client))
+ rep.status = GrabFrozen;
+ else if ((CompareTimeStamps(time, currentTime) == LATER) ||
+ (CompareTimeStamps(time, device->grabTime) == EARLIER))
+ rep.status = GrabInvalidTime;
+ else
+ {
+ GrabRec tempGrab;
+
+ oldCursor = NullCursor;
+ if (grab)
+ {
+ if (grab->confineTo && !confineTo)
+ ConfineCursorToWindow(ROOT, FALSE, FALSE);
+ oldCursor = grab->cursor;
+ }
+ tempGrab.cursor = cursor;
+ tempGrab.resource = client->clientAsMask;
+ tempGrab.ownerEvents = stuff->ownerEvents;
+ tempGrab.eventMask = stuff->eventMask;
+ tempGrab.confineTo = confineTo;
+ tempGrab.window = pWin;
+ tempGrab.keyboardMode = stuff->keyboardMode;
+ tempGrab.pointerMode = stuff->pointerMode;
+ tempGrab.device = device;
+ (*device->ActivateGrab)(device, &tempGrab, time, FALSE);
+ if (oldCursor)
+ FreeCursor (oldCursor, (Cursor)0);
+ rep.status = GrabSuccess;
+ }
+ WriteReplyToClient(client, sizeof(xGrabPointerReply), &rep);
+ return Success;
+}
+
+int
+ProcChangeActivePointerGrab(ClientPtr client)
+{
+ DeviceIntPtr device = inputInfo.pointer;
+ register GrabPtr grab = device->grab;
+ CursorPtr newCursor, oldCursor;
+ REQUEST(xChangeActivePointerGrabReq);
+ TimeStamp time;
+
+ REQUEST_SIZE_MATCH(xChangeActivePointerGrabReq);
+ if ((stuff->eventMask & ~PointerGrabMask) && !permitOldBugs)
+ {
+ client->errorValue = stuff->eventMask;
+ return BadValue;
+ }
+ if (stuff->cursor == None)
+ newCursor = NullCursor;
+ else
+ {
+ newCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
+ RT_CURSOR, SecurityReadAccess);
+ if (!newCursor)
+ {
+ client->errorValue = stuff->cursor;
+ return BadCursor;
+ }
+ }
+ if (!grab)
+ return Success;
+ if (!SameClient(grab, client))
+ return Success;
+ time = ClientTimeToServerTime(stuff->time);
+ if ((CompareTimeStamps(time, currentTime) == LATER) ||
+ (CompareTimeStamps(time, device->grabTime) == EARLIER))
+ return Success;
+ oldCursor = grab->cursor;
+ grab->cursor = newCursor;
+ if (newCursor)
+ newCursor->refcnt++;
+ PostNewCursor();
+ if (oldCursor)
+ FreeCursor(oldCursor, (Cursor)0);
+ grab->eventMask = stuff->eventMask;
+ return Success;
+}
+
+int
+ProcUngrabPointer(ClientPtr client)
+{
+ DeviceIntPtr device = inputInfo.pointer;
+ GrabPtr grab;
+ TimeStamp time;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ UpdateCurrentTime();
+ grab = device->grab;
+ time = ClientTimeToServerTime(stuff->id);
+ if ((CompareTimeStamps(time, currentTime) != LATER) &&
+ (CompareTimeStamps(time, device->grabTime) != EARLIER) &&
+ (grab) && SameClient(grab, client))
+ (*device->DeactivateGrab)(device);
+ return Success;
+}
+
+int
+GrabDevice(register ClientPtr client, register DeviceIntPtr dev,
+ unsigned this_mode, unsigned other_mode, Window grabWindow,
+ unsigned ownerEvents, Time ctime, Mask mask, CARD8 *status)
+{
+ register WindowPtr pWin;
+ register GrabPtr grab;
+ TimeStamp time;
+
+ UpdateCurrentTime();
+ if ((this_mode != GrabModeSync) && (this_mode != GrabModeAsync))
+ {
+ client->errorValue = this_mode;
+ return BadValue;
+ }
+ if ((other_mode != GrabModeSync) && (other_mode != GrabModeAsync))
+ {
+ client->errorValue = other_mode;
+ return BadValue;
+ }
+ if ((ownerEvents != xFalse) && (ownerEvents != xTrue))
+ {
+ client->errorValue = ownerEvents;
+ return BadValue;
+ }
+ pWin = SecurityLookupWindow(grabWindow, client, SecurityReadAccess);
+ if (!pWin)
+ return BadWindow;
+ time = ClientTimeToServerTime(ctime);
+ grab = dev->grab;
+ if (grab && !SameClient(grab, client))
+ *status = AlreadyGrabbed;
+ else if (!pWin->realized)
+ *status = GrabNotViewable;
+ else if ((CompareTimeStamps(time, currentTime) == LATER) ||
+ (CompareTimeStamps(time, dev->grabTime) == EARLIER))
+ *status = GrabInvalidTime;
+ else if (dev->sync.frozen &&
+ dev->sync.other && !SameClient(dev->sync.other, client))
+ *status = GrabFrozen;
+ else
+ {
+ GrabRec tempGrab;
+
+ tempGrab.window = pWin;
+ tempGrab.resource = client->clientAsMask;
+ tempGrab.ownerEvents = ownerEvents;
+ tempGrab.keyboardMode = this_mode;
+ tempGrab.pointerMode = other_mode;
+ tempGrab.eventMask = mask;
+ tempGrab.device = dev;
+ (*dev->ActivateGrab)(dev, &tempGrab, time, FALSE);
+ *status = GrabSuccess;
+ }
+ return Success;
+}
+
+int
+ProcGrabKeyboard(ClientPtr client)
+{
+ xGrabKeyboardReply rep;
+ REQUEST(xGrabKeyboardReq);
+ int result;
+
+ REQUEST_SIZE_MATCH(xGrabKeyboardReq);
+#ifdef XCSECURITY
+ if (!SecurityCheckDeviceAccess(client, inputInfo.keyboard, TRUE))
+ {
+ result = Success;
+ rep.status = AlreadyGrabbed;
+ }
+ else
+#endif
+ result = GrabDevice(client, inputInfo.keyboard, stuff->keyboardMode,
+ stuff->pointerMode, stuff->grabWindow,
+ stuff->ownerEvents, stuff->time,
+ KeyPressMask | KeyReleaseMask, &rep.status);
+ if (result != Success)
+ return result;
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ WriteReplyToClient(client, sizeof(xGrabKeyboardReply), &rep);
+ return Success;
+}
+
+int
+ProcUngrabKeyboard(ClientPtr client)
+{
+ DeviceIntPtr device = inputInfo.keyboard;
+ GrabPtr grab;
+ TimeStamp time;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ UpdateCurrentTime();
+ grab = device->grab;
+ time = ClientTimeToServerTime(stuff->id);
+ if ((CompareTimeStamps(time, currentTime) != LATER) &&
+ (CompareTimeStamps(time, device->grabTime) != EARLIER) &&
+ (grab) && SameClient(grab, client))
+ (*device->DeactivateGrab)(device);
+ return Success;
+}
+
+int
+ProcQueryPointer(ClientPtr client)
+{
+ xQueryPointerReply rep;
+ WindowPtr pWin, t;
+ REQUEST(xResourceReq);
+ DeviceIntPtr mouse = inputInfo.pointer;
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pWin = SecurityLookupWindow(stuff->id, client, SecurityReadAccess);
+ if (!pWin)
+ return BadWindow;
+ if (mouse->valuator->motionHintWindow)
+ MaybeStopHint(mouse, client);
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.mask = mouse->button->state | inputInfo.keyboard->key->state;
+ rep.length = 0;
+ rep.root = (ROOT)->drawable.id;
+ rep.rootX = sprite.hot.x;
+ rep.rootY = sprite.hot.y;
+ rep.child = None;
+ if (sprite.hot.pScreen == pWin->drawable.pScreen)
+ {
+ rep.sameScreen = xTrue;
+ rep.winX = sprite.hot.x - pWin->drawable.x;
+ rep.winY = sprite.hot.y - pWin->drawable.y;
+ for (t = sprite.win; t; t = t->parent)
+ if (t->parent == pWin)
+ {
+ rep.child = t->drawable.id;
+ break;
+ }
+ }
+ else
+ {
+ rep.sameScreen = xFalse;
+ rep.winX = 0;
+ rep.winY = 0;
+ }
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ rep.rootX += panoramiXdataPtr[0].x;
+ rep.rootY += panoramiXdataPtr[0].y;
+ if(stuff->id == rep.root) {
+ rep.winX += panoramiXdataPtr[0].x;
+ rep.winY += panoramiXdataPtr[0].y;
+ }
+ }
+#endif
+
+ WriteReplyToClient(client, sizeof(xQueryPointerReply), &rep);
+
+ return(Success);
+}
+
+void
+InitEvents()
+{
+ int i;
+
+ sprite.hot.pScreen = sprite.hotPhys.pScreen = (ScreenPtr)NULL;
+ inputInfo.numDevices = 0;
+ inputInfo.devices = (DeviceIntPtr)NULL;
+ inputInfo.off_devices = (DeviceIntPtr)NULL;
+ inputInfo.keyboard = (DeviceIntPtr)NULL;
+ inputInfo.pointer = (DeviceIntPtr)NULL;
+ if (spriteTraceSize == 0)
+ {
+ spriteTraceSize = 32;
+ spriteTrace = (WindowPtr *)xalloc(32*sizeof(WindowPtr));
+ if (!spriteTrace)
+ FatalError("failed to allocate spriteTrace");
+ }
+ spriteTraceGood = 0;
+ lastEventMask = OwnerGrabButtonMask;
+ filters[MotionNotify] = PointerMotionMask;
+#ifdef XEVIE
+ xeviewin =
+#endif
+ sprite.win = NullWindow;
+ sprite.current = NullCursor;
+ sprite.hotLimits.x1 = 0;
+ sprite.hotLimits.y1 = 0;
+ sprite.hotLimits.x2 = 0;
+ sprite.hotLimits.y2 = 0;
+ sprite.confined = FALSE;
+ syncEvents.replayDev = (DeviceIntPtr)NULL;
+ syncEvents.replayWin = NullWindow;
+ while (syncEvents.pending)
+ {
+ QdEventPtr next = syncEvents.pending->next;
+ xfree(syncEvents.pending);
+ syncEvents.pending = next;
+ }
+ syncEvents.pendtail = &syncEvents.pending;
+ syncEvents.playingEvents = FALSE;
+ syncEvents.time.months = 0;
+ syncEvents.time.milliseconds = 0; /* hardly matters */
+ currentTime.months = 0;
+ currentTime.milliseconds = GetTimeInMillis();
+ lastDeviceEventTime = currentTime;
+ for (i = 0; i < DNPMCOUNT; i++)
+ {
+ DontPropagateMasks[i] = 0;
+ DontPropagateRefCnts[i] = 0;
+ }
+}
+
+void
+CloseDownEvents(void)
+{
+ xfree(spriteTrace);
+ spriteTrace = NULL;
+ spriteTraceSize = 0;
+}
+
+int
+ProcSendEvent(ClientPtr client)
+{
+ WindowPtr pWin;
+ WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */
+ REQUEST(xSendEventReq);
+
+ REQUEST_SIZE_MATCH(xSendEventReq);
+
+ /* The client's event type must be a core event type or one defined by an
+ extension. */
+
+ if ( ! ((stuff->event.u.u.type > X_Reply &&
+ stuff->event.u.u.type < LASTEvent) ||
+ (stuff->event.u.u.type >= EXTENSION_EVENT_BASE &&
+ stuff->event.u.u.type < (unsigned)lastEvent)))
+ {
+ client->errorValue = stuff->event.u.u.type;
+ return BadValue;
+ }
+ if (stuff->event.u.u.type == ClientMessage &&
+ stuff->event.u.u.detail != 8 &&
+ stuff->event.u.u.detail != 16 &&
+ stuff->event.u.u.detail != 32 &&
+ !permitOldBugs)
+ {
+ client->errorValue = stuff->event.u.u.detail;
+ return BadValue;
+ }
+ if ((stuff->eventMask & ~AllEventMasks) && !permitOldBugs)
+ {
+ client->errorValue = stuff->eventMask;
+ return BadValue;
+ }
+
+ if (stuff->destination == PointerWindow)
+ pWin = sprite.win;
+ else if (stuff->destination == InputFocus)
+ {
+ WindowPtr inputFocus = inputInfo.keyboard->focus->win;
+
+ if (inputFocus == NoneWin)
+ return Success;
+
+ /* If the input focus is PointerRootWin, send the event to where
+ the pointer is if possible, then perhaps propogate up to root. */
+ if (inputFocus == PointerRootWin)
+ inputFocus = ROOT;
+
+ if (IsParent(inputFocus, sprite.win))
+ {
+ effectiveFocus = inputFocus;
+ pWin = sprite.win;
+ }
+ else
+ effectiveFocus = pWin = inputFocus;
+ }
+ else
+ pWin = SecurityLookupWindow(stuff->destination, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return BadWindow;
+ if ((stuff->propagate != xFalse) && (stuff->propagate != xTrue))
+ {
+ client->errorValue = stuff->propagate;
+ return BadValue;
+ }
+ stuff->event.u.u.type |= 0x80;
+ if (stuff->propagate)
+ {
+ for (;pWin; pWin = pWin->parent)
+ {
+ if (DeliverEventsToWindow(pWin, &stuff->event, 1, stuff->eventMask,
+ NullGrab, 0))
+ return Success;
+ if (pWin == effectiveFocus)
+ return Success;
+ stuff->eventMask &= ~wDontPropagateMask(pWin);
+ if (!stuff->eventMask)
+ break;
+ }
+ }
+ else
+ (void)DeliverEventsToWindow(pWin, &stuff->event, 1, stuff->eventMask,
+ NullGrab, 0);
+ return Success;
+}
+
+int
+ProcUngrabKey(ClientPtr client)
+{
+ REQUEST(xUngrabKeyReq);
+ WindowPtr pWin;
+ GrabRec tempGrab;
+ DeviceIntPtr keybd = inputInfo.keyboard;
+
+ REQUEST_SIZE_MATCH(xUngrabKeyReq);
+ pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
+ if (!pWin)
+ return BadWindow;
+
+ if (((stuff->key > keybd->key->curKeySyms.maxKeyCode) ||
+ (stuff->key < keybd->key->curKeySyms.minKeyCode))
+ && (stuff->key != AnyKey))
+ {
+ client->errorValue = stuff->key;
+ return BadValue;
+ }
+ if ((stuff->modifiers != AnyModifier) &&
+ (stuff->modifiers & ~AllModifiersMask))
+ {
+ client->errorValue = stuff->modifiers;
+ return BadValue;
+ }
+ tempGrab.resource = client->clientAsMask;
+ tempGrab.device = keybd;
+ tempGrab.window = pWin;
+ tempGrab.modifiersDetail.exact = stuff->modifiers;
+ tempGrab.modifiersDetail.pMask = NULL;
+ tempGrab.modifierDevice = inputInfo.keyboard;
+ tempGrab.type = KeyPress;
+ tempGrab.detail.exact = stuff->key;
+ tempGrab.detail.pMask = NULL;
+
+ if (!DeletePassiveGrabFromList(&tempGrab))
+ return(BadAlloc);
+ return(Success);
+}
+
+int
+ProcGrabKey(ClientPtr client)
+{
+ WindowPtr pWin;
+ REQUEST(xGrabKeyReq);
+ GrabPtr grab;
+ DeviceIntPtr keybd = inputInfo.keyboard;
+
+ REQUEST_SIZE_MATCH(xGrabKeyReq);
+ if ((stuff->ownerEvents != xTrue) && (stuff->ownerEvents != xFalse))
+ {
+ client->errorValue = stuff->ownerEvents;
+ return(BadValue);
+ }
+ if ((stuff->pointerMode != GrabModeSync) &&
+ (stuff->pointerMode != GrabModeAsync))
+ {
+ client->errorValue = stuff->pointerMode;
+ return BadValue;
+ }
+ if ((stuff->keyboardMode != GrabModeSync) &&
+ (stuff->keyboardMode != GrabModeAsync))
+ {
+ client->errorValue = stuff->keyboardMode;
+ return BadValue;
+ }
+ if (((stuff->key > keybd->key->curKeySyms.maxKeyCode) ||
+ (stuff->key < keybd->key->curKeySyms.minKeyCode))
+ && (stuff->key != AnyKey))
+ {
+ client->errorValue = stuff->key;
+ return BadValue;
+ }
+ if ((stuff->modifiers != AnyModifier) &&
+ (stuff->modifiers & ~AllModifiersMask))
+ {
+ client->errorValue = stuff->modifiers;
+ return BadValue;
+ }
+ pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
+ if (!pWin)
+ return BadWindow;
+
+ grab = CreateGrab(client->index, keybd, pWin,
+ (Mask)(KeyPressMask | KeyReleaseMask), (Bool)stuff->ownerEvents,
+ (Bool)stuff->keyboardMode, (Bool)stuff->pointerMode,
+ keybd, stuff->modifiers, KeyPress, stuff->key,
+ NullWindow, NullCursor);
+ if (!grab)
+ return BadAlloc;
+ return AddPassiveGrabToList(grab);
+}
+
+
+int
+ProcGrabButton(ClientPtr client)
+{
+ WindowPtr pWin, confineTo;
+ REQUEST(xGrabButtonReq);
+ CursorPtr cursor;
+ GrabPtr grab;
+
+ REQUEST_SIZE_MATCH(xGrabButtonReq);
+ if ((stuff->pointerMode != GrabModeSync) &&
+ (stuff->pointerMode != GrabModeAsync))
+ {
+ client->errorValue = stuff->pointerMode;
+ return BadValue;
+ }
+ if ((stuff->keyboardMode != GrabModeSync) &&
+ (stuff->keyboardMode != GrabModeAsync))
+ {
+ client->errorValue = stuff->keyboardMode;
+ return BadValue;
+ }
+ if ((stuff->modifiers != AnyModifier) &&
+ (stuff->modifiers & ~AllModifiersMask))
+ {
+ client->errorValue = stuff->modifiers;
+ return BadValue;
+ }
+ if ((stuff->ownerEvents != xFalse) && (stuff->ownerEvents != xTrue))
+ {
+ client->errorValue = stuff->ownerEvents;
+ return BadValue;
+ }
+ if (stuff->eventMask & ~PointerGrabMask)
+ {
+ client->errorValue = stuff->eventMask;
+ return BadValue;
+ }
+ pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
+ if (!pWin)
+ return BadWindow;
+ if (stuff->confineTo == None)
+ confineTo = NullWindow;
+ else {
+ confineTo = SecurityLookupWindow(stuff->confineTo, client,
+ SecurityReadAccess);
+ if (!confineTo)
+ return BadWindow;
+ }
+ if (stuff->cursor == None)
+ cursor = NullCursor;
+ else
+ {
+ cursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
+ RT_CURSOR, SecurityReadAccess);
+ if (!cursor)
+ {
+ client->errorValue = stuff->cursor;
+ return BadCursor;
+ }
+ }
+
+
+ grab = CreateGrab(client->index, inputInfo.pointer, pWin,
+ permitOldBugs ? (Mask)(stuff->eventMask |
+ ButtonPressMask | ButtonReleaseMask) :
+ (Mask)stuff->eventMask,
+ (Bool)stuff->ownerEvents, (Bool) stuff->keyboardMode,
+ (Bool)stuff->pointerMode, inputInfo.keyboard, stuff->modifiers,
+ ButtonPress, stuff->button, confineTo, cursor);
+ if (!grab)
+ return BadAlloc;
+ return AddPassiveGrabToList(grab);
+}
+
+int
+ProcUngrabButton(ClientPtr client)
+{
+ REQUEST(xUngrabButtonReq);
+ WindowPtr pWin;
+ GrabRec tempGrab;
+
+ REQUEST_SIZE_MATCH(xUngrabButtonReq);
+ if ((stuff->modifiers != AnyModifier) &&
+ (stuff->modifiers & ~AllModifiersMask))
+ {
+ client->errorValue = stuff->modifiers;
+ return BadValue;
+ }
+ pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess);
+ if (!pWin)
+ return BadWindow;
+ tempGrab.resource = client->clientAsMask;
+ tempGrab.device = inputInfo.pointer;
+ tempGrab.window = pWin;
+ tempGrab.modifiersDetail.exact = stuff->modifiers;
+ tempGrab.modifiersDetail.pMask = NULL;
+ tempGrab.modifierDevice = inputInfo.keyboard;
+ tempGrab.type = ButtonPress;
+ tempGrab.detail.exact = stuff->button;
+ tempGrab.detail.pMask = NULL;
+
+ if (!DeletePassiveGrabFromList(&tempGrab))
+ return(BadAlloc);
+ return(Success);
+}
+
+void
+DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
+{
+ WindowPtr parent;
+ DeviceIntPtr mouse = inputInfo.pointer;
+ DeviceIntPtr keybd = inputInfo.keyboard;
+ FocusClassPtr focus = keybd->focus;
+ OtherClientsPtr oc;
+ GrabPtr passive;
+
+
+ /* Deactivate any grabs performed on this window, before making any
+ input focus changes. */
+
+ if (mouse->grab &&
+ ((mouse->grab->window == pWin) || (mouse->grab->confineTo == pWin)))
+ (*mouse->DeactivateGrab)(mouse);
+
+ /* Deactivating a keyboard grab should cause focus events. */
+
+ if (keybd->grab && (keybd->grab->window == pWin))
+ (*keybd->DeactivateGrab)(keybd);
+
+ /* If the focus window is a root window (ie. has no parent) then don't
+ delete the focus from it. */
+
+ if ((pWin == focus->win) && (pWin->parent != NullWindow))
+ {
+ int focusEventMode = NotifyNormal;
+
+ /* If a grab is in progress, then alter the mode of focus events. */
+
+ if (keybd->grab)
+ focusEventMode = NotifyWhileGrabbed;
+
+ switch (focus->revert)
+ {
+ case RevertToNone:
+ DoFocusEvents(keybd, pWin, NoneWin, focusEventMode);
+ focus->win = NoneWin;
+ focus->traceGood = 0;
+ break;
+ case RevertToParent:
+ parent = pWin;
+ do
+ {
+ parent = parent->parent;
+ focus->traceGood--;
+ } while (!parent->realized
+/* This would be a good protocol change -- windows being reparented
+ during SaveSet processing would cause the focus to revert to the
+ nearest enclosing window which will survive the death of the exiting
+ client, instead of ending up reverting to a dying window and thence
+ to None
+ */
+#ifdef NOTDEF
+ || clients[CLIENT_ID(parent->drawable.id)]->clientGone
+#endif
+ );
+ DoFocusEvents(keybd, pWin, parent, focusEventMode);
+ focus->win = parent;
+ focus->revert = RevertToNone;
+ break;
+ case RevertToPointerRoot:
+ DoFocusEvents(keybd, pWin, PointerRootWin, focusEventMode);
+ focus->win = PointerRootWin;
+ focus->traceGood = 0;
+ break;
+ }
+ }
+
+ if (mouse->valuator->motionHintWindow == pWin)
+ mouse->valuator->motionHintWindow = NullWindow;
+
+ if (freeResources)
+ {
+ if (pWin->dontPropagate)
+ DontPropagateRefCnts[pWin->dontPropagate]--;
+ while ( (oc = wOtherClients(pWin)) )
+ FreeResource(oc->resource, RT_NONE);
+ while ( (passive = wPassiveGrabs(pWin)) )
+ FreeResource(passive->resource, RT_NONE);
+ }
+#ifdef XINPUT
+ DeleteWindowFromAnyExtEvents(pWin, freeResources);
+#endif
+}
+
+/**
+ * Call this whenever some window at or below pWin has changed geometry
+ */
+void
+CheckCursorConfinement(WindowPtr pWin)
+{
+ GrabPtr grab = inputInfo.pointer->grab;
+ WindowPtr confineTo;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) return;
+#endif
+
+ if (grab && (confineTo = grab->confineTo))
+ {
+ if (!BorderSizeNotEmpty(confineTo))
+ (*inputInfo.pointer->DeactivateGrab)(inputInfo.pointer);
+ else if ((pWin == confineTo) || IsParent(pWin, confineTo))
+ ConfineCursorToWindow(confineTo, TRUE, TRUE);
+ }
+}
+
+Mask
+EventMaskForClient(WindowPtr pWin, ClientPtr client)
+{
+ register OtherClientsPtr other;
+
+ if (wClient (pWin) == client)
+ return pWin->eventMask;
+ for (other = wOtherClients(pWin); other; other = other->next)
+ {
+ if (SameClient(other, client))
+ return other->mask;
+ }
+ return 0;
+}
+
+int
+ProcRecolorCursor(ClientPtr client)
+{
+ CursorPtr pCursor;
+ int nscr;
+ ScreenPtr pscr;
+ Bool displayed;
+ REQUEST(xRecolorCursorReq);
+
+ REQUEST_SIZE_MATCH(xRecolorCursorReq);
+ pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
+ RT_CURSOR, SecurityWriteAccess);
+ if ( !pCursor)
+ {
+ client->errorValue = stuff->cursor;
+ return (BadCursor);
+ }
+
+ pCursor->foreRed = stuff->foreRed;
+ pCursor->foreGreen = stuff->foreGreen;
+ pCursor->foreBlue = stuff->foreBlue;
+
+ pCursor->backRed = stuff->backRed;
+ pCursor->backGreen = stuff->backGreen;
+ pCursor->backBlue = stuff->backBlue;
+
+ for (nscr = 0; nscr < screenInfo.numScreens; nscr++)
+ {
+ pscr = screenInfo.screens[nscr];
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ displayed = (pscr == sprite.screen);
+ else
+#endif
+ displayed = (pscr == sprite.hotPhys.pScreen);
+ ( *pscr->RecolorCursor)(pscr, pCursor,
+ (pCursor == sprite.current) && displayed);
+ }
+ return (Success);
+}
+
+void
+WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
+{
+#ifdef PANORAMIX
+ xEvent eventCopy;
+#endif
+ xEvent eventTo, *eventFrom;
+ int i;
+
+#ifdef XKB
+ if ((!noXkbExtension)&&(!XkbFilterEvents(pClient, count, events)))
+ return;
+#endif
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension &&
+ (panoramiXdataPtr[0].x || panoramiXdataPtr[0].y))
+ {
+ switch(events->u.u.type) {
+ case MotionNotify:
+ case ButtonPress:
+ case ButtonRelease:
+ case KeyPress:
+ case KeyRelease:
+ case EnterNotify:
+ case LeaveNotify:
+ /*
+ When multiple clients want the same event DeliverEventsToWindow
+ passes the same event structure multiple times so we can't
+ modify the one passed to us
+ */
+ count = 1; /* should always be 1 */
+ memcpy(&eventCopy, events, sizeof(xEvent));
+ eventCopy.u.keyButtonPointer.rootX += panoramiXdataPtr[0].x;
+ eventCopy.u.keyButtonPointer.rootY += panoramiXdataPtr[0].y;
+ if(eventCopy.u.keyButtonPointer.event ==
+ eventCopy.u.keyButtonPointer.root)
+ {
+ eventCopy.u.keyButtonPointer.eventX += panoramiXdataPtr[0].x;
+ eventCopy.u.keyButtonPointer.eventY += panoramiXdataPtr[0].y;
+ }
+ events = &eventCopy;
+ break;
+ default: break;
+ }
+ }
+#endif
+
+ if (EventCallback)
+ {
+ EventInfoRec eventinfo;
+ eventinfo.client = pClient;
+ eventinfo.events = events;
+ eventinfo.count = count;
+ CallCallbacks(&EventCallback, (pointer)&eventinfo);
+ }
+ if(pClient->swapped)
+ {
+ for(i = 0; i < count; i++)
+ {
+ eventFrom = &events[i];
+ /* Remember to strip off the leading bit of type in case
+ this event was sent with "SendEvent." */
+ (*EventSwapVector[eventFrom->u.u.type & 0177])
+ (eventFrom, &eventTo);
+ (void)WriteToClient(pClient, sizeof(xEvent), (char *)&eventTo);
+ }
+ }
+ else
+ {
+ (void)WriteToClient(pClient, count * sizeof(xEvent), (char *) events);
+ }
+}
diff --git a/nx-X11/programs/Xserver/dix/extension.c b/nx-X11/programs/Xserver/dix/extension.c
new file mode 100644
index 000000000..270d54f9b
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/extension.c
@@ -0,0 +1,474 @@
+/* $XFree86: xc/programs/Xserver/dix/extension.c,v 3.11 2001/12/14 19:59:31 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: extension.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "dispatch.h"
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+#ifdef LBX
+#include "lbxserve.h"
+#endif
+
+#define EXTENSION_BASE 128
+#define EXTENSION_EVENT_BASE 64
+#define LAST_EVENT 128
+#define LAST_ERROR 255
+
+ScreenProcEntry AuxillaryScreenProcs[MAXSCREENS];
+
+static ExtensionEntry **extensions = (ExtensionEntry **)NULL;
+
+int lastEvent = EXTENSION_EVENT_BASE;
+static int lastError = FirstExtensionError;
+static unsigned int NumExtensions = 0;
+
+ExtensionEntry *
+AddExtension(char *name, int NumEvents, int NumErrors,
+ int (*MainProc)(ClientPtr c1),
+ int (*SwappedMainProc)(ClientPtr c2),
+ void (*CloseDownProc)(ExtensionEntry *e),
+ unsigned short (*MinorOpcodeProc)(ClientPtr c3))
+{
+ int i;
+ register ExtensionEntry *ext, **newexts;
+
+ if (!MainProc || !SwappedMainProc || !CloseDownProc || !MinorOpcodeProc)
+ return((ExtensionEntry *) NULL);
+ if ((lastEvent + NumEvents > LAST_EVENT) ||
+ (unsigned)(lastError + NumErrors > LAST_ERROR))
+ return((ExtensionEntry *) NULL);
+
+ ext = (ExtensionEntry *) xalloc(sizeof(ExtensionEntry));
+ if (!ext)
+ return((ExtensionEntry *) NULL);
+ ext->name = (char *)xalloc(strlen(name) + 1);
+ ext->num_aliases = 0;
+ ext->aliases = (char **)NULL;
+ if (!ext->name)
+ {
+ xfree(ext);
+ return((ExtensionEntry *) NULL);
+ }
+ strcpy(ext->name, name);
+ i = NumExtensions;
+ newexts = (ExtensionEntry **) xrealloc(extensions,
+ (i + 1) * sizeof(ExtensionEntry *));
+ if (!newexts)
+ {
+ xfree(ext->name);
+ xfree(ext);
+ return((ExtensionEntry *) NULL);
+ }
+ NumExtensions++;
+ extensions = newexts;
+ extensions[i] = ext;
+ ext->index = i;
+ ext->base = i + EXTENSION_BASE;
+ ext->CloseDown = CloseDownProc;
+ ext->MinorOpcode = MinorOpcodeProc;
+ ProcVector[i + EXTENSION_BASE] = MainProc;
+ SwappedProcVector[i + EXTENSION_BASE] = SwappedMainProc;
+ if (NumEvents)
+ {
+ ext->eventBase = lastEvent;
+ ext->eventLast = lastEvent + NumEvents;
+ lastEvent += NumEvents;
+ }
+ else
+ {
+ ext->eventBase = 0;
+ ext->eventLast = 0;
+ }
+ if (NumErrors)
+ {
+ ext->errorBase = lastError;
+ ext->errorLast = lastError + NumErrors;
+ lastError += NumErrors;
+ }
+ else
+ {
+ ext->errorBase = 0;
+ ext->errorLast = 0;
+ }
+#ifdef XCSECURITY
+ ext->secure = FALSE;
+#endif
+
+#ifdef LBX
+ (void) LbxAddExtension(name, ext->base, ext->eventBase, ext->errorBase);
+#endif
+ return(ext);
+}
+
+Bool AddExtensionAlias(char *alias, ExtensionEntry *ext)
+{
+ char *name;
+ char **aliases;
+
+ aliases = (char **)xrealloc(ext->aliases,
+ (ext->num_aliases + 1) * sizeof(char *));
+ if (!aliases)
+ return FALSE;
+ ext->aliases = aliases;
+ name = (char *)xalloc(strlen(alias) + 1);
+ if (!name)
+ return FALSE;
+ strcpy(name, alias);
+ ext->aliases[ext->num_aliases] = name;
+ ext->num_aliases++;
+#ifdef LBX
+ return LbxAddExtensionAlias(ext->index, alias);
+#else
+ return TRUE;
+#endif
+}
+
+static int
+FindExtension(char *extname, int len)
+{
+ int i, j;
+
+ for (i=0; i<NumExtensions; i++)
+ {
+ if ((strlen(extensions[i]->name) == len) &&
+ !strncmp(extname, extensions[i]->name, len))
+ break;
+ for (j = extensions[i]->num_aliases; --j >= 0;)
+ {
+ if ((strlen(extensions[i]->aliases[j]) == len) &&
+ !strncmp(extname, extensions[i]->aliases[j], len))
+ break;
+ }
+ if (j >= 0) break;
+ }
+ return ((i == NumExtensions) ? -1 : i);
+}
+
+/*
+ * CheckExtension returns the extensions[] entry for the requested
+ * extension name. Maybe this could just return a Bool instead?
+ */
+ExtensionEntry *
+CheckExtension(const char *extname)
+{
+ int n;
+
+ n = FindExtension((char*)extname, strlen(extname));
+ if (n != -1)
+ return extensions[n];
+ else
+ return NULL;
+}
+
+void
+DeclareExtensionSecurity(char *extname, Bool secure)
+{
+#ifdef XCSECURITY
+ int i = FindExtension(extname, strlen(extname));
+ if (i >= 0)
+ {
+ int majorop = extensions[i]->base;
+ extensions[i]->secure = secure;
+ if (secure)
+ {
+ UntrustedProcVector[majorop] = ProcVector[majorop];
+ SwappedUntrustedProcVector[majorop] = SwappedProcVector[majorop];
+ }
+ else
+ {
+ UntrustedProcVector[majorop] = ProcBadRequest;
+ SwappedUntrustedProcVector[majorop] = ProcBadRequest;
+ }
+ }
+#endif
+#ifdef LBX
+ LbxDeclareExtensionSecurity(extname, secure);
+#endif
+}
+
+unsigned short
+StandardMinorOpcode(ClientPtr client)
+{
+ return ((xReq *)client->requestBuffer)->data;
+}
+
+unsigned short
+MinorOpcodeOfRequest(ClientPtr client)
+{
+ unsigned char major;
+
+ major = ((xReq *)client->requestBuffer)->reqType;
+ if (major < EXTENSION_BASE)
+ return 0;
+ major -= EXTENSION_BASE;
+ if (major >= NumExtensions)
+ return 0;
+ return (*extensions[major]->MinorOpcode)(client);
+}
+
+void
+CloseDownExtensions()
+{
+ register int i,j;
+
+#ifdef LBX
+ LbxCloseDownExtensions();
+#endif
+
+ for (i = NumExtensions - 1; i >= 0; i--)
+ {
+ (* extensions[i]->CloseDown)(extensions[i]);
+ NumExtensions = i;
+ xfree(extensions[i]->name);
+ for (j = extensions[i]->num_aliases; --j >= 0;)
+ xfree(extensions[i]->aliases[j]);
+ xfree(extensions[i]->aliases);
+ xfree(extensions[i]);
+ }
+ xfree(extensions);
+ extensions = (ExtensionEntry **)NULL;
+ lastEvent = EXTENSION_EVENT_BASE;
+ lastError = FirstExtensionError;
+ for (i=0; i<MAXSCREENS; i++)
+ {
+ register ScreenProcEntry *spentry = &AuxillaryScreenProcs[i];
+
+ while (spentry->num)
+ {
+ spentry->num--;
+ xfree(spentry->procList[spentry->num].name);
+ }
+ xfree(spentry->procList);
+ spentry->procList = (ProcEntryPtr)NULL;
+ }
+}
+
+
+int
+ProcQueryExtension(ClientPtr client)
+{
+ xQueryExtensionReply reply;
+ int i;
+ REQUEST(xQueryExtensionReq);
+
+ REQUEST_FIXED_SIZE(xQueryExtensionReq, stuff->nbytes);
+
+ reply.type = X_Reply;
+ reply.length = 0;
+ reply.major_opcode = 0;
+ reply.sequenceNumber = client->sequence;
+
+ if ( ! NumExtensions )
+ reply.present = xFalse;
+ else
+ {
+ i = FindExtension((char *)&stuff[1], stuff->nbytes);
+ if (i < 0
+#ifdef XCSECURITY
+ /* don't show insecure extensions to untrusted clients */
+ || (client->trustLevel == XSecurityClientUntrusted &&
+ !extensions[i]->secure)
+#endif
+ )
+ reply.present = xFalse;
+ else
+ {
+ reply.present = xTrue;
+ reply.major_opcode = extensions[i]->base;
+ reply.first_event = extensions[i]->eventBase;
+ reply.first_error = extensions[i]->errorBase;
+ }
+ }
+ WriteReplyToClient(client, sizeof(xQueryExtensionReply), &reply);
+ return(client->noClientException);
+}
+
+int
+ProcListExtensions(ClientPtr client)
+{
+ xListExtensionsReply reply;
+ char *bufptr, *buffer;
+ int total_length = 0;
+
+ REQUEST_SIZE_MATCH(xReq);
+
+ reply.type = X_Reply;
+ reply.nExtensions = 0;
+ reply.length = 0;
+ reply.sequenceNumber = client->sequence;
+ buffer = NULL;
+
+ if ( NumExtensions )
+ {
+ register int i, j;
+
+ for (i=0; i<NumExtensions; i++)
+ {
+#ifdef XCSECURITY
+ /* don't show insecure extensions to untrusted clients */
+ if (client->trustLevel == XSecurityClientUntrusted &&
+ !extensions[i]->secure)
+ continue;
+#endif
+ total_length += strlen(extensions[i]->name) + 1;
+ reply.nExtensions += 1 + extensions[i]->num_aliases;
+ for (j = extensions[i]->num_aliases; --j >= 0;)
+ total_length += strlen(extensions[i]->aliases[j]) + 1;
+ }
+ reply.length = (total_length + 3) >> 2;
+ buffer = bufptr = (char *)ALLOCATE_LOCAL(total_length);
+ if (!buffer)
+ return(BadAlloc);
+ for (i=0; i<NumExtensions; i++)
+ {
+ int len;
+#ifdef XCSECURITY
+ if (client->trustLevel == XSecurityClientUntrusted &&
+ !extensions[i]->secure)
+ continue;
+#endif
+ *bufptr++ = len = strlen(extensions[i]->name);
+ memmove(bufptr, extensions[i]->name, len);
+ bufptr += len;
+ for (j = extensions[i]->num_aliases; --j >= 0;)
+ {
+ *bufptr++ = len = strlen(extensions[i]->aliases[j]);
+ memmove(bufptr, extensions[i]->aliases[j], len);
+ bufptr += len;
+ }
+ }
+ }
+ WriteReplyToClient(client, sizeof(xListExtensionsReply), &reply);
+ if (reply.length)
+ {
+ WriteToClient(client, total_length, buffer);
+ DEALLOCATE_LOCAL(buffer);
+ }
+ return(client->noClientException);
+}
+
+
+ExtensionLookupProc
+LookupProc(char *name, GCPtr pGC)
+{
+ register int i;
+ register ScreenProcEntry *spentry;
+ spentry = &AuxillaryScreenProcs[pGC->pScreen->myNum];
+ if (spentry->num)
+ {
+ for (i = 0; i < spentry->num; i++)
+ if (strcmp(name, spentry->procList[i].name) == 0)
+ return(spentry->procList[i].proc);
+ }
+ return (ExtensionLookupProc)NULL;
+}
+
+Bool
+RegisterProc(char *name, GC *pGC, ExtensionLookupProc proc)
+{
+ return RegisterScreenProc(name, pGC->pScreen, proc);
+}
+
+Bool
+RegisterScreenProc(char *name, ScreenPtr pScreen, ExtensionLookupProc proc)
+{
+ register ScreenProcEntry *spentry;
+ register ProcEntryPtr procEntry = (ProcEntryPtr)NULL;
+ char *newname;
+ int i;
+
+ spentry = &AuxillaryScreenProcs[pScreen->myNum];
+ /* first replace duplicates */
+ if (spentry->num)
+ {
+ for (i = 0; i < spentry->num; i++)
+ if (strcmp(name, spentry->procList[i].name) == 0)
+ {
+ procEntry = &spentry->procList[i];
+ break;
+ }
+ }
+ if (procEntry)
+ procEntry->proc = proc;
+ else
+ {
+ newname = (char *)xalloc(strlen(name)+1);
+ if (!newname)
+ return FALSE;
+ procEntry = (ProcEntryPtr)
+ xrealloc(spentry->procList,
+ sizeof(ProcEntryRec) * (spentry->num+1));
+ if (!procEntry)
+ {
+ xfree(newname);
+ return FALSE;
+ }
+ spentry->procList = procEntry;
+ procEntry += spentry->num;
+ procEntry->name = newname;
+ strcpy(newname, name);
+ procEntry->proc = proc;
+ spentry->num++;
+ }
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/dix/ffs.c b/nx-X11/programs/Xserver/dix/ffs.c
new file mode 100644
index 000000000..8d0954689
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/ffs.c
@@ -0,0 +1,37 @@
+/* $Xorg: ffs.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABIL-
+ITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization from
+The Open Group.
+
+*/
+
+int
+ffs(int i)
+{
+ int j;
+ for (j = 1; (i & 1) == 0; j++)
+ i >>= 1;
+ return j;
+}
diff --git a/nx-X11/programs/Xserver/dix/gc.c b/nx-X11/programs/Xserver/dix/gc.c
new file mode 100644
index 000000000..cb21e09fd
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/gc.c
@@ -0,0 +1,1288 @@
+/* $XFree86: xc/programs/Xserver/dix/gc.c,v 3.9 2001/12/14 19:59:32 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* $Xorg: gc.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "resource.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "dixfontstr.h"
+#include "scrnintstr.h"
+#include "region.h"
+
+#include "dix.h"
+#include <assert.h>
+
+extern XID clientErrorValue;
+extern FontPtr defaultFont;
+
+static Bool CreateDefaultTile(GCPtr pGC);
+
+unsigned char DefaultDash[2] = {4, 4};
+
+void
+ValidateGC(DrawablePtr pDraw, GC *pGC)
+{
+ (*pGC->funcs->ValidateGC) (pGC, pGC->stateChanges, pDraw);
+ pGC->stateChanges = 0;
+ pGC->serialNumber = pDraw->serialNumber;
+}
+
+
+/* dixChangeGC(client, pGC, mask, pC32, pUnion)
+ *
+ * This function was created as part of the Security extension
+ * implementation. The client performing the gc change must be passed so
+ * that access checks can be performed on any tiles, stipples, or fonts
+ * that are specified. ddxen can call this too; they should normally
+ * pass NullClient for the client since any access checking should have
+ * already been done at a higher level.
+ *
+ * Since we had to create a new function anyway, we decided to change the
+ * way the list of gc values is passed to eliminate the compiler warnings
+ * caused by the DoChangeGC interface. You can pass the values via pC32
+ * or pUnion, but not both; one of them must be NULL. If you don't need
+ * to pass any pointers, you can use either one:
+ *
+ * example calling dixChangeGC using pC32 parameter
+ *
+ * CARD32 v[2];
+ * v[0] = foreground;
+ * v[1] = background;
+ * dixChangeGC(client, pGC, GCForeground|GCBackground, v, NULL);
+ *
+ * example calling dixChangeGC using pUnion parameter;
+ * same effect as above
+ *
+ * ChangeGCVal v[2];
+ * v[0].val = foreground;
+ * v[1].val = background;
+ * dixChangeGC(client, pGC, GCForeground|GCBackground, NULL, v);
+ *
+ * However, if you need to pass a pointer to a pixmap or font, you MUST
+ * use the pUnion parameter.
+ *
+ * example calling dixChangeGC passing pointers in the value list
+ * v[1].ptr is a pointer to a pixmap
+ *
+ * ChangeGCVal v[2];
+ * v[0].val = FillTiled;
+ * v[1].ptr = pPixmap;
+ * dixChangeGC(client, pGC, GCFillStyle|GCTile, NULL, v);
+ *
+ * Note: we could have gotten by with just the pUnion parameter, but on
+ * 64 bit machines that would have forced us to copy the value list that
+ * comes in the ChangeGC request.
+ *
+ * Ideally, we'd change all the DoChangeGC calls to dixChangeGC, but this
+ * is far too many changes to consider at this time, so we've only
+ * changed the ones that caused compiler warnings. New code should use
+ * dixChangeGC.
+ *
+ * dpw
+ */
+
+#define NEXTVAL(_type, _var) { \
+ if (pC32) _var = (_type)*pC32++; \
+ else { \
+ _var = (_type)(pUnion->val); pUnion++; \
+ } \
+ }
+
+#define NEXT_PTR(_type, _var) { \
+ assert(pUnion); _var = (_type)pUnion->ptr; pUnion++; }
+
+int
+dixChangeGC(ClientPtr client, register GC *pGC, register BITS32 mask, CARD32 *pC32, ChangeGCValPtr pUnion)
+{
+ register BITS32 index2;
+ register int error = 0;
+ PixmapPtr pPixmap;
+ BITS32 maskQ;
+
+ assert( (pC32 && !pUnion) || (!pC32 && pUnion) );
+ pGC->serialNumber |= GC_CHANGE_SERIAL_BIT;
+
+ maskQ = mask; /* save these for when we walk the GCque */
+ while (mask && !error)
+ {
+ index2 = (BITS32) lowbit (mask);
+ mask &= ~index2;
+ pGC->stateChanges |= index2;
+ switch (index2)
+ {
+ case GCFunction:
+ {
+ CARD8 newalu;
+ NEXTVAL(CARD8, newalu);
+ if (newalu <= GXset)
+ pGC->alu = newalu;
+ else
+ {
+ clientErrorValue = newalu;
+ error = BadValue;
+ }
+ break;
+ }
+ case GCPlaneMask:
+ NEXTVAL(unsigned long, pGC->planemask);
+ break;
+ case GCForeground:
+ NEXTVAL(unsigned long, pGC->fgPixel);
+ /*
+ * this is for CreateGC
+ */
+ if (!pGC->tileIsPixel && !pGC->tile.pixmap)
+ {
+ pGC->tileIsPixel = TRUE;
+ pGC->tile.pixel = pGC->fgPixel;
+ }
+ break;
+ case GCBackground:
+ NEXTVAL(unsigned long, pGC->bgPixel);
+ break;
+ case GCLineWidth: /* ??? line width is a CARD16 */
+ NEXTVAL(CARD16, pGC->lineWidth);
+ break;
+ case GCLineStyle:
+ {
+ unsigned int newlinestyle;
+ NEXTVAL(unsigned int, newlinestyle);
+ if (newlinestyle <= LineDoubleDash)
+ pGC->lineStyle = newlinestyle;
+ else
+ {
+ clientErrorValue = newlinestyle;
+ error = BadValue;
+ }
+ break;
+ }
+ case GCCapStyle:
+ {
+ unsigned int newcapstyle;
+ NEXTVAL(unsigned int, newcapstyle);
+ if (newcapstyle <= CapProjecting)
+ pGC->capStyle = newcapstyle;
+ else
+ {
+ clientErrorValue = newcapstyle;
+ error = BadValue;
+ }
+ break;
+ }
+ case GCJoinStyle:
+ {
+ unsigned int newjoinstyle;
+ NEXTVAL(unsigned int, newjoinstyle);
+ if (newjoinstyle <= JoinBevel)
+ pGC->joinStyle = newjoinstyle;
+ else
+ {
+ clientErrorValue = newjoinstyle;
+ error = BadValue;
+ }
+ break;
+ }
+ case GCFillStyle:
+ {
+ unsigned int newfillstyle;
+ NEXTVAL(unsigned int, newfillstyle);
+ if (newfillstyle <= FillOpaqueStippled)
+ pGC->fillStyle = newfillstyle;
+ else
+ {
+ clientErrorValue = newfillstyle;
+ error = BadValue;
+ }
+ break;
+ }
+ case GCFillRule:
+ {
+ unsigned int newfillrule;
+ NEXTVAL(unsigned int, newfillrule);
+ if (newfillrule <= WindingRule)
+ pGC->fillRule = newfillrule;
+ else
+ {
+ clientErrorValue = newfillrule;
+ error = BadValue;
+ }
+ break;
+ }
+ case GCTile:
+ {
+ XID newpix = 0;
+ if (pUnion)
+ {
+ NEXT_PTR(PixmapPtr, pPixmap);
+ }
+ else
+ {
+ NEXTVAL(XID, newpix);
+ pPixmap = (PixmapPtr)SecurityLookupIDByType(client,
+ newpix, RT_PIXMAP, SecurityReadAccess);
+ }
+ if (pPixmap)
+ {
+ if ((pPixmap->drawable.depth != pGC->depth) ||
+ (pPixmap->drawable.pScreen != pGC->pScreen))
+ {
+ error = BadMatch;
+ }
+ else
+ {
+ pPixmap->refcnt++;
+ if (!pGC->tileIsPixel)
+ (* pGC->pScreen->DestroyPixmap)(pGC->tile.pixmap);
+ pGC->tileIsPixel = FALSE;
+ pGC->tile.pixmap = pPixmap;
+ }
+ }
+ else
+ {
+ clientErrorValue = newpix;
+ error = BadPixmap;
+ }
+ break;
+ }
+ case GCStipple:
+ {
+ XID newstipple = 0;
+ if (pUnion)
+ {
+ NEXT_PTR(PixmapPtr, pPixmap);
+ }
+ else
+ {
+ NEXTVAL(XID, newstipple)
+ pPixmap = (PixmapPtr)SecurityLookupIDByType(client,
+ newstipple, RT_PIXMAP, SecurityReadAccess);
+ }
+ if (pPixmap)
+ {
+ if ((pPixmap->drawable.depth != 1) ||
+ (pPixmap->drawable.pScreen != pGC->pScreen))
+ {
+ error = BadMatch;
+ }
+ else
+ {
+ pPixmap->refcnt++;
+ if (pGC->stipple)
+ (* pGC->pScreen->DestroyPixmap)(pGC->stipple);
+ pGC->stipple = pPixmap;
+ }
+ }
+ else
+ {
+ clientErrorValue = newstipple;
+ error = BadPixmap;
+ }
+ break;
+ }
+ case GCTileStipXOrigin:
+ NEXTVAL(INT16, pGC->patOrg.x);
+ break;
+ case GCTileStipYOrigin:
+ NEXTVAL(INT16, pGC->patOrg.y);
+ break;
+ case GCFont:
+ {
+ FontPtr pFont;
+ XID newfont = 0;
+ if (pUnion)
+ {
+ NEXT_PTR(FontPtr, pFont);
+ }
+ else
+ {
+ NEXTVAL(XID, newfont)
+ pFont = (FontPtr)SecurityLookupIDByType(client, newfont,
+ RT_FONT, SecurityReadAccess);
+ }
+ if (pFont)
+ {
+ pFont->refcnt++;
+ if (pGC->font)
+ CloseFont(pGC->font, (Font)0);
+ pGC->font = pFont;
+ }
+ else
+ {
+ clientErrorValue = newfont;
+ error = BadFont;
+ }
+ break;
+ }
+ case GCSubwindowMode:
+ {
+ unsigned int newclipmode;
+ NEXTVAL(unsigned int, newclipmode);
+ if (newclipmode <= IncludeInferiors)
+ pGC->subWindowMode = newclipmode;
+ else
+ {
+ clientErrorValue = newclipmode;
+ error = BadValue;
+ }
+ break;
+ }
+ case GCGraphicsExposures:
+ {
+ unsigned int newge;
+ NEXTVAL(unsigned int, newge);
+ if (newge <= xTrue)
+ pGC->graphicsExposures = newge;
+ else
+ {
+ clientErrorValue = newge;
+ error = BadValue;
+ }
+ break;
+ }
+ case GCClipXOrigin:
+ NEXTVAL(INT16, pGC->clipOrg.x);
+ break;
+ case GCClipYOrigin:
+ NEXTVAL(INT16, pGC->clipOrg.y);
+ break;
+ case GCClipMask:
+ {
+ Pixmap pid = 0;
+ int clipType = 0;
+
+ if (pUnion)
+ {
+ NEXT_PTR(PixmapPtr, pPixmap);
+ }
+ else
+ {
+ NEXTVAL(Pixmap, pid)
+ if (pid == None)
+ {
+ clipType = CT_NONE;
+ pPixmap = NullPixmap;
+ }
+ else
+ pPixmap = (PixmapPtr)SecurityLookupIDByType(client,
+ pid, RT_PIXMAP, SecurityReadAccess);
+ }
+
+ if (pPixmap)
+ {
+ if ((pPixmap->drawable.depth != 1) ||
+ (pPixmap->drawable.pScreen != pGC->pScreen))
+ {
+ error = BadMatch;
+ }
+ else
+ {
+ clipType = CT_PIXMAP;
+ pPixmap->refcnt++;
+ }
+ }
+ else if (!pUnion && (pid != None))
+ {
+ clientErrorValue = pid;
+ error = BadPixmap;
+ }
+ if(error == Success)
+ {
+ (*pGC->funcs->ChangeClip)(pGC, clipType,
+ (pointer)pPixmap, 0);
+ }
+ break;
+ }
+ case GCDashOffset:
+ NEXTVAL(INT16, pGC->dashOffset);
+ break;
+ case GCDashList:
+ {
+ CARD8 newdash;
+ NEXTVAL(CARD8, newdash);
+ if (newdash == 4)
+ {
+ if (pGC->dash != DefaultDash)
+ {
+ xfree(pGC->dash);
+ pGC->numInDashList = 2;
+ pGC->dash = DefaultDash;
+ }
+ }
+ else if (newdash != 0)
+ {
+ unsigned char *dash;
+
+ dash = (unsigned char *)xalloc(2 * sizeof(unsigned char));
+ if (dash)
+ {
+ if (pGC->dash != DefaultDash)
+ xfree(pGC->dash);
+ pGC->numInDashList = 2;
+ pGC->dash = dash;
+ dash[0] = newdash;
+ dash[1] = newdash;
+ }
+ else
+ error = BadAlloc;
+ }
+ else
+ {
+ clientErrorValue = newdash;
+ error = BadValue;
+ }
+ break;
+ }
+ case GCArcMode:
+ {
+ unsigned int newarcmode;
+ NEXTVAL(unsigned int, newarcmode);
+ if (newarcmode <= ArcPieSlice)
+ pGC->arcMode = newarcmode;
+ else
+ {
+ clientErrorValue = newarcmode;
+ error = BadValue;
+ }
+ break;
+ }
+ default:
+ clientErrorValue = maskQ;
+ error = BadValue;
+ break;
+ }
+ } /* end while mask && !error */
+
+ if (pGC->fillStyle == FillTiled && pGC->tileIsPixel)
+ {
+ if (!CreateDefaultTile (pGC))
+ {
+ pGC->fillStyle = FillSolid;
+ error = BadAlloc;
+ }
+ }
+ (*pGC->funcs->ChangeGC)(pGC, maskQ);
+ return error;
+}
+
+#undef NEXTVAL
+#undef NEXT_PTR
+
+/* Publically defined entry to ChangeGC. Just calls dixChangeGC and tells
+ * it that all of the entries are constants or IDs */
+int
+ChangeGC(register GC *pGC, register BITS32 mask, XID *pval)
+{
+ return (dixChangeGC(NullClient, pGC, mask, pval, NULL));
+}
+
+/* DoChangeGC(pGC, mask, pval, fPointer)
+ mask is a set of bits indicating which values to change.
+ pval contains an appropriate value for each mask.
+ fPointer is true if the values for tiles, stipples, fonts or clipmasks
+ are pointers instead of IDs. Note: if you are passing pointers you
+ MUST declare the array of values as type pointer! Other data types
+ may not be large enough to hold pointers on some machines. Yes,
+ this means you have to cast to (XID *) when you pass the array to
+ DoChangeGC. Similarly, if you are not passing pointers (fPointer = 0) you
+ MUST declare the array as type XID (not unsigned long!), or again the wrong
+ size data type may be used. To avoid this cruftiness, use dixChangeGC
+ above.
+
+ if there is an error, the value is marked as changed
+ anyway, which is probably wrong, but infrequent.
+
+NOTE:
+ all values sent over the protocol for ChangeGC requests are
+32 bits long
+*/
+int
+DoChangeGC(register GC *pGC, register BITS32 mask, XID *pval, int fPointer)
+{
+ if (fPointer)
+ /* XXX might be a problem on 64 bit big-endian servers */
+ return dixChangeGC(NullClient, pGC, mask, NULL, (ChangeGCValPtr)pval);
+ else
+ return dixChangeGC(NullClient, pGC, mask, pval, NULL);
+}
+
+
+/* CreateGC(pDrawable, mask, pval, pStatus)
+ creates a default GC for the given drawable, using mask to fill
+ in any non-default values.
+ Returns a pointer to the new GC on success, NULL otherwise.
+ returns status of non-default fields in pStatus
+BUG:
+ should check for failure to create default tile
+
+*/
+
+static GCPtr
+AllocateGC(ScreenPtr pScreen)
+{
+ GCPtr pGC;
+ register char *ptr;
+ register DevUnion *ppriv;
+ register unsigned *sizes;
+ register unsigned size;
+ register int i;
+
+ pGC = (GCPtr)xalloc(pScreen->totalGCSize);
+ if (pGC)
+ {
+ ppriv = (DevUnion *)(pGC + 1);
+ pGC->devPrivates = ppriv;
+ sizes = pScreen->GCPrivateSizes;
+ ptr = (char *)(ppriv + pScreen->GCPrivateLen);
+ for (i = pScreen->GCPrivateLen; --i >= 0; ppriv++, sizes++)
+ {
+ if ( (size = *sizes) )
+ {
+ ppriv->ptr = (pointer)ptr;
+ ptr += size;
+ }
+ else
+ ppriv->ptr = (pointer)NULL;
+ }
+ }
+ return pGC;
+}
+
+GCPtr
+CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus)
+{
+ register GCPtr pGC;
+
+ pGC = AllocateGC(pDrawable->pScreen);
+ if (!pGC)
+ {
+ *pStatus = BadAlloc;
+ return (GCPtr)NULL;
+ }
+
+ pGC->pScreen = pDrawable->pScreen;
+ pGC->depth = pDrawable->depth;
+ pGC->alu = GXcopy; /* dst <- src */
+ pGC->planemask = ~0;
+ pGC->serialNumber = GC_CHANGE_SERIAL_BIT;
+ pGC->funcs = 0;
+
+ pGC->fgPixel = 0;
+ pGC->bgPixel = 1;
+ pGC->lineWidth = 0;
+ pGC->lineStyle = LineSolid;
+ pGC->capStyle = CapButt;
+ pGC->joinStyle = JoinMiter;
+ pGC->fillStyle = FillSolid;
+ pGC->fillRule = EvenOddRule;
+ pGC->arcMode = ArcPieSlice;
+ if (mask & GCForeground)
+ {
+ /*
+ * magic special case -- ChangeGC checks for this condition
+ * and snags the Foreground value to create a pseudo default-tile
+ */
+ pGC->tileIsPixel = FALSE;
+ pGC->tile.pixmap = NullPixmap;
+ }
+ else
+ {
+ pGC->tileIsPixel = TRUE;
+ pGC->tile.pixel = 0;
+ }
+
+ pGC->patOrg.x = 0;
+ pGC->patOrg.y = 0;
+ pGC->subWindowMode = ClipByChildren;
+ pGC->graphicsExposures = TRUE;
+ pGC->clipOrg.x = 0;
+ pGC->clipOrg.y = 0;
+ pGC->clientClipType = CT_NONE;
+ pGC->clientClip = (pointer)NULL;
+ pGC->numInDashList = 2;
+ pGC->dash = DefaultDash;
+ pGC->dashOffset = 0;
+ pGC->lastWinOrg.x = 0;
+ pGC->lastWinOrg.y = 0;
+
+ /* use the default font and stipple */
+ pGC->font = defaultFont;
+ defaultFont->refcnt++;
+ pGC->stipple = pGC->pScreen->PixmapPerDepth[0];
+ pGC->stipple->refcnt++;
+
+ pGC->stateChanges = (1 << (GCLastBit+1)) - 1;
+ if (!(*pGC->pScreen->CreateGC)(pGC))
+ *pStatus = BadAlloc;
+ else if (mask)
+ *pStatus = ChangeGC(pGC, mask, pval);
+ else
+ *pStatus = Success;
+ if (*pStatus != Success)
+ {
+ if (!pGC->tileIsPixel && !pGC->tile.pixmap)
+ pGC->tileIsPixel = TRUE; /* undo special case */
+ FreeGC(pGC, (XID)0);
+ pGC = (GCPtr)NULL;
+ }
+
+ return (pGC);
+}
+
+static Bool
+CreateDefaultTile (GCPtr pGC)
+{
+ XID tmpval[3];
+ PixmapPtr pTile;
+ GCPtr pgcScratch;
+ xRectangle rect;
+ CARD16 w, h;
+
+ w = 1;
+ h = 1;
+ (*pGC->pScreen->QueryBestSize)(TileShape, &w, &h, pGC->pScreen);
+ pTile = (PixmapPtr)
+ (*pGC->pScreen->CreatePixmap)(pGC->pScreen,
+ w, h, pGC->depth);
+ pgcScratch = GetScratchGC(pGC->depth, pGC->pScreen);
+ if (!pTile || !pgcScratch)
+ {
+ if (pTile)
+ (*pTile->drawable.pScreen->DestroyPixmap)(pTile);
+ if (pgcScratch)
+ FreeScratchGC(pgcScratch);
+ return FALSE;
+ }
+ tmpval[0] = GXcopy;
+ tmpval[1] = pGC->tile.pixel;
+ tmpval[2] = FillSolid;
+ (void)ChangeGC(pgcScratch, GCFunction | GCForeground | GCFillStyle,
+ tmpval);
+ ValidateGC((DrawablePtr)pTile, pgcScratch);
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = w;
+ rect.height = h;
+ (*pgcScratch->ops->PolyFillRect)((DrawablePtr)pTile, pgcScratch, 1, &rect);
+ /* Always remember to free the scratch graphics context after use. */
+ FreeScratchGC(pgcScratch);
+
+ pGC->tileIsPixel = FALSE;
+ pGC->tile.pixmap = pTile;
+ return TRUE;
+}
+
+int
+CopyGC(register GC *pgcSrc, register GC *pgcDst, register BITS32 mask)
+{
+ register BITS32 index2;
+ BITS32 maskQ;
+ int error = 0;
+
+ if (pgcSrc == pgcDst)
+ return Success;
+ pgcDst->serialNumber |= GC_CHANGE_SERIAL_BIT;
+ pgcDst->stateChanges |= mask;
+ maskQ = mask;
+ while (mask)
+ {
+ index2 = (BITS32) lowbit (mask);
+ mask &= ~index2;
+ switch (index2)
+ {
+ case GCFunction:
+ pgcDst->alu = pgcSrc->alu;
+ break;
+ case GCPlaneMask:
+ pgcDst->planemask = pgcSrc->planemask;
+ break;
+ case GCForeground:
+ pgcDst->fgPixel = pgcSrc->fgPixel;
+ break;
+ case GCBackground:
+ pgcDst->bgPixel = pgcSrc->bgPixel;
+ break;
+ case GCLineWidth:
+ pgcDst->lineWidth = pgcSrc->lineWidth;
+ break;
+ case GCLineStyle:
+ pgcDst->lineStyle = pgcSrc->lineStyle;
+ break;
+ case GCCapStyle:
+ pgcDst->capStyle = pgcSrc->capStyle;
+ break;
+ case GCJoinStyle:
+ pgcDst->joinStyle = pgcSrc->joinStyle;
+ break;
+ case GCFillStyle:
+ pgcDst->fillStyle = pgcSrc->fillStyle;
+ break;
+ case GCFillRule:
+ pgcDst->fillRule = pgcSrc->fillRule;
+ break;
+ case GCTile:
+ {
+ if (EqualPixUnion(pgcDst->tileIsPixel,
+ pgcDst->tile,
+ pgcSrc->tileIsPixel,
+ pgcSrc->tile))
+ {
+ break;
+ }
+ if (!pgcDst->tileIsPixel)
+ (* pgcDst->pScreen->DestroyPixmap)(pgcDst->tile.pixmap);
+ pgcDst->tileIsPixel = pgcSrc->tileIsPixel;
+ pgcDst->tile = pgcSrc->tile;
+ if (!pgcDst->tileIsPixel)
+ pgcDst->tile.pixmap->refcnt++;
+ break;
+ }
+ case GCStipple:
+ {
+ if (pgcDst->stipple == pgcSrc->stipple)
+ break;
+ if (pgcDst->stipple)
+ (* pgcDst->pScreen->DestroyPixmap)(pgcDst->stipple);
+ pgcDst->stipple = pgcSrc->stipple;
+ if (pgcDst->stipple)
+ pgcDst->stipple->refcnt ++;
+ break;
+ }
+ case GCTileStipXOrigin:
+ pgcDst->patOrg.x = pgcSrc->patOrg.x;
+ break;
+ case GCTileStipYOrigin:
+ pgcDst->patOrg.y = pgcSrc->patOrg.y;
+ break;
+ case GCFont:
+ if (pgcDst->font == pgcSrc->font)
+ break;
+ if (pgcDst->font)
+ CloseFont(pgcDst->font, (Font)0);
+ if ((pgcDst->font = pgcSrc->font) != NullFont)
+ (pgcDst->font)->refcnt++;
+ break;
+ case GCSubwindowMode:
+ pgcDst->subWindowMode = pgcSrc->subWindowMode;
+ break;
+ case GCGraphicsExposures:
+ pgcDst->graphicsExposures = pgcSrc->graphicsExposures;
+ break;
+ case GCClipXOrigin:
+ pgcDst->clipOrg.x = pgcSrc->clipOrg.x;
+ break;
+ case GCClipYOrigin:
+ pgcDst->clipOrg.y = pgcSrc->clipOrg.y;
+ break;
+ case GCClipMask:
+ (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
+ break;
+ case GCDashOffset:
+ pgcDst->dashOffset = pgcSrc->dashOffset;
+ break;
+ case GCDashList:
+ if (pgcSrc->dash == DefaultDash)
+ {
+ if (pgcDst->dash != DefaultDash)
+ {
+ xfree(pgcDst->dash);
+ pgcDst->numInDashList = pgcSrc->numInDashList;
+ pgcDst->dash = pgcSrc->dash;
+ }
+ }
+ else
+ {
+ unsigned char *dash;
+ unsigned int i;
+
+ dash = (unsigned char *)xalloc(pgcSrc->numInDashList *
+ sizeof(unsigned char));
+ if (dash)
+ {
+ if (pgcDst->dash != DefaultDash)
+ xfree(pgcDst->dash);
+ pgcDst->numInDashList = pgcSrc->numInDashList;
+ pgcDst->dash = dash;
+ for (i=0; i<pgcSrc->numInDashList; i++)
+ dash[i] = pgcSrc->dash[i];
+ }
+ else
+ error = BadAlloc;
+ }
+ break;
+ case GCArcMode:
+ pgcDst->arcMode = pgcSrc->arcMode;
+ break;
+ default:
+ clientErrorValue = maskQ;
+ error = BadValue;
+ break;
+ }
+ }
+ if (pgcDst->fillStyle == FillTiled && pgcDst->tileIsPixel)
+ {
+ if (!CreateDefaultTile (pgcDst))
+ {
+ pgcDst->fillStyle = FillSolid;
+ error = BadAlloc;
+ }
+ }
+ (*pgcDst->funcs->CopyGC) (pgcSrc, maskQ, pgcDst);
+ return error;
+}
+
+/**
+ * does the diX part of freeing the characteristics in the GC.
+ *
+ * \param value must conform to DeleteType
+ */
+int
+FreeGC(pointer value, XID gid)
+{
+ GCPtr pGC = (GCPtr)value;
+
+ CloseFont(pGC->font, (Font)0);
+ (* pGC->funcs->DestroyClip)(pGC);
+
+ if (!pGC->tileIsPixel)
+ (* pGC->pScreen->DestroyPixmap)(pGC->tile.pixmap);
+ if (pGC->stipple)
+ (* pGC->pScreen->DestroyPixmap)(pGC->stipple);
+
+ (*pGC->funcs->DestroyGC) (pGC);
+ if (pGC->dash != DefaultDash)
+ xfree(pGC->dash);
+ xfree(pGC);
+ return(Success);
+}
+
+void
+SetGCMask(GCPtr pGC, Mask selectMask, Mask newDataMask)
+{
+ pGC->stateChanges = (~selectMask & pGC->stateChanges) |
+ (selectMask & newDataMask);
+ if (selectMask & newDataMask)
+ pGC->serialNumber |= GC_CHANGE_SERIAL_BIT;
+}
+
+
+
+/* CreateScratchGC(pScreen, depth)
+ like CreateGC, but doesn't do the default tile or stipple,
+since we can't create them without already having a GC. any code
+using the tile or stipple has to set them explicitly anyway,
+since the state of the scratch gc is unknown. This is OK
+because ChangeGC() has to be able to deal with NULL tiles and
+stipples anyway (in case the CreateGC() call has provided a
+value for them -- we can't set the default tile until the
+client-supplied attributes are installed, since the fgPixel
+is what fills the default tile. (maybe this comment should
+go with CreateGC() or ChangeGC().)
+*/
+
+GCPtr
+CreateScratchGC(ScreenPtr pScreen, unsigned depth)
+{
+ register GCPtr pGC;
+
+ pGC = AllocateGC(pScreen);
+ if (!pGC)
+ return (GCPtr)NULL;
+
+ pGC->pScreen = pScreen;
+ pGC->depth = depth;
+ pGC->alu = GXcopy; /* dst <- src */
+ pGC->planemask = ~0;
+ pGC->serialNumber = 0;
+
+ pGC->fgPixel = 0;
+ pGC->bgPixel = 1;
+ pGC->lineWidth = 0;
+ pGC->lineStyle = LineSolid;
+ pGC->capStyle = CapButt;
+ pGC->joinStyle = JoinMiter;
+ pGC->fillStyle = FillSolid;
+ pGC->fillRule = EvenOddRule;
+ pGC->arcMode = ArcPieSlice;
+ pGC->font = defaultFont;
+ if ( pGC->font) /* necessary, because open of default font could fail */
+ pGC->font->refcnt++;
+ pGC->tileIsPixel = TRUE;
+ pGC->tile.pixel = 0;
+ pGC->stipple = NullPixmap;
+ pGC->patOrg.x = 0;
+ pGC->patOrg.y = 0;
+ pGC->subWindowMode = ClipByChildren;
+ pGC->graphicsExposures = TRUE;
+ pGC->clipOrg.x = 0;
+ pGC->clipOrg.y = 0;
+ pGC->clientClipType = CT_NONE;
+ pGC->dashOffset = 0;
+ pGC->numInDashList = 2;
+ pGC->dash = DefaultDash;
+ pGC->lastWinOrg.x = 0;
+ pGC->lastWinOrg.y = 0;
+
+ pGC->stateChanges = (1 << (GCLastBit+1)) - 1;
+ if (!(*pScreen->CreateGC)(pGC))
+ {
+ FreeGC(pGC, (XID)0);
+ pGC = (GCPtr)NULL;
+ }
+ return pGC;
+}
+
+void
+FreeGCperDepth(int screenNum)
+{
+ register int i;
+ register ScreenPtr pScreen;
+ GCPtr *ppGC;
+
+ pScreen = screenInfo.screens[screenNum];
+ ppGC = pScreen->GCperDepth;
+
+ for (i = 0; i <= pScreen->numDepths; i++)
+ (void)FreeGC(ppGC[i], (XID)0);
+ pScreen->rgf = ~0L;
+}
+
+
+Bool
+CreateGCperDepth(int screenNum)
+{
+ register int i;
+ register ScreenPtr pScreen;
+ DepthPtr pDepth;
+ GCPtr *ppGC;
+
+ pScreen = screenInfo.screens[screenNum];
+ pScreen->rgf = 0;
+ ppGC = pScreen->GCperDepth;
+ /* do depth 1 separately because it's not included in list */
+ if (!(ppGC[0] = CreateScratchGC(pScreen, 1)))
+ return FALSE;
+ ppGC[0]->graphicsExposures = FALSE;
+ /* Make sure we don't overflow GCperDepth[] */
+ if( pScreen->numDepths > MAXFORMATS )
+ return FALSE;
+
+ pDepth = pScreen->allowedDepths;
+ for (i=0; i<pScreen->numDepths; i++, pDepth++)
+ {
+ if (!(ppGC[i+1] = CreateScratchGC(pScreen, pDepth->depth)))
+ {
+ for (; i >= 0; i--)
+ (void)FreeGC(ppGC[i], (XID)0);
+ return FALSE;
+ }
+ ppGC[i+1]->graphicsExposures = FALSE;
+ }
+ return TRUE;
+}
+
+Bool
+CreateDefaultStipple(int screenNum)
+{
+ register ScreenPtr pScreen;
+ XID tmpval[3];
+ xRectangle rect;
+ CARD16 w, h;
+ GCPtr pgcScratch;
+
+ pScreen = screenInfo.screens[screenNum];
+
+ w = 16;
+ h = 16;
+ (* pScreen->QueryBestSize)(StippleShape, &w, &h, pScreen);
+ if (!(pScreen->PixmapPerDepth[0] =
+ (*pScreen->CreatePixmap)(pScreen, w, h, 1)))
+ return FALSE;
+ /* fill stipple with 1 */
+ tmpval[0] = GXcopy; tmpval[1] = 1; tmpval[2] = FillSolid;
+ pgcScratch = GetScratchGC(1, pScreen);
+ if (!pgcScratch)
+ {
+ (*pScreen->DestroyPixmap)(pScreen->PixmapPerDepth[0]);
+ return FALSE;
+ }
+ (void)ChangeGC(pgcScratch, GCFunction|GCForeground|GCFillStyle, tmpval);
+ ValidateGC((DrawablePtr)pScreen->PixmapPerDepth[0], pgcScratch);
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = w;
+ rect.height = h;
+ (*pgcScratch->ops->PolyFillRect)((DrawablePtr)pScreen->PixmapPerDepth[0],
+ pgcScratch, 1, &rect);
+ FreeScratchGC(pgcScratch);
+ return TRUE;
+}
+
+void
+FreeDefaultStipple(int screenNum)
+{
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ (*pScreen->DestroyPixmap)(pScreen->PixmapPerDepth[0]);
+}
+
+int
+SetDashes(register GCPtr pGC, unsigned offset, unsigned ndash, unsigned char *pdash)
+{
+ register long i;
+ register unsigned char *p, *indash;
+ BITS32 maskQ = 0;
+
+ i = ndash;
+ p = pdash;
+ while (i--)
+ {
+ if (!*p++)
+ {
+ /* dash segment must be > 0 */
+ clientErrorValue = 0;
+ return BadValue;
+ }
+ }
+
+ if (ndash & 1)
+ p = (unsigned char *)xalloc(2 * ndash * sizeof(unsigned char));
+ else
+ p = (unsigned char *)xalloc(ndash * sizeof(unsigned char));
+ if (!p)
+ return BadAlloc;
+
+ pGC->serialNumber |= GC_CHANGE_SERIAL_BIT;
+ if (offset != pGC->dashOffset)
+ {
+ pGC->dashOffset = offset;
+ pGC->stateChanges |= GCDashOffset;
+ maskQ |= GCDashOffset;
+ }
+
+ if (pGC->dash != DefaultDash)
+ xfree(pGC->dash);
+ pGC->numInDashList = ndash;
+ pGC->dash = p;
+ if (ndash & 1)
+ {
+ pGC->numInDashList += ndash;
+ indash = pdash;
+ i = ndash;
+ while (i--)
+ *p++ = *indash++;
+ }
+ while(ndash--)
+ *p++ = *pdash++;
+ pGC->stateChanges |= GCDashList;
+ maskQ |= GCDashList;
+
+ if (pGC->funcs->ChangeGC)
+ (*pGC->funcs->ChangeGC) (pGC, maskQ);
+ return Success;
+}
+
+int
+VerifyRectOrder(int nrects, xRectangle *prects, int ordering)
+{
+ register xRectangle *prectP, *prectN;
+ register int i;
+
+ switch(ordering)
+ {
+ case Unsorted:
+ return CT_UNSORTED;
+ case YSorted:
+ if(nrects > 1)
+ {
+ for(i = 1, prectP = prects, prectN = prects + 1;
+ i < nrects;
+ i++, prectP++, prectN++)
+ if(prectN->y < prectP->y)
+ return -1;
+ }
+ return CT_YSORTED;
+ case YXSorted:
+ if(nrects > 1)
+ {
+ for(i = 1, prectP = prects, prectN = prects + 1;
+ i < nrects;
+ i++, prectP++, prectN++)
+ if((prectN->y < prectP->y) ||
+ ( (prectN->y == prectP->y) &&
+ (prectN->x < prectP->x) ) )
+ return -1;
+ }
+ return CT_YXSORTED;
+ case YXBanded:
+ if(nrects > 1)
+ {
+ for(i = 1, prectP = prects, prectN = prects + 1;
+ i < nrects;
+ i++, prectP++, prectN++)
+ if((prectN->y != prectP->y &&
+ prectN->y < prectP->y + (int) prectP->height) ||
+ ((prectN->y == prectP->y) &&
+ (prectN->height != prectP->height ||
+ prectN->x < prectP->x + (int) prectP->width)))
+ return -1;
+ }
+ return CT_YXBANDED;
+ }
+ return -1;
+}
+
+int
+SetClipRects(GCPtr pGC, int xOrigin, int yOrigin, int nrects,
+ xRectangle *prects, int ordering)
+{
+ int newct, size;
+ xRectangle *prectsNew;
+
+ newct = VerifyRectOrder(nrects, prects, ordering);
+ if (newct < 0)
+ return(BadMatch);
+ size = nrects * sizeof(xRectangle);
+ prectsNew = (xRectangle *) xalloc(size);
+ if (!prectsNew && size)
+ return BadAlloc;
+
+ pGC->serialNumber |= GC_CHANGE_SERIAL_BIT;
+ pGC->clipOrg.x = xOrigin;
+ pGC->stateChanges |= GCClipXOrigin;
+
+ pGC->clipOrg.y = yOrigin;
+ pGC->stateChanges |= GCClipYOrigin;
+
+ if (size)
+ memmove((char *)prectsNew, (char *)prects, size);
+ (*pGC->funcs->ChangeClip)(pGC, newct, (pointer)prectsNew, nrects);
+ if (pGC->funcs->ChangeGC)
+ (*pGC->funcs->ChangeGC) (pGC, GCClipXOrigin|GCClipYOrigin|GCClipMask);
+ return Success;
+}
+
+
+/*
+ sets reasonable defaults
+ if we can get a pre-allocated one, use it and mark it as used.
+ if we can't, create one out of whole cloth (The Velveteen GC -- if
+ you use it often enough it will become real.)
+*/
+GCPtr
+GetScratchGC(register unsigned depth, register ScreenPtr pScreen)
+{
+ register int i;
+ register GCPtr pGC;
+
+ for (i=0; i<=pScreen->numDepths; i++)
+ if ( pScreen->GCperDepth[i]->depth == depth &&
+ !(pScreen->rgf & (1L << (i+1)))
+ )
+ {
+ pScreen->rgf |= (1L << (i+1));
+ pGC = (pScreen->GCperDepth[i]);
+
+ pGC->alu = GXcopy;
+ pGC->planemask = ~0;
+ pGC->serialNumber = 0;
+ pGC->fgPixel = 0;
+ pGC->bgPixel = 1;
+ pGC->lineWidth = 0;
+ pGC->lineStyle = LineSolid;
+ pGC->capStyle = CapButt;
+ pGC->joinStyle = JoinMiter;
+ pGC->fillStyle = FillSolid;
+ pGC->fillRule = EvenOddRule;
+ pGC->arcMode = ArcChord;
+ pGC->patOrg.x = 0;
+ pGC->patOrg.y = 0;
+ pGC->subWindowMode = ClipByChildren;
+ pGC->graphicsExposures = FALSE;
+ pGC->clipOrg.x = 0;
+ pGC->clipOrg.y = 0;
+ if (pGC->clientClipType != CT_NONE)
+ (*pGC->funcs->ChangeClip) (pGC, CT_NONE, NULL, 0);
+ pGC->stateChanges = (1 << (GCLastBit+1)) - 1;
+ return pGC;
+ }
+ /* if we make it this far, need to roll our own */
+ pGC = CreateScratchGC(pScreen, depth);
+ if (pGC)
+ pGC->graphicsExposures = FALSE;
+ return pGC;
+}
+
+/*
+ if the gc to free is in the table of pre-existing ones,
+mark it as available.
+ if not, free it for real
+*/
+void
+FreeScratchGC(register GCPtr pGC)
+{
+ register ScreenPtr pScreen = pGC->pScreen;
+ register int i;
+
+ for (i=0; i<=pScreen->numDepths; i++)
+ {
+ if ( pScreen->GCperDepth[i] == pGC)
+ {
+ pScreen->rgf &= ~(1L << (i+1));
+ return;
+ }
+ }
+ (void)FreeGC(pGC, (GContext)0);
+}
diff --git a/nx-X11/programs/Xserver/dix/globals.c b/nx-X11/programs/Xserver/dix/globals.c
new file mode 100644
index 000000000..15eedf602
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/globals.c
@@ -0,0 +1,163 @@
+/* $XdotOrg: xc/programs/Xserver/dix/globals.c,v 1.7 2005/07/03 08:53:38 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/dix/globals.c,v 1.12tsi Exp $ */
+/************************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/* $Xorg: globals.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "misc.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "input.h"
+#include "dixfont.h"
+#include "site.h"
+#include "dixstruct.h"
+#include "os.h"
+
+ScreenInfo screenInfo;
+KeybdCtrl defaultKeyboardControl = {
+ DEFAULT_KEYBOARD_CLICK,
+ DEFAULT_BELL,
+ DEFAULT_BELL_PITCH,
+ DEFAULT_BELL_DURATION,
+ DEFAULT_AUTOREPEAT,
+ DEFAULT_AUTOREPEATS,
+ DEFAULT_LEDS,
+ 0};
+
+PtrCtrl defaultPointerControl = {
+ DEFAULT_PTR_NUMERATOR,
+ DEFAULT_PTR_DENOMINATOR,
+ DEFAULT_PTR_THRESHOLD,
+ 0};
+
+ClientPtr *clients;
+ClientPtr serverClient;
+int currentMaxClients; /* current size of clients array */
+long maxBigRequestSize = MAX_BIG_REQUEST_SIZE;
+
+WindowPtr *WindowTable;
+
+unsigned long globalSerialNumber = 0;
+unsigned long serverGeneration = 0;
+
+/* these next four are initialized in main.c */
+CARD32 ScreenSaverTime;
+CARD32 ScreenSaverInterval;
+int ScreenSaverBlanking;
+int ScreenSaverAllowExposures;
+
+#ifdef DPMSExtension
+# ifndef DEFAULT_STANDBY_TIME
+# define DEFAULT_STANDBY_TIME DEFAULT_SCREEN_SAVER_TIME * 2
+# endif
+# ifndef DEFAULT_SUSPEND_TIME
+# define DEFAULT_SUSPEND_TIME DEFAULT_SCREEN_SAVER_TIME * 3
+# endif
+# ifndef DEFAULT_OFF_TIME
+# define DEFAULT_OFF_TIME DEFAULT_SCREEN_SAVER_TIME * 4
+# endif
+# ifndef DEFAULT_DPMS_ENABLED
+# define DEFAULT_DPMS_ENABLED FALSE
+# endif
+CARD32 defaultDPMSStandbyTime = DEFAULT_STANDBY_TIME;
+CARD32 defaultDPMSSuspendTime = DEFAULT_SUSPEND_TIME;
+CARD32 defaultDPMSOffTime = DEFAULT_OFF_TIME;
+CARD16 DPMSPowerLevel = 0;
+Bool defaultDPMSEnabled = DEFAULT_DPMS_ENABLED;
+Bool DPMSEnabledSwitch = FALSE; /* these denote the DPMS command line */
+Bool DPMSDisabledSwitch = FALSE; /* switch states */
+Bool DPMSCapableFlag = FALSE;
+CARD32 DPMSStandbyTime;
+CARD32 DPMSSuspendTime;
+CARD32 DPMSOffTime;
+Bool DPMSEnabled;
+#endif
+
+CARD32 defaultScreenSaverTime = DEFAULT_SCREEN_SAVER_TIME;
+CARD32 defaultScreenSaverInterval = DEFAULT_SCREEN_SAVER_INTERVAL;
+int defaultScreenSaverBlanking = DEFAULT_SCREEN_SAVER_BLANKING;
+int defaultScreenSaverAllowExposures = DEFAULT_SCREEN_SAVER_EXPOSURES;
+#ifndef NOLOGOHACK
+int logoScreenSaver = DEFAULT_LOGO_SCREEN_SAVER;
+#endif
+
+char *defaultFontPath = COMPILEDDEFAULTFONTPATH;
+char *defaultTextFont = COMPILEDDEFAULTFONT;
+char *defaultCursorFont = COMPILEDCURSORFONT;
+char *rgbPath = RGB_DB;
+char *defaultDisplayClass = COMPILEDDISPLAYCLASS;
+FontPtr defaultFont; /* not declared in dix.h to avoid including font.h in
+ every compilation of dix code */
+Bool loadableFonts = FALSE;
+CursorPtr rootCursor;
+Bool blackRoot=FALSE;
+ClientPtr requestingClient; /* XXX this should be obsolete now, remove? */
+
+TimeStamp currentTime;
+TimeStamp lastDeviceEventTime;
+
+Bool permitOldBugs = FALSE; /* turn off some error checking, to permit certain
+ * old broken clients (like R2/R3 xterms) to work
+ */
+
+int defaultColorVisualClass = -1;
+int monitorResolution = 0;
+
+char *display;
+
+CARD32 TimeOutValue = DEFAULT_TIMEOUT * MILLI_PER_SECOND;
+int argcGlobal;
+char **argvGlobal;
+
+DDXPointRec dixScreenOrigins[MAXSCREENS];
diff --git a/nx-X11/programs/Xserver/dix/glyphcurs.c b/nx-X11/programs/Xserver/dix/glyphcurs.c
new file mode 100644
index 000000000..8f8adf5ce
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/glyphcurs.c
@@ -0,0 +1,194 @@
+/************************************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+************************************************************************/
+
+/* $Xorg: glyphcurs.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "misc.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "resource.h"
+#include "dix.h"
+#include "cursorstr.h"
+#include "opaque.h"
+#include "servermd.h"
+
+
+/*
+ get the bits out of the font in a portable way. to avoid
+dealing with padding and such-like, we draw the glyph into
+a bitmap, then read the bits out with GetImage, which
+uses server-natural format.
+ since all screens return the same bitmap format, we'll just use
+the first one we find.
+ the character origin lines up with the hotspot in the
+cursor metrics.
+*/
+
+int
+ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, unsigned char **ppbits)
+{
+ register ScreenPtr pScreen;
+ register GCPtr pGC;
+ xRectangle rect;
+ PixmapPtr ppix;
+ long nby;
+ char *pbits;
+ ChangeGCVal gcval[3];
+ unsigned char char2b[2];
+
+ /* turn glyph index into a protocol-format char2b */
+ char2b[0] = (unsigned char)(ch >> 8);
+ char2b[1] = (unsigned char)(ch & 0xff);
+
+ pScreen = screenInfo.screens[0];
+ nby = BitmapBytePad(cm->width) * (long)cm->height;
+ pbits = (char *)xalloc(nby);
+ if (!pbits)
+ return BadAlloc;
+ /* zeroing the (pad) bits seems to help some ddx cursor handling */
+ bzero(pbits, nby);
+
+ ppix = (PixmapPtr)(*pScreen->CreatePixmap)(pScreen, cm->width,
+ cm->height, 1);
+ pGC = GetScratchGC(1, pScreen);
+ if (!ppix || !pGC)
+ {
+ if (ppix)
+ (*pScreen->DestroyPixmap)(ppix);
+ if (pGC)
+ FreeScratchGC(pGC);
+ xfree(pbits);
+ return BadAlloc;
+ }
+
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = cm->width;
+ rect.height = cm->height;
+
+ /* fill the pixmap with 0 */
+ gcval[0].val = GXcopy;
+ gcval[1].val = 0;
+ gcval[2].ptr = (pointer)pfont;
+ dixChangeGC(NullClient, pGC, GCFunction | GCForeground | GCFont,
+ NULL, gcval);
+ ValidateGC((DrawablePtr)ppix, pGC);
+ (*pGC->ops->PolyFillRect)((DrawablePtr)ppix, pGC, 1, &rect);
+
+ /* draw the glyph */
+ gcval[0].val = 1;
+ dixChangeGC(NullClient, pGC, GCForeground, NULL, gcval);
+ ValidateGC((DrawablePtr)ppix, pGC);
+ (*pGC->ops->PolyText16)((DrawablePtr)ppix, pGC, cm->xhot, cm->yhot,
+ 1, (unsigned short *)char2b);
+ (*pScreen->GetImage)((DrawablePtr)ppix, 0, 0, cm->width, cm->height,
+ XYPixmap, 1, pbits);
+ *ppbits = (unsigned char *)pbits;
+ FreeScratchGC(pGC);
+ (*pScreen->DestroyPixmap)(ppix);
+ return Success;
+}
+
+
+Bool
+CursorMetricsFromGlyph(register FontPtr pfont, unsigned ch, register CursorMetricPtr cm)
+{
+ CharInfoPtr pci;
+ unsigned long nglyphs;
+ CARD8 chs[2];
+ FontEncoding encoding;
+
+ chs[0] = ch >> 8;
+ chs[1] = ch;
+ encoding = (FONTLASTROW(pfont) == 0) ? Linear16Bit : TwoD16Bit;
+ if (encoding == Linear16Bit)
+ {
+ if (ch < pfont->info.firstCol || pfont->info.lastCol < ch)
+ return FALSE;
+ }
+ else
+ {
+ if (chs[0] < pfont->info.firstRow || pfont->info.lastRow < chs[0])
+ return FALSE;
+ if (chs[1] < pfont->info.firstCol || pfont->info.lastCol < chs[1])
+ return FALSE;
+ }
+ (*pfont->get_glyphs) (pfont, 1, chs, encoding, &nglyphs, &pci);
+ if (nglyphs == 0)
+ return FALSE;
+ cm->width = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
+ cm->height = pci->metrics.descent + pci->metrics.ascent;
+ if (pci->metrics.leftSideBearing > 0)
+ {
+ cm->width += pci->metrics.leftSideBearing;
+ cm->xhot = 0;
+ }
+ else
+ {
+ cm->xhot = -pci->metrics.leftSideBearing;
+ if (pci->metrics.rightSideBearing < 0)
+ cm->width -= pci->metrics.rightSideBearing;
+ }
+ if (pci->metrics.ascent < 0)
+ {
+ cm->height -= pci->metrics.ascent;
+ cm->yhot = 0;
+ }
+ else
+ {
+ cm->yhot = pci->metrics.ascent;
+ if (pci->metrics.descent < 0)
+ cm->height -= pci->metrics.descent;
+ }
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/dix/grabs.c b/nx-X11/programs/Xserver/dix/grabs.c
new file mode 100644
index 000000000..1d76f7f07
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/grabs.c
@@ -0,0 +1,438 @@
+/* $Xorg: grabs.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN action OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*/
+/* $XFree86: xc/programs/Xserver/dix/grabs.c,v 3.4 2002/02/19 11:09:22 alanh Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include "windowstr.h"
+#include "inputstr.h"
+#include "cursorstr.h"
+#include "dixgrabs.h"
+
+#define BITMASK(i) (((Mask)1) << ((i) & 31))
+#define MASKIDX(i) ((i) >> 5)
+#define MASKWORD(buf, i) buf[MASKIDX(i)]
+#define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
+#define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
+#define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
+
+GrabPtr
+CreateGrab(
+ int client,
+ DeviceIntPtr device,
+ WindowPtr window,
+ Mask eventMask,
+ Bool ownerEvents, Bool keyboardMode, Bool pointerMode,
+ DeviceIntPtr modDevice,
+ unsigned short modifiers,
+ int type,
+ KeyCode keybut, /* key or button */
+ WindowPtr confineTo,
+ CursorPtr cursor)
+{
+ GrabPtr grab;
+
+ grab = (GrabPtr)xalloc(sizeof(GrabRec));
+ if (!grab)
+ return (GrabPtr)NULL;
+ grab->resource = FakeClientID(client);
+ grab->device = device;
+ grab->coreGrab = ((device == inputInfo.keyboard) ||
+ (device == inputInfo.pointer));
+ grab->window = window;
+ grab->eventMask = eventMask;
+ grab->ownerEvents = ownerEvents;
+ grab->keyboardMode = keyboardMode;
+ grab->pointerMode = pointerMode;
+ grab->modifiersDetail.exact = modifiers;
+ grab->modifiersDetail.pMask = NULL;
+ grab->modifierDevice = modDevice;
+ grab->coreMods = ((modDevice == inputInfo.keyboard) ||
+ (modDevice == inputInfo.pointer));
+ grab->type = type;
+ grab->detail.exact = keybut;
+ grab->detail.pMask = NULL;
+ grab->confineTo = confineTo;
+ grab->cursor = cursor;
+ if (cursor)
+ cursor->refcnt++;
+ return grab;
+
+}
+
+static void
+FreeGrab(GrabPtr pGrab)
+{
+ if (pGrab->modifiersDetail.pMask != NULL)
+ xfree(pGrab->modifiersDetail.pMask);
+
+ if (pGrab->detail.pMask != NULL)
+ xfree(pGrab->detail.pMask);
+
+ if (pGrab->cursor)
+ FreeCursor(pGrab->cursor, (Cursor)0);
+
+ xfree(pGrab);
+}
+
+int
+DeletePassiveGrab(pointer value, XID id)
+{
+ register GrabPtr g, prev;
+ GrabPtr pGrab = (GrabPtr)value;
+
+ /* it is OK if the grab isn't found */
+ prev = 0;
+ for (g = (wPassiveGrabs (pGrab->window)); g; g = g->next)
+ {
+ if (pGrab == g)
+ {
+ if (prev)
+ prev->next = g->next;
+ else
+ if (!(pGrab->window->optional->passiveGrabs = g->next))
+ CheckWindowOptionalNeed (pGrab->window);
+ break;
+ }
+ prev = g;
+ }
+ FreeGrab(pGrab);
+ return Success;
+}
+
+static Mask *
+DeleteDetailFromMask(Mask *pDetailMask, unsigned short detail)
+{
+ register Mask *mask;
+ register int i;
+
+ mask = (Mask *)xalloc(sizeof(Mask) * MasksPerDetailMask);
+ if (mask)
+ {
+ if (pDetailMask)
+ for (i = 0; i < MasksPerDetailMask; i++)
+ mask[i]= pDetailMask[i];
+ else
+ for (i = 0; i < MasksPerDetailMask; i++)
+ mask[i]= ~0L;
+ BITCLEAR(mask, detail);
+ }
+ return mask;
+}
+
+static Bool
+IsInGrabMask(
+ DetailRec firstDetail,
+ DetailRec secondDetail,
+ unsigned short exception)
+{
+ if (firstDetail.exact == exception)
+ {
+ if (firstDetail.pMask == NULL)
+ return TRUE;
+
+ /* (at present) never called with two non-null pMasks */
+ if (secondDetail.exact == exception)
+ return FALSE;
+
+ if (GETBIT(firstDetail.pMask, secondDetail.exact))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static Bool
+IdenticalExactDetails(
+ unsigned short firstExact,
+ unsigned short secondExact,
+ unsigned short exception)
+{
+ if ((firstExact == exception) || (secondExact == exception))
+ return FALSE;
+
+ if (firstExact == secondExact)
+ return TRUE;
+
+ return FALSE;
+}
+
+static Bool
+DetailSupersedesSecond(
+ DetailRec firstDetail,
+ DetailRec secondDetail,
+ unsigned short exception)
+{
+ if (IsInGrabMask(firstDetail, secondDetail, exception))
+ return TRUE;
+
+ if (IdenticalExactDetails(firstDetail.exact, secondDetail.exact,
+ exception))
+ return TRUE;
+
+ return FALSE;
+}
+
+static Bool
+GrabSupersedesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab)
+{
+ if (!DetailSupersedesSecond(pFirstGrab->modifiersDetail,
+ pSecondGrab->modifiersDetail,
+ (unsigned short)AnyModifier))
+ return FALSE;
+
+ if (DetailSupersedesSecond(pFirstGrab->detail,
+ pSecondGrab->detail, (unsigned short)AnyKey))
+ return TRUE;
+
+ return FALSE;
+}
+
+Bool
+GrabMatchesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab)
+{
+ if ((pFirstGrab->device != pSecondGrab->device) ||
+ (pFirstGrab->modifierDevice != pSecondGrab->modifierDevice) ||
+ (pFirstGrab->type != pSecondGrab->type))
+ return FALSE;
+
+ if (GrabSupersedesSecond(pFirstGrab, pSecondGrab) ||
+ GrabSupersedesSecond(pSecondGrab, pFirstGrab))
+ return TRUE;
+
+ if (DetailSupersedesSecond(pSecondGrab->detail, pFirstGrab->detail,
+ (unsigned short)AnyKey)
+ &&
+ DetailSupersedesSecond(pFirstGrab->modifiersDetail,
+ pSecondGrab->modifiersDetail,
+ (unsigned short)AnyModifier))
+ return TRUE;
+
+ if (DetailSupersedesSecond(pFirstGrab->detail, pSecondGrab->detail,
+ (unsigned short)AnyKey)
+ &&
+ DetailSupersedesSecond(pSecondGrab->modifiersDetail,
+ pFirstGrab->modifiersDetail,
+ (unsigned short)AnyModifier))
+ return TRUE;
+
+ return FALSE;
+}
+
+int
+AddPassiveGrabToList(GrabPtr pGrab)
+{
+ GrabPtr grab;
+
+ for (grab = wPassiveGrabs(pGrab->window); grab; grab = grab->next)
+ {
+ if (GrabMatchesSecond(pGrab, grab))
+ {
+ if (CLIENT_BITS(pGrab->resource) != CLIENT_BITS(grab->resource))
+ {
+ FreeGrab(pGrab);
+ return BadAccess;
+ }
+ }
+ }
+
+ if (!pGrab->window->optional && !MakeWindowOptional (pGrab->window))
+ {
+ FreeGrab(pGrab);
+ return BadAlloc;
+ }
+ pGrab->next = pGrab->window->optional->passiveGrabs;
+ pGrab->window->optional->passiveGrabs = pGrab;
+ if (AddResource(pGrab->resource, RT_PASSIVEGRAB, (pointer)pGrab))
+ return Success;
+ return BadAlloc;
+}
+
+/* the following is kinda complicated, because we need to be able to back out
+ * if any allocation fails
+ */
+
+Bool
+DeletePassiveGrabFromList(GrabPtr pMinuendGrab)
+{
+ register GrabPtr grab;
+ GrabPtr *deletes, *adds;
+ Mask ***updates, **details;
+ int i, ndels, nadds, nups;
+ Bool ok;
+
+#define UPDATE(mask,exact) \
+ if (!(details[nups] = DeleteDetailFromMask(mask, exact))) \
+ ok = FALSE; \
+ else \
+ updates[nups++] = &(mask)
+
+ i = 0;
+ for (grab = wPassiveGrabs(pMinuendGrab->window); grab; grab = grab->next)
+ i++;
+ if (!i)
+ return TRUE;
+ deletes = (GrabPtr *)ALLOCATE_LOCAL(i * sizeof(GrabPtr));
+ adds = (GrabPtr *)ALLOCATE_LOCAL(i * sizeof(GrabPtr));
+ updates = (Mask ***)ALLOCATE_LOCAL(i * sizeof(Mask **));
+ details = (Mask **)ALLOCATE_LOCAL(i * sizeof(Mask *));
+ if (!deletes || !adds || !updates || !details)
+ {
+ if (details) DEALLOCATE_LOCAL(details);
+ if (updates) DEALLOCATE_LOCAL(updates);
+ if (adds) DEALLOCATE_LOCAL(adds);
+ if (deletes) DEALLOCATE_LOCAL(deletes);
+ return FALSE;
+ }
+ ndels = nadds = nups = 0;
+ ok = TRUE;
+ for (grab = wPassiveGrabs(pMinuendGrab->window);
+ grab && ok;
+ grab = grab->next)
+ {
+ if ((CLIENT_BITS(grab->resource) != CLIENT_BITS(pMinuendGrab->resource)) ||
+ !GrabMatchesSecond(grab, pMinuendGrab))
+ continue;
+ if (GrabSupersedesSecond(pMinuendGrab, grab))
+ {
+ deletes[ndels++] = grab;
+ }
+ else if ((grab->detail.exact == AnyKey)
+ && (grab->modifiersDetail.exact != AnyModifier))
+ {
+ UPDATE(grab->detail.pMask, pMinuendGrab->detail.exact);
+ }
+ else if ((grab->modifiersDetail.exact == AnyModifier)
+ && (grab->detail.exact != AnyKey))
+ {
+ UPDATE(grab->modifiersDetail.pMask,
+ pMinuendGrab->modifiersDetail.exact);
+ }
+ else if ((pMinuendGrab->detail.exact != AnyKey)
+ && (pMinuendGrab->modifiersDetail.exact != AnyModifier))
+ {
+ GrabPtr pNewGrab;
+
+ UPDATE(grab->detail.pMask, pMinuendGrab->detail.exact);
+
+ pNewGrab = CreateGrab(CLIENT_ID(grab->resource), grab->device,
+ grab->window, (Mask)grab->eventMask,
+ (Bool)grab->ownerEvents,
+ (Bool)grab->keyboardMode,
+ (Bool)grab->pointerMode,
+ grab->modifierDevice,
+ AnyModifier, (int)grab->type,
+ pMinuendGrab->detail.exact,
+ grab->confineTo, grab->cursor);
+ if (!pNewGrab)
+ ok = FALSE;
+ else if (!(pNewGrab->modifiersDetail.pMask =
+ DeleteDetailFromMask(grab->modifiersDetail.pMask,
+ pMinuendGrab->modifiersDetail.exact))
+ ||
+ (!pNewGrab->window->optional &&
+ !MakeWindowOptional(pNewGrab->window)))
+ {
+ FreeGrab(pNewGrab);
+ ok = FALSE;
+ }
+ else if (!AddResource(pNewGrab->resource, RT_PASSIVEGRAB,
+ (pointer)pNewGrab))
+ ok = FALSE;
+ else
+ adds[nadds++] = pNewGrab;
+ }
+ else if (pMinuendGrab->detail.exact == AnyKey)
+ {
+ UPDATE(grab->modifiersDetail.pMask,
+ pMinuendGrab->modifiersDetail.exact);
+ }
+ else
+ {
+ UPDATE(grab->detail.pMask, pMinuendGrab->detail.exact);
+ }
+ }
+
+ if (!ok)
+ {
+ for (i = 0; i < nadds; i++)
+ FreeResource(adds[i]->resource, RT_NONE);
+ for (i = 0; i < nups; i++)
+ xfree(details[i]);
+ }
+ else
+ {
+ for (i = 0; i < ndels; i++)
+ FreeResource(deletes[i]->resource, RT_NONE);
+ for (i = 0; i < nadds; i++)
+ {
+ grab = adds[i];
+ grab->next = grab->window->optional->passiveGrabs;
+ grab->window->optional->passiveGrabs = grab;
+ }
+ for (i = 0; i < nups; i++)
+ {
+ xfree(*updates[i]);
+ *updates[i] = details[i];
+ }
+ }
+ DEALLOCATE_LOCAL(details);
+ DEALLOCATE_LOCAL(updates);
+ DEALLOCATE_LOCAL(adds);
+ DEALLOCATE_LOCAL(deletes);
+ return ok;
+
+#undef UPDATE
+}
diff --git a/nx-X11/programs/Xserver/dix/initatoms.c b/nx-X11/programs/Xserver/dix/initatoms.c
new file mode 100644
index 000000000..a5972afd6
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/initatoms.c
@@ -0,0 +1,84 @@
+/* THIS IS A GENERATED FILE
+ *
+ * Do not change! Changing this file implies a protocol change!
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xatom.h>
+#include "misc.h"
+#include "dix.h"
+void MakePredeclaredAtoms()
+{
+ if (MakeAtom("PRIMARY", 7, 1) != XA_PRIMARY) AtomError();
+ if (MakeAtom("SECONDARY", 9, 1) != XA_SECONDARY) AtomError();
+ if (MakeAtom("ARC", 3, 1) != XA_ARC) AtomError();
+ if (MakeAtom("ATOM", 4, 1) != XA_ATOM) AtomError();
+ if (MakeAtom("BITMAP", 6, 1) != XA_BITMAP) AtomError();
+ if (MakeAtom("CARDINAL", 8, 1) != XA_CARDINAL) AtomError();
+ if (MakeAtom("COLORMAP", 8, 1) != XA_COLORMAP) AtomError();
+ if (MakeAtom("CURSOR", 6, 1) != XA_CURSOR) AtomError();
+ if (MakeAtom("CUT_BUFFER0", 11, 1) != XA_CUT_BUFFER0) AtomError();
+ if (MakeAtom("CUT_BUFFER1", 11, 1) != XA_CUT_BUFFER1) AtomError();
+ if (MakeAtom("CUT_BUFFER2", 11, 1) != XA_CUT_BUFFER2) AtomError();
+ if (MakeAtom("CUT_BUFFER3", 11, 1) != XA_CUT_BUFFER3) AtomError();
+ if (MakeAtom("CUT_BUFFER4", 11, 1) != XA_CUT_BUFFER4) AtomError();
+ if (MakeAtom("CUT_BUFFER5", 11, 1) != XA_CUT_BUFFER5) AtomError();
+ if (MakeAtom("CUT_BUFFER6", 11, 1) != XA_CUT_BUFFER6) AtomError();
+ if (MakeAtom("CUT_BUFFER7", 11, 1) != XA_CUT_BUFFER7) AtomError();
+ if (MakeAtom("DRAWABLE", 8, 1) != XA_DRAWABLE) AtomError();
+ if (MakeAtom("FONT", 4, 1) != XA_FONT) AtomError();
+ if (MakeAtom("INTEGER", 7, 1) != XA_INTEGER) AtomError();
+ if (MakeAtom("PIXMAP", 6, 1) != XA_PIXMAP) AtomError();
+ if (MakeAtom("POINT", 5, 1) != XA_POINT) AtomError();
+ if (MakeAtom("RECTANGLE", 9, 1) != XA_RECTANGLE) AtomError();
+ if (MakeAtom("RESOURCE_MANAGER", 16, 1) != XA_RESOURCE_MANAGER) AtomError();
+ if (MakeAtom("RGB_COLOR_MAP", 13, 1) != XA_RGB_COLOR_MAP) AtomError();
+ if (MakeAtom("RGB_BEST_MAP", 12, 1) != XA_RGB_BEST_MAP) AtomError();
+ if (MakeAtom("RGB_BLUE_MAP", 12, 1) != XA_RGB_BLUE_MAP) AtomError();
+ if (MakeAtom("RGB_DEFAULT_MAP", 15, 1) != XA_RGB_DEFAULT_MAP) AtomError();
+ if (MakeAtom("RGB_GRAY_MAP", 12, 1) != XA_RGB_GRAY_MAP) AtomError();
+ if (MakeAtom("RGB_GREEN_MAP", 13, 1) != XA_RGB_GREEN_MAP) AtomError();
+ if (MakeAtom("RGB_RED_MAP", 11, 1) != XA_RGB_RED_MAP) AtomError();
+ if (MakeAtom("STRING", 6, 1) != XA_STRING) AtomError();
+ if (MakeAtom("VISUALID", 8, 1) != XA_VISUALID) AtomError();
+ if (MakeAtom("WINDOW", 6, 1) != XA_WINDOW) AtomError();
+ if (MakeAtom("WM_COMMAND", 10, 1) != XA_WM_COMMAND) AtomError();
+ if (MakeAtom("WM_HINTS", 8, 1) != XA_WM_HINTS) AtomError();
+ if (MakeAtom("WM_CLIENT_MACHINE", 17, 1) != XA_WM_CLIENT_MACHINE) AtomError();
+ if (MakeAtom("WM_ICON_NAME", 12, 1) != XA_WM_ICON_NAME) AtomError();
+ if (MakeAtom("WM_ICON_SIZE", 12, 1) != XA_WM_ICON_SIZE) AtomError();
+ if (MakeAtom("WM_NAME", 7, 1) != XA_WM_NAME) AtomError();
+ if (MakeAtom("WM_NORMAL_HINTS", 15, 1) != XA_WM_NORMAL_HINTS) AtomError();
+ if (MakeAtom("WM_SIZE_HINTS", 13, 1) != XA_WM_SIZE_HINTS) AtomError();
+ if (MakeAtom("WM_ZOOM_HINTS", 13, 1) != XA_WM_ZOOM_HINTS) AtomError();
+ if (MakeAtom("MIN_SPACE", 9, 1) != XA_MIN_SPACE) AtomError();
+ if (MakeAtom("NORM_SPACE", 10, 1) != XA_NORM_SPACE) AtomError();
+ if (MakeAtom("MAX_SPACE", 9, 1) != XA_MAX_SPACE) AtomError();
+ if (MakeAtom("END_SPACE", 9, 1) != XA_END_SPACE) AtomError();
+ if (MakeAtom("SUPERSCRIPT_X", 13, 1) != XA_SUPERSCRIPT_X) AtomError();
+ if (MakeAtom("SUPERSCRIPT_Y", 13, 1) != XA_SUPERSCRIPT_Y) AtomError();
+ if (MakeAtom("SUBSCRIPT_X", 11, 1) != XA_SUBSCRIPT_X) AtomError();
+ if (MakeAtom("SUBSCRIPT_Y", 11, 1) != XA_SUBSCRIPT_Y) AtomError();
+ if (MakeAtom("UNDERLINE_POSITION", 18, 1) != XA_UNDERLINE_POSITION) AtomError();
+ if (MakeAtom("UNDERLINE_THICKNESS", 19, 1) != XA_UNDERLINE_THICKNESS) AtomError();
+ if (MakeAtom("STRIKEOUT_ASCENT", 16, 1) != XA_STRIKEOUT_ASCENT) AtomError();
+ if (MakeAtom("STRIKEOUT_DESCENT", 17, 1) != XA_STRIKEOUT_DESCENT) AtomError();
+ if (MakeAtom("ITALIC_ANGLE", 12, 1) != XA_ITALIC_ANGLE) AtomError();
+ if (MakeAtom("X_HEIGHT", 8, 1) != XA_X_HEIGHT) AtomError();
+ if (MakeAtom("QUAD_WIDTH", 10, 1) != XA_QUAD_WIDTH) AtomError();
+ if (MakeAtom("WEIGHT", 6, 1) != XA_WEIGHT) AtomError();
+ if (MakeAtom("POINT_SIZE", 10, 1) != XA_POINT_SIZE) AtomError();
+ if (MakeAtom("RESOLUTION", 10, 1) != XA_RESOLUTION) AtomError();
+ if (MakeAtom("COPYRIGHT", 9, 1) != XA_COPYRIGHT) AtomError();
+ if (MakeAtom("NOTICE", 6, 1) != XA_NOTICE) AtomError();
+ if (MakeAtom("FONT_NAME", 9, 1) != XA_FONT_NAME) AtomError();
+ if (MakeAtom("FAMILY_NAME", 11, 1) != XA_FAMILY_NAME) AtomError();
+ if (MakeAtom("FULL_NAME", 9, 1) != XA_FULL_NAME) AtomError();
+ if (MakeAtom("CAP_HEIGHT", 10, 1) != XA_CAP_HEIGHT) AtomError();
+ if (MakeAtom("WM_CLASS", 8, 1) != XA_WM_CLASS) AtomError();
+ if (MakeAtom("WM_TRANSIENT_FOR", 16, 1) != XA_WM_TRANSIENT_FOR) AtomError();
+}
diff --git a/nx-X11/programs/Xserver/dix/main.c b/nx-X11/programs/Xserver/dix/main.c
new file mode 100644
index 000000000..6a8f79a96
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/main.c
@@ -0,0 +1,800 @@
+/* $XdotOrg: xc/programs/Xserver/dix/main.c,v 1.14 2005/07/03 08:53:38 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/dix/main.c,v 3.43 2003/10/30 21:21:02 herrb Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: main.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
+
+/* The panoramix components contained the following notice */
+/*****************************************************************
+
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+
+/* $TOG: main.c /main/86 1998/02/09 14:20:03 kaleb $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xos.h> /* for unistd.h */
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "misc.h"
+#include "os.h"
+#include "windowstr.h"
+#include "resource.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "extension.h"
+#include "colormap.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include <X11/fonts/font.h>
+#include "opaque.h"
+#include "servermd.h"
+#include "site.h"
+#include "dixfont.h"
+#include "extnsionst.h"
+#ifdef XPRINT
+#include "DiPrint.h"
+#endif
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+#else
+#include "dixevents.h" /* InitEvents() */
+#include "dispatch.h" /* InitProcVectors() */
+#endif
+
+#ifdef DPMSExtension
+#define DPMS_SERVER
+#include <X11/extensions/dpms.h>
+#include "dpmsproc.h"
+#endif
+
+extern int InitClientPrivates(ClientPtr client);
+
+extern void Dispatch(void);
+
+char *ConnectionInfo;
+xConnSetupPrefix connSetupPrefix;
+
+extern FontPtr defaultFont;
+extern int screenPrivateCount;
+
+extern void InitProcVectors(void);
+extern Bool CreateGCperDepthArray(void);
+
+#ifndef PANORAMIX
+static
+#endif
+Bool CreateConnectionBlock(void);
+
+static void FreeScreen(ScreenPtr);
+
+PaddingInfo PixmapWidthPaddingInfo[33];
+
+int connBlockScreenStart;
+
+static int restart = 0;
+
+void
+NotImplemented(xEvent *from, xEvent *to)
+{
+ FatalError("Not implemented");
+}
+
+/*
+ * Dummy entry for ReplySwapVector[]
+ */
+
+void
+ReplyNotSwappd(
+ ClientPtr pClient ,
+ int size ,
+ void * pbuf
+ )
+{
+ FatalError("Not implemented");
+}
+
+/*
+ * This array encodes the answer to the question "what is the log base 2
+ * of the number of pixels that fit in a scanline pad unit?"
+ * Note that ~0 is an invalid entry (mostly for the benefit of the reader).
+ */
+static int answer[6][4] = {
+ /* pad pad pad pad*/
+ /* 8 16 32 64 */
+
+ { 3, 4, 5 , 6 }, /* 1 bit per pixel */
+ { 1, 2, 3 , 4 }, /* 4 bits per pixel */
+ { 0, 1, 2 , 3 }, /* 8 bits per pixel */
+ { ~0, 0, 1 , 2 }, /* 16 bits per pixel */
+ { ~0, ~0, 0 , 1 }, /* 24 bits per pixel */
+ { ~0, ~0, 0 , 1 } /* 32 bits per pixel */
+};
+
+/*
+ * This array gives the answer to the question "what is the first index for
+ * the answer array above given the number of bits per pixel?"
+ * Note that ~0 is an invalid entry (mostly for the benefit of the reader).
+ */
+static int indexForBitsPerPixel[ 33 ] = {
+ ~0, 0, ~0, ~0, /* 1 bit per pixel */
+ 1, ~0, ~0, ~0, /* 4 bits per pixel */
+ 2, ~0, ~0, ~0, /* 8 bits per pixel */
+ ~0,~0, ~0, ~0,
+ 3, ~0, ~0, ~0, /* 16 bits per pixel */
+ ~0,~0, ~0, ~0,
+ 4, ~0, ~0, ~0, /* 24 bits per pixel */
+ ~0,~0, ~0, ~0,
+ 5 /* 32 bits per pixel */
+};
+
+/*
+ * This array gives the bytesperPixel value for cases where the number
+ * of bits per pixel is a multiple of 8 but not a power of 2.
+ */
+static int answerBytesPerPixel[ 33 ] = {
+ ~0, 0, ~0, ~0, /* 1 bit per pixel */
+ 0, ~0, ~0, ~0, /* 4 bits per pixel */
+ 0, ~0, ~0, ~0, /* 8 bits per pixel */
+ ~0,~0, ~0, ~0,
+ 0, ~0, ~0, ~0, /* 16 bits per pixel */
+ ~0,~0, ~0, ~0,
+ 3, ~0, ~0, ~0, /* 24 bits per pixel */
+ ~0,~0, ~0, ~0,
+ 0 /* 32 bits per pixel */
+};
+
+/*
+ * This array gives the answer to the question "what is the second index for
+ * the answer array above given the number of bits per scanline pad unit?"
+ * Note that ~0 is an invalid entry (mostly for the benefit of the reader).
+ */
+static int indexForScanlinePad[ 65 ] = {
+ ~0, ~0, ~0, ~0,
+ ~0, ~0, ~0, ~0,
+ 0, ~0, ~0, ~0, /* 8 bits per scanline pad unit */
+ ~0, ~0, ~0, ~0,
+ 1, ~0, ~0, ~0, /* 16 bits per scanline pad unit */
+ ~0, ~0, ~0, ~0,
+ ~0, ~0, ~0, ~0,
+ ~0, ~0, ~0, ~0,
+ 2, ~0, ~0, ~0, /* 32 bits per scanline pad unit */
+ ~0, ~0, ~0, ~0,
+ ~0, ~0, ~0, ~0,
+ ~0, ~0, ~0, ~0,
+ ~0, ~0, ~0, ~0,
+ ~0, ~0, ~0, ~0,
+ ~0, ~0, ~0, ~0,
+ ~0, ~0, ~0, ~0,
+ 3 /* 64 bits per scanline pad unit */
+};
+
+#ifndef MIN
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+int
+main(int argc, char *argv[], char *envp[])
+{
+ int i, j, k, error;
+ char *xauthfile;
+ HWEventQueueType alwaysCheckForInput[2];
+
+ display = "0";
+
+ InitGlobals();
+#ifdef XPRINT
+ PrinterInitGlobals();
+#endif
+
+ /* Quartz support on Mac OS X requires that the Cocoa event loop be in
+ * the main thread. This allows the X server main to be called again
+ * from another thread. */
+#if defined(__DARWIN__) && defined(DARWIN_WITH_QUARTZ)
+ DarwinHandleGUI(argc, argv, envp);
+#endif
+
+ /* Notice if we're restarted. Probably this is because we jumped through
+ * an uninitialized pointer */
+ if (restart)
+ FatalError("server restarted. Jumped through uninitialized pointer?\n");
+ else
+ restart = 1;
+
+ CheckUserParameters(argc, argv, envp);
+
+ CheckUserAuthorization();
+
+#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
+ ExpandCommandLine(&argc, &argv);
+#endif
+
+ InitConnectionLimits();
+
+ /* These are needed by some routines which are called from interrupt
+ * handlers, thus have no direct calling path back to main and thus
+ * can't be passed argc, argv as parameters */
+ argcGlobal = argc;
+ argvGlobal = argv;
+ /* prep X authority file from environment; this can be overriden by a
+ * command line option */
+ xauthfile = getenv("XAUTHORITY");
+ if (xauthfile) InitAuthorization (xauthfile);
+ ProcessCommandLine(argc, argv);
+
+ alwaysCheckForInput[0] = 0;
+ alwaysCheckForInput[1] = 1;
+ while(1)
+ {
+ serverGeneration++;
+ ScreenSaverTime = defaultScreenSaverTime;
+ ScreenSaverInterval = defaultScreenSaverInterval;
+ ScreenSaverBlanking = defaultScreenSaverBlanking;
+ ScreenSaverAllowExposures = defaultScreenSaverAllowExposures;
+#ifdef DPMSExtension
+ DPMSStandbyTime = defaultDPMSStandbyTime;
+ DPMSSuspendTime = defaultDPMSSuspendTime;
+ DPMSOffTime = defaultDPMSOffTime;
+ DPMSEnabled = defaultDPMSEnabled;
+ DPMSPowerLevel = 0;
+#endif
+ InitBlockAndWakeupHandlers();
+ /* Perform any operating system dependent initializations you'd like */
+ OsInit();
+ if(serverGeneration == 1)
+ {
+ CreateWellKnownSockets();
+ InitProcVectors();
+ clients = (ClientPtr *)xalloc(MAXCLIENTS * sizeof(ClientPtr));
+ if (!clients)
+ FatalError("couldn't create client array");
+ for (i=1; i<MAXCLIENTS; i++)
+ clients[i] = NullClient;
+ serverClient = (ClientPtr)xalloc(sizeof(ClientRec));
+ if (!serverClient)
+ FatalError("couldn't create server client");
+ InitClient(serverClient, 0, (pointer)NULL);
+ }
+ else
+ ResetWellKnownSockets ();
+ clients[0] = serverClient;
+ currentMaxClients = 1;
+
+ if (!InitClientResources(serverClient)) /* for root resources */
+ FatalError("couldn't init server resources");
+
+ SetInputCheck(&alwaysCheckForInput[0], &alwaysCheckForInput[1]);
+ screenInfo.arraySize = MAXSCREENS;
+ screenInfo.numScreens = 0;
+ screenInfo.numVideoScreens = -1;
+ WindowTable = (WindowPtr *)xalloc(MAXSCREENS * sizeof(WindowPtr));
+ if (!WindowTable)
+ FatalError("couldn't create root window table");
+
+ /*
+ * Just in case the ddx doesnt supply a format for depth 1 (like qvss).
+ */
+ j = indexForBitsPerPixel[ 1 ];
+ k = indexForScanlinePad[ BITMAP_SCANLINE_PAD ];
+ PixmapWidthPaddingInfo[1].padRoundUp = BITMAP_SCANLINE_PAD-1;
+ PixmapWidthPaddingInfo[1].padPixelsLog2 = answer[j][k];
+ j = indexForBitsPerPixel[8]; /* bits per byte */
+ PixmapWidthPaddingInfo[1].padBytesLog2 = answer[j][k];
+ PixmapWidthPaddingInfo[1].bitsPerPixel = 1;
+
+ InitAtoms();
+ InitEvents();
+ InitGlyphCaching();
+ ResetClientPrivates();
+ ResetScreenPrivates();
+ ResetWindowPrivates();
+ ResetGCPrivates();
+#ifdef PIXPRIV
+ ResetPixmapPrivates();
+#endif
+ ResetColormapPrivates();
+ ResetFontPrivateIndex();
+ ResetDevicePrivateIndex();
+ InitCallbackManager();
+ InitVisualWrap();
+ InitOutput(&screenInfo, argc, argv);
+#ifdef XPRINT
+ PrinterInitOutput(&screenInfo, argc, argv);
+#endif
+
+ if (screenInfo.numScreens < 1)
+ FatalError("no screens found");
+ if (screenInfo.numVideoScreens < 0)
+ screenInfo.numVideoScreens = screenInfo.numScreens;
+ InitExtensions(argc, argv);
+ if (!InitClientPrivates(serverClient))
+ FatalError("failed to allocate serverClient devprivates");
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ if (!CreateScratchPixmapsForScreen(i))
+ FatalError("failed to create scratch pixmaps");
+ if (pScreen->CreateScreenResources &&
+ !(*pScreen->CreateScreenResources)(pScreen))
+ FatalError("failed to create screen resources");
+ if (!CreateGCperDepth(i))
+ FatalError("failed to create scratch GCs");
+ if (!CreateDefaultStipple(i))
+ FatalError("failed to create default stipple");
+ if (!CreateRootWindow(pScreen))
+ FatalError("failed to create root window");
+ }
+ InitInput(argc, argv);
+ if (InitAndStartDevices() != Success)
+ FatalError("failed to initialize core devices");
+
+ InitFonts();
+ if (loadableFonts) {
+ SetFontPath(0, 0, (unsigned char *)defaultFontPath, &error);
+ } else {
+ if (SetDefaultFontPath(defaultFontPath) != Success)
+ ErrorF("failed to set default font path '%s'",
+ defaultFontPath);
+ }
+ if (!SetDefaultFont(defaultTextFont))
+ FatalError("could not open default font '%s'", defaultTextFont);
+ if (!(rootCursor = CreateRootCursor(defaultCursorFont, 0)))
+ FatalError("could not open default cursor font '%s'",
+ defaultCursorFont);
+#ifdef DPMSExtension
+ /* check all screens, looking for DPMS Capabilities */
+ DPMSCapableFlag = DPMSSupported();
+ if (!DPMSCapableFlag)
+ DPMSEnabled = FALSE;
+#endif
+
+#ifdef PANORAMIX
+ /*
+ * Consolidate window and colourmap information for each screen
+ */
+ if (!noPanoramiXExtension)
+ PanoramiXConsolidate();
+#endif
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ InitRootWindow(WindowTable[i]);
+ DefineInitialRootWindow(WindowTable[0]);
+ SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset);
+#ifdef DPMSExtension
+ SetDPMSTimers();
+#endif
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ if (!PanoramiXCreateConnectionBlock())
+ FatalError("could not create connection block info");
+ } else
+#endif
+ {
+ if (!CreateConnectionBlock())
+ FatalError("could not create connection block info");
+ }
+
+ Dispatch();
+
+ /* Now free up whatever must be freed */
+ if (screenIsSaved == SCREEN_SAVER_ON)
+ SaveScreens(SCREEN_SAVER_OFF, ScreenSaverReset);
+ FreeScreenSaverTimer();
+ CloseDownExtensions();
+
+#ifdef PANORAMIX
+ {
+ Bool remember_it = noPanoramiXExtension;
+ noPanoramiXExtension = TRUE;
+ FreeAllResources();
+ noPanoramiXExtension = remember_it;
+ }
+#else
+ FreeAllResources();
+#endif
+
+ CloseDownDevices();
+ for (i = screenInfo.numScreens - 1; i >= 0; i--)
+ {
+ FreeScratchPixmapsForScreen(i);
+ FreeGCperDepth(i);
+ FreeDefaultStipple(i);
+ (* screenInfo.screens[i]->CloseScreen)(i, screenInfo.screens[i]);
+ FreeScreen(screenInfo.screens[i]);
+ screenInfo.numScreens = i;
+ }
+ CloseDownEvents();
+ xfree(WindowTable);
+ WindowTable = NULL;
+ FreeFonts();
+
+#ifdef DPMSExtension
+ FreeDPMSTimers();
+#endif
+ FreeAuditTimer();
+
+ xfree(serverClient->devPrivates);
+ serverClient->devPrivates = NULL;
+
+ if (dispatchException & DE_TERMINATE)
+ {
+ CloseWellKnownConnections();
+ }
+
+ OsCleanup((dispatchException & DE_TERMINATE) != 0);
+
+ if (dispatchException & DE_TERMINATE)
+ {
+ ddxGiveUp();
+ break;
+ }
+
+ xfree(ConnectionInfo);
+ ConnectionInfo = NULL;
+ }
+ return(0);
+}
+
+static int VendorRelease = VENDOR_RELEASE;
+static char *VendorString = VENDOR_STRING;
+
+void
+SetVendorRelease(int release)
+{
+ VendorRelease = release;
+}
+
+void
+SetVendorString(char *string)
+{
+ VendorString = string;
+}
+
+static int padlength[4] = {0, 3, 2, 1};
+
+#ifndef PANORAMIX
+static
+#endif
+Bool
+CreateConnectionBlock()
+{
+ xConnSetup setup;
+ xWindowRoot root;
+ xDepth depth;
+ xVisualType visual;
+ xPixmapFormat format;
+ unsigned long vid;
+ int i, j, k,
+ lenofblock,
+ sizesofar = 0;
+ char *pBuf;
+
+
+ /* Leave off the ridBase and ridMask, these must be sent with
+ connection */
+
+ setup.release = VendorRelease;
+ /*
+ * per-server image and bitmap parameters are defined in Xmd.h
+ */
+ setup.imageByteOrder = screenInfo.imageByteOrder;
+
+ setup.bitmapScanlineUnit = screenInfo.bitmapScanlineUnit;
+ setup.bitmapScanlinePad = screenInfo.bitmapScanlinePad;
+
+ setup.bitmapBitOrder = screenInfo.bitmapBitOrder;
+ setup.motionBufferSize = NumMotionEvents();
+ setup.numRoots = screenInfo.numScreens;
+ setup.nbytesVendor = strlen(VendorString);
+ setup.numFormats = screenInfo.numPixmapFormats;
+ setup.maxRequestSize = MAX_REQUEST_SIZE;
+ QueryMinMaxKeyCodes(&setup.minKeyCode, &setup.maxKeyCode);
+
+ lenofblock = sizeof(xConnSetup) +
+ ((setup.nbytesVendor + 3) & ~3) +
+ (setup.numFormats * sizeof(xPixmapFormat)) +
+ (setup.numRoots * sizeof(xWindowRoot));
+ ConnectionInfo = (char *) xalloc(lenofblock);
+ if (!ConnectionInfo)
+ return FALSE;
+
+ memmove(ConnectionInfo, (char *)&setup, sizeof(xConnSetup));
+ sizesofar = sizeof(xConnSetup);
+ pBuf = ConnectionInfo + sizeof(xConnSetup);
+
+ memmove(pBuf, VendorString, (int)setup.nbytesVendor);
+ sizesofar += setup.nbytesVendor;
+ pBuf += setup.nbytesVendor;
+ i = padlength[setup.nbytesVendor & 3];
+ sizesofar += i;
+ while (--i >= 0)
+ *pBuf++ = 0;
+
+ for (i=0; i<screenInfo.numPixmapFormats; i++)
+ {
+ format.depth = screenInfo.formats[i].depth;
+ format.bitsPerPixel = screenInfo.formats[i].bitsPerPixel;
+ format.scanLinePad = screenInfo.formats[i].scanlinePad;
+ memmove(pBuf, (char *)&format, sizeof(xPixmapFormat));
+ pBuf += sizeof(xPixmapFormat);
+ sizesofar += sizeof(xPixmapFormat);
+ }
+
+ connBlockScreenStart = sizesofar;
+ for (i=0; i<screenInfo.numScreens; i++)
+ {
+ ScreenPtr pScreen;
+ DepthPtr pDepth;
+ VisualPtr pVisual;
+
+ pScreen = screenInfo.screens[i];
+ root.windowId = WindowTable[i]->drawable.id;
+ root.defaultColormap = pScreen->defColormap;
+ root.whitePixel = pScreen->whitePixel;
+ root.blackPixel = pScreen->blackPixel;
+ root.currentInputMask = 0; /* filled in when sent */
+ root.pixWidth = pScreen->width;
+ root.pixHeight = pScreen->height;
+ root.mmWidth = pScreen->mmWidth;
+ root.mmHeight = pScreen->mmHeight;
+ root.minInstalledMaps = pScreen->minInstalledCmaps;
+ root.maxInstalledMaps = pScreen->maxInstalledCmaps;
+ root.rootVisualID = pScreen->rootVisual;
+ root.backingStore = pScreen->backingStoreSupport;
+ root.saveUnders = pScreen->saveUnderSupport != NotUseful;
+ root.rootDepth = pScreen->rootDepth;
+ root.nDepths = pScreen->numDepths;
+ memmove(pBuf, (char *)&root, sizeof(xWindowRoot));
+ sizesofar += sizeof(xWindowRoot);
+ pBuf += sizeof(xWindowRoot);
+
+ pDepth = pScreen->allowedDepths;
+ for(j = 0; j < pScreen->numDepths; j++, pDepth++)
+ {
+ lenofblock += sizeof(xDepth) +
+ (pDepth->numVids * sizeof(xVisualType));
+ pBuf = (char *)xrealloc(ConnectionInfo, lenofblock);
+ if (!pBuf)
+ {
+ xfree(ConnectionInfo);
+ return FALSE;
+ }
+ ConnectionInfo = pBuf;
+ pBuf += sizesofar;
+ depth.depth = pDepth->depth;
+ depth.nVisuals = pDepth->numVids;
+ memmove(pBuf, (char *)&depth, sizeof(xDepth));
+ pBuf += sizeof(xDepth);
+ sizesofar += sizeof(xDepth);
+ for(k = 0; k < pDepth->numVids; k++)
+ {
+ vid = pDepth->vids[k];
+ for (pVisual = pScreen->visuals;
+ pVisual->vid != vid;
+ pVisual++)
+ ;
+ visual.visualID = vid;
+ visual.class = pVisual->class;
+ visual.bitsPerRGB = pVisual->bitsPerRGBValue;
+ visual.colormapEntries = pVisual->ColormapEntries;
+ visual.redMask = pVisual->redMask;
+ visual.greenMask = pVisual->greenMask;
+ visual.blueMask = pVisual->blueMask;
+ memmove(pBuf, (char *)&visual, sizeof(xVisualType));
+ pBuf += sizeof(xVisualType);
+ sizesofar += sizeof(xVisualType);
+ }
+ }
+ }
+ connSetupPrefix.success = xTrue;
+ connSetupPrefix.length = lenofblock/4;
+ connSetupPrefix.majorVersion = X_PROTOCOL;
+ connSetupPrefix.minorVersion = X_PROTOCOL_REVISION;
+ return TRUE;
+}
+
+/*
+ grow the array of screenRecs if necessary.
+ call the device-supplied initialization procedure
+with its screen number, a pointer to its ScreenRec, argc, and argv.
+ return the number of successfully installed screens.
+
+*/
+
+int
+AddScreen(
+ Bool (* pfnInit)(
+ int /*index*/,
+ ScreenPtr /*pScreen*/,
+ int /*argc*/,
+ char ** /*argv*/
+ ),
+ int argc,
+ char **argv)
+{
+
+ int i;
+ int scanlinepad, format, depth, bitsPerPixel, j, k;
+ ScreenPtr pScreen;
+#ifdef DEBUG
+ void (**jNI) ();
+#endif /* DEBUG */
+
+ i = screenInfo.numScreens;
+ if (i == MAXSCREENS)
+ return -1;
+
+ pScreen = (ScreenPtr) xcalloc(1, sizeof(ScreenRec));
+ if (!pScreen)
+ return -1;
+
+ pScreen->devPrivates = (DevUnion *)xcalloc(sizeof(DevUnion),
+ screenPrivateCount);
+ if (!pScreen->devPrivates && screenPrivateCount)
+ {
+ xfree(pScreen);
+ return -1;
+ }
+ pScreen->myNum = i;
+ pScreen->WindowPrivateLen = 0;
+ pScreen->WindowPrivateSizes = (unsigned *)NULL;
+ pScreen->totalWindowSize =
+ ((sizeof(WindowRec) + sizeof(long) - 1) / sizeof(long)) * sizeof(long);
+ pScreen->GCPrivateLen = 0;
+ pScreen->GCPrivateSizes = (unsigned *)NULL;
+ pScreen->totalGCSize =
+ ((sizeof(GC) + sizeof(long) - 1) / sizeof(long)) * sizeof(long);
+#ifdef PIXPRIV
+ pScreen->PixmapPrivateLen = 0;
+ pScreen->PixmapPrivateSizes = (unsigned *)NULL;
+ pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8);
+#endif
+ pScreen->ClipNotify = 0; /* for R4 ddx compatibility */
+ pScreen->CreateScreenResources = 0;
+
+#ifdef DEBUG
+ for (jNI = &pScreen->QueryBestSize;
+ jNI < (void (**) ()) &pScreen->SendGraphicsExpose;
+ jNI++)
+ *jNI = NotImplemented;
+#endif /* DEBUG */
+
+ /*
+ * This loop gets run once for every Screen that gets added,
+ * but thats ok. If the ddx layer initializes the formats
+ * one at a time calling AddScreen() after each, then each
+ * iteration will make it a little more accurate. Worst case
+ * we do this loop N * numPixmapFormats where N is # of screens.
+ * Anyway, this must be called after InitOutput and before the
+ * screen init routine is called.
+ */
+ for (format=0; format<screenInfo.numPixmapFormats; format++)
+ {
+ depth = screenInfo.formats[format].depth;
+ bitsPerPixel = screenInfo.formats[format].bitsPerPixel;
+ scanlinepad = screenInfo.formats[format].scanlinePad;
+ j = indexForBitsPerPixel[ bitsPerPixel ];
+ k = indexForScanlinePad[ scanlinepad ];
+ PixmapWidthPaddingInfo[ depth ].padPixelsLog2 = answer[j][k];
+ PixmapWidthPaddingInfo[ depth ].padRoundUp =
+ (scanlinepad/bitsPerPixel) - 1;
+ j = indexForBitsPerPixel[ 8 ]; /* bits per byte */
+ PixmapWidthPaddingInfo[ depth ].padBytesLog2 = answer[j][k];
+ PixmapWidthPaddingInfo[ depth ].bitsPerPixel = bitsPerPixel;
+ if (answerBytesPerPixel[bitsPerPixel])
+ {
+ PixmapWidthPaddingInfo[ depth ].notPower2 = 1;
+ PixmapWidthPaddingInfo[ depth ].bytesPerPixel =
+ answerBytesPerPixel[bitsPerPixel];
+ }
+ else
+ {
+ PixmapWidthPaddingInfo[ depth ].notPower2 = 0;
+ }
+ }
+
+ /* This is where screen specific stuff gets initialized. Load the
+ screen structure, call the hardware, whatever.
+ This is also where the default colormap should be allocated and
+ also pixel values for blackPixel, whitePixel, and the cursor
+ Note that InitScreen is NOT allowed to modify argc, argv, or
+ any of the strings pointed to by argv. They may be passed to
+ multiple screens.
+ */
+ pScreen->rgf = ~0L; /* there are no scratch GCs yet*/
+ WindowTable[i] = NullWindow;
+ screenInfo.screens[i] = pScreen;
+ screenInfo.numScreens++;
+ if (!(*pfnInit)(i, pScreen, argc, argv))
+ {
+ FreeScreen(pScreen);
+ screenInfo.numScreens--;
+ return -1;
+ }
+ return i;
+}
+
+static void
+FreeScreen(ScreenPtr pScreen)
+{
+ xfree(pScreen->WindowPrivateSizes);
+ xfree(pScreen->GCPrivateSizes);
+#ifdef PIXPRIV
+ xfree(pScreen->PixmapPrivateSizes);
+#endif
+ xfree(pScreen->devPrivates);
+ xfree(pScreen);
+}
diff --git a/nx-X11/programs/Xserver/dix/pixmap.c b/nx-X11/programs/Xserver/dix/pixmap.c
new file mode 100644
index 000000000..4be7d03ce
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/pixmap.c
@@ -0,0 +1,152 @@
+/* $Xorg: pixmap.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/dix/pixmap.c,v 3.4 2001/01/17 22:36:44 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "misc.h"
+#include "os.h"
+#include "windowstr.h"
+#include "resource.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#include "site.h"
+
+
+/*
+ * Scratch pixmap management and device independent pixmap allocation
+ * function.
+ */
+
+
+/* callable by ddx */
+PixmapPtr
+GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth,
+ int bitsPerPixel, int devKind, pointer pPixData)
+{
+ PixmapPtr pPixmap = pScreen->pScratchPixmap;
+
+ if (pPixmap)
+ pScreen->pScratchPixmap = NULL;
+ else
+ /* width and height of 0 means don't allocate any pixmap data */
+ pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth);
+
+ if (pPixmap) {
+ if ((*pScreen->ModifyPixmapHeader)(pPixmap, width, height, depth,
+ bitsPerPixel, devKind, pPixData))
+ return pPixmap;
+ (*pScreen->DestroyPixmap)(pPixmap);
+ }
+ return NullPixmap;
+}
+
+
+/* callable by ddx */
+void
+FreeScratchPixmapHeader(PixmapPtr pPixmap)
+{
+ if (pPixmap)
+ {
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+
+ pPixmap->devPrivate.ptr = NULL; /* lest ddx chases bad ptr */
+ if (pScreen->pScratchPixmap)
+ (*pScreen->DestroyPixmap)(pPixmap);
+ else
+ pScreen->pScratchPixmap = pPixmap;
+ }
+}
+
+
+Bool
+CreateScratchPixmapsForScreen(int scrnum)
+{
+ /* let it be created on first use */
+ screenInfo.screens[scrnum]->pScratchPixmap = NULL;
+ return TRUE;
+}
+
+
+void
+FreeScratchPixmapsForScreen(int scrnum)
+{
+ FreeScratchPixmapHeader(screenInfo.screens[scrnum]->pScratchPixmap);
+}
+
+
+/* callable by ddx */
+PixmapPtr
+AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
+{
+ PixmapPtr pPixmap;
+#ifdef PIXPRIV
+ char *ptr;
+ DevUnion *ppriv;
+ unsigned *sizes;
+ unsigned size;
+ int i;
+
+ if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize)
+ return NullPixmap;
+
+ /*
+ * FIXME: Allocate 4 bytes at the end of each pixmap. This
+ * is a quick workaround intended to fix a problem reported
+ * by Valgrind due to fbBlt() writing just after the end of
+ * the pixmap buffer. This may be a RENDER bug.
+ */
+
+ pPixmap = (PixmapPtr)xalloc(pScreen->totalPixmapSize + pixDataSize + 4);
+ if (!pPixmap)
+ return NullPixmap;
+ ppriv = (DevUnion *)(pPixmap + 1);
+ pPixmap->devPrivates = ppriv;
+ sizes = pScreen->PixmapPrivateSizes;
+ ptr = (char *)(ppriv + pScreen->PixmapPrivateLen);
+ for (i = pScreen->PixmapPrivateLen; --i >= 0; ppriv++, sizes++)
+ {
+ if ((size = *sizes) != 0)
+ {
+ ppriv->ptr = (pointer)ptr;
+ ptr += size;
+ }
+ else
+ ppriv->ptr = (pointer)NULL;
+ }
+#else
+ pPixmap = (PixmapPtr)xalloc(sizeof(PixmapRec) + pixDataSize);
+#endif
+ return pPixmap;
+}
diff --git a/nx-X11/programs/Xserver/dix/pixmap.c.NX.original b/nx-X11/programs/Xserver/dix/pixmap.c.NX.original
new file mode 100644
index 000000000..4be7d03ce
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/pixmap.c.NX.original
@@ -0,0 +1,152 @@
+/* $Xorg: pixmap.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/dix/pixmap.c,v 3.4 2001/01/17 22:36:44 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "misc.h"
+#include "os.h"
+#include "windowstr.h"
+#include "resource.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#include "site.h"
+
+
+/*
+ * Scratch pixmap management and device independent pixmap allocation
+ * function.
+ */
+
+
+/* callable by ddx */
+PixmapPtr
+GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth,
+ int bitsPerPixel, int devKind, pointer pPixData)
+{
+ PixmapPtr pPixmap = pScreen->pScratchPixmap;
+
+ if (pPixmap)
+ pScreen->pScratchPixmap = NULL;
+ else
+ /* width and height of 0 means don't allocate any pixmap data */
+ pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth);
+
+ if (pPixmap) {
+ if ((*pScreen->ModifyPixmapHeader)(pPixmap, width, height, depth,
+ bitsPerPixel, devKind, pPixData))
+ return pPixmap;
+ (*pScreen->DestroyPixmap)(pPixmap);
+ }
+ return NullPixmap;
+}
+
+
+/* callable by ddx */
+void
+FreeScratchPixmapHeader(PixmapPtr pPixmap)
+{
+ if (pPixmap)
+ {
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+
+ pPixmap->devPrivate.ptr = NULL; /* lest ddx chases bad ptr */
+ if (pScreen->pScratchPixmap)
+ (*pScreen->DestroyPixmap)(pPixmap);
+ else
+ pScreen->pScratchPixmap = pPixmap;
+ }
+}
+
+
+Bool
+CreateScratchPixmapsForScreen(int scrnum)
+{
+ /* let it be created on first use */
+ screenInfo.screens[scrnum]->pScratchPixmap = NULL;
+ return TRUE;
+}
+
+
+void
+FreeScratchPixmapsForScreen(int scrnum)
+{
+ FreeScratchPixmapHeader(screenInfo.screens[scrnum]->pScratchPixmap);
+}
+
+
+/* callable by ddx */
+PixmapPtr
+AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
+{
+ PixmapPtr pPixmap;
+#ifdef PIXPRIV
+ char *ptr;
+ DevUnion *ppriv;
+ unsigned *sizes;
+ unsigned size;
+ int i;
+
+ if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize)
+ return NullPixmap;
+
+ /*
+ * FIXME: Allocate 4 bytes at the end of each pixmap. This
+ * is a quick workaround intended to fix a problem reported
+ * by Valgrind due to fbBlt() writing just after the end of
+ * the pixmap buffer. This may be a RENDER bug.
+ */
+
+ pPixmap = (PixmapPtr)xalloc(pScreen->totalPixmapSize + pixDataSize + 4);
+ if (!pPixmap)
+ return NullPixmap;
+ ppriv = (DevUnion *)(pPixmap + 1);
+ pPixmap->devPrivates = ppriv;
+ sizes = pScreen->PixmapPrivateSizes;
+ ptr = (char *)(ppriv + pScreen->PixmapPrivateLen);
+ for (i = pScreen->PixmapPrivateLen; --i >= 0; ppriv++, sizes++)
+ {
+ if ((size = *sizes) != 0)
+ {
+ ppriv->ptr = (pointer)ptr;
+ ptr += size;
+ }
+ else
+ ppriv->ptr = (pointer)NULL;
+ }
+#else
+ pPixmap = (PixmapPtr)xalloc(sizeof(PixmapRec) + pixDataSize);
+#endif
+ return pPixmap;
+}
diff --git a/nx-X11/programs/Xserver/dix/pixmap.c.X.original b/nx-X11/programs/Xserver/dix/pixmap.c.X.original
new file mode 100644
index 000000000..78ce2a8c6
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/pixmap.c.X.original
@@ -0,0 +1,145 @@
+/* $Xorg: pixmap.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/dix/pixmap.c,v 3.4 2001/01/17 22:36:44 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "misc.h"
+#include "os.h"
+#include "windowstr.h"
+#include "resource.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#include "site.h"
+
+
+/*
+ * Scratch pixmap management and device independent pixmap allocation
+ * function.
+ */
+
+
+/* callable by ddx */
+PixmapPtr
+GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth,
+ int bitsPerPixel, int devKind, pointer pPixData)
+{
+ PixmapPtr pPixmap = pScreen->pScratchPixmap;
+
+ if (pPixmap)
+ pScreen->pScratchPixmap = NULL;
+ else
+ /* width and height of 0 means don't allocate any pixmap data */
+ pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth);
+
+ if (pPixmap) {
+ if ((*pScreen->ModifyPixmapHeader)(pPixmap, width, height, depth,
+ bitsPerPixel, devKind, pPixData))
+ return pPixmap;
+ (*pScreen->DestroyPixmap)(pPixmap);
+ }
+ return NullPixmap;
+}
+
+
+/* callable by ddx */
+void
+FreeScratchPixmapHeader(PixmapPtr pPixmap)
+{
+ if (pPixmap)
+ {
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+
+ pPixmap->devPrivate.ptr = NULL; /* lest ddx chases bad ptr */
+ if (pScreen->pScratchPixmap)
+ (*pScreen->DestroyPixmap)(pPixmap);
+ else
+ pScreen->pScratchPixmap = pPixmap;
+ }
+}
+
+
+Bool
+CreateScratchPixmapsForScreen(int scrnum)
+{
+ /* let it be created on first use */
+ screenInfo.screens[scrnum]->pScratchPixmap = NULL;
+ return TRUE;
+}
+
+
+void
+FreeScratchPixmapsForScreen(int scrnum)
+{
+ FreeScratchPixmapHeader(screenInfo.screens[scrnum]->pScratchPixmap);
+}
+
+
+/* callable by ddx */
+PixmapPtr
+AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
+{
+ PixmapPtr pPixmap;
+#ifdef PIXPRIV
+ char *ptr;
+ DevUnion *ppriv;
+ unsigned *sizes;
+ unsigned size;
+ int i;
+
+ if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize)
+ return NullPixmap;
+
+ pPixmap = (PixmapPtr)xalloc(pScreen->totalPixmapSize + pixDataSize);
+ if (!pPixmap)
+ return NullPixmap;
+ ppriv = (DevUnion *)(pPixmap + 1);
+ pPixmap->devPrivates = ppriv;
+ sizes = pScreen->PixmapPrivateSizes;
+ ptr = (char *)(ppriv + pScreen->PixmapPrivateLen);
+ for (i = pScreen->PixmapPrivateLen; --i >= 0; ppriv++, sizes++)
+ {
+ if ((size = *sizes) != 0)
+ {
+ ppriv->ptr = (pointer)ptr;
+ ptr += size;
+ }
+ else
+ ppriv->ptr = (pointer)NULL;
+ }
+#else
+ pPixmap = (PixmapPtr)xalloc(sizeof(PixmapRec) + pixDataSize);
+#endif
+ return pPixmap;
+}
diff --git a/nx-X11/programs/Xserver/dix/privates.c b/nx-X11/programs/Xserver/dix/privates.c
new file mode 100644
index 000000000..36bbc65d1
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/privates.c
@@ -0,0 +1,401 @@
+/* $Xorg: privates.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
+/* $XdotOrg: xc/programs/Xserver/dix/privates.c,v 1.10 2005/09/05 07:40:50 daniels Exp $ */
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/dix/privates.c,v 3.7 2001/01/17 22:36:44 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "misc.h"
+#include "os.h"
+#include "windowstr.h"
+#include "resource.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "colormapst.h"
+#include "servermd.h"
+#include "site.h"
+#include "inputstr.h"
+
+/*
+ * See the Wrappers and devPrivates section in "Definition of the
+ * Porting Layer for the X v11 Sample Server" (doc/Server/ddx.tbl.ms)
+ * for information on how to use devPrivates.
+ */
+
+/*
+ * client private machinery
+ */
+
+static int clientPrivateCount;
+int clientPrivateLen;
+unsigned *clientPrivateSizes;
+unsigned totalClientSize;
+
+void
+ResetClientPrivates()
+{
+ clientPrivateCount = 0;
+ clientPrivateLen = 0;
+ xfree(clientPrivateSizes);
+ clientPrivateSizes = (unsigned *)NULL;
+ totalClientSize =
+ ((sizeof(ClientRec) + sizeof(long) - 1) / sizeof(long)) * sizeof(long);
+}
+
+int
+AllocateClientPrivateIndex()
+{
+ return clientPrivateCount++;
+}
+
+Bool
+AllocateClientPrivate(int index2, unsigned amount)
+{
+ unsigned oldamount;
+
+ /* Round up sizes for proper alignment */
+ amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
+
+ if (index2 >= clientPrivateLen)
+ {
+ unsigned *nsizes;
+ nsizes = (unsigned *)xrealloc(clientPrivateSizes,
+ (index2 + 1) * sizeof(unsigned));
+ if (!nsizes)
+ return FALSE;
+ while (clientPrivateLen <= index2)
+ {
+ nsizes[clientPrivateLen++] = 0;
+ totalClientSize += sizeof(DevUnion);
+ }
+ clientPrivateSizes = nsizes;
+ }
+ oldamount = clientPrivateSizes[index2];
+ if (amount > oldamount)
+ {
+ clientPrivateSizes[index2] = amount;
+ totalClientSize += (amount - oldamount);
+ }
+ return TRUE;
+}
+
+/*
+ * screen private machinery
+ */
+
+int screenPrivateCount;
+
+void
+ResetScreenPrivates()
+{
+ screenPrivateCount = 0;
+}
+
+/* this can be called after some screens have been created,
+ * so we have to worry about resizing existing devPrivates
+ */
+int
+AllocateScreenPrivateIndex()
+{
+ int idx;
+ int i;
+ ScreenPtr pScreen;
+ DevUnion *nprivs;
+
+ idx = screenPrivateCount++;
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ pScreen = screenInfo.screens[i];
+ nprivs = (DevUnion *)xrealloc(pScreen->devPrivates,
+ screenPrivateCount * sizeof(DevUnion));
+ if (!nprivs)
+ {
+ screenPrivateCount--;
+ return -1;
+ }
+ /* Zero the new private */
+ bzero(&nprivs[idx], sizeof(DevUnion));
+ pScreen->devPrivates = nprivs;
+ }
+ return idx;
+}
+
+
+/*
+ * window private machinery
+ */
+
+static int windowPrivateCount;
+
+void
+ResetWindowPrivates()
+{
+ windowPrivateCount = 0;
+}
+
+int
+AllocateWindowPrivateIndex()
+{
+ return windowPrivateCount++;
+}
+
+Bool
+AllocateWindowPrivate(register ScreenPtr pScreen, int index2, unsigned amount)
+{
+ unsigned oldamount;
+
+ /* Round up sizes for proper alignment */
+ amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
+
+ if (index2 >= pScreen->WindowPrivateLen)
+ {
+ unsigned *nsizes;
+ nsizes = (unsigned *)xrealloc(pScreen->WindowPrivateSizes,
+ (index2 + 1) * sizeof(unsigned));
+ if (!nsizes)
+ return FALSE;
+ while (pScreen->WindowPrivateLen <= index2)
+ {
+ nsizes[pScreen->WindowPrivateLen++] = 0;
+ pScreen->totalWindowSize += sizeof(DevUnion);
+ }
+ pScreen->WindowPrivateSizes = nsizes;
+ }
+ oldamount = pScreen->WindowPrivateSizes[index2];
+ if (amount > oldamount)
+ {
+ pScreen->WindowPrivateSizes[index2] = amount;
+ pScreen->totalWindowSize += (amount - oldamount);
+ }
+ return TRUE;
+}
+
+
+/*
+ * gc private machinery
+ */
+
+static int gcPrivateCount;
+
+void
+ResetGCPrivates()
+{
+ gcPrivateCount = 0;
+}
+
+int
+AllocateGCPrivateIndex()
+{
+ return gcPrivateCount++;
+}
+
+Bool
+AllocateGCPrivate(register ScreenPtr pScreen, int index2, unsigned amount)
+{
+ unsigned oldamount;
+
+ /* Round up sizes for proper alignment */
+ amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
+
+ if (index2 >= pScreen->GCPrivateLen)
+ {
+ unsigned *nsizes;
+ nsizes = (unsigned *)xrealloc(pScreen->GCPrivateSizes,
+ (index2 + 1) * sizeof(unsigned));
+ if (!nsizes)
+ return FALSE;
+ while (pScreen->GCPrivateLen <= index2)
+ {
+ nsizes[pScreen->GCPrivateLen++] = 0;
+ pScreen->totalGCSize += sizeof(DevUnion);
+ }
+ pScreen->GCPrivateSizes = nsizes;
+ }
+ oldamount = pScreen->GCPrivateSizes[index2];
+ if (amount > oldamount)
+ {
+ pScreen->GCPrivateSizes[index2] = amount;
+ pScreen->totalGCSize += (amount - oldamount);
+ }
+ return TRUE;
+}
+
+
+/*
+ * pixmap private machinery
+ */
+#ifdef PIXPRIV
+static int pixmapPrivateCount;
+
+void
+ResetPixmapPrivates()
+{
+ pixmapPrivateCount = 0;
+}
+
+int
+AllocatePixmapPrivateIndex()
+{
+ return pixmapPrivateCount++;
+}
+
+Bool
+AllocatePixmapPrivate(register ScreenPtr pScreen, int index2, unsigned amount)
+{
+ unsigned oldamount;
+
+ /* Round up sizes for proper alignment */
+ amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
+
+ if (index2 >= pScreen->PixmapPrivateLen)
+ {
+ unsigned *nsizes;
+ nsizes = (unsigned *)xrealloc(pScreen->PixmapPrivateSizes,
+ (index2 + 1) * sizeof(unsigned));
+ if (!nsizes)
+ return FALSE;
+ while (pScreen->PixmapPrivateLen <= index2)
+ {
+ nsizes[pScreen->PixmapPrivateLen++] = 0;
+ pScreen->totalPixmapSize += sizeof(DevUnion);
+ }
+ pScreen->PixmapPrivateSizes = nsizes;
+ }
+ oldamount = pScreen->PixmapPrivateSizes[index2];
+ if (amount > oldamount)
+ {
+ pScreen->PixmapPrivateSizes[index2] = amount;
+ pScreen->totalPixmapSize += (amount - oldamount);
+ }
+ pScreen->totalPixmapSize = BitmapBytePad(pScreen->totalPixmapSize * 8);
+ return TRUE;
+}
+#endif
+
+
+/*
+ * colormap private machinery
+ */
+
+int colormapPrivateCount;
+
+void
+ResetColormapPrivates()
+{
+ colormapPrivateCount = 0;
+}
+
+
+int
+AllocateColormapPrivateIndex (InitCmapPrivFunc initPrivFunc)
+{
+ int index;
+ int i;
+ ColormapPtr pColormap;
+ DevUnion *privs;
+
+ index = colormapPrivateCount++;
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ /*
+ * AllocateColormapPrivateIndex may be called after the
+ * default colormap has been created on each screen!
+ *
+ * We must resize the devPrivates array for the default
+ * colormap on each screen, making room for this new private.
+ * We also call the initialization function 'initPrivFunc' on
+ * the new private allocated for each default colormap.
+ */
+
+ ScreenPtr pScreen = screenInfo.screens[i];
+
+ pColormap = (ColormapPtr) LookupIDByType (
+ pScreen->defColormap, RT_COLORMAP);
+
+ if (pColormap)
+ {
+ privs = (DevUnion *) xrealloc (pColormap->devPrivates,
+ colormapPrivateCount * sizeof(DevUnion));
+ if (!privs) {
+ colormapPrivateCount--;
+ return -1;
+ }
+ bzero(&privs[index], sizeof(DevUnion));
+ pColormap->devPrivates = privs;
+ if (!(*initPrivFunc)(pColormap,index))
+ {
+ colormapPrivateCount--;
+ return -1;
+ }
+ }
+ }
+
+ return index;
+}
+
+/*
+ * device private machinery
+ */
+
+static int devicePrivateIndex = 0;
+
+int
+AllocateDevicePrivateIndex()
+{
+ return devicePrivateIndex++;
+}
+
+Bool
+AllocateDevicePrivate(DeviceIntPtr device, int index)
+{
+ if (device->nPrivates < ++index) {
+ DevUnion *nprivs = (DevUnion *) xrealloc(device->devPrivates,
+ index * sizeof(DevUnion));
+ if (!nprivs)
+ return FALSE;
+ device->devPrivates = nprivs;
+ bzero(&nprivs[device->nPrivates], sizeof(DevUnion)
+ * (index - device->nPrivates));
+ device->nPrivates = index;
+ return TRUE;
+ } else {
+ return TRUE;
+ }
+}
+
+void
+ResetDevicePrivateIndex(void)
+{
+ devicePrivateIndex = 0;
+}
diff --git a/nx-X11/programs/Xserver/dix/property.c b/nx-X11/programs/Xserver/dix/property.c
new file mode 100644
index 000000000..cabe46ecc
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/property.c
@@ -0,0 +1,729 @@
+/* $XFree86: xc/programs/Xserver/dix/property.c,v 3.12 2002/02/19 11:09:22 alanh Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: property.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include "windowstr.h"
+#include "propertyst.h"
+#include "dixstruct.h"
+#include "dispatch.h"
+#include "swaprep.h"
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+#ifdef LBX
+#include "lbxserve.h"
+#include "lbxtags.h"
+#endif
+
+#if defined(LBX) || defined(LBX_COMPAT)
+#if 0 /* no header in X11 environment, not used in X11 environment */
+int fWriteToClient(ClientPtr client, int len, char *buf)
+{
+ return WriteToClient(client, len, buf);
+}
+#endif
+#endif
+
+/*****************************************************************
+ * Property Stuff
+ *
+ * ChangeProperty, DeleteProperty, GetProperties,
+ * ListProperties
+ *
+ * Properties below to windows. A allocate slots each time
+ * a property is added. No fancy searching done.
+ *
+ *****************************************************************/
+
+#ifdef notdef
+static void
+PrintPropertys(WindowPtr pWin)
+{
+ PropertyPtr pProp;
+ register int j;
+
+ pProp = pWin->userProps;
+ while (pProp)
+ {
+ ErrorF( "%x %x\n", pProp->propertyName, pProp->type);
+ ErrorF("property format: %d\n", pProp->format);
+ ErrorF("property data: \n");
+ for (j=0; j<(pProp->format/8)*pProp->size; j++)
+ ErrorF("%c\n", pProp->data[j]);
+ pProp = pProp->next;
+ }
+}
+#endif
+
+int
+ProcRotateProperties(ClientPtr client)
+{
+ int i, j, delta;
+ REQUEST(xRotatePropertiesReq);
+ WindowPtr pWin;
+ register Atom * atoms;
+ PropertyPtr * props; /* array of pointer */
+ PropertyPtr pProp;
+ xEvent event;
+
+ REQUEST_FIXED_SIZE(xRotatePropertiesReq, stuff->nAtoms << 2);
+ UpdateCurrentTime();
+ pWin = (WindowPtr) SecurityLookupWindow(stuff->window, client,
+ SecurityWriteAccess);
+ if (!pWin)
+ return(BadWindow);
+ if (!stuff->nAtoms)
+ return(Success);
+ atoms = (Atom *) & stuff[1];
+ props = (PropertyPtr *)ALLOCATE_LOCAL(stuff->nAtoms * sizeof(PropertyPtr));
+ if (!props)
+ return(BadAlloc);
+ for (i = 0; i < stuff->nAtoms; i++)
+ {
+#ifdef XCSECURITY
+ char action = SecurityCheckPropertyAccess(client, pWin, atoms[i],
+ SecurityReadAccess|SecurityWriteAccess);
+#endif
+ if (!ValidAtom(atoms[i])
+#ifdef XCSECURITY
+ || (SecurityErrorOperation == action)
+#endif
+ )
+ {
+ DEALLOCATE_LOCAL(props);
+ client->errorValue = atoms[i];
+ return BadAtom;
+ }
+#ifdef XCSECURITY
+ if (SecurityIgnoreOperation == action)
+ {
+ DEALLOCATE_LOCAL(props);
+ return Success;
+ }
+#endif
+ for (j = i + 1; j < stuff->nAtoms; j++)
+ if (atoms[j] == atoms[i])
+ {
+ DEALLOCATE_LOCAL(props);
+ return BadMatch;
+ }
+ pProp = wUserProps (pWin);
+ while (pProp)
+ {
+ if (pProp->propertyName == atoms[i])
+ goto found;
+ pProp = pProp->next;
+ }
+ DEALLOCATE_LOCAL(props);
+ return BadMatch;
+found:
+ props[i] = pProp;
+ }
+ delta = stuff->nPositions;
+
+ /* If the rotation is a complete 360 degrees, then moving the properties
+ around and generating PropertyNotify events should be skipped. */
+
+ if ( (stuff->nAtoms != 0) && (abs(delta) % stuff->nAtoms) != 0 )
+ {
+ while (delta < 0) /* faster if abs value is small */
+ delta += stuff->nAtoms;
+ for (i = 0; i < stuff->nAtoms; i++)
+ {
+ /* Generate a PropertyNotify event for each property whose value
+ is changed in the order in which they appear in the request. */
+
+ event.u.u.type = PropertyNotify;
+ event.u.property.window = pWin->drawable.id;
+ event.u.property.state = PropertyNewValue;
+ event.u.property.atom = props[i]->propertyName;
+ event.u.property.time = currentTime.milliseconds;
+ DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
+
+ props[i]->propertyName = atoms[(i + delta) % stuff->nAtoms];
+ }
+ }
+ DEALLOCATE_LOCAL(props);
+ return Success;
+}
+
+int
+ProcChangeProperty(ClientPtr client)
+{
+ WindowPtr pWin;
+ char format, mode;
+ unsigned long len;
+ int sizeInBytes;
+ int totalSize;
+ int err;
+ REQUEST(xChangePropertyReq);
+
+ REQUEST_AT_LEAST_SIZE(xChangePropertyReq);
+ UpdateCurrentTime();
+ format = stuff->format;
+ mode = stuff->mode;
+ if ((mode != PropModeReplace) && (mode != PropModeAppend) &&
+ (mode != PropModePrepend))
+ {
+ client->errorValue = mode;
+ return BadValue;
+ }
+ if ((format != 8) && (format != 16) && (format != 32))
+ {
+ client->errorValue = format;
+ return BadValue;
+ }
+ len = stuff->nUnits;
+ if (len > ((0xffffffff - sizeof(xChangePropertyReq)) >> 2))
+ return BadLength;
+ sizeInBytes = format>>3;
+ totalSize = len * sizeInBytes;
+ REQUEST_FIXED_SIZE(xChangePropertyReq, totalSize);
+
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityWriteAccess);
+ if (!pWin)
+ return(BadWindow);
+ if (!ValidAtom(stuff->property))
+ {
+ client->errorValue = stuff->property;
+ return(BadAtom);
+ }
+ if (!ValidAtom(stuff->type))
+ {
+ client->errorValue = stuff->type;
+ return(BadAtom);
+ }
+
+#ifdef XCSECURITY
+ switch (SecurityCheckPropertyAccess(client, pWin, stuff->property,
+ SecurityWriteAccess))
+ {
+ case SecurityErrorOperation:
+ client->errorValue = stuff->property;
+ return BadAtom;
+ case SecurityIgnoreOperation:
+ return Success;
+ }
+#endif
+
+#ifdef LBX
+ err = LbxChangeWindowProperty(client, pWin, stuff->property, stuff->type,
+ (int)format, (int)mode, len, TRUE, (pointer)&stuff[1], TRUE, NULL);
+#else
+ err = ChangeWindowProperty(pWin, stuff->property, stuff->type, (int)format,
+ (int)mode, len, (pointer)&stuff[1], TRUE);
+#endif
+ if (err != Success)
+ return err;
+ else
+ return client->noClientException;
+}
+
+int
+ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format,
+ int mode, unsigned long len, pointer value,
+ Bool sendevent)
+{
+#ifdef LBX
+ return LbxChangeWindowProperty(NULL, pWin, property, type,
+ format, mode, len, TRUE, value,
+ sendevent, NULL);
+#else
+ PropertyPtr pProp;
+ xEvent event;
+ int sizeInBytes;
+ int totalSize;
+ pointer data;
+
+ sizeInBytes = format>>3;
+ totalSize = len * sizeInBytes;
+
+ /* first see if property already exists */
+
+ pProp = wUserProps (pWin);
+ while (pProp)
+ {
+ if (pProp->propertyName == property)
+ break;
+ pProp = pProp->next;
+ }
+ if (!pProp) /* just add to list */
+ {
+ if (!pWin->optional && !MakeWindowOptional (pWin))
+ return(BadAlloc);
+ pProp = (PropertyPtr)xalloc(sizeof(PropertyRec));
+ if (!pProp)
+ return(BadAlloc);
+ data = (pointer)xalloc(totalSize);
+ if (!data && len)
+ {
+ xfree(pProp);
+ return(BadAlloc);
+ }
+ pProp->propertyName = property;
+ pProp->type = type;
+ pProp->format = format;
+ pProp->data = data;
+ if (len)
+ memmove((char *)data, (char *)value, totalSize);
+ pProp->size = len;
+ pProp->next = pWin->optional->userProps;
+ pWin->optional->userProps = pProp;
+ }
+ else
+ {
+ /* To append or prepend to a property the request format and type
+ must match those of the already defined property. The
+ existing format and type are irrelevant when using the mode
+ "PropModeReplace" since they will be written over. */
+
+ if ((format != pProp->format) && (mode != PropModeReplace))
+ return(BadMatch);
+ if ((pProp->type != type) && (mode != PropModeReplace))
+ return(BadMatch);
+ if (mode == PropModeReplace)
+ {
+ if (totalSize != pProp->size * (pProp->format >> 3))
+ {
+ data = (pointer)xrealloc(pProp->data, totalSize);
+ if (!data && len)
+ return(BadAlloc);
+ pProp->data = data;
+ }
+ if (len)
+ memmove((char *)pProp->data, (char *)value, totalSize);
+ pProp->size = len;
+ pProp->type = type;
+ pProp->format = format;
+ }
+ else if (len == 0)
+ {
+ /* do nothing */
+ }
+ else if (mode == PropModeAppend)
+ {
+ data = (pointer)xrealloc(pProp->data,
+ sizeInBytes * (len + pProp->size));
+ if (!data)
+ return(BadAlloc);
+ pProp->data = data;
+ memmove(&((char *)data)[pProp->size * sizeInBytes],
+ (char *)value,
+ totalSize);
+ pProp->size += len;
+ }
+ else if (mode == PropModePrepend)
+ {
+ data = (pointer)xalloc(sizeInBytes * (len + pProp->size));
+ if (!data)
+ return(BadAlloc);
+ memmove(&((char *)data)[totalSize], (char *)pProp->data,
+ (int)(pProp->size * sizeInBytes));
+ memmove((char *)data, (char *)value, totalSize);
+ xfree(pProp->data);
+ pProp->data = data;
+ pProp->size += len;
+ }
+ }
+ if (sendevent)
+ {
+ event.u.u.type = PropertyNotify;
+ event.u.property.window = pWin->drawable.id;
+ event.u.property.state = PropertyNewValue;
+ event.u.property.atom = pProp->propertyName;
+ event.u.property.time = currentTime.milliseconds;
+ DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
+ }
+ return(Success);
+#endif
+}
+
+int
+DeleteProperty(WindowPtr pWin, Atom propName)
+{
+ PropertyPtr pProp, prevProp;
+ xEvent event;
+
+ if (!(pProp = wUserProps (pWin)))
+ return(Success);
+ prevProp = (PropertyPtr)NULL;
+ while (pProp)
+ {
+ if (pProp->propertyName == propName)
+ break;
+ prevProp = pProp;
+ pProp = pProp->next;
+ }
+ if (pProp)
+ {
+ if (prevProp == (PropertyPtr)NULL) /* takes care of head */
+ {
+ if (!(pWin->optional->userProps = pProp->next))
+ CheckWindowOptionalNeed (pWin);
+ }
+ else
+ {
+ prevProp->next = pProp->next;
+ }
+#ifdef LBX
+ if (pProp->tag_id)
+ TagDeleteTag(pProp->tag_id);
+#endif
+ event.u.u.type = PropertyNotify;
+ event.u.property.window = pWin->drawable.id;
+ event.u.property.state = PropertyDelete;
+ event.u.property.atom = pProp->propertyName;
+ event.u.property.time = currentTime.milliseconds;
+ DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
+ xfree(pProp->data);
+ xfree(pProp);
+ }
+ return(Success);
+}
+
+void
+DeleteAllWindowProperties(WindowPtr pWin)
+{
+ PropertyPtr pProp, pNextProp;
+ xEvent event;
+
+ pProp = wUserProps (pWin);
+ while (pProp)
+ {
+#ifdef LBX
+ if (pProp->tag_id)
+ TagDeleteTag(pProp->tag_id);
+#endif
+ event.u.u.type = PropertyNotify;
+ event.u.property.window = pWin->drawable.id;
+ event.u.property.state = PropertyDelete;
+ event.u.property.atom = pProp->propertyName;
+ event.u.property.time = currentTime.milliseconds;
+ DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
+ pNextProp = pProp->next;
+ xfree(pProp->data);
+ xfree(pProp);
+ pProp = pNextProp;
+ }
+}
+
+static int
+NullPropertyReply(
+ ClientPtr client,
+ ATOM propertyType,
+ int format,
+ xGetPropertyReply *reply)
+{
+ reply->nItems = 0;
+ reply->length = 0;
+ reply->bytesAfter = 0;
+ reply->propertyType = propertyType;
+ reply->format = format;
+ WriteReplyToClient(client, sizeof(xGenericReply), reply);
+ return(client->noClientException);
+}
+
+/*****************
+ * GetProperty
+ * If type Any is specified, returns the property from the specified
+ * window regardless of its type. If a type is specified, returns the
+ * property only if its type equals the specified type.
+ * If delete is True and a property is returned, the property is also
+ * deleted from the window and a PropertyNotify event is generated on the
+ * window.
+ *****************/
+
+int
+ProcGetProperty(ClientPtr client)
+{
+ PropertyPtr pProp, prevProp;
+ unsigned long n, len, ind;
+ WindowPtr pWin;
+ xGetPropertyReply reply;
+ REQUEST(xGetPropertyReq);
+
+ REQUEST_SIZE_MATCH(xGetPropertyReq);
+ if (stuff->delete)
+ UpdateCurrentTime();
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return BadWindow;
+
+ if (!ValidAtom(stuff->property))
+ {
+ client->errorValue = stuff->property;
+ return(BadAtom);
+ }
+ if ((stuff->delete != xTrue) && (stuff->delete != xFalse))
+ {
+ client->errorValue = stuff->delete;
+ return(BadValue);
+ }
+ if ((stuff->type != AnyPropertyType) && !ValidAtom(stuff->type))
+ {
+ client->errorValue = stuff->type;
+ return(BadAtom);
+ }
+
+ pProp = wUserProps (pWin);
+ prevProp = (PropertyPtr)NULL;
+ while (pProp)
+ {
+ if (pProp->propertyName == stuff->property)
+ break;
+ prevProp = pProp;
+ pProp = pProp->next;
+ }
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ if (!pProp)
+ return NullPropertyReply(client, None, 0, &reply);
+
+#ifdef XCSECURITY
+ {
+ Mask access_mode = SecurityReadAccess;
+
+ if (stuff->delete)
+ access_mode |= SecurityDestroyAccess;
+ switch(SecurityCheckPropertyAccess(client, pWin, stuff->property,
+ access_mode))
+ {
+ case SecurityErrorOperation:
+ client->errorValue = stuff->property;
+ return BadAtom;;
+ case SecurityIgnoreOperation:
+ return NullPropertyReply(client, pProp->type, pProp->format,
+ &reply);
+ }
+ }
+#endif
+ /* If the request type and actual type don't match. Return the
+ property information, but not the data. */
+
+ if (((stuff->type != pProp->type) &&
+ (stuff->type != AnyPropertyType))
+ )
+ {
+ reply.bytesAfter = pProp->size;
+ reply.format = pProp->format;
+ reply.length = 0;
+ reply.nItems = 0;
+ reply.propertyType = pProp->type;
+ WriteReplyToClient(client, sizeof(xGenericReply), &reply);
+ return(Success);
+ }
+#ifdef LBX
+ /* make sure we have the current value */
+ if (pProp->tag_id && pProp->owner_pid) {
+ LbxStallPropRequest(client, pProp);
+ return client->noClientException;
+ }
+#endif
+
+/*
+ * Return type, format, value to client
+ */
+ n = (pProp->format/8) * pProp->size; /* size (bytes) of prop */
+ ind = stuff->longOffset << 2;
+
+ /* If longOffset is invalid such that it causes "len" to
+ be negative, it's a value error. */
+
+ if (n < ind)
+ {
+ client->errorValue = stuff->longOffset;
+ return BadValue;
+ }
+
+ len = min(n - ind, 4 * stuff->longLength);
+
+ reply.bytesAfter = n - (ind + len);
+ reply.format = pProp->format;
+ reply.length = (len + 3) >> 2;
+ reply.nItems = len / (pProp->format / 8 );
+ reply.propertyType = pProp->type;
+
+ if (stuff->delete && (reply.bytesAfter == 0))
+ { /* send the event */
+ xEvent event;
+
+ event.u.u.type = PropertyNotify;
+ event.u.property.window = pWin->drawable.id;
+ event.u.property.state = PropertyDelete;
+ event.u.property.atom = pProp->propertyName;
+ event.u.property.time = currentTime.milliseconds;
+ DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
+ }
+
+ WriteReplyToClient(client, sizeof(xGenericReply), &reply);
+ if (len)
+ {
+ switch (reply.format) {
+ case 32: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap32Write; break;
+ case 16: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write; break;
+ default: client->pSwapReplyFunc = (ReplySwapPtr)WriteToClient; break;
+ }
+ WriteSwappedDataToClient(client, len,
+ (char *)pProp->data + ind);
+ }
+
+ if (stuff->delete && (reply.bytesAfter == 0))
+ { /* delete the Property */
+#ifdef LBX
+ if (pProp->tag_id)
+ TagDeleteTag(pProp->tag_id);
+#endif
+ if (prevProp == (PropertyPtr)NULL) /* takes care of head */
+ {
+ if (!(pWin->optional->userProps = pProp->next))
+ CheckWindowOptionalNeed (pWin);
+ }
+ else
+ prevProp->next = pProp->next;
+ xfree(pProp->data);
+ xfree(pProp);
+ }
+ return(client->noClientException);
+}
+
+int
+ProcListProperties(ClientPtr client)
+{
+ Atom *pAtoms = NULL, *temppAtoms;
+ xListPropertiesReply xlpr;
+ int numProps = 0;
+ WindowPtr pWin;
+ PropertyPtr pProp;
+ REQUEST(xResourceReq);
+
+ REQUEST_SIZE_MATCH(xResourceReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+
+ pProp = wUserProps (pWin);
+ while (pProp)
+ {
+ pProp = pProp->next;
+ numProps++;
+ }
+ if (numProps)
+ if(!(pAtoms = (Atom *)ALLOCATE_LOCAL(numProps * sizeof(Atom))))
+ return(BadAlloc);
+
+ xlpr.type = X_Reply;
+ xlpr.nProperties = numProps;
+ xlpr.length = (numProps * sizeof(Atom)) >> 2;
+ xlpr.sequenceNumber = client->sequence;
+ pProp = wUserProps (pWin);
+ temppAtoms = pAtoms;
+ while (pProp)
+ {
+ *temppAtoms++ = pProp->propertyName;
+ pProp = pProp->next;
+ }
+ WriteReplyToClient(client, sizeof(xGenericReply), &xlpr);
+ if (numProps)
+ {
+ client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write;
+ WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms);
+ DEALLOCATE_LOCAL(pAtoms);
+ }
+ return(client->noClientException);
+}
+
+int
+ProcDeleteProperty(register ClientPtr client)
+{
+ WindowPtr pWin;
+ REQUEST(xDeletePropertyReq);
+ int result;
+
+ REQUEST_SIZE_MATCH(xDeletePropertyReq);
+ UpdateCurrentTime();
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityWriteAccess);
+ if (!pWin)
+ return(BadWindow);
+ if (!ValidAtom(stuff->property))
+ {
+ client->errorValue = stuff->property;
+ return (BadAtom);
+ }
+
+#ifdef XCSECURITY
+ switch(SecurityCheckPropertyAccess(client, pWin, stuff->property,
+ SecurityDestroyAccess))
+ {
+ case SecurityErrorOperation:
+ client->errorValue = stuff->property;
+ return BadAtom;;
+ case SecurityIgnoreOperation:
+ return Success;
+ }
+#endif
+
+ result = DeleteProperty(pWin, stuff->property);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return(result);
+}
diff --git a/nx-X11/programs/Xserver/dix/resource.c b/nx-X11/programs/Xserver/dix/resource.c
new file mode 100644
index 000000000..e12bc7b67
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/resource.c
@@ -0,0 +1,954 @@
+/************************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* The panoramix components contained the following notice */
+/*****************************************************************
+
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+
+/* $Xorg: resource.c,v 1.5 2001/02/09 02:04:40 xorgcvs Exp $ */
+/* $XdotOrg: xc/programs/Xserver/dix/resource.c,v 1.8 2005/07/03 08:53:38 daniels Exp $ */
+/* $TOG: resource.c /main/41 1998/02/09 14:20:31 kaleb $ */
+
+/* Routines to manage various kinds of resources:
+ *
+ * CreateNewResourceType, CreateNewResourceClass, InitClientResources,
+ * FakeClientID, AddResource, FreeResource, FreeClientResources,
+ * FreeAllResources, LookupIDByType, LookupIDByClass, GetXIDRange
+ */
+
+/*
+ * A resource ID is a 32 bit quantity, the upper 2 bits of which are
+ * off-limits for client-visible resources. The next 8 bits are
+ * used as client ID, and the low 22 bits come from the client.
+ * A resource ID is "hashed" by extracting and xoring subfields
+ * (varying with the size of the hash table).
+ *
+ * It is sometimes necessary for the server to create an ID that looks
+ * like it belongs to a client. This ID, however, must not be one
+ * the client actually can create, or we have the potential for conflict.
+ * The 31st bit of the ID is reserved for the server's use for this
+ * purpose. By setting CLIENT_ID(id) to the client, the SERVER_BIT to
+ * 1, and an otherwise arbitrary ID in the low 22 bits, we can create a
+ * resource "owned" by the client.
+ */
+/* $XFree86: xc/programs/Xserver/dix/resource.c,v 3.13 2003/09/24 02:43:13 dawes Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "os.h"
+#include "resource.h"
+#include "dixstruct.h"
+#include "opaque.h"
+#include "windowstr.h"
+#include "dixfont.h"
+#include "colormap.h"
+#include "inputstr.h"
+#include "dixevents.h"
+#include "dixgrabs.h"
+#include "cursor.h"
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+#include <assert.h>
+
+static void RebuildTable(
+ int /*client*/
+);
+
+#define SERVER_MINID 32
+
+#define INITBUCKETS 64
+#define INITHASHSIZE 6
+#define MAXHASHSIZE 11
+
+typedef struct _Resource {
+ struct _Resource *next;
+ XID id;
+ RESTYPE type;
+ pointer value;
+} ResourceRec, *ResourcePtr;
+#define NullResource ((ResourcePtr)NULL)
+
+typedef struct _ClientResource {
+ ResourcePtr *resources;
+ int elements;
+ int buckets;
+ int hashsize; /* log(2)(buckets) */
+ XID fakeID;
+ XID endFakeID;
+ XID expectID;
+} ClientResourceRec;
+
+RESTYPE lastResourceType;
+static RESTYPE lastResourceClass;
+RESTYPE TypeMask;
+
+static DeleteType *DeleteFuncs = (DeleteType *)NULL;
+
+#ifdef XResExtension
+
+Atom * ResourceNames = NULL;
+
+void RegisterResourceName (RESTYPE type, char *name)
+{
+ ResourceNames[type & TypeMask] = MakeAtom(name, strlen(name), TRUE);
+}
+
+#endif
+
+RESTYPE
+CreateNewResourceType(DeleteType deleteFunc)
+{
+ RESTYPE next = lastResourceType + 1;
+ DeleteType *funcs;
+
+ if (next & lastResourceClass)
+ return 0;
+ funcs = (DeleteType *)xrealloc(DeleteFuncs,
+ (next + 1) * sizeof(DeleteType));
+ if (!funcs)
+ return 0;
+
+#ifdef XResExtension
+ {
+ Atom *newnames;
+ newnames = xrealloc(ResourceNames, (next + 1) * sizeof(Atom));
+ if(!newnames)
+ return 0;
+ ResourceNames = newnames;
+ ResourceNames[next] = 0;
+ }
+#endif
+
+ lastResourceType = next;
+ DeleteFuncs = funcs;
+ DeleteFuncs[next] = deleteFunc;
+ return next;
+}
+
+RESTYPE
+CreateNewResourceClass()
+{
+ RESTYPE next = lastResourceClass >> 1;
+
+ if (next & lastResourceType)
+ return 0;
+ lastResourceClass = next;
+ TypeMask = next - 1;
+ return next;
+}
+
+ClientResourceRec clientTable[MAXCLIENTS];
+
+/*****************
+ * InitClientResources
+ * When a new client is created, call this to allocate space
+ * in resource table
+ *****************/
+
+Bool
+InitClientResources(ClientPtr client)
+{
+ register int i, j;
+
+ if (client == serverClient)
+ {
+ lastResourceType = RT_LASTPREDEF;
+ lastResourceClass = RC_LASTPREDEF;
+ TypeMask = RC_LASTPREDEF - 1;
+ if (DeleteFuncs)
+ xfree(DeleteFuncs);
+ DeleteFuncs = (DeleteType *)xalloc((lastResourceType + 1) *
+ sizeof(DeleteType));
+ if (!DeleteFuncs)
+ return FALSE;
+ DeleteFuncs[RT_NONE & TypeMask] = (DeleteType)NoopDDA;
+ DeleteFuncs[RT_WINDOW & TypeMask] = DeleteWindow;
+ DeleteFuncs[RT_PIXMAP & TypeMask] = dixDestroyPixmap;
+ DeleteFuncs[RT_GC & TypeMask] = FreeGC;
+ DeleteFuncs[RT_FONT & TypeMask] = CloseFont;
+ DeleteFuncs[RT_CURSOR & TypeMask] = FreeCursor;
+ DeleteFuncs[RT_COLORMAP & TypeMask] = FreeColormap;
+ DeleteFuncs[RT_CMAPENTRY & TypeMask] = FreeClientPixels;
+ DeleteFuncs[RT_OTHERCLIENT & TypeMask] = OtherClientGone;
+ DeleteFuncs[RT_PASSIVEGRAB & TypeMask] = DeletePassiveGrab;
+
+#ifdef XResExtension
+ if(ResourceNames)
+ xfree(ResourceNames);
+ ResourceNames = xalloc((lastResourceType + 1) * sizeof(Atom));
+ if(!ResourceNames)
+ return FALSE;
+#endif
+ }
+ clientTable[i = client->index].resources =
+ (ResourcePtr *)xalloc(INITBUCKETS*sizeof(ResourcePtr));
+ if (!clientTable[i].resources)
+ return FALSE;
+ clientTable[i].buckets = INITBUCKETS;
+ clientTable[i].elements = 0;
+ clientTable[i].hashsize = INITHASHSIZE;
+ /* Many IDs allocated from the server client are visible to clients,
+ * so we don't use the SERVER_BIT for them, but we have to start
+ * past the magic value constants used in the protocol. For normal
+ * clients, we can start from zero, with SERVER_BIT set.
+ */
+ clientTable[i].fakeID = client->clientAsMask |
+ (client->index ? SERVER_BIT : SERVER_MINID);
+ clientTable[i].endFakeID = (clientTable[i].fakeID | RESOURCE_ID_MASK) + 1;
+ clientTable[i].expectID = client->clientAsMask;
+ for (j=0; j<INITBUCKETS; j++)
+ {
+ clientTable[i].resources[j] = NullResource;
+ }
+ return TRUE;
+}
+
+
+static int
+Hash(int client, register XID id)
+{
+ id &= RESOURCE_ID_MASK;
+ switch (clientTable[client].hashsize)
+ {
+ case 6:
+ return ((int)(0x03F & (id ^ (id>>6) ^ (id>>12))));
+ case 7:
+ return ((int)(0x07F & (id ^ (id>>7) ^ (id>>13))));
+ case 8:
+ return ((int)(0x0FF & (id ^ (id>>8) ^ (id>>16))));
+ case 9:
+ return ((int)(0x1FF & (id ^ (id>>9))));
+ case 10:
+ return ((int)(0x3FF & (id ^ (id>>10))));
+ case 11:
+ return ((int)(0x7FF & (id ^ (id>>11))));
+ }
+ return -1;
+}
+
+static XID
+AvailableID(
+ register int client,
+ register XID id,
+ register XID maxid,
+ register XID goodid)
+{
+ register ResourcePtr res;
+
+ if ((goodid >= id) && (goodid <= maxid))
+ return goodid;
+ for (; id <= maxid; id++)
+ {
+ res = clientTable[client].resources[Hash(client, id)];
+ while (res && (res->id != id))
+ res = res->next;
+ if (!res)
+ return id;
+ }
+ return 0;
+}
+
+void
+GetXIDRange(int client, Bool server, XID *minp, XID *maxp)
+{
+ register XID id, maxid;
+ register ResourcePtr *resp;
+ register ResourcePtr res;
+ register int i;
+ XID goodid;
+
+ id = (Mask)client << CLIENTOFFSET;
+ if (server)
+ id |= client ? SERVER_BIT : SERVER_MINID;
+ maxid = id | RESOURCE_ID_MASK;
+ goodid = 0;
+ for (resp = clientTable[client].resources, i = clientTable[client].buckets;
+ --i >= 0;)
+ {
+ for (res = *resp++; res; res = res->next)
+ {
+ if ((res->id < id) || (res->id > maxid))
+ continue;
+ if (((res->id - id) >= (maxid - res->id)) ?
+ (goodid = AvailableID(client, id, res->id - 1, goodid)) :
+ !(goodid = AvailableID(client, res->id + 1, maxid, goodid)))
+ maxid = res->id - 1;
+ else
+ id = res->id + 1;
+ }
+ }
+ if (id > maxid)
+ id = maxid = 0;
+ *minp = id;
+ *maxp = maxid;
+}
+
+/**
+ * GetXIDList is called by the XC-MISC extension's MiscGetXIDList function.
+ * This function tries to find count unused XIDs for the given client. It
+ * puts the IDs in the array pids and returns the number found, which should
+ * almost always be the number requested.
+ *
+ * The circumstances that lead to a call to this function are very rare.
+ * Xlib must run out of IDs while trying to generate a request that wants
+ * multiple ID's, like the Multi-buffering CreateImageBuffers request.
+ *
+ * No rocket science in the implementation; just iterate over all
+ * possible IDs for the given client and pick the first count IDs
+ * that aren't in use. A more efficient algorithm could probably be
+ * invented, but this will be used so rarely that this should suffice.
+ */
+
+unsigned int
+GetXIDList(ClientPtr pClient, unsigned count, XID *pids)
+{
+ unsigned int found = 0;
+ XID id = pClient->clientAsMask;
+ XID maxid;
+
+ maxid = id | RESOURCE_ID_MASK;
+ while ( (found < count) && (id <= maxid) )
+ {
+ if (!LookupIDByClass(id, RC_ANY))
+ {
+ pids[found++] = id;
+ }
+ id++;
+ }
+ return found;
+}
+
+/*
+ * Return the next usable fake client ID.
+ *
+ * Normally this is just the next one in line, but if we've used the last
+ * in the range, we need to find a new range of safe IDs to avoid
+ * over-running another client.
+ */
+
+XID
+FakeClientID(register int client)
+{
+ XID id, maxid;
+
+ id = clientTable[client].fakeID++;
+ if (id != clientTable[client].endFakeID)
+ return id;
+ GetXIDRange(client, TRUE, &id, &maxid);
+ if (!id) {
+ if (!client)
+ FatalError("FakeClientID: server internal ids exhausted\n");
+ MarkClientException(clients[client]);
+ id = ((Mask)client << CLIENTOFFSET) | (SERVER_BIT * 3);
+ maxid = id | RESOURCE_ID_MASK;
+ }
+ clientTable[client].fakeID = id + 1;
+ clientTable[client].endFakeID = maxid + 1;
+ return id;
+}
+
+Bool
+AddResource(XID id, RESTYPE type, pointer value)
+{
+ int client;
+ register ClientResourceRec *rrec;
+ register ResourcePtr res, *head;
+
+ client = CLIENT_ID(id);
+ rrec = &clientTable[client];
+ if (!rrec->buckets)
+ {
+ ErrorF("AddResource(%lx, %lx, %lx), client=%d \n",
+ (unsigned long)id, type, (unsigned long)value, client);
+ FatalError("client not in use\n");
+ }
+ if ((rrec->elements >= 4*rrec->buckets) &&
+ (rrec->hashsize < MAXHASHSIZE))
+ RebuildTable(client);
+ head = &rrec->resources[Hash(client, id)];
+ res = (ResourcePtr)xalloc(sizeof(ResourceRec));
+ if (!res)
+ {
+ (*DeleteFuncs[type & TypeMask])(value, id);
+ return FALSE;
+ }
+ res->next = *head;
+ res->id = id;
+ res->type = type;
+ res->value = value;
+ *head = res;
+ rrec->elements++;
+ if (!(id & SERVER_BIT) && (id >= rrec->expectID))
+ rrec->expectID = id + 1;
+ return TRUE;
+}
+
+static void
+RebuildTable(int client)
+{
+ register int j;
+ register ResourcePtr res, next;
+ ResourcePtr **tails, *resources;
+ register ResourcePtr **tptr, *rptr;
+
+ /*
+ * For now, preserve insertion order, since some ddx layers depend
+ * on resources being free in the opposite order they are added.
+ */
+
+ j = 2 * clientTable[client].buckets;
+ tails = (ResourcePtr **)ALLOCATE_LOCAL(j * sizeof(ResourcePtr *));
+ if (!tails)
+ return;
+ resources = (ResourcePtr *)xalloc(j * sizeof(ResourcePtr));
+ if (!resources)
+ {
+ DEALLOCATE_LOCAL(tails);
+ return;
+ }
+ for (rptr = resources, tptr = tails; --j >= 0; rptr++, tptr++)
+ {
+ *rptr = NullResource;
+ *tptr = rptr;
+ }
+ clientTable[client].hashsize++;
+ for (j = clientTable[client].buckets,
+ rptr = clientTable[client].resources;
+ --j >= 0;
+ rptr++)
+ {
+ for (res = *rptr; res; res = next)
+ {
+ next = res->next;
+ res->next = NullResource;
+ tptr = &tails[Hash(client, res->id)];
+ **tptr = res;
+ *tptr = &res->next;
+ }
+ }
+ DEALLOCATE_LOCAL(tails);
+ clientTable[client].buckets *= 2;
+ xfree(clientTable[client].resources);
+ clientTable[client].resources = resources;
+}
+
+void
+FreeResource(XID id, RESTYPE skipDeleteFuncType)
+{
+ int cid;
+ register ResourcePtr res;
+ register ResourcePtr *prev, *head;
+ register int *eltptr;
+ int elements;
+ Bool gotOne = FALSE;
+
+ if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets)
+ {
+ head = &clientTable[cid].resources[Hash(cid, id)];
+ eltptr = &clientTable[cid].elements;
+
+ prev = head;
+ while ( (res = *prev) )
+ {
+ if (res->id == id)
+ {
+ RESTYPE rtype = res->type;
+ *prev = res->next;
+ elements = --*eltptr;
+ if (rtype & RC_CACHED)
+ FlushClientCaches(res->id);
+ if (rtype != skipDeleteFuncType)
+ (*DeleteFuncs[rtype & TypeMask])(res->value, res->id);
+ xfree(res);
+ if (*eltptr != elements)
+ prev = head; /* prev may no longer be valid */
+ gotOne = TRUE;
+ }
+ else
+ prev = &res->next;
+ }
+ if(clients[cid] && (id == clients[cid]->lastDrawableID))
+ {
+ clients[cid]->lastDrawable = (DrawablePtr)WindowTable[0];
+ clients[cid]->lastDrawableID = WindowTable[0]->drawable.id;
+ }
+ }
+ if (!gotOne)
+ ErrorF("Freeing resource id=%lX which isn't there.\n",
+ (unsigned long)id);
+}
+
+
+void
+FreeResourceByType(XID id, RESTYPE type, Bool skipFree)
+{
+ int cid;
+ register ResourcePtr res;
+ register ResourcePtr *prev, *head;
+ if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets)
+ {
+ head = &clientTable[cid].resources[Hash(cid, id)];
+
+ prev = head;
+ while ( (res = *prev) )
+ {
+ if (res->id == id && res->type == type)
+ {
+ *prev = res->next;
+ if (type & RC_CACHED)
+ FlushClientCaches(res->id);
+ if (!skipFree)
+ (*DeleteFuncs[type & TypeMask])(res->value, res->id);
+ xfree(res);
+ break;
+ }
+ else
+ prev = &res->next;
+ }
+ if(clients[cid] && (id == clients[cid]->lastDrawableID))
+ {
+ clients[cid]->lastDrawable = (DrawablePtr)WindowTable[0];
+ clients[cid]->lastDrawableID = WindowTable[0]->drawable.id;
+ }
+ }
+}
+
+/*
+ * Change the value associated with a resource id. Caller
+ * is responsible for "doing the right thing" with the old
+ * data
+ */
+
+Bool
+ChangeResourceValue (XID id, RESTYPE rtype, pointer value)
+{
+ int cid;
+ register ResourcePtr res;
+
+ if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets)
+ {
+ res = clientTable[cid].resources[Hash(cid, id)];
+
+ for (; res; res = res->next)
+ if ((res->id == id) && (res->type == rtype))
+ {
+ if (rtype & RC_CACHED)
+ FlushClientCaches(res->id);
+ res->value = value;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/* Note: if func adds or deletes resources, then func can get called
+ * more than once for some resources. If func adds new resources,
+ * func might or might not get called for them. func cannot both
+ * add and delete an equal number of resources!
+ */
+
+void
+FindClientResourcesByType(
+ ClientPtr client,
+ RESTYPE type,
+ FindResType func,
+ pointer cdata
+){
+ register ResourcePtr *resources;
+ register ResourcePtr this, next;
+ int i, elements;
+ register int *eltptr;
+
+ if (!client)
+ client = serverClient;
+
+ resources = clientTable[client->index].resources;
+ eltptr = &clientTable[client->index].elements;
+ for (i = 0; i < clientTable[client->index].buckets; i++)
+ {
+ for (this = resources[i]; this; this = next)
+ {
+ next = this->next;
+ if (!type || this->type == type) {
+ elements = *eltptr;
+ (*func)(this->value, this->id, cdata);
+ if (*eltptr != elements)
+ next = resources[i]; /* start over */
+ }
+ }
+ }
+}
+
+void
+FindAllClientResources(
+ ClientPtr client,
+ FindAllRes func,
+ pointer cdata
+){
+ register ResourcePtr *resources;
+ register ResourcePtr this, next;
+ int i, elements;
+ register int *eltptr;
+
+ if (!client)
+ client = serverClient;
+
+ resources = clientTable[client->index].resources;
+ eltptr = &clientTable[client->index].elements;
+ for (i = 0; i < clientTable[client->index].buckets; i++)
+ {
+ for (this = resources[i]; this; this = next)
+ {
+ next = this->next;
+ elements = *eltptr;
+ (*func)(this->value, this->id, this->type, cdata);
+ if (*eltptr != elements)
+ next = resources[i]; /* start over */
+ }
+ }
+}
+
+
+pointer
+LookupClientResourceComplex(
+ ClientPtr client,
+ RESTYPE type,
+ FindComplexResType func,
+ pointer cdata
+){
+ ResourcePtr *resources;
+ ResourcePtr this;
+ int i;
+
+ if (!client)
+ client = serverClient;
+
+ resources = clientTable[client->index].resources;
+ for (i = 0; i < clientTable[client->index].buckets; i++) {
+ for (this = resources[i]; this; this = this->next) {
+ if (!type || this->type == type) {
+ if((*func)(this->value, this->id, cdata))
+ return this->value;
+ }
+ }
+ }
+ return NULL;
+}
+
+
+void
+FreeClientNeverRetainResources(ClientPtr client)
+{
+ ResourcePtr *resources;
+ ResourcePtr this;
+ ResourcePtr *prev;
+ int j;
+
+ if (!client)
+ return;
+
+ resources = clientTable[client->index].resources;
+ for (j=0; j < clientTable[client->index].buckets; j++)
+ {
+ prev = &resources[j];
+ while ( (this = *prev) )
+ {
+ RESTYPE rtype = this->type;
+ if (rtype & RC_NEVERRETAIN)
+ {
+ *prev = this->next;
+ if (rtype & RC_CACHED)
+ FlushClientCaches(this->id);
+ (*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
+ xfree(this);
+ }
+ else
+ prev = &this->next;
+ }
+ }
+}
+
+void
+FreeClientResources(ClientPtr client)
+{
+ register ResourcePtr *resources;
+ register ResourcePtr this;
+ int j;
+
+ /* This routine shouldn't be called with a null client, but just in
+ case ... */
+
+ if (!client)
+ return;
+
+ HandleSaveSet(client);
+
+ resources = clientTable[client->index].resources;
+ for (j=0; j < clientTable[client->index].buckets; j++)
+ {
+ /* It may seem silly to update the head of this resource list as
+ we delete the members, since the entire list will be deleted any way,
+ but there are some resource deletion functions "FreeClientPixels" for
+ one which do a LookupID on another resource id (a Colormap id in this
+ case), so the resource list must be kept valid up to the point that
+ it is deleted, so every time we delete a resource, we must update the
+ head, just like in FreeResource. I hope that this doesn't slow down
+ mass deletion appreciably. PRH */
+
+ ResourcePtr *head;
+
+ head = &resources[j];
+
+ for (this = *head; this; this = *head)
+ {
+ RESTYPE rtype = this->type;
+ *head = this->next;
+ if (rtype & RC_CACHED)
+ FlushClientCaches(this->id);
+ (*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
+ xfree(this);
+ }
+ }
+ xfree(clientTable[client->index].resources);
+ clientTable[client->index].resources = NULL;
+ clientTable[client->index].buckets = 0;
+}
+
+void
+FreeAllResources()
+{
+ int i;
+
+ for (i = currentMaxClients; --i >= 0; )
+ {
+ if (clientTable[i].buckets)
+ FreeClientResources(clients[i]);
+ }
+}
+
+Bool
+LegalNewID(XID id, register ClientPtr client)
+{
+
+#ifdef PANORAMIX
+ XID minid, maxid;
+
+ if (!noPanoramiXExtension) {
+ minid = client->clientAsMask | (client->index ?
+ SERVER_BIT : SERVER_MINID);
+ maxid = (clientTable[client->index].fakeID | RESOURCE_ID_MASK) + 1;
+ if ((id >= minid) && (id <= maxid))
+ return TRUE;
+ }
+#endif /* PANORAMIX */
+ return ((client->clientAsMask == (id & ~RESOURCE_ID_MASK)) &&
+ ((clientTable[client->index].expectID <= id) ||
+ !LookupIDByClass(id, RC_ANY)));
+}
+
+#ifdef XCSECURITY
+
+/* SecurityLookupIDByType and SecurityLookupIDByClass:
+ * These are the heart of the resource ID security system. They take
+ * two additional arguments compared to the old LookupID functions:
+ * the client doing the lookup, and the access mode (see resource.h).
+ * The resource is returned if it exists and the client is allowed access,
+ * else NULL is returned.
+ */
+
+pointer
+SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype, Mask mode)
+{
+ int cid;
+ register ResourcePtr res;
+ pointer retval = NULL;
+
+ assert(client == NullClient ||
+ (client->index <= currentMaxClients && clients[client->index] == client));
+ assert( (rtype & TypeMask) <= lastResourceType);
+
+ if (((cid = CLIENT_ID(id)) < MAXCLIENTS) &&
+ clientTable[cid].buckets)
+ {
+ res = clientTable[cid].resources[Hash(cid, id)];
+
+ for (; res; res = res->next)
+ if ((res->id == id) && (res->type == rtype))
+ {
+ retval = res->value;
+ break;
+ }
+ }
+ if (retval && client && client->CheckAccess)
+ retval = (* client->CheckAccess)(client, id, rtype, mode, retval);
+ return retval;
+}
+
+
+pointer
+SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes, Mask mode)
+{
+ int cid;
+ register ResourcePtr res = NULL;
+ pointer retval = NULL;
+
+ assert(client == NullClient ||
+ (client->index <= currentMaxClients && clients[client->index] == client));
+ assert (classes >= lastResourceClass);
+
+ if (((cid = CLIENT_ID(id)) < MAXCLIENTS) &&
+ clientTable[cid].buckets)
+ {
+ res = clientTable[cid].resources[Hash(cid, id)];
+
+ for (; res; res = res->next)
+ if ((res->id == id) && (res->type & classes))
+ {
+ retval = res->value;
+ break;
+ }
+ }
+ if (retval && client && client->CheckAccess)
+ retval = (* client->CheckAccess)(client, id, res->type, mode, retval);
+ return retval;
+}
+
+/* We can't replace the LookupIDByType and LookupIDByClass functions with
+ * macros because of compatibility with loadable servers.
+ */
+
+pointer
+LookupIDByType(XID id, RESTYPE rtype)
+{
+ return SecurityLookupIDByType(NullClient, id, rtype,
+ SecurityUnknownAccess);
+}
+
+pointer
+LookupIDByClass(XID id, RESTYPE classes)
+{
+ return SecurityLookupIDByClass(NullClient, id, classes,
+ SecurityUnknownAccess);
+}
+
+#else /* not XCSECURITY */
+
+/*
+ * LookupIDByType returns the object with the given id and type, else NULL.
+ */
+pointer
+LookupIDByType(XID id, RESTYPE rtype)
+{
+ int cid;
+ register ResourcePtr res;
+
+ if (((cid = CLIENT_ID(id)) < MAXCLIENTS) &&
+ clientTable[cid].buckets)
+ {
+ res = clientTable[cid].resources[Hash(cid, id)];
+
+ for (; res; res = res->next)
+ if ((res->id == id) && (res->type == rtype))
+ return res->value;
+ }
+ return (pointer)NULL;
+}
+
+/*
+ * LookupIDByClass returns the object with the given id and any one of the
+ * given classes, else NULL.
+ */
+pointer
+LookupIDByClass(XID id, RESTYPE classes)
+{
+ int cid;
+ register ResourcePtr res;
+
+ if (((cid = CLIENT_ID(id)) < MAXCLIENTS) &&
+ clientTable[cid].buckets)
+ {
+ res = clientTable[cid].resources[Hash(cid, id)];
+
+ for (; res; res = res->next)
+ if ((res->id == id) && (res->type & classes))
+ return res->value;
+ }
+ return (pointer)NULL;
+}
+
+#endif /* XCSECURITY */
diff --git a/nx-X11/programs/Xserver/dix/swaprep.c b/nx-X11/programs/Xserver/dix/swaprep.c
new file mode 100644
index 000000000..9776cd437
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/swaprep.c
@@ -0,0 +1,1309 @@
+/* $XFree86: xc/programs/Xserver/dix/swaprep.c,v 3.7 2001/12/14 19:59:33 dawes Exp $ */
+/************************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/* $Xorg: swaprep.c,v 1.4 2001/02/09 02:04:41 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include <X11/fonts/fontstruct.h>
+#include "scrnintstr.h"
+#include "swaprep.h"
+#include "globals.h"
+
+static void SwapFontInfo(xQueryFontReply *pr);
+
+#ifndef LBX
+static void SwapCharInfo(xCharInfo *pInfo);
+
+static void SwapFont(xQueryFontReply *pr, Bool hasGlyphs);
+#endif
+
+/**
+ * Thanks to Jack Palevich for testing and subsequently rewriting all this
+ *
+ * \param size size in bytes
+ */
+void
+Swap32Write(ClientPtr pClient, int size, register CARD32 *pbuf)
+{
+ register int i;
+ register char n;
+
+ size >>= 2;
+ for(i = 0; i < size; i++)
+ /* brackets are mandatory here, because "swapl" macro expands
+ to several statements */
+ {
+ swapl(&pbuf[i], n);
+ }
+ (void)WriteToClient(pClient, size << 2, (char *) pbuf);
+}
+
+/**
+ *
+ * \param size size in bytes
+ */
+void
+CopySwap32Write(ClientPtr pClient, int size, CARD32 *pbuf)
+{
+ int bufsize = size;
+ CARD32 *pbufT;
+ register CARD32 *from, *to, *fromLast, *toLast;
+ CARD32 tmpbuf[1];
+
+ /* Allocate as big a buffer as we can... */
+ while (!(pbufT = (CARD32 *) ALLOCATE_LOCAL(bufsize)))
+ {
+ bufsize >>= 1;
+ if (bufsize == 4)
+ {
+ pbufT = tmpbuf;
+ break;
+ }
+ }
+
+ /* convert lengths from # of bytes to # of longs */
+ size >>= 2;
+ bufsize >>= 2;
+
+ from = pbuf;
+ fromLast = from + size;
+ while (from < fromLast) {
+ int nbytes;
+ to = pbufT;
+ toLast = to + min (bufsize, fromLast - from);
+ nbytes = (toLast - to) << 2;
+ while (to < toLast) {
+ /* can't write "cpswapl(*from++, *to++)" because cpswapl is a macro
+ that evaulates its args more than once */
+ cpswapl(*from, *to);
+ from++;
+ to++;
+ }
+ (void)WriteToClient (pClient, nbytes, (char *) pbufT);
+ }
+
+ if (pbufT != tmpbuf)
+ DEALLOCATE_LOCAL ((char *) pbufT);
+}
+
+/**
+ *
+ * \param size size in bytes
+ */
+void
+CopySwap16Write(ClientPtr pClient, int size, short *pbuf)
+{
+ int bufsize = size;
+ short *pbufT;
+ register short *from, *to, *fromLast, *toLast;
+ short tmpbuf[2];
+
+ /* Allocate as big a buffer as we can... */
+ while (!(pbufT = (short *) ALLOCATE_LOCAL(bufsize)))
+ {
+ bufsize >>= 1;
+ if (bufsize == 4)
+ {
+ pbufT = tmpbuf;
+ break;
+ }
+ }
+
+ /* convert lengths from # of bytes to # of shorts */
+ size >>= 1;
+ bufsize >>= 1;
+
+ from = pbuf;
+ fromLast = from + size;
+ while (from < fromLast) {
+ int nbytes;
+ to = pbufT;
+ toLast = to + min (bufsize, fromLast - from);
+ nbytes = (toLast - to) << 1;
+ while (to < toLast) {
+ /* can't write "cpswaps(*from++, *to++)" because cpswaps is a macro
+ that evaulates its args more than once */
+ cpswaps(*from, *to);
+ from++;
+ to++;
+ }
+ (void)WriteToClient (pClient, nbytes, (char *) pbufT);
+ }
+
+ if (pbufT != tmpbuf)
+ DEALLOCATE_LOCAL ((char *) pbufT);
+}
+
+
+/* Extra-small reply */
+void
+SGenericReply(ClientPtr pClient, int size, xGenericReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+/* Extra-large reply */
+void
+SGetWindowAttributesReply(ClientPtr pClient, int size,
+ xGetWindowAttributesReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swapl(&pRep->visualID, n);
+ swaps(&pRep->class, n);
+ swapl(&pRep->backingBitPlanes, n);
+ swapl(&pRep->backingPixel, n);
+ swapl(&pRep->colormap, n);
+ swapl(&pRep->allEventMasks, n);
+ swapl(&pRep->yourEventMask, n);
+ swaps(&pRep->doNotPropagateMask, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetGeometryReply(ClientPtr pClient, int size, xGetGeometryReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->root, n);
+ swaps(&pRep->x, n);
+ swaps(&pRep->y, n);
+ swaps(&pRep->width, n);
+ swaps(&pRep->height, n);
+ swaps(&pRep->borderWidth, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SQueryTreeReply(ClientPtr pClient, int size, xQueryTreeReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swapl(&pRep->root, n);
+ swapl(&pRep->parent, n);
+ swaps(&pRep->nChildren, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SInternAtomReply(ClientPtr pClient, int size, xInternAtomReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->atom, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetAtomNameReply(ClientPtr pClient, int size, xGetAtomNameReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swaps(&pRep->nameLength, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+
+void
+SGetPropertyReply(ClientPtr pClient, int size, xGetPropertyReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swapl(&pRep->propertyType, n);
+ swapl(&pRep->bytesAfter, n);
+ swapl(&pRep->nItems, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SListPropertiesReply(ClientPtr pClient, int size, xListPropertiesReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swaps(&pRep->nProperties, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetSelectionOwnerReply(ClientPtr pClient, int size,
+ xGetSelectionOwnerReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->owner, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+
+void
+SQueryPointerReply(ClientPtr pClient, int size, xQueryPointerReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->root, n);
+ swapl(&pRep->child, n);
+ swaps(&pRep->rootX, n);
+ swaps(&pRep->rootY, n);
+ swaps(&pRep->winX, n);
+ swaps(&pRep->winY, n);
+ swaps(&pRep->mask, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SwapTimecoord(xTimecoord* pCoord)
+{
+ register char n;
+
+ swapl(&pCoord->time, n);
+ swaps(&pCoord->x, n);
+ swaps(&pCoord->y, n);
+}
+
+void
+SwapTimeCoordWrite(ClientPtr pClient, int size, xTimecoord *pRep)
+{
+ int i, n;
+ xTimecoord *pRepT;
+
+ n = size / sizeof(xTimecoord);
+ pRepT = pRep;
+ for(i = 0; i < n; i++)
+ {
+ SwapTimecoord(pRepT);
+ pRepT++;
+ }
+ (void)WriteToClient(pClient, size, (char *) pRep);
+
+}
+void
+SGetMotionEventsReply(ClientPtr pClient, int size, xGetMotionEventsReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swapl(&pRep->nEvents, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+STranslateCoordsReply(ClientPtr pClient, int size, xTranslateCoordsReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->child, n);
+ swaps(&pRep->dstX, n);
+ swaps(&pRep->dstY, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetInputFocusReply(ClientPtr pClient, int size, xGetInputFocusReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->focus, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+/* extra long reply */
+void
+SQueryKeymapReply(ClientPtr pClient, int size, xQueryKeymapReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+#ifndef LBX
+static
+#endif
+void
+SwapCharInfo(xCharInfo *pInfo)
+{
+ register char n;
+
+ swaps(&pInfo->leftSideBearing, n);
+ swaps(&pInfo->rightSideBearing, n);
+ swaps(&pInfo->characterWidth, n);
+ swaps(&pInfo->ascent, n);
+ swaps(&pInfo->descent, n);
+ swaps(&pInfo->attributes, n);
+}
+
+static void
+SwapFontInfo(xQueryFontReply *pr)
+{
+ register char n;
+
+ swaps(&pr->minCharOrByte2, n);
+ swaps(&pr->maxCharOrByte2, n);
+ swaps(&pr->defaultChar, n);
+ swaps(&pr->nFontProps, n);
+ swaps(&pr->fontAscent, n);
+ swaps(&pr->fontDescent, n);
+ SwapCharInfo( &pr->minBounds);
+ SwapCharInfo( &pr->maxBounds);
+ swapl(&pr->nCharInfos, n);
+}
+
+#ifndef LBX
+static
+#endif
+void
+SwapFont(xQueryFontReply *pr, Bool hasGlyphs)
+{
+ unsigned i;
+ xCharInfo * pxci;
+ unsigned nchars, nprops;
+ char *pby;
+ register char n;
+
+ swaps(&pr->sequenceNumber, n);
+ swapl(&pr->length, n);
+ nchars = pr->nCharInfos;
+ nprops = pr->nFontProps;
+ SwapFontInfo(pr);
+ pby = (char *) &pr[1];
+ /* Font properties are an atom and either an int32 or a CARD32, so
+ * they are always 2 4 byte values */
+ for(i = 0; i < nprops; i++)
+ {
+ swapl(pby, n);
+ pby += 4;
+ swapl(pby, n);
+ pby += 4;
+ }
+ if (hasGlyphs)
+ {
+ pxci = (xCharInfo *)pby;
+ for(i = 0; i< nchars; i++, pxci++)
+ SwapCharInfo(pxci);
+ }
+}
+
+void
+SQueryFontReply(ClientPtr pClient, int size, xQueryFontReply *pRep)
+{
+ SwapFont(pRep, TRUE);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SQueryTextExtentsReply(ClientPtr pClient, int size, xQueryTextExtentsReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swaps(&pRep->fontAscent, n);
+ swaps(&pRep->fontDescent, n);
+ swaps(&pRep->overallAscent, n);
+ swaps(&pRep->overallDescent, n);
+ swapl(&pRep->overallWidth, n);
+ swapl(&pRep->overallLeft, n);
+ swapl(&pRep->overallRight, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SListFontsReply(ClientPtr pClient, int size, xListFontsReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swaps(&pRep->nFonts, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SListFontsWithInfoReply(ClientPtr pClient, int size,
+ xListFontsWithInfoReply *pRep)
+{
+ SwapFont((xQueryFontReply *)pRep, FALSE);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetFontPathReply(ClientPtr pClient, int size, xGetFontPathReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swaps(&pRep->nPaths, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetImageReply(ClientPtr pClient, int size, xGetImageReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swapl(&pRep->visual, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+ /* Fortunately, image doesn't need swapping */
+}
+
+void
+SListInstalledColormapsReply(ClientPtr pClient, int size,
+ xListInstalledColormapsReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swaps(&pRep->nColormaps, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SAllocColorReply(pClient, size, pRep)
+ ClientPtr pClient;
+ int size;
+ xAllocColorReply *pRep;
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swaps(&pRep->red, n);
+ swaps(&pRep->green, n);
+ swaps(&pRep->blue, n);
+ swapl(&pRep->pixel, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SAllocNamedColorReply(ClientPtr pClient, int size, xAllocNamedColorReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->pixel, n);
+ swaps(&pRep->exactRed, n);
+ swaps(&pRep->exactGreen, n);
+ swaps(&pRep->exactBlue, n);
+ swaps(&pRep->screenRed, n);
+ swaps(&pRep->screenGreen, n);
+ swaps(&pRep->screenBlue, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SAllocColorCellsReply(ClientPtr pClient, int size, xAllocColorCellsReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swaps(&pRep->nPixels, n);
+ swaps(&pRep->nMasks, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+
+void
+SAllocColorPlanesReply(ClientPtr pClient, int size, xAllocColorPlanesReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swaps(&pRep->nPixels, n);
+ swapl(&pRep->redMask, n);
+ swapl(&pRep->greenMask, n);
+ swapl(&pRep->blueMask, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SwapRGB(xrgb *prgb)
+{
+ register char n;
+
+ swaps(&prgb->red, n);
+ swaps(&prgb->green, n);
+ swaps(&prgb->blue, n);
+}
+
+void
+SQColorsExtend(ClientPtr pClient, int size, xrgb *prgb)
+{
+ int i, n;
+ xrgb *prgbT;
+
+ n = size / sizeof(xrgb);
+ prgbT = prgb;
+ for(i = 0; i < n; i++)
+ {
+ SwapRGB(prgbT);
+ prgbT++;
+ }
+ (void)WriteToClient(pClient, size, (char *) prgb);
+}
+
+void
+SQueryColorsReply(ClientPtr pClient, int size, xQueryColorsReply* pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swaps(&pRep->nColors, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SLookupColorReply(ClientPtr pClient, int size, xLookupColorReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swaps(&pRep->exactRed, n);
+ swaps(&pRep->exactGreen, n);
+ swaps(&pRep->exactBlue, n);
+ swaps(&pRep->screenRed, n);
+ swaps(&pRep->screenGreen, n);
+ swaps(&pRep->screenBlue, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SQueryBestSizeReply(ClientPtr pClient, int size, xQueryBestSizeReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swaps(&pRep->width, n);
+ swaps(&pRep->height, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SListExtensionsReply(ClientPtr pClient, int size, xListExtensionsReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetKeyboardMappingReply(ClientPtr pClient, int size,
+ xGetKeyboardMappingReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetPointerMappingReply(ClientPtr pClient, int size,
+ xGetPointerMappingReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetModifierMappingReply(ClientPtr pClient, int size,
+ xGetModifierMappingReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetKeyboardControlReply(ClientPtr pClient, int size, xGetKeyboardControlReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swapl(&pRep->ledMask, n);
+ swaps(&pRep->bellPitch, n);
+ swaps(&pRep->bellDuration, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetPointerControlReply(ClientPtr pClient, int size, xGetPointerControlReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swaps(&pRep->accelNumerator, n);
+ swaps(&pRep->accelDenominator, n);
+ swaps(&pRep->threshold, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetScreenSaverReply(ClientPtr pClient, int size, xGetScreenSaverReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swaps(&pRep->timeout, n);
+ swaps(&pRep->interval, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SLHostsExtend(ClientPtr pClient, int size, char *buf)
+{
+ char *bufT = buf;
+ char *endbuf = buf + size;
+ while (bufT < endbuf) {
+ xHostEntry *host = (xHostEntry *) bufT;
+ int len = host->length;
+ register char n;
+ swaps (&host->length, n);
+ bufT += sizeof (xHostEntry) + (((len + 3) >> 2) << 2);
+ }
+ (void)WriteToClient (pClient, size, buf);
+}
+
+void
+SListHostsReply(ClientPtr pClient, int size, xListHostsReply *pRep)
+{
+ register char n;
+
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swaps(&pRep->nHosts, n);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+
+
+void
+SErrorEvent(xError *from, xError *to)
+{
+ to->type = X_Error;
+ to->errorCode = from->errorCode;
+ cpswaps(from->sequenceNumber, to->sequenceNumber);
+ cpswapl(from->resourceID, to->resourceID);
+ cpswaps(from->minorCode, to->minorCode);
+ to->majorCode = from->majorCode;
+}
+
+void
+SKeyButtonPtrEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ to->u.u.detail = from->u.u.detail;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.keyButtonPointer.time,
+ to->u.keyButtonPointer.time);
+ cpswapl(from->u.keyButtonPointer.root,
+ to->u.keyButtonPointer.root);
+ cpswapl(from->u.keyButtonPointer.event,
+ to->u.keyButtonPointer.event);
+ cpswapl(from->u.keyButtonPointer.child,
+ to->u.keyButtonPointer.child);
+ cpswaps(from->u.keyButtonPointer.rootX,
+ to->u.keyButtonPointer.rootX);
+ cpswaps(from->u.keyButtonPointer.rootY,
+ to->u.keyButtonPointer.rootY);
+ cpswaps(from->u.keyButtonPointer.eventX,
+ to->u.keyButtonPointer.eventX);
+ cpswaps(from->u.keyButtonPointer.eventY,
+ to->u.keyButtonPointer.eventY);
+ cpswaps(from->u.keyButtonPointer.state,
+ to->u.keyButtonPointer.state);
+ to->u.keyButtonPointer.sameScreen =
+ from->u.keyButtonPointer.sameScreen;
+}
+
+void
+SEnterLeaveEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ to->u.u.detail = from->u.u.detail;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.enterLeave.time, to->u.enterLeave.time);
+ cpswapl(from->u.enterLeave.root, to->u.enterLeave.root);
+ cpswapl(from->u.enterLeave.event, to->u.enterLeave.event);
+ cpswapl(from->u.enterLeave.child, to->u.enterLeave.child);
+ cpswaps(from->u.enterLeave.rootX, to->u.enterLeave.rootX);
+ cpswaps(from->u.enterLeave.rootY, to->u.enterLeave.rootY);
+ cpswaps(from->u.enterLeave.eventX, to->u.enterLeave.eventX);
+ cpswaps(from->u.enterLeave.eventY, to->u.enterLeave.eventY);
+ cpswaps(from->u.enterLeave.state, to->u.enterLeave.state);
+ to->u.enterLeave.mode = from->u.enterLeave.mode;
+ to->u.enterLeave.flags = from->u.enterLeave.flags;
+}
+
+void
+SFocusEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ to->u.u.detail = from->u.u.detail;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.focus.window, to->u.focus.window);
+ to->u.focus.mode = from->u.focus.mode;
+}
+
+void
+SExposeEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.expose.window, to->u.expose.window);
+ cpswaps(from->u.expose.x, to->u.expose.x);
+ cpswaps(from->u.expose.y, to->u.expose.y);
+ cpswaps(from->u.expose.width, to->u.expose.width);
+ cpswaps(from->u.expose.height, to->u.expose.height);
+ cpswaps(from->u.expose.count, to->u.expose.count);
+}
+
+void
+SGraphicsExposureEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.graphicsExposure.drawable,
+ to->u.graphicsExposure.drawable);
+ cpswaps(from->u.graphicsExposure.x,
+ to->u.graphicsExposure.x);
+ cpswaps(from->u.graphicsExposure.y,
+ to->u.graphicsExposure.y);
+ cpswaps(from->u.graphicsExposure.width,
+ to->u.graphicsExposure.width);
+ cpswaps(from->u.graphicsExposure.height,
+ to->u.graphicsExposure.height);
+ cpswaps(from->u.graphicsExposure.minorEvent,
+ to->u.graphicsExposure.minorEvent);
+ cpswaps(from->u.graphicsExposure.count,
+ to->u.graphicsExposure.count);
+ to->u.graphicsExposure.majorEvent =
+ from->u.graphicsExposure.majorEvent;
+}
+
+void
+SNoExposureEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.noExposure.drawable, to->u.noExposure.drawable);
+ cpswaps(from->u.noExposure.minorEvent, to->u.noExposure.minorEvent);
+ to->u.noExposure.majorEvent = from->u.noExposure.majorEvent;
+}
+
+void
+SVisibilityEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.visibility.window, to->u.visibility.window);
+ to->u.visibility.state = from->u.visibility.state;
+}
+
+void
+SCreateNotifyEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.createNotify.window, to->u.createNotify.window);
+ cpswapl(from->u.createNotify.parent, to->u.createNotify.parent);
+ cpswaps(from->u.createNotify.x, to->u.createNotify.x);
+ cpswaps(from->u.createNotify.y, to->u.createNotify.y);
+ cpswaps(from->u.createNotify.width, to->u.createNotify.width);
+ cpswaps(from->u.createNotify.height, to->u.createNotify.height);
+ cpswaps(from->u.createNotify.borderWidth,
+ to->u.createNotify.borderWidth);
+ to->u.createNotify.override = from->u.createNotify.override;
+}
+
+void
+SDestroyNotifyEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.destroyNotify.event, to->u.destroyNotify.event);
+ cpswapl(from->u.destroyNotify.window, to->u.destroyNotify.window);
+}
+
+void
+SUnmapNotifyEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.unmapNotify.event, to->u.unmapNotify.event);
+ cpswapl(from->u.unmapNotify.window, to->u.unmapNotify.window);
+ to->u.unmapNotify.fromConfigure = from->u.unmapNotify.fromConfigure;
+}
+
+void
+SMapNotifyEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.mapNotify.event, to->u.mapNotify.event);
+ cpswapl(from->u.mapNotify.window, to->u.mapNotify.window);
+ to->u.mapNotify.override = from->u.mapNotify.override;
+}
+
+void
+SMapRequestEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.mapRequest.parent, to->u.mapRequest.parent);
+ cpswapl(from->u.mapRequest.window, to->u.mapRequest.window);
+}
+
+void
+SReparentEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.reparent.event, to->u.reparent.event);
+ cpswapl(from->u.reparent.window, to->u.reparent.window);
+ cpswapl(from->u.reparent.parent, to->u.reparent.parent);
+ cpswaps(from->u.reparent.x, to->u.reparent.x);
+ cpswaps(from->u.reparent.y, to->u.reparent.y);
+ to->u.reparent.override = from->u.reparent.override;
+}
+
+void
+SConfigureNotifyEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.configureNotify.event,
+ to->u.configureNotify.event);
+ cpswapl(from->u.configureNotify.window,
+ to->u.configureNotify.window);
+ cpswapl(from->u.configureNotify.aboveSibling,
+ to->u.configureNotify.aboveSibling);
+ cpswaps(from->u.configureNotify.x, to->u.configureNotify.x);
+ cpswaps(from->u.configureNotify.y, to->u.configureNotify.y);
+ cpswaps(from->u.configureNotify.width, to->u.configureNotify.width);
+ cpswaps(from->u.configureNotify.height,
+ to->u.configureNotify.height);
+ cpswaps(from->u.configureNotify.borderWidth,
+ to->u.configureNotify.borderWidth);
+ to->u.configureNotify.override = from->u.configureNotify.override;
+}
+
+void
+SConfigureRequestEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ to->u.u.detail = from->u.u.detail; /* actually stack-mode */
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.configureRequest.parent,
+ to->u.configureRequest.parent);
+ cpswapl(from->u.configureRequest.window,
+ to->u.configureRequest.window);
+ cpswapl(from->u.configureRequest.sibling,
+ to->u.configureRequest.sibling);
+ cpswaps(from->u.configureRequest.x, to->u.configureRequest.x);
+ cpswaps(from->u.configureRequest.y, to->u.configureRequest.y);
+ cpswaps(from->u.configureRequest.width,
+ to->u.configureRequest.width);
+ cpswaps(from->u.configureRequest.height,
+ to->u.configureRequest.height);
+ cpswaps(from->u.configureRequest.borderWidth,
+ to->u.configureRequest.borderWidth);
+ cpswaps(from->u.configureRequest.valueMask,
+ to->u.configureRequest.valueMask);
+}
+
+
+void
+SGravityEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.gravity.event, to->u.gravity.event);
+ cpswapl(from->u.gravity.window, to->u.gravity.window);
+ cpswaps(from->u.gravity.x, to->u.gravity.x);
+ cpswaps(from->u.gravity.y, to->u.gravity.y);
+}
+
+void
+SResizeRequestEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.resizeRequest.window, to->u.resizeRequest.window);
+ cpswaps(from->u.resizeRequest.width, to->u.resizeRequest.width);
+ cpswaps(from->u.resizeRequest.height, to->u.resizeRequest.height);
+}
+
+void
+SCirculateEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ to->u.u.detail = from->u.u.detail;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.circulate.event, to->u.circulate.event);
+ cpswapl(from->u.circulate.window, to->u.circulate.window);
+ cpswapl(from->u.circulate.parent, to->u.circulate.parent);
+ to->u.circulate.place = from->u.circulate.place;
+}
+
+void
+SPropertyEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.property.window, to->u.property.window);
+ cpswapl(from->u.property.atom, to->u.property.atom);
+ cpswapl(from->u.property.time, to->u.property.time);
+ to->u.property.state = from->u.property.state;
+}
+
+void
+SSelectionClearEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.selectionClear.time, to->u.selectionClear.time);
+ cpswapl(from->u.selectionClear.window, to->u.selectionClear.window);
+ cpswapl(from->u.selectionClear.atom, to->u.selectionClear.atom);
+}
+
+void
+SSelectionRequestEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.selectionRequest.time, to->u.selectionRequest.time);
+ cpswapl(from->u.selectionRequest.owner,
+ to->u.selectionRequest.owner);
+ cpswapl(from->u.selectionRequest.requestor,
+ to->u.selectionRequest.requestor);
+ cpswapl(from->u.selectionRequest.selection,
+ to->u.selectionRequest.selection);
+ cpswapl(from->u.selectionRequest.target,
+ to->u.selectionRequest.target);
+ cpswapl(from->u.selectionRequest.property,
+ to->u.selectionRequest.property);
+}
+
+void
+SSelectionNotifyEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.selectionNotify.time, to->u.selectionNotify.time);
+ cpswapl(from->u.selectionNotify.requestor,
+ to->u.selectionNotify.requestor);
+ cpswapl(from->u.selectionNotify.selection,
+ to->u.selectionNotify.selection);
+ cpswapl(from->u.selectionNotify.target,
+ to->u.selectionNotify.target);
+ cpswapl(from->u.selectionNotify.property,
+ to->u.selectionNotify.property);
+}
+
+void
+SColormapEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.colormap.window, to->u.colormap.window);
+ cpswapl(from->u.colormap.colormap, to->u.colormap.colormap);
+ to->u.colormap.new = from->u.colormap.new;
+ to->u.colormap.state = from->u.colormap.state;
+}
+
+void
+SMappingEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ to->u.mappingNotify.request = from->u.mappingNotify.request;
+ to->u.mappingNotify.firstKeyCode =
+ from->u.mappingNotify.firstKeyCode;
+ to->u.mappingNotify.count = from->u.mappingNotify.count;
+}
+
+void
+SClientMessageEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ to->u.u.detail = from->u.u.detail; /* actually format */
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.clientMessage.window, to->u.clientMessage.window);
+ cpswapl(from->u.clientMessage.u.l.type,
+ to->u.clientMessage.u.l.type);
+ switch (from->u.u.detail) {
+ case 8:
+ memmove(to->u.clientMessage.u.b.bytes,
+ from->u.clientMessage.u.b.bytes,20);
+ break;
+ case 16:
+ cpswaps(from->u.clientMessage.u.s.shorts0,
+ to->u.clientMessage.u.s.shorts0);
+ cpswaps(from->u.clientMessage.u.s.shorts1,
+ to->u.clientMessage.u.s.shorts1);
+ cpswaps(from->u.clientMessage.u.s.shorts2,
+ to->u.clientMessage.u.s.shorts2);
+ cpswaps(from->u.clientMessage.u.s.shorts3,
+ to->u.clientMessage.u.s.shorts3);
+ cpswaps(from->u.clientMessage.u.s.shorts4,
+ to->u.clientMessage.u.s.shorts4);
+ cpswaps(from->u.clientMessage.u.s.shorts5,
+ to->u.clientMessage.u.s.shorts5);
+ cpswaps(from->u.clientMessage.u.s.shorts6,
+ to->u.clientMessage.u.s.shorts6);
+ cpswaps(from->u.clientMessage.u.s.shorts7,
+ to->u.clientMessage.u.s.shorts7);
+ cpswaps(from->u.clientMessage.u.s.shorts8,
+ to->u.clientMessage.u.s.shorts8);
+ cpswaps(from->u.clientMessage.u.s.shorts9,
+ to->u.clientMessage.u.s.shorts9);
+ break;
+ case 32:
+ cpswapl(from->u.clientMessage.u.l.longs0,
+ to->u.clientMessage.u.l.longs0);
+ cpswapl(from->u.clientMessage.u.l.longs1,
+ to->u.clientMessage.u.l.longs1);
+ cpswapl(from->u.clientMessage.u.l.longs2,
+ to->u.clientMessage.u.l.longs2);
+ cpswapl(from->u.clientMessage.u.l.longs3,
+ to->u.clientMessage.u.l.longs3);
+ cpswapl(from->u.clientMessage.u.l.longs4,
+ to->u.clientMessage.u.l.longs4);
+ break;
+ }
+}
+
+void
+SKeymapNotifyEvent(xEvent *from, xEvent *to)
+{
+ /* Keymap notify events are special; they have no
+ sequence number field, and contain entirely 8-bit data */
+ *to = *from;
+}
+
+void
+SwapConnSetupInfo(
+ char *pInfo,
+ char *pInfoT
+)
+{
+ int i, j, k;
+ xConnSetup *pConnSetup = (xConnSetup *)pInfo;
+ xDepth *depth;
+ xWindowRoot *root;
+
+ SwapConnSetup(pConnSetup, (xConnSetup *)pInfoT);
+ pInfo += sizeof(xConnSetup);
+ pInfoT += sizeof(xConnSetup);
+
+ /* Copy the vendor string */
+ i = (pConnSetup->nbytesVendor + 3) & ~3;
+ memcpy(pInfoT, pInfo, i);
+ pInfo += i;
+ pInfoT += i;
+
+ /* The Pixmap formats don't need to be swapped, just copied. */
+ i = sizeof(xPixmapFormat) * pConnSetup->numFormats;
+ memcpy(pInfoT, pInfo, i);
+ pInfo += i;
+ pInfoT += i;
+
+ for(i = 0; i < pConnSetup->numRoots; i++)
+ {
+ root = (xWindowRoot*)pInfo;
+ SwapWinRoot(root, (xWindowRoot *)pInfoT);
+ pInfo += sizeof(xWindowRoot);
+ pInfoT += sizeof(xWindowRoot);
+
+ for(j = 0; j < root->nDepths; j++)
+ {
+ depth = (xDepth*)pInfo;
+ ((xDepth *)pInfoT)->depth = depth->depth;
+ cpswaps(depth->nVisuals, ((xDepth *)pInfoT)->nVisuals);
+ pInfo += sizeof(xDepth);
+ pInfoT += sizeof(xDepth);
+ for(k = 0; k < depth->nVisuals; k++)
+ {
+ SwapVisual((xVisualType *)pInfo, (xVisualType *)pInfoT);
+ pInfo += sizeof(xVisualType);
+ pInfoT += sizeof(xVisualType);
+ }
+ }
+ }
+}
+
+
+void
+WriteSConnectionInfo(ClientPtr pClient, unsigned long size, char *pInfo)
+{
+ char *pInfoTBase;
+
+ pInfoTBase = (char *) ALLOCATE_LOCAL(size);
+ if (!pInfoTBase)
+ {
+ pClient->noClientException = -1;
+ return;
+ }
+ SwapConnSetupInfo(pInfo, pInfoTBase);
+ (void)WriteToClient(pClient, (int)size, (char *) pInfoTBase);
+ DEALLOCATE_LOCAL(pInfoTBase);
+}
+
+void
+SwapConnSetup(xConnSetup *pConnSetup, xConnSetup *pConnSetupT)
+{
+ cpswapl(pConnSetup->release, pConnSetupT->release);
+ cpswapl(pConnSetup->ridBase, pConnSetupT->ridBase);
+ cpswapl(pConnSetup->ridMask, pConnSetupT->ridMask);
+ cpswapl(pConnSetup->motionBufferSize, pConnSetupT->motionBufferSize);
+ cpswaps(pConnSetup->nbytesVendor, pConnSetupT->nbytesVendor);
+ cpswaps(pConnSetup->maxRequestSize, pConnSetupT->maxRequestSize);
+ pConnSetupT->minKeyCode = pConnSetup->minKeyCode;
+ pConnSetupT->maxKeyCode = pConnSetup->maxKeyCode;
+ pConnSetupT->numRoots = pConnSetup->numRoots;
+ pConnSetupT->numFormats = pConnSetup->numFormats;
+ pConnSetupT->imageByteOrder = pConnSetup->imageByteOrder;
+ pConnSetupT->bitmapBitOrder = pConnSetup->bitmapBitOrder;
+ pConnSetupT->bitmapScanlineUnit = pConnSetup->bitmapScanlineUnit;
+ pConnSetupT->bitmapScanlinePad = pConnSetup->bitmapScanlinePad;
+}
+
+void
+SwapWinRoot(xWindowRoot *pRoot, xWindowRoot *pRootT)
+{
+ cpswapl(pRoot->windowId, pRootT->windowId);
+ cpswapl(pRoot->defaultColormap, pRootT->defaultColormap);
+ cpswapl(pRoot->whitePixel, pRootT->whitePixel);
+ cpswapl(pRoot->blackPixel, pRootT->blackPixel);
+ cpswapl(pRoot->currentInputMask, pRootT->currentInputMask);
+ cpswaps(pRoot->pixWidth, pRootT->pixWidth);
+ cpswaps(pRoot->pixHeight, pRootT->pixHeight);
+ cpswaps(pRoot->mmWidth, pRootT->mmWidth);
+ cpswaps(pRoot->mmHeight, pRootT->mmHeight);
+ cpswaps(pRoot->minInstalledMaps, pRootT->minInstalledMaps);
+ cpswaps(pRoot->maxInstalledMaps, pRootT->maxInstalledMaps);
+ cpswapl(pRoot->rootVisualID, pRootT->rootVisualID);
+ pRootT->backingStore = pRoot->backingStore;
+ pRootT->saveUnders = pRoot->saveUnders;
+ pRootT->rootDepth = pRoot->rootDepth;
+ pRootT->nDepths = pRoot->nDepths;
+}
+
+void
+SwapVisual(xVisualType *pVis, xVisualType *pVisT)
+{
+ cpswapl(pVis->visualID, pVisT->visualID);
+ pVisT->class = pVis->class;
+ pVisT->bitsPerRGB = pVis->bitsPerRGB;
+ cpswaps(pVis->colormapEntries, pVisT->colormapEntries);
+ cpswapl(pVis->redMask, pVisT->redMask);
+ cpswapl(pVis->greenMask, pVisT->greenMask);
+ cpswapl(pVis->blueMask, pVisT->blueMask);
+}
+
+void
+SwapConnSetupPrefix(xConnSetupPrefix *pcspFrom, xConnSetupPrefix *pcspTo)
+{
+ pcspTo->success = pcspFrom->success;
+ pcspTo->lengthReason = pcspFrom->lengthReason;
+ cpswaps(pcspFrom->majorVersion, pcspTo->majorVersion);
+ cpswaps(pcspFrom->minorVersion, pcspTo->minorVersion);
+ cpswaps(pcspFrom->length, pcspTo->length);
+}
+
+void
+WriteSConnSetupPrefix(ClientPtr pClient, xConnSetupPrefix *pcsp)
+{
+ xConnSetupPrefix cspT;
+
+ SwapConnSetupPrefix(pcsp, &cspT);
+ (void)WriteToClient(pClient, sizeof(cspT), (char *) &cspT);
+}
diff --git a/nx-X11/programs/Xserver/dix/swapreq.c b/nx-X11/programs/Xserver/dix/swapreq.c
new file mode 100644
index 000000000..7d57d551f
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/swapreq.c
@@ -0,0 +1,1104 @@
+/* $XFree86: xc/programs/Xserver/dix/swapreq.c,v 3.4 2001/12/14 19:59:33 dawes Exp $ */
+/************************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/* $Xorg: swapreq.c,v 1.4 2001/02/09 02:04:41 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include <X11/Xprotostr.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h" /* for SendEvent */
+#include "swapreq.h"
+
+/* Thanks to Jack Palevich for testing and subsequently rewriting all this */
+
+/* Byte swap a list of longs */
+
+void
+SwapLongs (register CARD32 *list, register unsigned long count)
+{
+ register char n;
+
+ while (count >= 8) {
+ swapl(list+0, n);
+ swapl(list+1, n);
+ swapl(list+2, n);
+ swapl(list+3, n);
+ swapl(list+4, n);
+ swapl(list+5, n);
+ swapl(list+6, n);
+ swapl(list+7, n);
+ list += 8;
+ count -= 8;
+ }
+ if (count != 0) {
+ do {
+ swapl(list, n);
+ list++;
+ } while (--count != 0);
+ }
+}
+
+/* Byte swap a list of shorts */
+
+void
+SwapShorts (register short *list, register unsigned long count)
+{
+ register char n;
+
+ while (count >= 16) {
+ swaps(list+0, n);
+ swaps(list+1, n);
+ swaps(list+2, n);
+ swaps(list+3, n);
+ swaps(list+4, n);
+ swaps(list+5, n);
+ swaps(list+6, n);
+ swaps(list+7, n);
+ swaps(list+8, n);
+ swaps(list+9, n);
+ swaps(list+10, n);
+ swaps(list+11, n);
+ swaps(list+12, n);
+ swaps(list+13, n);
+ swaps(list+14, n);
+ swaps(list+15, n);
+ list += 16;
+ count -= 16;
+ }
+ if (count != 0) {
+ do {
+ swaps(list, n);
+ list++;
+ } while (--count != 0);
+ }
+}
+
+/* The following is used for all requests that have
+ no fields to be swapped (except "length") */
+int
+SProcSimpleReq(register ClientPtr client)
+{
+ register char n;
+
+ REQUEST(xReq);
+ swaps(&stuff->length, n);
+ return(*ProcVector[stuff->reqType])(client);
+}
+
+/* The following is used for all requests that have
+ only a single 32-bit field to be swapped, coming
+ right after the "length" field */
+int
+SProcResourceReq(register ClientPtr client)
+{
+ register char n;
+
+ REQUEST(xResourceReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xResourceReq); /* not EXACT */
+ swapl(&stuff->id, n);
+ return(*ProcVector[stuff->reqType])(client);
+}
+
+int
+SProcCreateWindow(register ClientPtr client)
+{
+ register char n;
+
+ REQUEST(xCreateWindowReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
+ swapl(&stuff->wid, n);
+ swapl(&stuff->parent, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ swaps(&stuff->borderWidth, n);
+ swaps(&stuff->class, n);
+ swapl(&stuff->visual, n);
+ swapl(&stuff->mask, n);
+ SwapRestL(stuff);
+ return((* ProcVector[X_CreateWindow])(client));
+}
+
+int
+SProcChangeWindowAttributes(register ClientPtr client)
+{
+ register char n;
+
+ REQUEST(xChangeWindowAttributesReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
+ swapl(&stuff->window, n);
+ swapl(&stuff->valueMask, n);
+ SwapRestL(stuff);
+ return((* ProcVector[X_ChangeWindowAttributes])(client));
+}
+
+int
+SProcReparentWindow(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xReparentWindowReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xReparentWindowReq);
+ swapl(&stuff->window, n);
+ swapl(&stuff->parent, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ return((* ProcVector[X_ReparentWindow])(client));
+}
+
+int
+SProcConfigureWindow(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xConfigureWindowReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
+ swapl(&stuff->window, n);
+ swaps(&stuff->mask, n);
+ SwapRestL(stuff);
+ return((* ProcVector[X_ConfigureWindow])(client));
+
+}
+
+
+int
+SProcInternAtom(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xInternAtomReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xInternAtomReq);
+ swaps(&stuff->nbytes, n);
+ return((* ProcVector[X_InternAtom])(client));
+}
+
+int
+SProcChangeProperty(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xChangePropertyReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xChangePropertyReq);
+ swapl(&stuff->window, n);
+ swapl(&stuff->property, n);
+ swapl(&stuff->type, n);
+ swapl(&stuff->nUnits, n);
+ switch ( stuff->format ) {
+ case 8 :
+ break;
+ case 16:
+ SwapRestS(stuff);
+ break;
+ case 32:
+ SwapRestL(stuff);
+ break;
+ }
+ return((* ProcVector[X_ChangeProperty])(client));
+}
+
+int
+SProcDeleteProperty(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xDeletePropertyReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xDeletePropertyReq);
+ swapl(&stuff->window, n);
+ swapl(&stuff->property, n);
+ return((* ProcVector[X_DeleteProperty])(client));
+
+}
+
+int
+SProcGetProperty(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xGetPropertyReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGetPropertyReq);
+ swapl(&stuff->window, n);
+ swapl(&stuff->property, n);
+ swapl(&stuff->type, n);
+ swapl(&stuff->longOffset, n);
+ swapl(&stuff->longLength, n);
+ return((* ProcVector[X_GetProperty])(client));
+}
+
+int
+SProcSetSelectionOwner(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xSetSelectionOwnerReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
+ swapl(&stuff->window, n);
+ swapl(&stuff->selection, n);
+ swapl(&stuff->time, n);
+ return((* ProcVector[X_SetSelectionOwner])(client));
+}
+
+int
+SProcConvertSelection(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xConvertSelectionReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xConvertSelectionReq);
+ swapl(&stuff->requestor, n);
+ swapl(&stuff->selection, n);
+ swapl(&stuff->target, n);
+ swapl(&stuff->property, n);
+ swapl(&stuff->time, n);
+ return((* ProcVector[X_ConvertSelection])(client));
+}
+
+int
+SProcSendEvent(register ClientPtr client)
+{
+ register char n;
+ xEvent eventT;
+ EventSwapPtr proc;
+ REQUEST(xSendEventReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSendEventReq);
+ swapl(&stuff->destination, n);
+ swapl(&stuff->eventMask, n);
+
+ /* Swap event */
+ proc = EventSwapVector[stuff->event.u.u.type & 0177];
+ if (!proc || proc == NotImplemented) /* no swapping proc; invalid event type? */
+ return (BadValue);
+ (*proc)(&stuff->event, &eventT);
+ stuff->event = eventT;
+
+ return((* ProcVector[X_SendEvent])(client));
+}
+
+int
+SProcGrabPointer(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xGrabPointerReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGrabPointerReq);
+ swapl(&stuff->grabWindow, n);
+ swaps(&stuff->eventMask, n);
+ swapl(&stuff->confineTo, n);
+ swapl(&stuff->cursor, n);
+ swapl(&stuff->time, n);
+ return((* ProcVector[X_GrabPointer])(client));
+}
+
+int
+SProcGrabButton(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xGrabButtonReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGrabButtonReq);
+ swapl(&stuff->grabWindow, n);
+ swaps(&stuff->eventMask, n);
+ swapl(&stuff->confineTo, n);
+ swapl(&stuff->cursor, n);
+ swaps(&stuff->modifiers, n);
+ return((* ProcVector[X_GrabButton])(client));
+}
+
+int
+SProcUngrabButton(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xUngrabButtonReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xUngrabButtonReq);
+ swapl(&stuff->grabWindow, n);
+ swaps(&stuff->modifiers, n);
+ return((* ProcVector[X_UngrabButton])(client));
+}
+
+int
+SProcChangeActivePointerGrab(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xChangeActivePointerGrabReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xChangeActivePointerGrabReq);
+ swapl(&stuff->cursor, n);
+ swapl(&stuff->time, n);
+ swaps(&stuff->eventMask, n);
+ return((* ProcVector[X_ChangeActivePointerGrab])(client));
+}
+
+int
+SProcGrabKeyboard(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xGrabKeyboardReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGrabKeyboardReq);
+ swapl(&stuff->grabWindow, n);
+ swapl(&stuff->time, n);
+ return((* ProcVector[X_GrabKeyboard])(client));
+}
+
+int
+SProcGrabKey(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xGrabKeyReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGrabKeyReq);
+ swapl(&stuff->grabWindow, n);
+ swaps(&stuff->modifiers, n);
+ return((* ProcVector[X_GrabKey])(client));
+}
+
+int
+SProcUngrabKey(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xUngrabKeyReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xUngrabKeyReq);
+ swapl(&stuff->grabWindow, n);
+ swaps(&stuff->modifiers, n);
+ return((* ProcVector[X_UngrabKey])(client));
+}
+
+int
+SProcGetMotionEvents(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xGetMotionEventsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGetMotionEventsReq);
+ swapl(&stuff->window, n);
+ swapl(&stuff->start, n);
+ swapl(&stuff->stop, n);
+ return((* ProcVector[X_GetMotionEvents])(client));
+}
+
+int
+SProcTranslateCoords(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xTranslateCoordsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xTranslateCoordsReq);
+ swapl(&stuff->srcWid, n);
+ swapl(&stuff->dstWid, n);
+ swaps(&stuff->srcX, n);
+ swaps(&stuff->srcY, n);
+ return((* ProcVector[X_TranslateCoords])(client));
+}
+
+int
+SProcWarpPointer(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xWarpPointerReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xWarpPointerReq);
+ swapl(&stuff->srcWid, n);
+ swapl(&stuff->dstWid, n);
+ swaps(&stuff->srcX, n);
+ swaps(&stuff->srcY, n);
+ swaps(&stuff->srcWidth, n);
+ swaps(&stuff->srcHeight, n);
+ swaps(&stuff->dstX, n);
+ swaps(&stuff->dstY, n);
+ return((* ProcVector[X_WarpPointer])(client));
+}
+
+int
+SProcSetInputFocus(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xSetInputFocusReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSetInputFocusReq);
+ swapl(&stuff->focus, n);
+ swapl(&stuff->time, n);
+ return((* ProcVector[X_SetInputFocus])(client));
+}
+
+int
+SProcOpenFont(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xOpenFontReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xOpenFontReq);
+ swapl(&stuff->fid, n);
+ swaps(&stuff->nbytes, n);
+ return((* ProcVector[X_OpenFont])(client));
+}
+
+int
+SProcListFonts(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xListFontsReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xListFontsReq);
+ swaps(&stuff->maxNames, n);
+ swaps(&stuff->nbytes, n);
+ return((* ProcVector[X_ListFonts])(client));
+}
+
+int
+SProcListFontsWithInfo(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xListFontsWithInfoReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xListFontsWithInfoReq);
+ swaps(&stuff->maxNames, n);
+ swaps(&stuff->nbytes, n);
+ return((* ProcVector[X_ListFontsWithInfo])(client));
+}
+
+int
+SProcSetFontPath(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xSetFontPathReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSetFontPathReq);
+ swaps(&stuff->nFonts, n);
+ return((* ProcVector[X_SetFontPath])(client));
+}
+
+int
+SProcCreatePixmap(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xCreatePixmapReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCreatePixmapReq);
+ swapl(&stuff->pid, n);
+ swapl(&stuff->drawable, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ return((* ProcVector[X_CreatePixmap])(client));
+}
+
+int
+SProcCreateGC(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xCreateGCReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xCreateGCReq);
+ swapl(&stuff->gc, n);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->mask, n);
+ SwapRestL(stuff);
+ return((* ProcVector[X_CreateGC])(client));
+}
+
+int
+SProcChangeGC(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xChangeGCReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xChangeGCReq);
+ swapl(&stuff->gc, n);
+ swapl(&stuff->mask, n);
+ SwapRestL(stuff);
+ return((* ProcVector[X_ChangeGC])(client));
+}
+
+int
+SProcCopyGC(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xCopyGCReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCopyGCReq);
+ swapl(&stuff->srcGC, n);
+ swapl(&stuff->dstGC, n);
+ swapl(&stuff->mask, n);
+ return((* ProcVector[X_CopyGC])(client));
+}
+
+int
+SProcSetDashes(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xSetDashesReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSetDashesReq);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->dashOffset, n);
+ swaps(&stuff->nDashes, n);
+ return((* ProcVector[X_SetDashes])(client));
+
+}
+
+int
+SProcSetClipRectangles(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xSetClipRectanglesReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->xOrigin, n);
+ swaps(&stuff->yOrigin, n);
+ SwapRestS(stuff);
+ return((* ProcVector[X_SetClipRectangles])(client));
+}
+
+int
+SProcClearToBackground(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xClearAreaReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xClearAreaReq);
+ swapl(&stuff->window, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ return((* ProcVector[X_ClearArea])(client));
+}
+
+int
+SProcCopyArea(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xCopyAreaReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCopyAreaReq);
+ swapl(&stuff->srcDrawable, n);
+ swapl(&stuff->dstDrawable, n);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->srcX, n);
+ swaps(&stuff->srcY, n);
+ swaps(&stuff->dstX, n);
+ swaps(&stuff->dstY, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ return((* ProcVector[X_CopyArea])(client));
+}
+
+int
+SProcCopyPlane(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xCopyPlaneReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCopyPlaneReq);
+ swapl(&stuff->srcDrawable, n);
+ swapl(&stuff->dstDrawable, n);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->srcX, n);
+ swaps(&stuff->srcY, n);
+ swaps(&stuff->dstX, n);
+ swaps(&stuff->dstY, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ swapl(&stuff->bitPlane, n);
+ return((* ProcVector[X_CopyPlane])(client));
+}
+
+/* The following routine is used for all Poly drawing requests
+ (except FillPoly, which uses a different request format) */
+int
+SProcPoly(register ClientPtr client)
+{
+ register char n;
+
+ REQUEST(xPolyPointReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xPolyPointReq);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ SwapRestS(stuff);
+ return((* ProcVector[stuff->reqType])(client));
+}
+
+/* cannot use SProcPoly for this one, because xFillPolyReq
+ is longer than xPolyPointReq, and we don't want to swap
+ the difference as shorts! */
+int
+SProcFillPoly(register ClientPtr client)
+{
+ register char n;
+
+ REQUEST(xFillPolyReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xFillPolyReq);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ SwapRestS(stuff);
+ return((* ProcVector[X_FillPoly])(client));
+}
+
+int
+SProcPutImage(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xPutImageReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xPutImageReq);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ swaps(&stuff->dstX, n);
+ swaps(&stuff->dstY, n);
+ /* Image should already be swapped */
+ return((* ProcVector[X_PutImage])(client));
+
+}
+
+int
+SProcGetImage(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xGetImageReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xGetImageReq);
+ swapl(&stuff->drawable, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ swapl(&stuff->planeMask, n);
+ return((* ProcVector[X_GetImage])(client));
+}
+
+/* ProcPolyText used for both PolyText8 and PolyText16 */
+
+int
+SProcPolyText(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xPolyTextReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xPolyTextReq);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ return((* ProcVector[stuff->reqType])(client));
+}
+
+/* ProcImageText used for both ImageText8 and ImageText16 */
+
+int
+SProcImageText(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xImageTextReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xImageTextReq);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->gc, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ return((* ProcVector[stuff->reqType])(client));
+}
+
+int
+SProcCreateColormap(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xCreateColormapReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCreateColormapReq);
+ swapl(&stuff->mid, n);
+ swapl(&stuff->window, n);
+ swapl(&stuff->visual, n);
+ return((* ProcVector[X_CreateColormap])(client));
+}
+
+
+int
+SProcCopyColormapAndFree(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xCopyColormapAndFreeReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
+ swapl(&stuff->mid, n);
+ swapl(&stuff->srcCmap, n);
+ return((* ProcVector[X_CopyColormapAndFree])(client));
+
+}
+
+int
+SProcAllocColor(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xAllocColorReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xAllocColorReq);
+ swapl(&stuff->cmap, n);
+ swaps(&stuff->red, n);
+ swaps(&stuff->green, n);
+ swaps(&stuff->blue, n);
+ return((* ProcVector[X_AllocColor])(client));
+}
+
+int
+SProcAllocNamedColor(register ClientPtr client)
+{
+ register char n;
+
+ REQUEST(xAllocNamedColorReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xAllocNamedColorReq);
+ swapl(&stuff->cmap, n);
+ swaps(&stuff->nbytes, n);
+ return((* ProcVector[X_AllocNamedColor])(client));
+}
+
+int
+SProcAllocColorCells(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xAllocColorCellsReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xAllocColorCellsReq);
+ swapl(&stuff->cmap, n);
+ swaps(&stuff->colors, n);
+ swaps(&stuff->planes, n);
+ return((* ProcVector[X_AllocColorCells])(client));
+}
+
+int
+SProcAllocColorPlanes(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xAllocColorPlanesReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
+ swapl(&stuff->cmap, n);
+ swaps(&stuff->colors, n);
+ swaps(&stuff->red, n);
+ swaps(&stuff->green, n);
+ swaps(&stuff->blue, n);
+ return((* ProcVector[X_AllocColorPlanes])(client));
+}
+
+int
+SProcFreeColors(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xFreeColorsReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
+ swapl(&stuff->cmap, n);
+ swapl(&stuff->planeMask, n);
+ SwapRestL(stuff);
+ return((* ProcVector[X_FreeColors])(client));
+
+}
+
+void
+SwapColorItem(xColorItem *pItem)
+{
+ register char n;
+
+ swapl(&pItem->pixel, n);
+ swaps(&pItem->red, n);
+ swaps(&pItem->green, n);
+ swaps(&pItem->blue, n);
+}
+
+int
+SProcStoreColors(register ClientPtr client)
+{
+ register char n;
+ long count;
+ xColorItem *pItem;
+
+ REQUEST(xStoreColorsReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
+ swapl(&stuff->cmap, n);
+ pItem = (xColorItem *) &stuff[1];
+ for(count = LengthRestB(stuff)/sizeof(xColorItem); --count >= 0; )
+ SwapColorItem(pItem++);
+ return((* ProcVector[X_StoreColors])(client));
+}
+
+int
+SProcStoreNamedColor (register ClientPtr client)
+{
+ register char n;
+ REQUEST(xStoreNamedColorReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xStoreNamedColorReq);
+ swapl(&stuff->cmap, n);
+ swapl(&stuff->pixel, n);
+ swaps(&stuff->nbytes, n);
+ return((* ProcVector[X_StoreNamedColor])(client));
+}
+
+int
+SProcQueryColors (register ClientPtr client)
+{
+ register char n;
+ REQUEST(xQueryColorsReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
+ swapl(&stuff->cmap, n);
+ SwapRestL(stuff);
+ return((* ProcVector[X_QueryColors])(client));
+}
+
+int
+SProcLookupColor (register ClientPtr client)
+{
+ register char n;
+ REQUEST(xLookupColorReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xLookupColorReq);
+ swapl(&stuff->cmap, n);
+ swaps(&stuff->nbytes, n);
+ return((* ProcVector[X_LookupColor])(client));
+}
+
+int
+SProcCreateCursor (register ClientPtr client)
+{
+ register char n;
+ REQUEST(xCreateCursorReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCreateCursorReq);
+ swapl(&stuff->cid, n);
+ swapl(&stuff->source, n);
+ swapl(&stuff->mask, n);
+ swaps(&stuff->foreRed, n);
+ swaps(&stuff->foreGreen, n);
+ swaps(&stuff->foreBlue, n);
+ swaps(&stuff->backRed, n);
+ swaps(&stuff->backGreen, n);
+ swaps(&stuff->backBlue, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ return((* ProcVector[X_CreateCursor])(client));
+}
+
+int
+SProcCreateGlyphCursor (register ClientPtr client)
+{
+ register char n;
+ REQUEST(xCreateGlyphCursorReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xCreateGlyphCursorReq);
+ swapl(&stuff->cid, n);
+ swapl(&stuff->source, n);
+ swapl(&stuff->mask, n);
+ swaps(&stuff->sourceChar, n);
+ swaps(&stuff->maskChar, n);
+ swaps(&stuff->foreRed, n);
+ swaps(&stuff->foreGreen, n);
+ swaps(&stuff->foreBlue, n);
+ swaps(&stuff->backRed, n);
+ swaps(&stuff->backGreen, n);
+ swaps(&stuff->backBlue, n);
+ return((* ProcVector[X_CreateGlyphCursor])(client));
+}
+
+
+int
+SProcRecolorCursor (register ClientPtr client)
+{
+ register char n;
+ REQUEST(xRecolorCursorReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xRecolorCursorReq);
+ swapl(&stuff->cursor, n);
+ swaps(&stuff->foreRed, n);
+ swaps(&stuff->foreGreen, n);
+ swaps(&stuff->foreBlue, n);
+ swaps(&stuff->backRed, n);
+ swaps(&stuff->backGreen, n);
+ swaps(&stuff->backBlue, n);
+ return((* ProcVector[X_RecolorCursor])(client));
+}
+
+int
+SProcQueryBestSize (register ClientPtr client)
+{
+ register char n;
+ REQUEST(xQueryBestSizeReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xQueryBestSizeReq);
+ swapl(&stuff->drawable, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ return((* ProcVector[X_QueryBestSize])(client));
+
+}
+
+int
+SProcQueryExtension (register ClientPtr client)
+{
+ register char n;
+ REQUEST(xQueryExtensionReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xQueryExtensionReq);
+ swaps(&stuff->nbytes, n);
+ return((* ProcVector[X_QueryExtension])(client));
+}
+
+int
+SProcChangeKeyboardMapping (register ClientPtr client)
+{
+ register char n;
+ REQUEST(xChangeKeyboardMappingReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq);
+ SwapRestL(stuff);
+ return((* ProcVector[X_ChangeKeyboardMapping])(client));
+}
+
+
+int
+SProcChangeKeyboardControl (register ClientPtr client)
+{
+ register char n;
+ REQUEST(xChangeKeyboardControlReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
+ swapl(&stuff->mask, n);
+ SwapRestL(stuff);
+ return((* ProcVector[X_ChangeKeyboardControl])(client));
+}
+
+int
+SProcChangePointerControl (register ClientPtr client)
+{
+ register char n;
+ REQUEST(xChangePointerControlReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xChangePointerControlReq);
+ swaps(&stuff->accelNum, n);
+ swaps(&stuff->accelDenum, n);
+ swaps(&stuff->threshold, n);
+ return((* ProcVector[X_ChangePointerControl])(client));
+}
+
+
+int
+SProcSetScreenSaver (register ClientPtr client)
+{
+ register char n;
+ REQUEST(xSetScreenSaverReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSetScreenSaverReq);
+ swaps(&stuff->timeout, n);
+ swaps(&stuff->interval, n);
+ return((* ProcVector[X_SetScreenSaver])(client));
+}
+
+int
+SProcChangeHosts (register ClientPtr client)
+{
+ register char n;
+
+ REQUEST(xChangeHostsReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xChangeHostsReq);
+ swaps(&stuff->hostLength, n);
+ return((* ProcVector[X_ChangeHosts])(client));
+
+}
+
+int SProcRotateProperties (register ClientPtr client)
+{
+ register char n;
+ REQUEST(xRotatePropertiesReq);
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xRotatePropertiesReq);
+ swapl(&stuff->window, n);
+ swaps(&stuff->nAtoms, n);
+ swaps(&stuff->nPositions, n);
+ SwapRestL(stuff);
+ return ((* ProcVector[X_RotateProperties])(client));
+}
+
+int
+SProcNoOperation(register ClientPtr client)
+{
+ register char n;
+ REQUEST(xReq);
+ swaps(&stuff->length, n);
+ return ((* ProcVector[X_NoOperation])(client));
+}
+
+void
+SwapConnClientPrefix(xConnClientPrefix *pCCP)
+{
+ register char n;
+
+ swaps(&pCCP->majorVersion, n);
+ swaps(&pCCP->minorVersion, n);
+ swaps(&pCCP->nbytesAuthProto, n);
+ swaps(&pCCP->nbytesAuthString, n);
+}
diff --git a/nx-X11/programs/Xserver/dix/tables.c b/nx-X11/programs/Xserver/dix/tables.c
new file mode 100644
index 000000000..5196f0e85
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/tables.c
@@ -0,0 +1,529 @@
+/* $XFree86: xc/programs/Xserver/dix/tables.c,v 3.5 2002/02/19 11:09:22 alanh Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: tables.c,v 1.4 2001/02/09 02:04:41 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#include "windowstr.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "dixevents.h"
+#include "dispatch.h"
+#include "swaprep.h"
+#include "swapreq.h"
+
+#ifdef K5AUTH
+extern int
+ k5_stage1(), k5_stage2(), k5_stage3(), k5_bad();
+#endif
+
+int (* InitialVector[3]) (
+ ClientPtr /* client */
+ ) =
+{
+ 0,
+ ProcInitialConnection,
+ ProcEstablishConnection
+};
+
+int (* ProcVector[256]) (
+ ClientPtr /* client */
+ ) =
+{
+ ProcBadRequest,
+ ProcCreateWindow,
+ ProcChangeWindowAttributes,
+ ProcGetWindowAttributes,
+ ProcDestroyWindow,
+ ProcDestroySubwindows, /* 5 */
+ ProcChangeSaveSet,
+ ProcReparentWindow,
+ ProcMapWindow,
+ ProcMapSubwindows,
+ ProcUnmapWindow, /* 10 */
+ ProcUnmapSubwindows,
+ ProcConfigureWindow,
+ ProcCirculateWindow,
+ ProcGetGeometry,
+ ProcQueryTree, /* 15 */
+ ProcInternAtom,
+ ProcGetAtomName,
+ ProcChangeProperty,
+ ProcDeleteProperty,
+ ProcGetProperty, /* 20 */
+ ProcListProperties,
+ ProcSetSelectionOwner,
+ ProcGetSelectionOwner,
+ ProcConvertSelection,
+ ProcSendEvent, /* 25 */
+ ProcGrabPointer,
+ ProcUngrabPointer,
+ ProcGrabButton,
+ ProcUngrabButton,
+ ProcChangeActivePointerGrab, /* 30 */
+ ProcGrabKeyboard,
+ ProcUngrabKeyboard,
+ ProcGrabKey,
+ ProcUngrabKey,
+ ProcAllowEvents, /* 35 */
+ ProcGrabServer,
+ ProcUngrabServer,
+ ProcQueryPointer,
+ ProcGetMotionEvents,
+ ProcTranslateCoords, /* 40 */
+ ProcWarpPointer,
+ ProcSetInputFocus,
+ ProcGetInputFocus,
+ ProcQueryKeymap,
+ ProcOpenFont, /* 45 */
+ ProcCloseFont,
+ ProcQueryFont,
+ ProcQueryTextExtents,
+ ProcListFonts,
+ ProcListFontsWithInfo, /* 50 */
+ ProcSetFontPath,
+ ProcGetFontPath,
+ ProcCreatePixmap,
+ ProcFreePixmap,
+ ProcCreateGC, /* 55 */
+ ProcChangeGC,
+ ProcCopyGC,
+ ProcSetDashes,
+ ProcSetClipRectangles,
+ ProcFreeGC, /* 60 */
+ ProcClearToBackground,
+ ProcCopyArea,
+ ProcCopyPlane,
+ ProcPolyPoint,
+ ProcPolyLine, /* 65 */
+ ProcPolySegment,
+ ProcPolyRectangle,
+ ProcPolyArc,
+ ProcFillPoly,
+ ProcPolyFillRectangle, /* 70 */
+ ProcPolyFillArc,
+ ProcPutImage,
+ ProcGetImage,
+ ProcPolyText,
+ ProcPolyText, /* 75 */
+ ProcImageText8,
+ ProcImageText16,
+ ProcCreateColormap,
+ ProcFreeColormap,
+ ProcCopyColormapAndFree, /* 80 */
+ ProcInstallColormap,
+ ProcUninstallColormap,
+ ProcListInstalledColormaps,
+ ProcAllocColor,
+ ProcAllocNamedColor, /* 85 */
+ ProcAllocColorCells,
+ ProcAllocColorPlanes,
+ ProcFreeColors,
+ ProcStoreColors,
+ ProcStoreNamedColor, /* 90 */
+ ProcQueryColors,
+ ProcLookupColor,
+ ProcCreateCursor,
+ ProcCreateGlyphCursor,
+ ProcFreeCursor, /* 95 */
+ ProcRecolorCursor,
+ ProcQueryBestSize,
+ ProcQueryExtension,
+ ProcListExtensions,
+ ProcChangeKeyboardMapping, /* 100 */
+ ProcGetKeyboardMapping,
+ ProcChangeKeyboardControl,
+ ProcGetKeyboardControl,
+ ProcBell,
+ ProcChangePointerControl, /* 105 */
+ ProcGetPointerControl,
+ ProcSetScreenSaver,
+ ProcGetScreenSaver,
+ ProcChangeHosts,
+ ProcListHosts, /* 110 */
+ ProcChangeAccessControl,
+ ProcChangeCloseDownMode,
+ ProcKillClient,
+ ProcRotateProperties,
+ ProcForceScreenSaver, /* 115 */
+ ProcSetPointerMapping,
+ ProcGetPointerMapping,
+ ProcSetModifierMapping,
+ ProcGetModifierMapping,
+ 0, /* 120 */
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, /* 125 */
+ 0,
+ ProcNoOperation
+};
+
+int (* SwappedProcVector[256]) (
+ ClientPtr /* client */
+ ) =
+{
+ ProcBadRequest,
+ SProcCreateWindow,
+ SProcChangeWindowAttributes,
+ SProcResourceReq, /* GetWindowAttributes */
+ SProcResourceReq, /* DestroyWindow */
+ SProcResourceReq, /* 5 DestroySubwindows */
+ SProcResourceReq, /* SProcChangeSaveSet, */
+ SProcReparentWindow,
+ SProcResourceReq, /* MapWindow */
+ SProcResourceReq, /* MapSubwindows */
+ SProcResourceReq, /* 10 UnmapWindow */
+ SProcResourceReq, /* UnmapSubwindows */
+ SProcConfigureWindow,
+ SProcResourceReq, /* SProcCirculateWindow, */
+ SProcResourceReq, /* GetGeometry */
+ SProcResourceReq, /* 15 QueryTree */
+ SProcInternAtom,
+ SProcResourceReq, /* SProcGetAtomName, */
+ SProcChangeProperty,
+ SProcDeleteProperty,
+ SProcGetProperty, /* 20 */
+ SProcResourceReq, /* SProcListProperties, */
+ SProcSetSelectionOwner,
+ SProcResourceReq, /* SProcGetSelectionOwner, */
+ SProcConvertSelection,
+ SProcSendEvent, /* 25 */
+ SProcGrabPointer,
+ SProcResourceReq, /* SProcUngrabPointer, */
+ SProcGrabButton,
+ SProcUngrabButton,
+ SProcChangeActivePointerGrab, /* 30 */
+ SProcGrabKeyboard,
+ SProcResourceReq, /* SProcUngrabKeyboard, */
+ SProcGrabKey,
+ SProcUngrabKey,
+ SProcResourceReq, /* 35 SProcAllowEvents, */
+ SProcSimpleReq, /* SProcGrabServer, */
+ SProcSimpleReq, /* SProcUngrabServer, */
+ SProcResourceReq, /* SProcQueryPointer, */
+ SProcGetMotionEvents,
+ SProcTranslateCoords, /*40 */
+ SProcWarpPointer,
+ SProcSetInputFocus,
+ SProcSimpleReq, /* SProcGetInputFocus, */
+ SProcSimpleReq, /* QueryKeymap, */
+ SProcOpenFont, /* 45 */
+ SProcResourceReq, /* SProcCloseFont, */
+ SProcResourceReq, /* SProcQueryFont, */
+ SProcResourceReq, /* SProcQueryTextExtents, */
+ SProcListFonts,
+ SProcListFontsWithInfo, /* 50 */
+ SProcSetFontPath,
+ SProcSimpleReq, /* GetFontPath, */
+ SProcCreatePixmap,
+ SProcResourceReq, /* SProcFreePixmap, */
+ SProcCreateGC, /* 55 */
+ SProcChangeGC,
+ SProcCopyGC,
+ SProcSetDashes,
+ SProcSetClipRectangles,
+ SProcResourceReq, /* 60 SProcFreeGC, */
+ SProcClearToBackground,
+ SProcCopyArea,
+ SProcCopyPlane,
+ SProcPoly, /* PolyPoint, */
+ SProcPoly, /* 65 PolyLine */
+ SProcPoly, /* PolySegment, */
+ SProcPoly, /* PolyRectangle, */
+ SProcPoly, /* PolyArc, */
+ SProcFillPoly,
+ SProcPoly, /* 70 PolyFillRectangle */
+ SProcPoly, /* PolyFillArc, */
+ SProcPutImage,
+ SProcGetImage,
+ SProcPolyText,
+ SProcPolyText, /* 75 */
+ SProcImageText,
+ SProcImageText,
+ SProcCreateColormap,
+ SProcResourceReq, /* SProcFreeColormap, */
+ SProcCopyColormapAndFree, /* 80 */
+ SProcResourceReq, /* SProcInstallColormap, */
+ SProcResourceReq, /* SProcUninstallColormap, */
+ SProcResourceReq, /* SProcListInstalledColormaps, */
+ SProcAllocColor,
+ SProcAllocNamedColor, /* 85 */
+ SProcAllocColorCells,
+ SProcAllocColorPlanes,
+ SProcFreeColors,
+ SProcStoreColors,
+ SProcStoreNamedColor, /* 90 */
+ SProcQueryColors,
+ SProcLookupColor,
+ SProcCreateCursor,
+ SProcCreateGlyphCursor,
+ SProcResourceReq, /* 95 SProcFreeCursor, */
+ SProcRecolorCursor,
+ SProcQueryBestSize,
+ SProcQueryExtension,
+ SProcSimpleReq, /* ListExtensions, */
+ SProcChangeKeyboardMapping, /* 100 */
+ SProcSimpleReq, /* GetKeyboardMapping, */
+ SProcChangeKeyboardControl,
+ SProcSimpleReq, /* GetKeyboardControl, */
+ SProcSimpleReq, /* Bell, */
+ SProcChangePointerControl, /* 105 */
+ SProcSimpleReq, /* GetPointerControl, */
+ SProcSetScreenSaver,
+ SProcSimpleReq, /* GetScreenSaver, */
+ SProcChangeHosts,
+ SProcSimpleReq, /* 110 ListHosts, */
+ SProcSimpleReq, /* SProcChangeAccessControl, */
+ SProcSimpleReq, /* SProcChangeCloseDownMode, */
+ SProcResourceReq, /* SProcKillClient, */
+ SProcRotateProperties,
+ SProcSimpleReq, /* 115 ForceScreenSaver */
+ SProcSimpleReq, /* SetPointerMapping, */
+ SProcSimpleReq, /* GetPointerMapping, */
+ SProcSimpleReq, /* SetModifierMapping, */
+ SProcSimpleReq, /* GetModifierMapping, */
+ 0, /* 120 */
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, /* 125 */
+ 0,
+ SProcNoOperation
+};
+
+EventSwapPtr EventSwapVector[128] =
+{
+ (EventSwapPtr)SErrorEvent,
+ NotImplemented,
+ SKeyButtonPtrEvent,
+ SKeyButtonPtrEvent,
+ SKeyButtonPtrEvent,
+ SKeyButtonPtrEvent, /* 5 */
+ SKeyButtonPtrEvent,
+ SEnterLeaveEvent,
+ SEnterLeaveEvent,
+ SFocusEvent,
+ SFocusEvent, /* 10 */
+ SKeymapNotifyEvent,
+ SExposeEvent,
+ SGraphicsExposureEvent,
+ SNoExposureEvent,
+ SVisibilityEvent, /* 15 */
+ SCreateNotifyEvent,
+ SDestroyNotifyEvent,
+ SUnmapNotifyEvent,
+ SMapNotifyEvent,
+ SMapRequestEvent, /* 20 */
+ SReparentEvent,
+ SConfigureNotifyEvent,
+ SConfigureRequestEvent,
+ SGravityEvent,
+ SResizeRequestEvent, /* 25 */
+ SCirculateEvent,
+ SCirculateEvent,
+ SPropertyEvent,
+ SSelectionClearEvent,
+ SSelectionRequestEvent, /* 30 */
+ SSelectionNotifyEvent,
+ SColormapEvent,
+ SClientMessageEvent,
+ SMappingEvent,
+};
+
+
+ReplySwapPtr ReplySwapVector[256] =
+{
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ (ReplySwapPtr)SGetWindowAttributesReply,
+ ReplyNotSwappd,
+ ReplyNotSwappd, /* 5 */
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd, /* 10 */
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ (ReplySwapPtr)SGetGeometryReply,
+ (ReplySwapPtr)SQueryTreeReply, /* 15 */
+ (ReplySwapPtr)SInternAtomReply,
+ (ReplySwapPtr)SGetAtomNameReply,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ (ReplySwapPtr)SGetPropertyReply, /* 20 */
+ (ReplySwapPtr)SListPropertiesReply,
+ ReplyNotSwappd,
+ (ReplySwapPtr)SGetSelectionOwnerReply,
+ ReplyNotSwappd,
+ ReplyNotSwappd, /* 25 */
+ (ReplySwapPtr)SGenericReply, /* SGrabPointerReply, */
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd, /* 30 */
+ (ReplySwapPtr)SGenericReply, /* SGrabKeyboardReply, */
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd, /* 35 */
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ (ReplySwapPtr)SQueryPointerReply,
+ (ReplySwapPtr)SGetMotionEventsReply,
+ (ReplySwapPtr)STranslateCoordsReply, /* 40 */
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ (ReplySwapPtr)SGetInputFocusReply,
+ (ReplySwapPtr)SQueryKeymapReply,
+ ReplyNotSwappd, /* 45 */
+ ReplyNotSwappd,
+ (ReplySwapPtr)SQueryFontReply,
+ (ReplySwapPtr)SQueryTextExtentsReply,
+ (ReplySwapPtr)SListFontsReply,
+ (ReplySwapPtr)SListFontsWithInfoReply, /* 50 */
+ ReplyNotSwappd,
+ (ReplySwapPtr)SGetFontPathReply,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd, /* 55 */
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd, /* 60 */
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd, /* 65 */
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd, /* 70 */
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ (ReplySwapPtr)SGetImageReply,
+ ReplyNotSwappd,
+ ReplyNotSwappd, /* 75 */
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd, /* 80 */
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ (ReplySwapPtr)SListInstalledColormapsReply,
+ (ReplySwapPtr)SAllocColorReply,
+ (ReplySwapPtr)SAllocNamedColorReply, /* 85 */
+ (ReplySwapPtr)SAllocColorCellsReply,
+ (ReplySwapPtr)SAllocColorPlanesReply,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd, /* 90 */
+ (ReplySwapPtr)SQueryColorsReply,
+ (ReplySwapPtr)SLookupColorReply,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd, /* 95 */
+ ReplyNotSwappd,
+ (ReplySwapPtr)SQueryBestSizeReply,
+ (ReplySwapPtr)SGenericReply, /* SQueryExtensionReply, */
+ (ReplySwapPtr)SListExtensionsReply,
+ ReplyNotSwappd, /* 100 */
+ (ReplySwapPtr)SGetKeyboardMappingReply,
+ ReplyNotSwappd,
+ (ReplySwapPtr)SGetKeyboardControlReply,
+ ReplyNotSwappd,
+ ReplyNotSwappd, /* 105 */
+ (ReplySwapPtr)SGetPointerControlReply,
+ ReplyNotSwappd,
+ (ReplySwapPtr)SGetScreenSaverReply,
+ ReplyNotSwappd,
+ (ReplySwapPtr)SListHostsReply, /* 110 */
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd,
+ ReplyNotSwappd, /* 115 */
+ (ReplySwapPtr)SGenericReply, /* SetPointerMapping */
+ (ReplySwapPtr)SGetPointerMappingReply,
+ (ReplySwapPtr)SGenericReply, /* SetModifierMapping */
+ (ReplySwapPtr)SGetModifierMappingReply, /* 119 */
+ ReplyNotSwappd, /* 120 */
+ ReplyNotSwappd, /* 121 */
+ ReplyNotSwappd, /* 122 */
+ ReplyNotSwappd, /* 123 */
+ ReplyNotSwappd, /* 124 */
+ ReplyNotSwappd, /* 125 */
+ ReplyNotSwappd, /* 126 */
+ ReplyNotSwappd, /* NoOperation */
+ ReplyNotSwappd
+};
+
+#ifdef K5AUTH
+int (*k5_Vector[256])() =
+{
+ k5_bad,
+ k5_stage1,
+ k5_bad,
+ k5_stage3
+};
+#endif
diff --git a/nx-X11/programs/Xserver/dix/window.c b/nx-X11/programs/Xserver/dix/window.c
new file mode 100644
index 000000000..c060f4a23
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/window.c
@@ -0,0 +1,3853 @@
+/* $XdotOrg: xc/programs/Xserver/dix/window.c,v 1.12 2005/07/03 08:53:38 daniels Exp $ */
+/* $Xorg: window.c,v 1.4 2001/02/09 02:04:41 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*/
+
+/* The panoramix components contained the following notice */
+/*****************************************************************
+
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+
+/* $XFree86: xc/programs/Xserver/dix/window.c,v 3.36 2003/11/14 23:52:50 torrey Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "misc.h"
+#include "scrnintstr.h"
+#include "os.h"
+#include "regionstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "input.h"
+#include "resource.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+#include "dixevents.h"
+#include "globals.h"
+
+#ifdef XAPPGROUP
+#include <X11/extensions/Xagsrv.h>
+#endif
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+
+/******
+ * Window stuff for server
+ *
+ * CreateRootWindow, CreateWindow, ChangeWindowAttributes,
+ * GetWindowAttributes, DeleteWindow, DestroySubWindows,
+ * HandleSaveSet, ReparentWindow, MapWindow, MapSubWindows,
+ * UnmapWindow, UnmapSubWindows, ConfigureWindow, CirculateWindow,
+ *
+ ******/
+
+static unsigned char _back_lsb[4] = {0x88, 0x22, 0x44, 0x11};
+static unsigned char _back_msb[4] = {0x11, 0x44, 0x22, 0x88};
+
+int screenIsSaved = SCREEN_SAVER_OFF;
+
+ScreenSaverStuffRec savedScreenInfo[MAXSCREENS];
+
+#if 0
+extern void DeleteWindowFromAnyEvents();
+extern Mask EventMaskForClient();
+extern void WindowHasNewCursor();
+extern void RecalculateDeliverableEvents();
+#endif
+
+static Bool TileScreenSaver(int i, int kind);
+
+
+#define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \
+ CWDontPropagate | CWOverrideRedirect | CWCursor )
+
+#define BOXES_OVERLAP(b1, b2) \
+ (!( ((b1)->x2 <= (b2)->x1) || \
+ ( ((b1)->x1 >= (b2)->x2)) || \
+ ( ((b1)->y2 <= (b2)->y1)) || \
+ ( ((b1)->y1 >= (b2)->y2)) ) )
+
+#define RedirectSend(pWin) \
+ ((pWin->eventMask|wOtherEventMasks(pWin)) & SubstructureRedirectMask)
+
+#define SubSend(pWin) \
+ ((pWin->eventMask|wOtherEventMasks(pWin)) & SubstructureNotifyMask)
+
+#define StrSend(pWin) \
+ ((pWin->eventMask|wOtherEventMasks(pWin)) & StructureNotifyMask)
+
+#define SubStrSend(pWin,pParent) (StrSend(pWin) || SubSend(pParent))
+
+
+int numSaveUndersViewable = 0;
+int deltaSaveUndersViewable = 0;
+
+#ifdef DEBUG
+/******
+ * PrintWindowTree
+ * For debugging only
+ ******/
+
+int
+PrintChildren(WindowPtr p1, int indent)
+{
+ WindowPtr p2;
+ int i;
+
+ while (p1)
+ {
+ p2 = p1->firstChild;
+ for (i=0; i<indent; i++) ErrorF( " ");
+ ErrorF( "%x\n", p1->drawable.id);
+ miPrintRegion(&p1->clipList);
+ PrintChildren(p2, indent+4);
+ p1 = p1->nextSib;
+ }
+}
+
+PrintWindowTree()
+{
+ int i;
+ WindowPtr pWin, p1;
+
+ for (i=0; i<screenInfo.numScreens; i++)
+ {
+ ErrorF( "WINDOW %d\n", i);
+ pWin = WindowTable[i];
+ miPrintRegion(&pWin->clipList);
+ p1 = pWin->firstChild;
+ PrintChildren(p1, 4);
+ }
+}
+#endif
+
+int
+TraverseTree(register WindowPtr pWin, VisitWindowProcPtr func, pointer data)
+{
+ register int result;
+ register WindowPtr pChild;
+
+ if (!(pChild = pWin))
+ return(WT_NOMATCH);
+ while (1)
+ {
+ result = (* func)(pChild, data);
+ if (result == WT_STOPWALKING)
+ return(WT_STOPWALKING);
+ if ((result == WT_WALKCHILDREN) && pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ while (!pChild->nextSib && (pChild != pWin))
+ pChild = pChild->parent;
+ if (pChild == pWin)
+ break;
+ pChild = pChild->nextSib;
+ }
+ return(WT_NOMATCH);
+}
+
+/*****
+ * WalkTree
+ * Walk the window tree, for SCREEN, preforming FUNC(pWin, data) on
+ * each window. If FUNC returns WT_WALKCHILDREN, traverse the children,
+ * if it returns WT_DONTWALKCHILDREN, dont. If it returns WT_STOPWALKING
+ * exit WalkTree. Does depth-first traverse.
+ *****/
+
+int
+WalkTree(ScreenPtr pScreen, VisitWindowProcPtr func, pointer data)
+{
+ return(TraverseTree(WindowTable[pScreen->myNum], func, data));
+}
+
+/* hack for forcing backing store on all windows */
+int defaultBackingStore = NotUseful;
+/* hack to force no backing store */
+Bool disableBackingStore = FALSE;
+Bool enableBackingStore = FALSE;
+/* hack to force no save unders */
+Bool disableSaveUnders = FALSE;
+
+static void
+SetWindowToDefaults(register WindowPtr pWin)
+{
+ pWin->prevSib = NullWindow;
+ pWin->firstChild = NullWindow;
+ pWin->lastChild = NullWindow;
+
+ pWin->valdata = (ValidatePtr)NULL;
+ pWin->optional = (WindowOptPtr)NULL;
+ pWin->cursorIsNone = TRUE;
+
+ pWin->backingStore = NotUseful;
+ pWin->DIXsaveUnder = FALSE;
+ pWin->backStorage = (pointer) NULL;
+
+ pWin->mapped = FALSE; /* off */
+ pWin->realized = FALSE; /* off */
+ pWin->viewable = FALSE;
+ pWin->visibility = VisibilityNotViewable;
+ pWin->overrideRedirect = FALSE;
+ pWin->saveUnder = FALSE;
+
+ pWin->bitGravity = ForgetGravity;
+ pWin->winGravity = NorthWestGravity;
+
+ pWin->eventMask = 0;
+ pWin->deliverableEvents = 0;
+ pWin->dontPropagate = 0;
+ pWin->forcedBS = FALSE;
+#ifdef NEED_DBE_BUF_BITS
+ pWin->srcBuffer = DBE_FRONT_BUFFER;
+ pWin->dstBuffer = DBE_FRONT_BUFFER;
+#endif
+#ifdef COMPOSITE
+ pWin->redirectDraw = 0;
+#endif
+}
+
+static void
+MakeRootTile(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ GCPtr pGC;
+ unsigned char back[128];
+ int len = BitmapBytePad(sizeof(long));
+ register unsigned char *from, *to;
+ register int i, j;
+
+ pWin->background.pixmap = (*pScreen->CreatePixmap)(pScreen, 4, 4,
+ pScreen->rootDepth);
+
+ pWin->backgroundState = BackgroundPixmap;
+ pGC = GetScratchGC(pScreen->rootDepth, pScreen);
+ if (!pWin->background.pixmap || !pGC)
+ FatalError("could not create root tile");
+
+ {
+ CARD32 attributes[2];
+
+ attributes[0] = pScreen->whitePixel;
+ attributes[1] = pScreen->blackPixel;
+
+ (void)ChangeGC(pGC, GCForeground | GCBackground, attributes);
+ }
+
+ ValidateGC((DrawablePtr)pWin->background.pixmap, pGC);
+
+ from = (screenInfo.bitmapBitOrder == LSBFirst) ? _back_lsb : _back_msb;
+ to = back;
+
+ for (i = 4; i > 0; i--, from++)
+ for (j = len; j > 0; j--)
+ *to++ = *from;
+
+ if (blackRoot)
+ bzero(back, sizeof(back));
+
+ (*pGC->ops->PutImage)((DrawablePtr)pWin->background.pixmap, pGC, 1,
+ 0, 0, len, 4, 0, XYBitmap, (char *)back);
+
+ FreeScratchGC(pGC);
+
+}
+
+WindowPtr
+AllocateWindow(ScreenPtr pScreen)
+{
+ WindowPtr pWin;
+ register char *ptr;
+ register DevUnion *ppriv;
+ register unsigned *sizes;
+ register unsigned size;
+ register int i;
+
+ pWin = (WindowPtr)xalloc(pScreen->totalWindowSize);
+ if (pWin)
+ {
+ ppriv = (DevUnion *)(pWin + 1);
+ pWin->devPrivates = ppriv;
+ sizes = pScreen->WindowPrivateSizes;
+ ptr = (char *)(ppriv + pScreen->WindowPrivateLen);
+ for (i = pScreen->WindowPrivateLen; --i >= 0; ppriv++, sizes++)
+ {
+ if ( (size = *sizes) )
+ {
+ ppriv->ptr = (pointer)ptr;
+ ptr += size;
+ }
+ else
+ ppriv->ptr = (pointer)NULL;
+ }
+ }
+ return pWin;
+}
+
+/*****
+ * CreateRootWindow
+ * Makes a window at initialization time for specified screen
+ *****/
+
+Bool
+CreateRootWindow(ScreenPtr pScreen)
+{
+ WindowPtr pWin;
+ BoxRec box;
+ PixmapFormatRec *format;
+
+ pWin = AllocateWindow(pScreen);
+ if (!pWin)
+ return FALSE;
+
+ savedScreenInfo[pScreen->myNum].pWindow = NULL;
+ savedScreenInfo[pScreen->myNum].wid = FakeClientID(0);
+ savedScreenInfo[pScreen->myNum].ExternalScreenSaver = NULL;
+ screenIsSaved = SCREEN_SAVER_OFF;
+
+ WindowTable[pScreen->myNum] = pWin;
+
+ pWin->drawable.pScreen = pScreen;
+ pWin->drawable.type = DRAWABLE_WINDOW;
+
+ pWin->drawable.depth = pScreen->rootDepth;
+ for (format = screenInfo.formats;
+ format->depth != pScreen->rootDepth;
+ format++)
+ ;
+ pWin->drawable.bitsPerPixel = format->bitsPerPixel;
+
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+ pWin->parent = NullWindow;
+ SetWindowToDefaults(pWin);
+
+ pWin->optional = (WindowOptRec *) xalloc (sizeof (WindowOptRec));
+ if (!pWin->optional)
+ return FALSE;
+
+ pWin->optional->dontPropagateMask = 0;
+ pWin->optional->otherEventMasks = 0;
+ pWin->optional->otherClients = NULL;
+ pWin->optional->passiveGrabs = NULL;
+ pWin->optional->userProps = NULL;
+ pWin->optional->backingBitPlanes = ~0L;
+ pWin->optional->backingPixel = 0;
+#ifdef SHAPE
+ pWin->optional->boundingShape = NULL;
+ pWin->optional->clipShape = NULL;
+ pWin->optional->inputShape = NULL;
+#endif
+#ifdef XINPUT
+ pWin->optional->inputMasks = NULL;
+#endif
+ pWin->optional->colormap = pScreen->defColormap;
+ pWin->optional->visual = pScreen->rootVisual;
+
+ pWin->nextSib = NullWindow;
+
+ pWin->drawable.id = FakeClientID(0);
+
+ pWin->origin.x = pWin->origin.y = 0;
+ pWin->drawable.height = pScreen->height;
+ pWin->drawable.width = pScreen->width;
+ pWin->drawable.x = pWin->drawable.y = 0;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pScreen->width;
+ box.y2 = pScreen->height;
+ REGION_INIT(pScreen, &pWin->clipList, &box, 1);
+ REGION_INIT(pScreen, &pWin->winSize, &box, 1);
+ REGION_INIT(pScreen, &pWin->borderSize, &box, 1);
+ REGION_INIT(pScreen, &pWin->borderClip, &box, 1);
+
+ pWin->drawable.class = InputOutput;
+ pWin->optional->visual = pScreen->rootVisual;
+
+ pWin->backgroundState = BackgroundPixel;
+ pWin->background.pixel = pScreen->whitePixel;
+
+ pWin->borderIsPixel = TRUE;
+ pWin->border.pixel = pScreen->blackPixel;
+ pWin->borderWidth = 0;
+
+ if (!AddResource(pWin->drawable.id, RT_WINDOW, (pointer)pWin))
+ return FALSE;
+
+ if (disableBackingStore)
+ pScreen->backingStoreSupport = NotUseful;
+ if (enableBackingStore)
+ pScreen->backingStoreSupport = Always;
+
+#ifdef DO_SAVE_UNDERS
+ if ((pScreen->backingStoreSupport != NotUseful) &&
+ (pScreen->saveUnderSupport == NotUseful))
+ {
+ /*
+ * If the screen has backing-store but no save-unders, let the
+ * clients know we can support save-unders using backing-store.
+ */
+ pScreen->saveUnderSupport = USE_DIX_SAVE_UNDERS;
+ }
+#endif /* DO_SAVE_UNDERS */
+
+ if (disableSaveUnders)
+ pScreen->saveUnderSupport = NotUseful;
+
+ return TRUE;
+}
+
+void
+InitRootWindow(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ if (!(*pScreen->CreateWindow)(pWin))
+ return; /* XXX */
+ (*pScreen->PositionWindow)(pWin, 0, 0);
+
+ pWin->cursorIsNone = FALSE;
+ pWin->optional->cursor = rootCursor;
+ rootCursor->refcnt++;
+ MakeRootTile(pWin);
+ pWin->backingStore = defaultBackingStore;
+ pWin->forcedBS = (defaultBackingStore != NotUseful);
+ /* We SHOULD check for an error value here XXX */
+ (*pScreen->ChangeWindowAttributes)(pWin,
+ CWBackPixmap|CWBorderPixel|CWCursor|CWBackingStore);
+
+ MapWindow(pWin, serverClient);
+}
+
+/* Set the region to the intersection of the rectangle and the
+ * window's winSize. The window is typically the parent of the
+ * window from which the region came.
+ */
+
+void
+ClippedRegionFromBox(register WindowPtr pWin, RegionPtr Rgn,
+ register int x, register int y,
+ register int w, register int h)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ BoxRec box;
+
+ box = *(REGION_EXTENTS(pScreen, &pWin->winSize));
+ /* we do these calculations to avoid overflows */
+ if (x > box.x1)
+ box.x1 = x;
+ if (y > box.y1)
+ box.y1 = y;
+ x += w;
+ if (x < box.x2)
+ box.x2 = x;
+ y += h;
+ if (y < box.y2)
+ box.y2 = y;
+ if (box.x1 > box.x2)
+ box.x2 = box.x1;
+ if (box.y1 > box.y2)
+ box.y2 = box.y1;
+ REGION_RESET(pScreen, Rgn, &box);
+ REGION_INTERSECT(pScreen, Rgn, Rgn, &pWin->winSize);
+}
+
+WindowPtr
+RealChildHead(register WindowPtr pWin)
+{
+ if (!pWin->parent &&
+ (screenIsSaved == SCREEN_SAVER_ON) &&
+ (HasSaverWindow (pWin->drawable.pScreen->myNum)))
+ return (pWin->firstChild);
+ else
+ return (NullWindow);
+}
+
+/*****
+ * CreateWindow
+ * Makes a window in response to client request
+ *****/
+
+WindowPtr
+CreateWindow(Window wid, register WindowPtr pParent, int x, int y, unsigned w,
+ unsigned h, unsigned bw, unsigned class, register Mask vmask, XID *vlist,
+ int depth, ClientPtr client, VisualID visual, int *error)
+{
+ register WindowPtr pWin;
+ WindowPtr pHead;
+ register ScreenPtr pScreen;
+ xEvent event;
+ int idepth, ivisual;
+ Bool fOK;
+ DepthPtr pDepth;
+ PixmapFormatRec *format;
+ register WindowOptPtr ancwopt;
+
+ if (class == CopyFromParent)
+ class = pParent->drawable.class;
+
+ if ((class != InputOutput) && (class != InputOnly))
+ {
+ *error = BadValue;
+ client->errorValue = class;
+ return NullWindow;
+ }
+
+ if ((class != InputOnly) && (pParent->drawable.class == InputOnly))
+ {
+ *error = BadMatch;
+ return NullWindow;
+ }
+
+ if ((class == InputOnly) && ((bw != 0) || (depth != 0)))
+ {
+ *error = BadMatch;
+ return NullWindow;
+ }
+
+ pScreen = pParent->drawable.pScreen;
+ if ((class == InputOutput) && (depth == 0))
+ depth = pParent->drawable.depth;
+ ancwopt = pParent->optional;
+ if (!ancwopt)
+ ancwopt = FindWindowWithOptional(pParent)->optional;
+ if (visual == CopyFromParent) {
+#ifdef XAPPGROUP
+ VisualID ag_visual;
+
+ if (client->appgroup && !pParent->parent &&
+ (ag_visual = XagRootVisual (client)))
+ visual = ag_visual;
+ else
+#endif
+ visual = ancwopt->visual;
+ }
+
+ /* Find out if the depth and visual are acceptable for this Screen */
+ if ((visual != ancwopt->visual) || (depth != pParent->drawable.depth))
+ {
+ fOK = FALSE;
+ for(idepth = 0; idepth < pScreen->numDepths; idepth++)
+ {
+ pDepth = (DepthPtr) &pScreen->allowedDepths[idepth];
+ if ((depth == pDepth->depth) || (depth == 0))
+ {
+ for (ivisual = 0; ivisual < pDepth->numVids; ivisual++)
+ {
+ if (visual == pDepth->vids[ivisual])
+ {
+ fOK = TRUE;
+ break;
+ }
+ }
+ }
+ }
+ if (fOK == FALSE)
+ {
+ *error = BadMatch;
+ return NullWindow;
+ }
+ }
+
+ if (((vmask & (CWBorderPixmap | CWBorderPixel)) == 0) &&
+ (class != InputOnly) &&
+ (depth != pParent->drawable.depth))
+ {
+ *error = BadMatch;
+ return NullWindow;
+ }
+
+ if (((vmask & CWColormap) == 0) &&
+ (class != InputOnly) &&
+ ((visual != ancwopt->visual) || (ancwopt->colormap == None)))
+ {
+ *error = BadMatch;
+ return NullWindow;
+ }
+
+ pWin = AllocateWindow(pScreen);
+ if (!pWin)
+ {
+ *error = BadAlloc;
+ return NullWindow;
+ }
+ pWin->drawable = pParent->drawable;
+ pWin->drawable.depth = depth;
+ if (depth == pParent->drawable.depth)
+ pWin->drawable.bitsPerPixel = pParent->drawable.bitsPerPixel;
+ else
+ {
+ for (format = screenInfo.formats; format->depth != depth; format++)
+ ;
+ pWin->drawable.bitsPerPixel = format->bitsPerPixel;
+ }
+ if (class == InputOnly)
+ pWin->drawable.type = (short) UNDRAWABLE_WINDOW;
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+ pWin->drawable.id = wid;
+ pWin->drawable.class = class;
+
+ pWin->parent = pParent;
+ SetWindowToDefaults(pWin);
+
+ if (visual != ancwopt->visual)
+ {
+ if (!MakeWindowOptional (pWin))
+ {
+ xfree (pWin);
+ *error = BadAlloc;
+ return NullWindow;
+ }
+ pWin->optional->visual = visual;
+ pWin->optional->colormap = None;
+ }
+
+ pWin->borderWidth = bw;
+#ifdef XCSECURITY
+ /* can't let untrusted clients have background None windows;
+ * they make it too easy to steal window contents
+ */
+ if (client->trustLevel != XSecurityClientTrusted)
+ {
+ pWin->backgroundState = BackgroundPixel;
+ pWin->background.pixel = 0;
+ }
+ else
+#endif
+ pWin->backgroundState = None;
+
+ pWin->borderIsPixel = pParent->borderIsPixel;
+ pWin->border = pParent->border;
+ if (pWin->borderIsPixel == FALSE)
+ pWin->border.pixmap->refcnt++;
+
+ pWin->origin.x = x + (int)bw;
+ pWin->origin.y = y + (int)bw;
+ pWin->drawable.width = w;
+ pWin->drawable.height = h;
+ pWin->drawable.x = pParent->drawable.x + x + (int)bw;
+ pWin->drawable.y = pParent->drawable.y + y + (int)bw;
+
+ /* set up clip list correctly for unobscured WindowPtr */
+ REGION_NULL(pScreen, &pWin->clipList);
+ REGION_NULL(pScreen, &pWin->borderClip);
+ REGION_NULL(pScreen, &pWin->winSize);
+ REGION_NULL(pScreen, &pWin->borderSize);
+
+ pHead = RealChildHead(pParent);
+ if (pHead)
+ {
+ pWin->nextSib = pHead->nextSib;
+ if (pHead->nextSib)
+ pHead->nextSib->prevSib = pWin;
+ else
+ pParent->lastChild = pWin;
+ pHead->nextSib = pWin;
+ pWin->prevSib = pHead;
+ }
+ else
+ {
+ pWin->nextSib = pParent->firstChild;
+ if (pParent->firstChild)
+ pParent->firstChild->prevSib = pWin;
+ else
+ pParent->lastChild = pWin;
+ pParent->firstChild = pWin;
+ }
+
+ SetWinSize (pWin);
+ SetBorderSize (pWin);
+
+ /* We SHOULD check for an error value here XXX */
+ if (!(*pScreen->CreateWindow)(pWin))
+ {
+ *error = BadAlloc;
+ DeleteWindow(pWin, None);
+ return NullWindow;
+ }
+ /* We SHOULD check for an error value here XXX */
+ (*pScreen->PositionWindow)(pWin, pWin->drawable.x, pWin->drawable.y);
+
+ if (!(vmask & CWEventMask))
+ RecalculateDeliverableEvents(pWin);
+
+ if (vmask)
+ *error = ChangeWindowAttributes(pWin, vmask, vlist, wClient (pWin));
+ else
+ *error = Success;
+
+ if (*error != Success)
+ {
+ DeleteWindow(pWin, None);
+ return NullWindow;
+ }
+ if (!(vmask & CWBackingStore) && (defaultBackingStore != NotUseful))
+ {
+ XID value = defaultBackingStore;
+ (void)ChangeWindowAttributes(pWin, CWBackingStore, &value, wClient (pWin));
+ pWin->forcedBS = TRUE;
+ }
+
+ if (SubSend(pParent))
+ {
+ event.u.u.type = CreateNotify;
+ event.u.createNotify.window = wid;
+ event.u.createNotify.parent = pParent->drawable.id;
+ event.u.createNotify.x = x;
+ event.u.createNotify.y = y;
+ event.u.createNotify.width = w;
+ event.u.createNotify.height = h;
+ event.u.createNotify.borderWidth = bw;
+ event.u.createNotify.override = pWin->overrideRedirect;
+ DeliverEvents(pParent, &event, 1, NullWindow);
+ }
+ return pWin;
+}
+
+static void
+FreeWindowResources(register WindowPtr pWin)
+{
+ register ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ DeleteWindowFromAnySaveSet(pWin);
+ DeleteWindowFromAnySelections(pWin);
+ DeleteWindowFromAnyEvents(pWin, TRUE);
+ REGION_UNINIT(pScreen, &pWin->clipList);
+ REGION_UNINIT(pScreen, &pWin->winSize);
+ REGION_UNINIT(pScreen, &pWin->borderClip);
+ REGION_UNINIT(pScreen, &pWin->borderSize);
+#ifdef SHAPE
+ if (wBoundingShape (pWin))
+ REGION_DESTROY(pScreen, wBoundingShape (pWin));
+ if (wClipShape (pWin))
+ REGION_DESTROY(pScreen, wClipShape (pWin));
+ if (wInputShape (pWin))
+ REGION_DESTROY(pScreen, wInputShape (pWin));
+#endif
+ if (pWin->borderIsPixel == FALSE)
+ (*pScreen->DestroyPixmap)(pWin->border.pixmap);
+ if (pWin->backgroundState == BackgroundPixmap)
+ (*pScreen->DestroyPixmap)(pWin->background.pixmap);
+
+ DeleteAllWindowProperties(pWin);
+ /* We SHOULD check for an error value here XXX */
+ (*pScreen->DestroyWindow)(pWin);
+ DisposeWindowOptional (pWin);
+}
+
+static void
+CrushTree(WindowPtr pWin)
+{
+ register WindowPtr pChild, pSib, pParent;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ xEvent event;
+
+ if (!(pChild = pWin->firstChild))
+ return;
+ UnrealizeWindow = pWin->drawable.pScreen->UnrealizeWindow;
+ while (1)
+ {
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ while (1)
+ {
+ pParent = pChild->parent;
+ if (SubStrSend(pChild, pParent))
+ {
+ event.u.u.type = DestroyNotify;
+ event.u.destroyNotify.window = pChild->drawable.id;
+ DeliverEvents(pChild, &event, 1, NullWindow);
+ }
+ FreeResource(pChild->drawable.id, RT_WINDOW);
+ pSib = pChild->nextSib;
+#ifdef DO_SAVE_UNDERS
+ if (pChild->saveUnder && pChild->viewable)
+ deltaSaveUndersViewable--;
+#endif
+ pChild->viewable = FALSE;
+ if (pChild->realized)
+ {
+ pChild->realized = FALSE;
+ (*UnrealizeWindow)(pChild);
+ }
+ FreeWindowResources(pChild);
+ xfree(pChild);
+ if ( (pChild = pSib) )
+ break;
+ pChild = pParent;
+ pChild->firstChild = NullWindow;
+ pChild->lastChild = NullWindow;
+ if (pChild == pWin)
+ return;
+ }
+ }
+}
+
+/*****
+ * DeleteWindow
+ * Deletes child of window then window itself
+ * If wid is None, don't send any events
+ *****/
+
+int
+DeleteWindow(pointer value, XID wid)
+ {
+ register WindowPtr pParent;
+ register WindowPtr pWin = (WindowPtr)value;
+ xEvent event;
+
+ UnmapWindow(pWin, FALSE);
+
+ CrushTree(pWin);
+
+ pParent = pWin->parent;
+ if (wid && pParent && SubStrSend(pWin, pParent))
+ {
+ event.u.u.type = DestroyNotify;
+ event.u.destroyNotify.window = pWin->drawable.id;
+ DeliverEvents(pWin, &event, 1, NullWindow);
+ }
+
+ FreeWindowResources(pWin);
+ if (pParent)
+ {
+ if (pParent->firstChild == pWin)
+ pParent->firstChild = pWin->nextSib;
+ if (pParent->lastChild == pWin)
+ pParent->lastChild = pWin->prevSib;
+ if (pWin->nextSib)
+ pWin->nextSib->prevSib = pWin->prevSib;
+ if (pWin->prevSib)
+ pWin->prevSib->nextSib = pWin->nextSib;
+ }
+ xfree(pWin);
+ return Success;
+}
+
+void
+DestroySubwindows(register WindowPtr pWin, ClientPtr client)
+{
+ /* XXX
+ * The protocol is quite clear that each window should be
+ * destroyed in turn, however, unmapping all of the first
+ * eliminates most of the calls to ValidateTree. So,
+ * this implementation is incorrect in that all of the
+ * UnmapNotifies occur before all of the DestroyNotifies.
+ * If you care, simply delete the call to UnmapSubwindows.
+ */
+ UnmapSubwindows(pWin);
+ while (pWin->lastChild)
+ FreeResource(pWin->lastChild->drawable.id, RT_NONE);
+}
+
+#define DeviceEventMasks (KeyPressMask | KeyReleaseMask | ButtonPressMask | \
+ ButtonReleaseMask | PointerMotionMask)
+
+/*****
+ * ChangeWindowAttributes
+ *
+ * The value-mask specifies which attributes are to be changed; the
+ * value-list contains one value for each one bit in the mask, from least
+ * to most significant bit in the mask.
+ *****/
+
+int
+ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
+{
+ register Mask index2;
+ register XID *pVlist;
+ PixmapPtr pPixmap;
+ Pixmap pixID;
+ CursorPtr pCursor, pOldCursor;
+ Cursor cursorID;
+ WindowPtr pChild;
+ Colormap cmap;
+ ColormapPtr pCmap;
+ xEvent xE;
+ int result;
+ register ScreenPtr pScreen;
+ Mask vmaskCopy = 0;
+ register Mask tmask;
+ unsigned int val;
+ int error;
+ Bool checkOptional = FALSE;
+ Bool borderRelative = FALSE;
+ WindowPtr pLayerWin;
+
+ if ((pWin->drawable.class == InputOnly) && (vmask & (~INPUTONLY_LEGAL_MASK)))
+ return BadMatch;
+
+ error = Success;
+ pScreen = pWin->drawable.pScreen;
+ pVlist = vlist;
+ tmask = vmask;
+ while (tmask)
+ {
+ index2 = (Mask) lowbit (tmask);
+ tmask &= ~index2;
+ switch (index2)
+ {
+ case CWBackPixmap:
+ pixID = (Pixmap )*pVlist;
+ pVlist++;
+ if (pWin->backgroundState == ParentRelative)
+ borderRelative = TRUE;
+ if (pixID == None)
+ {
+#ifdef XCSECURITY
+ /* can't let untrusted clients have background None windows */
+ if (client->trustLevel == XSecurityClientTrusted)
+ {
+#endif
+ if (pWin->backgroundState == BackgroundPixmap)
+ (*pScreen->DestroyPixmap)(pWin->background.pixmap);
+ if (!pWin->parent)
+ MakeRootTile(pWin);
+ else
+ pWin->backgroundState = None;
+#ifdef XCSECURITY
+ }
+ else
+ { /* didn't change the background to None, so don't tell ddx */
+ index2 = 0;
+ }
+#endif
+ }
+ else if (pixID == ParentRelative)
+ {
+ if (pWin->parent &&
+ pWin->drawable.depth != pWin->parent->drawable.depth)
+ {
+ error = BadMatch;
+ goto PatchUp;
+ }
+ if (pWin->backgroundState == BackgroundPixmap)
+ (*pScreen->DestroyPixmap)(pWin->background.pixmap);
+ if (!pWin->parent)
+ MakeRootTile(pWin);
+ else
+ pWin->backgroundState = ParentRelative;
+ borderRelative = TRUE;
+ /* Note that the parent's backgroundTile's refcnt is NOT
+ * incremented. */
+ }
+ else
+ {
+ pPixmap = (PixmapPtr)SecurityLookupIDByType(client, pixID,
+ RT_PIXMAP, SecurityReadAccess);
+ if (pPixmap != (PixmapPtr) NULL)
+ {
+ if ((pPixmap->drawable.depth != pWin->drawable.depth) ||
+ (pPixmap->drawable.pScreen != pScreen))
+ {
+ error = BadMatch;
+ goto PatchUp;
+ }
+ if (pWin->backgroundState == BackgroundPixmap)
+ (*pScreen->DestroyPixmap)(pWin->background.pixmap);
+ pWin->backgroundState = BackgroundPixmap;
+ pWin->background.pixmap = pPixmap;
+ pPixmap->refcnt++;
+ }
+ else
+ {
+ error = BadPixmap;
+ client->errorValue = pixID;
+ goto PatchUp;
+ }
+ }
+ break;
+ case CWBackPixel:
+ if (pWin->backgroundState == ParentRelative)
+ borderRelative = TRUE;
+ if (pWin->backgroundState == BackgroundPixmap)
+ (*pScreen->DestroyPixmap)(pWin->background.pixmap);
+ pWin->backgroundState = BackgroundPixel;
+ pWin->background.pixel = (CARD32 ) *pVlist;
+ /* background pixel overrides background pixmap,
+ so don't let the ddx layer see both bits */
+ vmaskCopy &= ~CWBackPixmap;
+ pVlist++;
+ break;
+ case CWBorderPixmap:
+ pixID = (Pixmap ) *pVlist;
+ pVlist++;
+ if (pixID == CopyFromParent)
+ {
+ if (!pWin->parent ||
+ (pWin->drawable.depth != pWin->parent->drawable.depth))
+ {
+ error = BadMatch;
+ goto PatchUp;
+ }
+ if (pWin->borderIsPixel == FALSE)
+ (*pScreen->DestroyPixmap)(pWin->border.pixmap);
+ pWin->border = pWin->parent->border;
+ if ((pWin->borderIsPixel = pWin->parent->borderIsPixel) == TRUE)
+ {
+ index2 = CWBorderPixel;
+ }
+ else
+ {
+ pWin->parent->border.pixmap->refcnt++;
+ }
+ }
+ else
+ {
+ pPixmap = (PixmapPtr)SecurityLookupIDByType(client, pixID,
+ RT_PIXMAP, SecurityReadAccess);
+ if (pPixmap)
+ {
+ if ((pPixmap->drawable.depth != pWin->drawable.depth) ||
+ (pPixmap->drawable.pScreen != pScreen))
+ {
+ error = BadMatch;
+ goto PatchUp;
+ }
+ if (pWin->borderIsPixel == FALSE)
+ (*pScreen->DestroyPixmap)(pWin->border.pixmap);
+ pWin->borderIsPixel = FALSE;
+ pWin->border.pixmap = pPixmap;
+ pPixmap->refcnt++;
+ }
+ else
+ {
+ error = BadPixmap;
+ client->errorValue = pixID;
+ goto PatchUp;
+ }
+ }
+ break;
+ case CWBorderPixel:
+ if (pWin->borderIsPixel == FALSE)
+ (*pScreen->DestroyPixmap)(pWin->border.pixmap);
+ pWin->borderIsPixel = TRUE;
+ pWin->border.pixel = (CARD32) *pVlist;
+ /* border pixel overrides border pixmap,
+ so don't let the ddx layer see both bits */
+ vmaskCopy &= ~CWBorderPixmap;
+ pVlist++;
+ break;
+ case CWBitGravity:
+ val = (CARD8 )*pVlist;
+ pVlist++;
+ if (val > StaticGravity)
+ {
+ error = BadValue;
+ client->errorValue = val;
+ goto PatchUp;
+ }
+ pWin->bitGravity = val;
+ break;
+ case CWWinGravity:
+ val = (CARD8 )*pVlist;
+ pVlist++;
+ if (val > StaticGravity)
+ {
+ error = BadValue;
+ client->errorValue = val;
+ goto PatchUp;
+ }
+ pWin->winGravity = val;
+ break;
+ case CWBackingStore:
+ val = (CARD8 )*pVlist;
+ pVlist++;
+ if ((val != NotUseful) && (val != WhenMapped) && (val != Always))
+ {
+ error = BadValue;
+ client->errorValue = val;
+ goto PatchUp;
+ }
+ pWin->backingStore = val;
+ pWin->forcedBS = FALSE;
+ break;
+ case CWBackingPlanes:
+ if (pWin->optional || ((CARD32)*pVlist != (CARD32)~0L)) {
+ if (!pWin->optional && !MakeWindowOptional (pWin))
+ {
+ error = BadAlloc;
+ goto PatchUp;
+ }
+ pWin->optional->backingBitPlanes = (CARD32) *pVlist;
+ if ((CARD32)*pVlist == (CARD32)~0L)
+ checkOptional = TRUE;
+ }
+ pVlist++;
+ break;
+ case CWBackingPixel:
+ if (pWin->optional || (CARD32) *pVlist) {
+ if (!pWin->optional && !MakeWindowOptional (pWin))
+ {
+ error = BadAlloc;
+ goto PatchUp;
+ }
+ pWin->optional->backingPixel = (CARD32) *pVlist;
+ if (!*pVlist)
+ checkOptional = TRUE;
+ }
+ pVlist++;
+ break;
+ case CWSaveUnder:
+ val = (BOOL) *pVlist;
+ pVlist++;
+ if ((val != xTrue) && (val != xFalse))
+ {
+ error = BadValue;
+ client->errorValue = val;
+ goto PatchUp;
+ }
+#ifdef DO_SAVE_UNDERS
+ if (pWin->parent && (pWin->saveUnder != val) && (pWin->viewable) &&
+ DO_SAVE_UNDERS(pWin))
+ {
+ /*
+ * Re-check all siblings and inferiors for obscurity or
+ * exposition (hee hee).
+ */
+ if (pWin->saveUnder)
+ deltaSaveUndersViewable--;
+ else
+ deltaSaveUndersViewable++;
+ pWin->saveUnder = val;
+
+ if (pWin->firstChild)
+ {
+ pLayerWin = (*pScreen->GetLayerWindow)(pWin);
+ if ((*pScreen->ChangeSaveUnder)(pLayerWin->parent, pWin->nextSib))
+ (*pScreen->PostChangeSaveUnder)(pLayerWin->parent,
+ pWin->nextSib);
+ }
+ else
+ {
+ if ((*pScreen->ChangeSaveUnder)(pWin, pWin->nextSib))
+ (*pScreen->PostChangeSaveUnder)(pWin,
+ pWin->nextSib);
+ }
+ }
+ else
+ {
+ /* If we're changing the saveUnder attribute of the root
+ * window, all we do is set pWin->saveUnder so that
+ * GetWindowAttributes returns the right value. We don't
+ * do the "normal" save-under processing (as above).
+ * Hope that doesn't cause any problems.
+ */
+ pWin->saveUnder = val;
+ }
+#else
+ pWin->saveUnder = val;
+#endif /* DO_SAVE_UNDERS */
+ break;
+ case CWEventMask:
+ result = EventSelectForWindow(pWin, client, (Mask )*pVlist);
+ if (result)
+ {
+ error = result;
+ goto PatchUp;
+ }
+ pVlist++;
+ break;
+ case CWDontPropagate:
+ result = EventSuppressForWindow(pWin, client, (Mask )*pVlist,
+ &checkOptional);
+ if (result)
+ {
+ error = result;
+ goto PatchUp;
+ }
+ pVlist++;
+ break;
+ case CWOverrideRedirect:
+ val = (BOOL ) *pVlist;
+ pVlist++;
+ if ((val != xTrue) && (val != xFalse))
+ {
+ error = BadValue;
+ client->errorValue = val;
+ goto PatchUp;
+ }
+ pWin->overrideRedirect = val;
+ break;
+ case CWColormap:
+ cmap = (Colormap) *pVlist;
+ pVlist++;
+ if (cmap == CopyFromParent)
+ {
+#ifdef XAPPGROUP
+ Colormap ag_colormap;
+ ClientPtr win_owner;
+
+ /*
+ * win_owner == client for CreateWindow, other clients
+ * can ChangeWindowAttributes
+ */
+ win_owner = clients[CLIENT_ID(pWin->drawable.id)];
+
+ if ( win_owner && win_owner->appgroup &&
+ !pWin->parent->parent &&
+ (ag_colormap = XagDefaultColormap (win_owner)))
+ cmap = ag_colormap;
+ else
+#endif
+ if (pWin->parent &&
+ (!pWin->optional ||
+ pWin->optional->visual == wVisual (pWin->parent)))
+ {
+ cmap = wColormap (pWin->parent);
+ }
+ else
+ cmap = None;
+ }
+ if (cmap == None)
+ {
+ error = BadMatch;
+ goto PatchUp;
+ }
+ pCmap = (ColormapPtr)SecurityLookupIDByType(client, cmap,
+ RT_COLORMAP, SecurityReadAccess);
+ if (!pCmap)
+ {
+ error = BadColor;
+ client->errorValue = cmap;
+ goto PatchUp;
+ }
+ if (pCmap->pVisual->vid != wVisual (pWin) ||
+ pCmap->pScreen != pScreen)
+ {
+ error = BadMatch;
+ goto PatchUp;
+ }
+ if (cmap != wColormap (pWin))
+ {
+ if (!pWin->optional)
+ {
+ if (!MakeWindowOptional (pWin))
+ {
+ error = BadAlloc;
+ goto PatchUp;
+ }
+ }
+ else if (pWin->parent && cmap == wColormap (pWin->parent))
+ checkOptional = TRUE;
+
+ /*
+ * propagate the original colormap to any children
+ * inheriting it
+ */
+
+ for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib)
+ {
+ if (!pChild->optional && !MakeWindowOptional (pChild))
+ {
+ error = BadAlloc;
+ goto PatchUp;
+ }
+ }
+
+ pWin->optional->colormap = cmap;
+
+ /*
+ * check on any children now matching the new colormap
+ */
+
+ for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib)
+ {
+ if (pChild->optional->colormap == cmap)
+ CheckWindowOptionalNeed (pChild);
+ }
+
+ xE.u.u.type = ColormapNotify;
+ xE.u.colormap.window = pWin->drawable.id;
+ xE.u.colormap.colormap = cmap;
+ xE.u.colormap.new = xTrue;
+ xE.u.colormap.state = IsMapInstalled(cmap, pWin);
+ DeliverEvents(pWin, &xE, 1, NullWindow);
+ }
+ break;
+ case CWCursor:
+ cursorID = (Cursor ) *pVlist;
+ pVlist++;
+ /*
+ * install the new
+ */
+ if ( cursorID == None)
+ {
+ if (pWin == WindowTable[pWin->drawable.pScreen->myNum])
+ pCursor = rootCursor;
+ else
+ pCursor = (CursorPtr) None;
+ }
+ else
+ {
+ pCursor = (CursorPtr)SecurityLookupIDByType(client, cursorID,
+ RT_CURSOR, SecurityReadAccess);
+ if (!pCursor)
+ {
+ error = BadCursor;
+ client->errorValue = cursorID;
+ goto PatchUp;
+ }
+ }
+
+ if (pCursor != wCursor (pWin))
+ {
+ /*
+ * patch up child windows so they don't lose cursors.
+ */
+
+ for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib)
+ {
+ if (!pChild->optional && !pChild->cursorIsNone &&
+ !MakeWindowOptional (pChild))
+ {
+ error = BadAlloc;
+ goto PatchUp;
+ }
+ }
+
+ pOldCursor = 0;
+ if (pCursor == (CursorPtr) None)
+ {
+ pWin->cursorIsNone = TRUE;
+ if (pWin->optional)
+ {
+ pOldCursor = pWin->optional->cursor;
+ pWin->optional->cursor = (CursorPtr) None;
+ checkOptional = TRUE;
+ }
+ } else {
+ if (!pWin->optional)
+ {
+ if (!MakeWindowOptional (pWin))
+ {
+ error = BadAlloc;
+ goto PatchUp;
+ }
+ }
+ else if (pWin->parent && pCursor == wCursor (pWin->parent))
+ checkOptional = TRUE;
+ pOldCursor = pWin->optional->cursor;
+ pWin->optional->cursor = pCursor;
+ pCursor->refcnt++;
+ pWin->cursorIsNone = FALSE;
+ /*
+ * check on any children now matching the new cursor
+ */
+
+ for (pChild=pWin->firstChild; pChild; pChild=pChild->nextSib)
+ {
+ if (pChild->optional &&
+ (pChild->optional->cursor == pCursor))
+ CheckWindowOptionalNeed (pChild);
+ }
+ }
+
+ if (pWin->realized)
+ WindowHasNewCursor( pWin);
+
+ /* Can't free cursor until here - old cursor
+ * is needed in WindowHasNewCursor
+ */
+ if (pOldCursor)
+ FreeCursor (pOldCursor, (Cursor)0);
+ }
+ break;
+ default:
+ error = BadValue;
+ client->errorValue = vmask;
+ goto PatchUp;
+ }
+ vmaskCopy |= index2;
+ }
+PatchUp:
+ if (checkOptional)
+ CheckWindowOptionalNeed (pWin);
+
+ /* We SHOULD check for an error value here XXX */
+ (*pScreen->ChangeWindowAttributes)(pWin, vmaskCopy);
+
+ /*
+ If the border contents have changed, redraw the border.
+ Note that this has to be done AFTER pScreen->ChangeWindowAttributes
+ for the tile to be rotated, and the correct function selected.
+ */
+ if (((vmaskCopy & (CWBorderPixel | CWBorderPixmap)) || borderRelative)
+ && pWin->viewable && HasBorder (pWin))
+ {
+ RegionRec exposed;
+
+ REGION_NULL(pScreen, &exposed);
+ REGION_SUBTRACT(pScreen, &exposed, &pWin->borderClip, &pWin->winSize);
+ (*pWin->drawable.pScreen->PaintWindowBorder)(pWin, &exposed, PW_BORDER);
+ REGION_UNINIT(pScreen, &exposed);
+ }
+ return error;
+}
+
+
+/*****
+ * GetWindowAttributes
+ * Notice that this is different than ChangeWindowAttributes
+ *****/
+
+void
+GetWindowAttributes(register WindowPtr pWin, ClientPtr client, xGetWindowAttributesReply *wa)
+{
+ wa->type = X_Reply;
+ wa->bitGravity = pWin->bitGravity;
+ wa->winGravity = pWin->winGravity;
+ if (pWin->forcedBS && pWin->backingStore != Always)
+ wa->backingStore = NotUseful;
+ else
+ wa->backingStore = pWin->backingStore;
+ wa->length = (sizeof(xGetWindowAttributesReply) -
+ sizeof(xGenericReply)) >> 2;
+ wa->sequenceNumber = client->sequence;
+ wa->backingBitPlanes = wBackingBitPlanes (pWin);
+ wa->backingPixel = wBackingPixel (pWin);
+ wa->saveUnder = (BOOL)pWin->saveUnder;
+ wa->override = pWin->overrideRedirect;
+ if (!pWin->mapped)
+ wa->mapState = IsUnmapped;
+ else if (pWin->realized)
+ wa->mapState = IsViewable;
+ else
+ wa->mapState = IsUnviewable;
+
+ wa->colormap = wColormap (pWin);
+ wa->mapInstalled = (wa->colormap == None) ? xFalse
+ : IsMapInstalled(wa->colormap, pWin);
+
+ wa->yourEventMask = EventMaskForClient(pWin, client);
+ wa->allEventMasks = pWin->eventMask | wOtherEventMasks (pWin);
+ wa->doNotPropagateMask = wDontPropagateMask (pWin);
+ wa->class = pWin->drawable.class;
+ wa->visualID = wVisual (pWin);
+}
+
+
+WindowPtr
+MoveWindowInStack(register WindowPtr pWin, register WindowPtr pNextSib)
+{
+ register WindowPtr pParent = pWin->parent;
+ WindowPtr pFirstChange = pWin; /* highest window where list changes */
+
+ if (pWin->nextSib != pNextSib)
+ {
+ WindowPtr pOldNextSib = pWin->nextSib;
+
+ if (!pNextSib) /* move to bottom */
+ {
+ if (pParent->firstChild == pWin)
+ pParent->firstChild = pWin->nextSib;
+ /* if (pWin->nextSib) */ /* is always True: pNextSib == NULL
+ * and pWin->nextSib != pNextSib
+ * therefore pWin->nextSib != NULL */
+ pFirstChange = pWin->nextSib;
+ pWin->nextSib->prevSib = pWin->prevSib;
+ if (pWin->prevSib)
+ pWin->prevSib->nextSib = pWin->nextSib;
+ pParent->lastChild->nextSib = pWin;
+ pWin->prevSib = pParent->lastChild;
+ pWin->nextSib = NullWindow;
+ pParent->lastChild = pWin;
+ }
+ else if (pParent->firstChild == pNextSib) /* move to top */
+ {
+ pFirstChange = pWin;
+ if (pParent->lastChild == pWin)
+ pParent->lastChild = pWin->prevSib;
+ if (pWin->nextSib)
+ pWin->nextSib->prevSib = pWin->prevSib;
+ if (pWin->prevSib)
+ pWin->prevSib->nextSib = pWin->nextSib;
+ pWin->nextSib = pParent->firstChild;
+ pWin->prevSib = (WindowPtr ) NULL;
+ pNextSib->prevSib = pWin;
+ pParent->firstChild = pWin;
+ }
+ else /* move in middle of list */
+ {
+ WindowPtr pOldNext = pWin->nextSib;
+
+ pFirstChange = NullWindow;
+ if (pParent->firstChild == pWin)
+ pFirstChange = pParent->firstChild = pWin->nextSib;
+ if (pParent->lastChild == pWin) {
+ pFirstChange = pWin;
+ pParent->lastChild = pWin->prevSib;
+ }
+ if (pWin->nextSib)
+ pWin->nextSib->prevSib = pWin->prevSib;
+ if (pWin->prevSib)
+ pWin->prevSib->nextSib = pWin->nextSib;
+ pWin->nextSib = pNextSib;
+ pWin->prevSib = pNextSib->prevSib;
+ if (pNextSib->prevSib)
+ pNextSib->prevSib->nextSib = pWin;
+ pNextSib->prevSib = pWin;
+ if (!pFirstChange) { /* do we know it yet? */
+ pFirstChange = pParent->firstChild; /* no, search from top */
+ while ((pFirstChange != pWin) && (pFirstChange != pOldNext))
+ pFirstChange = pFirstChange->nextSib;
+ }
+ }
+ if(pWin->drawable.pScreen->RestackWindow)
+ (*pWin->drawable.pScreen->RestackWindow)(pWin, pOldNextSib);
+ }
+
+#ifdef ROOTLESS
+ /*
+ * In rootless mode we can't optimize away window restacks.
+ * There may be non-X windows around, so even if the window
+ * is in the correct position from X's point of view,
+ * the underlying window system may want to reorder it.
+ */
+ else if (pWin->drawable.pScreen->RestackWindow)
+ (*pWin->drawable.pScreen->RestackWindow)(pWin, pWin->nextSib);
+#endif
+
+ return( pFirstChange );
+}
+
+RegionPtr
+CreateUnclippedWinSize (register WindowPtr pWin)
+{
+ RegionPtr pRgn;
+ BoxRec box;
+
+ box.x1 = pWin->drawable.x;
+ box.y1 = pWin->drawable.y;
+ box.x2 = pWin->drawable.x + (int) pWin->drawable.width;
+ box.y2 = pWin->drawable.y + (int) pWin->drawable.height;
+ pRgn = REGION_CREATE(pWin->drawable.pScreen, &box, 1);
+#ifdef SHAPE
+ if (wBoundingShape (pWin) || wClipShape (pWin)) {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ REGION_TRANSLATE(pScreen, pRgn, - pWin->drawable.x,
+ - pWin->drawable.y);
+ if (wBoundingShape (pWin))
+ REGION_INTERSECT(pScreen, pRgn, pRgn, wBoundingShape (pWin));
+ if (wClipShape (pWin))
+ REGION_INTERSECT(pScreen, pRgn, pRgn, wClipShape (pWin));
+ REGION_TRANSLATE(pScreen, pRgn, pWin->drawable.x, pWin->drawable.y);
+ }
+#endif
+ return pRgn;
+}
+
+void
+SetWinSize (register WindowPtr pWin)
+{
+#ifdef COMPOSITE
+ if (pWin->redirectDraw)
+ {
+ BoxRec box;
+
+ box.x1 = pWin->drawable.x;
+ box.y1 = pWin->drawable.y;
+ box.x2 = pWin->drawable.x + pWin->drawable.width;
+ box.y2 = pWin->drawable.y + pWin->drawable.height;
+ REGION_RESET (pScreen, &pWin->winSize, &box);
+ }
+ else
+#endif
+ ClippedRegionFromBox(pWin->parent, &pWin->winSize,
+ pWin->drawable.x, pWin->drawable.y,
+ (int)pWin->drawable.width,
+ (int)pWin->drawable.height);
+#ifdef SHAPE
+ if (wBoundingShape (pWin) || wClipShape (pWin)) {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ REGION_TRANSLATE(pScreen, &pWin->winSize, - pWin->drawable.x,
+ - pWin->drawable.y);
+ if (wBoundingShape (pWin))
+ REGION_INTERSECT(pScreen, &pWin->winSize, &pWin->winSize,
+ wBoundingShape (pWin));
+ if (wClipShape (pWin))
+ REGION_INTERSECT(pScreen, &pWin->winSize, &pWin->winSize,
+ wClipShape (pWin));
+ REGION_TRANSLATE(pScreen, &pWin->winSize, pWin->drawable.x,
+ pWin->drawable.y);
+ }
+#endif
+}
+
+void
+SetBorderSize (register WindowPtr pWin)
+{
+ int bw;
+
+ if (HasBorder (pWin)) {
+ bw = wBorderWidth (pWin);
+#ifdef COMPOSITE
+ if (pWin->redirectDraw)
+ {
+ BoxRec box;
+
+ box.x1 = pWin->drawable.x - bw;
+ box.y1 = pWin->drawable.y - bw;
+ box.x2 = pWin->drawable.x + pWin->drawable.width + bw;
+ box.y2 = pWin->drawable.y + pWin->drawable.height + bw;
+ REGION_RESET (pScreen, &pWin->borderSize, &box);
+ }
+ else
+#endif
+ ClippedRegionFromBox(pWin->parent, &pWin->borderSize,
+ pWin->drawable.x - bw, pWin->drawable.y - bw,
+ (int)(pWin->drawable.width + (bw<<1)),
+ (int)(pWin->drawable.height + (bw<<1)));
+#ifdef SHAPE
+ if (wBoundingShape (pWin)) {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ REGION_TRANSLATE(pScreen, &pWin->borderSize, - pWin->drawable.x,
+ - pWin->drawable.y);
+ REGION_INTERSECT(pScreen, &pWin->borderSize, &pWin->borderSize,
+ wBoundingShape (pWin));
+ REGION_TRANSLATE(pScreen, &pWin->borderSize, pWin->drawable.x,
+ pWin->drawable.y);
+ REGION_UNION(pScreen, &pWin->borderSize, &pWin->borderSize,
+ &pWin->winSize);
+ }
+#endif
+ } else {
+ REGION_COPY(pWin->drawable.pScreen, &pWin->borderSize,
+ &pWin->winSize);
+ }
+}
+
+/**
+ *
+ * \param x,y new window position
+ * \param oldx,oldy old window position
+ * \param destx,desty position relative to gravity
+ */
+
+void
+GravityTranslate (register int x, register int y, int oldx, int oldy,
+ int dw, int dh, unsigned gravity,
+ register int *destx, register int *desty)
+{
+ switch (gravity) {
+ case NorthGravity:
+ *destx = x + dw / 2;
+ *desty = y;
+ break;
+ case NorthEastGravity:
+ *destx = x + dw;
+ *desty = y;
+ break;
+ case WestGravity:
+ *destx = x;
+ *desty = y + dh / 2;
+ break;
+ case CenterGravity:
+ *destx = x + dw / 2;
+ *desty = y + dh / 2;
+ break;
+ case EastGravity:
+ *destx = x + dw;
+ *desty = y + dh / 2;
+ break;
+ case SouthWestGravity:
+ *destx = x;
+ *desty = y + dh;
+ break;
+ case SouthGravity:
+ *destx = x + dw / 2;
+ *desty = y + dh;
+ break;
+ case SouthEastGravity:
+ *destx = x + dw;
+ *desty = y + dh;
+ break;
+ case StaticGravity:
+ *destx = oldx;
+ *desty = oldy;
+ break;
+ default:
+ *destx = x;
+ *desty = y;
+ break;
+ }
+}
+
+/* XXX need to retile border on each window with ParentRelative origin */
+void
+ResizeChildrenWinSize(register WindowPtr pWin, int dx, int dy, int dw, int dh)
+{
+ register ScreenPtr pScreen;
+ register WindowPtr pSib, pChild;
+ Bool resized = (dw || dh);
+
+ pScreen = pWin->drawable.pScreen;
+
+ for (pSib = pWin->firstChild; pSib; pSib = pSib->nextSib)
+ {
+ if (resized && (pSib->winGravity > NorthWestGravity))
+ {
+ int cwsx, cwsy;
+
+ cwsx = pSib->origin.x;
+ cwsy = pSib->origin.y;
+ GravityTranslate (cwsx, cwsy, cwsx - dx, cwsy - dy, dw, dh,
+ pSib->winGravity, &cwsx, &cwsy);
+ if (cwsx != pSib->origin.x || cwsy != pSib->origin.y)
+ {
+ xEvent event;
+
+ event.u.u.type = GravityNotify;
+ event.u.gravity.window = pSib->drawable.id;
+ event.u.gravity.x = cwsx - wBorderWidth (pSib);
+ event.u.gravity.y = cwsy - wBorderWidth (pSib);
+ DeliverEvents (pSib, &event, 1, NullWindow);
+ pSib->origin.x = cwsx;
+ pSib->origin.y = cwsy;
+ }
+ }
+ pSib->drawable.x = pWin->drawable.x + pSib->origin.x;
+ pSib->drawable.y = pWin->drawable.y + pSib->origin.y;
+ SetWinSize (pSib);
+ SetBorderSize (pSib);
+ (*pScreen->PositionWindow)(pSib, pSib->drawable.x, pSib->drawable.y);
+
+ if ( (pChild = pSib->firstChild) )
+ {
+ while (1)
+ {
+ pChild->drawable.x = pChild->parent->drawable.x +
+ pChild->origin.x;
+ pChild->drawable.y = pChild->parent->drawable.y +
+ pChild->origin.y;
+ SetWinSize (pChild);
+ SetBorderSize (pChild);
+ (*pScreen->PositionWindow)(pChild,
+ pChild->drawable.x, pChild->drawable.y);
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ while (!pChild->nextSib && (pChild != pSib))
+ pChild = pChild->parent;
+ if (pChild == pSib)
+ break;
+ pChild = pChild->nextSib;
+ }
+ }
+ }
+}
+
+#define GET_INT16(m, f) \
+ if (m & mask) \
+ { \
+ f = (INT16) *pVlist;\
+ pVlist++; \
+ }
+#define GET_CARD16(m, f) \
+ if (m & mask) \
+ { \
+ f = (CARD16) *pVlist;\
+ pVlist++;\
+ }
+
+#define GET_CARD8(m, f) \
+ if (m & mask) \
+ { \
+ f = (CARD8) *pVlist;\
+ pVlist++;\
+ }
+
+#define ChangeMask ((Mask)(CWX | CWY | CWWidth | CWHeight))
+
+#define IllegalInputOnlyConfigureMask (CWBorderWidth)
+
+/*
+ * IsSiblingAboveMe
+ * returns Above if pSib above pMe in stack or Below otherwise
+ */
+
+static int
+IsSiblingAboveMe(
+ register WindowPtr pMe,
+ register WindowPtr pSib)
+{
+ register WindowPtr pWin;
+
+ pWin = pMe->parent->firstChild;
+ while (pWin)
+ {
+ if (pWin == pSib)
+ return(Above);
+ else if (pWin == pMe)
+ return(Below);
+ pWin = pWin->nextSib;
+ }
+ return(Below);
+}
+
+static BoxPtr
+WindowExtents(
+ register WindowPtr pWin,
+ register BoxPtr pBox)
+{
+ pBox->x1 = pWin->drawable.x - wBorderWidth (pWin);
+ pBox->y1 = pWin->drawable.y - wBorderWidth (pWin);
+ pBox->x2 = pWin->drawable.x + (int)pWin->drawable.width
+ + wBorderWidth (pWin);
+ pBox->y2 = pWin->drawable.y + (int)pWin->drawable.height
+ + wBorderWidth (pWin);
+ return(pBox);
+}
+
+#ifdef SHAPE
+#define IS_SHAPED(pWin) (wBoundingShape (pWin) != (RegionPtr) NULL)
+
+static RegionPtr
+MakeBoundingRegion (
+ register WindowPtr pWin,
+ BoxPtr pBox)
+{
+ RegionPtr pRgn;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ pRgn = REGION_CREATE(pScreen, pBox, 1);
+ if (wBoundingShape (pWin)) {
+ REGION_TRANSLATE(pScreen, pRgn, -pWin->origin.x,
+ -pWin->origin.y);
+ REGION_INTERSECT(pScreen, pRgn, pRgn, wBoundingShape (pWin));
+ REGION_TRANSLATE(pScreen, pRgn, pWin->origin.x,
+ pWin->origin.y);
+ }
+ return pRgn;
+}
+
+static Bool
+ShapeOverlap (
+ WindowPtr pWin,
+ BoxPtr pWinBox,
+ WindowPtr pSib,
+ BoxPtr pSibBox)
+{
+ RegionPtr pWinRgn, pSibRgn;
+ register ScreenPtr pScreen;
+ Bool ret;
+
+ if (!IS_SHAPED(pWin) && !IS_SHAPED(pSib))
+ return TRUE;
+ pScreen = pWin->drawable.pScreen;
+ pWinRgn = MakeBoundingRegion (pWin, pWinBox);
+ pSibRgn = MakeBoundingRegion (pSib, pSibBox);
+ REGION_INTERSECT(pScreen, pWinRgn, pWinRgn, pSibRgn);
+ ret = REGION_NOTEMPTY(pScreen, pWinRgn);
+ REGION_DESTROY(pScreen, pWinRgn);
+ REGION_DESTROY(pScreen, pSibRgn);
+ return ret;
+}
+#endif
+
+static Bool
+AnyWindowOverlapsMe(
+ WindowPtr pWin,
+ WindowPtr pHead,
+ register BoxPtr box)
+{
+ register WindowPtr pSib;
+ BoxRec sboxrec;
+ register BoxPtr sbox;
+
+ for (pSib = pWin->prevSib; pSib != pHead; pSib = pSib->prevSib)
+ {
+ if (pSib->mapped)
+ {
+ sbox = WindowExtents(pSib, &sboxrec);
+ if (BOXES_OVERLAP(sbox, box)
+#ifdef SHAPE
+ && ShapeOverlap (pWin, box, pSib, sbox)
+#endif
+ )
+ return(TRUE);
+ }
+ }
+ return(FALSE);
+}
+
+static Bool
+IOverlapAnyWindow(
+ WindowPtr pWin,
+ register BoxPtr box)
+{
+ register WindowPtr pSib;
+ BoxRec sboxrec;
+ register BoxPtr sbox;
+
+ for (pSib = pWin->nextSib; pSib; pSib = pSib->nextSib)
+ {
+ if (pSib->mapped)
+ {
+ sbox = WindowExtents(pSib, &sboxrec);
+ if (BOXES_OVERLAP(sbox, box)
+#ifdef SHAPE
+ && ShapeOverlap (pWin, box, pSib, sbox)
+#endif
+ )
+ return(TRUE);
+ }
+ }
+ return(FALSE);
+}
+
+/*
+ * WhereDoIGoInTheStack()
+ * Given pWin and pSib and the relationshipe smode, return
+ * the window that pWin should go ABOVE.
+ * If a pSib is specified:
+ * Above: pWin is placed just above pSib
+ * Below: pWin is placed just below pSib
+ * TopIf: if pSib occludes pWin, then pWin is placed
+ * at the top of the stack
+ * BottomIf: if pWin occludes pSib, then pWin is
+ * placed at the bottom of the stack
+ * Opposite: if pSib occludes pWin, then pWin is placed at the
+ * top of the stack, else if pWin occludes pSib, then
+ * pWin is placed at the bottom of the stack
+ *
+ * If pSib is NULL:
+ * Above: pWin is placed at the top of the stack
+ * Below: pWin is placed at the bottom of the stack
+ * TopIf: if any sibling occludes pWin, then pWin is placed at
+ * the top of the stack
+ * BottomIf: if pWin occludes any sibline, then pWin is placed at
+ * the bottom of the stack
+ * Opposite: if any sibling occludes pWin, then pWin is placed at
+ * the top of the stack, else if pWin occludes any
+ * sibling, then pWin is placed at the bottom of the stack
+ *
+ */
+
+static WindowPtr
+WhereDoIGoInTheStack(
+ register WindowPtr pWin,
+ register WindowPtr pSib,
+ short x,
+ short y,
+ unsigned short w,
+ unsigned short h,
+ int smode)
+{
+ BoxRec box;
+ register ScreenPtr pScreen;
+ WindowPtr pHead, pFirst;
+
+ if ((pWin == pWin->parent->firstChild) &&
+ (pWin == pWin->parent->lastChild))
+ return((WindowPtr ) NULL);
+ pHead = RealChildHead(pWin->parent);
+ pFirst = pHead ? pHead->nextSib : pWin->parent->firstChild;
+ pScreen = pWin->drawable.pScreen;
+ box.x1 = x;
+ box.y1 = y;
+ box.x2 = x + (int)w;
+ box.y2 = y + (int)h;
+ switch (smode)
+ {
+ case Above:
+ if (pSib)
+ return(pSib);
+ else if (pWin == pFirst)
+ return(pWin->nextSib);
+ else
+ return(pFirst);
+ case Below:
+ if (pSib)
+ if (pSib->nextSib != pWin)
+ return(pSib->nextSib);
+ else
+ return(pWin->nextSib);
+ else
+ return NullWindow;
+ case TopIf:
+ if ((!pWin->mapped || (pSib && !pSib->mapped)) && !permitOldBugs)
+ return(pWin->nextSib);
+ else if (pSib)
+ {
+ if ((IsSiblingAboveMe(pWin, pSib) == Above) &&
+ (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT))
+ return(pFirst);
+ else
+ return(pWin->nextSib);
+ }
+ else if (AnyWindowOverlapsMe(pWin, pHead, &box))
+ return(pFirst);
+ else
+ return(pWin->nextSib);
+ case BottomIf:
+ if ((!pWin->mapped || (pSib && !pSib->mapped)) && !permitOldBugs)
+ return(pWin->nextSib);
+ else if (pSib)
+ {
+ if ((IsSiblingAboveMe(pWin, pSib) == Below) &&
+ (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT))
+ return NullWindow;
+ else
+ return(pWin->nextSib);
+ }
+ else if (IOverlapAnyWindow(pWin, &box))
+ return NullWindow;
+ else
+ return(pWin->nextSib);
+ case Opposite:
+ if ((!pWin->mapped || (pSib && !pSib->mapped)) && !permitOldBugs)
+ return(pWin->nextSib);
+ else if (pSib)
+ {
+ if (RECT_IN_REGION(pScreen, &pSib->borderSize, &box) != rgnOUT)
+ {
+ if (IsSiblingAboveMe(pWin, pSib) == Above)
+ return(pFirst);
+ else
+ return NullWindow;
+ }
+ else
+ return(pWin->nextSib);
+ }
+ else if (AnyWindowOverlapsMe(pWin, pHead, &box))
+ {
+ /* If I'm occluded, I can't possibly be the first child
+ * if (pWin == pWin->parent->firstChild)
+ * return pWin->nextSib;
+ */
+ return(pFirst);
+ }
+ else if (IOverlapAnyWindow(pWin, &box))
+ return NullWindow;
+ else
+ return pWin->nextSib;
+ default:
+ {
+ ErrorF("Internal error in ConfigureWindow, smode == %d\n",smode );
+ return pWin->nextSib;
+ }
+ }
+}
+
+static void
+ReflectStackChange(
+ register WindowPtr pWin,
+ register WindowPtr pSib,
+ VTKind kind)
+{
+/* Note that pSib might be NULL */
+
+ Bool WasViewable = (Bool)pWin->viewable;
+ Bool anyMarked;
+ WindowPtr pFirstChange;
+#ifdef DO_SAVE_UNDERS
+ Bool dosave = FALSE;
+#endif
+ WindowPtr pLayerWin;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ /* if this is a root window, can't be restacked */
+ if (!pWin->parent)
+ return;
+
+ pFirstChange = MoveWindowInStack(pWin, pSib);
+
+ if (WasViewable)
+ {
+ anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange,
+ &pLayerWin);
+ if (pLayerWin != pWin) pFirstChange = pLayerWin;
+#ifdef DO_SAVE_UNDERS
+ if (DO_SAVE_UNDERS(pWin))
+ {
+ dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pFirstChange);
+ }
+#endif /* DO_SAVE_UNDERS */
+ if (anyMarked)
+ {
+ (*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, kind);
+ (*pScreen->HandleExposures)(pLayerWin->parent);
+ }
+#ifdef DO_SAVE_UNDERS
+ if (dosave)
+ (*pScreen->PostChangeSaveUnder)(pLayerWin, pFirstChange);
+#endif /* DO_SAVE_UNDERS */
+ if (anyMarked && pWin->drawable.pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange, kind);
+ }
+ if (pWin->realized)
+ WindowsRestructured ();
+}
+
+/*****
+ * ConfigureWindow
+ *****/
+
+int
+ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientPtr client)
+{
+#define RESTACK_WIN 0
+#define MOVE_WIN 1
+#define RESIZE_WIN 2
+#define REBORDER_WIN 3
+ register WindowPtr pSib = NullWindow;
+ register WindowPtr pParent = pWin->parent;
+ Window sibwid = 0;
+ Mask index2, tmask;
+ register XID *pVlist;
+ short x, y, beforeX, beforeY;
+ unsigned short w = pWin->drawable.width,
+ h = pWin->drawable.height,
+ bw = pWin->borderWidth;
+ int action, smode = Above;
+#ifdef XAPPGROUP
+ ClientPtr win_owner;
+ ClientPtr ag_leader = NULL;
+#endif
+ xEvent event;
+
+ if ((pWin->drawable.class == InputOnly) && (mask & IllegalInputOnlyConfigureMask))
+ return(BadMatch);
+
+ if ((mask & CWSibling) && !(mask & CWStackMode))
+ return(BadMatch);
+
+ pVlist = vlist;
+
+ if (pParent)
+ {
+ x = pWin->drawable.x - pParent->drawable.x - (int)bw;
+ y = pWin->drawable.y - pParent->drawable.y - (int)bw;
+ }
+ else
+ {
+ x = pWin->drawable.x;
+ y = pWin->drawable.y;
+ }
+ beforeX = x;
+ beforeY = y;
+ action = RESTACK_WIN;
+ if ((mask & (CWX | CWY)) && (!(mask & (CWHeight | CWWidth))))
+ {
+ GET_INT16(CWX, x);
+ GET_INT16(CWY, y);
+ action = MOVE_WIN;
+ }
+ /* or should be resized */
+ else if (mask & (CWX | CWY | CWWidth | CWHeight))
+ {
+ GET_INT16(CWX, x);
+ GET_INT16(CWY, y);
+ GET_CARD16(CWWidth, w);
+ GET_CARD16 (CWHeight, h);
+ if (!w || !h)
+ {
+ client->errorValue = 0;
+ return BadValue;
+ }
+ action = RESIZE_WIN;
+ }
+ tmask = mask & ~ChangeMask;
+ while (tmask)
+ {
+ index2 = (Mask)lowbit (tmask);
+ tmask &= ~index2;
+ switch (index2)
+ {
+ case CWBorderWidth:
+ GET_CARD16(CWBorderWidth, bw);
+ break;
+ case CWSibling:
+ sibwid = (Window ) *pVlist;
+ pVlist++;
+ pSib = (WindowPtr )SecurityLookupIDByType(client, sibwid,
+ RT_WINDOW, SecurityReadAccess);
+ if (!pSib)
+ {
+ client->errorValue = sibwid;
+ return(BadWindow);
+ }
+ if (pSib->parent != pParent)
+ return(BadMatch);
+ if (pSib == pWin)
+ return(BadMatch);
+ break;
+ case CWStackMode:
+ GET_CARD8(CWStackMode, smode);
+ if ((smode != TopIf) && (smode != BottomIf) &&
+ (smode != Opposite) && (smode != Above) && (smode != Below))
+ {
+ client->errorValue = smode;
+ return(BadValue);
+ }
+ break;
+ default:
+ client->errorValue = mask;
+ return(BadValue);
+ }
+ }
+ /* root really can't be reconfigured, so just return */
+ if (!pParent)
+ return Success;
+
+ /* Figure out if the window should be moved. Doesnt
+ make the changes to the window if event sent */
+
+ if (mask & CWStackMode)
+ pSib = WhereDoIGoInTheStack(pWin, pSib, pParent->drawable.x + x,
+ pParent->drawable.y + y,
+ w + (bw << 1), h + (bw << 1), smode);
+ else
+ pSib = pWin->nextSib;
+
+#ifdef XAPPGROUP
+ win_owner = clients[CLIENT_ID(pWin->drawable.id)];
+ ag_leader = XagLeader (win_owner);
+#endif
+
+ if ((!pWin->overrideRedirect) &&
+ (RedirectSend(pParent)
+#ifdef XAPPGROUP
+ || (win_owner->appgroup && ag_leader &&
+ XagIsControlledRoot (client, pParent))
+#endif
+ ))
+ {
+ event.u.u.type = ConfigureRequest;
+ event.u.configureRequest.window = pWin->drawable.id;
+ if (mask & CWSibling)
+ event.u.configureRequest.sibling = sibwid;
+ else
+ event.u.configureRequest.sibling = None;
+ if (mask & CWStackMode)
+ event.u.u.detail = smode;
+ else
+ event.u.u.detail = Above;
+ event.u.configureRequest.x = x;
+ event.u.configureRequest.y = y;
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && (!pParent || !pParent->parent)) {
+ event.u.configureRequest.x += panoramiXdataPtr[0].x;
+ event.u.configureRequest.y += panoramiXdataPtr[0].y;
+ }
+#endif
+ event.u.configureRequest.width = w;
+ event.u.configureRequest.height = h;
+ event.u.configureRequest.borderWidth = bw;
+ event.u.configureRequest.valueMask = mask;
+#ifdef XAPPGROUP
+ /* make sure if the ag_leader maps the window it goes to the wm */
+ if (ag_leader && ag_leader != client &&
+ XagIsControlledRoot (client, pParent)) {
+ event.u.configureRequest.parent = XagId (win_owner);
+ (void) TryClientEvents (ag_leader, &event, 1,
+ NoEventMask, NoEventMask, NullGrab);
+ return Success;
+ }
+#endif
+ event.u.configureRequest.parent = pParent->drawable.id;
+ if (MaybeDeliverEventsToClient(pParent, &event, 1,
+ SubstructureRedirectMask, client) == 1)
+ return(Success);
+ }
+ if (action == RESIZE_WIN)
+ {
+ Bool size_change = (w != pWin->drawable.width)
+ || (h != pWin->drawable.height);
+ if (size_change && ((pWin->eventMask|wOtherEventMasks(pWin)) & ResizeRedirectMask))
+ {
+ xEvent eventT;
+ eventT.u.u.type = ResizeRequest;
+ eventT.u.resizeRequest.window = pWin->drawable.id;
+ eventT.u.resizeRequest.width = w;
+ eventT.u.resizeRequest.height = h;
+ if (MaybeDeliverEventsToClient(pWin, &eventT, 1,
+ ResizeRedirectMask, client) == 1)
+ {
+ /* if event is delivered, leave the actual size alone. */
+ w = pWin->drawable.width;
+ h = pWin->drawable.height;
+ size_change = FALSE;
+ }
+ }
+ if (!size_change)
+ {
+ if (mask & (CWX | CWY))
+ action = MOVE_WIN;
+ else if (mask & (CWStackMode | CWBorderWidth))
+ action = RESTACK_WIN;
+ else /* really nothing to do */
+ return(Success) ;
+ }
+ }
+
+ if (action == RESIZE_WIN)
+ /* we've already checked whether there's really a size change */
+ goto ActuallyDoSomething;
+ if ((mask & CWX) && (x != beforeX))
+ goto ActuallyDoSomething;
+ if ((mask & CWY) && (y != beforeY))
+ goto ActuallyDoSomething;
+ if ((mask & CWBorderWidth) && (bw != wBorderWidth (pWin)))
+ goto ActuallyDoSomething;
+ if (mask & CWStackMode)
+ {
+#ifndef ROOTLESS
+ /* See above for why we always reorder in rootless mode. */
+ if (pWin->nextSib != pSib)
+#endif
+ goto ActuallyDoSomething;
+ }
+ return(Success);
+
+ActuallyDoSomething:
+ if (SubStrSend(pWin, pParent))
+ {
+ event.u.u.type = ConfigureNotify;
+ event.u.configureNotify.window = pWin->drawable.id;
+ if (pSib)
+ event.u.configureNotify.aboveSibling = pSib->drawable.id;
+ else
+ event.u.configureNotify.aboveSibling = None;
+ event.u.configureNotify.x = x;
+ event.u.configureNotify.y = y;
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && (!pParent || !pParent->parent)) {
+ event.u.configureNotify.x += panoramiXdataPtr[0].x;
+ event.u.configureNotify.y += panoramiXdataPtr[0].y;
+ }
+#endif
+ event.u.configureNotify.width = w;
+ event.u.configureNotify.height = h;
+ event.u.configureNotify.borderWidth = bw;
+ event.u.configureNotify.override = pWin->overrideRedirect;
+ DeliverEvents(pWin, &event, 1, NullWindow);
+ }
+ if (mask & CWBorderWidth)
+ {
+ if (action == RESTACK_WIN)
+ {
+ action = MOVE_WIN;
+ pWin->borderWidth = bw;
+ }
+ else if ((action == MOVE_WIN) &&
+ (beforeX + wBorderWidth (pWin) == x + (int)bw) &&
+ (beforeY + wBorderWidth (pWin) == y + (int)bw))
+ {
+ action = REBORDER_WIN;
+ (*pWin->drawable.pScreen->ChangeBorderWidth)(pWin, bw);
+ }
+ else
+ pWin->borderWidth = bw;
+ }
+ if (action == MOVE_WIN)
+ (*pWin->drawable.pScreen->MoveWindow)(pWin, x, y, pSib,
+ (mask & CWBorderWidth) ? VTOther : VTMove);
+ else if (action == RESIZE_WIN)
+ (*pWin->drawable.pScreen->ResizeWindow)(pWin, x, y, w, h, pSib);
+ else if (mask & CWStackMode)
+ ReflectStackChange(pWin, pSib, VTOther);
+
+ if (action != RESTACK_WIN)
+ CheckCursorConfinement(pWin);
+ return(Success);
+#undef RESTACK_WIN
+#undef MOVE_WIN
+#undef RESIZE_WIN
+#undef REBORDER_WIN
+}
+
+
+/******
+ *
+ * CirculateWindow
+ * For RaiseLowest, raises the lowest mapped child (if any) that is
+ * obscured by another child to the top of the stack. For LowerHighest,
+ * lowers the highest mapped child (if any) that is obscuring another
+ * child to the bottom of the stack. Exposure processing is performed
+ *
+ ******/
+
+int
+CirculateWindow(WindowPtr pParent, int direction, ClientPtr client)
+{
+ register WindowPtr pWin, pHead, pFirst;
+ xEvent event;
+ BoxRec box;
+
+ pHead = RealChildHead(pParent);
+ pFirst = pHead ? pHead->nextSib : pParent->firstChild;
+ if (direction == RaiseLowest)
+ {
+ for (pWin = pParent->lastChild;
+ (pWin != pHead) &&
+ !(pWin->mapped &&
+ AnyWindowOverlapsMe(pWin, pHead, WindowExtents(pWin, &box)));
+ pWin = pWin->prevSib) ;
+ if (pWin == pHead)
+ return Success;
+ }
+ else
+ {
+ for (pWin = pFirst;
+ pWin &&
+ !(pWin->mapped &&
+ IOverlapAnyWindow(pWin, WindowExtents(pWin, &box)));
+ pWin = pWin->nextSib) ;
+ if (!pWin)
+ return Success;
+ }
+
+ event.u.circulate.window = pWin->drawable.id;
+ event.u.circulate.parent = pParent->drawable.id;
+ event.u.circulate.event = pParent->drawable.id;
+ if (direction == RaiseLowest)
+ event.u.circulate.place = PlaceOnTop;
+ else
+ event.u.circulate.place = PlaceOnBottom;
+
+ if (RedirectSend(pParent))
+ {
+ event.u.u.type = CirculateRequest;
+ if (MaybeDeliverEventsToClient(pParent, &event, 1,
+ SubstructureRedirectMask, client) == 1)
+ return(Success);
+ }
+
+ event.u.u.type = CirculateNotify;
+ DeliverEvents(pWin, &event, 1, NullWindow);
+ ReflectStackChange(pWin,
+ (direction == RaiseLowest) ? pFirst : NullWindow,
+ VTStack);
+
+ return(Success);
+}
+
+static int
+CompareWIDs(
+ WindowPtr pWin,
+ pointer value) /* must conform to VisitWindowProcPtr */
+{
+ Window *wid = (Window *)value;
+
+ if (pWin->drawable.id == *wid)
+ return(WT_STOPWALKING);
+ else
+ return(WT_WALKCHILDREN);
+}
+
+/*****
+ * ReparentWindow
+ *****/
+
+int
+ReparentWindow(register WindowPtr pWin, register WindowPtr pParent,
+ int x, int y, ClientPtr client)
+{
+ WindowPtr pPrev, pPriorParent;
+ Bool WasMapped = (Bool)(pWin->mapped);
+ xEvent event;
+ int bw = wBorderWidth (pWin);
+ register ScreenPtr pScreen;
+
+ pScreen = pWin->drawable.pScreen;
+ if (TraverseTree(pWin, CompareWIDs, (pointer)&pParent->drawable.id) == WT_STOPWALKING)
+ return(BadMatch);
+ if (!MakeWindowOptional(pWin))
+ return(BadAlloc);
+
+ if (WasMapped)
+ UnmapWindow(pWin, FALSE);
+
+ event.u.u.type = ReparentNotify;
+ event.u.reparent.window = pWin->drawable.id;
+ event.u.reparent.parent = pParent->drawable.id;
+ event.u.reparent.x = x;
+ event.u.reparent.y = y;
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && !pParent->parent) {
+ event.u.reparent.x += panoramiXdataPtr[0].x;
+ event.u.reparent.y += panoramiXdataPtr[0].y;
+ }
+#endif
+ event.u.reparent.override = pWin->overrideRedirect;
+ DeliverEvents(pWin, &event, 1, pParent);
+
+ /* take out of sibling chain */
+
+ pPriorParent = pPrev = pWin->parent;
+ if (pPrev->firstChild == pWin)
+ pPrev->firstChild = pWin->nextSib;
+ if (pPrev->lastChild == pWin)
+ pPrev->lastChild = pWin->prevSib;
+
+ if (pWin->nextSib)
+ pWin->nextSib->prevSib = pWin->prevSib;
+ if (pWin->prevSib)
+ pWin->prevSib->nextSib = pWin->nextSib;
+
+ /* insert at begining of pParent */
+ pWin->parent = pParent;
+ pPrev = RealChildHead(pParent);
+ if (pPrev)
+ {
+ pWin->nextSib = pPrev->nextSib;
+ if (pPrev->nextSib)
+ pPrev->nextSib->prevSib = pWin;
+ else
+ pParent->lastChild = pWin;
+ pPrev->nextSib = pWin;
+ pWin->prevSib = pPrev;
+ }
+ else
+ {
+ pWin->nextSib = pParent->firstChild;
+ pWin->prevSib = NullWindow;
+ if (pParent->firstChild)
+ pParent->firstChild->prevSib = pWin;
+ else
+ pParent->lastChild = pWin;
+ pParent->firstChild = pWin;
+ }
+
+ pWin->origin.x = x + bw;
+ pWin->origin.y = y + bw;
+ pWin->drawable.x = x + bw + pParent->drawable.x;
+ pWin->drawable.y = y + bw + pParent->drawable.y;
+
+ /* clip to parent */
+ SetWinSize (pWin);
+ SetBorderSize (pWin);
+
+ if (pScreen->ReparentWindow)
+ (*pScreen->ReparentWindow)(pWin, pPriorParent);
+ (*pScreen->PositionWindow)(pWin, pWin->drawable.x, pWin->drawable.y);
+ ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
+
+ CheckWindowOptionalNeed(pWin);
+
+ if (WasMapped)
+ MapWindow(pWin, client);
+ RecalculateDeliverableEvents(pWin);
+ return(Success);
+}
+
+static void
+RealizeTree(WindowPtr pWin)
+{
+ register WindowPtr pChild;
+ RealizeWindowProcPtr Realize;
+
+ Realize = pWin->drawable.pScreen->RealizeWindow;
+ pChild = pWin;
+ while (1)
+ {
+ if (pChild->mapped)
+ {
+ pChild->realized = TRUE;
+#ifdef DO_SAVE_UNDERS
+ if (pChild->saveUnder)
+ deltaSaveUndersViewable++;
+#endif
+ pChild->viewable = (pChild->drawable.class == InputOutput);
+ (* Realize)(pChild);
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ while (!pChild->nextSib && (pChild != pWin))
+ pChild = pChild->parent;
+ if (pChild == pWin)
+ return;
+ pChild = pChild->nextSib;
+ }
+}
+
+/*****
+ * MapWindow
+ * If some other client has selected SubStructureReDirect on the parent
+ * and override-redirect is xFalse, then a MapRequest event is generated,
+ * but the window remains unmapped. Otherwise, the window is mapped and a
+ * MapNotify event is generated.
+ *****/
+
+int
+MapWindow(register WindowPtr pWin, ClientPtr client)
+{
+ register ScreenPtr pScreen;
+
+ register WindowPtr pParent;
+#ifdef DO_SAVE_UNDERS
+ Bool dosave = FALSE;
+#endif
+ WindowPtr pLayerWin;
+
+ if (pWin->mapped)
+ return(Success);
+
+#ifdef XCSECURITY
+ /* don't let an untrusted client map a child-of-trusted-window, InputOnly
+ * window; too easy to steal device input
+ */
+ if ( (client->trustLevel != XSecurityClientTrusted) &&
+ (pWin->drawable.class == InputOnly) &&
+ (wClient(pWin->parent)->trustLevel == XSecurityClientTrusted) )
+ return Success;
+#endif
+
+ pScreen = pWin->drawable.pScreen;
+ if ( (pParent = pWin->parent) )
+ {
+ xEvent event;
+ Bool anyMarked;
+#ifdef XAPPGROUP
+ ClientPtr win_owner = clients[CLIENT_ID(pWin->drawable.id)];
+ ClientPtr ag_leader = XagLeader (win_owner);
+#endif
+
+ if ((!pWin->overrideRedirect) &&
+ (RedirectSend(pParent)
+#ifdef XAPPGROUP
+ || (win_owner->appgroup && ag_leader &&
+ XagIsControlledRoot (client, pParent))
+#endif
+ ))
+ {
+ event.u.u.type = MapRequest;
+ event.u.mapRequest.window = pWin->drawable.id;
+#ifdef XAPPGROUP
+ /* make sure if the ag_leader maps the window it goes to the wm */
+ if (ag_leader && ag_leader != client &&
+ XagIsControlledRoot (client, pParent)) {
+ event.u.mapRequest.parent = XagId (win_owner);
+ (void) TryClientEvents (ag_leader, &event, 1,
+ NoEventMask, NoEventMask, NullGrab);
+ return Success;
+ }
+#endif
+ event.u.mapRequest.parent = pParent->drawable.id;
+
+ if (MaybeDeliverEventsToClient(pParent, &event, 1,
+ SubstructureRedirectMask, client) == 1)
+ return(Success);
+ }
+
+ pWin->mapped = TRUE;
+ if (SubStrSend(pWin, pParent))
+ {
+ event.u.u.type = MapNotify;
+ event.u.mapNotify.window = pWin->drawable.id;
+ event.u.mapNotify.override = pWin->overrideRedirect;
+ DeliverEvents(pWin, &event, 1, NullWindow);
+ }
+
+ if (!pParent->realized)
+ return(Success);
+ RealizeTree(pWin);
+ if (pWin->viewable)
+ {
+ anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin,
+ &pLayerWin);
+#ifdef DO_SAVE_UNDERS
+ if (DO_SAVE_UNDERS(pWin))
+ {
+ dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib);
+ }
+#endif /* DO_SAVE_UNDERS */
+ if (anyMarked)
+ {
+ (*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTMap);
+ (*pScreen->HandleExposures)(pLayerWin->parent);
+ }
+#ifdef DO_SAVE_UNDERS
+ if (dosave)
+ (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib);
+#endif /* DO_SAVE_UNDERS */
+ if (anyMarked && pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin, VTMap);
+ }
+ WindowsRestructured ();
+ }
+ else
+ {
+ RegionRec temp;
+
+ pWin->mapped = TRUE;
+ pWin->realized = TRUE; /* for roots */
+ pWin->viewable = pWin->drawable.class == InputOutput;
+ /* We SHOULD check for an error value here XXX */
+ (*pScreen->RealizeWindow)(pWin);
+ if (pScreen->ClipNotify)
+ (*pScreen->ClipNotify) (pWin, 0, 0);
+ if (pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(NullWindow, pWin, VTMap);
+ REGION_NULL(pScreen, &temp);
+ REGION_COPY(pScreen, &temp, &pWin->clipList);
+ (*pScreen->WindowExposures) (pWin, &temp, NullRegion);
+ REGION_UNINIT(pScreen, &temp);
+ }
+
+ return(Success);
+}
+
+
+/*****
+ * MapSubwindows
+ * Performs a MapWindow all unmapped children of the window, in top
+ * to bottom stacking order.
+ *****/
+
+void
+MapSubwindows(register WindowPtr pParent, ClientPtr client)
+{
+ register WindowPtr pWin;
+ WindowPtr pFirstMapped = NullWindow;
+#ifdef DO_SAVE_UNDERS
+ WindowPtr pFirstSaveUndered = NullWindow;
+#endif
+ register ScreenPtr pScreen;
+ register Mask parentRedirect;
+ register Mask parentNotify;
+ xEvent event;
+ Bool anyMarked;
+#ifdef DO_SAVE_UNDERS
+ Bool dosave = FALSE;
+#endif
+ WindowPtr pLayerWin;
+
+ pScreen = pParent->drawable.pScreen;
+ parentRedirect = RedirectSend(pParent);
+ parentNotify = SubSend(pParent);
+ anyMarked = FALSE;
+ for (pWin = pParent->firstChild; pWin; pWin = pWin->nextSib)
+ {
+ if (!pWin->mapped)
+ {
+ if (parentRedirect && !pWin->overrideRedirect)
+ {
+ event.u.u.type = MapRequest;
+ event.u.mapRequest.window = pWin->drawable.id;
+ event.u.mapRequest.parent = pParent->drawable.id;
+
+ if (MaybeDeliverEventsToClient(pParent, &event, 1,
+ SubstructureRedirectMask, client) == 1)
+ continue;
+ }
+
+ pWin->mapped = TRUE;
+ if (parentNotify || StrSend(pWin))
+ {
+ event.u.u.type = MapNotify;
+ event.u.mapNotify.window = pWin->drawable.id;
+ event.u.mapNotify.override = pWin->overrideRedirect;
+ DeliverEvents(pWin, &event, 1, NullWindow);
+ }
+
+ if (!pFirstMapped)
+ pFirstMapped = pWin;
+ if (pParent->realized)
+ {
+ RealizeTree(pWin);
+ if (pWin->viewable)
+ {
+ anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin,
+ (WindowPtr *)NULL);
+#ifdef DO_SAVE_UNDERS
+ if (DO_SAVE_UNDERS(pWin))
+ {
+ dosave = TRUE;
+ }
+#endif /* DO_SAVE_UNDERS */
+ }
+ }
+ }
+ }
+
+ if (pFirstMapped)
+ {
+ pLayerWin = (*pScreen->GetLayerWindow)(pParent);
+ if (pLayerWin->parent != pParent) {
+ anyMarked |= (*pScreen->MarkOverlappedWindows)(pLayerWin,
+ pLayerWin,
+ (WindowPtr *)NULL);
+ pFirstMapped = pLayerWin;
+ }
+ if (anyMarked)
+ {
+#ifdef DO_SAVE_UNDERS
+ if (pLayerWin->parent != pParent)
+ {
+ if (dosave || (DO_SAVE_UNDERS(pLayerWin)))
+ {
+ dosave = (*pScreen->ChangeSaveUnder)(pLayerWin,
+ pLayerWin);
+ }
+ }
+ else if (dosave)
+ {
+ dosave = FALSE;
+ for (pWin = pParent->firstChild; pWin; pWin = pWin->nextSib)
+ {
+ if (DO_SAVE_UNDERS(pWin))
+ {
+ dosave |= (*pScreen->ChangeSaveUnder)(pWin,
+ pWin->nextSib);
+ if (dosave && !pFirstSaveUndered)
+ pFirstSaveUndered = pWin;
+ }
+ }
+ }
+#endif /* DO_SAVE_UNDERS */
+ (*pScreen->ValidateTree)(pLayerWin->parent, pFirstMapped, VTMap);
+ (*pScreen->HandleExposures)(pLayerWin->parent);
+ }
+#ifdef DO_SAVE_UNDERS
+ if (dosave)
+ (*pScreen->PostChangeSaveUnder)(pLayerWin,
+ pFirstSaveUndered->nextSib);
+#endif /* DO_SAVE_UNDERS */
+ if (anyMarked && pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstMapped,
+ VTMap);
+ WindowsRestructured ();
+ }
+}
+
+static void
+UnrealizeTree(
+ WindowPtr pWin,
+ Bool fromConfigure)
+{
+ register WindowPtr pChild;
+ UnrealizeWindowProcPtr Unrealize;
+ MarkUnrealizedWindowProcPtr MarkUnrealizedWindow;
+
+ Unrealize = pWin->drawable.pScreen->UnrealizeWindow;
+ MarkUnrealizedWindow = pWin->drawable.pScreen->MarkUnrealizedWindow;
+ pChild = pWin;
+ while (1)
+ {
+ if (pChild->realized)
+ {
+ pChild->realized = FALSE;
+ pChild->visibility = VisibilityNotViewable;
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension && !pChild->drawable.pScreen->myNum) {
+ PanoramiXRes *win;
+ win = (PanoramiXRes*)LookupIDByType(pChild->drawable.id,
+ XRT_WINDOW);
+ if(win)
+ win->u.win.visibility = VisibilityNotViewable;
+ }
+#endif
+ (* Unrealize)(pChild);
+ DeleteWindowFromAnyEvents(pChild, FALSE);
+ if (pChild->viewable)
+ {
+#ifdef DO_SAVE_UNDERS
+ if (pChild->saveUnder)
+ deltaSaveUndersViewable--;
+#endif
+ pChild->viewable = FALSE;
+ if (pChild->backStorage)
+ (*pChild->drawable.pScreen->SaveDoomedAreas)(
+ pChild, &pChild->clipList, 0, 0);
+ (* MarkUnrealizedWindow)(pChild, pWin, fromConfigure);
+ pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ }
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ while (!pChild->nextSib && (pChild != pWin))
+ pChild = pChild->parent;
+ if (pChild == pWin)
+ return;
+ pChild = pChild->nextSib;
+ }
+}
+
+/*****
+ * UnmapWindow
+ * If the window is already unmapped, this request has no effect.
+ * Otherwise, the window is unmapped and an UnMapNotify event is
+ * generated. Cannot unmap a root window.
+ *****/
+
+int
+UnmapWindow(register WindowPtr pWin, Bool fromConfigure)
+{
+ register WindowPtr pParent;
+ xEvent event;
+ Bool wasRealized = (Bool)pWin->realized;
+ Bool wasViewable = (Bool)pWin->viewable;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pLayerWin = pWin;
+
+ if ((!pWin->mapped) || (!(pParent = pWin->parent)))
+ return(Success);
+ if (SubStrSend(pWin, pParent))
+ {
+ event.u.u.type = UnmapNotify;
+ event.u.unmapNotify.window = pWin->drawable.id;
+ event.u.unmapNotify.fromConfigure = fromConfigure;
+ DeliverEvents(pWin, &event, 1, NullWindow);
+ }
+ if (wasViewable && !fromConfigure)
+ {
+ pWin->valdata = UnmapValData;
+ (*pScreen->MarkOverlappedWindows)(pWin, pWin->nextSib, &pLayerWin);
+ (*pScreen->MarkWindow)(pLayerWin->parent);
+ }
+ pWin->mapped = FALSE;
+ if (wasRealized)
+ UnrealizeTree(pWin, fromConfigure);
+ if (wasViewable)
+ {
+ if (!fromConfigure)
+ {
+ (*pScreen->ValidateTree)(pLayerWin->parent, pWin, VTUnmap);
+ (*pScreen->HandleExposures)(pLayerWin->parent);
+ }
+#ifdef DO_SAVE_UNDERS
+ if (DO_SAVE_UNDERS(pWin))
+ {
+ if ( (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib) )
+ {
+ (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib);
+ }
+ }
+ pWin->DIXsaveUnder = FALSE;
+#endif /* DO_SAVE_UNDERS */
+ if (!fromConfigure && pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pLayerWin->parent, pWin, VTUnmap);
+ }
+ if (wasRealized && !fromConfigure)
+ WindowsRestructured ();
+ return(Success);
+}
+
+/*****
+ * UnmapSubwindows
+ * Performs an UnmapWindow request with the specified mode on all mapped
+ * children of the window, in bottom to top stacking order.
+ *****/
+
+void
+UnmapSubwindows(register WindowPtr pWin)
+{
+ register WindowPtr pChild, pHead;
+ xEvent event;
+ Bool wasRealized = (Bool)pWin->realized;
+ Bool wasViewable = (Bool)pWin->viewable;
+ Bool anyMarked = FALSE;
+ Mask parentNotify;
+ WindowPtr pLayerWin = NULL;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ if (!pWin->firstChild)
+ return;
+ parentNotify = SubSend(pWin);
+ pHead = RealChildHead(pWin);
+
+ if (wasViewable)
+ pLayerWin = (*pScreen->GetLayerWindow)(pWin);
+
+ for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
+ {
+ if (pChild->mapped)
+ {
+ if (parentNotify || StrSend(pChild))
+ {
+ event.u.u.type = UnmapNotify;
+ event.u.unmapNotify.window = pChild->drawable.id;
+ event.u.unmapNotify.fromConfigure = xFalse;
+ DeliverEvents(pChild, &event, 1, NullWindow);
+ }
+ if (pChild->viewable)
+ {
+ pChild->valdata = UnmapValData;
+ anyMarked = TRUE;
+ }
+ pChild->mapped = FALSE;
+ if (pChild->realized)
+ UnrealizeTree(pChild, FALSE);
+ if (wasViewable)
+ {
+#ifdef DO_SAVE_UNDERS
+ pChild->DIXsaveUnder = FALSE;
+#endif /* DO_SAVE_UNDERS */
+ if (pChild->backStorage)
+ (*pScreen->SaveDoomedAreas)(
+ pChild, &pChild->clipList, 0, 0);
+ }
+ }
+ }
+ if (wasViewable)
+ {
+ if (anyMarked)
+ {
+ if (pLayerWin->parent == pWin)
+ (*pScreen->MarkWindow)(pWin);
+ else
+ {
+ WindowPtr ptmp;
+ (*pScreen->MarkOverlappedWindows)(pWin, pLayerWin,
+ (WindowPtr *)NULL);
+ (*pScreen->MarkWindow)(pLayerWin->parent);
+
+ /* Windows between pWin and pLayerWin may not have been marked */
+ ptmp = pWin;
+
+ while (ptmp != pLayerWin->parent)
+ {
+ (*pScreen->MarkWindow)(ptmp);
+ ptmp = ptmp->parent;
+ }
+ pHead = pWin->firstChild;
+ }
+ (*pScreen->ValidateTree)(pLayerWin->parent, pHead, VTUnmap);
+ (*pScreen->HandleExposures)(pLayerWin->parent);
+ }
+#ifdef DO_SAVE_UNDERS
+ if (DO_SAVE_UNDERS(pWin))
+ {
+ if ( (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin))
+ (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin);
+ }
+#endif /* DO_SAVE_UNDERS */
+ if (anyMarked && pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pLayerWin->parent, pHead, VTUnmap);
+ }
+ if (wasRealized)
+ WindowsRestructured ();
+}
+
+
+void
+HandleSaveSet(register ClientPtr client)
+{
+ register WindowPtr pParent, pWin;
+ register int j;
+
+ for (j=0; j<client->numSaved; j++)
+ {
+ pWin = SaveSetWindow(client->saveSet[j]);
+#ifdef XFIXES
+ if (SaveSetToRoot(client->saveSet[j]))
+ pParent = WindowTable[pWin->drawable.pScreen->myNum];
+ else
+#endif
+ {
+ pParent = pWin->parent;
+ while (pParent && (wClient (pParent) == client))
+ pParent = pParent->parent;
+ }
+ if (pParent)
+ {
+ if (pParent != pWin->parent)
+ {
+ ReparentWindow(pWin, pParent,
+ pWin->drawable.x - wBorderWidth (pWin) - pParent->drawable.x,
+ pWin->drawable.y - wBorderWidth (pWin) - pParent->drawable.y,
+ client);
+ if(!pWin->realized && pWin->mapped)
+ pWin->mapped = FALSE;
+ }
+#ifdef XFIXES
+ if (SaveSetRemap (client->saveSet[j]))
+#endif
+ MapWindow(pWin, client);
+ }
+ }
+ xfree(client->saveSet);
+ client->numSaved = 0;
+ client->saveSet = (SaveSetElt *)NULL;
+}
+
+/**
+ *
+ * \param x,y in root
+ * \param box "return" value
+ */
+Bool
+VisibleBoundingBoxFromPoint(register WindowPtr pWin, int x, int y, BoxPtr box)
+{
+ if (!pWin->realized)
+ return (FALSE);
+ if (POINT_IN_REGION(pWin->drawable.pScreen, &pWin->clipList, x, y, box))
+ return(TRUE);
+ return(FALSE);
+}
+
+/**
+ *
+ * \param x,y in root
+ */
+Bool
+PointInWindowIsVisible(register WindowPtr pWin, int x, int y)
+{
+ BoxRec box;
+
+ if (!pWin->realized)
+ return (FALSE);
+ if (POINT_IN_REGION(pWin->drawable.pScreen, &pWin->borderClip,
+ x, y, &box)
+ && (!wInputShape(pWin) ||
+ POINT_IN_REGION(pWin->drawable.pScreen,
+ wInputShape(pWin),
+ x - pWin->drawable.x,
+ y - pWin->drawable.y, &box)))
+ return(TRUE);
+ return(FALSE);
+}
+
+
+RegionPtr
+NotClippedByChildren(register WindowPtr pWin)
+{
+ register ScreenPtr pScreen;
+ RegionPtr pReg;
+
+ pScreen = pWin->drawable.pScreen;
+ pReg = REGION_CREATE(pScreen, NullBox, 1);
+ if (pWin->parent ||
+ screenIsSaved != SCREEN_SAVER_ON ||
+ !HasSaverWindow (pWin->drawable.pScreen->myNum))
+ {
+ REGION_INTERSECT(pScreen, pReg, &pWin->borderClip, &pWin->winSize);
+ }
+ return(pReg);
+}
+
+void
+SendVisibilityNotify(WindowPtr pWin)
+{
+ xEvent event;
+#ifndef NO_XINERAMA_PORT
+ unsigned int visibility = pWin->visibility;
+#endif
+#ifdef PANORAMIX
+ /* This is not quite correct yet, but it's close */
+ if(!noPanoramiXExtension) {
+ PanoramiXRes *win;
+ WindowPtr pWin2;
+ int i, Scrnum;
+
+ Scrnum = pWin->drawable.pScreen->myNum;
+
+ win = PanoramiXFindIDByScrnum(XRT_WINDOW, pWin->drawable.id, Scrnum);
+
+ if(!win || (win->u.win.visibility == visibility))
+ return;
+
+ switch(visibility) {
+ case VisibilityUnobscured:
+ for(i = 0; i < PanoramiXNumScreens; i++) {
+ if(i == Scrnum) continue;
+
+ pWin2 = (WindowPtr)LookupIDByType(win->info[i].id, RT_WINDOW);
+
+ if (pWin2) {
+ if(pWin2->visibility == VisibilityPartiallyObscured)
+ return;
+
+ if(!i) pWin = pWin2;
+ }
+ }
+ break;
+ case VisibilityPartiallyObscured:
+ if(Scrnum) {
+ pWin2 = (WindowPtr)LookupIDByType(win->info[0].id, RT_WINDOW);
+ if (pWin2) pWin = pWin2;
+ }
+ break;
+ case VisibilityFullyObscured:
+ for(i = 0; i < PanoramiXNumScreens; i++) {
+ if(i == Scrnum) continue;
+
+ pWin2 = (WindowPtr)LookupIDByType(win->info[i].id, RT_WINDOW);
+
+ if (pWin2) {
+ if(pWin2->visibility != VisibilityFullyObscured)
+ return;
+
+ if(!i) pWin = pWin2;
+ }
+ }
+ break;
+ }
+
+ win->u.win.visibility = visibility;
+ }
+#endif
+
+ event.u.u.type = VisibilityNotify;
+ event.u.visibility.window = pWin->drawable.id;
+ event.u.visibility.state = visibility;
+ DeliverEvents(pWin, &event, 1, NullWindow);
+}
+
+
+#define RANDOM_WIDTH 32
+
+#ifndef NOLOGOHACK
+static void DrawLogo(
+ WindowPtr pWin
+);
+#endif
+
+void
+SaveScreens(int on, int mode)
+{
+ int i;
+ int what;
+ int type;
+
+ if (on == SCREEN_SAVER_FORCER)
+ {
+ UpdateCurrentTimeIf();
+ lastDeviceEventTime = currentTime;
+ if (mode == ScreenSaverReset)
+ what = SCREEN_SAVER_OFF;
+ else
+ what = SCREEN_SAVER_ON;
+ type = what;
+ }
+ else
+ {
+ what = on;
+ type = what;
+ if (what == screenIsSaved)
+ type = SCREEN_SAVER_CYCLE;
+ }
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ if (on == SCREEN_SAVER_FORCER)
+ (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i], on);
+ if (savedScreenInfo[i].ExternalScreenSaver)
+ {
+ if ((*savedScreenInfo[i].ExternalScreenSaver)
+ (screenInfo.screens[i], type, on == SCREEN_SAVER_FORCER))
+ continue;
+ }
+ if (type == screenIsSaved)
+ continue;
+ switch (type) {
+ case SCREEN_SAVER_OFF:
+ if (savedScreenInfo[i].blanked == SCREEN_IS_BLANKED)
+ {
+ (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i],
+ what);
+ }
+ else if (HasSaverWindow (i))
+ {
+ savedScreenInfo[i].pWindow = NullWindow;
+ FreeResource(savedScreenInfo[i].wid, RT_NONE);
+ }
+ break;
+ case SCREEN_SAVER_CYCLE:
+ if (savedScreenInfo[i].blanked == SCREEN_IS_TILED)
+ {
+ WindowPtr pWin = savedScreenInfo[i].pWindow;
+ /* make it look like screen saver is off, so that
+ * NotClippedByChildren will compute a clip list
+ * for the root window, so miPaintWindow works
+ */
+ screenIsSaved = SCREEN_SAVER_OFF;
+#ifndef NOLOGOHACK
+ if (logoScreenSaver)
+ (*pWin->drawable.pScreen->ClearToBackground)(pWin, 0, 0, 0, 0, FALSE);
+#endif
+ (*pWin->drawable.pScreen->MoveWindow)(pWin,
+ (short)(-(rand() % RANDOM_WIDTH)),
+ (short)(-(rand() % RANDOM_WIDTH)),
+ pWin->nextSib, VTMove);
+#ifndef NOLOGOHACK
+ if (logoScreenSaver)
+ DrawLogo(pWin);
+#endif
+ screenIsSaved = SCREEN_SAVER_ON;
+ }
+ /*
+ * Call the DDX saver in case it wants to do something
+ * at cycle time
+ */
+ else if (savedScreenInfo[i].blanked == SCREEN_IS_BLANKED)
+ {
+ (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i],
+ type);
+ }
+ break;
+ case SCREEN_SAVER_ON:
+ if (ScreenSaverBlanking != DontPreferBlanking)
+ {
+ if ((* screenInfo.screens[i]->SaveScreen)
+ (screenInfo.screens[i], what))
+ {
+ savedScreenInfo[i].blanked = SCREEN_IS_BLANKED;
+ continue;
+ }
+ if ((ScreenSaverAllowExposures != DontAllowExposures) &&
+ TileScreenSaver(i, SCREEN_IS_BLACK))
+ {
+ savedScreenInfo[i].blanked = SCREEN_IS_BLACK;
+ continue;
+ }
+ }
+ if ((ScreenSaverAllowExposures != DontAllowExposures) &&
+ TileScreenSaver(i, SCREEN_IS_TILED))
+ {
+ savedScreenInfo[i].blanked = SCREEN_IS_TILED;
+ }
+ else
+ savedScreenInfo[i].blanked = SCREEN_ISNT_SAVED;
+ break;
+ }
+ }
+ screenIsSaved = what;
+ if (mode == ScreenSaverReset)
+ SetScreenSaverTimer();
+}
+
+static Bool
+TileScreenSaver(int i, int kind)
+{
+ int j;
+ int result;
+ XID attributes[3];
+ Mask mask;
+ WindowPtr pWin;
+ CursorMetricRec cm;
+ unsigned char *srcbits, *mskbits;
+ CursorPtr cursor;
+ XID cursorID = 0;
+ int attri;
+
+ mask = 0;
+ attri = 0;
+ switch (kind) {
+ case SCREEN_IS_TILED:
+ switch (WindowTable[i]->backgroundState) {
+ case BackgroundPixel:
+ attributes[attri++] = WindowTable[i]->background.pixel;
+ mask |= CWBackPixel;
+ break;
+ case BackgroundPixmap:
+ attributes[attri++] = None;
+ mask |= CWBackPixmap;
+ break;
+ default:
+ break;
+ }
+ break;
+ case SCREEN_IS_BLACK:
+ attributes[attri++] = WindowTable[i]->drawable.pScreen->blackPixel;
+ mask |= CWBackPixel;
+ break;
+ }
+ mask |= CWOverrideRedirect;
+ attributes[attri++] = xTrue;
+
+ /*
+ * create a blank cursor
+ */
+
+ cm.width=16;
+ cm.height=16;
+ cm.xhot=8;
+ cm.yhot=8;
+ srcbits = (unsigned char *)xalloc( BitmapBytePad(32)*16);
+ mskbits = (unsigned char *)xalloc( BitmapBytePad(32)*16);
+ if (!srcbits || !mskbits)
+ {
+ xfree(srcbits);
+ xfree(mskbits);
+ cursor = 0;
+ }
+ else
+ {
+ for (j=0; j<BitmapBytePad(32)*16; j++)
+ srcbits[j] = mskbits[j] = 0x0;
+ cursor = AllocCursor(srcbits, mskbits, &cm, 0, 0, 0, 0, 0, 0);
+ if (cursor)
+ {
+ cursorID = FakeClientID(0);
+ if (AddResource (cursorID, RT_CURSOR, (pointer) cursor))
+ {
+ attributes[attri] = cursorID;
+ mask |= CWCursor;
+ }
+ else
+ cursor = 0;
+ }
+ else
+ {
+ xfree (srcbits);
+ xfree (mskbits);
+ }
+ }
+
+ pWin = savedScreenInfo[i].pWindow =
+ CreateWindow(savedScreenInfo[i].wid,
+ WindowTable[i],
+ -RANDOM_WIDTH, -RANDOM_WIDTH,
+ (unsigned short)screenInfo.screens[i]->width + RANDOM_WIDTH,
+ (unsigned short)screenInfo.screens[i]->height + RANDOM_WIDTH,
+ 0, InputOutput, mask, attributes, 0, serverClient,
+ wVisual (WindowTable[i]), &result);
+
+ if (cursor)
+ FreeResource (cursorID, RT_NONE);
+
+ if (!pWin)
+ return FALSE;
+
+ if (!AddResource(pWin->drawable.id, RT_WINDOW,
+ (pointer)savedScreenInfo[i].pWindow))
+ return FALSE;
+
+ if (mask & CWBackPixmap)
+ {
+ MakeRootTile (pWin);
+ (*pWin->drawable.pScreen->ChangeWindowAttributes)(pWin, CWBackPixmap);
+ }
+ MapWindow(pWin, serverClient);
+#ifndef NOLOGOHACK
+ if (kind == SCREEN_IS_TILED && logoScreenSaver)
+ DrawLogo(pWin);
+#endif
+ return TRUE;
+}
+
+/*
+ * FindWindowWithOptional
+ *
+ * search ancestors of the given window for an entry containing
+ * a WindowOpt structure. Assumptions: some parent will
+ * contain the structure.
+ */
+
+WindowPtr
+FindWindowWithOptional (register WindowPtr w)
+{
+ do
+ w = w->parent;
+ while (!w->optional);
+ return w;
+}
+
+/*
+ * CheckWindowOptionalNeed
+ *
+ * check each optional entry in the given window to see if
+ * the value is satisfied by the default rules. If so,
+ * release the optional record
+ */
+
+void
+CheckWindowOptionalNeed (register WindowPtr w)
+{
+ register WindowOptPtr optional;
+ register WindowOptPtr parentOptional;
+
+ if (!w->parent)
+ return;
+ optional = w->optional;
+ if (optional->dontPropagateMask != DontPropagateMasks[w->dontPropagate])
+ return;
+ if (optional->otherEventMasks != 0)
+ return;
+ if (optional->otherClients != NULL)
+ return;
+ if (optional->passiveGrabs != NULL)
+ return;
+ if (optional->userProps != NULL)
+ return;
+ if (optional->backingBitPlanes != ~0L)
+ return;
+ if (optional->backingPixel != 0)
+ return;
+#ifdef SHAPE
+ if (optional->boundingShape != NULL)
+ return;
+ if (optional->clipShape != NULL)
+ return;
+ if (optional->inputShape != NULL)
+ return;
+#endif
+#ifdef XINPUT
+ if (optional->inputMasks != NULL)
+ return;
+#endif
+ parentOptional = FindWindowWithOptional(w)->optional;
+ if (optional->visual != parentOptional->visual)
+ return;
+ if (optional->cursor != None &&
+ (optional->cursor != parentOptional->cursor ||
+ w->parent->cursorIsNone))
+ return;
+ if (optional->colormap != parentOptional->colormap)
+ return;
+ DisposeWindowOptional (w);
+}
+
+/*
+ * MakeWindowOptional
+ *
+ * create an optional record and initialize it with the default
+ * values.
+ */
+
+Bool
+MakeWindowOptional (register WindowPtr pWin)
+{
+ register WindowOptPtr optional;
+ register WindowOptPtr parentOptional;
+
+ if (pWin->optional)
+ return TRUE;
+ optional = (WindowOptPtr) xalloc (sizeof (WindowOptRec));
+ if (!optional)
+ return FALSE;
+ optional->dontPropagateMask = DontPropagateMasks[pWin->dontPropagate];
+ optional->otherEventMasks = 0;
+ optional->otherClients = NULL;
+ optional->passiveGrabs = NULL;
+ optional->userProps = NULL;
+ optional->backingBitPlanes = ~0L;
+ optional->backingPixel = 0;
+#ifdef SHAPE
+ optional->boundingShape = NULL;
+ optional->clipShape = NULL;
+ optional->inputShape = NULL;
+#endif
+#ifdef XINPUT
+ optional->inputMasks = NULL;
+#endif
+ parentOptional = FindWindowWithOptional(pWin)->optional;
+ optional->visual = parentOptional->visual;
+ if (!pWin->cursorIsNone)
+ {
+ optional->cursor = parentOptional->cursor;
+ optional->cursor->refcnt++;
+ }
+ else
+ {
+ optional->cursor = None;
+ }
+ optional->colormap = parentOptional->colormap;
+ pWin->optional = optional;
+ return TRUE;
+}
+
+void
+DisposeWindowOptional (register WindowPtr pWin)
+{
+ if (!pWin->optional)
+ return;
+ /*
+ * everything is peachy. Delete the optional record
+ * and clean up
+ */
+ /*
+ * TOG changed this code to:
+ *
+ * if (pWin->cursorIsNone == FALSE)
+ * FreeCursor (pWin->optional->cursor, (Cursor)0);
+ * pWin->cursorIsNone = TRUE;
+ *
+ * This is blatently wrong; windows without optionals can have
+ * two different cursor values, either None or sharing their
+ * parents cursor. This difference is controlled by the
+ * cursorIsNone value; when TRUE, the window has no cursor,
+ * when false, it shares its cursor with its parent; TOG
+ * made it impossible for a window to have a cursor without
+ * an optional record.
+ */
+ if (pWin->optional->cursor)
+ {
+ FreeCursor (pWin->optional->cursor, (Cursor)0);
+ pWin->cursorIsNone = FALSE;
+ }
+ else
+ pWin->cursorIsNone = TRUE;
+ xfree (pWin->optional);
+ pWin->optional = NULL;
+}
+
+#ifndef NOLOGOHACK
+static void
+DrawLogo(WindowPtr pWin)
+{
+ DrawablePtr pDraw;
+ ScreenPtr pScreen;
+ int x, y;
+ unsigned int width, height, size;
+ GC *pGC;
+ int thin, gap, d31;
+ DDXPointRec poly[4];
+ ChangeGCVal fore[2], back[2];
+ xrgb rgb[2];
+ BITS32 fmask, bmask;
+ ColormapPtr cmap;
+
+ pDraw = (DrawablePtr)pWin;
+ pScreen = pDraw->pScreen;
+ x = -pWin->origin.x;
+ y = -pWin->origin.y;
+ width = pScreen->width;
+ height = pScreen->height;
+ pGC = GetScratchGC(pScreen->rootDepth, pScreen);
+ if (!pGC)
+ return;
+
+ if ((rand() % 100) <= 17) /* make the probability for white fairly low */
+ fore[0].val = pScreen->whitePixel;
+ else
+ fore[0].val = pScreen->blackPixel;
+ if ((pWin->backgroundState == BackgroundPixel) &&
+ (cmap = (ColormapPtr)LookupIDByType(wColormap (pWin), RT_COLORMAP))) {
+ Pixel querypixels[2];
+
+ querypixels[0] = fore[0].val;
+ querypixels[1] = pWin->background.pixel;
+ QueryColors(cmap, 2, querypixels, rgb);
+ if ((rgb[0].red == rgb[1].red) &&
+ (rgb[0].green == rgb[1].green) &&
+ (rgb[0].blue == rgb[1].blue)) {
+ if (fore[0].val == pScreen->blackPixel)
+ fore[0].val = pScreen->whitePixel;
+ else
+ fore[0].val = pScreen->blackPixel;
+ }
+ }
+ fore[1].val = FillSolid;
+ fmask = GCForeground|GCFillStyle;
+ if (pWin->backgroundState == BackgroundPixel) {
+ back[0].val = pWin->background.pixel;
+ back[1].val = FillSolid;
+ bmask = GCForeground|GCFillStyle;
+ } else {
+ back[0].val = 0;
+ back[1].val = 0;
+ dixChangeGC(NullClient, pGC, GCTileStipXOrigin|GCTileStipYOrigin,
+ NULL, back);
+ back[0].val = FillTiled;
+ back[1].ptr = pWin->background.pixmap;
+ bmask = GCFillStyle|GCTile;
+ }
+
+ /* should be the same as the reference function XmuDrawLogo() */
+
+ size = width;
+ if (height < width)
+ size = height;
+ size = RANDOM_WIDTH + rand() % (size - RANDOM_WIDTH);
+ size &= ~1;
+ x += rand() % (width - size);
+ y += rand() % (height - size);
+
+/*
+ * Draw what will be the thin strokes.
+ *
+ * -----
+ * / /
+ * / /
+ * / /
+ * / /
+ * /____/
+ * d
+ *
+ * Point d is 9/44 (~1/5) of the way across.
+ */
+
+ thin = (size / 11);
+ if (thin < 1) thin = 1;
+ gap = (thin+3) / 4;
+ d31 = thin + thin + gap;
+ poly[0].x = x + size; poly[0].y = y;
+ poly[1].x = x + size-d31; poly[1].y = y;
+ poly[2].x = x + 0; poly[2].y = y + size;
+ poly[3].x = x + d31; poly[3].y = y + size;
+ dixChangeGC(NullClient, pGC, fmask, NULL, fore);
+ ValidateGC(pDraw, pGC);
+ (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
+
+/*
+ * Erase area not needed for lower thin stroke.
+ *
+ * ------
+ * / /
+ * / __ /
+ * / / /
+ * / / /
+ * /__/__/
+ */
+
+ poly[0].x = x + d31/2; poly[0].y = y + size;
+ poly[1].x = x + size / 2; poly[1].y = y + size/2;
+ poly[2].x = x + (size/2)+(d31-(d31/2)); poly[2].y = y + size/2;
+ poly[3].x = x + d31; poly[3].y = y + size;
+ dixChangeGC(NullClient, pGC, bmask, NULL, back);
+ ValidateGC(pDraw, pGC);
+ (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
+
+/*
+ * Erase area not needed for upper thin stroke.
+ *
+ * ------
+ * / / /
+ * /--/ /
+ * / /
+ * / /
+ * /_____/
+ */
+
+ poly[0].x = x + size - d31/2; poly[0].y = y;
+ poly[1].x = x + size / 2; poly[1].y = y + size/2;
+ poly[2].x = x + (size/2)-(d31-(d31/2)); poly[2].y = y + size/2;
+ poly[3].x = x + size - d31; poly[3].y = y;
+ ValidateGC(pDraw, pGC);
+ (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
+
+/*
+ * Draw thick stroke.
+ * Point b is 1/4 of the way across.
+ *
+ * b
+ * -----
+ * \ \
+ * \ \
+ * \ \
+ * \ \
+ * \____\
+ */
+
+ poly[0].x = x; poly[0].y = y;
+ poly[1].x = x + size/4; poly[1].y = y;
+ poly[2].x = x + size; poly[2].y = y + size;
+ poly[3].x = x + size - size/4; poly[3].y = y + size;
+ dixChangeGC(NullClient, pGC, fmask, NULL, fore);
+ ValidateGC(pDraw, pGC);
+ (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
+
+/*
+ * Erase to create gap.
+ *
+ * /
+ * /
+ * /
+ * /
+ * /
+ */
+
+ poly[0].x = x + size- thin; poly[0].y = y;
+ poly[1].x = x + size-( thin+gap); poly[1].y = y;
+ poly[2].x = x + thin; poly[2].y = y + size;
+ poly[3].x = x + thin + gap; poly[3].y = y + size;
+ dixChangeGC(NullClient, pGC, bmask, NULL, back);
+ ValidateGC(pDraw, pGC);
+ (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
+
+ FreeScratchGC(pGC);
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/dix/xpstubs.c b/nx-X11/programs/Xserver/dix/xpstubs.c
new file mode 100644
index 000000000..5135cc398
--- /dev/null
+++ b/nx-X11/programs/Xserver/dix/xpstubs.c
@@ -0,0 +1,77 @@
+/* $XFree86$ */
+/*
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+*/
+
+/* $Xorg: xpstubs.c,v 1.5 2001/03/08 17:52:08 pookie Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "misc.h"
+#include <X11/fonts/font.h>
+#ifdef XPRINT
+#include "DiPrint.h"
+#endif
+
+Bool
+XpClientIsBitmapClient(
+ ClientPtr client)
+{
+ return TRUE;
+}
+
+Bool
+XpClientIsPrintClient(
+ ClientPtr client,
+ FontPathElementPtr fpe)
+{
+ return FALSE;
+}
+#ifdef XPRINT
+int
+PrinterOptions(
+ int argc,
+ char **argv,
+ int i)
+{
+ return i;
+}
+void
+PrinterInitOutput(
+ ScreenInfo *pScreenInfo,
+ int argc,
+ char **argv)
+{
+}
+void PrinterUseMsg(void)
+{
+}
+void PrinterInitGlobals(void)
+{
+}
+#endif /* XPRINT */
+
diff --git a/nx-X11/programs/Xserver/fb/Imakefile b/nx-X11/programs/Xserver/fb/Imakefile
new file mode 100644
index 000000000..cb560e7a0
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/Imakefile
@@ -0,0 +1,194 @@
+XCOMM $XFree86: xc/programs/Xserver/fb/Imakefile,v 1.16 2002/05/31 16:12:17 dawes Exp $
+XCOMM
+XCOMM
+XCOMM Id: Imakefile,v 1.1 1999/11/02 03:54:44 keithp Exp $
+
+/*
+ * The X.org 6.8.99.16 snapshot fails to compile with GCC 4.
+ * Temporarily disable the MMX features until the bug is
+ * fixed.
+ *
+#if defined(HasGcc34) && HasGcc34
+MMXOPTIONS= -mmmx -msse -Winline --param inline-unit-growth=10000 \
+ --param large-function-growth=10000 -DUSE_MMX
+USEMMXOPTIONS= -DUSE_MMX
+#if defined(i386Architecture) || defined(AMD64Architecture)
+SpecialCObjectRule(fbmmx,fbmmx.c,$(MMXOPTIONS))
+SpecialCObjectRule(fbpict,fbpict.c,$(USEMMXOPTIONS))
+SpecialCObjectRule(fbfill,fbfill.c,$(USEMMXOPTIONS))
+SpecialCObjectRule(fbcopy,fbcopy.c,$(USEMMXOPTIONS))
+#endif
+
+#endif
+ */
+
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+#include <Server.tmpl>
+
+#ifdef FbNoPixelAddrCode
+DEFINES=-DFBNOPIXADDR -DFBNO24BIT
+#endif
+
+#if defined(IHaveModules)
+XFMODSRC = fbmodule.c
+XFMODOBJ = fbmodule.o
+#endif
+
+#if BuildRender
+RENDERSRC = fbcompose.c
+RENDEROBJ = fbcompose.o
+#endif
+
+SRCS = $(XFMODSRC) \
+ fballpriv.c \
+ fbbits.c \
+ fbblt.c \
+ fbbltone.c \
+ fbbstore.c \
+ fbcmap.c \
+ $(RENDERSRC) \
+ fbcopy.c \
+ fbedge.c \
+ fbfill.c \
+ fbfillrect.c \
+ fbfillsp.c \
+ fbgc.c \
+ fbgetsp.c \
+ fbglyph.c \
+ fbimage.c \
+ fbline.c \
+ fboverlay.c \
+ fbpixmap.c \
+ fbpoint.c \
+ fbpush.c \
+ fbscreen.c \
+ fbseg.c \
+ fbsetsp.c \
+ fbsolid.c \
+ fbstipple.c \
+ fbtile.c \
+ fbtrap.c \
+ fbutil.c \
+ fbwindow.c \
+ fb24_32.c \
+ fbpict.c \
+ fbmmx.c \
+ fbpseudocolor.c
+
+OBJS = $(XFMODOBJ) \
+ fbarc.o \
+ fballpriv.o \
+ fbbits.o \
+ fbblt.o \
+ fbbltone.o \
+ fbbstore.o \
+ fbcmap.o \
+ $(RENDEROBJ) \
+ fbcopy.o \
+ fbedge.o \
+ fbfill.o \
+ fbfillrect.o \
+ fbfillsp.o \
+ fbgc.o \
+ fbgetsp.o \
+ fbglyph.o \
+ fbimage.o \
+ fbline.o \
+ fboverlay.o \
+ fbpixmap.o \
+ fbpoint.o \
+ fbpush.o \
+ fbscreen.o \
+ fbseg.o \
+ fbsetsp.o \
+ fbsolid.o \
+ fbstipple.o \
+ fbtile.o \
+ fbtrap.o \
+ fbutil.o \
+ fbwindow.o \
+ fb24_32.o \
+ fbpict.o \
+ fbmmx.o \
+ fbpseudocolor.o
+
+ INCLUDES = -I$(SERVERSRC)/fb -I$(SERVERSRC)/mi -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) \
+ -I$(FONTINCSRC) -I$(XF86SRC)/common $(EXTRAINCLUDES) \
+ -I$(SERVERSRC)/render -I$(EXTINCSRC) -I$(SERVERSRC)/Xext
+ LINTLIBS = $(SERVERSRC)/dix/llib-ldix.ln $(SERVERSRC)/os/llib-los.ln \
+ $(SERVERSRC)/mi/llib-lmi.ln
+
+#ifdef IHaveModules
+ModuleObjectRule()
+LibraryModuleTarget(fb,$(OBJS))
+#else
+NormalLibraryObjectRule()
+NormalLibraryTarget(fb,$(OBJS))
+#endif
+
+LintLibraryTarget(fb,$(SRCS))
+
+NormalLintTarget($(SRCS))
+
+#ifdef IHaveModules
+InstallLibraryModule(fb,$(MODULEDIR),.)
+#endif
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+#ifdef LinkDirectory
+LinkSourceFile(fb24_32.c,LinkDirectory)
+LinkSourceFile(fballpriv.c,LinkDirectory)
+LinkSourceFile(fbarc.c,LinkDirectory)
+LinkSourceFile(fbbits.c,LinkDirectory)
+LinkSourceFile(fbblt.c,LinkDirectory)
+LinkSourceFile(fbbltone.c,LinkDirectory)
+LinkSourceFile(fbbstore.c,LinkDirectory)
+LinkSourceFile(fbcmap.c,LinkDirectory)
+#if BuildRender
+LinkSourceFile(fbcompose.c,LinkDirectory)
+#endif
+LinkSourceFile(fbcopy.c,LinkDirectory)
+LinkSourceFile(fbfill.c,LinkDirectory)
+LinkSourceFile(fbfillrect.c,LinkDirectory)
+LinkSourceFile(fbfillsp.c,LinkDirectory)
+LinkSourceFile(fbgc.c,LinkDirectory)
+LinkSourceFile(fbgetsp.c,LinkDirectory)
+LinkSourceFile(fbglyph.c,LinkDirectory)
+LinkSourceFile(fbimage.c,LinkDirectory)
+LinkSourceFile(fbline.c,LinkDirectory)
+LinkSourceFile(fbmodule.c,LinkDirectory)
+LinkSourceFile(fboverlay.c,LinkDirectory)
+LinkSourceFile(fbpict.c,LinkDirectory)
+LinkSourceFile(fbpixmap.c,LinkDirectory)
+LinkSourceFile(fbpoint.c,LinkDirectory)
+LinkSourceFile(fbpush.c,LinkDirectory)
+LinkSourceFile(fbscreen.c,LinkDirectory)
+LinkSourceFile(fbseg.c,LinkDirectory)
+LinkSourceFile(fbsetsp.c,LinkDirectory)
+LinkSourceFile(fbsolid.c,LinkDirectory)
+LinkSourceFile(fbstipple.c,LinkDirectory)
+LinkSourceFile(fbtile.c,LinkDirectory)
+LinkSourceFile(fbtrap.c,LinkDirectory)
+LinkSourceFile(fbutil.c,LinkDirectory)
+LinkSourceFile(fbwindow.c,LinkDirectory)
+LinkSourceFile(fbmmx.c,LinkDirectory)
+#endif
+
+InstallDriverSDKLibraryModule(fb,$(DRIVERSDKMODULEDIR),.)
+InstallDriverSDKNonExecFile(fb.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(fbrop.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/fb/Imakefile.NX.original b/nx-X11/programs/Xserver/fb/Imakefile.NX.original
new file mode 100644
index 000000000..cb560e7a0
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/Imakefile.NX.original
@@ -0,0 +1,194 @@
+XCOMM $XFree86: xc/programs/Xserver/fb/Imakefile,v 1.16 2002/05/31 16:12:17 dawes Exp $
+XCOMM
+XCOMM
+XCOMM Id: Imakefile,v 1.1 1999/11/02 03:54:44 keithp Exp $
+
+/*
+ * The X.org 6.8.99.16 snapshot fails to compile with GCC 4.
+ * Temporarily disable the MMX features until the bug is
+ * fixed.
+ *
+#if defined(HasGcc34) && HasGcc34
+MMXOPTIONS= -mmmx -msse -Winline --param inline-unit-growth=10000 \
+ --param large-function-growth=10000 -DUSE_MMX
+USEMMXOPTIONS= -DUSE_MMX
+#if defined(i386Architecture) || defined(AMD64Architecture)
+SpecialCObjectRule(fbmmx,fbmmx.c,$(MMXOPTIONS))
+SpecialCObjectRule(fbpict,fbpict.c,$(USEMMXOPTIONS))
+SpecialCObjectRule(fbfill,fbfill.c,$(USEMMXOPTIONS))
+SpecialCObjectRule(fbcopy,fbcopy.c,$(USEMMXOPTIONS))
+#endif
+
+#endif
+ */
+
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+#include <Server.tmpl>
+
+#ifdef FbNoPixelAddrCode
+DEFINES=-DFBNOPIXADDR -DFBNO24BIT
+#endif
+
+#if defined(IHaveModules)
+XFMODSRC = fbmodule.c
+XFMODOBJ = fbmodule.o
+#endif
+
+#if BuildRender
+RENDERSRC = fbcompose.c
+RENDEROBJ = fbcompose.o
+#endif
+
+SRCS = $(XFMODSRC) \
+ fballpriv.c \
+ fbbits.c \
+ fbblt.c \
+ fbbltone.c \
+ fbbstore.c \
+ fbcmap.c \
+ $(RENDERSRC) \
+ fbcopy.c \
+ fbedge.c \
+ fbfill.c \
+ fbfillrect.c \
+ fbfillsp.c \
+ fbgc.c \
+ fbgetsp.c \
+ fbglyph.c \
+ fbimage.c \
+ fbline.c \
+ fboverlay.c \
+ fbpixmap.c \
+ fbpoint.c \
+ fbpush.c \
+ fbscreen.c \
+ fbseg.c \
+ fbsetsp.c \
+ fbsolid.c \
+ fbstipple.c \
+ fbtile.c \
+ fbtrap.c \
+ fbutil.c \
+ fbwindow.c \
+ fb24_32.c \
+ fbpict.c \
+ fbmmx.c \
+ fbpseudocolor.c
+
+OBJS = $(XFMODOBJ) \
+ fbarc.o \
+ fballpriv.o \
+ fbbits.o \
+ fbblt.o \
+ fbbltone.o \
+ fbbstore.o \
+ fbcmap.o \
+ $(RENDEROBJ) \
+ fbcopy.o \
+ fbedge.o \
+ fbfill.o \
+ fbfillrect.o \
+ fbfillsp.o \
+ fbgc.o \
+ fbgetsp.o \
+ fbglyph.o \
+ fbimage.o \
+ fbline.o \
+ fboverlay.o \
+ fbpixmap.o \
+ fbpoint.o \
+ fbpush.o \
+ fbscreen.o \
+ fbseg.o \
+ fbsetsp.o \
+ fbsolid.o \
+ fbstipple.o \
+ fbtile.o \
+ fbtrap.o \
+ fbutil.o \
+ fbwindow.o \
+ fb24_32.o \
+ fbpict.o \
+ fbmmx.o \
+ fbpseudocolor.o
+
+ INCLUDES = -I$(SERVERSRC)/fb -I$(SERVERSRC)/mi -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) \
+ -I$(FONTINCSRC) -I$(XF86SRC)/common $(EXTRAINCLUDES) \
+ -I$(SERVERSRC)/render -I$(EXTINCSRC) -I$(SERVERSRC)/Xext
+ LINTLIBS = $(SERVERSRC)/dix/llib-ldix.ln $(SERVERSRC)/os/llib-los.ln \
+ $(SERVERSRC)/mi/llib-lmi.ln
+
+#ifdef IHaveModules
+ModuleObjectRule()
+LibraryModuleTarget(fb,$(OBJS))
+#else
+NormalLibraryObjectRule()
+NormalLibraryTarget(fb,$(OBJS))
+#endif
+
+LintLibraryTarget(fb,$(SRCS))
+
+NormalLintTarget($(SRCS))
+
+#ifdef IHaveModules
+InstallLibraryModule(fb,$(MODULEDIR),.)
+#endif
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+#ifdef LinkDirectory
+LinkSourceFile(fb24_32.c,LinkDirectory)
+LinkSourceFile(fballpriv.c,LinkDirectory)
+LinkSourceFile(fbarc.c,LinkDirectory)
+LinkSourceFile(fbbits.c,LinkDirectory)
+LinkSourceFile(fbblt.c,LinkDirectory)
+LinkSourceFile(fbbltone.c,LinkDirectory)
+LinkSourceFile(fbbstore.c,LinkDirectory)
+LinkSourceFile(fbcmap.c,LinkDirectory)
+#if BuildRender
+LinkSourceFile(fbcompose.c,LinkDirectory)
+#endif
+LinkSourceFile(fbcopy.c,LinkDirectory)
+LinkSourceFile(fbfill.c,LinkDirectory)
+LinkSourceFile(fbfillrect.c,LinkDirectory)
+LinkSourceFile(fbfillsp.c,LinkDirectory)
+LinkSourceFile(fbgc.c,LinkDirectory)
+LinkSourceFile(fbgetsp.c,LinkDirectory)
+LinkSourceFile(fbglyph.c,LinkDirectory)
+LinkSourceFile(fbimage.c,LinkDirectory)
+LinkSourceFile(fbline.c,LinkDirectory)
+LinkSourceFile(fbmodule.c,LinkDirectory)
+LinkSourceFile(fboverlay.c,LinkDirectory)
+LinkSourceFile(fbpict.c,LinkDirectory)
+LinkSourceFile(fbpixmap.c,LinkDirectory)
+LinkSourceFile(fbpoint.c,LinkDirectory)
+LinkSourceFile(fbpush.c,LinkDirectory)
+LinkSourceFile(fbscreen.c,LinkDirectory)
+LinkSourceFile(fbseg.c,LinkDirectory)
+LinkSourceFile(fbsetsp.c,LinkDirectory)
+LinkSourceFile(fbsolid.c,LinkDirectory)
+LinkSourceFile(fbstipple.c,LinkDirectory)
+LinkSourceFile(fbtile.c,LinkDirectory)
+LinkSourceFile(fbtrap.c,LinkDirectory)
+LinkSourceFile(fbutil.c,LinkDirectory)
+LinkSourceFile(fbwindow.c,LinkDirectory)
+LinkSourceFile(fbmmx.c,LinkDirectory)
+#endif
+
+InstallDriverSDKLibraryModule(fb,$(DRIVERSDKMODULEDIR),.)
+InstallDriverSDKNonExecFile(fb.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(fbrop.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/fb/Imakefile.X.original b/nx-X11/programs/Xserver/fb/Imakefile.X.original
new file mode 100644
index 000000000..df867016a
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/Imakefile.X.original
@@ -0,0 +1,188 @@
+XCOMM $XFree86: xc/programs/Xserver/fb/Imakefile,v 1.16 2002/05/31 16:12:17 dawes Exp $
+XCOMM
+XCOMM
+XCOMM Id: Imakefile,v 1.1 1999/11/02 03:54:44 keithp Exp $
+
+#if defined(HasGcc34) && HasGcc34
+MMXOPTIONS= -mmmx -msse -Winline --param inline-unit-growth=10000 \
+ --param large-function-growth=10000 -DUSE_MMX
+USEMMXOPTIONS= -DUSE_MMX
+#if defined(i386Architecture) || defined(AMD64Architecture)
+SpecialCObjectRule(fbmmx,fbmmx.c,$(MMXOPTIONS))
+SpecialCObjectRule(fbpict,fbpict.c,$(USEMMXOPTIONS))
+SpecialCObjectRule(fbfill,fbfill.c,$(USEMMXOPTIONS))
+SpecialCObjectRule(fbcopy,fbcopy.c,$(USEMMXOPTIONS))
+#endif
+
+#endif
+
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+#include <Server.tmpl>
+
+#ifdef FbNoPixelAddrCode
+DEFINES=-DFBNOPIXADDR -DFBNO24BIT
+#endif
+
+#if defined(IHaveModules)
+XFMODSRC = fbmodule.c
+XFMODOBJ = fbmodule.o
+#endif
+
+#if BuildRender
+RENDERSRC = fbcompose.c
+RENDEROBJ = fbcompose.o
+#endif
+
+SRCS = $(XFMODSRC) \
+ fballpriv.c \
+ fbbits.c \
+ fbblt.c \
+ fbbltone.c \
+ fbbstore.c \
+ fbcmap.c \
+ $(RENDERSRC) \
+ fbcopy.c \
+ fbedge.c \
+ fbfill.c \
+ fbfillrect.c \
+ fbfillsp.c \
+ fbgc.c \
+ fbgetsp.c \
+ fbglyph.c \
+ fbimage.c \
+ fbline.c \
+ fboverlay.c \
+ fbpixmap.c \
+ fbpoint.c \
+ fbpush.c \
+ fbscreen.c \
+ fbseg.c \
+ fbsetsp.c \
+ fbsolid.c \
+ fbstipple.c \
+ fbtile.c \
+ fbtrap.c \
+ fbutil.c \
+ fbwindow.c \
+ fb24_32.c \
+ fbpict.c \
+ fbmmx.c \
+ fbpseudocolor.c
+
+OBJS = $(XFMODOBJ) \
+ fbarc.o \
+ fballpriv.o \
+ fbbits.o \
+ fbblt.o \
+ fbbltone.o \
+ fbbstore.o \
+ fbcmap.o \
+ $(RENDEROBJ) \
+ fbcopy.o \
+ fbedge.o \
+ fbfill.o \
+ fbfillrect.o \
+ fbfillsp.o \
+ fbgc.o \
+ fbgetsp.o \
+ fbglyph.o \
+ fbimage.o \
+ fbline.o \
+ fboverlay.o \
+ fbpixmap.o \
+ fbpoint.o \
+ fbpush.o \
+ fbscreen.o \
+ fbseg.o \
+ fbsetsp.o \
+ fbsolid.o \
+ fbstipple.o \
+ fbtile.o \
+ fbtrap.o \
+ fbutil.o \
+ fbwindow.o \
+ fb24_32.o \
+ fbpict.o \
+ fbmmx.o \
+ fbpseudocolor.o
+
+ INCLUDES = -I$(SERVERSRC)/fb -I$(SERVERSRC)/mi -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) \
+ -I$(FONTINCSRC) -I$(XF86SRC)/common $(EXTRAINCLUDES) \
+ -I$(SERVERSRC)/render -I$(EXTINCSRC) -I$(SERVERSRC)/Xext
+ LINTLIBS = $(SERVERSRC)/dix/llib-ldix.ln $(SERVERSRC)/os/llib-los.ln \
+ $(SERVERSRC)/mi/llib-lmi.ln
+
+#ifdef IHaveModules
+ModuleObjectRule()
+LibraryModuleTarget(fb,$(OBJS))
+#else
+NormalLibraryObjectRule()
+NormalLibraryTarget(fb,$(OBJS))
+#endif
+
+LintLibraryTarget(fb,$(SRCS))
+
+NormalLintTarget($(SRCS))
+
+#ifdef IHaveModules
+InstallLibraryModule(fb,$(MODULEDIR),.)
+#endif
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+#ifdef LinkDirectory
+LinkSourceFile(fb24_32.c,LinkDirectory)
+LinkSourceFile(fballpriv.c,LinkDirectory)
+LinkSourceFile(fbarc.c,LinkDirectory)
+LinkSourceFile(fbbits.c,LinkDirectory)
+LinkSourceFile(fbblt.c,LinkDirectory)
+LinkSourceFile(fbbltone.c,LinkDirectory)
+LinkSourceFile(fbbstore.c,LinkDirectory)
+LinkSourceFile(fbcmap.c,LinkDirectory)
+#if BuildRender
+LinkSourceFile(fbcompose.c,LinkDirectory)
+#endif
+LinkSourceFile(fbcopy.c,LinkDirectory)
+LinkSourceFile(fbfill.c,LinkDirectory)
+LinkSourceFile(fbfillrect.c,LinkDirectory)
+LinkSourceFile(fbfillsp.c,LinkDirectory)
+LinkSourceFile(fbgc.c,LinkDirectory)
+LinkSourceFile(fbgetsp.c,LinkDirectory)
+LinkSourceFile(fbglyph.c,LinkDirectory)
+LinkSourceFile(fbimage.c,LinkDirectory)
+LinkSourceFile(fbline.c,LinkDirectory)
+LinkSourceFile(fbmodule.c,LinkDirectory)
+LinkSourceFile(fboverlay.c,LinkDirectory)
+LinkSourceFile(fbpict.c,LinkDirectory)
+LinkSourceFile(fbpixmap.c,LinkDirectory)
+LinkSourceFile(fbpoint.c,LinkDirectory)
+LinkSourceFile(fbpush.c,LinkDirectory)
+LinkSourceFile(fbscreen.c,LinkDirectory)
+LinkSourceFile(fbseg.c,LinkDirectory)
+LinkSourceFile(fbsetsp.c,LinkDirectory)
+LinkSourceFile(fbsolid.c,LinkDirectory)
+LinkSourceFile(fbstipple.c,LinkDirectory)
+LinkSourceFile(fbtile.c,LinkDirectory)
+LinkSourceFile(fbtrap.c,LinkDirectory)
+LinkSourceFile(fbutil.c,LinkDirectory)
+LinkSourceFile(fbwindow.c,LinkDirectory)
+LinkSourceFile(fbmmx.c,LinkDirectory)
+#endif
+
+InstallDriverSDKLibraryModule(fb,$(DRIVERSDKMODULEDIR),.)
+InstallDriverSDKNonExecFile(fb.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(fbrop.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/fb/fb.h b/nx-X11/programs/Xserver/fb/fb.h
new file mode 100644
index 000000000..3ee79d4af
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fb.h
@@ -0,0 +1,2054 @@
+/*
+ * $XFree86: xc/programs/Xserver/fb/fb.h,v 1.36tsi Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* $XdotOrg: xc/programs/Xserver/fb/fb.h,v 1.13 2005/10/02 08:28:26 anholt Exp $ */
+
+#ifndef _FB_H_
+#define _FB_H_
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmap.h"
+#include "pixmapstr.h"
+#include "region.h"
+#include "gcstruct.h"
+#include "colormap.h"
+#include "miscstruct.h"
+#include "servermd.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "migc.h"
+#include "mibstore.h"
+#ifdef RENDER
+#include "picturestr.h"
+#else
+#include "picture.h"
+#endif
+
+/*
+ * This single define controls the basic size of data manipulated
+ * by this software; it must be log2(sizeof (FbBits) * 8)
+ */
+
+#ifndef FB_SHIFT
+#define FB_SHIFT LOG2_BITMAP_PAD
+#endif
+
+#if FB_SHIFT < LOG2_BITMAP_PAD
+ error FB_SHIFT must be >= LOG2_BITMAP_PAD
+#endif
+
+#define FB_UNIT (1 << FB_SHIFT)
+#define FB_HALFUNIT (1 << (FB_SHIFT-1))
+#define FB_MASK (FB_UNIT - 1)
+#define FB_ALLONES ((FbBits) -1)
+
+#if GLYPHPADBYTES != 4
+#error "GLYPHPADBYTES must be 4"
+#endif
+#if GETLEFTBITS_ALIGNMENT != 1
+#error "GETLEFTBITS_ALIGNMENT must be 1"
+#endif
+/* whether to bother to include 24bpp support */
+#ifndef FBNO24BIT
+#define FB_24BIT
+#endif
+
+/*
+ * Unless otherwise instructed, fb includes code to advertise 24bpp
+ * windows with 32bpp image format for application compatibility
+ */
+
+#ifdef FB_24BIT
+#ifndef FBNO24_32
+#define FB_24_32BIT
+#endif
+#endif
+
+#define FB_STIP_SHIFT LOG2_BITMAP_PAD
+#define FB_STIP_UNIT (1 << FB_STIP_SHIFT)
+#define FB_STIP_MASK (FB_STIP_UNIT - 1)
+#define FB_STIP_ALLONES ((FbStip) -1)
+
+#define FB_STIP_ODDSTRIDE(s) (((s) & (FB_MASK >> FB_STIP_SHIFT)) != 0)
+#define FB_STIP_ODDPTR(p) ((((long) (p)) & (FB_MASK >> 3)) != 0)
+
+#define FbStipStrideToBitsStride(s) (((s) >> (FB_SHIFT - FB_STIP_SHIFT)))
+#define FbBitsStrideToStipStride(s) (((s) << (FB_SHIFT - FB_STIP_SHIFT)))
+
+#define FbFullMask(n) ((n) == FB_UNIT ? FB_ALLONES : ((((FbBits) 1) << n) - 1))
+
+#if FB_SHIFT == 6
+# ifdef WIN32
+typedef unsigned __int64 FbBits;
+# else
+# if defined(__alpha__) || defined(__alpha) || \
+ defined(ia64) || defined(__ia64__) || \
+ defined(__sparc64__) || defined(_LP64) || \
+ defined(__s390x__) || \
+ defined(amd64) || defined (__amd64__) || \
+ defined (__powerpc64__) || \
+ (defined(sgi) && (_MIPS_SZLONG == 64))
+typedef unsigned long FbBits;
+# else
+typedef unsigned long long FbBits;
+# endif
+# endif
+#endif
+
+#if FB_SHIFT == 5
+typedef CARD32 FbBits;
+#endif
+
+#if FB_SHIFT == 4
+typedef CARD16 FbBits;
+#endif
+
+#if LOG2_BITMAP_PAD == FB_SHIFT
+typedef FbBits FbStip;
+#else
+# if LOG2_BITMAP_PAD == 5
+typedef CARD32 FbStip;
+# endif
+#endif
+
+typedef int FbStride;
+
+
+#ifdef FB_DEBUG
+extern void fbValidateDrawable(DrawablePtr d);
+extern void fbInitializeDrawable(DrawablePtr d);
+extern void fbSetBits (FbStip *bits, int stride, FbStip data);
+#define FB_HEAD_BITS (FbStip) (0xbaadf00d)
+#define FB_TAIL_BITS (FbStip) (0xbaddf0ad)
+#else
+#define fbValidateDrawable(d)
+#define fdInitializeDrawable(d)
+#endif
+
+#include "fbrop.h"
+
+#if BITMAP_BIT_ORDER == LSBFirst
+#define FbScrLeft(x,n) ((x) >> (n))
+#define FbScrRight(x,n) ((x) << (n))
+/* #define FbLeftBits(x,n) ((x) & ((((FbBits) 1) << (n)) - 1)) */
+#define FbLeftStipBits(x,n) ((x) & ((((FbStip) 1) << (n)) - 1))
+#define FbStipMoveLsb(x,s,n) (FbStipRight (x,(s)-(n)))
+#define FbPatternOffsetBits 0
+#else
+#define FbScrLeft(x,n) ((x) << (n))
+#define FbScrRight(x,n) ((x) >> (n))
+/* #define FbLeftBits(x,n) ((x) >> (FB_UNIT - (n))) */
+#define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n)))
+#define FbStipMoveLsb(x,s,n) (x)
+#define FbPatternOffsetBits (sizeof (FbBits) - 1)
+#endif
+
+#include "micoord.h"
+
+#define FbStipLeft(x,n) FbScrLeft(x,n)
+#define FbStipRight(x,n) FbScrRight(x,n)
+
+#define FbRotLeft(x,n) FbScrLeft(x,n) | (n ? FbScrRight(x,FB_UNIT-n) : 0)
+#define FbRotRight(x,n) FbScrRight(x,n) | (n ? FbScrLeft(x,FB_UNIT-n) : 0)
+
+#define FbRotStipLeft(x,n) FbStipLeft(x,n) | (n ? FbStipRight(x,FB_STIP_UNIT-n) : 0)
+#define FbRotStipRight(x,n) FbStipRight(x,n) | (n ? FbStipLeft(x,FB_STIP_UNIT-n) : 0)
+
+#define FbLeftMask(x) ( ((x) & FB_MASK) ? \
+ FbScrRight(FB_ALLONES,(x) & FB_MASK) : 0)
+#define FbRightMask(x) ( ((FB_UNIT - (x)) & FB_MASK) ? \
+ FbScrLeft(FB_ALLONES,(FB_UNIT - (x)) & FB_MASK) : 0)
+
+#define FbLeftStipMask(x) ( ((x) & FB_STIP_MASK) ? \
+ FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) : 0)
+#define FbRightStipMask(x) ( ((FB_STIP_UNIT - (x)) & FB_STIP_MASK) ? \
+ FbScrLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - (x)) & FB_STIP_MASK) : 0)
+
+#define FbBitsMask(x,w) (FbScrRight(FB_ALLONES,(x) & FB_MASK) & \
+ FbScrLeft(FB_ALLONES,(FB_UNIT - ((x) + (w))) & FB_MASK))
+
+#define FbStipMask(x,w) (FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) & \
+ FbStipLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - ((x)+(w))) & FB_STIP_MASK))
+
+
+#define FbMaskBits(x,w,l,n,r) { \
+ n = (w); \
+ r = FbRightMask((x)+n); \
+ l = FbLeftMask(x); \
+ if (l) { \
+ n -= FB_UNIT - ((x) & FB_MASK); \
+ if (n < 0) { \
+ n = 0; \
+ l &= r; \
+ r = 0; \
+ } \
+ } \
+ n >>= FB_SHIFT; \
+}
+
+#ifdef FBNOPIXADDR
+#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) FbMaskBits(x,w,l,n,r)
+#define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
+ *dst = FbDoMaskRRop(*dst,and,xor,l); \
+}
+#define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
+ *dst = FbDoMaskRRop(*dst,and,xor,r); \
+}
+#else
+
+#define FbByteMaskInvalid 0x10
+
+#define FbPatternOffset(o,t) ((o) ^ (FbPatternOffsetBits & ~(sizeof (t) - 1)))
+
+#define FbPtrOffset(p,o,t) ((t *) ((CARD8 *) (p) + (o)))
+#define FbSelectPatternPart(xor,o,t) ((xor) >> (FbPatternOffset (o,t) << 3))
+#define FbStorePart(dst,off,t,xor) (*FbPtrOffset(dst,off,t) = \
+ FbSelectPart(xor,off,t))
+#ifndef FbSelectPart
+#define FbSelectPart(x,o,t) FbSelectPatternPart(x,o,t)
+#endif
+
+#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) { \
+ n = (w); \
+ lb = 0; \
+ rb = 0; \
+ r = FbRightMask((x)+n); \
+ if (r) { \
+ /* compute right byte length */ \
+ if ((copy) && (((x) + n) & 7) == 0) { \
+ rb = (((x) + n) & FB_MASK) >> 3; \
+ } else { \
+ rb = FbByteMaskInvalid; \
+ } \
+ } \
+ l = FbLeftMask(x); \
+ if (l) { \
+ /* compute left byte length */ \
+ if ((copy) && ((x) & 7) == 0) { \
+ lb = ((x) & FB_MASK) >> 3; \
+ } else { \
+ lb = FbByteMaskInvalid; \
+ } \
+ /* subtract out the portion painted by leftMask */ \
+ n -= FB_UNIT - ((x) & FB_MASK); \
+ if (n < 0) { \
+ if (lb != FbByteMaskInvalid) { \
+ if (rb == FbByteMaskInvalid) { \
+ lb = FbByteMaskInvalid; \
+ } else if (rb) { \
+ lb |= (rb - lb) << (FB_SHIFT - 3); \
+ rb = 0; \
+ } \
+ } \
+ n = 0; \
+ l &= r; \
+ r = 0; \
+ }\
+ } \
+ n >>= FB_SHIFT; \
+}
+
+#if FB_SHIFT == 6
+#define FbDoLeftMaskByteRRop6Cases(dst,xor) \
+ case (sizeof (FbBits) - 7) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 7) | (2 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 7) | (3 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 7) | (4 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 7) | (5 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 7) | (6 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 7): \
+ FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
+ break; \
+ case (sizeof (FbBits) - 6) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 6) | (2 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 6) | (3 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 6) | (4 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 6) | (5 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 6): \
+ FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
+ break; \
+ case (sizeof (FbBits) - 5) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 5) | (2 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 5) | (3 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 5) | (4 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 5): \
+ FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
+ break; \
+ case (sizeof (FbBits) - 4) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 4) | (2 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ break; \
+ case (sizeof (FbBits) - 4) | (3 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 4): \
+ FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
+ break;
+
+#define FbDoRightMaskByteRRop6Cases(dst,xor) \
+ case 4: \
+ FbStorePart(dst,0,CARD32,xor); \
+ break; \
+ case 5: \
+ FbStorePart(dst,0,CARD32,xor); \
+ FbStorePart(dst,4,CARD8,xor); \
+ break; \
+ case 6: \
+ FbStorePart(dst,0,CARD32,xor); \
+ FbStorePart(dst,4,CARD16,xor); \
+ break; \
+ case 7: \
+ FbStorePart(dst,0,CARD32,xor); \
+ FbStorePart(dst,4,CARD16,xor); \
+ FbStorePart(dst,6,CARD8,xor); \
+ break;
+#else
+#define FbDoLeftMaskByteRRop6Cases(dst,xor)
+#define FbDoRightMaskByteRRop6Cases(dst,xor)
+#endif
+
+#define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
+ switch (lb) { \
+ FbDoLeftMaskByteRRop6Cases(dst,xor) \
+ case (sizeof (FbBits) - 3) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 3) | (2 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case (sizeof (FbBits) - 2) | (1 << (FB_SHIFT - 3)): \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
+ break; \
+ case sizeof (FbBits) - 3: \
+ FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
+ case sizeof (FbBits) - 2: \
+ FbStorePart(dst,sizeof (FbBits) - 2,CARD16,xor); \
+ break; \
+ case sizeof (FbBits) - 1: \
+ FbStorePart(dst,sizeof (FbBits) - 1,CARD8,xor); \
+ break; \
+ default: \
+ *dst = FbDoMaskRRop(*dst, and, xor, l); \
+ break; \
+ } \
+}
+
+
+#define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
+ switch (rb) { \
+ case 1: \
+ FbStorePart(dst,0,CARD8,xor); \
+ break; \
+ case 2: \
+ FbStorePart(dst,0,CARD16,xor); \
+ break; \
+ case 3: \
+ FbStorePart(dst,0,CARD16,xor); \
+ FbStorePart(dst,2,CARD8,xor); \
+ break; \
+ FbDoRightMaskByteRRop6Cases(dst,xor) \
+ default: \
+ *dst = FbDoMaskRRop (*dst, and, xor, r); \
+ } \
+}
+#endif
+
+#define FbMaskStip(x,w,l,n,r) { \
+ n = (w); \
+ r = FbRightStipMask((x)+n); \
+ l = FbLeftStipMask(x); \
+ if (l) { \
+ n -= FB_STIP_UNIT - ((x) & FB_STIP_MASK); \
+ if (n < 0) { \
+ n = 0; \
+ l &= r; \
+ r = 0; \
+ } \
+ } \
+ n >>= FB_STIP_SHIFT; \
+}
+
+/*
+ * These macros are used to transparently stipple
+ * in copy mode; the expected usage is with 'n' constant
+ * so all of the conditional parts collapse into a minimal
+ * sequence of partial word writes
+ *
+ * 'n' is the bytemask of which bytes to store, 'a' is the address
+ * of the FbBits base unit, 'o' is the offset within that unit
+ *
+ * The term "lane" comes from the hardware term "byte-lane" which
+ */
+
+#define FbLaneCase1(n,a,o) ((n) == 0x01 ? \
+ (*(CARD8 *) ((a)+FbPatternOffset(o,CARD8)) = \
+ fgxor) : 0)
+#define FbLaneCase2(n,a,o) ((n) == 0x03 ? \
+ (*(CARD16 *) ((a)+FbPatternOffset(o,CARD16)) = \
+ fgxor) : \
+ ((void)FbLaneCase1((n)&1,a,o), \
+ FbLaneCase1((n)>>1,a,(o)+1)))
+#define FbLaneCase4(n,a,o) ((n) == 0x0f ? \
+ (*(CARD32 *) ((a)+FbPatternOffset(o,CARD32)) = \
+ fgxor) : \
+ ((void)FbLaneCase2((n)&3,a,o), \
+ FbLaneCase2((n)>>2,a,(o)+2)))
+#define FbLaneCase8(n,a,o) ((n) == 0x0ff ? (*(FbBits *) ((a)+(o)) = fgxor) : \
+ ((void)FbLaneCase4((n)&15,a,o), \
+ FbLaneCase4((n)>>4,a,(o)+4)))
+
+#if FB_SHIFT == 6
+#define FbLaneCase(n,a) FbLaneCase8(n,(CARD8 *) (a),0)
+#endif
+
+#if FB_SHIFT == 5
+#define FbLaneCase(n,a) FbLaneCase4(n,(CARD8 *) (a),0)
+#endif
+
+/* Rotate a filled pixel value to the specified alignement */
+#define FbRot24(p,b) (FbScrRight(p,b) | FbScrLeft(p,24-(b)))
+#define FbRot24Stip(p,b) (FbStipRight(p,b) | FbStipLeft(p,24-(b)))
+
+/* step a filled pixel value to the next/previous FB_UNIT alignment */
+#define FbNext24Pix(p) (FbRot24(p,(24-FB_UNIT%24)))
+#define FbPrev24Pix(p) (FbRot24(p,FB_UNIT%24))
+#define FbNext24Stip(p) (FbRot24(p,(24-FB_STIP_UNIT%24)))
+#define FbPrev24Stip(p) (FbRot24(p,FB_STIP_UNIT%24))
+
+/* step a rotation value to the next/previous rotation value */
+#if FB_UNIT == 64
+#define FbNext24Rot(r) ((r) == 16 ? 0 : (r) + 8)
+#define FbPrev24Rot(r) ((r) == 0 ? 16 : (r) - 8)
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define FbFirst24Rot(x) (((x) + 8) % 24)
+#else
+#define FbFirst24Rot(x) ((x) % 24)
+#endif
+
+#endif
+
+#if FB_UNIT == 32
+#define FbNext24Rot(r) ((r) == 0 ? 16 : (r) - 8)
+#define FbPrev24Rot(r) ((r) == 16 ? 0 : (r) + 8)
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define FbFirst24Rot(x) (((x) + 16) % 24)
+#else
+#define FbFirst24Rot(x) ((x) % 24)
+#endif
+#endif
+
+#define FbNext24RotStip(r) ((r) == 0 ? 16 : (r) - 8)
+#define FbPrev24RotStip(r) ((r) == 16 ? 0 : (r) + 8)
+
+/* Whether 24-bit specific code is needed for this filled pixel value */
+#define FbCheck24Pix(p) ((p) == FbNext24Pix(p))
+
+/* Macros for dealing with dashing */
+
+#define FbDashDeclare \
+ unsigned char *__dash, *__firstDash, *__lastDash
+
+#define FbDashInit(pGC,pPriv,dashOffset,dashlen,even) { \
+ (even) = TRUE; \
+ __firstDash = (pGC)->dash; \
+ __lastDash = __firstDash + (pGC)->numInDashList; \
+ (dashOffset) %= (pPriv)->dashLength; \
+ \
+ __dash = __firstDash; \
+ while ((dashOffset) >= ((dashlen) = *__dash)) \
+ { \
+ (dashOffset) -= (dashlen); \
+ (even) = 1-(even); \
+ if (++__dash == __lastDash) \
+ __dash = __firstDash; \
+ } \
+ (dashlen) -= (dashOffset); \
+}
+
+#define FbDashNext(dashlen) { \
+ if (++__dash == __lastDash) \
+ __dash = __firstDash; \
+ (dashlen) = *__dash; \
+}
+
+/* as numInDashList is always even, this case can skip a test */
+
+#define FbDashNextEven(dashlen) { \
+ (dashlen) = *++__dash; \
+}
+
+#define FbDashNextOdd(dashlen) FbDashNext(dashlen)
+
+#define FbDashStep(dashlen,even) { \
+ if (!--(dashlen)) { \
+ FbDashNext(dashlen); \
+ (even) = 1-(even); \
+ } \
+}
+
+/* XXX fb*PrivateIndex should be static, but it breaks the ABI */
+
+extern int fbGCPrivateIndex;
+extern int fbGetGCPrivateIndex(void);
+#ifndef FB_NO_WINDOW_PIXMAPS
+extern int fbWinPrivateIndex;
+extern int fbGetWinPrivateIndex(void);
+#endif
+extern const GCOps fbGCOps;
+extern const GCFuncs fbGCFuncs;
+
+#ifdef TEKX11
+#define FB_OLD_GC
+#define FB_OLD_SCREEN
+#endif
+
+#ifdef FB_OLD_SCREEN
+# define FB_OLD_MISCREENINIT /* miScreenInit requires 14 args, not 13 */
+extern WindowPtr *WindowTable;
+#endif
+
+#ifdef FB_24_32BIT
+#define FB_SCREEN_PRIVATE
+#endif
+
+#ifdef FB_SCREEN_PRIVATE
+extern int fbScreenPrivateIndex;
+extern int fbGetScreenPrivateIndex(void);
+
+/* private field of a screen */
+typedef struct {
+ unsigned char win32bpp; /* window bpp for 32-bpp images */
+ unsigned char pix32bpp; /* pixmap bpp for 32-bpp images */
+} FbScreenPrivRec, *FbScreenPrivPtr;
+
+#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
+ (pScreen)->devPrivates[fbGetScreenPrivateIndex()].ptr)
+#endif
+
+/* private field of GC */
+typedef struct {
+#ifdef FB_OLD_GC
+ unsigned char pad1;
+ unsigned char pad2;
+ unsigned char pad3;
+ unsigned fExpose:1;
+ unsigned freeCompClip:1;
+ PixmapPtr pRotatedPixmap;
+ RegionPtr pCompositeClip;
+#endif
+ FbBits and, xor; /* reduced rop values */
+ FbBits bgand, bgxor; /* for stipples */
+ FbBits fg, bg, pm; /* expanded and filled */
+ unsigned int dashLength; /* total of all dash elements */
+ unsigned char oneRect; /* clip list is single rectangle */
+ unsigned char evenStipple; /* stipple is even */
+ unsigned char bpp; /* current drawable bpp */
+} FbGCPrivRec, *FbGCPrivPtr;
+
+#define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\
+ (pGC)->devPrivates[fbGetGCPrivateIndex()].ptr)
+
+#ifdef FB_OLD_GC
+#define fbGetCompositeClip(pGC) (fbGetGCPrivate(pGC)->pCompositeClip)
+#define fbGetExpose(pGC) (fbGetGCPrivate(pGC)->fExpose)
+#define fbGetFreeCompClip(pGC) (fbGetGCPrivate(pGC)->freeCompClip)
+#define fbGetRotatedPixmap(pGC) (fbGetGCPrivate(pGC)->pRotatedPixmap)
+#else
+#define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip)
+#define fbGetExpose(pGC) ((pGC)->fExpose)
+#define fbGetFreeCompClip(pGC) ((pGC)->freeCompClip)
+#define fbGetRotatedPixmap(pGC) ((pGC)->pRotatedPixmap)
+#endif
+
+#define fbGetScreenPixmap(s) ((PixmapPtr) (s)->devPrivate)
+#ifdef FB_NO_WINDOW_PIXMAPS
+#define fbGetWindowPixmap(d) fbGetScreenPixmap(((DrawablePtr) (d))->pScreen)
+#else
+#define fbGetWindowPixmap(pWin) ((PixmapPtr)\
+ ((WindowPtr) (pWin))->devPrivates[fbGetWinPrivateIndex()].ptr)
+#endif
+
+#ifdef ROOTLESS
+#define __fbPixDrawableX(pPix) ((pPix)->drawable.x)
+#define __fbPixDrawableY(pPix) ((pPix)->drawable.y)
+#else
+#define __fbPixDrawableX(pPix) 0
+#define __fbPixDrawableY(pPix) 0
+#endif
+
+#ifdef COMPOSITE
+#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix) - (pPix)->screen_x)
+#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix) - (pPix)->screen_y)
+#else
+#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix))
+#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix))
+#endif
+#define __fbPixOffXPix(pPix) (__fbPixDrawableX(pPix))
+#define __fbPixOffYPix(pPix) (__fbPixDrawableY(pPix))
+
+#define fbGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
+ PixmapPtr _pPix; \
+ if ((pDrawable)->type != DRAWABLE_PIXMAP) { \
+ _pPix = fbGetWindowPixmap(pDrawable); \
+ (xoff) = __fbPixOffXWin(_pPix); \
+ (yoff) = __fbPixOffYWin(_pPix); \
+ } else { \
+ _pPix = (PixmapPtr) (pDrawable); \
+ (xoff) = __fbPixOffXPix(_pPix); \
+ (yoff) = __fbPixOffYPix(_pPix); \
+ } \
+ (pointer) = (FbBits *) _pPix->devPrivate.ptr; \
+ (stride) = ((int) _pPix->devKind) / sizeof (FbBits); (void)(stride); \
+ (bpp) = _pPix->drawable.bitsPerPixel; (void)(bpp); \
+}
+
+#define fbGetStipDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
+ PixmapPtr _pPix; \
+ if ((pDrawable)->type != DRAWABLE_PIXMAP) { \
+ _pPix = fbGetWindowPixmap(pDrawable); \
+ (xoff) = __fbPixOffXWin(_pPix); \
+ (yoff) = __fbPixOffYWin(_pPix); \
+ } else { \
+ _pPix = (PixmapPtr) (pDrawable); \
+ (xoff) = __fbPixOffXPix(_pPix); \
+ (yoff) = __fbPixOffYPix(_pPix); \
+ } \
+ (pointer) = (FbStip *) _pPix->devPrivate.ptr; \
+ (stride) = ((int) _pPix->devKind) / sizeof (FbStip); (void)(stride); \
+ (bpp) = _pPix->drawable.bitsPerPixel; (void)(bpp); \
+}
+
+/*
+ * XFree86 empties the root BorderClip when the VT is inactive,
+ * here's a macro which uses that to disable GetImage and GetSpans
+ */
+
+#define fbWindowEnabled(pWin) \
+ REGION_NOTEMPTY((pWin)->drawable.pScreen, \
+ &WindowTable[(pWin)->drawable.pScreen->myNum]->borderClip)
+
+#define fbDrawableEnabled(pDrawable) \
+ ((pDrawable)->type == DRAWABLE_PIXMAP ? \
+ TRUE : fbWindowEnabled((WindowPtr) pDrawable))
+
+#ifdef FB_OLD_SCREEN
+#define BitsPerPixel(d) (\
+ ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
+ (PixmapWidthPaddingInfo[d].padRoundUp+1)))
+#endif
+
+#define FbPowerOfTwo(w) (((w) & ((w) - 1)) == 0)
+/*
+ * Accelerated tiles are power of 2 width <= FB_UNIT
+ */
+#define FbEvenTile(w) ((w) <= FB_UNIT && FbPowerOfTwo(w))
+/*
+ * Accelerated stipples are power of 2 width and <= FB_UNIT/dstBpp
+ * with dstBpp a power of 2 as well
+ */
+#define FbEvenStip(w,bpp) ((w) * (bpp) <= FB_UNIT && FbPowerOfTwo(w) && FbPowerOfTwo(bpp))
+
+/*
+ * fb24_32.c
+ */
+void
+fb24_32GetSpans(DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pchardstStart);
+
+void
+fb24_32SetSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *src,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted);
+
+void
+fb24_32PutZImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int alu,
+ FbBits pm,
+ int x,
+ int y,
+ int width,
+ int height,
+ CARD8 *src,
+ FbStride srcStride);
+
+void
+fb24_32GetImage (DrawablePtr pDrawable,
+ int x,
+ int y,
+ int w,
+ int h,
+ unsigned int format,
+ unsigned long planeMask,
+ char *d);
+
+void
+fb24_32CopyMtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+PixmapPtr
+fb24_32ReformatTile(PixmapPtr pOldTile, int bitsPerPixel);
+
+Bool
+fb24_32CreateScreenResources(ScreenPtr pScreen);
+
+Bool
+fb24_32ModifyPixmapHeader (PixmapPtr pPixmap,
+ int width,
+ int height,
+ int depth,
+ int bitsPerPixel,
+ int devKind,
+ pointer pPixData);
+
+/*
+ * fballpriv.c
+ */
+Bool
+fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex);
+
+/*
+ * fbarc.c
+ */
+
+void
+fbPolyArc (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int narcs,
+ xArc *parcs);
+
+/*
+ * fbbits.c
+ */
+
+void
+fbBresSolid8(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+void
+fbBresDash8 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+void
+fbDots8 (FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor);
+
+void
+fbArc8 (FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int dx,
+ int dy,
+ FbBits and,
+ FbBits xor);
+
+void
+fbGlyph8 (FbBits *dstLine,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int height,
+ int shift);
+
+void
+fbPolyline8 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ptsOrig);
+
+void
+fbPolySegment8 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg);
+
+void
+fbBresSolid16(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+void
+fbBresDash16(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+void
+fbDots16(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor);
+
+void
+fbArc16(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int dx,
+ int dy,
+ FbBits and,
+ FbBits xor);
+
+void
+fbGlyph16(FbBits *dstLine,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int height,
+ int shift);
+
+void
+fbPolyline16 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ptsOrig);
+
+void
+fbPolySegment16 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg);
+
+
+void
+fbBresSolid24(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+void
+fbBresDash24(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+void
+fbDots24(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor);
+
+void
+fbArc24(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int dx,
+ int dy,
+ FbBits and,
+ FbBits xor);
+
+void
+fbGlyph24(FbBits *dstLine,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int height,
+ int shift);
+
+void
+fbPolyline24 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ptsOrig);
+
+void
+fbPolySegment24 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg);
+
+
+void
+fbBresSolid32(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+void
+fbBresDash32(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+void
+fbDots32(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor);
+
+void
+fbArc32(FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int dx,
+ int dy,
+ FbBits and,
+ FbBits xor);
+
+void
+fbGlyph32(FbBits *dstLine,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int height,
+ int shift);
+void
+fbPolyline32 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ptsOrig);
+
+void
+fbPolySegment32 (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg);
+
+/*
+ * fbblt.c
+ */
+void
+fbBlt (FbBits *src,
+ FbStride srcStride,
+ int srcX,
+
+ FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+ int bpp,
+
+ Bool reverse,
+ Bool upsidedown);
+
+void
+fbBlt24 (FbBits *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ FbBits *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+
+ Bool reverse,
+ Bool upsidedown);
+
+void
+fbBltStip (FbStip *src,
+ FbStride srcStride, /* in FbStip units, not FbBits units */
+ int srcX,
+
+ FbStip *dst,
+ FbStride dstStride, /* in FbStip units, not FbBits units */
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+ int bpp);
+
+/*
+ * fbbltone.c
+ */
+void
+fbBltOne (FbStip *src,
+ FbStride srcStride,
+ int srcX,
+ FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbBits fgand,
+ FbBits fbxor,
+ FbBits bgand,
+ FbBits bgxor);
+
+#ifdef FB_24BIT
+void
+fbBltOne24 (FbStip *src,
+ FbStride srcStride, /* FbStip units per scanline */
+ int srcX, /* bit position of source */
+ FbBits *dst,
+ FbStride dstStride, /* FbBits units per scanline */
+ int dstX, /* bit position of dest */
+ int dstBpp, /* bits per destination unit */
+
+ int width, /* width in bits of destination */
+ int height, /* height in scanlines */
+
+ FbBits fgand, /* rrop values */
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor);
+#endif
+
+void
+fbBltPlane (FbBits *src,
+ FbStride srcStride,
+ int srcX,
+ int srcBpp,
+
+ FbStip *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbStip fgand,
+ FbStip fgxor,
+ FbStip bgand,
+ FbStip bgxor,
+ Pixel planeMask);
+
+/*
+ * fbbstore.c
+ */
+void
+fbSaveAreas(PixmapPtr pPixmap,
+ RegionPtr prgnSave,
+ int xorg,
+ int yorg,
+ WindowPtr pWin);
+
+void
+fbRestoreAreas(PixmapPtr pPixmap,
+ RegionPtr prgnRestore,
+ int xorg,
+ int yorg,
+ WindowPtr pWin);
+
+/*
+ * fbcmap.c
+ */
+int
+fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps);
+
+void
+fbInstallColormap(ColormapPtr pmap);
+
+void
+fbUninstallColormap(ColormapPtr pmap);
+
+void
+fbResolveColor(unsigned short *pred,
+ unsigned short *pgreen,
+ unsigned short *pblue,
+ VisualPtr pVisual);
+
+Bool
+fbInitializeColormap(ColormapPtr pmap);
+
+int
+fbExpandDirectColors (ColormapPtr pmap,
+ int ndef,
+ xColorItem *indefs,
+ xColorItem *outdefs);
+
+Bool
+fbCreateDefColormap(ScreenPtr pScreen);
+
+void
+fbClearVisualTypes(void);
+
+Bool
+fbSetVisualTypes (int depth, int visuals, int bitsPerRGB);
+
+Bool
+fbSetVisualTypesAndMasks (int depth, int visuals, int bitsPerRGB,
+ Pixel redMask, Pixel greenMask, Pixel blueMask);
+
+Bool
+fbInitVisuals (VisualPtr *visualp,
+ DepthPtr *depthp,
+ int *nvisualp,
+ int *ndepthp,
+ int *rootDepthp,
+ VisualID *defaultVisp,
+ unsigned long sizes,
+ int bitsPerRGB);
+
+/*
+ * fbcopy.c
+ */
+
+typedef void (*fbCopyProc) (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pDstBox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+void
+fbCopyNtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+void
+fbCopy1toN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+void
+fbCopyNto1 (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+void
+fbCopyRegion (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ RegionPtr pDstRegion,
+ int dx,
+ int dy,
+ fbCopyProc copyProc,
+ Pixel bitPlane,
+ void *closure);
+
+RegionPtr
+fbDoCopy (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut,
+ fbCopyProc copyProc,
+ Pixel bitplane,
+ void *closure);
+
+RegionPtr
+fbCopyArea (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut);
+
+RegionPtr
+fbCopyPlane (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut,
+ unsigned long bitplane);
+
+/*
+ * fbfill.c
+ */
+void
+fbFill (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int width,
+ int height);
+
+void
+fbSolidBoxClipped (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int xa,
+ int ya,
+ int xb,
+ int yb,
+ FbBits and,
+ FbBits xor);
+
+/*
+ * fbfillrect.c
+ */
+void
+fbPolyFillRect(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nrectInit,
+ xRectangle *prectInit);
+
+#define fbPolyFillArc miPolyFillArc
+
+#define fbFillPolygon miFillPolygon
+
+/*
+ * fbfillsp.c
+ */
+void
+fbFillSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nInit,
+ DDXPointPtr pptInit,
+ int *pwidthInit,
+ int fSorted);
+
+
+/*
+ * fbgc.c
+ */
+
+Bool
+fbCreateGC(GCPtr pGC);
+
+void
+fbPadPixmap (PixmapPtr pPixmap);
+
+void
+fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable);
+
+/*
+ * fbgetsp.c
+ */
+void
+fbGetSpans(DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pchardstStart);
+
+/*
+ * fbglyph.c
+ */
+
+Bool
+fbGlyphIn (RegionPtr pRegion,
+ int x,
+ int y,
+ int width,
+ int height);
+
+void
+fbPolyGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase);
+
+void
+fbImageGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase);
+
+/*
+ * fbimage.c
+ */
+
+void
+fbPutImage (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int depth,
+ int x,
+ int y,
+ int w,
+ int h,
+ int leftPad,
+ int format,
+ char *pImage);
+
+void
+fbPutZImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int alu,
+ FbBits pm,
+ int x,
+ int y,
+ int width,
+ int height,
+ FbStip *src,
+ FbStride srcStride);
+
+void
+fbPutXYImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ FbBits fg,
+ FbBits bg,
+ FbBits pm,
+ int alu,
+ Bool opaque,
+
+ int x,
+ int y,
+ int width,
+ int height,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX);
+
+void
+fbGetImage (DrawablePtr pDrawable,
+ int x,
+ int y,
+ int w,
+ int h,
+ unsigned int format,
+ unsigned long planeMask,
+ char *d);
+/*
+ * fbline.c
+ */
+
+void
+fbZeroLine (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ppt);
+
+void
+fbZeroSegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSegs);
+
+void
+fbPolyLine (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ppt);
+
+void
+fbFixCoordModePrevious (int npt,
+ DDXPointPtr ppt);
+
+void
+fbPolySegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg);
+
+#define fbPolyRectangle miPolyRectangle
+
+/*
+ * fbpict.c
+ */
+
+Bool
+fbPictureInit (ScreenPtr pScreen,
+ PictFormatPtr formats,
+ int nformats);
+
+/*
+ * fbpixmap.c
+ */
+
+PixmapPtr
+fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp);
+
+PixmapPtr
+fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth);
+
+Bool
+fbDestroyPixmap (PixmapPtr pPixmap);
+
+RegionPtr
+fbPixmapToRegion(PixmapPtr pPix);
+
+/*
+ * fbpoint.c
+ */
+
+void
+fbDots (FbBits *dstOrig,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits andOrig,
+ FbBits xorOrig);
+
+void
+fbPolyPoint (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ xPoint *pptInit);
+
+/*
+ * fbpush.c
+ */
+void
+fbPushPattern (DrawablePtr pDrawable,
+ GCPtr pGC,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX,
+
+ int x,
+ int y,
+
+ int width,
+ int height);
+
+void
+fbPushFill (DrawablePtr pDrawable,
+ GCPtr pGC,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX,
+
+ int x,
+ int y,
+ int width,
+ int height);
+
+void
+fbPush1toN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+void
+fbPushImage (DrawablePtr pDrawable,
+ GCPtr pGC,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX,
+
+ int x,
+ int y,
+ int width,
+ int height);
+
+void
+fbPushPixels (GCPtr pGC,
+ PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int dx,
+ int dy,
+ int xOrg,
+ int yOrg);
+
+
+/*
+ * fbscreen.c
+ */
+
+Bool
+fbCloseScreen (int indx, ScreenPtr pScreen);
+
+Bool
+fbRealizeFont(ScreenPtr pScreen, FontPtr pFont);
+
+Bool
+fbUnrealizeFont(ScreenPtr pScreen, FontPtr pFont);
+
+void
+fbQueryBestSize (int class,
+ unsigned short *width, unsigned short *height,
+ ScreenPtr pScreen);
+
+#ifndef FB_OLD_SCREEN
+PixmapPtr
+_fbGetWindowPixmap (WindowPtr pWindow);
+
+void
+_fbSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap);
+#endif
+
+Bool
+fbSetupScreen(ScreenPtr pScreen,
+ pointer pbits, /* pointer to screen bitmap */
+ int xsize, /* in pixels */
+ int ysize,
+ int dpix, /* dots per inch */
+ int dpiy,
+ int width, /* pixel width of frame buffer */
+ int bpp); /* bits per pixel of frame buffer */
+
+Bool
+fbFinishScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp);
+
+Bool
+fbScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp);
+
+void
+fbInitializeBackingStore (ScreenPtr pScreen);
+
+/*
+ * fbseg.c
+ */
+typedef void FbBres (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+FbBres fbBresSolid, fbBresDash, fbBresFill, fbBresFillDash;
+/*
+ * fbsetsp.c
+ */
+
+void
+fbSetSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *src,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted);
+
+FbBres *
+fbSelectBres (DrawablePtr pDrawable,
+ GCPtr pGC);
+
+void
+fbBres (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x,
+ int y,
+ int e,
+ int e1,
+ int e3,
+ int len);
+
+void
+fbSegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xa,
+ int ya,
+ int xb,
+ int yb,
+ Bool drawLast,
+ int *dashOffset);
+
+
+/*
+ * fbsolid.c
+ */
+
+void
+fbSolid (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int bpp,
+
+ int width,
+ int height,
+
+ FbBits and,
+ FbBits xor);
+
+#ifdef FB_24BIT
+void
+fbSolid24 (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits and,
+ FbBits xor);
+#endif
+
+/*
+ * fbstipple.c
+ */
+
+void
+fbTransparentSpan (FbBits *dst,
+ FbBits stip,
+ FbBits fgxor,
+ int n);
+
+void
+fbEvenStipple (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbStip *stip,
+ FbStride stipStride,
+ int stipHeight,
+
+ FbBits fgand,
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor,
+
+ int xRot,
+ int yRot);
+
+void
+fbOddStipple (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbStip *stip,
+ FbStride stipStride,
+ int stipWidth,
+ int stipHeight,
+
+ FbBits fgand,
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor,
+
+ int xRot,
+ int yRot);
+
+void
+fbStipple (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbStip *stip,
+ FbStride stipStride,
+ int stipWidth,
+ int stipHeight,
+ Bool even,
+
+ FbBits fgand,
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor,
+
+ int xRot,
+ int yRot);
+
+/*
+ * fbtile.c
+ */
+
+void
+fbEvenTile (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits *tile,
+ int tileHeight,
+
+ int alu,
+ FbBits pm,
+ int xRot,
+ int yRot);
+
+void
+fbOddTile (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits *tile,
+ FbStride tileStride,
+ int tileWidth,
+ int tileHeight,
+
+ int alu,
+ FbBits pm,
+ int bpp,
+
+ int xRot,
+ int yRot);
+
+void
+fbTile (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits *tile,
+ FbStride tileStride,
+ int tileWidth,
+ int tileHeight,
+
+ int alu,
+ FbBits pm,
+ int bpp,
+
+ int xRot,
+ int yRot);
+
+/*
+ * fbutil.c
+ */
+FbBits
+fbReplicatePixel (Pixel p, int bpp);
+
+void
+fbReduceRasterOp (int rop, FbBits fg, FbBits pm, FbBits *andp, FbBits *xorp);
+
+/*
+ * fbwindow.c
+ */
+
+Bool
+fbCreateWindow(WindowPtr pWin);
+
+Bool
+fbDestroyWindow(WindowPtr pWin);
+
+Bool
+fbMapWindow(WindowPtr pWindow);
+
+Bool
+fbPositionWindow(WindowPtr pWin, int x, int y);
+
+Bool
+fbUnmapWindow(WindowPtr pWindow);
+
+void
+fbCopyWindowProc (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+void
+fbCopyWindow(WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc);
+
+Bool
+fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
+
+void
+fbFillRegionSolid (DrawablePtr pDrawable,
+ RegionPtr pRegion,
+ FbBits and,
+ FbBits xor);
+
+void
+fbFillRegionTiled (DrawablePtr pDrawable,
+ RegionPtr pRegion,
+ PixmapPtr pTile);
+
+void
+fbPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
+
+
+#endif /* _FB_H_ */
diff --git a/nx-X11/programs/Xserver/fb/fb24_32.c b/nx-X11/programs/Xserver/fb/fb24_32.c
new file mode 100644
index 000000000..214e2e6dd
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fb24_32.c
@@ -0,0 +1,627 @@
+/*
+ * $XFree86: xc/programs/Xserver/fb/fb24_32.c,v 1.4 2000/08/09 17:50:51 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef XFree86LOADER
+#include "xf86.h"
+#include "xf86_ansic.h"
+#endif
+
+#include "fb.h"
+
+/* X apps don't like 24bpp images, this code exposes 32bpp images */
+
+/*
+ * These two functions do a full CopyArea while reformatting
+ * the data between 24 and 32bpp. They try to go a bit faster
+ * by reading/writing aligned CARD32s where it's easy
+ */
+
+#define Get8(a) ((CARD32) *(a))
+
+#if BITMAP_BIT_ORDER == MSBFirst
+#define Get24(a) ((Get8(a) << 16) | (Get8((a)+1) << 8) | Get8((a)+2))
+#define Put24(a,p) (((a)[0] = (CARD8) ((p) >> 16)), \
+ ((a)[1] = (CARD8) ((p) >> 8)), \
+ ((a)[2] = (CARD8) (p)))
+#else
+#define Get24(a) (Get8(a) | (Get8((a)+1) << 8) | (Get8((a)+2)<<16))
+#define Put24(a,p) (((a)[0] = (CARD8) (p)), \
+ ((a)[1] = (CARD8) ((p) >> 8)), \
+ ((a)[2] = (CARD8) ((p) >> 16)))
+#endif
+
+typedef void (*fb24_32BltFunc) (CARD8 *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ CARD8 *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm);
+
+static void
+fb24_32BltDown (CARD8 *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ CARD8 *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm)
+{
+ CARD32 *src;
+ CARD8 *dst;
+ int w;
+ Bool destInvarient;
+ CARD32 pixel, dpixel;
+ FbDeclareMergeRop ();
+
+ srcLine += srcX * 4;
+ dstLine += dstX * 3;
+
+ FbInitializeMergeRop(alu, (pm | ~(FbBits) 0xffffff));
+ destInvarient = FbDestInvarientMergeRop();
+
+ while (height--)
+ {
+ src = (CARD32 *) srcLine;
+ dst = dstLine;
+ srcLine += srcStride;
+ dstLine += dstStride;
+ w = width;
+ if (destInvarient)
+ {
+ while (((long) dst & 3) && w)
+ {
+ w--;
+ pixel = *src++;
+ pixel = FbDoDestInvarientMergeRop(pixel);
+ Put24 (dst, pixel);
+ dst += 3;
+ }
+ /* Do four aligned pixels at a time */
+ while (w >= 4)
+ {
+ CARD32 s0, s1;
+ s0 = *src++;
+ s0 = FbDoDestInvarientMergeRop(s0);
+ s1 = *src++;
+ s1 = FbDoDestInvarientMergeRop(s1);
+#if BITMAP_BIT_ORDER == LSBFirst
+ *(CARD32 *)(dst) = (s0 & 0xffffff) | (s1 << 24);
+#else
+ *(CARD32 *)(dst) = (s0 << 8) | ((s1 & 0xffffff) >> 16);
+#endif
+ s0 = *src++;
+ s0 = FbDoDestInvarientMergeRop(s0);
+#if BITMAP_BIT_ORDER == LSBFirst
+ *(CARD32 *)(dst+4) = ((s1 & 0xffffff) >> 8) | (s0 << 16);
+#else
+ *(CARD32 *)(dst+4) = (s1 << 16) | ((s0 & 0xffffff) >> 8);
+#endif
+ s1 = *src++;
+ s1 = FbDoDestInvarientMergeRop(s1);
+#if BITMAP_BIT_ORDER == LSBFirst
+ *(CARD32 *)(dst+8) = ((s0 & 0xffffff) >> 16) | (s1 << 8);
+#else
+ *(CARD32 *)(dst+8) = (s0 << 24) | (s1 & 0xffffff);
+#endif
+ dst += 12;
+ w -= 4;
+ }
+ while (w--)
+ {
+ pixel = *src++;
+ pixel = FbDoDestInvarientMergeRop(pixel);
+ Put24 (dst, pixel);
+ dst += 3;
+ }
+ }
+ else
+ {
+ while (w--)
+ {
+ pixel = *src++;
+ dpixel = Get24 (dst);
+ pixel = FbDoMergeRop(pixel, dpixel);
+ Put24 (dst, pixel);
+ dst += 3;
+ }
+ }
+ }
+}
+
+static void
+fb24_32BltUp (CARD8 *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ CARD8 *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm)
+{
+ CARD8 *src;
+ CARD32 *dst;
+ int w;
+ Bool destInvarient;
+ CARD32 pixel;
+ FbDeclareMergeRop ();
+
+ FbInitializeMergeRop(alu, (pm | (~(FbBits) 0xffffff)));
+ destInvarient = FbDestInvarientMergeRop();
+
+ srcLine += srcX * 3;
+ dstLine += dstX * 4;
+
+ while (height--)
+ {
+ w = width;
+ src = srcLine;
+ dst = (CARD32 *) dstLine;
+ srcLine += srcStride;
+ dstLine += dstStride;
+ if (destInvarient)
+ {
+ while (((long) src & 3) && w)
+ {
+ w--;
+ pixel = Get24(src);
+ src += 3;
+ *dst++ = FbDoDestInvarientMergeRop(pixel);
+ }
+ /* Do four aligned pixels at a time */
+ while (w >= 4)
+ {
+ CARD32 s0, s1;
+
+ s0 = *(CARD32 *)(src);
+#if BITMAP_BIT_ORDER == LSBFirst
+ pixel = s0 & 0xffffff;
+#else
+ pixel = s0 >> 8;
+#endif
+ *dst++ = FbDoDestInvarientMergeRop(pixel);
+ s1 = *(CARD32 *)(src+4);
+#if BITMAP_BIT_ORDER == LSBFirst
+ pixel = (s0 >> 24) | ((s1 << 8) & 0xffffff);
+#else
+ pixel = ((s0 << 16) & 0xffffff) | (s1 >> 16);
+#endif
+ *dst++ = FbDoDestInvarientMergeRop(pixel);
+ s0 = *(CARD32 *)(src+8);
+#if BITMAP_BIT_ORDER == LSBFirst
+ pixel = (s1 >> 16) | ((s0 << 16) & 0xffffff);
+#else
+ pixel = ((s1 << 8) & 0xffffff) | (s0 >> 24);
+#endif
+ *dst++ = FbDoDestInvarientMergeRop(pixel);
+#if BITMAP_BIT_ORDER == LSBFirst
+ pixel = s0 >> 8;
+#else
+ pixel = s0 & 0xffffff;
+#endif
+ *dst++ = FbDoDestInvarientMergeRop(pixel);
+ src += 12;
+ w -= 4;
+ }
+ while (w)
+ {
+ w--;
+ pixel = Get24(src);
+ src += 3;
+ *dst++ = FbDoDestInvarientMergeRop(pixel);
+ }
+ }
+ else
+ {
+ while (w--)
+ {
+ pixel = Get24(src);
+ src += 3;
+ *dst = FbDoMergeRop(pixel, *dst);
+ dst++;
+ }
+ }
+ }
+}
+
+/*
+ * Spans functions; probably unused.
+ */
+void
+fb24_32GetSpans(DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pchardstStart)
+{
+ FbBits *srcBits;
+ CARD8 *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ CARD8 *dst;
+
+ fbGetDrawable (pDrawable, srcBits, srcStride, srcBpp, srcXoff, srcYoff);
+ src = (CARD8 *) srcBits;
+ srcStride *= sizeof (FbBits);
+
+ while (nspans--)
+ {
+ dst = (CARD8 *) pchardstStart;
+ fb24_32BltUp (src + (ppt->y + srcYoff) * srcStride, srcStride,
+ ppt->x + srcXoff,
+
+ dst,
+ 1,
+ 0,
+
+ *pwidth,
+ 1,
+
+ GXcopy,
+ FB_ALLONES);
+
+ pchardstStart += PixmapBytePad(*pwidth, pDrawable->depth);
+ ppt++;
+ pwidth++;
+ }
+}
+
+void
+fb24_32SetSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *src,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ FbBits *dstBits;
+ CARD8 *dst, *d, *s;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ BoxPtr pbox;
+ int n;
+ int x1, x2;
+
+ fbGetDrawable (pDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff);
+ dst = (CARD8 *) dstBits;
+ dstStride *= sizeof (FbBits);
+ while (nspans--)
+ {
+ d = dst + (ppt->y + dstYoff) * dstStride;
+ s = (CARD8 *) src;
+ n = REGION_NUM_RECTS(pClip);
+ pbox = REGION_RECTS (pClip);
+ while (n--)
+ {
+ if (pbox->y1 > ppt->y)
+ break;
+ if (pbox->y2 > ppt->y)
+ {
+ x1 = ppt->x;
+ x2 = x1 + *pwidth;
+ if (pbox->x1 > x1)
+ x1 = pbox->x1;
+ if (pbox->x2 < x2)
+ x2 = pbox->x2;
+ if (x1 < x2)
+ fb24_32BltDown (s,
+ 0,
+ (x1 - ppt->x),
+ d,
+ dstStride,
+ x1 + dstXoff,
+
+ (x2 - x1),
+ 1,
+ pGC->alu,
+ pPriv->pm);
+ }
+ }
+ src += PixmapBytePad (*pwidth, pDrawable->depth);
+ ppt++;
+ pwidth++;
+ }
+}
+
+/*
+ * Clip and put 32bpp Z-format images to a 24bpp drawable
+ */
+void
+fb24_32PutZImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int alu,
+ FbBits pm,
+ int x,
+ int y,
+ int width,
+ int height,
+ CARD8 *src,
+ FbStride srcStride)
+{
+ FbBits *dstBits;
+ CARD8 *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ int nbox;
+ BoxPtr pbox;
+ int x1, y1, x2, y2;
+
+ fbGetDrawable (pDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff);
+ dstStride *= sizeof(FbBits);
+ dst = (CARD8 *) dstBits;
+
+ for (nbox = REGION_NUM_RECTS (pClip),
+ pbox = REGION_RECTS(pClip);
+ nbox--;
+ pbox++)
+ {
+ x1 = x;
+ y1 = y;
+ x2 = x + width;
+ y2 = y + height;
+ if (x1 < pbox->x1)
+ x1 = pbox->x1;
+ if (y1 < pbox->y1)
+ y1 = pbox->y1;
+ if (x2 > pbox->x2)
+ x2 = pbox->x2;
+ if (y2 > pbox->y2)
+ y2 = pbox->y2;
+ if (x1 >= x2 || y1 >= y2)
+ continue;
+ fb24_32BltDown (src + (y1 - y) * srcStride,
+ srcStride,
+ (x1 - x),
+
+ dst + (y1 + dstYoff) * dstStride,
+ dstStride,
+ x1 + dstXoff,
+
+ (x2 - x1),
+ (y2 - y1),
+
+ alu,
+ pm);
+ }
+}
+
+void
+fb24_32GetImage (DrawablePtr pDrawable,
+ int x,
+ int y,
+ int w,
+ int h,
+ unsigned int format,
+ unsigned long planeMask,
+ char *d)
+{
+ FbBits *srcBits;
+ CARD8 *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ FbStride dstStride;
+ FbBits pm;
+
+ fbGetDrawable (pDrawable, srcBits, srcStride, srcBpp, srcXoff, srcYoff);
+ src = (CARD8 *) srcBits;
+ srcStride *= sizeof (FbBits);
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ pm = fbReplicatePixel (planeMask, 32);
+ dstStride = PixmapBytePad(w, pDrawable->depth);
+ if (pm != FB_ALLONES)
+ memset (d, 0, dstStride * h);
+ fb24_32BltUp (src + (y + srcYoff) * srcStride, srcStride, x + srcXoff,
+ (CARD8 *) d, dstStride, 0,
+ w, h, GXcopy, pm);
+}
+
+void
+fb24_32CopyMtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ FbBits *srcBits;
+ CARD8 *src;
+ FbStride srcStride;
+ int srcBpp;
+ FbBits *dstBits;
+ CARD8 *dst;
+ FbStride dstStride;
+ int dstBpp;
+ fb24_32BltFunc blt;
+ int srcXoff, srcYoff;
+ int dstXoff, dstYoff;
+
+ fbGetDrawable (pSrcDrawable, srcBits, srcStride, srcBpp, srcXoff, srcYoff);
+ src = (CARD8 *) srcBits;
+ srcStride *= sizeof (FbBits);
+ fbGetDrawable (pDstDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff);
+ dst = (CARD8 *) dstBits;
+ dstStride *= sizeof (FbBits);
+ if (srcBpp == 24)
+ blt = fb24_32BltUp;
+ else
+ blt = fb24_32BltDown;
+
+ while (nbox--)
+ {
+ (*blt) (src + (pbox->y1 + dy + srcYoff) * srcStride,
+ srcStride,
+ (pbox->x1 + dx + srcXoff),
+
+ dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff),
+
+ (pbox->x2 - pbox->x1),
+ (pbox->y2 - pbox->y1),
+
+ pGC->alu,
+ pPriv->pm);
+ pbox++;
+ }
+}
+
+PixmapPtr
+fb24_32ReformatTile(PixmapPtr pOldTile, int bitsPerPixel)
+{
+ ScreenPtr pScreen = pOldTile->drawable.pScreen;
+ PixmapPtr pNewTile;
+ FbBits *old, *new;
+ FbStride oldStride, newStride;
+ int oldBpp, newBpp;
+ fb24_32BltFunc blt;
+ int oldXoff, oldYoff;
+ int newXoff, newYoff;
+
+ pNewTile = fbCreatePixmapBpp (pScreen,
+ pOldTile->drawable.width,
+ pOldTile->drawable.height,
+ pOldTile->drawable.depth,
+ bitsPerPixel);
+ if (!pNewTile)
+ return 0;
+ fbGetDrawable (&pOldTile->drawable,
+ old, oldStride, oldBpp, oldXoff, oldYoff);
+ fbGetDrawable (&pNewTile->drawable,
+ new, newStride, newBpp, newXoff, newYoff);
+ if (oldBpp == 24)
+ blt = fb24_32BltUp;
+ else
+ blt = fb24_32BltDown;
+
+ (*blt) ((CARD8 *) old,
+ oldStride * sizeof (FbBits),
+ 0,
+
+ (CARD8 *) new,
+ newStride * sizeof (FbBits),
+ 0,
+
+ pOldTile->drawable.width,
+ pOldTile->drawable.height,
+
+ GXcopy,
+ FB_ALLONES);
+
+ return pNewTile;
+}
+
+typedef struct {
+ pointer pbits;
+ int width;
+} miScreenInitParmsRec, *miScreenInitParmsPtr;
+
+Bool
+fb24_32CreateScreenResources(ScreenPtr pScreen)
+{
+ miScreenInitParmsPtr pScrInitParms;
+ int pitch;
+ Bool retval;
+
+ /* get the pitch before mi destroys it */
+ pScrInitParms = (miScreenInitParmsPtr)pScreen->devPrivate;
+ pitch = BitmapBytePad(pScrInitParms->width * 24);
+
+ if((retval = miCreateScreenResources(pScreen))) {
+ /* fix the screen pixmap */
+ PixmapPtr pPix = (PixmapPtr)pScreen->devPrivate;
+ pPix->drawable.bitsPerPixel = 24;
+ pPix->devKind = pitch;
+ }
+
+ return retval;
+}
+
+Bool
+fb24_32ModifyPixmapHeader (PixmapPtr pPixmap,
+ int width,
+ int height,
+ int depth,
+ int bitsPerPixel,
+ int devKind,
+ pointer pPixData)
+{
+ int bpp, w;
+
+ if (!pPixmap)
+ return FALSE;
+ bpp = bitsPerPixel;
+ if (bpp <= 0)
+ bpp = pPixmap->drawable.bitsPerPixel;
+ if (bpp == 24)
+ {
+ if (devKind < 0)
+ {
+ w = width;
+ if (w <= 0)
+ w = pPixmap->drawable.width;
+ devKind = BitmapBytePad(w * 24);
+ }
+ }
+ return miModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel,
+ devKind, pPixData);
+}
diff --git a/nx-X11/programs/Xserver/fb/fb24_32.h b/nx-X11/programs/Xserver/fb/fb24_32.h
new file mode 100644
index 000000000..3c83f3423
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fb24_32.h
@@ -0,0 +1,53 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _FB24_32_H_
+#define _FB24_32_H_
+
+Bool
+fb24_32FinishScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp);
+
+Bool
+fb24_32ScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp);
+
+#endif
diff --git a/nx-X11/programs/Xserver/fb/fballpriv.c b/nx-X11/programs/Xserver/fb/fballpriv.c
new file mode 100644
index 000000000..75b577049
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fballpriv.c
@@ -0,0 +1,93 @@
+/*
+ * Id: fballpriv.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fballpriv.c,v 1.3 2000/02/23 20:29:41 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+#ifdef FB_SCREEN_PRIVATE
+int fbScreenPrivateIndex;
+int fbGetScreenPrivateIndex(void)
+{
+ return fbScreenPrivateIndex;
+}
+#endif
+int fbGCPrivateIndex;
+int fbGetGCPrivateIndex(void)
+{
+ return fbGCPrivateIndex;
+}
+#ifndef FB_NO_WINDOW_PIXMAPS
+int fbWinPrivateIndex;
+int fbGetWinPrivateIndex(void)
+{
+ return fbWinPrivateIndex;
+}
+#endif
+int fbGeneration;
+
+#ifdef FB_OLD_SCREEN
+#define miAllocateGCPrivateIndex() AllocateGCPrivateIndex()
+#endif
+
+Bool
+fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex)
+{
+ if (fbGeneration != serverGeneration)
+ {
+ fbGCPrivateIndex = miAllocateGCPrivateIndex ();
+#ifndef FB_NO_WINDOW_PIXMAPS
+ fbWinPrivateIndex = AllocateWindowPrivateIndex();
+#endif
+#ifdef FB_SCREEN_PRIVATE
+ fbScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ if (fbScreenPrivateIndex == -1)
+ return FALSE;
+#endif
+
+ fbGeneration = serverGeneration;
+ }
+ if (pGCIndex)
+ *pGCIndex = fbGCPrivateIndex;
+ if (!AllocateGCPrivate(pScreen, fbGCPrivateIndex, sizeof(FbGCPrivRec)))
+ return FALSE;
+#ifndef FB_NO_WINDOW_PIXMAPS
+ if (!AllocateWindowPrivate(pScreen, fbWinPrivateIndex, 0))
+ return FALSE;
+#endif
+#ifdef FB_SCREEN_PRIVATE
+ {
+ FbScreenPrivPtr pScreenPriv;
+
+ pScreenPriv = (FbScreenPrivPtr) xalloc (sizeof (FbScreenPrivRec));
+ if (!pScreenPriv)
+ return FALSE;
+ pScreen->devPrivates[fbScreenPrivateIndex].ptr = (pointer) pScreenPriv;
+ }
+#endif
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/fb/fbarc.c b/nx-X11/programs/Xserver/fb/fbarc.c
new file mode 100644
index 000000000..315aa181c
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbarc.c
@@ -0,0 +1,122 @@
+/*
+ * Id: fbarc.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbarc.c,v 1.7tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include "mizerarc.h"
+#ifdef IN_MODULE
+#include "xf86_ansic.h"
+#endif
+
+typedef void (*FbArc) (FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int dx,
+ int dy,
+ FbBits and,
+ FbBits xor);
+
+void
+fbPolyArc (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int narcs,
+ xArc *parcs)
+{
+ FbArc arc;
+
+ if (pGC->lineWidth == 0)
+ {
+#ifndef FBNOPIXADDR
+ arc = 0;
+ if (pGC->lineStyle == LineSolid && pGC->fillStyle == FillSolid)
+ {
+ switch (pDrawable->bitsPerPixel)
+ {
+ case 8: arc = fbArc8; break;
+ case 16: arc = fbArc16; break;
+#ifdef FB_24BIT
+ case 24: arc = fbArc24; break;
+#endif
+ case 32: arc = fbArc32; break;
+ }
+ }
+ if (arc)
+ {
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ BoxRec box;
+ int x2, y2;
+ RegionPtr cclip;
+
+ cclip = fbGetCompositeClip (pGC);
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ while (narcs--)
+ {
+ if (miCanZeroArc (parcs))
+ {
+ box.x1 = parcs->x + pDrawable->x;
+ box.y1 = parcs->y + pDrawable->y;
+ /*
+ * Because box.x2 and box.y2 get truncated to 16 bits, and the
+ * RECT_IN_REGION test treats the resulting number as a signed
+ * integer, the RECT_IN_REGION test alone can go the wrong way.
+ * This can result in a server crash because the rendering
+ * routines in this file deal directly with cpu addresses
+ * of pixels to be stored, and do not clip or otherwise check
+ * that all such addresses are within their respective pixmaps.
+ * So we only allow the RECT_IN_REGION test to be used for
+ * values that can be expressed correctly in a signed short.
+ */
+ x2 = box.x1 + (int)parcs->width + 1;
+ box.x2 = x2;
+ y2 = box.y1 + (int)parcs->height + 1;
+ box.y2 = y2;
+ if ( (x2 <= MAXSHORT) && (y2 <= MAXSHORT) &&
+ (RECT_IN_REGION(pDrawable->pScreen, cclip, &box) == rgnIN) )
+ (*arc) (dst, dstStride, dstBpp,
+ parcs, pDrawable->x + dstXoff, pDrawable->y + dstYoff,
+ pPriv->and, pPriv->xor);
+ else
+ miZeroPolyArc(pDrawable, pGC, 1, parcs);
+ }
+ else
+ miPolyArc(pDrawable, pGC, 1, parcs);
+ parcs++;
+ }
+ }
+ else
+#endif
+ miZeroPolyArc (pDrawable, pGC, narcs, parcs);
+ }
+ else
+ miPolyArc (pDrawable, pGC, narcs, parcs);
+}
diff --git a/nx-X11/programs/Xserver/fb/fbbits.c b/nx-X11/programs/Xserver/fb/fbbits.c
new file mode 100644
index 000000000..ab67b4cf3
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbbits.c
@@ -0,0 +1,179 @@
+/*
+ * Id: fbbits.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbbits.c,v 1.5 2000/02/17 14:16:22 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include "miline.h"
+#include "mizerarc.h"
+
+#undef BRESSOLID
+#undef BRESDASH
+#undef DOTS
+#undef ARC
+#undef GLYPH
+#undef BITS
+#undef BITS2
+#undef BITS4
+
+#define BRESSOLID fbBresSolid8
+#define BRESDASH fbBresDash8
+#define DOTS fbDots8
+#define ARC fbArc8
+#define GLYPH fbGlyph8
+#define POLYLINE fbPolyline8
+#define POLYSEGMENT fbPolySegment8
+#define BITS BYTE
+#define BITS2 CARD16
+#define BITS4 CARD32
+
+#include "fbbits.h"
+
+#undef BRESSOLID
+#undef BRESDASH
+#undef DOTS
+#undef ARC
+#undef GLYPH
+#undef POLYLINE
+#undef POLYSEGMENT
+#undef BITS
+#undef BITS2
+#undef BITS4
+
+#define BRESSOLID fbBresSolid16
+#define BRESDASH fbBresDash16
+#define DOTS fbDots16
+#define ARC fbArc16
+#define GLYPH fbGlyph16
+#define POLYLINE fbPolyline16
+#define POLYSEGMENT fbPolySegment16
+#define BITS CARD16
+#define BITS2 CARD32
+#if FB_SHIFT == 6
+#define BITS4 FbBits
+#endif
+
+#include "fbbits.h"
+
+#undef BRESSOLID
+#undef BRESDASH
+#undef DOTS
+#undef ARC
+#undef GLYPH
+#undef POLYLINE
+#undef POLYSEGMENT
+#undef BITS
+#undef BITS2
+#if FB_SHIFT == 6
+#undef BITS4
+#endif
+
+#ifdef FB_24BIT
+#define BRESSOLID fbBresSolid24
+#define BRESDASH fbBresDash24
+#define DOTS fbDots24
+#define ARC fbArc24
+#define POLYLINE fbPolyline24
+#define POLYSEGMENT fbPolySegment24
+
+#define BITS CARD32
+#define BITSUNIT BYTE
+#define BITSMUL 3
+
+#define FbDoTypeStore(b,t,x,s) (*((t *) (b)) = (x) >> (s))
+#define FbDoTypeRRop(b,t,a,x,s) (*((t *) (b)) = FbDoRRop(*((t *) (b)),\
+ (a) >> (s), \
+ (x) >> (s)))
+#define FbDoTypeMaskRRop(b,t,a,x,m,s) (*((t *) (b)) = FbDoMaskRRop(*((t *) (b)),\
+ (a) >> (s), \
+ (x) >> (s), \
+ (m) >> (s))
+#if BITMAP_BIT_ORDER == LSBFirst
+#define BITSSTORE(b,x) ((unsigned long) (b) & 1 ? \
+ (FbDoTypeStore (b, CARD8, x, 0), \
+ FbDoTypeStore ((b) + 1, CARD16, x, 8)) : \
+ (FbDoTypeStore (b, CARD16, x, 0), \
+ FbDoTypeStore ((b) + 2, CARD8, x, 16)))
+#define BITSRROP(b,a,x) ((unsigned long) (b) & 1 ? \
+ (FbDoTypeRRop(b,CARD8,a,x,0), \
+ FbDoTypeRRop((b)+1,CARD16,a,x,8)) : \
+ (FbDoTypeRRop(b,CARD16,a,x,0), \
+ FbDoTypeRRop((b)+2,CARD8,a,x,16)))
+#else
+#define BITSSTORE(b,x) ((unsigned long) (b) & 1 ? \
+ (FbDoTypeStore (b, CARD8, x, 16), \
+ FbDoTypeStore ((b) + 1, CARD16, x, 0)) : \
+ (FbDoTypeStore (b, CARD16, x, 8), \
+ FbDoTypeStore ((b) + 2, CARD8, x, 0)))
+#define BITSRROP(b,a,x) ((unsigned long) (b) & 1 ? \
+ (FbDoTypeRRop (b, CARD8, a, x, 16), \
+ FbDoTypeRRop ((b) + 1, CARD16, a, x, 0)) : \
+ (FbDoTypeRRop (b, CARD16, a, x, 8), \
+ FbDoTypeRRop ((b) + 2, CARD8, a, x, 0)))
+#endif
+
+#include "fbbits.h"
+
+#undef BITSSTORE
+#undef BITSRROP
+#undef BITSMUL
+#undef BITSUNIT
+#undef BITS
+
+#undef BRESSOLID
+#undef BRESDASH
+#undef DOTS
+#undef ARC
+#undef POLYLINE
+#undef POLYSEGMENT
+#endif /* FB_24BIT */
+
+#define BRESSOLID fbBresSolid32
+#define BRESDASH fbBresDash32
+#define DOTS fbDots32
+#define ARC fbArc32
+#define GLYPH fbGlyph32
+#define POLYLINE fbPolyline32
+#define POLYSEGMENT fbPolySegment32
+#define BITS CARD32
+#if FB_SHIFT == 6
+#define BITS2 FbBits
+#endif
+
+#include "fbbits.h"
+
+#undef BRESSOLID
+#undef BRESDASH
+#undef DOTS
+#undef ARC
+#undef GLYPH
+#undef POLYLINE
+#undef POLYSEGMENT
+#undef BITS
+#if FB_SHIFT == 6
+#undef BITS2
+#endif
diff --git a/nx-X11/programs/Xserver/fb/fbbits.h b/nx-X11/programs/Xserver/fb/fbbits.h
new file mode 100644
index 000000000..7dfff58b4
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbbits.h
@@ -0,0 +1,964 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * This file defines functions for drawing some primitives using
+ * underlying datatypes instead of masks
+ */
+
+#define isClipped(c,ul,lr) ((((c) - (ul)) | ((lr) - (c))) & 0x80008000)
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef BITSMUL
+#define MUL BITSMUL
+#else
+#define MUL 1
+#endif
+
+#ifdef BITSSTORE
+#define STORE(b,x) BITSSTORE(b,x)
+#else
+#define STORE(b,x) (*(b) = (x))
+#endif
+
+#ifdef BITSRROP
+#define RROP(b,a,x) BITSRROP(b,a,x)
+#else
+#define RROP(b,a,x) (*(b) = FbDoRRop (*(b), (a), (x)))
+#endif
+
+#ifdef BITSUNIT
+#define UNIT BITSUNIT
+#define USE_SOLID
+#else
+#define UNIT BITS
+#endif
+
+/*
+ * Define the following before including this file:
+ *
+ * BRESSOLID name of function for drawing a solid segment
+ * BRESDASH name of function for drawing a dashed segment
+ * DOTS name of function for drawing dots
+ * ARC name of function for drawing a solid arc
+ * BITS type of underlying unit
+ */
+
+#ifdef BRESSOLID
+void
+BRESSOLID (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ UNIT *bits;
+ FbStride bitsStride;
+ FbStride majorStep, minorStep;
+ BITS xor = (BITS) pPriv->xor;
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ bits = ((UNIT *) (dst + ((y1 + dstYoff) * dstStride))) + (x1 + dstXoff) * MUL;
+ bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
+ if (signdy < 0)
+ bitsStride = -bitsStride;
+ if (axis == X_AXIS)
+ {
+ majorStep = signdx * MUL;
+ minorStep = bitsStride;
+ }
+ else
+ {
+ majorStep = bitsStride;
+ minorStep = signdx * MUL;
+ }
+ while (len--)
+ {
+ STORE(bits,xor);
+ bits += majorStep;
+ e += e1;
+ if (e >= 0)
+ {
+ bits += minorStep;
+ e += e3;
+ }
+ }
+}
+#endif
+
+#ifdef BRESDASH
+void
+BRESDASH (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ UNIT *bits;
+ FbStride bitsStride;
+ FbStride majorStep, minorStep;
+ BITS xorfg, xorbg;
+ FbDashDeclare;
+ int dashlen;
+ Bool even;
+ Bool doOdd;
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ doOdd = pGC->lineStyle == LineDoubleDash;
+ xorfg = (BITS) pPriv->xor;
+ xorbg = (BITS) pPriv->bgxor;
+
+ FbDashInit (pGC, pPriv, dashOffset, dashlen, even);
+
+ bits = ((UNIT *) (dst + ((y1 + dstYoff) * dstStride))) + (x1 + dstXoff) * MUL;
+ bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
+ if (signdy < 0)
+ bitsStride = -bitsStride;
+ if (axis == X_AXIS)
+ {
+ majorStep = signdx * MUL;
+ minorStep = bitsStride;
+ }
+ else
+ {
+ majorStep = bitsStride;
+ minorStep = signdx * MUL;
+ }
+ if (dashlen >= len)
+ dashlen = len;
+ if (doOdd)
+ {
+ if (!even)
+ goto doubleOdd;
+ for (;;)
+ {
+ len -= dashlen;
+ while (dashlen--)
+ {
+ STORE(bits,xorfg);
+ bits += majorStep;
+ if ((e += e1) >= 0)
+ {
+ e += e3;
+ bits += minorStep;
+ }
+ }
+ if (!len)
+ break;
+
+ FbDashNextEven(dashlen);
+
+ if (dashlen >= len)
+ dashlen = len;
+doubleOdd:
+ len -= dashlen;
+ while (dashlen--)
+ {
+ STORE(bits,xorbg);
+ bits += majorStep;
+ if ((e += e1) >= 0)
+ {
+ e += e3;
+ bits += minorStep;
+ }
+ }
+ if (!len)
+ break;
+
+ FbDashNextOdd(dashlen);
+
+ if (dashlen >= len)
+ dashlen = len;
+ }
+ }
+ else
+ {
+ if (!even)
+ goto onOffOdd;
+ for (;;)
+ {
+ len -= dashlen;
+ while (dashlen--)
+ {
+ STORE(bits,xorfg);
+ bits += majorStep;
+ if ((e += e1) >= 0)
+ {
+ e += e3;
+ bits += minorStep;
+ }
+ }
+ if (!len)
+ break;
+
+ FbDashNextEven (dashlen);
+
+ if (dashlen >= len)
+ dashlen = len;
+onOffOdd:
+ len -= dashlen;
+ while (dashlen--)
+ {
+ bits += majorStep;
+ if ((e += e1) >= 0)
+ {
+ e += e3;
+ bits += minorStep;
+ }
+ }
+ if (!len)
+ break;
+
+ FbDashNextOdd (dashlen);
+
+ if (dashlen >= len)
+ dashlen = len;
+ }
+ }
+}
+#endif
+
+#ifdef DOTS
+void
+DOTS (FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *ptsOrig,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor)
+{
+ INT32 *pts = (INT32 *) ptsOrig;
+ UNIT *bits = (UNIT *) dst;
+ UNIT *point;
+ BITS bxor = (BITS) xor;
+ BITS band = (BITS) and;
+ FbStride bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
+ INT32 ul, lr;
+ INT32 pt;
+
+ ul = coordToInt(pBox->x1 - xorg, pBox->y1 - yorg);
+ lr = coordToInt(pBox->x2 - xorg - 1, pBox->y2 - yorg - 1);
+
+ bits += bitsStride * (yorg + yoff) + (xorg + xoff) * MUL;
+
+ if (and == 0)
+ {
+ while (npt--)
+ {
+ pt = *pts++;
+ if (!isClipped(pt,ul,lr))
+ {
+ point = bits + intToY(pt) * bitsStride + intToX(pt) * MUL;
+ STORE(point,bxor);
+ }
+ }
+ }
+ else
+ {
+ while (npt--)
+ {
+ pt = *pts++;
+ if (!isClipped(pt,ul,lr))
+ {
+ point = bits + intToY(pt) * bitsStride + intToX(pt) * MUL;
+ RROP(point,band,bxor);
+ }
+ }
+ }
+}
+#endif
+
+#ifdef ARC
+
+#define ARCCOPY(d) STORE(d,xorBits)
+#define ARCRROP(d) RROP(d,andBits,xorBits)
+
+void
+ARC (FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ xArc *arc,
+ int drawX,
+ int drawY,
+ FbBits and,
+ FbBits xor)
+{
+ UNIT *bits;
+ FbStride bitsStride;
+ miZeroArcRec info;
+ Bool do360;
+ int x;
+ UNIT *yorgp, *yorgop;
+ BITS andBits, xorBits;
+ int yoffset, dyoffset;
+ int y, a, b, d, mask;
+ int k1, k3, dx, dy;
+
+ bits = (UNIT *) dst;
+ bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
+ andBits = (BITS) and;
+ xorBits = (BITS) xor;
+ do360 = miZeroArcSetup(arc, &info, TRUE);
+ yorgp = bits + ((info.yorg + drawY) * bitsStride);
+ yorgop = bits + ((info.yorgo + drawY) * bitsStride);
+ info.xorg = (info.xorg + drawX) * MUL;
+ info.xorgo = (info.xorgo + drawX) * MUL;
+ MIARCSETUP();
+ yoffset = y ? bitsStride : 0;
+ dyoffset = 0;
+ mask = info.initialMask;
+
+ if (!(arc->width & 1))
+ {
+ if (andBits == 0)
+ {
+ if (mask & 2)
+ ARCCOPY(yorgp + info.xorgo);
+ if (mask & 8)
+ ARCCOPY(yorgop + info.xorgo);
+ }
+ else
+ {
+ if (mask & 2)
+ ARCRROP(yorgp + info.xorgo);
+ if (mask & 8)
+ ARCRROP(yorgop + info.xorgo);
+ }
+ }
+ if (!info.end.x || !info.end.y)
+ {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ if (do360 && (arc->width == arc->height) && !(arc->width & 1))
+ {
+ int xoffset = bitsStride;
+ UNIT *yorghb = yorgp + (info.h * bitsStride) + info.xorg;
+ UNIT *yorgohb = yorghb - info.h * MUL;
+
+ yorgp += info.xorg;
+ yorgop += info.xorg;
+ yorghb += info.h * MUL;
+ while (1)
+ {
+ if (andBits == 0)
+ {
+ ARCCOPY(yorgp + yoffset + x * MUL);
+ ARCCOPY(yorgp + yoffset - x * MUL);
+ ARCCOPY(yorgop - yoffset - x * MUL);
+ ARCCOPY(yorgop - yoffset + x * MUL);
+ }
+ else
+ {
+ ARCRROP(yorgp + yoffset + x * MUL);
+ ARCRROP(yorgp + yoffset - x * MUL);
+ ARCRROP(yorgop - yoffset - x * MUL);
+ ARCRROP(yorgop - yoffset + x * MUL);
+ }
+ if (a < 0)
+ break;
+ if (andBits == 0)
+ {
+ ARCCOPY(yorghb - xoffset - y * MUL);
+ ARCCOPY(yorgohb - xoffset + y * MUL);
+ ARCCOPY(yorgohb + xoffset + y * MUL);
+ ARCCOPY(yorghb + xoffset - y * MUL);
+ }
+ else
+ {
+ ARCRROP(yorghb - xoffset - y * MUL);
+ ARCRROP(yorgohb - xoffset + y * MUL);
+ ARCRROP(yorgohb + xoffset + y * MUL);
+ ARCRROP(yorghb + xoffset - y * MUL);
+ }
+ xoffset += bitsStride;
+ MIARCCIRCLESTEP(yoffset += bitsStride;);
+ }
+ yorgp -= info.xorg;
+ yorgop -= info.xorg;
+ x = info.w;
+ yoffset = info.h * bitsStride;
+ }
+ else if (do360)
+ {
+ while (y < info.h || x < info.w)
+ {
+ MIARCOCTANTSHIFT(dyoffset = bitsStride;);
+ if (andBits == 0)
+ {
+ ARCCOPY(yorgp + yoffset + info.xorg + x * MUL);
+ ARCCOPY(yorgp + yoffset + info.xorgo - x * MUL);
+ ARCCOPY(yorgop - yoffset + info.xorgo - x * MUL);
+ ARCCOPY(yorgop - yoffset + info.xorg + x * MUL);
+ }
+ else
+ {
+ ARCRROP(yorgp + yoffset + info.xorg + x * MUL);
+ ARCRROP(yorgp + yoffset + info.xorgo - x * MUL);
+ ARCRROP(yorgop - yoffset + info.xorgo - x * MUL);
+ ARCRROP(yorgop - yoffset + info.xorg + x * MUL);
+ }
+ MIARCSTEP(yoffset += dyoffset;, yoffset += bitsStride;);
+ }
+ }
+ else
+ {
+ while (y < info.h || x < info.w)
+ {
+ MIARCOCTANTSHIFT(dyoffset = bitsStride;);
+ if ((x == info.start.x) || (y == info.start.y))
+ {
+ mask = info.start.mask;
+ info.start = info.altstart;
+ }
+ if (andBits == 0)
+ {
+ if (mask & 1)
+ ARCCOPY(yorgp + yoffset + info.xorg + x * MUL);
+ if (mask & 2)
+ ARCCOPY(yorgp + yoffset + info.xorgo - x * MUL);
+ if (mask & 4)
+ ARCCOPY(yorgop - yoffset + info.xorgo - x * MUL);
+ if (mask & 8)
+ ARCCOPY(yorgop - yoffset + info.xorg + x * MUL);
+ }
+ else
+ {
+ if (mask & 1)
+ ARCRROP(yorgp + yoffset + info.xorg + x * MUL);
+ if (mask & 2)
+ ARCRROP(yorgp + yoffset + info.xorgo - x * MUL);
+ if (mask & 4)
+ ARCRROP(yorgop - yoffset + info.xorgo - x * MUL);
+ if (mask & 8)
+ ARCRROP(yorgop - yoffset + info.xorg + x * MUL);
+ }
+ if ((x == info.end.x) || (y == info.end.y))
+ {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ MIARCSTEP(yoffset += dyoffset;, yoffset += bitsStride;);
+ }
+ }
+ if ((x == info.start.x) || (y == info.start.y))
+ mask = info.start.mask;
+ if (andBits == 0)
+ {
+ if (mask & 1)
+ ARCCOPY(yorgp + yoffset + info.xorg + x * MUL);
+ if (mask & 4)
+ ARCCOPY(yorgop - yoffset + info.xorgo - x * MUL);
+ if (arc->height & 1)
+ {
+ if (mask & 2)
+ ARCCOPY(yorgp + yoffset + info.xorgo - x * MUL);
+ if (mask & 8)
+ ARCCOPY(yorgop - yoffset + info.xorg + x * MUL);
+ }
+ }
+ else
+ {
+ if (mask & 1)
+ ARCRROP(yorgp + yoffset + info.xorg + x * MUL);
+ if (mask & 4)
+ ARCRROP(yorgop - yoffset + info.xorgo - x * MUL);
+ if (arc->height & 1)
+ {
+ if (mask & 2)
+ ARCRROP(yorgp + yoffset + info.xorgo - x * MUL);
+ if (mask & 8)
+ ARCRROP(yorgop - yoffset + info.xorg + x * MUL);
+ }
+ }
+}
+#undef ARCCOPY
+#undef ARCRROP
+#endif
+
+#ifdef GLYPH
+#if BITMAP_BIT_ORDER == LSBFirst
+# define WRITE_ADDR1(n) (n)
+# define WRITE_ADDR2(n) (n)
+# define WRITE_ADDR4(n) (n)
+#else
+# define WRITE_ADDR1(n) ((n) ^ 3)
+# define WRITE_ADDR2(n) ((n) ^ 2)
+# define WRITE_ADDR4(n) ((n))
+#endif
+
+#define WRITE1(d,n,fg) ((d)[WRITE_ADDR1(n)] = (BITS) (fg))
+
+#ifdef BITS2
+# define WRITE2(d,n,fg) (*((BITS2 *) &((d)[WRITE_ADDR2(n)])) = (BITS2) (fg))
+#else
+# define WRITE2(d,n,fg) WRITE1(d,(n)+1,WRITE1(d,n,fg))
+#endif
+
+#ifdef BITS4
+# define WRITE4(d,n,fg) (*((BITS4 *) &((d)[WRITE_ADDR4(n)])) = (BITS4) (fg))
+#else
+# define WRITE4(d,n,fg) WRITE2(d,(n)+2,WRITE2(d,n,fg))
+#endif
+
+void
+GLYPH (FbBits *dstBits,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int x,
+ int height)
+{
+ int lshift;
+ FbStip bits;
+ BITS *dstLine;
+ BITS *dst;
+ int n;
+ int shift;
+
+ dstLine = (BITS *) dstBits;
+ dstLine += x & ~3;
+ dstStride *= (sizeof (FbBits) / sizeof (BITS));
+ shift = x & 3;
+ lshift = 4 - shift;
+ while (height--)
+ {
+ bits = *stipple++;
+ dst = (BITS *) dstLine;
+ n = lshift;
+ while (bits)
+ {
+ switch (FbStipMoveLsb (FbLeftStipBits (bits, n), 4, n)) {
+ case 0:
+ break;
+ case 1:
+ WRITE1(dst,0,fg);
+ break;
+ case 2:
+ WRITE1(dst,1,fg);
+ break;
+ case 3:
+ WRITE2(dst,0,fg);
+ break;
+ case 4:
+ WRITE1(dst,2,fg);
+ break;
+ case 5:
+ WRITE1(dst,0,fg);
+ WRITE1(dst,2,fg);
+ break;
+ case 6:
+ WRITE1(dst,1,fg);
+ WRITE1(dst,2,fg);
+ break;
+ case 7:
+ WRITE2(dst,0,fg);
+ WRITE1(dst,2,fg);
+ break;
+ case 8:
+ WRITE1(dst,3,fg);
+ break;
+ case 9:
+ WRITE1(dst,0,fg);
+ WRITE1(dst,3,fg);
+ break;
+ case 10:
+ WRITE1(dst,1,fg);
+ WRITE1(dst,3,fg);
+ break;
+ case 11:
+ WRITE2(dst,0,fg);
+ WRITE1(dst,3,fg);
+ break;
+ case 12:
+ WRITE2(dst,2,fg);
+ break;
+ case 13:
+ WRITE1(dst,0,fg);
+ WRITE2(dst,2,fg);
+ break;
+ case 14:
+ WRITE1(dst,1,fg);
+ WRITE2(dst,2,fg);
+ break;
+ case 15:
+ WRITE4(dst,0,fg);
+ break;
+ }
+ bits = FbStipLeft (bits, n);
+ n = 4;
+ dst += 4;
+ }
+ dstLine += dstStride;
+ }
+}
+#undef WRITE_ADDR1
+#undef WRITE_ADDR2
+#undef WRITE_ADDR4
+#undef WRITE1
+#undef WRITE2
+#undef WRITE4
+
+#endif
+
+#ifdef POLYLINE
+void
+POLYLINE (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ptsOrig)
+{
+ INT32 *pts = (INT32 *) ptsOrig;
+ int xoff = pDrawable->x;
+ int yoff = pDrawable->y;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ BoxPtr pBox = REGION_EXTENTS (pDrawable->pScreen, fbGetCompositeClip (pGC));
+
+ FbBits *dst;
+ int dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+
+ UNIT *bits, *bitsBase;
+ FbStride bitsStride;
+ BITS xor = fbGetGCPrivate(pGC)->xor;
+ BITS and = fbGetGCPrivate(pGC)->and;
+ int dashoffset = 0;
+
+ INT32 ul, lr;
+ INT32 pt1, pt2;
+
+ int e, e1, e3, len;
+ int stepmajor, stepminor;
+ int octant;
+
+ if (mode == CoordModePrevious)
+ fbFixCoordModePrevious (npt, ptsOrig);
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
+ bitsBase = ((UNIT *) dst) + (yoff + dstYoff) * bitsStride + (xoff + dstXoff) * MUL;
+ ul = coordToInt(pBox->x1 - xoff, pBox->y1 - yoff);
+ lr = coordToInt(pBox->x2 - xoff - 1, pBox->y2 - yoff - 1);
+
+ pt1 = *pts++;
+ npt--;
+ pt2 = *pts++;
+ npt--;
+ for (;;)
+ {
+ if (isClipped (pt1, ul, lr) | isClipped (pt2, ul, lr))
+ {
+ fbSegment (pDrawable, pGC,
+ intToX(pt1) + xoff, intToY(pt1) + yoff,
+ intToX(pt2) + xoff, intToY(pt2) + yoff,
+ npt == 0 && pGC->capStyle != CapNotLast,
+ &dashoffset);
+ if (!npt)
+ return;
+ pt1 = pt2;
+ pt2 = *pts++;
+ npt--;
+ }
+ else
+ {
+ bits = bitsBase + intToY(pt1) * bitsStride + intToX(pt1) * MUL;
+ for (;;)
+ {
+ CalcLineDeltas (intToX(pt1), intToY(pt1),
+ intToX(pt2), intToY(pt2),
+ len, e1, stepmajor, stepminor, 1, bitsStride,
+ octant);
+ stepmajor *= MUL;
+ if (len < e1)
+ {
+ e3 = len;
+ len = e1;
+ e1 = e3;
+
+ e3 = stepminor;
+ stepminor = stepmajor;
+ stepmajor = e3;
+ SetYMajorOctant(octant);
+ }
+ e = -len;
+ e1 <<= 1;
+ e3 = e << 1;
+ FIXUP_ERROR (e, octant, bias);
+ if (and == 0)
+ {
+ while (len--)
+ {
+ STORE(bits,xor);
+ bits += stepmajor;
+ e += e1;
+ if (e >= 0)
+ {
+ bits += stepminor;
+ e += e3;
+ }
+ }
+ }
+ else
+ {
+ while (len--)
+ {
+ RROP(bits,and,xor);
+ bits += stepmajor;
+ e += e1;
+ if (e >= 0)
+ {
+ bits += stepminor;
+ e += e3;
+ }
+ }
+ }
+ if (!npt)
+ {
+ if (pGC->capStyle != CapNotLast &&
+ pt2 != *((INT32 *) ptsOrig))
+ {
+ RROP(bits,and,xor);
+ }
+ return;
+ }
+ pt1 = pt2;
+ pt2 = *pts++;
+ --npt;
+ if (isClipped (pt2, ul, lr))
+ break;
+ }
+ }
+ }
+}
+#endif
+
+#ifdef POLYSEGMENT
+void
+POLYSEGMENT (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg)
+{
+ INT32 *pts = (INT32 *) pseg;
+ int xoff = pDrawable->x;
+ int yoff = pDrawable->y;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ BoxPtr pBox = REGION_EXTENTS (pDrawable->pScreen, fbGetCompositeClip (pGC));
+
+ FbBits *dst;
+ int dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+
+ UNIT *bits, *bitsBase;
+ FbStride bitsStride;
+ FbBits xorBits = fbGetGCPrivate(pGC)->xor;
+ FbBits andBits = fbGetGCPrivate(pGC)->and;
+ BITS xor = xorBits;
+ BITS and = andBits;
+ int dashoffset = 0;
+
+ INT32 ul, lr;
+ INT32 pt1, pt2;
+
+ int e, e1, e3, len;
+ int stepmajor, stepminor;
+ int octant;
+ Bool capNotLast;
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
+ bitsBase = ((UNIT *) dst) + (yoff + dstYoff) * bitsStride + (xoff + dstXoff) * MUL;
+ ul = coordToInt(pBox->x1 - xoff, pBox->y1 - yoff);
+ lr = coordToInt(pBox->x2 - xoff - 1, pBox->y2 - yoff - 1);
+
+ bits += bitsStride * yoff + xoff * MUL;
+
+ capNotLast = pGC->capStyle == CapNotLast;
+
+ while (nseg--)
+ {
+ pt1 = *pts++;
+ pt2 = *pts++;
+ if (isClipped (pt1, ul, lr) | isClipped (pt2, ul, lr))
+ {
+ fbSegment (pDrawable, pGC,
+ intToX(pt1) + xoff, intToY(pt1) + yoff,
+ intToX(pt2) + xoff, intToY(pt2) + yoff,
+ !capNotLast, &dashoffset);
+ }
+ else
+ {
+ CalcLineDeltas (intToX(pt1), intToY(pt1),
+ intToX(pt2), intToY(pt2),
+ len, e1, stepmajor, stepminor, 1, bitsStride,
+ octant);
+ if (e1 == 0 && len > 3
+#if MUL != 1
+ && FbCheck24Pix(and) && FbCheck24Pix(xor)
+#endif
+ )
+ {
+ int x1, x2;
+ FbBits *dstLine;
+ int dstX, width;
+ FbBits startmask, endmask;
+ int nmiddle;
+
+ if (stepmajor < 0)
+ {
+ x1 = intToX(pt2);
+ x2 = intToX(pt1) + 1;
+ if (capNotLast)
+ x1++;
+ }
+ else
+ {
+ x1 = intToX(pt1);
+ x2 = intToX(pt2);
+ if (!capNotLast)
+ x2++;
+ }
+ dstX = (x1 + xoff + dstXoff) * (sizeof (UNIT) * 8 * MUL);
+ width = (x2 - x1) * (sizeof (UNIT) * 8 * MUL);
+
+ dstLine = dst + (intToY(pt1) + yoff + dstYoff) * dstStride;
+ dstLine += dstX >> FB_SHIFT;
+ dstX &= FB_MASK;
+ FbMaskBits (dstX, width, startmask, nmiddle, endmask);
+ if (startmask)
+ {
+ *dstLine = FbDoMaskRRop (*dstLine, andBits, xorBits, startmask);
+ dstLine++;
+ }
+ if (!andBits)
+ while (nmiddle--)
+ *dstLine++ = xorBits;
+ else
+ while (nmiddle--)
+ {
+ *dstLine = FbDoRRop (*dstLine, andBits, xorBits);
+ dstLine++;
+ }
+ if (endmask)
+ *dstLine = FbDoMaskRRop (*dstLine, andBits, xorBits, endmask);
+ }
+ else
+ {
+ stepmajor *= MUL;
+ bits = bitsBase + intToY(pt1) * bitsStride + intToX(pt1) * MUL;
+ if (len < e1)
+ {
+ e3 = len;
+ len = e1;
+ e1 = e3;
+
+ e3 = stepminor;
+ stepminor = stepmajor;
+ stepmajor = e3;
+ SetYMajorOctant(octant);
+ }
+ e = -len;
+ e1 <<= 1;
+ e3 = e << 1;
+ FIXUP_ERROR (e, octant, bias);
+ if (!capNotLast)
+ len++;
+ if (and == 0)
+ {
+ while (len--)
+ {
+ STORE(bits,xor);
+ bits += stepmajor;
+ e += e1;
+ if (e >= 0)
+ {
+ bits += stepminor;
+ e += e3;
+ }
+ }
+ }
+ else
+ {
+ while (len--)
+ {
+ RROP(bits,and,xor);
+ bits += stepmajor;
+ e += e1;
+ if (e >= 0)
+ {
+ bits += stepminor;
+ e += e3;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+#endif
+
+#undef MUL
+#undef STORE
+#undef RROP
+#undef UNIT
+#undef USE_SOLID
+
+#undef isClipped
diff --git a/nx-X11/programs/Xserver/fb/fbblt.c b/nx-X11/programs/Xserver/fb/fbblt.c
new file mode 100644
index 000000000..c2617a718
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbblt.c
@@ -0,0 +1,933 @@
+/*
+ * Id: fbblt.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbblt.c,v 1.7 2000/09/22 05:58:01 keithp Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+#define InitializeShifts(sx,dx,ls,rs) { \
+ if (sx != dx) { \
+ if (sx > dx) { \
+ ls = sx - dx; \
+ rs = FB_UNIT - ls; \
+ } else { \
+ rs = dx - sx; \
+ ls = FB_UNIT - rs; \
+ } \
+ } \
+}
+
+void
+fbBlt (FbBits *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ FbBits *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+ int bpp,
+
+ Bool reverse,
+ Bool upsidedown)
+{
+ FbBits *src, *dst;
+ int leftShift, rightShift;
+ FbBits startmask, endmask;
+ FbBits bits, bits1;
+ int n, nmiddle;
+ Bool destInvarient;
+ int startbyte, endbyte;
+ FbDeclareMergeRop ();
+
+#ifdef FB_24BIT
+ if (bpp == 24 && !FbCheck24Pix (pm))
+ {
+ fbBlt24 (srcLine, srcStride, srcX, dstLine, dstStride, dstX,
+ width, height, alu, pm, reverse, upsidedown);
+ return;
+ }
+#endif
+ FbInitializeMergeRop(alu, pm);
+ destInvarient = FbDestInvarientMergeRop();
+ if (upsidedown)
+ {
+ srcLine += (height - 1) * (srcStride);
+ dstLine += (height - 1) * (dstStride);
+ srcStride = -srcStride;
+ dstStride = -dstStride;
+ }
+ FbMaskBitsBytes (dstX, width, destInvarient, startmask, startbyte,
+ nmiddle, endmask, endbyte);
+ if (reverse)
+ {
+ srcLine += ((srcX + width - 1) >> FB_SHIFT) + 1;
+ dstLine += ((dstX + width - 1) >> FB_SHIFT) + 1;
+ srcX = (srcX + width - 1) & FB_MASK;
+ dstX = (dstX + width - 1) & FB_MASK;
+ }
+ else
+ {
+ srcLine += srcX >> FB_SHIFT;
+ dstLine += dstX >> FB_SHIFT;
+ srcX &= FB_MASK;
+ dstX &= FB_MASK;
+ }
+ if (srcX == dstX)
+ {
+ while (height--)
+ {
+ src = srcLine;
+ srcLine += srcStride;
+ dst = dstLine;
+ dstLine += dstStride;
+ if (reverse)
+ {
+ if (endmask)
+ {
+ bits = *--src;
+ --dst;
+ FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
+ }
+ n = nmiddle;
+ if (destInvarient)
+ {
+ while (n--)
+ *--dst = FbDoDestInvarientMergeRop(*--src);
+ }
+ else
+ {
+ while (n--)
+ {
+ bits = *--src;
+ --dst;
+ *dst = FbDoMergeRop (bits, *dst);
+ }
+ }
+ if (startmask)
+ {
+ bits = *--src;
+ --dst;
+ FbDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask);
+ }
+ }
+ else
+ {
+ if (startmask)
+ {
+ bits = *src++;
+ FbDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask);
+ dst++;
+ }
+ n = nmiddle;
+ if (destInvarient)
+ {
+#if 0
+ /*
+ * This provides some speedup on screen->screen blts
+ * over the PCI bus, usually about 10%. But fb
+ * isn't usually used for this operation...
+ */
+ if (_ca2 + 1 == 0 && _cx2 == 0)
+ {
+ FbBits t1, t2, t3, t4;
+ while (n >= 4)
+ {
+ t1 = *src++;
+ t2 = *src++;
+ t3 = *src++;
+ t4 = *src++;
+ *dst++ = t1;
+ *dst++ = t2;
+ *dst++ = t3;
+ *dst++ = t4;
+ n -= 4;
+ }
+ }
+#endif
+ while (n--)
+ *dst++ = FbDoDestInvarientMergeRop(*src++);
+ }
+ else
+ {
+ while (n--)
+ {
+ bits = *src++;
+ *dst = FbDoMergeRop (bits, *dst);
+ dst++;
+ }
+ }
+ if (endmask)
+ {
+ bits = *src;
+ FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
+ }
+ }
+ }
+ }
+ else
+ {
+ if (srcX > dstX)
+ {
+ leftShift = srcX - dstX;
+ rightShift = FB_UNIT - leftShift;
+ }
+ else
+ {
+ rightShift = dstX - srcX;
+ leftShift = FB_UNIT - rightShift;
+ }
+ while (height--)
+ {
+ src = srcLine;
+ srcLine += srcStride;
+ dst = dstLine;
+ dstLine += dstStride;
+
+ bits1 = 0;
+ if (reverse)
+ {
+ if (srcX < dstX)
+ bits1 = *--src;
+ if (endmask)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ if (FbScrRight(endmask, leftShift))
+ {
+ bits1 = *--src;
+ bits |= FbScrLeft(bits1, leftShift);
+ }
+ --dst;
+ FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
+ }
+ n = nmiddle;
+ if (destInvarient)
+ {
+ while (n--)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ bits1 = *--src;
+ bits |= FbScrLeft(bits1, leftShift);
+ --dst;
+ *dst = FbDoDestInvarientMergeRop(bits);
+ }
+ }
+ else
+ {
+ while (n--)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ bits1 = *--src;
+ bits |= FbScrLeft(bits1, leftShift);
+ --dst;
+ *dst = FbDoMergeRop(bits, *dst);
+ }
+ }
+ if (startmask)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ if (FbScrRight(startmask, leftShift))
+ {
+ bits1 = *--src;
+ bits |= FbScrLeft(bits1, leftShift);
+ }
+ --dst;
+ FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask);
+ }
+ }
+ else
+ {
+ if (srcX > dstX)
+ bits1 = *src++;
+ if (startmask)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ if (FbScrLeft(startmask, rightShift))
+ {
+ bits1 = *src++;
+ bits |= FbScrRight(bits1, rightShift);
+ }
+ FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask);
+ dst++;
+ }
+ n = nmiddle;
+ if (destInvarient)
+ {
+ while (n--)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ bits1 = *src++;
+ bits |= FbScrRight(bits1, rightShift);
+ *dst = FbDoDestInvarientMergeRop(bits);
+ dst++;
+ }
+ }
+ else
+ {
+ while (n--)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ bits1 = *src++;
+ bits |= FbScrRight(bits1, rightShift);
+ *dst = FbDoMergeRop(bits, *dst);
+ dst++;
+ }
+ }
+ if (endmask)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ if (FbScrLeft(endmask, rightShift))
+ {
+ bits1 = *src;
+ bits |= FbScrRight(bits1, rightShift);
+ }
+ FbDoRightMaskByteMergeRop (dst, bits, endbyte, endmask);
+ }
+ }
+ }
+ }
+}
+
+#ifdef FB_24BIT
+
+#undef DEBUG_BLT24
+#ifdef DEBUG_BLT24
+
+static unsigned long
+getPixel (char *src, int x)
+{
+ unsigned long l;
+
+ l = 0;
+ memcpy (&l, src + x * 3, 3);
+ return l;
+}
+#endif
+
+static void
+fbBlt24Line (FbBits *src,
+ int srcX,
+
+ FbBits *dst,
+ int dstX,
+
+ int width,
+
+ int alu,
+ FbBits pm,
+
+ Bool reverse)
+{
+#ifdef DEBUG_BLT24
+ char *origDst = (char *) dst;
+ FbBits *origLine = dst + ((dstX >> FB_SHIFT) - 1);
+ int origNlw = ((width + FB_MASK) >> FB_SHIFT) + 3;
+ int origX = dstX / 24;
+#endif
+
+ int leftShift, rightShift;
+ FbBits startmask, endmask;
+ int n;
+
+ FbBits bits, bits1;
+ FbBits mask;
+
+ int rot;
+ FbDeclareMergeRop ();
+
+ FbInitializeMergeRop (alu, FB_ALLONES);
+ FbMaskBits(dstX, width, startmask, n, endmask);
+#ifdef DEBUG_BLT24
+ ErrorF ("dstX %d width %d reverse %d\n", dstX, width, reverse);
+#endif
+ if (reverse)
+ {
+ src += ((srcX + width - 1) >> FB_SHIFT) + 1;
+ dst += ((dstX + width - 1) >> FB_SHIFT) + 1;
+ rot = FbFirst24Rot (((dstX + width - 8) & FB_MASK));
+ rot = FbPrev24Rot(rot);
+#ifdef DEBUG_BLT24
+ ErrorF ("dstX + width - 8: %d rot: %d\n", (dstX + width - 8) & FB_MASK, rot);
+#endif
+ srcX = (srcX + width - 1) & FB_MASK;
+ dstX = (dstX + width - 1) & FB_MASK;
+ }
+ else
+ {
+ src += srcX >> FB_SHIFT;
+ dst += dstX >> FB_SHIFT;
+ srcX &= FB_MASK;
+ dstX &= FB_MASK;
+ rot = FbFirst24Rot (dstX);
+#ifdef DEBUG_BLT24
+ ErrorF ("dstX: %d rot: %d\n", dstX, rot);
+#endif
+ }
+ mask = FbRot24(pm,rot);
+#ifdef DEBUG_BLT24
+ ErrorF ("pm 0x%x mask 0x%x\n", pm, mask);
+#endif
+ if (srcX == dstX)
+ {
+ if (reverse)
+ {
+ if (endmask)
+ {
+ bits = *--src;
+ --dst;
+ *dst = FbDoMaskMergeRop (bits, *dst, mask & endmask);
+ mask = FbPrev24Pix (mask);
+ }
+ while (n--)
+ {
+ bits = *--src;
+ --dst;
+ *dst = FbDoMaskMergeRop (bits, *dst, mask);
+ mask = FbPrev24Pix (mask);
+ }
+ if (startmask)
+ {
+ bits = *--src;
+ --dst;
+ *dst = FbDoMaskMergeRop(bits, *dst, mask & startmask);
+ }
+ }
+ else
+ {
+ if (startmask)
+ {
+ bits = *src++;
+ *dst = FbDoMaskMergeRop (bits, *dst, mask & startmask);
+ dst++;
+ mask = FbNext24Pix(mask);
+ }
+ while (n--)
+ {
+ bits = *src++;
+ *dst = FbDoMaskMergeRop (bits, *dst, mask);
+ dst++;
+ mask = FbNext24Pix(mask);
+ }
+ if (endmask)
+ {
+ bits = *src;
+ *dst = FbDoMaskMergeRop(bits, *dst, mask & endmask);
+ }
+ }
+ }
+ else
+ {
+ if (srcX > dstX)
+ {
+ leftShift = srcX - dstX;
+ rightShift = FB_UNIT - leftShift;
+ }
+ else
+ {
+ rightShift = dstX - srcX;
+ leftShift = FB_UNIT - rightShift;
+ }
+
+ bits1 = 0;
+ if (reverse)
+ {
+ if (srcX < dstX)
+ bits1 = *--src;
+ if (endmask)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ if (FbScrRight(endmask, leftShift))
+ {
+ bits1 = *--src;
+ bits |= FbScrLeft(bits1, leftShift);
+ }
+ --dst;
+ *dst = FbDoMaskMergeRop (bits, *dst, mask & endmask);
+ mask = FbPrev24Pix(mask);
+ }
+ while (n--)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ bits1 = *--src;
+ bits |= FbScrLeft(bits1, leftShift);
+ --dst;
+ *dst = FbDoMaskMergeRop(bits, *dst, mask);
+ mask = FbPrev24Pix(mask);
+ }
+ if (startmask)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ if (FbScrRight(startmask, leftShift))
+ {
+ bits1 = *--src;
+ bits |= FbScrLeft(bits1, leftShift);
+ }
+ --dst;
+ *dst = FbDoMaskMergeRop (bits, *dst, mask & startmask);
+ }
+ }
+ else
+ {
+ if (srcX > dstX)
+ bits1 = *src++;
+ if (startmask)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ bits1 = *src++;
+ bits |= FbScrRight(bits1, rightShift);
+ *dst = FbDoMaskMergeRop (bits, *dst, mask & startmask);
+ dst++;
+ mask = FbNext24Pix(mask);
+ }
+ while (n--)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ bits1 = *src++;
+ bits |= FbScrRight(bits1, rightShift);
+ *dst = FbDoMaskMergeRop(bits, *dst, mask);
+ dst++;
+ mask = FbNext24Pix(mask);
+ }
+ if (endmask)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ if (FbScrLeft(endmask, rightShift))
+ {
+ bits1 = *src;
+ bits |= FbScrRight(bits1, rightShift);
+ }
+ *dst = FbDoMaskMergeRop (bits, *dst, mask & endmask);
+ }
+ }
+ }
+#ifdef DEBUG_BLT24
+ {
+ int firstx, lastx, x;
+
+ firstx = origX;
+ if (firstx)
+ firstx--;
+ lastx = origX + width/24 + 1;
+ for (x = firstx; x <= lastx; x++)
+ ErrorF ("%06x ", getPixel (origDst, x));
+ ErrorF ("\n");
+ while (origNlw--)
+ ErrorF ("%08x ", *origLine++);
+ ErrorF ("\n");
+ }
+#endif
+}
+
+void
+fbBlt24 (FbBits *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ FbBits *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+
+ Bool reverse,
+ Bool upsidedown)
+{
+ if (upsidedown)
+ {
+ srcLine += (height-1) * srcStride;
+ dstLine += (height-1) * dstStride;
+ srcStride = -srcStride;
+ dstStride = -dstStride;
+ }
+ while (height--)
+ {
+ fbBlt24Line (srcLine, srcX, dstLine, dstX, width, alu, pm, reverse);
+ srcLine += srcStride;
+ dstLine += dstStride;
+ }
+#ifdef DEBUG_BLT24
+ ErrorF ("\n");
+#endif
+}
+#endif /* FB_24BIT */
+
+#if FB_SHIFT == FB_STIP_SHIFT + 1
+
+/*
+ * Could be generalized to FB_SHIFT > FB_STIP_SHIFT + 1 by
+ * creating an ring of values stepped through for each line
+ */
+
+void
+fbBltOdd (FbBits *srcLine,
+ FbStride srcStrideEven,
+ FbStride srcStrideOdd,
+ int srcXEven,
+ int srcXOdd,
+
+ FbBits *dstLine,
+ FbStride dstStrideEven,
+ FbStride dstStrideOdd,
+ int dstXEven,
+ int dstXOdd,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+ int bpp)
+{
+ FbBits *src;
+ int leftShiftEven, rightShiftEven;
+ FbBits startmaskEven, endmaskEven;
+ int nmiddleEven;
+
+ FbBits *dst;
+ int leftShiftOdd, rightShiftOdd;
+ FbBits startmaskOdd, endmaskOdd;
+ int nmiddleOdd;
+
+ int leftShift, rightShift;
+ FbBits startmask, endmask;
+ int nmiddle;
+
+ int srcX, dstX;
+
+ FbBits bits, bits1;
+ int n;
+
+ Bool destInvarient;
+ Bool even;
+ FbDeclareMergeRop ();
+
+ FbInitializeMergeRop (alu, pm);
+ destInvarient = FbDestInvarientMergeRop();
+
+ srcLine += srcXEven >> FB_SHIFT;
+ dstLine += dstXEven >> FB_SHIFT;
+ srcXEven &= FB_MASK;
+ dstXEven &= FB_MASK;
+ srcXOdd &= FB_MASK;
+ dstXOdd &= FB_MASK;
+
+ FbMaskBits(dstXEven, width, startmaskEven, nmiddleEven, endmaskEven);
+ FbMaskBits(dstXOdd, width, startmaskOdd, nmiddleOdd, endmaskOdd);
+
+ even = TRUE;
+ InitializeShifts(srcXEven, dstXEven, leftShiftEven, rightShiftEven);
+ InitializeShifts(srcXOdd, dstXOdd, leftShiftOdd, rightShiftOdd);
+ while (height--)
+ {
+ src = srcLine;
+ dst = dstLine;
+ if (even)
+ {
+ srcX = srcXEven;
+ dstX = dstXEven;
+ startmask = startmaskEven;
+ endmask = endmaskEven;
+ nmiddle = nmiddleEven;
+ leftShift = leftShiftEven;
+ rightShift = rightShiftEven;
+ srcLine += srcStrideEven;
+ dstLine += dstStrideEven;
+ even = FALSE;
+ }
+ else
+ {
+ srcX = srcXOdd;
+ dstX = dstXOdd;
+ startmask = startmaskOdd;
+ endmask = endmaskOdd;
+ nmiddle = nmiddleOdd;
+ leftShift = leftShiftOdd;
+ rightShift = rightShiftOdd;
+ srcLine += srcStrideOdd;
+ dstLine += dstStrideOdd;
+ even = TRUE;
+ }
+ if (srcX == dstX)
+ {
+ if (startmask)
+ {
+ bits = *src++;
+ *dst = FbDoMaskMergeRop (bits, *dst, startmask);
+ dst++;
+ }
+ n = nmiddle;
+ if (destInvarient)
+ {
+ while (n--)
+ {
+ bits = *src++;
+ *dst = FbDoDestInvarientMergeRop(bits);
+ dst++;
+ }
+ }
+ else
+ {
+ while (n--)
+ {
+ bits = *src++;
+ *dst = FbDoMergeRop (bits, *dst);
+ dst++;
+ }
+ }
+ if (endmask)
+ {
+ bits = *src;
+ *dst = FbDoMaskMergeRop(bits, *dst, endmask);
+ }
+ }
+ else
+ {
+ bits = 0;
+ if (srcX > dstX)
+ bits = *src++;
+ if (startmask)
+ {
+ bits1 = FbScrLeft(bits, leftShift);
+ bits = *src++;
+ bits1 |= FbScrRight(bits, rightShift);
+ *dst = FbDoMaskMergeRop (bits1, *dst, startmask);
+ dst++;
+ }
+ n = nmiddle;
+ if (destInvarient)
+ {
+ while (n--)
+ {
+ bits1 = FbScrLeft(bits, leftShift);
+ bits = *src++;
+ bits1 |= FbScrRight(bits, rightShift);
+ *dst = FbDoDestInvarientMergeRop(bits1);
+ dst++;
+ }
+ }
+ else
+ {
+ while (n--)
+ {
+ bits1 = FbScrLeft(bits, leftShift);
+ bits = *src++;
+ bits1 |= FbScrRight(bits, rightShift);
+ *dst = FbDoMergeRop(bits1, *dst);
+ dst++;
+ }
+ }
+ if (endmask)
+ {
+ bits1 = FbScrLeft(bits, leftShift);
+ if (FbScrLeft(endmask, rightShift))
+ {
+ bits = *src;
+ bits1 |= FbScrRight(bits, rightShift);
+ }
+ *dst = FbDoMaskMergeRop (bits1, *dst, endmask);
+ }
+ }
+ }
+}
+
+#ifdef FB_24BIT
+void
+fbBltOdd24 (FbBits *srcLine,
+ FbStride srcStrideEven,
+ FbStride srcStrideOdd,
+ int srcXEven,
+ int srcXOdd,
+
+ FbBits *dstLine,
+ FbStride dstStrideEven,
+ FbStride dstStrideOdd,
+ int dstXEven,
+ int dstXOdd,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm)
+{
+ Bool even = TRUE;
+
+ while (height--)
+ {
+ if (even)
+ {
+ fbBlt24Line (srcLine, srcXEven, dstLine, dstXEven,
+ width, alu, pm, FALSE);
+ srcLine += srcStrideEven;
+ dstLine += dstStrideEven;
+ even = FALSE;
+ }
+ else
+ {
+ fbBlt24Line (srcLine, srcXOdd, dstLine, dstXOdd,
+ width, alu, pm, FALSE);
+ srcLine += srcStrideOdd;
+ dstLine += dstStrideOdd;
+ even = TRUE;
+ }
+ }
+#if 0
+ fprintf (stderr, "\n");
+#endif
+}
+#endif
+
+#endif
+
+#if FB_STIP_SHIFT != FB_SHIFT
+void
+fbSetBltOdd (FbStip *stip,
+ FbStride stipStride,
+ int srcX,
+ FbBits **bits,
+ FbStride *strideEven,
+ FbStride *strideOdd,
+ int *srcXEven,
+ int *srcXOdd)
+{
+ int srcAdjust;
+ int strideAdjust;
+
+ /*
+ * bytes needed to align source
+ */
+ srcAdjust = (((int) stip) & (FB_MASK >> 3));
+ /*
+ * FbStip units needed to align stride
+ */
+ strideAdjust = stipStride & (FB_MASK >> FB_STIP_SHIFT);
+
+ *bits = (FbBits *) ((char *) stip - srcAdjust);
+ if (srcAdjust)
+ {
+ *strideEven = FbStipStrideToBitsStride (stipStride + 1);
+ *strideOdd = FbStipStrideToBitsStride (stipStride);
+
+ *srcXEven = srcX + (srcAdjust << 3);
+ *srcXOdd = srcX + (srcAdjust << 3) - (strideAdjust << FB_STIP_SHIFT);
+ }
+ else
+ {
+ *strideEven = FbStipStrideToBitsStride (stipStride);
+ *strideOdd = FbStipStrideToBitsStride (stipStride + 1);
+
+ *srcXEven = srcX;
+ *srcXOdd = srcX + (strideAdjust << FB_STIP_SHIFT);
+ }
+}
+#endif
+
+void
+fbBltStip (FbStip *src,
+ FbStride srcStride, /* in FbStip units, not FbBits units */
+ int srcX,
+
+ FbStip *dst,
+ FbStride dstStride, /* in FbStip units, not FbBits units */
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+ int bpp)
+{
+#if FB_STIP_SHIFT != FB_SHIFT
+ if (FB_STIP_ODDSTRIDE(srcStride) || FB_STIP_ODDPTR(src) ||
+ FB_STIP_ODDSTRIDE(dstStride) || FB_STIP_ODDPTR(dst))
+ {
+ FbStride srcStrideEven, srcStrideOdd;
+ FbStride dstStrideEven, dstStrideOdd;
+ int srcXEven, srcXOdd;
+ int dstXEven, dstXOdd;
+ FbBits *s, *d;
+ int sx, dx;
+
+ src += srcX >> FB_STIP_SHIFT;
+ srcX &= FB_STIP_MASK;
+ dst += dstX >> FB_STIP_SHIFT;
+ dstX &= FB_STIP_MASK;
+
+ fbSetBltOdd (src, srcStride, srcX,
+ &s,
+ &srcStrideEven, &srcStrideOdd,
+ &srcXEven, &srcXOdd);
+
+ fbSetBltOdd (dst, dstStride, dstX,
+ &d,
+ &dstStrideEven, &dstStrideOdd,
+ &dstXEven, &dstXOdd);
+
+#ifdef FB_24BIT
+ if (bpp == 24 && !FbCheck24Pix (pm))
+ {
+ fbBltOdd24 (s, srcStrideEven, srcStrideOdd,
+ srcXEven, srcXOdd,
+
+ d, dstStrideEven, dstStrideOdd,
+ dstXEven, dstXOdd,
+
+ width, height, alu, pm);
+ }
+ else
+#endif
+ {
+ fbBltOdd (s, srcStrideEven, srcStrideOdd,
+ srcXEven, srcXOdd,
+
+ d, dstStrideEven, dstStrideOdd,
+ dstXEven, dstXOdd,
+
+ width, height, alu, pm, bpp);
+ }
+ }
+ else
+#endif
+ {
+ fbBlt ((FbBits *) src, FbStipStrideToBitsStride (srcStride),
+ srcX,
+ (FbBits *) dst, FbStipStrideToBitsStride (dstStride),
+ dstX,
+ width, height,
+ alu, pm, bpp, FALSE, FALSE);
+ }
+}
diff --git a/nx-X11/programs/Xserver/fb/fbbltone.c b/nx-X11/programs/Xserver/fb/fbbltone.c
new file mode 100644
index 000000000..b271318d1
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbbltone.c
@@ -0,0 +1,880 @@
+/*
+ * Id: fbbltone.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbbltone.c,v 1.11 2001/09/07 15:15:31 keithp Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+/*
+ * Example: srcX = 13 dstX = 8 (FB unit 32 dstBpp 8)
+ *
+ * **** **** **** **** **** **** **** ****
+ * ^
+ * ******** ******** ******** ********
+ * ^
+ * leftShift = 12
+ * rightShift = 20
+ *
+ * Example: srcX = 0 dstX = 8 (FB unit 32 dstBpp 8)
+ *
+ * **** **** **** **** **** **** **** ****
+ * ^
+ * ******** ******** ******** ********
+ * ^
+ *
+ * leftShift = 24
+ * rightShift = 8
+ */
+
+#define LoadBits {\
+ if (leftShift) { \
+ bitsRight = (src < srcEnd ? *src++ : 0); \
+ bits = (FbStipLeft (bitsLeft, leftShift) | \
+ FbStipRight(bitsRight, rightShift)); \
+ bitsLeft = bitsRight; \
+ } else \
+ bits = (src < srcEnd ? *src++ : 0); \
+}
+
+#ifndef FBNOPIXADDR
+
+#define LaneCases1(n,a) case n: (void)FbLaneCase(n,a); break
+#define LaneCases2(n,a) LaneCases1(n,a); LaneCases1(n+1,a)
+#define LaneCases4(n,a) LaneCases2(n,a); LaneCases2(n+2,a)
+#define LaneCases8(n,a) LaneCases4(n,a); LaneCases4(n+4,a)
+#define LaneCases16(n,a) LaneCases8(n,a); LaneCases8(n+8,a)
+#define LaneCases32(n,a) LaneCases16(n,a); LaneCases16(n+16,a)
+#define LaneCases64(n,a) LaneCases32(n,a); LaneCases32(n+32,a)
+#define LaneCases128(n,a) LaneCases64(n,a); LaneCases64(n+64,a)
+#define LaneCases256(n,a) LaneCases128(n,a); LaneCases128(n+128,a)
+
+#if FB_SHIFT == 6
+#define LaneCases(a) LaneCases256(0,a)
+#endif
+
+#if FB_SHIFT == 5
+#define LaneCases(a) LaneCases16(0,a)
+#endif
+
+#if FB_SHIFT == 6
+CARD8 fb8Lane[256] = {
+0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
+22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
+60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
+79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
+98, 99, 100, 101, 102,103,104,105,106,107,108,109,110,111,112,113,114,115,
+116, 117, 118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,
+134, 135, 136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,
+152, 153, 154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,
+170, 171, 172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,
+188, 189, 190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,
+206, 207, 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
+224, 225, 226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,
+242, 243, 244,245,246,247,248,249,250,251,252,253,254,255,
+};
+
+CARD8 fb16Lane[256] = {
+ 0x00, 0x03, 0x0c, 0x0f,
+ 0x30, 0x33, 0x3c, 0x3f,
+ 0xc0, 0xc3, 0xcc, 0xcf,
+ 0xf0, 0xf3, 0xfc, 0xff,
+};
+
+CARD8 fb32Lane[16] = {
+ 0x00, 0x0f, 0xf0, 0xff,
+};
+#endif
+
+#if FB_SHIFT == 5
+CARD8 fb8Lane[16] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
+};
+
+CARD8 fb16Lane[16] = {
+ 0, 3, 12, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+
+CARD8 fb32Lane[16] = {
+ 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+#endif
+
+CARD8 *fbLaneTable[33] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ fb8Lane, 0, 0, 0, 0, 0, 0, 0,
+ fb16Lane, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ fb32Lane
+};
+#endif
+
+void
+fbBltOne (FbStip *src,
+ FbStride srcStride, /* FbStip units per scanline */
+ int srcX, /* bit position of source */
+ FbBits *dst,
+ FbStride dstStride, /* FbBits units per scanline */
+ int dstX, /* bit position of dest */
+ int dstBpp, /* bits per destination unit */
+
+ int width, /* width in bits of destination */
+ int height, /* height in scanlines */
+
+ FbBits fgand, /* rrop values */
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor)
+{
+ const FbBits *fbBits;
+ FbBits *srcEnd;
+ int pixelsPerDst; /* dst pixels per FbBits */
+ int unitsPerSrc; /* src patterns per FbStip */
+ int leftShift, rightShift; /* align source with dest */
+ FbBits startmask, endmask; /* dest scanline masks */
+ FbStip bits=0, bitsLeft, bitsRight;/* source bits */
+ FbStip left;
+ FbBits mask;
+ int nDst; /* dest longwords (w.o. end) */
+ int w;
+ int n, nmiddle;
+ int dstS; /* stipple-relative dst X coordinate */
+ Bool copy; /* accelerate dest-invariant */
+ Bool transparent; /* accelerate 0 nop */
+ int srcinc; /* source units consumed */
+ Bool endNeedsLoad = FALSE; /* need load for endmask */
+#ifndef FBNOPIXADDR
+ CARD8 *fbLane;
+#endif
+ int startbyte, endbyte;
+
+#ifdef FB_24BIT
+ if (dstBpp == 24)
+ {
+ fbBltOne24 (src, srcStride, srcX,
+ dst, dstStride, dstX, dstBpp,
+ width, height,
+ fgand, fgxor, bgand, bgxor);
+ return;
+ }
+#endif
+
+ /*
+ * Do not read past the end of the buffer!
+ */
+ srcEnd = src + height * srcStride;
+
+ /*
+ * Number of destination units in FbBits == number of stipple pixels
+ * used each time
+ */
+ pixelsPerDst = FB_UNIT / dstBpp;
+
+ /*
+ * Number of source stipple patterns in FbStip
+ */
+ unitsPerSrc = FB_STIP_UNIT / pixelsPerDst;
+
+ copy = FALSE;
+ transparent = FALSE;
+ if (bgand == 0 && fgand == 0)
+ copy = TRUE;
+ else if (bgand == FB_ALLONES && bgxor == 0)
+ transparent = TRUE;
+
+ /*
+ * Adjust source and dest to nearest FbBits boundary
+ */
+ src += srcX >> FB_STIP_SHIFT;
+ dst += dstX >> FB_SHIFT;
+ srcX &= FB_STIP_MASK;
+ dstX &= FB_MASK;
+
+ FbMaskBitsBytes(dstX, width, copy,
+ startmask, startbyte, nmiddle, endmask, endbyte);
+
+ /*
+ * Compute effective dest alignment requirement for
+ * source -- must align source to dest unit boundary
+ */
+ dstS = dstX / dstBpp;
+ /*
+ * Compute shift constants for effective alignement
+ */
+ if (srcX >= dstS)
+ {
+ leftShift = srcX - dstS;
+ rightShift = FB_STIP_UNIT - leftShift;
+ }
+ else
+ {
+ rightShift = dstS - srcX;
+ leftShift = FB_STIP_UNIT - rightShift;
+ }
+ /*
+ * Get pointer to stipple mask array for this depth
+ */
+ fbBits = 0; /* unused */
+ if (pixelsPerDst <= 8)
+ fbBits = fbStippleTable[pixelsPerDst];
+#ifndef FBNOPIXADDR
+ fbLane = 0;
+ if (transparent && fgand == 0 && dstBpp >= 8)
+ fbLane = fbLaneTable[dstBpp];
+#endif
+
+ /*
+ * Compute total number of destination words written, but
+ * don't count endmask
+ */
+ nDst = nmiddle;
+ if (startmask)
+ nDst++;
+
+ dstStride -= nDst;
+
+ /*
+ * Compute total number of source words consumed
+ */
+
+ srcinc = (nDst + unitsPerSrc - 1) / unitsPerSrc;
+
+ if (srcX > dstS)
+ srcinc++;
+ if (endmask)
+ {
+ endNeedsLoad = nDst % unitsPerSrc == 0;
+ if (endNeedsLoad)
+ srcinc++;
+ }
+
+ srcStride -= srcinc;
+
+ /*
+ * Copy rectangle
+ */
+ while (height--)
+ {
+ w = nDst; /* total units across scanline */
+ n = unitsPerSrc; /* units avail in single stipple */
+ if (n > w)
+ n = w;
+
+ bitsLeft = 0;
+ if (srcX > dstS)
+ bitsLeft = *src++;
+ if (n)
+ {
+ /*
+ * Load first set of stipple bits
+ */
+ LoadBits;
+
+ /*
+ * Consume stipple bits for startmask
+ */
+ if (startmask)
+ {
+#if FB_UNIT > 32
+ if (pixelsPerDst == 16)
+ mask = FbStipple16Bits(FbLeftStipBits(bits,16));
+ else
+#endif
+ mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
+#ifndef FBNOPIXADDR
+ if (fbLane)
+ {
+ fbTransparentSpan (dst, mask & startmask, fgxor, 1);
+ }
+ else
+#endif
+ {
+ if (mask || !transparent)
+ FbDoLeftMaskByteStippleRRop (dst, mask,
+ fgand, fgxor, bgand, bgxor,
+ startbyte, startmask);
+ }
+ bits = FbStipLeft (bits, pixelsPerDst);
+ dst++;
+ n--;
+ w--;
+ }
+ /*
+ * Consume stipple bits across scanline
+ */
+ for (;;)
+ {
+ w -= n;
+ if (copy)
+ {
+ while (n--)
+ {
+#if FB_UNIT > 32
+ if (pixelsPerDst == 16)
+ mask = FbStipple16Bits(FbLeftStipBits(bits,16));
+ else
+#endif
+ mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
+ *dst = FbOpaqueStipple (mask, fgxor, bgxor);
+ dst++;
+ bits = FbStipLeft(bits, pixelsPerDst);
+ }
+ }
+ else
+ {
+#ifndef FBNOPIXADDR
+ if (fbLane)
+ {
+ while (bits && n)
+ {
+ switch (fbLane[FbLeftStipBits(bits,pixelsPerDst)]) {
+ LaneCases((CARD8 *) dst);
+ }
+ bits = FbStipLeft(bits,pixelsPerDst);
+ dst++;
+ n--;
+ }
+ dst += n;
+ }
+ else
+#endif
+ {
+ while (n--)
+ {
+ left = FbLeftStipBits(bits,pixelsPerDst);
+ if (left || !transparent)
+ {
+ mask = fbBits[left];
+ *dst = FbStippleRRop (*dst, mask,
+ fgand, fgxor, bgand, bgxor);
+ }
+ dst++;
+ bits = FbStipLeft(bits, pixelsPerDst);
+ }
+ }
+ }
+ if (!w)
+ break;
+ /*
+ * Load another set and reset number of available units
+ */
+ LoadBits;
+ n = unitsPerSrc;
+ if (n > w)
+ n = w;
+ }
+ }
+ /*
+ * Consume stipple bits for endmask
+ */
+ if (endmask)
+ {
+ if (endNeedsLoad)
+ {
+ LoadBits;
+ }
+#if FB_UNIT > 32
+ if (pixelsPerDst == 16)
+ mask = FbStipple16Bits(FbLeftStipBits(bits,16));
+ else
+#endif
+ mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
+#ifndef FBNOPIXADDR
+ if (fbLane)
+ {
+ fbTransparentSpan (dst, mask & endmask, fgxor, 1);
+ }
+ else
+#endif
+ {
+ if (mask || !transparent)
+ FbDoRightMaskByteStippleRRop (dst, mask,
+ fgand, fgxor, bgand, bgxor,
+ endbyte, endmask);
+ }
+ }
+ dst += dstStride;
+ src += srcStride;
+ }
+}
+
+#ifdef FB_24BIT
+
+/*
+ * Crufty macros to initialize the mask array, most of this
+ * is to avoid compile-time warnings about shift overflow
+ */
+
+#if BITMAP_BIT_ORDER == MSBFirst
+#define Mask24Pos(x,r) ((x)*24-(r))
+#else
+#define Mask24Pos(x,r) ((x)*24-((r) ? 24 - (r) : 0))
+#endif
+
+#define Mask24Neg(x,r) (Mask24Pos(x,r) < 0 ? -Mask24Pos(x,r) : 0)
+#define Mask24Check(x,r) (Mask24Pos(x,r) < 0 ? 0 : \
+ Mask24Pos(x,r) >= FB_UNIT ? 0 : Mask24Pos(x,r))
+
+#define Mask24(x,r) (Mask24Pos(x,r) < FB_UNIT ? \
+ (Mask24Pos(x,r) < 0 ? \
+ 0xffffff >> Mask24Neg (x,r) : \
+ 0xffffff << Mask24Check(x,r)) : 0)
+
+#define SelMask24(b,n,r) ((((b) >> n) & 1) * Mask24(n,r))
+
+/*
+ * Untested for MSBFirst or FB_UNIT == 32
+ */
+
+#if FB_UNIT == 64
+#define C4_24(b,r) \
+ (SelMask24(b,0,r) | \
+ SelMask24(b,1,r) | \
+ SelMask24(b,2,r) | \
+ SelMask24(b,3,r))
+
+#define FbStip24New(rot) (2 + (rot != 0))
+#define FbStip24Len 4
+
+const FbBits fbStipple24Bits[3][1 << FbStip24Len] = {
+ /* rotate 0 */
+ {
+ C4_24( 0, 0), C4_24( 1, 0), C4_24( 2, 0), C4_24( 3, 0),
+ C4_24( 4, 0), C4_24( 5, 0), C4_24( 6, 0), C4_24( 7, 0),
+ C4_24( 8, 0), C4_24( 9, 0), C4_24(10, 0), C4_24(11, 0),
+ C4_24(12, 0), C4_24(13, 0), C4_24(14, 0), C4_24(15, 0),
+ },
+ /* rotate 8 */
+ {
+ C4_24( 0, 8), C4_24( 1, 8), C4_24( 2, 8), C4_24( 3, 8),
+ C4_24( 4, 8), C4_24( 5, 8), C4_24( 6, 8), C4_24( 7, 8),
+ C4_24( 8, 8), C4_24( 9, 8), C4_24(10, 8), C4_24(11, 8),
+ C4_24(12, 8), C4_24(13, 8), C4_24(14, 8), C4_24(15, 8),
+ },
+ /* rotate 16 */
+ {
+ C4_24( 0,16), C4_24( 1,16), C4_24( 2,16), C4_24( 3,16),
+ C4_24( 4,16), C4_24( 5,16), C4_24( 6,16), C4_24( 7,16),
+ C4_24( 8,16), C4_24( 9,16), C4_24(10,16), C4_24(11,16),
+ C4_24(12,16), C4_24(13,16), C4_24(14,16), C4_24(15,16),
+ }
+};
+
+#endif
+
+#if FB_UNIT == 32
+#define C2_24(b,r) \
+ (SelMask24(b,0,r) | \
+ SelMask24(b,1,r))
+
+#define FbStip24Len 2
+#if BITMAP_BIT_ORDER == MSBFirst
+#define FbStip24New(rot) (1 + (rot == 0))
+#else
+#define FbStip24New(rot) (1 + (rot == 8))
+#endif
+
+const FbBits fbStipple24Bits[3][1 << FbStip24Len] = {
+ /* rotate 0 */
+ {
+ C2_24( 0, 0), C2_24 ( 1, 0), C2_24 ( 2, 0), C2_24 ( 3, 0),
+ },
+ /* rotate 8 */
+ {
+ C2_24( 0, 8), C2_24 ( 1, 8), C2_24 ( 2, 8), C2_24 ( 3, 8),
+ },
+ /* rotate 16 */
+ {
+ C2_24( 0,16), C2_24 ( 1,16), C2_24 ( 2,16), C2_24 ( 3,16),
+ }
+};
+#endif
+
+#if BITMAP_BIT_ORDER == LSBFirst
+
+#define FbMergeStip24Bits(left, right, new) \
+ (FbStipLeft (left, new) | FbStipRight ((right), (FbStip24Len - (new))))
+
+#define FbMergePartStip24Bits(left, right, llen, rlen) \
+ (left | FbStipRight(right, llen))
+
+#else
+
+#define FbMergeStip24Bits(left, right, new) \
+ ((FbStipLeft (left, new) & ((1 << FbStip24Len) - 1)) | right)
+
+#define FbMergePartStip24Bits(left, right, llen, rlen) \
+ (FbStipLeft(left, rlen) | right)
+
+#endif
+
+#define fbFirstStipBits(len,stip) {\
+ int __len = (len); \
+ if (len <= remain) { \
+ stip = FbLeftStipBits(bits, len); \
+ } else { \
+ stip = FbLeftStipBits(bits, remain); \
+ bits = (src < srcEnd ? *src++ : 0); \
+ __len = (len) - remain; \
+ stip = FbMergePartStip24Bits(stip, FbLeftStipBits(bits, __len), \
+ remain, __len); \
+ remain = FB_STIP_UNIT; \
+ } \
+ bits = FbStipLeft (bits, __len); \
+ remain -= __len; \
+}
+
+#define fbInitStipBits(offset,len,stip) {\
+ bits = FbStipLeft (*src++,offset); \
+ remain = FB_STIP_UNIT - offset; \
+ fbFirstStipBits(len,stip); \
+ stip = FbMergeStip24Bits (0, stip, len); \
+}
+
+#define fbNextStipBits(rot,stip) {\
+ int __new = FbStip24New(rot); \
+ FbStip __right; \
+ fbFirstStipBits(__new, __right); \
+ stip = FbMergeStip24Bits (stip, __right, __new); \
+ rot = FbNext24Rot (rot); \
+}
+
+/*
+ * Use deep mask tables that incorporate rotation, pull
+ * a variable number of bits out of the stipple and
+ * reuse the right bits as needed for the next write
+ *
+ * Yes, this is probably too much code, but most 24-bpp screens
+ * have no acceleration so this code is used for stipples, copyplane
+ * and text
+ */
+void
+fbBltOne24 (FbStip *srcLine,
+ FbStride srcStride, /* FbStip units per scanline */
+ int srcX, /* bit position of source */
+ FbBits *dst,
+ FbStride dstStride, /* FbBits units per scanline */
+ int dstX, /* bit position of dest */
+ int dstBpp, /* bits per destination unit */
+
+ int width, /* width in bits of destination */
+ int height, /* height in scanlines */
+
+ FbBits fgand, /* rrop values */
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor)
+{
+ FbStip *src, *srcEnd;
+ FbBits leftMask, rightMask, mask;
+ int nlMiddle, nl;
+ FbStip stip, bits;
+ int remain;
+ int dstS;
+ int firstlen;
+ int rot0, rot;
+ int nDst;
+
+ /*
+ * Do not read past the end of the buffer!
+ */
+ srcEnd = srcLine + height * srcStride;
+
+ srcLine += srcX >> FB_STIP_SHIFT;
+ dst += dstX >> FB_SHIFT;
+ srcX &= FB_STIP_MASK;
+ dstX &= FB_MASK;
+ rot0 = FbFirst24Rot (dstX);
+
+ FbMaskBits (dstX, width, leftMask, nlMiddle, rightMask);
+
+ dstS = (dstX + 23) / 24;
+ firstlen = FbStip24Len - dstS;
+
+ nDst = nlMiddle;
+ if (leftMask)
+ nDst++;
+ dstStride -= nDst;
+
+ /* opaque copy */
+ if (bgand == 0 && fgand == 0)
+ {
+ while (height--)
+ {
+ rot = rot0;
+ src = srcLine;
+ srcLine += srcStride;
+ fbInitStipBits (srcX,firstlen, stip);
+ if (leftMask)
+ {
+ mask = fbStipple24Bits[rot >> 3][stip];
+ *dst = (*dst & ~leftMask) | (FbOpaqueStipple (mask,
+ FbRot24(fgxor, rot),
+ FbRot24(bgxor, rot))
+ & leftMask);
+ dst++;
+ fbNextStipBits(rot,stip);
+ }
+ nl = nlMiddle;
+ while (nl--)
+ {
+ mask = fbStipple24Bits[rot>>3][stip];
+ *dst = FbOpaqueStipple (mask,
+ FbRot24(fgxor, rot),
+ FbRot24(bgxor, rot));
+ dst++;
+ fbNextStipBits(rot,stip);
+ }
+ if (rightMask)
+ {
+ mask = fbStipple24Bits[rot >> 3][stip];
+ *dst = (*dst & ~rightMask) | (FbOpaqueStipple (mask,
+ FbRot24(fgxor, rot),
+ FbRot24(bgxor, rot))
+ & rightMask);
+ }
+ dst += dstStride;
+ src += srcStride;
+ }
+ }
+ /* transparent copy */
+ else if (bgand == FB_ALLONES && bgxor == 0 && fgand == 0)
+ {
+ while (height--)
+ {
+ rot = rot0;
+ src = srcLine;
+ srcLine += srcStride;
+ fbInitStipBits (srcX, firstlen, stip);
+ if (leftMask)
+ {
+ if (stip)
+ {
+ mask = fbStipple24Bits[rot >> 3][stip] & leftMask;
+ *dst = (*dst & ~mask) | (FbRot24(fgxor, rot) & mask);
+ }
+ dst++;
+ fbNextStipBits (rot, stip);
+ }
+ nl = nlMiddle;
+ while (nl--)
+ {
+ if (stip)
+ {
+ mask = fbStipple24Bits[rot>>3][stip];
+ *dst = (*dst & ~mask) | (FbRot24(fgxor,rot) & mask);
+ }
+ dst++;
+ fbNextStipBits (rot, stip);
+ }
+ if (rightMask)
+ {
+ if (stip)
+ {
+ mask = fbStipple24Bits[rot >> 3][stip] & rightMask;
+ *dst = (*dst & ~mask) | (FbRot24(fgxor, rot) & mask);
+ }
+ }
+ dst += dstStride;
+ }
+ }
+ else
+ {
+ while (height--)
+ {
+ rot = rot0;
+ src = srcLine;
+ srcLine += srcStride;
+ fbInitStipBits (srcX, firstlen, stip);
+ if (leftMask)
+ {
+ mask = fbStipple24Bits[rot >> 3][stip];
+ *dst = FbStippleRRopMask (*dst, mask,
+ FbRot24(fgand, rot),
+ FbRot24(fgxor, rot),
+ FbRot24(bgand, rot),
+ FbRot24(bgxor, rot),
+ leftMask);
+ dst++;
+ fbNextStipBits(rot,stip);
+ }
+ nl = nlMiddle;
+ while (nl--)
+ {
+ mask = fbStipple24Bits[rot >> 3][stip];
+ *dst = FbStippleRRop (*dst, mask,
+ FbRot24(fgand, rot),
+ FbRot24(fgxor, rot),
+ FbRot24(bgand, rot),
+ FbRot24(bgxor, rot));
+ dst++;
+ fbNextStipBits(rot,stip);
+ }
+ if (rightMask)
+ {
+ mask = fbStipple24Bits[rot >> 3][stip];
+ *dst = FbStippleRRopMask (*dst, mask,
+ FbRot24(fgand, rot),
+ FbRot24(fgxor, rot),
+ FbRot24(bgand, rot),
+ FbRot24(bgxor, rot),
+ rightMask);
+ }
+ dst += dstStride;
+ }
+ }
+}
+#endif
+
+/*
+ * Not very efficient, but simple -- copy a single plane
+ * from an N bit image to a 1 bit image
+ */
+
+void
+fbBltPlane (FbBits *src,
+ FbStride srcStride,
+ int srcX,
+ int srcBpp,
+
+ FbStip *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbStip fgand,
+ FbStip fgxor,
+ FbStip bgand,
+ FbStip bgxor,
+ Pixel planeMask)
+{
+ FbBits *s;
+ FbBits pm;
+ FbBits srcMask;
+ FbBits srcMaskFirst;
+ FbBits srcMask0 = 0;
+ FbBits srcBits;
+
+ FbStip dstBits;
+ FbStip *d;
+ FbStip dstMask;
+ FbStip dstMaskFirst;
+ FbStip dstUnion;
+ int w;
+ int wt;
+ int rot0;
+
+ if (!width)
+ return;
+
+ src += srcX >> FB_SHIFT;
+ srcX &= FB_MASK;
+
+ dst += dstX >> FB_STIP_SHIFT;
+ dstX &= FB_STIP_MASK;
+
+ w = width / srcBpp;
+
+ pm = fbReplicatePixel (planeMask, srcBpp);
+#ifdef FB_24BIT
+ if (srcBpp == 24)
+ {
+ int w = 24;
+
+ rot0 = FbFirst24Rot (srcX);
+ if (srcX + w > FB_UNIT)
+ w = FB_UNIT - srcX;
+ srcMaskFirst = FbRot24(pm,rot0) & FbBitsMask(srcX,w);
+ }
+ else
+#endif
+ {
+ rot0 = 0;
+ srcMaskFirst = pm & FbBitsMask(srcX, srcBpp);
+ srcMask0 = pm & FbBitsMask(0, srcBpp);
+ }
+
+ dstMaskFirst = FbStipMask(dstX,1);
+ while (height--)
+ {
+ d = dst;
+ dst += dstStride;
+ s = src;
+ src += srcStride;
+
+ srcMask = srcMaskFirst;
+#ifdef FB_24BIT
+ if (srcBpp == 24)
+ srcMask0 = FbRot24(pm,rot0) & FbBitsMask(0, srcBpp);
+#endif
+ srcBits = *s++;
+
+ dstMask = dstMaskFirst;
+ dstUnion = 0;
+ dstBits = 0;
+
+ wt = w;
+
+ while (wt--)
+ {
+ if (!srcMask)
+ {
+ srcBits = *s++;
+#ifdef FB_24BIT
+ if (srcBpp == 24)
+ srcMask0 = FbNext24Pix(srcMask0) & FbBitsMask(0,24);
+#endif
+ srcMask = srcMask0;
+ }
+ if (!dstMask)
+ {
+ *d = FbStippleRRopMask(*d, dstBits,
+ fgand, fgxor, bgand, bgxor,
+ dstUnion);
+ d++;
+ dstMask = FbStipMask(0,1);
+ dstUnion = 0;
+ dstBits = 0;
+ }
+ if (srcBits & srcMask)
+ dstBits |= dstMask;
+ dstUnion |= dstMask;
+ if (srcBpp == FB_UNIT)
+ srcMask = 0;
+ else
+ srcMask = FbScrRight(srcMask,srcBpp);
+ dstMask = FbStipRight(dstMask,1);
+ }
+ if (dstUnion)
+ *d = FbStippleRRopMask(*d,dstBits,
+ fgand, fgxor, bgand, bgxor,
+ dstUnion);
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/fb/fbbstore.c b/nx-X11/programs/Xserver/fb/fbbstore.c
new file mode 100644
index 000000000..01ec9b7e0
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbbstore.c
@@ -0,0 +1,66 @@
+/*
+ * Id: fbbstore.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbbstore.c,v 1.1 1999/11/19 13:53:42 hohndel Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbSaveAreas(PixmapPtr pPixmap,
+ RegionPtr prgnSave,
+ int xorg,
+ int yorg,
+ WindowPtr pWin)
+{
+ fbCopyWindowProc (&pWin->drawable,
+ &pPixmap->drawable,
+ 0,
+ REGION_RECTS(prgnSave),
+ REGION_NUM_RECTS(prgnSave),
+ xorg, yorg,
+ FALSE,
+ FALSE,
+ 0,0);
+}
+
+void
+fbRestoreAreas(PixmapPtr pPixmap,
+ RegionPtr prgnRestore,
+ int xorg,
+ int yorg,
+ WindowPtr pWin)
+{
+ fbCopyWindowProc (&pPixmap->drawable,
+ &pWin->drawable,
+ 0,
+ REGION_RECTS(prgnRestore),
+ REGION_NUM_RECTS(prgnRestore),
+ -xorg, -yorg,
+ FALSE,
+ FALSE,
+ 0,0);
+}
diff --git a/nx-X11/programs/Xserver/fb/fbcmap.c b/nx-X11/programs/Xserver/fb/fbcmap.c
new file mode 100644
index 000000000..762c51c9d
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbcmap.c
@@ -0,0 +1,672 @@
+/* $XConsortium: fbcmap.c,v 4.19 94/04/17 20:28:46 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbcmap.c,v 1.5 2000/09/20 00:09:13 keithp Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "colormapst.h"
+#include "resource.h"
+#include "fb.h"
+
+#ifndef XFree86Server
+ColormapPtr FbInstalledMaps[MAXSCREENS];
+
+int
+fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
+{
+ /* By the time we are processing requests, we can guarantee that there
+ * is always a colormap installed */
+ *pmaps = FbInstalledMaps[pScreen->myNum]->mid;
+ return (1);
+}
+
+
+void
+fbInstallColormap(ColormapPtr pmap)
+{
+ int index = pmap->pScreen->myNum;
+ ColormapPtr oldpmap = FbInstalledMaps[index];
+
+ if(pmap != oldpmap)
+ {
+ /* Uninstall pInstalledMap. No hardware changes required, just
+ * notify all interested parties. */
+ if(oldpmap != (ColormapPtr)None)
+ WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid);
+ /* Install pmap */
+ FbInstalledMaps[index] = pmap;
+ WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid);
+ }
+}
+
+void
+fbUninstallColormap(ColormapPtr pmap)
+{
+ int index = pmap->pScreen->myNum;
+ ColormapPtr curpmap = FbInstalledMaps[index];
+
+ if(pmap == curpmap)
+ {
+ if (pmap->mid != pmap->pScreen->defColormap)
+ {
+ curpmap = (ColormapPtr) LookupIDByType(pmap->pScreen->defColormap,
+ RT_COLORMAP);
+ (*pmap->pScreen->InstallColormap)(curpmap);
+ }
+ }
+}
+
+void
+fbResolveColor(unsigned short *pred,
+ unsigned short *pgreen,
+ unsigned short *pblue,
+ VisualPtr pVisual)
+{
+ int shift = 16 - pVisual->bitsPerRGBValue;
+ unsigned lim = (1 << pVisual->bitsPerRGBValue) - 1;
+
+ if ((pVisual->class | DynamicClass) == GrayScale)
+ {
+ /* rescale to gray then rgb bits */
+ *pred = (30L * *pred + 59L * *pgreen + 11L * *pblue) / 100;
+ *pblue = *pgreen = *pred = ((*pred >> shift) * 65535) / lim;
+ }
+ else
+ {
+ /* rescale to rgb bits */
+ *pred = ((*pred >> shift) * 65535) / lim;
+ *pgreen = ((*pgreen >> shift) * 65535) / lim;
+ *pblue = ((*pblue >> shift) * 65535) / lim;
+ }
+}
+
+Bool
+fbInitializeColormap(ColormapPtr pmap)
+{
+ register unsigned i;
+ register VisualPtr pVisual;
+ unsigned lim, maxent, shift;
+
+ pVisual = pmap->pVisual;
+ lim = (1 << pVisual->bitsPerRGBValue) - 1;
+ shift = 16 - pVisual->bitsPerRGBValue;
+ maxent = pVisual->ColormapEntries - 1;
+ if (pVisual->class == TrueColor)
+ {
+ unsigned limr, limg, limb;
+
+ limr = pVisual->redMask >> pVisual->offsetRed;
+ limg = pVisual->greenMask >> pVisual->offsetGreen;
+ limb = pVisual->blueMask >> pVisual->offsetBlue;
+ for(i = 0; i <= maxent; i++)
+ {
+ /* rescale to [0..65535] then rgb bits */
+ pmap->red[i].co.local.red =
+ ((((i * 65535) / limr) >> shift) * 65535) / lim;
+ pmap->green[i].co.local.green =
+ ((((i * 65535) / limg) >> shift) * 65535) / lim;
+ pmap->blue[i].co.local.blue =
+ ((((i * 65535) / limb) >> shift) * 65535) / lim;
+ }
+ }
+ else if (pVisual->class == StaticColor)
+ {
+ unsigned n;
+ unsigned r, g, b;
+ unsigned red, green, blue;
+
+ for (n = 0; n*n*n < pVisual->ColormapEntries; n++)
+ ;
+ n--;
+ i = 0;
+ for (r = 0; r < n; r++)
+ {
+ red = (((r * 65535 / (n - 1)) >> shift) * 65535) / lim;
+ for (g = 0; g < n; g++)
+ {
+ green = (((g * 65535 / (n - 1)) >> shift) * 65535) / lim;
+ for (b = 0; b < n; b++)
+ {
+ blue = (((b * 65535 / (n - 1)) >> shift) * 65535) / lim;
+ pmap->red[i].co.local.red = red;
+ pmap->red[i].co.local.green = green;
+ pmap->red[i].co.local.blue = blue;
+ i++;
+ }
+ }
+ }
+ n = pVisual->ColormapEntries - i;
+ for (r = 0; r < n; r++)
+ {
+ red = (((r * 65535 / (n - 1)) >> shift) * 65535) / lim;
+ pmap->red[i].co.local.red = red;
+ pmap->red[i].co.local.green = red;
+ pmap->red[i].co.local.blue = red;
+ i++;
+ }
+ }
+ else if (pVisual->class == StaticGray)
+ {
+ for(i = 0; i <= maxent; i++)
+ {
+ /* rescale to [0..65535] then rgb bits */
+ pmap->red[i].co.local.red = ((((i * 65535) / maxent) >> shift)
+ * 65535) / lim;
+ pmap->red[i].co.local.green = pmap->red[i].co.local.red;
+ pmap->red[i].co.local.blue = pmap->red[i].co.local.red;
+ }
+ }
+ return TRUE;
+}
+
+/* When simulating DirectColor on PseudoColor hardware, multiple
+ entries of the colormap must be updated
+ */
+
+#define AddElement(mask) { \
+ pixel = red | green | blue; \
+ for (i = 0; i < nresult; i++) \
+ if (outdefs[i].pixel == pixel) \
+ break; \
+ if (i == nresult) \
+ { \
+ nresult++; \
+ outdefs[i].pixel = pixel; \
+ outdefs[i].flags = 0; \
+ } \
+ outdefs[i].flags |= (mask); \
+ outdefs[i].red = pmap->red[red >> pVisual->offsetRed].co.local.red; \
+ outdefs[i].green = pmap->green[green >> pVisual->offsetGreen].co.local.green; \
+ outdefs[i].blue = pmap->blue[blue >> pVisual->offsetBlue].co.local.blue; \
+}
+
+int
+fbExpandDirectColors (ColormapPtr pmap,
+ int ndef,
+ xColorItem *indefs,
+ xColorItem *outdefs)
+{
+ register int red, green, blue;
+ int maxred, maxgreen, maxblue;
+ int stepred, stepgreen, stepblue;
+ VisualPtr pVisual;
+ register int pixel;
+ register int nresult;
+ register int i;
+
+ pVisual = pmap->pVisual;
+
+ stepred = 1 << pVisual->offsetRed;
+ stepgreen = 1 << pVisual->offsetGreen;
+ stepblue = 1 << pVisual->offsetBlue;
+ maxred = pVisual->redMask;
+ maxgreen = pVisual->greenMask;
+ maxblue = pVisual->blueMask;
+ nresult = 0;
+ for (;ndef--; indefs++)
+ {
+ if (indefs->flags & DoRed)
+ {
+ red = indefs->pixel & pVisual->redMask;
+ for (green = 0; green <= maxgreen; green += stepgreen)
+ {
+ for (blue = 0; blue <= maxblue; blue += stepblue)
+ {
+ AddElement (DoRed)
+ }
+ }
+ }
+ if (indefs->flags & DoGreen)
+ {
+ green = indefs->pixel & pVisual->greenMask;
+ for (red = 0; red <= maxred; red += stepred)
+ {
+ for (blue = 0; blue <= maxblue; blue += stepblue)
+ {
+ AddElement (DoGreen)
+ }
+ }
+ }
+ if (indefs->flags & DoBlue)
+ {
+ blue = indefs->pixel & pVisual->blueMask;
+ for (red = 0; red <= maxred; red += stepred)
+ {
+ for (green = 0; green <= maxgreen; green += stepgreen)
+ {
+ AddElement (DoBlue)
+ }
+ }
+ }
+ }
+ return nresult;
+}
+
+Bool
+fbCreateDefColormap(ScreenPtr pScreen)
+{
+ unsigned short zero = 0, ones = 0xFFFF;
+ VisualPtr pVisual;
+ ColormapPtr cmap;
+ Pixel wp, bp;
+
+ for (pVisual = pScreen->visuals;
+ pVisual->vid != pScreen->rootVisual;
+ pVisual++)
+ ;
+
+ if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &cmap,
+ (pVisual->class & DynamicClass) ? AllocNone : AllocAll,
+ 0)
+ != Success)
+ return FALSE;
+ wp = pScreen->whitePixel;
+ bp = pScreen->blackPixel;
+ if ((AllocColor(cmap, &ones, &ones, &ones, &wp, 0) !=
+ Success) ||
+ (AllocColor(cmap, &zero, &zero, &zero, &bp, 0) !=
+ Success))
+ return FALSE;
+ pScreen->whitePixel = wp;
+ pScreen->blackPixel = bp;
+ (*pScreen->InstallColormap)(cmap);
+ return TRUE;
+}
+
+extern int defaultColorVisualClass;
+
+#define _RZ(d) ((d + 2) / 3)
+#define _RS(d) 0
+#define _RM(d) ((1 << _RZ(d)) - 1)
+#define _GZ(d) ((d - _RZ(d) + 1) / 2)
+#define _GS(d) _RZ(d)
+#define _GM(d) (((1 << _GZ(d)) - 1) << _GS(d))
+#define _BZ(d) (d - _RZ(d) - _GZ(d))
+#define _BS(d) (_RZ(d) + _GZ(d))
+#define _BM(d) (((1 << _BZ(d)) - 1) << _BS(d))
+#define _CE(d) (1 << _RZ(d))
+
+#define MAX_PSEUDO_DEPTH 10 /* largest DAC size I know */
+
+#define StaticGrayMask (1 << StaticGray)
+#define GrayScaleMask (1 << GrayScale)
+#define StaticColorMask (1 << StaticColor)
+#define PseudoColorMask (1 << PseudoColor)
+#define TrueColorMask (1 << TrueColor)
+#define DirectColorMask (1 << DirectColor)
+
+#define ALL_VISUALS (StaticGrayMask|\
+ GrayScaleMask|\
+ StaticColorMask|\
+ PseudoColorMask|\
+ TrueColorMask|\
+ DirectColorMask)
+
+#define LARGE_VISUALS (TrueColorMask|\
+ DirectColorMask)
+
+typedef struct _fbVisuals {
+ struct _fbVisuals *next;
+ int depth;
+ int bitsPerRGB;
+ int visuals;
+ int count;
+ Pixel redMask, greenMask, blueMask;
+} fbVisualsRec, *fbVisualsPtr;
+
+static const int fbVisualPriority[] = {
+ PseudoColor, DirectColor, GrayScale, StaticColor, TrueColor, StaticGray
+};
+
+#define NUM_PRIORITY 6
+
+static fbVisualsPtr fbVisuals;
+
+static int
+popCount (int i)
+{
+ int count;
+
+ count = (i >> 1) & 033333333333;
+ count = i - count - ((count >> 1) & 033333333333);
+ count = (((count + (count >> 3)) & 030707070707) % 077); /* HAKMEM 169 */
+ return count;
+}
+
+/*
+ * Distance to least significant one bit
+ */
+static int
+maskShift (Pixel p)
+{
+ int s;
+
+ if (!p) return 0;
+ s = 0;
+ while (!(p & 1))
+ {
+ s++;
+ p >>= 1;
+ }
+ return s;
+}
+
+Bool
+fbSetVisualTypesAndMasks (int depth, int visuals, int bitsPerRGB,
+ Pixel redMask, Pixel greenMask, Pixel blueMask)
+{
+ fbVisualsPtr new, *prev, v;
+
+ new = (fbVisualsPtr) xalloc (sizeof *new);
+ if (!new)
+ return FALSE;
+ if (!redMask || !greenMask || !blueMask)
+ {
+ redMask = _RM(depth);
+ greenMask = _GM(depth);
+ blueMask = _BM(depth);
+ }
+ new->next = 0;
+ new->depth = depth;
+ new->visuals = visuals;
+ new->bitsPerRGB = bitsPerRGB;
+ new->redMask = redMask;
+ new->greenMask = greenMask;
+ new->blueMask = blueMask;
+ new->count = popCount (visuals);
+ for (prev = &fbVisuals; (v = *prev); prev = &v->next);
+ *prev = new;
+ return TRUE;
+}
+
+Bool
+fbHasVisualTypes (int depth)
+{
+ fbVisualsPtr v;
+
+ for (v = fbVisuals; v; v = v->next)
+ if (v->depth == depth)
+ return TRUE;
+ return FALSE;
+}
+
+Bool
+fbSetVisualTypes (int depth, int visuals, int bitsPerRGB)
+{
+ return fbSetVisualTypesAndMasks (depth, visuals, bitsPerRGB,
+ _RM(depth), _GM(depth), _BM(depth));
+}
+
+/*
+ * Given a list of formats for a screen, create a list
+ * of visuals and depths for the screen which coorespond to
+ * the set which can be used with this version of fb.
+ */
+
+Bool
+fbInitVisuals (VisualPtr *visualp,
+ DepthPtr *depthp,
+ int *nvisualp,
+ int *ndepthp,
+ int *rootDepthp,
+ VisualID *defaultVisp,
+ unsigned long sizes,
+ int bitsPerRGB)
+{
+ int i, j = 0, k;
+ VisualPtr visual;
+ DepthPtr depth;
+ VisualID *vid;
+ int d, b;
+ int f;
+ int ndepth, nvisual;
+ int nvtype;
+ int vtype;
+ fbVisualsPtr visuals, nextVisuals;
+
+ /* none specified, we'll guess from pixmap formats */
+ if (!fbVisuals)
+ {
+ for (f = 0; f < screenInfo.numPixmapFormats; f++)
+ {
+ d = screenInfo.formats[f].depth;
+ b = screenInfo.formats[f].bitsPerPixel;
+ if (sizes & (1 << (b - 1)))
+ {
+ if (d > MAX_PSEUDO_DEPTH)
+ vtype = LARGE_VISUALS;
+ else if (d == 1)
+ vtype = StaticGrayMask;
+ else
+ vtype = ALL_VISUALS;
+ }
+ else
+ vtype = 0;
+ if (!fbSetVisualTypes (d, vtype, bitsPerRGB))
+ return FALSE;
+ }
+ }
+ nvisual = 0;
+ ndepth = 0;
+ for (visuals = fbVisuals; visuals; visuals = nextVisuals)
+ {
+ nextVisuals = visuals->next;
+ ndepth++;
+ nvisual += visuals->count;
+ }
+ depth = (DepthPtr) xalloc (ndepth * sizeof (DepthRec));
+ visual = (VisualPtr) xalloc (nvisual * sizeof (VisualRec));
+ if (!depth || !visual)
+ {
+ xfree (depth);
+ xfree (visual);
+ return FALSE;
+ }
+ *depthp = depth;
+ *visualp = visual;
+ *ndepthp = ndepth;
+ *nvisualp = nvisual;
+ for (visuals = fbVisuals; visuals; visuals = nextVisuals)
+ {
+ nextVisuals = visuals->next;
+ d = visuals->depth;
+ vtype = visuals->visuals;
+ nvtype = visuals->count;
+ vid = NULL;
+ if (nvtype)
+ {
+ vid = (VisualID *) xalloc (nvtype * sizeof (VisualID));
+ if (!vid)
+ return FALSE;
+ }
+ depth->depth = d;
+ depth->numVids = nvtype;
+ depth->vids = vid;
+ depth++;
+ for (i = 0; i < NUM_PRIORITY; i++) {
+ if (! (vtype & (1 << fbVisualPriority[i])))
+ continue;
+ visual->class = fbVisualPriority[i];
+ visual->bitsPerRGBValue = visuals->bitsPerRGB;
+ visual->ColormapEntries = 1 << d;
+ visual->nplanes = d;
+ visual->vid = *vid = FakeClientID (0);
+ switch (visual->class) {
+ case PseudoColor:
+ case GrayScale:
+ case StaticGray:
+ case StaticColor:
+ visual->redMask = 0;
+ visual->greenMask = 0;
+ visual->blueMask = 0;
+ visual->offsetRed = 0;
+ visual->offsetGreen = 0;
+ visual->offsetBlue = 0;
+ break;
+ case DirectColor:
+ case TrueColor:
+ visual->ColormapEntries = _CE(d);
+ visual->redMask = visuals->redMask;
+ visual->greenMask = visuals->greenMask;
+ visual->blueMask = visuals->blueMask;
+ visual->offsetRed = maskShift (visuals->redMask);
+ visual->offsetGreen = maskShift (visuals->greenMask);
+ visual->offsetBlue = maskShift (visuals->blueMask);
+ }
+ vid++;
+ visual++;
+ }
+ xfree (visuals);
+ }
+ fbVisuals = NULL;
+ visual = *visualp;
+ depth = *depthp;
+ for (i = 0; i < ndepth; i++)
+ {
+ if (*rootDepthp && *rootDepthp != depth[i].depth)
+ continue;
+ for (j = 0; j < depth[i].numVids; j++)
+ {
+ for (k = 0; k < nvisual; k++)
+ if (visual[k].vid == depth[i].vids[j])
+ break;
+ if (k == nvisual)
+ continue;
+ if (defaultColorVisualClass < 0 ||
+ visual[k].class == defaultColorVisualClass)
+ break;
+ }
+ if (j != depth[i].numVids)
+ break;
+ }
+ if (i == ndepth) {
+ for (i = 0; i < ndepth; i++)
+ {
+ if (depth[i].numVids)
+ break;
+ }
+ if (i == ndepth)
+ return FALSE;
+ j = 0;
+ }
+ *rootDepthp = depth[i].depth;
+ *defaultVisp = depth[i].vids[j];
+ return TRUE;
+}
+#else
+
+#include "micmap.h"
+
+int
+fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
+{
+ return miListInstalledColormaps(pScreen, pmaps);
+}
+
+void
+fbInstallColormap(ColormapPtr pmap)
+{
+ miInstallColormap(pmap);
+}
+
+void
+fbUninstallColormap(ColormapPtr pmap)
+{
+ miUninstallColormap(pmap);
+}
+
+void
+fbResolveColor(unsigned short *pred,
+ unsigned short *pgreen,
+ unsigned short *pblue,
+ VisualPtr pVisual)
+{
+ miResolveColor(pred, pgreen, pblue, pVisual);
+}
+
+Bool
+fbInitializeColormap(ColormapPtr pmap)
+{
+ return miInitializeColormap(pmap);
+}
+
+int
+fbExpandDirectColors (ColormapPtr pmap,
+ int ndef,
+ xColorItem *indefs,
+ xColorItem *outdefs)
+{
+ return miExpandDirectColors(pmap, ndef, indefs, outdefs);
+}
+
+Bool
+fbCreateDefColormap(ScreenPtr pScreen)
+{
+ return miCreateDefColormap(pScreen);
+}
+
+void
+fbClearVisualTypes(void)
+{
+ miClearVisualTypes();
+}
+
+Bool
+fbSetVisualTypes (int depth, int visuals, int bitsPerRGB)
+{
+ return miSetVisualTypes(depth, visuals, bitsPerRGB, -1);
+}
+
+/*
+ * Given a list of formats for a screen, create a list
+ * of visuals and depths for the screen which coorespond to
+ * the set which can be used with this version of fb.
+ */
+
+Bool
+fbInitVisuals (VisualPtr *visualp,
+ DepthPtr *depthp,
+ int *nvisualp,
+ int *ndepthp,
+ int *rootDepthp,
+ VisualID *defaultVisp,
+ unsigned long sizes,
+ int bitsPerRGB)
+{
+ return miInitVisuals(visualp, depthp, nvisualp, ndepthp, rootDepthp,
+ defaultVisp, sizes, bitsPerRGB, -1);
+}
+#endif
diff --git a/nx-X11/programs/Xserver/fb/fbcompose.c b/nx-X11/programs/Xserver/fb/fbcompose.c
new file mode 100644
index 000000000..f8169995f
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbcompose.c
@@ -0,0 +1,3627 @@
+/*
+ * $XdotOrg: xc/programs/Xserver/fb/fbcompose.c,v 1.26 2005/12/09 18:35:20 ajax Exp $
+ * $XFree86: xc/programs/Xserver/fb/fbcompose.c,v 1.17tsi Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ * 2005 Lars Knoll & Zack Rusin, Trolltech
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+#ifdef RENDER
+
+#include "picturestr.h"
+#include "mipict.h"
+#include "fbpict.h"
+#include <math.h>
+
+#define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
+
+#define SCANLINE_BUFFER_LENGTH 2048
+
+typedef FASTCALL void (*fetchProc)(const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed);
+
+/*
+ * All of the fetch functions
+ */
+
+static FASTCALL void
+fbFetch_a8r8g8b8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ memcpy(buffer, (const CARD32 *)bits + x, width*sizeof(CARD32));
+}
+
+static FASTCALL void
+fbFetch_x8r8g8b8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD32 *pixel = (const CARD32 *)bits + x;
+ const CARD32 *end = pixel + width;
+ while (pixel < end) {
+ *buffer++ = *pixel++ | 0xff000000;
+ }
+}
+
+static FASTCALL void
+fbFetch_a8b8g8r8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD32 *pixel = (CARD32 *)bits + x;
+ const CARD32 *end = pixel + width;
+ while (pixel < end) {
+ *buffer++ = ((*pixel & 0xff00ff00) |
+ ((*pixel >> 16) & 0xff) |
+ ((*pixel & 0xff) << 16));
+ ++pixel;
+ }
+}
+
+static FASTCALL void
+fbFetch_x8b8g8r8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD32 *pixel = (CARD32 *)bits + x;
+ const CARD32 *end = pixel + width;
+ while (pixel < end) {
+ *buffer++ = 0xff000000 |
+ ((*pixel & 0x0000ff00) |
+ ((*pixel >> 16) & 0xff) |
+ ((*pixel & 0xff) << 16));
+ ++pixel;
+ }
+}
+
+static FASTCALL void
+fbFetch_r8g8b8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD8 *pixel = (const CARD8 *)bits + 3*x;
+ const CARD8 *end = pixel + 3*width;
+ while (pixel < end) {
+ CARD32 b = Fetch24(pixel) | 0xff000000;
+ pixel += 3;
+ *buffer++ = b;
+ }
+}
+
+static FASTCALL void
+fbFetch_b8g8r8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD8 *pixel = (const CARD8 *)bits + 3*x;
+ const CARD8 *end = pixel + 3*width;
+ while (pixel < end) {
+ CARD32 b = 0xff000000;
+#if IMAGE_BYTE_ORDER == MSBFirst
+ b |= (*pixel++);
+ b |= (*pixel++ << 8);
+ b |= (*pixel++ << 16);
+#else
+ b |= (*pixel++ << 16);
+ b |= (*pixel++ << 8);
+ b |= (*pixel++);
+#endif
+ }
+}
+
+static FASTCALL void
+fbFetch_r5g6b5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD16 *pixel = (const CARD16 *)bits + x;
+ const CARD16 *end = pixel + width;
+ while (pixel < end) {
+ CARD32 p = *pixel++;
+ CARD32 r = (((p) << 3) & 0xf8) |
+ (((p) << 5) & 0xfc00) |
+ (((p) << 8) & 0xf80000);
+ r |= (r >> 5) & 0x70007;
+ r |= (r >> 6) & 0x300;
+ *buffer++ = 0xff000000 | r;
+ }
+}
+
+static FASTCALL void
+fbFetch_b5g6r5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD16 *pixel = (const CARD16 *)bits + x;
+ const CARD16 *end = pixel + width;
+ while (pixel < end) {
+ CARD32 p = *pixel++;
+ CARD32 r,g,b;
+
+ b = ((p & 0xf800) | ((p & 0xe000) >> 5)) >> 8;
+ g = ((p & 0x07e0) | ((p & 0x0600) >> 6)) << 5;
+ r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14;
+ *buffer++ = (0xff000000 | r | g | b);
+ }
+}
+
+static FASTCALL void
+fbFetch_a1r5g5b5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD16 *pixel = (const CARD16 *)bits + x;
+ const CARD16 *end = pixel + width;
+ while (pixel < end) {
+ CARD32 p = *pixel++;
+ CARD32 r,g,b, a;
+
+ a = (CARD32) ((CARD8) (0 - ((p & 0x8000) >> 15))) << 24;
+ r = ((p & 0x7c00) | ((p & 0x7000) >> 5)) << 9;
+ g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
+ b = ((p & 0x001c) | ((p & 0x001f) << 5)) >> 2;
+ *buffer++ = (a | r | g | b);
+ }
+}
+
+static FASTCALL void
+fbFetch_x1r5g5b5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD16 *pixel = (const CARD16 *)bits + x;
+ const CARD16 *end = pixel + width;
+ while (pixel < end) {
+ CARD32 p = *pixel++;
+ CARD32 r,g,b;
+
+ r = ((p & 0x7c00) | ((p & 0x7000) >> 5)) << 9;
+ g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
+ b = ((p & 0x001c) | ((p & 0x001f) << 5)) >> 2;
+ *buffer++ = (0xff000000 | r | g | b);
+ }
+}
+
+static FASTCALL void
+fbFetch_a1b5g5r5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD16 *pixel = (const CARD16 *)bits + x;
+ const CARD16 *end = pixel + width;
+ while (pixel < end) {
+ CARD32 p = *pixel++;
+ CARD32 r,g,b, a;
+
+ a = (CARD32) ((CARD8) (0 - ((p & 0x8000) >> 15))) << 24;
+ b = ((p & 0x7c00) | ((p & 0x7000) >> 5)) >> 7;
+ g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
+ r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14;
+ *buffer++ = (a | r | g | b);
+ }
+}
+
+static FASTCALL void
+fbFetch_x1b5g5r5 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD16 *pixel = (const CARD16 *)bits + x;
+ const CARD16 *end = pixel + width;
+ while (pixel < end) {
+ CARD32 p = *pixel++;
+ CARD32 r,g,b;
+
+ b = ((p & 0x7c00) | ((p & 0x7000) >> 5)) >> 7;
+ g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
+ r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14;
+ *buffer++ = (0xff000000 | r | g | b);
+ }
+}
+
+static FASTCALL void
+fbFetch_a4r4g4b4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD16 *pixel = (const CARD16 *)bits + x;
+ const CARD16 *end = pixel + width;
+ while (pixel < end) {
+ CARD32 p = *pixel++;
+ CARD32 r,g,b, a;
+
+ a = ((p & 0xf000) | ((p & 0xf000) >> 4)) << 16;
+ r = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12;
+ g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
+ b = ((p & 0x000f) | ((p & 0x000f) << 4));
+ *buffer++ = (a | r | g | b);
+ }
+}
+
+static FASTCALL void
+fbFetch_x4r4g4b4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD16 *pixel = (const CARD16 *)bits + x;
+ const CARD16 *end = pixel + width;
+ while (pixel < end) {
+ CARD32 p = *pixel++;
+ CARD32 r,g,b;
+
+ r = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12;
+ g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
+ b = ((p & 0x000f) | ((p & 0x000f) << 4));
+ *buffer++ = (0xff000000 | r | g | b);
+ }
+}
+
+static FASTCALL void
+fbFetch_a4b4g4r4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD16 *pixel = (const CARD16 *)bits + x;
+ const CARD16 *end = pixel + width;
+ while (pixel < end) {
+ CARD32 p = *pixel++;
+ CARD32 r,g,b, a;
+
+ a = ((p & 0xf000) | ((p & 0xf000) >> 4)) << 16;
+ b = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12;
+ g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
+ r = ((p & 0x000f) | ((p & 0x000f) << 4));
+ *buffer++ = (a | r | g | b);
+ }
+}
+
+static FASTCALL void
+fbFetch_x4b4g4r4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD16 *pixel = (const CARD16 *)bits + x;
+ const CARD16 *end = pixel + width;
+ while (pixel < end) {
+ CARD32 p = *pixel++;
+ CARD32 r,g,b;
+
+ b = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12;
+ g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
+ r = ((p & 0x000f) | ((p & 0x000f) << 4));
+ *buffer++ = (0xff000000 | r | g | b);
+ }
+}
+
+static FASTCALL void
+fbFetch_a8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD8 *pixel = (const CARD8 *)bits + x;
+ const CARD8 *end = pixel + width;
+ while (pixel < end) {
+ *buffer++ = (*pixel++) << 24;
+ }
+}
+
+static FASTCALL void
+fbFetch_r3g3b2 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD8 *pixel = (const CARD8 *)bits + x;
+ const CARD8 *end = pixel + width;
+ while (pixel < end) {
+ CARD32 p = *pixel++;
+ CARD32 r,g,b;
+
+ r = ((p & 0xe0) | ((p & 0xe0) >> 3) | ((p & 0xc0) >> 6)) << 16;
+ g = ((p & 0x1c) | ((p & 0x18) >> 3) | ((p & 0x1c) << 3)) << 8;
+ b = (((p & 0x03) ) |
+ ((p & 0x03) << 2) |
+ ((p & 0x03) << 4) |
+ ((p & 0x03) << 6));
+ *buffer++ = (0xff000000 | r | g | b);
+ }
+}
+
+static FASTCALL void
+fbFetch_b2g3r3 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD8 *pixel = (const CARD8 *)bits + x;
+ const CARD8 *end = pixel + width;
+ while (pixel < end) {
+ CARD32 p = *pixel++;
+ CARD32 r,g,b;
+
+ b = (((p & 0xc0) ) |
+ ((p & 0xc0) >> 2) |
+ ((p & 0xc0) >> 4) |
+ ((p & 0xc0) >> 6));
+ g = ((p & 0x38) | ((p & 0x38) >> 3) | ((p & 0x30) << 2)) << 8;
+ r = (((p & 0x07) ) |
+ ((p & 0x07) << 3) |
+ ((p & 0x06) << 6)) << 16;
+ *buffer++ = (0xff000000 | r | g | b);
+ }
+}
+
+static FASTCALL void
+fbFetch_a2r2g2b2 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD8 *pixel = (const CARD8 *)bits + x;
+ const CARD8 *end = pixel + width;
+ while (pixel < end) {
+ CARD32 p = *pixel++;
+ CARD32 a,r,g,b;
+
+ a = ((p & 0xc0) * 0x55) << 18;
+ r = ((p & 0x30) * 0x55) << 12;
+ g = ((p & 0x0c) * 0x55) << 6;
+ b = ((p & 0x03) * 0x55);
+ *buffer++ = a|r|g|b;
+ }
+}
+
+static FASTCALL void
+fbFetch_a2b2g2r2 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD8 *pixel = (const CARD8 *)bits + x;
+ const CARD8 *end = pixel + width;
+ while (pixel < end) {
+ CARD32 p = *pixel++;
+ CARD32 a,r,g,b;
+
+ a = ((p & 0xc0) * 0x55) << 18;
+ b = ((p & 0x30) * 0x55) >> 6;
+ g = ((p & 0x0c) * 0x55) << 6;
+ r = ((p & 0x03) * 0x55) << 16;
+ *buffer++ = a|r|g|b;
+ }
+}
+
+static FASTCALL void
+fbFetch_c8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ const CARD8 *pixel = (const CARD8 *)bits + x;
+ const CARD8 *end = pixel + width;
+ while (pixel < end) {
+ CARD32 p = *pixel++;
+ *buffer++ = indexed->rgba[p];
+ }
+}
+
+#define Fetch8(l,o) (((CARD8 *) (l))[(o) >> 2])
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) & 0xf : Fetch8(l,o) >> 4)
+#else
+#define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) >> 4 : Fetch8(l,o) & 0xf)
+#endif
+
+static FASTCALL void
+fbFetch_a4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 p = Fetch4(bits, i + x);
+
+ p |= p << 4;
+ *buffer++ = p << 24;
+ }
+}
+
+static FASTCALL void
+fbFetch_r1g2b1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 p = Fetch4(bits, i + x);
+ CARD32 r,g,b;
+
+ r = ((p & 0x8) * 0xff) << 13;
+ g = ((p & 0x6) * 0x55) << 7;
+ b = ((p & 0x1) * 0xff);
+ *buffer++ = 0xff000000|r|g|b;
+ }
+}
+
+static FASTCALL void
+fbFetch_b1g2r1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 p = Fetch4(bits, i + x);
+ CARD32 r,g,b;
+
+ b = ((p & 0x8) * 0xff) >> 3;
+ g = ((p & 0x6) * 0x55) << 7;
+ r = ((p & 0x1) * 0xff) << 16;
+ *buffer++ = 0xff000000|r|g|b;
+ }
+}
+
+static FASTCALL void
+fbFetch_a1r1g1b1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 p = Fetch4(bits, i + x);
+ CARD32 a,r,g,b;
+
+ a = ((p & 0x8) * 0xff) << 21;
+ r = ((p & 0x4) * 0xff) << 14;
+ g = ((p & 0x2) * 0xff) << 7;
+ b = ((p & 0x1) * 0xff);
+ *buffer++ = a|r|g|b;
+ }
+}
+
+static FASTCALL void
+fbFetch_a1b1g1r1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 p = Fetch4(bits, i + x);
+ CARD32 a,r,g,b;
+
+ a = ((p & 0x8) * 0xff) << 21;
+ r = ((p & 0x4) * 0xff) >> 3;
+ g = ((p & 0x2) * 0xff) << 7;
+ b = ((p & 0x1) * 0xff) << 16;
+ *buffer++ = a|r|g|b;
+ }
+}
+
+static FASTCALL void
+fbFetch_c4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 p = Fetch4(bits, i + x);
+
+ *buffer++ = indexed->rgba[p];
+ }
+}
+
+
+static FASTCALL void
+fbFetch_a1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 p = ((CARD32 *)bits)[(i + x) >> 5];
+ CARD32 a;
+#if BITMAP_BIT_ORDER == MSBFirst
+ a = p >> (0x1f - ((i+x) & 0x1f));
+#else
+ a = p >> ((i+x) & 0x1f);
+#endif
+ a = a & 1;
+ a |= a << 1;
+ a |= a << 2;
+ a |= a << 4;
+ *buffer++ = a << 24;
+ }
+}
+
+static FASTCALL void
+fbFetch_g1 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 p = ((CARD32 *)bits)[(i+x) >> 5];
+ CARD32 a;
+#if BITMAP_BIT_ORDER == MSBFirst
+ a = p >> (0x1f - ((i+x) & 0x1f));
+#else
+ a = p >> ((i+x) & 0x1f);
+#endif
+ a = a & 1;
+ *buffer++ = indexed->rgba[a];
+ }
+}
+
+static fetchProc fetchProcForPicture (PicturePtr pict)
+{
+ switch(pict->format) {
+ case PICT_a8r8g8b8: return fbFetch_a8r8g8b8;
+ case PICT_x8r8g8b8: return fbFetch_x8r8g8b8;
+ case PICT_a8b8g8r8: return fbFetch_a8b8g8r8;
+ case PICT_x8b8g8r8: return fbFetch_x8b8g8r8;
+
+ /* 24bpp formats */
+ case PICT_r8g8b8: return fbFetch_r8g8b8;
+ case PICT_b8g8r8: return fbFetch_b8g8r8;
+
+ /* 16bpp formats */
+ case PICT_r5g6b5: return fbFetch_r5g6b5;
+ case PICT_b5g6r5: return fbFetch_b5g6r5;
+
+ case PICT_a1r5g5b5: return fbFetch_a1r5g5b5;
+ case PICT_x1r5g5b5: return fbFetch_x1r5g5b5;
+ case PICT_a1b5g5r5: return fbFetch_a1b5g5r5;
+ case PICT_x1b5g5r5: return fbFetch_x1b5g5r5;
+ case PICT_a4r4g4b4: return fbFetch_a4r4g4b4;
+ case PICT_x4r4g4b4: return fbFetch_x4r4g4b4;
+ case PICT_a4b4g4r4: return fbFetch_a4b4g4r4;
+ case PICT_x4b4g4r4: return fbFetch_x4b4g4r4;
+
+ /* 8bpp formats */
+ case PICT_a8: return fbFetch_a8;
+ case PICT_r3g3b2: return fbFetch_r3g3b2;
+ case PICT_b2g3r3: return fbFetch_b2g3r3;
+ case PICT_a2r2g2b2: return fbFetch_a2r2g2b2;
+ case PICT_a2b2g2r2: return fbFetch_a2b2g2r2;
+ case PICT_c8: return fbFetch_c8;
+ case PICT_g8: return fbFetch_c8;
+
+ /* 4bpp formats */
+ case PICT_a4: return fbFetch_a4;
+ case PICT_r1g2b1: return fbFetch_r1g2b1;
+ case PICT_b1g2r1: return fbFetch_b1g2r1;
+ case PICT_a1r1g1b1: return fbFetch_a1r1g1b1;
+ case PICT_a1b1g1r1: return fbFetch_a1b1g1r1;
+ case PICT_c4: return fbFetch_c4;
+ case PICT_g4: return fbFetch_c4;
+
+ /* 1bpp formats */
+ case PICT_a1: return fbFetch_a1;
+ case PICT_g1: return fbFetch_g1;
+ default:
+ return NULL;
+ }
+}
+
+/*
+ * Pixel wise fetching
+ */
+
+typedef FASTCALL CARD32 (*fetchPixelProc)(const FbBits *bits, int offset, miIndexedPtr indexed);
+
+static FASTCALL CARD32
+fbFetchPixel_a8r8g8b8 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ return ((CARD32 *)bits)[offset];
+}
+
+static FASTCALL CARD32
+fbFetchPixel_x8r8g8b8 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ return ((CARD32 *)bits)[offset] | 0xff000000;
+}
+
+static FASTCALL CARD32
+fbFetchPixel_a8b8g8r8 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD32 *)bits)[offset];
+
+ return ((pixel & 0xff000000) |
+ ((pixel >> 16) & 0xff) |
+ (pixel & 0x0000ff00) |
+ ((pixel & 0xff) << 16));
+}
+
+static FASTCALL CARD32
+fbFetchPixel_x8b8g8r8 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD32 *)bits)[offset];
+
+ return ((0xff000000) |
+ ((pixel >> 16) & 0xff) |
+ (pixel & 0x0000ff00) |
+ ((pixel & 0xff) << 16));
+}
+
+static FASTCALL CARD32
+fbFetchPixel_r8g8b8 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD8 *pixel = ((CARD8 *) bits) + (offset*3);
+#if IMAGE_BYTE_ORDER == MSBFirst
+ return (0xff000000 |
+ (pixel[0] << 16) |
+ (pixel[1] << 8) |
+ (pixel[2]));
+#else
+ return (0xff000000 |
+ (pixel[2] << 16) |
+ (pixel[1] << 8) |
+ (pixel[0]));
+#endif
+}
+
+static FASTCALL CARD32
+fbFetchPixel_b8g8r8 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD8 *pixel = ((CARD8 *) bits) + (offset*3);
+#if IMAGE_BYTE_ORDER == MSBFirst
+ return (0xff000000 |
+ (pixel[2] << 16) |
+ (pixel[1] << 8) |
+ (pixel[0]));
+#else
+ return (0xff000000 |
+ (pixel[0] << 16) |
+ (pixel[1] << 8) |
+ (pixel[2]));
+#endif
+}
+
+static FASTCALL CARD32
+fbFetchPixel_r5g6b5 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD16 *) bits)[offset];
+ CARD32 r,g,b;
+
+ r = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) << 8;
+ g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5;
+ b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
+ return (0xff000000 | r | g | b);
+}
+
+static FASTCALL CARD32
+fbFetchPixel_b5g6r5 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD16 *) bits)[offset];
+ CARD32 r,g,b;
+
+ b = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) >> 8;
+ g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5;
+ r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
+ return (0xff000000 | r | g | b);
+}
+
+static FASTCALL CARD32
+fbFetchPixel_a1r5g5b5 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD16 *) bits)[offset];
+ CARD32 a,r,g,b;
+
+ a = (CARD32) ((CARD8) (0 - ((pixel & 0x8000) >> 15))) << 24;
+ r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9;
+ g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
+ b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
+ return (a | r | g | b);
+}
+
+static FASTCALL CARD32
+fbFetchPixel_x1r5g5b5 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD16 *) bits)[offset];
+ CARD32 r,g,b;
+
+ r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9;
+ g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
+ b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
+ return (0xff000000 | r | g | b);
+}
+
+static FASTCALL CARD32
+fbFetchPixel_a1b5g5r5 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD16 *) bits)[offset];
+ CARD32 a,r,g,b;
+
+ a = (CARD32) ((CARD8) (0 - ((pixel & 0x8000) >> 15))) << 24;
+ b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7;
+ g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
+ r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
+ return (a | r | g | b);
+}
+
+static FASTCALL CARD32
+fbFetchPixel_x1b5g5r5 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD16 *) bits)[offset];
+ CARD32 r,g,b;
+
+ b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7;
+ g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
+ r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
+ return (0xff000000 | r | g | b);
+}
+
+static FASTCALL CARD32
+fbFetchPixel_a4r4g4b4 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD16 *) bits)[offset];
+ CARD32 a,r,g,b;
+
+ a = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16;
+ r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12;
+ g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
+ b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4));
+ return (a | r | g | b);
+}
+
+static FASTCALL CARD32
+fbFetchPixel_x4r4g4b4 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD16 *) bits)[offset];
+ CARD32 r,g,b;
+
+ r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12;
+ g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
+ b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4));
+ return (0xff000000 | r | g | b);
+}
+
+static FASTCALL CARD32
+fbFetchPixel_a4b4g4r4 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD16 *) bits)[offset];
+ CARD32 a,r,g,b;
+
+ a = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16;
+ b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12;
+ g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
+ r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4));
+ return (a | r | g | b);
+}
+
+static FASTCALL CARD32
+fbFetchPixel_x4b4g4r4 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD16 *) bits)[offset];
+ CARD32 r,g,b;
+
+ b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12;
+ g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
+ r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4));
+ return (0xff000000 | r | g | b);
+}
+
+static FASTCALL CARD32
+fbFetchPixel_a8 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD8 *) bits)[offset];
+
+ return pixel << 24;
+}
+
+static FASTCALL CARD32
+fbFetchPixel_r3g3b2 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD8 *) bits)[offset];
+ CARD32 r,g,b;
+
+ r = ((pixel & 0xe0) | ((pixel & 0xe0) >> 3) | ((pixel & 0xc0) >> 6)) << 16;
+ g = ((pixel & 0x1c) | ((pixel & 0x18) >> 3) | ((pixel & 0x1c) << 3)) << 8;
+ b = (((pixel & 0x03) ) |
+ ((pixel & 0x03) << 2) |
+ ((pixel & 0x03) << 4) |
+ ((pixel & 0x03) << 6));
+ return (0xff000000 | r | g | b);
+}
+
+static FASTCALL CARD32
+fbFetchPixel_b2g3r3 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD8 *) bits)[offset];
+ CARD32 r,g,b;
+
+ b = (((pixel & 0xc0) ) |
+ ((pixel & 0xc0) >> 2) |
+ ((pixel & 0xc0) >> 4) |
+ ((pixel & 0xc0) >> 6));
+ g = ((pixel & 0x38) | ((pixel & 0x38) >> 3) | ((pixel & 0x30) << 2)) << 8;
+ r = (((pixel & 0x07) ) |
+ ((pixel & 0x07) << 3) |
+ ((pixel & 0x06) << 6)) << 16;
+ return (0xff000000 | r | g | b);
+}
+
+static FASTCALL CARD32
+fbFetchPixel_a2r2g2b2 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD8 *) bits)[offset];
+ CARD32 a,r,g,b;
+
+ a = ((pixel & 0xc0) * 0x55) << 18;
+ r = ((pixel & 0x30) * 0x55) << 12;
+ g = ((pixel & 0x0c) * 0x55) << 6;
+ b = ((pixel & 0x03) * 0x55);
+ return a|r|g|b;
+}
+
+static FASTCALL CARD32
+fbFetchPixel_a2b2g2r2 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD8 *) bits)[offset];
+ CARD32 a,r,g,b;
+
+ a = ((pixel & 0xc0) * 0x55) << 18;
+ b = ((pixel & 0x30) * 0x55) >> 6;
+ g = ((pixel & 0x0c) * 0x55) << 6;
+ r = ((pixel & 0x03) * 0x55) << 16;
+ return a|r|g|b;
+}
+
+static FASTCALL CARD32
+fbFetchPixel_c8 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD8 *) bits)[offset];
+ return indexed->rgba[pixel];
+}
+
+#define Fetch8(l,o) (((CARD8 *) (l))[(o) >> 2])
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) & 0xf : Fetch8(l,o) >> 4)
+#else
+#define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) >> 4 : Fetch8(l,o) & 0xf)
+#endif
+
+static FASTCALL CARD32
+fbFetchPixel_a4 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = Fetch4(bits, offset);
+
+ pixel |= pixel << 4;
+ return pixel << 24;
+}
+
+static FASTCALL CARD32
+fbFetchPixel_r1g2b1 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = Fetch4(bits, offset);
+ CARD32 r,g,b;
+
+ r = ((pixel & 0x8) * 0xff) << 13;
+ g = ((pixel & 0x6) * 0x55) << 7;
+ b = ((pixel & 0x1) * 0xff);
+ return 0xff000000|r|g|b;
+}
+
+static FASTCALL CARD32
+fbFetchPixel_b1g2r1 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = Fetch4(bits, offset);
+ CARD32 r,g,b;
+
+ b = ((pixel & 0x8) * 0xff) >> 3;
+ g = ((pixel & 0x6) * 0x55) << 7;
+ r = ((pixel & 0x1) * 0xff) << 16;
+ return 0xff000000|r|g|b;
+}
+
+static FASTCALL CARD32
+fbFetchPixel_a1r1g1b1 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = Fetch4(bits, offset);
+ CARD32 a,r,g,b;
+
+ a = ((pixel & 0x8) * 0xff) << 21;
+ r = ((pixel & 0x4) * 0xff) << 14;
+ g = ((pixel & 0x2) * 0xff) << 7;
+ b = ((pixel & 0x1) * 0xff);
+ return a|r|g|b;
+}
+
+static FASTCALL CARD32
+fbFetchPixel_a1b1g1r1 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = Fetch4(bits, offset);
+ CARD32 a,r,g,b;
+
+ a = ((pixel & 0x8) * 0xff) << 21;
+ r = ((pixel & 0x4) * 0xff) >> 3;
+ g = ((pixel & 0x2) * 0xff) << 7;
+ b = ((pixel & 0x1) * 0xff) << 16;
+ return a|r|g|b;
+}
+
+static FASTCALL CARD32
+fbFetchPixel_c4 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = Fetch4(bits, offset);
+
+ return indexed->rgba[pixel];
+}
+
+
+static FASTCALL CARD32
+fbFetchPixel_a1 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD32 *)bits)[offset >> 5];
+ CARD32 a;
+#if BITMAP_BIT_ORDER == MSBFirst
+ a = pixel >> (0x1f - (offset & 0x1f));
+#else
+ a = pixel >> (offset & 0x1f);
+#endif
+ a = a & 1;
+ a |= a << 1;
+ a |= a << 2;
+ a |= a << 4;
+ return a << 24;
+}
+
+static FASTCALL CARD32
+fbFetchPixel_g1 (const FbBits *bits, int offset, miIndexedPtr indexed)
+{
+ CARD32 pixel = ((CARD32 *)bits)[offset >> 5];
+ CARD32 a;
+#if BITMAP_BIT_ORDER == MSBFirst
+ a = pixel >> (0x1f - (offset & 0x1f));
+#else
+ a = pixel >> (offset & 0x1f);
+#endif
+ a = a & 1;
+ return indexed->rgba[a];
+}
+
+static fetchPixelProc fetchPixelProcForPicture (PicturePtr pict)
+{
+ switch(pict->format) {
+ case PICT_a8r8g8b8: return fbFetchPixel_a8r8g8b8;
+ case PICT_x8r8g8b8: return fbFetchPixel_x8r8g8b8;
+ case PICT_a8b8g8r8: return fbFetchPixel_a8b8g8r8;
+ case PICT_x8b8g8r8: return fbFetchPixel_x8b8g8r8;
+
+ /* 24bpp formats */
+ case PICT_r8g8b8: return fbFetchPixel_r8g8b8;
+ case PICT_b8g8r8: return fbFetchPixel_b8g8r8;
+
+ /* 16bpp formats */
+ case PICT_r5g6b5: return fbFetchPixel_r5g6b5;
+ case PICT_b5g6r5: return fbFetchPixel_b5g6r5;
+
+ case PICT_a1r5g5b5: return fbFetchPixel_a1r5g5b5;
+ case PICT_x1r5g5b5: return fbFetchPixel_x1r5g5b5;
+ case PICT_a1b5g5r5: return fbFetchPixel_a1b5g5r5;
+ case PICT_x1b5g5r5: return fbFetchPixel_x1b5g5r5;
+ case PICT_a4r4g4b4: return fbFetchPixel_a4r4g4b4;
+ case PICT_x4r4g4b4: return fbFetchPixel_x4r4g4b4;
+ case PICT_a4b4g4r4: return fbFetchPixel_a4b4g4r4;
+ case PICT_x4b4g4r4: return fbFetchPixel_x4b4g4r4;
+
+ /* 8bpp formats */
+ case PICT_a8: return fbFetchPixel_a8;
+ case PICT_r3g3b2: return fbFetchPixel_r3g3b2;
+ case PICT_b2g3r3: return fbFetchPixel_b2g3r3;
+ case PICT_a2r2g2b2: return fbFetchPixel_a2r2g2b2;
+ case PICT_a2b2g2r2: return fbFetchPixel_a2b2g2r2;
+ case PICT_c8: return fbFetchPixel_c8;
+ case PICT_g8: return fbFetchPixel_c8;
+
+ /* 4bpp formats */
+ case PICT_a4: return fbFetchPixel_a4;
+ case PICT_r1g2b1: return fbFetchPixel_r1g2b1;
+ case PICT_b1g2r1: return fbFetchPixel_b1g2r1;
+ case PICT_a1r1g1b1: return fbFetchPixel_a1r1g1b1;
+ case PICT_a1b1g1r1: return fbFetchPixel_a1b1g1r1;
+ case PICT_c4: return fbFetchPixel_c4;
+ case PICT_g4: return fbFetchPixel_c4;
+
+ /* 1bpp formats */
+ case PICT_a1: return fbFetchPixel_a1;
+ case PICT_g1: return fbFetchPixel_g1;
+ default:
+ return NULL;
+ }
+}
+
+
+
+/*
+ * All the store functions
+ */
+
+typedef FASTCALL void (*storeProc) (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed);
+
+#define Splita(v) CARD32 a = ((v) >> 24), r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff
+#define Split(v) CARD32 r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff
+
+static FASTCALL void
+fbStore_a8r8g8b8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ memcpy(((CARD32 *)bits) + x, values, width*sizeof(CARD32));
+}
+
+static FASTCALL void
+fbStore_x8r8g8b8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD32 *pixel = (CARD32 *)bits + x;
+ for (i = 0; i < width; ++i)
+ *pixel++ = values[i] & 0xffffff;
+}
+
+static FASTCALL void
+fbStore_a8b8g8r8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD32 *pixel = (CARD32 *)bits + x;
+ for (i = 0; i < width; ++i)
+ *pixel++ = (values[i] & 0xff00ff00) | ((values[i] >> 16) & 0xff) | ((values[i] & 0xff) << 16);
+}
+
+static FASTCALL void
+fbStore_x8b8g8r8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD32 *pixel = (CARD32 *)bits + x;
+ for (i = 0; i < width; ++i)
+ *pixel++ = (values[i] & 0x0000ff00) | ((values[i] >> 16) & 0xff) | ((values[i] & 0xff) << 16);
+}
+
+static FASTCALL void
+fbStore_r8g8b8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD8 *pixel = ((CARD8 *) bits) + 3*x;
+ for (i = 0; i < width; ++i) {
+ Store24(pixel, values[i]);
+ pixel += 3;
+ }
+}
+
+static FASTCALL void
+fbStore_b8g8r8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD8 *pixel = ((CARD8 *) bits) + 3*x;
+ for (i = 0; i < width; ++i) {
+#if IMAGE_BYTE_ORDER == MSBFirst
+ *pixel++ = Blue(values[i]);
+ *pixel++ = Green(values[i]);
+ *pixel++ = Red(values[i]);
+#else
+ *pixel++ = Red(values[i]);
+ *pixel++ = Green(values[i]);
+ *pixel++ = Blue(values[i]);
+#endif
+ }
+}
+
+static FASTCALL void
+fbStore_r5g6b5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD16 *pixel = ((CARD16 *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ CARD32 s = values[i];
+ *pixel++ = ((s >> 3) & 0x001f) |
+ ((s >> 5) & 0x07e0) |
+ ((s >> 8) & 0xf800);
+ }
+}
+
+static FASTCALL void
+fbStore_b5g6r5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD16 *pixel = ((CARD16 *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ Split(values[i]);
+ *pixel++ = (((b << 8) & 0xf800) |
+ ((g << 3) & 0x07e0) |
+ ((r >> 3) ));
+ }
+}
+
+static FASTCALL void
+fbStore_a1r5g5b5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD16 *pixel = ((CARD16 *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ Splita(values[i]);
+ *pixel++ = (((a << 8) & 0x8000) |
+ ((r << 7) & 0x7c00) |
+ ((g << 2) & 0x03e0) |
+ ((b >> 3) ));
+ }
+}
+
+static FASTCALL void
+fbStore_x1r5g5b5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD16 *pixel = ((CARD16 *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ Split(values[i]);
+ *pixel++ = (((r << 7) & 0x7c00) |
+ ((g << 2) & 0x03e0) |
+ ((b >> 3) ));
+ }
+}
+
+static FASTCALL void
+fbStore_a1b5g5r5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD16 *pixel = ((CARD16 *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ Splita(values[i]);
+ *pixel++ = (((a << 8) & 0x8000) |
+ ((b << 7) & 0x7c00) |
+ ((g << 2) & 0x03e0) |
+ ((r >> 3) ));
+ }
+}
+
+static FASTCALL void
+fbStore_x1b5g5r5 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD16 *pixel = ((CARD16 *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ Split(values[i]);
+ *pixel++ = (((b << 7) & 0x7c00) |
+ ((g << 2) & 0x03e0) |
+ ((r >> 3) ));
+ }
+}
+
+static FASTCALL void
+fbStore_a4r4g4b4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD16 *pixel = ((CARD16 *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ Splita(values[i]);
+ *pixel++ = (((a << 8) & 0xf000) |
+ ((r << 4) & 0x0f00) |
+ ((g ) & 0x00f0) |
+ ((b >> 4) ));
+ }
+}
+
+static FASTCALL void
+fbStore_x4r4g4b4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD16 *pixel = ((CARD16 *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ Split(values[i]);
+ *pixel++ = (((r << 4) & 0x0f00) |
+ ((g ) & 0x00f0) |
+ ((b >> 4) ));
+ }
+}
+
+static FASTCALL void
+fbStore_a4b4g4r4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD16 *pixel = ((CARD16 *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ Splita(values[i]);
+ *pixel++ = (((a << 8) & 0xf000) |
+ ((b << 4) & 0x0f00) |
+ ((g ) & 0x00f0) |
+ ((r >> 4) ));
+ }
+}
+
+static FASTCALL void
+fbStore_x4b4g4r4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD16 *pixel = ((CARD16 *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ Split(values[i]);
+ *pixel++ = (((b << 4) & 0x0f00) |
+ ((g ) & 0x00f0) |
+ ((r >> 4) ));
+ }
+}
+
+static FASTCALL void
+fbStore_a8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD8 *pixel = ((CARD8 *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ *pixel++ = values[i] >> 24;
+ }
+}
+
+static FASTCALL void
+fbStore_r3g3b2 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD8 *pixel = ((CARD8 *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ Split(values[i]);
+ *pixel++ = (((r ) & 0xe0) |
+ ((g >> 3) & 0x1c) |
+ ((b >> 6) ));
+ }
+}
+
+static FASTCALL void
+fbStore_b2g3r3 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD8 *pixel = ((CARD8 *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ Split(values[i]);
+ *pixel++ = (((b ) & 0xe0) |
+ ((g >> 3) & 0x1c) |
+ ((r >> 6) ));
+ }
+}
+
+static FASTCALL void
+fbStore_a2r2g2b2 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD8 *pixel = ((CARD8 *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ Splita(values[i]);
+ *pixel++ = (((a ) & 0xc0) |
+ ((r >> 2) & 0x30) |
+ ((g >> 4) & 0x0c) |
+ ((b >> 6) ));
+ }
+}
+
+static FASTCALL void
+fbStore_c8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ CARD8 *pixel = ((CARD8 *) bits) + x;
+ for (i = 0; i < width; ++i) {
+ *pixel++ = miIndexToEnt24(indexed,values[i]);
+ }
+}
+
+#define Store8(l,o,v) (((CARD8 *) l)[(o) >> 3] = (v))
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define Store4(l,o,v) Store8(l,o,((o) & 4 ? \
+ (Fetch8(l,o) & 0xf0) | (v) : \
+ (Fetch8(l,o) & 0x0f) | ((v) << 4)))
+#else
+#define Store4(l,o,v) Store8(l,o,((o) & 4 ? \
+ (Fetch8(l,o) & 0x0f) | ((v) << 4) : \
+ (Fetch8(l,o) & 0xf0) | (v)))
+#endif
+
+static FASTCALL void
+fbStore_a4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ Store4(bits, i + x, values[i]>>28);
+ }
+}
+
+static FASTCALL void
+fbStore_r1g2b1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 pixel;
+
+ Split(values[i]);
+ pixel = (((r >> 4) & 0x8) |
+ ((g >> 5) & 0x6) |
+ ((b >> 7) ));
+ Store4(bits, i + x, pixel);
+ }
+}
+
+static FASTCALL void
+fbStore_b1g2r1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 pixel;
+
+ Split(values[i]);
+ pixel = (((b >> 4) & 0x8) |
+ ((g >> 5) & 0x6) |
+ ((r >> 7) ));
+ Store4(bits, i + x, pixel);
+ }
+}
+
+static FASTCALL void
+fbStore_a1r1g1b1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 pixel;
+ Splita(values[i]);
+ pixel = (((a >> 4) & 0x8) |
+ ((r >> 5) & 0x4) |
+ ((g >> 6) & 0x2) |
+ ((b >> 7) ));
+ Store4(bits, i + x, pixel);
+ }
+}
+
+static FASTCALL void
+fbStore_a1b1g1r1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 pixel;
+ Splita(values[i]);
+ pixel = (((a >> 4) & 0x8) |
+ ((b >> 5) & 0x4) |
+ ((g >> 6) & 0x2) |
+ ((r >> 7) ));
+ Store4(bits, i + x, pixel);
+ }
+}
+
+static FASTCALL void
+fbStore_c4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 pixel;
+
+ pixel = miIndexToEnt24(indexed, values[i]);
+ Store4(bits, i + x, pixel);
+ }
+}
+
+static FASTCALL void
+fbStore_a1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 *pixel = ((CARD32 *) bits) + ((i+x) >> 5);
+ CARD32 mask = FbStipMask((i+x) & 0x1f, 1);
+
+ CARD32 v = values[i] & 0x80000000 ? mask : 0;
+ *pixel = (*pixel & ~mask) | v;
+ }
+}
+
+static FASTCALL void
+fbStore_g1 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 *pixel = ((CARD32 *) bits) + ((i+x) >> 5);
+ CARD32 mask = FbStipMask((i+x) & 0x1f, 1);
+
+ CARD32 v = miIndexToEntY24(indexed,values[i]) ? mask : 0;
+ *pixel = (*pixel & ~mask) | v;
+ }
+}
+
+
+static storeProc storeProcForPicture (PicturePtr pict)
+{
+ switch(pict->format) {
+ case PICT_a8r8g8b8: return fbStore_a8r8g8b8;
+ case PICT_x8r8g8b8: return fbStore_x8r8g8b8;
+ case PICT_a8b8g8r8: return fbStore_a8b8g8r8;
+ case PICT_x8b8g8r8: return fbStore_x8b8g8r8;
+
+ /* 24bpp formats */
+ case PICT_r8g8b8: return fbStore_r8g8b8;
+ case PICT_b8g8r8: return fbStore_b8g8r8;
+
+ /* 16bpp formats */
+ case PICT_r5g6b5: return fbStore_r5g6b5;
+ case PICT_b5g6r5: return fbStore_b5g6r5;
+
+ case PICT_a1r5g5b5: return fbStore_a1r5g5b5;
+ case PICT_x1r5g5b5: return fbStore_x1r5g5b5;
+ case PICT_a1b5g5r5: return fbStore_a1b5g5r5;
+ case PICT_x1b5g5r5: return fbStore_x1b5g5r5;
+ case PICT_a4r4g4b4: return fbStore_a4r4g4b4;
+ case PICT_x4r4g4b4: return fbStore_x4r4g4b4;
+ case PICT_a4b4g4r4: return fbStore_a4b4g4r4;
+ case PICT_x4b4g4r4: return fbStore_x4b4g4r4;
+
+ /* 8bpp formats */
+ case PICT_a8: return fbStore_a8;
+ case PICT_r3g3b2: return fbStore_r3g3b2;
+ case PICT_b2g3r3: return fbStore_b2g3r3;
+ case PICT_a2r2g2b2: return fbStore_a2r2g2b2;
+ case PICT_c8: return fbStore_c8;
+ case PICT_g8: return fbStore_c8;
+
+ /* 4bpp formats */
+ case PICT_a4: return fbStore_a4;
+ case PICT_r1g2b1: return fbStore_r1g2b1;
+ case PICT_b1g2r1: return fbStore_b1g2r1;
+ case PICT_a1r1g1b1: return fbStore_a1r1g1b1;
+ case PICT_a1b1g1r1: return fbStore_a1b1g1r1;
+ case PICT_c4: return fbStore_c4;
+ case PICT_g4: return fbStore_c4;
+
+ /* 1bpp formats */
+ case PICT_a1: return fbStore_a1;
+ case PICT_g1: return fbStore_g1;
+ default:
+ return NULL;
+ }
+}
+
+
+/*
+ * Combine src and mask
+ */
+static FASTCALL void
+fbCombineMaskU (CARD32 *src, const CARD32 *mask, int width)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 a = mask[i] >> 24;
+ CARD32 s = src[i];
+ FbByteMul(s, a);
+ src[i] = s;
+ }
+}
+
+/*
+ * All of the composing functions
+ */
+
+static FASTCALL void
+fbCombineClear (CARD32 *dest, const CARD32 *src, int width)
+{
+ memset(dest, 0, width*sizeof(CARD32));
+}
+
+static FASTCALL void
+fbCombineSrcU (CARD32 *dest, const CARD32 *src, int width)
+{
+ memcpy(dest, src, width*sizeof(CARD32));
+}
+
+
+static FASTCALL void
+fbCombineOverU (CARD32 *dest, const CARD32 *src, int width)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 s = src[i];
+ CARD32 d = dest[i];
+ CARD32 ia = Alpha(~s);
+
+ FbByteMulAdd(d, ia, s);
+ dest[i] = d;
+ }
+}
+
+static FASTCALL void
+fbCombineOverReverseU (CARD32 *dest, const CARD32 *src, int width)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 s = src[i];
+ CARD32 d = dest[i];
+ CARD32 ia = Alpha(~dest[i]);
+ FbByteMulAdd(s, ia, d);
+ dest[i] = s;
+ }
+}
+
+static FASTCALL void
+fbCombineInU (CARD32 *dest, const CARD32 *src, int width)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 s = src[i];
+ CARD32 a = Alpha(dest[i]);
+ FbByteMul(s, a);
+ dest[i] = s;
+ }
+}
+
+static FASTCALL void
+fbCombineInReverseU (CARD32 *dest, const CARD32 *src, int width)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 d = dest[i];
+ CARD32 a = Alpha(src[i]);
+ FbByteMul(d, a);
+ dest[i] = d;
+ }
+}
+
+static FASTCALL void
+fbCombineOutU (CARD32 *dest, const CARD32 *src, int width)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 s = src[i];
+ CARD32 a = Alpha(~dest[i]);
+ FbByteMul(s, a);
+ dest[i] = s;
+ }
+}
+
+static FASTCALL void
+fbCombineOutReverseU (CARD32 *dest, const CARD32 *src, int width)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 d = dest[i];
+ CARD32 a = Alpha(~src[i]);
+ FbByteMul(d, a);
+ dest[i] = d;
+ }
+}
+
+static FASTCALL void
+fbCombineAtopU (CARD32 *dest, const CARD32 *src, int width)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 s = src[i];
+ CARD32 d = dest[i];
+ CARD32 dest_a = Alpha(d);
+ CARD32 src_ia = Alpha(~s);
+
+ FbByteAddMul(s, dest_a, d, src_ia);
+ dest[i] = s;
+ }
+}
+
+static FASTCALL void
+fbCombineAtopReverseU (CARD32 *dest, const CARD32 *src, int width)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 s = src[i];
+ CARD32 d = dest[i];
+ CARD32 src_a = Alpha(s);
+ CARD32 dest_ia = Alpha(~d);
+
+ FbByteAddMul(s, dest_ia, d, src_a);
+ dest[i] = s;
+ }
+}
+
+static FASTCALL void
+fbCombineXorU (CARD32 *dest, const CARD32 *src, int width)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 s = src[i];
+ CARD32 d = dest[i];
+ CARD32 src_ia = Alpha(~s);
+ CARD32 dest_ia = Alpha(~d);
+
+ FbByteAddMul(s, dest_ia, d, src_ia);
+ dest[i] = s;
+ }
+}
+
+static FASTCALL void
+fbCombineAddU (CARD32 *dest, const CARD32 *src, int width)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 s = src[i];
+ CARD32 d = dest[i];
+ FbByteAdd(d, s);
+ dest[i] = d;
+ }
+}
+
+static FASTCALL void
+fbCombineSaturateU (CARD32 *dest, const CARD32 *src, int width)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 s = src[i];
+ CARD32 d = dest[i];
+ CARD16 sa, da;
+
+ sa = s >> 24;
+ da = ~d >> 24;
+ if (sa > da)
+ {
+ sa = FbIntDiv(da, sa);
+ FbByteMul(s, sa);
+ }
+ FbByteAdd(d, s);
+ dest[i] = d;
+ }
+}
+
+/*
+ * All of the disjoint composing functions
+
+ The four entries in the first column indicate what source contributions
+ come from each of the four areas of the picture -- areas covered by neither
+ A nor B, areas covered only by A, areas covered only by B and finally
+ areas covered by both A and B.
+
+ Disjoint Conjoint
+ Fa Fb Fa Fb
+(0,0,0,0) 0 0 0 0
+(0,A,0,A) 1 0 1 0
+(0,0,B,B) 0 1 0 1
+(0,A,B,A) 1 min((1-a)/b,1) 1 max(1-a/b,0)
+(0,A,B,B) min((1-b)/a,1) 1 max(1-b/a,0) 1
+(0,0,0,A) max(1-(1-b)/a,0) 0 min(1,b/a) 0
+(0,0,0,B) 0 max(1-(1-a)/b,0) 0 min(a/b,1)
+(0,A,0,0) min(1,(1-b)/a) 0 max(1-b/a,0) 0
+(0,0,B,0) 0 min(1,(1-a)/b) 0 max(1-a/b,0)
+(0,0,B,A) max(1-(1-b)/a,0) min(1,(1-a)/b) min(1,b/a) max(1-a/b,0)
+(0,A,0,B) min(1,(1-b)/a) max(1-(1-a)/b,0) max(1-b/a,0) min(1,a/b)
+(0,A,B,0) min(1,(1-b)/a) min(1,(1-a)/b) max(1-b/a,0) max(1-a/b,0)
+
+ */
+
+#define CombineAOut 1
+#define CombineAIn 2
+#define CombineBOut 4
+#define CombineBIn 8
+
+#define CombineClear 0
+#define CombineA (CombineAOut|CombineAIn)
+#define CombineB (CombineBOut|CombineBIn)
+#define CombineAOver (CombineAOut|CombineBOut|CombineAIn)
+#define CombineBOver (CombineAOut|CombineBOut|CombineBIn)
+#define CombineAAtop (CombineBOut|CombineAIn)
+#define CombineBAtop (CombineAOut|CombineBIn)
+#define CombineXor (CombineAOut|CombineBOut)
+
+/* portion covered by a but not b */
+static INLINE CARD8
+fbCombineDisjointOutPart (CARD8 a, CARD8 b)
+{
+ /* min (1, (1-b) / a) */
+
+ b = ~b; /* 1 - b */
+ if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */
+ return 0xff; /* 1 */
+ return FbIntDiv(b,a); /* (1-b) / a */
+}
+
+/* portion covered by both a and b */
+static INLINE CARD8
+fbCombineDisjointInPart (CARD8 a, CARD8 b)
+{
+ /* max (1-(1-b)/a,0) */
+ /* = - min ((1-b)/a - 1, 0) */
+ /* = 1 - min (1, (1-b)/a) */
+
+ b = ~b; /* 1 - b */
+ if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */
+ return 0; /* 1 - 1 */
+ return ~FbIntDiv(b,a); /* 1 - (1-b) / a */
+}
+
+static FASTCALL void
+fbCombineDisjointGeneralU (CARD32 *dest, const CARD32 *src, int width, CARD8 combine)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 s = src[i];
+ CARD32 d = dest[i];
+ CARD32 m,n,o,p;
+ CARD16 Fa, Fb, t, u, v;
+ CARD8 sa = s >> 24;
+ CARD8 da = d >> 24;
+
+ switch (combine & CombineA) {
+ default:
+ Fa = 0;
+ break;
+ case CombineAOut:
+ Fa = fbCombineDisjointOutPart (sa, da);
+ break;
+ case CombineAIn:
+ Fa = fbCombineDisjointInPart (sa, da);
+ break;
+ case CombineA:
+ Fa = 0xff;
+ break;
+ }
+
+ switch (combine & CombineB) {
+ default:
+ Fb = 0;
+ break;
+ case CombineBOut:
+ Fb = fbCombineDisjointOutPart (da, sa);
+ break;
+ case CombineBIn:
+ Fb = fbCombineDisjointInPart (da, sa);
+ break;
+ case CombineB:
+ Fb = 0xff;
+ break;
+ }
+ m = FbGen (s,d,0,Fa,Fb,t, u, v);
+ n = FbGen (s,d,8,Fa,Fb,t, u, v);
+ o = FbGen (s,d,16,Fa,Fb,t, u, v);
+ p = FbGen (s,d,24,Fa,Fb,t, u, v);
+ s = m|n|o|p;
+ dest[i] = s;
+ }
+}
+
+static FASTCALL void
+fbCombineDisjointOverU (CARD32 *dest, const CARD32 *src, int width)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 s = src[i];
+ CARD16 a = s >> 24;
+
+ if (a != 0x00)
+ {
+ if (a != 0xff)
+ {
+ CARD32 d = dest[i];
+ a = fbCombineDisjointOutPart (d >> 24, a);
+ FbByteMulAdd(d, a, s);
+ s = d;
+ }
+ dest[i] = s;
+ }
+ }
+}
+
+static FASTCALL void
+fbCombineDisjointInU (CARD32 *dest, const CARD32 *src, int width)
+{
+ fbCombineDisjointGeneralU (dest, src, width, CombineAIn);
+}
+
+static FASTCALL void
+fbCombineDisjointInReverseU (CARD32 *dest, const CARD32 *src, int width)
+{
+ fbCombineDisjointGeneralU (dest, src, width, CombineBIn);
+}
+
+static FASTCALL void
+fbCombineDisjointOutU (CARD32 *dest, const CARD32 *src, int width)
+{
+ fbCombineDisjointGeneralU (dest, src, width, CombineAOut);
+}
+
+static FASTCALL void
+fbCombineDisjointOutReverseU (CARD32 *dest, const CARD32 *src, int width)
+{
+ fbCombineDisjointGeneralU (dest, src, width, CombineBOut);
+}
+
+static FASTCALL void
+fbCombineDisjointAtopU (CARD32 *dest, const CARD32 *src, int width)
+{
+ fbCombineDisjointGeneralU (dest, src, width, CombineAAtop);
+}
+
+static FASTCALL void
+fbCombineDisjointAtopReverseU (CARD32 *dest, const CARD32 *src, int width)
+{
+ fbCombineDisjointGeneralU (dest, src, width, CombineBAtop);
+}
+
+static FASTCALL void
+fbCombineDisjointXorU (CARD32 *dest, const CARD32 *src, int width)
+{
+ fbCombineDisjointGeneralU (dest, src, width, CombineXor);
+}
+
+/* portion covered by a but not b */
+static INLINE CARD8
+fbCombineConjointOutPart (CARD8 a, CARD8 b)
+{
+ /* max (1-b/a,0) */
+ /* = 1-min(b/a,1) */
+
+ /* min (1, (1-b) / a) */
+
+ if (b >= a) /* b >= a -> b/a >= 1 */
+ return 0x00; /* 0 */
+ return ~FbIntDiv(b,a); /* 1 - b/a */
+}
+
+/* portion covered by both a and b */
+static INLINE CARD8
+fbCombineConjointInPart (CARD8 a, CARD8 b)
+{
+ /* min (1,b/a) */
+
+ if (b >= a) /* b >= a -> b/a >= 1 */
+ return 0xff; /* 1 */
+ return FbIntDiv(b,a); /* b/a */
+}
+
+static FASTCALL void
+fbCombineConjointGeneralU (CARD32 *dest, const CARD32 *src, int width, CARD8 combine)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 s = src[i];
+ CARD32 d = dest[i];
+ CARD32 m,n,o,p;
+ CARD16 Fa, Fb, t, u, v;
+ CARD8 sa = s >> 24;
+ CARD8 da = d >> 24;
+
+ switch (combine & CombineA) {
+ default:
+ Fa = 0;
+ break;
+ case CombineAOut:
+ Fa = fbCombineConjointOutPart (sa, da);
+ break;
+ case CombineAIn:
+ Fa = fbCombineConjointInPart (sa, da);
+ break;
+ case CombineA:
+ Fa = 0xff;
+ break;
+ }
+
+ switch (combine & CombineB) {
+ default:
+ Fb = 0;
+ break;
+ case CombineBOut:
+ Fb = fbCombineConjointOutPart (da, sa);
+ break;
+ case CombineBIn:
+ Fb = fbCombineConjointInPart (da, sa);
+ break;
+ case CombineB:
+ Fb = 0xff;
+ break;
+ }
+ m = FbGen (s,d,0,Fa,Fb,t, u, v);
+ n = FbGen (s,d,8,Fa,Fb,t, u, v);
+ o = FbGen (s,d,16,Fa,Fb,t, u, v);
+ p = FbGen (s,d,24,Fa,Fb,t, u, v);
+ s = m|n|o|p;
+ dest[i] = s;
+ }
+}
+
+static FASTCALL void
+fbCombineConjointOverU (CARD32 *dest, const CARD32 *src, int width)
+{
+ fbCombineConjointGeneralU (dest, src, width, CombineAOver);
+}
+
+
+static FASTCALL void
+fbCombineConjointOverReverseU (CARD32 *dest, const CARD32 *src, int width)
+{
+ fbCombineConjointGeneralU (dest, src, width, CombineBOver);
+}
+
+
+static FASTCALL void
+fbCombineConjointInU (CARD32 *dest, const CARD32 *src, int width)
+{
+ fbCombineConjointGeneralU (dest, src, width, CombineAIn);
+}
+
+
+static FASTCALL void
+fbCombineConjointInReverseU (CARD32 *dest, const CARD32 *src, int width)
+{
+ fbCombineConjointGeneralU (dest, src, width, CombineBIn);
+}
+
+static FASTCALL void
+fbCombineConjointOutU (CARD32 *dest, const CARD32 *src, int width)
+{
+ fbCombineConjointGeneralU (dest, src, width, CombineAOut);
+}
+
+static FASTCALL void
+fbCombineConjointOutReverseU (CARD32 *dest, const CARD32 *src, int width)
+{
+ fbCombineConjointGeneralU (dest, src, width, CombineBOut);
+}
+
+static FASTCALL void
+fbCombineConjointAtopU (CARD32 *dest, const CARD32 *src, int width)
+{
+ fbCombineConjointGeneralU (dest, src, width, CombineAAtop);
+}
+
+static FASTCALL void
+fbCombineConjointAtopReverseU (CARD32 *dest, const CARD32 *src, int width)
+{
+ fbCombineConjointGeneralU (dest, src, width, CombineBAtop);
+}
+
+static FASTCALL void
+fbCombineConjointXorU (CARD32 *dest, const CARD32 *src, int width)
+{
+ fbCombineConjointGeneralU (dest, src, width, CombineXor);
+}
+
+static CombineFuncU fbCombineFuncU[] = {
+ fbCombineClear,
+ fbCombineSrcU,
+ NULL, /* CombineDst */
+ fbCombineOverU,
+ fbCombineOverReverseU,
+ fbCombineInU,
+ fbCombineInReverseU,
+ fbCombineOutU,
+ fbCombineOutReverseU,
+ fbCombineAtopU,
+ fbCombineAtopReverseU,
+ fbCombineXorU,
+ fbCombineAddU,
+ fbCombineSaturateU,
+ NULL,
+ NULL,
+ fbCombineClear,
+ fbCombineSrcU,
+ NULL, /* CombineDst */
+ fbCombineDisjointOverU,
+ fbCombineSaturateU, /* DisjointOverReverse */
+ fbCombineDisjointInU,
+ fbCombineDisjointInReverseU,
+ fbCombineDisjointOutU,
+ fbCombineDisjointOutReverseU,
+ fbCombineDisjointAtopU,
+ fbCombineDisjointAtopReverseU,
+ fbCombineDisjointXorU,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ fbCombineClear,
+ fbCombineSrcU,
+ NULL, /* CombineDst */
+ fbCombineConjointOverU,
+ fbCombineConjointOverReverseU,
+ fbCombineConjointInU,
+ fbCombineConjointInReverseU,
+ fbCombineConjointOutU,
+ fbCombineConjointOutReverseU,
+ fbCombineConjointAtopU,
+ fbCombineConjointAtopReverseU,
+ fbCombineConjointXorU,
+};
+
+static FASTCALL void
+fbCombineMaskC (CARD32 *src, CARD32 *mask, int width)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 a = mask[i];
+
+ CARD32 x;
+ CARD16 xa;
+
+ if (!a)
+ {
+ src[i] = 0;
+ continue;
+ }
+
+ x = src[i];
+ if (a == 0xffffffff)
+ {
+ x = x >> 24;
+ x |= x << 8;
+ x |= x << 16;
+ mask[i] = x;
+ continue;
+ }
+
+ xa = x >> 24;
+ FbByteMulC(x, a);
+ src[i] = x;
+ FbByteMul(a, xa);
+ mask[i] = a;
+ }
+}
+
+static FASTCALL void
+fbCombineMaskValueC (CARD32 *src, const CARD32 *mask, int width)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 a = mask[i];
+ CARD32 x;
+
+ if (!a)
+ {
+ src[i] = 0;
+ continue;
+ }
+
+ if (a == 0xffffffff)
+ continue;
+
+ x = src[i];
+ FbByteMulC(x, a);
+ src[i] = x;
+ }
+}
+
+
+static FASTCALL void
+fbCombineMaskAlphaC (const CARD32 *src, CARD32 *mask, int width)
+{
+ int i;
+ for (i = 0; i < width; ++i) {
+ CARD32 a = mask[i];
+ CARD32 x;
+
+ if (!a)
+ continue;
+
+ x = src[i] >> 24;
+ if (x == 0xff)
+ continue;
+ if (a == 0xffffffff)
+ {
+ x = x >> 24;
+ x |= x << 8;
+ x |= x << 16;
+ mask[i] = x;
+ continue;
+ }
+
+ FbByteMul(a, x);
+ mask[i] = a;
+ }
+}
+
+static FASTCALL void
+fbCombineClearC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ memset(dest, 0, width*sizeof(CARD32));
+}
+
+static FASTCALL void
+fbCombineSrcC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineMaskValueC(src, mask, width);
+ memcpy(dest, src, width*sizeof(CARD32));
+}
+
+static FASTCALL void
+fbCombineOverC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ int i;
+ fbCombineMaskC(src, mask, width);
+ for (i = 0; i < width; ++i) {
+ CARD32 s = src[i];
+ CARD32 a = ~mask[i];
+
+ if (a != 0xffffffff)
+ {
+ if (a)
+ {
+ CARD32 d = dest[i];
+ FbByteMulAddC(d, a, s);
+ s = d;
+ }
+ dest[i] = s;
+ }
+ }
+}
+
+static FASTCALL void
+fbCombineOverReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ int i;
+ fbCombineMaskValueC(src, mask, width);
+ for (i = 0; i < width; ++i) {
+ CARD32 d = dest[i];
+ CARD32 a = ~d >> 24;
+
+ if (a)
+ {
+ CARD32 s = src[i];
+ if (a != 0xff)
+ {
+ FbByteMulAdd(s, a, d);
+ }
+ dest[i] = s;
+ }
+ }
+}
+
+static FASTCALL void
+fbCombineInC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ int i;
+ fbCombineMaskValueC(src, mask, width);
+ for (i = 0; i < width; ++i) {
+ CARD32 d = dest[i];
+ CARD16 a = d >> 24;
+ CARD32 s = 0;
+ if (a)
+ {
+ s = src[i];
+ if (a != 0xff)
+ {
+ FbByteMul(s, a);
+ }
+ }
+ dest[i] = s;
+ }
+}
+
+static FASTCALL void
+fbCombineInReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ int i;
+ fbCombineMaskAlphaC(src, mask, width);
+ for (i = 0; i < width; ++i) {
+ CARD32 a = mask[i];
+
+ if (a != 0xffffffff)
+ {
+ CARD32 d = 0;
+ if (a)
+ {
+ d = dest[i];
+ FbByteMulC(d, a);
+ }
+ dest[i] = d;
+ }
+ }
+}
+
+static FASTCALL void
+fbCombineOutC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ int i;
+ fbCombineMaskValueC(src, mask, width);
+ for (i = 0; i < width; ++i) {
+ CARD32 d = dest[i];
+ CARD16 a = ~d >> 24;
+ CARD32 s = 0;
+ if (a)
+ {
+ s = src[i];
+ if (a != 0xff)
+ {
+ FbByteMul(s, a);
+ }
+ }
+ dest[i] = s;
+ }
+}
+
+static FASTCALL void
+fbCombineOutReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ int i;
+ fbCombineMaskAlphaC(src, mask, width);
+ for (i = 0; i < width; ++i) {
+ CARD32 a = ~mask[i];
+
+ if (a != 0xffffffff)
+ {
+ CARD32 d = 0;
+ if (a)
+ {
+ d = dest[i];
+ FbByteMulC(d, a);
+ }
+ dest[i] = d;
+ }
+ }
+}
+
+static FASTCALL void
+fbCombineAtopC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ int i;
+ fbCombineMaskC(src, mask, width);
+ for (i = 0; i < width; ++i) {
+ CARD32 d = dest[i];
+ CARD32 s = src[i];
+ CARD32 ad = ~mask[i];
+ CARD16 as = d >> 24;
+ FbByteAddMulC(d, ad, s, as);
+ dest[i] = d;
+ }
+}
+
+static FASTCALL void
+fbCombineAtopReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ int i;
+ fbCombineMaskC(src, mask, width);
+ for (i = 0; i < width; ++i) {
+
+ CARD32 d = dest[i];
+ CARD32 s = src[i];
+ CARD32 ad = mask[i];
+ CARD16 as = ~d >> 24;
+ FbByteAddMulC(d, ad, s, as);
+ dest[i] = d;
+ }
+}
+
+static FASTCALL void
+fbCombineXorC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ int i;
+ fbCombineMaskC(src, mask, width);
+ for (i = 0; i < width; ++i) {
+ CARD32 d = dest[i];
+ CARD32 s = src[i];
+ CARD32 ad = ~mask[i];
+ CARD16 as = ~d >> 24;
+ FbByteAddMulC(d, ad, s, as);
+ dest[i] = d;
+ }
+}
+
+static FASTCALL void
+fbCombineAddC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ int i;
+ fbCombineMaskValueC(src, mask, width);
+ for (i = 0; i < width; ++i) {
+ CARD32 s = src[i];
+ CARD32 d = dest[i];
+ FbByteAdd(d, s);
+ dest[i] = d;
+ }
+}
+
+static FASTCALL void
+fbCombineSaturateC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ int i;
+ fbCombineMaskC(src, mask, width);
+ for (i = 0; i < width; ++i) {
+ CARD32 s, d;
+ CARD16 sa, sr, sg, sb, da;
+ CARD16 t, u, v;
+ CARD32 m,n,o,p;
+
+ d = dest[i];
+ s = src[i];
+ sa = (mask[i] >> 24);
+ sr = (mask[i] >> 16) & 0xff;
+ sg = (mask[i] >> 8) & 0xff;
+ sb = (mask[i] ) & 0xff;
+ da = ~d >> 24;
+
+ if (sb <= da)
+ m = FbAdd(s,d,0,t);
+ else
+ m = FbGen (s, d, 0, (da << 8) / sb, 0xff, t, u, v);
+
+ if (sg <= da)
+ n = FbAdd(s,d,8,t);
+ else
+ n = FbGen (s, d, 8, (da << 8) / sg, 0xff, t, u, v);
+
+ if (sr <= da)
+ o = FbAdd(s,d,16,t);
+ else
+ o = FbGen (s, d, 16, (da << 8) / sr, 0xff, t, u, v);
+
+ if (sa <= da)
+ p = FbAdd(s,d,24,t);
+ else
+ p = FbGen (s, d, 24, (da << 8) / sa, 0xff, t, u, v);
+
+ dest[i] = m|n|o|p;
+ }
+}
+
+static FASTCALL void
+fbCombineDisjointGeneralC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width, CARD8 combine)
+{
+ int i;
+ fbCombineMaskC(src, mask, width);
+ for (i = 0; i < width; ++i) {
+ CARD32 s, d;
+ CARD32 m,n,o,p;
+ CARD32 Fa, Fb;
+ CARD16 t, u, v;
+ CARD32 sa;
+ CARD8 da;
+
+ s = src[i];
+ sa = mask[i];
+ d = dest[i];
+ da = d >> 24;
+
+ switch (combine & CombineA) {
+ default:
+ Fa = 0;
+ break;
+ case CombineAOut:
+ m = fbCombineDisjointOutPart ((CARD8) (sa >> 0), da);
+ n = fbCombineDisjointOutPart ((CARD8) (sa >> 8), da) << 8;
+ o = fbCombineDisjointOutPart ((CARD8) (sa >> 16), da) << 16;
+ p = fbCombineDisjointOutPart ((CARD8) (sa >> 24), da) << 24;
+ Fa = m|n|o|p;
+ break;
+ case CombineAIn:
+ m = fbCombineDisjointInPart ((CARD8) (sa >> 0), da);
+ n = fbCombineDisjointInPart ((CARD8) (sa >> 8), da) << 8;
+ o = fbCombineDisjointInPart ((CARD8) (sa >> 16), da) << 16;
+ p = fbCombineDisjointInPart ((CARD8) (sa >> 24), da) << 24;
+ Fa = m|n|o|p;
+ break;
+ case CombineA:
+ Fa = 0xffffffff;
+ break;
+ }
+
+ switch (combine & CombineB) {
+ default:
+ Fb = 0;
+ break;
+ case CombineBOut:
+ m = fbCombineDisjointOutPart (da, (CARD8) (sa >> 0));
+ n = fbCombineDisjointOutPart (da, (CARD8) (sa >> 8)) << 8;
+ o = fbCombineDisjointOutPart (da, (CARD8) (sa >> 16)) << 16;
+ p = fbCombineDisjointOutPart (da, (CARD8) (sa >> 24)) << 24;
+ Fb = m|n|o|p;
+ break;
+ case CombineBIn:
+ m = fbCombineDisjointInPart (da, (CARD8) (sa >> 0));
+ n = fbCombineDisjointInPart (da, (CARD8) (sa >> 8)) << 8;
+ o = fbCombineDisjointInPart (da, (CARD8) (sa >> 16)) << 16;
+ p = fbCombineDisjointInPart (da, (CARD8) (sa >> 24)) << 24;
+ Fb = m|n|o|p;
+ break;
+ case CombineB:
+ Fb = 0xffffffff;
+ break;
+ }
+ m = FbGen (s,d,0,FbGet8(Fa,0),FbGet8(Fb,0),t, u, v);
+ n = FbGen (s,d,8,FbGet8(Fa,8),FbGet8(Fb,8),t, u, v);
+ o = FbGen (s,d,16,FbGet8(Fa,16),FbGet8(Fb,16),t, u, v);
+ p = FbGen (s,d,24,FbGet8(Fa,24),FbGet8(Fb,24),t, u, v);
+ s = m|n|o|p;
+ dest[i] = s;
+ }
+}
+
+static FASTCALL void
+fbCombineDisjointOverC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineDisjointGeneralC (dest, src, mask, width, CombineAOver);
+}
+
+static FASTCALL void
+fbCombineDisjointInC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineDisjointGeneralC (dest, src, mask, width, CombineAIn);
+}
+
+static FASTCALL void
+fbCombineDisjointInReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineDisjointGeneralC (dest, src, mask, width, CombineBIn);
+}
+
+static FASTCALL void
+fbCombineDisjointOutC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineDisjointGeneralC (dest, src, mask, width, CombineAOut);
+}
+
+static FASTCALL void
+fbCombineDisjointOutReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineDisjointGeneralC (dest, src, mask, width, CombineBOut);
+}
+
+static FASTCALL void
+fbCombineDisjointAtopC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineDisjointGeneralC (dest, src, mask, width, CombineAAtop);
+}
+
+static FASTCALL void
+fbCombineDisjointAtopReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineDisjointGeneralC (dest, src, mask, width, CombineBAtop);
+}
+
+static FASTCALL void
+fbCombineDisjointXorC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineDisjointGeneralC (dest, src, mask, width, CombineXor);
+}
+
+static FASTCALL void
+fbCombineConjointGeneralC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width, CARD8 combine)
+{
+ int i;
+ fbCombineMaskC(src, mask, width);
+ for (i = 0; i < width; ++i) {
+ CARD32 s, d;
+ CARD32 m,n,o,p;
+ CARD32 Fa, Fb;
+ CARD16 t, u, v;
+ CARD32 sa;
+ CARD8 da;
+
+ s = src[i];
+ sa = mask[i];
+ d = dest[i];
+ da = d >> 24;
+
+ switch (combine & CombineA) {
+ default:
+ Fa = 0;
+ break;
+ case CombineAOut:
+ m = fbCombineConjointOutPart ((CARD8) (sa >> 0), da);
+ n = fbCombineConjointOutPart ((CARD8) (sa >> 8), da) << 8;
+ o = fbCombineConjointOutPart ((CARD8) (sa >> 16), da) << 16;
+ p = fbCombineConjointOutPart ((CARD8) (sa >> 24), da) << 24;
+ Fa = m|n|o|p;
+ break;
+ case CombineAIn:
+ m = fbCombineConjointInPart ((CARD8) (sa >> 0), da);
+ n = fbCombineConjointInPart ((CARD8) (sa >> 8), da) << 8;
+ o = fbCombineConjointInPart ((CARD8) (sa >> 16), da) << 16;
+ p = fbCombineConjointInPart ((CARD8) (sa >> 24), da) << 24;
+ Fa = m|n|o|p;
+ break;
+ case CombineA:
+ Fa = 0xffffffff;
+ break;
+ }
+
+ switch (combine & CombineB) {
+ default:
+ Fb = 0;
+ break;
+ case CombineBOut:
+ m = fbCombineConjointOutPart (da, (CARD8) (sa >> 0));
+ n = fbCombineConjointOutPart (da, (CARD8) (sa >> 8)) << 8;
+ o = fbCombineConjointOutPart (da, (CARD8) (sa >> 16)) << 16;
+ p = fbCombineConjointOutPart (da, (CARD8) (sa >> 24)) << 24;
+ Fb = m|n|o|p;
+ break;
+ case CombineBIn:
+ m = fbCombineConjointInPart (da, (CARD8) (sa >> 0));
+ n = fbCombineConjointInPart (da, (CARD8) (sa >> 8)) << 8;
+ o = fbCombineConjointInPart (da, (CARD8) (sa >> 16)) << 16;
+ p = fbCombineConjointInPart (da, (CARD8) (sa >> 24)) << 24;
+ Fb = m|n|o|p;
+ break;
+ case CombineB:
+ Fb = 0xffffffff;
+ break;
+ }
+ m = FbGen (s,d,0,FbGet8(Fa,0),FbGet8(Fb,0),t, u, v);
+ n = FbGen (s,d,8,FbGet8(Fa,8),FbGet8(Fb,8),t, u, v);
+ o = FbGen (s,d,16,FbGet8(Fa,16),FbGet8(Fb,16),t, u, v);
+ p = FbGen (s,d,24,FbGet8(Fa,24),FbGet8(Fb,24),t, u, v);
+ s = m|n|o|p;
+ dest[i] = s;
+ }
+}
+
+static FASTCALL void
+fbCombineConjointOverC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineConjointGeneralC (dest, src, mask, width, CombineAOver);
+}
+
+static FASTCALL void
+fbCombineConjointOverReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineConjointGeneralC (dest, src, mask, width, CombineBOver);
+}
+
+static FASTCALL void
+fbCombineConjointInC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineConjointGeneralC (dest, src, mask, width, CombineAIn);
+}
+
+static FASTCALL void
+fbCombineConjointInReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineConjointGeneralC (dest, src, mask, width, CombineBIn);
+}
+
+static FASTCALL void
+fbCombineConjointOutC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineConjointGeneralC (dest, src, mask, width, CombineAOut);
+}
+
+static FASTCALL void
+fbCombineConjointOutReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineConjointGeneralC (dest, src, mask, width, CombineBOut);
+}
+
+static FASTCALL void
+fbCombineConjointAtopC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineConjointGeneralC (dest, src, mask, width, CombineAAtop);
+}
+
+static FASTCALL void
+fbCombineConjointAtopReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineConjointGeneralC (dest, src, mask, width, CombineBAtop);
+}
+
+static FASTCALL void
+fbCombineConjointXorC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ fbCombineConjointGeneralC (dest, src, mask, width, CombineXor);
+}
+
+static CombineFuncC fbCombineFuncC[] = {
+ fbCombineClearC,
+ fbCombineSrcC,
+ NULL, /* Dest */
+ fbCombineOverC,
+ fbCombineOverReverseC,
+ fbCombineInC,
+ fbCombineInReverseC,
+ fbCombineOutC,
+ fbCombineOutReverseC,
+ fbCombineAtopC,
+ fbCombineAtopReverseC,
+ fbCombineXorC,
+ fbCombineAddC,
+ fbCombineSaturateC,
+ NULL,
+ NULL,
+ fbCombineClearC, /* 0x10 */
+ fbCombineSrcC,
+ NULL, /* Dest */
+ fbCombineDisjointOverC,
+ fbCombineSaturateC, /* DisjointOverReverse */
+ fbCombineDisjointInC,
+ fbCombineDisjointInReverseC,
+ fbCombineDisjointOutC,
+ fbCombineDisjointOutReverseC,
+ fbCombineDisjointAtopC,
+ fbCombineDisjointAtopReverseC,
+ fbCombineDisjointXorC, /* 0x1b */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ fbCombineClearC,
+ fbCombineSrcC,
+ NULL, /* Dest */
+ fbCombineConjointOverC,
+ fbCombineConjointOverReverseC,
+ fbCombineConjointInC,
+ fbCombineConjointInReverseC,
+ fbCombineConjointOutC,
+ fbCombineConjointOutReverseC,
+ fbCombineConjointAtopC,
+ fbCombineConjointAtopReverseC,
+ fbCombineConjointXorC,
+};
+
+
+FbComposeFunctions composeFunctions = {
+ fbCombineFuncU,
+ fbCombineFuncC,
+ fbCombineMaskU
+};
+
+
+static void fbFetchSolid(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
+{
+ FbBits *bits;
+ FbStride stride;
+ int bpp;
+ int xoff, yoff;
+ CARD32 color;
+ CARD32 *end;
+ fetchPixelProc fetch = fetchPixelProcForPicture(pict);
+ miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
+
+ fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
+ bits += yoff*stride + (xoff*bpp >> FB_SHIFT);
+
+ color = fetch(bits, 0, indexed);
+
+ end = buffer + width;
+ while (buffer < end)
+ *buffer++ = color;
+}
+
+static void fbFetch(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
+{
+ FbBits *bits;
+ FbStride stride;
+ int bpp;
+ int xoff, yoff;
+ fetchProc fetch = fetchProcForPicture(pict);
+ miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
+
+ fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
+ x += xoff;
+ y += yoff;
+
+ bits += y*stride;
+
+ fetch(bits, x, width, buffer, indexed);
+}
+
+#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
+#define DIV(a,b) ((((a) < 0) == ((b) < 0)) ? (a) / (b) :\
+ ((a) - (b) + 1 - (((b) < 0) << 1)) / (b))
+
+
+static CARD32 gradientPixel(const SourcePictPtr pGradient, xFixed_48_16 pos, unsigned int spread)
+{
+ int ipos = (pos * PICT_GRADIENT_STOPTABLE_SIZE - 1) >> 16;
+
+ /* calculate the actual offset. */
+ if (ipos < 0 || ipos >= PICT_GRADIENT_STOPTABLE_SIZE) {
+ if (pGradient->type == SourcePictTypeConical || spread == RepeatNormal) {
+ ipos = ipos % PICT_GRADIENT_STOPTABLE_SIZE;
+ ipos = ipos < 0 ? PICT_GRADIENT_STOPTABLE_SIZE + ipos : ipos;
+
+ } else if (spread == RepeatReflect) {
+ const int limit = PICT_GRADIENT_STOPTABLE_SIZE * 2 - 1;
+ ipos = ipos % limit;
+ ipos = ipos < 0 ? limit + ipos : ipos;
+ ipos = ipos >= PICT_GRADIENT_STOPTABLE_SIZE ? limit - ipos : ipos;
+
+ } else if (spread == RepeatPad) {
+ if (ipos < 0)
+ ipos = 0;
+ else if (ipos >= PICT_GRADIENT_STOPTABLE_SIZE)
+ ipos = PICT_GRADIENT_STOPTABLE_SIZE-1;
+ } else { /* RepeatNone */
+ return 0;
+ }
+ }
+
+ assert(ipos >= 0);
+ assert(ipos < PICT_GRADIENT_STOPTABLE_SIZE);
+
+ return pGradient->linear.colorTable[ipos];
+}
+
+static void fbFetchSourcePict(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
+{
+ SourcePictPtr pGradient = pict->pSourcePict;
+ CARD32 *end = buffer + width;
+
+ if (pGradient->type == SourcePictTypeSolidFill) {
+ register CARD32 color = pGradient->solidFill.color;
+ while (buffer < end) {
+ *buffer++ = color;
+ }
+ } else if (pGradient->type == SourcePictTypeLinear) {
+ PictVector v, unit;
+ xFixed_32_32 l;
+ xFixed_48_16 dx, dy, a, b, off;
+
+ v.vector[0] = IntToxFixed(x);
+ v.vector[1] = IntToxFixed(y);
+ v.vector[2] = xFixed1;
+ if (pict->transform) {
+ if (!PictureTransformPoint3d (pict->transform, &v))
+ return;
+ unit.vector[0] = pict->transform->matrix[0][0];
+ unit.vector[1] = pict->transform->matrix[1][0];
+ unit.vector[2] = pict->transform->matrix[2][0];
+ } else {
+ unit.vector[0] = xFixed1;
+ unit.vector[1] = 0;
+ unit.vector[2] = 0;
+ }
+
+ dx = pGradient->linear.p2.x - pGradient->linear.p1.x;
+ dy = pGradient->linear.p2.y - pGradient->linear.p1.y;
+ l = dx*dx + dy*dy;
+ if (l != 0) {
+ a = (dx << 32) / l;
+ b = (dy << 32) / l;
+ off = (-a*pGradient->linear.p1.x - b*pGradient->linear.p1.y)>>16;
+ }
+ if (l == 0 || (unit.vector[2] == 0 && v.vector[2] == xFixed1)) {
+ xFixed_48_16 inc, t;
+ /* affine transformation only */
+ if (l == 0) {
+ t = 0;
+ inc = 0;
+ } else {
+ t = ((a*v.vector[0] + b*v.vector[1]) >> 16) + off;
+ inc = (a * unit.vector[0] + b * unit.vector[1]) >> 16;
+ }
+ while (buffer < end) {
+ *buffer++ = gradientPixel(pGradient, t, pict->repeatType);
+ t += inc;
+ }
+ } else {
+ /* projective transformation */
+ while (buffer < end) {
+ xFixed_48_16 t;
+ if (v.vector[2] == 0) {
+ t = 0;
+ } else {
+ xFixed_48_16 x, y;
+ x = ((xFixed_48_16)v.vector[0] << 16) / v.vector[2];
+ y = ((xFixed_48_16)v.vector[1] << 16) / v.vector[2];
+ t = ((a*x + b*y) >> 16) + off;
+ }
+ *buffer++ = gradientPixel(pGradient, t, pict->repeatType);
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ }
+ } else {
+ /* radial or conical */
+ Bool affine = TRUE;
+ double cx = 1.;
+ double cy = 0.;
+ double cz = 0.;
+ double rx = x;
+ double ry = y;
+ double rz = 1.;
+
+ if (pict->transform) {
+ PictVector v;
+ v.vector[0] = IntToxFixed(x);
+ v.vector[1] = IntToxFixed(y);
+ v.vector[2] = xFixed1;
+ if (!PictureTransformPoint3d (pict->transform, &v))
+ return;
+
+ cx = pict->transform->matrix[0][0]/65536.;
+ cy = pict->transform->matrix[1][0]/65536.;
+ cz = pict->transform->matrix[2][0]/65536.;
+ rx = v.vector[0]/65536.;
+ ry = v.vector[1]/65536.;
+ rz = v.vector[2]/65536.;
+ affine = pict->transform->matrix[2][0] == 0 && v.vector[2] == xFixed1;
+ }
+
+ if (pGradient->type == SourcePictTypeRadial) {
+ if (affine) {
+ rx -= pGradient->radial.fx;
+ ry -= pGradient->radial.fy;
+
+ while (buffer < end) {
+ double b = 2*(rx*pGradient->radial.dx + ry*pGradient->radial.dy);
+ double c = -(rx*rx + ry*ry);
+ double det = (b * b) - (4 * pGradient->radial.a * c);
+ double s = (-b + sqrt(det))/(2. * pGradient->radial.a);
+ *buffer = gradientPixel(pGradient,
+ (xFixed_48_16)((s*pGradient->radial.m + pGradient->radial.b)*65536),
+ pict->repeatType);
+ ++buffer;
+ rx += cx;
+ ry += cy;
+ }
+ } else {
+ while (buffer < end) {
+ double x, y;
+ double b, c, det, s;
+ if (rz != 0) {
+ x = rx/rz;
+ y = ry/rz;
+ } else {
+ x = y = 0.;
+ }
+ x -= pGradient->radial.fx;
+ y -= pGradient->radial.fy;
+ b = 2*(x*pGradient->radial.dx + y*pGradient->radial.dy);
+ c = -(x*x + y*y);
+ det = (b * b) - (4 * pGradient->radial.a * c);
+ s = (-b + sqrt(det))/(2. * pGradient->radial.a);
+ *buffer = gradientPixel(pGradient,
+ (xFixed_48_16)((s*pGradient->radial.m + pGradient->radial.b)*65536),
+ pict->repeatType);
+ ++buffer;
+ rx += cx;
+ ry += cy;
+ rz += cz;
+ }
+ }
+ } else /* SourcePictTypeConical */ {
+ double a = pGradient->conical.angle/(180.*65536);
+ if (affine) {
+ rx -= pGradient->conical.center.x/65536.;
+ ry -= pGradient->conical.center.y/65536.;
+
+ while (buffer < end) {
+ double angle = atan2(ry, rx) + a;
+ *buffer = gradientPixel(pGradient, (xFixed_48_16) (angle * (65536. / (2*M_PI))),
+ pict->repeatType);
+ ++buffer;
+ rx += cx;
+ ry += cy;
+ }
+ } else {
+
+ while (buffer < end) {
+ double x, y, angle;
+ if (rz != 0) {
+ x = rx/rz;
+ y = ry/rz;
+ } else {
+ x = y = 0.;
+ }
+ x -= pGradient->conical.center.x/65536.;
+ y -= pGradient->conical.center.y/65536.;
+ angle = atan2(y, x) + a;
+ *buffer = gradientPixel(pGradient, (xFixed_48_16) (angle * (65536. / (2*M_PI))),
+ pict->repeatType);
+ ++buffer;
+ rx += cx;
+ ry += cy;
+ rz += cz;
+ }
+ }
+ }
+ }
+}
+
+
+
+static void fbFetchTransformed(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
+{
+ FbBits *bits;
+ FbStride stride;
+ int bpp;
+ int xoff, yoff;
+ fetchPixelProc fetch;
+ PictVector v;
+ PictVector unit;
+ int i;
+ BoxRec box;
+ miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
+ Bool affine = TRUE;
+
+ fetch = fetchPixelProcForPicture(pict);
+
+ fbGetDrawable(pict->pDrawable, bits, stride, bpp, xoff, yoff);
+ x += xoff;
+ y += yoff;
+
+ v.vector[0] = IntToxFixed(x);
+ v.vector[1] = IntToxFixed(y);
+ v.vector[2] = xFixed1;
+
+ /* when using convolution filters one might get here without a transform */
+ if (pict->transform) {
+ if (!PictureTransformPoint3d (pict->transform, &v))
+ return;
+ unit.vector[0] = pict->transform->matrix[0][0];
+ unit.vector[1] = pict->transform->matrix[1][0];
+ unit.vector[2] = pict->transform->matrix[2][0];
+ affine = v.vector[2] == xFixed1 && unit.vector[2] == 0;
+ } else {
+ unit.vector[0] = xFixed1;
+ unit.vector[1] = 0;
+ unit.vector[2] = 0;
+ }
+
+ if (pict->filter == PictFilterNearest)
+ {
+ if (pict->repeatType == RepeatNormal) {
+ if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
+ box = pict->pCompositeClip->extents;
+ for (i = 0; i < width; ++i) {
+ if (!v.vector[2]) {
+ buffer[i] = 0;
+ } else {
+ if (!affine) {
+ y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height);
+ x = MOD(DIV(v.vector[0],v.vector[2]), pict->pDrawable->width);
+ } else {
+ y = MOD(v.vector[1]>>16, pict->pDrawable->height);
+ x = MOD(v.vector[0]>>16, pict->pDrawable->width);
+ }
+ buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed);
+ }
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ } else {
+ for (i = 0; i < width; ++i) {
+ if (!v.vector[2]) {
+ buffer[i] = 0;
+ } else {
+ if (!affine) {
+ y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height);
+ x = MOD(DIV(v.vector[0],v.vector[2]), pict->pDrawable->width);
+ } else {
+ y = MOD(v.vector[1]>>16, pict->pDrawable->height);
+ x = MOD(v.vector[0]>>16, pict->pDrawable->width);
+ }
+ if (POINT_IN_REGION (0, pict->pCompositeClip, x, y, &box))
+ buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed);
+ else
+ buffer[i] = 0;
+ }
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ }
+ } else {
+ if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
+ box = pict->pCompositeClip->extents;
+ for (i = 0; i < width; ++i) {
+ if (!v.vector[2]) {
+ buffer[i] = 0;
+ } else {
+ if (!affine) {
+ y = DIV(v.vector[1],v.vector[2]);
+ x = DIV(v.vector[0],v.vector[2]);
+ } else {
+ y = v.vector[1]>>16;
+ x = v.vector[0]>>16;
+ }
+ buffer[i] = ((x < box.x1) | (x >= box.x2) | (y < box.y1) | (y >= box.y2)) ?
+ 0 : fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed);
+ }
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ } else {
+ for (i = 0; i < width; ++i) {
+ if (!v.vector[2]) {
+ buffer[i] = 0;
+ } else {
+ if (!affine) {
+ y = DIV(v.vector[1],v.vector[2]);
+ x = DIV(v.vector[0],v.vector[2]);
+ } else {
+ y = v.vector[1]>>16;
+ x = v.vector[0]>>16;
+ }
+ if (POINT_IN_REGION (0, pict->pCompositeClip, x, y, &box))
+ buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed);
+ else
+ buffer[i] = 0;
+ }
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ }
+ }
+ } else if (pict->filter == PictFilterBilinear) {
+ if (pict->repeatType == RepeatNormal) {
+ if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
+ box = pict->pCompositeClip->extents;
+ for (i = 0; i < width; ++i) {
+ if (!v.vector[2]) {
+ buffer[i] = 0;
+ } else {
+ int x1, x2, y1, y2, distx, idistx, disty, idisty;
+ FbBits *b;
+ CARD32 tl, tr, bl, br, r;
+ CARD32 ft, fb;
+
+ if (!affine) {
+ xFixed_48_16 div;
+ div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
+ x1 = div >> 16;
+ distx = ((xFixed)div >> 8) & 0xff;
+ div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
+ y1 = div >> 16;
+ disty = ((xFixed)div >> 8) & 0xff;
+ } else {
+ x1 = v.vector[0] >> 16;
+ distx = (v.vector[0] >> 8) & 0xff;
+ y1 = v.vector[1] >> 16;
+ disty = (v.vector[1] >> 8) & 0xff;
+ }
+ x2 = x1 + 1;
+ y2 = y1 + 1;
+
+ idistx = 256 - distx;
+ idisty = 256 - disty;
+
+ x1 = MOD (x1, pict->pDrawable->width);
+ x2 = MOD (x2, pict->pDrawable->width);
+ y1 = MOD (y1, pict->pDrawable->height);
+ y2 = MOD (y2, pict->pDrawable->height);
+
+ b = bits + (y1 + pict->pDrawable->y)*stride;
+
+ tl = fetch(b, x1 + pict->pDrawable->x, indexed);
+ tr = fetch(b, x2 + pict->pDrawable->x, indexed);
+ b = bits + (y2 + pict->pDrawable->y)*stride;
+ bl = fetch(b, x1 + pict->pDrawable->x, indexed);
+ br = fetch(b, x2 + pict->pDrawable->x, indexed);
+
+ ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
+ fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
+ r = (((ft * idisty + fb * disty) >> 16) & 0xff);
+ ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
+ fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
+ r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
+ ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
+ fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
+ r |= (((ft * idisty + fb * disty)) & 0xff0000);
+ ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
+ fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
+ r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
+ buffer[i] = r;
+ }
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ } else {
+ for (i = 0; i < width; ++i) {
+ if (!v.vector[2]) {
+ buffer[i] = 0;
+ } else {
+ int x1, x2, y1, y2, distx, idistx, disty, idisty;
+ FbBits *b;
+ CARD32 tl, tr, bl, br, r;
+ CARD32 ft, fb;
+
+ if (!affine) {
+ xFixed_48_16 div;
+ div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
+ x1 = div >> 16;
+ distx = ((xFixed)div >> 8) & 0xff;
+ div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
+ y1 = div >> 16;
+ disty = ((xFixed)div >> 8) & 0xff;
+ } else {
+ x1 = v.vector[0] >> 16;
+ distx = (v.vector[0] >> 8) & 0xff;
+ y1 = v.vector[1] >> 16;
+ disty = (v.vector[1] >> 8) & 0xff;
+ }
+ x2 = x1 + 1;
+ y2 = y1 + 1;
+
+ idistx = 256 - distx;
+ idisty = 256 - disty;
+
+ x1 = MOD (x1, pict->pDrawable->width);
+ x2 = MOD (x2, pict->pDrawable->width);
+ y1 = MOD (y1, pict->pDrawable->height);
+ y2 = MOD (y2, pict->pDrawable->height);
+
+ b = bits + (y1 + pict->pDrawable->y)*stride;
+
+ tl = POINT_IN_REGION(0, pict->pCompositeClip, x1, y1, &box)
+ ? fetch(b, x1 + pict->pDrawable->x, indexed) : 0;
+ tr = POINT_IN_REGION(0, pict->pCompositeClip, x2, y1, &box)
+ ? fetch(b, x2 + pict->pDrawable->x, indexed) : 0;
+ b = bits + (y2 + pict->pDrawable->y)*stride;
+ bl = POINT_IN_REGION(0, pict->pCompositeClip, x1, y2, &box)
+ ? fetch(b, x1 + pict->pDrawable->x, indexed) : 0;
+ br = POINT_IN_REGION(0, pict->pCompositeClip, x2, y2, &box)
+ ? fetch(b, x2 + pict->pDrawable->x, indexed) : 0;
+
+ ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
+ fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
+ r = (((ft * idisty + fb * disty) >> 16) & 0xff);
+ ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
+ fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
+ r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
+ ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
+ fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
+ r |= (((ft * idisty + fb * disty)) & 0xff0000);
+ ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
+ fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
+ r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
+ buffer[i] = r;
+ }
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ }
+ } else {
+ if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
+ box = pict->pCompositeClip->extents;
+ for (i = 0; i < width; ++i) {
+ if (!v.vector[2]) {
+ buffer[i] = 0;
+ } else {
+ int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off;
+ FbBits *b;
+ CARD32 tl, tr, bl, br, r;
+ Bool x1_out, x2_out, y1_out, y2_out;
+ CARD32 ft, fb;
+
+ if (!affine) {
+ xFixed_48_16 div;
+ div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
+ x1 = div >> 16;
+ distx = ((xFixed)div >> 8) & 0xff;
+ div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
+ y1 = div >> 16;
+ disty = ((xFixed)div >> 8) & 0xff;
+ } else {
+ x1 = v.vector[0] >> 16;
+ distx = (v.vector[0] >> 8) & 0xff;
+ y1 = v.vector[1] >> 16;
+ disty = (v.vector[1] >> 8) & 0xff;
+ }
+ x2 = x1 + 1;
+ y2 = y1 + 1;
+
+ idistx = 256 - distx;
+ idisty = 256 - disty;
+
+ b = bits + (y1 + pict->pDrawable->y)*stride;
+ x_off = x1 + pict->pDrawable->x;
+
+ x1_out = (x1 < box.x1) | (x1 >= box.x2);
+ x2_out = (x2 < box.x1) | (x2 >= box.x2);
+ y1_out = (y1 < box.y1) | (y1 >= box.y2);
+ y2_out = (y2 < box.y1) | (y2 >= box.y2);
+
+ tl = x1_out|y1_out ? 0 : fetch(b, x_off, indexed);
+ tr = x2_out|y1_out ? 0 : fetch(b, x_off + 1, indexed);
+ b += stride;
+ bl = x1_out|y2_out ? 0 : fetch(b, x_off, indexed);
+ br = x2_out|y2_out ? 0 : fetch(b, x_off + 1, indexed);
+
+ ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
+ fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
+ r = (((ft * idisty + fb * disty) >> 16) & 0xff);
+ ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
+ fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
+ r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
+ ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
+ fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
+ r |= (((ft * idisty + fb * disty)) & 0xff0000);
+ ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
+ fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
+ r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
+ buffer[i] = r;
+ }
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ } else {
+ for (i = 0; i < width; ++i) {
+ if (!v.vector[2]) {
+ buffer[i] = 0;
+ } else {
+ int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off;
+ FbBits *b;
+ CARD32 tl, tr, bl, br, r;
+ CARD32 ft, fb;
+
+ if (!affine) {
+ xFixed_48_16 div;
+ div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
+ x1 = div >> 16;
+ distx = ((xFixed)div >> 8) & 0xff;
+ div = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2];
+ y1 = div >> 16;
+ disty = ((xFixed)div >> 8) & 0xff;
+ } else {
+ x1 = v.vector[0] >> 16;
+ distx = (v.vector[0] >> 8) & 0xff;
+ y1 = v.vector[1] >> 16;
+ disty = (v.vector[1] >> 8) & 0xff;
+ }
+ x2 = x1 + 1;
+ y2 = y1 + 1;
+
+ idistx = 256 - distx;
+ idisty = 256 - disty;
+
+ b = bits + (y1 + pict->pDrawable->y)*stride;
+ x_off = x1 + pict->pDrawable->x;
+
+ tl = POINT_IN_REGION(0, pict->pCompositeClip, x1, y1, &box)
+ ? fetch(b, x_off, indexed) : 0;
+ tr = POINT_IN_REGION(0, pict->pCompositeClip, x2, y1, &box)
+ ? fetch(b, x_off + 1, indexed) : 0;
+ b += stride;
+ bl = POINT_IN_REGION(0, pict->pCompositeClip, x1, y2, &box)
+ ? fetch(b, x_off, indexed) : 0;
+ br = POINT_IN_REGION(0, pict->pCompositeClip, x2, y2, &box)
+ ? fetch(b, x_off + 1, indexed) : 0;
+
+ ft = FbGet8(tl,0) * idistx + FbGet8(tr,0) * distx;
+ fb = FbGet8(bl,0) * idistx + FbGet8(br,0) * distx;
+ r = (((ft * idisty + fb * disty) >> 16) & 0xff);
+ ft = FbGet8(tl,8) * idistx + FbGet8(tr,8) * distx;
+ fb = FbGet8(bl,8) * idistx + FbGet8(br,8) * distx;
+ r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
+ ft = FbGet8(tl,16) * idistx + FbGet8(tr,16) * distx;
+ fb = FbGet8(bl,16) * idistx + FbGet8(br,16) * distx;
+ r |= (((ft * idisty + fb * disty)) & 0xff0000);
+ ft = FbGet8(tl,24) * idistx + FbGet8(tr,24) * distx;
+ fb = FbGet8(bl,24) * idistx + FbGet8(br,24) * distx;
+ r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
+ buffer[i] = r;
+ }
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ }
+ }
+ } else if (pict->filter == PictFilterConvolution) {
+ xFixed *params = pict->filter_params;
+ INT32 cwidth = xFixedToInt(params[0]);
+ INT32 cheight = xFixedToInt(params[1]);
+ int xoff = params[0] >> 1;
+ int yoff = params[1] >> 1;
+ params += 2;
+ for (i = 0; i < width; ++i) {
+ if (!v.vector[2]) {
+ buffer[i] = 0;
+ } else {
+ int x1, x2, y1, y2, x, y;
+ INT32 srtot, sgtot, sbtot, satot;
+ xFixed *p = params;
+
+ if (!affine) {
+ xFixed_48_16 tmp;
+ tmp = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2] - xoff;
+ x1 = xFixedToInt(tmp);
+ tmp = ((xFixed_48_16)v.vector[1] << 16)/v.vector[2] - yoff;
+ y1 = xFixedToInt(tmp);
+ } else {
+ x1 = xFixedToInt(v.vector[0] - xoff);
+ y1 = xFixedToInt(v.vector[1] - yoff);
+ }
+ x2 = x1 + cwidth;
+ y2 = y1 + cheight;
+
+ srtot = sgtot = sbtot = satot = 0;
+
+ for (y = y1; y < y2; y++) {
+ int ty = (pict->repeatType == RepeatNormal) ? MOD (y, pict->pDrawable->height) : y;
+ for (x = x1; x < x2; x++) {
+ if (*p) {
+ int tx = (pict->repeatType == RepeatNormal) ? MOD (x, pict->pDrawable->width) : x;
+ if (POINT_IN_REGION (0, pict->pCompositeClip, tx, ty, &box)) {
+ FbBits *b = bits + (ty + pict->pDrawable->y)*stride;
+ CARD32 c = fetch(b, tx + pict->pDrawable->x, indexed);
+
+ srtot += Red(c) * *p;
+ sgtot += Green(c) * *p;
+ sbtot += Blue(c) * *p;
+ satot += Alpha(c) * *p;
+ }
+ }
+ p++;
+ }
+ }
+
+ if (satot < 0) satot = 0; else if (satot > 0xff) satot = 0xff;
+ if (srtot < 0) srtot = 0; else if (srtot > 0xff) srtot = 0xff;
+ if (sgtot < 0) sgtot = 0; else if (sgtot > 0xff) sgtot = 0xff;
+ if (sbtot < 0) sbtot = 0; else if (sbtot > 0xff) sbtot = 0xff;
+
+ buffer[i] = ((satot << 24) |
+ (srtot << 16) |
+ (sgtot << 8) |
+ (sbtot ));
+ }
+ v.vector[0] += unit.vector[0];
+ v.vector[1] += unit.vector[1];
+ v.vector[2] += unit.vector[2];
+ }
+ }
+}
+
+
+static void fbFetchExternalAlpha(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
+{
+ int i;
+ CARD32 _alpha_buffer[SCANLINE_BUFFER_LENGTH];
+ CARD32 *alpha_buffer = _alpha_buffer;
+
+ if (!pict->alphaMap) {
+ fbFetchTransformed(pict, x, y, width, buffer);
+ return;
+ }
+ if (width > SCANLINE_BUFFER_LENGTH)
+ alpha_buffer = (CARD32 *) malloc(width*sizeof(CARD32));
+
+ fbFetchTransformed(pict, x, y, width, buffer);
+ fbFetchTransformed(pict->alphaMap, x - pict->alphaOrigin.x, y - pict->alphaOrigin.y, width, alpha_buffer);
+ for (i = 0; i < width; ++i) {
+ int a = alpha_buffer[i]>>24;
+ buffer[i] = (a << 24)
+ | (div_255(Red(buffer[i]) * a) << 16)
+ | (div_255(Green(buffer[i]) * a) << 8)
+ | (div_255(Blue(buffer[i]) * a));
+ }
+
+ if (alpha_buffer != _alpha_buffer)
+ free(alpha_buffer);
+}
+
+static void fbStore(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
+{
+ FbBits *bits;
+ FbStride stride;
+ int bpp;
+ int xoff, yoff;
+ storeProc store = storeProcForPicture(pict);
+ miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
+
+ fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
+ x += xoff;
+ y += yoff;
+
+ bits += y*stride;
+ store(bits, buffer, x, width, indexed);
+}
+
+static void fbStoreExternalAlpha(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
+{
+ FbBits *bits, *alpha_bits;
+ FbStride stride, astride;
+ int bpp, abpp;
+ int xoff, yoff;
+ int ax, ay;
+ storeProc store;
+ storeProc astore;
+ miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
+ miIndexedPtr aindexed;
+
+ if (!pict->alphaMap) {
+ fbStore(pict, x, y, width, buffer);
+ return;
+ }
+
+ store = storeProcForPicture(pict);
+ astore = storeProcForPicture(pict->alphaMap);
+ aindexed = (miIndexedPtr) pict->alphaMap->pFormat->index.devPrivate;
+
+ ax = x;
+ ay = y;
+
+ fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
+ x += xoff;
+ y += yoff;
+ fbGetDrawable (pict->alphaMap->pDrawable, alpha_bits, astride, abpp, xoff, yoff);
+ ax += xoff;
+ ay += yoff;
+
+ bits += y*stride;
+ alpha_bits += (ay - pict->alphaOrigin.y)*astride;
+
+
+ store(bits, buffer, x, width, indexed);
+ astore(alpha_bits, buffer, ax - pict->alphaOrigin.x, width, aindexed);
+}
+
+typedef void (*scanStoreProc)(PicturePtr , int , int , int , CARD32 *);
+typedef void (*scanFetchProc)(PicturePtr , int , int , int , CARD32 *);
+
+static void
+fbCompositeRect (const FbComposeData *data, CARD32 *scanline_buffer)
+{
+ CARD32 *src_buffer = scanline_buffer;
+ CARD32 *dest_buffer = src_buffer + data->width;
+ int i;
+ scanStoreProc store;
+ scanFetchProc fetchSrc = NULL, fetchMask = NULL, fetchDest = NULL;
+
+ if (data->op == PictOpClear)
+ fetchSrc = NULL;
+ else if (!data->src->pDrawable) {
+ if (data->src->pSourcePict)
+ fetchSrc = fbFetchSourcePict;
+ } else if (data->src->alphaMap)
+ fetchSrc = fbFetchExternalAlpha;
+ else if (data->src->repeatType == RepeatNormal &&
+ data->src->pDrawable->width == 1 && data->src->pDrawable->height == 1)
+ fetchSrc = fbFetchSolid;
+ else if (!data->src->transform && data->src->filter != PictFilterConvolution)
+ fetchSrc = fbFetch;
+ else
+ fetchSrc = fbFetchTransformed;
+
+ if (data->mask && data->op != PictOpClear) {
+ if (!data->mask->pDrawable) {
+ if (data->mask->pSourcePict)
+ fetchMask = fbFetchSourcePict;
+ } else if (data->mask->alphaMap)
+ fetchMask = fbFetchExternalAlpha;
+ else if (data->mask->repeatType == RepeatNormal
+ && data->mask->pDrawable->width == 1 && data->mask->pDrawable->height == 1)
+ fetchMask = fbFetchSolid;
+ else if (!data->mask->transform && data->mask->filter != PictFilterConvolution)
+ fetchMask = fbFetch;
+ else
+ fetchMask = fbFetchTransformed;
+ } else {
+ fetchMask = NULL;
+ }
+
+ if (data->dest->alphaMap) {
+ fetchDest = fbFetchExternalAlpha;
+ store = fbStoreExternalAlpha;
+ } else {
+ fetchDest = fbFetch;
+ store = fbStore;
+ }
+ if (data->op == PictOpClear || data->op == PictOpSrc)
+ fetchDest = NULL;
+
+ if (fetchSrc && fetchMask && data->mask && data->mask->componentAlpha && PICT_FORMAT_RGB(data->mask->format)) {
+ CARD32 *mask_buffer = dest_buffer + data->width;
+ CombineFuncC compose = composeFunctions.combineC[data->op];
+ if (!compose)
+ return;
+
+ for (i = 0; i < data->height; ++i)
+ {
+ /* fill first half of scanline with source */
+ fetchSrc(data->src, data->xSrc, data->ySrc + i, data->width, src_buffer);
+ fetchMask(data->mask, data->xMask, data->yMask + i, data->width, mask_buffer);
+
+ /* fill dest into second half of scanline */
+ if (fetchDest)
+ fetchDest(data->dest, data->xDest, data->yDest + i, data->width, dest_buffer);
+
+ /* blend */
+ compose(dest_buffer, src_buffer, mask_buffer, data->width);
+
+ /* write back */
+ store(data->dest, data->xDest, data->yDest + i, data->width, dest_buffer);
+ }
+ } else {
+
+ CombineFuncU compose = composeFunctions.combineU[data->op];
+ if (!compose)
+ return;
+
+ if (fetchSrc == fbFetchSolid && (!fetchMask || fetchMask == fbFetchSolid)) {
+ fetchSrc(data->src, data->xSrc, data->ySrc, data->width, src_buffer);
+ if (fetchMask) {
+ fetchMask(data->mask, data->xMask, data->yMask, data->width, dest_buffer);
+ composeFunctions.combineMaskU(src_buffer, dest_buffer, data->width);
+ }
+ fetchSrc = NULL;
+ fetchMask = NULL;
+ }
+
+ for (i = 0; i < data->height; ++i)
+ {
+ /* fill first half of scanline with source */
+ if (fetchSrc) {
+ fetchSrc(data->src, data->xSrc, data->ySrc + i, data->width, src_buffer);
+
+ /* add in mask */
+ if (fetchMask) {
+ fetchMask(data->mask, data->xMask, data->yMask + i, data->width, dest_buffer);
+ composeFunctions.combineMaskU(src_buffer, dest_buffer, data->width);
+ }
+ }
+
+ /* fill dest into second half of scanline */
+ if (fetchDest)
+ fetchDest(data->dest, data->xDest, data->yDest + i, data->width, dest_buffer);
+
+ /* blend */
+ compose(dest_buffer, src_buffer, data->width);
+
+ /* write back */
+ store(data->dest, data->xDest, data->yDest + i, data->width, dest_buffer);
+ }
+ }
+}
+
+void
+fbCompositeGeneral (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ RegionRec region;
+ int n;
+ BoxPtr pbox;
+ Bool srcRepeat = FALSE;
+ Bool maskRepeat = FALSE;
+ int w, h;
+ CARD32 _scanline_buffer[SCANLINE_BUFFER_LENGTH*3];
+ CARD32 *scanline_buffer = _scanline_buffer;
+ FbComposeData compose_data;
+
+ if (pSrc->pDrawable)
+ srcRepeat = pSrc->repeatType == RepeatNormal && !pSrc->transform
+ && (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1);
+
+ if (pMask && pMask->pDrawable)
+ maskRepeat = pMask->repeatType == RepeatNormal && !pMask->transform
+ && (pMask->pDrawable->width != 1 || pMask->pDrawable->height != 1);
+
+ if (op == PictOpOver && !pMask && !pSrc->transform && !PICT_FORMAT_A(pSrc->format) && !pSrc->alphaMap)
+ op = PictOpSrc;
+
+ if (!miComputeCompositeRegion (&region,
+ pSrc,
+ pMask,
+ pDst,
+ xSrc,
+ ySrc,
+ xMask,
+ yMask,
+ xDst,
+ yDst,
+ width,
+ height))
+ return;
+
+ compose_data.op = op;
+ compose_data.src = pSrc;
+ compose_data.mask = pMask;
+ compose_data.dest = pDst;
+ if (width > SCANLINE_BUFFER_LENGTH)
+ scanline_buffer = (CARD32 *) malloc(width * 3 * sizeof(CARD32));
+
+ n = REGION_NUM_RECTS (&region);
+ pbox = REGION_RECTS (&region);
+ while (n--)
+ {
+ h = pbox->y2 - pbox->y1;
+ compose_data.ySrc = pbox->y1 - yDst + ySrc;
+ compose_data.yMask = pbox->y1 - yDst + yMask;
+ compose_data.yDest = pbox->y1;
+ while (h)
+ {
+ compose_data.height = h;
+ w = pbox->x2 - pbox->x1;
+ compose_data.xSrc = pbox->x1 - xDst + xSrc;
+ compose_data.xMask = pbox->x1 - xDst + xMask;
+ compose_data.xDest = pbox->x1;
+ if (maskRepeat)
+ {
+ compose_data.yMask = mod (compose_data.yMask, pMask->pDrawable->height);
+ if (compose_data.height > pMask->pDrawable->height - compose_data.yMask)
+ compose_data.height = pMask->pDrawable->height - compose_data.yMask;
+ }
+ if (srcRepeat)
+ {
+ compose_data.ySrc = mod (compose_data.ySrc, pSrc->pDrawable->height);
+ if (compose_data.height > pSrc->pDrawable->height - compose_data.ySrc)
+ compose_data.height = pSrc->pDrawable->height - compose_data.ySrc;
+ }
+ while (w)
+ {
+ compose_data.width = w;
+ if (maskRepeat)
+ {
+ compose_data.xMask = mod (compose_data.xMask, pMask->pDrawable->width);
+ if (compose_data.width > pMask->pDrawable->width - compose_data.xMask)
+ compose_data.width = pMask->pDrawable->width - compose_data.xMask;
+ }
+ if (srcRepeat)
+ {
+ compose_data.xSrc = mod (compose_data.xSrc, pSrc->pDrawable->width);
+ if (compose_data.width > pSrc->pDrawable->width - compose_data.xSrc)
+ compose_data.width = pSrc->pDrawable->width - compose_data.xSrc;
+ }
+ fbCompositeRect(&compose_data, scanline_buffer);
+ w -= compose_data.width;
+ compose_data.xSrc += compose_data.width;
+ compose_data.xMask += compose_data.width;
+ compose_data.xDest += compose_data.width;
+ }
+ h -= compose_data.height;
+ compose_data.ySrc += compose_data.height;
+ compose_data.yMask += compose_data.height;
+ compose_data.yDest += compose_data.height;
+ }
+ pbox++;
+ }
+ REGION_UNINIT (pDst->pDrawable->pScreen, &region);
+
+ if (scanline_buffer != _scanline_buffer)
+ free(scanline_buffer);
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/fb/fbcopy.c b/nx-X11/programs/Xserver/fb/fbcopy.c
new file mode 100644
index 000000000..1e7b93435
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbcopy.c
@@ -0,0 +1,663 @@
+/*
+ * Id: fbcopy.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbcopy.c,v 1.13 2003/11/10 18:21:47 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#ifdef IN_MODULE
+#include "xf86_ansic.h"
+#endif
+#include "fbmmx.h"
+
+void
+fbCopyNtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ CARD8 alu = pGC ? pGC->alu : GXcopy;
+ FbBits pm = pGC ? fbGetGCPrivate(pGC)->pm : FB_ALLONES;
+ FbBits *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+
+ fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+ fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ while (nbox--)
+ {
+#ifdef USE_MMX
+ if (pm == FB_ALLONES && alu == GXcopy && !reverse &&
+ !upsidedown && fbHaveMMX())
+ {
+ if (!fbCopyAreammx (pSrcDrawable,
+ pDstDrawable,
+
+ (pbox->x1 + dx),
+ (pbox->y1 + dy),
+
+ (pbox->x1),
+ (pbox->y1),
+
+ (pbox->x2 - pbox->x1),
+ (pbox->y2 - pbox->y1)))
+ goto fallback;
+ else
+ goto next;
+ }
+ fallback:
+#endif
+ fbBlt (src + (pbox->y1 + dy + srcYoff) * srcStride,
+ srcStride,
+ (pbox->x1 + dx + srcXoff) * srcBpp,
+
+ dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+
+ (pbox->x2 - pbox->x1) * dstBpp,
+ (pbox->y2 - pbox->y1),
+
+ alu,
+ pm,
+ dstBpp,
+
+ reverse,
+ upsidedown);
+#ifdef USE_MMX
+ next:
+#endif
+ pbox++;
+ }
+}
+
+void
+fbCopy1toN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ FbBits *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+
+ fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+ fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ while (nbox--)
+ {
+ if (dstBpp == 1)
+ {
+ fbBlt (src + (pbox->y1 + dy + srcYoff) * srcStride,
+ srcStride,
+ (pbox->x1 + dx + srcXoff) * srcBpp,
+
+ dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+
+ (pbox->x2 - pbox->x1) * dstBpp,
+ (pbox->y2 - pbox->y1),
+
+ FbOpaqueStipple1Rop(pGC->alu,
+ pGC->fgPixel,pGC->bgPixel),
+ pPriv->pm,
+ dstBpp,
+
+ reverse,
+ upsidedown);
+ }
+ else
+ {
+ fbBltOne ((FbStip *) (src + (pbox->y1 + dy + srcYoff) * srcStride),
+ srcStride*(FB_UNIT/FB_STIP_UNIT),
+ (pbox->x1 + dx + srcXoff),
+
+ dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+ dstBpp,
+
+ (pbox->x2 - pbox->x1) * dstBpp,
+ (pbox->y2 - pbox->y1),
+
+ pPriv->and, pPriv->xor,
+ pPriv->bgand, pPriv->bgxor);
+ }
+ pbox++;
+ }
+}
+
+void
+fbCopyNto1 (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+
+ while (nbox--)
+ {
+ if (pDstDrawable->bitsPerPixel == 1)
+ {
+ FbBits *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+
+ FbStip *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+
+ fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+ fbGetStipDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ fbBltPlane (src + (pbox->y1+ dy + srcYoff) * srcStride,
+ srcStride,
+ (pbox->x1 + dx + srcXoff) * srcBpp,
+ srcBpp,
+
+ dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+
+ (pbox->x2 - pbox->x1) * srcBpp,
+ (pbox->y2 - pbox->y1),
+
+ (FbStip) pPriv->and, (FbStip) pPriv->xor,
+ (FbStip) pPriv->bgand, (FbStip) pPriv->bgxor,
+ bitplane);
+ }
+ else
+ {
+ FbBits *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+
+ FbStip *tmp;
+ FbStride tmpStride;
+ int width, height;
+
+ width = pbox->x2 - pbox->x1;
+ height = pbox->y2 - pbox->y1;
+
+ tmpStride = ((width + FB_STIP_MASK) >> FB_STIP_SHIFT);
+ tmp = xalloc (tmpStride * height * sizeof (FbStip));
+ if (!tmp)
+ return;
+
+ fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+ fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ fbBltPlane (src + (pbox->y1+ dy + srcYoff) * srcStride,
+ srcStride,
+ (pbox->x1 + dx + srcXoff) * srcBpp,
+ srcBpp,
+
+ tmp,
+ tmpStride,
+ 0,
+
+ width * srcBpp,
+ height,
+
+ fbAndStip(GXcopy,FB_ALLONES,FB_ALLONES),
+ fbXorStip(GXcopy,FB_ALLONES,FB_ALLONES),
+ fbAndStip(GXcopy,0,FB_ALLONES),
+ fbXorStip(GXcopy,0,FB_ALLONES),
+ bitplane);
+ fbBltOne (tmp,
+ tmpStride,
+ 0,
+
+ dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+ dstBpp,
+
+ width * dstBpp,
+ height,
+
+ pPriv->and, pPriv->xor,
+ pPriv->bgand, pPriv->bgxor);
+ xfree (tmp);
+ }
+ pbox++;
+ }
+}
+
+void
+fbCopyRegion (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ RegionPtr pDstRegion,
+ int dx,
+ int dy,
+ fbCopyProc copyProc,
+ Pixel bitPlane,
+ void *closure)
+{
+ int careful;
+ Bool reverse;
+ Bool upsidedown;
+ BoxPtr pbox;
+ int nbox;
+ BoxPtr pboxNew1, pboxNew2, pboxBase, pboxNext, pboxTmp;
+
+ pbox = REGION_RECTS(pDstRegion);
+ nbox = REGION_NUM_RECTS(pDstRegion);
+
+ /* XXX we have to err on the side of safety when both are windows,
+ * because we don't know if IncludeInferiors is being used.
+ */
+ careful = ((pSrcDrawable == pDstDrawable) ||
+ ((pSrcDrawable->type == DRAWABLE_WINDOW) &&
+ (pDstDrawable->type == DRAWABLE_WINDOW)));
+
+ pboxNew1 = NULL;
+ pboxNew2 = NULL;
+ if (careful && dy < 0)
+ {
+ upsidedown = TRUE;
+
+ if (nbox > 1)
+ {
+ /* keep ordering in each band, reverse order of bands */
+ pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
+ if(!pboxNew1)
+ return;
+ pboxBase = pboxNext = pbox+nbox-1;
+ while (pboxBase >= pbox)
+ {
+ while ((pboxNext >= pbox) &&
+ (pboxBase->y1 == pboxNext->y1))
+ pboxNext--;
+ pboxTmp = pboxNext+1;
+ while (pboxTmp <= pboxBase)
+ {
+ *pboxNew1++ = *pboxTmp++;
+ }
+ pboxBase = pboxNext;
+ }
+ pboxNew1 -= nbox;
+ pbox = pboxNew1;
+ }
+ }
+ else
+ {
+ /* walk source top to bottom */
+ upsidedown = FALSE;
+ }
+
+ if (careful && dx < 0)
+ {
+ /* walk source right to left */
+ if (dy <= 0)
+ reverse = TRUE;
+ else
+ reverse = FALSE;
+
+ if (nbox > 1)
+ {
+ /* reverse order of rects in each band */
+ pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
+ if(!pboxNew2)
+ {
+ if (pboxNew1)
+ DEALLOCATE_LOCAL(pboxNew1);
+ return;
+ }
+ pboxBase = pboxNext = pbox;
+ while (pboxBase < pbox+nbox)
+ {
+ while ((pboxNext < pbox+nbox) &&
+ (pboxNext->y1 == pboxBase->y1))
+ pboxNext++;
+ pboxTmp = pboxNext;
+ while (pboxTmp != pboxBase)
+ {
+ *pboxNew2++ = *--pboxTmp;
+ }
+ pboxBase = pboxNext;
+ }
+ pboxNew2 -= nbox;
+ pbox = pboxNew2;
+ }
+ }
+ else
+ {
+ /* walk source left to right */
+ reverse = FALSE;
+ }
+
+ (*copyProc) (pSrcDrawable,
+ pDstDrawable,
+ pGC,
+ pbox,
+ nbox,
+ dx, dy,
+ reverse, upsidedown, bitPlane, closure);
+
+ if (pboxNew1)
+ DEALLOCATE_LOCAL (pboxNew1);
+ if (pboxNew2)
+ DEALLOCATE_LOCAL (pboxNew2);
+}
+
+RegionPtr
+fbDoCopy (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut,
+ fbCopyProc copyProc,
+ Pixel bitPlane,
+ void *closure)
+{
+ RegionPtr prgnSrcClip = NULL; /* may be a new region, or just a copy */
+ Bool freeSrcClip = FALSE;
+ RegionPtr prgnExposed = NULL;
+ RegionRec rgnDst;
+ int dx;
+ int dy;
+ int numRects;
+ int box_x1;
+ int box_y1;
+ int box_x2;
+ int box_y2;
+ Bool fastSrc = FALSE; /* for fast clipping with pixmap source */
+ Bool fastDst = FALSE; /* for fast clipping with one rect dest */
+ Bool fastExpose = FALSE; /* for fast exposures with pixmap source */
+
+ /* Short cut for unmapped windows */
+
+ if (pDstDrawable->type == DRAWABLE_WINDOW &&
+ !((WindowPtr)pDstDrawable)->realized)
+ {
+ return NULL;
+ }
+
+ if ((pSrcDrawable != pDstDrawable) &&
+ pSrcDrawable->pScreen->SourceValidate)
+ {
+ (*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, xIn, yIn, widthSrc, heightSrc);
+ }
+
+ /* Compute source clip region */
+ if (pSrcDrawable->type == DRAWABLE_PIXMAP)
+ {
+ if ((pSrcDrawable == pDstDrawable) && (pGC->clientClipType == CT_NONE))
+ prgnSrcClip = fbGetCompositeClip(pGC);
+ else
+ fastSrc = TRUE;
+ }
+ else
+ {
+ if (pGC->subWindowMode == IncludeInferiors)
+ {
+ /*
+ * XFree86 DDX empties the border clip when the
+ * VT is inactive, make sure the region isn't empty
+ */
+ if (!((WindowPtr) pSrcDrawable)->parent &&
+ REGION_NOTEMPTY (pSrcDrawable->pScreen,
+ &((WindowPtr) pSrcDrawable)->borderClip))
+ {
+ /*
+ * special case bitblt from root window in
+ * IncludeInferiors mode; just like from a pixmap
+ */
+ fastSrc = TRUE;
+ }
+ else if ((pSrcDrawable == pDstDrawable) &&
+ (pGC->clientClipType == CT_NONE))
+ {
+ prgnSrcClip = fbGetCompositeClip(pGC);
+ }
+ else
+ {
+ prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable);
+ freeSrcClip = TRUE;
+ }
+ }
+ else
+ {
+ prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList;
+ }
+ }
+
+ xIn += pSrcDrawable->x;
+ yIn += pSrcDrawable->y;
+
+ xOut += pDstDrawable->x;
+ yOut += pDstDrawable->y;
+
+ box_x1 = xIn;
+ box_y1 = yIn;
+ box_x2 = xIn + widthSrc;
+ box_y2 = yIn + heightSrc;
+
+ dx = xIn - xOut;
+ dy = yIn - yOut;
+
+ /* Don't create a source region if we are doing a fast clip */
+ if (fastSrc)
+ {
+ RegionPtr cclip;
+
+ fastExpose = TRUE;
+ /*
+ * clip the source; if regions extend beyond the source size,
+ * make sure exposure events get sent
+ */
+ if (box_x1 < pSrcDrawable->x)
+ {
+ box_x1 = pSrcDrawable->x;
+ fastExpose = FALSE;
+ }
+ if (box_y1 < pSrcDrawable->y)
+ {
+ box_y1 = pSrcDrawable->y;
+ fastExpose = FALSE;
+ }
+ if (box_x2 > pSrcDrawable->x + (int) pSrcDrawable->width)
+ {
+ box_x2 = pSrcDrawable->x + (int) pSrcDrawable->width;
+ fastExpose = FALSE;
+ }
+ if (box_y2 > pSrcDrawable->y + (int) pSrcDrawable->height)
+ {
+ box_y2 = pSrcDrawable->y + (int) pSrcDrawable->height;
+ fastExpose = FALSE;
+ }
+
+ /* Translate and clip the dst to the destination composite clip */
+ box_x1 -= dx;
+ box_x2 -= dx;
+ box_y1 -= dy;
+ box_y2 -= dy;
+
+ /* If the destination composite clip is one rectangle we can
+ do the clip directly. Otherwise we have to create a full
+ blown region and call intersect */
+
+ cclip = fbGetCompositeClip(pGC);
+ if (REGION_NUM_RECTS(cclip) == 1)
+ {
+ BoxPtr pBox = REGION_RECTS(cclip);
+
+ if (box_x1 < pBox->x1) box_x1 = pBox->x1;
+ if (box_x2 > pBox->x2) box_x2 = pBox->x2;
+ if (box_y1 < pBox->y1) box_y1 = pBox->y1;
+ if (box_y2 > pBox->y2) box_y2 = pBox->y2;
+ fastDst = TRUE;
+ }
+ }
+
+ /* Check to see if the region is empty */
+ if (box_x1 >= box_x2 || box_y1 >= box_y2)
+ {
+ REGION_NULL(pGC->pScreen, &rgnDst);
+ }
+ else
+ {
+ BoxRec box;
+ box.x1 = box_x1;
+ box.y1 = box_y1;
+ box.x2 = box_x2;
+ box.y2 = box_y2;
+ REGION_INIT(pGC->pScreen, &rgnDst, &box, 1);
+ }
+
+ /* Clip against complex source if needed */
+ if (!fastSrc)
+ {
+ REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip);
+ REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy);
+ }
+
+ /* Clip against complex dest if needed */
+ if (!fastDst)
+ {
+ REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst,
+ fbGetCompositeClip(pGC));
+ }
+
+ /* Do bit blitting */
+ numRects = REGION_NUM_RECTS(&rgnDst);
+ if (numRects && widthSrc && heightSrc)
+ fbCopyRegion (pSrcDrawable, pDstDrawable, pGC,
+ &rgnDst, dx, dy, copyProc, bitPlane, closure);
+
+ /* Pixmap sources generate a NoExposed (we return NULL to do this) */
+ if (!fastExpose && pGC->fExpose)
+ prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
+ xIn - pSrcDrawable->x,
+ yIn - pSrcDrawable->y,
+ widthSrc, heightSrc,
+ xOut - pDstDrawable->x,
+ yOut - pDstDrawable->y,
+ (unsigned long) bitPlane);
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ fbValidateDrawable (pDstDrawable);
+ return prgnExposed;
+}
+
+RegionPtr
+fbCopyArea (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut)
+{
+ fbCopyProc copy;
+
+#ifdef FB_24_32BIT
+ if (pSrcDrawable->bitsPerPixel != pDstDrawable->bitsPerPixel)
+ copy = fb24_32CopyMtoN;
+ else
+#endif
+ copy = fbCopyNtoN;
+ return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, xIn, yIn,
+ widthSrc, heightSrc, xOut, yOut, copy, 0, 0);
+}
+
+RegionPtr
+fbCopyPlane (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut,
+ unsigned long bitplane)
+{
+ if (pSrcDrawable->bitsPerPixel > 1)
+ return fbDoCopy (pSrcDrawable, pDstDrawable, pGC,
+ xIn, yIn, widthSrc, heightSrc,
+ xOut, yOut, fbCopyNto1, (Pixel) bitplane, 0);
+ else if (bitplane & 1)
+ return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, xIn, yIn,
+ widthSrc, heightSrc, xOut, yOut, fbCopy1toN,
+ (Pixel) bitplane, 0);
+ else
+ return miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
+ xIn, yIn,
+ widthSrc,
+ heightSrc,
+ xOut, yOut, bitplane);
+}
diff --git a/nx-X11/programs/Xserver/fb/fbedge.c b/nx-X11/programs/Xserver/fb/fbedge.c
new file mode 100644
index 000000000..66dcdc35f
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbedge.c
@@ -0,0 +1,314 @@
+/*
+ * $Id: fbedge.c,v 1.5 2005/10/03 10:20:29 anholt Exp $
+ *
+ * Copyright © 2004 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <string.h>
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+#ifdef RENDER
+
+#include "picturestr.h"
+#include "mipict.h"
+#include "renderedge.h"
+#include "fbpict.h"
+
+/*
+ * 4 bit alpha
+ */
+
+#define N_BITS 4
+#define rasterizeEdges fbRasterizeEdges4
+
+#if BITMAP_BIT_ORDER == LSBFirst
+#define Shift4(o) ((o) << 2)
+#else
+#define Shift4(o) ((1-(o)) << 2)
+#endif
+
+#define Get4(x,o) (((x) >> Shift4(o)) & 0xf)
+#define Put4(x,o,v) (((x) & ~(0xf << Shift4(o))) | (((v) & 0xf) << Shift4(o)))
+
+#define DefineAlpha(line,x) \
+ CARD8 *__ap = (CARD8 *) line + ((x) >> 1); \
+ int __ao = (x) & 1
+
+#define StepAlpha ((__ap += __ao), (__ao ^= 1))
+
+#define AddAlpha(a) { \
+ CARD8 __o = *__ap; \
+ CARD8 __a = (a) + Get4(__o, __ao); \
+ *__ap = Put4 (__o, __ao, __a | (0 - ((__a) >> 4))); \
+}
+
+#include "fbedgeimp.h"
+
+#undef AddAlpha
+#undef StepAlpha
+#undef DefineAlpha
+#undef rasterizeEdges
+#undef N_BITS
+
+
+/*
+ * 1 bit alpha
+ */
+
+#define N_BITS 1
+#define rasterizeEdges fbRasterizeEdges1
+
+#include "fbedgeimp.h"
+
+#undef rasterizeEdges
+#undef N_BITS
+
+/*
+ * 8 bit alpha
+ */
+
+static INLINE CARD8
+clip255 (int x)
+{
+ if (x > 255) return 255;
+ return x;
+}
+
+static INLINE void
+add_saturate_8 (CARD8 *buf, int value, int length)
+{
+ while (length--)
+ {
+ *buf = clip255 (*buf + value);
+ buf++;
+ }
+}
+
+/*
+ * We want to detect the case where we add the same value to a long
+ * span of pixels. The triangles on the end are filled in while we
+ * count how many sub-pixel scanlines contribute to the middle section.
+ *
+ * +--------------------------+
+ * fill_height =| \ /
+ * +------------------+
+ * |================|
+ * fill_start fill_end
+ */
+static void
+fbRasterizeEdges8 (FbBits *buf,
+ int width,
+ int stride,
+ RenderEdge *l,
+ RenderEdge *r,
+ xFixed t,
+ xFixed b)
+{
+ xFixed y = t;
+ FbBits *line;
+ int fill_start = -1, fill_end = -1;
+ int fill_size = 0;
+
+ line = buf + xFixedToInt (y) * stride;
+
+ for (;;)
+ {
+ CARD8 *ap = (CARD8 *) line;
+ xFixed lx, rx;
+ int lxi, rxi;
+
+ /* clip X */
+ lx = l->x;
+ if (lx < 0)
+ lx = 0;
+ rx = r->x;
+ if (xFixedToInt (rx) >= width)
+ rx = IntToxFixed (width);
+
+ /* Skip empty (or backwards) sections */
+ if (rx > lx)
+ {
+ int lxs, rxs;
+
+ /* Find pixel bounds for span. */
+ lxi = xFixedToInt (lx);
+ rxi = xFixedToInt (rx);
+
+ /* Sample coverage for edge pixels */
+ lxs = RenderSamplesX (lx, 8);
+ rxs = RenderSamplesX (rx, 8);
+
+ /* Add coverage across row */
+ if (lxi == rxi)
+ {
+ ap[lxi] = clip255 (ap[lxi] + rxs - lxs);
+ }
+ else
+ {
+ ap[lxi] = clip255 (ap[lxi] + N_X_FRAC(8) - lxs);
+
+ /* Move forward so that lxi/rxi is the pixel span */
+ lxi++;
+
+ /* Don't bother trying to optimize the fill unless
+ * the span is longer than 4 pixels. */
+ if (rxi - lxi > 4)
+ {
+ if (fill_start < 0)
+ {
+ fill_start = lxi;
+ fill_end = rxi;
+ fill_size++;
+ }
+ else
+ {
+ if (lxi >= fill_end || rxi < fill_start)
+ {
+ /* We're beyond what we saved, just fill it */
+ add_saturate_8 (ap + fill_start,
+ fill_size * N_X_FRAC(8),
+ fill_end - fill_start);
+ fill_start = lxi;
+ fill_end = rxi;
+ fill_size = 1;
+ }
+ else
+ {
+ /* Update fill_start */
+ if (lxi > fill_start)
+ {
+ add_saturate_8 (ap + fill_start,
+ fill_size * N_X_FRAC(8),
+ lxi - fill_start);
+ fill_start = lxi;
+ }
+ else if (lxi < fill_start)
+ {
+ add_saturate_8 (ap + lxi, N_X_FRAC(8),
+ fill_start - lxi);
+ }
+
+ /* Update fill_end */
+ if (rxi < fill_end)
+ {
+ add_saturate_8 (ap + rxi,
+ fill_size * N_X_FRAC(8),
+ fill_end - rxi);
+ fill_end = rxi;
+ }
+ else if (fill_end < rxi)
+ {
+ add_saturate_8 (ap + fill_end,
+ N_X_FRAC(8),
+ rxi - fill_end);
+ }
+ fill_size++;
+ }
+ }
+ }
+ else
+ {
+ add_saturate_8 (ap + lxi, N_X_FRAC(8), rxi - lxi);
+ }
+
+ /* Do not add in a 0 alpha here. This check is
+ * necessary to avoid a buffer overrun, (when rx
+ * is exactly on a pixel boundary). */
+ if (rxs)
+ ap[rxi] = clip255 (ap[rxi] + rxs);
+ }
+ }
+
+ if (y == b) {
+ /* We're done, make sure we clean up any remaining fill. */
+ if (fill_start != fill_end) {
+ if (fill_size == N_Y_FRAC(8))
+ {
+ memset (ap + fill_start, 0xff, fill_end - fill_start);
+ }
+ else
+ {
+ add_saturate_8 (ap + fill_start, fill_size * N_X_FRAC(8),
+ fill_end - fill_start);
+ }
+ }
+ break;
+ }
+
+ if (xFixedFrac (y) != Y_FRAC_LAST(8))
+ {
+ RenderEdgeStepSmall (l);
+ RenderEdgeStepSmall (r);
+ y += STEP_Y_SMALL(8);
+ }
+ else
+ {
+ RenderEdgeStepBig (l);
+ RenderEdgeStepBig (r);
+ y += STEP_Y_BIG(8);
+ if (fill_start != fill_end)
+ {
+ if (fill_size == N_Y_FRAC(8))
+ {
+ memset (ap + fill_start, 0xff, fill_end - fill_start);
+ }
+ else
+ {
+ add_saturate_8 (ap + fill_start, fill_size * N_X_FRAC(8),
+ fill_end - fill_start);
+ }
+ fill_start = fill_end = -1;
+ fill_size = 0;
+ }
+ line += stride;
+ }
+ }
+}
+
+void
+fbRasterizeEdges (FbBits *buf,
+ int bpp,
+ int width,
+ int stride,
+ RenderEdge *l,
+ RenderEdge *r,
+ xFixed t,
+ xFixed b)
+{
+ switch (bpp) {
+ case 1:
+ fbRasterizeEdges1 (buf, width, stride, l, r, t, b);
+ break;
+ case 4:
+ fbRasterizeEdges4 (buf, width, stride, l, r, t, b);
+ break;
+ case 8:
+ fbRasterizeEdges8 (buf, width, stride, l, r, t, b);
+ break;
+ }
+}
+
+#endif /* RENDER */
diff --git a/nx-X11/programs/Xserver/fb/fbedgeimp.h b/nx-X11/programs/Xserver/fb/fbedgeimp.h
new file mode 100644
index 000000000..6b363d7ce
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbedgeimp.h
@@ -0,0 +1,143 @@
+/*
+ * $Id: fbedgeimp.h,v 1.4 2005/08/30 03:05:21 anholt Exp $
+ *
+ * Copyright © 2004 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef rasterizeSpan
+#endif
+
+static void
+rasterizeEdges (FbBits *buf,
+ int width,
+ int stride,
+ RenderEdge *l,
+ RenderEdge *r,
+ xFixed t,
+ xFixed b)
+{
+ xFixed y = t;
+ FbBits *line;
+
+ line = buf + xFixedToInt (y) * stride;
+
+ for (;;)
+ {
+ xFixed lx, rx;
+ int lxi, rxi;
+
+ /* clip X */
+ lx = l->x;
+ if (lx < 0)
+ lx = 0;
+ rx = r->x;
+ if (xFixedToInt (rx) >= width)
+ rx = IntToxFixed (width);
+
+ /* Skip empty (or backwards) sections */
+ if (rx > lx)
+ {
+
+ /* Find pixel bounds for span */
+ lxi = xFixedToInt (lx);
+ rxi = xFixedToInt (rx);
+
+#if N_BITS == 1
+ {
+ FbBits *a = line;
+ FbBits startmask, endmask;
+ int nmiddle;
+ int width = rxi - lxi;
+ int x = lxi;
+
+ a += x >> FB_SHIFT;
+ x &= FB_MASK;
+
+ FbMaskBits (x, width, startmask, nmiddle, endmask);
+ if (startmask)
+ *a++ |= startmask;
+ while (nmiddle--)
+ *a++ = FB_ALLONES;
+ if (endmask)
+ *a |= endmask;
+ }
+#else
+ {
+ DefineAlpha(line,lxi);
+ int lxs, rxs;
+
+ /* Sample coverage for edge pixels */
+ lxs = RenderSamplesX (lx, N_BITS);
+ rxs = RenderSamplesX (rx, N_BITS);
+
+ /* Add coverage across row */
+ if (lxi == rxi)
+ {
+ AddAlpha (rxs - lxs);
+ }
+ else
+ {
+ int xi;
+
+ AddAlpha (N_X_FRAC(N_BITS) - lxs);
+ StepAlpha;
+ for (xi = lxi + 1; xi < rxi; xi++)
+ {
+ AddAlpha (N_X_FRAC(N_BITS));
+ StepAlpha;
+ }
+ /* Do not add in a 0 alpha here. This check is necessary
+ * to avoid a buffer overrun when rx is exactly on a pixel
+ * boundary.
+ */
+ if (rxs != 0)
+ AddAlpha (rxs);
+ }
+ }
+#endif
+ }
+
+ if (y == b)
+ break;
+
+#if N_BITS > 1
+ if (xFixedFrac (y) != Y_FRAC_LAST(N_BITS))
+ {
+ RenderEdgeStepSmall (l);
+ RenderEdgeStepSmall (r);
+ y += STEP_Y_SMALL(N_BITS);
+ }
+ else
+#endif
+ {
+ RenderEdgeStepBig (l);
+ RenderEdgeStepBig (r);
+ y += STEP_Y_BIG(N_BITS);
+ line += stride;
+ }
+ }
+}
+
+#undef rasterizeSpan
diff --git a/nx-X11/programs/Xserver/fb/fbfill.c b/nx-X11/programs/Xserver/fb/fbfill.c
new file mode 100644
index 000000000..c61ff3b4c
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbfill.c
@@ -0,0 +1,222 @@
+/*
+ * Id: fbfill.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbfill.c,v 1.5 2003/01/29 00:43:33 torrey Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include "fbmmx.h"
+
+void
+fbFill (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ switch (pGC->fillStyle) {
+ case FillSolid:
+#ifdef USE_MMX
+ if (!pPriv->and && fbHaveMMX())
+ if (fbSolidFillmmx (pDrawable, x, y, width, height, pPriv->xor))
+ return;
+#endif
+ fbSolid (dst + (y + dstYoff) * dstStride,
+ dstStride,
+ (x + dstXoff) * dstBpp,
+ dstBpp,
+ width * dstBpp, height,
+ pPriv->and, pPriv->xor);
+ break;
+ case FillStippled:
+ case FillOpaqueStippled: {
+ PixmapPtr pStip = pGC->stipple;
+ int stipWidth = pStip->drawable.width;
+ int stipHeight = pStip->drawable.height;
+
+ if (dstBpp == 1)
+ {
+ int alu;
+ FbBits *stip;
+ FbStride stipStride;
+ int stipBpp;
+ int stipXoff, stipYoff; /* XXX assumed to be zero */
+
+ if (pGC->fillStyle == FillStippled)
+ alu = FbStipple1Rop(pGC->alu,pGC->fgPixel);
+ else
+ alu = FbOpaqueStipple1Rop(pGC->alu,pGC->fgPixel,pGC->bgPixel);
+ fbGetDrawable (&pStip->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff);
+ fbTile (dst + (y + dstYoff) * dstStride,
+ dstStride,
+ x + dstXoff,
+ width, height,
+ stip,
+ stipStride,
+ stipWidth,
+ stipHeight,
+ alu,
+ pPriv->pm,
+ dstBpp,
+
+ (pGC->patOrg.x + pDrawable->x + dstXoff),
+ pGC->patOrg.y + pDrawable->y - y);
+ }
+ else
+ {
+ FbStip *stip;
+ FbStride stipStride;
+ int stipBpp;
+ int stipXoff, stipYoff; /* XXX assumed to be zero */
+ FbBits fgand, fgxor, bgand, bgxor;
+
+ fgand = pPriv->and;
+ fgxor = pPriv->xor;
+ if (pGC->fillStyle == FillStippled)
+ {
+ bgand = fbAnd(GXnoop,(FbBits) 0,FB_ALLONES);
+ bgxor = fbXor(GXnoop,(FbBits) 0,FB_ALLONES);
+ }
+ else
+ {
+ bgand = pPriv->bgand;
+ bgxor = pPriv->bgxor;
+ }
+
+ fbGetStipDrawable (&pStip->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff);
+ fbStipple (dst + (y + dstYoff) * dstStride,
+ dstStride,
+ (x + dstXoff) * dstBpp,
+ dstBpp,
+ width * dstBpp, height,
+ stip,
+ stipStride,
+ stipWidth,
+ stipHeight,
+ pPriv->evenStipple,
+ fgand, fgxor,
+ bgand, bgxor,
+ pGC->patOrg.x + pDrawable->x + dstXoff,
+ pGC->patOrg.y + pDrawable->y - y);
+ }
+ break;
+ }
+ case FillTiled: {
+ PixmapPtr pTile = pGC->tile.pixmap;
+ FbBits *tile;
+ FbStride tileStride;
+ int tileBpp;
+ int tileWidth;
+ int tileHeight;
+ int tileXoff, tileYoff; /* XXX assumed to be zero */
+
+ fbGetDrawable (&pTile->drawable, tile, tileStride, tileBpp, tileXoff, tileYoff);
+ tileWidth = pTile->drawable.width;
+ tileHeight = pTile->drawable.height;
+ fbTile (dst + (y + dstYoff) * dstStride,
+ dstStride,
+ (x + dstXoff) * dstBpp,
+ width * dstBpp, height,
+ tile,
+ tileStride,
+ tileWidth * tileBpp,
+ tileHeight,
+ pGC->alu,
+ pPriv->pm,
+ dstBpp,
+ (pGC->patOrg.x + pDrawable->x + dstXoff) * dstBpp,
+ pGC->patOrg.y + pDrawable->y - y);
+ break;
+ }
+ }
+ fbValidateDrawable (pDrawable);
+}
+
+void
+fbSolidBoxClipped (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int x1,
+ int y1,
+ int x2,
+ int y2,
+ FbBits and,
+ FbBits xor)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ BoxPtr pbox;
+ int nbox;
+ int partX1, partX2, partY1, partY2;
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip);
+ nbox--;
+ pbox++)
+ {
+ partX1 = pbox->x1;
+ if (partX1 < x1)
+ partX1 = x1;
+
+ partX2 = pbox->x2;
+ if (partX2 > x2)
+ partX2 = x2;
+
+ if (partX2 <= partX1)
+ continue;
+
+ partY1 = pbox->y1;
+ if (partY1 < y1)
+ partY1 = y1;
+
+ partY2 = pbox->y2;
+ if (partY2 > y2)
+ partY2 = y2;
+
+ if (partY2 <= partY1)
+ continue;
+
+ fbSolid (dst + (partY1 + dstYoff) * dstStride,
+ dstStride,
+ (partX1 + dstXoff) * dstBpp,
+ dstBpp,
+
+ (partX2 - partX1) * dstBpp,
+ (partY2 - partY1),
+ and, xor);
+ }
+}
diff --git a/nx-X11/programs/Xserver/fb/fbfillrect.c b/nx-X11/programs/Xserver/fb/fbfillrect.c
new file mode 100644
index 000000000..2a60da165
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbfillrect.c
@@ -0,0 +1,115 @@
+/*
+ * Id: fbfillrect.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbfillrect.c,v 1.1 1999/11/19 13:53:43 hohndel Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbPolyFillRect(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nrect,
+ xRectangle *prect)
+{
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ register BoxPtr pbox;
+ BoxPtr pextent;
+ int extentX1, extentX2, extentY1, extentY2;
+ int fullX1, fullX2, fullY1, fullY2;
+ int partX1, partX2, partY1, partY2;
+ int xorg, yorg;
+ int n;
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, pClip);
+ extentX1 = pextent->x1;
+ extentY1 = pextent->y1;
+ extentX2 = pextent->x2;
+ extentY2 = pextent->y2;
+ while (nrect--)
+ {
+ fullX1 = prect->x + xorg;
+ fullY1 = prect->y + yorg;
+ fullX2 = fullX1 + (int) prect->width;
+ fullY2 = fullY1 + (int) prect->height;
+ prect++;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+
+ if (fullY1 < extentY1)
+ fullY1 = extentY1;
+
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullY2 > extentY2)
+ fullY2 = extentY2;
+
+ if ((fullX1 >= fullX2) || (fullY1 >= fullY2))
+ continue;
+ n = REGION_NUM_RECTS (pClip);
+ if (n == 1)
+ {
+ fbFill (pDrawable,
+ pGC,
+ fullX1, fullY1, fullX2-fullX1, fullY2-fullY1);
+ }
+ else
+ {
+ pbox = REGION_RECTS(pClip);
+ /*
+ * clip the rectangle to each box in the clip region
+ * this is logically equivalent to calling Intersect()
+ */
+ while(n--)
+ {
+ partX1 = pbox->x1;
+ if (partX1 < fullX1)
+ partX1 = fullX1;
+ partY1 = pbox->y1;
+ if (partY1 < fullY1)
+ partY1 = fullY1;
+ partX2 = pbox->x2;
+ if (partX2 > fullX2)
+ partX2 = fullX2;
+ partY2 = pbox->y2;
+ if (partY2 > fullY2)
+ partY2 = fullY2;
+
+ pbox++;
+
+ if (partX1 < partX2 && partY1 < partY2)
+ fbFill (pDrawable, pGC,
+ partX1, partY1,
+ partX2 - partX1, partY2 - partY1);
+ }
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/fb/fbfillsp.c b/nx-X11/programs/Xserver/fb/fbfillsp.c
new file mode 100644
index 000000000..e2bb71e3a
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbfillsp.c
@@ -0,0 +1,103 @@
+/*
+ * Id: fbfillsp.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbfillsp.c,v 1.1 1999/11/19 13:53:43 hohndel Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbFillSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted)
+{
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ BoxPtr pextent, pbox;
+ int nbox;
+ int extentX1, extentX2, extentY1, extentY2;
+ int fullX1, fullX2, fullY1;
+ int partX1, partX2;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, pClip);
+ extentX1 = pextent->x1;
+ extentY1 = pextent->y1;
+ extentX2 = pextent->x2;
+ extentY2 = pextent->y2;
+ while (n--)
+ {
+ fullX1 = ppt->x;
+ fullY1 = ppt->y;
+ fullX2 = fullX1 + (int) *pwidth;
+ ppt++;
+ pwidth++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ nbox = REGION_NUM_RECTS (pClip);
+ if (nbox == 1)
+ {
+ fbFill (pDrawable,
+ pGC,
+ fullX1, fullY1, fullX2-fullX1, 1);
+ }
+ else
+ {
+ pbox = REGION_RECTS(pClip);
+ while(nbox--)
+ {
+ if (pbox->y1 <= fullY1 && fullY1 < pbox->y2)
+ {
+ partX1 = pbox->x1;
+ if (partX1 < fullX1)
+ partX1 = fullX1;
+ partX2 = pbox->x2;
+ if (partX2 > fullX2)
+ partX2 = fullX2;
+ if (partX2 > partX1)
+ {
+ fbFill (pDrawable, pGC,
+ partX1, fullY1,
+ partX2 - partX1, 1);
+ }
+ }
+ pbox++;
+ }
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/fb/fbgc.c b/nx-X11/programs/Xserver/fb/fbgc.c
new file mode 100644
index 000000000..fdd7a319c
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbgc.c
@@ -0,0 +1,317 @@
+/*
+ * Id: fbgc.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XdotOrg: xc/programs/Xserver/fb/fbgc.c,v 1.5 2005/07/03 07:01:23 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbgc.c,v 1.14 2003/12/18 15:22:32 alanh Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#ifdef IN_MODULE
+#include "xf86_ansic.h"
+#endif
+
+const GCFuncs fbGCFuncs = {
+ fbValidateGC,
+ miChangeGC,
+ miCopyGC,
+ miDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip,
+};
+
+const GCOps fbGCOps = {
+ fbFillSpans,
+ fbSetSpans,
+ fbPutImage,
+ fbCopyArea,
+ fbCopyPlane,
+ fbPolyPoint,
+ fbPolyLine,
+ fbPolySegment,
+ fbPolyRectangle,
+ fbPolyArc,
+ miFillPolygon,
+ fbPolyFillRect,
+ fbPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ fbImageGlyphBlt,
+ fbPolyGlyphBlt,
+ fbPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+Bool
+fbCreateGC(GCPtr pGC)
+{
+ pGC->clientClip = NULL;
+ pGC->clientClipType = CT_NONE;
+
+ pGC->ops = (GCOps *) &fbGCOps;
+ pGC->funcs = (GCFuncs *) &fbGCFuncs;
+
+ /* fb wants to translate before scan conversion */
+ pGC->miTranslate = 1;
+
+ fbGetRotatedPixmap(pGC) = 0;
+ fbGetExpose(pGC) = 1;
+ fbGetFreeCompClip(pGC) = 0;
+ fbGetCompositeClip(pGC) = 0;
+ fbGetGCPrivate(pGC)->bpp = BitsPerPixel (pGC->depth);
+ return TRUE;
+}
+
+/*
+ * Pad pixmap to FB_UNIT bits wide
+ */
+void
+fbPadPixmap (PixmapPtr pPixmap)
+{
+ int width;
+ FbBits *bits;
+ FbBits b;
+ FbBits mask;
+ int height;
+ int w;
+
+ width = pPixmap->drawable.width * pPixmap->drawable.bitsPerPixel;
+ bits = pPixmap->devPrivate.ptr;
+ height = pPixmap->drawable.height;
+ mask = FbBitsMask (0, width);
+ while (height--)
+ {
+ b = *bits & mask;
+ w = width;
+ while (w < FB_UNIT)
+ {
+ b = b | FbScrRight(b, w);
+ w <<= 1;
+ }
+ *bits++ = b;
+ }
+}
+
+/*
+ * Verify that 'bits' repeats every 'len' bits
+ */
+static Bool
+fbBitsRepeat (FbBits bits, int len, int width)
+{
+ FbBits mask = FbBitsMask(0, len);
+ FbBits orig = bits & mask;
+ int i;
+
+ if (width > FB_UNIT)
+ width = FB_UNIT;
+ for (i = 0; i < width / len; i++)
+ {
+ if ((bits & mask) != orig)
+ return FALSE;
+ bits = FbScrLeft(bits,len);
+ }
+ return TRUE;
+}
+
+/*
+ * Check whether an entire bitmap line is a repetition of
+ * the first 'len' bits
+ */
+static Bool
+fbLineRepeat (FbBits *bits, int len, int width)
+{
+ FbBits first = bits[0];
+
+ if (!fbBitsRepeat (first, len, width))
+ return FALSE;
+ width = (width + FB_UNIT-1) >> FB_SHIFT;
+ bits++;
+ while (--width)
+ if (*bits != first)
+ return FALSE;
+ return TRUE;
+}
+
+/*
+ * The even stipple code wants the first FB_UNIT/bpp bits on
+ * each scanline to represent the entire stipple
+ */
+static Bool
+fbCanEvenStipple (PixmapPtr pStipple, int bpp)
+{
+ int len = FB_UNIT / bpp;
+ FbBits *bits;
+ int stride;
+ int stip_bpp;
+ int stipXoff, stipYoff;
+ int h;
+
+ /* can't even stipple 24bpp drawables */
+ if ((bpp & (bpp-1)) != 0)
+ return FALSE;
+ /* make sure the stipple width is a multiple of the even stipple width */
+ if (pStipple->drawable.width % len != 0)
+ return FALSE;
+ fbGetDrawable (&pStipple->drawable, bits, stride, stip_bpp, stipXoff, stipYoff);
+ h = pStipple->drawable.height;
+ /* check to see that the stipple repeats horizontally */
+ while (h--)
+ {
+ if (!fbLineRepeat (bits, len, pStipple->drawable.width))
+ return FALSE;
+ bits += stride;
+ }
+ return TRUE;
+}
+
+void
+fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ FbBits mask;
+
+ pGC->lastWinOrg.x = pDrawable->x;
+ pGC->lastWinOrg.y = pDrawable->y;
+
+ /*
+ * if the client clip is different or moved OR the subwindowMode has
+ * changed OR the window's clip has changed since the last validation
+ * we need to recompute the composite clip
+ */
+
+ if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
+ (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
+ )
+ {
+ miComputeCompositeClip (pGC, pDrawable);
+ pPriv->oneRect = REGION_NUM_RECTS(fbGetCompositeClip(pGC)) == 1;
+ }
+
+#ifdef FB_24_32BIT
+ if (pPriv->bpp != pDrawable->bitsPerPixel)
+ {
+ changes |= GCStipple|GCForeground|GCBackground|GCPlaneMask;
+ pPriv->bpp = pDrawable->bitsPerPixel;
+ }
+ if ((changes & GCTile) && fbGetRotatedPixmap(pGC))
+ {
+ (*pGC->pScreen->DestroyPixmap) (fbGetRotatedPixmap(pGC));
+ fbGetRotatedPixmap(pGC) = 0;
+ }
+
+ if (pGC->fillStyle == FillTiled)
+ {
+ PixmapPtr pOldTile, pNewTile;
+
+ pOldTile = pGC->tile.pixmap;
+ if (pOldTile->drawable.bitsPerPixel != pDrawable->bitsPerPixel)
+ {
+ pNewTile = fbGetRotatedPixmap(pGC);
+ if (!pNewTile || pNewTile ->drawable.bitsPerPixel != pDrawable->bitsPerPixel)
+ {
+ if (pNewTile)
+ (*pGC->pScreen->DestroyPixmap) (pNewTile);
+ pNewTile = fb24_32ReformatTile (pOldTile, pDrawable->bitsPerPixel);
+ }
+ if (pNewTile)
+ {
+ fbGetRotatedPixmap(pGC) = pOldTile;
+ pGC->tile.pixmap = pNewTile;
+ changes |= GCTile;
+ }
+ }
+ }
+#endif
+ if (changes & GCTile)
+ {
+ if (!pGC->tileIsPixel &&
+ FbEvenTile (pGC->tile.pixmap->drawable.width *
+ pDrawable->bitsPerPixel))
+ fbPadPixmap (pGC->tile.pixmap);
+ }
+ if (changes & GCStipple)
+ {
+ pPriv->evenStipple = FALSE;
+
+ if (pGC->stipple) {
+
+ /* can we do an even stipple ?? */
+ if (FbEvenStip (pGC->stipple->drawable.width,
+ pDrawable->bitsPerPixel) &&
+ (fbCanEvenStipple (pGC->stipple, pDrawable->bitsPerPixel)))
+ pPriv->evenStipple = TRUE;
+
+ if (pGC->stipple->drawable.width * pDrawable->bitsPerPixel < FB_UNIT)
+ fbPadPixmap (pGC->stipple);
+ }
+ }
+ /*
+ * Recompute reduced rop values
+ */
+ if (changes & (GCForeground|GCBackground|GCPlaneMask|GCFunction))
+ {
+ int s;
+ FbBits depthMask;
+
+ mask = FbFullMask(pDrawable->bitsPerPixel);
+ depthMask = FbFullMask(pDrawable->depth);
+
+ pPriv->fg = pGC->fgPixel & mask;
+ pPriv->bg = pGC->bgPixel & mask;
+
+ if ((pGC->planemask & depthMask) == depthMask)
+ pPriv->pm = mask;
+ else
+ pPriv->pm = pGC->planemask & mask;
+
+ s = pDrawable->bitsPerPixel;
+ while (s < FB_UNIT)
+ {
+ pPriv->fg |= pPriv->fg << s;
+ pPriv->bg |= pPriv->bg << s;
+ pPriv->pm |= pPriv->pm << s;
+ s <<= 1;
+ }
+ pPriv->and = fbAnd(pGC->alu, pPriv->fg, pPriv->pm);
+ pPriv->xor = fbXor(pGC->alu, pPriv->fg, pPriv->pm);
+ pPriv->bgand = fbAnd(pGC->alu, pPriv->bg, pPriv->pm);
+ pPriv->bgxor = fbXor(pGC->alu, pPriv->bg, pPriv->pm);
+ }
+ if (changes & GCDashList)
+ {
+ unsigned short n = pGC->numInDashList;
+ unsigned char *dash = pGC->dash;
+ unsigned int dashLength = 0;
+
+ while (n--)
+ dashLength += (unsigned int ) *dash++;
+ pPriv->dashLength = dashLength;
+ }
+}
diff --git a/nx-X11/programs/Xserver/fb/fbgetsp.c b/nx-X11/programs/Xserver/fb/fbgetsp.c
new file mode 100644
index 000000000..7c58dcb82
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbgetsp.c
@@ -0,0 +1,88 @@
+/*
+ * Id: fbgetsp.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbgetsp.c,v 1.5 2000/05/06 21:09:33 keithp Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbGetSpans(DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pchardstStart)
+{
+ FbBits *src, *dst;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ int xoff;
+
+ /*
+ * XFree86 DDX empties the root borderClip when the VT is
+ * switched away; this checks for that case
+ */
+ if (!fbDrawableEnabled(pDrawable))
+ return;
+
+#ifdef FB_24_32BIT
+ if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
+ {
+ fb24_32GetSpans (pDrawable, wMax, ppt, pwidth, nspans, pchardstStart);
+ return;
+ }
+#endif
+
+ fbGetDrawable (pDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+
+ while (nspans--)
+ {
+ xoff = (int) (((long) pchardstStart) & (FB_MASK >> 3));
+ dst = (FbBits *) (pchardstStart - xoff);
+ xoff <<= 3;
+ fbBlt (src + (ppt->y + srcYoff) * srcStride, srcStride,
+ (ppt->x + srcXoff) * srcBpp,
+
+ dst,
+ 1,
+ xoff,
+
+ *pwidth * srcBpp,
+ 1,
+
+ GXcopy,
+ FB_ALLONES,
+ srcBpp,
+
+ FALSE,
+ FALSE);
+ pchardstStart += PixmapBytePad(*pwidth, pDrawable->depth);
+ ppt++;
+ pwidth++;
+ }
+}
diff --git a/nx-X11/programs/Xserver/fb/fbglyph.c b/nx-X11/programs/Xserver/fb/fbglyph.c
new file mode 100644
index 000000000..46334db50
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbglyph.c
@@ -0,0 +1,479 @@
+/*
+ * $XdotOrg: xc/programs/Xserver/fb/fbglyph.c,v 1.5 2005/07/03 07:01:23 daniels Exp $
+ * $XFree86: xc/programs/Xserver/fb/fbglyph.c,v 1.12tsi Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+
+#define dummyScreen screenInfo.screens[0]
+
+Bool
+fbGlyphIn (RegionPtr pRegion,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ BoxRec box;
+ BoxPtr pExtents = REGION_EXTENTS (dummyScreen, pRegion);
+
+ /*
+ * Check extents by hand to avoid 16 bit overflows
+ */
+ if (x < (int) pExtents->x1)
+ return FALSE;
+ if ((int) pExtents->x2 < x + width)
+ return FALSE;
+ if (y < (int) pExtents->y1)
+ return FALSE;
+ if ((int) pExtents->y2 < y + height)
+ return FALSE;
+ box.x1 = x;
+ box.x2 = x + width;
+ box.y1 = y;
+ box.y2 = y + height;
+ return RECT_IN_REGION (dummyScreen, pRegion, &box) == rgnIN;
+}
+
+#ifdef FB_24BIT
+#ifndef FBNOPIXADDR
+
+#define WRITE1(d,n,fg) ((d)[n] = (CARD8) fg)
+#define WRITE2(d,n,fg) (*(CARD16 *) &(d[n]) = (CARD16) fg)
+#define WRITE4(d,n,fg) (*(CARD32 *) &(d[n]) = (CARD32) fg)
+#if FB_UNIT == 6 && IMAGE_BYTE_ORDER == LSBFirst
+#define WRITE8(d) (*(FbBits *) &(d[0]) = fg)
+#else
+#define WRITE8(d) WRITE4(d,0,_ABCA), WRITE4(d,4,_BCAB)
+#endif
+
+/*
+ * This is a bit tricky, but it's brief. Write 12 bytes worth
+ * of dest, which is four pixels, at a time. This gives constant
+ * code for each pattern as they're always aligned the same
+ *
+ * a b c d a b c d a b c d bytes
+ * A B C A B C A B C A B C pixels
+ *
+ * f0 f1 f2
+ * A B C A B C A B C A B C pixels LSB
+ * C A B C A B C A B C A B pixels MSB
+ *
+ * LSB MSB
+ * A f0 f1
+ * B f1 f2
+ * C f2 f0
+ * A B f0 f2
+ * B C f1 f0
+ * C A f2 f1
+ * A B C A f0 f1
+ * B C A B f1 f2
+ * C A B C f2 f0
+ */
+
+#undef _A
+#undef _B
+#undef _C
+#undef _AB
+#undef _BC
+#undef _CA
+#undef _ABCA
+#undef _BCAB
+#undef _CABC
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define _A f1
+#define _B f2
+#define _C f0
+#define _AB f2
+#define _BC f0
+#define _CA f1
+#define _ABCA f1
+#define _BCAB f2
+#define _CABC f0
+#define CASE(a,b,c,d) ((a << 3) | (b << 2) | (c << 1) | d)
+#else
+#define _A f0
+#define _B f1
+#define _C f2
+#define _AB f0
+#define _BC f1
+#define _CA f2
+#define _ABCA f0
+#define _BCAB f1
+#define _CABC f2
+#define CASE(a,b,c,d) (a | (b << 1) | (c << 2) | (d << 3))
+#endif
+
+void
+fbGlyph24 (FbBits *dstBits,
+ FbStride dstStride,
+ int dstBpp,
+ FbStip *stipple,
+ FbBits fg,
+ int x,
+ int height)
+{
+ int lshift;
+ FbStip bits;
+ CARD8 *dstLine;
+ CARD8 *dst;
+ FbStip f0, f1, f2;
+ int n;
+ int shift;
+
+ f0 = fg;
+ f1 = FbRot24(f0,16);
+ f2 = FbRot24(f0,8);
+
+ dstLine = (CARD8 *) dstBits;
+ dstLine += (x & ~3) * 3;
+ dstStride *= (sizeof (FbBits) / sizeof (CARD8));
+ shift = x & 3;
+ lshift = 4 - shift;
+ while (height--)
+ {
+ bits = *stipple++;
+ n = lshift;
+ dst = dstLine;
+ while (bits)
+ {
+ switch (FbStipMoveLsb (FbLeftStipBits (bits, n), 4, n)) {
+ case CASE(0,0,0,0):
+ break;
+ case CASE(1,0,0,0):
+ WRITE2(dst,0,_AB);
+ WRITE1(dst,2,_C);
+ break;
+ case CASE(0,1,0,0):
+ WRITE1(dst,3,_A);
+ WRITE2(dst,4,_BC);
+ break;
+ case CASE(1,1,0,0):
+ WRITE4(dst,0,_ABCA);
+ WRITE2(dst,4,_BC);
+ break;
+ case CASE(0,0,1,0):
+ WRITE2(dst,6,_AB);
+ WRITE1(dst,8,_C);
+ break;
+ case CASE(1,0,1,0):
+ WRITE2(dst,0,_AB);
+ WRITE1(dst,2,_C);
+
+ WRITE2(dst,6,_AB);
+ WRITE1(dst,8,_C);
+ break;
+ case CASE(0,1,1,0):
+ WRITE1(dst,3,_A);
+ WRITE4(dst,4,_BCAB);
+ WRITE1(dst,8,_C);
+ break;
+ case CASE(1,1,1,0):
+ WRITE8(dst);
+ WRITE1(dst,8,_C);
+ break;
+ case CASE(0,0,0,1):
+ WRITE1(dst,9,_A);
+ WRITE2(dst,10,_BC);
+ break;
+ case CASE(1,0,0,1):
+ WRITE2(dst,0,_AB);
+ WRITE1(dst,2,_C);
+
+ WRITE1(dst,9,_A);
+ WRITE2(dst,10,_BC);
+ break;
+ case CASE(0,1,0,1):
+ WRITE1(dst,3,_A);
+ WRITE2(dst,4,_BC);
+
+ WRITE1(dst,9,_A);
+ WRITE2(dst,10,_BC);
+ break;
+ case CASE(1,1,0,1):
+ WRITE4(dst,0,_ABCA);
+ WRITE2(dst,4,_BC);
+
+ WRITE1(dst,9,_A);
+ WRITE2(dst,10,_BC);
+ break;
+ case CASE(0,0,1,1):
+ WRITE2(dst,6,_AB);
+ WRITE4(dst,8,_CABC);
+ break;
+ case CASE(1,0,1,1):
+ WRITE2(dst,0,_AB);
+ WRITE1(dst,2,_C);
+
+ WRITE2(dst,6,_AB);
+ WRITE4(dst,8,_CABC);
+ break;
+ case CASE(0,1,1,1):
+ WRITE1(dst,3,_A);
+ WRITE4(dst,4,_BCAB);
+ WRITE4(dst,8,_CABC);
+ break;
+ case CASE(1,1,1,1):
+ WRITE8(dst);
+ WRITE4(dst,8,_CABC);
+ break;
+ }
+ bits = FbStipLeft (bits, n);
+ n = 4;
+ dst += 12;
+ }
+ dstLine += dstStride;
+ }
+}
+#endif
+#endif
+
+void
+fbPolyGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ CharInfoPtr pci;
+ unsigned char *pglyph; /* pointer bits in glyph */
+ int gx, gy;
+ int gWidth, gHeight; /* width and height of glyph */
+ FbStride gStride; /* stride of glyph */
+#ifndef FBNOPIXADDR
+ void (*glyph) (FbBits *,
+ FbStride,
+ int,
+ FbStip *,
+ FbBits,
+ int,
+ int);
+ FbBits *dst = 0;
+ FbStride dstStride = 0;
+ int dstBpp = 0;
+ int dstXoff = 0, dstYoff = 0;
+
+ glyph = 0;
+ if (pGC->fillStyle == FillSolid && pPriv->and == 0)
+ {
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ switch (dstBpp) {
+ case 8: glyph = fbGlyph8; break;
+ case 16: glyph = fbGlyph16; break;
+#ifdef FB_24BIT
+ case 24: glyph = fbGlyph24; break;
+#endif
+ case 32: glyph = fbGlyph32; break;
+ }
+ }
+#endif
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ while (nglyph--)
+ {
+ pci = *ppci++;
+ pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ gWidth = GLYPHWIDTHPIXELS(pci);
+ gHeight = GLYPHHEIGHTPIXELS(pci);
+ if (gWidth && gHeight)
+ {
+ gx = x + pci->metrics.leftSideBearing;
+ gy = y - pci->metrics.ascent;
+#ifndef FBNOPIXADDR
+ if (glyph && gWidth <= sizeof (FbStip) * 8 &&
+ fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
+ {
+ (*glyph) (dst + (gy + dstYoff) * dstStride,
+ dstStride,
+ dstBpp,
+ (FbStip *) pglyph,
+ pPriv->xor,
+ gx + dstXoff,
+ gHeight);
+ }
+ else
+#endif
+ {
+ gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
+ fbPushImage (pDrawable,
+ pGC,
+
+ (FbStip *) pglyph,
+ gStride,
+ 0,
+
+ gx,
+ gy,
+ gWidth, gHeight);
+ }
+ }
+ x += pci->metrics.characterWidth;
+ }
+}
+
+
+void
+fbImageGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppciInit,
+ pointer pglyphBase)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ CharInfoPtr *ppci;
+ CharInfoPtr pci;
+ unsigned char *pglyph; /* pointer bits in glyph */
+ int gWidth, gHeight; /* width and height of glyph */
+ FbStride gStride; /* stride of glyph */
+ Bool opaque;
+ int n;
+ int gx, gy;
+#ifndef FBNOPIXADDR
+ void (*glyph) (FbBits *,
+ FbStride,
+ int,
+ FbStip *,
+ FbBits,
+ int,
+ int);
+ FbBits *dst = 0;
+ FbStride dstStride = 0;
+ int dstBpp = 0;
+ int dstXoff = 0, dstYoff = 0;
+
+ glyph = 0;
+ if (pPriv->and == 0)
+ {
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ switch (dstBpp) {
+ case 8: glyph = fbGlyph8; break;
+ case 16: glyph = fbGlyph16; break;
+#ifdef FB_24BIT
+ case 24: glyph = fbGlyph24; break;
+#endif
+ case 32: glyph = fbGlyph32; break;
+ }
+ }
+#endif
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ if (TERMINALFONT (pGC->font)
+#ifndef FBNOPIXADDR
+ && !glyph
+#endif
+ )
+ {
+ opaque = TRUE;
+ }
+ else
+ {
+ int xBack, widthBack;
+ int yBack, heightBack;
+
+ ppci = ppciInit;
+ n = nglyph;
+ widthBack = 0;
+ while (n--)
+ widthBack += (*ppci++)->metrics.characterWidth;
+
+ xBack = x;
+ if (widthBack < 0)
+ {
+ xBack += widthBack;
+ widthBack = -widthBack;
+ }
+ yBack = y - FONTASCENT(pGC->font);
+ heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+ fbSolidBoxClipped (pDrawable,
+ fbGetCompositeClip(pGC),
+ xBack,
+ yBack,
+ xBack + widthBack,
+ yBack + heightBack,
+ fbAnd(GXcopy,pPriv->bg,pPriv->pm),
+ fbXor(GXcopy,pPriv->bg,pPriv->pm));
+ opaque = FALSE;
+ }
+
+ ppci = ppciInit;
+ while (nglyph--)
+ {
+ pci = *ppci++;
+ pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ gWidth = GLYPHWIDTHPIXELS(pci);
+ gHeight = GLYPHHEIGHTPIXELS(pci);
+ if (gWidth && gHeight)
+ {
+ gx = x + pci->metrics.leftSideBearing;
+ gy = y - pci->metrics.ascent;
+#ifndef FBNOPIXADDR
+ if (glyph && gWidth <= sizeof (FbStip) * 8 &&
+ fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
+ {
+ (*glyph) (dst + (gy + dstYoff) * dstStride,
+ dstStride,
+ dstBpp,
+ (FbStip *) pglyph,
+ pPriv->fg,
+ gx + dstXoff,
+ gHeight);
+ }
+ else
+#endif
+ {
+ gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
+ fbPutXYImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pPriv->fg,
+ pPriv->bg,
+ pPriv->pm,
+ GXcopy,
+ opaque,
+
+ gx,
+ gy,
+ gWidth, gHeight,
+
+ (FbStip *) pglyph,
+ gStride,
+ 0);
+ }
+ }
+ x += pci->metrics.characterWidth;
+ }
+}
diff --git a/nx-X11/programs/Xserver/fb/fbimage.c b/nx-X11/programs/Xserver/fb/fbimage.c
new file mode 100644
index 000000000..96bd8cf95
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbimage.c
@@ -0,0 +1,368 @@
+/*
+ * Id: fbimage.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbimage.c,v 1.7 2001/05/29 04:54:09 keithp Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#ifdef XFree86LOADER
+#include "xf86.h"
+#include "xf86_ansic.h"
+#endif
+
+
+void
+fbPutImage (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int depth,
+ int x,
+ int y,
+ int w,
+ int h,
+ int leftPad,
+ int format,
+ char *pImage)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ unsigned long i;
+ FbStride srcStride;
+ FbStip *src = (FbStip *) pImage;
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ switch (format)
+ {
+ case XYBitmap:
+ srcStride = BitmapBytePad(w + leftPad) / sizeof (FbStip);
+ fbPutXYImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pPriv->fg,
+ pPriv->bg,
+ pPriv->pm,
+ pGC->alu,
+ TRUE,
+ x, y, w, h,
+ src,
+ srcStride,
+ leftPad);
+ break;
+ case XYPixmap:
+ srcStride = BitmapBytePad(w + leftPad) / sizeof (FbStip);
+ for (i = 1 << (pDrawable->depth - 1); i; i >>= 1)
+ {
+ if (i & pGC->planemask)
+ {
+ fbPutXYImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ FB_ALLONES,
+ 0,
+ fbReplicatePixel (i, pDrawable->bitsPerPixel),
+ pGC->alu,
+ TRUE,
+ x, y, w, h,
+ src,
+ srcStride,
+ leftPad);
+ src += srcStride * h;
+ }
+ }
+ break;
+ case ZPixmap:
+#ifdef FB_24_32BIT
+ if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
+ {
+ srcStride = PixmapBytePad(w, pDrawable->depth);
+ fb24_32PutZImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pGC->alu,
+ (FbBits) pGC->planemask,
+ x, y, w, h,
+ (CARD8 *) pImage,
+ srcStride);
+ }
+ else
+#endif
+ {
+ srcStride = PixmapBytePad(w, pDrawable->depth) / sizeof (FbStip);
+ fbPutZImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pGC->alu,
+ pPriv->pm,
+ x, y, w, h,
+ src, srcStride);
+ }
+ }
+}
+
+void
+fbPutZImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int alu,
+ FbBits pm,
+ int x,
+ int y,
+ int width,
+ int height,
+ FbStip *src,
+ FbStride srcStride)
+{
+ FbStip *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ int nbox;
+ BoxPtr pbox;
+ int x1, y1, x2, y2;
+
+ fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ for (nbox = REGION_NUM_RECTS (pClip),
+ pbox = REGION_RECTS(pClip);
+ nbox--;
+ pbox++)
+ {
+ x1 = x;
+ y1 = y;
+ x2 = x + width;
+ y2 = y + height;
+ if (x1 < pbox->x1)
+ x1 = pbox->x1;
+ if (y1 < pbox->y1)
+ y1 = pbox->y1;
+ if (x2 > pbox->x2)
+ x2 = pbox->x2;
+ if (y2 > pbox->y2)
+ y2 = pbox->y2;
+ if (x1 >= x2 || y1 >= y2)
+ continue;
+ fbBltStip (src + (y1 - y) * srcStride,
+ srcStride,
+ (x1 - x) * dstBpp,
+
+ dst + (y1 + dstYoff) * dstStride,
+ dstStride,
+ (x1 + dstXoff) * dstBpp,
+
+ (x2 - x1) * dstBpp,
+ (y2 - y1),
+
+ alu,
+ pm,
+ dstBpp);
+ }
+}
+
+void
+fbPutXYImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ FbBits fg,
+ FbBits bg,
+ FbBits pm,
+ int alu,
+ Bool opaque,
+
+ int x,
+ int y,
+ int width,
+ int height,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ int nbox;
+ BoxPtr pbox;
+ int x1, y1, x2, y2;
+ FbBits fgand = 0, fgxor = 0, bgand = 0, bgxor = 0;
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ if (dstBpp == 1)
+ {
+ if (opaque)
+ alu = FbOpaqueStipple1Rop(alu,fg,bg);
+ else
+ alu = FbStipple1Rop(alu,fg);
+ }
+ else
+ {
+ fgand = fbAnd(alu,fg,pm);
+ fgxor = fbXor(alu,fg,pm);
+ if (opaque)
+ {
+ bgand = fbAnd(alu,bg,pm);
+ bgxor = fbXor(alu,bg,pm);
+ }
+ else
+ {
+ bgand = fbAnd(GXnoop,(FbBits)0,FB_ALLONES);
+ bgxor = fbXor(GXnoop,(FbBits)0,FB_ALLONES);
+ }
+ }
+
+ for (nbox = REGION_NUM_RECTS (pClip),
+ pbox = REGION_RECTS(pClip);
+ nbox--;
+ pbox++)
+ {
+ x1 = x;
+ y1 = y;
+ x2 = x + width;
+ y2 = y + height;
+ if (x1 < pbox->x1)
+ x1 = pbox->x1;
+ if (y1 < pbox->y1)
+ y1 = pbox->y1;
+ if (x2 > pbox->x2)
+ x2 = pbox->x2;
+ if (y2 > pbox->y2)
+ y2 = pbox->y2;
+ if (x1 >= x2 || y1 >= y2)
+ continue;
+ if (dstBpp == 1)
+ {
+ fbBltStip (src + (y1 - y) * srcStride,
+ srcStride,
+ (x1 - x) + srcX,
+
+ (FbStip *) (dst + (y1 + dstYoff) * dstStride),
+ FbBitsStrideToStipStride(dstStride),
+ (x1 + dstXoff) * dstBpp,
+
+ (x2 - x1) * dstBpp,
+ (y2 - y1),
+
+ alu,
+ pm,
+ dstBpp);
+ }
+ else
+ {
+ fbBltOne (src + (y1 - y) * srcStride,
+ srcStride,
+ (x1 - x) + srcX,
+
+ dst + (y1 + dstYoff) * dstStride,
+ dstStride,
+ (x1 + dstXoff) * dstBpp,
+ dstBpp,
+
+ (x2 - x1) * dstBpp,
+ (y2 - y1),
+
+ fgand, fgxor, bgand, bgxor);
+ }
+ }
+}
+
+void
+fbGetImage (DrawablePtr pDrawable,
+ int x,
+ int y,
+ int w,
+ int h,
+ unsigned int format,
+ unsigned long planeMask,
+ char *d)
+{
+ FbBits *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ FbStip *dst;
+ FbStride dstStride;
+
+ /*
+ * XFree86 DDX empties the root borderClip when the VT is
+ * switched away; this checks for that case
+ */
+ if (!fbDrawableEnabled(pDrawable))
+ return;
+
+#ifdef FB_24_32BIT
+ if (format == ZPixmap &&
+ pDrawable->bitsPerPixel != BitsPerPixel (pDrawable->depth))
+ {
+ fb24_32GetImage (pDrawable, x, y, w, h, format, planeMask, d);
+ return;
+ }
+#endif
+
+ fbGetDrawable (pDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ dst = (FbStip *) d;
+ if (format == ZPixmap || srcBpp == 1)
+ {
+ FbBits pm;
+
+ pm = fbReplicatePixel (planeMask, srcBpp);
+ dstStride = PixmapBytePad(w, pDrawable->depth);
+ if (pm != FB_ALLONES)
+ memset (d, 0, dstStride * h);
+ dstStride /= sizeof (FbStip);
+ fbBltStip ((FbStip *) (src + (y + srcYoff) * srcStride),
+ FbBitsStrideToStipStride(srcStride),
+ (x + srcXoff) * srcBpp,
+
+ dst,
+ dstStride,
+ 0,
+
+ w * srcBpp, h,
+
+ GXcopy,
+ pm,
+ srcBpp);
+ }
+ else
+ {
+ dstStride = BitmapBytePad(w) / sizeof (FbStip);
+ fbBltPlane (src + (y + srcYoff) * srcStride,
+ srcStride,
+ (x + srcXoff) * srcBpp,
+ srcBpp,
+
+ dst,
+ dstStride,
+ 0,
+
+ w * srcBpp, h,
+
+ fbAndStip(GXcopy,FB_STIP_ALLONES,FB_STIP_ALLONES),
+ fbXorStip(GXcopy,FB_STIP_ALLONES,FB_STIP_ALLONES),
+ fbAndStip(GXcopy,0,FB_STIP_ALLONES),
+ fbXorStip(GXcopy,0,FB_STIP_ALLONES),
+ planeMask);
+ }
+}
diff --git a/nx-X11/programs/Xserver/fb/fbline.c b/nx-X11/programs/Xserver/fb/fbline.c
new file mode 100644
index 000000000..8e99dd99f
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbline.c
@@ -0,0 +1,177 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbZeroLine (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ppt)
+{
+ int x1, y1, x2, y2;
+ int x, y;
+ int dashOffset;
+
+ x = pDrawable->x;
+ y = pDrawable->y;
+ x1 = ppt->x;
+ y1 = ppt->y;
+ dashOffset = pGC->dashOffset;
+ while (--npt)
+ {
+ ++ppt;
+ x2 = ppt->x;
+ y2 = ppt->y;
+ if (mode == CoordModePrevious)
+ {
+ x2 += x1;
+ y2 += y1;
+ }
+ fbSegment (pDrawable, pGC, x1 + x, y1 + y,
+ x2 + x, y2 + y,
+ npt == 1 && pGC->capStyle != CapNotLast,
+ &dashOffset);
+ x1 = x2;
+ y1 = y2;
+ }
+}
+
+void
+fbZeroSegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSegs)
+{
+ int dashOffset;
+ int x, y;
+ Bool drawLast = pGC->capStyle != CapNotLast;
+
+ x = pDrawable->x;
+ y = pDrawable->y;
+ while (nseg--)
+ {
+ dashOffset = pGC->dashOffset;
+ fbSegment (pDrawable, pGC,
+ pSegs->x1 + x, pSegs->y1 + y,
+ pSegs->x2 + x, pSegs->y2 + y,
+ drawLast,
+ &dashOffset);
+ pSegs++;
+ }
+}
+
+void
+fbFixCoordModePrevious (int npt,
+ DDXPointPtr ppt)
+{
+ int x, y;
+
+ x = ppt->x;
+ y = ppt->y;
+ npt--;
+ while (npt--)
+ {
+ ppt++;
+ x = (ppt->x += x);
+ y = (ppt->y += y);
+ }
+}
+
+void
+fbPolyLine (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ppt)
+{
+ void (*line) (DrawablePtr, GCPtr, int mode, int npt, DDXPointPtr ppt);
+
+ if (pGC->lineWidth == 0)
+ {
+ line = fbZeroLine;
+#ifndef FBNOPIXADDR
+ if (pGC->fillStyle == FillSolid &&
+ pGC->lineStyle == LineSolid &&
+ REGION_NUM_RECTS (fbGetCompositeClip(pGC)) == 1)
+ {
+ switch (pDrawable->bitsPerPixel) {
+ case 8: line = fbPolyline8; break;
+ case 16: line = fbPolyline16; break;
+#ifdef FB_24BIT
+ case 24: line = fbPolyline24; break;
+#endif
+ case 32: line = fbPolyline32; break;
+ }
+ }
+#endif
+ }
+ else
+ {
+ if (pGC->lineStyle != LineSolid)
+ line = miWideDash;
+ else
+ line = miWideLine;
+ }
+ (*line) (pDrawable, pGC, mode, npt, ppt);
+}
+
+void
+fbPolySegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pseg)
+{
+ void (*seg) (DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pseg);
+
+ if (pGC->lineWidth == 0)
+ {
+ seg = fbZeroSegment;
+#ifndef FBNOPIXADDR
+ if (pGC->fillStyle == FillSolid &&
+ pGC->lineStyle == LineSolid &&
+ REGION_NUM_RECTS (fbGetCompositeClip(pGC)) == 1)
+ {
+ switch (pDrawable->bitsPerPixel) {
+ case 8: seg = fbPolySegment8; break;
+ case 16: seg = fbPolySegment16; break;
+#ifdef FB_24BIT
+ case 24: seg = fbPolySegment24; break;
+#endif
+ case 32: seg = fbPolySegment32; break;
+ }
+ }
+#endif
+ }
+ else
+ {
+ seg = miPolySegment;
+ }
+ (*seg) (pDrawable, pGC, nseg, pseg);
+}
diff --git a/nx-X11/programs/Xserver/fb/fbmmx.c b/nx-X11/programs/Xserver/fb/fbmmx.c
new file mode 100644
index 000000000..fef5c3820
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbmmx.c
@@ -0,0 +1,2276 @@
+/*
+ * Copyright © 2004, 2005 Red Hat, Inc.
+ * Copyright © 2004 Nicholas Miell
+ * Copyright © 2005 Trolltech AS
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Red Hat not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. Red Hat makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Søren Sandmann (sandmann@redhat.com)
+ * Minor Improvements: Nicholas Miell (nmiell@gmail.com)
+ * MMX code paths for fbcompose.c by Lars Knoll (lars@trolltech.com)
+ *
+ * Based on work by Owen Taylor
+ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef USE_MMX
+
+#if defined(__amd64__) || defined(__x86_64__)
+#define USE_SSE
+#endif
+
+#include <mmintrin.h>
+#include <xmmintrin.h> /* for _mm_shuffle_pi16 and _MM_SHUFFLE */
+
+#ifdef RENDER
+
+#include "fb.h"
+#include "fbmmx.h"
+
+#include "picturestr.h"
+#include "mipict.h"
+#include "fbpict.h"
+
+#define noVERBOSE
+
+#ifdef VERBOSE
+#define CHECKPOINT() ErrorF ("at %s %d\n", __FUNCTION__, __LINE__)
+#else
+#define CHECKPOINT()
+#endif
+
+/* Notes about writing mmx code
+ *
+ * give memory operands as the second operand. If you give it as the
+ * first, gcc will first load it into a register, then use that
+ * register
+ *
+ * ie. use
+ *
+ * _mm_mullo_pi16 (x, mmx_constant);
+ *
+ * not
+ *
+ * _mm_mullo_pi16 (mmx_constant, x);
+ *
+ * Also try to minimize dependencies. i.e. when you need a value, try
+ * to calculate it from a value that was calculated as early as
+ * possible.
+ */
+
+/* --------------- MMX primitivess ------------------------------------ */
+
+typedef unsigned long long ullong;
+
+typedef struct
+{
+ ullong mmx_4x00ff;
+ ullong mmx_4x0080;
+ ullong mmx_565_rgb;
+ ullong mmx_565_unpack_multiplier;
+ ullong mmx_565_r;
+ ullong mmx_565_g;
+ ullong mmx_565_b;
+ ullong mmx_mask_0;
+ ullong mmx_mask_1;
+ ullong mmx_mask_2;
+ ullong mmx_mask_3;
+ ullong mmx_full_alpha;
+ ullong mmx_ffff0000ffff0000;
+ ullong mmx_0000ffff00000000;
+ ullong mmx_000000000000ffff;
+} MMXData;
+
+static const MMXData c =
+{
+ .mmx_4x00ff = 0x00ff00ff00ff00ffULL,
+ .mmx_4x0080 = 0x0080008000800080ULL,
+ .mmx_565_rgb = 0x000001f0003f001fULL,
+ .mmx_565_r = 0x000000f800000000ULL,
+ .mmx_565_g = 0x0000000000fc0000ULL,
+ .mmx_565_b = 0x00000000000000f8ULL,
+ .mmx_mask_0 = 0xffffffffffff0000ULL,
+ .mmx_mask_1 = 0xffffffff0000ffffULL,
+ .mmx_mask_2 = 0xffff0000ffffffffULL,
+ .mmx_mask_3 = 0x0000ffffffffffffULL,
+ .mmx_full_alpha = 0x00ff000000000000ULL,
+ .mmx_565_unpack_multiplier = 0x0000008404100840ULL,
+ .mmx_ffff0000ffff0000 = 0xffff0000ffff0000ULL,
+ .mmx_0000ffff00000000 = 0x0000ffff00000000ULL,
+ .mmx_000000000000ffff = 0x000000000000ffffULL,
+};
+
+#define MC(x) ((__m64) c.mmx_##x)
+
+static __inline__ __m64
+shift (__m64 v, int s)
+{
+ if (s > 0)
+ return _mm_slli_si64 (v, s);
+ else if (s < 0)
+ return _mm_srli_si64 (v, -s);
+ else
+ return v;
+}
+
+static __inline__ __m64
+negate (__m64 mask)
+{
+ return _mm_xor_si64 (mask, MC(4x00ff));
+}
+
+static __inline__ __m64
+pix_multiply (__m64 a, __m64 b)
+{
+ __m64 res;
+
+ res = _mm_mullo_pi16 (a, b);
+ res = _mm_adds_pu16 (res, MC(4x0080));
+ res = _mm_adds_pu16 (res, _mm_srli_pi16 (res, 8));
+ res = _mm_srli_pi16 (res, 8);
+
+ return res;
+}
+
+static __inline__ __m64
+pix_add (__m64 a, __m64 b)
+{
+ return _mm_adds_pu8 (a, b);
+}
+
+#ifdef USE_SSE
+
+static __inline__ __m64
+expand_alpha (__m64 pixel)
+{
+ return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE(3, 3, 3, 3));
+}
+
+static __inline__ __m64
+expand_alpha_rev (__m64 pixel)
+{
+ return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE(0, 0, 0, 0));
+}
+
+static __inline__ __m64
+invert_colors (__m64 pixel)
+{
+ return _mm_shuffle_pi16 (pixel, _MM_SHUFFLE(3, 0, 1, 2));
+}
+
+#else
+
+static __inline__ __m64
+expand_alpha (__m64 pixel)
+{
+ __m64 t1, t2;
+
+ t1 = shift (pixel, -48);
+ t2 = shift (t1, 16);
+ t1 = _mm_or_si64 (t1, t2);
+ t2 = shift (t1, 32);
+ t1 = _mm_or_si64 (t1, t2);
+
+ return t1;
+}
+
+static __inline__ __m64
+expand_alpha_rev (__m64 pixel)
+{
+ __m64 t1, t2;
+
+ /* move alpha to low 16 bits and zero the rest */
+ t1 = shift (pixel, 48);
+ t1 = shift (t1, -48);
+
+ t2 = shift (t1, 16);
+ t1 = _mm_or_si64 (t1, t2);
+ t2 = shift (t1, 32);
+ t1 = _mm_or_si64 (t1, t2);
+
+ return t1;
+}
+
+static __inline__ __m64
+invert_colors (__m64 pixel)
+{
+ __m64 x, y, z;
+
+ x = y = z = pixel;
+
+ x = _mm_and_si64 (x, MC(ffff0000ffff0000));
+ y = _mm_and_si64 (y, MC(000000000000ffff));
+ z = _mm_and_si64 (z, MC(0000ffff00000000));
+
+ y = shift (y, 32);
+ z = shift (z, -32);
+
+ x = _mm_or_si64 (x, y);
+ x = _mm_or_si64 (x, z);
+
+ return x;
+}
+
+#endif
+
+static __inline__ __m64
+over (__m64 src, __m64 srca, __m64 dest)
+{
+ return _mm_adds_pu8 (src, pix_multiply(dest, negate(srca)));
+}
+
+static __inline__ __m64
+over_rev_non_pre (__m64 src, __m64 dest)
+{
+ __m64 srca = expand_alpha (src);
+ __m64 srcfaaa = _mm_or_si64 (srca, MC(full_alpha));
+
+ return over(pix_multiply(invert_colors(src), srcfaaa), srca, dest);
+}
+
+static __inline__ __m64
+in (__m64 src,
+ __m64 mask)
+{
+ return pix_multiply (src, mask);
+}
+
+static __inline__ __m64
+in_over (__m64 src,
+ __m64 srca,
+ __m64 mask,
+ __m64 dest)
+{
+ return over(in(src, mask), pix_multiply(srca, mask), dest);
+}
+
+static __inline__ __m64
+load8888 (CARD32 v)
+{
+ return _mm_unpacklo_pi8 (_mm_cvtsi32_si64 (v), _mm_setzero_si64());
+}
+
+static __inline__ __m64
+pack8888 (__m64 lo, __m64 hi)
+{
+ return _mm_packs_pu16 (lo, hi);
+}
+
+static __inline__ CARD32
+store8888 (__m64 v)
+{
+ return _mm_cvtsi64_si32(pack8888(v, _mm_setzero_si64()));
+}
+
+/* Expand 16 bits positioned at @pos (0-3) of a mmx register into
+ *
+ * 00RR00GG00BB
+ *
+ * --- Expanding 565 in the low word ---
+ *
+ * m = (m << (32 - 3)) | (m << (16 - 5)) | m;
+ * m = m & (01f0003f001f);
+ * m = m * (008404100840);
+ * m = m >> 8;
+ *
+ * Note the trick here - the top word is shifted by another nibble to
+ * avoid it bumping into the middle word
+ */
+static __inline__ __m64
+expand565 (__m64 pixel, int pos)
+{
+ __m64 p = pixel;
+ __m64 t1, t2;
+
+ /* move pixel to low 16 bit and zero the rest */
+ p = shift (shift (p, (3 - pos) * 16), -48);
+
+ t1 = shift (p, 36 - 11);
+ t2 = shift (p, 16 - 5);
+
+ p = _mm_or_si64 (t1, p);
+ p = _mm_or_si64 (t2, p);
+ p = _mm_and_si64 (p, MC(565_rgb));
+
+ pixel = _mm_mullo_pi16 (p, MC(565_unpack_multiplier));
+ return _mm_srli_pi16 (pixel, 8);
+}
+
+static __inline__ __m64
+expand8888 (__m64 in, int pos)
+{
+ if (pos == 0)
+ return _mm_unpacklo_pi8 (in, _mm_setzero_si64());
+ else
+ return _mm_unpackhi_pi8 (in, _mm_setzero_si64());
+}
+
+static __inline__ __m64
+pack565 (__m64 pixel, __m64 target, int pos)
+{
+ __m64 p = pixel;
+ __m64 t = target;
+ __m64 r, g, b;
+
+ r = _mm_and_si64 (p, MC(565_r));
+ g = _mm_and_si64 (p, MC(565_g));
+ b = _mm_and_si64 (p, MC(565_b));
+
+ r = shift (r, - (32 - 8) + pos * 16);
+ g = shift (g, - (16 - 3) + pos * 16);
+ b = shift (b, - (0 + 3) + pos * 16);
+
+ if (pos == 0)
+ t = _mm_and_si64 (t, MC(mask_0));
+ else if (pos == 1)
+ t = _mm_and_si64 (t, MC(mask_1));
+ else if (pos == 2)
+ t = _mm_and_si64 (t, MC(mask_2));
+ else if (pos == 3)
+ t = _mm_and_si64 (t, MC(mask_3));
+
+ p = _mm_or_si64 (r, t);
+ p = _mm_or_si64 (g, p);
+
+ return _mm_or_si64 (b, p);
+}
+
+static __inline__ __m64
+pix_add_mul (__m64 x, __m64 a, __m64 y, __m64 b)
+{
+ x = _mm_mullo_pi16 (x, a);
+ y = _mm_mullo_pi16 (y, b);
+ x = _mm_srli_pi16(x, 1);
+ y = _mm_srli_pi16(y, 1);
+ x = _mm_adds_pu16 (x, y);
+ x = _mm_adds_pu16 (x, _mm_srli_pi16 (x, 8));
+ x = _mm_adds_pu16 (x, MC(4x0080));
+ x = _mm_srli_pi16 (x, 7);
+
+ return x;
+}
+
+/* --------------- MMX code patch for fbcompose.c --------------------- */
+
+static FASTCALL void
+mmxCombineMaskU (CARD32 *src, const CARD32 *mask, int width)
+{
+ const CARD32 *end = mask + width;
+ while (mask < end) {
+ __m64 a = load8888(*mask);
+ __m64 s = load8888(*src);
+ a = expand_alpha(a);
+ s = pix_multiply(s, a);
+ *src = store8888(s);
+ ++src;
+ ++mask;
+ }
+ _mm_empty();
+}
+
+
+static FASTCALL void
+mmxCombineOverU (CARD32 *dest, const CARD32 *src, int width)
+{
+ const CARD32 *end = dest + width;
+
+ while (dest < end) {
+ __m64 s, sa;
+ s = load8888(*src);
+ sa = expand_alpha(s);
+ *dest = store8888(over(s, sa, load8888(*dest)));
+ ++dest;
+ ++src;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineOverReverseU (CARD32 *dest, const CARD32 *src, int width)
+{
+ const CARD32 *end = dest + width;
+
+ while (dest < end) {
+ __m64 d, da;
+ d = load8888(*dest);
+ da = expand_alpha(d);
+ *dest = store8888(over (d, da, load8888(*src)));
+ ++dest;
+ ++src;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineInU (CARD32 *dest, const CARD32 *src, int width)
+{
+ const CARD32 *end = dest + width;
+
+ while (dest < end) {
+ __m64 x, a;
+ x = load8888(*src);
+ a = load8888(*dest);
+ a = expand_alpha(a);
+ x = pix_multiply(x, a);
+ *dest = store8888(x);
+ ++dest;
+ ++src;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineInReverseU (CARD32 *dest, const CARD32 *src, int width)
+{
+ const CARD32 *end = dest + width;
+
+ while (dest < end) {
+ __m64 x, a;
+ x = load8888(*dest);
+ a = load8888(*src);
+ a = expand_alpha(a);
+ x = pix_multiply(x, a);
+ *dest = store8888(x);
+ ++dest;
+ ++src;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineOutU (CARD32 *dest, const CARD32 *src, int width)
+{
+ const CARD32 *end = dest + width;
+
+ while (dest < end) {
+ __m64 x, a;
+ x = load8888(*src);
+ a = load8888(*dest);
+ a = expand_alpha(a);
+ a = negate(a);
+ x = pix_multiply(x, a);
+ *dest = store8888(x);
+ ++dest;
+ ++src;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineOutReverseU (CARD32 *dest, const CARD32 *src, int width)
+{
+ const CARD32 *end = dest + width;
+
+ while (dest < end) {
+ __m64 x, a;
+ x = load8888(*dest);
+ a = load8888(*src);
+ a = expand_alpha(a);
+ a = negate(a);
+ x = pix_multiply(x, a);
+ *dest = store8888(x);
+ ++dest;
+ ++src;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineAtopU (CARD32 *dest, const CARD32 *src, int width)
+{
+ const CARD32 *end = dest + width;
+
+ while (dest < end) {
+ __m64 s, da, d, sia;
+ s = load8888(*src);
+ d = load8888(*dest);
+ sia = expand_alpha(s);
+ sia = negate(sia);
+ da = expand_alpha(d);
+ s = pix_add_mul (s, da, d, sia);
+ *dest = store8888(s);
+ ++dest;
+ ++src;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineAtopReverseU (CARD32 *dest, const CARD32 *src, int width)
+{
+ const CARD32 *end;
+
+ end = dest + width;
+
+ while (dest < end) {
+ __m64 s, dia, d, sa;
+ s = load8888(*src);
+ d = load8888(*dest);
+ sa = expand_alpha(s);
+ dia = expand_alpha(d);
+ dia = negate(dia);
+ s = pix_add_mul (s, dia, d, sa);
+ *dest = store8888(s);
+ ++dest;
+ ++src;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineXorU (CARD32 *dest, const CARD32 *src, int width)
+{
+ const CARD32 *end = dest + width;
+
+ while (dest < end) {
+ __m64 s, dia, d, sia;
+ s = load8888(*src);
+ d = load8888(*dest);
+ sia = expand_alpha(s);
+ dia = expand_alpha(d);
+ sia = negate(sia);
+ dia = negate(dia);
+ s = pix_add_mul (s, dia, d, sia);
+ *dest = store8888(s);
+ ++dest;
+ ++src;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineAddU (CARD32 *dest, const CARD32 *src, int width)
+{
+ const CARD32 *end = dest + width;
+ while (dest < end) {
+ __m64 s, d;
+ s = load8888(*src);
+ d = load8888(*dest);
+ s = pix_add(s, d);
+ *dest = store8888(s);
+ ++dest;
+ ++src;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineSaturateU (CARD32 *dest, const CARD32 *src, int width)
+{
+ const CARD32 *end = dest + width;
+ while (dest < end) {
+ CARD32 s = *src;
+ CARD32 d = *dest;
+ __m64 ms = load8888(s);
+ __m64 md = load8888(d);
+ CARD32 sa = s >> 24;
+ CARD32 da = ~d >> 24;
+
+ if (sa > da) {
+ __m64 msa = load8888(FbIntDiv(da, sa));
+ msa = expand_alpha(msa);
+ ms = pix_multiply(ms, msa);
+ }
+ md = pix_add(md, ms);
+ *dest = store8888(md);
+ ++src;
+ ++dest;
+ }
+ _mm_empty();
+}
+
+
+static FASTCALL void
+mmxCombineSrcC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ const CARD32 *end = src + width;
+ while (src < end) {
+ __m64 a = load8888(*mask);
+ __m64 s = load8888(*src);
+ s = pix_multiply(s, a);
+ *dest = store8888(s);
+ ++src;
+ ++mask;
+ ++dest;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineOverC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ const CARD32 *end = src + width;
+ while (src < end) {
+ __m64 a = load8888(*mask);
+ __m64 s = load8888(*src);
+ __m64 d = load8888(*dest);
+ __m64 sa = expand_alpha(s);
+
+ *dest = store8888(in_over (s, sa, a, d));
+
+ ++src;
+ ++dest;
+ ++mask;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineOverReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ const CARD32 *end = src + width;
+ while (src < end) {
+ __m64 a = load8888(*mask);
+ __m64 s = load8888(*src);
+ __m64 d = load8888(*dest);
+ __m64 da = expand_alpha(d);
+
+ *dest = store8888(over (d, da, in (s, a)));
+
+ ++src;
+ ++dest;
+ ++mask;
+ }
+ _mm_empty();
+}
+
+
+static FASTCALL void
+mmxCombineInC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ const CARD32 *end = src + width;
+ while (src < end) {
+ __m64 a = load8888(*mask);
+ __m64 s = load8888(*src);
+ __m64 d = load8888(*dest);
+ __m64 da = expand_alpha(d);
+ s = pix_multiply(s, a);
+ s = pix_multiply(s, da);
+ *dest = store8888(s);
+ ++src;
+ ++dest;
+ ++mask;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineInReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ const CARD32 *end = src + width;
+ while (src < end) {
+ __m64 a = load8888(*mask);
+ __m64 s = load8888(*src);
+ __m64 d = load8888(*dest);
+ __m64 sa = expand_alpha(s);
+ a = pix_multiply(a, sa);
+ d = pix_multiply(d, a);
+ *dest = store8888(d);
+ ++src;
+ ++dest;
+ ++mask;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineOutC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ const CARD32 *end = src + width;
+ while (src < end) {
+ __m64 a = load8888(*mask);
+ __m64 s = load8888(*src);
+ __m64 d = load8888(*dest);
+ __m64 da = expand_alpha(d);
+ da = negate(da);
+ s = pix_multiply(s, a);
+ s = pix_multiply(s, da);
+ *dest = store8888(s);
+ ++src;
+ ++dest;
+ ++mask;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineOutReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ const CARD32 *end = src + width;
+ while (src < end) {
+ __m64 a = load8888(*mask);
+ __m64 s = load8888(*src);
+ __m64 d = load8888(*dest);
+ __m64 sa = expand_alpha(s);
+ a = pix_multiply(a, sa);
+ a = negate(a);
+ d = pix_multiply(d, a);
+ *dest = store8888(d);
+ ++src;
+ ++dest;
+ ++mask;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineAtopC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ const CARD32 *end = src + width;
+ while (src < end) {
+ __m64 a = load8888(*mask);
+ __m64 s = load8888(*src);
+ __m64 d = load8888(*dest);
+ __m64 da = expand_alpha(d);
+ __m64 sa = expand_alpha(s);
+ s = pix_multiply(s, a);
+ a = pix_multiply(a, sa);
+ a = negate(a);
+ d = pix_add_mul (d, a, s, da);
+ *dest = store8888(d);
+ ++src;
+ ++dest;
+ ++mask;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineAtopReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ const CARD32 *end = src + width;
+ while (src < end) {
+ __m64 a = load8888(*mask);
+ __m64 s = load8888(*src);
+ __m64 d = load8888(*dest);
+ __m64 da = expand_alpha(d);
+ __m64 sa = expand_alpha(s);
+ s = pix_multiply(s, a);
+ a = pix_multiply(a, sa);
+ da = negate(da);
+ d = pix_add_mul (d, a, s, da);
+ *dest = store8888(d);
+ ++src;
+ ++dest;
+ ++mask;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineXorC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ const CARD32 *end = src + width;
+ while (src < end) {
+ __m64 a = load8888(*mask);
+ __m64 s = load8888(*src);
+ __m64 d = load8888(*dest);
+ __m64 da = expand_alpha(d);
+ __m64 sa = expand_alpha(s);
+ s = pix_multiply(s, a);
+ a = pix_multiply(a, sa);
+ da = negate(da);
+ a = negate(a);
+ d = pix_add_mul (d, a, s, da);
+ *dest = store8888(d);
+ ++src;
+ ++dest;
+ ++mask;
+ }
+ _mm_empty();
+}
+
+static FASTCALL void
+mmxCombineAddC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
+{
+ const CARD32 *end = src + width;
+ while (src < end) {
+ __m64 a = load8888(*mask);
+ __m64 s = load8888(*src);
+ __m64 d = load8888(*dest);
+ s = pix_multiply(s, a);
+ d = pix_add(s, d);
+ *dest = store8888(d);
+ ++src;
+ ++dest;
+ ++mask;
+ }
+ _mm_empty();
+}
+
+extern FbComposeFunctions composeFunctions;
+
+void fbComposeSetupMMX(void)
+{
+ /* check if we have MMX support and initialize accordingly */
+ if (fbHaveMMX()) {
+ composeFunctions.combineU[PictOpOver] = mmxCombineOverU;
+ composeFunctions.combineU[PictOpOverReverse] = mmxCombineOverReverseU;
+ composeFunctions.combineU[PictOpIn] = mmxCombineInU;
+ composeFunctions.combineU[PictOpInReverse] = mmxCombineInReverseU;
+ composeFunctions.combineU[PictOpOut] = mmxCombineOutU;
+ composeFunctions.combineU[PictOpOutReverse] = mmxCombineOutReverseU;
+ composeFunctions.combineU[PictOpAtop] = mmxCombineAtopU;
+ composeFunctions.combineU[PictOpAtopReverse] = mmxCombineAtopReverseU;
+ composeFunctions.combineU[PictOpXor] = mmxCombineXorU;
+ composeFunctions.combineU[PictOpAdd] = mmxCombineAddU;
+ composeFunctions.combineU[PictOpSaturate] = mmxCombineSaturateU;
+
+ composeFunctions.combineC[PictOpSrc] = mmxCombineSrcC;
+ composeFunctions.combineC[PictOpOver] = mmxCombineOverC;
+ composeFunctions.combineC[PictOpOverReverse] = mmxCombineOverReverseC;
+ composeFunctions.combineC[PictOpIn] = mmxCombineInC;
+ composeFunctions.combineC[PictOpInReverse] = mmxCombineInReverseC;
+ composeFunctions.combineC[PictOpOut] = mmxCombineOutC;
+ composeFunctions.combineC[PictOpOutReverse] = mmxCombineOutReverseC;
+ composeFunctions.combineC[PictOpAtop] = mmxCombineAtopC;
+ composeFunctions.combineC[PictOpAtopReverse] = mmxCombineAtopReverseC;
+ composeFunctions.combineC[PictOpXor] = mmxCombineXorC;
+ composeFunctions.combineC[PictOpAdd] = mmxCombineAddC;
+
+ composeFunctions.combineMaskU = mmxCombineMaskU;
+ }
+}
+
+
+/* ------------------ MMX code paths called from fbpict.c ----------------------- */
+
+void
+fbCompositeSolid_nx8888mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 src;
+ CARD32 *dstLine, *dst;
+ CARD16 w;
+ FbStride dstStride;
+ __m64 vsrc, vsrca;
+
+ CHECKPOINT();
+
+ fbComposeGetSolid(pSrc, src, pDst->format);
+
+ if (src >> 24 == 0)
+ return;
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
+
+ vsrc = load8888 (src);
+ vsrca = expand_alpha (vsrc);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ w = width;
+
+ CHECKPOINT();
+
+ while (w && (unsigned long)dst & 7)
+ {
+ *dst = store8888(over(vsrc, vsrca, load8888(*dst)));
+
+ w--;
+ dst++;
+ }
+
+ while (w >= 2)
+ {
+ __m64 vdest;
+ __m64 dest0, dest1;
+
+ vdest = *(__m64 *)dst;
+
+ dest0 = over(vsrc, vsrca, expand8888(vdest, 0));
+ dest1 = over(vsrc, vsrca, expand8888(vdest, 1));
+
+ *(__m64 *)dst = pack8888(dest0, dest1);
+
+ dst += 2;
+ w -= 2;
+ }
+
+ CHECKPOINT();
+
+ while (w)
+ {
+ *dst = store8888(over(vsrc, vsrca, load8888(*dst)));
+
+ w--;
+ dst++;
+ }
+ }
+
+ _mm_empty();
+}
+
+void
+fbCompositeSolid_nx0565mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 src;
+ CARD16 *dstLine, *dst;
+ CARD16 w;
+ FbStride dstStride;
+ __m64 vsrc, vsrca;
+
+ CHECKPOINT();
+
+ fbComposeGetSolid(pSrc, src, pDst->format);
+
+ if (src >> 24 == 0)
+ return;
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
+
+ vsrc = load8888 (src);
+ vsrca = expand_alpha (vsrc);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ w = width;
+
+ CHECKPOINT();
+
+ while (w && (unsigned long)dst & 7)
+ {
+ ullong d = *dst;
+ __m64 vdest = expand565 ((__m64)d, 0);
+ vdest = pack565(over(vsrc, vsrca, vdest), vdest, 0);
+ *dst = (ullong)vdest;
+
+ w--;
+ dst++;
+ }
+
+ while (w >= 4)
+ {
+ __m64 vdest;
+
+ vdest = *(__m64 *)dst;
+
+ vdest = pack565 (over(vsrc, vsrca, expand565(vdest, 0)), vdest, 0);
+ vdest = pack565 (over(vsrc, vsrca, expand565(vdest, 1)), vdest, 1);
+ vdest = pack565 (over(vsrc, vsrca, expand565(vdest, 2)), vdest, 2);
+ vdest = pack565 (over(vsrc, vsrca, expand565(vdest, 3)), vdest, 3);
+
+ *(__m64 *)dst = vdest;
+
+ dst += 4;
+ w -= 4;
+ }
+
+ CHECKPOINT();
+
+ while (w)
+ {
+ ullong d = *dst;
+ __m64 vdest = expand565 ((__m64)d, 0);
+ vdest = pack565(over(vsrc, vsrca, vdest), vdest, 0);
+ *dst = (ullong)vdest;
+
+ w--;
+ dst++;
+ }
+ }
+
+ _mm_empty();
+}
+
+void
+fbCompositeSolidMask_nx8888x8888Cmmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 src, srca;
+ CARD32 *dstLine;
+ CARD32 *maskLine;
+ FbStride dstStride, maskStride;
+ __m64 vsrc, vsrca;
+
+ CHECKPOINT();
+
+ fbComposeGetSolid(pSrc, src, pDst->format);
+
+ srca = src >> 24;
+ if (srca == 0)
+ return;
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
+ fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
+
+ vsrc = load8888(src);
+ vsrca = expand_alpha(vsrc);
+
+ while (height--)
+ {
+ int twidth = width;
+ CARD32 *p = (CARD32 *)maskLine;
+ CARD32 *q = (CARD32 *)dstLine;
+
+ while (twidth && (unsigned long)q & 7)
+ {
+ CARD32 m = *(CARD32 *)p;
+
+ if (m)
+ {
+ __m64 vdest = load8888(*q);
+ vdest = in_over(vsrc, vsrca, load8888(m), vdest);
+ *q = store8888(vdest);
+ }
+
+ twidth--;
+ p++;
+ q++;
+ }
+
+ while (twidth >= 2)
+ {
+ CARD32 m0, m1;
+ m0 = *p;
+ m1 = *(p + 1);
+
+ if (m0 | m1)
+ {
+ __m64 dest0, dest1;
+ __m64 vdest = *(__m64 *)q;
+
+ dest0 = in_over(vsrc, vsrca, load8888(m0),
+ expand8888 (vdest, 0));
+ dest1 = in_over(vsrc, vsrca, load8888(m1),
+ expand8888 (vdest, 1));
+
+ *(__m64 *)q = pack8888(dest0, dest1);
+ }
+
+ p += 2;
+ q += 2;
+ twidth -= 2;
+ }
+
+ while (twidth)
+ {
+ CARD32 m = *(CARD32 *)p;
+
+ if (m)
+ {
+ __m64 vdest = load8888(*q);
+ vdest = in_over(vsrc, vsrca, load8888(m), vdest);
+ *q = store8888(vdest);
+ }
+
+ twidth--;
+ p++;
+ q++;
+ }
+
+ dstLine += dstStride;
+ maskLine += maskStride;
+ }
+
+ _mm_empty();
+}
+
+void
+fbCompositeSrc_8888x8x8888mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 *dstLine, *dst;
+ CARD32 *srcLine, *src;
+ CARD8 *maskLine;
+ CARD32 mask;
+ __m64 vmask;
+ FbStride dstStride, srcStride, maskStride;
+ CARD16 w;
+ __m64 srca;
+
+ CHECKPOINT();
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
+ fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
+ fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
+
+ mask = *maskLine << 24 | *maskLine << 16 | *maskLine << 8 | *maskLine;
+ vmask = load8888 (mask);
+ srca = MC(4x00ff);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ src = srcLine;
+ srcLine += srcStride;
+ w = width;
+
+ while (w && (unsigned long)dst & 7)
+ {
+ __m64 s = load8888 (*src);
+ __m64 d = load8888 (*dst);
+
+ *dst = store8888 (in_over (s, srca, vmask, d));
+
+ w--;
+ dst++;
+ src++;
+ }
+
+ while (w >= 16)
+ {
+ __m64 vd0 = *(__m64 *)(dst + 0);
+ __m64 vd1 = *(__m64 *)(dst + 2);
+ __m64 vd2 = *(__m64 *)(dst + 4);
+ __m64 vd3 = *(__m64 *)(dst + 6);
+ __m64 vd4 = *(__m64 *)(dst + 8);
+ __m64 vd5 = *(__m64 *)(dst + 10);
+ __m64 vd6 = *(__m64 *)(dst + 12);
+ __m64 vd7 = *(__m64 *)(dst + 14);
+
+ __m64 vs0 = *(__m64 *)(src + 0);
+ __m64 vs1 = *(__m64 *)(src + 2);
+ __m64 vs2 = *(__m64 *)(src + 4);
+ __m64 vs3 = *(__m64 *)(src + 6);
+ __m64 vs4 = *(__m64 *)(src + 8);
+ __m64 vs5 = *(__m64 *)(src + 10);
+ __m64 vs6 = *(__m64 *)(src + 12);
+ __m64 vs7 = *(__m64 *)(src + 14);
+
+ vd0 = (__m64)pack8888 (
+ in_over (expand8888 (vs0, 0), srca, vmask, expand8888 (vd0, 0)),
+ in_over (expand8888 (vs0, 1), srca, vmask, expand8888 (vd0, 1)));
+
+ vd1 = (__m64)pack8888 (
+ in_over (expand8888 (vs1, 0), srca, vmask, expand8888 (vd1, 0)),
+ in_over (expand8888 (vs1, 1), srca, vmask, expand8888 (vd1, 1)));
+
+ vd2 = (__m64)pack8888 (
+ in_over (expand8888 (vs2, 0), srca, vmask, expand8888 (vd2, 0)),
+ in_over (expand8888 (vs2, 1), srca, vmask, expand8888 (vd2, 1)));
+
+ vd3 = (__m64)pack8888 (
+ in_over (expand8888 (vs3, 0), srca, vmask, expand8888 (vd3, 0)),
+ in_over (expand8888 (vs3, 1), srca, vmask, expand8888 (vd3, 1)));
+
+ vd4 = (__m64)pack8888 (
+ in_over (expand8888 (vs4, 0), srca, vmask, expand8888 (vd4, 0)),
+ in_over (expand8888 (vs4, 1), srca, vmask, expand8888 (vd4, 1)));
+
+ vd5 = (__m64)pack8888 (
+ in_over (expand8888 (vs5, 0), srca, vmask, expand8888 (vd5, 0)),
+ in_over (expand8888 (vs5, 1), srca, vmask, expand8888 (vd5, 1)));
+
+ vd6 = (__m64)pack8888 (
+ in_over (expand8888 (vs6, 0), srca, vmask, expand8888 (vd6, 0)),
+ in_over (expand8888 (vs6, 1), srca, vmask, expand8888 (vd6, 1)));
+
+ vd7 = (__m64)pack8888 (
+ in_over (expand8888 (vs7, 0), srca, vmask, expand8888 (vd7, 0)),
+ in_over (expand8888 (vs7, 1), srca, vmask, expand8888 (vd7, 1)));
+
+ *(__m64 *)(dst + 0) = vd0;
+ *(__m64 *)(dst + 2) = vd1;
+ *(__m64 *)(dst + 4) = vd2;
+ *(__m64 *)(dst + 6) = vd3;
+ *(__m64 *)(dst + 8) = vd4;
+ *(__m64 *)(dst + 10) = vd5;
+ *(__m64 *)(dst + 12) = vd6;
+ *(__m64 *)(dst + 14) = vd7;
+
+ w -= 16;
+ dst += 16;
+ src += 16;
+ }
+
+ while (w)
+ {
+ __m64 s = load8888 (*src);
+ __m64 d = load8888 (*dst);
+
+ *dst = store8888 (in_over (s, srca, vmask, d));
+
+ w--;
+ dst++;
+ src++;
+ }
+ }
+
+ _mm_empty();
+}
+
+void
+fbCompositeSrc_8888x8888mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 *dstLine, *dst;
+ CARD32 *srcLine, *src;
+ FbStride dstStride, srcStride;
+ CARD16 w;
+ __m64 srca;
+
+ CHECKPOINT();
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
+ fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
+
+ srca = MC (4x00ff);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ src = srcLine;
+ srcLine += srcStride;
+ w = width;
+
+ while (w && (unsigned long)dst & 7)
+ {
+ __m64 s = load8888 (*src);
+ __m64 d = load8888 (*dst);
+
+ *dst = store8888 (over (s, expand_alpha (s), d));
+
+ w--;
+ dst++;
+ src++;
+ }
+
+ while (w >= 2)
+ {
+ __m64 vd = *(__m64 *)(dst + 0);
+ __m64 vs = *(__m64 *)(src + 0);
+ __m64 vs0 = expand8888 (vs, 0);
+ __m64 vs1 = expand8888 (vs, 1);
+
+ *(__m64 *)dst = (__m64)pack8888 (
+ over (vs0, expand_alpha (vs0), expand8888 (vd, 0)),
+ over (vs1, expand_alpha (vs1), expand8888 (vd, 1)));
+
+ w -= 2;
+ dst += 2;
+ src += 2;
+ }
+
+ while (w)
+ {
+ __m64 s = load8888 (*src);
+ __m64 d = load8888 (*dst);
+
+ *dst = store8888 (over (s, expand_alpha (s), d));
+
+ w--;
+ dst++;
+ src++;
+ }
+ }
+
+ _mm_empty();
+}
+
+void
+fbCompositeSolidMask_nx8x8888mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 src, srca;
+ CARD32 *dstLine, *dst;
+ CARD8 *maskLine, *mask;
+ FbStride dstStride, maskStride;
+ CARD16 w;
+ __m64 vsrc, vsrca;
+ ullong srcsrc;
+
+ CHECKPOINT();
+
+ fbComposeGetSolid(pSrc, src, pDst->format);
+
+ srca = src >> 24;
+ if (srca == 0)
+ return;
+
+ srcsrc = (unsigned long long)src << 32 | src;
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
+ fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
+
+ vsrc = load8888 (src);
+ vsrca = expand_alpha (vsrc);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ mask = maskLine;
+ maskLine += maskStride;
+ w = width;
+
+ CHECKPOINT();
+
+ while (w && (unsigned long)dst & 7)
+ {
+ ullong m = *mask;
+
+ if (m)
+ {
+ __m64 vdest = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m), load8888(*dst));
+ *dst = store8888(vdest);
+ }
+
+ w--;
+ mask++;
+ dst++;
+ }
+
+ CHECKPOINT();
+
+ while (w >= 2)
+ {
+ ullong m0, m1;
+ m0 = *mask;
+ m1 = *(mask + 1);
+
+ if (srca == 0xff && (m0 & m1) == 0xff)
+ {
+ *(unsigned long long *)dst = srcsrc;
+ }
+ else if (m0 | m1)
+ {
+ __m64 vdest;
+ __m64 dest0, dest1;
+
+ vdest = *(__m64 *)dst;
+
+ dest0 = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m0), expand8888(vdest, 0));
+ dest1 = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m1), expand8888(vdest, 1));
+
+ *(__m64 *)dst = pack8888(dest0, dest1);
+ }
+
+ mask += 2;
+ dst += 2;
+ w -= 2;
+ }
+
+ CHECKPOINT();
+
+ while (w)
+ {
+ ullong m = *mask;
+
+ if (m)
+ {
+ __m64 vdest = load8888(*dst);
+ vdest = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m), vdest);
+ *dst = store8888(vdest);
+ }
+
+ w--;
+ mask++;
+ dst++;
+ }
+ }
+
+ _mm_empty();
+}
+
+
+void
+fbCompositeSolidMask_nx8x0565mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 src, srca;
+ CARD16 *dstLine, *dst;
+ CARD8 *maskLine, *mask;
+ FbStride dstStride, maskStride;
+ CARD16 w;
+ __m64 vsrc, vsrca;
+ unsigned long long srcsrcsrcsrc, src16;
+
+ CHECKPOINT();
+
+ fbComposeGetSolid(pSrc, src, pDst->format);
+
+ srca = src >> 24;
+ if (srca == 0)
+ return;
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
+ fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
+
+ vsrc = load8888 (src);
+ vsrca = expand_alpha (vsrc);
+
+ src16 = (ullong)pack565(vsrc, _mm_setzero_si64(), 0);
+
+ srcsrcsrcsrc = (ullong)src16 << 48 | (ullong)src16 << 32 |
+ (ullong)src16 << 16 | (ullong)src16;
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ mask = maskLine;
+ maskLine += maskStride;
+ w = width;
+
+ CHECKPOINT();
+
+ while (w && (unsigned long)dst & 7)
+ {
+ ullong m = *mask;
+
+ if (m)
+ {
+ ullong d = *dst;
+ __m64 vd = (__m64)d;
+ __m64 vdest = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m), expand565(vd, 0));
+ *dst = (ullong)pack565(vdest, _mm_setzero_si64(), 0);
+ }
+
+ w--;
+ mask++;
+ dst++;
+ }
+
+ CHECKPOINT();
+
+ while (w >= 4)
+ {
+ ullong m0, m1, m2, m3;
+ m0 = *mask;
+ m1 = *(mask + 1);
+ m2 = *(mask + 2);
+ m3 = *(mask + 3);
+
+ if (srca == 0xff && (m0 & m1 & m2 & m3) == 0xff)
+ {
+ *(unsigned long long *)dst = srcsrcsrcsrc;
+ }
+ else if (m0 | m1 | m2 | m3)
+ {
+ __m64 vdest;
+ __m64 vm0, vm1, vm2, vm3;
+
+ vdest = *(__m64 *)dst;
+
+ vm0 = (__m64)m0;
+ vdest = pack565(in_over(vsrc, vsrca, expand_alpha_rev(vm0), expand565(vdest, 0)), vdest, 0);
+ vm1 = (__m64)m1;
+ vdest = pack565(in_over(vsrc, vsrca, expand_alpha_rev(vm1), expand565(vdest, 1)), vdest, 1);
+ vm2 = (__m64)m2;
+ vdest = pack565(in_over(vsrc, vsrca, expand_alpha_rev(vm2), expand565(vdest, 2)), vdest, 2);
+ vm3 = (__m64)m3;
+ vdest = pack565(in_over(vsrc, vsrca, expand_alpha_rev(vm3), expand565(vdest, 3)), vdest, 3);
+
+ *(__m64 *)dst = vdest;
+ }
+
+ w -= 4;
+ mask += 4;
+ dst += 4;
+ }
+
+ CHECKPOINT();
+
+ while (w)
+ {
+ ullong m = *mask;
+
+ if (m)
+ {
+ ullong d = *dst;
+ __m64 vd = (__m64)d;
+ __m64 vdest = in_over(vsrc, vsrca, expand_alpha_rev ((__m64)m), expand565(vd, 0));
+ *dst = (ullong)pack565(vdest, _mm_setzero_si64(), 0);
+ }
+
+ w--;
+ mask++;
+ dst++;
+ }
+ }
+
+ _mm_empty();
+}
+
+void
+fbCompositeSrc_8888RevNPx0565mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD16 *dstLine, *dst;
+ CARD32 *srcLine, *src;
+ FbStride dstStride, srcStride;
+ CARD16 w;
+
+ CHECKPOINT();
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
+ fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
+
+ assert (pSrc->pDrawable == pMask->pDrawable);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ src = srcLine;
+ srcLine += srcStride;
+ w = width;
+
+ CHECKPOINT();
+
+ while (w && (unsigned long)dst & 7)
+ {
+ __m64 vsrc = load8888 (*src);
+ ullong d = *dst;
+ __m64 vdest = expand565 ((__m64)d, 0);
+
+ vdest = pack565(over_rev_non_pre(vsrc, vdest), vdest, 0);
+
+ *dst = (ullong)vdest;
+
+ w--;
+ dst++;
+ src++;
+ }
+
+ CHECKPOINT();
+
+ while (w >= 4)
+ {
+ CARD32 s0, s1, s2, s3;
+ unsigned char a0, a1, a2, a3;
+
+ s0 = *src;
+ s1 = *(src + 1);
+ s2 = *(src + 2);
+ s3 = *(src + 3);
+
+ a0 = (s0 >> 24);
+ a1 = (s1 >> 24);
+ a2 = (s2 >> 24);
+ a3 = (s3 >> 24);
+
+ if ((a0 & a1 & a2 & a3) == 0xFF)
+ {
+ __m64 vdest;
+ vdest = pack565(invert_colors(load8888(s0)), _mm_setzero_si64(), 0);
+ vdest = pack565(invert_colors(load8888(s1)), vdest, 1);
+ vdest = pack565(invert_colors(load8888(s2)), vdest, 2);
+ vdest = pack565(invert_colors(load8888(s3)), vdest, 3);
+
+ *(__m64 *)dst = vdest;
+ }
+ else if (a0 | a1 | a2 | a3)
+ {
+ __m64 vdest = *(__m64 *)dst;
+
+ vdest = pack565(over_rev_non_pre(load8888(s0), expand565(vdest, 0)), vdest, 0);
+ vdest = pack565(over_rev_non_pre(load8888(s1), expand565(vdest, 1)), vdest, 1);
+ vdest = pack565(over_rev_non_pre(load8888(s2), expand565(vdest, 2)), vdest, 2);
+ vdest = pack565(over_rev_non_pre(load8888(s3), expand565(vdest, 3)), vdest, 3);
+
+ *(__m64 *)dst = vdest;
+ }
+
+ w -= 4;
+ dst += 4;
+ src += 4;
+ }
+
+ CHECKPOINT();
+
+ while (w)
+ {
+ __m64 vsrc = load8888 (*src);
+ ullong d = *dst;
+ __m64 vdest = expand565 ((__m64)d, 0);
+
+ vdest = pack565(over_rev_non_pre(vsrc, vdest), vdest, 0);
+
+ *dst = (ullong)vdest;
+
+ w--;
+ dst++;
+ src++;
+ }
+ }
+
+ _mm_empty();
+}
+
+/* "8888RevNP" is GdkPixbuf's format: ABGR, non premultiplied */
+
+void
+fbCompositeSrc_8888RevNPx8888mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 *dstLine, *dst;
+ CARD32 *srcLine, *src;
+ FbStride dstStride, srcStride;
+ CARD16 w;
+
+ CHECKPOINT();
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
+ fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
+
+ assert (pSrc->pDrawable == pMask->pDrawable);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ src = srcLine;
+ srcLine += srcStride;
+ w = width;
+
+ while (w && (unsigned long)dst & 7)
+ {
+ __m64 s = load8888 (*src);
+ __m64 d = load8888 (*dst);
+
+ *dst = store8888 (over_rev_non_pre (s, d));
+
+ w--;
+ dst++;
+ src++;
+ }
+
+ while (w >= 2)
+ {
+ ullong s0, s1;
+ unsigned char a0, a1;
+ __m64 d0, d1;
+
+ s0 = *src;
+ s1 = *(src + 1);
+
+ a0 = (s0 >> 24);
+ a1 = (s1 >> 24);
+
+ if ((a0 & a1) == 0xFF)
+ {
+ d0 = invert_colors(load8888(s0));
+ d1 = invert_colors(load8888(s1));
+
+ *(__m64 *)dst = pack8888 (d0, d1);
+ }
+ else if (a0 | a1)
+ {
+ __m64 vdest = *(__m64 *)dst;
+
+ d0 = over_rev_non_pre (load8888(s0), expand8888 (vdest, 0));
+ d1 = over_rev_non_pre (load8888(s1), expand8888 (vdest, 1));
+
+ *(__m64 *)dst = pack8888 (d0, d1);
+ }
+
+ w -= 2;
+ dst += 2;
+ src += 2;
+ }
+
+ while (w)
+ {
+ __m64 s = load8888 (*src);
+ __m64 d = load8888 (*dst);
+
+ *dst = store8888 (over_rev_non_pre (s, d));
+
+ w--;
+ dst++;
+ src++;
+ }
+ }
+
+ _mm_empty();
+}
+
+void
+fbCompositeSolidMask_nx8888x0565Cmmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 src, srca;
+ CARD16 *dstLine;
+ CARD32 *maskLine;
+ FbStride dstStride, maskStride;
+ __m64 vsrc, vsrca;
+
+ CHECKPOINT();
+
+ fbComposeGetSolid(pSrc, src, pDst->format);
+
+ srca = src >> 24;
+ if (srca == 0)
+ return;
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
+ fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
+
+ vsrc = load8888 (src);
+ vsrca = expand_alpha (vsrc);
+
+ while (height--)
+ {
+ int twidth = width;
+ CARD32 *p = (CARD32 *)maskLine;
+ CARD16 *q = (CARD16 *)dstLine;
+
+ while (twidth && ((unsigned long)q & 7))
+ {
+ CARD32 m = *(CARD32 *)p;
+
+ if (m)
+ {
+ ullong d = *q;
+ __m64 vdest = expand565 ((__m64)d, 0);
+ vdest = pack565 (in_over (vsrc, vsrca, load8888 (m), vdest), vdest, 0);
+ *q = (ullong)vdest;
+ }
+
+ twidth--;
+ p++;
+ q++;
+ }
+
+ while (twidth >= 4)
+ {
+ CARD32 m0, m1, m2, m3;
+
+ m0 = *p;
+ m1 = *(p + 1);
+ m2 = *(p + 2);
+ m3 = *(p + 3);
+
+ if ((m0 | m1 | m2 | m3))
+ {
+ __m64 vdest = *(__m64 *)q;
+
+ vdest = pack565(in_over(vsrc, vsrca, load8888(m0), expand565(vdest, 0)), vdest, 0);
+ vdest = pack565(in_over(vsrc, vsrca, load8888(m1), expand565(vdest, 1)), vdest, 1);
+ vdest = pack565(in_over(vsrc, vsrca, load8888(m2), expand565(vdest, 2)), vdest, 2);
+ vdest = pack565(in_over(vsrc, vsrca, load8888(m3), expand565(vdest, 3)), vdest, 3);
+
+ *(__m64 *)q = vdest;
+ }
+ twidth -= 4;
+ p += 4;
+ q += 4;
+ }
+
+ while (twidth)
+ {
+ CARD32 m;
+
+ m = *(CARD32 *)p;
+ if (m)
+ {
+ ullong d = *q;
+ __m64 vdest = expand565((__m64)d, 0);
+ vdest = pack565 (in_over(vsrc, vsrca, load8888(m), vdest), vdest, 0);
+ *q = (ullong)vdest;
+ }
+
+ twidth--;
+ p++;
+ q++;
+ }
+
+ maskLine += maskStride;
+ dstLine += dstStride;
+ }
+
+ _mm_empty ();
+}
+
+void
+fbCompositeSrcAdd_8000x8000mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD8 *dstLine, *dst;
+ CARD8 *srcLine, *src;
+ FbStride dstStride, srcStride;
+ CARD16 w;
+ CARD8 s, d;
+ CARD16 t;
+
+ CHECKPOINT();
+
+ fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 1);
+ fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ src = srcLine;
+ srcLine += srcStride;
+ w = width;
+
+ while (w && (unsigned long)dst & 7)
+ {
+ s = *src;
+ d = *dst;
+ t = d + s;
+ s = t | (0 - (t >> 8));
+ *dst = s;
+
+ dst++;
+ src++;
+ w--;
+ }
+
+ while (w >= 8)
+ {
+ *(__m64*)dst = _mm_adds_pu8(*(__m64*)src, *(__m64*)dst);
+ dst += 8;
+ src += 8;
+ w -= 8;
+ }
+
+ while (w)
+ {
+ s = *src;
+ d = *dst;
+ t = d + s;
+ s = t | (0 - (t >> 8));
+ *dst = s;
+
+ dst++;
+ src++;
+ w--;
+ }
+ }
+
+ _mm_empty();
+}
+
+void
+fbCompositeSrcAdd_8888x8888mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 *dstLine, *dst;
+ CARD32 *srcLine, *src;
+ FbStride dstStride, srcStride;
+ CARD16 w;
+
+ CHECKPOINT();
+
+ fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
+ fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ src = srcLine;
+ srcLine += srcStride;
+ w = width;
+
+ while (w && (unsigned long)dst & 7)
+ {
+ *dst = _mm_cvtsi64_si32(_mm_adds_pu8(_mm_cvtsi32_si64(*src),
+ _mm_cvtsi32_si64(*dst)));
+ dst++;
+ src++;
+ w--;
+ }
+
+ while (w >= 2)
+ {
+ *(ullong*)dst = (ullong) _mm_adds_pu8(*(__m64*)src, *(__m64*)dst);
+ dst += 2;
+ src += 2;
+ w -= 2;
+ }
+
+ if (w)
+ {
+ *dst = _mm_cvtsi64_si32(_mm_adds_pu8(_mm_cvtsi32_si64(*src),
+ _mm_cvtsi32_si64(*dst)));
+
+ }
+ }
+
+ _mm_empty();
+}
+
+Bool
+fbSolidFillmmx (DrawablePtr pDraw,
+ int x,
+ int y,
+ int width,
+ int height,
+ FbBits xor)
+{
+ FbStride stride;
+ int bpp;
+ ullong fill;
+ __m64 vfill;
+ CARD32 byte_width;
+ CARD8 *byte_line;
+ FbBits *bits;
+ int xoff, yoff;
+
+ CHECKPOINT();
+
+ fbGetDrawable(pDraw, bits, stride, bpp, xoff, yoff);
+
+ if (bpp == 16 && (xor >> 16 != (xor & 0xffff)))
+ return FALSE;
+
+ if (bpp != 16 && bpp != 32)
+ return FALSE;
+
+ if (bpp == 16)
+ {
+ stride = stride * sizeof (FbBits) / 2;
+ byte_line = (CARD8 *)(((CARD16 *)bits) + stride * (y + yoff) + (x + xoff));
+ byte_width = 2 * width;
+ stride *= 2;
+ }
+ else
+ {
+ stride = stride * sizeof (FbBits) / 4;
+ byte_line = (CARD8 *)(((CARD32 *)bits) + stride * (y + yoff) + (x + xoff));
+ byte_width = 4 * width;
+ stride *= 4;
+ }
+
+ fill = ((ullong)xor << 32) | xor;
+ vfill = (__m64)fill;
+
+ while (height--)
+ {
+ int w;
+ CARD8 *d = byte_line;
+ byte_line += stride;
+ w = byte_width;
+
+ while (w >= 2 && ((unsigned long)d & 3))
+ {
+ *(CARD16 *)d = xor;
+ w -= 2;
+ d += 2;
+ }
+
+ while (w >= 4 && ((unsigned long)d & 7))
+ {
+ *(CARD32 *)d = xor;
+
+ w -= 4;
+ d += 4;
+ }
+
+ while (w >= 64)
+ {
+ *(__m64*) (d + 0) = vfill;
+ *(__m64*) (d + 8) = vfill;
+ *(__m64*) (d + 16) = vfill;
+ *(__m64*) (d + 24) = vfill;
+ *(__m64*) (d + 32) = vfill;
+ *(__m64*) (d + 40) = vfill;
+ *(__m64*) (d + 48) = vfill;
+ *(__m64*) (d + 56) = vfill;
+
+ w -= 64;
+ d += 64;
+ }
+ while (w >= 4)
+ {
+ *(CARD32 *)d = xor;
+
+ w -= 4;
+ d += 4;
+ }
+ if (w >= 2)
+ {
+ *(CARD16 *)d = xor;
+ w -= 2;
+ d += 2;
+ }
+ }
+
+ _mm_empty();
+ return TRUE;
+}
+
+Bool
+fbCopyAreammx (DrawablePtr pSrc,
+ DrawablePtr pDst,
+ int src_x,
+ int src_y,
+ int dst_x,
+ int dst_y,
+ int width,
+ int height)
+{
+ FbBits * src_bits;
+ FbStride src_stride;
+ int src_bpp;
+ int src_xoff;
+ int src_yoff;
+
+ FbBits * dst_bits;
+ FbStride dst_stride;
+ int dst_bpp;
+ int dst_xoff;
+ int dst_yoff;
+
+ CARD8 * src_bytes;
+ CARD8 * dst_bytes;
+ int byte_width;
+
+ fbGetDrawable(pSrc, src_bits, src_stride, src_bpp, src_xoff, src_yoff);
+ fbGetDrawable(pDst, dst_bits, dst_stride, dst_bpp, dst_xoff, dst_yoff);
+
+ if (src_bpp != dst_bpp)
+ return FALSE;
+
+ if (src_bpp == 16)
+ {
+ src_stride = src_stride * sizeof (FbBits) / 2;
+ dst_stride = dst_stride * sizeof (FbBits) / 2;
+ src_bytes = (CARD8 *)(((CARD16 *)src_bits) + src_stride * (src_y + src_yoff) + (src_x + src_xoff));
+ dst_bytes = (CARD8 *)(((CARD16 *)dst_bits) + dst_stride * (dst_y + dst_yoff) + (dst_x + dst_xoff));
+ byte_width = 2 * width;
+ src_stride *= 2;
+ dst_stride *= 2;
+ } else if (src_bpp == 32) {
+ src_stride = src_stride * sizeof (FbBits) / 4;
+ dst_stride = dst_stride * sizeof (FbBits) / 4;
+ src_bytes = (CARD8 *)(((CARD32 *)src_bits) + src_stride * (src_y + src_yoff) + (src_x + src_xoff));
+ dst_bytes = (CARD8 *)(((CARD32 *)dst_bits) + dst_stride * (dst_y + dst_yoff) + (dst_x + dst_xoff));
+ byte_width = 4 * width;
+ src_stride *= 4;
+ dst_stride *= 4;
+ } else {
+ return FALSE;
+ }
+
+ while (height--)
+ {
+ int w;
+ CARD8 *s = src_bytes;
+ CARD8 *d = dst_bytes;
+ src_bytes += src_stride;
+ dst_bytes += dst_stride;
+ w = byte_width;
+
+ while (w >= 2 && ((unsigned long)d & 3))
+ {
+ *(CARD16 *)d = *(CARD16 *)s;
+ w -= 2;
+ s += 2;
+ d += 2;
+ }
+
+ while (w >= 4 && ((unsigned long)d & 7))
+ {
+ *(CARD32 *)d = *(CARD32 *)s;
+
+ w -= 4;
+ s += 4;
+ d += 4;
+ }
+
+ while (w >= 64)
+ {
+ *(__m64 *)(d + 0) = *(__m64 *)(s + 0);
+ *(__m64 *)(d + 8) = *(__m64 *)(s + 8);
+ *(__m64 *)(d + 16) = *(__m64 *)(s + 16);
+ *(__m64 *)(d + 24) = *(__m64 *)(s + 24);
+ *(__m64 *)(d + 32) = *(__m64 *)(s + 32);
+ *(__m64 *)(d + 40) = *(__m64 *)(s + 40);
+ *(__m64 *)(d + 48) = *(__m64 *)(s + 48);
+ *(__m64 *)(d + 56) = *(__m64 *)(s + 56);
+ w -= 64;
+ s += 64;
+ d += 64;
+ }
+ while (w >= 4)
+ {
+ *(CARD32 *)d = *(CARD32 *)s;
+
+ w -= 4;
+ s += 4;
+ d += 4;
+ }
+ if (w >= 2)
+ {
+ *(CARD16 *)d = *(CARD16 *)s;
+ w -= 2;
+ s += 2;
+ d += 2;
+ }
+ }
+
+ _mm_empty();
+ return TRUE;
+}
+
+void
+fbCompositeCopyAreammx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ fbCopyAreammx (pSrc->pDrawable,
+ pDst->pDrawable,
+ xSrc, ySrc,
+ xDst, yDst,
+ width, height);
+}
+
+
+
+
+#endif /* RENDER */
+#endif /* USE_MMX */
diff --git a/nx-X11/programs/Xserver/fb/fbmmx.h b/nx-X11/programs/Xserver/fb/fbmmx.h
new file mode 100644
index 000000000..34718e3c0
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbmmx.h
@@ -0,0 +1,220 @@
+/*
+ * Copyright © 2004 Red Hat, Inc.
+ * Copyright © 2005 Trolltech AS
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Red Hat not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. Red Hat makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Søren Sandmann (sandmann@redhat.com)
+ * Lars Knoll (lars@trolltech.com)
+ *
+ * Based on work by Owen Taylor
+ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef USE_MMX
+
+#if !defined(__amd64__) && !defined(__x86_64__)
+Bool fbHaveMMX(void);
+#else
+#define fbHaveMMX() TRUE
+#endif
+
+#else
+#define fbHaveMMX() FALSE
+#endif
+
+#ifdef USE_MMX
+
+void fbComposeSetupMMX(void);
+
+void fbCompositeSolidMask_nx8888x0565Cmmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+void fbCompositeSrcAdd_8888x8888mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+void fbCompositeSrc_8888x8888mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+void fbCompositeSolidMask_nx8888x8888Cmmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+void fbCompositeSolidMask_nx8x8888mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+void fbCompositeSrcAdd_8000x8000mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+void fbCompositeSrc_8888RevNPx8888mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+void fbCompositeSrc_8888RevNPx0565mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+void fbCompositeSolid_nx8888mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+void fbCompositeSolid_nx0565mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+void fbCompositeSolidMask_nx8x0565mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+void fbCompositeSrc_8888x8x8888mmx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+Bool fbCopyAreammx (DrawablePtr pSrc,
+ DrawablePtr pDst,
+ int src_x,
+ int src_y,
+ int dst_x,
+ int dst_y,
+ int width,
+ int height);
+void fbCompositeCopyAreammx (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+Bool fbSolidFillmmx (DrawablePtr pDraw,
+ int x,
+ int y,
+ int width,
+ int height,
+ FbBits xor);
+
+#endif /* USE_MMX */
diff --git a/nx-X11/programs/Xserver/fb/fbmodule.c b/nx-X11/programs/Xserver/fb/fbmodule.c
new file mode 100644
index 000000000..80d99933a
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbmodule.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbmodule.c,v 1.3 2000/02/14 19:20:29 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef XFree86LOADER
+
+#include "xf86Module.h"
+#include "fb.h"
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "fb",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_ANSIC, /* Only need the ansic layer */
+ ABI_ANSIC_VERSION,
+ MOD_CLASS_NONE,
+ {0,0,0,0} /* signature, to be patched into the file by a tool */
+};
+
+XF86ModuleData fbModuleData = { &VersRec, NULL, NULL };
+
+#endif
diff --git a/nx-X11/programs/Xserver/fb/fboverlay.c b/nx-X11/programs/Xserver/fb/fboverlay.c
new file mode 100644
index 000000000..87524e27e
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fboverlay.c
@@ -0,0 +1,457 @@
+/*
+ * $XFree86: xc/programs/Xserver/fb/fboverlay.c,v 1.7 2003/11/10 18:21:47 tsi Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+/* $XdotOrg: xc/programs/Xserver/fb/fboverlay.c,v 1.7 2005/07/03 07:01:23 daniels Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include "fboverlay.h"
+
+int fbOverlayGeneration;
+int fbOverlayScreenPrivateIndex = -1;
+
+int fbOverlayGetScreenPrivateIndex(void)
+{
+ return fbOverlayScreenPrivateIndex;
+}
+
+/*
+ * Replace this if you want something supporting
+ * multiple overlays with the same depth
+ */
+Bool
+fbOverlayCreateWindow(WindowPtr pWin)
+{
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pWin->drawable.pScreen);
+ int i;
+ PixmapPtr pPixmap;
+
+ if (pWin->drawable.class != InputOutput)
+ return TRUE;
+
+#ifdef FB_SCREEN_PRIVATE
+ if (pWin->drawable.bitsPerPixel == 32)
+ pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp;
+#endif
+
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ {
+ pPixmap = pScrPriv->layer[i].u.run.pixmap;
+ if (pWin->drawable.depth == pPixmap->drawable.depth)
+ {
+ pWin->devPrivates[fbWinPrivateIndex].ptr = (pointer) pPixmap;
+ /*
+ * Make sure layer keys are written correctly by
+ * having non-root layers set to full while the
+ * root layer is set to empty. This will cause
+ * all of the layers to get painted when the root
+ * is mapped
+ */
+ if (!pWin->parent)
+ {
+ REGION_EMPTY (pWin->drawable.pScreen,
+ &pScrPriv->layer[i].u.run.region);
+ }
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+Bool
+fbOverlayCloseScreen (int iScreen, ScreenPtr pScreen)
+{
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
+ int i;
+
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ {
+ (*pScreen->DestroyPixmap)(pScrPriv->layer[i].u.run.pixmap);
+ REGION_UNINIT (pScreen, &pScrPriv->layer[i].u.run.region);
+ }
+ return TRUE;
+}
+
+/*
+ * Return layer containing this window
+ */
+int
+fbOverlayWindowLayer(WindowPtr pWin)
+{
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pWin->drawable.pScreen);
+ int i;
+
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ if (pWin->devPrivates[fbWinPrivateIndex].ptr ==
+ (pointer) pScrPriv->layer[i].u.run.pixmap)
+ return i;
+ return 0;
+}
+
+Bool
+fbOverlayCreateScreenResources(ScreenPtr pScreen)
+{
+ int i;
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
+ PixmapPtr pPixmap;
+ pointer pbits;
+ int width;
+ int depth;
+ BoxRec box;
+
+ if (!miCreateScreenResources(pScreen))
+ return FALSE;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pScreen->width;
+ box.y2 = pScreen->height;
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ {
+ pbits = pScrPriv->layer[i].u.init.pbits;
+ width = pScrPriv->layer[i].u.init.width;
+ depth = pScrPriv->layer[i].u.init.depth;
+ pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth);
+ if (!pPixmap)
+ return FALSE;
+ if (!(*pScreen->ModifyPixmapHeader)(pPixmap, pScreen->width,
+ pScreen->height, depth,
+ BitsPerPixel(depth),
+ PixmapBytePad(width, depth),
+ pbits))
+ return FALSE;
+ pScrPriv->layer[i].u.run.pixmap = pPixmap;
+ REGION_INIT(pScreen, &pScrPriv->layer[i].u.run.region, &box, 0);
+ }
+ pScreen->devPrivate = pScrPriv->layer[0].u.run.pixmap;
+ return TRUE;
+}
+
+void
+fbOverlayPaintKey (DrawablePtr pDrawable,
+ RegionPtr pRegion,
+ CARD32 pixel,
+ int layer)
+{
+ fbFillRegionSolid (pDrawable, pRegion, 0,
+ fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
+}
+
+/*
+ * Track visible region for each layer
+ */
+void
+fbOverlayUpdateLayerRegion (ScreenPtr pScreen,
+ int layer,
+ RegionPtr prgn)
+{
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
+ int i;
+ RegionRec rgnNew;
+
+ if (!prgn || !REGION_NOTEMPTY(pScreen, prgn))
+ return;
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ {
+ if (i == layer)
+ {
+ /* add new piece to this fb */
+ REGION_UNION (pScreen,
+ &pScrPriv->layer[i].u.run.region,
+ &pScrPriv->layer[i].u.run.region,
+ prgn);
+ }
+ else if (REGION_NOTEMPTY (pScreen,
+ &pScrPriv->layer[i].u.run.region))
+ {
+ /* paint new piece with chroma key */
+ REGION_NULL (pScreen, &rgnNew);
+ REGION_INTERSECT (pScreen,
+ &rgnNew,
+ prgn,
+ &pScrPriv->layer[i].u.run.region);
+ (*pScrPriv->PaintKey) (&pScrPriv->layer[i].u.run.pixmap->drawable,
+ &rgnNew,
+ pScrPriv->layer[i].key,
+ i);
+ REGION_UNINIT(pScreen, &rgnNew);
+ /* remove piece from other fbs */
+ REGION_SUBTRACT (pScreen,
+ &pScrPriv->layer[i].u.run.region,
+ &pScrPriv->layer[i].u.run.region,
+ prgn);
+ }
+ }
+}
+
+/*
+ * Copy only areas in each layer containing real bits
+ */
+void
+fbOverlayCopyWindow(WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pWin->drawable.pScreen);
+ RegionRec rgnDst;
+ int dx, dy;
+ int i;
+ RegionRec layerRgn[FB_OVERLAY_MAX];
+ PixmapPtr pPixmap;
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+
+ /*
+ * Clip to existing bits
+ */
+ REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
+ REGION_NULL (pScreen, &rgnDst);
+ REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+ REGION_TRANSLATE(pScreen, &rgnDst, dx, dy);
+ /*
+ * Compute the portion of each fb affected by this copy
+ */
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ {
+ REGION_NULL (pScreen, &layerRgn[i]);
+ REGION_INTERSECT(pScreen, &layerRgn[i], &rgnDst,
+ &pScrPriv->layer[i].u.run.region);
+ if (REGION_NOTEMPTY (pScreen, &layerRgn[i]))
+ {
+ REGION_TRANSLATE(pScreen, &layerRgn[i], -dx, -dy);
+ pPixmap = pScrPriv->layer[i].u.run.pixmap;
+ fbCopyRegion (&pPixmap->drawable, &pPixmap->drawable,
+ 0,
+ &layerRgn[i], dx, dy, pScrPriv->CopyWindow, 0,
+ (void *)(long) i);
+ }
+ }
+ /*
+ * Update regions
+ */
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ {
+ if (REGION_NOTEMPTY (pScreen, &layerRgn[i]))
+ fbOverlayUpdateLayerRegion (pScreen, i, &layerRgn[i]);
+
+ REGION_UNINIT(pScreen, &layerRgn[i]);
+ }
+ REGION_UNINIT(pScreen, &rgnDst);
+}
+
+void
+fbOverlayWindowExposures (WindowPtr pWin,
+ RegionPtr prgn,
+ RegionPtr other_exposed)
+{
+ fbOverlayUpdateLayerRegion (pWin->drawable.pScreen,
+ fbOverlayWindowLayer (pWin),
+ prgn);
+ miWindowExposures(pWin, prgn, other_exposed);
+}
+
+void
+fbOverlayPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ if (what == PW_BORDER)
+ fbOverlayUpdateLayerRegion (pWin->drawable.pScreen,
+ fbOverlayWindowLayer (pWin),
+ pRegion);
+ fbPaintWindow (pWin, pRegion, what);
+}
+
+Bool
+fbOverlaySetupScreen(ScreenPtr pScreen,
+ pointer pbits1,
+ pointer pbits2,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width1,
+ int width2,
+ int bpp1,
+ int bpp2)
+{
+ return fbSetupScreen (pScreen,
+ pbits1,
+ xsize,
+ ysize,
+ dpix,
+ dpiy,
+ width1,
+ bpp1);
+}
+
+static Bool
+fb24_32OverlayCreateScreenResources(ScreenPtr pScreen)
+{
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
+ int pitch;
+ Bool retval;
+ int i;
+
+ if((retval = fbOverlayCreateScreenResources(pScreen))) {
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ {
+ /* fix the screen pixmap */
+ PixmapPtr pPix = (PixmapPtr) pScrPriv->layer[i].u.run.pixmap;
+ if (pPix->drawable.bitsPerPixel == 32) {
+ pPix->drawable.bitsPerPixel = 24;
+ pitch = BitmapBytePad(pPix->drawable.width * 24);
+ pPix->devKind = pitch;
+ }
+ }
+ }
+
+ return retval;
+}
+
+Bool
+fbOverlayFinishScreenInit(ScreenPtr pScreen,
+ pointer pbits1,
+ pointer pbits2,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width1,
+ int width2,
+ int bpp1,
+ int bpp2,
+ int depth1,
+ int depth2)
+{
+ VisualPtr visuals;
+ DepthPtr depths;
+ int nvisuals;
+ int ndepths;
+ int bpp = 0, imagebpp = 32;
+ VisualID defaultVisual;
+ FbOverlayScrPrivPtr pScrPriv;
+
+ if (fbOverlayGeneration != serverGeneration)
+ {
+ fbOverlayScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ fbOverlayGeneration = serverGeneration;
+ }
+
+ pScrPriv = xalloc (sizeof (FbOverlayScrPrivRec));
+ if (!pScrPriv)
+ return FALSE;
+
+#ifdef FB_24_32BIT
+ if (bpp1 == 32 || bpp2 == 32)
+ bpp = 32;
+ else if (bpp1 == 24 || bpp2 == 24)
+ bpp = 24;
+
+ if (bpp == 24)
+ {
+ int f;
+
+ imagebpp = 32;
+ /*
+ * Check to see if we're advertising a 24bpp image format,
+ * in which case windows will use it in preference to a 32 bit
+ * format.
+ */
+ for (f = 0; f < screenInfo.numPixmapFormats; f++)
+ {
+ if (screenInfo.formats[f].bitsPerPixel == 24)
+ {
+ imagebpp = 24;
+ break;
+ }
+ }
+ }
+#endif
+#ifdef FB_SCREEN_PRIVATE
+ if (imagebpp == 32)
+ {
+ fbGetScreenPrivate(pScreen)->win32bpp = bpp;
+ fbGetScreenPrivate(pScreen)->pix32bpp = bpp;
+ }
+ else
+ {
+ fbGetScreenPrivate(pScreen)->win32bpp = 32;
+ fbGetScreenPrivate(pScreen)->pix32bpp = 32;
+ }
+#endif
+
+ if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &depth1,
+ &defaultVisual, ((unsigned long)1<<(bpp1-1)) |
+ ((unsigned long)1<<(bpp2-1)), 8))
+ return FALSE;
+ if (! miScreenInit(pScreen, 0, xsize, ysize, dpix, dpiy, 0,
+ depth1, ndepths, depths,
+ defaultVisual, nvisuals, visuals
+#ifdef FB_OLD_MISCREENINIT
+ , (miBSFuncPtr) 0
+#endif
+ ))
+ return FALSE;
+ /* MI thinks there's no frame buffer */
+#ifdef MITSHM
+ ShmRegisterFbFuncs(pScreen);
+#endif
+ pScreen->minInstalledCmaps = 1;
+ pScreen->maxInstalledCmaps = 2;
+
+ pScrPriv->nlayers = 2;
+ pScrPriv->PaintKey = fbOverlayPaintKey;
+ pScrPriv->CopyWindow = fbCopyWindowProc;
+ pScrPriv->layer[0].u.init.pbits = pbits1;
+ pScrPriv->layer[0].u.init.width = width1;
+ pScrPriv->layer[0].u.init.depth = depth1;
+
+ pScrPriv->layer[1].u.init.pbits = pbits2;
+ pScrPriv->layer[1].u.init.width = width2;
+ pScrPriv->layer[1].u.init.depth = depth2;
+
+ pScreen->devPrivates[fbOverlayScreenPrivateIndex].ptr = (pointer) pScrPriv;
+
+ /* overwrite miCloseScreen with our own */
+ pScreen->CloseScreen = fbOverlayCloseScreen;
+ pScreen->CreateScreenResources = fbOverlayCreateScreenResources;
+ pScreen->CreateWindow = fbOverlayCreateWindow;
+ pScreen->WindowExposures = fbOverlayWindowExposures;
+ pScreen->CopyWindow = fbOverlayCopyWindow;
+ pScreen->PaintWindowBorder = fbOverlayPaintWindow;
+#ifdef FB_24_32BIT
+ if (bpp == 24 && imagebpp == 32)
+ {
+ pScreen->ModifyPixmapHeader = fb24_32ModifyPixmapHeader;
+ pScreen->CreateScreenResources = fb24_32OverlayCreateScreenResources;
+ }
+#endif
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/fb/fboverlay.h b/nx-X11/programs/Xserver/fb/fboverlay.h
new file mode 100644
index 000000000..e6a4e033f
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fboverlay.h
@@ -0,0 +1,129 @@
+/*
+ * $XFree86: xc/programs/Xserver/fb/fboverlay.h,v 1.4tsi Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _FBOVERLAY_H_
+#define _FBOVERLAY_H_
+
+extern int fbOverlayGeneration;
+extern int fbOverlayScreenPrivateIndex; /* XXX should be static */
+extern int fbOverlayGetScreenPrivateIndex(void);
+
+#ifndef FB_OVERLAY_MAX
+#define FB_OVERLAY_MAX 2
+#endif
+
+typedef void (*fbOverlayPaintKeyProc) (DrawablePtr, RegionPtr, CARD32, int);
+
+typedef struct _fbOverlayLayer {
+ union {
+ struct {
+ pointer pbits;
+ int width;
+ int depth;
+ } init;
+ struct {
+ PixmapPtr pixmap;
+ RegionRec region;
+ } run;
+ } u;
+ CARD32 key; /* special pixel value */
+} FbOverlayLayer;
+
+typedef struct _fbOverlayScrPriv {
+ int nlayers;
+ fbOverlayPaintKeyProc PaintKey;
+ fbCopyProc CopyWindow;
+ FbOverlayLayer layer[FB_OVERLAY_MAX];
+} FbOverlayScrPrivRec, *FbOverlayScrPrivPtr;
+
+#define fbOverlayGetScrPriv(s) \
+ ((fbOverlayGetScreenPrivateIndex() != -1) ? \
+ (s)->devPrivates[fbOverlayGetScreenPrivateIndex()].ptr : NULL)
+Bool
+fbOverlayCreateWindow(WindowPtr pWin);
+
+Bool
+fbOverlayCloseScreen (int iScreen, ScreenPtr pScreen);
+
+int
+fbOverlayWindowLayer(WindowPtr pWin);
+
+Bool
+fbOverlayCreateScreenResources(ScreenPtr pScreen);
+
+void
+fbOverlayPaintKey (DrawablePtr pDrawable,
+ RegionPtr pRegion,
+ CARD32 pixel,
+ int layer);
+void
+fbOverlayUpdateLayerRegion (ScreenPtr pScreen,
+ int layer,
+ RegionPtr prgn);
+
+
+void
+fbOverlayCopyWindow(WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc);
+
+void
+fbOverlayWindowExposures (WindowPtr pWin,
+ RegionPtr prgn,
+ RegionPtr other_exposed);
+
+void
+fbOverlayPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
+
+
+Bool
+fbOverlaySetupScreen(ScreenPtr pScreen,
+ pointer pbits1,
+ pointer pbits2,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width1,
+ int width2,
+ int bpp1,
+ int bpp2);
+
+Bool
+fbOverlayFinishScreenInit(ScreenPtr pScreen,
+ pointer pbits1,
+ pointer pbits2,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width1,
+ int width2,
+ int bpp1,
+ int bpp2,
+ int depth1,
+ int depth2);
+
+#endif /* _FBOVERLAY_H_ */
diff --git a/nx-X11/programs/Xserver/fb/fbpict.c b/nx-X11/programs/Xserver/fb/fbpict.c
new file mode 100644
index 000000000..5ab3756b9
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbpict.c
@@ -0,0 +1,1456 @@
+/*
+ * $XFree86: xc/programs/Xserver/fb/fbpict.c,v 1.15 2002/09/26 02:56:48 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+#ifdef RENDER
+
+#include "picturestr.h"
+#include "mipict.h"
+#include "fbpict.h"
+#include "fbmmx.h"
+
+typedef void (*CompositeFunc) (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+CARD32
+fbOver (CARD32 x, CARD32 y)
+{
+ CARD16 a = ~x >> 24;
+ CARD16 t;
+ CARD32 m,n,o,p;
+
+ m = FbOverU(x,y,0,a,t);
+ n = FbOverU(x,y,8,a,t);
+ o = FbOverU(x,y,16,a,t);
+ p = FbOverU(x,y,24,a,t);
+ return m|n|o|p;
+}
+
+CARD32
+fbOver24 (CARD32 x, CARD32 y)
+{
+ CARD16 a = ~x >> 24;
+ CARD16 t;
+ CARD32 m,n,o;
+
+ m = FbOverU(x,y,0,a,t);
+ n = FbOverU(x,y,8,a,t);
+ o = FbOverU(x,y,16,a,t);
+ return m|n|o;
+}
+
+CARD32
+fbIn (CARD32 x, CARD8 y)
+{
+ CARD16 a = y;
+ CARD16 t;
+ CARD32 m,n,o,p;
+
+ m = FbInU(x,0,a,t);
+ n = FbInU(x,8,a,t);
+ o = FbInU(x,16,a,t);
+ p = FbInU(x,24,a,t);
+ return m|n|o|p;
+}
+
+/*
+ * Naming convention:
+ *
+ * opSRCxMASKxDST
+ */
+
+void
+fbCompositeSolidMask_nx8x8888 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 src, srca;
+ CARD32 *dstLine, *dst, d, dstMask;
+ CARD8 *maskLine, *mask, m;
+ FbStride dstStride, maskStride;
+ CARD16 w;
+
+ fbComposeGetSolid(pSrc, src, pDst->format);
+
+ dstMask = FbFullMask (pDst->pDrawable->depth);
+ srca = src >> 24;
+ if (src == 0)
+ return;
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
+ fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ mask = maskLine;
+ maskLine += maskStride;
+ w = width;
+
+ while (w--)
+ {
+ m = *mask++;
+ if (m == 0xff)
+ {
+ if (srca == 0xff)
+ *dst = src & dstMask;
+ else
+ *dst = fbOver (src, *dst) & dstMask;
+ }
+ else if (m)
+ {
+ d = fbIn (src, m);
+ *dst = fbOver (d, *dst) & dstMask;
+ }
+ dst++;
+ }
+ }
+}
+
+void
+fbCompositeSolidMask_nx8888x8888C (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 src, srca;
+ CARD32 *dstLine, *dst, d, dstMask;
+ CARD32 *maskLine, *mask, ma;
+ FbStride dstStride, maskStride;
+ CARD16 w;
+ CARD32 m, n, o, p;
+
+ fbComposeGetSolid(pSrc, src, pDst->format);
+
+ dstMask = FbFullMask (pDst->pDrawable->depth);
+ srca = src >> 24;
+ if (src == 0)
+ return;
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
+ fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ mask = maskLine;
+ maskLine += maskStride;
+ w = width;
+
+ while (w--)
+ {
+ ma = *mask++;
+ if (ma == 0xffffffff)
+ {
+ if (srca == 0xff)
+ *dst = src & dstMask;
+ else
+ *dst = fbOver (src, *dst) & dstMask;
+ }
+ else if (ma)
+ {
+ d = *dst;
+#define FbInOverC(src,srca,msk,dst,i,result) { \
+ CARD16 __a = FbGet8(msk,i); \
+ CARD32 __t, __ta; \
+ CARD32 __i; \
+ __t = FbIntMult (FbGet8(src,i), __a,__i); \
+ __ta = (CARD8) ~FbIntMult (srca, __a,__i); \
+ __t = __t + FbIntMult(FbGet8(dst,i),__ta,__i); \
+ __t = (CARD32) (CARD8) (__t | (-(__t >> 8))); \
+ result = __t << (i); \
+}
+ FbInOverC (src, srca, ma, d, 0, m);
+ FbInOverC (src, srca, ma, d, 8, n);
+ FbInOverC (src, srca, ma, d, 16, o);
+ FbInOverC (src, srca, ma, d, 24, p);
+ *dst = m|n|o|p;
+ }
+ dst++;
+ }
+ }
+}
+
+void
+fbCompositeSolidMask_nx8x0888 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 src, srca;
+ CARD8 *dstLine, *dst;
+ CARD32 d;
+ CARD8 *maskLine, *mask, m;
+ FbStride dstStride, maskStride;
+ CARD16 w;
+
+ fbComposeGetSolid(pSrc, src, pDst->format);
+
+ srca = src >> 24;
+ if (src == 0)
+ return;
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
+ fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ mask = maskLine;
+ maskLine += maskStride;
+ w = width;
+
+ while (w--)
+ {
+ m = *mask++;
+ if (m == 0xff)
+ {
+ if (srca == 0xff)
+ d = src;
+ else
+ {
+ d = Fetch24(dst);
+ d = fbOver24 (src, d);
+ }
+ Store24(dst,d);
+ }
+ else if (m)
+ {
+ d = fbOver24 (fbIn(src,m), Fetch24(dst));
+ Store24(dst,d);
+ }
+ dst += 3;
+ }
+ }
+}
+
+void
+fbCompositeSolidMask_nx8x0565 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 src, srca;
+ CARD16 *dstLine, *dst;
+ CARD32 d;
+ CARD8 *maskLine, *mask, m;
+ FbStride dstStride, maskStride;
+ CARD16 w;
+
+ fbComposeGetSolid(pSrc, src, pDst->format);
+
+ srca = src >> 24;
+ if (src == 0)
+ return;
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
+ fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ mask = maskLine;
+ maskLine += maskStride;
+ w = width;
+
+ while (w--)
+ {
+ m = *mask++;
+ if (m == 0xff)
+ {
+ if (srca == 0xff)
+ d = src;
+ else
+ {
+ d = *dst;
+ d = fbOver24 (src, cvt0565to8888(d));
+ }
+ *dst = cvt8888to0565(d);
+ }
+ else if (m)
+ {
+ d = *dst;
+ d = fbOver24 (fbIn(src,m), cvt0565to8888(d));
+ *dst = cvt8888to0565(d);
+ }
+ dst++;
+ }
+ }
+}
+
+void
+fbCompositeSolidMask_nx8888x0565C (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 src, srca;
+ CARD16 src16;
+ CARD16 *dstLine, *dst;
+ CARD32 d;
+ CARD32 *maskLine, *mask, ma;
+ FbStride dstStride, maskStride;
+ CARD16 w;
+ CARD32 m, n, o;
+
+ fbComposeGetSolid(pSrc, src, pDst->format);
+
+ srca = src >> 24;
+ if (src == 0)
+ return;
+
+ src16 = cvt8888to0565(src);
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
+ fbComposeGetStart (pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ mask = maskLine;
+ maskLine += maskStride;
+ w = width;
+
+ while (w--)
+ {
+ ma = *mask++;
+ if (ma == 0xffffffff)
+ {
+ if (srca == 0xff)
+ {
+ *dst = src16;
+ }
+ else
+ {
+ d = *dst;
+ d = fbOver24 (src, cvt0565to8888(d));
+ *dst = cvt8888to0565(d);
+ }
+ }
+ else if (ma)
+ {
+ d = *dst;
+ d = cvt0565to8888(d);
+ FbInOverC (src, srca, ma, d, 0, m);
+ FbInOverC (src, srca, ma, d, 8, n);
+ FbInOverC (src, srca, ma, d, 16, o);
+ d = m|n|o;
+ *dst = cvt8888to0565(d);
+ }
+ dst++;
+ }
+ }
+}
+
+void
+fbCompositeSrc_8888x8888 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 *dstLine, *dst, dstMask;
+ CARD32 *srcLine, *src, s;
+ FbStride dstStride, srcStride;
+ CARD8 a;
+ CARD16 w;
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
+ fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
+
+ dstMask = FbFullMask (pDst->pDrawable->depth);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ src = srcLine;
+ srcLine += srcStride;
+ w = width;
+
+ while (w--)
+ {
+ s = *src++;
+ a = s >> 24;
+ if (a == 0xff)
+ *dst = s & dstMask;
+ else if (a)
+ *dst = fbOver (s, *dst) & dstMask;
+ dst++;
+ }
+ }
+}
+
+void
+fbCompositeSrc_8888x0888 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD8 *dstLine, *dst;
+ CARD32 d;
+ CARD32 *srcLine, *src, s;
+ CARD8 a;
+ FbStride dstStride, srcStride;
+ CARD16 w;
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
+ fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ src = srcLine;
+ srcLine += srcStride;
+ w = width;
+
+ while (w--)
+ {
+ s = *src++;
+ a = s >> 24;
+ if (a)
+ {
+ if (a == 0xff)
+ d = s;
+ else
+ d = fbOver24 (s, Fetch24(dst));
+ Store24(dst,d);
+ }
+ dst += 3;
+ }
+ }
+}
+
+void
+fbCompositeSrc_8888x0565 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD16 *dstLine, *dst;
+ CARD32 d;
+ CARD32 *srcLine, *src, s;
+ CARD8 a;
+ FbStride dstStride, srcStride;
+ CARD16 w;
+
+ fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
+ fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ src = srcLine;
+ srcLine += srcStride;
+ w = width;
+
+ while (w--)
+ {
+ s = *src++;
+ a = s >> 24;
+ if (a)
+ {
+ if (a == 0xff)
+ d = s;
+ else
+ {
+ d = *dst;
+ d = fbOver24 (s, cvt0565to8888(d));
+ }
+ *dst = cvt8888to0565(d);
+ }
+ dst++;
+ }
+ }
+}
+
+void
+fbCompositeSrc_0565x0565 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD16 *dstLine, *dst;
+ CARD16 *srcLine, *src;
+ FbStride dstStride, srcStride;
+ CARD16 w;
+
+ fbComposeGetStart (pSrc, xSrc, ySrc, CARD16, srcStride, srcLine, 1);
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ src = srcLine;
+ srcLine += srcStride;
+ w = width;
+
+ while (w--)
+ *dst++ = *src++;
+ }
+}
+
+void
+fbCompositeSrcAdd_8000x8000 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD8 *dstLine, *dst;
+ CARD8 *srcLine, *src;
+ FbStride dstStride, srcStride;
+ CARD16 w;
+ CARD8 s, d;
+ CARD16 t;
+
+ fbComposeGetStart (pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 1);
+ fbComposeGetStart (pDst, xDst, yDst, CARD8, dstStride, dstLine, 1);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ src = srcLine;
+ srcLine += srcStride;
+ w = width;
+
+ while (w--)
+ {
+ s = *src++;
+ if (s)
+ {
+ if (s != 0xff)
+ {
+ d = *dst;
+ t = d + s;
+ s = t | (0 - (t >> 8));
+ }
+ *dst = s;
+ }
+ dst++;
+ }
+ }
+}
+
+void
+fbCompositeSrcAdd_8888x8888 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 *dstLine, *dst;
+ CARD32 *srcLine, *src;
+ FbStride dstStride, srcStride;
+ CARD16 w;
+ CARD32 s, d;
+ CARD16 t;
+ CARD32 m,n,o,p;
+
+ fbComposeGetStart (pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
+ fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ src = srcLine;
+ srcLine += srcStride;
+ w = width;
+
+ while (w--)
+ {
+ s = *src++;
+ if (s)
+ {
+ if (s != 0xffffffff)
+ {
+ d = *dst;
+ if (d)
+ {
+ m = FbAdd(s,d,0,t);
+ n = FbAdd(s,d,8,t);
+ o = FbAdd(s,d,16,t);
+ p = FbAdd(s,d,24,t);
+ s = m|n|o|p;
+ }
+ }
+ *dst = s;
+ }
+ dst++;
+ }
+ }
+}
+
+void
+fbCompositeSrcAdd_1000x1000 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ FbBits *dstBits, *srcBits;
+ FbStride dstStride, srcStride;
+ int dstBpp, srcBpp;
+ int dstXoff, dstYoff;
+ int srcXoff, srcYoff;
+
+ fbGetDrawable(pSrc->pDrawable, srcBits, srcStride, srcBpp, srcXoff, srcYoff);
+
+ fbGetDrawable(pDst->pDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff);
+
+ fbBlt (srcBits + srcStride * (ySrc + srcYoff),
+ srcStride,
+ xSrc + srcXoff,
+
+ dstBits + dstStride * (yDst + dstYoff),
+ dstStride,
+ xDst + dstXoff,
+
+ width,
+ height,
+
+ GXor,
+ FB_ALLONES,
+ srcBpp,
+
+ FALSE,
+ FALSE);
+}
+
+void
+fbCompositeSolidMask_nx1xn (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ FbBits *dstBits;
+ FbStip *maskBits;
+ FbStride dstStride, maskStride;
+ int dstBpp, maskBpp;
+ int dstXoff, dstYoff;
+ int maskXoff, maskYoff;
+ FbBits src;
+
+ fbComposeGetSolid(pSrc, src, pDst->format);
+
+ if ((src & 0xff000000) != 0xff000000)
+ {
+ fbCompositeGeneral (op, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask, xDst, yDst,
+ width, height);
+ return;
+ }
+ fbGetStipDrawable (pMask->pDrawable, maskBits, maskStride, maskBpp, maskXoff, maskYoff);
+ fbGetDrawable (pDst->pDrawable, dstBits, dstStride, dstBpp, dstXoff, dstYoff);
+
+ switch (dstBpp) {
+ case 32:
+ break;
+ case 24:
+ break;
+ case 16:
+ src = cvt8888to0565(src);
+ break;
+ }
+
+ src = fbReplicatePixel (src, dstBpp);
+
+ fbBltOne (maskBits + maskStride * (yMask + maskYoff),
+ maskStride,
+ xMask + maskXoff,
+
+ dstBits + dstStride * (yDst + dstYoff),
+ dstStride,
+ (xDst + dstXoff) * dstBpp,
+ dstBpp,
+
+ width * dstBpp,
+ height,
+
+ 0x0,
+ src,
+ FB_ALLONES,
+ 0x0);
+}
+
+# define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
+
+void
+fbComposite (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ RegionRec region;
+ int n;
+ BoxPtr pbox;
+ CompositeFunc func = NULL;
+ Bool srcRepeat = pSrc->pDrawable && pSrc->repeat == RepeatNormal;
+ Bool maskRepeat = FALSE;
+ Bool srcAlphaMap = pSrc->alphaMap != 0;
+ Bool maskAlphaMap = FALSE;
+ Bool dstAlphaMap = pDst->alphaMap != 0;
+ int x_msk, y_msk, x_src, y_src, x_dst, y_dst;
+ int w, h, w_this, h_this;
+
+#ifdef USE_MMX
+ static Bool mmx_setup = FALSE;
+ if (!mmx_setup) {
+ fbComposeSetupMMX();
+ mmx_setup = TRUE;
+ }
+#endif
+
+ xDst += pDst->pDrawable->x;
+ yDst += pDst->pDrawable->y;
+ if (pSrc->pDrawable) {
+ xSrc += pSrc->pDrawable->x;
+ ySrc += pSrc->pDrawable->y;
+ }
+ if (pMask && pMask->pDrawable)
+ {
+ xMask += pMask->pDrawable->x;
+ yMask += pMask->pDrawable->y;
+ maskRepeat = pMask->repeat == RepeatNormal;
+ maskAlphaMap = pMask->alphaMap != 0;
+ }
+
+ if (pSrc->pDrawable && (!pMask || pMask->pDrawable)
+ && !pSrc->transform && !(pMask && pMask->transform)
+ && !maskAlphaMap && !srcAlphaMap && !dstAlphaMap
+ && (pSrc->filter != PictFilterConvolution)
+ && (!pMask || pMask->filter != PictFilterConvolution))
+ switch (op) {
+ case PictOpSrc:
+#ifdef USE_MMX
+ if (!pMask && pSrc->format == pDst->format &&
+ pSrc->format != PICT_a8 && pSrc->pDrawable != pDst->pDrawable)
+ {
+ func = fbCompositeCopyAreammx;
+ }
+#endif
+ break;
+ case PictOpOver:
+ if (pMask)
+ {
+ if (srcRepeat &&
+ pSrc->pDrawable->width == 1 &&
+ pSrc->pDrawable->height == 1)
+ {
+ srcRepeat = FALSE;
+ if (PICT_FORMAT_COLOR(pSrc->format)) {
+ switch (pMask->format) {
+ case PICT_a8:
+ switch (pDst->format) {
+ case PICT_r5g6b5:
+ case PICT_b5g6r5:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8x0565mmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8x0565;
+ break;
+ case PICT_r8g8b8:
+ case PICT_b8g8r8:
+ func = fbCompositeSolidMask_nx8x0888;
+ break;
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+ case PICT_a8b8g8r8:
+ case PICT_x8b8g8r8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8x8888mmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8x8888;
+ break;
+ }
+ break;
+ case PICT_a8r8g8b8:
+ if (pMask->componentAlpha) {
+ switch (pDst->format) {
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8888x8888Cmmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8888x8888C;
+ break;
+ case PICT_r5g6b5:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8888x0565Cmmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8888x0565C;
+ break;
+ }
+ }
+ break;
+ case PICT_a8b8g8r8:
+ if (pMask->componentAlpha) {
+ switch (pDst->format) {
+ case PICT_a8b8g8r8:
+ case PICT_x8b8g8r8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8888x8888Cmmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8888x8888C;
+ break;
+ case PICT_b5g6r5:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8888x0565Cmmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8888x0565C;
+ break;
+ }
+ }
+ break;
+ case PICT_a1:
+ switch (pDst->format) {
+ case PICT_r5g6b5:
+ case PICT_b5g6r5:
+ case PICT_r8g8b8:
+ case PICT_b8g8r8:
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+ case PICT_a8b8g8r8:
+ case PICT_x8b8g8r8:
+ func = fbCompositeSolidMask_nx1xn;
+ break;
+ }
+ break;
+ }
+ }
+ }
+ else /* has mask and non-repeating source */
+ {
+ if (pSrc->pDrawable == pMask->pDrawable &&
+ xSrc == xMask && ySrc == yMask &&
+ !pMask->componentAlpha)
+ {
+ /* source == mask: non-premultiplied data */
+ switch (pSrc->format) {
+ case PICT_x8b8g8r8:
+ switch (pMask->format) {
+ case PICT_a8r8g8b8:
+ case PICT_a8b8g8r8:
+ switch (pDst->format) {
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888RevNPx8888mmx;
+#endif
+ break;
+ case PICT_r5g6b5:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888RevNPx0565mmx;
+#endif
+ break;
+ }
+ break;
+ }
+ break;
+ case PICT_x8r8g8b8:
+ switch (pMask->format) {
+ case PICT_a8r8g8b8:
+ case PICT_a8b8g8r8:
+ switch (pDst->format) {
+ case PICT_a8b8g8r8:
+ case PICT_x8b8g8r8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888RevNPx8888mmx;
+#endif
+ break;
+ case PICT_r5g6b5:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888RevNPx0565mmx;
+#endif
+ break;
+ }
+ break;
+ }
+ break;
+ }
+ break;
+ }
+ else
+ {
+ /* non-repeating source, repeating mask => translucent window */
+ if (maskRepeat &&
+ pMask->pDrawable->width == 1 &&
+ pMask->pDrawable->height == 1)
+ {
+ if (pSrc->format == PICT_x8r8g8b8 &&
+ pDst->format == PICT_x8r8g8b8 &&
+ pMask->format == PICT_a8)
+ {
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888x8x8888mmx;
+#endif
+ }
+ }
+ }
+ }
+ }
+ else /* no mask */
+ {
+ if (srcRepeat &&
+ pSrc->pDrawable->width == 1 &&
+ pSrc->pDrawable->height == 1)
+ {
+ /* no mask and repeating source */
+ switch (pSrc->format) {
+ case PICT_a8r8g8b8:
+ switch (pDst->format) {
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ {
+ srcRepeat = FALSE;
+ func = fbCompositeSolid_nx8888mmx;
+ }
+#endif
+ break;
+ case PICT_r5g6b5:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ {
+ srcRepeat = FALSE;
+ func = fbCompositeSolid_nx0565mmx;
+ }
+#endif
+ break;
+ }
+ break;
+ }
+ }
+ else
+ {
+ switch (pSrc->format) {
+ case PICT_a8r8g8b8:
+ switch (pDst->format) {
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888x8888mmx;
+ else
+#endif
+ func = fbCompositeSrc_8888x8888;
+ break;
+ case PICT_r8g8b8:
+ func = fbCompositeSrc_8888x0888;
+ break;
+ case PICT_r5g6b5:
+ func = fbCompositeSrc_8888x0565;
+ break;
+ }
+ break;
+ case PICT_x8r8g8b8:
+ switch (pDst->format) {
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeCopyAreammx;
+#endif
+ break;
+ }
+ case PICT_x8b8g8r8:
+ switch (pDst->format) {
+ case PICT_a8b8g8r8:
+ case PICT_x8b8g8r8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeCopyAreammx;
+#endif
+ break;
+ }
+ break;
+ case PICT_a8b8g8r8:
+ switch (pDst->format) {
+ case PICT_a8b8g8r8:
+ case PICT_x8b8g8r8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888x8888mmx;
+ else
+#endif
+ func = fbCompositeSrc_8888x8888;
+ break;
+ case PICT_b8g8r8:
+ func = fbCompositeSrc_8888x0888;
+ break;
+ case PICT_b5g6r5:
+ func = fbCompositeSrc_8888x0565;
+ break;
+ }
+ break;
+ case PICT_r5g6b5:
+ switch (pDst->format) {
+ case PICT_r5g6b5:
+ func = fbCompositeSrc_0565x0565;
+ break;
+ }
+ break;
+ case PICT_b5g6r5:
+ switch (pDst->format) {
+ case PICT_b5g6r5:
+ func = fbCompositeSrc_0565x0565;
+ break;
+ }
+ break;
+ }
+ }
+ }
+ break;
+ case PictOpAdd:
+ if (pMask == 0)
+ {
+ switch (pSrc->format) {
+ case PICT_a8r8g8b8:
+ switch (pDst->format) {
+ case PICT_a8r8g8b8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrcAdd_8888x8888mmx;
+ else
+#endif
+ func = fbCompositeSrcAdd_8888x8888;
+ break;
+ }
+ break;
+ case PICT_a8b8g8r8:
+ switch (pDst->format) {
+ case PICT_a8b8g8r8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrcAdd_8888x8888mmx;
+ else
+#endif
+ func = fbCompositeSrcAdd_8888x8888;
+ break;
+ }
+ break;
+ case PICT_a8:
+ switch (pDst->format) {
+ case PICT_a8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrcAdd_8000x8000mmx;
+ else
+#endif
+ func = fbCompositeSrcAdd_8000x8000;
+ break;
+ }
+ break;
+ case PICT_a1:
+ switch (pDst->format) {
+ case PICT_a1:
+ func = fbCompositeSrcAdd_1000x1000;
+ break;
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ if (!func) {
+ /* no fast path, use the general code */
+ fbCompositeGeneral(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
+ return;
+ }
+
+ if (!miComputeCompositeRegion (&region,
+ pSrc,
+ pMask,
+ pDst,
+ xSrc,
+ ySrc,
+ xMask,
+ yMask,
+ xDst,
+ yDst,
+ width,
+ height))
+ return;
+
+ n = REGION_NUM_RECTS (&region);
+ pbox = REGION_RECTS (&region);
+ while (n--)
+ {
+ h = pbox->y2 - pbox->y1;
+ y_src = pbox->y1 - yDst + ySrc;
+ y_msk = pbox->y1 - yDst + yMask;
+ y_dst = pbox->y1;
+ while (h)
+ {
+ h_this = h;
+ w = pbox->x2 - pbox->x1;
+ x_src = pbox->x1 - xDst + xSrc;
+ x_msk = pbox->x1 - xDst + xMask;
+ x_dst = pbox->x1;
+ if (maskRepeat)
+ {
+ y_msk = mod (y_msk - pMask->pDrawable->y, pMask->pDrawable->height);
+ if (h_this > pMask->pDrawable->height - y_msk)
+ h_this = pMask->pDrawable->height - y_msk;
+ y_msk += pMask->pDrawable->y;
+ }
+ if (srcRepeat)
+ {
+ y_src = mod (y_src - pSrc->pDrawable->y, pSrc->pDrawable->height);
+ if (h_this > pSrc->pDrawable->height - y_src)
+ h_this = pSrc->pDrawable->height - y_src;
+ y_src += pSrc->pDrawable->y;
+ }
+ while (w)
+ {
+ w_this = w;
+ if (maskRepeat)
+ {
+ x_msk = mod (x_msk - pMask->pDrawable->x, pMask->pDrawable->width);
+ if (w_this > pMask->pDrawable->width - x_msk)
+ w_this = pMask->pDrawable->width - x_msk;
+ x_msk += pMask->pDrawable->x;
+ }
+ if (srcRepeat)
+ {
+ x_src = mod (x_src - pSrc->pDrawable->x, pSrc->pDrawable->width);
+ if (w_this > pSrc->pDrawable->width - x_src)
+ w_this = pSrc->pDrawable->width - x_src;
+ x_src += pSrc->pDrawable->x;
+ }
+ (*func) (op, pSrc, pMask, pDst,
+ x_src, y_src, x_msk, y_msk, x_dst, y_dst,
+ w_this, h_this);
+ w -= w_this;
+ x_src += w_this;
+ x_msk += w_this;
+ x_dst += w_this;
+ }
+ h -= h_this;
+ y_src += h_this;
+ y_msk += h_this;
+ y_dst += h_this;
+ }
+ pbox++;
+ }
+ REGION_UNINIT (pDst->pDrawable->pScreen, &region);
+}
+
+#endif /* RENDER */
+
+Bool
+fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
+{
+
+#ifdef RENDER
+
+ PictureScreenPtr ps;
+
+ if (!miPictureInit (pScreen, formats, nformats))
+ return FALSE;
+ ps = GetPictureScreen(pScreen);
+ ps->Composite = fbComposite;
+ ps->Glyphs = miGlyphs;
+ ps->CompositeRects = miCompositeRects;
+ ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
+ ps->AddTraps = fbAddTraps;
+ ps->AddTriangles = fbAddTriangles;
+
+#endif /* RENDER */
+
+ return TRUE;
+}
+
+#ifdef USE_MMX
+/* The CPU detection code needs to be in a file not compiled with
+ * "-mmmx -msse", as gcc would generate CMOV instructions otherwise
+ * that would lead to SIGILL instructions on old CPUs that don't have
+ * it.
+ */
+#if !defined(__amd64__) && !defined(__x86_64__)
+
+enum CPUFeatures {
+ NoFeatures = 0,
+ MMX = 0x1,
+ MMX_Extensions = 0x2,
+ SSE = 0x6,
+ SSE2 = 0x8,
+ CMOV = 0x10
+};
+
+static unsigned int detectCPUFeatures(void) {
+ unsigned int result;
+ char vendor[13];
+ vendor[0] = 0;
+ vendor[12] = 0;
+ /* see p. 118 of amd64 instruction set manual Vol3 */
+ /* We need to be careful about the handling of %ebx and
+ * %esp here. We can't declare either one as clobbered
+ * since they are special registers (%ebx is the "PIC
+ * register" holding an offset to global data, %esp the
+ * stack pointer), so we need to make sure they have their+ * original values when we access the output operands.
+ */
+ __asm__ ("pushf\n"
+ "pop %%eax\n"
+ "mov %%eax, %%ecx\n"
+ "xor $0x00200000, %%eax\n"
+ "push %%eax\n"
+ "popf\n"
+ "pushf\n"
+ "pop %%eax\n"
+ "mov $0x0, %%edx\n"
+ "xor %%ecx, %%eax\n"
+ "jz 1\n"
+
+ "mov $0x00000000, %%eax\n"
+ "push %%ebx\n"
+ "cpuid\n"
+ "mov %%ebx, %%eax\n"
+ "pop %%ebx\n"
+ "mov %%eax, %1\n"
+ "mov %%edx, %2\n"
+ "mov %%ecx, %3\n"
+ "mov $0x00000001, %%eax\n"
+ "push %%ebx\n"
+ "cpuid\n"
+ "pop %%ebx\n"
+ "1:\n"
+ "mov %%edx, %0\n"
+ : "=r" (result),
+ "=m" (vendor[0]),
+ "=m" (vendor[4]),
+ "=m" (vendor[8])
+ :
+ : "%eax", "%ecx", "%edx"
+ );
+
+ unsigned int features = 0;
+ if (result) {
+ /* result now contains the standard feature bits */
+ if (result & (1 << 15))
+ features |= CMOV;
+ if (result & (1 << 23))
+ features |= MMX;
+ if (result & (1 << 25))
+ features |= SSE;
+ if (result & (1 << 26))
+ features |= SSE2;
+ if ((result & MMX) && !(result & SSE) && (strcmp(vendor, "AuthenticAMD") == 0)) {
+ /* check for AMD MMX extensions */
+
+ unsigned int result;
+ __asm__("push %%ebx\n"
+ "mov $0x80000000, %%eax\n"
+ "cpuid\n"
+ "xor %%edx, %%edx\n"
+ "cmp $0x1, %%eax\n"
+ "jge 2\n"
+ "mov $0x80000001, %%eax\n"
+ "cpuid\n"
+ "2:\n"
+ "pop %%ebx\n"
+ "mov %%edx, %0\n"
+ : "=r" (result)
+ :
+ : "%eax", "%ecx", "%edx"
+ );
+ if (result & (1<<22))
+ features |= MMX_Extensions;
+ }
+ }
+ return features;
+}
+
+Bool
+fbHaveMMX (void)
+{
+ static Bool initialized = FALSE;
+ static Bool mmx_present;
+
+ if (!initialized)
+ {
+ unsigned int features = detectCPUFeatures();
+ mmx_present = (features & (MMX|MMX_Extensions)) == (MMX|MMX_Extensions);
+ initialized = TRUE;
+ }
+
+ return mmx_present;
+}
+#endif /* __amd64__ */
+#endif
diff --git a/nx-X11/programs/Xserver/fb/fbpict.h b/nx-X11/programs/Xserver/fb/fbpict.h
new file mode 100644
index 000000000..665b92dd1
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbpict.h
@@ -0,0 +1,612 @@
+/*
+ * $XFree86: xc/programs/Xserver/fb/fbpict.h,v 1.7 2001/07/18 10:15:02 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _FBPICT_H_
+#define _FBPICT_H_
+
+#include "renderedge.h"
+
+#define FbIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) )
+#define FbIntDiv(a,b) (((CARD16) (a) * 255) / (b))
+
+#define FbGet8(v,i) ((CARD16) (CARD8) ((v) >> i))
+
+/*
+ * There are two ways of handling alpha -- either as a single unified value or
+ * a separate value for each component, hence each macro must have two
+ * versions. The unified alpha version has a 'U' at the end of the name,
+ * the component version has a 'C'. Similarly, functions which deal with
+ * this difference will have two versions using the same convention.
+ */
+
+#define FbOverU(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),(a),(t)) + FbGet8(x,i),\
+ (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
+
+#define FbOverC(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),FbGet8(a,i),(t)) + FbGet8(x,i),\
+ (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
+
+#define FbInU(x,i,a,t) ((CARD32) FbIntMult(FbGet8(x,i),(a),(t)) << (i))
+
+#define FbInC(x,i,a,t) ((CARD32) FbIntMult(FbGet8(x,i),FbGet8(a,i),(t)) << (i))
+
+#define FbGen(x,y,i,ax,ay,t,u,v) ((t) = (FbIntMult(FbGet8(y,i),ay,(u)) + \
+ FbIntMult(FbGet8(x,i),ax,(v))),\
+ (CARD32) ((CARD8) ((t) | \
+ (0 - ((t) >> 8)))) << (i))
+
+#define FbAdd(x,y,i,t) ((t) = FbGet8(x,i) + FbGet8(y,i), \
+ (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
+
+
+#define Alpha(x) ((x) >> 24)
+#define Red(x) (((x) >> 16) & 0xff)
+#define Green(x) (((x) >> 8) & 0xff)
+#define Blue(x) ((x) & 0xff)
+
+#define fbComposeGetSolid(pict, bits, fmt) { \
+ FbBits *__bits__; \
+ FbStride __stride__; \
+ int __bpp__; \
+ int __xoff__,__yoff__; \
+\
+ fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \
+ switch (__bpp__) { \
+ case 32: \
+ (bits) = *(CARD32 *) __bits__; \
+ break; \
+ case 24: \
+ (bits) = Fetch24 ((CARD8 *) __bits__); \
+ break; \
+ case 16: \
+ (bits) = *(CARD16 *) __bits__; \
+ (bits) = cvt0565to8888(bits); \
+ break; \
+ default: \
+ return; \
+ } \
+ /* If necessary, convert RGB <--> BGR. */ \
+ if (PICT_FORMAT_TYPE((pict)->format) != PICT_FORMAT_TYPE(fmt)) \
+ { \
+ (bits) = (((bits) & 0xff000000) | \
+ (((bits) & 0x00ff0000) >> 16) | \
+ (((bits) & 0x0000ff00) >> 0) | \
+ (((bits) & 0x000000ff) << 16)); \
+ } \
+ /* manage missing src alpha */ \
+ if ((pict)->pFormat->direct.alphaMask == 0) \
+ (bits) |= 0xff000000; \
+}
+
+#define fbComposeGetStart(pict,x,y,type,stride,line,mul) {\
+ FbBits *__bits__; \
+ FbStride __stride__; \
+ int __bpp__; \
+ int __xoff__,__yoff__; \
+\
+ fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \
+ (stride) = __stride__ * sizeof (FbBits) / sizeof (type); \
+ (line) = ((type *) __bits__) + (stride) * ((y) + __yoff__) + (mul) * ((x) + __xoff__); \
+}
+#define cvt8888to0565(s) ((((s) >> 3) & 0x001f) | \
+ (((s) >> 5) & 0x07e0) | \
+ (((s) >> 8) & 0xf800))
+#define cvt0565to8888(s) (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \
+ ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \
+ ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)))
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define Fetch24(a) ((unsigned long) (a) & 1 ? \
+ ((*(a) << 16) | *((CARD16 *) ((a)+1))) : \
+ ((*((CARD16 *) (a)) << 8) | *((a)+2)))
+#define Store24(a,v) ((unsigned long) (a) & 1 ? \
+ ((*(a) = (CARD8) ((v) >> 16)), \
+ (*((CARD16 *) ((a)+1)) = (CARD16) (v))) : \
+ ((*((CARD16 *) (a)) = (CARD16) ((v) >> 8)), \
+ (*((a)+2) = (CARD8) (v))))
+#else
+#define Fetch24(a) ((unsigned long) (a) & 1 ? \
+ ((*(a)) | (*((CARD16 *) ((a)+1)) << 8)) : \
+ ((*((CARD16 *) (a))) | (*((a)+2) << 16)))
+#define Store24(a,v) ((unsigned long) (a) & 1 ? \
+ ((*(a) = (CARD8) (v)), \
+ (*((CARD16 *) ((a)+1)) = (CARD16) ((v) >> 8))) : \
+ ((*((CARD16 *) (a)) = (CARD16) (v)),\
+ (*((a)+2) = (CARD8) ((v) >> 16))))
+#endif
+
+/*
+ The methods below use some tricks to be able to do two color
+ components at the same time.
+*/
+
+/*
+ x_c = (x_c * a) / 255
+*/
+#define FbByteMul(x, a) do { \
+ CARD32 t = ((x & 0xff00ff) * a) + 0x800080; \
+ t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
+ t &= 0xff00ff; \
+ \
+ x = (((x >> 8) & 0xff00ff) * a) + 0x800080; \
+ x = (x + ((x >> 8) & 0xff00ff)); \
+ x &= 0xff00ff00; \
+ x += t; \
+ } while (0)
+
+/*
+ x_c = (x_c * a) / 255 + y
+*/
+#define FbByteMulAdd(x, a, y) do { \
+ CARD32 t = ((x & 0xff00ff) * a) + 0x800080; \
+ t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
+ t &= 0xff00ff; \
+ t += y & 0xff00ff; \
+ t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
+ t &= 0xff00ff; \
+ \
+ x = (((x >> 8) & 0xff00ff) * a) + 0x800080; \
+ x = (x + ((x >> 8) & 0xff00ff)) >> 8; \
+ x &= 0xff00ff; \
+ x += (y >> 8) & 0xff00ff; \
+ x |= 0x1000100 - ((t >> 8) & 0xff00ff); \
+ x &= 0xff00ff; \
+ x <<= 8; \
+ x += t; \
+ } while (0)
+
+/*
+ x_c = (x_c * a + y_c * b) / 255
+*/
+#define FbByteAddMul(x, a, y, b) do { \
+ CARD32 t; \
+ CARD32 r = (x >> 24) * a + (y >> 24) * b + 0x80; \
+ r += (r >> 8); \
+ r >>= 8; \
+ \
+ t = (x & 0xff00) * a + (y & 0xff00) * b; \
+ t += (t >> 8) + 0x8000; \
+ t >>= 16; \
+ \
+ t |= r << 16; \
+ t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
+ t &= 0xff00ff; \
+ t <<= 8; \
+ \
+ r = ((x >> 16) & 0xff) * a + ((y >> 16) & 0xff) * b + 0x80; \
+ r += (r >> 8); \
+ r >>= 8; \
+ \
+ x = (x & 0xff) * a + (y & 0xff) * b + 0x80; \
+ x += (x >> 8); \
+ x >>= 8; \
+ x |= r << 16; \
+ x |= 0x1000100 - ((x >> 8) & 0xff00ff); \
+ x &= 0xff00ff; \
+ x |= t; \
+} while (0)
+
+/*
+ x_c = (x_c * a + y_c *b) / 256
+*/
+#define FbByteAddMul_256(x, a, y, b) do { \
+ CARD32 t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; \
+ t >>= 8; \
+ t &= 0xff00ff; \
+ \
+ x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b; \
+ x &= 0xff00ff00; \
+ x += t; \
+} while (0)
+/*
+ x_c = (x_c * a_c) / 255
+*/
+#define FbByteMulC(x, a) do { \
+ CARD32 t; \
+ CARD32 r = (x & 0xff) * (a & 0xff); \
+ r |= (x & 0xff0000) * ((a >> 16) & 0xff); \
+ r += 0x800080; \
+ r = (r + ((r >> 8) & 0xff00ff)) >> 8; \
+ r &= 0xff00ff; \
+ \
+ x >>= 8; \
+ t = (x & 0xff) * ((a >> 8) & 0xff); \
+ t |= (x & 0xff0000) * (a >> 24); \
+ t += 0x800080; \
+ t = t + ((t >> 8) & 0xff00ff); \
+ x = r | (t & 0xff00ff00); \
+ \
+ } while (0)
+
+/*
+ x_c = (x_c * a) / 255 + y
+*/
+#define FbByteMulAddC(x, a, y) do { \
+ CARD32 t; \
+ CARD32 r = (x & 0xff) * (a & 0xff); \
+ r |= (x & 0xff0000) * ((a >> 16) & 0xff); \
+ r += 0x800080; \
+ r = (r + ((r >> 8) & 0xff00ff)) >> 8; \
+ r &= 0xff00ff; \
+ r += y & 0xff00ff; \
+ r |= 0x1000100 - ((r >> 8) & 0xff00ff); \
+ r &= 0xff00ff; \
+ \
+ x >>= 8; \
+ t = (x & 0xff) * ((a >> 8) & 0xff); \
+ t |= (x & 0xff0000) * (a >> 24); \
+ t += 0x800080; \
+ t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
+ t &= 0xff00ff; \
+ t += (y >> 8) & 0xff00ff; \
+ t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
+ t &= 0xff00ff; \
+ x = r | (t << 8); \
+ } while (0)
+
+/*
+ x_c = (x_c * a_c + y_c * b) / 255
+*/
+#define FbByteAddMulC(x, a, y, b) do { \
+ CARD32 t; \
+ CARD32 r = (x >> 24) * (a >> 24) + (y >> 24) * b; \
+ r += (r >> 8) + 0x80; \
+ r >>= 8; \
+ \
+ t = (x & 0xff00) * ((a >> 8) & 0xff) + (y & 0xff00) * b; \
+ t += (t >> 8) + 0x8000; \
+ t >>= 16; \
+ \
+ t |= r << 16; \
+ t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
+ t &= 0xff00ff; \
+ t <<= 8; \
+ \
+ r = ((x >> 16) & 0xff) * ((a >> 16) & 0xff) + ((y >> 16) & 0xff) * b + 0x80; \
+ r += (r >> 8); \
+ r >>= 8; \
+ \
+ x = (x & 0xff) * (a & 0xff) + (y & 0xff) * b + 0x80; \
+ x += (x >> 8); \
+ x >>= 8; \
+ x |= r << 16; \
+ x |= 0x1000100 - ((x >> 8) & 0xff00ff); \
+ x &= 0xff00ff; \
+ x |= t; \
+ } while (0)
+
+/*
+ x_c = min(x_c + y_c, 255)
+*/
+#define FbByteAdd(x, y) do { \
+ CARD32 t; \
+ CARD32 r = (x & 0xff00ff) + (y & 0xff00ff); \
+ r |= 0x1000100 - ((r >> 8) & 0xff00ff); \
+ r &= 0xff00ff; \
+ \
+ t = ((x >> 8) & 0xff00ff) + ((y >> 8) & 0xff00ff); \
+ t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
+ r |= (t & 0xff00ff) << 8; \
+ x = r; \
+ } while (0)
+
+#define div_255(x) (((x) + 0x80 + (((x) + 0x80) >> 8)) >> 8)
+
+#if defined(__i386__) && defined(__GNUC__)
+#define FASTCALL __attribute__((regparm(3)))
+#else
+#define FASTCALL
+#endif
+
+#if defined(__GNUC__)
+#define INLINE __inline__
+#else
+#define INLINE
+#endif
+
+typedef struct _FbComposeData {
+ CARD8 op;
+ PicturePtr src;
+ PicturePtr mask;
+ PicturePtr dest;
+ INT16 xSrc;
+ INT16 ySrc;
+ INT16 xMask;
+ INT16 yMask;
+ INT16 xDest;
+ INT16 yDest;
+ CARD16 width;
+ CARD16 height;
+} FbComposeData;
+
+typedef FASTCALL void (*CombineMaskU) (CARD32 *src, const CARD32 *mask, int width);
+typedef FASTCALL void (*CombineFuncU) (CARD32 *dest, const CARD32 *src, int width);
+typedef FASTCALL void (*CombineFuncC) (CARD32 *dest, CARD32 *src, CARD32 *mask, int width);
+
+typedef struct _FbComposeFunctions {
+ CombineFuncU *combineU;
+ CombineFuncC *combineC;
+ CombineMaskU combineMaskU;
+} FbComposeFunctions;
+
+/* fbcompose.c */
+
+void
+fbCompositeGeneral (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+
+/* fbedge.c */
+void
+fbRasterizeEdges (FbBits *buf,
+ int bpp,
+ int width,
+ int stride,
+ RenderEdge *l,
+ RenderEdge *r,
+ xFixed t,
+ xFixed b);
+
+/* fbpict.c */
+CARD32
+fbOver (CARD32 x, CARD32 y);
+
+CARD32
+fbOver24 (CARD32 x, CARD32 y);
+
+CARD32
+fbIn (CARD32 x, CARD8 y);
+
+void
+fbCompositeSolidMask_nx8x8888 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
+fbCompositeSolidMask_nx8x0888 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
+fbCompositeSolidMask_nx8888x8888C (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
+fbCompositeSolidMask_nx8x0565 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
+fbCompositeSolidMask_nx8888x0565C (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
+fbCompositeSrc_8888x8888 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
+fbCompositeSrc_8888x0888 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
+fbCompositeSrc_8888x0565 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
+fbCompositeSrc_0565x0565 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
+fbCompositeSrcAdd_8000x8000 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
+fbCompositeSrcAdd_8888x8888 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
+fbCompositeSrcAdd_1000x1000 (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
+fbCompositeSolidMask_nx1xn (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
+fbComposite (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+/* fbtrap.c */
+
+void
+fbAddTraps (PicturePtr pPicture,
+ INT16 xOff,
+ INT16 yOff,
+ int ntrap,
+ xTrap *traps);
+
+void
+fbRasterizeTrapezoid (PicturePtr alpha,
+ xTrapezoid *trap,
+ int x_off,
+ int y_off);
+
+void
+fbAddTriangles (PicturePtr pPicture,
+ INT16 xOff,
+ INT16 yOff,
+ int ntri,
+ xTriangle *tris);
+
+#endif /* _FBPICT_H_ */
diff --git a/nx-X11/programs/Xserver/fb/fbpixmap.c b/nx-X11/programs/Xserver/fb/fbpixmap.c
new file mode 100644
index 000000000..decc07ba6
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbpixmap.c
@@ -0,0 +1,389 @@
+/*
+ * Id: fbpixmap.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbpixmap.c,v 1.9 2001/05/29 04:54:09 keithp Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#ifdef IN_MODULE
+#include "xf86_ansic.h"
+#endif
+
+PixmapPtr
+fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp)
+{
+ PixmapPtr pPixmap;
+ size_t datasize;
+ size_t paddedWidth;
+ int adjust;
+ int base;
+
+ paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits);
+ if (paddedWidth / 4 > 32767 || height > 32767)
+ return NullPixmap;
+ datasize = height * paddedWidth;
+#ifdef PIXPRIV
+ base = pScreen->totalPixmapSize;
+#else
+ base = sizeof (PixmapRec);
+#endif
+ adjust = 0;
+ if (base & 7)
+ adjust = 8 - (base & 7);
+ datasize += adjust;
+#ifdef FB_DEBUG
+ datasize += 2 * paddedWidth;
+#endif
+ pPixmap = AllocatePixmap(pScreen, datasize);
+ if (!pPixmap)
+ return NullPixmap;
+ pPixmap->drawable.type = DRAWABLE_PIXMAP;
+ pPixmap->drawable.class = 0;
+ pPixmap->drawable.pScreen = pScreen;
+ pPixmap->drawable.depth = depth;
+ pPixmap->drawable.bitsPerPixel = bpp;
+ pPixmap->drawable.id = 0;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pPixmap->drawable.x = 0;
+ pPixmap->drawable.y = 0;
+ pPixmap->drawable.width = width;
+ pPixmap->drawable.height = height;
+ pPixmap->devKind = paddedWidth;
+ pPixmap->refcnt = 1;
+ pPixmap->devPrivate.ptr = (pointer) ((char *)pPixmap + base + adjust);
+#ifdef FB_DEBUG
+ pPixmap->devPrivate.ptr = (void *) ((char *) pPixmap->devPrivate.ptr + paddedWidth);
+ fbInitializeDrawable (&pPixmap->drawable);
+#endif
+
+#ifdef COMPOSITE
+ pPixmap->screen_x = 0;
+ pPixmap->screen_y = 0;
+#endif
+
+ return pPixmap;
+}
+
+PixmapPtr
+fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth)
+{
+ int bpp;
+ bpp = BitsPerPixel (depth);
+#ifdef FB_SCREEN_PRIVATE
+ if (bpp == 32 && depth <= 24)
+ bpp = fbGetScreenPrivate(pScreen)->pix32bpp;
+#endif
+ return fbCreatePixmapBpp (pScreen, width, height, depth, bpp);
+}
+
+Bool
+fbDestroyPixmap (PixmapPtr pPixmap)
+{
+ if(--pPixmap->refcnt)
+ return TRUE;
+ xfree(pPixmap);
+ return TRUE;
+}
+
+#define ADDRECT(reg,r,fr,rx1,ry1,rx2,ry2) \
+if (((rx1) < (rx2)) && ((ry1) < (ry2)) && \
+ (!((reg)->data->numRects && \
+ ((r-1)->y1 == (ry1)) && \
+ ((r-1)->y2 == (ry2)) && \
+ ((r-1)->x1 <= (rx1)) && \
+ ((r-1)->x2 >= (rx2))))) \
+{ \
+ if ((reg)->data->numRects == (reg)->data->size) \
+ { \
+ miRectAlloc(reg, 1); \
+ fr = REGION_BOXPTR(reg); \
+ r = fr + (reg)->data->numRects; \
+ } \
+ r->x1 = (rx1); \
+ r->y1 = (ry1); \
+ r->x2 = (rx2); \
+ r->y2 = (ry2); \
+ (reg)->data->numRects++; \
+ if(r->x1 < (reg)->extents.x1) \
+ (reg)->extents.x1 = r->x1; \
+ if(r->x2 > (reg)->extents.x2) \
+ (reg)->extents.x2 = r->x2; \
+ r++; \
+}
+
+/* Convert bitmap clip mask into clipping region.
+ * First, goes through each line and makes boxes by noting the transitions
+ * from 0 to 1 and 1 to 0.
+ * Then it coalesces the current line with the previous if they have boxes
+ * at the same X coordinates.
+ */
+RegionPtr
+fbPixmapToRegion(PixmapPtr pPix)
+{
+ register RegionPtr pReg;
+ FbBits *pw, w;
+ register int ib;
+ int width, h, base, rx1 = 0, crects;
+ FbBits *pwLineEnd;
+ int irectPrevStart, irectLineStart;
+ register BoxPtr prectO, prectN;
+ BoxPtr FirstRect, rects, prectLineStart;
+ Bool fInBox, fSame;
+ register FbBits mask0 = FB_ALLONES & ~FbScrRight(FB_ALLONES, 1);
+ FbBits *pwLine;
+ int nWidth;
+
+ pReg = REGION_CREATE(pPix->drawable.pScreen, NULL, 1);
+ if(!pReg)
+ return NullRegion;
+ FirstRect = REGION_BOXPTR(pReg);
+ rects = FirstRect;
+
+ pwLine = (FbBits *) pPix->devPrivate.ptr;
+ nWidth = pPix->devKind >> (FB_SHIFT-3);
+
+ width = pPix->drawable.width;
+ pReg->extents.x1 = width - 1;
+ pReg->extents.x2 = 0;
+ irectPrevStart = -1;
+ for(h = 0; h < pPix->drawable.height; h++)
+ {
+ pw = pwLine;
+ pwLine += nWidth;
+ irectLineStart = rects - FirstRect;
+ /* If the Screen left most bit of the word is set, we're starting in
+ * a box */
+ if(*pw & mask0)
+ {
+ fInBox = TRUE;
+ rx1 = 0;
+ }
+ else
+ fInBox = FALSE;
+ /* Process all words which are fully in the pixmap */
+ pwLineEnd = pw + (width >> FB_SHIFT);
+ for (base = 0; pw < pwLineEnd; base += FB_UNIT)
+ {
+ w = *pw++;
+ if (fInBox)
+ {
+ if (!~w)
+ continue;
+ }
+ else
+ {
+ if (!w)
+ continue;
+ }
+ for(ib = 0; ib < FB_UNIT; ib++)
+ {
+ /* If the Screen left most bit of the word is set, we're
+ * starting a box */
+ if(w & mask0)
+ {
+ if(!fInBox)
+ {
+ rx1 = base + ib;
+ /* start new box */
+ fInBox = TRUE;
+ }
+ }
+ else
+ {
+ if(fInBox)
+ {
+ /* end box */
+ ADDRECT(pReg, rects, FirstRect,
+ rx1, h, base + ib, h + 1);
+ fInBox = FALSE;
+ }
+ }
+ /* Shift the word VISUALLY left one. */
+ w = FbScrLeft(w, 1);
+ }
+ }
+ if(width & FB_MASK)
+ {
+ /* Process final partial word on line */
+ w = *pw++;
+ for(ib = 0; ib < (width & FB_MASK); ib++)
+ {
+ /* If the Screen left most bit of the word is set, we're
+ * starting a box */
+ if(w & mask0)
+ {
+ if(!fInBox)
+ {
+ rx1 = base + ib;
+ /* start new box */
+ fInBox = TRUE;
+ }
+ }
+ else
+ {
+ if(fInBox)
+ {
+ /* end box */
+ ADDRECT(pReg, rects, FirstRect,
+ rx1, h, base + ib, h + 1);
+ fInBox = FALSE;
+ }
+ }
+ /* Shift the word VISUALLY left one. */
+ w = FbScrLeft(w, 1);
+ }
+ }
+ /* If scanline ended with last bit set, end the box */
+ if(fInBox)
+ {
+ ADDRECT(pReg, rects, FirstRect,
+ rx1, h, base + (width & FB_MASK), h + 1);
+ }
+ /* if all rectangles on this line have the same x-coords as
+ * those on the previous line, then add 1 to all the previous y2s and
+ * throw away all the rectangles from this line
+ */
+ fSame = FALSE;
+ if(irectPrevStart != -1)
+ {
+ crects = irectLineStart - irectPrevStart;
+ if(crects == ((rects - FirstRect) - irectLineStart))
+ {
+ prectO = FirstRect + irectPrevStart;
+ prectN = prectLineStart = FirstRect + irectLineStart;
+ fSame = TRUE;
+ while(prectO < prectLineStart)
+ {
+ if((prectO->x1 != prectN->x1) || (prectO->x2 != prectN->x2))
+ {
+ fSame = FALSE;
+ break;
+ }
+ prectO++;
+ prectN++;
+ }
+ if (fSame)
+ {
+ prectO = FirstRect + irectPrevStart;
+ while(prectO < prectLineStart)
+ {
+ prectO->y2 += 1;
+ prectO++;
+ }
+ rects -= crects;
+ pReg->data->numRects -= crects;
+ }
+ }
+ }
+ if(!fSame)
+ irectPrevStart = irectLineStart;
+ }
+ if (!pReg->data->numRects)
+ pReg->extents.x1 = pReg->extents.x2 = 0;
+ else
+ {
+ pReg->extents.y1 = REGION_BOXPTR(pReg)->y1;
+ pReg->extents.y2 = REGION_END(pReg)->y2;
+ if (pReg->data->numRects == 1)
+ {
+ xfree(pReg->data);
+ pReg->data = (RegDataPtr)NULL;
+ }
+ }
+#ifdef DEBUG
+ if (!miValidRegion(pReg))
+ FatalError("Assertion failed file %s, line %d: expr\n", __FILE__, __LINE__);
+#endif
+ return(pReg);
+}
+
+#ifdef FB_DEBUG
+
+#ifndef WIN32
+#include <stdio.h>
+#else
+#include <dbg.h>
+#endif
+
+static Bool
+fbValidateBits (FbStip *bits, int stride, FbStip data)
+{
+ while (stride--)
+ {
+ if (*bits != data)
+ {
+#ifdef WIN32
+ NCD_DEBUG ((DEBUG_FAILURE, "fdValidateBits failed at 0x%x (is 0x%x want 0x%x)",
+ bits, *bits, data));
+#else
+ fprintf (stderr, "fbValidateBits failed\n");
+#endif
+ return FALSE;
+ }
+ bits++;
+ }
+}
+
+void
+fbValidateDrawable (DrawablePtr pDrawable)
+{
+ FbStip *bits, *first, *last;
+ int stride, bpp;
+ int xoff, yoff;
+ int height;
+ Bool failed;
+
+ if (pDrawable->type != DRAWABLE_PIXMAP)
+ pDrawable = (DrawablePtr) fbGetWindowPixmap(pDrawable);
+ fbGetStipDrawable(pDrawable, bits, stride, bpp, xoff, yoff);
+ first = bits - stride;
+ last = bits + stride * pDrawable->height;
+ if (!fbValidateBits (first, stride, FB_HEAD_BITS) ||
+ !fbValidateBits (last, stride, FB_TAIL_BITS))
+ fbInitializeDrawable(pDrawable);
+}
+
+void
+fbSetBits (FbStip *bits, int stride, FbStip data)
+{
+ while (stride--)
+ *bits++ = data;
+}
+
+void
+fbInitializeDrawable (DrawablePtr pDrawable)
+{
+ FbStip *bits, *first, *last;
+ int stride, bpp;
+ int xoff, yoff;
+
+ fbGetStipDrawable(pDrawable, bits, stride, bpp, xoff, yoff);
+ first = bits - stride;
+ last = bits + stride * pDrawable->height;
+ fbSetBits (first, stride, FB_HEAD_BITS);
+ fbSetBits (last, stride, FB_TAIL_BITS);
+}
+#endif /* FB_DEBUG */
diff --git a/nx-X11/programs/Xserver/fb/fbpoint.c b/nx-X11/programs/Xserver/fb/fbpoint.c
new file mode 100644
index 000000000..5229d6970
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbpoint.c
@@ -0,0 +1,164 @@
+/*
+ * Id: fbpoint.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbpoint.c,v 1.7 2000/09/22 05:58:01 keithp Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+typedef void (*FbDots) (FbBits *dst,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits and,
+ FbBits xor);
+
+void
+fbDots (FbBits *dstOrig,
+ FbStride dstStride,
+ int dstBpp,
+ BoxPtr pBox,
+ xPoint *pts,
+ int npt,
+ int xorg,
+ int yorg,
+ int xoff,
+ int yoff,
+ FbBits andOrig,
+ FbBits xorOrig)
+{
+ FbStip *dst = (FbStip *) dstOrig;
+ int x1, y1, x2, y2;
+ int x, y;
+ FbStip *d;
+ FbStip and = andOrig;
+ FbStip xor = xorOrig;
+
+ dstStride = FbBitsStrideToStipStride (dstStride);
+ x1 = pBox->x1;
+ y1 = pBox->y1;
+ x2 = pBox->x2;
+ y2 = pBox->y2;
+ while (npt--)
+ {
+ x = pts->x + xorg;
+ y = pts->y + yorg;
+ pts++;
+ if (x1 <= x && x < x2 && y1 <= y && y < y2)
+ {
+ x = (x + xoff) * dstBpp;
+ d = dst + ((y + yoff) * dstStride) + (x >> FB_STIP_SHIFT);
+ x &= FB_STIP_MASK;
+#ifdef FB_24BIT
+ if (dstBpp == 24)
+ {
+ FbStip leftMask, rightMask;
+ int n, rot;
+ FbStip andT, xorT;
+
+ rot = FbFirst24Rot (x);
+ andT = FbRot24Stip(and,rot);
+ xorT = FbRot24Stip(xor,rot);
+ FbMaskStip (x, 24, leftMask, n, rightMask);
+ if (leftMask)
+ {
+ *d = FbDoMaskRRop (*d, andT, xorT, leftMask);
+ andT = FbNext24Stip(andT);
+ xorT = FbNext24Stip(xorT);
+ d++;
+ }
+ if (rightMask)
+ *d = FbDoMaskRRop(*d, andT, xorT, rightMask);
+ }
+ else
+#endif
+ {
+ FbStip mask;
+ mask = FbStipMask(x, dstBpp);
+ *d = FbDoMaskRRop (*d, and, xor, mask);
+ }
+ }
+ }
+}
+
+void
+fbPolyPoint (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int nptInit,
+ xPoint *pptInit)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbDots dots;
+ FbBits and, xor;
+ xPoint *ppt;
+ int npt;
+ BoxPtr pBox;
+ int nBox;
+
+ /* make pointlist origin relative */
+ ppt = pptInit;
+ npt = nptInit;
+ if (mode == CoordModePrevious)
+ {
+ npt--;
+ while(npt--)
+ {
+ ppt++;
+ ppt->x += (ppt-1)->x;
+ ppt->y += (ppt-1)->y;
+ }
+ }
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ and = pPriv->and;
+ xor = pPriv->xor;
+ dots = fbDots;
+#ifndef FBNOPIXADDR
+ switch (dstBpp) {
+ case 8: dots = fbDots8; break;
+ case 16: dots = fbDots16; break;
+#ifdef FB_24BIT
+ case 24: dots = fbDots24; break;
+#endif
+ case 32: dots = fbDots32; break;
+ }
+#endif
+ for (nBox = REGION_NUM_RECTS (pClip), pBox = REGION_RECTS (pClip);
+ nBox--; pBox++)
+ (*dots) (dst, dstStride, dstBpp, pBox, pptInit, nptInit,
+ pDrawable->x, pDrawable->y, dstXoff, dstYoff, and, xor);
+}
diff --git a/nx-X11/programs/Xserver/fb/fbpseudocolor.c b/nx-X11/programs/Xserver/fb/fbpseudocolor.c
new file mode 100644
index 000000000..ef40b7073
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbpseudocolor.c
@@ -0,0 +1,2335 @@
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "colormapst.h"
+#include "glyphstr.h"
+#include "resource.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "micmap.h"
+#include "fb.h"
+#include "fbpseudocolor.h"
+
+static Bool xxCreateGC(GCPtr pGC);
+static void xxValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw);
+static void xxDestroyGC(GCPtr pGC);
+static void xxChangeGC (GCPtr pGC, unsigned long mask);
+static void xxCopyGC (GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
+static void xxChangeClip (GCPtr pGC, int type, pointer pvalue, int nrects);
+
+static void xxCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
+static void xxDestroyClip(GCPtr pGC);
+static void xxFillSpans(DrawablePtr pDraw, GC *pGC, int nInit,
+ DDXPointPtr pptInit, int *pwidthInit, int fSorted);
+static void xxSetSpans(DrawablePtr pDraw, GCPtr pGC, char *pcharsrc,
+ DDXPointPtr pptInit, int *pwidthInit, int nspans,
+ int fSorted);
+static void xxPutImage(DrawablePtr pDraw, GCPtr pGC, int depth, int x, int y,
+ int w, int h,int leftPad, int format, char *pImage);
+static RegionPtr xxCopyPlane(DrawablePtr pSrc,
+ DrawablePtr pDst, GCPtr pGC,int srcx, int srcy,
+ int width, int height, int dstx, int dsty,
+ unsigned long bitPlane);
+static void xxPolyPoint(DrawablePtr pDraw, GCPtr pGC, int mode, int npt,
+ xPoint *pptInit);
+static void xxPolylines(DrawablePtr pDraw, GCPtr pGC, int mode,
+ int npt, DDXPointPtr pptInit);
+static void xxPolySegment(DrawablePtr pDraw, GCPtr pGC, int nseg,
+ xSegment *pSeg);
+static void xxPolyRectangle(DrawablePtr pDraw, GCPtr pGC, int nRects,
+ xRectangle *pRects);
+static void xxPolyArc( DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs);
+static void xxFillPolygon(DrawablePtr pDraw, GCPtr pGC, int shape,
+ int mode, int count, DDXPointPtr pptInit);
+static void xxPolyFillRect(DrawablePtr pDraw, GCPtr pGC, int nRectsInit,
+ xRectangle *pRectsInit);
+static RegionPtr xxCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GC *pGC,
+ int srcx, int srcy, int width, int height,
+ int dstx, int dsty);
+static void xxPolyFillArc(DrawablePtr pDraw, GCPtr pGC, int narcs,
+ xArc *parcs);
+static int xxPolyText8(DrawablePtr pDraw, GCPtr pGC, int x, int y, int count,
+ char *chars);
+static int xxPolyText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, unsigned short *chars);
+static void xxImageText8(DrawablePtr pDraw, GCPtr pGC, int x,
+ int y, int count, char *chars);
+static void xxImageText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ int count, unsigned short *chars);
+static void xxImageGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci,
+ pointer pglyphBase);
+static void xxPolyGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci,
+ pointer pglyphBase);
+static void xxPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDraw,
+ int dx, int dy, int xOrg, int yOrg);
+static void
+xxComposite (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
+ INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
+ INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
+static void
+xxGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist,
+ GlyphListPtr list, GlyphPtr *glyphs);
+
+
+typedef struct _xxCmapPrivRec {
+ CARD32* cmap;
+ ColormapPtr pmap;
+ Bool dirty;
+ struct _xxCmapPrivRec *next;
+} xxCmapPrivRec, *xxCmapPrivPtr;
+
+
+typedef struct {
+ CloseScreenProcPtr CloseScreen;
+ CreateScreenResourcesProcPtr CreateScreenResources;
+ CreateWindowProcPtr CreateWindow;
+ CopyWindowProcPtr CopyWindow;
+ PaintWindowProcPtr PaintWindowBackground;
+ PaintWindowProcPtr PaintWindowBorder;
+ WindowExposuresProcPtr WindowExposures;
+ CreateGCProcPtr CreateGC;
+ CreateColormapProcPtr CreateColormap;
+ DestroyColormapProcPtr DestroyColormap;
+ InstallColormapProcPtr InstallColormap;
+ UninstallColormapProcPtr UninstallColormap;
+ ListInstalledColormapsProcPtr ListInstalledColormaps;
+ StoreColorsProcPtr StoreColors;
+#ifdef RENDER
+ CompositeProcPtr Composite;
+ GlyphsProcPtr Glyphs;
+#endif
+ PixmapPtr pPixmap;
+ char * addr;
+ pointer pBits;
+ RegionRec region;
+ VisualPtr bVisual;
+ RegionRec bRegion;
+ int myDepth;
+ int depth;
+ ColormapPtr baseCmap;
+ ColormapPtr* InstalledCmaps;
+ xxCmapPrivPtr Cmaps;
+ int numInstalledColormaps;
+ int colormapDirty;
+ xxSyncFunc sync;
+} xxScrPrivRec, *xxScrPrivPtr;
+
+#define xxGetScrPriv(s) ((xxScrPrivPtr) \
+ (xxScrPrivateIndex != -1) \
+ ? (s)->devPrivates[xxScrPrivateIndex].ptr\
+ : NULL)
+#define xxScrPriv(s) xxScrPrivPtr pScrPriv = xxGetScrPriv(s)
+
+#define xxGetCmapPriv(s) ((xxCmapPrivPtr) \
+ (s)->devPrivates[xxColormapPrivateIndex].ptr)
+#define xxCmapPriv(s) xxCmapPrivPtr pCmapPriv = xxGetCmapPriv(s);
+
+typedef struct _xxGCPriv {
+ GCOps *ops;
+ GCFuncs *funcs;
+} xxGCPrivRec, *xxGCPrivPtr;
+
+#define xxGetGCPriv(pGC) ((xxGCPrivPtr) \
+ (pGC)->devPrivates[xxGCPrivateIndex].ptr)
+#define xxGCPriv(pGC) xxGCPrivPtr pGCPriv = xxGetGCPriv(pGC)
+
+int xxScrPrivateIndex = -1;
+int xxGCPrivateIndex;
+int xxColormapPrivateIndex = -1;
+int xxGeneration;
+
+
+#define wrap(priv,real,mem,func) {\
+ priv->mem = real->mem; \
+ real->mem = func; \
+}
+
+#define unwrap(priv,real,mem) {\
+ real->mem = priv->mem; \
+}
+
+#define MARK_DIRTY (1 << 31)
+
+#define MAX_NUM_XX_INSTALLED_CMAPS 255
+/* #define DEBUG */
+#ifdef DEBUG
+# define DBG ErrorF
+# define DBG_ARGS(x) ErrorF x
+# define PRINT_RECTS(rec) {\
+ int i;\
+ BoxPtr box;\
+ ErrorF("RECTS: %i\n",REGION_NUM_RECTS(&rec));\
+ if (REGION_NUM_RECTS(&rec) > 1) { \
+ for (i = 0; i < REGION_NUM_RECTS(&rec); i++ ) {\
+ box = REGION_BOX(&rec,i);\
+ ErrorF("x1: %hi x2: %hi y1: %hi y2: %hi\n", \
+ box->x1,box->x2,box->y1,box->y2);\
+ }\
+ } else { \
+ box = &(rec.extents); \
+ ErrorF("x1: %hi x2: %hi y1: %hi y2: %hi\n", \
+ box->x1,box->x2,box->y1,box->y2);\
+ } \
+}
+#else
+# define DBG(x)
+# define DBG_ARGS(x)
+# define PRINT_RECTS(rec)
+#endif
+
+#if 0
+static void xxCopyPseudocolorRegion(ScreenPtr pScreen, RegionPtr pReg,
+ xxCmapPrivPtr pCmapPriv);
+static void xxUpdateFb(ScreenPtr pScreen);
+
+
+static void
+xxUpdateWindowImmediately(WindowPtr pWin)
+{
+ xxScrPriv(pWin->drawable.pScreen);
+ xxCmapPrivPtr pCmapPriv;
+ ColormapPtr pmap;
+
+ pmap = (ColormapPtr)LookupIDByType(wColormap(pWin),RT_COLORMAP);
+
+ if (pmap && (pCmapPriv = xxGetCmapPriv(pmap)) != (pointer)-1) {
+ xxCopyPseudocolorRegion(pWin->drawable.pScreen,
+ &pScrPriv->region, pCmapPriv);
+ }
+}
+#else
+# define xxUpdateWindowImmediately(x)
+#endif
+
+static ColormapPtr
+xxGetBaseColormap(ScreenPtr pScreen)
+{
+ xxScrPriv(pScreen);
+ DepthPtr pDepth = pScreen->allowedDepths;
+ int i,j,k;
+ ColormapPtr pDefMap
+ = (ColormapPtr) LookupIDByType(pScreen->defColormap,RT_COLORMAP);
+ ColormapPtr cmap = NULL;
+ VisualPtr pVisual = NULL;
+
+ for (i = 0; i < pScreen->numDepths; i++, pDepth++)
+ if (pDepth->depth == pScrPriv->depth) {
+ for (j = 0; j < pDepth->numVids; j++) {
+ if (pDefMap->pVisual->vid == pDepth->vids[j]
+ && pDefMap->pVisual->class == TrueColor) {
+ cmap = pDefMap;
+ break;
+ }
+ if (!pVisual) {
+ for (k = 0; k < pScreen->numVisuals; k++) {
+ if (pScreen->visuals[k].class == TrueColor
+ && pScreen->visuals[k].vid
+ == pDepth->vids[j]) {
+ pVisual = &pScreen->visuals[k];
+ break;
+ }
+ }
+ }
+ }
+ if (cmap)
+ break;
+ }
+
+ if (!cmap) {
+ CreateColormap(FakeClientID(0),pScreen,pVisual,&cmap,AllocNone,0);
+ }
+
+ return cmap;
+}
+
+static Bool
+xxCreateScreenResources(ScreenPtr pScreen)
+{
+ PixmapPtr pPix;
+ xxScrPriv(pScreen);
+ Bool ret;
+ PixmapPtr pPixmap;
+ BoxRec box;
+ int depth = pScrPriv->myDepth;
+ pointer pBits;
+
+ unwrap (pScrPriv,pScreen, CreateScreenResources);
+ ret = pScreen->CreateScreenResources(pScreen);
+ wrap(pScrPriv,pScreen,CreateScreenResources,xxCreateScreenResources);
+
+ if (!ret) return FALSE;
+
+ pScrPriv->pBits = NULL;
+ if (pScrPriv->addr)
+ pBits = pScrPriv->addr;
+ else
+ pBits = xalloc(pScreen->width * pScreen->height
+ * (BitsPerPixel(depth) >> 3));
+ if (!pBits) return FALSE;
+
+ pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth);
+ if (!pPixmap) {
+ xfree(pBits);
+ return FALSE;
+ }
+ if (!(*pScreen->ModifyPixmapHeader)(pPixmap, pScreen->width,
+ pScreen->height, depth,
+ BitsPerPixel(depth),
+ PixmapBytePad(pScreen->width, depth),
+ pBits)) {
+ xfree(pBits);
+ return FALSE;
+ }
+ if (pScreen->rootDepth == pScrPriv->myDepth) {
+ pPix = (PixmapPtr)pScreen->devPrivate;
+ if (!(*pScreen->ModifyPixmapHeader)(pPix, 0,0, pScrPriv->depth,
+ BitsPerPixel(pScrPriv->depth),
+ PixmapBytePad(pScreen->width,
+ pScrPriv->depth),
+ 0)) {
+ xfree(pBits);
+ return FALSE;
+ }
+ }
+
+ pScrPriv->baseCmap = xxGetBaseColormap(pScreen);
+
+ pScrPriv->pBits = pBits;
+ pScrPriv->pPixmap = pPixmap;
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pScreen->width;
+ box.y2 = pScreen->height;
+ REGION_NULL(pScreen, &pScrPriv->region);
+ REGION_INIT(pScreen, &pScrPriv->bRegion, &box, 0);
+
+ return TRUE;
+}
+
+static Bool
+xxCloseScreen (int iScreen, ScreenPtr pScreen)
+{
+ xxScrPriv(pScreen);
+ Bool ret;
+
+ (*pScreen->DestroyPixmap)(pScrPriv->pPixmap);
+ /* We don't need to free the baseColormap as FreeClientResourcess
+ will have taken care of it. */
+ REGION_UNINIT (pScreen, &pScrPriv->region);
+
+ unwrap (pScrPriv,pScreen, CloseScreen);
+ ret = pScreen->CloseScreen(iScreen,pScreen);
+
+ xfree(pScrPriv->pBits);
+ xfree(pScrPriv->InstalledCmaps);
+ xfree(pScrPriv);
+
+ return TRUE;
+}
+
+static Bool
+xxMyVisual(ScreenPtr pScreen, VisualID vid)
+{
+ xxScrPriv(pScreen);
+ DepthPtr pDepth = pScreen->allowedDepths;
+ int i,j;
+
+ for (i = 0; i < pScreen->numDepths; i++, pDepth++)
+ if (pDepth->depth == pScrPriv->myDepth) {
+ for (j = 0; j < pDepth->numVids; j++) {
+ if (vid == pDepth->vids[j]) {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+static Bool
+xxInitColormapDummy(ColormapPtr pmap, int index)
+{
+ return TRUE;
+}
+
+static Bool
+xxInitColormapPrivate(ColormapPtr pmap)
+{
+ xxScrPriv(pmap->pScreen);
+ xxCmapPrivPtr pCmapPriv;
+ pointer cmap;
+
+ pmap->devPrivates[xxColormapPrivateIndex].ptr = (pointer) -1;
+
+ if (xxMyVisual(pmap->pScreen,pmap->pVisual->vid)) {
+ DBG("CreateColormap\n");
+ pCmapPriv = (xxCmapPrivPtr) xalloc (sizeof (xxCmapPrivRec));
+ if (!pCmapPriv)
+ return FALSE;
+ pmap->devPrivates[xxColormapPrivateIndex].ptr = (pointer) pCmapPriv;
+ cmap = xalloc(sizeof (CARD32) * (1 << pScrPriv->myDepth));
+ if (!cmap)
+ return FALSE;
+
+ memset(cmap,0,sizeof (CARD32) * (1 << pScrPriv->myDepth));
+
+ pCmapPriv->cmap = cmap;
+ pCmapPriv->dirty = FALSE;
+ pCmapPriv->pmap = pmap;
+ pCmapPriv->next = pScrPriv->Cmaps;
+ pScrPriv->Cmaps = pCmapPriv;
+ }
+ return TRUE;
+}
+
+
+static Bool
+xxCreateColormap(ColormapPtr pmap)
+{
+ xxScrPriv(pmap->pScreen);
+ Bool ret;
+
+ if (!xxInitColormapPrivate(pmap)) return FALSE;
+
+ unwrap(pScrPriv,pmap->pScreen, CreateColormap);
+ ret = pmap->pScreen->CreateColormap(pmap);
+ wrap(pScrPriv,pmap->pScreen,CreateColormap,xxCreateColormap);
+
+ return ret;
+}
+
+static int
+xxCmapInstalled(ColormapPtr pmap)
+{
+ xxScrPriv(pmap->pScreen);
+ int i;
+
+ for (i = 0; i < pScrPriv->numInstalledColormaps; i++)
+ if (pScrPriv->InstalledCmaps[i] == pmap)
+ break;
+ if (i == pScrPriv->numInstalledColormaps) /* not installed */
+ return -1;
+ return i;
+}
+
+static void
+xxInstalledCmapDelete(ScreenPtr pScreen, int num)
+{
+ xxScrPriv(pScreen);
+ int i;
+
+ pScrPriv->numInstalledColormaps--;
+
+ for (i = num; i < pScrPriv->numInstalledColormaps; i++)
+ pScrPriv->InstalledCmaps[i] = pScrPriv->InstalledCmaps[i+1];
+}
+
+static void
+xxDestroyColormap(ColormapPtr pmap)
+{
+ xxScrPriv(pmap->pScreen);
+ xxCmapPriv(pmap);
+
+ if (pCmapPriv != (pointer) -1) {
+ xxCmapPrivPtr tmpCmapPriv = pScrPriv->Cmaps;
+ xxCmapPrivPtr *prevCmapPriv = &pScrPriv->Cmaps;
+ int n;
+
+ DBG("DestroyColormap\n");
+
+ if ((n = xxCmapInstalled(pmap)) != -1)
+ xxInstalledCmapDelete(pmap->pScreen,n);
+
+ while (tmpCmapPriv) {
+ if (tmpCmapPriv->pmap == pmap) {
+ *prevCmapPriv = tmpCmapPriv->next;
+ break;
+ }
+ prevCmapPriv = &tmpCmapPriv->next;
+ tmpCmapPriv = tmpCmapPriv->next;
+ }
+
+ xfree(pCmapPriv->cmap);
+ xfree(pCmapPriv);
+ }
+
+ unwrap(pScrPriv,pmap->pScreen, DestroyColormap);
+ pmap->pScreen->DestroyColormap(pmap);
+ wrap(pScrPriv,pmap->pScreen,DestroyColormap,xxDestroyColormap);
+}
+
+#define Shift(v,d) ((d) < 0 ? ((v) >> (-d)) : ((v) << (d)))
+
+static int
+xxComputeCmapShift (unsigned long mask)
+{
+ int shift;
+ unsigned long bit;
+
+ shift = 16;
+ bit = 0x80000000;
+ while (!(mask & bit))
+ {
+ shift--;
+ bit >>= 1;
+ }
+ return shift;
+}
+
+static void
+xxStoreColors(ColormapPtr pmap, int nColors, xColorItem *pColors)
+{
+ xxScrPriv(pmap->pScreen);
+ xxCmapPriv(pmap);
+
+ if (pCmapPriv != (pointer) -1) {
+
+ xColorItem *expanddefs;
+ int i;
+ VisualPtr bVisual;
+ int rs, gs, bs;
+
+ if (nColors == 0) return;
+
+ DBG("StoreColors\n");
+
+ expanddefs = ALLOCATE_LOCAL(sizeof(xColorItem)
+ * (1 << pScrPriv->myDepth));
+ if (!expanddefs) return;
+
+ bVisual = pScrPriv->bVisual;
+
+ DBG("StoreColors\n");
+
+ rs = xxComputeCmapShift(bVisual->redMask);
+ gs = xxComputeCmapShift(bVisual->greenMask);
+ bs = xxComputeCmapShift(bVisual->blueMask);
+
+ if ((pmap->pVisual->class | DynamicClass) == DirectColor) {
+ nColors = miExpandDirectColors(pmap, nColors, pColors, expanddefs);
+ pColors = expanddefs;
+ }
+
+ for (i = 0; i < nColors; i++) {
+ DBG_ARGS(("index: %i r 0x%x g 0x%x b 0x%x\n", pColors->pixel,
+ pColors->red, pColors->green, pColors->blue));
+ pCmapPriv->cmap[pColors->pixel] = MARK_DIRTY
+ | (Shift(pColors->red, rs) & bVisual->redMask)
+ | (Shift(pColors->green, gs) & bVisual->greenMask)
+ | (Shift(pColors->blue, bs) & bVisual->blueMask);
+ pColors++;
+ }
+
+ DEALLOCATE_LOCAL(expanddefs);
+
+ pCmapPriv->dirty = TRUE;
+ pScrPriv->colormapDirty = TRUE;
+
+ return;
+ }
+
+ unwrap(pScrPriv,pmap->pScreen, StoreColors);
+ pmap->pScreen->StoreColors(pmap,nColors,pColors);
+ wrap(pScrPriv,pmap->pScreen,StoreColors,xxStoreColors);
+}
+
+static void
+xxInstallColormap(ColormapPtr pmap)
+{
+ int i;
+ xxScrPriv(pmap->pScreen);
+ xxCmapPriv(pmap);
+
+ if (pCmapPriv != (pointer) -1) {
+ Pixel *pixels;
+ xrgb *colors;
+ int i;
+ VisualPtr pVisual;
+ xColorItem *defs;
+
+ DBG("InstallColormap\n");
+
+ if (xxCmapInstalled(pmap) != -1)
+ return;
+
+ if (!pScrPriv->numInstalledColormaps) {
+ unwrap(pScrPriv,pmap->pScreen, InstallColormap);
+ pmap->pScreen->InstallColormap(pScrPriv->baseCmap);
+ wrap(pScrPriv,pmap->pScreen,InstallColormap,xxInstallColormap);
+ }
+
+ pixels = ALLOCATE_LOCAL(sizeof(Pixel) * (1 << pScrPriv->myDepth));
+ colors = ALLOCATE_LOCAL(sizeof(xrgb) * (1 << pScrPriv->myDepth));
+ defs = ALLOCATE_LOCAL(sizeof(xColorItem) * (1 << pScrPriv->myDepth));
+
+ if (!pixels || !colors)
+ return;
+
+ /* if we have more than max installed delete the oldest */
+ if (pScrPriv->numInstalledColormaps == MAX_NUM_XX_INSTALLED_CMAPS)
+ xxInstalledCmapDelete(pmap->pScreen,0);
+
+ pScrPriv->InstalledCmaps[pScrPriv->numInstalledColormaps] = pmap;
+ pScrPriv->numInstalledColormaps++;
+
+ pVisual = pScrPriv->bVisual;
+
+ for (i = 0; i < (1 << pScrPriv->myDepth); i++)
+ pixels[i] = i;
+
+ QueryColors (pmap, (1 << pScrPriv->myDepth), pixels, colors);
+
+ for (i = 0; i < (1 << pScrPriv->myDepth); i++) {
+ defs[i].pixel = pixels[i];
+ defs[i].red = colors[i].red;
+ defs[i].green = colors[i].green;
+ defs[i].blue = colors[i].blue;
+ defs[i].flags = DoRed|DoGreen|DoBlue;
+ }
+ xxStoreColors(pmap,(1 << pScrPriv->myDepth),defs);
+
+ DEALLOCATE_LOCAL(pixels);
+ DEALLOCATE_LOCAL(colors);
+ DEALLOCATE_LOCAL(defs);
+
+ return;
+ }
+
+ for (i = pScrPriv->numInstalledColormaps; i ; i--)
+ WalkTree(pmap->pScreen, TellLostMap,
+ (char *)&pScrPriv->InstalledCmaps[i-1]->mid);
+
+ pScrPriv->numInstalledColormaps = 0;
+
+ unwrap(pScrPriv,pmap->pScreen, InstallColormap);
+ pmap->pScreen->InstallColormap(pmap);
+ wrap(pScrPriv,pmap->pScreen,InstallColormap,xxInstallColormap);
+}
+
+static void
+xxUninstallColormap(ColormapPtr pmap)
+{
+ xxScrPriv(pmap->pScreen);
+ xxCmapPriv(pmap);
+
+ if (pCmapPriv != (pointer) -1) {
+ int num;
+
+ if ((num = xxCmapInstalled(pmap)) == -1)
+ return;
+
+ DBG("UninstallColormap\n");
+ xxInstalledCmapDelete(pmap->pScreen,num);
+
+ return;
+ }
+
+ unwrap(pScrPriv,pmap->pScreen, UninstallColormap);
+ pmap->pScreen->UninstallColormap(pmap);
+ wrap(pScrPriv,pmap->pScreen,UninstallColormap,xxUninstallColormap);
+
+}
+
+static int
+xxListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapIds)
+{
+ int n,i;
+ xxScrPriv(pScreen);
+
+ unwrap(pScrPriv,pScreen, ListInstalledColormaps);
+ n = pScreen->ListInstalledColormaps(pScreen, pCmapIds);
+ wrap (pScrPriv,pScreen,ListInstalledColormaps,xxListInstalledColormaps);
+
+ pCmapIds += n;
+
+ for (i = 0; i < pScrPriv->numInstalledColormaps; i++) {
+ *pCmapIds++ = pScrPriv->InstalledCmaps[i]->mid;
+ n++;
+ }
+
+ return n;
+}
+
+static Bool
+xxCreateWindow(WindowPtr pWin)
+{
+ xxScrPriv(pWin->drawable.pScreen);
+
+ if (pWin->drawable.class != InputOutput
+ || pScrPriv->myDepth != pWin->drawable.depth) {
+ Bool ret;
+ DBG("CreateWindow NoPseudo\n");
+ unwrap (pScrPriv, pWin->drawable.pScreen, CreateWindow);
+ ret = pWin->drawable.pScreen->CreateWindow(pWin);
+ wrap(pScrPriv, pWin->drawable.pScreen, CreateWindow, xxCreateWindow);
+
+ return ret;
+ }
+
+ DBG("CreateWindow\n");
+
+ pWin->devPrivates[fbWinPrivateIndex].ptr = (pointer) pScrPriv->pPixmap;
+ PRINT_RECTS(pScrPriv->region);
+ if (!pWin->parent) {
+ REGION_EMPTY (pWin->drawable.pScreen, &pScrPriv->region);
+ }
+ PRINT_RECTS(pScrPriv->region);
+
+ return TRUE;
+}
+
+static void
+xxWalkChildren(WindowPtr pWin, RegionPtr pReg, PixmapPtr pPixmap)
+{
+
+ WindowPtr pCurWin = pWin;
+
+ do {
+ if (fbGetWindowPixmap(pCurWin) == pPixmap) {
+ DBG("WalkWindow Add\n");
+ REGION_UNION(pWin->drawable.pScreen,pReg,pReg,
+ &pCurWin->borderClip);
+ } else {
+ DBG("WalkWindow Sub\n");
+ REGION_SUBTRACT(pWin->drawable.pScreen,pReg,pReg,
+ &pCurWin->borderClip);
+ }
+ if (pCurWin->lastChild)
+ xxWalkChildren(pCurWin->lastChild,pReg, pPixmap);
+ } while ((pCurWin = pCurWin->prevSib));
+}
+
+static void
+xxPickMyWindows(WindowPtr pWin, RegionPtr pRgn)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ xxScrPriv(pScreen);
+
+ if (fbGetWindowPixmap(pWin) == pScrPriv->pPixmap) {
+ REGION_UNION(pWin->drawable.pScreen,pRgn,pRgn,&pWin->borderClip);
+ }
+ if (pWin->lastChild)
+ xxWalkChildren(pWin->lastChild,pRgn,pScrPriv->pPixmap);
+}
+
+static void
+xxCopyWindow(WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ xxScrPriv(pScreen);
+ RegionRec rgn;
+ RegionRec rgn_new;
+ int dx, dy;
+ PixmapPtr pPixmap = fbGetWindowPixmap(pWin);
+
+ DBG("xxCopyWindow\n");
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+
+ REGION_NULL(pScreen, &rgn_new);
+ REGION_UNION(pScreen, &rgn_new,&rgn_new,prgnSrc);
+ REGION_TRANSLATE(pScreen,&rgn_new,-dx,-dy);
+
+ REGION_NULL(pScreen, &rgn);
+ xxPickMyWindows(pWin,&rgn);
+
+ unwrap (pScrPriv, pScreen, CopyWindow);
+ pWin->devPrivates[fbWinPrivateIndex].ptr = fbGetScreenPixmap(pScreen);
+ pScreen->CopyWindow(pWin, ptOldOrg, prgnSrc);
+ pWin->devPrivates[fbWinPrivateIndex].ptr = pPixmap;
+ wrap(pScrPriv, pScreen, CopyWindow, xxCopyWindow);
+
+ REGION_INTERSECT(pScreen,&rgn,&rgn,&rgn_new);
+ if (REGION_NOTEMPTY (pScreen,&rgn)) {
+ fbCopyRegion(&pScrPriv->pPixmap->drawable,&pScrPriv->pPixmap->drawable,
+ 0,&rgn,dx,dy,fbCopyWindowProc,0,(void*)0);
+ REGION_TRANSLATE(pScreen,&rgn,dx,dy);
+ REGION_INTERSECT(pScreen,&rgn_new,&pScrPriv->region,&rgn);
+ REGION_SUBTRACT(pScreen,&pScrPriv->region,&pScrPriv->region,&rgn);
+ REGION_TRANSLATE(pScreen,&rgn_new,-dx,-dy);
+ REGION_UNION(pScreen,&pScrPriv->region,&pScrPriv->region,&rgn_new);
+ }
+#if 1
+ REGION_UNINIT(pScreen,&rgn_new);
+ REGION_UNINIT(pScreen,&rgn);
+#endif
+}
+
+static void
+xxWindowExposures (WindowPtr pWin,
+ RegionPtr prgn,
+ RegionPtr other_exposed)
+{
+ xxScrPriv(pWin->drawable.pScreen);
+
+ if (fbGetWindowPixmap(pWin) == pScrPriv->pPixmap) {
+ DBG("WindowExposures\n");
+ PRINT_RECTS(pScrPriv->region);
+ REGION_UNION(pWin->drawable.pScreen,&pScrPriv->region,
+ &pScrPriv->region,
+ prgn);
+ PRINT_RECTS(pScrPriv->region);
+ } else {
+ DBG("WindowExposures NonPseudo\n");
+ PRINT_RECTS(pScrPriv->region);
+ REGION_SUBTRACT(pWin->drawable.pScreen,&pScrPriv->region,
+ &pScrPriv->region,
+ prgn);
+ PRINT_RECTS(pScrPriv->region);
+ }
+ unwrap (pScrPriv, pWin->drawable.pScreen, WindowExposures);
+ pWin->drawable.pScreen->WindowExposures(pWin, prgn, other_exposed);
+ wrap(pScrPriv, pWin->drawable.pScreen, WindowExposures, xxWindowExposures);
+}
+
+static void
+xxPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ xxScrPriv(pWin->drawable.pScreen);
+ RegionRec rgni;
+
+ DBG("xxPaintWindow\n");
+
+ REGION_NULL (pWin->drawable.pScreen, &rgni);
+#if 0
+ REGION_UNION (pWin->drawable.pScreen, &rgni, &rgni, &pWin->borderClip);
+ REGION_INTERSECT(pWin->drawable.pScreen, &rgni, &rgni, pRegion);
+#else
+ REGION_UNION (pWin->drawable.pScreen, &rgni, &rgni, pRegion);
+#endif
+ switch (what) {
+ case PW_BORDER:
+ REGION_SUBTRACT (pWin->drawable.pScreen, &rgni, &rgni, &pWin->winSize);
+ if (fbGetWindowPixmap(pWin) == pScrPriv->pPixmap) {
+ DBG("PaintWindowBorder\n");
+ REGION_UNION (pWin->drawable.pScreen, &pScrPriv->region,
+ &pScrPriv->region, &rgni);
+ } else {
+ DBG("PaintWindowBorder NoOverlay\n");
+ REGION_SUBTRACT (pWin->drawable.pScreen, &pScrPriv->region,
+ &pScrPriv->region, &rgni);
+ }
+ unwrap (pScrPriv, pWin->drawable.pScreen, PaintWindowBorder);
+ pWin->drawable.pScreen->PaintWindowBorder (pWin, pRegion, what);
+ wrap(pScrPriv, pWin->drawable.pScreen, PaintWindowBorder,
+ xxPaintWindow);
+ break;
+ case PW_BACKGROUND:
+ switch (pWin->backgroundState) {
+ case None:
+ break;
+ default:
+ REGION_INTERSECT (pWin->drawable.pScreen, &rgni,
+ &rgni,&pWin->winSize);
+ if (fbGetWindowPixmap(pWin) == pScrPriv->pPixmap) {
+ DBG("PaintWindowBackground\n");
+ REGION_UNION (pWin->drawable.pScreen, &pScrPriv->region,
+ &pScrPriv->region, &rgni);
+ } else {
+ DBG("PaintWindowBackground NoOverlay\n");
+ REGION_SUBTRACT (pWin->drawable.pScreen, &pScrPriv->region,
+ &pScrPriv->region, &rgni);
+ }
+ break;
+ }
+
+ unwrap (pScrPriv, pWin->drawable.pScreen, PaintWindowBackground);
+ pWin->drawable.pScreen->PaintWindowBackground (pWin, pRegion, what);
+ wrap(pScrPriv, pWin->drawable.pScreen, PaintWindowBackground,
+ xxPaintWindow);
+ break;
+ }
+ PRINT_RECTS(rgni);
+ PRINT_RECTS(pScrPriv->region);
+#if 1
+ REGION_UNINIT(pWin->drawable.pScreen,&rgni);
+#endif
+}
+
+static void
+xxCopyPseudocolorRegion(ScreenPtr pScreen, RegionPtr pReg,
+ xxCmapPrivPtr pCmapPriv)
+{
+ xxScrPriv(pScreen);
+ CARD32 mask = (1 << pScrPriv->myDepth) - 1;
+ int num = REGION_NUM_RECTS(pReg);
+ BoxPtr pbox = REGION_RECTS(pReg);
+ int width, height;
+ CARD8 *src;
+ CARD16 *dst, *dst_base;
+ int dst_stride;
+ register CARD32 *cmap = pCmapPriv->cmap;
+ register CARD8 *s;
+ register CARD16 *d;
+ int w;
+
+ dst_base = (CARD16*) ((PixmapPtr)pScreen->devPrivate)->devPrivate.ptr;
+ dst_stride = (int)((PixmapPtr)pScreen->devPrivate)->devKind
+ / sizeof (CARD16);
+
+ while (num--) {
+ height = pbox->y2 - pbox->y1;
+ width = pbox->x2 - pbox->x1;
+
+ src = (unsigned char *) pScrPriv->pBits
+ + (pbox->y1 * pScreen->width) + pbox->x1;
+ dst = dst_base + (pbox->y1 * dst_stride) + pbox->x1;
+ while (height--) {
+ w = width;
+ s = src;
+ d = dst;
+
+ while(w--) {
+ *(d++) = (CARD16)*(cmap + ((*(s++)) & mask));
+ }
+ src += pScreen->width;
+ dst += dst_stride;
+ }
+ pbox++;
+ }
+}
+
+static void
+xxUpdateCmapPseudocolorRegion(ScreenPtr pScreen, RegionPtr pReg,
+ xxCmapPrivPtr pCmapPriv)
+{
+ xxScrPriv(pScreen);
+ CARD32 mask = (1 << pScrPriv->myDepth) - 1;
+ int num = REGION_NUM_RECTS(pReg);
+ BoxPtr pbox = REGION_RECTS(pReg);
+ int width, height;
+ CARD8 *src;
+ CARD16 *dst, *dst_base;
+ int dst_stride;
+ register CARD32 val;
+ register CARD32 *cmap = pCmapPriv->cmap;
+ register CARD8 *s;
+ register CARD16 *d;
+ int w;
+
+ dst_base = (CARD16*) ((PixmapPtr)pScreen->devPrivate)->devPrivate.ptr;
+ dst_stride = (int)((PixmapPtr)pScreen->devPrivate)->devKind
+ / sizeof (CARD16);
+
+ while (num--) {
+
+ height = pbox->y2 - pbox->y1;
+ width = pbox->x2 - pbox->x1;
+
+ src = (unsigned char *) pScrPriv->pBits
+ + (pbox->y1 * pScreen->width) + pbox->x1;
+ dst = dst_base + (pbox->y1 * dst_stride) + pbox->x1;
+ while (height--) {
+ w = width;
+ s = src;
+ d = dst;
+ while(w--) {
+ val = *(cmap + ((*(s++)) & mask));
+ if (val & MARK_DIRTY) {
+ *d = (CARD16) val;
+ }
+ d++;
+ }
+ src += pScreen->width;
+ dst += dst_stride;
+ }
+ pbox++;
+ }
+}
+
+static void
+xxGetWindowRegion(WindowPtr pWin,RegionPtr winreg)
+{
+ REGION_NULL(pWin->drawable.pScreen,winreg);
+ /* get visible part of the border ...Argh */
+ REGION_SUBTRACT(pWin->drawable.pScreen,winreg,&pWin->borderSize,
+ &pWin->winSize);
+ REGION_INTERSECT(pWin->drawable.pScreen,winreg,winreg,
+ &pWin->borderClip);
+ /* add window interior excluding children */
+ REGION_UNION(pWin->drawable.pScreen,winreg,winreg,
+ &pWin->clipList);
+}
+
+static int
+xxUpdateRegion(WindowPtr pWin, pointer unused)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ xxScrPriv(pScreen);
+ ColormapPtr pmap = (pointer) -1;
+ RegionRec winreg, rgni;
+
+ if (pScrPriv->myDepth == pWin->drawable.depth) {
+ xxCmapPrivPtr pCmapPriv = (pointer)-1;
+ xxGetWindowRegion(pWin,&winreg);
+
+ if (pScrPriv->colormapDirty) {
+
+ pmap = (ColormapPtr)LookupIDByType(wColormap(pWin),RT_COLORMAP);
+ if (!pmap)
+ goto CONTINUE; /* return ? */
+
+ pCmapPriv = xxGetCmapPriv(pmap);
+ if (pCmapPriv == (pointer) -1)
+ return WT_WALKCHILDREN;
+ if (!pCmapPriv->dirty)
+ goto CONTINUE;
+
+ REGION_NULL (pScreen, &rgni);
+ /* This will be taken care of when damaged regions are updated */
+ REGION_SUBTRACT(pScreen, &rgni, &winreg, &pScrPriv->region);
+ if (REGION_NOTEMPTY (pScreen,&rgni))
+ xxUpdateCmapPseudocolorRegion(pScreen,&rgni, pCmapPriv);
+ }
+ CONTINUE:
+
+ REGION_NULL (pScreen, &rgni);
+ REGION_INTERSECT (pScreen, &rgni, &winreg, &pScrPriv->region);
+
+ if (REGION_NOTEMPTY (pScreen,&rgni)) {
+ if (pmap == (pointer) -1) {
+ pmap =
+ (ColormapPtr)LookupIDByType(wColormap(pWin),RT_COLORMAP);
+ if (!pmap) /* return ? */
+ pmap = (ColormapPtr)LookupIDByType(pScreen->defColormap,
+ RT_COLORMAP);
+ pCmapPriv = xxGetCmapPriv(pmap);
+ }
+
+ if (pCmapPriv != (pointer)-1)
+ xxCopyPseudocolorRegion(pScreen,&rgni, pCmapPriv);
+ REGION_SUBTRACT(pScreen, &pScrPriv->region, &pScrPriv->region,
+ &rgni);
+ }
+#if 1
+ REGION_UNINIT(pScreen,&rgni);
+ REGION_UNINIT(pScreen,&winreg);
+#endif
+ }
+ return WT_WALKCHILDREN;
+}
+
+
+static void
+xxUpdateFb(ScreenPtr pScreen)
+{
+ xxScrPriv(pScreen);
+
+ DBG("Update FB\n");
+ PRINT_RECTS(pScrPriv->region);
+
+ if (pScrPriv->sync)
+ pScrPriv->sync(pScreen); /*@!@*/
+
+ WalkTree(pScreen,xxUpdateRegion,NULL);
+#if 0
+ if (REGION_NOTEMPTY (pScreen,&pScrPriv->region)) {
+ ColormapPtr pmap = (pointer) -1;
+ xxCmapPrivPtr pCmapPriv;
+
+ pmap = (ColormapPtr)LookupIDByType(pScreen->defColormap,
+ RT_COLORMAP);
+ pCmapPriv = xxGetCmapPriv(pmap);
+ if (pCmapPriv != (pointer)-1)
+ xxCopyPseudocolorRegion(pScreen,&pScrPriv->region, pCmapPriv);
+ REGION_SUBTRACT(pScreen, &pScrPriv->region, &pScrPriv->region,
+ &pScrPriv->region);
+ }
+#endif
+ if (pScrPriv->colormapDirty) {
+ xxCmapPrivPtr pCmap = pScrPriv->Cmaps;
+
+ while (pCmap) {
+ int j;
+
+ if (pCmap->dirty) {
+ for (j = 0; j < (1 << pScrPriv->myDepth); j++)
+ pCmap->cmap[j] &= ~MARK_DIRTY;
+ pCmap->dirty = FALSE;
+ }
+ pCmap = pCmap->next;
+ }
+ pScrPriv->colormapDirty = FALSE;
+ }
+}
+
+static void
+xxBlockHandler (pointer data,
+ OSTimePtr pTimeout,
+ pointer pRead)
+{
+ ScreenPtr pScreen = (ScreenPtr) data;
+ xxScrPriv(pScreen);
+
+ if (REGION_NOTEMPTY (pScreen,&pScrPriv->region) || pScrPriv->colormapDirty)
+ xxUpdateFb (pScreen);
+}
+
+static void
+xxWakeupHandler (pointer data, int i, pointer LastSelectMask)
+{
+}
+
+Bool
+xxSetup(ScreenPtr pScreen, int myDepth, int baseDepth, char* addr, xxSyncFunc sync)
+{
+ xxScrPrivPtr pScrPriv;
+ DepthPtr pDepths;
+ ColormapPtr pDefMap;
+ int i,j,k;
+
+#ifdef RENDER
+ PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
+#endif
+
+ if (xxGeneration != serverGeneration) {
+ xxScrPrivateIndex = AllocateScreenPrivateIndex ();
+ if (xxScrPrivateIndex == -1)
+ return FALSE;
+ xxColormapPrivateIndex
+ = AllocateColormapPrivateIndex (xxInitColormapDummy);
+ if (xxColormapPrivateIndex == -1)
+ return FALSE;
+ xxGCPrivateIndex = AllocateGCPrivateIndex ();
+ if (xxGCPrivateIndex == -1)
+ return FALSE;
+ xxGeneration = serverGeneration;
+ }
+
+ if (!AllocateGCPrivate (pScreen, xxGCPrivateIndex, sizeof (xxGCPrivRec)))
+ return FALSE;
+
+ pScrPriv = (xxScrPrivPtr) xalloc (sizeof (xxScrPrivRec));
+ if (!pScrPriv)
+ return FALSE;
+
+ if (baseDepth)
+ pScrPriv->depth = baseDepth;
+ else {
+ pDepths = pScreen->allowedDepths;
+ for (i = 0; i < pScreen->numDepths; i++, pDepths++)
+ if (pDepths->depth != myDepth)
+ pScrPriv->depth = pDepths->depth;
+ }
+ if (!pScrPriv->depth)
+ return FALSE;
+
+ pDepths = pScreen->allowedDepths;
+ for (i = 0; i < pScreen->numDepths; i++, pDepths++)
+ if (pDepths->depth == pScrPriv->depth) {
+ for (j = 0; i < pDepths->numVids; j++) {
+ for (k = 0; k < pScreen->numVisuals; k++) {
+ if (pScreen->visuals[k].vid
+ == pDepths[i].vids[j]
+ && pScreen->visuals[k].class == TrueColor) {
+ pScrPriv->bVisual = &pScreen->visuals[k];
+ goto DONE;
+ }
+ }
+ }
+ }
+
+ DONE:
+ if (!pScrPriv->bVisual)
+ return FALSE;
+
+ pScrPriv->myDepth = myDepth;
+ pScrPriv->numInstalledColormaps = 0;
+ pScrPriv->colormapDirty = FALSE;
+ pScrPriv->Cmaps = NULL;
+ pScrPriv->sync = sync;
+
+ pScreen->maxInstalledCmaps += MAX_NUM_XX_INSTALLED_CMAPS;
+ pScrPriv->InstalledCmaps = xcalloc(MAX_NUM_XX_INSTALLED_CMAPS,
+ sizeof(ColormapPtr));
+ if (!pScrPriv->InstalledCmaps)
+ return FALSE;
+
+
+ if (!RegisterBlockAndWakeupHandlers (xxBlockHandler,
+ xxWakeupHandler,
+ (pointer) pScreen))
+ return FALSE;
+
+ wrap (pScrPriv, pScreen, CloseScreen, xxCloseScreen);
+ wrap (pScrPriv, pScreen, CreateScreenResources, xxCreateScreenResources);
+ wrap (pScrPriv, pScreen, CreateWindow, xxCreateWindow);
+ wrap (pScrPriv, pScreen, CopyWindow, xxCopyWindow);
+ wrap (pScrPriv, pScreen, PaintWindowBorder, xxPaintWindow);
+ wrap (pScrPriv, pScreen, PaintWindowBackground, xxPaintWindow);
+#if 0 /* can we leave this out even with backing store enabled ? */
+ wrap (pScrPriv, pScreen, WindowExposures, xxWindowExposures);
+#endif
+ wrap (pScrPriv, pScreen, CreateGC, xxCreateGC);
+ wrap (pScrPriv, pScreen, CreateColormap, xxCreateColormap);
+ wrap (pScrPriv, pScreen, DestroyColormap, xxDestroyColormap);
+ wrap (pScrPriv, pScreen, InstallColormap, xxInstallColormap);
+ wrap (pScrPriv, pScreen, UninstallColormap, xxUninstallColormap);
+ wrap (pScrPriv, pScreen, ListInstalledColormaps, xxListInstalledColormaps);
+ wrap (pScrPriv, pScreen, StoreColors, xxStoreColors);
+#ifdef RENDER
+ if (ps) {
+ wrap (pScrPriv, ps, Glyphs, xxGlyphs);
+ wrap (pScrPriv, ps, Composite, xxComposite);
+ }
+#endif
+ pScrPriv->addr = addr;
+ pScreen->devPrivates[xxScrPrivateIndex].ptr = (pointer) pScrPriv;
+
+ pDefMap = (ColormapPtr) LookupIDByType(pScreen->defColormap, RT_COLORMAP);
+ if (!xxInitColormapPrivate(pDefMap))
+ return FALSE;
+
+ return TRUE;
+}
+
+GCFuncs xxGCFuncs = {
+ xxValidateGC, xxChangeGC, xxCopyGC, xxDestroyGC,
+ xxChangeClip, xxDestroyClip, xxCopyClip
+};
+
+GCOps xxGCOps = {
+ xxFillSpans, xxSetSpans,
+ xxPutImage, xxCopyArea,
+ xxCopyPlane, xxPolyPoint,
+ xxPolylines, xxPolySegment,
+ xxPolyRectangle, xxPolyArc,
+ xxFillPolygon, xxPolyFillRect,
+ xxPolyFillArc, xxPolyText8,
+ xxPolyText16, xxImageText8,
+ xxImageText16, xxImageGlyphBlt,
+ xxPolyGlyphBlt, xxPushPixels,
+#ifdef NEED_LINEHELPER
+ NULL,
+#endif
+ {NULL} /* devPrivate */
+};
+
+#define IS_VISIBLE(pDraw) (pDraw->type == DRAWABLE_WINDOW \
+ && (fbGetWindowPixmap((WindowPtr) pDraw) == pScrPriv->pPixmap))
+
+#define TRANSLATE_BOX(box, pDraw) { \
+ box.x1 += pDraw->x; \
+ box.x2 += pDraw->x; \
+ box.y1 += pDraw->y; \
+ box.y2 += pDraw->y; \
+ }
+
+#define TRIM_BOX(box, pGC) { \
+ BoxPtr extents = &pGC->pCompositeClip->extents;\
+ if(box.x1 < extents->x1) box.x1 = extents->x1; \
+ if(box.x2 > extents->x2) box.x2 = extents->x2; \
+ if(box.y1 < extents->y1) box.y1 = extents->y1; \
+ if(box.y2 > extents->y2) box.y2 = extents->y2; \
+ }
+
+#define BOX_NOT_EMPTY(box) \
+ (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0))
+
+
+#define _ADD_BOX(box,pGC) {\
+ if (BOX_NOT_EMPTY(box)) { \
+ RegionRec region; \
+ ScreenPtr pScreen = pGC->pScreen;\
+ REGION_INIT (pScreen, &region, &box, 1); \
+ REGION_INTERSECT(pScreen,&region,&region,\
+ (pGC)->pCompositeClip);\
+ if (REGION_NOTEMPTY(pScreen,&region)) { \
+ xxScrPriv(pScreen);\
+ PRINT_RECTS(pScrPriv->region);\
+ REGION_UNION(pScreen,&pScrPriv->region,&pScrPriv->region,&region);\
+ PRINT_RECTS(pScrPriv->region);\
+ REGION_UNINIT(pScreen,&region);\
+ }\
+ }\
+}
+
+#define TRANSLATE_AND_ADD_BOX(box,pGC) {\
+ TRANSLATE_BOX(box,pDraw); \
+ TRIM_BOX(box,pGC); \
+ _ADD_BOX(box,pGC); \
+}
+
+#define ADD_BOX(box,pGC) { \
+ TRIM_BOX(box,pGC); \
+ _ADD_BOX(box,pGC); \
+}
+
+#define XX_GC_FUNC_PROLOGUE(pGC) \
+ xxGCPriv(pGC); \
+ unwrap(pGCPriv, pGC, funcs); \
+ if (pGCPriv->ops) unwrap(pGCPriv, pGC, ops)
+
+#define XX_GC_FUNC_EPILOGUE(pGC) \
+ wrap(pGCPriv, pGC, funcs, &xxGCFuncs); \
+ if (pGCPriv->ops) wrap(pGCPriv, pGC, ops, &xxGCOps)
+
+static Bool
+xxCreateGC(GCPtr pGC)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ xxScrPriv(pScreen);
+ xxGCPriv(pGC);
+ Bool ret;
+
+ unwrap (pScrPriv, pScreen, CreateGC);
+ if((ret = (*pScreen->CreateGC) (pGC))) {
+ pGCPriv->ops = NULL;
+ pGCPriv->funcs = pGC->funcs;
+ pGC->funcs = &xxGCFuncs;
+ }
+ wrap (pScrPriv, pScreen, CreateGC, xxCreateGC);
+
+ return ret;
+}
+
+static void
+xxValidateGC(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDraw
+){
+ XX_GC_FUNC_PROLOGUE (pGC);
+ (*pGC->funcs->ValidateGC)(pGC, changes, pDraw);
+ if(pDraw->type == DRAWABLE_WINDOW)
+ pGCPriv->ops = pGC->ops; /* just so it's not NULL */
+ else
+ pGCPriv->ops = NULL;
+ XX_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+xxDestroyGC(GCPtr pGC)
+{
+ XX_GC_FUNC_PROLOGUE (pGC);
+ (*pGC->funcs->DestroyGC)(pGC);
+ XX_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+xxChangeGC (
+ GCPtr pGC,
+ unsigned long mask
+){
+ XX_GC_FUNC_PROLOGUE (pGC);
+ (*pGC->funcs->ChangeGC) (pGC, mask);
+ XX_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+xxCopyGC (
+ GCPtr pGCSrc,
+ unsigned long mask,
+ GCPtr pGCDst
+){
+ XX_GC_FUNC_PROLOGUE (pGCDst);
+ (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
+ XX_GC_FUNC_EPILOGUE (pGCDst);
+}
+
+static void
+xxChangeClip (
+ GCPtr pGC,
+ int type,
+ pointer pvalue,
+ int nrects
+){
+ XX_GC_FUNC_PROLOGUE (pGC);
+ (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
+ XX_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+xxCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
+{
+ XX_GC_FUNC_PROLOGUE (pgcDst);
+ (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
+ XX_GC_FUNC_EPILOGUE (pgcDst);
+}
+
+static void
+xxDestroyClip(GCPtr pGC)
+{
+ XX_GC_FUNC_PROLOGUE (pGC);
+ (* pGC->funcs->DestroyClip)(pGC);
+ XX_GC_FUNC_EPILOGUE (pGC);
+}
+
+#define XX_GC_OP_PROLOGUE(pGC,pDraw) \
+ xxScrPriv(pDraw->pScreen); \
+ xxGCPriv(pGC); \
+ GCFuncs *oldFuncs = pGC->funcs; \
+ unwrap(pGCPriv, pGC, funcs); \
+ unwrap(pGCPriv, pGC, ops); \
+
+#define XX_GC_OP_EPILOGUE(pGC,pDraw) \
+ wrap(pGCPriv, pGC, funcs, oldFuncs); \
+ wrap(pGCPriv, pGC, ops, &xxGCOps)
+
+static void
+xxFillSpans(
+ DrawablePtr pDraw,
+ GC *pGC,
+ int nInit,
+ DDXPointPtr pptInit,
+ int *pwidthInit,
+ int fSorted
+){
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && nInit) {
+ DDXPointPtr ppt = pptInit;
+ int *pwidth = pwidthInit;
+ int i = nInit;
+ BoxRec box;
+
+ DBG("FillSpans\n");
+ box.x1 = ppt->x;
+ box.x2 = box.x1 + *pwidth;
+ box.y2 = box.y1 = ppt->y;
+
+ while(--i) {
+ ppt++;
+ pwidthInit++;
+ if(box.x1 > ppt->x) box.x1 = ppt->x;
+ if(box.x2 < (ppt->x + *pwidth))
+ box.x2 = ppt->x + *pwidth;
+ if(box.y1 > ppt->y) box.y1 = ppt->y;
+ else if(box.y2 < ppt->y) box.y2 = ppt->y;
+ }
+
+ box.y2++;
+
+ (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
+
+
+ TRANSLATE_AND_ADD_BOX(box, pGC);
+ } else
+ (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
+
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+}
+
+static void
+xxSetSpans(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ char *pcharsrc,
+ DDXPointPtr pptInit,
+ int *pwidthInit,
+ int nspans,
+ int fSorted
+){
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && nspans) {
+ DDXPointPtr ppt = pptInit;
+ int *pwidth = pwidthInit;
+ int i = nspans;
+ BoxRec box;
+
+ DBG("SetSpans\n");
+ box.x1 = ppt->x;
+ box.x2 = box.x1 + *pwidth;
+ box.y2 = box.y1 = ppt->y;
+
+ while(--i) {
+ ppt++;
+ pwidth++;
+ if(box.x1 > ppt->x) box.x1 = ppt->x;
+ if(box.x2 < (ppt->x + *pwidth))
+ box.x2 = ppt->x + *pwidth;
+ if(box.y1 > ppt->y) box.y1 = ppt->y;
+ else if(box.y2 < ppt->y) box.y2 = ppt->y;
+ }
+
+ box.y2++;
+
+ (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit,
+ pwidthInit, nspans, fSorted);
+
+ TRANSLATE_AND_ADD_BOX(box, pGC);
+ } else
+ (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit,
+ pwidthInit, nspans, fSorted);
+
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+}
+
+static void
+xxPutImage(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int depth,
+ int x, int y, int w, int h,
+ int leftPad,
+ int format,
+ char *pImage
+){
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h,
+ leftPad, format, pImage);
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+ if(IS_VISIBLE(pDraw)) {
+ BoxRec box;
+
+ DBG("PutImage\n");
+ box.x1 = x + pDraw->x;
+ box.x2 = box.x1 + w;
+ box.y1 = y + pDraw->y;
+ box.y2 = box.y1 + h;
+
+ ADD_BOX(box, pGC);
+ }
+}
+
+static RegionPtr
+xxCopyArea(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC *pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty
+){
+ RegionPtr ret;
+ XX_GC_OP_PROLOGUE(pGC, pDst);
+ DBG("xxCopyArea\n");
+ ret = (*pGC->ops->CopyArea)(pSrc, pDst,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+ XX_GC_OP_EPILOGUE(pGC, pDst);
+
+ if(IS_VISIBLE(pDst)) {
+ BoxRec box;
+
+ DBG("CopyArea\n");
+ box.x1 = dstx + pDst->x;
+ box.x2 = box.x1 + width;
+ box.y1 = dsty + pDst->y;
+ box.y2 = box.y1 + height;
+
+ ADD_BOX(box, pGC);
+ }
+
+ return ret;
+}
+
+static RegionPtr
+xxCopyPlane(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty,
+ unsigned long bitPlane
+){
+ RegionPtr ret;
+ XX_GC_OP_PROLOGUE(pGC, pDst);
+ ret = (*pGC->ops->CopyPlane)(pSrc, pDst,
+ pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
+ XX_GC_OP_EPILOGUE(pGC, pDst);
+
+ if(IS_VISIBLE(pDst)) {
+ BoxRec box;
+
+ DBG("CopyPlane\n");
+ box.x1 = dstx + pDst->x;
+ box.x2 = box.x1 + width;
+ box.y1 = dsty + pDst->y;
+ box.y2 = box.y1 + height;
+
+ ADD_BOX(box, pGC);
+ }
+
+ return ret;
+}
+
+static void
+xxPolyPoint(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ xPoint *pptInit
+){
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && npt) {
+ BoxRec box;
+
+ DBG("PolyPoint\n");
+ box.x2 = box.x1 = pptInit->x;
+ box.y2 = box.y1 = pptInit->y;
+
+ /* this could be slow if the points were spread out */
+
+ while(--npt) {
+ pptInit++;
+ if(box.x1 > pptInit->x) box.x1 = pptInit->x;
+ else if(box.x2 < pptInit->x) box.x2 = pptInit->x;
+ if(box.y1 > pptInit->y) box.y1 = pptInit->y;
+ else if(box.y2 < pptInit->y) box.y2 = pptInit->y;
+ }
+
+ box.x2++;
+ box.y2++;
+
+ TRANSLATE_AND_ADD_BOX(box, pGC);
+ }
+}
+
+static void
+xxPolylines(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr pptInit
+){
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+
+
+ if(IS_VISIBLE(pDraw) && npt) {
+ BoxRec box;
+ int extra = pGC->lineWidth >> 1;
+
+ DBG("PolyLine\n");
+ box.x2 = box.x1 = pptInit->x;
+ box.y2 = box.y1 = pptInit->y;
+
+ if(npt > 1) {
+ if(pGC->joinStyle == JoinMiter)
+ extra = 6 * pGC->lineWidth;
+ else if(pGC->capStyle == CapProjecting)
+ extra = pGC->lineWidth;
+ }
+
+ if(mode == CoordModePrevious) {
+ int x = box.x1;
+ int y = box.y1;
+ while(--npt) {
+ pptInit++;
+ x += pptInit->x;
+ y += pptInit->y;
+ if(box.x1 > x) box.x1 = x;
+ else if(box.x2 < x) box.x2 = x;
+ if(box.y1 > y) box.y1 = y;
+ else if(box.y2 < y) box.y2 = y;
+ }
+ } else {
+ while(--npt) {
+ pptInit++;
+ if(box.x1 > pptInit->x) box.x1 = pptInit->x;
+ else if(box.x2 < pptInit->x) box.x2 = pptInit->x;
+ if(box.y1 > pptInit->y) box.y1 = pptInit->y;
+ else if(box.y2 < pptInit->y) box.y2 = pptInit->y;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ if(extra) {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ TRANSLATE_AND_ADD_BOX(box, pGC);
+ }
+}
+
+static void
+xxPolySegment(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSeg
+ ){
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && nseg) {
+ BoxRec box;
+ int extra = pGC->lineWidth;
+
+ DBG("PolySegment\n");
+ if(pGC->capStyle != CapProjecting)
+ extra >>= 1;
+
+ if(pSeg->x2 > pSeg->x1) {
+ box.x1 = pSeg->x1;
+ box.x2 = pSeg->x2;
+ } else {
+ box.x2 = pSeg->x1;
+ box.x1 = pSeg->x2;
+ }
+
+ if(pSeg->y2 > pSeg->y1) {
+ box.y1 = pSeg->y1;
+ box.y2 = pSeg->y2;
+ } else {
+ box.y2 = pSeg->y1;
+ box.y1 = pSeg->y2;
+ }
+
+ while(--nseg) {
+ pSeg++;
+ if(pSeg->x2 > pSeg->x1) {
+ if(pSeg->x1 < box.x1) box.x1 = pSeg->x1;
+ if(pSeg->x2 > box.x2) box.x2 = pSeg->x2;
+ } else {
+ if(pSeg->x2 < box.x1) box.x1 = pSeg->x2;
+ if(pSeg->x1 > box.x2) box.x2 = pSeg->x1;
+ }
+ if(pSeg->y2 > pSeg->y1) {
+ if(pSeg->y1 < box.y1) box.y1 = pSeg->y1;
+ if(pSeg->y2 > box.y2) box.y2 = pSeg->y2;
+ } else {
+ if(pSeg->y2 < box.y1) box.y1 = pSeg->y2;
+ if(pSeg->y1 > box.y2) box.y2 = pSeg->y1;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ if(extra) {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ TRANSLATE_AND_ADD_BOX(box, pGC);
+ }
+}
+
+static void
+xxPolyRectangle(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nRects,
+ xRectangle *pRects
+){
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->PolyRectangle)(pDraw, pGC, nRects, pRects);
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && nRects)
+ {
+ BoxRec box;
+ int offset1, offset2, offset3;
+
+ DBG("PolyRectangle\n");
+ offset2 = pGC->lineWidth;
+ if(!offset2) offset2 = 1;
+ offset1 = offset2 >> 1;
+ offset3 = offset2 - offset1;
+
+ while(nRects--)
+ {
+ box.x1 = pRects->x - offset1;
+ box.y1 = pRects->y - offset1;
+ box.x2 = box.x1 + pRects->width + offset2;
+ box.y2 = box.y1 + offset2;
+ TRANSLATE_AND_ADD_BOX(box, pGC);
+ box.x1 = pRects->x - offset1;
+ box.y1 = pRects->y + offset3;
+ box.x2 = box.x1 + offset2;
+ box.y2 = box.y1 + pRects->height - offset2;
+ TRANSLATE_AND_ADD_BOX(box, pGC);
+ box.x1 = pRects->x + pRects->width - offset1;
+ box.y1 = pRects->y + offset3;
+ box.x2 = box.x1 + offset2;
+ box.y2 = box.y1 + pRects->height - offset2;
+ TRANSLATE_AND_ADD_BOX(box, pGC);
+ box.x1 = pRects->x - offset1;
+ box.y1 = pRects->y + pRects->height - offset1;
+ box.x2 = box.x1 + pRects->width + offset2;
+ box.y2 = box.y1 + offset2;
+ TRANSLATE_AND_ADD_BOX(box, pGC);
+
+ pRects++;
+ }
+ }
+}
+
+static void
+xxPolyArc(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int narcs,
+ xArc *parcs
+){
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && narcs) {
+ int extra = pGC->lineWidth >> 1;
+ BoxRec box;
+
+ DBG("PolyArc\n");
+ box.x1 = parcs->x;
+ box.x2 = box.x1 + parcs->width;
+ box.y1 = parcs->y;
+ box.y2 = box.y1 + parcs->height;
+
+ /* should I break these up instead ? */
+
+ while(--narcs) {
+ parcs++;
+ if(box.x1 > parcs->x) box.x1 = parcs->x;
+ if(box.x2 < (parcs->x + parcs->width))
+ box.x2 = parcs->x + parcs->width;
+ if(box.y1 > parcs->y) box.y1 = parcs->y;
+ if(box.y2 < (parcs->y + parcs->height))
+ box.y2 = parcs->y + parcs->height;
+ }
+
+ if(extra) {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ box.x2++;
+ box.y2++;
+
+ TRANSLATE_AND_ADD_BOX(box, pGC);
+ }
+}
+
+static void
+xxFillPolygon(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int count,
+ DDXPointPtr pptInit
+){
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && (count > 2)) {
+ DDXPointPtr ppt = pptInit;
+ int i = count;
+ BoxRec box;
+
+ DBG("FillPolygon\n");
+ box.x2 = box.x1 = ppt->x;
+ box.y2 = box.y1 = ppt->y;
+
+ if(mode != CoordModeOrigin) {
+ int x = box.x1;
+ int y = box.y1;
+ while(--i) {
+ ppt++;
+ x += ppt->x;
+ y += ppt->y;
+ if(box.x1 > x) box.x1 = x;
+ else if(box.x2 < x) box.x2 = x;
+ if(box.y1 > y) box.y1 = y;
+ else if(box.y2 < y) box.y2 = y;
+ }
+ } else {
+ while(--i) {
+ ppt++;
+ if(box.x1 > ppt->x) box.x1 = ppt->x;
+ else if(box.x2 < ppt->x) box.x2 = ppt->x;
+ if(box.y1 > ppt->y) box.y1 = ppt->y;
+ else if(box.y2 < ppt->y) box.y2 = ppt->y;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, pptInit);
+
+ TRANSLATE_AND_ADD_BOX(box, pGC);
+ } else
+ (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, pptInit);
+
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+}
+
+static void
+xxPolyFillRect(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nRectsInit,
+ xRectangle *pRectsInit
+){
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && nRectsInit) {
+ BoxRec box;
+ xRectangle *pRects = pRectsInit;
+ int nRects = nRectsInit;
+
+ DBG("PolyFillRect\n");
+ box.x1 = pRects->x;
+ box.x2 = box.x1 + pRects->width;
+ box.y1 = pRects->y;
+ box.y2 = box.y1 + pRects->height;
+
+ while(--nRects) {
+ pRects++;
+ if(box.x1 > pRects->x) box.x1 = pRects->x;
+ if(box.x2 < (pRects->x + pRects->width))
+ box.x2 = pRects->x + pRects->width;
+ if(box.y1 > pRects->y) box.y1 = pRects->y;
+ if(box.y2 < (pRects->y + pRects->height))
+ box.y2 = pRects->y + pRects->height;
+ }
+
+ /* cfb messes with the pRectsInit so we have to do our
+ calculations first */
+
+ (*pGC->ops->PolyFillRect)(pDraw, pGC, nRectsInit, pRectsInit);
+
+ TRANSLATE_AND_ADD_BOX(box, pGC);
+ } else
+ (*pGC->ops->PolyFillRect)(pDraw, pGC, nRectsInit, pRectsInit);
+
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+}
+
+static void
+xxPolyFillArc(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int narcs,
+ xArc *parcs
+){
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && narcs) {
+ BoxRec box;
+
+ DBG("PolyFillArc\n");
+ box.x1 = parcs->x;
+ box.x2 = box.x1 + parcs->width;
+ box.y1 = parcs->y;
+ box.y2 = box.y1 + parcs->height;
+
+ /* should I break these up instead ? */
+
+ while(--narcs) {
+ parcs++;
+ if(box.x1 > parcs->x) box.x1 = parcs->x;
+ if(box.x2 < (parcs->x + parcs->width))
+ box.x2 = parcs->x + parcs->width;
+ if(box.y1 > parcs->y) box.y1 = parcs->y;
+ if(box.y2 < (parcs->y + parcs->height))
+ box.y2 = parcs->y + parcs->height;
+ }
+
+ TRANSLATE_AND_ADD_BOX(box, pGC);
+ }
+}
+
+static int
+xxPolyText8(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *chars
+){
+ int width;
+
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+ width = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+
+ width -= x;
+
+ if(IS_VISIBLE(pDraw) && (width > 0)) {
+ BoxRec box;
+
+ DBG("PolyText8\n");
+ /* ugh */
+ box.x1 = pDraw->x + x + FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = pDraw->x + x + FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ if(count > 1) {
+ if(width > 0) box.x2 += width;
+ else box.x1 += width;
+ }
+
+ box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent);
+ box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent);
+
+ ADD_BOX(box, pGC);
+ }
+
+ return (width + x);
+}
+
+static int
+xxPolyText16(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *chars
+){
+ int width;
+
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+ width = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+
+ width -= x;
+
+ if(IS_VISIBLE(pDraw) && (width > 0)) {
+ BoxRec box;
+
+ DBG("PolyText16\n");
+ /* ugh */
+ box.x1 = pDraw->x + x + FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = pDraw->x + x + FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ if(count > 1) {
+ if(width > 0) box.x2 += width;
+ else box.x1 += width;
+ }
+
+ box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent);
+ box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent);
+
+ ADD_BOX(box, pGC);
+ }
+
+ return (width + x);
+}
+
+static void
+xxImageText8(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *chars
+){
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && count) {
+ int top, bot, Min, Max;
+ BoxRec box;
+
+ DBG("ImageText8\n");
+ top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+ bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+ Min = count * FONTMINBOUNDS(pGC->font, characterWidth);
+ if(Min > 0) Min = 0;
+ Max = count * FONTMAXBOUNDS(pGC->font, characterWidth);
+ if(Max < 0) Max = 0;
+
+ /* ugh */
+ box.x1 = pDraw->x + x + Min +
+ FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = pDraw->x + x + Max +
+ FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ box.y1 = pDraw->y + y - top;
+ box.y2 = pDraw->y + y + bot;
+
+ ADD_BOX(box, pGC);
+ }
+}
+
+static void
+xxImageText16(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *chars
+){
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && count) {
+ int top, bot, Min, Max;
+ BoxRec box;
+
+ DBG("ImageText16\n");
+ top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+ bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+ Min = count * FONTMINBOUNDS(pGC->font, characterWidth);
+ if(Min > 0) Min = 0;
+ Max = count * FONTMAXBOUNDS(pGC->font, characterWidth);
+ if(Max < 0) Max = 0;
+
+ /* ugh */
+ box.x1 = pDraw->x + x + Min +
+ FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = pDraw->x + x + Max +
+ FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ box.y1 = pDraw->y + y - top;
+ box.y2 = pDraw->y + y + bot;
+
+ ADD_BOX(box, pGC);
+ }
+}
+
+static void
+xxImageGlyphBlt(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase
+){
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, nglyph,
+ ppci, pglyphBase);
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && nglyph) {
+ int top, bot, width = 0;
+ BoxRec box;
+
+ DBG("ImageGlyphBlt\n");
+ top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+ bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+ box.x1 = ppci[0]->metrics.leftSideBearing;
+ if(box.x1 > 0) box.x1 = 0;
+ box.x2 = ppci[nglyph - 1]->metrics.rightSideBearing -
+ ppci[nglyph - 1]->metrics.characterWidth;
+ if(box.x2 < 0) box.x2 = 0;
+
+ box.x2 += pDraw->x + x;
+ box.x1 += pDraw->x + x;
+
+ while(nglyph--) {
+ width += (*ppci)->metrics.characterWidth;
+ ppci++;
+ }
+
+ if(width > 0)
+ box.x2 += width;
+ else
+ box.x1 += width;
+
+ box.y1 = pDraw->y + y - top;
+ box.y2 = pDraw->y + y + bot;
+
+ ADD_BOX(box, pGC);
+ }
+}
+
+static void
+xxPolyGlyphBlt(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase
+){
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, x, y, nglyph,
+ ppci, pglyphBase);
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && nglyph) {
+ BoxRec box;
+
+ DBG("PolyGlyphBlt\n");
+ /* ugh */
+ box.x1 = pDraw->x + x + ppci[0]->metrics.leftSideBearing;
+ box.x2 = pDraw->x + x + ppci[nglyph - 1]->metrics.rightSideBearing;
+
+ if(nglyph > 1) {
+ int width = 0;
+
+ while(--nglyph) {
+ width += (*ppci)->metrics.characterWidth;
+ ppci++;
+ }
+
+ if(width > 0) box.x2 += width;
+ else box.x1 += width;
+ }
+
+ box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent);
+ box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent);
+
+ ADD_BOX(box, pGC);
+ }
+}
+
+static void
+xxPushPixels(
+ GCPtr pGC,
+ PixmapPtr pBitMap,
+ DrawablePtr pDraw,
+ int dx, int dy, int xOrg, int yOrg
+){
+ XX_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
+ XX_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw)) {
+ BoxRec box;
+
+ DBG("PushPixels\n");
+ box.x1 = xOrg + pDraw->x;
+ box.x2 = box.x1 + dx;
+ box.y1 = yOrg + pDraw->y;
+ box.y2 = box.y1 + dy;
+
+ ADD_BOX(box, pGC);
+ }
+}
+
+
+#ifdef RENDER
+#define RENDER_MAKE_BOX(pDrawable,X,Y,W,H) { \
+ box.x1 = X + pDrawable->x; \
+ box.x2 = X + pDrawable->x + W; \
+ box.y1 = Y + pDrawable->y; \
+ box.y2 = Y + pDrawable->y + H; \
+}
+
+#define RENDER_ADD_BOX(pScreen,box) {\
+ if (BOX_NOT_EMPTY(box)) { \
+ RegionRec region; \
+ xxScrPriv(pScreen);\
+ ScreenPtr pScreen = pScreen;\
+ REGION_INIT (pScreen, &region, &box, 1); \
+ PRINT_RECTS(pScrPriv->region);\
+ REGION_UNION(pScreen,&pScrPriv->region,&pScrPriv->region,&region);\
+ PRINT_RECTS(pScrPriv->region);\
+ REGION_UNINIT(pScreen,&region);\
+ }\
+}
+
+static void
+xxComposite (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
+ INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
+ INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ xxScrPriv(pScreen);
+ BoxRec box;
+
+ unwrap (pScrPriv, ps, Composite);
+ (*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
+ xDst, yDst, width, height);
+ wrap (pScrPriv, ps, Composite, xxComposite);
+ if (pDst->pDrawable->type == DRAWABLE_WINDOW) {
+ RENDER_MAKE_BOX(pDst->pDrawable, xDst, yDst, width, height);
+ RENDER_ADD_BOX(pScreen,box);
+ }
+}
+
+
+static void
+xxGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist,
+ GlyphListPtr list, GlyphPtr *glyphs)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ xxScrPriv(pScreen);
+ int x, y;
+ int n;
+ GlyphPtr glyph;
+ BoxRec box;
+
+ unwrap (pScrPriv, ps, Glyphs);
+ (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc,
+ nlist, list, glyphs);
+ wrap (pScrPriv, ps, Glyphs, xxGlyphs);
+ if (pDst->pDrawable->type == DRAWABLE_WINDOW)
+ {
+ x = xSrc;
+ y = ySrc;
+ while (nlist--)
+ {
+ x += list->xOff;
+ y += list->yOff;
+ n = list->len;
+ while (n--)
+ {
+ glyph = *glyphs++;
+ RENDER_MAKE_BOX(pDst->pDrawable,
+ x - glyph->info.x, y - glyph->info.y,
+ glyph->info.width, glyph->info.height);
+ RENDER_ADD_BOX(pScreen,box);
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ }
+ list++;
+ }
+ }
+}
+#endif
+
+void
+xxPrintVisuals(void)
+{
+ int k,i,j;
+ DepthPtr pDepth;
+ VisualPtr pVisual;
+
+ for (k = 0; k < screenInfo.numScreens; k++) {
+ ScreenPtr pScreen = screenInfo.screens[k];
+
+ pDepth = pScreen->allowedDepths;
+ for (i = 0; i < pScreen->numDepths; i++, pDepth++)
+ for (j = 0; j < pDepth->numVids; j++) {
+ ErrorF("depth: %i vid: 0x%lx\n",
+ pDepth->depth, pDepth->vids[j]);
+ }
+
+ pVisual = pScreen->visuals;
+ for (i = 0; i < pScreen->numVisuals; i++, pVisual++)
+ ErrorF("vid: 0x%x rm: 0x%lx gm: 0x%lx bm: 0x%lx\n",
+ (unsigned int)pVisual->vid,
+ pVisual->redMask,
+ pVisual->greenMask,
+ pVisual->blueMask);
+ }
+}
+
+
diff --git a/nx-X11/programs/Xserver/fb/fbpseudocolor.h b/nx-X11/programs/Xserver/fb/fbpseudocolor.h
new file mode 100644
index 000000000..64de71db8
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbpseudocolor.h
@@ -0,0 +1,20 @@
+#ifndef _FB_XX_H_
+# define _FB_XX_H_
+
+typedef void (*xxSyncFunc)(ScreenPtr);
+extern Bool xxSetup(ScreenPtr pScreen, int myDepth,
+ int baseDepth, char *addr, xxSyncFunc sync);
+extern void xxPrintVisuals(void);
+
+
+#endif /* _FB_XX_H_ */
+
+
+
+
+
+
+
+
+
+
diff --git a/nx-X11/programs/Xserver/fb/fbpush.c b/nx-X11/programs/Xserver/fb/fbpush.c
new file mode 100644
index 000000000..8f1336963
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbpush.c
@@ -0,0 +1,247 @@
+/*
+ * Id: fbpush.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbpush.c,v 1.3 2000/02/14 19:20:30 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbPushPattern (DrawablePtr pDrawable,
+ GCPtr pGC,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX,
+
+ int x,
+ int y,
+
+ int width,
+ int height)
+{
+ FbStip *s, bitsMask, bitsMask0, bits;
+ int xspan;
+ int w;
+ int lenspan;
+
+ src += srcX >> FB_STIP_SHIFT;
+ srcX &= FB_STIP_MASK;
+
+ bitsMask0 = FbStipMask (srcX, 1);
+
+ while (height--)
+ {
+ bitsMask = bitsMask0;
+ w = width;
+ s = src;
+ src += srcStride;
+ bits = *s++;
+ xspan = x;
+ while (w)
+ {
+ if (bits & bitsMask)
+ {
+ lenspan = 0;
+ do
+ {
+ lenspan++;
+ if (lenspan == w)
+ break;
+ bitsMask = FbStipRight (bitsMask, 1);
+ if (!bitsMask)
+ {
+ bits = *s++;
+ bitsMask = FbBitsMask(0,1);
+ }
+ } while (bits & bitsMask);
+ fbFill (pDrawable, pGC, xspan, y, lenspan, 1);
+ xspan += lenspan;
+ w -= lenspan;
+ }
+ else
+ {
+ do
+ {
+ w--;
+ xspan++;
+ if (!w)
+ break;
+ bitsMask = FbStipRight (bitsMask, 1);
+ if (!bitsMask)
+ {
+ bits = *s++;
+ bitsMask = FbBitsMask(0,1);
+ }
+ } while (!(bits & bitsMask));
+ }
+ }
+ y++;
+ }
+}
+
+void
+fbPushFill (DrawablePtr pDrawable,
+ GCPtr pGC,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX,
+
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+
+ if (pGC->fillStyle == FillSolid)
+ {
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ int dstX;
+ int dstWidth;
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ dst = dst + (y + dstYoff) * dstStride;
+ dstX = (x + dstXoff) * dstBpp;
+ dstWidth = width * dstBpp;
+ if (dstBpp == 1)
+ {
+ fbBltStip (src,
+ srcStride,
+ srcX,
+
+ (FbStip *) dst,
+ FbBitsStrideToStipStride (dstStride),
+ dstX,
+
+ dstWidth,
+ height,
+
+ FbStipple1Rop(pGC->alu,pGC->fgPixel),
+ pPriv->pm,
+ dstBpp);
+ }
+ else
+ {
+ fbBltOne (src,
+ srcStride,
+ srcX,
+
+ dst,
+ dstStride,
+ dstX,
+ dstBpp,
+
+ dstWidth,
+ height,
+
+ pPriv->and, pPriv->xor,
+ fbAnd(GXnoop,(FbBits) 0,FB_ALLONES),
+ fbXor(GXnoop,(FbBits) 0,FB_ALLONES));
+ }
+ }
+ else
+ {
+ fbPushPattern (pDrawable, pGC, src, srcStride, srcX,
+ x, y, width, height);
+ }
+}
+
+void
+fbPushImage (DrawablePtr pDrawable,
+ GCPtr pGC,
+
+ FbStip *src,
+ FbStride srcStride,
+ int srcX,
+
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ RegionPtr pClip = fbGetCompositeClip (pGC);
+ int nbox;
+ BoxPtr pbox;
+ int x1, y1, x2, y2;
+
+ for (nbox = REGION_NUM_RECTS (pClip),
+ pbox = REGION_RECTS(pClip);
+ nbox--;
+ pbox++)
+ {
+ x1 = x;
+ y1 = y;
+ x2 = x + width;
+ y2 = y + height;
+ if (x1 < pbox->x1)
+ x1 = pbox->x1;
+ if (y1 < pbox->y1)
+ y1 = pbox->y1;
+ if (x2 > pbox->x2)
+ x2 = pbox->x2;
+ if (y2 > pbox->y2)
+ y2 = pbox->y2;
+ if (x1 >= x2 || y1 >= y2)
+ continue;
+ fbPushFill (pDrawable,
+ pGC,
+
+ src + (y1 - y) * srcStride,
+ srcStride,
+ srcX + (x1 - x),
+
+ x1,
+ y1,
+ x2 - x1,
+ y2 - y1);
+ }
+}
+
+void
+fbPushPixels (GCPtr pGC,
+ PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int dx,
+ int dy,
+ int xOrg,
+ int yOrg)
+{
+ FbStip *stip;
+ FbStride stipStride;
+ int stipBpp;
+ int stipXoff, stipYoff; /* Assumed to be zero */
+
+ fbGetStipDrawable (&pBitmap->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff);
+
+ fbPushImage (pDrawable, pGC,
+ stip, stipStride, 0,
+ xOrg, yOrg, dx, dy);
+}
diff --git a/nx-X11/programs/Xserver/fb/fbrop.h b/nx-X11/programs/Xserver/fb/fbrop.h
new file mode 100644
index 000000000..65f62c393
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbrop.h
@@ -0,0 +1,139 @@
+/*
+ * Id: fbrop.h,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbrop.h,v 1.3 2000/02/14 19:20:30 dawes Exp $ */
+
+#ifndef _FBROP_H_
+#define _FBROP_H_
+
+typedef struct _mergeRopBits {
+ FbBits ca1, cx1, ca2, cx2;
+} FbMergeRopRec, *FbMergeRopPtr;
+
+extern const FbMergeRopRec FbMergeRopBits[16];
+
+#define FbDeclareMergeRop() FbBits _ca1, _cx1, _ca2, _cx2;
+#define FbDeclarePrebuiltMergeRop() FbBits _cca, _ccx;
+
+#define FbInitializeMergeRop(alu,pm) {\
+ const FbMergeRopRec *_bits; \
+ _bits = &FbMergeRopBits[alu]; \
+ _ca1 = _bits->ca1 & pm; \
+ _cx1 = _bits->cx1 | ~pm; \
+ _ca2 = _bits->ca2 & pm; \
+ _cx2 = _bits->cx2 & pm; \
+}
+
+#define FbDestInvarientRop(alu,pm) ((pm) == FB_ALLONES && \
+ (((alu) >> 1 & 5) == ((alu) & 5)))
+
+#define FbDestInvarientMergeRop() (_ca1 == 0 && _cx1 == 0)
+
+/* AND has higher precedence than XOR */
+
+#define FbDoMergeRop(src, dst) \
+ (((dst) & (((src) & _ca1) ^ _cx1)) ^ (((src) & _ca2) ^ _cx2))
+
+#define FbDoDestInvarientMergeRop(src) (((src) & _ca2) ^ _cx2)
+
+#define FbDoMaskMergeRop(src, dst, mask) \
+ (((dst) & ((((src) & _ca1) ^ _cx1) | ~(mask))) ^ ((((src) & _ca2) ^ _cx2) & (mask)))
+
+#define FbDoLeftMaskByteMergeRop(dst, src, lb, l) { \
+ FbBits __xor = ((src) & _ca2) ^ _cx2; \
+ FbDoLeftMaskByteRRop(dst,lb,l,((src) & _ca1) ^ _cx1,__xor); \
+}
+
+#define FbDoRightMaskByteMergeRop(dst, src, rb, r) { \
+ FbBits __xor = ((src) & _ca2) ^ _cx2; \
+ FbDoRightMaskByteRRop(dst,rb,r,((src) & _ca1) ^ _cx1,__xor); \
+}
+
+#define FbDoRRop(dst, and, xor) (((dst) & (and)) ^ (xor))
+
+#define FbDoMaskRRop(dst, and, xor, mask) \
+ (((dst) & ((and) | ~(mask))) ^ (xor & mask))
+
+/*
+ * Take a single bit (0 or 1) and generate a full mask
+ */
+#define fbFillFromBit(b,t) (~((t) ((b) & 1)-1))
+
+#define fbXorT(rop,fg,pm,t) ((((fg) & fbFillFromBit((rop) >> 1,t)) | \
+ (~(fg) & fbFillFromBit((rop) >> 3,t))) & (pm))
+
+#define fbAndT(rop,fg,pm,t) ((((fg) & fbFillFromBit (rop ^ (rop>>1),t)) | \
+ (~(fg) & fbFillFromBit((rop>>2) ^ (rop>>3),t))) | \
+ ~(pm))
+
+#define fbXor(rop,fg,pm) fbXorT(rop,fg,pm,FbBits)
+
+#define fbAnd(rop,fg,pm) fbAndT(rop,fg,pm,FbBits)
+
+#define fbXorStip(rop,fg,pm) fbXorT(rop,fg,pm,FbStip)
+
+#define fbAndStip(rop,fg,pm) fbAndT(rop,fg,pm,FbStip)
+
+/*
+ * Stippling operations;
+ */
+
+extern const FbBits fbStipple16Bits[256]; /* half of table */
+#define FbStipple16Bits(b) \
+ (fbStipple16Bits[(b)&0xff] | fbStipple16Bits[(b) >> 8] << FB_HALFUNIT)
+extern const FbBits fbStipple8Bits[256];
+extern const FbBits fbStipple4Bits[16];
+extern const FbBits fbStipple2Bits[4];
+extern const FbBits fbStipple1Bits[2];
+extern const FbBits *const fbStippleTable[];
+
+#define FbStippleRRop(dst, b, fa, fx, ba, bx) \
+ (FbDoRRop(dst, fa, fx) & b) | (FbDoRRop(dst, ba, bx) & ~b)
+
+#define FbStippleRRopMask(dst, b, fa, fx, ba, bx, m) \
+ (FbDoMaskRRop(dst, fa, fx, m) & (b)) | (FbDoMaskRRop(dst, ba, bx, m) & ~(b))
+
+#define FbDoLeftMaskByteStippleRRop(dst, b, fa, fx, ba, bx, lb, l) { \
+ FbBits __xor = ((fx) & (b)) | ((bx) & ~(b)); \
+ FbDoLeftMaskByteRRop(dst, lb, l, ((fa) & (b)) | ((ba) & ~(b)), __xor); \
+}
+
+#define FbDoRightMaskByteStippleRRop(dst, b, fa, fx, ba, bx, rb, r) { \
+ FbBits __xor = ((fx) & (b)) | ((bx) & ~(b)); \
+ FbDoRightMaskByteRRop(dst, rb, r, ((fa) & (b)) | ((ba) & ~(b)), __xor); \
+}
+
+#define FbOpaqueStipple(b, fg, bg) (((fg) & (b)) | ((bg) & ~(b)))
+
+/*
+ * Compute rop for using tile code for 1-bit dest stipples; modifies
+ * existing rop to flip depending on pixel values
+ */
+#define FbStipple1RopPick(alu,b) (((alu) >> (2 - (((b) & 1) << 1))) & 3)
+
+#define FbOpaqueStipple1Rop(alu,fg,bg) (FbStipple1RopPick(alu,fg) | \
+ (FbStipple1RopPick(alu,bg) << 2))
+
+#define FbStipple1Rop(alu,fg) (FbStipple1RopPick(alu,fg) | 4)
+
+#endif
diff --git a/nx-X11/programs/Xserver/fb/fbscreen.c b/nx-X11/programs/Xserver/fb/fbscreen.c
new file mode 100644
index 000000000..70d3d7a13
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbscreen.c
@@ -0,0 +1,301 @@
+/* $XdotOrg: xc/programs/Xserver/fb/fbscreen.c,v 1.6 2005/07/03 07:01:23 daniels Exp $
+ * Id: fbscreen.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbscreen.c,v 1.13 2001/05/29 04:54:09 keithp Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+Bool
+fbCloseScreen (int index, ScreenPtr pScreen)
+{
+ int d;
+ DepthPtr depths = pScreen->allowedDepths;
+
+ for (d = 0; d < pScreen->numDepths; d++)
+ xfree (depths[d].vids);
+ xfree (depths);
+ xfree (pScreen->visuals);
+ xfree (pScreen->devPrivate);
+#ifdef FB_SCREEN_PRIVATE
+ xfree (pScreen->devPrivates[fbScreenPrivateIndex].ptr);
+#endif
+ return TRUE;
+}
+
+Bool
+fbRealizeFont(ScreenPtr pScreen, FontPtr pFont)
+{
+ return (TRUE);
+}
+
+Bool
+fbUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
+{
+ return (TRUE);
+}
+
+void
+fbQueryBestSize (int class,
+ unsigned short *width, unsigned short *height,
+ ScreenPtr pScreen)
+{
+ unsigned short w;
+
+ switch (class) {
+ case CursorShape:
+ if (*width > pScreen->width)
+ *width = pScreen->width;
+ if (*height > pScreen->height)
+ *height = pScreen->height;
+ break;
+ case TileShape:
+ case StippleShape:
+ w = *width;
+ if ((w & (w - 1)) && w < FB_UNIT)
+ {
+ for (w = 1; w < *width; w <<= 1)
+ ;
+ *width = w;
+ }
+ }
+}
+
+#ifndef FB_OLD_SCREEN
+PixmapPtr
+_fbGetWindowPixmap (WindowPtr pWindow)
+{
+ return fbGetWindowPixmap (pWindow);
+}
+
+void
+_fbSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
+{
+#ifdef FB_NO_WINDOW_PIXMAPS
+ FatalError ("Attempted to set window pixmap without fb support\n");
+#else
+ pWindow->devPrivates[fbWinPrivateIndex].ptr = (pointer) pPixmap;
+#endif
+}
+#endif
+
+Bool
+fbSetupScreen(ScreenPtr pScreen,
+ pointer pbits, /* pointer to screen bitmap */
+ int xsize, /* in pixels */
+ int ysize,
+ int dpix, /* dots per inch */
+ int dpiy,
+ int width, /* pixel width of frame buffer */
+ int bpp) /* bits per pixel for screen */
+{
+ if (!fbAllocatePrivates(pScreen, (int *) 0))
+ return FALSE;
+ pScreen->defColormap = FakeClientID(0);
+ /* let CreateDefColormap do whatever it wants for pixels */
+ pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
+ pScreen->QueryBestSize = fbQueryBestSize;
+ /* SaveScreen */
+ pScreen->GetImage = fbGetImage;
+ pScreen->GetSpans = fbGetSpans;
+ pScreen->CreateWindow = fbCreateWindow;
+ pScreen->DestroyWindow = fbDestroyWindow;
+ pScreen->PositionWindow = fbPositionWindow;
+ pScreen->ChangeWindowAttributes = fbChangeWindowAttributes;
+ pScreen->RealizeWindow = fbMapWindow;
+ pScreen->UnrealizeWindow = fbUnmapWindow;
+ pScreen->PaintWindowBackground = fbPaintWindow;
+ pScreen->PaintWindowBorder = fbPaintWindow;
+ pScreen->CopyWindow = fbCopyWindow;
+ pScreen->CreatePixmap = fbCreatePixmap;
+ pScreen->DestroyPixmap = fbDestroyPixmap;
+ pScreen->RealizeFont = fbRealizeFont;
+ pScreen->UnrealizeFont = fbUnrealizeFont;
+ pScreen->CreateGC = fbCreateGC;
+ pScreen->CreateColormap = fbInitializeColormap;
+ pScreen->DestroyColormap = (void (*)(ColormapPtr))NoopDDA;
+ pScreen->InstallColormap = fbInstallColormap;
+ pScreen->UninstallColormap = fbUninstallColormap;
+ pScreen->ListInstalledColormaps = fbListInstalledColormaps;
+ pScreen->StoreColors = (void (*)(ColormapPtr, int, xColorItem *))NoopDDA;
+ pScreen->ResolveColor = fbResolveColor;
+ pScreen->BitmapToRegion = fbPixmapToRegion;
+
+#ifndef FB_OLD_SCREEN
+ pScreen->GetWindowPixmap = _fbGetWindowPixmap;
+ pScreen->SetWindowPixmap = _fbSetWindowPixmap;
+
+ pScreen->BackingStoreFuncs.SaveAreas = fbSaveAreas;
+ pScreen->BackingStoreFuncs.RestoreAreas = fbRestoreAreas;
+ pScreen->BackingStoreFuncs.SetClipmaskRgn = 0;
+ pScreen->BackingStoreFuncs.GetImagePixmap = 0;
+ pScreen->BackingStoreFuncs.GetSpansPixmap = 0;
+#endif
+
+ return TRUE;
+}
+
+Bool
+fbFinishScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp)
+{
+ VisualPtr visuals;
+ DepthPtr depths;
+ int nvisuals;
+ int ndepths;
+ int rootdepth;
+ VisualID defaultVisual;
+ int imagebpp = bpp;
+
+#ifdef FB_DEBUG
+ int stride;
+
+ ysize -= 2;
+ stride = (width * bpp) / 8;
+ fbSetBits ((FbStip *) pbits,
+ stride / sizeof (FbStip), FB_HEAD_BITS);
+ pbits = (void *) ((char *) pbits + stride);
+ fbSetBits ((FbStip *) ((char *) pbits + stride * ysize),
+ stride / sizeof (FbStip), FB_TAIL_BITS);
+#endif
+ /*
+ * By default, a 24bpp screen will use 32bpp images, this avoids
+ * problems with many applications which just can't handle packed
+ * pixels. If you want real 24bit images, include a 24bpp
+ * format in the pixmap formats
+ */
+#ifdef FB_24_32BIT
+ if (bpp == 24)
+ {
+ int f;
+
+ imagebpp = 32;
+ /*
+ * Check to see if we're advertising a 24bpp image format,
+ * in which case windows will use it in preference to a 32 bit
+ * format.
+ */
+ for (f = 0; f < screenInfo.numPixmapFormats; f++)
+ {
+ if (screenInfo.formats[f].bitsPerPixel == 24)
+ {
+ imagebpp = 24;
+ break;
+ }
+ }
+ }
+#endif
+#ifdef FB_SCREEN_PRIVATE
+ if (imagebpp == 32)
+ {
+ fbGetScreenPrivate(pScreen)->win32bpp = bpp;
+ fbGetScreenPrivate(pScreen)->pix32bpp = bpp;
+ }
+ else
+ {
+ fbGetScreenPrivate(pScreen)->win32bpp = 32;
+ fbGetScreenPrivate(pScreen)->pix32bpp = 32;
+ }
+#endif
+ rootdepth = 0;
+ if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
+ &defaultVisual,((unsigned long)1<<(imagebpp-1)), 8))
+ return FALSE;
+ if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
+ rootdepth, ndepths, depths,
+ defaultVisual, nvisuals, visuals
+#ifdef FB_OLD_MISCREENINIT
+ , (miBSFuncPtr) 0
+#endif
+ ))
+ return FALSE;
+ /* overwrite miCloseScreen with our own */
+ pScreen->CloseScreen = fbCloseScreen;
+#ifdef FB_24_32BIT
+ if (bpp == 24 && imagebpp == 32)
+ {
+ pScreen->ModifyPixmapHeader = fb24_32ModifyPixmapHeader;
+ pScreen->CreateScreenResources = fb24_32CreateScreenResources;
+ }
+#endif
+#if 0
+ /* leave backing store initialization to the enclosing code so
+ * it can choose the correct order of wrappers
+ */
+ /* init backing store here so we can overwrite CloseScreen without stepping
+ * on the backing store wrapped version */
+ fbInitializeBackingStore (pScreen);
+#endif
+ return TRUE;
+}
+
+/* dts * (inch/dot) * (25.4 mm / inch) = mm */
+Bool
+fbScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp)
+{
+ if (!fbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp))
+ return FALSE;
+ if (!fbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy,
+ width, bpp))
+ return FALSE;
+ return TRUE;
+}
+
+
+#ifdef FB_OLD_SCREEN
+const miBSFuncRec fbBSFuncRec = {
+ fbSaveAreas,
+ fbRestoreAreas,
+ (void (*)(GCPtr, RegionPtr)) 0,
+ (PixmapPtr (*)(void)) 0,
+ (PixmapPtr (*)(void)) 0,
+};
+#endif
+
+#if 0
+void
+fbInitializeBackingStore (ScreenPtr pScreen)
+{
+#ifdef FB_OLD_SCREEN
+ miInitializeBackingStore (pScreen, (miBSFuncRec *) &fbBSFuncRec);
+#else
+ miInitializeBackingStore (pScreen);
+#endif
+}
+#endif
diff --git a/nx-X11/programs/Xserver/fb/fbseg.c b/nx-X11/programs/Xserver/fb/fbseg.c
new file mode 100644
index 000000000..18a996e0c
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbseg.c
@@ -0,0 +1,727 @@
+/*
+ * Id: fbseg.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbseg.c,v 1.7 2001/01/17 07:40:02 keithp Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include "miline.h"
+
+#define fbBresShiftMask(mask,dir,bpp) ((bpp == FB_STIP_UNIT) ? 0 : \
+ ((dir < 0) ? FbStipLeft(mask,bpp) : \
+ FbStipRight(mask,bpp)))
+
+void
+fbBresSolid (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ FbStip *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ FbStip and = (FbStip) pPriv->and;
+ FbStip xor = (FbStip) pPriv->xor;
+ FbStip mask, mask0;
+ FbStip bits;
+
+ fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ dst += ((y1 + dstYoff) * dstStride);
+ x1 = (x1 + dstXoff) * dstBpp;
+ dst += x1 >> FB_STIP_SHIFT;
+ x1 &= FB_STIP_MASK;
+ mask0 = FbStipMask(0, dstBpp);
+ mask = FbStipRight (mask0, x1);
+ if (signdx < 0)
+ mask0 = FbStipRight (mask0, FB_STIP_UNIT - dstBpp);
+ if (signdy < 0)
+ dstStride = -dstStride;
+ if (axis == X_AXIS)
+ {
+ bits = 0;
+ while (len--)
+ {
+ bits |= mask;
+ mask = fbBresShiftMask(mask,signdx,dstBpp);
+ if (!mask)
+ {
+ *dst = FbDoMaskRRop (*dst, and, xor, bits);
+ bits = 0;
+ dst += signdx;
+ mask = mask0;
+ }
+ e += e1;
+ if (e >= 0)
+ {
+ *dst = FbDoMaskRRop (*dst, and, xor, bits);
+ bits = 0;
+ dst += dstStride;
+ e += e3;
+ }
+ }
+ if (bits)
+ *dst = FbDoMaskRRop (*dst, and, xor, bits);
+ }
+ else
+ {
+ while (len--)
+ {
+ *dst = FbDoMaskRRop (*dst, and, xor, mask);
+ dst += dstStride;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ mask = fbBresShiftMask(mask,signdx,dstBpp);
+ if (!mask)
+ {
+ dst += signdx;
+ mask = mask0;
+ }
+ }
+ }
+ }
+}
+
+void
+fbBresDash (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ FbStip *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ FbStip and = (FbStip) pPriv->and;
+ FbStip xor = (FbStip) pPriv->xor;
+ FbStip bgand = (FbStip) pPriv->bgand;
+ FbStip bgxor = (FbStip) pPriv->bgxor;
+ FbStip mask, mask0;
+ FbDashDeclare;
+ int dashlen;
+ Bool even;
+ Bool doOdd;
+
+ fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ doOdd = pGC->lineStyle == LineDoubleDash;
+
+ FbDashInit (pGC, pPriv, dashOffset, dashlen, even);
+
+ dst += ((y1 + dstYoff) * dstStride);
+ x1 = (x1 + dstXoff) * dstBpp;
+ dst += x1 >> FB_STIP_SHIFT;
+ x1 &= FB_STIP_MASK;
+ mask0 = FbStipMask(0, dstBpp);
+ mask = FbStipRight (mask0, x1);
+ if (signdx < 0)
+ mask0 = FbStipRight (mask0, FB_STIP_UNIT - dstBpp);
+ if (signdy < 0)
+ dstStride = -dstStride;
+ while (len--)
+ {
+ if (even)
+ *dst = FbDoMaskRRop (*dst, and, xor, mask);
+ else if (doOdd)
+ *dst = FbDoMaskRRop (*dst, bgand, bgxor, mask);
+ if (axis == X_AXIS)
+ {
+ mask = fbBresShiftMask(mask,signdx,dstBpp);
+ if (!mask)
+ {
+ dst += signdx;
+ mask = mask0;
+ }
+ e += e1;
+ if (e >= 0)
+ {
+ dst += dstStride;
+ e += e3;
+ }
+ }
+ else
+ {
+ dst += dstStride;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ mask = fbBresShiftMask(mask,signdx,dstBpp);
+ if (!mask)
+ {
+ dst += signdx;
+ mask = mask0;
+ }
+ }
+ }
+ FbDashStep (dashlen, even);
+ }
+}
+
+void
+fbBresFill (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ while (len--)
+ {
+ fbFill (pDrawable, pGC, x1, y1, 1, 1);
+ if (axis == X_AXIS)
+ {
+ x1 += signdx;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ y1 += signdy;
+ }
+ }
+ else
+ {
+ y1 += signdy;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ x1 += signdx;
+ }
+ }
+ }
+}
+
+static void
+fbSetFg (DrawablePtr pDrawable,
+ GCPtr pGC,
+ Pixel fg)
+{
+ if (fg != pGC->fgPixel)
+ {
+ DoChangeGC (pGC, GCForeground, (XID *) &fg, FALSE);
+ ValidateGC (pDrawable, pGC);
+ }
+}
+
+void
+fbBresFillDash (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ FbDashDeclare;
+ int dashlen;
+ Bool even;
+ Bool doOdd;
+ Bool doBg;
+ Pixel fg, bg;
+
+ fg = pGC->fgPixel;
+ bg = pGC->bgPixel;
+
+ /* whether to fill the odd dashes */
+ doOdd = pGC->lineStyle == LineDoubleDash;
+ /* whether to switch fg to bg when filling odd dashes */
+ doBg = doOdd && (pGC->fillStyle == FillSolid ||
+ pGC->fillStyle == FillStippled);
+
+ /* compute current dash position */
+ FbDashInit (pGC, pPriv, dashOffset, dashlen, even);
+
+ while (len--)
+ {
+ if (even || doOdd)
+ {
+ if (doBg)
+ {
+ if (even)
+ fbSetFg (pDrawable, pGC, fg);
+ else
+ fbSetFg (pDrawable, pGC, bg);
+ }
+ fbFill (pDrawable, pGC, x1, y1, 1, 1);
+ }
+ if (axis == X_AXIS)
+ {
+ x1 += signdx;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ y1 += signdy;
+ }
+ }
+ else
+ {
+ y1 += signdy;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ x1 += signdx;
+ }
+ }
+ FbDashStep (dashlen, even);
+ }
+ if (doBg)
+ fbSetFg (pDrawable, pGC, fg);
+}
+
+#ifdef FB_24BIT
+static void
+fbBresSolid24RRop (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ FbStip *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ FbStip and = pPriv->and;
+ FbStip xor = pPriv->xor;
+ FbStip leftMask, rightMask;
+ int nl;
+ FbStip *d;
+ int x;
+ int rot;
+ FbStip andT, xorT;
+
+ fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ dst += ((y1 + dstYoff) * dstStride);
+ x1 = (x1 + dstXoff) * 24;
+ if (signdy < 0)
+ dstStride = -dstStride;
+ signdx *= 24;
+ while (len--)
+ {
+ d = dst + (x1 >> FB_STIP_SHIFT);
+ x = x1 & FB_STIP_MASK;
+ rot = FbFirst24Rot (x);
+ andT = FbRot24Stip(and,rot);
+ xorT = FbRot24Stip(xor,rot);
+ FbMaskStip (x, 24, leftMask, nl, rightMask);
+ if (leftMask)
+ {
+ *d = FbDoMaskRRop (*d, andT, xorT, leftMask);
+ d++;
+ andT = FbNext24Stip (andT);
+ xorT = FbNext24Stip (xorT);
+ }
+ if (rightMask)
+ *d = FbDoMaskRRop (*d, andT, xorT, rightMask);
+ if (axis == X_AXIS)
+ {
+ x1 += signdx;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ dst += dstStride;
+ }
+ }
+ else
+ {
+ dst += dstStride;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ x1 += signdx;
+ }
+ }
+ }
+}
+
+static void
+fbBresDash24RRop (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ FbStip *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ FbStip andT, xorT;
+ FbStip fgand = pPriv->and;
+ FbStip fgxor = pPriv->xor;
+ FbStip bgand = pPriv->bgand;
+ FbStip bgxor = pPriv->bgxor;
+ FbStip leftMask, rightMask;
+ int nl;
+ FbStip *d;
+ int x;
+ int rot;
+ FbDashDeclare;
+ int dashlen;
+ Bool even;
+ Bool doOdd;
+
+ fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ doOdd = pGC->lineStyle == LineDoubleDash;
+
+ /* compute current dash position */
+ FbDashInit(pGC, pPriv, dashOffset, dashlen, even);
+
+ dst += ((y1 + dstYoff) * dstStride);
+ x1 = (x1 + dstXoff) * 24;
+ if (signdy < 0)
+ dstStride = -dstStride;
+ signdx *= 24;
+ while (len--)
+ {
+ if (even || doOdd)
+ {
+ if (even)
+ {
+ andT = fgand;
+ xorT = fgxor;
+ }
+ else
+ {
+ andT = bgand;
+ xorT = bgxor;
+ }
+ d = dst + (x1 >> FB_STIP_SHIFT);
+ x = x1 & FB_STIP_MASK;
+ rot = FbFirst24Rot (x);
+ andT = FbRot24Stip (andT, rot);
+ xorT = FbRot24Stip (xorT, rot);
+ FbMaskStip (x, 24, leftMask, nl, rightMask);
+ if (leftMask)
+ {
+ *d = FbDoMaskRRop (*d, andT, xorT, leftMask);
+ d++;
+ andT = FbNext24Stip (andT);
+ xorT = FbNext24Stip (xorT);
+ }
+ if (rightMask)
+ *d = FbDoMaskRRop (*d, andT, xorT, rightMask);
+ }
+ if (axis == X_AXIS)
+ {
+ x1 += signdx;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ dst += dstStride;
+ }
+ }
+ else
+ {
+ dst += dstStride;
+ e += e1;
+ if (e >= 0)
+ {
+ e += e3;
+ x1 += signdx;
+ }
+ }
+ FbDashStep (dashlen, even);
+ }
+}
+#endif
+
+/*
+ * For drivers that want to bail drawing some lines, this
+ * function takes care of selecting the appropriate rasterizer
+ * based on the contents of the specified GC.
+ */
+
+FbBres *
+fbSelectBres (DrawablePtr pDrawable,
+ GCPtr pGC)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ int dstBpp = pDrawable->bitsPerPixel;
+ FbBres * bres;
+
+ if (pGC->lineStyle == LineSolid)
+ {
+ bres = fbBresFill;
+ if (pGC->fillStyle == FillSolid)
+ {
+ bres = fbBresSolid;
+#ifdef FB_24BIT
+ if (dstBpp == 24)
+ bres = fbBresSolid24RRop;
+#endif
+#ifndef FBNOPIXADDR
+ if (pPriv->and == 0)
+ {
+ switch (dstBpp) {
+ case 8: bres = fbBresSolid8; break;
+ case 16: bres = fbBresSolid16; break;
+#ifdef FB_24BIT
+ case 24: bres = fbBresSolid24; break;
+#endif
+ case 32: bres = fbBresSolid32; break;
+ }
+ }
+#endif
+ }
+ }
+ else
+ {
+ bres = fbBresFillDash;
+ if (pGC->fillStyle == FillSolid)
+ {
+ bres = fbBresDash;
+#ifdef FB_24BIT
+ if (dstBpp == 24)
+ bres = fbBresDash24RRop;
+#endif
+#ifndef FBNOPIXADDR
+ if (pPriv->and == 0 &&
+ (pGC->lineStyle == LineOnOffDash || pPriv->bgand == 0))
+ {
+ switch (dstBpp) {
+ case 8: bres = fbBresDash8; break;
+ case 16: bres = fbBresDash16; break;
+#ifdef FB_24BIT
+ case 24: bres = fbBresDash24; break;
+#endif
+ case 32: bres = fbBresDash32; break;
+ }
+ }
+#endif
+ }
+ }
+ return bres;
+}
+
+void
+fbBres (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int dashOffset,
+ int signdx,
+ int signdy,
+ int axis,
+ int x1,
+ int y1,
+ int e,
+ int e1,
+ int e3,
+ int len)
+{
+ (*fbSelectBres (pDrawable, pGC)) (pDrawable, pGC, dashOffset,
+ signdx, signdy, axis, x1, y1,
+ e, e1, e3, len);
+}
+
+void
+fbSegment (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x1,
+ int y1,
+ int x2,
+ int y2,
+ Bool drawLast,
+ int *dashOffset)
+{
+ FbBres * bres;
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ BoxPtr pBox;
+ int nBox;
+ int adx; /* abs values of dx and dy */
+ int ady;
+ int signdx; /* sign of dx and dy */
+ int signdy;
+ int e, e1, e2, e3; /* bresenham error and increments */
+ int len; /* length of segment */
+ int axis; /* major axis */
+ int octant;
+ int dashoff;
+ int doff;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ unsigned int oc1; /* outcode of point 1 */
+ unsigned int oc2; /* outcode of point 2 */
+
+ nBox = REGION_NUM_RECTS (pClip);
+ pBox = REGION_RECTS (pClip);
+
+ bres = fbSelectBres (pDrawable, pGC);
+
+ CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy,
+ 1, 1, octant);
+
+ if (adx > ady)
+ {
+ axis = X_AXIS;
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+ len = adx;
+ }
+ else
+ {
+ axis = Y_AXIS;
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ SetYMajorOctant(octant);
+ len = ady;
+ }
+
+ FIXUP_ERROR (e, octant, bias);
+
+ /*
+ * Adjust error terms to compare against zero
+ */
+ e3 = e2 - e1;
+ e = e - e1;
+
+ /* we have bresenham parameters and two points.
+ all we have to do now is clip and draw.
+ */
+
+ if (drawLast)
+ len++;
+ dashoff = *dashOffset;
+ *dashOffset = dashoff + len;
+ while(nBox--)
+ {
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES(oc1, x1, y1, pBox);
+ OUTCODES(oc2, x2, y2, pBox);
+ if ((oc1 | oc2) == 0)
+ {
+ (*bres) (pDrawable, pGC, dashoff,
+ signdx, signdy, axis, x1, y1,
+ e, e1, e3, len);
+ break;
+ }
+ else if (oc1 & oc2)
+ {
+ pBox++;
+ }
+ else
+ {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int clipdx, clipdy;
+ int err;
+
+ if (miZeroClipLine(pBox->x1, pBox->y1, pBox->x2-1,
+ pBox->y2-1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1)
+ {
+ pBox++;
+ continue;
+ }
+
+ if (axis == X_AXIS)
+ len = abs(new_x2 - new_x1);
+ else
+ len = abs(new_y2 - new_y1);
+ if (clip2 != 0 || drawLast)
+ len++;
+ if (len)
+ {
+ /* unwind bresenham error term to first point */
+ doff = dashoff;
+ err = e;
+ if (clip1)
+ {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ if (axis == X_AXIS)
+ {
+ doff += clipdx;
+ err += e3 * clipdy + e1 * clipdx;
+ }
+ else
+ {
+ doff += clipdy;
+ err += e3 * clipdx + e1 * clipdy;
+ }
+ }
+ (*bres) (pDrawable, pGC, doff,
+ signdx, signdy, axis, new_x1, new_y1,
+ err, e1, e3, len);
+ }
+ pBox++;
+ }
+ } /* while (nBox--) */
+}
diff --git a/nx-X11/programs/Xserver/fb/fbsetsp.c b/nx-X11/programs/Xserver/fb/fbsetsp.c
new file mode 100644
index 000000000..eefc2da82
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbsetsp.c
@@ -0,0 +1,104 @@
+/*
+ * Id: fbsetsp.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbsetsp.c,v 1.4 2000/05/06 21:09:34 keithp Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbSetSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *src,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ FbBits *dst, *d, *s;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ BoxPtr pbox;
+ int n;
+ int xoff;
+ int x1, x2;
+
+#ifdef FB_24_32BIT
+ if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
+ {
+ fb24_32SetSpans (pDrawable, pGC, src, ppt, pwidth, nspans, fSorted);
+ return;
+ }
+#endif
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ while (nspans--)
+ {
+ d = dst + (ppt->y + dstYoff) * dstStride;
+ xoff = (int) (((long) src) & (FB_MASK >> 3));
+ s = (FbBits *) (src - xoff);
+ xoff <<= 3;
+ n = REGION_NUM_RECTS(pClip);
+ pbox = REGION_RECTS (pClip);
+ while (n--)
+ {
+ if (pbox->y1 > ppt->y)
+ break;
+ if (pbox->y2 > ppt->y)
+ {
+ x1 = ppt->x;
+ x2 = x1 + *pwidth;
+ if (pbox->x1 > x1)
+ x1 = pbox->x1;
+ if (pbox->x2 < x2)
+ x2 = pbox->x2;
+ if (x1 < x2)
+ fbBlt ((FbBits *) s,
+ 0,
+ (x1 - ppt->x) * dstBpp + xoff,
+ d,
+ dstStride,
+ (x1 + dstXoff) * dstBpp,
+
+ (x2 - x1) * dstBpp,
+ 1,
+ pGC->alu,
+ pPriv->pm,
+ dstBpp,
+
+ FALSE,
+ FALSE);
+ }
+ }
+ src += PixmapBytePad (*pwidth, pDrawable->depth);
+ ppt++;
+ pwidth++;
+ }
+ fbValidateDrawable (pDrawable);
+}
+
diff --git a/nx-X11/programs/Xserver/fb/fbsolid.c b/nx-X11/programs/Xserver/fb/fbsolid.c
new file mode 100644
index 000000000..89effe63b
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbsolid.c
@@ -0,0 +1,215 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define FbSelectPart(xor,o,t) xor
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbSolid (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int bpp,
+
+ int width,
+ int height,
+
+ FbBits and,
+ FbBits xor)
+{
+ FbBits startmask, endmask;
+ int n, nmiddle;
+ int startbyte, endbyte;
+
+#ifdef FB_24BIT
+ if (bpp == 24 && (!FbCheck24Pix(and) || !FbCheck24Pix(xor)))
+ {
+ fbSolid24 (dst, dstStride, dstX, width, height, and, xor);
+ return;
+ }
+#endif
+ dst += dstX >> FB_SHIFT;
+ dstX &= FB_MASK;
+ FbMaskBitsBytes(dstX, width, and == 0, startmask, startbyte,
+ nmiddle, endmask, endbyte);
+ if (startmask)
+ dstStride--;
+ dstStride -= nmiddle;
+ while (height--)
+ {
+ if (startmask)
+ {
+ FbDoLeftMaskByteRRop(dst,startbyte,startmask,and,xor);
+ dst++;
+ }
+ n = nmiddle;
+ if (!and)
+ while (n--)
+ *dst++ = xor;
+ else
+ while (n--)
+ {
+ *dst = FbDoRRop (*dst, and, xor);
+ dst++;
+ }
+ if (endmask)
+ FbDoRightMaskByteRRop(dst,endbyte,endmask,and,xor);
+ dst += dstStride;
+ }
+}
+
+#ifdef FB_24BIT
+void
+fbSolid24 (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits and,
+ FbBits xor)
+{
+ FbBits startmask, endmask;
+ FbBits xor0 = 0, xor1 = 0, xor2 = 0;
+ FbBits and0 = 0, and1 = 0, and2 = 0;
+ FbBits xorS = 0, andS = 0, xorE = 0, andE = 0;
+ int n, nmiddle;
+ int rotS, rot;
+
+ dst += dstX >> FB_SHIFT;
+ dstX &= FB_MASK;
+ /*
+ * Rotate pixel values this far across the word to align on
+ * screen pixel boundaries
+ */
+ rot = FbFirst24Rot (dstX);
+ FbMaskBits (dstX, width, startmask, nmiddle, endmask);
+ if (startmask)
+ dstStride--;
+ dstStride -= nmiddle;
+
+ /*
+ * Precompute rotated versions of the rasterop values
+ */
+ rotS = rot;
+ xor = FbRot24(xor,rotS);
+ and = FbRot24(and,rotS);
+ if (startmask)
+ {
+ xorS = xor;
+ andS = and;
+ xor = FbNext24Pix(xor);
+ and = FbNext24Pix(and);
+ }
+
+ if (nmiddle)
+ {
+ xor0 = xor;
+ and0 = and;
+ xor1 = FbNext24Pix(xor0);
+ and1 = FbNext24Pix(and0);
+ xor2 = FbNext24Pix(xor1);
+ and2 = FbNext24Pix(and1);
+ }
+
+ if (endmask)
+ {
+ switch (nmiddle % 3) {
+ case 0:
+ xorE = xor;
+ andE = and;
+ break;
+ case 1:
+ xorE = xor1;
+ andE = and1;
+ break;
+ case 2:
+ xorE = xor2;
+ andE = and2;
+ break;
+ }
+ }
+
+ while (height--)
+ {
+ if (startmask)
+ {
+ *dst = FbDoMaskRRop(*dst, andS, xorS, startmask);
+ dst++;
+ }
+ n = nmiddle;
+ if (!and0)
+ {
+ while (n >= 3)
+ {
+ *dst++ = xor0;
+ *dst++ = xor1;
+ *dst++ = xor2;
+ n -= 3;
+ }
+ if (n)
+ {
+ *dst++ = xor0;
+ n--;
+ if (n)
+ {
+ *dst++ = xor1;
+ }
+ }
+ }
+ else
+ {
+ while (n >= 3)
+ {
+ *dst = FbDoRRop (*dst, and0, xor0);
+ dst++;
+ *dst = FbDoRRop (*dst, and1, xor1);
+ dst++;
+ *dst = FbDoRRop (*dst, and2, xor2);
+ dst++;
+ n -= 3;
+ }
+ if (n)
+ {
+ *dst = FbDoRRop (*dst, and0, xor0);
+ dst++;
+ n--;
+ if (n)
+ {
+ *dst = FbDoRRop (*dst, and1, xor1);
+ dst++;
+ }
+ }
+ }
+ if (endmask)
+ *dst = FbDoMaskRRop (*dst, andE, xorE, endmask);
+ dst += dstStride;
+ }
+}
+#endif
diff --git a/nx-X11/programs/Xserver/fb/fbstipple.c b/nx-X11/programs/Xserver/fb/fbstipple.c
new file mode 100644
index 000000000..44aa5f331
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbstipple.c
@@ -0,0 +1,316 @@
+/*
+ * Id: fbstipple.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbstipple.c,v 1.6 2000/02/23 20:29:47 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+#ifndef FBNOPIXADDR
+/*
+ * This is a slight abuse of the preprocessor to generate repetitive
+ * code, the idea is to generate code for each case of a copy-mode
+ * transparent stipple
+ */
+#define LaneCases1(c,a) case c: \
+ while (n--) { (void)FbLaneCase(c,a); a++; } \
+ break
+#define LaneCases2(c,a) LaneCases1(c,a); LaneCases1(c+1,a)
+#define LaneCases4(c,a) LaneCases2(c,a); LaneCases2(c+2,a)
+#define LaneCases8(c,a) LaneCases4(c,a); LaneCases4(c+4,a)
+#define LaneCases16(c,a) LaneCases8(c,a); LaneCases8(c+8,a)
+#define LaneCases32(c,a) LaneCases16(c,a); LaneCases16(c+16,a)
+#define LaneCases64(c,a) LaneCases32(c,a); LaneCases32(c+32,a)
+#define LaneCases128(c,a) LaneCases64(c,a); LaneCases64(c+64,a)
+#define LaneCases256(c,a) LaneCases128(c,a); LaneCases128(c+128,a)
+
+#if FB_SHIFT == 6
+#define LaneCases(a) LaneCases256(0,a)
+#endif
+
+#if FB_SHIFT == 5
+#define LaneCases(a) LaneCases16(0,a)
+#endif
+
+/*
+ * Repeat a transparent stipple across a scanline n times
+ */
+
+void
+fbTransparentSpan (FbBits *dst,
+ FbBits stip,
+ FbBits fgxor,
+ int n)
+{
+ FbStip s;
+
+ s = ((FbStip) (stip ) & 0x01);
+ s |= ((FbStip) (stip >> 8) & 0x02);
+ s |= ((FbStip) (stip >> 16) & 0x04);
+ s |= ((FbStip) (stip >> 24) & 0x08);
+#if FB_SHIFT > 5
+ s |= ((FbStip) (stip >> 32) & 0x10);
+ s |= ((FbStip) (stip >> 40) & 0x20);
+ s |= ((FbStip) (stip >> 48) & 0x40);
+ s |= ((FbStip) (stip >> 56) & 0x80);
+#endif
+ switch (s) {
+ LaneCases(dst);
+ }
+}
+#endif
+
+void
+fbEvenStipple (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbStip *stip,
+ FbStride stipStride,
+ int stipHeight,
+
+ FbBits fgand,
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor,
+
+ int xRot,
+ int yRot)
+{
+ FbBits startmask, endmask;
+ FbBits mask, and, xor;
+ int nmiddle, n;
+ FbStip *s, *stipEnd, bits;
+ int rot, stipX, stipY;
+ int pixelsPerDst;
+ const FbBits *fbBits;
+ Bool transparent;
+ int startbyte, endbyte;
+
+ /*
+ * Check for a transparent stipple (stencil)
+ */
+ transparent = FALSE;
+ if (dstBpp >= 8 &&
+ fgand == 0 && bgand == FB_ALLONES && bgxor == 0)
+ transparent = TRUE;
+
+ pixelsPerDst = FB_UNIT / dstBpp;
+ /*
+ * Adjust dest pointers
+ */
+ dst += dstX >> FB_SHIFT;
+ dstX &= FB_MASK;
+ FbMaskBitsBytes (dstX, width, fgand == 0 && bgand == 0,
+ startmask, startbyte, nmiddle, endmask, endbyte);
+
+ if (startmask)
+ dstStride--;
+ dstStride -= nmiddle;
+
+ xRot *= dstBpp;
+ /*
+ * Compute stip start scanline and rotation parameters
+ */
+ stipEnd = stip + stipStride * stipHeight;
+ modulus (- yRot, stipHeight, stipY);
+ s = stip + stipStride * stipY;
+ modulus (- xRot, FB_UNIT, stipX);
+ rot = stipX;
+
+ /*
+ * Get pointer to stipple mask array for this depth
+ */
+ fbBits = 0; /* unused */
+ if (pixelsPerDst <= 8)
+ fbBits = fbStippleTable[pixelsPerDst];
+
+ while (height--)
+ {
+ /*
+ * Extract stipple bits for this scanline;
+ */
+ bits = *s;
+ s += stipStride;
+ if (s == stipEnd)
+ s = stip;
+#if FB_UNIT > 32
+ if (pixelsPerDst == 16)
+ mask = FbStipple16Bits(FbLeftStipBits(bits,16));
+ else
+#endif
+ mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
+ /*
+ * Rotate into position and compute reduced rop values
+ */
+ mask = FbRotLeft(mask, rot);
+ and = (fgand & mask) | (bgand & ~mask);
+ xor = (fgxor & mask) | (bgxor & ~mask);
+
+#ifndef FBNOPIXADDR
+ if (transparent)
+ {
+ if (startmask)
+ {
+ fbTransparentSpan(dst, mask&startmask, fgxor, 1);
+ dst++;
+ }
+ fbTransparentSpan (dst, mask, fgxor, nmiddle);
+ dst += nmiddle;
+ if (endmask)
+ fbTransparentSpan(dst, mask&endmask, fgxor, 1);
+ }
+ else
+#endif
+ {
+ /*
+ * Fill scanline
+ */
+ if (startmask)
+ {
+ FbDoLeftMaskByteRRop (dst, startbyte, startmask, and, xor);
+ dst++;
+ }
+ n = nmiddle;
+ if (!and)
+ while (n--)
+ *dst++ = xor;
+ else
+ {
+ while (n--)
+ {
+ *dst = FbDoRRop (*dst, and, xor);
+ dst++;
+ }
+ }
+ if (endmask)
+ FbDoRightMaskByteRRop(dst, endbyte, endmask, and, xor);
+ }
+ dst += dstStride;
+ }
+}
+
+void
+fbOddStipple (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbStip *stip,
+ FbStride stipStride,
+ int stipWidth,
+ int stipHeight,
+
+ FbBits fgand,
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor,
+
+ int xRot,
+ int yRot)
+{
+ int stipX, stipY, sx;
+ int widthTmp;
+ int h, w;
+ int x, y;
+
+ modulus (- yRot, stipHeight, stipY);
+ modulus (dstX / dstBpp - xRot, stipWidth, stipX);
+ y = 0;
+ while (height)
+ {
+ h = stipHeight - stipY;
+ if (h > height)
+ h = height;
+ height -= h;
+ widthTmp = width;
+ x = dstX;
+ sx = stipX;
+ while (widthTmp)
+ {
+ w = (stipWidth - sx) * dstBpp;
+ if (w > widthTmp)
+ w = widthTmp;
+ widthTmp -= w;
+ fbBltOne (stip + stipY * stipStride,
+ stipStride,
+ sx,
+
+ dst + y * dstStride,
+ dstStride,
+ x,
+ dstBpp,
+
+ w, h,
+
+ fgand, fgxor, bgand, bgxor);
+ x += w;
+ sx = 0;
+ }
+ y += h;
+ stipY = 0;
+ }
+}
+
+void
+fbStipple (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbStip *stip,
+ FbStride stipStride,
+ int stipWidth,
+ int stipHeight,
+ Bool even,
+
+ FbBits fgand,
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor,
+
+ int xRot,
+ int yRot)
+{
+ if (even)
+ fbEvenStipple (dst, dstStride, dstX, dstBpp, width, height,
+ stip, stipStride, stipHeight,
+ fgand, fgxor, bgand, bgxor, xRot, yRot);
+ else
+ fbOddStipple (dst, dstStride, dstX, dstBpp, width, height,
+ stip, stipStride, stipWidth, stipHeight,
+ fgand, fgxor, bgand, bgxor, xRot, yRot);
+}
diff --git a/nx-X11/programs/Xserver/fb/fbtile.c b/nx-X11/programs/Xserver/fb/fbtile.c
new file mode 100644
index 000000000..ef3242241
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbtile.c
@@ -0,0 +1,204 @@
+/*
+ * Id: fbtile.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbtile.c,v 1.3 2000/02/12 03:39:43 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+/*
+ * Accelerated tile fill -- tile width is a power of two not greater
+ * than FB_UNIT
+ */
+
+void
+fbEvenTile (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits *tile,
+ int tileHeight,
+
+ int alu,
+ FbBits pm,
+ int xRot,
+ int yRot)
+{
+ FbBits *t, *tileEnd, bits;
+ FbBits startmask, endmask;
+ FbBits and, xor;
+ int n, nmiddle;
+ int tileX, tileY;
+ int rot;
+ int startbyte, endbyte;
+
+ dst += dstX >> FB_SHIFT;
+ dstX &= FB_MASK;
+ FbMaskBitsBytes(dstX, width, FbDestInvarientRop(alu, pm),
+ startmask, startbyte, nmiddle, endmask, endbyte);
+ if (startmask)
+ dstStride--;
+ dstStride -= nmiddle;
+
+ /*
+ * Compute tile start scanline and rotation parameters
+ */
+ tileEnd = tile + tileHeight;
+ modulus (- yRot, tileHeight, tileY);
+ t = tile + tileY;
+ modulus (- xRot, FB_UNIT, tileX);
+ rot = tileX;
+
+ while (height--)
+ {
+
+ /*
+ * Pick up bits for this scanline
+ */
+ bits = *t++;
+ if (t == tileEnd) t = tile;
+ bits = FbRotLeft(bits,rot);
+ and = fbAnd(alu,bits,pm);
+ xor = fbXor(alu,bits,pm);
+
+ if (startmask)
+ {
+ FbDoLeftMaskByteRRop(dst, startbyte, startmask, and, xor);
+ dst++;
+ }
+ n = nmiddle;
+ if (!and)
+ while (n--)
+ *dst++ = xor;
+ else
+ while (n--)
+ {
+ *dst = FbDoRRop (*dst, and, xor);
+ dst++;
+ }
+ if (endmask)
+ FbDoRightMaskByteRRop(dst, endbyte, endmask, and, xor);
+ dst += dstStride;
+ }
+}
+
+void
+fbOddTile(FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits *tile,
+ FbStride tileStride,
+ int tileWidth,
+ int tileHeight,
+
+ int alu,
+ FbBits pm,
+ int bpp,
+
+ int xRot,
+ int yRot)
+{
+ int tileX, tileY;
+ int widthTmp;
+ int h, w;
+ int x, y;
+
+ modulus (- yRot, tileHeight, tileY);
+ y = 0;
+ while (height)
+ {
+ h = tileHeight - tileY;
+ if (h > height)
+ h = height;
+ height -= h;
+ widthTmp = width;
+ x = dstX;
+ modulus (dstX - xRot, tileWidth, tileX);
+ while (widthTmp)
+ {
+ w = tileWidth - tileX;
+ if (w > widthTmp)
+ w = widthTmp;
+ widthTmp -= w;
+ fbBlt (tile + tileY * tileStride,
+ tileStride,
+ tileX,
+
+ dst + y * dstStride,
+ dstStride,
+ x,
+
+ w, h,
+ alu,
+ pm,
+ bpp,
+
+ FALSE,
+ FALSE);
+ x += w;
+ tileX = 0;
+ }
+ y += h;
+ tileY = 0;
+ }
+}
+
+void
+fbTile (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits *tile,
+ FbStride tileStride,
+ int tileWidth,
+ int tileHeight,
+
+ int alu,
+ FbBits pm,
+ int bpp,
+
+ int xRot,
+ int yRot)
+{
+ if (FbEvenTile (tileWidth))
+ fbEvenTile (dst, dstStride, dstX, width, height,
+ tile, tileHeight,
+ alu, pm, xRot, yRot);
+ else
+ fbOddTile (dst, dstStride, dstX, width, height,
+ tile, tileStride, tileWidth, tileHeight,
+ alu, pm, bpp, xRot, yRot);
+}
diff --git a/nx-X11/programs/Xserver/fb/fbtrap.c b/nx-X11/programs/Xserver/fb/fbtrap.c
new file mode 100644
index 000000000..39483d8cd
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbtrap.c
@@ -0,0 +1,239 @@
+/*
+ * $Id: fbtrap.c,v 1.5 2005/07/03 07:01:23 daniels Exp $
+ *
+ * Copyright © 2004 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+#ifdef RENDER
+
+#include "picturestr.h"
+#include "mipict.h"
+#include "renderedge.h"
+#include "fbpict.h"
+
+void
+fbAddTraps (PicturePtr pPicture,
+ INT16 x_off,
+ INT16 y_off,
+ int ntrap,
+ xTrap *traps)
+{
+ FbBits *buf;
+ int bpp;
+ int width;
+ int stride;
+ int height;
+ int pxoff, pyoff;
+
+ xFixed x_off_fixed;
+ xFixed y_off_fixed;
+ RenderEdge l, r;
+ xFixed t, b;
+
+ fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff);
+
+ width = pPicture->pDrawable->width;
+ height = pPicture->pDrawable->height;
+ x_off += pxoff;
+ y_off += pyoff;
+
+ x_off_fixed = IntToxFixed(y_off);
+ y_off_fixed = IntToxFixed(y_off);
+
+ while (ntrap--)
+ {
+ t = traps->top.y + y_off_fixed;
+ if (t < 0)
+ t = 0;
+ t = RenderSampleCeilY (t, bpp);
+
+ b = traps->bot.y + y_off_fixed;
+ if (xFixedToInt (b) >= height)
+ b = IntToxFixed (height) - 1;
+ b = RenderSampleFloorY (b, bpp);
+
+ if (b >= t)
+ {
+ /* initialize edge walkers */
+ RenderEdgeInit (&l, bpp, t,
+ traps->top.l + x_off_fixed,
+ traps->top.y + y_off_fixed,
+ traps->bot.l + x_off_fixed,
+ traps->bot.y + y_off_fixed);
+
+ RenderEdgeInit (&r, bpp, t,
+ traps->top.r + x_off_fixed,
+ traps->top.y + y_off_fixed,
+ traps->bot.r + x_off_fixed,
+ traps->bot.y + y_off_fixed);
+
+ fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b);
+ }
+ traps++;
+ }
+}
+
+void
+fbRasterizeTrapezoid (PicturePtr pPicture,
+ xTrapezoid *trap,
+ int x_off,
+ int y_off)
+{
+ FbBits *buf;
+ int bpp;
+ int width;
+ int stride;
+ int height;
+ int pxoff, pyoff;
+
+ xFixed x_off_fixed;
+ xFixed y_off_fixed;
+ RenderEdge l, r;
+ xFixed t, b;
+
+ fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff);
+
+ width = pPicture->pDrawable->width;
+ height = pPicture->pDrawable->height;
+ x_off += pxoff;
+ y_off += pyoff;
+
+ x_off_fixed = IntToxFixed(x_off);
+ y_off_fixed = IntToxFixed(y_off);
+ t = trap->top + y_off_fixed;
+ if (t < 0)
+ t = 0;
+ t = RenderSampleCeilY (t, bpp);
+
+ b = trap->bottom + y_off_fixed;
+ if (xFixedToInt (b) >= height)
+ b = IntToxFixed (height) - 1;
+ b = RenderSampleFloorY (b, bpp);
+
+ if (b >= t)
+ {
+ /* initialize edge walkers */
+ RenderLineFixedEdgeInit (&l, bpp, t, &trap->left, x_off, y_off);
+ RenderLineFixedEdgeInit (&r, bpp, t, &trap->right, x_off, y_off);
+
+ fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b);
+ }
+}
+
+static int
+_GreaterY (xPointFixed *a, xPointFixed *b)
+{
+ if (a->y == b->y)
+ return a->x > b->x;
+ return a->y > b->y;
+}
+
+/*
+ * Note that the definition of this function is a bit odd because
+ * of the X coordinate space (y increasing downwards).
+ */
+static int
+_Clockwise (xPointFixed *ref, xPointFixed *a, xPointFixed *b)
+{
+ xPointFixed ad, bd;
+
+ ad.x = a->x - ref->x;
+ ad.y = a->y - ref->y;
+ bd.x = b->x - ref->x;
+ bd.y = b->y - ref->y;
+
+ return ((xFixed_32_32) bd.y * ad.x - (xFixed_32_32) ad.y * bd.x) < 0;
+}
+
+/* FIXME -- this could be made more efficient */
+void
+fbAddTriangles (PicturePtr pPicture,
+ INT16 x_off,
+ INT16 y_off,
+ int ntri,
+ xTriangle *tris)
+{
+ xPointFixed *top, *left, *right, *tmp;
+ xTrapezoid trap;
+
+ for (; ntri; ntri--, tris++)
+ {
+ top = &tris->p1;
+ left = &tris->p2;
+ right = &tris->p3;
+ if (_GreaterY (top, left)) {
+ tmp = left; left = top; top = tmp;
+ }
+ if (_GreaterY (top, right)) {
+ tmp = right; right = top; top = tmp;
+ }
+ if (_Clockwise (top, right, left)) {
+ tmp = right; right = left; left = tmp;
+ }
+
+ /*
+ * Two cases:
+ *
+ * + +
+ * / \ / \
+ * / \ / \
+ * / + + \
+ * / -- -- \
+ * / -- -- \
+ * / --- --- \
+ * +-- --+
+ */
+
+ trap.top = top->y;
+ trap.left.p1 = *top;
+ trap.left.p2 = *left;
+ trap.right.p1 = *top;
+ trap.right.p2 = *right;
+ if (right->y < left->y)
+ trap.bottom = right->y;
+ else
+ trap.bottom = left->y;
+ fbRasterizeTrapezoid (pPicture, &trap, x_off, y_off);
+ if (right->y < left->y)
+ {
+ trap.top = right->y;
+ trap.bottom = left->y;
+ trap.right.p1 = *right;
+ trap.right.p2 = *left;
+ }
+ else
+ {
+ trap.top = left->y;
+ trap.bottom = right->y;
+ trap.left.p1 = *left;
+ trap.left.p2 = *right;
+ }
+ fbRasterizeTrapezoid (pPicture, &trap, x_off, y_off);
+ }
+}
+
+#endif /* RENDER */
diff --git a/nx-X11/programs/Xserver/fb/fbutil.c b/nx-X11/programs/Xserver/fb/fbutil.c
new file mode 100644
index 000000000..8153ab364
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbutil.c
@@ -0,0 +1,365 @@
+/*
+ * Id: fbutil.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbutil.c,v 1.4 2000/02/23 20:29:48 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+FbBits
+fbReplicatePixel (Pixel p, int bpp)
+{
+ FbBits b = p;
+
+ b &= FbFullMask (bpp);
+ while (bpp < FB_UNIT)
+ {
+ b |= b << bpp;
+ bpp <<= 1;
+ }
+ return b;
+}
+
+void
+fbReduceRasterOp (int rop, FbBits fg, FbBits pm, FbBits *andp, FbBits *xorp)
+{
+ FbBits and, xor;
+
+ switch (rop)
+ {
+ default:
+ case GXclear: /* 0 0 0 0 */
+ and = 0;
+ xor = 0;
+ break;
+ case GXand: /* 0 0 0 1 */
+ and = fg;
+ xor = 0;
+ break;
+ case GXandReverse: /* 0 0 1 0 */
+ and = fg;
+ xor = fg;
+ break;
+ case GXcopy: /* 0 0 1 1 */
+ and = 0;
+ xor = fg;
+ break;
+ case GXandInverted: /* 0 1 0 0 */
+ and = ~fg;
+ xor = 0;
+ break;
+ case GXnoop: /* 0 1 0 1 */
+ and = FB_ALLONES;
+ xor = 0;
+ break;
+ case GXxor: /* 0 1 1 0 */
+ and = FB_ALLONES;
+ xor = fg;
+ break;
+ case GXor: /* 0 1 1 1 */
+ and = ~fg;
+ xor = fg;
+ break;
+ case GXnor: /* 1 0 0 0 */
+ and = ~fg;
+ xor = ~fg;
+ break;
+ case GXequiv: /* 1 0 0 1 */
+ and = FB_ALLONES;
+ xor = ~fg;
+ break;
+ case GXinvert: /* 1 0 1 0 */
+ and = FB_ALLONES;
+ xor = FB_ALLONES;
+ break;
+ case GXorReverse: /* 1 0 1 1 */
+ and = ~fg;
+ xor = FB_ALLONES;
+ break;
+ case GXcopyInverted: /* 1 1 0 0 */
+ and = 0;
+ xor = ~fg;
+ break;
+ case GXorInverted: /* 1 1 0 1 */
+ and = fg;
+ xor = ~fg;
+ break;
+ case GXnand: /* 1 1 1 0 */
+ and = fg;
+ xor = FB_ALLONES;
+ break;
+ case GXset: /* 1 1 1 1 */
+ and = 0;
+ xor = FB_ALLONES;
+ break;
+ }
+ and |= ~pm;
+ xor &= pm;
+ *andp = and;
+ *xorp = xor;
+}
+
+#define O 0
+#define I FB_ALLONES
+
+const FbMergeRopRec FbMergeRopBits[16] = {
+ { O,O,O,O }, /* clear 0x0 0 */
+ { I,O,O,O }, /* and 0x1 src AND dst */
+ { I,O,I,O }, /* andReverse 0x2 src AND NOT dst */
+ { O,O,I,O }, /* copy 0x3 src */
+ { I,I,O,O }, /* andInverted 0x4 NOT src AND dst */
+ { O,I,O,O }, /* noop 0x5 dst */
+ { O,I,I,O }, /* xor 0x6 src XOR dst */
+ { I,I,I,O }, /* or 0x7 src OR dst */
+ { I,I,I,I }, /* nor 0x8 NOT src AND NOT dst */
+ { O,I,I,I }, /* equiv 0x9 NOT src XOR dst */
+ { O,I,O,I }, /* invert 0xa NOT dst */
+ { I,I,O,I }, /* orReverse 0xb src OR NOT dst */
+ { O,O,I,I }, /* copyInverted 0xc NOT src */
+ { I,O,I,I }, /* orInverted 0xd NOT src OR dst */
+ { I,O,O,I }, /* nand 0xe NOT src OR NOT dst */
+ { O,O,O,I }, /* set 0xf 1 */
+};
+
+/*
+ * Stipple masks are independent of bit/byte order as long
+ * as bitorder == byteorder. FB doesn't handle the case
+ * where these differ
+ */
+#define BitsMask(x,w) ((FB_ALLONES << ((x) & FB_MASK)) & \
+ (FB_ALLONES >> ((FB_UNIT - ((x) + (w))) & FB_MASK)))
+
+#define Mask(x,w) BitsMask((x)*(w),(w))
+
+
+#define SelMask(b,n,w) ((((b) >> n) & 1) * Mask(n,w))
+
+#define C1(b,w) \
+ (SelMask(b,0,w))
+
+#define C2(b,w) \
+ (SelMask(b,0,w) | \
+ SelMask(b,1,w))
+
+#define C4(b,w) \
+ (SelMask(b,0,w) | \
+ SelMask(b,1,w) | \
+ SelMask(b,2,w) | \
+ SelMask(b,3,w))
+
+#define C8(b,w) \
+ (SelMask(b,0,w) | \
+ SelMask(b,1,w) | \
+ SelMask(b,2,w) | \
+ SelMask(b,3,w) | \
+ SelMask(b,4,w) | \
+ SelMask(b,5,w) | \
+ SelMask(b,6,w) | \
+ SelMask(b,7,w))
+
+#if FB_UNIT == 16
+#define fbStipple16Bits 0
+#define fbStipple8Bits 0
+const FbBits fbStipple4Bits[16] = {
+ C4( 0,4), C4( 1,4), C4( 2,4), C4( 3,4), C4( 4,4), C4( 5,4),
+ C4( 6,4), C4( 7,4), C4( 8,4), C4( 9,4), C4( 10,4), C4( 11,4),
+ C4( 12,4), C4( 13,4), C4( 14,4), C4( 15,4),};
+const FbBits fbStipple2Bits[4] = {
+ C2( 0,8), C2( 1,8), C2( 2,8), C2( 3,8),
+};
+const FbBits fbStipple1Bits[2] = {
+ C1( 0,16), C1( 1,16),
+};
+#endif
+#if FB_UNIT == 32
+#define fbStipple16Bits 0
+const FbBits fbStipple8Bits[256] = {
+ C8( 0,4), C8( 1,4), C8( 2,4), C8( 3,4), C8( 4,4), C8( 5,4),
+ C8( 6,4), C8( 7,4), C8( 8,4), C8( 9,4), C8( 10,4), C8( 11,4),
+ C8( 12,4), C8( 13,4), C8( 14,4), C8( 15,4), C8( 16,4), C8( 17,4),
+ C8( 18,4), C8( 19,4), C8( 20,4), C8( 21,4), C8( 22,4), C8( 23,4),
+ C8( 24,4), C8( 25,4), C8( 26,4), C8( 27,4), C8( 28,4), C8( 29,4),
+ C8( 30,4), C8( 31,4), C8( 32,4), C8( 33,4), C8( 34,4), C8( 35,4),
+ C8( 36,4), C8( 37,4), C8( 38,4), C8( 39,4), C8( 40,4), C8( 41,4),
+ C8( 42,4), C8( 43,4), C8( 44,4), C8( 45,4), C8( 46,4), C8( 47,4),
+ C8( 48,4), C8( 49,4), C8( 50,4), C8( 51,4), C8( 52,4), C8( 53,4),
+ C8( 54,4), C8( 55,4), C8( 56,4), C8( 57,4), C8( 58,4), C8( 59,4),
+ C8( 60,4), C8( 61,4), C8( 62,4), C8( 63,4), C8( 64,4), C8( 65,4),
+ C8( 66,4), C8( 67,4), C8( 68,4), C8( 69,4), C8( 70,4), C8( 71,4),
+ C8( 72,4), C8( 73,4), C8( 74,4), C8( 75,4), C8( 76,4), C8( 77,4),
+ C8( 78,4), C8( 79,4), C8( 80,4), C8( 81,4), C8( 82,4), C8( 83,4),
+ C8( 84,4), C8( 85,4), C8( 86,4), C8( 87,4), C8( 88,4), C8( 89,4),
+ C8( 90,4), C8( 91,4), C8( 92,4), C8( 93,4), C8( 94,4), C8( 95,4),
+ C8( 96,4), C8( 97,4), C8( 98,4), C8( 99,4), C8(100,4), C8(101,4),
+ C8(102,4), C8(103,4), C8(104,4), C8(105,4), C8(106,4), C8(107,4),
+ C8(108,4), C8(109,4), C8(110,4), C8(111,4), C8(112,4), C8(113,4),
+ C8(114,4), C8(115,4), C8(116,4), C8(117,4), C8(118,4), C8(119,4),
+ C8(120,4), C8(121,4), C8(122,4), C8(123,4), C8(124,4), C8(125,4),
+ C8(126,4), C8(127,4), C8(128,4), C8(129,4), C8(130,4), C8(131,4),
+ C8(132,4), C8(133,4), C8(134,4), C8(135,4), C8(136,4), C8(137,4),
+ C8(138,4), C8(139,4), C8(140,4), C8(141,4), C8(142,4), C8(143,4),
+ C8(144,4), C8(145,4), C8(146,4), C8(147,4), C8(148,4), C8(149,4),
+ C8(150,4), C8(151,4), C8(152,4), C8(153,4), C8(154,4), C8(155,4),
+ C8(156,4), C8(157,4), C8(158,4), C8(159,4), C8(160,4), C8(161,4),
+ C8(162,4), C8(163,4), C8(164,4), C8(165,4), C8(166,4), C8(167,4),
+ C8(168,4), C8(169,4), C8(170,4), C8(171,4), C8(172,4), C8(173,4),
+ C8(174,4), C8(175,4), C8(176,4), C8(177,4), C8(178,4), C8(179,4),
+ C8(180,4), C8(181,4), C8(182,4), C8(183,4), C8(184,4), C8(185,4),
+ C8(186,4), C8(187,4), C8(188,4), C8(189,4), C8(190,4), C8(191,4),
+ C8(192,4), C8(193,4), C8(194,4), C8(195,4), C8(196,4), C8(197,4),
+ C8(198,4), C8(199,4), C8(200,4), C8(201,4), C8(202,4), C8(203,4),
+ C8(204,4), C8(205,4), C8(206,4), C8(207,4), C8(208,4), C8(209,4),
+ C8(210,4), C8(211,4), C8(212,4), C8(213,4), C8(214,4), C8(215,4),
+ C8(216,4), C8(217,4), C8(218,4), C8(219,4), C8(220,4), C8(221,4),
+ C8(222,4), C8(223,4), C8(224,4), C8(225,4), C8(226,4), C8(227,4),
+ C8(228,4), C8(229,4), C8(230,4), C8(231,4), C8(232,4), C8(233,4),
+ C8(234,4), C8(235,4), C8(236,4), C8(237,4), C8(238,4), C8(239,4),
+ C8(240,4), C8(241,4), C8(242,4), C8(243,4), C8(244,4), C8(245,4),
+ C8(246,4), C8(247,4), C8(248,4), C8(249,4), C8(250,4), C8(251,4),
+ C8(252,4), C8(253,4), C8(254,4), C8(255,4),
+};
+const FbBits fbStipple4Bits[16] = {
+ C4( 0,8), C4( 1,8), C4( 2,8), C4( 3,8), C4( 4,8), C4( 5,8),
+ C4( 6,8), C4( 7,8), C4( 8,8), C4( 9,8), C4( 10,8), C4( 11,8),
+ C4( 12,8), C4( 13,8), C4( 14,8), C4( 15,8),};
+const FbBits fbStipple2Bits[4] = {
+ C2( 0,16), C2( 1,16), C2( 2,16), C2( 3,16),
+};
+const FbBits fbStipple1Bits[2] = {
+ C1( 0,32), C1( 1,32),
+};
+#endif
+#if FB_UNIT == 64
+const FbBits fbStipple16Bits[256] = {
+ C8( 0,4), C8( 1,4), C8( 2,4), C8( 3,4), C8( 4,4), C8( 5,4),
+ C8( 6,4), C8( 7,4), C8( 8,4), C8( 9,4), C8( 10,4), C8( 11,4),
+ C8( 12,4), C8( 13,4), C8( 14,4), C8( 15,4), C8( 16,4), C8( 17,4),
+ C8( 18,4), C8( 19,4), C8( 20,4), C8( 21,4), C8( 22,4), C8( 23,4),
+ C8( 24,4), C8( 25,4), C8( 26,4), C8( 27,4), C8( 28,4), C8( 29,4),
+ C8( 30,4), C8( 31,4), C8( 32,4), C8( 33,4), C8( 34,4), C8( 35,4),
+ C8( 36,4), C8( 37,4), C8( 38,4), C8( 39,4), C8( 40,4), C8( 41,4),
+ C8( 42,4), C8( 43,4), C8( 44,4), C8( 45,4), C8( 46,4), C8( 47,4),
+ C8( 48,4), C8( 49,4), C8( 50,4), C8( 51,4), C8( 52,4), C8( 53,4),
+ C8( 54,4), C8( 55,4), C8( 56,4), C8( 57,4), C8( 58,4), C8( 59,4),
+ C8( 60,4), C8( 61,4), C8( 62,4), C8( 63,4), C8( 64,4), C8( 65,4),
+ C8( 66,4), C8( 67,4), C8( 68,4), C8( 69,4), C8( 70,4), C8( 71,4),
+ C8( 72,4), C8( 73,4), C8( 74,4), C8( 75,4), C8( 76,4), C8( 77,4),
+ C8( 78,4), C8( 79,4), C8( 80,4), C8( 81,4), C8( 82,4), C8( 83,4),
+ C8( 84,4), C8( 85,4), C8( 86,4), C8( 87,4), C8( 88,4), C8( 89,4),
+ C8( 90,4), C8( 91,4), C8( 92,4), C8( 93,4), C8( 94,4), C8( 95,4),
+ C8( 96,4), C8( 97,4), C8( 98,4), C8( 99,4), C8(100,4), C8(101,4),
+ C8(102,4), C8(103,4), C8(104,4), C8(105,4), C8(106,4), C8(107,4),
+ C8(108,4), C8(109,4), C8(110,4), C8(111,4), C8(112,4), C8(113,4),
+ C8(114,4), C8(115,4), C8(116,4), C8(117,4), C8(118,4), C8(119,4),
+ C8(120,4), C8(121,4), C8(122,4), C8(123,4), C8(124,4), C8(125,4),
+ C8(126,4), C8(127,4), C8(128,4), C8(129,4), C8(130,4), C8(131,4),
+ C8(132,4), C8(133,4), C8(134,4), C8(135,4), C8(136,4), C8(137,4),
+ C8(138,4), C8(139,4), C8(140,4), C8(141,4), C8(142,4), C8(143,4),
+ C8(144,4), C8(145,4), C8(146,4), C8(147,4), C8(148,4), C8(149,4),
+ C8(150,4), C8(151,4), C8(152,4), C8(153,4), C8(154,4), C8(155,4),
+ C8(156,4), C8(157,4), C8(158,4), C8(159,4), C8(160,4), C8(161,4),
+ C8(162,4), C8(163,4), C8(164,4), C8(165,4), C8(166,4), C8(167,4),
+ C8(168,4), C8(169,4), C8(170,4), C8(171,4), C8(172,4), C8(173,4),
+ C8(174,4), C8(175,4), C8(176,4), C8(177,4), C8(178,4), C8(179,4),
+ C8(180,4), C8(181,4), C8(182,4), C8(183,4), C8(184,4), C8(185,4),
+ C8(186,4), C8(187,4), C8(188,4), C8(189,4), C8(190,4), C8(191,4),
+ C8(192,4), C8(193,4), C8(194,4), C8(195,4), C8(196,4), C8(197,4),
+ C8(198,4), C8(199,4), C8(200,4), C8(201,4), C8(202,4), C8(203,4),
+ C8(204,4), C8(205,4), C8(206,4), C8(207,4), C8(208,4), C8(209,4),
+ C8(210,4), C8(211,4), C8(212,4), C8(213,4), C8(214,4), C8(215,4),
+ C8(216,4), C8(217,4), C8(218,4), C8(219,4), C8(220,4), C8(221,4),
+ C8(222,4), C8(223,4), C8(224,4), C8(225,4), C8(226,4), C8(227,4),
+ C8(228,4), C8(229,4), C8(230,4), C8(231,4), C8(232,4), C8(233,4),
+ C8(234,4), C8(235,4), C8(236,4), C8(237,4), C8(238,4), C8(239,4),
+ C8(240,4), C8(241,4), C8(242,4), C8(243,4), C8(244,4), C8(245,4),
+ C8(246,4), C8(247,4), C8(248,4), C8(249,4), C8(250,4), C8(251,4),
+ C8(252,4), C8(253,4), C8(254,4), C8(255,4),
+};
+const FbBits fbStipple8Bits[256] = {
+ C8( 0,8), C8( 1,8), C8( 2,8), C8( 3,8), C8( 4,8), C8( 5,8),
+ C8( 6,8), C8( 7,8), C8( 8,8), C8( 9,8), C8( 10,8), C8( 11,8),
+ C8( 12,8), C8( 13,8), C8( 14,8), C8( 15,8), C8( 16,8), C8( 17,8),
+ C8( 18,8), C8( 19,8), C8( 20,8), C8( 21,8), C8( 22,8), C8( 23,8),
+ C8( 24,8), C8( 25,8), C8( 26,8), C8( 27,8), C8( 28,8), C8( 29,8),
+ C8( 30,8), C8( 31,8), C8( 32,8), C8( 33,8), C8( 34,8), C8( 35,8),
+ C8( 36,8), C8( 37,8), C8( 38,8), C8( 39,8), C8( 40,8), C8( 41,8),
+ C8( 42,8), C8( 43,8), C8( 44,8), C8( 45,8), C8( 46,8), C8( 47,8),
+ C8( 48,8), C8( 49,8), C8( 50,8), C8( 51,8), C8( 52,8), C8( 53,8),
+ C8( 54,8), C8( 55,8), C8( 56,8), C8( 57,8), C8( 58,8), C8( 59,8),
+ C8( 60,8), C8( 61,8), C8( 62,8), C8( 63,8), C8( 64,8), C8( 65,8),
+ C8( 66,8), C8( 67,8), C8( 68,8), C8( 69,8), C8( 70,8), C8( 71,8),
+ C8( 72,8), C8( 73,8), C8( 74,8), C8( 75,8), C8( 76,8), C8( 77,8),
+ C8( 78,8), C8( 79,8), C8( 80,8), C8( 81,8), C8( 82,8), C8( 83,8),
+ C8( 84,8), C8( 85,8), C8( 86,8), C8( 87,8), C8( 88,8), C8( 89,8),
+ C8( 90,8), C8( 91,8), C8( 92,8), C8( 93,8), C8( 94,8), C8( 95,8),
+ C8( 96,8), C8( 97,8), C8( 98,8), C8( 99,8), C8(100,8), C8(101,8),
+ C8(102,8), C8(103,8), C8(104,8), C8(105,8), C8(106,8), C8(107,8),
+ C8(108,8), C8(109,8), C8(110,8), C8(111,8), C8(112,8), C8(113,8),
+ C8(114,8), C8(115,8), C8(116,8), C8(117,8), C8(118,8), C8(119,8),
+ C8(120,8), C8(121,8), C8(122,8), C8(123,8), C8(124,8), C8(125,8),
+ C8(126,8), C8(127,8), C8(128,8), C8(129,8), C8(130,8), C8(131,8),
+ C8(132,8), C8(133,8), C8(134,8), C8(135,8), C8(136,8), C8(137,8),
+ C8(138,8), C8(139,8), C8(140,8), C8(141,8), C8(142,8), C8(143,8),
+ C8(144,8), C8(145,8), C8(146,8), C8(147,8), C8(148,8), C8(149,8),
+ C8(150,8), C8(151,8), C8(152,8), C8(153,8), C8(154,8), C8(155,8),
+ C8(156,8), C8(157,8), C8(158,8), C8(159,8), C8(160,8), C8(161,8),
+ C8(162,8), C8(163,8), C8(164,8), C8(165,8), C8(166,8), C8(167,8),
+ C8(168,8), C8(169,8), C8(170,8), C8(171,8), C8(172,8), C8(173,8),
+ C8(174,8), C8(175,8), C8(176,8), C8(177,8), C8(178,8), C8(179,8),
+ C8(180,8), C8(181,8), C8(182,8), C8(183,8), C8(184,8), C8(185,8),
+ C8(186,8), C8(187,8), C8(188,8), C8(189,8), C8(190,8), C8(191,8),
+ C8(192,8), C8(193,8), C8(194,8), C8(195,8), C8(196,8), C8(197,8),
+ C8(198,8), C8(199,8), C8(200,8), C8(201,8), C8(202,8), C8(203,8),
+ C8(204,8), C8(205,8), C8(206,8), C8(207,8), C8(208,8), C8(209,8),
+ C8(210,8), C8(211,8), C8(212,8), C8(213,8), C8(214,8), C8(215,8),
+ C8(216,8), C8(217,8), C8(218,8), C8(219,8), C8(220,8), C8(221,8),
+ C8(222,8), C8(223,8), C8(224,8), C8(225,8), C8(226,8), C8(227,8),
+ C8(228,8), C8(229,8), C8(230,8), C8(231,8), C8(232,8), C8(233,8),
+ C8(234,8), C8(235,8), C8(236,8), C8(237,8), C8(238,8), C8(239,8),
+ C8(240,8), C8(241,8), C8(242,8), C8(243,8), C8(244,8), C8(245,8),
+ C8(246,8), C8(247,8), C8(248,8), C8(249,8), C8(250,8), C8(251,8),
+ C8(252,8), C8(253,8), C8(254,8), C8(255,8),
+};
+const FbBits fbStipple4Bits[16] = {
+ C4( 0,16), C4( 1,16), C4( 2,16), C4( 3,16), C4( 4,16), C4( 5,16),
+ C4( 6,16), C4( 7,16), C4( 8,16), C4( 9,16), C4( 10,16), C4( 11,16),
+ C4( 12,16), C4( 13,16), C4( 14,16), C4( 15,16),};
+const FbBits fbStipple2Bits[4] = {
+ C2( 0,32), C2( 1,32), C2( 2,32), C2( 3,32),
+};
+#define fbStipple1Bits 0
+#endif
+const FbBits * const fbStippleTable[] = {
+ 0,
+ fbStipple1Bits,
+ fbStipple2Bits,
+ 0,
+ fbStipple4Bits,
+ 0,
+ 0,
+ 0,
+ fbStipple8Bits,
+};
diff --git a/nx-X11/programs/Xserver/fb/fbwindow.c b/nx-X11/programs/Xserver/fb/fbwindow.c
new file mode 100644
index 000000000..0cfefa929
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/fbwindow.c
@@ -0,0 +1,352 @@
+/* $XdotOrg: xc/programs/Xserver/fb/fbwindow.c,v 1.9 2005/10/02 08:28:26 anholt Exp $ */
+/*
+ * Id: fbwindow.c,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ *
+ * Copyright © 1998 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbwindow.c,v 1.10tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#ifdef IN_MODULE
+#include "xf86_ansic.h"
+#endif
+
+Bool
+fbCreateWindow(WindowPtr pWin)
+{
+#ifndef FB_NO_WINDOW_PIXMAPS
+ pWin->devPrivates[fbWinPrivateIndex].ptr =
+ (pointer) fbGetScreenPixmap(pWin->drawable.pScreen);
+#endif
+#ifdef FB_SCREEN_PRIVATE
+ if (pWin->drawable.bitsPerPixel == 32)
+ pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp;
+#endif
+ return TRUE;
+}
+
+Bool
+fbDestroyWindow(WindowPtr pWin)
+{
+ return TRUE;
+}
+
+Bool
+fbMapWindow(WindowPtr pWindow)
+{
+ return TRUE;
+}
+
+Bool
+fbPositionWindow(WindowPtr pWin, int x, int y)
+{
+ return TRUE;
+}
+
+Bool
+fbUnmapWindow(WindowPtr pWindow)
+{
+ return TRUE;
+}
+
+void
+fbCopyWindowProc (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ FbBits *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+
+ fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+ fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ while (nbox--)
+ {
+ fbBlt (src + (pbox->y1 + dy + srcYoff) * srcStride,
+ srcStride,
+ (pbox->x1 + dx + srcXoff) * srcBpp,
+
+ dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+
+ (pbox->x2 - pbox->x1) * dstBpp,
+ (pbox->y2 - pbox->y1),
+
+ GXcopy,
+ FB_ALLONES,
+ dstBpp,
+
+ reverse,
+ upsidedown);
+ pbox++;
+ }
+}
+
+void
+fbCopyWindow(WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc)
+{
+ RegionRec rgnDst;
+ int dx, dy;
+
+ PixmapPtr pPixmap = fbGetWindowPixmap (pWin);
+ DrawablePtr pDrawable = &pPixmap->drawable;
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+
+ REGION_NULL (pWin->drawable.pScreen, &rgnDst);
+
+ REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+
+#ifdef COMPOSITE
+ if (pPixmap->screen_x || pPixmap->screen_y)
+ REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst,
+ -pPixmap->screen_x, -pPixmap->screen_y);
+#endif
+
+ fbCopyRegion (pDrawable, pDrawable,
+ 0,
+ &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
+
+ REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+ fbValidateDrawable (&pWin->drawable);
+}
+
+Bool
+fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
+{
+ PixmapPtr pPixmap;
+
+ if (mask & CWBackPixmap)
+ {
+ if (pWin->backgroundState == BackgroundPixmap)
+ {
+ pPixmap = pWin->background.pixmap;
+#ifdef FB_24_32BIT
+ if (pPixmap->drawable.bitsPerPixel != pWin->drawable.bitsPerPixel)
+ {
+ pPixmap = fb24_32ReformatTile (pPixmap,
+ pWin->drawable.bitsPerPixel);
+ if (pPixmap)
+ {
+ (*pWin->drawable.pScreen->DestroyPixmap) (pWin->background.pixmap);
+ pWin->background.pixmap = pPixmap;
+ }
+ }
+#endif
+ if (FbEvenTile (pPixmap->drawable.width *
+ pPixmap->drawable.bitsPerPixel))
+ fbPadPixmap (pPixmap);
+ }
+ }
+ if (mask & CWBorderPixmap)
+ {
+ if (pWin->borderIsPixel == FALSE)
+ {
+ pPixmap = pWin->border.pixmap;
+#ifdef FB_24_32BIT
+ if (pPixmap->drawable.bitsPerPixel !=
+ pWin->drawable.bitsPerPixel)
+ {
+ pPixmap = fb24_32ReformatTile (pPixmap,
+ pWin->drawable.bitsPerPixel);
+ if (pPixmap)
+ {
+ (*pWin->drawable.pScreen->DestroyPixmap) (pWin->border.pixmap);
+ pWin->border.pixmap = pPixmap;
+ }
+ }
+#endif
+ if (FbEvenTile (pPixmap->drawable.width *
+ pPixmap->drawable.bitsPerPixel))
+ fbPadPixmap (pPixmap);
+ }
+ }
+ return TRUE;
+}
+
+void
+fbFillRegionSolid (DrawablePtr pDrawable,
+ RegionPtr pRegion,
+ FbBits and,
+ FbBits xor)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ int n = REGION_NUM_RECTS(pRegion);
+ BoxPtr pbox = REGION_RECTS(pRegion);
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ while (n--)
+ {
+ fbSolid (dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+ dstBpp,
+ (pbox->x2 - pbox->x1) * dstBpp,
+ pbox->y2 - pbox->y1,
+ and, xor);
+ fbValidateDrawable (pDrawable);
+ pbox++;
+ }
+}
+
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+
+void
+fbFillRegionTiled (DrawablePtr pDrawable,
+ RegionPtr pRegion,
+ PixmapPtr pTile)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbBits *tile;
+ FbStride tileStride;
+ int tileBpp;
+ int tileXoff, tileYoff; /* XXX assumed to be zero */
+ int tileWidth, tileHeight;
+ int n = REGION_NUM_RECTS(pRegion);
+ BoxPtr pbox = REGION_RECTS(pRegion);
+ int xRot = pDrawable->x;
+ int yRot = pDrawable->y;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ {
+ int index = pDrawable->pScreen->myNum;
+ if(&WindowTable[index]->drawable == pDrawable)
+ {
+ xRot -= panoramiXdataPtr[index].x;
+ yRot -= panoramiXdataPtr[index].y;
+ }
+ }
+#endif
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ fbGetDrawable (&pTile->drawable, tile, tileStride, tileBpp, tileXoff, tileYoff);
+ tileWidth = pTile->drawable.width;
+ tileHeight = pTile->drawable.height;
+ xRot += dstXoff;
+ yRot += dstYoff;
+
+ while (n--)
+ {
+ fbTile (dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+ (pbox->x2 - pbox->x1) * dstBpp,
+ pbox->y2 - pbox->y1,
+ tile,
+ tileStride,
+ tileWidth * dstBpp,
+ tileHeight,
+ GXcopy,
+ FB_ALLONES,
+ dstBpp,
+ xRot * dstBpp,
+ yRot - (pbox->y1 + dstYoff));
+ pbox++;
+ }
+}
+
+void
+fbPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ WindowPtr pBgWin;
+
+ switch (what) {
+ case PW_BACKGROUND:
+ switch (pWin->backgroundState) {
+ case None:
+ break;
+ case ParentRelative:
+ do {
+ pWin = pWin->parent;
+ } while (pWin->backgroundState == ParentRelative);
+ (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
+ what);
+ break;
+ case BackgroundPixmap:
+ fbFillRegionTiled (&pWin->drawable,
+ pRegion,
+ pWin->background.pixmap);
+ break;
+ case BackgroundPixel:
+ fbFillRegionSolid (&pWin->drawable,
+ pRegion,
+ 0,
+ fbReplicatePixel (pWin->background.pixel,
+ pWin->drawable.bitsPerPixel));
+ break;
+ }
+ break;
+ case PW_BORDER:
+ if (pWin->borderIsPixel)
+ {
+ fbFillRegionSolid (&pWin->drawable,
+ pRegion,
+ 0,
+ fbReplicatePixel (pWin->border.pixel,
+ pWin->drawable.bitsPerPixel));
+ }
+ else
+ {
+ for (pBgWin = pWin;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+
+ fbFillRegionTiled (&pBgWin->drawable,
+ pRegion,
+ pWin->border.pixmap);
+ }
+ break;
+ }
+ fbValidateDrawable (&pWin->drawable);
+}
diff --git a/nx-X11/programs/Xserver/fb/module/Imakefile b/nx-X11/programs/Xserver/fb/module/Imakefile
new file mode 100644
index 000000000..bea44f4e8
--- /dev/null
+++ b/nx-X11/programs/Xserver/fb/module/Imakefile
@@ -0,0 +1,6 @@
+XCOMM $XFree86: xc/programs/Xserver/cfb/module/Imakefile,v 1.1 2002/05/31 15:12:56 dawes Exp $
+
+#define IHaveModules
+#define LinkDirectory ..
+
+#include "../Imakefile"
diff --git a/nx-X11/programs/Xserver/hw/Imakefile b/nx-X11/programs/Xserver/hw/Imakefile
new file mode 100644
index 000000000..6ea7f00a1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/Imakefile
@@ -0,0 +1,26 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:20 cpqbld Exp $
+XCOMM This is only used on NT where we do not know how to jump over this dir
+
+#ifdef Win32Architecture
+
+#define IHaveSubdirs
+#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
+
+#if XnestServer
+XNESTDIR = xnest
+#endif
+
+#if XVirtualFramebufferServer
+XVFBDIR = vfb
+#endif
+
+#if XdmxServer
+XDMXDIR = dmx
+#endif
+
+SUBDIRS= $(XNESTDIR) $(XVFBDIR) $(XDMXDIR)
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/darwin/Imakefile b/nx-X11/programs/Xserver/hw/darwin/Imakefile
new file mode 100644
index 000000000..213816647
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/Imakefile
@@ -0,0 +1,92 @@
+XCOMM $XdotOrg: xc/programs/Xserver/hw/darwin/Imakefile,v 1.6 2004/11/08 06:35:27 fabbione Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/Imakefile,v 1.19 2003/05/14 05:27:55 torrey Exp $
+
+#include <Server.tmpl>
+#define IHaveSubdirs
+
+LinkSourceFile(Xorg.man,../xfree86)
+
+/* The version of miinitext.c in mi is built with many extensions off. */
+LinkSourceFile(miinitext.c,$(SERVERSRC)/mi)
+SpecialCObjectRule(miinitext,$(ICONFIGFILES),$(EXT_DEFINES))
+
+#if BuildXInputExt
+XINPUTSRCS = darwinXinput.c
+XINPUTOBJS = darwinXinput.o
+#endif
+
+SRCS = darwin.c \
+ darwinEvents.c \
+ darwinKeyboard.c \
+ miinitext.c \
+ $(XINPUTSRCS)
+
+OBJS = darwin.o \
+ darwinEvents.o \
+ darwinKeyboard.o \
+ miinitext.o \
+ $(XINPUTOBJS)
+
+INCLUDES = -I. -I$(SERVERSRC)/mi -I$(SERVERSRC)/fb -I$(EXTINCSRC) \
+ -I$(SERVERSRC)/render -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/os -I$(INCLUDESRC) -I$(FONTINCSRC) \
+ -I$(SERVERSRC)/miext/shadow -I$(SERVERSRC)/hw/xfree86 \
+ -I$(SERVERSRC)/Xi
+
+OSNAME = OSName
+OSVENDOR = OSVendor
+OSNAMEDEF = -DOSNAME='" $(OSNAME)"' -DOSVENDOR='" $(OSVENDOR)"'
+#if defined(XorgCustomVersion) || defined(XFree86CustomVersion)
+# if defined(XorgCustomVersion)
+CUSTOMVERSION = XorgCustomVersion
+# else
+CUSTOMVERSION = XFree86CustomVersion
+# endif /* XorgCustomVersion */
+CUSTOMVERDEF = -DXORG_CUSTOM_VERSION='$(CUSTOMVERSION)'
+#endif /* XorgCustomVersion || XFree86CustomVersion */
+#if defined(BuilderString)
+BUILDERSTRING = BuilderString
+BUILDERMSG = -DBUILDERSTRING='$(BUILDERSTRING)'
+#endif
+XORGREL = XOrgReleaseString
+XORGREL_DEF = -DXORG_RELEASE="\"$(XORGREL)\""
+
+#if defined(BuildDate)
+ BUILD_DATE = BuildDate
+#else
+ BUILD_DATE = 0
+#endif
+
+#if defined(ChangelogDate)
+ CLOG_DATE = ChangelogDate
+#else
+ CLOG_DATE = 0
+#endif
+
+#if OSMajorVersion >= 6
+CLUTDEF = -DUSE_NEW_CLUT
+#endif
+
+#if DarwinQuartzSupport
+SUBDIRS = iokit bundle quartz utils
+QUARTZDEF = -DDARWIN_WITH_QUARTZ
+#else
+SUBDIRS = iokit utils
+#endif
+
+DEFINES = $(QUARTZDEF) $(VENDORSUPPORTDEFS)
+EXTRAMANDEFS = $(QUARTZDEF) -D__logdir__=$(LOGDIRECTORY)
+
+SpecialCObjectRule(darwin,$(ICONFIGFILES),$(OSNAMEDEF) $(BUILDERMSG) \
+ $(CUSTOMVERDEF) $(XORGREL_DEF) $(CLUTDEF) $(VENDOR_DEFINES))
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(darwin,$(OBJS))
+
+InstallManPage(XDarwin,$(MANDIR))
+InstallManPage(Xorg,$(MANDIR))
+
+DependTarget()
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
diff --git a/nx-X11/programs/Xserver/hw/darwin/XDarwin.man b/nx-X11/programs/Xserver/hw/darwin/XDarwin.man
new file mode 100644
index 000000000..eb1b9dcb8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/XDarwin.man
@@ -0,0 +1,205 @@
+.\" $XFree86: xc/programs/Xserver/hw/darwin/XDarwin.man,v 1.3 2001/09/23 23:02:37 torrey Exp $
+.\"
+.TH XDARWIN 1 __vendorversion__
+.SH NAME
+XDarwin \- X window system server for Darwin operating system
+.SH SYNOPSIS
+.B XDarwin
+[ options ] ...
+.SH DESCRIPTION
+#ifdef DARWIN_WITH_QUARTZ
+.I XDarwin
+is the X window server for Mac OS X and the Darwin operating system
+provided by the X.Org Foundation.
+.I XDarwin
+can run in three different modes. On Mac OS X,
+.I XDarwin
+runs in parallel with Aqua in full screen or rootless modes. These modes
+are called Quartz modes, named after the Quartz 2D compositing engine used
+by Aqua. XDarwin can also be run from the Darwin text console in IOKit mode.
+.PP
+When running from the console,
+.I XDarwin
+acts as the window server and uses IOKit services to access the display
+framebuffer, mouse and keyboard and to provide a layer of hardware
+abstraction. In console mode,
+.I XDarwin
+will normally be started by the \fIxdm(1)\fP display manager or by a script
+that runs the program \fIxinit(1)\fP.
+.PP
+When running with the Mac OS X Aqua GUI,
+.I XDarwin
+will normally be started by launching from the Finder, but it may also be
+started from the command line with the \fB\-quartz\fP, \fB\-fullscreen\fP, or
+\fB\-rootless\fP options. Note that the defaults for various command line
+options are set by the
+.I XDarwin
+application preferences in the Quartz modes.
+.PP
+In full screen Quartz mode, when the X Window System is active, it takes over
+the entire screen. CoreGraphics is used to capture and draw to the screen. The
+.I XDarwin
+application allows easy switching between the Mac OS X and X window
+desktops. More information is available in the Help menu of the
+.I XDarwin
+application.
+.PP
+In rootless mode, the X window system and Aqua share your display. The root
+window of the X11 display is the size of the screen and contains all the
+other windows. The X11 root window is not displayed in rootless mode as Aqua
+handles the desktop background.
+#else
+.I XDarwin
+is the X window server for Mac OS X and the Darwin operating system
+provided by the X.Org Foundation. This version of
+.I XDarwin
+can only be started from the Darwin text console. The Mac OS X Aqua GUI, if
+present, must be shut down.
+.I XDarwin
+uses IOKit services to access the display
+framebuffer, mouse and keyboard and to provide a layer of hardware
+abstraction.
+.I XDarwin
+will normally be started by the \fIxdm(1)\fP display manager or by a script
+that runs the program \fIxinit(1)\fP.
+#endif
+.SH OPTIONS
+.PP
+In addition to the normal server options described in the \fIXserver(1)\fP
+manual page, \fIXDarwin\fP accepts the following command line switches:
+.TP 8
+.B \-fakebuttons
+Emulates a 3 button mouse using modifier keys. By default, the Command modifier
+is used to emulate button 2 and Option is used for button 3. Thus, clicking the
+first mouse button while holding down Command will act like clicking
+button 2. Holding down Option will simulate button 3.
+.TP 8
+.B \-nofakebuttons
+Do not emulate a 3 button mouse. This is the default.
+.TP 8
+.B "\-fakemouse2 \fImodifiers\fP"
+Change the modifier keys used to emulate the second mouse button. By default,
+Command is used to emulate the second button. Any combination of the following
+modifier names may be used: Shift, Option, Control, Command, Fn. For example,
+.B \-fakemouse2 """Option,Shift""
+will set holding Option, Shift and clicking on button one as equivalent to
+clicking the second mouse button.
+.TP 8
+.B "\-fakemouse3 \fImodifiers\fP"
+Change the modifier keys used to emulate the third mouse button. By default,
+Option is used to emulate the third button. Any combination of the following
+modifier names may be used: Shift, Option, Control, Command, Fn. For example,
+.B \-fakemouse3 """Control,Shift""
+will set holding Control, Shift and clicking on button one as equivalent to
+clicking the third mouse button.
+.TP 8
+.B "\-keymap \fIfile\fP"
+On startup \fIXDarwin\fP translates a Darwin keymapping into an X keymap.
+The default is to read this keymapping from USA.keymapping. With this option
+the keymapping will be read from \fIfile\fP instead. If the file's path is
+not specified, it will be searched for in Library/Keyboards/ underneath the
+following directories (in order): ~, /, /Network, /System.
+.TP 8
+.B \-nokeymap
+On startup \fIXDarwin\fP translates a Darwin keymapping into an X keymap.
+With this option XDarwin queries the kernel for the current keymapping
+instead of reading it from a file. This will often fail on newer kernels.
+#ifdef DARWIN_WITH_QUARTZ
+.TP 8
+.B "\-size \fIwidth\fP \fIheight\fP"
+Sets the screen resolution for the X server to use.
+Ignored in rootless mode.
+.TP 8
+.B "\-depth \fIdepth\fP"
+Specifies the color bit depth to use. Currently only 8, 15, and 24 color bits
+per pixel are supported.
+Ignored in rootless mode.
+.TP 8
+.B "\-refresh \fIrate\fP"
+Gives the refresh rate to use in Hz. For LCD displays this should be 0.
+Ignored in rootless mode.
+.TP 8
+.B \-fullscreen
+Run full screen in parallel with Mac OS X Aqua GUI.
+.TP 8
+.B \-rootless
+Run rootless inside Mac OS X Aqua GUI.
+.TP 8
+.B \-quartz
+Run in parallel with the Mac OS X Aqua GUI using the default mode.
+#else
+.TP 8
+.B "\-size \fIwidth\fP \fIheight\fP"
+Sets the screen resolution for the X server to use.
+.TP 8
+.B "\-depth \fIdepth\fP"
+Specifies the color bit depth to use. Currently only 8, 15, and 24 color bits
+per pixel are supported.
+.TP 8
+.B "\-refresh \fIrate\fP"
+Gives the refresh rate to use in Hz. For LCD displays this should be 0.
+#endif
+.TP 8
+.B \-showconfig
+Print out the server version and patchlevel.
+.TP 8
+.B \-version
+Same as \fB\-showconfig\fP.
+.SH "SEE ALSO"
+.PP
+X(__miscmansuffix__), Xorg(1), Xserver(1), xdm(1), xinit(1)
+.SH BUGS
+.I XDarwin
+and this man page still have many limitations. Some of the more obvious
+ones are:
+.br
+- The display mode cannot be changed once the X server has started.
+.br
+- A screen saver is not supported.
+.PP
+.SH AUTHORS
+XFree86 was originally ported to Mac OS X Server by John Carmack. Dave
+Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0.
+Torrey T. Lyons improved and integrated this code into the XFree86
+Project's mainline for the 4.0.2 release.
+.PP
+The following members of the XonX Team contributed to the following
+releases (in alphabetical order):
+.TP 4
+XFree86 4.1.0:
+.br
+Rob Braun - Darwin x86 support
+.br
+Torrey T. Lyons - Project Lead
+.br
+Andreas Monitzer - Cocoa version of XDarwin front end
+.br
+Gregory Robert Parker - Original Quartz implementation
+.br
+Christoph Pfisterer - Dynamic shared X libraries
+.br
+Toshimitsu Tanaka - Japanese localization
+.TP 4
+XFree86 4.2.0:
+.br
+Rob Braun - Darwin x86 support
+.br
+Pablo Di Noto - Spanish localization
+.br
+Paul Edens - Dutch localization
+.br
+Kyunghwan Kim - Korean localization
+.br
+Mario Klebsch - Non-US keyboard support
+.br
+Torrey T. Lyons - Project Lead
+.br
+Andreas Monitzer - German localization
+.br
+Patrik Montgomery - Swedish localization
+.br
+Greg Parker - Rootless support
+.br
+Toshimitsu Tanaka - Japanese localization
+.br
+Olivier Verdier - French localization
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/Credits.rtf b/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/Credits.rtf
new file mode 100644
index 000000000..5858e5933
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/Credits.rtf
@@ -0,0 +1,168 @@
+{\rtf1\mac\ansicpg10000\cocoartf102
+{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fswiss\fcharset77 Helvetica-Oblique;
+}
+{\colortbl;\red255\green255\blue255;}
+\vieww9000\viewh9000\viewkind0
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\fs24 \cf0 This product includes software developed by The XFree86 Project, Inc (http://www.xfree86.org/) and its contributors. The following people contributed to Darwin/Mac OS X support.\
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Contributors to Xorg Foundation Release:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Kaleb KEITHLEY\
+
+\f2\i Working left and right Ctrl, Alt (Option), Meta (Command) and Shift keys.
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\f1\b \cf0 Contributors to XFree86 4.4:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Harper\
+
+\f2\i Rootless acceleration and Apple-WM extension
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Additional XonX Contributors to XFree86 4.3:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Fabr\'92cio Luis de Castro\
+
+\f2\i Portuguese localization
+\f0\i0 \
+Michael Oland\
+
+\f2\i New XDarwin icon
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 XonX Contributors to XFree86 4.2:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+
+\f2\i Darwin x86 support
+\f0\i0 \
+Pablo Di Noto\
+
+\f2\i Spanish localization
+\f0\i0 \
+Paul Edens\
+
+\f2\i Dutch localization
+\f0\i0 \
+Kyunghwan Kim\
+
+\f2\i Korean localization
+\f0\i0 \
+Mario Klebsch\
+
+\f2\i Non-US keyboard support
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+Andreas Monitzer\
+
+\f2\i German localization
+\f0\i0 \
+Patrik Montgomery\
+
+\f2\i Swedish localization
+\f0\i0 \
+Greg Parker\
+
+\f2\i Rootless support
+\f0\i0 \
+Toshimitsu Tanaka\
+
+\f2\i Japanese localization
+\f0\i0 \
+Olivier Verdier\
+
+\f2\i French localization
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Special Thanks:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Devin Poolman and Zero G Software, Inc.\
+
+\f2\i Installer
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 XonX Team Members\
+Contributing to XFree86 4.1:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+
+\f2\i Darwin x86 support
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+Andreas Monitzer\
+
+\f2\i Cocoa version of XDarwin front end
+\f0\i0 \
+Greg Parker\
+
+\f2\i Original Quartz implementation
+\f0\i0 \
+Christoph Pfisterer\
+
+\f2\i Dynamic shared libraries
+\f0\i0 \
+Toshimitsu Tanaka\
+
+\f2\i Japanese localization
+\f0\i0 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Special Thanks:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Tiago Ribeiro\
+
+\f2\i XDarwin icon
+\f0\i0 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 History:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Carmack\
+
+\f2\i Original XFree86 port to Mac OS X Server
+\f0\i0 \
+Dave Zarzycki\
+
+\f2\i XFree86 4.0 port to Darwin 1.0
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Integration into XFree86 Project for 4.0.2} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/Imakefile b/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/Imakefile
new file mode 100644
index 000000000..d367fbcee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/Imakefile
@@ -0,0 +1,36 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/Imakefile,v 1.1 2001/05/21 01:42:17 torrey Exp $
+
+#include <Server.tmpl>
+
+LinkSourceFile(InfoPlist.strings.cpp,../English.lproj)
+
+INCLUDES = -I$(SERVERSRC)/include
+
+#if defined (XorgVersionString)
+VERS = XorgVersionString
+PRE = XORG_VERSION_SNAP
+NAME = "X Version 11"
+LINK = '<a HREF="http://wiki.x.org/">X.Org Foundation</a>'
+#elif defined XFree86VersionString
+VERS = XFree86VersionString
+PRE = XF86_VERSION_SNAP
+NAME = "XFree86"
+LINK = '<a HREF="http://www.XFree86.Org/">XFree86 Project, Inc.</a>'
+#endif
+DATE = XFree86DateString
+X_DEFS = $(INCLUDES) -DX_VERSION=$(VERS) -DX_PRE_RELEASE=$(PRE) \
+ -DX_REL_DATE=$(DATE) -DX_VENDOR_NAME=$(NAME) -DX_VENDOR_LINK=$(LINK)
+
+AllTarget(XDarwinHelp.html)
+CppFileTarget(XDarwinHelp.html,XDarwinHelp.html.cpp,$(X_DEFS), \
+ NullParameter)
+
+AllTarget(InfoPlist.strings)
+InfoPlist.strings: InfoPlist.strings.cpp
+ RemoveFile($@)
+ ClearmakeOSName \
+ $(CPP) CppNoLineInfoOption $(X_DEFS) <InfoPlist.strings.cpp | \
+ CppSedMagic | sed 's/__quote__/"/g' >$@
+
+clean::
+ RemoveFiles(InfoPlist.strings)
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/Localizable.strings b/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/Localizable.strings
new file mode 100644
index 000000000..6abd91072
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/Localizable.strings
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/classes.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/classes.nib
new file mode 100644
index 000000000..77f345a4e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/classes.nib
@@ -0,0 +1,72 @@
+{
+ IBClasses = (
+ {
+ ACTIONS = {showHelp = id; };
+ CLASS = FirstResponder;
+ LANGUAGE = ObjC;
+ SUPERCLASS = NSObject;
+ },
+ {
+ ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; };
+ CLASS = Preferences;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ addToPathButton = id;
+ addToPathField = id;
+ button2ModifiersMatrix = id;
+ button3ModifiersMatrix = id;
+ depthButton = id;
+ displayField = id;
+ dockSwitchButton = id;
+ fakeButton = id;
+ keymapFileField = id;
+ modeMatrix = id;
+ modeWindowButton = id;
+ mouseAccelChangeButton = id;
+ startupHelpButton = id;
+ switchKeyButton = id;
+ systemBeepButton = id;
+ useDefaultShellMatrix = id;
+ useOtherShellField = id;
+ useXineramaButton = id;
+ window = id;
+ };
+ SUPERCLASS = NSObject;
+ },
+ {
+ CLASS = XApplication;
+ LANGUAGE = ObjC;
+ OUTLETS = {preferences = id; xserver = id; };
+ SUPERCLASS = NSApplication;
+ },
+ {
+ ACTIONS = {
+ bringAllToFront = id;
+ closeHelpAndShow = id;
+ itemSelected = id;
+ nextWindow = id;
+ previousWindow = id;
+ showAction = id;
+ showSwitchPanel = id;
+ startFullScreen = id;
+ startRootless = id;
+ };
+ CLASS = XServer;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ dockMenu = NSMenu;
+ helpWindow = NSWindow;
+ modeWindow = NSWindow;
+ startFullScreenButton = NSButton;
+ startRootlessButton = NSButton;
+ startupHelpButton = NSButton;
+ startupModeButton = NSButton;
+ switchWindow = NSPanel;
+ windowMenu = NSMenu;
+ windowSeparator = NSMenuItem;
+ };
+ SUPERCLASS = NSObject;
+ }
+ );
+ IBVersion = 1;
+} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/objects.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/objects.nib
new file mode 100644
index 000000000..8e9224cb6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/objects.nib
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp b/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp
new file mode 100644
index 000000000..1113b8ae6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp
@@ -0,0 +1,103 @@
+<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.2 2001/11/04 07:02:28 torrey Exp $ -->
+
+<html>
+<head>
+<title>XDarwin Help</title>
+</head>
+<body>
+<center>
+ <h1>XDarwin X Server for Mac OS X</h1>
+ X_VENDOR_NAME X_VERSION<br>
+ Release Date: X_REL_DATE
+</center>
+<h2>Inhoud</h2>
+<ol>
+ <li><A HREF="#notice">Belangrijke Informatie</A></li>
+ <li><A HREF="#usage">Gebruik</A></li>
+ <li><A HREF="#path">Instellen van het Path</A></li>
+ <li><A HREF="#prefs">Voorkeursinstellingen</A></li>
+ <li><A HREF="#license">Licentie</A></li>
+</ol>
+<center>
+ <h2><a NAME="notice">Belangrijke Informatie</a></h2>
+</center>
+<blockquote>
+#if X_PRE_RELEASE
+Dit is een pre-release van XDarwin, waarvoor geen ondersteuning beschikbaar is. Rapporteren van bugs en aanleveren van patches kan op de <A HREF="http://sourceforge.net/projects/xonx/">XonX project pagina</A> bij SourceForge. Kijk alvorens een bug te rapporteren in een pre-release eerst of een nieuwe versie beschikbaar is bij <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> of de X_VENDOR_LINK.
+#else
+Als de server ouder is dan 6-12 maanden, of als uw hardware nieuwer is dan de bovenstaande datum, kijk dan of een nieuwe versie beschikbaar is voor u een probleem aanmeldt. Rapporteren van bugs en aanleveren van patches kan op de <A HREF="http://sourceforge.net/projects/xonx/">XonX project pagina</A> bij SourceForge.
+#endif
+</blockquote>
+<blockquote>
+Deze software is beschikbaar gesteld onder de voorwaarden van de <A HREF="#license">MIT X11 / X Consortium Licentie</A> en is beschikbaar 'AS IS',zonder enige garantie. Lees s.v.p. de <A HREF="#license">Licentie</A> voor gebruik.</blockquote>
+
+<h2><a NAME="usage">Gebruik</a></h2>
+<p>XDarwin is een open-source X server van het <a HREF="http://www.x.org/">X Window Systeem</a>. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin werkt op Mac OS X in schermvullende of rootless modus.</p>
+<p>Het X window systeem in schermvullende modus neemt het hele beeldscherm in beslag. U schakelt terug naar de Mac OS X desktop door de toesten Command-Option-A in te drukken. Deze toetsencombinatie kunt u veranderen in de Voorkeuren. Op de Mac OS X desktop klikt u op de XDarwin icoon in de Dock om weer naar het X window systeem te schakelen. (In de Voorkeuren kunt er voor kiezen om een apart XDarwin schakelpaneel te gebruiken op de Mac OS X desktop.)</p>
+<p>In rootless modus verschijnen het X window systeem en Aqua (de Mac OS X desktop) tegelijk op het scherm. Het achtergrondscherm van X11, waarbinnen alle X11 vensters vallen, is net zo groot als het gehele scherm, maar het achtergrondscherm zelf is onzichtbaar.</p>
+
+<h3>Meerknopsmuis emulatie</h3>
+<p>Voor veel X11 programma's hebt u een 3-knops muis nodig. Met een 1-knops muis kunt u een 3-knops muis nabootsen door een toets in te drukken terwijl u klikt met de muis. Het instellen hiervan kan bij Voorkeuren, "Meerknopsmuis emulatie" in "Algemeen". Emulatie is standaard ingeschakeld: ingedrukt houden van de "command" toets terwijl u klikt emuleert knop 2, ingedrukt houden van "option" emuleert knop 3. Deze toetsen kunt u dus wijzigen in de Voorkeuren. Let op: als u xmodmap gebruikt om de indeling van het toetsenbord te wijzigen, moet u toch de oorspronkelijke toetsen op het toetsenbord gebruiken voor deze functie.</p>
+
+<h2><a NAME="path">Instellen van het Path</a></h2>
+<p>Het path is de lijst van directories waarin gezocht wordt naar commando's. De X11 commando's staan in de directory <code>/usr/X11R6/bin</code>, die dus aan uw path moet worden toegevoegd. XDarwin doet dit automatisch voor u en kan extra directories toevoegen waarin u commando's hebt ge&iuml;nstalleerd.</p>
+
+<p>Ervaren gebruikers zullen het path al correct hebben ingesteld in de configuratiebestanden voor hun shell. In dat geval kunt u XDarwin via de Voorkeuren vertellen het path niet te wijzigen. XDarwin start de eerste X11 clients binnen de standaard login shell van de gebruiker (bij de Voorkeuren kunt u een afwijkende shell opgeven). Het instellen van het path is afhankelijk van de shell. Zie hiervoor de man pages voor de shell.</p>
+
+<p>Het kan handig zijn de manualpages voor X11 toe te voegen aan de lijst waarin gezocht wordt als u documentatie opvraagt. De manualpages voor X11 staan in <code>/usr/X11R6/man</code> en de <code>MANPATH</code> environment variable bevat de lijst van directories waarin naar documentatie wordt gezocht.</p>
+
+<h2><a NAME="prefs">Voorkeursinstellingen</a></h2>
+<p>Een aantal instellingen kan worden gewijzigd door "Voorkeuren..." te kiezen in het "XDarwin" menu. Wijzigingen van de instellingen genoemd onder "Start" gaan pas in als u XDarwin opnieuw hebt gestart. Een wijziging van de overige instellingen is direct effectief. Hier onder vindt u de verschillende mogelijkheden beschreven:</p>
+
+<h3>Algemeen</h3>
+<ul>
+ <li><b>Gebruik systeempiep voor X11:</b> Als u dit inschakelt wordt het Mac OS X waarschuwingssignaal ook gebruikt door X11, anders gebruikt X11 een simpele pieptoon (dit is de standaardinstelling).</li>
+ <li><b>Wijzigen muis-versnelling door X11 mogelijk:</b> In een standaard X window systeem kan de window manager de muis-versnelling aanpassen. Dit kan verwarrend zijn omdat de snelheid onder X11 dan verschillend kan zijn van de snelheid die u in Mac OS X bij Systeemvoorkeuren hebt ingesteld. Om verwarring te voorkomen is de standaardinstelling dat X11 de versnelling niet kan wijzigen.</li>
+ <li><b>Meerknopsmuis emulatie:</b> Dit is hierboven beschreven bij <a HREF="#usage">Gebruik</a>. Als emulatie is ingeschakeld moet u de gekozen toetsen ingedrukt houden terwijl u met de muis klikt om de tweede en derde muisknop na te bootsen.</li>
+</ul>
+
+<h3>Start</h3>
+<ul>
+ <li><b>Standaard modus:</b> Hier kiest u de standaard scherm-modus: schermvullend of rootless (hierboven beschreven bij <a HREF="#usage">Gebruik</a>). U kunt ook kiezen tijdens het starten van XDarwin, zie de optie hieronder.</li>
+ <li><b>Kies scherm-modus tijdens start:</b> Dit is standaard ingeschakeld zodat u tijdens het starten van XDarwin kunt kiezen tussen schermvullend en rootless scherm-modus. Als u dit uitschakelt start XDarwin in de standaard modus zonder u iets te vragen.</li>
+ <li><b>X11 scherm nummer:</b> Met X11 kunnen meerdere schermen worden aangestuurd door verschillende X servers op dezelfde computer. Als u meerdere X servers tegelijk wilt gebruiken stelt u hier het scherm nummer in dat door XDarwin wordt gebruikt.</li>
+ <li><b>Xinerama multi-monitor ondersteuning mogelijk:</b> XDarwin ondersteunt het gebruik van meerdere monitoren met Xinerama, waarbij elke monitor wordt gezien als deel van &eacute;&eacute;n groot rechthoekig scherm. U kunt Xinerama hier uitschakelen, maar XDarwin werkt op dit moment zonder Xinerama niet goed met meerdere monitoren. Als u maar 1 monitor gebruikt is deze instelling automatisch uitgeschakeld.</li>
+ <li><b>Toetsenbordindeling-bestand:</b> Een toetsenbordindeling-bestand wordt bij het starten geladen en omgezet naar een X11 toetsenbordindeling. Voor verschillende talen vindt u toetsenbordindelingen in de directory <code>/System/Library/Keyboards</code>.</li>
+ <li><b>Bij starten eerste X11 clients:</b> Als XDarwin start, wordt <code>xinit</code> uitgevoerd om de X window manager en andere X clients te starten (zie "<code>man xinit</code>"). Voordat XDarwin <code>xinit</code> uitvoert voegt het de opgegeven directories toe aan het path. Standaard wordt alleen <code>/usr/X11R6/bin</code> toegevoegd. U kunt meerdere directories opgeven, gescheiden door een dubbelepunt. X clients worden gestart met de standaard login shell van de gebruiker met gebruik van de configuratiebestanden voor die shell. U kunt een afwijkende shell opgeven.</li>
+</ul>
+
+<h3>Schermvullend</h3>
+<ul>
+ <li><b>Toetscombinatie knop:</b> Klik op deze knop om de toetscombinatie te wijzigen waarmee u tussen de Mac OS X desktop en X11 schakelt. Als toetscombinatie kunt u elke combinatie gebruiken van de shift, control, command en option toetsen samen met &eacute;&eacute;n normale toets.</li>
+ <li><b>Klikken op icoon in Dock schakelt naar X11:</b> Hiermee is een klik op de XDarwin icoon in de Dock voldoende om naar X11 te schakelen. In sommige versies van Mac OS X verdwijnt soms de cursor als u deze mogelijkheid gebruikt en daarna terugkeert naar de Mac OS X desktop.</li>
+ <li><b>Toon help bij schermvullend starten:</b> Hiermee wordt een inleidend scherm getoond als XDarwin schermvullend start.</li>
+ <li><b>Kleurdiepte:</b> In de schermvullende modus kan X11 een andere kleurdiepte gebruiken dan Aqua (en de Mac OS X desktop). Als u "Huidig" kiest, neemt XDarwin bij het starten de kleurdiepte over van Aqua. U kunt ook kiezen voor 8, 15 of 24 bits.</li>
+</ul>
+
+<h2><a NAME="license">Licentie</a></h2>
+The main license for XDarwin is one based on the traditional MIT X11 / X Consortium License, which does not impose any conditions on modification or redistribution of source code or binaries other than requiring that copyright/license notices are left intact. For more information and additional copyright/licensing notices covering some sections of the code, please refer to the source code.
+<H3><A NAME="3"></A>X Consortium License</H3>
+<p>Copyright (C) 1996 X Consortium</p>
+<p>Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without
+limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to
+whom the Software is furnished to do so, subject to the following conditions:</p>
+<p>The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.</p>
+<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.</p>
+<p>Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization from
+the X Consortium.</p>
+<p>X Window System is a trademark of X Consortium, Inc.</p>
+</body>
+</html>
+
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/Credits.rtf b/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/Credits.rtf
new file mode 100644
index 000000000..34408e78c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/Credits.rtf
@@ -0,0 +1,168 @@
+{\rtf1\mac\ansicpg10000\cocoartf102
+{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fswiss\fcharset77 Helvetica-Oblique;
+}
+{\colortbl;\red255\green255\blue255;}
+\vieww5160\viewh6300\viewkind0
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\fs24 \cf0 This product includes software developed by The XFree86 Project, Inc (http://www.xfree86.org/) and its contributors. The following people contributed to Darwin/Mac OS X support.\
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Contributors to Xorg Foundation Release:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Kaleb KEITHLEY\
+
+\f2\i Working left and right Ctrl, Alt (Option), Meta (Command) and Shift keys.
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\f1\b \cf0 Contributors to XFree86 4.4:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Harper\
+
+\f2\i Rootless acceleration and Apple-WM extension
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Additional XonX Contributors to XFree86 4.3:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Fabr\'92cio Luis de Castro\
+
+\f2\i Portuguese localization
+\f0\i0 \
+Michael Oland\
+
+\f2\i New XDarwin icon
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 XonX Contributors to XFree86 4.2:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+
+\f2\i Darwin x86 support
+\f0\i0 \
+Pablo Di Noto\
+
+\f2\i Spanish localization
+\f0\i0 \
+Paul Edens\
+
+\f2\i Dutch localization
+\f0\i0 \
+Kyunghwan Kim\
+
+\f2\i Korean localization
+\f0\i0 \
+Mario Klebsch\
+
+\f2\i Non-US keyboard support
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+Andreas Monitzer\
+
+\f2\i German localization
+\f0\i0 \
+Patrik Montgomery\
+
+\f2\i Swedish localization
+\f0\i0 \
+Greg Parker\
+
+\f2\i Rootless support
+\f0\i0 \
+Toshimitsu Tanaka\
+
+\f2\i Japanese localization
+\f0\i0 \
+Olivier Verdier\
+
+\f2\i French localization
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Special Thanks:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Devin Poolman and Zero G Software, Inc.\
+
+\f2\i Installer
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 XonX Team Members\
+Contributing to XFree86 4.1:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+
+\f2\i Darwin x86 support
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+Andreas Monitzer\
+
+\f2\i Cocoa version of XDarwin front end
+\f0\i0 \
+Greg Parker\
+
+\f2\i Original Quartz implementation
+\f0\i0 \
+Christoph Pfisterer\
+
+\f2\i Dynamic shared libraries
+\f0\i0 \
+Toshimitsu Tanaka\
+
+\f2\i Japanese localization
+\f0\i0 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Special Thanks:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Tiago Ribeiro\
+
+\f2\i XDarwin icon
+\f0\i0 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 History:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Carmack\
+
+\f2\i Original XFree86 port to Mac OS X Server
+\f0\i0 \
+Dave Zarzycki\
+
+\f2\i XFree86 4.0 port to Darwin 1.0
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Integration into XFree86 Project for 4.0.2} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/Imakefile b/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/Imakefile
new file mode 100644
index 000000000..66a7a6baf
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/Imakefile
@@ -0,0 +1,34 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/Imakefile,v 1.1 2001/05/21 01:42:17 torrey Exp $
+
+#include <Server.tmpl>
+
+INCLUDES = -I$(SERVERSRC)/include
+
+#if defined (XorgVersionString)
+VERS = XorgVersionString
+PRE = XORG_VERSION_SNAP
+NAME = "X Version 11"
+LINK = '<a HREF="http://wiki.x.org/">X.Org Foundation</a>'
+#elif defined XFree86VersionString
+VERS = XFree86VersionString
+PRE = XF86_VERSION_SNAP
+NAME = "XFree86"
+LINK = '<a HREF="http://www.XFree86.Org/">XFree86 Project, Inc.</a>'
+#endif
+DATE = XFree86DateString
+X_DEFS = $(INCLUDES) -DX_VERSION=$(VERS) -DX_PRE_RELEASE=$(PRE) \
+ -DX_REL_DATE=$(DATE) -DX_VENDOR_NAME=$(NAME) -DX_VENDOR_LINK=$(LINK)
+
+AllTarget(XDarwinHelp.html)
+CppFileTarget(XDarwinHelp.html,XDarwinHelp.html.cpp,$(X_DEFS), \
+ NullParameter)
+
+AllTarget(InfoPlist.strings)
+InfoPlist.strings: InfoPlist.strings.cpp
+ RemoveFile($@)
+ ClearmakeOSName \
+ $(CPP) CppNoLineInfoOption $(X_DEFS) <InfoPlist.strings.cpp | \
+ CppSedMagic | sed 's/__quote__/"/g' >$@
+
+clean::
+ RemoveFiles(InfoPlist.strings)
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/InfoPlist.strings.cpp b/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/InfoPlist.strings.cpp
new file mode 100644
index 000000000..aeb210342
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/InfoPlist.strings.cpp
@@ -0,0 +1,5 @@
+/* English versions of the Info.plist keys; used by most localizations. */
+/* Most of these are set in the target application settings. */
+/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/InfoPlist.strings.cpp,v 1.3 2002/07/17 01:24:55 torrey Exp $ */
+
+NSHumanReadableCopyright = __quote__ X_VENDOR_NAME X_VERSION __quote__;
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/Localizable.strings b/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/Localizable.strings
new file mode 100644
index 000000000..2c25c1dc3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/Localizable.strings
@@ -0,0 +1,23 @@
+/* English localized versions of strings used by the Mac OS X front end. */
+/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/Localizable.strings,v 1.3 2002/01/30 06:50:46 torrey Exp $ */
+
+/* Title of alert panel */
+"Quit X server?" = "Quit X server?";
+
+/* Text of alert panel */
+"Quitting the X server will terminate any running X Window System programs." = "Quitting the X server will terminate any running X Window System programs.";
+
+/* Quit */
+"Quit" = "Quit";
+
+/* Cancel */
+"Cancel" = "Cancel";
+
+/* Default keymapping file */
+"USA.keymapping" = "USA.keymapping";
+
+/* Default switch string */
+"Cmd-Opt-a" = "Cmd-Opt-a";
+
+/* Button title when changing switch key */
+"Press key" = "Press key";
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/MainMenu.nib/classes.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/MainMenu.nib/classes.nib
new file mode 100644
index 000000000..77f345a4e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/MainMenu.nib/classes.nib
@@ -0,0 +1,72 @@
+{
+ IBClasses = (
+ {
+ ACTIONS = {showHelp = id; };
+ CLASS = FirstResponder;
+ LANGUAGE = ObjC;
+ SUPERCLASS = NSObject;
+ },
+ {
+ ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; };
+ CLASS = Preferences;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ addToPathButton = id;
+ addToPathField = id;
+ button2ModifiersMatrix = id;
+ button3ModifiersMatrix = id;
+ depthButton = id;
+ displayField = id;
+ dockSwitchButton = id;
+ fakeButton = id;
+ keymapFileField = id;
+ modeMatrix = id;
+ modeWindowButton = id;
+ mouseAccelChangeButton = id;
+ startupHelpButton = id;
+ switchKeyButton = id;
+ systemBeepButton = id;
+ useDefaultShellMatrix = id;
+ useOtherShellField = id;
+ useXineramaButton = id;
+ window = id;
+ };
+ SUPERCLASS = NSObject;
+ },
+ {
+ CLASS = XApplication;
+ LANGUAGE = ObjC;
+ OUTLETS = {preferences = id; xserver = id; };
+ SUPERCLASS = NSApplication;
+ },
+ {
+ ACTIONS = {
+ bringAllToFront = id;
+ closeHelpAndShow = id;
+ itemSelected = id;
+ nextWindow = id;
+ previousWindow = id;
+ showAction = id;
+ showSwitchPanel = id;
+ startFullScreen = id;
+ startRootless = id;
+ };
+ CLASS = XServer;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ dockMenu = NSMenu;
+ helpWindow = NSWindow;
+ modeWindow = NSWindow;
+ startFullScreenButton = NSButton;
+ startRootlessButton = NSButton;
+ startupHelpButton = NSButton;
+ startupModeButton = NSButton;
+ switchWindow = NSPanel;
+ windowMenu = NSMenu;
+ windowSeparator = NSMenuItem;
+ };
+ SUPERCLASS = NSObject;
+ }
+ );
+ IBVersion = 1;
+} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/MainMenu.nib/objects.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/MainMenu.nib/objects.nib
new file mode 100644
index 000000000..ebbfd8317
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/MainMenu.nib/objects.nib
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp b/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp
new file mode 100644
index 000000000..5996285ae
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp
@@ -0,0 +1,96 @@
+<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.1 2001/05/21 01:42:17 torrey Exp $ -->
+
+<html>
+<head>
+<title>XDarwin Help</title>
+</head>
+<body>
+<center>
+ <h1>XDarwin X Server for Mac OS X</h1>
+ X_VENDOR_NAME X_VERSION<br>
+ Release Date: X_REL_DATE
+</center>
+<h2>Contents</h2>
+<ol>
+ <li><A HREF="#notice">Important Notice</A></li>
+ <li><A HREF="#usage">Usage</A></li>
+ <li><A HREF="#path">Setting Your Path</A></li>
+ <li><A HREF="#prefs">User Preferences</A></li>
+ <li><A HREF="#license">License</A></li>
+</ol>
+<center>
+ <h2><a NAME="notice">Important Notice</a></h2>
+</center>
+<blockquote>
+#if X_PRE_RELEASE
+This is a pre-release version of XDarwin, and is not supported in any way. Bugs may be reported and patches may be submitted to the <A HREF="http://sourceforge.net/projects/xonx/">XonX project page</A> at SourceForge. Before reporting bugs in pre-release versions, please check the latest version from <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> or the X_VENDOR_LINK.
+#else
+If the server is older than 6-12 months, or if your hardware is newer than the above date, look for a newer version before reporting problems. Bugs may be reported and patches may be submitted to the <A HREF="http://sourceforge.net/projects/xonx/">XonX project page</A> at SourceForge.
+#endif
+</blockquote>
+<blockquote>
+This software is distributed under the terms of the <A HREF="#license">MIT X11 / X Consortium License</A> and is provided AS IS, with no warranty. Please read the <A HREF="#license">License</A> before using.</blockquote>
+
+<h2><a NAME="usage">Usage</a></h2>
+<p>XDarwin is a freely redistributable open-source X server for the <a HREF="http://www.x.org/">X Window System</a>. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin runs on Mac OS X in full screen or rootless modes.</p>
+<p>In full screen mode, when the X window system is active, it takes over the entire screen. You can switch back to the Mac OS X desktop by holding down Command-Option-A. This key combination can be changed in the user preferences. From the Mac OS X desktop, click on the XDarwin icon in the Dock to switch back to the X window system. (You can change this behavior in the user preferences so that you must click the XDarwin icon in the floating switch window instead.)</p>
+<p>In rootless mode, the X window system and Aqua share your display. The root window of the X11 display is the size of the screen and contains all the other windows. The X11 root window is not displayed in rootless mode as Aqua handles the desktop background.</p>
+<h3>Multi-Button Mouse Emulation</h3>
+<p>Many X11 applications rely on the use of a 3-button mouse. You can emulate a 3-button mouse with a single button by holding down various modifier keys while you click the mouse button. This is controlled by settings in the "Multi-Button Mouse Emulation" section of the "General" preferences. By default, emulation is on and holding down the command key and clicking the mouse button will simulate clicking the second mouse button. Holding down the option key and clicking will simulate the third button. You can change to any combination of modifiers to emulate buttons two and three in the preferences. Note, even if the modifiers keys are mapped to some other key with xmodmap, you still must use the actual keys specified in the preferences for multi-button mouse emulation.</p>
+
+<h2><a NAME="path">Setting Your Path</a></h2>
+<p>Your path is the list of directories to be searched for executable commands. The X11 commands are located in <code>/usr/X11R6/bin</code>, which needs to be added to your path. XDarwin does this for you by default and can also add additional directories where you have installed command line applications.</p>
+<p>More experienced users will have already set their path correctly using the initialization files for their shell. In this case, you can inform XDarwin not to modify your path in the preferences. XDarwin launches the initial X11 clients in the user's default login shell. (An alternate shell can also be specified in the preferences.) The way to set the path depends on the shell you are using. This is described in the man page documentation for the shell.</p>
+<p>In addition you may also want to add the X11 man pages to the list of pages to be searched when you are looking for documentation. The X11 man pages are located in <code>/usr/X11R6/man</code> and the <code>MANPATH</code> environment variable contains the list of directories to search.</p>
+
+<h2><a NAME="prefs">User Preferences</a></h2>
+<p>A number of options may be set from the user preferences, accessible from the "Preferences..." menu item in the "XDarwin" menu. The options listed as start up options will not take effect until you have restarted XDarwin. All other options take effect immediately. The various options are described below:</p>
+<h3>General</h3>
+<ul>
+ <li><b>Use System beep for X11:</b> When enabled the standard Mac OS X alert sound is used as the X11 bell. When disabled (default) a simple tone is used.</li>
+ <li><b>Allow X11 to change mouse acceleration:</b> In a standard X window system implementation, the window manager can change the mouse acceleration. This can lead to confusion as the mouse acceleration may be set to different values by the Mac OS X System Preferences and the X window manager. By default, X11 is not allowed to change the mouse acceleration to avoid this problem.</li>
+ <li><b>Multi-Button Mouse Emulation:</b> This is described above under <a HREF="#usage">Usage</a>. When emulation is enabled the selected modifiers must be held down when the mouse button is pushed to emulate the second or third mouse buttons.</li>
+</ul>
+<h3>Start Up</h3>
+<ul>
+ <li><b>Default Mode:</b> If the user does not indicate whether to run in full screen or rootless mode, the mode specified here will be used.</li>
+ <li><b>Show mode pick panel on startup:</b> By default, a panel is displayed when XDarwin is started to allow the user to choose between full screen or rootless mode. If this option is turned off, the default mode will be started automatically.</li>
+ <li><b>X11 Display number:</b> X11 allows there to be multiple displays managed by separate X servers on a single computer. The user may specify an integer display number for XDarwin to use if more than one X server is going to be run simultaneously.</li>
+ <li><b>Allow Xinerama multiple monitor support:</b> XDarwin supports multiple monitors with Xinerama, which treats all monitors as being part of one large rectangular screen. You can disable Xinerama with this option, but currently XDarwin does not handle multiple monitors correctly without it. If you only have a single monitor, Xinerama is automatically disabled.</li>
+ <li><b>Keymapping File:</b> A keymapping file is read at startup and translated to an X11 keymap. Keymapping files, available for a wide variety of languages, are found in <code>/System/Library/Keyboards</code>.</li>
+ <li><b>Starting First X11 Clients:</b> When XDarwin is started from the Finder, it will run <code>xinit</code> to launch the X window manager and other X clients. (See "<code>man xinit</code>" for more information.) Before XDarwin runs <code>xinit</code> it will add the specified directories to the user's path. By default only <code>/usr/X11R6/bin</code> is added. Additional directories may added, separated by a colon. The X clients are started in the user's default login shell so that the user's shell initialization files are read. If desired, an alternate shell may be specified.</li>
+</ul>
+<h3>Full Screen</h3>
+<ul>
+ <li><b>Key combination button:</b> Click this button and then press any number of modifiers followed by a standard key to change the key combination to switch between Aqua and X11.</li>
+ <li><b>Click on icon in Dock switches to X11:</b> Enable this to activate switching to X11 by clicking on the XDarwin icon in the Dock. On some versions of Mac OS X, switching by clicking in the Dock can cause the cursor to disappear on returning to Aqua.</li>
+ <li><b>Show help on startup:</b> This will show an introductory splash screen when XDarwin is started in full screen mode.</li>
+ <li><b>Color bit depth:</b> In full screen mode, the X11 display can use a different color bit depth than is used by Aqua. If "Current" is specified, the depth used by Aqua when XDarwin starts will be used. Otherwise 8, 15, or 24 bits may be specified.</li>
+</ul>
+
+<h2><a NAME="license">License</a></h2>
+The main license for XDarwin is based on the traditional MIT X11 / X Consortium License, which does not impose any conditions on modification or redistribution of source code or binaries other than requiring that copyright/license notices are left intact. For more information and additional copyright/licensing notices covering some sections of the code, please refer to the source code.
+<H3><A NAME="3"></A>X Consortium License</H3>
+<p>Copyright (C) 1996 X Consortium</p>
+<p>Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without
+limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to
+whom the Software is furnished to do so, subject to the following conditions:</p>
+<p>The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.</p>
+<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.</p>
+<p>Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization from
+the X Consortium.</p>
+<p>X Window System is a trademark of X Consortium, Inc.</p>
+</body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/Credits.rtf b/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/Credits.rtf
new file mode 100644
index 000000000..17e0a0d70
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/Credits.rtf
@@ -0,0 +1,166 @@
+{\rtf1\mac\ansicpg10000\cocoartf102
+{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fswiss\fcharset77 Helvetica-Oblique;
+}
+{\colortbl;\red255\green255\blue255;}
+\vieww5160\viewh4480\viewkind0
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\fs24 \cf0 This product includes software developed by The XFree86 Project, Inc (http://www.xfree86.org/) and its contributors. The following people contributed to Darwin/Mac OS X support.\
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Contributors to Xorg Foundation Release:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Kaleb KEITHLEY\
+
+\f2\i Working left and right Ctrl, Alt (Option), Meta (Command) and Shift keys.
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\f1\b \cf0 Contributors to XFree86 4.4:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Harper\
+
+\f2\i Rootless acceleration and Apple-WM extension
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Additional XonX Contributors to XFree86 4.3:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Fabr\'92cio Luis de Castro\
+
+\f2\i Portuguese localization
+\f0\i0 \
+Michael Oland\
+
+\f2\i New XDarwin icon
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 \
+Participants \'88 XonX pour XFree86 4.2 :
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+
+\f2\i Version pour Darwin x86
+\f0\i0 \
+Pablo Di Noto\
+
+\f2\i Traduction en espagnol
+\f0\i0 \
+Paul Edens\
+
+\f2\i Traduction en allemand
+\f0\i0 \
+Kyunghwan Kim\
+
+\f2\i Traduction en cor\'8een
+\f0\i0 \
+Mario Klebsch\
+
+\f2\i Claviers non-US
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Direction du projet
+\f0\i0 \
+Andreas Monitzer\
+
+\f2\i Traduction en allemand
+\f0\i0 \
+Patrik Montgomery\
+
+\f2\i Traduction en su\'8edois
+\f0\i0 \
+Greg Parker\
+
+\f2\i Version \'c7 rootless \'c8
+\f0\i0 \
+Toshimitsu Tanaka\
+
+\f2\i Traduction en japonais
+\f0\i0 \
+Olivier Verdier\
+
+\f2\i Traduction en fran\'8dais
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Remerciements :
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Devin Poolman et Zero G Software, Inc.\
+
+\f2\i Installeur
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Participants \'88 XonX pour XFree86 4.2 :
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+
+\f2\i Version pour Darwin x86
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Direction du projet
+\f0\i0 \
+Andreas Monitzer\
+
+\f2\i Version Cocoa de l'interface de XDarwin
+\f0\i0 \
+Greg Parker\
+
+\f2\i Impl\'8ementation initiale sur Quartz
+\f0\i0 \
+Christoph Pfisterer\
+
+\f2\i Librairies partag\'8ees dynamiquement
+\f0\i0 \
+Toshimitsu Tanaka\
+
+\f2\i Traduction en japonais
+\f0\i0 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Remerciements :
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Tiago Ribeiro\
+ Ic\'99ne
+\f2\i XDarwin
+\f0\i0 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Historique :
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Carmack\
+
+\f2\i Premi\'8fre adaptation de XFree86 sur Mac OS X Server
+\f0\i0 \
+Dave Zarzycki\
+
+\f2\i Adaptation de Free86 4.0 pour Darwin 1.0
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Int\'8egration dans le projet XFree86 pour la version 4.0.2} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/Imakefile b/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/Imakefile
new file mode 100644
index 000000000..d367fbcee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/Imakefile
@@ -0,0 +1,36 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/Imakefile,v 1.1 2001/05/21 01:42:17 torrey Exp $
+
+#include <Server.tmpl>
+
+LinkSourceFile(InfoPlist.strings.cpp,../English.lproj)
+
+INCLUDES = -I$(SERVERSRC)/include
+
+#if defined (XorgVersionString)
+VERS = XorgVersionString
+PRE = XORG_VERSION_SNAP
+NAME = "X Version 11"
+LINK = '<a HREF="http://wiki.x.org/">X.Org Foundation</a>'
+#elif defined XFree86VersionString
+VERS = XFree86VersionString
+PRE = XF86_VERSION_SNAP
+NAME = "XFree86"
+LINK = '<a HREF="http://www.XFree86.Org/">XFree86 Project, Inc.</a>'
+#endif
+DATE = XFree86DateString
+X_DEFS = $(INCLUDES) -DX_VERSION=$(VERS) -DX_PRE_RELEASE=$(PRE) \
+ -DX_REL_DATE=$(DATE) -DX_VENDOR_NAME=$(NAME) -DX_VENDOR_LINK=$(LINK)
+
+AllTarget(XDarwinHelp.html)
+CppFileTarget(XDarwinHelp.html,XDarwinHelp.html.cpp,$(X_DEFS), \
+ NullParameter)
+
+AllTarget(InfoPlist.strings)
+InfoPlist.strings: InfoPlist.strings.cpp
+ RemoveFile($@)
+ ClearmakeOSName \
+ $(CPP) CppNoLineInfoOption $(X_DEFS) <InfoPlist.strings.cpp | \
+ CppSedMagic | sed 's/__quote__/"/g' >$@
+
+clean::
+ RemoveFiles(InfoPlist.strings)
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/Localizable.strings b/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/Localizable.strings
new file mode 100644
index 000000000..21c4a99c1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/Localizable.strings
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/MainMenu.nib/classes.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/MainMenu.nib/classes.nib
new file mode 100644
index 000000000..77f345a4e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/MainMenu.nib/classes.nib
@@ -0,0 +1,72 @@
+{
+ IBClasses = (
+ {
+ ACTIONS = {showHelp = id; };
+ CLASS = FirstResponder;
+ LANGUAGE = ObjC;
+ SUPERCLASS = NSObject;
+ },
+ {
+ ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; };
+ CLASS = Preferences;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ addToPathButton = id;
+ addToPathField = id;
+ button2ModifiersMatrix = id;
+ button3ModifiersMatrix = id;
+ depthButton = id;
+ displayField = id;
+ dockSwitchButton = id;
+ fakeButton = id;
+ keymapFileField = id;
+ modeMatrix = id;
+ modeWindowButton = id;
+ mouseAccelChangeButton = id;
+ startupHelpButton = id;
+ switchKeyButton = id;
+ systemBeepButton = id;
+ useDefaultShellMatrix = id;
+ useOtherShellField = id;
+ useXineramaButton = id;
+ window = id;
+ };
+ SUPERCLASS = NSObject;
+ },
+ {
+ CLASS = XApplication;
+ LANGUAGE = ObjC;
+ OUTLETS = {preferences = id; xserver = id; };
+ SUPERCLASS = NSApplication;
+ },
+ {
+ ACTIONS = {
+ bringAllToFront = id;
+ closeHelpAndShow = id;
+ itemSelected = id;
+ nextWindow = id;
+ previousWindow = id;
+ showAction = id;
+ showSwitchPanel = id;
+ startFullScreen = id;
+ startRootless = id;
+ };
+ CLASS = XServer;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ dockMenu = NSMenu;
+ helpWindow = NSWindow;
+ modeWindow = NSWindow;
+ startFullScreenButton = NSButton;
+ startRootlessButton = NSButton;
+ startupHelpButton = NSButton;
+ startupModeButton = NSButton;
+ switchWindow = NSPanel;
+ windowMenu = NSMenu;
+ windowSeparator = NSMenuItem;
+ };
+ SUPERCLASS = NSObject;
+ }
+ );
+ IBVersion = 1;
+} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/MainMenu.nib/objects.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/MainMenu.nib/objects.nib
new file mode 100644
index 000000000..109d5cc6f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/MainMenu.nib/objects.nib
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/XDarwinHelp.html.cpp b/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/XDarwinHelp.html.cpp
new file mode 100644
index 000000000..2a14793db
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/XDarwinHelp.html.cpp
@@ -0,0 +1,101 @@
+<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.2 2001/11/04 07:02:28 torrey Exp $ -->
+
+<html>
+<head><META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-1">
+<title>XDarwin Help</title>
+</head>
+<body>
+<center>
+ <h1>XDarwin X Server pour Mac OS X</h1>
+ X_VENDOR_NAME X_VERSION<br>
+ Date : X_REL_DATE
+</center>
+<h2>Sommaire</h2>
+<ol>
+ <li><A HREF="#notice">Avertissement</A></li>
+ <li><A HREF="#usage">Utilisation</A></li>
+ <li><A HREF="#path">Chemins d'accès</A></li>
+ <li><A HREF="#prefs">Préférences</A></li>
+ <li><A HREF="#license">Licence</A></li>
+</ol>
+<center>
+ <h2><a NAME="notice">Avertissement</a></h2>
+</center>
+<blockquote>
+#if PRE_RELEASE
+Ceci est une pré-version de XDarwin et ne fait par conséquent l'objet d'aucun support client. Les bogues peuvent être signalés et des patches peuvent être soumis sur la
+<A HREF="http://sourceforge.net/projects/xonx/">page du projet XonX</A> chez SourceForge. Veuillez prendre connaissance de la dernière version sur <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> ou le X_VENDOR_LINK avant de signaler un bogue d'une pré-version.
+#else
+Si le serveur date de plus de 6-12 mois ou si votre matériel est plus récent que la date indiquée ci-dessus, veuillez vous procurer une version plus récente avant de signaler toute anomalie. Les bogues peuvent être signalés et des patches peuvent être soumis sur la <A HREF="http://sourceforge.net/projects/xonx/">page du projet XonX</A> chez SourceForge.
+#endif
+</blockquote>
+<blockquote>
+Ce logiciel est distribué sous la
+<A HREF="#license">Licence du Consortium X/X11 du MIT</A> et est fourni TEL QUEL, sans garanties. Veuillez prendre connaissance de la <A HREF="#license">Licence</A> avant toute utilisation.</blockquote>
+
+<h2><a NAME="usage">Utilisation</a></h2>
+<p>XDarwin est une X server libre et distribuable sans contrainte du <a HREF
+="http://www.x.org/">X Window System</a>. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin fonctionne sous Mac OS X en mode « rootless » ou plein écran.</p>
+<p>Lorsque le système X window est actif en mode plein écran, il prend en charge la totalité de l'écran. Il est possible de revenir sur le bureau de Mac OS X en appuyant sur Commande-Option-A. Cette combinaison de touches peut être modifiée dans les préférences. Pour revenir dans X window, cliquer sur l'icône de XDarwin dans le Dock de Mac OS X. (Un réglage des préférences permet d'effectuer cette opération en cliquant dans une fenêtre flottante au lieu de l'icône du Dock)</p>
+<p>En mode « rootless », X window system et Aqua utilisent le même affichage. La fenêtre-mère de l'affichage X11 est de la taille de l'écran et contient toutes les autre fenêtres. En mode « rootless » cette fenêtre-mère n'est pas affichée car Aqua gère le fond d'écran.</p>
+<h3>Émulation de souris à plusieurs boutons</h3>
+<p>Le fonctionnement de la plupart des applications X11 repose sur l'utilisation d'une souris à 3 boutons. Il est possible d'émuler une souris à 3 boutons avec un seul bouton en appuyant sur des touches de modification. Ceci est réglé dans la section "Émulation de souris à plusieurs boutons" de l'onglet "Général" des préférences. L'émulation est activée par défaut. Dans ce cas, cliquer en appuyant simultanément sur la touche "commande" simulera le bouton du milieu. Cliquer en appuyant simultanément sur la touche "option" simulera le bouton de droite. Les préférences permettent de régler n'importe quelle combinaison de touches de modification pour émuler les boutons du milieu et de droite. Notez que même si les touches de modifications sont mises en correspondance avec d'autres touches par xmodmap, ce sont les touches originelles spécifiées dans les préférences qui assureront l'émulation d'une souris à plusieurs boutons.
+
+<h2><a NAME="path">Réglage du chemin d'accès</a></h2>
+<p>Le chemin d'accès est une liste de répertoires utilisés pour la recherche d'exécutables. Les commandes X11 sont situées dans <code>/usr/X11R6/bin</code>, qui doit être ajouté à votre chemin d'accès. XDarwin fait cela par défaut, et peut également ajouter d'autres répertoires dans lesquels vous auriez installé d'autre commandes unix.</p>
+<p>Les utilisateurs plus expérimentés auront déjà réglé leur chemin d'accès correctement par le biais des fichiers d'initialisation de leur shell. Dans ce cas, il est possible de demander à XDarwin de ne pas modifier le chemin d'accès initial. XDarwin lance les premiers clients X11 dans le shell d'ouverture de session par défaut. (Un shell de remplacement peut être spécifié dans les préférences.) La façon de régler le chemin d'accès dépend du shell utilisé. Ceci est documenté dans les pages "man" du shell.</p>
+<p>De plus, il est possible d'ajouter les pages "man" de X11 à la liste des pages recherchées pour la documentation "man". Les pages "man" X11 se trouvent dans <code>/usr/X11R6/man</code> et la variable d'environnement <code>MANPATH</code> contient la liste des répertoires dans lesquels chercher.</p>
+
+
+<h2><a NAME="prefs">Préférences</a></h2>
+<p>Un certain nombre d'options peuvent être réglées dans les préférences. On accède aux préférences en choisissant "Préférences..." dans le menu "XDarwin". Les options décrites comme options de démarrage ne prendront pas effet avant le redémarrage de XDarwin. Les autres options prennent immédiatement effet. Les différentes options sont détaillées ci-après :</p>
+<h3>Général</h3>
+<ul>
+ <li><b>Utiliser le bip d'alerte Système dans X11 :</b> Cocher cette option pour que le son d'alerte standard de Mac OS X soit utilisé à la place du son d'alerte de X11. L'option n'est pas cochée ar défaut. Dans ce cas, un simple signal sonore est utilisé.</li>
+ <li><b>Autoriser X11 à changer la vitesse de la souris :</b> Dans une implémentation classique du sytème X window, le gestionnaire de fenêtres peut modifier la vitesse de la souris. Cela peut s'avérer déroutant puisque le réglage de la vitesse de la souris peut être différent dans les préférences de Mac OS X et dans le gestionnaire X window. Par défaut, X11 n'est pas autorisé à changer la vitesse de la souris.</li>
+ <li><b>Émulation de souris à plusieurs boutons :</b> Ceci est décrit ci-dessus à la rubrique <a HREF="#usage">Usage</a>. Lorsque l'émulation est activée, il suffit d'appuyer simultanément sur les touches modificatrices sélectionnées et sur le bouton de la souris afin d'émuler les boutons du milieu et de droite.</li>
+</ul>
+<h3>Démarrage</h3>
+<ul>
+ <li><b>Mode par défaut :</b> Le mode spécifié à cet endroit sera utilisé si l'utilisateur ne l'indique pas au démarrage.</li>
+ <li><b>Choix du mode d'affichage au démarrage</b> Par défaut, une fenêtre de dialogue est affichée au démarrage de XDarwin pour permettre à l'utilisateur de choisir entre le mode plein écran et le mode « rootless ». Si cette option est désactivée, le mode par défaut sera automatiquement utilisé.</li>
+ <li><b>Numéro d'affichage (Display)</b> X11 offre la possibilité de plusieurs serveurs X sur un ordinateur. L'utilisateur doit spécifier ici le numéro d'affichage utilisé par XDarwin dans le cas où plusieurs serveurs X seraient en service simultanément.</li>
+ <li><b>Autoriser la prise en charge Xinerama de plusieurs moniteurs :</b> XDarwin peut être utilisé avec plusieurs moniteur avec Xinerama, qui considère les différents moniteurs comme des parties d'un écran rectugulaire plus grand. Cette option permet de désactiver Xinerama mais XDarwin ne prend alors pour l'instant pas correctement en charge l'affichage sur plusieurs écrans. Si il n'y a qu'un seul moniteur, Xinerama est automatiquement désactivé.</li>
+ <li><b>Fichier clavier :</b> Un fichier de correspondance de clavier est lu au démarrage puis transformé en un fihcier de correspondance clavier pour X11. Les fichiers de correspondance clavier, disponibles pour de nombreuses langues, se trouvent dans <code>/System/Library/Keyboards</code>.</li>
+ <li><b>Démarrage des premiers clients X11 :</b> Lorsque XDarwin est démarré à partir du Finder, il lance <code>xinit</code> qui lance à son tour le gestionnaire X window ainsi que d'autres clients X. (Voir "<code>man xinit</code>" pour plus d'informations.) Avant de lancer <code>xinit</code>, XDarwin ajoute les répertoires ainsi spécifiés au chemin d'accès de l'utilisateur. Par défaut, seul <code>/usr/X11R6/bin</code> est ajouté. Il est possible d'ajouter d'autres répertoires en les séparants à l'aide de deux points (<code>:</code>). Les clients X sont démarrés à partir du shell par défaut de l'utilisateur. Ainsi, le fichier d'initialisation de shell de l'utilisateur est lu. Un autre shell peut éventuellement être spécifié.</li>
+</ul>
+<h3>Plein écran</h3>
+<ul>
+ <li><b>Combinaison de touches :</b> Appuyer sur ce bouton, puis appuyer sur une ou plusieurs touches modificatrices suivies d'une touche ordinaire. Cette combinaison de touche servira à commuter entre Aqua et X11.</li>
+ <li><b>Basculer dans X11 en cliquant sur l'icône du Dock :</b> Cette option permet de passer dans X11 en cliquant dans l'icône de XDarwin dans le Dock. Sur certaines versions de Mac OS X, la commutation en utilisant le Dock peut faire disparaître le curseur lors du retour dans Aqua.</li>
+ <li><b>Afficher l'aide du mode plein écran au démarrage :</b> Permet l'affichage d'une fenêtre d'introduction lorsque XDarwin est démarré en mode plein écran.</li>
+ <li><b>Profondeur de couleur :</b> En mode plein écran, l'affichage X11 peut utiliser une autre profondeur de couleur que celle employée par Aqua. Si "Actuelle" est choisi, XDarwin utilisera la même profondeur de couleur qu'Aqua. Les autres choix sont 8 (256 couleurs), 15 (milliers de couleurs) et 24 bits (millions de couleurs). </li>
+</ul>
+
+<h2><a NAME="license">Licence</a></h2>
+The main license for XDarwin is one based on the traditional MIT X11 / X Consortium License, which does not impose any conditions on modification or redistribution of source code or binaries other than requiring that copyright/license notices are left intact. For more information and additional copyright/licensing notices covering some sections of the code, please refer to the source code.
+<H3><A NAME="3"></A>X Consortium License</H3>
+<p>Copyright (C) 1996 X Consortium</p>
+<p>Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without
+limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to
+whom the Software is furnished to do so, subject to the following conditions:</p>
+<p>The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.</p>
+<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.</p>
+<p>Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization from
+the X Consortium.</p>
+<p>X Window System is a trademark of X Consortium, Inc.</p>
+</body>
+</html>
+
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/Credits.rtf b/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/Credits.rtf
new file mode 100644
index 000000000..34408e78c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/Credits.rtf
@@ -0,0 +1,168 @@
+{\rtf1\mac\ansicpg10000\cocoartf102
+{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fswiss\fcharset77 Helvetica-Oblique;
+}
+{\colortbl;\red255\green255\blue255;}
+\vieww5160\viewh6300\viewkind0
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\fs24 \cf0 This product includes software developed by The XFree86 Project, Inc (http://www.xfree86.org/) and its contributors. The following people contributed to Darwin/Mac OS X support.\
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Contributors to Xorg Foundation Release:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Kaleb KEITHLEY\
+
+\f2\i Working left and right Ctrl, Alt (Option), Meta (Command) and Shift keys.
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\f1\b \cf0 Contributors to XFree86 4.4:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Harper\
+
+\f2\i Rootless acceleration and Apple-WM extension
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Additional XonX Contributors to XFree86 4.3:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Fabr\'92cio Luis de Castro\
+
+\f2\i Portuguese localization
+\f0\i0 \
+Michael Oland\
+
+\f2\i New XDarwin icon
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 XonX Contributors to XFree86 4.2:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+
+\f2\i Darwin x86 support
+\f0\i0 \
+Pablo Di Noto\
+
+\f2\i Spanish localization
+\f0\i0 \
+Paul Edens\
+
+\f2\i Dutch localization
+\f0\i0 \
+Kyunghwan Kim\
+
+\f2\i Korean localization
+\f0\i0 \
+Mario Klebsch\
+
+\f2\i Non-US keyboard support
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+Andreas Monitzer\
+
+\f2\i German localization
+\f0\i0 \
+Patrik Montgomery\
+
+\f2\i Swedish localization
+\f0\i0 \
+Greg Parker\
+
+\f2\i Rootless support
+\f0\i0 \
+Toshimitsu Tanaka\
+
+\f2\i Japanese localization
+\f0\i0 \
+Olivier Verdier\
+
+\f2\i French localization
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Special Thanks:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Devin Poolman and Zero G Software, Inc.\
+
+\f2\i Installer
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 XonX Team Members\
+Contributing to XFree86 4.1:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+
+\f2\i Darwin x86 support
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+Andreas Monitzer\
+
+\f2\i Cocoa version of XDarwin front end
+\f0\i0 \
+Greg Parker\
+
+\f2\i Original Quartz implementation
+\f0\i0 \
+Christoph Pfisterer\
+
+\f2\i Dynamic shared libraries
+\f0\i0 \
+Toshimitsu Tanaka\
+
+\f2\i Japanese localization
+\f0\i0 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Special Thanks:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Tiago Ribeiro\
+
+\f2\i XDarwin icon
+\f0\i0 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 History:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Carmack\
+
+\f2\i Original XFree86 port to Mac OS X Server
+\f0\i0 \
+Dave Zarzycki\
+
+\f2\i XFree86 4.0 port to Darwin 1.0
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Integration into XFree86 Project for 4.0.2} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/Imakefile b/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/Imakefile
new file mode 100644
index 000000000..d367fbcee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/Imakefile
@@ -0,0 +1,36 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/Imakefile,v 1.1 2001/05/21 01:42:17 torrey Exp $
+
+#include <Server.tmpl>
+
+LinkSourceFile(InfoPlist.strings.cpp,../English.lproj)
+
+INCLUDES = -I$(SERVERSRC)/include
+
+#if defined (XorgVersionString)
+VERS = XorgVersionString
+PRE = XORG_VERSION_SNAP
+NAME = "X Version 11"
+LINK = '<a HREF="http://wiki.x.org/">X.Org Foundation</a>'
+#elif defined XFree86VersionString
+VERS = XFree86VersionString
+PRE = XF86_VERSION_SNAP
+NAME = "XFree86"
+LINK = '<a HREF="http://www.XFree86.Org/">XFree86 Project, Inc.</a>'
+#endif
+DATE = XFree86DateString
+X_DEFS = $(INCLUDES) -DX_VERSION=$(VERS) -DX_PRE_RELEASE=$(PRE) \
+ -DX_REL_DATE=$(DATE) -DX_VENDOR_NAME=$(NAME) -DX_VENDOR_LINK=$(LINK)
+
+AllTarget(XDarwinHelp.html)
+CppFileTarget(XDarwinHelp.html,XDarwinHelp.html.cpp,$(X_DEFS), \
+ NullParameter)
+
+AllTarget(InfoPlist.strings)
+InfoPlist.strings: InfoPlist.strings.cpp
+ RemoveFile($@)
+ ClearmakeOSName \
+ $(CPP) CppNoLineInfoOption $(X_DEFS) <InfoPlist.strings.cpp | \
+ CppSedMagic | sed 's/__quote__/"/g' >$@
+
+clean::
+ RemoveFiles(InfoPlist.strings)
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/Localizable.strings b/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/Localizable.strings
new file mode 100644
index 000000000..5db6306ec
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/Localizable.strings
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/MainMenu.nib/classes.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/MainMenu.nib/classes.nib
new file mode 100644
index 000000000..77f345a4e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/MainMenu.nib/classes.nib
@@ -0,0 +1,72 @@
+{
+ IBClasses = (
+ {
+ ACTIONS = {showHelp = id; };
+ CLASS = FirstResponder;
+ LANGUAGE = ObjC;
+ SUPERCLASS = NSObject;
+ },
+ {
+ ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; };
+ CLASS = Preferences;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ addToPathButton = id;
+ addToPathField = id;
+ button2ModifiersMatrix = id;
+ button3ModifiersMatrix = id;
+ depthButton = id;
+ displayField = id;
+ dockSwitchButton = id;
+ fakeButton = id;
+ keymapFileField = id;
+ modeMatrix = id;
+ modeWindowButton = id;
+ mouseAccelChangeButton = id;
+ startupHelpButton = id;
+ switchKeyButton = id;
+ systemBeepButton = id;
+ useDefaultShellMatrix = id;
+ useOtherShellField = id;
+ useXineramaButton = id;
+ window = id;
+ };
+ SUPERCLASS = NSObject;
+ },
+ {
+ CLASS = XApplication;
+ LANGUAGE = ObjC;
+ OUTLETS = {preferences = id; xserver = id; };
+ SUPERCLASS = NSApplication;
+ },
+ {
+ ACTIONS = {
+ bringAllToFront = id;
+ closeHelpAndShow = id;
+ itemSelected = id;
+ nextWindow = id;
+ previousWindow = id;
+ showAction = id;
+ showSwitchPanel = id;
+ startFullScreen = id;
+ startRootless = id;
+ };
+ CLASS = XServer;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ dockMenu = NSMenu;
+ helpWindow = NSWindow;
+ modeWindow = NSWindow;
+ startFullScreenButton = NSButton;
+ startRootlessButton = NSButton;
+ startupHelpButton = NSButton;
+ startupModeButton = NSButton;
+ switchWindow = NSPanel;
+ windowMenu = NSMenu;
+ windowSeparator = NSMenuItem;
+ };
+ SUPERCLASS = NSObject;
+ }
+ );
+ IBVersion = 1;
+} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/MainMenu.nib/objects.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/MainMenu.nib/objects.nib
new file mode 100644
index 000000000..28fff8920
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/MainMenu.nib/objects.nib
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/XDarwinHelp.html.cpp b/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/XDarwinHelp.html.cpp
new file mode 100644
index 000000000..5996285ae
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/XDarwinHelp.html.cpp
@@ -0,0 +1,96 @@
+<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.1 2001/05/21 01:42:17 torrey Exp $ -->
+
+<html>
+<head>
+<title>XDarwin Help</title>
+</head>
+<body>
+<center>
+ <h1>XDarwin X Server for Mac OS X</h1>
+ X_VENDOR_NAME X_VERSION<br>
+ Release Date: X_REL_DATE
+</center>
+<h2>Contents</h2>
+<ol>
+ <li><A HREF="#notice">Important Notice</A></li>
+ <li><A HREF="#usage">Usage</A></li>
+ <li><A HREF="#path">Setting Your Path</A></li>
+ <li><A HREF="#prefs">User Preferences</A></li>
+ <li><A HREF="#license">License</A></li>
+</ol>
+<center>
+ <h2><a NAME="notice">Important Notice</a></h2>
+</center>
+<blockquote>
+#if X_PRE_RELEASE
+This is a pre-release version of XDarwin, and is not supported in any way. Bugs may be reported and patches may be submitted to the <A HREF="http://sourceforge.net/projects/xonx/">XonX project page</A> at SourceForge. Before reporting bugs in pre-release versions, please check the latest version from <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> or the X_VENDOR_LINK.
+#else
+If the server is older than 6-12 months, or if your hardware is newer than the above date, look for a newer version before reporting problems. Bugs may be reported and patches may be submitted to the <A HREF="http://sourceforge.net/projects/xonx/">XonX project page</A> at SourceForge.
+#endif
+</blockquote>
+<blockquote>
+This software is distributed under the terms of the <A HREF="#license">MIT X11 / X Consortium License</A> and is provided AS IS, with no warranty. Please read the <A HREF="#license">License</A> before using.</blockquote>
+
+<h2><a NAME="usage">Usage</a></h2>
+<p>XDarwin is a freely redistributable open-source X server for the <a HREF="http://www.x.org/">X Window System</a>. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin runs on Mac OS X in full screen or rootless modes.</p>
+<p>In full screen mode, when the X window system is active, it takes over the entire screen. You can switch back to the Mac OS X desktop by holding down Command-Option-A. This key combination can be changed in the user preferences. From the Mac OS X desktop, click on the XDarwin icon in the Dock to switch back to the X window system. (You can change this behavior in the user preferences so that you must click the XDarwin icon in the floating switch window instead.)</p>
+<p>In rootless mode, the X window system and Aqua share your display. The root window of the X11 display is the size of the screen and contains all the other windows. The X11 root window is not displayed in rootless mode as Aqua handles the desktop background.</p>
+<h3>Multi-Button Mouse Emulation</h3>
+<p>Many X11 applications rely on the use of a 3-button mouse. You can emulate a 3-button mouse with a single button by holding down various modifier keys while you click the mouse button. This is controlled by settings in the "Multi-Button Mouse Emulation" section of the "General" preferences. By default, emulation is on and holding down the command key and clicking the mouse button will simulate clicking the second mouse button. Holding down the option key and clicking will simulate the third button. You can change to any combination of modifiers to emulate buttons two and three in the preferences. Note, even if the modifiers keys are mapped to some other key with xmodmap, you still must use the actual keys specified in the preferences for multi-button mouse emulation.</p>
+
+<h2><a NAME="path">Setting Your Path</a></h2>
+<p>Your path is the list of directories to be searched for executable commands. The X11 commands are located in <code>/usr/X11R6/bin</code>, which needs to be added to your path. XDarwin does this for you by default and can also add additional directories where you have installed command line applications.</p>
+<p>More experienced users will have already set their path correctly using the initialization files for their shell. In this case, you can inform XDarwin not to modify your path in the preferences. XDarwin launches the initial X11 clients in the user's default login shell. (An alternate shell can also be specified in the preferences.) The way to set the path depends on the shell you are using. This is described in the man page documentation for the shell.</p>
+<p>In addition you may also want to add the X11 man pages to the list of pages to be searched when you are looking for documentation. The X11 man pages are located in <code>/usr/X11R6/man</code> and the <code>MANPATH</code> environment variable contains the list of directories to search.</p>
+
+<h2><a NAME="prefs">User Preferences</a></h2>
+<p>A number of options may be set from the user preferences, accessible from the "Preferences..." menu item in the "XDarwin" menu. The options listed as start up options will not take effect until you have restarted XDarwin. All other options take effect immediately. The various options are described below:</p>
+<h3>General</h3>
+<ul>
+ <li><b>Use System beep for X11:</b> When enabled the standard Mac OS X alert sound is used as the X11 bell. When disabled (default) a simple tone is used.</li>
+ <li><b>Allow X11 to change mouse acceleration:</b> In a standard X window system implementation, the window manager can change the mouse acceleration. This can lead to confusion as the mouse acceleration may be set to different values by the Mac OS X System Preferences and the X window manager. By default, X11 is not allowed to change the mouse acceleration to avoid this problem.</li>
+ <li><b>Multi-Button Mouse Emulation:</b> This is described above under <a HREF="#usage">Usage</a>. When emulation is enabled the selected modifiers must be held down when the mouse button is pushed to emulate the second or third mouse buttons.</li>
+</ul>
+<h3>Start Up</h3>
+<ul>
+ <li><b>Default Mode:</b> If the user does not indicate whether to run in full screen or rootless mode, the mode specified here will be used.</li>
+ <li><b>Show mode pick panel on startup:</b> By default, a panel is displayed when XDarwin is started to allow the user to choose between full screen or rootless mode. If this option is turned off, the default mode will be started automatically.</li>
+ <li><b>X11 Display number:</b> X11 allows there to be multiple displays managed by separate X servers on a single computer. The user may specify an integer display number for XDarwin to use if more than one X server is going to be run simultaneously.</li>
+ <li><b>Allow Xinerama multiple monitor support:</b> XDarwin supports multiple monitors with Xinerama, which treats all monitors as being part of one large rectangular screen. You can disable Xinerama with this option, but currently XDarwin does not handle multiple monitors correctly without it. If you only have a single monitor, Xinerama is automatically disabled.</li>
+ <li><b>Keymapping File:</b> A keymapping file is read at startup and translated to an X11 keymap. Keymapping files, available for a wide variety of languages, are found in <code>/System/Library/Keyboards</code>.</li>
+ <li><b>Starting First X11 Clients:</b> When XDarwin is started from the Finder, it will run <code>xinit</code> to launch the X window manager and other X clients. (See "<code>man xinit</code>" for more information.) Before XDarwin runs <code>xinit</code> it will add the specified directories to the user's path. By default only <code>/usr/X11R6/bin</code> is added. Additional directories may added, separated by a colon. The X clients are started in the user's default login shell so that the user's shell initialization files are read. If desired, an alternate shell may be specified.</li>
+</ul>
+<h3>Full Screen</h3>
+<ul>
+ <li><b>Key combination button:</b> Click this button and then press any number of modifiers followed by a standard key to change the key combination to switch between Aqua and X11.</li>
+ <li><b>Click on icon in Dock switches to X11:</b> Enable this to activate switching to X11 by clicking on the XDarwin icon in the Dock. On some versions of Mac OS X, switching by clicking in the Dock can cause the cursor to disappear on returning to Aqua.</li>
+ <li><b>Show help on startup:</b> This will show an introductory splash screen when XDarwin is started in full screen mode.</li>
+ <li><b>Color bit depth:</b> In full screen mode, the X11 display can use a different color bit depth than is used by Aqua. If "Current" is specified, the depth used by Aqua when XDarwin starts will be used. Otherwise 8, 15, or 24 bits may be specified.</li>
+</ul>
+
+<h2><a NAME="license">License</a></h2>
+The main license for XDarwin is based on the traditional MIT X11 / X Consortium License, which does not impose any conditions on modification or redistribution of source code or binaries other than requiring that copyright/license notices are left intact. For more information and additional copyright/licensing notices covering some sections of the code, please refer to the source code.
+<H3><A NAME="3"></A>X Consortium License</H3>
+<p>Copyright (C) 1996 X Consortium</p>
+<p>Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without
+limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to
+whom the Software is furnished to do so, subject to the following conditions:</p>
+<p>The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.</p>
+<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.</p>
+<p>Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization from
+the X Consortium.</p>
+<p>X Window System is a trademark of X Consortium, Inc.</p>
+</body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Imakefile b/nx-X11/programs/Xserver/hw/darwin/bundle/Imakefile
new file mode 100644
index 000000000..5c50dd296
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Imakefile
@@ -0,0 +1,15 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/bundle/Imakefile,v 1.24 2002/02/17 03:15:18 torrey Exp $
+
+#include <Server.tmpl>
+#define IHaveSubdirs
+
+SUBDIRS = Dutch.lproj English.lproj French.lproj German.lproj Japanese.lproj \
+ ko.lproj Portuguese.lproj Spanish.lproj Swedish.lproj
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+
+AllTarget(startXClients)
+MakeScriptFromCpp(startXClients, -DXINITDIR=$(XINITDIR) -DXBINDIR=$(BINDIR))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/Credits.rtf b/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/Credits.rtf
new file mode 100644
index 000000000..cf9eae207
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/Credits.rtf
@@ -0,0 +1,193 @@
+{\rtf1\mac\ansicpg10001\cocoartf102
+{\fonttbl\f0\fnil\fcharset78 HiraKakuPro-W3;\f1\fswiss\fcharset77 Helvetica;\f2\fswiss\fcharset77 Helvetica-Bold;
+\f3\fswiss\fcharset77 Helvetica-Oblique;}
+{\colortbl;\red255\green255\blue255;}
+\vieww13980\viewh11160\viewkind0
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\fs24 \cf0 \'82\'b1\'82\'cc\'90\'bb\'95\'69\'82\'cd
+\f1 XFree86
+\f0 \'83\'76\'83\'8d\'83\'57\'83\'46\'83\'4e\'83\'67
+\f1 (http://www.xfree86.org/)
+\f0 \'82\'a8\'82\'e6\'82\'d1\'82\'bb\'82\'cc\'8d\'76\'8c\'a3\'8e\'d2\'82\'c9\'82\'e6\'82\'c1\'82\'c4\'8a\'4a\'94\'ad\'82\'b3\'82\'ea\'82\'bd\'83\'5c\'83\'74\'83\'67\'83\'45\'83\'46\'83\'41\'82\'f0\'8a\'dc\'82\'f1\'82\'c5\'82\'a2\'82\'dc\'82\'b7\'81\'42\'8e\'9f\'82\'cc\'90\'6c\'81\'58\'82\'cd Darwin
+\f1 /Mac OS X
+\f0 \'82\'cc\'83\'54\'83\'7c\'81\'5b\'83\'67\'82\'c9\'8d\'76\'8c\'a3\'82\'b5\'82\'dc\'82\'b5\'82\'bd\'81\'42
+\f1 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f2\b \cf0 Contributors to Xorg Foundation Release:
+\f1\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Kaleb KEITHLEY\
+
+\f0 \'8d\'b6\'89\'45\'82\'cc Ctrl,Alt(Option),Meta(Command) \'82\'a8\'82\'e6\'82\'d1 Shift \'83\'4c\'81\'5b\'82\'cc\'93\'ae\'8d\'ec
+\f1 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f2\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Contributors to XFree86 4.4:
+\f1\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Harper
+\f3\i \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f0\i0 \cf0 \'83\'8b\'81\'5b\'83\'67\'83\'8c\'83\'58 \'83\'41\'83\'4e\'83\'5a\'83\'89\'83\'8c\'81\'5b\'83\'56\'83\'87\'83\'93 \'82\'a8\'82\'e6\'82\'d1 Apple-WM \'8a\'67\'92\'a3
+\f1 \
+Torrey T. Lyons\
+
+\f0 \'83\'76\'83\'8d\'83\'57\'83\'46\'83\'4e\'83\'67 \'83\'8a\'81\'5b\'83\'5f\'81\'5b\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f2\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Additional XonX Contributors to XFree86 4.3:
+\f1\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Fabr\'92cio Luis de Castro\
+
+\f0 \'83\'7c\'83\'8b\'83\'67\'83\'4b\'83\'8b\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
+\f1 \
+Michael Oland\
+
+\f0 \'90\'56\'82\'b5\'82\'a2
+\f1 XDarwin
+\f0 \'83\'41\'83\'43\'83\'52\'83\'93
+\f1 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f2\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 XonX Contributors to XFree86 4.2:
+\f1\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+ Darwin x86
+\f3\i
+\f0\i0 \'83\'54\'83\'7c\'81\'5b\'83\'67
+\f1 \
+Pablo Di Noto\
+
+\f3\i
+\f0\i0 \'83\'58\'83\'79\'83\'43\'83\'93\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
+\f1 \
+Paul Edens\
+
+\f3\i
+\f0\i0 \'83\'49\'83\'89\'83\'93\'83\'5f\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
+\f1 \
+Kyunghwan Kim\
+
+\f3\i
+\f0\i0 \'8a\'d8\'8d\'91\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
+\f1 \
+Mario Klebsch\
+
+\f0 \'94\'f1US\'83\'4c\'81\'5b\'83\'7b\'81\'5b\'83\'68 \'83\'54\'83\'7c\'81\'5b\'83\'67
+\f1 \
+Torrey T. Lyons\
+
+\f0 \'83\'76\'83\'8d\'83\'57\'83\'46\'83\'4e\'83\'67 \'83\'8a\'81\'5b\'83\'5f\'81\'5b
+\f1 \
+Andreas Monitzer\
+
+\f0 \'83\'68\'83\'43\'83\'63\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
+\f1 \
+Patrik Montgomery\
+
+\f3\i
+\f0\i0 \'83\'58\'83\'45\'83\'46\'81\'5b\'83\'66\'83\'93\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
+\f1 \
+Greg Parker\
+
+\f0 \'83\'8b\'81\'5b\'83\'67\'83\'8c\'83\'58 \'83\'54\'83\'7c\'81\'5b\'83\'67
+\f1 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f0 \cf0 \'93\'63\'92\'86 \'8f\'72\'8c\'f5
+\f1 \
+
+\f0 \'93\'fa\'96\'7b\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
+\f1 \
+Olivier Verdier\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f3\i \cf0
+\f0\i0 \'83\'74\'83\'89\'83\'93\'83\'58\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
+\f1 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f2\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Special Thanks:
+\f1\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Devin Poolman and Zero G Software, Inc.\
+
+\f3\i
+\f0\i0 \'83\'43\'83\'93\'83\'58\'83\'67\'81\'5b\'83\'89
+\f1 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f2\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 XonX Team Members\
+Contributing to XFree86 4.1:
+\f1\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+ Darwin x86
+\f0 \'83\'54\'83\'7c\'81\'5b\'83\'67
+\f1 \
+Torrey T. Lyons\
+
+\f0 \'83\'76\'83\'8d\'83\'57\'83\'46\'83\'4e\'83\'67 \'83\'8a\'81\'5b\'83\'5f\'81\'5b
+\f1 \
+Andreas Monitzer\
+ Cocoa
+\f0 \'94\'c5 XDarwin \'83\'74\'83\'8d\'83\'93\'83\'67\'83\'47\'83\'93\'83\'68
+\f1 \
+Greg Parker\
+
+\f0 \'8d\'c5\'8f\'89\'82\'cc Quartz \'83\'43\'83\'93\'83\'76\'83\'8a\'83\'81\'83\'93\'83\'67
+\f1 \
+Christoph Pfisterer\
+
+\f0 \'8b\'a4\'97\'4c\'83\'89\'83\'43\'83\'75\'83\'89\'83\'8a
+\f1 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f0 \cf0 \'93\'63\'92\'86 \'8f\'72\'8c\'f5
+\f1 \
+
+\f0 \'93\'fa\'96\'7b\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
+\f1 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f2\b \cf0 Special Thanks:
+\f1\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Tiago Ribeiro\
+ XDarwin
+\f0 \'83\'41\'83\'43\'83\'52\'83\'93
+\f1 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f2\b \cf0 History:
+\f1\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Carmack\
+
+\f0 XFree86 \'82\'cc Mac OS X Server \'82\'d6\'82\'cc\'8d\'c5\'8f\'89\'82\'cc\'88\'da\'90\'41
+\f1 \
+Dave Zarzycki\
+ XFree86 4.0
+\f0 \'82\'f0 Darwin 1.0 \'82\'c9\'88\'da\'90\'41
+\f1 \
+Torrey T. Lyons\
+ XFree86 4.0.2
+\f0 \'83\'76\'83\'8d\'83\'57\'83\'46\'83\'4e\'83\'67\'82\'d6\'82\'cc\'93\'9d\'8d\'87} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/Imakefile b/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/Imakefile
new file mode 100644
index 000000000..d367fbcee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/Imakefile
@@ -0,0 +1,36 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/Imakefile,v 1.1 2001/05/21 01:42:17 torrey Exp $
+
+#include <Server.tmpl>
+
+LinkSourceFile(InfoPlist.strings.cpp,../English.lproj)
+
+INCLUDES = -I$(SERVERSRC)/include
+
+#if defined (XorgVersionString)
+VERS = XorgVersionString
+PRE = XORG_VERSION_SNAP
+NAME = "X Version 11"
+LINK = '<a HREF="http://wiki.x.org/">X.Org Foundation</a>'
+#elif defined XFree86VersionString
+VERS = XFree86VersionString
+PRE = XF86_VERSION_SNAP
+NAME = "XFree86"
+LINK = '<a HREF="http://www.XFree86.Org/">XFree86 Project, Inc.</a>'
+#endif
+DATE = XFree86DateString
+X_DEFS = $(INCLUDES) -DX_VERSION=$(VERS) -DX_PRE_RELEASE=$(PRE) \
+ -DX_REL_DATE=$(DATE) -DX_VENDOR_NAME=$(NAME) -DX_VENDOR_LINK=$(LINK)
+
+AllTarget(XDarwinHelp.html)
+CppFileTarget(XDarwinHelp.html,XDarwinHelp.html.cpp,$(X_DEFS), \
+ NullParameter)
+
+AllTarget(InfoPlist.strings)
+InfoPlist.strings: InfoPlist.strings.cpp
+ RemoveFile($@)
+ ClearmakeOSName \
+ $(CPP) CppNoLineInfoOption $(X_DEFS) <InfoPlist.strings.cpp | \
+ CppSedMagic | sed 's/__quote__/"/g' >$@
+
+clean::
+ RemoveFiles(InfoPlist.strings)
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/Localizable.strings b/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/Localizable.strings
new file mode 100644
index 000000000..c5c26d61a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/Localizable.strings
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/classes.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/classes.nib
new file mode 100644
index 000000000..77f345a4e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/classes.nib
@@ -0,0 +1,72 @@
+{
+ IBClasses = (
+ {
+ ACTIONS = {showHelp = id; };
+ CLASS = FirstResponder;
+ LANGUAGE = ObjC;
+ SUPERCLASS = NSObject;
+ },
+ {
+ ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; };
+ CLASS = Preferences;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ addToPathButton = id;
+ addToPathField = id;
+ button2ModifiersMatrix = id;
+ button3ModifiersMatrix = id;
+ depthButton = id;
+ displayField = id;
+ dockSwitchButton = id;
+ fakeButton = id;
+ keymapFileField = id;
+ modeMatrix = id;
+ modeWindowButton = id;
+ mouseAccelChangeButton = id;
+ startupHelpButton = id;
+ switchKeyButton = id;
+ systemBeepButton = id;
+ useDefaultShellMatrix = id;
+ useOtherShellField = id;
+ useXineramaButton = id;
+ window = id;
+ };
+ SUPERCLASS = NSObject;
+ },
+ {
+ CLASS = XApplication;
+ LANGUAGE = ObjC;
+ OUTLETS = {preferences = id; xserver = id; };
+ SUPERCLASS = NSApplication;
+ },
+ {
+ ACTIONS = {
+ bringAllToFront = id;
+ closeHelpAndShow = id;
+ itemSelected = id;
+ nextWindow = id;
+ previousWindow = id;
+ showAction = id;
+ showSwitchPanel = id;
+ startFullScreen = id;
+ startRootless = id;
+ };
+ CLASS = XServer;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ dockMenu = NSMenu;
+ helpWindow = NSWindow;
+ modeWindow = NSWindow;
+ startFullScreenButton = NSButton;
+ startRootlessButton = NSButton;
+ startupHelpButton = NSButton;
+ startupModeButton = NSButton;
+ switchWindow = NSPanel;
+ windowMenu = NSMenu;
+ windowSeparator = NSMenuItem;
+ };
+ SUPERCLASS = NSObject;
+ }
+ );
+ IBVersion = 1;
+} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/objects.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/objects.nib
new file mode 100644
index 000000000..357002706
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/objects.nib
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/XDarwinHelp.html.cpp b/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/XDarwinHelp.html.cpp
new file mode 100644
index 000000000..6653f5bea
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/XDarwinHelp.html.cpp
@@ -0,0 +1,141 @@
+<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/Japanese.lproj/XDarwinHelp.html.cpp,v 1.4 2001/11/27 07:27:46 torrey Exp $ -->
+
+<html>
+<head>
+<META http-equiv="Content-Type" content="text/html; charset=EUC-JP">
+<title>
+XDarwin Help</title></head>
+<body>
+<center>
+ <h1>XDarwin X Server for Mac OS X</h1>
+ X_VENDOR_NAME X_VERSION<br>
+ Release Date: X_REL_DATE
+</center>
+<h2>Ìܼ¡</h2>
+<ol>
+ <li><A HREF="#notice">Ãí°Õ»ö¹à</A></li>
+ <li><A HREF="#usage">»ÈÍÑË¡</A></li>
+ <li><A HREF="#path">¥Ñ¥¹¤ÎÀßÄê</A></li>
+ <li><A HREF="#prefs">´Ä¶­ÀßÄê</A></li>
+ <li><A HREF="#license">¥é¥¤¥»¥ó¥¹</A></li>
+</ol>
+<center>
+ <h2><a NAME="notice">Ãí°Õ»ö¹à</a></h2>
+</center>
+<blockquote>
+#if X_PRE_RELEASE
+¤³¤ì¤Ï¡¤XDarwin ¤Î¥×¥ì¥ê¥ê¡¼¥¹¥Ð¡¼¥¸¥ç¥ó¤Ç¤¢¤ê¡¤¤¤¤«¤Ê¤ë¾ì¹ç¤Ë¤ª¤¤¤Æ¤â¥µ¥Ý¡¼¥È¤µ¤ì¤Þ¤»¤ó¡£
+¥Ð¥°¤ÎÊó¹ð¤ä¥Ñ¥Ã¥Á¤¬ SourceForge ¤Î <A HREF="http://sourceforge.net/projects/xonx/">XonX ¥×¥í¥¸¥§¥¯¥È¥Ú¡¼¥¸</A>¤ËÄó½Ð¤µ¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£
+¥×¥ì¥ê¥ê¡¼¥¹¥Ð¡¼¥¸¥ç¥ó¤Î¥Ð¥°¤òÊó¹ð¤¹¤ëÁ°¤Ë¡¤<A HREF="http://sourceforge.net/projects/xonx/">XonX</A> ¥×¥í¥¸¥§¥¯¥È¥Ú¡¼¥¸¤Þ¤¿¤Ï X_VENDOR_LINK¤ÇºÇ¿·ÈǤΥÁ¥§¥Ã¥¯¤ò¤·¤Æ²¼¤µ¤¤¡£
+#else
+¤â¤·¡¤¥µ¡¼¥Ð¡¼¤¬ 6 -12 ¥ö·î°Ê¾åÁ°¤Î¤â¤Î¤«¡¤¤Þ¤¿¤Ï¤¢¤Ê¤¿¤Î¥Ï¡¼¥É¥¦¥§¥¢¤¬¾åµ­¤ÎÆüÉÕ¤è¤ê¤â¿·¤·¤¤¤â¤Î¤Ê¤é¤Ð¡¤ÌäÂê¤òÊó¹ð¤¹¤ëÁ°¤Ë¤è¤ê¿·¤·¤¤¥Ð¡¼¥¸¥ç¥ó¤òõ¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
+¥Ð¥°¤ÎÊó¹ð¤ä¥Ñ¥Ã¥Á¤¬ SourceForge ¤Î <A HREF="http://sourceforge.net/projects/xonx/">XonX ¥×¥í¥¸¥§¥¯¥È¥Ú¡¼¥¸</A>¤ËÄó½Ð¤µ¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£
+#endif
+</blockquote>
+<blockquote>
+ËÜ¥½¥Õ¥È¥¦¥§¥¢¤Ï¡¤<A HREF="#license">MIT X11/X Consortium License</A> ¤Î¾ò·ï¤Ë´ð¤Å¤­¡¤ÌµÊݾڤǡ¤¡Ö¤½¤Î¤Þ¤Þ¡×¤Î·Á¤Ç¶¡µë¤µ¤ì¤Þ¤¹¡£
+¤´»ÈÍѤˤʤëÁ°¤Ë¡¤<A HREF="#license">¥é¥¤¥»¥ó¥¹¾ò·ï</A>¤ò¤ªÆɤ߲¼¤µ¤¤¡£
+</blockquote>
+
+<h2><a NAME="usage">»ÈÍÑË¡</a></h2>
+<p>XDarwin ¤Ï¡¤ºÆÇÛÉÛ²Äǽ¤Ê¥ª¡¼¥×¥ó¥½¡¼¥¹¤Î <a HREF="http://www.x.org/">X Window System</a> ¤Î¤¿¤á¤Î X ¥µ¡¼¥Ð¡¼¤Î¼ÂÁõ¤Ç¤¹¡£¤³¤Î¥Ð¡¼¥¸¥ç¥ó¤Î XDarwin ¤Ï X_VENDOR_LINK ¤Ë¤è¤Ã¤ÆºîÀ®¤µ¤ì¤Þ¤·¤¿¡£XDarwin ¤Ï¡¤Mac OS X ¾å¤Ç¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Þ¤¿¤Ï¥ë¡¼¥È¥ì¥¹¥â¡¼¥É¤ÇÆ°ºî¤·¤Þ¤¹¡£</p>
+
+<p>¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Ç¤Ï¡¤X Window System ¤¬¥¢¥¯¥Æ¥£¥Ö¤Ê»þ¡¤¤½¤ì¤ÏÁ´²èÌ̤òÀêÍ­¤·¤Þ¤¹¡£
+¤¢¤Ê¤¿¤Ï¡¤Command-Option-A ¥­¡¼¤ò²¡¤¹¤³¤È¤Ë¤è¤Ã¤Æ Mac OS X ¥Ç¥¹¥¯¥È¥Ã¥×¤ØÀÚ¤êÂؤ¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤³¤Î¥­¡¼¤ÎÁȤ߹ç¤ï¤»¤Ï¡¤´Ä¶­ÀßÄê¤ÇÊѹ¹²Äǽ¤Ç¤¹¡£
+Mac OS X ¥Ç¥¹¥¯¥È¥Ã¥×¤«¤é X Window System ¤ØÀÚ¤êÂؤ¨¤ë¾ì¹ç¤Ï¡¤¥É¥Ã¥¯¤Ëɽ¼¨¤µ¤ì¤¿ XDarwin ¥¢¥¤¥³¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ²¼¤µ¤¤¡£
+¡Ê´Ä¶­ÀßÄê¤Ç¡¤¥Õ¥í¡¼¥Æ¥£¥ó¥°¡¦¥¦¥£¥ó¥É¥¦¤Ëɽ¼¨¤µ¤ì¤¿ XDarwin ¥¢¥¤¥³¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤è¤¦¤ËÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¡Ë</p>
+
+<p>¥ë¡¼¥È¥ì¥¹¥â¡¼¥É¤Ç¤Ï¡¤X Window System ¤È Aqua ¤Ï²èÌ̤ò¶¦Í­¤·¤Þ¤¹¡£
+X11 ¤¬É½¼¨¤¹¤ë¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤Ï²èÌ̤Υµ¥¤¥º¤Ç¤¢¤ê¡¤Â¾¤ÎÁ´¤Æ¤Î¥¦¥£¥ó¥É¥¦¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£
+Aqua ¤¬¥Ç¥¹¥¯¥È¥Ã¥×¤ÎÇطʤòÀ©¸æ¤¹¤ë¤Î¤Ç¡¤X11 ¤Î¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤Ï¥ë¡¼¥È¥ì¥¹¥â¡¼¥É¤Ç¤Ïɽ¼¨¤µ¤ì¤Þ¤»¤ó¡£</p>
+
+<h3>Ê£¿ô¥Ü¥¿¥ó¥Þ¥¦¥¹¤Î¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó</h3>
+<p>¿¤¯¤Î X11 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¤3 ¥Ü¥¿¥ó¥Þ¥¦¥¹¤òɬÍפȤ·¤Þ¤¹¡£
+¤¢¤Ê¤¿¤Ï¥Þ¥¦¥¹¥Ü¥¿¥ó¤Î¥¯¥ê¥Ã¥¯¤ÈƱ»þ¤Ë¤¤¤¯¤Ä¤«¤Î½¤¾þ¥­¡¼¤ò²¡¤¹¤³¤È¤Ë¤è¤Ã¤Æ¡¤°ì¤Ä¤Î¥Ü¥¿¥ó¤Ç 3 ¥Ü¥¿¥ó¥Þ¥¦¥¹¤ò¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+¤³¤ì¤Ï¡¤´Ä¶­ÀßÄê¤Î¡Ö°ìÈÌÀßÄê¡×¤Î¡ÖÊ£¿ô¥Ü¥¿¥ó¥Þ¥¦¥¹¤Î¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¡×¥»¥¯¥·¥ç¥ó¤ÇÀßÄꤷ¤Þ¤¹¡£
+¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¤¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤ÏÍ­¸ú¤Ç¡¤¥³¥Þ¥ó¥É¥­¡¼¤ò²¡¤·¤Ê¤¬¤é¥Þ¥¦¥¹¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤³¤È¤ÏÂè 2 ¥Þ¥¦¥¹¥Ü¥¿¥ó¤Î¥¯¥ê¥Ã¥¯¤ËÁêÅö¤·¤Þ¤¹¡£
+¥ª¥×¥·¥ç¥ó¥­¡¼¤ò²¡¤·¤Ê¤¬¤é¥¯¥ê¥Ã¥¯¤¹¤ë¤³¤È¤ÏÂè 3 ¥Þ¥¦¥¹¥Ü¥¿¥ó¤Î¥¯¥ê¥Ã¥¯¤ËÁêÅö¤·¤Þ¤¹¡£
+¤¢¤Ê¤¿¤Ï¡¤´Ä¶­ÀßÄê¤Ç¥Ü¥¿¥ó 2 ¤È 3 ¤ò¥¨¥ß¥å¥ì¡¼¥È¤¹¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë½¤¾þ¥­¡¼¤ÎÁȹ礻¤òÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+Ãí¡§½¤¾þ¥­¡¼¤ò xmodmap ¤Ç¾¤Î¥­¡¼¤Ë³ä¤êÅö¤Æ¤Æ¤¤¤ë¾ì¹ç¤Ç¤â¡¤Ê£¿ô¥Ü¥¿¥ó¥Þ¥¦¥¹¤Î¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤Ç¤ÏËÜÍè¤Î¥³¥Þ¥ó¥É¥­¡¼¤ä¥ª¥×¥·¥ç¥ó¥­¡¼¤ò»È¤ï¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£</p>
+
+<h2><a NAME="path">¥Ñ¥¹¤ÎÀßÄê</a></h2>
+<p>¥Ñ¥¹¤Ï¡¤ ¼Â¹Ô²Äǽ¤Ê¥³¥Þ¥ó¥É¤ò¸¡º÷¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¤Î¥ê¥¹¥È¤Ç¤¹¡£
+X11 ¥Ð¥¤¥Ê¥ê¤Ï¡¤<code>/usr/X11R6/bin</code> ¤ËÃÖ¤«¤ì¤Þ¤¹¡£¤¢¤Ê¤¿¤Ï¤½¤ì¤ò¥Ñ¥¹¤Ë²Ã¤¨¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
+XDarwin ¤Ï¡¤¤³¤ì¤ò¥Ç¥Õ¥©¥ë¥È¤Ç¹Ô¤¤¤Þ¤¹¡£¤Þ¤¿¡¤¤¢¤Ê¤¿¤¬¥³¥Þ¥ó¥É¥é¥¤¥ó¡¦¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò¥¤¥ó¥¹¥È¡¼¥ë¤·¤¿ÄɲäΥǥ£¥ì¥¯¥È¥ê¤ò²Ã¤¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£</p>
+
+<p>·Ð¸³Ë­¤«¤Ê¥æ¡¼¥¶¡¼¤Ï¡¤¤¹¤Ç¤Ë¼«¤é¤Î¥·¥§¥ë¤Î¤¿¤á¤Ë½é´ü²½¥Õ¥¡¥¤¥ë¤ò»ÈÍѤ·¤Æ¥Ñ¥¹¤òÀßÄꤷ¤Æ¤¤¤ë¤Ç¤·¤ç¤¦¡£
+¤³¤Î¾ì¹ç¡¤¤¢¤Ê¤¿¤Ï´Ä¶­ÀßÄê¤Ç XDarwin ¤¬¤¢¤Ê¤¿¤Î¥Ñ¥¹¤òÊѹ¹¤·¤Ê¤¤¤è¤¦¤ËÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+XDarwin ¤Ï¡¤¥æ¡¼¥¶¡¼¤Î¥Ç¥Õ¥©¥ë¥È¤Î¥í¥°¥¤¥ó¥·¥§¥ë¤ÇºÇ½é¤Î X11 ¥¯¥é¥¤¥¢¥ó¥È¤ò³«»Ï¤·¤Þ¤¹¡£
+¡Ê´Ä¶­ÀßÄê¤ÇÂå¤ï¤ê¤Î¥·¥§¥ë¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¡Ë
+¥Ñ¥¹¤òÀßÄꤹ¤ëÊýË¡¤Ï¡¤¤¢¤Ê¤¿¤¬»ÈÍѤ·¤Æ¤¤¤ë¥·¥§¥ë¤Ë°Í¸¤·¤Þ¤¹¡£
+¤³¤ì¤Ï¡¤¥·¥§¥ë¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¥É¥­¥å¥á¥ó¥È¤Ëµ­ºÜ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
+
+<p>¤Þ¤¿¡¤¤¢¤Ê¤¿¤Ï¥É¥­¥å¥á¥ó¥È¤òõ¤·¤Æ¤¤¤ë»þ¡¤X11 ¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤ò¸¡º÷¤µ¤ì¤ë¥Ú¡¼¥¸¤Î¥ê¥¹¥È¤ËÄɲä·¤¿¤¤¤È»×¤¦¤«¤â¤·¤ì¤Þ¤»¤ó¡£
+X11 ¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤Ï <code>/usr/X11R6/man</code> ¤ËÃÖ¤«¤ì¤Þ¤¹¡£¤½¤·¤Æ <code>MANPATH</code> ´Ä¶­ÊÑ¿ô¤Ï¸¡º÷¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¤Î¥ê¥¹¥È¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£</p>
+
+<h2><a NAME="prefs">´Ä¶­ÀßÄê</a></h2>
+<p>¡ÖXDarwin¡×¥á¥Ë¥å¡¼¤Î¡Ö´Ä¶­ÀßÄê...¡×¥á¥Ë¥å¡¼¹àÌܤ«¤é¥¢¥¯¥»¥¹¤Ç¤­¤ë´Ä¶­ÀßÄê¥Ñ¥Í¥ë¤Ç¡¤¤¤¤¯¤Ä¤«¤Î¥ª¥×¥·¥ç¥ó¤òÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+¡Öµ¯Æ°¥ª¥×¥·¥ç¥ó¡×¤ÎÆâÍƤϡ¤XDarwin ¤òºÆµ¯Æ°¤¹¤ë¤Þ¤ÇÍ­¸ú¤È¤Ê¤ê¤Þ¤»¤ó¡£
+¾¤ÎÁ´¤Æ¤Î¥ª¥×¥·¥ç¥ó¤ÎÆâÍƤϡ¤Ä¾¤Á¤ËÍ­¸ú¤È¤Ê¤ê¤Þ¤¹¡£
+°Ê²¼¡¤¤½¤ì¤¾¤ì¤Î¥ª¥×¥·¥ç¥ó¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤¹:</p>
+
+<h3>°ìÈÌÀßÄê</h3>
+<ul>
+ <li><b>X11 ¤Ç¥·¥¹¥Æ¥à¤Î¥Ó¡¼¥×²»¤ò»ÈÍѤ¹¤ë:</b> ¥ª¥ó¤Î¾ì¹ç¡¤Mac OS X ¤Î¥Ó¡¼¥×²»¤¬ X11 ¤Î¥Ù¥ë¤È¤·¤Æ»ÈÍѤµ¤ì¤Þ¤¹¡£¥ª¥Õ¤Î¾ì¹ç¡Ê¥Ç¥Õ¥©¥ë¥È¡Ë¡¤¥·¥ó¥×¥ë ¥È¡¼¥ó¤¬»È¤ï¤ì¤Þ¤¹¡£</li>
+ <li><b>X11 ¤Î¥Þ¥¦¥¹¥¢¥¯¥»¥é¥ì¡¼¥·¥ç¥ó¤òÍ­¸ú¤Ë¤¹¤ë:</b> ɸ½àŪ¤Ê X Window System ¤Î¼ÂÁõ¤Ç¤Ï¡¤¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¡¼¤Ï¥Þ¥¦¥¹¤Î²Ã®ÅÙ¤òÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+ ¥Þ¥¦¥¹¤Î²Ã®ÅÙ¤Ë Mac OS X ¤Î¥·¥¹¥Æ¥à´Ä¶­ÀßÄê¤È X ¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¡¼¤¬°Û¤Ê¤ëÃͤòÀßÄꤷ¤¿¾ì¹ç¡¤¤³¤ì¤Ïº®Íð¤ò¾·¤­¤Þ¤¹¡£
+ ¤³¤ÎÌäÂê¤òÈò¤±¤ë¤¿¤á¡¤¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï X11 ¤Î¥Þ¥¦¥¹¥¢¥¯¥»¥é¥ì¡¼¥·¥ç¥ó¤òÍ­¸ú¤È¤·¤Þ¤»¤ó¡£</li>
+ <li><b>Ê£¿ô¥Ü¥¿¥ó¥Þ¥¦¥¹¤Î¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó:</b> <a HREF="#usage">»ÈÍÑË¡</a>¤ò»²¾È¤·¤Æ²¼¤µ¤¤¡£¥ª¥ó¤Î¾ì¹ç¡¤¥Þ¥¦¥¹¥Ü¥¿¥ó¤¬Âè 2 ¤Þ¤¿¤ÏÂè 3 ¤Î¥Þ¥¦¥¹¥Ü¥¿¥ó¤ò¥¨¥ß¥å¥ì¡¼¥È¤¹¤ë»þ¤Ë¡¤ÁªÂò¤·¤¿½¤¾þ¥­¡¼¤òƱ»þ¤Ë²¡¤·¤Þ¤¹¡£</li>
+</ul>
+
+<h3>µ¯Æ°¥ª¥×¥·¥ç¥ó</h3>
+<ul>
+ <li><b>²èÌ̥⡼¥É:</b> ¥æ¡¼¥¶¡¼¤¬¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Þ¤¿¤Ï¥ë¡¼¥È¥ì¥¹¥â¡¼¥É¤Î¤É¤Á¤é¤ò»ÈÍѤ¹¤ë¤«¤ò»ØÄꤷ¤Ê¤¤¾ì¹ç¡¤¤³¤³¤Ç»ØÄꤵ¤ì¤¿¥â¡¼¥É¤¬»È¤ï¤ì¤Þ¤¹¡£</li>
+ <li><b>µ¯Æ°»þ¤Ë¥â¡¼¥ÉÁªÂò¥Ñ¥Í¥ë¤òɽ¼¨¤¹¤ë:</b> ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¤XDarwin ¤Îµ¯Æ°»þ¤Ë¥æ¡¼¥¶¡¼¤¬¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Þ¤¿¤Ï¥ë¡¼¥È¥ì¥¹¥â¡¼¥É¤Î¤É¤Á¤é¤ò»ÈÍѤ¹¤ë¤«¤òÁªÂò¤¹¤ë¥Ñ¥Í¥ë¤òɽ¼¨¤·¤Þ¤¹¡£¤³¤Î¥ª¥×¥·¥ç¥ó¤¬¥ª¥Õ¤Î¾ì¹ç¡¤²èÌ̥⡼¥É¤Ç»ØÄꤷ¤¿¥â¡¼¥É¤Çµ¯Æ°¤·¤Þ¤¹¡£</li>
+ <li><b>X11 ¥Ç¥£¥¹¥×¥ì¥¤ÈÖ¹æ:</b> X11¤Ï¡¤°ì¤Ä¤Î¥³¥ó¥Ô¥å¡¼¥¿¾å¤ÇÊÌ¡¹¤Î X ¥µ¡¼¥Ð¡¼¤¬´ÉÍý¤¹¤ëÊ£¿ô¤Î¥Ç¥£¥¹¥×¥ì¥¤¤¬Â¸ºß¤¹¤ë¤³¤È¤òµö¤·¤Þ¤¹¡£Ê£¿ô¤Î X ¥µ¡¼¥Ð¡¼¤¬Æ±»þ¤Ë¼Â¹Ô¤·¤Æ¤¤¤ë»þ¡¤XDarwin ¤¬»ÈÍѤ¹¤ë¥Ç¥£¥¹¥×¥ì¥¤¤ÎÈÖ¹æ¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£</li>
+ <li><b>Xinerama ¥Þ¥ë¥Á¥â¥Ë¥¿¥µ¥Ý¡¼¥È¤òÍ­¸ú¤Ë¤¹¤ë:</b> XDarwin ¤Ï¡¤Xinerama ¥Þ¥ë¥Á¥â¥Ë¥¿¤ò¥µ¥Ý¡¼¥È¤·¤Þ¤¹¡£¤½¤ì¤ÏÁ´¤Æ¤Î¥â¥Ë¥¿¤ò°ì¤Ä¤ÎÂ礭¤Ê²èÌ̤ΰìÉô¤È¤ß¤Ê¤·¤Þ¤¹¡£¤¢¤Ê¤¿¤Ï¤³¤Î¥ª¥×¥·¥ç¥ó¤Ç Xinerama ¤ò̵¸ú¤Ë¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤¿¤À¤·¡¤¸½ºß XDarwin ¤Ï¤½¤ì̵¤·¤ÇÀµ¤·¤¯Ê£¿ô¤Î¥â¥Ë¥¿¤ò°·¤¦¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¡£¤â¤·¡¤¤¢¤Ê¤¿¤¬°ì¤Ä¤Î¥â¥Ë¥¿¤ò»È¤¦¤À¤±¤Ê¤é¤Ð¡¤Xinerama ¤Ï¼«Æ°Åª¤Ë̵¸ú¤È¤Ê¤ê¤Þ¤¹¡£</li>
+ <li><b>¥­¡¼¥Þ¥Ã¥Ô¥ó¥°¥Õ¥¡¥¤¥ë:</b> ¥­¡¼¥Þ¥Ã¥Ô¥ó¥°¥Õ¥¡¥¤¥ë¤Ïµ¯Æ°»þ¤ËÆɤ߹þ¤Þ¤ì¡¤X11 ¥­¡¼¥Þ¥Ã¥×¤ËÊÑ´¹¤µ¤ì¤Þ¤¹¡£Â¾¸À¸ì¤ËÂбþ¤·¤¿¥­¡¼¥Þ¥Ã¥Ô¥ó¥°¥Õ¥¡¥¤¥ë¤Ï <code>/System/Library/Keyboards</code> ¤Ë¤¢¤ê¤Þ¤¹¡£¡ÊÌõÃí¡§¥­¡¼¥Þ¥Ã¥Ô¥ó¥°¤Ç Japanese ¤òÁªÂò¤¹¤ë¤È¡¤°ìÉô¤Î¥­¡¼¤¬¸ú¤«¤Ê¤¤Åù¤ÎÉÔ¶ñ¹ç¤¬È¯À¸¤¹¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£¤³¤Î¾ì¹ç¤Ï USA ¤òÁªÂò¤·¤¿¾å¤Ç ~/.Xmodmap ¤òŬÍѤ·¤Æ²¼¤µ¤¤¡£¡Ë</li>
+ <li><b>ºÇ½é¤Î X11 ¥¯¥é¥¤¥¢¥ó¥È¤Îµ¯Æ°:</b> XDarwin ¤¬ Finder¤«¤éµ¯Æ°¤¹¤ë»þ¡¤X ¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¡¼¤È X ¥¯¥é¥¤¥¢¥ó¥È¤Îµ¯Æ°¤Ï <code>xinit</code> ¤ò¼Â¹Ô¤·¤Þ¤¹¡£¡Ê¾ÜºÙ¤Ï "<code>man xinit</code>" ¤ò»²¾È¤·¤Æ²¼¤µ¤¤¡£¡ËXDarwin ¤Ï <code>xinit</code> ¤ò¼Â¹Ô¤¹¤ëÁ°¤Ë¡¤»ØÄꤵ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¤ò¥æ¡¼¥¶¡¼¤Î¥Ñ¥¹¤ËÄɲä·¤Þ¤¹¡£¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï <code>/usr/X11R6/bin</code> ¤À¤±¤òÄɲä·¤Þ¤¹¡£Â¾¤Î¥Ç¥£¥ì¥¯¥È¥ê¤òÄɲä·¤¿¤¤¾ì¹ç¤Ï¡¤¥³¥í¥ó¤Ç¶èÀڤäƻØÄꤷ¤Þ¤¹¡£¥æ¡¼¥¶¡¼¤Î¥·¥§¥ë½é´ü²½¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤à¤¿¤á¤Ë¡¤X ¥¯¥é¥¤¥¢¥ó¥È¤Ï¥æ¡¼¥¶¡¼¤Î¥Ç¥Õ¥©¥ë¥È¥í¥°¥¤¥ó¥·¥§¥ë¤Çµ¯Æ°¤µ¤ì¤Þ¤¹¡£É¬ÍפǤ¢¤ì¤Ð¡¤Âå¤ï¤ê¤Î¥·¥§¥ë¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£</li>
+</ul>
+
+<h3>¥Õ¥ë¥¹¥¯¥ê¡¼¥ó</h3>
+<ul>
+ <li><b>¥­¡¼ÀßÄê¥Ü¥¿¥ó:</b> X11 ¤È Aqua ¤òÀÚ¤êÂؤ¨¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë¥Ü¥¿¥ó¤ÎÁȤ߹ç¤ï¤»¤ò»ØÄꤷ¤Þ¤¹¡£
+ ¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¡¤Ç¤°Õ¤Î¿ô¤Î½¤¾þ¥­¡¼¤Ë³¤¤¤ÆÄ̾ï¤Î¥­¡¼¤ò²¡¤·¤Þ¤¹¡£</li>
+ <li><b>¥É¥Ã¥¯¤Î¥¢¥¤¥³¥ó¤Î¥¯¥ê¥Ã¥¯¤Ç X11 ¤ËÌá¤ë:</b> ¥ª¥ó¤Î¾ì¹ç¡¤¥É¥Ã¥¯¤Ëɽ¼¨¤µ¤ì¤¿ XDarwin ¥¢¥¤¥³¥ó¤Î¥¯¥ê¥Ã¥¯¤Ç X11 ¤Ø¤ÎÀڤ괹¤¨¤¬²Äǽ¤È¤Ê¤ê¤Þ¤¹¡£Mac OS X ¤Î¤¤¤¯¤Ä¤«¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ï¡¤¥É¥Ã¥¯¤Î¥¢¥¤¥³¥ó¤Î¥¯¥ê¥Ã¥¯¤Ç Aqua ¤ËÌá¤Ã¤¿»þ¡¤¥«¡¼¥½¥ë¤¬¾Ã¼º¤¹¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£</li>
+ <li><b>µ¯Æ°»þ¤Ë¥Ø¥ë¥×¤òɽ¼¨¤¹¤ë:</b> XDarwin ¤¬¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Çµ¯Æ°¤¹¤ë»þ¡¤¥¹¥×¥é¥Ã¥·¥å¥¹¥¯¥ê¡¼¥ó¤òɽ¼¨¤·¤Þ¤¹¡£</li>
+ <li><b>¿§¿¼ÅÙ:</b> ¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Ç¤Ï¡¤X11 ¥Ç¥£¥¹¥×¥ì¥¤¤¬ Aqua ¤È°Û¤Ê¤ë¿§¿¼ÅÙ¤ò»È¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¡ÖÊѹ¹¤Ê¤·¡×¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¤XDarwin ¤Ï Aqua ¤Ë¤è¤Ã¤Æ»ÈÍѤµ¤ì¤ë¿§¿¼ÅÙ¤ò»È¤¤¤Þ¤¹¡£¤³¤ì°Ê³°¤Ë 8¡¤15 ¤Þ¤¿¤Ï24 ¥Ó¥Ã¥È¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£</li>
+</ul>
+
+<h2>
+<a NAME="license">¥é¥¤¥»¥ó¥¹</a>
+</h2>
+XDarwin ¤Î¼çÍפʥ饤¥»¥ó¥¹¤ÏÅÁÅýŪ¤Ê MIT X11/X Consortium License ¤Ë´ð¤Å¤­¤Þ¤¹¡£
+¤½¤ì¤Ï½¤Àµ¤Þ¤¿¤ÏºÆÇÛÉÛ¤µ¤ì¤ë¥½¡¼¥¹¥³¡¼¥É¤Þ¤¿¤Ï¥Ð¥¤¥Ê¥ê¤Ë¡¤¤½¤ÎÃøºî¸¢/¥é¥¤¥»¥ó¥¹É½¼¨¤¬¤½¤Î¤Þ¤Þ»Ä¤µ¤ì¤ë¤³¤È¤òÍ׵᤹¤ë°Ê³°¤Î¾ò·ï¤ò¶¯À©¤·¤Þ¤»¤ó¡£
+¤è¤ê¿¤¯¤Î¾ðÊó¤È¡¤¥³¡¼¥É¤Î°ìÉô¤ò¥«¥Ð¡¼¤¹¤ëÄɲäÎÃøºî¸¢/¥é¥¤¥»¥ó¥¹É½¼¨¤Î¤¿¤á¤Ë¡¤¥½¡¼¥¹¥³¡¼¥É¤ò»²¾È¤·¤Æ²¼¤µ¤¤¡£
+<H3>
+<A NAME="3"></A>
+X Consortium License</H3>
+<p>Copyright (C) 1996 X Consortium</p>
+<p>Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without
+limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to
+whom the Software is furnished to do so, subject to the following conditions:</p>
+<p>The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.</p>
+<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.</p>
+<p>Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization from
+the X Consortium.</p>
+<p>X Window System is a trademark of X Consortium, Inc.</p>
+</body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/Credits.rtf b/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/Credits.rtf
new file mode 100644
index 000000000..8dcddc2f7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/Credits.rtf
@@ -0,0 +1,171 @@
+{\rtf1\mac\ansicpg10000\cocoartf102
+{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fswiss\fcharset77 Helvetica-Oblique;
+}
+{\colortbl;\red255\green255\blue255;}
+\vieww5140\viewh4980\viewkind0
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\fs24 \cf0 This product includes software developed by The XFree86 Project, Inc (http://www.xfree86.org/) and its contributors. The following people contributed to Darwin/Mac OS X support.\
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Contributors to Xorg Foundation Release:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Kaleb KEITHLEY\
+
+\f2\i Working left and right Ctrl, Alt (Option), Meta (Command) and Shift keys.
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\f1\b \cf0 Contributors to XFree86 4.4:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Harper\
+
+\f2\i Rootless acceleration and Apple-WM extension
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Contribuidores do XonX ao XFree86 4.3:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Fabr\'92cio Luis de Castro
+\f1\b \
+
+\f2\i\b0 Localiza\'8d\'8bo para o Portugu\'90s\
+
+\f0\i0 Michael Oland\
+
+\f2\i New XDarwin icon
+\f1\i0\b \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Contribuidores do XonX ao XFree86 4.2:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+
+\f2\i Suporte para o Darwin x86\
+
+\f0\i0 Pablo Di Noto\
+
+\f2\i Localiza\'8d\'8bo para o Espanhol
+\f0\i0 \
+Paul Edens\
+
+\f2\i Localiza\'8d\'8bo para o Holand\'90s
+\f0\i0 \
+Kyunghwan Kim\
+
+\f2\i Localiza\'8d\'8bo para o Coreano
+\f0\i0 \
+Mario Klebsch\
+
+\f2\i Suporte para teclados Non-US
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i L\'92der de Projeto
+\f0\i0 \
+Andreas Monitzer\
+
+\f2\i Localiza\'8d\'8bo para o Alem\'8bo
+\f0\i0 \
+Patrik Montgomery\
+
+\f2\i Localiza\'8d\'8bo para o Sueco
+\f0\i0 \
+Greg Parker\
+
+\f2\i Suporte ao modo Compartilhado (Rootless)
+\f0\i0 \
+Toshimitsu Tanaka\
+
+\f2\i Localiza\'8d\'8bo para o Japon\'90s
+\f0\i0 \
+Olivier Verdier\
+
+\f2\i Localiza\'8d\'8bo para o Fran\'8d\'90s
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Agradecimentos Especiais:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Devin Poolman and Zero G Software, Inc.\
+
+\f2\i Instalador
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Membros do Time XonX\
+Contribuindo com o XFree86 4.1:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+
+\f2\i Suporte ao Darwin x86\
+
+\f0\i0 Torrey T. Lyons\
+
+\f2\i L\'92der de Projeto
+\f0\i0 \
+Andreas Monitzer\
+
+\f2\i Vers\'8bo Cocoa da interface XDarwin
+\f0\i0 \
+Greg Parker\
+
+\f2\i Implementa\'8d\'8bo Original
+\f0\i0
+\f2\i ao Quartz \
+
+\f0\i0 Christoph Pfisterer\
+
+\f2\i Bibliotecas Din\'89micas Compartilhadas
+\f0\i0 \
+Toshimitsu Tanaka\
+
+\f2\i Localiza\'8d\'8bo para o Japon\'90s
+\f0\i0 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Agradecimento Especial:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Tiago Ribeiro\
+
+\f2\i \'eacone do XDarwin
+\f0\i0 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Hist\'97rico:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Carmack\
+
+\f2\i Suporte Original do XFree86 no Mac OS X Server
+\f0\i0 \
+Dave Zarzycki\
+
+\f2\i Suporte ao
+\f0\i0
+\f2\i XFree86 4.0 no Darwin 1.0
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Integra\'8d\'8bo dentro do Projeto XFree86 na vers\'8bo 4.0.2} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/Imakefile b/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/Imakefile
new file mode 100644
index 000000000..d367fbcee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/Imakefile
@@ -0,0 +1,36 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/Imakefile,v 1.1 2001/05/21 01:42:17 torrey Exp $
+
+#include <Server.tmpl>
+
+LinkSourceFile(InfoPlist.strings.cpp,../English.lproj)
+
+INCLUDES = -I$(SERVERSRC)/include
+
+#if defined (XorgVersionString)
+VERS = XorgVersionString
+PRE = XORG_VERSION_SNAP
+NAME = "X Version 11"
+LINK = '<a HREF="http://wiki.x.org/">X.Org Foundation</a>'
+#elif defined XFree86VersionString
+VERS = XFree86VersionString
+PRE = XF86_VERSION_SNAP
+NAME = "XFree86"
+LINK = '<a HREF="http://www.XFree86.Org/">XFree86 Project, Inc.</a>'
+#endif
+DATE = XFree86DateString
+X_DEFS = $(INCLUDES) -DX_VERSION=$(VERS) -DX_PRE_RELEASE=$(PRE) \
+ -DX_REL_DATE=$(DATE) -DX_VENDOR_NAME=$(NAME) -DX_VENDOR_LINK=$(LINK)
+
+AllTarget(XDarwinHelp.html)
+CppFileTarget(XDarwinHelp.html,XDarwinHelp.html.cpp,$(X_DEFS), \
+ NullParameter)
+
+AllTarget(InfoPlist.strings)
+InfoPlist.strings: InfoPlist.strings.cpp
+ RemoveFile($@)
+ ClearmakeOSName \
+ $(CPP) CppNoLineInfoOption $(X_DEFS) <InfoPlist.strings.cpp | \
+ CppSedMagic | sed 's/__quote__/"/g' >$@
+
+clean::
+ RemoveFiles(InfoPlist.strings)
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/Localizable.strings b/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/Localizable.strings
new file mode 100644
index 000000000..c79b282f6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/Localizable.strings
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/classes.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/classes.nib
new file mode 100644
index 000000000..77f345a4e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/classes.nib
@@ -0,0 +1,72 @@
+{
+ IBClasses = (
+ {
+ ACTIONS = {showHelp = id; };
+ CLASS = FirstResponder;
+ LANGUAGE = ObjC;
+ SUPERCLASS = NSObject;
+ },
+ {
+ ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; };
+ CLASS = Preferences;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ addToPathButton = id;
+ addToPathField = id;
+ button2ModifiersMatrix = id;
+ button3ModifiersMatrix = id;
+ depthButton = id;
+ displayField = id;
+ dockSwitchButton = id;
+ fakeButton = id;
+ keymapFileField = id;
+ modeMatrix = id;
+ modeWindowButton = id;
+ mouseAccelChangeButton = id;
+ startupHelpButton = id;
+ switchKeyButton = id;
+ systemBeepButton = id;
+ useDefaultShellMatrix = id;
+ useOtherShellField = id;
+ useXineramaButton = id;
+ window = id;
+ };
+ SUPERCLASS = NSObject;
+ },
+ {
+ CLASS = XApplication;
+ LANGUAGE = ObjC;
+ OUTLETS = {preferences = id; xserver = id; };
+ SUPERCLASS = NSApplication;
+ },
+ {
+ ACTIONS = {
+ bringAllToFront = id;
+ closeHelpAndShow = id;
+ itemSelected = id;
+ nextWindow = id;
+ previousWindow = id;
+ showAction = id;
+ showSwitchPanel = id;
+ startFullScreen = id;
+ startRootless = id;
+ };
+ CLASS = XServer;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ dockMenu = NSMenu;
+ helpWindow = NSWindow;
+ modeWindow = NSWindow;
+ startFullScreenButton = NSButton;
+ startRootlessButton = NSButton;
+ startupHelpButton = NSButton;
+ startupModeButton = NSButton;
+ switchWindow = NSPanel;
+ windowMenu = NSMenu;
+ windowSeparator = NSMenuItem;
+ };
+ SUPERCLASS = NSObject;
+ }
+ );
+ IBVersion = 1;
+} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/objects.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/objects.nib
new file mode 100644
index 000000000..9cb67cf89
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/objects.nib
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/XDarwinHelp.html.cpp b/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/XDarwinHelp.html.cpp
new file mode 100644
index 000000000..7ef1ba5d8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/XDarwinHelp.html.cpp
@@ -0,0 +1,211 @@
+<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.2 2001/11/04 07:02:28 torrey Exp $ --><html><body>
+
+<head>
+<title>XDarwin Help</title>
+</head>
+
+<center>
+
+ <h1>XDarwin X Server para Mac OS X</h1>
+ X_VENDOR_NAME X_VERSION<br>
+ Release Date: X_REL_DATE
+</center>
+<h2>&Iacute;ndice</h2>
+<ol>
+ <li><A HREF="#notice">Notas importantes</A></li>
+ <li><A HREF="#usage">Uso</A></li>
+ <li><A HREF="#path">Ajustando seu Path</A></li>
+
+ <li><A HREF="#prefs">Prefer&ecirc;ncias do usu&aacute;rio</A></li>
+ <li><A HREF="#license">Licen&ccedil;a</A></li>
+</ol>
+<center>
+ <h2><a NAME="notice">Notas importantes</a></h2>
+</center>
+<blockquote>
+#if PRE_RELEASE
+ Essa &eacute; uma vers&atilde;o pr&eacute;-lancamento
+ do XDarwin, e ela n&atilde;o &eacute; suportada de nenhuma forma. Bugs podem
+ ser reportados e corre&ccedil;&otilde;es podem ser enviadas para <A HREF="http://sourceforge.net/projects/xonx/">P&aacute;gina
+ do projeto XonX</A> no SourceForge. Antes de informar bugs em vers&otilde;es
+ pr&eacute;-lancamento, por favor verifique a þltima vers&atilde;o em <A HREF="http://sourceforge.net/projects/xonx/">XonX</A>
+ or X_VENDOR_LINK.
+#else
+Se o servidor &eacute; mais velho que 6-12 semanas, ou seu hardware &eacute;
+ mais novo que a data acima, procure por uma nova vers&atilde;o antes de informar
+ problemas. Bugs podem ser reportados e corre&ccedil;&otilde;es podem ser enviadas
+ para a <A HREF="http://sourceforge.net/projects/xonx/">P&aacute;gina do projeto
+ XonX</A> na SourceForge.
+#endif
+</blockquote>
+<blockquote> Este software &eacute; distribu&iacute;do sob os termos da <a href="#license">licen&ccedil;a
+ MIT X11 / X Consortium</a> e &eacute; provido, sem nenhuma garantia. Por favor
+ leia a <a href="#license">Licen&ccedil;a</a> antes de come&ccedil;ar a usar
+ o programa.</blockquote>
+
+<h2><a NAME="usage">Uso</a></h2>
+<p>O XDarwin &eacute; uma X server &quot;open-source&quot; livremente
+ redistribu&iacute;da do <a HREF
+="http://www.x.org/">Sistema X Window</a>. This version of XDarwin was produced by the X_VENDOR_LINK.
+ XDarwin roda sobre Mac OS X no modo Tela Cheia ou no modo Compartilhado.</p>
+<p>No modo Tela Cheia, quando o sistema X window est&aacute; ativo, ele ocupa
+ a tela toda. Voc&ecirc; pode voltar ao desktop do Mac OS X clicando Command-Option-A.
+ Essa combina&ccedil;&atilde;o de teclas pode ser mudada nas prefer&ecirc;ncias.
+ Pelo desktop Mac OS X, clique no &iacute;cone XDarwin no Dock para voltar ao
+ sistema X window. (Voc&ecirc; pode mudar esse comportamento nas prefer&ecirc;ncias
+ da&iacute; voc&ecirc; dever&aacute; clicar no &iacute;cone XDarwin na janela
+ flutuante que aparecer&aacute;.)</p>
+<p>No modo Compartilhado, o sistema X window e Aqua dividem a mesma tela. A janela
+ raiz da tela X11 est&aacute; do tamanho da tela (monitor) e cont&eacute;m todas
+ as outras janelas. A janela raiz do X11 no modo compartilhado n&atilde;o &eacute;
+ mostrada pois o Aqua controla o fundo de tela.</p>
+<h3>Emula&ccedil;&atilde;o de Mouse Multi-Bot&otilde;es</h3>
+<p>Muitas aplica&ccedil;&otilde;es X11 insistem em usar um mouse de 3 bot&otilde;es.
+ Voc&ecirc; pode emular um mouse de 3 bot&otilde;es com um simples bot&atilde;o,
+ mantendo pressionando teclas modificadoras enquanto voc&ecirc; clica no bot&atilde;o
+ do mouse. Isto &eacute; controlado pela configura&ccedil;&atilde;o da &quot;Emula&ccedil;&atilde;o
+ de Mouse Multi-Bot&otilde;es&quot; da prefer&ecirc;ncia &quot;Geral&quot;. Por
+ padr&atilde;o, a emula&ccedil;&atilde;o est&aacute; habilitada e mantendo pressionada
+ a tecla Command e clicando no bot&atilde;o do mouse ele simular&aacute; o clique
+ no segundo bot&atilde;o do mouse. Mantendo pressionada a tecla Option e clicando
+ no bot&atilde;o do mouse ele simular&aacute; o terceiro bot&atilde;o. Voc&ecirc;
+ pode mudar a combina&ccedil;&atilde;o de teclas modificadoras para emular os
+ bot&otilde;es dois e tr&ecirc;s nas prefer&ecirc;ncias. Nota, se a tecla modificadora
+ foi mapeada para alguma outra tecla no xmodmap, voc&ecirc; ainda ter&aacute;
+ que usar a tecla atual especificada nas prefer&ecirc;ncias para a emula&ccedil;&atilde;o
+ do mouse multi-bot&otilde;es.</p>
+<h2><a NAME="path">Ajustando seu Path</a></h2>
+<p>Seu path &eacute; a lista de diret&oacute;rios a serem procurados por arquivos
+ execut&aacute;veis. O comando X11 est&aacute; localizado em <code>/usr/X11R6/bin</code>,
+ que precisa ser adicionado ao seu path. XDarwin faz isso para voc&ecirc; por
+ padr&atilde;o e pode-se tamb&eacute;m adicionar diret&oacute;rios onde voc&ecirc;
+ instalou aplica&ccedil;&otilde;es de linha de comando.</p>
+<p>Usu&aacute;rios experientes j&aacute; ter&atilde;o configurado corretamente
+ seu path usando arquivos de inicializa&ccedil;&atilde;o de seu shell. Neste
+ caso, voc&ecirc; pode informar o XDarwin para n&atilde;o modificar seu path
+ nas prefer&ecirc;ncias. O XDarwin inicia o cliente inicial X11 no shell padr&atilde;o
+ do usu&aacute;rio corrente. (Um shell alternativo pode ser tamb&eacute;m expecificado
+ nas prefer&ecirc;ncias.) O modo para ajustar o path depende do shell que voc&ecirc;
+ est&aacute; usando. Isto &eacute; descrito na man page do seu shell.</p>
+<p>Voc&ecirc; pode tamb&eacute;m querer adicionar as man pages do X11 para
+ a lista de p&aacute;ginas a serem procuradas quando voc&ecirc; est&aacute; procurando
+ por documenta&ccedil;&atilde;o. As man pages do X11 est&atilde;o localizadas
+ em <code>/usr/X11R6/man</code> e a vari&aacute;vel de ambiente <code>MANPATH</code>
+ cont&eacute;m a lista de diret&oacute;rios a buscar.</p>
+<h2><a NAME="prefs">Prefer&ecirc;ncias do Usu&aacute;rio</a></h2>
+<p>V&aacute;rias op&ccedil;&otilde;es podem ser ajustadas nas prefer&ecirc;ncias
+ do usu&aacute;rio, acess&iacute;vel pelo item &quot;Prefer&ecirc;ncias...&quot;
+ no menu &quot;XDarwin&quot;. As op&ccedil;&otilde;es listadas como op&ccedil;&otilde;es
+ de inicializa&ccedil;&atilde;o, n&atilde;o ter&atilde;o efeito at&eacute; voc&ecirc;
+ reiniciar o XDarwin. Todas as outras op&ccedil;&otilde;es ter&atilde;o efeito
+ imediatamente. V&aacute;rias das op&ccedil;&otilde;es est&atilde;o descritas
+ abaixo:</p>
+<h3>Geral</h3>
+<ul>
+ <li><b>Usar o Beep do Sistema para o X11: </b>Quando habilitado som de alerta
+ padr&atilde;o do Mac OS X ser&aacute; usado como alerta no X11. Quando desabilitado
+ (padr&atilde;o) um tom simples ser&aacute; usado.</li>
+ <li><b>Permitir o X11 mudar a acelera&ccedil;&atilde;o do mouse: </b>Por implementa&ccedil;&atilde;o
+ padr&atilde;o no sistema X window, o gerenciador de janelas pode mudar a acelera&ccedil;&atilde;o
+ do mouse. Isso pode gerar uma confus&atilde;o pois a acelera&ccedil;&atilde;o
+ do mouse pode ser ajustada diferentemente nas prefer&ecirc;ncias do Mac OS
+ X e nas prefer&ecirc;ncias do X window. Por padr&atilde;o, o X11 n&atilde;o
+ est&aacute; habilitado a mudar a acelera&ccedil;&atilde;o do mouse para evitar
+ este problema.</li>
+ <li><b>Emula&ccedil;&atilde;o de Mouse de Multi-Bot&otilde;es: </b>Esta op&ccedil;&atilde;o
+ est&aacute; escrita acima em <a href="#usage">Uso</a>. Quando a emula&ccedil;&atilde;o
+ est&aacute; habilitada as teclas modificadoras selecionadas tem que estar
+ pressionadas quando o bot&atilde;o do mouse for pressionado, para emular o
+ segundo e terceiro bot&otilde;es.</li>
+</ul>
+<h3>Inicial</h3>
+<ul>
+ <li><b>Modo Padr&atilde;o: </b>Se o usu&aacute;rio n&atilde;o indicar qual modo
+ de exibi&ccedil;&atilde;o quer usar (Tela Cheia ou Compartilhado) o modo especificado
+ aqui ser&aacute; usado .</li>
+ <li><b>Mostrar o painel de escolha na inicializa&ccedil;&atilde;o: </b> Por
+ padr&atilde;o, uma painel &eacute; mostrado quando o XDarwin &eacute;
+ iniciado para permitir que o usu&aacute;rio escolha ente o modo tela cheia
+ ou modo compartilhado. Se esta op&ccedil;&atilde;o estiver desligada, o modo
+ padr&atilde;o ser&aacute; inicializado automaticamente.</li>
+ <li><b>N&uacute;mero do Monitor X11: </b>O X11 permite ser administrado em multiplos
+ monitores por servidores X separados num mesmo computador. O usu&aacute;rio
+ pode indicar o n&uacute;mero do monitor para o XDarwin usar se mais de um
+ servidor X se estiver rodando simultaneamente.</li>
+ <li><b>Habilitar suporte a m&uacute;ltiplos monitores pelo Xinerama: </b>o XDarwin
+ suporta m&uacute;ltiplos monitores com o Xinerama, que trata todos os monitores
+ como parte de uma grande e retangular tela. Voc&ecirc; pode desabilitar o
+ Xinerama com est&aacute; op&ccedil;&atilde;o, mas normalmente o XDarwin n&atilde;o
+ controla m&uacute;ltiplos monitores corretamente sem est&aacute; op&ccedil;&atilde;o.
+ Se voc&ecirc; s&oacute; tiver um monotor, Xinerama &eacute; automaticamente
+ desabilitado. </li>
+ <li><b>Arquivo de Mapa de Teclado: </b> O mapa de teclado &eacute; lido na inicializa&ccedil;&atilde;o
+ e traduzido para um mapa de teclado X11. Arquivos de mapa de teclado, est&atilde;o
+ dispon&iacute;veis numa grande variedade de l&iacute;nguas e s&atilde;o encontradas
+ em <code>/System/Library/Keyboards</code>.</li>
+ <li><b>Iniciando Clientes X11 primeiro: </b>Quando o XDrawin &eacute; inicializado
+ pelo Finder, ele ir&aacute; rodar o <code>xinit</code> para abrir o controlador
+ X window e outros clientes X. (Veja o manual "<code>man xinit</code>" para
+ mais informa&ccedil;&otilde;es.) Antes do XDarwin rodar o <code>xinit</code>
+ ele ir&aacute; adicionar espec&iacute;ficos diret&oacute;rios a seu path.
+ Por padr&atilde;o somente o <code>/usr/X11R6/bin</code> &eacute; adicionado.
+ separado por um ponto-e-v&iacute;rgula. Os clientes X s&atilde;o inicializados
+ no shell padr&atilde;o do usu&aacute;rio e os arquivos de inicializa&ccedil;&atilde;o
+ do shell ser&atilde;o lidos. Se desejado, um shell alternativo pode ser especificado.</li>
+</ul>
+<h3>Tela Cheia</h3>
+<ul>
+ <li><b>Bot&atilde;o de Combina&ccedil;&atilde;o de Teclas: </b> Clique no bot&atilde;o
+ e pressione qualquer quantidade de teclas modificadoras seguidas por uma tecla
+ padr&atilde;o para modificar a combina&ccedil;&atilde;o quando se quer mudar
+ entre o Aqua e X11.</li>
+ <li><b>Clique no &Iacute;cone no Dock para mudar para o X11: </b>Habilitando
+ esta op&ccedil;&atilde;o voc&ecirc; ir&aacute; ativar a mudan&ccedil;a para
+ o X11 clicando no &iacute;cone do XDarwin no Dock. Em algumas vers&otilde;es
+ do Mac OS X, mudando pelo clique no Dock pode causar o desaparecimento do
+ cursor quando retornar ao Aqua.</li>
+ <li><b>Mostrar a Ajuda na inicializa&ccedil;&atilde;o: </b>Isto ir&aacute; mostrar
+ uma tela introdut&oacute;ria quando o XDarwin for inicializado no modo Tela
+ Cheia. </li>
+ <li><b>Profundidade de Cores em bits: </b> No modo Tela Cheia, a tela do X11
+ pode usar uma profundiadde de cor diferente da usada no Aqua. Se a op&ccedil;&atilde;o
+ &quot;Atual&quot; est&aacute; especificada, a profundidade usada pelo Aqua
+ quando o XDarwin iniciar ser&aacute; a mesma. Al&eacute;m das op&ccedil;&otilde;es
+ 8, 15 ou 24 bits que podem ser especificadas.</li>
+</ul>
+
+<h2><a NAME="license">Licen&ccedil;a</a></h2>
+<p>A licen&ccedil;a
+ principal n&oacute;s por XDarwin baseada na licen&ccedil;a tradicional MIT X11
+ / X Consortium, que n&atilde;o imp&otilde;e nenhuma condi&ccedil;&atilde;o sobre
+ modifica&ccedil;&otilde;es ou redistribui&ccedil;&atilde;o do c&oacute;digo-fonte
+ ou dos bin&aacute;rios desde que o copyright/licen&ccedil;a sejam mantidos intactos.
+ Para mais informa&ccedil;&otilde;es e not&iacute;cias adicionais de copyright/licensing
+ em algumas se&ccedil;&atilde;o do c&oacute;digo, por favor refer to the source code.</p>
+<H3><A NAME="3"></A>Licen&ccedil;a do X Consortium</H3>
+<p>Copyright (C) 1996 X Consortium</p>
+<p>Permiss&otilde;es s&atilde;o em virtude garantidas, livre de mudan&ccedil;as,
+ para qualquer pessoa que possua uma c&oacute;pia deste software e aos arquivos
+ de documenta&ccedil;&atilde;o associada (o &quot;Software&quot;), para lidar
+ com o software sem restri&ccedil;&otilde;es, incluindo limita&ccedil;&otilde;es
+ dos direitos de uso, c&oacute;pia, modifica&ccedil;&atilde;o, inclus&atilde;o,
+ publica&ccedil;&atilde;o, distribui&ccedil;&atilde;o, sub licen&ccedil;a, e/ou
+ venda de c&oacute;pias deste Software, e permitir pessoas to whom o Software
+ &eacute; fornecido para ser desta forma, verifique as seguintes condi&ccedil;&otilde;es:</p>
+<p>O nota de copyright abaixo e a permiss&atilde;o dever&atilde;o ser inclu&iacute;das
+ em todas as c&oacute;pias ou substanciais por&ccedil;&otilde;es do Software.</p>
+<p>O SOFTWARE 'E PROVIDO &quot;COMO TAL&quot;, SEM GARANTIAS DE NENHUM TIPO, EXPLICITA
+ OU IMPLICITA, INCLUINDO MAS N&Atilde;O LIMITADO NOS AVISOS DE COM&Eacute;RCIO,
+ TAMANHO OU PARA PROPOSTAS PARTICULARES E N&Atilde;O INFRA&Ccedil;&Atilde;O.
+ EM NENHUM ACONTECIMENTO O X CONSORTIUM SER&Aacute; RESPONSAV&Eacute;L POR NENHUMA
+ RECLAMA&Ccedil;&Atilde;O, DANOS OU OUTRAS RESPONSABILIDADES, SE NUMA A&Ccedil;&Atilde;O
+ DE CONTRATO, OU OUTRA COISA, SURGINDO DE, FORA DE OU EM CONEX&Atilde;O COM O
+ SOFTWARE OU O USO OU OUTRO MODO DE LIDAR COM O SOFTWARE.</p>
+<p>Exceto o contido nesta nota, o nome do X Consortium n&atilde;o pode ser usado
+ em propagandas ou outra forma de promo&ccedil;&atilde;o de vendas, uso ou outro
+ modo de lidar com este Software sem ter recebido uma autoriza&ccedil;&atilde;o
+ escrita pelo X Consortium.</p>
+<p>O Sistema X Window &eacute; marca registrada do X Consortium, Inc.</p>
+</body>
+</html>
+
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/Credits.rtf b/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/Credits.rtf
new file mode 100644
index 000000000..34408e78c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/Credits.rtf
@@ -0,0 +1,168 @@
+{\rtf1\mac\ansicpg10000\cocoartf102
+{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fswiss\fcharset77 Helvetica-Oblique;
+}
+{\colortbl;\red255\green255\blue255;}
+\vieww5160\viewh6300\viewkind0
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\fs24 \cf0 This product includes software developed by The XFree86 Project, Inc (http://www.xfree86.org/) and its contributors. The following people contributed to Darwin/Mac OS X support.\
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Contributors to Xorg Foundation Release:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Kaleb KEITHLEY\
+
+\f2\i Working left and right Ctrl, Alt (Option), Meta (Command) and Shift keys.
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\f1\b \cf0 Contributors to XFree86 4.4:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Harper\
+
+\f2\i Rootless acceleration and Apple-WM extension
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Additional XonX Contributors to XFree86 4.3:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Fabr\'92cio Luis de Castro\
+
+\f2\i Portuguese localization
+\f0\i0 \
+Michael Oland\
+
+\f2\i New XDarwin icon
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 XonX Contributors to XFree86 4.2:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+
+\f2\i Darwin x86 support
+\f0\i0 \
+Pablo Di Noto\
+
+\f2\i Spanish localization
+\f0\i0 \
+Paul Edens\
+
+\f2\i Dutch localization
+\f0\i0 \
+Kyunghwan Kim\
+
+\f2\i Korean localization
+\f0\i0 \
+Mario Klebsch\
+
+\f2\i Non-US keyboard support
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+Andreas Monitzer\
+
+\f2\i German localization
+\f0\i0 \
+Patrik Montgomery\
+
+\f2\i Swedish localization
+\f0\i0 \
+Greg Parker\
+
+\f2\i Rootless support
+\f0\i0 \
+Toshimitsu Tanaka\
+
+\f2\i Japanese localization
+\f0\i0 \
+Olivier Verdier\
+
+\f2\i French localization
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Special Thanks:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Devin Poolman and Zero G Software, Inc.\
+
+\f2\i Installer
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 XonX Team Members\
+Contributing to XFree86 4.1:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+
+\f2\i Darwin x86 support
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+Andreas Monitzer\
+
+\f2\i Cocoa version of XDarwin front end
+\f0\i0 \
+Greg Parker\
+
+\f2\i Original Quartz implementation
+\f0\i0 \
+Christoph Pfisterer\
+
+\f2\i Dynamic shared libraries
+\f0\i0 \
+Toshimitsu Tanaka\
+
+\f2\i Japanese localization
+\f0\i0 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Special Thanks:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Tiago Ribeiro\
+
+\f2\i XDarwin icon
+\f0\i0 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 History:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Carmack\
+
+\f2\i Original XFree86 port to Mac OS X Server
+\f0\i0 \
+Dave Zarzycki\
+
+\f2\i XFree86 4.0 port to Darwin 1.0
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Integration into XFree86 Project for 4.0.2} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/Imakefile b/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/Imakefile
new file mode 100644
index 000000000..d367fbcee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/Imakefile
@@ -0,0 +1,36 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/Imakefile,v 1.1 2001/05/21 01:42:17 torrey Exp $
+
+#include <Server.tmpl>
+
+LinkSourceFile(InfoPlist.strings.cpp,../English.lproj)
+
+INCLUDES = -I$(SERVERSRC)/include
+
+#if defined (XorgVersionString)
+VERS = XorgVersionString
+PRE = XORG_VERSION_SNAP
+NAME = "X Version 11"
+LINK = '<a HREF="http://wiki.x.org/">X.Org Foundation</a>'
+#elif defined XFree86VersionString
+VERS = XFree86VersionString
+PRE = XF86_VERSION_SNAP
+NAME = "XFree86"
+LINK = '<a HREF="http://www.XFree86.Org/">XFree86 Project, Inc.</a>'
+#endif
+DATE = XFree86DateString
+X_DEFS = $(INCLUDES) -DX_VERSION=$(VERS) -DX_PRE_RELEASE=$(PRE) \
+ -DX_REL_DATE=$(DATE) -DX_VENDOR_NAME=$(NAME) -DX_VENDOR_LINK=$(LINK)
+
+AllTarget(XDarwinHelp.html)
+CppFileTarget(XDarwinHelp.html,XDarwinHelp.html.cpp,$(X_DEFS), \
+ NullParameter)
+
+AllTarget(InfoPlist.strings)
+InfoPlist.strings: InfoPlist.strings.cpp
+ RemoveFile($@)
+ ClearmakeOSName \
+ $(CPP) CppNoLineInfoOption $(X_DEFS) <InfoPlist.strings.cpp | \
+ CppSedMagic | sed 's/__quote__/"/g' >$@
+
+clean::
+ RemoveFiles(InfoPlist.strings)
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/Localizable.strings b/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/Localizable.strings
new file mode 100644
index 000000000..5bf813f1f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/Localizable.strings
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/classes.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/classes.nib
new file mode 100644
index 000000000..77f345a4e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/classes.nib
@@ -0,0 +1,72 @@
+{
+ IBClasses = (
+ {
+ ACTIONS = {showHelp = id; };
+ CLASS = FirstResponder;
+ LANGUAGE = ObjC;
+ SUPERCLASS = NSObject;
+ },
+ {
+ ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; };
+ CLASS = Preferences;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ addToPathButton = id;
+ addToPathField = id;
+ button2ModifiersMatrix = id;
+ button3ModifiersMatrix = id;
+ depthButton = id;
+ displayField = id;
+ dockSwitchButton = id;
+ fakeButton = id;
+ keymapFileField = id;
+ modeMatrix = id;
+ modeWindowButton = id;
+ mouseAccelChangeButton = id;
+ startupHelpButton = id;
+ switchKeyButton = id;
+ systemBeepButton = id;
+ useDefaultShellMatrix = id;
+ useOtherShellField = id;
+ useXineramaButton = id;
+ window = id;
+ };
+ SUPERCLASS = NSObject;
+ },
+ {
+ CLASS = XApplication;
+ LANGUAGE = ObjC;
+ OUTLETS = {preferences = id; xserver = id; };
+ SUPERCLASS = NSApplication;
+ },
+ {
+ ACTIONS = {
+ bringAllToFront = id;
+ closeHelpAndShow = id;
+ itemSelected = id;
+ nextWindow = id;
+ previousWindow = id;
+ showAction = id;
+ showSwitchPanel = id;
+ startFullScreen = id;
+ startRootless = id;
+ };
+ CLASS = XServer;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ dockMenu = NSMenu;
+ helpWindow = NSWindow;
+ modeWindow = NSWindow;
+ startFullScreenButton = NSButton;
+ startRootlessButton = NSButton;
+ startupHelpButton = NSButton;
+ startupModeButton = NSButton;
+ switchWindow = NSPanel;
+ windowMenu = NSMenu;
+ windowSeparator = NSMenuItem;
+ };
+ SUPERCLASS = NSObject;
+ }
+ );
+ IBVersion = 1;
+} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/objects.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/objects.nib
new file mode 100644
index 000000000..2df75ee0c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/objects.nib
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/XDarwinHelp.html.cpp b/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/XDarwinHelp.html.cpp
new file mode 100644
index 000000000..5cd27862d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/XDarwinHelp.html.cpp
@@ -0,0 +1,111 @@
+<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.2 2001/11/04 07:02:28 torrey Exp $ -->
+
+<html>
+<head>
+<title>XDarwin Ayuda</title>
+</head>
+<body>
+<center>
+ <h1>XDarwin X Server for Mac OS X</h1>
+ X_VENDOR_NAME X_VERSION<br>
+ Fecha de release: X_REL_DATE
+</center>
+<h2>Contenido</h2>
+<ol>
+ <li><A HREF="#notice">Aviso Importante</A></li>
+ <li><A HREF="#usage">Modo de uso</A></li>
+ <li><A HREF="#path">Configurando su Path</A></li>
+ <li><A HREF="#prefs">Preferencias del Usuario</A></li>
+ <li><A HREF="#license">Licencia</A></li>
+</ol>
+<center>
+ <h2><a NAME="notice">Aviso Importante</a></h2>
+</center>
+<blockquote>
+#if PRE_RELEASE
+Esta es una versi&oacuten pre-release de XDarwin, y no tiene ning&uacuten soporte. Patches y reportes de error pueden ser enviados a la <A HREF="http://sourceforge.net/projects/xonx/">p&aacutegina del proyecto XonX</A> en SourceForge. Antes de reportar errores en versiones pre-release, por favor verifique la ultima versi&oacuten en <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> o bien el X_VENDOR_LINK.
+#else
+Si el server el m&aacutes antiguo que 6 a 12 meses, o si su hardware es posterior a la fecha indicada m&aacutes arriba, por favor verifique la &uacuteltima versi&oacuten antes de reportar problemas. Patches y reportes de error pueden ser enviados a la <A HREF="http://sourceforge.net/projects/xonx/">p&aacutegina del proyecto XonX</A> en SourceForge.
+#endif
+</blockquote>
+<blockquote>
+Este software es distribuido bajo los t&eacuterminos de la <A HREF="#license">Licencia MIT X11 / X Consortium</A> y es provisto sin garant&iacutea alguna y en el estado en que se encuentra. Por favor lea la <A HREF="#license">Licencia</A> antes de utilizarlo.</blockquote>
+
+<h2><a NAME="usage">Modo de uso</a></h2>
+<p>XDarwin es una X server open-source de distribuci&oacuten libre del <a HREF
+="http://www.x.org/">X Window System</a>. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin funciona en Mac OS X en modo pantalla completa o en modo rootless (integrado al escritorio).</p>
+<p>En modo pantalla completa, el X window system toma control total de la pantalla mientras esta activo. Presionando Command-Option-A puede regresar al Escritorio de Mac OS X. Esta combinaci&oacuten de teclas puede cambiarse en las Preferencias de Usuario. Desde el Escritorio de Mac OS X, haga click en &iacutecono de XDarwin en el Dock para volver al X window system. (Puede cambiar esta comportamiento en las Preferencias de Usuario y configurar que XDarwin vuelva al X window system haciendo click en la ventana flotante con el logo X.)</p>
+<p>En modo rootless, el X window system comparte la pantalla con Aqua. La ventana root de X11 es del tama&ntildeo de la pantalla y contiene a todas las dem&aacutes ventanas. La ventana root de X11 no se muestra en este modo, ya que Aqua maneja el fondo de pantalla.</p>
+<h3>Emulaci&oacuten de mouse multi-bot&oacuten</h3>
+<p>Muchas aplicaciones X11 requieren del uso de un mouse de 3 botones. Es posible emular un mouse de 3 botones con un mouse de solo un bot&oacuten presionando teclas modificadoras mientras hace click. Esto es controlado en de la seccion "Emulaci&oacuten mouse" dentro de la secci&oacuten "General" de las Preferencias del Usuario. Por defecto, la emulaci&oacuten est&aacute activa y utiliza la tecla Command para simular el 2do bot&oacuten y la tecla Option para simlar el 3er bot&oacuten. La conbinaci&oacuten para simular el 2do y 3er bot&oacuten pueden ser modificada por cualquier combinaci&oacuten de teclas modificadoras dentro de las Preferencias del Usuario. Tenga en cuenta que aunque las teclas modificadoras hayan sido mapeadas a otras teclas con xmodmap, las teclas configuradas en las Preferencias del Usuario seguir&aacuten siendo las utilizadas por la emulaci&oacuten de mouse multi-bot&oacuten.</p>
+
+<h2><a NAME="path">Configurando su Path</a></h2>
+<p>El path es la lista de directorios donde se buscar&aacuten los comandos ejecutables. Los comandos de X11 se encuentran en <code>/usr/X11R6/bin</code>, y &eacuteste necesita estar dentro de su path. XDarwin hace &eacutesto autom&aacuteticamente por defecto, y puede adem&aacutes agregar directorios adicionales donde tenga otros comandos de l&iacutenea.</p>
+<p>Usuarios experimentados pueden tener su path correctamente configurado mediante los archivos de inicio de su interprete de comandos. En este caso, puede informarle a XDarwin en las Preferencias de Usuario para que no modifique su path. XDarwin arrancar&aacute los clientes X11 iniciales usando el int&eacuterprete de comandos del usuario, seg&uacuten su configuraci&oacuten de login. Un int&eacuterprete de comandos alternativo puede ser especificado en las Preferencias del Usuario. La manera de configurar el path de su int&eacuterprete de comandos depende de cual est&aacute usando, y es generalmente descripta en las p&aacuteginas man del mismo.</p>
+<p>Adem&aacutes, Ud. puede agregar las p&aacuteginas man de X11 a la lista de p&aacuteginas que son consultadas. Estas est&aacuten ubicadas en <code>/usr/X11R6/man</code> y <code>MANPATH</code> es la variable de entorno que contiene los directorios que son consultados.</p>
+
+<h2><a NAME="prefs">Preferencias del Usuario</a></h2>
+<p>Ciertas opciones pueden definirse dentro de "Preferencias...", en el men&uacute de XDarwin. Las opciones dentro de de "Inicio" no surtir&aacuten efecto hasta que la aplicaci&oacuten se reinicie. Las restantes opciones surten efecto inmediatamente. Las diferentes opciones se describen a continuaci&oacuten:</p>
+<h3>General</h3>
+<ul>
+ <li><b>Usar beep del sistema en X11:</b> Cuando esta opci&oacuten est&aacute activa, el sonido de alerta est&aacutendar de Mac OS X se usar&aacute como alerta de X11. Cuando est&aacute desactivada, un simple tono es utilizado (esta es la opci&oacuten por defecto).</li>
+ <li><b>Permitir que X11 cambie la aceleraci&oacuten del mouse:</b> En una implementaci&oacuten est&aacutendard de X11, el window manager puede cambiar la aceleraci&oacuten del mouse. Esto puede llevar a una gran confusi&oacuten si la aceleraci&oacuten es diferente en XDarwin y en Mac OS X. Por defecto, no se le permite a X11 alterar la aceleraci&oacuten para evitar este inconveniente.</li>
+ <li><b>Emulaci&oacuten de mouse multi-bot&oacuten:</b> Esta opci&oacuten es descripta m&aacutes arriba bajo <a HREF="#usage">Modo de Uso</a>. Cuando esta emulaci&oacuten est&aacute activa los modificadores seleccionados deben ser presionados cuando se hace click para emular el bot&oacuten 2 o el bot&oacuten 3.</li>
+</ul>
+<h3>Inicio</h3>
+<ul>
+ <li><b>Modo inicial:</b> Si el usuario no indica si desea utilizar la Pantalla Completa o el modo Rootless, el modo especificado aqu&iacute ser&aacute el usado.</li>
+ <li><b>Mostrar panel de selecci&oacuten al inicio:</b> Por defecto, un di&aacutelogo permite al usuario elegir entre Pantalla Completa o Rootless al inicio. Si esta opci&oacuten esta desactivada, XDarwin arrancar&aacute utilizando el modo por defecto sin consultar al usuario.</li>
+ <li><b>N&uacutemero de display X11:</b> X11 permite que existan m&uacuteltiples pantallas manejadas por servidores X11 separados funcionando en una misma computadora. El usuario puede especificar aqui un n&uacutemero entero para indicar el n&uacutemero de pantalla (display) que XDarwin utilizar&aacute si m&aacutes de un servidor X funciona en forma simult&aacutenea.</li>
+ <li><b>Habilitar soporte Xinerama para m&uacuteltipes monitores:</b> XDarwin suporta m&uacuteltiple monitores con Xinerama, que maneja todos los monitores como si fueran parte de una gran pantalla rectangular. Puede deshabilitar Xinerama con esta opci&oacuten, pero XDarwin no maneja m&uacuteltiples monitores en forma correcta sin esta opci&oacuten habilitada. Si tiene solo un monitor, Xinerama es autom&aacuteticamente deshabilitado.</li>
+ <li><b>Archivo de mapa de teclado:</b> Un archivo de mapa de teclas es le&iacutedo al inicio y es traducido a un keymap X11 (un archivo est&aacutendard de X11 para especificar la funci&oacuten de cada tecla). Estos archivos, disponibles para una amplia variedad de lenguajes, pueden encontrarse en <code>/System/Library/Keyboards</code>.</li>
+ <li><b>Al iniciar clientes X11:</b> Cuando XDarwin arranca desde el Finder, &eacuteste ejecutar&aacute <code>xinit</code> para a su vez arrancar el window manager y otros clientes. (Vea en "<code>man xinit</code>" para mayor informaci&oacuten). Antes de ejecutar <code>xinit</code> XDarwin agregar&aacute los directorios especificados al path del usuario. Por defecto, solo <code>/usr/X11R6/bin</code> es agregado. Otros directorios adicionales puede agregarse separados por dos puntos (:). Los clientes X son ejecutados con el int&eacuterprete de comandos del usuario, por lo que los archivos de inicio de &eacuteste son le&iacutedos. Si se desea, un int&eacuterprete de comandos diferente puede ser especificado.</li>
+</ul>
+<h3>Pantalla Completa</h3>
+<ul>
+ <li><b>Bot&oacuten para definir combinaci&oacuten de teclas:</b> Haga click en este bot&oacuten y luego presione cualquier combinaci&oacuten de modificadores seguidos de una tecla convencional para definir que combinaci&oacuten usar&aacute para intercambiar entre X11 y Aqua.</li>
+ <li><b>Click en el &iacutecono del Dock cambia a X11:</b> Habilite esta opci&oacuten para volver a X11 al hacer click en &iacutecono de XDarwin en el Dock. En algunas versiones de Mac OS X, al volver haciendo click en el Dock puede causar al desaparci&oacuten del cursor al volver a Aqua.</li>
+ <li><b>Mostrar ayuda al inicio:</b> Esta opci&oacuten habilitada har&aacute que una pantalla inicial de introducci&oacuten aparezca cuando XDarwin es arrancado en modo Pantalla Completa.</li>
+ <li><b>Profundidad de color (bits):</b> En modo Pantalla Completa, el display X11 puede utilizar una profundidad de color diferente de la utilizada por Aqua. Si se especifica "Actual", la misma profundidad de color que Aqua utiliza ser&aacute adoptada por X11. Al contrario, puede especificar 8, 15, o 24 bits.</li>
+</ul>
+
+<h2><a NAME="license">Licencia</a></h2>
+La licencia principal de XDarwin es basada en la Licencia MIT X11 tradicional, que no impone condiciones a la modificaci&oacuten o redistribuci&oacuten del c&oacutedigo fuente o de archivos binarios m&aacutes all&aacute de requerir que los mensajes de Licencia y Copyright se mantengan intactos. Para mayor informaci&oacuten y para mensajes adicionales de Licencia y Copyright que cubren algunas secciones del c&oacutedigo fuente, por favor consulte the source code.
+<H3><A NAME="3"></A>Licencia del X Consortium</H3>
+<p>Copyright (C) 1996 X Consortium</p>
+<p>Se otorga aqui permiso, libre de costo, a toda persona que obtenga una copia de este Software y los archivos de documentaci&oacuten asociados (el "Software"),
+para utilizar el Software sin restricciones, incluyendo sin l&iacutemites los derechos de usar, copiar, modificar, integrar con otros productos, publicar, distribuir, sub-licenciar y/o comercializar copias del Software, y de permitir a las personas que lo reciben para hacer lo propio, sujeto a las siguientes condiciones:</p>
+<p>El mensaje de Copyright indicado m&aacutes arriba y este permiso ser&aacute inclu&iacutedo en todas las copias o porciones sustanciales del Software.</p>
+<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.</p>
+<p>Excepto lo indicado en este mensaje, el nombre del X Consortium no ser&aacute utilizado en propaganda o como medio de promoci&oacuten para la venta, utilizaci&oacuten u otros manejos de este Software sin previa autorizaci&oacuten escrita del X Consortium.</p>
+<p>X Window System es una marca registrada de X Consortium, Inc.</p>
+<H3><A NAME="3"></A>X Consortium License (English)</H3>
+<p>Copyright (C) 1996 X Consortium</p>
+<p>Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without
+limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to
+whom the Software is furnished to do so, subject to the following conditions:</p>
+<p>The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.</p>
+<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.</p>
+<p>Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization from
+the X Consortium.</p>
+<p>X Window System is a trademark of X Consortium, Inc.</p>
+</body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/Credits.rtf b/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/Credits.rtf
new file mode 100644
index 000000000..34408e78c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/Credits.rtf
@@ -0,0 +1,168 @@
+{\rtf1\mac\ansicpg10000\cocoartf102
+{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fswiss\fcharset77 Helvetica-Oblique;
+}
+{\colortbl;\red255\green255\blue255;}
+\vieww5160\viewh6300\viewkind0
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\fs24 \cf0 This product includes software developed by The XFree86 Project, Inc (http://www.xfree86.org/) and its contributors. The following people contributed to Darwin/Mac OS X support.\
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Contributors to Xorg Foundation Release:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Kaleb KEITHLEY\
+
+\f2\i Working left and right Ctrl, Alt (Option), Meta (Command) and Shift keys.
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\f1\b \cf0 Contributors to XFree86 4.4:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Harper\
+
+\f2\i Rootless acceleration and Apple-WM extension
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Additional XonX Contributors to XFree86 4.3:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Fabr\'92cio Luis de Castro\
+
+\f2\i Portuguese localization
+\f0\i0 \
+Michael Oland\
+
+\f2\i New XDarwin icon
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 XonX Contributors to XFree86 4.2:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+
+\f2\i Darwin x86 support
+\f0\i0 \
+Pablo Di Noto\
+
+\f2\i Spanish localization
+\f0\i0 \
+Paul Edens\
+
+\f2\i Dutch localization
+\f0\i0 \
+Kyunghwan Kim\
+
+\f2\i Korean localization
+\f0\i0 \
+Mario Klebsch\
+
+\f2\i Non-US keyboard support
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+Andreas Monitzer\
+
+\f2\i German localization
+\f0\i0 \
+Patrik Montgomery\
+
+\f2\i Swedish localization
+\f0\i0 \
+Greg Parker\
+
+\f2\i Rootless support
+\f0\i0 \
+Toshimitsu Tanaka\
+
+\f2\i Japanese localization
+\f0\i0 \
+Olivier Verdier\
+
+\f2\i French localization
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Special Thanks:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Devin Poolman and Zero G Software, Inc.\
+
+\f2\i Installer
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 XonX Team Members\
+Contributing to XFree86 4.1:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+
+\f2\i Darwin x86 support
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+Andreas Monitzer\
+
+\f2\i Cocoa version of XDarwin front end
+\f0\i0 \
+Greg Parker\
+
+\f2\i Original Quartz implementation
+\f0\i0 \
+Christoph Pfisterer\
+
+\f2\i Dynamic shared libraries
+\f0\i0 \
+Toshimitsu Tanaka\
+
+\f2\i Japanese localization
+\f0\i0 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Special Thanks:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Tiago Ribeiro\
+
+\f2\i XDarwin icon
+\f0\i0 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 History:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Carmack\
+
+\f2\i Original XFree86 port to Mac OS X Server
+\f0\i0 \
+Dave Zarzycki\
+
+\f2\i XFree86 4.0 port to Darwin 1.0
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Integration into XFree86 Project for 4.0.2} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/Imakefile b/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/Imakefile
new file mode 100644
index 000000000..d367fbcee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/Imakefile
@@ -0,0 +1,36 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/Imakefile,v 1.1 2001/05/21 01:42:17 torrey Exp $
+
+#include <Server.tmpl>
+
+LinkSourceFile(InfoPlist.strings.cpp,../English.lproj)
+
+INCLUDES = -I$(SERVERSRC)/include
+
+#if defined (XorgVersionString)
+VERS = XorgVersionString
+PRE = XORG_VERSION_SNAP
+NAME = "X Version 11"
+LINK = '<a HREF="http://wiki.x.org/">X.Org Foundation</a>'
+#elif defined XFree86VersionString
+VERS = XFree86VersionString
+PRE = XF86_VERSION_SNAP
+NAME = "XFree86"
+LINK = '<a HREF="http://www.XFree86.Org/">XFree86 Project, Inc.</a>'
+#endif
+DATE = XFree86DateString
+X_DEFS = $(INCLUDES) -DX_VERSION=$(VERS) -DX_PRE_RELEASE=$(PRE) \
+ -DX_REL_DATE=$(DATE) -DX_VENDOR_NAME=$(NAME) -DX_VENDOR_LINK=$(LINK)
+
+AllTarget(XDarwinHelp.html)
+CppFileTarget(XDarwinHelp.html,XDarwinHelp.html.cpp,$(X_DEFS), \
+ NullParameter)
+
+AllTarget(InfoPlist.strings)
+InfoPlist.strings: InfoPlist.strings.cpp
+ RemoveFile($@)
+ ClearmakeOSName \
+ $(CPP) CppNoLineInfoOption $(X_DEFS) <InfoPlist.strings.cpp | \
+ CppSedMagic | sed 's/__quote__/"/g' >$@
+
+clean::
+ RemoveFiles(InfoPlist.strings)
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/Localizable.strings b/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/Localizable.strings
new file mode 100644
index 000000000..9709e5469
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/Localizable.strings
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/classes.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/classes.nib
new file mode 100644
index 000000000..77f345a4e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/classes.nib
@@ -0,0 +1,72 @@
+{
+ IBClasses = (
+ {
+ ACTIONS = {showHelp = id; };
+ CLASS = FirstResponder;
+ LANGUAGE = ObjC;
+ SUPERCLASS = NSObject;
+ },
+ {
+ ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; };
+ CLASS = Preferences;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ addToPathButton = id;
+ addToPathField = id;
+ button2ModifiersMatrix = id;
+ button3ModifiersMatrix = id;
+ depthButton = id;
+ displayField = id;
+ dockSwitchButton = id;
+ fakeButton = id;
+ keymapFileField = id;
+ modeMatrix = id;
+ modeWindowButton = id;
+ mouseAccelChangeButton = id;
+ startupHelpButton = id;
+ switchKeyButton = id;
+ systemBeepButton = id;
+ useDefaultShellMatrix = id;
+ useOtherShellField = id;
+ useXineramaButton = id;
+ window = id;
+ };
+ SUPERCLASS = NSObject;
+ },
+ {
+ CLASS = XApplication;
+ LANGUAGE = ObjC;
+ OUTLETS = {preferences = id; xserver = id; };
+ SUPERCLASS = NSApplication;
+ },
+ {
+ ACTIONS = {
+ bringAllToFront = id;
+ closeHelpAndShow = id;
+ itemSelected = id;
+ nextWindow = id;
+ previousWindow = id;
+ showAction = id;
+ showSwitchPanel = id;
+ startFullScreen = id;
+ startRootless = id;
+ };
+ CLASS = XServer;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ dockMenu = NSMenu;
+ helpWindow = NSWindow;
+ modeWindow = NSWindow;
+ startFullScreenButton = NSButton;
+ startRootlessButton = NSButton;
+ startupHelpButton = NSButton;
+ startupModeButton = NSButton;
+ switchWindow = NSPanel;
+ windowMenu = NSMenu;
+ windowSeparator = NSMenuItem;
+ };
+ SUPERCLASS = NSObject;
+ }
+ );
+ IBVersion = 1;
+} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/objects.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/objects.nib
new file mode 100644
index 000000000..3157d72cb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/objects.nib
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/XDarwinHelp.html.cpp b/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/XDarwinHelp.html.cpp
new file mode 100644
index 000000000..4210878c0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/XDarwinHelp.html.cpp
@@ -0,0 +1,103 @@
+<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.2 2001/11/04 07:02:28 torrey Exp $ -->
+
+<html>
+<head>
+<title>XDarwin Help</title>
+</head>
+<body>
+<center>
+ <h1>XDarwin X Server for Mac OS X</h1>
+ X_VENDOR_NAME X_VERSION<br>
+ F&auml;rdigst&auml;llt: X_REL_DATE
+</center>
+<h2>Inneh&aring;ll</h2>
+<ol>
+ <li><A HREF="#notice">Viktigt!</A></li>
+ <li><A HREF="#usage">Anv&auml;ndande</A></li>
+ <li><A HREF="#path">Att st&auml;lla in sin s&ouml;kv&auml;g</A></li>
+ <li><A HREF="#prefs">Inst&auml;llningar</A></li>
+ <li><A HREF="#license">Licens</A></li>
+</ol>
+<center>
+ <h2><a NAME="notice">Viktigt!</a></h2>
+</center>
+<blockquote>
+#if PRE_RELEASE
+Detta &auml;r en testversion av XDarwin, och du kan inte garranteras n&aring;gon som helst support f&ouml;r den. Buggar och fel kan rapporteras och f&ouml;rslag till fixar kan skickas till <A HREF="http://sourceforge.net/projects/xonx/">XonX-projektets sida</A> p&aring; SourceForge. Innan du rapporterar buggar i testversioner, var god pr&ouml;va den senaste versionen fr&aring;n <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> eller i X_VENDOR_LINK.
+#else
+Om servern &auml;r &auml;ldre &auml;n 6-12 m&aring;nader, eller om din h&aring;rdvara &auml;r nyare &auml;n datumet ovan, leta efter en nyare version innan du rapporterar fel. Buggar och fel kan rapporteras och f&ouml;rslag till fixar kan skickas till <A HREF="http://sourceforge.net/projects/xonx/">XonX-projektets sida</A> p&aring; SourceForge.
+#endif
+</blockquote>
+<blockquote>
+Denna programvara distrubueras i enlighet med <A HREF="#license">MIT X11 / X Consortium License</A> och tilhandh&aring;lls som den &auml;r, helt utan garantier. Var god l&auml;s igenom <A HREF="#license">licensdokumentet (engelska)</A> innan du anv&auml;nder programmet.</blockquote>
+
+<h2><a NAME="usage">Anv&auml;ndande</a></h2>
+<p>XDarwin &auml;r en fritt spridd X server av <a HREF
+="http://www.x.org/">X Window-systemet</a>. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin kan k&ouml;ras p&aring; Mac OS X i fullsk&auml;rmsl&auml;ge eller rotl&ouml;st l&auml;ge.</p>
+<p>I fullsk&auml;rmsl&auml;ge kommer X window-systemet att ta &ouml;ver hela sk&auml;rmen n&auml;r det &auml;r aktivt. Du kan byta tillbaka till Mac OS Xs skrivbord genom att trycka Kommando-Alt-A. Denna tangentkombination kan &auml;ndra i inst&auml;llningarna. N&auml;r du &auml;r p&aring; Mac OS Xs skrivbord kan du klicka p&aring; XDarwin-ikonen i dockan f&ouml;r att byta tillbaka till X Window-systemet. (Du kan f&ouml;r&auml;ndra detta beteende i inst&auml;llningarna s&aring; att du ist&auml;llet m&aring;ste klicka i det fltande bytesf&ouml;nstret ist&auml;llet.)</p>
+<p>I rotl&ouml;stl&auml;ge delar X11 och Aqua p&aring; din sk&auml;rm. Rotf&ouml;nstret p&aring; X11-sk&auml;rmen &auml;r av samma storlek som hela sk&auml;rmen och inneh&aring;ller alla andra f&ouml;nster - det fungerar som bakgrund. I rotl&ouml;stl&auml;ge visas inte detta rotf&ouml;nster, eftersom Aqua hanterar skrvbordbakgrunden.</p>
+
+<h3>Emulering av flerknapparsmus</h3>
+<p>M&aring;nga X11-program utnyttjar en treknapparsmus. Du kan emulera en treknapparsmus med en knapp genom att h&aring;lla ner olika knappar p&aring; tangentbordet medan du klickar med musens enda knapp. Denna funktion styrs av inst&auml;llningarna i "Emulera flerknapparsmus" under fliken "Diverse" i inst&auml;llningarna. Grundinst&auml;llningen &auml;r att emulationen &auml;r aktiv och att ett kommando-klick (H&aring;ll ner kommando och klicka) simulerar den andra musknappen. Den tredje musknappen f&aring;s genom att h&aring;lla ner alt och klicka. Du kan &auml;ndra detta till n&aring;gon annan kombination av de fem tangenterna kommando, alt, kontrol, skift och fn (Powerbook/iBook). Notera att om dessa knappar har flyttats med hj&auml;lp av kommandot xmodmap kommer denna f&ouml;r&auml;ndring inte att p&aring;verka vilka knappar som anv&auml;nds vid flerknappsemulationen.</p>
+
+<h2><a NAME="path">Att st&auml;lla in sin s&ouml;kv&auml;g</a></h2>
+<p>Din s&ouml;kv&auml;g &auml;r en lista av kataloger som s&ouml;ks igenom n&auml;r terminalen letar efter kommandon att exekvera. Kommandon som h&ouml;r till X11 ligger i <code>/usr/X11R6/bin</code>, en katalog som inte ligger i din s&ouml;kv&auml;g fr&aring;n b&ouml;rjan. XDarwin l&auml;gger till denna katalog &aring;t dig, och du kan ocks&aring; l&auml;gga till ytterligare kataloger i vilka du lagt program som skall k&ouml;ras fr&aring;n kommandoraden.</p>
+<p>Mer erfarna anv&auml;ndare har antagligen redan st&auml;llt in sin s&ouml;kv&auml;g i skalets inst&auml;llningsfiler. Om detta g&auml;ller dig kan st&auml;lla in XDarwin s&aring; att din s&ouml;kv&auml;g inte modifieras. XDarwin startar de f&ouml;rsta X11-klienterna i anv&auml;ndarens inloggningsskal (Vill du anv&auml;nda ett alternativt skall, kan du specificera detta i inst&auml;llningarna). Hur du st&auml;ller in din s&ouml;kv&auml;g beror p&aring; vilket skal du anv&auml;nder. Exakt hur beskrivs i skalets man-sidor.</p>
+
+<p>Ut&ouml;ver detta kan du ocks&aring; vilja l&auml;gga till X11s man-sidor (dokumentation) till listan &auml;ver sidor som som skall s&ouml;kas n&auml;r du vill l&auml;sa efter dokumentationen. X11s man-sidor ligger i <code>/usr/X11R6/man</code> och listan &auml;ver kataloger att s&ouml;ka best&auml;mms av variabeln<code>MANPATH</code>.</p>
+
+<h2><a NAME="prefs">Inst&auml;llningar</a></h2>
+<p>I inst&auml;llningarna finns ett antal alternativ d&auml;r du kan p&aring;verka hur XDarwin beter sig i vissa fall. Inst&auml;llningarna kommer du till genom att v&auml;lja "Inst&auml;llningar..." i menyn "XDarwin". De alternativ som finns under fliken "Starta" tr&auml;der inte i kraft f&ouml;rr&auml;n du startat om programmet. Alla andra alternativ tr&auml;der i kraft omedelbart. De olika alternativen beskrivs nedan:</p>
+<h3>Diverse</h3>
+<ul>
+ <li><b>Anv&auml;nd Mac OS varningsljud i X11:</b> N&auml;r detta alternativ &auml;r valt anv&auml;nds Mac OS vanliga varningsljud &auml;r X11s varningsljud (bell). N&auml;r detta alternativ inte &auml;r valt (f&ouml;rvalt) anv&auml;nds en vanlig ton.</li>
+ <li><b>Till&aring;t X11 att &auml;ndra musens acceleration:</b> I ett vanligt X11-system kan f&ouml;nsterhanteraren &auml;ndra musens acceleration. Detta kan vara f&ouml;rvirrande eftersom musens acceleration kan vara olika i Mac OS Xs System Preferences och i f&ouml;nsterhanteraren i X11. F&ouml;rvalet &auml;r att X11 inte kan &auml;ndra musens acceleration f&ouml;r att p&aring; detta s&auml;tt undvika detta problem.</li>
+ <li><b>Emulera flerknapparsmus:</b> Detta beskrivs ovan under <a HREF="#usage">Anv&auml;ndande</a>. N&auml;r emulationen &auml;r aktiv m&aring;ste du h&aring;lla ner de valda knapparna f&ouml;r att emulera en andra eller tredje musknapp.</li>
+</ul>
+<h3>Starta</h3>
+<ul>
+ <li><b>F&ouml;rvalt l&auml;ge:</b> Om anv&auml;ndaren inte p&aring; annat s&auml;tt v&auml;ljer vilket l&auml;ge som skall anv&auml;ndas kommer alternativet h&auml;r att anv&auml;ndas.</li>
+ <li><b>Visa val av sk&auml;rml&auml;ge vid start:</b> F&ouml;rvalet &auml;r att visa ett f&ouml;nster n&auml;r XDarwin startar som l&aring;ter anv&auml;ndaren v&auml;lja mellan fullsk&auml;rmsl&auml;ge och rotl&ouml;st l&auml;ge. Om detta alternativ inte &auml;r aktivt kommer XDarwin automatiskt att startas i det l&auml;ge som valts ovan.</li>
+ <li><b>Sk&auml;rmnummer i X11:</b> X11 till&aring;ter att det finns flera sk&auml;rmar styrda av varsin X-server p&aring; en och samma dator. Anv&auml;ndaren kan ange vilket nummer XDarwin skall anv&auml;nda om mer &auml;n en X-server skall anv&auml;ndas samtidigt.</li>
+ <li><b>Aktivera Xinerama (st&ouml;d f&ouml;r flera sk&auml;rmar):</b> XDarwin st&ouml;djer flera sk&auml;rmar genom Xinerama, vilket hanterar alla skr&auml;mar som delar av en enda stor rektangul&auml;r sk&auml;rm. Du kan anv&auml;nda detta alternativ f&ouml;r att st&auml;nga av Xinerama, men f&ouml;r n&auml;rvarande kan inte XDarwin hantera flera sk&auml;rmar utan det. Om du bara har en sk&auml;rm kommer Xinerama automatiskt att deaktiveras.</li>
+ <li><b>Fil med tangentbordsupps&auml;ttning:</b> En fil som anger tangentbordsupps&auml;ttning l&auml;ses vid start och &ouml;vers&auml;tts till en tangentborsupps&auml;ttningsfil f&ouml;r X11. Filer med tangentbordsupps&auml;ttningar f&ouml;r ett stort antal spr&aring;k finns i <code>/System/Library/Keyboards</code>.</li>
+ <li><b>Startar f&ouml;rsta X11-klienterna:</b> N&auml;r X11 startas fr&aring;n Finder kommer det att exekvera filen <code>xinit</code> f&ouml;r att starta f&ouml;nsterhanteraren i X11 och andra program. (Se "<code>man xinit</code>" f&ouml;r mer information.) Innan XDarwin k&ouml;r xinit kommer det att l&auml;gga till katalogern h&auml;r till anv&auml;ndarens s&ouml;kv&auml;g. F&ouml;rvalet &auml;r att endast l&auml;gga till katalogen <code>/usr/X11R6/bin</code>. Ytterligare kataloger kan l&auml;ggas till - separera dem med kolon. X11-klienterna startas i anv&auml;ndarens inloggningsskal s&aring; att anv&auml;ndarens inst&auml;llningsfiler i skalet l&auml;ses. Om s&aring; &ouml;nskas kan de startas i ett annat skal.</li>
+</ul>
+<h3>Fullsk&auml;rm</h3>
+<ul>
+ <li><b>Tangentkombinationsknappen:</b> Tryck p&aring; denna knapp och en tangentkombination f&ouml;r att &auml;ndra den tangentkombination som anv&auml;nds f&ouml;r att byta mellan X11 och Aqua.</li>
+ <li><b>Klick p&aring; ikonen i dockan byter till X11:</b> Aktivera detta alternativ f&ouml;r att byta till X11 genom att klicka p&aring; ikonen i dockan. I vissa versioner av Mac OS X kommer ett bte p&aring; detta s&auml;tt att g&ouml;mma pekaren n&auml;r du &aring;terv&auml;nder till Aqua.</li>
+ <li><b>Visa fullsk&auml;rmshj&auml;lp vid start:</b> Detta kommer att visa en informationsruta n&auml;r XDarwin startas i fullsk&auml;rmsl&auml;ge.</li>
+ <li><b>F&auml;rgdjup:</b> I fullsk&auml;rmsl&auml;ge kan X11 anv&auml;nda ett annat f&auml;rgdjup &auml;n Aquas. Om du v&auml;jer "Nuvarande" kommer X11 att anv&auml;nda det f&auml;rgdjup som Aqua har just d&aring;. Annars kan du v&auml;lja 8, 15, eller 24 bitare f&auml;rg.</li>
+</ul>
+
+<h2><a NAME="license">Licens (svenska)</a></h2>
+<p>Den huvudsakliga licens vi anv&auml;nder oss av &auml;r baserad p&aring; den traditionella MIT X11 / XConsortium-licensen, vilken inte p&aring; n&aring;got s&auml;tt begr&auml;nsar f&ouml;r&auml;ndringar eller vidarespridning av vare sig k&auml;llkod eller kompilerad programvara annat &auml;n genom att kr&auml;va att delarna som r&ouml;r copyright och licensiering l&auml;mnas intakta. F&ouml;r mer information och ytterligare copyright/licensieringsinfromation r&ouml;rande vissa speciella delar av koden, se the source code.</p>
+
+<h3>Licence (english)</h3>
+<p>The main license for XDarwin is based on the traditional MIT X11 / X Consortium License, which does not impose any conditions on modification or redistribution of source code or binaries other than requiring that copyright/license notices are left intact. For more information and additional copyright/licensing notices covering some sections of the code, please refer to the source code.</p>
+
+<H3><A NAME="3"></A>X Consortium License</H3>
+<p>Copyright (C) 1996 X Consortium</p>
+<p>Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without
+limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to
+whom the Software is furnished to do so, subject to the following conditions:</p>
+<p>The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.</p>
+<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.</p>
+<p>Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization from
+the X Consortium.</p>
+<p>X Window System is a trademark of X Consortium, Inc.</p>
+</body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/XDarwin.icns b/nx-X11/programs/Xserver/hw/darwin/bundle/XDarwin.icns
new file mode 100644
index 000000000..9c560846e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/XDarwin.icns
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/Credits.rtf b/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/Credits.rtf
new file mode 100644
index 000000000..34408e78c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/Credits.rtf
@@ -0,0 +1,168 @@
+{\rtf1\mac\ansicpg10000\cocoartf102
+{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fswiss\fcharset77 Helvetica-Oblique;
+}
+{\colortbl;\red255\green255\blue255;}
+\vieww5160\viewh6300\viewkind0
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\fs24 \cf0 This product includes software developed by The XFree86 Project, Inc (http://www.xfree86.org/) and its contributors. The following people contributed to Darwin/Mac OS X support.\
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Contributors to Xorg Foundation Release:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Kaleb KEITHLEY\
+
+\f2\i Working left and right Ctrl, Alt (Option), Meta (Command) and Shift keys.
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\f1\b \cf0 Contributors to XFree86 4.4:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Harper\
+
+\f2\i Rootless acceleration and Apple-WM extension
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Additional XonX Contributors to XFree86 4.3:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Fabr\'92cio Luis de Castro\
+
+\f2\i Portuguese localization
+\f0\i0 \
+Michael Oland\
+
+\f2\i New XDarwin icon
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 XonX Contributors to XFree86 4.2:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+
+\f2\i Darwin x86 support
+\f0\i0 \
+Pablo Di Noto\
+
+\f2\i Spanish localization
+\f0\i0 \
+Paul Edens\
+
+\f2\i Dutch localization
+\f0\i0 \
+Kyunghwan Kim\
+
+\f2\i Korean localization
+\f0\i0 \
+Mario Klebsch\
+
+\f2\i Non-US keyboard support
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+Andreas Monitzer\
+
+\f2\i German localization
+\f0\i0 \
+Patrik Montgomery\
+
+\f2\i Swedish localization
+\f0\i0 \
+Greg Parker\
+
+\f2\i Rootless support
+\f0\i0 \
+Toshimitsu Tanaka\
+
+\f2\i Japanese localization
+\f0\i0 \
+Olivier Verdier\
+
+\f2\i French localization
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 Special Thanks:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Devin Poolman and Zero G Software, Inc.\
+
+\f2\i Installer
+\f0\i0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f1\b \cf0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+\cf0 XonX Team Members\
+Contributing to XFree86 4.1:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Rob Braun\
+
+\f2\i Darwin x86 support
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Project Lead
+\f0\i0 \
+Andreas Monitzer\
+
+\f2\i Cocoa version of XDarwin front end
+\f0\i0 \
+Greg Parker\
+
+\f2\i Original Quartz implementation
+\f0\i0 \
+Christoph Pfisterer\
+
+\f2\i Dynamic shared libraries
+\f0\i0 \
+Toshimitsu Tanaka\
+
+\f2\i Japanese localization
+\f0\i0 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 Special Thanks:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 Tiago Ribeiro\
+
+\f2\i XDarwin icon
+\f0\i0 \
+\
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
+
+\f1\b \cf0 History:
+\f0\b0 \
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+\cf0 John Carmack\
+
+\f2\i Original XFree86 port to Mac OS X Server
+\f0\i0 \
+Dave Zarzycki\
+
+\f2\i XFree86 4.0 port to Darwin 1.0
+\f0\i0 \
+Torrey T. Lyons\
+
+\f2\i Integration into XFree86 Project for 4.0.2} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/Imakefile b/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/Imakefile
new file mode 100644
index 000000000..d367fbcee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/Imakefile
@@ -0,0 +1,36 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/Imakefile,v 1.1 2001/05/21 01:42:17 torrey Exp $
+
+#include <Server.tmpl>
+
+LinkSourceFile(InfoPlist.strings.cpp,../English.lproj)
+
+INCLUDES = -I$(SERVERSRC)/include
+
+#if defined (XorgVersionString)
+VERS = XorgVersionString
+PRE = XORG_VERSION_SNAP
+NAME = "X Version 11"
+LINK = '<a HREF="http://wiki.x.org/">X.Org Foundation</a>'
+#elif defined XFree86VersionString
+VERS = XFree86VersionString
+PRE = XF86_VERSION_SNAP
+NAME = "XFree86"
+LINK = '<a HREF="http://www.XFree86.Org/">XFree86 Project, Inc.</a>'
+#endif
+DATE = XFree86DateString
+X_DEFS = $(INCLUDES) -DX_VERSION=$(VERS) -DX_PRE_RELEASE=$(PRE) \
+ -DX_REL_DATE=$(DATE) -DX_VENDOR_NAME=$(NAME) -DX_VENDOR_LINK=$(LINK)
+
+AllTarget(XDarwinHelp.html)
+CppFileTarget(XDarwinHelp.html,XDarwinHelp.html.cpp,$(X_DEFS), \
+ NullParameter)
+
+AllTarget(InfoPlist.strings)
+InfoPlist.strings: InfoPlist.strings.cpp
+ RemoveFile($@)
+ ClearmakeOSName \
+ $(CPP) CppNoLineInfoOption $(X_DEFS) <InfoPlist.strings.cpp | \
+ CppSedMagic | sed 's/__quote__/"/g' >$@
+
+clean::
+ RemoveFiles(InfoPlist.strings)
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/Localizable.strings b/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/Localizable.strings
new file mode 100644
index 000000000..fb8c77e0d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/Localizable.strings
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/MainMenu.nib/classes.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/MainMenu.nib/classes.nib
new file mode 100644
index 000000000..77f345a4e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/MainMenu.nib/classes.nib
@@ -0,0 +1,72 @@
+{
+ IBClasses = (
+ {
+ ACTIONS = {showHelp = id; };
+ CLASS = FirstResponder;
+ LANGUAGE = ObjC;
+ SUPERCLASS = NSObject;
+ },
+ {
+ ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; };
+ CLASS = Preferences;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ addToPathButton = id;
+ addToPathField = id;
+ button2ModifiersMatrix = id;
+ button3ModifiersMatrix = id;
+ depthButton = id;
+ displayField = id;
+ dockSwitchButton = id;
+ fakeButton = id;
+ keymapFileField = id;
+ modeMatrix = id;
+ modeWindowButton = id;
+ mouseAccelChangeButton = id;
+ startupHelpButton = id;
+ switchKeyButton = id;
+ systemBeepButton = id;
+ useDefaultShellMatrix = id;
+ useOtherShellField = id;
+ useXineramaButton = id;
+ window = id;
+ };
+ SUPERCLASS = NSObject;
+ },
+ {
+ CLASS = XApplication;
+ LANGUAGE = ObjC;
+ OUTLETS = {preferences = id; xserver = id; };
+ SUPERCLASS = NSApplication;
+ },
+ {
+ ACTIONS = {
+ bringAllToFront = id;
+ closeHelpAndShow = id;
+ itemSelected = id;
+ nextWindow = id;
+ previousWindow = id;
+ showAction = id;
+ showSwitchPanel = id;
+ startFullScreen = id;
+ startRootless = id;
+ };
+ CLASS = XServer;
+ LANGUAGE = ObjC;
+ OUTLETS = {
+ dockMenu = NSMenu;
+ helpWindow = NSWindow;
+ modeWindow = NSWindow;
+ startFullScreenButton = NSButton;
+ startRootlessButton = NSButton;
+ startupHelpButton = NSButton;
+ startupModeButton = NSButton;
+ switchWindow = NSPanel;
+ windowMenu = NSMenu;
+ windowSeparator = NSMenuItem;
+ };
+ SUPERCLASS = NSObject;
+ }
+ );
+ IBVersion = 1;
+} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/MainMenu.nib/objects.nib b/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/MainMenu.nib/objects.nib
new file mode 100644
index 000000000..8f9b5e01c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/MainMenu.nib/objects.nib
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/XDarwinHelp.html.cpp b/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/XDarwinHelp.html.cpp
new file mode 100644
index 000000000..5996285ae
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/XDarwinHelp.html.cpp
@@ -0,0 +1,96 @@
+<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.1 2001/05/21 01:42:17 torrey Exp $ -->
+
+<html>
+<head>
+<title>XDarwin Help</title>
+</head>
+<body>
+<center>
+ <h1>XDarwin X Server for Mac OS X</h1>
+ X_VENDOR_NAME X_VERSION<br>
+ Release Date: X_REL_DATE
+</center>
+<h2>Contents</h2>
+<ol>
+ <li><A HREF="#notice">Important Notice</A></li>
+ <li><A HREF="#usage">Usage</A></li>
+ <li><A HREF="#path">Setting Your Path</A></li>
+ <li><A HREF="#prefs">User Preferences</A></li>
+ <li><A HREF="#license">License</A></li>
+</ol>
+<center>
+ <h2><a NAME="notice">Important Notice</a></h2>
+</center>
+<blockquote>
+#if X_PRE_RELEASE
+This is a pre-release version of XDarwin, and is not supported in any way. Bugs may be reported and patches may be submitted to the <A HREF="http://sourceforge.net/projects/xonx/">XonX project page</A> at SourceForge. Before reporting bugs in pre-release versions, please check the latest version from <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> or the X_VENDOR_LINK.
+#else
+If the server is older than 6-12 months, or if your hardware is newer than the above date, look for a newer version before reporting problems. Bugs may be reported and patches may be submitted to the <A HREF="http://sourceforge.net/projects/xonx/">XonX project page</A> at SourceForge.
+#endif
+</blockquote>
+<blockquote>
+This software is distributed under the terms of the <A HREF="#license">MIT X11 / X Consortium License</A> and is provided AS IS, with no warranty. Please read the <A HREF="#license">License</A> before using.</blockquote>
+
+<h2><a NAME="usage">Usage</a></h2>
+<p>XDarwin is a freely redistributable open-source X server for the <a HREF="http://www.x.org/">X Window System</a>. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin runs on Mac OS X in full screen or rootless modes.</p>
+<p>In full screen mode, when the X window system is active, it takes over the entire screen. You can switch back to the Mac OS X desktop by holding down Command-Option-A. This key combination can be changed in the user preferences. From the Mac OS X desktop, click on the XDarwin icon in the Dock to switch back to the X window system. (You can change this behavior in the user preferences so that you must click the XDarwin icon in the floating switch window instead.)</p>
+<p>In rootless mode, the X window system and Aqua share your display. The root window of the X11 display is the size of the screen and contains all the other windows. The X11 root window is not displayed in rootless mode as Aqua handles the desktop background.</p>
+<h3>Multi-Button Mouse Emulation</h3>
+<p>Many X11 applications rely on the use of a 3-button mouse. You can emulate a 3-button mouse with a single button by holding down various modifier keys while you click the mouse button. This is controlled by settings in the "Multi-Button Mouse Emulation" section of the "General" preferences. By default, emulation is on and holding down the command key and clicking the mouse button will simulate clicking the second mouse button. Holding down the option key and clicking will simulate the third button. You can change to any combination of modifiers to emulate buttons two and three in the preferences. Note, even if the modifiers keys are mapped to some other key with xmodmap, you still must use the actual keys specified in the preferences for multi-button mouse emulation.</p>
+
+<h2><a NAME="path">Setting Your Path</a></h2>
+<p>Your path is the list of directories to be searched for executable commands. The X11 commands are located in <code>/usr/X11R6/bin</code>, which needs to be added to your path. XDarwin does this for you by default and can also add additional directories where you have installed command line applications.</p>
+<p>More experienced users will have already set their path correctly using the initialization files for their shell. In this case, you can inform XDarwin not to modify your path in the preferences. XDarwin launches the initial X11 clients in the user's default login shell. (An alternate shell can also be specified in the preferences.) The way to set the path depends on the shell you are using. This is described in the man page documentation for the shell.</p>
+<p>In addition you may also want to add the X11 man pages to the list of pages to be searched when you are looking for documentation. The X11 man pages are located in <code>/usr/X11R6/man</code> and the <code>MANPATH</code> environment variable contains the list of directories to search.</p>
+
+<h2><a NAME="prefs">User Preferences</a></h2>
+<p>A number of options may be set from the user preferences, accessible from the "Preferences..." menu item in the "XDarwin" menu. The options listed as start up options will not take effect until you have restarted XDarwin. All other options take effect immediately. The various options are described below:</p>
+<h3>General</h3>
+<ul>
+ <li><b>Use System beep for X11:</b> When enabled the standard Mac OS X alert sound is used as the X11 bell. When disabled (default) a simple tone is used.</li>
+ <li><b>Allow X11 to change mouse acceleration:</b> In a standard X window system implementation, the window manager can change the mouse acceleration. This can lead to confusion as the mouse acceleration may be set to different values by the Mac OS X System Preferences and the X window manager. By default, X11 is not allowed to change the mouse acceleration to avoid this problem.</li>
+ <li><b>Multi-Button Mouse Emulation:</b> This is described above under <a HREF="#usage">Usage</a>. When emulation is enabled the selected modifiers must be held down when the mouse button is pushed to emulate the second or third mouse buttons.</li>
+</ul>
+<h3>Start Up</h3>
+<ul>
+ <li><b>Default Mode:</b> If the user does not indicate whether to run in full screen or rootless mode, the mode specified here will be used.</li>
+ <li><b>Show mode pick panel on startup:</b> By default, a panel is displayed when XDarwin is started to allow the user to choose between full screen or rootless mode. If this option is turned off, the default mode will be started automatically.</li>
+ <li><b>X11 Display number:</b> X11 allows there to be multiple displays managed by separate X servers on a single computer. The user may specify an integer display number for XDarwin to use if more than one X server is going to be run simultaneously.</li>
+ <li><b>Allow Xinerama multiple monitor support:</b> XDarwin supports multiple monitors with Xinerama, which treats all monitors as being part of one large rectangular screen. You can disable Xinerama with this option, but currently XDarwin does not handle multiple monitors correctly without it. If you only have a single monitor, Xinerama is automatically disabled.</li>
+ <li><b>Keymapping File:</b> A keymapping file is read at startup and translated to an X11 keymap. Keymapping files, available for a wide variety of languages, are found in <code>/System/Library/Keyboards</code>.</li>
+ <li><b>Starting First X11 Clients:</b> When XDarwin is started from the Finder, it will run <code>xinit</code> to launch the X window manager and other X clients. (See "<code>man xinit</code>" for more information.) Before XDarwin runs <code>xinit</code> it will add the specified directories to the user's path. By default only <code>/usr/X11R6/bin</code> is added. Additional directories may added, separated by a colon. The X clients are started in the user's default login shell so that the user's shell initialization files are read. If desired, an alternate shell may be specified.</li>
+</ul>
+<h3>Full Screen</h3>
+<ul>
+ <li><b>Key combination button:</b> Click this button and then press any number of modifiers followed by a standard key to change the key combination to switch between Aqua and X11.</li>
+ <li><b>Click on icon in Dock switches to X11:</b> Enable this to activate switching to X11 by clicking on the XDarwin icon in the Dock. On some versions of Mac OS X, switching by clicking in the Dock can cause the cursor to disappear on returning to Aqua.</li>
+ <li><b>Show help on startup:</b> This will show an introductory splash screen when XDarwin is started in full screen mode.</li>
+ <li><b>Color bit depth:</b> In full screen mode, the X11 display can use a different color bit depth than is used by Aqua. If "Current" is specified, the depth used by Aqua when XDarwin starts will be used. Otherwise 8, 15, or 24 bits may be specified.</li>
+</ul>
+
+<h2><a NAME="license">License</a></h2>
+The main license for XDarwin is based on the traditional MIT X11 / X Consortium License, which does not impose any conditions on modification or redistribution of source code or binaries other than requiring that copyright/license notices are left intact. For more information and additional copyright/licensing notices covering some sections of the code, please refer to the source code.
+<H3><A NAME="3"></A>X Consortium License</H3>
+<p>Copyright (C) 1996 X Consortium</p>
+<p>Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without
+limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to
+whom the Software is furnished to do so, subject to the following conditions:</p>
+<p>The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.</p>
+<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.</p>
+<p>Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization from
+the X Consortium.</p>
+<p>X Window System is a trademark of X Consortium, Inc.</p>
+</body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/darwin/bundle/startXClients.cpp b/nx-X11/programs/Xserver/hw/darwin/bundle/startXClients.cpp
new file mode 100644
index 000000000..51cdb5c9e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/bundle/startXClients.cpp
@@ -0,0 +1,24 @@
+XCOMM!/bin/sh
+
+XCOMM This script is used by XDarwin to start X clients when XDarwin is
+XCOMM launched from the Finder.
+XCOMM
+XCOMM $XFree86: $
+
+userclientrc=$HOME/.xinitrc
+sysclientrc=XINITDIR/xinitrc
+clientargs=""
+
+if [ -f $userclientrc ]; then
+ clientargs=$userclientrc
+else if [ -f $sysclientrc ]; then
+ clientargs=$sysclientrc
+fi
+fi
+
+if [ "x$2" != "x" ]; then
+ PATH="$PATH:$2"
+ export PATH
+fi
+
+exec xinit $clientargs -- XBINDIR/XDarwinStartup "$1" -idle
diff --git a/nx-X11/programs/Xserver/hw/darwin/darwin.c b/nx-X11/programs/Xserver/hw/darwin/darwin.c
new file mode 100644
index 000000000..99241d927
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/darwin.c
@@ -0,0 +1,1108 @@
+/**************************************************************
+ *
+ * Shared code for the Darwin X Server
+ * running with Quartz or IOKit display mode
+ *
+ **************************************************************/
+/*
+ * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XdotOrg: xc/programs/Xserver/hw/darwin/darwin.c,v 1.8 2005/07/03 08:53:38 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/darwin.c,v 1.55 2003/11/15 00:07:09 torrey Exp $ */
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "os.h"
+#include "servermd.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "mibstore.h" // mi backing store implementation
+#include "mipointer.h" // mi software cursor
+#include "micmap.h" // mi colormap code
+#include "fb.h" // fb framebuffer code
+#include "site.h"
+#include "globals.h"
+#include "xorgVersion.h"
+#include "xf86Date.h"
+#include "dix.h"
+
+#ifdef XINPUT
+# include <X11/extensions/XI.h>
+# include <X11/extensions/XIproto.h>
+# include "exevents.h"
+# include "extinit.h"
+#endif
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/syslimits.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#define HAS_UTSNAME 1
+#include <sys/utsname.h>
+
+#define NO_CFPLUGIN
+#include <IOKit/IOKitLib.h>
+#include <IOKit/hidsystem/IOHIDLib.h>
+#include <IOKit/hidsystem/ev_keymap.h>
+
+#include "darwin.h"
+#include "darwinClut8.h"
+
+/*
+ * X server shared global variables
+ */
+int darwinScreensFound = 0;
+int darwinScreenIndex = 0;
+io_connect_t darwinParamConnect = 0;
+int darwinEventReadFD = -1;
+int darwinEventWriteFD = -1;
+int darwinMouseAccelChange = 1;
+int darwinFakeButtons = 0;
+
+// location of X11's (0,0) point in global screen coordinates
+int darwinMainScreenX = 0;
+int darwinMainScreenY = 0;
+
+// parameters read from the command line or user preferences
+unsigned int darwinDesiredWidth = 0, darwinDesiredHeight = 0;
+int darwinDesiredDepth = -1;
+int darwinDesiredRefresh = -1;
+char *darwinKeymapFile = "USA.keymapping";
+int darwinSyncKeymap = FALSE;
+int darwinSwapAltMeta = FALSE;
+
+// modifier masks for faking mouse buttons
+int darwinFakeMouse2Mask = NX_COMMANDMASK;
+int darwinFakeMouse3Mask = NX_ALTERNATEMASK;
+
+// devices
+DeviceIntPtr darwinPointer = NULL;
+DeviceIntPtr darwinKeyboard = NULL;
+
+// Common pixmap formats
+static PixmapFormatRec formats[] = {
+ { 1, 1, BITMAP_SCANLINE_PAD },
+ { 4, 8, BITMAP_SCANLINE_PAD },
+ { 8, 8, BITMAP_SCANLINE_PAD },
+ { 15, 16, BITMAP_SCANLINE_PAD },
+ { 16, 16, BITMAP_SCANLINE_PAD },
+ { 24, 32, BITMAP_SCANLINE_PAD },
+ { 32, 32, BITMAP_SCANLINE_PAD }
+};
+const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
+
+#ifndef OSNAME
+#define OSNAME " Darwin"
+#endif
+#ifndef OSVENDOR
+#define OSVENDOR ""
+#endif
+#ifndef PRE_RELEASE
+#define PRE_RELEASE XORG_VERSION_SNAP
+#endif
+
+void
+DarwinPrintBanner()
+{
+#if PRE_RELEASE
+ ErrorF("\n"
+ "This is a pre-release version of the " XVENDORNAME " X11.\n"
+ "Portions of this release are based on XFree86 4.4RC2 and selected\n"
+ "files from XFree86 4.4RC3. It is not supported in any way.\n"
+ "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n"
+ "Select the \"xorg\" product for bugs you find in this release.\n"
+ "Before reporting bugs in pre-release versions please check the\n"
+ "latest version in the " XVENDORNAME " \"monolithic tree\" CVS\n"
+ "repository hosted at http://www.freedesktop.org/Software/xorg/");
+#endif
+#if XORG_VERSION_SNAP > 0
+ ErrorF(".%d", XORG_VERSION_SNAP);
+#endif
+
+#if XORG_VERSION_SNAP >= 900
+ ErrorF(" (%d.%d.0 RC %d)", XORG_VERSION_MAJOR, XORG_VERSION_MINOR + 1,
+ XORG_VERSION_SNAP - 900);
+#endif
+
+#ifdef XORG_CUSTOM_VERSION
+ ErrorF(" (%s)", XF86_CUSTOM_VERSION);
+#endif
+ ErrorF("\nRelease Date: %s\n", XF86_DATE);
+ ErrorF("X Protocol Version %d, Revision %d, %s\n",
+ X_PROTOCOL, X_PROTOCOL_REVISION, XORG_RELEASE );
+ ErrorF("Build Operating System:%s%s\n", OSNAME, OSVENDOR);
+#ifdef HAS_UTSNAME
+ {
+ struct utsname name;
+
+ if (uname(&name) == 0) {
+ ErrorF("Current Operating System: %s %s %s %s %s\n",
+ name.sysname, name.nodename, name.release, name.version, name.machine);
+ }
+ }
+#endif
+#if defined(BUILD_DATE) && (BUILD_DATE > 19000000)
+ {
+ struct tm t;
+ char buf[100];
+
+ bzero(&t, sizeof(t));
+ bzero(buf, sizeof(buf));
+ t.tm_mday = BUILD_DATE % 100;
+ t.tm_mon = (BUILD_DATE / 100) % 100 - 1;
+ t.tm_year = BUILD_DATE / 10000 - 1900;
+ if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
+ ErrorF("Build Date: %s\n", buf);
+ }
+#endif
+#if defined(CLOG_DATE) && (CLOG_DATE > 19000000)
+ {
+ struct tm t;
+ char buf[100];
+
+ bzero(&t, sizeof(t));
+ bzero(buf, sizeof(buf));
+ t.tm_mday = CLOG_DATE % 100;
+ t.tm_mon = (CLOG_DATE / 100) % 100 - 1;
+ t.tm_year = CLOG_DATE / 10000 - 1900;
+ if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
+ ErrorF("Changelog Date: %s\n", buf);
+ }
+#endif
+#if defined(BUILDERSTRING)
+ ErrorF("%s \n",BUILDERSTRING);
+#endif
+ ErrorF("\tBefore reporting problems, check "__VENDORDWEBSUPPORT__"\n"
+ "\tto make sure that you have the latest version.\n");
+}
+
+
+/*
+ * DarwinSaveScreen
+ * X screensaver support. Not implemented.
+ */
+static Bool DarwinSaveScreen(ScreenPtr pScreen, int on)
+{
+ // FIXME
+ if (on == SCREEN_SAVER_FORCER) {
+ } else if (on == SCREEN_SAVER_ON) {
+ } else {
+ }
+ return TRUE;
+}
+
+
+/*
+ * DarwinAddScreen
+ * This is a callback from dix during AddScreen() from InitOutput().
+ * Initialize the screen and communicate information about it back to dix.
+ */
+static Bool DarwinAddScreen(
+ int index,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv )
+{
+ int bitsPerRGB, i, dpi;
+ static int foundIndex = 0;
+ Bool ret;
+ VisualPtr visual;
+ ColormapPtr pmap;
+ DarwinFramebufferPtr dfb;
+
+ // reset index of found screens for each server generation
+ if (index == 0) foundIndex = 0;
+
+ // allocate space for private per screen storage
+ dfb = xalloc(sizeof(DarwinFramebufferRec));
+ SCREEN_PRIV(pScreen) = dfb;
+
+ // setup hardware/mode specific details
+ ret = DarwinModeAddScreen(foundIndex, pScreen);
+ foundIndex++;
+ if (! ret)
+ return FALSE;
+
+ bitsPerRGB = dfb->bitsPerComponent;
+
+ // reset the visual list
+ miClearVisualTypes();
+
+ // setup a single visual appropriate for our pixel type
+ if (dfb->colorType == TrueColor) {
+ if (!miSetVisualTypes( dfb->colorBitsPerPixel, TrueColorMask,
+ bitsPerRGB, TrueColor )) {
+ return FALSE;
+ }
+ } else if (dfb->colorType == PseudoColor) {
+ if (!miSetVisualTypes( dfb->colorBitsPerPixel, PseudoColorMask,
+ bitsPerRGB, PseudoColor )) {
+ return FALSE;
+ }
+ } else if (dfb->colorType == StaticColor) {
+ if (!miSetVisualTypes( dfb->colorBitsPerPixel, StaticColorMask,
+ bitsPerRGB, StaticColor )) {
+ return FALSE;
+ }
+ } else {
+ return FALSE;
+ }
+
+ miSetPixmapDepths();
+
+ // machine independent screen init
+ // setup _Screen structure in pScreen
+ if (monitorResolution)
+ dpi = monitorResolution;
+ else
+ dpi = 75;
+
+ // initialize fb
+ if (! fbScreenInit(pScreen,
+ dfb->framebuffer, // pointer to screen bitmap
+ dfb->width, dfb->height, // screen size in pixels
+ dpi, dpi, // dots per inch
+ dfb->pitch/(dfb->bitsPerPixel/8), // pixel width of framebuffer
+ dfb->bitsPerPixel)) // bits per pixel for screen
+ {
+ return FALSE;
+ }
+
+ // set the RGB order correctly for TrueColor
+ if (dfb->bitsPerPixel > 8) {
+ for (i = 0, visual = pScreen->visuals; // someday we may have more than 1
+ i < pScreen->numVisuals; i++, visual++) {
+ if (visual->class == TrueColor) {
+ visual->offsetRed = bitsPerRGB * 2;
+ visual->offsetGreen = bitsPerRGB;
+ visual->offsetBlue = 0;
+ visual->redMask = ((1<<bitsPerRGB)-1) << visual->offsetRed;
+ visual->greenMask = ((1<<bitsPerRGB)-1) << visual->offsetGreen;
+ visual->blueMask = ((1<<bitsPerRGB)-1) << visual->offsetBlue;
+ }
+ }
+ }
+
+#ifdef RENDER
+ if (! fbPictureInit(pScreen, 0, 0)) {
+ return FALSE;
+ }
+#endif
+
+#ifdef MITSHM
+ ShmRegisterFbFuncs(pScreen);
+#endif
+
+ // this must be initialized (why doesn't X have a default?)
+ pScreen->SaveScreen = DarwinSaveScreen;
+
+ // finish mode dependent screen setup including cursor support
+ if (!DarwinModeSetupScreen(index, pScreen)) {
+ return FALSE;
+ }
+
+ // create and install the default colormap and
+ // set pScreen->blackPixel / pScreen->white
+ if (!miCreateDefColormap( pScreen )) {
+ return FALSE;
+ }
+
+ /* Set the colormap to the statically defined one if we're in 8 bit
+ * mode and we're using a fixed color map. Essentially this translates
+ * to Darwin/x86 in 8-bit mode.
+ */
+ if( (dfb->colorBitsPerPixel == 8) &&
+ (dfb->colorType == StaticColor) )
+ {
+ pmap = miInstalledMaps[pScreen->myNum];
+ visual = pmap->pVisual;
+ for( i = 0; i < visual->ColormapEntries; i++ ) {
+ pmap->red[i].co.local.red = darwinClut8[i].red;
+ pmap->red[i].co.local.green = darwinClut8[i].green;
+ pmap->red[i].co.local.blue = darwinClut8[i].blue;
+ }
+ }
+
+ dixScreenOrigins[index].x = dfb->x;
+ dixScreenOrigins[index].y = dfb->y;
+
+ ErrorF("Screen %d added: %dx%d @ (%d,%d)\n",
+ index, dfb->width, dfb->height, dfb->x, dfb->y);
+
+ return TRUE;
+}
+
+/*
+ =============================================================================
+
+ mouse and keyboard callbacks
+
+ =============================================================================
+*/
+
+/*
+ * DarwinChangePointerControl
+ * Set mouse acceleration and thresholding
+ * FIXME: We currently ignore the threshold in ctrl->threshold.
+ */
+static void DarwinChangePointerControl(
+ DeviceIntPtr device,
+ PtrCtrl *ctrl )
+{
+ kern_return_t kr;
+ double acceleration;
+
+ if (!darwinMouseAccelChange)
+ return;
+
+ acceleration = ctrl->num / ctrl->den;
+ kr = IOHIDSetMouseAcceleration( darwinParamConnect, acceleration );
+ if (kr != KERN_SUCCESS)
+ ErrorF( "Could not set mouse acceleration with kernel return = 0x%x.\n", kr );
+}
+
+
+/*
+ * DarwinMouseProc
+ * Handle the initialization, etc. of a mouse
+ */
+static int DarwinMouseProc(
+ DeviceIntPtr pPointer,
+ int what )
+{
+ char map[6];
+
+ switch (what) {
+
+ case DEVICE_INIT:
+ pPointer->public.on = FALSE;
+
+ // Set button map.
+ map[1] = 1;
+ map[2] = 2;
+ map[3] = 3;
+ map[4] = 4;
+ map[5] = 5;
+ InitPointerDeviceStruct( (DevicePtr)pPointer,
+ map,
+ 5, // numbuttons (4 & 5 are scroll wheel)
+ miPointerGetMotionEvents,
+ DarwinChangePointerControl,
+ 0 );
+#ifdef XINPUT
+ InitValuatorAxisStruct( pPointer,
+ 0, // X axis
+ 0, // min value
+ 16000, // max value (fixme screen size?)
+ 1, // resolution (fixme ?)
+ 1, // min resolution
+ 1 ); // max resolution
+ InitValuatorAxisStruct( pPointer,
+ 1, // X axis
+ 0, // min value
+ 16000, // max value (fixme screen size?)
+ 1, // resolution (fixme ?)
+ 1, // min resolution
+ 1 ); // max resolution
+#endif
+ break;
+
+ case DEVICE_ON:
+ pPointer->public.on = TRUE;
+ AddEnabledDevice( darwinEventReadFD );
+ return Success;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ pPointer->public.on = FALSE;
+ RemoveEnabledDevice( darwinEventReadFD );
+ return Success;
+ }
+
+ return Success;
+}
+
+
+/*
+ * DarwinKeybdProc
+ * Callback from X
+ */
+static int DarwinKeybdProc( DeviceIntPtr pDev, int onoff )
+{
+ switch ( onoff ) {
+ case DEVICE_INIT:
+ DarwinKeyboardInit( pDev );
+ break;
+ case DEVICE_ON:
+ pDev->public.on = TRUE;
+ AddEnabledDevice( darwinEventReadFD );
+ break;
+ case DEVICE_OFF:
+ pDev->public.on = FALSE;
+ RemoveEnabledDevice( darwinEventReadFD );
+ break;
+ case DEVICE_CLOSE:
+ break;
+ }
+
+ return Success;
+}
+
+/*
+===========================================================================
+
+ Utility routines
+
+===========================================================================
+*/
+
+/*
+ * DarwinFindLibraryFile
+ * Search for a file in the standard Library paths, which are (in order):
+ *
+ * ~/Library/ user specific
+ * /Library/ host specific
+ * /Network/Library/ LAN specific
+ * /System/Library/ OS specific
+ *
+ * A sub-path can be specified to search in below the various Library
+ * directories. Returns a new character string (owned by the caller)
+ * containing the full path to the first file found.
+ */
+static char * DarwinFindLibraryFile(
+ const char *file,
+ const char *pathext )
+{
+ // Library search paths
+ char *pathList[] = {
+ "",
+ "/Network",
+ "/System",
+ NULL
+ };
+ char *home;
+ char *fullPath;
+ int i = 0;
+
+ // Return the file name as is if it is already a fully qualified path.
+ if (!access(file, F_OK)) {
+ fullPath = xalloc(strlen(file)+1);
+ strcpy(fullPath, file);
+ return fullPath;
+ }
+
+ fullPath = xalloc(PATH_MAX);
+
+ home = getenv("HOME");
+ if (home) {
+ snprintf(fullPath, PATH_MAX, "%s/Library/%s/%s", home, pathext, file);
+ if (!access(fullPath, F_OK))
+ return fullPath;
+ }
+
+ while (pathList[i]) {
+ snprintf(fullPath, PATH_MAX, "%s/Library/%s/%s", pathList[i++],
+ pathext, file);
+ if (!access(fullPath, F_OK))
+ return fullPath;
+ }
+
+ xfree(fullPath);
+ return NULL;
+}
+
+
+/*
+ * DarwinParseModifierList
+ * Parse a list of modifier names and return a corresponding modifier mask
+ */
+int DarwinParseModifierList(
+ const char *constmodifiers) // string containing list of modifier names
+{
+ int result = 0;
+
+ if (constmodifiers) {
+ char *modifiers = strdup(constmodifiers);
+ char *modifier;
+ int nxkey;
+ char *p = modifiers;
+
+ while (p) {
+ modifier = strsep(&p, " ,+&|/"); // allow lots of separators
+ nxkey = DarwinModifierStringToNXKey(modifier);
+ if (nxkey != -1)
+ result |= DarwinModifierNXKeyToNXMask(nxkey);
+ else
+ ErrorF("fakebuttons: Unknown modifier \"%s\"\n", modifier);
+ }
+ free(modifiers);
+ }
+ return result;
+}
+
+/*
+===========================================================================
+
+ Functions needed to link against device independent X
+
+===========================================================================
+*/
+
+/*
+ * InitInput
+ * Register the keyboard and mouse devices
+ */
+void InitInput( int argc, char **argv )
+{
+ darwinPointer = AddInputDevice(DarwinMouseProc, TRUE);
+ RegisterPointerDevice( darwinPointer );
+
+ darwinKeyboard = AddInputDevice(DarwinKeybdProc, TRUE);
+ RegisterKeyboardDevice( darwinKeyboard );
+
+ DarwinEQInit( (DevicePtr)darwinKeyboard, (DevicePtr)darwinPointer );
+
+ DarwinModeInitInput(argc, argv);
+}
+
+
+/*
+ * DarwinAdjustScreenOrigins
+ * Shift all screens so the X11 (0, 0) coordinate is at the top
+ * left of the global screen coordinates.
+ *
+ * Screens can be arranged so the top left isn't on any screen, so
+ * instead use the top left of the leftmost screen as (0,0). This
+ * may mean some screen space is in -y, but it's better that (0,0)
+ * be onscreen, or else default xterms disappear. It's better that
+ * -y be used than -x, because when popup menus are forced
+ * "onscreen" by dumb window managers like twm, they'll shift the
+ * menus down instead of left, which still looks funny but is an
+ * easier target to hit.
+ */
+void
+DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo)
+{
+ int i, left, top;
+
+ left = dixScreenOrigins[0].x;
+ top = dixScreenOrigins[0].y;
+
+ /* Find leftmost screen. If there's a tie, take the topmost of the two. */
+ for (i = 1; i < pScreenInfo->numScreens; i++) {
+ if (dixScreenOrigins[i].x < left ||
+ (dixScreenOrigins[i].x == left &&
+ dixScreenOrigins[i].y < top))
+ {
+ left = dixScreenOrigins[i].x;
+ top = dixScreenOrigins[i].y;
+ }
+ }
+
+ darwinMainScreenX = left;
+ darwinMainScreenY = top;
+
+ /* Shift all screens so that there is a screen whose top left
+ is at X11 (0,0) and at global screen coordinate
+ (darwinMainScreenX, darwinMainScreenY). */
+
+ if (darwinMainScreenX != 0 || darwinMainScreenY != 0) {
+ for (i = 0; i < pScreenInfo->numScreens; i++) {
+ dixScreenOrigins[i].x -= darwinMainScreenX;
+ dixScreenOrigins[i].y -= darwinMainScreenY;
+ ErrorF("Screen %d placed at X11 coordinate (%d,%d).\n",
+ i, dixScreenOrigins[i].x, dixScreenOrigins[i].y);
+ }
+ }
+}
+
+
+/*
+ * InitOutput
+ * Initialize screenInfo for all actually accessible framebuffers.
+ *
+ * The display mode dependent code gets called three times. The mode
+ * specific InitOutput routines are expected to discover the number
+ * of potentially useful screens and cache routes to them internally.
+ * Inside DarwinAddScreen are two other mode specific calls.
+ * A mode specific AddScreen routine is called for each screen to
+ * actually initialize the screen with the ScreenPtr structure.
+ * After other screen setup has been done, a mode specific
+ * SetupScreen function can be called to finalize screen setup.
+ */
+void InitOutput( ScreenInfo *pScreenInfo, int argc, char **argv )
+{
+ int i;
+ static unsigned long generation = 0;
+
+ pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+ pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+
+ // List how we want common pixmap formats to be padded
+ pScreenInfo->numPixmapFormats = NUMFORMATS;
+ for (i = 0; i < NUMFORMATS; i++)
+ pScreenInfo->formats[i] = formats[i];
+
+ // Allocate private storage for each screen's Darwin specific info
+ if (generation != serverGeneration) {
+ darwinScreenIndex = AllocateScreenPrivateIndex();
+ generation = serverGeneration;
+ }
+
+ // Discover screens and do mode specific initialization
+ DarwinModeInitOutput(argc, argv);
+
+ // Add screens
+ for (i = 0; i < darwinScreensFound; i++) {
+ AddScreen( DarwinAddScreen, argc, argv );
+ }
+
+ DarwinAdjustScreenOrigins(pScreenInfo);
+}
+
+
+/*
+ * OsVendorFataError
+ */
+void OsVendorFatalError( void )
+{
+ ErrorF( " OsVendorFatalError\n" );
+}
+
+
+/*
+ * OsVendorInit
+ * Initialization of Darwin OS support.
+ */
+void OsVendorInit(void)
+{
+ if (serverGeneration == 1) {
+ DarwinPrintBanner();
+ }
+
+ // Find the full path to the keymapping file.
+ if ( darwinKeymapFile ) {
+ char *tempStr = DarwinFindLibraryFile(darwinKeymapFile, "Keyboards");
+ if ( !tempStr ) {
+ ErrorF("Could not find keymapping file %s.\n", darwinKeymapFile);
+ } else {
+ ErrorF("Using keymapping provided in %s.\n", tempStr);
+ }
+ darwinKeymapFile = tempStr;
+ }
+
+ if ( !darwinKeymapFile ) {
+ ErrorF("Reading keymap from the system.\n");
+ }
+}
+
+
+/*
+ * ddxInitGlobals
+ * Called by InitGlobals() from os/util.c.
+ */
+void ddxInitGlobals(void)
+{
+}
+
+
+/*
+ * ddxProcessArgument
+ * Process device-dependent command line args. Returns 0 if argument is
+ * not device dependent, otherwise Count of number of elements of argv
+ * that are part of a device dependent commandline option.
+ */
+int ddxProcessArgument( int argc, char *argv[], int i )
+{
+ int numDone;
+
+ if ((numDone = DarwinModeProcessArgument( argc, argv, i )))
+ return numDone;
+
+ if ( !strcmp( argv[i], "-fakebuttons" ) ) {
+ darwinFakeButtons = TRUE;
+ ErrorF( "Faking a three button mouse\n" );
+ return 1;
+ }
+
+ if ( !strcmp( argv[i], "-nofakebuttons" ) ) {
+ darwinFakeButtons = FALSE;
+ ErrorF( "Not faking a three button mouse\n" );
+ return 1;
+ }
+
+ if (!strcmp( argv[i], "-fakemouse2" ) ) {
+ if ( i == argc-1 ) {
+ FatalError( "-fakemouse2 must be followed by a modifer list\n" );
+ }
+ if (!strcasecmp(argv[i+1], "none") || !strcmp(argv[i+1], ""))
+ darwinFakeMouse2Mask = 0;
+ else
+ darwinFakeMouse2Mask = DarwinParseModifierList(argv[i+1]);
+ ErrorF("Modifier mask to fake mouse button 2 = 0x%x\n",
+ darwinFakeMouse2Mask);
+ return 2;
+ }
+
+ if (!strcmp( argv[i], "-fakemouse3" ) ) {
+ if ( i == argc-1 ) {
+ FatalError( "-fakemouse3 must be followed by a modifer list\n" );
+ }
+ if (!strcasecmp(argv[i+1], "none") || !strcmp(argv[i+1], ""))
+ darwinFakeMouse3Mask = 0;
+ else
+ darwinFakeMouse3Mask = DarwinParseModifierList(argv[i+1]);
+ ErrorF("Modifier mask to fake mouse button 3 = 0x%x\n",
+ darwinFakeMouse3Mask);
+ return 2;
+ }
+
+ if ( !strcmp( argv[i], "-swapAltMeta" ) ) {
+ darwinSwapAltMeta = 1;
+ return 1;
+ }
+
+ if ( !strcmp( argv[i], "-keymap" ) ) {
+ if ( i == argc-1 ) {
+ FatalError( "-keymap must be followed by a filename\n" );
+ }
+ darwinKeymapFile = argv[i+1];
+ return 2;
+ }
+
+ if ( !strcmp( argv[i], "-nokeymap" ) ) {
+ darwinKeymapFile = NULL;
+ return 1;
+ }
+
+ if ( !strcmp( argv[i], "+synckeymap" ) ) {
+ darwinSyncKeymap = TRUE;
+ return 1;
+ }
+
+ if ( !strcmp( argv[i], "-synckeymap" ) ) {
+ darwinSyncKeymap = FALSE;
+ return 1;
+ }
+
+ if ( !strcmp( argv[i], "-size" ) ) {
+ if ( i >= argc-2 ) {
+ FatalError( "-size must be followed by two numbers\n" );
+ }
+#ifdef OLD_POWERBOOK_G3
+ ErrorF( "Ignoring unsupported -size option on old PowerBook G3\n" );
+#else
+ darwinDesiredWidth = atoi( argv[i+1] );
+ darwinDesiredHeight = atoi( argv[i+2] );
+ ErrorF( "Attempting to use width x height = %i x %i\n",
+ darwinDesiredWidth, darwinDesiredHeight );
+#endif
+ return 3;
+ }
+
+ if ( !strcmp( argv[i], "-depth" ) ) {
+ int bitDepth;
+
+ if ( i == argc-1 ) {
+ FatalError( "-depth must be followed by a number\n" );
+ }
+#ifdef OLD_POWERBOOK_G3
+ ErrorF( "Ignoring unsupported -depth option on old PowerBook G3\n");
+#else
+ bitDepth = atoi( argv[i+1] );
+ if (bitDepth == 8)
+ darwinDesiredDepth = 0;
+ else if (bitDepth == 15)
+ darwinDesiredDepth = 1;
+ else if (bitDepth == 24)
+ darwinDesiredDepth = 2;
+ else
+ FatalError( "Unsupported pixel depth. Use 8, 15, or 24 bits\n" );
+ ErrorF( "Attempting to use pixel depth of %i\n", bitDepth );
+#endif
+ return 2;
+ }
+
+ if ( !strcmp( argv[i], "-refresh" ) ) {
+ if ( i == argc-1 ) {
+ FatalError( "-refresh must be followed by a number\n" );
+ }
+#ifdef OLD_POWERBOOK_G3
+ ErrorF( "Ignoring unsupported -refresh option on old PowerBook G3\n");
+#else
+ darwinDesiredRefresh = atoi( argv[i+1] );
+ ErrorF( "Attempting to use refresh rate of %i\n", darwinDesiredRefresh );
+#endif
+ return 2;
+ }
+
+ if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
+ DarwinPrintBanner();
+ exit(0);
+ }
+
+ // XDarwinStartup uses this argument to indicate the IOKit X server
+ // should be started. Ignore it here.
+ if ( !strcmp( argv[i], "-iokit" ) ) {
+ return 1;
+ }
+
+ return 0;
+}
+
+
+/*
+ * ddxUseMsg --
+ * Print out correct use of device dependent commandline options.
+ * Maybe the user now knows what really to do ...
+ */
+void ddxUseMsg( void )
+{
+ ErrorF("\n");
+ ErrorF("\n");
+ ErrorF("Device Dependent Usage:\n");
+ ErrorF("\n");
+ ErrorF("-fakebuttons : fake a three button mouse with Command and Option keys.\n");
+ ErrorF("-nofakebuttons : don't fake a three button mouse.\n");
+ ErrorF("-fakemouse2 <modifiers> : fake middle mouse button with modifier keys.\n");
+ ErrorF("-fakemouse3 <modifiers> : fake right mouse button with modifier keys.\n");
+ ErrorF(" ex: -fakemouse2 \"option,shift\" = option-shift-click is middle button.\n");
+ ErrorF("-keymap <file> : read the keymapping from a file instead of the kernel.\n");
+ ErrorF("-version : show the server version.\n");
+ ErrorF("\n");
+#ifdef DARWIN_WITH_QUARTZ
+ ErrorF("Quartz modes:\n");
+ ErrorF("-fullscreen : run full screen in parallel with Mac OS X window server.\n");
+ ErrorF("-rootless : run rootless inside Mac OS X window server.\n");
+ ErrorF("-quartz : use default Mac OS X window server mode\n");
+ ErrorF("\n");
+ ErrorF("Options ignored in rootless mode:\n");
+#endif
+ ErrorF("-size <height> <width> : use a screen resolution of <height> x <width>.\n");
+ ErrorF("-depth <8,15,24> : use this bit depth.\n");
+ ErrorF("-refresh <rate> : use a monitor refresh rate of <rate> Hz.\n");
+ ErrorF("\n");
+}
+
+
+/*
+ * ddxGiveUp --
+ * Device dependent cleanup. Called by dix before normal server death.
+ */
+void ddxGiveUp( void )
+{
+ ErrorF( "Quitting XDarwin...\n" );
+
+ DarwinModeGiveUp();
+}
+
+
+/*
+ * AbortDDX --
+ * DDX - specific abort routine. Called by AbortServer(). The attempt is
+ * made to restore all original setting of the displays. Also all devices
+ * are closed.
+ */
+void AbortDDX( void )
+{
+ ErrorF( " AbortDDX\n" );
+ /*
+ * This is needed for a abnormal server exit, since the normal exit stuff
+ * MUST also be performed (i.e. the vt must be left in a defined state)
+ */
+ ddxGiveUp();
+}
+
+
+#ifdef DPMSExtension
+/*
+ * DPMS extension stubs
+ */
+Bool DPMSSupported(void)
+{
+ return FALSE;
+}
+
+void DPMSSet(int level)
+{
+}
+
+int DPMSGet(int *level)
+{
+ return -1;
+}
+#endif
+
+
+#include "mivalidate.h" // for union _Validate used by windowstr.h
+#include "windowstr.h" // for struct _Window
+#include "scrnintstr.h" // for struct _Screen
+
+// This is copied from Xserver/hw/xfree86/common/xf86Helper.c.
+// Quartz mode uses this when switching in and out of Quartz.
+// Quartz or IOKit can use this when waking from sleep.
+// Copyright (c) 1997-1998 by The XFree86 Project, Inc.
+
+/*
+ * xf86SetRootClip --
+ * Enable or disable rendering to the screen by
+ * setting the root clip list and revalidating
+ * all of the windows
+ */
+
+void
+xf86SetRootClip (ScreenPtr pScreen, BOOL enable)
+{
+ WindowPtr pWin = WindowTable[pScreen->myNum];
+ WindowPtr pChild;
+ Bool WasViewable = (Bool)(pWin->viewable);
+ Bool anyMarked = TRUE;
+ RegionPtr pOldClip = NULL, bsExposed;
+#ifdef DO_SAVE_UNDERS
+ Bool dosave = FALSE;
+#endif
+ WindowPtr pLayerWin;
+ BoxRec box;
+
+ if (WasViewable)
+ {
+ for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
+ {
+ (void) (*pScreen->MarkOverlappedWindows)(pChild,
+ pChild,
+ &pLayerWin);
+ }
+ (*pScreen->MarkWindow) (pWin);
+ anyMarked = TRUE;
+ if (pWin->valdata)
+ {
+ if (HasBorder (pWin))
+ {
+ RegionPtr borderVisible;
+
+ borderVisible = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_SUBTRACT(pScreen, borderVisible,
+ &pWin->borderClip, &pWin->winSize);
+ pWin->valdata->before.borderVisible = borderVisible;
+ }
+ pWin->valdata->before.resized = TRUE;
+ }
+ }
+
+ /*
+ * Use REGION_BREAK to avoid optimizations in ValidateTree
+ * that assume the root borderClip can't change well, normally
+ * it doesn't...)
+ */
+ if (enable)
+ {
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pScreen->width;
+ box.y2 = pScreen->height;
+ REGION_RESET(pScreen, &pWin->borderClip, &box);
+ REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+ }
+ else
+ {
+ REGION_EMPTY(pScreen, &pWin->borderClip);
+ REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+ }
+
+ ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
+
+ if (WasViewable)
+ {
+ if (pWin->backStorage)
+ {
+ pOldClip = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_COPY(pScreen, pOldClip, &pWin->clipList);
+ }
+
+ if (pWin->firstChild)
+ {
+ anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild,
+ pWin->firstChild,
+ (WindowPtr *)NULL);
+ }
+ else
+ {
+ (*pScreen->MarkWindow) (pWin);
+ anyMarked = TRUE;
+ }
+
+#ifdef DO_SAVE_UNDERS
+ if (DO_SAVE_UNDERS(pWin))
+ {
+ dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin);
+ }
+#endif /* DO_SAVE_UNDERS */
+
+ if (anyMarked)
+ (*pScreen->ValidateTree)(pWin, NullWindow, VTOther);
+ }
+
+ if (pWin->backStorage &&
+ ((pWin->backingStore == Always) || WasViewable))
+ {
+ if (!WasViewable)
+ pOldClip = &pWin->clipList; /* a convenient empty region */
+ bsExposed = (*pScreen->TranslateBackingStore)
+ (pWin, 0, 0, pOldClip,
+ pWin->drawable.x, pWin->drawable.y);
+ if (WasViewable)
+ REGION_DESTROY(pScreen, pOldClip);
+ if (bsExposed)
+ {
+ RegionPtr valExposed = NullRegion;
+
+ if (pWin->valdata)
+ valExposed = &pWin->valdata->after.exposed;
+ (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
+ if (valExposed)
+ REGION_EMPTY(pScreen, valExposed);
+ REGION_DESTROY(pScreen, bsExposed);
+ }
+ }
+ if (WasViewable)
+ {
+ if (anyMarked)
+ (*pScreen->HandleExposures)(pWin);
+#ifdef DO_SAVE_UNDERS
+ if (dosave)
+ (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin);
+#endif /* DO_SAVE_UNDERS */
+ if (anyMarked && pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pWin, NullWindow, VTOther);
+ }
+ if (pWin->realized)
+ WindowsRestructured ();
+ FlushAllOutput ();
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/darwin.h b/nx-X11/programs/Xserver/hw/darwin/darwin.h
new file mode 100644
index 000000000..4f4e9b91f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/darwin.h
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/darwin.h,v 1.20 2003/11/15 00:07:09 torrey Exp $ */
+
+#ifndef _DARWIN_H
+#define _DARWIN_H
+
+#include <IOKit/IOTypes.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include <X11/extensions/XKB.h>
+
+typedef struct {
+ void *framebuffer;
+ int x;
+ int y;
+ int width;
+ int height;
+ int pitch;
+ int colorType;
+ int bitsPerPixel;
+ int colorBitsPerPixel;
+ int bitsPerComponent;
+} DarwinFramebufferRec, *DarwinFramebufferPtr;
+
+
+// From darwin.c
+void DarwinPrintBanner();
+int DarwinParseModifierList(const char *constmodifiers);
+void DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo);
+void xf86SetRootClip (ScreenPtr pScreen, BOOL enable);
+
+// From darwinEvents.c
+Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr);
+void DarwinEQEnqueue(const xEvent *e);
+void DarwinEQPointerPost(xEvent *e);
+void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
+
+// From darwinKeyboard.c
+int DarwinModifierNXKeyToNXKeycode(int key, int side);
+void DarwinKeyboardInit(DeviceIntPtr pDev);
+int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
+int DarwinModifierNXKeyToNXMask(int key);
+int DarwinModifierNXMaskToNXKey(int mask);
+int DarwinModifierStringToNXKey(const char *string);
+
+// Mode specific functions
+Bool DarwinModeAddScreen(int index, ScreenPtr pScreen);
+Bool DarwinModeSetupScreen(int index, ScreenPtr pScreen);
+void DarwinModeInitOutput(int argc,char **argv);
+void DarwinModeInitInput(int argc, char **argv);
+int DarwinModeProcessArgument(int argc, char *argv[], int i);
+void DarwinModeProcessEvent(xEvent *xe);
+void DarwinModeGiveUp(void);
+void DarwinModeBell(int volume, DeviceIntPtr pDevice, pointer ctrl, int class);
+
+
+#undef assert
+#define assert(x) { if ((x) == 0) \
+ FatalError("assert failed on line %d of %s!\n", __LINE__, __FILE__); }
+#define kern_assert(x) { if ((x) != KERN_SUCCESS) \
+ FatalError("assert failed on line %d of %s with kernel return 0x%x!\n", \
+ __LINE__, __FILE__, x); }
+#define SCREEN_PRIV(pScreen) \
+ ((DarwinFramebufferPtr)pScreen->devPrivates[darwinScreenIndex].ptr)
+
+
+#define MIN_KEYCODE XkbMinLegalKeyCode // unfortunately, this isn't 0...
+
+
+/*
+ * Global variables from darwin.c
+ */
+extern int darwinScreenIndex; // index into pScreen.devPrivates
+extern int darwinScreensFound;
+extern io_connect_t darwinParamConnect;
+extern int darwinEventReadFD;
+extern int darwinEventWriteFD;
+extern DeviceIntPtr darwinPointer;
+extern DeviceIntPtr darwinKeyboard;
+
+// User preferences
+extern int darwinMouseAccelChange;
+extern int darwinFakeButtons;
+extern int darwinFakeMouse2Mask;
+extern int darwinFakeMouse3Mask;
+extern int darwinSwapAltMeta;
+extern char *darwinKeymapFile;
+extern int darwinSyncKeymap;
+extern unsigned int darwinDesiredWidth, darwinDesiredHeight;
+extern int darwinDesiredDepth;
+extern int darwinDesiredRefresh;
+
+// location of X11's (0,0) point in global screen coordinates
+extern int darwinMainScreenX;
+extern int darwinMainScreenY;
+
+
+/*
+ * Special ddx events understood by the X server
+ */
+enum {
+ kXDarwinUpdateModifiers // update all modifier keys
+ = LASTEvent+1, // (from X.h list of event names)
+ kXDarwinUpdateButtons, // update state of mouse buttons 2 and up
+ kXDarwinScrollWheel, // scroll wheel event
+
+ /*
+ * Quartz-specific events -- not used in IOKit mode
+ */
+ kXDarwinActivate, // restore X drawing and cursor
+ kXDarwinDeactivate, // clip X drawing and switch to Aqua cursor
+ kXDarwinSetRootClip, // enable or disable drawing to the X screen
+ kXDarwinQuit, // kill the X server and release the display
+ kXDarwinReadPasteboard, // copy Mac OS X pasteboard into X cut buffer
+ kXDarwinWritePasteboard, // copy X cut buffer onto Mac OS X pasteboard
+ /*
+ * AppleWM events
+ */
+ kXDarwinControllerNotify, // send an AppleWMControllerNotify event
+ kXDarwinPasteboardNotify, // notify the WM to copy or paste
+ /*
+ * Xplugin notification events
+ */
+ kXDarwinDisplayChanged, // display configuration has changed
+ kXDarwinWindowState, // window visibility state has changed
+ kXDarwinWindowMoved // window has moved on screen
+};
+
+#endif /* _DARWIN_H */
diff --git a/nx-X11/programs/Xserver/hw/darwin/darwinClut8.h b/nx-X11/programs/Xserver/hw/darwin/darwinClut8.h
new file mode 100644
index 000000000..06e7b71c5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/darwinClut8.h
@@ -0,0 +1,532 @@
+/*
+ * Darwin default 8-bit Colormap for StaticColor
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/darwinClut8.h,v 1.1.8.1 2003/03/04 01:31:43 torrey Exp $ */
+
+#ifndef _DARWIN_CLUT8_
+#define _DARWIN_CLUT8_
+
+#ifdef USE_NEW_CLUT
+
+static xColorItem darwinClut8[] = {
+ { 0, 0xffff, 0xffff, 0xffff, 0, 0 },
+ { 1, 0xfefe, 0xfefe, 0xfefe, 0, 0 },
+ { 2, 0xfdfd, 0xfdfd, 0xfdfd, 0, 0 },
+ { 3, 0xb8b8, 0x2727, 0x2b2b, 0, 0 },
+ { 4, 0xfcfc, 0xfcfc, 0xfcfc, 0, 0 },
+ { 5, 0xffff, 0xffff, 0x0, 0, 0 },
+ { 6, 0xfafa, 0xfafa, 0xfafa, 0, 0 },
+ { 7, 0xf9f9, 0xf9f9, 0xf9f9, 0, 0 },
+ { 8, 0xf8f8, 0xf8f8, 0xf8f8, 0, 0 },
+ { 9, 0xf7f7, 0xf7f7, 0xf7f7, 0, 0 },
+ { 10, 0xf6f6, 0xf6f6, 0xf6f6, 0, 0 },
+ { 11, 0xf5f5, 0xf5f5, 0xf5f5, 0, 0 },
+ { 12, 0xf4f4, 0xf4f4, 0xf4f4, 0, 0 },
+ { 13, 0xf2f2, 0xf2f2, 0xf2f2, 0, 0 },
+ { 14, 0xf1f1, 0xf1f1, 0xf1f1, 0, 0 },
+ { 15, 0x0, 0x0, 0x0, 0, 0 },
+ { 16, 0xefef, 0xefef, 0xefef, 0, 0 },
+ { 17, 0xeeee, 0xeeee, 0xeeee, 0, 0 },
+ { 18, 0xeded, 0xeded, 0xeded, 0, 0 },
+ { 19, 0xebeb, 0xebeb, 0xebeb, 0, 0 },
+ { 20, 0xe8e8, 0xe8e8, 0xe8e8, 0, 0 },
+ { 21, 0xe7e7, 0xe7e7, 0xe7e7, 0, 0 },
+ { 22, 0xc9c9, 0x3838, 0x3e3e, 0, 0 },
+ { 23, 0xe5e5, 0xe5e5, 0xe5e5, 0, 0 },
+ { 24, 0xffff, 0x0, 0xffff, 0, 0 },
+ { 25, 0xfbfb, 0xfbfb, 0xfbfb, 0, 0 },
+ { 26, 0xdede, 0x6c6c, 0x7272, 0, 0 },
+ { 27, 0xe0e0, 0xe0e0, 0xe0e0, 0, 0 },
+ { 28, 0xe8e8, 0x8686, 0x9090, 0, 0 },
+ { 29, 0xdede, 0xdede, 0xdede, 0, 0 },
+ { 30, 0xdddd, 0xdddd, 0xdddd, 0, 0 },
+ { 31, 0xd3d3, 0x7e7e, 0x8d8d, 0, 0 },
+ { 32, 0xd9d9, 0xd9d9, 0xd9d9, 0, 0 },
+ { 33, 0xf3f3, 0x9696, 0xa6a6, 0, 0 },
+ { 34, 0xb1b1, 0x1c1c, 0x3939, 0, 0 },
+ { 35, 0xffff, 0x0, 0x0, 0, 0 },
+ { 36, 0xbebe, 0x5e5e, 0x7272, 0, 0 },
+ { 37, 0xd3d3, 0xd3d3, 0xd3d3, 0, 0 },
+ { 38, 0xc6c6, 0x2e2e, 0x6767, 0, 0 },
+ { 39, 0xd1d1, 0xd1d1, 0xd1d1, 0, 0 },
+ { 40, 0xa3a3, 0x606, 0x4545, 0, 0 },
+ { 41, 0xcece, 0xcece, 0xcece, 0, 0 },
+ { 42, 0xcccc, 0xcccc, 0xffff, 0, 0 },
+ { 43, 0xcccc, 0xcccc, 0xcccc, 0, 0 },
+ { 44, 0xc6c6, 0x8f8f, 0xa7a7, 0, 0 },
+ { 45, 0xe1e1, 0xd3d3, 0xd9d9, 0, 0 },
+ { 46, 0xcece, 0x9e9e, 0xb4b4, 0, 0 },
+ { 47, 0xcaca, 0xcaca, 0xcaca, 0, 0 },
+ { 48, 0xbfbf, 0x3f3f, 0x7d7d, 0, 0 },
+ { 49, 0xc9c9, 0xc9c9, 0xc9c9, 0, 0 },
+ { 50, 0xf4f4, 0x8989, 0xbebe, 0, 0 },
+ { 51, 0xc6c6, 0xc6c6, 0xc6c6, 0, 0 },
+ { 52, 0xd6d6, 0x5151, 0x9797, 0, 0 },
+ { 53, 0xc9c9, 0x2c2c, 0x8484, 0, 0 },
+ { 54, 0x9696, 0x1a1a, 0x6a6a, 0, 0 },
+ { 55, 0xc2c2, 0xc2c2, 0xc2c2, 0, 0 },
+ { 56, 0xf3f3, 0x6f6f, 0xc6c6, 0, 0 },
+ { 57, 0xe5e5, 0x4c4c, 0xbbbb, 0, 0 },
+ { 58, 0xb7b7, 0x5a5a, 0x9c9c, 0, 0 },
+ { 59, 0xbfbf, 0xbfbf, 0xbfbf, 0, 0 },
+ { 60, 0xbebe, 0xbebe, 0xbebe, 0, 0 },
+ { 61, 0xbdbd, 0xbdbd, 0xbdbd, 0, 0 },
+ { 62, 0xb8b8, 0x2121, 0xa2a2, 0, 0 },
+ { 63, 0xd3d3, 0x4444, 0xc0c0, 0, 0 },
+ { 64, 0xc2c2, 0x6666, 0xb7b7, 0, 0 },
+ { 65, 0xf4f4, 0x6666, 0xe6e6, 0, 0 },
+ { 66, 0xfcfc, 0x7373, 0xfdfd, 0, 0 },
+ { 67, 0xb9b9, 0xb9b9, 0xb9b9, 0, 0 },
+ { 68, 0xeaea, 0xdfdf, 0xeaea, 0, 0 },
+ { 69, 0xd4d4, 0x7171, 0xd5d5, 0, 0 },
+ { 70, 0xf9f9, 0x8b8b, 0xffff, 0, 0 },
+ { 71, 0xf5f5, 0xadad, 0xffff, 0, 0 },
+ { 72, 0xbcbc, 0x9292, 0xc2c2, 0, 0 },
+ { 73, 0xc7c7, 0x4f4f, 0xd9d9, 0, 0 },
+ { 74, 0xa0a0, 0x4444, 0xafaf, 0, 0 },
+ { 75, 0xc8c8, 0x8c8c, 0xd5d5, 0, 0 },
+ { 76, 0xd7d7, 0x7474, 0xf7f7, 0, 0 },
+ { 77, 0xb4b4, 0xb4b4, 0xb4b4, 0, 0 },
+ { 78, 0xdada, 0x9595, 0xf9f9, 0, 0 },
+ { 79, 0xeded, 0xcbcb, 0xffff, 0, 0 },
+ { 80, 0xb2b2, 0xb2b2, 0xb2b2, 0, 0 },
+ { 81, 0xa1a1, 0x6161, 0xd7d7, 0, 0 },
+ { 82, 0xb2b2, 0x8585, 0xe2e2, 0, 0 },
+ { 83, 0x5959, 0x2626, 0x9c9c, 0, 0 },
+ { 84, 0x7c7c, 0x5151, 0xcccc, 0, 0 },
+ { 85, 0xb0b0, 0xb0b0, 0xb0b0, 0, 0 },
+ { 86, 0xb4b4, 0x8e8e, 0xfcfc, 0, 0 },
+ { 87, 0xd5d5, 0xc0c0, 0xffff, 0, 0 },
+ { 88, 0x5d5d, 0x3232, 0xcccc, 0, 0 },
+ { 89, 0x7b7b, 0x5c5c, 0xe5e5, 0, 0 },
+ { 90, 0xc0c0, 0xb0b0, 0xfdfd, 0, 0 },
+ { 91, 0x6060, 0x5353, 0xadad, 0, 0 },
+ { 92, 0x1212, 0xc0c, 0x7e7e, 0, 0 },
+ { 93, 0x2e2e, 0x2929, 0x9999, 0, 0 },
+ { 94, 0x7979, 0x7878, 0xe9e9, 0, 0 },
+ { 95, 0x5b5b, 0x5c5c, 0xd0d0, 0, 0 },
+ { 96, 0x6969, 0x6a6a, 0xcccc, 0, 0 },
+ { 97, 0x9393, 0x9494, 0xf8f8, 0, 0 },
+ { 98, 0x9292, 0x9292, 0xc3c3, 0, 0 },
+ { 99, 0x4141, 0x4444, 0xbaba, 0, 0 },
+ { 100, 0xa8a8, 0xabab, 0xffff, 0, 0 },
+ { 101, 0xa3a3, 0xa3a3, 0xa3a3, 0, 0 },
+ { 102, 0xdbdb, 0xdddd, 0xeaea, 0, 0 },
+ { 103, 0x3131, 0x4949, 0xaaaa, 0, 0 },
+ { 104, 0x7070, 0x8f8f, 0xf9f9, 0, 0 },
+ { 105, 0x4848, 0x6666, 0xc1c1, 0, 0 },
+ { 106, 0x5c5c, 0x7e7e, 0xe9e9, 0, 0 },
+ { 107, 0xe2e2, 0xe5e5, 0xebeb, 0, 0 },
+ { 108, 0xb0b0, 0xcdcd, 0xffff, 0, 0 },
+ { 109, 0x6c6c, 0x8989, 0xb7b7, 0, 0 },
+ { 110, 0x3434, 0x6565, 0xafaf, 0, 0 },
+ { 111, 0x8c8c, 0xb9b9, 0xffff, 0, 0 },
+ { 112, 0x3737, 0x7979, 0xd4d4, 0, 0 },
+ { 113, 0x5a5a, 0x9999, 0xeaea, 0, 0 },
+ { 114, 0xe0e, 0x4c4c, 0x9595, 0, 0 },
+ { 115, 0x7979, 0xb9b9, 0xffff, 0, 0 },
+ { 116, 0x8a8a, 0xa3a3, 0xbcbc, 0, 0 },
+ { 117, 0x2020, 0x6161, 0x9d9d, 0, 0 },
+ { 118, 0x8f8f, 0xaeae, 0xcaca, 0, 0 },
+ { 119, 0xa0a, 0x6060, 0xa8a8, 0, 0 },
+ { 120, 0x3f3f, 0x9494, 0xd9d9, 0, 0 },
+ { 121, 0x6363, 0xb5b5, 0xf9f9, 0, 0 },
+ { 122, 0xe2e2, 0xe8e8, 0xeded, 0, 0 },
+ { 123, 0x2828, 0x6a6a, 0x9999, 0, 0 },
+ { 124, 0x5555, 0xb2b2, 0xe7e7, 0, 0 },
+ { 125, 0x3232, 0x8989, 0xa9a9, 0, 0 },
+ { 126, 0xcfcf, 0xdada, 0xdede, 0, 0 },
+ { 127, 0x2929, 0xa1a1, 0xc7c7, 0, 0 },
+ { 128, 0x8686, 0xa9a9, 0xb4b4, 0, 0 },
+ { 129, 0x0, 0x5f5f, 0x7979, 0, 0 },
+ { 130, 0xc0c, 0x7777, 0x8e8e, 0, 0 },
+ { 131, 0x1212, 0x8f8f, 0xabab, 0, 0 },
+ { 132, 0x4141, 0xbaba, 0xd5d5, 0, 0 },
+ { 133, 0x2424, 0x8282, 0x8383, 0, 0 },
+ { 134, 0x2c2c, 0xc4c4, 0xc3c3, 0, 0 },
+ { 135, 0x1a1a, 0xabab, 0xa6a6, 0, 0 },
+ { 136, 0x4b4b, 0xa8a8, 0xa2a2, 0, 0 },
+ { 137, 0xa0a, 0x9393, 0x8585, 0, 0 },
+ { 138, 0xd0d, 0xa5a5, 0x9696, 0, 0 },
+ { 139, 0x2626, 0xbcbc, 0xacac, 0, 0 },
+ { 140, 0x404, 0x8181, 0x7272, 0, 0 },
+ { 141, 0x1919, 0xb3b3, 0x8686, 0, 0 },
+ { 142, 0x2929, 0xc1c1, 0x9494, 0, 0 },
+ { 143, 0x2121, 0x9c9c, 0x7171, 0, 0 },
+ { 144, 0x202, 0x8c8c, 0x5050, 0, 0 },
+ { 145, 0x3535, 0xd0d0, 0x8989, 0, 0 },
+ { 146, 0x4646, 0xa5a5, 0x7676, 0, 0 },
+ { 147, 0x202, 0x7d7d, 0x3939, 0, 0 },
+ { 148, 0x2929, 0xc9c9, 0x7171, 0, 0 },
+ { 149, 0x5757, 0xd6d6, 0x8f8f, 0, 0 },
+ { 150, 0xa2a2, 0xb5b5, 0xaaaa, 0, 0 },
+ { 151, 0x101, 0x8888, 0x2a2a, 0, 0 },
+ { 152, 0x7474, 0xbebe, 0x8a8a, 0, 0 },
+ { 153, 0x1919, 0xb6b6, 0x4747, 0, 0 },
+ { 154, 0x2d2d, 0xc6c6, 0x5151, 0, 0 },
+ { 155, 0x3838, 0xdede, 0x5d5d, 0, 0 },
+ { 156, 0x4c4c, 0xf4f4, 0x6f6f, 0, 0 },
+ { 157, 0x9191, 0x9c9c, 0x9393, 0, 0 },
+ { 158, 0x0, 0x8e8e, 0x1919, 0, 0 },
+ { 159, 0x1010, 0xafaf, 0x2828, 0, 0 },
+ { 160, 0xe3e3, 0xe3e3, 0xe3e3, 0, 0 },
+ { 161, 0x808, 0xa1a1, 0x1a1a, 0, 0 },
+ { 162, 0x5959, 0xc2c2, 0x6161, 0, 0 },
+ { 163, 0xf0f0, 0xf0f0, 0xf0f0, 0, 0 },
+ { 164, 0x8f8f, 0x9c9c, 0x9090, 0, 0 },
+ { 165, 0x2323, 0xcece, 0x2a2a, 0, 0 },
+ { 166, 0x1212, 0xbaba, 0x1717, 0, 0 },
+ { 167, 0x101, 0x8a8a, 0x202, 0, 0 },
+ { 168, 0x303, 0x9a9a, 0x202, 0, 0 },
+ { 169, 0x4040, 0xe4e4, 0x4040, 0, 0 },
+ { 170, 0x808, 0xb2b2, 0x505, 0, 0 },
+ { 171, 0x1313, 0xcccc, 0xf0f, 0, 0 },
+ { 172, 0x3636, 0xd7d7, 0x3232, 0, 0 },
+ { 173, 0x2828, 0xe9e9, 0x1f1f, 0, 0 },
+ { 174, 0x5353, 0xfbfb, 0x4c4c, 0, 0 },
+ { 175, 0x6f6f, 0xafaf, 0x6a6a, 0, 0 },
+ { 176, 0x7171, 0xe0e0, 0x6767, 0, 0 },
+ { 177, 0x3232, 0xc0c0, 0x1212, 0, 0 },
+ { 178, 0x2929, 0xa5a5, 0x808, 0, 0 },
+ { 179, 0x5c5c, 0xdddd, 0x3535, 0, 0 },
+ { 180, 0x0, 0xffff, 0xffff, 0, 0 },
+ { 181, 0x6363, 0xc8c8, 0x4545, 0, 0 },
+ { 182, 0x8686, 0xfdfd, 0x5b5b, 0, 0 },
+ { 183, 0x7171, 0xf6f6, 0x3939, 0, 0 },
+ { 184, 0x5555, 0xcccc, 0x1515, 0, 0 },
+ { 185, 0x0, 0xffff, 0x0, 0, 0 },
+ { 186, 0x9090, 0xcaca, 0x6e6e, 0, 0 },
+ { 187, 0x4343, 0xa7a7, 0x101, 0, 0 },
+ { 188, 0x8d8d, 0xe4e4, 0x3737, 0, 0 },
+ { 189, 0xb3b3, 0xf0f0, 0x6464, 0, 0 },
+ { 190, 0x8585, 0x8e8e, 0x7a7a, 0, 0 },
+ { 191, 0xb0b0, 0xfafa, 0x4d4d, 0, 0 },
+ { 192, 0xd6d6, 0xd6d6, 0xd6d6, 0, 0 },
+ { 193, 0x8888, 0xd0d0, 0x1a1a, 0, 0 },
+ { 194, 0x6a6a, 0xa7a7, 0x303, 0, 0 },
+ { 195, 0x9898, 0xbfbf, 0x4141, 0, 0 },
+ { 196, 0xcdcd, 0xf8f8, 0x5151, 0, 0 },
+ { 197, 0x9494, 0xa4a4, 0x5555, 0, 0 },
+ { 198, 0x9191, 0xb0b0, 0xa0a, 0, 0 },
+ { 199, 0xdada, 0xf1f1, 0x3c3c, 0, 0 },
+ { 200, 0xbaba, 0xcaca, 0x5353, 0, 0 },
+ { 201, 0xb9b9, 0xc3c3, 0x2828, 0, 0 },
+ { 202, 0xb1b1, 0xbaba, 0x1212, 0, 0 },
+ { 203, 0xd2d2, 0xd9d9, 0x2626, 0, 0 },
+ { 204, 0xe8e8, 0xecec, 0x2d2d, 0, 0 },
+ { 205, 0x9898, 0x9696, 0x202, 0, 0 },
+ { 206, 0xadad, 0xadad, 0x5c5c, 0, 0 },
+ { 207, 0xe2e2, 0xd8d8, 0x3838, 0, 0 },
+ { 208, 0xd9d9, 0xc4c4, 0x3838, 0, 0 },
+ { 209, 0xa8a8, 0x9a9a, 0x5050, 0, 0 },
+ { 210, 0x0, 0x0, 0xffff, 0, 0 },
+ { 211, 0xbebe, 0xaeae, 0x5e5e, 0, 0 },
+ { 212, 0x9a9a, 0x9898, 0x8e8e, 0, 0 },
+ { 213, 0xacac, 0x8d8d, 0xd0d, 0, 0 },
+ { 214, 0xc5c5, 0xa0a0, 0x2b2b, 0, 0 },
+ { 215, 0xdbdb, 0xb5b5, 0x4848, 0, 0 },
+ { 216, 0xdddd, 0x0, 0x0, 0, 0 },
+ { 217, 0x9c9c, 0x6d6d, 0x303, 0, 0 },
+ { 218, 0xd4d4, 0xa8a8, 0x4747, 0, 0 },
+ { 219, 0xb7b7, 0x7171, 0x1717, 0, 0 },
+ { 220, 0xdcdc, 0xa1a1, 0x5a5a, 0, 0 },
+ { 221, 0xb9b9, 0x9c9c, 0x7c7c, 0, 0 },
+ { 222, 0xb4b4, 0xabab, 0xa2a2, 0, 0 },
+ { 223, 0x9e9e, 0x4b4b, 0x101, 0, 0 },
+ { 224, 0xc8c8, 0x7878, 0x3535, 0, 0 },
+ { 225, 0xd2d2, 0x8d8d, 0x5151, 0, 0 },
+ { 226, 0xadad, 0x5252, 0xf0f, 0, 0 },
+ { 227, 0x0, 0xbbbb, 0x0, 0, 0 },
+ { 228, 0xb2b2, 0x6666, 0x3838, 0, 0 },
+ { 229, 0xb1b1, 0xa6a6, 0x9f9f, 0, 0 },
+ { 230, 0xb1b1, 0x8787, 0x6f6f, 0, 0 },
+ { 231, 0xa4a4, 0x3434, 0x303, 0, 0 },
+ { 232, 0xeeee, 0x9e9e, 0x8585, 0, 0 },
+ { 233, 0xc9c9, 0x7373, 0x5a5a, 0, 0 },
+ { 234, 0xe6e6, 0x9494, 0x7c7c, 0, 0 },
+ { 235, 0xa9a9, 0x2222, 0x606, 0, 0 },
+ { 236, 0xdbdb, 0x8787, 0x7474, 0, 0 },
+ { 237, 0xb0b0, 0x2e2e, 0x1515, 0, 0 },
+ { 238, 0xb7b7, 0x5a5a, 0x5050, 0, 0 },
+ { 239, 0xb2b2, 0x4242, 0x3b3b, 0, 0 },
+ { 240, 0xcdcd, 0x7373, 0x6e6e, 0, 0 },
+ { 241, 0xd9d9, 0x5858, 0x5858, 0, 0 },
+ { 242, 0xacac, 0xacac, 0xacac, 0, 0 },
+ { 243, 0xa0a0, 0xa0a0, 0xa0a0, 0, 0 },
+ { 244, 0x9a9a, 0x9a9a, 0x9a9a, 0, 0 },
+ { 245, 0x9292, 0x9292, 0x9292, 0, 0 },
+ { 246, 0x8e8e, 0x8e8e, 0x8e8e, 0, 0 },
+ { 247, 0xbbbb, 0xbbbb, 0xbbbb, 0, 0 },
+ { 248, 0x8181, 0x8181, 0x8181, 0, 0 },
+ { 249, 0x8888, 0x8888, 0x8888, 0, 0 },
+ { 250, 0x7777, 0x7777, 0x7777, 0, 0 },
+ { 251, 0x5555, 0x5555, 0x5555, 0, 0 },
+ { 252, 0x4444, 0x4444, 0x4444, 0, 0 },
+ { 253, 0x2222, 0x2222, 0x2222, 0, 0 },
+ { 254, 0x7b7b, 0x7b7b, 0x7b7b, 0, 0 },
+ { 255, 0x0, 0x0, 0x0, 0, 0 },
+};
+
+#else /* !USE_NEW_CLUT */
+
+static xColorItem darwinClut8[] = {
+ { 0, 0x0000, 0x0000, 0x0000, 0, 0 },
+ { 1, 0xffff, 0xffff, 0xcccc, 0, 0 },
+ { 2, 0xffff, 0xffff, 0x9999, 0, 0 },
+ { 3, 0xffff, 0xffff, 0x6666, 0, 0 },
+ { 4, 0xffff, 0xffff, 0x3333, 0, 0 },
+ { 5, 0xffff, 0xffff, 0x0000, 0, 0 },
+ { 6, 0xffff, 0xcccc, 0xffff, 0, 0 },
+ { 7, 0xffff, 0xcccc, 0xcccc, 0, 0 },
+ { 8, 0xffff, 0xcccc, 0x9999, 0, 0 },
+ { 9, 0xffff, 0xcccc, 0x6666, 0, 0 },
+ { 10, 0xffff, 0xcccc, 0x3333, 0, 0 },
+ { 11, 0xffff, 0xcccc, 0x0000, 0, 0 },
+ { 12, 0xffff, 0x9999, 0xffff, 0, 0 },
+ { 13, 0xffff, 0x9999, 0xcccc, 0, 0 },
+ { 14, 0xffff, 0x9999, 0x9999, 0, 0 },
+ { 15, 0xffff, 0x9999, 0x6666, 0, 0 },
+ { 16, 0xffff, 0x9999, 0x3333, 0, 0 },
+ { 17, 0xffff, 0x9999, 0x0000, 0, 0 },
+ { 18, 0xffff, 0x6666, 0xffff, 0, 0 },
+ { 19, 0xffff, 0x6666, 0xcccc, 0, 0 },
+ { 20, 0xffff, 0x6666, 0x9999, 0, 0 },
+ { 21, 0xffff, 0x6666, 0x6666, 0, 0 },
+ { 22, 0xffff, 0x6666, 0x3333, 0, 0 },
+ { 23, 0xffff, 0x6666, 0x0000, 0, 0 },
+ { 24, 0xffff, 0x3333, 0xffff, 0, 0 },
+ { 25, 0xffff, 0x3333, 0xcccc, 0, 0 },
+ { 26, 0xffff, 0x3333, 0x9999, 0, 0 },
+ { 27, 0xffff, 0x3333, 0x6666, 0, 0 },
+ { 28, 0xffff, 0x3333, 0x3333, 0, 0 },
+ { 29, 0xffff, 0x3333, 0x0000, 0, 0 },
+ { 30, 0xffff, 0x0000, 0xffff, 0, 0 },
+ { 31, 0xffff, 0x0000, 0xcccc, 0, 0 },
+ { 32, 0xffff, 0x0000, 0x9999, 0, 0 },
+ { 33, 0xffff, 0x0000, 0x6666, 0, 0 },
+ { 34, 0xffff, 0x0000, 0x3333, 0, 0 },
+ { 35, 0xffff, 0x0000, 0x0000, 0, 0 },
+ { 36, 0xcccc, 0xffff, 0xffff, 0, 0 },
+ { 37, 0xcccc, 0xffff, 0xcccc, 0, 0 },
+ { 38, 0xcccc, 0xffff, 0x9999, 0, 0 },
+ { 39, 0xcccc, 0xffff, 0x6666, 0, 0 },
+ { 40, 0xcccc, 0xffff, 0x3333, 0, 0 },
+ { 41, 0xcccc, 0xffff, 0x0000, 0, 0 },
+ { 42, 0xcccc, 0xcccc, 0xffff, 0, 0 },
+ { 43, 0xcccc, 0xcccc, 0xcccc, 0, 0 },
+ { 44, 0xcccc, 0xcccc, 0x9999, 0, 0 },
+ { 45, 0xcccc, 0xcccc, 0x6666, 0, 0 },
+ { 46, 0xcccc, 0xcccc, 0x3333, 0, 0 },
+ { 47, 0xcccc, 0xcccc, 0x0000, 0, 0 },
+ { 48, 0xcccc, 0x9999, 0xffff, 0, 0 },
+ { 49, 0xcccc, 0x9999, 0xcccc, 0, 0 },
+ { 50, 0xcccc, 0x9999, 0x9999, 0, 0 },
+ { 51, 0xcccc, 0x9999, 0x6666, 0, 0 },
+ { 52, 0xcccc, 0x9999, 0x3333, 0, 0 },
+ { 53, 0xcccc, 0x9999, 0x0000, 0, 0 },
+ { 54, 0xcccc, 0x6666, 0xffff, 0, 0 },
+ { 55, 0xcccc, 0x6666, 0xcccc, 0, 0 },
+ { 56, 0xcccc, 0x6666, 0x9999, 0, 0 },
+ { 57, 0xcccc, 0x6666, 0x6666, 0, 0 },
+ { 58, 0xcccc, 0x6666, 0x3333, 0, 0 },
+ { 59, 0xcccc, 0x6666, 0x0000, 0, 0 },
+ { 60, 0xcccc, 0x3333, 0xffff, 0, 0 },
+ { 61, 0xcccc, 0x3333, 0xcccc, 0, 0 },
+ { 62, 0xcccc, 0x3333, 0x9999, 0, 0 },
+ { 63, 0xcccc, 0x3333, 0x6666, 0, 0 },
+ { 64, 0xcccc, 0x3333, 0x3333, 0, 0 },
+ { 65, 0xcccc, 0x3333, 0x0000, 0, 0 },
+ { 66, 0xcccc, 0x0000, 0xffff, 0, 0 },
+ { 67, 0xcccc, 0x0000, 0xcccc, 0, 0 },
+ { 68, 0xcccc, 0x0000, 0x9999, 0, 0 },
+ { 69, 0xcccc, 0x0000, 0x6666, 0, 0 },
+ { 70, 0xcccc, 0x0000, 0x3333, 0, 0 },
+ { 71, 0xcccc, 0x0000, 0x0000, 0, 0 },
+ { 72, 0x9999, 0xffff, 0xffff, 0, 0 },
+ { 73, 0x9999, 0xffff, 0xcccc, 0, 0 },
+ { 74, 0x9999, 0xffff, 0x9999, 0, 0 },
+ { 75, 0x9999, 0xffff, 0x6666, 0, 0 },
+ { 76, 0x9999, 0xffff, 0x3333, 0, 0 },
+ { 77, 0x9999, 0xffff, 0x0000, 0, 0 },
+ { 78, 0x9999, 0xcccc, 0xffff, 0, 0 },
+ { 79, 0x9999, 0xcccc, 0xcccc, 0, 0 },
+ { 80, 0x9999, 0xcccc, 0x9999, 0, 0 },
+ { 81, 0x9999, 0xcccc, 0x6666, 0, 0 },
+ { 82, 0x9999, 0xcccc, 0x3333, 0, 0 },
+ { 83, 0x9999, 0xcccc, 0x0000, 0, 0 },
+ { 84, 0x9999, 0x9999, 0xffff, 0, 0 },
+ { 85, 0x9999, 0x9999, 0xcccc, 0, 0 },
+ { 86, 0x9999, 0x9999, 0x9999, 0, 0 },
+ { 87, 0x9999, 0x9999, 0x6666, 0, 0 },
+ { 88, 0x9999, 0x9999, 0x3333, 0, 0 },
+ { 89, 0x9999, 0x9999, 0x0000, 0, 0 },
+ { 90, 0x9999, 0x6666, 0xffff, 0, 0 },
+ { 91, 0x9999, 0x6666, 0xcccc, 0, 0 },
+ { 92, 0x9999, 0x6666, 0x9999, 0, 0 },
+ { 93, 0x9999, 0x6666, 0x6666, 0, 0 },
+ { 94, 0x9999, 0x6666, 0x3333, 0, 0 },
+ { 95, 0x9999, 0x6666, 0x0000, 0, 0 },
+ { 96, 0x9999, 0x3333, 0xffff, 0, 0 },
+ { 97, 0x9999, 0x3333, 0xcccc, 0, 0 },
+ { 98, 0x9999, 0x3333, 0x9999, 0, 0 },
+ { 99, 0x9999, 0x3333, 0x6666, 0, 0 },
+ { 100, 0x9999, 0x3333, 0x3333, 0, 0 },
+ { 101, 0x9999, 0x3333, 0x0000, 0, 0 },
+ { 102, 0x9999, 0x0000, 0xffff, 0, 0 },
+ { 103, 0x9999, 0x0000, 0xcccc, 0, 0 },
+ { 104, 0x9999, 0x0000, 0x9999, 0, 0 },
+ { 105, 0x9999, 0x0000, 0x6666, 0, 0 },
+ { 106, 0x9999, 0x0000, 0x3333, 0, 0 },
+ { 107, 0x9999, 0x0000, 0x0000, 0, 0 },
+ { 108, 0x6666, 0xffff, 0xffff, 0, 0 },
+ { 109, 0x6666, 0xffff, 0xcccc, 0, 0 },
+ { 110, 0x6666, 0xffff, 0x9999, 0, 0 },
+ { 111, 0x6666, 0xffff, 0x6666, 0, 0 },
+ { 112, 0x6666, 0xffff, 0x3333, 0, 0 },
+ { 113, 0x6666, 0xffff, 0x0000, 0, 0 },
+ { 114, 0x6666, 0xcccc, 0xffff, 0, 0 },
+ { 115, 0x6666, 0xcccc, 0xcccc, 0, 0 },
+ { 116, 0x6666, 0xcccc, 0x9999, 0, 0 },
+ { 117, 0x6666, 0xcccc, 0x6666, 0, 0 },
+ { 118, 0x6666, 0xcccc, 0x3333, 0, 0 },
+ { 119, 0x6666, 0xcccc, 0x0000, 0, 0 },
+ { 120, 0x6666, 0x9999, 0xffff, 0, 0 },
+ { 121, 0x6666, 0x9999, 0xcccc, 0, 0 },
+ { 122, 0x6666, 0x9999, 0x9999, 0, 0 },
+ { 123, 0x6666, 0x9999, 0x6666, 0, 0 },
+ { 124, 0x6666, 0x9999, 0x3333, 0, 0 },
+ { 125, 0x6666, 0x9999, 0x0000, 0, 0 },
+ { 126, 0x6666, 0x6666, 0xffff, 0, 0 },
+ { 127, 0x6666, 0x6666, 0xcccc, 0, 0 },
+ { 128, 0x6666, 0x6666, 0x9999, 0, 0 },
+ { 129, 0x6666, 0x6666, 0x6666, 0, 0 },
+ { 130, 0x6666, 0x6666, 0x3333, 0, 0 },
+ { 131, 0x6666, 0x6666, 0x0000, 0, 0 },
+ { 132, 0x6666, 0x3333, 0xffff, 0, 0 },
+ { 133, 0x6666, 0x3333, 0xcccc, 0, 0 },
+ { 134, 0x6666, 0x3333, 0x9999, 0, 0 },
+ { 135, 0x6666, 0x3333, 0x6666, 0, 0 },
+ { 136, 0x6666, 0x3333, 0x3333, 0, 0 },
+ { 137, 0x6666, 0x3333, 0x0000, 0, 0 },
+ { 138, 0x6666, 0x0000, 0xffff, 0, 0 },
+ { 139, 0x6666, 0x0000, 0xcccc, 0, 0 },
+ { 140, 0x6666, 0x0000, 0x9999, 0, 0 },
+ { 141, 0x6666, 0x0000, 0x6666, 0, 0 },
+ { 142, 0x6666, 0x0000, 0x3333, 0, 0 },
+ { 143, 0x6666, 0x0000, 0x0000, 0, 0 },
+ { 144, 0x3333, 0xffff, 0xffff, 0, 0 },
+ { 145, 0x3333, 0xffff, 0xcccc, 0, 0 },
+ { 146, 0x3333, 0xffff, 0x9999, 0, 0 },
+ { 147, 0x3333, 0xffff, 0x6666, 0, 0 },
+ { 148, 0x3333, 0xffff, 0x3333, 0, 0 },
+ { 149, 0x3333, 0xffff, 0x0000, 0, 0 },
+ { 150, 0x3333, 0xcccc, 0xffff, 0, 0 },
+ { 151, 0x3333, 0xcccc, 0xcccc, 0, 0 },
+ { 152, 0x3333, 0xcccc, 0x9999, 0, 0 },
+ { 153, 0x3333, 0xcccc, 0x6666, 0, 0 },
+ { 154, 0x3333, 0xcccc, 0x3333, 0, 0 },
+ { 155, 0x3333, 0xcccc, 0x0000, 0, 0 },
+ { 156, 0x3333, 0x9999, 0xffff, 0, 0 },
+ { 157, 0x3333, 0x9999, 0xcccc, 0, 0 },
+ { 158, 0x3333, 0x9999, 0x9999, 0, 0 },
+ { 159, 0x3333, 0x9999, 0x6666, 0, 0 },
+ { 160, 0x3333, 0x9999, 0x3333, 0, 0 },
+ { 161, 0x3333, 0x9999, 0x0000, 0, 0 },
+ { 162, 0x3333, 0x6666, 0xffff, 0, 0 },
+ { 163, 0x3333, 0x6666, 0xcccc, 0, 0 },
+ { 164, 0x3333, 0x6666, 0x9999, 0, 0 },
+ { 165, 0x3333, 0x6666, 0x6666, 0, 0 },
+ { 166, 0x3333, 0x6666, 0x3333, 0, 0 },
+ { 167, 0x3333, 0x6666, 0x0000, 0, 0 },
+ { 168, 0x3333, 0x3333, 0xffff, 0, 0 },
+ { 169, 0x3333, 0x3333, 0xcccc, 0, 0 },
+ { 170, 0x3333, 0x3333, 0x9999, 0, 0 },
+ { 171, 0x3333, 0x3333, 0x6666, 0, 0 },
+ { 172, 0x3333, 0x3333, 0x3333, 0, 0 },
+ { 173, 0x3333, 0x3333, 0x0000, 0, 0 },
+ { 174, 0x3333, 0x0000, 0xffff, 0, 0 },
+ { 175, 0x3333, 0x0000, 0xcccc, 0, 0 },
+ { 176, 0x3333, 0x0000, 0x9999, 0, 0 },
+ { 177, 0x3333, 0x0000, 0x6666, 0, 0 },
+ { 178, 0x3333, 0x0000, 0x3333, 0, 0 },
+ { 179, 0x3333, 0x0000, 0x0000, 0, 0 },
+ { 180, 0x0000, 0xffff, 0xffff, 0, 0 },
+ { 181, 0x0000, 0xffff, 0xcccc, 0, 0 },
+ { 182, 0x0000, 0xffff, 0x9999, 0, 0 },
+ { 183, 0x0000, 0xffff, 0x6666, 0, 0 },
+ { 184, 0x0000, 0xffff, 0x3333, 0, 0 },
+ { 185, 0x0000, 0xffff, 0x0000, 0, 0 },
+ { 186, 0x0000, 0xcccc, 0xffff, 0, 0 },
+ { 187, 0x0000, 0xcccc, 0xcccc, 0, 0 },
+ { 188, 0x0000, 0xcccc, 0x9999, 0, 0 },
+ { 189, 0x0000, 0xcccc, 0x6666, 0, 0 },
+ { 190, 0x0000, 0xcccc, 0x3333, 0, 0 },
+ { 191, 0x0000, 0xcccc, 0x0000, 0, 0 },
+ { 192, 0x0000, 0x9999, 0xffff, 0, 0 },
+ { 193, 0x0000, 0x9999, 0xcccc, 0, 0 },
+ { 194, 0x0000, 0x9999, 0x9999, 0, 0 },
+ { 195, 0x0000, 0x9999, 0x6666, 0, 0 },
+ { 196, 0x0000, 0x9999, 0x3333, 0, 0 },
+ { 197, 0x0000, 0x9999, 0x0000, 0, 0 },
+ { 198, 0x0000, 0x6666, 0xffff, 0, 0 },
+ { 199, 0x0000, 0x6666, 0xcccc, 0, 0 },
+ { 200, 0x0000, 0x6666, 0x9999, 0, 0 },
+ { 201, 0x0000, 0x6666, 0x6666, 0, 0 },
+ { 202, 0x0000, 0x6666, 0x3333, 0, 0 },
+ { 203, 0x0000, 0x6666, 0x0000, 0, 0 },
+ { 204, 0x0000, 0x3333, 0xffff, 0, 0 },
+ { 205, 0x0000, 0x3333, 0xcccc, 0, 0 },
+ { 206, 0x0000, 0x3333, 0x9999, 0, 0 },
+ { 207, 0x0000, 0x3333, 0x6666, 0, 0 },
+ { 208, 0x0000, 0x3333, 0x3333, 0, 0 },
+ { 209, 0x0000, 0x3333, 0x0000, 0, 0 },
+ { 210, 0x0000, 0x0000, 0xffff, 0, 0 },
+ { 211, 0x0000, 0x0000, 0xcccc, 0, 0 },
+ { 212, 0x0000, 0x0000, 0x9999, 0, 0 },
+ { 213, 0x0000, 0x0000, 0x6666, 0, 0 },
+ { 214, 0x0000, 0x0000, 0x3333, 0, 0 },
+ { 215, 0xeeee, 0x0000, 0x0000, 0, 0 },
+ { 216, 0xdddd, 0x0000, 0x0000, 0, 0 },
+ { 217, 0xbbbb, 0x0000, 0x0000, 0, 0 },
+ { 218, 0xaaaa, 0x0000, 0x0000, 0, 0 },
+ { 219, 0x8888, 0x0000, 0x0000, 0, 0 },
+ { 220, 0x7777, 0x0000, 0x0000, 0, 0 },
+ { 221, 0x5555, 0x0000, 0x0000, 0, 0 },
+ { 222, 0x4444, 0x0000, 0x0000, 0, 0 },
+ { 223, 0x2222, 0x0000, 0x0000, 0, 0 },
+ { 224, 0x1111, 0x0000, 0x0000, 0, 0 },
+ { 225, 0x0000, 0xeeee, 0x0000, 0, 0 },
+ { 226, 0x0000, 0xdddd, 0x0000, 0, 0 },
+ { 227, 0x0000, 0xbbbb, 0x0000, 0, 0 },
+ { 228, 0x0000, 0xaaaa, 0x0000, 0, 0 },
+ { 229, 0x0000, 0x8888, 0x0000, 0, 0 },
+ { 230, 0x0000, 0x7777, 0x0000, 0, 0 },
+ { 231, 0x0000, 0x5555, 0x0000, 0, 0 },
+ { 232, 0x0000, 0x4444, 0x0000, 0, 0 },
+ { 233, 0x0000, 0x2222, 0x0000, 0, 0 },
+ { 234, 0x0000, 0x1111, 0x0000, 0, 0 },
+ { 235, 0x0000, 0x0000, 0xeeee, 0, 0 },
+ { 236, 0x0000, 0x0000, 0xdddd, 0, 0 },
+ { 237, 0x0000, 0x0000, 0xbbbb, 0, 0 },
+ { 238, 0x0000, 0x0000, 0xaaaa, 0, 0 },
+ { 239, 0x0000, 0x0000, 0x8888, 0, 0 },
+ { 240, 0x0000, 0x0000, 0x7777, 0, 0 },
+ { 241, 0x0000, 0x0000, 0x5555, 0, 0 },
+ { 242, 0x0000, 0x0000, 0x4444, 0, 0 },
+ { 243, 0x0000, 0x0000, 0x2222, 0, 0 },
+ { 244, 0x0000, 0x0000, 0x1111, 0, 0 },
+ { 245, 0xeeee, 0xeeee, 0xeeee, 0, 0 },
+ { 246, 0xdddd, 0xdddd, 0xdddd, 0, 0 },
+ { 247, 0xbbbb, 0xbbbb, 0xbbbb, 0, 0 },
+ { 248, 0xaaaa, 0xaaaa, 0xaaaa, 0, 0 },
+ { 249, 0x8888, 0x8888, 0x8888, 0, 0 },
+ { 250, 0x7777, 0x7777, 0x7777, 0, 0 },
+ { 251, 0x5555, 0x5555, 0x5555, 0, 0 },
+ { 252, 0x4444, 0x4444, 0x4444, 0, 0 },
+ { 253, 0x2222, 0x2222, 0x2222, 0, 0 },
+ { 254, 0x1111, 0x1111, 0x1111, 0, 0 },
+ { 255, 0xffff, 0xffff, 0xffff, 0, 0 }
+};
+#endif /* USE_NEW_CLUT */
+
+#endif /* _DARWIN_CLUT8_ */
diff --git a/nx-X11/programs/Xserver/hw/darwin/darwinEvents.c b/nx-X11/programs/Xserver/hw/darwin/darwinEvents.c
new file mode 100644
index 000000000..61100d9b3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/darwinEvents.c
@@ -0,0 +1,481 @@
+/*
+ * Darwin event queue and event handling
+ */
+/*
+Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
+Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
+
+This file is based on mieq.c by Keith Packard,
+which contains the following copyright:
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/darwinEvents.c,v 1.6 2004/03/31 22:29:09 torrey Exp $ */
+
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "inputstr.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "mipointer.h"
+
+#include "darwin.h"
+#include "darwinKeyboard.h"
+
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#include <IOKit/hidsystem/IOLLEvent.h>
+
+/* Fake button press/release for scroll wheel move. */
+#define SCROLLWHEELUPFAKE 4
+#define SCROLLWHEELDOWNFAKE 5
+
+#define QUEUE_SIZE 256
+
+typedef struct _Event {
+ xEvent event;
+ ScreenPtr pScreen;
+} EventRec, *EventPtr;
+
+typedef struct _EventQueue {
+ HWEventQueueType head, tail; /* long for SetInputCheck */
+ CARD32 lastEventTime; /* to avoid time running backwards */
+ Bool lastMotion;
+ EventRec events[QUEUE_SIZE]; /* static allocation for signals */
+ DevicePtr pKbd, pPtr; /* device pointer, to get funcs */
+ ScreenPtr pEnqueueScreen; /* screen events are being delivered to */
+ ScreenPtr pDequeueScreen; /* screen events are being dispatched to */
+} EventQueueRec, *EventQueuePtr;
+
+static EventQueueRec darwinEventQueue;
+
+
+/*
+ * DarwinPressModifierMask
+ * Press or release the given modifier key, specified by its mask.
+ */
+static void DarwinPressModifierMask(
+ xEvent *xe, // must already have type, time and mouse location
+ int mask) // one of NX_*MASK constants
+{
+ int key = DarwinModifierNXMaskToNXKey(mask);
+
+ if (key != -1) {
+ int keycode = DarwinModifierNXKeyToNXKeycode(key, 0);
+ if (keycode != 0) {
+ xe->u.u.detail = keycode + MIN_KEYCODE;
+ (*darwinEventQueue.pKbd->processInputProc)(xe,
+ (DeviceIntPtr)darwinEventQueue.pKbd, 1);
+ }
+ }
+}
+
+#ifdef NX_DEVICELCTLKEYMASK
+#define CONTROL_MASK(flags) (flags & (NX_DEVICELCTLKEYMASK|NX_DEVICERCTLKEYMASK))
+#else
+#define CONTROL_MASK(flags) (NX_CONTROLMASK)
+#endif /* NX_DEVICELCTLKEYMASK */
+
+#ifdef NX_DEVICELSHIFTKEYMASK
+#define SHIFT_MASK(flags) (flags & (NX_DEVICELSHIFTKEYMASK|NX_DEVICERSHIFTKEYMASK))
+#else
+#define SHIFT_MASK(flags) (NX_SHIFTMASK)
+#endif /* NX_DEVICELSHIFTKEYMASK */
+
+#ifdef NX_DEVICELCMDKEYMASK
+#define COMMAND_MASK(flags) (flags & (NX_DEVICELCMDKEYMASK|NX_DEVICERCMDKEYMASK))
+#else
+#define COMMAND_MASK(flags) (NX_COMMANDMASK)
+#endif /* NX_DEVICELCMDKEYMASK */
+
+#ifdef NX_DEVICELALTKEYMASK
+#define ALTERNATE_MASK(flags) (flags & (NX_DEVICELALTKEYMASK|NX_DEVICERALTKEYMASK))
+#else
+#define ALTERNATE_MASK(flags) (NX_ALTERNATEMASK)
+#endif /* NX_DEVICELALTKEYMASK */
+
+/*
+ * DarwinUpdateModifiers
+ * Send events to update the modifier state.
+ */
+static void DarwinUpdateModifiers(
+ xEvent *xe, // event template with time and mouse position set
+ int pressed, // KeyPress or KeyRelease
+ int flags ) // modifier flags that have changed
+{
+ xe->u.u.type = pressed;
+ if (flags & NX_ALPHASHIFTMASK) {
+ DarwinPressModifierMask(xe, NX_ALPHASHIFTMASK);
+ }
+ if (flags & NX_COMMANDMASK) {
+ DarwinPressModifierMask(xe, COMMAND_MASK(flags));
+ }
+ if (flags & NX_CONTROLMASK) {
+ DarwinPressModifierMask(xe, CONTROL_MASK(flags));
+ }
+ if (flags & NX_ALTERNATEMASK) {
+ DarwinPressModifierMask(xe, ALTERNATE_MASK(flags));
+ }
+ if (flags & NX_SHIFTMASK) {
+ DarwinPressModifierMask(xe, SHIFT_MASK(flags));
+ }
+ if (flags & NX_SECONDARYFNMASK) {
+ DarwinPressModifierMask(xe, NX_SECONDARYFNMASK);
+ }
+}
+
+
+/*
+ * DarwinSimulateMouseClick
+ * Send a mouse click to X when multiple mouse buttons are simulated
+ * with modifier-clicks, such as command-click for button 2. The dix
+ * layer is told that the previously pressed modifier key(s) are
+ * released, the simulated click event is sent. After the mouse button
+ * is released, the modifier keys are reverted to their actual state,
+ * which may or may not be pressed at that point. This is usually
+ * closest to what the user wants. Ie. the user typically wants to
+ * simulate a button 2 press instead of Command-button 2.
+ */
+static void DarwinSimulateMouseClick(
+ xEvent *xe, // event template with time and
+ // mouse position filled in
+ int whichButton, // mouse button to be pressed
+ int modifierMask) // modifiers used for the fake click
+{
+ // first fool X into forgetting about the keys
+ DarwinUpdateModifiers(xe, KeyRelease, modifierMask);
+
+ // push the mouse button
+ xe->u.u.type = ButtonPress;
+ xe->u.u.detail = whichButton;
+ (*darwinEventQueue.pPtr->processInputProc)
+ (xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+}
+
+
+Bool
+DarwinEQInit(
+ DevicePtr pKbd,
+ DevicePtr pPtr)
+{
+ darwinEventQueue.head = darwinEventQueue.tail = 0;
+ darwinEventQueue.lastEventTime = GetTimeInMillis ();
+ darwinEventQueue.pKbd = pKbd;
+ darwinEventQueue.pPtr = pPtr;
+ darwinEventQueue.pEnqueueScreen = screenInfo.screens[0];
+ darwinEventQueue.pDequeueScreen = darwinEventQueue.pEnqueueScreen;
+ SetInputCheck (&darwinEventQueue.head, &darwinEventQueue.tail);
+ return TRUE;
+}
+
+
+/*
+ * DarwinEQEnqueue
+ * Must be thread safe with ProcessInputEvents.
+ * DarwinEQEnqueue - called from event gathering thread
+ * ProcessInputEvents - called from X server thread
+ * DarwinEQEnqueue should never be called from more than one thread.
+ */
+void
+DarwinEQEnqueue(
+ const xEvent *e)
+{
+ HWEventQueueType oldtail, newtail;
+ char byte = 0;
+
+ oldtail = darwinEventQueue.tail;
+
+ // mieqEnqueue() collapses successive motion events into one event.
+ // This is difficult to do in a thread-safe way and rarely useful.
+
+ newtail = oldtail + 1;
+ if (newtail == QUEUE_SIZE)
+ newtail = 0;
+ /* Toss events which come in late */
+ if (newtail == darwinEventQueue.head)
+ return;
+
+ darwinEventQueue.events[oldtail].event = *e;
+ /*
+ * Make sure that event times don't go backwards - this
+ * is "unnecessary", but very useful
+ */
+ if (e->u.keyButtonPointer.time < darwinEventQueue.lastEventTime &&
+ darwinEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000)
+ {
+ darwinEventQueue.events[oldtail].event.u.keyButtonPointer.time =
+ darwinEventQueue.lastEventTime;
+ }
+ darwinEventQueue.events[oldtail].pScreen = darwinEventQueue.pEnqueueScreen;
+
+ // Update the tail after the event is prepared
+ darwinEventQueue.tail = newtail;
+
+ // Signal there is an event ready to handle
+ write(darwinEventWriteFD, &byte, 1);
+}
+
+
+/*
+ * DarwinEQPointerPost
+ * Post a pointer event. Used by the mipointer.c routines.
+ */
+void
+DarwinEQPointerPost(
+ xEvent *e)
+{
+ (*darwinEventQueue.pPtr->processInputProc)
+ (e, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+}
+
+
+void
+DarwinEQSwitchScreen(
+ ScreenPtr pScreen,
+ Bool fromDIX)
+{
+ darwinEventQueue.pEnqueueScreen = pScreen;
+ if (fromDIX)
+ darwinEventQueue.pDequeueScreen = pScreen;
+}
+
+
+/*
+ * ProcessInputEvents
+ * Read and process events from the event queue until it is empty.
+ */
+void ProcessInputEvents(void)
+{
+ EventRec *e;
+ int x, y;
+ xEvent xe;
+ static int old_flags = 0; // last known modifier state
+ // button number and modifier mask of currently pressed fake button
+ static int darwinFakeMouseButtonDown = 0;
+ static int darwinFakeMouseButtonMask = 0;
+
+ // Empty the signaling pipe
+ x = sizeof(xe);
+ while (x == sizeof(xe)) {
+ x = read(darwinEventReadFD, &xe, sizeof(xe));
+ }
+
+ while (darwinEventQueue.head != darwinEventQueue.tail)
+ {
+ if (screenIsSaved == SCREEN_SAVER_ON)
+ SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
+
+ e = &darwinEventQueue.events[darwinEventQueue.head];
+ xe = e->event;
+
+ // Shift from global screen coordinates to coordinates relative to
+ // the origin of the current screen.
+ xe.u.keyButtonPointer.rootX -= darwinMainScreenX +
+ dixScreenOrigins[miPointerCurrentScreen()->myNum].x;
+ xe.u.keyButtonPointer.rootY -= darwinMainScreenY +
+ dixScreenOrigins[miPointerCurrentScreen()->myNum].y;
+
+ /*
+ * Assumption - screen switching can only occur on motion events
+ */
+ if (e->pScreen != darwinEventQueue.pDequeueScreen)
+ {
+ darwinEventQueue.pDequeueScreen = e->pScreen;
+ x = xe.u.keyButtonPointer.rootX;
+ y = xe.u.keyButtonPointer.rootY;
+ if (darwinEventQueue.head == QUEUE_SIZE - 1)
+ darwinEventQueue.head = 0;
+ else
+ ++darwinEventQueue.head;
+ NewCurrentScreen (darwinEventQueue.pDequeueScreen, x, y);
+ }
+ else
+ {
+ if (darwinEventQueue.head == QUEUE_SIZE - 1)
+ darwinEventQueue.head = 0;
+ else
+ ++darwinEventQueue.head;
+ switch (xe.u.u.type)
+ {
+ case KeyPress:
+ if (old_flags == 0
+ && darwinSyncKeymap && darwinKeymapFile == NULL)
+ {
+ /* See if keymap has changed. */
+
+ static unsigned int last_seed;
+ unsigned int this_seed;
+
+ this_seed = DarwinModeSystemKeymapSeed();
+ if (this_seed != last_seed)
+ {
+ last_seed = this_seed;
+ DarwinKeyboardReload(darwinKeyboard);
+ }
+ }
+ /* fall through */
+
+ case KeyRelease:
+ xe.u.u.detail += MIN_KEYCODE;
+ (*darwinEventQueue.pKbd->processInputProc)
+ (&xe, (DeviceIntPtr)darwinEventQueue.pKbd, 1);
+ break;
+
+ case ButtonPress:
+ miPointerAbsoluteCursor(xe.u.keyButtonPointer.rootX,
+ xe.u.keyButtonPointer.rootY,
+ xe.u.keyButtonPointer.time);
+ if (darwinFakeButtons && xe.u.u.detail == 1) {
+ // Mimic multi-button mouse with modifier-clicks
+ // If both sets of modifiers are pressed,
+ // button 2 is clicked.
+ if ((old_flags & darwinFakeMouse2Mask) ==
+ darwinFakeMouse2Mask)
+ {
+ DarwinSimulateMouseClick(&xe, 2, darwinFakeMouse2Mask);
+ darwinFakeMouseButtonDown = 2;
+ darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
+ break;
+ }
+ else if ((old_flags & darwinFakeMouse3Mask) ==
+ darwinFakeMouse3Mask)
+ {
+ DarwinSimulateMouseClick(&xe, 3, darwinFakeMouse3Mask);
+ darwinFakeMouseButtonDown = 3;
+ darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
+ break;
+ }
+ }
+ (*darwinEventQueue.pPtr->processInputProc)
+ (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+ break;
+
+ case ButtonRelease:
+ miPointerAbsoluteCursor(xe.u.keyButtonPointer.rootX,
+ xe.u.keyButtonPointer.rootY,
+ xe.u.keyButtonPointer.time);
+ if (darwinFakeButtons && xe.u.u.detail == 1 &&
+ darwinFakeMouseButtonDown)
+ {
+ // If last mousedown was a fake click, don't check for
+ // mouse modifiers here. The user may have released the
+ // modifiers before the mouse button.
+ xe.u.u.detail = darwinFakeMouseButtonDown;
+ darwinFakeMouseButtonDown = 0;
+ (*darwinEventQueue.pPtr->processInputProc)
+ (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+
+ // Bring modifiers back up to date
+ DarwinUpdateModifiers(&xe, KeyPress,
+ darwinFakeMouseButtonMask & old_flags);
+ darwinFakeMouseButtonMask = 0;
+ } else {
+ (*darwinEventQueue.pPtr->processInputProc)
+ (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+ }
+ break;
+
+ case MotionNotify:
+ miPointerAbsoluteCursor(xe.u.keyButtonPointer.rootX,
+ xe.u.keyButtonPointer.rootY,
+ xe.u.keyButtonPointer.time);
+ break;
+
+ case kXDarwinUpdateModifiers:
+ {
+ // Update modifier state.
+ // Any amount of modifiers may have changed.
+ int flags = xe.u.clientMessage.u.l.longs0;
+ DarwinUpdateModifiers(&xe, KeyRelease,
+ old_flags & ~flags);
+ DarwinUpdateModifiers(&xe, KeyPress,
+ ~old_flags & flags);
+ old_flags = flags;
+ break;
+ }
+
+ case kXDarwinUpdateButtons:
+ {
+ long hwDelta = xe.u.clientMessage.u.l.longs0;
+ long hwButtons = xe.u.clientMessage.u.l.longs1;
+ int i;
+
+ for (i = 1; i < 5; i++) {
+ if (hwDelta & (1 << i)) {
+ // IOKit and X have different numbering for the
+ // middle and right mouse buttons.
+ if (i == 1) {
+ xe.u.u.detail = 3;
+ } else if (i == 2) {
+ xe.u.u.detail = 2;
+ } else {
+ xe.u.u.detail = i + 1;
+ }
+ if (hwButtons & (1 << i)) {
+ xe.u.u.type = ButtonPress;
+ } else {
+ xe.u.u.type = ButtonRelease;
+ }
+ (*darwinEventQueue.pPtr->processInputProc)
+ (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+ }
+ }
+ break;
+ }
+
+ case kXDarwinScrollWheel:
+ {
+ short count = xe.u.clientMessage.u.s.shorts0;
+
+ if (count > 0) {
+ xe.u.u.detail = SCROLLWHEELUPFAKE;
+ } else {
+ xe.u.u.detail = SCROLLWHEELDOWNFAKE;
+ count = -count;
+ }
+
+ for (; count; --count) {
+ xe.u.u.type = ButtonPress;
+ (*darwinEventQueue.pPtr->processInputProc)
+ (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+ xe.u.u.type = ButtonRelease;
+ (*darwinEventQueue.pPtr->processInputProc)
+ (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+ }
+ break;
+ }
+
+ default:
+ // Check for mode specific event
+ DarwinModeProcessEvent(&xe);
+ }
+ }
+ }
+
+ miPointerUpdate();
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/darwinKeyboard.c b/nx-X11/programs/Xserver/hw/darwin/darwinKeyboard.c
new file mode 100644
index 000000000..dbc449dc3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/darwinKeyboard.c
@@ -0,0 +1,1027 @@
+//=============================================================================
+//
+// Keyboard support for the Darwin X Server
+//
+// Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
+// Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved.
+// Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
+//
+// The code to parse the Darwin keymap is derived from dumpkeymap.c
+// by Eric Sunshine, which includes the following copyright:
+//
+// Copyright (C) 1999,2000 by Eric Sunshine <sunshine@sunshineco.com>
+// All rights reserved.
+//
+//-----------------------------------------------------------------------------
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// 3. The name of the author may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+// NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//=============================================================================
+
+/* $XFree86: xc/programs/Xserver/hw/darwin/darwinKeyboard.c,v 1.21 2004/04/01 00:05:22 torrey Exp $ */
+
+/*
+===========================================================================
+
+ An X keyCode must be in the range XkbMinLegalKeyCode (8) to
+ XkbMaxLegalKeyCode(255).
+
+ The keyCodes we get from the kernel range from 0 to 127, so we need to
+ offset the range before passing the keyCode to X.
+
+ An X KeySym is an extended ascii code that is device independent.
+
+ The modifier map is accessed by the keyCode, but the normal map is
+ accessed by keyCode - MIN_KEYCODE. Sigh.
+
+===========================================================================
+*/
+
+// Define this to get a diagnostic output to stderr which is helpful
+// in determining how the X server is interpreting the Darwin keymap.
+#undef DUMP_DARWIN_KEYMAP
+
+/* Define this to use Alt for Mode_switch. */
+#define ALT_IS_MODE_SWITCH 1
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <IOKit/hidsystem/event_status_driver.h>
+#include <IOKit/hidsystem/ev_keymap.h>
+#include <architecture/byte_order.h> // For the NXSwap*
+#include "darwin.h"
+#include "darwinKeyboard.h"
+
+#define AltMask Mod1Mask
+#define MetaMask Mod2Mask
+#define FunctionMask Mod3Mask
+
+// FIXME: It would be nice to support some of the extra keys in XF86keysym.h,
+// at least the volume controls that now ship on every Apple keyboard.
+
+#define UK(a) NoSymbol // unknown symbol
+
+static KeySym const next_to_x[256] = {
+ NoSymbol, NoSymbol, NoSymbol, XK_KP_Enter,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, XK_Return, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Escape,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
+ XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
+ XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
+ XK_comma, XK_minus, XK_period, XK_slash,
+ XK_0, XK_1, XK_2, XK_3,
+ XK_4, XK_5, XK_6, XK_7,
+ XK_8, XK_9, XK_colon, XK_semicolon,
+ XK_less, XK_equal, XK_greater, XK_question,
+ XK_at, XK_A, XK_B, XK_C,
+ XK_D, XK_E, XK_F, XK_G,
+ XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O,
+ XK_P, XK_Q, XK_R, XK_S,
+ XK_T, XK_U, XK_V, XK_W,
+ XK_X, XK_Y, XK_Z, XK_bracketleft,
+ XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
+ XK_grave, XK_a, XK_b, XK_c,
+ XK_d, XK_e, XK_f, XK_g,
+ XK_h, XK_i, XK_j, XK_k,
+ XK_l, XK_m, XK_n, XK_o,
+ XK_p, XK_q, XK_r, XK_s,
+ XK_t, XK_u, XK_v, XK_w,
+ XK_x, XK_y, XK_z, XK_braceleft,
+ XK_bar, XK_braceright, XK_asciitilde, XK_BackSpace,
+// 128
+ NoSymbol, XK_Agrave, XK_Aacute, XK_Acircumflex,
+ XK_Atilde, XK_Adiaeresis, XK_Aring, XK_Ccedilla,
+ XK_Egrave, XK_Eacute, XK_Ecircumflex, XK_Ediaeresis,
+ XK_Igrave, XK_Iacute, XK_Icircumflex, XK_Idiaeresis,
+// 144
+ XK_ETH, XK_Ntilde, XK_Ograve, XK_Oacute,
+ XK_Ocircumflex, XK_Otilde, XK_Odiaeresis, XK_Ugrave,
+ XK_Uacute, XK_Ucircumflex, XK_Udiaeresis, XK_Yacute,
+ XK_THORN, XK_mu, XK_multiply, XK_division,
+// 160
+ XK_copyright, XK_exclamdown, XK_cent, XK_sterling,
+ UK(fraction), XK_yen, UK(fhook), XK_section,
+ XK_currency, XK_rightsinglequotemark,
+ XK_leftdoublequotemark,
+ XK_guillemotleft,
+ XK_leftanglebracket,
+ XK_rightanglebracket,
+ UK(filigature), UK(flligature),
+// 176
+ XK_registered, XK_endash, XK_dagger, XK_doubledagger,
+ XK_periodcentered,XK_brokenbar, XK_paragraph, UK(bullet),
+ XK_singlelowquotemark,
+ XK_doublelowquotemark,
+ XK_rightdoublequotemark,
+ XK_guillemotright,
+ XK_ellipsis, UK(permille), XK_notsign, XK_questiondown,
+// 192
+ XK_onesuperior, XK_dead_grave, XK_dead_acute, XK_dead_circumflex,
+ XK_dead_tilde, XK_dead_macron, XK_dead_breve, XK_dead_abovedot,
+ XK_dead_diaeresis,
+ XK_twosuperior, XK_dead_abovering,
+ XK_dead_cedilla,
+ XK_threesuperior,
+ XK_dead_doubleacute,
+ XK_dead_ogonek, XK_dead_caron,
+// 208
+ XK_emdash, XK_plusminus, XK_onequarter, XK_onehalf,
+ XK_threequarters,
+ XK_agrave, XK_aacute, XK_acircumflex,
+ XK_atilde, XK_adiaeresis, XK_aring, XK_ccedilla,
+ XK_egrave, XK_eacute, XK_ecircumflex, XK_ediaeresis,
+// 224
+ XK_igrave, XK_AE, XK_iacute, XK_ordfeminine,
+ XK_icircumflex, XK_idiaeresis, XK_eth, XK_ntilde,
+ XK_Lstroke, XK_Ooblique, XK_OE, XK_masculine,
+ XK_ograve, XK_oacute, XK_ocircumflex, XK_otilde,
+// 240
+ XK_odiaeresis, XK_ae, XK_ugrave, XK_uacute,
+ XK_ucircumflex, XK_idotless, XK_udiaeresis, XK_ygrave,
+ XK_lstroke, XK_ooblique, XK_oe, XK_ssharp,
+ XK_thorn, XK_ydiaeresis, NoSymbol, NoSymbol,
+ };
+
+#define MIN_SYMBOL 0xAC
+static KeySym const symbol_to_x[] = {
+ XK_Left, XK_Up, XK_Right, XK_Down
+ };
+int const NUM_SYMBOL = sizeof(symbol_to_x) / sizeof(symbol_to_x[0]);
+
+#define MIN_FUNCKEY 0x20
+static KeySym const funckey_to_x[] = {
+ XK_F1, XK_F2, XK_F3, XK_F4,
+ XK_F5, XK_F6, XK_F7, XK_F8,
+ XK_F9, XK_F10, XK_F11, XK_F12,
+ XK_Insert, XK_Delete, XK_Home, XK_End,
+ XK_Page_Up, XK_Page_Down, XK_F13, XK_F14,
+ XK_F15
+ };
+int const NUM_FUNCKEY = sizeof(funckey_to_x) / sizeof(funckey_to_x[0]);
+
+typedef struct {
+ KeySym normalSym;
+ KeySym keypadSym;
+} darwinKeyPad_t;
+
+static darwinKeyPad_t const normal_to_keypad[] = {
+ { XK_0, XK_KP_0 },
+ { XK_1, XK_KP_1 },
+ { XK_2, XK_KP_2 },
+ { XK_3, XK_KP_3 },
+ { XK_4, XK_KP_4 },
+ { XK_5, XK_KP_5 },
+ { XK_6, XK_KP_6 },
+ { XK_7, XK_KP_7 },
+ { XK_8, XK_KP_8 },
+ { XK_9, XK_KP_9 },
+ { XK_equal, XK_KP_Equal },
+ { XK_asterisk, XK_KP_Multiply },
+ { XK_plus, XK_KP_Add },
+ { XK_comma, XK_KP_Separator },
+ { XK_minus, XK_KP_Subtract },
+ { XK_period, XK_KP_Decimal },
+ { XK_slash, XK_KP_Divide }
+};
+int const NUM_KEYPAD = sizeof(normal_to_keypad) / sizeof(normal_to_keypad[0]);
+
+static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl )
+{
+ // keyclick, bell volume / pitch, autorepead, LED's
+}
+
+static darwinKeyboardInfo keyInfo;
+static FILE *fref = NULL;
+static char *inBuffer = NULL;
+
+//-----------------------------------------------------------------------------
+// Data Stream Object
+// Can be configured to treat embedded "numbers" as being composed of
+// either 1, 2, or 4 bytes, apiece.
+//-----------------------------------------------------------------------------
+typedef struct _DataStream
+{
+ unsigned char const *data;
+ unsigned char const *data_end;
+ short number_size; // Size in bytes of a "number" in the stream.
+} DataStream;
+
+static DataStream* new_data_stream( unsigned char const* data, int size )
+{
+ DataStream* s = (DataStream*)xalloc( sizeof(DataStream) );
+ s->data = data;
+ s->data_end = data + size;
+ s->number_size = 1; // Default to byte-sized numbers.
+ return s;
+}
+
+static void destroy_data_stream( DataStream* s )
+{
+ xfree(s);
+}
+
+static unsigned char get_byte( DataStream* s )
+{
+ assert(s->data + 1 <= s->data_end);
+ return *s->data++;
+}
+
+static short get_word( DataStream* s )
+{
+ short hi, lo;
+ assert(s->data + 2 <= s->data_end);
+ hi = *s->data++;
+ lo = *s->data++;
+ return ((hi << 8) | lo);
+}
+
+static int get_dword( DataStream* s )
+{
+ int b1, b2, b3, b4;
+ assert(s->data + 4 <= s->data_end);
+ b4 = *s->data++;
+ b3 = *s->data++;
+ b2 = *s->data++;
+ b1 = *s->data++;
+ return ((b4 << 24) | (b3 << 16) | (b2 << 8) | b1);
+}
+
+static int get_number( DataStream* s )
+{
+ switch (s->number_size) {
+ case 4: return get_dword(s);
+ case 2: return get_word(s);
+ default: return get_byte(s);
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Utility functions to help parse Darwin keymap
+//-----------------------------------------------------------------------------
+
+/*
+ * bits_set
+ * Calculate number of bits set in the modifier mask.
+ */
+static short bits_set( short mask )
+{
+ short n = 0;
+
+ for ( ; mask != 0; mask >>= 1)
+ if ((mask & 0x01) != 0)
+ n++;
+ return n;
+}
+
+/*
+ * parse_next_char_code
+ * Read the next character code from the Darwin keymapping
+ * and write it to the X keymap.
+ */
+static void parse_next_char_code(
+ DataStream *s,
+ KeySym *k )
+{
+ const short charSet = get_number(s);
+ const short charCode = get_number(s);
+
+ if (charSet == 0) { // ascii character
+ if (charCode >= 0 && charCode < 256)
+ *k = next_to_x[charCode];
+ } else if (charSet == 0x01) { // symbol character
+ if (charCode >= MIN_SYMBOL &&
+ charCode <= MIN_SYMBOL + NUM_SYMBOL)
+ *k = symbol_to_x[charCode - MIN_SYMBOL];
+ } else if (charSet == 0xFE) { // function key
+ if (charCode >= MIN_FUNCKEY &&
+ charCode <= MIN_FUNCKEY + NUM_FUNCKEY)
+ *k = funckey_to_x[charCode - MIN_FUNCKEY];
+ }
+}
+
+
+/*
+ * DarwinReadKeymapFile
+ * Read the appropriate keymapping from a keymapping file.
+ */
+Bool DarwinReadKeymapFile(
+ NXKeyMapping *keyMap)
+{
+ struct stat st;
+ NXEventSystemDevice info[20];
+ int interface = 0, handler_id = 0;
+ int map_interface, map_handler_id, map_size = 0;
+ unsigned int i, size;
+ int *bufferEnd;
+ union km_tag {
+ int *intP;
+ char *charP;
+ } km;
+
+ fref = fopen( darwinKeymapFile, "rb" );
+ if (fref == NULL) {
+ ErrorF("Unable to open keymapping file '%s' (errno %d).\n",
+ darwinKeymapFile, errno);
+ return FALSE;
+ }
+ if (fstat(fileno(fref), &st) == -1) {
+ ErrorF("Could not stat keymapping file '%s' (errno %d).\n",
+ darwinKeymapFile, errno);
+ return FALSE;
+ }
+
+ // check to make sure we don't crash later
+ if (st.st_size <= 16*sizeof(int)) {
+ ErrorF("Keymapping file '%s' is invalid (too small).\n",
+ darwinKeymapFile);
+ return FALSE;
+ }
+
+ inBuffer = (char*) xalloc( st.st_size );
+ bufferEnd = (int *) (inBuffer + st.st_size);
+ if (fread(inBuffer, st.st_size, 1, fref) != 1) {
+ ErrorF("Could not read %qd bytes from keymapping file '%s' (errno %d).\n",
+ st.st_size, darwinKeymapFile, errno);
+ return FALSE;
+ }
+
+ if (strncmp( inBuffer, "KYM1", 4 ) == 0) {
+ // Magic number OK.
+ } else if (strncmp( inBuffer, "KYMP", 4 ) == 0) {
+ ErrorF("Keymapping file '%s' is intended for use with the original NeXT keyboards and cannot be used by XDarwin.\n", darwinKeymapFile);
+ return FALSE;
+ } else {
+ ErrorF("Keymapping file '%s' has a bad magic number and cannot be used by XDarwin.\n", darwinKeymapFile);
+ return FALSE;
+ }
+
+ // find the keyboard interface and handler id
+ size = sizeof( info ) / sizeof( int );
+ if (!NXEventSystemInfo( darwinParamConnect, NX_EVS_DEVICE_INFO,
+ (NXEventSystemInfoType) info, &size )) {
+ ErrorF("Error reading event status driver info.\n");
+ return FALSE;
+ }
+
+ size = size * sizeof( int ) / sizeof( info[0] );
+ for( i = 0; i < size; i++) {
+ if (info[i].dev_type == NX_EVS_DEVICE_TYPE_KEYBOARD) {
+ Bool hasInterface = FALSE;
+ Bool hasMatch = FALSE;
+
+ interface = info[i].interface;
+ handler_id = info[i].id;
+
+ // Find an appropriate keymapping:
+ // The first time we try to match both interface and handler_id.
+ // If we can't match both, we take the first match for interface.
+
+ do {
+ km.charP = inBuffer;
+ km.intP++;
+ while (km.intP+3 < bufferEnd) {
+ map_interface = NXSwapBigIntToHost(*(km.intP++));
+ map_handler_id = NXSwapBigIntToHost(*(km.intP++));
+ map_size = NXSwapBigIntToHost(*(km.intP++));
+ if (map_interface == interface) {
+ if (map_handler_id == handler_id || hasInterface) {
+ hasMatch = TRUE;
+ break;
+ } else {
+ hasInterface = TRUE;
+ }
+ }
+ km.charP += map_size;
+ }
+ } while (hasInterface && !hasMatch);
+
+ if (hasMatch) {
+ // fill in NXKeyMapping structure
+ keyMap->size = map_size;
+ keyMap->mapping = (char*) xalloc(map_size);
+ memcpy(keyMap->mapping, km.charP, map_size);
+ return TRUE;
+ }
+ } // if dev_id == keyboard device
+ } // foreach info struct
+
+ // The keymapping file didn't match any of the info structs
+ // returned by NXEventSystemInfo.
+ ErrorF("Keymapping file '%s' did not contain appropriate keyboard interface.\n", darwinKeymapFile);
+ return FALSE;
+}
+
+
+/*
+ * DarwinParseNXKeyMapping
+ */
+Bool DarwinParseNXKeyMapping(
+ darwinKeyboardInfo *info)
+{
+ KeySym *k;
+ int i;
+ short numMods, numKeys, numPadKeys = 0;
+ Bool haveKeymap = FALSE;
+ NXKeyMapping keyMap;
+ DataStream *keyMapStream;
+ unsigned char const *numPadStart = 0;
+
+ if (darwinKeymapFile) {
+ haveKeymap = DarwinReadKeymapFile(&keyMap);
+ if (fref)
+ fclose(fref);
+ if (inBuffer)
+ xfree(inBuffer);
+ if (!haveKeymap) {
+ ErrorF("Reverting to kernel keymapping.\n");
+ }
+ }
+
+ if (!haveKeymap) {
+ // get the Darwin keyboard map
+ keyMap.size = NXKeyMappingLength( darwinParamConnect );
+ keyMap.mapping = (char*) xalloc( keyMap.size );
+ if (!NXGetKeyMapping( darwinParamConnect, &keyMap )) {
+ return FALSE;
+ }
+ }
+
+ keyMapStream = new_data_stream( (unsigned char const*)keyMap.mapping,
+ keyMap.size );
+
+ // check the type of map
+ if (get_word(keyMapStream)) {
+ keyMapStream->number_size = 2;
+ ErrorF("Current 16-bit keymapping may not be interpreted correctly.\n");
+ }
+
+ // Insert X modifier KeySyms into the keyboard map.
+ numMods = get_number(keyMapStream);
+ while (numMods-- > 0) {
+ int left = 1; // first keycode is left
+ short const charCode = get_number(keyMapStream);
+ short numKeyCodes = get_number(keyMapStream);
+
+ // This is just a marker, not a real modifier.
+ // Store numeric keypad keys for later.
+ if (charCode == NX_MODIFIERKEY_NUMERICPAD) {
+ numPadStart = keyMapStream->data;
+ numPadKeys = numKeyCodes;
+ }
+
+ while (numKeyCodes-- > 0) {
+ const short keyCode = get_number(keyMapStream);
+ if (charCode != NX_MODIFIERKEY_NUMERICPAD) {
+ switch (charCode) {
+ case NX_MODIFIERKEY_ALPHALOCK:
+ info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Caps_Lock;
+ break;
+ case NX_MODIFIERKEY_SHIFT:
+ info->keyMap[keyCode * GLYPHS_PER_KEY] =
+ (left ? XK_Shift_L : XK_Shift_R);
+ break;
+ case NX_MODIFIERKEY_CONTROL:
+ info->keyMap[keyCode * GLYPHS_PER_KEY] =
+ (left ? XK_Control_L : XK_Control_R);
+ break;
+ case NX_MODIFIERKEY_ALTERNATE:
+ info->keyMap[keyCode * GLYPHS_PER_KEY] =
+ (left ? XK_Mode_switch : XK_Alt_R);
+ break;
+ case NX_MODIFIERKEY_COMMAND:
+ info->keyMap[keyCode * GLYPHS_PER_KEY] =
+ (left ? XK_Meta_L : XK_Meta_R);
+ break;
+ case NX_MODIFIERKEY_SECONDARYFN:
+ info->keyMap[keyCode * GLYPHS_PER_KEY] =
+ (left ? XK_Control_L : XK_Control_R);
+ break;
+ case NX_MODIFIERKEY_HELP:
+ // Help is not an X11 modifier; treat as normal key
+ info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Help;
+ break;
+ }
+ }
+ left = 0;
+ }
+ }
+
+ // Convert the Darwin keyboard mapping to an X keyboard map.
+ // A key can have a different character code for each combination of
+ // modifiers. We currently ignore all modifier combinations except
+ // those with Shift, AlphaLock, and Alt.
+ numKeys = get_number(keyMapStream);
+ for (i = 0, k = info->keyMap; i < numKeys; i++, k += GLYPHS_PER_KEY) {
+ short const charGenMask = get_number(keyMapStream);
+ if (charGenMask != 0xFF) { // is key bound?
+ short numKeyCodes = 1 << bits_set(charGenMask);
+
+ // Record unmodified case
+ parse_next_char_code( keyMapStream, k );
+ numKeyCodes--;
+
+ // If AlphaLock and Shift modifiers produce different codes,
+ // we record the Shift case since X handles AlphaLock.
+ if (charGenMask & 0x01) { // AlphaLock
+ parse_next_char_code( keyMapStream, k+1 );
+ numKeyCodes--;
+ }
+
+ if (charGenMask & 0x02) { // Shift
+ parse_next_char_code( keyMapStream, k+1 );
+ numKeyCodes--;
+
+ if (charGenMask & 0x01) { // Shift-AlphaLock
+ get_number(keyMapStream); get_number(keyMapStream);
+ numKeyCodes--;
+ }
+ }
+
+ // Skip the Control cases
+ if (charGenMask & 0x04) { // Control
+ get_number(keyMapStream); get_number(keyMapStream);
+ numKeyCodes--;
+
+ if (charGenMask & 0x01) { // Control-AlphaLock
+ get_number(keyMapStream); get_number(keyMapStream);
+ numKeyCodes--;
+ }
+
+ if (charGenMask & 0x02) { // Control-Shift
+ get_number(keyMapStream); get_number(keyMapStream);
+ numKeyCodes--;
+
+ if (charGenMask & 0x01) { // Shift-Control-AlphaLock
+ get_number(keyMapStream); get_number(keyMapStream);
+ numKeyCodes--;
+ }
+ }
+ }
+
+ // Process Alt cases
+ if (charGenMask & 0x08) { // Alt
+ parse_next_char_code( keyMapStream, k+2 );
+ numKeyCodes--;
+
+ if (charGenMask & 0x01) { // Alt-AlphaLock
+ parse_next_char_code( keyMapStream, k+3 );
+ numKeyCodes--;
+ }
+
+ if (charGenMask & 0x02) { // Alt-Shift
+ parse_next_char_code( keyMapStream, k+3 );
+ numKeyCodes--;
+
+ if (charGenMask & 0x01) { // Alt-Shift-AlphaLock
+ get_number(keyMapStream); get_number(keyMapStream);
+ numKeyCodes--;
+ }
+ }
+ }
+
+ while (numKeyCodes-- > 0) {
+ get_number(keyMapStream); get_number(keyMapStream);
+ }
+
+ if (k[3] == k[2]) k[3] = NoSymbol;
+ if (k[2] == k[1]) k[2] = NoSymbol;
+ if (k[1] == k[0]) k[1] = NoSymbol;
+ if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
+ }
+ }
+
+ // Now we have to go back through the list of keycodes that are on the
+ // numeric keypad and update the X keymap.
+ keyMapStream->data = numPadStart;
+ while(numPadKeys-- > 0) {
+ const short keyCode = get_number(keyMapStream);
+ k = &info->keyMap[keyCode * GLYPHS_PER_KEY];
+ for (i = 0; i < NUM_KEYPAD; i++) {
+ if (*k == normal_to_keypad[i].normalSym) {
+ k[0] = normal_to_keypad[i].keypadSym;
+ break;
+ }
+ }
+ }
+
+ // free Darwin keyboard map
+ destroy_data_stream( keyMapStream );
+ xfree( keyMap.mapping );
+
+ return TRUE;
+}
+
+
+/*
+ * DarwinBuildModifierMaps
+ * Use the keyMap field of keyboard info structure to populate
+ * the modMap and modifierKeycodes fields.
+ */
+static void
+DarwinBuildModifierMaps(
+ darwinKeyboardInfo *info)
+{
+ int i;
+ KeySym *k;
+
+ memset(info->modMap, NoSymbol, sizeof(info->modMap));
+ memset(info->modifierKeycodes, 0, sizeof(info->modifierKeycodes));
+
+ for (i = 0; i < NUM_KEYCODES; i++)
+ {
+ k = info->keyMap + i * GLYPHS_PER_KEY;
+
+ switch (k[0]) {
+ case XK_Shift_L:
+ info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
+ info->modMap[MIN_KEYCODE + i] = ShiftMask;
+ break;
+
+ case XK_Shift_R:
+#ifdef NX_MODIFIERKEY_RSHIFT
+ info->modifierKeycodes[NX_MODIFIERKEY_RSHIFT][0] = i;
+#else
+ info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
+#endif
+ info->modMap[MIN_KEYCODE + i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
+ info->modMap[MIN_KEYCODE + i] = ControlMask;
+ break;
+
+ case XK_Control_R:
+#ifdef NX_MODIFIERKEY_RCONTROL
+ info->modifierKeycodes[NX_MODIFIERKEY_RCONTROL][0] = i;
+#else
+ info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
+#endif
+ info->modMap[MIN_KEYCODE + i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ info->modifierKeycodes[NX_MODIFIERKEY_ALPHALOCK][0] = i;
+ info->modMap[MIN_KEYCODE + i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
+ info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+ break;
+
+ case XK_Alt_R:
+#ifdef NX_MODIFIERKEY_RALTERNATE
+ info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
+#else
+ info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
+#endif
+ info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+ break;
+
+ case XK_Mode_switch:
+ info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+ break;
+
+ case XK_Meta_L:
+ info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
+ info->modMap[MIN_KEYCODE + i] = Mod2Mask;
+ break;
+
+ case XK_Meta_R:
+#ifdef NX_MODIFIERKEY_RCOMMAND
+ info->modifierKeycodes[NX_MODIFIERKEY_RCOMMAND][0] = i;
+#else
+ info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
+#endif
+ info->modMap[MIN_KEYCODE + i] = Mod2Mask;
+ break;
+
+ case XK_Num_Lock:
+ info->modMap[MIN_KEYCODE + i] = Mod3Mask;
+ break;
+ }
+
+ if (darwinSwapAltMeta)
+ {
+ switch (k[0])
+ {
+ case XK_Alt_L:
+ k[0] = XK_Meta_L;
+ break;
+ case XK_Alt_R:
+ k[0] = XK_Meta_R;
+ break;
+ case XK_Meta_L:
+ k[0] = XK_Alt_L;
+ break;
+ case XK_Meta_R:
+ k[0] = XK_Alt_R;
+ break;
+ }
+ }
+
+#if ALT_IS_MODE_SWITCH
+ if (k[0] == XK_Alt_L)
+ k[0] = XK_Mode_switch;
+#endif
+ }
+}
+
+
+/*
+ * DarwinLoadKeyboardMapping
+ * Load the keyboard map from a file or system and convert
+ * it to an equivalent X keyboard map and modifier map.
+ */
+static void
+DarwinLoadKeyboardMapping(KeySymsRec *keySyms)
+{
+ memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
+
+ if (!DarwinParseNXKeyMapping(&keyInfo)) {
+ if (!DarwinModeReadSystemKeymap(&keyInfo)) {
+ FatalError("Could not build a valid keymap.");
+ }
+ }
+
+ DarwinBuildModifierMaps(&keyInfo);
+
+#ifdef DUMP_DARWIN_KEYMAP
+ ErrorF("Darwin -> X converted keyboard map\n");
+ for (i = 0, k = info->keyMap; i < NX_NUMKEYCODES;
+ i++, k += GLYPHS_PER_KEY)
+ {
+ int j;
+ ErrorF("0x%02x:", i);
+ for (j = 0; j < GLYPHS_PER_KEY; j++) {
+ if (k[j] == NoSymbol) {
+ ErrorF("\tNoSym");
+ } else {
+ ErrorF("\t0x%x", k[j]);
+ }
+ }
+ ErrorF("\n");
+ }
+#endif
+
+ keySyms->map = keyInfo.keyMap;
+ keySyms->mapWidth = GLYPHS_PER_KEY;
+ keySyms->minKeyCode = MIN_KEYCODE;
+ keySyms->maxKeyCode = MAX_KEYCODE;
+}
+
+
+/*
+ * DarwinKeyboardInit
+ * Get the Darwin keyboard map and compute an equivalent
+ * X keyboard map and modifier map. Set the new keyboard
+ * device structure.
+ */
+void DarwinKeyboardInit(
+ DeviceIntPtr pDev )
+{
+ KeySymsRec keySyms;
+
+ // Open a shared connection to the HID System.
+ // Note that the Event Status Driver is really just a wrapper
+ // for a kIOHIDParamConnectType connection.
+ assert( darwinParamConnect = NXOpenEventStatus() );
+
+ DarwinLoadKeyboardMapping(&keySyms);
+
+ /* Initialize the seed, so we don't reload the keymap unnecessarily
+ (and possibly overwrite xinitrc changes) */
+ DarwinModeSystemKeymapSeed();
+
+ assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms,
+ keyInfo.modMap, DarwinModeBell,
+ DarwinChangeKeyboardControl ));
+}
+
+
+/* Borrowed from dix/devices.c */
+static Bool
+InitModMap(register KeyClassPtr keyc)
+{
+ int i, j;
+ CARD8 keysPerModifier[8];
+ CARD8 mask;
+
+ if (keyc->modifierKeyMap != NULL)
+ xfree (keyc->modifierKeyMap);
+
+ keyc->maxKeysPerModifier = 0;
+ for (i = 0; i < 8; i++)
+ keysPerModifier[i] = 0;
+ for (i = 8; i < MAP_LENGTH; i++)
+ {
+ for (j = 0, mask = 1; j < 8; j++, mask <<= 1)
+ {
+ if (mask & keyc->modifierMap[i])
+ {
+ if (++keysPerModifier[j] > keyc->maxKeysPerModifier)
+ keyc->maxKeysPerModifier = keysPerModifier[j];
+ }
+ }
+ }
+ keyc->modifierKeyMap = (KeyCode *)xalloc(8*keyc->maxKeysPerModifier);
+ if (!keyc->modifierKeyMap && keyc->maxKeysPerModifier)
+ return (FALSE);
+ bzero((char *)keyc->modifierKeyMap, 8*(int)keyc->maxKeysPerModifier);
+ for (i = 0; i < 8; i++)
+ keysPerModifier[i] = 0;
+ for (i = 8; i < MAP_LENGTH; i++)
+ {
+ for (j = 0, mask = 1; j < 8; j++, mask <<= 1)
+ {
+ if (mask & keyc->modifierMap[i])
+ {
+ keyc->modifierKeyMap[(j*keyc->maxKeysPerModifier) +
+ keysPerModifier[j]] = i;
+ keysPerModifier[j]++;
+ }
+ }
+ }
+ return TRUE;
+}
+
+
+void
+DarwinKeyboardReload(DeviceIntPtr pDev)
+{
+ KeySymsRec keySyms;
+
+ DarwinLoadKeyboardMapping(&keySyms);
+
+ if (SetKeySymsMap(&pDev->key->curKeySyms, &keySyms)) {
+ /* now try to update modifiers. */
+
+ memmove(pDev->key->modifierMap, keyInfo.modMap, MAP_LENGTH);
+ InitModMap(pDev->key);
+ }
+
+ SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0);
+ SendMappingNotify(MappingModifier, 0, 0, 0);
+}
+
+
+//-----------------------------------------------------------------------------
+// Modifier translation functions
+//
+// There are three different ways to specify a Mac modifier key:
+// keycode - specifies hardware key, read from keymapping
+// key - NX_MODIFIERKEY_*, really an index
+// mask - NX_*MASK, mask for modifier flags in event record
+// Left and right side have different keycodes but the same key and mask.
+//-----------------------------------------------------------------------------
+
+/*
+ * DarwinModifierNXKeyToNXKeycode
+ * Return the keycode for an NX_MODIFIERKEY_* modifier.
+ * side = 0 for left or 1 for right.
+ * Returns 0 if key+side is not a known modifier.
+ */
+int DarwinModifierNXKeyToNXKeycode(int key, int side)
+{
+ return keyInfo.modifierKeycodes[key][side];
+}
+
+/*
+ * DarwinModifierNXKeycodeToNXKey
+ * Returns -1 if keycode+side is not a modifier key
+ * outSide may be NULL, else it gets 0 for left and 1 for right.
+ */
+int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide)
+{
+ int key, side;
+
+ keycode += MIN_KEYCODE;
+ // search modifierKeycodes for this keycode+side
+ for (key = 0; key < NX_NUMMODIFIERS; key++) {
+ for (side = 0; side <= 1; side++) {
+ if (keyInfo.modifierKeycodes[key][side] == keycode) break;
+ }
+ }
+ if (key == NX_NUMMODIFIERS) return -1;
+ if (outSide) *outSide = side;
+ return key;
+}
+
+/*
+ * DarwinModifierNXMaskToNXKey
+ * Returns -1 if mask is not a known modifier mask.
+ */
+int DarwinModifierNXMaskToNXKey(int mask)
+{
+ switch (mask) {
+ case NX_ALPHASHIFTMASK: return NX_MODIFIERKEY_ALPHALOCK;
+ case NX_SHIFTMASK: return NX_MODIFIERKEY_SHIFT;
+#ifdef NX_DEVICELSHIFTKEYMASK
+ case NX_DEVICELSHIFTKEYMASK: return NX_MODIFIERKEY_SHIFT;
+ case NX_DEVICERSHIFTKEYMASK: return NX_MODIFIERKEY_RSHIFT;
+#endif
+ case NX_CONTROLMASK: return NX_MODIFIERKEY_CONTROL;
+#ifdef NX_DEVICELCTLKEYMASK
+ case NX_DEVICELCTLKEYMASK: return NX_MODIFIERKEY_CONTROL;
+ case NX_DEVICERCTLKEYMASK: return NX_MODIFIERKEY_RCONTROL;
+#endif
+ case NX_ALTERNATEMASK: return NX_MODIFIERKEY_ALTERNATE;
+#ifdef NX_DEVICELALTKEYMASK
+ case NX_DEVICELALTKEYMASK: return NX_MODIFIERKEY_ALTERNATE;
+ case NX_DEVICERALTKEYMASK: return NX_MODIFIERKEY_RALTERNATE;
+#endif
+ case NX_COMMANDMASK: return NX_MODIFIERKEY_COMMAND;
+#ifdef NX_DEVICELCMDKEYMASK
+ case NX_DEVICELCMDKEYMASK: return NX_MODIFIERKEY_COMMAND;
+ case NX_DEVICERCMDKEYMASK: return NX_MODIFIERKEY_RCOMMAND;
+#endif
+ case NX_NUMERICPADMASK: return NX_MODIFIERKEY_NUMERICPAD;
+ case NX_HELPMASK: return NX_MODIFIERKEY_HELP;
+ case NX_SECONDARYFNMASK: return NX_MODIFIERKEY_SECONDARYFN;
+ }
+ return -1;
+}
+
+/*
+ * DarwinModifierNXKeyToNXMask
+ * Returns 0 if key is not a known modifier key.
+ */
+int DarwinModifierNXKeyToNXMask(int key)
+{
+ switch (key) {
+ case NX_MODIFIERKEY_ALPHALOCK: return NX_ALPHASHIFTMASK;
+ case NX_MODIFIERKEY_SHIFT: return NX_SHIFTMASK;
+#ifdef NX_MODIFIERKEY_RSHIFT
+ case NX_MODIFIERKEY_RSHIFT: return NX_SHIFTMASK;
+#endif
+ case NX_MODIFIERKEY_CONTROL: return NX_CONTROLMASK;
+#ifdef NX_MODIFIERKEY_RCONTROL
+ case NX_MODIFIERKEY_RCONTROL: return NX_CONTROLMASK;
+#endif
+ case NX_MODIFIERKEY_ALTERNATE: return NX_ALTERNATEMASK;
+#ifdef NX_MODIFIERKEY_RALTERNATE
+ case NX_MODIFIERKEY_RALTERNATE: return NX_ALTERNATEMASK;
+#endif
+ case NX_MODIFIERKEY_COMMAND: return NX_COMMANDMASK;
+#ifdef NX_MODIFIERKEY_RCOMMAND
+ case NX_MODIFIERKEY_RCOMMAND: return NX_COMMANDMASK;
+#endif
+ case NX_MODIFIERKEY_NUMERICPAD: return NX_NUMERICPADMASK;
+ case NX_MODIFIERKEY_HELP: return NX_HELPMASK;
+ case NX_MODIFIERKEY_SECONDARYFN: return NX_SECONDARYFNMASK;
+ }
+ return 0;
+}
+
+/*
+ * DarwinModifierStringToNXKey
+ * Returns -1 if string is not a known modifier.
+ */
+int DarwinModifierStringToNXKey(const char *str)
+{
+ if (!strcasecmp(str, "shift")) return NX_MODIFIERKEY_SHIFT;
+ else if (!strcasecmp(str, "control")) return NX_MODIFIERKEY_CONTROL;
+ else if (!strcasecmp(str, "option")) return NX_MODIFIERKEY_ALTERNATE;
+ else if (!strcasecmp(str, "command")) return NX_MODIFIERKEY_COMMAND;
+ else if (!strcasecmp(str, "fn")) return NX_MODIFIERKEY_SECONDARYFN;
+ else return -1;
+}
+
+/*
+ * LegalModifier
+ * This allows the ddx layer to prevent some keys from being remapped
+ * as modifier keys.
+ */
+Bool LegalModifier(unsigned int key, DevicePtr pDev)
+{
+ return 1;
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/darwinKeyboard.h b/nx-X11/programs/Xserver/hw/darwin/darwinKeyboard.h
new file mode 100644
index 000000000..0ea9c1d60
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/darwinKeyboard.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2003-2004 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/darwinKeyboard.c,v 1.18 2003/05/14 05:27:55 torrey Exp $ */
+
+#ifndef DARWIN_KEYBOARD_H
+#define DARWIN_KEYBOARD_H 1
+
+#define XK_TECHNICAL // needed to get XK_Escape
+#define XK_PUBLISHING
+#include "keysym.h"
+#include "inputstr.h"
+
+// Each key can generate 4 glyphs. They are, in order:
+// unshifted, shifted, modeswitch unshifted, modeswitch shifted
+#define GLYPHS_PER_KEY 4
+#define NUM_KEYCODES 248 // NX_NUMKEYCODES might be better
+#define MAX_KEYCODE NUM_KEYCODES + MIN_KEYCODE - 1
+
+typedef struct darwinKeyboardInfo_struct {
+ CARD8 modMap[MAP_LENGTH];
+ KeySym keyMap[MAP_LENGTH * GLYPHS_PER_KEY];
+ unsigned char modifierKeycodes[32][2];
+} darwinKeyboardInfo;
+
+void DarwinKeyboardReload(DeviceIntPtr pDev);
+unsigned int DarwinModeSystemKeymapSeed(void);
+Bool DarwinModeReadSystemKeymap(darwinKeyboardInfo *info);
+
+#endif /* DARWIN_KEYBOARD_H */
diff --git a/nx-X11/programs/Xserver/hw/darwin/darwinXinput.c b/nx-X11/programs/Xserver/hw/darwin/darwinXinput.c
new file mode 100644
index 000000000..d3716a1d4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/darwinXinput.c
@@ -0,0 +1,310 @@
+/* $Xorg: stubs.c,v 1.4 2001/02/09 02:04:35 xorgcvs Exp $ */
+
+/*
+ * X server support of the XINPUT extension for Darwin
+ *
+ * This is currently a copy of mi/stubs.c, but eventually this
+ * should include more complete XINPUT support.
+ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/hw/darwin/darwinXinput.c,v 1.1 2004/05/28 07:44:00 torrey Exp $ */
+
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "inputstr.h"
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h"
+
+/***********************************************************************
+ *
+ * Caller: ProcXChangeKeyboardDevice
+ *
+ * This procedure does the implementation-dependent portion of the work
+ * needed to change the keyboard device.
+ *
+ * The X keyboard device has a FocusRec. If the device that has been
+ * made into the new X keyboard did not have a FocusRec,
+ * ProcXChangeKeyboardDevice will allocate one for it.
+ *
+ * If you do not want clients to be able to focus the old X keyboard
+ * device, call DeleteFocusClassDeviceStruct to free the FocusRec.
+ *
+ * If you support input devices with keys that you do not want to be
+ * used as the X keyboard, you need to check for them here and return
+ * a BadDevice error.
+ *
+ * The default implementation is to do nothing (assume you do want
+ * clients to be able to focus the old X keyboard). The commented-out
+ * sample code shows what you might do if you don't want the default.
+ *
+ */
+
+int
+ChangeKeyboardDevice (old_dev, new_dev)
+ DeviceIntPtr old_dev;
+ DeviceIntPtr new_dev;
+ {
+ /***********************************************************************
+ DeleteFocusClassDeviceStruct(old_dev); * defined in xchgptr.c *
+ **********************************************************************/
+ return BadMatch;
+ }
+
+
+/***********************************************************************
+ *
+ * Caller: ProcXChangePointerDevice
+ *
+ * This procedure does the implementation-dependent portion of the work
+ * needed to change the pointer device.
+ *
+ * The X pointer device does not have a FocusRec. If the device that
+ * has been made into the new X pointer had a FocusRec,
+ * ProcXChangePointerDevice will free it.
+ *
+ * If you want clients to be able to focus the old pointer device that
+ * has now become accessible through the input extension, you need to
+ * add a FocusRec to it here.
+ *
+ * The XChangePointerDevice protocol request also allows the client
+ * to choose which axes of the new pointer device are used to move
+ * the X cursor in the X- and Y- directions. If the axes are different
+ * than the default ones, you need to keep track of that here.
+ *
+ * If you support input devices with valuators that you do not want to be
+ * used as the X pointer, you need to check for them here and return a
+ * BadDevice error.
+ *
+ * The default implementation is to do nothing (assume you don't want
+ * clients to be able to focus the old X pointer). The commented-out
+ * sample code shows what you might do if you don't want the default.
+ *
+ */
+
+int
+ChangePointerDevice (
+ DeviceIntPtr old_dev,
+ DeviceIntPtr new_dev,
+ unsigned char x,
+ unsigned char y)
+ {
+ /***********************************************************************
+ InitFocusClassDeviceStruct(old_dev); * allow focusing old ptr*
+
+ x_axis = x; * keep track of new x-axis*
+ y_axis = y; * keep track of new y-axis*
+ if (x_axis != 0 || y_axis != 1)
+ axes_changed = TRUE; * remember axes have changed*
+ else
+ axes_changed = FALSE;
+ *************************************************************************/
+ return BadMatch;
+ }
+
+/***********************************************************************
+ *
+ * Caller: ProcXCloseDevice
+ *
+ * Take care of implementation-dependent details of closing a device.
+ * Some implementations may actually close the device, others may just
+ * remove this clients interest in that device.
+ *
+ * The default implementation is to do nothing (assume all input devices
+ * are initialized during X server initialization and kept open).
+ *
+ */
+
+void
+CloseInputDevice (d, client)
+ DeviceIntPtr d;
+ ClientPtr client;
+ {
+ }
+
+/***********************************************************************
+ *
+ * Caller: ProcXListInputDevices
+ *
+ * This is the implementation-dependent routine to initialize an input
+ * device to the point that information about it can be listed.
+ * Some implementations open all input devices when the server is first
+ * initialized, and never close them. Other implementations open only
+ * the X pointer and keyboard devices during server initialization,
+ * and only open other input devices when some client makes an
+ * XOpenDevice request. If some other process has the device open, the
+ * server may not be able to get information about the device to list it.
+ *
+ * This procedure should be used by implementations that do not initialize
+ * all input devices at server startup. It should do device-dependent
+ * initialization for any devices not previously initialized, and call
+ * AddInputDevice for each of those devices so that a DeviceIntRec will be
+ * created for them.
+ *
+ * The default implementation is to do nothing (assume all input devices
+ * are initialized during X server initialization and kept open).
+ * The commented-out sample code shows what you might do if you don't want
+ * the default.
+ *
+ */
+
+void
+AddOtherInputDevices ()
+ {
+ /**********************************************************************
+ for each uninitialized device, do something like:
+
+ DeviceIntPtr dev;
+ DeviceProc deviceProc;
+ pointer private;
+
+ dev = (DeviceIntPtr) AddInputDevice(deviceProc, TRUE);
+ dev->public.devicePrivate = private;
+ RegisterOtherDevice(dev);
+ dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
+ ************************************************************************/
+
+ }
+
+/***********************************************************************
+ *
+ * Caller: ProcXOpenDevice
+ *
+ * This is the implementation-dependent routine to open an input device.
+ * Some implementations open all input devices when the server is first
+ * initialized, and never close them. Other implementations open only
+ * the X pointer and keyboard devices during server initialization,
+ * and only open other input devices when some client makes an
+ * XOpenDevice request. This entry point is for the latter type of
+ * implementation.
+ *
+ * If the physical device is not already open, do it here. In this case,
+ * you need to keep track of the fact that one or more clients has the
+ * device open, and physically close it when the last client that has
+ * it open does an XCloseDevice.
+ *
+ * The default implementation is to do nothing (assume all input devices
+ * are opened during X server initialization and kept open).
+ *
+ */
+
+void
+OpenInputDevice (dev, client, status)
+ DeviceIntPtr dev;
+ ClientPtr client;
+ int *status;
+ {
+ }
+
+/****************************************************************************
+ *
+ * Caller: ProcXSetDeviceMode
+ *
+ * Change the mode of an extension device.
+ * This function is used to change the mode of a device from reporting
+ * relative motion to reporting absolute positional information, and
+ * vice versa.
+ * The default implementation below is that no such devices are supported.
+ *
+ */
+
+int
+SetDeviceMode (client, dev, mode)
+ register ClientPtr client;
+ DeviceIntPtr dev;
+ int mode;
+ {
+ return BadMatch;
+ }
+
+/****************************************************************************
+ *
+ * Caller: ProcXSetDeviceValuators
+ *
+ * Set the value of valuators on an extension input device.
+ * This function is used to set the initial value of valuators on
+ * those input devices that are capable of reporting either relative
+ * motion or an absolute position, and allow an initial position to be set.
+ * The default implementation below is that no such devices are supported.
+ *
+ */
+
+int
+SetDeviceValuators (client, dev, valuators, first_valuator, num_valuators)
+ register ClientPtr client;
+ DeviceIntPtr dev;
+ int *valuators;
+ int first_valuator;
+ int num_valuators;
+ {
+ return BadMatch;
+ }
+
+/****************************************************************************
+ *
+ * Caller: ProcXChangeDeviceControl
+ *
+ * Change the specified device controls on an extension input device.
+ *
+ */
+
+int
+ChangeDeviceControl (client, dev, control)
+ register ClientPtr client;
+ DeviceIntPtr dev;
+ xDeviceCtl *control;
+ {
+ switch (control->control)
+ {
+ case DEVICE_RESOLUTION:
+ return (BadMatch);
+ default:
+ return (BadMatch);
+ }
+ }
diff --git a/nx-X11/programs/Xserver/hw/darwin/iokit/Imakefile b/nx-X11/programs/Xserver/hw/darwin/iokit/Imakefile
new file mode 100644
index 000000000..061874e75
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/iokit/Imakefile
@@ -0,0 +1,25 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/Imakefile,v 1.18 2003/03/15 18:02:08 torrey Exp $
+
+#include <Server.tmpl>
+
+SRCS = xfIOKit.c \
+ xfIOKitCursor.c \
+ xfIOKitStartup.c
+
+OBJS = xfIOKit.o \
+ xfIOKitCursor.o \
+ xfIOKitStartup.o
+
+INCLUDES = -I. -I$(SERVERSRC)/mi -I$(SERVERSRC)/fb -I$(EXTINCSRC) \
+ -I$(SERVERSRC)/render -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/os -I$(INCLUDESRC) -I$(FONTINCSRC) \
+ -I$(SERVERSRC)/miext/shadow -I..
+
+#if DarwinQuartzSupport
+DEFINES = -DDARWIN_WITH_QUARTZ
+#endif
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(iokit,$(OBJS))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKit.c b/nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKit.c
new file mode 100644
index 000000000..2f0fc11a3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKit.c
@@ -0,0 +1,772 @@
+/**************************************************************
+ *
+ * IOKit support for the Darwin X Server
+ *
+ * HISTORY:
+ * Original port to Mac OS X Server by John Carmack
+ * Port to Darwin 1.0 by Dave Zarzycki
+ * Significantly rewritten for XFree86 4.0.1 by Torrey Lyons
+ *
+ **************************************************************/
+/*
+ * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XdotOrg: xc/programs/Xserver/hw/darwin/iokit/xfIOKit.c,v 1.6 2005/07/03 08:53:39 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/iokit/xfIOKit.c,v 1.2 2003/10/16 23:50:09 torrey Exp $ */
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "os.h"
+#include "servermd.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "mi.h"
+#include "mibstore.h"
+#include "mipointer.h"
+#include "micmap.h"
+#include "shadow.h"
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <pthread.h>
+
+#include <mach/mach_interface.h>
+
+#define NO_CFPLUGIN
+#include <IOKit/IOKitLib.h>
+#include <IOKit/hidsystem/IOHIDShared.h>
+#include <IOKit/graphics/IOGraphicsLib.h>
+#include <drivers/event_status_driver.h>
+
+// Define this to work around bugs in the display drivers for
+// older PowerBook G3's. If the X server starts without this
+// #define, you don't need it.
+#undef OLD_POWERBOOK_G3
+
+#include "darwin.h"
+#include "xfIOKit.h"
+
+// Globals
+int xfIOKitScreenIndex = 0;
+io_connect_t xfIOKitInputConnect = 0;
+
+static pthread_t inputThread;
+static EvGlobals * evg;
+static mach_port_t masterPort;
+static mach_port_t notificationPort;
+static IONotificationPortRef NotificationPortRef;
+static mach_port_t pmNotificationPort;
+static io_iterator_t fbIter;
+
+
+/*
+ * XFIOKitStoreColors
+ * This is a callback from X to change the hardware colormap
+ * when using PsuedoColor.
+ */
+static void XFIOKitStoreColors(
+ ColormapPtr pmap,
+ int numEntries,
+ xColorItem *pdefs)
+{
+ kern_return_t kr;
+ int i;
+ IOColorEntry *newColors;
+ ScreenPtr pScreen = pmap->pScreen;
+ XFIOKitScreenPtr iokitScreen = XFIOKIT_SCREEN_PRIV(pScreen);
+
+ assert( newColors = (IOColorEntry *)
+ xalloc( numEntries*sizeof(IOColorEntry) ));
+
+ // Convert xColorItem values to IOColorEntry
+ // assume the colormap is PsuedoColor
+ // as we do not support DirectColor
+ for (i = 0; i < numEntries; i++) {
+ newColors[i].index = pdefs[i].pixel;
+ newColors[i].red = pdefs[i].red;
+ newColors[i].green = pdefs[i].green;
+ newColors[i].blue = pdefs[i].blue;
+ }
+
+ kr = IOFBSetCLUT( iokitScreen->fbService, 0, numEntries,
+ kSetCLUTByValue, newColors );
+ kern_assert( kr );
+
+ xfree( newColors );
+}
+
+
+/*
+ * DarwinModeBell
+ * FIXME
+ */
+void DarwinModeBell(
+ int loud,
+ DeviceIntPtr pDevice,
+ pointer ctrl,
+ int fbclass)
+{
+}
+
+
+/*
+ * DarwinModeGiveUp
+ * Closes the connections to IOKit services
+ */
+void DarwinModeGiveUp( void )
+{
+ int i;
+
+ // we must close the HID System first
+ // because it is a client of the framebuffer
+ NXCloseEventStatus( darwinParamConnect );
+ IOServiceClose( xfIOKitInputConnect );
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ XFIOKitScreenPtr iokitScreen =
+ XFIOKIT_SCREEN_PRIV(screenInfo.screens[i]);
+ IOServiceClose( iokitScreen->fbService );
+ }
+}
+
+
+/*
+ * ClearEvent
+ * Clear an event from the HID System event queue
+ */
+static void ClearEvent(NXEvent * ep)
+{
+ static NXEvent nullEvent = {NX_NULLEVENT, {0, 0 }, 0, -1, 0 };
+
+ *ep = nullEvent;
+ ep->data.compound.subType = ep->data.compound.misc.L[0] =
+ ep->data.compound.misc.L[1] = 0;
+}
+
+
+/*
+ * XFIOKitHIDThread
+ * Read the HID System event queue, translate it to an X event,
+ * and queue it for processing.
+ */
+static void *XFIOKitHIDThread(void *unused)
+{
+ for (;;) {
+ NXEQElement *oldHead;
+ mach_msg_return_t kr;
+ mach_msg_empty_rcv_t msg;
+
+ kr = mach_msg((mach_msg_header_t*) &msg, MACH_RCV_MSG, 0,
+ sizeof(msg), notificationPort, 0, MACH_PORT_NULL);
+ kern_assert(kr);
+
+ while (evg->LLEHead != evg->LLETail) {
+ NXEvent ev;
+ xEvent xe;
+
+ // Extract the next event from the kernel queue
+ oldHead = (NXEQElement*)&evg->lleq[evg->LLEHead];
+ ev_lock(&oldHead->sema);
+ ev = oldHead->event;
+ ClearEvent(&oldHead->event);
+ evg->LLEHead = oldHead->next;
+ ev_unlock(&oldHead->sema);
+
+ memset(&xe, 0, sizeof(xe));
+
+ // These fields should be filled in for every event
+ xe.u.keyButtonPointer.rootX = ev.location.x;
+ xe.u.keyButtonPointer.rootY = ev.location.y;
+ xe.u.keyButtonPointer.time = GetTimeInMillis();
+
+ switch( ev.type ) {
+ case NX_MOUSEMOVED:
+ xe.u.u.type = MotionNotify;
+ break;
+
+ case NX_LMOUSEDOWN:
+ xe.u.u.type = ButtonPress;
+ xe.u.u.detail = 1;
+ break;
+
+ case NX_LMOUSEUP:
+ xe.u.u.type = ButtonRelease;
+ xe.u.u.detail = 1;
+ break;
+
+ // A newer kernel generates multi-button events with
+ // NX_SYSDEFINED. Button 2 isn't handled correctly by
+ // older kernels anyway. Just let NX_SYSDEFINED events
+ // handle these.
+#if 0
+ case NX_RMOUSEDOWN:
+ xe.u.u.type = ButtonPress;
+ xe.u.u.detail = 2;
+ break;
+
+ case NX_RMOUSEUP:
+ xe.u.u.type = ButtonRelease;
+ xe.u.u.detail = 2;
+ break;
+#endif
+
+ case NX_KEYDOWN:
+ xe.u.u.type = KeyPress;
+ xe.u.u.detail = ev.data.key.keyCode;
+ break;
+
+ case NX_KEYUP:
+ xe.u.u.type = KeyRelease;
+ xe.u.u.detail = ev.data.key.keyCode;
+ break;
+
+ case NX_FLAGSCHANGED:
+ xe.u.u.type = kXDarwinUpdateModifiers;
+ xe.u.clientMessage.u.l.longs0 = ev.flags;
+ break;
+
+ case NX_SYSDEFINED:
+ if (ev.data.compound.subType == 7) {
+ xe.u.u.type = kXDarwinUpdateButtons;
+ xe.u.clientMessage.u.l.longs0 =
+ ev.data.compound.misc.L[0];
+ xe.u.clientMessage.u.l.longs1 =
+ ev.data.compound.misc.L[1];
+ } else {
+ continue;
+ }
+ break;
+
+ case NX_SCROLLWHEELMOVED:
+ xe.u.u.type = kXDarwinScrollWheel;
+ xe.u.clientMessage.u.s.shorts0 =
+ ev.data.scrollWheel.deltaAxis1;
+ break;
+
+ default:
+ continue;
+ }
+
+ DarwinEQEnqueue(&xe);
+ }
+ }
+
+ return NULL;
+}
+
+
+/*
+ * XFIOKitPMThread
+ * Handle power state notifications
+ */
+static void *XFIOKitPMThread(void *arg)
+{
+ ScreenPtr pScreen = (ScreenPtr)arg;
+ XFIOKitScreenPtr iokitScreen = XFIOKIT_SCREEN_PRIV(pScreen);
+
+ for (;;) {
+ mach_msg_return_t kr;
+ mach_msg_empty_rcv_t msg;
+
+ kr = mach_msg((mach_msg_header_t*) &msg, MACH_RCV_MSG, 0,
+ sizeof(msg), pmNotificationPort, 0, MACH_PORT_NULL);
+ kern_assert(kr);
+
+ // display is powering down
+ if (msg.header.msgh_id == 0) {
+ IOFBAcknowledgePM( iokitScreen->fbService );
+ xf86SetRootClip(pScreen, FALSE);
+ }
+ // display just woke up
+ else if (msg.header.msgh_id == 1) {
+ xf86SetRootClip(pScreen, TRUE);
+ }
+ }
+ return NULL;
+}
+
+
+/*
+ * SetupFBandHID
+ * Setup an IOFramebuffer service and connect the HID system to it.
+ */
+static Bool SetupFBandHID(
+ int index,
+ DarwinFramebufferPtr dfb,
+ XFIOKitScreenPtr iokitScreen)
+{
+ kern_return_t kr;
+ io_service_t service;
+ io_connect_t fbService;
+ vm_address_t vram;
+ vm_size_t shmemSize;
+ int i;
+ UInt32 numModes;
+ IODisplayModeInformation modeInfo;
+ IODisplayModeID displayMode, *allModes;
+ IOIndex displayDepth;
+ IOFramebufferInformation fbInfo;
+ IOPixelInformation pixelInfo;
+ StdFBShmem_t *cshmem;
+
+ // find and open the IOFrameBuffer service
+ service = IOIteratorNext(fbIter);
+ if (service == 0)
+ return FALSE;
+
+ kr = IOServiceOpen( service, mach_task_self(),
+ kIOFBServerConnectType, &iokitScreen->fbService );
+ IOObjectRelease( service );
+ if (kr != KERN_SUCCESS) {
+ ErrorF("Failed to connect as window server to screen %i.\n", index);
+ return FALSE;
+ }
+ fbService = iokitScreen->fbService;
+
+ // create the slice of shared memory containing cursor state data
+ kr = IOFBCreateSharedCursor( fbService,
+ kIOFBCurrentShmemVersion,
+ 32, 32 );
+ if (kr != KERN_SUCCESS)
+ return FALSE;
+
+ // Register for power management events for the framebuffer's device
+ kr = IOCreateReceivePort(kOSNotificationMessageID, &pmNotificationPort);
+ kern_assert(kr);
+ kr = IOConnectSetNotificationPort( fbService, 0,
+ pmNotificationPort, 0 );
+ if (kr != KERN_SUCCESS) {
+ ErrorF("Power management registration failed.\n");
+ }
+
+ // SET THE SCREEN PARAMETERS
+ // get the current screen resolution, refresh rate and depth
+ kr = IOFBGetCurrentDisplayModeAndDepth( fbService,
+ &displayMode,
+ &displayDepth );
+ if (kr != KERN_SUCCESS)
+ return FALSE;
+
+ // use the current screen resolution if the user
+ // only wants to change the refresh rate
+ if (darwinDesiredRefresh != -1 && darwinDesiredWidth == 0) {
+ kr = IOFBGetDisplayModeInformation( fbService,
+ displayMode,
+ &modeInfo );
+ if (kr != KERN_SUCCESS)
+ return FALSE;
+ darwinDesiredWidth = modeInfo.nominalWidth;
+ darwinDesiredHeight = modeInfo.nominalHeight;
+ }
+
+ // use the current resolution and refresh rate
+ // if the user doesn't have a preference
+ if (darwinDesiredWidth == 0) {
+
+ // change the pixel depth if desired
+ if (darwinDesiredDepth != -1) {
+ kr = IOFBGetDisplayModeInformation( fbService,
+ displayMode,
+ &modeInfo );
+ if (kr != KERN_SUCCESS)
+ return FALSE;
+ if (modeInfo.maxDepthIndex < darwinDesiredDepth) {
+ ErrorF("Discarding screen %i:\n", index);
+ ErrorF("Current screen resolution does not support desired pixel depth.\n");
+ return FALSE;
+ }
+
+ displayDepth = darwinDesiredDepth;
+ kr = IOFBSetDisplayModeAndDepth( fbService, displayMode,
+ displayDepth );
+ if (kr != KERN_SUCCESS)
+ return FALSE;
+ }
+
+ // look for display mode with correct resolution and refresh rate
+ } else {
+
+ // get an array of all supported display modes
+ kr = IOFBGetDisplayModeCount( fbService, &numModes );
+ if (kr != KERN_SUCCESS)
+ return FALSE;
+ assert(allModes = (IODisplayModeID *)
+ xalloc( numModes * sizeof(IODisplayModeID) ));
+ kr = IOFBGetDisplayModes( fbService, numModes, allModes );
+ if (kr != KERN_SUCCESS)
+ return FALSE;
+
+ for (i = 0; i < numModes; i++) {
+ kr = IOFBGetDisplayModeInformation( fbService, allModes[i],
+ &modeInfo );
+ if (kr != KERN_SUCCESS)
+ return FALSE;
+
+ if (modeInfo.flags & kDisplayModeValidFlag &&
+ modeInfo.nominalWidth == darwinDesiredWidth &&
+ modeInfo.nominalHeight == darwinDesiredHeight) {
+
+ if (darwinDesiredDepth == -1)
+ darwinDesiredDepth = modeInfo.maxDepthIndex;
+ if (modeInfo.maxDepthIndex < darwinDesiredDepth) {
+ ErrorF("Discarding screen %i:\n", index);
+ ErrorF("Desired screen resolution does not support desired pixel depth.\n");
+ return FALSE;
+ }
+
+ if ((darwinDesiredRefresh == -1 ||
+ (darwinDesiredRefresh << 16) == modeInfo.refreshRate)) {
+ displayMode = allModes[i];
+ displayDepth = darwinDesiredDepth;
+ kr = IOFBSetDisplayModeAndDepth(fbService,
+ displayMode,
+ displayDepth);
+ if (kr != KERN_SUCCESS)
+ return FALSE;
+ break;
+ }
+ }
+ }
+
+ xfree( allModes );
+ if (i >= numModes) {
+ ErrorF("Discarding screen %i:\n", index);
+ ErrorF("Desired screen resolution or refresh rate is not supported.\n");
+ return FALSE;
+ }
+ }
+
+ kr = IOFBGetPixelInformation( fbService, displayMode, displayDepth,
+ kIOFBSystemAperture, &pixelInfo );
+ if (kr != KERN_SUCCESS)
+ return FALSE;
+
+#ifdef __i386__
+ /* x86 in 8bit mode currently needs fixed color map... */
+ if (pixelInfo.bitsPerComponent == 8 &&
+ pixelInfo.componentCount == 1)
+ {
+ pixelInfo.pixelType = kIOFixedCLUTPixels;
+ }
+#endif
+
+#ifdef OLD_POWERBOOK_G3
+ if (pixelInfo.pixelType == kIOCLUTPixels)
+ pixelInfo.pixelType = kIOFixedCLUTPixels;
+#endif
+
+ kr = IOFBGetFramebufferInformationForAperture( fbService,
+ kIOFBSystemAperture,
+ &fbInfo );
+ if (kr != KERN_SUCCESS)
+ return FALSE;
+
+ // FIXME: 1x1 IOFramebuffers are sometimes used to indicate video
+ // outputs without a monitor connected to them. Since IOKit Xinerama
+ // does not really work, this often causes problems on PowerBooks.
+ // For now we explicitly check and ignore these screens.
+ if (fbInfo.activeWidth <= 1 || fbInfo.activeHeight <= 1) {
+ ErrorF("Discarding screen %i:\n", index);
+ ErrorF("Invalid width or height.\n");
+ return FALSE;
+ }
+
+ kr = IOConnectMapMemory( fbService, kIOFBCursorMemory,
+ mach_task_self(), (vm_address_t *) &cshmem,
+ &shmemSize, kIOMapAnywhere );
+ if (kr != KERN_SUCCESS)
+ return FALSE;
+ iokitScreen->cursorShmem = cshmem;
+
+ kr = IOConnectMapMemory( fbService, kIOFBSystemAperture,
+ mach_task_self(), &vram, &shmemSize,
+ kIOMapAnywhere );
+ if (kr != KERN_SUCCESS)
+ return FALSE;
+
+ iokitScreen->framebuffer = (void*)vram;
+ dfb->x = cshmem->screenBounds.minx;
+ dfb->y = cshmem->screenBounds.miny;
+ dfb->width = fbInfo.activeWidth;
+ dfb->height = fbInfo.activeHeight;
+ dfb->pitch = fbInfo.bytesPerRow;
+ dfb->bitsPerPixel = fbInfo.bitsPerPixel;
+ dfb->colorBitsPerPixel = pixelInfo.componentCount *
+ pixelInfo.bitsPerComponent;
+ dfb->bitsPerComponent = pixelInfo.bitsPerComponent;
+
+ // allocate shadow framebuffer
+ iokitScreen->shadowPtr = xalloc(dfb->pitch * dfb->height);
+ dfb->framebuffer = iokitScreen->shadowPtr;
+
+ // Note: Darwin kIORGBDirectPixels = X TrueColor, not DirectColor
+ if (pixelInfo.pixelType == kIORGBDirectPixels) {
+ dfb->colorType = TrueColor;
+ } else if (pixelInfo.pixelType == kIOCLUTPixels) {
+ dfb->colorType = PseudoColor;
+ } else if (pixelInfo.pixelType == kIOFixedCLUTPixels) {
+ dfb->colorType = StaticColor;
+ }
+
+ // Inform the HID system that the framebuffer is also connected to it.
+ kr = IOConnectAddClient( xfIOKitInputConnect, fbService );
+ kern_assert( kr );
+
+ // We have to have added at least one screen
+ // before we can enable the cursor.
+ kr = IOHIDSetCursorEnable(xfIOKitInputConnect, TRUE);
+ kern_assert( kr );
+
+ return TRUE;
+}
+
+
+/*
+ * DarwinModeAddScreen
+ * IOKit specific initialization for each screen.
+ */
+Bool DarwinModeAddScreen(
+ int index,
+ ScreenPtr pScreen)
+{
+ DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
+ XFIOKitScreenPtr iokitScreen;
+
+ // allocate space for private per screen storage
+ iokitScreen = xalloc(sizeof(XFIOKitScreenRec));
+ XFIOKIT_SCREEN_PRIV(pScreen) = iokitScreen;
+
+ // setup hardware framebuffer
+ iokitScreen->fbService = 0;
+ if (! SetupFBandHID(index, dfb, iokitScreen)) {
+ if (iokitScreen->fbService) {
+ IOServiceClose(iokitScreen->fbService);
+ }
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * XFIOKitShadowUpdate
+ * Update the damaged regions of the shadow framebuffer on the screen.
+ */
+static void XFIOKitShadowUpdate(ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
+ XFIOKitScreenPtr iokitScreen = XFIOKIT_SCREEN_PRIV(pScreen);
+ RegionPtr damage = &pBuf->damage;
+ int numBox = REGION_NUM_RECTS(damage);
+ BoxPtr pBox = REGION_RECTS(damage);
+ int pitch = dfb->pitch;
+ int bpp = dfb->bitsPerPixel/8;
+
+ // Loop through all the damaged boxes
+ while (numBox--) {
+ int width, height, offset;
+ unsigned char *src, *dst;
+
+ width = (pBox->x2 - pBox->x1) * bpp;
+ height = pBox->y2 - pBox->y1;
+ offset = (pBox->y1 * pitch) + (pBox->x1 * bpp);
+ src = iokitScreen->shadowPtr + offset;
+ dst = iokitScreen->framebuffer + offset;
+
+ while (height--) {
+ memcpy(dst, src, width);
+ dst += pitch;
+ src += pitch;
+ }
+
+ // Get the next box
+ pBox++;
+ }
+}
+
+
+/*
+ * DarwinModeSetupScreen
+ * Finalize IOKit specific initialization of each screen.
+ */
+Bool DarwinModeSetupScreen(
+ int index,
+ ScreenPtr pScreen)
+{
+ DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
+ pthread_t pmThread;
+
+ // initalize cursor support
+ if (! XFIOKitInitCursor(pScreen)) {
+ return FALSE;
+ }
+
+ // initialize shadow framebuffer support
+ if (! shadowInit(pScreen, XFIOKitShadowUpdate, NULL)) {
+ ErrorF("Failed to initalize shadow framebuffer for screen %i.\n",
+ index);
+ return FALSE;
+ }
+
+ // initialize colormap handling as needed
+ if (dfb->colorType == PseudoColor) {
+ pScreen->StoreColors = XFIOKitStoreColors;
+ }
+
+ // initialize power manager handling
+ pthread_create( &pmThread, NULL, XFIOKitPMThread,
+ (void *) pScreen );
+
+ return TRUE;
+}
+
+
+/*
+ * DarwinModeInitOutput
+ * One-time initialization of IOKit output support.
+ */
+void DarwinModeInitOutput(
+ int argc,
+ char **argv)
+{
+ static unsigned long generation = 0;
+ kern_return_t kr;
+ io_iterator_t iter;
+ io_service_t service;
+ vm_address_t shmem;
+ vm_size_t shmemSize;
+
+ ErrorF("Display mode: IOKit\n");
+
+ // Allocate private storage for each screen's IOKit specific info
+ if (generation != serverGeneration) {
+ xfIOKitScreenIndex = AllocateScreenPrivateIndex();
+ generation = serverGeneration;
+ }
+
+ kr = IOMasterPort(bootstrap_port, &masterPort);
+ kern_assert( kr );
+
+ // Find and open the HID System Service
+ // Do this now to be sure the Mac OS X window server is not running.
+ kr = IOServiceGetMatchingServices( masterPort,
+ IOServiceMatching( kIOHIDSystemClass ),
+ &iter );
+ kern_assert( kr );
+
+ assert( service = IOIteratorNext( iter ) );
+
+ kr = IOServiceOpen( service, mach_task_self(), kIOHIDServerConnectType,
+ &xfIOKitInputConnect );
+ if (kr != KERN_SUCCESS) {
+ ErrorF("Failed to connect to the HID System as the window server!\n");
+#ifdef DARWIN_WITH_QUARTZ
+ FatalError("Quit the Mac OS X window server or use the -quartz option.\n");
+#else
+ FatalError("Make sure you have quit the Mac OS X window server.\n");
+#endif
+ }
+
+ IOObjectRelease( service );
+ IOObjectRelease( iter );
+
+ // Setup the event queue in memory shared by the kernel and X server
+ kr = IOHIDCreateSharedMemory( xfIOKitInputConnect,
+ kIOHIDCurrentShmemVersion );
+ kern_assert( kr );
+
+ kr = IOConnectMapMemory( xfIOKitInputConnect, kIOHIDGlobalMemory,
+ mach_task_self(), &shmem, &shmemSize,
+ kIOMapAnywhere );
+ kern_assert( kr );
+
+ evg = (EvGlobals *)(shmem + ((EvOffsets *)shmem)->evGlobalsOffset);
+
+ assert(sizeof(EvGlobals) == evg->structSize);
+
+ NotificationPortRef = IONotificationPortCreate( masterPort );
+
+ notificationPort = IONotificationPortGetMachPort(NotificationPortRef);
+
+ kr = IOConnectSetNotificationPort( xfIOKitInputConnect,
+ kIOHIDEventNotification,
+ notificationPort, 0 );
+ kern_assert( kr );
+
+ evg->movedMask |= NX_MOUSEMOVEDMASK;
+
+ // find number of framebuffers
+ kr = IOServiceGetMatchingServices( masterPort,
+ IOServiceMatching( IOFRAMEBUFFER_CONFORMSTO ),
+ &fbIter );
+ kern_assert( kr );
+
+ darwinScreensFound = 0;
+ while ((service = IOIteratorNext(fbIter))) {
+ IOObjectRelease( service );
+ darwinScreensFound++;
+ }
+ IOIteratorReset(fbIter);
+}
+
+
+/*
+ * DarwinModeInitInput
+ * One-time initialization of IOKit input support.
+ */
+void DarwinModeInitInput(
+ int argc,
+ char **argv)
+{
+ kern_return_t kr;
+ int fd[2];
+
+ kr = IOHIDSetEventsEnable(xfIOKitInputConnect, TRUE);
+ kern_assert( kr );
+
+ // Start event passing thread
+ assert( pipe(fd) == 0 );
+ darwinEventReadFD = fd[0];
+ darwinEventWriteFD = fd[1];
+ fcntl(darwinEventReadFD, F_SETFL, O_NONBLOCK);
+ pthread_create(&inputThread, NULL,
+ XFIOKitHIDThread, NULL);
+
+}
+
+
+/*
+ * DarwinModeProcessEvent
+ * Process IOKit specific events.
+ */
+void DarwinModeProcessEvent(
+ xEvent *xe)
+{
+ // No mode specific events
+ ErrorF("Unknown X event caught: %d\n", xe->u.u.type);
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKit.h b/nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKit.h
new file mode 100644
index 000000000..288063da1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKit.h
@@ -0,0 +1,57 @@
+/*
+ xfIOKit.h
+
+ IOKit specific functions and definitions
+*/
+/*
+ * Copyright (c) 2001-2002 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/xfIOKit.h,v 1.10 2003/03/15 18:02:08 torrey Exp $ */
+
+#ifndef _XFIOKIT_H
+#define _XFIOKIT_H
+
+#include <pthread.h>
+#include <IOKit/graphics/IOFramebufferShared.h>
+#include <X11/Xproto.h>
+#include "screenint.h"
+#include "darwin.h"
+
+typedef struct {
+ io_connect_t fbService;
+ StdFBShmem_t *cursorShmem;
+ unsigned char *framebuffer;
+ unsigned char *shadowPtr;
+} XFIOKitScreenRec, *XFIOKitScreenPtr;
+
+#define XFIOKIT_SCREEN_PRIV(pScreen) \
+ ((XFIOKitScreenPtr)pScreen->devPrivates[xfIOKitScreenIndex].ptr)
+
+extern int xfIOKitScreenIndex; // index into pScreen.devPrivates
+extern io_connect_t xfIOKitInputConnect;
+
+Bool XFIOKitInitCursor(ScreenPtr pScreen);
+
+#endif /* _XFIOKIT_H */
diff --git a/nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKitCursor.c b/nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKitCursor.c
new file mode 100644
index 000000000..69eb41d2f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKitCursor.c
@@ -0,0 +1,735 @@
+/**************************************************************
+ *
+ * Cursor support for Darwin X Server
+ *
+ * Three different cursor modes are possible:
+ * X (0) - tracking via Darwin kernel,
+ * display via X machine independent
+ * Kernel (1) - tracking and display via Darwin kernel
+ * (not currently supported)
+ * Hardware (2) - tracking and display via hardware
+ *
+ * The X software cursor uses the Darwin software cursor
+ * routines in IOFramebuffer.cpp to track the cursor, but
+ * displays the cursor image using the X machine
+ * independent display cursor routines in midispcur.c.
+ *
+ * The kernel cursor uses IOFramebuffer.cpp routines to
+ * track and display the cursor. This gives better
+ * performance as the display calls don't have to cross
+ * the kernel boundary. Unfortunately, this mode has
+ * synchronization issues with the user land X server
+ * and isn't currently used.
+ *
+ * Hardware cursor support lets the hardware handle these
+ * details.
+ *
+ * Kernel and hardware cursor mode only work for cursors
+ * up to a certain size, currently 16x16 pixels. If a
+ * bigger cursor is set, we fallback to X cursor mode.
+ *
+ * HISTORY:
+ * 1.0 by Torrey T. Lyons, October 30, 2000
+ *
+ **************************************************************/
+/*
+ * Copyright (c) 2001-2002 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/xfIOKitCursor.c,v 1.6 2002/12/10 00:00:39 torrey Exp $ */
+
+#include "scrnintstr.h"
+#include "cursorstr.h"
+#include "mipointrst.h"
+#include "micmap.h"
+#define NO_CFPLUGIN
+#include <IOKit/graphics/IOGraphicsLib.h>
+#include <IOKit/hidsystem/IOHIDLib.h>
+#include "darwin.h"
+#include "xfIOKit.h"
+
+#define DUMP_DARWIN_CURSOR FALSE
+
+#define CURSOR_PRIV(pScreen) \
+ ((XFIOKitCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
+
+// The cursors format are documented in IOFramebufferShared.h.
+#define RGBto34WithGamma(red, green, blue) \
+ ( 0x000F \
+ | (((red) & 0xF) << 12) \
+ | (((green) & 0xF) << 8) \
+ | (((blue) & 0xF) << 4) )
+#define RGBto38WithGamma(red, green, blue) \
+ ( 0xFF << 24 \
+ | (((red) & 0xFF) << 16) \
+ | (((green) & 0xFF) << 8) \
+ | (((blue) & 0xFF)) )
+#define HighBitOf32 0x80000000
+
+typedef struct {
+ Bool canHWCursor;
+ short cursorMode;
+ RecolorCursorProcPtr RecolorCursor;
+ InstallColormapProcPtr InstallColormap;
+ QueryBestSizeProcPtr QueryBestSize;
+ miPointerSpriteFuncPtr spriteFuncs;
+ ColormapPtr pInstalledMap;
+} XFIOKitCursorScreenRec, *XFIOKitCursorScreenPtr;
+
+static int darwinCursorScreenIndex = -1;
+static unsigned long darwinCursorGeneration = 0;
+
+/*
+===========================================================================
+
+ Pointer sprite functions
+
+===========================================================================
+*/
+
+/*
+ Realizing the Darwin hardware cursor (ie. converting from the
+ X representation to the IOKit representation) is complicated
+ by the fact that we have three different potential cursor
+ formats to go to, one for each bit depth (8, 15, or 24).
+ The IOKit formats are documented in IOFramebufferShared.h.
+ X cursors are represented as two pieces, a source and a mask.
+ The mask is a bitmap indicating which parts of the cursor are
+ transparent and which parts are drawn. The source is a bitmap
+ indicating which parts of the non-transparent portion of the the
+ cursor should be painted in the foreground color and which should
+ be painted in the background color. The bitmaps are given in
+ 32-bit format with least significant byte and bit first.
+ (This is opposite PowerPC Darwin.)
+*/
+
+typedef struct {
+ unsigned char image[CURSORWIDTH*CURSORHEIGHT];
+ unsigned char mask[CURSORWIDTH*CURSORHEIGHT];
+} cursorPrivRec, *cursorPrivPtr;
+
+/*
+ * XFIOKitRealizeCursor8
+ * Convert the X cursor representation to an 8-bit depth
+ * format for Darwin. This function assumes the maximum cursor
+ * width is a multiple of 8.
+ */
+static Bool
+XFIOKitRealizeCursor8(
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ cursorPrivPtr newCursor;
+ unsigned char *newSourceP, *newMaskP;
+ CARD32 *oldSourceP, *oldMaskP;
+ xColorItem fgColor, bgColor;
+ int index, x, y, rowPad;
+ int cursorWidth, cursorHeight;
+ ColormapPtr pmap;
+
+ // check cursor size just to be sure
+ cursorWidth = pCursor->bits->width;
+ cursorHeight = pCursor->bits->height;
+ if (cursorHeight > CURSORHEIGHT || cursorWidth > CURSORWIDTH)
+ return FALSE;
+
+ // get cursor colors in colormap
+ index = pScreen->myNum;
+ pmap = miInstalledMaps[index];
+ if (!pmap) return FALSE;
+
+ fgColor.red = pCursor->foreRed;
+ fgColor.green = pCursor->foreGreen;
+ fgColor.blue = pCursor->foreBlue;
+ FakeAllocColor(pmap, &fgColor);
+ bgColor.red = pCursor->backRed;
+ bgColor.green = pCursor->backGreen;
+ bgColor.blue = pCursor->backBlue;
+ FakeAllocColor(pmap, &bgColor);
+ FakeFreeColor(pmap, fgColor.pixel);
+ FakeFreeColor(pmap, bgColor.pixel);
+
+ // allocate memory for new cursor image
+ newCursor = xalloc( sizeof(cursorPrivRec) );
+ if (!newCursor)
+ return FALSE;
+ memset( newCursor->image, pScreen->blackPixel, CURSORWIDTH*CURSORHEIGHT );
+ memset( newCursor->mask, 0, CURSORWIDTH*CURSORHEIGHT );
+
+ // convert to 8-bit Darwin cursor format
+ oldSourceP = (CARD32 *) pCursor->bits->source;
+ oldMaskP = (CARD32 *) pCursor->bits->mask;
+ newSourceP = newCursor->image;
+ newMaskP = newCursor->mask;
+ rowPad = CURSORWIDTH - cursorWidth;
+
+ for (y = 0; y < cursorHeight; y++) {
+ for (x = 0; x < cursorWidth; x++) {
+ if (*oldSourceP & (HighBitOf32 >> x))
+ *newSourceP = fgColor.pixel;
+ else
+ *newSourceP = bgColor.pixel;
+ if (*oldMaskP & (HighBitOf32 >> x))
+ *newMaskP = 255;
+ else
+ *newSourceP = pScreen->blackPixel;
+ newSourceP++; newMaskP++;
+ }
+ oldSourceP++; oldMaskP++;
+ newSourceP += rowPad; newMaskP += rowPad;
+ }
+
+ // save the result
+ pCursor->devPriv[pScreen->myNum] = (pointer) newCursor;
+ return TRUE;
+}
+
+
+/*
+ * XFIOKitRealizeCursor15
+ * Convert the X cursor representation to an 15-bit depth
+ * format for Darwin.
+ */
+static Bool
+XFIOKitRealizeCursor15(
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ unsigned short *newCursor;
+ unsigned short fgPixel, bgPixel;
+ unsigned short *newSourceP;
+ CARD32 *oldSourceP, *oldMaskP;
+ int x, y, rowPad;
+ int cursorWidth, cursorHeight;
+
+ // check cursor size just to be sure
+ cursorWidth = pCursor->bits->width;
+ cursorHeight = pCursor->bits->height;
+ if (cursorHeight > CURSORHEIGHT || cursorWidth > CURSORWIDTH)
+ return FALSE;
+
+ // allocate memory for new cursor image
+ newCursor = xalloc( CURSORWIDTH*CURSORHEIGHT*sizeof(short) );
+ if (!newCursor)
+ return FALSE;
+ memset( newCursor, 0, CURSORWIDTH*CURSORHEIGHT*sizeof(short) );
+
+ // calculate pixel values
+ fgPixel = RGBto34WithGamma( pCursor->foreRed, pCursor->foreGreen,
+ pCursor->foreBlue );
+ bgPixel = RGBto34WithGamma( pCursor->backRed, pCursor->backGreen,
+ pCursor->backBlue );
+
+ // convert to 15-bit Darwin cursor format
+ oldSourceP = (CARD32 *) pCursor->bits->source;
+ oldMaskP = (CARD32 *) pCursor->bits->mask;
+ newSourceP = newCursor;
+ rowPad = CURSORWIDTH - cursorWidth;
+
+ for (y = 0; y < cursorHeight; y++) {
+ for (x = 0; x < cursorWidth; x++) {
+ if (*oldMaskP & (HighBitOf32 >> x)) {
+ if (*oldSourceP & (HighBitOf32 >> x))
+ *newSourceP = fgPixel;
+ else
+ *newSourceP = bgPixel;
+ } else {
+ *newSourceP = 0;
+ }
+ newSourceP++;
+ }
+ oldSourceP++; oldMaskP++;
+ newSourceP += rowPad;
+ }
+
+#if DUMP_DARWIN_CURSOR
+ // Write out the cursor
+ ErrorF("Cursor: 0x%x\n", pCursor);
+ ErrorF("Width = %i, Height = %i, RowPad = %i\n", cursorWidth,
+ cursorHeight, rowPad);
+ for (y = 0; y < cursorHeight; y++) {
+ newSourceP = newCursor + y*CURSORWIDTH;
+ for (x = 0; x < cursorWidth; x++) {
+ if (*newSourceP == fgPixel)
+ ErrorF("x");
+ else if (*newSourceP == bgPixel)
+ ErrorF("o");
+ else
+ ErrorF(" ");
+ newSourceP++;
+ }
+ ErrorF("\n");
+ }
+#endif
+
+ // save the result
+ pCursor->devPriv[pScreen->myNum] = (pointer) newCursor;
+ return TRUE;
+}
+
+
+/*
+ * XFIOKitRealizeCursor24
+ * Convert the X cursor representation to an 24-bit depth
+ * format for Darwin. This function assumes the maximum cursor
+ * width is a multiple of 8.
+ */
+static Bool
+XFIOKitRealizeCursor24(
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ unsigned int *newCursor;
+ unsigned int fgPixel, bgPixel;
+ unsigned int *newSourceP;
+ CARD32 *oldSourceP, *oldMaskP;
+ int x, y, rowPad;
+ int cursorWidth, cursorHeight;
+
+ // check cursor size just to be sure
+ cursorWidth = pCursor->bits->width;
+ cursorHeight = pCursor->bits->height;
+ if (cursorHeight > CURSORHEIGHT || cursorWidth > CURSORWIDTH)
+ return FALSE;
+
+ // allocate memory for new cursor image
+ newCursor = xalloc( CURSORWIDTH*CURSORHEIGHT*sizeof(int) );
+ if (!newCursor)
+ return FALSE;
+ memset( newCursor, 0, CURSORWIDTH*CURSORHEIGHT*sizeof(int) );
+
+ // calculate pixel values
+ fgPixel = RGBto38WithGamma( pCursor->foreRed, pCursor->foreGreen,
+ pCursor->foreBlue );
+ bgPixel = RGBto38WithGamma( pCursor->backRed, pCursor->backGreen,
+ pCursor->backBlue );
+
+ // convert to 24-bit Darwin cursor format
+ oldSourceP = (CARD32 *) pCursor->bits->source;
+ oldMaskP = (CARD32 *) pCursor->bits->mask;
+ newSourceP = newCursor;
+ rowPad = CURSORWIDTH - cursorWidth;
+
+ for (y = 0; y < cursorHeight; y++) {
+ for (x = 0; x < cursorWidth; x++) {
+ if (*oldMaskP & (HighBitOf32 >> x)) {
+ if (*oldSourceP & (HighBitOf32 >> x))
+ *newSourceP = fgPixel;
+ else
+ *newSourceP = bgPixel;
+ } else {
+ *newSourceP = 0;
+ }
+ newSourceP++;
+ }
+ oldSourceP++; oldMaskP++;
+ newSourceP += rowPad;
+ }
+
+#if DUMP_DARWIN_CURSOR
+ // Write out the cursor
+ ErrorF("Cursor: 0x%x\n", pCursor);
+ ErrorF("Width = %i, Height = %i, RowPad = %i\n", cursorWidth,
+ cursorHeight, rowPad);
+ for (y = 0; y < cursorHeight; y++) {
+ newSourceP = newCursor + y*CURSORWIDTH;
+ for (x = 0; x < cursorWidth; x++) {
+ if (*newSourceP == fgPixel)
+ ErrorF("x");
+ else if (*newSourceP == bgPixel)
+ ErrorF("o");
+ else
+ ErrorF(" ");
+ newSourceP++;
+ }
+ ErrorF("\n");
+ }
+#endif
+
+ // save the result
+ pCursor->devPriv[pScreen->myNum] = (pointer) newCursor;
+ return TRUE;
+}
+
+
+/*
+ * XFIOKitRealizeCursor
+ *
+ */
+static Bool
+XFIOKitRealizeCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ Bool result;
+ XFIOKitCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+ DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
+
+ if ((pCursor->bits->height > CURSORHEIGHT) ||
+ (pCursor->bits->width > CURSORWIDTH) ||
+ // FIXME: this condition is not needed after kernel cursor works
+ !ScreenPriv->canHWCursor) {
+ result = (*ScreenPriv->spriteFuncs->RealizeCursor)(pScreen, pCursor);
+ } else if (dfb->bitsPerPixel == 8) {
+ result = XFIOKitRealizeCursor8(pScreen, pCursor);
+ } else if (dfb->bitsPerPixel == 16) {
+ result = XFIOKitRealizeCursor15(pScreen, pCursor);
+ } else {
+ result = XFIOKitRealizeCursor24(pScreen, pCursor);
+ }
+
+ return result;
+}
+
+
+/*
+ * XFIOKitUnrealizeCursor
+ *
+ */
+static Bool
+XFIOKitUnrealizeCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ Bool result;
+ XFIOKitCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ if ((pCursor->bits->height > CURSORHEIGHT) ||
+ (pCursor->bits->width > CURSORWIDTH) ||
+ // FIXME: this condition is not needed after kernel cursor works
+ !ScreenPriv->canHWCursor) {
+ result = (*ScreenPriv->spriteFuncs->UnrealizeCursor)(pScreen, pCursor);
+ } else {
+ xfree( pCursor->devPriv[pScreen->myNum] );
+ result = TRUE;
+ }
+
+ return result;
+}
+
+
+/*
+ * XFIOKitSetCursor
+ * Set the cursor sprite and position
+ * Use hardware cursor if possible
+ */
+static void
+XFIOKitSetCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor,
+ int x,
+ int y)
+{
+ kern_return_t kr;
+ DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
+ XFIOKitScreenPtr iokitScreen = XFIOKIT_SCREEN_PRIV(pScreen);
+ StdFBShmem_t *cshmem = iokitScreen->cursorShmem;
+ XFIOKitCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ // are we supposed to remove the cursor?
+ if (!pCursor) {
+ if (ScreenPriv->cursorMode == 0)
+ (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
+ else {
+ if (!cshmem->cursorShow) {
+ cshmem->cursorShow++;
+ if (cshmem->hardwareCursorActive) {
+ kr = IOFBSetCursorVisible(iokitScreen->fbService, FALSE);
+ kern_assert( kr );
+ }
+ }
+ }
+ return;
+ }
+
+ // can we use the kernel or hardware cursor?
+ if ((pCursor->bits->height <= CURSORHEIGHT) &&
+ (pCursor->bits->width <= CURSORWIDTH) &&
+ // FIXME: condition not needed when kernel cursor works
+ ScreenPriv->canHWCursor) {
+
+ if (ScreenPriv->cursorMode == 0) // remove the X cursor
+ (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
+ ScreenPriv->cursorMode = 1; // kernel cursor
+
+ // change the cursor image in shared memory
+ if (dfb->bitsPerPixel == 8) {
+ cursorPrivPtr newCursor =
+ (cursorPrivPtr) pCursor->devPriv[pScreen->myNum];
+ memcpy(cshmem->cursor.bw8.image[0], newCursor->image,
+ CURSORWIDTH*CURSORHEIGHT);
+ memcpy(cshmem->cursor.bw8.mask[0], newCursor->mask,
+ CURSORWIDTH*CURSORHEIGHT);
+ } else if (dfb->bitsPerPixel == 16) {
+ unsigned short *newCursor =
+ (unsigned short *) pCursor->devPriv[pScreen->myNum];
+ memcpy(cshmem->cursor.rgb.image[0], newCursor,
+ 2*CURSORWIDTH*CURSORHEIGHT);
+ } else {
+ unsigned int *newCursor =
+ (unsigned int *) pCursor->devPriv[pScreen->myNum];
+ memcpy(cshmem->cursor.rgb24.image[0], newCursor,
+ 4*CURSORWIDTH*CURSORHEIGHT);
+ }
+
+ // FIXME: We always use a full size cursor, even if the image
+ // is smaller because I couldn't get the padding to come out
+ // right otherwise.
+ cshmem->cursorSize[0].width = CURSORWIDTH;
+ cshmem->cursorSize[0].height = CURSORHEIGHT;
+ cshmem->hotSpot[0].x = pCursor->bits->xhot;
+ cshmem->hotSpot[0].y = pCursor->bits->yhot;
+
+ // try to use a hardware cursor
+ if (ScreenPriv->canHWCursor) {
+ kr = IOFBSetNewCursor(iokitScreen->fbService, 0, 0, 0);
+ // FIXME: this is a fatal error without the kernel cursor
+ kern_assert( kr );
+#if 0
+ if (kr != KERN_SUCCESS) {
+ ErrorF("Could not set new cursor with kernel return 0x%x.\n", kr);
+ ScreenPriv->canHWCursor = FALSE;
+ }
+#endif
+ }
+
+ // make the new cursor visible
+ if (cshmem->cursorShow)
+ cshmem->cursorShow--;
+
+ if (!cshmem->cursorShow && ScreenPriv->canHWCursor) {
+ kr = IOFBSetCursorVisible(iokitScreen->fbService, TRUE);
+ // FIXME: this is a fatal error without the kernel cursor
+ kern_assert( kr );
+#if 0
+ if (kr != KERN_SUCCESS) {
+ ErrorF("Couldn't set hardware cursor visible with kernel return 0x%x.\n", kr);
+ ScreenPriv->canHWCursor = FALSE;
+ } else
+#endif
+ ScreenPriv->cursorMode = 2; // hardware cursor
+ }
+
+ return;
+ }
+
+ // otherwise we use a software cursor
+ if (ScreenPriv->cursorMode) {
+ /* remove the kernel or hardware cursor */
+ XFIOKitSetCursor(pScreen, 0, x, y);
+ }
+
+ ScreenPriv->cursorMode = 0;
+ (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, pCursor, x, y);
+}
+
+
+/*
+ * XFIOKitMoveCursor
+ * Move the cursor. This is a noop for a kernel or hardware cursor.
+ */
+static void
+XFIOKitMoveCursor(
+ ScreenPtr pScreen,
+ int x,
+ int y)
+{
+ XFIOKitCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ // only the X cursor needs to be explicitly moved
+ if (!ScreenPriv->cursorMode)
+ (*ScreenPriv->spriteFuncs->MoveCursor)(pScreen, x, y);
+}
+
+static miPointerSpriteFuncRec darwinSpriteFuncsRec = {
+ XFIOKitRealizeCursor,
+ XFIOKitUnrealizeCursor,
+ XFIOKitSetCursor,
+ XFIOKitMoveCursor
+};
+
+
+/*
+===========================================================================
+
+ Pointer screen functions
+
+===========================================================================
+*/
+
+/*
+ * XFIOKitCursorOffScreen
+ */
+static Bool XFIOKitCursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
+{ return FALSE;
+}
+
+
+/*
+ * XFIOKitCrossScreen
+ */
+static void XFIOKitCrossScreen(ScreenPtr pScreen, Bool entering)
+{ return;
+}
+
+
+/*
+ * XFIOKitWarpCursor
+ * Change the cursor position without generating an event or motion history
+ */
+static void
+XFIOKitWarpCursor(
+ ScreenPtr pScreen,
+ int x,
+ int y)
+{
+ kern_return_t kr;
+
+ kr = IOHIDSetMouseLocation( xfIOKitInputConnect, x, y );
+ if (kr != KERN_SUCCESS) {
+ ErrorF("Could not set cursor position with kernel return 0x%x.\n", kr);
+ }
+ miPointerWarpCursor(pScreen, x, y);
+}
+
+static miPointerScreenFuncRec darwinScreenFuncsRec = {
+ XFIOKitCursorOffScreen,
+ XFIOKitCrossScreen,
+ XFIOKitWarpCursor,
+ DarwinEQPointerPost,
+ DarwinEQSwitchScreen
+};
+
+
+/*
+===========================================================================
+
+ Other screen functions
+
+===========================================================================
+*/
+
+/*
+ * XFIOKitCursorQueryBestSize
+ * Handle queries for best cursor size
+ */
+static void
+XFIOKitCursorQueryBestSize(
+ int class,
+ unsigned short *width,
+ unsigned short *height,
+ ScreenPtr pScreen)
+{
+ XFIOKitCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ if (class == CursorShape) {
+ *width = CURSORWIDTH;
+ *height = CURSORHEIGHT;
+ } else
+ (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
+}
+
+
+/*
+ * XFIOKitInitCursor
+ * Initialize cursor support
+ */
+Bool
+XFIOKitInitCursor(
+ ScreenPtr pScreen)
+{
+ XFIOKitScreenPtr iokitScreen = XFIOKIT_SCREEN_PRIV(pScreen);
+ XFIOKitCursorScreenPtr ScreenPriv;
+ miPointerScreenPtr PointPriv;
+ kern_return_t kr;
+
+ // start with no cursor displayed
+ if (!iokitScreen->cursorShmem->cursorShow++) {
+ if (iokitScreen->cursorShmem->hardwareCursorActive) {
+ kr = IOFBSetCursorVisible(iokitScreen->fbService, FALSE);
+ kern_assert( kr );
+ }
+ }
+
+ // initialize software cursor handling (always needed as backup)
+ if (!miDCInitialize(pScreen, &darwinScreenFuncsRec)) {
+ return FALSE;
+ }
+
+ // allocate private storage for this screen's hardware cursor info
+ if (darwinCursorGeneration != serverGeneration) {
+ if ((darwinCursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+ darwinCursorGeneration = serverGeneration;
+ }
+
+ ScreenPriv = xcalloc( 1, sizeof(XFIOKitCursorScreenRec) );
+ if (!ScreenPriv) return FALSE;
+
+ pScreen->devPrivates[darwinCursorScreenIndex].ptr = (pointer) ScreenPriv;
+
+ // check if a hardware cursor is supported
+ if (!iokitScreen->cursorShmem->hardwareCursorCapable) {
+ ScreenPriv->canHWCursor = FALSE;
+ ErrorF("Hardware cursor not supported.\n");
+ } else {
+ // we need to make sure that the hardware cursor really works
+ ScreenPriv->canHWCursor = TRUE;
+ kr = IOFBSetNewCursor(iokitScreen->fbService, 0, 0, 0);
+ if (kr != KERN_SUCCESS) {
+ ErrorF("Could not set hardware cursor with kernel return 0x%x.\n", kr);
+ ScreenPriv->canHWCursor = FALSE;
+ }
+ kr = IOFBSetCursorVisible(iokitScreen->fbService, TRUE);
+ if (kr != KERN_SUCCESS) {
+ ErrorF("Couldn't set hardware cursor visible with kernel return 0x%x.\n", kr);
+ ScreenPriv->canHWCursor = FALSE;
+ }
+ IOFBSetCursorVisible(iokitScreen->fbService, FALSE);
+ }
+
+ ScreenPriv->cursorMode = 0;
+ ScreenPriv->pInstalledMap = NULL;
+
+ // override some screen procedures
+ ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
+ pScreen->QueryBestSize = XFIOKitCursorQueryBestSize;
+// ScreenPriv->ConstrainCursor = pScreen->ConstrainCursor;
+// pScreen->ConstrainCursor = XFIOKitConstrainCursor;
+
+ // initialize hardware cursor handling
+ PointPriv = (miPointerScreenPtr)
+ pScreen->devPrivates[miPointerScreenIndex].ptr;
+
+ ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
+ PointPriv->spriteFuncs = &darwinSpriteFuncsRec;
+
+ /* Other routines that might be overridden */
+/*
+ CursorLimitsProcPtr CursorLimits;
+ RecolorCursorProcPtr RecolorCursor;
+*/
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKitStartup.c b/nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKitStartup.c
new file mode 100644
index 000000000..09c5daa1c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKitStartup.c
@@ -0,0 +1,126 @@
+/**************************************************************
+ *
+ * Startup code for the IOKit Darwin X Server
+ *
+ **************************************************************/
+/*
+ * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/iokit/xfIOKitStartup.c,v 1.1 2003/05/14 05:27:56 torrey Exp $ */
+
+#include "darwin.h"
+#include "darwinKeyboard.h"
+#include "micmap.h"
+
+void GlxExtensionInit(void);
+void GlxWrapInitVisuals(miInitVisualsProcPtr *procPtr);
+
+
+/*
+ * DarwinHandleGUI
+ * This function is called first from main().
+ * It does nothing for the IOKit X server.
+ */
+void DarwinHandleGUI(
+ int argc,
+ char *argv[],
+ char *envp[] )
+{
+}
+
+
+/*
+ * DarwinGlxExtensionInit
+ * Initialize the GLX extension.
+ * Mesa is linked into the IOKit mode X server so we just call directly.
+ */
+void DarwinGlxExtensionInit(void)
+{
+ GlxExtensionInit();
+}
+
+
+/*
+ * DarwinGlxWrapInitVisuals
+ */
+void DarwinGlxWrapInitVisuals(
+ miInitVisualsProcPtr *procPtr)
+{
+ GlxWrapInitVisuals(procPtr);
+}
+
+
+/*
+ * DarwinModeProcessArgument
+ * Process IOKit specific command line arguments.
+ */
+int DarwinModeProcessArgument(
+ int argc,
+ char *argv[],
+ int i)
+{
+#ifdef DARWIN_WITH_QUARTZ
+ // XDarwinStartup uses these arguments to indicate which X server
+ // should be started. Ignore them here.
+ if (!strcmp( argv[i], "-fullscreen" ) ||
+ !strcmp( argv[i], "-rootless" ) ||
+ !strcmp( argv[i], "-quartz" ))
+ {
+ return 1;
+ }
+#else
+ if (!strcmp( argv[i], "-fullscreen" ) ||
+ !strcmp( argv[i], "-rootless" ) ||
+ !strcmp( argv[i], "-quartz" ))
+ {
+ FatalError("Command line option %s is not available without Quartz "
+ "support.\n", argv[i]);
+ }
+#endif
+
+ return 0;
+}
+
+
+/*
+ * DarwinModeSystemKeymapSeed
+ * Changes to NXKeyMapping are not tracked.
+ */
+unsigned int
+DarwinModeSystemKeymapSeed(void)
+{
+ return 0;
+}
+
+
+/*
+ * DarwinModeReadSystemKeymap
+ * IOKit has no alternative to NXKeyMapping API.
+ */
+Bool DarwinModeReadSystemKeymap(
+ darwinKeyboardInfo *info)
+{
+ return FALSE;
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/Imakefile b/nx-X11/programs/Xserver/hw/darwin/quartz/Imakefile
new file mode 100644
index 000000000..d12b04f6b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/Imakefile
@@ -0,0 +1,113 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/quartz/Imakefile,v 1.12 2003/11/11 01:29:47 torrey Exp $
+
+#include <Server.tmpl>
+#define IHaveSubdirs
+
+SRCS = Preferences.m \
+ XApplication.m \
+ XServer.m \
+ applewm.c \
+ keysym2ucs.c \
+ quartz.c \
+ quartzAudio.c \
+ quartzCocoa.m \
+ quartzPasteboard.c \
+ quartzKeyboard.c \
+ quartzStartup.c \
+ pseudoramiX.c
+
+OBJS = Preferences.o \
+ XApplication.o \
+ XServer.o \
+ applewm.o \
+ keysym2ucs.o \
+ quartz.o \
+ quartzAudio.o \
+ quartzCocoa.o \
+ quartzPasteboard.o \
+ quartzKeyboard.o \
+ quartzStartup.o \
+ pseudoramiX.o
+
+INCLUDES = -I. -I$(SERVERSRC)/fb -I$(SERVERSRC)/mi -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(SERVERSRC)/render \
+ -I$(SERVERSRC)/miext/shadow -I$(EXTINCSRC) -I$(SERVERSRC)/Xext \
+ -I.. -I$(APPLEWMLIBSRC)
+
+#if defined(XorgCustomVersion) || defined(XFree86CustomVersion)
+# if defined(XorgCustomVersion)
+CUSTOMVERSION = XorgCustomVersion
+# else
+CUSTOMVERSION = XFree86CustomVersion
+# endif /* XorgCustomVersion */
+CUSTOMVERDEF = -DXORG_CUSTOM_VERSION='$(CUSTOMVERSION)'
+#endif /* XorgCustomVersion || XFree86CustomVersion */
+
+#if XFree86Devel
+BUILDSTYLE = -buildstyle Development
+DEBUGDEFINES = -DROOTLESSDEBUG
+#else
+BUILDSTYLE = -buildstyle Deployment
+#endif
+
+#if OSMajorVersion >= 7
+PROJ_TARGET = -project XDarwin.pbproj -target XDarwin
+#else
+PROJ_TARGET = -target XDarwin
+#endif
+
+#if (OSMajorVersion == 1 && OSMinorVersion >= 4) || OSMajorVersion >= 5
+QUARTZDEFINES = -DHAS_CG_MACH_PORT
+#endif
+
+#if HasXplugin
+XPRDEFINES = -DBUILD_XPR
+#endif
+
+#if OSMajorVersion >= 6
+KLDEFINES = -DHAS_KL_API
+#endif
+
+DEFINES = $(CUSTOMVERDEF) -DXBINDIR=$(BINDIR) -DXINITDIR=$(XINITDIR) \
+ $(QUARTZDEFINES) $(DEBUGDEFINES) $(XPRDEFINES) $(KLDEFINES)
+EXTRAMANDEFS = -D__XBinDir__=$(BINDIR)
+#if NothingOutsideProjectRoot
+XDARWINROOT = $(BINDIR)
+#else
+XDARWINROOT = /Applications
+#endif
+
+#if HasXplugin
+SUBDIRS = cr fullscreen xpr
+#else
+SUBDIRS = cr fullscreen
+#endif
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(XQuartz,$(OBJS))
+
+AllTarget(XDarwinStartup)
+NormalProgramTarget(XDarwinStartup,XDarwinStartup.o, \
+ NullParameter,NullParameter, \
+ -framework CoreFoundation -framework ApplicationServices)
+InstallProgram(XDarwinStartup,$(BINDIR))
+install::
+ -(cd $(DESTDIR)$(BINDIR); $(RM) X; $(LN) XDarwinStartup X)
+
+AllTarget(XDarwin)
+XDarwin:
+ $(PROJ_BUILD) $(PROJ_TARGET) $(BUILDSTYLE)
+
+install::
+ $(PROJ_BUILD) install $(PROJ_TARGET) $(BUILDSTYLE) \
+ DSTROOT=$(DESTDIR)$(XDARWINROOT)
+
+InstallManPage(XDarwinStartup,$(MANDIR))
+
+clean::
+ $(PROJ_BUILD) "clean" $(PROJ_TARGET) $(BUILDSTYLE)
+
+DependTarget()
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/Preferences.h b/nx-X11/programs/Xserver/hw/darwin/quartz/Preferences.h
new file mode 100644
index 000000000..d8c3c2ea2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/Preferences.h
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.h,v 1.2 2003/01/15 02:34:05 torrey Exp $ */
+
+#import <Cocoa/Cocoa.h>
+
+@interface Preferences : NSObject
+{
+ IBOutlet NSPanel *window;
+ IBOutlet id displayField;
+ IBOutlet id dockSwitchButton;
+ IBOutlet id fakeButton;
+ IBOutlet id button2ModifiersMatrix;
+ IBOutlet id button3ModifiersMatrix;
+ IBOutlet id switchKeyButton;
+ IBOutlet id keymapFileField;
+ IBOutlet id modeMatrix;
+ IBOutlet id modeWindowButton;
+ IBOutlet id startupHelpButton;
+ IBOutlet id systemBeepButton;
+ IBOutlet id mouseAccelChangeButton;
+ IBOutlet id useXineramaButton;
+ IBOutlet id addToPathButton;
+ IBOutlet id addToPathField;
+ IBOutlet id useDefaultShellMatrix;
+ IBOutlet id useOtherShellField;
+ IBOutlet id depthButton;
+
+ BOOL isGettingKeyCode;
+ int keyCode;
+ int modifiers;
+ NSMutableString *switchString;
+}
+
+- (IBAction)close:(id)sender;
+- (IBAction)pickFile:(id)sender;
+- (IBAction)saveChanges:(id)sender;
+- (IBAction)setKey:(id)sender;
+
+- (BOOL)sendEvent:(NSEvent *)anEvent;
+
+- (void)awakeFromNib;
+- (void)windowWillClose:(NSNotification *)aNotification;
+
++ (void)setUseKeymapFile:(BOOL)newUseKeymapFile;
++ (void)setKeymapFile:(NSString *)newFile;
++ (void)setSwitchString:(NSString *)newString;
++ (void)setKeyCode:(int)newKeyCode;
++ (void)setModifiers:(int)newModifiers;
++ (void)setDisplay:(int)newDisplay;
++ (void)setDockSwitch:(BOOL)newDockSwitch;
++ (void)setFakeButtons:(BOOL)newFakeButtons;
++ (void)setButton2Mask:(int)newFakeMask;
++ (void)setButton3Mask:(int)newFakeMask;
++ (void)setMouseAccelChange:(BOOL)newMouseAccelChange;
++ (void)setUseQDCursor:(int)newUseQDCursor;
++ (void)setRootless:(BOOL)newRootless;
++ (void)setUseAGL:(BOOL)newUseAGL;
++ (void)setModeWindow:(BOOL)newModeWindow;
++ (void)setStartupHelp:(BOOL)newStartupHelp;
++ (void)setSystemBeep:(BOOL)newSystemBeep;
++ (void)setEnableKeyEquivalents:(BOOL)newKeyEquivs;
++ (void)setXinerama:(BOOL)newXinerama;
++ (void)setAddToPath:(BOOL)newAddToPath;
++ (void)setAddToPathString:(NSString *)newAddToPathString;
++ (void)setUseDefaultShell:(BOOL)newUseDefaultShell;
++ (void)setShellString:(NSString *)newShellString;
++ (void)setDepth:(int)newDepth;
++ (void)setDisplayModeBundles:(NSArray *)newBundles;
++ (void)saveToDisk;
+
++ (BOOL)useKeymapFile;
++ (NSString *)keymapFile;
++ (NSString *)switchString;
++ (unsigned int)keyCode;
++ (unsigned int)modifiers;
++ (int)display;
++ (BOOL)dockSwitch;
++ (BOOL)fakeButtons;
++ (int)button2Mask;
++ (int)button3Mask;
++ (BOOL)mouseAccelChange;
++ (int)useQDCursor;
++ (BOOL)rootless;
++ (BOOL)useAGL;
++ (BOOL)modeWindow;
++ (BOOL)startupHelp;
++ (BOOL)systemBeep;
++ (BOOL)enableKeyEquivalents;
++ (BOOL)xinerama;
++ (BOOL)addToPath;
++ (NSString *)addToPathString;
++ (BOOL)useDefaultShell;
++ (NSString *)shellString;
++ (int)depth;
++ (NSArray *)displayModeBundles;
+
+@end
+
+// Possible settings for useQDCursor
+enum {
+ qdCursor_Never, // never use QuickDraw cursor
+ qdCursor_Not8Bit, // don't try to use QuickDraw with 8-bit depth
+ qdCursor_Always // always try to use QuickDraw cursor
+};
+
+// Possible settings for depth
+enum {
+ depth_Current,
+ depth_8Bit,
+ depth_15Bit,
+ depth_24Bit
+};
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/Preferences.m b/nx-X11/programs/Xserver/hw/darwin/quartz/Preferences.m
new file mode 100644
index 000000000..6c14f4982
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/Preferences.m
@@ -0,0 +1,597 @@
+//
+// Preferences.m
+//
+// This class keeps track of the user preferences.
+//
+/*
+ * Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.m,v 1.5 2004/06/08 22:58:10 torrey Exp $ */
+
+#import "quartzCommon.h"
+
+#define BOOL xBOOL
+#include "darwin.h"
+#undef BOOL
+
+#import "Preferences.h"
+
+#include <IOKit/hidsystem/IOLLEvent.h> // for modifier masks
+
+// Macros to build the path name
+#ifndef XBINDIR
+#define XBINDIR /usr/X11R6/bin
+#endif
+#define STR(s) #s
+#define XSTRPATH(s) STR(s)
+
+// Keys for user defaults dictionary
+static NSString *X11EnableKeyEquivalentsKey = @"EnableKeyEquivalents";
+
+
+@implementation Preferences
+
++ (void)initialize
+{
+ // Provide user defaults if needed
+ NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithInt:0], @"Display",
+ @"YES", @"FakeButtons",
+ [NSNumber numberWithInt:NX_COMMANDMASK], @"Button2Mask",
+ [NSNumber numberWithInt:NX_ALTERNATEMASK], @"Button3Mask",
+ NSLocalizedString(@"USA.keymapping",@""), @"KeymappingFile",
+ @"YES", @"UseKeymappingFile",
+ NSLocalizedString(@"Cmd-Opt-a",@""), @"SwitchString",
+ @"YES", @"UseRootlessMode",
+ @"YES", @"UseAGLforGLX",
+ @"YES", @"ShowModePickWindow",
+ @"YES", @"ShowStartupHelp",
+ [NSNumber numberWithInt:0], @"SwitchKeyCode",
+ [NSNumber numberWithInt:(NSCommandKeyMask | NSAlternateKeyMask)],
+ @"SwitchModifiers", @"NO", @"UseSystemBeep",
+ @"YES", X11EnableKeyEquivalentsKey,
+ @"YES", @"DockSwitch",
+ @"NO", @"AllowMouseAccelChange",
+ [NSNumber numberWithInt:qdCursor_Not8Bit], @"UseQDCursor",
+ @"YES", @"Xinerama",
+ @"YES", @"AddToPath",
+ [NSString stringWithCString:XSTRPATH(XBINDIR)], @"AddToPathString",
+ @"YES", @"UseDefaultShell",
+ @"/bin/tcsh", @"Shell",
+ [NSNumber numberWithInt:depth_Current], @"Depth",
+#ifdef BUILD_XPR
+ [NSArray arrayWithObjects:@"xpr.bundle", @"cr.bundle", nil],
+#else
+ [NSArray arrayWithObjects:@"cr.bundle", nil],
+#endif
+ @"DisplayModeBundles", nil];
+
+ [super initialize];
+ [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
+}
+
+// Initialize internal state info of switch key button
+- (void)initSwitchKey
+{
+ keyCode = [Preferences keyCode];
+ modifiers = [Preferences modifiers];
+ [switchString setString:[Preferences switchString]];
+}
+
+- (id)init
+{
+ self = [super init];
+
+ isGettingKeyCode=NO;
+ switchString=[[NSMutableString alloc] init];
+ [self initSwitchKey];
+
+ return self;
+}
+
+// Set a modifiers checkbox matrix to match a modifier mask
+- (void)resetMatrix:(NSMatrix *)aMatrix withMask:(int)aMask
+{
+ [aMatrix setState:(aMask & NX_SHIFTMASK) atRow:0 column:0];
+ [aMatrix setState:(aMask & NX_CONTROLMASK) atRow:1 column:0];
+ [aMatrix setState:(aMask & NX_COMMANDMASK) atRow:2 column:0];
+ [aMatrix setState:(aMask & NX_ALTERNATEMASK) atRow:3 column:0];
+ [aMatrix setState:(aMask & NX_SECONDARYFNMASK) atRow:4 column:0];
+}
+
+// Generate a modifiers mask from a modifiers checkbox matrix
+- (int)getMaskFromMatrix:(NSMatrix *)aMatrix
+{
+ int theMask = 0;
+
+ if ([[aMatrix cellAtRow:0 column:0] state])
+ theMask |= NX_SHIFTMASK;
+ if ([[aMatrix cellAtRow:1 column:0] state])
+ theMask |= NX_CONTROLMASK;
+ if ([[aMatrix cellAtRow:2 column:0] state])
+ theMask |= NX_COMMANDMASK;
+ if ([[aMatrix cellAtRow:3 column:0] state])
+ theMask |= NX_ALTERNATEMASK;
+ if ([[aMatrix cellAtRow:4 column:0] state])
+ theMask |= NX_SECONDARYFNMASK;
+
+ return theMask;
+}
+
+// Set the window controls to the state in user defaults
+- (void)resetWindow
+{
+ if ([Preferences keymapFile] == nil)
+ [keymapFileField setStringValue:@" "];
+ else
+ [keymapFileField setStringValue:[Preferences keymapFile]];
+
+ if ([Preferences switchString] == nil)
+ [switchKeyButton setTitle:@"--"];
+ else
+ [switchKeyButton setTitle:[Preferences switchString]];
+
+ [displayField setIntValue:[Preferences display]];
+ [dockSwitchButton setIntValue:[Preferences dockSwitch]];
+ [fakeButton setIntValue:[Preferences fakeButtons]];
+ [self resetMatrix:button2ModifiersMatrix
+ withMask:[Preferences button2Mask]];
+ [self resetMatrix:button3ModifiersMatrix
+ withMask:[Preferences button3Mask]];
+ [modeMatrix setState:[Preferences rootless] atRow:0 column:1];
+ [startupHelpButton setIntValue:[Preferences startupHelp]];
+ [modeWindowButton setIntValue:[Preferences modeWindow]];
+ [systemBeepButton setIntValue:[Preferences systemBeep]];
+ [mouseAccelChangeButton setIntValue:[Preferences mouseAccelChange]];
+ [useXineramaButton setIntValue:[Preferences xinerama]];
+ [addToPathButton setIntValue:[Preferences addToPath]];
+ [addToPathField setStringValue:[Preferences addToPathString]];
+ [useDefaultShellMatrix setState:![Preferences useDefaultShell]
+ atRow:1 column:0];
+ [useOtherShellField setStringValue:[Preferences shellString]];
+ [depthButton selectItemAtIndex:[Preferences depth]];
+}
+
+- (void)awakeFromNib
+{
+ [self resetWindow];
+}
+
+// Preference window delegate
+- (void)windowWillClose:(NSNotification *)aNotification
+{
+ [self resetWindow];
+ [self initSwitchKey];
+}
+
+// User cancelled the changes
+- (IBAction)close:(id)sender
+{
+ [window orderOut:nil];
+ [self resetWindow]; // reset window controls
+ [self initSwitchKey]; // reset switch key state
+}
+
+// Pick keymapping file
+- (IBAction)pickFile:(id)sender
+{
+ int result;
+ NSArray *fileTypes = [NSArray arrayWithObject:@"keymapping"];
+ NSOpenPanel *oPanel = [NSOpenPanel openPanel];
+
+ [oPanel setAllowsMultipleSelection:NO];
+ result = [oPanel runModalForDirectory:@"/System/Library/Keyboards"
+ file:nil types:fileTypes];
+ if (result == NSOKButton) {
+ [keymapFileField setStringValue:[oPanel filename]];
+ }
+}
+
+// User saved changes
+- (IBAction)saveChanges:(id)sender
+{
+ [Preferences setKeyCode:keyCode];
+ [Preferences setModifiers:modifiers];
+ [Preferences setSwitchString:switchString];
+ [Preferences setKeymapFile:[keymapFileField stringValue]];
+ [Preferences setUseKeymapFile:YES];
+ [Preferences setDisplay:[displayField intValue]];
+ [Preferences setDockSwitch:[dockSwitchButton intValue]];
+ [Preferences setFakeButtons:[fakeButton intValue]];
+ [Preferences setButton2Mask:
+ [self getMaskFromMatrix:button2ModifiersMatrix]];
+ [Preferences setButton3Mask:
+ [self getMaskFromMatrix:button3ModifiersMatrix]];
+ [Preferences setRootless:[[modeMatrix cellAtRow:0 column:1] state]];
+ [Preferences setModeWindow:[modeWindowButton intValue]];
+ [Preferences setStartupHelp:[startupHelpButton intValue]];
+ [Preferences setSystemBeep:[systemBeepButton intValue]];
+ [Preferences setMouseAccelChange:[mouseAccelChangeButton intValue]];
+ [Preferences setXinerama:[useXineramaButton intValue]];
+ [Preferences setAddToPath:[addToPathButton intValue]];
+ [Preferences setAddToPathString:[addToPathField stringValue]];
+ [Preferences setUseDefaultShell:
+ [[useDefaultShellMatrix cellAtRow:0 column:0] state]];
+ [Preferences setShellString:[useOtherShellField stringValue]];
+ [Preferences setDepth:[depthButton indexOfSelectedItem]];
+ [Preferences saveToDisk];
+
+ [window orderOut:nil];
+}
+
+- (IBAction)setKey:(id)sender
+{
+ [switchKeyButton setTitle:NSLocalizedString(@"Press key",@"")];
+ isGettingKeyCode=YES;
+ [switchString setString:@""];
+}
+
+- (BOOL)sendEvent:(NSEvent *)anEvent
+{
+ if(isGettingKeyCode) {
+ if([anEvent type]==NSKeyDown) // wait for keyup
+ return YES;
+ if([anEvent type]!=NSKeyUp)
+ return NO;
+
+ if([anEvent modifierFlags] & NSCommandKeyMask)
+ [switchString appendString:@"Cmd-"];
+ if([anEvent modifierFlags] & NSControlKeyMask)
+ [switchString appendString:@"Ctrl-"];
+ if([anEvent modifierFlags] & NSAlternateKeyMask)
+ [switchString appendString:@"Opt-"];
+ if([anEvent modifierFlags] & NSNumericPadKeyMask) // doesn't work
+ [switchString appendString:@"Num-"];
+ if([anEvent modifierFlags] & NSHelpKeyMask)
+ [switchString appendString:@"Help-"];
+ if([anEvent modifierFlags] & NSFunctionKeyMask) // powerbooks only
+ [switchString appendString:@"Fn-"];
+
+ [switchString appendString:[anEvent charactersIgnoringModifiers]];
+ [switchKeyButton setTitle:switchString];
+
+ keyCode = [anEvent keyCode];
+ modifiers = [anEvent modifierFlags];
+ isGettingKeyCode=NO;
+
+ return YES;
+ }
+ return NO;
+}
+
++ (void)setKeymapFile:(NSString *)newFile
+{
+ [[NSUserDefaults standardUserDefaults] setObject:newFile
+ forKey:@"KeymappingFile"];
+}
+
++ (void)setUseKeymapFile:(BOOL)newUseKeymapFile
+{
+ [[NSUserDefaults standardUserDefaults] setBool:newUseKeymapFile
+ forKey:@"UseKeymappingFile"];
+}
+
++ (void)setSwitchString:(NSString *)newString
+{
+ [[NSUserDefaults standardUserDefaults] setObject:newString
+ forKey:@"SwitchString"];
+}
+
++ (void)setKeyCode:(int)newKeyCode
+{
+ [[NSUserDefaults standardUserDefaults] setInteger:newKeyCode
+ forKey:@"SwitchKeyCode"];
+}
+
++ (void)setModifiers:(int)newModifiers
+{
+ [[NSUserDefaults standardUserDefaults] setInteger:newModifiers
+ forKey:@"SwitchModifiers"];
+}
+
++ (void)setDisplay:(int)newDisplay
+{
+ [[NSUserDefaults standardUserDefaults] setInteger:newDisplay
+ forKey:@"Display"];
+}
+
++ (void)setDockSwitch:(BOOL)newDockSwitch
+{
+ [[NSUserDefaults standardUserDefaults] setBool:newDockSwitch
+ forKey:@"DockSwitch"];
+}
+
++ (void)setFakeButtons:(BOOL)newFakeButtons
+{
+ [[NSUserDefaults standardUserDefaults] setBool:newFakeButtons
+ forKey:@"FakeButtons"];
+ // Update the setting used by the X server thread
+ darwinFakeButtons = newFakeButtons;
+}
+
++ (void)setButton2Mask:(int)newFakeMask
+{
+ [[NSUserDefaults standardUserDefaults] setInteger:newFakeMask
+ forKey:@"Button2Mask"];
+ // Update the setting used by the X server thread
+ darwinFakeMouse2Mask = newFakeMask;
+}
+
++ (void)setButton3Mask:(int)newFakeMask
+{
+ [[NSUserDefaults standardUserDefaults] setInteger:newFakeMask
+ forKey:@"Button3Mask"];
+ // Update the setting used by the X server thread
+ darwinFakeMouse3Mask = newFakeMask;
+}
+
++ (void)setMouseAccelChange:(BOOL)newMouseAccelChange
+{
+ [[NSUserDefaults standardUserDefaults] setBool:newMouseAccelChange
+ forKey:@"AllowMouseAccelChange"];
+ // Update the setting used by the X server thread
+ darwinMouseAccelChange = newMouseAccelChange;
+}
+
++ (void)setUseQDCursor:(int)newUseQDCursor
+{
+ [[NSUserDefaults standardUserDefaults] setInteger:newUseQDCursor
+ forKey:@"UseQDCursor"];
+}
+
++ (void)setModeWindow:(BOOL)newModeWindow
+{
+ [[NSUserDefaults standardUserDefaults] setBool:newModeWindow
+ forKey:@"ShowModePickWindow"];
+}
+
++ (void)setRootless:(BOOL)newRootless
+{
+ [[NSUserDefaults standardUserDefaults] setBool:newRootless
+ forKey:@"UseRootlessMode"];
+}
+
++ (void)setUseAGL:(BOOL)newUseAGL
+{
+ [[NSUserDefaults standardUserDefaults] setBool:newUseAGL
+ forKey:@"UseAGLforGLX"];
+}
+
++ (void)setStartupHelp:(BOOL)newStartupHelp
+{
+ [[NSUserDefaults standardUserDefaults] setBool:newStartupHelp
+ forKey:@"ShowStartupHelp"];
+}
+
++ (void)setSystemBeep:(BOOL)newSystemBeep
+{
+ [[NSUserDefaults standardUserDefaults] setBool:newSystemBeep
+ forKey:@"UseSystemBeep"];
+ // Update the setting used by the X server thread
+ quartzUseSysBeep = newSystemBeep;
+}
+
++ (void)setEnableKeyEquivalents:(BOOL)newKeyEquivs
+{
+ [[NSUserDefaults standardUserDefaults] setBool:newKeyEquivs
+ forKey:X11EnableKeyEquivalentsKey];
+ // Update the setting used by the X server thread
+ quartzEnableKeyEquivalents = newKeyEquivs;
+}
+
++ (void)setXinerama:(BOOL)newXinerama
+{
+ [[NSUserDefaults standardUserDefaults] setBool:newXinerama
+ forKey:@"Xinerama"];
+}
+
++ (void)setAddToPath:(BOOL)newAddToPath
+{
+ [[NSUserDefaults standardUserDefaults] setBool:newAddToPath
+ forKey:@"AddToPath"];
+}
+
++ (void)setAddToPathString:(NSString *)newAddToPathString
+{
+ [[NSUserDefaults standardUserDefaults] setObject:newAddToPathString
+ forKey:@"AddToPathString"];
+}
+
++ (void)setUseDefaultShell:(BOOL)newUseDefaultShell
+{
+ [[NSUserDefaults standardUserDefaults] setBool:newUseDefaultShell
+ forKey:@"UseDefaultShell"];
+}
+
++ (void)setShellString:(NSString *)newShellString
+{
+ [[NSUserDefaults standardUserDefaults] setObject:newShellString
+ forKey:@"Shell"];
+}
+
++ (void)setDepth:(int)newDepth
+{
+ [[NSUserDefaults standardUserDefaults] setInteger:newDepth
+ forKey:@"Depth"];
+}
+
++ (void)setDisplayModeBundles:(NSArray *)newBundles
+{
+ [[NSUserDefaults standardUserDefaults] setObject:newBundles
+ forKey:@"DisplayModeBundles"];
+}
+
++ (void)saveToDisk
+{
+ [[NSUserDefaults standardUserDefaults] synchronize];
+}
+
++ (BOOL)useKeymapFile
+{
+ return [[NSUserDefaults standardUserDefaults]
+ boolForKey:@"UseKeymappingFile"];
+}
+
++ (NSString *)keymapFile
+{
+ return [[NSUserDefaults standardUserDefaults]
+ stringForKey:@"KeymappingFile"];
+}
+
++ (NSString *)switchString
+{
+ return [[NSUserDefaults standardUserDefaults]
+ stringForKey:@"SwitchString"];
+}
+
++ (unsigned int)keyCode
+{
+ return [[NSUserDefaults standardUserDefaults]
+ integerForKey:@"SwitchKeyCode"];
+}
+
++ (unsigned int)modifiers
+{
+ return [[NSUserDefaults standardUserDefaults]
+ integerForKey:@"SwitchModifiers"];
+}
+
++ (int)display
+{
+ return [[NSUserDefaults standardUserDefaults]
+ integerForKey:@"Display"];
+}
+
++ (BOOL)dockSwitch
+{
+ return [[NSUserDefaults standardUserDefaults] boolForKey:@"DockSwitch"];
+}
+
++ (BOOL)fakeButtons
+{
+ return [[NSUserDefaults standardUserDefaults] boolForKey:@"FakeButtons"];
+}
+
++ (int)button2Mask
+{
+ return [[NSUserDefaults standardUserDefaults]
+ integerForKey:@"Button2Mask"];
+}
+
++ (int)button3Mask
+{
+ return [[NSUserDefaults standardUserDefaults]
+ integerForKey:@"Button3Mask"];
+}
+
++ (BOOL)mouseAccelChange
+{
+ return [[NSUserDefaults standardUserDefaults]
+ boolForKey:@"AllowMouseAccelChange"];
+}
+
++ (int)useQDCursor
+{
+ return [[NSUserDefaults standardUserDefaults]
+ integerForKey:@"UseQDCursor"];
+}
+
++ (BOOL)rootless
+{
+ return [[NSUserDefaults standardUserDefaults]
+ boolForKey:@"UseRootlessMode"];
+}
+
++ (BOOL)useAGL
+{
+ return [[NSUserDefaults standardUserDefaults]
+ boolForKey:@"UseAGLforGLX"];
+}
+
++ (BOOL)modeWindow
+{
+ return [[NSUserDefaults standardUserDefaults]
+ boolForKey:@"ShowModePickWindow"];
+}
+
++ (BOOL)startupHelp
+{
+ return [[NSUserDefaults standardUserDefaults]
+ boolForKey:@"ShowStartupHelp"];
+}
+
++ (BOOL)systemBeep
+{
+ return [[NSUserDefaults standardUserDefaults] boolForKey:@"UseSystemBeep"];
+}
+
++ (BOOL)enableKeyEquivalents
+{
+ return [[NSUserDefaults standardUserDefaults] boolForKey:X11EnableKeyEquivalentsKey];
+}
+
++ (BOOL)xinerama
+{
+ return [[NSUserDefaults standardUserDefaults] boolForKey:@"Xinerama"];
+}
+
++ (BOOL)addToPath
+{
+ return [[NSUserDefaults standardUserDefaults] boolForKey:@"AddToPath"];
+}
+
++ (NSString *)addToPathString
+{
+ return [[NSUserDefaults standardUserDefaults]
+ stringForKey:@"AddToPathString"];
+}
+
++ (BOOL)useDefaultShell
+{
+ return [[NSUserDefaults standardUserDefaults]
+ boolForKey:@"UseDefaultShell"];
+}
+
++ (NSString *)shellString
+{
+ return [[NSUserDefaults standardUserDefaults]
+ stringForKey:@"Shell"];
+}
+
++ (int)depth
+{
+ return [[NSUserDefaults standardUserDefaults]
+ integerForKey:@"Depth"];
+}
+
++ (NSArray *)displayModeBundles
+{
+ return [[NSUserDefaults standardUserDefaults]
+ objectForKey:@"DisplayModeBundles"];
+}
+
+@end
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/XApplication.h b/nx-X11/programs/Xserver/hw/darwin/quartz/XApplication.h
new file mode 100644
index 000000000..a2622e060
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/XApplication.h
@@ -0,0 +1,47 @@
+//
+// XApplication.h
+//
+// Created by Andreas Monitzer on January 6, 2001.
+//
+/*
+ * Copyright (c) 2001 Andreas Monitzer. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ */
+/* $XFree86: $ */
+
+#import <Cocoa/Cocoa.h>
+
+#import "XServer.h"
+#import "Preferences.h"
+
+@interface XApplication : NSApplication {
+ IBOutlet XServer *xserver;
+ IBOutlet Preferences *preferences;
+}
+
+- (void)sendEvent:(NSEvent *)anEvent;
+
+@end
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/XApplication.m b/nx-X11/programs/Xserver/hw/darwin/quartz/XApplication.m
new file mode 100644
index 000000000..e0ee8d9c6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/XApplication.m
@@ -0,0 +1,47 @@
+//
+// XApplication.m
+//
+// Created by Andreas Monitzer on January 6, 2001.
+//
+/*
+ * Copyright (c) 2001 Andreas Monitzer. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ */
+/* $XFree86: $ */
+
+#import "XApplication.h"
+
+
+@implementation XApplication
+
+- (void)sendEvent:(NSEvent *)anEvent {
+ if (![xserver translateEvent:anEvent]) {
+ if (![preferences sendEvent:anEvent])
+ [super sendEvent:anEvent];
+ }
+}
+
+@end
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj b/nx-X11/programs/Xserver/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj
new file mode 100644
index 000000000..90002db56
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj
@@ -0,0 +1,2519 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 39;
+ objects = {
+ 01279092000747AA0A000002 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.objc;
+ path = XServer.m;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 0127909600074AF60A000002 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.objc;
+ path = XApplication.m;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 0127909800074B1A0A000002 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = XApplication.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 015698ED003DF345CE6F79C2 = {
+ isa = PBXFileReference;
+ lastKnownFileType = image.icns;
+ path = XDarwin.icns;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 0157A37D002CF6D7CE6F79C2 = {
+ children = (
+ F533214601A4B45401000001,
+ 0157A37E002CF6D7CE6F79C2,
+ F58D65DF018F79B101000001,
+ F533213D0193CBE001000001,
+ 43B962E200617B93416877C2,
+ F5ACD263C5BE031F01000001,
+ F51BF62E02026E3501000001,
+ F5ACD25CC5B5E96601000001,
+ F587E16401924C6901000001,
+ );
+ isa = PBXVariantGroup;
+ name = Credits.rtf;
+ path = "";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 0157A37E002CF6D7CE6F79C2 = {
+ isa = PBXFileReference;
+ lastKnownFileType = text.rtf;
+ name = English;
+ path = English.lproj/Credits.rtf;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 015EDCEA004203A8CE6F79C2 = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.framework;
+ name = IOKit.framework;
+ path = /System/Library/Frameworks/IOKit.framework;
+ refType = 0;
+ sourceTree = "<absolute>";
+ };
+ 018F40F2003E1902CE6F79C2 = {
+ children = (
+ 018F40F3003E1916CE6F79C2,
+ 021D6BA9003E1BACCE6F79C2,
+ 3E74E03600863F047F000001,
+ F5A94EF10314BAC70100011B,
+ 018F40F6003E1974CE6F79C2,
+ 6E5F5F0005537A1A008FEAD7,
+ );
+ isa = PBXGroup;
+ name = "X Server";
+ path = ..;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 018F40F3003E1916CE6F79C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = darwin.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 018F40F6003E1974CE6F79C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = darwinKeyboard.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 018F40F8003E1979CE6F79C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = quartz.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 018F40FA003E197ECE6F79C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = quartz.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 018F40FC003E1983CE6F79C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = xfIOKit.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 018F40FE003E1988CE6F79C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = xfIOKit.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 018F4100003E19E4CE6F79C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = xfIOKitCursor.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//010
+//011
+//012
+//013
+//014
+//020
+//021
+//022
+//023
+//024
+ 021D6BA9003E1BACCE6F79C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = darwin.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 02A1FEA6006D34BE416877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = xfIOKitStartup.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 02A1FEA8006D38F0416877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = quartzStartup.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 02E03CA000348209CE6F79C2 = {
+ children = (
+ F533214701A4B48301000001,
+ 02E03CA100348209CE6F79C2,
+ F58D65E0018F79C001000001,
+ F533213E0193CBF401000001,
+ 43B962E300617B93416877C2,
+ F5ACD268C5BE046401000001,
+ F51BF62F02026E5C01000001,
+ F5ACD261C5B5EA2001000001,
+ F587E16501924C7401000001,
+ );
+ isa = PBXVariantGroup;
+ name = XDarwinHelp.html;
+ path = "";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 02E03CA100348209CE6F79C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.html;
+ name = English;
+ path = English.lproj/XDarwinHelp.html;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//020
+//021
+//022
+//023
+//024
+//030
+//031
+//032
+//033
+//034
+ 0338412F0083BFE57F000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = quartzCursor.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//030
+//031
+//032
+//033
+//034
+//040
+//041
+//042
+//043
+//044
+ 04329610000763920A000002 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.objc;
+ path = Preferences.m;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 04329611000763920A000002 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = Preferences.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//040
+//041
+//042
+//043
+//044
+//080
+//081
+//082
+//083
+//084
+ 080E96DDFE201D6D7F000001 = {
+ children = (
+ 04329610000763920A000002,
+ 04329611000763920A000002,
+ 0127909600074AF60A000002,
+ 0127909800074B1A0A000002,
+ 01279092000747AA0A000002,
+ 1C4A3109004D8F24CE6F79C2,
+ );
+ isa = PBXGroup;
+ name = Classes;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 089C165CFE840E0CC02AAC07 = {
+ children = (
+ F533214301A4B3F001000001,
+ 089C165DFE840E0CC02AAC07,
+ F58D65DD018F798F01000001,
+ F533213A0193CBA201000001,
+ 43B962E100617B49416877C2,
+ F5ACD269C5BE049301000001,
+ F51BF62B02026DDA01000001,
+ F5ACD262C5B5EA4D01000001,
+ F587E16101924C2F01000001,
+ );
+ isa = PBXVariantGroup;
+ name = InfoPlist.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 089C165DFE840E0CC02AAC07 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = English;
+ path = English.lproj/InfoPlist.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//080
+//081
+//082
+//083
+//084
+//0A0
+//0A1
+//0A2
+//0A3
+//0A4
+ 0A79E19E004499A1CE6F79C2 = {
+ explicitFileType = wrapper.application;
+ isa = PBXFileReference;
+ path = XDarwin.app;
+ refType = 3;
+ sourceTree = BUILT_PRODUCTS_DIR;
+ };
+ 0A79E19F004499A1CE6F79C2 = {
+ buildPhases = (
+ 0A79E1A0004499A1CE6F79C2,
+ 0A79E1A1004499A1CE6F79C2,
+ 0A79E1A2004499A1CE6F79C2,
+ 0A79E1A3004499A1CE6F79C2,
+ 0A79E1A4004499A1CE6F79C2,
+ );
+ buildSettings = {
+ INSTALL_PATH = /;
+ OTHER_CFLAGS = "";
+ OTHER_LDFLAGS = "";
+ OTHER_REZFLAGS = "";
+ PRODUCT_NAME = XDarwin;
+ SECTORDER_FLAGS = "";
+ WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
+ WRAPPER_EXTENSION = app;
+ };
+ dependencies = (
+ 6EF065C903D4F0CA006877C2,
+ 6EF065C703D4EE19006877C2,
+ 6E11A986048BDFFB006877C2,
+ 6E7904110500F33B00EEC080,
+ );
+ isa = PBXApplicationTarget;
+ name = XDarwin;
+ productInstallPath = /;
+ productName = XDarwin;
+ productReference = 0A79E19E004499A1CE6F79C2;
+ productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
+<plist version=\"1.0\">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDocumentTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>x11app</string>
+ </array>
+ <key>CFBundleTypeName</key>
+ <string>X11 Application</string>
+ <key>CFBundleTypeOSTypes</key>
+ <array>
+ <string>****</string>
+ </array>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
+ </dict>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>tool</string>
+ <string>*</string>
+ </array>
+ <key>CFBundleTypeName</key>
+ <string>UNIX Application</string>
+ <key>CFBundleTypeOSTypes</key>
+ <array>
+ <string>****</string>
+ </array>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
+ </dict>
+ </array>
+ <key>CFBundleExecutable</key>
+ <string>XDarwin</string>
+ <key>CFBundleGetInfoString</key>
+ <string>XDarwin 1.4.0, X.Org Foundation</string>
+ <key>CFBundleIconFile</key>
+ <string>XDarwin.icns</string>
+ <key>CFBundleIdentifier</key>
+ <string>org.xfree86.XDarwin</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>XDarwin</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>XDarwin 1.4.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string></string>
+ <key>NSHelpFile</key>
+ <string>XDarwinHelp.html</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>XApplication</string>
+</dict>
+</plist>
+";
+ };
+ 0A79E1A0004499A1CE6F79C2 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXHeadersBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 0A79E1A1004499A1CE6F79C2 = {
+ buildActionMask = 2147483647;
+ files = (
+ 0A79E1A600449EB2CE6F79C2,
+ 0A79E1A700449EB2CE6F79C2,
+ 0A79E1A800449EB2CE6F79C2,
+ 0A79E1A900449EB2CE6F79C2,
+ 0A79E1AA00449EB2CE6F79C2,
+ 1220774500712D2D416877C2,
+ F54BF6ED017D506E01000001,
+ );
+ isa = PBXResourcesBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 0A79E1A2004499A1CE6F79C2 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXSourcesBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 0A79E1A3004499A1CE6F79C2 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXFrameworksBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 0A79E1A4004499A1CE6F79C2 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXRezBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 0A79E1A600449EB2CE6F79C2 = {
+ fileRef = 29B97318FDCFA39411CA2CEA;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 0A79E1A700449EB2CE6F79C2 = {
+ fileRef = 089C165CFE840E0CC02AAC07;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 0A79E1A800449EB2CE6F79C2 = {
+ fileRef = 0157A37D002CF6D7CE6F79C2;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 0A79E1A900449EB2CE6F79C2 = {
+ fileRef = 02E03CA000348209CE6F79C2;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 0A79E1AA00449EB2CE6F79C2 = {
+ fileRef = 015698ED003DF345CE6F79C2;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+//0A0
+//0A1
+//0A2
+//0A3
+//0A4
+//100
+//101
+//102
+//103
+//104
+ 1058C7A0FEA54F0111CA2CBB = {
+ children = (
+ F53321400193CCF001000001,
+ 1BE4F84D0006C9890A000002,
+ 1058C7A1FEA54F0111CA2CBB,
+ F53321410193CCF001000001,
+ 015EDCEA004203A8CE6F79C2,
+ );
+ isa = PBXGroup;
+ name = "Linked Frameworks";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 1058C7A1FEA54F0111CA2CBB = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.framework;
+ name = Cocoa.framework;
+ path = /System/Library/Frameworks/Cocoa.framework;
+ refType = 0;
+ sourceTree = "<absolute>";
+ };
+ 1058C7A2FEA54F0111CA2CBB = {
+ children = (
+ 29B97325FDCFA39411CA2CEA,
+ 29B97324FDCFA39411CA2CEA,
+ );
+ isa = PBXGroup;
+ name = "Other Frameworks";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//100
+//101
+//102
+//103
+//104
+//120
+//121
+//122
+//123
+//124
+ 1220774300712D2D416877C2 = {
+ children = (
+ F533214501A4B42501000001,
+ 1220774400712D2D416877C2,
+ F58D65DE018F79A001000001,
+ F533213C0193CBC901000001,
+ 1220774600712D75416877C2,
+ F5ACD266C5BE03C501000001,
+ F51BF62D02026E1C01000001,
+ F5ACD25FC5B5E9AA01000001,
+ F587E16301924C5E01000001,
+ );
+ isa = PBXVariantGroup;
+ name = Localizable.strings;
+ path = "";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 1220774400712D2D416877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = English;
+ path = English.lproj/Localizable.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 1220774500712D2D416877C2 = {
+ fileRef = 1220774300712D2D416877C2;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 1220774600712D75416877C2 = {
+ fileEncoding = 10;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = Japanese;
+ path = Japanese.lproj/Localizable.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//120
+//121
+//122
+//123
+//124
+//170
+//171
+//172
+//173
+//174
+ 170DFAFF00729A35416877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = XDarwinStartup.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 170DFB0000729C86416877C2 = {
+ children = (
+ 018F40FC003E1983CE6F79C2,
+ 018F40FE003E1988CE6F79C2,
+ 018F4100003E19E4CE6F79C2,
+ 02A1FEA6006D34BE416877C2,
+ );
+ isa = PBXGroup;
+ name = IOKit;
+ path = ../iokit;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//170
+//171
+//172
+//173
+//174
+//190
+//191
+//192
+//193
+//194
+ 19C28FACFE9D520D11CA2CBB = {
+ children = (
+ 0A79E19E004499A1CE6F79C2,
+ 6EF7C58703D3BC6D00000104,
+ 6EF065C603D4EE19006877C2,
+ 6E11A985048BDFEE006877C2,
+ 6E7904100500F05600EEC080,
+ );
+ isa = PBXGroup;
+ name = Products;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//190
+//191
+//192
+//193
+//194
+//1B0
+//1B1
+//1B2
+//1B3
+//1B4
+ 1BD8DE4200B8A3567F000001 = {
+ children = (
+ F533214401A4B40F01000001,
+ 1BD8DE4300B8A3567F000001,
+ F58D65DC018F794D01000001,
+ F533213B0193CBB401000001,
+ 1BD8DE4700B8A3C77F000001,
+ F5ACD264C5BE035B01000001,
+ F51BF62C02026E0601000001,
+ F5ACD25DC5B5E97701000001,
+ F587E16201924C5301000001,
+ );
+ isa = PBXVariantGroup;
+ name = InfoPlist.strings.cpp;
+ path = "";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 1BD8DE4300B8A3567F000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = English;
+ path = English.lproj/InfoPlist.strings.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 1BD8DE4400B8A38E7F000001 = {
+ children = (
+ F533214801A4B4D701000001,
+ 1BD8DE4500B8A38E7F000001,
+ F58D65E1018F79E001000001,
+ F533213F0193CC2501000001,
+ 1BD8DE4800B8A4167F000001,
+ F5ACD267C5BE03FC01000001,
+ F51BF63002026E8D01000001,
+ F5ACD260C5B5E9DF01000001,
+ F587E16601924C9D01000001,
+ );
+ isa = PBXVariantGroup;
+ name = XDarwinHelp.html.cpp;
+ path = "";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 1BD8DE4500B8A38E7F000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = English;
+ path = English.lproj/XDarwinHelp.html.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 1BD8DE4700B8A3C77F000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = Japanese;
+ path = Japanese.lproj/InfoPlist.strings.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 1BD8DE4800B8A4167F000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = Japanese;
+ path = Japanese.lproj/XDarwinHelp.html.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 1BE4F84D0006C9890A000002 = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.framework;
+ name = Carbon.framework;
+ path = /System/Library/Frameworks/Carbon.framework;
+ refType = 0;
+ sourceTree = "<absolute>";
+ };
+//1B0
+//1B1
+//1B2
+//1B3
+//1B4
+//1C0
+//1C1
+//1C2
+//1C3
+//1C4
+ 1C4A3109004D8F24CE6F79C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = XServer.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//1C0
+//1C1
+//1C2
+//1C3
+//1C4
+//230
+//231
+//232
+//233
+//234
+ 237A34C10076E37E7F000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = quartzAudio.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 237A34C20076E37E7F000001 = {
+ buildSettings = {
+ COPY_PHASE_STRIP = NO;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ OPTIMIZATION_CFLAGS = "-O0";
+ ZERO_LINK = YES;
+ };
+ isa = PBXBuildStyle;
+ name = Development;
+ };
+ 237A34C30076E37E7F000001 = {
+ buildSettings = {
+ COPY_PHASE_STRIP = YES;
+ GCC_ENABLE_FIX_AND_CONTINUE = NO;
+ ZERO_LINK = NO;
+ };
+ isa = PBXBuildStyle;
+ name = Deployment;
+ };
+ 237A34C40076F4F07F000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = quartzAudio.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//230
+//231
+//232
+//233
+//234
+//290
+//291
+//292
+//293
+//294
+ 29B97313FDCFA39411CA2CEA = {
+ buildSettings = {
+ };
+ buildStyles = (
+ 237A34C20076E37E7F000001,
+ 237A34C30076E37E7F000001,
+ );
+ hasScannedForEncodings = 1;
+ isa = PBXProject;
+ knownRegions = (
+ English,
+ Japanese,
+ French,
+ German,
+ Swedish,
+ Dutch,
+ Spanish,
+ ko,
+ Portuguese,
+ );
+ mainGroup = 29B97314FDCFA39411CA2CEA;
+ projectDirPath = "";
+ targets = (
+ 0A79E19F004499A1CE6F79C2,
+ 6EF7C58603D3BC6D00000104,
+ 6E11A984048BDFEE006877C2,
+ 6EF065C503D4EE19006877C2,
+ 6E79040F0500F05600EEC080,
+ );
+ };
+ 29B97314FDCFA39411CA2CEA = {
+ children = (
+ 080E96DDFE201D6D7F000001,
+ 018F40F2003E1902CE6F79C2,
+ 170DFB0000729C86416877C2,
+ 43B962CE00617089416877C2,
+ F5614B3D025112D901000114,
+ 6EC4A64C042A9597006877C2,
+ 32FEE13C00E07C3E7F000001,
+ 6EE1214104968658006877C2,
+ 6EC4A66D042A97FC006877C2,
+ 29B97315FDCFA39411CA2CEA,
+ 29B97317FDCFA39411CA2CEA,
+ 29B97323FDCFA39411CA2CEA,
+ 19C28FACFE9D520D11CA2CBB,
+ );
+ isa = PBXGroup;
+ name = "Xmaster-Cocoa";
+ path = "";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 29B97315FDCFA39411CA2CEA = {
+ children = (
+ 170DFAFF00729A35416877C2,
+ );
+ isa = PBXGroup;
+ name = "Other Sources";
+ path = "";
+ refType = 2;
+ sourceTree = SOURCE_ROOT;
+ };
+ 29B97317FDCFA39411CA2CEA = {
+ children = (
+ 29B97318FDCFA39411CA2CEA,
+ 089C165CFE840E0CC02AAC07,
+ 1BD8DE4200B8A3567F000001,
+ 1220774300712D2D416877C2,
+ 0157A37D002CF6D7CE6F79C2,
+ 02E03CA000348209CE6F79C2,
+ 1BD8DE4400B8A38E7F000001,
+ 015698ED003DF345CE6F79C2,
+ F54BF6EA017D500901000001,
+ F54BF6EC017D506E01000001,
+ );
+ isa = PBXGroup;
+ name = Resources;
+ path = ../bundle;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 29B97318FDCFA39411CA2CEA = {
+ children = (
+ F533214201A4B3CE01000001,
+ 29B97319FDCFA39411CA2CEA,
+ F58D65DB018F793801000001,
+ F53321390193CB6A01000001,
+ 43B962E000617B49416877C2,
+ F5ACD265C5BE038601000001,
+ F51BF62A02026DAF01000001,
+ F5ACD25EC5B5E98D01000001,
+ F587E16001924C1D01000001,
+ );
+ isa = PBXVariantGroup;
+ name = MainMenu.nib;
+ path = "";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 29B97319FDCFA39411CA2CEA = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.nib;
+ name = English;
+ path = English.lproj/MainMenu.nib;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 29B97323FDCFA39411CA2CEA = {
+ children = (
+ 1058C7A0FEA54F0111CA2CBB,
+ 1058C7A2FEA54F0111CA2CBB,
+ );
+ isa = PBXGroup;
+ name = Frameworks;
+ path = "";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 29B97324FDCFA39411CA2CEA = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.framework;
+ name = AppKit.framework;
+ path = /System/Library/Frameworks/AppKit.framework;
+ refType = 0;
+ sourceTree = "<absolute>";
+ };
+ 29B97325FDCFA39411CA2CEA = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.framework;
+ name = Foundation.framework;
+ path = /System/Library/Frameworks/Foundation.framework;
+ refType = 0;
+ sourceTree = "<absolute>";
+ };
+//290
+//291
+//292
+//293
+//294
+//320
+//321
+//322
+//323
+//324
+ 32FEE13C00E07C3E7F000001 = {
+ children = (
+ F5269C2D01D5BC3501000001,
+ F5269C2E01D5BC3501000001,
+ );
+ isa = PBXGroup;
+ name = "Old Cocoa Imp";
+ path = "";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//320
+//321
+//322
+//323
+//324
+//350
+//351
+//352
+//353
+//354
+ 3576829A0077B8F17F000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = quartzCursor.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//350
+//351
+//352
+//353
+//354
+//3E0
+//3E1
+//3E2
+//3E3
+//3E4
+ 3E74E03600863F047F000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = darwinClut8.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//3E0
+//3E1
+//3E2
+//3E3
+//3E4
+//430
+//431
+//432
+//433
+//434
+ 43B962CE00617089416877C2 = {
+ children = (
+ 6EE9B21604E859C200CA7FEA,
+ 6E97A0F505079F9100B8294C,
+ 6E5F5F030553815A008FEAD7,
+ 6E5F5F040553815A008FEAD7,
+ 018F40F8003E1979CE6F79C2,
+ 018F40FA003E197ECE6F79C2,
+ 237A34C10076E37E7F000001,
+ 237A34C40076F4F07F000001,
+ 43B962CF00617089416877C2,
+ F5582948015DAD3B01000001,
+ 6E5F5F0105537A5F008FEAD7,
+ 43B962D000617089416877C2,
+ 43B962D100617089416877C2,
+ 02A1FEA8006D38F0416877C2,
+ );
+ isa = PBXGroup;
+ name = Quartz;
+ path = "";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 43B962CF00617089416877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.objc;
+ path = quartzCocoa.m;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 43B962D000617089416877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = quartzPasteboard.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 43B962D100617089416877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = quartzPasteboard.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 43B962E000617B49416877C2 = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.nib;
+ name = Japanese;
+ path = Japanese.lproj/MainMenu.nib;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 43B962E100617B49416877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = Japanese;
+ path = Japanese.lproj/InfoPlist.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 43B962E200617B93416877C2 = {
+ isa = PBXFileReference;
+ lastKnownFileType = text.rtf;
+ name = Japanese;
+ path = Japanese.lproj/Credits.rtf;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 43B962E300617B93416877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.html;
+ name = Japanese;
+ path = Japanese.lproj/XDarwinHelp.html;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//430
+//431
+//432
+//433
+//434
+//6E0
+//6E1
+//6E2
+//6E3
+//6E4
+ 6E11A97F048BDFEE006877C2 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXHeadersBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6E11A980048BDFEE006877C2 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXResourcesBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6E11A981048BDFEE006877C2 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXSourcesBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6E11A982048BDFEE006877C2 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXFrameworksBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6E11A983048BDFEE006877C2 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXRezBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6E11A984048BDFEE006877C2 = {
+ buildPhases = (
+ 6E11A97F048BDFEE006877C2,
+ 6E11A980048BDFEE006877C2,
+ 6E11A981048BDFEE006877C2,
+ 6E11A982048BDFEE006877C2,
+ 6E11A983048BDFEE006877C2,
+ );
+ buildSettings = {
+ OTHER_CFLAGS = "";
+ OTHER_LDFLAGS = "";
+ OTHER_REZFLAGS = "";
+ PRODUCT_NAME = glxCGL;
+ SECTORDER_FLAGS = "";
+ WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
+ WRAPPER_EXTENSION = bundle;
+ };
+ dependencies = (
+ );
+ isa = PBXBundleTarget;
+ name = glxCGL;
+ productInstallPath = "$(USER_LIBRARY_DIR)/Bundles";
+ productName = glxCGL;
+ productReference = 6E11A985048BDFEE006877C2;
+ productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
+<plist version=\"1.0\">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>glxCGL</string>
+ <key>CFBundleGetInfoString</key>
+ <string></string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string></string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>GLX bundle using Apple's OpenGL</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>0.1</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>0.1</string>
+</dict>
+</plist>
+";
+ };
+ 6E11A985048BDFEE006877C2 = {
+ explicitFileType = wrapper.cfbundle;
+ isa = PBXFileReference;
+ path = glxCGL.bundle;
+ refType = 3;
+ sourceTree = BUILT_PRODUCTS_DIR;
+ };
+ 6E11A986048BDFFB006877C2 = {
+ isa = PBXTargetDependency;
+ target = 6E11A984048BDFEE006877C2;
+ targetProxy = 6E4CAF650702464F001A7398;
+ };
+ 6E4CAF630702464F001A7398 = {
+ containerPortal = 29B97313FDCFA39411CA2CEA;
+ isa = PBXContainerItemProxy;
+ proxyType = 1;
+ remoteGlobalIDString = 6EF7C58603D3BC6D00000104;
+ remoteInfo = glxAGL;
+ };
+ 6E4CAF640702464F001A7398 = {
+ containerPortal = 29B97313FDCFA39411CA2CEA;
+ isa = PBXContainerItemProxy;
+ proxyType = 1;
+ remoteGlobalIDString = 6E79040F0500F05600EEC080;
+ remoteInfo = xpr;
+ };
+ 6E4CAF650702464F001A7398 = {
+ containerPortal = 29B97313FDCFA39411CA2CEA;
+ isa = PBXContainerItemProxy;
+ proxyType = 1;
+ remoteGlobalIDString = 6E11A984048BDFEE006877C2;
+ remoteInfo = glxCGL;
+ };
+ 6E4CAF660702464F001A7398 = {
+ containerPortal = 29B97313FDCFA39411CA2CEA;
+ isa = PBXContainerItemProxy;
+ proxyType = 1;
+ remoteGlobalIDString = 6EF065C503D4EE19006877C2;
+ remoteInfo = glxMesa;
+ };
+ 6E5F5F0005537A1A008FEAD7 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = darwinKeyboard.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6E5F5F0105537A5F008FEAD7 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = quartzKeyboard.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6E5F5F030553815A008FEAD7 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = keysym2ucs.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6E5F5F040553815A008FEAD7 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = keysym2ucs.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6E6656EC048832CF006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = "x-hook.c";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6E6656ED048832CF006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = "x-hook.h";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6E6656F0048832EC006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = dri.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6E6656F1048832EC006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = dri.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6E6656F2048832EC006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = dristruct.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6E6656F3048832F9006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = appledri.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6E79040104FD5ED900EEC080 = {
+ children = (
+ 6E79040204FD5EDA00EEC080,
+ 6E79040304FD5EDA00EEC080,
+ 6E79040404FD5EDA00EEC080,
+ );
+ isa = PBXGroup;
+ name = "Safe Alpha";
+ path = safeAlpha;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6E79040204FD5EDA00EEC080 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = safeAlpha.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6E79040304FD5EDA00EEC080 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = safeAlphaPicture.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6E79040404FD5EDA00EEC080 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = safeAlphaWindow.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6E79040A0500F05600EEC080 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXHeadersBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6E79040B0500F05600EEC080 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXResourcesBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6E79040C0500F05600EEC080 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXSourcesBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6E79040D0500F05600EEC080 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXFrameworksBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6E79040E0500F05600EEC080 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXRezBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6E79040F0500F05600EEC080 = {
+ buildPhases = (
+ 6E79040A0500F05600EEC080,
+ 6E79040B0500F05600EEC080,
+ 6E79040C0500F05600EEC080,
+ 6E79040D0500F05600EEC080,
+ 6E79040E0500F05600EEC080,
+ );
+ buildSettings = {
+ OTHER_CFLAGS = "";
+ OTHER_LDFLAGS = "";
+ OTHER_REZFLAGS = "";
+ PRODUCT_NAME = xpr;
+ SECTORDER_FLAGS = "";
+ WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
+ WRAPPER_EXTENSION = bundle;
+ };
+ dependencies = (
+ );
+ isa = PBXBundleTarget;
+ name = xpr;
+ productInstallPath = "$(USER_LIBRARY_DIR)/Bundles";
+ productName = xpr;
+ productReference = 6E7904100500F05600EEC080;
+ productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
+<plist version=\"1.0\">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>xpr</string>
+ <key>CFBundleGetInfoString</key>
+ <string></string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string></string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>Xplugin rootless implementation</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>0.1</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>0.1</string>
+</dict>
+</plist>
+";
+ };
+ 6E7904100500F05600EEC080 = {
+ explicitFileType = wrapper.cfbundle;
+ isa = PBXFileReference;
+ path = xpr.bundle;
+ refType = 3;
+ sourceTree = BUILT_PRODUCTS_DIR;
+ };
+ 6E7904110500F33B00EEC080 = {
+ isa = PBXTargetDependency;
+ target = 6E79040F0500F05600EEC080;
+ targetProxy = 6E4CAF640702464F001A7398;
+ };
+ 6E97A0F2050798B100B8294C = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = xprAppleWM.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6E97A0F305079B6500B8294C = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.objc;
+ path = crAppleWM.m;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6E97A0F505079F9100B8294C = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = applewmExt.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EA0B3AF0544A9CC006877C2 = {
+ children = (
+ 6EA0B3B00544A9CC006877C2,
+ 6EA0B3B10544A9CC006877C2,
+ 6EA0B3B20544A9CC006877C2,
+ 6EA0B3B30544A9CC006877C2,
+ 6EA0B3B40544A9CC006877C2,
+ 6EA0B3B50544A9CC006877C2,
+ 6EA0B3B60544A9CC006877C2,
+ 6EA0B3B70544A9CC006877C2,
+ );
+ isa = PBXGroup;
+ name = Acceleration;
+ path = accel;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EA0B3B00544A9CC006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = rlAccel.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EA0B3B10544A9CC006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = rlBlt.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EA0B3B20544A9CC006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = rlCopy.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EA0B3B30544A9CC006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = rlFill.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EA0B3B40544A9CC006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = rlFillRect.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EA0B3B50544A9CC006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = rlFillSpans.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EA0B3B60544A9CC006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = rlGlyph.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EA0B3B70544A9CC006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = rlSolid.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EA8EEC80445E25C006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = rootlessConfig.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EC4A64C042A9597006877C2 = {
+ children = (
+ 6EC4A65D042A9654006877C2,
+ 6EC4A65E042A9654006877C2,
+ 6EC4A65F042A9654006877C2,
+ 6EA8EEC80445E25C006877C2,
+ 6EC4A661042A9654006877C2,
+ 6EC4A662042A9654006877C2,
+ 6EC4A660042A9654006877C2,
+ 6EC4A663042A9654006877C2,
+ 6EC4A664042A9654006877C2,
+ 6EA0B3AF0544A9CC006877C2,
+ 6E79040104FD5ED900EEC080,
+ );
+ isa = PBXGroup;
+ name = Rootless;
+ path = ../../../miext/rootless;
+ refType = 2;
+ sourceTree = SOURCE_ROOT;
+ };
+ 6EC4A65D042A9654006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = rootless.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EC4A65E042A9654006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = rootlessCommon.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EC4A65F042A9654006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = rootlessCommon.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EC4A660042A9654006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = rootlessWindow.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EC4A661042A9654006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = rootlessScreen.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EC4A662042A9654006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = rootlessWindow.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EC4A663042A9654006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = rootlessGC.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EC4A664042A9654006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = rootlessValTree.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EC4A66D042A97FC006877C2 = {
+ children = (
+ 6EF471A004478DE0006877C2,
+ 6E6656F3048832F9006877C2,
+ 6E6656F0048832EC006877C2,
+ 6E6656F1048832EC006877C2,
+ 6E6656F2048832EC006877C2,
+ 6ECF218404589E4D006877C2,
+ 6E97A0F2050798B100B8294C,
+ 6ECF218604589F40006877C2,
+ 6EF4719E04478B08006877C2,
+ 6EDDB2DF04508B2C006877C2,
+ 6EF471A204479263006877C2,
+ 6EF471A404479263006877C2,
+ 6E6656EC048832CF006877C2,
+ 6E6656ED048832CF006877C2,
+ 6EF471A504479263006877C2,
+ 6EF471A304479263006877C2,
+ );
+ isa = PBXGroup;
+ path = xpr;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6ECF218404589E4D006877C2 = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = xpr.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6ECF218604589F40006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = xprCursor.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EDDB2DF04508B2C006877C2 = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = xprScreen.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EE1214104968658006877C2 = {
+ children = (
+ 6EE1214304968692006877C2,
+ 6EE1214404968692006877C2,
+ 6EE1214204968692006877C2,
+ 6E97A0F305079B6500B8294C,
+ 6EE1214504968692006877C2,
+ 6EE1214604968692006877C2,
+ );
+ isa = PBXGroup;
+ path = cr;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EE1214204968692006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = cr.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EE1214304968692006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.objc;
+ path = XView.m;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EE1214404968692006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = XView.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EE1214504968692006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.objc;
+ path = crFrame.m;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EE1214604968692006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.objc;
+ path = crScreen.m;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EE9B21604E859C200CA7FEA = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = applewm.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EF065C003D4EE19006877C2 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXHeadersBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6EF065C103D4EE19006877C2 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXResourcesBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6EF065C203D4EE19006877C2 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXSourcesBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6EF065C303D4EE19006877C2 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXFrameworksBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6EF065C403D4EE19006877C2 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXRezBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6EF065C503D4EE19006877C2 = {
+ buildPhases = (
+ 6EF065C003D4EE19006877C2,
+ 6EF065C103D4EE19006877C2,
+ 6EF065C203D4EE19006877C2,
+ 6EF065C303D4EE19006877C2,
+ 6EF065C403D4EE19006877C2,
+ );
+ buildSettings = {
+ OTHER_CFLAGS = "";
+ OTHER_LDFLAGS = "";
+ OTHER_REZFLAGS = "";
+ PRODUCT_NAME = glxMesa;
+ SECTORDER_FLAGS = "";
+ WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
+ WRAPPER_EXTENSION = bundle;
+ };
+ dependencies = (
+ );
+ isa = PBXBundleTarget;
+ name = glxMesa;
+ productInstallPath = "$(USER_LIBRARY_DIR)/Bundles";
+ productName = glxMesa;
+ productReference = 6EF065C603D4EE19006877C2;
+ productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
+<plist version=\"1.0\">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>glxMesa</string>
+ <key>CFBundleGetInfoString</key>
+ <string></string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string></string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>GLX bundle with Mesa</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>0.1</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>0.1</string>
+</dict>
+</plist>
+";
+ };
+ 6EF065C603D4EE19006877C2 = {
+ explicitFileType = wrapper.cfbundle;
+ isa = PBXFileReference;
+ path = glxMesa.bundle;
+ refType = 3;
+ sourceTree = BUILT_PRODUCTS_DIR;
+ };
+ 6EF065C703D4EE19006877C2 = {
+ isa = PBXTargetDependency;
+ target = 6EF065C503D4EE19006877C2;
+ targetProxy = 6E4CAF660702464F001A7398;
+ };
+ 6EF065C903D4F0CA006877C2 = {
+ isa = PBXTargetDependency;
+ target = 6EF7C58603D3BC6D00000104;
+ targetProxy = 6E4CAF630702464F001A7398;
+ };
+ 6EF4719E04478B08006877C2 = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = xprFrame.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EF471A004478DE0006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = Xplugin.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EF471A204479263006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = "x-hash.c";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EF471A304479263006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = "x-list.h";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EF471A404479263006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = "x-hash.h";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EF471A504479263006877C2 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = "x-list.c";
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 6EF7C58103D3BC6D00000104 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXHeadersBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6EF7C58203D3BC6D00000104 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXResourcesBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6EF7C58303D3BC6D00000104 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXSourcesBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6EF7C58403D3BC6D00000104 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXFrameworksBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6EF7C58503D3BC6D00000104 = {
+ buildActionMask = 2147483647;
+ files = (
+ );
+ isa = PBXRezBuildPhase;
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 6EF7C58603D3BC6D00000104 = {
+ buildPhases = (
+ 6EF7C58103D3BC6D00000104,
+ 6EF7C58203D3BC6D00000104,
+ 6EF7C58303D3BC6D00000104,
+ 6EF7C58403D3BC6D00000104,
+ 6EF7C58503D3BC6D00000104,
+ );
+ buildSettings = {
+ OTHER_CFLAGS = "";
+ OTHER_LDFLAGS = "";
+ OTHER_REZFLAGS = "";
+ PRODUCT_NAME = glxAGL;
+ SECTORDER_FLAGS = "";
+ WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
+ WRAPPER_EXTENSION = bundle;
+ };
+ dependencies = (
+ );
+ isa = PBXBundleTarget;
+ name = glxAGL;
+ productName = glxAGL;
+ productReference = 6EF7C58703D3BC6D00000104;
+ productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
+<plist version=\"1.0\">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>glxAGL</string>
+ <key>CFBundleGetInfoString</key>
+ <string></string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string></string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>GLX bundle using AGL framework</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>0.1</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>0.1</string>
+</dict>
+</plist>
+";
+ };
+ 6EF7C58703D3BC6D00000104 = {
+ explicitFileType = wrapper.cfbundle;
+ isa = PBXFileReference;
+ path = glxAGL.bundle;
+ refType = 3;
+ sourceTree = BUILT_PRODUCTS_DIR;
+ };
+//6E0
+//6E1
+//6E2
+//6E3
+//6E4
+//F50
+//F51
+//F52
+//F53
+//F54
+ F51BF62A02026DAF01000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.nib;
+ name = Portuguese;
+ path = Portuguese.lproj/MainMenu.nib;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F51BF62B02026DDA01000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = Portuguese;
+ path = Portuguese.lproj/InfoPlist.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F51BF62C02026E0601000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = Portuguese;
+ path = Portuguese.lproj/InfoPlist.strings.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F51BF62D02026E1C01000001 = {
+ fileEncoding = 10;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = Portuguese;
+ path = Portuguese.lproj/Localizable.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F51BF62E02026E3501000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = text.rtf;
+ name = Portuguese;
+ path = Portuguese.lproj/Credits.rtf;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F51BF62F02026E5C01000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.html;
+ name = Portuguese;
+ path = Portuguese.lproj/XDarwinHelp.html;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F51BF63002026E8D01000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = Portuguese;
+ path = Portuguese.lproj/XDarwinHelp.html.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5269C2D01D5BC3501000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = pseudoramiX.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5269C2E01D5BC3501000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = pseudoramiX.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F53321390193CB6A01000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.nib;
+ name = German;
+ path = German.lproj/MainMenu.nib;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F533213A0193CBA201000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = German;
+ path = German.lproj/InfoPlist.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F533213B0193CBB401000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = German;
+ path = German.lproj/InfoPlist.strings.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F533213C0193CBC901000001 = {
+ fileEncoding = 10;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = German;
+ path = German.lproj/Localizable.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F533213D0193CBE001000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = text.rtf;
+ name = German;
+ path = German.lproj/Credits.rtf;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F533213E0193CBF401000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.html;
+ name = German;
+ path = German.lproj/XDarwinHelp.html;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F533213F0193CC2501000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = German;
+ path = German.lproj/XDarwinHelp.html.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F53321400193CCF001000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.framework;
+ name = ApplicationServices.framework;
+ path = /System/Library/Frameworks/ApplicationServices.framework;
+ refType = 0;
+ sourceTree = "<absolute>";
+ };
+ F53321410193CCF001000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.framework;
+ name = CoreAudio.framework;
+ path = /System/Library/Frameworks/CoreAudio.framework;
+ refType = 0;
+ sourceTree = "<absolute>";
+ };
+ F533214201A4B3CE01000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.nib;
+ name = Dutch;
+ path = Dutch.lproj/MainMenu.nib;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F533214301A4B3F001000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = Dutch;
+ path = Dutch.lproj/InfoPlist.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F533214401A4B40F01000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = Dutch;
+ path = Dutch.lproj/InfoPlist.strings.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F533214501A4B42501000001 = {
+ fileEncoding = 10;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = Dutch;
+ path = Dutch.lproj/Localizable.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F533214601A4B45401000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = text.rtf;
+ name = Dutch;
+ path = Dutch.lproj/Credits.rtf;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F533214701A4B48301000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.html;
+ name = Dutch;
+ path = Dutch.lproj/XDarwinHelp.html;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F533214801A4B4D701000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = Dutch;
+ path = Dutch.lproj/XDarwinHelp.html.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F54BF6EA017D500901000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ path = startXClients.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F54BF6EC017D506E01000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = text.script.sh;
+ path = startXClients;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F54BF6ED017D506E01000001 = {
+ fileRef = F54BF6EC017D506E01000001;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ F5582948015DAD3B01000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = quartzCommon.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5614B3B0251124C01000114 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = fullscreen.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5614B3D025112D901000114 = {
+ children = (
+ F5614B3B0251124C01000114,
+ 3576829A0077B8F17F000001,
+ 0338412F0083BFE57F000001,
+ );
+ isa = PBXGroup;
+ path = fullscreen;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F587E16001924C1D01000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.nib;
+ name = Swedish;
+ path = Swedish.lproj/MainMenu.nib;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F587E16101924C2F01000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = Swedish;
+ path = Swedish.lproj/InfoPlist.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F587E16201924C5301000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = Swedish;
+ path = Swedish.lproj/InfoPlist.strings.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F587E16301924C5E01000001 = {
+ fileEncoding = 10;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = Swedish;
+ path = Swedish.lproj/Localizable.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F587E16401924C6901000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = text.rtf;
+ name = Swedish;
+ path = Swedish.lproj/Credits.rtf;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F587E16501924C7401000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.html;
+ name = Swedish;
+ path = Swedish.lproj/XDarwinHelp.html;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F587E16601924C9D01000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = Swedish;
+ path = Swedish.lproj/XDarwinHelp.html.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F58D65DB018F793801000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.nib;
+ name = French;
+ path = French.lproj/MainMenu.nib;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F58D65DC018F794D01000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = French;
+ path = French.lproj/InfoPlist.strings.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F58D65DD018F798F01000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = French;
+ path = French.lproj/InfoPlist.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F58D65DE018F79A001000001 = {
+ fileEncoding = 10;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = French;
+ path = French.lproj/Localizable.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F58D65DF018F79B101000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = text.rtf;
+ name = French;
+ path = French.lproj/Credits.rtf;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F58D65E0018F79C001000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.html;
+ name = French;
+ path = French.lproj/XDarwinHelp.html;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F58D65E1018F79E001000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = French;
+ path = French.lproj/XDarwinHelp.html.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5A94EF10314BAC70100011B = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.c;
+ path = darwinEvents.c;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5ACD25CC5B5E96601000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = text.rtf;
+ name = Spanish;
+ path = Spanish.lproj/Credits.rtf;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5ACD25DC5B5E97701000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = Spanish;
+ path = Spanish.lproj/InfoPlist.strings.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5ACD25EC5B5E98D01000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.nib;
+ name = Spanish;
+ path = Spanish.lproj/MainMenu.nib;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5ACD25FC5B5E9AA01000001 = {
+ fileEncoding = 10;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = Spanish;
+ path = Spanish.lproj/Localizable.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5ACD260C5B5E9DF01000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = Spanish;
+ path = Spanish.lproj/XDarwinHelp.html.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5ACD261C5B5EA2001000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.html;
+ name = Spanish;
+ path = Spanish.lproj/XDarwinHelp.html;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5ACD262C5B5EA4D01000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = Spanish;
+ path = Spanish.lproj/InfoPlist.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5ACD263C5BE031F01000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = text.rtf;
+ name = ko;
+ path = ko.lproj/Credits.rtf;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5ACD264C5BE035B01000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = ko;
+ path = ko.lproj/InfoPlist.strings.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5ACD265C5BE038601000001 = {
+ isa = PBXFileReference;
+ lastKnownFileType = wrapper.nib;
+ name = ko;
+ path = ko.lproj/MainMenu.nib;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5ACD266C5BE03C501000001 = {
+ fileEncoding = 10;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = ko;
+ path = ko.lproj/Localizable.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5ACD267C5BE03FC01000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = ko;
+ path = ko.lproj/XDarwinHelp.html.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5ACD268C5BE046401000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.html;
+ name = ko;
+ path = ko.lproj/XDarwinHelp.html;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ F5ACD269C5BE049301000001 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = text.plist.strings;
+ name = ko;
+ path = ko.lproj/InfoPlist.strings;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ };
+ rootObject = 29B97313FDCFA39411CA2CEA;
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/XDarwinStartup.c b/nx-X11/programs/Xserver/hw/darwin/quartz/XDarwinStartup.c
new file mode 100644
index 000000000..0adb4c212
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/XDarwinStartup.c
@@ -0,0 +1,164 @@
+/**************************************************************
+ *
+ * Startup program for Darwin X servers
+ *
+ * This program selects the appropriate X server to launch:
+ * XDarwin IOKit X server (default)
+ * XDarwinQuartz A soft link to the Quartz X server
+ * executable (-quartz etc. option)
+ *
+ * If told to idle, the program will simply pause and not
+ * launch any X server. This is to support startx being
+ * run by XDarwin.app.
+ *
+ **************************************************************/
+/*
+ * Copyright (c) 2001-2002 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * TORREY T. LYONS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Torrey T. Lyons shall not
+ * be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from
+ * Torrey T. Lyons.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XDarwinStartup.c,v 1.1 2002/03/28 02:21:18 torrey Exp $ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/syslimits.h>
+#include <ApplicationServices/ApplicationServices.h>
+
+// Macros to build the path name
+#ifndef XBINDIR
+#define XBINDIR /usr/X11R6/bin
+#endif
+#define STR(s) #s
+#define XSTRPATH(s) STR(s) "/"
+#define XPATH(file) XSTRPATH(XBINDIR) STR(file)
+
+int main(
+ int argc,
+ char *argv[] )
+{
+ int i, j, quartzMode = -1;
+ char **newargv;
+
+ // Check if we are going to run in Quartz mode or idle
+ // to support startx from the Quartz server. The last
+ // parameter in the list is the one used.
+ for (i = argc-1; i; i--) {
+ if (!strcmp(argv[i], "-idle")) {
+ pause();
+ return 0;
+
+ } else if (!strcmp(argv[i], "-quartz") ||
+ !strcmp(argv[i], "-rootless") ||
+ !strcmp(argv[i], "-fullscreen"))
+ {
+ quartzMode = 1;
+ break;
+
+ } else if (!strcmp(argv[i], "-iokit")) {
+ quartzMode = 0;
+ break;
+ }
+ }
+
+ if (quartzMode == -1) {
+#ifdef HAS_CG_MACH_PORT
+ // Check if the CoreGraphics window server is running.
+ // Mike Paquette says this is the fastest way to determine if it is running.
+ CFMachPortRef cgMachPortRef = CGWindowServerCFMachPort();
+ if (cgMachPortRef == NULL)
+ quartzMode = 0;
+ else
+ quartzMode = 1;
+#else
+ // On older systems we assume IOKit mode.
+ quartzMode = 0;
+#endif
+ }
+
+ if (quartzMode) {
+ // Launch the X server for the quartz modes
+
+ char quartzPath[PATH_MAX+1];
+ int pathLength;
+ OSStatus theStatus;
+ CFURLRef appURL;
+ CFStringRef appPath;
+ Boolean success;
+
+ // Build the new argument list
+ newargv = (char **) malloc((argc+2) * sizeof(char *));
+ for (j = argc; j; j--)
+ newargv[j] = argv[j];
+ newargv[argc] = "-nostartx";
+ newargv[argc+1] = NULL;
+
+ // Use the XDarwinQuartz soft link if it is valid
+ pathLength = readlink(XPATH(XDarwinQuartz), quartzPath, PATH_MAX);
+ if (pathLength != -1) {
+ quartzPath[pathLength] = '\0';
+ newargv[0] = quartzPath;
+ execv(newargv[0], newargv);
+ }
+
+ // Otherwise query LaunchServices for the location of the XDarwin application
+ theStatus = LSFindApplicationForInfo(kLSUnknownCreator,
+ CFSTR("org.xfree86.XDarwin"),
+ NULL, NULL, &appURL);
+ if (theStatus) {
+ fprintf(stderr, "Could not find the XDarwin application. (Error = 0x%lx)\n", theStatus);
+ fprintf(stderr, "Launch XDarwin once from the Finder.\n");
+ return theStatus;
+ }
+
+ appPath = CFURLCopyFileSystemPath (appURL, kCFURLPOSIXPathStyle);
+ success = CFStringGetCString(appPath, quartzPath, PATH_MAX, CFStringGetSystemEncoding());
+ if (! success) {
+ fprintf(stderr, "Could not find path to XDarwin application.\n");
+ return success;
+ }
+
+ // Launch the XDarwin application
+ strncat(quartzPath, "/Contents/MacOS/XDarwin", PATH_MAX);
+ newargv[0] = quartzPath;
+ execv(newargv[0], newargv);
+ fprintf(stderr, "Could not start XDarwin application at %s.\n", newargv[0]);
+ return errno;
+
+ } else {
+
+ // Build the new argument list
+ newargv = (char **) malloc((argc+1) * sizeof(char *));
+ for (j = argc; j; j--)
+ newargv[j] = argv[j];
+ newargv[0] = "XDarwin";
+ newargv[argc] = NULL;
+
+ // Launch the IOKit X server
+ execvp(newargv[0], newargv);
+ fprintf(stderr, "Could not start XDarwin IOKit X server.\n");
+ return errno;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/XDarwinStartup.man b/nx-X11/programs/Xserver/hw/darwin/quartz/XDarwinStartup.man
new file mode 100644
index 000000000..28efd1edf
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/XDarwinStartup.man
@@ -0,0 +1,75 @@
+.\" $XFree86: xc/programs/Xserver/hw/darwin/bundle/XDarwinStartup.man,v 1.1 2002/02/05 19:16:14 torrey Exp $
+.TH XDarwinStartup 1
+.SH NAME
+XDarwinStartup - Startup program for the XDarwin X window server
+.SH SYNOPSIS
+.B XDarwinStartup
+[\fI-iokit\fP]
+[\fI-fullscreen\fP]
+[\fI-rootless\fP]
+[\fI-quartz\fP]
+[\fI-idle\fP]
+[\fIoptions\fP]
+.SH DESCRIPTION
+The \fIXDarwin(1)\fP X window server can be run in a variety of different
+modes and is actually two different executables. The IOKit X server,
+XDarwin, is used when running from the console. It is most commonly
+located in __XBinDir__. The Quartz X server, for running in parallel with
+Aqua, is a full-fledged Mac OS X application that can be started from
+the Finder. Its application bundle is XDarwin.app, which is typically
+located in /Applications.
+.I XDarwinStartup
+allows easy switching between these X servers and auto-detection of the
+appropriate one to use when launching from the command line.
+When run without any arguments,
+.I XDarwinStartup
+will start the Quartz X server if the Core Graphics window server
+is currently running. Otherwise it will start the IOKit X server.
+.PP
+To locate the Quartz X server,
+.I XDarwinStartup
+will try to read the soft link at __XBinDir__/XDarwinQuartz.
+This is typically a soft link to the executable of the XDarwin.app
+application. If this fails,
+.I XDarwinStartup
+will call Launch Services to locate XDarwin.app.
+.PP
+To start the IOKit X server,
+.I XDarwinStartup
+will run the XDarwin execuatable, which should be present in the
+user's path.
+.SH OPTIONS
+.I XDarwinStartup
+accepts and passes on all options to the X server it
+launches. In addition the following options have specific effects:
+.TP 8
+.B \-iokit
+Launch the IOKit X server.
+.TP 8
+.B \-fullscreen
+Launch the Quartz X server to run in full screen mode.
+.TP 8
+.B \-rootless
+Launch the Quartz X server to run in rootless mode.
+.TP 8
+.B \-quartz
+Launch the Quartz X server.
+.TP 8
+.B \-idle
+Pause and do nothing. This option is used by XDarwin.app when it is
+started from the Finder.
+.SH FILES
+.TP 30
+__XBinDir__/XDarwin
+IOKit mode X server
+.TP 30
+/Applications/XDarwin.app
+Quartz mode X server
+.TP 30
+__XBinDir__/XDarwinQuartz
+Soft link to Quartz mode X server executable
+.SH SEE ALSO
+XDarwin(1)
+.SH BUGS
+The path to XDarwinQuartz should not be hard coded.
+
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/XServer.h b/nx-X11/programs/Xserver/hw/darwin/quartz/XServer.h
new file mode 100644
index 000000000..8b45ffc55
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/XServer.h
@@ -0,0 +1,138 @@
+//
+// XServer.h
+//
+/*
+ * Copyright (c) 2001 Andreas Monitzer. All Rights Reserved.
+ * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ */
+/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.h,v 1.5 2005/07/01 22:43:07 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.h,v 1.16 2003/11/23 06:04:01 torrey Exp $ */
+
+#define BOOL xBOOL
+#include <X11/Xproto.h>
+#undef BOOL
+
+#import <Cocoa/Cocoa.h>
+
+@interface XServer : NSObject {
+ // Server state
+ int serverState;
+ NSRecursiveLock *serverLock;
+ NSMutableArray *pendingClients;
+ BOOL serverVisible;
+ BOOL rootlessMenuBarVisible;
+ BOOL queueShowServer;
+ BOOL quitWithoutQuery;
+ BOOL pendingAppQuitReply;
+ UInt32 mouseState;
+ unsigned short swallowedKey;
+ BOOL sendServerEvents;
+ BOOL x11Active;
+
+ // Aqua interface
+ IBOutlet NSWindow *modeWindow;
+ IBOutlet NSButton *startupModeButton;
+ IBOutlet NSButton *startFullScreenButton;
+ IBOutlet NSButton *startRootlessButton;
+ IBOutlet NSWindow *helpWindow;
+ IBOutlet NSButton *startupHelpButton;
+ IBOutlet NSPanel *switchWindow;
+
+ // Menu elements setable by Apple-WM extension
+ IBOutlet NSMenu *windowMenu;
+ IBOutlet NSMenuItem *windowSeparator;
+ IBOutlet NSMenu *dockMenu;
+ int checkedWindowItem;
+}
+
+- (id)init;
+
+- (BOOL)translateEvent:(NSEvent *)anEvent;
+- (BOOL)getMousePosition:(xEvent *)xe fromEvent:(NSEvent *)anEvent;
+
+- (NSString *)makeSafePath:(NSString *)path;
+
+- (BOOL)loadDisplayBundle;
+- (void)startX;
+- (void)finishStartX;
+- (BOOL)startXClients;
+- (void)runClient:(NSString *)filename;
+- (void)run;
+- (void)toggle;
+- (void)showServer:(BOOL)show;
+- (void)forceShowServer:(BOOL)show;
+- (void)setRootClip:(BOOL)enable;
+- (void)readPasteboard;
+- (void)writePasteboard;
+- (void)quitServer;
+- (void)sendXEvent:(xEvent *)xe;
+- (void)sendShowHide:(BOOL)show;
+- (void)clientProcessDone:(int)clientStatus;
+- (void)activateX11:(BOOL)state;
+- (void)windowBecameKey:(NSNotification *)notification;
+- (void)setX11WindowList:(NSArray *)list;
+- (void)setX11WindowCheck:(NSNumber *)nn;
+
+// Aqua interface actions
+- (IBAction)startFullScreen:(id)sender;
+- (IBAction)startRootless:(id)sender;
+- (IBAction)closeHelpAndShow:(id)sender;
+- (IBAction)showSwitchPanel:(id)sender;
+- (IBAction)showAction:(id)sender;
+- (IBAction)itemSelected:(id)sender;
+- (IBAction)nextWindow:(id)sender;
+- (IBAction)previousWindow:(id)sender;
+- (IBAction)performClose:(id)sender;
+- (IBAction)performMiniaturize:(id)sender;
+- (IBAction)performZoom:(id)sender;
+- (IBAction)bringAllToFront:(id)sender;
+- (IBAction)copy:(id)sender;
+
+// NSApplication delegate
+- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
+- (void)applicationWillTerminate:(NSNotification *)aNotification;
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
+- (void)applicationDidHide:(NSNotification *)aNotification;
+- (void)applicationDidUnhide:(NSNotification *)aNotification;
+- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag;
+- (void)applicationWillResignActive:(NSNotification *)aNotification;
+- (void)applicationWillBecomeActive:(NSNotification *)aNotification;
+- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename;
+
+// NSPort delegate
+- (void)handlePortMessage:(NSPortMessage *)portMessage;
+
+@end
+
+// X server states
+enum {
+ server_NotStarted,
+ server_Starting,
+ server_Running,
+ server_Quitting,
+ server_Done
+};
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/XServer.m b/nx-X11/programs/Xserver/hw/darwin/quartz/XServer.m
new file mode 100644
index 000000000..613c9c830
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/XServer.m
@@ -0,0 +1,1539 @@
+//
+// XServer.m
+//
+// This class handles the interaction between the Cocoa front-end
+// and the Darwin X server thread.
+//
+// Created by Andreas Monitzer on January 6, 2001.
+//
+/*
+ * Copyright (c) 2001 Andreas Monitzer. All Rights Reserved.
+ * Copyright (c) 2002-2005 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ */
+/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.4 2005/04/02 02:29:24 torrey Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.19 2003/11/24 05:39:01 torrey Exp $ */
+
+#include "quartzCommon.h"
+
+#define BOOL xBOOL
+#include "X.h"
+#include "Xproto.h"
+#include "os.h"
+#include "opaque.h"
+#include "darwin.h"
+#include "quartz.h"
+#define _APPLEWM_SERVER_
+#include "applewm.h"
+#include "applewmExt.h"
+#undef BOOL
+
+#import "XServer.h"
+#import "Preferences.h"
+
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/syslimits.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <pwd.h>
+#include <signal.h>
+#include <fcntl.h>
+
+// For power management notifications
+#import <mach/mach_port.h>
+#import <mach/mach_interface.h>
+#import <mach/mach_init.h>
+#import <IOKit/pwr_mgt/IOPMLib.h>
+#import <IOKit/IOMessage.h>
+
+// Types of shells
+enum {
+ shell_Unknown,
+ shell_Bourne,
+ shell_C
+};
+
+typedef struct {
+ char *name;
+ int type;
+} shellList_t;
+
+static shellList_t const shellList[] = {
+ { "csh", shell_C }, // standard C shell
+ { "tcsh", shell_C }, // ... needs no introduction
+ { "sh", shell_Bourne }, // standard Bourne shell
+ { "zsh", shell_Bourne }, // Z shell
+ { "bash", shell_Bourne }, // GNU Bourne again shell
+ { NULL, shell_Unknown }
+};
+
+extern int argcGlobal;
+extern char **argvGlobal;
+extern char **envpGlobal;
+extern int main(int argc, char *argv[], char *envp[]);
+extern void HideMenuBar(void);
+extern void ShowMenuBar(void);
+static void childDone(int sig);
+static void powerDidChange(void *x, io_service_t y, natural_t messageType,
+ void *messageArgument);
+
+static NSPort *signalPort;
+static NSPort *returnPort;
+static NSPortMessage *signalMessage;
+static pid_t clientPID;
+static XServer *oneXServer;
+static NSRect aquaMenuBarBox;
+static io_connect_t root_port;
+
+
+@implementation XServer
+
+- (id)init
+{
+ self = [super init];
+ oneXServer = self;
+
+ serverState = server_NotStarted;
+ serverLock = [[NSRecursiveLock alloc] init];
+ pendingClients = nil;
+ clientPID = 0;
+ sendServerEvents = NO;
+ x11Active = YES;
+ serverVisible = NO;
+ rootlessMenuBarVisible = YES;
+ queueShowServer = YES;
+ quartzServerQuitting = NO;
+ pendingAppQuitReply = NO;
+ mouseState = 0;
+
+ // set up a port to safely send messages to main thread from server thread
+ signalPort = [[NSPort port] retain];
+ returnPort = [[NSPort port] retain];
+ signalMessage = [[NSPortMessage alloc] initWithSendPort:signalPort
+ receivePort:returnPort components:nil];
+
+ // set up receiving end
+ [signalPort setDelegate:self];
+ [[NSRunLoop currentRunLoop] addPort:signalPort
+ forMode:NSDefaultRunLoopMode];
+ [[NSRunLoop currentRunLoop] addPort:signalPort
+ forMode:NSModalPanelRunLoopMode];
+
+ return self;
+}
+
+- (NSApplicationTerminateReply)
+ applicationShouldTerminate:(NSApplication *)sender
+{
+ // Quit if the X server is not running
+ if ([serverLock tryLock]) {
+ quartzServerQuitting = YES;
+ serverState = server_Done;
+ if (clientPID != 0)
+ kill(clientPID, SIGINT);
+ return NSTerminateNow;
+ }
+
+ // Hide the X server and stop sending it events
+ [self showServer:NO];
+ sendServerEvents = NO;
+
+ if (!quitWithoutQuery && (clientPID != 0 || !quartzStartClients)) {
+ int but;
+
+ but = NSRunAlertPanel(NSLocalizedString(@"Quit X server?",@""),
+ NSLocalizedString(@"Quitting the X server will terminate any running X Window System programs.",@""),
+ NSLocalizedString(@"Quit",@""),
+ NSLocalizedString(@"Cancel",@""),
+ nil);
+
+ switch (but) {
+ case NSAlertDefaultReturn: // quit
+ break;
+ case NSAlertAlternateReturn: // cancel
+ if (serverState == server_Running)
+ sendServerEvents = YES;
+ return NSTerminateCancel;
+ }
+ }
+
+ quartzServerQuitting = YES;
+ if (clientPID != 0)
+ kill(clientPID, SIGINT);
+
+ // At this point the X server is either running or starting.
+ if (serverState == server_Starting) {
+ // Quit will be queued later when server is running
+ pendingAppQuitReply = YES;
+ return NSTerminateLater;
+ } else if (serverState == server_Running) {
+ [self quitServer];
+ }
+
+ return NSTerminateNow;
+}
+
+// Ensure that everything has quit cleanly
+- (void)applicationWillTerminate:(NSNotification *)aNotification
+{
+ // Make sure the client process has finished
+ if (clientPID != 0) {
+ NSLog(@"Waiting on client process...");
+ sleep(2);
+
+ // If the client process hasn't finished yet, kill it off
+ if (clientPID != 0) {
+ int clientStatus;
+ NSLog(@"Killing client process...");
+ killpg(clientPID, SIGKILL);
+ waitpid(clientPID, &clientStatus, 0);
+ }
+ }
+
+ // Wait until the X server thread quits
+ [serverLock lock];
+}
+
+// returns YES when event was handled
+- (BOOL)translateEvent:(NSEvent *)anEvent
+{
+ xEvent xe;
+ static BOOL mouse1Pressed = NO;
+ NSEventType type;
+ unsigned int flags;
+
+ if (!sendServerEvents) {
+ return NO;
+ }
+
+ type = [anEvent type];
+ flags = [anEvent modifierFlags];
+
+ if (!quartzRootless) {
+ // Check for switch keypress
+ if ((type == NSKeyDown) && (![anEvent isARepeat]) &&
+ ([anEvent keyCode] == [Preferences keyCode]))
+ {
+ unsigned int switchFlags = [Preferences modifiers];
+
+ // Switch if all the switch modifiers are pressed, while none are
+ // pressed that should not be, except for caps lock.
+ if (((flags & switchFlags) == switchFlags) &&
+ ((flags & ~(switchFlags | NSAlphaShiftKeyMask)) == 0))
+ {
+ [self toggle];
+ return YES;
+ }
+ }
+
+ if (!serverVisible)
+ return NO;
+ }
+
+ memset(&xe, 0, sizeof(xe));
+
+ switch (type) {
+ case NSLeftMouseUp:
+ if (quartzRootless && !mouse1Pressed) {
+ // MouseUp after MouseDown in menu - ignore
+ return NO;
+ }
+ mouse1Pressed = NO;
+ [self getMousePosition:&xe fromEvent:anEvent];
+ xe.u.u.type = ButtonRelease;
+ xe.u.u.detail = 1;
+ break;
+
+ case NSLeftMouseDown:
+ if (quartzRootless) {
+ // Check that event is in X11 window
+ if (!quartzProcs->IsX11Window([anEvent window],
+ [anEvent windowNumber]))
+ {
+ if (x11Active)
+ [self activateX11:NO];
+ return NO;
+ } else {
+ if (!x11Active)
+ [self activateX11:YES];
+ }
+ }
+ mouse1Pressed = YES;
+ [self getMousePosition:&xe fromEvent:anEvent];
+ xe.u.u.type = ButtonPress;
+ xe.u.u.detail = 1;
+ break;
+
+ case NSRightMouseUp:
+ [self getMousePosition:&xe fromEvent:anEvent];
+ xe.u.u.type = ButtonRelease;
+ xe.u.u.detail = 3;
+ break;
+
+ case NSRightMouseDown:
+ [self getMousePosition:&xe fromEvent:anEvent];
+ xe.u.u.type = ButtonPress;
+ xe.u.u.detail = 3;
+ break;
+
+ case NSOtherMouseUp:
+ {
+ int hwButton = [anEvent buttonNumber];
+
+ [self getMousePosition:&xe fromEvent:anEvent];
+ xe.u.u.type = ButtonRelease;
+ xe.u.u.detail = (hwButton == 2) ? hwButton : hwButton + 1;
+ break;
+ }
+
+ case NSOtherMouseDown:
+ {
+ int hwButton = [anEvent buttonNumber];
+
+ [self getMousePosition:&xe fromEvent:anEvent];
+ xe.u.u.type = ButtonPress;
+ xe.u.u.detail = (hwButton == 2) ? hwButton : hwButton + 1;
+ break;
+ }
+
+ case NSMouseMoved:
+ case NSLeftMouseDragged:
+ case NSRightMouseDragged:
+ case NSOtherMouseDragged:
+ [self getMousePosition:&xe fromEvent:anEvent];
+ xe.u.u.type = MotionNotify;
+ break;
+
+ case NSScrollWheel:
+ [self getMousePosition:&xe fromEvent:anEvent];
+ xe.u.u.type = kXDarwinScrollWheel;
+ xe.u.clientMessage.u.s.shorts0 = [anEvent deltaX] +
+ [anEvent deltaY];
+ break;
+
+ case NSKeyDown:
+ case NSKeyUp:
+ if (!x11Active) {
+ swallowedKey = 0;
+ return NO;
+ }
+
+ if (type == NSKeyDown) {
+ // If the mouse is not on the valid X display area,
+ // don't send the X server key events.
+ if (![self getMousePosition:&xe fromEvent:nil]) {
+ swallowedKey = [anEvent keyCode];
+ return NO;
+ }
+
+ // See if there are any global shortcuts for this key combo.
+ if (quartzEnableKeyEquivalents
+ && [[NSApp mainMenu] performKeyEquivalent:anEvent])
+ {
+ swallowedKey = [anEvent keyCode];
+ return YES;
+ }
+ } else {
+ // If the down key event was a valid key combo,
+ // don't pass the up event to X11.
+ if (swallowedKey != 0 && [anEvent keyCode] == swallowedKey) {
+ swallowedKey = 0;
+ return NO;
+ }
+ }
+
+ xe.u.u.type = (type == NSKeyDown) ? KeyPress : KeyRelease;
+ xe.u.u.detail = [anEvent keyCode];
+ break;
+
+ case NSFlagsChanged:
+ if (!x11Active)
+ return NO;
+ xe.u.u.type = kXDarwinUpdateModifiers;
+ xe.u.clientMessage.u.l.longs0 = flags;
+ break;
+
+ default:
+ return NO;
+ }
+
+ [self sendXEvent:&xe];
+
+ // Rootless: Send first NSLeftMouseDown to Cocoa windows and views so
+ // window ordering can be suppressed.
+ // Don't pass further events - they (incorrectly?) bring the window
+ // forward no matter what.
+ if (quartzRootless &&
+ (type == NSLeftMouseDown || type == NSLeftMouseUp) &&
+ [anEvent clickCount] == 1 && [anEvent window])
+ {
+ return NO;
+ }
+
+ return YES;
+}
+
+// Return mouse coordinates, inverting y coordinate.
+// The coordinates are extracted from an event or the current mouse position.
+// For rootless mode, the menu bar is treated as not part of the usable
+// X display area and the cursor position is adjusted accordingly.
+// Returns YES if the cursor is not in the menu bar.
+- (BOOL)getMousePosition:(xEvent *)xe fromEvent:(NSEvent *)anEvent
+{
+ NSPoint pt;
+
+ if (anEvent) {
+ NSWindow *eventWindow = [anEvent window];
+
+ if (eventWindow) {
+ pt = [anEvent locationInWindow];
+ pt.x += [eventWindow frame].origin.x;
+ pt.y += [eventWindow frame].origin.y;
+ } else {
+ pt = [NSEvent mouseLocation];
+ }
+ } else {
+ pt = [NSEvent mouseLocation];
+ }
+
+ xe->u.keyButtonPointer.rootX = (int)(pt.x);
+
+ if (quartzRootless && NSMouseInRect(pt, aquaMenuBarBox, NO)) {
+ // mouse in menu bar - tell X11 that it's just below instead
+ xe->u.keyButtonPointer.rootY = aquaMenuBarHeight;
+ return NO;
+ } else {
+ xe->u.keyButtonPointer.rootY =
+ NSHeight([[NSScreen mainScreen] frame]) - (int)(pt.y);
+ return YES;
+ }
+}
+
+
+// Make a safe path
+//
+// Return the path in single quotes in case there are problematic characters in it.
+// We still have to worry about there being single quotes in the path. So, replace
+// all instances of the ' character in the path with '\''.
+- (NSString *)makeSafePath:(NSString *)path
+{
+ NSMutableString *safePath = [NSMutableString stringWithString:path];
+ NSRange aRange = NSMakeRange(0, [safePath length]);
+
+ while (aRange.length) {
+ aRange = [safePath rangeOfString:@"'" options:0 range:aRange];
+ if (!aRange.length)
+ break;
+ [safePath replaceCharactersInRange:aRange
+ withString:@"\'\\'\'"];
+ aRange.location += 4;
+ aRange.length = [safePath length] - aRange.location;
+ }
+
+ safePath = [NSMutableString stringWithFormat:@"'%@'", safePath];
+
+ return safePath;
+}
+
+
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
+{
+ // Block SIGPIPE
+ // SIGPIPE repeatably killed the (rootless) server when closing a
+ // dozen xterms in rapid succession. Those SIGPIPEs should have been
+ // sent to the X server thread, which ignores them, but somehow they
+ // ended up in this thread instead.
+ {
+ sigset_t set;
+ sigemptyset(&set);
+ sigaddset(&set, SIGPIPE);
+ // pthread_sigmask not implemented yet
+ // pthread_sigmask(SIG_BLOCK, &set, NULL);
+ sigprocmask(SIG_BLOCK, &set, NULL);
+ }
+
+ if (quartzRootless == -1) {
+ // The display mode was not set from the command line.
+ // Show mode pick panel?
+ if ([Preferences modeWindow]) {
+ if ([Preferences rootless])
+ [startRootlessButton setKeyEquivalent:@"\r"];
+ else
+ [startFullScreenButton setKeyEquivalent:@"\r"];
+ [modeWindow makeKeyAndOrderFront:nil];
+ } else {
+ // Otherwise use default mode
+ quartzRootless = [Preferences rootless];
+ [self startX];
+ }
+ } else {
+ [self startX];
+ }
+}
+
+
+// Load the appropriate display mode bundle
+- (BOOL)loadDisplayBundle
+{
+ if (quartzRootless) {
+ NSEnumerator *enumerator = [[Preferences displayModeBundles]
+ objectEnumerator];
+ NSString *bundleName;
+
+ while ((bundleName = [enumerator nextObject])) {
+ if (QuartzLoadDisplayBundle([bundleName cString]))
+ return YES;
+ }
+
+ return NO;
+ } else {
+ return QuartzLoadDisplayBundle("fullscreen.bundle");
+ }
+}
+
+
+// Start the X server thread and the client process
+- (void)startX
+{
+ NSDictionary *appDictionary;
+ NSString *appVersion;
+
+ [modeWindow close];
+
+ // Calculate the height of the menu bar so rootless mode can avoid it
+ if (quartzRootless) {
+ aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
+ NSMaxY([[NSScreen mainScreen] visibleFrame]) - 1;
+ aquaMenuBarBox =
+ NSMakeRect(0, NSMaxY([[NSScreen mainScreen] visibleFrame]) + 1,
+ NSWidth([[NSScreen mainScreen] frame]),
+ aquaMenuBarHeight);
+ }
+
+ // Write the XDarwin version to the console log
+ appDictionary = [[NSBundle mainBundle] infoDictionary];
+ appVersion = [appDictionary objectForKey:@"CFBundleShortVersionString"];
+ if (appVersion)
+ NSLog(@"\n%@", appVersion);
+ else
+ NSLog(@"No version");
+
+ if (![self loadDisplayBundle])
+ [NSApp terminate:nil];
+
+ if (quartzRootless) {
+ // We need to track whether the key window is an X11 window
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(windowBecameKey:)
+ name:NSWindowDidBecomeKeyNotification
+ object:nil];
+
+ // Request notification of screen layout changes even when this
+ // is not the active application
+ [[NSDistributedNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(applicationDidChangeScreenParameters:)
+ name:NSApplicationDidChangeScreenParametersNotification
+ object:nil];
+ }
+
+ // Start the X server thread
+ serverState = server_Starting;
+ [NSThread detachNewThreadSelector:@selector(run) toTarget:self
+ withObject:nil];
+
+ // Start the X clients if started from GUI
+ if (quartzStartClients) {
+ [self startXClients];
+ }
+
+ if (quartzRootless) {
+ // There is no help window for rootless; just start
+ [helpWindow close];
+ helpWindow = nil;
+ } else {
+ IONotificationPortRef notify;
+ io_object_t anIterator;
+
+ // Register for system power notifications
+ root_port = IORegisterForSystemPower(0, &notify, powerDidChange,
+ &anIterator);
+ if (root_port) {
+ CFRunLoopAddSource([[NSRunLoop currentRunLoop] getCFRunLoop],
+ IONotificationPortGetRunLoopSource(notify),
+ kCFRunLoopDefaultMode);
+ } else {
+ NSLog(@"Failed to register for system power notifications.");
+ }
+
+ // Show the X switch window if not using dock icon switching
+ if (![Preferences dockSwitch])
+ [switchWindow orderFront:nil];
+
+ if ([Preferences startupHelp]) {
+ // display the full screen mode help
+ [helpWindow makeKeyAndOrderFront:nil];
+ queueShowServer = NO;
+ } else {
+ // start running full screen and make sure X is visible
+ ShowMenuBar();
+ [self closeHelpAndShow:nil];
+ }
+ }
+}
+
+// Finish starting the X server thread
+// This includes anything that must be done after the X server is
+// ready to process events after the first or subsequent generations.
+- (void)finishStartX
+{
+ sendServerEvents = YES;
+ serverState = server_Running;
+
+ if (quartzRootless) {
+ [self forceShowServer:[NSApp isActive]];
+ } else {
+ [self forceShowServer:queueShowServer];
+ }
+
+ if (quartzServerQuitting) {
+ [self quitServer];
+ if (pendingAppQuitReply)
+ [NSApp replyToApplicationShouldTerminate:YES];
+ return;
+ }
+
+ if (pendingClients) {
+ NSEnumerator *enumerator = [pendingClients objectEnumerator];
+ NSString *filename;
+
+ while ((filename = [enumerator nextObject])) {
+ [self runClient:filename];
+ }
+
+ [pendingClients release];
+ pendingClients = nil;
+ }
+}
+
+// Start the first X clients in a separate process
+- (BOOL)startXClients
+{
+ struct passwd *passwdUser;
+ NSString *shellPath, *dashShellName, *commandStr, *startXPath;
+ NSString *safeStartXPath;
+ NSBundle *thisBundle;
+ const char *shellPathStr, *newargv[3], *shellNameStr;
+ int fd[2], outFD, length, shellType, i;
+
+ // Register to catch the signal when the client processs finishes
+ signal(SIGCHLD, childDone);
+
+ // Get user's password database entry
+ passwdUser = getpwuid(getuid());
+
+ // Find the shell to use
+ if ([Preferences useDefaultShell])
+ shellPath = [NSString stringWithCString:passwdUser->pw_shell];
+ else
+ shellPath = [Preferences shellString];
+
+ dashShellName = [NSString stringWithFormat:@"-%@",
+ [shellPath lastPathComponent]];
+ shellPathStr = [shellPath cString];
+ shellNameStr = [[shellPath lastPathComponent] cString];
+
+ if (access(shellPathStr, X_OK)) {
+ NSLog(@"Shell %s is not valid!", shellPathStr);
+ return NO;
+ }
+
+ // Find the type of shell
+ for (i = 0; shellList[i].name; i++) {
+ if (!strcmp(shellNameStr, shellList[i].name))
+ break;
+ }
+ shellType = shellList[i].type;
+
+ newargv[0] = [dashShellName cString];
+ if (shellType == shell_Bourne) {
+ // Bourne shells need to be told they are interactive to make
+ // sure they read all their initialization files.
+ newargv[1] = "-i";
+ newargv[2] = NULL;
+ } else {
+ newargv[1] = NULL;
+ }
+
+ // Create a pipe to communicate with the X client process
+ NSAssert(pipe(fd) == 0, @"Could not create new pipe.");
+
+ // Open a file descriptor for writing to stdout and stderr
+ outFD = open("/dev/console", O_WRONLY, 0);
+ if (outFD == -1) {
+ outFD = open("/dev/null", O_WRONLY, 0);
+ NSAssert(outFD != -1, @"Could not open shell output.");
+ }
+
+ // Fork process to start X clients in user's default shell
+ // Sadly we can't use NSTask because we need to start a login shell.
+ // Login shells are started by passing "-" as the first character of
+ // argument 0. NSTask forces argument 0 to be the shell's name.
+ clientPID = vfork();
+ if (clientPID == 0) {
+
+ // Inside the new process:
+ if (fd[0] != STDIN_FILENO) {
+ dup2(fd[0], STDIN_FILENO); // Take stdin from pipe
+ close(fd[0]);
+ }
+ close(fd[1]); // Close write end of pipe
+ if (outFD == STDOUT_FILENO) { // Setup stdout and stderr
+ dup2(outFD, STDERR_FILENO);
+ } else if (outFD == STDERR_FILENO) {
+ dup2(outFD, STDOUT_FILENO);
+ } else {
+ dup2(outFD, STDERR_FILENO);
+ dup2(outFD, STDOUT_FILENO);
+ close(outFD);
+ }
+
+ // Setup environment
+ setenv("HOME", passwdUser->pw_dir, 1);
+ setenv("SHELL", shellPathStr, 1);
+ setenv("LOGNAME", passwdUser->pw_name, 1);
+ setenv("USER", passwdUser->pw_name, 1);
+ setenv("TERM", "unknown", 1);
+ if (chdir(passwdUser->pw_dir)) // Change to user's home dir
+ NSLog(@"Could not change to user's home directory.");
+
+ execv(shellPathStr, (char * const *)newargv); // Start user's shell
+
+ NSLog(@"Could not start X client process with errno = %i.", errno);
+ _exit(127);
+ }
+
+ // In parent process:
+ close(fd[0]); // Close read end of pipe
+ close(outFD); // Close output file descriptor
+
+ thisBundle = [NSBundle bundleForClass:[self class]];
+ startXPath = [thisBundle pathForResource:@"startXClients" ofType:nil];
+ if (!startXPath) {
+ NSLog(@"Could not find startXClients in application bundle!");
+ return NO;
+ }
+
+ safeStartXPath = [self makeSafePath:startXPath];
+
+ if ([Preferences addToPath]) {
+ commandStr = [NSString stringWithFormat:@"%@ :%d %@\n",
+ safeStartXPath, [Preferences display],
+ [Preferences addToPathString]];
+ } else {
+ commandStr = [NSString stringWithFormat:@"%@ :%d\n",
+ safeStartXPath, [Preferences display]];
+ }
+
+ length = [commandStr cStringLength];
+ if (write(fd[1], [commandStr cString], length) != length) {
+ NSLog(@"Write to X client process failed.");
+ return NO;
+ }
+
+ // Close the pipe so that shell will terminate when xinit quits
+ close(fd[1]);
+
+ return YES;
+}
+
+// Start the specified client in its own task
+// FIXME: This should be unified with startXClients
+- (void)runClient:(NSString *)filename
+{
+ const char *command = [[self makeSafePath:filename] UTF8String];
+ const char *shell;
+ const char *argv[5];
+ int child1, child2 = 0;
+ int status;
+
+ shell = getenv("SHELL");
+ if (shell == NULL)
+ shell = "/bin/bash";
+
+ /* At least [ba]sh, [t]csh and zsh all work with this syntax. We
+ need to use an interactive shell to force it to load the user's
+ environment. */
+
+ argv[0] = shell;
+ argv[1] = "-i";
+ argv[2] = "-c";
+ argv[3] = command;
+ argv[4] = NULL;
+
+ /* Do the fork-twice trick to avoid having to reap zombies */
+
+ child1 = fork();
+
+ switch (child1) {
+ case -1: /* error */
+ break;
+
+ case 0: /* child1 */
+ child2 = fork();
+
+ switch (child2) {
+ int max_files, i;
+ char buf[1024], *tem;
+
+ case -1: /* error */
+ _exit(1);
+
+ case 0: /* child2 */
+ /* close all open files except for standard streams */
+ max_files = sysconf(_SC_OPEN_MAX);
+ for (i = 3; i < max_files; i++)
+ close(i);
+
+ /* ensure stdin is on /dev/null */
+ close(0);
+ open("/dev/null", O_RDONLY);
+
+ /* cd $HOME */
+ tem = getenv("HOME");
+ if (tem != NULL)
+ chdir(tem);
+
+ /* Setup environment */
+ snprintf(buf, sizeof(buf), ":%s", display);
+ setenv("DISPLAY", buf, TRUE);
+ tem = getenv("PATH");
+ if (tem != NULL && tem[0] != NULL)
+ snprintf(buf, sizeof(buf), "%s:/usr/X11R6/bin", tem);
+ else
+ snprintf(buf, sizeof(buf), "/bin:/usr/bin:/usr/X11R6/bin");
+ setenv("PATH", buf, TRUE);
+
+ execvp(argv[0], (char **const) argv);
+
+ _exit(2);
+
+ default: /* parent (child1) */
+ _exit(0);
+ }
+ break;
+
+ default: /* parent */
+ waitpid(child1, &status, 0);
+ }
+}
+
+// Run the X server thread
+- (void)run
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ [serverLock lock];
+ main(argcGlobal, argvGlobal, envpGlobal);
+ serverVisible = NO;
+ [pool release];
+ [serverLock unlock];
+ QuartzMessageMainThread(kQuartzServerDied, nil, 0);
+}
+
+// Full screen mode was picked in the mode pick panel
+- (IBAction)startFullScreen:(id)sender
+{
+ [Preferences setModeWindow:[startupModeButton intValue]];
+ [Preferences saveToDisk];
+ quartzRootless = FALSE;
+ [self startX];
+}
+
+// Rootless mode was picked in the mode pick panel
+- (IBAction)startRootless:(id)sender
+{
+ [Preferences setModeWindow:[startupModeButton intValue]];
+ [Preferences saveToDisk];
+ quartzRootless = TRUE;
+ [self startX];
+}
+
+// Close the help splash screen and show the X server
+- (IBAction)closeHelpAndShow:(id)sender
+{
+ if (sender) {
+ int helpVal = [startupHelpButton intValue];
+ [Preferences setStartupHelp:helpVal];
+ [Preferences saveToDisk];
+ }
+ [helpWindow close];
+ helpWindow = nil;
+
+ [self forceShowServer:YES];
+ [NSApp activateIgnoringOtherApps:YES];
+}
+
+// Show the Aqua-X11 switch panel useful for fullscreen mode
+- (IBAction)showSwitchPanel:(id)sender
+{
+ [switchWindow orderFront:nil];
+}
+
+// Show the X server when sent message from GUI
+- (IBAction)showAction:(id)sender
+{
+ [self forceShowServer:YES];
+}
+
+// Show or hide the X server or menu bar in rootless mode
+- (void)toggle
+{
+ if (quartzRootless) {
+#if 0
+ // FIXME: Remove or add option to not dodge menubar
+ if (rootlessMenuBarVisible)
+ HideMenuBar();
+ else
+ ShowMenuBar();
+ rootlessMenuBarVisible = !rootlessMenuBarVisible;
+#endif
+ } else {
+ [self showServer:!serverVisible];
+ }
+}
+
+// Show or hide the X server on screen
+- (void)showServer:(BOOL)show
+{
+ // Do not show or hide multiple times in a row
+ if (serverVisible == show)
+ return;
+
+ if (sendServerEvents) {
+ [self sendShowHide:show];
+ } else if (serverState == server_Starting) {
+ queueShowServer = show;
+ }
+}
+
+// Show or hide the X server irregardless of the current state
+- (void)forceShowServer:(BOOL)show
+{
+ serverVisible = !show;
+ [self showServer:show];
+}
+
+// Tell the X server to show or hide itself.
+// This ignores the current X server visible state.
+//
+// In full screen mode, the order we do things is important and must be
+// preserved between the threads. X drawing operations have to be performed
+// in the X server thread. It appears that we have the additional
+// constraint that we must hide and show the menu bar in the main thread.
+//
+// To show the X server:
+// 1. Capture the displays. (Main thread)
+// 2. Hide the menu bar. (Must be in main thread)
+// 3. Send event to X server thread to redraw X screen.
+// 4. Redraw the X screen. (Must be in X server thread)
+//
+// To hide the X server:
+// 1. Send event to X server thread to stop drawing.
+// 2. Stop drawing to the X screen. (Must be in X server thread)
+// 3. Message main thread that drawing is stopped.
+// 4. If main thread still wants X server hidden:
+// a. Release the displays. (Main thread)
+// b. Unhide the menu bar. (Must be in main thread)
+// Otherwise we have already queued an event to start drawing again.
+//
+- (void)sendShowHide:(BOOL)show
+{
+ xEvent xe;
+
+ [self getMousePosition:&xe fromEvent:nil];
+
+ if (show) {
+ if (!quartzRootless) {
+ quartzProcs->CaptureScreens();
+ HideMenuBar();
+ }
+ [self activateX11:YES];
+
+ // the mouse location will have moved; track it
+ xe.u.u.type = MotionNotify;
+ [self sendXEvent:&xe];
+
+ // inform the X server of the current modifier state
+ xe.u.u.type = kXDarwinUpdateModifiers;
+ xe.u.clientMessage.u.l.longs0 = [[NSApp currentEvent] modifierFlags];
+ [self sendXEvent:&xe];
+
+ // If there is no AppleWM-aware cut and paste manager, do what we can.
+ if ((AppleWMSelectedEvents() & AppleWMPasteboardNotifyMask) == 0) {
+ // put the pasteboard into the X cut buffer
+ [self readPasteboard];
+ }
+ } else {
+ // If there is no AppleWM-aware cut and paste manager, do what we can.
+ if ((AppleWMSelectedEvents() & AppleWMPasteboardNotifyMask) == 0) {
+ // put the X cut buffer on the pasteboard
+ [self writePasteboard];
+ }
+
+ [self activateX11:NO];
+ }
+
+ serverVisible = show;
+}
+
+// Enable or disable rendering to the X screen
+- (void)setRootClip:(BOOL)enable
+{
+ xEvent xe;
+
+ xe.u.u.type = kXDarwinSetRootClip;
+ xe.u.clientMessage.u.l.longs0 = enable;
+ [self sendXEvent:&xe];
+}
+
+// Tell the X server to read from the pasteboard into the X cut buffer
+- (void)readPasteboard
+{
+ xEvent xe;
+
+ xe.u.u.type = kXDarwinReadPasteboard;
+ [self sendXEvent:&xe];
+}
+
+// Tell the X server to write the X cut buffer into the pasteboard
+- (void)writePasteboard
+{
+ xEvent xe;
+
+ xe.u.u.type = kXDarwinWritePasteboard;
+ [self sendXEvent:&xe];
+}
+
+- (void)quitServer
+{
+ xEvent xe;
+
+ xe.u.u.type = kXDarwinQuit;
+ [self sendXEvent:&xe];
+
+ // Revert to the Mac OS X arrow cursor. The main thread sets the cursor
+ // and it won't be responding to future requests to change it.
+ [[NSCursor arrowCursor] set];
+
+ serverState = server_Quitting;
+}
+
+- (void)sendXEvent:(xEvent *)xe
+{
+ // This field should be filled in for every event
+ xe->u.keyButtonPointer.time = GetTimeInMillis();
+
+ DarwinEQEnqueue(xe);
+}
+
+// Handle messages from the X server thread
+- (void)handlePortMessage:(NSPortMessage *)portMessage
+{
+ unsigned msg = [portMessage msgid];
+
+ switch (msg) {
+ case kQuartzServerHidden:
+ // Make sure the X server wasn't queued to be shown again while
+ // the hide was pending.
+ if (!quartzRootless && !serverVisible) {
+ quartzProcs->ReleaseScreens();
+ ShowMenuBar();
+ }
+ break;
+
+ case kQuartzServerStarted:
+ [self finishStartX];
+ break;
+
+ case kQuartzServerDied:
+ sendServerEvents = NO;
+ serverState = server_Done;
+ if (!quartzServerQuitting) {
+ [NSApp terminate:nil]; // quit if we aren't already
+ }
+ break;
+
+ case kQuartzCursorUpdate:
+ if (quartzProcs->CursorUpdate)
+ quartzProcs->CursorUpdate();
+ break;
+
+ case kQuartzPostEvent:
+ {
+ const xEvent *xe = [[[portMessage components] lastObject] bytes];
+ DarwinEQEnqueue(xe);
+ break;
+ }
+
+ case kQuartzSetWindowMenu:
+ {
+ NSArray *list;
+ [[[portMessage components] lastObject] getBytes:&list];
+ [self setX11WindowList:list];
+ [list release];
+ break;
+ }
+
+ case kQuartzSetWindowMenuCheck:
+ {
+ int n;
+ [[[portMessage components] lastObject] getBytes:&n];
+ [self setX11WindowCheck:[NSNumber numberWithInt:n]];
+ break;
+ }
+
+ case kQuartzSetFrontProcess:
+ [NSApp activateIgnoringOtherApps:YES];
+ break;
+
+ case kQuartzSetCanQuit:
+ {
+ int n;
+ [[[portMessage components] lastObject] getBytes:&n];
+ quitWithoutQuery = (BOOL) n;
+ break;
+ }
+
+ default:
+ NSLog(@"Unknown message from server thread.");
+ }
+}
+
+// Quit the X server when the X client process finishes
+- (void)clientProcessDone:(int)clientStatus
+{
+ if (WIFEXITED(clientStatus)) {
+ int exitStatus = WEXITSTATUS(clientStatus);
+ if (exitStatus != 0)
+ NSLog(@"X client process terminated with status %i.", exitStatus);
+ } else {
+ NSLog(@"X client process terminated abnormally.");
+ }
+
+ if (!quartzServerQuitting) {
+ [NSApp terminate:nil]; // quit if we aren't already
+ }
+}
+
+// User selected an X11 window from a menu
+- (IBAction)itemSelected:(id)sender
+{
+ xEvent xe;
+
+ [NSApp activateIgnoringOtherApps:YES];
+
+ // Notify the client of the change through the X server thread
+ xe.u.u.type = kXDarwinControllerNotify;
+ xe.u.clientMessage.u.l.longs0 = AppleWMWindowMenuItem;
+ xe.u.clientMessage.u.l.longs1 = [sender tag];
+ [self sendXEvent:&xe];
+}
+
+// User selected Next from window menu
+- (IBAction)nextWindow:(id)sender
+{
+ QuartzMessageServerThread(kXDarwinControllerNotify, 1,
+ AppleWMNextWindow);
+}
+
+// User selected Previous from window menu
+- (IBAction)previousWindow:(id)sender
+{
+ QuartzMessageServerThread(kXDarwinControllerNotify, 1,
+ AppleWMPreviousWindow);
+}
+
+/*
+ * The XPR implementation handles close, minimize, and zoom actions for X11
+ * windows here, while CR handles these in the NSWindow class.
+ */
+
+// Handle Close from window menu for X11 window in XPR implementation
+- (IBAction)performClose:(id)sender
+{
+ QuartzMessageServerThread(kXDarwinControllerNotify, 1,
+ AppleWMCloseWindow);
+}
+
+// Handle Minimize from window menu for X11 window in XPR implementation
+- (IBAction)performMiniaturize:(id)sender
+{
+ QuartzMessageServerThread(kXDarwinControllerNotify, 1,
+ AppleWMMinimizeWindow);
+}
+
+// Handle Zoom from window menu for X11 window in XPR implementation
+- (IBAction)performZoom:(id)sender
+{
+ QuartzMessageServerThread(kXDarwinControllerNotify, 1,
+ AppleWMZoomWindow);
+}
+
+// Handle "Bring All to Front" from window menu
+- (IBAction)bringAllToFront:(id)sender
+{
+ if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0) {
+ QuartzMessageServerThread(kXDarwinControllerNotify, 1,
+ AppleWMBringAllToFront);
+ } else {
+ [NSApp arrangeInFront:nil];
+ }
+}
+
+// This ends up at the end of the responder chain.
+- (IBAction)copy:(id)sender
+{
+ QuartzMessageServerThread(kXDarwinPasteboardNotify, 1,
+ AppleWMCopyToPasteboard);
+}
+
+// Set whether or not X11 is active and should receive all key events
+- (void)activateX11:(BOOL)state
+{
+ if (state) {
+ QuartzMessageServerThread(kXDarwinActivate, 0);
+ }
+ else {
+ QuartzMessageServerThread(kXDarwinDeactivate, 0);
+ }
+
+ x11Active = state;
+}
+
+// Some NSWindow became the key window
+- (void)windowBecameKey:(NSNotification *)notification
+{
+ NSWindow *window = [notification object];
+
+ if (quartzProcs->IsX11Window(window, [window windowNumber])) {
+ if (!x11Active)
+ [self activateX11:YES];
+ } else {
+ if (x11Active)
+ [self activateX11:NO];
+ }
+}
+
+// Set the Apple-WM specifiable part of the window menu
+- (void)setX11WindowList:(NSArray *)list
+{
+ NSMenuItem *item;
+ int first, count, i;
+ xEvent xe;
+
+ /* Work backwards so we don't mess up the indices */
+ first = [windowMenu indexOfItem:windowSeparator] + 1;
+ if (first > 0) {
+ count = [windowMenu numberOfItems];
+ for (i = count - 1; i >= first; i--)
+ [windowMenu removeItemAtIndex:i];
+ } else {
+ windowSeparator = (NSMenuItem *)[windowMenu addItemWithTitle:@""
+ action:nil
+ keyEquivalent:@""];
+ }
+
+ count = [dockMenu numberOfItems];
+ for (i = 0; i < count; i++)
+ [dockMenu removeItemAtIndex:0];
+
+ count = [list count];
+
+ for (i = 0; i < count; i++)
+ {
+ NSString *name, *shortcut;
+
+ name = [[list objectAtIndex:i] objectAtIndex:0];
+ shortcut = [[list objectAtIndex:i] objectAtIndex:1];
+
+ item = (NSMenuItem *)[windowMenu addItemWithTitle:name
+ action:@selector(itemSelected:)
+ keyEquivalent:shortcut];
+ [item setTarget:self];
+ [item setTag:i];
+ [item setEnabled:YES];
+
+ item = (NSMenuItem *)[dockMenu insertItemWithTitle:name
+ action:@selector(itemSelected:)
+ keyEquivalent:shortcut atIndex:i];
+ [item setTarget:self];
+ [item setTag:i];
+ [item setEnabled:YES];
+ }
+
+ if (checkedWindowItem >= 0 && checkedWindowItem < count)
+ {
+ item = (NSMenuItem *)[windowMenu itemAtIndex:first + checkedWindowItem];
+ [item setState:NSOnState];
+ item = (NSMenuItem *)[dockMenu itemAtIndex:checkedWindowItem];
+ [item setState:NSOnState];
+ }
+
+ // Notify the client of the change through the X server thread
+ xe.u.u.type = kXDarwinControllerNotify;
+ xe.u.clientMessage.u.l.longs0 = AppleWMWindowMenuNotify;
+ [self sendXEvent:&xe];
+}
+
+// Set the checked item on the Apple-WM specifiable window menu
+- (void)setX11WindowCheck:(NSNumber *)nn
+{
+ NSMenuItem *item;
+ int first, count;
+ int n = [nn intValue];
+
+ first = [windowMenu indexOfItem:windowSeparator] + 1;
+ count = [windowMenu numberOfItems] - first;
+
+ if (checkedWindowItem >= 0 && checkedWindowItem < count)
+ {
+ item = (NSMenuItem *)[windowMenu itemAtIndex:first + checkedWindowItem];
+ [item setState:NSOffState];
+ item = (NSMenuItem *)[dockMenu itemAtIndex:checkedWindowItem];
+ [item setState:NSOffState];
+ }
+ if (n >= 0 && n < count)
+ {
+ item = (NSMenuItem *)[windowMenu itemAtIndex:first + n];
+ [item setState:NSOnState];
+ item = (NSMenuItem *)[dockMenu itemAtIndex:n];
+ [item setState:NSOnState];
+ }
+ checkedWindowItem = n;
+}
+
+// Return whether or not a menu item should be enabled
+- (BOOL)validateMenuItem:(NSMenuItem *)item
+{
+ NSMenu *menu = [item menu];
+
+ if (menu == windowMenu && [item tag] == 30) {
+ // Mode switch panel is for fullscreen only
+ return !quartzRootless;
+ }
+ else if ((menu == windowMenu && [item tag] != 40) || menu == dockMenu) {
+ // The special window and dock menu items should not be active unless
+ // there is an AppleWM-aware window manager running.
+ return (AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0;
+ }
+ else {
+ return TRUE;
+ }
+}
+
+/*
+ * Application Delegate Methods
+ */
+
+- (void)applicationDidChangeScreenParameters:(NSNotification *)aNotification
+{
+ if (quartzProcs->ScreenChanged)
+ quartzProcs->ScreenChanged();
+}
+
+- (void)applicationDidHide:(NSNotification *)aNotification
+{
+ if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0) {
+ QuartzMessageServerThread(kXDarwinControllerNotify, 1,
+ AppleWMHideAll);
+ } else {
+ if (quartzProcs->HideWindows)
+ quartzProcs->HideWindows(YES);
+ }
+}
+
+- (void)applicationDidUnhide:(NSNotification *)aNotification
+{
+ if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0) {
+ QuartzMessageServerThread(kXDarwinControllerNotify, 1,
+ AppleWMShowAll);
+ } else {
+ if (quartzProcs->HideWindows)
+ quartzProcs->HideWindows(NO);
+ }
+}
+
+// Called when the user clicks the application icon,
+// but not when Cmd-Tab is used.
+// Rootless: Don't switch until applicationWillBecomeActive.
+- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication
+ hasVisibleWindows:(BOOL)flag
+{
+ if ([Preferences dockSwitch] && !quartzRootless) {
+ [self showServer:YES];
+ }
+ return NO;
+}
+
+- (void)applicationWillResignActive:(NSNotification *)aNotification
+{
+ [self showServer:NO];
+}
+
+- (void)applicationWillBecomeActive:(NSNotification *)aNotification
+{
+ if (quartzRootless) {
+ [self showServer:YES];
+
+ // If there is no AppleWM-aware window manager, we can't allow
+ // interleaving of Aqua and X11 windows.
+ if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) == 0) {
+ [NSApp arrangeInFront:nil];
+ }
+ }
+}
+
+// Called when the user opens a document type that we claim (ie. an X11 executable).
+- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
+{
+ if (serverState == server_Running) {
+ [self runClient:filename];
+ return YES;
+ }
+ else if (serverState == server_NotStarted || serverState == server_Starting) {
+ if ([filename UTF8String][0] != ':') { // Ignore display names
+ if (!pendingClients) {
+ pendingClients = [[NSMutableArray alloc] initWithCapacity:1];
+ }
+ [pendingClients addObject:filename];
+ return YES; // Assume it will launch successfully
+ }
+ return NO;
+ }
+
+ // If the server is quitting or done,
+ // its too late to launch new clients this time.
+ return NO;
+}
+
+@end
+
+
+// Send a message to the main thread, which calls handlePortMessage in
+// response. Must only be called from the X server thread because
+// NSPort is not thread safe.
+void QuartzMessageMainThread(unsigned msg, void *data, unsigned length)
+{
+ if (length > 0) {
+ NSData *eventData = [NSData dataWithBytes:data length:length];
+ NSArray *eventArray = [NSArray arrayWithObject:eventData];
+ NSPortMessage *newMessage =
+ [[NSPortMessage alloc]
+ initWithSendPort:signalPort
+ receivePort:returnPort components:eventArray];
+ [newMessage setMsgid:msg];
+ [newMessage sendBeforeDate:[NSDate distantPast]];
+ [newMessage release];
+ } else {
+ [signalMessage setMsgid:msg];
+ [signalMessage sendBeforeDate:[NSDate distantPast]];
+ }
+}
+
+void
+QuartzSetWindowMenu(int nitems, const char **items,
+ const char *shortcuts)
+{
+ NSMutableArray *array;
+ int i;
+
+ array = [[NSMutableArray alloc] initWithCapacity:nitems];
+
+ for (i = 0; i < nitems; i++) {
+ NSMutableArray *subarray = [NSMutableArray arrayWithCapacity:2];
+ NSString *string = [NSString stringWithUTF8String:items[i]];
+
+ [subarray addObject:string];
+
+ if (shortcuts[i] != 0) {
+ NSString *number = [NSString stringWithFormat:@"%d",
+ shortcuts[i]];
+ [subarray addObject:number];
+ } else
+ [subarray addObject:@""];
+
+ [array addObject:subarray];
+ }
+
+ /* Send the array of strings over to the main thread. */
+ /* Will be released in main thread. */
+ QuartzMessageMainThread(kQuartzSetWindowMenu, &array, sizeof(NSArray *));
+}
+
+// Handle SIGCHLD signals
+static void childDone(int sig)
+{
+ int clientStatus;
+
+ if (clientPID == 0)
+ return;
+
+ // Make sure it was the client task that finished
+ if (waitpid(clientPID, &clientStatus, WNOHANG) == clientPID) {
+ if (WIFSTOPPED(clientStatus))
+ return;
+ clientPID = 0;
+ [oneXServer clientProcessDone:clientStatus];
+ }
+}
+
+static void powerDidChange(
+ void *x,
+ io_service_t y,
+ natural_t messageType,
+ void *messageArgument)
+{
+ switch (messageType) {
+ case kIOMessageSystemWillSleep:
+ if (!quartzRootless) {
+ [oneXServer setRootClip:FALSE];
+ }
+ IOAllowPowerChange(root_port, (long)messageArgument);
+ break;
+ case kIOMessageCanSystemSleep:
+ IOAllowPowerChange(root_port, (long)messageArgument);
+ break;
+ case kIOMessageSystemHasPoweredOn:
+ if (!quartzRootless) {
+ [oneXServer setRootClip:TRUE];
+ }
+ break;
+ }
+
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/applewm.c b/nx-X11/programs/Xserver/hw/darwin/quartz/applewm.c
new file mode 100644
index 000000000..d79df4cee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/applewm.c
@@ -0,0 +1,722 @@
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/applewm.c,v 1.2 2003/09/16 00:36:13 torrey Exp $ */
+/**************************************************************************
+
+Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
+Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include "quartzCommon.h"
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "misc.h"
+#include "dixstruct.h"
+#include "globals.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#include "swaprep.h"
+#include "propertyst.h"
+#include <X11/Xatom.h>
+#include "darwin.h"
+#define _APPLEWM_SERVER_
+#include "applewmstr.h"
+#include "applewmExt.h"
+
+#define DEFINE_ATOM_HELPER(func,atom_name) \
+static Atom func (void) { \
+ static int generation; \
+ static Atom atom; \
+ if (generation != serverGeneration) { \
+ generation = serverGeneration; \
+ atom = MakeAtom (atom_name, strlen (atom_name), TRUE); \
+ } \
+ return atom; \
+}
+
+DEFINE_ATOM_HELPER(xa_native_screen_origin, "_NATIVE_SCREEN_ORIGIN")
+DEFINE_ATOM_HELPER (xa_apple_no_order_in, "_APPLE_NO_ORDER_IN")
+
+static AppleWMProcsPtr appleWMProcs;
+
+static int WMErrorBase;
+
+static DISPATCH_PROC(ProcAppleWMDispatch);
+static DISPATCH_PROC(SProcAppleWMDispatch);
+
+static void AppleWMResetProc(ExtensionEntry* extEntry);
+
+static unsigned char WMReqCode = 0;
+static int WMEventBase = 0;
+
+static RESTYPE ClientType, EventType; /* resource types for event masks */
+static XID eventResource;
+
+/* Currently selected events */
+static unsigned int eventMask = 0;
+
+static int WMFreeClient (pointer data, XID id);
+static int WMFreeEvents (pointer data, XID id);
+static void SNotifyEvent(xAppleWMNotifyEvent *from, xAppleWMNotifyEvent *to);
+
+typedef struct _WMEvent *WMEventPtr;
+typedef struct _WMEvent {
+ WMEventPtr next;
+ ClientPtr client;
+ XID clientResource;
+ unsigned int mask;
+} WMEventRec;
+
+static inline BoxRec
+make_box (int x, int y, int w, int h)
+{
+ BoxRec r;
+ r.x1 = x;
+ r.y1 = y;
+ r.x2 = x + w;
+ r.y2 = y + h;
+ return r;
+}
+
+void
+AppleWMExtensionInit(
+ AppleWMProcsPtr procsPtr)
+{
+ ExtensionEntry* extEntry;
+
+ ClientType = CreateNewResourceType(WMFreeClient);
+ EventType = CreateNewResourceType(WMFreeEvents);
+ eventResource = FakeClientID(0);
+
+ if (ClientType && EventType &&
+ (extEntry = AddExtension(APPLEWMNAME,
+ AppleWMNumberEvents,
+ AppleWMNumberErrors,
+ ProcAppleWMDispatch,
+ SProcAppleWMDispatch,
+ AppleWMResetProc,
+ StandardMinorOpcode)))
+ {
+ WMReqCode = (unsigned char)extEntry->base;
+ WMErrorBase = extEntry->errorBase;
+ WMEventBase = extEntry->eventBase;
+ EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent;
+ appleWMProcs = procsPtr;
+ }
+}
+
+/*ARGSUSED*/
+static void
+AppleWMResetProc (
+ ExtensionEntry* extEntry
+)
+{
+}
+
+/* Updates the _NATIVE_SCREEN_ORIGIN property on the given root window. */
+void
+AppleWMSetScreenOrigin(
+ WindowPtr pWin
+)
+{
+ long data[2];
+
+ data[0] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].x
+ + darwinMainScreenX);
+ data[1] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].y
+ + darwinMainScreenY);
+
+ ChangeWindowProperty(pWin, xa_native_screen_origin(), XA_INTEGER,
+ 32, PropModeReplace, 2, data, TRUE);
+}
+
+/* Window managers can set the _APPLE_NO_ORDER_IN property on windows
+ that are being genie-restored from the Dock. We want them to
+ be mapped but remain ordered-out until the animation
+ completes (when the Dock will order them in). */
+Bool
+AppleWMDoReorderWindow(
+ WindowPtr pWin
+)
+{
+ Atom atom;
+ PropertyPtr prop;
+
+ atom = xa_apple_no_order_in();
+ for (prop = wUserProps(pWin); prop != NULL; prop = prop->next)
+ {
+ if (prop->propertyName == atom && prop->type == atom)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+static int
+ProcAppleWMQueryVersion(
+ register ClientPtr client
+)
+{
+ xAppleWMQueryVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xAppleWMQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = APPLE_WM_MAJOR_VERSION;
+ rep.minorVersion = APPLE_WM_MINOR_VERSION;
+ rep.patchVersion = APPLE_WM_PATCH_VERSION;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ }
+ WriteToClient(client, sizeof(xAppleWMQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+
+/* events */
+
+static inline void
+updateEventMask (WMEventPtr *pHead)
+{
+ WMEventPtr pCur;
+
+ eventMask = 0;
+ for (pCur = *pHead; pCur != NULL; pCur = pCur->next)
+ eventMask |= pCur->mask;
+}
+
+/*ARGSUSED*/
+static int
+WMFreeClient (data, id)
+ pointer data;
+ XID id;
+{
+ WMEventPtr pEvent;
+ WMEventPtr *pHead, pCur, pPrev;
+
+ pEvent = (WMEventPtr) data;
+ pHead = (WMEventPtr *) LookupIDByType(eventResource, EventType);
+ if (pHead) {
+ pPrev = 0;
+ for (pCur = *pHead; pCur && pCur != pEvent; pCur=pCur->next)
+ pPrev = pCur;
+ if (pCur) {
+ if (pPrev)
+ pPrev->next = pEvent->next;
+ else
+ *pHead = pEvent->next;
+ }
+ updateEventMask (pHead);
+ }
+ xfree ((pointer) pEvent);
+ return 1;
+}
+
+/*ARGSUSED*/
+static int
+WMFreeEvents (data, id)
+ pointer data;
+ XID id;
+{
+ WMEventPtr *pHead, pCur, pNext;
+
+ pHead = (WMEventPtr *) data;
+ for (pCur = *pHead; pCur; pCur = pNext) {
+ pNext = pCur->next;
+ FreeResource (pCur->clientResource, ClientType);
+ xfree ((pointer) pCur);
+ }
+ xfree ((pointer) pHead);
+ eventMask = 0;
+ return 1;
+}
+
+static int
+ProcAppleWMSelectInput (client)
+ register ClientPtr client;
+{
+ REQUEST(xAppleWMSelectInputReq);
+ WMEventPtr pEvent, pNewEvent, *pHead;
+ XID clientResource;
+
+ REQUEST_SIZE_MATCH (xAppleWMSelectInputReq);
+ pHead = (WMEventPtr *)SecurityLookupIDByType(client,
+ eventResource, EventType, SecurityWriteAccess);
+ if (stuff->mask != 0) {
+ if (pHead) {
+ /* check for existing entry. */
+ for (pEvent = *pHead; pEvent; pEvent = pEvent->next)
+ {
+ if (pEvent->client == client)
+ {
+ pEvent->mask = stuff->mask;
+ updateEventMask (pHead);
+ return Success;
+ }
+ }
+ }
+
+ /* build the entry */
+ pNewEvent = (WMEventPtr) xalloc (sizeof (WMEventRec));
+ if (!pNewEvent)
+ return BadAlloc;
+ pNewEvent->next = 0;
+ pNewEvent->client = client;
+ pNewEvent->mask = stuff->mask;
+ /*
+ * add a resource that will be deleted when
+ * the client goes away
+ */
+ clientResource = FakeClientID (client->index);
+ pNewEvent->clientResource = clientResource;
+ if (!AddResource (clientResource, ClientType, (pointer)pNewEvent))
+ return BadAlloc;
+ /*
+ * create a resource to contain a pointer to the list
+ * of clients selecting input. This must be indirect as
+ * the list may be arbitrarily rearranged which cannot be
+ * done through the resource database.
+ */
+ if (!pHead)
+ {
+ pHead = (WMEventPtr *) xalloc (sizeof (WMEventPtr));
+ if (!pHead ||
+ !AddResource (eventResource, EventType, (pointer)pHead))
+ {
+ FreeResource (clientResource, RT_NONE);
+ return BadAlloc;
+ }
+ *pHead = 0;
+ }
+ pNewEvent->next = *pHead;
+ *pHead = pNewEvent;
+ updateEventMask (pHead);
+ } else if (stuff->mask == 0) {
+ /* delete the interest */
+ if (pHead) {
+ pNewEvent = 0;
+ for (pEvent = *pHead; pEvent; pEvent = pEvent->next) {
+ if (pEvent->client == client)
+ break;
+ pNewEvent = pEvent;
+ }
+ if (pEvent) {
+ FreeResource (pEvent->clientResource, ClientType);
+ if (pNewEvent)
+ pNewEvent->next = pEvent->next;
+ else
+ *pHead = pEvent->next;
+ xfree (pEvent);
+ updateEventMask (pHead);
+ }
+ }
+ } else {
+ client->errorValue = stuff->mask;
+ return BadValue;
+ }
+ return Success;
+}
+
+/*
+ * deliver the event
+ */
+
+void
+AppleWMSendEvent (type, mask, which, arg)
+ int type, which, arg;
+ unsigned int mask;
+{
+ WMEventPtr *pHead, pEvent;
+ ClientPtr client;
+ xAppleWMNotifyEvent se;
+
+ pHead = (WMEventPtr *) LookupIDByType(eventResource, EventType);
+ if (!pHead)
+ return;
+ for (pEvent = *pHead; pEvent; pEvent = pEvent->next) {
+ client = pEvent->client;
+ if ((pEvent->mask & mask) == 0
+ || client == serverClient || client->clientGone)
+ {
+ continue;
+ }
+ se.type = type + WMEventBase;
+ se.kind = which;
+ se.arg = arg;
+ se.sequenceNumber = client->sequence;
+ se.time = currentTime.milliseconds;
+ WriteEventsToClient (client, 1, (xEvent *) &se);
+ }
+}
+
+/* Safe to call from any thread. */
+unsigned int
+AppleWMSelectedEvents (void)
+{
+ return eventMask;
+}
+
+
+/* general utility functions */
+
+static int
+ProcAppleWMDisableUpdate(
+ register ClientPtr client
+)
+{
+ REQUEST_SIZE_MATCH(xAppleWMDisableUpdateReq);
+
+ appleWMProcs->DisableUpdate();
+
+ return (client->noClientException);
+}
+
+static int
+ProcAppleWMReenableUpdate(
+ register ClientPtr client
+)
+{
+ REQUEST_SIZE_MATCH(xAppleWMReenableUpdateReq);
+
+ appleWMProcs->EnableUpdate();
+
+ return (client->noClientException);
+}
+
+
+/* window functions */
+
+static int
+ProcAppleWMSetWindowMenu(
+ register ClientPtr client
+)
+{
+ const char *bytes, **items;
+ char *shortcuts;
+ int max_len, nitems, i, j;
+ REQUEST(xAppleWMSetWindowMenuReq);
+
+ REQUEST_AT_LEAST_SIZE(xAppleWMSetWindowMenuReq);
+
+ nitems = stuff->nitems;
+ items = xalloc (sizeof (char *) * nitems);
+ shortcuts = xalloc (sizeof (char) * nitems);
+
+ max_len = (stuff->length << 2) - sizeof(xAppleWMSetWindowMenuReq);
+ bytes = (char *) &stuff[1];
+
+ for (i = j = 0; i < max_len && j < nitems;)
+ {
+ shortcuts[j] = bytes[i++];
+ items[j++] = bytes + i;
+
+ while (i < max_len)
+ {
+ if (bytes[i++] == 0)
+ break;
+ }
+ }
+
+ QuartzSetWindowMenu (nitems, items, shortcuts);
+
+ free(items);
+ free(shortcuts);
+
+ return (client->noClientException);
+}
+
+static int
+ProcAppleWMSetWindowMenuCheck(
+ register ClientPtr client
+)
+{
+ REQUEST(xAppleWMSetWindowMenuCheckReq);
+
+ REQUEST_SIZE_MATCH(xAppleWMSetWindowMenuCheckReq);
+
+ QuartzMessageMainThread(kQuartzSetWindowMenuCheck, &stuff->index,
+ sizeof(stuff->index));
+
+ return (client->noClientException);
+}
+
+static int
+ProcAppleWMSetFrontProcess(
+ register ClientPtr client
+)
+{
+ REQUEST_SIZE_MATCH(xAppleWMSetFrontProcessReq);
+
+ QuartzMessageMainThread(kQuartzSetFrontProcess, NULL, 0);
+
+ return (client->noClientException);
+}
+
+static int
+ProcAppleWMSetWindowLevel(
+ register ClientPtr client
+)
+{
+ REQUEST(xAppleWMSetWindowLevelReq);
+ WindowPtr pWin;
+ int errno;
+
+ REQUEST_SIZE_MATCH(xAppleWMSetWindowLevelReq);
+
+ if (!(pWin = SecurityLookupWindow((Drawable)stuff->window,
+ client, SecurityReadAccess)))
+ {
+ return BadValue;
+ }
+
+ if (stuff->level < 0 || stuff->level >= AppleWMNumWindowLevels) {
+ return BadValue;
+ }
+
+ errno = appleWMProcs->SetWindowLevel(pWin, stuff->level);
+ if (errno != Success) {
+ return errno;
+ }
+
+ return (client->noClientException);
+}
+
+static int
+ProcAppleWMSetCanQuit(
+ register ClientPtr client
+)
+{
+ REQUEST(xAppleWMSetCanQuitReq);
+
+ REQUEST_SIZE_MATCH(xAppleWMSetCanQuitReq);
+
+ QuartzMessageMainThread(kQuartzSetCanQuit, &stuff->state,
+ sizeof(stuff->state));
+
+ return (client->noClientException);
+}
+
+
+/* frame functions */
+
+static int
+ProcAppleWMFrameGetRect(
+ register ClientPtr client
+)
+{
+ xAppleWMFrameGetRectReply rep;
+ BoxRec ir, or, rr;
+ REQUEST(xAppleWMFrameGetRectReq);
+
+ REQUEST_SIZE_MATCH(xAppleWMFrameGetRectReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
+ or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
+
+ if (appleWMProcs->FrameGetRect(stuff->frame_rect,
+ stuff->frame_class,
+ &or, &ir, &rr) != Success)
+ {
+ return BadValue;
+ }
+
+ rep.x = rr.x1;
+ rep.y = rr.y1;
+ rep.w = rr.x2 - rr.x1;
+ rep.h = rr.y2 - rr.y1;
+
+ WriteToClient(client, sizeof(xAppleWMFrameGetRectReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcAppleWMFrameHitTest(
+ register ClientPtr client
+)
+{
+ xAppleWMFrameHitTestReply rep;
+ BoxRec ir, or;
+ int ret;
+ REQUEST(xAppleWMFrameHitTestReq);
+
+ REQUEST_SIZE_MATCH(xAppleWMFrameHitTestReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
+ or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
+
+ if (appleWMProcs->FrameHitTest(stuff->frame_class, stuff->px,
+ stuff->py, &or, &ir, &ret) != Success)
+ {
+ return BadValue;
+ }
+
+ rep.ret = ret;
+
+ WriteToClient(client, sizeof(xAppleWMFrameHitTestReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcAppleWMFrameDraw(
+ register ClientPtr client
+)
+{
+ BoxRec ir, or;
+ unsigned int title_length, title_max;
+ unsigned char *title_bytes;
+ REQUEST(xAppleWMFrameDrawReq);
+ WindowPtr pWin;
+
+ REQUEST_AT_LEAST_SIZE(xAppleWMFrameDrawReq);
+
+ if (!(pWin = SecurityLookupWindow((Drawable)stuff->window,
+ client, SecurityReadAccess)))
+ {
+ return BadValue;
+ }
+
+ ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
+ or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
+
+ title_length = stuff->title_length;
+ title_max = (stuff->length << 2) - sizeof(xAppleWMFrameDrawReq);
+
+ if (title_max < title_length)
+ return BadValue;
+
+ title_bytes = (unsigned char *) &stuff[1];
+
+ errno = appleWMProcs->FrameDraw(pWin, stuff->frame_class,
+ stuff->frame_attr, &or, &ir,
+ title_length, title_bytes);
+ if (errno != Success) {
+ return errno;
+ }
+
+ return (client->noClientException);
+}
+
+
+/* dispatch */
+
+static int
+ProcAppleWMDispatch (
+ register ClientPtr client
+)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_AppleWMQueryVersion:
+ return ProcAppleWMQueryVersion(client);
+ }
+
+ if (!LocalClient(client))
+ return WMErrorBase + AppleWMClientNotLocal;
+
+ switch (stuff->data)
+ {
+ case X_AppleWMSelectInput:
+ return ProcAppleWMSelectInput(client);
+ case X_AppleWMDisableUpdate:
+ return ProcAppleWMDisableUpdate(client);
+ case X_AppleWMReenableUpdate:
+ return ProcAppleWMReenableUpdate(client);
+ case X_AppleWMSetWindowMenu:
+ return ProcAppleWMSetWindowMenu(client);
+ case X_AppleWMSetWindowMenuCheck:
+ return ProcAppleWMSetWindowMenuCheck(client);
+ case X_AppleWMSetFrontProcess:
+ return ProcAppleWMSetFrontProcess(client);
+ case X_AppleWMSetWindowLevel:
+ return ProcAppleWMSetWindowLevel(client);
+ case X_AppleWMSetCanQuit:
+ return ProcAppleWMSetCanQuit(client);
+ case X_AppleWMFrameGetRect:
+ return ProcAppleWMFrameGetRect(client);
+ case X_AppleWMFrameHitTest:
+ return ProcAppleWMFrameHitTest(client);
+ case X_AppleWMFrameDraw:
+ return ProcAppleWMFrameDraw(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static void
+SNotifyEvent(from, to)
+ xAppleWMNotifyEvent *from, *to;
+{
+ to->type = from->type;
+ to->kind = from->kind;
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswapl (from->time, to->time);
+ cpswapl (from->arg, to->arg);
+}
+
+static int
+SProcAppleWMQueryVersion(
+ register ClientPtr client
+)
+{
+ register int n;
+ REQUEST(xAppleWMQueryVersionReq);
+ swaps(&stuff->length, n);
+ return ProcAppleWMQueryVersion(client);
+}
+
+static int
+SProcAppleWMDispatch (
+ register ClientPtr client
+)
+{
+ REQUEST(xReq);
+
+ /* It is bound to be non-local when there is byte swapping */
+ if (!LocalClient(client))
+ return WMErrorBase + AppleWMClientNotLocal;
+
+ /* only local clients are allowed WM access */
+ switch (stuff->data)
+ {
+ case X_AppleWMQueryVersion:
+ return SProcAppleWMQueryVersion(client);
+ default:
+ return BadRequest;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/applewmExt.h b/nx-X11/programs/Xserver/hw/darwin/quartz/applewmExt.h
new file mode 100644
index 000000000..b27083ac7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/applewmExt.h
@@ -0,0 +1,85 @@
+/*
+ * External interface for the server's AppleWM support
+ */
+/**************************************************************************
+
+Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
+Copyright (c) 2003-2004 Torrey T. Lyons. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/applewmExt.h,v 1.2 2003/11/11 23:48:41 torrey Exp $ */
+
+#ifndef _APPLEWMEXT_H_
+#define _APPLEWMEXT_H_
+
+#include "window.h"
+
+typedef int (*DisableUpdateProc)(void);
+typedef int (*EnableUpdateProc)(void);
+typedef int (*SetWindowLevelProc)(WindowPtr pWin, int level);
+typedef int (*FrameGetRectProc)(int type, int class, const BoxRec *outer,
+ const BoxRec *inner, BoxRec *ret);
+typedef int (*FrameHitTestProc)(int class, int x, int y,
+ const BoxRec *outer,
+ const BoxRec *inner, int *ret);
+typedef int (*FrameDrawProc)(WindowPtr pWin, int class, unsigned int attr,
+ const BoxRec *outer, const BoxRec *inner,
+ unsigned int title_len,
+ const unsigned char *title_bytes);
+
+/*
+ * AppleWM implementation function list
+ */
+typedef struct _AppleWMProcs {
+ DisableUpdateProc DisableUpdate;
+ EnableUpdateProc EnableUpdate;
+ SetWindowLevelProc SetWindowLevel;
+ FrameGetRectProc FrameGetRect;
+ FrameHitTestProc FrameHitTest;
+ FrameDrawProc FrameDraw;
+} AppleWMProcsRec, *AppleWMProcsPtr;
+
+void AppleWMExtensionInit(
+ AppleWMProcsPtr procsPtr
+);
+
+void AppleWMSetScreenOrigin(
+ WindowPtr pWin
+);
+
+Bool AppleWMDoReorderWindow(
+ WindowPtr pWin
+);
+
+void AppleWMSendEvent(
+ int /* type */,
+ unsigned int /* mask */,
+ int /* which */,
+ int /* arg */
+);
+
+unsigned int AppleWMSelectedEvents(
+ void
+);
+
+#endif /* _APPLEWMEXT_H_ */
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/cr/Imakefile b/nx-X11/programs/Xserver/hw/darwin/quartz/cr/Imakefile
new file mode 100644
index 000000000..8746063a8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/cr/Imakefile
@@ -0,0 +1,35 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/Imakefile,v 1.3 2004/03/19 02:05:29 torrey Exp $
+
+#include <Server.tmpl>
+
+LinkSourceFile(quartzCursor.c,../fullscreen)
+LinkSourceFile(quartzCursor.h,../fullscreen)
+
+SRCS = crAppleWM.m \
+ crFrame.m \
+ crScreen.m \
+ quartzCursor.c \
+ XView.m
+
+OBJS = crAppleWM.o \
+ crFrame.o \
+ crScreen.o \
+ quartzCursor.o \
+ XView.o
+
+INCLUDES = -I. -I$(SERVERSRC)/fb -I$(SERVERSRC)/mi -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(SERVERSRC)/render \
+ -I$(SERVERSRC)/miext/rootless -I$(SERVERSRC)/miext/damage \
+ -I$(EXTINCSRC) -I.. -I../.. \
+ -I$(SERVERSRC)/miext/rootless/safeAlpha -I$(SERVERSRC)/Xext \
+ -I$(APPLEWMLIBSRC)
+
+#if OSMajorVersion < 6
+DEFINES = -DDEFER_NSWINDOW
+#endif
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(cr,$(OBJS))
+
+DependTarget()
+
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/cr/XView.h b/nx-X11/programs/Xserver/hw/darwin/quartz/cr/XView.h
new file mode 100644
index 000000000..01f5b04b4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/cr/XView.h
@@ -0,0 +1,42 @@
+/*
+ * NSView subclass for Mac OS X rootless X server
+ *
+ * Copyright (c) 2001 Greg Parker. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XView.h,v 1.2 2002/07/15 19:58:31 torrey Exp $ */
+
+#import <Cocoa/Cocoa.h>
+
+@interface XView : NSQuickDrawView
+
+- (BOOL)isFlipped;
+- (BOOL)isOpaque;
+- (BOOL)acceptsFirstResponder;
+- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent;
+- (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)theEvent;
+
+- (void)mouseDown:(NSEvent *)anEvent;
+
+@end
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/cr/XView.m b/nx-X11/programs/Xserver/hw/darwin/quartz/cr/XView.m
new file mode 100644
index 000000000..5feac6b42
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/cr/XView.m
@@ -0,0 +1,74 @@
+/*
+ * NSView subclass for Mac OS X rootless X server
+ *
+ * Each rootless window contains an instance of this class.
+ * This class handles events while drawing is handled by Carbon
+ * code in the rootless Aqua implementation.
+ *
+ * Copyright (c) 2001 Greg Parker. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/XView.m,v 1.1 2003/06/07 05:49:07 torrey Exp $ */
+
+#import "XView.h"
+
+
+@implementation XView
+
+- (BOOL)isFlipped
+{
+ return NO;
+}
+
+- (BOOL)isOpaque
+{
+ return YES;
+}
+
+- (BOOL)acceptsFirstResponder
+{
+ return YES;
+}
+
+- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
+{
+ return YES;
+}
+
+- (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)theEvent
+{
+ return YES;
+}
+
+- (void)mouseDown:(NSEvent *)anEvent
+{
+ // Only X is allowed to restack windows.
+ [NSApp preventWindowOrdering];
+ if (! [NSApp isActive]) {
+ [NSApp activateIgnoringOtherApps:YES];
+ }
+ [[self nextResponder] mouseDown:anEvent];
+}
+
+@end
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/cr/cr.h b/nx-X11/programs/Xserver/hw/darwin/quartz/cr/cr.h
new file mode 100644
index 000000000..94133e4af
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/cr/cr.h
@@ -0,0 +1,62 @@
+/*
+ * Internal definitions of the Cocoa rootless implementation
+ */
+/*
+ * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86$ */
+
+#ifndef _CR_H
+#define _CR_H
+
+#ifdef __OBJC__
+#import <Cocoa/Cocoa.h>
+#import "XView.h"
+#else
+typedef struct OpaqueNSWindow NSWindow;
+typedef struct OpaqueXView XView;
+#endif
+
+#undef BOOL
+#define BOOL xBOOL
+#include "screenint.h"
+#include "window.h"
+#undef BOOL
+
+// Predefined style for the window which is about to be framed
+extern WindowPtr nextWindowToFrame;
+extern unsigned int nextWindowStyle;
+
+typedef struct {
+ NSWindow *window;
+ XView *view;
+ GrafPtr port;
+ CGContextRef context;
+} CRWindowRec, *CRWindowPtr;
+
+Bool CRInit(ScreenPtr pScreen);
+void CRAppleWMInit(void);
+
+#endif /* _CR_H */
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/cr/crAppleWM.m b/nx-X11/programs/Xserver/hw/darwin/quartz/cr/crAppleWM.m
new file mode 100644
index 000000000..a2e97ff81
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/cr/crAppleWM.m
@@ -0,0 +1,157 @@
+/*
+ * Cocoa rootless implementation functions for AppleWM extension
+ */
+/*
+ * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.2 2003/06/30 01:45:13 torrey Exp $ */
+
+#include "quartzCommon.h"
+#include "cr.h"
+
+#undef BOOL
+#define BOOL xBOOL
+#include "rootless.h"
+#include "X.h"
+#define _APPLEWM_SERVER_
+#include "applewm.h"
+#include "applewmExt.h"
+#undef BOOL
+
+#define StdDocumentStyleMask (NSTitledWindowMask | \
+ NSClosableWindowMask | \
+ NSMiniaturizableWindowMask | \
+ NSResizableWindowMask)
+
+static int
+CRDisableUpdate(void)
+{
+ return Success;
+}
+
+
+static int
+CREnableUpdate(void)
+{
+ return Success;
+}
+
+
+static int CRSetWindowLevel(
+ WindowPtr pWin,
+ int level)
+{
+ CRWindowPtr crWinPtr;
+
+ crWinPtr = (CRWindowPtr) RootlessFrameForWindow(pWin, TRUE);
+ if (crWinPtr == 0)
+ return BadWindow;
+
+ RootlessStopDrawing(pWin, FALSE);
+
+ [crWinPtr->window setLevel:level];
+
+ return Success;
+}
+
+
+static int CRFrameGetRect(
+ int type,
+ int class,
+ const BoxRec *outer,
+ const BoxRec *inner,
+ BoxRec *ret)
+{
+ return Success;
+}
+
+
+static int CRFrameHitTest(
+ int class,
+ int x,
+ int y,
+ const BoxRec *outer,
+ const BoxRec *inner,
+ int *ret)
+{
+ return 0;
+}
+
+
+static int CRFrameDraw(
+ WindowPtr pWin,
+ int class,
+ unsigned int attr,
+ const BoxRec *outer,
+ const BoxRec *inner,
+ unsigned int title_len,
+ const unsigned char *title_bytes)
+{
+ CRWindowPtr crWinPtr;
+ NSWindow *window;
+ Bool hasResizeIndicator;
+
+ /* We assume the window has not yet been framed so
+ RootlessFrameForWindow() will cause it to be. Record the window
+ style so that the appropriate one will be used when it is framed.
+ If the window is already framed, we can't change the window
+ style and the following will have no effect. */
+
+ nextWindowToFrame = pWin;
+ if (class == AppleWMFrameClassDocument)
+ nextWindowStyle = StdDocumentStyleMask;
+ else
+ nextWindowStyle = NSBorderlessWindowMask;
+
+ crWinPtr = (CRWindowPtr) RootlessFrameForWindow(pWin, TRUE);
+ if (crWinPtr == 0)
+ return BadWindow;
+
+ window = crWinPtr->window;
+
+ [window setTitle:[NSString stringWithCString:title_bytes
+ length:title_len]];
+
+ hasResizeIndicator = (attr & AppleWMFrameGrowBox) ? YES : NO;
+ [window setShowsResizeIndicator:hasResizeIndicator];
+
+ return Success;
+}
+
+
+static AppleWMProcsRec crAppleWMProcs = {
+ CRDisableUpdate,
+ CREnableUpdate,
+ CRSetWindowLevel,
+ CRFrameGetRect,
+ CRFrameHitTest,
+ CRFrameDraw
+};
+
+
+void CRAppleWMInit(void)
+{
+ AppleWMExtensionInit(&crAppleWMProcs);
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/cr/crFrame.m b/nx-X11/programs/Xserver/hw/darwin/quartz/cr/crFrame.m
new file mode 100644
index 000000000..9427b2e1d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/cr/crFrame.m
@@ -0,0 +1,439 @@
+/*
+ * Cocoa rootless implementation frame functions
+ */
+/*
+ * Copyright (c) 2001 Greg Parker. All Rights Reserved.
+ * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/cr/crFrame.m,v 1.3 2004/10/08 00:35:05 torrey Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/crFrame.m,v 1.9 2004/03/19 02:05:29 torrey Exp $ */
+
+#include "quartzCommon.h"
+#include "cr.h"
+
+#undef BOOL
+#define BOOL xBOOL
+#include "rootless.h"
+#include "applewmExt.h"
+#include "windowstr.h"
+#undef BOOL
+
+WindowPtr nextWindowToFrame = NULL;
+unsigned int nextWindowStyle = 0;
+
+static void CRReshapeFrame(RootlessFrameID wid, RegionPtr pShape);
+
+
+/*
+ * CRCreateFrame
+ * Create a new physical window.
+ * Rootless windows must not autodisplay! Autodisplay can cause a deadlock.
+ * Event thread - autodisplay: locks view hierarchy, then window
+ * X Server thread - window resize: locks window, then view hierarchy
+ * Deadlock occurs if each thread gets one lock and waits for the other.
+ */
+static Bool
+CRCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
+ int newX, int newY, RegionPtr pShape)
+{
+ CRWindowPtr crWinPtr;
+ NSRect bounds;
+ NSWindow *theWindow;
+ XView *theView;
+ unsigned int theStyleMask = NSBorderlessWindowMask;
+
+ crWinPtr = (CRWindowPtr) xalloc(sizeof(CRWindowRec));
+
+ bounds = NSMakeRect(newX,
+ NSHeight([[NSScreen mainScreen] frame]) -
+ newY - pFrame->height,
+ pFrame->width, pFrame->height);
+
+ // Check if AppleWM has specified a style for this window
+ if (pFrame->win == nextWindowToFrame) {
+ theStyleMask = nextWindowStyle;
+ }
+ nextWindowToFrame = NULL;
+
+ // Create an NSWindow for the new X11 window
+ theWindow = [[NSWindow alloc] initWithContentRect:bounds
+ styleMask:theStyleMask
+ backing:NSBackingStoreBuffered
+#ifdef DEFER_NSWINDOW
+ defer:YES];
+#else
+ defer:NO];
+#endif
+
+ if (!theWindow) return FALSE;
+
+ [theWindow setBackgroundColor:[NSColor clearColor]]; // erase transparent
+ [theWindow setAlphaValue:1.0]; // draw opaque
+ [theWindow setOpaque:YES]; // changed when window is shaped
+
+ [theWindow useOptimizedDrawing:YES]; // Has no overlapping sub-views
+ [theWindow setAutodisplay:NO]; // See comment above
+ [theWindow disableFlushWindow]; // We do all the flushing manually
+ [theWindow setHasShadow:YES]; // All windows have shadows
+ [theWindow setReleasedWhenClosed:YES]; // Default, but we want to be sure
+
+ theView = [[XView alloc] initWithFrame:bounds];
+ [theWindow setContentView:theView];
+ [theWindow setInitialFirstResponder:theView];
+
+#ifdef DEFER_NSWINDOW
+ // We need the NSWindow to actually be created now.
+ // If we had to defer creating it, we have to order it
+ // onto the screen to force it to be created.
+
+ if (pFrame->win->prevSib) {
+ CRWindowPtr crWinPtr = (CRWindowPtr) RootlessFrameForWindow(
+ pFrame->win->prevSib, FALSE);
+ int upperNum = [crWinPtr->window windowNumber];
+ [theWindow orderWindow:NSWindowBelow relativeTo:upperNum];
+ } else {
+ [theWindow orderFront:nil];
+ }
+#endif
+
+ [theWindow setAcceptsMouseMovedEvents:YES];
+
+ crWinPtr->window = theWindow;
+ crWinPtr->view = theView;
+
+ [theView lockFocus];
+ // Fill the window with white to make sure alpha channel is set
+ NSEraseRect(bounds);
+ crWinPtr->port = [theView qdPort];
+ crWinPtr->context = [[NSGraphicsContext currentContext] graphicsPort];
+ // CreateCGContextForPort(crWinPtr->port, &crWinPtr->context);
+ [theView unlockFocus];
+
+ // Store the implementation private frame ID
+ pFrame->wid = (RootlessFrameID) crWinPtr;
+
+ // Reshape the frame if it was created shaped.
+ if (pShape != NULL)
+ CRReshapeFrame(pFrame->wid, pShape);
+
+ return TRUE;
+}
+
+
+/*
+ * CRDestroyFrame
+ * Destroy a frame.
+ */
+static void
+CRDestroyFrame(RootlessFrameID wid)
+{
+ CRWindowPtr crWinPtr = (CRWindowPtr) wid;
+
+ [crWinPtr->window orderOut:nil];
+ [crWinPtr->window close];
+ [crWinPtr->view release];
+ free(crWinPtr);
+}
+
+
+/*
+ * CRMoveFrame
+ * Move a frame on screen.
+ */
+static void
+CRMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY)
+{
+ CRWindowPtr crWinPtr = (CRWindowPtr) wid;
+ NSPoint topLeft;
+
+ topLeft = NSMakePoint(newX,
+ NSHeight([[NSScreen mainScreen] frame]) - newY);
+
+ [crWinPtr->window setFrameTopLeftPoint:topLeft];
+}
+
+
+/*
+ * CRResizeFrame
+ * Move and resize a frame.
+ */
+static void
+CRResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
+ int newX, int newY, unsigned int newW, unsigned int newH,
+ unsigned int gravity)
+{
+ CRWindowPtr crWinPtr = (CRWindowPtr) wid;
+ NSRect bounds = NSMakeRect(newX, NSHeight([[NSScreen mainScreen] frame]) -
+ newY - newH, newW, newH);
+
+ [crWinPtr->window setFrame:bounds display:NO];
+}
+
+
+/*
+ * CRRestackFrame
+ * Change the frame order. Put the frame behind nextWid or on top if
+ * it is NULL. Unmapped frames are mapped by restacking them.
+ */
+static void
+CRRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
+{
+ CRWindowPtr crWinPtr = (CRWindowPtr) wid;
+ CRWindowPtr crNextWinPtr = (CRWindowPtr) nextWid;
+
+ if (crNextWinPtr) {
+ int upperNum = [crNextWinPtr->window windowNumber];
+
+ [crWinPtr->window orderWindow:NSWindowBelow relativeTo:upperNum];
+ } else {
+ [crWinPtr->window makeKeyAndOrderFront:nil];
+ }
+}
+
+
+/*
+ * CRReshapeFrame
+ * Set the shape of a frame.
+ */
+static void
+CRReshapeFrame(RootlessFrameID wid, RegionPtr pShape)
+{
+ CRWindowPtr crWinPtr = (CRWindowPtr) wid;
+ NSRect bounds = [crWinPtr->view frame];
+ int winHeight = NSHeight(bounds);
+ BoxRec localBox = {0, 0, NSWidth(bounds), winHeight};
+
+ [crWinPtr->view lockFocus];
+
+ if (pShape != NULL) {
+ // Calculate the region outside the new shape.
+ miInverse(pShape, pShape, &localBox);
+ }
+
+ // If window is currently shaped we need to undo the previous shape.
+ if (![crWinPtr->window isOpaque]) {
+ [[NSColor whiteColor] set];
+ NSRectFillUsingOperation(bounds, NSCompositeDestinationAtop);
+ }
+
+ if (pShape != NULL) {
+ int count = REGION_NUM_RECTS(pShape);
+ BoxRec *extRects = REGION_RECTS(pShape);
+ BoxRec *rects, *end;
+
+ // Make transparent if window is now shaped.
+ [crWinPtr->window setOpaque:NO];
+
+ // Clear the areas outside the window shape
+ [[NSColor clearColor] set];
+ for (rects = extRects, end = extRects+count; rects < end; rects++) {
+ int rectHeight = rects->y2 - rects->y1;
+ NSRectFill( NSMakeRect(rects->x1,
+ winHeight - rects->y1 - rectHeight,
+ rects->x2 - rects->x1, rectHeight) );
+ }
+ [[NSGraphicsContext currentContext] flushGraphics];
+
+ // force update of window shadow
+ [crWinPtr->window setHasShadow:NO];
+ [crWinPtr->window setHasShadow:YES];
+
+ } else {
+ [crWinPtr->window setOpaque:YES];
+ [[NSGraphicsContext currentContext] flushGraphics];
+ }
+
+ [crWinPtr->view unlockFocus];
+}
+
+
+/*
+ * CRUnmapFrame
+ * Unmap a frame.
+ */
+static void
+CRUnmapFrame(RootlessFrameID wid)
+{
+ CRWindowPtr crWinPtr = (CRWindowPtr) wid;
+
+ [crWinPtr->window orderOut:nil];
+}
+
+
+/*
+ * CRStartDrawing
+ * When a window's buffer is not being drawn to, the CoreGraphics
+ * window server may compress or move it. Call this routine
+ * to lock down the buffer during direct drawing. It returns
+ * a pointer to the backing buffer.
+ */
+static void
+CRStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
+{
+ CRWindowPtr crWinPtr = (CRWindowPtr) wid;
+ PixMapHandle pix;
+
+ [crWinPtr->view lockFocus];
+ crWinPtr->port = [crWinPtr->view qdPort];
+ LockPortBits(crWinPtr->port);
+ [crWinPtr->view unlockFocus];
+ pix = GetPortPixMap(crWinPtr->port);
+
+ *pixelData = GetPixBaseAddr(pix);
+ *bytesPerRow = GetPixRowBytes(pix) & 0x3fff; // fixme is mask needed?
+}
+
+
+/*
+ * CRStopDrawing
+ * When direct access to a window's buffer is no longer needed, this
+ * routine should be called to allow CoreGraphics to compress or
+ * move it.
+ */
+static void
+CRStopDrawing(RootlessFrameID wid, Bool flush)
+{
+ CRWindowPtr crWinPtr = (CRWindowPtr) wid;
+
+ UnlockPortBits(crWinPtr->port);
+
+ if (flush) {
+ QDFlushPortBuffer(crWinPtr->port, NULL);
+ }
+}
+
+
+/*
+ * CRUpdateRegion
+ * Flush a region from a window's backing buffer to the screen.
+ */
+static void
+CRUpdateRegion(RootlessFrameID wid, RegionPtr pDamage)
+{
+ CRWindowPtr crWinPtr = (CRWindowPtr) wid;
+
+#ifdef ROOTLESS_TRACK_DAMAGE
+ int count = REGION_NUM_RECTS(pDamage);
+ BoxRec *rects = REGION_RECTS(pDamage);
+ BoxRec *end;
+
+ static RgnHandle rgn = NULL;
+ static RgnHandle box = NULL;
+
+ if (!rgn) rgn = NewRgn();
+ if (!box) box = NewRgn();
+
+ for (end = rects+count; rects < end; rects++) {
+ Rect qdRect;
+ qdRect.left = rects->x1;
+ qdRect.top = rects->y1;
+ qdRect.right = rects->x2;
+ qdRect.bottom = rects->y2;
+
+ RectRgn(box, &qdRect);
+ UnionRgn(rgn, box, rgn);
+ }
+
+ QDFlushPortBuffer(crWinPtr->port, rgn);
+
+ SetEmptyRgn(rgn);
+ SetEmptyRgn(box);
+
+#else /* !ROOTLESS_TRACK_DAMAGE */
+ QDFlushPortBuffer(crWinPtr->port, NULL);
+#endif
+}
+
+
+/*
+ * CRDamageRects
+ * Mark damaged rectangles as requiring redisplay to screen.
+ */
+static void
+CRDamageRects(RootlessFrameID wid, int count, const BoxRec *rects,
+ int shift_x, int shift_y)
+{
+ CRWindowPtr crWinPtr = (CRWindowPtr) wid;
+ const BoxRec *end;
+
+ for (end = rects + count; rects < end; rects++) {
+ Rect qdRect;
+ qdRect.left = rects->x1 + shift_x;
+ qdRect.top = rects->y1 + shift_y;
+ qdRect.right = rects->x2 + shift_x;
+ qdRect.bottom = rects->y2 + shift_y;
+
+ QDAddRectToDirtyRegion(crWinPtr->port, &qdRect);
+ }
+}
+
+
+/*
+ * Called to check if the frame should be reordered when it is restacked.
+ */
+Bool CRDoReorderWindow(RootlessWindowPtr pFrame)
+{
+ WindowPtr pWin = pFrame->win;
+
+ return AppleWMDoReorderWindow(pWin);
+}
+
+
+static RootlessFrameProcsRec CRRootlessProcs = {
+ CRCreateFrame,
+ CRDestroyFrame,
+ CRMoveFrame,
+ CRResizeFrame,
+ CRRestackFrame,
+ CRReshapeFrame,
+ CRUnmapFrame,
+ CRStartDrawing,
+ CRStopDrawing,
+ CRUpdateRegion,
+ CRDamageRects,
+ NULL,
+ CRDoReorderWindow,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+
+/*
+ * Initialize CR implementation
+ */
+Bool
+CRInit(ScreenPtr pScreen)
+{
+ RootlessInit(pScreen, &CRRootlessProcs);
+
+ rootless_CopyBytes_threshold = 0;
+ rootless_FillBytes_threshold = 0;
+ rootless_CompositePixels_threshold = 0;
+ rootless_CopyWindow_threshold = 0;
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/cr/crScreen.m b/nx-X11/programs/Xserver/hw/darwin/quartz/cr/crScreen.m
new file mode 100644
index 000000000..caf26f123
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/cr/crScreen.m
@@ -0,0 +1,381 @@
+/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/cr/crScreen.m,v 1.5 2004/09/18 00:38:30 torrey Exp $ */
+/*
+ * Cocoa rootless implementation initialization
+ */
+/*
+ * Copyright (c) 2001 Greg Parker. All Rights Reserved.
+ * Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/crScreen.m,v 1.5 2003/11/12 20:21:52 torrey Exp $ */
+
+#include "quartzCommon.h"
+#include "cr.h"
+
+#undef BOOL
+#define BOOL xBOOL
+#include "darwin.h"
+#include "quartz.h"
+#include "quartzCursor.h"
+#include "rootless.h"
+#include "safeAlpha.h"
+#include "pseudoramiX.h"
+#include "applewmExt.h"
+
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "picturestr.h"
+#include "globals.h"
+#ifdef DAMAGE
+# include "damage.h"
+#endif
+#undef BOOL
+
+// Name of GLX bundle using AGL framework
+static const char *crOpenGLBundle = "glxAGL.bundle";
+
+static Class classXView = nil;
+
+
+/*
+ * CRDisplayInit
+ * Find all screens.
+ *
+ * Multihead note: When rootless mode uses PseudoramiX, the
+ * X server only sees one screen; only PseudoramiX itself knows
+ * about all of the screens.
+ */
+static void
+CRDisplayInit(void)
+{
+ ErrorF("Display mode: Rootless Quartz -- Cocoa implementation\n");
+
+ if (noPseudoramiXExtension) {
+ darwinScreensFound = [[NSScreen screens] count];
+ } else {
+ darwinScreensFound = 1; // only PseudoramiX knows about the rest
+ }
+
+ CRAppleWMInit();
+}
+
+
+/*
+ * CRAddPseudoramiXScreens
+ * Add a single virtual screen encompassing all the physical screens
+ * with PseudoramiX.
+ */
+static void
+CRAddPseudoramiXScreens(int *x, int *y, int *width, int *height)
+{
+ int i;
+ NSRect unionRect = NSMakeRect(0, 0, 0, 0);
+ NSArray *screens = [NSScreen screens];
+
+ // Get the union of all screens (minus the menu bar on main screen)
+ for (i = 0; i < [screens count]; i++) {
+ NSScreen *screen = [screens objectAtIndex:i];
+ NSRect frame = [screen frame];
+ frame.origin.y = [[NSScreen mainScreen] frame].size.height -
+ frame.size.height - frame.origin.y;
+ if (NSEqualRects([screen frame], [[NSScreen mainScreen] frame])) {
+ frame.origin.y += aquaMenuBarHeight;
+ frame.size.height -= aquaMenuBarHeight;
+ }
+ unionRect = NSUnionRect(unionRect, frame);
+ }
+
+ // Use unionRect as the screen size for the X server.
+ *x = unionRect.origin.x;
+ *y = unionRect.origin.y;
+ *width = unionRect.size.width;
+ *height = unionRect.size.height;
+
+ // Tell PseudoramiX about the real screens.
+ // InitOutput() will move the big screen to (0,0),
+ // so compensate for that here.
+ for (i = 0; i < [screens count]; i++) {
+ NSScreen *screen = [screens objectAtIndex:i];
+ NSRect frame = [screen frame];
+ int j;
+
+ // Skip this screen if it's a mirrored copy of an earlier screen.
+ for (j = 0; j < i; j++) {
+ if (NSEqualRects(frame, [[screens objectAtIndex:j] frame])) {
+ ErrorF("PseudoramiX screen %d is a mirror of screen %d.\n",
+ i, j);
+ break;
+ }
+ }
+ if (j < i) continue; // this screen is a mirrored copy
+
+ frame.origin.y = [[NSScreen mainScreen] frame].size.height -
+ frame.size.height - frame.origin.y;
+
+ if (NSEqualRects([screen frame], [[NSScreen mainScreen] frame])) {
+ frame.origin.y += aquaMenuBarHeight;
+ frame.size.height -= aquaMenuBarHeight;
+ }
+
+ ErrorF("PseudoramiX screen %d added: %dx%d @ (%d,%d).\n", i,
+ (int)frame.size.width, (int)frame.size.height,
+ (int)frame.origin.x, (int)frame.origin.y);
+
+ frame.origin.x -= unionRect.origin.x;
+ frame.origin.y -= unionRect.origin.y;
+
+ ErrorF("PseudoramiX screen %d placed at X11 coordinate (%d,%d).\n",
+ i, (int)frame.origin.x, (int)frame.origin.y);
+
+ PseudoramiXAddScreen(frame.origin.x, frame.origin.y,
+ frame.size.width, frame.size.height);
+ }
+}
+
+
+/*
+ * CRScreenParams
+ * Set the basic screen parameters.
+ */
+static void
+CRScreenParams(int index, DarwinFramebufferPtr dfb)
+{
+ dfb->bitsPerComponent = CGDisplayBitsPerSample(kCGDirectMainDisplay);
+ dfb->bitsPerPixel = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
+ dfb->colorBitsPerPixel = 3 * dfb->bitsPerComponent;
+
+ if (noPseudoramiXExtension) {
+ NSScreen *screen = [[NSScreen screens] objectAtIndex:index];
+ NSRect frame = [screen frame];
+
+ // set x, y so (0,0) is top left of main screen
+ dfb->x = NSMinX(frame);
+ dfb->y = NSHeight([[NSScreen mainScreen] frame]) -
+ NSHeight(frame) - NSMinY(frame);
+
+ dfb->width = NSWidth(frame);
+ dfb->height = NSHeight(frame);
+
+ // Shift the usable part of main screen down to avoid the menu bar.
+ if (NSEqualRects(frame, [[NSScreen mainScreen] frame])) {
+ dfb->y += aquaMenuBarHeight;
+ dfb->height -= aquaMenuBarHeight;
+ }
+
+ } else {
+ CRAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height);
+ }
+}
+
+
+/*
+ * CRAddScreen
+ * Init the framebuffer and record pixmap parameters for the screen.
+ */
+static Bool
+CRAddScreen(int index, ScreenPtr pScreen)
+{
+ DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
+ QuartzScreenPtr displayInfo = QUARTZ_PRIV(pScreen);
+ CGRect cgRect;
+ CGDisplayCount numDisplays;
+ CGDisplayCount allocatedDisplays = 0;
+ CGDirectDisplayID *displays = NULL;
+ CGDisplayErr cgErr;
+
+ CRScreenParams(index, dfb);
+
+ dfb->colorType = TrueColor;
+
+ /* Passing zero width (pitch) makes miCreateScreenResources set the
+ screen pixmap to the framebuffer pointer, i.e. NULL. The generic
+ rootless code takes care of making this work. */
+ dfb->pitch = 0;
+ dfb->framebuffer = NULL;
+
+ // Get all CoreGraphics displays covered by this X11 display.
+ cgRect = CGRectMake(dfb->x, dfb->y, dfb->width, dfb->height);
+ do {
+ cgErr = CGGetDisplaysWithRect(cgRect, 0, NULL, &numDisplays);
+ if (cgErr) break;
+ allocatedDisplays = numDisplays;
+ displays = xrealloc(displays,
+ numDisplays * sizeof(CGDirectDisplayID));
+ cgErr = CGGetDisplaysWithRect(cgRect, allocatedDisplays, displays,
+ &numDisplays);
+ if (cgErr != CGDisplayNoErr) break;
+ } while (numDisplays > allocatedDisplays);
+
+ if (cgErr != CGDisplayNoErr || numDisplays == 0) {
+ ErrorF("Could not find CGDirectDisplayID(s) for X11 screen %d: %dx%d @ %d,%d.\n",
+ index, dfb->width, dfb->height, dfb->x, dfb->y);
+ return FALSE;
+ }
+
+ // This X11 screen covers all CoreGraphics displays we just found.
+ // If there's more than one CG display, then video mirroring is on
+ // or PseudoramiX is on.
+ displayInfo->displayCount = allocatedDisplays;
+ displayInfo->displayIDs = displays;
+
+ return TRUE;
+}
+
+
+/*
+ * CRSetupScreen
+ * Setup the screen for rootless access.
+ */
+static Bool
+CRSetupScreen(int index, ScreenPtr pScreen)
+{
+ // Add alpha protecting replacements for fb screen functions
+ pScreen->PaintWindowBackground = SafeAlphaPaintWindow;
+ pScreen->PaintWindowBorder = SafeAlphaPaintWindow;
+
+#ifdef RENDER
+ {
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ ps->Composite = SafeAlphaComposite;
+ }
+#endif /* RENDER */
+
+ // Initialize accelerated rootless drawing
+ // Note that this must be done before DamageSetup().
+ RootlessAccelInit(pScreen);
+
+#ifdef DAMAGE
+ // The Damage extension needs to wrap underneath the
+ // generic rootless layer, so do it now.
+ if (!DamageSetup(pScreen))
+ return FALSE;
+#endif
+
+ // Initialize generic rootless code
+ return CRInit(pScreen);
+}
+
+
+/*
+ * CRScreenChanged
+ * Configuration of displays has changed.
+ */
+static void
+CRScreenChanged(void)
+{
+ QuartzMessageServerThread(kXDarwinDisplayChanged, 0);
+}
+
+
+/*
+ * CRUpdateScreen
+ * Update screen after configuation change.
+ */
+static void
+CRUpdateScreen(ScreenPtr pScreen)
+{
+ rootlessGlobalOffsetX = darwinMainScreenX;
+ rootlessGlobalOffsetY = darwinMainScreenY;
+
+ AppleWMSetScreenOrigin(WindowTable[pScreen->myNum]);
+
+ RootlessRepositionWindows(pScreen);
+ RootlessUpdateScreenPixmap(pScreen);
+}
+
+
+/*
+ * CRInitInput
+ * Finalize CR specific setup.
+ */
+static void
+CRInitInput(int argc, char **argv)
+{
+ int i;
+
+ rootlessGlobalOffsetX = darwinMainScreenX;
+ rootlessGlobalOffsetY = darwinMainScreenY;
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ AppleWMSetScreenOrigin(WindowTable[i]);
+}
+
+
+/*
+ * CRIsX11Window
+ * Returns TRUE if cr is displaying this window.
+ */
+static Bool
+CRIsX11Window(void *nsWindow, int windowNumber)
+{
+ NSWindow *theWindow = nsWindow;
+
+ if (!theWindow)
+ return FALSE;
+
+ if ([[theWindow contentView] isKindOfClass:classXView])
+ return TRUE;
+ else
+ return FALSE;
+}
+
+
+/*
+ * Quartz display mode function list.
+ */
+static QuartzModeProcsRec crModeProcs = {
+ CRDisplayInit,
+ CRAddScreen,
+ CRSetupScreen,
+ CRInitInput,
+ QuartzInitCursor,
+ QuartzReallySetCursor,
+ QuartzSuspendXCursor,
+ QuartzResumeXCursor,
+ NULL, // No capture or release in rootless mode
+ NULL,
+ CRScreenChanged,
+ CRAddPseudoramiXScreens,
+ CRUpdateScreen,
+ CRIsX11Window,
+ NULL, // Cocoa NSWindows hide themselves
+ RootlessFrameForWindow,
+ TopLevelParent,
+ NULL, // No support for DRI surfaces
+ NULL
+};
+
+
+/*
+ * QuartzModeBundleInit
+ * Initialize the display mode bundle after loading.
+ */
+Bool
+QuartzModeBundleInit(void)
+{
+ quartzProcs = &crModeProcs;
+ quartzOpenGLBundle = crOpenGLBundle;
+ classXView = [XView class];
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/Imakefile b/nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/Imakefile
new file mode 100644
index 000000000..59c295050
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/Imakefile
@@ -0,0 +1,19 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/Imakefile,v 1.1 2003/06/07 05:49:07 torrey Exp $
+
+#include <Server.tmpl>
+
+SRCS = fullscreen.c \
+ quartzCursor.c
+
+OBJS = fullscreen.o \
+ quartzCursor.o
+
+INCLUDES = -I. -I$(SERVERSRC)/mi -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(FONTINCSRC) -I$(SERVERSRC)/render -I$(SERVERSRC)/miext/shadow \
+ -I$(EXTINCSRC) -I.. -I../..
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(fullscreen,$(OBJS))
+
+DependTarget()
+
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/fullscreen.c b/nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/fullscreen.c
new file mode 100644
index 000000000..fc0744ca5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/fullscreen.c
@@ -0,0 +1,569 @@
+/*
+ * Screen routines for full screen Quartz mode
+ *
+ * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * TORREY T. LYONS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/fullscreen/fullscreen.c,v 1.4 2005/07/01 22:43:08 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/fullscreen/fullscreen.c,v 1.3 2003/11/27 01:59:53 torrey Exp $ */
+
+#include "quartzCommon.h"
+#include "darwin.h"
+#include "quartz.h"
+#include "quartzCursor.h"
+#include "colormapst.h"
+#include "scrnintstr.h"
+#include "micmap.h"
+#include "shadow.h"
+
+// Full screen specific per screen storage structure
+typedef struct {
+ CGDirectDisplayID displayID;
+ CFDictionaryRef xDisplayMode;
+ CFDictionaryRef aquaDisplayMode;
+ CGDirectPaletteRef xPalette;
+ CGDirectPaletteRef aquaPalette;
+ unsigned char *framebuffer;
+ unsigned char *shadowPtr;
+} FSScreenRec, *FSScreenPtr;
+
+#define FULLSCREEN_PRIV(pScreen) \
+ ((FSScreenPtr)pScreen->devPrivates[fsScreenIndex].ptr)
+
+static int fsScreenIndex;
+static CGDirectDisplayID *quartzDisplayList = NULL;
+static int quartzNumScreens = 0;
+static FSScreenPtr quartzScreens[MAXSCREENS];
+
+static int darwinCmapPrivateIndex = -1;
+static unsigned long darwinCmapGeneration = 0;
+
+#define CMAP_PRIV(pCmap) \
+ ((CGDirectPaletteRef) (pCmap)->devPrivates[darwinCmapPrivateIndex].ptr)
+
+/*
+ =============================================================================
+
+ Colormap handling
+
+ =============================================================================
+*/
+
+/*
+ * FSInitCmapPrivates
+ * Colormap privates may be allocated after the default colormap has
+ * already been created for some screens. This initialization procedure
+ * is called for each default colormap that is found.
+ */
+static Bool
+FSInitCmapPrivates(
+ ColormapPtr pCmap)
+{
+ return TRUE;
+}
+
+
+/*
+ * FSCreateColormap
+ * This is a callback from X after a new colormap is created.
+ * We allocate a new CoreGraphics pallete for each colormap.
+ */
+static Bool
+FSCreateColormap(
+ ColormapPtr pCmap)
+{
+ CGDirectPaletteRef pallete;
+
+ // Allocate private storage for the hardware dependent colormap info.
+ if (darwinCmapGeneration != serverGeneration) {
+ if ((darwinCmapPrivateIndex =
+ AllocateColormapPrivateIndex(FSInitCmapPrivates)) < 0)
+ {
+ return FALSE;
+ }
+ darwinCmapGeneration = serverGeneration;
+ }
+
+ pallete = CGPaletteCreateDefaultColorPalette();
+ if (!pallete) return FALSE;
+
+ CMAP_PRIV(pCmap) = pallete;
+ return TRUE;
+}
+
+
+/*
+ * FSDestroyColormap
+ * This is called by DIX FreeColormap after it has uninstalled a colormap
+ * and notified all interested parties. We deallocated the corresponding
+ * CoreGraphics pallete.
+ */
+static void
+FSDestroyColormap(
+ ColormapPtr pCmap)
+{
+ CGPaletteRelease( CMAP_PRIV(pCmap) );
+}
+
+
+/*
+ * FSInstallColormap
+ * Set the current CoreGraphics pallete to the pallete corresponding
+ * to the provided colormap.
+ */
+static void
+FSInstallColormap(
+ ColormapPtr pCmap)
+{
+ CGDirectPaletteRef palette = CMAP_PRIV(pCmap);
+ ScreenPtr pScreen = pCmap->pScreen;
+ FSScreenPtr fsDisplayInfo = FULLSCREEN_PRIV(pScreen);
+
+ // Inform all interested parties that the map is being changed.
+ miInstallColormap(pCmap);
+
+ if (quartzServerVisible)
+ CGDisplaySetPalette(fsDisplayInfo->displayID, palette);
+
+ fsDisplayInfo->xPalette = palette;
+}
+
+
+/*
+ * FSStoreColors
+ * This is a callback from X to change the hardware colormap
+ * when using PsuedoColor in full screen mode.
+ */
+static void
+FSStoreColors(
+ ColormapPtr pCmap,
+ int numEntries,
+ xColorItem *pdefs)
+{
+ CGDirectPaletteRef palette = CMAP_PRIV(pCmap);
+ ScreenPtr pScreen = pCmap->pScreen;
+ FSScreenPtr fsDisplayInfo = FULLSCREEN_PRIV(pScreen);
+ CGDeviceColor color;
+ int i;
+
+ if (! palette)
+ return;
+
+ for (i = 0; i < numEntries; i++) {
+ color.red = pdefs[i].red / 65535.0;
+ color.green = pdefs[i].green / 65535.0;
+ color.blue = pdefs[i].blue / 65535.0;
+ CGPaletteSetColorAtIndex(palette, color, pdefs[i].pixel);
+ }
+
+ // Update hardware colormap
+ if (quartzServerVisible)
+ CGDisplaySetPalette(fsDisplayInfo->displayID, palette);
+}
+
+
+/*
+ =============================================================================
+
+ Switching between Aqua and X
+
+ =============================================================================
+*/
+
+/*
+ * FSCapture
+ * Capture the screen so we can draw. Called directly from the main thread
+ * to synchronize with hiding the menubar.
+ */
+static void FSCapture(void)
+{
+ int i;
+
+ if (quartzRootless) return;
+
+ for (i = 0; i < quartzNumScreens; i++) {
+ FSScreenPtr fsDisplayInfo = quartzScreens[i];
+ CGDirectDisplayID cgID = fsDisplayInfo->displayID;
+
+ if (!CGDisplayIsCaptured(cgID)) {
+ CGDisplayCapture(cgID);
+ fsDisplayInfo->aquaDisplayMode = CGDisplayCurrentMode(cgID);
+ if (fsDisplayInfo->xDisplayMode != fsDisplayInfo->aquaDisplayMode)
+ CGDisplaySwitchToMode(cgID, fsDisplayInfo->xDisplayMode);
+ if (fsDisplayInfo->xPalette)
+ CGDisplaySetPalette(cgID, fsDisplayInfo->xPalette);
+ }
+ }
+}
+
+
+/*
+ * FSRelease
+ * Release the screen so others can draw.
+ */
+static void FSRelease(void)
+{
+ int i;
+
+ if (quartzRootless) return;
+
+ for (i = 0; i < quartzNumScreens; i++) {
+ FSScreenPtr fsDisplayInfo = quartzScreens[i];
+ CGDirectDisplayID cgID = fsDisplayInfo->displayID;
+
+ if (CGDisplayIsCaptured(cgID)) {
+ if (fsDisplayInfo->xDisplayMode != fsDisplayInfo->aquaDisplayMode)
+ CGDisplaySwitchToMode(cgID, fsDisplayInfo->aquaDisplayMode);
+ if (fsDisplayInfo->aquaPalette)
+ CGDisplaySetPalette(cgID, fsDisplayInfo->aquaPalette);
+ CGDisplayRelease(cgID);
+ }
+ }
+}
+
+
+/*
+ * FSSuspendScreen
+ * Suspend X11 cursor and drawing to the screen.
+ */
+static void FSSuspendScreen(
+ ScreenPtr pScreen)
+{
+ QuartzSuspendXCursor(pScreen);
+ xf86SetRootClip(pScreen, FALSE);
+}
+
+
+/*
+ * FSResumeScreen
+ * Resume X11 cursor and drawing to the screen.
+ */
+static void FSResumeScreen(
+ ScreenPtr pScreen,
+ int x, // cursor location
+ int y )
+{
+ QuartzResumeXCursor(pScreen, x, y);
+ xf86SetRootClip(pScreen, TRUE);
+}
+
+
+/*
+ =============================================================================
+
+ Screen initialization
+
+ =============================================================================
+*/
+
+/*
+ * FSDisplayInit
+ * Full screen specific initialization called from InitOutput.
+ */
+static void FSDisplayInit(void)
+{
+ static unsigned long generation = 0;
+ CGDisplayCount quartzDisplayCount = 0;
+
+ ErrorF("Display mode: Full screen Quartz -- Direct Display\n");
+
+ // Allocate private storage for each screen's mode specific info
+ if (generation != serverGeneration) {
+ fsScreenIndex = AllocateScreenPrivateIndex();
+ generation = serverGeneration;
+ }
+
+ // Find all the CoreGraphics displays
+ CGGetActiveDisplayList(0, NULL, &quartzDisplayCount);
+ quartzDisplayList = xalloc(quartzDisplayCount * sizeof(CGDirectDisplayID));
+ CGGetActiveDisplayList(quartzDisplayCount, quartzDisplayList,
+ &quartzDisplayCount);
+
+ darwinScreensFound = quartzDisplayCount;
+ atexit(FSRelease);
+}
+
+
+/*
+ * FSFindDisplayMode
+ * Find the appropriate display mode to use in full screen mode.
+ * If display mode is not the same as the current Aqua mode, switch
+ * to the new mode.
+ */
+static Bool FSFindDisplayMode(
+ FSScreenPtr fsDisplayInfo)
+{
+ CGDirectDisplayID cgID = fsDisplayInfo->displayID;
+ size_t height, width, bpp;
+ boolean_t exactMatch;
+
+ fsDisplayInfo->aquaDisplayMode = CGDisplayCurrentMode(cgID);
+
+ // If no user options, use current display mode
+ if (darwinDesiredWidth == 0 && darwinDesiredDepth == -1 &&
+ darwinDesiredRefresh == -1)
+ {
+ fsDisplayInfo->xDisplayMode = fsDisplayInfo->aquaDisplayMode;
+ return TRUE;
+ }
+
+ // If the user has no choice for size, use current
+ if (darwinDesiredWidth == 0) {
+ width = CGDisplayPixelsWide(cgID);
+ height = CGDisplayPixelsHigh(cgID);
+ } else {
+ width = darwinDesiredWidth;
+ height = darwinDesiredHeight;
+ }
+
+ switch (darwinDesiredDepth) {
+ case 0:
+ bpp = 8;
+ break;
+ case 1:
+ bpp = 16;
+ break;
+ case 2:
+ bpp = 32;
+ break;
+ default:
+ bpp = CGDisplayBitsPerPixel(cgID);
+ }
+
+ if (darwinDesiredRefresh == -1) {
+ fsDisplayInfo->xDisplayMode =
+ CGDisplayBestModeForParameters(cgID, bpp, width, height,
+ &exactMatch);
+ } else {
+ fsDisplayInfo->xDisplayMode =
+ CGDisplayBestModeForParametersAndRefreshRate(cgID, bpp,
+ width, height, darwinDesiredRefresh, &exactMatch);
+ }
+ if (!exactMatch) {
+ fsDisplayInfo->xDisplayMode = fsDisplayInfo->aquaDisplayMode;
+ return FALSE;
+ }
+
+ // Switch to the new display mode
+ CGDisplaySwitchToMode(cgID, fsDisplayInfo->xDisplayMode);
+ return TRUE;
+}
+
+
+/*
+ * FSAddScreen
+ * Do initialization of each screen for Quartz in full screen mode.
+ */
+static Bool FSAddScreen(
+ int index,
+ ScreenPtr pScreen)
+{
+ DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
+ QuartzScreenPtr displayInfo = QUARTZ_PRIV(pScreen);
+ CGDirectDisplayID cgID = quartzDisplayList[index];
+ CGRect bounds;
+ FSScreenPtr fsDisplayInfo;
+
+ // Allocate space for private per screen fullscreen specific storage.
+ fsDisplayInfo = xalloc(sizeof(FSScreenRec));
+ FULLSCREEN_PRIV(pScreen) = fsDisplayInfo;
+
+ displayInfo->displayCount = 1;
+ displayInfo->displayIDs = xrealloc(displayInfo->displayIDs,
+ 1 * sizeof(CGDirectDisplayID));
+ displayInfo->displayIDs[0] = cgID;
+
+ fsDisplayInfo->displayID = cgID;
+ fsDisplayInfo->xDisplayMode = 0;
+ fsDisplayInfo->aquaDisplayMode = 0;
+ fsDisplayInfo->xPalette = 0;
+ fsDisplayInfo->aquaPalette = 0;
+
+ // Capture full screen because X doesn't like read-only framebuffer.
+ // We need to do this before we (potentially) switch the display mode.
+ CGDisplayCapture(cgID);
+
+ if (! FSFindDisplayMode(fsDisplayInfo)) {
+ ErrorF("Could not support specified display mode on screen %i.\n",
+ index);
+ xfree(fsDisplayInfo);
+ return FALSE;
+ }
+
+ // Don't need to flip y-coordinate as CoreGraphics treats (0, 0)
+ // as the top left of main screen.
+ bounds = CGDisplayBounds(cgID);
+ dfb->x = bounds.origin.x;
+ dfb->y = bounds.origin.y;
+ dfb->width = bounds.size.width;
+ dfb->height = bounds.size.height;
+ dfb->pitch = CGDisplayBytesPerRow(cgID);
+ dfb->bitsPerPixel = CGDisplayBitsPerPixel(cgID);
+
+ if (dfb->bitsPerPixel == 8) {
+ if (CGDisplayCanSetPalette(cgID)) {
+ dfb->colorType = PseudoColor;
+ } else {
+ dfb->colorType = StaticColor;
+ }
+ dfb->bitsPerComponent = 8;
+ dfb->colorBitsPerPixel = 8;
+ } else {
+ dfb->colorType = TrueColor;
+ dfb->bitsPerComponent = CGDisplayBitsPerSample(cgID);
+ dfb->colorBitsPerPixel = CGDisplaySamplesPerPixel(cgID) *
+ dfb->bitsPerComponent;
+ }
+
+ fsDisplayInfo->framebuffer = CGDisplayBaseAddress(cgID);
+
+ // allocate shadow framebuffer
+ fsDisplayInfo->shadowPtr = xalloc(dfb->pitch * dfb->height);
+ dfb->framebuffer = fsDisplayInfo->shadowPtr;
+
+ return TRUE;
+}
+
+
+/*
+ * FSShadowUpdate
+ * Update the damaged regions of the shadow framebuffer on the display.
+ */
+static void FSShadowUpdate(
+ ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
+ FSScreenPtr fsDisplayInfo = FULLSCREEN_PRIV(pScreen);
+ RegionPtr damage = &pBuf->damage;
+ int numBox = REGION_NUM_RECTS(damage);
+ BoxPtr pBox = REGION_RECTS(damage);
+ int pitch = dfb->pitch;
+ int bpp = dfb->bitsPerPixel/8;
+
+ // Don't update if the X server is not visible
+ if (!quartzServerVisible)
+ return;
+
+ // Loop through all the damaged boxes
+ while (numBox--) {
+ int width, height, offset;
+ unsigned char *src, *dst;
+
+ width = (pBox->x2 - pBox->x1) * bpp;
+ height = pBox->y2 - pBox->y1;
+ offset = (pBox->y1 * pitch) + (pBox->x1 * bpp);
+ src = fsDisplayInfo->shadowPtr + offset;
+ dst = fsDisplayInfo->framebuffer + offset;
+
+ while (height--) {
+ memcpy(dst, src, width);
+ dst += pitch;
+ src += pitch;
+ }
+
+ // Get the next box
+ pBox++;
+ }
+}
+
+
+/*
+ * FSSetupScreen
+ * Finalize full screen specific setup of each screen.
+ */
+static Bool FSSetupScreen(
+ int index,
+ ScreenPtr pScreen)
+{
+ DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
+ FSScreenPtr fsDisplayInfo = FULLSCREEN_PRIV(pScreen);
+ CGDirectDisplayID cgID = fsDisplayInfo->displayID;
+
+ // Initialize shadow framebuffer support
+ if (! shadowInit(pScreen, FSShadowUpdate, NULL)) {
+ ErrorF("Failed to initalize shadow framebuffer for screen %i.\n",
+ index);
+ return FALSE;
+ }
+
+ if (dfb->colorType == PseudoColor) {
+ // Initialize colormap handling
+ size_t aquaBpp;
+
+ // If Aqua is using 8 bits we need to keep track of its pallete.
+ CFNumberGetValue(CFDictionaryGetValue(fsDisplayInfo->aquaDisplayMode,
+ kCGDisplayBitsPerPixel), kCFNumberLongType, &aquaBpp);
+ if (aquaBpp <= 8)
+ fsDisplayInfo->aquaPalette = CGPaletteCreateWithDisplay(cgID);
+
+ pScreen->CreateColormap = FSCreateColormap;
+ pScreen->DestroyColormap = FSDestroyColormap;
+ pScreen->InstallColormap = FSInstallColormap;
+ pScreen->StoreColors = FSStoreColors;
+
+ }
+
+ quartzScreens[quartzNumScreens++] = fsDisplayInfo;
+ return TRUE;
+}
+
+
+/*
+ * Quartz display mode function list.
+ */
+static QuartzModeProcsRec fsModeProcs = {
+ FSDisplayInit,
+ FSAddScreen,
+ FSSetupScreen,
+ NULL, // Not needed
+ QuartzInitCursor,
+ QuartzReallySetCursor,
+ FSSuspendScreen,
+ FSResumeScreen,
+ FSCapture,
+ FSRelease,
+ NULL, // No dynamic screen change support
+ NULL,
+ NULL,
+ NULL, // No rootless code in fullscreen
+ NULL,
+ NULL,
+ NULL,
+ NULL, // No support for DRI surfaces
+ NULL
+};
+
+
+/*
+ * QuartzModeBundleInit
+ * Initialize the display mode bundle after loading.
+ */
+Bool
+QuartzModeBundleInit(void)
+{
+ quartzProcs = &fsModeProcs;
+ quartzOpenGLBundle = NULL; // Only Mesa support for now
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/quartzCursor.c b/nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/quartzCursor.c
new file mode 100644
index 000000000..8abce2318
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/quartzCursor.c
@@ -0,0 +1,653 @@
+/**************************************************************
+ *
+ * Support for using the Quartz Window Manager cursor
+ *
+ **************************************************************/
+/*
+ * Copyright (c) 2001-2003 Torrey T. Lyons and Greg Parker.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCursor.c,v 1.5 2003/01/23 00:34:26 torrey Exp $ */
+
+#include "quartzCommon.h"
+#include "quartzCursor.h"
+#include "darwin.h"
+
+#include <pthread.h>
+
+#include "mi.h"
+#include "scrnintstr.h"
+#include "cursorstr.h"
+#include "mipointrst.h"
+#include "globals.h"
+
+// Size of the QuickDraw cursor
+#define CURSORWIDTH 16
+#define CURSORHEIGHT 16
+
+typedef struct {
+ int qdCursorMode;
+ int qdCursorVisible;
+ int useQDCursor;
+ QueryBestSizeProcPtr QueryBestSize;
+ miPointerSpriteFuncPtr spriteFuncs;
+} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
+
+static int darwinCursorScreenIndex = -1;
+static unsigned long darwinCursorGeneration = 0;
+static CursorPtr quartzLatentCursor = NULL;
+static QD_Cursor gQDArrow; // QuickDraw arrow cursor
+
+// Cursor for the main thread to set (NULL = arrow cursor).
+static CCrsrHandle currentCursor = NULL;
+static pthread_mutex_t cursorMutex;
+static pthread_cond_t cursorCondition;
+
+#define CURSOR_PRIV(pScreen) \
+ ((QuartzCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
+
+#define HIDE_QD_CURSOR(pScreen, visible) \
+ if (visible) { \
+ int ix; \
+ for (ix = 0; ix < QUARTZ_PRIV(pScreen)->displayCount; ix++) { \
+ CGDisplayHideCursor(QUARTZ_PRIV(pScreen)->displayIDs[ix]); \
+ } \
+ visible = FALSE; \
+ } ((void)0)
+
+#define SHOW_QD_CURSOR(pScreen, visible) \
+ { \
+ int ix; \
+ for (ix = 0; ix < QUARTZ_PRIV(pScreen)->displayCount; ix++) { \
+ CGDisplayShowCursor(QUARTZ_PRIV(pScreen)->displayIDs[ix]); \
+ } \
+ visible = TRUE; \
+ } ((void)0)
+
+#define CHANGE_QD_CURSOR(cursorH) \
+ if (!quartzServerQuitting) { \
+ /* Acquire lock and tell the main thread to change cursor */ \
+ pthread_mutex_lock(&cursorMutex); \
+ currentCursor = (CCrsrHandle) (cursorH); \
+ QuartzMessageMainThread(kQuartzCursorUpdate, NULL, 0); \
+ \
+ /* Wait for the main thread to change the cursor */ \
+ pthread_cond_wait(&cursorCondition, &cursorMutex); \
+ pthread_mutex_unlock(&cursorMutex); \
+ } ((void)0)
+
+
+/*
+ * MakeQDCursor helpers: CTAB_ENTER, interleave
+ */
+
+// Add a color entry to a ctab
+#define CTAB_ENTER(ctab, index, r, g, b) \
+ ctab->ctTable[index].value = index; \
+ ctab->ctTable[index].rgb.red = r; \
+ ctab->ctTable[index].rgb.green = g; \
+ ctab->ctTable[index].rgb.blue = b
+
+// Make an unsigned short by interleaving the bits of bytes c1 and c2.
+// High bit of c1 is first; low bit of c2 is last.
+// Interleave is a built-in INTERCAL operator.
+static unsigned short
+interleave(
+ unsigned char c1,
+ unsigned char c2 )
+{
+ return
+ ((c1 & 0x80) << 8) | ((c2 & 0x80) << 7) |
+ ((c1 & 0x40) << 7) | ((c2 & 0x40) << 6) |
+ ((c1 & 0x20) << 6) | ((c2 & 0x20) << 5) |
+ ((c1 & 0x10) << 5) | ((c2 & 0x10) << 4) |
+ ((c1 & 0x08) << 4) | ((c2 & 0x08) << 3) |
+ ((c1 & 0x04) << 3) | ((c2 & 0x04) << 2) |
+ ((c1 & 0x02) << 2) | ((c2 & 0x02) << 1) |
+ ((c1 & 0x01) << 1) | ((c2 & 0x01) << 0) ;
+}
+
+/*
+ * MakeQDCursor
+ * Make a QuickDraw color cursor from the given X11 cursor.
+ * Warning: This code is nasty. Color cursors were meant to be read
+ * from resources; constructing the structures programmatically is messy.
+ */
+/*
+ QuickDraw cursor representation:
+ Our color cursor is a 2 bit per pixel pixmap.
+ Each pixel's bits are (source<<1 | mask) from the original X cursor pixel.
+ The cursor's color table maps the colors like this:
+ (2-bit value | X result | colortable | Mac result)
+ 00 | transparent | white | transparent (white outside mask)
+ 01 | back color | back color | back color
+ 10 | undefined | black | invert background (just for fun)
+ 11 | fore color | fore color | fore color
+*/
+static CCrsrHandle
+MakeQDCursor(
+ CursorPtr pCursor )
+{
+ CCrsrHandle result;
+ CCrsrPtr curs;
+ int i, w, h;
+ unsigned short rowMask;
+ PixMap *pix;
+ ColorTable *ctab;
+ unsigned short *image;
+
+ result = (CCrsrHandle) NewHandleClear(sizeof(CCrsr));
+ if (!result) return NULL;
+ HLock((Handle)result);
+ curs = *result;
+
+ // Initialize CCrsr
+ curs->crsrType = 0x8001; // 0x8000 = b&w, 0x8001 = color
+ curs->crsrMap = (PixMapHandle) NewHandleClear(sizeof(PixMap));
+ if (!curs->crsrMap) goto pixAllocFailed;
+ HLock((Handle)curs->crsrMap);
+ pix = *curs->crsrMap;
+ curs->crsrData = NULL; // raw cursor image data (set below)
+ curs->crsrXData = NULL; // QD's processed data
+ curs->crsrXValid = 0; // zero means QD must re-process cursor data
+ curs->crsrXHandle = NULL; // reserved
+ memset(curs->crsr1Data, 0, CURSORWIDTH*CURSORHEIGHT/8); // b&w data
+ memset(curs->crsrMask, 0, CURSORWIDTH*CURSORHEIGHT/8); // b&w & color mask
+ curs->crsrHotSpot.h = min(CURSORWIDTH, pCursor->bits->xhot); // hot spot
+ curs->crsrHotSpot.v = min(CURSORHEIGHT, pCursor->bits->yhot); // hot spot
+ curs->crsrXTable = 0; // reserved
+ curs->crsrID = GetCTSeed(); // unique ID from Color Manager
+
+ // Set the b&w data and mask
+ w = min(pCursor->bits->width, CURSORWIDTH);
+ h = min(pCursor->bits->height, CURSORHEIGHT);
+ rowMask = ~((1 << (CURSORWIDTH - w)) - 1);
+ for (i = 0; i < h; i++) {
+ curs->crsr1Data[i] = rowMask &
+ ((pCursor->bits->source[i*4]<<8) | pCursor->bits->source[i*4+1]);
+ curs->crsrMask[i] = rowMask &
+ ((pCursor->bits->mask[i*4]<<8) | pCursor->bits->mask[i*4+1]);
+ }
+
+ // Set the color data and mask
+ // crsrMap: defines bit depth and size and colortable only
+ pix->rowBytes = (CURSORWIDTH * 2 / 8) | 0x8000; // last bit on means PixMap
+ SetRect(&pix->bounds, 0, 0, CURSORWIDTH, CURSORHEIGHT); // see TN 1020
+ pix->pixelSize = 2;
+ pix->cmpCount = 1;
+ pix->cmpSize = 2;
+ // pix->pmTable set below
+
+ // crsrData is the pixel data. crsrMap's baseAddr is not used.
+ curs->crsrData = NewHandleClear(CURSORWIDTH*CURSORHEIGHT * 2 / 8);
+ if (!curs->crsrData) goto imageAllocFailed;
+ HLock((Handle)curs->crsrData);
+ image = (unsigned short *) *curs->crsrData;
+ // Pixel data is just 1-bit data and mask interleaved (see above)
+ for (i = 0; i < h; i++) {
+ unsigned char s, m;
+ s = pCursor->bits->source[i*4] & (rowMask >> 8);
+ m = pCursor->bits->mask[i*4] & (rowMask >> 8);
+ image[2*i] = interleave(s, m);
+ s = pCursor->bits->source[i*4+1] & (rowMask & 0x00ff);
+ m = pCursor->bits->mask[i*4+1] & (rowMask & 0x00ff);
+ image[2*i+1] = interleave(s, m);
+ }
+
+ // Build the color table (entries described above)
+ // NewPixMap allocates a color table handle.
+ pix->pmTable = (CTabHandle) NewHandleClear(sizeof(ColorTable) + 3
+ * sizeof(ColorSpec));
+ if (!pix->pmTable) goto ctabAllocFailed;
+ HLock((Handle)pix->pmTable);
+ ctab = *pix->pmTable;
+ ctab->ctSeed = GetCTSeed();
+ ctab->ctFlags = 0;
+ ctab->ctSize = 3; // color count - 1
+ CTAB_ENTER(ctab, 0, 0xffff, 0xffff, 0xffff);
+ CTAB_ENTER(ctab, 1, pCursor->backRed, pCursor->backGreen,
+ pCursor->backBlue);
+ CTAB_ENTER(ctab, 2, 0x0000, 0x0000, 0x0000);
+ CTAB_ENTER(ctab, 3, pCursor->foreRed, pCursor->foreGreen,
+ pCursor->foreBlue);
+
+ HUnlock((Handle)pix->pmTable); // ctab
+ HUnlock((Handle)curs->crsrData); // image data
+ HUnlock((Handle)curs->crsrMap); // pix
+ HUnlock((Handle)result); // cursor
+
+ return result;
+
+ // "What we have here is a failure to allocate"
+ctabAllocFailed:
+ HUnlock((Handle)curs->crsrData);
+ DisposeHandle((Handle)curs->crsrData);
+imageAllocFailed:
+ HUnlock((Handle)curs->crsrMap);
+ DisposeHandle((Handle)curs->crsrMap);
+pixAllocFailed:
+ HUnlock((Handle)result);
+ DisposeHandle((Handle)result);
+ return NULL;
+}
+
+
+/*
+ * FreeQDCursor
+ * Destroy a QuickDraw color cursor created with MakeQDCursor().
+ * The cursor must not currently be on screen.
+ */
+static void FreeQDCursor(CCrsrHandle cursHandle)
+{
+ CCrsrPtr curs;
+ PixMap *pix;
+
+ HLock((Handle)cursHandle);
+ curs = *cursHandle;
+ HLock((Handle)curs->crsrMap);
+ pix = *curs->crsrMap;
+ DisposeHandle((Handle)pix->pmTable);
+ HUnlock((Handle)curs->crsrMap);
+ DisposeHandle((Handle)curs->crsrMap);
+ DisposeHandle((Handle)curs->crsrData);
+ HUnlock((Handle)cursHandle);
+ DisposeHandle((Handle)cursHandle);
+}
+
+
+/*
+===========================================================================
+
+ Pointer sprite functions
+
+===========================================================================
+*/
+
+/*
+ * QuartzRealizeCursor
+ * Convert the X cursor representation to QuickDraw format if possible.
+ */
+Bool
+QuartzRealizeCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor )
+{
+ CCrsrHandle qdCursor;
+ QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ if(!pCursor || !pCursor->bits)
+ return FALSE;
+
+ // if the cursor is too big we use a software cursor
+ if ((pCursor->bits->height > CURSORHEIGHT) ||
+ (pCursor->bits->width > CURSORWIDTH) || !ScreenPriv->useQDCursor)
+ {
+ if (quartzRootless) {
+ // rootless can't use a software cursor
+ return TRUE;
+ } else {
+ return (*ScreenPriv->spriteFuncs->RealizeCursor)
+ (pScreen, pCursor);
+ }
+ }
+
+ // make new cursor image
+ qdCursor = MakeQDCursor(pCursor);
+ if (!qdCursor) return FALSE;
+
+ // save the result
+ pCursor->devPriv[pScreen->myNum] = (pointer) qdCursor;
+
+ return TRUE;
+}
+
+
+/*
+ * QuartzUnrealizeCursor
+ * Free the storage space associated with a realized cursor.
+ */
+Bool
+QuartzUnrealizeCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor )
+{
+ QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ if ((pCursor->bits->height > CURSORHEIGHT) ||
+ (pCursor->bits->width > CURSORWIDTH) || !ScreenPriv->useQDCursor)
+ {
+ if (quartzRootless) {
+ return TRUE;
+ } else {
+ return (*ScreenPriv->spriteFuncs->UnrealizeCursor)
+ (pScreen, pCursor);
+ }
+ } else {
+ CCrsrHandle oldCursor = (CCrsrHandle) pCursor->devPriv[pScreen->myNum];
+
+ if (currentCursor != oldCursor) {
+ // This should only fail when quitting, in which case we just leak.
+ FreeQDCursor(oldCursor);
+ }
+ pCursor->devPriv[pScreen->myNum] = NULL;
+ return TRUE;
+ }
+}
+
+
+/*
+ * QuartzSetCursor
+ * Set the cursor sprite and position.
+ * Use QuickDraw cursor if possible.
+ */
+static void
+QuartzSetCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor,
+ int x,
+ int y)
+{
+ QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ quartzLatentCursor = pCursor;
+
+ // Don't touch Mac OS cursor if X is hidden!
+ if (!quartzServerVisible)
+ return;
+
+ if (!pCursor) {
+ // Remove the cursor completely.
+ HIDE_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
+ if (! ScreenPriv->qdCursorMode)
+ (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
+ }
+ else if ((pCursor->bits->height <= CURSORHEIGHT) &&
+ (pCursor->bits->width <= CURSORWIDTH) && ScreenPriv->useQDCursor)
+ {
+ // Cursor is small enough to use QuickDraw directly.
+ if (! ScreenPriv->qdCursorMode) // remove the X cursor
+ (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
+ ScreenPriv->qdCursorMode = TRUE;
+
+ CHANGE_QD_CURSOR(pCursor->devPriv[pScreen->myNum]);
+ SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
+ }
+ else if (quartzRootless) {
+ // Rootless can't use a software cursor, so we just use Mac OS arrow.
+ CHANGE_QD_CURSOR(NULL);
+ SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
+ }
+ else {
+ // Cursor is too big for QuickDraw. Use X software cursor.
+ HIDE_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
+ ScreenPriv->qdCursorMode = FALSE;
+ (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, pCursor, x, y);
+ }
+}
+
+
+/*
+ * QuartzReallySetCursor
+ * Set the QuickDraw cursor. Called from the main thread since changing the
+ * cursor with QuickDraw is not thread safe on dual processor machines.
+ */
+void
+QuartzReallySetCursor()
+{
+ pthread_mutex_lock(&cursorMutex);
+
+ if (currentCursor) {
+ SetCCursor(currentCursor);
+ } else {
+ SetCursor(&gQDArrow);
+ }
+
+ pthread_cond_signal(&cursorCondition);
+ pthread_mutex_unlock(&cursorMutex);
+}
+
+
+/*
+ * QuartzMoveCursor
+ * Move the cursor. This is a noop for QuickDraw.
+ */
+static void
+QuartzMoveCursor(
+ ScreenPtr pScreen,
+ int x,
+ int y)
+{
+ QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ // only the X cursor needs to be explicitly moved
+ if (!ScreenPriv->qdCursorMode)
+ (*ScreenPriv->spriteFuncs->MoveCursor)(pScreen, x, y);
+}
+
+
+static miPointerSpriteFuncRec quartzSpriteFuncsRec = {
+ QuartzRealizeCursor,
+ QuartzUnrealizeCursor,
+ QuartzSetCursor,
+ QuartzMoveCursor
+};
+
+
+/*
+===========================================================================
+
+ Pointer screen functions
+
+===========================================================================
+*/
+
+/*
+ * QuartzCursorOffScreen
+ */
+static Bool QuartzCursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
+{
+ return FALSE;
+}
+
+
+/*
+ * QuartzCrossScreen
+ */
+static void QuartzCrossScreen(ScreenPtr pScreen, Bool entering)
+{
+ return;
+}
+
+
+/*
+ * QuartzWarpCursor
+ * Change the cursor position without generating an event or motion history.
+ * The input coordinates (x,y) are in pScreen-local X11 coordinates.
+ *
+ */
+static void
+QuartzWarpCursor(
+ ScreenPtr pScreen,
+ int x,
+ int y)
+{
+ static int neverMoved = TRUE;
+
+ if (neverMoved) {
+ // Don't move the cursor the first time. This is the jump-to-center
+ // initialization, and it's annoying because we may still be in MacOS.
+ neverMoved = FALSE;
+ return;
+ }
+
+ if (quartzServerVisible) {
+ CGDisplayErr cgErr;
+ CGPoint cgPoint;
+ // Only need to do this for one display. Any display will do.
+ CGDirectDisplayID cgID = QUARTZ_PRIV(pScreen)->displayIDs[0];
+ CGRect cgRect = CGDisplayBounds(cgID);
+
+ // Convert (x,y) to CoreGraphics screen-local CG coordinates.
+ // This is necessary because the X11 screen and CG screen may not
+ // coincide. (e.g. X11 screen may be moved to dodge the menu bar)
+
+ // Make point in X11 global coordinates
+ cgPoint = CGPointMake(x + dixScreenOrigins[pScreen->myNum].x,
+ y + dixScreenOrigins[pScreen->myNum].y);
+ // Shift to CoreGraphics global screen coordinates
+ cgPoint.x += darwinMainScreenX;
+ cgPoint.y += darwinMainScreenY;
+ // Shift to CoreGraphics screen-local coordinates
+ cgPoint.x -= cgRect.origin.x;
+ cgPoint.y -= cgRect.origin.y;
+
+ cgErr = CGDisplayMoveCursorToPoint(cgID, cgPoint);
+ if (cgErr != CGDisplayNoErr) {
+ ErrorF("Could not set cursor position with error code 0x%x.\n",
+ cgErr);
+ }
+ }
+
+ miPointerWarpCursor(pScreen, x, y);
+ miPointerUpdate();
+}
+
+
+static miPointerScreenFuncRec quartzScreenFuncsRec = {
+ QuartzCursorOffScreen,
+ QuartzCrossScreen,
+ QuartzWarpCursor,
+ DarwinEQPointerPost,
+ DarwinEQSwitchScreen
+};
+
+
+/*
+===========================================================================
+
+ Other screen functions
+
+===========================================================================
+*/
+
+/*
+ * QuartzCursorQueryBestSize
+ * Handle queries for best cursor size
+ */
+static void
+QuartzCursorQueryBestSize(
+ int class,
+ unsigned short *width,
+ unsigned short *height,
+ ScreenPtr pScreen)
+{
+ QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ if (class == CursorShape) {
+ *width = CURSORWIDTH;
+ *height = CURSORHEIGHT;
+ } else {
+ (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
+ }
+}
+
+
+/*
+ * QuartzInitCursor
+ * Initialize cursor support
+ */
+Bool
+QuartzInitCursor(
+ ScreenPtr pScreen )
+{
+ QuartzCursorScreenPtr ScreenPriv;
+ miPointerScreenPtr PointPriv;
+ DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
+
+ // initialize software cursor handling (always needed as backup)
+ if (!miDCInitialize(pScreen, &quartzScreenFuncsRec)) {
+ return FALSE;
+ }
+
+ // allocate private storage for this screen's QuickDraw cursor info
+ if (darwinCursorGeneration != serverGeneration) {
+ if ((darwinCursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+ darwinCursorGeneration = serverGeneration;
+ }
+
+ ScreenPriv = xcalloc( 1, sizeof(QuartzCursorScreenRec) );
+ if (!ScreenPriv) return FALSE;
+
+ CURSOR_PRIV(pScreen) = ScreenPriv;
+
+ // override some screen procedures
+ ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
+ pScreen->QueryBestSize = QuartzCursorQueryBestSize;
+
+ // initialize QuickDraw cursor handling
+ GetQDGlobalsArrow(&gQDArrow);
+ PointPriv = (miPointerScreenPtr)
+ pScreen->devPrivates[miPointerScreenIndex].ptr;
+
+ ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
+ PointPriv->spriteFuncs = &quartzSpriteFuncsRec;
+
+ if (!quartzRootless)
+ ScreenPriv->useQDCursor = QuartzFSUseQDCursor(dfb->colorBitsPerPixel);
+ else
+ ScreenPriv->useQDCursor = TRUE;
+ ScreenPriv->qdCursorMode = TRUE;
+ ScreenPriv->qdCursorVisible = TRUE;
+
+ // initialize cursor mutex lock
+ pthread_mutex_init(&cursorMutex, NULL);
+
+ // initialize condition for waiting
+ pthread_cond_init(&cursorCondition, NULL);
+
+ return TRUE;
+}
+
+
+// X server is hiding. Restore the Aqua cursor.
+void QuartzSuspendXCursor(
+ ScreenPtr pScreen )
+{
+ QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ CHANGE_QD_CURSOR(NULL);
+ SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
+}
+
+
+// X server is showing. Restore the X cursor.
+void QuartzResumeXCursor(
+ ScreenPtr pScreen,
+ int x,
+ int y )
+{
+ QuartzSetCursor(pScreen, quartzLatentCursor, x, y);
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/quartzCursor.h b/nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/quartzCursor.h
new file mode 100644
index 000000000..efcc4435e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/quartzCursor.h
@@ -0,0 +1,44 @@
+/*
+ * quartzCursor.h
+ *
+ * External interface for Quartz hardware cursor
+ */
+/*
+ * Copyright (c) 2001 Torrey T. Lyons and Greg Parker.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCursor.h,v 1.1 2002/03/28 02:21:19 torrey Exp $ */
+
+#ifndef QUARTZCURSOR_H
+#define QUARTZCURSOR_H
+
+#include "screenint.h"
+
+Bool QuartzInitCursor(ScreenPtr pScreen);
+void QuartzReallySetCursor(void);
+void QuartzSuspendXCursor(ScreenPtr pScreen);
+void QuartzResumeXCursor(ScreenPtr pScreen, int x, int y);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/keysym2ucs.c b/nx-X11/programs/Xserver/hw/darwin/quartz/keysym2ucs.c
new file mode 100644
index 000000000..98b8b6fee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/keysym2ucs.c
@@ -0,0 +1,909 @@
+/* $XFree86: $
+ *
+ * This module converts keysym values into the corresponding ISO 10646
+ * (UCS, Unicode) values.
+ *
+ * The array keysymtab[] contains pairs of X11 keysym values for graphical
+ * characters and the corresponding Unicode value. The function
+ * keysym2ucs() maps a keysym onto a Unicode value using a binary search,
+ * therefore keysymtab[] must remain SORTED by keysym value.
+ *
+ * The keysym -> UTF-8 conversion will hopefully one day be provided
+ * by Xlib via XmbLookupString() and should ideally not have to be
+ * done in X applications. But we are not there yet.
+ *
+ * We allow to represent any UCS character in the range U-00000000 to
+ * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
+ * This admittedly does not cover the entire 31-bit space of UCS, but
+ * it does cover all of the characters up to U-10FFFF, which can be
+ * represented by UTF-16, and more, and it is very unlikely that higher
+ * UCS codes will ever be assigned by ISO. So to get Unicode character
+ * U+ABCD you can directly use keysym 0x0100abcd.
+ *
+ * NOTE: The comments in the table below contain the actual character
+ * encoded in UTF-8, so for viewing and editing best use an editor in
+ * UTF-8 mode.
+ *
+ * Author: Markus G. Kuhn <mkuhn@acm.org>, University of Cambridge, April 2001
+ *
+ * Special thanks to Richard Verhoeven <river@win.tue.nl> for preparing
+ * an initial draft of the mapping table.
+ *
+ * This software is in the public domain. Share and enjoy!
+ *
+ * AUTOMATICALLY GENERATED FILE, DO NOT EDIT !!! (unicode/convmap.pl)
+ */
+
+#include "keysym2ucs.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+struct codepair {
+ unsigned short keysym;
+ unsigned short ucs;
+};
+
+const static struct codepair keysymtab[] = {
+ { 0x01a1, 0x0104 },
+ { 0x01a2, 0x02d8 },
+ { 0x01a3, 0x0141 },
+ { 0x01a5, 0x013d },
+ { 0x01a6, 0x015a },
+ { 0x01a9, 0x0160 },
+ { 0x01aa, 0x015e },
+ { 0x01ab, 0x0164 },
+ { 0x01ac, 0x0179 },
+ { 0x01ae, 0x017d },
+ { 0x01af, 0x017b },
+ { 0x01b1, 0x0105 },
+ { 0x01b2, 0x02db },
+ { 0x01b3, 0x0142 },
+ { 0x01b5, 0x013e },
+ { 0x01b6, 0x015b },
+ { 0x01b7, 0x02c7 },
+ { 0x01b9, 0x0161 },
+ { 0x01ba, 0x015f },
+ { 0x01bb, 0x0165 },
+ { 0x01bc, 0x017a },
+ { 0x01bd, 0x02dd },
+ { 0x01be, 0x017e },
+ { 0x01bf, 0x017c },
+ { 0x01c0, 0x0154 },
+ { 0x01c3, 0x0102 },
+ { 0x01c5, 0x0139 },
+ { 0x01c6, 0x0106 },
+ { 0x01c8, 0x010c },
+ { 0x01ca, 0x0118 },
+ { 0x01cc, 0x011a },
+ { 0x01cf, 0x010e },
+ { 0x01d0, 0x0110 },
+ { 0x01d1, 0x0143 },
+ { 0x01d2, 0x0147 },
+ { 0x01d5, 0x0150 },
+ { 0x01d8, 0x0158 },
+ { 0x01d9, 0x016e },
+ { 0x01db, 0x0170 },
+ { 0x01de, 0x0162 },
+ { 0x01e0, 0x0155 },
+ { 0x01e3, 0x0103 },
+ { 0x01e5, 0x013a },
+ { 0x01e6, 0x0107 },
+ { 0x01e8, 0x010d },
+ { 0x01ea, 0x0119 },
+ { 0x01ec, 0x011b },
+ { 0x01ef, 0x010f },
+ { 0x01f0, 0x0111 },
+ { 0x01f1, 0x0144 },
+ { 0x01f2, 0x0148 },
+ { 0x01f5, 0x0151 },
+ { 0x01f8, 0x0159 },
+ { 0x01f9, 0x016f },
+ { 0x01fb, 0x0171 },
+ { 0x01fe, 0x0163 },
+ { 0x01ff, 0x02d9 },
+ { 0x02a1, 0x0126 },
+ { 0x02a6, 0x0124 },
+ { 0x02a9, 0x0130 },
+ { 0x02ab, 0x011e },
+ { 0x02ac, 0x0134 },
+ { 0x02b1, 0x0127 },
+ { 0x02b6, 0x0125 },
+ { 0x02b9, 0x0131 },
+ { 0x02bb, 0x011f },
+ { 0x02bc, 0x0135 },
+ { 0x02c5, 0x010a },
+ { 0x02c6, 0x0108 },
+ { 0x02d5, 0x0120 },
+ { 0x02d8, 0x011c },
+ { 0x02dd, 0x016c },
+ { 0x02de, 0x015c },
+ { 0x02e5, 0x010b },
+ { 0x02e6, 0x0109 },
+ { 0x02f5, 0x0121 },
+ { 0x02f8, 0x011d },
+ { 0x02fd, 0x016d },
+ { 0x02fe, 0x015d },
+ { 0x03a2, 0x0138 },
+ { 0x03a3, 0x0156 },
+ { 0x03a5, 0x0128 },
+ { 0x03a6, 0x013b },
+ { 0x03aa, 0x0112 },
+ { 0x03ab, 0x0122 },
+ { 0x03ac, 0x0166 },
+ { 0x03b3, 0x0157 },
+ { 0x03b5, 0x0129 },
+ { 0x03b6, 0x013c },
+ { 0x03ba, 0x0113 },
+ { 0x03bb, 0x0123 },
+ { 0x03bc, 0x0167 },
+ { 0x03bd, 0x014a },
+ { 0x03bf, 0x014b },
+ { 0x03c0, 0x0100 },
+ { 0x03c7, 0x012e },
+ { 0x03cc, 0x0116 },
+ { 0x03cf, 0x012a },
+ { 0x03d1, 0x0145 },
+ { 0x03d2, 0x014c },
+ { 0x03d3, 0x0136 },
+ { 0x03d9, 0x0172 },
+ { 0x03dd, 0x0168 },
+ { 0x03de, 0x016a },
+ { 0x03e0, 0x0101 },
+ { 0x03e7, 0x012f },
+ { 0x03ec, 0x0117 },
+ { 0x03ef, 0x012b },
+ { 0x03f1, 0x0146 },
+ { 0x03f2, 0x014d },
+ { 0x03f3, 0x0137 },
+ { 0x03f9, 0x0173 },
+ { 0x03fd, 0x0169 },
+ { 0x03fe, 0x016b },
+ { 0x047e, 0x203e },
+ { 0x04a1, 0x3002 },
+ { 0x04a2, 0x300c },
+ { 0x04a3, 0x300d },
+ { 0x04a4, 0x3001 },
+ { 0x04a5, 0x30fb },
+ { 0x04a6, 0x30f2 },
+ { 0x04a7, 0x30a1 },
+ { 0x04a8, 0x30a3 },
+ { 0x04a9, 0x30a5 },
+ { 0x04aa, 0x30a7 },
+ { 0x04ab, 0x30a9 },
+ { 0x04ac, 0x30e3 },
+ { 0x04ad, 0x30e5 },
+ { 0x04ae, 0x30e7 },
+ { 0x04af, 0x30c3 },
+ { 0x04b0, 0x30fc },
+ { 0x04b1, 0x30a2 },
+ { 0x04b2, 0x30a4 },
+ { 0x04b3, 0x30a6 },
+ { 0x04b4, 0x30a8 },
+ { 0x04b5, 0x30aa },
+ { 0x04b6, 0x30ab },
+ { 0x04b7, 0x30ad },
+ { 0x04b8, 0x30af },
+ { 0x04b9, 0x30b1 },
+ { 0x04ba, 0x30b3 },
+ { 0x04bb, 0x30b5 },
+ { 0x04bc, 0x30b7 },
+ { 0x04bd, 0x30b9 },
+ { 0x04be, 0x30bb },
+ { 0x04bf, 0x30bd },
+ { 0x04c0, 0x30bf },
+ { 0x04c1, 0x30c1 },
+ { 0x04c2, 0x30c4 },
+ { 0x04c3, 0x30c6 },
+ { 0x04c4, 0x30c8 },
+ { 0x04c5, 0x30ca },
+ { 0x04c6, 0x30cb },
+ { 0x04c7, 0x30cc },
+ { 0x04c8, 0x30cd },
+ { 0x04c9, 0x30ce },
+ { 0x04ca, 0x30cf },
+ { 0x04cb, 0x30d2 },
+ { 0x04cc, 0x30d5 },
+ { 0x04cd, 0x30d8 },
+ { 0x04ce, 0x30db },
+ { 0x04cf, 0x30de },
+ { 0x04d0, 0x30df },
+ { 0x04d1, 0x30e0 },
+ { 0x04d2, 0x30e1 },
+ { 0x04d3, 0x30e2 },
+ { 0x04d4, 0x30e4 },
+ { 0x04d5, 0x30e6 },
+ { 0x04d6, 0x30e8 },
+ { 0x04d7, 0x30e9 },
+ { 0x04d8, 0x30ea },
+ { 0x04d9, 0x30eb },
+ { 0x04da, 0x30ec },
+ { 0x04db, 0x30ed },
+ { 0x04dc, 0x30ef },
+ { 0x04dd, 0x30f3 },
+ { 0x04de, 0x309b },
+ { 0x04df, 0x309c },
+ { 0x05ac, 0x060c },
+ { 0x05bb, 0x061b },
+ { 0x05bf, 0x061f },
+ { 0x05c1, 0x0621 },
+ { 0x05c2, 0x0622 },
+ { 0x05c3, 0x0623 },
+ { 0x05c4, 0x0624 },
+ { 0x05c5, 0x0625 },
+ { 0x05c6, 0x0626 },
+ { 0x05c7, 0x0627 },
+ { 0x05c8, 0x0628 },
+ { 0x05c9, 0x0629 },
+ { 0x05ca, 0x062a },
+ { 0x05cb, 0x062b },
+ { 0x05cc, 0x062c },
+ { 0x05cd, 0x062d },
+ { 0x05ce, 0x062e },
+ { 0x05cf, 0x062f },
+ { 0x05d0, 0x0630 },
+ { 0x05d1, 0x0631 },
+ { 0x05d2, 0x0632 },
+ { 0x05d3, 0x0633 },
+ { 0x05d4, 0x0634 },
+ { 0x05d5, 0x0635 },
+ { 0x05d6, 0x0636 },
+ { 0x05d7, 0x0637 },
+ { 0x05d8, 0x0638 },
+ { 0x05d9, 0x0639 },
+ { 0x05da, 0x063a },
+ { 0x05e0, 0x0640 },
+ { 0x05e1, 0x0641 },
+ { 0x05e2, 0x0642 },
+ { 0x05e3, 0x0643 },
+ { 0x05e4, 0x0644 },
+ { 0x05e5, 0x0645 },
+ { 0x05e6, 0x0646 },
+ { 0x05e7, 0x0647 },
+ { 0x05e8, 0x0648 },
+ { 0x05e9, 0x0649 },
+ { 0x05ea, 0x064a },
+ { 0x05eb, 0x064b },
+ { 0x05ec, 0x064c },
+ { 0x05ed, 0x064d },
+ { 0x05ee, 0x064e },
+ { 0x05ef, 0x064f },
+ { 0x05f0, 0x0650 },
+ { 0x05f1, 0x0651 },
+ { 0x05f2, 0x0652 },
+ { 0x06a1, 0x0452 },
+ { 0x06a2, 0x0453 },
+ { 0x06a3, 0x0451 },
+ { 0x06a4, 0x0454 },
+ { 0x06a5, 0x0455 },
+ { 0x06a6, 0x0456 },
+ { 0x06a7, 0x0457 },
+ { 0x06a8, 0x0458 },
+ { 0x06a9, 0x0459 },
+ { 0x06aa, 0x045a },
+ { 0x06ab, 0x045b },
+ { 0x06ac, 0x045c },
+ { 0x06ae, 0x045e },
+ { 0x06af, 0x045f },
+ { 0x06b0, 0x2116 },
+ { 0x06b1, 0x0402 },
+ { 0x06b2, 0x0403 },
+ { 0x06b3, 0x0401 },
+ { 0x06b4, 0x0404 },
+ { 0x06b5, 0x0405 },
+ { 0x06b6, 0x0406 },
+ { 0x06b7, 0x0407 },
+ { 0x06b8, 0x0408 },
+ { 0x06b9, 0x0409 },
+ { 0x06ba, 0x040a },
+ { 0x06bb, 0x040b },
+ { 0x06bc, 0x040c },
+ { 0x06be, 0x040e },
+ { 0x06bf, 0x040f },
+ { 0x06c0, 0x044e },
+ { 0x06c1, 0x0430 },
+ { 0x06c2, 0x0431 },
+ { 0x06c3, 0x0446 },
+ { 0x06c4, 0x0434 },
+ { 0x06c5, 0x0435 },
+ { 0x06c6, 0x0444 },
+ { 0x06c7, 0x0433 },
+ { 0x06c8, 0x0445 },
+ { 0x06c9, 0x0438 },
+ { 0x06ca, 0x0439 },
+ { 0x06cb, 0x043a },
+ { 0x06cc, 0x043b },
+ { 0x06cd, 0x043c },
+ { 0x06ce, 0x043d },
+ { 0x06cf, 0x043e },
+ { 0x06d0, 0x043f },
+ { 0x06d1, 0x044f },
+ { 0x06d2, 0x0440 },
+ { 0x06d3, 0x0441 },
+ { 0x06d4, 0x0442 },
+ { 0x06d5, 0x0443 },
+ { 0x06d6, 0x0436 },
+ { 0x06d7, 0x0432 },
+ { 0x06d8, 0x044c },
+ { 0x06d9, 0x044b },
+ { 0x06da, 0x0437 },
+ { 0x06db, 0x0448 },
+ { 0x06dc, 0x044d },
+ { 0x06dd, 0x0449 },
+ { 0x06de, 0x0447 },
+ { 0x06df, 0x044a },
+ { 0x06e0, 0x042e },
+ { 0x06e1, 0x0410 },
+ { 0x06e2, 0x0411 },
+ { 0x06e3, 0x0426 },
+ { 0x06e4, 0x0414 },
+ { 0x06e5, 0x0415 },
+ { 0x06e6, 0x0424 },
+ { 0x06e7, 0x0413 },
+ { 0x06e8, 0x0425 },
+ { 0x06e9, 0x0418 },
+ { 0x06ea, 0x0419 },
+ { 0x06eb, 0x041a },
+ { 0x06ec, 0x041b },
+ { 0x06ed, 0x041c },
+ { 0x06ee, 0x041d },
+ { 0x06ef, 0x041e },
+ { 0x06f0, 0x041f },
+ { 0x06f1, 0x042f },
+ { 0x06f2, 0x0420 },
+ { 0x06f3, 0x0421 },
+ { 0x06f4, 0x0422 },
+ { 0x06f5, 0x0423 },
+ { 0x06f6, 0x0416 },
+ { 0x06f7, 0x0412 },
+ { 0x06f8, 0x042c },
+ { 0x06f9, 0x042b },
+ { 0x06fa, 0x0417 },
+ { 0x06fb, 0x0428 },
+ { 0x06fc, 0x042d },
+ { 0x06fd, 0x0429 },
+ { 0x06fe, 0x0427 },
+ { 0x06ff, 0x042a },
+ { 0x07a1, 0x0386 },
+ { 0x07a2, 0x0388 },
+ { 0x07a3, 0x0389 },
+ { 0x07a4, 0x038a },
+ { 0x07a5, 0x03aa },
+ { 0x07a7, 0x038c },
+ { 0x07a8, 0x038e },
+ { 0x07a9, 0x03ab },
+ { 0x07ab, 0x038f },
+ { 0x07ae, 0x0385 },
+ { 0x07af, 0x2015 },
+ { 0x07b1, 0x03ac },
+ { 0x07b2, 0x03ad },
+ { 0x07b3, 0x03ae },
+ { 0x07b4, 0x03af },
+ { 0x07b5, 0x03ca },
+ { 0x07b6, 0x0390 },
+ { 0x07b7, 0x03cc },
+ { 0x07b8, 0x03cd },
+ { 0x07b9, 0x03cb },
+ { 0x07ba, 0x03b0 },
+ { 0x07bb, 0x03ce },
+ { 0x07c1, 0x0391 },
+ { 0x07c2, 0x0392 },
+ { 0x07c3, 0x0393 },
+ { 0x07c4, 0x0394 },
+ { 0x07c5, 0x0395 },
+ { 0x07c6, 0x0396 },
+ { 0x07c7, 0x0397 },
+ { 0x07c8, 0x0398 },
+ { 0x07c9, 0x0399 },
+ { 0x07ca, 0x039a },
+ { 0x07cb, 0x039b },
+ { 0x07cc, 0x039c },
+ { 0x07cd, 0x039d },
+ { 0x07ce, 0x039e },
+ { 0x07cf, 0x039f },
+ { 0x07d0, 0x03a0 },
+ { 0x07d1, 0x03a1 },
+ { 0x07d2, 0x03a3 },
+ { 0x07d4, 0x03a4 },
+ { 0x07d5, 0x03a5 },
+ { 0x07d6, 0x03a6 },
+ { 0x07d7, 0x03a7 },
+ { 0x07d8, 0x03a8 },
+ { 0x07d9, 0x03a9 },
+ { 0x07e1, 0x03b1 },
+ { 0x07e2, 0x03b2 },
+ { 0x07e3, 0x03b3 },
+ { 0x07e4, 0x03b4 },
+ { 0x07e5, 0x03b5 },
+ { 0x07e6, 0x03b6 },
+ { 0x07e7, 0x03b7 },
+ { 0x07e8, 0x03b8 },
+ { 0x07e9, 0x03b9 },
+ { 0x07ea, 0x03ba },
+ { 0x07eb, 0x03bb },
+ { 0x07ec, 0x03bc },
+ { 0x07ed, 0x03bd },
+ { 0x07ee, 0x03be },
+ { 0x07ef, 0x03bf },
+ { 0x07f0, 0x03c0 },
+ { 0x07f1, 0x03c1 },
+ { 0x07f2, 0x03c3 },
+ { 0x07f3, 0x03c2 },
+ { 0x07f4, 0x03c4 },
+ { 0x07f5, 0x03c5 },
+ { 0x07f6, 0x03c6 },
+ { 0x07f7, 0x03c7 },
+ { 0x07f8, 0x03c8 },
+ { 0x07f9, 0x03c9 },
+ { 0x08a1, 0x23b7 },
+ { 0x08a2, 0x250c },
+ { 0x08a3, 0x2500 },
+ { 0x08a4, 0x2320 },
+ { 0x08a5, 0x2321 },
+ { 0x08a6, 0x2502 },
+ { 0x08a7, 0x23a1 },
+ { 0x08a8, 0x23a3 },
+ { 0x08a9, 0x23a4 },
+ { 0x08aa, 0x23a6 },
+ { 0x08ab, 0x239b },
+ { 0x08ac, 0x239d },
+ { 0x08ad, 0x239e },
+ { 0x08ae, 0x23a0 },
+ { 0x08af, 0x23a8 },
+ { 0x08b0, 0x23ac },
+ { 0x08bc, 0x2264 },
+ { 0x08bd, 0x2260 },
+ { 0x08be, 0x2265 },
+ { 0x08bf, 0x222b },
+ { 0x08c0, 0x2234 },
+ { 0x08c1, 0x221d },
+ { 0x08c2, 0x221e },
+ { 0x08c5, 0x2207 },
+ { 0x08c8, 0x223c },
+ { 0x08c9, 0x2243 },
+ { 0x08cd, 0x21d4 },
+ { 0x08ce, 0x21d2 },
+ { 0x08cf, 0x2261 },
+ { 0x08d6, 0x221a },
+ { 0x08da, 0x2282 },
+ { 0x08db, 0x2283 },
+ { 0x08dc, 0x2229 },
+ { 0x08dd, 0x222a },
+ { 0x08de, 0x2227 },
+ { 0x08df, 0x2228 },
+ { 0x08ef, 0x2202 },
+ { 0x08f6, 0x0192 },
+ { 0x08fb, 0x2190 },
+ { 0x08fc, 0x2191 },
+ { 0x08fd, 0x2192 },
+ { 0x08fe, 0x2193 },
+ { 0x09e0, 0x25c6 },
+ { 0x09e1, 0x2592 },
+ { 0x09e2, 0x2409 },
+ { 0x09e3, 0x240c },
+ { 0x09e4, 0x240d },
+ { 0x09e5, 0x240a },
+ { 0x09e8, 0x2424 },
+ { 0x09e9, 0x240b },
+ { 0x09ea, 0x2518 },
+ { 0x09eb, 0x2510 },
+ { 0x09ec, 0x250c },
+ { 0x09ed, 0x2514 },
+ { 0x09ee, 0x253c },
+ { 0x09ef, 0x23ba },
+ { 0x09f0, 0x23bb },
+ { 0x09f1, 0x2500 },
+ { 0x09f2, 0x23bc },
+ { 0x09f3, 0x23bd },
+ { 0x09f4, 0x251c },
+ { 0x09f5, 0x2524 },
+ { 0x09f6, 0x2534 },
+ { 0x09f7, 0x252c },
+ { 0x09f8, 0x2502 },
+ { 0x0aa1, 0x2003 },
+ { 0x0aa2, 0x2002 },
+ { 0x0aa3, 0x2004 },
+ { 0x0aa4, 0x2005 },
+ { 0x0aa5, 0x2007 },
+ { 0x0aa6, 0x2008 },
+ { 0x0aa7, 0x2009 },
+ { 0x0aa8, 0x200a },
+ { 0x0aa9, 0x2014 },
+ { 0x0aaa, 0x2013 },
+ { 0x0aae, 0x2026 },
+ { 0x0aaf, 0x2025 },
+ { 0x0ab0, 0x2153 },
+ { 0x0ab1, 0x2154 },
+ { 0x0ab2, 0x2155 },
+ { 0x0ab3, 0x2156 },
+ { 0x0ab4, 0x2157 },
+ { 0x0ab5, 0x2158 },
+ { 0x0ab6, 0x2159 },
+ { 0x0ab7, 0x215a },
+ { 0x0ab8, 0x2105 },
+ { 0x0abb, 0x2012 },
+ { 0x0abc, 0x2329 },
+ { 0x0abe, 0x232a },
+ { 0x0ac3, 0x215b },
+ { 0x0ac4, 0x215c },
+ { 0x0ac5, 0x215d },
+ { 0x0ac6, 0x215e },
+ { 0x0ac9, 0x2122 },
+ { 0x0aca, 0x2613 },
+ { 0x0acc, 0x25c1 },
+ { 0x0acd, 0x25b7 },
+ { 0x0ace, 0x25cb },
+ { 0x0acf, 0x25af },
+ { 0x0ad0, 0x2018 },
+ { 0x0ad1, 0x2019 },
+ { 0x0ad2, 0x201c },
+ { 0x0ad3, 0x201d },
+ { 0x0ad4, 0x211e },
+ { 0x0ad6, 0x2032 },
+ { 0x0ad7, 0x2033 },
+ { 0x0ad9, 0x271d },
+ { 0x0adb, 0x25ac },
+ { 0x0adc, 0x25c0 },
+ { 0x0add, 0x25b6 },
+ { 0x0ade, 0x25cf },
+ { 0x0adf, 0x25ae },
+ { 0x0ae0, 0x25e6 },
+ { 0x0ae1, 0x25ab },
+ { 0x0ae2, 0x25ad },
+ { 0x0ae3, 0x25b3 },
+ { 0x0ae4, 0x25bd },
+ { 0x0ae5, 0x2606 },
+ { 0x0ae6, 0x2022 },
+ { 0x0ae7, 0x25aa },
+ { 0x0ae8, 0x25b2 },
+ { 0x0ae9, 0x25bc },
+ { 0x0aea, 0x261c },
+ { 0x0aeb, 0x261e },
+ { 0x0aec, 0x2663 },
+ { 0x0aed, 0x2666 },
+ { 0x0aee, 0x2665 },
+ { 0x0af0, 0x2720 },
+ { 0x0af1, 0x2020 },
+ { 0x0af2, 0x2021 },
+ { 0x0af3, 0x2713 },
+ { 0x0af4, 0x2717 },
+ { 0x0af5, 0x266f },
+ { 0x0af6, 0x266d },
+ { 0x0af7, 0x2642 },
+ { 0x0af8, 0x2640 },
+ { 0x0af9, 0x260e },
+ { 0x0afa, 0x2315 },
+ { 0x0afb, 0x2117 },
+ { 0x0afc, 0x2038 },
+ { 0x0afd, 0x201a },
+ { 0x0afe, 0x201e },
+ { 0x0ba3, 0x003c },
+ { 0x0ba6, 0x003e },
+ { 0x0ba8, 0x2228 },
+ { 0x0ba9, 0x2227 },
+ { 0x0bc0, 0x00af },
+ { 0x0bc2, 0x22a5 },
+ { 0x0bc3, 0x2229 },
+ { 0x0bc4, 0x230a },
+ { 0x0bc6, 0x005f },
+ { 0x0bca, 0x2218 },
+ { 0x0bcc, 0x2395 },
+ { 0x0bce, 0x22a4 },
+ { 0x0bcf, 0x25cb },
+ { 0x0bd3, 0x2308 },
+ { 0x0bd6, 0x222a },
+ { 0x0bd8, 0x2283 },
+ { 0x0bda, 0x2282 },
+ { 0x0bdc, 0x22a2 },
+ { 0x0bfc, 0x22a3 },
+ { 0x0cdf, 0x2017 },
+ { 0x0ce0, 0x05d0 },
+ { 0x0ce1, 0x05d1 },
+ { 0x0ce2, 0x05d2 },
+ { 0x0ce3, 0x05d3 },
+ { 0x0ce4, 0x05d4 },
+ { 0x0ce5, 0x05d5 },
+ { 0x0ce6, 0x05d6 },
+ { 0x0ce7, 0x05d7 },
+ { 0x0ce8, 0x05d8 },
+ { 0x0ce9, 0x05d9 },
+ { 0x0cea, 0x05da },
+ { 0x0ceb, 0x05db },
+ { 0x0cec, 0x05dc },
+ { 0x0ced, 0x05dd },
+ { 0x0cee, 0x05de },
+ { 0x0cef, 0x05df },
+ { 0x0cf0, 0x05e0 },
+ { 0x0cf1, 0x05e1 },
+ { 0x0cf2, 0x05e2 },
+ { 0x0cf3, 0x05e3 },
+ { 0x0cf4, 0x05e4 },
+ { 0x0cf5, 0x05e5 },
+ { 0x0cf6, 0x05e6 },
+ { 0x0cf7, 0x05e7 },
+ { 0x0cf8, 0x05e8 },
+ { 0x0cf9, 0x05e9 },
+ { 0x0cfa, 0x05ea },
+ { 0x0da1, 0x0e01 },
+ { 0x0da2, 0x0e02 },
+ { 0x0da3, 0x0e03 },
+ { 0x0da4, 0x0e04 },
+ { 0x0da5, 0x0e05 },
+ { 0x0da6, 0x0e06 },
+ { 0x0da7, 0x0e07 },
+ { 0x0da8, 0x0e08 },
+ { 0x0da9, 0x0e09 },
+ { 0x0daa, 0x0e0a },
+ { 0x0dab, 0x0e0b },
+ { 0x0dac, 0x0e0c },
+ { 0x0dad, 0x0e0d },
+ { 0x0dae, 0x0e0e },
+ { 0x0daf, 0x0e0f },
+ { 0x0db0, 0x0e10 },
+ { 0x0db1, 0x0e11 },
+ { 0x0db2, 0x0e12 },
+ { 0x0db3, 0x0e13 },
+ { 0x0db4, 0x0e14 },
+ { 0x0db5, 0x0e15 },
+ { 0x0db6, 0x0e16 },
+ { 0x0db7, 0x0e17 },
+ { 0x0db8, 0x0e18 },
+ { 0x0db9, 0x0e19 },
+ { 0x0dba, 0x0e1a },
+ { 0x0dbb, 0x0e1b },
+ { 0x0dbc, 0x0e1c },
+ { 0x0dbd, 0x0e1d },
+ { 0x0dbe, 0x0e1e },
+ { 0x0dbf, 0x0e1f },
+ { 0x0dc0, 0x0e20 },
+ { 0x0dc1, 0x0e21 },
+ { 0x0dc2, 0x0e22 },
+ { 0x0dc3, 0x0e23 },
+ { 0x0dc4, 0x0e24 },
+ { 0x0dc5, 0x0e25 },
+ { 0x0dc6, 0x0e26 },
+ { 0x0dc7, 0x0e27 },
+ { 0x0dc8, 0x0e28 },
+ { 0x0dc9, 0x0e29 },
+ { 0x0dca, 0x0e2a },
+ { 0x0dcb, 0x0e2b },
+ { 0x0dcc, 0x0e2c },
+ { 0x0dcd, 0x0e2d },
+ { 0x0dce, 0x0e2e },
+ { 0x0dcf, 0x0e2f },
+ { 0x0dd0, 0x0e30 },
+ { 0x0dd1, 0x0e31 },
+ { 0x0dd2, 0x0e32 },
+ { 0x0dd3, 0x0e33 },
+ { 0x0dd4, 0x0e34 },
+ { 0x0dd5, 0x0e35 },
+ { 0x0dd6, 0x0e36 },
+ { 0x0dd7, 0x0e37 },
+ { 0x0dd8, 0x0e38 },
+ { 0x0dd9, 0x0e39 },
+ { 0x0dda, 0x0e3a },
+ { 0x0ddf, 0x0e3f },
+ { 0x0de0, 0x0e40 },
+ { 0x0de1, 0x0e41 },
+ { 0x0de2, 0x0e42 },
+ { 0x0de3, 0x0e43 },
+ { 0x0de4, 0x0e44 },
+ { 0x0de5, 0x0e45 },
+ { 0x0de6, 0x0e46 },
+ { 0x0de7, 0x0e47 },
+ { 0x0de8, 0x0e48 },
+ { 0x0de9, 0x0e49 },
+ { 0x0dea, 0x0e4a },
+ { 0x0deb, 0x0e4b },
+ { 0x0dec, 0x0e4c },
+ { 0x0ded, 0x0e4d },
+ { 0x0df0, 0x0e50 },
+ { 0x0df1, 0x0e51 },
+ { 0x0df2, 0x0e52 },
+ { 0x0df3, 0x0e53 },
+ { 0x0df4, 0x0e54 },
+ { 0x0df5, 0x0e55 },
+ { 0x0df6, 0x0e56 },
+ { 0x0df7, 0x0e57 },
+ { 0x0df8, 0x0e58 },
+ { 0x0df9, 0x0e59 },
+ { 0x0ea1, 0x3131 },
+ { 0x0ea2, 0x3132 },
+ { 0x0ea3, 0x3133 },
+ { 0x0ea4, 0x3134 },
+ { 0x0ea5, 0x3135 },
+ { 0x0ea6, 0x3136 },
+ { 0x0ea7, 0x3137 },
+ { 0x0ea8, 0x3138 },
+ { 0x0ea9, 0x3139 },
+ { 0x0eaa, 0x313a },
+ { 0x0eab, 0x313b },
+ { 0x0eac, 0x313c },
+ { 0x0ead, 0x313d },
+ { 0x0eae, 0x313e },
+ { 0x0eaf, 0x313f },
+ { 0x0eb0, 0x3140 },
+ { 0x0eb1, 0x3141 },
+ { 0x0eb2, 0x3142 },
+ { 0x0eb3, 0x3143 },
+ { 0x0eb4, 0x3144 },
+ { 0x0eb5, 0x3145 },
+ { 0x0eb6, 0x3146 },
+ { 0x0eb7, 0x3147 },
+ { 0x0eb8, 0x3148 },
+ { 0x0eb9, 0x3149 },
+ { 0x0eba, 0x314a },
+ { 0x0ebb, 0x314b },
+ { 0x0ebc, 0x314c },
+ { 0x0ebd, 0x314d },
+ { 0x0ebe, 0x314e },
+ { 0x0ebf, 0x314f },
+ { 0x0ec0, 0x3150 },
+ { 0x0ec1, 0x3151 },
+ { 0x0ec2, 0x3152 },
+ { 0x0ec3, 0x3153 },
+ { 0x0ec4, 0x3154 },
+ { 0x0ec5, 0x3155 },
+ { 0x0ec6, 0x3156 },
+ { 0x0ec7, 0x3157 },
+ { 0x0ec8, 0x3158 },
+ { 0x0ec9, 0x3159 },
+ { 0x0eca, 0x315a },
+ { 0x0ecb, 0x315b },
+ { 0x0ecc, 0x315c },
+ { 0x0ecd, 0x315d },
+ { 0x0ece, 0x315e },
+ { 0x0ecf, 0x315f },
+ { 0x0ed0, 0x3160 },
+ { 0x0ed1, 0x3161 },
+ { 0x0ed2, 0x3162 },
+ { 0x0ed3, 0x3163 },
+ { 0x0ed4, 0x11a8 },
+ { 0x0ed5, 0x11a9 },
+ { 0x0ed6, 0x11aa },
+ { 0x0ed7, 0x11ab },
+ { 0x0ed8, 0x11ac },
+ { 0x0ed9, 0x11ad },
+ { 0x0eda, 0x11ae },
+ { 0x0edb, 0x11af },
+ { 0x0edc, 0x11b0 },
+ { 0x0edd, 0x11b1 },
+ { 0x0ede, 0x11b2 },
+ { 0x0edf, 0x11b3 },
+ { 0x0ee0, 0x11b4 },
+ { 0x0ee1, 0x11b5 },
+ { 0x0ee2, 0x11b6 },
+ { 0x0ee3, 0x11b7 },
+ { 0x0ee4, 0x11b8 },
+ { 0x0ee5, 0x11b9 },
+ { 0x0ee6, 0x11ba },
+ { 0x0ee7, 0x11bb },
+ { 0x0ee8, 0x11bc },
+ { 0x0ee9, 0x11bd },
+ { 0x0eea, 0x11be },
+ { 0x0eeb, 0x11bf },
+ { 0x0eec, 0x11c0 },
+ { 0x0eed, 0x11c1 },
+ { 0x0eee, 0x11c2 },
+ { 0x0eef, 0x316d },
+ { 0x0ef0, 0x3171 },
+ { 0x0ef1, 0x3178 },
+ { 0x0ef2, 0x317f },
+ { 0x0ef3, 0x3181 },
+ { 0x0ef4, 0x3184 },
+ { 0x0ef5, 0x3186 },
+ { 0x0ef6, 0x318d },
+ { 0x0ef7, 0x318e },
+ { 0x0ef8, 0x11eb },
+ { 0x0ef9, 0x11f0 },
+ { 0x0efa, 0x11f9 },
+ { 0x0eff, 0x20a9 },
+#if 0
+ /* FIXME: there is no keysym 0x13a4? But 0x20ac is EuroSign in both
+ keysym and Unicode */
+ { 0x13a4, 0x20ac },
+#endif
+ { 0x13bc, 0x0152 },
+ { 0x13bd, 0x0153 },
+ { 0x13be, 0x0178 },
+ { 0x20ac, 0x20ac },
+
+ /* Special function keys. */
+
+ { 0xff08, 0x0008 }, /* XK_BackSpace */
+ { 0xff09, 0x0009 }, /* XK_Tab */
+ { 0xff0a, 0x000a }, /* XK_Linefeed */
+ { 0xff0d, 0x000d }, /* XK_Return */
+ { 0xff13, 0x0013 }, /* XK_Pause */
+ { 0xff1b, 0x001b }, /* XK_Escape */
+ { 0xff50, 0x0001 }, /* XK_Home */
+ { 0xff51, 0x001c }, /* XK_Left */
+ { 0xff52, 0x001e }, /* XK_Up */
+ { 0xff53, 0x001d }, /* XK_Right */
+ { 0xff54, 0x001f }, /* XK_Down */
+ { 0xff55, 0x000b }, /* XK_Prior */
+ { 0xff56, 0x000c }, /* XK_Next */
+ { 0xff57, 0x0004 }, /* XK_End */
+ { 0xff6a, 0x0005 }, /* XK_Help */
+ { 0xffff, 0x007f }, /* XK_Delete */
+};
+
+long keysym2ucs(int keysym)
+{
+ int min = 0;
+ int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
+ int mid;
+
+ /* first check for Latin-1 characters (1:1 mapping) */
+ if ((keysym >= 0x0020 && keysym <= 0x007e) ||
+ (keysym >= 0x00a0 && keysym <= 0x00ff))
+ return keysym;
+
+ /* also check for directly encoded 24-bit UCS characters */
+ if ((keysym & 0xff000000) == 0x01000000)
+ return keysym & 0x00ffffff;
+
+ /* binary search in table */
+ while (max >= min) {
+ mid = (min + max) / 2;
+ if (keysymtab[mid].keysym < keysym)
+ min = mid + 1;
+ else if (keysymtab[mid].keysym > keysym)
+ max = mid - 1;
+ else {
+ /* found it */
+ return keysymtab[mid].ucs;
+ }
+ }
+
+ /* no matching Unicode value found */
+ return -1;
+}
+
+static int reverse_compare (const void *a, const void *b)
+{
+ const struct codepair *ca = a, *cb = b;
+
+ return ca->ucs - cb->ucs;
+}
+
+int ucs2keysym(long ucs)
+{
+ static struct codepair *reverse_keysymtab;
+
+ int min = 0;
+ int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
+ int mid;
+
+ if (reverse_keysymtab == NULL)
+ {
+ reverse_keysymtab = malloc (sizeof (keysymtab));
+ memcpy (reverse_keysymtab, keysymtab, sizeof (keysymtab));
+
+ qsort (reverse_keysymtab,
+ sizeof (keysymtab) / sizeof (struct codepair),
+ sizeof (struct codepair),
+ reverse_compare);
+ }
+
+ /* first check for Latin-1 characters (1:1 mapping) */
+ if ((ucs >= 0x0020 && ucs <= 0x007e) ||
+ (ucs >= 0x00a0 && ucs <= 0x00ff))
+ return ucs;
+
+ /* binary search in table */
+ while (max >= min) {
+ mid = (min + max) / 2;
+ if (reverse_keysymtab[mid].ucs < ucs)
+ min = mid + 1;
+ else if (reverse_keysymtab[mid].ucs > ucs)
+ max = mid - 1;
+ else {
+ /* found it */
+ return reverse_keysymtab[mid].keysym;
+ }
+ }
+
+ /* finally, assume a directly encoded 24-bit UCS character */
+ return ucs | 0x01000000;
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/keysym2ucs.h b/nx-X11/programs/Xserver/hw/darwin/quartz/keysym2ucs.h
new file mode 100644
index 000000000..c7ff6f3b3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/keysym2ucs.h
@@ -0,0 +1,37 @@
+/* $XFree86: $
+ *
+ * This module converts keysym values into the corresponding ISO 10646
+ * (UCS, Unicode) values.
+ *
+ * The array keysymtab[] contains pairs of X11 keysym values for graphical
+ * characters and the corresponding Unicode value. The function
+ * keysym2ucs() maps a keysym onto a Unicode value using a binary search,
+ * therefore keysymtab[] must remain SORTED by keysym value.
+ *
+ * The keysym -> UTF-8 conversion will hopefully one day be provided
+ * by Xlib via XmbLookupString() and should ideally not have to be
+ * done in X applications. But we are not there yet.
+ *
+ * We allow to represent any UCS character in the range U-00000000 to
+ * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
+ * This admittedly does not cover the entire 31-bit space of UCS, but
+ * it does cover all of the characters up to U-10FFFF, which can be
+ * represented by UTF-16, and more, and it is very unlikely that higher
+ * UCS codes will ever be assigned by ISO. So to get Unicode character
+ * U+ABCD you can directly use keysym 0x0100abcd.
+ *
+ * Author: Markus G. Kuhn <mkuhn@acm.org>, University of Cambridge, April 2001
+ *
+ * Special thanks to Richard Verhoeven <river@win.tue.nl> for preparing
+ * an initial draft of the mapping table.
+ *
+ * This software is in the public domain. Share and enjoy!
+ */
+
+#ifndef KEYSYM2UCS_H
+#define KEYSYM2UCS_H 1
+
+extern long keysym2ucs(int keysym);
+extern int ucs2keysym(long ucs);
+
+#endif /* KEYSYM2UCS_H */
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/pseudoramiX.c b/nx-X11/programs/Xserver/hw/darwin/quartz/pseudoramiX.c
new file mode 100644
index 000000000..71093f5fb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/pseudoramiX.c
@@ -0,0 +1,430 @@
+/*
+ * Minimal implementation of PanoramiX/Xinerama
+ *
+ * This is used in rootless mode where the underlying window server
+ * already provides an abstracted view of multiple screens as one
+ * large screen area.
+ *
+ * This code is largely based on panoramiX.c, which contains the
+ * following copyright notice:
+ */
+/*****************************************************************
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.c,v 1.4 2004/07/02 01:30:33 torrey Exp $ */
+
+#include "pseudoramiX.h"
+
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "window.h"
+#include <X11/extensions/panoramiXproto.h>
+#include "globals.h"
+
+extern int ProcPanoramiXQueryVersion (ClientPtr client);
+
+static void PseudoramiXResetProc(ExtensionEntry *extEntry);
+
+static int ProcPseudoramiXQueryVersion(ClientPtr client);
+static int ProcPseudoramiXGetState(ClientPtr client);
+static int ProcPseudoramiXGetScreenCount(ClientPtr client);
+static int ProcPseudoramiXGetScreenSize(ClientPtr client);
+static int ProcPseudoramiXIsActive(ClientPtr client);
+static int ProcPseudoramiXQueryScreens(ClientPtr client);
+static int ProcPseudoramiXDispatch(ClientPtr client);
+
+static int SProcPseudoramiXQueryVersion(ClientPtr client);
+static int SProcPseudoramiXGetState(ClientPtr client);
+static int SProcPseudoramiXGetScreenCount(ClientPtr client);
+static int SProcPseudoramiXGetScreenSize(ClientPtr client);
+static int SProcPseudoramiXIsActive(ClientPtr client);
+static int SProcPseudoramiXQueryScreens(ClientPtr client);
+static int SProcPseudoramiXDispatch(ClientPtr client);
+
+
+typedef struct {
+ int x;
+ int y;
+ int w;
+ int h;
+} PseudoramiXScreenRec;
+
+static PseudoramiXScreenRec *pseudoramiXScreens = NULL;
+static int pseudoramiXScreensAllocated = 0;
+static int pseudoramiXNumScreens = 0;
+static unsigned long pseudoramiXGeneration = 0;
+
+
+// Add a PseudoramiX screen.
+// The rest of the X server will know nothing about this screen.
+// Can be called before or after extension init.
+// Screens must be re-added once per generation.
+void
+PseudoramiXAddScreen(int x, int y, int w, int h)
+{
+ PseudoramiXScreenRec *s;
+
+ if (noPseudoramiXExtension) return;
+
+ if (pseudoramiXNumScreens == pseudoramiXScreensAllocated) {
+ pseudoramiXScreensAllocated += pseudoramiXScreensAllocated + 1;
+ pseudoramiXScreens = xrealloc(pseudoramiXScreens,
+ pseudoramiXScreensAllocated *
+ sizeof(PseudoramiXScreenRec));
+ }
+
+ s = &pseudoramiXScreens[pseudoramiXNumScreens++];
+ s->x = x;
+ s->y = y;
+ s->w = w;
+ s->h = h;
+}
+
+
+// Initialize PseudoramiX.
+// Copied from PanoramiXExtensionInit
+void PseudoramiXExtensionInit(int argc, char *argv[])
+{
+ Bool success = FALSE;
+ ExtensionEntry *extEntry;
+
+ if (noPseudoramiXExtension) return;
+
+ /* Even with only one screen we need to enable PseudoramiX to allow
+ dynamic screen configuration changes. */
+#if 0
+ if (pseudoramiXNumScreens == 1) {
+ // Only one screen - disable Xinerama extension.
+ noPseudoramiXExtension = TRUE;
+ return;
+ }
+#endif
+
+ // The server must not run the PanoramiX operations.
+ noPanoramiXExtension = TRUE;
+
+ if (pseudoramiXGeneration != serverGeneration) {
+ extEntry = AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0,
+ ProcPseudoramiXDispatch,
+ SProcPseudoramiXDispatch,
+ PseudoramiXResetProc,
+ StandardMinorOpcode);
+ if (!extEntry) {
+ ErrorF("PseudoramiXExtensionInit(): AddExtension failed\n");
+ } else {
+ pseudoramiXGeneration = serverGeneration;
+ success = TRUE;
+ }
+ }
+
+ if (!success) {
+ ErrorF("%s Extension (PseudoramiX) failed to initialize\n",
+ PANORAMIX_PROTOCOL_NAME);
+ return;
+ }
+}
+
+
+void PseudoramiXResetScreens(void)
+{
+ pseudoramiXNumScreens = 0;
+}
+
+
+static void PseudoramiXResetProc(ExtensionEntry *extEntry)
+{
+ PseudoramiXResetScreens();
+}
+
+
+// was PanoramiX
+static int ProcPseudoramiXQueryVersion(ClientPtr client)
+{
+ return ProcPanoramiXQueryVersion(client);
+}
+
+
+// was PanoramiX
+static int ProcPseudoramiXGetState(ClientPtr client)
+{
+ REQUEST(xPanoramiXGetStateReq);
+ WindowPtr pWin;
+ xPanoramiXGetStateReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
+ pWin = LookupWindow (stuff->window, client);
+ if (!pWin)
+ return BadWindow;
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.state = !noPseudoramiXExtension;
+ if (client->swapped) {
+ swaps (&rep.sequenceNumber, n);
+ swapl (&rep.length, n);
+ swaps (&rep.state, n);
+ }
+ WriteToClient (client, sizeof (xPanoramiXGetStateReply), (char *) &rep);
+ return client->noClientException;
+}
+
+
+// was PanoramiX
+static int ProcPseudoramiXGetScreenCount(ClientPtr client)
+{
+ REQUEST(xPanoramiXGetScreenCountReq);
+ WindowPtr pWin;
+ xPanoramiXGetScreenCountReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
+ pWin = LookupWindow (stuff->window, client);
+ if (!pWin)
+ return BadWindow;
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.ScreenCount = pseudoramiXNumScreens;
+ if (client->swapped) {
+ swaps (&rep.sequenceNumber, n);
+ swapl (&rep.length, n);
+ swaps (&rep.ScreenCount, n);
+ }
+ WriteToClient (client, sizeof(xPanoramiXGetScreenCountReply), (char *)&rep);
+ return client->noClientException;
+}
+
+
+// was PanoramiX
+static int ProcPseudoramiXGetScreenSize(ClientPtr client)
+{
+ REQUEST(xPanoramiXGetScreenSizeReq);
+ WindowPtr pWin;
+ xPanoramiXGetScreenSizeReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+ pWin = LookupWindow (stuff->window, client);
+ if (!pWin)
+ return BadWindow;
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ /* screen dimensions */
+ rep.width = pseudoramiXScreens[stuff->screen].w;
+ // was panoramiXdataPtr[stuff->screen].width;
+ rep.height = pseudoramiXScreens[stuff->screen].h;
+ // was panoramiXdataPtr[stuff->screen].height;
+ if (client->swapped) {
+ swaps (&rep.sequenceNumber, n);
+ swapl (&rep.length, n);
+ swaps (&rep.width, n);
+ swaps (&rep.height, n);
+ }
+ WriteToClient (client, sizeof(xPanoramiXGetScreenSizeReply), (char *)&rep);
+ return client->noClientException;
+}
+
+
+// was Xinerama
+static int ProcPseudoramiXIsActive(ClientPtr client)
+{
+ /* REQUEST(xXineramaIsActiveReq); */
+ xXineramaIsActiveReply rep;
+
+ REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.state = !noPseudoramiXExtension;
+ if (client->swapped) {
+ register int n;
+ swaps (&rep.sequenceNumber, n);
+ swapl (&rep.length, n);
+ swapl (&rep.state, n);
+ }
+ WriteToClient (client, sizeof (xXineramaIsActiveReply), (char *) &rep);
+ return client->noClientException;
+}
+
+
+// was Xinerama
+static int ProcPseudoramiXQueryScreens(ClientPtr client)
+{
+ /* REQUEST(xXineramaQueryScreensReq); */
+ xXineramaQueryScreensReply rep;
+
+ REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.number = noPseudoramiXExtension ? 0 : pseudoramiXNumScreens;
+ rep.length = rep.number * sz_XineramaScreenInfo >> 2;
+ if (client->swapped) {
+ register int n;
+ swaps (&rep.sequenceNumber, n);
+ swapl (&rep.length, n);
+ swapl (&rep.number, n);
+ }
+ WriteToClient (client, sizeof (xXineramaQueryScreensReply), (char *) &rep);
+
+ if (!noPseudoramiXExtension) {
+ xXineramaScreenInfo scratch;
+ int i;
+
+ for(i = 0; i < pseudoramiXNumScreens; i++) {
+ scratch.x_org = pseudoramiXScreens[i].x;
+ scratch.y_org = pseudoramiXScreens[i].y;
+ scratch.width = pseudoramiXScreens[i].w;
+ scratch.height = pseudoramiXScreens[i].h;
+
+ if(client->swapped) {
+ register int n;
+ swaps (&scratch.x_org, n);
+ swaps (&scratch.y_org, n);
+ swaps (&scratch.width, n);
+ swaps (&scratch.height, n);
+ }
+ WriteToClient (client, sz_XineramaScreenInfo, (char *) &scratch);
+ }
+ }
+
+ return client->noClientException;
+}
+
+
+// was PanoramiX
+static int ProcPseudoramiXDispatch (ClientPtr client)
+{ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_PanoramiXQueryVersion:
+ return ProcPseudoramiXQueryVersion(client);
+ case X_PanoramiXGetState:
+ return ProcPseudoramiXGetState(client);
+ case X_PanoramiXGetScreenCount:
+ return ProcPseudoramiXGetScreenCount(client);
+ case X_PanoramiXGetScreenSize:
+ return ProcPseudoramiXGetScreenSize(client);
+ case X_XineramaIsActive:
+ return ProcPseudoramiXIsActive(client);
+ case X_XineramaQueryScreens:
+ return ProcPseudoramiXQueryScreens(client);
+ }
+ return BadRequest;
+}
+
+
+
+static int
+SProcPseudoramiXQueryVersion (ClientPtr client)
+{
+ REQUEST(xPanoramiXQueryVersionReq);
+ register int n;
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq);
+ return ProcPseudoramiXQueryVersion(client);
+}
+
+static int
+SProcPseudoramiXGetState(ClientPtr client)
+{
+ REQUEST(xPanoramiXGetStateReq);
+ register int n;
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
+ return ProcPseudoramiXGetState(client);
+}
+
+static int
+SProcPseudoramiXGetScreenCount(ClientPtr client)
+{
+ REQUEST(xPanoramiXGetScreenCountReq);
+ register int n;
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
+ return ProcPseudoramiXGetScreenCount(client);
+}
+
+static int
+SProcPseudoramiXGetScreenSize(ClientPtr client)
+{
+ REQUEST(xPanoramiXGetScreenSizeReq);
+ register int n;
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+ return ProcPseudoramiXGetScreenSize(client);
+}
+
+
+static int
+SProcPseudoramiXIsActive(ClientPtr client)
+{
+ REQUEST(xXineramaIsActiveReq);
+ register int n;
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
+ return ProcPseudoramiXIsActive(client);
+}
+
+
+static int
+SProcPseudoramiXQueryScreens(ClientPtr client)
+{
+ REQUEST(xXineramaQueryScreensReq);
+ register int n;
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
+ return ProcPseudoramiXQueryScreens(client);
+}
+
+
+static int
+SProcPseudoramiXDispatch (ClientPtr client)
+{ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_PanoramiXQueryVersion:
+ return SProcPseudoramiXQueryVersion(client);
+ case X_PanoramiXGetState:
+ return SProcPseudoramiXGetState(client);
+ case X_PanoramiXGetScreenCount:
+ return SProcPseudoramiXGetScreenCount(client);
+ case X_PanoramiXGetScreenSize:
+ return SProcPseudoramiXGetScreenSize(client);
+ case X_XineramaIsActive:
+ return SProcPseudoramiXIsActive(client);
+ case X_XineramaQueryScreens:
+ return SProcPseudoramiXQueryScreens(client);
+ }
+ return BadRequest;
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/pseudoramiX.h b/nx-X11/programs/Xserver/hw/darwin/quartz/pseudoramiX.h
new file mode 100644
index 000000000..c2943369d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/pseudoramiX.h
@@ -0,0 +1,10 @@
+/*
+ * Minimal implementation of PanoramiX/Xinerama
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.h,v 1.3 2004/07/02 01:30:33 torrey Exp $ */
+
+extern int noPseudoramiXExtension;
+
+void PseudoramiXAddScreen(int x, int y, int w, int h);
+void PseudoramiXExtensionInit(int argc, char *argv[]);
+void PseudoramiXResetScreens(void);
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/quartz.c b/nx-X11/programs/Xserver/hw/darwin/quartz/quartz.c
new file mode 100644
index 000000000..7a0155f98
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/quartz.c
@@ -0,0 +1,426 @@
+/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartz.c,v 1.4 2005/07/01 22:43:07 daniels Exp $ */
+/**************************************************************
+ *
+ * Quartz-specific support for the Darwin X Server
+ *
+ **************************************************************/
+/*
+ * Copyright (c) 2001-2004 Greg Parker and Torrey T. Lyons.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.c,v 1.16 2004/07/02 01:30:33 torrey Exp $ */
+
+#include "quartzCommon.h"
+#include "quartz.h"
+#include "darwin.h"
+#include "quartzAudio.h"
+#include "pseudoramiX.h"
+#define _APPLEWM_SERVER_
+#include "applewm.h"
+#include "applewmExt.h"
+
+// X headers
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "colormapst.h"
+#include "globals.h"
+
+// System headers
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <IOKit/pwr_mgt/IOPMLib.h>
+
+// Shared global variables for Quartz modes
+int quartzEventWriteFD = -1;
+int quartzStartClients = 1;
+int quartzRootless = -1;
+int quartzUseSysBeep = 0;
+int quartzUseAGL = 1;
+int quartzEnableKeyEquivalents = 1;
+int quartzServerVisible = TRUE;
+int quartzServerQuitting = FALSE;
+int quartzScreenIndex = 0;
+int aquaMenuBarHeight = 0;
+int noPseudoramiXExtension = TRUE;
+QuartzModeProcsPtr quartzProcs = NULL;
+const char *quartzOpenGLBundle = NULL;
+
+/*
+===========================================================================
+
+ Screen functions
+
+===========================================================================
+*/
+
+/*
+ * DarwinModeAddScreen
+ * Do mode dependent initialization of each screen for Quartz.
+ */
+Bool DarwinModeAddScreen(
+ int index,
+ ScreenPtr pScreen)
+{
+ // allocate space for private per screen Quartz specific storage
+ QuartzScreenPtr displayInfo = xcalloc(sizeof(QuartzScreenRec), 1);
+ QUARTZ_PRIV(pScreen) = displayInfo;
+
+ // do Quartz mode specific initialization
+ return quartzProcs->AddScreen(index, pScreen);
+}
+
+
+/*
+ * DarwinModeSetupScreen
+ * Finalize mode specific setup of each screen.
+ */
+Bool DarwinModeSetupScreen(
+ int index,
+ ScreenPtr pScreen)
+{
+ // do Quartz mode specific setup
+ if (! quartzProcs->SetupScreen(index, pScreen))
+ return FALSE;
+
+ // setup cursor support
+ if (! quartzProcs->InitCursor(pScreen))
+ return FALSE;
+
+ return TRUE;
+}
+
+
+/*
+ * DarwinModeInitOutput
+ * Quartz display initialization.
+ */
+void DarwinModeInitOutput(
+ int argc,
+ char **argv )
+{
+ static unsigned long generation = 0;
+
+ // Allocate private storage for each screen's Quartz specific info
+ if (generation != serverGeneration) {
+ quartzScreenIndex = AllocateScreenPrivateIndex();
+ generation = serverGeneration;
+ }
+
+ if (serverGeneration == 0) {
+ QuartzAudioInit();
+ }
+
+ if (!RegisterBlockAndWakeupHandlers(QuartzBlockHandler,
+ QuartzWakeupHandler,
+ NULL))
+ {
+ FatalError("Could not register block and wakeup handlers.");
+ }
+
+ // Do display mode specific initialization
+ quartzProcs->DisplayInit();
+
+ // Init PseudoramiX implementation of Xinerama.
+ // This should be in InitExtensions, but that causes link errors
+ // for servers that don't link in pseudoramiX.c.
+ if (!noPseudoramiXExtension) {
+ PseudoramiXExtensionInit(argc, argv);
+ }
+}
+
+
+/*
+ * DarwinModeInitInput
+ * Inform the main thread the X server is ready to handle events.
+ */
+void DarwinModeInitInput(
+ int argc,
+ char **argv )
+{
+ QuartzMessageMainThread(kQuartzServerStarted, NULL, 0);
+
+ // Do final display mode specific initialization before handling events
+ if (quartzProcs->InitInput)
+ quartzProcs->InitInput(argc, argv);
+}
+
+
+/*
+ * QuartzUpdateScreens
+ * Adjust for screen arrangement changes.
+ */
+static void QuartzUpdateScreens(void)
+{
+ ScreenPtr pScreen;
+ WindowPtr pRoot;
+ int x, y, width, height, sx, sy;
+ xEvent e;
+
+ if (noPseudoramiXExtension || screenInfo.numScreens != 1)
+ {
+ /* FIXME: if not using Xinerama, we have multiple screens, and
+ to do this properly may need to add or remove screens. Which
+ isn't possible. So don't do anything. Another reason why
+ we default to running with Xinerama. */
+
+ return;
+ }
+
+ pScreen = screenInfo.screens[0];
+
+ PseudoramiXResetScreens();
+ quartzProcs->AddPseudoramiXScreens(&x, &y, &width, &height);
+
+ dixScreenOrigins[pScreen->myNum].x = x;
+ dixScreenOrigins[pScreen->myNum].y = y;
+ pScreen->mmWidth = pScreen->mmWidth * ((double) width / pScreen->width);
+ pScreen->mmHeight = pScreen->mmHeight * ((double) height / pScreen->height);
+ pScreen->width = width;
+ pScreen->height = height;
+
+ /* FIXME: should probably do something with RandR here. */
+
+ DarwinAdjustScreenOrigins(&screenInfo);
+ quartzProcs->UpdateScreen(pScreen);
+
+ sx = dixScreenOrigins[pScreen->myNum].x + darwinMainScreenX;
+ sy = dixScreenOrigins[pScreen->myNum].y + darwinMainScreenY;
+
+ /* Adjust the root window. */
+ pRoot = WindowTable[pScreen->myNum];
+ AppleWMSetScreenOrigin(pRoot);
+ pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL);
+ pScreen->PaintWindowBackground(pRoot, &pRoot->borderClip, PW_BACKGROUND);
+// QuartzIgnoreNextWarpCursor();
+ DefineInitialRootWindow(pRoot);
+
+ /* Send an event for the root reconfigure */
+ e.u.u.type = ConfigureNotify;
+ e.u.configureNotify.window = pRoot->drawable.id;
+ e.u.configureNotify.aboveSibling = None;
+ e.u.configureNotify.x = x - sx;
+ e.u.configureNotify.y = y - sy;
+ e.u.configureNotify.width = width;
+ e.u.configureNotify.height = height;
+ e.u.configureNotify.borderWidth = wBorderWidth(pRoot);
+ e.u.configureNotify.override = pRoot->overrideRedirect;
+ DeliverEvents(pRoot, &e, 1, NullWindow);
+
+ /* FIXME: Should we use RREditConnectionInfo(pScreen)? */
+}
+
+
+/*
+ * QuartzShow
+ * Show the X server on screen. Does nothing if already shown.
+ * Calls mode specific screen resume to restore the X clip regions
+ * (if needed) and the X server cursor state.
+ */
+static void QuartzShow(
+ int x, // cursor location
+ int y )
+{
+ int i;
+
+ if (!quartzServerVisible) {
+ quartzServerVisible = TRUE;
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ if (screenInfo.screens[i]) {
+ quartzProcs->ResumeScreen(screenInfo.screens[i], x, y);
+ }
+ }
+ }
+}
+
+
+/*
+ * QuartzHide
+ * Remove the X server display from the screen. Does nothing if already
+ * hidden. Calls mode specific screen suspend to set X clip regions to
+ * prevent drawing (if needed) and restore the Aqua cursor.
+ */
+static void QuartzHide(void)
+{
+ int i;
+
+ if (quartzServerVisible) {
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ if (screenInfo.screens[i]) {
+ quartzProcs->SuspendScreen(screenInfo.screens[i]);
+ }
+ }
+ }
+ quartzServerVisible = FALSE;
+ QuartzMessageMainThread(kQuartzServerHidden, NULL, 0);
+}
+
+
+/*
+ * QuartzSetRootClip
+ * Enable or disable rendering to the X screen.
+ */
+static void QuartzSetRootClip(
+ BOOL enable)
+{
+ int i;
+
+ if (!quartzServerVisible)
+ return;
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ if (screenInfo.screens[i]) {
+ xf86SetRootClip(screenInfo.screens[i], enable);
+ }
+ }
+}
+
+
+/*
+ * QuartzMessageServerThread
+ * Send the X server thread a message by placing it on the event queue.
+ */
+void
+QuartzMessageServerThread(
+ int type,
+ int argc, ...)
+{
+ xEvent xe;
+ INT32 *argv;
+ int i, max_args;
+ va_list args;
+
+ memset(&xe, 0, sizeof(xe));
+ xe.u.u.type = type;
+ xe.u.clientMessage.u.l.type = type;
+
+ argv = &xe.u.clientMessage.u.l.longs0;
+ max_args = 4;
+
+ if (argc > 0 && argc <= max_args) {
+ va_start (args, argc);
+ for (i = 0; i < argc; i++)
+ argv[i] = (int) va_arg (args, int);
+ va_end (args);
+ }
+
+ DarwinEQEnqueue(&xe);
+}
+
+
+/*
+ * DarwinModeProcessEvent
+ * Process Quartz specific events.
+ */
+void DarwinModeProcessEvent(
+ xEvent *xe)
+{
+ switch (xe->u.u.type) {
+
+ case kXDarwinActivate:
+ QuartzShow(xe->u.keyButtonPointer.rootX,
+ xe->u.keyButtonPointer.rootY);
+ AppleWMSendEvent(AppleWMActivationNotify,
+ AppleWMActivationNotifyMask,
+ AppleWMIsActive, 0);
+ break;
+
+ case kXDarwinDeactivate:
+ AppleWMSendEvent(AppleWMActivationNotify,
+ AppleWMActivationNotifyMask,
+ AppleWMIsInactive, 0);
+ QuartzHide();
+ break;
+
+ case kXDarwinSetRootClip:
+ QuartzSetRootClip((BOOL)xe->u.clientMessage.u.l.longs0);
+ break;
+
+ case kXDarwinQuit:
+ GiveUp(0);
+ break;
+
+ case kXDarwinReadPasteboard:
+ QuartzReadPasteboard();
+ break;
+
+ case kXDarwinWritePasteboard:
+ QuartzWritePasteboard();
+ break;
+
+ /*
+ * AppleWM events
+ */
+ case kXDarwinControllerNotify:
+ AppleWMSendEvent(AppleWMControllerNotify,
+ AppleWMControllerNotifyMask,
+ xe->u.clientMessage.u.l.longs0,
+ xe->u.clientMessage.u.l.longs1);
+ break;
+
+ case kXDarwinPasteboardNotify:
+ AppleWMSendEvent(AppleWMPasteboardNotify,
+ AppleWMPasteboardNotifyMask,
+ xe->u.clientMessage.u.l.longs0,
+ xe->u.clientMessage.u.l.longs1);
+ break;
+
+ case kXDarwinDisplayChanged:
+ QuartzUpdateScreens();
+ break;
+
+ case kXDarwinWindowState:
+ case kXDarwinWindowMoved:
+ // FIXME: Not implemented yet
+ break;
+
+ default:
+ ErrorF("Unknown application defined event type %d.\n",
+ xe->u.u.type);
+ }
+}
+
+
+/*
+ * DarwinModeGiveUp
+ * Cleanup before X server shutdown
+ * Release the screen and restore the Aqua cursor.
+ */
+void DarwinModeGiveUp(void)
+{
+#if 0
+// Trying to switch cursors when quitting causes deadlock
+ int i;
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ if (screenInfo.screens[i]) {
+ QuartzSuspendXCursor(screenInfo.screens[i]);
+ }
+ }
+#endif
+
+ if (!quartzRootless)
+ quartzProcs->ReleaseScreens();
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/quartz.h b/nx-X11/programs/Xserver/hw/darwin/quartz/quartz.h
new file mode 100644
index 000000000..9e2f90f78
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/quartz.h
@@ -0,0 +1,131 @@
+/*
+ * quartz.h
+ *
+ * External interface of the Quartz display modes seen by the generic, mode
+ * independent parts of the Darwin X server.
+ */
+/*
+ * Copyright (c) 2001-2003 Greg Parker and Torrey T. Lyons.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartz.h,v 1.4 2005/07/01 22:43:07 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.h,v 1.7 2003/11/12 20:21:51 torrey Exp $ */
+
+#ifndef _QUARTZ_H
+#define _QUARTZ_H
+
+#include "quartzPasteboard.h"
+
+#include "screenint.h"
+#include "window.h"
+
+/*------------------------------------------
+ Quartz display mode function types
+ ------------------------------------------*/
+
+/*
+ * Display mode initialization
+ */
+typedef void (*DisplayInitProc)(void);
+typedef Bool (*AddScreenProc)(int index, ScreenPtr pScreen);
+typedef Bool (*SetupScreenProc)(int index, ScreenPtr pScreen);
+typedef void (*InitInputProc)(int argc, char **argv);
+
+/*
+ * Cursor functions
+ */
+typedef Bool (*InitCursorProc)(ScreenPtr pScreen);
+typedef void (*CursorUpdateProc)(void);
+
+/*
+ * Suspend and resume X11 activity
+ */
+typedef void (*SuspendScreenProc)(ScreenPtr pScreen);
+typedef void (*ResumeScreenProc)(ScreenPtr pScreen, int x, int y);
+typedef void (*CaptureScreensProc)(void);
+typedef void (*ReleaseScreensProc)(void);
+
+/*
+ * Screen state change support
+ */
+typedef void (*ScreenChangedProc)(void);
+typedef void (*AddPseudoramiXScreensProc)(int *x, int *y, int *width, int *height);
+typedef void (*UpdateScreenProc)(ScreenPtr pScreen);
+
+/*
+ * Rootless helper functions
+ */
+typedef Bool (*IsX11WindowProc)(void *nsWindow, int windowNumber);
+typedef void (*HideWindowsProc)(Bool hide);
+
+/*
+ * Rootless functions for optional export to GLX layer
+ */
+typedef void * (*FrameForWindowProc)(WindowPtr pWin, Bool create);
+typedef WindowPtr (*TopLevelParentProc)(WindowPtr pWindow);
+typedef Bool (*CreateSurfaceProc)
+ (ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
+ unsigned int client_id, unsigned int *surface_id,
+ unsigned int key[2], void (*notify) (void *arg, void *data),
+ void *notify_data);
+typedef Bool (*DestroySurfaceProc)
+ (ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
+ void (*notify) (void *arg, void *data), void *notify_data);
+
+/*
+ * Quartz display mode function list
+ */
+typedef struct _QuartzModeProcs {
+ DisplayInitProc DisplayInit;
+ AddScreenProc AddScreen;
+ SetupScreenProc SetupScreen;
+ InitInputProc InitInput;
+
+ InitCursorProc InitCursor;
+ CursorUpdateProc CursorUpdate; // Not used if NULL
+
+ SuspendScreenProc SuspendScreen;
+ ResumeScreenProc ResumeScreen;
+ CaptureScreensProc CaptureScreens; // Only called in fullscreen
+ ReleaseScreensProc ReleaseScreens; // Only called in fullscreen
+
+ ScreenChangedProc ScreenChanged;
+ AddPseudoramiXScreensProc AddPseudoramiXScreens;
+ UpdateScreenProc UpdateScreen;
+
+ IsX11WindowProc IsX11Window;
+ HideWindowsProc HideWindows;
+
+ FrameForWindowProc FrameForWindow;
+ TopLevelParentProc TopLevelParent;
+ CreateSurfaceProc CreateSurface;
+ DestroySurfaceProc DestroySurface;
+} QuartzModeProcsRec, *QuartzModeProcsPtr;
+
+extern QuartzModeProcsPtr quartzProcs;
+
+Bool QuartzLoadDisplayBundle(const char *dpyBundleName);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/quartzAudio.c b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzAudio.c
new file mode 100644
index 000000000..2106dfad4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzAudio.c
@@ -0,0 +1,342 @@
+//
+// QuartzAudio.m
+//
+// X Window bell support using CoreAudio or AppKit.
+// Greg Parker gparker@cs.stanford.edu 19 Feb 2001
+//
+// Info about sine wave sound playback:
+// CoreAudio code derived from macosx-dev posting by Tim Wood
+// http://www.omnigroup.com/mailman/archive/macosx-dev/2000-May/002004.html
+// Smoothing transitions between sounds
+// http://www.wam.umd.edu/~mphoenix/dss/dss.html
+//
+/*
+ * Copyright (c) 2001 Greg Parker. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzAudio.c,v 1.1 2002/03/28 02:21:18 torrey Exp $ */
+
+#include "quartzCommon.h"
+#include "quartzAudio.h"
+
+#include <CoreAudio/CoreAudio.h>
+#include <pthread.h>
+
+#include "inputstr.h"
+#include <X11/extensions/XI.h>
+
+void NSBeep();
+
+typedef struct QuartzAudioRec {
+ double frequency;
+ double amplitude;
+
+ UInt32 curFrame;
+ UInt32 remainingFrames;
+ UInt32 totalFrames;
+ UInt32 bytesPerFrame;
+ double sampleRate;
+ UInt32 fadeLength;
+
+ UInt32 bufferByteCount;
+ Boolean playing;
+ pthread_mutex_t lock;
+
+ // used to fade out interrupted sound and avoid 'pop'
+ double prevFrequency;
+ double prevAmplitude;
+ UInt32 prevFrame;
+} QuartzAudioRec;
+
+static AudioDeviceID quartzAudioDevice = kAudioDeviceUnknown;
+static QuartzAudioRec data;
+
+
+/*
+ * QuartzAudioEnvelope
+ * Fade sound in and out to avoid pop.
+ * Sounds with shorter duration will never reach full amplitude. Deal.
+ */
+static double QuartzAudioEnvelope(
+ UInt32 curFrame,
+ UInt32 totalFrames,
+ UInt32 fadeLength )
+{
+ double fadeFrames = min(fadeLength, totalFrames / 2);
+ if (fadeFrames < 1) return 0;
+
+ if (curFrame < fadeFrames) {
+ return curFrame / fadeFrames;
+ } else if (curFrame > totalFrames - fadeFrames) {
+ return (totalFrames-curFrame) / fadeFrames;
+ } else {
+ return 1.0;
+ }
+}
+
+
+/*
+ * QuartzFillBuffer
+ * Fill this buffer with data and update the data position.
+ * FIXME: this is ugly
+ */
+static void QuartzFillBuffer(
+ AudioBuffer *audiobuffer,
+ QuartzAudioRec *data )
+{
+ float *buffer, *b;
+ unsigned int frame, frameCount;
+ unsigned int bufferFrameCount;
+ float multiplier, v;
+ int i;
+
+ buffer = (float *)audiobuffer->mData;
+ bufferFrameCount = audiobuffer->mDataByteSize / data->bytesPerFrame;
+
+ frameCount = min(bufferFrameCount, data->remainingFrames);
+
+ // Fade out previous sine wave, if any.
+ b = buffer;
+ if (data->prevFrame) {
+ multiplier = 2*M_PI*(data->prevFrequency/data->sampleRate);
+ for (frame = 0; frame < data->fadeLength; frame++) {
+ v = data->prevAmplitude *
+ QuartzAudioEnvelope(frame+data->fadeLength,
+ 2*data->fadeLength,
+ data->fadeLength) *
+ sin(multiplier * (data->prevFrame+frame));
+ for (i = 0; i < audiobuffer->mNumberChannels; i++) {
+ *b++ = v;
+ }
+ }
+ // no more prev fade
+ data->prevFrame = 0;
+
+ // adjust for space eaten by prev fade
+ buffer += audiobuffer->mNumberChannels*frame;
+ bufferFrameCount -= frame;
+ frameCount = min(bufferFrameCount, data->remainingFrames);
+ }
+
+ // Write a sine wave with the specified frequency and amplitude
+ multiplier = 2*M_PI*(data->frequency/data->sampleRate);
+ for (frame = 0; frame < frameCount; frame++) {
+ v = data->amplitude *
+ QuartzAudioEnvelope(data->curFrame+frame, data->totalFrames,
+ data->fadeLength) *
+ sin(multiplier * (data->curFrame+frame));
+ for (i = 0; i < audiobuffer->mNumberChannels; i++) {
+ *b++ = v;
+ }
+ }
+
+ // Zero out the rest of the buffer, if any
+ memset(b, 0, sizeof(float) * audiobuffer->mNumberChannels *
+ (bufferFrameCount-frame));
+
+ data->curFrame += frameCount;
+ data->remainingFrames -= frameCount;
+ if (data->remainingFrames == 0) {
+ data->playing = FALSE;
+ data->curFrame = 0;
+ }
+}
+
+
+/*
+ * QuartzAudioIOProc
+ * Callback function for audio playback.
+ * FIXME: use inOutputTime to correct for skipping
+ */
+static OSStatus
+QuartzAudioIOProc(
+ AudioDeviceID inDevice,
+ const AudioTimeStamp *inNow,
+ const AudioBufferList *inInputData,
+ const AudioTimeStamp *inInputTime,
+ AudioBufferList *outOutputData,
+ const AudioTimeStamp *inOutputTime,
+ void *inClientData )
+{
+ QuartzAudioRec *data = (QuartzAudioRec *)inClientData;
+ int i;
+ Boolean wasPlaying;
+
+ pthread_mutex_lock(&data->lock);
+ wasPlaying = data->playing;
+ for (i = 0; i < outOutputData->mNumberBuffers; i++) {
+ if (data->playing) {
+ QuartzFillBuffer(outOutputData->mBuffers+i, data);
+ }
+ else {
+ memset(outOutputData->mBuffers[i].mData, 0,
+ outOutputData->mBuffers[i].mDataByteSize);
+ }
+ }
+ if (wasPlaying && !data->playing) {
+ OSStatus err;
+ err = AudioDeviceStop(inDevice, QuartzAudioIOProc);
+ }
+ pthread_mutex_unlock(&data->lock);
+ return 0;
+}
+
+
+/*
+ * QuartzCoreAudioBell
+ * Play a tone using the CoreAudio API
+ */
+static void QuartzCoreAudioBell(
+ int volume, // volume is % of max
+ int pitch, // pitch is Hz
+ int duration ) // duration is milliseconds
+{
+ if (quartzAudioDevice == kAudioDeviceUnknown) return;
+
+ pthread_mutex_lock(&data.lock);
+
+ // fade previous sound, if any
+ data.prevFrequency = data.frequency;
+ data.prevAmplitude = data.amplitude;
+ data.prevFrame = data.curFrame;
+
+ // set new sound
+ data.frequency = pitch;
+ data.amplitude = volume / 100.0;
+ data.curFrame = 0;
+ data.totalFrames = (int)(data.sampleRate * duration / 1000.0);
+ data.remainingFrames = data.totalFrames;
+
+ if (! data.playing) {
+ OSStatus status;
+ status = AudioDeviceStart(quartzAudioDevice, QuartzAudioIOProc);
+ if (status) {
+ ErrorF("QuartzAudioBell: AudioDeviceStart returned %ld\n", status);
+ } else {
+ data.playing = TRUE;
+ }
+ }
+ pthread_mutex_unlock(&data.lock);
+}
+
+
+/*
+ * DarwinModeBell
+ * Ring the bell
+ */
+void DarwinModeBell(
+ int volume, // volume in percent of max
+ DeviceIntPtr pDevice,
+ pointer ctrl,
+ int class )
+{
+ int pitch; // pitch in Hz
+ int duration; // duration in milliseconds
+
+ if (class == BellFeedbackClass) {
+ pitch = ((BellCtrl*)ctrl)->pitch;
+ duration = ((BellCtrl*)ctrl)->duration;
+ } else if (class == KbdFeedbackClass) {
+ pitch = ((KeybdCtrl*)ctrl)->bell_pitch;
+ duration = ((KeybdCtrl*)ctrl)->bell_duration;
+ } else {
+ ErrorF("QuartzBell: bad bell class %d\n", class);
+ return;
+ }
+
+ if (quartzUseSysBeep) {
+ if (volume)
+ NSBeep();
+ } else {
+ QuartzCoreAudioBell(volume, pitch, duration);
+ }
+}
+
+
+/*
+ * QuartzAudioInit
+ * Prepare to play the bell with the CoreAudio API
+ */
+void QuartzAudioInit(void)
+{
+ UInt32 propertySize;
+ OSStatus status;
+ AudioDeviceID outputDevice;
+ AudioStreamBasicDescription outputStreamDescription;
+ double sampleRate;
+
+ // Get the default output device
+ propertySize = sizeof(outputDevice);
+ status = AudioHardwareGetProperty(
+ kAudioHardwarePropertyDefaultOutputDevice,
+ &propertySize, &outputDevice);
+ if (status) {
+ ErrorF("QuartzAudioInit: AudioHardwareGetProperty returned %ld\n",
+ status);
+ return;
+ }
+ if (outputDevice == kAudioDeviceUnknown) {
+ ErrorF("QuartzAudioInit: No audio output devices available.\n");
+ return;
+ }
+
+ // Get the basic device description
+ propertySize = sizeof(outputStreamDescription);
+ status = AudioDeviceGetProperty(outputDevice, 0, FALSE,
+ kAudioDevicePropertyStreamFormat,
+ &propertySize, &outputStreamDescription);
+ if (status) {
+ ErrorF("QuartzAudioInit: GetProperty(stream format) returned %ld\n",
+ status);
+ return;
+ }
+ sampleRate = outputStreamDescription.mSampleRate;
+
+ // Fill in the playback data
+ data.frequency = 0;
+ data.amplitude = 0;
+ data.curFrame = 0;
+ data.remainingFrames = 0;
+ data.bytesPerFrame = outputStreamDescription.mBytesPerFrame;
+ data.sampleRate = sampleRate;
+ // data.bufferByteCount = bufferByteCount;
+ data.playing = FALSE;
+ data.prevAmplitude = 0;
+ data.prevFrame = 0;
+ data.prevFrequency = 0;
+ data.fadeLength = data.sampleRate / 200;
+ pthread_mutex_init(&data.lock, NULL); // fixme error check
+
+ // fixme assert fadeLength<framesPerBuffer
+
+ // Prepare for playback
+ status = AudioDeviceAddIOProc(outputDevice, QuartzAudioIOProc, &data);
+ if (status) {
+ ErrorF("QuartzAudioInit: AddIOProc returned %ld\n", status);
+ return;
+ }
+
+ // success!
+ quartzAudioDevice = outputDevice;
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/quartzAudio.h b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzAudio.h
new file mode 100644
index 000000000..e20c21ad2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzAudio.h
@@ -0,0 +1,41 @@
+//
+// QuartzAudio.h
+//
+// X Window bell support using CoreAudio or AppKit.
+// Greg Parker gparker@cs.stanford.edu 19 Feb 2001
+/*
+ * Copyright (c) 2001 Greg Parker. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/quartzAudio.h,v 1.2 2001/04/01 20:45:43 tsi Exp $ */
+
+#ifndef _QUARTZAUDIO_H
+#define _QUARTZAUDIO_H
+
+#include "input.h"
+
+void QuartzAudioInit(void);
+void QuartzBell(int volume, DeviceIntPtr pDevice, pointer ctrl, int class);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/quartzCocoa.m b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzCocoa.m
new file mode 100644
index 000000000..52832ccd6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzCocoa.m
@@ -0,0 +1,205 @@
+/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.3 2004/07/30 19:12:17 torrey Exp $ */
+/**************************************************************
+ *
+ * Quartz-specific support for the Darwin X Server
+ * that requires Cocoa and Objective-C.
+ *
+ * This file is separate from the parts of Quartz support
+ * that use X include files to avoid symbol collisions.
+ *
+ **************************************************************/
+/*
+ * Copyright (c) 2001-2004 Torrey T. Lyons and Greg Parker.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.5 2004/06/08 22:58:10 torrey Exp $ */
+
+#include "quartzCommon.h"
+
+#define BOOL xBOOL
+#include "darwin.h"
+#undef BOOL
+
+#include <Cocoa/Cocoa.h>
+
+#import "Preferences.h"
+#include "pseudoramiX.h"
+
+extern void FatalError(const char *, ...);
+extern char *display;
+extern int noPanoramiXExtension;
+
+
+/*
+ * QuartzReadPreferences
+ * Read the user preferences from the Cocoa front end.
+ */
+void QuartzReadPreferences(void)
+{
+ char *fileString;
+
+ darwinFakeButtons = [Preferences fakeButtons];
+ darwinFakeMouse2Mask = [Preferences button2Mask];
+ darwinFakeMouse3Mask = [Preferences button3Mask];
+ darwinMouseAccelChange = [Preferences mouseAccelChange];
+ quartzUseSysBeep = [Preferences systemBeep];
+ quartzEnableKeyEquivalents = [Preferences enableKeyEquivalents];
+
+ // quartzRootless has already been set
+ if (quartzRootless) {
+ // Use PseudoramiX instead of Xinerama
+ noPanoramiXExtension = TRUE;
+ noPseudoramiXExtension = ![Preferences xinerama];
+
+ quartzUseAGL = [Preferences useAGL];
+ } else {
+ noPanoramiXExtension = ![Preferences xinerama];
+ noPseudoramiXExtension = TRUE;
+
+ // Full screen can't use AGL for GLX
+ quartzUseAGL = FALSE;
+ }
+
+ if ([Preferences useKeymapFile]) {
+ fileString = (char *) [[Preferences keymapFile] lossyCString];
+ darwinKeymapFile = (char *) malloc(strlen(fileString)+1);
+ if (! darwinKeymapFile)
+ FatalError("malloc failed in QuartzReadPreferences()!\n");
+ strcpy(darwinKeymapFile, fileString);
+ }
+
+ display = (char *) malloc(8);
+ if (! display)
+ FatalError("malloc failed in QuartzReadPreferences()!\n");
+ snprintf(display, 8, "%i", [Preferences display]);
+
+ darwinDesiredDepth = [Preferences depth] - 1;
+}
+
+
+/*
+ * QuartzWriteCocoaPasteboard
+ * Write text to the Mac OS X pasteboard.
+ */
+void QuartzWriteCocoaPasteboard(
+ char *text)
+{
+ NSPasteboard *pasteboard;
+ NSArray *pasteboardTypes;
+ NSString *string;
+
+ if (! text) return;
+ pasteboard = [NSPasteboard generalPasteboard];
+ if (! pasteboard) return;
+ string = [NSString stringWithCString:text];
+ if (! string) return;
+ pasteboardTypes = [NSArray arrayWithObject:NSStringPboardType];
+
+ // nil owner because we don't provide type translations
+ [pasteboard declareTypes:pasteboardTypes owner:nil];
+ [pasteboard setString:string forType:NSStringPboardType];
+}
+
+
+/*
+ * QuartzReadCocoaPasteboard
+ * Read text from the Mac OS X pasteboard and return it as a heap string.
+ * The caller must free the string.
+ */
+char *QuartzReadCocoaPasteboard(void)
+{
+ NSPasteboard *pasteboard;
+ NSArray *pasteboardTypes;
+ NSString *existingType;
+ char *text = NULL;
+
+ pasteboardTypes = [NSArray arrayWithObject:NSStringPboardType];
+ pasteboard = [NSPasteboard generalPasteboard];
+ if (! pasteboard) return NULL;
+
+ existingType = [pasteboard availableTypeFromArray:pasteboardTypes];
+ if (existingType) {
+ NSString *string = [pasteboard stringForType:existingType];
+ char *buffer;
+
+ if (! string) return NULL;
+ buffer = (char *) [string lossyCString];
+ text = (char *) malloc(strlen(buffer)+1);
+ if (text)
+ strcpy(text, buffer);
+ }
+
+ return text;
+}
+
+
+/*
+ * QuartzFSUseQDCursor
+ * Return whether the screen should use a QuickDraw cursor.
+ */
+int QuartzFSUseQDCursor(
+ int depth) // screen depth
+{
+ switch ([Preferences useQDCursor]) {
+ case qdCursor_Always:
+ return TRUE;
+ case qdCursor_Never:
+ return FALSE;
+ case qdCursor_Not8Bit:
+ if (depth > 8)
+ return TRUE;
+ else
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+/*
+ * QuartzBlockHandler
+ * Clean out any autoreleased objects.
+ */
+void QuartzBlockHandler(
+ void *blockData,
+ void *pTimeout,
+ void *pReadmask)
+{
+ static NSAutoreleasePool *aPool = nil;
+
+ [aPool release];
+ aPool = [[NSAutoreleasePool alloc] init];
+}
+
+
+/*
+ * QuartzWakeupHandler
+ */
+void QuartzWakeupHandler(
+ void *blockData,
+ int result,
+ void *pReadmask)
+{
+ // nothing here
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/quartzCommon.h b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzCommon.h
new file mode 100644
index 000000000..d0f743662
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzCommon.h
@@ -0,0 +1,108 @@
+/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartzCommon.h,v 1.4 2005/07/01 22:43:07 daniels Exp $ */
+/*
+ * quartzCommon.h
+ *
+ * Common definitions used internally by all Quartz modes
+ *
+ * This file should be included before any X11 or IOKit headers
+ * so that it can avoid symbol conflicts.
+ *
+ * Copyright (c) 2001-2004 Torrey T. Lyons and Greg Parker.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCommon.h,v 1.15 2004/06/08 22:58:10 torrey Exp $ */
+
+#ifndef _QUARTZCOMMON_H
+#define _QUARTZCOMMON_H
+
+// QuickDraw in ApplicationServices has the following conflicts with
+// the basic X server headers. Use QD_<name> to use the QuickDraw
+// definition of any of these symbols, or the normal name for the
+// X11 definition.
+#define Cursor QD_Cursor
+#define WindowPtr QD_WindowPtr
+#define Picture QD_Picture
+#include <ApplicationServices/ApplicationServices.h>
+#undef Cursor
+#undef WindowPtr
+#undef Picture
+
+// Quartz specific per screen storage structure
+typedef struct {
+ // List of CoreGraphics displays that this X11 screen covers.
+ // This is more than one CG display for video mirroring and
+ // rootless PseudoramiX mode.
+ // No CG display will be covered by more than one X11 screen.
+ int displayCount;
+ CGDirectDisplayID *displayIDs;
+} QuartzScreenRec, *QuartzScreenPtr;
+
+#define QUARTZ_PRIV(pScreen) \
+ ((QuartzScreenPtr)pScreen->devPrivates[quartzScreenIndex].ptr)
+
+// Data stored at startup for Cocoa front end
+extern int quartzEventWriteFD;
+extern int quartzStartClients;
+
+// User preferences used by Quartz modes
+extern int quartzRootless;
+extern int quartzUseSysBeep;
+extern int quartzUseAGL;
+extern int quartzEnableKeyEquivalents;
+
+// Other shared data
+extern int quartzServerVisible;
+extern int quartzServerQuitting;
+extern int quartzScreenIndex;
+extern int aquaMenuBarHeight;
+
+// Name of GLX bundle for native OpenGL
+extern const char *quartzOpenGLBundle;
+
+void QuartzReadPreferences(void);
+void QuartzMessageMainThread(unsigned msg, void *data, unsigned length);
+void QuartzMessageServerThread(int type, int argc, ...);
+void QuartzSetWindowMenu(int nitems, const char **items,
+ const char *shortcuts);
+void QuartzFSCapture(void);
+void QuartzFSRelease(void);
+int QuartzFSUseQDCursor(int depth);
+void QuartzBlockHandler(void *blockData, void *pTimeout, void *pReadmask);
+void QuartzWakeupHandler(void *blockData, int result, void *pReadmask);
+
+// Messages that can be sent to the main thread.
+enum {
+ kQuartzServerHidden,
+ kQuartzServerStarted,
+ kQuartzServerDied,
+ kQuartzCursorUpdate,
+ kQuartzPostEvent,
+ kQuartzSetWindowMenu,
+ kQuartzSetWindowMenuCheck,
+ kQuartzSetFrontProcess,
+ kQuartzSetCanQuit
+};
+
+#endif /* _QUARTZCOMMON_H */
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/quartzCursor.c b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzCursor.c
new file mode 100644
index 000000000..711ce64f0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzCursor.c
@@ -0,0 +1,653 @@
+/**************************************************************
+ *
+ * Support for using the Quartz Window Manager cursor
+ *
+ **************************************************************/
+/*
+ * Copyright (c) 2001-2003 Torrey T. Lyons and Greg Parker.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCursor.c,v 1.4 2002/11/19 23:01:30 torrey Exp $ */
+
+#include "quartzCommon.h"
+#include "quartzCursor.h"
+#include "darwin.h"
+
+#include <pthread.h>
+
+#include "mi.h"
+#include "scrnintstr.h"
+#include "cursorstr.h"
+#include "mipointrst.h"
+#include "globals.h"
+
+// Size of the QuickDraw cursor
+#define CURSORWIDTH 16
+#define CURSORHEIGHT 16
+
+typedef struct {
+ int qdCursorMode;
+ int qdCursorVisible;
+ int useQDCursor;
+ QueryBestSizeProcPtr QueryBestSize;
+ miPointerSpriteFuncPtr spriteFuncs;
+} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
+
+static int darwinCursorScreenIndex = -1;
+static unsigned long darwinCursorGeneration = 0;
+static CursorPtr quartzLatentCursor = NULL;
+static QD_Cursor gQDArrow; // QuickDraw arrow cursor
+
+// Cursor for the main thread to set (NULL = arrow cursor).
+static CCrsrHandle currentCursor = NULL;
+static pthread_mutex_t cursorMutex;
+static pthread_cond_t cursorCondition;
+
+#define CURSOR_PRIV(pScreen) \
+ ((QuartzCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
+
+#define HIDE_QD_CURSOR(pScreen, visible) \
+ if (visible) { \
+ int ix; \
+ for (ix = 0; ix < QUARTZ_PRIV(pScreen)->displayCount; ix++) { \
+ CGDisplayHideCursor(QUARTZ_PRIV(pScreen)->displayIDs[ix]); \
+ } \
+ visible = FALSE; \
+ } ((void)0)
+
+#define SHOW_QD_CURSOR(pScreen, visible) \
+ { \
+ int ix; \
+ for (ix = 0; ix < QUARTZ_PRIV(pScreen)->displayCount; ix++) { \
+ CGDisplayShowCursor(QUARTZ_PRIV(pScreen)->displayIDs[ix]); \
+ } \
+ visible = TRUE; \
+ } ((void)0)
+
+#define CHANGE_QD_CURSOR(cursorH) \
+ if (!quartzServerQuitting) { \
+ /* Acquire lock and tell the main thread to change cursor */ \
+ pthread_mutex_lock(&cursorMutex); \
+ currentCursor = (CCrsrHandle) (cursorH); \
+ QuartzMessageMainThread(kQuartzCursorUpdate, NULL, 0); \
+ \
+ /* Wait for the main thread to change the cursor */ \
+ pthread_cond_wait(&cursorCondition, &cursorMutex); \
+ pthread_mutex_unlock(&cursorMutex); \
+ } ((void)0)
+
+
+/*
+ * MakeQDCursor helpers: CTAB_ENTER, interleave
+ */
+
+// Add a color entry to a ctab
+#define CTAB_ENTER(ctab, index, r, g, b) \
+ ctab->ctTable[index].value = index; \
+ ctab->ctTable[index].rgb.red = r; \
+ ctab->ctTable[index].rgb.green = g; \
+ ctab->ctTable[index].rgb.blue = b
+
+// Make an unsigned short by interleaving the bits of bytes c1 and c2.
+// High bit of c1 is first; low bit of c2 is last.
+// Interleave is a built-in INTERCAL operator.
+static unsigned short
+interleave(
+ unsigned char c1,
+ unsigned char c2 )
+{
+ return
+ ((c1 & 0x80) << 8) | ((c2 & 0x80) << 7) |
+ ((c1 & 0x40) << 7) | ((c2 & 0x40) << 6) |
+ ((c1 & 0x20) << 6) | ((c2 & 0x20) << 5) |
+ ((c1 & 0x10) << 5) | ((c2 & 0x10) << 4) |
+ ((c1 & 0x08) << 4) | ((c2 & 0x08) << 3) |
+ ((c1 & 0x04) << 3) | ((c2 & 0x04) << 2) |
+ ((c1 & 0x02) << 2) | ((c2 & 0x02) << 1) |
+ ((c1 & 0x01) << 1) | ((c2 & 0x01) << 0) ;
+}
+
+/*
+ * MakeQDCursor
+ * Make a QuickDraw color cursor from the given X11 cursor.
+ * Warning: This code is nasty. Color cursors were meant to be read
+ * from resources; constructing the structures programmatically is messy.
+ */
+/*
+ QuickDraw cursor representation:
+ Our color cursor is a 2 bit per pixel pixmap.
+ Each pixel's bits are (source<<1 | mask) from the original X cursor pixel.
+ The cursor's color table maps the colors like this:
+ (2-bit value | X result | colortable | Mac result)
+ 00 | transparent | white | transparent (white outside mask)
+ 01 | back color | back color | back color
+ 10 | undefined | black | invert background (just for fun)
+ 11 | fore color | fore color | fore color
+*/
+static CCrsrHandle
+MakeQDCursor(
+ CursorPtr pCursor )
+{
+ CCrsrHandle result;
+ CCrsrPtr curs;
+ int i, w, h;
+ unsigned short rowMask;
+ PixMap *pix;
+ ColorTable *ctab;
+ unsigned short *image;
+
+ result = (CCrsrHandle) NewHandleClear(sizeof(CCrsr));
+ if (!result) return NULL;
+ HLock((Handle)result);
+ curs = *result;
+
+ // Initialize CCrsr
+ curs->crsrType = 0x8001; // 0x8000 = b&w, 0x8001 = color
+ curs->crsrMap = (PixMapHandle) NewHandleClear(sizeof(PixMap));
+ if (!curs->crsrMap) goto pixAllocFailed;
+ HLock((Handle)curs->crsrMap);
+ pix = *curs->crsrMap;
+ curs->crsrData = NULL; // raw cursor image data (set below)
+ curs->crsrXData = NULL; // QD's processed data
+ curs->crsrXValid = 0; // zero means QD must re-process cursor data
+ curs->crsrXHandle = NULL; // reserved
+ memset(curs->crsr1Data, 0, CURSORWIDTH*CURSORHEIGHT/8); // b&w data
+ memset(curs->crsrMask, 0, CURSORWIDTH*CURSORHEIGHT/8); // b&w & color mask
+ curs->crsrHotSpot.h = min(CURSORWIDTH, pCursor->bits->xhot); // hot spot
+ curs->crsrHotSpot.v = min(CURSORHEIGHT, pCursor->bits->yhot); // hot spot
+ curs->crsrXTable = 0; // reserved
+ curs->crsrID = GetCTSeed(); // unique ID from Color Manager
+
+ // Set the b&w data and mask
+ w = min(pCursor->bits->width, CURSORWIDTH);
+ h = min(pCursor->bits->height, CURSORHEIGHT);
+ rowMask = ~((1 << (CURSORWIDTH - w)) - 1);
+ for (i = 0; i < h; i++) {
+ curs->crsr1Data[i] = rowMask &
+ ((pCursor->bits->source[i*4]<<8) | pCursor->bits->source[i*4+1]);
+ curs->crsrMask[i] = rowMask &
+ ((pCursor->bits->mask[i*4]<<8) | pCursor->bits->mask[i*4+1]);
+ }
+
+ // Set the color data and mask
+ // crsrMap: defines bit depth and size and colortable only
+ pix->rowBytes = (CURSORWIDTH * 2 / 8) | 0x8000; // last bit on means PixMap
+ SetRect(&pix->bounds, 0, 0, CURSORWIDTH, CURSORHEIGHT); // see TN 1020
+ pix->pixelSize = 2;
+ pix->cmpCount = 1;
+ pix->cmpSize = 2;
+ // pix->pmTable set below
+
+ // crsrData is the pixel data. crsrMap's baseAddr is not used.
+ curs->crsrData = NewHandleClear(CURSORWIDTH*CURSORHEIGHT * 2 / 8);
+ if (!curs->crsrData) goto imageAllocFailed;
+ HLock((Handle)curs->crsrData);
+ image = (unsigned short *) *curs->crsrData;
+ // Pixel data is just 1-bit data and mask interleaved (see above)
+ for (i = 0; i < h; i++) {
+ unsigned char s, m;
+ s = pCursor->bits->source[i*4] & (rowMask >> 8);
+ m = pCursor->bits->mask[i*4] & (rowMask >> 8);
+ image[2*i] = interleave(s, m);
+ s = pCursor->bits->source[i*4+1] & (rowMask & 0x00ff);
+ m = pCursor->bits->mask[i*4+1] & (rowMask & 0x00ff);
+ image[2*i+1] = interleave(s, m);
+ }
+
+ // Build the color table (entries described above)
+ // NewPixMap allocates a color table handle.
+ pix->pmTable = (CTabHandle) NewHandleClear(sizeof(ColorTable) + 3
+ * sizeof(ColorSpec));
+ if (!pix->pmTable) goto ctabAllocFailed;
+ HLock((Handle)pix->pmTable);
+ ctab = *pix->pmTable;
+ ctab->ctSeed = GetCTSeed();
+ ctab->ctFlags = 0;
+ ctab->ctSize = 3; // color count - 1
+ CTAB_ENTER(ctab, 0, 0xffff, 0xffff, 0xffff);
+ CTAB_ENTER(ctab, 1, pCursor->backRed, pCursor->backGreen,
+ pCursor->backBlue);
+ CTAB_ENTER(ctab, 2, 0x0000, 0x0000, 0x0000);
+ CTAB_ENTER(ctab, 3, pCursor->foreRed, pCursor->foreGreen,
+ pCursor->foreBlue);
+
+ HUnlock((Handle)pix->pmTable); // ctab
+ HUnlock((Handle)curs->crsrData); // image data
+ HUnlock((Handle)curs->crsrMap); // pix
+ HUnlock((Handle)result); // cursor
+
+ return result;
+
+ // "What we have here is a failure to allocate"
+ctabAllocFailed:
+ HUnlock((Handle)curs->crsrData);
+ DisposeHandle((Handle)curs->crsrData);
+imageAllocFailed:
+ HUnlock((Handle)curs->crsrMap);
+ DisposeHandle((Handle)curs->crsrMap);
+pixAllocFailed:
+ HUnlock((Handle)result);
+ DisposeHandle((Handle)result);
+ return NULL;
+}
+
+
+/*
+ * FreeQDCursor
+ * Destroy a QuickDraw color cursor created with MakeQDCursor().
+ * The cursor must not currently be on screen.
+ */
+static void FreeQDCursor(CCrsrHandle cursHandle)
+{
+ CCrsrPtr curs;
+ PixMap *pix;
+
+ HLock((Handle)cursHandle);
+ curs = *cursHandle;
+ HLock((Handle)curs->crsrMap);
+ pix = *curs->crsrMap;
+ DisposeHandle((Handle)pix->pmTable);
+ HUnlock((Handle)curs->crsrMap);
+ DisposeHandle((Handle)curs->crsrMap);
+ DisposeHandle((Handle)curs->crsrData);
+ HUnlock((Handle)cursHandle);
+ DisposeHandle((Handle)cursHandle);
+}
+
+
+/*
+===========================================================================
+
+ Pointer sprite functions
+
+===========================================================================
+*/
+
+/*
+ * QuartzRealizeCursor
+ * Convert the X cursor representation to QuickDraw format if possible.
+ */
+Bool
+QuartzRealizeCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor )
+{
+ CCrsrHandle qdCursor;
+ QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ if(!pCursor || !pCursor->bits)
+ return FALSE;
+
+ // if the cursor is too big we use a software cursor
+ if ((pCursor->bits->height > CURSORHEIGHT) ||
+ (pCursor->bits->width > CURSORWIDTH) || !ScreenPriv->useQDCursor)
+ {
+ if (quartzRootless) {
+ // rootless can't use a software cursor
+ return TRUE;
+ } else {
+ return (*ScreenPriv->spriteFuncs->RealizeCursor)
+ (pScreen, pCursor);
+ }
+ }
+
+ // make new cursor image
+ qdCursor = MakeQDCursor(pCursor);
+ if (!qdCursor) return FALSE;
+
+ // save the result
+ pCursor->devPriv[pScreen->myNum] = (pointer) qdCursor;
+
+ return TRUE;
+}
+
+
+/*
+ * QuartzUnrealizeCursor
+ * Free the storage space associated with a realized cursor.
+ */
+Bool
+QuartzUnrealizeCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor )
+{
+ QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ if ((pCursor->bits->height > CURSORHEIGHT) ||
+ (pCursor->bits->width > CURSORWIDTH) || !ScreenPriv->useQDCursor)
+ {
+ if (quartzRootless) {
+ return TRUE;
+ } else {
+ return (*ScreenPriv->spriteFuncs->UnrealizeCursor)
+ (pScreen, pCursor);
+ }
+ } else {
+ CCrsrHandle oldCursor = (CCrsrHandle) pCursor->devPriv[pScreen->myNum];
+
+ if (currentCursor != oldCursor) {
+ // This should only fail when quitting, in which case we just leak.
+ FreeQDCursor(oldCursor);
+ }
+ pCursor->devPriv[pScreen->myNum] = NULL;
+ return TRUE;
+ }
+}
+
+
+/*
+ * QuartzSetCursor
+ * Set the cursor sprite and position.
+ * Use QuickDraw cursor if possible.
+ */
+static void
+QuartzSetCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor,
+ int x,
+ int y)
+{
+ QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ quartzLatentCursor = pCursor;
+
+ // Don't touch Mac OS cursor if X is hidden!
+ if (!quartzServerVisible)
+ return;
+
+ if (!pCursor) {
+ // Remove the cursor completely.
+ HIDE_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
+ if (! ScreenPriv->qdCursorMode)
+ (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
+ }
+ else if ((pCursor->bits->height <= CURSORHEIGHT) &&
+ (pCursor->bits->width <= CURSORWIDTH) && ScreenPriv->useQDCursor)
+ {
+ // Cursor is small enough to use QuickDraw directly.
+ if (! ScreenPriv->qdCursorMode) // remove the X cursor
+ (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
+ ScreenPriv->qdCursorMode = TRUE;
+
+ CHANGE_QD_CURSOR(pCursor->devPriv[pScreen->myNum]);
+ SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
+ }
+ else if (quartzRootless) {
+ // Rootless can't use a software cursor, so we just use Mac OS arrow.
+ CHANGE_QD_CURSOR(NULL);
+ SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
+ }
+ else {
+ // Cursor is too big for QuickDraw. Use X software cursor.
+ HIDE_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
+ ScreenPriv->qdCursorMode = FALSE;
+ (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, pCursor, x, y);
+ }
+}
+
+
+/*
+ * QuartzReallySetCursor
+ * Set the QuickDraw cursor. Called from the main thread since changing the
+ * cursor with QuickDraw is not thread safe on dual processor machines.
+ */
+void
+QuartzReallySetCursor()
+{
+ pthread_mutex_lock(&cursorMutex);
+
+ if (currentCursor) {
+ SetCCursor(currentCursor);
+ } else {
+ SetCursor(&gQDArrow);
+ }
+
+ pthread_cond_signal(&cursorCondition);
+ pthread_mutex_unlock(&cursorMutex);
+}
+
+
+/*
+ * QuartzMoveCursor
+ * Move the cursor. This is a noop for QuickDraw.
+ */
+static void
+QuartzMoveCursor(
+ ScreenPtr pScreen,
+ int x,
+ int y)
+{
+ QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ // only the X cursor needs to be explicitly moved
+ if (!ScreenPriv->qdCursorMode)
+ (*ScreenPriv->spriteFuncs->MoveCursor)(pScreen, x, y);
+}
+
+
+static miPointerSpriteFuncRec quartzSpriteFuncsRec = {
+ QuartzRealizeCursor,
+ QuartzUnrealizeCursor,
+ QuartzSetCursor,
+ QuartzMoveCursor
+};
+
+
+/*
+===========================================================================
+
+ Pointer screen functions
+
+===========================================================================
+*/
+
+/*
+ * QuartzCursorOffScreen
+ */
+static Bool QuartzCursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
+{
+ return FALSE;
+}
+
+
+/*
+ * QuartzCrossScreen
+ */
+static void QuartzCrossScreen(ScreenPtr pScreen, Bool entering)
+{
+ return;
+}
+
+
+/*
+ * QuartzWarpCursor
+ * Change the cursor position without generating an event or motion history.
+ * The input coordinates (x,y) are in pScreen-local X11 coordinates.
+ *
+ */
+static void
+QuartzWarpCursor(
+ ScreenPtr pScreen,
+ int x,
+ int y)
+{
+ static int neverMoved = TRUE;
+
+ if (neverMoved) {
+ // Don't move the cursor the first time. This is the jump-to-center
+ // initialization, and it's annoying because we may still be in MacOS.
+ neverMoved = FALSE;
+ return;
+ }
+
+ if (quartzServerVisible) {
+ CGDisplayErr cgErr;
+ CGPoint cgPoint;
+ // Only need to do this for one display. Any display will do.
+ CGDirectDisplayID cgID = QUARTZ_PRIV(pScreen)->displayIDs[0];
+ CGRect cgRect = CGDisplayBounds(cgID);
+
+ // Convert (x,y) to CoreGraphics screen-local CG coordinates.
+ // This is necessary because the X11 screen and CG screen may not
+ // coincide. (e.g. X11 screen may be moved to dodge the menu bar)
+
+ // Make point in X11 global coordinates
+ cgPoint = CGPointMake(x + dixScreenOrigins[pScreen->myNum].x,
+ y + dixScreenOrigins[pScreen->myNum].y);
+ // Shift to CoreGraphics global screen coordinates
+ cgPoint.x += darwinMainScreenX;
+ cgPoint.y += darwinMainScreenY;
+ // Shift to CoreGraphics screen-local coordinates
+ cgPoint.x -= cgRect.origin.x;
+ cgPoint.y -= cgRect.origin.y;
+
+ cgErr = CGDisplayMoveCursorToPoint(cgID, cgPoint);
+ if (cgErr != CGDisplayNoErr) {
+ ErrorF("Could not set cursor position with error code 0x%x.\n",
+ cgErr);
+ }
+ }
+
+ miPointerWarpCursor(pScreen, x, y);
+ miPointerUpdate();
+}
+
+
+static miPointerScreenFuncRec quartzScreenFuncsRec = {
+ QuartzCursorOffScreen,
+ QuartzCrossScreen,
+ QuartzWarpCursor,
+ DarwinEQPointerPost,
+ DarwinEQSwitchScreen
+};
+
+
+/*
+===========================================================================
+
+ Other screen functions
+
+===========================================================================
+*/
+
+/*
+ * QuartzCursorQueryBestSize
+ * Handle queries for best cursor size
+ */
+static void
+QuartzCursorQueryBestSize(
+ int class,
+ unsigned short *width,
+ unsigned short *height,
+ ScreenPtr pScreen)
+{
+ QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ if (class == CursorShape) {
+ *width = CURSORWIDTH;
+ *height = CURSORHEIGHT;
+ } else {
+ (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
+ }
+}
+
+
+/*
+ * QuartzInitCursor
+ * Initialize cursor support
+ */
+Bool
+QuartzInitCursor(
+ ScreenPtr pScreen )
+{
+ QuartzCursorScreenPtr ScreenPriv;
+ miPointerScreenPtr PointPriv;
+ DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
+
+ // initialize software cursor handling (always needed as backup)
+ if (!miDCInitialize(pScreen, &quartzScreenFuncsRec)) {
+ return FALSE;
+ }
+
+ // allocate private storage for this screen's QuickDraw cursor info
+ if (darwinCursorGeneration != serverGeneration) {
+ if ((darwinCursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+ darwinCursorGeneration = serverGeneration;
+ }
+
+ ScreenPriv = xcalloc( 1, sizeof(QuartzCursorScreenRec) );
+ if (!ScreenPriv) return FALSE;
+
+ CURSOR_PRIV(pScreen) = ScreenPriv;
+
+ // override some screen procedures
+ ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
+ pScreen->QueryBestSize = QuartzCursorQueryBestSize;
+
+ // initialize QuickDraw cursor handling
+ GetQDGlobalsArrow(&gQDArrow);
+ PointPriv = (miPointerScreenPtr)
+ pScreen->devPrivates[miPointerScreenIndex].ptr;
+
+ ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
+ PointPriv->spriteFuncs = &quartzSpriteFuncsRec;
+
+ if (!quartzRootless)
+ ScreenPriv->useQDCursor = QuartzFSUseQDCursor(dfb->colorBitsPerPixel);
+ else
+ ScreenPriv->useQDCursor = TRUE;
+ ScreenPriv->qdCursorMode = TRUE;
+ ScreenPriv->qdCursorVisible = TRUE;
+
+ // initialize cursor mutex lock
+ pthread_mutex_init(&cursorMutex, NULL);
+
+ // initialize condition for waiting
+ pthread_cond_init(&cursorCondition, NULL);
+
+ return TRUE;
+}
+
+
+// X server is hiding. Restore the Aqua cursor.
+void QuartzSuspendXCursor(
+ ScreenPtr pScreen )
+{
+ QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ CHANGE_QD_CURSOR(NULL);
+ SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
+}
+
+
+// X server is showing. Restore the X cursor.
+void QuartzResumeXCursor(
+ ScreenPtr pScreen,
+ int x,
+ int y )
+{
+ QuartzSetCursor(pScreen, quartzLatentCursor, x, y);
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/quartzCursor.h b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzCursor.h
new file mode 100644
index 000000000..4db5531fa
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzCursor.h
@@ -0,0 +1,43 @@
+/*
+ * quartzCursor.h
+ *
+ * External interface for Quartz hardware cursor
+ */
+/*
+ * Copyright (c) 2001 Torrey T. Lyons and Greg Parker.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/quartzCursor.h,v 1.2 2001/09/23 04:04:49 torrey Exp $ */
+
+#ifndef QUARTZCURSOR_H
+#define QUARTZCURSOR_H
+
+#include "screenint.h"
+
+Bool QuartzInitCursor(ScreenPtr pScreen);
+void QuartzSuspendXCursor(ScreenPtr pScreen);
+void QuartzResumeXCursor(ScreenPtr pScreen, int x, int y);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/quartzKeyboard.c b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzKeyboard.c
new file mode 100644
index 000000000..f960b496f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzKeyboard.c
@@ -0,0 +1,388 @@
+/*
+ quartzKeyboard.c
+ $Id: quartzKeyboard.c,v 1.4 2005/07/01 22:43:07 daniels Exp $
+
+ Code to build a keymap using the Carbon Keyboard Layout API,
+ which is supported on Mac OS X 10.2 and newer.
+
+ Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name(s) of the above
+ copyright holders shall not be used in advertising or otherwise to
+ promote the sale, use or other dealings in this Software without
+ prior written authorization.
+*/
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzKeyboard.c,v 1.1 2003/11/01 08:13:08 torrey Exp $ */
+
+#include "quartzCommon.h"
+
+#include <CoreServices/CoreServices.h>
+#include <Carbon/Carbon.h>
+
+#include "darwinKeyboard.h"
+#include "keysym.h"
+#include "keysym2ucs.h"
+
+#ifdef HAS_KL_API
+
+#define HACK_MISSING 1
+#define HACK_KEYPAD 1
+
+enum {
+ MOD_COMMAND = 256,
+ MOD_SHIFT = 512,
+ MOD_OPTION = 2048,
+ MOD_CONTROL = 4096,
+};
+
+#define UKEYSYM(u) ((u) | 0x01000000)
+
+/* Table of keycode->keysym mappings we use to fallback on for important
+ keys that are often not in the Unicode mapping. */
+
+const static struct {
+ unsigned short keycode;
+ KeySym keysym;
+} known_keys[] = {
+ {55, XK_Meta_L},
+ {56, XK_Shift_L},
+ {57, XK_Caps_Lock},
+ {58, XK_Alt_L},
+ {59, XK_Control_L},
+
+ {60, XK_Shift_R},
+ {61, XK_Alt_R},
+ {62, XK_Control_R},
+ {63, XK_Meta_R},
+
+ {122, XK_F1},
+ {120, XK_F2},
+ {99, XK_F3},
+ {118, XK_F4},
+ {96, XK_F5},
+ {97, XK_F6},
+ {98, XK_F7},
+ {100, XK_F8},
+ {101, XK_F9},
+ {109, XK_F10},
+ {103, XK_F11},
+ {111, XK_F12},
+ {105, XK_F13},
+ {107, XK_F14},
+ {113, XK_F15},
+};
+
+/* Table of keycode->old,new-keysym mappings we use to fixup the numeric
+ keypad entries. */
+
+const static struct {
+ unsigned short keycode;
+ KeySym normal, keypad;
+} known_numeric_keys[] = {
+ {65, XK_period, XK_KP_Decimal},
+ {67, XK_asterisk, XK_KP_Multiply},
+ {69, XK_plus, XK_KP_Add},
+ {75, XK_slash, XK_KP_Divide},
+ {76, 0x01000003, XK_KP_Enter},
+ {78, XK_minus, XK_KP_Subtract},
+ {81, XK_equal, XK_KP_Equal},
+ {82, XK_0, XK_KP_0},
+ {83, XK_1, XK_KP_1},
+ {84, XK_2, XK_KP_2},
+ {85, XK_3, XK_KP_3},
+ {86, XK_4, XK_KP_4},
+ {87, XK_5, XK_KP_5},
+ {88, XK_6, XK_KP_6},
+ {89, XK_7, XK_KP_7},
+ {91, XK_8, XK_KP_8},
+ {92, XK_9, XK_KP_9},
+};
+
+/* Table mapping normal keysyms to their dead equivalents.
+ FIXME: all the unicode keysyms (apart from circumflex) were guessed. */
+
+const static struct {
+ KeySym normal, dead;
+} dead_keys[] = {
+ {XK_grave, XK_dead_grave},
+ {XK_acute, XK_dead_acute},
+ {XK_asciicircum, XK_dead_circumflex},
+ {UKEYSYM (0x2c6), XK_dead_circumflex}, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
+ {XK_asciitilde, XK_dead_tilde},
+ {UKEYSYM (0x2dc), XK_dead_tilde}, /* SMALL TILDE */
+ {XK_macron, XK_dead_macron},
+ {XK_breve, XK_dead_breve},
+ {XK_abovedot, XK_dead_abovedot},
+ {XK_diaeresis, XK_dead_diaeresis},
+ {UKEYSYM (0x2da), XK_dead_abovering}, /* DOT ABOVE */
+ {XK_doubleacute, XK_dead_doubleacute},
+ {XK_caron, XK_dead_caron},
+ {XK_cedilla, XK_dead_cedilla},
+ {XK_ogonek, XK_dead_ogonek},
+ {UKEYSYM (0x269), XK_dead_iota}, /* LATIN SMALL LETTER IOTA */
+ {UKEYSYM (0x2ec), XK_dead_voiced_sound}, /* MODIFIER LETTER VOICING */
+/* {XK_semivoiced_sound, XK_dead_semivoiced_sound}, */
+ {UKEYSYM (0x323), XK_dead_belowdot}, /* COMBINING DOT BELOW */
+ {UKEYSYM (0x309), XK_dead_hook}, /* COMBINING HOOK ABOVE */
+ {UKEYSYM (0x31b), XK_dead_horn}, /* COMBINING HORN */
+};
+
+unsigned int
+DarwinModeSystemKeymapSeed (void)
+{
+ static unsigned int seed;
+
+ static KeyboardLayoutRef last_key_layout;
+ KeyboardLayoutRef key_layout;
+
+ KLGetCurrentKeyboardLayout (&key_layout);
+
+ if (key_layout != last_key_layout)
+ seed++;
+
+ last_key_layout = key_layout;
+
+ return seed;
+}
+
+static inline UniChar
+macroman2ucs (unsigned char c)
+{
+ /* Precalculated table mapping MacRoman-128 to Unicode. Generated
+ by creating single element CFStringRefs then extracting the
+ first character. */
+
+ static const unsigned short table[128] = {
+ 0xc4, 0xc5, 0xc7, 0xc9, 0xd1, 0xd6, 0xdc, 0xe1,
+ 0xe0, 0xe2, 0xe4, 0xe3, 0xe5, 0xe7, 0xe9, 0xe8,
+ 0xea, 0xeb, 0xed, 0xec, 0xee, 0xef, 0xf1, 0xf3,
+ 0xf2, 0xf4, 0xf6, 0xf5, 0xfa, 0xf9, 0xfb, 0xfc,
+ 0x2020, 0xb0, 0xa2, 0xa3, 0xa7, 0x2022, 0xb6, 0xdf,
+ 0xae, 0xa9, 0x2122, 0xb4, 0xa8, 0x2260, 0xc6, 0xd8,
+ 0x221e, 0xb1, 0x2264, 0x2265, 0xa5, 0xb5, 0x2202, 0x2211,
+ 0x220f, 0x3c0, 0x222b, 0xaa, 0xba, 0x3a9, 0xe6, 0xf8,
+ 0xbf, 0xa1, 0xac, 0x221a, 0x192, 0x2248, 0x2206, 0xab,
+ 0xbb, 0x2026, 0xa0, 0xc0, 0xc3, 0xd5, 0x152, 0x153,
+ 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0xf7, 0x25ca,
+ 0xff, 0x178, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01, 0xfb02,
+ 0x2021, 0xb7, 0x201a, 0x201e, 0x2030, 0xc2, 0xca, 0xc1,
+ 0xcb, 0xc8, 0xcd, 0xce, 0xcf, 0xcc, 0xd3, 0xd4,
+ 0xf8ff, 0xd2, 0xda, 0xdb, 0xd9, 0x131, 0x2c6, 0x2dc,
+ 0xaf, 0x2d8, 0x2d9, 0x2da, 0xb8, 0x2dd, 0x2db, 0x2c7,
+ };
+
+ if (c < 128)
+ return c;
+ else
+ return table[c - 128];
+}
+
+static KeySym
+make_dead_key (KeySym in)
+{
+ int i;
+
+ for (i = 0; i < sizeof (dead_keys) / sizeof (dead_keys[0]); i++)
+ {
+ if (dead_keys[i].normal == in)
+ return dead_keys[i].dead;
+ }
+
+ return in;
+}
+
+Bool
+DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
+{
+ KeyboardLayoutRef key_layout;
+ const void *chr_data;
+ int num_keycodes = NUM_KEYCODES;
+ UInt32 keyboard_type = 0;
+ int is_uchr, i, j;
+ OSStatus err;
+ KeySym *k;
+
+ KLGetCurrentKeyboardLayout (&key_layout);
+ KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
+
+ if (chr_data != NULL)
+ {
+ is_uchr = 1;
+ keyboard_type = LMGetKbdType ();
+ }
+ else
+ {
+ KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
+
+ if (chr_data == NULL)
+ {
+ ErrorF ( "Couldn't get uchr or kchr resource\n");
+ return FALSE;
+ }
+
+ is_uchr = 0;
+ num_keycodes = 128;
+ }
+
+
+ /* Scan the keycode range for the Unicode character that each
+ key produces in the four shift states. Then convert that to
+ an X11 keysym (which may just the bit that says "this is
+ Unicode" if it can't find the real symbol.) */
+
+ for (i = 0; i < num_keycodes; i++)
+ {
+ static const int mods[4] = {0, MOD_SHIFT, MOD_OPTION,
+ MOD_OPTION | MOD_SHIFT};
+
+ k = info->keyMap + i * GLYPHS_PER_KEY;
+
+ for (j = 0; j < 4; j++)
+ {
+ if (is_uchr)
+ {
+ UniChar s[8];
+ UniCharCount len;
+ UInt32 dead_key_state, extra_dead;
+
+ dead_key_state = 0;
+ err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
+ mods[j] >> 8, keyboard_type, 0,
+ &dead_key_state, 8, &len, s);
+ if (err != noErr)
+ continue;
+
+ if (len == 0 && dead_key_state != 0)
+ {
+ /* Found a dead key. Work out which one it is, but
+ remembering that it's dead. */
+
+ extra_dead = 0;
+ err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
+ mods[j] >> 8, keyboard_type,
+ kUCKeyTranslateNoDeadKeysMask,
+ &extra_dead, 8, &len, s);
+ if (err != noErr)
+ continue;
+ }
+
+ if (len > 0 && s[0] != 0x0010)
+ {
+ k[j] = ucs2keysym (s[0]);
+
+ if (dead_key_state != 0)
+ k[j] = make_dead_key (k[j]);
+ }
+ }
+ else
+ {
+ UInt32 c, state = 0;
+ UInt16 code;
+
+ code = i | mods[j];
+ c = KeyTranslate (chr_data, code, &state);
+
+ /* Dead keys are only processed on key-down, so ask
+ to translate those events. When we find a dead key,
+ translating the matching key up event will give
+ us the actual dead character. */
+
+ if (state != 0)
+ {
+ UInt32 state2 = 0;
+ c = KeyTranslate (chr_data, code | 128, &state2);
+ }
+
+ /* Characters seem to be in MacRoman encoding. */
+
+ if (c != 0 && c != 0x0010)
+ {
+ k[j] = ucs2keysym (macroman2ucs (c & 255));
+
+ if (state != 0)
+ k[j] = make_dead_key (k[j]);
+ }
+ }
+ }
+
+ if (k[3] == k[2])
+ k[3] = NoSymbol;
+ if (k[2] == k[1])
+ k[2] = NoSymbol;
+ if (k[1] == k[0])
+ k[1] = NoSymbol;
+ if (k[0] == k[2] && k[1] == k[3])
+ k[2] = k[3] = NoSymbol;
+ }
+
+ /* Fix up some things that are normally missing.. */
+
+ if (HACK_MISSING)
+ {
+ for (i = 0; i < sizeof (known_keys) / sizeof (known_keys[0]); i++)
+ {
+ k = info->keyMap + known_keys[i].keycode * GLYPHS_PER_KEY;
+
+ if (k[0] == NoSymbol && k[1] == NoSymbol
+ && k[2] == NoSymbol && k[3] == NoSymbol)
+ {
+ k[0] = known_keys[i].keysym;
+ }
+ }
+ }
+
+ /* And some more things. We find the right symbols for the numeric
+ keypad, but not the KP_ keysyms. So try to convert known keycodes. */
+
+ if (HACK_KEYPAD)
+ {
+ for (i = 0; i < sizeof (known_numeric_keys)
+ / sizeof (known_numeric_keys[0]); i++)
+ {
+ k = info->keyMap + known_numeric_keys[i].keycode * GLYPHS_PER_KEY;
+
+ if (k[0] == known_numeric_keys[i].normal)
+ {
+ k[0] = known_numeric_keys[i].keypad;
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+#else /* !HAS_KL_API */
+
+unsigned int
+DarwinModeSystemKeymapSeed (void)
+{
+ return 0;
+}
+
+Bool
+DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
+{
+ return FALSE;
+}
+
+#endif /* HAS_KL_API */
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/quartzPasteboard.c b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzPasteboard.c
new file mode 100644
index 000000000..536dcc336
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzPasteboard.c
@@ -0,0 +1,150 @@
+/**************************************************************
+ * quartzPasteboard.c
+ *
+ * Aqua pasteboard <-> X cut buffer
+ * Greg Parker gparker@cs.stanford.edu March 8, 2001
+ **************************************************************/
+/*
+ * Copyright (c) 2001 Greg Parker. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/quartzPasteboard.c,v 1.3 2001/09/23 04:04:49 torrey Exp $ */
+
+#include "quartzPasteboard.h"
+
+#include <X11/Xatom.h>
+#include "windowstr.h"
+#include "propertyst.h"
+#include "scrnintstr.h"
+#include "selection.h"
+#include "globals.h"
+
+extern Selection *CurrentSelections;
+extern int NumCurrentSelections;
+
+
+// Helper function to read the X11 cut buffer
+// FIXME: What about multiple screens? Currently, this reads the first
+// CUT_BUFFER0 from the first screen where the buffer content is a string.
+// Returns a string on the heap that the caller must free.
+// Returns NULL if there is no cut text or there is not enough memory.
+static char * QuartzReadCutBuffer(void)
+{
+ int i;
+ char *text = NULL;
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ PropertyPtr pProp;
+
+ pProp = wUserProps (WindowTable[pScreen->myNum]);
+ while (pProp && pProp->propertyName != XA_CUT_BUFFER0) {
+ pProp = pProp->next;
+ }
+ if (! pProp) continue;
+ if (pProp->type != XA_STRING) continue;
+ if (pProp->format != 8) continue;
+
+ text = xalloc(1 + pProp->size);
+ if (! text) continue;
+ memcpy(text, pProp->data, pProp->size);
+ text[pProp->size] = '\0';
+ return text;
+ }
+
+ // didn't find any text
+ return NULL;
+}
+
+// Write X cut buffer to Mac OS X pasteboard
+// Called by ProcessInputEvents() in response to request from X server thread.
+void QuartzWritePasteboard(void)
+{
+ char *text;
+ text = QuartzReadCutBuffer();
+ if (text) {
+ QuartzWriteCocoaPasteboard(text);
+ free(text);
+ }
+}
+
+#define strequal(a, b) (0 == strcmp((a), (b)))
+
+// Read Mac OS X pasteboard into X cut buffer
+// Called by ProcessInputEvents() in response to request from X server thread.
+void QuartzReadPasteboard(void)
+{
+ char *oldText = QuartzReadCutBuffer();
+ char *text = QuartzReadCocoaPasteboard();
+
+ // Compare text with current cut buffer contents.
+ // Change the buffer if both exist and are different
+ // OR if there is new text but no old text.
+ // Otherwise, don't clear the selection unnecessarily.
+
+ if ((text && oldText && !strequal(text, oldText)) ||
+ (text && !oldText)) {
+ int scrn, sel;
+
+ for (scrn = 0; scrn < screenInfo.numScreens; scrn++) {
+ ScreenPtr pScreen = screenInfo.screens[scrn];
+ // Set the cut buffers on each screen
+ // fixme really on each screen?
+ ChangeWindowProperty(WindowTable[pScreen->myNum], XA_CUT_BUFFER0,
+ XA_STRING, 8, PropModeReplace,
+ strlen(text), (pointer)text, TRUE);
+ }
+
+ // Undo any current X selection (similar to code in dispatch.c)
+ // FIXME: what about secondary selection?
+ // FIXME: only touch first XA_PRIMARY selection?
+ sel = 0;
+ while ((sel < NumCurrentSelections) &&
+ CurrentSelections[sel].selection != XA_PRIMARY)
+ sel++;
+ if (sel < NumCurrentSelections) {
+ // Notify client if necessary
+ if (CurrentSelections[sel].client) {
+ xEvent event;
+
+ event.u.u.type = SelectionClear;
+ event.u.selectionClear.time = GetTimeInMillis();
+ event.u.selectionClear.window = CurrentSelections[sel].window;
+ event.u.selectionClear.atom = CurrentSelections[sel].selection;
+ TryClientEvents(CurrentSelections[sel].client, &event, 1,
+ NoEventMask, NoEventMask /*CantBeFiltered*/,
+ NullGrab);
+ }
+
+ // Erase it
+ // FIXME: need to erase .selection too? dispatch.c doesn't
+ CurrentSelections[sel].pWin = NullWindow;
+ CurrentSelections[sel].window = None;
+ CurrentSelections[sel].client = NullClient;
+ }
+ }
+
+ if (text) free(text);
+ if (oldText) free(oldText);
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/quartzPasteboard.h b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzPasteboard.h
new file mode 100644
index 000000000..296c52c17
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzPasteboard.h
@@ -0,0 +1,45 @@
+/*
+ QuartzPasteboard.h
+
+ Mac OS X pasteboard <-> X cut buffer
+ Greg Parker gparker@cs.stanford.edu March 8, 2001
+*/
+/*
+ * Copyright (c) 2001 Greg Parker. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/quartzPasteboard.h,v 1.1 2001/03/15 22:24:27 torrey Exp $ */
+
+#ifndef _QUARTZPASTEBOARD_H
+#define _QUARTZPASTEBOARD_H
+
+// Aqua->X
+void QuartzReadPasteboard();
+char * QuartzReadCocoaPasteboard(void); // caller must free string
+
+// X->Aqua
+void QuartzWritePasteboard();
+void QuartzWriteCocoaPasteboard(char *text);
+
+#endif /* _QUARTZPASTEBOARD_H */ \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/quartzStartup.c b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzStartup.c
new file mode 100644
index 000000000..cd58701b1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/quartzStartup.c
@@ -0,0 +1,291 @@
+/**************************************************************
+ *
+ * Startup code for the Quartz Darwin X Server
+ *
+ **************************************************************/
+/*
+ * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzStartup.c,v 1.8 2003/11/05 00:15:00 torrey Exp $ */
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include "quartzCommon.h"
+#include "darwin.h"
+#include "quartz.h"
+#include "opaque.h"
+#include "micmap.h"
+
+int NSApplicationMain(int argc, char *argv[]);
+
+char **envpGlobal; // argcGlobal and argvGlobal
+ // are from dix/globals.c
+
+// GLX bundle function pointers
+typedef void (*GlxExtensionInitPtr)(void);
+static GlxExtensionInitPtr GlxExtensionInit = NULL;
+
+typedef void (*GlxWrapInitVisualsPtr)(miInitVisualsProcPtr *);
+static GlxWrapInitVisualsPtr GlxWrapInitVisuals = NULL;
+
+typedef Bool (*QuartzModeBundleInitPtr)(void);
+
+
+/*
+ * DarwinHandleGUI
+ * This function is called first from main(). The first time
+ * it is called we start the Mac OS X front end. The front end
+ * will call main() again from another thread to run the X
+ * server. On the second call this function loads the user
+ * preferences set by the Mac OS X front end.
+ */
+void DarwinHandleGUI(
+ int argc,
+ char *argv[],
+ char *envp[] )
+{
+ static Bool been_here = FALSE;
+ int main_exit, i;
+ int fd[2];
+
+ if (been_here) {
+ QuartzReadPreferences();
+ return;
+ }
+ been_here = TRUE;
+
+ // Make a pipe to pass events
+ assert( pipe(fd) == 0 );
+ darwinEventReadFD = fd[0];
+ darwinEventWriteFD = fd[1];
+ fcntl(darwinEventReadFD, F_SETFL, O_NONBLOCK);
+
+ // Store command line arguments to pass back to main()
+ argcGlobal = argc;
+ argvGlobal = argv;
+ envpGlobal = envp;
+
+ quartzStartClients = 1;
+ for (i = 1; i < argc; i++) {
+ // Display version info without starting Mac OS X UI if requested
+ if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
+ DarwinPrintBanner();
+ exit(0);
+ }
+
+ // Determine if we need to start X clients
+ // and what display mode to use
+ if (!strcmp(argv[i], "-nostartx")) {
+ quartzStartClients = 0;
+ } else if (!strcmp( argv[i], "-fullscreen")) {
+ quartzRootless = 0;
+ } else if (!strcmp( argv[i], "-rootless")) {
+ quartzRootless = 1;
+ }
+ }
+
+ main_exit = NSApplicationMain(argc, argv);
+ exit(main_exit);
+}
+
+
+/*
+ * QuartzLoadDisplayBundle
+ * Try to load the appropriate bundle containing the back end display code.
+ */
+Bool QuartzLoadDisplayBundle(
+ const char *dpyBundleName)
+{
+ CFBundleRef mainBundle;
+ CFStringRef bundleName;
+ CFURLRef bundleURL;
+ CFBundleRef dpyBundle;
+ QuartzModeBundleInitPtr bundleInit;
+
+ // Get the main bundle for the application
+ mainBundle = CFBundleGetMainBundle();
+
+ // Make CFString from bundle name
+ bundleName = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault,
+ dpyBundleName,
+ kCFStringEncodingASCII,
+ kCFAllocatorNull);
+
+ // Look for the appropriate bundle in the main bundle
+ bundleURL = CFBundleCopyResourceURL(mainBundle, bundleName,
+ NULL, NULL);
+ if (!bundleURL) {
+ ErrorF("Could not find display mode bundle %s.\n", dpyBundleName);
+ return FALSE;
+ }
+
+ // Make a bundle instance using the URLRef
+ dpyBundle = CFBundleCreate(kCFAllocatorDefault, bundleURL);
+
+ if (!CFBundleLoadExecutable(dpyBundle)) {
+ ErrorF("Could not load display mode bundle %s.\n", dpyBundleName);
+ return FALSE;
+ }
+
+ // Lookup the bundle initialization function
+ bundleInit = (void *)
+ CFBundleGetFunctionPointerForName(dpyBundle,
+ CFSTR("QuartzModeBundleInit"));
+ if (!bundleInit) {
+ ErrorF("Could not initialize display mode bundle %s.\n",
+ dpyBundleName);
+ return FALSE;
+ }
+ if (!bundleInit())
+ return FALSE;
+
+ // Release the CF objects
+ CFRelease(bundleName);
+ CFRelease(bundleURL);
+
+ return TRUE;
+}
+
+
+/*
+ * LoadGlxBundle
+ * The Quartz mode X server needs to dynamically load the appropriate
+ * bundle before initializing GLX.
+ */
+static void LoadGlxBundle(void)
+{
+ CFBundleRef mainBundle;
+ CFStringRef bundleName;
+ CFURLRef bundleURL;
+ CFBundleRef glxBundle;
+
+ // Get the main bundle for the application
+ mainBundle = CFBundleGetMainBundle();
+
+ // Choose the bundle to load
+ ErrorF("Loading GLX bundle ");
+ if (quartzUseAGL) {
+ bundleName = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault,
+ quartzOpenGLBundle,
+ kCFStringEncodingASCII,
+ kCFAllocatorNull);
+ ErrorF("%s (using Apple's OpenGL)\n", quartzOpenGLBundle);
+ } else {
+ bundleName = CFSTR("glxMesa.bundle");
+ CFRetain(bundleName); // so we can release later
+ ErrorF("glxMesa.bundle (using Mesa)\n");
+ }
+
+ // Look for the appropriate GLX bundle in the main bundle by name
+ bundleURL = CFBundleCopyResourceURL(mainBundle, bundleName,
+ NULL, NULL);
+ if (!bundleURL) {
+ FatalError("Could not find GLX bundle.");
+ }
+
+ // Make a bundle instance using the URLRef
+ glxBundle = CFBundleCreate(kCFAllocatorDefault, bundleURL);
+
+ if (!CFBundleLoadExecutable(glxBundle)) {
+ FatalError("Could not load GLX bundle.");
+ }
+
+ // Find the GLX init functions
+ GlxExtensionInit = (void *) CFBundleGetFunctionPointerForName(
+ glxBundle, CFSTR("GlxExtensionInit"));
+
+ GlxWrapInitVisuals = (void *) CFBundleGetFunctionPointerForName(
+ glxBundle, CFSTR("GlxWrapInitVisuals"));
+
+ if (!GlxExtensionInit || !GlxWrapInitVisuals) {
+ FatalError("Could not initialize GLX bundle.");
+ }
+
+ // Release the CF objects
+ CFRelease(bundleName);
+ CFRelease(bundleURL);
+}
+
+
+/*
+ * DarwinGlxExtensionInit
+ * Initialize the GLX extension.
+ */
+void DarwinGlxExtensionInit(void)
+{
+ if (!GlxExtensionInit)
+ LoadGlxBundle();
+
+ GlxExtensionInit();
+}
+
+
+/*
+ * DarwinGlxWrapInitVisuals
+ */
+void DarwinGlxWrapInitVisuals(
+ miInitVisualsProcPtr *procPtr)
+{
+ if (!GlxWrapInitVisuals)
+ LoadGlxBundle();
+
+ GlxWrapInitVisuals(procPtr);
+}
+
+
+int DarwinModeProcessArgument( int argc, char *argv[], int i )
+{
+ // fullscreen: CoreGraphics full-screen mode
+ // rootless: Cocoa rootless mode
+ // quartz: Default, either fullscreen or rootless
+
+ if ( !strcmp( argv[i], "-fullscreen" ) ) {
+ ErrorF( "Running full screen in parallel with Mac OS X Quartz window server.\n" );
+ return 1;
+ }
+
+ if ( !strcmp( argv[i], "-rootless" ) ) {
+ ErrorF( "Running rootless inside Mac OS X window server.\n" );
+ return 1;
+ }
+
+ if ( !strcmp( argv[i], "-quartz" ) ) {
+ ErrorF( "Running in parallel with Mac OS X Quartz window server.\n" );
+ return 1;
+ }
+
+ // The Mac OS X front end uses this argument, which we just ignore here.
+ if ( !strcmp( argv[i], "-nostartx" ) ) {
+ return 1;
+ }
+
+ // This command line arg is passed when launched from the Aqua GUI.
+ if ( !strncmp( argv[i], "-psn_", 5 ) ) {
+ return 1;
+ }
+
+ return 0;
+} \ No newline at end of file
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/Imakefile b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/Imakefile
new file mode 100644
index 000000000..77a420958
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/Imakefile
@@ -0,0 +1,35 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/Imakefile,v 1.3 2003/08/12 23:47:10 torrey Exp $
+
+#include <Server.tmpl>
+
+SRCS = appledir.c \
+ dri.c \
+ xprAppleWM.c \
+ xprCursor.c \
+ xprFrame.c \
+ xprScreen.c \
+ x-hash.c \
+ x-hook.c \
+ x-list.c
+
+OBJS = appledri.o \
+ dri.o \
+ xprAppleWM.o \
+ xprCursor.o \
+ xprFrame.o \
+ xprScreen.o \
+ x-hash.o \
+ x-hook.o \
+ x-list.o
+
+INCLUDES = -I. -I$(SERVERSRC)/fb -I$(SERVERSRC)/mi -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(SERVERSRC)/render \
+ -I$(SERVERSRC)/miext/rootless -I$(SERVERSRC)/miext/damage \
+ -I$(EXTINCSRC) -I.. -I../.. \
+ -I$(SERVERSRC)/miext/rootless/safeAlpha \
+ -I$(SERVERSRC)/Xext -I$(LIBSRC)/GL/apple -I$(APPLEWMLIBSRC)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(xpr,$(OBJS))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/Xplugin.h b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/Xplugin.h
new file mode 100644
index 000000000..7673a0de3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/Xplugin.h
@@ -0,0 +1,591 @@
+/* Xplugin.h -- windowing API for rootless X11 server
+ $Id: Xplugin.h,v 1.3 2005/07/01 22:43:08 daniels Exp $
+
+ Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name(s) of the above
+ copyright holders shall not be used in advertising or otherwise to
+ promote the sale, use or other dealings in this Software without
+ prior written authorization.
+
+ Note that these interfaces are provided solely for the use of the
+ X11 server. Any other uses are unsupported and strongly discouraged. */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/Xplugin.h,v 1.2 2003/05/02 00:08:49 torrey Exp $ */
+
+#ifndef XPLUGIN_H
+#define XPLUGIN_H 1
+
+#include <stdint.h>
+
+/* By default we use the X server definition of BoxRec to define xp_box,
+ so that the compiler can silently convert between the two. But if
+ XP_NO_X_HEADERS is defined, we'll define it ourselves. */
+
+#ifndef XP_NO_X_HEADERS
+# include "miscstruct.h"
+ typedef BoxRec xp_box;
+#else
+ struct xp_box_struct {
+ short x1, y1, x2, y2;
+ };
+ typedef struct xp_box_struct xp_box;
+#endif
+
+typedef unsigned int xp_resource_id;
+typedef xp_resource_id xp_window_id;
+typedef xp_resource_id xp_surface_id;
+typedef unsigned int xp_client_id;
+typedef unsigned int xp_request_type;
+typedef int xp_error;
+typedef int xp_bool;
+
+
+/* Error codes that the functions declared here may return. They all
+ numerically match their X equivalents, i.e. the XP_ can be dropped
+ if <X11/X.h> has been included. */
+
+enum xp_error_enum {
+ XP_Success = 0,
+ XP_BadRequest = 1,
+ XP_BadValue = 2,
+ XP_BadWindow = 3,
+ XP_BadMatch = 8,
+ XP_BadAccess = 10,
+ XP_BadImplementation = 17,
+};
+
+
+/* Event types generated by the plugin. */
+
+enum xp_event_type_enum {
+ /* The global display configuration changed somehow. */
+ XP_EVENT_DISPLAY_CHANGED = 1 << 0,
+
+ /* A window changed state. Argument is xp_window_state_event */
+ XP_EVENT_WINDOW_STATE_CHANGED = 1 << 1,
+
+ /* An async request encountered an error. Argument is of type
+ xp_async_error_event */
+ XP_EVENT_ASYNC_ERROR = 1 << 2,
+
+ /* Sent when a surface is destroyed as a side effect of destroying
+ a window. Arg is of type xp_surface_id. */
+ XP_EVENT_SURFACE_DESTROYED = 1 << 3,
+
+ /* Sent when any GL contexts pointing at the given surface need to
+ call xp_update_gl_context () to refresh their state (because the
+ window moved or was resized. Arg is of type xp_surface_id. */
+ XP_EVENT_SURFACE_CHANGED = 1 << 4,
+
+ /* Sent when a window has been moved. Arg is of type xp_window_id. */
+ XP_EVENT_WINDOW_MOVED = 1 << 5,
+};
+
+/* Function type used to receive events. */
+
+typedef void (xp_event_fun) (unsigned int type, const void *arg,
+ unsigned int arg_size, void *user_data);
+
+
+/* Operation types. Used when reporting errors asynchronously. */
+
+enum xp_request_type_enum {
+ XP_REQUEST_NIL = 0,
+ XP_REQUEST_DESTROY_WINDOW = 1,
+ XP_REQUEST_CONFIGURE_WINDOW = 2,
+ XP_REQUEST_FLUSH_WINDOW = 3,
+ XP_REQUEST_COPY_WINDOW = 4,
+ XP_REQUEST_UNLOCK_WINDOW = 5,
+ XP_REQUEST_DISABLE_UPDATE = 6,
+ XP_REQUEST_REENABLE_UPDATE = 7,
+ XP_REQUEST_HIDE_CURSOR = 8,
+ XP_REQUEST_SHOW_CURSOR = 9,
+ XP_REQUEST_FRAME_DRAW = 10,
+};
+
+/* Structure used to report an error asynchronously. Passed as the "arg"
+ of an XP_EVENT_ASYNC_ERROR event. */
+
+struct xp_async_error_event_struct {
+ xp_request_type request_type;
+ xp_resource_id id;
+ xp_error error;
+};
+
+typedef struct xp_async_error_event_struct xp_async_error_event;
+
+
+/* Possible window states. */
+
+enum xp_window_state_enum {
+ /* The window is not in the global list of possibly-visible windows. */
+ XP_WINDOW_STATE_OFFSCREEN = 1 << 0,
+
+ /* Parts of the window may be obscured by other windows. */
+ XP_WINDOW_STATE_OBSCURED = 1 << 1,
+};
+
+/* Structure passed as argument of an XP_EVENT_WINDOW_STATE_CHANGED event. */
+
+struct xp_window_state_event_struct {
+ xp_window_id id;
+ unsigned int state;
+};
+
+typedef struct xp_window_state_event_struct xp_window_state_event;
+
+
+/* Function type used to supply a colormap for indexed drawables. */
+
+typedef xp_error (xp_colormap_fun) (void *data, int first_color,
+ int n_colors, uint32_t *colors);
+
+
+/* Window attributes structure. Used when creating and configuring windows.
+ Also used when configuring surfaces attached to windows. Functions that
+ take one of these structures also take a bit mask defining which
+ fields are set to meaningful values. */
+
+enum xp_window_changes_enum {
+ XP_ORIGIN = 1 << 0,
+ XP_SIZE = 1 << 1,
+ XP_BOUNDS = XP_ORIGIN | XP_SIZE,
+ XP_SHAPE = 1 << 2,
+ XP_STACKING = 1 << 3,
+ XP_DEPTH = 1 << 4,
+ XP_COLORMAP = 1 << 5,
+ XP_WINDOW_LEVEL = 1 << 6,
+};
+
+struct xp_window_changes_struct {
+ /* XP_ORIGIN */
+ int x, y;
+
+ /* XP_SIZE */
+ unsigned int width, height;
+ int bit_gravity; /* how to resize the backing store */
+
+ /* XP_SHAPE */
+ int shape_nrects; /* -1 = remove shape */
+ xp_box *shape_rects;
+ int shape_tx, shape_ty; /* translation for shape */
+
+ /* XP_STACKING */
+ int stack_mode;
+ xp_window_id sibling; /* may be zero; in ABOVE/BELOW modes
+ it may specify a relative window */
+ /* XP_DEPTH, window-only */
+ unsigned int depth;
+
+ /* XP_COLORMAP, window-only */
+ xp_colormap_fun *colormap;
+ void *colormap_data;
+
+ /* XP_WINDOW_LEVEL, window-only */
+ int window_level;
+};
+
+typedef struct xp_window_changes_struct xp_window_changes;
+
+/* Values for bit_gravity field */
+
+enum xp_bit_gravity_enum {
+ XP_GRAVITY_NONE = 0, /* no gravity, fill everything */
+ XP_GRAVITY_NORTH_WEST = 1, /* anchor to top-left corner */
+ XP_GRAVITY_NORTH_EAST = 2, /* anchor to top-right corner */
+ XP_GRAVITY_SOUTH_EAST = 3, /* anchor to bottom-right corner */
+ XP_GRAVITY_SOUTH_WEST = 4, /* anchor to bottom-left corner */
+};
+
+/* Values for stack_mode field */
+
+enum xp_window_stack_mode_enum {
+ XP_UNMAPPED = 0, /* remove the window */
+ XP_MAPPED_ABOVE = 1, /* display the window on top */
+ XP_MAPPED_BELOW = 2, /* display the window at bottom */
+};
+
+/* Data formats for depth field and composite functions */
+
+enum xp_depth_enum {
+ XP_DEPTH_NIL = 0, /* null source when compositing */
+ XP_DEPTH_ARGB8888,
+ XP_DEPTH_RGB555,
+ XP_DEPTH_A8, /* for masks when compositing */
+ XP_DEPTH_INDEX8,
+};
+
+/* Options that may be passed to the xp_init () function. */
+
+enum xp_init_options_enum {
+ /* Don't mark that this process can be in the foreground. */
+ XP_IN_BACKGROUND = 1 << 0,
+
+ /* Deliver background pointer events to this process. */
+ XP_BACKGROUND_EVENTS = 1 << 1,
+};
+
+
+
+/* Miscellaneous functions */
+
+/* Initialize the plugin library. Only the copy/fill/composite functions
+ may be called without having previously called xp_init () */
+
+extern xp_error xp_init (unsigned int options);
+
+/* Sets the current set of requested notifications to MASK. When any of
+ these arrive, CALLBACK will be invoked with CALLBACK-DATA. Note that
+ calling this function cancels any previously requested notifications
+ that aren't set in MASK. */
+
+extern xp_error xp_select_events (unsigned int mask,
+ xp_event_fun *callback,
+ void *callback_data);
+
+/* Waits for all initiated operations to complete. */
+
+extern xp_error xp_synchronize (void);
+
+/* Causes any display update initiated through the plugin libary to be
+ queued until update is reenabled. Note that calls to these functions
+ nest. */
+
+extern xp_error xp_disable_update (void);
+extern xp_error xp_reenable_update (void);
+
+
+
+/* Cursor functions. */
+
+/* Installs the specified cursor. ARGB-DATA should point to 32-bit
+ premultiplied big-endian ARGB data. The HOT-X,HOT-Y parameters
+ specify the offset to the cursor's hot spot from its top-left
+ corner. */
+
+extern xp_error xp_set_cursor (unsigned int width, unsigned int height,
+ unsigned int hot_x, unsigned int hot_y,
+ const uint32_t *argb_data,
+ unsigned int rowbytes);
+
+/* Hide and show the cursor if it's owned by the current process. Calls
+ to these functions nest. */
+
+extern xp_error xp_hide_cursor (void);
+extern xp_error xp_show_cursor (void);
+
+
+
+/* Window functions. */
+
+/* Create a new window as defined by MASK and VALUES. MASK must contain
+ XP_BOUNDS or an error is raised. The id of the newly created window
+ is stored in *RET-ID if this function returns XP_Success. */
+
+extern xp_error xp_create_window (unsigned int mask,
+ const xp_window_changes *values,
+ xp_window_id *ret_id);
+
+/* Destroys the window identified by ID. */
+
+extern xp_error xp_destroy_window (xp_window_id id);
+
+/* Reconfigures the given window according to MASK and VALUES. */
+
+extern xp_error xp_configure_window (xp_window_id id, unsigned int mask,
+ const xp_window_changes *values);
+
+
+/* Returns true if NATIVE-ID is a window created by the plugin library.
+ If so and RET-ID is non-null, stores the id of the window in *RET-ID. */
+
+extern xp_bool xp_lookup_native_window (unsigned int native_id,
+ xp_window_id *ret_id);
+
+/* If ID names a window created by the plugin library, stores it's native
+ window id in *RET-NATIVE-ID. */
+
+extern xp_error xp_get_native_window (xp_window_id id,
+ unsigned int *ret_native_id);
+
+
+/* Locks the rectangle IN-RECT (or, if null, the entire window) of the
+ given window's backing store. Any other non-null parameters are filled
+ in as follows:
+
+ DEPTH = format of returned data. Currently either XP_DEPTH_ARGB8888
+ or XP_DEPTH_RGB565 (possibly with 8 bit planar alpha). Data is
+ always stored in native byte order.
+
+ BITS[0] = pointer to top-left pixel of locked color data
+ BITS[1] = pointer to top-left of locked alpha data, or null if window
+ has no alpha. If the alpha data is meshed, then BITS[1] = BITS[0].
+
+ ROWBYTES[0,1] = size in bytes of each row of color,alpha data
+
+ OUT-RECT = rectangle specifying the current position and size of the
+ locked region relative to the window origin.
+
+ Note that an error is raised when trying to lock an already locked
+ window. While the window is locked, the only operations that may
+ be performed on it are to modify, access or flush its marked region. */
+
+extern xp_error xp_lock_window (xp_window_id id,
+ const xp_box *in_rect,
+ unsigned int *depth,
+ void *bits[2],
+ unsigned int rowbytes[2],
+ xp_box *out_rect);
+
+/* Mark that the region specified by SHAPE-NRECTS, SHAPE-RECTS,
+ SHAPE-TX, and SHAPE-TY in the specified window has been updated, and
+ will need to subsequently be redisplayed. */
+
+extern xp_error xp_mark_window (xp_window_id id, int shape_nrects,
+ const xp_box *shape_rects,
+ int shape_tx, int shape_ty);
+
+/* Unlocks the specified window. If FLUSH is true, then any marked
+ regions are immediately redisplayed. Note that it's an error to
+ unlock an already unlocked window. */
+
+extern xp_error xp_unlock_window (xp_window_id id, xp_bool flush);
+
+/* If anything is marked in the given window for redisplay, do it now. */
+
+extern xp_error xp_flush_window (xp_window_id id);
+
+/* Moves the contents of the region DX,DY pixels away from that specified
+ by DST_RECTS and DST_NRECTS in the window with SRC-ID to the
+ destination region in the window DST-ID. Note that currently source
+ and destination windows must be the same. */
+
+extern xp_error xp_copy_window (xp_window_id src_id, xp_window_id dst_id,
+ int dst_nrects, const xp_box *dst_rects,
+ int dx, int dy);
+
+/* Returns true if the given window has any regions marked for
+ redisplay. */
+
+extern xp_bool xp_is_window_marked (xp_window_id id);
+
+/* If successful returns a superset of the region marked for update in
+ the given window. Use xp_free_region () to release the returned data. */
+
+extern xp_error xp_get_marked_shape (xp_window_id id,
+ int *ret_nrects, xp_box **ret_rects);
+
+extern void xp_free_shape (int nrects, xp_box *rects);
+
+/* Searches for the first window below ABOVE-ID containing the point X,Y,
+ and returns it's window id in *RET-ID. If no window is found, *RET-ID
+ is set to zero. If ABOVE-ID is zero, finds the topmost window
+ containing the given point. */
+
+extern xp_error xp_find_window (int x, int y, xp_window_id above_id,
+ xp_window_id *ret_id);
+
+/* Returns the current origin and size of the window ID in *BOUNDS-RET if
+ successful. */
+extern xp_error xp_get_window_bounds (xp_window_id id, xp_box *bounds_ret);
+
+
+
+/* Window surface functions. */
+
+/* Create a new VRAM surface on the specified window. If successful,
+ returns the identifier of the new surface in *RET-SID. */
+
+extern xp_error xp_create_surface (xp_window_id id, xp_surface_id *ret_sid);
+
+/* Destroys the specified surface. */
+
+extern xp_error xp_destroy_surface (xp_surface_id sid);
+
+/* Reconfigures the specified surface as defined by MASK and VALUES.
+ Note that specifying XP_DEPTH is an error. */
+
+extern xp_error xp_configure_surface (xp_surface_id sid, unsigned int mask,
+ const xp_window_changes *values);
+
+/* If successful, places the client identifier of the current process
+ in *RET-CLIENT. */
+
+extern xp_error xp_get_client_id (xp_client_id *ret_client);
+
+/* Given a valid window,surface combination created by the current
+ process, attempts to allow the specified external client access
+ to that surface. If successful, returns two integers in RET-KEY
+ which the client can use to import the surface into their process. */
+
+extern xp_error xp_export_surface (xp_window_id wid, xp_surface_id sid,
+ xp_client_id client,
+ unsigned int ret_key[2]);
+
+/* Given a two integer key returned from xp_export_surface (), tries
+ to import the surface into the current process. If successful the
+ local surface identifier is stored in *SID-RET. */
+
+extern xp_error xp_import_surface (const unsigned int key[2],
+ xp_surface_id *sid_ret);
+
+/* If successful, stores the number of surfaces attached to the
+ specified window in *RET. */
+
+extern xp_error xp_get_window_surface_count (xp_window_id id,
+ unsigned int *ret);
+
+/* Attaches the CGLContextObj CGL-CTX to the specified surface. */
+
+extern xp_error xp_attach_gl_context (void *cgl_ctx, xp_surface_id sid);
+
+/* Updates the CGLContextObj CGL-CTX to reflect any recent changes to
+ the surface it's attached to. */
+
+extern xp_error xp_update_gl_context (void *cgl_ctx);
+
+
+
+/* Window frame functions. */
+
+/* Possible arguments to xp_frame_get_rect (). */
+
+enum xp_frame_rect_enum {
+ XP_FRAME_RECT_TITLEBAR = 1,
+ XP_FRAME_RECT_TRACKING = 2,
+ XP_FRAME_RECT_GROWBOX = 3,
+};
+
+/* Classes of window frame. */
+
+enum xp_frame_class_enum {
+ XP_FRAME_CLASS_DOCUMENT = 1 << 0,
+ XP_FRAME_CLASS_DIALOG = 1 << 1,
+ XP_FRAME_CLASS_MODAL_DIALOG = 1 << 2,
+ XP_FRAME_CLASS_SYSTEM_MODAL_DIALOG = 1 << 3,
+ XP_FRAME_CLASS_UTILITY = 1 << 4,
+ XP_FRAME_CLASS_TOOLBAR = 1 << 5,
+ XP_FRAME_CLASS_MENU = 1 << 6,
+ XP_FRAME_CLASS_SPLASH = 1 << 7,
+ XP_FRAME_CLASS_BORDERLESS = 1 << 8,
+};
+
+/* Attributes of window frames. */
+
+enum xp_frame_attr_enum {
+ XP_FRAME_ACTIVE = 0x0001,
+ XP_FRAME_URGENT = 0x0002,
+ XP_FRAME_TITLE = 0x0004,
+ XP_FRAME_PRELIGHT = 0x0008,
+ XP_FRAME_SHADED = 0x0010,
+ XP_FRAME_CLOSE_BOX = 0x0100,
+ XP_FRAME_COLLAPSE = 0x0200,
+ XP_FRAME_ZOOM = 0x0400,
+ XP_FRAME_ANY_BUTTON = 0x0700,
+ XP_FRAME_CLOSE_BOX_CLICKED = 0x0800,
+ XP_FRAME_COLLAPSE_BOX_CLICKED = 0x1000,
+ XP_FRAME_ZOOM_BOX_CLICKED = 0x2000,
+ XP_FRAME_ANY_CLICKED = 0x3800,
+ XP_FRAME_GROW_BOX = 0x4000,
+};
+
+#define XP_FRAME_ATTR_IS_SET(a,b) (((a) & (b)) == (b))
+#define XP_FRAME_ATTR_IS_CLICKED(a,m) ((a) & ((m) << 3))
+#define XP_FRAME_ATTR_SET_CLICKED(a,m) ((a) |= ((m) << 3))
+#define XP_FRAME_ATTR_UNSET_CLICKED(a,m) ((a) &= ~((m) << 3))
+
+#define XP_FRAME_POINTER_ATTRS (XP_FRAME_PRELIGHT \
+ | XP_FRAME_ANY_BUTTON \
+ | XP_FRAME_ANY_CLICKED)
+
+extern xp_error xp_frame_get_rect (int type, int class, const xp_box *outer,
+ const xp_box *inner, xp_box *ret);
+extern xp_error xp_frame_hit_test (int class, int x, int y,
+ const xp_box *outer,
+ const xp_box *inner, int *ret);
+extern xp_error xp_frame_draw (xp_window_id wid, int class, unsigned int attr,
+ const xp_box *outer, const xp_box *inner,
+ unsigned int title_len,
+ const unsigned char *title_bytes);
+
+
+
+/* Memory manipulation functions. */
+
+enum xp_composite_op_enum {
+ XP_COMPOSITE_SRC = 0,
+ XP_COMPOSITE_OVER,
+};
+
+#define XP_COMPOSITE_FUNCTION(op, src_depth, mask_depth, dest_depth) \
+ (((op) << 24) | ((src_depth) << 16) \
+ | ((mask_depth) << 8) | ((dest_depth) << 0))
+
+#define XP_COMPOSITE_FUNCTION_OP(f) (((f) >> 24) & 255)
+#define XP_COMPOSITE_FUNCTION_SRC_DEPTH(f) (((f) >> 16) & 255)
+#define XP_COMPOSITE_FUNCTION_MASK_DEPTH(f) (((f) >> 8) & 255)
+#define XP_COMPOSITE_FUNCTION_DEST_DEPTH(f) (((f) >> 0) & 255)
+
+/* Composite WIDTH by HEIGHT pixels from source and mask to destination
+ using a specified function (if source and destination overlap,
+ undefined behavior results).
+
+ For SRC and DEST, the first element of the array is the color data. If
+ the second element is non-null it implies that there is alpha data
+ (which may be meshed or planar). Data without alpha is assumed to be
+ opaque.
+
+ Passing a null SRC-ROWBYTES pointer implies that the data SRC points
+ to is a single element.
+
+ Operations that are not supported will return XP_BadImplementation. */
+
+extern xp_error xp_composite_pixels (unsigned int width, unsigned int height,
+ unsigned int function,
+ void *src[2], unsigned int src_rowbytes[2],
+ void *mask, unsigned int mask_rowbytes,
+ void *dest[2], unsigned int dest_rowbytes[2]);
+
+/* Fill HEIGHT rows of data starting at DST. Each row will have WIDTH
+ bytes filled with the 32-bit pattern VALUE. Each row is DST-ROWBYTES
+ wide in total. */
+
+extern void xp_fill_bytes (unsigned int width,
+ unsigned int height, uint32_t value,
+ void *dst, unsigned int dst_rowbytes);
+
+/* Copy HEIGHT rows of bytes from SRC to DST. Each row will have WIDTH
+ bytes copied. SRC and DST may overlap, and the right thing will happen. */
+
+extern void xp_copy_bytes (unsigned int width, unsigned int height,
+ const void *src, unsigned int src_rowbytes,
+ void *dst, unsigned int dst_rowbytes);
+
+/* Suggestions for the minimum number of bytes or pixels for which it
+ makes sense to use some of the xp_ functions */
+
+extern unsigned int xp_fill_bytes_threshold, xp_copy_bytes_threshold,
+ xp_composite_area_threshold, xp_scroll_area_threshold;
+
+
+#endif /* XPLUGIN_H */
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/appledri.c b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/appledri.c
new file mode 100644
index 000000000..d4cd27b8f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/appledri.c
@@ -0,0 +1,350 @@
+/* $XFree86: xc/programs/Xserver/GL/dri/xf86dri.c,v 1.10 2000/12/07 20:26:14 dawes Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+Copyright (c) 2002 Apple Computer, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <martin@valinux.com>
+ * Jens Owen <jens@valinux.com>
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#define _APPLEDRI_SERVER_
+#include "appledristr.h"
+#include "swaprep.h"
+#include "dri.h"
+#include "dristruct.h"
+
+static int DRIErrorBase = 0;
+
+static DISPATCH_PROC(ProcAppleDRIDispatch);
+static DISPATCH_PROC(SProcAppleDRIDispatch);
+
+static void AppleDRIResetProc(ExtensionEntry* extEntry);
+
+static unsigned char DRIReqCode = 0;
+static int DRIEventBase = 0;
+
+static void SNotifyEvent(xAppleDRINotifyEvent *from, xAppleDRINotifyEvent *to);
+
+typedef struct _DRIEvent *DRIEventPtr;
+typedef struct _DRIEvent {
+ DRIEventPtr next;
+ ClientPtr client;
+ XID clientResource;
+ unsigned int mask;
+} DRIEventRec;
+
+
+void
+AppleDRIExtensionInit(void)
+{
+ ExtensionEntry* extEntry;
+
+ if (DRIExtensionInit() &&
+ (extEntry = AddExtension(APPLEDRINAME,
+ AppleDRINumberEvents,
+ AppleDRINumberErrors,
+ ProcAppleDRIDispatch,
+ SProcAppleDRIDispatch,
+ AppleDRIResetProc,
+ StandardMinorOpcode))) {
+ DRIReqCode = (unsigned char)extEntry->base;
+ DRIErrorBase = extEntry->errorBase;
+ DRIEventBase = extEntry->eventBase;
+ EventSwapVector[DRIEventBase] = (EventSwapPtr) SNotifyEvent;
+ }
+}
+
+/*ARGSUSED*/
+static void
+AppleDRIResetProc (
+ ExtensionEntry* extEntry
+)
+{
+ DRIReset();
+}
+
+static int
+ProcAppleDRIQueryVersion(
+ register ClientPtr client
+)
+{
+ xAppleDRIQueryVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xAppleDRIQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = APPLE_DRI_MAJOR_VERSION;
+ rep.minorVersion = APPLE_DRI_MINOR_VERSION;
+ rep.patchVersion = APPLE_DRI_PATCH_VERSION;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ }
+ WriteToClient(client, sizeof(xAppleDRIQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+
+/* surfaces */
+
+static int
+ProcAppleDRIQueryDirectRenderingCapable(
+ register ClientPtr client
+)
+{
+ xAppleDRIQueryDirectRenderingCapableReply rep;
+ Bool isCapable;
+
+ REQUEST(xAppleDRIQueryDirectRenderingCapableReq);
+ REQUEST_SIZE_MATCH(xAppleDRIQueryDirectRenderingCapableReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!DRIQueryDirectRenderingCapable( screenInfo.screens[stuff->screen],
+ &isCapable)) {
+ return BadValue;
+ }
+ rep.isCapable = isCapable;
+
+ if (!LocalClient(client))
+ rep.isCapable = 0;
+
+ WriteToClient(client,
+ sizeof(xAppleDRIQueryDirectRenderingCapableReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcAppleDRIAuthConnection(
+ register ClientPtr client
+)
+{
+ xAppleDRIAuthConnectionReply rep;
+
+ REQUEST(xAppleDRIAuthConnectionReq);
+ REQUEST_SIZE_MATCH(xAppleDRIAuthConnectionReq);
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.authenticated = 1;
+
+ if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) {
+ ErrorF("Failed to authenticate %u\n", stuff->magic);
+ rep.authenticated = 0;
+ }
+ WriteToClient(client, sizeof(xAppleDRIAuthConnectionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static void surface_notify(
+ void *_arg,
+ void *data
+)
+{
+ DRISurfaceNotifyArg *arg = _arg;
+ int client_index = (int) data;
+ ClientPtr client;
+ xAppleDRINotifyEvent se;
+
+ if (client_index < 0 || client_index >= currentMaxClients)
+ return;
+
+ client = clients[client_index];
+ if (client == NULL || client == serverClient || client->clientGone)
+ return;
+
+ se.type = DRIEventBase + AppleDRISurfaceNotify;
+ se.kind = arg->kind;
+ se.arg = arg->id;
+ se.sequenceNumber = client->sequence;
+ se.time = currentTime.milliseconds;
+ WriteEventsToClient (client, 1, (xEvent *) &se);
+}
+
+static int
+ProcAppleDRICreateSurface(
+ ClientPtr client
+)
+{
+ xAppleDRICreateSurfaceReply rep;
+ DrawablePtr pDrawable;
+ xp_surface_id sid;
+ unsigned int key[2];
+
+ REQUEST(xAppleDRICreateSurfaceReq);
+ REQUEST_SIZE_MATCH(xAppleDRICreateSurfaceReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable(
+ (Drawable)stuff->drawable,
+ client,
+ SecurityReadAccess))) {
+ return BadValue;
+ }
+
+ rep.key_0 = rep.key_1 = rep.uid = 0;
+
+ if (!DRICreateSurface( screenInfo.screens[stuff->screen],
+ (Drawable)stuff->drawable, pDrawable,
+ stuff->client_id, &sid, key,
+ surface_notify, (void *) client->index)) {
+ return BadValue;
+ }
+
+ rep.key_0 = key[0];
+ rep.key_1 = key[1];
+ rep.uid = sid;
+
+ WriteToClient(client, sizeof(xAppleDRICreateSurfaceReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcAppleDRIDestroySurface(
+ register ClientPtr client
+)
+{
+ REQUEST(xAppleDRIDestroySurfaceReq);
+ DrawablePtr pDrawable;
+ REQUEST_SIZE_MATCH(xAppleDRIDestroySurfaceReq);
+
+ if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable(
+ (Drawable)stuff->drawable,
+ client,
+ SecurityReadAccess))) {
+ return BadValue;
+ }
+
+ if (!DRIDestroySurface( screenInfo.screens[stuff->screen],
+ (Drawable)stuff->drawable,
+ pDrawable, NULL, NULL)) {
+ return BadValue;
+ }
+
+ return (client->noClientException);
+}
+
+
+/* dispatch */
+
+static int
+ProcAppleDRIDispatch (
+ register ClientPtr client
+)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_AppleDRIQueryVersion:
+ return ProcAppleDRIQueryVersion(client);
+ case X_AppleDRIQueryDirectRenderingCapable:
+ return ProcAppleDRIQueryDirectRenderingCapable(client);
+ }
+
+ if (!LocalClient(client))
+ return DRIErrorBase + AppleDRIClientNotLocal;
+
+ switch (stuff->data)
+ {
+ case X_AppleDRIAuthConnection:
+ return ProcAppleDRIAuthConnection(client);
+ case X_AppleDRICreateSurface:
+ return ProcAppleDRICreateSurface(client);
+ case X_AppleDRIDestroySurface:
+ return ProcAppleDRIDestroySurface(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static void
+SNotifyEvent(
+ xAppleDRINotifyEvent *from,
+ xAppleDRINotifyEvent *to
+)
+{
+ to->type = from->type;
+ to->kind = from->kind;
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswapl (from->time, to->time);
+ cpswapl (from->arg, to->arg);
+}
+
+static int
+SProcAppleDRIQueryVersion(
+ register ClientPtr client
+)
+{
+ register int n;
+ REQUEST(xAppleDRIQueryVersionReq);
+ swaps(&stuff->length, n);
+ return ProcAppleDRIQueryVersion(client);
+}
+
+static int
+SProcAppleDRIDispatch (
+ register ClientPtr client
+)
+{
+ REQUEST(xReq);
+
+ /* It is bound to be non-local when there is byte swapping */
+ if (!LocalClient(client))
+ return DRIErrorBase + AppleDRIClientNotLocal;
+
+ /* only local clients are allowed DRI access */
+ switch (stuff->data)
+ {
+ case X_AppleDRIQueryVersion:
+ return SProcAppleDRIQueryVersion(client);
+ default:
+ return BadRequest;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dri.c b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dri.c
new file mode 100644
index 000000000..e8e49f965
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dri.c
@@ -0,0 +1,757 @@
+/* $XFree86: xc/programs/Xserver/GL/dri/dri.c,v 1.34 2001/12/10 19:07:19 dawes Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+Copyright (c) 2002 Apple Computer, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Jens Owen <jens@valinux.com>
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#ifdef XFree86LOADER
+#include "xf86.h"
+#include "xf86_ansic.h"
+#else
+#include <sys/time.h>
+#include <unistd.h>
+#endif
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#define _APPLEDRI_SERVER_
+#include "appledristr.h"
+#include "swaprep.h"
+#include "dri.h"
+#include "dristruct.h"
+#include "mi.h"
+#include "mipointer.h"
+#include "rootless.h"
+#include "x-hash.h"
+#include "x-hook.h"
+
+#include <AvailabilityMacros.h>
+
+static int DRIScreenPrivIndex = -1;
+static int DRIWindowPrivIndex = -1;
+static int DRIPixmapPrivIndex = -1;
+
+static RESTYPE DRIDrawablePrivResType;
+
+static x_hash_table *surface_hash; /* maps surface ids -> drawablePrivs */
+
+/* FIXME: don't hardcode this? */
+#define CG_INFO_FILE "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Resources/Info-macos.plist"
+
+/* Corresponds to SU Jaguar Green */
+#define CG_REQUIRED_MAJOR 1
+#define CG_REQUIRED_MINOR 157
+#define CG_REQUIRED_MICRO 11
+
+/* Returns version as major.minor.micro in 10.10.10 fixed form */
+static unsigned int
+get_cg_version (void)
+{
+ static unsigned int version;
+
+ FILE *fh;
+ char *ptr;
+
+ if (version != 0)
+ return version;
+
+ /* I tried CFBundleGetVersion, but it returns zero, so.. */
+
+ fh = fopen (CG_INFO_FILE, "r");
+ if (fh != NULL)
+ {
+ char buf[256];
+
+ while (fgets (buf, sizeof (buf), fh) != NULL)
+ {
+ unsigned char c;
+
+ if (!strstr (buf, "<key>CFBundleShortVersionString</key>")
+ || fgets (buf, sizeof (buf), fh) == NULL)
+ {
+ continue;
+ }
+
+ ptr = strstr (buf, "<string>");
+ if (ptr == NULL)
+ continue;
+
+ ptr += strlen ("<string>");
+
+ /* Now PTR points to "MAJOR.MINOR.MICRO". */
+
+ version = 0;
+
+ again:
+ switch ((c = *ptr++))
+ {
+ case '.':
+ version = version * 1024;
+ goto again;
+
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ version = ((version & ~0x3ff)
+ + (version & 0x3ff) * 10 + (c - '0'));
+ goto again;
+ }
+ break;
+ }
+
+ fclose (fh);
+ }
+
+ return version;
+}
+
+static Bool
+test_cg_version (unsigned int major, unsigned int minor, unsigned int micro)
+{
+ unsigned int cg_ver = get_cg_version ();
+
+ unsigned int cg_major = (cg_ver >> 20) & 0x3ff;
+ unsigned int cg_minor = (cg_ver >> 10) & 0x3ff;
+ unsigned int cg_micro = cg_ver & 0x3ff;
+
+ if (cg_major > major)
+ return TRUE;
+ else if (cg_major < major)
+ return FALSE;
+
+ /* cg_major == major */
+
+ if (cg_minor > minor)
+ return TRUE;
+ else if (cg_minor < minor)
+ return FALSE;
+
+ /* cg_minor == minor */
+
+ if (cg_micro < micro)
+ return FALSE;
+
+ return TRUE;
+}
+
+Bool
+DRIScreenInit(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv;
+ int i;
+
+ pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec));
+ if (!pDRIPriv) {
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ return FALSE;
+ }
+
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = (pointer) pDRIPriv;
+ pDRIPriv->directRenderingSupport = TRUE;
+ pDRIPriv->nrWindows = 0;
+
+ /* Need recent cg for window access update */
+ if (!test_cg_version (CG_REQUIRED_MAJOR,
+ CG_REQUIRED_MINOR,
+ CG_REQUIRED_MICRO))
+ {
+ ErrorF ("[DRI] disabled direct rendering; requires CoreGraphics %d.%d.%d\n",
+ CG_REQUIRED_MAJOR, CG_REQUIRED_MINOR, CG_REQUIRED_MICRO);
+
+ pDRIPriv->directRenderingSupport = FALSE;
+
+ /* Note we don't nuke the dri private, since we need it for
+ managing indirect surfaces. */
+ }
+
+ /* Initialize drawable tables */
+ for (i = 0; i < DRI_MAX_DRAWABLES; i++) {
+ pDRIPriv->DRIDrawables[i] = NULL;
+ }
+
+ return TRUE;
+}
+
+Bool
+DRIFinishScreenInit(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ /* Allocate zero sized private area for each window. Should a window
+ * become a DRI window, we'll hang a DRIWindowPrivateRec off of this
+ * private index.
+ */
+ if (!AllocateWindowPrivate(pScreen, DRIWindowPrivIndex, 0))
+ return FALSE;
+
+ /* Wrap DRI support */
+ pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
+ pScreen->ValidateTree = DRIValidateTree;
+
+ pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
+ pScreen->PostValidateTree = DRIPostValidateTree;
+
+ pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
+ pScreen->WindowExposures = DRIWindowExposures;
+
+ pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = DRICopyWindow;
+
+ pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
+ pScreen->ClipNotify = DRIClipNotify;
+
+ ErrorF("[DRI] screen %d installation complete\n", pScreen->myNum);
+
+ return TRUE;
+}
+
+void
+DRICloseScreen(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (pDRIPriv && pDRIPriv->directRenderingSupport) {
+ xfree(pDRIPriv);
+ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ }
+}
+
+Bool
+DRIExtensionInit(void)
+{
+ static unsigned long DRIGeneration = 0;
+
+ if (DRIGeneration != serverGeneration) {
+ if ((DRIScreenPrivIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+ DRIGeneration = serverGeneration;
+ }
+
+ /*
+ * Allocate a window private index with a zero sized private area for
+ * each window, then should a window become a DRI window, we'll hang
+ * a DRIWindowPrivateRec off of this private index. Do same for pixmaps.
+ */
+ if ((DRIWindowPrivIndex = AllocateWindowPrivateIndex()) < 0)
+ return FALSE;
+ if ((DRIPixmapPrivIndex = AllocatePixmapPrivateIndex()) < 0)
+ return FALSE;
+
+ DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete);
+
+ return TRUE;
+}
+
+void
+DRIReset(void)
+{
+ /*
+ * This stub routine is called when the X Server recycles, resources
+ * allocated by DRIExtensionInit need to be managed here.
+ *
+ * Currently this routine is a stub because all the interesting resources
+ * are managed via the screen init process.
+ */
+}
+
+Bool
+DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (pDRIPriv)
+ *isCapable = pDRIPriv->directRenderingSupport;
+ else
+ *isCapable = FALSE;
+
+ return TRUE;
+}
+
+Bool
+DRIAuthConnection(ScreenPtr pScreen, unsigned int magic)
+{
+#if 0
+ /* FIXME: something? */
+
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE;
+#endif
+ return TRUE;
+}
+
+static void
+DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw)
+{
+ xp_window_changes wc;
+ unsigned int flags = 0;
+
+ if (pDRIDrawablePriv->sid == 0)
+ return;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+ wc.depth = (pDraw->bitsPerPixel == 32 ? XP_DEPTH_ARGB8888
+ : pDraw->bitsPerPixel == 16 ? XP_DEPTH_RGB555 : XP_DEPTH_NIL);
+ if (wc.depth != XP_DEPTH_NIL)
+ flags |= XP_DEPTH;
+#endif
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ WindowPtr pWin = (WindowPtr) pDraw;
+ WindowPtr pTopWin = TopLevelParent(pWin);
+
+ wc.x = pWin->drawable.x - (pTopWin->drawable.x - pTopWin->borderWidth);
+ wc.y = pWin->drawable.y - (pTopWin->drawable.y - pTopWin->borderWidth);
+ wc.width = pWin->drawable.width + 2 * pWin->borderWidth;
+ wc.height = pWin->drawable.height + 2 * pWin->borderWidth;
+ wc.bit_gravity = XP_GRAVITY_NONE;
+
+ wc.shape_nrects = REGION_NUM_RECTS(&pWin->clipList);
+ wc.shape_rects = REGION_RECTS(&pWin->clipList);
+ wc.shape_tx = - (pTopWin->drawable.x - pTopWin->borderWidth);
+ wc.shape_ty = - (pTopWin->drawable.y - pTopWin->borderWidth);
+
+ flags |= XP_BOUNDS | XP_SHAPE;
+
+ } else if (pDraw->type == DRAWABLE_PIXMAP) {
+ wc.x = 0;
+ wc.y = 0;
+ wc.width = pDraw->width;
+ wc.height = pDraw->height;
+ wc.bit_gravity = XP_GRAVITY_NONE;
+ flags |= XP_BOUNDS;
+ }
+
+ xp_configure_surface(pDRIDrawablePriv->sid, flags, &wc);
+}
+
+Bool
+DRICreateSurface(ScreenPtr pScreen, Drawable id,
+ DrawablePtr pDrawable, xp_client_id client_id,
+ xp_surface_id *surface_id, unsigned int ret_key[2],
+ void (*notify) (void *arg, void *data), void *notify_data)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+ xp_window_id wid = 0;
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ WindowPtr pWin = (WindowPtr)pDrawable;
+
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+ if (pDRIDrawablePriv == NULL) {
+ xp_error err;
+ xp_window_changes wc;
+
+ /* allocate a DRI Window Private record */
+ if (!(pDRIDrawablePriv = xalloc(sizeof(DRIDrawablePrivRec)))) {
+ return FALSE;
+ }
+
+ pDRIDrawablePriv->pDraw = pDrawable;
+ pDRIDrawablePriv->pScreen = pScreen;
+ pDRIDrawablePriv->refCount = 0;
+ pDRIDrawablePriv->drawableIndex = -1;
+ pDRIDrawablePriv->notifiers = NULL;
+
+ /* find the physical window */
+ wid = (xp_window_id) RootlessFrameForWindow(pWin, TRUE);
+ if (wid == 0) {
+ xfree(pDRIDrawablePriv);
+ return FALSE;
+ }
+
+ /* allocate the physical surface */
+ err = xp_create_surface(wid, &pDRIDrawablePriv->sid);
+ if (err != Success) {
+ xfree(pDRIDrawablePriv);
+ return FALSE;
+ }
+
+ /* Make it visible */
+ wc.stack_mode = XP_MAPPED_ABOVE;
+ wc.sibling = 0;
+ err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc);
+ if (err != Success)
+ {
+ xp_destroy_surface(pDRIDrawablePriv->sid);
+ xfree(pDRIDrawablePriv);
+ return FALSE;
+ }
+
+ /* save private off of preallocated index */
+ pWin->devPrivates[DRIWindowPrivIndex].ptr = (pointer)pDRIDrawablePriv;
+ }
+ }
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+ else if (pDrawable->type == DRAWABLE_PIXMAP) {
+ PixmapPtr pPix = (PixmapPtr)pDrawable;
+
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
+ if (pDRIDrawablePriv == NULL) {
+ xp_error err;
+
+ /* allocate a DRI Window Private record */
+ if (!(pDRIDrawablePriv = xcalloc(1, sizeof(DRIDrawablePrivRec)))) {
+ return FALSE;
+ }
+
+ pDRIDrawablePriv->pDraw = pDrawable;
+ pDRIDrawablePriv->pScreen = pScreen;
+ pDRIDrawablePriv->refCount = 0;
+ pDRIDrawablePriv->drawableIndex = -1;
+ pDRIDrawablePriv->notifiers = NULL;
+
+ /* Passing a null window id to Xplugin in 10.3+ asks for
+ an accelerated offscreen surface. */
+
+ err = xp_create_surface(0, &pDRIDrawablePriv->sid);
+ if (err != Success) {
+ xfree(pDRIDrawablePriv);
+ return FALSE;
+ }
+
+ /* save private off of preallocated index */
+ pPix->devPrivates[DRIPixmapPrivIndex].ptr = (pointer)pDRIDrawablePriv;
+ }
+ }
+#endif
+
+ else { /* for GLX 1.3, a PBuffer */
+ /* NOT_DONE */
+ return FALSE;
+ }
+
+ /* Finish initialization of new surfaces */
+ if (pDRIDrawablePriv->refCount == 0) {
+ unsigned int key[2] = {0};
+ xp_error err;
+
+ /* try to give the client access to the surface */
+ if (client_id != 0 && wid != 0)
+ {
+ err = xp_export_surface(wid, pDRIDrawablePriv->sid,
+ client_id, key);
+ if (err != Success) {
+ xp_destroy_surface(pDRIDrawablePriv->sid);
+ xfree(pDRIDrawablePriv);
+ return FALSE;
+ }
+ }
+
+ pDRIDrawablePriv->key[0] = key[0];
+ pDRIDrawablePriv->key[1] = key[1];
+
+ ++pDRIPriv->nrWindows;
+
+ /* and stash it by surface id */
+ if (surface_hash == NULL)
+ surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
+ x_hash_table_insert(surface_hash,
+ (void *) pDRIDrawablePriv->sid, pDRIDrawablePriv);
+
+ /* track this in case this window is destroyed */
+ AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable);
+
+ /* Initialize shape */
+ DRIUpdateSurface(pDRIDrawablePriv, pDrawable);
+ }
+
+ pDRIDrawablePriv->refCount++;
+
+ *surface_id = pDRIDrawablePriv->sid;
+
+ if (ret_key != NULL) {
+ ret_key[0] = pDRIDrawablePriv->key[0];
+ ret_key[1] = pDRIDrawablePriv->key[1];
+ }
+
+ if (notify != NULL) {
+ pDRIDrawablePriv->notifiers = x_hook_add(pDRIDrawablePriv->notifiers,
+ notify, notify_data);
+ }
+
+ return TRUE;
+}
+
+Bool
+DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
+ void (*notify) (void *, void *), void *notify_data)
+{
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW((WindowPtr)pDrawable);
+ } else if (pDrawable->type == DRAWABLE_PIXMAP) {
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP((PixmapPtr)pDrawable);
+ } else {
+ return FALSE;
+ }
+
+ if (pDRIDrawablePriv != NULL) {
+ if (notify != NULL) {
+ pDRIDrawablePriv->notifiers = x_hook_remove(pDRIDrawablePriv->notifiers,
+ notify, notify_data);
+ }
+ if (--pDRIDrawablePriv->refCount <= 0) {
+ /* This calls back to DRIDrawablePrivDelete
+ which frees the private area */
+ FreeResourceByType(id, DRIDrawablePrivResType, FALSE);
+ }
+ }
+
+ return TRUE;
+}
+
+Bool
+DRIDrawablePrivDelete(pointer pResource, XID id)
+{
+ DrawablePtr pDrawable = (DrawablePtr)pResource;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pDrawable->pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv = NULL;
+ WindowPtr pWin = NULL;
+ PixmapPtr pPix = NULL;
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ pWin = (WindowPtr)pDrawable;
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+ } else if (pDrawable->type == DRAWABLE_PIXMAP) {
+ pPix = (PixmapPtr)pDrawable;
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
+ }
+
+ if (pDRIDrawablePriv == NULL)
+ return FALSE;
+
+ if (pDRIDrawablePriv->drawableIndex != -1) {
+ /* release drawable table entry */
+ pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL;
+ }
+
+ if (pDRIDrawablePriv->sid != 0) {
+ xp_destroy_surface(pDRIDrawablePriv->sid);
+ x_hash_table_remove(surface_hash, (void *) pDRIDrawablePriv->sid);
+ }
+
+ if (pDRIDrawablePriv->notifiers != NULL)
+ x_hook_free(pDRIDrawablePriv->notifiers);
+
+ xfree(pDRIDrawablePriv);
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL;
+ } else if (pDrawable->type == DRAWABLE_PIXMAP) {
+ pPix->devPrivates[DRIPixmapPrivIndex].ptr = NULL;
+ }
+
+ --pDRIPriv->nrWindows;
+
+ return TRUE;
+}
+
+void
+DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+
+ if (pDRIDrawablePriv) {
+ /* FIXME: something? */
+ }
+
+ pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
+
+ (*pScreen->WindowExposures)(pWin, prgn, bsreg);
+
+ pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
+ pScreen->WindowExposures = DRIWindowExposures;
+}
+
+void
+DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+
+ if (pDRIPriv->nrWindows > 0) {
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+ if (pDRIDrawablePriv != NULL) {
+ DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable);
+ }
+ }
+
+ /* unwrap */
+ pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
+
+ /* call lower layers */
+ (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
+
+ /* rewrap */
+ pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = DRICopyWindow;
+}
+
+int
+DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
+{
+ ScreenPtr pScreen = pParent->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ int returnValue;
+
+ /* unwrap */
+ pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
+
+ /* call lower layers */
+ returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind);
+
+ /* rewrap */
+ pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
+ pScreen->ValidateTree = DRIValidateTree;
+
+ return returnValue;
+}
+
+void
+DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
+{
+ ScreenPtr pScreen;
+ DRIScreenPrivPtr pDRIPriv;
+
+ if (pParent) {
+ pScreen = pParent->drawable.pScreen;
+ } else {
+ pScreen = pChild->drawable.pScreen;
+ }
+ pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (pDRIPriv->wrap.PostValidateTree) {
+ /* unwrap */
+ pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
+
+ /* call lower layers */
+ (*pScreen->PostValidateTree)(pParent, pChild, kind);
+
+ /* rewrap */
+ pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
+ pScreen->PostValidateTree = DRIPostValidateTree;
+ }
+}
+
+void
+DRIClipNotify(WindowPtr pWin, int dx, int dy)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+
+ if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
+ DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable);
+ }
+
+ if (pDRIPriv->wrap.ClipNotify) {
+ pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
+
+ (*pScreen->ClipNotify)(pWin, dx, dy);
+
+ pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
+ pScreen->ClipNotify = DRIClipNotify;
+ }
+}
+
+/* This lets us get at the unwrapped functions so that they can correctly
+ * call the lower level functions, and choose whether they will be
+ * called at every level of recursion (eg in validatetree).
+ */
+DRIWrappedFuncsRec *
+DRIGetWrappedFuncs(ScreenPtr pScreen)
+{
+ return &(DRI_SCREEN_PRIV(pScreen)->wrap);
+}
+
+void
+DRIQueryVersion(int *majorVersion,
+ int *minorVersion,
+ int *patchVersion)
+{
+ *majorVersion = APPLE_DRI_MAJOR_VERSION;
+ *minorVersion = APPLE_DRI_MINOR_VERSION;
+ *patchVersion = APPLE_DRI_PATCH_VERSION;
+}
+
+void
+DRISurfaceNotify(xp_surface_id id, int kind)
+{
+ DRIDrawablePrivPtr pDRIDrawablePriv = NULL;
+ DRISurfaceNotifyArg arg;
+
+ arg.id = id;
+ arg.kind = kind;
+
+ if (surface_hash != NULL)
+ {
+ pDRIDrawablePriv = x_hash_table_lookup(surface_hash,
+ (void *) id, NULL);
+ }
+
+ if (pDRIDrawablePriv == NULL)
+ return;
+
+ if (kind == AppleDRISurfaceNotifyDestroyed)
+ {
+ pDRIDrawablePriv->sid = 0;
+ x_hash_table_remove(surface_hash, (void *) id);
+ }
+
+ x_hook_run(pDRIDrawablePriv->notifiers, &arg);
+
+ if (kind == AppleDRISurfaceNotifyDestroyed)
+ {
+ /* Kill off the handle. */
+
+ FreeResourceByType(pDRIDrawablePriv->pDraw->id,
+ DRIDrawablePrivResType, FALSE);
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dri.h b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dri.h
new file mode 100644
index 000000000..f826167f6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dri.h
@@ -0,0 +1,129 @@
+/* $XFree86: xc/programs/Xserver/GL/dri/dri.h,v 1.18 2001/03/21 16:21:40 dawes Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright (c) 2002 Apple Computer, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Jens Owen <jens@precisioninsight.com>
+ *
+ */
+
+/* Prototypes for AppleDRI functions */
+
+#ifndef _DRI_H_
+#define _DRI_H_
+
+#include <X11/Xdefs.h>
+#include "scrnintstr.h"
+#define _APPLEDRI_SERVER_
+#include "appledri.h"
+#include "Xplugin.h"
+
+typedef void (*ClipNotifyPtr)( WindowPtr, int, int );
+
+
+/*
+ * These functions can be wrapped by the DRI. Each of these have
+ * generic default funcs (initialized in DRICreateInfoRec) and can be
+ * overridden by the driver in its [driver]DRIScreenInit function.
+ */
+typedef struct {
+ WindowExposuresProcPtr WindowExposures;
+ CopyWindowProcPtr CopyWindow;
+ ValidateTreeProcPtr ValidateTree;
+ PostValidateTreeProcPtr PostValidateTree;
+ ClipNotifyProcPtr ClipNotify;
+} DRIWrappedFuncsRec, *DRIWrappedFuncsPtr;
+
+typedef struct {
+ xp_surface_id id;
+ int kind;
+} DRISurfaceNotifyArg;
+
+extern Bool DRIScreenInit(ScreenPtr pScreen);
+
+extern Bool DRIFinishScreenInit(ScreenPtr pScreen);
+
+extern void DRICloseScreen(ScreenPtr pScreen);
+
+extern Bool DRIExtensionInit(void);
+
+extern void DRIReset(void);
+
+extern Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen,
+ Bool *isCapable);
+
+extern Bool DRIAuthConnection(ScreenPtr pScreen, unsigned int magic);
+
+extern Bool DRICreateSurface(ScreenPtr pScreen,
+ Drawable id,
+ DrawablePtr pDrawable,
+ xp_client_id client_id,
+ xp_surface_id *surface_id,
+ unsigned int key[2],
+ void (*notify) (void *arg, void *data),
+ void *notify_data);
+
+extern Bool DRIDestroySurface(ScreenPtr pScreen,
+ Drawable id,
+ DrawablePtr pDrawable,
+ void (*notify) (void *arg, void *data),
+ void *notify_data);
+
+extern Bool DRIDrawablePrivDelete(pointer pResource,
+ XID id);
+
+extern DRIWrappedFuncsRec *DRIGetWrappedFuncs(ScreenPtr pScreen);
+
+extern void DRICopyWindow(WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc);
+
+extern int DRIValidateTree(WindowPtr pParent,
+ WindowPtr pChild,
+ VTKind kind);
+
+extern void DRIPostValidateTree(WindowPtr pParent,
+ WindowPtr pChild,
+ VTKind kind);
+
+extern void DRIClipNotify(WindowPtr pWin,
+ int dx,
+ int dy);
+
+extern void DRIWindowExposures(WindowPtr pWin,
+ RegionPtr prgn,
+ RegionPtr bsreg);
+
+extern void DRISurfaceNotify (xp_surface_id id, int kind);
+
+extern void DRIQueryVersion(int *majorVersion,
+ int *minorVersion,
+ int *patchVersion);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dristruct.h b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dristruct.h
new file mode 100644
index 000000000..0df8f1890
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dristruct.h
@@ -0,0 +1,82 @@
+/* $XFree86: xc/programs/Xserver/GL/dri/dristruct.h,v 1.10 2001/03/21 16:21:40 dawes Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright (c) 2002 Apple Computer, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Jens Owen <jens@precisioninsight.com>
+ *
+ */
+
+#ifndef DRI_STRUCT_H
+#define DRI_STRUCT_H
+
+#include "dri.h"
+#include "x-list.h"
+
+#define DRI_MAX_DRAWABLES 256
+
+#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) \
+ ((DRIWindowPrivIndex < 0) ? \
+ NULL : \
+ ((DRIDrawablePrivPtr)((pWin)->devPrivates[DRIWindowPrivIndex].ptr)))
+
+#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) \
+ ((DRIPixmapPrivIndex < 0) ? \
+ NULL : \
+ ((DRIDrawablePrivPtr)((pPix)->devPrivates[DRIPixmapPrivIndex].ptr)))
+
+typedef struct _DRIDrawablePrivRec
+{
+ xp_surface_id sid;
+ int drawableIndex;
+ DrawablePtr pDraw;
+ ScreenPtr pScreen;
+ int refCount;
+ unsigned int key[2];
+ x_list *notifiers; /* list of (FUN . DATA) */
+} DRIDrawablePrivRec, *DRIDrawablePrivPtr;
+
+#define DRI_SCREEN_PRIV(pScreen) \
+ ((DRIScreenPrivIndex < 0) ? \
+ NULL : \
+ ((DRIScreenPrivPtr)((pScreen)->devPrivates[DRIScreenPrivIndex].ptr)))
+
+#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
+ (screenInfo.screens[screenIndex]->devPrivates[DRIScreenPrivIndex].ptr))
+
+
+typedef struct _DRIScreenPrivRec
+{
+ Bool directRenderingSupport;
+ int nrWindows;
+ DRIWrappedFuncsRec wrap;
+ DrawablePtr DRIDrawables[DRI_MAX_DRAWABLES];
+} DRIScreenPrivRec, *DRIScreenPrivPtr;
+
+#endif /* DRI_STRUCT_H */
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hash.c b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hash.c
new file mode 100644
index 000000000..a1c6655f7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hash.c
@@ -0,0 +1,341 @@
+/* x-hash.c - basic hash tables
+ $Id: x-hash.c,v 1.5 2005/07/01 22:43:08 daniels Exp $
+
+ Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name(s) of the above
+ copyright holders shall not be used in advertising or otherwise to
+ promote the sale, use or other dealings in this Software without
+ prior written authorization. */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/x-hash.c,v 1.1 2003/04/30 23:15:42 torrey Exp $ */
+
+#include "x-hash.h"
+#include "x-list.h"
+#include <stdlib.h>
+#include <assert.h>
+
+struct x_hash_table_struct {
+ unsigned int bucket_index;
+ unsigned int total_keys;
+ x_list **buckets;
+
+ x_hash_fun *hash_key;
+ x_compare_fun *compare_keys;
+ x_destroy_fun *destroy_key;
+ x_destroy_fun *destroy_value;
+};
+
+#define ITEM_NEW(k, v) X_PFX (list_prepend) ((x_list *) (k), v)
+#define ITEM_FREE(i) X_PFX (list_free_1) (i)
+#define ITEM_KEY(i) ((void *) (i)->next)
+#define ITEM_VALUE(i) ((i)->data)
+
+#define SPLIT_THRESHOLD_FACTOR 2
+
+/* http://planetmath.org/?op=getobj&from=objects&name=GoodHashTablePrimes */
+static const unsigned int bucket_sizes[] = {
+ 29, 53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593, 49157,
+ 98317, 196613, 393241, 786433, 1572869, 3145739, 6291469, 12582917,
+ 25165843, 50331653, 100663319, 201326611, 402653189, 805306457,
+ 1610612741
+};
+
+#define N_BUCKET_SIZES (sizeof (bucket_sizes) / sizeof (bucket_sizes[0]))
+
+static inline unsigned int
+hash_table_total_buckets (x_hash_table *h)
+{
+ return bucket_sizes[h->bucket_index];
+}
+
+static inline void
+hash_table_destroy_item (x_hash_table *h, void *k, void *v)
+{
+ if (h->destroy_key != 0)
+ (*h->destroy_key) (k);
+
+ if (h->destroy_value != 0)
+ (*h->destroy_value) (v);
+}
+
+static inline unsigned int
+hash_table_hash_key (x_hash_table *h, void *k)
+{
+ if (h->hash_key != 0)
+ return (*h->hash_key) (k);
+ else
+ return (unsigned int) k;
+}
+
+static inline int
+hash_table_compare_keys (x_hash_table *h, void *k1, void *k2)
+{
+ if (h->compare_keys == 0)
+ return k1 == k2;
+ else
+ return (*h->compare_keys) (k1, k2) == 0;
+}
+
+static void
+hash_table_split (x_hash_table *h)
+{
+ x_list **new, **old;
+ x_list *node, *item, *next;
+ int new_size, old_size;
+ unsigned int b;
+ int i;
+
+ if (h->bucket_index == N_BUCKET_SIZES - 1)
+ return;
+
+ old_size = hash_table_total_buckets (h);
+ old = h->buckets;
+
+ h->bucket_index++;
+
+ new_size = hash_table_total_buckets (h);
+ new = calloc (new_size, sizeof (x_list *));
+
+ if (new == 0)
+ {
+ h->bucket_index--;
+ return;
+ }
+
+ for (i = 0; i < old_size; i++)
+ {
+ for (node = old[i]; node != 0; node = next)
+ {
+ next = node->next;
+ item = node->data;
+
+ b = hash_table_hash_key (h, ITEM_KEY (item)) % new_size;
+
+ node->next = new[b];
+ new[b] = node;
+ }
+ }
+
+ h->buckets = new;
+ free (old);
+}
+
+X_EXTERN x_hash_table *
+X_PFX (hash_table_new) (x_hash_fun *hash,
+ x_compare_fun *compare,
+ x_destroy_fun *key_destroy,
+ x_destroy_fun *value_destroy)
+{
+ x_hash_table *h;
+
+ h = calloc (1, sizeof (x_hash_table));
+ if (h == 0)
+ return 0;
+
+ h->bucket_index = 0;
+ h->buckets = calloc (hash_table_total_buckets (h), sizeof (x_list *));
+
+ if (h->buckets == 0)
+ {
+ free (h);
+ return 0;
+ }
+
+ h->hash_key = hash;
+ h->compare_keys = compare;
+ h->destroy_key = key_destroy;
+ h->destroy_value = value_destroy;
+
+ return h;
+}
+
+X_EXTERN void
+X_PFX (hash_table_free) (x_hash_table *h)
+{
+ int n, i;
+ x_list *node, *item;
+
+ assert (h != NULL);
+
+ n = hash_table_total_buckets (h);
+
+ for (i = 0; i < n; i++)
+ {
+ for (node = h->buckets[i]; node != 0; node = node->next)
+ {
+ item = node->data;
+ hash_table_destroy_item (h, ITEM_KEY (item), ITEM_VALUE (item));
+ ITEM_FREE (item);
+ }
+ X_PFX (list_free) (h->buckets[i]);
+ }
+
+ free (h->buckets);
+ free (h);
+}
+
+X_EXTERN unsigned int
+X_PFX (hash_table_size) (x_hash_table *h)
+{
+ assert (h != NULL);
+
+ return h->total_keys;
+}
+
+static void
+hash_table_modify (x_hash_table *h, void *k, void *v, int replace)
+{
+ unsigned int hash_value;
+ x_list *node, *item;
+
+ assert (h != NULL);
+
+ hash_value = hash_table_hash_key (h, k);
+
+ for (node = h->buckets[hash_value % hash_table_total_buckets (h)];
+ node != 0; node = node->next)
+ {
+ item = node->data;
+
+ if (hash_table_compare_keys (h, ITEM_KEY (item), k))
+ {
+ if (replace)
+ {
+ hash_table_destroy_item (h, ITEM_KEY (item),
+ ITEM_VALUE (item));
+ item->next = k;
+ ITEM_VALUE (item) = v;
+ }
+ else
+ {
+ hash_table_destroy_item (h, k, ITEM_VALUE (item));
+ ITEM_VALUE (item) = v;
+ }
+ return;
+ }
+ }
+
+ /* Key isn't already in the table. Insert it. */
+
+ if (h->total_keys + 1
+ > hash_table_total_buckets (h) * SPLIT_THRESHOLD_FACTOR)
+ {
+ hash_table_split (h);
+ }
+
+ hash_value = hash_value % hash_table_total_buckets (h);
+ h->buckets[hash_value] = X_PFX (list_prepend) (h->buckets[hash_value],
+ ITEM_NEW (k, v));
+ h->total_keys++;
+}
+
+X_EXTERN void
+X_PFX (hash_table_insert) (x_hash_table *h, void *k, void *v)
+{
+ hash_table_modify (h, k, v, 0);
+}
+
+X_EXTERN void
+X_PFX (hash_table_replace) (x_hash_table *h, void *k, void *v)
+{
+ hash_table_modify (h, k, v, 1);
+}
+
+X_EXTERN void
+X_PFX (hash_table_remove) (x_hash_table *h, void *k)
+{
+ unsigned int hash_value;
+ x_list **ptr, *item;
+
+ assert (h != NULL);
+
+ hash_value = hash_table_hash_key (h, k);
+
+ for (ptr = &h->buckets[hash_value % hash_table_total_buckets (h)];
+ *ptr != 0; ptr = &((*ptr)->next))
+ {
+ item = (*ptr)->data;
+
+ if (hash_table_compare_keys (h, ITEM_KEY (item), k))
+ {
+ hash_table_destroy_item (h, ITEM_KEY (item), ITEM_VALUE (item));
+ ITEM_FREE (item);
+ item = *ptr;
+ *ptr = item->next;
+ X_PFX (list_free_1) (item);
+ h->total_keys--;
+ return;
+ }
+ }
+}
+
+X_EXTERN void *
+X_PFX (hash_table_lookup) (x_hash_table *h, void *k, void **k_ret)
+{
+ unsigned int hash_value;
+ x_list *node, *item;
+
+ assert (h != NULL);
+
+ hash_value = hash_table_hash_key (h, k);
+
+ for (node = h->buckets[hash_value % hash_table_total_buckets (h)];
+ node != 0; node = node->next)
+ {
+ item = node->data;
+
+ if (hash_table_compare_keys (h, ITEM_KEY (item), k))
+ {
+ if (k_ret != 0)
+ *k_ret = ITEM_KEY (item);
+
+ return ITEM_VALUE (item);
+ }
+ }
+
+ if (k_ret != 0)
+ *k_ret = 0;
+
+ return 0;
+}
+
+X_EXTERN void
+X_PFX (hash_table_foreach) (x_hash_table *h,
+ x_hash_foreach_fun *fun, void *data)
+{
+ int i, n;
+ x_list *node, *item;
+
+ assert (h != NULL);
+
+ n = hash_table_total_buckets (h);
+
+ for (i = 0; i < n; i++)
+ {
+ for (node = h->buckets[i]; node != 0; node = node->next)
+ {
+ item = node->data;
+ (*fun) (ITEM_KEY (item), ITEM_VALUE (item), data);
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hash.h b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hash.h
new file mode 100644
index 000000000..5ee069cda
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hash.h
@@ -0,0 +1,62 @@
+/* x-hash.h -- basic hash table class
+ $Id: x-hash.h,v 1.3 2005/07/01 22:43:08 daniels Exp $
+
+ Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name(s) of the above
+ copyright holders shall not be used in advertising or otherwise to
+ promote the sale, use or other dealings in this Software without
+ prior written authorization. */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/x-hash.h,v 1.1 2003/04/30 23:15:42 torrey Exp $ */
+
+#ifndef X_HASH_H
+#define X_HASH_H 1
+
+typedef struct x_hash_table_struct x_hash_table;
+
+typedef int (x_compare_fun) (const void *a, const void *b);
+typedef unsigned int (x_hash_fun) (const void *k);
+typedef void (x_destroy_fun) (void *x);
+typedef void (x_hash_foreach_fun) (void *k, void *v, void *data);
+
+/* for X_PFX and X_EXTERN */
+#include "x-list.h"
+
+X_EXTERN x_hash_table *X_PFX (hash_table_new) (x_hash_fun *hash,
+ x_compare_fun *compare,
+ x_destroy_fun *key_destroy,
+ x_destroy_fun *value_destroy);
+X_EXTERN void X_PFX (hash_table_free) (x_hash_table *h);
+
+X_EXTERN unsigned int X_PFX (hash_table_size) (x_hash_table *h);
+
+X_EXTERN void X_PFX (hash_table_insert) (x_hash_table *h, void *k, void *v);
+X_EXTERN void X_PFX (hash_table_replace) (x_hash_table *h, void *k, void *v);
+X_EXTERN void X_PFX (hash_table_remove) (x_hash_table *h, void *k);
+X_EXTERN void *X_PFX (hash_table_lookup) (x_hash_table *h,
+ void *k, void **k_ret);
+X_EXTERN void X_PFX (hash_table_foreach) (x_hash_table *h,
+ x_hash_foreach_fun *fun,
+ void *data);
+
+#endif /* X_HASH_H */
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hook.c b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hook.c
new file mode 100644
index 000000000..b4e6673eb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hook.c
@@ -0,0 +1,106 @@
+/* x-hook.c
+ $Id: x-hook.c,v 1.3 2005/07/01 22:43:08 daniels Exp $
+
+ Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name(s) of the above
+ copyright holders shall not be used in advertising or otherwise to
+ promote the sale, use or other dealings in this Software without
+ prior written authorization. */
+/* $XFree86: $ */
+
+#include "x-hook.h"
+#include <stdlib.h>
+#include <assert.h>
+
+#define CELL_NEW(f,d) X_PFX (list_prepend) ((x_list *) (f), (d))
+#define CELL_FREE(c) X_PFX (list_free_1) (c)
+#define CELL_FUN(c) ((x_hook_function *) ((c)->next))
+#define CELL_DATA(c) ((c)->data)
+
+X_EXTERN x_list *
+X_PFX (hook_add) (x_list *lst, x_hook_function *fun, void *data)
+{
+ return X_PFX (list_prepend) (lst, CELL_NEW (fun, data));
+}
+
+X_EXTERN x_list *
+X_PFX (hook_remove) (x_list *lst, x_hook_function *fun, void *data)
+{
+ x_list *node, *cell;
+ x_list *to_delete = NULL;
+
+ for (node = lst; node != NULL; node = node->next)
+ {
+ cell = node->data;
+ if (CELL_FUN (cell) == fun && CELL_DATA (cell) == data)
+ to_delete = X_PFX (list_prepend) (to_delete, cell);
+ }
+
+ for (node = to_delete; node != NULL; node = node->next)
+ {
+ cell = node->data;
+ lst = X_PFX (list_remove) (lst, cell);
+ CELL_FREE (cell);
+ }
+
+ X_PFX (list_free) (to_delete);
+}
+
+X_EXTERN void
+X_PFX (hook_run) (x_list *lst, void *arg)
+{
+ x_list *node, *cell;
+ x_hook_function **fun;
+ void **data;
+ int length, i;
+
+ length = X_PFX (list_length) (lst);
+ fun = alloca (sizeof (x_hook_function *) * length);
+ data = alloca (sizeof (void *) * length);
+
+ for (i = 0, node = lst; node != NULL; node = node->next, i++)
+ {
+ cell = node->data;
+ fun[i] = CELL_FUN (cell);
+ data[i] = CELL_DATA (cell);
+ }
+
+ for (i = 0; i < length; i++)
+ {
+ (*fun[i]) (arg, data[i]);
+ }
+}
+
+X_EXTERN void
+X_PFX (hook_free) (x_list *lst)
+{
+ x_list *node;
+
+ for (node = lst; node != NULL; node = node->next)
+ {
+ CELL_FREE (node->data);
+ }
+
+ X_PFX (list_free) (lst);
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hook.h b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hook.h
new file mode 100644
index 000000000..08b29a94e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hook.h
@@ -0,0 +1,44 @@
+/* x-hook.h -- lists of function,data pairs to call.
+ $Id: x-hook.h,v 1.3 2005/07/01 22:43:08 daniels Exp $
+
+ Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name(s) of the above
+ copyright holders shall not be used in advertising or otherwise to
+ promote the sale, use or other dealings in this Software without
+ prior written authorization. */
+/* $XFree86: $ */
+
+#ifndef X_HOOK_H
+#define X_HOOK_H 1
+
+#include "x-list.h"
+
+typedef void x_hook_function (void *arg, void *data);
+
+X_EXTERN x_list *X_PFX (hook_add) (x_list *lst, x_hook_function *fun, void *data);
+X_EXTERN x_list *X_PFX (hook_remove) (x_list *lst, x_hook_function *fun, void *data);
+X_EXTERN void X_PFX (hook_run) (x_list *lst, void *arg);
+X_EXTERN void X_PFX (hook_free) (x_list *lst);
+
+#endif /* X_HOOK_H */
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-list.c b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-list.c
new file mode 100644
index 000000000..fdadee212
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-list.c
@@ -0,0 +1,335 @@
+/* x-list.c
+ $Id: x-list.c,v 1.4 2005/07/01 22:43:08 daniels Exp $
+
+ Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name(s) of the above
+ copyright holders shall not be used in advertising or otherwise to
+ promote the sale, use or other dealings in this Software without
+ prior written authorization. */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/x-list.c,v 1.1 2003/04/30 23:15:42 torrey Exp $ */
+
+#include "x-list.h"
+#include <stdlib.h>
+#include <assert.h>
+#include <pthread.h>
+
+/* Allocate in ~4k blocks */
+#define NODES_PER_BLOCK 508
+
+typedef struct x_list_block_struct x_list_block;
+
+struct x_list_block_struct {
+ x_list l[NODES_PER_BLOCK];
+};
+
+static x_list *freelist;
+
+static pthread_mutex_t freelist_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static inline void
+list_free_1 (x_list *node)
+{
+ node->next = freelist;
+ freelist = node;
+}
+
+X_EXTERN void
+X_PFX (list_free_1) (x_list *node)
+{
+ assert (node != NULL);
+
+ pthread_mutex_lock (&freelist_lock);
+
+ list_free_1 (node);
+
+ pthread_mutex_unlock (&freelist_lock);
+}
+
+X_EXTERN void
+X_PFX (list_free) (x_list *lst)
+{
+ x_list *next;
+
+ pthread_mutex_lock (&freelist_lock);
+
+ for (; lst != NULL; lst = next)
+ {
+ next = lst->next;
+ list_free_1 (lst);
+ }
+
+ pthread_mutex_unlock (&freelist_lock);
+}
+
+X_EXTERN x_list *
+X_PFX (list_prepend) (x_list *lst, void *data)
+{
+ x_list *node;
+
+ pthread_mutex_lock (&freelist_lock);
+
+ if (freelist == NULL)
+ {
+ x_list_block *b;
+ int i;
+
+ b = malloc (sizeof (x_list_block));
+
+ for (i = 0; i < NODES_PER_BLOCK - 1; i++)
+ b->l[i].next = &(b->l[i+1]);
+ b->l[i].next = NULL;
+
+ freelist = b->l;
+ }
+
+ node = freelist;
+ freelist = node->next;
+
+ pthread_mutex_unlock (&freelist_lock);
+
+ node->next = lst;
+ node->data = data;
+
+ return node;
+}
+
+X_EXTERN x_list *
+X_PFX (list_append) (x_list *lst, void *data)
+{
+ x_list *head = lst;
+
+ if (lst == NULL)
+ return X_PFX (list_prepend) (NULL, data);
+
+ while (lst->next != NULL)
+ lst = lst->next;
+
+ lst->next = X_PFX (list_prepend) (NULL, data);
+
+ return head;
+}
+
+X_EXTERN x_list *
+X_PFX (list_reverse) (x_list *lst)
+{
+ x_list *head = NULL, *next;
+
+ while (lst != NULL)
+ {
+ next = lst->next;
+ lst->next = head;
+ head = lst;
+ lst = next;
+ }
+
+ return head;
+}
+
+X_EXTERN x_list *
+X_PFX (list_find) (x_list *lst, void *data)
+{
+ for (; lst != NULL; lst = lst->next)
+ {
+ if (lst->data == data)
+ return lst;
+ }
+
+ return NULL;
+}
+
+X_EXTERN x_list *
+X_PFX (list_nth) (x_list *lst, int n)
+{
+ while (n-- > 0 && lst != NULL)
+ lst = lst->next;
+
+ return lst;
+}
+
+X_EXTERN x_list *
+X_PFX (list_pop) (x_list *lst, void **data_ret)
+{
+ void *data = NULL;
+
+ if (lst != NULL)
+ {
+ x_list *tem = lst;
+ data = lst->data;
+ lst = lst->next;
+ X_PFX (list_free_1) (tem);
+ }
+
+ if (data_ret != NULL)
+ *data_ret = data;
+
+ return lst;
+}
+
+X_EXTERN x_list *
+X_PFX (list_filter) (x_list *lst,
+ int (*pred) (void *item, void *data), void *data)
+{
+ x_list *ret = NULL, *node;
+
+ for (node = lst; node != NULL; node = node->next)
+ {
+ if ((*pred) (node->data, data))
+ ret = X_PFX (list_prepend) (ret, node->data);
+ }
+
+ return X_PFX (list_reverse) (ret);
+}
+
+X_EXTERN x_list *
+X_PFX (list_map) (x_list *lst,
+ void *(*fun) (void *item, void *data), void *data)
+{
+ x_list *ret = NULL, *node;
+
+ for (node = lst; node != NULL; node = node->next)
+ {
+ X_PFX (list_prepend) (ret, fun (node->data, data));
+ }
+
+ return X_PFX (list_reverse) (ret);
+}
+
+X_EXTERN x_list *
+X_PFX (list_copy) (x_list *lst)
+{
+ x_list *copy = NULL;
+
+ for (; lst != NULL; lst = lst->next)
+ {
+ copy = X_PFX (list_prepend) (copy, lst->data);
+ }
+
+ return X_PFX (list_reverse) (copy);
+}
+
+X_EXTERN x_list *
+X_PFX (list_remove) (x_list *lst, void *data)
+{
+ x_list **ptr, *node;
+
+ for (ptr = &lst; *ptr != NULL;)
+ {
+ node = *ptr;
+
+ if (node->data == data)
+ {
+ *ptr = node->next;
+ X_PFX (list_free_1) (node);
+ }
+ else
+ ptr = &((*ptr)->next);
+ }
+
+ return lst;
+}
+
+X_EXTERN unsigned int
+X_PFX (list_length) (x_list *lst)
+{
+ unsigned int n;
+
+ n = 0;
+ for (; lst != NULL; lst = lst->next)
+ n++;
+
+ return n;
+}
+
+X_EXTERN void
+X_PFX (list_foreach) (x_list *lst,
+ void (*fun) (void *data, void *user_data),
+ void *user_data)
+{
+ for (; lst != NULL; lst = lst->next)
+ {
+ (*fun) (lst->data, user_data);
+ }
+}
+
+static x_list *
+list_sort_1 (x_list *lst, int length,
+ int (*less) (const void *, const void *))
+{
+ x_list *mid, *ptr;
+ x_list *out_head, *out;
+ int mid_point, i;
+
+ /* This is a standard (stable) list merge sort */
+
+ if (length < 2)
+ return lst;
+
+ /* Calculate the halfway point. Split the list into two sub-lists. */
+
+ mid_point = length / 2;
+ ptr = lst;
+ for (i = mid_point - 1; i > 0; i--)
+ ptr = ptr->next;
+ mid = ptr->next;
+ ptr->next = NULL;
+
+ /* Sort each sub-list. */
+
+ lst = list_sort_1 (lst, mid_point, less);
+ mid = list_sort_1 (mid, length - mid_point, less);
+
+ /* Then merge them back together. */
+
+ assert (lst != NULL && mid != NULL);
+
+ if ((*less) (mid->data, lst->data))
+ out = out_head = mid, mid = mid->next;
+ else
+ out = out_head = lst, lst = lst->next;
+
+ while (lst != NULL && mid != NULL)
+ {
+ if ((*less) (mid->data, lst->data))
+ out = out->next = mid, mid = mid->next;
+ else
+ out = out->next = lst, lst = lst->next;
+ }
+
+ if (lst != NULL)
+ out->next = lst;
+ else
+ out->next = mid;
+
+ return out_head;
+}
+
+X_EXTERN x_list *
+X_PFX (list_sort) (x_list *lst, int (*less) (const void *, const void *))
+{
+ int length;
+
+ length = X_PFX (list_length) (lst);
+
+ return list_sort_1 (lst, length, less);
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-list.h b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-list.h
new file mode 100644
index 000000000..8da37a91b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-list.h
@@ -0,0 +1,79 @@
+/* x-list.h -- simple list type
+ $Id: x-list.h,v 1.4 2005/07/01 22:43:08 daniels Exp $
+
+ Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name(s) of the above
+ copyright holders shall not be used in advertising or otherwise to
+ promote the sale, use or other dealings in this Software without
+ prior written authorization. */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/x-list.h,v 1.1 2003/04/30 23:15:42 torrey Exp $ */
+
+#ifndef X_LIST_H
+#define X_LIST_H 1
+
+/* This is just a cons. */
+
+typedef struct x_list_struct x_list;
+
+struct x_list_struct {
+ void *data;
+ x_list *next;
+};
+
+#ifndef X_PFX
+# define X_PFX(x) x_ ## x
+#endif
+
+#ifndef X_EXTERN
+# define X_EXTERN __private_extern__
+#endif
+
+X_EXTERN void X_PFX (list_free_1) (x_list *node);
+X_EXTERN x_list *X_PFX (list_prepend) (x_list *lst, void *data);
+
+X_EXTERN x_list *X_PFX (list_append) (x_list *lst, void *data);
+X_EXTERN x_list *X_PFX (list_remove) (x_list *lst, void *data);
+X_EXTERN void X_PFX (list_free) (x_list *lst);
+X_EXTERN x_list *X_PFX (list_pop) (x_list *lst, void **data_ret);
+
+X_EXTERN x_list *X_PFX (list_copy) (x_list *lst);
+X_EXTERN x_list *X_PFX (list_reverse) (x_list *lst);
+X_EXTERN x_list *X_PFX (list_find) (x_list *lst, void *data);
+X_EXTERN x_list *X_PFX (list_nth) (x_list *lst, int n);
+X_EXTERN x_list *X_PFX (list_filter) (x_list *src,
+ int (*pred) (void *item, void *data),
+ void *data);
+X_EXTERN x_list *X_PFX (list_map) (x_list *src,
+ void *(*fun) (void *item, void *data),
+ void *data);
+
+X_EXTERN unsigned int X_PFX (list_length) (x_list *lst);
+X_EXTERN void X_PFX (list_foreach) (x_list *lst, void (*fun)
+ (void *data, void *user_data),
+ void *user_data);
+
+X_EXTERN x_list *X_PFX (list_sort) (x_list *lst, int (*less) (const void *,
+ const void *));
+
+#endif /* X_LIST_H */
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xpr.h b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xpr.h
new file mode 100644
index 000000000..ac7e74f08
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xpr.h
@@ -0,0 +1,49 @@
+/*
+ * Xplugin rootless implementation
+ */
+/*
+ * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/xpr/xpr.h,v 1.3 2005/07/01 22:43:08 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xpr.h,v 1.4 2003/11/12 20:21:52 torrey Exp $ */
+
+#ifndef XPR_H
+#define XPR_H
+
+#include "screenint.h"
+
+extern Bool QuartzModeBundleInit(void);
+
+void AppleDRIExtensionInit(void);
+void xprAppleWMInit(void);
+Bool xprInit(ScreenPtr pScreen);
+Bool xprIsX11Window(void *nsWindow, int windowNumber);
+void xprHideWindows(Bool hide);
+
+Bool QuartzInitCursor(ScreenPtr pScreen);
+void QuartzSuspendXCursor(ScreenPtr pScreen);
+void QuartzResumeXCursor(ScreenPtr pScreen, int x, int y);
+
+#endif /* XPR_H */
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprAppleWM.c b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprAppleWM.c
new file mode 100644
index 000000000..2db6a2432
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprAppleWM.c
@@ -0,0 +1,99 @@
+/*
+ * Xplugin rootless implementation functions for AppleWM extension
+ */
+/*
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.2 2003/06/30 01:45:13 torrey Exp $ */
+
+#include "xpr.h"
+#include "applewmExt.h"
+#include "rootless.h"
+#include "Xplugin.h"
+#include <X11/X.h>
+
+
+static int xprSetWindowLevel(
+ WindowPtr pWin,
+ int level)
+{
+ xp_window_id wid;
+ xp_window_changes wc;
+
+ wid = (xp_window_id) RootlessFrameForWindow (pWin, TRUE);
+ if (wid == 0)
+ return BadWindow;
+
+ RootlessStopDrawing (pWin, FALSE);
+
+ wc.window_level = level;
+ if (xp_configure_window (wid, XP_WINDOW_LEVEL, &wc) != Success) {
+ return BadValue;
+ }
+
+ return Success;
+}
+
+
+static int xprFrameDraw(
+ WindowPtr pWin,
+ int class,
+ unsigned int attr,
+ const BoxRec *outer,
+ const BoxRec *inner,
+ unsigned int title_len,
+ const unsigned char *title_bytes)
+{
+ xp_window_id wid;
+
+ wid = (xp_window_id) RootlessFrameForWindow (pWin, FALSE);
+ if (wid == 0)
+ return BadWindow;
+
+ if (xp_frame_draw (wid, class, attr, outer, inner,
+ title_len, title_bytes) != Success)
+ {
+ return BadValue;
+ }
+
+ return Success;
+}
+
+
+static AppleWMProcsRec xprAppleWMProcs = {
+ xp_disable_update,
+ xp_reenable_update,
+ xprSetWindowLevel,
+ xp_frame_get_rect,
+ xp_frame_hit_test,
+ xprFrameDraw
+};
+
+
+void xprAppleWMInit(void)
+{
+ AppleWMExtensionInit(&xprAppleWMProcs);
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprCursor.c b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprCursor.c
new file mode 100644
index 000000000..ee06043df
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprCursor.c
@@ -0,0 +1,420 @@
+/**************************************************************
+ *
+ * Xplugin cursor support
+ *
+ **************************************************************/
+/*
+ * Copyright (c) 2001 Torrey T. Lyons and Greg Parker.
+ * Copyright (c) 2002 Apple Computer, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprCursor.c,v 1.1 2003/04/30 23:15:42 torrey Exp $ */
+
+#include "quartzCommon.h"
+#include "xpr.h"
+#include "darwin.h"
+#include "Xplugin.h"
+
+#include "mi.h"
+#include "scrnintstr.h"
+#include "cursorstr.h"
+#include "mipointrst.h"
+#include "windowstr.h"
+#include "globals.h"
+#include "servermd.h"
+#include "dixevents.h"
+
+typedef struct {
+ int cursorVisible;
+ QueryBestSizeProcPtr QueryBestSize;
+ miPointerSpriteFuncPtr spriteFuncs;
+} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
+
+static int darwinCursorScreenIndex = -1;
+static unsigned long darwinCursorGeneration = 0;
+
+#define CURSOR_PRIV(pScreen) \
+ ((QuartzCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
+
+
+static Bool
+load_cursor(CursorPtr src, int screen)
+{
+ uint32_t *data;
+ uint32_t rowbytes;
+ int width, height;
+ int hot_x, hot_y;
+
+ uint32_t fg_color, bg_color;
+ uint8_t *srow, *sptr;
+ uint8_t *mrow, *mptr;
+ uint32_t *drow, *dptr;
+ unsigned xcount, ycount;
+
+ xp_error err;
+
+ width = src->bits->width;
+ height = src->bits->height;
+ hot_x = src->bits->xhot;
+ hot_y = src->bits->yhot;
+
+#ifdef ARGB_CURSOR
+ if (src->bits->argb != NULL)
+ {
+ rowbytes = src->bits->width * sizeof(CARD32);
+ data = (uint32_t *) src->bits->argb;
+ }
+ else
+#endif
+ {
+ fg_color = 0xFF00 | (src->foreRed >> 8);
+ fg_color <<= 16;
+ fg_color |= src->foreGreen & 0xFF00;
+ fg_color |= src->foreBlue >> 8;
+
+ bg_color = 0xFF00 | (src->backRed >> 8);
+ bg_color <<= 16;
+ bg_color |= src->backGreen & 0xFF00;
+ bg_color |= src->backBlue >> 8;
+
+ fg_color = htonl(fg_color);
+ bg_color = htonl(bg_color);
+
+ /* round up to 8 pixel boundary so we can convert whole bytes */
+ rowbytes = ((src->bits->width * 4) + 31) & ~31;
+ data = alloca(rowbytes * src->bits->height);
+
+ if (!src->bits->emptyMask)
+ {
+ ycount = src->bits->height;
+ srow = src->bits->source; mrow = src->bits->mask;
+ drow = data;
+
+ while (ycount-- > 0)
+ {
+ xcount = (src->bits->width + 7) / 8;
+ sptr = srow; mptr = mrow;
+ dptr = drow;
+
+ while (xcount-- > 0)
+ {
+ uint8_t s, m;
+ int i;
+
+ s = *sptr++; m = *mptr++;
+ for (i = 0; i < 8; i++)
+ {
+#if BITMAP_BIT_ORDER == MSBFirst
+ if (m & 128)
+ *dptr++ = (s & 128) ? fg_color : bg_color;
+ else
+ *dptr++ = 0;
+ s <<= 1; m <<= 1;
+#else
+ if (m & 1)
+ *dptr++ = (s & 1) ? fg_color : bg_color;
+ else
+ *dptr++ = 0;
+ s >>= 1; m >>= 1;
+#endif
+ }
+ }
+
+ srow += BitmapBytePad(src->bits->width);
+ mrow += BitmapBytePad(src->bits->width);
+ drow = (uint32_t *) ((char *) drow + rowbytes);
+ }
+ }
+ else
+ {
+ memset(data, 0, src->bits->height * rowbytes);
+ }
+ }
+
+ err = xp_set_cursor(width, height, hot_x, hot_y, data, rowbytes);
+ return err == Success;
+}
+
+
+/*
+===========================================================================
+
+ Pointer sprite functions
+
+===========================================================================
+*/
+
+/*
+ * QuartzRealizeCursor
+ * Convert the X cursor representation to native format if possible.
+ */
+static Bool
+QuartzRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+ if(pCursor == NULL || pCursor->bits == NULL)
+ return FALSE;
+
+ /* FIXME: cache ARGB8888 representation? */
+
+ return TRUE;
+}
+
+
+/*
+ * QuartzUnrealizeCursor
+ * Free the storage space associated with a realized cursor.
+ */
+static Bool
+QuartzUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+ return TRUE;
+}
+
+
+/*
+ * QuartzSetCursor
+ * Set the cursor sprite and position.
+ */
+static void
+QuartzSetCursor(ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
+{
+ QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ if (!quartzServerVisible)
+ return;
+
+ if (pCursor == NULL)
+ {
+ if (ScreenPriv->cursorVisible)
+ {
+ xp_hide_cursor();
+ ScreenPriv->cursorVisible = FALSE;
+ }
+ }
+ else
+ {
+ load_cursor(pCursor, pScreen->myNum);
+
+ if (!ScreenPriv->cursorVisible)
+ {
+ xp_show_cursor();
+ ScreenPriv->cursorVisible = TRUE;
+ }
+ }
+}
+
+
+/*
+ * QuartzMoveCursor
+ * Move the cursor. This is a noop for us.
+ */
+static void
+QuartzMoveCursor(ScreenPtr pScreen, int x, int y)
+{
+}
+
+
+static miPointerSpriteFuncRec quartzSpriteFuncsRec = {
+ QuartzRealizeCursor,
+ QuartzUnrealizeCursor,
+ QuartzSetCursor,
+ QuartzMoveCursor
+};
+
+
+/*
+===========================================================================
+
+ Pointer screen functions
+
+===========================================================================
+*/
+
+/*
+ * QuartzCursorOffScreen
+ */
+static Bool
+QuartzCursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
+{
+ return FALSE;
+}
+
+
+/*
+ * QuartzCrossScreen
+ */
+static void
+QuartzCrossScreen(ScreenPtr pScreen, Bool entering)
+{
+ return;
+}
+
+
+/*
+ * QuartzWarpCursor
+ * Change the cursor position without generating an event or motion history.
+ * The input coordinates (x,y) are in pScreen-local X11 coordinates.
+ *
+ */
+static void
+QuartzWarpCursor(ScreenPtr pScreen, int x, int y)
+{
+ static Bool neverMoved = TRUE;
+
+ if (neverMoved)
+ {
+ /* Don't move the cursor the first time. This is the
+ jump-to-center initialization, and it's annoying. */
+ neverMoved = FALSE;
+ return;
+ }
+
+ if (quartzServerVisible)
+ {
+ int sx, sy;
+
+ sx = dixScreenOrigins[pScreen->myNum].x + darwinMainScreenX;
+ sy = dixScreenOrigins[pScreen->myNum].y + darwinMainScreenY;
+
+ CGWarpMouseCursorPosition(CGPointMake(sx + x, sy + y));
+ }
+
+ miPointerWarpCursor(pScreen, x, y);
+ miPointerUpdate();
+}
+
+
+static miPointerScreenFuncRec quartzScreenFuncsRec = {
+ QuartzCursorOffScreen,
+ QuartzCrossScreen,
+ QuartzWarpCursor,
+ DarwinEQPointerPost,
+ DarwinEQSwitchScreen
+};
+
+
+/*
+===========================================================================
+
+ Other screen functions
+
+===========================================================================
+*/
+
+/*
+ * QuartzCursorQueryBestSize
+ * Handle queries for best cursor size
+ */
+static void
+QuartzCursorQueryBestSize(int class, unsigned short *width,
+ unsigned short *height, ScreenPtr pScreen)
+{
+ QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+ if (class == CursorShape)
+ {
+ /* FIXME: query window server? */
+ *width = 32;
+ *height = 32;
+ }
+ else
+ {
+ (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
+ }
+}
+
+/*
+ * QuartzInitCursor
+ * Initialize cursor support
+ */
+Bool
+QuartzInitCursor(ScreenPtr pScreen)
+{
+ QuartzCursorScreenPtr ScreenPriv;
+ miPointerScreenPtr PointPriv;
+
+ /* initialize software cursor handling (always needed as backup) */
+ if (!miDCInitialize(pScreen, &quartzScreenFuncsRec))
+ return FALSE;
+
+ /* allocate private storage for this screen's QuickDraw cursor info */
+ if (darwinCursorGeneration != serverGeneration)
+ {
+ if ((darwinCursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+
+ darwinCursorGeneration = serverGeneration;
+ }
+
+ ScreenPriv = xcalloc(1, sizeof(QuartzCursorScreenRec));
+ if (ScreenPriv == NULL)
+ return FALSE;
+
+ CURSOR_PRIV(pScreen) = ScreenPriv;
+
+ /* override some screen procedures */
+ ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
+ pScreen->QueryBestSize = QuartzCursorQueryBestSize;
+
+ PointPriv = (miPointerScreenPtr) pScreen->devPrivates[miPointerScreenIndex].ptr;
+
+ ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
+ PointPriv->spriteFuncs = &quartzSpriteFuncsRec;
+
+ ScreenPriv->cursorVisible = TRUE;
+ return TRUE;
+}
+
+
+/*
+ * QuartzSuspendXCursor
+ * X server is hiding. Restore the Aqua cursor.
+ */
+void
+QuartzSuspendXCursor(ScreenPtr pScreen)
+{
+}
+
+
+/*
+ * QuartzResumeXCursor
+ * X server is showing. Restore the X cursor.
+ */
+void
+QuartzResumeXCursor(ScreenPtr pScreen, int x, int y)
+{
+ WindowPtr pWin;
+ CursorPtr pCursor;
+
+ pWin = GetSpriteWindow();
+ if (pWin->drawable.pScreen != pScreen)
+ return;
+
+ pCursor = GetSpriteCursor();
+ if (pCursor == NULL)
+ return;
+
+ QuartzSetCursor(pScreen, pCursor, x, y);
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c
new file mode 100644
index 000000000..7836091f6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c
@@ -0,0 +1,495 @@
+/*
+ * Xplugin rootless implementation frame functions
+ */
+/*
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.5 2005/07/01 22:43:08 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.4 2003/11/12 20:21:52 torrey Exp $ */
+
+#include "xpr.h"
+#include "rootlessCommon.h"
+#include "Xplugin.h"
+#include "x-hash.h"
+#include "x-list.h"
+#include "applewmExt.h"
+
+#include "propertyst.h"
+#include "dix.h"
+#include <X11/Xatom.h>
+#include "windowstr.h"
+
+#include <pthread.h>
+
+#define DEFINE_ATOM_HELPER(func,atom_name) \
+static Atom func (void) { \
+ static int generation; \
+ static Atom atom; \
+ if (generation != serverGeneration) { \
+ generation = serverGeneration; \
+ atom = MakeAtom (atom_name, strlen (atom_name), TRUE); \
+ } \
+ return atom; \
+}
+
+DEFINE_ATOM_HELPER(xa_native_window_id, "_NATIVE_WINDOW_ID")
+
+/* Maps xp_window_id -> RootlessWindowRec */
+static x_hash_table *window_hash;
+static pthread_mutex_t window_hash_mutex;
+
+static Bool no_configure_window;
+
+
+static inline xp_error
+xprConfigureWindow(xp_window_id id, unsigned int mask,
+ const xp_window_changes *values)
+{
+ if (!no_configure_window)
+ return xp_configure_window(id, mask, values);
+ else
+ return XP_Success;
+}
+
+
+static void
+xprSetNativeProperty(RootlessWindowPtr pFrame)
+{
+ xp_error err;
+ unsigned int native_id;
+ long data;
+
+ err = xp_get_native_window((xp_window_id) pFrame->wid, &native_id);
+ if (err == Success)
+ {
+ /* FIXME: move this to AppleWM extension */
+
+ data = native_id;
+ ChangeWindowProperty(pFrame->win, xa_native_window_id(),
+ XA_INTEGER, 32, PropModeReplace, 1, &data, TRUE);
+ }
+}
+
+
+/*
+ * Create and display a new frame.
+ */
+Bool
+xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
+ int newX, int newY, RegionPtr pShape)
+{
+ WindowPtr pWin = pFrame->win;
+ xp_window_changes wc;
+ unsigned int mask = 0;
+ xp_error err;
+
+ wc.x = newX;
+ wc.y = newY;
+ wc.width = pFrame->width;
+ wc.height = pFrame->height;
+ wc.bit_gravity = XP_GRAVITY_NONE;
+ mask |= XP_BOUNDS;
+
+ if (pWin->drawable.depth == 8)
+ {
+ wc.depth = XP_DEPTH_INDEX8;
+#if 0
+ wc.colormap = xprColormapCallback;
+ wc.colormap_data = pScreen;
+ mask |= XP_COLORMAP;
+#endif
+ }
+ else if (pWin->drawable.depth == 15)
+ wc.depth = XP_DEPTH_RGB555;
+ else if (pWin->drawable.depth == 24)
+ wc.depth = XP_DEPTH_ARGB8888;
+ else
+ wc.depth = XP_DEPTH_NIL;
+ mask |= XP_DEPTH;
+
+ if (pShape != NULL)
+ {
+ wc.shape_nrects = REGION_NUM_RECTS(pShape);
+ wc.shape_rects = REGION_RECTS(pShape);
+ wc.shape_tx = wc.shape_ty = 0;
+ mask |= XP_SHAPE;
+ }
+
+ err = xp_create_window(mask, &wc, (xp_window_id *) &pFrame->wid);
+
+ if (err != Success)
+ {
+ return FALSE;
+ }
+
+ if (window_hash == NULL)
+ {
+ window_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
+ pthread_mutex_init(&window_hash_mutex, NULL);
+ }
+
+ pthread_mutex_lock(&window_hash_mutex);
+ x_hash_table_insert(window_hash, pFrame->wid, pFrame);
+ pthread_mutex_unlock(&window_hash_mutex);
+
+ xprSetNativeProperty(pFrame);
+
+ return TRUE;
+}
+
+
+/*
+ * Destroy a frame.
+ */
+void
+xprDestroyFrame(RootlessFrameID wid)
+{
+ pthread_mutex_lock(&window_hash_mutex);
+ x_hash_table_remove(window_hash, wid);
+ pthread_mutex_unlock(&window_hash_mutex);
+
+ xp_destroy_window((xp_window_id) wid);
+}
+
+
+/*
+ * Move a frame on screen.
+ */
+void
+xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY)
+{
+ xp_window_changes wc;
+
+ wc.x = newX;
+ wc.y = newY;
+
+ xprConfigureWindow((xp_window_id) wid, XP_ORIGIN, &wc);
+}
+
+
+/*
+ * Resize and move a frame.
+ */
+void
+xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
+ int newX, int newY, unsigned int newW, unsigned int newH,
+ unsigned int gravity)
+{
+ xp_window_changes wc;
+
+ wc.x = newX;
+ wc.y = newY;
+ wc.width = newW;
+ wc.height = newH;
+ wc.bit_gravity = gravity;
+
+ /* It's unlikely that being async will save us anything here.
+ But it can't hurt. */
+
+ xprConfigureWindow((xp_window_id) wid, XP_BOUNDS, &wc);
+}
+
+
+/*
+ * Change frame stacking.
+ */
+void
+xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
+{
+ xp_window_changes wc;
+
+ /* Stack frame below nextWid it if it exists, or raise
+ frame above everything otherwise. */
+
+ if (nextWid == NULL)
+ {
+ wc.stack_mode = XP_MAPPED_ABOVE;
+ wc.sibling = 0;
+ }
+ else
+ {
+ wc.stack_mode = XP_MAPPED_BELOW;
+ wc.sibling = (xp_window_id) nextWid;
+ }
+
+ xprConfigureWindow((xp_window_id) wid, XP_STACKING, &wc);
+}
+
+
+/*
+ * Change the frame's shape.
+ */
+void
+xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape)
+{
+ xp_window_changes wc;
+
+ if (pShape != NULL)
+ {
+ wc.shape_nrects = REGION_NUM_RECTS(pShape);
+ wc.shape_rects = REGION_RECTS(pShape);
+ }
+ else
+ {
+ wc.shape_nrects = -1;
+ wc.shape_rects = NULL;
+ }
+
+ wc.shape_tx = wc.shape_ty = 0;
+
+ xprConfigureWindow((xp_window_id) wid, XP_SHAPE, &wc);
+}
+
+
+/*
+ * Unmap a frame.
+ */
+void
+xprUnmapFrame(RootlessFrameID wid)
+{
+ xp_window_changes wc;
+
+ wc.stack_mode = XP_UNMAPPED;
+ wc.sibling = 0;
+
+ xprConfigureWindow((xp_window_id) wid, XP_STACKING, &wc);
+}
+
+
+/*
+ * Start drawing to a frame.
+ * Prepare for direct access to its backing buffer.
+ */
+void
+xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
+{
+ void *data[2];
+ unsigned int rowbytes[2];
+ xp_error err;
+
+ err = xp_lock_window((xp_window_id) wid, NULL, NULL, data, rowbytes, NULL);
+ if (err != Success)
+ FatalError("Could not lock window %i for drawing.", (int) wid);
+
+ *pixelData = data[0];
+ *bytesPerRow = rowbytes[0];
+}
+
+
+/*
+ * Stop drawing to a frame.
+ */
+void
+xprStopDrawing(RootlessFrameID wid, Bool flush)
+{
+ xp_unlock_window((xp_window_id) wid, flush);
+}
+
+
+/*
+ * Flush drawing updates to the screen.
+ */
+void
+xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage)
+{
+ xp_flush_window((xp_window_id) wid);
+}
+
+
+/*
+ * Mark damaged rectangles as requiring redisplay to screen.
+ */
+void
+xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
+ int shift_x, int shift_y)
+{
+ xp_mark_window((xp_window_id) wid, nrects, rects, shift_x, shift_y);
+}
+
+
+/*
+ * Called after the window associated with a frame has been switched
+ * to a new top-level parent.
+ */
+void
+xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin)
+{
+ DeleteProperty(oldWin, xa_native_window_id());
+
+ xprSetNativeProperty(pFrame);
+}
+
+
+/*
+ * Called to check if the frame should be reordered when it is restacked.
+ */
+Bool xprDoReorderWindow(RootlessWindowPtr pFrame)
+{
+ WindowPtr pWin = pFrame->win;
+
+ return AppleWMDoReorderWindow(pWin);
+}
+
+
+/*
+ * Copy area in frame to another part of frame.
+ * Used to accelerate scrolling.
+ */
+void
+xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
+ int dx, int dy)
+{
+ xp_copy_window((xp_window_id) wid, (xp_window_id) wid,
+ dstNrects, dstRects, dx, dy);
+}
+
+
+static RootlessFrameProcsRec xprRootlessProcs = {
+ xprCreateFrame,
+ xprDestroyFrame,
+ xprMoveFrame,
+ xprResizeFrame,
+ xprRestackFrame,
+ xprReshapeFrame,
+ xprUnmapFrame,
+ xprStartDrawing,
+ xprStopDrawing,
+ xprUpdateRegion,
+ xprDamageRects,
+ xprSwitchWindow,
+ xprDoReorderWindow,
+ xp_copy_bytes,
+ xp_fill_bytes,
+ xp_composite_pixels,
+ xprCopyWindow
+};
+
+
+/*
+ * Initialize XPR implementation
+ */
+Bool
+xprInit(ScreenPtr pScreen)
+{
+ RootlessInit(pScreen, &xprRootlessProcs);
+
+ rootless_CopyBytes_threshold = xp_copy_bytes_threshold;
+ rootless_FillBytes_threshold = xp_fill_bytes_threshold;
+ rootless_CompositePixels_threshold = xp_composite_area_threshold;
+ rootless_CopyWindow_threshold = xp_scroll_area_threshold;
+
+ no_configure_window = FALSE;
+
+ return TRUE;
+}
+
+
+/*
+ * Given the id of a physical window, try to find the top-level (or root)
+ * X window that it represents.
+ */
+static WindowPtr
+xprGetXWindow(xp_window_id wid)
+{
+ RootlessWindowRec *winRec;
+
+ if (window_hash == NULL)
+ return NULL;
+
+ winRec = x_hash_table_lookup(window_hash, (void *) wid, NULL);
+
+ return winRec != NULL ? winRec->win : NULL;
+}
+
+
+/*
+ * The windowNumber is an AppKit window number. Returns TRUE if xpr is
+ * displaying a window with that number.
+ */
+Bool
+xprIsX11Window(void *nsWindow, int windowNumber)
+{
+ Bool ret;
+ xp_window_id wid;
+
+ if (window_hash == NULL)
+ return FALSE;
+
+ /* need to lock, since this function can be called by any thread */
+
+ pthread_mutex_lock(&window_hash_mutex);
+
+ if (xp_lookup_native_window(windowNumber, &wid))
+ ret = xprGetXWindow(wid) != NULL;
+ else
+ ret = FALSE;
+
+ pthread_mutex_unlock(&window_hash_mutex);
+
+ return ret;
+}
+
+
+/*
+ * xprHideWindows
+ * Hide or unhide all top level windows. This is called for application hide/
+ * unhide events if the window manager is not Apple-WM aware. Xplugin windows
+ * do not hide or unhide themselves.
+ */
+void
+xprHideWindows(Bool hide)
+{
+ int screen;
+ WindowPtr pRoot, pWin;
+
+ for (screen = 0; screen < screenInfo.numScreens; screen++) {
+ pRoot = WindowTable[screenInfo.screens[screen]->myNum];
+ RootlessFrameID prevWid = NULL;
+
+ for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) {
+ RootlessWindowRec *winRec = WINREC(pWin);
+
+ if (winRec != NULL) {
+ if (hide) {
+ xprUnmapFrame(winRec->wid);
+ } else {
+ BoxRec box;
+
+ xprRestackFrame(winRec->wid, prevWid);
+ prevWid = winRec->wid;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = winRec->width;
+ box.y2 = winRec->height;
+
+ xprDamageRects(winRec->wid, 1, &box, 0, 0);
+ RootlessQueueRedisplay(screenInfo.screens[screen]);
+ }
+ }
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c
new file mode 100644
index 000000000..ba89fd38f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c
@@ -0,0 +1,417 @@
+/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c,v 1.6 2005/07/01 22:43:08 daniels Exp $ */
+/*
+ * Xplugin rootless implementation screen functions
+ */
+/*
+ * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
+ * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c,v 1.11 2004/07/15 18:53:25 torrey Exp $ */
+
+#include "quartzCommon.h"
+#include "quartz.h"
+#include "xpr.h"
+#include "pseudoramiX.h"
+#include "darwin.h"
+#include "rootless.h"
+#include "safeAlpha.h"
+#include "dri.h"
+#include "globals.h"
+#include "Xplugin.h"
+#include "applewmExt.h"
+
+#ifdef DAMAGE
+# include "damage.h"
+#endif
+
+// Name of GLX bundle for native OpenGL
+static const char *xprOpenGLBundle = "glxCGL.bundle";
+
+
+/*
+ * eventHandler
+ * Callback handler for Xplugin events.
+ */
+static void
+eventHandler(unsigned int type, const void *arg,
+ unsigned int arg_size, void *data)
+{
+ switch (type)
+ {
+ case XP_EVENT_DISPLAY_CHANGED:
+ QuartzMessageServerThread(kXDarwinDisplayChanged, 0);
+ break;
+
+ case XP_EVENT_WINDOW_STATE_CHANGED:
+ if (arg_size >= sizeof(xp_window_state_event))
+ {
+ const xp_window_state_event *ws_arg = arg;
+
+ QuartzMessageServerThread(kXDarwinWindowState, 2,
+ ws_arg->id, ws_arg->state);
+ }
+ break;
+
+ case XP_EVENT_WINDOW_MOVED:
+ if (arg_size == sizeof(xp_window_id))
+ {
+ xp_window_id id = * (xp_window_id *) arg;
+
+ QuartzMessageServerThread(kXDarwinWindowMoved, 1, id);
+ }
+ break;
+
+ case XP_EVENT_SURFACE_DESTROYED:
+ case XP_EVENT_SURFACE_CHANGED:
+ if (arg_size == sizeof(xp_surface_id))
+ {
+ int kind;
+
+ if (type == XP_EVENT_SURFACE_DESTROYED)
+ kind = AppleDRISurfaceNotifyDestroyed;
+ else
+ kind = AppleDRISurfaceNotifyChanged;
+
+ DRISurfaceNotify(*(xp_surface_id *) arg, kind);
+ }
+ break;
+ }
+}
+
+
+/*
+ * displayScreenBounds
+ * Return the display ID for a particular display index.
+ */
+static CGDirectDisplayID
+displayAtIndex(int index)
+{
+ CGError err;
+ CGDisplayCount cnt;
+ CGDirectDisplayID dpy[index+1];
+
+ err = CGGetActiveDisplayList(index + 1, dpy, &cnt);
+ if (err == kCGErrorSuccess && cnt == index + 1)
+ return dpy[index];
+ else
+ return kCGNullDirectDisplay;
+}
+
+
+/*
+ * displayScreenBounds
+ * Return the bounds of a particular display.
+ */
+static CGRect
+displayScreenBounds(CGDirectDisplayID id)
+{
+ CGRect frame;
+
+ frame = CGDisplayBounds(id);
+
+ /* Remove menubar to help standard X11 window managers. */
+
+ if (frame.origin.x == 0 && frame.origin.y == 0)
+ {
+ frame.origin.y += aquaMenuBarHeight;
+ frame.size.height -= aquaMenuBarHeight;
+ }
+
+ return frame;
+}
+
+
+/*
+ * xprAddPseudoramiXScreens
+ * Add a single virtual screen encompassing all the physical screens
+ * with PseudoramiX.
+ */
+static void
+xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height)
+{
+ CGDisplayCount i, displayCount;
+ CGDirectDisplayID *displayList = NULL;
+ CGRect unionRect = CGRectNull, frame;
+
+ // Find all the CoreGraphics displays
+ CGGetActiveDisplayList(0, NULL, &displayCount);
+ displayList = xalloc(displayCount * sizeof(CGDirectDisplayID));
+ CGGetActiveDisplayList(displayCount, displayList, &displayCount);
+
+ /* Get the union of all screens */
+ for (i = 0; i < displayCount; i++)
+ {
+ CGDirectDisplayID dpy = displayList[i];
+ frame = displayScreenBounds(dpy);
+ unionRect = CGRectUnion(unionRect, frame);
+ }
+
+ /* Use unionRect as the screen size for the X server. */
+ *x = unionRect.origin.x;
+ *y = unionRect.origin.y;
+ *width = unionRect.size.width;
+ *height = unionRect.size.height;
+
+ /* Tell PseudoramiX about the real screens. */
+ for (i = 0; i < displayCount; i++)
+ {
+ CGDirectDisplayID dpy = displayList[i];
+
+ frame = displayScreenBounds(dpy);
+
+ ErrorF("PseudoramiX screen %d added: %dx%d @ (%d,%d).\n", i,
+ (int)frame.size.width, (int)frame.size.height,
+ (int)frame.origin.x, (int)frame.origin.y);
+
+ frame.origin.x -= unionRect.origin.x;
+ frame.origin.y -= unionRect.origin.y;
+
+ ErrorF("PseudoramiX screen %d placed at X11 coordinate (%d,%d).\n",
+ i, (int)frame.origin.x, (int)frame.origin.y);
+
+ PseudoramiXAddScreen(frame.origin.x, frame.origin.y,
+ frame.size.width, frame.size.height);
+ }
+
+ xfree(displayList);
+}
+
+
+/*
+ * xprDisplayInit
+ * Find number of CoreGraphics displays and initialize Xplugin.
+ */
+static void
+xprDisplayInit(void)
+{
+ CGDisplayCount displayCount;
+
+ ErrorF("Display mode: Rootless Quartz -- Xplugin implementation\n");
+
+ CGGetActiveDisplayList(0, NULL, &displayCount);
+
+ /* With PseudoramiX, the X server only sees one screen; only PseudoramiX
+ itself knows about all of the screens. */
+
+ if (noPseudoramiXExtension)
+ darwinScreensFound = displayCount;
+ else
+ darwinScreensFound = 1;
+
+ if (xp_init(XP_IN_BACKGROUND) != Success)
+ {
+ FatalError("Could not initialize the Xplugin library.");
+ }
+
+ xp_select_events(XP_EVENT_DISPLAY_CHANGED
+ | XP_EVENT_WINDOW_STATE_CHANGED
+ | XP_EVENT_WINDOW_MOVED
+ | XP_EVENT_SURFACE_CHANGED
+ | XP_EVENT_SURFACE_DESTROYED,
+ eventHandler, NULL);
+
+ AppleDRIExtensionInit();
+ xprAppleWMInit();
+}
+
+
+/*
+ * xprAddScreen
+ * Init the framebuffer and record pixmap parameters for the screen.
+ */
+static Bool
+xprAddScreen(int index, ScreenPtr pScreen)
+{
+ DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
+
+ /* If no specific depth chosen, look for the depth of the main display.
+ Else if 16bpp specified, use that. Else use 32bpp. */
+
+ dfb->colorType = TrueColor;
+ dfb->bitsPerComponent = 8;
+ dfb->bitsPerPixel = 32;
+ dfb->colorBitsPerPixel = 24;
+
+ if (darwinDesiredDepth == -1)
+ {
+ dfb->bitsPerComponent = CGDisplayBitsPerSample(kCGDirectMainDisplay);
+ dfb->bitsPerPixel = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
+ dfb->colorBitsPerPixel =
+ CGDisplaySamplesPerPixel(kCGDirectMainDisplay) *
+ dfb->bitsPerComponent;
+ }
+ else if (darwinDesiredDepth == 15)
+ {
+ dfb->bitsPerComponent = 5;
+ dfb->bitsPerPixel = 16;
+ dfb->colorBitsPerPixel = 15;
+ }
+ else if (darwinDesiredDepth == 8)
+ {
+ dfb->colorType = PseudoColor;
+ dfb->bitsPerComponent = 8;
+ dfb->bitsPerPixel = 8;
+ dfb->colorBitsPerPixel = 8;
+ }
+
+ if (noPseudoramiXExtension)
+ {
+ CGDirectDisplayID dpy;
+ CGRect frame;
+
+ dpy = displayAtIndex(index);
+
+ frame = displayScreenBounds(dpy);
+
+ dfb->x = frame.origin.x;
+ dfb->y = frame.origin.y;
+ dfb->width = frame.size.width;
+ dfb->height = frame.size.height;
+ }
+ else
+ {
+ xprAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height);
+ }
+
+ /* Passing zero width (pitch) makes miCreateScreenResources set the
+ screen pixmap to the framebuffer pointer, i.e. NULL. The generic
+ rootless code takes care of making this work. */
+ dfb->pitch = 0;
+ dfb->framebuffer = NULL;
+
+ DRIScreenInit(pScreen);
+
+ return TRUE;
+}
+
+
+/*
+ * xprSetupScreen
+ * Setup the screen for rootless access.
+ */
+static Bool
+xprSetupScreen(int index, ScreenPtr pScreen)
+{
+ // Add alpha protecting replacements for fb screen functions
+ pScreen->PaintWindowBackground = SafeAlphaPaintWindow;
+ pScreen->PaintWindowBorder = SafeAlphaPaintWindow;
+
+#ifdef RENDER
+ {
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ ps->Composite = SafeAlphaComposite;
+ }
+#endif /* RENDER */
+
+ // Initialize accelerated rootless drawing
+ // Note that this must be done before DamageSetup().
+ RootlessAccelInit(pScreen);
+
+#ifdef DAMAGE
+ // The Damage extension needs to wrap underneath the
+ // generic rootless layer, so do it now.
+ if (!DamageSetup(pScreen))
+ return FALSE;
+#endif
+
+ // Initialize generic rootless code
+ if (!xprInit(pScreen))
+ return FALSE;
+
+ return DRIFinishScreenInit(pScreen);
+}
+
+
+/*
+ * xprUpdateScreen
+ * Update screen after configuation change.
+ */
+static void
+xprUpdateScreen(ScreenPtr pScreen)
+{
+ rootlessGlobalOffsetX = darwinMainScreenX;
+ rootlessGlobalOffsetY = darwinMainScreenY;
+
+ AppleWMSetScreenOrigin(WindowTable[pScreen->myNum]);
+
+ RootlessRepositionWindows(pScreen);
+ RootlessUpdateScreenPixmap(pScreen);
+}
+
+
+/*
+ * xprInitInput
+ * Finalize xpr specific setup.
+ */
+static void
+xprInitInput(int argc, char **argv)
+{
+ int i;
+
+ rootlessGlobalOffsetX = darwinMainScreenX;
+ rootlessGlobalOffsetY = darwinMainScreenY;
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ AppleWMSetScreenOrigin(WindowTable[i]);
+}
+
+
+/*
+ * Quartz display mode function list.
+ */
+static QuartzModeProcsRec xprModeProcs = {
+ xprDisplayInit,
+ xprAddScreen,
+ xprSetupScreen,
+ xprInitInput,
+ QuartzInitCursor,
+ NULL, // No need to update cursor
+ QuartzSuspendXCursor,
+ QuartzResumeXCursor,
+ NULL, // No capture or release in rootless mode
+ NULL,
+ NULL, // Xplugin sends screen change events directly
+ xprAddPseudoramiXScreens,
+ xprUpdateScreen,
+ xprIsX11Window,
+ xprHideWindows,
+ RootlessFrameForWindow,
+ TopLevelParent,
+ DRICreateSurface,
+ DRIDestroySurface
+};
+
+
+/*
+ * QuartzModeBundleInit
+ * Initialize the display mode bundle after loading.
+ */
+Bool
+QuartzModeBundleInit(void)
+{
+ quartzProcs = &xprModeProcs;
+ quartzOpenGLBundle = xprOpenGLBundle;
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/darwin/utils/Imakefile b/nx-X11/programs/Xserver/hw/darwin/utils/Imakefile
new file mode 100644
index 000000000..b6ad53d8b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/utils/Imakefile
@@ -0,0 +1,10 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/utils/Imakefile,v 1.2 2000/11/16 03:22:18 dawes Exp $
+
+ SRCS = dumpkeymap.c
+ OBJS = dumpkeymap.o
+EXTRA_LOAD_FLAGS = -framework IOKit
+
+AllTarget(ProgramTargetName(dumpkeymap))
+
+SimpleProgramTarget(dumpkeymap)
+
diff --git a/nx-X11/programs/Xserver/hw/darwin/utils/README.txt b/nx-X11/programs/Xserver/hw/darwin/utils/README.txt
new file mode 100644
index 000000000..fb6d4399e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/utils/README.txt
@@ -0,0 +1,111 @@
+dumpkeymap - Diagnostic dump and detailed description of .keymapping files
+Version 4
+
+Copyright (C)1999,2000 by Eric Sunshine <sunshine@sunshineco.com>
+Eric Sunshine, 1 December 2000
+
+OVERVIEW
+========
+This package contains the diagnostic utility dumpkeymap, as well as highly
+detailed documentation describing the internal layout of the Apple/NeXT
+.keymapping file.
+
+The dumpkeymap utility displays detailed information about each .keymapping
+file mentioned on the command-line. On Apple and NeXT platforms, if no
+.keymapping files are mentioned on the command-line, then it will instead
+dissect the key mapping currently in use by the WindowServer and AppKit.
+
+Documentation includes a thorough and detailed description of the internal
+layout of the .keymapping file, as well as an explanation of how to interpret
+the output of dumpkeymap.
+
+The complete set of documentation is available for perusal via dumpkeymap's
+manual page (dumpkeymap.1), as well as via the command-line options described
+below.
+
+ --help
+ Usage summary.
+ --help-keymapping
+ Detailed discussion of the internal format of a .keymapping file.
+ --help-output
+ Explanation of dumpkeymap's output.
+ --help-files
+ List of key mapping-related files and directories.
+ --help-diagnostics
+ Explanation of diagnostic messages.
+
+Once the manual page is been installed, documentation can also be accessed
+with the Unix `man' command:
+
+ % man dumpkeymap
+
+
+COMPILATION
+===========
+MacOS/X, Darwin
+
+ cc -Wall -o dumpkeymap dumpkeymap.c -framework IOKit
+
+MacOS/X DP4 (Developer Preview 4)
+
+ cc -Wall -o dumpkeymap dumpkeymap.c -FKernel -framework IOKit
+
+MacOS/X Server, OpenStep, NextStep
+
+ cc -Wall -o dumpkeymap dumpkeymap.c
+
+By default, dumpkeymap is configured to interface with the HID driver (Apple)
+or event-status driver (NeXT), thus allowing it to dump the key mapping which
+is currently in use by the WindowServer and AppKit. However, these facilities
+are specific to Apple/NeXT. In order to build dumpkeymap for non-Apple/NeXT
+platforms, you must define the DUMPKEYMAP_FILE_ONLY flag when compiling the
+program. This flag inhibits use of the HID and event-status drivers and
+configures dumpkeymap to work strictly with raw key mapping files.
+
+For example, to compile for Linux:
+
+ gcc -Wall -DDUMPKEYMAP_FILE_ONLY -o dumpkeymap dumpkeymap.c
+
+
+INSTALLATION
+============
+Install the dumpkeymap executable image in a location mentioned in the PATH
+environment variable. Typicall locations for executable files are:
+
+ /usr/local/bin
+ $(HOME)/bin
+
+Install the manual page, dumpkeymap.1, in the `man1' subdirectory one of the
+standard manual page locations or in any other location mentioned by the
+MANPATH environment variable.
+
+Typical locations for manual pages on most Unix platforms are:
+
+ /usr/local/man/man1
+
+Typical locations for manual pages on MacOS/X, Darwin, and MacOS/X Server are:
+
+ /usr/local/man/man1
+ /Local/Documentation/ManPages/man1
+ /Network/Documentation/ManPages/man1
+
+Typical locations for manual pages on OpenStep and NextStep are:
+
+ /usr/local/man/man1
+ /LocalLibrary/Documentation/ManPages/man1
+ /LocalDeveloper/Documentation/ManPages/man1
+
+
+CONCLUSION
+==========
+This program and its accompanying documentation were written by Eric Sunshine
+and are copyright (C)1999,2000 by Eric Sunshine <sunshine@sunshineco.com>.
+
+The implementation of dumpkeymap is based upon information gathered on
+September 3, 1997 by Eric Sunshine <sunshine@sunshineco.com> and Paul S.
+McCarthy <zarnuk@zarnuk.com> during an effort to reverse engineer the format
+of the NeXT .keymapping file.
+
+
+
+$XFree86: xc/programs/Xserver/hw/darwin/utils/README.txt,v 1.1 2000/12/01 19:47:39 dawes Exp $
diff --git a/nx-X11/programs/Xserver/hw/darwin/utils/dumpkeymap.c b/nx-X11/programs/Xserver/hw/darwin/utils/dumpkeymap.c
new file mode 100644
index 000000000..8f3340b15
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/utils/dumpkeymap.c
@@ -0,0 +1,1454 @@
+// $XFree86: dumpkeymap.c,v 1.3 2000/12/05 21:18:34 dawes Exp $
+//=============================================================================
+//
+// Copyright (C) 1999,2000 by Eric Sunshine <sunshine@sunshineco.com>
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// 3. The name of the author may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+// NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//=============================================================================
+//-----------------------------------------------------------------------------
+// dumpkeymap.c
+//
+// Prints a textual representation of each Apple/NeXT .keymapping file
+// mentioned on the command-line. If no files are mentioned and if the
+// local machine is an Apple or NeXT installation, then the key mapping
+// currently in use by the WindowServer and the AppKit is printed
+// instead.
+//
+// Invoke dumpkeymap with one of the options listed below in order to
+// view detailed documentation about .keymapping files and the use of
+// this program.
+//
+// --help: Usage summary.
+// --help-keymapping: Detailed discussion of the internal format of a
+// .keymapping file.
+// --help-output: Explanation of dumpkeymap's output.
+// --help-files: List of key mapping-related files and directories.
+// --help-diagnostics: Explanation of diagnostic messages.
+//
+// COMPILATION INSTRUCTIONS
+//
+// MacOS/X, Darwin
+// cc -Wall -o dumpkeymap dumpkeymap.c -framework IOKit
+//
+// MacOS/X DP4 (Developer Preview 4)
+// cc -Wall -o dumpkeymap dumpkeymap.c -FKernel -framework IOKit
+//
+// MacOS/X Server, OpenStep, NextStep
+// cc -Wall -o dumpkeymap dumpkeymap.c
+//
+// By default, dumpkeymap is configured to interface with the HID driver
+// (Apple) or event-status driver (NeXT), thus allowing it to dump the
+// key mapping which is currently in use by the WindowServer and AppKit.
+// However, these facilities are specific to Apple/NeXT. In order to
+// build dumpkeymap for non-Apple/NeXT platforms, you must define the
+// DUMPKEYMAP_FILE_ONLY flag when compiling the program. This flag
+// inhibits use of the HID and event-status drivers and configures
+// dumpkeymap to work strictly with raw key mapping files.
+//
+// For example, to compile for Linux:
+// gcc -Wall -DDUMPKEYMAP_FILE_ONLY -o dumpkeymap dumpkeymap.c
+//
+// CONCLUSION
+//
+// This program and its accompanying documentation were written by Eric
+// Sunshine and are copyright (C)1999,2000 by Eric Sunshine
+// <sunshine@sunshineco.com>.
+//
+// The implementation of dumpkeymap is based upon information gathered
+// on September 3, 1997 by Eric Sunshine <sunshine@sunshineco.com> and
+// Paul S. McCarthy <zarnuk@zarnuk.com> during an effort to reverse
+// engineer the format of the NeXT .keymapping file.
+//
+// HISTORY
+//
+// v4 2000/12/01 Eric Sunshine <sunshine@sunshineco.com>
+// Updated manual page to work with `rman', the `man' to `HTML'
+// translator. Unfortunately, however, rman is missing important
+// roff features such as diversions, indentation, and tab stops,
+// and is also hideously buggy, so getting the manual to work with
+// rman required quite a few work-arounds.
+// The manual page has now been tested with nroff (plain text), troff
+// (PostScript, etc.), groff (PostScript), and rman (HTML, etc.)
+//
+// v3 2000/11/28 Eric Sunshine <sunshine@sunshineco.com>
+// Considerably expanded the documentation.
+// Augmented the existing description of .keymapping internals.
+// Added these new documentation topics:
+// - Output: Very important section describing how to interpret
+// the output of dumpkeymap.
+// - Files: Lists files and directories related to key mappings.
+// - Diagnostics: Explains diagnostic messages issued by
+// dumpkeymap.
+// Created a manual page (dumpkeymap.1) which contains the complete
+// set of documentation for key mapping files and dumpkeymap.
+// Added command-line options (--help, --help-keymapping,
+// --help-output, --help-files, --help-diagnostics) which allow
+// access to all key mapping documentation. Previously the
+// description of the internal layout of a .keymapping file was
+// only available as source code comments.
+// Added --version option.
+// Ported to non-Apple/NeXT platforms. Defining the pre-processor
+// flag DUMPKEYMAP_FILE_ONLY at compilation time inhibits use of
+// Apple/NeXT-specific API.
+// Added a README file.
+//
+// v2 2000/11/13 Eric Sunshine <sunshine@sunshineco.com>
+// Converted from C++ to plain-C.
+// Now parses and takes into account the "number-size" flag stored
+// with each key map. This flag indicates the size, in bytes, of
+// all remaining numeric values in the mapping. Updated all code
+// to respect this flag. (Previously, the purpose of this field
+// was unknown, and it was thus denoted as
+// `KeyMapping::fill[2]'.)
+// Updated all documentation; especially the "KEY MAPPING
+// DESCRIPTION" section. Added discussion of the "number-size"
+// flag and revamped all structure definitions to use the generic
+// data type `number' instead of `uchar' or 'byte'. Clarified
+// several sections of the documentation and added missing
+// discussions about type definitions and the relationship of
+// `interface' and `handler_id' to .keymapping and .keyboard
+// files.
+// Updated compilation instructions to include directions for all
+// platforms on which this program might be built.
+// Now published under the formal BSD license rather than a
+// home-grown license.
+//
+// v1 1999/09/08 Eric Sunshine <sunshine@sunshineco.com>
+// Created.
+//-----------------------------------------------------------------------------
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#if !defined(DUMPKEYMAP_FILE_ONLY)
+#include <drivers/event_status_driver.h>
+#endif
+
+#define PROG_NAME "dumpkeymap"
+#define PROG_VERSION "4"
+#define AUTHOR_NAME "Eric Sunshine"
+#define AUTHOR_EMAIL "sunshine@sunshineco.com"
+#define AUTHOR_INFO AUTHOR_NAME " <" AUTHOR_EMAIL ">"
+#define COPYRIGHT "Copyright (C) 1999,2000 by " AUTHOR_INFO
+
+typedef unsigned char byte;
+typedef unsigned short word;
+typedef unsigned int natural;
+typedef unsigned long dword;
+typedef dword number;
+
+#define ASCII_SET 0x00
+#define BIND_FUNCTION 0xfe
+#define BIND_SPECIAL 0xff
+
+#define OPT_SWITCH(X) { char const* switched_str__=(X); if (0) {
+#define OPT_CASE(X,Y) } else if (strcmp(switched_str__,(#X)) == 0 || \
+ strcmp(switched_str__,(#Y)) == 0) {
+#define OPT_DEFAULT } else {
+#define OPT_SWITCH_END }}
+
+//-----------------------------------------------------------------------------
+// Translation Tables
+//-----------------------------------------------------------------------------
+static char const* const SPECIAL_CODE[] =
+ {
+ "sound-up",
+ "sound-down",
+ "brightness-up",
+ "brightness-down",
+ "alpha-lock",
+ "help",
+ "power",
+ "secondary-up-arrow",
+ "secondary-down-arrow"
+ };
+#define N_SPECIAL_CODE (sizeof(SPECIAL_CODE) / sizeof(SPECIAL_CODE[0]))
+
+static char const* const MODIFIER_CODE[] =
+ {
+ "alpha-lock",
+ "shift",
+ "control",
+ "alternate",
+ "command",
+ "keypad",
+ "help"
+ };
+#define N_MODIFIER_CODE (sizeof(MODIFIER_CODE) / sizeof(MODIFIER_CODE[0]))
+
+static char const* const MODIFIER_MASK[] =
+ {
+ "-----", // R = carriage-return
+ "----L", // A = alternate
+ "---S-", // C = control
+ "---SL", // S = shift
+ "--C--", // L = alpha-lock
+ "--C-L",
+ "--CS-",
+ "--CSL",
+ "-A---",
+ "-A--L",
+ "-A-S-",
+ "-A-SL",
+ "-AC--",
+ "-AC-L",
+ "-ACS-",
+ "-ACSL",
+ "R----",
+ "R---L",
+ "R--S-",
+ "R--SL",
+ "R-C--",
+ "R-C-L",
+ "R-CS-",
+ "R-CSL",
+ "RA---",
+ "RA--L",
+ "RA-S-",
+ "RA-SL",
+ "RAC--",
+ "RAC-L",
+ "RACS-",
+ "RACSL",
+ };
+#define N_MODIFIER_MASK (sizeof(MODIFIER_MASK) / sizeof(MODIFIER_MASK[0]))
+
+#define FUNCTION_KEY_FIRST 0x20
+static char const* const FUNCTION_KEY[] =
+ {
+ "F1", // 0x20
+ "F2", // 0x21
+ "F3", // 0x22
+ "F4", // 0x23
+ "F5", // 0x24
+ "F6", // 0x25
+ "F7", // 0x26
+ "F8", // 0x27
+ "F9", // 0x28
+ "F10", // 0x29
+ "F11", // 0x2a
+ "F12", // 0x2b
+ "insert", // 0x2c
+ "delete", // 0x2d
+ "home", // 0x2e
+ "end", // 0x2f
+ "page up", // 0x30
+ "page down", // 0x31
+ "print screen", // 0x32
+ "scroll lock", // 0x33
+ "pause", // 0x34
+ "sys-request", // 0x35
+ "break", // 0x36
+ "reset (HIL)", // 0x37
+ "stop (HIL)", // 0x38
+ "menu (HIL)", // 0x39
+ "user (HIL)", // 0x3a
+ "system (HIL)", // 0x3b
+ "print (HIL)", // 0x3c
+ "clear line (HIL)", // 0x3d
+ "clear display (HIL)", // 0x3e
+ "insert line (HIL)", // 0x3f
+ "delete line (HIL)", // 0x40
+ "insert char (HIL)", // 0x41
+ "delete char (HIL)", // 0x42
+ "prev (HIL)", // 0x43
+ "next (HIL)", // 0x44
+ "select (HIL)", // 0x45
+ };
+#define N_FUNCTION_KEY (sizeof(FUNCTION_KEY) / sizeof(FUNCTION_KEY[0]))
+
+
+//-----------------------------------------------------------------------------
+// Data Stream Object
+// Can be configured to treat embedded "numbers" as being composed of
+// either 1, 2, or 4 bytes, apiece.
+//-----------------------------------------------------------------------------
+typedef struct _DataStream
+ {
+ byte const* data;
+ byte const* data_end;
+ natural number_size; // Size in bytes of a "number" in the stream.
+ } DataStream;
+
+static DataStream* new_data_stream( byte const* data, int size )
+ {
+ DataStream* s = (DataStream*)malloc( sizeof(DataStream) );
+ s->data = data;
+ s->data_end = data + size;
+ s->number_size = 1; // Default to byte-sized numbers.
+ return s;
+ }
+
+static void destroy_data_stream( DataStream* s )
+ {
+ free(s);
+ }
+
+static int end_of_stream( DataStream* s )
+ {
+ return (s->data >= s->data_end);
+ }
+
+static void expect_nbytes( DataStream* s, int nbytes )
+ {
+ if (s->data + nbytes > s->data_end)
+ {
+ fputs( "Insufficient data in keymapping data stream.\n", stderr );
+ exit(-1);
+ }
+ }
+
+static byte get_byte( DataStream* s )
+ {
+ expect_nbytes( s, 1 );
+ return *s->data++;
+ }
+
+static word get_word( DataStream* s )
+ {
+ word hi, lo;
+ expect_nbytes( s, 2 );
+ hi = *s->data++;
+ lo = *s->data++;
+ return ((hi << 8) | lo);
+ }
+
+static dword get_dword( DataStream* s )
+ {
+ dword b1, b2, b3, b4;
+ expect_nbytes( s, 4 );
+ b4 = *s->data++;
+ b3 = *s->data++;
+ b2 = *s->data++;
+ b1 = *s->data++;
+ return ((b4 << 24) | (b3 << 16) | (b2 << 8) | b1);
+ }
+
+static number get_number( DataStream* s )
+ {
+ switch (s->number_size)
+ {
+ case 4: return get_dword(s);
+ case 2: return get_word(s);
+ default: return get_byte(s);
+ }
+ }
+
+
+//-----------------------------------------------------------------------------
+// Translation Utility Functions
+//-----------------------------------------------------------------------------
+static char const* special_code_desc( number n )
+ {
+ if (n < N_SPECIAL_CODE)
+ return SPECIAL_CODE[n];
+ else
+ return "invalid";
+ }
+
+static char const* modifier_code_desc( number n )
+ {
+ if (n < N_MODIFIER_CODE)
+ return MODIFIER_CODE[n];
+ else
+ return "invalid";
+ }
+
+static char const* modifier_mask_desc( number n )
+ {
+ if (n < N_MODIFIER_MASK)
+ return MODIFIER_MASK[n];
+ else
+ return "?????";
+ }
+
+static char const* function_key_desc( number n )
+ {
+ if (n >= FUNCTION_KEY_FIRST && n < N_FUNCTION_KEY + FUNCTION_KEY_FIRST)
+ return FUNCTION_KEY[ n - FUNCTION_KEY_FIRST ];
+ else
+ return "unknown";
+ }
+
+static number bits_set( number mask )
+ {
+ number n = 0;
+ for ( ; mask != 0; mask >>= 1)
+ if ((mask & 0x01) != 0)
+ n++;
+ return n;
+ }
+
+
+//-----------------------------------------------------------------------------
+// Unparse a list of Modifier records.
+//-----------------------------------------------------------------------------
+static void unparse_modifiers( DataStream* s )
+ {
+ number nmod = get_number(s); // Modifier count
+ printf( "MODIFIERS [%lu]\n", nmod );
+ while (nmod-- > 0)
+ {
+ number nscan;
+ number const code = get_number(s);
+ printf( "%s:", modifier_code_desc(code) );
+ nscan = get_number(s);
+ while (nscan-- > 0)
+ printf( " 0x%02x", (natural)get_number(s) );
+ putchar( '\n' );
+ }
+ putchar( '\n' );
+ }
+
+
+//-----------------------------------------------------------------------------
+// Unparse a list of Character records.
+//-----------------------------------------------------------------------------
+typedef void (*UnparseSpecialFunc)( number code );
+
+static void unparse_char_codes(
+ DataStream* s, number ncodes, UnparseSpecialFunc unparse_special )
+ {
+ if (ncodes != 0)
+ {
+ while (ncodes-- > 0)
+ {
+ number const char_set = get_number(s);
+ number const code = get_number(s);
+ putchar(' ');
+ switch (char_set)
+ {
+ case ASCII_SET:
+ {
+ int const c = (int)code;
+ if (isprint(c))
+ printf( "\"%c\"", c );
+ else if (code < ' ')
+ printf( "\"^%c\"", c + '@' );
+ else
+ printf( "%02x", c );
+ break;
+ }
+ case BIND_FUNCTION:
+ printf( "[%s]", function_key_desc(code) );
+ break;
+ case BIND_SPECIAL:
+ unparse_special( code );
+ break;
+ default:
+ printf( "%02x/%02x", (natural)char_set, (natural)code );
+ break;
+ }
+ }
+ }
+ }
+
+
+//-----------------------------------------------------------------------------
+// Unparse a list of scan code bindings.
+//-----------------------------------------------------------------------------
+static void unparse_key_special( number code )
+ {
+ printf( "{seq#%lu}", code );
+ }
+
+static void unparse_characters( DataStream* s )
+ {
+ number const NOT_BOUND = 0xff;
+ number const nscans = get_number(s);
+ number scan;
+ printf( "CHARACTERS [%lu]\n", nscans );
+ for (scan = 0; scan < nscans; scan++)
+ {
+ number const mask = get_number(s);
+ printf( "scan 0x%02x: ", (natural)scan );
+ if (mask == NOT_BOUND)
+ fputs( "not-bound\n", stdout );
+ else
+ {
+ number const bits = bits_set( mask );
+ number const codes = 1 << bits;
+ printf( "%s ", modifier_mask_desc(mask) );
+ unparse_char_codes( s, codes, unparse_key_special );
+ putchar( '\n' );
+ }
+ }
+ putchar( '\n' );
+ }
+
+
+//-----------------------------------------------------------------------------
+// Unparse a list of key sequences.
+//-----------------------------------------------------------------------------
+static void unparse_sequence_special( number code )
+ {
+ printf( "{%s}", (code == 0 ? "unmodify" : modifier_code_desc(code)) );
+ }
+
+static void unparse_sequences( DataStream* s )
+ {
+ number const nseqs = get_number(s);
+ number seq;
+ printf( "SEQUENCES [%lu]\n", nseqs );
+ for (seq = 0; seq < nseqs; seq++)
+ {
+ number const nchars = get_number(s);
+ printf( "sequence %lu:", seq );
+ unparse_char_codes( s, nchars, unparse_sequence_special );
+ putchar( '\n' );
+ }
+ putchar( '\n' );
+ }
+
+
+//-----------------------------------------------------------------------------
+// Unparse a list of special keys.
+//-----------------------------------------------------------------------------
+static void unparse_specials( DataStream* s )
+ {
+ number nspecials = get_number(s);
+ printf( "SPECIALS [%lu]\n", nspecials );
+ while (nspecials-- > 0)
+ {
+ number const special = get_number(s);
+ number const scan = get_number(s);
+ printf( "%s: 0x%02x\n", special_code_desc(special), (natural)scan );
+ }
+ putchar( '\n' );
+ }
+
+
+//-----------------------------------------------------------------------------
+// Unparse the number-size flag.
+//-----------------------------------------------------------------------------
+static void unparse_numeric_size( DataStream* s )
+ {
+ word const numbers_are_shorts = get_word(s);
+ s->number_size = numbers_are_shorts ? 2 : 1;
+ }
+
+
+//-----------------------------------------------------------------------------
+// Unparse an entire key map.
+//-----------------------------------------------------------------------------
+static void unparse_keymap_data( DataStream* s )
+ {
+ unparse_numeric_size(s);
+ unparse_modifiers(s);
+ unparse_characters(s);
+ unparse_sequences(s);
+ unparse_specials(s);
+ }
+
+
+//-----------------------------------------------------------------------------
+// Unparse the active key map.
+//-----------------------------------------------------------------------------
+#if !defined(DUMPKEYMAP_FILE_ONLY)
+static int unparse_active_keymap( void )
+ {
+ int rc = 1;
+ NXEventHandle const h = NXOpenEventStatus();
+ if (h == 0)
+ fputs( "Unable to open event status driver.\n", stderr );
+ else
+ {
+ NXKeyMapping km;
+ km.size = NXKeyMappingLength(h);
+ if (km.size <= 0)
+ fprintf( stderr, "Bad key mapping length (%d).\n", km.size );
+ else
+ {
+ km.mapping = (char*)malloc( km.size );
+ if (NXGetKeyMapping( h, &km ) == 0)
+ fputs( "Unable to get current key mapping.\n", stderr );
+ else
+ {
+ DataStream* stream =
+ new_data_stream( (byte const*)km.mapping, km.size );
+ fputs( "=============\nACTIVE KEYMAP\n=============\n\n",
+ stdout);
+ unparse_keymap_data( stream );
+ destroy_data_stream( stream );
+ rc = 0;
+ }
+ free( km.mapping );
+ }
+ NXCloseEventStatus(h);
+ }
+ return rc;
+ }
+#endif
+
+
+//-----------------------------------------------------------------------------
+// Unparse one key map from a keymapping file.
+//-----------------------------------------------------------------------------
+static void unparse_keymap( DataStream* s )
+ {
+ dword const interface = get_dword(s);
+ dword const handler_id = get_dword(s);
+ dword const map_size = get_dword(s);
+ printf( "interface: 0x%02lx\nhandler_id: 0x%02lx\nmap_size: %lu bytes\n\n",
+ interface, handler_id, map_size );
+ unparse_keymap_data(s);
+ }
+
+
+//-----------------------------------------------------------------------------
+// Check the magic number of a keymapping file.
+//-----------------------------------------------------------------------------
+static int check_magic_number( DataStream* s )
+ {
+ return (get_byte(s) == 'K' &&
+ get_byte(s) == 'Y' &&
+ get_byte(s) == 'M' &&
+ get_byte(s) == '1');
+ }
+
+
+//-----------------------------------------------------------------------------
+// Unparse all key maps within a keymapping file.
+//-----------------------------------------------------------------------------
+static int unparse_keymaps( DataStream* s )
+ {
+ int rc = 0;
+ if (check_magic_number(s))
+ {
+ int n = 1;
+ while (!end_of_stream(s))
+ {
+ printf( "---------\nKEYMAP #%d\n---------\n", n++ );
+ unparse_keymap(s);
+ }
+ }
+ else
+ {
+ fputs( "Bad magic number.\n", stderr );
+ rc = 1;
+ }
+ return rc;
+ }
+
+
+//-----------------------------------------------------------------------------
+// Unparse a keymapping file.
+//-----------------------------------------------------------------------------
+static int unparse_keymap_file( char const* const path )
+ {
+ int rc = 1;
+ FILE* file;
+ printf( "===========\nKEYMAP FILE\n===========\n%s\n\n", path );
+ file = fopen( path, "rb" );
+ if (file == 0)
+ perror( "Unable to open key mapping file" );
+ else
+ {
+ struct stat st;
+ if (fstat( fileno(file), &st ) != 0)
+ perror( "Unable to determine key mapping file size" );
+ else
+ {
+ byte* buffer = (byte*)malloc( st.st_size );
+ if (fread( buffer, st.st_size, 1, file ) != 1)
+ perror( "Unable to read key mapping file" );
+ else
+ {
+ DataStream* stream = new_data_stream(buffer, (int)st.st_size);
+ fclose( file ); file = 0;
+ rc = unparse_keymaps( stream );
+ destroy_data_stream( stream );
+ }
+ free( buffer );
+ }
+ if (file != 0)
+ fclose( file );
+ }
+ return rc;
+ }
+
+
+//-----------------------------------------------------------------------------
+// Handle the case when no documents are mentioned on the command-line. For
+// Apple/NeXT platforms, dump the currently active key mapping; else display
+// an error message.
+//-----------------------------------------------------------------------------
+static int handle_empty_document_list( void )
+ {
+#if !defined(DUMPKEYMAP_FILE_ONLY)
+ return unparse_active_keymap();
+#else
+ fputs( "ERROR: Must specify at least one .keymapping file.\n\n", stderr );
+ return 1;
+#endif
+ }
+
+
+//-----------------------------------------------------------------------------
+// Print a detailed description of the internal layout of a key mapping.
+//-----------------------------------------------------------------------------
+static void print_internal_layout_info( FILE* f )
+ {
+ fputs(
+"What follows is a detailed descriptions of the internal layout of an\n"
+"Apple/NeXT .keymapping file.\n"
+"\n"
+"Types and Data\n"
+"--------------\n"
+"The following type definitions are employed throughout this discussion:\n"
+"\n"
+" typedef unsigned char byte;\n"
+" typedef unsigned short word;\n"
+" typedef unsigned long dword;\n"
+"\n"
+"Additionally, the type definition `number' is used generically to indicate\n"
+"a numeric value. The actual size of the `number' type may be one or two\n"
+"bytes depending upon how the data is stored in the key map. Although most\n"
+"key maps use byte-sized numeric values, word-sized values are also allowed.\n"
+"\n"
+"Multi-byte values in a key mapping file are stored in big-endian byte\n"
+"order.\n"
+"\n"
+"Key Mapping File and Device Mapping\n"
+"-----------------------------------\n"
+"A key mapping file begins with a magic-number and continues with a variable\n"
+"number of device-specific key mappings.\n"
+"\n"
+" struct KeyMappingFile {\n"
+" char magic_number[4]; // `KYM1'\n"
+" DeviceMapping maps[...]; // Variable number of maps\n"
+" };\n"
+"\n"
+" struct DeviceMapping {\n"
+" dword interface; // Interface type\n"
+" dword handler_id; // Interface subtype\n"
+" dword map_size; // Byte count of `map' (below)\n"
+" KeyMapping map;\n"
+" };\n"
+"\n"
+"The value of `interface' represents a family of keyboard device types\n"
+"(such as Intel PC, ADB, NeXT, Sun Type5, etc.), and is generally\n"
+"specified as one of the constant values NX_EVS_DEVICE_INTERFACE_ADB,\n"
+"NX_EVS_DEVICE_INTERFACE_ACE, etc., which are are defined in IOHIDTypes.h on\n"
+"MacOS/X and Darwin, and in ev_types.h on MacOS/X Server, OpenStep, and\n"
+"NextStep.\n"
+"\n"
+"The value of `handler_id' represents a specific keyboard layout within the\n"
+"much broader `interface' family. For instance, for a 101-key Intel PC\n"
+"keyboard (of type NX_EVS_DEVICE_INTERFACE_ACE) the `handler_id' is '0',\n"
+"whereas for a 102-key keyboard it is `1'.\n"
+"\n"
+"Together, `interface' and `handler_id' identify the exact keyboard hardware\n"
+"to which this mapping applies. Programs which display a visual\n"
+"representation of a keyboard layout, match `interface' and `handler_id'\n"
+"from the .keymapping file against the `interface' and `handler_id' values\n"
+"found in each .keyboard file.\n"
+"\n"
+"Key Mapping\n"
+"-----------\n"
+"A key mapping completely defines the relationship of all scan codes with\n"
+"their associated functionality. A KeyMapping structure is embedded within\n"
+"the DeviceMapping structure in a KeyMappingFile. The key mapping currently\n"
+"in use by the WindowServer and AppKit is also represented by a KeyMapping\n"
+"structure, and can be referred to directly by calling NXGetKeyMapping() and\n"
+"accessing the `mapping' data member of the returned NXKeyMapping structure.\n"
+"\n"
+" struct KeyMapping {\n"
+" word number_size; // 0=1 byte, non-zero=2 bytes\n"
+" number num_modifier_groups; // Modifier groups\n"
+" ModifierGroup modifier_groups[...];\n"
+" number num_scan_codes; // Scan groups\n"
+" ScanGroup scan_table[...];\n"
+" number num_sequence_lists; // Sequence lists\n"
+" Sequence sequence_lists[...];\n"
+" number num_special_keys; // Special keys\n"
+" SpecialKey special_key[...];\n"
+" };\n"
+"\n"
+"The `number_size' flag determines the size, in bytes, of all remaining\n"
+"numeric values (denoted by the type definition `number') within the key\n"
+"mapping. If its value is zero, then numbers are represented by a single\n"
+"byte. If it is non-zero, then numbers are represented by a word (two\n"
+"bytes).\n"
+"\n"
+"Modifier Group\n"
+"--------------\n"
+"A modifier group defines all scan codes which map to a particular type of\n"
+"modifier, such as `shift', `control', etc.\n"
+"\n"
+" enum Modifier {\n"
+" ALPHALOCK = 0,\n"
+" SHIFT,\n"
+" CONTROL,\n"
+" ALTERNATE,\n"
+" COMMAND,\n"
+" KEYPAD,\n"
+" HELP\n"
+" };\n"
+"\n"
+" struct ModifierGroup {\n"
+" number modifier; // A Modifier constant\n"
+" number num_scan_codes;\n"
+" number scan_codes[...]; // Variable number of scan codes\n"
+" };\n"
+"\n"
+"The scan_codes[] array contains a list of all scan codes which map to the\n"
+"specified modifier. The `shift', `command', and `alternate' modifiers are\n"
+"frequently mapped to two different scan codes, apiece, since these\n"
+"modifiers often appear on both the left and right sides of the keyboard.\n"
+"\n"
+"Scan Group\n"
+"----------\n"
+"There is one ScanGroup for each scan code generated by the given keyboard.\n"
+"This number is given by KeyMapping::num_scan_codes. The first scan group\n"
+"represents hardware scan code 0, the second represents scan code 1, etc.\n"
+"\n"
+" enum ModifierMask {\n"
+" ALPHALOCK_MASK = 1 << 0,\n"
+" SHIFT_MASK = 1 << 1,\n"
+" CONTROL_MASK = 1 << 2,\n"
+" ALTERNATE_MASK = 1 << 3,\n"
+" CARRIAGE_RETURN_MASK = 1 << 4\n"
+" };\n"
+" #define NOT_BOUND 0xff\n"
+"\n"
+" struct ScanGroup {\n"
+" number mask;\n"
+" Character characters[...];\n"
+" };\n"
+"\n"
+"For each scan code, `mask' defines which modifier combinations generate\n"
+"characters. If `mask' is NOT_BOUND (0xff) then then this scan code does\n"
+"not generate any characters ever, and its characters[] array is zero\n"
+"length. Otherwise, the characters[] array contains one Character record\n"
+"for each modifier combination.\n"
+"\n"
+"The number of records in characters[] is determined by computing (1 <<\n"
+"bits_set_in_mask). In other words, if mask is zero, then zero bits are\n"
+"set, so characters[] contains only one record. If `mask' is (SHIFT_MASK |\n"
+"CONTROL_MASK), then two bits are set, so characters[] contains four\n"
+"records.\n"
+"\n"
+"The first record always represents the character which is generated by that\n"
+"key when no modifiers are active. The remaining records represent\n"
+"characters generated by the various modifier combinations. Using the\n"
+"example with the `shift' and `control' masks set, record two would\n"
+"represent the character with the `shift' modifier active; record three, the\n"
+"`control' modifier active; and record four, both the `shift' and `control'\n"
+"modifiers active.\n"
+"\n"
+"As a special case, ALPHALOCK_MASK implies SHIFT_MASK, though only\n"
+"ALPHALOCK_MASK appears in `mask'. In this case the same character is\n"
+"generated for both the `shift' and `alpha-lock' modifiers, but only needs\n"
+"to appear once in the characters[] array.\n"
+"\n"
+"CARRIAGE_RETURN_MASK does not actually refer to a modifier key. Instead,\n"
+"it is used to distinguish the scan code which is given the special\n"
+"pseudo-designation of `carriage return' key. Typically, this mask appears\n"
+"solo in a ScanGroup record and only the two Character records for control-M\n"
+"and control-C follow. This flag may be a throwback to an earlier time or\n"
+"may be specially interpreted by the low-level keyboard driver, but its\n"
+"purpose is otherwise enigmatic.\n"
+"Character\n"
+"---------\n"
+"Each Character record indicates the character generated when this key is\n"
+"pressed, as well as the character set which contains the character. Well\n"
+"known character sets are `ASCII' and `Symbol'. The character set can also\n"
+"be one of the meta values FUNCTION_KEY or KEY_SEQUENCE. If it is\n"
+"FUNCTION_KEY then `char_code' represents a generally well-known function\n"
+"key such as those enumerated by FunctionKey. If the character set is\n"
+"KEY_SEQUENCE then `char_code' represents a zero-base index into\n"
+"KeyMapping::sequence_lists[].\n"
+"\n"
+" enum CharacterSet {\n"
+" ASCII = 0x00,\n"
+" SYMBOL = 0x01,\n"
+" ...\n"
+" FUNCTION_KEY = 0xfe,\n"
+" KEY_SEQUENCE = 0xff\n"
+" };\n"
+"\n"
+" struct Character {\n"
+" number set; // CharacterSet of generated character\n"
+" number char_code; // Actual character generated\n"
+" };\n"
+"\n"
+" enum FunctionKey {\n"
+" F1 = 0x20, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,\n"
+" INSERT, DELETE, HOME, END, PAGE_UP, PAGE_DOWN, PRINT_SCREEN,\n"
+" SCROLL_LOCK, PAUSE, SYS_REQUEST, BREAK, RESET, STOP, MENU, USER,\n"
+" SYSTEM, PRINT, CLEAR_LINE, CLEAR_DISPLAY, INSERT_LINE,\n"
+" DELETE_LINE, INSERT_CHAR, DELETE_CHAR, PREV, NEXT, SELECT\n"
+" };\n"
+"\n"
+"Sequence\n"
+"--------\n"
+"When Character::set contains the meta value KEY_SEQUENCE, the scan code is\n"
+"bound to a sequence of keys rather than a single character. A sequence is\n"
+"a series of modifiers and characters which are automatically generated when\n"
+"the associated key is depressed.\n"
+"\n"
+" #define MODIFIER_KEY 0xff\n"
+"\n"
+" struct Sequence {\n"
+" number num_chars;\n"
+" Character characters[...];\n"
+" };\n"
+"\n"
+"Each generated Character is represented as previously described, with the\n"
+"exception that MODIFIER_KEY may appear in place of KEY_SEQUENCE. When the\n"
+"value of Character::set is MODIFIER_KEY then Character::char_code\n"
+"represents a modifier key rather than an actual character. If the modifier\n"
+"represented by `char_code' is non-zero, then it indicates that the\n"
+"associated modifier key has been depressed. In this case, the value is one\n"
+"of the constants enumerated by Modifier (SHIFT, CONTROL, ALTERNATE, etc.).\n"
+"If the value is zero then it means that the modifier keys have been\n"
+"released.\n"
+"\n"
+"Special Key\n"
+"-----------\n"
+"A special key is one which is scanned directly by the Mach kernel rather\n"
+"than by the WindowServer. In general, events are not generated for special\n"
+"keys.\n"
+"\n"
+" enum SpecialKeyType {\n"
+" VOLUME_UP = 0,\n"
+" VOLUME_DOWN,\n"
+" BRIGHTNESS_UP,\n"
+" BRIGHTNESS_DOWN,\n"
+" ALPHA_LOCK,\n"
+" HELP,\n"
+" POWER,\n"
+" SECONDARY_ARROW_UP,\n"
+" SECONDARY_ARROW_DOWN\n"
+" };\n"
+"\n"
+" struct SpecialKey {\n"
+" number type; // A SpecialKeyType constant\n"
+" number scan_code; // Actual scan code\n"
+" };\n"
+"\n", f );
+ }
+
+
+//-----------------------------------------------------------------------------
+// Print an explanation of the output generated by this program.
+//-----------------------------------------------------------------------------
+static void print_output_info( FILE* f )
+ {
+ fputs(
+"What follows is an explanation and description of the various pieces of\n"
+"information emitted by dumpkeymap.\n"
+"\n"
+"For a more thorough discussion of any particular piece of information\n"
+"described here, refer to the detailed description of the internal layout of\n"
+"a key mapping given by the --help-layout option.\n"
+"\n"
+"Conventions\n"
+"-----------\n"
+"Depending upon context, some numeric values are displayed in decimal\n"
+"notation, whereas others are displayed in hexadecimal notation.\n"
+"Hexadecimal numbers are denoted by a `0x' prefix (for instance, `0x7b'),\n"
+"except when explicitly noted otherwise.\n"
+"\n"
+"Key Mapping Source\n"
+"------------------\n"
+"The first piece of information presented about a particular key mapping is\n"
+"the source from which the data was gleaned. For a .keymapping file, the\n"
+"title `KEYMAP FILE' is emitted along with the path and name of the file in\n"
+"question. For the key mapping currently in use by the WindowServer and\n"
+"AppKit, the title `ACTIVE KEYMAP' is emitted instead.\n"
+"\n"
+"Device Information\n"
+"------------------\n"
+"Each .keymapping file may contain one or more raw key mappings. For\n"
+"example, a file which maps keys to a Dvorak-style layout might contain raw\n"
+"mappings for Intel PC, ADB, NeXT, and Sun Type5 keyboards.\n"
+"\n"
+"For each raw mapping, the following information is emitted:\n"
+"\n"
+" o The title `KEYMAP' along with the mapping's relative position in the\n"
+" .keymapping file.\n"
+" o The `interface' identifier.\n"
+" o The `handler_id' sub-identifier.\n"
+" o The size of the raw mapping resource counted in bytes.\n"
+"\n"
+"The `interface' and `handler_id' values, taken together, define a specific\n"
+"keyboard device. A .keyboard file, which describes the visual layout of a\n"
+"keyboard, also contains `interface' and `handler_id' identifiers. The\n"
+".keyboard file corresponding to a particular key mapping can be found by\n"
+"matching the `interface' and `handler_id' values from each resource.\n"
+"\n"
+"Modifiers\n"
+"---------\n"
+"Each mapping may contain zero or more modifier records which associate\n"
+"hardware scan codes with modifier descriptions such as `shift', `control',\n"
+"`alternate', etc. The title `MODIFIERS' is printed along with the count of\n"
+"modifier records which follow. For each modifier record, the modifier's\n"
+"name is printed along with a list of scan codes, in hexadecimal format,\n"
+"which generate that modifier value. For example:\n"
+"\n"
+" MODIFIERS [4]\n"
+" alternate: 0x1d 0x60\n"
+" control: 0x3a\n"
+" keypad: 0x52 0x53 ... 0x63 0x62\n"
+" shift: 0x2a 0x36\n"
+"\n"
+"Characters\n"
+"----------\n"
+"Each mapping may contain zero or more character records which associate\n"
+"hardware scan codes with the actual characters generated by those scan\n"
+"codes in the presence or absence of various modifier combinations. The\n"
+"title `CHARACTERS' is printed along with the count of character records\n"
+"which follow. Here is a highly abbreviated example:\n"
+"\n"
+" CHARACTERS [9]\n"
+" scan 0x00: -AC-L \"a\" \"A\" \"^A\" \"^A\" ca c7 \"^A\" \"^A\"\n"
+" scan 0x07: -AC-L \"x\" \"X\" \"^X\" \"^X\" 01/b4 01/ce \"^X\" \"^X\"\n"
+" scan 0x0a: ---S- \"<\" \">\"\n"
+" scan 0x13: -ACS- \"2\" \"@\" \"^@\" \"^@\" b2 b3 \"^@\" \"^@\"\n"
+" scan 0x24: R---- \"^M\" \"^C\"\n"
+" scan 0x3e: ----- [F4]\n"
+" scan 0x4a: ----- [page up]\n"
+" scan 0x60: ----- {seq#3}\n"
+" scan 0x68: not-bound\n"
+"\n"
+"For each record, the hexadecimal value of the hardware scan code is\n"
+"printed, followed by a list of modifier flag combinations and the actual\n"
+"characters generated by this scan code with and without modifiers applied.\n"
+"\n"
+"The modifier flags field is composed of a combination of single letter\n"
+"representations of the various modifier types. The letters stand for:\n"
+"\n"
+" L - alpha-lock\n"
+" S - shift\n"
+" C - control\n"
+" A - alternate\n"
+" R - carriage-return\n"
+"\n"
+"As a special case, the `alpha-lock' flag also implies the `shift' flag, so\n"
+"these two flags never appear together in the same record.\n"
+"\n"
+"The combination of modifier flags determines the meaning and number of\n"
+"fields which follow. The first field after the modifier flags always\n"
+"represents the character that will be generated if no modifier keys are\n"
+"depressed. The remaining fields represent characters generated by the\n"
+"various modifier combinations. The order of the fields follows this\n"
+"general pattern:\n"
+"\n"
+" o The character generated by this scan code when no modifiers are in\n"
+" effect is listed first.\n"
+"\n"
+" o If the `L' or `S' flag is active, then the shifted character\n"
+" generated by this scan code is listed next.\n"
+"\n"
+" o If the `C' flag is active, then the control-character generated by\n"
+" this scan code is listed next. Furthermore, if the `L' or `S' flag\n"
+" is also active, then the shifted control-character is listed after\n"
+" that.\n"
+"\n"
+" o If the `A' flag is active, then the alternate-character generated by\n"
+" this scan code is listed next. Furthermore, if the `L' or `S' flag\n"
+" is active, then the shifted alternate-character is listed after that.\n"
+" If the `C' flag is also active, then the alternate-control-character\n"
+" is listed next. Finally, if the `C' and `L' or `C' and `S' flags are\n"
+" also active, then the shifted alternate-control-character is listed.\n"
+"\n"
+"The `R' flag does not actually refer to a modifier key. Instead, it is\n"
+"used to distinguish the scan code which is given the special\n"
+"pseudo-designation of `carriage return' key. Typically, this mask appears\n"
+"solo and only the two fields for control-M and control-C follow. This flag\n"
+"may be a throwback to an earlier time or may be specially interpreted by\n"
+"the low-level keyboard driver, but its purpose is otherwise enigmatic.\n"
+"\n"
+"Recalling the example from above, the following fields can be identified:\n"
+"\n"
+" scan 0x00: -AC-L \"a\" \"A\" \"^A\" \"^A\" ca c7 \"^A\" \"^A\"\n"
+"\n"
+" o Lower-case `a' is generated when no modifiers are active.\n"
+" o Upper-case `A' is generated when `shift' or `alpha-lock' are active.\n"
+" o Control-A is generated when `control' is active.\n"
+" o Control-A is generated when `control' and `shift' are active.\n"
+" o The character represented by the hexadecimal code 0xca is generated\n"
+" when `alternate' is active.\n"
+" o The character represented by 0xc7 is generated when `alternate' and\n"
+" `shift' (or `alpha-lock') are active.\n"
+" o Control-A is generated when `alternate' and `control' are active.\n"
+" o Control-A is generated when `alternate', `control' and `shift' (or\n"
+" `alpha-lock') are active.\n"
+"\n"
+"The notation used to represent a particular generated character varies.\n"
+"\n"
+" o Printable ASCII characters are quoted, as in \"x\" or \"X\".\n"
+"\n"
+" o Control-characters are quoted and prefixed with `^', as in \"^X\".\n"
+"\n"
+" o Characters with values greater than 127 (0x7f) are displayed as\n"
+" hexadecimal values without the `0x' prefix.\n"
+"\n"
+" o Characters in a non-ASCII character set (such as `Symbol') are\n"
+" displayed as two hexadecimal numbers separated by a slash, as in\n"
+" `01/4a'. The first number is the character set's identification code\n"
+" (such as `01' for the `Symbol' set), and the second number is the\n"
+" value of the generated character.\n"
+"\n"
+" o Non-printing special function characters are displayed with the\n"
+" function's common name enclosed in brackets, as in `[page up]' or\n"
+" `[F4]'.\n"
+"\n"
+" o If the binding represents a key sequence rather than a single\n"
+" character, then the sequence's identification number is enclosed in\n"
+" braces, as in `{seq#3}'.\n"
+"\n"
+"Recalling a few examples from above, the following interpretations can be\n"
+"made:\n"
+"\n"
+" scan 0x07: -AC-L \"x\" \"X\" \"^X\" \"^X\" 01/b4 01/ce \"^X\" \"^X\"\n"
+" scan 0x3e: ----- [F4]\n"
+" scan 0x4a: ----- [page up]\n"
+" scan 0x60: ----- {seq#3}\n"
+"\n"
+" o \"x\" and \"X\" are printable ASCII characters.\n"
+" o \"^X\" is a control-character.\n"
+" o `01/b4' and `01/ce' represent the character codes 0xb4 and 0xce in\n"
+" the `Symbol' character set.\n"
+" o Scan code 0x3e generates function-key `F4', and scan code 0x4a\n"
+" generates function-key `page up'.\n"
+" o Scan code 0x60 is bound to key sequence #3.\n"
+"\n"
+"Finally, if a scan code is not bound to any characters, then it is\n"
+"annotated with the label `not-bound', as with example scan code 0x68 from\n"
+"above.\n"
+"\n"
+"Sequences\n"
+"---------\n"
+"A scan code (modified and unmodified) can be bound to a key sequence rather\n"
+"than generating a single character or acting as a modifier. When it is\n"
+"bound to a key sequence, a series of character invocations and modifier\n"
+"actions are automatically generated rather than a single keystroke.\n"
+"\n"
+"Each mapping may contain zero or more key sequence records. The title\n"
+"`SEQUENCES' is printed along with the count of sequence records which\n"
+"follow. For example:\n"
+"\n"
+" SEQUENCES [3]\n"
+" sequence 0: \"f\" \"o\" \"o\"\n"
+" sequence 1: {alternate} \"b\" \"a\" \"r\" {unmodify}\n"
+" sequence 2: [home] \"b\" \"a\" \"z\"\n"
+"\n"
+"The notation used to represent the sequence of generated characters is\n"
+"identical to the notation already described in the `Characters' section\n"
+"above, with the exception that modifier actions may be interposed between\n"
+"generated characters. Such modifier actions are represented by the\n"
+"modifier's name enclosed in braces. The special name `{unmodify}'\n"
+"indicates the release of the modifier keys.\n"
+"\n"
+"Thus, the sequences in the above example can be interpreted as follows:\n"
+"\n"
+" o Sequence #0 generates `foo'.\n"
+" o Sequence #1 invokes the `alternate' modifier, generates `bar', and\n"
+" then releases `alternate'.\n"
+" o Sequence #2 invokes the `home' key and then generates `baz'. In a\n"
+" text editor, this would probably result in `baz' being prepended to\n"
+" the line of text on which the cursor resides.\n"
+"\n"
+"Special Keys\n"
+"------------\n"
+"Certain keyboards feature keys which perform some type of special purpose\n"
+"function rather than generating a character or acting as a modifier. For\n"
+"instance, Apple keyboards often contain a `power' key, and NeXT keyboards\n"
+"have historically featured screen brightness and volume control keys.\n"
+"\n"
+"Each mapping may contain zero or more special-key records which associate\n"
+"hardware scan codes with such special purpose functions. The title\n"
+"`SPECIALS' is printed along with the count of records which follow. For\n"
+"each record, the special function's name is printed along with a list of\n"
+"scan codes, in hexadecimal format, which are bound to that function. For\n"
+"example:\n"
+"\n"
+" SPECIALS [6]\n"
+" alpha-lock: 0x39\n"
+" brightness-down: 0x79\n"
+" brightness-up: 0x74\n"
+" power: 0x7f\n"
+" sound-down: 0x77\n"
+" sound-up: 0x73\n"
+"\n", f );
+ }
+
+
+//-----------------------------------------------------------------------------
+// Print a summary of the various files and directories which are related to
+// key mappings.
+//-----------------------------------------------------------------------------
+static void print_files_info( FILE* f )
+ {
+ fputs(
+"This is a summary of the various files and directories which are related to\n"
+"key mappings.\n"
+"\n"
+"*.keymapping\n"
+" A key mapping file which precisely defines the relationship of all\n"
+" hardware-specific keyboard scan-codes with their associated\n"
+" functionality.\n"
+"\n"
+"*.keyboard\n"
+" A file describing the physical layout of keys on a particular type of\n"
+" keyboard. Each `key' token in this file defines the position and shape\n"
+" of the key on the keyboard, as well as the associated scan code which\n"
+" that key generates. A .keymapping file, on the other hand, defines the\n"
+" characters which are generated by a particular scan code depending upon\n"
+" the state of the various modifier keys (such as shift, control, etc.).\n"
+" The `interface' and `handler_id' values from a .keymapping file are\n"
+" matched against those in each .keyboard file in order to associate a\n"
+" particular .keyboard file with a key mapping. Various GUI programs use\n"
+" the .keyboard file to display a visual representation of a keyboard for\n"
+" the user. Since these files are just plain text, they can be easily\n"
+" viewed and interpreted without the aid of a specialized program, thus\n"
+" dumpkeymap leaves these files alone.\n"
+"\n"
+"/System/Library/Keyboards\n"
+"/Network/Library/Keyboards\n"
+"/Local/Library/Keyboards\n"
+"/Library/Keyboards\n"
+" Repositories for .keymapping and .keyboard files for MacOS/X, Darwin,\n"
+" and MacOS/X Server.\n"
+"\n"
+"/NextLibrary/Keyboards\n"
+"/LocalLibrary/Keyboards\n"
+" Repositories for .keymapping and .keyboard files for OpenStep and\n"
+" NextStep.\n"
+"\n"
+"$(HOME)/Library/Keyboards\n"
+" Repository for personal .keymapping and .keyboard files.\n"
+"\n", f );
+ }
+
+
+//-----------------------------------------------------------------------------
+// Print a list of the various diagnostic messages which may be emitted.
+//-----------------------------------------------------------------------------
+static void print_diagnostics_info( FILE* f )
+ {
+ fputs(
+"The following diagnostic messages may be issued to the standard error\n"
+"stream.\n"
+"\n"
+"Unrecognized option.\n"
+" An unrecognized option was specified on the command-line. Invoke\n"
+" dumpkeymap with the --help option to view a list of valid options.\n"
+"\n"
+"Insufficient data in keymapping data stream.\n"
+" The key mapping file or data stream is corrupt. Either the file has\n"
+" been incorrectly truncated or a field, such as those which indicates\n"
+" the number of variable records which follow, contains a corrupt value.\n"
+"\n"
+"The following diagnostic messages have significance only when trying to\n"
+"print .keymapping files mentioned on the command-line.\n"
+"\n"
+"Bad magic number.\n"
+" The mentioned file is not a .keymapping file. The file's content does\n"
+" not start with the string `KYM1'.\n"
+"\n"
+"Unable to open key mapping file.\n"
+" The call to fopen() failed; probably because the specified path is\n"
+" invalid or dumpkeymap does not have permission to read the file.\n"
+"\n"
+"Unable to determine key mapping file size.\n"
+" The call to fstat() failed, thus memory can not be allocated for\n"
+" loading the file.\n"
+"\n"
+"Unable to read key mapping file.\n"
+" The call to fread() failed.\n"
+"\n"
+"The following diagnostic messages have significance only when trying to\n"
+"print the currently active key mapping when no .keymapping files have been\n"
+"mentioned on the command-line.\n"
+"\n"
+"Unable to open event status driver.\n"
+" The call to NXOpenEventStatus() failed.\n"
+"\n"
+"Bad key mapping length.\n"
+" The call to NXKeyMappingLength() returned a bogus value.\n"
+"\n"
+"Unable to get current key mapping.\n"
+" The call to NXGetKeyMapping() failed.\n"
+"\n"
+"The following diagnostic messages have significance only when using\n"
+"dumpkeymap on a non-Apple/NeXT platform.\n"
+"\n"
+"Must specify at least one .keymapping file.\n"
+" No .keymapping files were mentioned on the command-line. On\n"
+" non-Apple/NeXT platforms, there is no concept of a currently active\n"
+" .keymapping file, so at least one file must be mentioned on the\n"
+" command-line.\n"
+"\n", f );
+ }
+
+
+//-----------------------------------------------------------------------------
+// Print warranty.
+//-----------------------------------------------------------------------------
+static void print_warranty( FILE* f )
+ {
+ fputs(
+"This software is provided by the author `AS IS' and any express or implied\n"
+"WARRANTIES, including, but not limited to, the implied warranties of\n"
+"MERCHANTABILITY and FITNESS FOR A PARTICULAR PURPOSE are DISCLAIMED. In NO\n"
+"EVENT shall the author be LIABLE for any DIRECT, INDIRECT, INCIDENTAL,\n"
+"SPECIAL, EXEMPLARY, or CONSEQUENTIAL damages (including, but not limited\n"
+"to, procurement of substitute goods or services; loss of use, data, or\n"
+"profits; or business interruption) however caused and on any theory of\n"
+"liability, whether in contract, strict liability, or tort (including\n"
+"negligence or otherwise) arising in any way out of the use of this\n"
+"software, even if advised of the possibility of such damage.\n"
+"\n", f );
+ }
+
+
+//-----------------------------------------------------------------------------
+// Print this program's version number.
+//-----------------------------------------------------------------------------
+static void print_version( FILE* f )
+ {
+ fputs( "Version " PROG_VERSION " (built " __DATE__ ")\n\n", f );
+ }
+
+
+//-----------------------------------------------------------------------------
+// Print a usage summary.
+//-----------------------------------------------------------------------------
+static void print_usage( FILE* f )
+ {
+ fputs(
+"Usage: dumpkeymap [options] [-] [file ...]\n"
+"\n"
+"Prints a textual representation of each Apple/NeXT .keymapping file\n"
+"mentioned on the command-line. If no files are mentioned and if the local\n"
+"machine is an Apple or NeXT installation, then the key mapping currently in\n"
+"use by the WindowServer and the AppKit is printed instead.\n"
+"\n"
+"Options:\n"
+" -h --help\n"
+" Display general program instructions and option summary.\n"
+"\n"
+" -k --help-keymapping\n"
+" Display a detailed description of the internal layout of a\n"
+" .keymapping file.\n"
+"\n"
+" -o --help-output\n"
+" Display an explanation of the output generated by dumpkeymap when\n"
+" dissecting a .keymapping file.\n"
+"\n"
+" -f --help-files\n"
+" Display a summary of the various files and directories which are\n"
+" related to key mappings.\n"
+"\n"
+" -d --help-diagnostics\n"
+" Display a list of the various diagnostic messages which may be\n"
+" emitted by dumpkeymap.\n"
+"\n"
+" -v --version\n"
+" Display the dumpkeymap version number and warranty information.\n"
+"\n"
+" - --\n"
+" Inhibit processing of options at this point in the argument list.\n"
+" An occurrence of `-' or `--' in the argument list causes all\n"
+" following arguments to be treated as file names even if an argument\n"
+" begins with a `-' character.\n"
+"\n", f );
+ }
+
+
+//-----------------------------------------------------------------------------
+// Print an informational banner.
+//-----------------------------------------------------------------------------
+static void print_banner( FILE* f )
+ {
+ fputs( "\n" PROG_NAME " v" PROG_VERSION " by " AUTHOR_INFO "\n"
+ COPYRIGHT "\n\n", f );
+ }
+
+
+//-----------------------------------------------------------------------------
+// Process command-line arguments. Examine options first; collecting files
+// along the way. If all is well, process collected file list.
+//-----------------------------------------------------------------------------
+int main( int const argc, char const* const argv[] )
+ {
+ int rc = 0, i, nfiles = 0, more_options = 1, process_files = 1;
+ int* files = (int*)calloc( argc - 1, sizeof(int) );
+ print_banner( stdout );
+
+ for (i = 1; i < argc; i++)
+ {
+ char const* const s = argv[i];
+ if (!more_options || *s != '-')
+ files[ nfiles++ ] = i;
+ else
+ {
+ OPT_SWITCH(s)
+ OPT_CASE(-,--)
+ more_options = 0;
+ OPT_CASE(-h,--help)
+ print_usage( stdout );
+ process_files = 0;
+ OPT_CASE(-k,--help-keymapping)
+ print_internal_layout_info( stdout );
+ process_files = 0;
+ OPT_CASE(-o,--help-output)
+ print_output_info( stdout );
+ process_files = 0;
+ OPT_CASE(-f,--help-files)
+ print_files_info( stdout );
+ process_files = 0;
+ OPT_CASE(-d,--help-diagnostics)
+ print_diagnostics_info( stdout );
+ process_files = 0;
+ OPT_CASE(-v,--version)
+ print_version( stdout );
+ print_warranty( stdout );
+ process_files = 0;
+ OPT_DEFAULT
+ fprintf( stderr, "ERROR: Unrecognized option: %s\n\n", s );
+ process_files = 0;
+ rc = 1;
+ OPT_SWITCH_END
+ }
+ }
+
+ if (process_files)
+ {
+ if (nfiles == 0)
+ rc = handle_empty_document_list();
+ else
+ for (i = 0; i < nfiles; i++)
+ rc |= unparse_keymap_file( argv[files[i]] );
+ }
+
+ free( files );
+ return rc;
+ }
diff --git a/nx-X11/programs/Xserver/hw/darwin/utils/dumpkeymap.man b/nx-X11/programs/Xserver/hw/darwin/utils/dumpkeymap.man
new file mode 100644
index 000000000..12983bada
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/darwin/utils/dumpkeymap.man
@@ -0,0 +1,1004 @@
+.ig
+//=============================================================================
+//
+// Manual page for `dumpkeymap'.
+//
+// Copyright (C) 1999,2000 by Eric Sunshine <sunshine@sunshineco.com>
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// 3. The name of the author may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//=============================================================================
+//
+// $XFree86$
+//
+..
+.ig
+//-----------------------------------------------------------------------------
+// Local identification information.
+//-----------------------------------------------------------------------------
+..
+.nr VE 4 \" Version number
+.TH DUMPKEYMAP 1 "v\n(VE \-\- 1 December 2000" "Version \n(VE"
+.de UP
+1 December 2000
+..
+.ig
+//-----------------------------------------------------------------------------
+// Annotation Macros
+// -----------------
+// Facilitate creation of annotated, non-filled blocks of text. An
+// annotated block is initiated with the `AS' macro. Each annotated,
+// non-filled line within the block must be introduced with the `AN' macro
+// which takes three arguments. The first argument is the detail text to
+// be annotated. The second is a string of spaces used to align the
+// annotations by certain (broken) roff interpreters which fail to
+// implement the proper set of roff commands (such as diversions,
+// indentation, and tab stops). It is assumed that the spaces will be
+// used with fixed-point font. The third argument is the annotation
+// itself. The block should be terminated with the `AE' macro. For all
+// roff interpreters which properly implement diversions, indentation, and
+// tab stops, all anotations within the block are automatically aligned at
+// the same horizontal position. This position is guaranteed to be just
+// to the right of the widest `AN' detail line. For broken roff
+// interpreters, such as `rman', the string of spaces from the second
+// argument are used to align the annotations. Finally, the `AZ' macro,
+// which takes a single argument, can be used to to insert a non-annotated
+// line into the block which does not play a part in the calculation of
+// the horizontal annotation alignment.
+//
+// Implementation Notes
+// --------------------
+// *1* These macros utilize a diversion (named `AD'). Since the prevailing
+// indentation is stored along with the diverted text, we must muck with
+// the indentation level in order to prevent the indentation from being
+// applied to the text a second time when `AD' is finally emitted.
+//
+// *2* Unfortunately, `.if' strips leading whitespace from following text, so
+// `AN' uses \& to preserve the whitespace.
+//
+// *3* This manual page has been tested for proper formatting with troff,
+// groff, nroff and rman (the `man' to `HTML' converter). Unfortunately,
+// rman fails to implement many useful features such as diversions,
+// indentation, and tab stops, and is also hideously buggy. Furthermore
+// it identifies itself as nroff and fails to provide any further
+// identification, so there is no way to create macros which specifically
+// work around its limitations. Following is a list of several bugs in
+// rman which the implementation of these macros must avoid:
+// o Fails with multi-line conditionals within macros.
+// o Fails on macro definition within multi-line conditionals.
+// o Fails when macro arguments are not delimited by exactly 1 space.
+// o String definition `.ds' ignores the value; uses empty "" instead.
+// As a consequence of these problems, the following macros are written
+// using a series of ugly single-line `.if' conditionals rather than the
+// more natural multi-line `.if' and `.ie' conditionals. Also, rman fails
+// to understand the common idiom of `.\"' to introduce a comment, which
+// is why all comments in this file are wrapped in ignore `.ig' blocks.
+//-----------------------------------------------------------------------------
+..
+.de AS
+.if t .nr AW 0
+.if t .nr AI \\n(.i
+.if t .in -\\n(AI
+.nf
+..
+.de AN
+.if t .if \w'\\$1'>\\n(AW .nr AW \w'\\$1'
+.if t .da AD
+.if t \\&\\$1\\t\\$3
+.if t .da
+.if n \\&\\$1 \\$2\\$3
+..
+.de AZ
+.if t .da AD
+\\$1
+.if t .da
+..
+.de AE
+.if t .in +\\n(AIu
+.if t .if \\n(AW .ta \\n(AWu+\w'\\(em'u
+.if t .AD
+.if t .DT
+.if t .rm AD
+.if t .rm AW
+.fi
+..
+.ig
+//-----------------------------------------------------------------------------
+// Bulleted list macros -- `BG' begins a bulleted list; `BU' delimits
+// bulleted entries; `BE' ends a bulleted list.
+//-----------------------------------------------------------------------------
+..
+.de BG
+.PP
+.RS
+..
+.de BU
+.HP
+\\(bu\\ \\c
+..
+.de BE
+.RE
+.PP
+..
+.ig
+//-----------------------------------------------------------------------------
+// Indented paragraph with stylized hanging tag macro. `TG' takes a single
+// argument and treats it as the hanging tag of the indented paragraph.
+// The tag is italicized in troff but not in nroff.
+//-----------------------------------------------------------------------------
+..
+.de TG
+.TP
+.ie t .I "\\$1"
+.el \\$1
+..
+.ig
+//-----------------------------------------------------------------------------
+// Manual page for `dumpkeymap'.
+//-----------------------------------------------------------------------------
+..
+.SH NAME
+dumpkeymap \- Dianostic dump of a .keymapping file
+.SH SYNOPSIS
+.B dumpkeymap
+.RI [ options "] [-] [" file "...]"
+.SH DESCRIPTION
+.I dumpkeymap
+prints a textual representation of each Apple/\c
+.SM NeXT
+.I .keymapping
+file mentioned on the command-line. If no files are mentioned and if the
+local machine is an Apple or
+.SM NeXT
+installation, then the key mapping currently in use by the WindowServer and the
+AppKit is printed instead.
+.SH OPTIONS
+.TP
+.B "\-h \-\^\-help"
+Display general program instructions and option summary.
+.TP
+.B "\-k \-\^\-help\-keymapping"
+Display a detailed description of the internal layout of a
+.I .keymapping
+file. This is the same information as that presented in the
+.I "Key Mapping Description"
+section of this document.
+.TP
+.B "\-o \-\^\-help\-output"
+Display an explanation of the output generated by
+.I dumpkeymap
+when dissecting a
+.I .keymapping
+file. This is the same information as that presented in the
+.I "Output Description"
+section of this document.
+.TP
+.B "\-f \-\^\-help\-files"
+Display a summary of the various files and directories which are related to
+key mappings. This is the same information as that presented in the
+.I "Files"
+section of this document.
+.TP
+.B "\-d \-\^\-help\-diagnostics"
+Display a list of the various diagnostic messages which may be emitted by
+.I dumpkeymap.
+This is the same information as that presented in the
+.I "Diagnostics"
+section of this document.
+.TP
+.B "\-v \-\^\-version"
+Display the
+.I dumpkeymap
+version number and warranty information.
+.TP
+.B "\- \-\^\-"
+Inhibit processing of options at this point in the argument list. An
+occurrence of `\-' or `\-\^\-' in the argument list causes all following
+arguments to be treated as file names even if an argument begins with a `\-'
+character.
+.SH "KEY MAPPING DESCRIPTION"
+The following sections describe, in complete detail, the format of a raw key
+mapping resource, as well as the format of the
+.I .keymapping
+file which encapsulates one or more raw mappings.
+.SH "Types and Data"
+The following type definitions are employed throughout this discussion:
+.PP
+.RS
+.AS
+.AZ "typedef unsigned char byte;"
+.AZ "typedef unsigned short word;"
+.AZ "typedef unsigned long dword;"
+.AE
+.RE
+.PP
+Additionally, the type definition
+.RI ` number '
+is used generically to
+indicate a numeric value. The actual size of the
+.RI ` number '
+type may be one or two bytes depending upon how the data is stored in the key
+map. Although most key maps use byte-sized numeric values, word-sized values
+are also allowed.
+.PP
+Multi-byte values in a key mapping file are stored in big-endian byte order.
+.SH "Key Mapping File and Device Mapping"
+A key mapping file begins with a magic-number and continues with a
+variable number of device-specific key mappings.
+.PP
+.RS
+.AS
+.AZ "struct KeyMappingFile {"
+.AN " char magic_number[4];" " " "// `KYM1'"
+.AN " DeviceMapping maps[...];" "" "// Variable number of maps"
+.AZ };
+.AE
+.PP
+.AS
+.AZ "struct DeviceMapping {"
+.AN " dword interface;" " " "// Interface type"
+.AN " dword handler_id;" "" "// Interface subtype"
+.AN " dword map_size;" " " "// Byte count of `map' (below)"
+.AN " KeyMapping map;"
+.AZ };
+.AE
+.RE
+.PP
+The value of `interface' represents a family of keyboard device types
+(such as Intel
+.SM "PC, ADB, NeXT,"
+Sun Type5, etc.), and is generally specified as one of the constant values
+.SM "NX_EVS_DEVICE_INTERFACE_ADB, NX_EVS_DEVICE_INTERFACE_ACE,"
+etc., which are are defined in IOHIDTypes.h on MacOS/X and Darwin, and in
+ev_types.h on MacOS/X Server, OpenStep, and NextStep.
+.PP
+The value of `handler_id' represents a specific keyboard layout within the
+much broader `interface' family. For instance, for a 101-key Intel
+.SM PC
+keyboard (of type
+.SM NX_EVS_DEVICE_INTERFACE_ACE\c
+) the `handler_id' is '0', whereas for a 102-key keyboard it is `1'.
+.PP
+Together, `interface' and `handler_id' identify the exact keyboard hardware to
+which this mapping applies. Programs which display a visual representation of
+a keyboard layout, match `interface' and `handler_id' from the
+.I .keymapping
+file against the `interface' and `handler_id' values found in each
+.I .keyboard
+file.
+.SH "Key Mapping"
+A key mapping completely defines the relationship of all scan codes with their
+associated functionality. A
+.I KeyMapping
+structure is embedded within the
+.I DeviceMapping
+structure in a
+.IR KeyMappingFile .
+The key mapping currently in use by the WindowServer and AppKit is also
+represented by a
+.I KeyMapping
+structure, and can be referred to directly by calling NXGetKeyMapping() and
+accessing the `mapping' data member of the returned
+.I NXKeyMapping
+structure.
+.PP
+.RS
+.AS
+.AZ "struct KeyMapping {"
+.AN " word number_size;" " " "// 0=1 byte, non-zero=2 bytes"
+.AN " number num_modifier_groups;" "" "// Modifier groups"
+.AZ " ModifierGroup modifier_groups[...];"
+.AN " number num_scan_codes;" " " "// Scan groups"
+.AN " ScanGroup scan_table[...];"
+.AN " number num_sequence_lists;" " " "// Sequence lists"
+.AN " Sequence sequence_lists[...];"
+.AN " number num_special_keys;" " " "// Special keys"
+.AN " SpecialKey special_key[...];"
+.AZ };
+.AE
+.RE
+.PP
+The `number_size' flag determines the size, in bytes, of all remaining numeric
+values (denoted by the type definition
+.RI ` number ')
+within the
+key mapping. If its value is zero, then numbers are represented by a single
+byte. If it is non-zero, then numbers are represented by a word (two bytes).
+.SH "Modifier Group"
+A modifier group defines all scan codes which map to a particular type of
+modifier, such as
+.IR shift ,
+.IR control ,
+etc.
+.PP
+.RS
+.AS
+.AZ "enum Modifier {"
+.AZ " ALPHALOCK = 0,"
+.AZ " SHIFT,"
+.AZ " CONTROL,"
+.AZ " ALTERNATE,"
+.AZ " COMMAND,"
+.AZ " KEYPAD,"
+.AZ " HELP"
+.AZ };
+.AE
+.PP
+.AS
+.AZ "struct ModifierGroup {"
+.AN " number modifier;" " " "// A Modifier constant"
+.AN " number num_scan_codes;"
+.AN " number scan_codes[...];" "" "// Variable number of scan codes"
+.AZ };
+.AE
+.RE
+.PP
+The scan_codes[] array contains a list of all scan codes which map to the
+specified modifier. The
+.IR shift ", " command ", and " alternate
+modifiers are frequently mapped to two different scan codes, apiece,
+since these modifiers often appear on both the left and right sides of
+the keyboard.
+.SH "Scan Group"
+There is one
+.I ScanGroup
+for each scan code generated by the given keyboard. This number is given by
+KeyMapping::num_scan_codes. The first scan group represents hardware scan
+code 0, the second represents scan code 1, etc.
+.PP
+.RS
+.AS
+.AZ "enum ModifierMask {"
+.AN " ALPHALOCK_MASK" " " "= 1 << 0,"
+.AN " SHIFT_MASK" " " "= 1 << 1,"
+.AN " CONTROL_MASK" " " "= 1 << 2,"
+.AN " ALTERNATE_MASK" " " "= 1 << 3,"
+.AN " CARRIAGE_RETURN_MASK" "" "= 1 << 4"
+.AZ };
+.AZ "#define NOT_BOUND 0xff"
+.AE
+.PP
+.AS
+.AZ "struct ScanGroup {"
+.AN " number mask;"
+.AN " Character characters[...];"
+.AZ };
+.AE
+.RE
+.PP
+For each scan code, `mask' defines which modifier combinations generate
+characters. If `mask' is
+.SM NOT_BOUND
+(0xff) then then this scan code does not generate any characters ever, and its
+characters[] array is zero length. Otherwise, the characters[] array contains
+one
+.I Character
+record for each modifier combination.
+.PP
+The number of records in characters[] is determined by computing (1 <<
+bits_set_in_mask). In other words, if mask is zero, then zero bits are set,
+so characters[] contains only one record. If `mask' is
+.SM "(SHIFT_MASK | CONTROL_MASK),"
+then two bits are set, so characters[] contains four records.
+.PP
+The first record always represents the character which is generated by that
+key when no modifiers are active. The remaining records represent characters
+generated by the various modifier combinations. Using the example with the
+.I shift
+and
+.I control
+masks set, record two would represent the character with the
+.I shift
+modifier active; record three, the
+.I control
+modifier active; and record four, both the
+.I shift
+and
+.I control
+modifiers active.
+.PP
+As a special case,
+.SM ALPHALOCK_MASK
+implies
+.SM SHIFT_MASK,
+though only
+.SM ALPHALOCK_MASK
+appears in `mask'. In this case the same character is generated for both the
+.I shift
+and
+.I alpha-lock
+modifiers, but only needs to appear once in the characters[] array.
+.PP
+.SM CARRIAGE_RETURN_MASK
+does not actually refer to a modifier key. Instead, it is used to
+distinguish the scan code which is given the special pseudo-designation of
+.I "carriage return"
+key. Typically, this mask appears solo in a
+.I ScanGroup
+record and only the two
+.I Character
+records for control-M and control-C follow. This flag may be a throwback to
+an earlier time or may be specially interpreted by the low-level keyboard
+driver, but its purpose is otherwise enigmatic.
+.SH Character
+Each
+.I Character
+record indicates the character generated when this key is pressed, as well as
+the character set which contains the character. Well known character sets are
+.SM `ASCII'
+and `Symbol'. The character set can also be one of the meta values
+.SM FUNCTION_KEY
+or
+.SM KEY_SEQUENCE.
+If it is
+.SM FUNCTION_KEY
+then `char_code' represents a generally well-known function key such as those
+enumerated by
+.I FunctionKey.
+If the character set is
+.SM KEY_SEQUENCE
+then `char_code' represents is a zero-base index into
+KeyMapping::sequence_lists[].
+.PP
+.RS
+.AS
+.AZ "enum CharacterSet {"
+.AN " ASCII" " " "= 0x00,"
+.AN " SYMBOL" " " "= 0x01,"
+.AN " ..."
+.AN " FUNCTION_KEY" "" "= 0xfe,"
+.AN " KEY_SEQUENCE" "" "= 0xff"
+.AZ };
+.AE
+.PP
+.AS
+.AZ "struct Character {"
+.AN " number set;" " " "// CharacterSet of generated character"
+.AN " number char_code;" "" "// Actual character generated"
+.AZ };
+.AE
+.PP
+.AS
+.AZ "enum FunctionKey {"
+.AZ " F1 = 0x20, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,"
+.AZ " INSERT, DELETE, HOME, END, PAGE_UP, PAGE_DOWN, PRINT_SCREEN,"
+.AZ " SCROLL_LOCK, PAUSE, SYS_REQUEST, BREAK, RESET, STOP, MENU,"
+.AZ " USER, SYSTEM, PRINT, CLEAR_LINE, CLEAR_DISPLAY, INSERT_LINE,"
+.AZ " DELETE_LINE, INSERT_CHAR, DELETE_CHAR, PREV, NEXT, SELECT"
+.AZ };
+.AE
+.RE
+.SH Sequence
+When Character::set contains the meta value
+.SM KEY_SEQUENCE,
+the scan code is bound to a sequence of keys rather than a single character.
+A sequence is a series of modifiers and characters which are automatically
+generated when the associated key is depressed.
+.PP
+.RS
+.AS
+.AZ "#define MODIFIER_KEY 0xff"
+.AE
+.PP
+.AS
+.AZ "struct Sequence {"
+.AN " number num_chars;"
+.AN " Character characters[...];"
+.AZ };
+.AE
+.RE
+.PP
+Each generated
+.I Character
+is represented as previously described, with the exception that
+.SM MODIFIER_KEY
+may appear in place of
+.SM KEY_SEQUENCE.
+When the value of Character::set is
+.SM MODIFIER_KEY
+then Character::char_code represents a modifier key rather than an actual
+character. If the modifier represented by `char_code' is non-zero, then it
+indicates that the associated modifier key has been depressed. In this case,
+the value is one of the constants enumerated by
+.I Modifier
+(\c
+.SM "SHIFT, CONTROL, ALTERNATE,"
+etc.). If the value is zero then it means that the modifier keys have been
+released.
+.SH "Special Key"
+A special key is one which is scanned directly by the Mach kernel rather than
+by the WindowServer. In general, events are not generated for special keys.
+.PP
+.RS
+.AS
+.AZ "enum SpecialKeyType {"
+.AZ " VOLUME_UP = 0,"
+.AZ " VOLUME_DOWN,"
+.AZ " BRIGHTNESS_UP,"
+.AZ " BRIGHTNESS_DOWN,"
+.AZ " ALPHA_LOCK,"
+.AZ " HELP,"
+.AZ " POWER,"
+.AZ " SECONDARY_ARROW_UP,"
+.AZ " SECONDARY_ARROW_DOWN"
+.AZ };
+.AE
+.PP
+.AS
+.AZ "struct SpecialKey {"
+.AN " number type;" " " "// A SpecialKeyType constant"
+.AN " number scan_code;" "" "// Actual scan code"
+.AZ };
+.AE
+.RE
+.SH OUTPUT
+What follows is an explanation and description of the various pieces of
+information emitted by
+.I dumpkeymap.
+.PP
+For a more thorough discussion of any particular piece of information described
+here, refer to the detailed description of the internal layout of a key mapping
+provided by the
+.I "Key Mapping Description"
+section above.
+.SH Conventions
+Depending upon context, some numeric values are displayed in decimal
+notation, whereas others are displayed in hexadecimal notation.
+Hexadecimal numbers are denoted by a `0x' prefix (for instance, `0x7b'),
+except when explicitly noted otherwise.
+.SH "Key Mapping Source"
+The first piece of information presented about a particular key mapping is the
+source from which the data was gleaned. For a
+.I .keymapping
+file, the title
+.SM "`KEYMAP FILE'"
+is emitted along with the path and name of the file in question. For the key
+mapping currently in use by the WindowServer and AppKit, the title
+.SM "`ACTIVE KEYMAP'"
+is emitted instead.
+.SH "Device Information"
+Each
+.I .keymapping
+file may contain one or more raw key mappings. For example, a file which maps
+keys to a Dvorak-style layout might contain raw mappings for Intel
+.SM "PC, ADB, NeXT,"
+and Sun Type5 keyboards.
+.PP
+For each raw mapping, the following information is emitted:
+.BG
+.BU
+The title
+.SM `KEYMAP'
+along with the mapping's relative position in the
+.I .keymapping
+file.
+.BU
+The `interface' identifier.
+.BU
+The `handler_id' sub-identifier.
+.BU
+The size of the raw mapping resource counted in bytes.
+.BE
+The `interface' and `handler_id' values, taken together, define a specific
+keyboard device. A
+.I .keyboard
+file, which describes the visual layout of a keyboard, also contains
+`interface' and `handler_id' identifiers. The
+.I .keyboard
+file corresponding to a particular key mapping can be found by matching the
+`interface' and `handler_id' values from each resource.
+.SH Modifiers
+Each mapping may contain zero or more modifier records which associate hardware
+scan codes with modifier descriptions such as
+.I "shift, control, alternate,"
+etc. The title
+.SM `MODIFIERS'
+is printed along with the count of modifier records which follow. For each
+modifier record, the modifier's name is printed along with a list of scan
+codes, in hexadecimal format, which generate that modifier value. For example:
+.PP
+.RS
+.nf
+MODIFIERS [4]
+alternate: 0x1d 0x60
+control: 0x3a
+keypad: 0x52 0x53 ... 0x63 0x62
+shift: 0x2a 0x36
+.fi
+.RE
+.SH Characters
+Each mapping may contain zero or more character records which associate
+hardware scan codes with the actual characters generated by those scan
+codes in the presence or absence of various modifier combinations. The
+title
+.SM `CHARACTERS'
+is printed along with the count of character records which follow. Here is a
+highly abbreviated example:
+.PP
+.RS
+.nf
+CHARACTERS [9]
+scan 0x00: -AC-L "a" "A" "^A" "^A" ca c7 "^A" "^A"
+scan 0x07: -AC-L "x" "X" "^X" "^X" 01/b4 01/ce "^X" "^X"
+scan 0x0a: ---S- "<" ">"
+scan 0x13: -ACS- "2" "@" "^@" "^@" b2 b3 "^@" "^@"
+scan 0x24: R---- "^M" "^C"
+scan 0x3e: ----- [F4]
+scan 0x4a: ----- [page up]
+scan 0x60: ----- {seq#3}
+scan 0x68: not-bound
+.fi
+.RE
+.PP
+For each record, the hexadecimal value of the hardware scan code is printed,
+followed by a list of modifier flag combinations and the actual characters
+generated by this scan code with and without modifiers applied.
+.PP
+The modifier flags field is composed of a combination of single letter
+representations of the various modifier types. The letters stand for:
+.PP
+.RS
+.nf
+L \- alpha-lock
+S \- shift
+C \- control
+A \- alternate
+R \- carriage-return
+.fi
+.RE
+.PP
+As a special case, the
+.I alpha-lock
+flag also implies the
+.I shift
+flag, so these two flags never appear together in the same record.
+.PP
+The combination of modifier flags determines the meaning and number of fields
+which follow. The first field after the modifier flags always represents the
+character that will be generated if no modifier keys are depressed. The
+remaining fields represent characters generated by the various modifier
+combinations. The order of the fields follows this general pattern:
+.BG
+.BU
+The character generated by this scan code when no modifiers are in effect is
+listed first.
+.BU
+If the `L' or `S' flag is active, then the shifted character generated by this
+scan code is listed next.
+.BU
+If the `C' flag is active, then the control-character generated by this scan
+code is listed next. Furthermore, if the `L' or `S' flag is also active, then
+the shifted control-character is listed after that.
+.BU
+If the `A' flag is active, then the alternate-character generated by this scan
+code is listed next. Furthermore, if the `L' or `S' flag is active, then the
+shifted alternate-character is listed after that. If the `C' flag is also
+active, then the alternate-control-character is listed next. Finally, if the
+`C' and `L' or `C' and `S' flags are also active, then the shifted
+alternate-control-character is listed.
+.BE
+The `R' flag does not actually refer to a modifier key. Instead, it is used to
+distinguish the scan code which is given the special pseudo-designation of
+.I "carriage return"
+key. Typically, this mask appears solo and only the two fields for control-M
+and control-C follow. This flag may be a throwback to an earlier time or may
+be specially interpreted by the low-level keyboard driver, but its purpose is
+otherwise enigmatic.
+.PP
+Recalling the example from above, the following fields can be identified:
+.PP
+.RS
+.nf
+scan 0x00: -AC-L "a" "A" "^A" "^A" ca c7 "^A" "^A"
+.fi
+.RE
+.BG
+.BU
+Lower-case `a' is generated when no modifiers are active.
+.BU
+Upper-case `A' is generated when
+.IR shift " or " alpha-lock
+are active.
+.BU
+Control-A is generated when
+.I control
+is active.
+.BU
+Control-A is generated when
+.IR control " and " shift
+are active.
+.BU
+The character represented by the hexadecimal code 0xca is generated when
+.I alternate
+is active.
+.BU
+The character represented by 0xc7 is generated when
+.IR alternate " and " shift " (or " alpha-lock ") are active."
+.BU
+Control-A is generated when
+.IR alternate " and " control
+are active.
+.BU
+Control-A is generated when
+.IR "alternate, control" " and " shift " (or " alpha-lock ") are active."
+.BE
+The notation used to represent a particular generated character varies.
+.BG
+.BU
+Printable
+.SM ASCII
+characters are quoted, as in "x" or "X".
+.BU
+Control-characters are quoted and prefixed with `^', as in "^X".
+.BU
+Characters with values greater than 127 (0x7f) are displayed as hexadecimal
+values without the `0x' prefix.
+.BU
+Characters in a non-\c
+.SM ASCII
+character set (such as `Symbol') are displayed as two hexadecimal numbers
+separated by a slash, as in `01/4a'. The first number is the character set's
+identification code (such as `01' for the `Symbol' set), and the second number
+is the value of the generated character.
+.BU
+Non-printing special function characters are displayed with the function's
+common name enclosed in brackets, as in `[page up]' or `[F4]'.
+.BU
+If the binding represents a key sequence rather than a single character, then
+the sequence's identification number is enclosed in braces, as in `{seq#3}'.
+.BE
+Recalling a few examples from above, the following interpretations can be made:
+.PP
+.RS
+.nf
+scan 0x07: -AC-L "x" "X" "^X" "^X" 01/b4 01/ce "^X" "^X"
+scan 0x3e: ----- [F4]
+scan 0x4a: ----- [page up]
+scan 0x60: ----- {seq#3}
+.fi
+.RE
+.BG
+.BU
+"x" and "X" are printable
+.SM ASCII
+characters.
+.BU
+"^X" is a control-character.
+.BU
+`01/b4' and `01/ce' represent the character codes 0xb4 and 0xce in the `Symbol'
+character set.
+.BU
+Scan code 0x3e generates function-key `F4', and scan code 0x4a generates
+function-key `page up'.
+.BU
+Scan code 0x60 is bound to key sequence #3.
+.BE
+Finally, if a scan code is not bound to any characters, then it is annotated
+with the label `not-bound', as with example scan code 0x68 from above.
+.SH Sequences
+A scan code (modified and unmodified) can be bound to a key sequence rather
+than generating a single character or acting as a modifier. When it is bound
+to a key sequence, a series of character invocations and modifier actions are
+automatically generated rather than a single keystroke.
+.PP
+Each mapping may contain zero or more key sequence records. The title
+.SM `SEQUENCES'
+is printed along with the count of sequence records which follow. For example:
+.PP
+.RS
+.nf
+SEQUENCES [3]
+sequence 0: "f" "o" "o"
+sequence 1: {alternate} "b" "a" "r" {unmodify}
+sequence 2: [home] "b" "a" "z"
+.fi
+.RE
+.PP
+The notation used to represent the sequence of generated characters is
+identical to the notation already described in the
+.I Characters
+section above, with the exception that modifier actions may be interposed
+between generated characters. Such modifier actions are represented by the
+modifier's name enclosed in braces. The special name `{unmodify}' indicates
+the release of the modifier keys.
+.PP
+Thus, the sequences in the above example can be interpreted as follows:
+.BG
+.BU
+Sequence\ #0 generates `foo'.
+.BU
+Sequence\ #1 invokes the
+.I alternate
+modifier, generates `bar', and then releases
+.I alternate.
+.BU
+Sequence\ #2 invokes the
+.I home
+key and then generates `baz'. In a text editor, this would probably result in
+`baz' being prepended to the line of text on which the cursor resides.
+.BE
+.SH Special Keys
+Certain keyboards feature keys which perform some type of special purpose
+function rather than generating a character or acting as a modifier. For
+instance, Apple keyboards often contain a
+.I power
+key, and
+.SM NeXT
+keyboards have historically featured screen brightness and volume control keys.
+.PP
+Each mapping may contain zero or more special-key records which associate
+hardware scan codes with such special purpose functions. The title
+.SM `SPECIALS'
+is printed along with the count of records which follow. For each record, the
+special function's name is printed along with a list of scan codes, in
+hexadecimal format, which are bound to that function. For example:
+.PP
+.RS
+.nf
+SPECIALS [6]
+alpha-lock: 0x39
+brightness-down: 0x79
+brightness-up: 0x74
+power: 0x7f
+sound-down: 0x77
+sound-up: 0x73
+.fi
+.RE
+.SH FILES
+.IP *.keymapping
+A key mapping file which precisely defines the relationship of all
+hardware-specific keyboard scan-codes with their associated functionality.
+.IP *.keyboard
+A file describing the physical layout of keys on a particular type of
+keyboard. Each `key' token in this file defines the position and shape of the
+key on the keyboard, as well as the associated scan code which that key
+generates. A
+.I .keymapping
+file, on the other hand, defines the characters which are generated by a
+particular scan code depending upon the state of the various modifier keys
+(such as
+.I shift,
+.I control,
+etc.). The `interface' and `handler_id' values from a
+.I .keymapping
+file are matched against those in each
+.I .keyboard
+file in order to associate a particular
+.I .keyboard
+file with a key mapping. Various
+.SM GUI
+programs use the
+.I .keyboard
+file to display a visual representation of a keyboard for the user. Since
+these files are just plain text, they can be easily viewed and interpreted
+without the aid of a specialized program, thus
+.I dumpkeymap
+leaves these files alone.
+.PP
+/System/Library/Keyboards
+.br
+/Network/Library/Keyboards
+.br
+/Local/Library/Keyboards
+.br
+/Library/Keyboards
+.RS
+Repositories for
+.I .keymapping
+and
+.I .keyboard
+files for MacOS/X, Darwin, and MacOS/X Server.
+.RE
+.PP
+/NextLibrary/Keyboards
+.br
+/LocalLibrary/Keyboards
+.RS
+Repositories for
+.I .keymapping
+and
+.I .keyboard
+files for OpenStep and NextStep.
+.RE
+.IP $(HOME)/Library/Keyboards
+Repository for personal
+.I .keymapping
+and
+.I .keyboard
+files.
+.SH DIGANOSTICS
+The following diagnostic messages may be issued to the standard error stream.
+.TG "Unrecognized option."
+An unrecognized option was specified on the command-line. Invoke
+.I dumpkeymap
+with the
+.B "\-\^\-help"
+option to view a list of valid options.
+.TG "Insufficient data in keymapping data stream."
+The key mapping file or data stream is corrupt. Either the file has been
+incorrectly truncated or a field, such as those which indicates the number of
+variable records which follow, contains a corrupt value.
+.PP
+The following diagnostic messages have significance only when trying to print
+.I .keymapping
+files mentioned on the command-line.
+.TG "Bad magic number."
+The mentioned file is not a
+.I .keymapping
+file. The file's content does not start with the string `KYM1'.
+.TG "Unable to open key mapping file."
+The call to fopen() failed; probably because the specified path is invalid or
+.I dumpkeymap
+does not have permission to read the file.
+.TG "Unable to determine key mapping file size."
+The call to fstat() failed, thus memory can not be allocated for loading the
+file.
+.TG "Unable to read key mapping file."
+The call to fread() failed.
+.PP
+The following diagnostic messages have significance only when trying to print
+the currently active key mapping when no
+.I .keymapping
+files have been mentioned on the command-line.
+.TG "Unable to open event status driver."
+The call to NXOpenEventStatus() failed.
+.TG "Bad key mapping length."
+The call to NXKeyMappingLength() returned a bogus value.
+.TG "Unable to get current key mapping."
+The call to NXGetKeyMapping() failed.
+.PP
+The following diagnostic messages have significance only when using
+.I dumpkeymap
+on a non-Apple/\c
+.SM NeXT
+platform.
+.TG "Must specify at least one .keymapping file."
+No
+.I .keymapping
+files were mentioned on the command-line. On non-Apple/\c
+.SM NeXT
+platforms, there is no concept of a currently active
+.I .keymapping
+file, so at least one file must be mentioned on the command-line.
+.SH AUTHOR
+Eric Sunshine <sunshine@sunshineco.com> wrote
+.I dumpkeymap
+and this document, the
+.I "dumpkeymap user's manual."
+Both
+.I dumpkeymap
+and this document are copyright \(co1999,2000 by Eric Sunshine
+<sunshine@sunshineco.com>. All rights reserved.
+.PP
+The implementation of
+.I dumpkeymap
+is based upon information gathered on September 3, 1997 by Eric Sunshine
+<sunshine@sunshineco.com> and Paul S. McCarthy <zarnuk@zarnuk.com> during an
+effort to reverse engineer the format of the
+.SM NeXT
+.I .keymapping
+file.
+.if n .PP
+.if n Version \n(VE \-\-
+.if n .UP
diff --git a/nx-X11/programs/Xserver/hw/dmx/Imakefile b/nx-X11/programs/Xserver/hw/dmx/Imakefile
new file mode 100644
index 000000000..b8c16dd53
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/Imakefile
@@ -0,0 +1,125 @@
+XCOMM $XFree86$
+
+#include <Server.tmpl>
+
+#if BuildXinerama
+PANORAMIX_SRCS = panoramiX.c
+PANORAMIX_OBJS = panoramiX.o
+#endif
+
+#if BuildGlxExt
+GLX_SRCS = dmx_glxvisuals.c $(PANORAMIX_SRCS)
+GLX_OBJS = dmx_glxvisuals.o $(PANORAMIX_OBJS)
+DMX_GLX_DEFINES = $(GLX_DEFINES) -DGLXPROXY
+GLXPROXY_SUBDIR = glxProxy
+#endif
+
+#define IHaveSubdirs
+
+#if BuildServersOnly && !BuildDmxDevelTools
+SUBDIRS = input config $(GLXPROXY_SUBDIR)
+#else
+SUBDIRS = input config doc examples $(GLXPROXY_SUBDIR)
+#endif
+
+#if BuildRender
+RENDER_SRCS = dmxpict.c
+RENDER_OBJS = dmxpict.o
+#endif
+
+SRCS = dmxinit.c \
+ dmxscrinit.c \
+ dmxshadow.c \
+ dmxcursor.c \
+ dmxinput.c \
+ dmxdpms.c \
+ dmxgc.c \
+ dmxgcops.c \
+ dmxwindow.c \
+ dmxpixmap.c \
+ dmxfont.c \
+ dmxcmap.c \
+ dmxvisual.c \
+ dmxlog.c \
+ dmxcb.c \
+ dmxprop.c \
+ dmxstat.c \
+ dmxsync.c \
+ dmxextension.c \
+ miinitext.c \
+ $(GLX_SRCS) \
+ $(RENDER_SRCS)
+
+OBJS = dmxinit.o \
+ dmxscrinit.o \
+ dmxshadow.o \
+ dmxcursor.o \
+ dmxinput.o \
+ dmxdpms.o \
+ dmxgc.o \
+ dmxgcops.o \
+ dmxwindow.o \
+ dmxpixmap.o \
+ dmxfont.o \
+ dmxcmap.o \
+ dmxvisual.o \
+ dmxlog.o \
+ dmxcb.o \
+ dmxprop.o \
+ dmxstat.o \
+ dmxsync.o \
+ dmxextension.o \
+ miinitext.o \
+ $(GLX_OBJS) \
+ $(RENDER_OBJS)
+
+#include <dmx.cf>
+
+#ifdef XVendorString
+ VENDORSTRING = XVendorString
+ VENDOR_STRING = -DVENDOR_STRING=\"$(VENDORSTRING)\"
+#endif
+
+#ifdef XVendorRelease
+ VENDORRELEASE = XVendorRelease
+ VENDOR_RELEASE = -DVENDOR_RELEASE="$(VENDORRELEASE)"
+#endif
+
+VENDOR_DEFINES = $(VENDOR_STRING) $(VENDOR_RELEASE)
+
+ OSNAME = OSName
+ OSVENDOR = OSVendor
+OSNAME_DEFINES = -DOSNAME='"$(OSNAME)"' -DOSVENDOR='"$(OSVENDOR)"'
+
+INCLUDES = -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
+ -I../../mi -I../../include -I../../os \
+ -I../../fb -I../../miext/shadow -I../../render \
+ -I$(EXTINCSRC) -I$(XINCLUDESRC) -I$(SERVERSRC)/Xext
+
+DEFINES = $(OS_DEFINES) $(EXT_DEFINES) -DDMXEXT -DXTEST \
+ $(DMX_GLX_DEFINES) $(DMX_DEFINES) $(VENDOR_DEFINES) \
+ $(OSNAME_DEFINES)
+
+all:: $(OBJS)
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+
+LinkSourceFile(miinitext.c,$(SERVERSRC)/mi)
+SpecialCObjectRule(miinitext,$(ICONFIGFILES),-DDMXSERVER)
+
+#if BuildGlxExt
+LinkSourceFile(panoramiX.c,$(SERVERSRC)/Xext)
+#if HasGcc3
+SpecialCObjectRule(panoramiX,$(ICONFIGFILES),-Wno-missing-prototypes -Wno-strict-prototypes -Wno-missing-declarations -Wno-sign-compare)
+#else
+SpecialCObjectRule(panoramiX,$(ICONFIGFILES),$(_NOOP_))
+#endif
+#endif
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(dmx,$(OBJS))
+
+InstallManPage(Xdmx,$(MANDIR))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/dmx/Xdmx.man b/nx-X11/programs/Xserver/hw/dmx/Xdmx.man
new file mode 100644
index 000000000..9c8bdea00
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/Xdmx.man
@@ -0,0 +1,741 @@
+.\" $XFree86$
+.\"
+.\" Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+.\" All Rights Reserved.
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation on the rights to use, copy, modify, merge,
+.\" publish, distribute, sublicense, and/or sell copies of the Software,
+.\" and to permit persons to whom the Software is furnished to do so,
+.\" subject to the following conditions:
+.\"
+.\" he above copyright notice and this permission notice (including the
+.\" next paragraph) shall be included in all copies or substantial
+.\" portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+.\" NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+.\" BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+.\" ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+.\" CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+.\" SOFTWARE.
+.TH Xdmx 1 __vendorversion__
+.SH NAME
+Xdmx - Distributed Multi-head X server
+.SH SYNOPSIS
+.B Xdmx
+[:display] [option ...]
+.SH DESCRIPTION
+.I Xdmx
+is a proxy X server that uses one or more other X servers as its display
+devices. It provides multi-head X functionality for displays that might
+be located on different machines.
+.I Xdmx
+functions as a front-end X server that acts as a proxy to a set of
+back-end X servers. All of the visible rendering is passed to the
+back-end X servers. Clients connect to the
+.I Xdmx
+front-end, and everything appears as it would in a regular multi-head
+configuration. If Xinerama is enabled (e.g., with
+.B +xinerama
+on the command line), the clients see a single large screen.
+.PP
+.I Xdmx
+communicates to the back-end X servers using the standard X11 protocol,
+and standard and/or commonly available X server extensions.
+.SH OPTIONS
+In addition to the normal X server options described in the
+.I Xserver(1)
+manual page,
+.I Xdmx
+accepts the following command line switches:
+.TP 8
+.BI "\-display " display-name
+This specifies the name(s) of the back-end X server display(s) to connect
+to. This option may be specified multiple times to connect to more than
+one back-end display. The first is used as screen 0, the second as screen 1,
+etc. If this option is omitted, the
+.B $DISPLAY
+environment variable is used as the single back-end X server display.
+.sp
+.TP 8
+.BI "\-xinput " input-source
+This specifies the source to use for XInput extension devices. The
+choices are the same as for
+.BR "\-input " ,
+described below, except that core devices on backend servers cannot be
+treated as XInput extension devices. (Although extension devices on
+backend and console servers are supported as extension devices under
+.IR Xdmx ).
+.sp
+.TP 8
+.BI "\-input " input-source
+This specifies the source to use for the core input devices. The choices are:
+.RS
+.TP 4
+.B dummy
+A set of dummy core input drivers are used. These never generate any
+input events.
+.sp
+.TP 4
+.B local
+The raw keyboard and pointer from the local computer are used. A
+comma-separated list of driver names can be appended. For example, to
+select the example Linux keyboard and PS/2 mouse driver use:
+.BR "-input local,kbd,ps2" .
+The following drivers have been implemented for Linux: kbd, ms (a
+two-button Microsoft mouse driver), ps2 (a PS/2 mouse driver), usb-mou
+(a USB mouse driver), usb-kbd (a USB keyboard driver), and usb-oth (a
+USB non-keyboard, non-mouse driver). Additional drivers may be
+implemented in the future. Appropriate defaults will be used if no
+comma-separated list is provided.
+.sp
+.TP 4
+.I display-name
+If the display-name is a back-end server, then core input events are
+taken from the server specified. Otherwise, a console window will be
+opened on the specified display.
+.sp
+If the
+.I display-name
+is followed by ",xi" then XInput extension devices on the display will
+be used as
+.I Xdmx
+XInput extension devices. If the
+.I display-name
+is followed by ",noxi" then XInput extension devices on the display will
+.B not
+be used as
+.I Xdmx
+XInput extension devices. Currently, the default is ",xi".
+.sp
+If the
+.I display-name
+is followed by ",console" and the
+.I display-name
+refers to a display that is used as a backend display, then a console
+window will be opened on that display
+.B and
+that display will be treated as a backend display. Otherwise (or if
+",noconsole" is used), the display will be treated purely as a backend
+or a console display, as described above.
+.sp
+If the
+.I display-name
+is followed by ",windows", then outlines of the windows on the backend
+will be displayed inside the console window. Otherwise (or if
+",nowindows" is used), the console window will not display the outlines
+of backend windows. (This option only applies to console input.)
+.sp
+If the
+.I display-name
+is followed by ",xkb", then the next 1 to 3 comma-separated parameters
+will specify the keycodes, symbols, and geometry of the keyboard for
+this input device. For example, ",xkb,xfree86,pc104" will specify that
+the "xfree86" keycodes and the "pc104" symbols should be used to
+initialize the keyboard. For an SGI keyboard, ",xkb,sgi/indy(pc102)"
+might be useful. A list of keycodes, symbols, and geometries can be
+found in
+.IR /usr/X11R6/lib/X11/xkb .
+If this option is not specified, the input device will be queried,
+perhaps using the XKEYBOARD extension.
+.RE
+.sp
+.RS
+If this option isn't specified, the default input source is the first
+back-end server (the one used for screen 0). The console window shows
+the layout of the back-end display(s) and pointer movements and key
+presses within the console window will be used as core input devices.
+.sp
+Several special function keys are active, depending on the input
+source:
+.sp
+.RS
+.B Ctrl-Alt-q
+will terminate the
+.I Xdmx
+server in all modes.
+.sp
+.B Ctrl-Alt-g
+will toggle a
+server grab in console mode (a special cursor, currently a spider, is
+used to indicate an active server grab).
+.sp
+.B Ctrl-Alt-f
+will toggle fine-grain motion in console mode (a special cursor,
+currently a cross hair, is used to indicate this mode). If this mode is
+combined with a server grab, then the cursor will have 4 lines instead
+of only 2.
+.sp
+.BR Ctrl-Alt-F1 " through " Ctrl-Alt-F12
+will switch to another VC in local (raw) mode.
+.RE
+.RE
+.sp
+.TP 8
+.BI "-shadowfb"
+This option turns on (legacy) support for the shadow frame buffer.
+.sp
+.TP 8
+.BI "-noshadowfb"
+This option turns off (legacy) support for the shadow frame buffer.
+Note that this option has been deprecated and will be removed in the
+next release.
+.sp
+.TP 8
+.BI "-nomulticursor"
+This option turns off support for displaying multiple cursors on
+overlapped back-end displays. This option is available for testing and
+benchmarking purposes.
+.sp
+.TP 8
+.BI "-fontpath"
+This option sets the
+.I Xdmx
+server's default font path. This option can be specified multiple times
+to accommodate multiple font paths. See the
+.B "FONT PATHS"
+section below for very important information regarding setting the
+default font path.
+.sp
+.TP 8
+.BI "-configfile " filename
+Specify the configuration file that should be read. Note that if the
+.B \-display
+command-line option is used, then the configuration file will be
+ignored.
+.sp
+.TP 8
+.BI "-config " name
+Specify a configuration to use. The
+.I name
+will be the name following the
+.B virtual
+keyword in the configuration file.
+.sp
+.TP 8
+.BI "-stat " "interval screens"
+This option enables the display of performance statistics. The interval
+is in seconds. The screens is a count of the number of back-end screens
+for which data is printed each interval. Specifying 0 for screens will
+display data for all screens.
+.sp
+For each screen, the following information is printed: the screen
+number, an absolute count of the number of XSync() calls made
+(SyncCount), the rate of these calls during the previous interval
+(Sync/s), the average round-trip time (in microseconds) of the last 10
+XSync() calls (avSync), the maximum round-trip time (in microseconds) of
+the last 10 XSync calls (mxSync), the average number of XSync() requests
+that were pending but not yet processed for each of the last 10
+processed XSync() calls, the maximum number of XSync() requests that
+were pending but not yet processed for each of the last 10 processed
+XSync() calls, and a histogram showing the distribution of the times of
+all of the XSync() calls that were made during the previous interval.
+.sp
+(The length of the moving average and the number and value of histogram
+bins are configurable at compile time in the
+.B dmxstat.h
+header file.)
+.sp
+.TP 8
+.BI "-syncbatch " interval
+This option sets the
+.I interval
+in milliseconds for XSync() batching. An
+.I interval
+less than or equal to 0 will disable XSync() batching. The default
+.I interval
+is 100 ms.
+.sp
+.TP 8
+.BI "-nooffscreenopt"
+This option disables the offscreen optimization. Since the lazy window
+creation optimization requires the offscreen optimization to be enabled,
+this option will also disable the lazy window creation optimization.
+.sp
+.TP 8
+.BI "-nowindowopt"
+This option disables the lazy window creation optimization.
+.sp
+.TP 8
+.BI "-nosubdivprims"
+This option disables the primitive subdivision optimization.
+.sp
+.TP 8
+.BI "-noxkb"
+Disable use of the XKB extension for communication with the back end
+displays. (Combine with
+.B "-kb"
+to disable all use of XKB.)
+.sp
+.TP 8
+.BI "-depth " int
+This option sets the root window's default depth. When choosing a
+default visual from those available on the back-end X server, the first
+visual with that matches the depth specified is used.
+.sp
+This option can be combined with the
+.BI "-cc"
+option, which specifies the default color visual class, to force the use
+of a specific depth and color class for the root window.
+.sp
+.TP 8
+.BI "-norender"
+This option disables the RENDER extension.
+.sp
+.TP 8
+.BI "-noglxproxy"
+This option disables GLX proxy -- the build-in GLX extension
+implementation that is DMX aware.
+.sp
+.TP 8
+.BI "-noglxswapgroup"
+This option disables the swap group and swap barrier extensions in GLX
+proxy.
+.sp
+.TP 8
+.BI "-glxsyncswap"
+This option enables synchronization after a swap buffers call by waiting
+until all X protocol has been processed. When a client issues a
+glXSwapBuffers request, Xdmx relays that request to each back-end X
+server, and those requests are buffered along with all other protocol
+requests. However, in systems that have large network buffers, this
+buffering can lead to the set of back-end X servers handling the swap
+buffers request asynchronously. With this option, an XSync() request is
+issued to each back-end X server after sending the swap buffers request.
+The XSync() requests will flush all buffered protocol (including the
+swap buffers requests) and wait until the back-end X servers have
+processed those requests before continuing. This option does not wait
+until all GL commands have been processed so there might be previously
+issued commands that are still being processed in the GL pipe when the
+XSync() request returns. See the
+.BI "-glxfinishswap"
+option below if Xdmx should wait until the GL commands have been
+processed.
+.sp
+.TP 8
+.BI "-glxfinishswap"
+This option enables synchronization after a swap buffers call by waiting
+until all GL commands have been completed. It is similar to the
+.BI "-glxsyncswap"
+option above; however, instead of issuing an XSync(), it issues a
+glFinish() request to each back-end X server after sending the swap
+buffers requests. The glFinish() request will flush all buffered
+protocol requests, process both X and GL requests, and wait until all
+previously called GL commands are complete before returning.
+.sp
+.TP 8
+.BI "-ignorebadfontpaths"
+This option ignores font paths that are not available on all back-end
+servers by removing the bad font path(s) from the default font path
+list. If no valid font paths are left after removing the bad paths, an
+error to that effect is printed in the log.
+.sp
+.TP 8
+.BI "-addremovescreens"
+This option enables the dynamic addition and removal of screens, which
+is disabled by default. Note that GLXProxy and Render do not yet
+support dynamic addition and removal of screens, and must be disabled
+via the
+.BI "-noglxproxy"
+and
+.BI "-norender"
+command line options described above.
+.sp
+.TP 8
+.BI "-param"
+This option specifies parameters on the command line. Currently, only
+parameters dealing with XKEYBOARD configuration are supported. These
+parameters apply only to the core keyboard. Parameter values are
+installation-dependent. Please see
+.I /usr/X11R6/lib/X11/xkb
+or a similar directory for complete information.
+.RS
+.TP 8
+.B XkbRules
+Defaults to "xfree86". Other values may include "sgi" and "sun".
+.sp
+.TP 8
+.B XkbModel
+Defaults to "pc101". When used with "xfree86" rules, other values may
+include "pc102", "pc104", "pc105", "microsoft", and many others. When
+used with "sun" rules, other values may include "type4" and "type5".
+.sp
+.TP 8
+.B XkbLayout
+Defaults to "us". Other country codes and "dvorak" are usually
+available.
+.sp
+.TP 8
+.B XkbVariant
+Defaults to "".
+.sp
+.TP 8
+.B XkbOptions
+Defaults to "".
+.RE
+.SH "CONFIGURATION FILE GRAMMAR"
+The following words and tokens are reserved:
+.RS
+.B virtual
+.B display
+.B wall
+.B option
+.B param
+.B {
+.B }
+.B ;
+.B #
+.RE
+.PP
+Comments start with a
+.B #
+mark and extend to the end of the line. They may appear anywhere. If a
+configuration file is read into
+.BR xdmxconfig ,
+the comments in that file will be preserved, but will not be editable.
+.PP
+The grammar is as follows:
+.RS
+virtual-list ::= [ virtual-list ] | virtual
+
+virtual ::=
+.B virtual
+[ name ] [ dim ]
+.B {
+dw-list
+.B }
+
+dw-list ::= [ dw-list ] | dw
+
+dw ::= display | wall | option
+
+display ::=
+.B display
+name [ geometry ] [ / geometry ] [ origin ]
+.B ;
+
+wall ::=
+.B wall
+[ dim ] [ dim ] name-list
+.B ;
+
+option ::=
+.B option
+name-list
+.B ;
+
+param ::=
+.B param
+name-list
+.B ;
+
+param ::=
+.B param {
+param-list
+.B }
+
+param-list ::= [ param-list ] | name-list
+.B ;
+
+name-list ::= [ name-list ] | name
+
+name ::= string | double-quoted-string
+
+dim ::= integer
+.B x
+integer
+
+geometry ::= [ integer
+.B x
+integer ] [ signed-integer signed-integer ]
+
+origin ::=
+.B @
+integer
+.B x
+integer
+.RE
+.PP
+The name following
+.B virtual
+is used as an identifier for the configuration, and may be passed to
+.B Xdmx
+using the
+.B \-config
+command line option. The name of a display should be standard X display
+name, although no checking is performed (e.g., "machine:0").
+.PP
+For names, double quotes are optional unless the name is reserved or
+contains spaces.
+.PP
+The first dimension following
+.B wall
+is the dimension for tiling (e.g., 2x4 or 4x4). The second dimension
+following
+.B wall
+is the dimension of each display in the wall (e.g., 1280x1024).
+.PP
+The first geometry following
+.B display
+is the geometry of the screen window on the backend server. The second
+geometry, which is always preceeded by a slash, is the geometry of the
+root window. By default, the root window has the same geometry as the
+screen window.
+.PP
+The
+.B option
+line can be used to specify any command-line options (e.g.,
+.BR \-input ).
+(It cannot be used to specify the name of the front-end display.) The
+option line is processed once at server startup, just line command line
+options. This behavior may be unexpected.
+.SH "CONFIGURATION FILE EXAMPLES"
+Two displays being used for a desktop may be specified in any of the
+following formats:
+.RS
+.nf
+virtual example0 {
+ display d0:0 1280x1024 @0x0;
+ display d1:0 1280x1024 @1280x0;
+}
+.sp
+virtual example1 {
+ display d0:0 1280x1024;
+ display d1:0 @1280x0;
+}
+.sp
+virtual example2 {
+ display "d0:0";
+ display "d1:0" @1280x0;
+}
+.sp
+virtual example3 { wall 2x1 d0:0 d1:0; }
+.fi
+.RE
+A 4x4 wall of 16 total displays could be specified as follows (if no
+tiling dimension is specified, an approximate square is used):
+.RS
+.nf
+virtual example4 {
+ wall d0:0 d1:0 d2:0 d3:0
+ d4:0 d5:0 d6:0 d7:0
+ d8:0 d9:0 da:0 db:0
+ dc:0 dd:0 de:0 df:0;
+}
+.fi
+.RE
+.SH "FONT PATHS"
+The font path used by the
+.I Xdmx
+front-end server will be propagated to each back-end server,which
+requires that each back-end server have access to the exact same font
+paths as the front-end server. This can be most easily handled by
+either using a font server (e.g., xfs) or by remotely mounting the font
+paths on each back-end server, and then setting the
+.I Xdmx
+server's default font path with the
+-I "-fontpath"
+command line option described above.
+.PP
+For example, if you specify a font path with the following command line:
+.RS
+Xdmx :1 -display d0:0 -fontpath /usr/fonts/75dpi/ -fontpath /usr/fonts/Type1/ +xinerama
+.RE
+Then, /usr/fonts/75dpi/ and /usr/fonts/Type1/ must be valid font paths
+on the
+.I Xdmx
+server and all back-end server, which is d0 in this example.
+.PP
+Font servers can also be specified with the
+.I "-fontpath"
+option. For example, let's assume that a properly configured font
+server is running on host d0. Then, the following command line
+.RS
+Xdmx :1 -display d0:0 -display d1:0 -fontpath tcp/d0:7100 +xinerama
+.RE
+will initialize the front-end
+.I Xdmx
+server and each of the back-end servers to use the font server on d0.
+.PP
+Some fonts might not be supported by either the front-end or the
+back-end servers. For example, let's assume the front-end
+.I Xdmx
+server includes support Type1 fonts, but one of the back-end servers
+does not. Let's also assume that the default font path for
+.I Xdmx
+includes Type1 fonts in its font path. Then, when
+.I Xdmx
+initializes the default font path to load the default font, the font
+path that includes Type1 fonts (along with the other default font paths
+that are used by the
+.I Xdmx
+server) is sent to the back-end server that cannot handle Type1 fonts.
+That back-end server then rejects the font path and sends an error back
+to the
+.I Xdmx
+server.
+.I Xdmx
+then prints an error message and exits because it failed to set the
+default font path and was unable load the default font.
+.PP
+To fix this error, the offending font path must be removed from the
+default font path by using a different
+.I "-fontpath"
+command line option.
+.PP
+The
+.I "-fontpath"
+option can also be added to the configuration file as described above.
+.SH "COMMAND-LINE EXAMPLES"
+The back-end machines are d0 and d1, core input is from the pointer and
+keyboard attached to d0, clients will refer to :1 when opening windows:
+.RS
+Xdmx :1 -display d0:0 -display d1:0 +xinerama
+.RE
+.PP
+As above, except with core input from d1:
+.RS
+Xdmx :1 -display d0:0 -display d1:0 -input d1:0 +xinerama
+.RE
+.PP
+As above, except with core input from a console window on the local
+display:
+.RS
+Xdmx :1 -display d0:0 -display d1:0 -input :0 +xinerama
+.RE
+.PP
+As above, except with core input from the local keyboard and mouse:
+.RS
+Xdmx :1 -display d0:0 -display d1:0 -input local,kbd,ps2 +xinerama
+.RE
+Note that local input can be used under Linux while another X session is
+running on :0 (assuming the user can access the Linux console tty and
+mouse devices): a new (blank) VC will be used for keyboard input on the
+local machine and the Ctrl-Alt-F* sequence will be available to change
+to another VC (possibly back to another X session running on the local
+machine). Using Ctrl-Alt-Backspace on the blank VC will terminate the
+Xdmx session and return to the original VC.
+.PP
+This example uses the configuration file shown in the previous section:
+.RS
+Xdmx :1 -input :0 +xinerama -configfile filename -config example2
+.RE
+With this configuration file line:
+.RS
+option -input :0 +xinerama;
+.RE
+the command line can be shortened to:
+.RS
+Xdmx :1 -configfile filename -config example2
+.RE
+.SH "USING THE USB DEVICE DRIVERS"
+.P
+The USB device drivers use the devices called
+.IR /dev/input/event0 ", " /dev/input/event1 ", etc."
+under Linux. These devices are driven using the
+.I evdev
+Linux kernel module, which is part of the hid suite. Please note that
+if you load the
+.I mousedev
+or
+.I kbddev
+Linux kernel modules, then USB devices will appear as core Linux input
+devices and you will not be able to select between using the device only
+as an
+.I Xdmx
+core device or an
+.I Xdmx
+XInput extension device. Further, you may be unable to unload the
+.I mousedev
+Linux kernel module if
+.I XFree86
+is configured to use
+.I /dev/input/mice
+as an input device (this is quite helpful for laptop users and is set up
+by default under some Linux distributions, but should be changed if USB
+devices are to be used with
+.IR Xdmx ).
+.PP
+The USB device drivers search through the Linux devices for the first
+mouse, keyboard, or non-mouse-non-keyboard Linux device and use that
+device.
+.SH "KEYBOARD INITIALIZATION"
+.PP
+If
+.I Xdmx
+was invoked with
+.I \-xkb
+or was
+.B not
+compiled to use the XKEYBOARD extension, then a keyboard on a backend or
+console will be initialized using the map that the host X server
+provides.
+.PP
+If the XKEYBOARD extension is used for both
+.I Xdmx
+and the host X server for the keyboard (i.e., the backend or console X
+server), then the type of the keyboard will
+be obtained from the host X server and the keyboard under
+.I Xdmx
+will be initialized with that information. Otherwise, the default type
+of keyboard will be initialized. In both cases, the map from the host X
+server will
+.B not
+be used. This means that different initial behavior may be noted with
+and without XKEYBOARD. Consistent and expected results will be obtained
+by running XKEYBOARD on all servers and by avoiding the use of
+.I xmodmap
+on the backend or console X servers prior to starting
+.IR Xdmx .
+.PP
+If
+.I \-xkbmap
+is specified on the
+.I Xdmx
+command line, then that map will currently be used for all keyboards.
+.SH "MULTIPLE CORE KEYBOARDS"
+X was not designed to support multiple core keyboards. However,
+.I Xdmx
+provides some support for multiple core keyboards. Best results will be
+obtained if all of the keyboards are of the same type and are using the
+same keyboard map. Because the X server passes raw key code information
+to the X client, key symbols for keyboards with different key maps would
+be different if the key code for each keyboard was sent without
+translation to the client. Therefore,
+.I Xdmx
+will attempt to translate the key code from a core keyboard to the key
+code for the key with the same key symbol of the
+.B first
+core keyboard that was loaded. If the key symbol appears in both maps,
+the results will be expected. Otherwise, the second core keyboard will
+return a NoSymbol key symbol for some keys that would have been
+translated if it was the first core keyboard.
+.ig
+.SH ENVIRONMENT
+..
+.ig
+.SH FILES
+..
+.SH "SEE ALSO"
+.BR DMX "(3X), " X "(__miscmansuffix__), " Xserver "(1), " xdmxconfig "(1), "
+.BR vdltodmx "(1), " xfs "(1), " xkbcomp (1)
+.SH AUTHORS
+Kevin E. Martin
+.I <kem@redhat.com>,
+David H. Dawes
+.I <dawes@xfree86.org>,
+and
+Rickard E. (Rik) Faith
+.IR <faith@redhat.com> .
+.PP
+Portions of
+.I Xdmx
+are based on code from The XFree86 Project
+.RI ( http://www.xfree86.org )
+and X.Org
+.RI ( http://www.x.org ).
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/Canvas.c b/nx-X11/programs/Xserver/hw/dmx/config/Canvas.c
new file mode 100644
index 000000000..4dccd7382
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/Canvas.c
@@ -0,0 +1,160 @@
+/* $XFree86$ */
+/*
+ * Copyright 1987, 1998 The Open Group
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of The Open Group shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from The Open Group.
+ */
+
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ * This file was originally taken from xc/lib/Xaw/Template.c
+ */
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include "CanvasP.h"
+
+static void CanvasInitialize(Widget request, Widget w,
+ ArgList args, Cardinal *num_args)
+{
+}
+
+static void CanvasExpose(Widget w, XEvent *event, Region region)
+{
+ CanvasExposeDataRec data;
+
+ data.w = w;
+ data.event = event;
+ data.region = region;
+
+ if (!XtIsRealized(w)) return;
+ XtCallCallbacks(w, XtNcanvasExposeCallback, (XtPointer)&data);
+}
+
+static void CanvasResize(Widget w)
+{
+ if (!XtIsRealized(w)) return;
+ XtCallCallbacks(w, XtNcanvasResizeCallback, (XtPointer)w);
+}
+
+static void CanvasAction(Widget w, XEvent *event,
+ String *params, Cardinal *num_params)
+{
+ XtCallCallbacks(w, XtNcallback, (XtPointer)event);
+}
+
+#define offset(field) XtOffsetOf(CanvasRec, canvas.field)
+static XtResource resources[] = {
+ { XtNcallback, XtCCallback, XtRCallback,
+ sizeof(XtCallbackList), offset(input_callback), XtRCallback, NULL },
+ { XtNcanvasExposeCallback, XtCcanvasExposeCallback, XtRCallback,
+ sizeof(XtCallbackList), offset(expose_callback), XtRCallback, NULL },
+ { XtNcanvasResizeCallback, XtCcanvasResizeCallback, XtRCallback,
+ sizeof(XtCallbackList), offset(resize_callback), XtRCallback, NULL },
+};
+#undef offset
+
+static XtActionsRec actions[] =
+{
+ {"canvas", CanvasAction},
+};
+
+static char translations[] =
+"<Key>: canvas()\n\
+<Motion>: canvas()\n\
+<BtnDown>: canvas()\n\
+<BtnUp>: canvas()\n\
+"
+;
+
+#define Superclass (&widgetClassRec)
+CanvasClassRec canvasClassRec = {
+ /* core */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "Canvas", /* class_name */
+ sizeof(CanvasRec), /* widget_size */
+ NULL, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ CanvasInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ actions, /* actions */
+ XtNumber(actions), /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ NULL, /* destroy */
+ CanvasResize, /* resize */
+ CanvasExpose, /* expose */
+ NULL, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ translations, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* canvas */
+ {
+ NULL, /* extension */
+ }
+};
+
+WidgetClass canvasWidgetClass = (WidgetClass)&canvasClassRec;
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/Canvas.h b/nx-X11/programs/Xserver/hw/dmx/config/Canvas.h
new file mode 100644
index 000000000..a36851a6d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/Canvas.h
@@ -0,0 +1,56 @@
+/* $XFree86$ */
+/*
+
+Copyright 1987, 1998 The Open Group
+Copyright 2002 Red Hat Inc., Durham, North Carolina.
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ * This file was originally taken from xc/lib/Xaw/Template.h
+ */
+
+#ifndef _Canvas_h
+#define _Canvas_h
+
+#include <X11/Intrinsic.h>
+
+#define XtNcanvasExposeCallback "canvasExposeCallback"
+#define XtCcanvasExposeCallback "CanvasExposeCallback"
+#define XtNcanvasResizeCallback "canvasResizeCallback"
+#define XtCcanvasResizeCallback "CanvasResizeCallback"
+
+typedef struct _CanvasClassRec *CanvasWidgetClass;
+typedef struct _CanvasRec *CanvasWidget;
+extern WidgetClass canvasWidgetClass;
+
+typedef struct _CanvasExposeDataRec {
+ Widget w;
+ XEvent *event;
+ Region region;
+} CanvasExposeDataRec, *CanvasExposeDataPtr;
+
+#endif /* _Canvas_h */
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/CanvasP.h b/nx-X11/programs/Xserver/hw/dmx/config/CanvasP.h
new file mode 100644
index 000000000..98f95b94e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/CanvasP.h
@@ -0,0 +1,66 @@
+/* $XFree86$ */
+/*
+
+Copyright 1987, 1998 The Open Group
+Copyright 2002 Red Hat Inc., Durham, North Carolina.
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ * This file was originally taken from xc/lib/Xaw/TemplateP.h
+ */
+
+#ifndef _CanvasP_h
+#define _CanvasP_h
+
+#include "Canvas.h"
+
+/* include superclass private header file */
+#include <X11/CoreP.h>
+
+typedef struct {
+ XtPointer extension;
+} CanvasClassPart;
+
+typedef struct _CanvasClassRec {
+ CoreClassPart core_class;
+ CanvasClassPart canvas_class;
+} CanvasClassRec;
+
+extern CanvasClassRec canvasClassRec;
+
+typedef struct {
+ XtCallbackList input_callback;
+ XtCallbackList expose_callback;
+ XtCallbackList resize_callback;
+} CanvasPart;
+
+typedef struct _CanvasRec {
+ CorePart core;
+ CanvasPart canvas;
+} CanvasRec;
+
+#endif /* _CanvasP_h */
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/Imakefile b/nx-X11/programs/Xserver/hw/dmx/config/Imakefile
new file mode 100644
index 000000000..08039c03e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/Imakefile
@@ -0,0 +1,101 @@
+XCOMM $XFree86$
+
+#include <Server.tmpl>
+#include <lnxdoc.rules>
+
+YFLAGS = -d
+
+LIBSRCS = parser.c scanner.c dmxparse.c dmxprint.c dmxcompat.c dmxconfig.c
+LIBOBJS = parser.o scanner.o dmxparse.o dmxprint.o dmxcompat.o dmxconfig.o
+
+#if !BuildServersOnly
+CONFIGSRCS = xdmxconfig.c dmxlog.c Canvas.c
+CONFIGOBJS = xdmxconfig.o dmxlog.o Canvas.o
+
+COMPATSRCS = vdltodmx.c
+COMPATOBJS = vdltodmx.o
+
+TESTSRCS = dmxtodmx.c
+TESTOBJS = dmxtodmx.o
+#endif
+
+SRCS = $(LIBSRCS) $(CONFIGSRCS) $(COMPATSRCS) $(TESTSRCS)
+OBJS = $(LIBOBJS) $(CONFIGOBJS) $(COMPATOBJS) $(TESTOBJS)
+
+#if !BuildServersOnly
+EXES = xdmxconfig vdltodmx dmxtodmx
+#endif
+
+LOCAL_LIBRARIES = -L. -ldmxconfig
+
+#include <dmx.cf>
+
+INCLUDES = -I. -I.. -I$(XBUILDINCDIR) -I$(FONTINCSRC) -I../../../mi \
+ -I../../../include -I../../../render -I$(EXTINCSRC)
+
+DEFINES = $(OS_DEFINES) $(EXT_DEFINES) -DDMX_LOG_STANDALONE $(DMX_DEFINES)
+
+all::
+
+LexFile(scanner)
+YaccFile(parser,$(YFLAGS))
+
+#if HasGcc3
+XCOMM These rules remove some of the default warnings and, therefore, the
+XCOMM clutter from the compiler output. Only do this for GCC 3, since the
+XCOMM undef warning was added in 2.8. (The warnings are harmless, so be
+XCOMM conservative in their removal.)
+SpecialCObjectRule(parser,parser.h,-Wno-undef)
+SpecialCObjectRule(scanner,parser.h,-Wno-undef -Wno-unused-function -Wno-unused-label -Wno-unused-variable)
+#endif
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(dmxconfig,$(LIBOBJS))
+
+#if !BuildServersOnly
+NormalProgramTarget(xdmxconfig,$(CONFIGOBJS),\
+ libdmxconfig.a XawClientDepLibs $(DEPXTOOLLIB),\
+ $(LOCAL_LIBRARIES) XawClientLibs $(XTOOLLIB),NullParameter)
+AllTarget(ProgramTargetName(xdmxconfig))
+
+NormalProgramTarget(vdltodmx,$(COMPATOBJS),libdmxconfig.a,\
+ $(LOCAL_LIBRARIES),NullParameter)
+AllTarget(ProgramTargetName(vdltodmx))
+
+NormalProgramTarget(dmxtodmx,$(TESTOBJS),libdmxconfig.a,\
+ $(LOCAL_LIBRARIES),NullParameter)
+AllTarget(ProgramTargetName(dmxtodmx))
+
+LinkSourceFile(dmxlog.c,..)
+
+InstallProgram(dmxtodmx,$(BINDIR))
+InstallProgram(vdltodmx,$(BINDIR))
+InstallProgram(xdmxconfig,$(BINDIR))
+
+InstallManPage(dmxtodmx,$(MANDIR))
+InstallManPage(vdltodmx,$(MANDIR))
+InstallManPage(xdmxconfig,$(MANDIR))
+#endif
+
+DependTarget()
+
+#if !BuildServersOnly
+test: $(EXES)
+ @for i in test-*.in; do \
+ b=`echo $$i | sed 's,.in$$,,'` \
+ export b; \
+ (./dmxtodmx < $$i > $$b.tmp 2>&1; exit 0); \
+ if cmp -s ./$$b.out ./$$b.tmp; \
+ then echo PASSED $$b; rm -f $$b.tmp; \
+ else echo "FAILED $$b **********"; \
+ fi \
+ done
+
+test-update:
+ @for i in test-*.in; do \
+ b=`echo $$i | sed 's,.in$$,,'` \
+ export b; \
+ echo Writing $$b.out; \
+ (./dmxtodmx < $$i > $$b.out 2>&1; exit 0) \
+ done
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/TODO b/nx-X11/programs/Xserver/hw/dmx/config/TODO
new file mode 100644
index 000000000..2998ff4a0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/TODO
@@ -0,0 +1,7 @@
+Fri May 31 13:20:17 2002
+
+1) Sanitize values from input boxes.
+
+2) Add canvas colors to cavas widget resources or to command-line options.
+
+3) Add ability to edit option line(s) and wall.
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/dmxcompat.c b/nx-X11/programs/Xserver/hw/dmx/config/dmxcompat.c
new file mode 100644
index 000000000..3681e8aa2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/dmxcompat.c
@@ -0,0 +1,237 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ */
+
+/** \file
+ * This file provides some compatibility support for reading VDL files
+ * that are used by xmovie
+ * (http://www.llnl.gov/icc/sdd/img/xmovie/xmovie.shtml).
+ *
+ * This file is not used by the DMX server.
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmxconfig.h"
+#include "dmxparse.h"
+#include "dmxcompat.h"
+#include "parser.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+static int dmxVDLReadLine(FILE *str, char *buf, int len)
+{
+ if (fgets(buf, len, str)) return strlen(buf);
+ return 0;
+}
+
+static int dmxVDLCount(const char *buf)
+{
+ return strtol(buf, NULL, 10);
+}
+
+static void dmxVDLVirtualEntry(const char *buf,
+ char *name, int *len,
+ int *x, int *y)
+{
+ char *end;
+ const char *s;
+ char *d;
+ int start;
+
+ *x = strtol(buf, &end, 10);
+ *y = strtol(end, &end, 10);
+
+ for (s = end, d = name, start = 1; *s && *s != '['; ++s) {
+ if (start && isspace(*s)) continue;
+ *d++ = *s;
+ start = 0;
+ }
+ *d = '\0';
+ while (d > name && isspace(d[-1])) *--d = '\0'; /* remove trailing space */
+ *len = strlen(name);
+}
+
+static void dmxVDLDisplayEntry(const char *buf,
+ char *name, int *len,
+ int *x, int *y,
+ int *xoff, int *yoff,
+ int *xorig, int *yorig)
+{
+ const char *pt;
+ char *end;
+
+ pt = strchr(buf, ' ');
+ strncpy(name, buf, pt-buf);
+ name[pt-buf] = '\0';
+ *len = strlen(name);
+
+ *x = strtol(pt, &end, 10);
+ *y = strtol(end, &end, 10);
+ *xorig = strtol(end, &end, 10);
+ *yorig = strtol(end, &end, 10);
+ *xoff = strtol(end, &end, 10);
+ *yoff = strtol(end, NULL, 10);
+}
+
+/** Read from the VDL format \a filename and return a newly allocated \a
+ * DMXConfigEntryPtr */
+DMXConfigEntryPtr dmxVDLRead(const char *filename)
+{
+ FILE *str;
+ char buf[2048]; /* RATS: Use ok */
+ char *pt;
+ int lineno = 0;
+ DMXConfigEntryPtr entry = NULL;
+ DMXConfigVirtualPtr virtual = NULL;
+ DMXConfigSubPtr sub = NULL;
+ DMXConfigDisplayPtr display = NULL;
+ DMXConfigFullDimPtr fdim = NULL;
+ int vcount = 0;
+ int dcount = 0;
+ int icount = 0;
+ int x, y, xoff, yoff, xorig, yorig;
+ char name[2048]; /* RATS: Use ok */
+ const char *tmp;
+ int len;
+ enum {
+ simulateFlag,
+ virtualCount,
+ virtualEntry,
+ displayCount,
+ displayEntry,
+ ignoreCount,
+ ignoreEntry
+ } state = simulateFlag;
+
+ if (!filename) str = stdin;
+ else str = fopen(filename, "r");
+ if (!str) return NULL;
+
+ while (dmxVDLReadLine(str, buf, sizeof(buf))) {
+ DMXConfigCommentPtr comment = NULL;
+
+ ++lineno;
+ for (pt = buf; *pt; pt++)
+ if (*pt == '\r' || *pt == '\n') {
+ *pt = '\0';
+ break;
+ }
+ if (buf[0] == '#') {
+ tmp = dmxConfigCopyString(buf + 1, strlen(buf + 1));
+ comment = dmxConfigCreateComment(T_COMMENT, lineno, tmp);
+ entry = dmxConfigAddEntry(entry, dmxConfigComment, comment, NULL);
+ continue;
+ }
+ switch (state) {
+ case simulateFlag:
+ state = virtualCount;
+ break;
+ case virtualCount:
+ vcount = dmxVDLCount(buf);
+ state = virtualEntry;
+ break;
+ case virtualEntry:
+ len = sizeof(name);
+ dmxVDLVirtualEntry(buf, name, &len, &x, &y);
+ tmp = dmxConfigCopyString(name, len);
+ virtual = dmxConfigCreateVirtual(NULL,
+ dmxConfigCreateString(T_STRING,
+ lineno,
+ NULL,
+ tmp),
+ dmxConfigCreatePair(T_DIMENSION,
+ lineno,
+ NULL,
+ x, y, 0, 0),
+ NULL, NULL, NULL);
+ state = displayCount;
+ break;
+ case displayCount:
+ dcount = dmxVDLCount(buf);
+ state = displayEntry;
+ break;
+ case displayEntry:
+ dmxVDLDisplayEntry(buf, name, &len, &x, &y, &xoff, &yoff,
+ &xorig, &yorig);
+ tmp = dmxConfigCopyString(name, len);
+ fdim = dmxConfigCreateFullDim(
+ dmxConfigCreatePartDim(
+ dmxConfigCreatePair(T_DIMENSION,
+ lineno,
+ NULL,
+ x, y, 0, 0),
+ dmxConfigCreatePair(T_OFFSET,
+ lineno,
+ NULL,
+ xoff, yoff,
+ xoff, yoff)),
+ NULL);
+ display = dmxConfigCreateDisplay(NULL,
+ dmxConfigCreateString(T_STRING,
+ lineno,
+ NULL,
+ tmp),
+ fdim,
+ dmxConfigCreatePair(T_ORIGIN,
+ lineno,
+ NULL,
+ xorig, yorig,
+ 0, 0),
+ NULL);
+ sub = dmxConfigAddSub(sub, dmxConfigSubDisplay(display));
+ if (!--dcount) {
+ state = ignoreCount;
+ virtual->subentry = sub;
+ entry = dmxConfigAddEntry(entry,
+ dmxConfigVirtual,
+ NULL,
+ virtual);
+ virtual = NULL;
+ sub = NULL;
+ }
+ break;
+ case ignoreCount:
+ icount = dmxVDLCount(buf);
+ state = ignoreEntry;
+ break;
+ case ignoreEntry:
+ if (!--icount) state = virtualEntry;
+ break;
+ }
+ }
+ return entry;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/dmxcompat.h b/nx-X11/programs/Xserver/hw/dmx/config/dmxcompat.h
new file mode 100644
index 000000000..416ec7873
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/dmxcompat.h
@@ -0,0 +1,45 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to VDL compatibility support. \see dmxcompat.c
+ *
+ * This file is not used by the DMX server.
+ */
+
+#ifndef _DMXCOMPAT_H_
+#define _DMXCOMPAT_H_
+
+extern DMXConfigEntryPtr dmxVDLRead(const char *filename);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/dmxconfig.c b/nx-X11/programs/Xserver/hw/dmx/config/dmxconfig.c
new file mode 100644
index 000000000..353ce11db
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/dmxconfig.c
@@ -0,0 +1,499 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Provides interface for reading DMX configuration files and for
+ * combining that information with command-line configuration parameters. */
+
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxinput.h"
+#include "dmxconfig.h"
+#include "dmxparse.h"
+#include "dmxlog.h"
+#include "dmxcb.h"
+#include "dmxstat.h"
+#include "parser.h"
+
+extern int yyparse(void);
+extern FILE *yyin;
+
+static char *dmxXkbRules;
+static char *dmxXkbModel;
+static char *dmxXkbLayout;
+static char *dmxXkbVariant;
+static char *dmxXkbOptions;
+
+/** Stores lists of configuration information. */
+typedef struct DMXConfigListStruct {
+ const char *name;
+ struct DMXConfigListStruct *next;
+} DMXConfigList, *DMXConfigListPtr;
+
+/** This stucture stores the parsed configuration information. */
+typedef struct DMXConfigCmdStruct {
+ const char *filename;
+ const char *config;
+ DMXConfigList *displays;
+ DMXConfigList *inputs;
+ DMXConfigList *xinputs;
+} DMXConfigCmd, *DMXConfigCmdPtr;
+
+DMXConfigEntryPtr dmxConfigEntry;
+static DMXConfigCmd dmxConfigCmd;
+
+static int dmxDisplaysFromCommandLine;
+
+/** Make a note that \a display is the name of an X11 display that
+ * should be initialized as a backend (output) display. Called from
+ * #ddxProcessArgument. */
+void dmxConfigStoreDisplay(const char *display)
+{
+ DMXConfigListPtr entry = malloc(sizeof(*entry));
+ entry->name = strdup(display);
+ entry->next = NULL;
+ if (!dmxConfigCmd.displays) dmxConfigCmd.displays = entry;
+ else {
+ DMXConfigList *pt;
+ for (pt = dmxConfigCmd.displays; pt->next; pt = pt->next);
+ if (!pt)
+ dmxLog(dmxFatal, "dmxConfigStoreDisplay: end of list non-NULL\n");
+ pt->next = entry;
+ }
+ ++dmxDisplaysFromCommandLine;
+}
+
+/** Make a note that \a input is the name of an X11 display that should
+ * be used for input (either a backend or a console input device). */
+void dmxConfigStoreInput(const char *input)
+{
+ DMXConfigListPtr entry = malloc(sizeof(*entry));
+ entry->name = strdup(input);
+ entry->next = NULL;
+ if (!dmxConfigCmd.inputs) dmxConfigCmd.inputs = entry;
+ else {
+ DMXConfigList *pt;
+ for (pt = dmxConfigCmd.inputs; pt->next; pt = pt->next);
+ if (!pt)
+ dmxLog(dmxFatal, "dmxConfigStoreInput: end of list non-NULL\n");
+ pt->next = entry;
+ }
+}
+
+/** Make a note that \a input is the name of an X11 display that should
+ * be used for input from XInput extension devices. */
+void dmxConfigStoreXInput(const char *input)
+{
+ DMXConfigListPtr entry = malloc(sizeof(*entry));
+ entry->name = strdup(input);
+ entry->next = NULL;
+ if (!dmxConfigCmd.xinputs) dmxConfigCmd.xinputs = entry;
+ else {
+ DMXConfigList *pt;
+ for (pt = dmxConfigCmd.xinputs; pt->next; pt = pt->next);
+ if (!pt)
+ dmxLog(dmxFatal, "dmxConfigStoreXInput: end of list non-NULL\n");
+ pt->next = entry;
+ }
+}
+
+/** Make a note that \a file is the configuration file. */
+void dmxConfigStoreFile(const char *file)
+{
+ if (dmxConfigCmd.filename)
+ dmxLog(dmxFatal, "Only one -configfile allowed\n");
+ dmxConfigCmd.filename = strdup(file);
+}
+
+/** Make a note that \a config should be used as the configuration for
+ * current instantiation of the DMX server. */
+void dmxConfigStoreConfig(const char *config)
+{
+ if (dmxConfigCmd.config) dmxLog(dmxFatal, "Only one -config allowed\n");
+ dmxConfigCmd.config = strdup(config);
+}
+
+static int dmxConfigReadFile(const char *filename, int debug)
+{
+ FILE *str;
+
+ if (!(str = fopen(filename, "r"))) return -1;
+ dmxLog(dmxInfo, "Reading configuration file \"%s\"\n", filename);
+ yyin = str;
+ yydebug = debug;
+ yyparse();
+ fclose(str);
+ return 0;
+}
+
+static const char *dmxConfigMatch(const char *target, DMXConfigEntryPtr entry)
+{
+ DMXConfigVirtualPtr v = entry->virtual;
+ const char *name = NULL;
+
+ if (v && v->name) name = v->name;
+
+ if (v && !dmxConfigCmd.config) return v->name ? v->name : "<noname>";
+ if (!name) return NULL;
+ if (!strcmp(name, target)) return name;
+ return NULL;
+}
+
+static DMXScreenInfo *dmxConfigAddDisplay(const char *name,
+ int scrnWidth, int scrnHeight,
+ int scrnX, int scrnY,
+ int scrnXSign, int scrnYSign,
+ int rootWidth, int rootHeight,
+ int rootX, int rootY,
+ int rootXSign, int rootYSign)
+{
+ DMXScreenInfo *dmxScreen;
+
+ if (!(dmxScreens = realloc(dmxScreens,
+ (dmxNumScreens+1) * sizeof(*dmxScreens))))
+ dmxLog(dmxFatal,
+ "dmxConfigAddDisplay: realloc failed for screen %d (%s)\n",
+ dmxNumScreens, name);
+
+ dmxScreen = &dmxScreens[dmxNumScreens];
+ memset(dmxScreen, 0, sizeof(*dmxScreen));
+ dmxScreen->name = name;
+ dmxScreen->index = dmxNumScreens;
+ dmxScreen->scrnWidth = scrnWidth;
+ dmxScreen->scrnHeight = scrnHeight;
+ dmxScreen->scrnX = scrnX;
+ dmxScreen->scrnY = scrnY;
+ dmxScreen->scrnXSign = scrnXSign;
+ dmxScreen->scrnYSign = scrnYSign;
+ dmxScreen->rootWidth = rootWidth;
+ dmxScreen->rootHeight = rootHeight;
+ dmxScreen->rootX = rootX;
+ dmxScreen->rootY = rootY;
+ dmxScreen->stat = dmxStatAlloc();
+ ++dmxNumScreens;
+ return dmxScreen;
+}
+
+DMXInputInfo *dmxConfigAddInput(const char *name, int core)
+{
+ DMXInputInfo *dmxInput;
+
+ if (!(dmxInputs = realloc(dmxInputs,
+ (dmxNumInputs+1) * sizeof(*dmxInputs))))
+ dmxLog(dmxFatal,
+ "dmxConfigAddInput: realloc failed for input %d (%s)\n",
+ dmxNumInputs, name);
+
+ dmxInput = &dmxInputs[dmxNumInputs];
+
+ memset(dmxInput, 0, sizeof(*dmxInput));
+ dmxInput->name = name;
+ dmxInput->inputIdx = dmxNumInputs;
+ dmxInput->scrnIdx = -1;
+ dmxInput->core = core;
+ ++dmxNumInputs;
+ return dmxInput;
+}
+
+static void dmxConfigCopyFromDisplay(DMXConfigDisplayPtr d)
+{
+ DMXScreenInfo *dmxScreen;
+
+ dmxScreen = dmxConfigAddDisplay(d->name,
+ d->scrnWidth, d->scrnHeight,
+ d->scrnX, d->scrnY,
+ d->scrnXSign, d->scrnYSign,
+ d->rootWidth, d->rootHeight,
+ d->rootX, d->rootY,
+ d->rootXSign, d->rootXSign);
+ dmxScreen->where = PosAbsolute;
+ dmxScreen->whereX = d->rootXOrigin;
+ dmxScreen->whereY = d->rootYOrigin;
+}
+
+static void dmxConfigCopyFromWall(DMXConfigWallPtr w)
+{
+ DMXConfigStringPtr pt;
+ DMXScreenInfo *dmxScreen;
+ int edge = dmxNumScreens;
+ int last = dmxNumScreens;
+
+ if (!w->xwall && !w->ywall) { /* Try to make it square */
+ int count;
+ for (pt = w->nameList, count = 0; pt; pt = pt->next) ++count;
+ w->xwall = sqrt(count) + .5;
+ }
+
+ for (pt = w->nameList; pt; pt = pt->next) {
+ dmxScreen = dmxConfigAddDisplay(pt->string, w->width, w->height,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+ if (pt == w->nameList) { /* Upper left */
+ dmxScreen->where = PosAbsolute;
+ dmxScreen->whereX = 0;
+ dmxScreen->whereY = 0;
+ } else if (w->xwall) { /* Tile left to right, then top to bottom */
+ if (!((dmxNumScreens-1) % w->xwall)) {
+ dmxScreen->where = PosBelow;
+ dmxScreen->whereRefScreen = edge;
+ edge = dmxNumScreens-1;
+ } else {
+ dmxScreen->where = PosRightOf;
+ dmxScreen->whereRefScreen = last;
+ }
+ } else { /* Tile top to bottom, then left to right */
+ if (!((dmxNumScreens-1) % w->ywall)) {
+ dmxScreen->where = PosRightOf;
+ dmxScreen->whereRefScreen = edge;
+ edge = dmxNumScreens-1;
+ } else {
+ dmxScreen->where = PosBelow;
+ dmxScreen->whereRefScreen = last;
+ }
+
+ }
+ last = dmxNumScreens-1;
+ if (dmxScreen->where == PosAbsolute)
+ dmxLog(dmxInfo, "Added %s at %d %d\n",
+ pt->string, dmxScreen->whereX, dmxScreen->whereY);
+ else
+ dmxLog(dmxInfo, "Added %s %s %s\n",
+ pt->string,
+ dmxScreen->where == PosBelow ? "below" : "right of",
+ dmxScreens[dmxScreen->whereRefScreen].name);
+ }
+}
+
+static void dmxConfigCopyFromOption(DMXConfigOptionPtr o)
+{
+ DMXConfigStringPtr pt;
+ int argc = 0;
+ char **argv = NULL;
+
+ if (serverGeneration != 1) return; /* FIXME: only do once, for now */
+ if (!o || !o->string) return;
+ for (pt = o->option; pt; pt = pt->next) {
+ if (pt->string) {
+ ++argc;
+ argv = realloc(argv, (argc+1) * sizeof(*argv));
+ argv[argc] = (char *)pt->string;
+ }
+ }
+ argv[0] = NULL;
+ ProcessCommandLine(argc+1, argv);
+ free(argv);
+}
+
+static void dmxConfigCopyFromParam(DMXConfigParamPtr p)
+{
+ const char **argv;
+ int argc;
+
+ if ((argv = dmxConfigLookupParam(p, "xkbrules", &argc)) && argc == 2) {
+ dmxConfigSetXkbRules(argv[1]);
+ } else if ((argv = dmxConfigLookupParam(p, "xkbmodel", &argc))
+ && argc == 2) {
+ dmxConfigSetXkbModel(argv[1]);
+ } else if ((argv = dmxConfigLookupParam(p, "xkblayout", &argc))
+ && argc == 2) {
+ dmxConfigSetXkbLayout(argv[1]);
+ } else if ((argv = dmxConfigLookupParam(p, "xkbvariant", &argc))
+ && argc == 2) {
+ dmxConfigSetXkbVariant(argv[1]);
+ } else if ((argv = dmxConfigLookupParam(p, "xkboptions", &argc))
+ && argc == 2) {
+ dmxConfigSetXkbOptions(argv[1]);
+ }
+}
+
+static void dmxConfigCopyData(DMXConfigVirtualPtr v)
+{
+ DMXConfigSubPtr sub;
+
+ if (v->dim) dmxSetWidthHeight(v->dim->x, v->dim->y);
+ else dmxSetWidthHeight(0, 0);
+ for (sub = v->subentry; sub; sub = sub->next) {
+ switch (sub->type) {
+ case dmxConfigDisplay: dmxConfigCopyFromDisplay(sub->display); break;
+ case dmxConfigWall: dmxConfigCopyFromWall(sub->wall); break;
+ case dmxConfigOption: dmxConfigCopyFromOption(sub->option); break;
+ case dmxConfigParam: dmxConfigCopyFromParam(sub->param); break;
+ default:
+ dmxLog(dmxFatal,
+ "dmxConfigCopyData: not a display, wall, or value\n");
+ }
+ }
+}
+
+static void dmxConfigFromCommandLine(void)
+{
+ DMXConfigListPtr pt;
+
+ dmxLog(dmxInfo, "Using configuration from command line\n");
+ for (pt = dmxConfigCmd.displays; pt; pt = pt->next) {
+ DMXScreenInfo *dmxScreen = dmxConfigAddDisplay(pt->name,
+ 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0);
+ if (dmxNumScreens == 1) {
+ dmxScreen->where = PosAbsolute;
+ dmxScreen->whereX = 0;
+ dmxScreen->whereY = 0;
+ dmxLog(dmxInfo, "Added %s at %d %d\n",
+ dmxScreen->name, dmxScreen->whereX, dmxScreen->whereY);
+ } else {
+ dmxScreen->where = PosRightOf;
+ dmxScreen->whereRefScreen = dmxNumScreens - 2;
+ if (dmxScreen->whereRefScreen < 0) dmxScreen->whereRefScreen = 0;
+ dmxLog(dmxInfo, "Added %s %s %s\n",
+ dmxScreen->name,
+ dmxScreen->where == PosBelow ? "below" : "right of",
+ dmxScreens[dmxScreen->whereRefScreen].name);
+ }
+ }
+}
+
+static void dmxConfigFromConfigFile(void)
+{
+ DMXConfigEntryPtr pt;
+ const char *name;
+
+ for (pt = dmxConfigEntry; pt; pt = pt->next) {
+ /* FIXME -- if an input is specified, use it */
+ if (pt->type != dmxConfigVirtual) continue;
+ if ((name = dmxConfigMatch(dmxConfigCmd.config, pt))) {
+ dmxLog(dmxInfo, "Using configuration \"%s\"\n", name);
+ dmxConfigCopyData(pt->virtual);
+ return;
+ }
+ }
+ dmxLog(dmxFatal, "Could not find configuration \"%s\" in \"%s\"\n",
+ dmxConfigCmd.config, dmxConfigCmd.filename);
+}
+
+static void dmxConfigConfigInputs(void)
+{
+ DMXConfigListPtr pt;
+
+ if (dmxNumInputs) return;
+
+ if (dmxConfigCmd.inputs) { /* Use command line */
+ for (pt = dmxConfigCmd.inputs; pt; pt = pt->next)
+ dmxConfigAddInput(pt->name, TRUE);
+ } else if (dmxNumScreens) { /* Use first display */
+ dmxConfigAddInput(dmxScreens[0].name, TRUE);
+ } else { /* Use dummy */
+ dmxConfigAddInput("dummy", TRUE);
+ }
+
+ if (dmxConfigCmd.xinputs) { /* Non-core devices from command line */
+ for (pt = dmxConfigCmd.xinputs; pt; pt = pt->next)
+ dmxConfigAddInput(pt->name, FALSE);
+ }
+}
+
+/** Set up the appropriate global variables so that the DMX server will
+ * be initialized using the configuration specified in the config file
+ * and on the command line. */
+void dmxConfigConfigure(void)
+{
+ if (dmxConfigEntry) {
+ dmxConfigFreeEntry(dmxConfigEntry);
+ dmxConfigEntry = NULL;
+ }
+ if (dmxConfigCmd.filename) {
+ if (dmxConfigCmd.displays)
+ dmxLog(dmxWarning,
+ "Using configuration file \"%s\" instead of command line\n",
+ dmxConfigCmd.filename);
+ dmxConfigReadFile(dmxConfigCmd.filename, 0);
+ dmxConfigFromConfigFile();
+ } else {
+ if (dmxConfigCmd.config)
+ dmxLog(dmxWarning,
+ "Configuration name (%s) without configuration file\n",
+ dmxConfigCmd.config);
+ dmxConfigFromCommandLine();
+ }
+ dmxConfigConfigInputs();
+}
+
+/** This function determines the number of displays we WILL have and
+ * sets MAXSCREENS to that value. This is difficult since the number
+ * depends on the command line (which is easy to count) or on the config
+ * file, which has to be parsed. */
+void dmxConfigSetMaxScreens(void)
+{
+ static int processing = 0;
+
+ if (processing) return; /* Prevent reentry via ProcessCommandLine */
+ processing = 1;
+ if (dmxConfigCmd.filename) {
+ if (!dmxNumScreens)
+ dmxConfigConfigure();
+#ifndef MAXSCREENS
+ SetMaxScreens(dmxNumScreens);
+#endif
+ } else
+#ifndef MAXSCREENS
+ SetMaxScreens(dmxDisplaysFromCommandLine);
+#endif
+ processing = 0;
+}
+
+/** This macro is used to generate the following access methods:
+ * - dmxConfig{Set,Get}rules
+ * - dmxConfig{Set,Get}model
+ * - dmxConfig{Set,Get}layout
+ * - dmxConfig{Set,Get}variant
+ * - dmxConfig{Set,Get}options
+ * These methods are used to read and write information about the keyboard. */
+
+#define GEN(param,glob,def) \
+ void dmxConfigSet##glob(const char *param) { \
+ if (dmx##glob) free((void *)dmx##glob); \
+ dmx##glob = strdup(param); \
+ } \
+ char *dmxConfigGet##glob(void) { \
+ return (char *)(dmx##glob ? dmx##glob : def); \
+ }
+
+GEN(rules, XkbRules, DMX_DEFAULT_XKB_RULES)
+GEN(model, XkbModel, DMX_DEFAULT_XKB_MODEL)
+GEN(layout, XkbLayout, DMX_DEFAULT_XKB_LAYOUT)
+GEN(variant, XkbVariant, DMX_DEFAULT_XKB_VARIANT)
+GEN(options, XkbOptions, DMX_DEFAULT_XKB_OPTIONS)
+
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/dmxconfig.h b/nx-X11/programs/Xserver/hw/dmx/config/dmxconfig.h
new file mode 100644
index 000000000..b5c0c1f1c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/dmxconfig.h
@@ -0,0 +1,65 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for DMX configuration file support. \see dmxconfig.c */
+
+#ifndef _DMXCONFIG_H_
+#define _DMXCONFIG_H_
+#define DMX_DEFAULT_XKB_RULES "xfree86"
+#define DMX_DEFAULT_XKB_MODEL "pc101"
+#define DMX_DEFAULT_XKB_LAYOUT "us"
+#define DMX_DEFAULT_XKB_VARIANT NULL
+#define DMX_DEFAULT_XKB_OPTIONS NULL
+
+extern void dmxConfigStoreDisplay(const char *display);
+extern void dmxConfigStoreInput(const char *input); /* Core devices */
+extern void dmxConfigStoreXInput(const char *input); /* Non-core devices */
+extern void dmxConfigStoreFile(const char *file);
+extern void dmxConfigStoreConfig(const char *config);
+extern void dmxConfigConfigure(void);
+extern void dmxConfigSetMaxScreens(void);
+
+extern void dmxConfigSetXkbRules(const char *rules);
+extern void dmxConfigSetXkbModel(const char *model);
+extern void dmxConfigSetXkbLayout(const char *layout);
+extern void dmxConfigSetXkbVariant(const char *variant);
+extern void dmxConfigSetXkbOptions(const char *options);
+
+extern char *dmxConfigGetXkbRules(void);
+extern char *dmxConfigGetXkbModel(void);
+extern char *dmxConfigGetXkbLayout(void);
+extern char *dmxConfigGetXkbVariant(void);
+extern char *dmxConfigGetXkbOptions(void);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/dmxparse.c b/nx-X11/programs/Xserver/hw/dmx/config/dmxparse.c
new file mode 100644
index 000000000..1acb6d13e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/dmxparse.c
@@ -0,0 +1,611 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * This file provides support routines and helper functions to be used
+ * by the DMX configuration file parser.
+ *
+ * Because the DMX configuration file parsing should be capable of being
+ * used in a stand-alone fashion (i.e., independent from the DMX server
+ * source tree), no dependencies on other DMX routines are made. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include "dmxparse.h"
+
+/** A general error logging routine that does not depend on the dmxLog
+ * functions. */
+void dmxConfigLog(const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ vprintf(format, args); /* RATS: All calls to dmxConfigLog from
+ * dmxparse.c and dmxprint.c use a
+ * trusted format. */
+ va_end(args);
+}
+
+void *dmxConfigAlloc(unsigned long bytes)
+{
+ void *area = malloc(bytes);
+ if (!area) {
+ dmxConfigLog("dmxConfigAlloc: out of memory\n");
+ return NULL;
+ }
+ memset(area, 0, bytes);
+ return area;
+}
+
+void *dmxConfigRealloc(void *orig, unsigned long orig_bytes,
+ unsigned long bytes)
+{
+ unsigned char *area = realloc(orig, bytes);
+ if (!area) {
+ dmxConfigLog("dmxConfigRealloc: out of memory\n");
+ return NULL;
+ }
+ memset(area + orig_bytes, 0, bytes - orig_bytes);
+ return area;
+}
+
+const char *dmxConfigCopyString(const char *string, int length)
+{
+ char *copy;
+
+ if (!length) length = strlen(string);
+ copy = dmxConfigAlloc(length + 1);
+ if (length) strncpy(copy, string, length);
+ copy[length] = '\0';
+ return copy;
+}
+
+void dmxConfigFree(void *area)
+{
+ if (area) free(area);
+}
+
+DMXConfigTokenPtr dmxConfigCreateToken(int token, int line,
+ const char *comment)
+{
+ DMXConfigTokenPtr pToken = dmxConfigAlloc(sizeof(*pToken));
+ pToken->token = token;
+ pToken->line = line;
+ pToken->comment = comment;
+ return pToken;
+}
+
+void dmxConfigFreeToken(DMXConfigTokenPtr p)
+{
+ if (!p) return;
+ dmxConfigFree((void *)p->comment);
+ dmxConfigFree(p);
+}
+
+DMXConfigStringPtr dmxConfigCreateString(int token, int line,
+ const char *comment,
+ const char *string)
+{
+ DMXConfigStringPtr pString = dmxConfigAlloc(sizeof(*pString));
+
+ pString->token = token;
+ pString->line = line;
+ pString->comment = comment;
+ pString->string = string;
+ return pString;
+}
+
+void dmxConfigFreeString(DMXConfigStringPtr p)
+{
+ DMXConfigStringPtr next;
+
+ if (!p) return;
+ do {
+ next = p->next;
+ dmxConfigFree((void *)p->comment);
+ dmxConfigFree((void *)p->string);
+ dmxConfigFree(p);
+ } while ((p = next));
+}
+
+DMXConfigNumberPtr dmxConfigCreateNumber(int token, int line,
+ const char *comment,
+ int number)
+{
+ DMXConfigNumberPtr pNumber = dmxConfigAlloc(sizeof(*pNumber));
+
+ pNumber->token = token;
+ pNumber->line = line;
+ pNumber->comment = comment;
+ pNumber->number = number;
+ return pNumber;
+}
+
+void dmxConfigFreeNumber(DMXConfigNumberPtr p)
+{
+ if (!p) return;
+ dmxConfigFree((void *)p->comment);
+ dmxConfigFree(p);
+}
+
+DMXConfigPairPtr dmxConfigCreatePair(int token, int line,
+ const char *comment,
+ int x, int y,
+ int xsign, int ysign)
+{
+ DMXConfigPairPtr pPair = dmxConfigAlloc(sizeof(*pPair));
+
+ pPair->token = token;
+ pPair->line = line;
+ pPair->comment = comment;
+ pPair->x = x;
+ pPair->y = y;
+ pPair->xsign = (xsign < 0) ? -1 : 1;
+ pPair->ysign = (ysign < 0) ? -1 : 1;
+ return pPair;
+}
+
+void dmxConfigFreePair(DMXConfigPairPtr p)
+{
+ if (!p) return;
+ dmxConfigFree((void *)p->comment);
+ dmxConfigFree(p);
+}
+
+DMXConfigCommentPtr dmxConfigCreateComment(int token, int line,
+ const char *comment)
+{
+ DMXConfigCommentPtr pComment = dmxConfigAlloc(sizeof(*pComment));
+
+ pComment->token = token;
+ pComment->line = line;
+ pComment->comment = comment;
+ return pComment;
+}
+
+void dmxConfigFreeComment(DMXConfigCommentPtr p)
+{
+ if (!p) return;
+ dmxConfigFree((void *)p->comment);
+ dmxConfigFree(p);
+}
+
+DMXConfigPartDimPtr dmxConfigCreatePartDim(DMXConfigPairPtr pDim,
+ DMXConfigPairPtr pOffset)
+{
+ DMXConfigPartDimPtr pPart = dmxConfigAlloc(sizeof(*pPart));
+ pPart->dim = pDim;
+ pPart->offset = pOffset;
+ return pPart;
+}
+
+void dmxConfigFreePartDim(DMXConfigPartDimPtr p)
+{
+ if (!p) return;
+ dmxConfigFreePair(p->dim);
+ dmxConfigFreePair(p->offset);
+ dmxConfigFree(p);
+}
+
+DMXConfigFullDimPtr dmxConfigCreateFullDim(DMXConfigPartDimPtr pScrn,
+ DMXConfigPartDimPtr pRoot)
+{
+ DMXConfigFullDimPtr pFull = dmxConfigAlloc(sizeof(*pFull));
+ pFull->scrn = pScrn;
+ pFull->root = pRoot;
+ return pFull;
+}
+
+void dmxConfigFreeFullDim(DMXConfigFullDimPtr p)
+{
+ if (!p) return;
+ dmxConfigFreePartDim(p->scrn);
+ dmxConfigFreePartDim(p->root);
+ dmxConfigFree(p);
+}
+
+DMXConfigDisplayPtr dmxConfigCreateDisplay(DMXConfigTokenPtr pStart,
+ DMXConfigStringPtr pName,
+ DMXConfigFullDimPtr pDim,
+ DMXConfigPairPtr pOrigin,
+ DMXConfigTokenPtr pEnd)
+{
+ DMXConfigDisplayPtr pDisplay = dmxConfigAlloc(sizeof(*pDisplay));
+
+ memset(pDisplay, 0, sizeof(*pDisplay));
+
+ pDisplay->start = pStart;
+ pDisplay->dname = pName;
+ pDisplay->dim = pDim;
+ pDisplay->origin = pOrigin;
+ pDisplay->end = pEnd;
+
+ pDisplay->name = pName ? pName->string : NULL;
+ pDisplay->rootXOrigin = pOrigin ? pOrigin->x : 0;
+ pDisplay->rootYOrigin = pOrigin ? pOrigin->y : 0;
+
+ if (pDim && pDim->scrn && pDim->scrn->dim) {
+ pDisplay->scrnWidth = pDim->scrn->dim->x;
+ pDisplay->scrnHeight = pDim->scrn->dim->y;
+ }
+ if (pDim && pDim->scrn && pDim->scrn->offset) {
+ pDisplay->scrnX = pDim->scrn->offset->x;
+ pDisplay->scrnY = pDim->scrn->offset->y;
+ pDisplay->scrnXSign = pDim->scrn->offset->xsign;
+ pDisplay->scrnYSign = pDim->scrn->offset->ysign;
+ }
+
+ if (pDim && pDim->root) {
+ if (pDim->root->dim) {
+ pDisplay->rootWidth = pDim->root->dim->x;
+ pDisplay->rootHeight = pDim->root->dim->y;
+ }
+ if (pDim->root->offset) {
+ pDisplay->rootX = pDim->root->offset->x;
+ pDisplay->rootY = pDim->root->offset->y;
+ pDisplay->rootXSign = pDim->root->offset->xsign;
+ pDisplay->rootYSign = pDim->root->offset->ysign;
+ }
+ } else { /* If no root specification, copy width
+ * and height from scrn -- leave offset
+ * as zero, since it is relative to
+ * scrn. */
+ pDisplay->rootWidth = pDisplay->scrnWidth;
+ pDisplay->rootHeight = pDisplay->scrnHeight;
+ }
+
+
+ return pDisplay;
+}
+
+void dmxConfigFreeDisplay(DMXConfigDisplayPtr p)
+{
+ if (!p) return;
+ dmxConfigFreeToken(p->start);
+ dmxConfigFreeString(p->dname);
+ dmxConfigFreeFullDim(p->dim);
+ dmxConfigFreeToken(p->end);
+ dmxConfigFree(p);
+}
+
+DMXConfigWallPtr dmxConfigCreateWall(DMXConfigTokenPtr pStart,
+ DMXConfigPairPtr pWallDim,
+ DMXConfigPairPtr pDisplayDim,
+ DMXConfigStringPtr pNameList,
+ DMXConfigTokenPtr pEnd)
+{
+ DMXConfigWallPtr pWall = dmxConfigAlloc(sizeof(*pWall));
+
+ pWall->start = pStart;
+ pWall->wallDim = pWallDim;
+ pWall->displayDim = pDisplayDim;
+ pWall->nameList = pNameList;
+ pWall->end = pEnd;
+
+ pWall->width = pDisplayDim ? pDisplayDim->x : 0;
+ pWall->height = pDisplayDim ? pDisplayDim->y : 0;
+ pWall->xwall = pWallDim ? pWallDim->x : 0;
+ pWall->ywall = pWallDim ? pWallDim->y : 0;
+
+ return pWall;
+}
+
+void dmxConfigFreeWall(DMXConfigWallPtr p)
+{
+ if (!p) return;
+ dmxConfigFreeToken(p->start);
+ dmxConfigFreePair(p->wallDim);
+ dmxConfigFreePair(p->displayDim);
+ dmxConfigFreeString(p->nameList);
+ dmxConfigFreeToken(p->end);
+ dmxConfigFree(p);
+}
+
+DMXConfigOptionPtr dmxConfigCreateOption(DMXConfigTokenPtr pStart,
+ DMXConfigStringPtr pOption,
+ DMXConfigTokenPtr pEnd)
+{
+ int length = 0;
+ int offset = 0;
+ DMXConfigStringPtr p;
+ DMXConfigOptionPtr option = dmxConfigAlloc(sizeof(*option));
+
+ for (p = pOption; p; p = p->next) {
+ if (p->string) length += strlen(p->string) + 1;
+ }
+
+ option->string = dmxConfigAlloc(length + 1);
+
+ for (p = pOption; p; p = p->next) {
+ if (p->string) {
+ int len = strlen(p->string);
+ strncpy(option->string + offset, p->string, len);
+ offset += len;
+ if (p->next) option->string[offset++] = ' ';
+ }
+ }
+ option->string[offset] = '\0';
+
+ option->start = pStart;
+ option->option = pOption;
+ option->end = pEnd;
+
+ return option;
+}
+
+void dmxConfigFreeOption(DMXConfigOptionPtr p)
+{
+ if (!p) return;
+ if (p->string) free(p->string);
+ dmxConfigFreeToken(p->start);
+ dmxConfigFreeString(p->option);
+ dmxConfigFreeToken(p->end);
+ dmxConfigFree(p);
+}
+
+const char **dmxConfigLookupParam(DMXConfigParamPtr p, const char *key,
+ int *argc)
+{
+ DMXConfigParamPtr pt;
+
+ for (pt = p; pt; pt = pt->next) {
+ if (pt->argv && !strcasecmp(pt->argv[0], key)) {
+ *argc = pt->argc;
+ return pt->argv;
+ }
+ }
+ *argc = 0;
+ return NULL;
+}
+
+DMXConfigParamPtr dmxConfigCreateParam(DMXConfigTokenPtr pStart,
+ DMXConfigTokenPtr pOpen,
+ DMXConfigStringPtr pParam,
+ DMXConfigTokenPtr pClose,
+ DMXConfigTokenPtr pEnd)
+{
+ DMXConfigParamPtr param = dmxConfigAlloc(sizeof(*param));
+ DMXConfigStringPtr pt;
+
+ param->argc = 0;
+ param->argv = NULL;
+ for (pt = pParam; pt; pt = pt->next) {
+ if (pt->string) {
+ param->argv = realloc(param->argv,
+ (param->argc+2) * sizeof(*param->argv));
+ param->argv[param->argc] = pt->string;
+ ++param->argc;
+ }
+ }
+ if (param->argv) param->argv[param->argc] = NULL;
+
+ param->start = pStart;
+ param->open = pOpen;
+ param->param = pParam;
+ param->close = pClose;
+ param->end = pEnd;
+
+ return param;
+}
+
+void dmxConfigFreeParam(DMXConfigParamPtr p)
+{
+ DMXConfigParamPtr next;
+
+ if (!p) return;
+ do {
+ next = p->next;
+ dmxConfigFreeToken(p->start);
+ dmxConfigFreeToken(p->open);
+ dmxConfigFreeString(p->param);
+ dmxConfigFreeToken(p->close);
+ dmxConfigFreeToken(p->end);
+ dmxConfigFree(p->argv);
+ dmxConfigFree(p);
+ } while ((p = next));
+}
+
+DMXConfigSubPtr dmxConfigCreateSub(DMXConfigType type,
+ DMXConfigCommentPtr comment,
+ DMXConfigDisplayPtr display,
+ DMXConfigWallPtr wall,
+ DMXConfigOptionPtr option,
+ DMXConfigParamPtr param)
+{
+ DMXConfigSubPtr pSub = dmxConfigAlloc(sizeof(*pSub));
+ pSub->type = type;
+ switch (type) {
+ case dmxConfigComment: pSub->comment = comment; break;
+ case dmxConfigDisplay: pSub->display = display; break;
+ case dmxConfigWall: pSub->wall = wall; break;
+ case dmxConfigOption: pSub->option = option; break;
+ case dmxConfigParam: pSub->param = param; break;
+ default: dmxConfigLog("Type %d not supported in subentry\n", type); break;
+ }
+ return pSub;
+}
+
+void dmxConfigFreeSub(DMXConfigSubPtr sub)
+{
+ DMXConfigSubPtr pt;
+
+ for (pt = sub; pt; pt = pt->next) {
+ switch (pt->type) {
+ case dmxConfigComment: dmxConfigFreeComment(pt->comment); break;
+ case dmxConfigDisplay: dmxConfigFreeDisplay(pt->display); break;
+ case dmxConfigWall: dmxConfigFreeWall(pt->wall); break;
+ case dmxConfigOption: dmxConfigFreeOption(pt->option); break;
+ case dmxConfigParam: dmxConfigFreeParam(pt->param); break;
+ default:
+ dmxConfigLog("Type %d not supported in subentry\n", pt->type);
+ break;
+ }
+ }
+ dmxConfigFree(sub);
+}
+
+DMXConfigSubPtr dmxConfigSubComment(DMXConfigCommentPtr comment)
+{
+ return dmxConfigCreateSub(dmxConfigComment, comment, NULL, NULL, NULL,
+ NULL);
+}
+
+DMXConfigSubPtr dmxConfigSubDisplay(DMXConfigDisplayPtr display)
+{
+ return dmxConfigCreateSub(dmxConfigDisplay, NULL, display, NULL, NULL,
+ NULL);
+}
+
+DMXConfigSubPtr dmxConfigSubWall(DMXConfigWallPtr wall)
+{
+ return dmxConfigCreateSub(dmxConfigWall, NULL, NULL, wall, NULL, NULL);
+}
+
+DMXConfigSubPtr dmxConfigSubOption(DMXConfigOptionPtr option)
+{
+ return dmxConfigCreateSub(dmxConfigOption, NULL, NULL, NULL, option, NULL);
+}
+
+DMXConfigSubPtr dmxConfigSubParam(DMXConfigParamPtr param)
+{
+ return dmxConfigCreateSub(dmxConfigParam, NULL, NULL, NULL, NULL, param);
+}
+
+extern DMXConfigSubPtr dmxConfigAddSub(DMXConfigSubPtr head,
+ DMXConfigSubPtr sub)
+{
+ DMXConfigSubPtr pt;
+
+ if (!head) return sub;
+ for (pt = head; pt->next; pt = pt->next);
+ pt->next = sub;
+ return head;
+}
+
+DMXConfigVirtualPtr dmxConfigCreateVirtual(DMXConfigTokenPtr pStart,
+ DMXConfigStringPtr pName,
+ DMXConfigPairPtr pDim,
+ DMXConfigTokenPtr pOpen,
+ DMXConfigSubPtr pSubentry,
+ DMXConfigTokenPtr pClose)
+{
+ DMXConfigVirtualPtr pVirtual = dmxConfigAlloc(sizeof(*pVirtual));
+
+ pVirtual->start = pStart;
+ pVirtual->vname = pName;
+ pVirtual->dim = pDim;
+ pVirtual->open = pOpen;
+ pVirtual->subentry = pSubentry;
+ pVirtual->close = pClose;
+
+ pVirtual->name = pName ? pName->string : NULL;
+ pVirtual->width = pDim ? pDim->x : 0;
+ pVirtual->height = pDim ? pDim->y : 0;
+
+ return pVirtual;
+}
+
+void dmxConfigFreeVirtual(DMXConfigVirtualPtr virtual)
+{
+ dmxConfigFreeToken(virtual->start);
+ dmxConfigFreeString(virtual->vname);
+ dmxConfigFreePair(virtual->dim);
+ dmxConfigFreeToken(virtual->open);
+ dmxConfigFreeSub(virtual->subentry);
+ dmxConfigFreeToken(virtual->close);
+ dmxConfigFree(virtual);
+}
+
+DMXConfigEntryPtr dmxConfigCreateEntry(DMXConfigType type,
+ DMXConfigCommentPtr comment,
+ DMXConfigVirtualPtr virtual)
+{
+ DMXConfigEntryPtr pEntry = dmxConfigAlloc(sizeof(*pEntry));
+ pEntry->type = type;
+ switch (type) {
+ case dmxConfigComment: pEntry->comment = comment; break;
+ case dmxConfigVirtual: pEntry->virtual = virtual; break;
+ default: dmxConfigLog("Type %d not supported in entry\n", type); break;
+ }
+ return pEntry;
+}
+
+void dmxConfigFreeEntry(DMXConfigEntryPtr entry)
+{
+ DMXConfigEntryPtr pt;
+
+ for (pt = entry; pt; pt = pt->next) {
+ switch (pt->type) {
+ case dmxConfigComment: dmxConfigFreeComment(pt->comment); break;
+ case dmxConfigVirtual: dmxConfigFreeVirtual(pt->virtual); break;
+ default:
+ dmxConfigLog("Type %d not supported in entry\n", pt->type);
+ break;
+ }
+ }
+ dmxConfigFree(entry);
+}
+
+DMXConfigEntryPtr dmxConfigAddEntry(DMXConfigEntryPtr head,
+ DMXConfigType type,
+ DMXConfigCommentPtr comment,
+ DMXConfigVirtualPtr virtual)
+{
+ DMXConfigEntryPtr child = dmxConfigCreateEntry(type, comment, virtual);
+ DMXConfigEntryPtr pt;
+
+ if (!head) return child;
+
+ for (pt = head; pt->next; pt = pt->next);
+ pt->next = child;
+
+ return head;
+}
+
+DMXConfigEntryPtr dmxConfigEntryComment(DMXConfigCommentPtr comment)
+{
+ return dmxConfigCreateEntry(dmxConfigComment, comment, NULL);
+}
+
+DMXConfigEntryPtr dmxConfigEntryVirtual(DMXConfigVirtualPtr virtual)
+{
+ return dmxConfigCreateEntry(dmxConfigVirtual, NULL, virtual);
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/dmxparse.h b/nx-X11/programs/Xserver/hw/dmx/config/dmxparse.h
new file mode 100644
index 000000000..8ea84f4e3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/dmxparse.h
@@ -0,0 +1,298 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to DMX configuration file parser. \see dmxparse.c */
+
+#ifndef _DMXPARSE_H_
+#define _DMXPARSE_H_
+
+#include <stdio.h> /* For FILE */
+
+/** Stores tokens not stored in other structures (e.g., keywords and ;) */
+typedef struct _DMXConfigToken {
+ int token;
+ int line;
+ const char *comment;
+} DMXConfigToken, *DMXConfigTokenPtr;
+
+/** Stores parsed strings. */
+typedef struct _DMXConfigString {
+ int token;
+ int line;
+ const char *comment;
+ const char *string;
+ struct _DMXConfigString *next;
+} DMXConfigString, *DMXConfigStringPtr;
+
+/** Stores parsed numbers. */
+typedef struct _DMXConfigNumber {
+ int token;
+ int line;
+ const char *comment;
+ int number;
+} DMXConfigNumber, *DMXConfigNumberPtr;
+
+/** Stores parsed pairs (e.g., x y) */
+typedef struct _DMXConfigPair {
+ int token;
+ int line;
+ const char *comment;
+ int x;
+ int y;
+ int xsign;
+ int ysign;
+} DMXConfigPair, *DMXConfigPairPtr;
+
+/** Stores parsed comments not stored with a token. */
+typedef struct _DMXConfigComment {
+ int token;
+ int line;
+ const char *comment;
+} DMXConfigComment, *DMXConfigCommentPtr;
+
+typedef enum {
+ dmxConfigComment,
+ dmxConfigVirtual,
+ dmxConfigDisplay,
+ dmxConfigWall,
+ dmxConfigOption,
+ dmxConfigParam
+} DMXConfigType;
+
+/** Stores a geometry specification. */
+typedef struct _DMXConfigPartDim {
+ DMXConfigPairPtr dim;
+ DMXConfigPairPtr offset;
+} DMXConfigPartDim, *DMXConfigPartDimPtr;
+
+/** Stores a pair of geometry specifications. */
+typedef struct _DMXConfigFullDim {
+ DMXConfigPartDimPtr scrn;
+ DMXConfigPartDimPtr root;
+} DMXConfigFullDim, *DMXConfigFullDimPtr;
+
+/** Stores parsed display information. */
+typedef struct _DMXConfigDisplay {
+ /* Summary information */
+ const char *name;
+ /* Screen Window Geometry */
+ int scrnWidth, scrnHeight;
+ int scrnX, scrnY;
+ int scrnXSign, scrnYSign;
+ /* Root Window Geometry */
+ int rootWidth, rootHeight;
+ int rootX, rootY;
+ int rootXSign, rootYSign;
+ /* Origin in global space */
+ int rootXOrigin, rootYOrigin;
+
+ /* Raw configuration information */
+ DMXConfigTokenPtr start;
+ DMXConfigStringPtr dname;
+ DMXConfigFullDimPtr dim;
+ DMXConfigPairPtr origin;
+ DMXConfigTokenPtr end;
+} DMXConfigDisplay, *DMXConfigDisplayPtr;
+
+/** Stores parsed wall information. */
+typedef struct _DMXConfigWall {
+ /* Summary information */
+ int width, height; /* dimensions of displays */
+ int xwall, ywall; /* dimensions of wall, in tiles */
+
+
+ /* Raw configuration informaiton */
+ DMXConfigTokenPtr start;
+ DMXConfigPairPtr wallDim;
+ DMXConfigPairPtr displayDim;
+ DMXConfigStringPtr nameList;
+ DMXConfigTokenPtr end;
+} DMXConfigWall, *DMXConfigWallPtr;
+
+/** Stores parsed option information. */
+typedef struct _DMXConfigOption {
+ /* Summary information */
+ char *string;
+
+ /* Raw configuration informaiton */
+ DMXConfigTokenPtr start;
+ DMXConfigStringPtr option;
+ DMXConfigTokenPtr end;
+} DMXConfigOption, *DMXConfigOptionPtr;
+
+/** Stores parsed param information. */
+typedef struct _DMXConfigParam {
+ int argc;
+ const char **argv;
+
+ DMXConfigTokenPtr start;
+ DMXConfigTokenPtr open;
+ DMXConfigStringPtr param;
+ DMXConfigTokenPtr close;
+ DMXConfigTokenPtr end; /* Either open/close OR end */
+ struct _DMXConfigParam *next;
+} DMXConfigParam, *DMXConfigParamPtr;
+
+/** Stores options under an entry (subentry). */
+typedef struct _DMXConfigSub {
+ DMXConfigType type;
+ DMXConfigCommentPtr comment;
+ DMXConfigDisplayPtr display;
+ DMXConfigWallPtr wall;
+ DMXConfigOptionPtr option;
+ DMXConfigParamPtr param;
+ struct _DMXConfigSub *next;
+} DMXConfigSub, *DMXConfigSubPtr;
+
+/** Stores parsed virtual information. */
+typedef struct _DMXConfigVirtual {
+ /* Summary information */
+ const char *name;
+ int width, height;
+
+ /* Raw configuration information */
+ DMXConfigTokenPtr start;
+ DMXConfigStringPtr vname;
+ DMXConfigPairPtr dim;
+ DMXConfigTokenPtr open;
+ DMXConfigSubPtr subentry;
+ DMXConfigTokenPtr close;
+} DMXConfigVirtual, *DMXConfigVirtualPtr;
+
+/** Heads entry storage. */
+typedef struct _DMXConfigEntry {
+ DMXConfigType type;
+ DMXConfigCommentPtr comment;
+ DMXConfigVirtualPtr virtual;
+ struct _DMXConfigEntry *next;
+} DMXConfigEntry, *DMXConfigEntryPtr;
+
+extern DMXConfigEntryPtr dmxConfigEntry;
+
+extern int yylex(void);
+extern int yydebug;
+extern void yyerror(const char *message);
+
+extern void dmxConfigLog(const char *format, ...);
+extern void *dmxConfigAlloc(unsigned long bytes);
+extern void *dmxConfigRealloc(void *orig,
+ unsigned long orig_bytes,
+ unsigned long bytes);
+extern const char *dmxConfigCopyString(const char *string,
+ int length);
+extern void dmxConfigFree(void *area);
+extern DMXConfigTokenPtr dmxConfigCreateToken(int token, int line,
+ const char *comment);
+extern void dmxConfigFreeToken(DMXConfigTokenPtr p);
+extern DMXConfigStringPtr dmxConfigCreateString(int token, int line,
+ const char *comment,
+ const char *string);
+extern void dmxConfigFreeString(DMXConfigStringPtr p);
+extern DMXConfigNumberPtr dmxConfigCreateNumber(int token, int line,
+ const char *comment,
+ int number);
+extern void dmxConfigFreeNumber(DMXConfigNumberPtr p);
+extern DMXConfigPairPtr dmxConfigCreatePair(int token, int line,
+ const char *comment,
+ int x, int y,
+ int xsign, int ysign);
+extern void dmxConfigFreePair(DMXConfigPairPtr p);
+extern DMXConfigCommentPtr dmxConfigCreateComment(int token, int line,
+ const char *comment);
+extern void dmxConfigFreeComment(DMXConfigCommentPtr p);
+extern DMXConfigPartDimPtr dmxConfigCreatePartDim(DMXConfigPairPtr pDim,
+ DMXConfigPairPtr pOffset);
+extern void dmxConfigFreePartDim(DMXConfigPartDimPtr p);
+extern DMXConfigFullDimPtr dmxConfigCreateFullDim(DMXConfigPartDimPtr pScrn,
+ DMXConfigPartDimPtr pRoot);
+extern void dmxConfigFreeFullDim(DMXConfigFullDimPtr p);
+extern DMXConfigDisplayPtr dmxConfigCreateDisplay(DMXConfigTokenPtr pStart,
+ DMXConfigStringPtr pName,
+ DMXConfigFullDimPtr pDim,
+ DMXConfigPairPtr pOrigin,
+ DMXConfigTokenPtr pEnd);
+extern void dmxConfigFreeDisplay(DMXConfigDisplayPtr p);
+extern DMXConfigWallPtr dmxConfigCreateWall(DMXConfigTokenPtr pStart,
+ DMXConfigPairPtr pWallDim,
+ DMXConfigPairPtr pDisplayDim,
+ DMXConfigStringPtr pNameList,
+ DMXConfigTokenPtr pEnd);
+extern void dmxConfigFreeWall(DMXConfigWallPtr p);
+extern DMXConfigOptionPtr dmxConfigCreateOption(DMXConfigTokenPtr pStart,
+ DMXConfigStringPtr pOption,
+ DMXConfigTokenPtr pEnd);
+extern void dmxConfigFreeOption(DMXConfigOptionPtr p);
+extern DMXConfigParamPtr dmxConfigCreateParam(DMXConfigTokenPtr pStart,
+ DMXConfigTokenPtr pOpen,
+ DMXConfigStringPtr pParam,
+ DMXConfigTokenPtr pClose,
+ DMXConfigTokenPtr pEnd);
+extern void dmxConfigFreeParam(DMXConfigParamPtr p);
+extern const char **dmxConfigLookupParam(DMXConfigParamPtr p,
+ const char *key,
+ int *argc);
+extern DMXConfigSubPtr dmxConfigCreateSub(DMXConfigType type,
+ DMXConfigCommentPtr comment,
+ DMXConfigDisplayPtr display,
+ DMXConfigWallPtr wall,
+ DMXConfigOptionPtr option,
+ DMXConfigParamPtr param);
+extern void dmxConfigFreeSub(DMXConfigSubPtr sub);
+extern DMXConfigSubPtr dmxConfigSubComment(DMXConfigCommentPtr comment);
+extern DMXConfigSubPtr dmxConfigSubDisplay(DMXConfigDisplayPtr display);
+extern DMXConfigSubPtr dmxConfigSubWall(DMXConfigWallPtr wall);
+extern DMXConfigSubPtr dmxConfigSubOption(DMXConfigOptionPtr option);
+extern DMXConfigSubPtr dmxConfigSubParam(DMXConfigParamPtr param);
+extern DMXConfigSubPtr dmxConfigAddSub(DMXConfigSubPtr head,
+ DMXConfigSubPtr sub);
+extern DMXConfigVirtualPtr dmxConfigCreateVirtual(DMXConfigTokenPtr pStart,
+ DMXConfigStringPtr pName,
+ DMXConfigPairPtr pDim,
+ DMXConfigTokenPtr pOpen,
+ DMXConfigSubPtr pSubentry,
+ DMXConfigTokenPtr pClose);
+extern void dmxConfigFreeVirtual(DMXConfigVirtualPtr virtual);
+extern DMXConfigEntryPtr dmxConfigCreateEntry(DMXConfigType type,
+ DMXConfigCommentPtr comment,
+ DMXConfigVirtualPtr virtual);
+extern void dmxConfigFreeEntry(DMXConfigEntryPtr entry);
+extern DMXConfigEntryPtr dmxConfigAddEntry(DMXConfigEntryPtr head,
+ DMXConfigType type,
+ DMXConfigCommentPtr comment,
+ DMXConfigVirtualPtr virtual);
+extern DMXConfigEntryPtr dmxConfigEntryComment(DMXConfigCommentPtr comment);
+extern DMXConfigEntryPtr dmxConfigEntryVirtual(DMXConfigVirtualPtr virtual);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/dmxprint.c b/nx-X11/programs/Xserver/hw/dmx/config/dmxprint.c
new file mode 100644
index 000000000..ed3fc213d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/dmxprint.c
@@ -0,0 +1,456 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * This file provides support routines and helper functions to be used
+ * to pretty-print DMX configurations.
+ *
+ * Because the DMX configuration file parsing should be capable of being
+ * used in a stand-alone fashion (i.e., independent from the DMX server
+ * source tree), no dependencies on other DMX routines are made. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmxconfig.h"
+#include "dmxparse.h"
+#include "dmxprint.h"
+#include "parser.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <ctype.h>
+
+static FILE *str = NULL;
+static int indent = 0;
+static int pos = 0;
+
+/** Stack of indentation information used for pretty-printing
+ * configuration information. */
+static struct stack {
+ int base;
+ int comment;
+ int step;
+ struct stack *next;
+} *stack, initialStack = { 0, 0, 4, NULL };
+
+static void dmxConfigIndent(void)
+{
+ int i;
+ if (indent < 0) indent = 0;
+ if (indent > 40) indent = 40;
+ for (i = 0; i < indent; i++) fprintf(str, " ");
+}
+
+static void dmxConfigNewline(void)
+{
+ if (pos) fprintf(str, "\n");
+ pos = 0;
+}
+
+static void dmxConfigPushState(int base, int comment, int step)
+{
+ struct stack *new = dmxConfigAlloc(sizeof(*new));
+ new->base = base;
+ new->comment = comment;
+ new->step = step;
+ new->next = stack;
+ stack = new;
+ indent = base;
+ dmxConfigNewline();
+}
+
+static void dmxConfigPushComment(void)
+{
+ if (stack) indent = stack->comment;
+}
+
+static void dmxConfigPushStep(void)
+{
+ if (stack) indent = stack->step;
+}
+
+static void dmxConfigPopState(void)
+{
+ struct stack *old = stack;
+
+ if (!stack) return;
+ indent = old->base;
+ stack = old->next;
+ if (!stack) dmxConfigLog("Stack underflow\n");
+ dmxConfigFree(old);
+ dmxConfigNewline();
+}
+
+static void dmxConfigOutput(int addSpace, int doNewline, const char *comment,
+ const char *format, ...)
+{
+ va_list args;
+
+ if (!pos) dmxConfigIndent();
+ else if (addSpace) fprintf(str, " ");
+
+ if (format) {
+ va_start(args, format);
+ /* RATS: This hasn't been audited -- it
+ * could probably result in a buffer
+ * overflow. */
+ pos += vfprintf(str, format, args); /* assumes no newlines! */
+ va_end(args);
+ }
+
+ if (comment) {
+ if (pos) fprintf(str, " ");
+ pos += fprintf(str, "#%s", comment);
+ dmxConfigNewline();
+ dmxConfigPushComment();
+ } else if (doNewline) dmxConfigNewline();
+}
+
+static void dmxConfigPrintComment(DMXConfigCommentPtr p)
+{
+ dmxConfigOutput(1, 1, p->comment, NULL);
+}
+
+static void dmxConfigPrintTokenFlag(DMXConfigTokenPtr p, int flag)
+{
+ if (!p) return;
+ switch (p->token) {
+ case T_VIRTUAL:
+ dmxConfigPushState(0, 4, 4);
+ dmxConfigOutput(0, 0, p->comment, "virtual");
+ break;
+ case T_DISPLAY:
+ dmxConfigPushState(4, 12, 16);
+ dmxConfigOutput(0, 0, p->comment, "display");
+ break;
+ case T_WALL:
+ dmxConfigPushState(4, 12, 16);
+ dmxConfigOutput(0, 0, p->comment, "wall");
+ break;
+ case T_OPTION:
+ dmxConfigPushState(4, 12, 16);
+ dmxConfigOutput(0, 0, p->comment, "option");
+ break;
+ case T_PARAM:
+ dmxConfigPushState(4, 8, 12);
+ dmxConfigOutput(0, 0, p->comment, "param");
+ break;
+ case ';':
+ dmxConfigOutput(0, 1, p->comment, ";");
+ if (flag) dmxConfigPopState();
+ break;
+ case '{':
+ dmxConfigOutput(1, 1, p->comment, "{");
+ dmxConfigPushStep();
+ break;
+ case '}':
+ if (flag) dmxConfigPopState();
+ dmxConfigOutput(0, 1, p->comment, "}");
+ break;
+ case '/':
+ dmxConfigOutput(1, 0, NULL, "/");
+ break;
+ default:
+ dmxConfigLog("unknown token %d on line %d\n", p->token, p->line);
+ }
+}
+
+static void dmxConfigPrintToken(DMXConfigTokenPtr p)
+{
+ dmxConfigPrintTokenFlag(p, 1);
+}
+
+static void dmxConfigPrintTokenNopop(DMXConfigTokenPtr p)
+{
+ dmxConfigPrintTokenFlag(p, 0);
+}
+
+static int dmxConfigPrintQuotedString(const char *s)
+{
+ const char *pt;
+
+ if (!s || !s[0]) return 1; /* Quote empty string */
+ for (pt = s; *pt; ++pt) if (isspace(*pt)) return 1;
+ return 0;
+}
+
+static void dmxConfigPrintString(DMXConfigStringPtr p, int quote)
+{
+ DMXConfigStringPtr pt;
+
+ if (!p) return;
+ for (pt = p; pt; pt = pt->next) {
+ if (quote && dmxConfigPrintQuotedString(pt->string)) {
+ dmxConfigOutput(1, 0, pt->comment, "\"%s\"",
+ pt->string ? pt->string : "");
+ } else
+ dmxConfigOutput(1, 0, pt->comment, "%s",
+ pt->string ? pt->string : "");
+ }
+}
+
+static int dmxConfigPrintPair(DMXConfigPairPtr p, int addSpace)
+{
+ const char *format = NULL;
+
+ if (!p) return 0;
+ switch (p->token) {
+ case T_ORIGIN: format = "@%dx%d"; break;
+ case T_DIMENSION: format = "%dx%d"; break;
+ case T_OFFSET: format = "%c%d%c%d"; break;
+ }
+ if (p->token == T_OFFSET) {
+ if (!p->comment && !p->x && !p->y && p->xsign >= 0 && p->ysign >= 0)
+ return 0;
+ dmxConfigOutput(addSpace, 0, p->comment, format,
+ p->xsign < 0 ? '-' : '+', p->x,
+ p->ysign < 0 ? '-' : '+', p->y);
+ } else {
+ if (!p->comment && !p->x && !p->y) return 0;
+ dmxConfigOutput(addSpace, 0, p->comment, format, p->x, p->y);
+ }
+ return 1;
+}
+
+static void dmxConfigPrintDisplay(DMXConfigDisplayPtr p)
+{
+ DMXConfigToken dummyStart = { T_DISPLAY, 0, NULL };
+ DMXConfigToken dummyEnd = { ';', 0, NULL };
+ DMXConfigToken dummySep = { '/', 0, NULL };
+ DMXConfigString dummyName = { T_STRING, 0, NULL, NULL, NULL };
+ DMXConfigPair dummySDim = { T_DIMENSION, 0, NULL, 0, 0, 0, 0 };
+ DMXConfigPair dummySOffset = { T_OFFSET, 0, NULL, 0, 0, 0, 0 };
+ DMXConfigPair dummyRDim = { T_DIMENSION, 0, NULL, 0, 0, 0, 0 };
+ DMXConfigPair dummyROffset = { T_OFFSET, 0, NULL, 0, 0, 0, 0 };
+ DMXConfigPair dummyOrigin = { T_ORIGIN, 0, NULL, 0, 0, 0, 0 };
+ int output;
+
+ if (p->dname) p->dname->string = p->name;
+ else dummyName.string = p->name;
+
+ if (p->dim && p->dim->scrn && p->dim->scrn->dim) {
+ p->dim->scrn->dim->x = p->scrnWidth;
+ p->dim->scrn->dim->y = p->scrnHeight;
+ } else {
+ dummySDim.x = p->scrnWidth;
+ dummySDim.y = p->scrnHeight;
+ }
+
+ if (p->dim && p->dim->scrn && p->dim->scrn->offset) {
+ p->dim->scrn->offset->x = p->scrnX;
+ p->dim->scrn->offset->y = p->scrnY;
+ } else {
+ dummySOffset.x = p->scrnX;
+ dummySOffset.y = p->scrnY;
+ }
+
+ if (p->dim && p->dim->root && p->dim->root->dim) {
+ p->dim->root->dim->x = p->rootWidth;
+ p->dim->root->dim->y = p->rootHeight;
+ } else {
+ dummyRDim.x = p->rootWidth;
+ dummyRDim.y = p->rootHeight;
+ }
+
+ if (p->dim && p->dim->root && p->dim->root->offset) {
+ p->dim->root->offset->x = p->rootX;
+ p->dim->root->offset->y = p->rootY;
+ } else {
+ dummyROffset.x = p->rootX;
+ dummyROffset.y = p->rootY;
+ }
+
+ if (p->origin) {
+ p->origin->x = p->rootXOrigin, p->origin->y = p->rootYOrigin;
+ p->origin->xsign = p->rootXSign, p->origin->ysign = p->rootYSign;
+ } else {
+ dummyOrigin.x = p->rootXOrigin, dummyOrigin.y = p->rootYOrigin;
+ dummyOrigin.xsign = p->rootXSign, dummyOrigin.ysign = p->rootYSign;
+ }
+
+ dmxConfigPrintToken(p->start ? p->start : &dummyStart);
+ dmxConfigPrintString(p->dname ? p->dname : &dummyName, 1);
+
+ if (p->dim && p->dim->scrn && p->dim->scrn->dim)
+ output = dmxConfigPrintPair(p->dim->scrn->dim, 1);
+ else
+ output = dmxConfigPrintPair(&dummySDim, 1);
+ if (p->dim && p->dim->scrn && p->dim->scrn->offset)
+ dmxConfigPrintPair(p->dim->scrn->offset, !output);
+ else
+ dmxConfigPrintPair(&dummySOffset, !output);
+
+ if (p->scrnWidth != p->rootWidth
+ || p->scrnHeight != p->rootHeight
+ || p->rootX
+ || p->rootY) {
+ dmxConfigPrintToken(&dummySep);
+ if (p->dim && p->dim->root && p->dim->root->dim)
+ output = dmxConfigPrintPair(p->dim->root->dim, 1);
+ else
+ output = dmxConfigPrintPair(&dummyRDim, 1);
+ if (p->dim && p->dim->root && p->dim->root->offset)
+ dmxConfigPrintPair(p->dim->root->offset, !output);
+ else
+ dmxConfigPrintPair(&dummyROffset, !output);
+ }
+
+ dmxConfigPrintPair(p->origin ? p->origin : &dummyOrigin, 1);
+ dmxConfigPrintToken(p->end ? p->end : &dummyEnd);
+}
+
+static void dmxConfigPrintWall(DMXConfigWallPtr p)
+{
+ dmxConfigPrintToken(p->start);
+ dmxConfigPrintPair(p->wallDim, 1);
+ dmxConfigPrintPair(p->displayDim, 1);
+ dmxConfigPrintString(p->nameList, 1);
+ dmxConfigPrintToken(p->end);
+}
+
+static void dmxConfigPrintOption(DMXConfigOptionPtr p)
+{
+ DMXConfigToken dummyStart = { T_OPTION, 0, NULL };
+ DMXConfigString dummyOption = { T_STRING, 0, NULL, NULL, NULL };
+ DMXConfigToken dummyEnd = { ';', 0, NULL };
+
+ dummyOption.string = p->string;
+
+ dmxConfigPrintToken(p->start ? p->start : &dummyStart);
+ dmxConfigPrintString(&dummyOption, 0);
+ dmxConfigPrintToken(p->end ? p->end : &dummyEnd);
+}
+
+static void dmxConfigPrintParam(DMXConfigParamPtr p)
+{
+ if (!p) return;
+ if (p->start) {
+ if (p->open && p->close) {
+ dmxConfigPrintToken(p->start);
+ dmxConfigPrintToken(p->open);
+ dmxConfigPrintParam(p->next);
+ dmxConfigPrintToken(p->close);
+ } else if (p->end && p->param) {
+ dmxConfigPrintToken(p->start);
+ dmxConfigPrintString(p->param, 1);
+ dmxConfigPrintToken(p->end);
+ } else
+ dmxConfigLog("dmxConfigPrintParam: cannot handle format (a)\n");
+ } else if (p->end && p->param) {
+ dmxConfigPrintString(p->param, 1);
+ dmxConfigPrintTokenNopop(p->end);
+ dmxConfigPrintParam(p->next);
+ } else
+ dmxConfigLog("dmxConfigPrintParam: cannot handle format (b)\n");
+}
+
+static void dmxConfigPrintSub(DMXConfigSubPtr p)
+{
+ DMXConfigSubPtr pt;
+
+ if (!p) return;
+ for (pt = p; pt; pt = pt->next) {
+ switch (pt->type) {
+ case dmxConfigComment: dmxConfigPrintComment(pt->comment); break;
+ case dmxConfigDisplay: dmxConfigPrintDisplay(pt->display); break;
+ case dmxConfigWall: dmxConfigPrintWall(pt->wall); break;
+ case dmxConfigOption: dmxConfigPrintOption(pt->option); break;
+ case dmxConfigParam: dmxConfigPrintParam(pt->param); break;
+ default:
+ dmxConfigLog("dmxConfigPrintSub:"
+ " cannot handle type %d in subentry\n", pt->type);
+ }
+ }
+}
+
+static void dmxConfigPrintVirtual(DMXConfigVirtualPtr p)
+{
+ DMXConfigToken dummyStart = { T_VIRTUAL, 0, NULL };
+ DMXConfigToken dummyOpen = { '{', 0, NULL };
+ DMXConfigToken dummyClose = { '}', 0, NULL };
+ DMXConfigString dummyName = { T_STRING, 0, NULL, NULL, NULL };
+ DMXConfigPair dummyDim = { T_DIMENSION, 0, NULL, 0, 0 };
+
+ if (p->vname) p->vname->string = p->name;
+ else dummyName.string = p->name;
+
+ if (p->dim) p->dim->x = p->width, p->dim->y = p->height;
+ else dummyDim.x = p->width, dummyDim.y = p->height;
+
+
+ dmxConfigPrintToken(p->start ? p->start : &dummyStart);
+ dmxConfigPrintString(p->vname ? p->vname : &dummyName, 1);
+ dmxConfigPrintPair(p->dim ? p->dim : &dummyDim, 1);
+ dmxConfigPrintToken(p->open ? p->open : &dummyOpen);
+ dmxConfigPrintSub(p->subentry);
+ dmxConfigPrintToken(p->close ? p->close : &dummyClose);
+}
+
+/** The configuration information in \a entry will be pretty-printed to
+ * the \a stream. If \a stream is NULL, then stdout will be used. */
+void dmxConfigPrint(FILE *stream, DMXConfigEntryPtr entry)
+{
+ DMXConfigEntryPtr pt;
+
+ if (!stream) str = stdout;
+ else str = stream;
+
+ stack = &initialStack;
+
+ for (pt = entry; pt; pt = pt->next) {
+ switch (pt->type) {
+ case dmxConfigComment: dmxConfigPrintComment(pt->comment); break;
+ case dmxConfigVirtual: dmxConfigPrintVirtual(pt->virtual); break;
+ default:
+ dmxConfigLog("dmxConfigPrint: cannot handle type %d in entry\n",
+ pt->type);
+ }
+ }
+ if (pos) dmxConfigNewline();
+}
+
+/** The configuration information in \a p will be pretty-printed to the
+ * \a stream. If \a stream is NULL, then stdout will be used. */
+void dmxConfigVirtualPrint(FILE *stream, DMXConfigVirtualPtr p)
+{
+ if (!stream) str = stdout;
+ else str = stream;
+
+ stack = &initialStack;
+
+ dmxConfigPrintVirtual(p);
+ if (pos) dmxConfigNewline();
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/dmxprint.h b/nx-X11/programs/Xserver/hw/dmx/config/dmxprint.h
new file mode 100644
index 000000000..b68c29620
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/dmxprint.h
@@ -0,0 +1,44 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to DMX configuration file pretty-printer. \see dmxprint.c */
+
+#ifndef _DMXPRINT_H_
+#define _DMXPRINT_H_
+
+void dmxConfigPrint(FILE *str, DMXConfigEntryPtr entry);
+void dmxConfigVirtualPrint(FILE *str, DMXConfigVirtualPtr p);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/dmxtodmx.c b/nx-X11/programs/Xserver/hw/dmx/config/dmxtodmx.c
new file mode 100644
index 000000000..706c49908
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/dmxtodmx.c
@@ -0,0 +1,50 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ * This is a simple filter for testing.
+ */
+
+#include "dmxconfig.h"
+#include "dmxparse.h"
+#include "dmxprint.h"
+#include "dmxcompat.h"
+
+extern int yyparse(void);
+extern FILE *yyin;
+
+int main(int argc, char **argv)
+{
+ yydebug = 0;
+ yyparse();
+ dmxConfigPrint(stdout, dmxConfigEntry);
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/dmxtodmx.man b/nx-X11/programs/Xserver/hw/dmx/config/dmxtodmx.man
new file mode 100644
index 000000000..68c7f5b40
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/dmxtodmx.man
@@ -0,0 +1,41 @@
+.\" $XFree86$
+.\" Copyright 2002 Red Hat Inc., Durham, North Carolina.
+.\" All Rights Reserved.
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation on the rights to use, copy, modify, merge,
+.\" publish, distribute, sublicense, and/or sell copies of the Software,
+.\" and to permit persons to whom the Software is furnished to do so,
+.\" subject to the following conditions:
+.\"
+.\" The above copyright notice and this permission notice (including the
+.\" next paragraph) shall be included in all copies or substantial
+.\" portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+.\" NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+.\" BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+.\" ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+.\" CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+.\" SOFTWARE.
+.\"
+.\" Authors:
+.\" Rickard E. (Rik) Faith <faith@redhat.com>
+.\"
+.TH dmxtodmx 1 __vendorversion__
+.SH NAME
+dmxtodmx - dmx configuration file parser and printer
+.SH SYNOPSIS
+.B dmxtodmx
+.SH DESCRIPTION
+.I dmxtodmx
+reads the standard input, parsing a configuration file for the
+.I Xdmx
+distributed multi-head X server. After a successful parse, the file is
+pretty-printed to standard output.
+.SH "SEE ALSO"
+Xdmx(1), vdltodmx(1), xdmxconfig(1)
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/parser.y b/nx-X11/programs/Xserver/hw/dmx/config/parser.y
new file mode 100644
index 000000000..ac2441017
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/parser.y
@@ -0,0 +1,226 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+%{
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmxparse.h"
+#include <string.h>
+#include <stdlib.h>
+#define YYDEBUG 1
+#define YYERROR_VERBOSE
+#define YY_USE_PROTOS
+
+DMXConfigEntryPtr dmxConfigEntry = NULL;
+#define APPEND(type, h, t) \
+{ \
+ type pt; \
+ for (pt = h; pt->next; pt = pt->next); \
+ pt->next = t; \
+}
+%}
+
+%union {
+ DMXConfigTokenPtr token;
+ DMXConfigStringPtr string;
+ DMXConfigNumberPtr number;
+ DMXConfigPairPtr pair;
+ DMXConfigFullDimPtr fdim;
+ DMXConfigPartDimPtr pdim;
+ DMXConfigDisplayPtr display;
+ DMXConfigWallPtr wall;
+ DMXConfigOptionPtr option;
+ DMXConfigParamPtr param;
+ DMXConfigCommentPtr comment;
+ DMXConfigSubPtr subentry;
+ DMXConfigVirtualPtr virtual;
+ DMXConfigEntryPtr entry;
+}
+
+ /* Terminals */
+%token <token> '{' '}' ';' '/' T_VIRTUAL T_DISPLAY T_WALL T_OPTION T_PARAM
+%token <string> T_STRING
+%token <pair> T_DIMENSION T_OFFSET T_ORIGIN
+%token <comment> T_COMMENT T_LINE_COMMENT
+
+ /* Non-termials */
+%type <token> Display Wall Terminal Open Close
+%type <string> NameList Name
+%type <pair> Dimension Offset Origin
+%type <pdim> PartialDim
+%type <fdim> FullDim
+%type <display> DisplayEntry
+%type <option> OptionEntry
+%type <param> ParamEntry ParamList Param
+%type <subentry> SubList Sub
+%type <wall> WallEntry
+%type <virtual> Virtual
+%type <entry> Program EntryList Entry
+
+%%
+
+Program : EntryList { dmxConfigEntry = $1; }
+ ;
+
+EntryList : Entry
+ | EntryList Entry { APPEND(DMXConfigEntryPtr,$1,$2); $$ = $1; }
+ ;
+
+Entry : Virtual { $$ = dmxConfigEntryVirtual($1); }
+ | T_LINE_COMMENT { $$ = dmxConfigEntryComment($1); }
+ ;
+
+Virtual : T_VIRTUAL Open SubList Close
+ { $$ = dmxConfigCreateVirtual($1, NULL, NULL, $2, $3, $4); }
+ | T_VIRTUAL Dimension Open SubList Close
+ { $$ = dmxConfigCreateVirtual($1, NULL, $2, $3, $4, $5); }
+ | T_VIRTUAL Name Open SubList Close
+ { $$ = dmxConfigCreateVirtual($1, $2, NULL, $3, $4, $5); }
+ | T_VIRTUAL Name Dimension Open SubList Close
+ { $$ = dmxConfigCreateVirtual($1, $2, $3, $4, $5, $6 ); }
+ ;
+
+SubList : Sub
+ | SubList Sub { APPEND(DMXConfigSubPtr,$1,$2); $$ = $1; }
+ ;
+
+Sub : T_LINE_COMMENT { $$ = dmxConfigSubComment($1); }
+ | DisplayEntry { $$ = dmxConfigSubDisplay($1); }
+ | WallEntry { $$ = dmxConfigSubWall($1); }
+ | OptionEntry { $$ = dmxConfigSubOption($1); }
+ | ParamEntry { $$ = dmxConfigSubParam($1); }
+ ;
+
+OptionEntry : T_OPTION NameList Terminal
+ { $$ = dmxConfigCreateOption($1, $2, $3); }
+ ;
+
+ParamEntry : T_PARAM NameList Terminal
+ { $$ = dmxConfigCreateParam($1, NULL, $2, NULL, $3); }
+ | T_PARAM Open ParamList Close
+ { $$ = dmxConfigCreateParam($1, $2, NULL, $4, NULL);
+ $$->next = $3;
+ }
+ ;
+
+ParamList : Param
+ | ParamList Param { APPEND(DMXConfigParamPtr,$1,$2); $$ = $1; }
+ ;
+
+Param : NameList Terminal
+ { $$ = dmxConfigCreateParam(NULL, NULL, $1, NULL, $2); }
+ ;
+
+PartialDim : Dimension Offset
+ { $$ = dmxConfigCreatePartDim($1, $2); }
+ | Dimension
+ { $$ = dmxConfigCreatePartDim($1, NULL); }
+ | Offset
+ { $$ = dmxConfigCreatePartDim(NULL, $1); }
+ ;
+
+FullDim : PartialDim '/' PartialDim
+ { $$ = dmxConfigCreateFullDim($1, $3); }
+ | '/' PartialDim
+ { $$ = dmxConfigCreateFullDim(NULL, $2); }
+ | PartialDim
+ { $$ = dmxConfigCreateFullDim($1, NULL); }
+ ;
+
+DisplayEntry : Display Name FullDim Origin Terminal
+ { $$ = dmxConfigCreateDisplay($1, $2, $3, $4, $5); }
+ | Display FullDim Origin Terminal
+ { $$ = dmxConfigCreateDisplay($1, NULL, $2, $3, $4); }
+ | Display Name Origin Terminal
+ { $$ = dmxConfigCreateDisplay($1, $2, NULL, $3, $4); }
+
+ | Display Name FullDim Terminal
+ { $$ = dmxConfigCreateDisplay($1, $2, $3, NULL, $4); }
+ | Display FullDim Terminal
+ { $$ = dmxConfigCreateDisplay($1, NULL, $2, NULL, $3); }
+ | Display Name Terminal
+ { $$ = dmxConfigCreateDisplay($1, $2, NULL, NULL, $3); }
+ | Display Terminal
+ { $$ = dmxConfigCreateDisplay($1, NULL, NULL, NULL, $2); }
+ ;
+
+WallEntry : Wall Dimension Dimension NameList Terminal
+ { $$ = dmxConfigCreateWall($1, $2, $3, $4, $5); }
+ | Wall Dimension NameList Terminal
+ { $$ = dmxConfigCreateWall($1, $2, NULL, $3, $4); }
+ | Wall NameList Terminal
+ { $$ = dmxConfigCreateWall($1, NULL, NULL, $2, $3); }
+ ;
+
+Display : T_DISPLAY
+ | T_DISPLAY T_COMMENT { $$ = $1; $$->comment = $2->comment; }
+ ;
+
+Name : T_STRING
+ | T_STRING T_COMMENT { $$ = $1; $$->comment = $2->comment; }
+ ;
+
+Dimension : T_DIMENSION
+ | T_DIMENSION T_COMMENT { $$ = $1; $$->comment = $2->comment; }
+ ;
+
+Offset : T_OFFSET
+ | T_OFFSET T_COMMENT { $$ = $1; $$->comment = $2->comment; }
+ ;
+
+Origin : T_ORIGIN
+ | T_ORIGIN T_COMMENT { $$ = $1; $$->comment = $2->comment; }
+ ;
+
+Terminal : ';'
+ | ';' T_COMMENT { $$ = $1; $$->comment = $2->comment; }
+ ;
+
+Open : '{'
+ | '{' T_COMMENT { $$ = $1; $$->comment = $2->comment; }
+ ;
+
+Close : '}'
+ | '}' T_COMMENT { $$ = $1; $$->comment = $2->comment; }
+ ;
+
+Wall : T_WALL
+ | T_WALL T_COMMENT { $$ = $1; $$->comment = $2->comment; }
+ ;
+
+NameList : Name
+ | NameList Name { APPEND(DMXConfigStringPtr, $1, $2); $$ = $1; }
+ ;
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/scanner.l b/nx-X11/programs/Xserver/hw/dmx/config/scanner.l
new file mode 100644
index 000000000..ec450243a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/scanner.l
@@ -0,0 +1,183 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+%{
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmxparse.h"
+#include "parser.h"
+#include <string.h>
+#include <ctype.h>
+static int getdimension(int token, const char *text, int leng);
+static int getstring(int token, const char *text, int leng);
+static int gettoken(int token, const char *text, int leng);
+static int getcomment(int token, const char *text, int leng);
+static int lineno = 1;
+%}
+%s OTHER
+comment #.*
+word ([[:alpha:]_/:\-\+\.\*][[:alnum:]_/:\-\+\.\*]+)
+string \"(([^\"\n])|\"\")*\"
+badstring \"(([^\"\n])|\"\")*
+number [[:digit:]x]+
+dimension [[:digit:]]+[[:blank:]]*x[[:blank:]]*[[:digit:]]+
+offset [+-][[:digit:]]+[[:blank:]]*[+-][[:blank:]]*[[:digit:]]+
+origin @[[:blank:]]*[[:digit:]]+[[:blank:]]*[[:blank:]]*x[[:digit:]]+
+NL \n
+WS [[:blank:]]+
+%%
+virtual return gettoken(T_VIRTUAL, yytext, yyleng);
+display return gettoken(T_DISPLAY, yytext, yyleng);
+wall return gettoken(T_WALL, yytext, yyleng);
+option return gettoken(T_OPTION, yytext, yyleng);
+param return gettoken(T_PARAM, yytext, yyleng);
+{dimension} return getdimension(T_DIMENSION, yytext, yyleng);
+{offset} return getdimension(T_OFFSET, yytext+1, yyleng-1);
+{origin} return getdimension(T_ORIGIN, yytext+1, yyleng-1);
+{word} return getstring(T_STRING, yytext, yyleng);
+{string} return getstring(T_STRING, yytext+1, yyleng-2);
+{NL} ++lineno;
+{WS}
+\{ return gettoken(yytext[0], yytext, yyleng);
+\} return gettoken(yytext[0], yytext, yyleng);
+\; return gettoken(yytext[0], yytext, yyleng);
+\/ return gettoken(yytext[0], yytext, yyleng);
+^{comment} return getcomment(T_LINE_COMMENT, yytext, yyleng);
+{comment} return getcomment(T_COMMENT, yytext, yyleng);
+. return getstring(T_STRING, yytext, yyleng);
+<<EOF>> return 0;
+%%
+int yywrap(void)
+{
+ return 1;
+}
+
+void yyerror(const char *message)
+{
+ const char *pt, *end;
+ struct _entry {
+ const char *from;
+ const char *to;
+ } *entry, list[] = {
+ { "T_VIRTUAL", "\"virtual\"" },
+ { "T_DISPLAY", "\"display\"" },
+ { "T_WALL", "\"wall\"" },
+ { "T_OPTION", "\"option\"" },
+ { "T_PARAM", "\"param\"" },
+ { "T_DIMENSION", "dimension (e.g., 2x2 or 1024x768)" },
+ { "T_OFFSET", "display offset (e.g., +10-10)" },
+ { "T_ORIGIN", "tile origin (e.g., @1280x1024)" },
+ { "T_STRING", "string" },
+ { "T_COMMENT", "comment (e.g., #...)" },
+ { "T_LINE_COMMENT", "comment (e.g., #...)" },
+ { NULL, NULL }
+ };
+
+ fprintf(stderr, "parse error on line %d at token \"%*.*s\"\n",
+ lineno, yyleng, yyleng, yytext);
+ end = message + strlen(message);
+ for (pt = message; *pt; pt++) {
+ if (pt[0] == 'T' && pt[1] == '_') {
+ const char *next = strchr(pt, ' ');
+ if (!next || !*next) next = strchr(pt, '\0');
+ if (!next) goto bail;
+ --next;
+ if (next-pt == 1 && next[1]
+ && next[2] == '\'' && next[3] == '\'') {
+ fprintf(stderr, "\"%c\"", next[1]);
+ pt += 4;
+ goto cnt;
+ }
+ for (entry = list; entry->from; ++entry) {
+ if (!strncmp(entry->from, pt, strlen(entry->from))) {
+ fprintf(stderr, "%s", entry->to);
+ pt = next;
+ goto cnt;
+ }
+ }
+ } else if (end-pt >= 5 && pt[0] == '\'' && pt[1] == '\'' && pt[3]
+ && pt[4] == '\'' && pt[5] == '\'') {
+ fprintf(stderr, "\"%c\"", pt[3]);
+ pt += 5;
+ } else if (end-pt >= 3 && pt[0] == '\'' && pt[1] && pt[2] == '\'') {
+ fprintf(stderr, "\"%c\"", pt[1]);
+ pt += 3;
+ }
+ bail:
+ putc(*pt, stderr);
+ cnt:
+ ;
+ }
+ fprintf(stderr, "\n");
+ exit( 1 );
+}
+
+static int getdimension(int token, const char *text, int leng)
+{
+ char *endptr;
+ char *tmp = dmxConfigAlloc(leng+1);
+ int x, y;
+
+ strncpy(tmp, text, leng);
+ x = strtol(tmp, &endptr, 10);
+ while (*endptr && !isdigit(*endptr)) ++endptr;
+ y = strtol(endptr, NULL, 10);
+ dmxConfigFree(tmp);
+ yylval.pair = dmxConfigCreatePair(token, lineno, NULL, x, y, 1, 1);
+ return token;
+}
+
+static int getstring(int token, const char *text, int leng)
+{
+ yylval.string = dmxConfigCreateString(token, lineno, NULL,
+ dmxConfigCopyString(leng ? text : "",
+ leng));
+ return token;
+}
+
+static int gettoken(int token, const char *text, int leng)
+{
+ yylval.token = dmxConfigCreateToken(token, lineno, NULL);
+ return token;
+}
+
+static int getcomment(int token, const char *text, int leng)
+{
+ yylval.comment = dmxConfigCreateComment(token, lineno,
+ dmxConfigCopyString(text + 1,
+ leng - 1));
+ return token;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-a.in b/nx-X11/programs/Xserver/hw/dmx/config/test-a.in
new file mode 100644
index 000000000..827675374
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-a.in
@@ -0,0 +1 @@
+error
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-a.out b/nx-X11/programs/Xserver/hw/dmx/config/test-a.out
new file mode 100644
index 000000000..d35b29fc0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-a.out
@@ -0,0 +1,2 @@
+parse error on line 1 at token "error"
+syntax error, unexpected string expecting "virtual" or comment (e.g., #...)
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-b.in b/nx-X11/programs/Xserver/hw/dmx/config/test-b.in
new file mode 100644
index 000000000..308ec1db4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-b.in
@@ -0,0 +1 @@
+# comment
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-b.out b/nx-X11/programs/Xserver/hw/dmx/config/test-b.out
new file mode 100644
index 000000000..308ec1db4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-b.out
@@ -0,0 +1 @@
+# comment
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-c.in b/nx-X11/programs/Xserver/hw/dmx/config/test-c.in
new file mode 100644
index 000000000..e07ae5ba6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-c.in
@@ -0,0 +1 @@
+virtual
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-c.out b/nx-X11/programs/Xserver/hw/dmx/config/test-c.out
new file mode 100644
index 000000000..7390397a4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-c.out
@@ -0,0 +1,2 @@
+parse error on line 2 at token " "
+syntax error, unexpected $end, expecting "{" or string or dimension (e.g., 2x2 or 1024x768)
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-d.in b/nx-X11/programs/Xserver/hw/dmx/config/test-d.in
new file mode 100644
index 000000000..6827503b1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-d.in
@@ -0,0 +1 @@
+display
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-d.out b/nx-X11/programs/Xserver/hw/dmx/config/test-d.out
new file mode 100644
index 000000000..f3219b301
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-d.out
@@ -0,0 +1,2 @@
+parse error on line 1 at token "display"
+syntax error, unexpected "display" expecting "virtual" or comment (e.g., #...)
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-e.in b/nx-X11/programs/Xserver/hw/dmx/config/test-e.in
new file mode 100644
index 000000000..21dbde95c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-e.in
@@ -0,0 +1 @@
+display;
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-e.out b/nx-X11/programs/Xserver/hw/dmx/config/test-e.out
new file mode 100644
index 000000000..f3219b301
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-e.out
@@ -0,0 +1,2 @@
+parse error on line 1 at token "display"
+syntax error, unexpected "display" expecting "virtual" or comment (e.g., #...)
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-f.in b/nx-X11/programs/Xserver/hw/dmx/config/test-f.in
new file mode 100644
index 000000000..17f6c6327
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-f.in
@@ -0,0 +1,2 @@
+virtual {
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-f.out b/nx-X11/programs/Xserver/hw/dmx/config/test-f.out
new file mode 100644
index 000000000..ba3f441d7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-f.out
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-g.in b/nx-X11/programs/Xserver/hw/dmx/config/test-g.in
new file mode 100644
index 000000000..453d8121c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-g.in
@@ -0,0 +1,4 @@
+virtual a {
+ display d0:0 1280x1024;
+ display d1:0 1280x1024;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-g.out b/nx-X11/programs/Xserver/hw/dmx/config/test-g.out
new file mode 100644
index 000000000..453d8121c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-g.out
@@ -0,0 +1,4 @@
+virtual a {
+ display d0:0 1280x1024;
+ display d1:0 1280x1024;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-h.in b/nx-X11/programs/Xserver/hw/dmx/config/test-h.in
new file mode 100644
index 000000000..1193d309e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-h.in
@@ -0,0 +1,7 @@
+# comment a
+# comment b
+## comment c
+# <-- tab
+# Next comment is empty
+#
+# Non empty
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-h.out b/nx-X11/programs/Xserver/hw/dmx/config/test-h.out
new file mode 100644
index 000000000..1193d309e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-h.out
@@ -0,0 +1,7 @@
+# comment a
+# comment b
+## comment c
+# <-- tab
+# Next comment is empty
+#
+# Non empty
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-i.in b/nx-X11/programs/Xserver/hw/dmx/config/test-i.in
new file mode 100644
index 000000000..b65967e62
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-i.in
@@ -0,0 +1,3 @@
+virtual a {
+ param a b; # comment
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-i.out b/nx-X11/programs/Xserver/hw/dmx/config/test-i.out
new file mode 100644
index 000000000..b65967e62
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-i.out
@@ -0,0 +1,3 @@
+virtual a {
+ param a b; # comment
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-j.in b/nx-X11/programs/Xserver/hw/dmx/config/test-j.in
new file mode 100644
index 000000000..cc1cdd0ea
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-j.in
@@ -0,0 +1,13 @@
+virtual a {
+ option aaa # bbb
+ aa cc;
+ param { # comment 1
+ a b;
+ c d;
+ x y z; # comment 2
+ }
+ param e f g h; # comment 3
+ param e f g hlskdjflskdfjsd #comment 4
+ flksdjf sldkfjsldkfjsdlf
+ "lsdkfjsldkfjlsdkjflskdjflsdkjfl" "lkjsdlfjsdlfkjsdlfj";
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-j.out b/nx-X11/programs/Xserver/hw/dmx/config/test-j.out
new file mode 100644
index 000000000..9acaa009b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-j.out
@@ -0,0 +1,11 @@
+virtual a {
+ option "aaa aa cc";
+ param { # comment 1
+ a b;
+ c d;
+ x y z; # comment 2
+ }
+ param e f g h; # comment 3
+ param e f g hlskdjflskdfjsd #comment 4
+ flksdjf sldkfjsldkfjsdlf lsdkfjsldkfjlsdkjflskdjflsdkjfl lkjsdlfjsdlfkjsdlfj;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-k.in b/nx-X11/programs/Xserver/hw/dmx/config/test-k.in
new file mode 100644
index 000000000..2218d26d9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-k.in
@@ -0,0 +1,3 @@
+virtual a {
+ option +xinerama -syncbatch 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-k.out b/nx-X11/programs/Xserver/hw/dmx/config/test-k.out
new file mode 100644
index 000000000..ebd743923
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-k.out
@@ -0,0 +1,3 @@
+virtual a {
+ option "+xinerama -syncbatch 0";
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-l.in b/nx-X11/programs/Xserver/hw/dmx/config/test-l.in
new file mode 100644
index 000000000..7bf05139b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-l.in
@@ -0,0 +1,12 @@
+virtual a {
+ display d0:0 1x2;
+ display d1:0 +3+4;
+ display d2:0 100x200 @1x1;
+ display d3:0 +3+4 @2x2;
+ display d4:0 100x200+3+4 @3x3;
+ display d5:0 / 1x2+3+4;
+ display d6:0 / 1x2;
+ display d7:0 / +3+4;
+ display d8:0 / 1x2+3+4 @4x4;
+ display d9:0 11x22+33+44 / 111x222+333+444 @1000x1100;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/test-l.out b/nx-X11/programs/Xserver/hw/dmx/config/test-l.out
new file mode 100644
index 000000000..7bf05139b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/test-l.out
@@ -0,0 +1,12 @@
+virtual a {
+ display d0:0 1x2;
+ display d1:0 +3+4;
+ display d2:0 100x200 @1x1;
+ display d3:0 +3+4 @2x2;
+ display d4:0 100x200+3+4 @3x3;
+ display d5:0 / 1x2+3+4;
+ display d6:0 / 1x2;
+ display d7:0 / +3+4;
+ display d8:0 / 1x2+3+4 @4x4;
+ display d9:0 11x22+33+44 / 111x222+333+444 @1000x1100;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/vdltodmx.c b/nx-X11/programs/Xserver/hw/dmx/config/vdltodmx.c
new file mode 100644
index 000000000..33cd8fe8a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/vdltodmx.c
@@ -0,0 +1,58 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+#include "dmxconfig.h"
+#include "dmxparse.h"
+#include "dmxprint.h"
+#include "dmxcompat.h"
+
+int main(int argc, char **argv)
+{
+ DMXConfigEntryPtr entry;
+ FILE *str;
+
+ if (argc != 2 && argc !=3) {
+ fprintf(stderr, "Usage: vdltodmx inFile [outFile]\n");
+ return 1;
+ }
+ if (argc == 2) {
+ str = stdout;
+ } else if (!(str = fopen(argv[2], "w"))) {
+ fprintf(stderr, "Cannot open %s for write\n", argv[2]);
+ return 2;
+ }
+ entry = dmxVDLRead(argv[1]);
+ dmxConfigPrint(str, entry);
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/vdltodmx.man b/nx-X11/programs/Xserver/hw/dmx/config/vdltodmx.man
new file mode 100644
index 000000000..b733db7ab
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/vdltodmx.man
@@ -0,0 +1,95 @@
+.\" $XFree86$
+.\" Copyright 2002 Red Hat Inc., Durham, North Carolina.
+.\" All Rights Reserved.
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation on the rights to use, copy, modify, merge,
+.\" publish, distribute, sublicense, and/or sell copies of the Software,
+.\" and to permit persons to whom the Software is furnished to do so,
+.\" subject to the following conditions:
+.\"
+.\" The above copyright notice and this permission notice (including the
+.\" next paragraph) shall be included in all copies or substantial
+.\" portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+.\" NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+.\" BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+.\" ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+.\" CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+.\" SOFTWARE.
+.\"
+.\" Authors:
+.\" Rickard E. (Rik) Faith <faith@redhat.com>
+.\"
+.TH vdltodmx 1 __vendorversion__
+.SH NAME
+vdltodmx - dmx configuration file parser and printer
+.SH SYNOPSIS
+.B vdltodmx
+.I infile
+.I outfile
+.SH DESCRIPTION
+.I vdltodmx
+reads the input file, which should be in VDL configuration file format.
+After a successful parse, a file in Xdmx configuration file format is
+written to the output file.
+.P
+The VDL file format is used with
+.IR xmovie ,
+which is available from
+http://www.llnl.gov/icc/lc/img/xmovie/xmovie.html
+.SH EXAMPLE
+Given the following VDL-format file:
+.RS
+.nf
+0
+2
+#
+#
+2560 2048 Left two-thirds [restrict=*:2]
+2
+:2.1 1280 2048 0 0 0 0
+:2.2 1280 2048 1280 0 0 0
+4
+1280 1024 0 0
+1280 1024 0 1024
+1280 1024 1280 0
+1280 1024 1280 1024
+#
+2560 2048 Right two-thirds [restrict=*:2]
+2
+:2.2 1280 2048 0 0 0 0
+:2.3 1280 2048 1280 0 0 0
+4
+1280 1024 1280 0
+1280 1024 1280 1024
+1280 1024 2560 0
+1280 1024 2560 1024
+.fi
+.RE
+the following DMX-format file will be produced:
+.RS
+.nf
+#
+#
+virtual "Left two-thirds" 2560x2048 {
+ display :2.1 1280x2048;
+ display :2.2 1280x2048 @1280x0;
+}
+#
+virtual "Right two-thirds" 2560x2048 {
+ display :2.2 1280x2048;
+ display :2.3 1280x2048 @1280x0;
+}
+.fi
+.RE
+.SH BUGS
+If the VDL file is not in the expected format, the program will probably
+dump core.
+.SH "SEE ALSO"
+Xdmx(1), xdmxconfig(1), vdl(3), xmovie(1)
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/xdmxconfig.c b/nx-X11/programs/Xserver/hw/dmx/config/xdmxconfig.c
new file mode 100644
index 000000000..4ba9ee5f8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/xdmxconfig.c
@@ -0,0 +1,1192 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Box.h>
+/* #include <X11/Xaw/Paned.h> */
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/SimpleMenu.h>
+#include <X11/Xaw/SmeBSB.h>
+#include <X11/Xaw/MenuButton.h>
+#include <X11/Xaw/Viewport.h>
+#include <X11/Xaw/Dialog.h>
+#include <X11/keysym.h>
+#include <X11/Xmu/SysUtil.h>
+#include "Canvas.h"
+
+#include "dmxparse.h"
+#include "dmxprint.h"
+#include "dmxlog.h"
+
+extern int yyparse(void);
+extern FILE *yyin;
+
+#define DMX_INFO "xdmxconfig v0.9\nCopyright 2002 Red Hat Inc.\n$Id: xdmxconfig.c,v 1.3 2005/10/06 02:40:41 kem Exp $"
+
+#define DMX_MAIN_WIDTH 800
+#define DMX_MAIN_HEIGHT 600
+#define DMX_DATA_WIDTH 200
+#define DMX_DATA_HEIGHT 200
+#define DMX_CANVAS_WIDTH 400
+#define DMX_CANVAS_HEIGHT 500
+
+DMXConfigEntryPtr dmxConfigEntry;
+static DMXConfigVirtualPtr dmxConfigCurrent, dmxConfigNewVirtual;
+static DMXConfigDisplayPtr dmxConfigCurrentDisplay, dmxConfigNewDisplay;
+static int dmxConfigGrabbed, dmxConfigGrabbedFine;
+static int dmxConfigGrabbedX, dmxConfigGrabbedY;
+static char *dmxConfigFilename;
+static GC dmxConfigGC, dmxConfigGCRev, dmxConfigGCHL;
+static int dmxConfigGCInit = 0;
+static Dimension dmxConfigWidgetWidth, dmxConfigWidgetHeight;
+static Dimension dmxConfigWallWidth, dmxConfigWallHeight;
+static double dmxConfigScaleX, dmxConfigScaleY;
+static int dmxConfigNotSaved;
+static enum {
+ dmxConfigStateOpen,
+ dmxConfigStateSave
+} dmxConfigState;
+
+/* Global widgets */
+static Widget canvas;
+static Widget cnamebox, cdimbox;
+static Widget openpopup, opendialog;
+static Widget namebox, dimbox, rtbox, origbox;
+static Widget okbutton, buttonpopup;
+static Widget ecbutton, dcbutton;
+static Widget ndbutton0, ndbutton1, edbutton, ddbutton;
+static Widget ecpopup, ecdialog0, ecdialog1;
+static Widget edpopup, eddialog0, eddialog1, eddialog2;
+static Widget aboutpopup, quitpopup;
+
+static void dmxConfigCanvasGCs(void)
+{
+ Display *dpy = XtDisplay(canvas);
+ Window win = XtWindow(canvas);
+ XGCValues gcvals;
+ unsigned long mask;
+ Colormap colormap;
+ XColor fg, bg, hl, tmp;
+
+ if (dmxConfigGCInit++) return;
+
+ XtVaGetValues(canvas, XtNcolormap, &colormap, NULL);
+ XAllocNamedColor(XtDisplay(canvas), colormap, "black", &bg, &tmp);
+ XAllocNamedColor(XtDisplay(canvas), colormap, "white", &fg, &tmp);
+ XAllocNamedColor(XtDisplay(canvas), colormap, "red", &hl, &tmp);
+
+ mask = (GCFunction | GCPlaneMask | GCClipMask | GCForeground |
+ GCBackground | GCLineWidth | GCLineStyle | GCCapStyle |
+ GCFillStyle);
+
+ /* FIXME: copy this from widget */
+ gcvals.function = GXcopy;
+ gcvals.plane_mask = AllPlanes;
+ gcvals.clip_mask = None;
+ gcvals.foreground = fg.pixel;
+ gcvals.background = bg.pixel;
+ gcvals.line_width = 0;
+ gcvals.line_style = LineSolid;
+ gcvals.cap_style = CapNotLast;
+ gcvals.fill_style = FillSolid;
+
+ dmxConfigGC = XCreateGC(dpy, win, mask, &gcvals);
+ gcvals.foreground = hl.pixel;
+ dmxConfigGCHL = XCreateGC(dpy, win, mask, &gcvals);
+ gcvals.foreground = bg.pixel;
+ gcvals.background = fg.pixel;
+ dmxConfigGCRev = XCreateGC(dpy, win, mask, &gcvals);
+}
+
+static void dmxConfigGetDims(int *maxWidth, int *maxHeight)
+{
+ DMXConfigSubPtr pt;
+ DMXConfigEntryPtr e;
+
+ *maxWidth = dmxConfigWallWidth = 0;
+ *maxWidth = dmxConfigWallHeight = 0;
+ if (!dmxConfigCurrent) return;
+
+ dmxConfigWallWidth = dmxConfigCurrent->width;
+ dmxConfigWallHeight = dmxConfigCurrent->height;
+ if (!dmxConfigWallWidth || !dmxConfigWallHeight) {
+ for (pt = dmxConfigCurrent->subentry; pt; pt = pt->next) {
+ if (pt->type == dmxConfigDisplay) {
+ int x = pt->display->scrnWidth + pt->display->rootXOrigin;
+ int y = pt->display->scrnHeight + pt->display->rootYOrigin;
+ if (x > dmxConfigWallWidth) dmxConfigWallWidth = x;
+ if (y > dmxConfigWallHeight) dmxConfigWallHeight = y;
+ }
+ }
+ }
+ /* Compute maximums */
+ *maxWidth = *maxHeight = 0;
+ for (e = dmxConfigEntry; e; e = e->next) {
+ if (e->type != dmxConfigVirtual) continue;
+ for (pt = e->virtual->subentry; pt; pt = pt->next) {
+ if (pt->type == dmxConfigDisplay) {
+ int x = pt->display->scrnWidth + pt->display->rootXOrigin;
+ int y = pt->display->scrnHeight + pt->display->rootYOrigin;
+ if (x > *maxWidth) *maxWidth = x;
+ if (y > *maxHeight) *maxHeight = y;
+ }
+ }
+ }
+ if (dmxConfigWallWidth > *maxWidth) *maxWidth = dmxConfigWallWidth;
+ if (dmxConfigWallHeight > *maxHeight) *maxHeight = dmxConfigWallHeight;
+}
+
+static int scalex(int x) { return (int)((x * dmxConfigScaleX) + .5); }
+static int scaley(int y) { return (int)((y * dmxConfigScaleY) + .5); }
+static int unscalex(int x) { return (int)((x / dmxConfigScaleX) + .5); }
+static int unscaley(int y) { return (int)((y / dmxConfigScaleY) + .5); }
+
+static void dmxConfigDataUpdate(void)
+{
+ /* FIXME: could result in buffer overflows */
+ char cnambuf[512];
+ char cdimbuf[128];
+ char nambuf[512];
+ char dimbuf[128];
+ char rtbuf[128];
+ char offbuf[128];
+ const char *name;
+
+ if (!dmxConfigCurrent) {
+ XtVaSetValues(cnamebox, XtNlabel, "", XtNsensitive, False, NULL);
+ XtVaSetValues(cdimbox, XtNlabel, "", XtNsensitive, False, NULL);
+ XtVaSetValues(ecbutton, XtNsensitive, False, NULL);
+ XtVaSetValues(dcbutton, XtNsensitive, False, NULL);
+ XtVaSetValues(ndbutton0, XtNsensitive, False, NULL);
+ XtVaSetValues(ndbutton1, XtNsensitive, False, NULL);
+ } else {
+ name = dmxConfigCurrent->name;
+ XmuSnprintf(cnambuf, sizeof(cnambuf), "%s", name ? name : "");
+ XmuSnprintf(cdimbuf, sizeof(cdimbuf), "%dx%d",
+ dmxConfigWallWidth, dmxConfigWallHeight);
+ XtVaSetValues(cnamebox, XtNlabel, cnambuf, XtNsensitive, True, NULL);
+ XtVaSetValues(cdimbox, XtNlabel, cdimbuf, XtNsensitive, True, NULL);
+ XtVaSetValues(ecbutton, XtNsensitive, True, NULL);
+ XtVaSetValues(dcbutton, XtNsensitive, True, NULL);
+ XtVaSetValues(ndbutton0, XtNsensitive, True, NULL);
+ XtVaSetValues(ndbutton1, XtNsensitive, True, NULL);
+ }
+
+ if (!dmxConfigCurrentDisplay) {
+ XtVaSetValues(namebox, XtNlabel, "", XtNsensitive, False, NULL);
+ XtVaSetValues(dimbox, XtNlabel, "", XtNsensitive, False, NULL);
+ XtVaSetValues(rtbox, XtNlabel, "", XtNsensitive, False, NULL);
+ XtVaSetValues(origbox, XtNlabel, "", XtNsensitive, False, NULL);
+ XtVaSetValues(edbutton, XtNsensitive, False, NULL);
+ XtVaSetValues(ddbutton, XtNsensitive, False, NULL);
+ } else {
+ name = dmxConfigCurrentDisplay->name;
+ XmuSnprintf(nambuf, sizeof(nambuf), "%s", name ? name : "");
+ XmuSnprintf(dimbuf, sizeof(dimbuf), "%dx%d%c%d%c%d",
+ dmxConfigCurrentDisplay->scrnWidth,
+ dmxConfigCurrentDisplay->scrnHeight,
+ dmxConfigCurrentDisplay->scrnXSign < 0 ? '-' : '+',
+ dmxConfigCurrentDisplay->scrnX,
+ dmxConfigCurrentDisplay->scrnYSign < 0 ? '-' : '+',
+ dmxConfigCurrentDisplay->scrnY);
+ XmuSnprintf(rtbuf, sizeof(dimbuf), "%dx%d%c%d%c%d",
+ dmxConfigCurrentDisplay->rootWidth,
+ dmxConfigCurrentDisplay->rootHeight,
+ dmxConfigCurrentDisplay->rootXSign < 0 ? '-' : '+',
+ dmxConfigCurrentDisplay->rootX,
+ dmxConfigCurrentDisplay->rootYSign < 0 ? '-' : '+',
+ dmxConfigCurrentDisplay->rootY);
+ XmuSnprintf(offbuf, sizeof(offbuf), "@%dx%d",
+ dmxConfigCurrentDisplay->rootXOrigin,
+ dmxConfigCurrentDisplay->rootYOrigin);
+ XtVaSetValues(namebox, XtNlabel, nambuf, XtNsensitive, True, NULL);
+ XtVaSetValues(dimbox, XtNlabel, dimbuf, XtNsensitive, True, NULL);
+ XtVaSetValues(rtbox, XtNlabel, rtbuf, XtNsensitive, True, NULL);
+ XtVaSetValues(origbox, XtNlabel, offbuf, XtNsensitive, True, NULL);
+ XtVaSetValues(edbutton, XtNsensitive, True, NULL);
+ XtVaSetValues(ddbutton, XtNsensitive, True, NULL);
+ }
+}
+
+static void dmxConfigCanvasUpdate(void)
+{
+ DMXConfigSubPtr pt;
+ Display *dpy = XtDisplay(canvas);
+ Window win = XtWindow(canvas);
+ GContext gcontext = XGContextFromGC(dmxConfigGC);
+ XFontStruct *fs;
+ int w, h;
+
+ XFillRectangle(dpy, win, dmxConfigGCRev,
+ 0, 0, dmxConfigWidgetWidth, dmxConfigWidgetHeight);
+ dmxConfigDataUpdate();
+ if (!dmxConfigCurrent) return;
+
+ w = scalex(dmxConfigWallWidth);
+ h = scaley(dmxConfigWallHeight);
+ if (w > dmxConfigWidgetWidth - 1) w = dmxConfigWidgetWidth - 1;
+ if (h > dmxConfigWidgetHeight - 1) h = dmxConfigWidgetHeight - 1;
+ XDrawRectangle(dpy, win, dmxConfigGC, 0, 0, w, h);
+ fs = XQueryFont(dpy, gcontext);
+ for (pt = dmxConfigCurrent->subentry; pt; pt = pt->next) {
+ int x, y, len;
+ int xo = 3, yo = fs->ascent + fs->descent + 2;
+ GC gc;
+
+ if (pt->type != dmxConfigDisplay) continue;
+ gc = (pt->display == dmxConfigCurrentDisplay
+ ? dmxConfigGCHL
+ : dmxConfigGC);
+ x = scalex(pt->display->rootXOrigin);
+ y = scaley(pt->display->rootYOrigin);
+ w = scalex(pt->display->scrnWidth);
+ h = scaley(pt->display->scrnHeight);
+ len = pt->display->name ? strlen(pt->display->name) : 0;
+ if (x > dmxConfigWidgetWidth - 1) x = dmxConfigWidgetWidth - 1;
+ if (y > dmxConfigWidgetHeight - 1) y = dmxConfigWidgetHeight - 1;
+ XDrawRectangle(dpy, win, gc, x, y, w, h);
+ if (fs && len) {
+ while (len && XTextWidth(fs, pt->display->name, len) >= w - 2 * xo)
+ --len;
+ if (len)
+ XDrawString(dpy, win, gc, x+xo, y+yo, pt->display->name, len);
+ }
+ }
+ if (fs) XFreeFontInfo(NULL, fs, 0);
+}
+
+static void dmxConfigCanvasDraw(Region region)
+{
+ Display *dpy = XtDisplay(canvas);
+ int maxWidth, maxHeight;
+
+ dmxConfigCanvasGCs();
+ if (region) {
+ XSetRegion(dpy, dmxConfigGC, region);
+ XSetRegion(dpy, dmxConfigGCRev, region);
+ XSetRegion(dpy, dmxConfigGCHL, region);
+ }
+ XtVaGetValues(canvas,
+ XtNwidth, &dmxConfigWidgetWidth,
+ XtNheight, &dmxConfigWidgetHeight,
+ NULL);
+ dmxConfigGetDims(&maxWidth, &maxHeight);
+ dmxConfigScaleX = (double)dmxConfigWidgetWidth / maxWidth;
+ dmxConfigScaleY = (double)dmxConfigWidgetHeight / maxHeight;
+ if (dmxConfigScaleX > dmxConfigScaleY) dmxConfigScaleX = dmxConfigScaleY;
+ if (dmxConfigScaleY > dmxConfigScaleX) dmxConfigScaleY = dmxConfigScaleX;
+ dmxConfigCanvasUpdate();
+ if (region) {
+ XSetClipMask(dpy, dmxConfigGC, None);
+ XSetClipMask(dpy, dmxConfigGCRev, None);
+ XSetClipMask(dpy, dmxConfigGCHL, None);
+ }
+}
+
+static void dmxConfigSelectCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ dmxConfigCurrent = closure;
+ dmxConfigVirtualPrint(stdout, dmxConfigCurrent);
+ dmxConfigCanvasDraw(NULL);
+}
+
+static void dmxConfigCopystrings(void)
+{
+ DMXConfigEntryPtr pt;
+ DMXConfigSubPtr sub;
+
+ if (!dmxConfigCurrent) return;
+
+ /* FIXME: this is all a per-config file
+ * memory leak */
+ for (pt = dmxConfigEntry; pt; pt = pt->next) {
+ if (pt->type == dmxConfigVirtual) {
+ pt->virtual->name = XtNewString(pt->virtual->name
+ ? pt->virtual->name
+ : "");
+
+ for (sub = pt->virtual->subentry; sub; sub = sub->next) {
+ if (sub->type != dmxConfigDisplay) continue;
+ sub->display->name = XtNewString(sub->display->name
+ ? sub->display->name
+ : "");
+ }
+ }
+ }
+}
+
+static void dmxConfigGetValueString(char **d, Widget w)
+{
+ const char *tmp = XawDialogGetValueString(w);
+ if (*d) XtFree(*d);
+ *d = XtNewString(tmp);
+}
+
+static void dmxConfigSetupCnamemenu(void)
+{
+ static Widget cnamemenu = NULL;
+ Widget w;
+ DMXConfigEntryPtr pt;
+
+ if (cnamemenu) XtDestroyWidget(cnamemenu);
+ cnamemenu = NULL;
+
+ if (!dmxConfigCurrent) return;
+ cnamemenu = XtVaCreatePopupShell("cnamemenu", simpleMenuWidgetClass,
+ cnamebox,
+ NULL);
+
+ for (pt = dmxConfigEntry; pt; pt = pt->next) {
+ if (pt->type == dmxConfigVirtual) {
+ w = XtVaCreateManagedWidget(pt->virtual->name
+ ? pt->virtual->name
+ : "",
+ smeBSBObjectClass, cnamemenu,
+ NULL);
+ XtAddCallback(w, XtNcallback,
+ dmxConfigSelectCallback, pt->virtual);
+ }
+ }
+}
+
+static void dmxConfigReadFile(void)
+{
+ FILE *str;
+ DMXConfigEntryPtr pt;
+
+ if (!(str = fopen(dmxConfigFilename, "r"))) {
+ dmxLog(dmxWarning, "Unable to read configuration file %s\n",
+ dmxConfigFilename);
+ return;
+ }
+ yyin = str;
+ yydebug = 0;
+ yyparse();
+ fclose(str);
+ dmxLog(dmxInfo, "Read configuration file %s\n", dmxConfigFilename);
+
+ for (pt = dmxConfigEntry; pt; pt = pt->next) {
+ if (pt->type == dmxConfigVirtual) {
+ dmxConfigCurrent = pt->virtual;
+ break;
+ }
+ }
+
+
+
+ if (XtIsRealized(canvas)) {
+ dmxConfigCopystrings();
+ dmxConfigSetupCnamemenu();
+ dmxConfigCanvasDraw(NULL);
+ }
+ dmxConfigVirtualPrint(stdout, dmxConfigCurrent);
+}
+
+static void dmxConfigWriteFile(void)
+{
+ FILE *str;
+
+ if (!(str = fopen(dmxConfigFilename, "w"))) {
+ dmxLog(dmxWarning, "Unable to write configuration file %s\n",
+ dmxConfigFilename);
+ return;
+ }
+ dmxConfigPrint(str, dmxConfigEntry);
+ fclose(str);
+}
+
+static DMXConfigDisplayPtr dmxConfigFindDisplay(int x, int y)
+{
+ DMXConfigSubPtr pt;
+
+ if (!dmxConfigCurrent) return NULL;
+ for (pt = dmxConfigCurrent->subentry; pt; pt = pt->next) {
+ DMXConfigDisplayPtr d = pt->display;
+ if (pt->type != dmxConfigDisplay) continue;
+ if (x >= scalex(d->rootXOrigin)
+ && x <= scalex(d->rootXOrigin + d->scrnWidth)
+ && y >= scaley(d->rootYOrigin)
+ && y <= scaley(d->rootYOrigin + d->scrnHeight)) return d;
+ }
+ return NULL;
+}
+
+static void dmxConfigSetPopupPosition(Widget popup)
+{
+ Position x, y;
+ Window t1, t2;
+ int root_x, root_y;
+ int temp_x, temp_y;
+ unsigned int temp;
+
+
+ XtRealizeWidget(popup);
+ if (!XQueryPointer(XtDisplay(popup), XtWindow(popup), &t1, &t2,
+ &root_x, &root_y, &temp_x, &temp_y, &temp))
+ root_x = root_y = 0;
+
+ x = root_x - 5;
+ y = root_y - 5;
+ XtVaSetValues(popup, XtNx, x, XtNy, y, NULL);
+}
+
+static void dmxConfigPlaceMenu(Widget w, XEvent *event,
+ String *params, Cardinal *num_params)
+{
+ dmxConfigSetPopupPosition(buttonpopup);
+}
+
+static void dmxConfigMove(int deltaX, int deltaY)
+{
+ dmxConfigCurrentDisplay->rootXOrigin += deltaX;
+ dmxConfigCurrentDisplay->rootYOrigin += deltaY;
+ if (dmxConfigCurrentDisplay->rootXOrigin < 0)
+ dmxConfigCurrentDisplay->rootXOrigin = 0;
+ if (dmxConfigCurrentDisplay->rootYOrigin < 0)
+ dmxConfigCurrentDisplay->rootYOrigin = 0;
+ if (dmxConfigWallWidth && dmxConfigWallHeight) {
+ if (dmxConfigCurrentDisplay->rootXOrigin >= dmxConfigWallWidth)
+ dmxConfigCurrentDisplay->rootXOrigin = dmxConfigWallWidth - 1;
+ if (dmxConfigCurrentDisplay->rootYOrigin >= dmxConfigWallHeight)
+ dmxConfigCurrentDisplay->rootYOrigin = dmxConfigWallHeight - 1;
+ }
+ dmxConfigCanvasUpdate();
+ dmxConfigNotSaved = 1;
+}
+
+static void dmxConfigCanvasInput(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ XEvent *e = (XEvent *)callData;
+ DMXConfigDisplayPtr display = NULL;
+
+ switch (e->type) {
+ case ButtonPress:
+ if (e->xbutton.button == Button1) {
+ dmxConfigGrabbed = 1;
+ dmxConfigGrabbedFine = 0;
+ dmxConfigGrabbedX = e->xbutton.x;
+ dmxConfigGrabbedY = e->xbutton.y;
+ }
+ if (e->xbutton.button == Button2) {
+ dmxConfigGrabbed = 1;
+ dmxConfigGrabbedFine = 1;
+ dmxConfigGrabbedX = e->xbutton.x;
+ dmxConfigGrabbedY = e->xbutton.y;
+ }
+ break;
+ case ButtonRelease:
+ if (e->xbutton.button == Button1) dmxConfigGrabbed = 0;
+ if (e->xbutton.button == Button2) dmxConfigGrabbed = 0;
+ break;
+ case MotionNotify:
+ if (dmxConfigGrabbed && dmxConfigCurrentDisplay) {
+ int deltaX = e->xmotion.x - dmxConfigGrabbedX;
+ int deltaY = e->xmotion.y - dmxConfigGrabbedY;
+ dmxConfigMove(dmxConfigGrabbedFine ? deltaX : unscalex(deltaX),
+ dmxConfigGrabbedFine ? deltaY : unscaley(deltaY));
+ dmxConfigGrabbedX = e->xmotion.x;
+ dmxConfigGrabbedY = e->xmotion.y;
+ } else {
+ display = dmxConfigFindDisplay(e->xmotion.x, e->xmotion.y);
+ if (display != dmxConfigCurrentDisplay) {
+ dmxConfigCurrentDisplay = display;
+ dmxConfigCanvasUpdate();
+ }
+ }
+ break;
+ case KeyPress:
+ switch (XLookupKeysym(&e->xkey, 0)) {
+ case XK_Right: dmxConfigMove(1,0); break;
+ case XK_Left: dmxConfigMove(-1,0); break;
+ case XK_Down: dmxConfigMove(0,1); break;
+ case XK_Up: dmxConfigMove(0,-1); break;
+ }
+ break;
+ }
+}
+
+static void dmxConfigCanvasResize(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ dmxConfigCanvasDraw(NULL);
+}
+
+static void dmxConfigCanvasExpose(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ CanvasExposeDataPtr data = (CanvasExposeDataPtr)callData;
+
+ dmxConfigCanvasDraw(data->region);
+}
+
+static void dmxConfigOpenCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ dmxConfigState = dmxConfigStateOpen;
+ XtVaSetValues(okbutton, XtNlabel, "Open", NULL);
+ dmxConfigSetPopupPosition(openpopup);
+ XtPopup(openpopup, XtGrabExclusive);
+}
+
+static void dmxConfigSaveCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ dmxConfigState = dmxConfigStateSave;
+ XtVaSetValues(okbutton, XtNlabel, "Save", NULL);
+ dmxConfigSetPopupPosition(openpopup);
+ XtPopup(openpopup, XtGrabExclusive);
+}
+
+static void dmxConfigOkCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ dmxConfigGetValueString(&dmxConfigFilename, opendialog);
+ XtPopdown(openpopup);
+ if (dmxConfigState == dmxConfigStateOpen) dmxConfigReadFile();
+ else dmxConfigWriteFile();
+ dmxConfigNotSaved = 0;
+}
+
+static void dmxConfigCanCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ XtPopdown(openpopup);
+}
+
+static void dmxConfigECCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ char buf[256]; /* RATS: Only used in XmuSnprintf */
+
+ if (!dmxConfigCurrent) return;
+ dmxConfigSetPopupPosition(ecpopup);
+ XtVaSetValues(ecdialog0, XtNvalue,
+ dmxConfigCurrent->name ? dmxConfigCurrent->name : "",
+ NULL);
+ XmuSnprintf(buf, sizeof(buf), "%dx%d",
+ dmxConfigCurrent->width, dmxConfigCurrent->height);
+ XtVaSetValues(ecdialog1, XtNvalue, buf, NULL);
+ XtPopup(ecpopup, XtGrabExclusive);
+}
+
+static void dmxConfigNCCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ int width = 1280*2, height = 1024*2;
+
+ if (dmxConfigCurrent) {
+ width = dmxConfigCurrent->width;
+ height = dmxConfigCurrent->height;
+ }
+
+ dmxConfigCurrent = dmxConfigCreateVirtual(NULL, NULL, NULL,
+ NULL, NULL, NULL);
+ dmxConfigNewVirtual = dmxConfigCurrent;
+ dmxConfigCurrent->width = width;
+ dmxConfigCurrent->height = height;
+ dmxConfigEntry = dmxConfigAddEntry(dmxConfigEntry, dmxConfigVirtual, NULL,
+ dmxConfigCurrent);
+ dmxConfigECCallback(w, closure, callData);
+}
+
+static void dmxConfigDCCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ DMXConfigEntryPtr pt;
+
+ if (!dmxConfigEntry) return;
+ if (dmxConfigEntry
+ && dmxConfigEntry->type == dmxConfigVirtual
+ && dmxConfigEntry->virtual == dmxConfigCurrent) {
+ dmxConfigEntry = dmxConfigEntry->next;
+ } else {
+ for (pt = dmxConfigEntry; pt && pt->next; pt = pt->next)
+ if (pt->next->type == dmxConfigVirtual
+ && pt->next->virtual == dmxConfigCurrent) {
+ pt->next = pt->next->next;
+ break;
+ }
+ }
+ dmxConfigFreeVirtual(dmxConfigCurrent);
+ dmxConfigCurrent = NULL;
+ dmxConfigCurrentDisplay = NULL;
+
+ /* Make the first entry current */
+ for (pt = dmxConfigEntry; pt; pt = pt->next) {
+ if (pt->type == dmxConfigVirtual) {
+ dmxConfigCurrent = pt->virtual;
+ break;
+ }
+ }
+
+ dmxConfigSetupCnamemenu();
+ dmxConfigCanvasDraw(NULL);
+}
+
+static void dmxConfigECOkCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ const char *value;
+ char *endpt;
+
+ dmxConfigGetValueString((char **)&dmxConfigCurrent->name, ecdialog0);
+ value = XawDialogGetValueString(ecdialog1);
+ dmxConfigCurrent->width = strtol(value, &endpt, 10);
+ dmxConfigCurrent->height = strtol(endpt+1, NULL, 10);
+ XtPopdown(ecpopup);
+ dmxConfigCurrentDisplay = NULL;
+ dmxConfigNewVirtual = NULL;
+ dmxConfigSetupCnamemenu();
+ dmxConfigCanvasDraw(NULL);
+ dmxConfigNotSaved = 1;
+}
+
+static void dmxConfigECCanCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ if (dmxConfigNewVirtual) dmxConfigDCCallback(w, closure, callData);
+ dmxConfigNewVirtual = NULL;
+ XtPopdown(ecpopup);
+}
+
+static void dmxConfigEDCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ char buf[256]; /* RATS: Only used in XmuSnprintf */
+
+ if (!dmxConfigCurrent || !dmxConfigCurrentDisplay) return;
+ dmxConfigSetPopupPosition(edpopup);
+ XtVaSetValues(eddialog0, XtNvalue,
+ dmxConfigCurrentDisplay->name
+ ? dmxConfigCurrentDisplay->name
+ : "",
+ NULL);
+ XmuSnprintf(buf, sizeof(buf), "%dx%d%c%d%c%d",
+ dmxConfigCurrentDisplay->scrnWidth,
+ dmxConfigCurrentDisplay->scrnHeight,
+ dmxConfigCurrentDisplay->scrnXSign < 0 ? '-' : '+',
+ dmxConfigCurrentDisplay->scrnY,
+ dmxConfigCurrentDisplay->scrnYSign < 0 ? '-' : '+',
+ dmxConfigCurrentDisplay->scrnY);
+ XtVaSetValues(eddialog1, XtNvalue, buf, NULL);
+ XmuSnprintf(buf, sizeof(buf), "@%dx%d",
+ dmxConfigCurrentDisplay->rootXOrigin,
+ dmxConfigCurrentDisplay->rootYOrigin);
+ XtVaSetValues(eddialog2, XtNvalue, buf, NULL);
+ XtPopup(edpopup, XtGrabExclusive);
+}
+
+static void dmxConfigNDCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ int width = 1280, height = 1024;
+
+ if (!dmxConfigCurrent) return;
+ if (dmxConfigCurrentDisplay) {
+ width = dmxConfigCurrentDisplay->scrnWidth;
+ height = dmxConfigCurrentDisplay->scrnHeight;
+ }
+ dmxConfigCurrentDisplay = dmxConfigCreateDisplay(NULL, NULL, NULL,
+ NULL, NULL);
+ dmxConfigNewDisplay = dmxConfigCurrentDisplay;
+ dmxConfigCurrentDisplay->scrnWidth = width;
+ dmxConfigCurrentDisplay->scrnHeight = height;
+
+ dmxConfigCurrent->subentry
+ = dmxConfigAddSub(dmxConfigCurrent->subentry,
+ dmxConfigSubDisplay(dmxConfigCurrentDisplay));
+ dmxConfigEDCallback(w, closure, callData);
+}
+
+static void dmxConfigDDCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ DMXConfigSubPtr pt;
+
+ if (!dmxConfigCurrent || !dmxConfigCurrentDisplay) return;
+ /* First */
+ if (dmxConfigCurrent->subentry
+ && dmxConfigCurrent->subentry->type == dmxConfigDisplay
+ && dmxConfigCurrent->subentry->display == dmxConfigCurrentDisplay) {
+ dmxConfigCurrent->subentry = dmxConfigCurrent->subentry->next;
+ } else {
+ for (pt = dmxConfigCurrent->subentry; pt && pt->next; pt = pt->next)
+ if (pt->next->type == dmxConfigDisplay
+ && pt->next->display == dmxConfigCurrentDisplay) {
+ pt->next = pt->next->next;
+ break;
+ }
+ }
+ dmxConfigFreeDisplay(dmxConfigCurrentDisplay);
+ dmxConfigCurrentDisplay = NULL;
+ dmxConfigSetupCnamemenu();
+ dmxConfigCanvasDraw(NULL);
+}
+
+static void dmxConfigAboutCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ dmxConfigSetPopupPosition(aboutpopup);
+ XtPopup(aboutpopup, XtGrabExclusive);
+}
+
+static void dmxConfigAboutOkCallback(Widget w, XtPointer closure,
+ XtPointer CallData)
+{
+ XtPopdown(aboutpopup);
+}
+
+static void dmxConfigQuitCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ if (dmxConfigNotSaved) {
+ dmxConfigSetPopupPosition(quitpopup);
+ XtPopup(quitpopup, XtGrabExclusive);
+ return;
+ }
+ exit(0);
+}
+
+static void dmxConfigQuitOkCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ XtPopdown(quitpopup);
+ exit(0);
+}
+
+static void dmxConfigQuitCanCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ XtPopdown(quitpopup);
+}
+
+static void dmxConfigEDOkCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ char *value;
+ char *endpt;
+
+ dmxConfigNewDisplay = NULL;
+ dmxConfigGetValueString((char **)&dmxConfigCurrentDisplay->name,
+ eddialog0);
+ value = XawDialogGetValueString(eddialog1);
+ if (*value == '-' || *value == '+') {
+ dmxConfigCurrentDisplay->scrnWidth = 0;
+ dmxConfigCurrentDisplay->scrnHeight = 0;
+ endpt = value;
+ } else {
+ dmxConfigCurrentDisplay->scrnWidth = strtol(value, &endpt, 10);
+ dmxConfigCurrentDisplay->scrnHeight = strtol(endpt+1, &endpt, 10);
+ }
+ if (*endpt) {
+ dmxConfigCurrentDisplay->scrnXSign = (*endpt == '-') ? -1 : 1;
+ dmxConfigCurrentDisplay->scrnX = strtol(endpt+1, &endpt, 10);
+ dmxConfigCurrentDisplay->scrnYSign = (*endpt == '-') ? -1 : 1;
+ dmxConfigCurrentDisplay->scrnY = strtol(endpt+1, NULL, 10);
+ }
+ if (dmxConfigCurrentDisplay->scrnX < 0)
+ dmxConfigCurrentDisplay->scrnX = -dmxConfigCurrentDisplay->scrnX;
+ if (dmxConfigCurrentDisplay->scrnY < 0)
+ dmxConfigCurrentDisplay->scrnY = -dmxConfigCurrentDisplay->scrnY;
+ value = XawDialogGetValueString(eddialog2);
+ dmxConfigCurrentDisplay->rootXOrigin = strtol(value+1, &endpt, 10);
+ dmxConfigCurrentDisplay->rootYOrigin = strtol(endpt+1, NULL, 10);
+ XtPopdown(edpopup);
+ dmxConfigSetupCnamemenu();
+ dmxConfigCanvasDraw(NULL);
+ dmxConfigNotSaved = 1;
+}
+
+static void dmxConfigEDCanCallback(Widget w, XtPointer closure,
+ XtPointer callData)
+{
+ if (dmxConfigNewDisplay) dmxConfigDDCallback(w, closure, callData);
+ dmxConfigNewDisplay = NULL;
+ XtPopdown(edpopup);
+}
+
+static void dmxConfigOkAction(Widget w, XEvent *event,
+ String *params, Cardinal *num_params)
+{
+ Widget p = XtParent(w);
+ Widget t;
+
+ if (p == opendialog) dmxConfigOkCallback(w, NULL, NULL);
+
+ if (p == ecdialog0) {
+ t = XtNameToWidget(ecdialog1, "value");
+ XWarpPointer(XtDisplay(t), None, XtWindow(t), 0, 0, 0, 0, 0, 10);
+ }
+ if (p == ecdialog1) dmxConfigECOkCallback(w, NULL, NULL);
+
+ if (p == eddialog0) {
+ t = XtNameToWidget(eddialog1, "value");
+ XWarpPointer(XtDisplay(t), None, XtWindow(t), 0, 0, 0, 0, 0, 10);
+ }
+ if (p == eddialog1) {
+ t = XtNameToWidget(eddialog2, "value");
+ XWarpPointer(XtDisplay(t), None, XtWindow(t), 0, 0, 0, 0, 0, 10);
+ }
+ if (p == eddialog2) dmxConfigEDOkCallback(w, NULL, NULL);
+}
+
+int main(int argc, char **argv)
+{
+ XtAppContext appContext;
+ Widget toplevel;
+ Widget parent, menubox, bottombox, databox, canvasbox;
+ Widget filebutton, helpbutton;
+ Widget filemenu, openbutton, savebutton, quitbutton;
+ Widget helpmenu, aboutbutton, aboutbox, abouttext, aboutok;
+ Widget quitbox, quittext, quitok, quitcan;
+ Widget ncbutton;
+ Widget canbutton;
+ Widget ecbox, ecokbutton, eccanbutton;
+ Widget edbox, edokbutton;
+ Widget edcanbutton;
+ /* FIXME: add meta-i, ctrl,meta-z,v? */
+ const char *opentrans = "<Key>Return: openOk()\n\
+ <Key>Linefeed: openOk()\n\
+ Ctrl<Key>M: openOk()\n\
+ Ctrl<Key>J: openOk()\n\
+ Ctrl<Key>O: noop()\n\
+ Ctrl<Key>N: noop()\n\
+ Ctrl<Key>P: noop()";
+ const char *canvastrans =
+ "<Btn3Down>: placeMenu() XtMenuPopup(buttonpopup)";
+ XtActionsRec actiontable[] = {
+ { "openOk", dmxConfigOkAction },
+ { "placeMenu", dmxConfigPlaceMenu },
+ { "noop", NULL }
+ };
+
+ dmxConfigFilename = XtNewString((argc >= 2) ? argv[1] : "");
+
+ toplevel = XtVaAppInitialize(&appContext, "XDmxconfig",
+ NULL, 0,
+ &argc, argv,
+ NULL,
+ NULL);
+
+ /* Main boxes */
+ parent = XtVaCreateManagedWidget("parent", formWidgetClass, toplevel,
+ XtNorientation, XtorientVertical,
+ XtNwidth, DMX_MAIN_WIDTH,
+ XtNheight, DMX_MAIN_HEIGHT,
+ NULL);
+ menubox = XtVaCreateManagedWidget("menubox", boxWidgetClass, parent,
+ XtNborderWidth, 0,
+ XtNorientation, XtorientHorizontal,
+ XtNtop, XtChainTop,
+ NULL);
+ bottombox = XtVaCreateManagedWidget("bottombox", formWidgetClass, parent,
+ XtNborderWidth, 0,
+ XtNfromVert, menubox,
+ XtNorientation, XtorientHorizontal,
+ NULL);
+ databox = XtVaCreateManagedWidget("databox", formWidgetClass,
+ bottombox,
+ XtNborderWidth, 0,
+ XtNhorizDistance, 0,
+ XtNwidth, DMX_DATA_WIDTH,
+ XtNheight, DMX_DATA_HEIGHT,
+ XtNleft, XtChainLeft,
+ XtNorientation, XtorientVertical,
+ NULL);
+
+ /* Data */
+ cnamebox = XtVaCreateManagedWidget("cnamebox", menuButtonWidgetClass,
+ databox,
+ XtNtop, XtChainTop,
+ XtNjustify, XtJustifyLeft,
+ XtNwidth, DMX_DATA_WIDTH,
+ XtNlabel, "",
+ XtNmenuName, "cnamemenu",
+ NULL);
+ cdimbox = XtVaCreateManagedWidget("cdimbox", labelWidgetClass,
+ databox,
+ XtNfromVert, cnamebox,
+ XtNjustify, XtJustifyLeft,
+ XtNwidth, DMX_DATA_WIDTH,
+ XtNlabel, "",
+ NULL);
+ namebox = XtVaCreateManagedWidget("namebox", labelWidgetClass, databox,
+ XtNfromVert, cdimbox,
+ XtNjustify, XtJustifyLeft,
+ XtNwidth, DMX_DATA_WIDTH,
+ XtNlabel, "",
+ NULL);
+ dimbox = XtVaCreateManagedWidget("dimbox", labelWidgetClass,
+ databox,
+ XtNfromVert, namebox,
+ XtNjustify, XtJustifyLeft,
+ XtNwidth, DMX_DATA_WIDTH,
+ XtNlabel, "",
+ NULL);
+ rtbox = XtVaCreateManagedWidget("rtbox", labelWidgetClass,
+ databox,
+ XtNfromVert, dimbox,
+ XtNjustify, XtJustifyLeft,
+ XtNwidth, DMX_DATA_WIDTH,
+ XtNlabel, "",
+ NULL);
+ origbox = XtVaCreateManagedWidget("origbox", labelWidgetClass,
+ databox,
+ XtNfromVert, rtbox,
+ XtNjustify, XtJustifyLeft,
+ XtNwidth, DMX_DATA_WIDTH,
+ XtNlabel, "",
+ NULL);
+
+ /* Canvas */
+ canvasbox = XtVaCreateManagedWidget("canvasbox", boxWidgetClass,
+ bottombox,
+ XtNborderWidth, 0,
+ XtNwidth, DMX_CANVAS_WIDTH,
+ XtNheight, DMX_CANVAS_HEIGHT,
+ XtNfromHoriz, databox,
+ NULL);
+
+ canvas = XtVaCreateManagedWidget("canvas", canvasWidgetClass,
+ canvasbox,
+ XtNwidth, DMX_CANVAS_WIDTH,
+ XtNheight, DMX_CANVAS_HEIGHT,
+ NULL);
+
+
+ /* Main menu buttons */
+ filebutton = XtVaCreateManagedWidget("File", menuButtonWidgetClass,
+ menubox,
+ XtNmenuName, "filemenu",
+ NULL);
+ helpbutton = XtVaCreateManagedWidget("Help", menuButtonWidgetClass,
+ menubox,
+ XtNmenuName, "helpmenu",
+ NULL);
+
+
+ /* File submenu buttons */
+ filemenu = XtVaCreatePopupShell("filemenu", simpleMenuWidgetClass,
+ filebutton, NULL);
+ openbutton = XtVaCreateManagedWidget("Open File", smeBSBObjectClass,
+ filemenu, NULL);
+ savebutton = XtVaCreateManagedWidget("Save File", smeBSBObjectClass,
+ filemenu,
+ NULL);
+ ncbutton = XtVaCreateManagedWidget("New Global", smeBSBObjectClass,
+ filemenu, NULL);
+ ecbutton = XtVaCreateManagedWidget("Edit Global", smeBSBObjectClass,
+ filemenu,
+ NULL);
+ dcbutton = XtVaCreateManagedWidget("Delete Global", smeBSBObjectClass,
+ filemenu,
+ NULL);
+ ndbutton0 = XtVaCreateManagedWidget("New Display", smeBSBObjectClass,
+ filemenu,
+ NULL);
+ quitbutton = XtVaCreateManagedWidget("Quit", smeBSBObjectClass,
+ filemenu, NULL);
+
+ /* Help submenu button */
+ helpmenu = XtVaCreatePopupShell("helpmenu", simpleMenuWidgetClass,
+ helpbutton, NULL);
+ aboutbutton = XtVaCreateManagedWidget("About", smeBSBObjectClass,
+ helpmenu, NULL);
+
+ /* Open popup */
+ openpopup = XtVaCreatePopupShell("openpopup", transientShellWidgetClass,
+ toplevel, NULL);
+ opendialog = XtVaCreateManagedWidget("opendialog", dialogWidgetClass,
+ openpopup,
+ XtNlabel, "Filename: ",
+ XtNvalue, dmxConfigFilename,
+ NULL);
+ okbutton = XtVaCreateManagedWidget("Open", commandWidgetClass,
+ opendialog, NULL);
+ canbutton = XtVaCreateManagedWidget("Cancel", commandWidgetClass,
+ opendialog, NULL);
+
+ /* EC popup */
+ ecpopup = XtVaCreatePopupShell("ecpopup", transientShellWidgetClass,
+ toplevel, NULL);
+ ecbox = XtVaCreateManagedWidget("ecbox", boxWidgetClass,
+ ecpopup, NULL);
+ ecdialog0 = XtVaCreateManagedWidget("ecdialog0", dialogWidgetClass,
+ ecbox,
+ XtNlabel, "Name: ",
+ XtNvalue, "",
+ NULL);
+ ecdialog1 = XtVaCreateManagedWidget("ecdialog1", dialogWidgetClass,
+ ecbox,
+ XtNlabel, "Dimension: ",
+ XtNvalue, "",
+ NULL);
+ ecokbutton = XtVaCreateManagedWidget("OK", commandWidgetClass,
+ ecbox, NULL);
+ eccanbutton = XtVaCreateManagedWidget("Cancel", commandWidgetClass,
+ ecbox, NULL);
+
+ /* ED popup */
+ edpopup = XtVaCreatePopupShell("edpopup", transientShellWidgetClass,
+ toplevel, NULL);
+ edbox = XtVaCreateManagedWidget("edbox", boxWidgetClass,
+ edpopup, NULL);
+ eddialog0 = XtVaCreateManagedWidget("eddialog0", dialogWidgetClass,
+ edbox,
+ XtNlabel, "Display Name: ",
+ XtNvalue, "",
+ NULL);
+ eddialog1 = XtVaCreateManagedWidget("eddialog1", dialogWidgetClass,
+ edbox,
+ XtNlabel, "Geometry: ",
+ XtNvalue, "",
+ NULL);
+ eddialog2 = XtVaCreateManagedWidget("eddialog2", dialogWidgetClass,
+ edbox,
+ XtNlabel, "Offset: ",
+ XtNvalue, "",
+ NULL);
+ edokbutton = XtVaCreateManagedWidget("OK", commandWidgetClass,
+ edbox, NULL);
+ edcanbutton = XtVaCreateManagedWidget("Cancel", commandWidgetClass,
+ edbox, NULL);
+
+ /* About popup */
+ aboutpopup = XtVaCreatePopupShell("aboutpopup",transientShellWidgetClass,
+ toplevel, NULL);
+ aboutbox = XtVaCreateManagedWidget("aboutbox", boxWidgetClass,
+ aboutpopup, NULL);
+ abouttext = XtVaCreateManagedWidget("abouttext", labelWidgetClass,
+ aboutbox,
+ XtNlabel, DMX_INFO,
+ NULL);
+ aboutok = XtVaCreateManagedWidget("OK", commandWidgetClass,
+ aboutbox, NULL);
+
+ /* Quit popup */
+ quitpopup = XtVaCreatePopupShell("quitpopup",transientShellWidgetClass,
+ toplevel, NULL);
+ quitbox = XtVaCreateManagedWidget("quitbox", boxWidgetClass,
+ quitpopup, NULL);
+ quittext = XtVaCreateManagedWidget("quittext", labelWidgetClass,
+ quitbox,
+ XtNlabel,
+ "Changes to the configuration\n"
+ "been made that have not yet\n"
+ "been saved. Do you want to\n"
+ "quit without saving?",
+ NULL);
+ quitok = XtVaCreateManagedWidget("Quit WITHOUT Saving",
+ commandWidgetClass,
+ quitbox, NULL);
+ quitcan = XtVaCreateManagedWidget("Continue Editing",
+ commandWidgetClass,
+ quitbox, NULL);
+
+ /* Button popup */
+ buttonpopup = XtVaCreatePopupShell("buttonpopup", simpleMenuWidgetClass,
+ toplevel, NULL);
+ ndbutton1 = XtVaCreateManagedWidget("New Display", smeBSBObjectClass,
+ buttonpopup,
+ NULL);
+ edbutton = XtVaCreateManagedWidget("Edit Display", smeBSBObjectClass,
+ buttonpopup,
+ NULL);
+ ddbutton = XtVaCreateManagedWidget("Delete Display", smeBSBObjectClass,
+ buttonpopup,
+ NULL);
+
+ /* Callbacks */
+ XtAddCallback(openbutton, XtNcallback, dmxConfigOpenCallback, NULL);
+ XtAddCallback(savebutton, XtNcallback, dmxConfigSaveCallback, NULL);
+ XtAddCallback(okbutton, XtNcallback, dmxConfigOkCallback, NULL);
+ XtAddCallback(canbutton, XtNcallback, dmxConfigCanCallback, NULL);
+
+ XtAppAddActions(appContext, actiontable, XtNumber(actiontable));
+ XtOverrideTranslations(canvas, XtParseTranslationTable(canvastrans));
+ XtOverrideTranslations(XtNameToWidget(opendialog, "value"),
+ XtParseTranslationTable(opentrans));
+ XtOverrideTranslations(XtNameToWidget(ecdialog0, "value"),
+ XtParseTranslationTable(opentrans));
+ XtOverrideTranslations(XtNameToWidget(ecdialog1, "value"),
+ XtParseTranslationTable(opentrans));
+ XtOverrideTranslations(XtNameToWidget(eddialog0, "value"),
+ XtParseTranslationTable(opentrans));
+ XtOverrideTranslations(XtNameToWidget(eddialog1, "value"),
+ XtParseTranslationTable(opentrans));
+ XtOverrideTranslations(XtNameToWidget(eddialog2, "value"),
+ XtParseTranslationTable(opentrans));
+
+ XtAddCallback(ncbutton, XtNcallback, dmxConfigNCCallback, NULL);
+ XtAddCallback(ecbutton, XtNcallback, dmxConfigECCallback, NULL);
+ XtAddCallback(ecokbutton, XtNcallback, dmxConfigECOkCallback, NULL);
+ XtAddCallback(eccanbutton, XtNcallback, dmxConfigECCanCallback, NULL);
+ XtAddCallback(dcbutton, XtNcallback, dmxConfigDCCallback, NULL);
+
+ XtAddCallback(ndbutton0, XtNcallback, dmxConfigNDCallback, NULL);
+ XtAddCallback(ndbutton1, XtNcallback, dmxConfigNDCallback, NULL);
+ XtAddCallback(edbutton, XtNcallback, dmxConfigEDCallback, NULL);
+ XtAddCallback(ddbutton, XtNcallback, dmxConfigDDCallback, NULL);
+ XtAddCallback(edokbutton, XtNcallback, dmxConfigEDOkCallback, NULL);
+ XtAddCallback(edcanbutton, XtNcallback, dmxConfigEDCanCallback, NULL);
+
+ XtAddCallback(aboutbutton, XtNcallback, dmxConfigAboutCallback, NULL);
+ XtAddCallback(aboutok, XtNcallback, dmxConfigAboutOkCallback, NULL);
+ XtAddCallback(quitok, XtNcallback, dmxConfigQuitOkCallback, NULL);
+ XtAddCallback(quitcan, XtNcallback, dmxConfigQuitCanCallback, NULL);
+
+ XtAddCallback(quitbutton, XtNcallback, dmxConfigQuitCallback, NULL);
+
+ XtAddCallback(canvas, XtNcallback, dmxConfigCanvasInput, NULL);
+ XtAddCallback(canvas, XtNcanvasExposeCallback, dmxConfigCanvasExpose,NULL);
+ XtAddCallback(canvas, XtNcanvasResizeCallback, dmxConfigCanvasResize,NULL);
+
+ if (dmxConfigFilename) dmxConfigReadFile();
+
+ XtRealizeWidget(toplevel);
+ dmxConfigCopystrings();
+ dmxConfigSetupCnamemenu();
+ XtAppMainLoop(appContext);
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/config/xdmxconfig.man b/nx-X11/programs/Xserver/hw/dmx/config/xdmxconfig.man
new file mode 100644
index 000000000..dcceea0e3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/config/xdmxconfig.man
@@ -0,0 +1,63 @@
+.\" $XFree86$
+.\" Copyright 2002 Red Hat Inc., Durham, North Carolina.
+.\" All Rights Reserved.
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation on the rights to use, copy, modify, merge,
+.\" publish, distribute, sublicense, and/or sell copies of the Software,
+.\" and to permit persons to whom the Software is furnished to do so,
+.\" subject to the following conditions:
+.\"
+.\" The above copyright notice and this permission notice (including the
+.\" next paragraph) shall be included in all copies or substantial
+.\" portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+.\" NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+.\" BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+.\" ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+.\" CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+.\" SOFTWARE.
+.\"
+.\" Authors:
+.\" Rickard E. (Rik) Faith <faith@redhat.com>
+.\"
+.TH xdmxconfig 1 __vendorversion__
+.SH NAME
+xdmxconfig - a graphical configuration tool for Xdmx configuration files
+.SH SYNOPSIS
+.B xdmxconfig
+[filename]
+.SH DESCRIPTION
+.I xdmxconfig
+reads, edits, and writes configuration files for the Xdmx server. The
+grammar for the configuration file is specified in the Xdmx(1) manual
+page.
+.PP
+To start from scratch, create a "New Global" and specify the name and
+overall dimensions for the configuration. Then use "New Display" to
+enter more displays.
+.PP
+If there is more than one configuration, the configuration name button
+will bring up a selection menu.
+.PP
+In the right-hand pannel, the left mouse button will move the
+highlighted display at "tool resolution"; the middle mouse button will
+move the highlighted display by a single pixel (at "wall resolution");
+and the right mouse button will bring up a menu allowing the highlighted
+display to be edited or deleted. The arrow keys will also move the
+highlighted display by a single pixel.
+.SH BUGS
+Currently, entries with the
+.B wall
+keyword are not editable, but will be preserved in the new output file.
+The tool will quit when requested by the user, even if a configuration
+file has not been written out (i.e., without warning). The menu
+interaction should be improved (menu entries that don't currently work
+should be greyed-out, for example). The Help button does not work.
+.SH "SEE ALSO"
+Xdmx(1), vdltodmx(1)
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmx.h b/nx-X11/programs/Xserver/hw/dmx/dmx.h
new file mode 100644
index 000000000..18e75de90
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmx.h
@@ -0,0 +1,374 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ * David H. Dawes <dawes@xfree86.org>
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Main header file included by all other DMX-related files.
+ */
+
+/** \mainpage
+ * - <a href="http://dmx.sourceforge.net">DMX Home Page</a>
+ * - <a href="http://sourceforge.net/projects/dmx">DMX Project Page (on
+ * Source Forge)</a>
+ * - <a href="http://dmx.sourceforge.net/dmx.html">Distributed Multihead
+ * X design</a>, the design document for DMX
+ * - <a href="http://dmx.sourceforge.net/DMXSpec.txt">Client-to-Server
+ * DMX Extension to the X Protocol</a>
+ */
+
+#ifndef DMX_H
+#define DMX_H
+
+#include "gcstruct.h"
+
+/* Handle client-side include files in one place. */
+#include "dmxclient.h"
+
+#include "globals.h"
+#include "scrnintstr.h"
+
+#ifdef RENDER
+#include "picturestr.h"
+#endif
+
+#ifdef GLXEXT
+#include <GL/glx.h>
+#include <GL/glxint.h>
+#endif
+
+typedef enum {
+ PosNone = -1,
+ PosAbsolute = 0,
+ PosRightOf,
+ PosLeftOf,
+ PosAbove,
+ PosBelow,
+ PosRelative
+} PositionType;
+
+/** Provide the typedef globally, but keep the contents opaque outside
+ * of the input routines. \see dmxinput.h */
+typedef struct _DMXInputInfo DMXInputInfo;
+
+/** Provide the typedef globally, but keep the contents opaque outside
+ * of the XSync statistic routines. \see dmxstat.c */
+typedef struct _DMXStatInfo DMXStatInfo;
+
+/** Global structure containing information about each backend screen. */
+typedef struct _DMXScreenInfo {
+ const char *name; /**< Name from command line or config file */
+ int index; /**< Index into dmxScreens global */
+
+ /*---------- Back-end X server information ----------*/
+
+ Display *beDisplay; /**< Back-end X server's display */
+ int beWidth; /**< Width of BE display */
+ int beHeight; /**< Height of BE display */
+ int beDepth; /**< Depth of BE display */
+ int beBPP; /**< Bits per pixel of BE display */
+ int beXDPI; /**< Horizontal dots per inch of BE */
+ int beYDPI; /**< Vertical dots per inch of BE */
+
+ int beNumDepths; /**< Number of depths on BE server */
+ int *beDepths; /**< Depths from BE server */
+
+ int beNumPixmapFormats; /**< Number of pixmap formats on BE */
+ XPixmapFormatValues *bePixmapFormats; /**< Pixmap formats on BE */
+
+ int beNumVisuals; /**< Number of visuals on BE */
+ XVisualInfo *beVisuals; /**< Visuals from BE server */
+ int beDefVisualIndex; /**< Default visual index of BE */
+
+ int beNumDefColormaps; /**< Number of default colormaps */
+ Colormap *beDefColormaps; /**< Default colormaps for DMX server */
+
+ Pixel beBlackPixel; /**< Default black pixel for BE */
+ Pixel beWhitePixel; /**< Default white pixel for BE */
+
+ /*---------- Screen window information ----------*/
+
+ Window scrnWin; /**< "Screen" window on backend display */
+ int scrnX; /**< X offset of "screen" WRT BE display */
+ int scrnY; /**< Y offset of "screen" WRT BE display */
+ int scrnWidth; /**< Width of "screen" */
+ int scrnHeight; /**< Height of "screen" */
+ int scrnXSign; /**< X offset sign of "screen" */
+ int scrnYSign; /**< Y offset sign of "screen" */
+
+ /** Default drawables for "screen" */
+ Drawable scrnDefDrawables[MAXFORMATS];
+
+ struct _DMXScreenInfo *next; /**< List of "screens" on same display */
+ struct _DMXScreenInfo *over; /**< List of "screens" that overlap */
+
+ /*---------- Root window information ----------*/
+
+ Window rootWin; /**< "Root" window on backend display */
+ int rootX; /**< X offset of "root" window WRT "screen"*/
+ int rootY; /**< Y offset of "root" window WRT "screen"*/
+ int rootWidth; /**< Width of "root" window */
+ int rootHeight; /**< Height of "root" window */
+
+ int rootXOrigin; /**< Global X origin of "root" window */
+ int rootYOrigin; /**< Global Y origin of "root" window */
+
+ /*---------- Shadow framebuffer information ----------*/
+
+ void *shadow; /**< Shadow framebuffer data (if enabled) */
+ XlibGC shadowGC; /**< Default GC used by shadow FB code */
+ XImage *shadowFBImage; /**< Screen image used by shadow FB code */
+
+ /*---------- Other related information ----------*/
+
+ int shared; /**< Non-zero if another Xdmx is running */
+
+ Bool WMRunningOnBE;
+
+ Cursor noCursor;
+ Cursor curCursor;
+ /* Support for cursors on overlapped
+ * backend displays. */
+ CursorPtr cursor;
+ int cursorVisible;
+ int cursorNotShared; /* for overlapping screens on a backend */
+
+ PositionType where; /**< Relative layout information */
+ int whereX; /**< Relative layout information */
+ int whereY; /**< Relative layout information */
+ int whereRefScreen; /**< Relative layout information */
+
+ int savedTimeout; /**< Original screen saver timeout */
+ int dpmsCapable; /**< Non-zero if backend is DPMS capable */
+ int dpmsEnabled; /**< Non-zero if DPMS enabled */
+ int dpmsStandby; /**< Original DPMS standby value */
+ int dpmsSuspend; /**< Original DPMS suspend value */
+ int dpmsOff; /**< Original DPMS off value */
+
+ DMXStatInfo *stat; /**< Statistics about XSync */
+ Bool needsSync; /**< True if an XSync is pending */
+
+#ifdef GLXEXT
+ /** Visual information for glxProxy */
+ int numGlxVisuals;
+ __GLXvisualConfig *glxVisuals;
+ int glxMajorOpcode;
+ int glxErrorBase;
+
+ /** FB config information for glxProxy */
+ __GLXFBConfig *fbconfigs;
+ int numFBConfigs;
+#endif
+
+ /** Function pointers to wrapped screen
+ * functions */
+ CloseScreenProcPtr CloseScreen;
+ SaveScreenProcPtr SaveScreen;
+
+ CreateGCProcPtr CreateGC;
+
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ PositionWindowProcPtr PositionWindow;
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ RestackWindowProcPtr RestackWindow;
+ WindowExposuresProcPtr WindowExposures;
+ PaintWindowBackgroundProcPtr PaintWindowBackground;
+ PaintWindowBorderProcPtr PaintWindowBorder;
+ CopyWindowProcPtr CopyWindow;
+
+ ResizeWindowProcPtr ResizeWindow;
+ ReparentWindowProcPtr ReparentWindow;
+
+ ChangeBorderWidthProcPtr ChangeBorderWidth;
+
+ GetImageProcPtr GetImage;
+ GetSpansProcPtr GetSpans;
+
+ CreatePixmapProcPtr CreatePixmap;
+ DestroyPixmapProcPtr DestroyPixmap;
+ BitmapToRegionProcPtr BitmapToRegion;
+
+ RealizeFontProcPtr RealizeFont;
+ UnrealizeFontProcPtr UnrealizeFont;
+
+ CreateColormapProcPtr CreateColormap;
+ DestroyColormapProcPtr DestroyColormap;
+ InstallColormapProcPtr InstallColormap;
+ StoreColorsProcPtr StoreColors;
+
+#ifdef SHAPE
+ SetShapeProcPtr SetShape;
+#endif
+
+#ifdef RENDER
+ CreatePictureProcPtr CreatePicture;
+ DestroyPictureProcPtr DestroyPicture;
+ ChangePictureClipProcPtr ChangePictureClip;
+ DestroyPictureClipProcPtr DestroyPictureClip;
+
+ ChangePictureProcPtr ChangePicture;
+ ValidatePictureProcPtr ValidatePicture;
+
+ CompositeProcPtr Composite;
+ GlyphsProcPtr Glyphs;
+ CompositeRectsProcPtr CompositeRects;
+
+ InitIndexedProcPtr InitIndexed;
+ CloseIndexedProcPtr CloseIndexed;
+ UpdateIndexedProcPtr UpdateIndexed;
+
+ TrapezoidsProcPtr Trapezoids;
+ TrianglesProcPtr Triangles;
+ TriStripProcPtr TriStrip;
+ TriFanProcPtr TriFan;
+#endif
+} DMXScreenInfo;
+
+/* Global variables available to all Xserver/hw/dmx routines. */
+extern int dmxNumScreens; /**< Number of dmxScreens */
+extern DMXScreenInfo *dmxScreens; /**< List of outputs */
+extern int dmxShadowFB; /**< Non-zero if using
+ * shadow frame-buffer
+ * (deprecated) */
+extern XErrorEvent dmxLastErrorEvent; /**< Last error that
+ * occurred */
+extern Bool dmxErrorOccurred; /**< True if an error
+ * occurred */
+extern Bool dmxOffScreenOpt; /**< True if using off
+ * screen
+ * optimizations */
+extern Bool dmxSubdividePrimitives; /**< True if using the
+ * primitive subdivision
+ * optimization */
+extern Bool dmxLazyWindowCreation; /**< True if using the
+ * lazy window creation
+ * optimization */
+extern Bool dmxUseXKB; /**< True if the XKB
+ * extension should be
+ * used with the backend
+ * servers */
+extern int dmxDepth; /**< Requested depth if
+ * non-zero */
+#ifdef GLXEXT
+extern Bool dmxGLXProxy; /**< True if glxProxy
+ * support is enabled */
+extern Bool dmxGLXSwapGroupSupport; /**< True if glxProxy
+ * support for swap
+ * groups and barriers
+ * is enabled */
+extern Bool dmxGLXSyncSwap; /**< True if glxProxy
+ * should force an XSync
+ * request after each
+ * swap buffers call */
+extern Bool dmxGLXFinishSwap; /**< True if glxProxy
+ * should force a
+ * glFinish request
+ * after each swap
+ * buffers call */
+#endif
+extern char *dmxFontPath; /**< NULL if no font
+ * path is set on the
+ * command line;
+ * otherwise, a string
+ * of comma separated
+ * paths built from the
+ * command line
+ * specified font
+ * paths */
+extern Bool dmxIgnoreBadFontPaths; /**< True if bad font
+ * paths should be
+ * ignored during server
+ * init */
+extern Bool dmxAddRemoveScreens; /**< True if add and
+ * remove screens support
+ * is enabled */
+
+/** Wrap screen or GC function pointer */
+#define DMX_WRAP(_entry, _newfunc, _saved, _actual) \
+do { \
+ (_saved)->_entry = (_actual)->_entry; \
+ (_actual)->_entry = (_newfunc); \
+} while (0)
+
+/** Unwrap screen or GC function pointer */
+#define DMX_UNWRAP(_entry, _saved, _actual) \
+do { \
+ (_actual)->_entry = (_saved)->_entry; \
+} while (0)
+
+/* Define the MAXSCREENSALLOC/FREE macros, when MAXSCREENS patch has not
+ * been applied to sources. */
+#ifdef MAXSCREENS
+#define MAXSCREEN_MAKECONSTSTR1(x) #x
+#define MAXSCREEN_MAKECONSTSTR2(x) MAXSCREEN_MAKECONSTSTR1(x)
+
+#define MAXSCREEN_FAILED_TXT "Failed at [" \
+ MAXSCREEN_MAKECONSTSTR2(__LINE__) ":" __FILE__ "] to allocate object: "
+
+#define _MAXSCREENSALLOCF(o,size,fatal) \
+ do { \
+ if (!o) { \
+ o = xalloc((size) * sizeof(*(o))); \
+ if (o) memset(o, 0, (size) * sizeof(*(o))); \
+ if (!o && fatal) FatalError(MAXSCREEN_FAILED_TXT #o); \
+ } \
+ } while (0)
+#define _MAXSCREENSALLOCR(o,size,retval) \
+ do { \
+ if (!o) { \
+ o = xalloc((size) * sizeof(*(o))); \
+ if (o) memset(o, 0, (size) * sizeof(*(o))); \
+ if (!o) return retval; \
+ } \
+ } while (0)
+
+#define MAXSCREENSFREE(o) \
+ do { \
+ if (o) xfree(o); \
+ o = NULL; \
+ } while (0)
+
+#define MAXSCREENSALLOC(o) _MAXSCREENSALLOCF(o,MAXSCREENS, 0)
+#define MAXSCREENSALLOC_FATAL(o) _MAXSCREENSALLOCF(o,MAXSCREENS, 1)
+#define MAXSCREENSALLOC_RETURN(o,r) _MAXSCREENSALLOCR(o,MAXSCREENS, (r))
+#define MAXSCREENSALLOCPLUSONE(o) _MAXSCREENSALLOCF(o,MAXSCREENS+1,0)
+#define MAXSCREENSALLOCPLUSONE_FATAL(o) _MAXSCREENSALLOCF(o,MAXSCREENS+1,1)
+#define MAXSCREENSCALLOC(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),0)
+#define MAXSCREENSCALLOC_FATAL(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),1)
+#endif
+
+#endif /* DMX_H */
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmx_glxvisuals.c b/nx-X11/programs/Xserver/hw/dmx/dmx_glxvisuals.c
new file mode 100644
index 000000000..1e0cbbc1b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmx_glxvisuals.c
@@ -0,0 +1,606 @@
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include <GL/glx.h>
+#include <GL/glxproto.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+#include "dmx_glxvisuals.h"
+
+__GLXvisualConfig *GetGLXVisualConfigs(Display *dpy, int screen, int *nconfigs)
+{
+ xGLXGetVisualConfigsReq *req;
+ xGLXGetVisualConfigsReply reply;
+ __GLXvisualConfig *config, *configs;
+ GLint i, j, nvisuals, nprops;
+ INT32 *props, *p;
+ int majorOpcode, dummy;
+ int num_good_visuals;
+
+ if (!XQueryExtension(dpy, "GLX", &majorOpcode, &dummy, &dummy)) {
+ return(NULL);
+ }
+
+ /* Send the glXGetVisualConfigs request */
+ LockDisplay(dpy);
+ GetReq(GLXGetVisualConfigs,req);
+ req->reqType = majorOpcode;
+ req->glxCode = X_GLXGetVisualConfigs;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply*) &reply, 0, False)) {
+ /* Something is busted. Punt. */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+
+ nvisuals = (int)reply.numVisuals;
+ if (!nvisuals) {
+ /* This screen does not support GL rendering */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+
+ /* Check number of properties per visual */
+ nprops = (int)reply.numProps;
+ if (nprops < __GLX_MIN_CONFIG_PROPS) {
+ /* Huh? Not in protocol defined limits. Punt */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+ props = (INT32*) Xmalloc(nprops * __GLX_SIZE_CARD32);
+ if (!props) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+
+ /* Allocate memory for our config structure */
+ config = (__GLXvisualConfig*)
+ Xmalloc(nvisuals * sizeof(__GLXvisualConfig));
+ if (!config) {
+ Xfree(props);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+ memset(config, 0, nvisuals * sizeof(__GLXvisualConfig));
+ configs = config;
+ num_good_visuals = 0;
+
+ /* Convert config structure into our format */
+ for (i=0; i<nvisuals; i++) {
+
+ /* Read config structure */
+ _XRead(dpy, (char *)props, (nprops * __GLX_SIZE_CARD32));
+
+ /* fill in default values */
+ config->visualRating = GLX_NONE_EXT;
+ config->transparentPixel = GLX_NONE_EXT;
+
+ /* Copy in the first set of properties */
+ config->vid = props[0];
+ config->class = props[1];
+
+ config->rgba = (Bool) props[2];
+
+ config->redSize = props[3];
+ config->greenSize = props[4];
+ config->blueSize = props[5];
+ config->alphaSize = props[6];
+
+ config->accumRedSize = props[7];
+ config->accumGreenSize = props[8];
+ config->accumBlueSize = props[9];
+ config->accumAlphaSize = props[10];
+
+ config->doubleBuffer = (Bool) props[11];
+ config->stereo = (Bool) props[12];
+
+ config->bufferSize = props[13];
+ config->depthSize = props[14];
+ config->stencilSize = props[15];
+
+ config->auxBuffers = props[16];
+ config->level = props[17];
+
+ /* Process remaining properties */
+ p = &props[18];
+ for (j=__GLX_MIN_CONFIG_PROPS; j<nprops; j+=2) {
+ int property = *p++;
+ int value = *p++;
+
+ switch (property) {
+ case GLX_SAMPLES_SGIS:
+ config->multiSampleSize = value;
+ break;
+ case GLX_SAMPLE_BUFFERS_SGIS:
+ config->nMultiSampleBuffers = value;
+ break;
+
+ case GLX_TRANSPARENT_TYPE_EXT:
+ config->transparentPixel = value;
+ break;
+ case GLX_TRANSPARENT_INDEX_VALUE_EXT:
+ config->transparentIndex = value;
+ break;
+ case GLX_TRANSPARENT_RED_VALUE_EXT:
+ config->transparentRed = value;
+ break;
+ case GLX_TRANSPARENT_GREEN_VALUE_EXT:
+ config->transparentGreen = value;
+ break;
+ case GLX_TRANSPARENT_BLUE_VALUE_EXT:
+ config->transparentBlue = value;
+ break;
+ case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
+ config->transparentAlpha = value;
+ break;
+
+ case GLX_VISUAL_CAVEAT_EXT:
+ config->visualRating = value;
+ break;
+
+ /* visualSelectGroup is an internal used property */
+ case GLX_VISUAL_SELECT_GROUP_SGIX:
+ config->visualSelectGroup = value;
+ break;
+
+ default :
+ /* Ignore properties we don't recognize */
+ break;
+ }
+ } /* for j */
+
+ /*
+ // filter out overlay visuals (dmx does not support overlays)
+ */
+ if (config->level == 0) {
+ config++;
+ num_good_visuals++;
+ }
+
+ } /* for i */
+
+ UnlockDisplay(dpy);
+
+ nvisuals = num_good_visuals;
+
+ config = configs;
+ for (i=0; i<nvisuals; i++) {
+ /* XXX hack to fill-in mask info (need a better way to do this) */
+ {
+ XVisualInfo *vis, template;
+ int n;
+
+ template.screen = screen;
+ template.visualid = config->vid;
+ vis = XGetVisualInfo(dpy, VisualScreenMask|VisualIDMask,
+ &template, &n);
+
+ if (vis != NULL) {
+ config->redMask = vis->red_mask;
+ config->greenMask = vis->green_mask;
+ config->blueMask = vis->blue_mask;
+ config->alphaMask = 0; /* XXX */
+ free(vis);
+ }
+ }
+ config++;
+ } /* for i */
+
+ XFree(props);
+ SyncHandle();
+
+ *nconfigs = nvisuals;
+ return( configs );
+}
+
+
+__GLXFBConfig *GetGLXFBConfigs(Display *dpy, int glxMajorOpcode, int *nconfigs)
+{
+ xGLXGetFBConfigsReq *req;
+ xGLXGetFBConfigsReply reply;
+ __GLXFBConfig *config, *fbconfigs;
+ GLint i, j, numFBConfigs, numAttribs;
+ INT32 *attrs, *p;
+ int screen = DefaultScreen( dpy );
+ int numValidConfigs = 0;
+
+ /* Send the glXGetFBConfigs request */
+ LockDisplay(dpy);
+ GetReq(GLXGetFBConfigs, req);
+ req->reqType = glxMajorOpcode;
+ req->glxCode = X_GLXGetFBConfigs;
+ req->screen = screen;
+
+ *nconfigs = 0;
+
+ if (!_XReply(dpy, (xReply*) &reply, 0, False)) {
+ /* Something is busted. Punt. */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+
+ numFBConfigs = (int)reply.numFBConfigs;
+ if (!numFBConfigs) {
+ /* This screen does not support GL rendering */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+
+ numAttribs = (int)reply.numAttribs;
+ if (!numAttribs) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+
+ attrs = (INT32*) Xmalloc(2*numAttribs * __GLX_SIZE_CARD32);
+ if (!attrs) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+
+ /* Allocate memory for our config structure */
+ config = (__GLXFBConfig*)
+ Xmalloc(numFBConfigs * sizeof(__GLXFBConfig));
+ if (!config) {
+ Xfree(attrs);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+ memset(config, 0, numFBConfigs * sizeof(__GLXFBConfig));
+ fbconfigs = config;
+
+ /* Convert attribute list into our format */
+ for (i=0; i<numFBConfigs; i++) {
+
+ /* Fill in default properties */
+ config->transparentType = GLX_NONE_EXT;
+ config->visualCaveat = GLX_NONE_EXT;
+ config->minRed = 0.;
+ config->maxRed = 1.;
+ config->minGreen = 0.;
+ config->maxGreen = 1.;
+ config->minBlue = 0.;
+ config->maxBlue = 1.;
+ config->minAlpha = 0.;
+ config->maxAlpha = 1.;
+
+ /* Read attribute list */
+ _XRead(dpy, (char *)attrs, (2*numAttribs * __GLX_SIZE_CARD32));
+
+ p = attrs;
+ for (j=0; j<numAttribs; j++) {
+ int attribute = *p++;
+ int value = *p++;
+
+ switch (attribute) {
+ /* core attributes */
+ case GLX_FBCONFIG_ID:
+ config->id = value;
+ break;
+ case GLX_BUFFER_SIZE:
+ config->indexBits = value;
+ break;
+ case GLX_LEVEL:
+ config->level = value;
+ break;
+ case GLX_DOUBLEBUFFER:
+ config->doubleBufferMode = value;
+ break;
+ case GLX_STEREO:
+ config->stereoMode = value;
+ break;
+ case GLX_AUX_BUFFERS:
+ config->maxAuxBuffers = value;
+ break;
+ case GLX_RED_SIZE:
+ config->redBits = value;
+ break;
+ case GLX_GREEN_SIZE:
+ config->greenBits = value;
+ break;
+ case GLX_BLUE_SIZE:
+ config->blueBits = value;
+ break;
+ case GLX_ALPHA_SIZE:
+ config->alphaBits = value;
+ break;
+ case GLX_DEPTH_SIZE:
+ config->depthBits = value;
+ break;
+ case GLX_STENCIL_SIZE:
+ config->stencilBits = value;
+ break;
+ case GLX_ACCUM_RED_SIZE:
+ config->accumRedBits = value;
+ break;
+ case GLX_ACCUM_GREEN_SIZE:
+ config->accumGreenBits = value;
+ break;
+ case GLX_ACCUM_BLUE_SIZE:
+ config->accumBlueBits = value;
+ break;
+ case GLX_ACCUM_ALPHA_SIZE:
+ config->accumAlphaBits = value;
+ break;
+ case GLX_RENDER_TYPE:
+ config->renderType = value;
+ break;
+ case GLX_DRAWABLE_TYPE:
+ config->drawableType = value;
+ break;
+ case GLX_X_VISUAL_TYPE:
+ config->visualType = value;
+ break;
+ case GLX_CONFIG_CAVEAT:
+ config->visualCaveat = value;
+ break;
+ case GLX_TRANSPARENT_TYPE:
+ config->transparentType = value;
+ break;
+ case GLX_TRANSPARENT_INDEX_VALUE:
+ config->transparentIndex = value;
+ break;
+ case GLX_TRANSPARENT_RED_VALUE:
+ config->transparentRed = value;
+ break;
+ case GLX_TRANSPARENT_GREEN_VALUE:
+ config->transparentGreen = value;
+ break;
+ case GLX_TRANSPARENT_BLUE_VALUE:
+ config->transparentBlue = value;
+ break;
+ case GLX_TRANSPARENT_ALPHA_VALUE:
+ config->transparentAlpha = value;
+ break;
+ case GLX_MAX_PBUFFER_WIDTH:
+ config->maxPbufferWidth = value;
+ break;
+ case GLX_MAX_PBUFFER_HEIGHT:
+ config->maxPbufferHeight = value;
+ break;
+ case GLX_MAX_PBUFFER_PIXELS:
+ config->maxPbufferPixels = value;
+ break;
+ case GLX_VISUAL_ID:
+ config->associatedVisualId = value;
+ break;
+
+ /* visualSelectGroup is an internal used property */
+ case GLX_VISUAL_SELECT_GROUP_SGIX:
+ config->visualSelectGroup = value;
+ break;
+
+ /* SGIS_multisample attributes */
+ case GLX_SAMPLES_SGIS:
+ config->multiSampleSize = value;
+ break;
+ case GLX_SAMPLE_BUFFERS_SGIS:
+ config->nMultiSampleBuffers = value;
+ break;
+
+ /* SGIX_pbuffer specific attributes */
+ case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
+ config->optimalPbufferWidth = value;
+ break;
+ case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
+ config->optimalPbufferHeight = value;
+ break;
+
+ default:
+ /* Ignore attributes we don't recognize */
+ break;
+ }
+ } /* for j */
+
+ /* Fill in derived values */
+ config->screen = screen;
+
+ config->rgbMode = config->renderType & GLX_RGBA_BIT;
+ config->colorIndexMode = !config->rgbMode;
+
+ config->haveAccumBuffer =
+ config->accumRedBits > 0 ||
+ config->accumGreenBits > 0 ||
+ config->accumBlueBits > 0;
+ /* Can't have alpha without color */
+
+ config->haveDepthBuffer = config->depthBits > 0;
+ config->haveStencilBuffer = config->stencilBits > 0;
+
+ /* overlay visuals are not valid for now */
+ if (!config->level) {
+ config++;
+ numValidConfigs++;
+ }
+
+ } /* for i */
+ UnlockDisplay(dpy);
+
+ config = fbconfigs;
+ for (i=0; i<numValidConfigs; i++) {
+
+ /* XXX hack to fill-in mask info (need a better way to do this) */
+ if (config->associatedVisualId != 0) {
+ XVisualInfo *vis, template;
+ int n;
+
+ template.screen = screen;
+ template.visualid = config->associatedVisualId;
+ vis = XGetVisualInfo(dpy, VisualScreenMask|VisualIDMask,
+ &template, &n);
+
+ if (vis != NULL) {
+ config->redMask = (GLuint)vis->red_mask;
+ config->greenMask = (GLuint)vis->green_mask;
+ config->blueMask = (GLuint)vis->blue_mask;
+ config->alphaMask = 0; /* XXX */
+ free(vis);
+ }
+ }
+
+ config++;
+ } /* for i */
+
+ XFree(attrs);
+ SyncHandle();
+
+ *nconfigs = numValidConfigs;
+ return fbconfigs;
+}
+
+__GLXvisualConfig *
+GetGLXVisualConfigsFromFBConfigs(__GLXFBConfig *fbconfigs, int nfbconfigs,
+ XVisualInfo *visuals, int nvisuals,
+ __GLXvisualConfig *glxConfigs, int nGlxConfigs,
+ int *nconfigs)
+{
+ __GLXvisualConfig *configs = NULL;
+ int i;
+
+ if (!fbconfigs || !nfbconfigs || !nconfigs) return(NULL);
+ *nconfigs = 0;
+
+ /* Allocate memory for our config structure */
+ configs = (__GLXvisualConfig*)
+ Xmalloc(nfbconfigs * sizeof(__GLXvisualConfig));
+ if (!configs) {
+ return NULL;
+ }
+ memset(configs, 0, nfbconfigs * sizeof(__GLXvisualConfig));
+
+ for (i=0; i<nfbconfigs; i++) {
+ __GLXFBConfig *fbcfg = &fbconfigs[i];
+
+ if (fbcfg->associatedVisualId > 0) {
+ __GLXvisualConfig *cfg = configs + (*nconfigs);
+ int j;
+ XVisualInfo *vinfo = NULL;
+
+ for (j=0; j<nvisuals; j++) {
+ if (visuals[j].visualid == fbcfg->associatedVisualId) {
+ vinfo = &visuals[j];
+ break;
+ }
+ }
+ if (!vinfo) continue;
+
+ /* skip 16 bit colormap visuals */
+ if (vinfo->depth == 16 &&
+ vinfo->class != TrueColor &&
+ vinfo->class != DirectColor ) {
+ continue;
+ }
+
+ (*nconfigs)++;
+
+ /*
+ * if the same visualid exists in the glx configs,
+ * copy the glx attributes from the glx config
+ */
+ for (j=0; j<nGlxConfigs; j++) {
+ if (glxConfigs[j].vid == vinfo->visualid)
+ break;
+ }
+ if (j < nGlxConfigs) {
+ memcpy(cfg, &glxConfigs[j], sizeof(__GLXvisualConfig) );
+ continue;
+ }
+
+ /*
+ * make glx attributes from the FB config attributes
+ */
+ cfg->vid = fbcfg->associatedVisualId;
+ cfg->class = vinfo->class;
+ cfg->rgba = !(fbcfg->renderType & GLX_COLOR_INDEX_BIT_SGIX);
+ cfg->redSize = fbcfg->redBits;
+ cfg->greenSize = fbcfg->greenBits;
+ cfg->blueSize = fbcfg->blueBits;
+ cfg->alphaSize = fbcfg->alphaBits;
+ cfg->redMask = fbcfg->redMask;
+ cfg->greenMask = fbcfg->greenMask;
+ cfg->blueMask = fbcfg->blueMask;
+ cfg->alphaMask = fbcfg->alphaMask;
+ cfg->accumRedSize = fbcfg->accumRedBits;
+ cfg->accumGreenSize = fbcfg->accumGreenBits;
+ cfg->accumBlueSize = fbcfg->accumBlueBits;
+ cfg->accumAlphaSize = fbcfg->accumAlphaBits;
+ cfg->doubleBuffer = fbcfg->doubleBufferMode;
+ cfg->stereo = fbcfg->stereoMode;
+ if (vinfo->class == TrueColor || vinfo->class == DirectColor) {
+ cfg->bufferSize = (fbcfg->rgbMode ? (fbcfg->redBits +
+ fbcfg->greenBits +
+ fbcfg->blueBits +
+ fbcfg->alphaBits)
+ : fbcfg->indexBits );
+ }
+ else {
+ cfg->bufferSize = vinfo->depth;
+ }
+ cfg->depthSize = fbcfg->depthBits;
+ cfg->stencilSize = fbcfg->stencilBits;
+ cfg->auxBuffers = fbcfg->maxAuxBuffers;
+ cfg->level = fbcfg->level;
+ cfg->visualRating = fbcfg->visualCaveat;
+ cfg->transparentPixel = fbcfg->transparentType;
+ cfg->transparentRed = fbcfg->transparentRed;
+ cfg->transparentGreen = fbcfg->transparentGreen;
+ cfg->transparentBlue = fbcfg->transparentBlue;
+ cfg->transparentAlpha = fbcfg->transparentAlpha;
+ cfg->transparentIndex = fbcfg->transparentIndex;
+ cfg->multiSampleSize = fbcfg->multiSampleSize;
+ cfg->nMultiSampleBuffers = fbcfg->nMultiSampleBuffers;
+ cfg->visualSelectGroup = fbcfg->visualSelectGroup;
+ }
+ }
+
+ return( configs );
+}
+
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmx_glxvisuals.h b/nx-X11/programs/Xserver/hw/dmx/dmx_glxvisuals.h
new file mode 100644
index 000000000..a9ac2e9ac
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmx_glxvisuals.h
@@ -0,0 +1,64 @@
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#ifndef _GLXVISUALS_H
+#define _GLXVISUALS_H
+
+#include <GL/glxint.h>
+
+/** GLX Visual private area. */
+typedef struct {
+ int x_visual_depth;
+ int x_visual_class;
+} dmxGlxVisualPrivate;
+
+__GLXvisualConfig *GetGLXVisualConfigs(Display *dpy,
+ int screen,
+ int *nconfigs);
+
+__GLXFBConfig *GetGLXFBConfigs(Display *dpy,
+ int glxMajorOpcode,
+ int *nconfigs);
+
+__GLXvisualConfig *GetGLXVisualConfigsFromFBConfigs(__GLXFBConfig *fbconfigs,
+ int nfbconfigs,
+ XVisualInfo *visuals,
+ int nvisuals,
+ __GLXvisualConfig
+ *glxConfigs,
+ int nGlxConfigs,
+ int *nconfigs);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxcb.c b/nx-X11/programs/Xserver/hw/dmx/dmxcb.c
new file mode 100644
index 000000000..b1f47bde4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxcb.c
@@ -0,0 +1,224 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * This code queries and modifies the connection block. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxcb.h"
+#include "dmxinput.h"
+#include "dmxlog.h"
+
+extern char *ConnectionInfo;
+extern int connBlockScreenStart;
+
+#ifdef PANORAMIX
+extern int PanoramiXPixWidth;
+extern int PanoramiXPixHeight;
+extern int PanoramiXNumScreens;
+#endif
+
+ int dmxGlobalWidth, dmxGlobalHeight;
+
+/** We may want the wall dimensions to be different from the bounding
+ * box dimensions that Xinerama computes, so save those and update them
+ * here.
+ */
+void dmxSetWidthHeight(int width, int height)
+{
+ dmxGlobalWidth = width;
+ dmxGlobalHeight = height;
+}
+
+/** Computes the global bounding box for DMX. This may be larger than
+ * the one computed by Xinerama because of the DMX configuration
+ * file. */
+void dmxComputeWidthHeight(DMXRecomputeFlag flag)
+{
+ int i;
+ DMXScreenInfo *dmxScreen;
+ int w = 0;
+ int h = 0;
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ /* Don't use root* here because this is
+ * the global bounding box. */
+ dmxScreen = &dmxScreens[i];
+ if (w < dmxScreen->scrnWidth + dmxScreen->rootXOrigin)
+ w = dmxScreen->scrnWidth + dmxScreen->rootXOrigin;
+ if (h < dmxScreen->scrnHeight + dmxScreen->rootYOrigin)
+ h = dmxScreen->scrnHeight + dmxScreen->rootYOrigin;
+ }
+ if (!dmxGlobalWidth && !dmxGlobalHeight) {
+ dmxLog(dmxInfo, "Using %dx%d as global bounding box\n", w, h);
+ } else {
+ switch (flag) {
+ case DMX_NO_RECOMPUTE_BOUNDING_BOX:
+ dmxLog(dmxInfo,
+ "Using old bounding box (%dx%d) instead of new (%dx%d)\n",
+ dmxGlobalWidth, dmxGlobalHeight, w, h);
+ w = dmxGlobalWidth;
+ h = dmxGlobalHeight;
+ break;
+ case DMX_RECOMPUTE_BOUNDING_BOX:
+ dmxLog(dmxInfo,
+ "Using %dx%d as global bounding box, instead of %dx%d\n",
+ w, h, dmxGlobalWidth, dmxGlobalHeight);
+ break;
+ }
+ }
+
+ dmxGlobalWidth = w;
+ dmxGlobalHeight = h;
+}
+
+/** A callback routine that hooks into Xinerama and provides a
+ * convenient place to print summary log information during server
+ * startup. This routine does not modify any values. */
+void dmxConnectionBlockCallback(void)
+{
+ xWindowRoot *root = (xWindowRoot *)(ConnectionInfo+connBlockScreenStart);
+ int offset = connBlockScreenStart + sizeof(xWindowRoot);
+ int i;
+ Bool *found = NULL;
+
+ MAXSCREENSALLOC(found);
+ if (!found)
+ dmxLog(dmxFatal, "dmxConnectionBlockCallback: out of memory\n");
+
+ dmxLog(dmxInfo, "===== Start of Summary =====\n");
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ if (dmxGlobalWidth && dmxGlobalHeight
+ && (dmxGlobalWidth != PanoramiXPixWidth
+ || dmxGlobalHeight != PanoramiXPixHeight)) {
+ dmxLog(dmxInfo,
+ "Changing Xinerama dimensions from %d %d to %d %d\n",
+ PanoramiXPixWidth, PanoramiXPixHeight,
+ dmxGlobalWidth, dmxGlobalHeight);
+ PanoramiXPixWidth = root->pixWidth = dmxGlobalWidth;
+ PanoramiXPixHeight = root->pixHeight = dmxGlobalHeight;
+ } else {
+ dmxGlobalWidth = PanoramiXPixWidth;
+ dmxGlobalHeight = PanoramiXPixHeight;
+ }
+ dmxLog(dmxInfo, "%d screens configured with Xinerama (%d %d)\n",
+ PanoramiXNumScreens, PanoramiXPixWidth, PanoramiXPixHeight);
+ for (i = 0; i < PanoramiXNumScreens; i++) found[i] = FALSE;
+ } else {
+#endif
+ /* This never happens because we're
+ * either called from a Xinerama
+ * callback or during reconfiguration
+ * (which only works with Xinerama on).
+ * In any case, be reasonable. */
+ dmxLog(dmxInfo, "%d screens configured (%d %d)\n",
+ screenInfo.numScreens, root->pixWidth, root->pixHeight);
+#ifdef PANORAMIX
+ }
+#endif
+
+ for (i = 0; i < root->nDepths; i++) {
+ xDepth *depth = (xDepth *)(ConnectionInfo + offset);
+ int voffset = offset + sizeof(xDepth);
+ xVisualType *visual = (xVisualType *)(ConnectionInfo + voffset);
+ int j;
+
+ dmxLog(dmxInfo, "%d visuals at depth %d:\n",
+ depth->nVisuals, depth->depth);
+ for (j = 0; j < depth->nVisuals; j++, visual++) {
+ XVisualInfo vi;
+
+ vi.visual = NULL;
+ vi.visualid = visual->visualID;
+ vi.screen = 0;
+ vi.depth = depth->depth;
+ vi.class = visual->class;
+ vi.red_mask = visual->redMask;
+ vi.green_mask = visual->greenMask;
+ vi.blue_mask = visual->blueMask;
+ vi.colormap_size = visual->colormapEntries;
+ vi.bits_per_rgb = visual->bitsPerRGB;
+ dmxLogVisual(NULL, &vi, 0);
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ int k;
+ for (k = 0; k < PanoramiXNumScreens; k++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[k];
+
+ if (dmxScreen->beDisplay) {
+ XVisualInfo *pvi =
+ &dmxScreen->beVisuals[dmxScreen->beDefVisualIndex];
+ if (pvi->depth == depth->depth &&
+ pvi->class == visual->class)
+ found[k] = TRUE;
+ } else {
+ /* Screen #k is detatched, so it always succeeds */
+ found[k] = TRUE;
+ }
+ }
+ }
+#endif
+ }
+ offset = voffset + depth->nVisuals * sizeof(xVisualType);
+ }
+
+ dmxInputLogDevices();
+ dmxLog(dmxInfo, "===== End of Summary =====\n");
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ Bool fatal = FALSE;
+ for (i = 0; i < PanoramiXNumScreens; i++) {
+ fatal |= !found[i];
+ if (!found[i]) {
+ dmxLog(dmxError,
+ "The default visual for screen #%d does not match "
+ "any of the\n", i);
+ dmxLog(dmxError,
+ "consolidated visuals from Xinerama (listed above)\n");
+ }
+ }
+ if (fatal)
+ dmxLog(dmxFatal,
+ "dmxConnectionBlockCallback: invalid screen(s) found");
+ }
+#endif
+ MAXSCREENSFREE(found);
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxcb.h b/nx-X11/programs/Xserver/hw/dmx/dmxcb.h
new file mode 100644
index 000000000..38ffa5671
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxcb.h
@@ -0,0 +1,54 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001,2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Header file for connection block functions. \see dmxcb.c.
+ */
+
+#ifndef _DMXCB_H_
+#define _DMXCB_H_
+/** The cursor position, in global coordinates. */
+extern int dmxGlobalWidth, dmxGlobalHeight;
+
+/** #dmxComputeWidthHeight can either recompute the global bounding box
+ * or not. */
+typedef enum {
+ DMX_RECOMPUTE_BOUNDING_BOX,
+ DMX_NO_RECOMPUTE_BOUNDING_BOX
+} DMXRecomputeFlag;
+
+extern void dmxSetWidthHeight(int width, int height);
+extern void dmxComputeWidthHeight(DMXRecomputeFlag flag);
+extern void dmxConnectionBlockCallback(void);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxclient.h b/nx-X11/programs/Xserver/hw/dmx/dmxclient.h
new file mode 100644
index 000000000..586b82990
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxclient.h
@@ -0,0 +1,152 @@
+/* $XFree86$ */
+/*
+ * Copyright (c) 1995 X Consortium
+ * Copyright 2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT, THE X CONSORTIUM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the X Consortium
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization from the X Consortium.
+ */
+
+/*
+ * Derived from hw/xnest/Xnest.h by Rickard E. (Rik) Faith <faith@redhat.com>
+ */
+
+/** \file
+ * This file includes all client-side include files with proper wrapping.
+ */
+
+#ifndef _DMXCLIENT_H_
+#define _DMXCLIENT_H_
+
+#define GC XlibGC
+
+#ifdef _XSERVER64
+#define DMX64
+#undef _XSERVER64
+typedef unsigned long XID64;
+typedef unsigned long Mask64;
+typedef unsigned long Atom64;
+typedef unsigned long VisualID64;
+typedef unsigned long Time64;
+#define XID XID64
+#define Mask Mask64
+#define Atom Atom64
+#define VisualID VisualID64
+#define Time Time64
+typedef XID Window64;
+typedef XID Drawable64;
+typedef XID Font64;
+typedef XID Pixmap64;
+typedef XID Cursor64;
+typedef XID Colormap64;
+typedef XID GContext64;
+typedef XID KeySym64;
+#define Window Window64
+#define Drawable Drawable64
+#define Font Font64
+#define Pixmap Pixmap64
+#define Cursor Cursor64
+#define Colormap Colormap64
+#define GContext GContext64
+#define KeySym KeySym64
+#endif
+
+#include <X11/Xlib.h>
+#include <X11/Xlibint.h> /* For _XExtension */
+#include <X11/X.h> /* from glxserver.h */
+#include <X11/Xmd.h> /* from glxserver.h */
+#include <X11/Xproto.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/cursorfont.h>
+#include <X11/Xmu/SysUtil.h> /* For XmuSnprintf */
+
+#ifdef SHAPE
+#include <X11/extensions/shape.h>
+#endif
+
+#ifdef RENDER
+#include <X11/extensions/Xrender.h>
+#undef PictFormatType
+#endif
+
+#ifdef XKB
+#include <X11/extensions/XKB.h>
+#include <X11/extensions/XKBstr.h>
+#endif
+
+#ifdef XINPUT
+#include <X11/extensions/XI.h>
+#endif
+
+/* Always include these, since we query them even if we don't export XINPUT. */
+#include <X11/extensions/XInput.h> /* For XDevice */
+#include <X11/extensions/Xext.h>
+
+#undef GC
+
+#ifdef DMX64
+#define _XSERVER64
+#undef XID
+#undef Mask
+#undef Atom
+#undef VisualID
+#undef Time
+#undef Window
+#undef Drawable
+#undef Font
+#undef Pixmap
+#undef Cursor
+#undef Colormap
+#undef GContext
+#undef KeySym
+#endif
+
+/* These are in exglobals.h, but that conflicts with X11/extensions/XKBsrv.h */
+extern int ProximityIn;
+extern int ProximityOut;
+extern int DeviceValuator;
+extern int DeviceMotionNotify;
+extern int DeviceFocusIn;
+extern int DeviceFocusOut;
+extern int DeviceStateNotify;
+extern int DeviceMappingNotify;
+extern int ChangeDeviceNotify;
+
+/* Some protocol gets included last, after undefines. */
+#include <X11/XKBlib.h>
+#ifdef XKB
+#include <X11/extensions/XKBproto.h>
+#ifndef XKB_IN_SERVER
+#define XKB_IN_SERVER
+#endif
+#include <X11/extensions/XKBsrv.h>
+#undef XPointer
+#endif
+#include <X11/extensions/XIproto.h>
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxcmap.c b/nx-X11/programs/Xserver/hw/dmx/dmxcmap.c
new file mode 100644
index 000000000..f46dc5411
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxcmap.c
@@ -0,0 +1,220 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * Colormap support. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxsync.h"
+#include "dmxcmap.h"
+#include "dmxvisual.h"
+
+#include "micmap.h"
+
+static int dmxInitColormapPrivateFunc(ColormapPtr pColormap)
+{
+ return TRUE;
+}
+
+static Bool dmxAllocateColormapPrivates(ColormapPtr pColormap)
+{
+ static unsigned long dmxColormapGeneration;
+ dmxColormapPrivPtr pCmapPriv;
+
+ if (dmxColormapGeneration != serverGeneration) {
+ if ((dmxColormapPrivateIndex
+ = AllocateColormapPrivateIndex(dmxInitColormapPrivateFunc)) < 0)
+ return FALSE;
+
+ dmxColormapGeneration = serverGeneration;
+ }
+
+ pCmapPriv = (dmxColormapPrivPtr)xalloc(sizeof(*pCmapPriv));
+ if (!pCmapPriv)
+ return FALSE;
+ pCmapPriv->cmap = (Colormap)0;
+
+ DMX_SET_COLORMAP_PRIV(pColormap, pCmapPriv);
+
+ return TRUE;
+}
+
+/** Create \a pColormap on the back-end server. */
+Bool dmxBECreateColormap(ColormapPtr pColormap)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxColormapPrivPtr pCmapPriv = DMX_GET_COLORMAP_PRIV(pColormap);
+ VisualPtr pVisual = pColormap->pVisual;
+ Visual *visual = dmxLookupVisual(pScreen, pVisual);
+
+ pCmapPriv->cmap = XCreateColormap(dmxScreen->beDisplay,
+ dmxScreen->scrnWin,
+ visual,
+ (pVisual->class & DynamicClass ?
+ AllocAll : AllocNone));
+ return (pCmapPriv->cmap != 0);
+}
+
+/** Create colormap on back-end server associated with \a pColormap's
+ * screen. */
+Bool dmxCreateColormap(ColormapPtr pColormap)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+
+ if (!dmxAllocateColormapPrivates(pColormap))
+ return FALSE;
+
+ if (dmxScreen->beDisplay) {
+ if (!dmxBECreateColormap(pColormap))
+ return FALSE;
+ }
+
+ DMX_UNWRAP(CreateColormap, dmxScreen, pScreen);
+ if (pScreen->CreateColormap)
+ ret = pScreen->CreateColormap(pColormap);
+ DMX_WRAP(CreateColormap, dmxCreateColormap, dmxScreen, pScreen);
+
+ return ret;
+}
+
+/** Destroy \a pColormap on the back-end server. */
+Bool dmxBEFreeColormap(ColormapPtr pColormap)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxColormapPrivPtr pCmapPriv = DMX_GET_COLORMAP_PRIV(pColormap);
+
+ if (pCmapPriv->cmap) {
+ XFreeColormap(dmxScreen->beDisplay, pCmapPriv->cmap);
+ pCmapPriv->cmap = (Colormap)0;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/** Destroy colormap on back-end server associated with \a pColormap's
+ * screen. */
+void dmxDestroyColormap(ColormapPtr pColormap)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxColormapPrivPtr pCmapPriv = DMX_GET_COLORMAP_PRIV(pColormap);
+
+ if (dmxScreen->beDisplay)
+ dmxBEFreeColormap(pColormap);
+ xfree(pCmapPriv);
+ DMX_SET_COLORMAP_PRIV(pColormap, NULL);
+
+ DMX_UNWRAP(DestroyColormap, dmxScreen, pScreen);
+ if (pScreen->DestroyColormap)
+ pScreen->DestroyColormap(pColormap);
+ DMX_WRAP(DestroyColormap, dmxDestroyColormap, dmxScreen, pScreen);
+}
+
+/** Install colormap on back-end server associated with \a pColormap's
+ * screen. */
+void dmxInstallColormap(ColormapPtr pColormap)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxColormapPrivPtr pCmapPriv = DMX_GET_COLORMAP_PRIV(pColormap);
+
+ DMX_UNWRAP(InstallColormap, dmxScreen, pScreen);
+ if (pScreen->InstallColormap)
+ pScreen->InstallColormap(pColormap);
+ DMX_WRAP(InstallColormap, dmxInstallColormap, dmxScreen, pScreen);
+
+ if (dmxScreen->beDisplay) {
+ XInstallColormap(dmxScreen->beDisplay, pCmapPriv->cmap);
+ dmxSync(dmxScreen, FALSE);
+ }
+}
+
+/** Store colors in \a pColormap on back-end server associated with \a
+ * pColormap's screen. */
+void dmxStoreColors(ColormapPtr pColormap, int ndef, xColorItem *pdef)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxColormapPrivPtr pCmapPriv = DMX_GET_COLORMAP_PRIV(pColormap);
+
+ if (dmxScreen->beDisplay && (pColormap->pVisual->class & DynamicClass)) {
+ XColor *color = xalloc(sizeof(*color) * ndef);
+ int i;
+
+ if (color) {
+ for (i = 0; i < ndef; i++) {
+ color[i].pixel = pdef[i].pixel;
+ color[i].red = pdef[i].red;
+ color[i].blue = pdef[i].blue;
+ color[i].green = pdef[i].green;
+ color[i].flags = pdef[i].flags;
+ color[i].pad = pdef[i].pad;
+ }
+ XStoreColors(dmxScreen->beDisplay, pCmapPriv->cmap, color, ndef);
+ xfree(color);
+ } else { /* xalloc failed, so fallback */
+ XColor c;
+ for (i = 0; i < ndef; i++) {
+ c.pixel = pdef[i].pixel;
+ c.red = pdef[i].red;
+ c.blue = pdef[i].blue;
+ c.green = pdef[i].green;
+ c.flags = pdef[i].flags;
+ c.pad = pdef[i].pad;
+ XStoreColor(dmxScreen->beDisplay, pCmapPriv->cmap, &c);
+ }
+ }
+ dmxSync(dmxScreen, FALSE);
+ }
+
+ DMX_UNWRAP(StoreColors, dmxScreen, pScreen);
+ if (pScreen->StoreColors)
+ pScreen->StoreColors(pColormap, ndef, pdef);
+ DMX_WRAP(StoreColors, dmxStoreColors, dmxScreen, pScreen);
+}
+
+/** Create the DMX server's default colormap. */
+Bool dmxCreateDefColormap(ScreenPtr pScreen)
+{
+ return miCreateDefColormap(pScreen);
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxcmap.h b/nx-X11/programs/Xserver/hw/dmx/dmxcmap.h
new file mode 100644
index 000000000..09039e72b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxcmap.h
@@ -0,0 +1,71 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * Header file for colormap support. \see dmxcmap.c. */
+
+#ifndef DMXCMAP_H
+#define DMXCMAP_H
+
+#include "colormapst.h"
+
+/** Colormap private area. */
+typedef struct _dmxColormapPriv {
+ Colormap cmap;
+} dmxColormapPrivRec, *dmxColormapPrivPtr;
+
+
+extern Bool dmxCreateColormap(ColormapPtr pColormap);
+extern void dmxDestroyColormap(ColormapPtr pColormap);
+extern void dmxInstallColormap(ColormapPtr pColormap);
+extern void dmxStoreColors(ColormapPtr pColormap, int ndef, xColorItem *pdef);
+
+extern Bool dmxCreateDefColormap(ScreenPtr pScreen);
+
+extern Bool dmxBECreateColormap(ColormapPtr pColormap);
+extern Bool dmxBEFreeColormap(ColormapPtr pColormap);
+
+/** Private index. \see dmxcmap.c \see dmxscrinit.c \see dmxwindow.c */
+extern int dmxColormapPrivateIndex;
+
+/** Set colormap private structure. */
+#define DMX_SET_COLORMAP_PRIV(_pCMap, _pCMapPriv) \
+ (_pCMap)->devPrivates[dmxColormapPrivateIndex].ptr \
+ = (pointer)(_pCMapPriv);
+
+/** Get colormap private structure. */
+#define DMX_GET_COLORMAP_PRIV(_pCMap) \
+ (dmxColormapPrivPtr)(_pCMap)->devPrivates[dmxColormapPrivateIndex].ptr
+
+#endif /* DMXCMAP_H */
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxcursor.c b/nx-X11/programs/Xserver/hw/dmx/dmxcursor.c
new file mode 100644
index 000000000..a49fc9f43
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxcursor.c
@@ -0,0 +1,926 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * David H. Dawes <dawes@xfree86.org>
+ * Kevin E. Martin <kem@redhat.com>
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * This file contains code than supports cursor movement, including the
+ * code that initializes and reinitializes the screen positions and
+ * computes screen overlap.
+ *
+ * "This code is based very closely on the XFree86 equivalent
+ * (xfree86/common/xf86Cursor.c)." --David Dawes.
+ *
+ * "This code was then extensively re-written, as explained here."
+ * --Rik Faith
+ *
+ * The code in xf86Cursor.c used edge lists to implement the
+ * CursorOffScreen function. The edge list computation was complex
+ * (especially in the face of arbitrarily overlapping screens) compared
+ * with the speed savings in the CursorOffScreen function. The new
+ * implementation has erred on the side of correctness, readability, and
+ * maintainability over efficiency. For the common (non-edge) case, the
+ * dmxCursorOffScreen function does avoid a loop over all the screens.
+ * When the cursor has left the screen, all the screens are searched,
+ * and the first screen (in dmxScreens order) containing the cursor will
+ * be returned. If run-time profiling shows that this routing is a
+ * performance bottle-neck, then an edge list may have to be
+ * reimplemented. An edge list algorithm is O(edges) whereas the new
+ * algorithm is O(dmxNumScreens). Since edges is usually 1-3 and
+ * dmxNumScreens may be 30-60 for large backend walls, this trade off
+ * may be compelling.
+ *
+ * The xf86InitOrigins routine uses bit masks during the computation and
+ * is therefore limited to the length of a word (e.g., 32 or 64 bits)
+ * screens. Because Xdmx is expected to be used with a large number of
+ * backend displays, this limitation was removed. The new
+ * implementation has erred on the side of readability over efficiency,
+ * using the dmxSL* routines to manage a screen list instead of a
+ * bitmap, and a function call to decrease the length of the main
+ * routine. Both algorithms are of the same order, and both are called
+ * only at server generation time, so trading clarity and long-term
+ * maintainability for efficiency does not seem justified in this case.
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#define DMX_CURSOR_DEBUG 0
+
+#include "dmx.h"
+#include "dmxsync.h"
+#include "dmxcursor.h"
+#include "dmxlog.h"
+#include "dmxprop.h"
+#include "dmxinput.h"
+
+#include "mipointer.h"
+#include "windowstr.h"
+#include "globals.h"
+#include "cursorstr.h"
+#include "dixevents.h" /* For GetSpriteCursor() */
+
+#if DMX_CURSOR_DEBUG
+#define DMXDBG0(f) dmxLog(dmxDebug,f)
+#define DMXDBG1(f,a) dmxLog(dmxDebug,f,a)
+#define DMXDBG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define DMXDBG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define DMXDBG4(f,a,b,c,d) dmxLog(dmxDebug,f,a,b,c,d)
+#define DMXDBG5(f,a,b,c,d,e) dmxLog(dmxDebug,f,a,b,c,d,e)
+#define DMXDBG6(f,a,b,c,d,e,g) dmxLog(dmxDebug,f,a,b,c,d,e,g)
+#define DMXDBG7(f,a,b,c,d,e,g,h) dmxLog(dmxDebug,f,a,b,c,d,e,g,h)
+#else
+#define DMXDBG0(f)
+#define DMXDBG1(f,a)
+#define DMXDBG2(f,a,b)
+#define DMXDBG3(f,a,b,c)
+#define DMXDBG4(f,a,b,c,d)
+#define DMXDBG5(f,a,b,c,d,e)
+#define DMXDBG6(f,a,b,c,d,e,g)
+#define DMXDBG7(f,a,b,c,d,e,g,h)
+#endif
+
+static int dmxCursorDoMultiCursors = 1;
+
+/** Turn off support for displaying multiple cursors on overlapped
+ back-end displays. See #dmxCursorDoMultiCursors. */
+void dmxCursorNoMulti(void)
+{
+ dmxCursorDoMultiCursors = 0;
+}
+
+static Bool dmxCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
+{
+ DMXScreenInfo *dmxScreen;
+ int i;
+ int localX = *x;
+ int localY = *y;
+ int globalX;
+ int globalY;
+
+ if (screenInfo.numScreens == 1) return FALSE;
+
+ /* On current screen? */
+ dmxScreen = &dmxScreens[(*ppScreen)->myNum];
+ if (localX >= 0
+ && localX < dmxScreen->rootWidth
+ && localY >= 0
+ && localY < dmxScreen->rootHeight) return FALSE;
+
+ /* Convert to global coordinate space */
+ globalX = dmxScreen->rootXOrigin + localX;
+ globalY = dmxScreen->rootYOrigin + localY;
+
+ /* Is cursor on the current screen?
+ * This efficiently exits this routine
+ * for the most common case. */
+ if (ppScreen && *ppScreen) {
+ dmxScreen = &dmxScreens[(*ppScreen)->myNum];
+ if (globalX >= dmxScreen->rootXOrigin
+ && globalX < dmxScreen->rootXOrigin + dmxScreen->rootWidth
+ && globalY >= dmxScreen->rootYOrigin
+ && globalY < dmxScreen->rootYOrigin + dmxScreen->rootHeight)
+ return FALSE;
+ }
+
+ /* Find first screen cursor is on */
+ for (i = 0; i < dmxNumScreens; i++) {
+ dmxScreen = &dmxScreens[i];
+ if (globalX >= dmxScreen->rootXOrigin
+ && globalX < dmxScreen->rootXOrigin + dmxScreen->rootWidth
+ && globalY >= dmxScreen->rootYOrigin
+ && globalY < dmxScreen->rootYOrigin + dmxScreen->rootHeight) {
+ if (dmxScreen->index == (*ppScreen)->myNum) return FALSE;
+ *ppScreen = screenInfo.screens[dmxScreen->index];
+ *x = globalX - dmxScreen->rootXOrigin;
+ *y = globalY - dmxScreen->rootYOrigin;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static void dmxCrossScreen(ScreenPtr pScreen, Bool entering)
+{
+}
+
+static void dmxWarpCursor(ScreenPtr pScreen, int x, int y)
+{
+ DMXDBG3("dmxWarpCursor(%d,%d,%d)\n", pScreen->myNum, x, y);
+ miPointerWarpCursor(pScreen, x, y);
+}
+
+miPointerScreenFuncRec dmxPointerCursorFuncs =
+{
+ dmxCursorOffScreen,
+ dmxCrossScreen,
+ dmxWarpCursor,
+ dmxeqEnqueue,
+ dmxeqSwitchScreen
+};
+
+
+/** Create a list of screens that we'll manipulate. */
+static int *dmxSLCreate(void)
+{
+ int *list = malloc(dmxNumScreens * sizeof(*list));
+ int i;
+
+ for (i = 0; i < dmxNumScreens; i++) list[i] = 1;
+ return list;
+}
+
+/** Free list. */
+static void dmxSLFree(int *list)
+{
+ free(list);
+}
+
+/** Find next uninitialized entry in list. */
+static int dmxSLFindNext(int *list)
+{
+ int i;
+ for (i = 0; i < dmxNumScreens; i++) if (list[i]) return i;
+ return -1;
+}
+
+/** Make one pass over all the screens and return the number updated. */
+static int dmxTryComputeScreenOrigins(int *screensLeft)
+{
+ ScreenPtr pScreen;
+ DMXScreenInfo *screen;
+ int i, ref;
+ int changed = 0;
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ if (!screensLeft[i]) continue;
+ screen = &dmxScreens[i];
+ switch (screen->where) {
+ case PosAbsolute:
+ dixScreenOrigins[i].x = screen->whereX;
+ dixScreenOrigins[i].y = screen->whereY;
+ ++changed, screensLeft[i] = 0;
+ break;
+ case PosRelative:
+ ref = screen->whereRefScreen;
+ if (screensLeft[ref]) break;
+ dixScreenOrigins[i].x = dixScreenOrigins[ref].x + screen->whereX;
+ dixScreenOrigins[i].y = dixScreenOrigins[ref].y + screen->whereY;
+ ++changed, screensLeft[i] = 0;
+ break;
+ case PosRightOf:
+ ref = screen->whereRefScreen;
+ if (screensLeft[ref]) break;
+ pScreen = screenInfo.screens[ref];
+ dixScreenOrigins[i].x = dixScreenOrigins[ref].x + pScreen->width;
+ dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+ ++changed, screensLeft[i] = 0;
+ break;
+ case PosLeftOf:
+ ref = screen->whereRefScreen;
+ if (screensLeft[ref]) break;
+ pScreen = screenInfo.screens[i];
+ dixScreenOrigins[i].x = dixScreenOrigins[ref].x - pScreen->width;
+ dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+ ++changed, screensLeft[i] = 0;
+ break;
+ case PosBelow:
+ ref = screen->whereRefScreen;
+ if (screensLeft[ref]) break;
+ pScreen = screenInfo.screens[ref];
+ dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
+ dixScreenOrigins[i].y = dixScreenOrigins[ref].y + pScreen->height;
+ ++changed, screensLeft[i] = 0;
+ break;
+ case PosAbove:
+ ref = screen->whereRefScreen;
+ if (screensLeft[ref]) break;
+ pScreen = screenInfo.screens[i];
+ dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
+ dixScreenOrigins[i].y = dixScreenOrigins[ref].y - pScreen->height;
+ ++changed, screensLeft[i] = 0;
+ break;
+ case PosNone:
+ dmxLog(dmxFatal, "No position information for screen %d\n", i);
+ }
+ }
+ return changed;
+}
+
+static void dmxComputeScreenOrigins(void)
+{
+ int *screensLeft;
+ int i, ref;
+ int minX, minY;
+
+ /* Compute origins based on
+ * configuration information. */
+ screensLeft = dmxSLCreate();
+ while ((i = dmxSLFindNext(screensLeft)) >= 0) {
+ while (dmxTryComputeScreenOrigins(screensLeft));
+ if ((i = dmxSLFindNext(screensLeft)) >= 0) {
+ /* All of the remaining screens are referencing each other.
+ * Assign a value to one of them and go through again. This
+ * guarantees that we will eventually terminate.
+ */
+ ref = dmxScreens[i].whereRefScreen;
+ dixScreenOrigins[ref].x = dixScreenOrigins[ref].y = 0;
+ screensLeft[ref] = 0;
+ }
+ }
+ dmxSLFree(screensLeft);
+
+
+ /* Justify the topmost and leftmost to
+ * (0,0). */
+ minX = dixScreenOrigins[0].x;
+ minY = dixScreenOrigins[0].y;
+ for (i = 1; i < dmxNumScreens; i++) { /* Compute minX, minY */
+ if (dixScreenOrigins[i].x < minX) minX = dixScreenOrigins[i].x;
+ if (dixScreenOrigins[i].y < minY) minY = dixScreenOrigins[i].y;
+ }
+ if (minX || minY) {
+ for (i = 0; i < dmxNumScreens; i++) {
+ dixScreenOrigins[i].x -= minX;
+ dixScreenOrigins[i].y -= minY;
+ }
+ }
+}
+
+/** Recompute origin information in the #dmxScreens list. This is
+ * either called from #dmxInitOrigins() or from #dmxReconfig(). */
+void dmxReInitOrigins(void)
+{
+ int i;
+
+ if (dmxNumScreens > MAXSCREENS)
+ dmxLog(dmxFatal, "dmxNumScreens = %d > MAXSCREENS = %d\n",
+ dmxNumScreens, MAXSCREENS);
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ dmxLogOutput(dmxScreen,
+ "s=%dx%d%+d%+d r=%dx%d%+d%+d @%d,%d"
+ " (be=%dx%d depth=%d bpp=%d)\n",
+ dmxScreen->scrnWidth, dmxScreen->scrnHeight,
+ dmxScreen->scrnX, dmxScreen->scrnY,
+
+ dmxScreen->rootWidth, dmxScreen->rootHeight,
+ dmxScreen->rootX, dmxScreen->rootY,
+
+ dmxScreen->rootXOrigin, dmxScreen->rootYOrigin,
+ dmxScreen->beWidth, dmxScreen->beHeight,
+ dmxScreen->beDepth, dmxScreen->beBPP);
+ }
+}
+
+/** Initialize screen origins (and relative position). This is called
+ * for each server generation. For dynamic reconfiguration, use
+ * #dmxReInitOrigins() instead. */
+void dmxInitOrigins(void)
+{
+ int i;
+
+ if (dmxNumScreens > MAXSCREENS)
+ dmxLog(dmxFatal, "dmxNumScreens = %d > MAXSCREENS = %d\n",
+ dmxNumScreens, MAXSCREENS);
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ dmxLogOutput(dmxScreen,
+ "(request) s=%dx%d%+d%+d r=%dx%d%+d%+d @%d,%d (%d)"
+ " (be=%dx%d depth=%d bpp=%d)\n",
+ dmxScreen->scrnWidth, dmxScreen->scrnHeight,
+ dmxScreen->scrnX, dmxScreen->scrnY,
+
+ dmxScreen->rootWidth, dmxScreen->rootHeight,
+ dmxScreen->rootX, dmxScreen->rootY,
+
+ dmxScreen->whereX, dmxScreen->whereY,
+ dmxScreen->where,
+
+ dmxScreen->beWidth, dmxScreen->beHeight,
+ dmxScreen->beDepth, dmxScreen->beBPP);
+ }
+
+ dmxComputeScreenOrigins();
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ dmxScreen->rootXOrigin = dixScreenOrigins[i].x;
+ dmxScreen->rootYOrigin = dixScreenOrigins[i].y;
+ }
+
+ dmxReInitOrigins();
+}
+
+/** Returns non-zero if the global \a x, \a y coordinate is on the
+ * screen window of the \a dmxScreen. */
+int dmxOnScreen(int x, int y, DMXScreenInfo *dmxScreen)
+{
+#if DMX_CURSOR_DEBUG > 1
+ dmxLog(dmxDebug,
+ "dmxOnScreen %d %d,%d (r=%dx%d%+d%+d@%d,%d s=%dx%d%+d%+d)\n",
+ dmxScreen->index, x, y,
+ dmxScreen->rootWidth, dmxScreen->rootHeight,
+ dmxScreen->rootX, dmxScreen->rootY,
+ dmxScreen->rootXOrigin, dmxScreen->rootYOrigin,
+ dmxScreen->scrnWidth, dmxScreen->scrnHeight,
+ dmxScreen->scrnX, dmxScreen->scrnY);
+#endif
+ if (x >= dmxScreen->rootXOrigin
+ && x < dmxScreen->rootXOrigin + dmxScreen->rootWidth
+ && y >= dmxScreen->rootYOrigin
+ && y < dmxScreen->rootYOrigin + dmxScreen->rootHeight) return 1;
+ return 0;
+}
+
+/** Returns non-zero if \a a overlaps \a b. */
+static int dmxDoesOverlap(DMXScreenInfo *a, DMXScreenInfo *b)
+{
+ if (dmxOnScreen(a->rootXOrigin,
+ a->rootYOrigin, b)) return 1;
+
+ if (dmxOnScreen(a->rootXOrigin,
+ a->rootYOrigin + a->scrnWidth, b)) return 1;
+
+ if (dmxOnScreen(a->rootXOrigin + a->scrnHeight,
+ a->rootYOrigin, b)) return 1;
+
+ if (dmxOnScreen(a->rootXOrigin + a->scrnHeight,
+ a->rootYOrigin + a->scrnWidth, b)) return 1;
+
+ if (dmxOnScreen(b->rootXOrigin,
+ b->rootYOrigin, a)) return 1;
+
+ if (dmxOnScreen(b->rootXOrigin,
+ b->rootYOrigin + b->scrnWidth, a)) return 1;
+
+ if (dmxOnScreen(b->rootXOrigin + b->scrnHeight,
+ b->rootYOrigin, a)) return 1;
+
+ if (dmxOnScreen(b->rootXOrigin + b->scrnHeight,
+ b->rootYOrigin + b->scrnWidth, a)) return 1;
+
+ return 0;
+}
+
+/** Used with #dmxInterateOverlap to print out a list of screens which
+ * overlap each other. */
+static void *dmxPrintOverlap(DMXScreenInfo *dmxScreen, void *closure)
+{
+ DMXScreenInfo *a = closure;
+ if (dmxScreen != a) {
+ if (dmxScreen->cursorNotShared)
+ dmxLogOutputCont(a, " [%d/%s]", dmxScreen->index, dmxScreen->name);
+ else
+ dmxLogOutputCont(a, " %d/%s", dmxScreen->index, dmxScreen->name);
+ }
+ return NULL;
+}
+
+/** Iterate over the screens which overlap with the \a start screen,
+ * calling \a f with the \a closure for each argument. Often used with
+ * #dmxPrintOverlap. */
+static void *dmxIterateOverlap(DMXScreenInfo *start,
+ void *(*f)(DMXScreenInfo *dmxScreen, void *),
+ void *closure)
+{
+ DMXScreenInfo *pt;
+
+ if (!start->over) return f(start, closure);
+
+ for (pt = start->over; /* condition at end of loop */; pt = pt->over) {
+ void *retval;
+ if ((retval = f(pt, closure))) return retval;
+ if (pt == start) break;
+ }
+ return NULL;
+}
+
+/** Used with #dmxPropertyIterate to determine if screen \a a is the
+ * same as the screen \a closure. */
+static void *dmxTestSameDisplay(DMXScreenInfo *a, void *closure)
+{
+ DMXScreenInfo *b = closure;
+
+ if (a == b) return a;
+ return NULL;
+}
+
+/** Detects overlapping dmxScreens and creates circular lists. This
+ * uses an O(dmxNumScreens^2) algorithm, but dmxNumScreens is < 100 and
+ * the computation only needs to be performed for every server
+ * generation or dynamic reconfiguration . */
+void dmxInitOverlap(void)
+{
+ int i, j;
+ DMXScreenInfo *a, *b, *pt;
+
+ for (i = 0; i < dmxNumScreens; i++) dmxScreens[i].over = NULL;
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ a = &dmxScreens[i];
+
+ for (j = i+1; j < dmxNumScreens; j++) {
+ b = &dmxScreens[j];
+ if (b->over) continue;
+
+ if (dmxDoesOverlap(a, b)) {
+ DMXDBG6("%d overlaps %d: a=%p %p b=%p %p\n",
+ a->index, b->index, a, a->over, b, b->over);
+ b->over = (a->over ? a->over : a);
+ a->over = b;
+ }
+ }
+ }
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ a = &dmxScreens[i];
+
+ if (!a->over) continue;
+
+ /* Flag all pairs that are on same display */
+ for (pt = a->over; pt != a; pt = pt->over) {
+ if (dmxPropertyIterate(a, dmxTestSameDisplay, pt)) {
+ /* The ->over sets contain the transitive set of screens
+ * that overlap. For screens that are on the same
+ * backend display, we only want to exclude pairs of
+ * screens that mutually overlap on the backend display,
+ * so we call dmxDoesOverlap, which is stricter than the
+ * ->over set. */
+ if (!dmxDoesOverlap(a, pt)) continue;
+ a->cursorNotShared = 1;
+ pt->cursorNotShared = 1;
+ dmxLog(dmxInfo,
+ "Screen %d and %d overlap on %s\n",
+ a->index, pt->index, a->name);
+ }
+ }
+ }
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ a = &dmxScreens[i];
+
+ if (a->over) {
+ dmxLogOutput(a, "Overlaps");
+ dmxIterateOverlap(a, dmxPrintOverlap, a);
+ dmxLogOutputCont(a, "\n");
+ }
+ }
+}
+
+/** Create \a pCursor on the back-end associated with \a pScreen. */
+void dmxBECreateCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxCursorPrivPtr pCursorPriv = DMX_GET_CURSOR_PRIV(pCursor, pScreen);
+ CursorBitsPtr pBits = pCursor->bits;
+ Pixmap src, msk;
+ XColor fg, bg;
+ XImage *img;
+ XlibGC gc = NULL;
+ XGCValues v;
+ unsigned long m;
+ int i;
+
+ if (!pCursorPriv)
+ return;
+
+ m = GCFunction | GCPlaneMask | GCForeground | GCBackground | GCClipMask;
+ v.function = GXcopy;
+ v.plane_mask = AllPlanes;
+ v.foreground = 1L;
+ v.background = 0L;
+ v.clip_mask = None;
+
+ for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) {
+ if (dmxScreen->bePixmapFormats[i].depth == 1) {
+ /* Create GC in the back-end servers */
+ gc = XCreateGC(dmxScreen->beDisplay, dmxScreen->scrnDefDrawables[i],
+ m, &v);
+ break;
+ }
+ }
+ if (!gc)
+ dmxLog(dmxFatal, "dmxRealizeCursor: gc not initialized\n");
+
+ src = XCreatePixmap(dmxScreen->beDisplay, dmxScreen->scrnWin,
+ pBits->width, pBits->height, 1);
+ msk = XCreatePixmap(dmxScreen->beDisplay, dmxScreen->scrnWin,
+ pBits->width, pBits->height, 1);
+
+ img = XCreateImage(dmxScreen->beDisplay,
+ dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual,
+ 1, XYBitmap, 0, (char *)pBits->source,
+ pBits->width, pBits->height,
+ BitmapPad(dmxScreen->beDisplay), 0);
+
+ XPutImage(dmxScreen->beDisplay, src, gc, img, 0, 0, 0, 0,
+ pBits->width, pBits->height);
+
+ XFree(img);
+
+ img = XCreateImage(dmxScreen->beDisplay,
+ dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual,
+ 1, XYBitmap, 0, (char *)pBits->mask,
+ pBits->width, pBits->height,
+ BitmapPad(dmxScreen->beDisplay), 0);
+
+ XPutImage(dmxScreen->beDisplay, msk, gc, img, 0, 0, 0, 0,
+ pBits->width, pBits->height);
+
+ XFree(img);
+
+ fg.red = pCursor->foreRed;
+ fg.green = pCursor->foreGreen;
+ fg.blue = pCursor->foreBlue;
+
+ bg.red = pCursor->backRed;
+ bg.green = pCursor->backGreen;
+ bg.blue = pCursor->backBlue;
+
+ pCursorPriv->cursor = XCreatePixmapCursor(dmxScreen->beDisplay,
+ src, msk,
+ &fg, &bg,
+ pBits->xhot, pBits->yhot);
+
+ XFreePixmap(dmxScreen->beDisplay, src);
+ XFreePixmap(dmxScreen->beDisplay, msk);
+ XFreeGC(dmxScreen->beDisplay, gc);
+
+ dmxSync(dmxScreen, FALSE);
+}
+
+static Bool _dmxRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxCursorPrivPtr pCursorPriv;
+
+ DMXDBG2("_dmxRealizeCursor(%d,%p)\n", pScreen->myNum, pCursor);
+
+ pCursor->devPriv[pScreen->myNum] = xalloc(sizeof(*pCursorPriv));
+ if (!pCursor->devPriv[pScreen->myNum])
+ return FALSE;
+
+ pCursorPriv = DMX_GET_CURSOR_PRIV(pCursor, pScreen);
+ pCursorPriv->cursor = (Cursor)0;
+
+ if (!dmxScreen->beDisplay)
+ return TRUE;
+
+ dmxBECreateCursor(pScreen, pCursor);
+ return TRUE;
+}
+
+/** Free \a pCursor on the back-end associated with \a pScreen. */
+Bool dmxBEFreeCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxCursorPrivPtr pCursorPriv = DMX_GET_CURSOR_PRIV(pCursor, pScreen);
+
+ if (pCursorPriv) {
+ XFreeCursor(dmxScreen->beDisplay, pCursorPriv->cursor);
+ pCursorPriv->cursor = (Cursor)0;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static Bool _dmxUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+
+ DMXDBG3("_dmxUnrealizeCursor(%d,%p) %p\n",
+ pScreen->myNum, pCursor, pCursorPriv);
+
+ if (dmxScreen->beDisplay) {
+ if (dmxBEFreeCursor(pScreen, pCursor))
+ xfree(pCursor->devPriv[pScreen->myNum]);
+ }
+ pCursor->devPriv[pScreen->myNum] = NULL;
+
+ return TRUE;
+}
+
+static void _dmxMoveCursor(ScreenPtr pScreen, int x, int y)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ int newX = x + dmxScreen->rootX;
+ int newY = y + dmxScreen->rootY;
+
+ if (newX < 0) newX = 0;
+ if (newY < 0) newY = 0;
+
+ DMXDBG5("_dmxMoveCursor(%d,%d,%d) -> %d,%d\n",
+ pScreen->myNum, x, y, newX, newY);
+ if (dmxScreen->beDisplay) {
+ XWarpPointer(dmxScreen->beDisplay, None, dmxScreen->scrnWin,
+ 0, 0, 0, 0, newX, newY);
+ dmxSync(dmxScreen, TRUE);
+ }
+}
+
+static void _dmxSetCursor(ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+
+ DMXDBG4("_dmxSetCursor(%d,%p,%d,%d)\n", pScreen->myNum, pCursor, x, y);
+
+ if (pCursor) {
+ dmxCursorPrivPtr pCursorPriv = DMX_GET_CURSOR_PRIV(pCursor, pScreen);
+ if (dmxScreen->curCursor != pCursorPriv->cursor) {
+ if (dmxScreen->beDisplay)
+ XDefineCursor(dmxScreen->beDisplay, dmxScreen->scrnWin,
+ pCursorPriv->cursor);
+ dmxScreen->cursor = pCursor;
+ dmxScreen->curCursor = pCursorPriv->cursor;
+ dmxScreen->cursorVisible = 1;
+ }
+ _dmxMoveCursor(pScreen, x, y);
+ } else {
+ if (dmxScreen->beDisplay)
+ XDefineCursor(dmxScreen->beDisplay, dmxScreen->scrnWin,
+ dmxScreen->noCursor);
+ dmxScreen->cursor = NULL;
+ dmxScreen->curCursor = (Cursor)0;
+ dmxScreen->cursorVisible = 0;
+ }
+ if (dmxScreen->beDisplay) dmxSync(dmxScreen, TRUE);
+}
+
+static Bool dmxRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+ DMXScreenInfo *start = &dmxScreens[pScreen->myNum];
+ DMXScreenInfo *pt;
+
+ if (!start->over || !dmxCursorDoMultiCursors || start->cursorNotShared)
+ return _dmxRealizeCursor(pScreen, pCursor);
+
+ for (pt = start->over; /* condition at end of loop */; pt = pt->over) {
+ if (pt->cursorNotShared) continue;
+ _dmxRealizeCursor(screenInfo.screens[pt->index], pCursor);
+ if (pt == start) break;
+ }
+ return TRUE;
+}
+
+static Bool dmxUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+ DMXScreenInfo *start = &dmxScreens[pScreen->myNum];
+ DMXScreenInfo *pt;
+
+ if (!start->over || !dmxCursorDoMultiCursors || start->cursorNotShared)
+ return _dmxUnrealizeCursor(pScreen, pCursor);
+
+ for (pt = start->over; /* condition at end of loop */; pt = pt->over) {
+ if (pt->cursorNotShared) continue;
+ _dmxUnrealizeCursor(screenInfo.screens[pt->index], pCursor);
+ if (pt == start) break;
+ }
+ return TRUE;
+}
+
+static CursorPtr dmxFindCursor(DMXScreenInfo *start)
+{
+ DMXScreenInfo *pt;
+
+ if (!start || !start->over) return GetSpriteCursor();
+ for (pt = start->over; /* condition at end of loop */; pt = pt->over) {
+ if (pt->cursor) return pt->cursor;
+ if (pt == start) break;
+ }
+ return GetSpriteCursor();
+}
+
+/** Move the cursor to coordinates (\a x, \a y)on \a pScreen. This
+ * function is usually called via #dmxPointerSpriteFuncs, except during
+ * reconfiguration when the cursor is repositioned to force an update on
+ * newley overlapping screens and on screens that no longer overlap. */
+void dmxMoveCursor(ScreenPtr pScreen, int x, int y)
+{
+ DMXScreenInfo *start = &dmxScreens[pScreen->myNum];
+ DMXScreenInfo *pt;
+
+ DMXDBG3("dmxMoveCursor(%d,%d,%d)\n", pScreen->myNum, x, y);
+
+ if (!start->over || !dmxCursorDoMultiCursors || start->cursorNotShared) {
+ _dmxMoveCursor(pScreen, x, y);
+ return;
+ }
+
+ for (pt = start->over; /* condition at end of loop */; pt = pt->over) {
+ if (pt->cursorNotShared) continue;
+ if (dmxOnScreen(x + start->rootXOrigin, y + start->rootYOrigin, pt)) {
+ if (/* pt != start && */ !pt->cursorVisible) {
+ if (!pt->cursor) {
+ /* This only happens during
+ * reconfiguration when a new overlap
+ * occurs. */
+ CursorPtr pCursor;
+
+ if ((pCursor = dmxFindCursor(start)))
+ _dmxRealizeCursor(screenInfo.screens[pt->index],
+ pt->cursor = pCursor);
+
+ }
+ _dmxSetCursor(screenInfo.screens[pt->index],
+ pt->cursor,
+ x + start->rootXOrigin - pt->rootXOrigin,
+ y + start->rootYOrigin - pt->rootYOrigin);
+ }
+ _dmxMoveCursor(screenInfo.screens[pt->index],
+ x + start->rootXOrigin - pt->rootXOrigin,
+ y + start->rootYOrigin - pt->rootYOrigin);
+ } else if (/* pt != start && */ pt->cursorVisible) {
+ _dmxSetCursor(screenInfo.screens[pt->index],
+ NULL,
+ x + start->rootXOrigin - pt->rootXOrigin,
+ y + start->rootYOrigin - pt->rootYOrigin);
+ }
+ if (pt == start) break;
+ }
+}
+
+static void dmxSetCursor(ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
+{
+ DMXScreenInfo *start = &dmxScreens[pScreen->myNum];
+ DMXScreenInfo *pt;
+ int GX, GY, gx, gy;
+
+ DMXDBG5("dmxSetCursor(%d %p, %p,%d,%d)\n",
+ pScreen->myNum, start, pCursor, x, y);
+
+ /* We do this check here because of two cases:
+ *
+ * 1) if a client calls XWarpPointer()
+ * and Xinerama is not running, we can
+ * have mi's notion of the pointer
+ * position out of phase with DMX's
+ * notion.
+ *
+ * 2) if a down button is held while the
+ * cursor moves outside the root window,
+ * mi's notion of the pointer position
+ * is out of phase with DMX's notion and
+ * the cursor can remain visible when it
+ * shouldn't be. */
+
+ dmxGetGlobalPosition(&GX, &GY);
+ gx = start->rootXOrigin + x;
+ gy = start->rootYOrigin + y;
+ if (x && y && (GX != gx || GY != gy))
+ dmxCoreMotion(gx, gy, 0, DMX_NO_BLOCK);
+
+ if (!start->over || !dmxCursorDoMultiCursors || start->cursorNotShared) {
+ _dmxSetCursor(pScreen, pCursor, x, y);
+ return;
+ }
+
+ for (pt = start->over; /* condition at end of loop */; pt = pt->over) {
+ if (pt->cursorNotShared) continue;
+ if (dmxOnScreen(x + start->rootXOrigin, y + start->rootYOrigin, pt)) {
+ _dmxSetCursor(screenInfo.screens[pt->index], pCursor,
+ x + start->rootXOrigin - pt->rootXOrigin,
+ y + start->rootYOrigin - pt->rootYOrigin);
+ } else {
+ _dmxSetCursor(screenInfo.screens[pt->index], NULL,
+ x + start->rootXOrigin - pt->rootXOrigin,
+ y + start->rootYOrigin - pt->rootYOrigin);
+ }
+ if (pt == start) break;
+ }
+}
+
+
+/** This routine is used by the backend input routines to hide the
+ * cursor on a screen that is being used for relative input. \see
+ * dmxbackend.c */
+void dmxHideCursor(DMXScreenInfo *dmxScreen)
+{
+ int x, y;
+ ScreenPtr pScreen = screenInfo.screens[dmxScreen->index];
+
+ dmxGetGlobalPosition(&x, &y);
+ _dmxSetCursor(pScreen, NULL, x, y);
+}
+
+/** This routine is called during reconfiguration to make sure the
+ * cursor is visible. */
+void dmxCheckCursor(void)
+{
+ int i;
+ int x, y;
+ ScreenPtr pScreen;
+ DMXScreenInfo *firstScreen;
+
+ dmxGetGlobalPosition(&x, &y);
+ firstScreen = dmxFindFirstScreen(x, y);
+
+ DMXDBG2("dmxCheckCursor %d %d\n", x, y);
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ pScreen = screenInfo.screens[dmxScreen->index];
+
+ if (!dmxOnScreen(x, y, dmxScreen)) {
+ if (firstScreen && i == miPointerCurrentScreen()->myNum)
+ miPointerSetNewScreen(firstScreen->index, x, y);
+ _dmxSetCursor(pScreen, NULL,
+ x - dmxScreen->rootXOrigin,
+ y - dmxScreen->rootYOrigin);
+ } else {
+ if (!dmxScreen->cursor) {
+ CursorPtr pCursor;
+
+ if ((pCursor = dmxFindCursor(dmxScreen))) {
+ _dmxRealizeCursor(pScreen, dmxScreen->cursor = pCursor);
+ }
+ }
+ _dmxSetCursor(pScreen, dmxScreen->cursor,
+ x - dmxScreen->rootXOrigin,
+ y - dmxScreen->rootYOrigin);
+ }
+ }
+ DMXDBG2(" leave dmxCheckCursor %d %d\n", x, y);
+}
+
+miPointerSpriteFuncRec dmxPointerSpriteFuncs =
+{
+ dmxRealizeCursor,
+ dmxUnrealizeCursor,
+ dmxSetCursor,
+ dmxMoveCursor,
+};
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxcursor.h b/nx-X11/programs/Xserver/hw/dmx/dmxcursor.h
new file mode 100644
index 000000000..af076bd1c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxcursor.h
@@ -0,0 +1,70 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * David H. Dawes <dawes@xfree86.org>
+ * Kevin E. Martin <kem@redhat.com>
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for cursor support. \see dmxcursor.c. */
+
+#ifndef DMXCURSOR_H
+#define DMXCURSOR_H
+
+#include "mipointer.h"
+
+/** Cursor private area. */
+typedef struct _dmxCursorPriv {
+ Cursor cursor;
+} dmxCursorPrivRec, *dmxCursorPrivPtr;
+
+/** Cursor functions for mi layer. \see dmxcursor.c \see dmxscrinit.c */
+extern miPointerScreenFuncRec dmxPointerCursorFuncs;
+/** Sprite functions for mi layer. \see dmxcursor.c \see dmxscrinit.c */
+extern miPointerSpriteFuncRec dmxPointerSpriteFuncs;
+
+extern void dmxReInitOrigins(void);
+extern void dmxInitOrigins(void);
+extern void dmxInitOverlap(void);
+extern void dmxCursorNoMulti(void);
+extern void dmxMoveCursor(ScreenPtr pScreen, int x, int y);
+extern void dmxCheckCursor(void);
+extern int dmxOnScreen(int x, int y, DMXScreenInfo *dmxScreen);
+extern void dmxHideCursor(DMXScreenInfo *dmxScreen);
+
+extern void dmxBECreateCursor(ScreenPtr pScreen, CursorPtr pCursor);
+extern Bool dmxBEFreeCursor(ScreenPtr pScreen, CursorPtr pCursor);
+
+#define DMX_GET_CURSOR_PRIV(_pCursor, _pScreen) \
+ (dmxCursorPrivPtr)(_pCursor)->devPriv[(_pScreen)->myNum]
+
+#endif /* DMXCURSOR_H */
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxdpms.c b/nx-X11/programs/Xserver/hw/dmx/dmxdpms.c
new file mode 100644
index 000000000..5bcce188d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxdpms.c
@@ -0,0 +1,213 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Author:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Provides DPMS support and unifies all DPMS and other screen-saver
+ * support in one file. If -dpms is given on the command line, or the
+ * Xdmx server is not compiled with DPMS support, then the DPMS extension
+ * does not work for clients, but DPMS on the backends is still disables
+ * (and restored at Xdmx server shutdown time).
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxdpms.h"
+#include "dmxlog.h"
+#include "dmxsync.h"
+#ifdef DPMSExtension
+#include "dpmsproc.h"
+#endif
+#include "windowstr.h" /* For screenIsSaved */
+#include <X11/extensions/dpms.h>
+
+static unsigned long dpmsGeneration = 0;
+static Bool dpmsSupported = TRUE;
+
+static void _dmxDPMSInit(DMXScreenInfo *dmxScreen)
+{
+ int event_base, error_base;
+ int major, minor;
+ CARD16 level, standby, suspend, off;
+ BOOL state;
+ const char *monitor;
+
+ if (dpmsGeneration != serverGeneration) {
+ dpmsSupported = TRUE; /* On unless a backend doesn't support it */
+ dpmsGeneration = serverGeneration;
+ }
+
+#ifdef DPMSExtension
+ if (DPMSDisabledSwitch) dpmsSupported = FALSE; /* -dpms turns off */
+#endif
+
+ dmxScreen->dpmsCapable = 0;
+
+ if (!dmxScreen->beDisplay) {
+ dmxLogOutput(dmxScreen,
+ "Cannot determine if DPMS supported (detached screen)\n");
+ dpmsSupported = FALSE;
+ return;
+ }
+
+ if (!DPMSQueryExtension(dmxScreen->beDisplay,
+ &event_base, &error_base)) {
+ dmxLogOutput(dmxScreen, "DPMS not supported\n");
+ dpmsSupported = FALSE;
+ return;
+ }
+ if (!DPMSGetVersion(dmxScreen->beDisplay, &major, &minor)) {
+ dmxLogOutput(dmxScreen, "DPMS not supported\n");
+ dpmsSupported = FALSE;
+ return;
+ }
+ if (!DPMSCapable(dmxScreen->beDisplay)) {
+ dmxLogOutput(dmxScreen, "DPMS %d.%d (not DPMS capable)\n",
+ major, minor);
+ dpmsSupported = FALSE;
+ return;
+ }
+
+ DPMSInfo(dmxScreen->beDisplay, &level, &state);
+ DPMSGetTimeouts(dmxScreen->beDisplay, &standby, &suspend, &off);
+ DPMSSetTimeouts(dmxScreen->beDisplay, 0, 0, 0);
+ DPMSEnable(dmxScreen->beDisplay);
+ DPMSForceLevel(dmxScreen->beDisplay, DPMSModeOn);
+ dmxScreen->dpmsCapable = 1;
+ dmxScreen->dpmsEnabled = !!state;
+ dmxScreen->dpmsStandby = standby;
+ dmxScreen->dpmsSuspend = suspend;
+ dmxScreen->dpmsOff = off;
+
+ switch (level) {
+ case DPMSModeOn: monitor = "on"; break;
+ case DPMSModeStandby: monitor = "standby"; break;
+ case DPMSModeSuspend: monitor = "suspend"; break;
+ case DPMSModeOff: monitor = "off"; break;
+ default: monitor = "unknown"; break;
+ }
+
+ dmxLogOutput(dmxScreen,
+ "DPMS %d.%d (%s, %s, %d %d %d)\n",
+ major, minor, monitor, state ? "enabled" : "disabled",
+ standby, suspend, off);
+}
+
+/** Initialize DPMS support. We save the current settings and turn off
+ * DPMS. The settings are restored in #dmxDPMSTerm. */
+void dmxDPMSInit(DMXScreenInfo *dmxScreen)
+{
+ int interval, preferBlanking, allowExposures;
+
+ /* Turn off DPMS */
+ _dmxDPMSInit(dmxScreen);
+
+ if (!dmxScreen->beDisplay)
+ return;
+
+ /* Turn off screen saver */
+ XGetScreenSaver(dmxScreen->beDisplay, &dmxScreen->savedTimeout, &interval,
+ &preferBlanking, &allowExposures);
+ XSetScreenSaver(dmxScreen->beDisplay, 0, interval,
+ preferBlanking, allowExposures);
+ XResetScreenSaver(dmxScreen->beDisplay);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Terminate DPMS support on \a dmxScreen. We restore the settings
+ * saved in #dmxDPMSInit. */
+void dmxDPMSTerm(DMXScreenInfo *dmxScreen)
+{
+ int timeout, interval, preferBlanking, allowExposures;
+
+ if (!dmxScreen->beDisplay)
+ return;
+
+ XGetScreenSaver(dmxScreen->beDisplay, &timeout, &interval,
+ &preferBlanking, &allowExposures);
+ XSetScreenSaver(dmxScreen->beDisplay, dmxScreen->savedTimeout, interval,
+ preferBlanking, allowExposures);
+ if (dmxScreen->dpmsCapable) {
+ /* Restore saved state */
+ DPMSForceLevel(dmxScreen->beDisplay, DPMSModeOn);
+ DPMSSetTimeouts(dmxScreen->beDisplay, dmxScreen->dpmsStandby,
+ dmxScreen->dpmsSuspend, dmxScreen->dpmsOff);
+ if (dmxScreen->dpmsEnabled) DPMSEnable(dmxScreen->beDisplay);
+ else DPMSDisable(dmxScreen->beDisplay);
+ }
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Called when activity is detected so that DPMS power-saving mode can
+ * be deactivated. */
+void dmxDPMSWakeup(void)
+{
+ if (screenIsSaved == SCREEN_SAVER_ON)
+ SaveScreens(SCREEN_SAVER_OFF, ScreenSaverReset);
+#ifdef DPMSExtension
+ if (DPMSPowerLevel) DPMSSet(0);
+#endif
+}
+
+#ifdef DPMSExtension
+/** This is called on each server generation. It should determine if
+ * DPMS is supported on all of the backends and, if so, return TRUE. */
+Bool DPMSSupported(void)
+{
+ return dpmsSupported;
+}
+
+/** This is used by clients (e.g., xset) to set the DPMS level. */
+void DPMSSet(int level)
+{
+ int i;
+
+ if (!dpmsSupported) return;
+
+ if (level < 0) level = DPMSModeOn;
+ if (level > 3) level = DPMSModeOff;
+
+ DPMSPowerLevel = level;
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ if (dmxScreen->beDisplay) {
+ DPMSForceLevel(dmxScreen->beDisplay, level);
+ dmxSync(dmxScreen, FALSE);
+ }
+ }
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxdpms.h b/nx-X11/programs/Xserver/hw/dmx/dmxdpms.h
new file mode 100644
index 000000000..d3fa57d4a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxdpms.h
@@ -0,0 +1,43 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Author:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for DPMS extension support. \see dmxdpms.c */
+
+#ifndef _DMXDPMS_H_
+#define _DMXDPMS_H_
+extern void dmxDPMSInit(DMXScreenInfo *dmxScreen);
+extern void dmxDPMSTerm(DMXScreenInfo *dmxScreen);
+extern void dmxDPMSWakeup(void); /* Call when input is processed */
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxextension.c b/nx-X11/programs/Xserver/hw/dmx/dmxextension.c
new file mode 100644
index 000000000..feadb5e31
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxextension.c
@@ -0,0 +1,1497 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Author:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * This file provides the only interface to the X server extension support
+ * in programs/Xserver/Xext. Those programs should only include dmxext.h
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxinit.h"
+#include "dmxextension.h"
+#include "dmxwindow.h"
+#include "dmxcb.h"
+#include "dmxcursor.h"
+#include "dmxpixmap.h"
+#include "dmxgc.h"
+#include "dmxfont.h"
+#include "dmxcmap.h"
+#ifdef RENDER
+#include "dmxpict.h"
+#endif
+#include "dmxinput.h"
+#include "dmxsync.h"
+#include "dmxscrinit.h"
+#include "input/dmxinputinit.h"
+
+#include "windowstr.h"
+#include "inputstr.h" /* For DeviceIntRec */
+#include <X11/extensions/dmxproto.h> /* For DMX_BAD_* */
+#include "cursorstr.h"
+
+/* The default font is declared in dix/globals.c, but is not included in
+ * _any_ header files. */
+extern FontPtr defaultFont;
+
+/** This routine provides information to the DMX protocol extension
+ * about a particular screen. */
+Bool dmxGetScreenAttributes(int physical, DMXScreenAttributesPtr attr)
+{
+ DMXScreenInfo *dmxScreen;
+
+ if (physical < 0 || physical >= dmxNumScreens) return FALSE;
+
+ dmxScreen = &dmxScreens[physical];
+ attr->displayName = dmxScreen->name;
+#ifdef PANORAMIX
+ attr->logicalScreen = noPanoramiXExtension ? dmxScreen->index : 0;
+#else
+ attr->logicalScreen = dmxScreen->index;
+#endif
+
+ attr->screenWindowWidth = dmxScreen->scrnWidth;
+ attr->screenWindowHeight = dmxScreen->scrnHeight;
+ attr->screenWindowXoffset = dmxScreen->scrnX;
+ attr->screenWindowYoffset = dmxScreen->scrnY;
+
+ attr->rootWindowWidth = dmxScreen->rootWidth;
+ attr->rootWindowHeight = dmxScreen->rootHeight;
+ attr->rootWindowXoffset = dmxScreen->rootX;
+ attr->rootWindowYoffset = dmxScreen->rootY;
+
+ attr->rootWindowXorigin = dmxScreen->rootXOrigin;
+ attr->rootWindowYorigin = dmxScreen->rootYOrigin;
+
+ return TRUE;
+}
+
+/** This routine provides information to the DMX protocol extension
+ * about a particular window. */
+Bool dmxGetWindowAttributes(WindowPtr pWindow, DMXWindowAttributesPtr attr)
+{
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ attr->screen = pWindow->drawable.pScreen->myNum;
+ attr->window = pWinPriv->window;
+
+ attr->pos.x = pWindow->drawable.x;
+ attr->pos.y = pWindow->drawable.y;
+ attr->pos.width = pWindow->drawable.width;
+ attr->pos.height = pWindow->drawable.height;
+
+ if (!pWinPriv->window || pWinPriv->offscreen) {
+ attr->vis.x = 0;
+ attr->vis.y = 0;
+ attr->vis.height = 0;
+ attr->vis.width = 0;
+ return pWinPriv->window ? TRUE : FALSE;
+ }
+
+ /* Compute display-relative coordinates */
+ attr->vis.x = pWindow->drawable.x;
+ attr->vis.y = pWindow->drawable.y;
+ attr->vis.width = pWindow->drawable.width;
+ attr->vis.height = pWindow->drawable.height;
+
+ if (attr->pos.x < 0) {
+ attr->vis.x -= attr->pos.x;
+ attr->vis.width = attr->pos.x + attr->pos.width - attr->vis.x;
+ }
+ if (attr->pos.x + attr->pos.width > pWindow->drawable.pScreen->width) {
+ if (attr->pos.x < 0)
+ attr->vis.width = pWindow->drawable.pScreen->width;
+ else
+ attr->vis.width = pWindow->drawable.pScreen->width - attr->pos.x;
+ }
+ if (attr->pos.y < 0) {
+ attr->vis.y -= attr->pos.y;
+ attr->vis.height = attr->pos.y + attr->pos.height - attr->vis.y;
+ }
+ if (attr->pos.y + attr->pos.height > pWindow->drawable.pScreen->height) {
+ if (attr->pos.y < 0)
+ attr->vis.height = pWindow->drawable.pScreen->height;
+ else
+ attr->vis.height = pWindow->drawable.pScreen->height - attr->pos.y;
+ }
+
+ /* Convert to window-relative coordinates */
+ attr->vis.x -= attr->pos.x;
+ attr->vis.y -= attr->pos.y;
+
+ return TRUE;
+}
+
+void dmxGetDesktopAttributes(DMXDesktopAttributesPtr attr)
+{
+ attr->width = dmxGlobalWidth;
+ attr->height = dmxGlobalHeight;
+ attr->shiftX = 0; /* NOTE: The upper left hand corner of */
+ attr->shiftY = 0; /* the desktop is always <0,0>. */
+}
+
+/** Return the total number of devices, not just #dmxNumInputs. The
+ * number returned should be the same as that returned by
+ * XListInputDevices. */
+int dmxGetInputCount(void)
+{
+ int i, total;
+
+ for (total = i = 0; i < dmxNumInputs; i++) total += dmxInputs[i].numDevs;
+ return total;
+}
+
+/** Return information about the device with id = \a deviceId. This
+ * information is primarily for the #ProcDMXGetInputAttributes()
+ * function, which does not have access to the appropriate data
+ * structure. */
+int dmxGetInputAttributes(int deviceId, DMXInputAttributesPtr attr)
+{
+ int i, j;
+ DMXInputInfo *dmxInput;
+
+ if (deviceId < 0) return -1;
+ for (i = 0; i < dmxNumInputs; i++) {
+ dmxInput = &dmxInputs[i];
+ for (j = 0; j < dmxInput->numDevs; j++) {
+ DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[j];
+ if (deviceId != dmxLocal->pDevice->id) continue;
+ attr->isCore = !!dmxLocal->isCore;
+ attr->sendsCore = !!dmxLocal->sendsCore;
+ attr->detached = !!dmxInput->detached;
+ attr->physicalScreen = -1;
+ attr->physicalId = -1;
+ attr->name = NULL;
+ switch (dmxLocal->extType) {
+ case DMX_LOCAL_TYPE_LOCAL:
+ attr->inputType = 0;
+ break;
+ case DMX_LOCAL_TYPE_CONSOLE:
+ attr->inputType = 1;
+ attr->name = dmxInput->name;
+ attr->physicalId = dmxLocal->deviceId;
+ break;
+ case DMX_LOCAL_TYPE_BACKEND:
+ case DMX_LOCAL_TYPE_COMMON:
+ attr->inputType = 2;
+ attr->physicalScreen = dmxInput->scrnIdx;
+ attr->name = dmxInput->name;
+ attr->physicalId = dmxLocal->deviceId;
+ break;
+ }
+ return 0; /* Success */
+ }
+ }
+ return -1; /* Failure */
+}
+
+/** Reinitialized the cursor boundaries. */
+static void dmxAdjustCursorBoundaries(void)
+{
+ int i;
+
+ dmxReInitOrigins();
+ dmxInitOverlap();
+ dmxComputeWidthHeight(DMX_NO_RECOMPUTE_BOUNDING_BOX);
+ dmxConnectionBlockCallback();
+ for (i = 0; i < dmxNumInputs; i++) {
+ DMXInputInfo *dmxInput = &dmxInputs[i];
+ if (!dmxInput->detached) dmxInputReInit(dmxInput);
+ }
+
+ dmxCheckCursor();
+
+ for (i = 0; i < dmxNumInputs; i++) {
+ DMXInputInfo *dmxInput = &dmxInputs[i];
+ if (!dmxInput->detached) dmxInputLateReInit(dmxInput);
+ }
+}
+
+/** Add an input with the specified attributes. If the input is added,
+ * the physical id is returned in \a deviceId. */
+int dmxAddInput(DMXInputAttributesPtr attr, int *id)
+{
+ int retcode = BadValue;
+
+ if (attr->inputType == 1) /* console */
+ retcode = dmxInputAttachConsole(attr->name, attr->sendsCore, id);
+ else if (attr->inputType == 2) /* backend */
+ retcode = dmxInputAttachBackend(attr->physicalScreen,
+ attr->sendsCore,id);
+
+ if (retcode == Success) {
+ /* Adjust the cursor boundaries */
+ dmxAdjustCursorBoundaries();
+
+ /* Force completion of the changes */
+ dmxSync(NULL, TRUE);
+ }
+
+ return retcode;
+}
+
+/** Remove the input with physical id \a id. */
+int dmxRemoveInput(int id)
+{
+ return dmxInputDetachId(id);
+}
+
+/** Return the value of #dmxNumScreens -- the total number of backend
+ * screens in use (these are logical screens and may be larger than the
+ * number of backend displays). */
+unsigned long dmxGetNumScreens(void)
+{
+ return dmxNumScreens;
+}
+
+/** Make sure that #dmxCreateAndRealizeWindow has been called for \a
+ * pWindow. */
+void dmxForceWindowCreation(WindowPtr pWindow)
+{
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ if (!pWinPriv->window) dmxCreateAndRealizeWindow(pWindow, TRUE);
+}
+
+/** Flush pending syncs for all screens. */
+void dmxFlushPendingSyncs(void)
+{
+ dmxSync(NULL, TRUE);
+}
+
+/** Update DMX's screen resources to match those of the newly moved
+ * and/or resized "root" window. */
+void dmxUpdateScreenResources(ScreenPtr pScreen, int x, int y, int w, int h)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ WindowPtr pRoot = WindowTable[pScreen->myNum];
+ WindowPtr pChild;
+ Bool anyMarked = FALSE;
+
+ /* Handle special case where width and/or height are zero */
+ if (w == 0 || h == 0) {
+ w = 1;
+ h = 1;
+ }
+
+ /* Change screen size */
+ pScreen->width = w;
+ pScreen->height = h;
+
+ /* Reset the root window's drawable's size */
+ pRoot->drawable.width = w;
+ pRoot->drawable.height = h;
+
+ /* Set the root window's new winSize and borderSize */
+ pRoot->winSize.extents.x1 = 0;
+ pRoot->winSize.extents.y1 = 0;
+ pRoot->winSize.extents.x2 = w;
+ pRoot->winSize.extents.y2 = h;
+
+ pRoot->borderSize.extents.x1 = 0;
+ pRoot->borderSize.extents.y1 = 0;
+ pRoot->borderSize.extents.x2 = w;
+ pRoot->borderSize.extents.y2 = h;
+
+ /* Recompute this screen's mmWidth & mmHeight */
+ pScreen->mmWidth =
+ (w * 254 + dmxScreen->beXDPI * 5) / (dmxScreen->beXDPI * 10);
+ pScreen->mmHeight =
+ (h * 254 + dmxScreen->beYDPI * 5) / (dmxScreen->beYDPI * 10);
+
+ /* Recompute this screen's window's clip rects as follows: */
+ /* 1. Mark all of root's children's windows */
+ for (pChild = pRoot->firstChild; pChild; pChild = pChild->nextSib)
+ anyMarked |= pScreen->MarkOverlappedWindows(pChild, pChild,
+ (WindowPtr *)NULL);
+
+ /* 2. Set the root window's borderClip */
+ pRoot->borderClip.extents.x1 = 0;
+ pRoot->borderClip.extents.y1 = 0;
+ pRoot->borderClip.extents.x2 = w;
+ pRoot->borderClip.extents.y2 = h;
+
+ /* 3. Set the root window's clipList */
+ if (anyMarked) {
+ /* If any windows have been marked, set the root window's
+ * clipList to be broken since it will be recalculated in
+ * ValidateTree()
+ */
+ REGION_BREAK(pScreen, &pRoot->clipList);
+ } else {
+ /* Otherwise, we just set it directly since there are no
+ * windows visible on this screen
+ */
+ pRoot->clipList.extents.x1 = 0;
+ pRoot->clipList.extents.y1 = 0;
+ pRoot->clipList.extents.x2 = w;
+ pRoot->clipList.extents.y2 = h;
+ }
+
+ /* 4. Revalidate all clip rects and generate expose events */
+ if (anyMarked) {
+ pScreen->ValidateTree(pRoot, NULL, VTBroken);
+ pScreen->HandleExposures(pRoot);
+ if (pScreen->PostValidateTree)
+ pScreen->PostValidateTree(pRoot, NULL, VTBroken);
+ }
+}
+
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+
+/* Defined in dix/events.c */
+extern void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff);
+
+/** Change the "screen" window attributes by resizing the actual window
+ * on the back-end display (if necessary). */
+static void dmxConfigureScreenWindow(int idx,
+ int x, int y, int w, int h)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ ScreenPtr pScreen = screenInfo.screens[idx];
+
+ /* Resize "screen" window */
+ if (dmxScreen->scrnX != x ||
+ dmxScreen->scrnY != y ||
+ dmxScreen->scrnWidth != w ||
+ dmxScreen->scrnHeight != h) {
+ dmxResizeScreenWindow(pScreen, x, y, w, h);
+ }
+
+ /* Change "screen" window values */
+ dmxScreen->scrnX = x;
+ dmxScreen->scrnY = y;
+ dmxScreen->scrnWidth = w;
+ dmxScreen->scrnHeight = h;
+}
+
+/** Change the "root" window position and size by resizing the actual
+ * window on the back-end display (if necessary) and updating all of
+ * DMX's resources by calling #dmxUpdateScreenResources. */
+static void dmxConfigureRootWindow(int idx, int x, int y, int w, int h)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ WindowPtr pRoot = WindowTable[idx];
+
+ /* NOTE: Either this function or the ones that it calls must handle
+ * the case where w == 0 || h == 0. Currently, the functions that
+ * this one calls handle that case. */
+
+ /* 1. Resize "root" window */
+ if (dmxScreen->rootX != x ||
+ dmxScreen->rootY != y ||
+ dmxScreen->rootWidth != w ||
+ dmxScreen->rootHeight != h) {
+ dmxResizeRootWindow(pRoot, x, y, w, h);
+ }
+
+ /* 2. Update all of the screen's resources associated with this root
+ * window */
+ if (dmxScreen->rootWidth != w ||
+ dmxScreen->rootHeight != h) {
+ dmxUpdateScreenResources(screenInfo.screens[idx], x, y, w, h);
+ }
+
+ /* Change "root" window values */
+ dmxScreen->rootX = x;
+ dmxScreen->rootY = y;
+ dmxScreen->rootWidth = w;
+ dmxScreen->rootHeight = h;
+}
+
+/** Change the "root" window's origin by updating DMX's internal data
+ * structures (dix and Xinerama) to use the new origin and adjust the
+ * positions of windows that overlap this "root" window. */
+static void dmxSetRootWindowOrigin(int idx, int x, int y)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ ScreenPtr pScreen = screenInfo.screens[idx];
+ WindowPtr pRoot = WindowTable[idx];
+ WindowPtr pChild;
+ int xoff;
+ int yoff;
+
+ /* Change "root" window's origin */
+ dmxScreen->rootXOrigin = x;
+ dmxScreen->rootYOrigin = y;
+
+ /* Compute offsets here in case <x,y> has been changed above */
+ xoff = x - dixScreenOrigins[idx].x;
+ yoff = y - dixScreenOrigins[idx].y;
+
+ /* Adjust the root window's position in dixScreenOrigins */
+ dixScreenOrigins[idx].x = dmxScreen->rootXOrigin;
+ dixScreenOrigins[idx].y = dmxScreen->rootYOrigin;
+
+ /* Recalculate the Xinerama regions and data structs */
+ XineramaReinitData(pScreen);
+
+ /* Adjust each of the root window's children */
+ if (!idx) ReinitializeRootWindow(WindowTable[0], xoff, yoff);
+ pChild = pRoot->firstChild;
+ while (pChild) {
+ /* Adjust child window's position */
+ pScreen->MoveWindow(pChild,
+ pChild->origin.x - wBorderWidth(pChild) - xoff,
+ pChild->origin.y - wBorderWidth(pChild) - yoff,
+ pChild->nextSib,
+ VTMove);
+
+ /* Note that the call to MoveWindow will eventually call
+ * dmxPositionWindow which will automatically create a
+ * window if it is now exposed on screen (for lazy window
+ * creation optimization) and it will properly set the
+ * offscreen flag.
+ */
+
+ pChild = pChild->nextSib;
+ }
+}
+
+/** Configure the attributes of each "screen" and "root" window. */
+int dmxConfigureScreenWindows(int nscreens,
+ CARD32 *screens,
+ DMXScreenAttributesPtr attribs,
+ int *errorScreen)
+{
+ int i;
+
+ for (i = 0; i < nscreens; i++) {
+ DMXScreenAttributesPtr attr = &attribs[i];
+ int idx = screens[i];
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+
+ if (errorScreen) *errorScreen = i;
+
+ if (!dmxScreen->beDisplay) return DMX_BAD_VALUE;
+
+ /* Check for illegal values */
+ if (idx < 0 || idx >= dmxNumScreens) return BadValue;
+
+ /* The "screen" and "root" windows must have valid sizes */
+ if (attr->screenWindowWidth <= 0 || attr->screenWindowHeight <= 0 ||
+ attr->rootWindowWidth < 0 || attr->rootWindowHeight < 0)
+ return DMX_BAD_VALUE;
+
+ /* The "screen" window must fit entirely within the BE display */
+ if (attr->screenWindowXoffset < 0 ||
+ attr->screenWindowYoffset < 0 ||
+ attr->screenWindowXoffset
+ + attr->screenWindowWidth > (unsigned)dmxScreen->beWidth ||
+ attr->screenWindowYoffset
+ + attr->screenWindowHeight > (unsigned)dmxScreen->beHeight)
+ return DMX_BAD_VALUE;
+
+ /* The "root" window must fit entirely within the "screen" window */
+ if (attr->rootWindowXoffset < 0 ||
+ attr->rootWindowYoffset < 0 ||
+ attr->rootWindowXoffset
+ + attr->rootWindowWidth > attr->screenWindowWidth ||
+ attr->rootWindowYoffset
+ + attr->rootWindowHeight > attr->screenWindowHeight)
+ return DMX_BAD_VALUE;
+
+ /* The "root" window must not expose unaddressable coordinates */
+ if (attr->rootWindowXorigin < 0 ||
+ attr->rootWindowYorigin < 0 ||
+ attr->rootWindowXorigin + attr->rootWindowWidth > 32767 ||
+ attr->rootWindowYorigin + attr->rootWindowHeight > 32767)
+ return DMX_BAD_VALUE;
+
+ /* The "root" window must fit within the global bounding box */
+ if (attr->rootWindowXorigin
+ + attr->rootWindowWidth > (unsigned)dmxGlobalWidth ||
+ attr->rootWindowYorigin
+ + attr->rootWindowHeight > (unsigned)dmxGlobalHeight)
+ return DMX_BAD_VALUE;
+
+ /* FIXME: Handle the rest of the illegal value checking */
+ }
+
+ /* No illegal values found */
+ if (errorScreen) *errorScreen = 0;
+
+ for (i = 0; i < nscreens; i++) {
+ DMXScreenAttributesPtr attr = &attribs[i];
+ int idx = screens[i];
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+
+ dmxLog(dmxInfo, "Changing screen #%d attributes "
+ "from %dx%d+%d+%d %dx%d+%d+%d +%d+%d "
+ "to %dx%d+%d+%d %dx%d+%d+%d +%d+%d\n",
+ idx,
+ dmxScreen->scrnWidth, dmxScreen->scrnHeight,
+ dmxScreen->scrnX, dmxScreen->scrnY,
+ dmxScreen->rootWidth, dmxScreen->rootHeight,
+ dmxScreen->rootX, dmxScreen->rootY,
+ dmxScreen->rootXOrigin, dmxScreen->rootYOrigin,
+ attr->screenWindowWidth, attr->screenWindowHeight,
+ attr->screenWindowXoffset, attr->screenWindowYoffset,
+ attr->rootWindowWidth, attr->rootWindowHeight,
+ attr->rootWindowXoffset, attr->rootWindowYoffset,
+ attr->rootWindowXorigin, attr->rootWindowYorigin);
+
+ /* Configure "screen" window */
+ dmxConfigureScreenWindow(idx,
+ attr->screenWindowXoffset,
+ attr->screenWindowYoffset,
+ attr->screenWindowWidth,
+ attr->screenWindowHeight);
+
+ /* Configure "root" window */
+ dmxConfigureRootWindow(idx,
+ attr->rootWindowXoffset,
+ attr->rootWindowYoffset,
+ attr->rootWindowWidth,
+ attr->rootWindowHeight);
+
+
+ /* Set "root" window's origin */
+ dmxSetRootWindowOrigin(idx,
+ attr->rootWindowXorigin,
+ attr->rootWindowYorigin);
+ }
+
+ /* Adjust the cursor boundaries */
+ dmxAdjustCursorBoundaries();
+
+ /* Force completion of the changes */
+ dmxSync(NULL, TRUE);
+
+ return Success;
+}
+
+/** Configure the attributes of the global desktop. */
+int dmxConfigureDesktop(DMXDesktopAttributesPtr attribs)
+{
+ if (attribs->width <= 0 || attribs->width >= 32767 ||
+ attribs->height <= 0 || attribs->height >= 32767)
+ return DMX_BAD_VALUE;
+
+ /* If the desktop is shrinking, adjust the "root" windows on each
+ * "screen" window to only show the visible desktop. Also, handle
+ * the special case where the desktop shrinks such that the it no
+ * longer overlaps an portion of a "screen" window. */
+ if (attribs->width < dmxGlobalWidth || attribs->height < dmxGlobalHeight) {
+ int i;
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ if (dmxScreen->rootXOrigin
+ + dmxScreen->rootWidth > attribs->width ||
+ dmxScreen->rootYOrigin
+ + dmxScreen->rootHeight > attribs->height) {
+ int w, h;
+ if ((w = attribs->width - dmxScreen->rootXOrigin) < 0) w = 0;
+ if ((h = attribs->height - dmxScreen->rootYOrigin) < 0) h = 0;
+ if (w > dmxScreen->scrnWidth) w = dmxScreen->scrnWidth;
+ if (h > dmxScreen->scrnHeight) h = dmxScreen->scrnHeight;
+ if (w > dmxScreen->rootWidth) w = dmxScreen->rootWidth;
+ if (h > dmxScreen->rootHeight) h = dmxScreen->rootHeight;
+ dmxConfigureRootWindow(i,
+ dmxScreen->rootX,
+ dmxScreen->rootY,
+ w, h);
+ }
+ }
+ }
+
+ /* Set the global width/height */
+ dmxSetWidthHeight(attribs->width, attribs->height);
+
+ /* Handle shift[XY] changes */
+ if (attribs->shiftX || attribs->shiftY) {
+ int i;
+ for (i = 0; i < dmxNumScreens; i++) {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ WindowPtr pChild = WindowTable[i]->firstChild;
+ while (pChild) {
+ /* Adjust child window's position */
+ pScreen->MoveWindow(pChild,
+ pChild->origin.x - wBorderWidth(pChild)
+ - attribs->shiftX,
+ pChild->origin.y - wBorderWidth(pChild)
+ - attribs->shiftY,
+ pChild->nextSib,
+ VTMove);
+
+ /* Note that the call to MoveWindow will eventually call
+ * dmxPositionWindow which will automatically create a
+ * window if it is now exposed on screen (for lazy
+ * window creation optimization) and it will properly
+ * set the offscreen flag.
+ */
+
+ pChild = pChild->nextSib;
+ }
+ }
+ }
+
+ /* Update connection block, Xinerama, etc. -- these appears to
+ * already be handled in dmxConnectionBlockCallback(), which is
+ * called from dmxAdjustCursorBoundaries() [below]. */
+
+ /* Adjust the cursor boundaries */
+ dmxAdjustCursorBoundaries();
+
+ /* Force completion of the changes */
+ dmxSync(NULL, TRUE);
+
+ return Success;
+}
+#endif
+
+/** Create the scratch GCs per depth. */
+static void dmxBECreateScratchGCs(int scrnNum)
+{
+ ScreenPtr pScreen = screenInfo.screens[scrnNum];
+ GCPtr *ppGC = pScreen->GCperDepth;
+ int i;
+
+ for (i = 0; i <= pScreen->numDepths; i++)
+ dmxBECreateGC(pScreen, ppGC[i]);
+}
+
+#ifdef PANORAMIX
+static Bool FoundPixImage;
+
+/** Search the Xinerama XRT_PIXMAP resources for the pixmap that needs
+ * to have its image restored. When it is found, see if there is
+ * another screen with the same image. If so, copy the pixmap image
+ * from the existing screen to the newly created pixmap. */
+static void dmxBERestorePixmapImage(pointer value, XID id, RESTYPE type,
+ pointer p)
+{
+ if ((type & TypeMask) == (XRT_PIXMAP & TypeMask)) {
+ PixmapPtr pDst = (PixmapPtr)p;
+ int idx = pDst->drawable.pScreen->myNum;
+ PanoramiXRes *pXinPix = (PanoramiXRes *)value;
+ PixmapPtr pPix;
+ int i;
+
+ pPix = (PixmapPtr)LookupIDByType(pXinPix->info[idx].id, RT_PIXMAP);
+ if (pPix != pDst) return; /* Not a match.... Next! */
+
+ for (i = 0; i < PanoramiXNumScreens; i++) {
+ PixmapPtr pSrc;
+ dmxPixPrivPtr pSrcPriv = NULL;
+
+ if (i == idx) continue; /* Self replication is bad */
+
+ pSrc =
+ (PixmapPtr)LookupIDByType(pXinPix->info[i].id, RT_PIXMAP);
+ pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc);
+ if (pSrcPriv->pixmap) {
+ DMXScreenInfo *dmxSrcScreen = &dmxScreens[i];
+ DMXScreenInfo *dmxDstScreen = &dmxScreens[idx];
+ dmxPixPrivPtr pDstPriv = DMX_GET_PIXMAP_PRIV(pDst);
+ XImage *img;
+ int j;
+ XlibGC gc = NULL;
+
+ /* This should never happen, but just in case.... */
+ if (pSrc->drawable.width != pDst->drawable.width ||
+ pSrc->drawable.height != pDst->drawable.height)
+ return;
+
+ /* Copy from src pixmap to dst pixmap */
+ img = XGetImage(dmxSrcScreen->beDisplay,
+ pSrcPriv->pixmap,
+ 0, 0,
+ pSrc->drawable.width, pSrc->drawable.height,
+ -1,
+ ZPixmap);
+
+ for (j = 0; j < dmxDstScreen->beNumPixmapFormats; j++) {
+ if (dmxDstScreen->bePixmapFormats[j].depth == img->depth) {
+ unsigned long m;
+ XGCValues v;
+
+ m = GCFunction | GCPlaneMask | GCClipMask;
+ v.function = GXcopy;
+ v.plane_mask = AllPlanes;
+ v.clip_mask = None;
+
+ gc = XCreateGC(dmxDstScreen->beDisplay,
+ dmxDstScreen->scrnDefDrawables[j],
+ m, &v);
+ break;
+ }
+ }
+
+ if (gc) {
+ XPutImage(dmxDstScreen->beDisplay,
+ pDstPriv->pixmap,
+ gc, img, 0, 0, 0, 0,
+ pDst->drawable.width, pDst->drawable.height);
+ XFreeGC(dmxDstScreen->beDisplay, gc);
+ FoundPixImage = True;
+ } else {
+ dmxLog(dmxWarning, "Could not create GC\n");
+ }
+
+ XDestroyImage(img);
+ return;
+ }
+ }
+ }
+}
+#endif
+
+/** Restore the pixmap image either from another screen or from an image
+ * that was saved when the screen was previously detached. */
+static void dmxBERestorePixmap(PixmapPtr pPixmap)
+{
+#ifdef PANORAMIX
+ int i;
+
+ /* If Xinerama is not active, there's nothing we can do (see comment
+ * in #else below for more info). */
+ if (noPanoramiXExtension) {
+ dmxLog(dmxWarning, "Cannot restore pixmap image\n");
+ return;
+ }
+
+ FoundPixImage = False;
+ for (i = currentMaxClients; --i >= 0; )
+ if (clients[i])
+ FindAllClientResources(clients[i], dmxBERestorePixmapImage,
+ (pointer)pPixmap);
+
+ /* No corresponding pixmap image was found on other screens, so we
+ * need to copy it from the saved image when the screen was detached
+ * (if available). */
+ if (!FoundPixImage) {
+ dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
+
+ if (pPixPriv->detachedImage) {
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ XlibGC gc = NULL;
+
+ for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) {
+ if (dmxScreen->bePixmapFormats[i].depth ==
+ pPixPriv->detachedImage->depth) {
+ unsigned long m;
+ XGCValues v;
+
+ m = GCFunction | GCPlaneMask | GCClipMask;
+ v.function = GXcopy;
+ v.plane_mask = AllPlanes;
+ v.clip_mask = None;
+
+ gc = XCreateGC(dmxScreen->beDisplay,
+ dmxScreen->scrnDefDrawables[i],
+ m, &v);
+ break;
+ }
+ }
+
+ if (gc) {
+ XPutImage(dmxScreen->beDisplay,
+ pPixPriv->pixmap,
+ gc,
+ pPixPriv->detachedImage,
+ 0, 0, 0, 0,
+ pPixmap->drawable.width, pPixmap->drawable.height);
+ XFreeGC(dmxScreen->beDisplay, gc);
+ } else {
+ dmxLog(dmxWarning, "Cannot restore pixmap image\n");
+ }
+
+ XDestroyImage(pPixPriv->detachedImage);
+ pPixPriv->detachedImage = NULL;
+ } else {
+ dmxLog(dmxWarning, "Cannot restore pixmap image\n");
+ }
+ }
+#else
+ /* If Xinerama is not enabled, then there is no other copy of the
+ * pixmap image that we can restore. Saving all pixmap data is not
+ * a feasible option since there is no mechanism for updating pixmap
+ * data when a screen is detached, which means that the data that
+ * was previously saved would most likely be out of date. */
+ dmxLog(dmxWarning, "Cannot restore pixmap image\n");
+ return;
+#endif
+}
+
+/** Create resources on the back-end server. This function is called
+ * from #dmxAttachScreen() via the dix layer's FindAllResources
+ * function. It walks all resources, compares them to the screen
+ * number passed in as \a n and calls the appropriate DMX function to
+ * create the associated resource on the back-end server. */
+static void dmxBECreateResources(pointer value, XID id, RESTYPE type,
+ pointer n)
+{
+ int scrnNum = (int)n;
+ ScreenPtr pScreen = screenInfo.screens[scrnNum];
+
+ if ((type & TypeMask) == (RT_WINDOW & TypeMask)) {
+ /* Window resources are created below in dmxBECreateWindowTree */
+ } else if ((type & TypeMask) == (RT_PIXMAP & TypeMask)) {
+ PixmapPtr pPix = value;
+ if (pPix->drawable.pScreen->myNum == scrnNum) {
+ dmxBECreatePixmap(pPix);
+ dmxBERestorePixmap(pPix);
+ }
+ } else if ((type & TypeMask) == (RT_GC & TypeMask)) {
+ GCPtr pGC = value;
+ if (pGC->pScreen->myNum == scrnNum) {
+ /* Create the GC on the back-end server */
+ dmxBECreateGC(pScreen, pGC);
+ /* Create any pixmaps associated with this GC */
+ if (!pGC->tileIsPixel) {
+ dmxBECreatePixmap(pGC->tile.pixmap);
+ dmxBERestorePixmap(pGC->tile.pixmap);
+ }
+ if (pGC->stipple != pScreen->PixmapPerDepth[0]) {
+ dmxBECreatePixmap(pGC->stipple);
+ dmxBERestorePixmap(pGC->stipple);
+ }
+ if (pGC->font != defaultFont) {
+ (void)dmxBELoadFont(pScreen, pGC->font);
+ }
+ /* Update the GC on the back-end server */
+ dmxChangeGC(pGC, -1L);
+ }
+ } else if ((type & TypeMask) == (RT_FONT & TypeMask)) {
+ (void)dmxBELoadFont(pScreen, (FontPtr)value);
+ } else if ((type & TypeMask) == (RT_CURSOR & TypeMask)) {
+ dmxBECreateCursor(pScreen, (CursorPtr)value);
+ } else if ((type & TypeMask) == (RT_COLORMAP & TypeMask)) {
+ ColormapPtr pCmap = value;
+ if (pCmap->pScreen->myNum == scrnNum)
+ (void)dmxBECreateColormap((ColormapPtr)value);
+#if 0
+#ifdef RENDER
+ /* TODO: Recreate Picture and GlyphSet resources */
+ } else if ((type & TypeMask) == (PictureType & TypeMask)) {
+ /* Picture resources are created when windows are created */
+ } else if ((type & TypeMask) == (GlyphSetType & TypeMask)) {
+ dmxBEFreeGlyphSet(pScreen, (GlyphSetPtr)value);
+#endif
+#endif
+ } else {
+ /* Other resource types??? */
+ }
+}
+
+/** Create window hierachy on back-end server. The window tree is
+ * created in a special order (bottom most subwindow first) so that the
+ * #dmxCreateNonRootWindow() function does not need to recursively call
+ * itself to create each window's parents. This is required so that we
+ * have the opportunity to create each window's border and background
+ * pixmaps (where appropriate) before the window is created. */
+static void dmxBECreateWindowTree(int idx)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ WindowPtr pRoot = WindowTable[idx];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pRoot);
+ WindowPtr pWin;
+
+ /* Create the pixmaps associated with the root window */
+ if (!pRoot->borderIsPixel) {
+ dmxBECreatePixmap(pRoot->border.pixmap);
+ dmxBERestorePixmap(pRoot->border.pixmap);
+ }
+ if (pRoot->backgroundState == BackgroundPixmap) {
+ dmxBECreatePixmap(pRoot->background.pixmap);
+ dmxBERestorePixmap(pRoot->background.pixmap);
+ }
+
+ /* Create root window first */
+ dmxScreen->rootWin = pWinPriv->window = dmxCreateRootWindow(pRoot);
+ XMapWindow(dmxScreen->beDisplay, dmxScreen->rootWin);
+
+ pWin = pRoot->lastChild;
+ while (pWin) {
+ pWinPriv = DMX_GET_WINDOW_PRIV(pWin);
+
+ /* Create the pixmaps regardless of whether or not the
+ * window is created or not due to lazy window creation.
+ */
+ if (!pWin->borderIsPixel) {
+ dmxBECreatePixmap(pWin->border.pixmap);
+ dmxBERestorePixmap(pWin->border.pixmap);
+ }
+ if (pWin->backgroundState == BackgroundPixmap) {
+ dmxBECreatePixmap(pWin->background.pixmap);
+ dmxBERestorePixmap(pWin->background.pixmap);
+ }
+
+ /* Reset the window attributes */
+ dmxGetDefaultWindowAttributes(pWin,
+ &pWinPriv->cmap,
+ &pWinPriv->visual);
+
+ /* Create the window */
+ if (pWinPriv->mapped && !pWinPriv->offscreen)
+ dmxCreateAndRealizeWindow(pWin, TRUE);
+
+ /* Next, create the bottom-most child */
+ if (pWin->lastChild) {
+ pWin = pWin->lastChild;
+ continue;
+ }
+
+ /* If the window has no children, move on to the next higher window */
+ while (!pWin->prevSib && (pWin != pRoot))
+ pWin = pWin->parent;
+
+ if (pWin->prevSib) {
+ pWin = pWin->prevSib;
+ continue;
+ }
+
+ /* When we reach the root window, we are finished */
+ if (pWin == pRoot)
+ break;
+ }
+}
+
+/* Refresh screen by generating exposure events for all windows */
+static void dmxForceExposures(int idx)
+{
+ ScreenPtr pScreen = screenInfo.screens[idx];
+ WindowPtr pRoot = WindowTable[idx];
+ Bool anyMarked = FALSE;
+ WindowPtr pChild;
+
+ for (pChild = pRoot->firstChild; pChild; pChild = pChild->nextSib)
+ anyMarked |= pScreen->MarkOverlappedWindows(pChild, pChild,
+ (WindowPtr *)NULL);
+ if (anyMarked) {
+ /* If any windows have been marked, set the root window's
+ * clipList to be broken since it will be recalculated in
+ * ValidateTree()
+ */
+ REGION_BREAK(pScreen, &pRoot->clipList);
+ pScreen->ValidateTree(pRoot, NULL, VTBroken);
+ pScreen->HandleExposures(pRoot);
+ if (pScreen->PostValidateTree)
+ pScreen->PostValidateTree(pRoot, NULL, VTBroken);
+ }
+}
+
+/** Compare the new and old screens to see if they are compatible. */
+static Bool dmxCompareScreens(DMXScreenInfo *new, DMXScreenInfo *old)
+{
+ int i;
+
+ if (new->beWidth != old->beWidth) return FALSE;
+ if (new->beHeight != old->beHeight) return FALSE;
+ if (new->beDepth != old->beDepth) return FALSE;
+ if (new->beBPP != old->beBPP) return FALSE;
+
+ if (new->beNumDepths != old->beNumDepths) return FALSE;
+ for (i = 0; i < old->beNumDepths; i++)
+ if (new->beDepths[i] != old->beDepths[i]) return FALSE;
+
+ if (new->beNumPixmapFormats != old->beNumPixmapFormats) return FALSE;
+ for (i = 0; i < old->beNumPixmapFormats; i++) {
+ if (new->bePixmapFormats[i].depth !=
+ old->bePixmapFormats[i].depth) return FALSE;
+ if (new->bePixmapFormats[i].bits_per_pixel !=
+ old->bePixmapFormats[i].bits_per_pixel) return FALSE;
+ if (new->bePixmapFormats[i].scanline_pad !=
+ old->bePixmapFormats[i].scanline_pad) return FALSE;
+ }
+
+ if (new->beNumVisuals != old->beNumVisuals) return FALSE;
+ for (i = 0; i < old->beNumVisuals; i++) {
+ if (new->beVisuals[i].visualid !=
+ old->beVisuals[i].visualid) return FALSE;
+ if (new->beVisuals[i].screen !=
+ old->beVisuals[i].screen) return FALSE;
+ if (new->beVisuals[i].depth !=
+ old->beVisuals[i].depth) return FALSE;
+ if (new->beVisuals[i].class !=
+ old->beVisuals[i].class) return FALSE;
+ if (new->beVisuals[i].red_mask !=
+ old->beVisuals[i].red_mask) return FALSE;
+ if (new->beVisuals[i].green_mask !=
+ old->beVisuals[i].green_mask) return FALSE;
+ if (new->beVisuals[i].blue_mask !=
+ old->beVisuals[i].blue_mask) return FALSE;
+ if (new->beVisuals[i].colormap_size !=
+ old->beVisuals[i].colormap_size) return FALSE;
+ if (new->beVisuals[i].bits_per_rgb !=
+ old->beVisuals[i].bits_per_rgb) return FALSE;
+ }
+
+ if (new->beDefVisualIndex != old->beDefVisualIndex) return FALSE;
+
+ return TRUE;
+}
+
+/** Reattach previously detached back-end screen. */
+int dmxAttachScreen(int idx, DMXScreenAttributesPtr attr)
+{
+ ScreenPtr pScreen = screenInfo.screens[idx];
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ CARD32 scrnNum = idx;
+ DMXScreenInfo oldDMXScreen;
+ int i;
+
+ /* Return failure if dynamic addition/removal of screens is disabled */
+ if (!dmxAddRemoveScreens) {
+ dmxLog(dmxWarning,
+ "Attempting to add a screen, but the AddRemoveScreen\n");
+ dmxLog(dmxWarning,
+ "extension has not been enabled. To enable this extension\n");
+ dmxLog(dmxWarning,
+ "add the \"-addremovescreens\" option either to the command\n");
+ dmxLog(dmxWarning,
+ "line or in the configuration file.\n");
+ return 1;
+ }
+
+ /* Cannot add a screen that does not exist */
+ if (idx < 0 || idx >= dmxNumScreens) return 1;
+
+ /* Cannot attach to a screen that is already opened */
+ if (dmxScreen->beDisplay) {
+ dmxLog(dmxWarning,
+ "Attempting to add screen #%d but a screen already exists\n",
+ idx);
+ return 1;
+ }
+
+ dmxLogOutput(dmxScreen, "Attaching screen #%d\n", idx);
+
+ /* Save old info */
+ oldDMXScreen = *dmxScreen;
+
+ /* Copy the name to the new screen */
+ dmxScreen->name = strdup(attr->displayName);
+
+ /* Open display and get all of the screen info */
+ if (!dmxOpenDisplay(dmxScreen)) {
+ dmxLog(dmxWarning,
+ "dmxOpenDisplay: Unable to open display %s\n",
+ dmxScreen->name);
+
+ /* Restore the old screen */
+ *dmxScreen = oldDMXScreen;
+ return 1;
+ }
+
+ dmxSetErrorHandler(dmxScreen);
+ dmxCheckForWM(dmxScreen);
+ dmxGetScreenAttribs(dmxScreen);
+
+ if (!dmxGetVisualInfo(dmxScreen)) {
+ dmxLog(dmxWarning, "dmxGetVisualInfo: No matching visuals found\n");
+ XFree(dmxScreen->beVisuals);
+ XCloseDisplay(dmxScreen->beDisplay);
+
+ /* Restore the old screen */
+ *dmxScreen = oldDMXScreen;
+ return 1;
+ }
+
+ dmxGetColormaps(dmxScreen);
+ dmxGetPixmapFormats(dmxScreen);
+
+ /* Verify that the screen to be added has the same info as the
+ * previously added screen. */
+ if (!dmxCompareScreens(dmxScreen, &oldDMXScreen)) {
+ dmxLog(dmxWarning,
+ "New screen data (%s) does not match previously\n",
+ dmxScreen->name);
+ dmxLog(dmxWarning,
+ "attached screen data (%s)\n",
+ oldDMXScreen.name);
+ dmxLog(dmxWarning,
+ "All data must match in order to attach to screen #%d\n",
+ idx);
+ XFree(dmxScreen->beVisuals);
+ XFree(dmxScreen->beDepths);
+ XFree(dmxScreen->bePixmapFormats);
+ XCloseDisplay(dmxScreen->beDisplay);
+
+ /* Restore the old screen */
+ *dmxScreen = oldDMXScreen;
+ return 1;
+ }
+
+ /* Initialize the BE screen resources */
+ dmxBEScreenInit(idx, screenInfo.screens[idx]);
+
+ /* TODO: Handle GLX visual initialization. GLXProxy needs to be
+ * updated to handle dynamic addition/removal of screens. */
+
+ /* Create default stipple */
+ dmxBECreatePixmap(pScreen->PixmapPerDepth[0]);
+ dmxBERestorePixmap(pScreen->PixmapPerDepth[0]);
+
+ /* Create the scratch GCs */
+ dmxBECreateScratchGCs(idx);
+
+ /* Create the default font */
+ (void)dmxBELoadFont(pScreen, defaultFont);
+
+ /* Create all resources that don't depend on windows */
+ for (i = currentMaxClients; --i >= 0; )
+ if (clients[i])
+ FindAllClientResources(clients[i], dmxBECreateResources,
+ (pointer)idx);
+
+ /* Create window hierarchy (top down) */
+ dmxBECreateWindowTree(idx);
+
+ /* Refresh screen by generating exposure events for all windows */
+ dmxForceExposures(idx);
+
+ dmxSync(&dmxScreens[idx], TRUE);
+
+ /* We used these to compare the old and new screens. They are no
+ * longer needed since we have a newly attached screen, so we can
+ * now free the old screen's resources. */
+ XFree(oldDMXScreen.beVisuals);
+ XFree(oldDMXScreen.beDepths);
+ XFree(oldDMXScreen.bePixmapFormats);
+ /* TODO: should oldDMXScreen.name be freed?? */
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension)
+ return dmxConfigureScreenWindows(1, &scrnNum, attr, NULL);
+ else
+#endif
+ return 0; /* Success */
+}
+
+/*
+ * Resources that may have state on the BE server and need to be freed:
+ *
+ * RT_NONE
+ * RT_WINDOW
+ * RT_PIXMAP
+ * RT_GC
+ * RT_FONT
+ * RT_CURSOR
+ * RT_COLORMAP
+ * RT_CMAPENTRY
+ * RT_OTHERCLIENT
+ * RT_PASSIVEGRAB
+ * XRT_WINDOW
+ * XRT_PIXMAP
+ * XRT_GC
+ * XRT_COLORMAP
+ * XRT_PICTURE
+ * PictureType
+ * PictFormatType
+ * GlyphSetType
+ * ClientType
+ * EventType
+ * RT_INPUTCLIENT
+ * XETrapType
+ * RTCounter
+ * RTAwait
+ * RTAlarmClient
+ * RT_XKBCLIENT
+ * RTContext
+ * TagResType
+ * StalledResType
+ * RT_APPGROUP
+ * SecurityAuthorizationResType
+ * RTEventClient
+ * __glXContextRes
+ * __glXClientRes
+ * __glXPixmapRes
+ * __glXWindowRes
+ * __glXPbufferRes
+ */
+
+#ifdef PANORAMIX
+/** Search the Xinerama XRT_PIXMAP resources for the pixmap that needs
+ * to have its image saved. */
+static void dmxBEFindPixmapImage(pointer value, XID id, RESTYPE type,
+ pointer p)
+{
+ if ((type & TypeMask) == (XRT_PIXMAP & TypeMask)) {
+ PixmapPtr pDst = (PixmapPtr)p;
+ int idx = pDst->drawable.pScreen->myNum;
+ PanoramiXRes *pXinPix = (PanoramiXRes *)value;
+ PixmapPtr pPix;
+ int i;
+
+ pPix = (PixmapPtr)LookupIDByType(pXinPix->info[idx].id, RT_PIXMAP);
+ if (pPix != pDst) return; /* Not a match.... Next! */
+
+ for (i = 0; i < PanoramiXNumScreens; i++) {
+ PixmapPtr pSrc;
+ dmxPixPrivPtr pSrcPriv = NULL;
+
+ if (i == idx) continue; /* Self replication is bad */
+
+ pSrc =
+ (PixmapPtr)LookupIDByType(pXinPix->info[i].id, RT_PIXMAP);
+ pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc);
+ if (pSrcPriv->pixmap) {
+ FoundPixImage = True;
+ return;
+ }
+ }
+ }
+}
+#endif
+
+/** Save the pixmap image only when there is not another screen with
+ * that pixmap from which the image can be read when the screen is
+ * reattached. To do this, we first try to find a pixmap on another
+ * screen corresponding to the one we are trying to save. If we find
+ * one, then we do not need to save the image data since during
+ * reattachment, the image data can be read from that other pixmap.
+ * However, if we do not find one, then we need to save the image data.
+ * The common case for these are for the default stipple and root
+ * tile. */
+static void dmxBESavePixmap(PixmapPtr pPixmap)
+{
+#ifdef PANORAMIX
+ int i;
+
+ /* If Xinerama is not active, there's nothing we can do (see comment
+ * in #else below for more info). */
+ if (noPanoramiXExtension) return;
+
+ FoundPixImage = False;
+ for (i = currentMaxClients; --i >= 0; )
+ if (clients[i])
+ FindAllClientResources(clients[i], dmxBEFindPixmapImage,
+ (pointer)pPixmap);
+
+ /* Save the image only if there is no other screens that have a
+ * pixmap that corresponds to the one we are trying to save. */
+ if (!FoundPixImage) {
+ dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
+
+ if (!pPixPriv->detachedImage) {
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+
+ pPixPriv->detachedImage = XGetImage(dmxScreen->beDisplay,
+ pPixPriv->pixmap,
+ 0, 0,
+ pPixmap->drawable.width,
+ pPixmap->drawable.height,
+ -1,
+ ZPixmap);
+ if (!pPixPriv->detachedImage)
+ dmxLog(dmxWarning, "Cannot save pixmap image\n");
+ }
+ }
+#else
+ /* NOTE: The only time there is a pixmap on another screen that
+ * corresponds to the one we are trying to save is when Xinerama is
+ * active. Otherwise, the pixmap image data is only stored on a
+ * single screen, which means that once it is detached, that data is
+ * lost. We could save the data here, but then that would require
+ * us to implement the ability for Xdmx to keep the pixmap up to
+ * date while the screen is detached, which is beyond the scope of
+ * the current project. */
+ return;
+#endif
+}
+
+/** Destroy resources on the back-end server. This function is called
+ * from #dmxDetachScreen() via the dix layer's FindAllResources
+ * function. It walks all resources, compares them to the screen
+ * number passed in as \a n and calls the appropriate DMX function to
+ * free the associated resource on the back-end server. */
+static void dmxBEDestroyResources(pointer value, XID id, RESTYPE type,
+ pointer n)
+{
+ int scrnNum = (int)n;
+ ScreenPtr pScreen = screenInfo.screens[scrnNum];
+
+ if ((type & TypeMask) == (RT_WINDOW & TypeMask)) {
+ /* Window resources are destroyed below in dmxBEDestroyWindowTree */
+ } else if ((type & TypeMask) == (RT_PIXMAP & TypeMask)) {
+ PixmapPtr pPix = value;
+ if (pPix->drawable.pScreen->myNum == scrnNum) {
+ dmxBESavePixmap(pPix);
+ dmxBEFreePixmap(pPix);
+ }
+ } else if ((type & TypeMask) == (RT_GC & TypeMask)) {
+ GCPtr pGC = value;
+ if (pGC->pScreen->myNum == scrnNum)
+ dmxBEFreeGC(pGC);
+ } else if ((type & TypeMask) == (RT_FONT & TypeMask)) {
+ dmxBEFreeFont(pScreen, (FontPtr)value);
+ } else if ((type & TypeMask) == (RT_CURSOR & TypeMask)) {
+ dmxBEFreeCursor(pScreen, (CursorPtr)value);
+ } else if ((type & TypeMask) == (RT_COLORMAP & TypeMask)) {
+ ColormapPtr pCmap = value;
+ if (pCmap->pScreen->myNum == scrnNum)
+ dmxBEFreeColormap((ColormapPtr)value);
+#ifdef RENDER
+ } else if ((type & TypeMask) == (PictureType & TypeMask)) {
+ PicturePtr pPict = value;
+ if (pPict->pDrawable->pScreen->myNum == scrnNum)
+ dmxBEFreePicture((PicturePtr)value);
+ } else if ((type & TypeMask) == (GlyphSetType & TypeMask)) {
+ dmxBEFreeGlyphSet(pScreen, (GlyphSetPtr)value);
+#endif
+ } else {
+ /* Other resource types??? */
+ }
+}
+
+/** Destroy the scratch GCs that are created per depth. */
+static void dmxBEDestroyScratchGCs(int scrnNum)
+{
+ ScreenPtr pScreen = screenInfo.screens[scrnNum];
+ GCPtr *ppGC = pScreen->GCperDepth;
+ int i;
+
+ for (i = 0; i <= pScreen->numDepths; i++)
+ dmxBEFreeGC(ppGC[i]);
+}
+
+/** Destroy window hierachy on back-end server. To ensure that all
+ * XDestroyWindow() calls succeed, they must be performed in a bottom
+ * up order so that windows are not destroyed before their children.
+ * XDestroyWindow(), which is called from #dmxBEDestrowWindow(), will
+ * destroy a window as well as all of it's children. */
+static void dmxBEDestroyWindowTree(int idx)
+{
+ WindowPtr pWin = WindowTable[idx];
+ WindowPtr pChild = pWin;
+
+ while (1) {
+ if (pChild->firstChild) {
+ pChild = pChild->firstChild;
+ continue;
+ }
+
+ /* Destroy the window */
+ dmxBEDestroyWindow(pChild);
+
+ /* Make sure we destroy the window's border and background
+ * pixmaps if they exist */
+ if (!pChild->borderIsPixel) {
+ dmxBESavePixmap(pChild->border.pixmap);
+ dmxBEFreePixmap(pChild->border.pixmap);
+ }
+ if (pChild->backgroundState == BackgroundPixmap) {
+ dmxBESavePixmap(pChild->background.pixmap);
+ dmxBEFreePixmap(pChild->background.pixmap);
+ }
+
+ while (!pChild->nextSib && (pChild != pWin)) {
+ pChild = pChild->parent;
+ dmxBEDestroyWindow(pChild);
+ if (!pChild->borderIsPixel) {
+ dmxBESavePixmap(pChild->border.pixmap);
+ dmxBEFreePixmap(pChild->border.pixmap);
+ }
+ if (pChild->backgroundState == BackgroundPixmap) {
+ dmxBESavePixmap(pChild->background.pixmap);
+ dmxBEFreePixmap(pChild->background.pixmap);
+ }
+ }
+
+ if (pChild == pWin)
+ break;
+
+ pChild = pChild->nextSib;
+ }
+}
+
+/** Detach back-end screen. */
+int dmxDetachScreen(int idx)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ int i;
+
+ /* Return failure if dynamic addition/removal of screens is disabled */
+ if (!dmxAddRemoveScreens) {
+ dmxLog(dmxWarning,
+ "Attempting to remove a screen, but the AddRemoveScreen\n");
+ dmxLog(dmxWarning,
+ "extension has not been enabled. To enable this extension\n");
+ dmxLog(dmxWarning,
+ "add the \"-addremovescreens\" option either to the command\n");
+ dmxLog(dmxWarning,
+ "line or in the configuration file.\n");
+ return 1;
+ }
+
+ /* Cannot remove a screen that does not exist */
+ if (idx < 0 || idx >= dmxNumScreens) return 1;
+
+ /* Cannot detach from a screen that is not opened */
+ if (!dmxScreen->beDisplay) {
+ dmxLog(dmxWarning,
+ "Attempting to remove screen #%d but it has not been opened\n",
+ idx);
+ return 1;
+ }
+
+ dmxLogOutput(dmxScreen, "Detaching screen #%d\n", idx);
+
+ /* Detach input */
+ dmxInputDetachAll(dmxScreen);
+
+ /* Save all relevant state (TODO) */
+
+ /* Free all non-window resources related to this screen */
+ for (i = currentMaxClients; --i >= 0; )
+ if (clients[i])
+ FindAllClientResources(clients[i], dmxBEDestroyResources,
+ (pointer)idx);
+
+ /* Free scratch GCs */
+ dmxBEDestroyScratchGCs(idx);
+
+ /* Free window resources related to this screen */
+ dmxBEDestroyWindowTree(idx);
+
+ /* Free default stipple */
+ dmxBESavePixmap(screenInfo.screens[idx]->PixmapPerDepth[0]);
+ dmxBEFreePixmap(screenInfo.screens[idx]->PixmapPerDepth[0]);
+
+ /* Free the remaining screen resources and close the screen */
+ dmxBECloseScreen(screenInfo.screens[idx]);
+
+ /* Adjust the cursor boundaries (paints detached console window) */
+ dmxAdjustCursorBoundaries();
+
+ return 0; /* Success */
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxextension.h b/nx-X11/programs/Xserver/hw/dmx/dmxextension.h
new file mode 100644
index 000000000..3ea0b83ec
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxextension.h
@@ -0,0 +1,119 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Author:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for DMX extension support. These routines are called by
+ * function in Xserver/Xext/dmx.c. \see dmxextension.c */
+
+#ifndef _DMXEXTENSION_H_
+#define _DMXEXTENSION_H_
+
+/** Screen attributes. Used by #ProcDMXGetScreenAttributes and
+ * #ProcDMXChangeScreenAttributes. */
+typedef struct {
+ const char *displayName;
+ int logicalScreen;
+
+ unsigned int screenWindowWidth; /* displayName's coordinate system */
+ unsigned int screenWindowHeight; /* displayName's coordinate system */
+ int screenWindowXoffset; /* displayName's coordinate system */
+ int screenWindowYoffset; /* displayName's coordinate system */
+
+ unsigned int rootWindowWidth; /* screenWindow's coordinate system */
+ unsigned int rootWindowHeight; /* screenWindow's coordinate system */
+ int rootWindowXoffset; /* screenWindow's coordinate system */
+ int rootWindowYoffset; /* screenWindow's coordinate system */
+
+ int rootWindowXorigin; /* global coordinate system */
+ int rootWindowYorigin; /* global coordinate system */
+} DMXScreenAttributesRec, *DMXScreenAttributesPtr;
+
+/** Window attributes. Used by #ProcDMXGetWidowAttributes. */
+typedef struct {
+ int screen;
+ Window window;
+ xRectangle pos;
+ xRectangle vis;
+} DMXWindowAttributesRec, *DMXWindowAttributesPtr;
+
+/** Desktop attributes. Used by #ProcDMXGetDesktopAttributes and
+ * #ProcDMXChangeDesktopAttributes. */
+typedef struct {
+ int width;
+ int height;
+ int shiftX;
+ int shiftY;
+} DMXDesktopAttributesRec, *DMXDesktopAttributesPtr;
+
+/** Input attributes. Used by #ProcDMXGetInputAttributes. */
+typedef struct {
+ const char *name;
+ int inputType;
+ int physicalScreen;
+ int physicalId;
+ int isCore;
+ int sendsCore;
+ int detached;
+} DMXInputAttributesRec, *DMXInputAttributesPtr;
+
+
+extern unsigned long dmxGetNumScreens(void);
+extern void dmxForceWindowCreation(WindowPtr pWindow);
+extern void dmxFlushPendingSyncs(void);
+extern Bool dmxGetScreenAttributes(int physical,
+ DMXScreenAttributesPtr attr);
+extern Bool dmxGetWindowAttributes(WindowPtr pWindow,
+ DMXWindowAttributesPtr attr);
+extern void dmxGetDesktopAttributes(DMXDesktopAttributesPtr attr);
+extern int dmxGetInputCount(void);
+extern int dmxGetInputAttributes(int deviceId,
+ DMXInputAttributesPtr attr);
+extern int dmxAddInput(DMXInputAttributesPtr attr, int *deviceId);
+extern int dmxRemoveInput(int deviceId);
+
+extern int dmxConfigureScreenWindows(int nscreens,
+ CARD32 *screens,
+ DMXScreenAttributesPtr attribs,
+ int *errorScreen);
+
+extern int dmxConfigureDesktop(DMXDesktopAttributesPtr attribs);
+
+/* dmxUpdateScreenResources exposed for dmxCreateWindow in dmxwindow.c */
+extern void dmxUpdateScreenResources(ScreenPtr pScreen,
+ int x, int y, int w, int h);
+
+extern int dmxAttachScreen(int idx, DMXScreenAttributesPtr attr);
+extern int dmxDetachScreen(int idx);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxfont.c b/nx-X11/programs/Xserver/hw/dmx/dmxfont.c
new file mode 100644
index 000000000..3dba61de4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxfont.c
@@ -0,0 +1,559 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * This file provides support for fonts. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#define DMX_FONTPATH_DEBUG 0
+
+#include "dmx.h"
+#include "dmxsync.h"
+#include "dmxfont.h"
+#include "dmxlog.h"
+
+#include <X11/fonts/fontstruct.h>
+#include "dixfont.h"
+#include "dixstruct.h"
+
+static int (*dmxSaveProcVector[256])(ClientPtr);
+static int dmxFontLastError;
+
+static int dmxFontErrorHandler(Display *dpy, XErrorEvent *ev)
+{
+ dmxFontLastError = ev->error_code;
+
+ return 0;
+}
+
+static char **dmxGetFontPath(int *npaths)
+{
+ char **fp;
+ unsigned char *c, *paths;
+ char *newfp;
+ int len, l, i;
+
+ paths = GetFontPath(npaths, &len);
+
+ newfp = xalloc(*npaths + len);
+ c = (unsigned char *)newfp;
+ fp = xalloc(*npaths * sizeof(*fp));
+
+ memmove(newfp, paths+1, *npaths + len - 1);
+ l = *paths;
+ for (i = 0; i < *npaths; i++) {
+ fp[i] = (char *)c;
+ c += l;
+ l = *c;
+ *c++ = '\0';
+ }
+
+#if DMX_FONTPATH_DEBUG
+ for (i = 0; i < *npaths; i++)
+ dmxLog(dmxDebug, "FontPath[%d] = %s\n", i, fp[i]);
+#endif
+
+ return fp;
+}
+
+static void dmxFreeFontPath(char **fp)
+{
+ xfree(fp[0]);
+ xfree(fp);
+}
+
+static Bool dmxCheckFontPathElement(DMXScreenInfo *dmxScreen, char *fp)
+{
+ int (*oldErrorHandler)(Display *, XErrorEvent *);
+
+ if (!dmxScreen->beDisplay)
+ return TRUE;
+
+ dmxFontLastError = 0;
+ oldErrorHandler = XSetErrorHandler(dmxFontErrorHandler);
+ XSetFontPath(dmxScreen->beDisplay, &fp, 1);
+ dmxSync(dmxScreen, TRUE); /* Must complete before removing handler */
+ XSetErrorHandler(oldErrorHandler);
+
+ return (dmxFontLastError == 0);
+}
+
+static int dmxSetFontPath(DMXScreenInfo *dmxScreen)
+{
+ int (*oldErrorHandler)(Display *, XErrorEvent *);
+ char **fp;
+ int result = Success;
+ int npaths;
+
+ if (!dmxScreen->beDisplay)
+ return result;
+
+ fp = dmxGetFontPath(&npaths);
+ if (!fp) return BadAlloc;
+
+ dmxFontLastError = 0;
+ oldErrorHandler = XSetErrorHandler(dmxFontErrorHandler);
+ XSetFontPath(dmxScreen->beDisplay, fp, npaths);
+ dmxSync(dmxScreen, TRUE); /* Must complete before removing handler */
+ XSetErrorHandler(oldErrorHandler);
+
+ if (dmxFontLastError) {
+ result = dmxFontLastError;
+ /* We could set *error here to the offending path, but it is
+ * ignored, so we don't bother figuring out which path is bad.
+ * If we do add this support in the future, we'll need to add
+ * error to the function's argument list.
+ */
+ }
+
+ dmxFreeFontPath(fp);
+
+ return result;
+}
+
+static int dmxCheckFontPath(DMXScreenInfo *dmxScreen, int *error)
+{
+ char **oldFontPath;
+ int nOldPaths;
+ int result = Success;
+
+ if (!dmxScreen->beDisplay)
+ return result;
+
+ /* Save old font path */
+ oldFontPath = XGetFontPath(dmxScreen->beDisplay, &nOldPaths);
+
+ result = dmxSetFontPath(dmxScreen);
+
+ /* Restore old font path */
+ XSetFontPath(dmxScreen->beDisplay, oldFontPath, nOldPaths);
+ XFreeFontPath(oldFontPath);
+ dmxSync(dmxScreen, FALSE);
+
+ return result;
+}
+
+static int dmxProcSetFontPath(ClientPtr client)
+{
+ unsigned char *ptr;
+ unsigned long nbytes, total, n;
+ long nfonts;
+ int i, result;
+ int error;
+ unsigned char *oldFontPath, *tmpFontPath;
+ int nOldPaths;
+ int lenOldPaths;
+ REQUEST(xSetFontPathReq);
+
+ REQUEST_AT_LEAST_SIZE(xSetFontPathReq);
+
+ nbytes = (client->req_len << 2) - sizeof(xSetFontPathReq);
+ total = nbytes;
+ ptr = (unsigned char *)&stuff[1];
+ nfonts = stuff->nFonts;
+
+ while (--nfonts >= 0) {
+ if ((total == 0) || (total < (n = (*ptr + 1))))
+ return BadLength;
+ total -= n;
+ ptr += n;
+ }
+ if (total >= 4)
+ return BadLength;
+
+ tmpFontPath = GetFontPath(&nOldPaths, &lenOldPaths);
+ oldFontPath = xalloc(nOldPaths + lenOldPaths);
+ memmove(oldFontPath, tmpFontPath, nOldPaths + lenOldPaths);
+
+ result = SetFontPath(client, stuff->nFonts, (unsigned char *)&stuff[1],
+ &error);
+ if (!result) {
+ for (i = 0; i < dmxNumScreens; i++)
+ if ((result = dmxCheckFontPath(&dmxScreens[i], &error)))
+ break;
+
+ if (result) {
+ int ignoreresult, ignoreerror;
+
+ /* Restore old fontpath in the DMX server */
+ ignoreresult = SetFontPath(client, nOldPaths, oldFontPath,
+ &ignoreerror);
+ } else {
+ result = client->noClientException;
+ client->errorValue = error;
+ }
+ }
+
+ xfree(oldFontPath);
+ return result;
+}
+
+/** Initialize font support. In addition to the screen function call
+ * pointers, DMX also hooks in at the ProcVector[] level. Here the old
+ * ProcVector function pointers are saved and the new ProcVector
+ * function pointers are initialized. */
+void dmxInitFonts(void)
+{
+ int i;
+
+ for (i = 0; i < 256; i++)
+ dmxSaveProcVector[i] = ProcVector[i];
+
+ ProcVector[X_SetFontPath] = dmxProcSetFontPath;
+}
+
+/** Reset font support by restoring the original ProcVector function
+ * pointers. */
+void dmxResetFonts(void)
+{
+ int i;
+
+ for (i = 0; i < 256; i++)
+ ProcVector[i] = dmxSaveProcVector[i];
+}
+
+/** Load the font, \a pFont, on the back-end server associated with \a
+ * pScreen. When a font is loaded, the font path on back-end server is
+ * first initialized to that specified on the command line with the
+ * -fontpath options, and then the font is loaded. */
+Bool dmxBELoadFont(ScreenPtr pScreen, FontPtr pFont)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxFontPrivPtr pFontPriv = FontGetPrivate(pFont, dmxFontPrivateIndex);
+ char *name;
+ char **oldFontPath = NULL;
+ int nOldPaths;
+ Atom name_atom, value_atom;
+ int i;
+
+ /* Make sure we have a font private struct to work with */
+ if (!pFontPriv)
+ return FALSE;
+
+ /* Don't load a font over top of itself */
+ if (pFontPriv->font[pScreen->myNum]) {
+ return TRUE; /* Already loaded font */
+ }
+
+ /* Save old font path */
+ oldFontPath = XGetFontPath(dmxScreen->beDisplay, &nOldPaths);
+
+ /* Set the font path for the font about to be loaded on the back-end */
+ if (dmxSetFontPath(dmxScreen)) {
+ char **fp;
+ int npaths;
+ Bool *goodfps;
+
+ /* This could fail only when first starting the X server and
+ * loading the default font. If it fails here, then the default
+ * font path is invalid, no default font path will be set, the
+ * DMX server will fail to load the default font, and it will
+ * exit with an error unless we remove the offending font paths
+ * with the -ignorebadfontpaths command line option.
+ */
+
+ fp = dmxGetFontPath(&npaths);
+ if (!fp) {
+ dmxLog(dmxError,
+ "No default font path set.\n");
+ dmxLog(dmxError,
+ "Please see the Xdmx man page for information on how to\n");
+ dmxLog(dmxError,
+ "initialize the DMX server's default font path.\n");
+ XFreeFontPath(oldFontPath);
+ return FALSE;
+ }
+
+ if (!dmxFontPath)
+ dmxLog(dmxWarning, "No default font path is set.\n");
+
+ goodfps = xalloc(npaths * sizeof(*goodfps));
+
+ dmxLog(dmxError,
+ "The DMX server failed to set the following font paths on "
+ "screen #%d:\n", pScreen->myNum);
+
+ for (i = 0; i < npaths; i++)
+ if (!(goodfps[i] = dmxCheckFontPathElement(dmxScreen, fp[i])))
+ dmxLog(dmxError, " %s\n", fp[i]);
+
+ if (dmxIgnoreBadFontPaths) {
+ char *newfp;
+ int newnpaths = 0;
+ int len = 0;
+ int j = 0;
+ int error;
+
+ dmxLog(dmxError,
+ "These font paths will not be used because the "
+ "\"-ignorebadfontpaths\"\n");
+ dmxLog(dmxError,
+ "option is set.\n");
+
+ for (i = 0; i < npaths; i++)
+ if (goodfps[i]) {
+ len += strlen(fp[i]) + 1;
+ newnpaths++;
+ }
+
+ if (!newnpaths) {
+ /* No valid font paths were found */
+ dmxLog(dmxError,
+ "After removing the font paths above, no valid font "
+ "paths were\n");
+ dmxLog(dmxError,
+ "available. Please check that the font paths set on "
+ "the command\n");
+ dmxLog(dmxError,
+ "line or in the configuration file via the "
+ "\"-fontpath\" option\n");
+ dmxLog(dmxError,
+ "are valid on all back-end servers. See the Xdmx man "
+ "page for\n");
+ dmxLog(dmxError,
+ "more information on font paths.\n");
+ dmxFreeFontPath(fp);
+ XFreeFontPath(oldFontPath);
+ xfree(goodfps);
+ return FALSE;
+ }
+
+ newfp = xalloc(len * sizeof(*newfp));
+ for (i = 0; i < npaths; i++) {
+ if (goodfps[i]) {
+ int n = strlen(fp[i]);
+ newfp[j++] = n;
+ strncpy(&newfp[j], fp[i], n);
+ j += n;
+ }
+ }
+
+ if (SetFontPath(NULL, newnpaths, (unsigned char *)newfp, &error)) {
+ /* Note that this should never happen since all of the
+ * FPEs were previously valid. */
+ dmxLog(dmxError, "Cannot reset the default font path.\n");
+ }
+ } else if (dmxFontPath) {
+ dmxLog(dmxError,
+ "Please remove these font paths from the command line "
+ "or\n");
+ dmxLog(dmxError,
+ "configuration file, or set the \"-ignorebadfontpaths\" "
+ "option to\n");
+ dmxLog(dmxError,
+ "ignore them. For more information on these options, see "
+ "the\n");
+ dmxLog(dmxError,
+ "Xdmx man page.\n");
+ } else {
+ dmxLog(dmxError,
+ "Please specify the font paths that are available on all "
+ "back-end\n");
+ dmxLog(dmxError,
+ "servers with the \"-fontpath\" option, or use the "
+ "\"-ignorebadfontpaths\"\n");
+ dmxLog(dmxError,
+ "to ignore bad defaults. For more information on "
+ "these and other\n");
+ dmxLog(dmxError,
+ "font-path-related options, see the Xdmx man page.\n");
+ }
+
+ if (!dmxIgnoreBadFontPaths ||
+ (dmxIgnoreBadFontPaths && dmxSetFontPath(dmxScreen))) {
+ /* We still have errors so return with error */
+ dmxFreeFontPath(fp);
+ XFreeFontPath(oldFontPath);
+ xfree(goodfps);
+ return FALSE;
+ }
+ }
+
+ /* Find requested font on back-end server */
+ name_atom = MakeAtom("FONT", 4, TRUE);
+ value_atom = 0L;
+
+ for (i = 0; i < pFont->info.nprops; i++) {
+ if ((Atom)pFont->info.props[i].name == name_atom) {
+ value_atom = pFont->info.props[i].value;
+ break;
+ }
+ }
+ if (!value_atom) return FALSE;
+
+ name = (char *)NameForAtom(value_atom);
+ if (!name) return FALSE;
+
+ pFontPriv->font[pScreen->myNum] =
+ XLoadQueryFont(dmxScreen->beDisplay, name);
+
+ /* Restore old font path */
+ XSetFontPath(dmxScreen->beDisplay, oldFontPath, nOldPaths);
+ XFreeFontPath(oldFontPath);
+ dmxSync(dmxScreen, FALSE);
+
+ if (!pFontPriv->font[pScreen->myNum]) return FALSE;
+
+ return TRUE;
+}
+
+/** Realize the font, \a pFont, on the back-end server associated with
+ * \a pScreen. */
+Bool dmxRealizeFont(ScreenPtr pScreen, FontPtr pFont)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxFontPrivPtr pFontPriv;
+
+ if (!(pFontPriv = FontGetPrivate(pFont, dmxFontPrivateIndex))) {
+ FontSetPrivate(pFont, dmxFontPrivateIndex, NULL);
+ pFontPriv = xalloc(sizeof(dmxFontPrivRec));
+ if (!pFontPriv) return FALSE;
+ pFontPriv->font = NULL;
+ MAXSCREENSALLOC(pFontPriv->font);
+ if (!pFontPriv->font) {
+ xfree(pFontPriv);
+ return FALSE;
+ }
+ pFontPriv->refcnt = 0;
+ }
+
+ FontSetPrivate(pFont, dmxFontPrivateIndex, (pointer)pFontPriv);
+
+ if (dmxScreen->beDisplay) {
+ if (!dmxBELoadFont(pScreen, pFont))
+ return FALSE;
+
+ pFontPriv->refcnt++;
+ } else {
+ pFontPriv->font[pScreen->myNum] = NULL;
+ }
+
+ return TRUE;
+}
+
+/** Free \a pFont on the back-end associated with \a pScreen. */
+Bool dmxBEFreeFont(ScreenPtr pScreen, FontPtr pFont)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxFontPrivPtr pFontPriv = FontGetPrivate(pFont, dmxFontPrivateIndex);
+
+ if (pFontPriv && pFontPriv->font[pScreen->myNum]) {
+ XFreeFont(dmxScreen->beDisplay, pFontPriv->font[pScreen->myNum]);
+ pFontPriv->font[pScreen->myNum] = NULL;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/** Unrealize the font, \a pFont, on the back-end server associated with
+ * \a pScreen. */
+Bool dmxUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxFontPrivPtr pFontPriv;
+
+ if ((pFontPriv = FontGetPrivate(pFont, dmxFontPrivateIndex))) {
+ /* In case the font failed to load properly */
+ if (!pFontPriv->refcnt) {
+ MAXSCREENSFREE(pFontPriv->font);
+ xfree(pFontPriv);
+ FontSetPrivate(pFont, dmxFontPrivateIndex, NULL);
+ } else if (pFontPriv->font[pScreen->myNum]) {
+ if (dmxScreen->beDisplay)
+ dmxBEFreeFont(pScreen, pFont);
+
+ /* The code below is non-obvious, so here's an explanation...
+ *
+ * When creating the default GC, the server opens up the
+ * default font once for each screen, which in turn calls
+ * the RealizeFont function pointer once for each screen.
+ * During this process both dix's font refcnt and DMX's font
+ * refcnt are incremented once for each screen.
+ *
+ * Later, when shutting down the X server, dix shuts down
+ * each screen in reverse order. During this shutdown
+ * procedure, each screen's default GC is freed and then
+ * that screen is closed by calling the CloseScreen function
+ * pointer. screenInfo.numScreens is then decremented after
+ * closing each screen. This procedure means that the dix's
+ * font refcnt for the font used by the default GC's is
+ * decremented once for each screen # greater than 0.
+ * However, since dix's refcnt for the default font is not
+ * yet 0 for each screen greater than 0, no call to the
+ * UnrealizeFont function pointer is made for those screens.
+ * Then, when screen 0 is being closed, dix's font refcnt
+ * for the default GC's font is finally 0 and the font is
+ * unrealized. However, since screenInfo.numScreens has
+ * been decremented already down to 1, only one call to
+ * UnrealizeFont is made (for screen 0). Thus, even though
+ * RealizeFont was called once for each screen,
+ * UnrealizeFont is only called for screen 0.
+ *
+ * This is a bug in dix.
+ *
+ * To avoid the memory leak of pFontPriv for each server
+ * generation, we can also free pFontPriv if the refcnt is
+ * not yet 0 but the # of screens is 1 -- i.e., the case
+ * described in the dix bug above. This is only a temporary
+ * workaround until the bug in dix is solved.
+ *
+ * The other problem is that the font structure allocated by
+ * XLoadQueryFont() above is not freed for screens > 0.
+ * This problem cannot be worked around here since the back-
+ * end displays for screens > 0 have already been closed by
+ * the time this code is called from dix.
+ *
+ * When the bug in dix described above is fixed, then we can
+ * remove the "|| screenInfo.numScreens == 1" code below and
+ * the memory leaks will be eliminated.
+ */
+ if (--pFontPriv->refcnt == 0
+#if 1
+ /* Remove this code when the dix bug is fixed */
+ || screenInfo.numScreens == 1
+#endif
+ ) {
+ MAXSCREENSFREE(pFontPriv->font);
+ xfree(pFontPriv);
+ FontSetPrivate(pFont, dmxFontPrivateIndex, NULL);
+ }
+ }
+ }
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxfont.h b/nx-X11/programs/Xserver/hw/dmx/dmxfont.h
new file mode 100644
index 000000000..f69aac196
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxfont.h
@@ -0,0 +1,60 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for font-related functions. \see dmxfont.c */
+
+#ifndef DMXFONT_H
+#define DMXFONT_H
+
+#include <X11/fonts/fontstruct.h>
+
+/** Font private area. */
+typedef struct _dmxFontPriv {
+ int refcnt;
+ XFontStruct **font;
+} dmxFontPrivRec, *dmxFontPrivPtr;
+
+extern void dmxInitFonts(void);
+extern void dmxResetFonts(void);
+
+extern Bool dmxRealizeFont(ScreenPtr pScreen, FontPtr pFont);
+extern Bool dmxUnrealizeFont(ScreenPtr pScreen, FontPtr pFont);
+
+extern Bool dmxBELoadFont(ScreenPtr pScreen, FontPtr pFont);
+extern Bool dmxBEFreeFont(ScreenPtr pScreen, FontPtr pFont);
+
+extern int dmxFontPrivateIndex;
+
+#endif /* DMXFONT_H */
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxgc.c b/nx-X11/programs/Xserver/hw/dmx/dmxgc.c
new file mode 100644
index 000000000..d17b05164
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxgc.c
@@ -0,0 +1,424 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * This file provides support for GCs. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxsync.h"
+#include "dmxgc.h"
+#include "dmxgcops.h"
+#include "dmxpixmap.h"
+#include "dmxfont.h"
+
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "migc.h"
+
+static GCFuncs dmxGCFuncs = {
+ dmxValidateGC,
+ dmxChangeGC,
+ dmxCopyGC,
+ dmxDestroyGC,
+ dmxChangeClip,
+ dmxDestroyClip,
+ dmxCopyClip,
+};
+
+static GCOps dmxGCOps = {
+ dmxFillSpans,
+ dmxSetSpans,
+ dmxPutImage,
+ dmxCopyArea,
+ dmxCopyPlane,
+ dmxPolyPoint,
+ dmxPolylines,
+ dmxPolySegment,
+ dmxPolyRectangle,
+ dmxPolyArc,
+ dmxFillPolygon,
+ dmxPolyFillRect,
+ dmxPolyFillArc,
+ dmxPolyText8,
+ dmxPolyText16,
+ dmxImageText8,
+ dmxImageText16,
+ dmxImageGlyphBlt,
+ dmxPolyGlyphBlt,
+ dmxPushPixels
+};
+
+/** Initialize the GC on \a pScreen, which currently involves allocating
+ * the GC private associated with this screen. */
+Bool dmxInitGC(ScreenPtr pScreen)
+{
+ if (!AllocateGCPrivate(pScreen, dmxGCPrivateIndex, sizeof(dmxGCPrivRec)))
+ return FALSE;
+
+ return TRUE;
+}
+
+/** Create the GC on the back-end server. */
+void dmxBECreateGC(ScreenPtr pScreen, GCPtr pGC)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ int i;
+
+ for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) {
+ if (pGC->depth == dmxScreen->bePixmapFormats[i].depth) {
+ unsigned long mask;
+ XGCValues gcvals;
+
+ mask = GCGraphicsExposures;
+ gcvals.graphics_exposures = FALSE;
+
+ /* Create GC in the back-end servers */
+ pGCPriv->gc = XCreateGC(dmxScreen->beDisplay,
+ dmxScreen->scrnDefDrawables[i],
+ mask, &gcvals);
+ break;
+ }
+ }
+}
+
+/** Create a graphics context on the back-end server associated /a pGC's
+ * screen. */
+Bool dmxCreateGC(GCPtr pGC)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Bool ret;
+
+ DMX_UNWRAP(CreateGC, dmxScreen, pScreen);
+ if ((ret = pScreen->CreateGC(pGC))) {
+ /* Save the old funcs */
+ pGCPriv->funcs = pGC->funcs;
+ pGCPriv->ops = NULL;
+
+ pGC->funcs = &dmxGCFuncs;
+
+ if (dmxScreen->beDisplay) {
+ dmxBECreateGC(pScreen, pGC);
+ } else {
+ pGCPriv->gc = NULL;
+ }
+
+ /* Check for "magic special case"
+ * 1. see CreateGC in dix/gc.c for more info
+ * 2. see dmxChangeGC for more info
+ */
+ pGCPriv->msc = (!pGC->tileIsPixel && !pGC->tile.pixmap);
+ }
+ DMX_WRAP(CreateGC, dmxCreateGC, dmxScreen, pScreen);
+
+ return ret;
+}
+
+/** Validate a graphics context, \a pGC, locally in the DMX server and
+ * recompute the composite clip, if necessary. */
+void dmxValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
+{
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+
+ DMX_GC_FUNC_PROLOGUE(pGC);
+#if 0
+ pGC->funcs->ValidateGC(pGC, changes, pDrawable);
+#endif
+
+ if (pDrawable->type == DRAWABLE_WINDOW ||
+ pDrawable->type == DRAWABLE_PIXMAP) {
+ /* Save the old ops, since we're about to change the ops in the
+ * epilogue.
+ */
+ pGCPriv->ops = pGC->ops;
+ } else {
+ pGCPriv->ops = NULL;
+ }
+
+ /* If the client clip is different or moved OR the subwindowMode has
+ * changed OR the window's clip has changed since the last
+ * validation, then we need to recompute the composite clip.
+ */
+ if ((changes & (GCClipXOrigin |
+ GCClipYOrigin |
+ GCClipMask |
+ GCSubwindowMode)) ||
+ (pDrawable->serialNumber !=
+ (pGC->serialNumber & DRAWABLE_SERIAL_BITS))) {
+ miComputeCompositeClip(pGC, pDrawable);
+ }
+
+ DMX_GC_FUNC_EPILOGUE(pGC);
+}
+
+/** Set the values in the graphics context on the back-end server
+ * associated with \a pGC's screen. */
+void dmxChangeGC(GCPtr pGC, unsigned long mask)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ XGCValues v;
+
+ DMX_GC_FUNC_PROLOGUE(pGC);
+#if 0
+ pGC->funcs->ChangeGC(pGC, mask);
+#endif
+
+ /* Handle "magic special case" from CreateGC */
+ if (pGCPriv->msc) {
+ /* The "magic special case" is used to handle the case where a
+ * foreground pixel is set when the GC is created so that a
+ * "pseudo default-tile" can be created and used in case the
+ * fillstyle was set to FillTiled. This specific case is tested
+ * in xtest (XCreateGC test #3). What has happened in dix by
+ * the time it reaches here is (1) the pGC->tile.pixel has been
+ * set to pGC->fgPixel and pGC->tileIsPixel is set, (2) if a
+ * tile has also been set, then pGC->tileIsPixel is unset and
+ * pGC->tile.pixmap is initialized; else, the default tile is
+ * created and pGC->tileIsPixel is unset and pGC->tile.pixmap is
+ * initialized to the "pseudo default-tile". In either case,
+ * pGC->tile.pixmap is set; however, in the "magic special case"
+ * the mask is not updated to allow us to detect that we should
+ * initialize the GCTile in the back-end server. Thus, we catch
+ * this case in dmxCreateGC and add GCTile to the mask here.
+ * Are there any cases that I've missed?
+ */
+
+ /* Make sure that the tile.pixmap is set, just in case the user
+ * set GCTile in the mask but forgot to set vals.pixmap
+ */
+ if (pGC->tile.pixmap) mask |= GCTile;
+
+ /* This only happens once when the GC is created */
+ pGCPriv->msc = FALSE;
+ }
+
+ /* Update back-end server's gc */
+ if (mask & GCFunction) v.function = pGC->alu;
+ if (mask & GCPlaneMask) v.plane_mask = pGC->planemask;
+ if (mask & GCForeground) v.foreground = pGC->fgPixel;
+ if (mask & GCBackground) v.background = pGC->bgPixel;
+ if (mask & GCLineWidth) v.line_width = pGC->lineWidth;
+ if (mask & GCLineStyle) v.line_style = pGC->lineStyle;
+ if (mask & GCCapStyle) v.cap_style = pGC->capStyle;
+ if (mask & GCJoinStyle) v.join_style = pGC->joinStyle;
+ if (mask & GCFillStyle) v.fill_style = pGC->fillStyle;
+ if (mask & GCFillRule) v.fill_rule = pGC->fillRule;
+ if (mask & GCTile) {
+ if (pGC->tileIsPixel) {
+ mask &= ~GCTile;
+ } else {
+ dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pGC->tile.pixmap);
+ v.tile = (Drawable)pPixPriv->pixmap;
+ }
+ }
+ if (mask & GCStipple) {
+ dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pGC->stipple);
+ v.stipple = (Drawable)pPixPriv->pixmap;
+ }
+ if (mask & GCTileStipXOrigin) v.ts_x_origin = pGC->patOrg.x;
+ if (mask & GCTileStipYOrigin) v.ts_y_origin = pGC->patOrg.y;
+ if (mask & GCFont) {
+ if (dmxScreen->beDisplay) {
+ dmxFontPrivPtr pFontPriv;
+ pFontPriv = FontGetPrivate(pGC->font, dmxFontPrivateIndex);
+ v.font = pFontPriv->font[pScreen->myNum]->fid;
+ } else {
+ mask &= ~GCFont;
+ }
+ }
+ if (mask & GCSubwindowMode) v.subwindow_mode = pGC->subWindowMode;
+
+ /* Graphics exposures are not needed on the back-ends since they can
+ be generated on the front-end thereby saving bandwidth. */
+ if (mask & GCGraphicsExposures) mask &= ~GCGraphicsExposures;
+
+ if (mask & GCClipXOrigin) v.clip_x_origin = pGC->clipOrg.x;
+ if (mask & GCClipYOrigin) v.clip_y_origin = pGC->clipOrg.y;
+ if (mask & GCClipMask) mask &= ~GCClipMask; /* See ChangeClip */
+ if (mask & GCDashOffset) v.dash_offset = pGC->dashOffset;
+ if (mask & GCDashList) {
+ mask &= ~GCDashList;
+ if (dmxScreen->beDisplay)
+ XSetDashes(dmxScreen->beDisplay, pGCPriv->gc,
+ pGC->dashOffset, (char *)pGC->dash,
+ pGC->numInDashList);
+ }
+ if (mask & GCArcMode) v.arc_mode = pGC->arcMode;
+
+ if (mask && dmxScreen->beDisplay) {
+ XChangeGC(dmxScreen->beDisplay, pGCPriv->gc, mask, &v);
+ dmxSync(dmxScreen, FALSE);
+ }
+
+ DMX_GC_FUNC_EPILOGUE(pGC);
+}
+
+/** Copy \a pGCSrc to \a pGCDst on the back-end server associated with
+ * \a pGCSrc's screen. */
+void dmxCopyGC(GCPtr pGCSrc, unsigned long changes, GCPtr pGCDst)
+{
+ ScreenPtr pScreen = pGCSrc->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxGCPrivPtr pGCSrcPriv = DMX_GET_GC_PRIV(pGCSrc);
+ dmxGCPrivPtr pGCDstPriv = DMX_GET_GC_PRIV(pGCDst);
+
+ DMX_GC_FUNC_PROLOGUE(pGCDst);
+ pGCDst->funcs->CopyGC(pGCSrc, changes, pGCDst);
+
+ /* Copy the GC on the back-end server */
+ if (dmxScreen->beDisplay)
+ XCopyGC(dmxScreen->beDisplay, pGCSrcPriv->gc, changes, pGCDstPriv->gc);
+
+ DMX_GC_FUNC_EPILOGUE(pGCDst);
+}
+
+/** Free the \a pGC on the back-end server. */
+Bool dmxBEFreeGC(GCPtr pGC)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+
+ if (pGCPriv->gc) {
+ XFreeGC(dmxScreen->beDisplay, pGCPriv->gc);
+ pGCPriv->gc = NULL;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/** Destroy the graphics context, \a pGC and free the corresponding GC
+ * on the back-end server. */
+void dmxDestroyGC(GCPtr pGC)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+
+ DMX_GC_FUNC_PROLOGUE(pGC);
+
+ /* Free the GC on the back-end server */
+ if (dmxScreen->beDisplay)
+ dmxBEFreeGC(pGC);
+
+ pGC->funcs->DestroyGC(pGC);
+ DMX_GC_FUNC_EPILOGUE(pGC);
+}
+
+/** Change the clip rects for a GC. */
+void dmxChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ XRectangle *pRects;
+ BoxPtr pBox;
+ int i, nRects;
+
+ DMX_GC_FUNC_PROLOGUE(pGC);
+ pGC->funcs->ChangeClip(pGC, type, pvalue, nrects);
+
+ /* Set the client clip on the back-end server */
+ switch (pGC->clientClipType) {
+ case CT_NONE:
+ if (dmxScreen->beDisplay)
+ XSetClipMask(dmxScreen->beDisplay, pGCPriv->gc, None);
+ break;
+
+ case CT_REGION:
+ if (dmxScreen->beDisplay) {
+ nRects = REGION_NUM_RECTS((RegionPtr)pGC->clientClip);
+ pRects = xalloc(nRects * sizeof(*pRects));
+ pBox = REGION_RECTS((RegionPtr)pGC->clientClip);
+
+ for (i = 0; i < nRects; i++) {
+ pRects[i].x = pBox[i].x1;
+ pRects[i].y = pBox[i].y1;
+ pRects[i].width = pBox[i].x2 - pBox[i].x1;
+ pRects[i].height = pBox[i].y2 - pBox[i].y1;
+ }
+
+ XSetClipRectangles(dmxScreen->beDisplay, pGCPriv->gc,
+ pGC->clipOrg.x, pGC->clipOrg.y,
+ pRects, nRects, Unsorted);
+
+ xfree(pRects);
+ }
+ break;
+
+ case CT_PIXMAP:
+ case CT_UNSORTED:
+ case CT_YSORTED:
+ case CT_YXSORTED:
+ case CT_YXBANDED:
+ /* These clip types are condensed down to either NONE or REGION
+ in the mi code */
+ break;
+ }
+
+ DMX_GC_FUNC_EPILOGUE(pGC);
+}
+
+/** Destroy a GC's clip rects. */
+void dmxDestroyClip(GCPtr pGC)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+
+ DMX_GC_FUNC_PROLOGUE(pGC);
+ pGC->funcs->DestroyClip(pGC);
+
+ /* Set the client clip on the back-end server to None */
+ if (dmxScreen->beDisplay)
+ XSetClipMask(dmxScreen->beDisplay, pGCPriv->gc, None);
+
+ DMX_GC_FUNC_EPILOGUE(pGC);
+}
+
+/** Copy a GC's clip rects. */
+void dmxCopyClip(GCPtr pGCDst, GCPtr pGCSrc)
+{
+ DMX_GC_FUNC_PROLOGUE(pGCDst);
+ pGCDst->funcs->CopyClip(pGCDst, pGCSrc);
+ DMX_GC_FUNC_EPILOGUE(pGCDst);
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxgc.h b/nx-X11/programs/Xserver/hw/dmx/dmxgc.h
new file mode 100644
index 000000000..5f54d7dc9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxgc.h
@@ -0,0 +1,90 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for GC support. \see dmxgc.c */
+
+#ifndef DMXGC_H
+#define DMXGC_H
+
+#include "gcstruct.h"
+
+/** GC private area. */
+typedef struct _dmxGCPriv {
+ GCOps *ops;
+ GCFuncs *funcs;
+ XlibGC gc;
+ Bool msc;
+} dmxGCPrivRec, *dmxGCPrivPtr;
+
+
+extern Bool dmxInitGC(ScreenPtr pScreen);
+
+extern Bool dmxCreateGC(GCPtr pGC);
+extern void dmxValidateGC(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDrawable);
+extern void dmxChangeGC(GCPtr pGC, unsigned long mask);
+extern void dmxCopyGC(GCPtr pGCSrc, unsigned long changes, GCPtr pGCDst);
+extern void dmxDestroyGC(GCPtr pGC);
+extern void dmxChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects);
+extern void dmxDestroyClip(GCPtr pGC);
+extern void dmxCopyClip(GCPtr pGCDst, GCPtr pGCSrc);
+
+extern void dmxBECreateGC(ScreenPtr pScreen, GCPtr pGC);
+extern Bool dmxBEFreeGC(GCPtr pGC);
+
+/** Private index. \see dmxgc.c \see dmxscrinit.c */
+extern int dmxGCPrivateIndex;
+
+/** Get private. */
+#define DMX_GET_GC_PRIV(_pGC) \
+ (dmxGCPrivPtr)(_pGC)->devPrivates[dmxGCPrivateIndex].ptr
+
+#define DMX_GC_FUNC_PROLOGUE(_pGC) \
+do { \
+ dmxGCPrivPtr _pGCPriv = DMX_GET_GC_PRIV(_pGC); \
+ DMX_UNWRAP(funcs, _pGCPriv, (_pGC)); \
+ if (_pGCPriv->ops) \
+ DMX_UNWRAP(ops, _pGCPriv, (_pGC)); \
+} while (0)
+
+#define DMX_GC_FUNC_EPILOGUE(_pGC) \
+do { \
+ dmxGCPrivPtr _pGCPriv = DMX_GET_GC_PRIV(_pGC); \
+ DMX_WRAP(funcs, &dmxGCFuncs, _pGCPriv, (_pGC)); \
+ if (_pGCPriv->ops) \
+ DMX_WRAP(ops, &dmxGCOps, _pGCPriv, (_pGC)); \
+} while (0)
+
+#endif /* DMXGC_H */
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxgcops.c b/nx-X11/programs/Xserver/hw/dmx/dmxgcops.c
new file mode 100644
index 000000000..75d9dfb73
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxgcops.c
@@ -0,0 +1,602 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * This file provides support for GC operations. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxsync.h"
+#include "dmxgc.h"
+#include "dmxgcops.h"
+#include "dmxwindow.h"
+#include "dmxpixmap.h"
+
+#include "mi.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "dixfontstr.h"
+
+#include "panoramiXsrv.h"
+
+#define DMX_GCOPS_SET_DRAWABLE(_pDraw, _draw) \
+do { \
+ if ((_pDraw)->type == DRAWABLE_WINDOW) { \
+ dmxWinPrivPtr pWinPriv = \
+ DMX_GET_WINDOW_PRIV((WindowPtr)(_pDraw)); \
+ (_draw) = (Drawable)pWinPriv->window; \
+ } else { \
+ dmxPixPrivPtr pPixPriv = \
+ DMX_GET_PIXMAP_PRIV((PixmapPtr)(_pDraw)); \
+ (_draw) = (Drawable)pPixPriv->pixmap; \
+ } \
+} while (0)
+
+#define DMX_GCOPS_OFFSCREEN(_pDraw) \
+ (!dmxScreens[(_pDraw)->pScreen->myNum].beDisplay || \
+ (dmxOffScreenOpt && \
+ (_pDraw)->type == DRAWABLE_WINDOW && \
+ (DMX_GET_WINDOW_PRIV((WindowPtr)(_pDraw))->offscreen || \
+ !DMX_GET_WINDOW_PRIV((WindowPtr)(_pDraw))->window)))
+
+/** Fill spans -- this function should never be called. */
+void dmxFillSpans(DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit, int *pwidthInit,
+ int fSorted)
+{
+ /* Error -- this should never happen! */
+}
+
+/** Set spans -- this function should never be called. */
+void dmxSetSpans(DrawablePtr pDrawable, GCPtr pGC,
+ char *psrc, DDXPointPtr ppt, int *pwidth, int nspans,
+ int fSorted)
+{
+ /* Error -- this should never happen! */
+}
+
+/** Transfer \a pBits image to back-end server associated with \a
+ * pDrawable's screen. If primitive subdivision optimization is
+ * enabled, then only transfer the sections of \a pBits that are
+ * visible (i.e., not-clipped) to the back-end server. */
+void dmxPutImage(DrawablePtr pDrawable, GCPtr pGC,
+ int depth, int x, int y, int w, int h,
+ int leftPad, int format, char *pBits)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ XImage *img;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ img = XCreateImage(dmxScreen->beDisplay,
+ dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual,
+ depth, format, leftPad, pBits, w, h,
+ BitmapPad(dmxScreen->beDisplay),
+ (format == ZPixmap) ?
+ PixmapBytePad(w, depth) : BitmapBytePad(w+leftPad));
+
+ if (img) {
+ Drawable draw;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ if (dmxSubdividePrimitives && pGC->pCompositeClip) {
+ RegionPtr pSubImages;
+ RegionPtr pClip;
+ BoxRec box;
+ BoxPtr pBox;
+ int nBox;
+
+ box.x1 = x;
+ box.y1 = y;
+ box.x2 = x + w;
+ box.y2 = y + h;
+ pSubImages = REGION_CREATE(pGC->pScreen, &box, 1);
+
+ pClip = REGION_CREATE(pGC->pScreen, NullBox, 1);
+ REGION_COPY(pGC->pScreen, pClip, pGC->pCompositeClip);
+ REGION_TRANSLATE(pGC->pScreen, pClip,
+ -pDrawable->x, -pDrawable->y);
+ REGION_INTERSECT(pGC->pScreen, pSubImages, pSubImages, pClip);
+
+ nBox = REGION_NUM_RECTS(pSubImages);
+ pBox = REGION_RECTS(pSubImages);
+
+ while (nBox--) {
+ XPutImage(dmxScreen->beDisplay, draw, pGCPriv->gc, img,
+ pBox->x1 - box.x1,
+ pBox->y1 - box.y1,
+ pBox->x1,
+ pBox->y1,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1);
+ pBox++;
+ }
+ REGION_DESTROY(pGC->pScreen, pClip);
+ REGION_DESTROY(pGC->pScreen, pSubImages);
+ } else {
+ XPutImage(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ img, 0, 0, x, y, w, h);
+ }
+ XFree(img); /* Use XFree instead of XDestroyImage
+ * because pBits is passed in from the
+ * caller. */
+
+ dmxSync(dmxScreen, FALSE);
+ } else {
+ /* Error -- this should not happen! */
+ }
+}
+
+/** Copy area from \a pSrc drawable to \a pDst drawable on the back-end
+ * server associated with \a pSrc drawable's screen. If the offscreen
+ * optimization is enabled, only copy when both \a pSrc and \a pDst are
+ * at least partially visible. */
+RegionPtr dmxCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h, int dstx, int dsty)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pSrc->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable srcDraw, dstDraw;
+
+ if (DMX_GCOPS_OFFSCREEN(pSrc) || DMX_GCOPS_OFFSCREEN(pDst))
+ return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, w, h,
+ dstx, dsty, 0L);
+
+ DMX_GCOPS_SET_DRAWABLE(pSrc, srcDraw);
+ DMX_GCOPS_SET_DRAWABLE(pDst, dstDraw);
+
+ XCopyArea(dmxScreen->beDisplay, srcDraw, dstDraw, pGCPriv->gc,
+ srcx, srcy, w, h, dstx, dsty);
+ dmxSync(dmxScreen, FALSE);
+
+ return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, w, h,
+ dstx, dsty, 0L);
+}
+
+/** Copy plane number \a bitPlane from \a pSrc drawable to \a pDst
+ * drawable on the back-end server associated with \a pSrc drawable's
+ * screen. If the offscreen optimization is enabled, only copy when
+ * both \a pSrc and \a pDst are at least partially visible. */
+RegionPtr dmxCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int width, int height,
+ int dstx, int dsty, unsigned long bitPlane)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pSrc->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable srcDraw, dstDraw;
+
+ if (DMX_GCOPS_OFFSCREEN(pSrc) || DMX_GCOPS_OFFSCREEN(pDst))
+ return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, width, height,
+ dstx, dsty, bitPlane);
+
+ DMX_GCOPS_SET_DRAWABLE(pSrc, srcDraw);
+ DMX_GCOPS_SET_DRAWABLE(pDst, dstDraw);
+
+ XCopyPlane(dmxScreen->beDisplay, srcDraw, dstDraw, pGCPriv->gc,
+ srcx, srcy, width, height, dstx, dsty, bitPlane);
+ dmxSync(dmxScreen, FALSE);
+
+ return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, width, height,
+ dstx, dsty, bitPlane);
+}
+
+/** Render list of points, \a pptInit in \a pDrawable on the back-end
+ * server associated with \a pDrawable's screen. If the offscreen
+ * optimization is enabled, only draw when \a pDrawable is at least
+ * partially visible. */
+void dmxPolyPoint(DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr pptInit)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawPoints(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XPoint *)pptInit, npt, mode);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of connected lines, \a pptInit in \a pDrawable on the
+ * back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+void dmxPolylines(DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr pptInit)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawLines(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XPoint *)pptInit, npt, mode);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of disjoint segments, \a pSegs in \a pDrawable on the
+ * back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+void dmxPolySegment(DrawablePtr pDrawable, GCPtr pGC,
+ int nseg, xSegment *pSegs)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawSegments(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XSegment *)pSegs, nseg);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of rectangle outlines, \a pRects in \a pDrawable on the
+ * back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+void dmxPolyRectangle(DrawablePtr pDrawable, GCPtr pGC,
+ int nrects, xRectangle *pRects)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawRectangles(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XRectangle *)pRects, nrects);
+
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of arc outlines, \a parcs in \a pDrawable on the
+ * back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+void dmxPolyArc(DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *parcs)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawArcs(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XArc *)parcs, narcs);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render a filled polygons in \a pDrawable on the back-end server
+ * associated with \a pDrawable's screen. If the offscreen
+ * optimization is enabled, only draw when \a pDrawable is at least
+ * partially visible. */
+void dmxFillPolygon(DrawablePtr pDrawable, GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr pPts)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XFillPolygon(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XPoint *)pPts, count, shape, mode);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of filled rectangles, \a prectInit in \a pDrawable on
+ * the back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+void dmxPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
+ int nrectFill, xRectangle *prectInit)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XFillRectangles(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XRectangle *)prectInit, nrectFill);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of filled arcs, \a parcs in \a pDrawable on the back-end
+ * server associated with \a pDrawable's screen. If the offscreen
+ * optimization is enabled, only draw when \a pDrawable is at least
+ * partially visible. */
+void dmxPolyFillArc(DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *parcs)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XFillArcs(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XArc *)parcs, narcs);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render string of 8-bit \a chars (foreground only) in \a pDrawable on
+ * the back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+int dmxPolyText8(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, char *chars)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ unsigned long n, i;
+ int w;
+ CharInfoPtr charinfo[255];
+ Drawable draw;
+
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars,
+ Linear8Bit, &n, charinfo);
+
+ /* Calculate text width */
+ w = 0;
+ for (i = 0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
+
+ if (n != 0 && !DMX_GCOPS_OFFSCREEN(pDrawable)) {
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawString(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ x, y, chars, count);
+ dmxSync(dmxScreen, FALSE);
+ }
+
+ return x+w;
+}
+
+/** Render string of 16-bit \a chars (foreground only) in \a pDrawable
+ * on the back-end server associated with \a pDrawable's screen. If
+ * the offscreen optimization is enabled, only draw when \a pDrawable
+ * is at least partially visible. */
+int dmxPolyText16(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ unsigned long n, i;
+ int w;
+ CharInfoPtr charinfo[255];
+ Drawable draw;
+
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars,
+ (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
+ &n, charinfo);
+
+ /* Calculate text width */
+ w = 0;
+ for (i = 0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
+
+ if (n != 0 && !DMX_GCOPS_OFFSCREEN(pDrawable)) {
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawString16(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ x, y, (XChar2b *)chars, count);
+ dmxSync(dmxScreen, FALSE);
+ }
+
+ return x+w;
+}
+
+/** Render string of 8-bit \a chars (both foreground and background) in
+ * \a pDrawable on the back-end server associated with \a pDrawable's
+ * screen. If the offscreen optimization is enabled, only draw when \a
+ * pDrawable is at least partially visible. */
+void dmxImageText8(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, char *chars)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawImageString(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ x, y, chars, count);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render string of 16-bit \a chars (both foreground and background) in
+ * \a pDrawable on the back-end server associated with \a pDrawable's
+ * screen. If the offscreen optimization is enabled, only draw when \a
+ * pDrawable is at least partially visible. */
+void dmxImageText16(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawImageString16(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ x, y, (XChar2b *)chars, count);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Image Glyph Blt -- this function should never be called. */
+void dmxImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase)
+{
+ /* Error -- this should never happen! */
+}
+
+/** Poly Glyph Blt -- this function should never be called. */
+void dmxPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase)
+{
+ /* Error -- this should never happen! */
+}
+
+/** Push Pixels -- this function should never be called. */
+void dmxPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst,
+ int w, int h, int x, int y)
+{
+ /* Error -- this should never happen! */
+}
+
+/**********************************************************************
+ * Miscellaneous drawing commands
+ */
+
+/** When Xinerama is active, the client pixmaps are always obtained from
+ * screen 0. When screen 0 is detached, the pixmaps must be obtained
+ * from any other screen that is not detached. Usually, this is screen
+ * 1. */
+static DMXScreenInfo *dmxFindAlternatePixmap(DrawablePtr pDrawable, XID *draw)
+{
+#ifdef PANORAMIX
+ PanoramiXRes *pXinPix;
+ int i;
+ DMXScreenInfo *dmxScreen;
+
+ if (noPanoramiXExtension) return NULL;
+ if (pDrawable->type != DRAWABLE_PIXMAP) return NULL;
+
+ if (!(pXinPix = (PanoramiXRes *)LookupIDByType(pDrawable->id, XRT_PIXMAP)))
+ return NULL;
+
+ for (i = 1; i < PanoramiXNumScreens; i++) {
+ dmxScreen = &dmxScreens[i];
+ if (dmxScreen->beDisplay) {
+ PixmapPtr pSrc;
+ dmxPixPrivPtr pSrcPriv;
+
+ pSrc = (PixmapPtr)LookupIDByType(pXinPix->info[i].id,
+ RT_PIXMAP);
+ pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc);
+ if (pSrcPriv->pixmap) {
+ *draw = pSrcPriv->pixmap;
+ return dmxScreen;
+ }
+ }
+ }
+#endif
+ return NULL;
+}
+
+/** Get an image from the back-end server associated with \a pDrawable's
+ * screen. If \a pDrawable is a window, it must be viewable to get an
+ * image from it. If it is not viewable, then get the image from the
+ * first ancestor of \a pDrawable that is viewable. If no viewable
+ * ancestor is found, then simply return without getting an image. */
+void dmxGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
+ unsigned int format, unsigned long planeMask, char *pdstLine)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ XImage *img;
+ Drawable draw;
+
+ /* Cannot get image from unviewable window */
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ WindowPtr pWindow = (WindowPtr)pDrawable;
+ if (!pWindow->viewable) {
+ while (!pWindow->viewable && pWindow->parent) {
+ sx += pWindow->origin.x - wBorderWidth(pWindow);
+ sx += pWindow->origin.y - wBorderWidth(pWindow);
+ pWindow = pWindow->parent;
+ }
+ if (!pWindow->viewable) {
+ return;
+ }
+ }
+ DMX_GCOPS_SET_DRAWABLE(&pWindow->drawable, draw);
+ if (DMX_GCOPS_OFFSCREEN(&pWindow->drawable))
+ return;
+ } else {
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) {
+ /* Try to find the pixmap on a non-detached Xinerama screen */
+ dmxScreen = dmxFindAlternatePixmap(pDrawable, &draw);
+ if (!dmxScreen) return;
+ }
+ }
+
+ img = XGetImage(dmxScreen->beDisplay, draw,
+ sx, sy, w, h, planeMask, format);
+ if (img) {
+ int len = img->bytes_per_line * img->height;
+ memmove(pdstLine, img->data, len);
+ XDestroyImage(img);
+ }
+
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Get Spans -- this function should never be called. */
+void dmxGetSpans(DrawablePtr pDrawable, int wMax,
+ DDXPointPtr ppt, int *pwidth, int nspans,
+ char *pdstStart)
+{
+ /* Error -- this should never happen! */
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxgcops.h b/nx-X11/programs/Xserver/hw/dmx/dmxgcops.h
new file mode 100644
index 000000000..0754c44c1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxgcops.h
@@ -0,0 +1,96 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001,2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for gcops support. \see dmxgcops.c */
+
+#ifndef DMXGCOPS_H
+#define DMXGCOPS_H
+
+extern void dmxFillSpans(DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit, int *pwidthInit,
+ int fSorted);
+extern void dmxSetSpans(DrawablePtr pDrawable, GCPtr pGC,
+ char *psrc, DDXPointPtr ppt, int *pwidth, int nspans,
+ int fSorted);
+extern void dmxPutImage(DrawablePtr pDrawable, GCPtr pGC,
+ int depth, int x, int y, int w, int h,
+ int leftPad, int format, char *pBits);
+extern RegionPtr dmxCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h,
+ int dstx, int dsty);
+extern RegionPtr dmxCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int width, int height,
+ int dstx, int dsty, unsigned long bitPlane);
+extern void dmxPolyPoint(DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr pptInit);
+extern void dmxPolylines(DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr pptInit);
+extern void dmxPolySegment(DrawablePtr pDrawable, GCPtr pGC,
+ int nseg, xSegment *pSegs);
+extern void dmxPolyRectangle(DrawablePtr pDrawable, GCPtr pGC,
+ int nrects, xRectangle *pRects);
+extern void dmxPolyArc(DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *parcs);
+extern void dmxFillPolygon(DrawablePtr pDrawable, GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr pPts);
+extern void dmxPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
+ int nrectFill, xRectangle *prectInit);
+extern void dmxPolyFillArc(DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *parcs);
+extern int dmxPolyText8(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, char *chars);
+extern int dmxPolyText16(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars);
+extern void dmxImageText8(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, char *chars);
+extern void dmxImageText16(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars);
+extern void dmxImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase);
+extern void dmxPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase);
+extern void dmxPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst,
+ int w, int h, int x, int y);
+
+extern void dmxGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
+ unsigned int format, unsigned long planeMask,
+ char *pdstLine);
+extern void dmxGetSpans(DrawablePtr pDrawable, int wMax,
+ DDXPointPtr ppt, int *pwidth, int nspans,
+ char *pdstStart);
+
+#endif /* DMXGCOPS_H */
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxinit.c b/nx-X11/programs/Xserver/hw/dmx/dmxinit.c
new file mode 100644
index 000000000..ddc4d2b04
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxinit.c
@@ -0,0 +1,1062 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ * David H. Dawes <dawes@xfree86.org>
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Provide expected functions for initialization from the ddx layer and
+ * global variables for the DMX server. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxinit.h"
+#include "dmxsync.h"
+#include "dmxlog.h"
+#include "dmxinput.h"
+#include "dmxscrinit.h"
+#include "dmxcursor.h"
+#include "dmxfont.h"
+#include "config/dmxconfig.h"
+#include "dmxcb.h"
+#include "dmxprop.h"
+#include "dmxstat.h"
+#ifdef RENDER
+#include "dmxpict.h"
+#endif
+
+#include <X11/Xos.h> /* For gettimeofday */
+#include "dixstruct.h"
+#include "panoramiXsrv.h"
+
+#include <signal.h> /* For SIGQUIT */
+
+#ifdef GLXEXT
+#include <GL/glx.h>
+#include <GL/glxint.h>
+#include "dmx_glxvisuals.h"
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+extern void GlxSetVisualConfigs(
+ int nconfigs,
+ __GLXvisualConfig *configs,
+ void **configprivs
+);
+#endif /* GLXEXT */
+
+extern void SetVendorRelease(int release); /* in dix/main.c */
+extern void SetVendorString(char *string); /* in dix/main.c */
+
+/* Global variables available to all Xserver/hw/dmx routines. */
+int dmxNumScreens;
+DMXScreenInfo *dmxScreens;
+
+int dmxNumInputs;
+DMXInputInfo *dmxInputs;
+
+int dmxShadowFB = FALSE;
+
+XErrorEvent dmxLastErrorEvent;
+Bool dmxErrorOccurred = FALSE;
+
+char *dmxFontPath = NULL;
+
+Bool dmxOffScreenOpt = TRUE;
+
+Bool dmxSubdividePrimitives = TRUE;
+
+Bool dmxLazyWindowCreation = TRUE;
+
+Bool dmxUseXKB = TRUE;
+
+int dmxDepth = 0;
+
+#ifndef GLXEXT
+static Bool dmxGLXProxy = FALSE;
+#else
+Bool dmxGLXProxy = TRUE;
+
+Bool dmxGLXSwapGroupSupport = TRUE;
+
+Bool dmxGLXSyncSwap = FALSE;
+
+Bool dmxGLXFinishSwap = FALSE;
+#endif
+
+Bool dmxIgnoreBadFontPaths = FALSE;
+
+Bool dmxAddRemoveScreens = FALSE;
+
+/* dmxErrorHandler catches errors that occur when calling one of the
+ * back-end servers. Some of this code is based on _XPrintDefaultError
+ * in xc/lib/X11/XlibInt.c */
+static int dmxErrorHandler(Display *dpy, XErrorEvent *ev)
+{
+#define DMX_ERROR_BUF_SIZE 256
+ /* RATS: these buffers are only used in
+ * length-limited calls. */
+ char buf[DMX_ERROR_BUF_SIZE];
+ char request[DMX_ERROR_BUF_SIZE];
+ _XExtension *ext = NULL;
+
+ dmxErrorOccurred = TRUE;
+ dmxLastErrorEvent = *ev;
+
+ XGetErrorText(dpy, ev->error_code, buf, sizeof(buf));
+ dmxLog(dmxWarning, "dmxErrorHandler: %s\n", buf);
+
+ /* Find major opcode name */
+ if (ev->request_code < 128) {
+ XmuSnprintf(request, sizeof(request), "%d", ev->request_code);
+ XGetErrorDatabaseText(dpy, "XRequest", request, "", buf, sizeof(buf));
+ } else {
+ for (ext = dpy->ext_procs;
+ ext && ext->codes.major_opcode != ev->request_code;
+ ext = ext->next);
+ if (ext) strncpy(buf, ext->name, sizeof(buf));
+ else buf[0] = '\0';
+ }
+ dmxLog(dmxWarning, " Major opcode: %d (%s)\n",
+ ev->request_code, buf);
+
+ /* Find minor opcode name */
+ if (ev->request_code >= 128 && ext) {
+ XmuSnprintf(request, sizeof(request), "%d", ev->request_code);
+ XmuSnprintf(request, sizeof(request), "%s.%d",
+ ext->name, ev->minor_code);
+ XGetErrorDatabaseText(dpy, "XRequest", request, "", buf, sizeof(buf));
+ dmxLog(dmxWarning, " Minor opcode: %d (%s)\n",
+ ev->minor_code, buf);
+ }
+
+ /* Provide value information */
+ switch (ev->error_code) {
+ case BadValue:
+ dmxLog(dmxWarning, " Value: 0x%x\n",
+ ev->resourceid);
+ break;
+ case BadAtom:
+ dmxLog(dmxWarning, " AtomID: 0x%x\n",
+ ev->resourceid);
+ break;
+ default:
+ dmxLog(dmxWarning, " ResourceID: 0x%x\n",
+ ev->resourceid);
+ break;
+ }
+
+ /* Provide serial number information */
+ dmxLog(dmxWarning, " Failed serial number: %d\n",
+ ev->serial);
+ dmxLog(dmxWarning, " Current serial number: %d\n",
+ dpy->request);
+ return 0;
+}
+
+#ifdef GLXEXT
+static int dmxNOPErrorHandler(Display *dpy, XErrorEvent *ev)
+{
+ return 0;
+}
+#endif
+
+Bool dmxOpenDisplay(DMXScreenInfo *dmxScreen)
+{
+ if (!(dmxScreen->beDisplay = XOpenDisplay(dmxScreen->name)))
+ return FALSE;
+
+ dmxPropertyDisplay(dmxScreen);
+ return TRUE;
+}
+
+void dmxSetErrorHandler(DMXScreenInfo *dmxScreen)
+{
+ XSetErrorHandler(dmxErrorHandler);
+}
+
+static void dmxPrintScreenInfo(DMXScreenInfo *dmxScreen)
+{
+ XWindowAttributes attribs;
+ int ndepths = 0, *depths = NULL;
+ int i;
+ Display *dpy = dmxScreen->beDisplay;
+ Screen *s = DefaultScreenOfDisplay(dpy);
+ int scr = DefaultScreen(dpy);
+
+ XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &attribs);
+ if (!(depths = XListDepths(dpy, scr, &ndepths))) ndepths = 0;
+
+ dmxLogOutput(dmxScreen, "Name of display: %s\n", DisplayString(dpy));
+ dmxLogOutput(dmxScreen, "Version number: %d.%d\n",
+ ProtocolVersion(dpy), ProtocolRevision(dpy));
+ dmxLogOutput(dmxScreen, "Vendor string: %s\n", ServerVendor(dpy));
+ if (!strstr(ServerVendor(dpy), "XFree86")) {
+ dmxLogOutput(dmxScreen, "Vendor release: %d\n", VendorRelease(dpy));
+ } else {
+ /* This code based on xdpyinfo.c */
+ int v = VendorRelease(dpy);
+ int major = -1, minor = -1, patch = -1, subpatch = -1;
+
+ if (v < 336)
+ major = v / 100, minor = (v / 10) % 10, patch = v % 10;
+ else if (v < 3900) {
+ major = v / 1000;
+ minor = (v / 100) % 10;
+ if (((v / 10) % 10) || (v % 10)) {
+ patch = (v / 10) % 10;
+ if (v % 10) subpatch = v % 10;
+ }
+ } else if (v < 40000000) {
+ major = v / 1000;
+ minor = (v / 10) % 10;
+ if (v % 10) patch = v % 10;
+ } else {
+ major = v / 10000000;
+ minor = (v / 100000) % 100;
+ patch = (v / 1000) % 100;
+ if (v % 1000) subpatch = v % 1000;
+ }
+ dmxLogOutput(dmxScreen, "Vendor release: %d (XFree86 version: %d.%d",
+ v, major, minor);
+ if (patch > 0) dmxLogOutputCont(dmxScreen, ".%d", patch);
+ if (subpatch > 0) dmxLogOutputCont(dmxScreen, ".%d", subpatch);
+ dmxLogOutputCont(dmxScreen, ")\n");
+ }
+
+
+ dmxLogOutput(dmxScreen, "Dimensions: %dx%d pixels\n",
+ attribs.width, attribs.height);
+ dmxLogOutput(dmxScreen, "%d depths on screen %d: ", ndepths, scr);
+ for (i = 0; i < ndepths; i++)
+ dmxLogOutputCont(dmxScreen, "%c%d", i ? ',' : ' ', depths[i]);
+ dmxLogOutputCont(dmxScreen, "\n");
+ dmxLogOutput(dmxScreen, "Depth of root window: %d plane%s (%d)\n",
+ attribs.depth, attribs.depth == 1 ? "" : "s",
+ DisplayPlanes(dpy, scr));
+ dmxLogOutput(dmxScreen, "Number of colormaps: %d min, %d max\n",
+ MinCmapsOfScreen(s), MaxCmapsOfScreen(s));
+ dmxLogOutput(dmxScreen, "Options: backing-store %s, save-unders %s\n",
+ (DoesBackingStore (s) == NotUseful) ? "no" :
+ ((DoesBackingStore (s) == Always) ? "yes" : "when mapped"),
+ DoesSaveUnders (s) ? "yes" : "no");
+ dmxLogOutput(dmxScreen, "Window Manager running: %s\n",
+ (dmxScreen->WMRunningOnBE) ? "yes" : "no");
+
+ if (dmxScreen->WMRunningOnBE) {
+ dmxLogOutputWarning(dmxScreen,
+ "Window manager running "
+ "-- colormaps not supported\n");
+ }
+ XFree(depths);
+}
+
+void dmxGetScreenAttribs(DMXScreenInfo *dmxScreen)
+{
+ XWindowAttributes attribs;
+ Display *dpy = dmxScreen->beDisplay;
+#ifdef GLXEXT
+ int dummy;
+#endif
+
+ XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &attribs);
+
+ dmxScreen->beWidth = attribs.width;
+ dmxScreen->beHeight = attribs.height;
+
+ /* Fill in missing geometry information */
+ if (dmxScreen->scrnXSign < 0) {
+ if (dmxScreen->scrnWidth) {
+ dmxScreen->scrnX = (attribs.width - dmxScreen->scrnWidth
+ - dmxScreen->scrnX);
+ } else {
+ dmxScreen->scrnWidth = attribs.width - dmxScreen->scrnX;
+ dmxScreen->scrnX = 0;
+ }
+ }
+ if (dmxScreen->scrnYSign < 0) {
+ if (dmxScreen->scrnHeight) {
+ dmxScreen->scrnY = (attribs.height - dmxScreen->scrnHeight
+ - dmxScreen->scrnY);
+ } else {
+ dmxScreen->scrnHeight = attribs.height - dmxScreen->scrnY;
+ dmxScreen->scrnY = 0;
+ }
+ }
+ if (!dmxScreen->scrnWidth)
+ dmxScreen->scrnWidth = attribs.width - dmxScreen->scrnX;
+ if (!dmxScreen->scrnHeight)
+ dmxScreen->scrnHeight = attribs.height - dmxScreen->scrnY;
+
+ if (!dmxScreen->rootWidth) dmxScreen->rootWidth = dmxScreen->scrnWidth;
+ if (!dmxScreen->rootHeight) dmxScreen->rootHeight = dmxScreen->scrnHeight;
+ if (dmxScreen->rootWidth + dmxScreen->rootX > dmxScreen->scrnWidth)
+ dmxScreen->rootWidth = dmxScreen->scrnWidth - dmxScreen->rootX;
+ if (dmxScreen->rootHeight + dmxScreen->rootY > dmxScreen->scrnHeight)
+ dmxScreen->rootHeight = dmxScreen->scrnHeight - dmxScreen->rootY;
+
+ /* FIXME: Get these from the back-end server */
+ dmxScreen->beXDPI = 75;
+ dmxScreen->beYDPI = 75;
+
+ dmxScreen->beDepth = attribs.depth; /* FIXME: verify that this
+ * works always. In
+ * particular, this will work
+ * well for depth=16, will fail
+ * because of colormap issues
+ * at depth 8. More work needs
+ * to be done here. */
+
+ if (dmxScreen->beDepth <= 8) dmxScreen->beBPP = 8;
+ else if (dmxScreen->beDepth <= 16) dmxScreen->beBPP = 16;
+ else dmxScreen->beBPP = 32;
+
+#ifdef GLXEXT
+ /* get the majorOpcode for the back-end GLX extension */
+ XQueryExtension(dpy, "GLX", &dmxScreen->glxMajorOpcode,
+ &dummy, &dmxScreen->glxErrorBase);
+#endif
+
+ dmxPrintScreenInfo(dmxScreen);
+ dmxLogOutput(dmxScreen, "%dx%d+%d+%d on %dx%d at depth=%d, bpp=%d\n",
+ dmxScreen->scrnWidth, dmxScreen->scrnHeight,
+ dmxScreen->scrnX, dmxScreen->scrnY,
+ dmxScreen->beWidth, dmxScreen->beHeight,
+ dmxScreen->beDepth, dmxScreen->beBPP);
+ if (dmxScreen->beDepth == 8)
+ dmxLogOutputWarning(dmxScreen,
+ "Support for depth == 8 is not complete\n");
+}
+
+Bool dmxGetVisualInfo(DMXScreenInfo *dmxScreen)
+{
+ int i;
+ XVisualInfo visinfo;
+
+ visinfo.screen = DefaultScreen(dmxScreen->beDisplay);
+ dmxScreen->beVisuals = XGetVisualInfo(dmxScreen->beDisplay,
+ VisualScreenMask,
+ &visinfo,
+ &dmxScreen->beNumVisuals);
+
+ dmxScreen->beDefVisualIndex = -1;
+
+ if (defaultColorVisualClass >= 0 || dmxDepth > 0) {
+ for (i = 0; i < dmxScreen->beNumVisuals; i++)
+ if (defaultColorVisualClass >= 0) {
+ if (dmxScreen->beVisuals[i].class == defaultColorVisualClass) {
+ if (dmxDepth > 0) {
+ if (dmxScreen->beVisuals[i].depth == dmxDepth) {
+ dmxScreen->beDefVisualIndex = i;
+ break;
+ }
+ } else {
+ dmxScreen->beDefVisualIndex = i;
+ break;
+ }
+ }
+ } else if (dmxScreen->beVisuals[i].depth == dmxDepth) {
+ dmxScreen->beDefVisualIndex = i;
+ break;
+ }
+ } else {
+ visinfo.visualid =
+ XVisualIDFromVisual(DefaultVisual(dmxScreen->beDisplay,
+ visinfo.screen));
+
+ for (i = 0; i < dmxScreen->beNumVisuals; i++)
+ if (visinfo.visualid == dmxScreen->beVisuals[i].visualid) {
+ dmxScreen->beDefVisualIndex = i;
+ break;
+ }
+ }
+
+ for (i = 0; i < dmxScreen->beNumVisuals; i++)
+ dmxLogVisual(dmxScreen, &dmxScreen->beVisuals[i],
+ (i == dmxScreen->beDefVisualIndex));
+
+ return (dmxScreen->beDefVisualIndex >= 0);
+}
+
+void dmxGetColormaps(DMXScreenInfo *dmxScreen)
+{
+ int i;
+
+ dmxScreen->beNumDefColormaps = dmxScreen->beNumVisuals;
+ dmxScreen->beDefColormaps = xalloc(dmxScreen->beNumDefColormaps *
+ sizeof(*dmxScreen->beDefColormaps));
+
+ for (i = 0; i < dmxScreen->beNumDefColormaps; i++)
+ dmxScreen->beDefColormaps[i] =
+ XCreateColormap(dmxScreen->beDisplay,
+ DefaultRootWindow(dmxScreen->beDisplay),
+ dmxScreen->beVisuals[i].visual,
+ AllocNone);
+
+ dmxScreen->beBlackPixel = BlackPixel(dmxScreen->beDisplay,
+ DefaultScreen(dmxScreen->beDisplay));
+ dmxScreen->beWhitePixel = WhitePixel(dmxScreen->beDisplay,
+ DefaultScreen(dmxScreen->beDisplay));
+}
+
+void dmxGetPixmapFormats(DMXScreenInfo *dmxScreen)
+{
+ dmxScreen->beDepths =
+ XListDepths(dmxScreen->beDisplay, DefaultScreen(dmxScreen->beDisplay),
+ &dmxScreen->beNumDepths);
+
+ dmxScreen->bePixmapFormats =
+ XListPixmapFormats(dmxScreen->beDisplay,
+ &dmxScreen->beNumPixmapFormats);
+}
+
+static Bool dmxSetPixmapFormats(ScreenInfo *pScreenInfo,
+ DMXScreenInfo *dmxScreen)
+{
+ XPixmapFormatValues *bePixmapFormat;
+ PixmapFormatRec *format;
+ int i, j;
+
+ pScreenInfo->imageByteOrder = ImageByteOrder(dmxScreen->beDisplay);
+ pScreenInfo->bitmapScanlineUnit = BitmapUnit(dmxScreen->beDisplay);
+ pScreenInfo->bitmapScanlinePad = BitmapPad(dmxScreen->beDisplay);
+ pScreenInfo->bitmapBitOrder = BitmapBitOrder(dmxScreen->beDisplay);
+
+ pScreenInfo->numPixmapFormats = 0;
+ for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) {
+ bePixmapFormat = &dmxScreen->bePixmapFormats[i];
+ for (j = 0; j < dmxScreen->beNumDepths; j++)
+ if ((bePixmapFormat->depth == 1) ||
+ (bePixmapFormat->depth == dmxScreen->beDepths[j])) {
+ format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats];
+
+ format->depth = bePixmapFormat->depth;
+ format->bitsPerPixel = bePixmapFormat->bits_per_pixel;
+ format->scanlinePad = bePixmapFormat->scanline_pad;
+
+ pScreenInfo->numPixmapFormats++;
+ break;
+ }
+ }
+
+ return TRUE;
+}
+
+void dmxCheckForWM(DMXScreenInfo *dmxScreen)
+{
+ Status status;
+ XWindowAttributes xwa;
+
+ status = XGetWindowAttributes(dmxScreen->beDisplay,
+ DefaultRootWindow(dmxScreen->beDisplay),
+ &xwa);
+ dmxScreen->WMRunningOnBE =
+ (status &&
+ ((xwa.all_event_masks & SubstructureRedirectMask) ||
+ (xwa.all_event_masks & SubstructureNotifyMask)));
+}
+
+/** Initialize the display and collect relevant information about the
+ * display properties */
+static void dmxDisplayInit(DMXScreenInfo *dmxScreen)
+{
+ if (!dmxOpenDisplay(dmxScreen))
+ dmxLog(dmxFatal,
+ "dmxOpenDisplay: Unable to open display %s\n",
+ dmxScreen->name);
+
+ dmxSetErrorHandler(dmxScreen);
+ dmxCheckForWM(dmxScreen);
+ dmxGetScreenAttribs(dmxScreen);
+
+ if (!dmxGetVisualInfo(dmxScreen))
+ dmxLog(dmxFatal, "dmxGetVisualInfo: No matching visuals found\n");
+
+ dmxGetColormaps(dmxScreen);
+ dmxGetPixmapFormats(dmxScreen);
+}
+
+/* If this doesn't compile, just add || defined(yoursystem) to the line
+ * below. This information is to help with bug reports and is not
+ * critical. */
+#if !defined(_POSIX_SOURCE) && !defined(__sgi)
+static const char *dmxExecOS(void) { return ""; }
+#else
+#include <sys/utsname.h>
+static const char *dmxExecOS(void)
+{
+ static char buffer[128];
+ static int initialized = 0;
+ struct utsname u;
+
+ if (!initialized++) {
+ memset(buffer, 0, sizeof(buffer));
+ uname(&u);
+ XmuSnprintf(buffer, sizeof(buffer)-1, "%s %s %s",
+ u.sysname, u.release, u.version);
+ }
+ return buffer;
+}
+#endif
+
+static const char *dmxBuildCompiler(void)
+{
+ static char buffer[128];
+ static int initialized = 0;
+
+ if (!initialized++) {
+ memset(buffer, 0, sizeof(buffer));
+#if defined(__GNUC__) && defined(__GNUC_MINOR__) &&defined(__GNUC_PATCHLEVEL__)
+ XmuSnprintf(buffer, sizeof(buffer)-1, "gcc %d.%d.%d",
+ __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
+#elif defined(__sgi) && defined(_COMPILER_VERSION) && !defined(__GNUC__)
+ {
+ int a = _COMPILER_VERSION / 100;
+ int b = (_COMPILER_VERSION - a * 100) / 10;
+ int c = _COMPILER_VERSION - a * 100 - b * 10;
+ XmuSnprintf(buffer, sizeof(buffer)-1, "SGI MIPSpro %d.%d.%d",
+ a, b, c);
+ }
+#endif
+ }
+ return buffer;
+}
+
+static const char *dmxExecHost(void)
+{
+ static char buffer[128];
+ static int initialized = 0;
+
+ if (!initialized++) {
+ memset(buffer, 0, sizeof(buffer));
+ XmuGetHostname(buffer, sizeof(buffer) - 1);
+ }
+ return buffer;
+}
+
+/** This routine is called in Xserver/dix/main.c from \a main(). */
+void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[])
+{
+ int i;
+ static unsigned long dmxGeneration = 0;
+#ifdef GLXEXT
+ Bool glxSupported = TRUE;
+#endif
+
+ if (dmxGeneration != serverGeneration) {
+ int vendrel = VENDOR_RELEASE;
+ int major, minor, year, month, day;
+
+ dmxGeneration = serverGeneration;
+
+ major = vendrel / 100000000;
+ vendrel -= major * 100000000;
+ minor = vendrel / 1000000;
+ vendrel -= minor * 1000000;
+ year = vendrel / 10000;
+ vendrel -= year * 10000;
+ month = vendrel / 100;
+ vendrel -= month * 100;
+ day = vendrel;
+
+ /* Add other epoch tests here */
+ if (major > 0 && minor > 0) year += 2000;
+
+ dmxLog(dmxInfo, "Generation: %d\n", dmxGeneration);
+ dmxLog(dmxInfo, "DMX version: %d.%d.%02d%02d%02d (%s)\n",
+ major, minor, year, month, day, VENDOR_STRING);
+
+ SetVendorRelease(VENDOR_RELEASE);
+ SetVendorString(VENDOR_STRING);
+
+ if (dmxGeneration == 1) {
+ dmxLog(dmxInfo, "DMX Build OS: %s (%s)\n", OSNAME, OSVENDOR);
+ dmxLog(dmxInfo, "DMX Build Compiler: %s\n", dmxBuildCompiler());
+ dmxLog(dmxInfo, "DMX Execution OS: %s\n", dmxExecOS());
+ dmxLog(dmxInfo, "DMX Execution Host: %s\n", dmxExecHost());
+ }
+ dmxLog(dmxInfo, "MAXSCREENS: %d\n", MAXSCREENS);
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ if (dmxScreens[i].beDisplay)
+ dmxLog(dmxWarning, "Display \"%s\" still open\n",
+ dmxScreens[i].name);
+ dmxStatFree(dmxScreens[i].stat);
+ dmxScreens[i].stat = NULL;
+ }
+ for (i = 0; i < dmxNumInputs; i++) dmxInputFree(&dmxInputs[i]);
+ if (dmxScreens) free(dmxScreens);
+ if (dmxInputs) free(dmxInputs);
+ dmxScreens = NULL;
+ dmxInputs = NULL;
+ dmxNumScreens = 0;
+ dmxNumInputs = 0;
+ }
+
+ /* Make sure that the command-line arguments are sane. */
+ if (dmxAddRemoveScreens && (!noRenderExtension || dmxGLXProxy)) {
+ /* Currently it is not possible to support GLX and Render
+ * extensions with dynamic screen addition/removal due to the
+ * state that each extension keeps, which cannot be restored. */
+ dmxLog(dmxWarning,
+ "GLX Proxy and Render extensions do not yet support dynamic\n");
+ dmxLog(dmxWarning,
+ "screen addition and removal. Please specify -noglxproxy\n");
+ dmxLog(dmxWarning,
+ "and -norender on the command line or in the configuration\n");
+ dmxLog(dmxWarning,
+ "file to disable these two extensions if you wish to use\n");
+ dmxLog(dmxWarning,
+ "the dynamic addition and removal of screens support.\n");
+ dmxLog(dmxFatal,
+ "Dynamic screen addition/removal error (see above).\n");
+ }
+
+ /* ddxProcessArgument has been called at this point, but any data
+ * from the configuration file has not been applied. Do so, and be
+ * sure we have at least one back-end display. */
+ dmxConfigConfigure();
+ if (!dmxNumScreens)
+ dmxLog(dmxFatal, "InitOutput: no back-end displays found\n");
+ if (!dmxNumInputs)
+ dmxLog(dmxInfo, "InitOutput: no inputs found\n");
+
+ /* Disable lazy window creation optimization if offscreen
+ * optimization is disabled */
+ if (!dmxOffScreenOpt && dmxLazyWindowCreation) {
+ dmxLog(dmxInfo,
+ "InitOutput: Disabling lazy window creation optimization\n");
+ dmxLog(dmxInfo,
+ " since it requires the offscreen optimization\n");
+ dmxLog(dmxInfo,
+ " to function properly.\n");
+ dmxLazyWindowCreation = FALSE;
+ }
+
+ /* Open each display and gather information about it. */
+ for (i = 0; i < dmxNumScreens; i++)
+ dmxDisplayInit(&dmxScreens[i]);
+
+#if PANORAMIX
+ /* Register a Xinerama callback which will run from within
+ * PanoramiXCreateConnectionBlock. We can use the callback to
+ * determine if Xinerama is loaded and to check the visuals
+ * determined by PanoramiXConsolidate. */
+ XineramaRegisterConnectionBlockCallback(dmxConnectionBlockCallback);
+#endif
+
+ /* Since we only have a single screen thus far, we only need to set
+ the pixmap formats to match that screen. FIXME: this isn't true.*/
+ if (!dmxSetPixmapFormats(pScreenInfo, &dmxScreens[0])) return;
+
+ /* Might want to install a signal handler to allow cleaning up after
+ * unexpected signals. The DIX/OS layer already handles SIGINT and
+ * SIGTERM, so everything is OK for expected signals. --DD
+ *
+ * SIGHUP, SIGINT, and SIGTERM are trapped in os/connection.c
+ * SIGQUIT is another common signal that is sent from the keyboard.
+ * Trap it here, to ensure that the keyboard modifier map and other
+ * state for the input devices are restored. (This makes the
+ * behavior of SIGQUIT somewhat unexpected, since it will be the
+ * same as the behavior of SIGINT. However, leaving the modifier
+ * map of the input devices empty is even more unexpected.) --RF
+ */
+ OsSignal(SIGQUIT, GiveUp);
+
+#ifdef GLXEXT
+ /* Check if GLX extension exists on all back-end servers */
+ for (i = 0; i < dmxNumScreens; i++)
+ glxSupported &= (dmxScreens[i].glxMajorOpcode > 0);
+#endif
+
+ /* Tell dix layer about the backend displays */
+ for (i = 0; i < dmxNumScreens; i++) {
+
+#ifdef GLXEXT
+ if (glxSupported) {
+ /*
+ * Builds GLX configurations from the list of visuals
+ * supported by the back-end server, and give that
+ * configuration list to the glx layer - so that he will
+ * build the visuals accordingly.
+ */
+
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ __GLXvisualConfig *configs = NULL;
+ dmxGlxVisualPrivate **configprivs = NULL;
+ int nconfigs = 0;
+ int (*oldErrorHandler)(Display *, XErrorEvent *);
+ int i;
+
+ /* Catch errors if when using an older GLX w/o FBconfigs */
+ oldErrorHandler = XSetErrorHandler(dmxNOPErrorHandler);
+
+ /* Get FBConfigs of the back-end server */
+ dmxScreen->fbconfigs = GetGLXFBConfigs(dmxScreen->beDisplay,
+ dmxScreen->glxMajorOpcode,
+ &dmxScreen->numFBConfigs);
+
+ XSetErrorHandler(oldErrorHandler);
+
+ dmxScreen->glxVisuals =
+ GetGLXVisualConfigs(dmxScreen->beDisplay,
+ DefaultScreen(dmxScreen->beDisplay),
+ &dmxScreen->numGlxVisuals);
+
+ if (dmxScreen->fbconfigs) {
+ configs =
+ GetGLXVisualConfigsFromFBConfigs(dmxScreen->fbconfigs,
+ dmxScreen->numFBConfigs,
+ dmxScreen->beVisuals,
+ dmxScreen->beNumVisuals,
+ dmxScreen->glxVisuals,
+ dmxScreen->numGlxVisuals,
+ &nconfigs);
+ } else {
+ configs = dmxScreen->glxVisuals;
+ nconfigs = dmxScreen->numGlxVisuals;
+ }
+
+ configprivs = xalloc(dmxScreen->beNumVisuals *
+ sizeof(dmxGlxVisualPrivate*));
+
+ if (configs != NULL && configprivs != NULL) {
+
+ /* Initialize our private info for each visual
+ * (currently only x_visual_depth and x_visual_class)
+ */
+ for (i = 0; i < nconfigs; i++) {
+
+ configprivs[i] = (dmxGlxVisualPrivate *)
+ xalloc(sizeof(dmxGlxVisualPrivate));
+ configprivs[i]->x_visual_depth = 0;
+ configprivs[i]->x_visual_class = 0;
+
+ /* Find the visual depth */
+ if (configs[i].vid > 0) {
+ int j;
+ for (j = 0; j < dmxScreen->beNumVisuals; j++) {
+ if (dmxScreen->beVisuals[j].visualid ==
+ configs[i].vid) {
+ configprivs[i]->x_visual_depth =
+ dmxScreen->beVisuals[j].depth;
+ configprivs[i]->x_visual_class =
+ dmxScreen->beVisuals[j].class;
+ break;
+ }
+ }
+ }
+ }
+
+ /* Hand out the glx configs to glx extension */
+ GlxSetVisualConfigs(nconfigs, configs, (void**)configprivs);
+ }
+ }
+#endif /* GLXEXT */
+
+ AddScreen(dmxScreenInit, argc, argv);
+ }
+
+ /* Compute origin information. */
+ dmxInitOrigins();
+
+ /* Compute overlap information. */
+ dmxInitOverlap();
+
+ /* Make sure there is a global width/height available */
+ dmxComputeWidthHeight(DMX_NO_RECOMPUTE_BOUNDING_BOX);
+
+ /* FIXME: The following is temporarily placed here. When the DMX
+ * extension is available, it will be move there.
+ */
+ dmxInitFonts();
+
+#ifdef RENDER
+ /* Initialize the render extension */
+ if (!noRenderExtension)
+ dmxInitRender();
+#endif
+
+ /* Initialized things that need timer hooks */
+ dmxStatInit();
+ dmxSyncInit(); /* Calls RegisterBlockAndWakeupHandlers */
+
+ dmxLog(dmxInfo, "Shadow framebuffer support %s\n",
+ dmxShadowFB ? "enabled" : "disabled");
+}
+
+/* RATS: Assuming the fp string (which comes from the command-line argv
+ vector) is NULL-terminated, the buffer is large enough for the
+ strcpy. */
+static void dmxSetDefaultFontPath(char *fp)
+{
+ int fplen = strlen(fp) + 1;
+
+ if (dmxFontPath) {
+ int len;
+
+ len = strlen(dmxFontPath);
+ dmxFontPath = xrealloc(dmxFontPath, len+fplen+1);
+ dmxFontPath[len] = ',';
+ strncpy(&dmxFontPath[len+1], fp, fplen);
+ } else {
+ dmxFontPath = xalloc(fplen);
+ strncpy(dmxFontPath, fp, fplen);
+ }
+
+ defaultFontPath = dmxFontPath;
+}
+
+/** This function is called in Xserver/os/utils.c from \a AbortServer().
+ * We must ensure that backend and console state is restored in the
+ * event the server shutdown wasn't clean. */
+void AbortDDX(void)
+{
+ int i;
+
+ for (i=0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+
+ if (dmxScreen->beDisplay) XCloseDisplay(dmxScreen->beDisplay);
+ dmxScreen->beDisplay = NULL;
+ }
+}
+
+/** This function is called in Xserver/dix/main.c from \a main() when
+ * dispatchException & DE_TERMINATE (which is the only way to exit the
+ * main loop without an interruption. */
+void ddxGiveUp(void)
+{
+ AbortDDX();
+}
+
+/** This function is called in Xserver/os/osinit.c from \a OsInit(). */
+void OsVendorInit(void)
+{
+}
+
+/** This function is called in Xserver/os/utils.c from \a FatalError()
+ * and \a VFatalError(). (Note that setting the function pointer \a
+ * OsVendorVErrorFProc will cause \a VErrorF() (which is called by the
+ * two routines mentioned here, as well as by others) to use the
+ * referenced routine instead of \a vfprintf().) */
+void OsVendorFatalError(void)
+{
+}
+
+/** This funciton is called by InitGlobals from Xserver/os/utils.c to
+ * initialize any ddx specific globals at a very early point in the
+ * server startup. */
+void ddxInitGlobals(void)
+{
+}
+
+/** Process our command line arguments. */
+int ddxProcessArgument(int argc, char *argv[], int i)
+{
+ int retval = 0;
+
+ if (!strcmp(argv[i], "-display")) {
+ if (++i < argc) dmxConfigStoreDisplay(argv[i]);
+ retval = 2;
+ } else if (!strcmp(argv[i], "-inputfrom") || !strcmp(argv[i], "-input")) {
+ if (++i < argc) dmxConfigStoreInput(argv[i]);
+ retval = 2;
+ } else if (!strcmp(argv[i], "-xinputfrom") || !strcmp(argv[i],"-xinput")) {
+ if (++i < argc) dmxConfigStoreXInput(argv[i]);
+ retval = 2;
+ } else if (!strcmp(argv[i], "-noshadowfb")) {
+ dmxLog(dmxWarning,
+ "-noshadowfb has been deprecated "
+ "since it is now the default\n");
+ dmxShadowFB = FALSE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-nomulticursor")) {
+ dmxCursorNoMulti();
+ retval = 1;
+ } else if (!strcmp(argv[i], "-shadowfb")) {
+ dmxShadowFB = TRUE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-configfile")) {
+ if (++i < argc) dmxConfigStoreFile(argv[i]);
+ retval = 2;
+ } else if (!strcmp(argv[i], "-config")) {
+ if (++i < argc) dmxConfigStoreConfig(argv[i]);
+ retval = 2;
+ } else if (!strcmp(argv[i], "-fontpath")) {
+ if (++i < argc) dmxSetDefaultFontPath(argv[i]);
+ retval = 2;
+ } else if (!strcmp(argv[i], "-stat")) {
+ if ((i += 2) < argc) dmxStatActivate(argv[i-1], argv[i]);
+ retval = 3;
+ } else if (!strcmp(argv[i], "-syncbatch")) {
+ if (++i < argc) dmxSyncActivate(argv[i]);
+ retval = 2;
+ } else if (!strcmp(argv[i], "-nooffscreenopt")) {
+ dmxOffScreenOpt = FALSE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-nosubdivprims")) {
+ dmxSubdividePrimitives = FALSE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-nowindowopt")) {
+ dmxLazyWindowCreation = FALSE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-noxkb")) {
+ dmxUseXKB = FALSE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-depth")) {
+ if (++i < argc) dmxDepth = atoi(argv[i]);
+ retval = 2;
+ } else if (!strcmp(argv[i], "-norender")) {
+ noRenderExtension = TRUE;
+ retval = 1;
+#ifdef GLXEXT
+ } else if (!strcmp(argv[i], "-noglxproxy")) {
+ dmxGLXProxy = FALSE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-noglxswapgroup")) {
+ dmxGLXSwapGroupSupport = FALSE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-glxsyncswap")) {
+ dmxGLXSyncSwap = TRUE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-glxfinishswap")) {
+ dmxGLXFinishSwap = TRUE;
+ retval = 1;
+#endif
+ } else if (!strcmp(argv[i], "-ignorebadfontpaths")) {
+ dmxIgnoreBadFontPaths = TRUE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-addremovescreens")) {
+ dmxAddRemoveScreens = TRUE;
+ retval = 1;
+ } else if (!strcmp(argv[i], "-param")) {
+ if ((i += 2) < argc) {
+ if (!strcasecmp(argv[i-1], "xkbrules"))
+ dmxConfigSetXkbRules(argv[i]);
+ else if (!strcasecmp(argv[i-1], "xkbmodel"))
+ dmxConfigSetXkbModel(argv[i]);
+ else if (!strcasecmp(argv[i-1], "xkblayout"))
+ dmxConfigSetXkbLayout(argv[i]);
+ else if (!strcasecmp(argv[i-1], "xkbvariant"))
+ dmxConfigSetXkbVariant(argv[i]);
+ else if (!strcasecmp(argv[i-1], "xkboptions"))
+ dmxConfigSetXkbOptions(argv[i]);
+ else
+ dmxLog(dmxWarning,
+ "-param requires: XkbRules, XkbModel, XkbLayout,"
+ " XkbVariant, or XkbOptions\n");
+ }
+ retval = 3;
+ }
+ if (!serverGeneration) dmxConfigSetMaxScreens();
+ return retval;
+}
+
+/** Provide succinct usage information for the DMX server. */
+void ddxUseMsg(void)
+{
+ ErrorF("\n\nDevice Dependent Usage:\n");
+ ErrorF("-display string Specify the back-end display(s)\n");
+ ErrorF("-input string Specify input source for core device\n");
+ ErrorF("-xinput string Specify input source for XInput device\n");
+ ErrorF("-shadowfb Enable shadow frame buffer\n");
+ ErrorF("-configfile file Read from a configuration file\n");
+ ErrorF("-config config Select a specific configuration\n");
+ ErrorF("-nomulticursor Turn of multiple cursor support\n");
+ ErrorF("-fontpath Sets the default font path\n");
+ ErrorF("-stat inter scrns Print out performance statistics\n");
+ ErrorF("-syncbatch inter Set interval for XSync batching\n");
+ ErrorF("-nooffscreenopt Disable offscreen optimization\n");
+ ErrorF("-nosubdivprims Disable primitive subdivision\n");
+ ErrorF(" optimization\n");
+ ErrorF("-nowindowopt Disable lazy window creation optimization\n");
+ ErrorF("-noxkb Disable use of the XKB extension with\n");
+ ErrorF(" backend displays (cf. -kb).\n");
+ ErrorF("-depth Specify the default root window depth\n");
+ ErrorF("-norender Disable RENDER extension support\n");
+#ifdef GLXEXT
+ ErrorF("-noglxproxy Disable GLX Proxy\n");
+ ErrorF("-noglxswapgroup Disable swap group and swap barrier\n");
+ ErrorF(" extensions in GLX proxy\n");
+ ErrorF("-glxsyncswap Force XSync after swap buffers\n");
+ ErrorF("-glxfinishswap Force glFinish after swap buffers\n");
+#endif
+ ErrorF("-ignorebadfontpaths Ignore bad font paths during initialization\n");
+ ErrorF("-addremovescreens Enable dynamic screen addition/removal\n");
+ ErrorF("-param ... Specify configuration parameters (e.g.,\n");
+ ErrorF(" XkbRules, XkbModel, XkbLayout, etc.)\n");
+ ErrorF("\n");
+ ErrorF(" If the -input string matches a -display string, then input\n"
+ " is taken from that backend display. (XInput cannot be taken\n"
+ " from a backend display.) Placing \",console\" after the\n"
+ " display name will force a console window to be opened on\n"
+ " that display in addition to the backend input. This is\n"
+ " useful if the backend window does not cover the whole\n"
+ " physical display.\n\n");
+
+ ErrorF(" Otherwise, if the -input or -xinput string specifies another\n"
+ " X display, then a console window will be created on that\n"
+ " display. Placing \",windows\" or \",nowindows\" after the\n"
+ " display name will control the display of window outlines in\n"
+ " the console.\n\n");
+
+ ErrorF(" -input or -xinput dummy specifies no input.\n");
+ ErrorF(" -input or -xinput local specifies the use of a raw keyboard,\n"
+ " mouse, or other (extension) device:\n"
+ " -input local,kbd,ps2 will use a ps2 mouse\n"
+ " -input local,kbd,ms will use a serial mouse\n"
+ " -input local,usb-kbd,usb-mou will use USB devices \n"
+ " -xinput local,usb-oth will use a non-mouse and\n"
+ " non-keyboard USB device with XInput\n\n");
+
+ ErrorF(" Special Keys:\n");
+ ErrorF(" Ctrl-Alt-g Server grab/ungrab (console only)\n");
+ ErrorF(" Ctrl-Alt-f Fine (1-pixel) mouse mode (console only)\n");
+ ErrorF(" Ctrl-Alt-q Quit (core devices only)\n");
+ ErrorF(" Ctrl-Alt-F* Switch to VC (local only)\n");
+}
+
+#ifdef DDXTIME
+/** Return wall-clock time in milliseconds. */
+CARD32 GetTimeInMillis(void)
+{
+ struct timeval tp;
+
+ gettimeofday(&tp, 0);
+ return tp.tv_sec * 1000 + tp.tv_usec / 1000;
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxinit.h b/nx-X11/programs/Xserver/hw/dmx/dmxinit.h
new file mode 100644
index 000000000..e5bdb9957
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxinit.h
@@ -0,0 +1,51 @@
+/* $XFree86$ */
+/*
+ * Copyright 2004 Red Hat Inc., Raleigh, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for initialization. \see dmxinit.c */
+
+#ifndef DMXINIT_H
+#define DMXINIT_H
+
+#include "scrnintstr.h"
+
+extern Bool dmxOpenDisplay(DMXScreenInfo *dmxScreen);
+extern void dmxSetErrorHandler(DMXScreenInfo *dmxScreen);
+extern void dmxCheckForWM(DMXScreenInfo *dmxScreen);
+extern void dmxGetScreenAttribs(DMXScreenInfo *dmxScreen);
+extern Bool dmxGetVisualInfo(DMXScreenInfo *dmxScreen);
+extern void dmxGetColormaps(DMXScreenInfo *dmxScreen);
+extern void dmxGetPixmapFormats(DMXScreenInfo *dmxScreen);
+
+#endif /* DMXINIT_H */
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxinput.c b/nx-X11/programs/Xserver/hw/dmx/dmxinput.c
new file mode 100644
index 000000000..7c376dee4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxinput.c
@@ -0,0 +1,105 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001,2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * David H. Dawes <dawes@xfree86.org>
+ * Kevin E. Martin <kem@redhat.com>
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Provide the main entry points for input initialization and processing
+ * that arequired by the dix layer.
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxlog.h"
+#include "dmxinput.h"
+
+#include "inputstr.h"
+#include "input.h"
+
+/** Returns TRUE if the key is a valid modifier. For PC-class
+ * keyboards, all keys can be used as modifiers, so return TRUE
+ * always. */
+Bool LegalModifier(unsigned int key, DevicePtr pDev)
+{
+ return TRUE;
+}
+
+/** Called from dix/main.c on each server generation to initialize
+ * inputs. All the work is done in dmxInputInit. \see
+ * dmxInputInit() */
+void InitInput(int argc, char **argv)
+{
+ int i;
+ DMXInputInfo *dmxInput;
+
+ if (!dmxNumInputs)
+ dmxLog(dmxFatal, "InitInput: no inputs specified\n");
+
+ for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++)
+ dmxInputInit(dmxInput);
+ if (!dmxeqInitialized()) {
+ dmxLog(dmxWarning, "Use keyboard/mouse pair with the first -input\n");
+ dmxLog(dmxFatal, "At least one core keyboard/mouse pair required\n");
+ }
+}
+
+/** Called from dix/dispatch.c in Dispatch() whenever input events
+ * require processing. All the work is done in the lower level
+ * routines. */
+void ProcessInputEvents(void)
+{
+ int i;
+ DMXInputInfo *dmxInput;
+
+ for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++)
+ if (!dmxInput->detached && dmxInput->processInputEvents)
+ dmxInput->processInputEvents(dmxInput);
+}
+
+/** This routine is called from #dmxwindow.c whenever the layout of
+ * windows on the display might have changed. This information is used
+ * by input drivers (currently only the console driver) that provide
+ * information about window layout to the user. */
+void dmxUpdateWindowInfo(DMXUpdateType type, WindowPtr pWindow)
+{
+ int i;
+ DMXInputInfo *dmxInput;
+
+ for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++)
+ if (!dmxInput->detached && dmxInput->updateWindowInfo)
+ dmxInput->updateWindowInfo(dmxInput, type, pWindow);
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxinput.h b/nx-X11/programs/Xserver/hw/dmx/dmxinput.h
new file mode 100644
index 000000000..59fa823d3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxinput.h
@@ -0,0 +1,163 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001,2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * David H. Dawes <dawes@xfree86.org>
+ * Kevin E. Martin <kem@redhat.com>
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * This file provides access to:
+ * - global variables available to all hw/dmx routines, and
+ * - enumerations and typedefs needed by input routines in hw/dmx (and
+ * hw/dmx/input).
+ *
+ * The goal is that no files in hw/dmx should include header files from
+ * hw/dmx/input -- the interface defined here should be the only
+ * interface exported to the hw/dmx layer. \see input/dmxinputinit.c.
+ */
+
+#ifndef DMXINPUT_H
+#define DMXINPUT_H
+
+/** Maximum number of file descriptors for SIGIO handling */
+#define DMX_MAX_SIGIO_FDS 4
+
+struct _DMXInputInfo;
+
+/** Reason why window layout was updated. */
+typedef enum {
+ DMX_UPDATE_REALIZE, /**< Window realized */
+ DMX_UPDATE_UNREALIZE, /**< Window unrealized */
+ DMX_UPDATE_RESTACK, /**< Stacking order changed */
+ DMX_UPDATE_COPY, /**< Window copied */
+ DMX_UPDATE_RESIZE, /**< Window resized */
+ DMX_UPDATE_REPARENT /**< Window reparented */
+} DMXUpdateType;
+
+typedef void (*ProcessInputEventsProc)(struct _DMXInputInfo *);
+typedef void (*UpdateWindowInfoProc)(struct _DMXInputInfo *,
+ DMXUpdateType, WindowPtr);
+
+/** An opaque structure that is only exposed in the dmx/input layer. */
+typedef struct _DMXLocalInputInfo *DMXLocalInputInfoPtr;
+
+/** State of the SIGIO engine */
+typedef enum {
+ DMX_NOSIGIO = 0, /**< Device does not use SIGIO at all. */
+ DMX_USESIGIO, /**< Device can use SIGIO, but is not
+ * (e.g., because the VT is switch
+ * away). */
+ DMX_ACTIVESIGIO /**< Device is currently using SIGIO. */
+} dmxSigioState;
+
+/** DMXInputInfo is typedef'd in #dmx.h so that all routines can have
+ * access to the global pointers. However, the elements are only
+ * available to input-related routines. */
+struct _DMXInputInfo {
+ const char *name; /**< Name of input display or device
+ * (from command line or config
+ * file) */
+ Bool freename; /**< If true, free name on destroy */
+ Bool detached; /**< If true, input screen is detached */
+ int inputIdx; /**< Index into #dmxInputs global */
+ int scrnIdx; /**< Index into #dmxScreens global */
+ Bool core; /**< If True, initialize these
+ * devices as devices that send core
+ * events */
+ Bool console; /**< True if console and backend
+ * input share the same backend
+ * display */
+
+ Bool windows; /**< True if window outlines are
+ * draw in console */
+
+ ProcessInputEventsProc processInputEvents;
+ UpdateWindowInfoProc updateWindowInfo;
+
+ /* Local input information */
+ dmxSigioState sigioState; /**< Current stat */
+ int sigioFdCount; /**< Number of fds in use */
+ int sigioFd[DMX_MAX_SIGIO_FDS]; /**< List of fds */
+ Bool sigioAdded[DMX_MAX_SIGIO_FDS]; /**< Active fds */
+
+
+ /** True if a VT switch is pending, but has not yet happened. */
+ int vt_switch_pending;
+
+ /** True if a VT switch has happened. */
+ int vt_switched;
+
+ /** Number of devices handled in this _DMXInputInfo structure. */
+ int numDevs;
+
+ /** List of actual input devices. Each _DMXInputInfo structure can
+ * refer to more than one device. For example, the keyboard and the
+ * pointer of a backend display; or all of the XInput extension
+ * devices on a backend display. */
+ DMXLocalInputInfoPtr *devs;
+
+ char *keycodes; /**< XKB keycodes from command line */
+ char *symbols; /**< XKB symbols from command line */
+ char *geometry; /**< XKB geometry from command line */
+};
+
+extern int dmxNumInputs; /**< Number of #dmxInputs */
+extern DMXInputInfo *dmxInputs; /**< List of inputs */
+
+extern void dmxInputInit(DMXInputInfo *dmxInput);
+extern void dmxInputReInit(DMXInputInfo *dmxInput);
+extern void dmxInputLateReInit(DMXInputInfo *dmxInput);
+extern void dmxInputFree(DMXInputInfo *dmxInput);
+extern void dmxInputLogDevices(void);
+extern void dmxUpdateWindowInfo(DMXUpdateType type, WindowPtr pWindow);
+
+/* These functions are defined in input/dmxeq.c */
+extern Bool dmxeqInitialized(void);
+extern void dmxeqEnqueue(xEvent *e);
+extern void dmxeqSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
+
+/* This type is used in input/dmxevents.c. Also, these functions are
+ * defined in input/dmxevents.c */
+typedef enum {
+ DMX_NO_BLOCK = 0,
+ DMX_BLOCK = 1
+} DMXBlockType;
+
+extern void dmxGetGlobalPosition(int *x, int *y);
+extern DMXScreenInfo *dmxFindFirstScreen(int x, int y);
+extern void dmxCoreMotion(int x, int y, int delta,
+ DMXBlockType block);
+
+/* Support for dynamic addition of inputs. This functions is defined in
+ * config/dmxconfig.c */
+extern DMXInputInfo *dmxConfigAddInput(const char *name, int core);
+#endif /* DMXINPUT_H */
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxlog.c b/nx-X11/programs/Xserver/hw/dmx/dmxlog.c
new file mode 100644
index 000000000..16d082daa
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxlog.c
@@ -0,0 +1,351 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * This file encapsulated all of the logging functions that are used by
+ * DMX for informational, warning, and error messages. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxlog.h"
+#include "dmxinput.h"
+#ifdef XINPUT
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#endif
+
+static dmxLogLevel dmxCurrentLogLevel = dmxDebug;
+
+/** Set the default level for logging to #dmxLogLevel. Returns the
+ * previous log level. */
+dmxLogLevel dmxSetLogLevel(dmxLogLevel newLevel)
+{
+ dmxLogLevel oldLevel = dmxCurrentLogLevel;
+ if (newLevel > dmxFatal) newLevel = dmxFatal;
+ dmxCurrentLogLevel = newLevel;
+ return oldLevel;
+}
+
+/** Returns the log level set by #dmxLogLevel. */
+dmxLogLevel dmxGetLogLevel(void)
+{
+ return dmxCurrentLogLevel;
+}
+
+#ifdef DMX_LOG_STANDALONE
+/* When using this file as part of a stand-alone (i.e., non-X-Server
+ * program, then the ultimate output routines have to be defined. */
+
+/** Provide an ErrorF function when used stand-alone. */
+void ErrorF(const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ vfprintf(stderr, format, args); /* RATS: We assume the format string
+ * is trusted, since it is always
+ * from a log message in our code. */
+ va_end(args);
+}
+
+/** Provide an VFatalError function when used stand-alone. */
+static void VFatalError(const char *format, va_list args)
+{
+ vfprintf(stderr, format, args); /* RATS: We assume the format string
+ * is trusted, since it is always
+ * from a log message in our code. */
+ exit(1);
+}
+
+/** Provide an VErrorF function when used stand-alone. */
+void VErrorF(const char *format, va_list args)
+{
+ vfprintf(stderr, format, args); /* RATS: We assume the format string
+ * is trusted, since it is always
+ * from a log message in our code. */
+}
+#else
+/** This function was removed between XFree86 4.3.0 and XFree86 4.4.0. */
+extern void AbortServer(void);
+static void VFatalError(const char *format, va_list args)
+{
+ VErrorF(format, args);
+ ErrorF("\n");
+#ifdef DDXOSFATALERROR
+ OsVendorFatalError();
+#endif
+ AbortServer();
+ /*NOTREACHED*/
+}
+#endif
+
+/* Prints a consistent header for each line. */
+static void dmxHeader(dmxLogLevel logLevel, DMXInputInfo *dmxInput,
+ DMXScreenInfo *dmxScreen)
+{
+ const char *type = "??";
+
+ switch (logLevel) {
+ case dmxDebug: type = ".."; break;
+ case dmxInfo: type = "II"; break;
+ case dmxWarning: type = "**"; break;
+ case dmxError: type = "!!"; break;
+ case dmxFatal: type = "Fatal Error"; break;
+ }
+
+ if (dmxInput && dmxScreen) {
+ ErrorF("(%s) dmx[i%d/%s;o%d/%s]: ", type,
+ dmxInput->inputIdx, dmxInput->name,
+ dmxScreen->index, dmxScreen->name);
+ } else if (dmxScreen) {
+ ErrorF("(%s) dmx[o%d/%s]: ", type,
+ dmxScreen->index, dmxScreen->name);
+ } else if (dmxInput) {
+ const char *pt = strchr(dmxInput->name, ',');
+ int len = (pt
+ ? (size_t)(pt-dmxInput->name)
+ : strlen(dmxInput->name));
+
+ ErrorF("(%s) dmx[i%d/%*.*s]: ", type,
+ dmxInput->inputIdx, len, len, dmxInput->name);
+ } else {
+ ErrorF("(%s) dmx: ", type);
+ }
+}
+
+/* Prints the error message with the appropriate low-level X output
+ * routine. */
+static void dmxMessage(dmxLogLevel logLevel, const char *format, va_list args)
+{
+ if (logLevel == dmxFatal || logLevel >= dmxCurrentLogLevel) {
+ if (logLevel == dmxFatal) VFatalError(format, args);
+ else VErrorF(format, args);
+ }
+}
+
+/** Log the specified message at the specified \a logLevel. \a format
+ * can be a printf-like format expression. */
+void dmxLog(dmxLogLevel logLevel, const char *format, ...)
+{
+ va_list args;
+
+ dmxHeader(logLevel, NULL, NULL);
+ va_start(args, format);
+ dmxMessage(logLevel, format, args);
+ va_end(args);
+}
+
+/** Continue a log message without printing the message prefix. */
+void dmxLogCont(dmxLogLevel logLevel, const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ dmxMessage(logLevel, format, args);
+ va_end(args);
+}
+
+#ifndef DMX_LOG_STANDALONE
+/** Log an informational message (at level #dmxInfo) related to ouput.
+ * The message prefix will contain backend information from \a
+ * dmxScreen. */
+void dmxLogOutput(DMXScreenInfo *dmxScreen, const char *format, ...)
+{
+ va_list args;
+
+ dmxHeader(dmxInfo, NULL, dmxScreen);
+ va_start(args, format);
+ dmxMessage(dmxInfo, format, args);
+ va_end(args);
+}
+
+/** Continue a message related to output without printing the message
+ * prefix. */
+void dmxLogOutputCont(DMXScreenInfo *dmxScreen, const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ dmxMessage(dmxInfo, format, args);
+ va_end(args);
+}
+
+/** Log a warning message (at level #dmxWarning) related to output.
+ * The message prefix will contain backend information from \a
+ * dmxScreen. */
+void dmxLogOutputWarning(DMXScreenInfo *dmxScreen, const char *format, ...)
+{
+ va_list args;
+
+ dmxHeader(dmxWarning, NULL, dmxScreen);
+ va_start(args, format);
+ dmxMessage(dmxWarning, format, args);
+ va_end(args);
+}
+
+/** Log an informational message (at level #dmxInfo) related to input.
+ * The message prefix will contain information from \a dmxInput. */
+void dmxLogInput(DMXInputInfo *dmxInput, const char *format, ...)
+{
+ va_list args;
+
+ dmxHeader(dmxInfo, dmxInput, NULL);
+ va_start(args, format);
+ dmxMessage(dmxInfo, format, args);
+ va_end(args);
+}
+
+/** Continue a message related to input without printing the message
+ * prefix. */
+void dmxLogInputCont(DMXInputInfo *dmxInput, const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ dmxMessage(dmxInfo, format, args);
+ va_end(args);
+}
+
+/** Print \a argc messages, each describing an element in \a argv. This
+ * is maingly for debugging purposes. */
+void dmxLogArgs(dmxLogLevel logLevel, int argc, char **argv)
+{
+ int i;
+ for (i = 0; i < argc; i++)
+ dmxLog(logLevel, " Arg[%d] = \"%s\"\n", i, argv[i]);
+}
+
+/** Print messages at level #dmxInfo describing the visuals in \a vi. */
+void dmxLogVisual(DMXScreenInfo *dmxScreen, XVisualInfo *vi, int defaultVisual)
+{
+ const char *class = "Unknown";
+
+ switch (vi->class) {
+ case StaticGray: class = "StaticGray "; break;
+ case GrayScale: class = "GrayScale "; break;
+ case StaticColor: class = "StaticColor"; break;
+ case PseudoColor: class = "PseudoColor"; break;
+ case TrueColor: class = "TrueColor "; break;
+ case DirectColor: class = "DirectColor"; break;
+ }
+
+ if (dmxScreen) {
+ dmxLogOutput(dmxScreen,
+ "0x%02x %s %2db %db/rgb %3d 0x%04x 0x%04x 0x%04x%s\n",
+ vi->visualid, class, vi->depth, vi->bits_per_rgb,
+ vi->colormap_size,
+ vi->red_mask, vi->green_mask, vi->blue_mask,
+ defaultVisual ? " *" : "");
+ } else {
+ dmxLog(dmxInfo,
+ " 0x%02x %s %2db %db/rgb %3d 0x%04x 0x%04x 0x%04x%s\n",
+ vi->visualid, class, vi->depth, vi->bits_per_rgb,
+ vi->colormap_size,
+ vi->red_mask, vi->green_mask, vi->blue_mask,
+ defaultVisual ? " *" : "");
+ }
+}
+
+#ifdef XINPUT
+/** Translate a (normalized) XInput event \a type into a human-readable
+ * string. */
+const char *dmxXInputEventName(int type)
+{
+ switch (type) {
+ case XI_DeviceValuator: return "XI_DeviceValuator";
+ case XI_DeviceKeyPress: return "XI_DeviceKeyPress";
+ case XI_DeviceKeyRelease: return "XI_DeviceKeyRelease";
+ case XI_DeviceButtonPress: return "XI_DeviceButtonPress";
+ case XI_DeviceButtonRelease: return "XI_DeviceButtonRelease";
+ case XI_DeviceMotionNotify: return "XI_DeviceMotionNotify";
+ case XI_DeviceFocusIn: return "XI_DeviceFocusIn";
+ case XI_DeviceFocusOut: return "XI_DeviceFocusOut";
+ case XI_ProximityIn: return "XI_ProximityIn";
+ case XI_ProximityOut: return "XI_ProximityOut";
+ case XI_DeviceStateNotify: return "XI_DeviceStateNotify";
+ case XI_DeviceMappingNotify: return "XI_DeviceMappingNotify";
+ case XI_ChangeDeviceNotify: return "XI_ChangeDeviceNotify";
+ case XI_DeviceKeystateNotify: return "XI_DeviceKeystateNotify";
+ case XI_DeviceButtonstateNotify: return "XI_DeviceButtonstateNotify";
+ default: return "unknown";
+ }
+}
+
+#endif
+#endif
+
+/** Translate an event \a type into a human-readable string. */
+const char *dmxEventName(int type)
+{
+ switch (type) {
+ case KeyPress: return "KeyPress";
+ case KeyRelease: return "KeyRelease";
+ case ButtonPress: return "ButtonPress";
+ case ButtonRelease: return "ButtonRelease";
+ case MotionNotify: return "MotionNotify";
+ case EnterNotify: return "EnterNotify";
+ case LeaveNotify: return "LeaveNotify";
+ case FocusIn: return "FocusIn";
+ case FocusOut: return "FocusOut";
+ case KeymapNotify: return "KeymapNotify";
+ case Expose: return "Expose";
+ case GraphicsExpose: return "GraphicsExpose";
+ case NoExpose: return "NoExpose";
+ case VisibilityNotify: return "VisibilityNotify";
+ case CreateNotify: return "CreateNotify";
+ case DestroyNotify: return "DestroyNotify";
+ case UnmapNotify: return "UnmapNotify";
+ case MapNotify: return "MapNotify";
+ case MapRequest: return "MapRequest";
+ case ReparentNotify: return "ReparentNotify";
+ case ConfigureNotify: return "ConfigureNotify";
+ case ConfigureRequest: return "ConfigureRequest";
+ case GravityNotify: return "GravityNotify";
+ case ResizeRequest: return "ResizeRequest";
+ case CirculateNotify: return "CirculateNotify";
+ case CirculateRequest: return "CirculateRequest";
+ case PropertyNotify: return "PropertyNotify";
+ case SelectionClear: return "SelectionClear";
+ case SelectionRequest: return "SelectionRequest";
+ case SelectionNotify: return "SelectionNotify";
+ case ColormapNotify: return "ColormapNotify";
+ case ClientMessage: return "ClientMessage";
+ case MappingNotify: return "MappingNotify";
+ default: return "<unknown>";
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxlog.h b/nx-X11/programs/Xserver/hw/dmx/dmxlog.h
new file mode 100644
index 000000000..6b9ec6005
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxlog.h
@@ -0,0 +1,79 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * This header is included by all files that need to use the DMX logging
+ * facilities. */
+
+#ifndef _DMXLOG_H_
+#define _DMXLOG_H_
+
+/** Logging levels -- output is tunable with #dmxSetLogLevel. */
+typedef enum {
+ dmxDebug, /**< Usually verbose debugging info */
+ dmxInfo, /**< Non-warning information */
+ dmxWarning, /**< A warning that may indicate DMX
+ * will not function as the user
+ * intends. */
+ dmxError, /**< A non-fatal error that probably
+ * indicates DMX will not function as
+ * desired.*/
+ dmxFatal /**< A fatal error that will cause DMX
+ * to shut down. */
+} dmxLogLevel;
+
+/* Logging functions used by Xserver/hw/dmx routines. */
+extern dmxLogLevel dmxSetLogLevel(dmxLogLevel newLevel);
+extern dmxLogLevel dmxGetLogLevel(void);
+extern void dmxLog(dmxLogLevel logLevel, const char *format, ...);
+extern void dmxLogCont(dmxLogLevel logLevel, const char *format, ...);
+extern const char *dmxEventName(int type);
+
+#ifndef DMX_LOG_STANDALONE
+extern void dmxLogOutput(DMXScreenInfo *dmxScreen, const char *format, ...);
+extern void dmxLogOutputCont(DMXScreenInfo *dmxScreen, const char *format,
+ ...);
+extern void dmxLogOutputWarning(DMXScreenInfo *dmxScreen, const char *format,
+ ...);
+extern void dmxLogInput(DMXInputInfo *dmxInput, const char *format, ...);
+extern void dmxLogInputCont(DMXInputInfo *dmxInput, const char *format, ...);
+extern void dmxLogArgs(dmxLogLevel logLevel, int argc, char **argv);
+extern void dmxLogVisual(DMXScreenInfo *dmxScreen, XVisualInfo *vi,
+ int defaultVisual);
+#ifdef XINPUT
+extern const char *dmxXInputEventName(int type);
+#endif
+#endif
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxpict.c b/nx-X11/programs/Xserver/hw/dmx/dmxpict.c
new file mode 100644
index 000000000..9a76a6696
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxpict.c
@@ -0,0 +1,1298 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * Provide support for the RENDER extension (version 0.8).
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxsync.h"
+#include "dmxpict.h"
+#include "dmxwindow.h"
+#include "dmxpixmap.h"
+
+#include "fb.h"
+#include "pixmapstr.h"
+#include "dixstruct.h"
+
+#include <X11/extensions/render.h>
+#include <X11/extensions/renderproto.h>
+#include "picture.h"
+#include "picturestr.h"
+#include "mipict.h"
+#include "fbpict.h"
+
+
+extern int RenderErrBase;
+extern int (*ProcRenderVector[RenderNumberRequests])(ClientPtr);
+
+static int (*dmxSaveRenderVector[RenderNumberRequests])(ClientPtr);
+
+
+static int dmxProcRenderCreateGlyphSet(ClientPtr client);
+static int dmxProcRenderFreeGlyphSet(ClientPtr client);
+static int dmxProcRenderAddGlyphs(ClientPtr client);
+static int dmxProcRenderFreeGlyphs(ClientPtr client);
+static int dmxProcRenderCompositeGlyphs(ClientPtr client);
+static int dmxProcRenderSetPictureTransform(ClientPtr client);
+static int dmxProcRenderSetPictureFilter(ClientPtr client);
+#if 0
+/* FIXME: Not (yet) supported */
+static int dmxProcRenderCreateCursor(ClientPtr client);
+static int dmxProcRenderCreateAnimCursor(ClientPtr client);
+#endif
+
+/** Catch errors that might occur when allocating Glyph Sets. Errors
+ * are saved in dmxGlyphLastError for later handling. */
+static int dmxGlyphLastError;
+static int dmxGlyphErrorHandler(Display *dpy, XErrorEvent *ev)
+{
+ dmxGlyphLastError = ev->error_code;
+ return 0;
+}
+
+
+/** Initialize the Proc Vector for the RENDER extension. The functions
+ * here cannot be handled by the mi layer RENDER hooks either because
+ * the required information is no longer available when it reaches the
+ * mi layer or no mi layer hooks exist. This function is called from
+ * InitOutput() since it should be initialized only once per server
+ * generation. */
+void dmxInitRender(void)
+{
+ int i;
+
+ for (i = 0; i < RenderNumberRequests; i++)
+ dmxSaveRenderVector[i] = ProcRenderVector[i];
+
+ ProcRenderVector[X_RenderCreateGlyphSet]
+ = dmxProcRenderCreateGlyphSet;
+ ProcRenderVector[X_RenderFreeGlyphSet]
+ = dmxProcRenderFreeGlyphSet;
+ ProcRenderVector[X_RenderAddGlyphs]
+ = dmxProcRenderAddGlyphs;
+ ProcRenderVector[X_RenderFreeGlyphs]
+ = dmxProcRenderFreeGlyphs;
+ ProcRenderVector[X_RenderCompositeGlyphs8]
+ = dmxProcRenderCompositeGlyphs;
+ ProcRenderVector[X_RenderCompositeGlyphs16]
+ = dmxProcRenderCompositeGlyphs;
+ ProcRenderVector[X_RenderCompositeGlyphs32]
+ = dmxProcRenderCompositeGlyphs;
+ ProcRenderVector[X_RenderSetPictureTransform]
+ = dmxProcRenderSetPictureTransform;
+ ProcRenderVector[X_RenderSetPictureFilter]
+ = dmxProcRenderSetPictureFilter;
+}
+
+/** Reset the Proc Vector for the RENDER extension back to the original
+ * functions. This function is called from dmxCloseScreen() during the
+ * server reset (only for screen #0). */
+void dmxResetRender(void)
+{
+ int i;
+
+ for (i = 0; i < RenderNumberRequests; i++)
+ ProcRenderVector[i] = dmxSaveRenderVector[i];
+}
+
+/** Initialize the RENDER extension, allocate the picture privates and
+ * wrap mi function hooks. If the shadow frame buffer is used, then
+ * call the appropriate fb initialization function. */
+Bool dmxPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ PictureScreenPtr ps;
+
+ /* The shadow framebuffer only relies on FB to be initialized */
+ if (dmxShadowFB) return fbPictureInit(pScreen, formats, nformats);
+
+ if (!miPictureInit(pScreen, formats, nformats))
+ return FALSE;
+
+ if (!AllocatePicturePrivate(pScreen, dmxPictPrivateIndex,
+ sizeof(dmxPictPrivRec)))
+ return FALSE;
+
+ ps = GetPictureScreen(pScreen);
+
+ DMX_WRAP(CreatePicture, dmxCreatePicture, dmxScreen, ps);
+ DMX_WRAP(DestroyPicture, dmxDestroyPicture, dmxScreen, ps);
+
+ DMX_WRAP(ChangePictureClip, dmxChangePictureClip, dmxScreen, ps);
+ DMX_WRAP(DestroyPictureClip, dmxDestroyPictureClip, dmxScreen, ps);
+
+ DMX_WRAP(ChangePicture, dmxChangePicture, dmxScreen, ps);
+ DMX_WRAP(ValidatePicture, dmxValidatePicture, dmxScreen, ps);
+
+ DMX_WRAP(Composite, dmxComposite, dmxScreen, ps);
+ DMX_WRAP(Glyphs, dmxGlyphs, dmxScreen, ps);
+ DMX_WRAP(CompositeRects, dmxCompositeRects, dmxScreen, ps);
+
+ DMX_WRAP(Trapezoids, dmxTrapezoids, dmxScreen, ps);
+ DMX_WRAP(Triangles, dmxTriangles, dmxScreen, ps);
+ DMX_WRAP(TriStrip, dmxTriStrip, dmxScreen, ps);
+ DMX_WRAP(TriFan, dmxTriFan, dmxScreen, ps);
+
+ return TRUE;
+}
+
+
+/** Find the appropriate format on the requested screen given the
+ * internal format requested. The list of formats is searched
+ * sequentially as the XRenderFindFormat() function does not always
+ * find the appropriate format when a specific format is requested. */
+static XRenderPictFormat *dmxFindFormat(DMXScreenInfo *dmxScreen,
+ PictFormatPtr pFmt)
+{
+ XRenderPictFormat *pFormat = NULL;
+ int i = 0;
+
+ if (!pFmt || !dmxScreen->beDisplay) return pFormat;
+
+ while (1) {
+ pFormat = XRenderFindFormat(dmxScreen->beDisplay, 0, 0, i++);
+ if (!pFormat) break;
+
+ if (pFormat->type != pFmt->type) continue;
+ if (pFormat->depth != pFmt->depth) continue;
+ if (pFormat->direct.red != pFmt->direct.red) continue;
+ if (pFormat->direct.redMask != pFmt->direct.redMask) continue;
+ if (pFormat->direct.green != pFmt->direct.green) continue;
+ if (pFormat->direct.greenMask != pFmt->direct.greenMask) continue;
+ if (pFormat->direct.blue != pFmt->direct.blue) continue;
+ if (pFormat->direct.blueMask != pFmt->direct.blueMask) continue;
+ if (pFormat->direct.alpha != pFmt->direct.alpha) continue;
+ if (pFormat->direct.alphaMask != pFmt->direct.alphaMask) continue;
+
+ /* We have a match! */
+ break;
+ }
+
+ return pFormat;
+}
+
+/** Free \a glyphSet on back-end screen number \a idx. */
+Bool dmxBEFreeGlyphSet(ScreenPtr pScreen, GlyphSetPtr glyphSet)
+{
+ dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
+ int idx = pScreen->myNum;
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+
+ if (glyphPriv->glyphSets[idx]) {
+ XRenderFreeGlyphSet(dmxScreen->beDisplay, glyphPriv->glyphSets[idx]);
+ glyphPriv->glyphSets[idx] = (GlyphSet)0;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/** Create a Glyph Set on each screen. Save the glyphset ID from each
+ * screen in the Glyph Set's private structure. Fail if the format
+ * requested is not available or if the Glyph Set cannot be created on
+ * the screen. */
+static int dmxProcRenderCreateGlyphSet(ClientPtr client)
+{
+ int ret;
+ REQUEST(xRenderCreateGlyphSetReq);
+
+ ret = dmxSaveRenderVector[stuff->renderReqType](client);
+
+ if (ret == Success) {
+ int (*oldErrorHandler)(Display *, XErrorEvent *);
+ GlyphSetPtr glyphSet;
+ dmxGlyphPrivPtr glyphPriv;
+ int i;
+ PictFormatPtr pFmt;
+ XRenderPictFormat *pFormat;
+
+ /* Look up glyphSet that was just created ???? */
+ /* Store glyphsets from backends in glyphSet->devPrivate ????? */
+ /* Make sure we handle all errors here!! */
+
+ glyphSet = SecurityLookupIDByType(client, stuff->gsid, GlyphSetType,
+ SecurityDestroyAccess);
+ glyphPriv = xalloc(sizeof(dmxGlyphPrivRec));
+ if (!glyphPriv) return BadAlloc;
+ glyphPriv->glyphSets = NULL;
+ MAXSCREENSALLOC_RETURN(glyphPriv->glyphSets, BadAlloc);
+ DMX_SET_GLYPH_PRIV(glyphSet, glyphPriv);
+
+ pFmt = SecurityLookupIDByType(client, stuff->format, PictFormatType,
+ SecurityReadAccess);
+
+ oldErrorHandler = XSetErrorHandler(dmxGlyphErrorHandler);
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+
+ if (!dmxScreen->beDisplay) {
+ glyphPriv->glyphSets[i] = 0;
+ continue;
+ }
+
+ pFormat = dmxFindFormat(dmxScreen, pFmt);
+ if (!pFormat) {
+ int j;
+
+ /* Free the glyph sets we've allocated thus far */
+ for (j = 0; j < i; j++)
+ dmxBEFreeGlyphSet(screenInfo.screens[j], glyphSet);
+
+ /* Free the resource created by render */
+ FreeResource(stuff->gsid, RT_NONE);
+
+ ret = BadMatch;
+ break;
+ }
+
+ /* Catch when this fails */
+ glyphPriv->glyphSets[i]
+ = XRenderCreateGlyphSet(dmxScreen->beDisplay, pFormat);
+
+ if (dmxGlyphLastError) {
+ int j;
+
+ /* Free the glyph sets we've allocated thus far */
+ for (j = 0; j < i; j++)
+ dmxBEFreeGlyphSet(screenInfo.screens[j], glyphSet);
+
+ /* Free the resource created by render */
+ FreeResource(stuff->gsid, RT_NONE);
+
+ ret = dmxGlyphLastError;
+ break;
+ }
+ }
+
+ XSetErrorHandler(oldErrorHandler);
+ }
+
+ return ret;
+}
+
+/** Free the previously allocated Glyph Sets for each screen. */
+static int dmxProcRenderFreeGlyphSet(ClientPtr client)
+{
+ GlyphSetPtr glyphSet;
+ REQUEST(xRenderFreeGlyphSetReq);
+
+ REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
+ glyphSet = SecurityLookupIDByType(client, stuff->glyphset, GlyphSetType,
+ SecurityDestroyAccess);
+
+ if (glyphSet && glyphSet->refcnt == 1) {
+ dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
+ int i;
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+
+ if (dmxScreen->beDisplay) {
+ if (dmxBEFreeGlyphSet(screenInfo.screens[i], glyphSet))
+ dmxSync(dmxScreen, FALSE);
+ }
+ }
+
+ MAXSCREENSFREE(glyphPriv->glyphSets);
+ xfree(glyphPriv);
+ DMX_SET_GLYPH_PRIV(glyphSet, NULL);
+ }
+
+ return dmxSaveRenderVector[stuff->renderReqType](client);
+}
+
+/** Add glyphs to the Glyph Set on each screen. */
+static int dmxProcRenderAddGlyphs(ClientPtr client)
+{
+ int ret;
+ REQUEST(xRenderAddGlyphsReq);
+
+ ret = dmxSaveRenderVector[stuff->renderReqType](client);
+
+ if (ret == Success) {
+ GlyphSetPtr glyphSet;
+ dmxGlyphPrivPtr glyphPriv;
+ int i;
+ int nglyphs;
+ CARD32 *gids;
+ Glyph *gidsCopy;
+ xGlyphInfo *gi;
+ CARD8 *bits;
+ int nbytes;
+
+ glyphSet = SecurityLookupIDByType(client, stuff->glyphset,
+ GlyphSetType, SecurityReadAccess);
+ glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
+
+ nglyphs = stuff->nglyphs;
+ gids = (CARD32 *)(stuff + 1);
+ gi = (xGlyphInfo *)(gids + nglyphs);
+ bits = (CARD8 *)(gi + nglyphs);
+ nbytes = ((stuff->length << 2) -
+ sizeof(xRenderAddGlyphsReq) -
+ (sizeof(CARD32) + sizeof(xGlyphInfo)) * nglyphs);
+
+ gidsCopy = xalloc(sizeof(*gidsCopy) * nglyphs);
+ for (i = 0; i < nglyphs; i++) gidsCopy[i] = gids[i];
+
+ /* FIXME: Will this ever fail? */
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+
+ if (dmxScreen->beDisplay) {
+ XRenderAddGlyphs(dmxScreen->beDisplay,
+ glyphPriv->glyphSets[i],
+ gidsCopy,
+ (XGlyphInfo *)gi,
+ nglyphs,
+ (char *)bits,
+ nbytes);
+ dmxSync(dmxScreen, FALSE);
+ }
+ }
+ xfree(gidsCopy);
+ }
+
+ return ret;
+}
+
+/** Free glyphs from the Glyph Set for each screen. */
+static int dmxProcRenderFreeGlyphs(ClientPtr client)
+{
+ GlyphSetPtr glyphSet;
+ REQUEST(xRenderFreeGlyphsReq);
+
+ REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq);
+ glyphSet = SecurityLookupIDByType(client, stuff->glyphset, GlyphSetType,
+ SecurityWriteAccess);
+
+ if (glyphSet) {
+ dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
+ int i;
+ int nglyphs;
+ Glyph *gids;
+
+ nglyphs = ((client->req_len << 2) - sizeof(xRenderFreeGlyphsReq)) >> 2;
+ if (nglyphs) {
+ gids = xalloc(sizeof(*gids) * nglyphs);
+ for (i = 0; i < nglyphs; i++)
+ gids[i] = ((CARD32 *)(stuff + 1))[i];
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+
+ if (dmxScreen->beDisplay) {
+ XRenderFreeGlyphs(dmxScreen->beDisplay,
+ glyphPriv->glyphSets[i], gids, nglyphs);
+ dmxSync(dmxScreen, FALSE);
+ }
+ }
+ xfree(gids);
+ }
+ }
+
+ return dmxSaveRenderVector[stuff->renderReqType](client);
+}
+
+/** Composite glyphs on each screen into the requested picture. If
+ * either the src or dest picture has not been allocated due to lazy
+ * window creation, this request will gracefully return. */
+static int dmxProcRenderCompositeGlyphs(ClientPtr client)
+{
+ int ret;
+ REQUEST(xRenderCompositeGlyphsReq);
+
+ ret = dmxSaveRenderVector[stuff->renderReqType](client);
+
+ /* For the following to work with PanoramiX, it assumes that Render
+ * wraps the ProcRenderVector after dmxRenderInit has been called.
+ */
+ if (ret == Success) {
+ PicturePtr pSrc;
+ dmxPictPrivPtr pSrcPriv;
+ PicturePtr pDst;
+ dmxPictPrivPtr pDstPriv;
+ PictFormatPtr pFmt;
+ XRenderPictFormat *pFormat;
+ int size;
+
+ int scrnNum;
+ DMXScreenInfo *dmxScreen;
+
+ CARD8 *buffer;
+ CARD8 *end;
+ int space;
+
+ int nglyph;
+ char *glyphs;
+ char *curGlyph;
+
+ xGlyphElt *elt;
+ int nelt;
+ XGlyphElt8 *elts;
+ XGlyphElt8 *curElt;
+
+ GlyphSetPtr glyphSet;
+ dmxGlyphPrivPtr glyphPriv;
+
+ pSrc = SecurityLookupIDByType(client, stuff->src, PictureType,
+ SecurityReadAccess);
+ pSrcPriv = DMX_GET_PICT_PRIV(pSrc);
+ if (!pSrcPriv->pict)
+ return ret;
+
+ pDst = SecurityLookupIDByType(client, stuff->dst, PictureType,
+ SecurityWriteAccess);
+ pDstPriv = DMX_GET_PICT_PRIV(pDst);
+ if (!pDstPriv->pict)
+ return ret;
+
+ scrnNum = pDst->pDrawable->pScreen->myNum;
+ dmxScreen = &dmxScreens[scrnNum];
+
+ /* Note: If the back-end display has been detached, then it
+ * should not be possible to reach here since the pSrcPriv->pict
+ * and pDstPriv->pict will have already been set to 0.
+ */
+ if (!dmxScreen->beDisplay)
+ return ret;
+
+ if (stuff->maskFormat)
+ pFmt = SecurityLookupIDByType(client, stuff->maskFormat,
+ PictFormatType, SecurityReadAccess);
+ else
+ pFmt = NULL;
+
+ pFormat = dmxFindFormat(dmxScreen, pFmt);
+
+ switch (stuff->renderReqType) {
+ case X_RenderCompositeGlyphs8: size = sizeof(CARD8); break;
+ case X_RenderCompositeGlyphs16: size = sizeof(CARD16); break;
+ case X_RenderCompositeGlyphs32: size = sizeof(CARD32); break;
+ default: return BadPictOp; /* Can't happen */
+ }
+
+ buffer = (CARD8 *)(stuff + 1);
+ end = (CARD8 *)stuff + (stuff->length << 2);
+ nelt = 0;
+ nglyph = 0;
+ while (buffer + sizeof(xGlyphElt) < end) {
+ elt = (xGlyphElt *)buffer;
+ buffer += sizeof(xGlyphElt);
+
+ if (elt->len == 0xff) {
+ buffer += 4;
+ } else {
+ nelt++;
+ nglyph += elt->len;
+ space = size * elt->len;
+ if (space & 3) space += 4 - (space & 3);
+ buffer += space;
+ }
+ }
+
+ /* The following only works for Render version > 0.2 */
+
+ /* All of the XGlyphElt* structure sizes are identical */
+ elts = ALLOCATE_LOCAL(nelt * sizeof(XGlyphElt8));
+ if (!elts)
+ return BadAlloc;
+
+ glyphs = ALLOCATE_LOCAL(nglyph * size);
+ if (!glyphs) {
+ DEALLOCATE_LOCAL(elts);
+ return BadAlloc;
+ }
+
+ buffer = (CARD8 *)(stuff + 1);
+ end = (CARD8 *)stuff + (stuff->length << 2);
+ curGlyph = glyphs;
+ curElt = elts;
+
+ glyphSet = SecurityLookupIDByType(client, stuff->glyphset,
+ GlyphSetType, SecurityReadAccess);
+ glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
+
+ while (buffer + sizeof(xGlyphElt) < end) {
+ elt = (xGlyphElt *)buffer;
+ buffer += sizeof(xGlyphElt);
+
+ if (elt->len == 0xff) {
+ glyphSet = SecurityLookupIDByType(client,
+ *((CARD32 *)buffer),
+ GlyphSetType,
+ SecurityReadAccess);
+ glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
+ buffer += 4;
+ } else {
+ curElt->glyphset = glyphPriv->glyphSets[scrnNum];
+ curElt->xOff = elt->deltax;
+ curElt->yOff = elt->deltay;
+ curElt->nchars = elt->len;
+ curElt->chars = curGlyph;
+
+ memcpy(curGlyph, buffer, size*elt->len);
+ curGlyph += size * elt->len;
+
+ curElt++;
+
+ space = size * elt->len;
+ if (space & 3) space += 4 - (space & 3);
+ buffer += space;
+ }
+ }
+
+ switch (stuff->renderReqType) {
+ case X_RenderCompositeGlyphs8:
+ XRenderCompositeText8(dmxScreen->beDisplay, stuff->op,
+ pSrcPriv->pict, pDstPriv->pict,
+ pFormat,
+ stuff->xSrc, stuff->ySrc,
+ 0, 0, elts, nelt);
+ break;
+ case X_RenderCompositeGlyphs16:
+ XRenderCompositeText16(dmxScreen->beDisplay, stuff->op,
+ pSrcPriv->pict, pDstPriv->pict,
+ pFormat,
+ stuff->xSrc, stuff->ySrc,
+ 0, 0, (XGlyphElt16 *)elts, nelt);
+ break;
+ case X_RenderCompositeGlyphs32:
+ XRenderCompositeText32(dmxScreen->beDisplay, stuff->op,
+ pSrcPriv->pict, pDstPriv->pict,
+ pFormat,
+ stuff->xSrc, stuff->ySrc,
+ 0, 0, (XGlyphElt32 *)elts, nelt);
+ break;
+ }
+
+ dmxSync(dmxScreen, FALSE);
+
+ DEALLOCATE_LOCAL(elts);
+ DEALLOCATE_LOCAL(glyphs);
+ }
+
+ return ret;
+}
+
+/** Set the picture transform on each screen. */
+static int dmxProcRenderSetPictureTransform(ClientPtr client)
+{
+ DMXScreenInfo *dmxScreen;
+ PicturePtr pPicture;
+ dmxPictPrivPtr pPictPriv;
+ XTransform xform;
+ REQUEST(xRenderSetPictureTransformReq);
+
+ REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq);
+ VERIFY_PICTURE(pPicture, stuff->picture, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+
+ /* For the following to work with PanoramiX, it assumes that Render
+ * wraps the ProcRenderVector after dmxRenderInit has been called.
+ */
+ dmxScreen = &dmxScreens[pPicture->pDrawable->pScreen->myNum];
+ pPictPriv = DMX_GET_PICT_PRIV(pPicture);
+
+ if (pPictPriv->pict) {
+ xform.matrix[0][0] = stuff->transform.matrix11;
+ xform.matrix[0][1] = stuff->transform.matrix12;
+ xform.matrix[0][2] = stuff->transform.matrix13;
+ xform.matrix[1][0] = stuff->transform.matrix21;
+ xform.matrix[1][1] = stuff->transform.matrix22;
+ xform.matrix[1][2] = stuff->transform.matrix23;
+ xform.matrix[2][0] = stuff->transform.matrix31;
+ xform.matrix[2][1] = stuff->transform.matrix32;
+ xform.matrix[2][2] = stuff->transform.matrix33;
+
+ XRenderSetPictureTransform(dmxScreen->beDisplay,
+ pPictPriv->pict,
+ &xform);
+ dmxSync(dmxScreen, FALSE);
+ }
+
+ return dmxSaveRenderVector[stuff->renderReqType](client);
+}
+
+/** Set the picture filter on each screen. */
+static int dmxProcRenderSetPictureFilter(ClientPtr client)
+{
+ DMXScreenInfo *dmxScreen;
+ PicturePtr pPicture;
+ dmxPictPrivPtr pPictPriv;
+ char *filter;
+ XFixed *params;
+ int nparams;
+ REQUEST(xRenderSetPictureFilterReq);
+
+ REQUEST_SIZE_MATCH(xRenderSetPictureFilterReq);
+ VERIFY_PICTURE(pPicture, stuff->picture, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+
+ /* For the following to work with PanoramiX, it assumes that Render
+ * wraps the ProcRenderVector after dmxRenderInit has been called.
+ */
+ dmxScreen = &dmxScreens[pPicture->pDrawable->pScreen->myNum];
+ pPictPriv = DMX_GET_PICT_PRIV(pPicture);
+
+ if (pPictPriv->pict) {
+ filter = (char *)(stuff + 1);
+ params = (XFixed *)(filter + ((stuff->nbytes + 3) & ~3));
+ nparams = ((XFixed *)stuff + client->req_len) - params;
+
+ XRenderSetPictureFilter(dmxScreen->beDisplay,
+ pPictPriv->pict,
+ filter,
+ params,
+ nparams);
+ dmxSync(dmxScreen, FALSE);
+ }
+
+ return dmxSaveRenderVector[stuff->renderReqType](client);
+}
+
+
+/** Create a picture on the appropriate screen. This is the actual
+ * function that creates the picture. However, if the associated
+ * window has not yet been created due to lazy window creation, then
+ * delay the picture creation until the window is mapped. */
+static Picture dmxDoCreatePicture(PicturePtr pPicture)
+{
+ DrawablePtr pDraw = pPicture->pDrawable;
+ ScreenPtr pScreen = pDraw->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ XRenderPictFormat *pFormat;
+ Drawable draw;
+
+ if (pPicture->pDrawable->type == DRAWABLE_WINDOW) {
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV((WindowPtr)(pDraw));
+
+ if (!(draw = pWinPriv->window)) {
+ /* Window has not been created yet due to the window
+ * optimization. Delay picture creation until window is
+ * mapped.
+ */
+ pWinPriv->hasPict = TRUE;
+ return 0;
+ }
+ } else {
+ dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV((PixmapPtr)(pDraw));
+
+ if (!(draw = pPixPriv->pixmap)) {
+ /* FIXME: Zero width/height pixmap?? */
+ return 0;
+ }
+ }
+
+ /* This should not be reached if the back-end display has been
+ * detached because the pWinPriv->window or the pPixPriv->pixmap
+ * will be NULL; however, we add it here for completeness
+ */
+ if (!dmxScreen->beDisplay)
+ return 0;
+
+ pFormat = dmxFindFormat(dmxScreen, pPicture->pFormat);
+
+ return XRenderCreatePicture(dmxScreen->beDisplay, draw, pFormat, 0, 0);
+}
+
+/** Create a list of pictures. This function is called by
+ * dmxCreateAndRealizeWindow() during the lazy window creation
+ * realization process. It creates the entire list of pictures that
+ * are associated with the given window. */
+void dmxCreatePictureList(WindowPtr pWindow)
+{
+ PicturePtr pPicture = GetPictureWindow(pWindow);
+
+ while (pPicture) {
+ dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pPicture);
+
+ /* Create the picture for this window */
+ pPictPriv->pict = dmxDoCreatePicture(pPicture);
+
+ /* ValidatePicture takes care of the state changes */
+
+ pPicture = pPicture->pNext;
+ }
+}
+
+/** Create a picture. This function handles the CreatePicture
+ * unwrapping/wrapping and calls dmxDoCreatePicture to actually create
+ * the picture on the appropriate screen. */
+int dmxCreatePicture(PicturePtr pPicture)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pPicture);
+ int ret = Success;
+
+ DMX_UNWRAP(CreatePicture, dmxScreen, ps);
+#if 1
+ if (ps->CreatePicture)
+ ret = ps->CreatePicture(pPicture);
+#endif
+
+ /* Create picture on back-end server */
+ pPictPriv->pict = dmxDoCreatePicture(pPicture);
+ pPictPriv->savedMask = 0;
+
+ DMX_WRAP(CreatePicture, dmxCreatePicture, dmxScreen, ps);
+
+ return ret;
+}
+
+/** Destroy \a pPicture on the back-end server. */
+Bool dmxBEFreePicture(PicturePtr pPicture)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pPicture);
+
+ if (pPictPriv->pict) {
+ XRenderFreePicture(dmxScreen->beDisplay, pPictPriv->pict);
+ pPictPriv->pict = (Picture)0;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/** Destroy a list of pictures that are associated with the window that
+ * is being destroyed. This function is called by #dmxDestroyWindow().
+ * */
+Bool dmxDestroyPictureList(WindowPtr pWindow)
+{
+ PicturePtr pPicture = GetPictureWindow(pWindow);
+ Bool ret = FALSE;
+
+ while (pPicture) {
+ ret |= dmxBEFreePicture(pPicture);
+ pPicture = pPicture->pNext;
+ }
+
+ return ret;
+}
+
+/** Destroy a picture. This function calls the wrapped function that
+ * frees the resources in the DMX server associated with this
+ * picture. */
+void dmxDestroyPicture(PicturePtr pPicture)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+
+ DMX_UNWRAP(DestroyPicture, dmxScreen, ps);
+
+ /* Destroy picture on back-end server */
+ if (dmxBEFreePicture(pPicture))
+ dmxSync(dmxScreen, FALSE);
+
+#if 1
+ if (ps->DestroyPicture)
+ ps->DestroyPicture(pPicture);
+#endif
+ DMX_WRAP(DestroyPicture, dmxDestroyPicture, dmxScreen, ps);
+}
+
+/** Change the picture's list of clip rectangles. */
+int dmxChangePictureClip(PicturePtr pPicture, int clipType,
+ pointer value, int n)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pPicture);
+
+ DMX_UNWRAP(ChangePictureClip, dmxScreen, ps);
+#if 1
+ if (ps->ChangePictureClip)
+ ps->ChangePictureClip(pPicture, clipType, value, n);
+#endif
+
+ /* Change picture clip rects on back-end server */
+ if (pPictPriv->pict) {
+ /* The clip has already been changed into a region by the mi
+ * routine called above.
+ */
+ if (pPicture->clientClip) {
+ RegionPtr pClip = pPicture->clientClip;
+ BoxPtr pBox = REGION_RECTS(pClip);
+ int nBox = REGION_NUM_RECTS(pClip);
+ XRectangle *pRects;
+ XRectangle *pRect;
+ int nRects;
+
+ nRects = nBox;
+ pRects = pRect = xalloc(nRects * sizeof(*pRect));
+
+ while (nBox--) {
+ pRect->x = pBox->x1;
+ pRect->y = pBox->y1;
+ pRect->width = pBox->x2 - pBox->x1;
+ pRect->height = pBox->y2 - pBox->y1;
+ pBox++;
+ pRect++;
+ }
+
+ XRenderSetPictureClipRectangles(dmxScreen->beDisplay,
+ pPictPriv->pict,
+ 0, 0,
+ pRects,
+ nRects);
+ xfree(pRects);
+ } else {
+ XRenderSetPictureClipRectangles(dmxScreen->beDisplay,
+ pPictPriv->pict,
+ 0, 0, NULL, 0);
+ }
+ dmxSync(dmxScreen, FALSE);
+ } else {
+ /* FIXME: Handle saving clip region when offscreen */
+ }
+
+ DMX_WRAP(ChangePictureClip, dmxChangePictureClip, dmxScreen, ps);
+
+ return Success;
+}
+
+/** Destroy the picture's list of clip rectangles. */
+void dmxDestroyPictureClip(PicturePtr pPicture)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pPicture);
+
+ DMX_UNWRAP(DestroyPictureClip, dmxScreen, ps);
+#if 1
+ if (ps->DestroyPictureClip)
+ ps->DestroyPictureClip(pPicture);
+#endif
+
+ /* Destroy picture clip rects on back-end server */
+ if (pPictPriv->pict) {
+ XRenderSetPictureClipRectangles(dmxScreen->beDisplay,
+ pPictPriv->pict,
+ 0, 0, NULL, 0);
+ dmxSync(dmxScreen, FALSE);
+ } else {
+ /* FIXME: Handle destroying clip region when offscreen */
+ }
+
+ DMX_WRAP(DestroyPictureClip, dmxDestroyPictureClip, dmxScreen, ps);
+}
+
+/** Change the attributes of the pictures. If the picture has not yet
+ * been created due to lazy window creation, save the mask so that it
+ * can be used to appropriately initialize the picture's attributes
+ * when it is created later. */
+void dmxChangePicture(PicturePtr pPicture, Mask mask)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pPicture);
+
+ DMX_UNWRAP(ChangePicture, dmxScreen, ps);
+#if 1
+ if (ps->ChangePicture)
+ ps->ChangePicture(pPicture, mask);
+#endif
+
+ /* Picture attribute changes are handled in ValidatePicture */
+ pPictPriv->savedMask |= mask;
+
+ DMX_WRAP(ChangePicture, dmxChangePicture, dmxScreen, ps);
+}
+
+/** Validate the picture's attributes before rendering to it. Update
+ * any picture attributes that have been changed by one of the higher
+ * layers. */
+void dmxValidatePicture(PicturePtr pPicture, Mask mask)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pPicture);
+
+ DMX_UNWRAP(ValidatePicture, dmxScreen, ps);
+
+ /* Change picture attributes on back-end server */
+ if (pPictPriv->pict) {
+ XRenderPictureAttributes attribs;
+
+ if (mask & CPRepeat) {
+ attribs.repeat = pPicture->repeatType;
+ }
+ if (mask & CPAlphaMap) {
+ if (pPicture->alphaMap) {
+ dmxPictPrivPtr pAlphaPriv;
+ pAlphaPriv = DMX_GET_PICT_PRIV(pPicture->alphaMap);
+ if (pAlphaPriv->pict) {
+ attribs.alpha_map = pAlphaPriv->pict;
+ } else {
+ /* FIXME: alpha picture drawable has not been created?? */
+ return; /* or should this be: attribs.alpha_map = None; */
+ }
+ } else {
+ attribs.alpha_map = None;
+ }
+ }
+ if (mask & CPAlphaXOrigin)
+ attribs.alpha_x_origin = pPicture->alphaOrigin.x;
+ if (mask & CPAlphaYOrigin)
+ attribs.alpha_y_origin = pPicture->alphaOrigin.y;
+ if (mask & CPClipXOrigin)
+ attribs.clip_x_origin = pPicture->clipOrigin.x;
+ if (mask & CPClipYOrigin)
+ attribs.clip_y_origin = pPicture->clipOrigin.y;
+ if (mask & CPClipMask)
+ mask &= ~CPClipMask; /* Handled in ChangePictureClip */
+ if (mask & CPGraphicsExposure)
+ attribs.graphics_exposures = pPicture->graphicsExposures;
+ if (mask & CPSubwindowMode)
+ attribs.subwindow_mode = pPicture->subWindowMode;
+ if (mask & CPPolyEdge)
+ attribs.poly_edge = pPicture->polyEdge;
+ if (mask & CPPolyMode)
+ attribs.poly_mode = pPicture->polyMode;
+ if (mask & CPDither)
+ attribs.dither = pPicture->dither;
+ if (mask & CPComponentAlpha)
+ attribs.component_alpha = pPicture->componentAlpha;
+
+ XRenderChangePicture(dmxScreen->beDisplay, pPictPriv->pict,
+ mask, &attribs);
+ dmxSync(dmxScreen, FALSE);
+ } else {
+ pPictPriv->savedMask |= mask;
+ }
+
+#if 1
+ if (ps->ValidatePicture)
+ ps->ValidatePicture(pPicture, mask);
+#endif
+
+ DMX_WRAP(ValidatePicture, dmxValidatePicture, dmxScreen, ps);
+}
+
+/** Composite a picture on the appropriate screen by combining the
+ * specified rectangle of the transformed src and mask operands with
+ * the specified rectangle of the dst using op as the compositing
+ * operator. For a complete description see the protocol document of
+ * the RENDER library. */
+void dmxComposite(CARD8 op,
+ PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
+ INT16 xSrc, INT16 ySrc,
+ INT16 xMask, INT16 yMask,
+ INT16 xDst, INT16 yDst,
+ CARD16 width, CARD16 height)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ dmxPictPrivPtr pSrcPriv = DMX_GET_PICT_PRIV(pSrc);
+ dmxPictPrivPtr pMaskPriv = NULL;
+ dmxPictPrivPtr pDstPriv = DMX_GET_PICT_PRIV(pDst);
+
+ if (pMask) pMaskPriv = DMX_GET_PICT_PRIV(pMask);
+
+ DMX_UNWRAP(Composite, dmxScreen, ps);
+#if 0
+ if (ps->Composite)
+ ps->Composite(op, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask, xDst, yDst,
+ width, height);
+#endif
+
+ /* Composite on back-end server */
+ if (pSrcPriv->pict && pDstPriv->pict &&
+ ((pMaskPriv && pMaskPriv->pict) || !pMaskPriv)) {
+ XRenderComposite(dmxScreen->beDisplay,
+ op,
+ pSrcPriv->pict,
+ pMaskPriv ? pMaskPriv->pict : None,
+ pDstPriv->pict,
+ xSrc, ySrc,
+ xMask, yMask,
+ xDst, yDst,
+ width, height);
+ dmxSync(dmxScreen, FALSE);
+ }
+
+
+ DMX_WRAP(Composite, dmxComposite, dmxScreen, ps);
+}
+
+/** Null function to catch when/if RENDER calls lower level mi hooks.
+ * Compositing glyphs is handled by dmxProcRenderCompositeGlyphs().
+ * This function should never be called. */
+void dmxGlyphs(CARD8 op,
+ PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc,
+ int nlists, GlyphListPtr lists, GlyphPtr *glyphs)
+{
+ /* This won't work, so we need to wrap ProcRenderCompositeGlyphs */
+}
+
+/** Fill a rectangle on the appropriate screen by combining the color
+ * with the dest picture in the area specified by the list of
+ * rectangles. For a complete description see the protocol document of
+ * the RENDER library. */
+void dmxCompositeRects(CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect, xRectangle *rects)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pDst);
+
+ DMX_UNWRAP(CompositeRects, dmxScreen, ps);
+#if 0
+ if (ps->CompositeRects)
+ ps->CompositeRects(op, pDst, color, nRect, rects);
+#endif
+
+ /* CompositeRects on back-end server */
+ if (pPictPriv->pict) {
+ XRenderFillRectangles(dmxScreen->beDisplay,
+ op,
+ pPictPriv->pict,
+ (XRenderColor *)color,
+ (XRectangle *)rects,
+ nRect);
+ dmxSync(dmxScreen, FALSE);
+ }
+
+ DMX_WRAP(CompositeRects, dmxCompositeRects, dmxScreen, ps);
+}
+
+/** Indexed color visuals are not yet supported. */
+Bool dmxInitIndexed(ScreenPtr pScreen, PictFormatPtr pFormat)
+{
+ return TRUE;
+}
+
+/** Indexed color visuals are not yet supported. */
+void dmxCloseIndexed(ScreenPtr pScreen, PictFormatPtr pFormat)
+{
+}
+
+/** Indexed color visuals are not yet supported. */
+void dmxUpdateIndexed(ScreenPtr pScreen, PictFormatPtr pFormat,
+ int ndef, xColorItem *pdef)
+{
+}
+
+/** Composite a list of trapezoids on the appropriate screen. For a
+ * complete description see the protocol document of the RENDER
+ * library. */
+void dmxTrapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc,
+ int ntrap, xTrapezoid *traps)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ dmxPictPrivPtr pSrcPriv = DMX_GET_PICT_PRIV(pSrc);
+ dmxPictPrivPtr pDstPriv = DMX_GET_PICT_PRIV(pDst);
+
+ DMX_UNWRAP(Trapezoids, dmxScreen, ps);
+#if 0
+ if (ps->Trapezoids)
+ ps->Trapezoids(op, pSrc, pDst, maskFormat, xSrc, ySrc, ntrap, *traps);
+#endif
+
+ /* Draw trapezoids on back-end server */
+ if (pDstPriv->pict) {
+ XRenderPictFormat *pFormat;
+
+ pFormat = dmxFindFormat(dmxScreen, maskFormat);
+ if (!pFormat) {
+ /* FIXME: Error! */
+ }
+
+ XRenderCompositeTrapezoids(dmxScreen->beDisplay,
+ op,
+ pSrcPriv->pict,
+ pDstPriv->pict,
+ pFormat,
+ xSrc, ySrc,
+ (XTrapezoid *)traps,
+ ntrap);
+ dmxSync(dmxScreen, FALSE);
+ }
+
+ DMX_WRAP(Trapezoids, dmxTrapezoids, dmxScreen, ps);
+}
+
+/** Composite a list of triangles on the appropriate screen. For a
+ * complete description see the protocol document of the RENDER
+ * library. */
+void dmxTriangles(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc,
+ int ntri, xTriangle *tris)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ dmxPictPrivPtr pSrcPriv = DMX_GET_PICT_PRIV(pSrc);
+ dmxPictPrivPtr pDstPriv = DMX_GET_PICT_PRIV(pDst);
+
+ DMX_UNWRAP(Triangles, dmxScreen, ps);
+#if 0
+ if (ps->Triangles)
+ ps->Triangles(op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, *tris);
+#endif
+
+ /* Draw trapezoids on back-end server */
+ if (pDstPriv->pict) {
+ XRenderPictFormat *pFormat;
+
+ pFormat = dmxFindFormat(dmxScreen, maskFormat);
+ if (!pFormat) {
+ /* FIXME: Error! */
+ }
+
+ XRenderCompositeTriangles(dmxScreen->beDisplay,
+ op,
+ pSrcPriv->pict,
+ pDstPriv->pict,
+ pFormat,
+ xSrc, ySrc,
+ (XTriangle *)tris,
+ ntri);
+ dmxSync(dmxScreen, FALSE);
+ }
+
+ DMX_WRAP(Triangles, dmxTriangles, dmxScreen, ps);
+}
+
+/** Composite a triangle strip on the appropriate screen. For a
+ * complete description see the protocol document of the RENDER
+ * library. */
+void dmxTriStrip(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc,
+ int npoint, xPointFixed *points)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ dmxPictPrivPtr pSrcPriv = DMX_GET_PICT_PRIV(pSrc);
+ dmxPictPrivPtr pDstPriv = DMX_GET_PICT_PRIV(pDst);
+
+ DMX_UNWRAP(TriStrip, dmxScreen, ps);
+#if 0
+ if (ps->TriStrip)
+ ps->TriStrip(op, pSrc, pDst, maskFormat, xSrc, ySrc, npoint, *points);
+#endif
+
+ /* Draw trapezoids on back-end server */
+ if (pDstPriv->pict) {
+ XRenderPictFormat *pFormat;
+
+ pFormat = dmxFindFormat(dmxScreen, maskFormat);
+ if (!pFormat) {
+ /* FIXME: Error! */
+ }
+
+ XRenderCompositeTriStrip(dmxScreen->beDisplay,
+ op,
+ pSrcPriv->pict,
+ pDstPriv->pict,
+ pFormat,
+ xSrc, ySrc,
+ (XPointFixed *)points,
+ npoint);
+ dmxSync(dmxScreen, FALSE);
+ }
+
+ DMX_WRAP(TriStrip, dmxTriStrip, dmxScreen, ps);
+}
+
+/** Composite a triangle fan on the appropriate screen. For a complete
+ * description see the protocol document of the RENDER library. */
+void dmxTriFan(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc,
+ int npoint, xPointFixed *points)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ dmxPictPrivPtr pSrcPriv = DMX_GET_PICT_PRIV(pSrc);
+ dmxPictPrivPtr pDstPriv = DMX_GET_PICT_PRIV(pDst);
+
+ DMX_UNWRAP(TriFan, dmxScreen, ps);
+#if 0
+ if (ps->TriFan)
+ ps->TriFan(op, pSrc, pDst, maskFormat, xSrc, ySrc, npoint, *points);
+#endif
+
+ /* Draw trapezoids on back-end server */
+ if (pDstPriv->pict) {
+ XRenderPictFormat *pFormat;
+
+ pFormat = dmxFindFormat(dmxScreen, maskFormat);
+ if (!pFormat) {
+ /* FIXME: Error! */
+ }
+
+ XRenderCompositeTriFan(dmxScreen->beDisplay,
+ op,
+ pSrcPriv->pict,
+ pDstPriv->pict,
+ pFormat,
+ xSrc, ySrc,
+ (XPointFixed *)points,
+ npoint);
+ dmxSync(dmxScreen, FALSE);
+ }
+
+ DMX_WRAP(TriFan, dmxTriFan, dmxScreen, ps);
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxpict.h b/nx-X11/programs/Xserver/hw/dmx/dmxpict.h
new file mode 100644
index 000000000..2ca04ed87
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxpict.h
@@ -0,0 +1,133 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * This file provides access to the externally visible RENDER support
+ * functions, global variables and macros for DMX.
+ *
+ * FIXME: Move function definitions for non-externally visible function
+ * to .c file. */
+
+#ifndef DMXPICT_H
+#define DMXPICT_H
+
+/** Picture private structure */
+typedef struct _dmxPictPriv {
+ Picture pict; /**< Picture ID from back-end server */
+ Mask savedMask; /**< Mask of picture attributes saved for
+ * lazy window creation. */
+} dmxPictPrivRec, *dmxPictPrivPtr;
+
+
+/** Glyph Set private structure */
+typedef struct _dmxGlyphPriv {
+ GlyphSet *glyphSets; /**< Glyph Set IDs from back-end server */
+} dmxGlyphPrivRec, *dmxGlyphPrivPtr;
+
+
+extern void dmxInitRender(void);
+extern void dmxResetRender(void);
+
+extern Bool dmxPictureInit(ScreenPtr pScreen,
+ PictFormatPtr formats, int nformats);
+
+extern void dmxCreatePictureList(WindowPtr pWindow);
+extern Bool dmxDestroyPictureList(WindowPtr pWindow);
+
+extern int dmxCreatePicture(PicturePtr pPicture);
+extern void dmxDestroyPicture(PicturePtr pPicture);
+extern int dmxChangePictureClip(PicturePtr pPicture, int clipType,
+ pointer value, int n);
+extern void dmxDestroyPictureClip(PicturePtr pPicture);
+extern void dmxChangePicture(PicturePtr pPicture, Mask mask);
+extern void dmxValidatePicture(PicturePtr pPicture, Mask mask);
+extern void dmxComposite(CARD8 op,
+ PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
+ INT16 xSrc, INT16 ySrc,
+ INT16 xMask, INT16 yMask,
+ INT16 xDst, INT16 yDst,
+ CARD16 width, CARD16 height);
+extern void dmxGlyphs(CARD8 op,
+ PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc,
+ int nlists, GlyphListPtr lists, GlyphPtr *glyphs);
+extern void dmxCompositeRects(CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect, xRectangle *rects);
+extern Bool dmxInitIndexed(ScreenPtr pScreen, PictFormatPtr pFormat);
+extern void dmxCloseIndexed(ScreenPtr pScreen, PictFormatPtr pFormat);
+extern void dmxUpdateIndexed(ScreenPtr pScreen, PictFormatPtr pFormat,
+ int ndef, xColorItem *pdef);
+extern void dmxTrapezoids(CARD8 op,
+ PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc,
+ int ntrap, xTrapezoid *traps);
+extern void dmxTriangles(CARD8 op,
+ PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc,
+ int ntri, xTriangle *tris);
+extern void dmxTriStrip(CARD8 op,
+ PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc,
+ int npoint, xPointFixed *points);
+extern void dmxTriFan(CARD8 op,
+ PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc,
+ int npoint, xPointFixed *points);
+
+extern Bool dmxBEFreeGlyphSet(ScreenPtr pScreen, GlyphSetPtr glyphSet);
+extern Bool dmxBEFreePicture(PicturePtr pPicture);
+
+extern int dmxPictPrivateIndex; /**< Index for picture private data */
+extern int dmxGlyphSetPrivateIndex; /**< Index for glyphset private data */
+
+
+/** Get the picture private data given a picture pointer */
+#define DMX_GET_PICT_PRIV(_pPict) \
+ (dmxPictPrivPtr)(_pPict)->devPrivates[dmxPictPrivateIndex].ptr
+
+/** Set the glyphset private data given a glyphset pointer */
+#define DMX_SET_GLYPH_PRIV(_pGlyph, _pPriv) \
+ GlyphSetSetPrivate((_pGlyph), dmxGlyphSetPrivateIndex, (_pPriv))
+/** Get the glyphset private data given a glyphset pointer */
+#define DMX_GET_GLYPH_PRIV(_pGlyph) \
+ (dmxGlyphPrivPtr)GlyphSetGetPrivate((_pGlyph), dmxGlyphSetPrivateIndex)
+
+#endif /* DMXPICT_H */
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxpixmap.c b/nx-X11/programs/Xserver/hw/dmx/dmxpixmap.c
new file mode 100644
index 000000000..e95ddd72e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxpixmap.c
@@ -0,0 +1,252 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * Provides pixmap support. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxsync.h"
+#include "dmxpixmap.h"
+
+#include "pixmapstr.h"
+#include "servermd.h"
+
+/** Initialize a private area in \a pScreen for pixmap information. */
+Bool dmxInitPixmap(ScreenPtr pScreen)
+{
+#ifdef PIXPRIV
+ if (!AllocatePixmapPrivate(pScreen, dmxPixPrivateIndex,
+ sizeof(dmxPixPrivRec)))
+ return FALSE;
+
+ return TRUE;
+#else
+#error Must define PIXPRIV to compile DMX X server
+#endif
+}
+
+/** Create a pixmap on the back-end server. */
+void dmxBECreatePixmap(PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
+
+ /* Make sure we haven't already created this pixmap. This can
+ * happen when the pixmap is used elsewhere (e.g., as a background
+ * or border for a window) and the refcnt > 1.
+ */
+ if (pPixPriv->pixmap)
+ return;
+
+ if (pPixmap->drawable.width && pPixmap->drawable.height) {
+ pPixPriv->pixmap = XCreatePixmap(dmxScreen->beDisplay,
+ dmxScreen->scrnWin,
+ pPixmap->drawable.width,
+ pPixmap->drawable.height,
+ pPixmap->drawable.depth);
+ dmxSync(dmxScreen, FALSE);
+ }
+}
+
+/** Create a pixmap for \a pScreen with the specified \a width, \a
+ * height, and \a depth. */
+PixmapPtr dmxCreatePixmap(ScreenPtr pScreen, int width, int height, int depth)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ PixmapPtr pPixmap;
+ int bpp;
+ dmxPixPrivPtr pPixPriv;
+
+#if 0
+ DMX_UNWRAP(CreatePixmap, dmxScreen, pScreen);
+ if (pScreen->CreatePixmap)
+ ret = pScreen->CreatePixmap(pPixmap);
+#endif
+
+ /* Create pixmap on back-end server */
+ if (depth == 24) bpp = 32;
+ else bpp = depth;
+
+ pPixmap = AllocatePixmap(pScreen, 0);
+ if (!pPixmap)
+ return NullPixmap;
+
+ pPixmap->drawable.type = DRAWABLE_PIXMAP;
+ pPixmap->drawable.class = 0;
+ pPixmap->drawable.pScreen = pScreen;
+ pPixmap->drawable.depth = depth;
+ pPixmap->drawable.bitsPerPixel = bpp;
+ pPixmap->drawable.id = 0;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pPixmap->drawable.x = 0;
+ pPixmap->drawable.y = 0;
+ pPixmap->drawable.width = width;
+ pPixmap->drawable.height = height;
+ pPixmap->devKind = PixmapBytePad(width, bpp);
+ pPixmap->refcnt = 1;
+
+ pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
+ pPixPriv->pixmap = (Pixmap)0;
+ pPixPriv->detachedImage = NULL;
+
+ /* Create the pixmap on the back-end server */
+ if (dmxScreen->beDisplay) {
+ dmxBECreatePixmap(pPixmap);
+ }
+
+#if 0
+ DMX_WRAP(CreatePixmap, dmxCreatePixmap, dmxScreen, pScreen);
+#endif
+
+ return pPixmap;
+}
+
+/** Destroy the pixmap on the back-end server. */
+Bool dmxBEFreePixmap(PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
+
+ if (pPixPriv->pixmap) {
+ XFreePixmap(dmxScreen->beDisplay, pPixPriv->pixmap);
+ pPixPriv->pixmap = (Pixmap)0;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/** Destroy the pixmap pointed to by \a pPixmap. */
+Bool dmxDestroyPixmap(PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+
+#if 0
+ DMX_UNWRAP(DestroyPixmap, dmxScreen, pScreen);
+#endif
+
+ if (--pPixmap->refcnt)
+ return TRUE;
+
+ /* Destroy pixmap on back-end server */
+ if (dmxScreen->beDisplay) {
+ if (dmxBEFreePixmap(pPixmap)) {
+ /* Also make sure that we destroy any detached image */
+ dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
+ if (pPixPriv->detachedImage)
+ XDestroyImage(pPixPriv->detachedImage);
+ dmxSync(dmxScreen, FALSE);
+ }
+ }
+ xfree(pPixmap);
+
+#if 0
+ if (pScreen->DestroyPixmap)
+ ret = pScreen->DestroyPixmap(pPixmap);
+ DMX_WRAP(DestroyPixmap, dmxDestroyPixmap, dmxScreen, pScreen);
+#endif
+
+ return ret;
+}
+
+/** Create and return a region based on the pixmap pointed to by \a
+ * pPixmap. */
+RegionPtr dmxBitmapToRegion(PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
+ XImage *ximage;
+ RegionPtr pReg, pTmpReg;
+ int x, y;
+ unsigned long previousPixel, currentPixel;
+ BoxRec Box;
+ Bool overlap;
+
+ if (!dmxScreen->beDisplay) {
+ pReg = REGION_CREATE(pScreen, NullBox, 1);
+ return pReg;
+ }
+
+ ximage = XGetImage(dmxScreen->beDisplay, pPixPriv->pixmap, 0, 0,
+ pPixmap->drawable.width, pPixmap->drawable.height,
+ 1, XYPixmap);
+
+ pReg = REGION_CREATE(pScreen, NullBox, 1);
+ pTmpReg = REGION_CREATE(pScreen, NullBox, 1);
+ if(!pReg || !pTmpReg) return NullRegion;
+
+ for (y = 0; y < pPixmap->drawable.height; y++) {
+ Box.y1 = y;
+ Box.y2 = y + 1;
+ previousPixel = 0L;
+ for (x = 0; x < pPixmap->drawable.width; x++) {
+ currentPixel = XGetPixel(ximage, x, y);
+ if (previousPixel != currentPixel) {
+ if (previousPixel == 0L) {
+ /* left edge */
+ Box.x1 = x;
+ } else if (currentPixel == 0L) {
+ /* right edge */
+ Box.x2 = x;
+ REGION_RESET(pScreen, pTmpReg, &Box);
+ REGION_APPEND(pScreen, pReg, pTmpReg);
+ }
+ previousPixel = currentPixel;
+ }
+ }
+ if (previousPixel != 0L) {
+ /* right edge because of the end of pixmap */
+ Box.x2 = pPixmap->drawable.width;
+ REGION_RESET(pScreen, pTmpReg, &Box);
+ REGION_APPEND(pScreen, pReg, pTmpReg);
+ }
+ }
+
+ REGION_DESTROY(pScreen, pTmpReg);
+ XDestroyImage(ximage);
+
+ REGION_VALIDATE(pScreen, pReg, &overlap);
+
+ dmxSync(dmxScreen, FALSE);
+ return(pReg);
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxpixmap.h b/nx-X11/programs/Xserver/hw/dmx/dmxpixmap.h
new file mode 100644
index 000000000..908d2cb2c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxpixmap.h
@@ -0,0 +1,67 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for pixmap support. \see dmxpixmap.c */
+
+#ifndef DMXPIXMAP_H
+#define DMXPIXMAP_H
+
+#include "pixmapstr.h"
+
+/** Pixmap private area. */
+typedef struct _dmxPixPriv {
+ Pixmap pixmap;
+ XImage *detachedImage;
+} dmxPixPrivRec, *dmxPixPrivPtr;
+
+
+extern Bool dmxInitPixmap(ScreenPtr pScreen);
+
+extern PixmapPtr dmxCreatePixmap(ScreenPtr pScreen,
+ int width, int height, int depth);
+extern Bool dmxDestroyPixmap(PixmapPtr pPixmap);
+extern RegionPtr dmxBitmapToRegion(PixmapPtr pPixmap);
+
+extern void dmxBECreatePixmap(PixmapPtr pPixmap);
+extern Bool dmxBEFreePixmap(PixmapPtr pPixmap);
+
+/** Private index. \see dmxpicmap.h \see dmxscrinit.c */
+extern int dmxPixPrivateIndex;
+
+/** Get pixmap private pointer. */
+#define DMX_GET_PIXMAP_PRIV(_pPix) \
+ (dmxPixPrivPtr)(_pPix)->devPrivates[dmxPixPrivateIndex].ptr
+
+#endif /* DMXPIXMAP_H */
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxprop.c b/nx-X11/programs/Xserver/hw/dmx/dmxprop.c
new file mode 100644
index 000000000..8d9e22a27
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxprop.c
@@ -0,0 +1,348 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * It is possible for one of the DMX "backend displays" to actually be
+ * smaller than the dimensions of the backend X server. Therefore, it
+ * is possible for more than one of the DMX "backend displays" to be
+ * physically located on the same backend X server. This situation must
+ * be detected so that cursor motion can be handled in an expected
+ * fashion.
+ *
+ * We could analyze the names used for the DMX "backend displays" (e.g.,
+ * the names passed to the -display command-line parameter), but there
+ * are many possible names for a single X display, and failing to detect
+ * sameness leads to very unexpected results. Therefore, whenever the
+ * DMX server opens a window on a backend X server, a property value is
+ * queried and set on that backend to detect when another window is
+ * already open on that server.
+ *
+ * Further, it is possible that two different DMX server instantiations
+ * both have windows on the same physical backend X server. This case
+ * is also detected so that pointer input is not taken from that
+ * particular backend X server.
+ *
+ * The routines in this file handle the property management. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxprop.h"
+#include "dmxlog.h"
+
+/** Holds the window id of all DMX windows on the backend X server. */
+#define DMX_ATOMNAME "DMX_NAME"
+
+/** The identification string of this DMX server */
+#define DMX_IDENT "Xdmx"
+
+extern char *display;
+
+static int dmxPropertyErrorHandler(Display *dpy, XErrorEvent *ev)
+{
+ return 0;
+}
+
+static const unsigned char *dmxPropertyIdentifier(void)
+{
+ /* RATS: These buffers are only used in
+ * length-limited calls. */
+ char hostname[256];
+ static char buf[128];
+ static int initialized = 0;
+
+ if (initialized++) return (unsigned char *)buf;
+
+ XmuGetHostname(hostname, sizeof(hostname));
+ XmuSnprintf(buf, sizeof(buf), "%s:%s:%s", DMX_IDENT, hostname, display);
+ return (unsigned char *)buf;
+}
+
+/** Starting with the \a start screen, iterate over all of the screens
+ * on the same physical X server as \a start, calling \a f with the
+ * screen and the \a closure. (The common case is that \a start is the
+ * only DMX window on the backend X server.) */
+void *dmxPropertyIterate(DMXScreenInfo *start,
+ void *(*f)(DMXScreenInfo *dmxScreen, void *),
+ void *closure)
+{
+ DMXScreenInfo *pt;
+
+ if (!start->next) {
+ if (!start->beDisplay) return NULL;
+ return f(start, closure);
+ }
+
+ for (pt = start->next; /* condition at end of loop */; pt = pt->next) {
+ void *retval;
+ /* beDisplay ban be NULL if a screen was detached */
+ dmxLog(dmxDebug, "pt = %p\n", pt);
+ dmxLog(dmxDebug, "pt->beDisplay = %p\n", pt->beDisplay);
+ if (pt->beDisplay && (retval = f(pt, closure))) return retval;
+ if (pt == start) break;
+ }
+ return NULL;
+}
+
+/** Returns 0 if this is the only Xdmx session on the display; 1
+ * otherwise. */
+static int dmxPropertyCheckOtherServers(DMXScreenInfo *dmxScreen, Atom atom)
+{
+ Display *dpy = dmxScreen->beDisplay;
+ XTextProperty tp;
+ XTextProperty tproot;
+ const char *pt;
+ int retcode = 0;
+ char **list = NULL;
+ int count = 0;
+ int i;
+ int (*dmxOldHandler)(Display *, XErrorEvent *);
+
+ if (!dpy)
+ return 0;
+
+ if (!XGetTextProperty(dpy, RootWindow(dpy,0), &tproot, atom)
+ || !tproot.nitems) return 0;
+
+ /* Ignore BadWindow errors for this
+ * routine because the window id stored
+ * in the property might be old */
+ dmxOldHandler = XSetErrorHandler(dmxPropertyErrorHandler);
+ for (pt = (const char *)tproot.value; pt && *pt; pt = pt ? pt + 1 : NULL) {
+ if ((pt = strchr(pt, ','))) {
+ Window win = strtol(pt+1, NULL, 10);
+ if (XGetTextProperty(dpy, win, &tp, atom) && tp.nitems) {
+ if (!strncmp((char *)tp.value, DMX_IDENT, strlen(DMX_IDENT))) {
+ int flag = 0;
+ for (i = 0; i < count; i++)
+ if (!strcmp(list[i], (char *)tp.value)) {
+ ++flag;
+ break;
+ }
+ if (flag) continue;
+ ++retcode;
+ dmxLogOutputWarning(dmxScreen,
+ "%s also running on %s\n",
+ tp.value, dmxScreen->name);
+ list = xrealloc(list, ++count * sizeof(*list));
+ list[count-1] = xalloc(tp.nitems + 2);
+ strncpy(list[count-1], (char *)tp.value, tp.nitems + 1);
+ }
+ XFree(tp.value);
+ }
+ }
+ }
+ XSetErrorHandler(dmxOldHandler);
+
+ for (i = 0; i < count; i++) xfree(list[i]);
+ xfree(list);
+ XFree(tproot.value);
+ if (!retcode)
+ dmxLogOutput(dmxScreen, "No Xdmx server running on backend\n");
+ return retcode;
+}
+
+/** Returns NULL if this is the only Xdmx window on the display.
+ * Otherwise, returns a pointer to the dmxScreen of the other windows on
+ * the display. */
+static DMXScreenInfo *dmxPropertyCheckOtherWindows(DMXScreenInfo *dmxScreen,
+ Atom atom)
+{
+ Display *dpy = dmxScreen->beDisplay;
+ const unsigned char *id = dmxPropertyIdentifier();
+ XTextProperty tproot;
+ XTextProperty tp;
+ const char *pt;
+ int (*dmxOldHandler)(Display *, XErrorEvent *);
+
+ if (!dpy)
+ return NULL;
+
+ if (!XGetTextProperty(dpy, RootWindow(dpy,0), &tproot, atom)
+ || !tproot.nitems) return 0;
+
+ /* Ignore BadWindow errors for this
+ * routine because the window id stored
+ * in the property might be old */
+ dmxOldHandler = XSetErrorHandler(dmxPropertyErrorHandler);
+ for (pt = (const char *)tproot.value; pt && *pt; pt = pt ? pt + 1 : NULL) {
+ if ((pt = strchr(pt, ','))) {
+ Window win = strtol(pt+1, NULL, 10);
+ if (XGetTextProperty(dpy, win, &tp, atom) && tp.nitems) {
+ dmxLog(dmxDebug,"On %s/%lu: %s\n",
+ dmxScreen->name, win, tp.value);
+ if (!strncmp((char *)tp.value, (char *)id,
+ strlen((char *)id))) {
+ int idx;
+
+ if (!(pt = strchr((char *)tp.value, ','))) continue;
+ idx = strtol(pt+1, NULL, 10);
+ if (idx < 0 || idx >= dmxNumScreens) continue;
+ if (dmxScreens[idx].scrnWin != win) continue;
+ XSetErrorHandler(dmxOldHandler);
+ return &dmxScreens[idx];
+ }
+ XFree(tp.value);
+ }
+ }
+ }
+ XSetErrorHandler(dmxOldHandler);
+ XFree(tproot.value);
+ return 0;
+}
+
+/** Returns 0 if this is the only Xdmx session on the display; 1
+ * otherwise. */
+int dmxPropertyDisplay(DMXScreenInfo *dmxScreen)
+{
+ Atom atom;
+ const unsigned char *id = dmxPropertyIdentifier();
+ Display *dpy = dmxScreen->beDisplay;
+
+ if (!dpy)
+ return 0;
+
+ atom = XInternAtom(dpy, DMX_ATOMNAME, False);
+ if (dmxPropertyCheckOtherServers(dmxScreen, atom)) {
+ dmxScreen->shared = 1;
+ return 1;
+ }
+ XChangeProperty(dpy, RootWindow(dpy,0), atom, XA_STRING, 8,
+ PropModeReplace, id, strlen((char *)id));
+ return 0;
+}
+
+/** Returns 1 if the dmxScreen and the display in \a name are on the
+ * same display, or 0 otherwise. We can't just compare the display
+ * names because there can be multiple synonyms for the same display,
+ * some of which cannot be determined without accessing the display
+ * itself (e.g., domain aliases or machines with multiple NICs). */
+int dmxPropertySameDisplay(DMXScreenInfo *dmxScreen, const char *name)
+{
+ Display *dpy0 = dmxScreen->beDisplay;
+ Atom atom0;
+ XTextProperty tp0;
+ Display *dpy1 = NULL;
+ Atom atom1;
+ XTextProperty tp1;
+ int retval = 0;
+
+ if (!dpy0)
+ return 0;
+
+ tp0.nitems = 0;
+ tp1.nitems = 0;
+
+ if ((atom0 = XInternAtom(dpy0, DMX_ATOMNAME, True)) == None) {
+ dmxLog(dmxWarning, "No atom on %s\n", dmxScreen->name);
+ return 0;
+ }
+ if (!XGetTextProperty(dpy0, RootWindow(dpy0,0), &tp0, atom0)
+ || !tp0.nitems) {
+ dmxLog(dmxWarning, "No text property on %s\n", dmxScreen->name);
+ return 0;
+ }
+
+ if (!(dpy1 = XOpenDisplay(name))) {
+ dmxLog(dmxWarning, "Cannot open %s\n", name);
+ goto cleanup;
+ }
+ atom1 = XInternAtom(dpy1, DMX_ATOMNAME, True);
+ if (atom1 == None) {
+ dmxLog(dmxDebug, "No atom on %s\n", name);
+ goto cleanup;
+ }
+ if (!XGetTextProperty(dpy1, RootWindow(dpy1,0), &tp1, atom1)
+ || !tp1.nitems) {
+ dmxLog(dmxDebug, "No text property on %s\n", name);
+ goto cleanup;
+ }
+ if (!strcmp((char *)tp0.value, (char *)tp1.value)) retval = 1;
+
+ cleanup:
+ if (tp0.nitems) XFree(tp0.value);
+ if (tp1.nitems) XFree(tp1.value);
+ if (dpy1) XCloseDisplay(dpy1);
+ return retval;
+}
+
+/** Prints a log message if \a dmxScreen is on the same backend X server
+ * as some other DMX backend (output) screen. Modifies the property
+ * (#DMX_ATOMNAME) on the backend X server to reflect the creation of \a
+ * dmxScreen.
+ *
+ * The root window of the backend X server holds a list of window ids
+ * for all DMX windows (on this DMX server or some other DMX server).
+ *
+ * This list can then be iterated, and the property for each window can
+ * be examined. This property contains the following tuple (no quotes):
+ *
+ * "#DMX_IDENT:<hostname running DMX>:<display name of DMX>,<screen number>"
+ */
+void dmxPropertyWindow(DMXScreenInfo *dmxScreen)
+{
+ Atom atom;
+ const unsigned char *id = dmxPropertyIdentifier();
+ Display *dpy = dmxScreen->beDisplay;
+ Window win = dmxScreen->scrnWin;
+ DMXScreenInfo *other;
+ char buf[128]; /* RATS: only used with XmuSnprintf */
+
+ if (!dpy)
+ return; /* FIXME: What should be done here if Xdmx is started
+ * with this screen initially detached?
+ */
+
+ atom = XInternAtom(dpy, DMX_ATOMNAME, False);
+ if ((other = dmxPropertyCheckOtherWindows(dmxScreen, atom))) {
+ DMXScreenInfo *tmp = dmxScreen->next;
+ dmxScreen->next = (other->next ? other->next : other);
+ other->next = (tmp ? tmp : dmxScreen);
+ dmxLog(dmxDebug, "%d/%s/%lu and %d/%s/%lu are on the same backend\n",
+ dmxScreen->index, dmxScreen->name, dmxScreen->scrnWin,
+ other->index, other->name, other->scrnWin);
+ }
+
+ XmuSnprintf(buf, sizeof(buf), ".%d,%lu", dmxScreen->index,
+ (long unsigned)win);
+ XChangeProperty(dpy, RootWindow(dpy,0), atom, XA_STRING, 8,
+ PropModeAppend, (unsigned char *)buf, strlen(buf));
+
+ XmuSnprintf(buf, sizeof(buf), "%s,%d", id, dmxScreen->index);
+ XChangeProperty(dpy, win, atom, XA_STRING, 8,
+ PropModeAppend, (unsigned char *)buf, strlen(buf));
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxprop.h b/nx-X11/programs/Xserver/hw/dmx/dmxprop.h
new file mode 100644
index 000000000..f0c5afb95
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxprop.h
@@ -0,0 +1,47 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002,2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for property support. \see dmxprop.c */
+
+#ifndef _DMXPROP_H_
+#define _DMXPROP_H_
+extern int dmxPropertyDisplay(DMXScreenInfo *dmxScreen);
+extern void dmxPropertyWindow(DMXScreenInfo *dmxScreen);
+extern void *dmxPropertyIterate(DMXScreenInfo *start,
+ void *(*f)(DMXScreenInfo *dmxScreen,
+ void *closure),
+ void *closure);
+extern int dmxPropertySameDisplay(DMXScreenInfo *dmxScreen, const char *name);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxscrinit.c b/nx-X11/programs/Xserver/hw/dmx/dmxscrinit.c
new file mode 100644
index 000000000..5bfb4df0a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxscrinit.c
@@ -0,0 +1,566 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ * David H. Dawes <dawes@xfree86.org>
+ *
+ */
+
+/** \file
+ * This file provides support for screen initialization. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxsync.h"
+#include "dmxshadow.h"
+#include "dmxscrinit.h"
+#include "dmxcursor.h"
+#include "dmxgc.h"
+#include "dmxgcops.h"
+#include "dmxwindow.h"
+#include "dmxpixmap.h"
+#include "dmxfont.h"
+#include "dmxcmap.h"
+#include "dmxprop.h"
+#include "dmxdpms.h"
+
+#ifdef RENDER
+#include "dmxpict.h"
+#endif
+
+#include "fb.h"
+#include "mipointer.h"
+#include "micmap.h"
+
+extern Bool dmxCloseScreen(int idx, ScreenPtr pScreen);
+static Bool dmxSaveScreen(ScreenPtr pScreen, int what);
+
+static unsigned long dmxGeneration;
+static unsigned long *dmxCursorGeneration;
+
+int dmxGCPrivateIndex; /**< Private index for GCs */
+int dmxWinPrivateIndex; /**< Private index for Windows */
+#ifdef PIXPRIV
+int dmxPixPrivateIndex; /**< Private index for Pixmaps */
+#endif
+int dmxFontPrivateIndex; /**< Private index for Fonts */
+int dmxScreenPrivateIndex; /**< Private index for Screens */
+int dmxColormapPrivateIndex; /**< Private index for Colormaps */
+#ifdef RENDER
+int dmxPictPrivateIndex; /**< Private index for Picts */
+int dmxGlyphSetPrivateIndex; /**< Private index for GlyphSets */
+#endif
+
+/** Initialize the parts of screen \a idx that require access to the
+ * back-end server. */
+void dmxBEScreenInit(int idx, ScreenPtr pScreen)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ XSetWindowAttributes attribs;
+ XGCValues gcvals;
+ unsigned long mask;
+ int i, j;
+
+ /* FIXME: The dmxScreenInit() code currently assumes that it will
+ * not be called if the Xdmx server is started with this screen
+ * detached -- i.e., it assumes that dmxScreen->beDisplay is always
+ * valid. This is not necessarily a valid assumption when full
+ * addition/removal of screens is implemented, but when this code is
+ * broken out for screen reattachment, then we will reevaluate this
+ * assumption.
+ */
+
+ pScreen->mmWidth = DisplayWidthMM(dmxScreen->beDisplay,
+ DefaultScreen(dmxScreen->beDisplay));
+ pScreen->mmHeight = DisplayHeightMM(dmxScreen->beDisplay,
+ DefaultScreen(dmxScreen->beDisplay));
+
+ pScreen->whitePixel = dmxScreen->beWhitePixel;
+ pScreen->blackPixel = dmxScreen->beBlackPixel;
+
+ /* Handle screen savers and DPMS on the backend */
+ dmxDPMSInit(dmxScreen);
+
+ /* Create root window for screen */
+ mask = CWBackPixel | CWEventMask | CWColormap | CWOverrideRedirect;
+ attribs.background_pixel = dmxScreen->beBlackPixel;
+ attribs.event_mask = (KeyPressMask
+ | KeyReleaseMask
+ | ButtonPressMask
+ | ButtonReleaseMask
+ | EnterWindowMask
+ | LeaveWindowMask
+ | PointerMotionMask
+ | KeymapStateMask
+ | FocusChangeMask);
+ attribs.colormap = dmxScreen->beDefColormaps[dmxScreen->beDefVisualIndex];
+ attribs.override_redirect = True;
+
+ dmxScreen->scrnWin =
+ XCreateWindow(dmxScreen->beDisplay,
+ DefaultRootWindow(dmxScreen->beDisplay),
+ dmxScreen->scrnX,
+ dmxScreen->scrnY,
+ dmxScreen->scrnWidth,
+ dmxScreen->scrnHeight,
+ 0,
+ pScreen->rootDepth,
+ InputOutput,
+ dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual,
+ mask,
+ &attribs);
+ dmxPropertyWindow(dmxScreen);
+
+ /*
+ * This turns off the cursor by defining a cursor with no visible
+ * components.
+ */
+ {
+ char noCursorData[] = {0, 0, 0, 0,
+ 0, 0, 0, 0};
+ Pixmap pixmap;
+ XColor color, tmp;
+
+ pixmap = XCreateBitmapFromData(dmxScreen->beDisplay, dmxScreen->scrnWin,
+ noCursorData, 8, 8);
+ XAllocNamedColor(dmxScreen->beDisplay, dmxScreen->beDefColormaps[0],
+ "black", &color, &tmp);
+ dmxScreen->noCursor = XCreatePixmapCursor(dmxScreen->beDisplay,
+ pixmap, pixmap,
+ &color, &color, 0, 0);
+ XDefineCursor(dmxScreen->beDisplay, dmxScreen->scrnWin,
+ dmxScreen->noCursor);
+
+ XFreePixmap(dmxScreen->beDisplay, pixmap);
+ }
+
+ XMapWindow(dmxScreen->beDisplay, dmxScreen->scrnWin);
+
+ if (dmxShadowFB) {
+ mask = (GCFunction
+ | GCPlaneMask
+ | GCClipMask);
+ gcvals.function = GXcopy;
+ gcvals.plane_mask = AllPlanes;
+ gcvals.clip_mask = None;
+
+ dmxScreen->shadowGC = XCreateGC(dmxScreen->beDisplay,
+ dmxScreen->scrnWin,
+ mask, &gcvals);
+
+ dmxScreen->shadowFBImage =
+ XCreateImage(dmxScreen->beDisplay,
+ dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual,
+ dmxScreen->beDepth,
+ ZPixmap,
+ 0,
+ (char *)dmxScreen->shadow,
+ dmxScreen->scrnWidth, dmxScreen->scrnHeight,
+ dmxScreen->beBPP,
+ PixmapBytePad(dmxScreen->scrnWidth,
+ dmxScreen->beBPP));
+ } else {
+ /* Create default drawables (used during GC creation) */
+ for (i = 0; i < dmxScreen->beNumPixmapFormats; i++)
+ for (j = 0; j < dmxScreen->beNumDepths; j++)
+ if ((dmxScreen->bePixmapFormats[i].depth == 1) ||
+ (dmxScreen->bePixmapFormats[i].depth ==
+ dmxScreen->beDepths[j])) {
+ dmxScreen->scrnDefDrawables[i] = (Drawable)
+ XCreatePixmap(dmxScreen->beDisplay, dmxScreen->scrnWin,
+ 1, 1, dmxScreen->bePixmapFormats[i].depth);
+ break;
+ }
+ }
+}
+
+/** Initialize screen number \a idx. */
+Bool dmxScreenInit(int idx, ScreenPtr pScreen, int argc, char *argv[])
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ int i, j;
+
+ if (dmxGeneration != serverGeneration) {
+#ifdef RENDER
+ /* Allocate picture private index */
+ dmxPictPrivateIndex = AllocatePicturePrivateIndex();
+ if (dmxPictPrivateIndex == -1)
+ return FALSE;
+
+ /* Allocate glyph set private index */
+ dmxGlyphSetPrivateIndex = AllocateGlyphSetPrivateIndex();
+ if (dmxGlyphSetPrivateIndex == -1)
+ return FALSE;
+#endif
+
+ /* Allocate GC private index */
+ dmxGCPrivateIndex = AllocateGCPrivateIndex();
+ if (dmxGCPrivateIndex == -1)
+ return FALSE;
+
+ /* Allocate window private index */
+ dmxWinPrivateIndex = AllocateWindowPrivateIndex();
+ if (dmxWinPrivateIndex == -1)
+ return FALSE;
+
+#ifdef PIXPRIV
+ /* Allocate pixmap private index */
+ dmxPixPrivateIndex = AllocatePixmapPrivateIndex();
+ if (dmxPixPrivateIndex == -1)
+ return FALSE;
+#else
+#error Must define PIXPRIV to compile DMX X server
+#endif
+
+ /* Allocate font private index */
+ dmxFontPrivateIndex = AllocateFontPrivateIndex();
+ if (dmxFontPrivateIndex == -1)
+ return FALSE;
+
+ /* Allocate screen private index */
+ dmxScreenPrivateIndex = AllocateScreenPrivateIndex();
+ if (dmxScreenPrivateIndex == -1)
+ return FALSE;
+
+ dmxGeneration = serverGeneration;
+ }
+
+ if (dmxShadowFB) {
+ dmxScreen->shadow = shadowAlloc(dmxScreen->scrnWidth,
+ dmxScreen->scrnHeight,
+ dmxScreen->beBPP);
+ } else {
+ if (!dmxInitGC(pScreen)) return FALSE;
+ if (!dmxInitWindow(pScreen)) return FALSE;
+ if (!dmxInitPixmap(pScreen)) return FALSE;
+ }
+
+ /*
+ * Initalise the visual types. miSetVisualTypesAndMasks() requires
+ * that all of the types for each depth be collected together. It's
+ * intended for slightly different usage to what we would like here.
+ * Maybe a miAddVisualTypeAndMask() function will be added to make
+ * things easier here.
+ */
+ for (i = 0; i < dmxScreen->beNumDepths; i++) {
+ int depth;
+ int visuals = 0;
+ int bitsPerRgb = 0;
+ int preferredClass = -1;
+ Pixel redMask = 0;
+ Pixel greenMask = 0;
+ Pixel blueMask = 0;
+
+ depth = dmxScreen->beDepths[i];
+ for (j = 0; j < dmxScreen->beNumVisuals; j++) {
+ XVisualInfo *vi;
+
+ vi = &dmxScreen->beVisuals[j];
+ if (vi->depth == depth) {
+ /* Assume the masks are all the same. */
+ visuals |= (1 << vi->class);
+ bitsPerRgb = vi->bits_per_rgb;
+ redMask = vi->red_mask;
+ greenMask = vi->green_mask;
+ blueMask = vi->blue_mask;
+ if (j == dmxScreen->beDefVisualIndex) {
+ preferredClass = vi->class;
+ }
+ }
+ }
+ miSetVisualTypesAndMasks(depth, visuals, bitsPerRgb, preferredClass,
+ redMask, greenMask, blueMask);
+ }
+
+ fbScreenInit(pScreen,
+ dmxShadowFB ? dmxScreen->shadow : NULL,
+ dmxScreen->scrnWidth,
+ dmxScreen->scrnHeight,
+ dmxScreen->beXDPI,
+ dmxScreen->beXDPI,
+ dmxScreen->scrnWidth,
+ dmxScreen->beBPP);
+#ifdef RENDER
+ (void)dmxPictureInit(pScreen, 0, 0);
+#endif
+
+ if (dmxShadowFB && !shadowInit(pScreen, dmxShadowUpdateProc, NULL))
+ return FALSE;
+
+ miInitializeBackingStore(pScreen);
+
+ if (dmxShadowFB) {
+ miDCInitialize(pScreen, &dmxPointerCursorFuncs);
+ } else {
+ MAXSCREENSALLOC(dmxCursorGeneration);
+ if (dmxCursorGeneration[idx] != serverGeneration) {
+ if (!(miPointerInitialize(pScreen,
+ &dmxPointerSpriteFuncs,
+ &dmxPointerCursorFuncs,
+ FALSE)))
+ return FALSE;
+
+ dmxCursorGeneration[idx] = serverGeneration;
+ }
+ }
+
+ DMX_WRAP(CloseScreen, dmxCloseScreen, dmxScreen, pScreen);
+ DMX_WRAP(SaveScreen, dmxSaveScreen, dmxScreen, pScreen);
+
+ dmxBEScreenInit(idx, pScreen);
+
+ if (!dmxShadowFB) {
+ /* Wrap GC functions */
+ DMX_WRAP(CreateGC, dmxCreateGC, dmxScreen, pScreen);
+
+ /* Wrap Window functions */
+ DMX_WRAP(CreateWindow, dmxCreateWindow, dmxScreen, pScreen);
+ DMX_WRAP(DestroyWindow, dmxDestroyWindow, dmxScreen, pScreen);
+ DMX_WRAP(PositionWindow, dmxPositionWindow, dmxScreen, pScreen);
+ DMX_WRAP(ChangeWindowAttributes, dmxChangeWindowAttributes, dmxScreen,
+ pScreen);
+ DMX_WRAP(RealizeWindow, dmxRealizeWindow, dmxScreen, pScreen);
+ DMX_WRAP(UnrealizeWindow, dmxUnrealizeWindow, dmxScreen, pScreen);
+ DMX_WRAP(RestackWindow, dmxRestackWindow, dmxScreen, pScreen);
+ DMX_WRAP(WindowExposures, dmxWindowExposures, dmxScreen, pScreen);
+ DMX_WRAP(PaintWindowBackground, dmxPaintWindowBackground, dmxScreen,
+ pScreen);
+ DMX_WRAP(PaintWindowBorder, dmxPaintWindowBorder, dmxScreen, pScreen);
+ DMX_WRAP(CopyWindow, dmxCopyWindow, dmxScreen, pScreen);
+
+ DMX_WRAP(ResizeWindow, dmxResizeWindow, dmxScreen, pScreen);
+ DMX_WRAP(ReparentWindow, dmxReparentWindow, dmxScreen, pScreen);
+
+ DMX_WRAP(ChangeBorderWidth, dmxChangeBorderWidth, dmxScreen, pScreen);
+
+ /* Wrap Image functions */
+ DMX_WRAP(GetImage, dmxGetImage, dmxScreen, pScreen);
+ DMX_WRAP(GetSpans, dmxGetSpans, dmxScreen, pScreen);
+
+ /* Wrap Pixmap functions */
+ DMX_WRAP(CreatePixmap, dmxCreatePixmap, dmxScreen, pScreen);
+ DMX_WRAP(DestroyPixmap, dmxDestroyPixmap, dmxScreen, pScreen);
+ DMX_WRAP(BitmapToRegion, dmxBitmapToRegion, dmxScreen, pScreen);
+
+ /* Wrap Font functions */
+ DMX_WRAP(RealizeFont, dmxRealizeFont, dmxScreen, pScreen);
+ DMX_WRAP(UnrealizeFont, dmxUnrealizeFont, dmxScreen, pScreen);
+
+ /* Wrap Colormap functions */
+ DMX_WRAP(CreateColormap, dmxCreateColormap, dmxScreen, pScreen);
+ DMX_WRAP(DestroyColormap, dmxDestroyColormap, dmxScreen, pScreen);
+ DMX_WRAP(InstallColormap, dmxInstallColormap, dmxScreen, pScreen);
+ DMX_WRAP(StoreColors, dmxStoreColors, dmxScreen, pScreen);
+
+#ifdef SHAPE
+ /* Wrap Shape functions */
+ DMX_WRAP(SetShape, dmxSetShape, dmxScreen, pScreen);
+#endif
+ }
+
+ if (!dmxCreateDefColormap(pScreen))
+ return FALSE;
+
+ return TRUE;
+}
+
+/** Close the \a pScreen resources on the back-end server. */
+void dmxBECloseScreen(ScreenPtr pScreen)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ int i;
+
+ /* Restore the back-end screen-saver and DPMS state. */
+ dmxDPMSTerm(dmxScreen);
+
+ /* Free the screen resources */
+
+ XFreeCursor(dmxScreen->beDisplay, dmxScreen->noCursor);
+ dmxScreen->noCursor = (Cursor)0;
+
+ XUnmapWindow(dmxScreen->beDisplay, dmxScreen->scrnWin);
+ XDestroyWindow(dmxScreen->beDisplay, dmxScreen->scrnWin);
+ dmxScreen->scrnWin = (Window)0;
+
+ if (dmxShadowFB) {
+ /* Free the shadow GC and image assocated with the back-end server */
+ XFreeGC(dmxScreen->beDisplay, dmxScreen->shadowGC);
+ dmxScreen->shadowGC = NULL;
+ XFree(dmxScreen->shadowFBImage);
+ dmxScreen->shadowFBImage = NULL;
+ } else {
+ /* Free the default drawables */
+ for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) {
+ XFreePixmap(dmxScreen->beDisplay, dmxScreen->scrnDefDrawables[i]);
+ dmxScreen->scrnDefDrawables[i] = (Drawable)0;
+ }
+ }
+
+ /* Free resources allocated during initialization (in dmxinit.c) */
+ for (i = 0; i < dmxScreen->beNumDefColormaps; i++)
+ XFreeColormap(dmxScreen->beDisplay, dmxScreen->beDefColormaps[i]);
+ xfree(dmxScreen->beDefColormaps);
+ dmxScreen->beDefColormaps = NULL;
+
+#if 0
+ /* Do not free visuals, depths and pixmap formats here. Free them
+ * in dmxCloseScreen() instead -- see comment below. */
+ XFree(dmxScreen->beVisuals);
+ dmxScreen->beVisuals = NULL;
+
+ XFree(dmxScreen->beDepths);
+ dmxScreen->beDepths = NULL;
+
+ XFree(dmxScreen->bePixmapFormats);
+ dmxScreen->bePixmapFormats = NULL;
+#endif
+
+#ifdef GLXEXT
+ if (dmxScreen->glxVisuals) {
+ XFree(dmxScreen->glxVisuals);
+ dmxScreen->glxVisuals = NULL;
+ dmxScreen->numGlxVisuals = 0;
+ }
+#endif
+
+ /* Close display */
+ XCloseDisplay(dmxScreen->beDisplay);
+ dmxScreen->beDisplay = NULL;
+}
+
+/** Close screen number \a idx. */
+Bool dmxCloseScreen(int idx, ScreenPtr pScreen)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+
+ /* Reset the proc vectors */
+ if (idx == 0) {
+#ifdef RENDER
+ dmxResetRender();
+#endif
+ dmxResetFonts();
+ }
+
+ if (dmxShadowFB) {
+ /* Free the shadow framebuffer */
+ xfree(dmxScreen->shadow);
+ } else {
+
+#ifdef SHAPE
+ /* Unwrap Shape functions */
+ DMX_UNWRAP(SetShape, dmxScreen, pScreen);
+#endif
+
+ /* Unwrap the pScreen functions */
+ DMX_UNWRAP(CreateGC, dmxScreen, pScreen);
+
+ DMX_UNWRAP(CreateWindow, dmxScreen, pScreen);
+ DMX_UNWRAP(DestroyWindow, dmxScreen, pScreen);
+ DMX_UNWRAP(PositionWindow, dmxScreen, pScreen);
+ DMX_UNWRAP(ChangeWindowAttributes, dmxScreen, pScreen);
+ DMX_UNWRAP(RealizeWindow, dmxScreen, pScreen);
+ DMX_UNWRAP(UnrealizeWindow, dmxScreen, pScreen);
+ DMX_UNWRAP(RestackWindow, dmxScreen, pScreen);
+ DMX_UNWRAP(WindowExposures, dmxScreen, pScreen);
+ DMX_UNWRAP(PaintWindowBackground, dmxScreen, pScreen);
+ DMX_UNWRAP(PaintWindowBorder, dmxScreen, pScreen);
+ DMX_UNWRAP(CopyWindow, dmxScreen, pScreen);
+
+ DMX_UNWRAP(ResizeWindow, dmxScreen, pScreen);
+ DMX_UNWRAP(ReparentWindow, dmxScreen, pScreen);
+
+ DMX_UNWRAP(ChangeBorderWidth, dmxScreen, pScreen);
+
+ DMX_UNWRAP(GetImage, dmxScreen, pScreen);
+ DMX_UNWRAP(GetSpans, dmxScreen, pScreen);
+
+ DMX_UNWRAP(CreatePixmap, dmxScreen, pScreen);
+ DMX_UNWRAP(DestroyPixmap, dmxScreen, pScreen);
+ DMX_UNWRAP(BitmapToRegion, dmxScreen, pScreen);
+
+ DMX_UNWRAP(RealizeFont, dmxScreen, pScreen);
+ DMX_UNWRAP(UnrealizeFont, dmxScreen, pScreen);
+
+ DMX_UNWRAP(CreateColormap, dmxScreen, pScreen);
+ DMX_UNWRAP(DestroyColormap, dmxScreen, pScreen);
+ DMX_UNWRAP(InstallColormap, dmxScreen, pScreen);
+ DMX_UNWRAP(StoreColors, dmxScreen, pScreen);
+ }
+
+ DMX_UNWRAP(SaveScreen, dmxScreen, pScreen);
+
+ if (dmxScreen->beDisplay) {
+ dmxBECloseScreen(pScreen);
+
+#if 1
+ /* Free visuals, depths and pixmap formats here so that they
+ * won't be freed when a screen is detached, thereby allowing
+ * the screen to be reattached to be compared to the one
+ * previously removed.
+ */
+ XFree(dmxScreen->beVisuals);
+ dmxScreen->beVisuals = NULL;
+
+ XFree(dmxScreen->beDepths);
+ dmxScreen->beDepths = NULL;
+
+ XFree(dmxScreen->bePixmapFormats);
+ dmxScreen->bePixmapFormats = NULL;
+#endif
+ }
+
+ DMX_UNWRAP(CloseScreen, dmxScreen, pScreen);
+ return pScreen->CloseScreen(idx, pScreen);
+}
+
+static Bool dmxSaveScreen(ScreenPtr pScreen, int what)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+
+ if (dmxScreen->beDisplay) {
+ switch (what) {
+ case SCREEN_SAVER_OFF:
+ case SCREEN_SAVER_FORCER:
+ XResetScreenSaver(dmxScreen->beDisplay);
+ dmxSync(dmxScreen, FALSE);
+ break;
+ case SCREEN_SAVER_ON:
+ case SCREEN_SAVER_CYCLE:
+ XActivateScreenSaver(dmxScreen->beDisplay);
+ dmxSync(dmxScreen, FALSE);
+ break;
+ }
+ }
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxscrinit.h b/nx-X11/programs/Xserver/hw/dmx/dmxscrinit.h
new file mode 100644
index 000000000..91be0948c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxscrinit.h
@@ -0,0 +1,52 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ * David H. Dawes <dawes@xfree86.org>
+ *
+ */
+
+/** \file
+ * Interface for screen initialization. \see dmxscrinit.c */
+
+#ifndef DMXSCRINIT_H
+#define DMXSCRINIT_H
+
+#include "scrnintstr.h"
+
+/** Private index. \see dmxscrrinit.c \see input/dmxconcole.c */
+extern int dmxScreenPrivateIndex;
+
+extern Bool dmxScreenInit(int idx, ScreenPtr pScreen, int argc, char *argv[]);
+
+extern void dmxBEScreenInit(int idx, ScreenPtr pScreen);
+extern void dmxBECloseScreen(ScreenPtr pScreen);
+
+#endif /* DMXSCRINIT_H */
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxshadow.c b/nx-X11/programs/Xserver/hw/dmx/dmxshadow.c
new file mode 100644
index 000000000..8d1e147d1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxshadow.c
@@ -0,0 +1,72 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ * David H. Dawes <dawes@xfree86.org>
+ *
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxsync.h"
+#include "dmxshadow.h"
+
+/** \file
+ * This file provides support for the shadow frame buffer. */
+
+/** Update the screen from the shadow frame buffer. */
+void dmxShadowUpdateProc(ScreenPtr pScreen, shadowBufPtr pBuf)
+{
+ RegionPtr damage = &pBuf->damage;
+ int nbox = REGION_NUM_RECTS(damage);
+ BoxPtr pbox = REGION_RECTS(damage);
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+
+ if (!dmxScreen->beDisplay)
+ return;
+
+ while (nbox--) {
+ XPutImage(dmxScreen->beDisplay,
+ dmxScreen->scrnWin,
+ dmxScreen->shadowGC,
+ dmxScreen->shadowFBImage,
+ pbox->x1, pbox->y1,
+ pbox->x1, pbox->y1,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+
+ pbox++;
+ }
+
+ dmxSync(dmxScreen, FALSE);
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxshadow.h b/nx-X11/programs/Xserver/hw/dmx/dmxshadow.h
new file mode 100644
index 000000000..4ba084c99
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxshadow.h
@@ -0,0 +1,47 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ * David H. Dawes <dawes@xfree86.org>
+ *
+ */
+
+/** \file
+ * Interface for shadow framebuffer support. \see dmxshadow.c */
+
+#ifndef DMXSHADOW_H
+#define DMXSHADOW_H
+
+#include "shadow.h"
+#include "scrnintstr.h"
+
+extern void dmxShadowUpdateProc(ScreenPtr pScreen, shadowBufPtr pBuf);
+
+#endif /* DMXSHADOW_H */
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxstat.c b/nx-X11/programs/Xserver/hw/dmx/dmxstat.c
new file mode 100644
index 000000000..3b092b2a8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxstat.c
@@ -0,0 +1,223 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002, 2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * The DMX server code is written to call #dmxSync() whenever an XSync()
+ * might be necessary. However, since XSync() requires a two way
+ * communication with the other X server, eliminating unnecessary
+ * XSync() calls is a key performance optimization. Support for this
+ * optimization is provided in #dmxsync.c. This file provides routines
+ * that evaluate this optimization by counting the number of XSync()
+ * calls and monitoring their latency. This functionality can be turned
+ * on using the -stat command-line parameter. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxstat.h"
+#include "dmxlog.h"
+#include <X11/Xos.h> /* For sys/time.h */
+
+/** Used to compute a running average of value. */
+typedef struct _DMXStatAvg {
+ int pos;
+ int count;
+ unsigned long value[DMX_STAT_LENGTH];
+} DMXStatAvg;
+
+/** Statistical information about XSync calls. */
+struct _DMXStatInfo {
+ unsigned long syncCount;
+ unsigned long oldSyncCount;
+
+ DMXStatAvg usec;
+ DMXStatAvg pending;
+
+ unsigned long bins[DMX_STAT_BINS];
+};
+
+/* Interval in mS between statistic message log entries. */
+ int dmxStatInterval;
+static int dmxStatDisplays;
+static OsTimerPtr dmxStatTimer;
+
+/** Return the number of microseconds as an unsigned long.
+ * Unfortunately, this is only useful for intervals < about 4 sec. */
+static unsigned long usec(struct timeval *stop, struct timeval *start)
+{
+ return (stop->tv_sec - start->tv_sec) * 1000000
+ + stop->tv_usec - start->tv_usec;
+}
+
+static unsigned long avg(DMXStatAvg *data, unsigned long *max)
+{
+ unsigned long sum;
+ int i;
+
+ *max = 0;
+ if (!data->count) return 0;
+
+ for (i = 0, sum = 0; i < data->count; i++) {
+ if (data->value[i] > *max) *max = data->value[i];
+ sum += data->value[i];
+ }
+ return sum / data->count;
+}
+
+/** Turn on XSync statistic gathering and printing. Print every \a
+ * interval seconds, with lines for the first \a displays. If \a
+ * interval is NULL, 1 will be used. If \a displays is NULL, 0 will be
+ * used (meaning a line for every display will be printed). Note that
+ * this function takes string arguments because it will usually be
+ * called from #ddxProcessArgument in #dmxinit.c. */
+void dmxStatActivate(const char *interval, const char *displays)
+{
+ dmxStatInterval = (interval ? atoi(interval) : 1) * 1000;
+ dmxStatDisplays = (displays ? atoi(displays) : 0);
+
+ if (dmxStatInterval < 1000) dmxStatInterval = 1000;
+ if (dmxStatDisplays < 0) dmxStatDisplays = 0;
+}
+
+/** Allocate a \a DMXStatInfo structure. */
+DMXStatInfo *dmxStatAlloc(void)
+{
+ DMXStatInfo *pt = malloc(sizeof(*pt));
+ memset(pt, 0, sizeof(*pt));
+ return pt;
+}
+
+/** Free the memory used by a \a DMXStatInfo structure. */
+void dmxStatFree(DMXStatInfo *pt)
+{
+ if (pt) free(pt);
+}
+
+static void dmxStatValue(DMXStatAvg *data, unsigned long value)
+{
+ if (data->count != DMX_STAT_LENGTH) ++data->count;
+ if (data->pos >= DMX_STAT_LENGTH-1) data->pos = 0;
+ data->value[data->pos++] = value;
+}
+
+/** Note that a XSync() was just done on \a dmxScreen with the \a start
+ * and \a stop times (from gettimeofday()) and the number of
+ * pending-but-not-yet-processed XSync requests. This routine is called
+ * from #dmxDoSync in #dmxsync.c */
+void dmxStatSync(DMXScreenInfo *dmxScreen,
+ struct timeval *stop, struct timeval *start,
+ unsigned long pending)
+{
+ DMXStatInfo *s = dmxScreen->stat;
+ unsigned long elapsed = usec(stop, start);
+ unsigned long thresh;
+ int i;
+
+ ++s->syncCount;
+ dmxStatValue(&s->usec, elapsed);
+ dmxStatValue(&s->pending, pending);
+
+ for (i = 0, thresh = DMX_STAT_BIN0; i < DMX_STAT_BINS-1; i++) {
+ if (elapsed < thresh) {
+ ++s->bins[i];
+ break;
+ }
+ thresh *= DMX_STAT_BINMULT;
+ }
+ if (i == DMX_STAT_BINS-1) ++s->bins[i];
+}
+
+/* Actually do the work of printing out the human-readable message. */
+static CARD32 dmxStatCallback(OsTimerPtr timer, CARD32 t, pointer arg)
+{
+ int i, j;
+ static int header = 0;
+ int limit = dmxNumScreens;
+
+ if (!dmxNumScreens) {
+ header = 0;
+ return DMX_STAT_INTERVAL;
+ }
+
+ if (!header++ || !(header % 10)) {
+ dmxLog(dmxDebug,
+ " S SyncCount Sync/s avSync mxSync avPend mxPend | "
+ "<10ms <1s >1s\n");
+ }
+
+ if (dmxStatDisplays && dmxStatDisplays < limit) limit = dmxStatDisplays;
+ for (i = 0; i < limit; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ DMXStatInfo *s = dmxScreen->stat;
+ unsigned long aSync, mSync;
+ unsigned long aPend, mPend;
+
+ if (!s) continue;
+
+ aSync = avg(&s->usec, &mSync);
+ aPend = avg(&s->pending, &mPend);
+ dmxLog(dmxDebug, "%2d %9lu %7lu %6lu %6lu %6lu %6lu |",
+ i, /* S */
+ s->syncCount, /* SyncCount */
+ (s->syncCount
+ - s->oldSyncCount) * 1000 / dmxStatInterval, /* Sync/s */
+ aSync, /* us/Sync */
+ mSync, /* max/Sync */
+ aPend, /* avgPend */
+ mPend); /* maxPend */
+ for (j = 0; j < DMX_STAT_BINS; j++)
+ dmxLogCont(dmxDebug, " %5lu", s->bins[j]);
+ dmxLogCont(dmxDebug, "\n");
+
+ /* Reset/clear */
+ s->oldSyncCount = s->syncCount;
+ for (j = 0; j < DMX_STAT_BINS; j++) s->bins[j] = 0;
+ }
+ return DMX_STAT_INTERVAL; /* Place on queue again */
+}
+
+/** Try to initialize the statistic gathering and printing routines.
+ * Initialization only takes place if #dmxStatActivate has already been
+ * called. We don't need the same generation protection that we used in
+ * dmxSyncInit because our timer is always on a queue -- hence, server
+ * generation will always free it. */
+void dmxStatInit(void)
+{
+ if (dmxStatInterval)
+ dmxStatTimer = TimerSet(NULL, 0,
+ dmxStatInterval, dmxStatCallback, NULL);
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxstat.h b/nx-X11/programs/Xserver/hw/dmx/dmxstat.h
new file mode 100644
index 000000000..5411272ca
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxstat.h
@@ -0,0 +1,56 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for statistic gathering interface. \see dmxstat.c */
+
+#ifndef _DMXSTAT_H_
+#define _DMXSTAT_H_
+
+#define DMX_STAT_LENGTH 10 /**< number of events for moving average */
+#define DMX_STAT_INTERVAL 1000 /**< msec between printouts */
+#define DMX_STAT_BINS 3 /**< number of bins */
+#define DMX_STAT_BIN0 10000 /**< us for bin[0] */
+#define DMX_STAT_BINMULT 100 /**< multiplier for next bin[] */
+
+extern int dmxStatInterval; /**< Only for dmxstat.c and dmxsync.c */
+extern void dmxStatActivate(const char *interval, const char *displays);
+extern DMXStatInfo *dmxStatAlloc(void);
+extern void dmxStatFree(DMXStatInfo *);
+extern void dmxStatInit(void);
+extern void dmxStatSync(DMXScreenInfo *dmxScreen,
+ struct timeval *stop, struct timeval *start,
+ unsigned long pending);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxsync.c b/nx-X11/programs/Xserver/hw/dmx/dmxsync.c
new file mode 100644
index 000000000..02e244697
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxsync.c
@@ -0,0 +1,194 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * The DMX server code is written to call #dmxSync() whenever an XSync()
+ * might be necessary. However, since XSync() requires a two way
+ * communication with the other X server, eliminating unnecessary
+ * XSync() calls is a key performance optimization. Support for this
+ * optimization is provided here. Statistics about XSync() calls and
+ * latency are gathered in #dmxstat.c.
+ *
+ * During the initial conversion from calling XSync() immediately to the
+ * XSync() batching method implemented in this file, it was noted that,
+ * out of more than 300 \a x11perf tests, 8 tests became more than 100
+ * times faster, with 68 more than 50X faster, 114 more than 10X faster,
+ * and 181 more than 2X faster. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxsync.h"
+#include "dmxstat.h"
+#include "dmxlog.h"
+#include <sys/time.h>
+
+static int dmxSyncInterval = 100; /* Default interval in milliseconds */
+static OsTimerPtr dmxSyncTimer;
+static int dmxSyncPending;
+
+static void dmxDoSync(DMXScreenInfo *dmxScreen)
+{
+ dmxScreen->needsSync = FALSE;
+
+ if (!dmxScreen->beDisplay)
+ return; /* FIXME: Is this correct behavior for sync stats? */
+
+ if (!dmxStatInterval) {
+ XSync(dmxScreen->beDisplay, False);
+ } else {
+ struct timeval start, stop;
+
+ gettimeofday(&start, 0);
+ XSync(dmxScreen->beDisplay, False);
+ gettimeofday(&stop, 0);
+ dmxStatSync(dmxScreen, &stop, &start, dmxSyncPending);
+ }
+}
+
+static CARD32 dmxSyncCallback(OsTimerPtr timer, CARD32 time, pointer arg)
+{
+ int i;
+
+ if (dmxSyncPending) {
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ if (dmxScreen->needsSync) dmxDoSync(dmxScreen);
+ }
+ }
+ dmxSyncPending = 0;
+ return 0; /* Do not place on queue again */
+}
+
+static void dmxSyncBlockHandler(pointer blockData, OSTimePtr pTimeout,
+ pointer pReadMask)
+{
+ TimerForce(dmxSyncTimer);
+}
+
+static void dmxSyncWakeupHandler(pointer blockData, int result,
+ pointer pReadMask)
+{
+}
+
+/** Request the XSync() batching optimization with the specified \a
+ * interval (in mS). If the \a interval is 0, 100mS is used. If the \a
+ * interval is less than 0, then the XSync() batching optimization is
+ * not requested (e.g., so the -syncbatch -1 command line option can
+ * turn off the default 100mS XSync() batching).
+ *
+ * Note that the parameter to this routine is a string, since it will
+ * usually be called from #ddxProcessArgument in #dmxinit.c */
+void dmxSyncActivate(const char *interval)
+{
+ dmxSyncInterval = (interval ? atoi(interval) : 100);
+
+ if (dmxSyncInterval < 0) dmxSyncInterval = 0;
+}
+
+/** Initialize the XSync() batching optimization, but only if
+ * #dmxSyncActivate was last called with a non-negative value. */
+void dmxSyncInit(void)
+{
+ if (dmxSyncInterval) {
+ RegisterBlockAndWakeupHandlers(dmxSyncBlockHandler,
+ dmxSyncWakeupHandler,
+ NULL);
+ dmxLog(dmxInfo, "XSync batching with %d ms interval\n",
+ dmxSyncInterval);
+ } else {
+ dmxLog(dmxInfo, "XSync batching disabled\n");
+ }
+}
+
+/** Request an XSync() to the display used by \a dmxScreen. If \a now
+ * is TRUE, call XSync() immediately instead of waiting for the next
+ * XSync() batching point. Note that if XSync() batching was deselected
+ * with #dmxSyncActivate() before #dmxSyncInit() was called, then no
+ * XSync() batching is performed and this function always calles XSync()
+ * immediately.
+ *
+ * (Note that this function uses TimerSet but works correctly in the
+ * face of a server generation. See the source for details.)
+ *
+ * If \a dmxScreen is \a NULL, then all pending syncs will be flushed
+ * immediately.
+ */
+void dmxSync(DMXScreenInfo *dmxScreen, Bool now)
+{
+ static unsigned long dmxGeneration = 0;
+
+ if (dmxSyncInterval) {
+ if (dmxGeneration != serverGeneration) {
+ /* Server generation does a TimerInit, which frees all
+ * timers. So, at this point dmxSyncTimer is either:
+ * 1) NULL, iff dmxGeneration == 0,
+ * 2) freed, if it was on a queue (dmxSyncPending != 0), or
+ * 3) allocated, if it wasn't on a queue (dmxSyncPending == 0)
+ */
+ if (dmxSyncTimer && !dmxSyncPending) xfree(dmxSyncTimer);
+ dmxSyncTimer = NULL;
+ now = TRUE;
+ dmxGeneration = serverGeneration;
+ }
+ /* Queue sync */
+ if (dmxScreen) {
+ dmxScreen->needsSync = TRUE;
+ ++dmxSyncPending;
+ }
+
+ /* Do sync or set time for later */
+ if (now || !dmxScreen) {
+ if (!TimerForce(dmxSyncTimer)) dmxSyncCallback(NULL, 0, NULL);
+ /* At this point, dmxSyncPending == 0 because
+ * dmxSyncCallback must have been called. */
+ if (dmxSyncPending)
+ dmxLog(dmxFatal, "dmxSync(%s,%d): dmxSyncPending = %d\n",
+ dmxScreen ? dmxScreen->name : "", now, dmxSyncPending);
+ } else {
+ dmxScreen->needsSync = TRUE;
+ if (dmxSyncPending == 1)
+ dmxSyncTimer = TimerSet(dmxSyncTimer, 0, dmxSyncInterval,
+ dmxSyncCallback, NULL);
+ }
+ } else {
+ /* If dmxSyncInterval is not being used,
+ * then all the backends are already
+ * up-to-date. */
+ if (dmxScreen) dmxDoSync(dmxScreen);
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxsync.h b/nx-X11/programs/Xserver/hw/dmx/dmxsync.h
new file mode 100644
index 000000000..85fd36c07
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxsync.h
@@ -0,0 +1,44 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for sync support. \see dmxsync.c */
+
+#ifndef _DMXSYNC_H_
+#define _DMXSYNC_H_
+
+extern void dmxSyncActivate(const char *interval);
+extern void dmxSyncInit(void);
+extern void dmxSync(DMXScreenInfo *dmxScreen, Bool now);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxvisual.c b/nx-X11/programs/Xserver/hw/dmx/dmxvisual.c
new file mode 100644
index 000000000..23ff0acfa
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxvisual.c
@@ -0,0 +1,141 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * This file provides support for visuals. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxvisual.h"
+
+#include "scrnintstr.h"
+
+#ifdef GLXEXT
+
+#include <GL/glxint.h>
+
+extern VisualID glxMatchVisualInConfigList(ScreenPtr pScreen,
+ VisualPtr pVisual,
+ __GLXvisualConfig *configs,
+ int nconfigs);
+
+static Visual *dmxLookupGLXVisual(ScreenPtr pScreen, VisualPtr pVisual)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ int j;
+ VisualID vid;
+
+ vid = glxMatchVisualInConfigList(pScreen, pVisual,
+ dmxScreen->glxVisuals,
+ dmxScreen->numGlxVisuals);
+ if (vid) {
+ /* Find the X visual of the matching GLX visual */
+ for (j = 0; j < dmxScreen->beNumVisuals; j++)
+ if (vid == dmxScreen->beVisuals[j].visualid)
+ return dmxScreen->beVisuals[j].visual;
+ }
+
+ /* No matching visual found */
+ return NULL;
+}
+#endif
+
+/** Return the visual that matched \a pVisual. */
+Visual *dmxLookupVisual(ScreenPtr pScreen, VisualPtr pVisual)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ int i;
+#ifdef GLXEXT
+ Visual *retval;
+#endif
+
+ if (!dmxScreen->beDisplay)
+ return NULL;
+
+#ifdef GLXEXT
+ if ((retval = dmxLookupGLXVisual(pScreen, pVisual)))
+ return retval;
+#endif
+
+ for (i = 0; i < dmxScreen->beNumVisuals; i++) {
+ if (pVisual->class == dmxScreen->beVisuals[i].class &&
+ pVisual->bitsPerRGBValue == dmxScreen->beVisuals[i].bits_per_rgb &&
+ pVisual->ColormapEntries == dmxScreen->beVisuals[i].colormap_size &&
+ pVisual->nplanes == dmxScreen->beVisuals[i].depth &&
+ pVisual->redMask == dmxScreen->beVisuals[i].red_mask &&
+ pVisual->greenMask == dmxScreen->beVisuals[i].green_mask &&
+ pVisual->blueMask == dmxScreen->beVisuals[i].blue_mask) {
+ return dmxScreen->beVisuals[i].visual;
+ }
+ }
+
+ return NULL;
+}
+
+/** Return the visual that matched the \a vid. */
+Visual *dmxLookupVisualFromID(ScreenPtr pScreen, VisualID vid)
+{
+ Visual *visual;
+ int i;
+
+ if (!dmxScreens[pScreen->myNum].beDisplay)
+ return NULL;
+
+ for (i = 0; i < pScreen->numVisuals; i++) {
+ if (pScreen->visuals[i].vid == vid) {
+ visual = dmxLookupVisual(pScreen, &pScreen->visuals[i]);
+ if (visual) return visual;
+ }
+ }
+
+ return NULL;
+}
+
+/** Return the colormap for the \a visual. */
+Colormap dmxColormapFromDefaultVisual(ScreenPtr pScreen, Visual *visual)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ int i;
+
+ if (dmxScreen->beDisplay) {
+ for (i = 0; i < dmxScreen->beNumDefColormaps; i++)
+ if (visual == dmxScreen->beVisuals[i].visual)
+ return dmxScreen->beDefColormaps[i];
+ }
+
+ return None;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxvisual.h b/nx-X11/programs/Xserver/hw/dmx/dmxvisual.h
new file mode 100644
index 000000000..8701bf01f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxvisual.h
@@ -0,0 +1,48 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for visual support. \see dmxvisual.c */
+
+#ifndef DMXVISUAL_H
+#define DMXVISUAL_H
+
+#include "scrnintstr.h"
+
+extern Visual *dmxLookupVisual(ScreenPtr pScreen, VisualPtr pVisual);
+extern Visual *dmxLookupVisualFromID(ScreenPtr pScreen, VisualID vid);
+extern Colormap dmxColormapFromDefaultVisual(ScreenPtr pScreen,
+ Visual *visual);
+
+#endif /* DMXVISUAL_H */
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxwindow.c b/nx-X11/programs/Xserver/hw/dmx/dmxwindow.c
new file mode 100644
index 000000000..25456e228
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxwindow.c
@@ -0,0 +1,1085 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * This file provides support for window-related functions. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxsync.h"
+#include "dmxwindow.h"
+#include "dmxpixmap.h"
+#include "dmxcmap.h"
+#include "dmxvisual.h"
+#include "dmxinput.h"
+#include "dmxextension.h"
+#ifdef RENDER
+#include "dmxpict.h"
+#endif
+
+#include "windowstr.h"
+
+static void dmxDoRestackWindow(WindowPtr pWindow);
+static void dmxDoChangeWindowAttributes(WindowPtr pWindow,
+ unsigned long *mask,
+ XSetWindowAttributes *attribs);
+
+#ifdef SHAPE
+static void dmxDoSetShape(WindowPtr pWindow);
+#endif
+
+/** Initialize the private area for the window functions. */
+Bool dmxInitWindow(ScreenPtr pScreen)
+{
+ if (!AllocateWindowPrivate(pScreen, dmxWinPrivateIndex,
+ sizeof(dmxWinPrivRec)))
+ return FALSE;
+
+ return TRUE;
+}
+
+
+Window dmxCreateRootWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ Window parent;
+ Visual *visual;
+ unsigned long mask;
+ XSetWindowAttributes attribs;
+ ColormapPtr pCmap;
+ dmxColormapPrivPtr pCmapPriv;
+
+ /* Create root window */
+
+ parent = dmxScreen->scrnWin; /* This is our "Screen" window */
+ visual = dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual;
+
+ pCmap = (ColormapPtr)LookupIDByType(wColormap(pWindow), RT_COLORMAP);
+ pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
+
+ mask = CWEventMask | CWBackingStore | CWColormap | CWBorderPixel;
+ attribs.event_mask = ExposureMask;
+ attribs.backing_store = NotUseful;
+ attribs.colormap = pCmapPriv->cmap;
+ attribs.border_pixel = 0;
+
+ /* Incorporate new attributes, if needed */
+ if (pWinPriv->attribMask) {
+ dmxDoChangeWindowAttributes(pWindow, &pWinPriv->attribMask, &attribs);
+ mask |= pWinPriv->attribMask;
+ }
+
+ return XCreateWindow(dmxScreen->beDisplay,
+ parent,
+ pWindow->origin.x - wBorderWidth(pWindow),
+ pWindow->origin.y - wBorderWidth(pWindow),
+ pWindow->drawable.width,
+ pWindow->drawable.height,
+ pWindow->borderWidth,
+ pWindow->drawable.depth,
+ pWindow->drawable.class,
+ visual,
+ mask,
+ &attribs);
+}
+
+/** Change the location and size of the "screen" window. Called from
+ * #dmxReconfigureScreenWindow(). */
+void dmxResizeScreenWindow(ScreenPtr pScreen,
+ int x, int y, int w, int h)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ unsigned int m;
+ XWindowChanges c;
+
+ if (!dmxScreen->beDisplay)
+ return;
+
+ /* Handle resizing on back-end server */
+ m = CWX | CWY | CWWidth | CWHeight;
+ c.x = x;
+ c.y = y;
+ c.width = w;
+ c.height = h;
+
+ XConfigureWindow(dmxScreen->beDisplay, dmxScreen->scrnWin, m, &c);
+ dmxSync(dmxScreen, False);
+}
+
+/** Change the location and size of the "root" window. Called from
+ * #dmxReconfigureRootWindow(). */
+void dmxResizeRootWindow(WindowPtr pRoot,
+ int x, int y, int w, int h)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pRoot->drawable.pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pRoot);
+ unsigned int m;
+ XWindowChanges c;
+
+ /* Handle resizing on back-end server */
+ if (dmxScreen->beDisplay) {
+ m = CWX | CWY | CWWidth | CWHeight;
+ c.x = x;
+ c.y = y;
+ c.width = (w > 0) ? w : 1;
+ c.height = (h > 0) ? h : 1;
+
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ }
+
+ if (w == 0 || h == 0) {
+ if (pWinPriv->mapped) {
+ if (dmxScreen->beDisplay)
+ XUnmapWindow(dmxScreen->beDisplay, pWinPriv->window);
+ pWinPriv->mapped = FALSE;
+ }
+ } else if (!pWinPriv->mapped) {
+ if (dmxScreen->beDisplay)
+ XMapWindow(dmxScreen->beDisplay, pWinPriv->window);
+ pWinPriv->mapped = TRUE;
+ }
+
+ if (dmxScreen->beDisplay)
+ dmxSync(dmxScreen, False);
+}
+
+void dmxGetDefaultWindowAttributes(WindowPtr pWindow,
+ Colormap *cmap,
+ Visual **visual)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+
+ if (pWindow->drawable.class != InputOnly &&
+ pWindow->optional &&
+ pWindow->optional->visual != wVisual(pWindow->parent)) {
+
+ /* Find the matching visual */
+ *visual = dmxLookupVisualFromID(pScreen, wVisual(pWindow));
+
+ /* Handle optional colormaps */
+ if (pWindow->optional->colormap) {
+ ColormapPtr pCmap;
+ dmxColormapPrivPtr pCmapPriv;
+
+ pCmap = (ColormapPtr)LookupIDByType(wColormap(pWindow),
+ RT_COLORMAP);
+ pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
+ *cmap = pCmapPriv->cmap;
+ } else {
+ *cmap = dmxColormapFromDefaultVisual(pScreen, *visual);
+ }
+ } else {
+ *visual = CopyFromParent;
+ *cmap = (Colormap)0;
+ }
+}
+
+static Window dmxCreateNonRootWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ Window parent;
+ unsigned long mask = 0L;
+ XSetWindowAttributes attribs;
+ dmxWinPrivPtr pParentPriv = DMX_GET_WINDOW_PRIV(pWindow->parent);
+
+ /* Create window on back-end server */
+
+ parent = pParentPriv->window;
+
+ /* The parent won't exist if this call to CreateNonRootWindow came
+ from ReparentWindow and the grandparent window has not yet been
+ created */
+ if (!parent) {
+ dmxCreateAndRealizeWindow(pWindow->parent, FALSE);
+ parent = pParentPriv->window;
+ }
+
+ /* Incorporate new attributes, if needed */
+ if (pWinPriv->attribMask) {
+ dmxDoChangeWindowAttributes(pWindow, &pWinPriv->attribMask, &attribs);
+ mask |= pWinPriv->attribMask;
+ }
+
+ /* Add in default attributes */
+ if (pWindow->drawable.class != InputOnly) {
+ mask |= CWBackingStore;
+ attribs.backing_store = NotUseful;
+
+ if (!(mask & CWColormap) && pWinPriv->cmap) {
+ mask |= CWColormap;
+ attribs.colormap = pWinPriv->cmap;
+ if (!(mask & CWBorderPixel)) {
+ mask |= CWBorderPixel;
+ attribs.border_pixel = 0;
+ }
+ }
+ }
+
+ /* Handle case where subwindows are being mapped, but created out of
+ order -- if current window has a previous sibling, then it cannot
+ be created on top of the stack, so we must restack the windows */
+ pWinPriv->restacked = (pWindow->prevSib != NullWindow);
+
+ return XCreateWindow(dmxScreen->beDisplay,
+ parent,
+ pWindow->origin.x - wBorderWidth(pWindow),
+ pWindow->origin.y - wBorderWidth(pWindow),
+ pWindow->drawable.width,
+ pWindow->drawable.height,
+ pWindow->borderWidth,
+ pWindow->drawable.depth,
+ pWindow->drawable.class,
+ pWinPriv->visual,
+ mask,
+ &attribs);
+}
+
+/** This function handles lazy window creation and realization. Window
+ * creation is handled by #dmxCreateNonRootWindow(). It also handles
+ * any stacking changes that have occured since the window was
+ * originally created by calling #dmxDoRestackWindow(). If the window
+ * is shaped, the shape is set on the back-end server by calling
+ * #dmxDoSetShape(), and if the window has pictures (from RENDER)
+ * associated with it, those pictures are created on the back-end
+ * server by calling #dmxCreatePictureList(). If \a doSync is TRUE,
+ * then #dmxSync() is called. */
+void dmxCreateAndRealizeWindow(WindowPtr pWindow, Bool doSync)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ if (!dmxScreen->beDisplay) return;
+
+ pWinPriv->window = dmxCreateNonRootWindow(pWindow);
+ if (pWinPriv->restacked) dmxDoRestackWindow(pWindow);
+#ifdef SHAPE
+ if (pWinPriv->isShaped) dmxDoSetShape(pWindow);
+#endif
+#ifdef RENDER
+ if (pWinPriv->hasPict) dmxCreatePictureList(pWindow);
+#endif
+ if (pWinPriv->mapped) XMapWindow(dmxScreen->beDisplay,
+ pWinPriv->window);
+ if (doSync) dmxSync(dmxScreen, False);
+}
+
+/** Create \a pWindow on the back-end server. If the lazy window
+ * creation optimization is enabled, then the actual creation and
+ * realization of the window is handled by
+ * #dmxCreateAndRealizeWindow(). */
+Bool dmxCreateWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ Bool ret = TRUE;
+
+ DMX_UNWRAP(CreateWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->CreateWindow)
+ ret = pScreen->CreateWindow(pWindow);
+#endif
+
+ /* Set up the defaults */
+ pWinPriv->window = (Window)0;
+ pWinPriv->offscreen = TRUE;
+ pWinPriv->mapped = FALSE;
+ pWinPriv->restacked = FALSE;
+ pWinPriv->attribMask = 0;
+#ifdef SHAPE
+ pWinPriv->isShaped = FALSE;
+#endif
+#ifdef RENDER
+ pWinPriv->hasPict = FALSE;
+#endif
+#ifdef GLXEXT
+ pWinPriv->swapGroup = NULL;
+ pWinPriv->barrier = 0;
+#endif
+
+ if (dmxScreen->beDisplay) {
+ /* Only create the root window at this stage -- non-root windows are
+ created when they are mapped and are on-screen */
+ if (!pWindow->parent) {
+ dmxScreen->rootWin = pWinPriv->window
+ = dmxCreateRootWindow(pWindow);
+ if (dmxScreen->scrnX != dmxScreen->rootX
+ || dmxScreen->scrnY != dmxScreen->rootY
+ || dmxScreen->scrnWidth != dmxScreen->rootWidth
+ || dmxScreen->scrnHeight != dmxScreen->rootHeight) {
+ dmxResizeRootWindow(pWindow,
+ dmxScreen->rootX,
+ dmxScreen->rootY,
+ dmxScreen->rootWidth,
+ dmxScreen->rootHeight);
+ dmxUpdateScreenResources(screenInfo.screens[dmxScreen->index],
+ dmxScreen->rootX,
+ dmxScreen->rootY,
+ dmxScreen->rootWidth,
+ dmxScreen->rootHeight);
+ pWindow->origin.x = dmxScreen->rootX;
+ pWindow->origin.y = dmxScreen->rootY;
+ }
+ } else {
+ dmxGetDefaultWindowAttributes(pWindow,
+ &pWinPriv->cmap,
+ &pWinPriv->visual);
+
+ if (dmxLazyWindowCreation) {
+ /* Save parent's visual for use later */
+ if (pWinPriv->visual == CopyFromParent)
+ pWinPriv->visual =
+ dmxLookupVisualFromID(pScreen,
+ wVisual(pWindow->parent));
+ } else {
+ pWinPriv->window = dmxCreateNonRootWindow(pWindow);
+ }
+ }
+
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(CreateWindow, dmxCreateWindow, dmxScreen, pScreen);
+
+ return ret;
+}
+
+/** Destroy \a pWindow on the back-end server. */
+Bool dmxBEDestroyWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ if (pWinPriv->window) {
+ XDestroyWindow(dmxScreen->beDisplay, pWinPriv->window);
+ pWinPriv->window = (Window)0;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/** Destroy \a pWindow on the back-end server. If any RENDER pictures
+ were created, destroy them as well. */
+Bool dmxDestroyWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+ Bool needSync = FALSE;
+#ifdef GLXEXT
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+#endif
+
+ DMX_UNWRAP(DestroyWindow, dmxScreen, pScreen);
+
+#ifdef RENDER
+ /* Destroy any picture list associated with this window */
+ needSync |= dmxDestroyPictureList(pWindow);
+#endif
+
+ /* Destroy window on back-end server */
+ needSync |= dmxBEDestroyWindow(pWindow);
+ if (needSync) dmxSync(dmxScreen, FALSE);
+
+#ifdef GLXEXT
+ if (pWinPriv->swapGroup && pWinPriv->windowDestroyed)
+ pWinPriv->windowDestroyed(pWindow);
+#endif
+
+#if 0
+ if (pScreen->DestroyWindow)
+ ret = pScreen->DestroyWindow(pWindow);
+#endif
+ DMX_WRAP(DestroyWindow, dmxDestroyWindow, dmxScreen, pScreen);
+
+ return ret;
+}
+
+/** Change the position of \a pWindow to be \a x, \a y. */
+Bool dmxPositionWindow(WindowPtr pWindow, int x, int y)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ unsigned int m;
+ XWindowChanges c;
+
+ DMX_UNWRAP(PositionWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->PositionWindow)
+ ret = pScreen->PositionWindow(pWindow, x, y);
+#endif
+
+ /* Determine if the window is completely off the visible portion of
+ the screen */
+ pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
+
+ /* If the window is now on-screen and it is mapped and it has not
+ been created yet, create it and map it */
+ if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
+ dmxCreateAndRealizeWindow(pWindow, TRUE);
+ } else if (pWinPriv->window) {
+ /* Position window on back-end server */
+ m = CWX | CWY | CWWidth | CWHeight;
+ c.x = pWindow->origin.x - wBorderWidth(pWindow);
+ c.y = pWindow->origin.y - wBorderWidth(pWindow);
+ c.width = pWindow->drawable.width;
+ c.height = pWindow->drawable.height;
+ if (pWindow->drawable.class != InputOnly) {
+ m |= CWBorderWidth;
+ c.border_width = pWindow->borderWidth;
+ }
+
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(PositionWindow, dmxPositionWindow, dmxScreen, pScreen);
+
+ return ret;
+}
+
+static void dmxDoChangeWindowAttributes(WindowPtr pWindow,
+ unsigned long *mask,
+ XSetWindowAttributes *attribs)
+{
+ dmxPixPrivPtr pPixPriv;
+
+ if (*mask & CWBackPixmap) {
+ switch (pWindow->backgroundState) {
+ case None:
+ attribs->background_pixmap = None;
+ break;
+
+ case ParentRelative:
+ attribs->background_pixmap = ParentRelative;
+ break;
+
+ case BackgroundPixmap:
+ pPixPriv = DMX_GET_PIXMAP_PRIV(pWindow->background.pixmap);
+ attribs->background_pixmap = pPixPriv->pixmap;
+ break;
+
+ case BackgroundPixel:
+ *mask &= ~CWBackPixmap;
+ break;
+ }
+ }
+
+ if (*mask & CWBackPixel) {
+ if (pWindow->backgroundState == BackgroundPixel)
+ attribs->background_pixel = pWindow->background.pixel;
+ else
+ *mask &= ~CWBackPixel;
+ }
+
+ if (*mask & CWBorderPixmap) {
+ if (pWindow->borderIsPixel)
+ *mask &= ~CWBorderPixmap;
+ else {
+ pPixPriv = DMX_GET_PIXMAP_PRIV(pWindow->border.pixmap);
+ attribs->border_pixmap = pPixPriv->pixmap;
+ }
+ }
+
+ if (*mask & CWBorderPixel) {
+ if (pWindow->borderIsPixel)
+ attribs->border_pixel = pWindow->border.pixel;
+ else
+ *mask &= ~CWBorderPixel;
+ }
+
+ if (*mask & CWBitGravity)
+ attribs->bit_gravity = pWindow->bitGravity;
+
+ if (*mask & CWWinGravity)
+ *mask &= ~CWWinGravity; /* Handled by dix */
+
+ if (*mask & CWBackingStore)
+ *mask &= ~CWBackingStore; /* Backing store not supported */
+
+ if (*mask & CWBackingPlanes)
+ *mask &= ~CWBackingPlanes; /* Backing store not supported */
+
+ if (*mask & CWBackingPixel)
+ *mask &= ~CWBackingPixel; /* Backing store not supported */
+
+ if (*mask & CWOverrideRedirect)
+ attribs->override_redirect = pWindow->overrideRedirect;
+
+ if (*mask & CWSaveUnder)
+ *mask &= ~CWSaveUnder; /* Save unders not supported */
+
+ if (*mask & CWEventMask)
+ *mask &= ~CWEventMask; /* Events are handled by dix */
+
+ if (*mask & CWDontPropagate)
+ *mask &= ~CWDontPropagate; /* Events are handled by dix */
+
+ if (*mask & CWColormap) {
+ ColormapPtr pCmap;
+ dmxColormapPrivPtr pCmapPriv;
+
+ pCmap = (ColormapPtr)LookupIDByType(wColormap(pWindow), RT_COLORMAP);
+ pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
+ attribs->colormap = pCmapPriv->cmap;
+ }
+
+ if (*mask & CWCursor)
+ *mask &= ~CWCursor; /* Handled by the cursor code */
+}
+
+/** Change the window attributes of \a pWindow. */
+Bool dmxChangeWindowAttributes(WindowPtr pWindow, unsigned long mask)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ XSetWindowAttributes attribs;
+
+ DMX_UNWRAP(ChangeWindowAttributes, dmxScreen, pScreen);
+#if 0
+ if (pScreen->ChangeWindowAttributes)
+ ret = pScreen->ChangeWindowAttributes(pWindow, mask);
+#endif
+
+ /* Change window attribs on back-end server */
+ dmxDoChangeWindowAttributes(pWindow, &mask, &attribs);
+
+ /* Save mask for lazy window creation optimization */
+ pWinPriv->attribMask |= mask;
+
+ if (mask && pWinPriv->window) {
+ XChangeWindowAttributes(dmxScreen->beDisplay, pWinPriv->window,
+ mask, &attribs);
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(ChangeWindowAttributes, dmxChangeWindowAttributes, dmxScreen,
+ pScreen);
+
+ return ret;
+}
+
+/** Realize \a pWindow on the back-end server. If the lazy window
+ * creation optimization is enabled, the window is only realized when
+ * it at least partially overlaps the screen. */
+Bool dmxRealizeWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ DMX_UNWRAP(RealizeWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->RealizeWindow)
+ ret = pScreen->RealizeWindow(pWindow);
+#endif
+
+ /* Determine if the window is completely off the visible portion of
+ the screen */
+ pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
+
+ /* If the window hasn't been created and it's not offscreen, then
+ create it */
+ if (!pWinPriv->window && !pWinPriv->offscreen) {
+ dmxCreateAndRealizeWindow(pWindow, FALSE);
+ }
+
+ if (pWinPriv->window) {
+ /* Realize window on back-end server */
+ XMapWindow(dmxScreen->beDisplay, pWinPriv->window);
+ dmxSync(dmxScreen, False);
+ }
+
+ /* Let the other functions know that the window is now mapped */
+ pWinPriv->mapped = TRUE;
+
+ DMX_WRAP(RealizeWindow, dmxRealizeWindow, dmxScreen, pScreen);
+
+ dmxUpdateWindowInfo(DMX_UPDATE_REALIZE, pWindow);
+ return ret;
+}
+
+/** Unrealize \a pWindow on the back-end server. */
+Bool dmxUnrealizeWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ DMX_UNWRAP(UnrealizeWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->UnrealizeWindow)
+ ret = pScreen->UnrealizeWindow(pWindow);
+#endif
+
+ if (pWinPriv->window) {
+ /* Unrealize window on back-end server */
+ XUnmapWindow(dmxScreen->beDisplay, pWinPriv->window);
+ dmxSync(dmxScreen, False);
+ }
+
+ /* When unrealized (i.e., unmapped), the window is always considered
+ off of the visible portion of the screen */
+ pWinPriv->offscreen = TRUE;
+ pWinPriv->mapped = FALSE;
+
+#ifdef GLXEXT
+ if (pWinPriv->swapGroup && pWinPriv->windowUnmapped)
+ pWinPriv->windowUnmapped(pWindow);
+#endif
+
+ DMX_WRAP(UnrealizeWindow, dmxUnrealizeWindow, dmxScreen, pScreen);
+
+ dmxUpdateWindowInfo(DMX_UPDATE_UNREALIZE, pWindow);
+ return ret;
+}
+
+static void dmxDoRestackWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ WindowPtr pNextSib = pWindow->nextSib;
+ unsigned int m;
+ XWindowChanges c;
+
+ if (pNextSib == NullWindow) {
+ /* Window is at the bottom of the stack */
+ m = CWStackMode;
+ c.sibling = (Window)0;
+ c.stack_mode = Below;
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ } else {
+ /* Window is not at the bottom of the stack */
+ dmxWinPrivPtr pNextSibPriv = DMX_GET_WINDOW_PRIV(pNextSib);
+
+ /* Handle case where siblings have not yet been created due to
+ lazy window creation optimization by first finding the next
+ sibling in the sibling list that has been created (if any)
+ and then putting the current window just above that sibling,
+ and if no next siblings have been created yet, then put it at
+ the bottom of the stack (since it might have a previous
+ sibling that should be above it). */
+ while (!pNextSibPriv->window) {
+ pNextSib = pNextSib->nextSib;
+ if (pNextSib == NullWindow) {
+ /* Window is at the bottom of the stack */
+ m = CWStackMode;
+ c.sibling = (Window)0;
+ c.stack_mode = Below;
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ return;
+ }
+ pNextSibPriv = DMX_GET_WINDOW_PRIV(pNextSib);
+ }
+
+ m = CWStackMode | CWSibling;
+ c.sibling = pNextSibPriv->window;
+ c.stack_mode = Above;
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ }
+}
+
+/** Handle window restacking. The actual restacking occurs in
+ * #dmxDoRestackWindow(). */
+void dmxRestackWindow(WindowPtr pWindow, WindowPtr pOldNextSib)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ DMX_UNWRAP(RestackWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->RestackWindow)
+ pScreen->RestackWindow(pWindow, pOldNextSib);
+#endif
+
+ if (pOldNextSib != pWindow->nextSib) {
+ /* Track restacking for lazy window creation optimization */
+ pWinPriv->restacked = TRUE;
+
+ /* Restack window on back-end server */
+ if (pWinPriv->window) {
+ dmxDoRestackWindow(pWindow);
+ dmxSync(dmxScreen, False);
+ }
+ }
+
+ DMX_WRAP(RestackWindow, dmxRestackWindow, dmxScreen, pScreen);
+ dmxUpdateWindowInfo(DMX_UPDATE_RESTACK, pWindow);
+}
+
+static Bool dmxWindowExposurePredicate(Display *dpy, XEvent *ev, XPointer ptr)
+{
+ return (ev->type == Expose && ev->xexpose.window == *(Window *)ptr);
+}
+
+/** Handle exposures on \a pWindow. Since window exposures are handled
+ * in DMX, the events that are generated by the back-end server are
+ * redundant, so we eat them here. */
+void dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn,
+ RegionPtr other_exposed)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ XEvent ev;
+
+ DMX_UNWRAP(WindowExposures, dmxScreen, pScreen);
+
+ dmxSync(dmxScreen, False);
+
+ if (pWinPriv->window) {
+ while (XCheckIfEvent(dmxScreen->beDisplay, &ev,
+ dmxWindowExposurePredicate,
+ (XPointer)&pWinPriv->window)) {
+ /* Handle expose events -- this should not be necessary
+ since the base window in which the root window was
+ created is guaranteed to be on top (override_redirect),
+ so we should just swallow these events. If for some
+ reason the window is not on top, then we'd need to
+ collect these events and send them to the client later
+ (e.g., during the block handler as Xnest does). */
+ }
+ }
+
+#if 1
+ if (pScreen->WindowExposures)
+ pScreen->WindowExposures(pWindow, prgn, other_exposed);
+#endif
+ DMX_WRAP(WindowExposures, dmxWindowExposures, dmxScreen, pScreen);
+}
+
+/** Paint background of \a pWindow in \a pRegion. */
+void dmxPaintWindowBackground(WindowPtr pWindow, RegionPtr pRegion, int what)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ BoxPtr pBox;
+ int nBox;
+
+ DMX_UNWRAP(PaintWindowBackground, dmxScreen, pScreen);
+#if 0
+ if (pScreen->PaintWindowBackground)
+ pScreen->PaintWindowBackground(pWindow, pRegion, what);
+#endif
+
+ if (pWinPriv->window) {
+ /* Paint window background on back-end server */
+ pBox = REGION_RECTS(pRegion);
+ nBox = REGION_NUM_RECTS(pRegion);
+ while (nBox--) {
+ XClearArea(dmxScreen->beDisplay, pWinPriv->window,
+ pBox->x1 - pWindow->drawable.x,
+ pBox->y1 - pWindow->drawable.y,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1,
+ False);
+ pBox++;
+ }
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(PaintWindowBackground, dmxPaintWindowBackground, dmxScreen, pScreen);
+}
+
+/** Paint window border for \a pWindow in \a pRegion. */
+void dmxPaintWindowBorder(WindowPtr pWindow, RegionPtr pRegion, int what)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+
+ DMX_UNWRAP(PaintWindowBorder, dmxScreen, pScreen);
+#if 0
+ if (pScreen->PaintWindowBorder)
+ pScreen->PaintWindowBorder(pWindow, pRegion, what);
+#endif
+
+ /* Paint window border on back-end server */
+
+ DMX_WRAP(PaintWindowBorder, dmxPaintWindowBorder, dmxScreen, pScreen);
+}
+
+/** Move \a pWindow on the back-end server. Determine whether or not it
+ * is on or offscreen, and realize it if it is newly on screen and the
+ * lazy window creation optimization is enabled. */
+void dmxCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ unsigned int m;
+ XWindowChanges c;
+
+ DMX_UNWRAP(CopyWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->CopyWindow)
+ pScreen->CopyWindow(pWindow, ptOldOrg, prgnSrc);
+#endif
+
+ /* Determine if the window is completely off the visible portion of
+ the screen */
+ pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
+
+ /* If the window is now on-screen and it is mapped and it has not
+ been created yet, create it and map it */
+ if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
+ dmxCreateAndRealizeWindow(pWindow, TRUE);
+ } else if (pWinPriv->window) {
+ /* Move window on back-end server */
+ m = CWX | CWY | CWWidth | CWHeight;
+ c.x = pWindow->origin.x - wBorderWidth(pWindow);
+ c.y = pWindow->origin.y - wBorderWidth(pWindow);
+ c.width = pWindow->drawable.width;
+ c.height = pWindow->drawable.height;
+
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(CopyWindow, dmxCopyWindow, dmxScreen, pScreen);
+ dmxUpdateWindowInfo(DMX_UPDATE_COPY, pWindow);
+}
+
+/** Resize \a pWindow on the back-end server. Determine whether or not
+ * it is on or offscreen, and realize it if it is newly on screen and
+ * the lazy window creation optimization is enabled. */
+void dmxResizeWindow(WindowPtr pWindow, int x, int y,
+ unsigned int w, unsigned int h, WindowPtr pSib)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ dmxWinPrivPtr pSibPriv;
+ unsigned int m;
+ XWindowChanges c;
+
+ if (pSib)
+ pSibPriv = DMX_GET_WINDOW_PRIV(pSib);
+
+ DMX_UNWRAP(ResizeWindow, dmxScreen, pScreen);
+#if 1
+ if (pScreen->ResizeWindow)
+ pScreen->ResizeWindow(pWindow, x, y, w, h, pSib);
+#endif
+
+ /* Determine if the window is completely off the visible portion of
+ the screen */
+ pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
+
+ /* If the window is now on-screen and it is mapped and it has not
+ been created yet, create it and map it */
+ if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
+ dmxCreateAndRealizeWindow(pWindow, TRUE);
+ } else if (pWinPriv->window) {
+ /* Handle resizing on back-end server */
+ m = CWX | CWY | CWWidth | CWHeight;
+ c.x = pWindow->origin.x - wBorderWidth(pWindow);
+ c.y = pWindow->origin.y - wBorderWidth(pWindow);
+ c.width = pWindow->drawable.width;
+ c.height = pWindow->drawable.height;
+
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(ResizeWindow, dmxResizeWindow, dmxScreen, pScreen);
+ dmxUpdateWindowInfo(DMX_UPDATE_RESIZE, pWindow);
+}
+
+/** Reparent \a pWindow on the back-end server. */
+void dmxReparentWindow(WindowPtr pWindow, WindowPtr pPriorParent)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ dmxWinPrivPtr pParentPriv = DMX_GET_WINDOW_PRIV(pWindow->parent);
+
+ DMX_UNWRAP(ReparentWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->ReparentWindow)
+ pScreen->ReparentWindow(pWindow, pPriorParent);
+#endif
+
+ if (pWinPriv->window) {
+ if (!pParentPriv->window) {
+ dmxCreateAndRealizeWindow(pWindow->parent, FALSE);
+ }
+
+ /* Handle reparenting on back-end server */
+ XReparentWindow(dmxScreen->beDisplay, pWinPriv->window,
+ pParentPriv->window,
+ pWindow->origin.x - wBorderWidth(pWindow),
+ pWindow->origin.x - wBorderWidth(pWindow));
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(ReparentWindow, dmxReparentWindow, dmxScreen, pScreen);
+ dmxUpdateWindowInfo(DMX_UPDATE_REPARENT, pWindow);
+}
+
+/** Change border width for \a pWindow to \a width pixels. */
+void dmxChangeBorderWidth(WindowPtr pWindow, unsigned int width)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ unsigned int m;
+ XWindowChanges c;
+
+ DMX_UNWRAP(ChangeBorderWidth, dmxScreen, pScreen);
+#if 1
+ if (pScreen->ChangeBorderWidth)
+ pScreen->ChangeBorderWidth(pWindow, width);
+#endif
+
+ /* NOTE: Do we need to check for on/off screen here? */
+
+ if (pWinPriv->window) {
+ /* Handle border width change on back-end server */
+ m = CWBorderWidth;
+ c.border_width = width;
+
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(ChangeBorderWidth, dmxChangeBorderWidth, dmxScreen, pScreen);
+}
+
+#ifdef SHAPE
+static void dmxDoSetShape(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ int nBox;
+ BoxPtr pBox;
+ int nRect;
+ XRectangle *pRect;
+ XRectangle *pRectFirst;
+
+ /* First, set the bounding shape */
+ if (wBoundingShape(pWindow)) {
+ pBox = REGION_RECTS(wBoundingShape(pWindow));
+ nRect = nBox = REGION_NUM_RECTS(wBoundingShape(pWindow));
+ pRectFirst = pRect = xalloc(nRect * sizeof(*pRect));
+ while (nBox--) {
+ pRect->x = pBox->x1;
+ pRect->y = pBox->y1;
+ pRect->width = pBox->x2 - pBox->x1;
+ pRect->height = pBox->y2 - pBox->y1;
+ pBox++;
+ pRect++;
+ }
+ XShapeCombineRectangles(dmxScreen->beDisplay, pWinPriv->window,
+ ShapeBounding, 0, 0,
+ pRectFirst, nRect,
+ ShapeSet, YXBanded);
+ xfree(pRectFirst);
+ } else {
+ XShapeCombineMask(dmxScreen->beDisplay, pWinPriv->window,
+ ShapeBounding, 0, 0, None, ShapeSet);
+ }
+
+ /* Next, set the clip shape */
+ if (wClipShape(pWindow)) {
+ pBox = REGION_RECTS(wClipShape(pWindow));
+ nRect = nBox = REGION_NUM_RECTS(wClipShape(pWindow));
+ pRectFirst = pRect = xalloc(nRect * sizeof(*pRect));
+ while (nBox--) {
+ pRect->x = pBox->x1;
+ pRect->y = pBox->y1;
+ pRect->width = pBox->x2 - pBox->x1;
+ pRect->height = pBox->y2 - pBox->y1;
+ pBox++;
+ pRect++;
+ }
+ XShapeCombineRectangles(dmxScreen->beDisplay, pWinPriv->window,
+ ShapeClip, 0, 0,
+ pRectFirst, nRect,
+ ShapeSet, YXBanded);
+ xfree(pRectFirst);
+ } else {
+ XShapeCombineMask(dmxScreen->beDisplay, pWinPriv->window,
+ ShapeClip, 0, 0, None, ShapeSet);
+ }
+
+ if (XShapeInputSelected(dmxScreen->beDisplay, pWinPriv->window)) {
+ ErrorF("Input selected for window %x on Screen %d\n",
+ (unsigned int)pWinPriv->window, pScreen->myNum);
+ }
+}
+
+/** Set shape of \a pWindow on the back-end server. */
+void dmxSetShape(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ DMX_UNWRAP(SetShape, dmxScreen, pScreen);
+#if 1
+ if (pScreen->SetShape)
+ pScreen->SetShape(pWindow);
+#endif
+
+ if (pWinPriv->window) {
+ /* Handle setting the current shape on the back-end server */
+ dmxDoSetShape(pWindow);
+ dmxSync(dmxScreen, False);
+ } else {
+ pWinPriv->isShaped = TRUE;
+ }
+
+ DMX_WRAP(SetShape, dmxSetShape, dmxScreen, pScreen);
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/dmxwindow.h b/nx-X11/programs/Xserver/hw/dmx/dmxwindow.h
new file mode 100644
index 000000000..e6302fe3f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/dmxwindow.h
@@ -0,0 +1,149 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for window support. \see dmxwindow.c */
+
+#ifndef DMXWINDOW_H
+#define DMXWINDOW_H
+
+#include "windowstr.h"
+
+/** Window private area. */
+typedef struct _dmxWinPriv {
+ Window window;
+ Bool offscreen;
+ Bool mapped;
+ Bool restacked;
+ unsigned long attribMask;
+ Colormap cmap;
+ Visual *visual;
+#ifdef SHAPE
+ Bool isShaped;
+#endif
+#ifdef RENDER
+ Bool hasPict;
+#endif
+#ifdef GLXEXT
+ void *swapGroup;
+ int barrier;
+ void (*windowDestroyed)(WindowPtr);
+ void (*windowUnmapped)(WindowPtr);
+#endif
+} dmxWinPrivRec, *dmxWinPrivPtr;
+
+
+extern Bool dmxInitWindow(ScreenPtr pScreen);
+
+extern Window dmxCreateRootWindow(WindowPtr pWindow);
+
+extern void dmxGetDefaultWindowAttributes(WindowPtr pWindow,
+ Colormap *cmap,
+ Visual **visual);
+extern void dmxCreateAndRealizeWindow(WindowPtr pWindow, Bool doSync);
+
+extern Bool dmxCreateWindow(WindowPtr pWindow);
+extern Bool dmxDestroyWindow(WindowPtr pWindow);
+extern Bool dmxPositionWindow(WindowPtr pWindow, int x, int y);
+extern Bool dmxChangeWindowAttributes(WindowPtr pWindow, unsigned long mask);
+extern Bool dmxRealizeWindow(WindowPtr pWindow);
+extern Bool dmxUnrealizeWindow(WindowPtr pWindow);
+extern void dmxRestackWindow(WindowPtr pWindow, WindowPtr pOldNextSib);
+extern void dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn,
+ RegionPtr other_exposed);
+extern void dmxPaintWindowBackground(WindowPtr pWindow, RegionPtr pRegion,
+ int what);
+extern void dmxPaintWindowBorder(WindowPtr pWindow, RegionPtr pRegion,
+ int what);
+extern void dmxCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc);
+
+extern void dmxResizeWindow(WindowPtr pWindow, int x, int y,
+ unsigned int w, unsigned int h, WindowPtr pSib);
+extern void dmxReparentWindow(WindowPtr pWindow, WindowPtr pPriorParent);
+
+extern void dmxChangeBorderWidth(WindowPtr pWindow, unsigned int width);
+
+extern void dmxResizeScreenWindow(ScreenPtr pScreen,
+ int x, int y, int w, int h);
+extern void dmxResizeRootWindow(WindowPtr pRoot,
+ int x, int y, int w, int h);
+
+extern Bool dmxBEDestroyWindow(WindowPtr pWindow);
+
+#ifdef SHAPE
+/* Support for shape extension */
+extern void dmxSetShape(WindowPtr pWindow);
+#endif
+
+/** Private index. \see dmxwindow.c \see dmxscrinit.c */
+extern int dmxWinPrivateIndex;
+
+/** Get window private pointer. */
+#define DMX_GET_WINDOW_PRIV(_pWin) \
+ ((dmxWinPrivPtr)(_pWin)->devPrivates[dmxWinPrivateIndex].ptr)
+
+/* All of these macros are only used in dmxwindow.c */
+#define DMX_WINDOW_FUNC_PROLOGUE(_pGC) \
+do { \
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(_pGC); \
+ DMX_UNWRAP(funcs, pGCPriv, (_pGC)); \
+ if (pGCPriv->ops) \
+ DMX_UNWRAP(ops, pGCPriv, (_pGC)); \
+} while (0)
+
+#define DMX_WINDOW_FUNC_EPILOGUE(_pGC) \
+do { \
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(_pGC); \
+ DMX_WRAP(funcs, &dmxGCFuncs, pGCPriv, (_pGC)); \
+ if (pGCPriv->ops) \
+ DMX_WRAP(ops, &dmxGCOps, pGCPriv, (_pGC)); \
+} while (0)
+
+#define DMX_WINDOW_X1(_pWin) \
+ ((_pWin)->drawable.x - wBorderWidth(_pWin))
+#define DMX_WINDOW_Y1(_pWin) \
+ ((_pWin)->drawable.y - wBorderWidth(_pWin))
+#define DMX_WINDOW_X2(_pWin) \
+ ((_pWin)->drawable.x + wBorderWidth(_pWin) + (_pWin)->drawable.width)
+#define DMX_WINDOW_Y2(_pWin) \
+ ((_pWin)->drawable.y + wBorderWidth(_pWin) + (_pWin)->drawable.height)
+
+#define DMX_WINDOW_OFFSCREEN(_pWin) \
+ (DMX_WINDOW_X1(_pWin) >= (_pWin)->drawable.pScreen->width || \
+ DMX_WINDOW_Y1(_pWin) >= (_pWin)->drawable.pScreen->height || \
+ DMX_WINDOW_X2(_pWin) <= 0 || \
+ DMX_WINDOW_Y2(_pWin) <= 0)
+
+#endif /* DMXWINDOW_H */
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/DMXSpec-v1.txt b/nx-X11/programs/Xserver/hw/dmx/doc/DMXSpec-v1.txt
new file mode 100644
index 000000000..423bc32f8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/DMXSpec-v1.txt
@@ -0,0 +1,458 @@
+
+
+ Client-to-Server DMX Extension to the X Protocol
+
+ $Date: 2004/06/30 20:06:54 $, $Revision: 1.1 $
+
+ Rickard E. (Rik) Faith (faith@redhat.com)
+ Kevin E. Martin (kem@redhat.com)
+
+ Copyright 2002,2003 Red Hat Inc., Raleigh, North Carolina.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation on the rights to use, copy, modify,
+ merge, publish, distribute, sublicense, and/or sell copies of the
+ Software, and to permit persons to whom the Software is furnished to
+ do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+
+
+
+1. Overview
+
+ The client-to-server DMX extension to the X protocol (DMX) provides
+ normal client applications with the ability to determine information
+ about the characteristics of the Xdmx server and the back-end X
+ servers that DMX is using.
+
+ The name for this extension is "DMX".
+
+
+
+2. Syntactic conventions
+
+ This document uses the same syntactic conventions requests and data
+ types as [X11R6.4].
+
+
+
+3. Data types
+
+ No new data types are defined by this extension. All data types
+ referenced in this document are defined in [X11R6.4].
+
+
+
+4. Requests
+
+ DMXQueryVersion
+ ==>
+ majorVersion: CARD32
+ minorVersion: CARD32
+ patchVersion: CARD32
+
+ The protocol this extension actually supports is indicated by
+ majorVersion and minorVersion (patchVersion indicates the
+ patchlevel and is for informational purposes only).
+
+ Any incompatible changes to the protocol should be indicated by
+ incrementing majorVersion.
+
+ Small, upward-compatible changes should be indicated by incrementing
+ minorVersion.
+
+ Servers that support the protocol defined in this document will
+ return a majorVersion of 1 and a minorVersion of 1.
+
+
+
+ DMXGetScreenCount
+ ==>
+ screenCount: CARD32
+
+ This request returns the number of back-end screens that the Xdmx
+ server controls. A back-end screen may be managed as a regular X
+ screen in the Xdmx server or may be joined with other back-end
+ screens using Xinerama. (The information returned by this request
+ does not change while Xdmx is running and may be cached on the
+ client side.)
+
+
+
+ DMXGetScreenInformation
+ physicalScreen: CARD32
+ ==>
+ displayName: STRING8
+ width: CARD16
+ height: CARD16
+ xoffset: INT16
+ yoffset: INT16
+ logicalScreen: CARD32
+ xorigin: INT16
+ yorigin: INT16
+
+ Errors: Value
+
+ This request returns information about individual back-end screens.
+ The physicalScreen value is between 0 and screenCount-1, inclusive
+ (values outside this range will result in a Value error). The
+ displayname is the name used to open the display, either from the
+ Xdmx command-line or from the configuration file. The width,
+ height, xoffset, and yoffset values comprise a geometry
+ specification (see X(7x)) for the location of the DMX window on the
+ back-end screen. This request will always return non-negative
+ (i.e., normalized) values for xoffset and yoffset. The
+ logicalScreen value is the value of the screen that that Xdmx server
+ exports to clients. When Xinerama is in use, this value is
+ typically 0 for all values of physicalScreen. If Xinerama is in
+ use, the xorigin and yorigin values specify where the physical
+ screen is positioned in the global Xinerama coordinate system.
+ Otherwise, these values are set to 0. (The information returned by
+ this request does not change while Xdmx is running and may be cached
+ on the client side.)
+
+
+
+ DMXGetWindowInformation
+ window: CARD32
+ ==>
+ screenCount: CARD32
+ screens: LISTofCARD32
+ windows: LISTofCARD32
+ pos: LISTofRECTANGLE
+ vis: LISTofRECTANGLE
+
+ Errors: Window, Alloc
+
+ This request computed the return values incorrectly for version 1.0
+ of this protocol. Version 1.1 of this protocol conforms to this
+ description.
+
+ Given a window ID on the Xdmx server, this request returns data
+ about how the window is represented on the back-end X servers. For
+ each back-end X server that displays a portion of the window, the
+ following information is returned:
+ 1) the number of the physical screen containing that portion
+ (which can be used with the DMXGetScreenInformation request
+ to obtain more information about the screen),
+ 2) the window ID on the back-end X server of the window
+ containing that portion,
+ 3) the position and dimensions of the window on the back-end, in
+ screen coordinates, and
+ 4) the visible area of the window on the back-end, in
+ window-relative coordinates (all zeros for windows that are
+ not visible)
+ Note that DMX allows multiple back-end windows to overlap in their
+ view of the DMX logical window. Further, a logical window does not
+ have to be completely covered by back-end windows -- there may be
+ gaps.
+
+ As an example, consider a 500x500 window that spans the top two
+ 1024x768 back-end displays (A and B) of a 2048x1536 DMX display
+ composed of 4 1024x768 back-end displays arranged in a cube:
+ A B
+ C D
+
+ In this case, the DMXGetWindowInformation call would return the
+ following information for the 500x500 window:
+
+ display A: 500x500 window at 1024-250,0 (relative to back end)
+ with 250x500 visible at 0,0 (relative to window origin)
+
+ display B: 500x500 window at -250,0 (relative to back end)
+ with 250x500 visible at 250,0 (relative to window origin)
+
+ display C: 500x500 window at 1024-250,-768 with 0x0 visible at 0,0
+
+ display D: 500x500 window at -250,-768 with 0x0 visible at 0,0
+
+ Note that if the specified window has not yet been mapped when
+ DMXGetWindowInformation is called, then a subsequent XMapWindow call
+ might be buffered in xlib while requests directly to the back-end X
+ servers are processed. This race condition can be solved by calling
+ DMXSync before talking directly to the back-end X servers.
+
+
+ DMXGetInputCount
+ ==>
+ inputCount: CARD32
+
+ This request was first supported in version 1.1 of this protocol.
+
+ This request returns the number of input devices connected to the
+ Xdmx server. This number is the same as that returned by
+ XListInputDevices, but is available even when the XInput extension
+ is not supported.
+
+
+
+ DMXGetInputInformation
+ deviceId: CARD32
+ ==>
+ inputType: CARD32
+ physicalScreen: CARD32
+ physicalId: CARD32
+ isCore: BOOL
+ sendsCore: BOOL
+ name: STRING8
+
+ Errors: Value
+
+ This request was first supported in version 1.1 of this protocol.
+
+ This request returns information about the specified input device
+ that cannot be obtained from the XListInputDeivices call. The
+ deviceId is the same as that used by the XListInputDevices call, and
+ must be in the range 0 to inputCount-1, inclusive (values outside
+ this range will result in a Value error).
+
+ The value of inputType will always be value, and will be one of the
+ following values:
+ 0 for local (and dummy) devices,
+ 1 for console devices, and
+ 2 for back-end devices.
+
+ For local devices, all other fields returned, except isCore and
+ sendsCore, are invalid.
+
+ For console devices, the physicalScreen and physicalID will be
+ invalid, and the name will return the name of the X server on which
+ the console window is displayed.
+
+ For back-end devices, the physicalScreen will identify the back-end
+ display and can be used as an argument to DMXGetScreenInformation to
+ obtain more information; the physicalId will be the XInput device id
+ on the back-end X server; and the name will be invalid (since it
+ does not provide any additional information that cannot be obtained
+ with DMXGetScreenInformation).
+
+ If isCore is True, then this device is active as a true core input
+ device and will send core events. If sendsCore is True, then this
+ device queried an XInput extension device, but sends core events
+ instead of extension events. Note that this behavior is different
+ from that of XFree86, where XInput extension devices may send both
+ extension events and core events.
+
+
+
+ DMXForceWindowCreation
+ window: CARD32
+ ==>
+
+ Errors: Window
+
+ This request was first supported in version 1.2 of this protocol.
+
+ When using the lazy window creation optimization, windows are not
+ created on the back-end X servers until they are required. This
+ request forces the immediate creation of the window requested.
+
+
+
+ DMXReconfigureScreen
+ screen: CARD32
+ x: INT16
+ y: INT16
+ ==>
+ status: CARD32
+
+ Errors: Value
+
+ This request was first supported in version 1.3 of this protocol.
+
+ This request reconfigures the screen position to coordinates (x,y)
+ when using the Xinerama extension. Otherwise, it is a NOP. Illegal
+ values for screen will result in a BadValue error. Other non-fatal
+ errors will be returned in status.
+
+
+
+ DMXSync
+ ==>
+
+ This request was first supported in version 1.5 of this protocol.
+
+ This request flushes all pending protocol requests between the Xdmx
+ server and each back-end X server. It is used by a client that
+ talks directly to back-end X servers
+
+ To ensure proper synchronization semantics, this request has a
+ reply, but the reply does not carry any information.
+
+
+
+5. Events
+
+ No new events are defined by this extension.
+
+
+
+6. Errors
+
+ No new events are defined by this extension.
+
+
+
+7. Encoding
+
+ DMXQueryVersion
+ 1 CARD8 opcode (X assigned)
+ 1 0 DMX opcode (X_DMXQueryVersion)
+ 2 1 request length
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 4 CARD32 majorVersion
+ 4 CARD32 minorVersion
+ 4 CARD32 patchVersion
+ 12 unused
+
+ DMXGetScreenCount
+ 1 CARD8 opcode (X assigned)
+ 1 1 DMX opcode (X_DMXGetScreenCount)
+ 2 1 request length
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 4 CARD32 screenCount
+ 20 unused
+
+ DMXGetScreenInformation
+ 1 CARD8 opcode (X assigned)
+ 1 2 DMX opcode (X_DMXGetScreenInformation)
+ 2 2 request length
+ 4 CARD32 physicalScreen
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 n/4+p reply length
+ 4 n displayNameLength
+ 2 CARD16 width
+ 2 CARD16 height
+ 2 INT16 xoffset
+ 2 INT16 yoffset
+ 4 CARD32 logicalScreen
+ 2 INT16 xorigin
+ 2 INT16 yorigin
+ 4 unused
+ n displayName
+ p pad(n)
+
+ DMXGetWindowInformation
+ 1 CARD8 opcode (X assigned)
+ 1 3 DMX opcode (X_DMXGetWindowInformation)
+ 2 2 request length
+ 4 CARD32 window
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 n*6 reply length
+ 4 n screenCount
+ 20 unused
+ n*4 LISTofCARD32 screens
+ n*4 LISTofCARD32 windows
+ n*8 LISTofRECTANGLE pos
+ n*8 LISTofRECTANGLE vis
+
+ DMXGetInputCount
+ 1 CARD8 opcode (X assigned)
+ 1 DMX opcode (X_DMXGetInputCount)
+ 2 1 request length
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 4 CARD32 inputCount
+ 20 unused
+
+ DMXGetInputInformation
+ 1 CARD8 opcode (X assigned)
+ 1 4 DMX opcode (X_DMXGetInputInformation)
+ 2 2 request length
+ 4 CARD32 deviceId
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 n/4+p reply length
+ 4 CARD32 inputType
+ 4 CARD32 physicalScreen
+ 4 CARD32 physicalId
+ 4 n nameLength
+ 1 BOOL isCore
+ 1 BOOL sendsCore
+ 6 unused
+ n name
+ p pad(n)
+
+ DMXForceWindowCreation
+ 1 CARD8 opcode (X assigned)
+ 1 2 DMX opcode (X_DMXForceWindowCreation)
+ 2 2 request length
+ 4 CARD32 window
+ ==>
+
+ DMXReconfigureScreen
+ 1 CARD8 opcode (X assigned)
+ 1 2 DMX opcode (X_DMXReconfigureScreen)
+ 2 2 request length
+ 4 CARD32 screen
+ 2 INT16 x
+ 2 INT16 y
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 4 CARD32 status
+ 20 unused
+
+ DMXSync
+ 1 CARD8 opcode (X assigned)
+ 1 0 DMX opcode (X_DMXSync)
+ 2 1 request length
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 24 unused
+
+
+8. Changes to existing requests/replies/events
+
+ No changes to existing requests, replies, or events are necessitated
+ by this extension.
+
+
+
+9. Acknowledgments
+
+
+
+10. References
+
+ [X11R6.4] Robert W. Sheifler. X Window System Protocol, X Consortium
+ Standard, X Version 11, Release 6.4. Available from
+ xc/doc/specs/XProtocol and xc/doc/hardcopy/XProtocol.
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/DMXSpec.txt b/nx-X11/programs/Xserver/hw/dmx/doc/DMXSpec.txt
new file mode 100644
index 000000000..9283ce1ce
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/DMXSpec.txt
@@ -0,0 +1,875 @@
+
+
+ Client-to-Server DMX Extension to the X Protocol
+
+ $Date: 2004/06/30 20:06:54 $, $Revision: 1.1 $
+
+ Rickard E. (Rik) Faith (faith@redhat.com)
+ Kevin E. Martin (kem@redhat.com)
+
+ Copyright 2002-2004 Red Hat Inc., Raleigh, North Carolina.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation on the rights to use, copy, modify,
+ merge, publish, distribute, sublicense, and/or sell copies of the
+ Software, and to permit persons to whom the Software is furnished to
+ do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+
+
+
+1. Overview
+
+ The client-to-server DMX extension to the X protocol (DMX) provides
+ normal client applications with the ability to determine information
+ about the characteristics of the Xdmx server and the back-end X
+ servers that DMX is using.
+
+ The name for this extension is "DMX".
+
+
+
+2. Syntactic conventions
+
+ This document uses the same syntactic conventions requests and data
+ types as [X11R6.4].
+
+
+
+3. Data types
+
+ No new data types are defined by this extension. All data types
+ referenced in this document are defined in [X11R6.4].
+
+
+
+4. Requests
+
+ DMXQueryVersion
+ ==>
+ majorVersion: CARD32
+ minorVersion: CARD32
+ patchVersion: CARD32
+
+ Errors: None
+
+ The protocol this extension actually supports is indicated by
+ majorVersion and minorVersion (patchVersion indicates the
+ patchlevel and is for informational purposes only).
+
+ Any incompatible changes to the protocol should be indicated by
+ incrementing majorVersion.
+
+ Small, upward-compatible changes should be indicated by incrementing
+ minorVersion.
+
+ Servers that support the protocol defined in this document will
+ return a majorVersion of 2 and a minorVersion of 2.
+
+ (Version 1.5 was the last version in the 1.x series; version 2.0 was
+ a testing version that was poorly defined.)
+
+
+
+ DMXSync
+ ==>
+ status: CARD32
+
+ Errors: None
+
+ This request was first supported in version 1.5 of this protocol.
+ The status field in the reply was introduced in version 2.0 of this
+ protocol. Since the status field is ignored, no changes to the
+ underlying protocol were required.
+
+ This request flushes all pending protocol requests between the Xdmx
+ server and each back-end X server. It is used by clients that
+ talk directly to back-end X servers to ensure that all pending Xdmx
+ requests have reached all back-end servers and have been processed
+ by those servers.
+
+ The value of status is always 0.
+
+
+
+ DMXForceWindowCreation
+ window: CARD32
+ ==>
+ status: CARD32
+
+ Errors: Window
+
+ This request was first supported in version 1.2 of this protocol.
+ This request was changed to have a reply in version 2.0 of this
+ protocol. The old version of this request was deprecated and will
+ return BadImplementation.
+
+ When using the lazy window creation optimization, windows are not
+ created on the back-end X servers until they are required. This
+ request forces the immediate creation of the window requested.
+
+ The value of status is always 0.
+
+
+
+
+ DMXGetScreenCount
+ ==>
+ screenCount: CARD32
+
+ Errors: None
+
+ This request returns the number of screens that the Xdmx server
+ controls. Since a DMX screen usually fills all of the available
+ area on a back-end server, there is usually a one-to-one
+ correspondence between DMX screens and backend servers. However, it
+ is also possible for a DMX screen to cover only part of the
+ available area on a back-end server, and for more than one DMX
+ screen to occupy different parts of the visible area on the same
+ back-end server.
+
+ A DMX screen may be managed as a regular X screen in the Xdmx server
+ or may be joined with other DMX screens using Xinerama.
+
+
+
+ DMXGetScreenAttributes
+ physicalScreen: CARD32
+ ==>
+ displayName: STRING8
+ logicalScreen: CARD32
+ screenWindowWidth: CARD16
+ screenWindowHeight: CARD16
+ screenWindowXoffset: INT16
+ screenWindowYoffset: INT16
+ rootWindowWidth: CARD16
+ rootWindowHeight: CARD16
+ rootWindowXoffset: INT16
+ rootWindowYoffset: INT16
+ rootWindowXorigin: INT16
+ rootWindowYorigin: INT16
+
+ Errors: Value
+
+ This request is new in version 2.0 of this protocol. The old
+ DMXGetScreenInformation request is deprecated and will now return
+ BadImplementation.
+
+ This request returns attributes about a single DMX screen.
+
+ The physicalScreen value is between 0 and screenCount-1, inclusive
+ (values outside this range will result in a Value error).
+
+ The displayname is the name used to open the display, either from
+ the Xdmx command-line or from the configuration file.
+
+ The logicalScreen value is the value of the screen that that Xdmx
+ server exports to clients. When Xinerama is in use, this value is
+ typically 0 for all values of physicalScreen. If Xinerama is in
+ use, the rootWindowXOrigin and rootWindowYOrigin values specify
+ where the physical screen is positioned in the global Xinerama
+ coordinate system. Otherwise, these values are set to 0.
+
+ The screenWindow values comprise a geometry specification (see
+ X(7x)) for the location of the DMX screen on the back-end screen.
+ The coordinant system of the back-end display is used.
+
+ The first four rootWindow values comprise a geometry specification
+ (see X(7x)) for the location of the root window on the screen
+ window. The coordinant system of the screen window is used. In
+ most cases, the root window will have the same geometry as the DMX
+ screen window, and will occupy the same area of the back-end
+ display. (This would not be the case, for example, if automatic
+ projector alignment is used.)
+
+
+
+ DMXChangeScreensAttributes
+ screenCount: CARD32
+ maskCount: CARD32
+ screens: LISTofCARD32
+ valueMasks: LISTofCARD32
+ valueList: LISTofVALUES
+ ==>
+ status: CARD32
+ errorScreen: CARD32
+
+ Errors: Length, Alloc
+
+ This request was first supported in version 2.0 of this protocol.
+ (A singular version of this request with the ability to change some
+ RootWindow attributes was supported in version 1.3 of this protocol,
+ has been deprecated, and will return BadImplementation.)
+
+ This request changes the geometries and positions of the DMX screen
+ and DMX root windows on the back-end X servers.
+
+ The valueMask and valueList specify which attributes are to be
+ changed. The possible values are:
+
+ Attribute Type
+
+ ScreenWindowWidth CARD16
+ ScreenWindowHeight CARD16
+ ScreenWindowXoffset INT16
+ ScreenWindowYoffset INT16
+ RootWindowWidth CARD16
+ RootWindowHeight CARD16
+ RootWindowXoffset INT16
+ RootWindowYoffset INT16
+ RootWindowXorigin INT16
+ RootWindowYorigin INT16
+
+ The attribute values have the same meaning as do the corresponding
+ values for DMXGetScreenAttributes.
+
+ Non-fatal errors will be returned in status (0 otherwise):
+ DmxBadXinerama: Xinerama is not active
+ DmxBadValue: The resulting position is not allowed
+ (e.g., one corner is outside the bounding box)
+ On error, errorScreen will contain the number of the screen that
+ caused the first error.
+
+
+
+ DMXAddScreen
+ displayName: STRING8
+ physicalScreen: CARD32
+ valueMask: CARD32
+ valueList: LISTofVALUES
+ ==>
+ status: CARD32
+ physicalScreen: CARD32
+
+ Errors: Length, Alloc, Value
+
+ This request was first supported in version 2.2 of this protocol.
+
+ This request re-attaches the back-end physicalScreen to the Xdmx
+ server. Only back-end screens that have been previously detached
+ with DMXRemoveScreen may be added. The name of the back-end display
+ is given in displayName, and this will replace the name of the
+ back-end screen that was detached. Both the displayName and
+ physicalScreen must be correct for this request to work.
+
+ The valueMask and valueList specify the attributes to be used. The
+ possible values are:
+
+ Attribute Type
+
+ ScreenWindowWidth CARD16
+ ScreenWindowHeight CARD16
+ ScreenWindowXoffset INT16
+ ScreenWindowYoffset INT16
+ RootWindowWidth CARD16
+ RootWindowHeight CARD16
+ RootWindowXoffset INT16
+ RootWindowYoffset INT16
+ RootWindowXorigin INT16
+ RootWindowYorigin INT16
+
+ The attribute values have the same meaning as do the corresponding
+ values for DMXGetScreenAttributes.
+
+ On success, status will be 0 and physicalScreen will contain the new
+ screen number. On failure, status will be non-zero. The status
+ will be 1 if any of the following occured:
+ * the -addremovescreens command-line option was not specified on
+ the Xdmx command line
+ * the value of physicalScreen is out of range
+ * physicalScreen has not been detached (with DMXRemoveScreen)
+ * displayName cannot be opened
+ * the visuals of displayname do not match the visuals that Xdmx
+ is using
+ * the screen data for displayName does not match the data for the
+ previously removed display
+ The status will be DmxBadValue if the attribute values are out of
+ range.
+
+
+
+ DMXRemoveScreen
+ physicalScreen: CARD32
+ ==>
+ status: CARD32
+
+ Errors: None
+
+ This request was first supported in version 2.2 of this protocol.
+
+ This request detaches the physicalScreen screen.
+
+ On success, status will be 0. On failure, the status will 1 if any
+ of the following occur:
+ * the -addremovescreens command-line option was not specified on
+ the Xdmx command line
+ * the value of physicalScreen is out of range
+ * the back-end screen has already been detached.
+
+
+
+ DMXGetWindowAttributes
+ window: CARD32
+ ==>
+ screenCount: CARD32
+ screens: LISTofCARD32
+ windows: LISTofCARD32
+ pos: LISTofRECTANGLE
+ vis: LISTofRECTANGLE
+
+ Errors: Window, Alloc
+
+ This request computes the return values incorrectly for version 1.0
+ of this protocol. Version 1.1 of this protocol conforms to this
+ description. In version 2.0, the name of this request was changed
+ from DMXGetWindowInformation. However, since the request itself did
+ not change, no changes to the underlying protocol were made.
+
+ Given a window ID on the Xdmx server, this request returns data
+ about how the window is represented on the back-end X servers. For
+ each back-end X server that displays a portion of the window, the
+ following information is returned:
+ 1) the number of the physical screen containing that portion
+ (which can be used with the DMXGetScreenAttributes request
+ to obtain more information about the screen),
+ 2) the window ID on the back-end X server of the window
+ containing that portion,
+ 3) the position and dimensions of the window on the back-end, in
+ screen coordinates, and
+ 4) the visible area of the window on the back-end, in
+ window-relative coordinates (all zeros for windows that are
+ not visible).
+ Note that DMX allows multiple back-end windows to overlap in their
+ view of the DMX logical window. Further, a logical window does not
+ have to be completely covered by back-end windows -- there may be
+ gaps.
+
+ As an example, consider a 500x500 window that spans the top two
+ 1024x768 back-end displays (A and B) of a 2048x1536 DMX display
+ composed of 4 1024x768 back-end displays arranged in a cube:
+ A B
+ C D
+
+ In this case, the DMXGetWindowAttributes call would return the
+ following information for the 500x500 window:
+
+ display A: 500x500 window at 1024-250,0 (relative to back end)
+ with 250x500 visible at 0,0 (relative to window origin)
+
+ display B: 500x500 window at -250,0 (relative to back end)
+ with 250x500 visible at 250,0 (relative to window origin)
+
+ display C: 500x500 window at 1024-250,-768 with 0x0 visible at 0,0
+
+ display D: 500x500 window at -250,-768 with 0x0 visible at 0,0
+
+ Note that if the specified window has not yet been mapped when
+ DMXGetWindowAttributes is called, then a subsequent XMapWindow call
+ might be buffered in xlib while requests directly to the back-end X
+ servers are processed. This race condition can be solved by calling
+ DMXSync before talking directly to the back-end X servers.
+
+
+
+ DMXGetDesktopAttributes
+ ==>
+ width: INT16
+ height: INT16
+ shiftX: INT16
+ shiftY: INT16
+
+ Errors: None
+
+ This request was first supported in version 2.0 of this protocol.
+
+ This request returns the size of the bounding box of the whole
+ screen in width and height. The shiftX and shiftY values will
+ always be 0. The global bounding box is computed whether or not
+ Xinerama is active, and may be larger than the Xinerama screen size
+ because of information in the configuration file.
+
+
+
+ DMXChangeDesktopAttributes
+ valueMask: BITMASK
+ valueList: LISTofVALUE
+ ==>
+ status: CARD32
+
+ Errors: Length, Value
+
+ This request was first supported in version 2.0 of this protocol.
+
+ This request resizes the bounding box of the whole screen when using
+ the Xinerama extension. Otherwise, it has no effect on the screen
+ layout. The valueMask and valueList specify which attributes are to
+ be changed. The possible values are:
+
+ Attriubute Type
+
+ Width INT16
+ Height INT16
+ ShiftX INT16
+ ShiftY INT16
+
+ Width and Height specify the new width and height for the bounding
+ box. ShiftX and ShiftY specify where the Xinerama origin will be
+ placed with respect to the origin of the new bounding box. This
+ allows the left and upper edges of the bounding box to be changed
+ without changing the visual position of the windows on the desktop.
+ If Width or Height is not specified, the current values will be
+ used. If ShiftX or ShiftY is not specified, 0 will be used.
+
+ All coordinants are in the global DMX coordinant system. If
+ Xinerama is not active, this request is not useful.
+
+ Non-fatal errors will be returned in status (0 otherwise):
+ DmxBadXinerama: Xinerama is not active
+ DmxBadValue: The size of the bounding box is too large
+
+
+
+ DMXGetInputCount
+ ==>
+ inputCount: CARD32
+
+ This request was first supported in version 1.1 of this protocol.
+
+ This request returns the number of input devices connected to the
+ Xdmx server. This number is the same as that returned by
+ XListInputDevices, but is available even when the XInput extension
+ is not supported.
+
+
+
+ DMXGetInputAttributes
+ deviceId: CARD32
+ ==>
+ inputType: CARD32
+ physicalScreen: CARD32
+ physicalId: CARD32
+ isCore: BOOL
+ sendsCore: BOOL
+ detached: BOOL
+ name: STRING8
+
+ Errors: Value
+
+ This request was first supported in version 1.1 of this protocol.
+ In version 2.0, the name of this request was changed from
+ DMXGetInputInformation. However, since the request itself did not
+ change, no changes to the underlying protocol were made. In version
+ 2.2, the name of detached was changed from reservation. There was
+ no change in underlying protocol.
+
+ This request returns information about the specified input device
+ that cannot be obtained from the XListInputDeivices call. The
+ deviceId is the same as that used by the XListInputDevices call, and
+ must be in the range 0 to inputCount-1, inclusive (values outside
+ this range will result in a Value error).
+
+ The value of inputType will always be valid, and will be one of the
+ following values:
+ 0 for local (and dummy) devices,
+ 1 for console devices, and
+ 2 for back-end devices.
+
+ For local devices, all other fields returned, except isCore and
+ sendsCore, are invalid.
+
+ For console devices, the physicalScreen and physicalID will be
+ invalid, and the name will return the name of the X server on which
+ the console window is displayed.
+
+ For back-end devices, the physicalScreen will identify the back-end
+ display and can be used as an argument to DMXGetScreenAttributes to
+ obtain more information; the physicalId will be the XInput device id
+ on the back-end X server; and the name will be invalid (since it
+ does not provide any additional information that cannot be obtained
+ with DMXGetScreenAttributes).
+
+ If isCore is True, then this device is active as a true core input
+ device and will send core events. If sendsCore is True, then this
+ device is an XInput extension device, but sends core events instead
+ of extension events. Note that this behavior is different from that
+ of XFree86 or Xorg, where XInput extension devices may send both
+ extension events and core events.
+
+ If detached is True, then this device has been detached and is no
+ longer producing input events. The device may be reattached using
+ DMXAddInput.
+
+
+
+ DMXAddInput
+ displayName: STRING8
+ valueMask: CARD32
+ valueList: LISTofVALUES
+ ==>
+ status: CARD32
+ physicalId: CARD32
+
+ Errors: Value, Access
+
+ This request was first supported in version 2.2 of this protocol.
+
+ The valueMask and valueList specify the attributes to be used. The
+ possible values are:
+
+ Attribute Type
+
+ InputType CARD32
+ InputPhysicalScreen CARD32
+ InputSendsCore BOOL
+
+ This request attaches an input device to the Xdmx server. The value
+ of inputType will be one:
+ 1 for console devices, and
+ 2 for back-end devices.
+ Other values of InputType will return a BadValue error. Local
+ devices (inputType=0 in DMXGetInputAttributes) cannot be attached or
+ removed. For console devices, displayName will store the name of
+ the display to be used.
+
+ For back-end devices, InputPhysicalScreen will specify the screen
+ number. BadValue will be returned if the screen number is out of
+ range. BadAccess will be returned if the input has already been
+ attached or if the backend screen is currently detached.
+
+ If InputSendsCore is True, the new device will be added as a true
+ core device.
+
+ If a device was removed with DMXRemoveInput an attempt will be made
+ to reconnect the previous devices (InputSendsCore is ignored in this
+ case).
+
+
+
+ DMXRemoveInput
+ physicalId: CARD32
+ ==>
+ status: CARD32
+
+ Errors: Value, Access
+
+ This request was first supported in version 2.2 of this protocol.
+
+ This request detaches the input device with physicalId, and all
+ associated inputs (e.g., if the physicalId is a backend mouse, and a
+ keyboard is also attached to the backend, then both devices will be
+ detached). If the physicalId is outside the valid range (0 to one
+ less than the value returned by DMXInputCount), BadValue is
+ returned. If the physicalId has already been detached, BadAccess is
+ returned. The status is always 0.
+
+
+
+5. Events
+
+ No new events are defined by this extension.
+
+
+
+6. Errors
+
+ No new events are defined by this extension.
+
+
+
+7. Encoding
+
+ Deprecated DMX opcodes:
+ DMXGetScreenInformation 2
+ DMXForceWindowCreation 6
+ DMXReconfigureScreen 7
+
+ Valid DMX opcodes:
+ DMXQueryVersion 0
+ DMXSync 8
+ DMXForceWindowCreation 9
+
+ DMXGetScreenCount 1
+ DMXGetScreenAttributes 10
+ DMXChangeScreensAttributes 11
+ DMXAddScreen 12
+ DMXRemoveScreen 13
+
+ DMXGetWindowAttributes 3
+
+ DMXGetDesktopAttributes 14
+ DMXChangeDesktopAttributes 15
+
+ DMXGetInputCount 4
+ DMXGetInputAttributes 5
+ DMXAddInput 16
+ DMXRemoveInput 17
+
+ DMXQueryVersion
+ 1 CARD8 opcode (X assigned)
+ 1 0 DMX opcode (X_DMXQueryVersion)
+ 2 1 request length
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 4 CARD32 majorVersion
+ 4 CARD32 minorVersion
+ 4 CARD32 patchVersion
+ 12 unused
+
+ DMXSync
+ 1 CARD8 opcode (X assigned)
+ 1 8 DMX opcode (X_DMXSync)
+ 2 1 request length
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 4 CARD32 status
+ 20 unused
+
+ DMXForceWindowCreation
+ 1 CARD8 opcode (X assigned)
+ 1 9 DMX opcode (X_DMXForceWindowCreation)
+ 2 2 request length
+ 4 CARD32 window
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 4 CARD32 status
+ 20 unused
+
+
+ DMXGetScreenCount
+ 1 CARD8 opcode (X assigned)
+ 1 1 DMX opcode (X_DMXGetScreenCount)
+ 2 1 request length
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 4 CARD32 screenCount
+ 20 unused
+
+ DMXGetScreenAttributes
+ 1 CARD8 opcode (X assigned)
+ 1 10 DMX opcode (X_DMXGetScreenAttributes)
+ 2 2 request length
+ 4 CARD32 physicalScreen
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 1+(n+p)/4 reply length
+ 4 n displayNameLength
+ 4 CARD32 logicalScreen
+ 2 CARD16 screenWindowWidth
+ 2 CARD16 screenWindowHeight
+ 2 INT16 screenWindowXoffset
+ 2 INT16 screenWindowYoffset
+ 2 CARD16 rootWindowWidth
+ 2 CARD16 rootWindowHeight
+ 2 INT16 rootWindowXoffset
+ 2 INT16 rootWindowYoffset
+ 2 INT16 rootWindowXorigin
+ 2 INT16 rootWindowYorigin
+ n displayName
+ p pad(n)
+
+ DMXChangeScreensAttributes
+ 1 CARD8 opcode (X assigned)
+ 1 11 DMX opcode (X_DMXChangeScreenAttributes)
+ 2 3+s+m+n request length
+ 4 s screenCount
+ 4 m maskCount
+ 4s LISTofCARD32 screens
+ 4m LISTofCARD32 valueMasks
+ 4n LISTofVALUES valueList
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 4 CARD32 status
+ 4 CARD32 errorScreen
+ 16 unused
+
+
+ DMXAddScreen
+ 1 CARD8 opcode (X assigned)
+ 1 12 DMX opcode (X_DMXAddScreen)
+ 2 3+m+(n+p)/4 request length
+ 4 n displayNameLength
+ 4 CARD32 physicalScreen
+ 4 CARD32 valueMask
+ 4m LISTofVALUES valueList
+ n displayName
+ p pad(n)
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 4 CARD32 status
+ 4 CARD32 physicalScreen
+ 16 unused
+
+ DMXRemoveScreen
+ 1 CARD8 opcode (X assigned)
+ 1 13 DMX opcode (X_DMXRemoveScreen)
+ 2 2 request length
+ 4 CARD32 physicalScreen
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 4 CARD32 status
+ 20 unused
+
+ DMXGetWindowAttributes
+ 1 CARD8 opcode (X assigned)
+ 1 3 DMX opcode (X_DMXGetWindowAttributes)
+ 2 2 request length
+ 4 CARD32 window
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 n*6 reply length
+ 4 n screenCount
+ 20 unused
+ n*4 LISTofCARD32 screens
+ n*4 LISTofCARD32 windows
+ n*8 LISTofRECTANGLE pos
+ n*8 LISTofRECTANGLE vis
+
+ DMXGetDesktopAttributes
+ 1 CARD8 opcode (X assigned)
+ 1 14 DMX opcode (X_DMXGetDesktopAttributes)
+ 2 1 request length
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 2 INT16 width
+ 2 INT16 height
+ 2 INT16 shiftX
+ 2 INT16 shiftY
+ 16 unused
+
+ DMXChangeDesktopAttributes
+ 1 CARD8 opcode (X assigned)
+ 1 15 DMX opcode (X_DMXChangeDesktopAttributes)
+ 2 2+n request length
+ 4 BITMASK valueMask
+ 4n LISTofVALUES valueList
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 4 CARD32 status
+ 20 unused
+
+ DMXGetInputCount
+ 1 CARD8 opcode (X assigned)
+ 1 4 DMX opcode (X_DMXGetInputCount)
+ 2 1 request length
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 4 CARD32 inputCount
+ 20 unused
+
+ DMXGetInputAttributes
+ 1 CARD8 opcode (X assigned)
+ 1 5 DMX opcode (X_DMXGetInputAttributes)
+ 2 2 request length
+ 4 CARD32 deviceId
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 (n+p)/4 reply length
+ 4 CARD32 inputType
+ 4 CARD32 physicalScreen
+ 4 CARD32 physicalId
+ 4 n nameLength
+ 1 BOOL isCore
+ 1 BOOL sendsCore
+ 1 BOOL detached
+ 5 unused
+ n name
+ p pad(n)
+
+ DMXAddInput
+ 1 CARD8 opcode (X assigned)
+ 1 16 DMX opcode (X_DMXAddInput)
+ 2 3+m+(n+p)/4 request length
+ 4 n displayNameLength
+ 4 CARD32 valueMask
+ 4m LISTofVALUES valueList
+ n displayName
+ p pad(n)
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 4 CARD32 status
+ 4 CARD32 physicalId
+ 16 unused
+
+ DMXRemoveInput
+ 1 CARD8 opcode (X assigned)
+ 1 17 DMX opcode (X_DMXRemoveInput)
+ 2 3 request length
+ 4 CARD32 physicalId
+ ==>
+ 1 1 Reply
+ 1 unused
+ 2 CARD16 sequence number
+ 4 0 reply length
+ 4 CARD32 status
+ 20 unused
+
+
+8. Changes to existing requests/replies/events
+
+ No changes to existing requests, replies, or events are necessitated
+ by this extension.
+
+
+
+9. Acknowledgments
+
+
+
+10. References
+
+ [X11R6.4] Robert W. Sheifler. X Window System Protocol, X Consortium
+ Standard, X Version 11, Release 6.4. Available from
+ xc/doc/specs/XProtocol and xc/doc/hardcopy/XProtocol.
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/Imakefile b/nx-X11/programs/Xserver/hw/dmx/doc/Imakefile
new file mode 100644
index 000000000..bf70a4a23
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/Imakefile
@@ -0,0 +1,10 @@
+XCOMM $XFree86$
+
+#include <Server.tmpl>
+#include <lnxdoc.rules>
+
+all::
+
+#if BuildSgmlDocs
+LinuxDocTarget(dmx)
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/Makefile.linux b/nx-X11/programs/Xserver/hw/dmx/doc/Makefile.linux
new file mode 100644
index 000000000..e43901c66
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/Makefile.linux
@@ -0,0 +1,42 @@
+# This is a temporary convenience Makefile that will be removed before
+# merging in to XFree86 tree.
+
+# For RedHat 7.2:
+SGML2TXT = GROFF_NO_SGR= sgml2txt
+SGML2LATEX = sgml2latex
+SGML2HTML = sgml2html
+
+# For RedHat 8.0:
+#SGML2TXT = GROFF_NO_SGR= linuxdoc -B txt
+#SGML2LATEX = linuxdoc -B latex
+#SGML2HTML = linuxdoc -B html
+
+FILES = dmx.sgml scaled.sgml
+
+TXT_FILES = $(FILES:.sgml=.txt)
+DVI_FILES = $(FILES:.sgml=.dvi)
+PS_FILES = $(FILES:.sgml=.ps)
+HTML_FILES = $(FILES:.sgml=.html)
+
+all: txt ps html
+ doxygen doxygen.conf
+
+txt: $(TXT_FILES)
+dvi: $(DVI_FILES)
+ps: $(PS_FILES)
+html: $(HTML_FILES)
+
+%.txt: %.sgml
+ $(SGML2TXT) $*
+
+%.dvi: %.sgml
+ $(SGML2LATEX) --papersize=letter $*
+
+%.ps: %.sgml
+ $(SGML2LATEX) --papersize=letter --output=ps $*
+
+%.html: %.sgml
+ $(SGML2HTML) --split=0 $*
+
+clean:
+ rm -f $(TXT_FILES) $(DVI_FILES) $(PS_FILES) # $(HTML_FILES)
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/dmx.sgml b/nx-X11/programs/Xserver/hw/dmx/doc/dmx.sgml
new file mode 100644
index 000000000..ef66d1195
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/dmx.sgml
@@ -0,0 +1,2778 @@
+<!DOCTYPE linuxdoc PUBLIC "-//XFree86//DTD linuxdoc//EN">
+ <article>
+
+ <!-- Title information -->
+ <title>Distributed Multihead X design
+ <author>Kevin E. Martin, David H. Dawes, and Rickard E. Faith
+ <date>29 June 2004 (created 25 July 2001)
+ <abstract>
+ This document covers the motivation, background, design, and
+ implementation of the distributed multihead X (DMX) system. It
+ is a living document and describes the current design and
+ implementation details of the DMX system. As the project
+ progresses, this document will be continually updated to reflect
+ the changes in the code and/or design. <it>Copyright 2001 by VA
+ Linux Systems, Inc., Fremont, California. Copyright 2001-2004
+ by Red Hat, Inc., Raleigh, North Carolina</it>
+ </abstract>
+
+ <!-- Table of contents -->
+ <toc>
+
+<!-- Begin the document -->
+<sect>Introduction
+
+<sect1>The Distributed Multihead X Server
+
+<p>Current Open Source multihead solutions are limited to a single
+physical machine. A single X server controls multiple display devices,
+which can be arranged as independent heads or unified into a single
+desktop (with Xinerama). These solutions are limited to the number of
+physical devices that can co-exist in a single machine (e.g., due to the
+number of AGP/PCI slots available for graphics cards). Thus, large
+tiled displays are not currently possible. The work described in this
+paper will eliminate the requirement that the display devices reside in
+the same physical machine. This will be accomplished by developing a
+front-end proxy X server that will control multiple back-end X servers
+that make up the large display.
+
+<p>The overall structure of the distributed multihead X (DMX) project is
+as follows: A single front-end X server will act as a proxy to a set of
+back-end X servers, which handle all of the visible rendering. X
+clients will connect to the front-end server just as they normally would
+to a regular X server. The front-end server will present an abstracted
+view to the client of a single large display. This will ensure that all
+standard X clients will continue to operate without modification
+(limited, as always, by the visuals and extensions provided by the X
+server). Clients that are DMX-aware will be able to use an extension to
+obtain information about the back-end servers (e.g., for placement of
+pop-up windows, window alignments by the window manager, etc.).
+
+<p>The architecture of the DMX server is divided into two main sections:
+input (e.g., mouse and keyboard events) and output (e.g., rendering and
+windowing requests). Each of these are describe briefly below, and the
+rest of this design document will describe them in greater detail.
+
+<p>The DMX server can receive input from three general types of input
+devices: "local" devices that are physically attached to the machine on
+which DMX is running, "backend" devices that are physically attached to
+one or more of the back-end X servers (and that generate events via the
+X protocol stream from the backend), and "console" devices that can be
+abstracted from any non-back-end X server. Backend and console devices
+are treated differently because the pointer device on the back-end X
+server also controls the location of the hardware X cursor. Full
+support for XInput extension devices is provided.
+
+<p>Rendering requests will be accepted by the front-end server; however,
+rendering to visible windows will be broken down as needed and sent to
+the appropriate back-end server(s) via X11 library calls for actual
+rendering. The basic framework will follow a Xnest-style approach. GC
+state will be managed in the front-end server and sent to the
+appropriate back-end server(s) as required. Pixmap rendering will (at
+least initially) be handled by the front-end X server. Windowing
+requests (e.g., ordering, mapping, moving, etc.) will handled in the
+front-end server. If the request requires a visible change, the
+windowing operation will be translated into requests for the appropriate
+back-end server(s). Window state will be mirrored in the back-end
+server(s) as needed.
+
+<sect1>Layout of Paper
+
+<p>The next section describes the general development plan that was
+actually used for implementation. The final section discusses
+outstanding issues at the conclusion of development. The first appendix
+provides low-level technical detail that may be of interest to those
+intimately familiar with the X server architecture. The final appendix
+describes the four phases of development that were performed during the
+first two years of development.
+
+<p>The final year of work was divided into 9 tasks that are not
+described in specific sections of this document. The major tasks during
+that time were the enhancement of the reconfiguration ability added in
+Phase IV, addition of support for a dynamic number of back-end displays
+(instead of a hard-coded limit), and the support for back-end display
+and input removal and addition. This work is mentioned in this paper,
+but is not covered in detail.
+
+<!-- ============================================================ -->
+<sect>Development plan
+
+<p>This section describes the development plan from approximately June
+2001 through July 2003.
+
+<sect1>Bootstrap code
+
+<p>To allow for rapid development of the DMX server by multiple
+developers during the first development stage, the problem will be
+broken down into three tasks: the overall DMX framework, back-end
+rendering services and input device handling services. However, before
+the work begins on these tasks, a simple framework that each developer
+could use was implemented to bootstrap the development effort. This
+framework renders to a single back-end server and provides dummy input
+devices (i.e., the keyboard and mouse). The simple back-end rendering
+service was implemented using the shadow framebuffer support currently
+available in the XFree86 environment.
+
+<p>Using this bootstrapping framework, each developer has been able to
+work on each of the tasks listed above independently as follows: the
+framework will be extended to handle arbitrary back-end server
+configurations; the back-end rendering services will be transitioned to
+the more efficient Xnest-style implementation; and, an input device
+framework to handle various input devices via the input extension will
+be developed.
+
+<p>Status: The boot strap code is complete. <!-- August 2001 -->
+
+
+<sect1>Input device handling
+
+<p>An X server (including the front-end X server) requires two core
+input devices -- a keyboard and a pointer (mouse). These core devices
+are handled and required by the core X11 protocol. Additional types of
+input devices may be attached and utilized via the XInput extension.
+These are usually referred to as ``XInput extension devices'',
+
+<p>There are some options as to how the front-end X server gets its core
+input devices:
+
+<enum>
+ <item>Local Input. The physical input devices (e.g., keyboard and
+ mouse) can be attached directly to the front-end X server. In this
+ case, the keyboard and mouse on the machine running the front-end X
+ server will be used. The front-end will have drivers to read the
+ raw input from those devices and convert it into the required X
+ input events (e.g., key press/release, pointer button press/release,
+ pointer motion). The front-end keyboard driver will keep track of
+ keyboard properties such as key and modifier mappings, autorepeat
+ state, keyboard sound and led state. Similarly the front-end
+ pointer driver will keep track if pointer properties such as the
+ button mapping and movement acceleration parameters. With this
+ option, input is handled fully in the front-end X server, and the
+ back-end X servers are used in a display-only mode. This option was
+ implemented and works for a limited number of Linux-specific
+ devices. Adding additional local input devices for other
+ architectures is expected to be relatively simple.
+
+ <p>The following options are available for implementing local input
+ devices:
+
+ <enum>
+ <item>The XFree86 X server has modular input drivers that could
+ be adapted for this purpose. The mouse driver supports a wide
+ range of mouse types and interfaces, as well as a range of
+ Operating System platforms. The keyboard driver in XFree86 is
+ not currently as modular as the mouse driver, but could be made
+ so. The XFree86 X server also has a range of other input
+ drivers for extended input devices such as tablets and touch
+ screens. Unfortunately, the XFree86 drivers are generally
+ complex, often simultaneously providing support for multiple
+ devices across multiple architectures; and rely so heavily on
+ XFree86-specific helper-functions, that this option was not
+ pursued.
+
+
+ <item>The <tt/kdrive/ X server in XFree86 has built-in drivers that
+ support PS/2 mice and keyboard under Linux. The mouse driver
+ can indirectly handle other mouse types if the Linux utility
+ <tt/gpm/ is used as to translate the native mouse protocol into
+ PS/2 mouse format. These drivers could be adapted and built in
+ to the front-end X server if this range of hardware and OS
+ support is sufficient. While much simpler than the XFree86
+ drivers, the <tt/kdrive/ drivers were not used for the DMX
+ implementation.
+
+ <item>Reimplementation of keyboard and mouse drivers from
+ scratch for the DMX framework. Because keyboard and mouse
+ drivers are relatively trivial to implement, this pathway was
+ selected. Other drivers in the X source tree were referenced,
+ and significant contributions from other drivers are noted in
+ the DMX source code.
+ </enum>
+
+ <item>Backend Input. The front-end can make use of the core input
+ devices attached to one or more of the back-end X servers. Core
+ input events from multiple back-ends are merged into a single input
+ event stream. This can work sanely when only a single set of input
+ devices is used at any given time. The keyboard and pointer state
+ will be handled in the front-end, with changes propagated to the
+ back-end servers as needed. This option was implemented and works
+ well. Because the core pointer on a back-end controls the hardware
+ mouse on that back-end, core pointers cannot be treated as XInput
+ extension devices. However, all back-end XInput extensions devices
+ can be mapped to either DMX core or DMX XInput extension devices.
+
+ <item>Console Input. The front-end server could create a console
+ window that is displayed on an X server independent of the back-end
+ X servers. This console window could display things like the
+ physical screen layout, and the front-end could get its core input
+ events from events delivered to the console window. This option was
+ implemented and works well. To help the human navigate, window
+ outlines are also displayed in the console window. Further, console
+ windows can be used as either core or XInput extension devices.
+
+ <item>Other options were initially explored, but they were all
+ partial subsets of the options listed above and, hence, are
+ irrelevant.
+
+</enum>
+
+<p>Although extended input devices are not specifically mentioned in the
+Distributed X requirements, the options above were all implemented so
+that XInput extension devices were supported.
+
+<p>The bootstrap code (Xdmx) had dummy input devices, and these are
+still supported in the final version. These do the necessary
+initialization to satisfy the X server's requirements for core pointer
+and keyboard devices, but no input events are ever generated.
+
+<p>Status: The input code is complete. Because of the complexity of the
+XFree86 input device drivers (and their heavy reliance on XFree86
+infrastructure), separate low-level device drivers were implemented for
+Xdmx. The following kinds of drivers are supported (in general, the
+devices can be treated arbitrarily as "core" input devices or as XInput
+"extension" devices; and multiple instances of different kinds of
+devices can be simultaneously available):
+ <enum>
+ <item> A "dummy" device drive that never generates events.
+
+ <item> "Local" input is from the low-level hardware on which the
+ Xdmx binary is running. This is the only area where using the
+ XFree86 driver infrastructure would have been helpful, and then
+ only partially, since good support for generic USB devices does
+ not yet exist in XFree86 (in any case, XFree86 and kdrive driver
+ code was used where possible). Currently, the following local
+ devices are supported under Linux (porting to other operating
+ systems should be fairly straightforward):
+ <itemize>
+ <item>Linux keyboard
+ <item>Linux serial mouse (MS)
+ <item>Linux PS/2 mouse
+ <item>USB keyboard
+ <item>USB mouse
+ <item>USB generic device (e.g., joystick, gamepad, etc.)
+ </itemize>
+
+ <item> "Backend" input is taken from one or more of the back-end
+ displays. In this case, events are taken from the back-end X
+ server and are converted to Xdmx events. Care must be taken so
+ that the sprite moves properly on the display from which input
+ is being taken.
+
+ <item> "Console" input is taken from an X window that Xdmx
+ creates on the operator's display (i.e., on the machine running
+ the Xdmx binary). When the operator's mouse is inside the
+ console window, then those events are converted to Xdmx events.
+ Several special features are available: the console can display
+ outlines of windows that are on the Xdmx display (to facilitate
+ navigation), the cursor can be confined to the console, and a
+ "fine" mode can be activated to allow very precise cursor
+ positioning.
+ </enum>
+
+
+<!-- May 2002; July 2003 -->
+
+<sect1>Output device handling
+
+<p>The output of the DMX system displays rendering and windowing
+requests across multiple screens. The screens are typically arranged in
+a grid such that together they represent a single large display.
+
+<p>The output section of the DMX code consists of two parts. The first
+is in the front-end proxy X server (Xdmx), which accepts client
+connections, manages the windows, and potentially renders primitives but
+does not actually display any of the drawing primitives. The second
+part is the back-end X server(s), which accept commands from the
+front-end server and display the results on their screens.
+
+<sect2>Initialization
+
+<p>The DMX front-end must first initialize its screens by connecting to
+each of the back-end X servers and collecting information about each of
+these screens. However, the information collected from the back-end X
+servers might be inconsistent. Handling these cases can be difficult
+and/or inefficient. For example, a two screen system has one back-end X
+server running at 16bpp while the second is running at 32bpp.
+Converting rendering requests (e.g., XPutImage() or XGetImage()
+requests) to the appropriate bit depth can be very time consuming.
+Analyzing these cases to determine how or even if it is possible to
+handle them is required. The current Xinerama code handles many of
+these cases (e.g., in PanoramiXConsolidate()) and will be used as a
+starting point. In general, the best solution is to use homogeneous X
+servers and display devices. Using back-end servers with the same depth
+is a requirement of the final DMX implementation.
+
+<p>Once this screen consolidation is finished, the relative position of
+each back-end X server's screen in the unified screen is initialized. A
+full-screen window is opened on each of the back-end X servers, and the
+cursor on each screen is turned off. The final DMX implementation can
+also make use of a partial-screen window, or multiple windows per
+back-end screen.
+
+<sect2>Handling rendering requests
+
+<p>After initialization, X applications connect to the front-end server.
+There are two possible implementations of how rendering and windowing
+requests are handled in the DMX system:
+
+<enum>
+ <item>A shadow framebuffer is used in the front-end server as the
+ render target. In this option, all protocol requests are completely
+ handled in the front-end server. All state and resources are
+ maintained in the front-end including a shadow copy of the entire
+ framebuffer. The framebuffers attached to the back-end servers are
+ updated by XPutImage() calls with data taken directly from the
+ shadow framebuffer.
+
+ <p>This solution suffers from two main problems. First, it does not
+ take advantage of any accelerated hardware available in the system.
+ Second, the size of the XPutImage() calls can be quite large and
+ thus will be limited by the bandwidth available.
+
+ <p>The initial DMX implementation used a shadow framebuffer by
+ default.
+
+ <item>Rendering requests are sent to each back-end server for
+ handling (as is done in the Xnest server described above). In this
+ option, certain protocol requests are handled in the front-end
+ server and certain requests are repackaged and then sent to the
+ back-end servers. The framebuffer is distributed across the
+ multiple back-end servers. Rendering to the framebuffer is handled
+ on each back-end and can take advantage of any acceleration
+ available on the back-end servers' graphics display device. State
+ is maintained both in the front and back-end servers.
+
+ <p>This solution suffers from two main drawbacks. First, protocol
+ requests are sent to all back-end servers -- even those that will
+ completely clip the rendering primitive -- which wastes bandwidth
+ and processing time. Second, state is maintained both in the front-
+ and back-end servers. These drawbacks are not as severe as in
+ option 1 (above) and can either be overcome through optimizations or
+ are acceptable. Therefore, this option will be used in the final
+ implementation.
+
+ <p>The final DMX implementation defaults to this mechanism, but also
+ supports the shadow framebuffer mechanism. Several optimizations
+ were implemented to eliminate the drawbacks of the default
+ mechanism. These optimizations are described the section below and
+ in Phase II of the Development Results (see appendix).
+
+</enum>
+
+<p>Status: Both the shadow framebuffer and Xnest-style code is complete.
+<!-- May 2002 -->
+
+
+<sect1>Optimizing DMX
+
+<p>Initially, the Xnest-style solution's performance will be measured
+and analyzed to determine where the performance bottlenecks exist.
+There are four main areas that will be addressed.
+
+<p>First, to obtain reasonable interactivity with the first development
+phase, XSync() was called after each protocol request. The XSync()
+function flushes any pending protocol requests. It then waits for the
+back-end to process the request and send a reply that the request has
+completed. This happens with each back-end server and performance
+greatly suffers. As a result of the way XSync() is called in the first
+development phase, the batching that the X11 library performs is
+effectively defeated. The XSync() call usage will be analyzed and
+optimized by batching calls and performing them at regular intervals,
+except where interactivity will suffer (e.g., on cursor movements).
+
+<p>Second, the initial Xnest-style solution described above sends the
+repackaged protocol requests to all back-end servers regardless of
+whether or not they would be completely clipped out. The requests that
+are trivially rejected on the back-end server wastes the limited
+bandwidth available. By tracking clipping changes in the DMX X server's
+windowing code (e.g., by opening, closing, moving or resizing windows),
+we can determine whether or not back-end windows are visible so that
+trivial tests in the front-end server's GC ops drawing functions can
+eliminate these unnecessary protocol requests.
+
+<p>Third, each protocol request will be analyzed to determine if it is
+possible to break the request into smaller pieces at display boundaries.
+The initial ones to be analyzed are put and get image requests since
+they will require the greatest bandwidth to transmit data between the
+front and back-end servers. Other protocol requests will be analyzed
+and those that will benefit from breaking them into smaller requests
+will be implemented.
+
+<p>Fourth, an extension is being considered that will allow font glyphs to
+be transferred from the front-end DMX X server to each back-end server.
+This extension will permit the front-end to handle all font requests and
+eliminate the requirement that all back-end X servers share the exact
+same fonts as the front-end server. We are investigating the
+feasibility of this extension during this development phase.
+
+<p>Other potential optimizations will be determined from the performance
+analysis.
+
+<p>Please note that in our initial design, we proposed optimizing BLT
+operations (e.g., XCopyArea() and window moves) by developing an
+extension that would allow individual back-end servers to directly copy
+pixel data to other back-end servers. This potential optimization was
+in response to the simple image movement implementation that required
+potentially many calls to GetImage() and PutImage(). However, the
+current Xinerama implementation handles these BLT operations
+differently. Instead of copying data to and from screens, they generate
+expose events -- just as happens in the case when a window is moved from
+off a screen to on screen. This approach saves the limited bandwidth
+available between front and back-end servers and is being standardized
+with Xinerama. It also eliminates the potential setup problems and
+security issues resulting from having each back-end server open
+connections to all other back-end servers. Therefore, we suggest
+accepting Xinerama's expose event solution.
+
+<p>Also note that the approach proposed in the second and third
+optimizations might cause backing store algorithms in the back-end to be
+defeated, so a DMX X server configuration flag will be added to disable
+these optimizations.
+
+<p>Status: The optimizations proposed above are complete. It was
+determined that the using the xfs font server was sufficient and
+creating a new mechanism to pass glyphs was redundant; therefore, the
+fourth optimization proposed above was not included in DMX.
+<!-- September 2002 -->
+
+
+<sect1>DMX X extension support
+
+<p>The DMX X server keeps track of all the windowing information on the
+back-end X servers, but does not currently export this information to
+any client applications. An extension will be developed to pass the
+screen information and back-end window IDs to DMX-aware clients. These
+clients can then use this information to directly connect to and render
+to the back-end windows. Bypassing the DMX X server allows DMX-aware
+clients to break up complex rendering requests on their own and send
+them directly to the windows on the back-end server's screens. An
+example of a client that can make effective use of this extension is
+Chromium.
+
+<p>Status: The extension, as implemented, is fully documented in
+"Client-to-Server DMX Extension to the X Protocol". Future changes
+might be required based on feedback and other proposed enhancements to
+DMX. Currently, the following facilities are supported:
+<enum>
+ <item>
+ Screen information (clipping rectangle for each screen relative
+ to the virtual screen)
+ <item>
+ Window information (window IDs and clipping information for each
+ back-end window that corresponds to each DMX window)
+ <item>
+ Input device information (mappings from DMX device IDs to
+ back-end device IDs)
+ <item>
+ Force window creation (so that a client can override the
+ server-side lazy window creation optimization)
+ <item>
+ Reconfiguration (so that a client can request that a screen
+ position be changed)
+ <item>
+ Addition and removal of back-end servers and back-end and
+ console inputs.
+</enum>
+<!-- September 2002; July 2003 -->
+
+
+<sect1>Common X extension support
+
+<p>The XInput, XKeyboard and Shape extensions are commonly used
+extensions to the base X11 protocol. XInput allows multiple and
+non-standard input devices to be accessed simultaneously. These input
+devices can be connected to either the front-end or back-end servers.
+XKeyboard allows much better keyboard mappings control. Shape adds
+support for arbitrarily shaped windows and is used by various window
+managers. Nearly all potential back-end X servers make these extensions
+available, and support for each one will be added to the DMX system.
+
+<p>In addition to the extensions listed above, support for the X
+Rendering extension (Render) is being developed. Render adds digital
+image composition to the rendering model used by the X Window System.
+While this extension is still under development by Keith Packard of HP,
+support for the current version will be added to the DMX system.
+
+<p>Support for the XTest extension was added during the first
+development phase.
+
+<!-- WARNING: this list is duplicated in the Phase IV discussion -->
+<p>Status: The following extensions are supported and are discussed in
+more detail in Phase IV of the Development Results (see appendix):
+ BIG-REQUESTS,
+ DEC-XTRAP,
+ DMX,
+ DPMS,
+ Extended-Visual-Information,
+ GLX,
+ LBX,
+ RECORD,
+ RENDER,
+ SECURITY,
+ SHAPE,
+ SYNC,
+ X-Resource,
+ XC-APPGROUP,
+ XC-MISC,
+ XFree86-Bigfont,
+ XINERAMA,
+ XInputExtension,
+ XKEYBOARD, and
+ XTEST.
+<!-- November 2002; updated February 2003, July 2003 -->
+
+<sect1>OpenGL support
+
+<p>OpenGL support using the Mesa code base exists in XFree86 release 4
+and later. Currently, the direct rendering infrastructure (DRI)
+provides accelerated OpenGL support for local clients and unaccelerated
+OpenGL support (i.e., software rendering) is provided for non-local
+clients.
+
+<p>The single head OpenGL support in XFree86 4.x will be extended to use
+the DMX system. When the front and back-end servers are on the same
+physical hardware, it is possible to use the DRI to directly render to
+the back-end servers. First, the existing DRI will be extended to
+support multiple display heads, and then to support the DMX system.
+OpenGL rendering requests will be direct rendering to each back-end X
+server. The DRI will request the screen layout (either from the
+existing Xinerama extension or a DMX-specific extension). Support for
+synchronized swap buffers will also be added (on hardware that supports
+it). Note that a single front-end server with a single back-end server
+on the same physical machine can emulate accelerated indirect rendering.
+
+<p>When the front and back-end servers are on different physical
+hardware or are using non-XFree86 4.x X servers, a mechanism to render
+primitives across the back-end servers will be provided. There are
+several options as to how this can be implemented.
+
+<enum>
+ <item>The existing OpenGL support in each back-end server can be
+ used by repackaging rendering primitives and sending them to each
+ back-end server. This option is similar to the unoptimized
+ Xnest-style approach mentioned above. Optimization of this solution
+ is beyond the scope of this project and is better suited to other
+ distributed rendering systems.
+
+ <item>Rendering to a pixmap in the front-end server using the
+ current XFree86 4.x code, and then displaying to the back-ends via
+ calls to XPutImage() is another option. This option is similar to
+ the shadow frame buffer approach mentioned above. It is slower and
+ bandwidth intensive, but has the advantage that the back-end servers
+ are not required to have OpenGL support.
+</enum>
+
+<p>These, and other, options will be investigated in this phase of the
+work.
+
+<p>Work by others have made Chromium DMX-aware. Chromium will use the
+DMX X protocol extension to obtain information about the back-end
+servers and will render directly to those servers, bypassing DMX.
+
+<p>Status: OpenGL support by the glxProxy extension was implemented by
+SGI and has been integrated into the DMX code base.
+<!-- May 2003-->
+
+
+<!-- ============================================================ -->
+<sect>Current issues
+
+<p>In this sections the current issues are outlined that require further
+investigation.
+
+<sect1>Fonts
+
+<p>The font path and glyphs need to be the same for the front-end and
+each of the back-end servers. Font glyphs could be sent to the back-end
+servers as necessary but this would consume a significant amount of
+available bandwidth during font rendering for clients that use many
+different fonts (e.g., Netscape). Initially, the font server (xfs) will
+be used to provide the fonts to both the front-end and back-end servers.
+Other possibilities will be investigated during development.
+
+<sect1>Zero width rendering primitives
+
+<p>To allow pixmap and on-screen rendering to be pixel perfect, all
+back-end servers must render zero width primitives exactly the same as
+the front-end renders the primitives to pixmaps. For those back-end
+servers that do not exactly match, zero width primitives will be
+automatically converted to one width primitives. This can be handled in
+the front-end server via the GC state.
+
+<sect1>Output scaling
+
+<p>With very large tiled displays, it might be difficult to read the
+information on the standard X desktop. In particular, the cursor can be
+easily lost and fonts could be difficult to read. Automatic primitive
+scaling might prove to be very useful. We will investigate the
+possibility of scaling the cursor and providing a set of alternate
+pre-scaled fonts to replace the standard fonts that many applications
+use (e.g., fixed). Other options for automatic scaling will also be
+investigated.
+
+<sect1>Per-screen colormaps
+
+<p>Each screen's default colormap in the set of back-end X servers
+should be able to be adjusted via a configuration utility. This support
+is would allow the back-end screens to be calibrated via custom gamma
+tables. On 24-bit systems that support a DirectColor visual, this type
+of correction can be accommodated. One possible implementation would be
+to advertise to X client of the DMX server a TrueColor visual while
+using DirectColor visuals on the back-end servers to implement this type
+of color correction. Other options will be investigated.
+
+<!-- ============================================================ -->
+<appendix>
+
+<sect>Background
+
+<p>This section describes the existing Open Source architectures that
+can be used to handle multiple screens and upon which this development
+project is based. This section was written before the implementation
+was finished, and may not reflect actual details of the implementation.
+It is left for historical interest only.
+
+<sect1>Core input device handling
+
+<p>The following is a description of how core input devices are handled
+by an X server.
+
+<sect2>InitInput()
+
+<p>InitInput() is a DDX function that is called at the start of each
+server generation from the X server's main() function. Its purpose is
+to determine what input devices are connected to the X server, register
+them with the DIX and MI layers, and initialize the input event queue.
+InitInput() does not have a return value, but the X server will abort if
+either a core keyboard device or a core pointer device are not
+registered. Extended input (XInput) devices can also be registered in
+InitInput().
+
+<p>InitInput() usually has implementation specific code to determine
+which input devices are available. For each input device it will be
+using, it calls AddInputDevice():
+
+<descrip>
+<tag/AddInputDevice()/ This DIX function allocates the device structure,
+registers a callback function (which handles device init, close, on and
+off), and returns the input handle, which can be treated as opaque. It
+is called once for each input device.
+</descrip>
+
+<p>Once input handles for core keyboard and core pointer devices have
+been obtained from AddInputDevice(), they are registered as core devices
+by calling RegisterPointerDevice() and RegisterKeyboardDevice(). Each
+of these should be called once. If both core devices are not
+registered, then the X server will exit with a fatal error when it
+attempts to start the input devices in InitAndStartDevices(), which is
+called directly after InitInput() (see below).
+
+<descrip>
+<tag/Register{Pointer,Keyboard}Device()/ These DIX functions take a
+handle returned from AddInputDevice() and initialize the core input
+device fields in inputInfo, and initialize the input processing and grab
+functions for each core input device.
+</descrip>
+
+<p>The core pointer device is then registered with the miPointer code
+(which does the high level cursor handling). While this registration
+is not necessary for correct miPointer operation in the current XFree86
+code, it is still done mostly for compatibility reasons.
+
+<descrip>
+<tag/miRegisterPointerDevice()/ This MI function registers the core
+pointer's input handle with with the miPointer code.
+</descrip>
+
+<p>The final part of InitInput() is the initialization of the input
+event queue handling. In most cases, the event queue handling provided
+in the MI layer is used. The primary XFree86 X server uses its own
+event queue handling to support some special cases related to the XInput
+extension and the XFree86-specific DGA extension. For our purposes, the
+MI event queue handling should be suitable. It is initialized by
+calling mieqInit():
+
+<descrip>
+<tag/mieqInit()/ This MI function initializes the MI event queue for the
+core devices, and is passed the public component of the input handles
+for the two core devices.
+</descrip>
+
+<p>If a wakeup handler is required to deliver synchronous input
+events, it can be registered here by calling the DIX function
+RegisterBlockAndWakeupHandlers(). (See the devReadInput() description
+below.)
+
+<sect2>InitAndStartDevices()
+
+<p>InitAndStartDevices() is a DIX function that is called immediately
+after InitInput() from the X server's main() function. Its purpose is
+to initialize each input device that was registered with
+AddInputDevice(), enable each input device that was successfully
+initialized, and create the list of enabled input devices. Once each
+registered device is processed in this way, the list of enabled input
+devices is checked to make sure that both a core keyboard device and
+core pointer device were registered and successfully enabled. If not,
+InitAndStartDevices() returns failure, and results in the the X server
+exiting with a fatal error.
+
+<p>Each registered device is initialized by calling its callback
+(dev-&gt;deviceProc) with the DEVICE_INIT argument:
+
+<descrip>
+<tag/(*dev-&gt;deviceProc)(dev, DEVICE_INIT)/ This function initializes the
+device structs with core information relevant to the device.
+
+<p>For pointer devices, this means specifying the number of buttons,
+default button mapping, the function used to get motion events (usually
+miPointerGetMotionEvents()), the function used to change/control the
+core pointer motion parameters (acceleration and threshold), and the
+motion buffer size.
+
+<p>For keyboard devices, this means specifying the keycode range,
+default keycode to keysym mapping, default modifier mapping, and the
+functions used to sound the keyboard bell and modify/control the
+keyboard parameters (LEDs, bell pitch and duration, key click, which
+keys are auto-repeating, etc).
+</descrip>
+
+<p>Each initialized device is enabled by calling EnableDevice():
+
+<descrip>
+<tag/EnableDevice()/ EnableDevice() calls the device callback with
+DEVICE_ON:
+ <descrip>
+ <tag/(*dev-&gt;deviceProc)(dev, DEVICE_ON)/ This typically opens and
+ initializes the relevant physical device, and when appropriate,
+ registers the device's file descriptor (or equivalent) as a valid
+ input source.
+ </descrip>
+
+ <p>EnableDevice() then adds the device handle to the X server's
+ global list of enabled devices.
+</descrip>
+
+<p>InitAndStartDevices() then verifies that a valid core keyboard and
+pointer has been initialized and enabled. It returns failure if either
+are missing.
+
+<sect2>devReadInput()
+
+<p>Each device will have some function that gets called to read its
+physical input. These may be called in a number of different ways. In
+the case of synchronous I/O, they will be called from a DDX
+wakeup-handler that gets called after the server detects that new input is
+available. In the case of asynchronous I/O, they will be called from a
+(SIGIO) signal handler triggered when new input is available. This
+function should do at least two things: make sure that input events get
+enqueued, and make sure that the cursor gets moved for motion events
+(except if these are handled later by the driver's own event queue
+processing function, which cannot be done when using the MI event queue
+handling).
+
+<p>Events are queued by calling mieqEnqueue():
+
+<descrip>
+<tag/mieqEnqueue()/ This MI function is used to add input events to the
+event queue. It is simply passed the event to be queued.
+</descrip>
+
+<p>The cursor position should be updated when motion events are
+enqueued, by calling either miPointerAbsoluteCursor() or
+miPointerDeltaCursor():
+
+<descrip>
+<tag/miPointerAbsoluteCursor()/ This MI function is used to move the
+cursor to the absolute coordinates provided.
+<tag/miPointerDeltaCursor()/ This MI function is used to move the cursor
+relative to its current position.
+</descrip>
+
+<sect2>ProcessInputEvents()
+
+<p>ProcessInputEvents() is a DDX function that is called from the X
+server's main dispatch loop when new events are available in the input
+event queue. It typically processes the enqueued events, and updates
+the cursor/pointer position. It may also do other DDX-specific event
+processing.
+
+<p>Enqueued events are processed by mieqProcessInputEvents() and passed
+to the DIX layer for transmission to clients:
+
+<descrip>
+<tag/mieqProcessInputEvents()/ This function processes each event in the
+event queue, and passes it to the device's input processing function.
+The DIX layer provides default functions to do this processing, and they
+handle the task of getting the events passed back to the relevant
+clients.
+<tag/miPointerUpdate()/ This function resynchronized the cursor position
+with the new pointer position. It also takes care of moving the cursor
+between screens when needed in multi-head configurations.
+</descrip>
+
+
+<sect2>DisableDevice()
+
+<p>DisableDevice is a DIX function that removes an input device from the
+list of enabled devices. The result of this is that the device no
+longer generates input events. The device's data structures are kept in
+place, and disabling a device like this can be reversed by calling
+EnableDevice(). DisableDevice() may be called from the DDX when it is
+desirable to do so (e.g., the XFree86 server does this when VT
+switching). Except for special cases, this is not normally called for
+core input devices.
+
+<p>DisableDevice() calls the device's callback function with
+<tt/DEVICE_OFF/:
+
+<descrip>
+<tag/(*dev-&gt;deviceProc)(dev, DEVICE_OFF)/ This typically closes the
+relevant physical device, and when appropriate, unregisters the device's
+file descriptor (or equivalent) as a valid input source.
+</descrip>
+
+<p>DisableDevice() then removes the device handle from the X server's
+global list of enabled devices.
+
+
+<sect2>CloseDevice()
+
+<p>CloseDevice is a DIX function that removes an input device from the
+list of available devices. It disables input from the device and frees
+all data structures associated with the device. This function is
+usually called from CloseDownDevices(), which is called from main() at
+the end of each server generation to close all input devices.
+
+<p>CloseDevice() calls the device's callback function with
+<tt/DEVICE_CLOSE/:
+
+<descrip>
+<tag/(*dev-&gt;deviceProc)(dev, DEVICE_CLOSE)/ This typically closes the
+relevant physical device, and when appropriate, unregisters the device's
+file descriptor (or equivalent) as a valid input source. If any device
+specific data structures were allocated when the device was initialized,
+they are freed here.
+</descrip>
+
+<p>CloseDevice() then frees the data structures that were allocated
+for the device when it was registered/initialized.
+
+
+<sect2>LegalModifier()
+<!-- dmx/dmxinput.c - currently returns TRUE -->
+<p>LegalModifier() is a required DDX function that can be used to
+restrict which keys may be modifier keys. This seems to be present for
+historical reasons, so this function should simply return TRUE
+unconditionally.
+
+
+<sect1>Output handling
+
+<p>The following sections describe the main functions required to
+initialize, use and close the output device(s) for each screen in the X
+server.
+
+<sect2>InitOutput()
+
+<p>This DDX function is called near the start of each server generation
+from the X server's main() function. InitOutput()'s main purpose is to
+initialize each screen and fill in the global screenInfo structure for
+each screen. It is passed three arguments: a pointer to the screenInfo
+struct, which it is to initialize, and argc and argv from main(), which
+can be used to determine additional configuration information.
+
+<p>The primary tasks for this function are outlined below:
+
+<enum>
+ <item><bf/Parse configuration info:/ The first task of InitOutput()
+ is to parses any configuration information from the configuration
+ file. In addition to the XF86Config file, other configuration
+ information can be taken from the command line. The command line
+ options can be gathered either in InitOutput() or earlier in the
+ ddxProcessArgument() function, which is called by
+ ProcessCommandLine(). The configuration information determines the
+ characteristics of the screen(s). For example, in the XFree86 X
+ server, the XF86Config file specifies the monitor information, the
+ screen resolution, the graphics devices and slots in which they are
+ located, and, for Xinerama, the screens' layout.
+
+ <item><bf/Initialize screen info:/ The next task is to initialize
+ the screen-dependent internal data structures. For example, part of
+ what the XFree86 X server does is to allocate its screen and pixmap
+ private indices, probe for graphics devices, compare the probed
+ devices to the ones listed in the XF86Config file, and add the ones that
+ match to the internal xf86Screens&lsqb;&rsqb; structure.
+
+ <item><bf/Set pixmap formats:/ The next task is to initialize the
+ screenInfo's image byte order, bitmap bit order and bitmap scanline
+ unit/pad. The screenInfo's pixmap format's depth, bits per pixel
+ and scanline padding is also initialized at this stage.
+
+ <item><bf/Unify screen info:/ An optional task that might be done at
+ this stage is to compare all of the information from the various
+ screens and determines if they are compatible (i.e., if the set of
+ screens can be unified into a single desktop). This task has
+ potential to be useful to the DMX front-end server, if Xinerama's
+ PanoramiXConsolidate() function is not sufficient.
+</enum>
+
+<p>Once these tasks are complete, the valid screens are known and each
+of these screens can be initialized by calling AddScreen().
+
+<sect2>AddScreen()
+
+<p>This DIX function is called from InitOutput(), in the DDX layer, to
+add each new screen to the screenInfo structure. The DDX screen
+initialization function and command line arguments (i.e., argc and argv)
+are passed to it as arguments.
+
+<p>This function first allocates a new Screen structure and any privates
+that are required. It then initializes some of the fields in the Screen
+struct and sets up the pixmap padding information. Finally, it calls
+the DDX screen initialization function ScreenInit(), which is described
+below. It returns the number of the screen that were just added, or -1
+if there is insufficient memory to add the screen or if the DDX screen
+initialization fails.
+
+<sect2>ScreenInit()
+
+<p>This DDX function initializes the rest of the Screen structure with
+either generic or screen-specific functions (as necessary). It also
+fills in various screen attributes (e.g., width and height in
+millimeters, black and white pixel values).
+
+<p>The screen init function usually calls several functions to perform
+certain screen initialization functions. They are described below:
+
+<descrip>
+<tag/{mi,*fb}ScreenInit()/ The DDX layer's ScreenInit() function usually
+calls another layer's ScreenInit() function (e.g., miScreenInit() or
+fbScreenInit()) to initialize the fallbacks that the DDX driver does not
+specifically handle.
+
+<p>After calling another layer's ScreenInit() function, any
+screen-specific functions either wrap or replace the other layer's
+function pointers. If a function is to be wrapped, each of the old
+function pointers from the other layer are stored in a screen private
+area. Common functions to wrap are CloseScreen() and SaveScreen().
+
+<tag/miInitializeBackingStore()/ This MI function initializes the
+screen's backing storage functions, which are used to save areas of
+windows that are currently covered by other windows.
+
+<tag/miDCInitialize()/ This MI function initializes the MI cursor
+display structures and function pointers. If a hardware cursor is used,
+the DDX layer's ScreenInit() function will wrap additional screen and
+the MI cursor display function pointers.
+</descrip>
+
+<p>Another common task for ScreenInit() function is to initialize the
+output device state. For example, in the XFree86 X server, the
+ScreenInit() function saves the original state of the video card and
+then initializes the video mode of the graphics device.
+
+<sect2>CloseScreen()
+
+<p>This function restores any wrapped screen functions (and in
+particular the wrapped CloseScreen() function) and restores the state of
+the output device to its original state. It should also free any
+private data it created during the screen initialization.
+
+<sect2>GC operations
+
+<p>When the X server is requested to render drawing primitives, it does
+so by calling drawing functions through the graphics context's operation
+function pointer table (i.e., the GCOps functions). These functions
+render the basic graphics operations such as drawing rectangles, lines,
+text or copying pixmaps. Default routines are provided either by the MI
+layer, which draws indirectly through a simple span interface, or by the
+framebuffer layers (e.g., CFB, MFB, FB), which draw directly to a
+linearly mapped frame buffer.
+
+<p>To take advantage of special hardware on the graphics device,
+specific GCOps functions can be replaced by device specific code.
+However, many times the graphics devices can handle only a subset of the
+possible states of the GC, so during graphics context validation,
+appropriate routines are selected based on the state and capabilities of
+the hardware. For example, some graphics hardware can accelerate single
+pixel width lines with certain dash patterns. Thus, for dash patterns
+that are not supported by hardware or for width 2 or greater lines, the
+default routine is chosen during GC validation.
+
+<p>Note that some pointers to functions that draw to the screen are
+stored in the Screen structure. They include GetImage(), GetSpans(),
+PaintWindowBackground(), PaintWindowBorder(), CopyWindow() and
+RestoreAreas().
+
+<sect2>Xnest
+
+<p>The Xnest X server is a special proxy X server that relays the X
+protocol requests that it receives to a ``real'' X server that then
+processes the requests and displays the results, if applicable. To the X
+applications, Xnest appears as if it is a regular X server. However,
+Xnest is both server to the X application and client of the real X
+server, which will actually handle the requests.
+
+<p>The Xnest server implements all of the standard input and output
+initialization steps outlined above.
+
+<descrip>
+<tag/InitOutput()/ Xnest takes its configuration information from
+command line arguments via ddxProcessArguments(). This information
+includes the real X server display to connect to, its default visual
+class, the screen depth, the Xnest window's geometry, etc. Xnest then
+connects to the real X server and gathers visual, colormap, depth and
+pixmap information about that server's display, creates a window on that
+server, which will be used as the root window for Xnest.
+
+<p>Next, Xnest initializes its internal data structures and uses the
+data from the real X server's pixmaps to initialize its own pixmap
+formats. Finally, it calls AddScreen(xnestOpenScreen, argc, argv) to
+initialize each of its screens.
+
+<tag/ScreenInit()/ Xnest's ScreenInit() function is called
+xnestOpenScreen(). This function initializes its screen's depth and
+visual information, and then calls miScreenInit() to set up the default
+screen functions. It then calls miInitializeBackingStore() and
+miDCInitialize() to initialize backing store and the software cursor.
+Finally, it replaces many of the screen functions with its own
+functions that repackage and send the requests to the real X server to
+which Xnest is attached.
+
+<tag/CloseScreen()/ This function frees its internal data structure
+allocations. Since it replaces instead of wrapping screen functions,
+there are no function pointers to unwrap. This can potentially lead to
+problems during server regeneration.
+
+<tag/GC operations/ The GC operations in Xnest are very simple since
+they leave all of the drawing to the real X server to which Xnest is
+attached. Each of the GCOps takes the request and sends it to the
+real X server using standard Xlib calls. For example, the X
+application issues a XDrawLines() call. This function turns into a
+protocol request to Xnest, which calls the xnestPolylines() function
+through Xnest's GCOps function pointer table. The xnestPolylines()
+function is only a single line, which calls XDrawLines() using the same
+arguments that were passed into it. Other GCOps functions are very
+similar. Two exceptions to the simple GCOps functions described above
+are the image functions and the BLT operations.
+
+<p>The image functions, GetImage() and PutImage(), must use a temporary
+image to hold the image to be put of the image that was just grabbed
+from the screen while it is in transit to the real X server or the
+client. When the image has been transmitted, the temporary image is
+destroyed.
+
+<p>The BLT operations, CopyArea() and CopyPlane(), handle not only the
+copy function, which is the same as the simple cases described above,
+but also the graphics exposures that result when the GC's graphics
+exposure bit is set to True. Graphics exposures are handled in a helper
+function, xnestBitBlitHelper(). This function collects the exposure
+events from the real X server and, if any resulting in regions being
+exposed, then those regions are passed back to the MI layer so that it
+can generate exposure events for the X application.
+</descrip>
+
+<p>The Xnest server takes its input from the X server to which it is
+connected. When the mouse is in the Xnest server's window, keyboard and
+mouse events are received by the Xnest server, repackaged and sent back
+to any client that requests those events.
+
+<sect2>Shadow framebuffer
+
+<p>The most common type of framebuffer is a linear array memory that
+maps to the video memory on the graphics device. However, accessing
+that video memory over an I/O bus (e.g., ISA or PCI) can be slow. The
+shadow framebuffer layer allows the developer to keep the entire
+framebuffer in main memory and copy it back to video memory at regular
+intervals. It also has been extended to handle planar video memory and
+rotated framebuffers.
+
+<p>There are two main entry points to the shadow framebuffer code:
+
+<descrip>
+<tag/shadowAlloc(width, height, bpp)/ This function allocates the in
+memory copy of the framebuffer of size width*height*bpp. It returns a
+pointer to that memory, which will be used by the framebuffer
+ScreenInit() code during the screen's initialization.
+
+<tag/shadowInit(pScreen, updateProc, windowProc)/ This function
+initializes the shadow framebuffer layer. It wraps several screen
+drawing functions, and registers a block handler that will update the
+screen. The updateProc is a function that will copy the damaged regions
+to the screen, and the windowProc is a function that is used when the
+entire linear video memory range cannot be accessed simultaneously so
+that only a window into that memory is available (e.g., when using the
+VGA aperture).
+</descrip>
+
+<p>The shadow framebuffer code keeps track of the damaged area of each
+screen by calculating the bounding box of all drawing operations that
+have occurred since the last screen update. Then, when the block handler
+is next called, only the damaged portion of the screen is updated.
+
+<p>Note that since the shadow framebuffer is kept in main memory, all
+drawing operations are performed by the CPU and, thus, no accelerated
+hardware drawing operations are possible.
+
+
+<sect1>Xinerama
+
+<p>Xinerama is an X extension that allows multiple physical screens
+controlled by a single X server to appear as a single screen. Although
+the extension allows clients to find the physical screen layout via
+extension requests, it is completely transparent to clients at the core
+X11 protocol level. The original public implementation of Xinerama came
+from Digital/Compaq. XFree86 rewrote it, filling in some missing pieces
+and improving both X11 core protocol compliance and performance. The
+Xinerama extension will be passing through X.Org's standardization
+process in the near future, and the sample implementation will be based
+on this rewritten version.
+
+<p>The current implementation of Xinerama is based primarily in the DIX
+(device independent) and MI (machine independent) layers of the X
+server. With few exceptions the DDX layers do not need any changes to
+support Xinerama. X server extensions often do need modifications to
+provide full Xinerama functionality.
+
+<p>The following is a code-level description of how Xinerama functions.
+
+<p>Note: Because the Xinerama extension was originally called the
+PanoramiX extension, many of the Xinerama functions still have the
+PanoramiX prefix.
+
+<descrip>
+ <tag/PanoramiXExtensionInit()/ PanoramiXExtensionInit() is a
+ device-independent extension function that is called at the start of
+ each server generation from InitExtensions(), which is called from
+ the X server's main() function after all output devices have been
+ initialized, but before any input devices have been initialized.
+
+ <p>PanoramiXNumScreens is set to the number of physical screens. If
+ only one physical screen is present, the extension is disabled, and
+ PanoramiXExtensionInit() returns without doing anything else.
+
+ <p>The Xinerama extension is registered by calling AddExtension().
+
+ <p>A local per-screen array of data structures
+ (panoramiXdataPtr&lsqb;&rsqb;)
+ is allocated for each physical screen, and GC and Screen private
+ indexes are allocated, and both GC and Screen private areas are
+ allocated for each physical screen. These hold Xinerama-specific
+ per-GC and per-Screen data. Each screen's CreateGC and CloseScreen
+ functions are wrapped by XineramaCreateGC() and
+ XineramaCloseScreen() respectively. Some new resource classes are
+ created for Xinerama drawables and GCs, and resource types for
+ Xinerama windows, pixmaps and colormaps.
+
+ <p>A region (XineramaScreenRegions&lsqb;i&rsqb;) is initialized for each
+ physical screen, and single region (PanoramiXScreenRegion) is
+ initialized to be the union of the screen regions. The
+ panoramiXdataPtr&lsqb;&rsqb; array is also initialized with the size and
+ origin of each screen. The relative positioning information for the
+ physical screens is taken from the array
+ dixScreenOrigins&lsqb;&rsqb;, which
+ the DDX layer must initialize in InitOutput(). The bounds of the
+ combined screen is also calculated (PanoramiXPixWidth and
+ PanoramiXPixHeight).
+
+ <p>The DIX layer has a list of function pointers
+ (ProcVector&lsqb;&rsqb;) that
+ holds the entry points for the functions that process core protocol
+ requests. The requests that Xinerama must intercept and break up
+ into physical screen-specific requests are wrapped. The original
+ set is copied to SavedProcVector&lsqb;&rsqb;. The types of requests
+ intercepted are Window requests, GC requests, colormap requests,
+ drawing requests, and some geometry-related requests. This wrapping
+ allows the bulk of the protocol request processing to be handled
+ transparently to the DIX layer. Some operations cannot be dealt with
+ in this way and are handled with Xinerama-specific code within the
+ DIX layer.
+
+ <tag/PanoramiXConsolidate()/ PanoramiXConsolidate() is a
+ device-independent extension function that is called directly from
+ the X server's main() function after extensions and input/output
+ devices have been initialized, and before the root windows are
+ defined and initialized.
+
+ <p>This function finds the set of depths (PanoramiXDepths&lsqb;&rsqb;) and
+ visuals (PanoramiXVisuals&lsqb;&rsqb;)
+ common to all of the physical screens.
+ PanoramiXNumDepths is set to the number of common depths, and
+ PanoramiXNumVisuals is set to the number of common visuals.
+ Resources are created for the single root window and the default
+ colormap. Each of these resources has per-physical screen entries.
+
+ <tag/PanoramiXCreateConnectionBlock()/ PanoramiXConsolidate() is a
+ device-independent extension function that is called directly from
+ the X server's main() function after the per-physical screen root
+ windows are created. It is called instead of the standard DIX
+ CreateConnectionBlock() function. If this function returns FALSE,
+ the X server exits with a fatal error. This function will return
+ FALSE if no common depths were found in PanoramiXConsolidate().
+ With no common depths, Xinerama mode is not possible.
+
+ <p>The connection block holds the information that clients get when
+ they open a connection to the X server. It includes information
+ such as the supported pixmap formats, number of screens and the
+ sizes, depths, visuals, default colormap information, etc, for each
+ of the screens (much of information that <tt/xdpyinfo/ shows). The
+ connection block is initialized with the combined single screen
+ values that were calculated in the above two functions.
+
+ <p>The Xinerama extension allows the registration of connection
+ block callback functions. The purpose of these is to allow other
+ extensions to do processing at this point. These callbacks can be
+ registered by calling XineramaRegisterConnectionBlockCallback() from
+ the other extension's ExtensionInit() function. Each registered
+ connection block callback is called at the end of
+ PanoramiXCreateConnectionBlock().
+</descrip>
+
+<sect2>Xinerama-specific changes to the DIX code
+
+<p>There are a few types of Xinerama-specific changes within the DIX
+code. The main ones are described here.
+
+<p>Functions that deal with colormap or GC -related operations outside of
+the intercepted protocol requests have a test added to only do the
+processing for screen numbers > 0. This is because they are handled for
+the single Xinerama screen and the processing is done once for screen 0.
+
+<p>The handling of motion events does some coordinate translation between
+the physical screen's origin and screen zero's origin. Also, motion
+events must be reported relative to the composite screen origin rather
+than the physical screen origins.
+
+<p>There is some special handling for cursor, window and event processing
+that cannot (either not at all or not conveniently) be done via the
+intercepted protocol requests. A particular case is the handling of
+pointers moving between physical screens.
+
+<sect2>Xinerama-specific changes to the MI code
+
+<p>The only Xinerama-specific change to the MI code is in miSendExposures()
+to handle the coordinate (and window ID) translation for expose events.
+
+<sect2>Intercepted DIX core requests
+
+<p>Xinerama breaks up drawing requests for dispatch to each physical
+screen. It also breaks up windows into pieces for each physical screen.
+GCs are translated into per-screen GCs. Colormaps are replicated on
+each physical screen. The functions handling the intercepted requests
+take care of breaking the requests and repackaging them so that they can
+be passed to the standard request handling functions for each screen in
+turn. In addition, and to aid the repackaging, the information from
+many of the intercepted requests is used to keep up to date the
+necessary state information for the single composite screen. Requests
+(usually those with replies) that can be satisfied completely from this
+stored state information do not call the standard request handling
+functions.
+
+<!-- ============================================================ -->
+
+<sect>Development Results
+
+<p>In this section the results of each phase of development are
+discussed. This development took place between approximately June 2001
+and July 2003.
+
+<sect1>Phase I
+
+<p>The initial development phase dealt with the basic implementation
+including the bootstrap code, which used the shadow framebuffer, and the
+unoptimized implementation, based on an Xnest-style implementation.
+
+<sect2>Scope
+
+<p>The goal of Phase I is to provide fundamental functionality that can
+act as a foundation for ongoing work:
+<enum>
+ <item>Develop the proxy X server
+ <itemize>
+ <item>The proxy X server will operate on the X11 protocol and
+ relay requests as necessary to correctly perform the request.
+ <item>Work will be based on the existing work for Xinerama and
+ Xnest.
+ <item>Input events and windowing operations are handled in the
+ proxy server and rendering requests are repackaged and sent to
+ each of the back-end servers for display.
+ <item>The multiple screen layout (including support for
+ overlapping screens) will be user configurable via a
+ configuration file or through the configuration tool.
+ </itemize>
+ <item>Develop graphical configuration tool
+ <itemize>
+ <item>There will be potentially a large number of X servers to
+ configure into a single display. The tool will allow the user
+ to specify which servers are involved in the configuration and
+ how they should be laid out.
+ </itemize>
+ <item>Pass the X Test Suite
+ <itemize>
+ <item>The X Test Suite covers the basic X11 operations. All
+ tests known to succeed must correctly operate in the distributed
+ X environment.
+ </itemize>
+</enum>
+
+<p>For this phase, the back-end X servers are assumed to be unmodified X
+servers that do not support any DMX-related protocol extensions; future
+optimization pathways are considered, but are not implemented; and the
+configuration tool is assumed to rely only on libraries in the X source
+tree (e.g., Xt).
+
+<sect2>Results
+
+<p>The proxy X server, Xdmx, was developed to distribute X11 protocol
+requests to the set of back-end X servers. It opens a window on each
+back-end server, which represents the part of the front-end's root
+window that is visible on that screen. It mirrors window, pixmap and
+other state in each back-end server. Drawing requests are sent to
+either windows or pixmaps on each back-end server. This code is based
+on Xnest and uses the existing Xinerama extension.
+
+<p>Input events can be taken from (1) devices attached to the back-end
+server, (2) core devices attached directly to the Xdmx server, or (3)
+from a ``console'' window on another X server. Events for these devices
+are gathered, processed and delivered to clients attached to the Xdmx
+server.
+
+<p>An intuitive configuration format was developed to help the user
+easily configure the multiple back-end X servers. It was defined (see
+grammar in Xdmx man page) and a parser was implemented that is used by
+the Xdmx server and by a standalone xdmxconfig utility. The parsing
+support was implemented such that it can be easily factored out of the X
+source tree for use with other tools (e.g., vdl). Support for
+converting legacy vdl-format configuration files to the DMX format is
+provided by the vdltodmx utility.
+
+<p>Originally, the configuration file was going to be a subsection of
+XFree86's XF86Config file, but that was not possible since Xdmx is a
+completely separate X server. Thus, a separate config file format was
+developed. In addition, a graphical configuration
+tool, xdmxconfig, was developed to allow the user to create and arrange
+the screens in the configuration file. The <bf/-configfile/ and <bf/-config/
+command-line options can be used to start Xdmx using a configuration
+file.
+
+<p>An extension that enables remote input testing is required for the X
+Test Suite to function. During this phase, this extension (XTEST) was
+implemented in the Xdmx server. The results from running the X Test
+Suite are described in detail below.
+
+<sect2>X Test Suite
+
+ <sect3> Introduction
+ <p>
+ The X Test Suite contains tests that verify Xlib functions
+ operate correctly. The test suite is designed to run on a
+ single X server; however, since X applications will not be
+ able to tell the difference between the DMX server and a
+ standard X server, the X Test Suite should also run on the
+ DMX server.
+ <p>
+ The Xdmx server was tested with the X Test Suite, and the
+ existing failures are noted in this section. To put these
+ results in perspective, we first discuss expected X Test
+ failures and how errors in underlying systems can impact
+ Xdmx test results.
+
+ <sect3>Expected Failures for a Single Head
+ <p>
+ A correctly implemented X server with a single screen is
+ expected to fail certain X Test tests. The following
+ well-known errors occur because of rounding error in the X
+ server code:
+ <verb>
+XDrawArc: Tests 42, 63, 66, 73
+XDrawArcs: Tests 45, 66, 69, 76
+ </verb>
+ <p>
+ The following failures occur because of the high-level X
+ server implementation:
+ <verb>
+XLoadQueryFont: Test 1
+XListFontsWithInfo: Tests 3, 4
+XQueryFont: Tests 1, 2
+ </verb>
+ <p>
+ The following test fails when running the X server as root
+ under Linux because of the way directory modes are
+ interpreted:
+ <verb>
+XWriteBitmapFile: Test 3
+ </verb>
+ <p>
+ Depending on the video card used for the back-end, other
+ failures may also occur because of bugs in the low-level
+ driver implementation. Over time, failures of this kind
+ are usually fixed by XFree86, but will show up in Xdmx
+ testing until then.
+
+ <sect3>Expected Failures for Xinerama
+ <p>
+ Xinerama fails several X Test Suite tests because of
+ design decisions made for the current implementation of
+ Xinerama. Over time, many of these errors will be
+ corrected by XFree86 and the group working on a new
+ Xinerama implementation. Therefore, Xdmx will also share
+ X Suite Test failures with Xinerama.
+ <p>
+ We may be able to fix or work-around some of these
+ failures at the Xdmx level, but this will require
+ additional exploration that was not part of Phase I.
+ <p>
+ Xinerama is constantly improving, and the list of
+ Xinerama-related failures depends on XFree86 version and
+ the underlying graphics hardware. We tested with a
+ variety of hardware, including nVidia, S3, ATI Radeon,
+ and Matrox G400 (in dual-head mode). The list below
+ includes only those failures that appear to be from the
+ Xinerama layer, and does not include failures listed in
+ the previous section, or failures that appear to be from
+ the low-level graphics driver itself:
+ <p>
+ These failures were noted with multiple Xinerama
+ configurations:
+ <verb>
+XCopyPlane: Tests 13, 22, 31 (well-known Xinerama implementation issue)
+XSetFontPath: Test 4
+XGetDefault: Test 5
+XMatchVisualInfo: Test 1
+ </verb>
+ <p>
+ These failures were noted only when using one dual-head
+ video card with a 4.2.99.x XFree86 server:
+ <verb>
+XListPixmapFormats: Test 1
+XDrawRectangles: Test 45
+ </verb>
+ <p>
+ These failures were noted only when using two video cards
+ from different vendors with a 4.1.99.x XFree86 server:
+ <verb>
+XChangeWindowAttributes: Test 32
+XCreateWindow: Test 30
+XDrawLine: Test 22
+XFillArc: Test 22
+XChangeKeyboardControl: Tests 9, 10
+XRebindKeysym: Test 1
+ </verb>
+
+ <sect3>Additional Failures from Xdmx
+ <p>
+ When running Xdmx, no unexpected failures were noted.
+ Since the Xdmx server is based on Xinerama, we expect to
+ have most of the Xinerama failures present in the Xdmx
+ server. Similarly, since the Xdmx server must rely on the
+ low-level device drivers on each back-end server, we also
+ expect that Xdmx will exhibit most of the back-end
+ failures. Here is a summary:
+ <verb>
+XListPixmapFormats: Test 1 (configuration dependent)
+XChangeWindowAttributes: Test 32
+XCreateWindow: Test 30
+XCopyPlane: Test 13, 22, 31
+XSetFontPath: Test 4
+XGetDefault: Test 5 (configuration dependent)
+XMatchVisualInfo: Test 1
+XRebindKeysym: Test 1 (configuration dependent)
+ </verb>
+ <p>
+ Note that this list is shorter than the combined list for
+ Xinerama because Xdmx uses different code paths to perform
+ some Xinerama operations. Further, some Xinerama failures
+ have been fixed in the XFree86 4.2.99.x CVS repository.
+
+ <sect3>Summary and Future Work
+ <p>
+ Running the X Test Suite on Xdmx does not produce any
+ failures that cannot be accounted for by the underlying
+ Xinerama subsystem used by the front-end or by the
+ low-level device-driver code running on the back-end X
+ servers. The Xdmx server therefore is as ``correct'' as
+ possible with respect to the standard set of X Test Suite
+ tests.
+ <p>
+ During the following phases, we will continue to verify
+ Xdmx correctness using the X Test Suite. We may also use
+ other tests suites or write additional tests that run
+ under the X Test Suite that specifically verify the
+ expected behavior of DMX.
+
+<sect2>Fonts
+
+<p>In Phase I, fonts are handled directly by both the front-end and the
+back-end servers, which is required since we must treat each back-end
+server during this phase as a ``black box''. What this requires is that
+<bf/the front- and back-end servers must share the exact same font
+path/. There are two ways to help make sure that all servers share the
+same font path:
+
+<enum>
+ <item>First, each server can be configured to use the same font
+ server. The font server, xfs, can be configured to serve fonts to
+ multiple X servers via TCP.
+
+ <item>Second, each server can be configured to use the same font
+ path and either those font paths can be copied to each back-end
+ machine or they can be mounted (e.g., via NFS) on each back-end
+ machine.
+</enum>
+
+<p>One additional concern is that a client program can set its own font
+path, and if it does so, then that font path must be available on each
+back-end machine.
+
+<p>The -fontpath command line option was added to allow users to
+initialize the font path of the front end server. This font path is
+propagated to each back-end server when the default font is loaded. If
+there are any problems, an error message is printed, which will describe
+the problem and list the current font path. For more information about
+setting the font path, see the -fontpath option description in the man
+page.
+
+<sect2>Performance
+
+<p>Phase I of development was not intended to optimize performance. Its
+focus was on completely and correctly handling the base X11 protocol in
+the Xdmx server. However, several insights were gained during Phase I,
+which are listed here for reference during the next phase of
+development.
+
+<enum>
+ <item>Calls to XSync() can slow down rendering since it requires a
+ complete round trip to and from a back-end server. This is
+ especially problematic when communicating over long haul networks.
+ <item>Sending drawing requests to only the screens that they overlap
+ should improve performance.
+</enum>
+
+<sect2>Pixmaps
+
+<p>Pixmaps were originally expected to be handled entirely in the
+front-end X server; however, it was found that this overly complicated
+the rendering code and would have required sending potentially large
+images to each back server that required them when copying from pixmap
+to screen. Thus, pixmap state is mirrored in the back-end server just
+as it is with regular window state. With this implementation, the same
+rendering code that draws to windows can be used to draw to pixmaps on
+the back-end server, and no large image transfers are required to copy
+from pixmap to window.
+
+<!-- ============================================================ -->
+<sect1>Phase II
+
+<p>The second phase of development concentrates on performance
+optimizations. These optimizations are documented here, with
+<tt/x11perf/ data to show how the optimizations improve performance.
+
+<p>All benchmarks were performed by running Xdmx on a dual processor
+1.4GHz AMD Athlon machine with 1GB of RAM connecting over 100baseT to
+two single-processor 1GHz Pentium III machines with 256MB of RAM and ATI
+Rage 128 (RF) video cards. The front end was running Linux
+2.4.20-pre1-ac1 and the back ends were running Linux 2.4.7-10 and
+version 4.2.99.1 of XFree86 pulled from the XFree86 CVS repository on
+August 7, 2002. All systems were running Red Hat Linux 7.2.
+
+<sect2>Moving from XFree86 4.1.99.1 to 4.2.0.0
+
+<p>For phase II, the working source tree was moved to the branch tagged
+with dmx-1-0-branch and was updated from version 4.1.99.1 (20 August
+2001) of the XFree86 sources to version 4.2.0.0 (18 January 2002).
+After this update, the following tests were noted to be more than 10%
+faster:
+ <verb>
+1.13 Fill 300x300 opaque stippled trapezoid (161x145 stipple)
+1.16 Fill 1x1 tiled trapezoid (161x145 tile)
+1.13 Fill 10x10 tiled trapezoid (161x145 tile)
+1.17 Fill 100x100 tiled trapezoid (161x145 tile)
+1.16 Fill 1x1 tiled trapezoid (216x208 tile)
+1.20 Fill 10x10 tiled trapezoid (216x208 tile)
+1.15 Fill 100x100 tiled trapezoid (216x208 tile)
+1.37 Circulate Unmapped window (200 kids)
+ </verb>
+And the following tests were noted to be more than 10% slower:
+ <verb>
+0.88 Unmap window via parent (25 kids)
+0.75 Circulate Unmapped window (4 kids)
+0.79 Circulate Unmapped window (16 kids)
+0.80 Circulate Unmapped window (25 kids)
+0.82 Circulate Unmapped window (50 kids)
+0.85 Circulate Unmapped window (75 kids)
+ </verb>
+<p>These changes were not caused by any changes in the DMX system, and
+may point to changes in the XFree86 tree or to tests that have more
+"jitter" than most other <tt/x11perf/ tests.
+
+<sect2>Global changes
+
+<p>During the development of the Phase II DMX server, several global
+changes were made. These changes were also compared with the Phase I
+server. The following tests were noted to be more than 10% faster:
+ <verb>
+1.13 Fill 300x300 opaque stippled trapezoid (161x145 stipple)
+1.15 Fill 1x1 tiled trapezoid (161x145 tile)
+1.13 Fill 10x10 tiled trapezoid (161x145 tile)
+1.17 Fill 100x100 tiled trapezoid (161x145 tile)
+1.16 Fill 1x1 tiled trapezoid (216x208 tile)
+1.19 Fill 10x10 tiled trapezoid (216x208 tile)
+1.15 Fill 100x100 tiled trapezoid (216x208 tile)
+1.15 Circulate Unmapped window (4 kids)
+ </verb>
+
+<p>The following tests were noted to be more than 10% slower:
+ <verb>
+0.69 Scroll 10x10 pixels
+0.68 Scroll 100x100 pixels
+0.68 Copy 10x10 from window to window
+0.68 Copy 100x100 from window to window
+0.76 Circulate Unmapped window (75 kids)
+0.83 Circulate Unmapped window (100 kids)
+ </verb>
+
+<p>For the remainder of this analysis, the baseline of comparison will
+be the Phase II deliverable with all optimizations disabled (unless
+otherwise noted). This will highlight how the optimizations in
+isolation impact performance.
+
+<sect2>XSync() Batching
+
+<p>During the Phase I implementation, XSync() was called after every
+protocol request made by the DMX server. This provided the DMX server
+with an interactive feel, but defeated X11's protocol buffering system
+and introduced round-trip wire latency into every operation. During
+Phase II, DMX was changed so that protocol requests are no longer
+followed by calls to XSync(). Instead, the need for an XSync() is
+noted, and XSync() calls are only made every 100mS or when the DMX
+server specifically needs to make a call to guarantee interactivity.
+With this new system, X11 buffers protocol as much as possible during a
+100mS interval, and many unnecessary XSync() calls are avoided.
+
+<p>Out of more than 300 <tt/x11perf/ tests, 8 tests became more than 100
+times faster, with 68 more than 50X faster, 114 more than 10X faster,
+and 181 more than 2X faster. See table below for summary.
+
+<p>The following tests were noted to be more than 10% slower with
+XSync() batching on:
+ <verb>
+0.88 500x500 tiled rectangle (161x145 tile)
+0.89 Copy 500x500 from window to window
+ </verb>
+
+<sect2>Offscreen Optimization
+
+<p>Windows span one or more of the back-end servers' screens; however,
+during Phase I development, windows were created on every back-end
+server and every rendering request was sent to every window regardless
+of whether or not that window was visible. With the offscreen
+optimization, the DMX server tracks when a window is completely off of a
+back-end server's screen and, in that case, it does not send rendering
+requests to those back-end windows. This optimization saves bandwidth
+between the front and back-end servers, and it reduces the number of
+XSync() calls. The performance tests were run on a DMX system with only
+two back-end servers. Greater performance gains will be had as the
+number of back-end servers increases.
+
+<p>Out of more than 300 <tt/x11perf/ tests, 3 tests were at least twice as
+fast, and 146 tests were at least 10% faster. Two tests were more than
+10% slower with the offscreen optimization:
+ <verb>
+0.88 Hide/expose window via popup (4 kids)
+0.89 Resize unmapped window (75 kids)
+ </verb>
+
+<sect2>Lazy Window Creation Optimization
+
+<p>As mentioned above, during Phase I, windows were created on every
+back-end server even if they were not visible on that back-end. With
+the lazy window creation optimization, the DMX server does not create
+windows on a back-end server until they are either visible or they
+become the parents of a visible window. This optimization builds on the
+offscreen optimization (described above) and requires it to be enabled.
+
+<p>The lazy window creation optimization works by creating the window
+data structures in the front-end server when a client creates a window,
+but delays creation of the window on the back-end server(s). A private
+window structure in the DMX server saves the relevant window data and
+tracks changes to the window's attributes and stacking order for later
+use. The only times a window is created on a back-end server are (1)
+when it is mapped and is at least partially overlapping the back-end
+server's screen (tracked by the offscreen optimization), or (2) when the
+window becomes the parent of a previously visible window. The first
+case occurs when a window is mapped or when a visible window is copied,
+moved or resized and now overlaps the back-end server's screen. The
+second case occurs when starting a window manager after having created
+windows to which the window manager needs to add decorations.
+
+<p>When either case occurs, a window on the back-end server is created
+using the data saved in the DMX server's window private data structure.
+The stacking order is then adjusted to correctly place the window on the
+back-end and lastly the window is mapped. From this time forward, the
+window is handled exactly as if the window had been created at the time
+of the client's request.
+
+<p>Note that when a window is no longer visible on a back-end server's
+screen (e.g., it is moved offscreen), the window is not destroyed;
+rather, it is kept and reused later if the window once again becomes
+visible on the back-end server's screen. Originally with this
+optimization, destroying windows was implemented but was later rejected
+because it increased bandwidth when windows were opaquely moved or
+resized, which is common in many window managers.
+
+<p>The performance tests were run on a DMX system with only two back-end
+servers. Greater performance gains will be had as the number of
+back-end servers increases.
+
+<p>This optimization improved the following <tt/x11perf/ tests by more
+than 10%:
+ <verb>
+1.10 500x500 rectangle outline
+1.12 Fill 100x100 stippled trapezoid (161x145 stipple)
+1.20 Circulate Unmapped window (50 kids)
+1.19 Circulate Unmapped window (75 kids)
+ </verb>
+
+<sect2>Subdividing Rendering Primitives
+
+<p>X11 imaging requests transfer significant data between the client and
+the X server. During Phase I, the DMX server would then transfer the
+image data to each back-end server. Even with the offscreen
+optimization (above), these requests still required transferring
+significant data to each back-end server that contained a visible
+portion of the window. For example, if the client uses XPutImage() to
+copy an image to a window that overlaps the entire DMX screen, then the
+entire image is copied by the DMX server to every back-end server.
+
+<p>To reduce the amount of data transferred between the DMX server and
+the back-end servers when XPutImage() is called, the image data is
+subdivided and only the data that will be visible on a back-end server's
+screen is sent to that back-end server. Xinerama already implements a
+subdivision algorithm for XGetImage() and no further optimization was
+needed.
+
+<p>Other rendering primitives were analyzed, but the time required to
+subdivide these primitives was a significant proportion of the time
+required to send the entire rendering request to the back-end server, so
+this optimization was rejected for the other rendering primitives.
+
+<p>Again, the performance tests were run on a DMX system with only two
+back-end servers. Greater performance gains will be had as the number
+of back-end servers increases.
+
+<p>This optimization improved the following <tt/x11perf/ tests by more
+than 10%:
+ <verb>
+1.12 Fill 100x100 stippled trapezoid (161x145 stipple)
+1.26 PutImage 10x10 square
+1.83 PutImage 100x100 square
+1.91 PutImage 500x500 square
+1.40 PutImage XY 10x10 square
+1.48 PutImage XY 100x100 square
+1.50 PutImage XY 500x500 square
+1.45 Circulate Unmapped window (75 kids)
+1.74 Circulate Unmapped window (100 kids)
+ </verb>
+
+<p>The following test was noted to be more than 10% slower with this
+optimization:
+ <verb>
+0.88 10-pixel fill chord partial circle
+ </verb>
+
+<sect2>Summary of x11perf Data
+
+<p>With all of the optimizations on, 53 <tt/x11perf/ tests are more than
+100X faster than the unoptimized Phase II deliverable, with 69 more than
+50X faster, 73 more than 10X faster, and 199 more than twice as fast.
+No tests were more than 10% slower than the unoptimized Phase II
+deliverable. (Compared with the Phase I deliverable, only Circulate
+Unmapped window (100 kids) was more than 10% slower than the Phase II
+deliverable. As noted above, this test seems to have wider variability
+than other <tt/x11perf/ tests.)
+
+<p>The following table summarizes relative <tt/x11perf/ test changes for
+all optimizations individually and collectively. Note that some of the
+optimizations have a synergistic effect when used together.
+ <verb>
+
+1: XSync() batching only
+2: Off screen optimizations only
+3: Window optimizations only
+4: Subdivprims only
+5: All optimizations
+
+ 1 2 3 4 5 Operation
+------ ---- ---- ---- ------ ---------
+ 2.14 1.85 1.00 1.00 4.13 Dot
+ 1.67 1.80 1.00 1.00 3.31 1x1 rectangle
+ 2.38 1.43 1.00 1.00 2.44 10x10 rectangle
+ 1.00 1.00 0.92 0.98 1.00 100x100 rectangle
+ 1.00 1.00 1.00 1.00 1.00 500x500 rectangle
+ 1.83 1.85 1.05 1.06 3.54 1x1 stippled rectangle (8x8 stipple)
+ 2.43 1.43 1.00 1.00 2.41 10x10 stippled rectangle (8x8 stipple)
+ 0.98 1.00 1.00 1.00 1.00 100x100 stippled rectangle (8x8 stipple)
+ 1.00 1.00 1.00 1.00 0.98 500x500 stippled rectangle (8x8 stipple)
+ 1.75 1.75 1.00 1.00 3.40 1x1 opaque stippled rectangle (8x8 stipple)
+ 2.38 1.42 1.00 1.00 2.34 10x10 opaque stippled rectangle (8x8 stipple)
+ 1.00 1.00 0.97 0.97 1.00 100x100 opaque stippled rectangle (8x8 stipple)
+ 1.00 1.00 1.00 1.00 0.99 500x500 opaque stippled rectangle (8x8 stipple)
+ 1.82 1.82 1.04 1.04 3.56 1x1 tiled rectangle (4x4 tile)
+ 2.33 1.42 1.00 1.00 2.37 10x10 tiled rectangle (4x4 tile)
+ 1.00 0.92 1.00 1.00 1.00 100x100 tiled rectangle (4x4 tile)
+ 1.00 1.00 1.00 1.00 1.00 500x500 tiled rectangle (4x4 tile)
+ 1.94 1.62 1.00 1.00 3.66 1x1 stippled rectangle (17x15 stipple)
+ 1.74 1.28 1.00 1.00 1.73 10x10 stippled rectangle (17x15 stipple)
+ 1.00 1.00 1.00 0.89 0.98 100x100 stippled rectangle (17x15 stipple)
+ 1.00 1.00 1.00 1.00 0.98 500x500 stippled rectangle (17x15 stipple)
+ 1.94 1.62 1.00 1.00 3.67 1x1 opaque stippled rectangle (17x15 stipple)
+ 1.69 1.26 1.00 1.00 1.66 10x10 opaque stippled rectangle (17x15 stipple)
+ 1.00 0.95 1.00 1.00 1.00 100x100 opaque stippled rectangle (17x15 stipple)
+ 1.00 1.00 1.00 1.00 0.97 500x500 opaque stippled rectangle (17x15 stipple)
+ 1.93 1.61 0.99 0.99 3.69 1x1 tiled rectangle (17x15 tile)
+ 1.73 1.27 1.00 1.00 1.72 10x10 tiled rectangle (17x15 tile)
+ 1.00 1.00 1.00 1.00 0.98 100x100 tiled rectangle (17x15 tile)
+ 1.00 1.00 0.97 0.97 1.00 500x500 tiled rectangle (17x15 tile)
+ 1.95 1.63 1.00 1.00 3.83 1x1 stippled rectangle (161x145 stipple)
+ 1.80 1.30 1.00 1.00 1.83 10x10 stippled rectangle (161x145 stipple)
+ 0.97 1.00 1.00 1.00 1.01 100x100 stippled rectangle (161x145 stipple)
+ 1.00 1.00 1.00 1.00 0.98 500x500 stippled rectangle (161x145 stipple)
+ 1.95 1.63 1.00 1.00 3.56 1x1 opaque stippled rectangle (161x145 stipple)
+ 1.65 1.25 1.00 1.00 1.68 10x10 opaque stippled rectangle (161x145 stipple)
+ 1.00 1.00 1.00 1.00 1.01 100x100 opaque stippled rectangle (161x145...
+ 1.00 1.00 1.00 1.00 0.97 500x500 opaque stippled rectangle (161x145...
+ 1.95 1.63 0.98 0.99 3.80 1x1 tiled rectangle (161x145 tile)
+ 1.67 1.26 1.00 1.00 1.67 10x10 tiled rectangle (161x145 tile)
+ 1.13 1.14 1.14 1.14 1.14 100x100 tiled rectangle (161x145 tile)
+ 0.88 1.00 1.00 1.00 0.99 500x500 tiled rectangle (161x145 tile)
+ 1.93 1.63 1.00 1.00 3.53 1x1 tiled rectangle (216x208 tile)
+ 1.69 1.26 1.00 1.00 1.66 10x10 tiled rectangle (216x208 tile)
+ 1.00 1.00 1.00 1.00 1.00 100x100 tiled rectangle (216x208 tile)
+ 1.00 1.00 1.00 1.00 1.00 500x500 tiled rectangle (216x208 tile)
+ 1.82 1.70 1.00 1.00 3.38 1-pixel line segment
+ 2.07 1.56 0.90 1.00 3.31 10-pixel line segment
+ 1.29 1.10 1.00 1.00 1.27 100-pixel line segment
+ 1.05 1.06 1.03 1.03 1.09 500-pixel line segment
+ 1.30 1.13 1.00 1.00 1.29 100-pixel line segment (1 kid)
+ 1.32 1.15 1.00 1.00 1.32 100-pixel line segment (2 kids)
+ 1.33 1.16 1.00 1.00 1.33 100-pixel line segment (3 kids)
+ 1.92 1.64 1.00 1.00 3.73 10-pixel dashed segment
+ 1.34 1.16 1.00 1.00 1.34 100-pixel dashed segment
+ 1.24 1.11 0.99 0.97 1.23 100-pixel double-dashed segment
+ 1.72 1.77 1.00 1.00 3.25 10-pixel horizontal line segment
+ 1.83 1.66 1.01 1.00 3.54 100-pixel horizontal line segment
+ 1.86 1.30 1.00 1.00 1.84 500-pixel horizontal line segment
+ 2.11 1.52 1.00 0.99 3.02 10-pixel vertical line segment
+ 1.21 1.10 1.00 1.00 1.20 100-pixel vertical line segment
+ 1.03 1.03 1.00 1.00 1.02 500-pixel vertical line segment
+ 4.42 1.68 1.00 1.01 4.64 10x1 wide horizontal line segment
+ 1.83 1.31 1.00 1.00 1.83 100x10 wide horizontal line segment
+ 1.07 1.00 0.96 1.00 1.07 500x50 wide horizontal line segment
+ 4.10 1.67 1.00 1.00 4.62 10x1 wide vertical line segment
+ 1.50 1.24 1.06 1.06 1.48 100x10 wide vertical line segment
+ 1.06 1.03 1.00 1.00 1.05 500x50 wide vertical line segment
+ 2.54 1.61 1.00 1.00 3.61 1-pixel line
+ 2.71 1.48 1.00 1.00 2.67 10-pixel line
+ 1.19 1.09 1.00 1.00 1.19 100-pixel line
+ 1.04 1.02 1.00 1.00 1.03 500-pixel line
+ 2.68 1.51 0.98 1.00 3.17 10-pixel dashed line
+ 1.23 1.11 0.99 0.99 1.23 100-pixel dashed line
+ 1.15 1.08 1.00 1.00 1.15 100-pixel double-dashed line
+ 2.27 1.39 1.00 1.00 2.23 10x1 wide line
+ 1.20 1.09 1.00 1.00 1.20 100x10 wide line
+ 1.04 1.02 1.00 1.00 1.04 500x50 wide line
+ 1.52 1.45 1.00 1.00 1.52 100x10 wide dashed line
+ 1.54 1.47 1.00 1.00 1.54 100x10 wide double-dashed line
+ 1.97 1.30 0.96 0.95 1.95 10x10 rectangle outline
+ 1.44 1.27 1.00 1.00 1.43 100x100 rectangle outline
+ 3.22 2.16 1.10 1.09 3.61 500x500 rectangle outline
+ 1.95 1.34 1.00 1.00 1.90 10x10 wide rectangle outline
+ 1.14 1.14 1.00 1.00 1.13 100x100 wide rectangle outline
+ 1.00 1.00 1.00 1.00 1.00 500x500 wide rectangle outline
+ 1.57 1.72 1.00 1.00 3.03 1-pixel circle
+ 1.96 1.35 1.00 1.00 1.92 10-pixel circle
+ 1.21 1.07 0.86 0.97 1.20 100-pixel circle
+ 1.08 1.04 1.00 1.00 1.08 500-pixel circle
+ 1.39 1.19 1.03 1.03 1.38 100-pixel dashed circle
+ 1.21 1.11 1.00 1.00 1.23 100-pixel double-dashed circle
+ 1.59 1.28 1.00 1.00 1.58 10-pixel wide circle
+ 1.22 1.12 0.99 1.00 1.22 100-pixel wide circle
+ 1.06 1.04 1.00 1.00 1.05 500-pixel wide circle
+ 1.87 1.84 1.00 1.00 1.85 100-pixel wide dashed circle
+ 1.90 1.93 1.01 1.01 1.90 100-pixel wide double-dashed circle
+ 2.13 1.43 1.00 1.00 2.32 10-pixel partial circle
+ 1.42 1.18 1.00 1.00 1.42 100-pixel partial circle
+ 1.92 1.85 1.01 1.01 1.89 10-pixel wide partial circle
+ 1.73 1.67 1.00 1.00 1.73 100-pixel wide partial circle
+ 1.36 1.95 1.00 1.00 2.64 1-pixel solid circle
+ 2.02 1.37 1.00 1.00 2.03 10-pixel solid circle
+ 1.19 1.09 1.00 1.00 1.19 100-pixel solid circle
+ 1.02 0.99 1.00 1.00 1.01 500-pixel solid circle
+ 1.74 1.28 1.00 0.88 1.73 10-pixel fill chord partial circle
+ 1.31 1.13 1.00 1.00 1.31 100-pixel fill chord partial circle
+ 1.67 1.31 1.03 1.03 1.72 10-pixel fill slice partial circle
+ 1.30 1.13 1.00 1.00 1.28 100-pixel fill slice partial circle
+ 2.45 1.49 1.01 1.00 2.71 10-pixel ellipse
+ 1.22 1.10 1.00 1.00 1.22 100-pixel ellipse
+ 1.09 1.04 1.00 1.00 1.09 500-pixel ellipse
+ 1.90 1.28 1.00 1.00 1.89 100-pixel dashed ellipse
+ 1.62 1.24 0.96 0.97 1.61 100-pixel double-dashed ellipse
+ 2.43 1.50 1.00 1.00 2.42 10-pixel wide ellipse
+ 1.61 1.28 1.03 1.03 1.60 100-pixel wide ellipse
+ 1.08 1.05 1.00 1.00 1.08 500-pixel wide ellipse
+ 1.93 1.88 1.00 1.00 1.88 100-pixel wide dashed ellipse
+ 1.94 1.89 1.01 1.00 1.94 100-pixel wide double-dashed ellipse
+ 2.31 1.48 1.00 1.00 2.67 10-pixel partial ellipse
+ 1.38 1.17 1.00 1.00 1.38 100-pixel partial ellipse
+ 2.00 1.85 0.98 0.97 1.98 10-pixel wide partial ellipse
+ 1.89 1.86 1.00 1.00 1.89 100-pixel wide partial ellipse
+ 3.49 1.60 1.00 1.00 3.65 10-pixel filled ellipse
+ 1.67 1.26 1.00 1.00 1.67 100-pixel filled ellipse
+ 1.06 1.04 1.00 1.00 1.06 500-pixel filled ellipse
+ 2.38 1.43 1.01 1.00 2.32 10-pixel fill chord partial ellipse
+ 2.06 1.30 1.00 1.00 2.05 100-pixel fill chord partial ellipse
+ 2.27 1.41 1.00 1.00 2.27 10-pixel fill slice partial ellipse
+ 1.98 1.33 1.00 0.97 1.97 100-pixel fill slice partial ellipse
+ 57.46 1.99 1.01 1.00 114.92 Fill 1x1 equivalent triangle
+ 56.94 1.98 1.01 1.00 73.89 Fill 10x10 equivalent triangle
+ 6.07 1.75 1.00 1.00 6.07 Fill 100x100 equivalent triangle
+ 51.12 1.98 1.00 1.00 102.81 Fill 1x1 trapezoid
+ 51.42 1.82 1.01 1.00 94.89 Fill 10x10 trapezoid
+ 6.47 1.80 1.00 1.00 6.44 Fill 100x100 trapezoid
+ 1.56 1.28 1.00 0.99 1.56 Fill 300x300 trapezoid
+ 51.27 1.97 0.96 0.97 102.54 Fill 1x1 stippled trapezoid (8x8 stipple)
+ 51.73 2.00 1.02 1.02 67.92 Fill 10x10 stippled trapezoid (8x8 stipple)
+ 5.36 1.72 1.00 1.00 5.36 Fill 100x100 stippled trapezoid (8x8 stipple)
+ 1.54 1.26 1.00 1.00 1.59 Fill 300x300 stippled trapezoid (8x8 stipple)
+ 51.41 1.94 1.01 1.00 102.82 Fill 1x1 opaque stippled trapezoid (8x8 stipple)
+ 50.71 1.95 0.99 1.00 65.44 Fill 10x10 opaque stippled trapezoid (8x8...
+ 5.33 1.73 1.00 1.00 5.36 Fill 100x100 opaque stippled trapezoid (8x8...
+ 1.58 1.25 1.00 1.00 1.58 Fill 300x300 opaque stippled trapezoid (8x8...
+ 51.56 1.96 0.99 0.90 103.68 Fill 1x1 tiled trapezoid (4x4 tile)
+ 51.59 1.99 1.01 1.01 62.25 Fill 10x10 tiled trapezoid (4x4 tile)
+ 5.38 1.72 1.00 1.00 5.38 Fill 100x100 tiled trapezoid (4x4 tile)
+ 1.54 1.25 1.00 0.99 1.58 Fill 300x300 tiled trapezoid (4x4 tile)
+ 51.70 1.98 1.01 1.01 103.98 Fill 1x1 stippled trapezoid (17x15 stipple)
+ 44.86 1.97 1.00 1.00 44.86 Fill 10x10 stippled trapezoid (17x15 stipple)
+ 2.74 1.56 1.00 1.00 2.73 Fill 100x100 stippled trapezoid (17x15 stipple)
+ 1.29 1.14 1.00 1.00 1.27 Fill 300x300 stippled trapezoid (17x15 stipple)
+ 51.41 1.96 0.96 0.95 103.39 Fill 1x1 opaque stippled trapezoid (17x15...
+ 45.14 1.96 1.01 1.00 45.14 Fill 10x10 opaque stippled trapezoid (17x15...
+ 2.68 1.56 1.00 1.00 2.68 Fill 100x100 opaque stippled trapezoid (17x15...
+ 1.26 1.10 1.00 1.00 1.28 Fill 300x300 opaque stippled trapezoid (17x15...
+ 51.13 1.97 1.00 0.99 103.39 Fill 1x1 tiled trapezoid (17x15 tile)
+ 47.58 1.96 1.00 1.00 47.86 Fill 10x10 tiled trapezoid (17x15 tile)
+ 2.74 1.56 1.00 1.00 2.74 Fill 100x100 tiled trapezoid (17x15 tile)
+ 1.29 1.14 1.00 1.00 1.28 Fill 300x300 tiled trapezoid (17x15 tile)
+ 51.13 1.97 0.99 0.97 103.39 Fill 1x1 stippled trapezoid (161x145 stipple)
+ 45.14 1.97 1.00 1.00 44.29 Fill 10x10 stippled trapezoid (161x145 stipple)
+ 3.02 1.77 1.12 1.12 3.38 Fill 100x100 stippled trapezoid (161x145 stipple)
+ 1.31 1.13 1.00 1.00 1.30 Fill 300x300 stippled trapezoid (161x145 stipple)
+ 51.27 1.97 1.00 1.00 103.10 Fill 1x1 opaque stippled trapezoid (161x145...
+ 45.01 1.97 1.00 1.00 45.01 Fill 10x10 opaque stippled trapezoid (161x145...
+ 2.67 1.56 1.00 1.00 2.69 Fill 100x100 opaque stippled trapezoid (161x145..
+ 1.29 1.13 1.00 1.01 1.27 Fill 300x300 opaque stippled trapezoid (161x145..
+ 51.41 1.96 1.00 0.99 103.39 Fill 1x1 tiled trapezoid (161x145 tile)
+ 45.01 1.96 0.98 1.00 45.01 Fill 10x10 tiled trapezoid (161x145 tile)
+ 2.62 1.36 1.00 1.00 2.69 Fill 100x100 tiled trapezoid (161x145 tile)
+ 1.27 1.13 1.00 1.00 1.22 Fill 300x300 tiled trapezoid (161x145 tile)
+ 51.13 1.98 1.00 1.00 103.39 Fill 1x1 tiled trapezoid (216x208 tile)
+ 45.14 1.97 1.01 0.99 45.14 Fill 10x10 tiled trapezoid (216x208 tile)
+ 2.62 1.55 1.00 1.00 2.71 Fill 100x100 tiled trapezoid (216x208 tile)
+ 1.28 1.13 1.00 1.00 1.20 Fill 300x300 tiled trapezoid (216x208 tile)
+ 50.71 1.95 1.00 1.00 54.70 Fill 10x10 equivalent complex polygon
+ 5.51 1.71 0.96 0.98 5.47 Fill 100x100 equivalent complex polygons
+ 8.39 1.97 1.00 1.00 16.75 Fill 10x10 64-gon (Convex)
+ 8.38 1.83 1.00 1.00 8.43 Fill 100x100 64-gon (Convex)
+ 8.50 1.96 1.00 1.00 16.64 Fill 10x10 64-gon (Complex)
+ 8.26 1.83 1.00 1.00 8.35 Fill 100x100 64-gon (Complex)
+ 14.09 1.87 1.00 1.00 14.05 Char in 80-char line (6x13)
+ 11.91 1.87 1.00 1.00 11.95 Char in 70-char line (8x13)
+ 11.16 1.85 1.01 1.00 11.10 Char in 60-char line (9x15)
+ 10.09 1.78 1.00 1.00 10.09 Char16 in 40-char line (k14)
+ 6.15 1.75 1.00 1.00 6.31 Char16 in 23-char line (k24)
+ 11.92 1.90 1.03 1.03 11.88 Char in 80-char line (TR 10)
+ 8.18 1.78 1.00 0.99 8.17 Char in 30-char line (TR 24)
+ 42.83 1.44 1.01 1.00 42.11 Char in 20/40/20 line (6x13, TR 10)
+ 27.45 1.43 1.01 1.01 27.45 Char16 in 7/14/7 line (k14, k24)
+ 12.13 1.85 1.00 1.00 12.05 Char in 80-char image line (6x13)
+ 10.00 1.84 1.00 1.00 10.00 Char in 70-char image line (8x13)
+ 9.18 1.83 1.00 1.00 9.12 Char in 60-char image line (9x15)
+ 9.66 1.82 0.98 0.95 9.66 Char16 in 40-char image line (k14)
+ 5.82 1.72 1.00 1.00 5.99 Char16 in 23-char image line (k24)
+ 8.70 1.80 1.00 1.00 8.65 Char in 80-char image line (TR 10)
+ 4.67 1.66 1.00 1.00 4.67 Char in 30-char image line (TR 24)
+ 84.43 1.47 1.00 1.00 124.18 Scroll 10x10 pixels
+ 3.73 1.50 1.00 0.98 3.73 Scroll 100x100 pixels
+ 1.00 1.00 1.00 1.00 1.00 Scroll 500x500 pixels
+ 84.43 1.51 1.00 1.00 134.02 Copy 10x10 from window to window
+ 3.62 1.51 0.98 0.98 3.62 Copy 100x100 from window to window
+ 0.89 1.00 1.00 1.00 1.00 Copy 500x500 from window to window
+ 57.06 1.99 1.00 1.00 88.64 Copy 10x10 from pixmap to window
+ 2.49 2.00 1.00 1.00 2.48 Copy 100x100 from pixmap to window
+ 1.00 0.91 1.00 1.00 0.98 Copy 500x500 from pixmap to window
+ 2.04 1.01 1.00 1.00 2.03 Copy 10x10 from window to pixmap
+ 1.05 1.00 1.00 1.00 1.05 Copy 100x100 from window to pixmap
+ 1.00 1.00 0.93 1.00 1.04 Copy 500x500 from window to pixmap
+ 58.52 1.03 1.03 1.02 57.95 Copy 10x10 from pixmap to pixmap
+ 2.40 1.00 1.00 1.00 2.45 Copy 100x100 from pixmap to pixmap
+ 1.00 1.00 1.00 1.00 1.00 Copy 500x500 from pixmap to pixmap
+ 51.57 1.92 1.00 1.00 85.75 Copy 10x10 1-bit deep plane
+ 6.37 1.75 1.01 1.01 6.37 Copy 100x100 1-bit deep plane
+ 1.26 1.11 1.00 1.00 1.24 Copy 500x500 1-bit deep plane
+ 4.23 1.63 0.98 0.97 4.38 Copy 10x10 n-bit deep plane
+ 1.04 1.02 1.00 1.00 1.04 Copy 100x100 n-bit deep plane
+ 1.00 1.00 1.00 1.00 1.00 Copy 500x500 n-bit deep plane
+ 6.45 1.98 1.00 1.26 12.80 PutImage 10x10 square
+ 1.10 1.87 1.00 1.83 2.11 PutImage 100x100 square
+ 1.02 1.93 1.00 1.91 1.91 PutImage 500x500 square
+ 4.17 1.78 1.00 1.40 7.18 PutImage XY 10x10 square
+ 1.27 1.49 0.97 1.48 2.10 PutImage XY 100x100 square
+ 1.00 1.50 1.00 1.50 1.52 PutImage XY 500x500 square
+ 1.07 1.01 1.00 1.00 1.06 GetImage 10x10 square
+ 1.01 1.00 1.00 1.00 1.01 GetImage 100x100 square
+ 1.00 1.00 1.00 1.00 1.00 GetImage 500x500 square
+ 1.56 1.00 0.99 0.97 1.56 GetImage XY 10x10 square
+ 1.02 1.00 1.00 1.00 1.02 GetImage XY 100x100 square
+ 1.00 1.00 1.00 1.00 1.00 GetImage XY 500x500 square
+ 1.00 1.00 1.01 0.98 0.95 X protocol NoOperation
+ 1.02 1.03 1.04 1.03 1.00 QueryPointer
+ 1.03 1.02 1.04 1.03 1.00 GetProperty
+100.41 1.51 1.00 1.00 198.76 Change graphics context
+ 45.81 1.00 0.99 0.97 57.10 Create and map subwindows (4 kids)
+ 78.45 1.01 1.02 1.02 63.07 Create and map subwindows (16 kids)
+ 73.91 1.01 1.00 1.00 56.37 Create and map subwindows (25 kids)
+ 73.22 1.00 1.00 1.00 49.07 Create and map subwindows (50 kids)
+ 72.36 1.01 0.99 1.00 32.14 Create and map subwindows (75 kids)
+ 70.34 1.00 1.00 1.00 30.12 Create and map subwindows (100 kids)
+ 55.00 1.00 1.00 0.99 23.75 Create and map subwindows (200 kids)
+ 55.30 1.01 1.00 1.00 141.03 Create unmapped window (4 kids)
+ 55.38 1.01 1.01 1.00 163.25 Create unmapped window (16 kids)
+ 54.75 0.96 1.00 0.99 166.95 Create unmapped window (25 kids)
+ 54.83 1.00 1.00 0.99 178.81 Create unmapped window (50 kids)
+ 55.38 1.01 1.01 1.00 181.20 Create unmapped window (75 kids)
+ 55.38 1.01 1.01 1.00 181.20 Create unmapped window (100 kids)
+ 54.87 1.01 1.01 1.00 182.05 Create unmapped window (200 kids)
+ 28.13 1.00 1.00 1.00 30.75 Map window via parent (4 kids)
+ 36.14 1.01 1.01 1.01 32.58 Map window via parent (16 kids)
+ 26.13 1.00 0.98 0.95 29.85 Map window via parent (25 kids)
+ 40.07 1.00 1.01 1.00 27.57 Map window via parent (50 kids)
+ 23.26 0.99 1.00 1.00 18.23 Map window via parent (75 kids)
+ 22.91 0.99 1.00 0.99 16.52 Map window via parent (100 kids)
+ 27.79 1.00 1.00 0.99 12.50 Map window via parent (200 kids)
+ 22.35 1.00 1.00 1.00 56.19 Unmap window via parent (4 kids)
+ 9.57 1.00 0.99 1.00 89.78 Unmap window via parent (16 kids)
+ 80.77 1.01 1.00 1.00 103.85 Unmap window via parent (25 kids)
+ 96.34 1.00 1.00 1.00 116.06 Unmap window via parent (50 kids)
+ 99.72 1.00 1.00 1.00 124.93 Unmap window via parent (75 kids)
+112.36 1.00 1.00 1.00 125.27 Unmap window via parent (100 kids)
+105.41 1.00 1.00 0.99 120.00 Unmap window via parent (200 kids)
+ 51.29 1.03 1.02 1.02 74.19 Destroy window via parent (4 kids)
+ 86.75 0.99 0.99 0.99 116.87 Destroy window via parent (16 kids)
+106.43 1.01 1.01 1.01 127.49 Destroy window via parent (25 kids)
+120.34 1.01 1.01 1.00 140.11 Destroy window via parent (50 kids)
+126.67 1.00 0.99 0.99 145.00 Destroy window via parent (75 kids)
+126.11 1.01 1.01 1.00 140.56 Destroy window via parent (100 kids)
+128.57 1.01 1.00 1.00 137.91 Destroy window via parent (200 kids)
+ 16.04 0.88 1.00 1.00 20.36 Hide/expose window via popup (4 kids)
+ 19.04 1.01 1.00 1.00 23.48 Hide/expose window via popup (16 kids)
+ 19.22 1.00 1.00 1.00 20.44 Hide/expose window via popup (25 kids)
+ 17.41 1.00 0.91 0.97 17.68 Hide/expose window via popup (50 kids)
+ 17.29 1.01 1.00 1.01 17.07 Hide/expose window via popup (75 kids)
+ 16.74 1.00 1.00 1.00 16.17 Hide/expose window via popup (100 kids)
+ 10.30 1.00 1.00 1.00 10.51 Hide/expose window via popup (200 kids)
+ 16.48 1.01 1.00 1.00 26.05 Move window (4 kids)
+ 17.01 0.95 1.00 1.00 23.97 Move window (16 kids)
+ 16.95 1.00 1.00 1.00 22.90 Move window (25 kids)
+ 16.05 1.01 1.00 1.00 21.32 Move window (50 kids)
+ 15.58 1.00 0.98 0.98 19.44 Move window (75 kids)
+ 14.98 1.02 1.03 1.03 18.17 Move window (100 kids)
+ 10.90 1.01 1.01 1.00 12.68 Move window (200 kids)
+ 49.42 1.00 1.00 1.00 198.27 Moved unmapped window (4 kids)
+ 50.72 0.97 1.00 1.00 193.66 Moved unmapped window (16 kids)
+ 50.87 1.00 0.99 1.00 195.09 Moved unmapped window (25 kids)
+ 50.72 1.00 1.00 1.00 189.34 Moved unmapped window (50 kids)
+ 50.87 1.00 1.00 1.00 191.33 Moved unmapped window (75 kids)
+ 50.87 1.00 1.00 0.90 186.71 Moved unmapped window (100 kids)
+ 50.87 1.00 1.00 1.00 179.19 Moved unmapped window (200 kids)
+ 41.04 1.00 1.00 1.00 56.61 Move window via parent (4 kids)
+ 69.81 1.00 1.00 1.00 130.82 Move window via parent (16 kids)
+ 95.81 1.00 1.00 1.00 141.92 Move window via parent (25 kids)
+ 95.98 1.00 1.00 1.00 149.43 Move window via parent (50 kids)
+ 96.59 1.01 1.01 1.00 153.98 Move window via parent (75 kids)
+ 97.19 1.00 1.00 1.00 157.30 Move window via parent (100 kids)
+ 96.67 1.00 0.99 0.96 159.44 Move window via parent (200 kids)
+ 17.75 1.01 1.00 1.00 27.61 Resize window (4 kids)
+ 17.94 1.00 1.00 0.99 25.42 Resize window (16 kids)
+ 17.92 1.01 1.00 1.00 24.47 Resize window (25 kids)
+ 17.24 0.97 1.00 1.00 24.14 Resize window (50 kids)
+ 16.81 1.00 1.00 0.99 22.75 Resize window (75 kids)
+ 16.08 1.00 1.00 1.00 21.20 Resize window (100 kids)
+ 12.92 1.00 0.99 1.00 16.26 Resize window (200 kids)
+ 52.94 1.01 1.00 1.00 327.12 Resize unmapped window (4 kids)
+ 53.60 1.01 1.01 1.01 333.71 Resize unmapped window (16 kids)
+ 52.99 1.00 1.00 1.00 337.29 Resize unmapped window (25 kids)
+ 51.98 1.00 1.00 1.00 329.38 Resize unmapped window (50 kids)
+ 53.05 0.89 1.00 1.00 322.60 Resize unmapped window (75 kids)
+ 53.05 1.00 1.00 1.00 318.08 Resize unmapped window (100 kids)
+ 53.11 1.00 1.00 0.99 306.21 Resize unmapped window (200 kids)
+ 16.76 1.00 0.96 1.00 19.46 Circulate window (4 kids)
+ 17.24 1.00 1.00 0.97 16.24 Circulate window (16 kids)
+ 16.30 1.03 1.03 1.03 15.85 Circulate window (25 kids)
+ 13.45 1.00 1.00 1.00 14.90 Circulate window (50 kids)
+ 12.91 1.00 1.00 1.00 13.06 Circulate window (75 kids)
+ 11.30 0.98 1.00 1.00 11.03 Circulate window (100 kids)
+ 7.58 1.01 1.01 0.99 7.47 Circulate window (200 kids)
+ 1.01 1.01 0.98 1.00 0.95 Circulate Unmapped window (4 kids)
+ 1.07 1.07 1.01 1.07 1.02 Circulate Unmapped window (16 kids)
+ 1.04 1.09 1.06 1.05 0.97 Circulate Unmapped window (25 kids)
+ 1.04 1.23 1.20 1.18 1.05 Circulate Unmapped window (50 kids)
+ 1.18 1.53 1.19 1.45 1.24 Circulate Unmapped window (75 kids)
+ 1.08 1.02 1.01 1.74 1.01 Circulate Unmapped window (100 kids)
+ 1.01 1.12 0.98 0.91 0.97 Circulate Unmapped window (200 kids)
+ </verb>
+
+<sect2>Profiling with OProfile
+
+<p>OProfile (available from http://oprofile.sourceforge.net/) is a
+system-wide profiler for Linux systems that uses processor-level
+counters to collect sampling data. OProfile can provide information
+that is similar to that provided by <tt/gprof/, but without the
+necessity of recompiling the program with special instrumentation (i.e.,
+OProfile can collect statistical profiling information about optimized
+programs). A test harness was developed to collect OProfile data for
+each <tt/x11perf/ test individually.
+
+<p>Test runs were performed using the RETIRED_INSNS counter on the AMD
+Athlon and the CPU_CLK_HALTED counter on the Intel Pentium III (with a
+test configuration different from the one described above). We have
+examined OProfile output and have compared it with <tt/gprof/ output.
+This investigation has not produced results that yield performance
+increases in <tt/x11perf/ numbers.
+
+<!--
+<sect3>Retired Instructions
+
+<p>The initial tests using OProfile were done using the RETIRED_INSNS
+counter with DMX running on the dual-processor AMD Athlon machine - the
+same test configuration that was described above and that was used for
+other tests. The RETIRED_INSNS counter counts retired instructions and
+showed drawing, text, copying, and image tests to be dominated (&gt;
+30%) by calls to Hash(), SecurityLookupIDByClass(),
+SecurityLookupIDByType(), and StandardReadRequestFromClient(). Some of
+these tests also executed significant instructions in
+WaitForSomething().
+
+<p>In contrast, the window tests executed significant
+instructions in SecurityLookupIDByType(), Hash(),
+StandardReadRequestFromClient(), but also executed significant
+instructions in other routines, such as ConfigureWindow(). Some time
+was spent looking at Hash() function, but optimizations in this routine
+did not lead to a dramatic increase in <tt/x11perf/ performance.
+-->
+
+<!--
+<sect3>Clock Cycles
+
+<p>Retired instructions can be misleading because Intel/AMD instructions
+execute in variable amounts of time. The OProfile tests were repeated
+using the Intel CPU_CLK_HALTED counter with DMX running on the second
+back-end machine. Note that this is a different test configuration that
+the one described above. However, these tests show the amount of time
+(as measured in CPU cycles) that are spent in each routine. Because
+<tt/x11perf/ was running on the first back-end machine and because
+window optimizations were on, the load on the second back-end machine
+was not significant.
+
+<p>Using CPU_CLK_HALTED, DMX showed simple drawing
+tests spending more than 10% of their time in
+StandardReadRequestFromClient(), with significant time (&gt; 20% total)
+spent in SecurityLookupIDByClass(), WaitForSomething(), and Dispatch().
+For these tests, &lt; 5% of the time was spent in Hash(), which explains
+why optimizing the Hash() routine did not impact <tt/x11perf/ results.
+
+<p>The trapezoid, text, scrolling, copying, and image tests were
+dominated by time in ProcFillPoly(), PanoramiXFillPoly(), dmxFillPolygon(),
+SecurityLookupIDByClass(), SecurityLookupIDByType(), and
+StandardReadRequestFromClient(). Hash() time was generally above 5% but
+less than 10% of total time.
+-->
+
+<sect2>X Test Suite
+
+<p>The X Test Suite was run on the fully optimized DMX server using the
+configuration described above. The following failures were noted:
+ <verb>
+XListPixmapFormats: Test 1 [1]
+XChangeWindowAttributes: Test 32 [1]
+XCreateWindow: Test 30 [1]
+XFreeColors: Test 4 [3]
+XCopyArea: Test 13, 17, 21, 25, 30 [2]
+XCopyPlane: Test 11, 15, 27, 31 [2]
+XSetFontPath: Test 4 [1]
+XChangeKeyboardControl: Test 9, 10 [1]
+
+[1] Previously documented errors expected from the Xinerama
+ implementation (see Phase I discussion).
+[2] Newly noted errors that have been verified as expected
+ behavior of the Xinerama implementation.
+[3] Newly noted error that has been verified as a Xinerama
+ implementation bug.
+ </verb>
+
+<!-- ============================================================ -->
+<sect1>Phase III
+
+<p>During the third phase of development, support was provided for the
+following extensions: SHAPE, RENDER, XKEYBOARD, XInput.
+
+<sect2>SHAPE
+
+<p>The SHAPE extension is supported. Test applications (e.g., xeyes and
+oclock) and window managers that make use of the SHAPE extension will
+work as expected.
+
+<sect2>RENDER
+
+<p>The RENDER extension is supported. The version included in the DMX
+CVS tree is version 0.2, and this version is fully supported by Xdmx.
+Applications using only version 0.2 functions will work correctly;
+however, some apps that make use of functions from later versions do not
+properly check the extension's major/minor version numbers. These apps
+will fail with a Bad Implementation error when using post-version 0.2
+functions. This is expected behavior. When the DMX CVS tree is updated
+to include newer versions of RENDER, support for these newer functions
+will be added to the DMX X server.
+
+<sect2>XKEYBOARD
+
+<p>The XKEYBOARD extension is supported. If present on the back-end X
+servers, the XKEYBOARD extension will be used to obtain information
+about the type of the keyboard for initialization. Otherwise, the
+keyboard will be initialized using defaults. Note that this departs
+from older behavior: when Xdmx is compiled without XKEYBOARD support,
+the map from the back-end X server will be preserved. With XKEYBOARD
+support, the map is not preserved because better information and control
+of the keyboard is available.
+
+<sect2>XInput
+
+<p>The XInput extension is supported. Any device can be used as a core
+device and be used as an XInput extension device, with the exception of
+core devices on the back-end servers. This limitation is present
+because cursor handling on the back-end requires that the back-end
+cursor sometimes track the Xdmx core cursor -- behavior that is
+incompatible with using the back-end pointer as a non-core device.
+
+<p>Currently, back-end extension devices are not available as Xdmx
+extension devices, but this limitation should be removed in the future.
+
+<p>To demonstrate the XInput extension, and to provide more examples for
+low-level input device driver writers, USB device drivers have been
+written for mice (usb-mou), keyboards (usb-kbd), and
+non-mouse/non-keyboard USB devices (usb-oth). Please see the man page
+for information on Linux kernel drivers that are required for using
+these Xdmx drivers.
+
+<sect2>DPMS
+
+<p>The DPMS extension is exported but does not do anything at this time.
+
+<sect2>Other Extensions
+
+<p>The LBX,
+ SECURITY,
+ XC-APPGROUP, and
+ XFree86-Bigfont
+extensions do not require any special Xdmx support and have been exported.
+
+<p>The
+ BIG-REQUESTS,
+ DEC-XTRAP,
+ DOUBLE-BUFFER,
+ Extended-Visual-Information,
+ FontCache,
+ GLX,
+ MIT-SCREEN-SAVER,
+ MIT-SHM,
+ MIT-SUNDRY-NONSTANDARD,
+ RECORD,
+ SECURITY,
+ SGI-GLX,
+ SYNC,
+ TOG-CUP,
+ X-Resource,
+ XC-MISC,
+ XFree86-DGA,
+ XFree86-DRI,
+ XFree86-Misc,
+ XFree86-VidModeExtension, and
+ XVideo
+extensions are <it/not/ supported at this time, but will be evaluated
+for inclusion in future DMX releases. <bf>See below for additional work
+on extensions after Phase III.</bf>
+
+<sect1>Phase IV
+
+<sect2>Moving to XFree86 4.3.0
+
+<p>For Phase IV, the recent release of XFree86 4.3.0 (27 February 2003)
+was merged onto the dmx.sourceforge.net CVS trunk and all work is
+proceeding using this tree.
+
+<sect2>Extensions
+
+<sect3>XC-MISC (supported)
+
+<p>XC-MISC is used internally by the X library to recycle XIDs from the
+X server. This is important for long-running X server sessions. Xdmx
+supports this extension. The X Test Suite passed and failed the exact
+same tests before and after this extension was enabled.
+<!-- Tested February/March 2003 -->
+
+<sect3>Extended-Visual-Information (supported)
+
+<p>The Extended-Visual-Information extension provides a method for an X
+client to obtain detailed visual information. Xdmx supports this
+extension. It was tested using the <tt>hw/dmx/examples/evi</tt> example
+program. <bf/Note that this extension is not Xinerama-aware/ -- it will
+return visual information for each screen even though Xinerama is
+causing the X server to export a single logical screen.
+<!-- Tested March 2003 -->
+
+<sect3>RES (supported)
+
+<p>The X-Resource extension provides a mechanism for a client to obtain
+detailed information about the resources used by other clients. This
+extension was tested with the <tt>hw/dmx/examples/res</tt> program. The
+X Test Suite passed and failed the exact same tests before and after
+this extension was enabled.
+<!-- Tested March 2003 -->
+
+<sect3>BIG-REQUESTS (supported)
+
+<p>This extension enables the X11 protocol to handle requests longer
+than 262140 bytes. The X Test Suite passed and failed the exact same
+tests before and after this extension was enabled.
+<!-- Tested March 2003 -->
+
+<sect3>XSYNC (supported)
+
+<p>This extension provides facilities for two different X clients to
+synchronize their requests. This extension was minimally tested with
+<tt/xdpyinfo/ and the X Test Suite passed and failed the exact same
+tests before and after this extension was enabled.
+<!-- Tested March 2003 -->
+
+<sect3>XTEST, RECORD, DEC-XTRAP (supported) and XTestExtension1 (not supported)
+
+<p>The XTEST and RECORD extension were developed by the X Consortium for
+use in the X Test Suite and are supported as a standard in the X11R6
+tree. They are also supported in Xdmx. When X Test Suite tests that
+make use of the XTEST extension are run, Xdmx passes and fails exactly
+the same tests as does a standard XFree86 X server. When the
+<tt/rcrdtest/ test (a part of the X Test Suite that verifies the RECORD
+extension) is run, Xdmx passes and fails exactly the same tests as does
+a standard XFree86 X server. <!-- Tested February/March 2003 -->
+
+<p>There are two older XTEST-like extensions: DEC-XTRAP and
+XTestExtension1. The XTestExtension1 extension was developed for use by
+the X Testing Consortium for use with a test suite that eventually
+became (part of?) the X Test Suite. Unlike XTEST, which only allows
+events to be sent to the server, the XTestExtension1 extension also
+allowed events to be recorded (similar to the RECORD extension). The
+second is the DEC-XTRAP extension that was developed by the Digital
+Equipment Corporation.
+
+<p>The DEC-XTRAP extension is available from Xdmx and has been tested
+with the <tt/xtrap*/ tools which are distributed as standard X11R6
+clients. <!-- Tested March 2003 -->
+
+<p>The XTestExtension1 is <em/not/ supported because it does not appear
+to be used by any modern X clients (the few that support it also support
+XTEST) and because there are no good methods available for testing that
+it functions correctly (unlike XTEST and DEC-XTRAP, the code for
+XTestExtension1 is not part of the standard X server source tree, so
+additional testing is important). <!-- Tested March 2003 -->
+
+<p>Most of these extensions are documented in the X11R6 source tree.
+Further, several original papers exist that this author was unable to
+locate -- for completeness and historical interest, citations are
+provide:
+<descrip>
+<tag/XRECORD/ Martha Zimet. Extending X For Recording. 8th Annual X
+Technical Conference Boston, MA January 24-26, 1994.
+<tag/DEC-XTRAP/ Dick Annicchiarico, Robert Chesler, Alan Jamison. XTrap
+Architecture. Digital Equipment Corporation, July 1991.
+<tag/XTestExtension1/ Larry Woestman. X11 Input Synthesis Extension
+Proposal. Hewlett Packard, November 1991.
+</descrip>
+
+<sect3>MIT-MISC (not supported)
+
+<p>The MIT-MISC extension is used to control a bug-compatibility flag
+that provides compatibility with xterm programs from X11R1 and X11R2.
+There does not appear to be a single client available that makes use of
+this extension and there is not way to verify that it works correctly.
+The Xdmx server does <em/not/ support MIT-MISC.
+
+<sect3>SCREENSAVER (not supported)
+
+<p>This extension provides special support for the X screen saver. It
+was tested with beforelight, which appears to be the only client that
+works with it. When Xinerama was not active, <tt/beforelight/ behaved
+as expected. However, when Xinerama was active, <tt/beforelight/ did
+not behave as expected. Further, when this extension is not active,
+<tt/xscreensaver/ (a widely-used X screen saver program) did not behave
+as expected. Since this extension is not Xinerama-aware and is not
+commonly used with expected results by clients, we have left this
+extension disabled at this time.
+
+<sect3>GLX (supported)
+
+<p>The GLX extension provides OpenGL and GLX windowing support. In
+Xdmx, the extension is called glxProxy, and it is Xinerama aware. It
+works by either feeding requests forward through Xdmx to each of the
+back-end servers or handling them locally. All rendering requests are
+handled on the back-end X servers. This code was donated to the DMX
+project by SGI. For the X Test Suite results comparison, see below.
+
+<sect3>RENDER (supported)
+
+<p>The X Rendering Extension (RENDER) provides support for digital image
+composition. Geometric and text rendering are supported. RENDER is
+partially Xinerama-aware, with text and the most basic compositing
+operator; however, its higher level primitives (triangles, triangle
+strips, and triangle fans) are not yet Xinerama-aware. The RENDER
+extension is still under development, and is currently at version 0.8.
+Additional support will be required in DMX as more primitives and/or
+requests are added to the extension.
+
+<p>There is currently no test suite for the X Rendering Extension;
+however, there has been discussion of developing a test suite as the
+extension matures. When that test suite becomes available, additional
+testing can be performed with Xdmx. The X Test Suite passed and failed
+the exact same tests before and after this extension was enabled.
+
+<sect3>Summary
+
+<!-- WARNING: this list is duplicated in the "Common X extension
+support" section -->
+<p>To summarize, the following extensions are currently supported:
+ BIG-REQUESTS,
+ DEC-XTRAP,
+ DMX,
+ DPMS,
+ Extended-Visual-Information,
+ GLX,
+ LBX,
+ RECORD,
+ RENDER,
+ SECURITY,
+ SHAPE,
+ SYNC,
+ X-Resource,
+ XC-APPGROUP,
+ XC-MISC,
+ XFree86-Bigfont,
+ XINERAMA,
+ XInputExtension,
+ XKEYBOARD, and
+ XTEST.
+
+<p>The following extensions are <em/not/ supported at this time:
+ DOUBLE-BUFFER,
+ FontCache,
+ MIT-SCREEN-SAVER,
+ MIT-SHM,
+ MIT-SUNDRY-NONSTANDARD,
+ TOG-CUP,
+ XFree86-DGA,
+ XFree86-Misc,
+ XFree86-VidModeExtension,
+ XTestExtensionExt1, and
+ XVideo.
+
+<sect2>Additional Testing with the X Test Suite
+
+<sect3>XFree86 without XTEST
+
+<p>After the release of XFree86 4.3.0, we retested the XFree86 X server
+with and without using the XTEST extension. When the XTEST extension
+was <em/not/ used for testing, the XFree86 4.3.0 server running on our
+usual test system with a Radeon VE card reported unexpected failures in
+the following tests:
+<verb>
+XListPixmapFormats: Test 1
+XChangeKeyboardControl: Tests 9, 10
+XGetDefault: Test 5
+XRebindKeysym: Test 1
+</verb>
+
+<sect3>XFree86 with XTEST
+
+<p>When using the XTEST extension, the XFree86 4.3.0 server reported the
+following errors:
+<verb>
+XListPixmapFormats: Test 1
+XChangeKeyboardControl: Tests 9, 10
+XGetDefault: Test 5
+XRebindKeysym: Test 1
+
+XAllowEvents: Tests 20, 21, 24
+XGrabButton: Tests 5, 9-12, 14, 16, 19, 21-25
+XGrabKey: Test 8
+XSetPointerMapping: Test 3
+XUngrabButton: Test 4
+</verb>
+
+<p>While these errors may be important, they will probably be fixed
+eventually in the XFree86 source tree. We are particularly interested
+in demonstrating that the Xdmx server does not introduce additional
+failures that are not known Xinerama failures.
+
+<sect3>Xdmx with XTEST, without Xinerama, without GLX
+
+<p>Without Xinerama, but using the XTEST extension, the following errors
+were reported from Xdmx (note that these are the same as for the XFree86
+4.3.0, except that XGetDefault no longer fails):
+<verb>
+XListPixmapFormats: Test 1
+XChangeKeyboardControl: Tests 9, 10
+XRebindKeysym: Test 1
+
+XAllowEvents: Tests 20, 21, 24
+XGrabButton: Tests 5, 9-12, 14, 16, 19, 21-25
+XGrabKey: Test 8
+XSetPointerMapping: Test 3
+XUngrabButton: Test 4
+</verb>
+
+<sect3>Xdmx with XTEST, with Xinerama, without GLX
+
+<p>With Xinerama, using the XTEST extension, the following errors
+were reported from Xdmx:
+<verb>
+XListPixmapFormats: Test 1
+XChangeKeyboardControl: Tests 9, 10
+XRebindKeysym: Test 1
+
+XAllowEvents: Tests 20, 21, 24
+XGrabButton: Tests 5, 9-12, 14, 16, 19, 21-25
+XGrabKey: Test 8
+XSetPointerMapping: Test 3
+XUngrabButton: Test 4
+
+XCopyPlane: Tests 13, 22, 31 (well-known XTEST/Xinerama interaction issue)
+XDrawLine: Test 67
+XDrawLines: Test 91
+XDrawSegments: Test 68
+</verb>
+Note that the first two sets of errors are the same as for the XFree86
+4.3.0 server, and that the XCopyPlane error is a well-known error
+resulting from an XTEST/Xinerama interaction when the request crosses a
+screen boundary. The XDraw* errors are resolved when the tests are run
+individually and they do not cross a screen boundary. We will
+investigate these errors further to determine their cause.
+
+<sect3>Xdmx with XTEST, with Xinerama, with GLX
+
+<p>With GLX enabled, using the XTEST extension, the following errors
+were reported from Xdmx (these results are from early during the Phase
+IV development, but were confirmed with a late Phase IV snapshot):
+<verb>
+XListPixmapFormats: Test 1
+XChangeKeyboardControl: Tests 9, 10
+XRebindKeysym: Test 1
+
+XAllowEvents: Tests 20, 21, 24
+XGrabButton: Tests 5, 9-12, 14, 16, 19, 21-25
+XGrabKey: Test 8
+XSetPointerMapping: Test 3
+XUngrabButton: Test 4
+
+XClearArea: Test 8
+XCopyArea: Tests 4, 5, 11, 14, 17, 23, 25, 27, 30
+XCopyPlane: Tests 6, 7, 10, 19, 22, 31
+XDrawArcs: Tests 89, 100, 102
+XDrawLine: Test 67
+XDrawSegments: Test 68
+</verb>
+Note that the first two sets of errors are the same as for the XFree86
+4.3.0 server, and that the third set has different failures than when
+Xdmx does not include GLX support. Since the GLX extension adds new
+visuals to support GLX's visual configs and the X Test Suite runs tests
+over the entire set of visuals, additional rendering tests were run and
+presumably more of them crossed a screen boundary. This conclusion is
+supported by the fact that nearly all of the rendering errors reported
+are resolved when the tests are run individually and they do no cross a
+screen boundary.
+
+<p>Further, when hardware rendering is disabled on the back-end displays,
+many of the errors in the third set are eliminated, leaving only:
+<verb>
+XClearArea: Test 8
+XCopyArea: Test 4, 5, 11, 14, 17, 23, 25, 27, 30
+XCopyPlane: Test 6, 7, 10, 19, 22, 31
+</verb>
+
+<sect3>Conclusion
+
+<p>We conclude that all of the X Test Suite errors reported for Xdmx are
+the result of errors in the back-end X server or the Xinerama
+implementation. Further, all of these errors that can be reasonably
+fixed at the Xdmx layer have been. (Where appropriate, we have
+submitted patches to the XFree86 and Xinerama upstream maintainers.)
+
+<sect2>Dynamic Reconfiguration
+
+<p>During this development phase, dynamic reconfiguration support was
+added to DMX. This support allows an application to change the position
+and offset of a back-end server's screen. For example, if the
+application would like to shift a screen slightly to the left, it could
+query Xdmx for the screen's &lt;x,y&gt; position and then dynamically
+reconfigure that screen to be at position &lt;x+10,y&gt;. When a screen
+is dynamically reconfigured, input handling and a screen's root window
+dimensions are adjusted as needed. These adjustments are transparent to
+the user.
+
+<sect3>Dynamic reconfiguration extension
+
+<p>The application interface to DMX's dynamic reconfiguration is through
+a function in the DMX extension library:
+<verb>
+Bool DMXReconfigureScreen(Display *dpy, int screen, int x, int y)
+</verb>
+where <it/dpy/ is DMX server's display, <it/screen/ is the number of the
+screen to be reconfigured, and <it/x/ and <it/y/ are the new upper,
+left-hand coordinates of the screen to be reconfigured.
+
+<p>The coordinates are not limited other than as required by the X
+protocol, which limits all coordinates to a signed 16 bit number. In
+addition, all coordinates within a screen must also be legal values.
+Therefore, setting a screen's upper, left-hand coordinates such that the
+right or bottom edges of the screen is greater than 32,767 is illegal.
+
+<sect3>Bounding box
+
+<p>When the Xdmx server is started, a bounding box is calculated from
+the screens' layout given either on the command line or in the
+configuration file. This bounding box is currently fixed for the
+lifetime of the Xdmx server.
+
+<p>While it is possible to move a screen outside of the bounding box, it
+is currently not possible to change the dimensions of the bounding box.
+For example, it is possible to specify coordinates of &lt;-100,-100&gt;
+for the upper, left-hand corner of the bounding box, which was
+previously at coordinates &lt;0,0&gt;. As expected, the screen is moved
+down and to the right; however, since the bounding box is fixed, the
+left side and upper portions of the screen exposed by the
+reconfiguration are no longer accessible on that screen. Those
+inaccessible regions are filled with black.
+
+<p>This fixed bounding box limitation will be addressed in a future
+development phase.
+
+<sect3>Sample applications
+
+<p>An example of where this extension is useful is in setting up a video
+wall. It is not always possible to get everything perfectly aligned,
+and sometimes the positions are changed (e.g., someone might bump into a
+projector). Instead of physically moving projectors or monitors, it is
+now possible to adjust the positions of the back-end server's screens
+using the dynamic reconfiguration support in DMX.
+
+<p>Other applications, such as automatic setup and calibration tools,
+can make use of dynamic reconfiguration to correct for projector
+alignment problems, as long as the projectors are still arranged
+rectilinearly. Horizontal and vertical keystone correction could be
+applied to projectors to correct for non-rectilinear alignment problems;
+however, this must be done external to Xdmx.
+
+<p>A sample test program is included in the DMX server's examples
+directory to demonstrate the interface and how an application might use
+dynamic reconfiguration. See <tt/dmxreconfig.c/ for details.
+
+<sect3>Additional notes
+
+<p>In the original development plan, Phase IV was primarily devoted to
+adding OpenGL support to DMX; however, SGI became interested in the DMX
+project and developed code to support OpenGL/GLX. This code was later
+donated to the DMX project and integrated into the DMX code base, which
+freed the DMX developers to concentrate on dynamic reconfiguration (as
+described above).
+
+<sect2>Doxygen documentation
+
+<p>Doxygen is an open-source (GPL) documentation system for generating
+browseable documentation from stylized comments in the source code. We
+have placed all of the Xdmx server and DMX protocol source code files
+under Doxygen so that comprehensive documentation for the Xdmx source
+code is available in an easily browseable format.
+
+<sect2>Valgrind
+
+<p>Valgrind, an open-source (GPL) memory debugger for Linux, was used to
+search for memory management errors. Several memory leaks were detected
+and repaired. The following errors were not addressed:
+<enum>
+ <item>
+ When the X11 transport layer sends a reply to the client, only
+ those fields that are required by the protocol are filled in --
+ unused fields are left as uninitialized memory and are therefore
+ noted by valgrind. These instances are not errors and were not
+ repaired.
+ <item>
+ At each server generation, glxInitVisuals allocates memory that
+ is never freed. The amount of memory lost each generation
+ approximately equal to 128 bytes for each back-end visual.
+ Because the code involved is automatically generated, this bug
+ has not been fixed and will be referred to SGI.
+ <item>
+ At each server generation, dmxRealizeFont calls XLoadQueryFont,
+ which allocates a font structure that is not freed.
+ dmxUnrealizeFont can free the font structure for the first
+ screen, but cannot free it for the other screens since they are
+ already closed by the time dmxUnrealizeFont could free them.
+ The amount of memory lost each generation is approximately equal
+ to 80 bytes per font per back-end. When this bug is fixed in
+ the the X server's device-independent (dix) code, DMX will be
+ able to properly free the memory allocated by XLoadQueryFont.
+</enum>
+
+<sect2>RATS
+
+<p>RATS (Rough Auditing Tool for Security) is an open-source (GPL)
+security analysis tool that scans source code for common
+security-related programming errors (e.g., buffer overflows and TOCTOU
+races). RATS was used to audit all of the code in the hw/dmx directory
+and all "High" notations were checked manually. The code was either
+re-written to eliminate the warning, or a comment containing "RATS" was
+inserted on the line to indicate that a human had checked the code.
+Unrepaired warnings are as follows:
+<enum>
+ <item>
+ Fixed-size buffers are used in many areas, but code has been
+ added to protect against buffer overflows (e.g., XmuSnprint).
+ The only instances that have not yet been fixed are in
+ config/xdmxconfig.c (which is not part of the Xdmx server) and
+ input/usb-common.c.
+ <item>
+ vprintf and vfprintf are used in the logging routines. In
+ general, all uses of these functions (e.g., dmxLog) provide a
+ constant format string from a trusted source, so the use is
+ relatively benign.
+ <item>
+ glxProxy/glxscreens.c uses getenv and strcat. The use of these
+ functions is safe and will remain safe as long as
+ ExtensionsString is longer then GLXServerExtensions (ensuring
+ this may not be ovious to the casual programmer, but this is in
+ automatically generated code, so we hope that the generator
+ enforces this constraint).
+</enum>
+
+ </article>
+
+ <!-- Local Variables: -->
+ <!-- fill-column: 72 -->
+ <!-- End: -->
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/dmx.txt b/nx-X11/programs/Xserver/hw/dmx/doc/dmx.txt
new file mode 100644
index 000000000..568c75178
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/dmx.txt
@@ -0,0 +1,2989 @@
+ Distributed Multihead X design
+ Kevin E. Martin, David H. Dawes, and Rickard E. Faith
+
+ 29 June 2004 (created 25 July 2001)
+
+ This document covers the motivation, background, design, and implemen-
+ tation of the distributed multihead X (DMX) system. It is a living
+ document and describes the current design and implementation details
+ of the DMX system. As the project progresses, this document will be
+ continually updated to reflect the changes in the code and/or design.
+ _C_o_p_y_r_i_g_h_t _2_0_0_1 _b_y _V_A _L_i_n_u_x _S_y_s_t_e_m_s_, _I_n_c_._, _F_r_e_m_o_n_t_, _C_a_l_i_f_o_r_n_i_a_. _C_o_p_y_-
+ _r_i_g_h_t _2_0_0_1_-_2_0_0_4 _b_y _R_e_d _H_a_t_, _I_n_c_._, _R_a_l_e_i_g_h_, _N_o_r_t_h _C_a_r_o_l_i_n_a
+
+ ______________________________________________________________________
+
+ Table of Contents
+
+
+
+ 1. Introduction
+ 1.1 The Distributed Multihead X Server
+ 1.2 Layout of Paper
+
+ 2. Development plan
+ 2.1 Bootstrap code
+ 2.2 Input device handling
+ 2.3 Output device handling
+ 2.3.1 Initialization
+ 2.3.2 Handling rendering requests
+ 2.4 Optimizing DMX
+ 2.5 DMX X extension support
+ 2.6 Common X extension support
+ 2.7 OpenGL support
+
+ 3. Current issues
+ 3.1 Fonts
+ 3.2 Zero width rendering primitives
+ 3.3 Output scaling
+ 3.4 Per-screen colormaps
+
+ A. Background
+ A.1 Core input device handling
+ A.1.1 InitInput()
+ A.1.2 InitAndStartDevices()
+ A.1.3 devReadInput()
+ A.1.4 ProcessInputEvents()
+ A.1.5 DisableDevice()
+ A.1.6 CloseDevice()
+ A.1.7 LegalModifier()
+ A.2 Output handling
+ A.2.1 InitOutput()
+ A.2.2 AddScreen()
+ A.2.3 ScreenInit()
+ A.2.4 CloseScreen()
+ A.2.5 GC operations
+ A.2.6 Xnest
+ A.2.7 Shadow framebuffer
+ A.3 Xinerama
+ A.3.1 Xinerama-specific changes to the DIX code
+ A.3.2 Xinerama-specific changes to the MI code
+ A.3.3 Intercepted DIX core requests
+
+ B. Development Results
+ B.1 Phase I
+ B.1.1 Scope
+ B.1.2 Results
+ B.1.3 X Test Suite
+ B.1.3.1 Introduction
+ B.1.3.2 Expected Failures for a Single Head
+ B.1.3.3 Expected Failures for Xinerama
+ B.1.3.4 Additional Failures from Xdmx
+ B.1.3.5 Summary and Future Work
+ B.1.4 Fonts
+ B.1.5 Performance
+ B.1.6 Pixmaps
+ B.2 Phase II
+ B.2.1 Moving from XFree86 4.1.99.1 to 4.2.0.0
+ B.2.2 Global changes
+ B.2.3 XSync() Batching
+ B.2.4 Offscreen Optimization
+ B.2.5 Lazy Window Creation Optimization
+ B.2.6 Subdividing Rendering Primitives
+ B.2.7 Summary of x11perf Data
+ B.2.8 Profiling with OProfile
+ B.2.9 X Test Suite
+ B.3 Phase III
+ B.3.1 SHAPE
+ B.3.2 RENDER
+ B.3.3 XKEYBOARD
+ B.3.4 XInput
+ B.3.5 DPMS
+ B.3.6 Other Extensions
+ B.4 Phase IV
+ B.4.1 Moving to XFree86 4.3.0
+ B.4.2 Extensions
+ B.4.2.1 XC-MISC (supported)
+ B.4.2.2 Extended-Visual-Information (supported)
+ B.4.2.3 RES (supported)
+ B.4.2.4 BIG-REQUESTS (supported)
+ B.4.2.5 XSYNC (supported)
+ B.4.2.6 XTEST, RECORD, DEC-XTRAP (supported) and XTestExtension1 (not supported)
+ B.4.2.7 MIT-MISC (not supported)
+ B.4.2.8 SCREENSAVER (not supported)
+ B.4.2.9 GLX (supported)
+ B.4.2.10 RENDER (supported)
+ B.4.2.11 Summary
+ B.4.3 Additional Testing with the X Test Suite
+ B.4.3.1 XFree86 without XTEST
+ B.4.3.2 XFree86 with XTEST
+ B.4.3.3 Xdmx with XTEST, without Xinerama, without GLX
+ B.4.3.4 Xdmx with XTEST, with Xinerama, without GLX
+ B.4.3.5 Xdmx with XTEST, with Xinerama, with GLX
+ B.4.3.6 Conclusion
+ B.4.4 Dynamic Reconfiguration
+ B.4.4.1 Dynamic reconfiguration extension
+ B.4.4.2 Bounding box
+ B.4.4.3 Sample applications
+ B.4.4.4 Additional notes
+ B.4.5 Doxygen documentation
+ B.4.6 Valgrind
+ B.4.7 RATS
+
+
+ ______________________________________________________________________
+
+ 11.. IInnttrroodduuccttiioonn
+
+ 11..11.. TThhee DDiissttrriibbuutteedd MMuullttiihheeaadd XX SSeerrvveerr
+
+ Current Open Source multihead solutions are limited to a single
+ physical machine. A single X server controls multiple display
+ devices, which can be arranged as independent heads or unified into a
+ single desktop (with Xinerama). These solutions are limited to the
+ number of physical devices that can co-exist in a single machine
+ (e.g., due to the number of AGP/PCI slots available for graphics
+ cards). Thus, large tiled displays are not currently possible. The
+ work described in this paper will eliminate the requirement that the
+ display devices reside in the same physical machine. This will be
+ accomplished by developing a front-end proxy X server that will
+ control multiple back-end X servers that make up the large display.
+
+
+ The overall structure of the distributed multihead X (DMX) project is
+ as follows: A single front-end X server will act as a proxy to a set
+ of back-end X servers, which handle all of the visible rendering. X
+ clients will connect to the front-end server just as they normally
+ would to a regular X server. The front-end server will present an
+ abstracted view to the client of a single large display. This will
+ ensure that all standard X clients will continue to operate without
+ modification (limited, as always, by the visuals and extensions
+ provided by the X server). Clients that are DMX-aware will be able to
+ use an extension to obtain information about the back-end servers
+ (e.g., for placement of pop-up windows, window alignments by the
+ window manager, etc.).
+
+
+ The architecture of the DMX server is divided into two main sections:
+ input (e.g., mouse and keyboard events) and output (e.g., rendering
+ and windowing requests). Each of these are describe briefly below,
+ and the rest of this design document will describe them in greater
+ detail.
+
+
+ The DMX server can receive input from three general types of input
+ devices: "local" devices that are physically attached to the machine
+ on which DMX is running, "backend" devices that are physically
+ attached to one or more of the back-end X servers (and that generate
+ events via the X protocol stream from the backend), and "console"
+ devices that can be abstracted from any non-back-end X server.
+ Backend and console devices are treated differently because the
+ pointer device on the back-end X server also controls the location of
+ the hardware X cursor. Full support for XInput extension devices is
+ provided.
+
+
+ Rendering requests will be accepted by the front-end server; however,
+ rendering to visible windows will be broken down as needed and sent to
+ the appropriate back-end server(s) via X11 library calls for actual
+ rendering. The basic framework will follow a Xnest-style approach.
+ GC state will be managed in the front-end server and sent to the
+ appropriate back-end server(s) as required. Pixmap rendering will (at
+ least initially) be handled by the front-end X server. Windowing
+ requests (e.g., ordering, mapping, moving, etc.) will handled in the
+ front-end server. If the request requires a visible change, the
+ windowing operation will be translated into requests for the
+ appropriate back-end server(s). Window state will be mirrored in the
+ back-end server(s) as needed.
+
+
+ 11..22.. LLaayyoouutt ooff PPaappeerr
+
+ The next section describes the general development plan that was
+ actually used for implementation. The final section discusses
+ outstanding issues at the conclusion of development. The first
+ appendix provides low-level technical detail that may be of interest
+ to those intimately familiar with the X server architecture. The
+ final appendix describes the four phases of development that were
+ performed during the first two years of development.
+
+
+ The final year of work was divided into 9 tasks that are not described
+ in specific sections of this document. The major tasks during that
+ time were the enhancement of the reconfiguration ability added in
+ Phase IV, addition of support for a dynamic number of back-end
+ displays (instead of a hard-coded limit), and the support for back-end
+ display and input removal and addition. This work is mentioned in
+ this paper, but is not covered in detail.
+
+
+ 22.. DDeevveellooppmmeenntt ppllaann
+
+ This section describes the development plan from approximately June
+ 2001 through July 2003.
+
+
+
+ 22..11.. BBoooottssttrraapp ccooddee
+
+ To allow for rapid development of the DMX server by multiple
+ developers during the first development stage, the problem will be
+ broken down into three tasks: the overall DMX framework, back-end
+ rendering services and input device handling services. However,
+ before the work begins on these tasks, a simple framework that each
+ developer could use was implemented to bootstrap the development
+ effort. This framework renders to a single back-end server and
+ provides dummy input devices (i.e., the keyboard and mouse). The
+ simple back-end rendering service was implemented using the shadow
+ framebuffer support currently available in the XFree86 environment.
+
+
+ Using this bootstrapping framework, each developer has been able to
+ work on each of the tasks listed above independently as follows: the
+ framework will be extended to handle arbitrary back-end server
+ configurations; the back-end rendering services will be transitioned
+ to the more efficient Xnest-style implementation; and, an input device
+ framework to handle various input devices via the input extension will
+ be developed.
+
+
+ Status: The boot strap code is complete.
+
+
+
+ 22..22.. IInnppuutt ddeevviiccee hhaannddlliinngg
+
+ An X server (including the front-end X server) requires two core input
+ devices -- a keyboard and a pointer (mouse). These core devices are
+ handled and required by the core X11 protocol. Additional types of
+ input devices may be attached and utilized via the XInput extension.
+ These are usually referred to as ``XInput extension devices'',
+
+
+ There are some options as to how the front-end X server gets its core
+ input devices:
+
+
+ 1. Local Input. The physical input devices (e.g., keyboard and mouse)
+ can be attached directly to the front-end X server. In this case,
+ the keyboard and mouse on the machine running the front-end X
+ server will be used. The front-end will have drivers to read the
+ raw input from those devices and convert it into the required X
+ input events (e.g., key press/release, pointer button
+ press/release, pointer motion). The front-end keyboard driver will
+ keep track of keyboard properties such as key and modifier
+ mappings, autorepeat state, keyboard sound and led state.
+ Similarly the front-end pointer driver will keep track if pointer
+ properties such as the button mapping and movement acceleration
+ parameters. With this option, input is handled fully in the front-
+ end X server, and the back-end X servers are used in a display-only
+ mode. This option was implemented and works for a limited number
+ of Linux-specific devices. Adding additional local input devices
+ for other architectures is expected to be relatively simple.
+
+
+ The following options are available for implementing local input
+ devices:
+
+
+ a. The XFree86 X server has modular input drivers that could be
+ adapted for this purpose. The mouse driver supports a wide
+ range of mouse types and interfaces, as well as a range of
+ Operating System platforms. The keyboard driver in XFree86 is
+ not currently as modular as the mouse driver, but could be made
+ so. The XFree86 X server also has a range of other input
+ drivers for extended input devices such as tablets and touch
+ screens. Unfortunately, the XFree86 drivers are generally
+ complex, often simultaneously providing support for multiple
+ devices across multiple architectures; and rely so heavily on
+ XFree86-specific helper-functions, that this option was not
+ pursued.
+
+
+ b. The kdrive X server in XFree86 has built-in drivers that support
+ PS/2 mice and keyboard under Linux. The mouse driver can
+ indirectly handle other mouse types if the Linux utility gpm is
+ used as to translate the native mouse protocol into PS/2 mouse
+ format. These drivers could be adapted and built in to the
+ front-end X server if this range of hardware and OS support is
+ sufficient. While much simpler than the XFree86 drivers, the
+ kdrive drivers were not used for the DMX implementation.
+
+ c. Reimplementation of keyboard and mouse drivers from scratch for
+ the DMX framework. Because keyboard and mouse drivers are
+ relatively trivial to implement, this pathway was selected.
+ Other drivers in the X source tree were referenced, and
+ significant contributions from other drivers are noted in the
+ DMX source code.
+
+
+ 2. Backend Input. The front-end can make use of the core input
+ devices attached to one or more of the back-end X servers. Core
+ input events from multiple back-ends are merged into a single input
+ event stream. This can work sanely when only a single set of input
+ devices is used at any given time. The keyboard and pointer state
+ will be handled in the front-end, with changes propagated to the
+ back-end servers as needed. This option was implemented and works
+ well. Because the core pointer on a back-end controls the hardware
+ mouse on that back-end, core pointers cannot be treated as XInput
+ extension devices. However, all back-end XInput extensions devices
+ can be mapped to either DMX core or DMX XInput extension devices.
+
+ 3. Console Input. The front-end server could create a console window
+ that is displayed on an X server independent of the back-end X
+ servers. This console window could display things like the
+ physical screen layout, and the front-end could get its core input
+ events from events delivered to the console window. This option
+ was implemented and works well. To help the human navigate, window
+ outlines are also displayed in the console window. Further,
+ console windows can be used as either core or XInput extension
+ devices.
+
+ 4. Other options were initially explored, but they were all partial
+ subsets of the options listed above and, hence, are irrelevant.
+
+
+ Although extended input devices are not specifically mentioned in the
+ Distributed X requirements, the options above were all implemented so
+ that XInput extension devices were supported.
+
+
+ The bootstrap code (Xdmx) had dummy input devices, and these are still
+ supported in the final version. These do the necessary initialization
+ to satisfy the X server's requirements for core pointer and keyboard
+ devices, but no input events are ever generated.
+
+
+ Status: The input code is complete. Because of the complexity of the
+ XFree86 input device drivers (and their heavy reliance on XFree86
+ infrastructure), separate low-level device drivers were implemented
+ for Xdmx. The following kinds of drivers are supported (in general,
+ the devices can be treated arbitrarily as "core" input devices or as
+ XInput "extension" devices; and multiple instances of different kinds
+ of devices can be simultaneously available):
+
+ 1. A "dummy" device drive that never generates events.
+
+ 2. "Local" input is from the low-level hardware on which the Xdmx
+ binary is running. This is the only area where using the XFree86
+ driver infrastructure would have been helpful, and then only
+ partially, since good support for generic USB devices does not yet
+ exist in XFree86 (in any case, XFree86 and kdrive driver code was
+ used where possible). Currently, the following local devices are
+ supported under Linux (porting to other operating systems should be
+ fairly straightforward):
+
+ +o Linux keyboard
+
+ +o Linux serial mouse (MS)
+
+ +o Linux PS/2 mouse
+
+ +o USB keyboard
+
+ +o USB mouse
+
+ +o USB generic device (e.g., joystick, gamepad, etc.)
+
+
+ 3. "Backend" input is taken from one or more of the back-end displays.
+ In this case, events are taken from the back-end X server and are
+ converted to Xdmx events. Care must be taken so that the sprite
+ moves properly on the display from which input is being taken.
+
+ 4. "Console" input is taken from an X window that Xdmx creates on the
+ operator's display (i.e., on the machine running the Xdmx binary).
+ When the operator's mouse is inside the console window, then those
+ events are converted to Xdmx events. Several special features are
+ available: the console can display outlines of windows that are on
+ the Xdmx display (to facilitate navigation), the cursor can be
+ confined to the console, and a "fine" mode can be activated to
+ allow very precise cursor positioning.
+
+
+
+ 22..33.. OOuuttppuutt ddeevviiccee hhaannddlliinngg
+
+ The output of the DMX system displays rendering and windowing requests
+ across multiple screens. The screens are typically arranged in a grid
+ such that together they represent a single large display.
+
+
+ The output section of the DMX code consists of two parts. The first
+ is in the front-end proxy X server (Xdmx), which accepts client
+ connections, manages the windows, and potentially renders primitives
+ but does not actually display any of the drawing primitives. The
+ second part is the back-end X server(s), which accept commands from
+ the front-end server and display the results on their screens.
+
+
+ 22..33..11.. IInniittiiaalliizzaattiioonn
+
+ The DMX front-end must first initialize its screens by connecting to
+ each of the back-end X servers and collecting information about each
+ of these screens. However, the information collected from the back-
+ end X servers might be inconsistent. Handling these cases can be
+ difficult and/or inefficient. For example, a two screen system has
+ one back-end X server running at 16bpp while the second is running at
+ 32bpp. Converting rendering requests (e.g., XPutImage() or
+ XGetImage() requests) to the appropriate bit depth can be very time
+ consuming. Analyzing these cases to determine how or even if it is
+ possible to handle them is required. The current Xinerama code
+ handles many of these cases (e.g., in PanoramiXConsolidate()) and will
+ be used as a starting point. In general, the best solution is to use
+ homogeneous X servers and display devices. Using back-end servers
+ with the same depth is a requirement of the final DMX implementation.
+
+
+ Once this screen consolidation is finished, the relative position of
+ each back-end X server's screen in the unified screen is initialized.
+ A full-screen window is opened on each of the back-end X servers, and
+ the cursor on each screen is turned off. The final DMX implementation
+ can also make use of a partial-screen window, or multiple windows per
+ back-end screen.
+
+
+ 22..33..22.. HHaannddlliinngg rreennddeerriinngg rreeqquueessttss
+
+ After initialization, X applications connect to the front-end server.
+ There are two possible implementations of how rendering and windowing
+ requests are handled in the DMX system:
+
+
+ 1. A shadow framebuffer is used in the front-end server as the render
+ target. In this option, all protocol requests are completely
+ handled in the front-end server. All state and resources are
+ maintained in the front-end including a shadow copy of the entire
+ framebuffer. The framebuffers attached to the back-end servers are
+ updated by XPutImage() calls with data taken directly from the
+ shadow framebuffer.
+
+
+ This solution suffers from two main problems. First, it does not
+ take advantage of any accelerated hardware available in the system.
+ Second, the size of the XPutImage() calls can be quite large and
+ thus will be limited by the bandwidth available.
+
+
+ The initial DMX implementation used a shadow framebuffer by
+ default.
+
+
+ 2. Rendering requests are sent to each back-end server for handling
+ (as is done in the Xnest server described above). In this option,
+ certain protocol requests are handled in the front-end server and
+ certain requests are repackaged and then sent to the back-end
+ servers. The framebuffer is distributed across the multiple back-
+ end servers. Rendering to the framebuffer is handled on each back-
+ end and can take advantage of any acceleration available on the
+ back-end servers' graphics display device. State is maintained
+ both in the front and back-end servers.
+
+
+ This solution suffers from two main drawbacks. First, protocol
+ requests are sent to all back-end servers -- even those that will
+ completely clip the rendering primitive -- which wastes bandwidth
+ and processing time. Second, state is maintained both in the
+ front- and back-end servers. These drawbacks are not as severe as
+ in option 1 (above) and can either be overcome through
+ optimizations or are acceptable. Therefore, this option will be
+ used in the final implementation.
+
+
+ The final DMX implementation defaults to this mechanism, but also
+ supports the shadow framebuffer mechanism. Several optimizations
+ were implemented to eliminate the drawbacks of the default
+ mechanism. These optimizations are described the section below and
+ in Phase II of the Development Results (see appendix).
+
+
+
+ Status: Both the shadow framebuffer and Xnest-style code is complete.
+
+
+
+ 22..44.. OOppttiimmiizziinngg DDMMXX
+
+ Initially, the Xnest-style solution's performance will be measured and
+ analyzed to determine where the performance bottlenecks exist. There
+ are four main areas that will be addressed.
+
+
+ First, to obtain reasonable interactivity with the first development
+ phase, XSync() was called after each protocol request. The XSync()
+ function flushes any pending protocol requests. It then waits for the
+ back-end to process the request and send a reply that the request has
+ completed. This happens with each back-end server and performance
+ greatly suffers. As a result of the way XSync() is called in the
+ first development phase, the batching that the X11 library performs is
+ effectively defeated. The XSync() call usage will be analyzed and
+ optimized by batching calls and performing them at regular intervals,
+ except where interactivity will suffer (e.g., on cursor movements).
+
+
+ Second, the initial Xnest-style solution described above sends the
+ repackaged protocol requests to all back-end servers regardless of
+ whether or not they would be completely clipped out. The requests
+ that are trivially rejected on the back-end server wastes the limited
+ bandwidth available. By tracking clipping changes in the DMX X
+ server's windowing code (e.g., by opening, closing, moving or resizing
+ windows), we can determine whether or not back-end windows are visible
+ so that trivial tests in the front-end server's GC ops drawing
+ functions can eliminate these unnecessary protocol requests.
+
+
+ Third, each protocol request will be analyzed to determine if it is
+ possible to break the request into smaller pieces at display
+ boundaries. The initial ones to be analyzed are put and get image
+ requests since they will require the greatest bandwidth to transmit
+ data between the front and back-end servers. Other protocol requests
+ will be analyzed and those that will benefit from breaking them into
+ smaller requests will be implemented.
+
+
+ Fourth, an extension is being considered that will allow font glyphs
+ to be transferred from the front-end DMX X server to each back-end
+ server. This extension will permit the front-end to handle all font
+ requests and eliminate the requirement that all back-end X servers
+ share the exact same fonts as the front-end server. We are
+ investigating the feasibility of this extension during this
+ development phase.
+
+
+ Other potential optimizations will be determined from the performance
+ analysis.
+
+ Please note that in our initial design, we proposed optimizing BLT
+ operations (e.g., XCopyArea() and window moves) by developing an
+ extension that would allow individual back-end servers to directly
+ copy pixel data to other back-end servers. This potential
+ optimization was in response to the simple image movement
+ implementation that required potentially many calls to GetImage() and
+ PutImage(). However, the current Xinerama implementation handles
+ these BLT operations differently. Instead of copying data to and from
+ screens, they generate expose events -- just as happens in the case
+ when a window is moved from off a screen to on screen. This approach
+ saves the limited bandwidth available between front and back-end
+ servers and is being standardized with Xinerama. It also eliminates
+ the potential setup problems and security issues resulting from having
+ each back-end server open connections to all other back-end servers.
+ Therefore, we suggest accepting Xinerama's expose event solution.
+
+
+ Also note that the approach proposed in the second and third
+ optimizations might cause backing store algorithms in the back-end to
+ be defeated, so a DMX X server configuration flag will be added to
+ disable these optimizations.
+
+
+ Status: The optimizations proposed above are complete. It was
+ determined that the using the xfs font server was sufficient and
+ creating a new mechanism to pass glyphs was redundant; therefore, the
+ fourth optimization proposed above was not included in DMX.
+
+
+
+ 22..55.. DDMMXX XX eexxtteennssiioonn ssuuppppoorrtt
+
+ The DMX X server keeps track of all the windowing information on the
+ back-end X servers, but does not currently export this information to
+ any client applications. An extension will be developed to pass the
+ screen information and back-end window IDs to DMX-aware clients.
+ These clients can then use this information to directly connect to and
+ render to the back-end windows. Bypassing the DMX X server allows
+ DMX-aware clients to break up complex rendering requests on their own
+ and send them directly to the windows on the back-end server's
+ screens. An example of a client that can make effective use of this
+ extension is Chromium.
+
+
+ Status: The extension, as implemented, is fully documented in "Client-
+ to-Server DMX Extension to the X Protocol". Future changes might be
+ required based on feedback and other proposed enhancements to DMX.
+ Currently, the following facilities are supported:
+
+ 1. Screen information (clipping rectangle for each screen relative to
+ the virtual screen)
+
+ 2. Window information (window IDs and clipping information for each
+ back-end window that corresponds to each DMX window)
+
+ 3. Input device information (mappings from DMX device IDs to back-end
+ device IDs)
+
+ 4. Force window creation (so that a client can override the server-
+ side lazy window creation optimization)
+
+ 5. Reconfiguration (so that a client can request that a screen
+ position be changed)
+
+ 6. Addition and removal of back-end servers and back-end and console
+ inputs.
+ 22..66.. CCoommmmoonn XX eexxtteennssiioonn ssuuppppoorrtt
+
+ The XInput, XKeyboard and Shape extensions are commonly used
+ extensions to the base X11 protocol. XInput allows multiple and non-
+ standard input devices to be accessed simultaneously. These input
+ devices can be connected to either the front-end or back-end servers.
+ XKeyboard allows much better keyboard mappings control. Shape adds
+ support for arbitrarily shaped windows and is used by various window
+ managers. Nearly all potential back-end X servers make these
+ extensions available, and support for each one will be added to the
+ DMX system.
+
+
+ In addition to the extensions listed above, support for the X
+ Rendering extension (Render) is being developed. Render adds digital
+ image composition to the rendering model used by the X Window System.
+ While this extension is still under development by Keith Packard of
+ HP, support for the current version will be added to the DMX system.
+
+
+ Support for the XTest extension was added during the first development
+ phase.
+
+
+ Status: The following extensions are supported and are discussed in
+ more detail in Phase IV of the Development Results (see appendix):
+ BIG-REQUESTS, DEC-XTRAP, DMX, DPMS, Extended-Visual-Information, GLX,
+ LBX, RECORD, RENDER, SECURITY, SHAPE, SYNC, X-Resource, XC-APPGROUP,
+ XC-MISC, XFree86-Bigfont, XINERAMA, XInputExtension, XKEYBOARD, and
+ XTEST.
+
+
+ 22..77.. OOppeennGGLL ssuuppppoorrtt
+
+ OpenGL support using the Mesa code base exists in XFree86 release 4
+ and later. Currently, the direct rendering infrastructure (DRI)
+ provides accelerated OpenGL support for local clients and
+ unaccelerated OpenGL support (i.e., software rendering) is provided
+ for non-local clients.
+
+
+ The single head OpenGL support in XFree86 4.x will be extended to use
+ the DMX system. When the front and back-end servers are on the same
+ physical hardware, it is possible to use the DRI to directly render to
+ the back-end servers. First, the existing DRI will be extended to
+ support multiple display heads, and then to support the DMX system.
+ OpenGL rendering requests will be direct rendering to each back-end X
+ server. The DRI will request the screen layout (either from the
+ existing Xinerama extension or a DMX-specific extension). Support for
+ synchronized swap buffers will also be added (on hardware that
+ supports it). Note that a single front-end server with a single back-
+ end server on the same physical machine can emulate accelerated
+ indirect rendering.
+
+
+ When the front and back-end servers are on different physical hardware
+ or are using non-XFree86 4.x X servers, a mechanism to render
+ primitives across the back-end servers will be provided. There are
+ several options as to how this can be implemented.
+
+
+ 1. The existing OpenGL support in each back-end server can be used by
+ repackaging rendering primitives and sending them to each back-end
+ server. This option is similar to the unoptimized Xnest-style
+ approach mentioned above. Optimization of this solution is beyond
+ the scope of this project and is better suited to other distributed
+ rendering systems.
+
+ 2. Rendering to a pixmap in the front-end server using the current
+ XFree86 4.x code, and then displaying to the back-ends via calls to
+ XPutImage() is another option. This option is similar to the
+ shadow frame buffer approach mentioned above. It is slower and
+ bandwidth intensive, but has the advantage that the back-end
+ servers are not required to have OpenGL support.
+
+
+ These, and other, options will be investigated in this phase of the
+ work.
+
+
+ Work by others have made Chromium DMX-aware. Chromium will use the
+ DMX X protocol extension to obtain information about the back-end
+ servers and will render directly to those servers, bypassing DMX.
+
+
+ Status: OpenGL support by the glxProxy extension was implemented by
+ SGI and has been integrated into the DMX code base.
+
+
+
+ 33.. CCuurrrreenntt iissssuueess
+
+ In this sections the current issues are outlined that require further
+ investigation.
+
+
+ 33..11.. FFoonnttss
+
+ The font path and glyphs need to be the same for the front-end and
+ each of the back-end servers. Font glyphs could be sent to the back-
+ end servers as necessary but this would consume a significant amount
+ of available bandwidth during font rendering for clients that use many
+ different fonts (e.g., Netscape). Initially, the font server (xfs)
+ will be used to provide the fonts to both the front-end and back-end
+ servers. Other possibilities will be investigated during development.
+
+
+ 33..22.. ZZeerroo wwiiddtthh rreennddeerriinngg pprriimmiittiivveess
+
+ To allow pixmap and on-screen rendering to be pixel perfect, all back-
+ end servers must render zero width primitives exactly the same as the
+ front-end renders the primitives to pixmaps. For those back-end
+ servers that do not exactly match, zero width primitives will be
+ automatically converted to one width primitives. This can be handled
+ in the front-end server via the GC state.
+
+
+ 33..33.. OOuuttppuutt ssccaalliinngg
+
+ With very large tiled displays, it might be difficult to read the
+ information on the standard X desktop. In particular, the cursor can
+ be easily lost and fonts could be difficult to read. Automatic
+ primitive scaling might prove to be very useful. We will investigate
+ the possibility of scaling the cursor and providing a set of alternate
+ pre-scaled fonts to replace the standard fonts that many applications
+ use (e.g., fixed). Other options for automatic scaling will also be
+ investigated.
+
+
+
+ 33..44.. PPeerr--ssccrreeeenn ccoolloorrmmaappss
+
+ Each screen's default colormap in the set of back-end X servers should
+ be able to be adjusted via a configuration utility. This support is
+ would allow the back-end screens to be calibrated via custom gamma
+ tables. On 24-bit systems that support a DirectColor visual, this
+ type of correction can be accommodated. One possible implementation
+ would be to advertise to X client of the DMX server a TrueColor visual
+ while using DirectColor visuals on the back-end servers to implement
+ this type of color correction. Other options will be investigated.
+
+
+ AA.. BBaacckkggrroouunndd
+
+ This section describes the existing Open Source architectures that can
+ be used to handle multiple screens and upon which this development
+ project is based. This section was written before the implementation
+ was finished, and may not reflect actual details of the
+ implementation. It is left for historical interest only.
+
+
+ AA..11.. CCoorree iinnppuutt ddeevviiccee hhaannddlliinngg
+
+ The following is a description of how core input devices are handled
+ by an X server.
+
+
+ AA..11..11.. IInniittIInnppuutt(())
+
+ InitInput() is a DDX function that is called at the start of each
+ server generation from the X server's main() function. Its purpose is
+ to determine what input devices are connected to the X server,
+ register them with the DIX and MI layers, and initialize the input
+ event queue. InitInput() does not have a return value, but the X
+ server will abort if either a core keyboard device or a core pointer
+ device are not registered. Extended input (XInput) devices can also
+ be registered in InitInput().
+
+
+ InitInput() usually has implementation specific code to determine
+ which input devices are available. For each input device it will be
+ using, it calls AddInputDevice():
+
+
+ AAddddIInnppuuttDDeevviiccee(())
+ This DIX function allocates the device structure, registers a
+ callback function (which handles device init, close, on and
+ off), and returns the input handle, which can be treated as
+ opaque. It is called once for each input device.
+
+
+ Once input handles for core keyboard and core pointer devices have
+ been obtained from AddInputDevice(), they are registered as core
+ devices by calling RegisterPointerDevice() and
+ RegisterKeyboardDevice(). Each of these should be called once. If
+ both core devices are not registered, then the X server will exit with
+ a fatal error when it attempts to start the input devices in
+ InitAndStartDevices(), which is called directly after InitInput() (see
+ below).
+
+
+ RReeggiisstteerr{{PPooiinntteerr,,KKeeyybbooaarrdd}}DDeevviiccee(())
+ These DIX functions take a handle returned from AddInputDevice()
+ and initialize the core input device fields in inputInfo, and
+ initialize the input processing and grab functions for each core
+ input device.
+ The core pointer device is then registered with the miPointer code
+ (which does the high level cursor handling). While this registration
+ is not necessary for correct miPointer operation in the current
+ XFree86 code, it is still done mostly for compatibility reasons.
+
+
+ mmiiRReeggiisstteerrPPooiinntteerrDDeevviiccee(())
+ This MI function registers the core pointer's input handle with
+ with the miPointer code.
+
+
+ The final part of InitInput() is the initialization of the input event
+ queue handling. In most cases, the event queue handling provided in
+ the MI layer is used. The primary XFree86 X server uses its own event
+ queue handling to support some special cases related to the XInput
+ extension and the XFree86-specific DGA extension. For our purposes,
+ the MI event queue handling should be suitable. It is initialized by
+ calling mieqInit():
+
+
+ mmiieeqqIInniitt(())
+ This MI function initializes the MI event queue for the core
+ devices, and is passed the public component of the input handles
+ for the two core devices.
+
+
+ If a wakeup handler is required to deliver synchronous input events,
+ it can be registered here by calling the DIX function
+ RegisterBlockAndWakeupHandlers(). (See the devReadInput() description
+ below.)
+
+
+ AA..11..22.. IInniittAAnnddSSttaarrttDDeevviicceess(())
+
+ InitAndStartDevices() is a DIX function that is called immediately
+ after InitInput() from the X server's main() function. Its purpose is
+ to initialize each input device that was registered with
+ AddInputDevice(), enable each input device that was successfully
+ initialized, and create the list of enabled input devices. Once each
+ registered device is processed in this way, the list of enabled input
+ devices is checked to make sure that both a core keyboard device and
+ core pointer device were registered and successfully enabled. If not,
+ InitAndStartDevices() returns failure, and results in the the X server
+ exiting with a fatal error.
+
+
+ Each registered device is initialized by calling its callback
+ (dev->deviceProc) with the DEVICE_INIT argument:
+
+
+ ((**ddeevv-->>ddeevviicceePPrroocc))((ddeevv,, DDEEVVIICCEE__IINNIITT))
+ This function initializes the device structs with core
+ information relevant to the device.
+
+
+ For pointer devices, this means specifying the number of
+ buttons, default button mapping, the function used to get motion
+ events (usually miPointerGetMotionEvents()), the function used
+ to change/control the core pointer motion parameters
+ (acceleration and threshold), and the motion buffer size.
+
+
+ For keyboard devices, this means specifying the keycode range,
+ default keycode to keysym mapping, default modifier mapping, and
+ the functions used to sound the keyboard bell and modify/control
+ the keyboard parameters (LEDs, bell pitch and duration, key
+ click, which keys are auto-repeating, etc).
+
+
+ Each initialized device is enabled by calling EnableDevice():
+
+
+ EEnnaabblleeDDeevviiccee(())
+ EnableDevice() calls the device callback with DEVICE_ON:
+
+ ((**ddeevv-->>ddeevviicceePPrroocc))((ddeevv,, DDEEVVIICCEE__OONN))
+ This typically opens and initializes the relevant physical
+ device, and when appropriate, registers the device's file
+ descriptor (or equivalent) as a valid input source.
+
+
+ EnableDevice() then adds the device handle to the X server's
+ global list of enabled devices.
+
+
+ InitAndStartDevices() then verifies that a valid core keyboard and
+ pointer has been initialized and enabled. It returns failure if
+ either are missing.
+
+
+ AA..11..33.. ddeevvRReeaaddIInnppuutt(())
+
+ Each device will have some function that gets called to read its
+ physical input. These may be called in a number of different ways.
+ In the case of synchronous I/O, they will be called from a DDX wakeup-
+ handler that gets called after the server detects that new input is
+ available. In the case of asynchronous I/O, they will be called from
+ a (SIGIO) signal handler triggered when new input is available. This
+ function should do at least two things: make sure that input events
+ get enqueued, and make sure that the cursor gets moved for motion
+ events (except if these are handled later by the driver's own event
+ queue processing function, which cannot be done when using the MI
+ event queue handling).
+
+
+ Events are queued by calling mieqEnqueue():
+
+
+ mmiieeqqEEnnqquueeuuee(())
+ This MI function is used to add input events to the event queue.
+ It is simply passed the event to be queued.
+
+
+ The cursor position should be updated when motion events are enqueued,
+ by calling either miPointerAbsoluteCursor() or miPointerDeltaCursor():
+
+
+ mmiiPPooiinntteerrAAbbssoolluutteeCCuurrssoorr(())
+ This MI function is used to move the cursor to the absolute
+ coordinates provided.
+
+ mmiiPPooiinntteerrDDeellttaaCCuurrssoorr(())
+ This MI function is used to move the cursor relative to its
+ current position.
+
+
+ AA..11..44.. PPrroocceessssIInnppuuttEEvveennttss(())
+
+ ProcessInputEvents() is a DDX function that is called from the X
+ server's main dispatch loop when new events are available in the input
+ event queue. It typically processes the enqueued events, and updates
+ the cursor/pointer position. It may also do other DDX-specific event
+ processing.
+
+
+ Enqueued events are processed by mieqProcessInputEvents() and passed
+ to the DIX layer for transmission to clients:
+
+
+ mmiieeqqPPrroocceessssIInnppuuttEEvveennttss(())
+ This function processes each event in the event queue, and
+ passes it to the device's input processing function. The DIX
+ layer provides default functions to do this processing, and they
+ handle the task of getting the events passed back to the
+ relevant clients.
+
+ mmiiPPooiinntteerrUUppddaattee(())
+ This function resynchronized the cursor position with the new
+ pointer position. It also takes care of moving the cursor
+ between screens when needed in multi-head configurations.
+
+
+
+ AA..11..55.. DDiissaabblleeDDeevviiccee(())
+
+ DisableDevice is a DIX function that removes an input device from the
+ list of enabled devices. The result of this is that the device no
+ longer generates input events. The device's data structures are kept
+ in place, and disabling a device like this can be reversed by calling
+ EnableDevice(). DisableDevice() may be called from the DDX when it is
+ desirable to do so (e.g., the XFree86 server does this when VT
+ switching). Except for special cases, this is not normally called for
+ core input devices.
+
+
+ DisableDevice() calls the device's callback function with DEVICE_OFF:
+
+
+ ((**ddeevv-->>ddeevviicceePPrroocc))((ddeevv,, DDEEVVIICCEE__OOFFFF))
+ This typically closes the relevant physical device, and when
+ appropriate, unregisters the device's file descriptor (or
+ equivalent) as a valid input source.
+
+
+ DisableDevice() then removes the device handle from the X server's
+ global list of enabled devices.
+
+
+
+ AA..11..66.. CClloosseeDDeevviiccee(())
+
+ CloseDevice is a DIX function that removes an input device from the
+ list of available devices. It disables input from the device and
+ frees all data structures associated with the device. This function
+ is usually called from CloseDownDevices(), which is called from main()
+ at the end of each server generation to close all input devices.
+
+
+ CloseDevice() calls the device's callback function with DEVICE_CLOSE:
+
+
+ ((**ddeevv-->>ddeevviicceePPrroocc))((ddeevv,, DDEEVVIICCEE__CCLLOOSSEE))
+ This typically closes the relevant physical device, and when
+ appropriate, unregisters the device's file descriptor (or
+ equivalent) as a valid input source. If any device specific
+ data structures were allocated when the device was initialized,
+ they are freed here.
+
+ CloseDevice() then frees the data structures that were allocated for
+ the device when it was registered/initialized.
+
+
+
+ AA..11..77.. LLeeggaallMMooddiiffiieerr(())
+
+ LegalModifier() is a required DDX function that can be used to
+ restrict which keys may be modifier keys. This seems to be present
+ for historical reasons, so this function should simply return TRUE
+ unconditionally.
+
+
+
+ AA..22.. OOuuttppuutt hhaannddlliinngg
+
+ The following sections describe the main functions required to
+ initialize, use and close the output device(s) for each screen in the
+ X server.
+
+
+ AA..22..11.. IInniittOOuuttppuutt(())
+
+ This DDX function is called near the start of each server generation
+ from the X server's main() function. InitOutput()'s main purpose is
+ to initialize each screen and fill in the global screenInfo structure
+ for each screen. It is passed three arguments: a pointer to the
+ screenInfo struct, which it is to initialize, and argc and argv from
+ main(), which can be used to determine additional configuration
+ information.
+
+
+ The primary tasks for this function are outlined below:
+
+
+ 1. PPaarrssee ccoonnffiigguurraattiioonn iinnffoo:: The first task of InitOutput() is to
+ parses any configuration information from the configuration file.
+ In addition to the XF86Config file, other configuration information
+ can be taken from the command line. The command line options can
+ be gathered either in InitOutput() or earlier in the
+ ddxProcessArgument() function, which is called by
+ ProcessCommandLine(). The configuration information determines the
+ characteristics of the screen(s). For example, in the XFree86 X
+ server, the XF86Config file specifies the monitor information, the
+ screen resolution, the graphics devices and slots in which they are
+ located, and, for Xinerama, the screens' layout.
+
+ 2. IInniittiiaalliizzee ssccrreeeenn iinnffoo:: The next task is to initialize the screen-
+ dependent internal data structures. For example, part of what the
+ XFree86 X server does is to allocate its screen and pixmap private
+ indices, probe for graphics devices, compare the probed devices to
+ the ones listed in the XF86Config file, and add the ones that match
+ to the internal xf86Screens[] structure.
+
+ 3. SSeett ppiixxmmaapp ffoorrmmaattss:: The next task is to initialize the screenInfo's
+ image byte order, bitmap bit order and bitmap scanline unit/pad.
+ The screenInfo's pixmap format's depth, bits per pixel and scanline
+ padding is also initialized at this stage.
+
+ 4. UUnniiffyy ssccrreeeenn iinnffoo:: An optional task that might be done at this
+ stage is to compare all of the information from the various screens
+ and determines if they are compatible (i.e., if the set of screens
+ can be unified into a single desktop). This task has potential to
+ be useful to the DMX front-end server, if Xinerama's
+ PanoramiXConsolidate() function is not sufficient.
+
+ Once these tasks are complete, the valid screens are known and each of
+ these screens can be initialized by calling AddScreen().
+
+
+ AA..22..22.. AAddddSSccrreeeenn(())
+
+ This DIX function is called from InitOutput(), in the DDX layer, to
+ add each new screen to the screenInfo structure. The DDX screen
+ initialization function and command line arguments (i.e., argc and
+ argv) are passed to it as arguments.
+
+
+ This function first allocates a new Screen structure and any privates
+ that are required. It then initializes some of the fields in the
+ Screen struct and sets up the pixmap padding information. Finally, it
+ calls the DDX screen initialization function ScreenInit(), which is
+ described below. It returns the number of the screen that were just
+ added, or -1 if there is insufficient memory to add the screen or if
+ the DDX screen initialization fails.
+
+
+ AA..22..33.. SSccrreeeennIInniitt(())
+
+ This DDX function initializes the rest of the Screen structure with
+ either generic or screen-specific functions (as necessary). It also
+ fills in various screen attributes (e.g., width and height in
+ millimeters, black and white pixel values).
+
+
+ The screen init function usually calls several functions to perform
+ certain screen initialization functions. They are described below:
+
+
+ {{mmii,,**ffbb}}SSccrreeeennIInniitt(())
+ The DDX layer's ScreenInit() function usually calls another
+ layer's ScreenInit() function (e.g., miScreenInit() or
+ fbScreenInit()) to initialize the fallbacks that the DDX driver
+ does not specifically handle.
+
+
+ After calling another layer's ScreenInit() function, any screen-
+ specific functions either wrap or replace the other layer's
+ function pointers. If a function is to be wrapped, each of the
+ old function pointers from the other layer are stored in a
+ screen private area. Common functions to wrap are CloseScreen()
+ and SaveScreen().
+
+
+ mmiiIInniittiiaalliizzeeBBaacckkiinnggSSttoorree(())
+ This MI function initializes the screen's backing storage
+ functions, which are used to save areas of windows that are
+ currently covered by other windows.
+
+
+ mmiiDDCCIInniittiiaalliizzee(())
+ This MI function initializes the MI cursor display structures
+ and function pointers. If a hardware cursor is used, the DDX
+ layer's ScreenInit() function will wrap additional screen and
+ the MI cursor display function pointers.
+
+
+ Another common task for ScreenInit() function is to initialize the
+ output device state. For example, in the XFree86 X server, the
+ ScreenInit() function saves the original state of the video card and
+ then initializes the video mode of the graphics device.
+
+ AA..22..44.. CClloosseeSSccrreeeenn(())
+
+ This function restores any wrapped screen functions (and in particular
+ the wrapped CloseScreen() function) and restores the state of the
+ output device to its original state. It should also free any private
+ data it created during the screen initialization.
+
+
+ AA..22..55.. GGCC ooppeerraattiioonnss
+
+ When the X server is requested to render drawing primitives, it does
+ so by calling drawing functions through the graphics context's
+ operation function pointer table (i.e., the GCOps functions). These
+ functions render the basic graphics operations such as drawing
+ rectangles, lines, text or copying pixmaps. Default routines are
+ provided either by the MI layer, which draws indirectly through a
+ simple span interface, or by the framebuffer layers (e.g., CFB, MFB,
+ FB), which draw directly to a linearly mapped frame buffer.
+
+
+ To take advantage of special hardware on the graphics device, specific
+ GCOps functions can be replaced by device specific code. However,
+ many times the graphics devices can handle only a subset of the
+ possible states of the GC, so during graphics context validation,
+ appropriate routines are selected based on the state and capabilities
+ of the hardware. For example, some graphics hardware can accelerate
+ single pixel width lines with certain dash patterns. Thus, for dash
+ patterns that are not supported by hardware or for width 2 or greater
+ lines, the default routine is chosen during GC validation.
+
+
+ Note that some pointers to functions that draw to the screen are
+ stored in the Screen structure. They include GetImage(), GetSpans(),
+ PaintWindowBackground(), PaintWindowBorder(), CopyWindow() and
+ RestoreAreas().
+
+
+ AA..22..66.. XXnneesstt
+
+ The Xnest X server is a special proxy X server that relays the X
+ protocol requests that it receives to a ``real'' X server that then
+ processes the requests and displays the results, if applicable. To
+ the X applications, Xnest appears as if it is a regular X server.
+ However, Xnest is both server to the X application and client of the
+ real X server, which will actually handle the requests.
+
+
+ The Xnest server implements all of the standard input and output
+ initialization steps outlined above.
+
+
+ IInniittOOuuttppuutt(())
+ Xnest takes its configuration information from command line
+ arguments via ddxProcessArguments(). This information includes
+ the real X server display to connect to, its default visual
+ class, the screen depth, the Xnest window's geometry, etc.
+ Xnest then connects to the real X server and gathers visual,
+ colormap, depth and pixmap information about that server's
+ display, creates a window on that server, which will be used as
+ the root window for Xnest.
+
+
+ Next, Xnest initializes its internal data structures and uses
+ the data from the real X server's pixmaps to initialize its own
+ pixmap formats. Finally, it calls AddScreen(xnestOpenScreen,
+ argc, argv) to initialize each of its screens.
+ SSccrreeeennIInniitt(())
+ Xnest's ScreenInit() function is called xnestOpenScreen(). This
+ function initializes its screen's depth and visual information,
+ and then calls miScreenInit() to set up the default screen
+ functions. It then calls miInitializeBackingStore() and
+ miDCInitialize() to initialize backing store and the software
+ cursor. Finally, it replaces many of the screen functions with
+ its own functions that repackage and send the requests to the
+ real X server to which Xnest is attached.
+
+
+ CClloosseeSSccrreeeenn(())
+ This function frees its internal data structure allocations.
+ Since it replaces instead of wrapping screen functions, there
+ are no function pointers to unwrap. This can potentially lead
+ to problems during server regeneration.
+
+
+ GGCC ooppeerraattiioonnss
+ The GC operations in Xnest are very simple since they leave all
+ of the drawing to the real X server to which Xnest is attached.
+ Each of the GCOps takes the request and sends it to the real X
+ server using standard Xlib calls. For example, the X
+ application issues a XDrawLines() call. This function turns
+ into a protocol request to Xnest, which calls the
+ xnestPolylines() function through Xnest's GCOps function pointer
+ table. The xnestPolylines() function is only a single line,
+ which calls XDrawLines() using the same arguments that were
+ passed into it. Other GCOps functions are very similar. Two
+ exceptions to the simple GCOps functions described above are the
+ image functions and the BLT operations.
+
+
+ The image functions, GetImage() and PutImage(), must use a
+ temporary image to hold the image to be put of the image that
+ was just grabbed from the screen while it is in transit to the
+ real X server or the client. When the image has been
+ transmitted, the temporary image is destroyed.
+
+
+ The BLT operations, CopyArea() and CopyPlane(), handle not only
+ the copy function, which is the same as the simple cases
+ described above, but also the graphics exposures that result
+ when the GC's graphics exposure bit is set to True. Graphics
+ exposures are handled in a helper function,
+ xnestBitBlitHelper(). This function collects the exposure
+ events from the real X server and, if any resulting in regions
+ being exposed, then those regions are passed back to the MI
+ layer so that it can generate exposure events for the X
+ application.
+
+
+ The Xnest server takes its input from the X server to which it is
+ connected. When the mouse is in the Xnest server's window, keyboard
+ and mouse events are received by the Xnest server, repackaged and sent
+ back to any client that requests those events.
+
+
+ AA..22..77.. SShhaaddooww ffrraammeebbuuffffeerr
+
+ The most common type of framebuffer is a linear array memory that maps
+ to the video memory on the graphics device. However, accessing that
+ video memory over an I/O bus (e.g., ISA or PCI) can be slow. The
+ shadow framebuffer layer allows the developer to keep the entire
+ framebuffer in main memory and copy it back to video memory at regular
+ intervals. It also has been extended to handle planar video memory
+ and rotated framebuffers.
+
+
+ There are two main entry points to the shadow framebuffer code:
+
+
+ sshhaaddoowwAAlllloocc((wwiiddtthh,, hheeiigghhtt,, bbpppp))
+ This function allocates the in memory copy of the framebuffer of
+ size width*height*bpp. It returns a pointer to that memory,
+ which will be used by the framebuffer ScreenInit() code during
+ the screen's initialization.
+
+
+ sshhaaddoowwIInniitt((ppSSccrreeeenn,, uuppddaatteePPrroocc,, wwiinnddoowwPPrroocc))
+ This function initializes the shadow framebuffer layer. It
+ wraps several screen drawing functions, and registers a block
+ handler that will update the screen. The updateProc is a
+ function that will copy the damaged regions to the screen, and
+ the windowProc is a function that is used when the entire linear
+ video memory range cannot be accessed simultaneously so that
+ only a window into that memory is available (e.g., when using
+ the VGA aperture).
+
+
+ The shadow framebuffer code keeps track of the damaged area of each
+ screen by calculating the bounding box of all drawing operations that
+ have occurred since the last screen update. Then, when the block
+ handler is next called, only the damaged portion of the screen is
+ updated.
+
+
+ Note that since the shadow framebuffer is kept in main memory, all
+ drawing operations are performed by the CPU and, thus, no accelerated
+ hardware drawing operations are possible.
+
+
+
+ AA..33.. XXiinneerraammaa
+
+ Xinerama is an X extension that allows multiple physical screens
+ controlled by a single X server to appear as a single screen.
+ Although the extension allows clients to find the physical screen
+ layout via extension requests, it is completely transparent to clients
+ at the core X11 protocol level. The original public implementation of
+ Xinerama came from Digital/Compaq. XFree86 rewrote it, filling in
+ some missing pieces and improving both X11 core protocol compliance
+ and performance. The Xinerama extension will be passing through
+ X.Org's standardization process in the near future, and the sample
+ implementation will be based on this rewritten version.
+
+
+ The current implementation of Xinerama is based primarily in the DIX
+ (device independent) and MI (machine independent) layers of the X
+ server. With few exceptions the DDX layers do not need any changes to
+ support Xinerama. X server extensions often do need modifications to
+ provide full Xinerama functionality.
+
+
+ The following is a code-level description of how Xinerama functions.
+
+
+ Note: Because the Xinerama extension was originally called the
+ PanoramiX extension, many of the Xinerama functions still have the
+ PanoramiX prefix.
+
+
+ PPaannoorraammiiXXEExxtteennssiioonnIInniitt(())
+ PanoramiXExtensionInit() is a device-independent extension
+ function that is called at the start of each server generation
+ from InitExtensions(), which is called from the X server's
+ main() function after all output devices have been initialized,
+ but before any input devices have been initialized.
+
+
+ PanoramiXNumScreens is set to the number of physical screens.
+ If only one physical screen is present, the extension is
+ disabled, and PanoramiXExtensionInit() returns without doing
+ anything else.
+
+
+ The Xinerama extension is registered by calling AddExtension().
+
+
+ A local per-screen array of data structures (panoramiXdataPtr[])
+ is allocated for each physical screen, and GC and Screen private
+ indexes are allocated, and both GC and Screen private areas are
+ allocated for each physical screen. These hold Xinerama-
+ specific per-GC and per-Screen data. Each screen's CreateGC and
+ CloseScreen functions are wrapped by XineramaCreateGC() and
+ XineramaCloseScreen() respectively. Some new resource classes
+ are created for Xinerama drawables and GCs, and resource types
+ for Xinerama windows, pixmaps and colormaps.
+
+
+ A region (XineramaScreenRegions[i]) is initialized for each
+ physical screen, and single region (PanoramiXScreenRegion) is
+ initialized to be the union of the screen regions. The
+ panoramiXdataPtr[] array is also initialized with the size and
+ origin of each screen. The relative positioning information for
+ the physical screens is taken from the array dixScreenOrigins[],
+ which the DDX layer must initialize in InitOutput(). The bounds
+ of the combined screen is also calculated (PanoramiXPixWidth and
+ PanoramiXPixHeight).
+
+
+ The DIX layer has a list of function pointers (ProcVector[])
+ that holds the entry points for the functions that process core
+ protocol requests. The requests that Xinerama must intercept
+ and break up into physical screen-specific requests are wrapped.
+ The original set is copied to SavedProcVector[]. The types of
+ requests intercepted are Window requests, GC requests, colormap
+ requests, drawing requests, and some geometry-related requests.
+ This wrapping allows the bulk of the protocol request processing
+ to be handled transparently to the DIX layer. Some operations
+ cannot be dealt with in this way and are handled with Xinerama-
+ specific code within the DIX layer.
+
+
+ PPaannoorraammiiXXCCoonnssoolliiddaattee(())
+ PanoramiXConsolidate() is a device-independent extension
+ function that is called directly from the X server's main()
+ function after extensions and input/output devices have been
+ initialized, and before the root windows are defined and
+ initialized.
+
+
+ This function finds the set of depths (PanoramiXDepths[]) and
+ visuals (PanoramiXVisuals[]) common to all of the physical
+ screens. PanoramiXNumDepths is set to the number of common
+ depths, and PanoramiXNumVisuals is set to the number of common
+ visuals. Resources are created for the single root window and
+ the default colormap. Each of these resources has per-physical
+ screen entries.
+
+
+ PPaannoorraammiiXXCCrreeaatteeCCoonnnneeccttiioonnBBlloocckk(())
+ PanoramiXConsolidate() is a device-independent extension
+ function that is called directly from the X server's main()
+ function after the per-physical screen root windows are created.
+ It is called instead of the standard DIX CreateConnectionBlock()
+ function. If this function returns FALSE, the X server exits
+ with a fatal error. This function will return FALSE if no
+ common depths were found in PanoramiXConsolidate(). With no
+ common depths, Xinerama mode is not possible.
+
+
+ The connection block holds the information that clients get when
+ they open a connection to the X server. It includes information
+ such as the supported pixmap formats, number of screens and the
+ sizes, depths, visuals, default colormap information, etc, for
+ each of the screens (much of information that xdpyinfo shows).
+ The connection block is initialized with the combined single
+ screen values that were calculated in the above two functions.
+
+
+ The Xinerama extension allows the registration of connection
+ block callback functions. The purpose of these is to allow
+ other extensions to do processing at this point. These
+ callbacks can be registered by calling
+ XineramaRegisterConnectionBlockCallback() from the other
+ extension's ExtensionInit() function. Each registered
+ connection block callback is called at the end of
+ PanoramiXCreateConnectionBlock().
+
+
+ AA..33..11.. XXiinneerraammaa--ssppeecciiffiicc cchhaannggeess ttoo tthhee DDIIXX ccooddee
+
+ There are a few types of Xinerama-specific changes within the DIX
+ code. The main ones are described here.
+
+
+ Functions that deal with colormap or GC -related operations outside of
+ the intercepted protocol requests have a test added to only do the
+ processing for screen numbers > 0. This is because they are handled
+ for the single Xinerama screen and the processing is done once for
+ screen 0.
+
+
+ The handling of motion events does some coordinate translation between
+ the physical screen's origin and screen zero's origin. Also, motion
+ events must be reported relative to the composite screen origin rather
+ than the physical screen origins.
+
+
+ There is some special handling for cursor, window and event processing
+ that cannot (either not at all or not conveniently) be done via the
+ intercepted protocol requests. A particular case is the handling of
+ pointers moving between physical screens.
+
+
+ AA..33..22.. XXiinneerraammaa--ssppeecciiffiicc cchhaannggeess ttoo tthhee MMII ccooddee
+
+ The only Xinerama-specific change to the MI code is in
+ miSendExposures() to handle the coordinate (and window ID) translation
+ for expose events.
+
+
+
+ AA..33..33.. IInntteerrcceepptteedd DDIIXX ccoorree rreeqquueessttss
+
+ Xinerama breaks up drawing requests for dispatch to each physical
+ screen. It also breaks up windows into pieces for each physical
+ screen. GCs are translated into per-screen GCs. Colormaps are
+ replicated on each physical screen. The functions handling the
+ intercepted requests take care of breaking the requests and
+ repackaging them so that they can be passed to the standard request
+ handling functions for each screen in turn. In addition, and to aid
+ the repackaging, the information from many of the intercepted requests
+ is used to keep up to date the necessary state information for the
+ single composite screen. Requests (usually those with replies) that
+ can be satisfied completely from this stored state information do not
+ call the standard request handling functions.
+
+
+
+ BB.. DDeevveellooppmmeenntt RReessuullttss
+
+ In this section the results of each phase of development are
+ discussed. This development took place between approximately June
+ 2001 and July 2003.
+
+
+ BB..11.. PPhhaassee II
+
+ The initial development phase dealt with the basic implementation
+ including the bootstrap code, which used the shadow framebuffer, and
+ the unoptimized implementation, based on an Xnest-style
+ implementation.
+
+
+ BB..11..11.. SSccooppee
+
+ The goal of Phase I is to provide fundamental functionality that can
+ act as a foundation for ongoing work:
+
+ 1. Develop the proxy X server
+
+ +o The proxy X server will operate on the X11 protocol and relay
+ requests as necessary to correctly perform the request.
+
+ +o Work will be based on the existing work for Xinerama and Xnest.
+
+ +o Input events and windowing operations are handled in the proxy
+ server and rendering requests are repackaged and sent to each of
+ the back-end servers for display.
+
+ +o The multiple screen layout (including support for overlapping
+ screens) will be user configurable via a configuration file or
+ through the configuration tool.
+
+ 2. Develop graphical configuration tool
+
+ +o There will be potentially a large number of X servers to
+ configure into a single display. The tool will allow the user
+ to specify which servers are involved in the configuration and
+ how they should be laid out.
+
+ 3. Pass the X Test Suite
+
+ +o The X Test Suite covers the basic X11 operations. All tests
+ known to succeed must correctly operate in the distributed X
+ environment.
+
+
+ For this phase, the back-end X servers are assumed to be unmodified X
+ servers that do not support any DMX-related protocol extensions;
+ future optimization pathways are considered, but are not implemented;
+ and the configuration tool is assumed to rely only on libraries in the
+ X source tree (e.g., Xt).
+
+
+ BB..11..22.. RReessuullttss
+
+ The proxy X server, Xdmx, was developed to distribute X11 protocol
+ requests to the set of back-end X servers. It opens a window on each
+ back-end server, which represents the part of the front-end's root
+ window that is visible on that screen. It mirrors window, pixmap and
+ other state in each back-end server. Drawing requests are sent to
+ either windows or pixmaps on each back-end server. This code is based
+ on Xnest and uses the existing Xinerama extension.
+
+
+ Input events can be taken from (1) devices attached to the back-end
+ server, (2) core devices attached directly to the Xdmx server, or (3)
+ from a ``console'' window on another X server. Events for these
+ devices are gathered, processed and delivered to clients attached to
+ the Xdmx server.
+
+
+ An intuitive configuration format was developed to help the user
+ easily configure the multiple back-end X servers. It was defined (see
+ grammar in Xdmx man page) and a parser was implemented that is used by
+ the Xdmx server and by a standalone xdmxconfig utility. The parsing
+ support was implemented such that it can be easily factored out of the
+ X source tree for use with other tools (e.g., vdl). Support for
+ converting legacy vdl-format configuration files to the DMX format is
+ provided by the vdltodmx utility.
+
+
+ Originally, the configuration file was going to be a subsection of
+ XFree86's XF86Config file, but that was not possible since Xdmx is a
+ completely separate X server. Thus, a separate config file format was
+ developed. In addition, a graphical configuration tool, xdmxconfig,
+ was developed to allow the user to create and arrange the screens in
+ the configuration file. The --ccoonnffiiggffiillee and --ccoonnffiigg command-line
+ options can be used to start Xdmx using a configuration file.
+
+
+ An extension that enables remote input testing is required for the X
+ Test Suite to function. During this phase, this extension (XTEST) was
+ implemented in the Xdmx server. The results from running the X Test
+ Suite are described in detail below.
+
+
+ BB..11..33.. XX TTeesstt SSuuiittee
+
+ BB..11..33..11.. IInnttrroodduuccttiioonn
+
+ The X Test Suite contains tests that verify Xlib functions operate
+ correctly. The test suite is designed to run on a single X server;
+ however, since X applications will not be able to tell the difference
+ between the DMX server and a standard X server, the X Test Suite
+ should also run on the DMX server.
+
+ The Xdmx server was tested with the X Test Suite, and the existing
+ failures are noted in this section. To put these results in
+ perspective, we first discuss expected X Test failures and how errors
+ in underlying systems can impact Xdmx test results.
+
+
+ BB..11..33..22.. EExxppeecctteedd FFaaiilluurreess ffoorr aa SSiinnggllee HHeeaadd
+
+ A correctly implemented X server with a single screen is expected to
+ fail certain X Test tests. The following well-known errors occur
+ because of rounding error in the X server code:
+
+ XDrawArc: Tests 42, 63, 66, 73
+ XDrawArcs: Tests 45, 66, 69, 76
+
+
+
+ The following failures occur because of the high-level X server
+ implementation:
+
+ XLoadQueryFont: Test 1
+ XListFontsWithInfo: Tests 3, 4
+ XQueryFont: Tests 1, 2
+
+
+
+ The following test fails when running the X server as root under Linux
+ because of the way directory modes are interpreted:
+
+ XWriteBitmapFile: Test 3
+
+
+
+ Depending on the video card used for the back-end, other failures may
+ also occur because of bugs in the low-level driver implementation.
+ Over time, failures of this kind are usually fixed by XFree86, but
+ will show up in Xdmx testing until then.
+
+
+ BB..11..33..33.. EExxppeecctteedd FFaaiilluurreess ffoorr XXiinneerraammaa
+
+ Xinerama fails several X Test Suite tests because of design decisions
+ made for the current implementation of Xinerama. Over time, many of
+ these errors will be corrected by XFree86 and the group working on a
+ new Xinerama implementation. Therefore, Xdmx will also share X Suite
+ Test failures with Xinerama.
+
+ We may be able to fix or work-around some of these failures at the
+ Xdmx level, but this will require additional exploration that was not
+ part of Phase I.
+
+ Xinerama is constantly improving, and the list of Xinerama-related
+ failures depends on XFree86 version and the underlying graphics
+ hardware. We tested with a variety of hardware, including nVidia, S3,
+ ATI Radeon, and Matrox G400 (in dual-head mode). The list below
+ includes only those failures that appear to be from the Xinerama
+ layer, and does not include failures listed in the previous section,
+ or failures that appear to be from the low-level graphics driver
+ itself:
+
+ These failures were noted with multiple Xinerama configurations:
+
+ XCopyPlane: Tests 13, 22, 31 (well-known Xinerama implementation issue)
+ XSetFontPath: Test 4
+ XGetDefault: Test 5
+ XMatchVisualInfo: Test 1
+
+
+
+ These failures were noted only when using one dual-head video card
+ with a 4.2.99.x XFree86 server:
+
+ XListPixmapFormats: Test 1
+ XDrawRectangles: Test 45
+
+
+
+ These failures were noted only when using two video cards from
+ different vendors with a 4.1.99.x XFree86 server:
+
+ XChangeWindowAttributes: Test 32
+ XCreateWindow: Test 30
+ XDrawLine: Test 22
+ XFillArc: Test 22
+ XChangeKeyboardControl: Tests 9, 10
+ XRebindKeysym: Test 1
+
+
+
+ BB..11..33..44.. AAddddiittiioonnaall FFaaiilluurreess ffrroomm XXddmmxx
+
+ When running Xdmx, no unexpected failures were noted. Since the Xdmx
+ server is based on Xinerama, we expect to have most of the Xinerama
+ failures present in the Xdmx server. Similarly, since the Xdmx server
+ must rely on the low-level device drivers on each back-end server, we
+ also expect that Xdmx will exhibit most of the back-end failures.
+ Here is a summary:
+
+ XListPixmapFormats: Test 1 (configuration dependent)
+ XChangeWindowAttributes: Test 32
+ XCreateWindow: Test 30
+ XCopyPlane: Test 13, 22, 31
+ XSetFontPath: Test 4
+ XGetDefault: Test 5 (configuration dependent)
+ XMatchVisualInfo: Test 1
+ XRebindKeysym: Test 1 (configuration dependent)
+
+
+
+ Note that this list is shorter than the combined list for Xinerama
+ because Xdmx uses different code paths to perform some Xinerama
+ operations. Further, some Xinerama failures have been fixed in the
+ XFree86 4.2.99.x CVS repository.
+
+
+ BB..11..33..55.. SSuummmmaarryy aanndd FFuuttuurree WWoorrkk
+
+ Running the X Test Suite on Xdmx does not produce any failures that
+ cannot be accounted for by the underlying Xinerama subsystem used by
+ the front-end or by the low-level device-driver code running on the
+ back-end X servers. The Xdmx server therefore is as ``correct'' as
+ possible with respect to the standard set of X Test Suite tests.
+
+ During the following phases, we will continue to verify Xdmx
+ correctness using the X Test Suite. We may also use other tests
+ suites or write additional tests that run under the X Test Suite that
+ specifically verify the expected behavior of DMX.
+
+
+
+ BB..11..44.. FFoonnttss
+
+ In Phase I, fonts are handled directly by both the front-end and the
+ back-end servers, which is required since we must treat each back-end
+ server during this phase as a ``black box''. What this requires is
+ that tthhee ffrroonntt-- aanndd bbaacckk--eenndd sseerrvveerrss mmuusstt sshhaarree tthhee eexxaacctt ssaammee ffoonntt
+ ppaatthh. There are two ways to help make sure that all servers share the
+ same font path:
+
+
+ 1. First, each server can be configured to use the same font server.
+ The font server, xfs, can be configured to serve fonts to multiple
+ X servers via TCP.
+
+ 2. Second, each server can be configured to use the same font path and
+ either those font paths can be copied to each back-end machine or
+ they can be mounted (e.g., via NFS) on each back-end machine.
+
+
+ One additional concern is that a client program can set its own font
+ path, and if it does so, then that font path must be available on each
+ back-end machine.
+
+
+ The -fontpath command line option was added to allow users to
+ initialize the font path of the front end server. This font path is
+ propagated to each back-end server when the default font is loaded.
+ If there are any problems, an error message is printed, which will
+ describe the problem and list the current font path. For more
+ information about setting the font path, see the -fontpath option
+ description in the man page.
+
+
+ BB..11..55.. PPeerrffoorrmmaannccee
+
+ Phase I of development was not intended to optimize performance. Its
+ focus was on completely and correctly handling the base X11 protocol
+ in the Xdmx server. However, several insights were gained during
+ Phase I, which are listed here for reference during the next phase of
+ development.
+
+
+ 1. Calls to XSync() can slow down rendering since it requires a
+ complete round trip to and from a back-end server. This is
+ especially problematic when communicating over long haul networks.
+
+ 2. Sending drawing requests to only the screens that they overlap
+ should improve performance.
+
+
+ BB..11..66.. PPiixxmmaappss
+
+ Pixmaps were originally expected to be handled entirely in the front-
+ end X server; however, it was found that this overly complicated the
+ rendering code and would have required sending potentially large
+ images to each back server that required them when copying from pixmap
+ to screen. Thus, pixmap state is mirrored in the back-end server just
+ as it is with regular window state. With this implementation, the
+ same rendering code that draws to windows can be used to draw to
+ pixmaps on the back-end server, and no large image transfers are
+ required to copy from pixmap to window.
+
+
+
+ BB..22.. PPhhaassee IIII
+
+ The second phase of development concentrates on performance
+ optimizations. These optimizations are documented here, with x11perf
+ data to show how the optimizations improve performance.
+
+
+ All benchmarks were performed by running Xdmx on a dual processor
+ 1.4GHz AMD Athlon machine with 1GB of RAM connecting over 100baseT to
+ two single-processor 1GHz Pentium III machines with 256MB of RAM and
+ ATI Rage 128 (RF) video cards. The front end was running Linux
+ 2.4.20-pre1-ac1 and the back ends were running Linux 2.4.7-10 and
+ version 4.2.99.1 of XFree86 pulled from the XFree86 CVS repository on
+ August 7, 2002. All systems were running Red Hat Linux 7.2.
+
+
+ BB..22..11.. MMoovviinngg ffrroomm XXFFrreeee8866 44..11..9999..11 ttoo 44..22..00..00
+
+ For phase II, the working source tree was moved to the branch tagged
+ with dmx-1-0-branch and was updated from version 4.1.99.1 (20 August
+ 2001) of the XFree86 sources to version 4.2.0.0 (18 January 2002).
+ After this update, the following tests were noted to be more than 10%
+ faster:
+
+ 1.13 Fill 300x300 opaque stippled trapezoid (161x145 stipple)
+ 1.16 Fill 1x1 tiled trapezoid (161x145 tile)
+ 1.13 Fill 10x10 tiled trapezoid (161x145 tile)
+ 1.17 Fill 100x100 tiled trapezoid (161x145 tile)
+ 1.16 Fill 1x1 tiled trapezoid (216x208 tile)
+ 1.20 Fill 10x10 tiled trapezoid (216x208 tile)
+ 1.15 Fill 100x100 tiled trapezoid (216x208 tile)
+ 1.37 Circulate Unmapped window (200 kids)
+
+
+
+ And the following tests were noted to be more than 10% slower:
+
+ 0.88 Unmap window via parent (25 kids)
+ 0.75 Circulate Unmapped window (4 kids)
+ 0.79 Circulate Unmapped window (16 kids)
+ 0.80 Circulate Unmapped window (25 kids)
+ 0.82 Circulate Unmapped window (50 kids)
+ 0.85 Circulate Unmapped window (75 kids)
+
+
+
+ These changes were not caused by any changes in the DMX system, and
+ may point to changes in the XFree86 tree or to tests that have more
+ "jitter" than most other x11perf tests.
+
+
+ BB..22..22.. GGlloobbaall cchhaannggeess
+
+ During the development of the Phase II DMX server, several global
+ changes were made. These changes were also compared with the Phase I
+ server. The following tests were noted to be more than 10% faster:
+
+
+
+ 1.13 Fill 300x300 opaque stippled trapezoid (161x145 stipple)
+ 1.15 Fill 1x1 tiled trapezoid (161x145 tile)
+ 1.13 Fill 10x10 tiled trapezoid (161x145 tile)
+ 1.17 Fill 100x100 tiled trapezoid (161x145 tile)
+ 1.16 Fill 1x1 tiled trapezoid (216x208 tile)
+ 1.19 Fill 10x10 tiled trapezoid (216x208 tile)
+ 1.15 Fill 100x100 tiled trapezoid (216x208 tile)
+ 1.15 Circulate Unmapped window (4 kids)
+
+
+
+ The following tests were noted to be more than 10% slower:
+
+ 0.69 Scroll 10x10 pixels
+ 0.68 Scroll 100x100 pixels
+ 0.68 Copy 10x10 from window to window
+ 0.68 Copy 100x100 from window to window
+ 0.76 Circulate Unmapped window (75 kids)
+ 0.83 Circulate Unmapped window (100 kids)
+
+
+
+ For the remainder of this analysis, the baseline of comparison will be
+ the Phase II deliverable with all optimizations disabled (unless
+ otherwise noted). This will highlight how the optimizations in
+ isolation impact performance.
+
+
+ BB..22..33.. XXSSyynncc(()) BBaattcchhiinngg
+
+ During the Phase I implementation, XSync() was called after every
+ protocol request made by the DMX server. This provided the DMX server
+ with an interactive feel, but defeated X11's protocol buffering system
+ and introduced round-trip wire latency into every operation. During
+ Phase II, DMX was changed so that protocol requests are no longer
+ followed by calls to XSync(). Instead, the need for an XSync() is
+ noted, and XSync() calls are only made every 100mS or when the DMX
+ server specifically needs to make a call to guarantee interactivity.
+ With this new system, X11 buffers protocol as much as possible during
+ a 100mS interval, and many unnecessary XSync() calls are avoided.
+
+
+ Out of more than 300 x11perf tests, 8 tests became more than 100 times
+ faster, with 68 more than 50X faster, 114 more than 10X faster, and
+ 181 more than 2X faster. See table below for summary.
+
+
+ The following tests were noted to be more than 10% slower with XSync()
+ batching on:
+
+ 0.88 500x500 tiled rectangle (161x145 tile)
+ 0.89 Copy 500x500 from window to window
+
+
+
+ BB..22..44.. OOffffssccrreeeenn OOppttiimmiizzaattiioonn
+
+ Windows span one or more of the back-end servers' screens; however,
+ during Phase I development, windows were created on every back-end
+ server and every rendering request was sent to every window regardless
+ of whether or not that window was visible. With the offscreen
+ optimization, the DMX server tracks when a window is completely off of
+ a back-end server's screen and, in that case, it does not send
+ rendering requests to those back-end windows. This optimization saves
+ bandwidth between the front and back-end servers, and it reduces the
+ number of XSync() calls. The performance tests were run on a DMX
+ system with only two back-end servers. Greater performance gains will
+ be had as the number of back-end servers increases.
+
+
+ Out of more than 300 x11perf tests, 3 tests were at least twice as
+ fast, and 146 tests were at least 10% faster. Two tests were more
+ than 10% slower with the offscreen optimization:
+
+ 0.88 Hide/expose window via popup (4 kids)
+ 0.89 Resize unmapped window (75 kids)
+
+
+
+ BB..22..55.. LLaazzyy WWiinnddooww CCrreeaattiioonn OOppttiimmiizzaattiioonn
+
+ As mentioned above, during Phase I, windows were created on every
+ back-end server even if they were not visible on that back-end. With
+ the lazy window creation optimization, the DMX server does not create
+ windows on a back-end server until they are either visible or they
+ become the parents of a visible window. This optimization builds on
+ the offscreen optimization (described above) and requires it to be
+ enabled.
+
+
+ The lazy window creation optimization works by creating the window
+ data structures in the front-end server when a client creates a
+ window, but delays creation of the window on the back-end server(s).
+ A private window structure in the DMX server saves the relevant window
+ data and tracks changes to the window's attributes and stacking order
+ for later use. The only times a window is created on a back-end
+ server are (1) when it is mapped and is at least partially overlapping
+ the back-end server's screen (tracked by the offscreen optimization),
+ or (2) when the window becomes the parent of a previously visible
+ window. The first case occurs when a window is mapped or when a
+ visible window is copied, moved or resized and now overlaps the back-
+ end server's screen. The second case occurs when starting a window
+ manager after having created windows to which the window manager needs
+ to add decorations.
+
+
+ When either case occurs, a window on the back-end server is created
+ using the data saved in the DMX server's window private data
+ structure. The stacking order is then adjusted to correctly place the
+ window on the back-end and lastly the window is mapped. From this
+ time forward, the window is handled exactly as if the window had been
+ created at the time of the client's request.
+
+
+ Note that when a window is no longer visible on a back-end server's
+ screen (e.g., it is moved offscreen), the window is not destroyed;
+ rather, it is kept and reused later if the window once again becomes
+ visible on the back-end server's screen. Originally with this
+ optimization, destroying windows was implemented but was later
+ rejected because it increased bandwidth when windows were opaquely
+ moved or resized, which is common in many window managers.
+
+
+
+ The performance tests were run on a DMX system with only two back-end
+ servers. Greater performance gains will be had as the number of back-
+ end servers increases.
+
+
+ This optimization improved the following x11perf tests by more than
+ 10%:
+
+ 1.10 500x500 rectangle outline
+ 1.12 Fill 100x100 stippled trapezoid (161x145 stipple)
+ 1.20 Circulate Unmapped window (50 kids)
+ 1.19 Circulate Unmapped window (75 kids)
+
+
+
+ BB..22..66.. SSuubbddiivviiddiinngg RReennddeerriinngg PPrriimmiittiivveess
+
+ X11 imaging requests transfer significant data between the client and
+ the X server. During Phase I, the DMX server would then transfer the
+ image data to each back-end server. Even with the offscreen
+ optimization (above), these requests still required transferring
+ significant data to each back-end server that contained a visible
+ portion of the window. For example, if the client uses XPutImage() to
+ copy an image to a window that overlaps the entire DMX screen, then
+ the entire image is copied by the DMX server to every back-end server.
+
+
+ To reduce the amount of data transferred between the DMX server and
+ the back-end servers when XPutImage() is called, the image data is
+ subdivided and only the data that will be visible on a back-end
+ server's screen is sent to that back-end server. Xinerama already
+ implements a subdivision algorithm for XGetImage() and no further
+ optimization was needed.
+
+
+ Other rendering primitives were analyzed, but the time required to
+ subdivide these primitives was a significant proportion of the time
+ required to send the entire rendering request to the back-end server,
+ so this optimization was rejected for the other rendering primitives.
+
+
+ Again, the performance tests were run on a DMX system with only two
+ back-end servers. Greater performance gains will be had as the number
+ of back-end servers increases.
+
+
+ This optimization improved the following x11perf tests by more than
+ 10%:
+
+ 1.12 Fill 100x100 stippled trapezoid (161x145 stipple)
+ 1.26 PutImage 10x10 square
+ 1.83 PutImage 100x100 square
+ 1.91 PutImage 500x500 square
+ 1.40 PutImage XY 10x10 square
+ 1.48 PutImage XY 100x100 square
+ 1.50 PutImage XY 500x500 square
+ 1.45 Circulate Unmapped window (75 kids)
+ 1.74 Circulate Unmapped window (100 kids)
+
+
+
+ The following test was noted to be more than 10% slower with this
+ optimization:
+
+ 0.88 10-pixel fill chord partial circle
+
+
+
+ BB..22..77.. SSuummmmaarryy ooff xx1111ppeerrff DDaattaa
+
+ With all of the optimizations on, 53 x11perf tests are more than 100X
+ faster than the unoptimized Phase II deliverable, with 69 more than
+ 50X faster, 73 more than 10X faster, and 199 more than twice as fast.
+ No tests were more than 10% slower than the unoptimized Phase II
+ deliverable. (Compared with the Phase I deliverable, only Circulate
+ Unmapped window (100 kids) was more than 10% slower than the Phase II
+ deliverable. As noted above, this test seems to have wider
+ variability than other x11perf tests.)
+
+
+ The following table summarizes relative x11perf test changes for all
+ optimizations individually and collectively. Note that some of the
+ optimizations have a synergistic effect when used together.
+
+
+
+ 1: XSync() batching only
+ 2: Off screen optimizations only
+ 3: Window optimizations only
+ 4: Subdivprims only
+ 5: All optimizations
+
+ 1 2 3 4 5 Operation
+ ------ ---- ---- ---- ------ ---------
+ 2.14 1.85 1.00 1.00 4.13 Dot
+ 1.67 1.80 1.00 1.00 3.31 1x1 rectangle
+ 2.38 1.43 1.00 1.00 2.44 10x10 rectangle
+ 1.00 1.00 0.92 0.98 1.00 100x100 rectangle
+ 1.00 1.00 1.00 1.00 1.00 500x500 rectangle
+ 1.83 1.85 1.05 1.06 3.54 1x1 stippled rectangle (8x8 stipple)
+ 2.43 1.43 1.00 1.00 2.41 10x10 stippled rectangle (8x8 stipple)
+ 0.98 1.00 1.00 1.00 1.00 100x100 stippled rectangle (8x8 stipple)
+ 1.00 1.00 1.00 1.00 0.98 500x500 stippled rectangle (8x8 stipple)
+ 1.75 1.75 1.00 1.00 3.40 1x1 opaque stippled rectangle (8x8 stipple)
+ 2.38 1.42 1.00 1.00 2.34 10x10 opaque stippled rectangle (8x8 stipple)
+ 1.00 1.00 0.97 0.97 1.00 100x100 opaque stippled rectangle (8x8 stipple)
+ 1.00 1.00 1.00 1.00 0.99 500x500 opaque stippled rectangle (8x8 stipple)
+ 1.82 1.82 1.04 1.04 3.56 1x1 tiled rectangle (4x4 tile)
+ 2.33 1.42 1.00 1.00 2.37 10x10 tiled rectangle (4x4 tile)
+ 1.00 0.92 1.00 1.00 1.00 100x100 tiled rectangle (4x4 tile)
+ 1.00 1.00 1.00 1.00 1.00 500x500 tiled rectangle (4x4 tile)
+ 1.94 1.62 1.00 1.00 3.66 1x1 stippled rectangle (17x15 stipple)
+ 1.74 1.28 1.00 1.00 1.73 10x10 stippled rectangle (17x15 stipple)
+ 1.00 1.00 1.00 0.89 0.98 100x100 stippled rectangle (17x15 stipple)
+ 1.00 1.00 1.00 1.00 0.98 500x500 stippled rectangle (17x15 stipple)
+ 1.94 1.62 1.00 1.00 3.67 1x1 opaque stippled rectangle (17x15 stipple)
+ 1.69 1.26 1.00 1.00 1.66 10x10 opaque stippled rectangle (17x15 stipple)
+ 1.00 0.95 1.00 1.00 1.00 100x100 opaque stippled rectangle (17x15 stipple)
+ 1.00 1.00 1.00 1.00 0.97 500x500 opaque stippled rectangle (17x15 stipple)
+ 1.93 1.61 0.99 0.99 3.69 1x1 tiled rectangle (17x15 tile)
+ 1.73 1.27 1.00 1.00 1.72 10x10 tiled rectangle (17x15 tile)
+ 1.00 1.00 1.00 1.00 0.98 100x100 tiled rectangle (17x15 tile)
+ 1.00 1.00 0.97 0.97 1.00 500x500 tiled rectangle (17x15 tile)
+ 1.95 1.63 1.00 1.00 3.83 1x1 stippled rectangle (161x145 stipple)
+ 1.80 1.30 1.00 1.00 1.83 10x10 stippled rectangle (161x145 stipple)
+ 0.97 1.00 1.00 1.00 1.01 100x100 stippled rectangle (161x145 stipple)
+ 1.00 1.00 1.00 1.00 0.98 500x500 stippled rectangle (161x145 stipple)
+ 1.95 1.63 1.00 1.00 3.56 1x1 opaque stippled rectangle (161x145 stipple)
+ 1.65 1.25 1.00 1.00 1.68 10x10 opaque stippled rectangle (161x145 stipple)
+ 1.00 1.00 1.00 1.00 1.01 100x100 opaque stippled rectangle (161x145...
+ 1.00 1.00 1.00 1.00 0.97 500x500 opaque stippled rectangle (161x145...
+ 1.95 1.63 0.98 0.99 3.80 1x1 tiled rectangle (161x145 tile)
+ 1.67 1.26 1.00 1.00 1.67 10x10 tiled rectangle (161x145 tile)
+ 1.13 1.14 1.14 1.14 1.14 100x100 tiled rectangle (161x145 tile)
+ 0.88 1.00 1.00 1.00 0.99 500x500 tiled rectangle (161x145 tile)
+ 1.93 1.63 1.00 1.00 3.53 1x1 tiled rectangle (216x208 tile)
+ 1.69 1.26 1.00 1.00 1.66 10x10 tiled rectangle (216x208 tile)
+ 1.00 1.00 1.00 1.00 1.00 100x100 tiled rectangle (216x208 tile)
+ 1.00 1.00 1.00 1.00 1.00 500x500 tiled rectangle (216x208 tile)
+ 1.82 1.70 1.00 1.00 3.38 1-pixel line segment
+ 2.07 1.56 0.90 1.00 3.31 10-pixel line segment
+ 1.29 1.10 1.00 1.00 1.27 100-pixel line segment
+ 1.05 1.06 1.03 1.03 1.09 500-pixel line segment
+ 1.30 1.13 1.00 1.00 1.29 100-pixel line segment (1 kid)
+ 1.32 1.15 1.00 1.00 1.32 100-pixel line segment (2 kids)
+ 1.33 1.16 1.00 1.00 1.33 100-pixel line segment (3 kids)
+ 1.92 1.64 1.00 1.00 3.73 10-pixel dashed segment
+ 1.34 1.16 1.00 1.00 1.34 100-pixel dashed segment
+ 1.24 1.11 0.99 0.97 1.23 100-pixel double-dashed segment
+ 1.72 1.77 1.00 1.00 3.25 10-pixel horizontal line segment
+ 1.83 1.66 1.01 1.00 3.54 100-pixel horizontal line segment
+ 1.86 1.30 1.00 1.00 1.84 500-pixel horizontal line segment
+ 2.11 1.52 1.00 0.99 3.02 10-pixel vertical line segment
+ 1.21 1.10 1.00 1.00 1.20 100-pixel vertical line segment
+ 1.03 1.03 1.00 1.00 1.02 500-pixel vertical line segment
+ 4.42 1.68 1.00 1.01 4.64 10x1 wide horizontal line segment
+ 1.83 1.31 1.00 1.00 1.83 100x10 wide horizontal line segment
+ 1.07 1.00 0.96 1.00 1.07 500x50 wide horizontal line segment
+ 4.10 1.67 1.00 1.00 4.62 10x1 wide vertical line segment
+ 1.50 1.24 1.06 1.06 1.48 100x10 wide vertical line segment
+ 1.06 1.03 1.00 1.00 1.05 500x50 wide vertical line segment
+ 2.54 1.61 1.00 1.00 3.61 1-pixel line
+ 2.71 1.48 1.00 1.00 2.67 10-pixel line
+ 1.19 1.09 1.00 1.00 1.19 100-pixel line
+ 1.04 1.02 1.00 1.00 1.03 500-pixel line
+ 2.68 1.51 0.98 1.00 3.17 10-pixel dashed line
+ 1.23 1.11 0.99 0.99 1.23 100-pixel dashed line
+ 1.15 1.08 1.00 1.00 1.15 100-pixel double-dashed line
+ 2.27 1.39 1.00 1.00 2.23 10x1 wide line
+ 1.20 1.09 1.00 1.00 1.20 100x10 wide line
+ 1.04 1.02 1.00 1.00 1.04 500x50 wide line
+ 1.52 1.45 1.00 1.00 1.52 100x10 wide dashed line
+ 1.54 1.47 1.00 1.00 1.54 100x10 wide double-dashed line
+ 1.97 1.30 0.96 0.95 1.95 10x10 rectangle outline
+ 1.44 1.27 1.00 1.00 1.43 100x100 rectangle outline
+ 3.22 2.16 1.10 1.09 3.61 500x500 rectangle outline
+ 1.95 1.34 1.00 1.00 1.90 10x10 wide rectangle outline
+ 1.14 1.14 1.00 1.00 1.13 100x100 wide rectangle outline
+ 1.00 1.00 1.00 1.00 1.00 500x500 wide rectangle outline
+ 1.57 1.72 1.00 1.00 3.03 1-pixel circle
+ 1.96 1.35 1.00 1.00 1.92 10-pixel circle
+ 1.21 1.07 0.86 0.97 1.20 100-pixel circle
+ 1.08 1.04 1.00 1.00 1.08 500-pixel circle
+ 1.39 1.19 1.03 1.03 1.38 100-pixel dashed circle
+ 1.21 1.11 1.00 1.00 1.23 100-pixel double-dashed circle
+ 1.59 1.28 1.00 1.00 1.58 10-pixel wide circle
+ 1.22 1.12 0.99 1.00 1.22 100-pixel wide circle
+ 1.06 1.04 1.00 1.00 1.05 500-pixel wide circle
+ 1.87 1.84 1.00 1.00 1.85 100-pixel wide dashed circle
+ 1.90 1.93 1.01 1.01 1.90 100-pixel wide double-dashed circle
+ 2.13 1.43 1.00 1.00 2.32 10-pixel partial circle
+ 1.42 1.18 1.00 1.00 1.42 100-pixel partial circle
+ 1.92 1.85 1.01 1.01 1.89 10-pixel wide partial circle
+ 1.73 1.67 1.00 1.00 1.73 100-pixel wide partial circle
+ 1.36 1.95 1.00 1.00 2.64 1-pixel solid circle
+ 2.02 1.37 1.00 1.00 2.03 10-pixel solid circle
+ 1.19 1.09 1.00 1.00 1.19 100-pixel solid circle
+ 1.02 0.99 1.00 1.00 1.01 500-pixel solid circle
+ 1.74 1.28 1.00 0.88 1.73 10-pixel fill chord partial circle
+ 1.31 1.13 1.00 1.00 1.31 100-pixel fill chord partial circle
+ 1.67 1.31 1.03 1.03 1.72 10-pixel fill slice partial circle
+ 1.30 1.13 1.00 1.00 1.28 100-pixel fill slice partial circle
+ 2.45 1.49 1.01 1.00 2.71 10-pixel ellipse
+ 1.22 1.10 1.00 1.00 1.22 100-pixel ellipse
+ 1.09 1.04 1.00 1.00 1.09 500-pixel ellipse
+ 1.90 1.28 1.00 1.00 1.89 100-pixel dashed ellipse
+ 1.62 1.24 0.96 0.97 1.61 100-pixel double-dashed ellipse
+ 2.43 1.50 1.00 1.00 2.42 10-pixel wide ellipse
+ 1.61 1.28 1.03 1.03 1.60 100-pixel wide ellipse
+ 1.08 1.05 1.00 1.00 1.08 500-pixel wide ellipse
+ 1.93 1.88 1.00 1.00 1.88 100-pixel wide dashed ellipse
+ 1.94 1.89 1.01 1.00 1.94 100-pixel wide double-dashed ellipse
+ 2.31 1.48 1.00 1.00 2.67 10-pixel partial ellipse
+ 1.38 1.17 1.00 1.00 1.38 100-pixel partial ellipse
+ 2.00 1.85 0.98 0.97 1.98 10-pixel wide partial ellipse
+ 1.89 1.86 1.00 1.00 1.89 100-pixel wide partial ellipse
+ 3.49 1.60 1.00 1.00 3.65 10-pixel filled ellipse
+ 1.67 1.26 1.00 1.00 1.67 100-pixel filled ellipse
+ 1.06 1.04 1.00 1.00 1.06 500-pixel filled ellipse
+ 2.38 1.43 1.01 1.00 2.32 10-pixel fill chord partial ellipse
+ 2.06 1.30 1.00 1.00 2.05 100-pixel fill chord partial ellipse
+ 2.27 1.41 1.00 1.00 2.27 10-pixel fill slice partial ellipse
+ 1.98 1.33 1.00 0.97 1.97 100-pixel fill slice partial ellipse
+ 57.46 1.99 1.01 1.00 114.92 Fill 1x1 equivalent triangle
+ 56.94 1.98 1.01 1.00 73.89 Fill 10x10 equivalent triangle
+ 6.07 1.75 1.00 1.00 6.07 Fill 100x100 equivalent triangle
+ 51.12 1.98 1.00 1.00 102.81 Fill 1x1 trapezoid
+ 51.42 1.82 1.01 1.00 94.89 Fill 10x10 trapezoid
+ 6.47 1.80 1.00 1.00 6.44 Fill 100x100 trapezoid
+ 1.56 1.28 1.00 0.99 1.56 Fill 300x300 trapezoid
+ 51.27 1.97 0.96 0.97 102.54 Fill 1x1 stippled trapezoid (8x8 stipple)
+ 51.73 2.00 1.02 1.02 67.92 Fill 10x10 stippled trapezoid (8x8 stipple)
+ 5.36 1.72 1.00 1.00 5.36 Fill 100x100 stippled trapezoid (8x8 stipple)
+ 1.54 1.26 1.00 1.00 1.59 Fill 300x300 stippled trapezoid (8x8 stipple)
+ 51.41 1.94 1.01 1.00 102.82 Fill 1x1 opaque stippled trapezoid (8x8 stipple)
+ 50.71 1.95 0.99 1.00 65.44 Fill 10x10 opaque stippled trapezoid (8x8...
+ 5.33 1.73 1.00 1.00 5.36 Fill 100x100 opaque stippled trapezoid (8x8...
+ 1.58 1.25 1.00 1.00 1.58 Fill 300x300 opaque stippled trapezoid (8x8...
+ 51.56 1.96 0.99 0.90 103.68 Fill 1x1 tiled trapezoid (4x4 tile)
+ 51.59 1.99 1.01 1.01 62.25 Fill 10x10 tiled trapezoid (4x4 tile)
+ 5.38 1.72 1.00 1.00 5.38 Fill 100x100 tiled trapezoid (4x4 tile)
+ 1.54 1.25 1.00 0.99 1.58 Fill 300x300 tiled trapezoid (4x4 tile)
+ 51.70 1.98 1.01 1.01 103.98 Fill 1x1 stippled trapezoid (17x15 stipple)
+ 44.86 1.97 1.00 1.00 44.86 Fill 10x10 stippled trapezoid (17x15 stipple)
+ 2.74 1.56 1.00 1.00 2.73 Fill 100x100 stippled trapezoid (17x15 stipple)
+ 1.29 1.14 1.00 1.00 1.27 Fill 300x300 stippled trapezoid (17x15 stipple)
+ 51.41 1.96 0.96 0.95 103.39 Fill 1x1 opaque stippled trapezoid (17x15...
+ 45.14 1.96 1.01 1.00 45.14 Fill 10x10 opaque stippled trapezoid (17x15...
+ 2.68 1.56 1.00 1.00 2.68 Fill 100x100 opaque stippled trapezoid (17x15...
+ 1.26 1.10 1.00 1.00 1.28 Fill 300x300 opaque stippled trapezoid (17x15...
+ 51.13 1.97 1.00 0.99 103.39 Fill 1x1 tiled trapezoid (17x15 tile)
+ 47.58 1.96 1.00 1.00 47.86 Fill 10x10 tiled trapezoid (17x15 tile)
+ 2.74 1.56 1.00 1.00 2.74 Fill 100x100 tiled trapezoid (17x15 tile)
+ 1.29 1.14 1.00 1.00 1.28 Fill 300x300 tiled trapezoid (17x15 tile)
+ 51.13 1.97 0.99 0.97 103.39 Fill 1x1 stippled trapezoid (161x145 stipple)
+ 45.14 1.97 1.00 1.00 44.29 Fill 10x10 stippled trapezoid (161x145 stipple)
+ 3.02 1.77 1.12 1.12 3.38 Fill 100x100 stippled trapezoid (161x145 stipple)
+ 1.31 1.13 1.00 1.00 1.30 Fill 300x300 stippled trapezoid (161x145 stipple)
+ 51.27 1.97 1.00 1.00 103.10 Fill 1x1 opaque stippled trapezoid (161x145...
+ 45.01 1.97 1.00 1.00 45.01 Fill 10x10 opaque stippled trapezoid (161x145...
+ 2.67 1.56 1.00 1.00 2.69 Fill 100x100 opaque stippled trapezoid (161x145..
+ 1.29 1.13 1.00 1.01 1.27 Fill 300x300 opaque stippled trapezoid (161x145..
+ 51.41 1.96 1.00 0.99 103.39 Fill 1x1 tiled trapezoid (161x145 tile)
+ 45.01 1.96 0.98 1.00 45.01 Fill 10x10 tiled trapezoid (161x145 tile)
+ 2.62 1.36 1.00 1.00 2.69 Fill 100x100 tiled trapezoid (161x145 tile)
+ 1.27 1.13 1.00 1.00 1.22 Fill 300x300 tiled trapezoid (161x145 tile)
+ 51.13 1.98 1.00 1.00 103.39 Fill 1x1 tiled trapezoid (216x208 tile)
+ 45.14 1.97 1.01 0.99 45.14 Fill 10x10 tiled trapezoid (216x208 tile)
+ 2.62 1.55 1.00 1.00 2.71 Fill 100x100 tiled trapezoid (216x208 tile)
+ 1.28 1.13 1.00 1.00 1.20 Fill 300x300 tiled trapezoid (216x208 tile)
+ 50.71 1.95 1.00 1.00 54.70 Fill 10x10 equivalent complex polygon
+ 5.51 1.71 0.96 0.98 5.47 Fill 100x100 equivalent complex polygons
+ 8.39 1.97 1.00 1.00 16.75 Fill 10x10 64-gon (Convex)
+ 8.38 1.83 1.00 1.00 8.43 Fill 100x100 64-gon (Convex)
+ 8.50 1.96 1.00 1.00 16.64 Fill 10x10 64-gon (Complex)
+ 8.26 1.83 1.00 1.00 8.35 Fill 100x100 64-gon (Complex)
+ 14.09 1.87 1.00 1.00 14.05 Char in 80-char line (6x13)
+ 11.91 1.87 1.00 1.00 11.95 Char in 70-char line (8x13)
+ 11.16 1.85 1.01 1.00 11.10 Char in 60-char line (9x15)
+ 10.09 1.78 1.00 1.00 10.09 Char16 in 40-char line (k14)
+ 6.15 1.75 1.00 1.00 6.31 Char16 in 23-char line (k24)
+ 11.92 1.90 1.03 1.03 11.88 Char in 80-char line (TR 10)
+ 8.18 1.78 1.00 0.99 8.17 Char in 30-char line (TR 24)
+ 42.83 1.44 1.01 1.00 42.11 Char in 20/40/20 line (6x13, TR 10)
+ 27.45 1.43 1.01 1.01 27.45 Char16 in 7/14/7 line (k14, k24)
+ 12.13 1.85 1.00 1.00 12.05 Char in 80-char image line (6x13)
+ 10.00 1.84 1.00 1.00 10.00 Char in 70-char image line (8x13)
+ 9.18 1.83 1.00 1.00 9.12 Char in 60-char image line (9x15)
+ 9.66 1.82 0.98 0.95 9.66 Char16 in 40-char image line (k14)
+ 5.82 1.72 1.00 1.00 5.99 Char16 in 23-char image line (k24)
+ 8.70 1.80 1.00 1.00 8.65 Char in 80-char image line (TR 10)
+ 4.67 1.66 1.00 1.00 4.67 Char in 30-char image line (TR 24)
+ 84.43 1.47 1.00 1.00 124.18 Scroll 10x10 pixels
+ 3.73 1.50 1.00 0.98 3.73 Scroll 100x100 pixels
+ 1.00 1.00 1.00 1.00 1.00 Scroll 500x500 pixels
+ 84.43 1.51 1.00 1.00 134.02 Copy 10x10 from window to window
+ 3.62 1.51 0.98 0.98 3.62 Copy 100x100 from window to window
+ 0.89 1.00 1.00 1.00 1.00 Copy 500x500 from window to window
+ 57.06 1.99 1.00 1.00 88.64 Copy 10x10 from pixmap to window
+ 2.49 2.00 1.00 1.00 2.48 Copy 100x100 from pixmap to window
+ 1.00 0.91 1.00 1.00 0.98 Copy 500x500 from pixmap to window
+ 2.04 1.01 1.00 1.00 2.03 Copy 10x10 from window to pixmap
+ 1.05 1.00 1.00 1.00 1.05 Copy 100x100 from window to pixmap
+ 1.00 1.00 0.93 1.00 1.04 Copy 500x500 from window to pixmap
+ 58.52 1.03 1.03 1.02 57.95 Copy 10x10 from pixmap to pixmap
+ 2.40 1.00 1.00 1.00 2.45 Copy 100x100 from pixmap to pixmap
+ 1.00 1.00 1.00 1.00 1.00 Copy 500x500 from pixmap to pixmap
+ 51.57 1.92 1.00 1.00 85.75 Copy 10x10 1-bit deep plane
+ 6.37 1.75 1.01 1.01 6.37 Copy 100x100 1-bit deep plane
+ 1.26 1.11 1.00 1.00 1.24 Copy 500x500 1-bit deep plane
+ 4.23 1.63 0.98 0.97 4.38 Copy 10x10 n-bit deep plane
+ 1.04 1.02 1.00 1.00 1.04 Copy 100x100 n-bit deep plane
+ 1.00 1.00 1.00 1.00 1.00 Copy 500x500 n-bit deep plane
+ 6.45 1.98 1.00 1.26 12.80 PutImage 10x10 square
+ 1.10 1.87 1.00 1.83 2.11 PutImage 100x100 square
+ 1.02 1.93 1.00 1.91 1.91 PutImage 500x500 square
+ 4.17 1.78 1.00 1.40 7.18 PutImage XY 10x10 square
+ 1.27 1.49 0.97 1.48 2.10 PutImage XY 100x100 square
+ 1.00 1.50 1.00 1.50 1.52 PutImage XY 500x500 square
+ 1.07 1.01 1.00 1.00 1.06 GetImage 10x10 square
+ 1.01 1.00 1.00 1.00 1.01 GetImage 100x100 square
+ 1.00 1.00 1.00 1.00 1.00 GetImage 500x500 square
+ 1.56 1.00 0.99 0.97 1.56 GetImage XY 10x10 square
+ 1.02 1.00 1.00 1.00 1.02 GetImage XY 100x100 square
+ 1.00 1.00 1.00 1.00 1.00 GetImage XY 500x500 square
+ 1.00 1.00 1.01 0.98 0.95 X protocol NoOperation
+ 1.02 1.03 1.04 1.03 1.00 QueryPointer
+ 1.03 1.02 1.04 1.03 1.00 GetProperty
+ 100.41 1.51 1.00 1.00 198.76 Change graphics context
+ 45.81 1.00 0.99 0.97 57.10 Create and map subwindows (4 kids)
+ 78.45 1.01 1.02 1.02 63.07 Create and map subwindows (16 kids)
+ 73.91 1.01 1.00 1.00 56.37 Create and map subwindows (25 kids)
+ 73.22 1.00 1.00 1.00 49.07 Create and map subwindows (50 kids)
+ 72.36 1.01 0.99 1.00 32.14 Create and map subwindows (75 kids)
+ 70.34 1.00 1.00 1.00 30.12 Create and map subwindows (100 kids)
+ 55.00 1.00 1.00 0.99 23.75 Create and map subwindows (200 kids)
+ 55.30 1.01 1.00 1.00 141.03 Create unmapped window (4 kids)
+ 55.38 1.01 1.01 1.00 163.25 Create unmapped window (16 kids)
+ 54.75 0.96 1.00 0.99 166.95 Create unmapped window (25 kids)
+ 54.83 1.00 1.00 0.99 178.81 Create unmapped window (50 kids)
+ 55.38 1.01 1.01 1.00 181.20 Create unmapped window (75 kids)
+ 55.38 1.01 1.01 1.00 181.20 Create unmapped window (100 kids)
+ 54.87 1.01 1.01 1.00 182.05 Create unmapped window (200 kids)
+ 28.13 1.00 1.00 1.00 30.75 Map window via parent (4 kids)
+ 36.14 1.01 1.01 1.01 32.58 Map window via parent (16 kids)
+ 26.13 1.00 0.98 0.95 29.85 Map window via parent (25 kids)
+ 40.07 1.00 1.01 1.00 27.57 Map window via parent (50 kids)
+ 23.26 0.99 1.00 1.00 18.23 Map window via parent (75 kids)
+ 22.91 0.99 1.00 0.99 16.52 Map window via parent (100 kids)
+ 27.79 1.00 1.00 0.99 12.50 Map window via parent (200 kids)
+ 22.35 1.00 1.00 1.00 56.19 Unmap window via parent (4 kids)
+ 9.57 1.00 0.99 1.00 89.78 Unmap window via parent (16 kids)
+ 80.77 1.01 1.00 1.00 103.85 Unmap window via parent (25 kids)
+ 96.34 1.00 1.00 1.00 116.06 Unmap window via parent (50 kids)
+ 99.72 1.00 1.00 1.00 124.93 Unmap window via parent (75 kids)
+ 112.36 1.00 1.00 1.00 125.27 Unmap window via parent (100 kids)
+ 105.41 1.00 1.00 0.99 120.00 Unmap window via parent (200 kids)
+ 51.29 1.03 1.02 1.02 74.19 Destroy window via parent (4 kids)
+ 86.75 0.99 0.99 0.99 116.87 Destroy window via parent (16 kids)
+ 106.43 1.01 1.01 1.01 127.49 Destroy window via parent (25 kids)
+ 120.34 1.01 1.01 1.00 140.11 Destroy window via parent (50 kids)
+ 126.67 1.00 0.99 0.99 145.00 Destroy window via parent (75 kids)
+ 126.11 1.01 1.01 1.00 140.56 Destroy window via parent (100 kids)
+ 128.57 1.01 1.00 1.00 137.91 Destroy window via parent (200 kids)
+ 16.04 0.88 1.00 1.00 20.36 Hide/expose window via popup (4 kids)
+ 19.04 1.01 1.00 1.00 23.48 Hide/expose window via popup (16 kids)
+ 19.22 1.00 1.00 1.00 20.44 Hide/expose window via popup (25 kids)
+ 17.41 1.00 0.91 0.97 17.68 Hide/expose window via popup (50 kids)
+ 17.29 1.01 1.00 1.01 17.07 Hide/expose window via popup (75 kids)
+ 16.74 1.00 1.00 1.00 16.17 Hide/expose window via popup (100 kids)
+ 10.30 1.00 1.00 1.00 10.51 Hide/expose window via popup (200 kids)
+ 16.48 1.01 1.00 1.00 26.05 Move window (4 kids)
+ 17.01 0.95 1.00 1.00 23.97 Move window (16 kids)
+ 16.95 1.00 1.00 1.00 22.90 Move window (25 kids)
+ 16.05 1.01 1.00 1.00 21.32 Move window (50 kids)
+ 15.58 1.00 0.98 0.98 19.44 Move window (75 kids)
+ 14.98 1.02 1.03 1.03 18.17 Move window (100 kids)
+ 10.90 1.01 1.01 1.00 12.68 Move window (200 kids)
+ 49.42 1.00 1.00 1.00 198.27 Moved unmapped window (4 kids)
+ 50.72 0.97 1.00 1.00 193.66 Moved unmapped window (16 kids)
+ 50.87 1.00 0.99 1.00 195.09 Moved unmapped window (25 kids)
+ 50.72 1.00 1.00 1.00 189.34 Moved unmapped window (50 kids)
+ 50.87 1.00 1.00 1.00 191.33 Moved unmapped window (75 kids)
+ 50.87 1.00 1.00 0.90 186.71 Moved unmapped window (100 kids)
+ 50.87 1.00 1.00 1.00 179.19 Moved unmapped window (200 kids)
+ 41.04 1.00 1.00 1.00 56.61 Move window via parent (4 kids)
+ 69.81 1.00 1.00 1.00 130.82 Move window via parent (16 kids)
+ 95.81 1.00 1.00 1.00 141.92 Move window via parent (25 kids)
+ 95.98 1.00 1.00 1.00 149.43 Move window via parent (50 kids)
+ 96.59 1.01 1.01 1.00 153.98 Move window via parent (75 kids)
+ 97.19 1.00 1.00 1.00 157.30 Move window via parent (100 kids)
+ 96.67 1.00 0.99 0.96 159.44 Move window via parent (200 kids)
+ 17.75 1.01 1.00 1.00 27.61 Resize window (4 kids)
+ 17.94 1.00 1.00 0.99 25.42 Resize window (16 kids)
+ 17.92 1.01 1.00 1.00 24.47 Resize window (25 kids)
+ 17.24 0.97 1.00 1.00 24.14 Resize window (50 kids)
+ 16.81 1.00 1.00 0.99 22.75 Resize window (75 kids)
+ 16.08 1.00 1.00 1.00 21.20 Resize window (100 kids)
+ 12.92 1.00 0.99 1.00 16.26 Resize window (200 kids)
+ 52.94 1.01 1.00 1.00 327.12 Resize unmapped window (4 kids)
+ 53.60 1.01 1.01 1.01 333.71 Resize unmapped window (16 kids)
+ 52.99 1.00 1.00 1.00 337.29 Resize unmapped window (25 kids)
+ 51.98 1.00 1.00 1.00 329.38 Resize unmapped window (50 kids)
+ 53.05 0.89 1.00 1.00 322.60 Resize unmapped window (75 kids)
+ 53.05 1.00 1.00 1.00 318.08 Resize unmapped window (100 kids)
+ 53.11 1.00 1.00 0.99 306.21 Resize unmapped window (200 kids)
+ 16.76 1.00 0.96 1.00 19.46 Circulate window (4 kids)
+ 17.24 1.00 1.00 0.97 16.24 Circulate window (16 kids)
+ 16.30 1.03 1.03 1.03 15.85 Circulate window (25 kids)
+ 13.45 1.00 1.00 1.00 14.90 Circulate window (50 kids)
+ 12.91 1.00 1.00 1.00 13.06 Circulate window (75 kids)
+ 11.30 0.98 1.00 1.00 11.03 Circulate window (100 kids)
+ 7.58 1.01 1.01 0.99 7.47 Circulate window (200 kids)
+ 1.01 1.01 0.98 1.00 0.95 Circulate Unmapped window (4 kids)
+ 1.07 1.07 1.01 1.07 1.02 Circulate Unmapped window (16 kids)
+ 1.04 1.09 1.06 1.05 0.97 Circulate Unmapped window (25 kids)
+ 1.04 1.23 1.20 1.18 1.05 Circulate Unmapped window (50 kids)
+ 1.18 1.53 1.19 1.45 1.24 Circulate Unmapped window (75 kids)
+ 1.08 1.02 1.01 1.74 1.01 Circulate Unmapped window (100 kids)
+ 1.01 1.12 0.98 0.91 0.97 Circulate Unmapped window (200 kids)
+
+
+
+ BB..22..88.. PPrrooffiilliinngg wwiitthh OOPPrrooffiillee
+
+ OProfile (available from http://oprofile.sourceforge.net/) is a
+ system-wide profiler for Linux systems that uses processor-level
+ counters to collect sampling data. OProfile can provide information
+ that is similar to that provided by gprof, but without the necessity
+ of recompiling the program with special instrumentation (i.e.,
+ OProfile can collect statistical profiling information about optimized
+ programs). A test harness was developed to collect OProfile data for
+ each x11perf test individually.
+
+
+ Test runs were performed using the RETIRED_INSNS counter on the AMD
+ Athlon and the CPU_CLK_HALTED counter on the Intel Pentium III (with a
+ test configuration different from the one described above). We have
+ examined OProfile output and have compared it with gprof output. This
+ investigation has not produced results that yield performance
+ increases in x11perf numbers.
+
+
+
+ BB..22..99.. XX TTeesstt SSuuiittee
+
+ The X Test Suite was run on the fully optimized DMX server using the
+ configuration described above. The following failures were noted:
+
+ XListPixmapFormats: Test 1 [1]
+ XChangeWindowAttributes: Test 32 [1]
+ XCreateWindow: Test 30 [1]
+ XFreeColors: Test 4 [3]
+ XCopyArea: Test 13, 17, 21, 25, 30 [2]
+ XCopyPlane: Test 11, 15, 27, 31 [2]
+ XSetFontPath: Test 4 [1]
+ XChangeKeyboardControl: Test 9, 10 [1]
+
+ [1] Previously documented errors expected from the Xinerama
+ implementation (see Phase I discussion).
+ [2] Newly noted errors that have been verified as expected
+ behavior of the Xinerama implementation.
+ [3] Newly noted error that has been verified as a Xinerama
+ implementation bug.
+
+
+
+ BB..33.. PPhhaassee IIIIII
+
+ During the third phase of development, support was provided for the
+ following extensions: SHAPE, RENDER, XKEYBOARD, XInput.
+
+
+ BB..33..11.. SSHHAAPPEE
+
+ The SHAPE extension is supported. Test applications (e.g., xeyes and
+ oclock) and window managers that make use of the SHAPE extension will
+ work as expected.
+
+
+ BB..33..22.. RREENNDDEERR
+
+ The RENDER extension is supported. The version included in the DMX
+ CVS tree is version 0.2, and this version is fully supported by Xdmx.
+ Applications using only version 0.2 functions will work correctly;
+ however, some apps that make use of functions from later versions do
+ not properly check the extension's major/minor version numbers. These
+ apps will fail with a Bad Implementation error when using post-version
+ 0.2 functions. This is expected behavior. When the DMX CVS tree is
+ updated to include newer versions of RENDER, support for these newer
+ functions will be added to the DMX X server.
+
+
+ BB..33..33.. XXKKEEYYBBOOAARRDD
+
+ The XKEYBOARD extension is supported. If present on the back-end X
+ servers, the XKEYBOARD extension will be used to obtain information
+ about the type of the keyboard for initialization. Otherwise, the
+ keyboard will be initialized using defaults. Note that this departs
+ from older behavior: when Xdmx is compiled without XKEYBOARD support,
+ the map from the back-end X server will be preserved. With XKEYBOARD
+ support, the map is not preserved because better information and
+ control of the keyboard is available.
+
+
+ BB..33..44.. XXIInnppuutt
+
+ The XInput extension is supported. Any device can be used as a core
+ device and be used as an XInput extension device, with the exception
+ of core devices on the back-end servers. This limitation is present
+ because cursor handling on the back-end requires that the back-end
+ cursor sometimes track the Xdmx core cursor -- behavior that is
+ incompatible with using the back-end pointer as a non-core device.
+
+
+ Currently, back-end extension devices are not available as Xdmx
+ extension devices, but this limitation should be removed in the
+ future.
+
+
+ To demonstrate the XInput extension, and to provide more examples for
+ low-level input device driver writers, USB device drivers have been
+ written for mice (usb-mou), keyboards (usb-kbd), and non-mouse/non-
+ keyboard USB devices (usb-oth). Please see the man page for
+ information on Linux kernel drivers that are required for using these
+ Xdmx drivers.
+
+
+ BB..33..55.. DDPPMMSS
+
+ The DPMS extension is exported but does not do anything at this time.
+
+
+ BB..33..66.. OOtthheerr EExxtteennssiioonnss
+
+ The LBX, SECURITY, XC-APPGROUP, and XFree86-Bigfont extensions do not
+ require any special Xdmx support and have been exported.
+
+
+ The BIG-REQUESTS, DEC-XTRAP, DOUBLE-BUFFER, Extended-Visual-
+ Information, FontCache, GLX, MIT-SCREEN-SAVER, MIT-SHM, MIT-SUNDRY-
+ NONSTANDARD, RECORD, SECURITY, SGI-GLX, SYNC, TOG-CUP, X-Resource, XC-
+ MISC, XFree86-DGA, XFree86-DRI, XFree86-Misc,
+ XFree86-VidModeExtension, and XVideo extensions are _n_o_t supported at
+ this time, but will be evaluated for inclusion in future DMX releases.
+ SSeeee bbeellooww ffoorr aaddddiittiioonnaall wwoorrkk oonn eexxtteennssiioonnss aafftteerr PPhhaassee IIIIII..
+
+
+ BB..44.. PPhhaassee IIVV
+
+ BB..44..11.. MMoovviinngg ttoo XXFFrreeee8866 44..33..00
+
+ For Phase IV, the recent release of XFree86 4.3.0 (27 February 2003)
+ was merged onto the dmx.sourceforge.net CVS trunk and all work is
+ proceeding using this tree.
+
+
+ BB..44..22.. EExxtteennssiioonnss
+
+ BB..44..22..11.. XXCC--MMIISSCC ((ssuuppppoorrtteedd))
+
+ XC-MISC is used internally by the X library to recycle XIDs from the X
+ server. This is important for long-running X server sessions. Xdmx
+ supports this extension. The X Test Suite passed and failed the exact
+ same tests before and after this extension was enabled.
+
+
+ BB..44..22..22.. EExxtteennddeedd--VViissuuaall--IInnffoorrmmaattiioonn ((ssuuppppoorrtteedd))
+
+ The Extended-Visual-Information extension provides a method for an X
+ client to obtain detailed visual information. Xdmx supports this
+ extension. It was tested using the hw/dmx/examples/evi example
+ program. NNoottee tthhaatt tthhiiss eexxtteennssiioonn iiss nnoott XXiinneerraammaa--aawwaarree -- it will
+ return visual information for each screen even though Xinerama is
+ causing the X server to export a single logical screen.
+
+
+ BB..44..22..33.. RREESS ((ssuuppppoorrtteedd))
+
+ The X-Resource extension provides a mechanism for a client to obtain
+ detailed information about the resources used by other clients. This
+ extension was tested with the hw/dmx/examples/res program. The X Test
+ Suite passed and failed the exact same tests before and after this
+ extension was enabled.
+
+
+ BB..44..22..44.. BBIIGG--RREEQQUUEESSTTSS ((ssuuppppoorrtteedd))
+
+ This extension enables the X11 protocol to handle requests longer than
+ 262140 bytes. The X Test Suite passed and failed the exact same tests
+ before and after this extension was enabled.
+
+
+ BB..44..22..55.. XXSSYYNNCC ((ssuuppppoorrtteedd))
+
+ This extension provides facilities for two different X clients to
+ synchronize their requests. This extension was minimally tested with
+ xdpyinfo and the X Test Suite passed and failed the exact same tests
+ before and after this extension was enabled.
+
+
+ BB..44..22..66.. XXTTEESSTT,, RREECCOORRDD,, DDEECC--XXTTRRAAPP ((ssuuppppoorrtteedd)) aanndd XXTTeessttEExxtteennssiioonn11
+ ((nnoott ssuuppppoorrtteedd))
+
+ The XTEST and RECORD extension were developed by the X Consortium for
+ use in the X Test Suite and are supported as a standard in the X11R6
+ tree. They are also supported in Xdmx. When X Test Suite tests that
+ make use of the XTEST extension are run, Xdmx passes and fails exactly
+ the same tests as does a standard XFree86 X server. When the rcrdtest
+ test (a part of the X Test Suite that verifies the RECORD extension)
+ is run, Xdmx passes and fails exactly the same tests as does a
+ standard XFree86 X server.
+
+
+ There are two older XTEST-like extensions: DEC-XTRAP and
+ XTestExtension1. The XTestExtension1 extension was developed for use
+ by the X Testing Consortium for use with a test suite that eventually
+ became (part of?) the X Test Suite. Unlike XTEST, which only allows
+ events to be sent to the server, the XTestExtension1 extension also
+ allowed events to be recorded (similar to the RECORD extension). The
+ second is the DEC-XTRAP extension that was developed by the Digital
+ Equipment Corporation.
+
+
+ The DEC-XTRAP extension is available from Xdmx and has been tested
+ with the xtrap* tools which are distributed as standard X11R6 clients.
+
+
+ The XTestExtension1 is _n_o_t supported because it does not appear to be
+ used by any modern X clients (the few that support it also support
+ XTEST) and because there are no good methods available for testing
+ that it functions correctly (unlike XTEST and DEC-XTRAP, the code for
+ XTestExtension1 is not part of the standard X server source tree, so
+ additional testing is important).
+
+
+ Most of these extensions are documented in the X11R6 source tree.
+ Further, several original papers exist that this author was unable to
+ locate -- for completeness and historical interest, citations are
+ provide:
+
+ XXRREECCOORRDD
+ Martha Zimet. Extending X For Recording. 8th Annual X Technical
+ Conference Boston, MA January 24-26, 1994.
+
+ DDEECC--XXTTRRAAPP
+ Dick Annicchiarico, Robert Chesler, Alan Jamison. XTrap
+ Architecture. Digital Equipment Corporation, July 1991.
+
+ XXTTeessttEExxtteennssiioonn11
+ Larry Woestman. X11 Input Synthesis Extension Proposal. Hewlett
+ Packard, November 1991.
+
+
+ BB..44..22..77.. MMIITT--MMIISSCC ((nnoott ssuuppppoorrtteedd))
+
+ The MIT-MISC extension is used to control a bug-compatibility flag
+ that provides compatibility with xterm programs from X11R1 and X11R2.
+ There does not appear to be a single client available that makes use
+ of this extension and there is not way to verify that it works
+ correctly. The Xdmx server does _n_o_t support MIT-MISC.
+
+
+ BB..44..22..88.. SSCCRREEEENNSSAAVVEERR ((nnoott ssuuppppoorrtteedd))
+
+ This extension provides special support for the X screen saver. It
+ was tested with beforelight, which appears to be the only client that
+ works with it. When Xinerama was not active, beforelight behaved as
+ expected. However, when Xinerama was active, beforelight did not
+ behave as expected. Further, when this extension is not active,
+ xscreensaver (a widely-used X screen saver program) did not behave as
+ expected. Since this extension is not Xinerama-aware and is not
+ commonly used with expected results by clients, we have left this
+ extension disabled at this time.
+
+ BB..44..22..99.. GGLLXX ((ssuuppppoorrtteedd))
+
+ The GLX extension provides OpenGL and GLX windowing support. In Xdmx,
+ the extension is called glxProxy, and it is Xinerama aware. It works
+ by either feeding requests forward through Xdmx to each of the back-
+ end servers or handling them locally. All rendering requests are
+ handled on the back-end X servers. This code was donated to the DMX
+ project by SGI. For the X Test Suite results comparison, see below.
+
+
+ BB..44..22..1100.. RREENNDDEERR ((ssuuppppoorrtteedd))
+
+ The X Rendering Extension (RENDER) provides support for digital image
+ composition. Geometric and text rendering are supported. RENDER is
+ partially Xinerama-aware, with text and the most basic compositing
+ operator; however, its higher level primitives (triangles, triangle
+ strips, and triangle fans) are not yet Xinerama-aware. The RENDER
+ extension is still under development, and is currently at version 0.8.
+ Additional support will be required in DMX as more primitives and/or
+ requests are added to the extension.
+
+
+ There is currently no test suite for the X Rendering Extension;
+ however, there has been discussion of developing a test suite as the
+ extension matures. When that test suite becomes available, additional
+ testing can be performed with Xdmx. The X Test Suite passed and
+ failed the exact same tests before and after this extension was
+ enabled.
+
+
+ BB..44..22..1111.. SSuummmmaarryy
+
+ To summarize, the following extensions are currently supported: BIG-
+ REQUESTS, DEC-XTRAP, DMX, DPMS, Extended-Visual-Information, GLX, LBX,
+ RECORD, RENDER, SECURITY, SHAPE, SYNC, X-Resource, XC-APPGROUP, XC-
+ MISC, XFree86-Bigfont, XINERAMA, XInputExtension, XKEYBOARD, and
+ XTEST.
+
+
+ The following extensions are _n_o_t supported at this time: DOUBLE-
+ BUFFER, FontCache, MIT-SCREEN-SAVER, MIT-SHM, MIT-SUNDRY-NONSTANDARD,
+ TOG-CUP, XFree86-DGA, XFree86-Misc, XFree86-VidModeExtension,
+ XTestExtensionExt1, and XVideo.
+
+
+ BB..44..33.. AAddddiittiioonnaall TTeessttiinngg wwiitthh tthhee XX TTeesstt SSuuiittee
+
+ BB..44..33..11.. XXFFrreeee8866 wwiitthhoouutt XXTTEESSTT
+
+ After the release of XFree86 4.3.0, we retested the XFree86 X server
+ with and without using the XTEST extension. When the XTEST extension
+ was _n_o_t used for testing, the XFree86 4.3.0 server running on our
+ usual test system with a Radeon VE card reported unexpected failures
+ in the following tests:
+
+ XListPixmapFormats: Test 1
+ XChangeKeyboardControl: Tests 9, 10
+ XGetDefault: Test 5
+ XRebindKeysym: Test 1
+
+
+
+ BB..44..33..22.. XXFFrreeee8866 wwiitthh XXTTEESSTT
+
+ When using the XTEST extension, the XFree86 4.3.0 server reported the
+ following errors:
+
+ XListPixmapFormats: Test 1
+ XChangeKeyboardControl: Tests 9, 10
+ XGetDefault: Test 5
+ XRebindKeysym: Test 1
+
+ XAllowEvents: Tests 20, 21, 24
+ XGrabButton: Tests 5, 9-12, 14, 16, 19, 21-25
+ XGrabKey: Test 8
+ XSetPointerMapping: Test 3
+ XUngrabButton: Test 4
+
+
+
+ While these errors may be important, they will probably be fixed
+ eventually in the XFree86 source tree. We are particularly interested
+ in demonstrating that the Xdmx server does not introduce additional
+ failures that are not known Xinerama failures.
+
+
+ BB..44..33..33.. XXddmmxx wwiitthh XXTTEESSTT,, wwiitthhoouutt XXiinneerraammaa,, wwiitthhoouutt GGLLXX
+
+ Without Xinerama, but using the XTEST extension, the following errors
+ were reported from Xdmx (note that these are the same as for the
+ XFree86 4.3.0, except that XGetDefault no longer fails):
+
+ XListPixmapFormats: Test 1
+ XChangeKeyboardControl: Tests 9, 10
+ XRebindKeysym: Test 1
+
+ XAllowEvents: Tests 20, 21, 24
+ XGrabButton: Tests 5, 9-12, 14, 16, 19, 21-25
+ XGrabKey: Test 8
+ XSetPointerMapping: Test 3
+ XUngrabButton: Test 4
+
+
+
+ BB..44..33..44.. XXddmmxx wwiitthh XXTTEESSTT,, wwiitthh XXiinneerraammaa,, wwiitthhoouutt GGLLXX
+
+ With Xinerama, using the XTEST extension, the following errors were
+ reported from Xdmx:
+
+ XListPixmapFormats: Test 1
+ XChangeKeyboardControl: Tests 9, 10
+ XRebindKeysym: Test 1
+
+ XAllowEvents: Tests 20, 21, 24
+ XGrabButton: Tests 5, 9-12, 14, 16, 19, 21-25
+ XGrabKey: Test 8
+ XSetPointerMapping: Test 3
+ XUngrabButton: Test 4
+
+ XCopyPlane: Tests 13, 22, 31 (well-known XTEST/Xinerama interaction issue)
+ XDrawLine: Test 67
+ XDrawLines: Test 91
+ XDrawSegments: Test 68
+
+
+
+ Note that the first two sets of errors are the same as for the XFree86
+ 4.3.0 server, and that the XCopyPlane error is a well-known error
+ resulting from an XTEST/Xinerama interaction when the request crosses
+ a screen boundary. The XDraw* errors are resolved when the tests are
+ run individually and they do not cross a screen boundary. We will
+ investigate these errors further to determine their cause.
+
+
+ BB..44..33..55.. XXddmmxx wwiitthh XXTTEESSTT,, wwiitthh XXiinneerraammaa,, wwiitthh GGLLXX
+
+ With GLX enabled, using the XTEST extension, the following errors were
+ reported from Xdmx (these results are from early during the Phase IV
+ development, but were confirmed with a late Phase IV snapshot):
+
+ XListPixmapFormats: Test 1
+ XChangeKeyboardControl: Tests 9, 10
+ XRebindKeysym: Test 1
+
+ XAllowEvents: Tests 20, 21, 24
+ XGrabButton: Tests 5, 9-12, 14, 16, 19, 21-25
+ XGrabKey: Test 8
+ XSetPointerMapping: Test 3
+ XUngrabButton: Test 4
+
+ XClearArea: Test 8
+ XCopyArea: Tests 4, 5, 11, 14, 17, 23, 25, 27, 30
+ XCopyPlane: Tests 6, 7, 10, 19, 22, 31
+ XDrawArcs: Tests 89, 100, 102
+ XDrawLine: Test 67
+ XDrawSegments: Test 68
+
+
+ Note that the first two sets of errors are the same as for the XFree86
+ 4.3.0 server, and that the third set has different failures than when
+ Xdmx does not include GLX support. Since the GLX extension adds new
+ visuals to support GLX's visual configs and the X Test Suite runs
+ tests over the entire set of visuals, additional rendering tests were
+ run and presumably more of them crossed a screen boundary. This con-
+ clusion is supported by the fact that nearly all of the rendering
+ errors reported are resolved when the tests are run individually and
+ they do no cross a screen boundary.
+
+
+ Further, when hardware rendering is disabled on the back-end displays,
+ many of the errors in the third set are eliminated, leaving only:
+
+ XClearArea: Test 8
+ XCopyArea: Test 4, 5, 11, 14, 17, 23, 25, 27, 30
+ XCopyPlane: Test 6, 7, 10, 19, 22, 31
+
+
+
+ BB..44..33..66.. CCoonncclluussiioonn
+
+ We conclude that all of the X Test Suite errors reported for Xdmx are
+ the result of errors in the back-end X server or the Xinerama
+ implementation. Further, all of these errors that can be reasonably
+ fixed at the Xdmx layer have been. (Where appropriate, we have
+ submitted patches to the XFree86 and Xinerama upstream maintainers.)
+
+
+ BB..44..44.. DDyynnaammiicc RReeccoonnffiigguurraattiioonn
+
+ During this development phase, dynamic reconfiguration support was
+ added to DMX. This support allows an application to change the
+ position and offset of a back-end server's screen. For example, if
+ the application would like to shift a screen slightly to the left, it
+ could query Xdmx for the screen's <x,y> position and then dynamically
+ reconfigure that screen to be at position <x+10,y>. When a screen is
+ dynamically reconfigured, input handling and a screen's root window
+ dimensions are adjusted as needed. These adjustments are transparent
+ to the user.
+
+
+ BB..44..44..11.. DDyynnaammiicc rreeccoonnffiigguurraattiioonn eexxtteennssiioonn
+
+ The application interface to DMX's dynamic reconfiguration is through
+ a function in the DMX extension library:
+
+ Bool DMXReconfigureScreen(Display *dpy, int screen, int x, int y)
+
+
+ where _d_p_y is DMX server's display, _s_c_r_e_e_n is the number of the screen
+ to be reconfigured, and _x and _y are the new upper, left-hand coordi-
+ nates of the screen to be reconfigured.
+
+
+ The coordinates are not limited other than as required by the X
+ protocol, which limits all coordinates to a signed 16 bit number. In
+ addition, all coordinates within a screen must also be legal values.
+ Therefore, setting a screen's upper, left-hand coordinates such that
+ the right or bottom edges of the screen is greater than 32,767 is
+ illegal.
+
+
+ BB..44..44..22.. BBoouunnddiinngg bbooxx
+
+ When the Xdmx server is started, a bounding box is calculated from the
+ screens' layout given either on the command line or in the
+ configuration file. This bounding box is currently fixed for the
+ lifetime of the Xdmx server.
+
+
+ While it is possible to move a screen outside of the bounding box, it
+ is currently not possible to change the dimensions of the bounding
+ box. For example, it is possible to specify coordinates of
+ <-100,-100> for the upper, left-hand corner of the bounding box, which
+ was previously at coordinates <0,0>. As expected, the screen is moved
+ down and to the right; however, since the bounding box is fixed, the
+ left side and upper portions of the screen exposed by the
+ reconfiguration are no longer accessible on that screen. Those
+ inaccessible regions are filled with black.
+
+
+ This fixed bounding box limitation will be addressed in a future
+ development phase.
+
+
+ BB..44..44..33.. SSaammppllee aapppplliiccaattiioonnss
+
+ An example of where this extension is useful is in setting up a video
+ wall. It is not always possible to get everything perfectly aligned,
+ and sometimes the positions are changed (e.g., someone might bump into
+ a projector). Instead of physically moving projectors or monitors, it
+ is now possible to adjust the positions of the back-end server's
+ screens using the dynamic reconfiguration support in DMX.
+
+
+ Other applications, such as automatic setup and calibration tools, can
+ make use of dynamic reconfiguration to correct for projector alignment
+ problems, as long as the projectors are still arranged rectilinearly.
+ Horizontal and vertical keystone correction could be applied to
+ projectors to correct for non-rectilinear alignment problems; however,
+ this must be done external to Xdmx.
+
+
+ A sample test program is included in the DMX server's examples
+ directory to demonstrate the interface and how an application might
+ use dynamic reconfiguration. See dmxreconfig.c for details.
+
+
+ BB..44..44..44.. AAddddiittiioonnaall nnootteess
+
+ In the original development plan, Phase IV was primarily devoted to
+ adding OpenGL support to DMX; however, SGI became interested in the
+ DMX project and developed code to support OpenGL/GLX. This code was
+ later donated to the DMX project and integrated into the DMX code
+ base, which freed the DMX developers to concentrate on dynamic
+ reconfiguration (as described above).
+
+
+ BB..44..55.. DDooxxyyggeenn ddooccuummeennttaattiioonn
+
+ Doxygen is an open-source (GPL) documentation system for generating
+ browseable documentation from stylized comments in the source code.
+ We have placed all of the Xdmx server and DMX protocol source code
+ files under Doxygen so that comprehensive documentation for the Xdmx
+ source code is available in an easily browseable format.
+
+
+ BB..44..66.. VVaallggrriinndd
+
+ Valgrind, an open-source (GPL) memory debugger for Linux, was used to
+ search for memory management errors. Several memory leaks were
+ detected and repaired. The following errors were not addressed:
+
+ 1. When the X11 transport layer sends a reply to the client, only
+ those fields that are required by the protocol are filled in --
+ unused fields are left as uninitialized memory and are therefore
+ noted by valgrind. These instances are not errors and were not
+ repaired.
+
+ 2. At each server generation, glxInitVisuals allocates memory that is
+ never freed. The amount of memory lost each generation
+ approximately equal to 128 bytes for each back-end visual. Because
+ the code involved is automatically generated, this bug has not been
+ fixed and will be referred to SGI.
+
+ 3. At each server generation, dmxRealizeFont calls XLoadQueryFont,
+ which allocates a font structure that is not freed.
+ dmxUnrealizeFont can free the font structure for the first screen,
+ but cannot free it for the other screens since they are already
+ closed by the time dmxUnrealizeFont could free them. The amount of
+ memory lost each generation is approximately equal to 80 bytes per
+ font per back-end. When this bug is fixed in the the X server's
+ device-independent (dix) code, DMX will be able to properly free
+ the memory allocated by XLoadQueryFont.
+
+
+ BB..44..77.. RRAATTSS
+
+ RATS (Rough Auditing Tool for Security) is an open-source (GPL)
+ security analysis tool that scans source code for common security-
+ related programming errors (e.g., buffer overflows and TOCTOU races).
+ RATS was used to audit all of the code in the hw/dmx directory and all
+ "High" notations were checked manually. The code was either re-
+ written to eliminate the warning, or a comment containing "RATS" was
+ inserted on the line to indicate that a human had checked the code.
+ Unrepaired warnings are as follows:
+
+ 1. Fixed-size buffers are used in many areas, but code has been added
+ to protect against buffer overflows (e.g., XmuSnprint). The only
+ instances that have not yet been fixed are in config/xdmxconfig.c
+ (which is not part of the Xdmx server) and input/usb-common.c.
+
+ 2. vprintf and vfprintf are used in the logging routines. In general,
+ all uses of these functions (e.g., dmxLog) provide a constant
+ format string from a trusted source, so the use is relatively
+ benign.
+
+ 3. glxProxy/glxscreens.c uses getenv and strcat. The use of these
+ functions is safe and will remain safe as long as ExtensionsString
+ is longer then GLXServerExtensions (ensuring this may not be ovious
+ to the casual programmer, but this is in automatically generated
+ code, so we hope that the generator enforces this constraint).
+
+
+
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/doxygen.conf b/nx-X11/programs/Xserver/hw/dmx/doc/doxygen.conf
new file mode 100644
index 000000000..5b706b6d6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/doxygen.conf
@@ -0,0 +1,1090 @@
+# Doxyfile 1.3.4
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME = "Distributed Multihead X"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER = "dmx-1-2-20040604 and later"
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY =
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch,
+# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en
+# (Japanese with English messages), Korean, Norwegian, Polish, Portuguese,
+# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
+
+OUTPUT_LANGUAGE = English
+
+# This tag can be used to specify the encoding used in the generated output.
+# The encoding is not always determined by the language that is chosen,
+# but also whether or not the output is meant for Windows or non-Windows users.
+# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES
+# forces the Windows encoding (this is the default for the Windows binary),
+# whereas setting the tag to NO uses a Unix-style encoding (the default for
+# all platforms other than Windows).
+
+USE_WINDOWS_ENCODING = NO
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = YES
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited
+# members of a class in the documentation of that class as if those members were
+# ordinary class members. Constructors, destructors and assignment operators of
+# the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. It is allowed to use relative paths in the argument list.
+
+STRIP_FROM_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like the Qt-style comments (thus requiring an
+# explict @brief command for a brief description.
+
+JAVADOC_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member
+# documentation.
+
+DETAILS_AT_TOP = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# reimplements.
+
+INHERIT_DOCS = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 8
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
+# only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources
+# only. Doxygen will then generate output that is more tailored for Java.
+# For instance, namespaces will be presented as packages, qualified scopes
+# will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = YES
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = YES
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text.
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = .. \
+ ../input \
+ ../config \
+ ../../../Xext/dmx.c \
+ ../../../../../include/extensions/dmxproto.h \
+ ../../../../../include/extensions/dmxext.h \
+ ../../../../../lib/dmx
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp
+# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc
+
+FILE_PATTERNS =
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE = ../config/parser.c \
+ ../config/parser.h \
+ ../config/scanner.c
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories
+# that are symbolic links (a Unix filesystem feature) are excluded from the input.
+
+EXCLUDE_SYMLINKS = YES
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories.
+
+EXCLUDE_PATTERNS = atKeynames.h \
+ Canvas*.*
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+
+INPUT_FILTER =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+
+SOURCE_BROWSER = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES (the default)
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES (the default)
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = YES
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER = doxygen.head
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER = doxygen.foot
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet
+
+HTML_STYLESHEET = doxygen.css
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output dir.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE = 4
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
+# probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW = YES
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimised for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assigments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader. This is useful
+# if you want to understand what is going on. On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_PREDEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed.
+
+PREDEFINED = SHAPE \
+ RENDER \
+ XKB \
+ XINPUT
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse the
+# parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::addtions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or
+# super classes. Setting the tag to NO turns the diagrams off. Note that this
+# option is superceded by the HAVE_DOT option below. This is only a fallback. It is
+# recommended to install and use dot, since it yields more powerful graphs.
+
+CLASS_DIAGRAMS = YES
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = NO
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similiar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will
+# generate a call dependency graph for every global function or class method.
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable call graphs for selected
+# functions only using the \callgraph command.
+
+CALL_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT = gif
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found on the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than
+# this value, doxygen will try to truncate the graph, so that it fits within
+# the specified constraint. Beware that most browsers cannot cope with very
+# large images.
+
+MAX_DOT_GRAPH_WIDTH = 1024
+
+# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than
+# this value, doxygen will try to truncate the graph, so that it fits within
+# the specified constraint. Beware that most browsers cannot cope with very
+# large images.
+
+MAX_DOT_GRAPH_HEIGHT = 1024
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes that
+# lay further from the root node will be omitted. Note that setting this option to
+# 1 or 2 may greatly reduce the computation time needed for large code bases. Also
+# note that a graph may be further truncated if the graph's image dimensions are
+# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT).
+# If 0 is used for the depth value (the default), the graph is not depth-constrained.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
+
+#---------------------------------------------------------------------------
+# Configuration::addtions related to the search engine
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE = NO
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/doxygen.css b/nx-X11/programs/Xserver/hw/dmx/doc/doxygen.css
new file mode 100644
index 000000000..841f709a7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/doxygen.css
@@ -0,0 +1,49 @@
+H1 { text-align: center; }
+CAPTION { font-weight: bold }
+A.qindex {}
+A.qindexRef {}
+A.el { text-decoration: none; font-weight: bold }
+A.elRef { font-weight: bold }
+A.code { text-decoration: none; font-weight: normal; color: #4444ee }
+A.codeRef { font-weight: normal; color: #4444ee }
+A:hover { text-decoration: none; background-color: #f2f2ff }
+DL.el { margin-left: -1cm }
+DIV.fragment { width: 100%; border: none; background-color: #eeeeee }
+DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px }
+TD.md { background-color: #f2f2ff; font-weight: bold; }
+TD.mdname1 { background-color: #f2f2ff; font-weight: bold; color: #602020; }
+TD.mdname { background-color: #f2f2ff; font-weight: bold; color: #602020; width: 600px; }
+DIV.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold }
+DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller }
+BODY { background: white }
+TD.indexkey {
+ background-color: #eeeeff;
+ font-weight: bold;
+ padding-right : 10px;
+ padding-top : 2px;
+ padding-left : 10px;
+ padding-bottom : 2px;
+ margin-left : 0px;
+ margin-right : 0px;
+ margin-top : 2px;
+ margin-bottom : 2px
+}
+TD.indexvalue {
+ background-color: #eeeeff;
+ font-style: italic;
+ padding-right : 10px;
+ padding-top : 2px;
+ padding-left : 10px;
+ padding-bottom : 2px;
+ margin-left : 0px;
+ margin-right : 0px;
+ margin-top : 2px;
+ margin-bottom : 2px
+}
+FONT.keyword { color: #008000 }
+FONT.keywordtype { color: #604020 }
+FONT.keywordflow { color: #e08000 }
+FONT.comment { color: #800000 }
+FONT.preprocessor { color: #806020 }
+FONT.stringliteral { color: #002080 }
+FONT.charliteral { color: #008080 }
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/doxygen.foot b/nx-X11/programs/Xserver/hw/dmx/doc/doxygen.foot
new file mode 100644
index 000000000..3aca11763
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/doxygen.foot
@@ -0,0 +1,12 @@
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/doxygen.head b/nx-X11/programs/Xserver/hw/dmx/doc/doxygen.head
new file mode 100644
index 000000000..89bda8fda
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/doxygen.head
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/ChkNotMaskEv_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/ChkNotMaskEv_8c.html
new file mode 100644
index 000000000..29fc27d63
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/ChkNotMaskEv_8c.html
@@ -0,0 +1,76 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>ChkNotMaskEv.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="ChkNotMaskEv_8h-source.html">ChkNotMaskEv.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="ChkNotMaskEv_8c.html#a2">XCheckNotMaskEvent</a> (Display *dpy, long mask, XEvent *event)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides a <a class="el" href="ChkNotMaskEv_8h.html#a0">XCheckNotMaskEvent</a> function that is derived from the standard Xlib XCheckMaskEvent function.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a2" doxytag="ChkNotMaskEv.c::XCheckNotMaskEvent" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool XCheckNotMaskEvent </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>long&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>XEvent *&nbsp;</td>
+ <td class="mdname" nowrap> <em>event</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Check existing events in queue to find if any match. If so, return. If not, flush buffer and see if any more events are readable. If one matches, return. If all else fails, tell the user no events found. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/ChkNotMaskEv_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/ChkNotMaskEv_8h-source.html
new file mode 100644
index 000000000..4a4fc4c52
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/ChkNotMaskEv_8h-source.html
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>ChkNotMaskEv.h</h1><a href="ChkNotMaskEv_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _CHKNOTMASKEV_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _CHKNOTMASKEV_H_</span>
+00040 <span class="preprocessor"></span><span class="keyword">extern</span> Bool <a class="code" href="ChkNotMaskEv_8c.html#a2">XCheckNotMaskEvent</a> (Display *dpy, <span class="keywordtype">long</span> mask, XEvent *event);
+00041 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/ChkNotMaskEv_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/ChkNotMaskEv_8h.html
new file mode 100644
index 000000000..658c94d9f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/ChkNotMaskEv_8h.html
@@ -0,0 +1,77 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>ChkNotMaskEv.h File Reference</h1>
+<p>
+<a href="ChkNotMaskEv_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="ChkNotMaskEv_8h.html#a0">XCheckNotMaskEvent</a> (Display *dpy, long mask, XEvent *event)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for <a class="el" href="ChkNotMaskEv_8h.html#a0">XCheckNotMaskEvent</a> function. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="ChkNotMaskEv_8c.html">ChkNotMaskEv.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a0" doxytag="ChkNotMaskEv.h::XCheckNotMaskEvent" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool XCheckNotMaskEvent </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>long&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>XEvent *&nbsp;</td>
+ <td class="mdname" nowrap> <em>event</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Check existing events in queue to find if any match. If so, return. If not, flush buffer and see if any more events are readable. If one matches, return. If all else fails, tell the user no events found. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/annotated.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/annotated.html
new file mode 100644
index 000000000..0bd5e9c98
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/annotated.html
@@ -0,0 +1,98 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindexHL" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>Distributed Multihead X Data Structures</h1>Here are the data structures with brief descriptions:<table>
+ <tr><td class="indexkey"><a class="el" href="struct__dmxArg.html">_dmxArg</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__dmxColormapPriv.html">_dmxColormapPriv</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXConfigComment.html">_DMXConfigComment</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXConfigDisplay.html">_DMXConfigDisplay</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXConfigEntry.html">_DMXConfigEntry</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXConfigFullDim.html">_DMXConfigFullDim</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXConfigNumber.html">_DMXConfigNumber</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXConfigOption.html">_DMXConfigOption</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXConfigPair.html">_DMXConfigPair</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXConfigParam.html">_DMXConfigParam</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXConfigPartDim.html">_DMXConfigPartDim</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXConfigString.html">_DMXConfigString</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXConfigSub.html">_DMXConfigSub</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXConfigToken.html">_DMXConfigToken</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXConfigVirtual.html">_DMXConfigVirtual</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXConfigWall.html">_DMXConfigWall</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__dmxCursorPriv.html">_dmxCursorPriv</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXEventMap.html">_DMXEventMap</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__dmxFontPriv.html">_dmxFontPriv</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__dmxGCPriv.html">_dmxGCPriv</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__dmxGlyphPriv.html">_dmxGlyphPriv</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXInputInfo.html">_DMXInputInfo</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXLocalInitInfo.html">_DMXLocalInitInfo</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXLocalInputInfo.html">_DMXLocalInputInfo</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__dmxPictPriv.html">_dmxPictPriv</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__dmxPixPriv.html">_dmxPixPriv</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXScreenInfo.html">_DMXScreenInfo</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXStatAvg.html">_DMXStatAvg</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__DMXStatInfo.html">_DMXStatInfo</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__dmxWinPriv.html">_dmxWinPriv</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__Event.html">_Event</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__EventQueue.html">_EventQueue</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="struct__myPrivate.html">_myPrivate</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structDMXConfigCmdStruct.html">DMXConfigCmdStruct</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structDMXConfigListStruct.html">DMXConfigListStruct</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structDMXDesktopAttributes.html">DMXDesktopAttributes</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structDMXDesktopAttributesRec.html">DMXDesktopAttributesRec</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structdmxGlxVisualPrivate.html">dmxGlxVisualPrivate</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structDMXInputAttributes.html">DMXInputAttributes</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structDMXInputAttributesRec.html">DMXInputAttributesRec</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structDMXScreenAttributes.html">DMXScreenAttributes</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structDMXScreenAttributesRec.html">DMXScreenAttributesRec</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structDMXWindowAttributes.html">DMXWindowAttributes</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structDMXWindowAttributesRec.html">DMXWindowAttributesRec</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXAddInputReply.html">xDMXAddInputReply</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXAddInputReq.html">xDMXAddInputReq</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXAddScreenReply.html">xDMXAddScreenReply</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXAddScreenReq.html">xDMXAddScreenReq</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXChangeDesktopAttributesReply.html">xDMXChangeDesktopAttributesReply</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXChangeDesktopAttributesReq.html">xDMXChangeDesktopAttributesReq</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXChangeScreensAttributesReply.html">xDMXChangeScreensAttributesReply</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXChangeScreensAttributesReq.html">xDMXChangeScreensAttributesReq</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXForceWindowCreationReply.html">xDMXForceWindowCreationReply</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXForceWindowCreationReq.html">xDMXForceWindowCreationReq</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXGetDesktopAttributesReply.html">xDMXGetDesktopAttributesReply</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXGetDesktopAttributesReq.html">xDMXGetDesktopAttributesReq</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXGetInputAttributesReply.html">xDMXGetInputAttributesReply</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXGetInputAttributesReq.html">xDMXGetInputAttributesReq</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXGetInputCountReply.html">xDMXGetInputCountReply</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXGetInputCountReq.html">xDMXGetInputCountReq</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXGetScreenAttributesReply.html">xDMXGetScreenAttributesReply</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXGetScreenAttributesReq.html">xDMXGetScreenAttributesReq</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXGetScreenCountReply.html">xDMXGetScreenCountReply</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXGetScreenCountReq.html">xDMXGetScreenCountReq</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXGetWindowAttributesReply.html">xDMXGetWindowAttributesReply</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXGetWindowAttributesReq.html">xDMXGetWindowAttributesReq</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXQueryVersionReply.html">xDMXQueryVersionReply</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXQueryVersionReq.html">xDMXQueryVersionReq</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXRemoveInputReply.html">xDMXRemoveInputReply</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXRemoveInputReq.html">xDMXRemoveInputReq</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXRemoveScreenReply.html">xDMXRemoveScreenReply</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXRemoveScreenReq.html">xDMXRemoveScreenReq</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXSyncReply.html">xDMXSyncReply</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="structxDMXSyncReq.html">xDMXSyncReq</a></td><td class="indexvalue"></td></tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/classes.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/classes.html
new file mode 100644
index 000000000..d6632fb09
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/classes.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindexHL" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>Distributed Multihead X Data Structure Index</h1><table align=center width="95%" border="0" cellspacing="0" cellpadding="0">
+<tr><td><table border="0" cellspacing="0" cellpadding="0"><tr><td><div class="ah">&nbsp;&nbsp;_&nbsp;&nbsp;</div></td></tr></table>
+</td><td><a class="el" href="struct__DMXConfigWall.html">_DMXConfigWall</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__EventQueue.html">_EventQueue</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXAddInputReply.html">xDMXAddInputReply</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXGetInputCountReq.html">xDMXGetInputCountReq</a>&nbsp;&nbsp;&nbsp;</td></tr><tr><td><a class="el" href="struct__dmxArg.html">_dmxArg</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__dmxCursorPriv.html">_dmxCursorPriv</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__myPrivate.html">_myPrivate</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXAddInputReq.html">xDMXAddInputReq</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXGetScreenAttributesReply.html">xDMXGetScreenAttributesReply</a>&nbsp;&nbsp;&nbsp;</td></tr><tr><td><a class="el" href="struct__dmxColormapPriv.html">_dmxColormapPriv</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__DMXEventMap.html">_DMXEventMap</a>&nbsp;&nbsp;&nbsp;</td><td><table border="0" cellspacing="0" cellpadding="0"><tr><td><div class="ah">&nbsp;&nbsp;D&nbsp;&nbsp;</div></td></tr></table>
+</td><td><a class="el" href="structxDMXAddScreenReply.html">xDMXAddScreenReply</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXGetScreenAttributesReq.html">xDMXGetScreenAttributesReq</a>&nbsp;&nbsp;&nbsp;</td></tr><tr><td><a class="el" href="struct__DMXConfigComment.html">_DMXConfigComment</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__dmxFontPriv.html">_dmxFontPriv</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structDMXConfigCmdStruct.html">DMXConfigCmdStruct</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXAddScreenReq.html">xDMXAddScreenReq</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXGetScreenCountReply.html">xDMXGetScreenCountReply</a>&nbsp;&nbsp;&nbsp;</td></tr><tr><td><a class="el" href="struct__DMXConfigDisplay.html">_DMXConfigDisplay</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__dmxGCPriv.html">_dmxGCPriv</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structDMXConfigListStruct.html">DMXConfigListStruct</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXChangeDesktopAttributesReply.html">xDMXChangeDesktopAttributesReply</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXGetScreenCountReq.html">xDMXGetScreenCountReq</a>&nbsp;&nbsp;&nbsp;</td></tr><tr><td><a class="el" href="struct__DMXConfigEntry.html">_DMXConfigEntry</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__dmxGlyphPriv.html">_dmxGlyphPriv</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structDMXDesktopAttributes.html">DMXDesktopAttributes</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXChangeDesktopAttributesReq.html">xDMXChangeDesktopAttributesReq</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXGetWindowAttributesReply.html">xDMXGetWindowAttributesReply</a>&nbsp;&nbsp;&nbsp;</td></tr><tr><td><a class="el" href="struct__DMXConfigFullDim.html">_DMXConfigFullDim</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__DMXInputInfo.html">_DMXInputInfo</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structDMXDesktopAttributesRec.html">DMXDesktopAttributesRec</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXChangeScreensAttributesReply.html">xDMXChangeScreensAttributesReply</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXGetWindowAttributesReq.html">xDMXGetWindowAttributesReq</a>&nbsp;&nbsp;&nbsp;</td></tr><tr><td><a class="el" href="struct__DMXConfigNumber.html">_DMXConfigNumber</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__DMXLocalInitInfo.html">_DMXLocalInitInfo</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structdmxGlxVisualPrivate.html">dmxGlxVisualPrivate</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXChangeScreensAttributesReq.html">xDMXChangeScreensAttributesReq</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXQueryVersionReply.html">xDMXQueryVersionReply</a>&nbsp;&nbsp;&nbsp;</td></tr><tr><td><a class="el" href="struct__DMXConfigOption.html">_DMXConfigOption</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__DMXLocalInputInfo.html">_DMXLocalInputInfo</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structDMXInputAttributes.html">DMXInputAttributes</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXForceWindowCreationReply.html">xDMXForceWindowCreationReply</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXQueryVersionReq.html">xDMXQueryVersionReq</a>&nbsp;&nbsp;&nbsp;</td></tr><tr><td><a class="el" href="struct__DMXConfigPair.html">_DMXConfigPair</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__dmxPictPriv.html">_dmxPictPriv</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structDMXInputAttributesRec.html">DMXInputAttributesRec</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXForceWindowCreationReq.html">xDMXForceWindowCreationReq</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXRemoveInputReply.html">xDMXRemoveInputReply</a>&nbsp;&nbsp;&nbsp;</td></tr><tr><td><a class="el" href="struct__DMXConfigParam.html">_DMXConfigParam</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__dmxPixPriv.html">_dmxPixPriv</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structDMXScreenAttributes.html">DMXScreenAttributes</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXGetDesktopAttributesReply.html">xDMXGetDesktopAttributesReply</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXRemoveInputReq.html">xDMXRemoveInputReq</a>&nbsp;&nbsp;&nbsp;</td></tr><tr><td><a class="el" href="struct__DMXConfigPartDim.html">_DMXConfigPartDim</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__DMXScreenInfo.html">_DMXScreenInfo</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structDMXScreenAttributesRec.html">DMXScreenAttributesRec</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXGetDesktopAttributesReq.html">xDMXGetDesktopAttributesReq</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXRemoveScreenReply.html">xDMXRemoveScreenReply</a>&nbsp;&nbsp;&nbsp;</td></tr><tr><td><a class="el" href="struct__DMXConfigString.html">_DMXConfigString</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__DMXStatAvg.html">_DMXStatAvg</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structDMXWindowAttributes.html">DMXWindowAttributes</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXGetInputAttributesReply.html">xDMXGetInputAttributesReply</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXRemoveScreenReq.html">xDMXRemoveScreenReq</a>&nbsp;&nbsp;&nbsp;</td></tr><tr><td><a class="el" href="struct__DMXConfigSub.html">_DMXConfigSub</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__DMXStatInfo.html">_DMXStatInfo</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structDMXWindowAttributesRec.html">DMXWindowAttributesRec</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXGetInputAttributesReq.html">xDMXGetInputAttributesReq</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXSyncReply.html">xDMXSyncReply</a>&nbsp;&nbsp;&nbsp;</td></tr><tr><td><a class="el" href="struct__DMXConfigToken.html">_DMXConfigToken</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__dmxWinPriv.html">_dmxWinPriv</a>&nbsp;&nbsp;&nbsp;</td><td><table border="0" cellspacing="0" cellpadding="0"><tr><td><div class="ah">&nbsp;&nbsp;X&nbsp;&nbsp;</div></td></tr></table>
+</td><td><a class="el" href="structxDMXGetInputCountReply.html">xDMXGetInputCountReply</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="structxDMXSyncReq.html">xDMXSyncReq</a>&nbsp;&nbsp;&nbsp;</td></tr><tr><td><a class="el" href="struct__DMXConfigVirtual.html">_DMXConfigVirtual</a>&nbsp;&nbsp;&nbsp;</td><td><a class="el" href="struct__Event.html">_Event</a>&nbsp;&nbsp;&nbsp;</td></tr></table> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmx_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmx_8h-source.html
new file mode 100644
index 000000000..3dc9b85ac
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmx_8h-source.html
@@ -0,0 +1,276 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmx.h</h1><a href="dmx_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Kevin E. Martin &lt;kem@redhat.com&gt;</span>
+00032 <span class="comment"> * David H. Dawes &lt;dawes@xfree86.org&gt;</span>
+00033 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00034 <span class="comment"> *</span>
+00035 <span class="comment"> */</span>
+00036
+00051 <span class="preprocessor">#ifndef DMX_H</span>
+00052 <span class="preprocessor"></span><span class="preprocessor">#define DMX_H</span>
+00053 <span class="preprocessor"></span>
+00054 <span class="preprocessor">#include "gcstruct.h"</span>
+00055
+00056 <span class="comment">/* Handle client-side include files in one place. */</span>
+00057 <span class="preprocessor">#include "<a class="code" href="dmxclient_8h.html">dmxclient.h</a>"</span>
+00058
+00059 <span class="preprocessor">#include "globals.h"</span>
+00060 <span class="preprocessor">#include "scrnintstr.h"</span>
+00061
+00062 <span class="preprocessor">#ifdef RENDER</span>
+00063 <span class="preprocessor"></span><span class="preprocessor">#include "picturestr.h"</span>
+00064 <span class="preprocessor">#endif</span>
+00065 <span class="preprocessor"></span>
+00066 <span class="preprocessor">#ifdef GLXEXT</span>
+00067 <span class="preprocessor"></span><span class="preprocessor">#include &lt;GL/glx.h&gt;</span>
+00068 <span class="preprocessor">#include &lt;GL/glxint.h&gt;</span>
+00069 <span class="preprocessor">#endif</span>
+00070 <span class="preprocessor"></span>
+00071 <span class="keyword">typedef</span> <span class="keyword">enum</span> {
+00072 PosNone = -1,
+00073 PosAbsolute = 0,
+00074 PosRightOf,
+00075 PosLeftOf,
+00076 PosAbove,
+00077 PosBelow,
+00078 PosRelative
+00079 } PositionType;
+00080
+<a name="l00083"></a><a class="code" href="dmx_8h.html#a2">00083</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXInputInfo.html">_DMXInputInfo</a> <a class="code" href="dmx_8h.html#a2">DMXInputInfo</a>;
+00084
+<a name="l00087"></a><a class="code" href="dmx_8h.html#a3">00087</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXStatInfo.html">_DMXStatInfo</a> <a class="code" href="dmx_8h.html#a3">DMXStatInfo</a>;
+00088
+<a name="l00090"></a><a class="code" href="struct__DMXScreenInfo.html">00090</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXScreenInfo.html">_DMXScreenInfo</a> {
+<a name="l00091"></a><a class="code" href="struct__DMXScreenInfo.html#o0">00091</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="struct__DMXScreenInfo.html#o0">name</a>;
+<a name="l00092"></a><a class="code" href="struct__DMXScreenInfo.html#o1">00092</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o1">index</a>;
+00094 <span class="comment">/*---------- Back-end X server information ----------*/</span>
+00095
+<a name="l00096"></a><a class="code" href="struct__DMXScreenInfo.html#o2">00096</a> Display *<a class="code" href="struct__DMXScreenInfo.html#o2">beDisplay</a>;
+<a name="l00097"></a><a class="code" href="struct__DMXScreenInfo.html#o3">00097</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o3">beWidth</a>;
+<a name="l00098"></a><a class="code" href="struct__DMXScreenInfo.html#o4">00098</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o4">beHeight</a>;
+<a name="l00099"></a><a class="code" href="struct__DMXScreenInfo.html#o5">00099</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o5">beDepth</a>;
+<a name="l00100"></a><a class="code" href="struct__DMXScreenInfo.html#o6">00100</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o6">beBPP</a>;
+<a name="l00101"></a><a class="code" href="struct__DMXScreenInfo.html#o7">00101</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o7">beXDPI</a>;
+<a name="l00102"></a><a class="code" href="struct__DMXScreenInfo.html#o8">00102</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o8">beYDPI</a>;
+<a name="l00104"></a><a class="code" href="struct__DMXScreenInfo.html#o9">00104</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o9">beNumDepths</a>;
+<a name="l00105"></a><a class="code" href="struct__DMXScreenInfo.html#o10">00105</a> <span class="keywordtype">int</span> *<a class="code" href="struct__DMXScreenInfo.html#o10">beDepths</a>;
+<a name="l00107"></a><a class="code" href="struct__DMXScreenInfo.html#o11">00107</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o11">beNumPixmapFormats</a>;
+<a name="l00108"></a><a class="code" href="struct__DMXScreenInfo.html#o12">00108</a> XPixmapFormatValues *<a class="code" href="struct__DMXScreenInfo.html#o12">bePixmapFormats</a>;
+<a name="l00110"></a><a class="code" href="struct__DMXScreenInfo.html#o13">00110</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o13">beNumVisuals</a>;
+<a name="l00111"></a><a class="code" href="struct__DMXScreenInfo.html#o14">00111</a> XVisualInfo *<a class="code" href="struct__DMXScreenInfo.html#o14">beVisuals</a>;
+<a name="l00112"></a><a class="code" href="struct__DMXScreenInfo.html#o15">00112</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o15">beDefVisualIndex</a>;
+<a name="l00114"></a><a class="code" href="struct__DMXScreenInfo.html#o16">00114</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o16">beNumDefColormaps</a>;
+<a name="l00115"></a><a class="code" href="struct__DMXScreenInfo.html#o17">00115</a> Colormap *<a class="code" href="struct__DMXScreenInfo.html#o17">beDefColormaps</a>;
+<a name="l00117"></a><a class="code" href="struct__DMXScreenInfo.html#o18">00117</a> Pixel <a class="code" href="struct__DMXScreenInfo.html#o18">beBlackPixel</a>;
+<a name="l00118"></a><a class="code" href="struct__DMXScreenInfo.html#o19">00118</a> Pixel <a class="code" href="struct__DMXScreenInfo.html#o19">beWhitePixel</a>;
+00120 <span class="comment">/*---------- Screen window information ----------*/</span>
+00121
+<a name="l00122"></a><a class="code" href="struct__DMXScreenInfo.html#o20">00122</a> Window <a class="code" href="struct__DMXScreenInfo.html#o20">scrnWin</a>;
+<a name="l00123"></a><a class="code" href="struct__DMXScreenInfo.html#o21">00123</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o21">scrnX</a>;
+<a name="l00124"></a><a class="code" href="struct__DMXScreenInfo.html#o22">00124</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o22">scrnY</a>;
+<a name="l00125"></a><a class="code" href="struct__DMXScreenInfo.html#o23">00125</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o23">scrnWidth</a>;
+<a name="l00126"></a><a class="code" href="struct__DMXScreenInfo.html#o24">00126</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o24">scrnHeight</a>;
+<a name="l00127"></a><a class="code" href="struct__DMXScreenInfo.html#o25">00127</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o25">scrnXSign</a>;
+<a name="l00128"></a><a class="code" href="struct__DMXScreenInfo.html#o26">00128</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o26">scrnYSign</a>;
+<a name="l00131"></a><a class="code" href="struct__DMXScreenInfo.html#o27">00131</a> Drawable <a class="code" href="struct__DMXScreenInfo.html#o27">scrnDefDrawables</a>[MAXFORMATS];
+00132
+<a name="l00133"></a><a class="code" href="struct__DMXScreenInfo.html#o28">00133</a> <span class="keyword">struct </span><a class="code" href="struct__DMXScreenInfo.html">_DMXScreenInfo</a> *<a class="code" href="struct__DMXScreenInfo.html#o28">next</a>;
+<a name="l00134"></a><a class="code" href="struct__DMXScreenInfo.html#o29">00134</a> <span class="keyword">struct </span><a class="code" href="struct__DMXScreenInfo.html">_DMXScreenInfo</a> *<a class="code" href="struct__DMXScreenInfo.html#o29">over</a>;
+00136 <span class="comment">/*---------- Root window information ----------*/</span>
+00137
+<a name="l00138"></a><a class="code" href="struct__DMXScreenInfo.html#o30">00138</a> Window <a class="code" href="struct__DMXScreenInfo.html#o30">rootWin</a>;
+<a name="l00139"></a><a class="code" href="struct__DMXScreenInfo.html#o31">00139</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o31">rootX</a>;
+<a name="l00140"></a><a class="code" href="struct__DMXScreenInfo.html#o32">00140</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o32">rootY</a>;
+<a name="l00141"></a><a class="code" href="struct__DMXScreenInfo.html#o33">00141</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o33">rootWidth</a>;
+<a name="l00142"></a><a class="code" href="struct__DMXScreenInfo.html#o34">00142</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o34">rootHeight</a>;
+<a name="l00144"></a><a class="code" href="struct__DMXScreenInfo.html#o35">00144</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o35">rootXOrigin</a>;
+<a name="l00145"></a><a class="code" href="struct__DMXScreenInfo.html#o36">00145</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o36">rootYOrigin</a>;
+00147 <span class="comment">/*---------- Shadow framebuffer information ----------*/</span>
+00148
+<a name="l00149"></a><a class="code" href="struct__DMXScreenInfo.html#o37">00149</a> <span class="keywordtype">void</span> *<a class="code" href="struct__DMXScreenInfo.html#o37">shadow</a>;
+<a name="l00150"></a><a class="code" href="struct__DMXScreenInfo.html#o38">00150</a> XlibGC <a class="code" href="struct__DMXScreenInfo.html#o38">shadowGC</a>;
+<a name="l00151"></a><a class="code" href="struct__DMXScreenInfo.html#o39">00151</a> XImage *<a class="code" href="struct__DMXScreenInfo.html#o39">shadowFBImage</a>;
+00153 <span class="comment">/*---------- Other related information ----------*/</span>
+00154
+<a name="l00155"></a><a class="code" href="struct__DMXScreenInfo.html#o40">00155</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o40">shared</a>;
+00157 Bool WMRunningOnBE;
+00158
+00159 Cursor noCursor;
+00160 Cursor curCursor;
+00161 <span class="comment">/* Support for cursors on overlapped</span>
+00162 <span class="comment"> * backend displays. */</span>
+00163 CursorPtr cursor;
+00164 <span class="keywordtype">int</span> cursorVisible;
+00165 <span class="keywordtype">int</span> cursorNotShared; <span class="comment">/* for overlapping screens on a backend */</span>
+00166
+<a name="l00167"></a><a class="code" href="struct__DMXScreenInfo.html#o47">00167</a> PositionType <a class="code" href="struct__DMXScreenInfo.html#o47">where</a>;
+<a name="l00168"></a><a class="code" href="struct__DMXScreenInfo.html#o48">00168</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o48">whereX</a>;
+<a name="l00169"></a><a class="code" href="struct__DMXScreenInfo.html#o49">00169</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o49">whereY</a>;
+<a name="l00170"></a><a class="code" href="struct__DMXScreenInfo.html#o50">00170</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o50">whereRefScreen</a>;
+<a name="l00172"></a><a class="code" href="struct__DMXScreenInfo.html#o51">00172</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o51">savedTimeout</a>;
+<a name="l00173"></a><a class="code" href="struct__DMXScreenInfo.html#o52">00173</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o52">dpmsCapable</a>;
+<a name="l00174"></a><a class="code" href="struct__DMXScreenInfo.html#o53">00174</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o53">dpmsEnabled</a>;
+<a name="l00175"></a><a class="code" href="struct__DMXScreenInfo.html#o54">00175</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o54">dpmsStandby</a>;
+<a name="l00176"></a><a class="code" href="struct__DMXScreenInfo.html#o55">00176</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o55">dpmsSuspend</a>;
+<a name="l00177"></a><a class="code" href="struct__DMXScreenInfo.html#o56">00177</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXScreenInfo.html#o56">dpmsOff</a>;
+<a name="l00179"></a><a class="code" href="struct__DMXScreenInfo.html#o57">00179</a> <a class="code" href="dmx_8h.html#a3">DMXStatInfo</a> *<a class="code" href="struct__DMXScreenInfo.html#o57">stat</a>;
+<a name="l00180"></a><a class="code" href="struct__DMXScreenInfo.html#o58">00180</a> Bool <a class="code" href="struct__DMXScreenInfo.html#o58">needsSync</a>;
+00182 <span class="preprocessor">#ifdef GLXEXT</span>
+00183 <span class="preprocessor"></span>
+00184 <span class="keywordtype">int</span> numGlxVisuals;
+00185 __GLXvisualConfig *glxVisuals;
+00186 <span class="keywordtype">int</span> glxMajorOpcode;
+00187 <span class="keywordtype">int</span> glxErrorBase;
+00188
+00190 __GLXFBConfig *fbconfigs;
+00191 <span class="keywordtype">int</span> numFBConfigs;
+00192 <span class="preprocessor">#endif</span>
+00193 <span class="preprocessor"></span>
+<a name="l00196"></a><a class="code" href="struct__DMXScreenInfo.html#o59">00196</a> CloseScreenProcPtr <a class="code" href="struct__DMXScreenInfo.html#o59">CloseScreen</a>;
+00197 SaveScreenProcPtr SaveScreen;
+00198
+00199 CreateGCProcPtr CreateGC;
+00200
+00201 CreateWindowProcPtr CreateWindow;
+00202 DestroyWindowProcPtr DestroyWindow;
+00203 PositionWindowProcPtr PositionWindow;
+00204 ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+00205 RealizeWindowProcPtr RealizeWindow;
+00206 UnrealizeWindowProcPtr UnrealizeWindow;
+00207 RestackWindowProcPtr RestackWindow;
+00208 WindowExposuresProcPtr WindowExposures;
+00209 PaintWindowBackgroundProcPtr PaintWindowBackground;
+00210 PaintWindowBorderProcPtr PaintWindowBorder;
+00211 CopyWindowProcPtr CopyWindow;
+00212
+00213 ResizeWindowProcPtr ResizeWindow;
+00214 ReparentWindowProcPtr ReparentWindow;
+00215
+00216 ChangeBorderWidthProcPtr ChangeBorderWidth;
+00217
+00218 GetImageProcPtr GetImage;
+00219 GetSpansProcPtr GetSpans;
+00220
+00221 CreatePixmapProcPtr CreatePixmap;
+00222 DestroyPixmapProcPtr DestroyPixmap;
+00223 BitmapToRegionProcPtr BitmapToRegion;
+00224
+00225 RealizeFontProcPtr RealizeFont;
+00226 UnrealizeFontProcPtr UnrealizeFont;
+00227
+00228 CreateColormapProcPtr CreateColormap;
+00229 DestroyColormapProcPtr DestroyColormap;
+00230 InstallColormapProcPtr InstallColormap;
+00231 StoreColorsProcPtr StoreColors;
+00232
+00233 <span class="preprocessor">#ifdef SHAPE</span>
+00234 <span class="preprocessor"></span> SetShapeProcPtr SetShape;
+00235 <span class="preprocessor">#endif</span>
+00236 <span class="preprocessor"></span>
+00237 <span class="preprocessor">#ifdef RENDER</span>
+00238 <span class="preprocessor"></span> CreatePictureProcPtr CreatePicture;
+00239 DestroyPictureProcPtr DestroyPicture;
+00240 ChangePictureClipProcPtr ChangePictureClip;
+00241 DestroyPictureClipProcPtr DestroyPictureClip;
+00242
+00243 ChangePictureProcPtr ChangePicture;
+00244 ValidatePictureProcPtr ValidatePicture;
+00245
+00246 CompositeProcPtr Composite;
+00247 GlyphsProcPtr Glyphs;
+00248 CompositeRectsProcPtr CompositeRects;
+00249
+00250 InitIndexedProcPtr InitIndexed;
+00251 CloseIndexedProcPtr CloseIndexed;
+00252 UpdateIndexedProcPtr UpdateIndexed;
+00253
+00254 TrapezoidsProcPtr Trapezoids;
+00255 TrianglesProcPtr Triangles;
+00256 TriStripProcPtr TriStrip;
+00257 TriFanProcPtr TriFan;
+00258 <span class="preprocessor">#endif</span>
+00259 <span class="preprocessor"></span>} <a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a>;
+00260
+00261 <span class="comment">/* Global variables available to all Xserver/hw/dmx routines. */</span>
+<a name="l00262"></a><a class="code" href="dmx_8h.html#a5">00262</a> <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmx_8h.html#a5">dmxNumScreens</a>;
+<a name="l00263"></a><a class="code" href="dmx_8h.html#a6">00263</a> <span class="keyword">extern</span> <a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *<a class="code" href="dmx_8h.html#a6">dmxScreens</a>;
+<a name="l00264"></a><a class="code" href="dmx_8h.html#a7">00264</a> <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmx_8h.html#a7">dmxShadowFB</a>;
+<a name="l00267"></a><a class="code" href="dmx_8h.html#a8">00267</a> <span class="keyword">extern</span> XErrorEvent <a class="code" href="dmx_8h.html#a8">dmxLastErrorEvent</a>;
+<a name="l00269"></a><a class="code" href="dmx_8h.html#a9">00269</a> <span class="keyword">extern</span> Bool <a class="code" href="dmx_8h.html#a9">dmxErrorOccurred</a>;
+<a name="l00271"></a><a class="code" href="dmx_8h.html#a10">00271</a> <span class="keyword">extern</span> Bool <a class="code" href="dmx_8h.html#a10">dmxOffScreenOpt</a>;
+<a name="l00274"></a><a class="code" href="dmx_8h.html#a11">00274</a> <span class="keyword">extern</span> Bool <a class="code" href="dmx_8h.html#a11">dmxSubdividePrimitives</a>;
+<a name="l00277"></a><a class="code" href="dmx_8h.html#a12">00277</a> <span class="keyword">extern</span> Bool <a class="code" href="dmx_8h.html#a12">dmxLazyWindowCreation</a>;
+<a name="l00280"></a><a class="code" href="dmx_8h.html#a13">00280</a> <span class="keyword">extern</span> Bool <a class="code" href="dmx_8h.html#a13">dmxUseXKB</a>;
+<a name="l00284"></a><a class="code" href="dmx_8h.html#a14">00284</a> <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmx_8h.html#a14">dmxDepth</a>;
+<a name="l00286"></a><a class="code" href="dmx_8h.html#a15">00286</a> <span class="keyword">extern</span> Bool <a class="code" href="dmx_8h.html#a15">dmxNoRender</a>;
+00289 <span class="preprocessor">#ifdef GLXEXT</span>
+00290 <span class="preprocessor"></span><span class="keyword">extern</span> Bool dmxGLXProxy;
+00292 <span class="keyword">extern</span> Bool dmxGLXSwapGroupSupport;
+00296 <span class="keyword">extern</span> Bool dmxGLXSyncSwap;
+00300 <span class="keyword">extern</span> Bool dmxGLXFinishSwap;
+00305 <span class="preprocessor">#endif</span>
+<a name="l00306"></a><a class="code" href="dmx_8h.html#a16">00306</a> <span class="preprocessor"></span><span class="keyword">extern</span> <span class="keywordtype">char</span> *<a class="code" href="dmx_8h.html#a16">dmxFontPath</a>;
+<a name="l00315"></a><a class="code" href="dmx_8h.html#a17">00315</a> <span class="keyword">extern</span> Bool <a class="code" href="dmx_8h.html#a17">dmxIgnoreBadFontPaths</a>;
+<a name="l00319"></a><a class="code" href="dmx_8h.html#a18">00319</a> <span class="keyword">extern</span> Bool <a class="code" href="dmx_8h.html#a18">dmxAddRemoveScreens</a>;
+<a name="l00324"></a><a class="code" href="dmx_8h.html#a0">00324</a> <span class="preprocessor">#define DMX_WRAP(_entry, _newfunc, _saved, _actual) \</span>
+00325 <span class="preprocessor">do { \</span>
+00326 <span class="preprocessor"> (_saved)-&gt;_entry = (_actual)-&gt;_entry; \</span>
+00327 <span class="preprocessor"> (_actual)-&gt;_entry = (_newfunc); \</span>
+00328 <span class="preprocessor">} while (0)</span>
+00329 <span class="preprocessor"></span>
+<a name="l00331"></a><a class="code" href="dmx_8h.html#a1">00331</a> <span class="preprocessor">#define DMX_UNWRAP(_entry, _saved, _actual) \</span>
+00332 <span class="preprocessor">do { \</span>
+00333 <span class="preprocessor"> (_actual)-&gt;_entry = (_saved)-&gt;_entry; \</span>
+00334 <span class="preprocessor">} while (0)</span>
+00335 <span class="preprocessor"></span>
+00336 <span class="preprocessor">#endif </span><span class="comment">/* DMX_H */</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmx_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmx_8h.html
new file mode 100644
index 000000000..ecdde319d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmx_8h.html
@@ -0,0 +1,532 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmx.h File Reference</h1><code>#include "gcstruct.h"</code><br>
+<code>#include "<a class="el" href="dmxclient_8h-source.html">dmxclient.h</a>"</code><br>
+<code>#include "globals.h"</code><br>
+<code>#include "scrnintstr.h"</code><br>
+<code>#include "picturestr.h"</code><br>
+
+<p>
+<a href="dmx_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html">_DMXScreenInfo</a></td></tr>
+
+<tr><td colspan=2><br><h2>Defines</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a0">DMX_WRAP</a>(_entry, _newfunc, _saved, _actual)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a1">DMX_UNWRAP</a>(_entry, _saved, _actual)</td></tr>
+
+<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXInputInfo.html">_DMXInputInfo</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a2">DMXInputInfo</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXStatInfo.html">_DMXStatInfo</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a3">DMXStatInfo</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXScreenInfo.html">_DMXScreenInfo</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a4">DMXScreenInfo</a></td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a5">dmxNumScreens</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a6">dmxScreens</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a7">dmxShadowFB</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>XErrorEvent&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a8">dmxLastErrorEvent</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a9">dmxErrorOccurred</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a10">dmxOffScreenOpt</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a11">dmxSubdividePrimitives</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a12">dmxLazyWindowCreation</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a13">dmxUseXKB</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a14">dmxDepth</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a15">dmxNoRender</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a16">dmxFontPath</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a17">dmxIgnoreBadFontPaths</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmx_8h.html#a18">dmxAddRemoveScreens</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Main header file included by all other DMX-related files.<hr><h2>Define Documentation</h2>
+<a class="anchor" name="a1" doxytag="dmx.h::DMX_UNWRAP" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_UNWRAP</td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">_entry, <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>_saved, <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>_actual&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+<b>Value:</b><div class="fragment"><pre><span class="keywordflow">do</span> { \
+ (_actual)-&gt;_entry = (_saved)-&gt;_entry; \
+} <span class="keywordflow">while</span> (0)
+</pre></div>Unwrap screen or GC function pointer </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmx.h::DMX_WRAP" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_WRAP</td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">_entry, <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>_newfunc, <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>_saved, <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>_actual&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+<b>Value:</b><div class="fragment"><pre><span class="keywordflow">do</span> { \
+ (_saved)-&gt;_entry = (_actual)-&gt;_entry; \
+ (_actual)-&gt;_entry = (_newfunc); \
+} <span class="keywordflow">while</span> (0)
+</pre></div>Wrap screen or GC function pointer </td>
+ </tr>
+</table>
+<hr><h2>Typedef Documentation</h2>
+<a class="anchor" name="a2" doxytag="dmx.h::DMXInputInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXInputInfo.html">_DMXInputInfo</a> <a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Provide the typedef globally, but keep the contents opaque outside of the input routines. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxinput_8h.html">dmxinput.h</a> </dd></dl>
+ </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmx.h::DMXScreenInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXScreenInfo.html">_DMXScreenInfo</a> <a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Global structure containing information about each backend screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmx.h::DMXStatInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXStatInfo.html">_DMXStatInfo</a> <a class="el" href="struct__DMXStatInfo.html">DMXStatInfo</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Provide the typedef globally, but keep the contents opaque outside of the XSync statistic routines. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxstat_8c.html">dmxstat.c</a> </dd></dl>
+ </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a18" doxytag="dmx.h::dmxAddRemoveScreens" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="dmxinit_8c.html#a17">dmxAddRemoveScreens</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if add and remove screens support is enabled </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmx.h::dmxDepth" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxinit_8c.html#a13">dmxDepth</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Requested depth if non-zero </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmx.h::dmxErrorOccurred" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="dmxinit_8c.html#a7">dmxErrorOccurred</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if an error occurred </td>
+ </tr>
+</table>
+<a class="anchor" name="a16" doxytag="dmx.h::dmxFontPath" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> char* <a class="el" href="dmxinit_8c.html#a8">dmxFontPath</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+NULL if no font path is set on the command line; otherwise, a string of comma separated paths built from the command line specified font paths </td>
+ </tr>
+</table>
+<a class="anchor" name="a17" doxytag="dmx.h::dmxIgnoreBadFontPaths" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="dmxinit_8c.html#a16">dmxIgnoreBadFontPaths</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if bad font paths should be ignored during server init </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmx.h::dmxLastErrorEvent" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> XErrorEvent <a class="el" href="dmxinit_8c.html#a6">dmxLastErrorEvent</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Last error that occurred </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmx.h::dmxLazyWindowCreation" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="dmxinit_8c.html#a11">dmxLazyWindowCreation</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if using the lazy window creation optimization </td>
+ </tr>
+</table>
+<a class="anchor" name="a15" doxytag="dmx.h::dmxNoRender" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="dmxinit_8c.html#a14">dmxNoRender</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if the RENDER extension should be disabled </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmx.h::dmxNumScreens" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxinit_8c.html#a1">dmxNumScreens</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Number of dmxScreens </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmx.h::dmxOffScreenOpt" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="dmxinit_8c.html#a9">dmxOffScreenOpt</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if using off screen optimizations </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmx.h::dmxScreens" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a>* <a class="el" href="dmxinit_8c.html#a2">dmxScreens</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+List of outputs </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmx.h::dmxShadowFB" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxinit_8c.html#a5">dmxShadowFB</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if using shadow frame-buffer (deprecated) </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmx.h::dmxSubdividePrimitives" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="dmxinit_8c.html#a10">dmxSubdividePrimitives</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if using the primitive subdivision optimization </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmx.h::dmxUseXKB" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="dmxinit_8c.html#a12">dmxUseXKB</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if the XKB extension should be used with the backend servers </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmx__glxvisuals_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmx__glxvisuals_8h-source.html
new file mode 100644
index 000000000..1885e30d7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmx__glxvisuals_8h-source.html
@@ -0,0 +1,85 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmx_glxvisuals.h</h1><div class="fragment"><pre>00001 <span class="comment">/*</span>
+00002 <span class="comment">** License Applicability. Except to the extent portions of this file are</span>
+00003 <span class="comment">** made subject to an alternative license as permitted in the SGI Free</span>
+00004 <span class="comment">** Software License B, Version 1.1 (the "License"), the contents of this</span>
+00005 <span class="comment">** file are subject only to the provisions of the License. You may not use</span>
+00006 <span class="comment">** this file except in compliance with the License. You may obtain a copy</span>
+00007 <span class="comment">** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600</span>
+00008 <span class="comment">** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:</span>
+00009 <span class="comment">**</span>
+00010 <span class="comment">** http://oss.sgi.com/projects/FreeB</span>
+00011 <span class="comment">**</span>
+00012 <span class="comment">** Note that, as provided in the License, the Software is distributed on an</span>
+00013 <span class="comment">** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS</span>
+00014 <span class="comment">** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND</span>
+00015 <span class="comment">** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A</span>
+00016 <span class="comment">** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.</span>
+00017 <span class="comment">**</span>
+00018 <span class="comment">** Original Code. The Original Code is: OpenGL Sample Implementation,</span>
+00019 <span class="comment">** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,</span>
+00020 <span class="comment">** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.</span>
+00021 <span class="comment">** Copyright in any portions created by third parties is as indicated</span>
+00022 <span class="comment">** elsewhere herein. All Rights Reserved.</span>
+00023 <span class="comment">**</span>
+00024 <span class="comment">** Additional Notice Provisions: The application programming interfaces</span>
+00025 <span class="comment">** established by SGI in conjunction with the Original Code are The</span>
+00026 <span class="comment">** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released</span>
+00027 <span class="comment">** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version</span>
+00028 <span class="comment">** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X</span>
+00029 <span class="comment">** Window System(R) (Version 1.3), released October 19, 1998. This software</span>
+00030 <span class="comment">** was created using the OpenGL(R) version 1.2.1 Sample Implementation</span>
+00031 <span class="comment">** published by SGI, but has not been independently verified as being</span>
+00032 <span class="comment">** compliant with the OpenGL(R) version 1.2.1 Specification.</span>
+00033 <span class="comment">**</span>
+00034 <span class="comment">*/</span>
+00035
+00036 <span class="preprocessor">#ifndef _GLXVISUALS_H</span>
+00037 <span class="preprocessor"></span><span class="preprocessor">#define _GLXVISUALS_H</span>
+00038 <span class="preprocessor"></span>
+00039 <span class="preprocessor">#include &lt;GL/glxint.h&gt;</span>
+00040
+<a name="l00042"></a><a class="code" href="structdmxGlxVisualPrivate.html">00042</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00043 <span class="keywordtype">int</span> x_visual_depth;
+00044 <span class="keywordtype">int</span> x_visual_class;
+00045 } <a class="code" href="structdmxGlxVisualPrivate.html">dmxGlxVisualPrivate</a>;
+00046
+00047 __GLXvisualConfig *GetGLXVisualConfigs(Display *dpy,
+00048 <span class="keywordtype">int</span> screen,
+00049 <span class="keywordtype">int</span> *nconfigs);
+00050
+00051 __GLXFBConfig *GetGLXFBConfigs(Display *dpy,
+00052 <span class="keywordtype">int</span> glxMajorOpcode,
+00053 <span class="keywordtype">int</span> *nconfigs);
+00054
+00055 __GLXvisualConfig *GetGLXVisualConfigsFromFBConfigs(__GLXFBConfig *fbconfigs,
+00056 <span class="keywordtype">int</span> nfbconfigs,
+00057 XVisualInfo *visuals,
+00058 <span class="keywordtype">int</span> nvisuals,
+00059 __GLXvisualConfig
+00060 *glxConfigs,
+00061 <span class="keywordtype">int</span> nGlxConfigs,
+00062 <span class="keywordtype">int</span> *nconfigs);
+00063
+00064 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxarg_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxarg_8c.html
new file mode 100644
index 000000000..db05599a6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxarg_8c.html
@@ -0,0 +1,239 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxarg.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxarg_8h-source.html">dmxarg.h</a>"</code><br>
+<code>#include &lt;stdio.h&gt;</code><br>
+<code>#include &lt;string.h&gt;</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__dmxArg.html">_dmxArg</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__dmxArg.html">dmxArg</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxarg_8c.html#a1">dmxArgCreate</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxarg_8c.html#a2">dmxArgFree</a> (<a class="el" href="struct__dmxArg.html">dmxArg</a> a)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxarg_8c.html#a3">dmxArgAdd</a> (<a class="el" href="struct__dmxArg.html">dmxArg</a> a, const char *string)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>const char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxarg_8c.html#a4">dmxArgV</a> (<a class="el" href="struct__dmxArg.html">dmxArg</a> a, int item)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxarg_8c.html#a5">dmxArgC</a> (<a class="el" href="struct__dmxArg.html">dmxArg</a> a)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__dmxArg.html">dmxArg</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxarg_8c.html#a6">dmxArgParse</a> (const char *string)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Generic comma-delimited argument processing.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a3" doxytag="dmxarg.c::dmxArgAdd" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxArgAdd </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__dmxArg.html">dmxArg</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>a</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>string</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Add the <em>string</em> as the next argument in the <em>dmxArg</em> object. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxarg.c::dmxArgC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxArgC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__dmxArg.html">dmxArg</a>&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>a</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the number of arguments in the <em>dmxArg</em> object. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxarg.c::dmxArgCreate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__dmxArg.html">dmxArg</a> dmxArgCreate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create an (externally opaque) <em>dmxArg</em> object. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxarg.c::dmxArgFree" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxArgFree </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__dmxArg.html">dmxArg</a>&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>a</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Free the specified <em>dmxArg</em> object. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxarg.c::dmxArgParse" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__dmxArg.html">dmxArg</a> dmxArgParse </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>string</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Parse a string into arguments delimited by commas. Return a new <em>dmxArg</em> object containing the arguments. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxarg.c::dmxArgV" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> const char* dmxArgV </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__dmxArg.html">dmxArg</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>a</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>item</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the argument number <em>item</em> in the <em>dmxArg</em> object. Arguments are 0 based. NULL will be returned for values less than 0 or equal to or greater than the number of arguments in the object. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxarg_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxarg_8h-source.html
new file mode 100644
index 000000000..1f2fbce39
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxarg_8h-source.html
@@ -0,0 +1,69 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxarg.h</h1><a href="dmxarg_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _DMXARG_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _DMXARG_H_</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__dmxArg.html">_dmxArg</a> *<a class="code" href="struct__dmxArg.html">dmxArg</a>;
+00042
+00043 <span class="keyword">extern</span> <a class="code" href="struct__dmxArg.html">dmxArg</a> <a class="code" href="dmxarg_8c.html#a1">dmxArgCreate</a>(<span class="keywordtype">void</span>);
+00044 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxarg_8c.html#a2">dmxArgFree</a>(<a class="code" href="struct__dmxArg.html">dmxArg</a> a);
+00045 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxarg_8c.html#a3">dmxArgAdd</a>(<a class="code" href="struct__dmxArg.html">dmxArg</a> a, <span class="keyword">const</span> <span class="keywordtype">char</span> *string);
+00046 <span class="keyword">extern</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="dmxarg_8c.html#a4">dmxArgV</a>(<a class="code" href="struct__dmxArg.html">dmxArg</a> a, <span class="keywordtype">int</span> item);
+00047 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxarg_8c.html#a5">dmxArgC</a>(<a class="code" href="struct__dmxArg.html">dmxArg</a> a);
+00048 <span class="keyword">extern</span> <a class="code" href="struct__dmxArg.html">dmxArg</a> <a class="code" href="dmxarg_8c.html#a6">dmxArgParse</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *string);
+00049
+00050 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxarg_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxarg_8h.html
new file mode 100644
index 000000000..41fd707e9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxarg_8h.html
@@ -0,0 +1,235 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxarg.h File Reference</h1>
+<p>
+<a href="dmxarg_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__dmxArg.html">dmxArg</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxarg_8h.html#a1">dmxArgCreate</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxarg_8h.html#a2">dmxArgFree</a> (<a class="el" href="struct__dmxArg.html">dmxArg</a> a)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxarg_8h.html#a3">dmxArgAdd</a> (<a class="el" href="struct__dmxArg.html">dmxArg</a> a, const char *string)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>const char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxarg_8h.html#a4">dmxArgV</a> (<a class="el" href="struct__dmxArg.html">dmxArg</a> a, int item)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxarg_8h.html#a5">dmxArgC</a> (<a class="el" href="struct__dmxArg.html">dmxArg</a> a)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__dmxArg.html">dmxArg</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxarg_8h.html#a6">dmxArgParse</a> (const char *string)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to argument handling functions. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxarg_8c.html">dmxarg.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a3" doxytag="dmxarg.h::dmxArgAdd" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxArgAdd </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__dmxArg.html">dmxArg</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>a</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>string</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Add the <em>string</em> as the next argument in the <em>dmxArg</em> object. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxarg.h::dmxArgC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxArgC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__dmxArg.html">dmxArg</a>&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>a</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the number of arguments in the <em>dmxArg</em> object. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxarg.h::dmxArgCreate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__dmxArg.html">dmxArg</a> dmxArgCreate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create an (externally opaque) <em>dmxArg</em> object. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxarg.h::dmxArgFree" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxArgFree </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__dmxArg.html">dmxArg</a>&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>a</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Free the specified <em>dmxArg</em> object. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxarg.h::dmxArgParse" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__dmxArg.html">dmxArg</a> dmxArgParse </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>string</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Parse a string into arguments delimited by commas. Return a new <em>dmxArg</em> object containing the arguments. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxarg.h::dmxArgV" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> const char* dmxArgV </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__dmxArg.html">dmxArg</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>a</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>item</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the argument number <em>item</em> in the <em>dmxArg</em> object. Arguments are 0 based. NULL will be returned for values less than 0 or equal to or greater than the number of arguments in the object. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxbackend_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxbackend_8c.html
new file mode 100644
index 000000000..1fde71a99
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxbackend_8c.html
@@ -0,0 +1,427 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxbackend.c File Reference</h1><code>#include "<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxbackend_8h-source.html">dmxbackend.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcommon_8h-source.html">dmxcommon.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxconsole_8h-source.html">dmxconsole.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcursor_8h-source.html">dmxcursor.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxprop_8h-source.html">dmxprop.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcb_8h-source.html">dmxcb.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxevents_8h-source.html">dmxevents.h</a>"</code><br>
+<code>#include "<a class="el" href="ChkNotMaskEv_8h-source.html">ChkNotMaskEv.h</a>"</code><br>
+<code>#include "inputstr.h"</code><br>
+<code>#include "input.h"</code><br>
+<code>#include "keysym.h"</code><br>
+<code>#include "mipointer.h"</code><br>
+<code>#include "scrnintstr.h"</code><br>
+<code>#include "windowstr.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html">_myPrivate</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>pointer&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8c.html#a12">dmxBackendCreatePrivate</a> (DeviceIntPtr pDevice)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8c.html#a13">dmxBackendDestroyPrivate</a> (pointer private)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8c.html#a24">dmxBackendUpdatePosition</a> (pointer private, int x, int y)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8c.html#a25">dmxBackendCollectEvents</a> (DevicePtr pDev, dmxMotionProcPtr motion, dmxEnqueueProcPtr enqueue, dmxCheckSpecialProcPtr checkspecial, DMXBlockType block)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8c.html#a26">dmxBackendProcessInput</a> (pointer private)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8c.html#a29">dmxBackendLateReInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8c.html#a30">dmxBackendInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8c.html#a31">dmxBackendMouGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8c.html#a32">dmxBackendKbdGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8c.html#a33">dmxBackendFunctions</a> (pointer private, DMXFunctionType function)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+These routines support taking input from devices on the backend (output) displays. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxcommon_8c.html">dmxcommon.c</a>.</dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a25" doxytag="dmxbackend.c::dmxBackendCollectEvents" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBackendCollectEvents </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>dmxMotionProcPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>motion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>dmxEnqueueProcPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>enqueue</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>dmxCheckSpecialProcPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>checkspecial</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXBlockType&nbsp;</td>
+ <td class="mdname" nowrap> <em>block</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get events from the X queue on the backend servers and put the events into the DMX event queue. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxbackend.c::dmxBackendCreatePrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> pointer dmxBackendCreatePrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDevice</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create and return a private data structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmxbackend.c::dmxBackendDestroyPrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBackendDestroyPrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>private</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy the private data structure. No checking is performed to verify that the structure was actually created by <a class="el" href="dmxbackend_8h.html#a0">dmxBackendCreatePrivate</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a33" doxytag="dmxbackend.c::dmxBackendFunctions" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxBackendFunctions </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>private</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXFunctionType&nbsp;</td>
+ <td class="mdname" nowrap> <em>function</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Process #DMXFunctionType functions. The only function handled here is to acknowledge a pending server shutdown. </td>
+ </tr>
+</table>
+<a class="anchor" name="a30" doxytag="dmxbackend.c::dmxBackendInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBackendInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialized the backend device described by <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a32" doxytag="dmxbackend.c::dmxBackendKbdGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBackendKbdGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get information about the backend keyboard (for initialization). </td>
+ </tr>
+</table>
+<a class="anchor" name="a29" doxytag="dmxbackend.c::dmxBackendLateReInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBackendLateReInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Re-initialized the backend device described by <em>pDev</em> (after a reconfig). </td>
+ </tr>
+</table>
+<a class="anchor" name="a31" doxytag="dmxbackend.c::dmxBackendMouGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBackendMouGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get information about the backend pointer (for initialization). </td>
+ </tr>
+</table>
+<a class="anchor" name="a26" doxytag="dmxbackend.c::dmxBackendProcessInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBackendProcessInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>private</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Called after input events are processed from the DMX queue. No event processing actually takes place here, but this is a convenient place to update the pointer. </td>
+ </tr>
+</table>
+<a class="anchor" name="a24" doxytag="dmxbackend.c::dmxBackendUpdatePosition" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBackendUpdatePosition </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>private</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine is called from #dmxCoreMotion for each motion event. #x and #y are global coordinants. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxbackend_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxbackend_8h-source.html
new file mode 100644
index 000000000..9b58dac3e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxbackend_8h-source.html
@@ -0,0 +1,75 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxbackend.h</h1><a href="dmxbackend_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00039 <span class="preprocessor">#ifndef _DMXBACKEND_H_</span>
+00040 <span class="preprocessor"></span><span class="preprocessor">#define _DMXBACKEND_H_</span>
+00041 <span class="preprocessor"></span>
+00042 <span class="keyword">extern</span> pointer <a class="code" href="dmxbackend_8c.html#a12">dmxBackendCreatePrivate</a>(DeviceIntPtr pDevice);
+00043 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxbackend_8c.html#a13">dmxBackendDestroyPrivate</a>(pointer <span class="keyword">private</span>);
+00044 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxbackend_8c.html#a30">dmxBackendInit</a>(DevicePtr pDev);
+00045 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxbackend_8c.html#a29">dmxBackendLateReInit</a>(DevicePtr pDev);
+00046 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxbackend_8c.html#a31">dmxBackendMouGetInfo</a>(DevicePtr pDev, <a class="code" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info);
+00047 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxbackend_8c.html#a32">dmxBackendKbdGetInfo</a>(DevicePtr pDev, <a class="code" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info);
+00048 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxbackend_8c.html#a25">dmxBackendCollectEvents</a>(DevicePtr pDev,
+00049 dmxMotionProcPtr motion,
+00050 dmxEnqueueProcPtr enqueue,
+00051 dmxCheckSpecialProcPtr checkspecial,
+00052 DMXBlockType block);
+00053 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxbackend_8c.html#a26">dmxBackendProcessInput</a>(pointer <span class="keyword">private</span>);
+00054 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxbackend_8c.html#a33">dmxBackendFunctions</a>(pointer <span class="keyword">private</span>, DMXFunctionType function);
+00055 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxbackend_8c.html#a24">dmxBackendUpdatePosition</a>(pointer <span class="keyword">private</span>, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y);
+00056
+00057 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxbackend_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxbackend_8h.html
new file mode 100644
index 000000000..2a601be0c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxbackend_8h.html
@@ -0,0 +1,411 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxbackend.h File Reference</h1>
+<p>
+<a href="dmxbackend_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>pointer&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8h.html#a0">dmxBackendCreatePrivate</a> (DeviceIntPtr pDevice)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8h.html#a1">dmxBackendDestroyPrivate</a> (pointer private)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8h.html#a2">dmxBackendInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8h.html#a3">dmxBackendLateReInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8h.html#a4">dmxBackendMouGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8h.html#a5">dmxBackendKbdGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8h.html#a6">dmxBackendCollectEvents</a> (DevicePtr pDev, dmxMotionProcPtr motion, dmxEnqueueProcPtr enqueue, dmxCheckSpecialProcPtr checkspecial, DMXBlockType block)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8h.html#a7">dmxBackendProcessInput</a> (pointer private)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8h.html#a8">dmxBackendFunctions</a> (pointer private, DMXFunctionType function)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxbackend_8h.html#a9">dmxBackendUpdatePosition</a> (pointer private, int x, int y)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to backend input device support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxbackend_8c.html">dmxbackend.c</a> <p>
+<a class="el" href="dmxcommon_8c.html">dmxcommon.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a6" doxytag="dmxbackend.h::dmxBackendCollectEvents" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBackendCollectEvents </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>dmxMotionProcPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>motion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>dmxEnqueueProcPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>enqueue</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>dmxCheckSpecialProcPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>checkspecial</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXBlockType&nbsp;</td>
+ <td class="mdname" nowrap> <em>block</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get events from the X queue on the backend servers and put the events into the DMX event queue. </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxbackend.h::dmxBackendCreatePrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> pointer dmxBackendCreatePrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDevice</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create and return a private data structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxbackend.h::dmxBackendDestroyPrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBackendDestroyPrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>private</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy the private data structure. No checking is performed to verify that the structure was actually created by <a class="el" href="dmxbackend_8h.html#a0">dmxBackendCreatePrivate</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxbackend.h::dmxBackendFunctions" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxBackendFunctions </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>private</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXFunctionType&nbsp;</td>
+ <td class="mdname" nowrap> <em>function</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Process #DMXFunctionType functions. The only function handled here is to acknowledge a pending server shutdown. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxbackend.h::dmxBackendInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBackendInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialized the backend device described by <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxbackend.h::dmxBackendKbdGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBackendKbdGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get information about the backend keyboard (for initialization). </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxbackend.h::dmxBackendLateReInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBackendLateReInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Re-initialized the backend device described by <em>pDev</em> (after a reconfig). </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxbackend.h::dmxBackendMouGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBackendMouGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get information about the backend pointer (for initialization). </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxbackend.h::dmxBackendProcessInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBackendProcessInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>private</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Called after input events are processed from the DMX queue. No event processing actually takes place here, but this is a convenient place to update the pointer. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxbackend.h::dmxBackendUpdatePosition" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBackendUpdatePosition </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>private</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine is called from #dmxCoreMotion for each motion event. #x and #y are global coordinants. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcb_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcb_8c.html
new file mode 100644
index 000000000..072c3ff06
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcb_8c.html
@@ -0,0 +1,184 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxcb.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcb_8h-source.html">dmxcb.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxinput_8h-source.html">dmxinput.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxlog_8h-source.html">dmxlog.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcb_8c.html#a7">dmxSetWidthHeight</a> (int width, int height)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcb_8c.html#a8">dmxComputeWidthHeight</a> (<a class="el" href="dmxcb_8h.html#a7">DMXRecomputeFlag</a> flag)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcb_8c.html#a9">dmxConnectionBlockCallback</a> (void)</td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcb_8c.html#a5">dmxGlobalWidth</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcb_8c.html#a6">dmxGlobalHeight</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This code queries and modifies the connection block.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a8" doxytag="dmxcb.c::dmxComputeWidthHeight" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxComputeWidthHeight </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="dmxcb_8h.html#a7">DMXRecomputeFlag</a>&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>flag</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Computes the global bounding box for DMX. This may be larger than the one computed by Xinerama because of the DMX configuration file. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxcb.c::dmxConnectionBlockCallback" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConnectionBlockCallback </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+A callback routine that hooks into Xinerama and provides a convenient place to print summary log information during server startup. This routine does not modify any values. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxcb.c::dmxSetWidthHeight" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSetWidthHeight </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>width</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>height</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+We may want the wall dimensions to be different from the bounding box dimensions that Xinerama computes, so save those and update them here. </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a6" doxytag="dmxcb.c::dmxGlobalHeight" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxcb_8h.html#a1">dmxGlobalHeight</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+The cursor position, in global coordinates. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxcb.c::dmxGlobalWidth" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxcb_8h.html#a0">dmxGlobalWidth</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+The cursor position, in global coordinates. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcb_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcb_8h-source.html
new file mode 100644
index 000000000..ff57d4982
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcb_8h-source.html
@@ -0,0 +1,70 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxcb.h</h1><a href="dmxcb_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001,2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00039 <span class="preprocessor">#ifndef _DMXCB_H_</span>
+00040 <span class="preprocessor"></span><span class="preprocessor">#define _DMXCB_H_</span>
+00041 <span class="preprocessor"></span>
+<a name="l00042"></a><a class="code" href="dmxcb_8h.html#a0">00042</a> <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxcb_8c.html#a5">dmxGlobalWidth</a>, <a class="code" href="dmxcb_8c.html#a6">dmxGlobalHeight</a>;
+00043
+<a name="l00046"></a><a class="code" href="dmxcb_8h.html#a7">00046</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> {
+00047 DMX_RECOMPUTE_BOUNDING_BOX,
+00048 DMX_NO_RECOMPUTE_BOUNDING_BOX
+00049 } <a class="code" href="dmxcb_8h.html#a7">DMXRecomputeFlag</a>;
+00050
+00051 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcb_8c.html#a7">dmxSetWidthHeight</a>(<span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height);
+00052 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcb_8c.html#a8">dmxComputeWidthHeight</a>(DMXRecomputeFlag flag);
+00053 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcb_8c.html#a9">dmxConnectionBlockCallback</a>(<span class="keywordtype">void</span>);
+00054 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcb_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcb_8h.html
new file mode 100644
index 000000000..78eaf4f3a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcb_8h.html
@@ -0,0 +1,209 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxcb.h File Reference</h1>
+<p>
+<a href="dmxcb_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Enumerations</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>enum &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcb_8h.html#a7">DMXRecomputeFlag</a> </td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcb_8h.html#a4">dmxSetWidthHeight</a> (int width, int height)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcb_8h.html#a5">dmxComputeWidthHeight</a> (<a class="el" href="dmxcb_8h.html#a7">DMXRecomputeFlag</a> flag)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcb_8h.html#a6">dmxConnectionBlockCallback</a> (void)</td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcb_8h.html#a0">dmxGlobalWidth</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcb_8h.html#a1">dmxGlobalHeight</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Header file for connection block functions. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxcb_8c.html">dmxcb.c</a>.</dd></dl>
+<hr><h2>Enumeration Type Documentation</h2>
+<a class="anchor" name="a7" doxytag="dmxcb.h::DMXRecomputeFlag" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> enum <a class="el" href="dmxcb_8h.html#a7">DMXRecomputeFlag</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+<a class="el" href="dmxcb_8h.html#a5">dmxComputeWidthHeight</a> can either recompute the global bounding box or not. </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a5" doxytag="dmxcb.h::dmxComputeWidthHeight" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxComputeWidthHeight </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="dmxcb_8h.html#a7">DMXRecomputeFlag</a>&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>flag</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Computes the global bounding box for DMX. This may be larger than the one computed by Xinerama because of the DMX configuration file. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxcb.h::dmxConnectionBlockCallback" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConnectionBlockCallback </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+A callback routine that hooks into Xinerama and provides a convenient place to print summary log information during server startup. This routine does not modify any values. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxcb.h::dmxSetWidthHeight" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSetWidthHeight </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>width</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>height</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+We may want the wall dimensions to be different from the bounding box dimensions that Xinerama computes, so save those and update them here. </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a1" doxytag="dmxcb.h::dmxGlobalHeight" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxcb_8h.html#a1">dmxGlobalHeight</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+The cursor position, in global coordinates. </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxcb.h::dmxGlobalWidth" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxcb_8h.html#a0">dmxGlobalWidth</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+The cursor position, in global coordinates. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxclient_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxclient_8h-source.html
new file mode 100644
index 000000000..39d1b3bc0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxclient_8h-source.html
@@ -0,0 +1,168 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxclient.h</h1><a href="dmxclient_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright (c) 1995 X Consortium</span>
+00004 <span class="comment"> * Copyright 2004 Red Hat Inc., Durham, North Carolina.</span>
+00005 <span class="comment"> *</span>
+00006 <span class="comment"> * All Rights Reserved.</span>
+00007 <span class="comment"> *</span>
+00008 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00009 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00010 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00011 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00012 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00013 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00014 <span class="comment"> * subject to the following conditions:</span>
+00015 <span class="comment"> *</span>
+00016 <span class="comment"> * The above copyright notice and this permission notice shall be</span>
+00017 <span class="comment"> * included in all copies or substantial portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT, THE X CONSORTIUM,</span>
+00023 <span class="comment"> * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
+00024 <span class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,</span>
+00025 <span class="comment"> * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR</span>
+00026 <span class="comment"> * OTHER DEALINGS IN THE SOFTWARE.</span>
+00027 <span class="comment"> *</span>
+00028 <span class="comment"> * Except as contained in this notice, the name of the X Consortium</span>
+00029 <span class="comment"> * shall not be used in advertising or otherwise to promote the sale,</span>
+00030 <span class="comment"> * use or other dealings in this Software without prior written</span>
+00031 <span class="comment"> * authorization from the X Consortium.</span>
+00032 <span class="comment"> */</span>
+00033
+00034 <span class="comment">/*</span>
+00035 <span class="comment"> * Derived from hw/xnest/Xnest.h by Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00036 <span class="comment"> */</span>
+00037
+00042 <span class="preprocessor">#ifndef _DMXCLIENT_H_</span>
+00043 <span class="preprocessor"></span><span class="preprocessor">#define _DMXCLIENT_H_</span>
+00044 <span class="preprocessor"></span>
+00045 <span class="preprocessor">#define GC XlibGC</span>
+00046 <span class="preprocessor"></span>
+00047 <span class="preprocessor">#ifdef _XSERVER64</span>
+00048 <span class="preprocessor"></span><span class="preprocessor">#define DMX64</span>
+00049 <span class="preprocessor"></span><span class="preprocessor">#undef _XSERVER64</span>
+00050 <span class="preprocessor"></span><span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> XID64;
+00051 <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> Mask64;
+00052 <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> Atom64;
+00053 <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> VisualID64;
+00054 <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> Time64;
+00055 <span class="preprocessor">#define XID XID64</span>
+00056 <span class="preprocessor"></span><span class="preprocessor">#define Mask Mask64</span>
+00057 <span class="preprocessor"></span><span class="preprocessor">#define Atom Atom64</span>
+00058 <span class="preprocessor"></span><span class="preprocessor">#define VisualID VisualID64</span>
+00059 <span class="preprocessor"></span><span class="preprocessor">#define Time Time64</span>
+00060 <span class="preprocessor"></span><span class="keyword">typedef</span> XID Window64;
+00061 <span class="keyword">typedef</span> XID Drawable64;
+00062 <span class="keyword">typedef</span> XID Font64;
+00063 <span class="keyword">typedef</span> XID Pixmap64;
+00064 <span class="keyword">typedef</span> XID Cursor64;
+00065 <span class="keyword">typedef</span> XID Colormap64;
+00066 <span class="keyword">typedef</span> XID GContext64;
+00067 <span class="keyword">typedef</span> XID KeySym64;
+00068 <span class="preprocessor">#define Window Window64</span>
+00069 <span class="preprocessor"></span><span class="preprocessor">#define Drawable Drawable64</span>
+00070 <span class="preprocessor"></span><span class="preprocessor">#define Font Font64</span>
+00071 <span class="preprocessor"></span><span class="preprocessor">#define Pixmap Pixmap64</span>
+00072 <span class="preprocessor"></span><span class="preprocessor">#define Cursor Cursor64</span>
+00073 <span class="preprocessor"></span><span class="preprocessor">#define Colormap Colormap64</span>
+00074 <span class="preprocessor"></span><span class="preprocessor">#define GContext GContext64</span>
+00075 <span class="preprocessor"></span><span class="preprocessor">#define KeySym KeySym64</span>
+00076 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00077 <span class="preprocessor"></span>
+00078 <span class="preprocessor">#include &lt;X11/Xlib.h&gt;</span>
+00079 <span class="preprocessor">#include &lt;X11/Xlibint.h&gt;</span> <span class="comment">/* For _XExtension */</span>
+00080 <span class="preprocessor">#include &lt;X11/X.h&gt;</span> <span class="comment">/* from glxserver.h */</span>
+00081 <span class="preprocessor">#include &lt;X11/Xmd.h&gt;</span> <span class="comment">/* from glxserver.h */</span>
+00082 <span class="preprocessor">#include &lt;X11/Xproto.h&gt;</span>
+00083 <span class="preprocessor">#include &lt;X11/Xutil.h&gt;</span>
+00084 <span class="preprocessor">#include &lt;X11/Xatom.h&gt;</span>
+00085 <span class="preprocessor">#include &lt;X11/cursorfont.h&gt;</span>
+00086 <span class="preprocessor">#include &lt;X11/Xmu/SysUtil.h&gt;</span> <span class="comment">/* For XmuSnprintf */</span>
+00087
+00088 <span class="preprocessor">#ifdef SHAPE</span>
+00089 <span class="preprocessor"></span><span class="preprocessor">#include &lt;X11/extensions/shape.h&gt;</span>
+00090 <span class="preprocessor">#endif</span>
+00091 <span class="preprocessor"></span>
+00092 <span class="preprocessor">#ifdef RENDER</span>
+00093 <span class="preprocessor"></span><span class="preprocessor">#include &lt;X11/extensions/Xrender.h&gt;</span>
+00094 <span class="preprocessor">#undef PictFormatType</span>
+00095 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00096 <span class="preprocessor"></span>
+00097 <span class="preprocessor">#ifdef XKB</span>
+00098 <span class="preprocessor"></span><span class="preprocessor">#include &lt;X11/extensions/XKB.h&gt;</span>
+00099 <span class="preprocessor">#include &lt;X11/extensions/XKBstr.h&gt;</span>
+00100 <span class="preprocessor">#endif</span>
+00101 <span class="preprocessor"></span>
+00102 <span class="preprocessor">#ifdef XINPUT</span>
+00103 <span class="preprocessor"></span><span class="preprocessor">#include &lt;X11/extensions/XI.h&gt;</span>
+00104 <span class="preprocessor">#endif</span>
+00105 <span class="preprocessor"></span>
+00106 <span class="comment">/* Always include these, since we query them even if we don't export XINPUT. */</span>
+00107 <span class="preprocessor">#include &lt;X11/extensions/XInput.h&gt;</span> <span class="comment">/* For XDevice */</span>
+00108 <span class="preprocessor">#include &lt;X11/extensions/Xext.h&gt;</span>
+00109
+00110 <span class="preprocessor">#undef GC</span>
+00111 <span class="preprocessor"></span>
+00112 <span class="preprocessor">#ifdef DMX64</span>
+00113 <span class="preprocessor"></span><span class="preprocessor">#define _XSERVER64</span>
+00114 <span class="preprocessor"></span><span class="preprocessor">#undef XID</span>
+00115 <span class="preprocessor"></span><span class="preprocessor">#undef Mask</span>
+00116 <span class="preprocessor"></span><span class="preprocessor">#undef Atom</span>
+00117 <span class="preprocessor"></span><span class="preprocessor">#undef VisualID</span>
+00118 <span class="preprocessor"></span><span class="preprocessor">#undef Time</span>
+00119 <span class="preprocessor"></span><span class="preprocessor">#undef Window</span>
+00120 <span class="preprocessor"></span><span class="preprocessor">#undef Drawable</span>
+00121 <span class="preprocessor"></span><span class="preprocessor">#undef Font</span>
+00122 <span class="preprocessor"></span><span class="preprocessor">#undef Pixmap</span>
+00123 <span class="preprocessor"></span><span class="preprocessor">#undef Cursor</span>
+00124 <span class="preprocessor"></span><span class="preprocessor">#undef Colormap</span>
+00125 <span class="preprocessor"></span><span class="preprocessor">#undef GContext</span>
+00126 <span class="preprocessor"></span><span class="preprocessor">#undef KeySym</span>
+00127 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00128 <span class="preprocessor"></span>
+00129 <span class="comment">/* These are in exglobals.h, but that conflicts with X11/extensions/XKBsrv.h */</span>
+00130 <span class="keyword">extern</span> <span class="keywordtype">int</span> ProximityIn;
+00131 <span class="keyword">extern</span> <span class="keywordtype">int</span> ProximityOut;
+00132 <span class="keyword">extern</span> <span class="keywordtype">int</span> DeviceValuator;
+00133 <span class="keyword">extern</span> <span class="keywordtype">int</span> DeviceMotionNotify;
+00134 <span class="keyword">extern</span> <span class="keywordtype">int</span> DeviceFocusIn;
+00135 <span class="keyword">extern</span> <span class="keywordtype">int</span> DeviceFocusOut;
+00136 <span class="keyword">extern</span> <span class="keywordtype">int</span> DeviceStateNotify;
+00137 <span class="keyword">extern</span> <span class="keywordtype">int</span> DeviceMappingNotify;
+00138 <span class="keyword">extern</span> <span class="keywordtype">int</span> ChangeDeviceNotify;
+00139
+00140 <span class="comment">/* Some protocol gets included last, after undefines. */</span>
+00141 <span class="preprocessor">#include &lt;X11/XKBlib.h&gt;</span>
+00142 <span class="preprocessor">#ifdef XKB</span>
+00143 <span class="preprocessor"></span><span class="preprocessor">#include &lt;X11/extensions/XKBproto.h&gt;</span>
+00144 <span class="preprocessor">#define XKB_IN_SERVER</span>
+00145 <span class="preprocessor"></span><span class="preprocessor">#include &lt;X11/extensions/XKBsrv.h&gt;</span>
+00146 <span class="preprocessor">#undef XPointer</span>
+00147 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00148 <span class="preprocessor"></span><span class="preprocessor">#include &lt;X11/extensions/XIproto.h&gt;</span>
+00149
+00150 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxclient_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxclient_8h.html
new file mode 100644
index 000000000..f5e62f572
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxclient_8h.html
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxclient.h File Reference</h1><code>#include &lt;X11/Xlib.h&gt;</code><br>
+<code>#include &lt;X11/Xlibint.h&gt;</code><br>
+<code>#include &lt;X11/X.h&gt;</code><br>
+<code>#include &lt;X11/Xmd.h&gt;</code><br>
+<code>#include &lt;X11/Xproto.h&gt;</code><br>
+<code>#include &lt;X11/Xutil.h&gt;</code><br>
+<code>#include &lt;X11/Xatom.h&gt;</code><br>
+<code>#include &lt;X11/cursorfont.h&gt;</code><br>
+<code>#include &lt;X11/Xmu/SysUtil.h&gt;</code><br>
+<code>#include &lt;X11/extensions/shape.h&gt;</code><br>
+<code>#include &lt;X11/extensions/Xrender.h&gt;</code><br>
+<code>#include &lt;X11/extensions/XKB.h&gt;</code><br>
+<code>#include &lt;X11/extensions/XKBstr.h&gt;</code><br>
+<code>#include &lt;X11/extensions/XI.h&gt;</code><br>
+<code>#include &lt;X11/extensions/XInput.h&gt;</code><br>
+<code>#include &lt;X11/extensions/Xext.h&gt;</code><br>
+<code>#include &lt;X11/XKBlib.h&gt;</code><br>
+<code>#include &lt;X11/extensions/XKBproto.h&gt;</code><br>
+<code>#include &lt;X11/extensions/XKBsrv.h&gt;</code><br>
+<code>#include &lt;X11/extensions/XIproto.h&gt;</code><br>
+
+<p>
+<a href="dmxclient_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file includes all client-side include files with proper wrapping. <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcmap_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcmap_8c.html
new file mode 100644
index 000000000..40f62a633
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcmap_8c.html
@@ -0,0 +1,265 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxcmap.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcmap_8h-source.html">dmxcmap.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxvisual_8h-source.html">dmxvisual.h</a>"</code><br>
+<code>#include "micmap.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8c.html#a2">dmxBECreateColormap</a> (ColormapPtr pColormap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8c.html#a3">dmxCreateColormap</a> (ColormapPtr pColormap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8c.html#a4">dmxBEFreeColormap</a> (ColormapPtr pColormap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8c.html#a5">dmxDestroyColormap</a> (ColormapPtr pColormap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8c.html#a6">dmxInstallColormap</a> (ColormapPtr pColormap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8c.html#a7">dmxStoreColors</a> (ColormapPtr pColormap, int ndef, xColorItem *pdef)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8c.html#a8">dmxCreateDefColormap</a> (ScreenPtr pScreen)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Colormap support.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a2" doxytag="dmxcmap.c::dmxBECreateColormap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBECreateColormap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ColormapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pColormap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create <em>pColormap</em> on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxcmap.c::dmxBEFreeColormap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBEFreeColormap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ColormapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pColormap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy <em>pColormap</em> on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxcmap.c::dmxCreateColormap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxCreateColormap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ColormapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pColormap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create colormap on back-end server associated with <em>pColormap's</em> screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxcmap.c::dmxCreateDefColormap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxCreateDefColormap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create the DMX server's default colormap. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxcmap.c::dmxDestroyColormap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDestroyColormap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ColormapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pColormap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy colormap on back-end server associated with <em>pColormap's</em> screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxcmap.c::dmxInstallColormap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInstallColormap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ColormapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pColormap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Install colormap on back-end server associated with <em>pColormap's</em> screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxcmap.c::dmxStoreColors" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxStoreColors </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ColormapPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pColormap</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>ndef</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xColorItem *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pdef</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Store colors in <em>pColormap</em> on back-end server associated with <em>pColormap's</em> screen. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcmap_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcmap_8h-source.html
new file mode 100644
index 000000000..b3a9b291a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcmap_8h-source.html
@@ -0,0 +1,86 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxcmap.h</h1><a href="dmxcmap_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002-2004 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Kevin E. Martin &lt;kem@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef DMXCMAP_H</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define DMXCMAP_H</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="preprocessor">#include "colormapst.h"</span>
+00042
+<a name="l00044"></a><a class="code" href="struct__dmxColormapPriv.html">00044</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__dmxColormapPriv.html">_dmxColormapPriv</a> {
+00045 Colormap cmap;
+00046 } <a class="code" href="struct__dmxColormapPriv.html">dmxColormapPrivRec</a>, *<a class="code" href="struct__dmxColormapPriv.html">dmxColormapPrivPtr</a>;
+00047
+00048
+00049 <span class="keyword">extern</span> Bool <a class="code" href="dmxcmap_8c.html#a3">dmxCreateColormap</a>(ColormapPtr pColormap);
+00050 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcmap_8c.html#a5">dmxDestroyColormap</a>(ColormapPtr pColormap);
+00051 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcmap_8c.html#a6">dmxInstallColormap</a>(ColormapPtr pColormap);
+00052 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcmap_8c.html#a7">dmxStoreColors</a>(ColormapPtr pColormap, <span class="keywordtype">int</span> ndef, xColorItem *pdef);
+00053
+00054 <span class="keyword">extern</span> Bool <a class="code" href="dmxcmap_8c.html#a8">dmxCreateDefColormap</a>(ScreenPtr pScreen);
+00055
+00056 <span class="keyword">extern</span> Bool <a class="code" href="dmxcmap_8c.html#a2">dmxBECreateColormap</a>(ColormapPtr pColormap);
+00057 <span class="keyword">extern</span> Bool <a class="code" href="dmxcmap_8c.html#a4">dmxBEFreeColormap</a>(ColormapPtr pColormap);
+00058
+<a name="l00060"></a><a class="code" href="dmxcmap_8h.html#a4">00060</a> <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxcmap_8h.html#a4">dmxColormapPrivateIndex</a>;
+00061
+<a name="l00063"></a><a class="code" href="dmxcmap_8h.html#a0">00063</a> <span class="preprocessor">#define DMX_SET_COLORMAP_PRIV(_pCMap, _pCMapPriv) \</span>
+00064 <span class="preprocessor"> (_pCMap)-&gt;devPrivates[dmxColormapPrivateIndex].ptr \</span>
+00065 <span class="preprocessor"> = (pointer)(_pCMapPriv);</span>
+00066 <span class="preprocessor"></span>
+<a name="l00068"></a><a class="code" href="dmxcmap_8h.html#a1">00068</a> <span class="preprocessor">#define DMX_GET_COLORMAP_PRIV(_pCMap) \</span>
+00069 <span class="preprocessor"> (dmxColormapPrivPtr)(_pCMap)-&gt;devPrivates[dmxColormapPrivateIndex].ptr</span>
+00070 <span class="preprocessor"></span>
+00071 <span class="preprocessor">#endif </span><span class="comment">/* DMXCMAP_H */</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcmap_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcmap_8h.html
new file mode 100644
index 000000000..f22a97b0e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcmap_8h.html
@@ -0,0 +1,408 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxcmap.h File Reference</h1><code>#include "colormapst.h"</code><br>
+
+<p>
+<a href="dmxcmap_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__dmxColormapPriv.html">_dmxColormapPriv</a></td></tr>
+
+<tr><td colspan=2><br><h2>Defines</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8h.html#a0">DMX_SET_COLORMAP_PRIV</a>(_pCMap, _pCMapPriv)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8h.html#a1">DMX_GET_COLORMAP_PRIV</a>(_pCMap)&nbsp;&nbsp;&nbsp;(<a class="el" href="struct__dmxColormapPriv.html">dmxColormapPrivPtr</a>)(_pCMap)-&gt;devPrivates[<a class="el" href="dmxscrinit_8c.html#a6">dmxColormapPrivateIndex</a>].ptr</td></tr>
+
+<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__dmxColormapPriv.html">_dmxColormapPriv</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8h.html#a2">dmxColormapPrivRec</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__dmxColormapPriv.html">_dmxColormapPriv</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8h.html#a3">dmxColormapPrivPtr</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8h.html#a5">dmxCreateColormap</a> (ColormapPtr pColormap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8h.html#a6">dmxDestroyColormap</a> (ColormapPtr pColormap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8h.html#a7">dmxInstallColormap</a> (ColormapPtr pColormap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8h.html#a8">dmxStoreColors</a> (ColormapPtr pColormap, int ndef, xColorItem *pdef)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8h.html#a9">dmxCreateDefColormap</a> (ScreenPtr pScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8h.html#a10">dmxBECreateColormap</a> (ColormapPtr pColormap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8h.html#a11">dmxBEFreeColormap</a> (ColormapPtr pColormap)</td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcmap_8h.html#a4">dmxColormapPrivateIndex</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Header file for colormap support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxcmap_8c.html">dmxcmap.c</a>.</dd></dl>
+<hr><h2>Define Documentation</h2>
+<a class="anchor" name="a1" doxytag="dmxcmap.h::DMX_GET_COLORMAP_PRIV" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_GET_COLORMAP_PRIV</td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">_pCMap&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap>&nbsp;&nbsp;&nbsp;(<a class="el" href="struct__dmxColormapPriv.html">dmxColormapPrivPtr</a>)(_pCMap)-&gt;devPrivates[<a class="el" href="dmxscrinit_8c.html#a6">dmxColormapPrivateIndex</a>].ptr
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get colormap private structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxcmap.h::DMX_SET_COLORMAP_PRIV" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_SET_COLORMAP_PRIV</td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">_pCMap, <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>_pCMapPriv&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+<b>Value:</b><div class="fragment"><pre>(_pCMap)-&gt;devPrivates[<a class="code" href="dmxcmap_8h.html#a4">dmxColormapPrivateIndex</a>].ptr \
+ = (pointer)(_pCMapPriv);
+</pre></div>Set colormap private structure. </td>
+ </tr>
+</table>
+<hr><h2>Typedef Documentation</h2>
+<a class="anchor" name="a3" doxytag="dmxcmap.h::dmxColormapPrivPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__dmxColormapPriv.html">_dmxColormapPriv</a> * <a class="el" href="struct__dmxColormapPriv.html">dmxColormapPrivPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Colormap private area. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxcmap.h::dmxColormapPrivRec" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__dmxColormapPriv.html">_dmxColormapPriv</a> <a class="el" href="struct__dmxColormapPriv.html">dmxColormapPrivRec</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Colormap private area. </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a10" doxytag="dmxcmap.h::dmxBECreateColormap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBECreateColormap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ColormapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pColormap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create <em>pColormap</em> on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxcmap.h::dmxBEFreeColormap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBEFreeColormap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ColormapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pColormap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy <em>pColormap</em> on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxcmap.h::dmxCreateColormap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxCreateColormap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ColormapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pColormap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create colormap on back-end server associated with <em>pColormap's</em> screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxcmap.h::dmxCreateDefColormap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxCreateDefColormap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create the DMX server's default colormap. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxcmap.h::dmxDestroyColormap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDestroyColormap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ColormapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pColormap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy colormap on back-end server associated with <em>pColormap's</em> screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxcmap.h::dmxInstallColormap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInstallColormap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ColormapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pColormap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Install colormap on back-end server associated with <em>pColormap's</em> screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxcmap.h::dmxStoreColors" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxStoreColors </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ColormapPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pColormap</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>ndef</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xColorItem *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pdef</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Store colors in <em>pColormap</em> on back-end server associated with <em>pColormap's</em> screen. </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a4" doxytag="dmxcmap.h::dmxColormapPrivateIndex" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxscrinit_8c.html#a6">dmxColormapPrivateIndex</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Private index for Colormaps </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcommon_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcommon_8c.html
new file mode 100644
index 000000000..3e0459c12
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcommon_8c.html
@@ -0,0 +1,701 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxcommon.c File Reference</h1><code>#include "<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcommon_8h-source.html">dmxcommon.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxconsole_8h-source.html">dmxconsole.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxprop_8h-source.html">dmxprop.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxmap_8h-source.html">dmxmap.h</a>"</code><br>
+<code>#include "inputstr.h"</code><br>
+<code>#include "input.h"</code><br>
+<code>#include "keysym.h"</code><br>
+<code>#include "mipointer.h"</code><br>
+<code>#include "scrnintstr.h"</code><br>
+<code>#include &lt;unistd.h&gt;</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html">_myPrivate</a></td></tr>
+
+<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__myPrivate.html">_myPrivate</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a4">myPrivate</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a9">dmxCommonKbdCtrl</a> (DevicePtr pDev, KeybdCtrl *ctrl)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a10">dmxCommonMouCtrl</a> (DevicePtr pDev, PtrCtrl *ctrl)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a11">dmxCommonKbdBell</a> (DevicePtr pDev, int percent, int volume, int pitch, int duration)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a12">dmxCommonKbdGetMap</a> (DevicePtr pDev, KeySymsPtr pKeySyms, CARD8 *pModMap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a13">dmxCommonKbdGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a14">dmxCommonKbdOn</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a15">dmxCommonKbdOff</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a16">dmxCommonOthOn</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a17">dmxCommonOthOff</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a18">dmxCommonOthGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a19">dmxCommonMouGetMap</a> (DevicePtr pDev, unsigned char *map, int *nButtons)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a23">dmxCommonMouOn</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a24">dmxCommonMouOff</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a25">dmxFindPointerScreen</a> (int x, int y)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>pointer&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a26">dmxCommonCopyPrivate</a> (DeviceIntPtr pDevice)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a27">dmxCommonSaveState</a> (pointer private)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8c.html#a28">dmxCommonRestoreState</a> (pointer private)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file implements common routines used by the backend and console input devices.<hr><h2>Typedef Documentation</h2>
+<a class="anchor" name="a4" doxytag="dmxcommon.c::myPrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__myPrivate.html">_myPrivate</a> <a class="el" href="struct__myPrivate.html">myPrivate</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Each device has a private area that is visible only from inside the driver code. </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a26" doxytag="dmxcommon.c::dmxCommonCopyPrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> pointer dmxCommonCopyPrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDevice</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Returns a pointer to the private area for the device that comes just prior to <em>pDevice</em> in the current <em>dmxInput</em> device list. This is used as the private area for the current device in some situations (e.g., when a keyboard and mouse form a pair that should share the same private area). If the requested private area cannot be located, then NULL is returned. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxcommon.c::dmxCommonKbdBell" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonKbdBell </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>percent</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>volume</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>pitch</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>duration</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Sound they keyboard bell. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxcommon.c::dmxCommonKbdCtrl" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonKbdCtrl </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>KeybdCtrl *&nbsp;</td>
+ <td class="mdname" nowrap> <em>ctrl</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Update the keyboard control. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmxcommon.c::dmxCommonKbdGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonKbdGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill in the XKEYBOARD parts of the <em>info</em> structure for the specified <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxcommon.c::dmxCommonKbdGetMap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonKbdGetMap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>KeySymsPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pKeySyms</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CARD8 *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pModMap</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get the keyboard mapping. </td>
+ </tr>
+</table>
+<a class="anchor" name="a15" doxytag="dmxcommon.c::dmxCommonKbdOff" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonKbdOff </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> off. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmxcommon.c::dmxCommonKbdOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxCommonKbdOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxcommon.c::dmxCommonMouCtrl" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonMouCtrl </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PtrCtrl *&nbsp;</td>
+ <td class="mdname" nowrap> <em>ctrl</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Update the mouse control. </td>
+ </tr>
+</table>
+<a class="anchor" name="a19" doxytag="dmxcommon.c::dmxCommonMouGetMap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonMouGetMap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>map</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>nButtons</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Obtain the mouse button mapping. </td>
+ </tr>
+</table>
+<a class="anchor" name="a24" doxytag="dmxcommon.c::dmxCommonMouOff" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonMouOff </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> off. </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="dmxcommon.c::dmxCommonMouOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxCommonMouOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a18" doxytag="dmxcommon.c::dmxCommonOthGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonOthGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill the <em>info</em> structure with information needed to initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a17" doxytag="dmxcommon.c::dmxCommonOthOff" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonOthOff </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> off. </td>
+ </tr>
+</table>
+<a class="anchor" name="a16" doxytag="dmxcommon.c::dmxCommonOthOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxCommonOthOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a28" doxytag="dmxcommon.c::dmxCommonRestoreState" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonRestoreState </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>private</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine restores all the information saved by <a class="el" href="dmxcommon_8h.html#a28">dmxCommonSaveState</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a27" doxytag="dmxcommon.c::dmxCommonSaveState" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonSaveState </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>private</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine saves and resets some important state for the backend and console device drivers:<ul>
+<li>the modifier map is saved and set to 0 (so DMX controls the LEDs)</li><li>the key click, bell, led, and repeat masks are saved and set to the values that DMX claims to be using</li></ul>
+<p>
+This routine and <a class="el" href="dmxcommon_8h.html#a29">dmxCommonRestoreState</a> are used when the pointer enters and leaves the console window, or when the backend window is active or not active (for a full-screen window, this only happens at server startup and server shutdown). </td>
+ </tr>
+</table>
+<a class="anchor" name="a25" doxytag="dmxcommon.c::dmxFindPointerScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxFindPointerScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Given the global coordinates <em>x</em> and <em>y</em>, determine the screen with the lowest number on which those coordinates lie. If they are not on any screen, return -1. The number returned is an index into #dmxScreenInfo and is between -1 and <a class="el" href="dmxinit_8c.html#a1">dmxNumScreens</a> - 1, inclusive. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcommon_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcommon_8h-source.html
new file mode 100644
index 000000000..72ac5378b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcommon_8h-source.html
@@ -0,0 +1,151 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxcommon.h</h1><a href="dmxcommon_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002,2003 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00039 <span class="preprocessor">#ifndef _DMXCOMMON_H_</span>
+00040 <span class="preprocessor"></span><span class="preprocessor">#define _DMXCOMMON_H_</span>
+00041 <span class="preprocessor"></span>
+00042 <span class="preprocessor">#define DMX_COMMON_OTHER \</span>
+00043 <span class="preprocessor"> Display *display; \</span>
+00044 <span class="preprocessor"> Window window; \</span>
+00045 <span class="preprocessor"> DMXScreenInfo *be; \</span>
+00046 <span class="preprocessor"> DMXLocalInputInfoPtr dmxLocal; \</span>
+00047 <span class="preprocessor"> int initPointerX; \</span>
+00048 <span class="preprocessor"> int initPointerY; \</span>
+00049 <span class="preprocessor"> long eventMask; \</span>
+00050 <span class="preprocessor"> KeybdCtrl kctrl; \</span>
+00051 <span class="preprocessor"> PtrCtrl mctrl; \</span>
+00052 <span class="preprocessor"> int kctrlset; \</span>
+00053 <span class="preprocessor"> int mctrlset; \</span>
+00054 <span class="preprocessor"> KeybdCtrl savedKctrl; \</span>
+00055 <span class="preprocessor"> XModifierKeymap *savedModMap; \</span>
+00056 <span class="preprocessor"> int stateSaved</span>
+00057 <span class="preprocessor"></span>
+00058 <span class="preprocessor">#ifdef XKB</span>
+00059 <span class="preprocessor"></span><span class="preprocessor">#define DMX_COMMON_XKB \</span>
+00060 <span class="preprocessor"> DMX_COMMON_OTHER; \</span>
+00061 <span class="preprocessor"> XkbDescPtr xkb; \</span>
+00062 <span class="preprocessor"> XkbIndicatorRec savedIndicators</span>
+00063 <span class="preprocessor"></span><span class="preprocessor">#else</span>
+00064 <span class="preprocessor"></span><span class="preprocessor">#define DMX_COMMON_XKB DMX_COMMON_OTHER</span>
+00065 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00066 <span class="preprocessor"></span>
+00067 <span class="preprocessor">#ifdef XINPUT</span>
+00068 <span class="preprocessor"></span><span class="preprocessor">#define DMX_COMMON_PRIVATE \</span>
+00069 <span class="preprocessor"> DMX_COMMON_XKB; \</span>
+00070 <span class="preprocessor"> XDevice *xi</span>
+00071 <span class="preprocessor"></span><span class="preprocessor">#else</span>
+00072 <span class="preprocessor"></span><span class="preprocessor">#define DMX_COMMON_PRIVATE DMX_COMMON_OTHER</span>
+00073 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00074 <span class="preprocessor"></span>
+00075 <span class="preprocessor">#define GETONLYPRIVFROMPRIVATE \</span>
+00076 <span class="preprocessor"> myPrivate *priv = private</span>
+00077 <span class="preprocessor"></span>
+00078 <span class="preprocessor">#define GETPRIVFROMPRIVATE \</span>
+00079 <span class="preprocessor"> GETONLYPRIVFROMPRIVATE; \</span>
+00080 <span class="preprocessor"> DMXInputInfo *dmxInput = &amp;dmxInputs[priv-&gt;dmxLocal-&gt;inputIdx]</span>
+00081 <span class="preprocessor"></span>
+00082 <span class="preprocessor">#define GETDMXLOCALFROMPDEVICE \</span>
+00083 <span class="preprocessor"> DevicePtr pDev = &amp;pDevice-&gt;public; \</span>
+00084 <span class="preprocessor"> DMXLocalInputInfoPtr dmxLocal = pDev-&gt;devicePrivate</span>
+00085 <span class="preprocessor"></span>
+00086 <span class="preprocessor">#define GETDMXINPUTFROMPRIV \</span>
+00087 <span class="preprocessor"> DMXInputInfo *dmxInput = &amp;dmxInputs[priv-&gt;dmxLocal-&gt;inputIdx]</span>
+00088 <span class="preprocessor"></span>
+00089 <span class="preprocessor">#define GETDMXINPUTFROMPDEVICE \</span>
+00090 <span class="preprocessor"> GETDMXLOCALFROMPDEVICE; \</span>
+00091 <span class="preprocessor"> DMXInputInfo *dmxInput = &amp;dmxInputs[dmxLocal-&gt;inputIdx]</span>
+00092 <span class="preprocessor"></span>
+00093 <span class="preprocessor">#define GETDMXLOCALFROMPDEV \</span>
+00094 <span class="preprocessor"> DMXLocalInputInfoPtr dmxLocal = pDev-&gt;devicePrivate</span>
+00095 <span class="preprocessor"></span>
+00096 <span class="preprocessor">#define GETDMXINPUTFROMPDEV \</span>
+00097 <span class="preprocessor"> GETDMXLOCALFROMPDEV; \</span>
+00098 <span class="preprocessor"> DMXInputInfo *dmxInput = &amp;dmxInputs[dmxLocal-&gt;inputIdx]</span>
+00099 <span class="preprocessor"></span>
+00100 <span class="preprocessor">#define GETPRIVFROMPDEV \</span>
+00101 <span class="preprocessor"> GETDMXLOCALFROMPDEV; \</span>
+00102 <span class="preprocessor"> myPrivate *priv = dmxLocal-&gt;private</span>
+00103 <span class="preprocessor"></span>
+00104 <span class="preprocessor">#define DMX_KEYBOARD_EVENT_MASK \</span>
+00105 <span class="preprocessor"> (KeyPressMask | KeyReleaseMask | KeymapStateMask)</span>
+00106 <span class="preprocessor"></span>
+00107 <span class="preprocessor">#define DMX_POINTER_EVENT_MASK \</span>
+00108 <span class="preprocessor"> (ButtonPressMask | ButtonReleaseMask | PointerMotionMask)</span>
+00109 <span class="preprocessor"></span>
+00110 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcommon_8c.html#a13">dmxCommonKbdGetInfo</a>(DevicePtr pDev, <a class="code" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info);
+00111 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcommon_8c.html#a12">dmxCommonKbdGetMap</a>(DevicePtr pDev,
+00112 KeySymsPtr pKeySyms, CARD8 *pModMap);
+00113 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcommon_8c.html#a9">dmxCommonKbdCtrl</a>(DevicePtr pDev, KeybdCtrl *ctrl);
+00114 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcommon_8c.html#a11">dmxCommonKbdBell</a>(DevicePtr pDev, <span class="keywordtype">int</span> percent,
+00115 <span class="keywordtype">int</span> volume, <span class="keywordtype">int</span> pitch, <span class="keywordtype">int</span> duration);
+00116 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxcommon_8c.html#a14">dmxCommonKbdOn</a>(DevicePtr pDev);
+00117 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcommon_8c.html#a15">dmxCommonKbdOff</a>(DevicePtr pDev);
+00118 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcommon_8c.html#a19">dmxCommonMouGetMap</a>(DevicePtr pDev,
+00119 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *map, <span class="keywordtype">int</span> *nButtons);
+00120 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcommon_8c.html#a10">dmxCommonMouCtrl</a>(DevicePtr pDev, PtrCtrl *ctrl);
+00121 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxcommon_8c.html#a23">dmxCommonMouOn</a>(DevicePtr pDev);
+00122 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcommon_8c.html#a24">dmxCommonMouOff</a>(DevicePtr pDev);
+00123 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxcommon_8c.html#a25">dmxFindPointerScreen</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y);
+00124
+00125 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxcommon_8c.html#a16">dmxCommonOthOn</a>(DevicePtr pDev);
+00126 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcommon_8c.html#a17">dmxCommonOthOff</a>(DevicePtr pDev);
+00127 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcommon_8c.html#a18">dmxCommonOthGetInfo</a>(DevicePtr pDev, <a class="code" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info);
+00128
+00129 <span class="comment">/* helper functions */</span>
+00130 <span class="keyword">extern</span> pointer <a class="code" href="dmxcommon_8c.html#a26">dmxCommonCopyPrivate</a>(DeviceIntPtr pDevice);
+00131 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcommon_8c.html#a27">dmxCommonSaveState</a>(pointer <span class="keyword">private</span>);
+00132 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcommon_8c.html#a28">dmxCommonRestoreState</a>(pointer <span class="keyword">private</span>);
+00133 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcommon_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcommon_8h.html
new file mode 100644
index 000000000..9367b5d2c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcommon_8h.html
@@ -0,0 +1,665 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxcommon.h File Reference</h1>
+<p>
+<a href="dmxcommon_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a13">dmxCommonKbdGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a14">dmxCommonKbdGetMap</a> (DevicePtr pDev, KeySymsPtr pKeySyms, CARD8 *pModMap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a15">dmxCommonKbdCtrl</a> (DevicePtr pDev, KeybdCtrl *ctrl)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a16">dmxCommonKbdBell</a> (DevicePtr pDev, int percent, int volume, int pitch, int duration)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a17">dmxCommonKbdOn</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a18">dmxCommonKbdOff</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a19">dmxCommonMouGetMap</a> (DevicePtr pDev, unsigned char *map, int *nButtons)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a20">dmxCommonMouCtrl</a> (DevicePtr pDev, PtrCtrl *ctrl)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a21">dmxCommonMouOn</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a22">dmxCommonMouOff</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a23">dmxFindPointerScreen</a> (int x, int y)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a24">dmxCommonOthOn</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a25">dmxCommonOthOff</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a26">dmxCommonOthGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>pointer&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a27">dmxCommonCopyPrivate</a> (DeviceIntPtr pDevice)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a28">dmxCommonSaveState</a> (pointer private)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcommon_8h.html#a29">dmxCommonRestoreState</a> (pointer private)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to functions used by backend and console input devices. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxcommon_8c.html">dmxcommon.c</a> <p>
+<a class="el" href="dmxbackend_8c.html">dmxbackend.c</a> <p>
+<a class="el" href="dmxconsole_8c.html">dmxconsole.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a27" doxytag="dmxcommon.h::dmxCommonCopyPrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> pointer dmxCommonCopyPrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDevice</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Returns a pointer to the private area for the device that comes just prior to <em>pDevice</em> in the current <em>dmxInput</em> device list. This is used as the private area for the current device in some situations (e.g., when a keyboard and mouse form a pair that should share the same private area). If the requested private area cannot be located, then NULL is returned. </td>
+ </tr>
+</table>
+<a class="anchor" name="a16" doxytag="dmxcommon.h::dmxCommonKbdBell" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonKbdBell </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>percent</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>volume</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>pitch</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>duration</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Sound they keyboard bell. </td>
+ </tr>
+</table>
+<a class="anchor" name="a15" doxytag="dmxcommon.h::dmxCommonKbdCtrl" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonKbdCtrl </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>KeybdCtrl *&nbsp;</td>
+ <td class="mdname" nowrap> <em>ctrl</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Update the keyboard control. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmxcommon.h::dmxCommonKbdGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonKbdGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill in the XKEYBOARD parts of the <em>info</em> structure for the specified <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmxcommon.h::dmxCommonKbdGetMap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonKbdGetMap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>KeySymsPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pKeySyms</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CARD8 *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pModMap</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get the keyboard mapping. </td>
+ </tr>
+</table>
+<a class="anchor" name="a18" doxytag="dmxcommon.h::dmxCommonKbdOff" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonKbdOff </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> off. </td>
+ </tr>
+</table>
+<a class="anchor" name="a17" doxytag="dmxcommon.h::dmxCommonKbdOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxCommonKbdOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a20" doxytag="dmxcommon.h::dmxCommonMouCtrl" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonMouCtrl </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PtrCtrl *&nbsp;</td>
+ <td class="mdname" nowrap> <em>ctrl</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Update the mouse control. </td>
+ </tr>
+</table>
+<a class="anchor" name="a19" doxytag="dmxcommon.h::dmxCommonMouGetMap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonMouGetMap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>map</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>nButtons</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Obtain the mouse button mapping. </td>
+ </tr>
+</table>
+<a class="anchor" name="a22" doxytag="dmxcommon.h::dmxCommonMouOff" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonMouOff </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> off. </td>
+ </tr>
+</table>
+<a class="anchor" name="a21" doxytag="dmxcommon.h::dmxCommonMouOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxCommonMouOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a26" doxytag="dmxcommon.h::dmxCommonOthGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonOthGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill the <em>info</em> structure with information needed to initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a25" doxytag="dmxcommon.h::dmxCommonOthOff" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonOthOff </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> off. </td>
+ </tr>
+</table>
+<a class="anchor" name="a24" doxytag="dmxcommon.h::dmxCommonOthOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxCommonOthOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a29" doxytag="dmxcommon.h::dmxCommonRestoreState" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonRestoreState </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>private</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine restores all the information saved by <a class="el" href="dmxcommon_8h.html#a28">dmxCommonSaveState</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a28" doxytag="dmxcommon.h::dmxCommonSaveState" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCommonSaveState </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>private</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine saves and resets some important state for the backend and console device drivers:<ul>
+<li>the modifier map is saved and set to 0 (so DMX controls the LEDs)</li><li>the key click, bell, led, and repeat masks are saved and set to the values that DMX claims to be using</li></ul>
+<p>
+This routine and <a class="el" href="dmxcommon_8h.html#a29">dmxCommonRestoreState</a> are used when the pointer enters and leaves the console window, or when the backend window is active or not active (for a full-screen window, this only happens at server startup and server shutdown). </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="dmxcommon.h::dmxFindPointerScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxFindPointerScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Given the global coordinates <em>x</em> and <em>y</em>, determine the screen with the lowest number on which those coordinates lie. If they are not on any screen, return -1. The number returned is an index into #dmxScreenInfo and is between -1 and <a class="el" href="dmxinit_8c.html#a1">dmxNumScreens</a> - 1, inclusive. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcompat_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcompat_8c.html
new file mode 100644
index 000000000..fe1f991ea
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcompat_8c.html
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxcompat.c File Reference</h1><code>#include "<a class="el" href="dmxconfig_8h-source.html">dmxconfig.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcompat_8h-source.html">dmxcompat.h</a>"</code><br>
+<code>#include "parser.h"</code><br>
+<code>#include &lt;stdio.h&gt;</code><br>
+<code>#include &lt;stdlib.h&gt;</code><br>
+<code>#include &lt;string.h&gt;</code><br>
+<code>#include &lt;ctype.h&gt;</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__DMXConfigEntry.html">DMXConfigEntryPtr</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcompat_8c.html#a4">dmxVDLRead</a> (const char *filename)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides some compatibility support for reading VDL files that are used by xmovie (<a href="http://www.llnl.gov/icc/sdd/img/xmovie/xmovie.shtml">http://www.llnl.gov/icc/sdd/img/xmovie/xmovie.shtml</a>).<p>
+This file is not used by the DMX server.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a4" doxytag="dmxcompat.c::dmxVDLRead" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__DMXConfigEntry.html">DMXConfigEntryPtr</a> dmxVDLRead </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>filename</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Read from the VDL format <em>filename</em> and return a newly allocated <em>DMXConfigEntryPtr</em> </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcompat_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcompat_8h-source.html
new file mode 100644
index 000000000..5199ae022
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcompat_8h-source.html
@@ -0,0 +1,61 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxcompat.h</h1><a href="dmxcompat_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00041 <span class="preprocessor">#ifndef _DMXCOMPAT_H_</span>
+00042 <span class="preprocessor"></span><span class="preprocessor">#define _DMXCOMPAT_H_</span>
+00043 <span class="preprocessor"></span>
+00044 <span class="keyword">extern</span> <a class="code" href="struct__DMXConfigEntry.html">DMXConfigEntryPtr</a> <a class="code" href="dmxcompat_8c.html#a4">dmxVDLRead</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *filename);
+00045 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcompat_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcompat_8h.html
new file mode 100644
index 000000000..ab3412ac7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcompat_8h.html
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxcompat.h File Reference</h1>
+<p>
+<a href="dmxcompat_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__DMXConfigEntry.html">DMXConfigEntryPtr</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcompat_8h.html#a0">dmxVDLRead</a> (const char *filename)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to VDL compatibility support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxcompat_8c.html">dmxcompat.c</a></dd></dl>
+This file is not used by the DMX server.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxcompat.h::dmxVDLRead" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__DMXConfigEntry.html">DMXConfigEntryPtr</a> dmxVDLRead </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>filename</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Read from the VDL format <em>filename</em> and return a newly allocated <em>DMXConfigEntryPtr</em> </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconfig_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconfig_8c.html
new file mode 100644
index 000000000..a20ab1c26
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconfig_8c.html
@@ -0,0 +1,402 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxconfig.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxinput_8h-source.html">dmxinput.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxconfig_8h-source.html">dmxconfig.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxlog_8h-source.html">dmxlog.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcb_8h-source.html">dmxcb.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxstat_8h-source.html">dmxstat.h</a>"</code><br>
+<code>#include "parser.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structDMXConfigCmdStruct.html">DMXConfigCmdStruct</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structDMXConfigListStruct.html">DMXConfigListStruct</a></td></tr>
+
+<tr><td colspan=2><br><h2>Defines</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8c.html#a0">GEN</a>(param, glob, def)</td></tr>
+
+<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="structDMXConfigListStruct.html">DMXConfigListStruct</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8c.html#a7">DMXConfigList</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="structDMXConfigListStruct.html">DMXConfigListStruct</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8c.html#a8">DMXConfigListPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="structDMXConfigCmdStruct.html">DMXConfigCmdStruct</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8c.html#a9">DMXConfigCmd</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="structDMXConfigCmdStruct.html">DMXConfigCmdStruct</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8c.html#a10">DMXConfigCmdPtr</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8c.html#a15">dmxConfigStoreDisplay</a> (const char *display)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8c.html#a16">dmxConfigStoreInput</a> (const char *input)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8c.html#a17">dmxConfigStoreXInput</a> (const char *input)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8c.html#a18">dmxConfigStoreFile</a> (const char *file)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8c.html#a19">dmxConfigStoreConfig</a> (const char *config)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8c.html#a32">dmxConfigConfigure</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8c.html#a33">dmxConfigSetMaxScreens</a> (void)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Provides interface for reading DMX configuration files and for combining that information with command-line configuration parameters.<hr><h2>Define Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxconfig.c::GEN" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define GEN</td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">param, <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>glob, <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>def&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+<b>Value:</b><div class="fragment"><pre><span class="keywordtype">void</span> dmxConfigSet##glob(<span class="keyword">const</span> <span class="keywordtype">char</span> *param) { \
+ <span class="keywordflow">if</span> (dmx##glob) free((<span class="keywordtype">void</span> *)dmx##glob); \
+ dmx##glob = strdup(param); \
+ } \
+ <span class="keywordtype">char</span> *dmxConfigGet##glob(<span class="keywordtype">void</span>) { \
+ <span class="keywordflow">return</span> (<span class="keywordtype">char</span> *)(dmx##glob ? dmx##glob : def); \
+ }
+</pre></div>This macro is used to generate the following access methods:<ul>
+<li>dmxConfig{Set,Get}rules</li><li>dmxConfig{Set,Get}model</li><li>dmxConfig{Set,Get}layout</li><li>dmxConfig{Set,Get}variant</li><li>dmxConfig{Set,Get}options These methods are used to read and write information about the keyboard. </li></ul>
+ </td>
+ </tr>
+</table>
+<hr><h2>Typedef Documentation</h2>
+<a class="anchor" name="a9" doxytag="dmxconfig.c::DMXConfigCmd" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="structDMXConfigCmdStruct.html">DMXConfigCmdStruct</a> <a class="el" href="structDMXConfigCmdStruct.html">DMXConfigCmd</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This stucture stores the parsed configuration information. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxconfig.c::DMXConfigCmdPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="structDMXConfigCmdStruct.html">DMXConfigCmdStruct</a> * <a class="el" href="structDMXConfigCmdStruct.html">DMXConfigCmdPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This stucture stores the parsed configuration information. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxconfig.c::DMXConfigList" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="structDMXConfigListStruct.html">DMXConfigListStruct</a> <a class="el" href="structDMXConfigListStruct.html">DMXConfigList</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores lists of configuration information. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxconfig.c::DMXConfigListPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="structDMXConfigListStruct.html">DMXConfigListStruct</a> * <a class="el" href="structDMXConfigListStruct.html">DMXConfigListPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores lists of configuration information. </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a32" doxytag="dmxconfig.c::dmxConfigConfigure" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigConfigure </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set up the appropriate global variables so that the DMX server will be initialized using the configuration specified in the config file and on the command line. </td>
+ </tr>
+</table>
+<a class="anchor" name="a33" doxytag="dmxconfig.c::dmxConfigSetMaxScreens" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigSetMaxScreens </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This function determines the number of displays we WILL have and sets MAXSCREENS to that value. This is difficult since the number depends on the command line (which is easy to count) or on the config file, which has to be parsed. </td>
+ </tr>
+</table>
+<a class="anchor" name="a19" doxytag="dmxconfig.c::dmxConfigStoreConfig" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigStoreConfig </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>config</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Make a note that <em>config</em> should be used as the configuration for current instantiation of the DMX server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a15" doxytag="dmxconfig.c::dmxConfigStoreDisplay" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigStoreDisplay </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>display</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Make a note that <em>display</em> is the name of an X11 display that should be initialized as a backend (output) display. Called from <a class="el" href="dmxinit_8c.html#a40">ddxProcessArgument</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a18" doxytag="dmxconfig.c::dmxConfigStoreFile" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigStoreFile </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>file</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Make a note that <em>file</em> is the configuration file. </td>
+ </tr>
+</table>
+<a class="anchor" name="a16" doxytag="dmxconfig.c::dmxConfigStoreInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigStoreInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>input</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Make a note that <em>input</em> is the name of an X11 display that should be used for input (either a backend or a console input device). </td>
+ </tr>
+</table>
+<a class="anchor" name="a17" doxytag="dmxconfig.c::dmxConfigStoreXInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigStoreXInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>input</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Make a note that <em>input</em> is the name of an X11 display that should be used for input from XInput extension devices. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconfig_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconfig_8h-source.html
new file mode 100644
index 000000000..eeaae6481
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconfig_8h-source.html
@@ -0,0 +1,84 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxconfig.h</h1><a href="dmxconfig_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _DMXCONFIG_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _DMXCONFIG_H_</span>
+00040 <span class="preprocessor"></span><span class="preprocessor">#define DMX_DEFAULT_XKB_RULES "xfree86"</span>
+00041 <span class="preprocessor"></span><span class="preprocessor">#define DMX_DEFAULT_XKB_MODEL "pc101"</span>
+00042 <span class="preprocessor"></span><span class="preprocessor">#define DMX_DEFAULT_XKB_LAYOUT "us"</span>
+00043 <span class="preprocessor"></span><span class="preprocessor">#define DMX_DEFAULT_XKB_VARIANT NULL</span>
+00044 <span class="preprocessor"></span><span class="preprocessor">#define DMX_DEFAULT_XKB_OPTIONS NULL</span>
+00045 <span class="preprocessor"></span>
+00046 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconfig_8c.html#a15">dmxConfigStoreDisplay</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *display);
+00047 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconfig_8c.html#a16">dmxConfigStoreInput</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *input); <span class="comment">/* Core devices */</span>
+00048 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconfig_8c.html#a17">dmxConfigStoreXInput</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *input); <span class="comment">/* Non-core devices */</span>
+00049 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconfig_8c.html#a18">dmxConfigStoreFile</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *file);
+00050 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconfig_8c.html#a19">dmxConfigStoreConfig</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *config);
+00051 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconfig_8c.html#a32">dmxConfigConfigure</a>(<span class="keywordtype">void</span>);
+00052 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconfig_8c.html#a33">dmxConfigSetMaxScreens</a>(<span class="keywordtype">void</span>);
+00053
+00054 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigSetXkbRules(<span class="keyword">const</span> <span class="keywordtype">char</span> *rules);
+00055 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigSetXkbModel(<span class="keyword">const</span> <span class="keywordtype">char</span> *model);
+00056 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigSetXkbLayout(<span class="keyword">const</span> <span class="keywordtype">char</span> *layout);
+00057 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigSetXkbVariant(<span class="keyword">const</span> <span class="keywordtype">char</span> *variant);
+00058 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigSetXkbOptions(<span class="keyword">const</span> <span class="keywordtype">char</span> *options);
+00059
+00060 <span class="keyword">extern</span> <span class="keywordtype">char</span> *dmxConfigGetXkbRules(<span class="keywordtype">void</span>);
+00061 <span class="keyword">extern</span> <span class="keywordtype">char</span> *dmxConfigGetXkbModel(<span class="keywordtype">void</span>);
+00062 <span class="keyword">extern</span> <span class="keywordtype">char</span> *dmxConfigGetXkbLayout(<span class="keywordtype">void</span>);
+00063 <span class="keyword">extern</span> <span class="keywordtype">char</span> *dmxConfigGetXkbVariant(<span class="keywordtype">void</span>);
+00064 <span class="keyword">extern</span> <span class="keywordtype">char</span> *dmxConfigGetXkbOptions(<span class="keywordtype">void</span>);
+00065 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconfig_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconfig_8h.html
new file mode 100644
index 000000000..76c2eb03d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconfig_8h.html
@@ -0,0 +1,248 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxconfig.h File Reference</h1>
+<p>
+<a href="dmxconfig_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8h.html#a5">dmxConfigStoreDisplay</a> (const char *display)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8h.html#a6">dmxConfigStoreInput</a> (const char *input)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8h.html#a7">dmxConfigStoreXInput</a> (const char *input)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8h.html#a8">dmxConfigStoreFile</a> (const char *file)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8h.html#a9">dmxConfigStoreConfig</a> (const char *config)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8h.html#a10">dmxConfigConfigure</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconfig_8h.html#a11">dmxConfigSetMaxScreens</a> (void)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for DMX configuration file support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxconfig_8c.html">dmxconfig.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a10" doxytag="dmxconfig.h::dmxConfigConfigure" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigConfigure </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set up the appropriate global variables so that the DMX server will be initialized using the configuration specified in the config file and on the command line. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxconfig.h::dmxConfigSetMaxScreens" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigSetMaxScreens </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This function determines the number of displays we WILL have and sets MAXSCREENS to that value. This is difficult since the number depends on the command line (which is easy to count) or on the config file, which has to be parsed. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxconfig.h::dmxConfigStoreConfig" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigStoreConfig </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>config</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Make a note that <em>config</em> should be used as the configuration for current instantiation of the DMX server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxconfig.h::dmxConfigStoreDisplay" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigStoreDisplay </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>display</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Make a note that <em>display</em> is the name of an X11 display that should be initialized as a backend (output) display. Called from <a class="el" href="dmxinit_8c.html#a40">ddxProcessArgument</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxconfig.h::dmxConfigStoreFile" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigStoreFile </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>file</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Make a note that <em>file</em> is the configuration file. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxconfig.h::dmxConfigStoreInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigStoreInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>input</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Make a note that <em>input</em> is the name of an X11 display that should be used for input (either a backend or a console input device). </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxconfig.h::dmxConfigStoreXInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigStoreXInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>input</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Make a note that <em>input</em> is the name of an X11 display that should be used for input from XInput extension devices. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconsole_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconsole_8c.html
new file mode 100644
index 000000000..026847587
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconsole_8c.html
@@ -0,0 +1,498 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxconsole.c File Reference</h1><code>#include "<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxevents_8h-source.html">dmxevents.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxconsole_8h-source.html">dmxconsole.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcommon_8h-source.html">dmxcommon.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxscrinit_8h-source.html">dmxscrinit.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcb_8h-source.html">dmxcb.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "inputstr.h"</code><br>
+<code>#include "input.h"</code><br>
+<code>#include "mipointer.h"</code><br>
+<code>#include "windowstr.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html">_myPrivate</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>pointer&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8c.html#a25">dmxConsoleCreatePrivate</a> (DeviceIntPtr pDevice)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8c.html#a26">dmxConsoleDestroyPrivate</a> (pointer private)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8c.html#a32">dmxConsoleUpdateInfo</a> (pointer private, <a class="el" href="dmxinput_8h.html#a30">DMXUpdateType</a> type, WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8c.html#a35">dmxConsoleUpdatePosition</a> (pointer private, int x, int y)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8c.html#a36">dmxConsoleCollectEvents</a> (DevicePtr pDev, dmxMotionProcPtr motion, dmxEnqueueProcPtr enqueue, dmxCheckSpecialProcPtr checkspecial, DMXBlockType block)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8c.html#a41">dmxConsoleReInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8c.html#a42">dmxConsoleInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8c.html#a43">dmxConsoleMouGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8c.html#a44">dmxConsoleKbdGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8c.html#a45">dmxConsoleFunctions</a> (pointer private, DMXFunctionType function)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8c.html#a47">dmxConsoleCapture</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8c.html#a48">dmxConsoleUncapture</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file implements the console input devices.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a47" doxytag="dmxconsole.c::dmxConsoleCapture" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleCapture </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxInput</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine is used to warp the pointer into the console window from anywhere on the screen. It is used when backend and console input are both being taken from the same X display. </td>
+ </tr>
+</table>
+<a class="anchor" name="a36" doxytag="dmxconsole.c::dmxConsoleCollectEvents" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleCollectEvents </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>dmxMotionProcPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>motion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>dmxEnqueueProcPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>enqueue</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>dmxCheckSpecialProcPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>checkspecial</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXBlockType&nbsp;</td>
+ <td class="mdname" nowrap> <em>block</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Collect all pending events from the console's display. Plase these events on the server event queue using the <em>motion</em> and <em>enqueue</em> routines. The <em>checkspecial</em> routine is used to check for special keys that need handling. <em>block</em> tells if signals should be blocked when updating the event queue. </td>
+ </tr>
+</table>
+<a class="anchor" name="a25" doxytag="dmxconsole.c::dmxConsoleCreatePrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> pointer dmxConsoleCreatePrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDevice</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create the private area for <em>pDevice</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a26" doxytag="dmxconsole.c::dmxConsoleDestroyPrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleDestroyPrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>private</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If <em>private</em> is non-NULL, free its associated memory. </td>
+ </tr>
+</table>
+<a class="anchor" name="a45" doxytag="dmxconsole.c::dmxConsoleFunctions" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxConsoleFunctions </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>private</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXFunctionType&nbsp;</td>
+ <td class="mdname" nowrap> <em>function</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Handle special console-only keys. </td>
+ </tr>
+</table>
+<a class="anchor" name="a42" doxytag="dmxconsole.c::dmxConsoleInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialized the console device described by <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a44" doxytag="dmxconsole.c::dmxConsoleKbdGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleKbdGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill in the <em>info</em> structure for the specified <em>pDev</em>. Only used for keyboard. </td>
+ </tr>
+</table>
+<a class="anchor" name="a43" doxytag="dmxconsole.c::dmxConsoleMouGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleMouGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill in the <em>info</em> structure for the specified <em>pDev</em>. Only used for pointers. </td>
+ </tr>
+</table>
+<a class="anchor" name="a41" doxytag="dmxconsole.c::dmxConsoleReInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleReInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Re-initialized the console device described by <em>pDev</em> (after a reconfig). </td>
+ </tr>
+</table>
+<a class="anchor" name="a48" doxytag="dmxconsole.c::dmxConsoleUncapture" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleUncapture </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxInput</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Undo the capture that was done by <a class="el" href="dmxconsole_8h.html#a10">dmxConsoleCapture</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a32" doxytag="dmxconsole.c::dmxConsoleUpdateInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleUpdateInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>private</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="dmxinput_8h.html#a30">DMXUpdateType</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>type</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Whenever the window layout (size, position, stacking order) might be changed, this routine is called with the <em>pWindow</em> that changed and the <em>type</em> of change. This routine is called in a conservative fashion: the actual layout of the windows of the screen might not have had any human-visible changes. </td>
+ </tr>
+</table>
+<a class="anchor" name="a35" doxytag="dmxconsole.c::dmxConsoleUpdatePosition" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleUpdatePosition </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>private</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine gets called from #dmxCoreMotion for each motion. This allows the console's notion of the cursor postion to change when another input device actually caused the change. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconsole_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconsole_8h-source.html
new file mode 100644
index 000000000..b806b86fc
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconsole_8h-source.html
@@ -0,0 +1,79 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxconsole.h</h1><a href="dmxconsole_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _DMXCONSOLE_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _DMXCONSOLE_H_</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="keyword">extern</span> pointer <a class="code" href="dmxconsole_8c.html#a25">dmxConsoleCreatePrivate</a>(DeviceIntPtr pDevice);
+00042 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconsole_8c.html#a26">dmxConsoleDestroyPrivate</a>(pointer <span class="keyword">private</span>);
+00043 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconsole_8c.html#a42">dmxConsoleInit</a>(DevicePtr pDev);
+00044 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconsole_8c.html#a41">dmxConsoleReInit</a>(DevicePtr pDev);
+00045 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconsole_8c.html#a43">dmxConsoleMouGetInfo</a>(DevicePtr pDev, <a class="code" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info);
+00046 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconsole_8c.html#a44">dmxConsoleKbdGetInfo</a>(DevicePtr pDev, <a class="code" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info);
+00047 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconsole_8c.html#a36">dmxConsoleCollectEvents</a>(DevicePtr pDev,
+00048 dmxMotionProcPtr motion,
+00049 dmxEnqueueProcPtr enqueue,
+00050 dmxCheckSpecialProcPtr checkspecial,
+00051 DMXBlockType block);
+00052 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxconsole_8c.html#a45">dmxConsoleFunctions</a>(pointer <span class="keyword">private</span>, DMXFunctionType function);
+00053 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconsole_8c.html#a35">dmxConsoleUpdatePosition</a>(pointer <span class="keyword">private</span>, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y);
+00054 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConsoleKbdSetCtrl(pointer <span class="keyword">private</span>, KeybdCtrl *ctrl);
+00055 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconsole_8c.html#a47">dmxConsoleCapture</a>(<a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput);
+00056 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconsole_8c.html#a48">dmxConsoleUncapture</a>(<a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput);
+00057 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxconsole_8c.html#a32">dmxConsoleUpdateInfo</a>(pointer <span class="keyword">private</span>,
+00058 DMXUpdateType, WindowPtr pWindow);
+00059
+00060 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconsole_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconsole_8h.html
new file mode 100644
index 000000000..398f56a16
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconsole_8h.html
@@ -0,0 +1,488 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxconsole.h File Reference</h1>
+<p>
+<a href="dmxconsole_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>pointer&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8h.html#a0">dmxConsoleCreatePrivate</a> (DeviceIntPtr pDevice)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8h.html#a1">dmxConsoleDestroyPrivate</a> (pointer private)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8h.html#a2">dmxConsoleInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8h.html#a3">dmxConsoleReInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8h.html#a4">dmxConsoleMouGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8h.html#a5">dmxConsoleKbdGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8h.html#a6">dmxConsoleCollectEvents</a> (DevicePtr pDev, dmxMotionProcPtr motion, dmxEnqueueProcPtr enqueue, dmxCheckSpecialProcPtr checkspecial, DMXBlockType block)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8h.html#a7">dmxConsoleFunctions</a> (pointer private, DMXFunctionType function)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8h.html#a8">dmxConsoleUpdatePosition</a> (pointer private, int x, int y)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8h.html#a10">dmxConsoleCapture</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8h.html#a11">dmxConsoleUncapture</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxconsole_8h.html#a12">dmxConsoleUpdateInfo</a> (pointer private, <a class="el" href="dmxinput_8h.html#a30">DMXUpdateType</a>, WindowPtr pWindow)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for console device support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxconsole_8c.html">dmxconsole.c</a> <p>
+<a class="el" href="dmxcommon_8c.html">dmxcommon.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a10" doxytag="dmxconsole.h::dmxConsoleCapture" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleCapture </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxInput</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine is used to warp the pointer into the console window from anywhere on the screen. It is used when backend and console input are both being taken from the same X display. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxconsole.h::dmxConsoleCollectEvents" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleCollectEvents </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>dmxMotionProcPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>motion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>dmxEnqueueProcPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>enqueue</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>dmxCheckSpecialProcPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>checkspecial</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXBlockType&nbsp;</td>
+ <td class="mdname" nowrap> <em>block</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Collect all pending events from the console's display. Plase these events on the server event queue using the <em>motion</em> and <em>enqueue</em> routines. The <em>checkspecial</em> routine is used to check for special keys that need handling. <em>block</em> tells if signals should be blocked when updating the event queue. </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxconsole.h::dmxConsoleCreatePrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> pointer dmxConsoleCreatePrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDevice</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create the private area for <em>pDevice</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxconsole.h::dmxConsoleDestroyPrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleDestroyPrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>private</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If <em>private</em> is non-NULL, free its associated memory. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxconsole.h::dmxConsoleFunctions" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxConsoleFunctions </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>private</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXFunctionType&nbsp;</td>
+ <td class="mdname" nowrap> <em>function</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Handle special console-only keys. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxconsole.h::dmxConsoleInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialized the console device described by <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxconsole.h::dmxConsoleKbdGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleKbdGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill in the <em>info</em> structure for the specified <em>pDev</em>. Only used for keyboard. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxconsole.h::dmxConsoleMouGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleMouGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill in the <em>info</em> structure for the specified <em>pDev</em>. Only used for pointers. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxconsole.h::dmxConsoleReInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleReInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Re-initialized the console device described by <em>pDev</em> (after a reconfig). </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxconsole.h::dmxConsoleUncapture" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleUncapture </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxInput</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Undo the capture that was done by <a class="el" href="dmxconsole_8h.html#a10">dmxConsoleCapture</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxconsole.h::dmxConsoleUpdateInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleUpdateInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>private</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="dmxinput_8h.html#a30">DMXUpdateType</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>type</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Whenever the window layout (size, position, stacking order) might be changed, this routine is called with the <em>pWindow</em> that changed and the <em>type</em> of change. This routine is called in a conservative fashion: the actual layout of the windows of the screen might not have had any human-visible changes. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxconsole.h::dmxConsoleUpdatePosition" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConsoleUpdatePosition </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>private</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine gets called from #dmxCoreMotion for each motion. This allows the console's notion of the cursor postion to change when another input device actually caused the change. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcursor_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcursor_8c.html
new file mode 100644
index 000000000..744bc3547
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcursor_8c.html
@@ -0,0 +1,471 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxcursor.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcursor_8h-source.html">dmxcursor.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxlog_8h-source.html">dmxlog.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxprop_8h-source.html">dmxprop.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxinput_8h-source.html">dmxinput.h</a>"</code><br>
+<code>#include "mipointer.h"</code><br>
+<code>#include "windowstr.h"</code><br>
+<code>#include "globals.h"</code><br>
+<code>#include "cursorstr.h"</code><br>
+<code>#include "dixevents.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8c.html#a12">dmxCursorNoMulti</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8c.html#a21">dmxReInitOrigins</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8c.html#a22">dmxInitOrigins</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8c.html#a23">dmxOnScreen</a> (int x, int y, <a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8c.html#a28">dmxInitOverlap</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8c.html#a29">dmxBECreateCursor</a> (ScreenPtr pScreen, CursorPtr pCursor)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8c.html#a31">dmxBEFreeCursor</a> (ScreenPtr pScreen, CursorPtr pCursor)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8c.html#a38">dmxMoveCursor</a> (ScreenPtr pScreen, int x, int y)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8c.html#a40">dmxHideCursor</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8c.html#a41">dmxCheckCursor</a> (void)</td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>miPointerScreenFuncRec&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8c.html#a10">dmxPointerCursorFuncs</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>miPointerSpriteFuncRec&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8c.html#a11">dmxPointerSpriteFuncs</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file contains code than supports cursor movement, including the code that initializes and reinitializes the screen positions and computes screen overlap.<p>
+"This code is based very closely on the XFree86 equivalent (xfree86/common/xf86Cursor.c)." --David Dawes.<p>
+"This code was then extensively re-written, as explained here." --Rik Faith<p>
+The code in xf86Cursor.c used edge lists to implement the CursorOffScreen function. The edge list computation was complex (especially in the face of arbitrarily overlapping screens) compared with the speed savings in the CursorOffScreen function. The new implementation has erred on the side of correctness, readability, and maintainability over efficiency. For the common (non-edge) case, the dmxCursorOffScreen function does avoid a loop over all the screens. When the cursor has left the screen, all the screens are searched, and the first screen (in dmxScreens order) containing the cursor will be returned. If run-time profiling shows that this routing is a performance bottle-neck, then an edge list may have to be reimplemented. An edge list algorithm is O(edges) whereas the new algorithm is O(dmxNumScreens). Since edges is usually 1-3 and dmxNumScreens may be 30-60 for large backend walls, this trade off may be compelling.<p>
+The xf86InitOrigins routine uses bit masks during the computation and is therefore limited to the length of a word (e.g., 32 or 64 bits) screens. Because Xdmx is expected to be used with a large number of backend displays, this limitation was removed. The new implementation has erred on the side of readability over efficiency, using the dmxSL* routines to manage a screen list instead of a bitmap, and a function call to decrease the length of the main routine. Both algorithms are of the same order, and both are called only at server generation time, so trading clarity and long-term maintainability for efficiency does not seem justified in this case.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a29" doxytag="dmxcursor.c::dmxBECreateCursor" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBECreateCursor </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CursorPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pCursor</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create <em>pCursor</em> on the back-end associated with <em>pScreen</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a31" doxytag="dmxcursor.c::dmxBEFreeCursor" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBEFreeCursor </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CursorPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pCursor</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Free <em>pCursor</em> on the back-end associated with <em>pScreen</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a41" doxytag="dmxcursor.c::dmxCheckCursor" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCheckCursor </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine is called during reconfiguration to make sure the cursor is visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxcursor.c::dmxCursorNoMulti" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCursorNoMulti </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn off support for displaying multiple cursors on overlapped back-end displays. See #dmxCursorDoMultiCursors. </td>
+ </tr>
+</table>
+<a class="anchor" name="a40" doxytag="dmxcursor.c::dmxHideCursor" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxHideCursor </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine is used by the backend input routines to hide the cursor on a screen that is being used for relative input. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxbackend_8c.html">dmxbackend.c</a> </dd></dl>
+ </td>
+ </tr>
+</table>
+<a class="anchor" name="a22" doxytag="dmxcursor.c::dmxInitOrigins" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInitOrigins </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize screen origins (and relative position). This is called for each server generation. For dynamic reconfiguration, use <a class="el" href="dmxcursor_8c.html#a21">dmxReInitOrigins()</a> instead. </td>
+ </tr>
+</table>
+<a class="anchor" name="a28" doxytag="dmxcursor.c::dmxInitOverlap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInitOverlap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Detects overlapping dmxScreens and creates circular lists. This uses an O(dmxNumScreens^2) algorithm, but dmxNumScreens is &lt; 100 and the computation only needs to be performed for every server generation or dynamic reconfiguration . </td>
+ </tr>
+</table>
+<a class="anchor" name="a38" doxytag="dmxcursor.c::dmxMoveCursor" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxMoveCursor </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Move the cursor to coordinates (<em>x</em>, <em>y</em>)on <em>pScreen</em>. This function is usually called via <a class="el" href="dmxcursor_8h.html#a4">dmxPointerSpriteFuncs</a>, except during reconfiguration when the cursor is repositioned to force an update on newley overlapping screens and on screens that no longer overlap. </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="dmxcursor.c::dmxOnScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxOnScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Returns non-zero if the global <em>x</em>, <em>y</em> coordinate is on the screen window of the <em>dmxScreen</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a21" doxytag="dmxcursor.c::dmxReInitOrigins" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxReInitOrigins </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Recompute origin information in the <a class="el" href="dmxinit_8c.html#a2">dmxScreens</a> list. This is either called from <a class="el" href="dmxcursor_8c.html#a22">dmxInitOrigins()</a> or from #dmxReconfig(). </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a10" doxytag="dmxcursor.c::dmxPointerCursorFuncs" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> miPointerScreenFuncRec <a class="el" href="dmxcursor_8h.html#a3">dmxPointerCursorFuncs</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+<b>Initial value:</b><div class="fragment"><pre>
+{
+ dmxCursorOffScreen,
+ dmxCrossScreen,
+ dmxWarpCursor,
+ <a class="code" href="dmxeq_8c.html#a13">dmxeqEnqueue</a>,
+ <a class="code" href="dmxeq_8c.html#a14">dmxeqSwitchScreen</a>
+}
+</pre></div>Cursor functions for mi layer. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxcursor_8c.html">dmxcursor.c</a> <p>
+<a class="el" href="dmxscrinit_8c.html">dmxscrinit.c</a> </dd></dl>
+ </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxcursor.c::dmxPointerSpriteFuncs" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> miPointerSpriteFuncRec <a class="el" href="dmxcursor_8h.html#a4">dmxPointerSpriteFuncs</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+<b>Initial value:</b><div class="fragment"><pre>
+{
+ dmxRealizeCursor,
+ dmxUnrealizeCursor,
+ dmxSetCursor,
+ <a class="code" href="dmxcursor_8c.html#a38">dmxMoveCursor</a>,
+}
+</pre></div>Sprite functions for mi layer. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxcursor_8c.html">dmxcursor.c</a> <p>
+<a class="el" href="dmxscrinit_8c.html">dmxscrinit.c</a> </dd></dl>
+ </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcursor_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcursor_8h-source.html
new file mode 100644
index 000000000..c9a7c8d4d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcursor_8h-source.html
@@ -0,0 +1,86 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxcursor.h</h1><a href="dmxcursor_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * David H. Dawes &lt;dawes@xfree86.org&gt;</span>
+00032 <span class="comment"> * Kevin E. Martin &lt;kem@redhat.com&gt;</span>
+00033 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00034 <span class="comment"> *</span>
+00035 <span class="comment"> */</span>
+00036
+00040 <span class="preprocessor">#ifndef DMXCURSOR_H</span>
+00041 <span class="preprocessor"></span><span class="preprocessor">#define DMXCURSOR_H</span>
+00042 <span class="preprocessor"></span>
+00043 <span class="preprocessor">#include "mipointer.h"</span>
+00044
+<a name="l00046"></a><a class="code" href="struct__dmxCursorPriv.html">00046</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__dmxCursorPriv.html">_dmxCursorPriv</a> {
+00047 Cursor cursor;
+00048 } <a class="code" href="struct__dmxCursorPriv.html">dmxCursorPrivRec</a>, *<a class="code" href="struct__dmxCursorPriv.html">dmxCursorPrivPtr</a>;
+00049
+<a name="l00051"></a><a class="code" href="dmxcursor_8h.html#a3">00051</a> <span class="keyword">extern</span> miPointerScreenFuncRec <a class="code" href="dmxcursor_8c.html#a10">dmxPointerCursorFuncs</a>;
+<a name="l00053"></a><a class="code" href="dmxcursor_8h.html#a4">00053</a> <span class="keyword">extern</span> miPointerSpriteFuncRec <a class="code" href="dmxcursor_8c.html#a11">dmxPointerSpriteFuncs</a>;
+00054
+00055 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcursor_8c.html#a21">dmxReInitOrigins</a>(<span class="keywordtype">void</span>);
+00056 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcursor_8c.html#a22">dmxInitOrigins</a>(<span class="keywordtype">void</span>);
+00057 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcursor_8c.html#a28">dmxInitOverlap</a>(<span class="keywordtype">void</span>);
+00058 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcursor_8c.html#a12">dmxCursorNoMulti</a>(<span class="keywordtype">void</span>);
+00059 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcursor_8c.html#a38">dmxMoveCursor</a>(ScreenPtr pScreen, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y);
+00060 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcursor_8c.html#a41">dmxCheckCursor</a>(<span class="keywordtype">void</span>);
+00061 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxcursor_8c.html#a23">dmxOnScreen</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen);
+00062 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcursor_8c.html#a40">dmxHideCursor</a>(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen);
+00063
+00064 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxcursor_8c.html#a29">dmxBECreateCursor</a>(ScreenPtr pScreen, CursorPtr pCursor);
+00065 <span class="keyword">extern</span> Bool <a class="code" href="dmxcursor_8c.html#a31">dmxBEFreeCursor</a>(ScreenPtr pScreen, CursorPtr pCursor);
+00066
+00067 <span class="preprocessor">#define DMX_GET_CURSOR_PRIV(_pCursor, _pScreen) \</span>
+00068 <span class="preprocessor"> (dmxCursorPrivPtr)(_pCursor)-&gt;devPriv[(_pScreen)-&gt;myNum]</span>
+00069 <span class="preprocessor"></span>
+00070 <span class="preprocessor">#endif </span><span class="comment">/* DMXCURSOR_H */</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcursor_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcursor_8h.html
new file mode 100644
index 000000000..3bb81f00f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcursor_8h.html
@@ -0,0 +1,498 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxcursor.h File Reference</h1><code>#include "mipointer.h"</code><br>
+
+<p>
+<a href="dmxcursor_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__dmxCursorPriv.html">_dmxCursorPriv</a></td></tr>
+
+<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__dmxCursorPriv.html">_dmxCursorPriv</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8h.html#a1">dmxCursorPrivRec</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__dmxCursorPriv.html">_dmxCursorPriv</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8h.html#a2">dmxCursorPrivPtr</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8h.html#a5">dmxReInitOrigins</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8h.html#a6">dmxInitOrigins</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8h.html#a7">dmxInitOverlap</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8h.html#a8">dmxCursorNoMulti</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8h.html#a9">dmxMoveCursor</a> (ScreenPtr pScreen, int x, int y)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8h.html#a10">dmxCheckCursor</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8h.html#a11">dmxOnScreen</a> (int x, int y, <a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8h.html#a12">dmxHideCursor</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8h.html#a13">dmxBECreateCursor</a> (ScreenPtr pScreen, CursorPtr pCursor)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8h.html#a14">dmxBEFreeCursor</a> (ScreenPtr pScreen, CursorPtr pCursor)</td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>miPointerScreenFuncRec&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8h.html#a3">dmxPointerCursorFuncs</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>miPointerSpriteFuncRec&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxcursor_8h.html#a4">dmxPointerSpriteFuncs</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for cursor support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxcursor_8c.html">dmxcursor.c</a>.</dd></dl>
+<hr><h2>Typedef Documentation</h2>
+<a class="anchor" name="a2" doxytag="dmxcursor.h::dmxCursorPrivPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__dmxCursorPriv.html">_dmxCursorPriv</a> * <a class="el" href="struct__dmxCursorPriv.html">dmxCursorPrivPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Cursor private area. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxcursor.h::dmxCursorPrivRec" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__dmxCursorPriv.html">_dmxCursorPriv</a> <a class="el" href="struct__dmxCursorPriv.html">dmxCursorPrivRec</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Cursor private area. </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a13" doxytag="dmxcursor.h::dmxBECreateCursor" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBECreateCursor </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CursorPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pCursor</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create <em>pCursor</em> on the back-end associated with <em>pScreen</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmxcursor.h::dmxBEFreeCursor" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBEFreeCursor </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CursorPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pCursor</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Free <em>pCursor</em> on the back-end associated with <em>pScreen</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxcursor.h::dmxCheckCursor" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCheckCursor </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine is called during reconfiguration to make sure the cursor is visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxcursor.h::dmxCursorNoMulti" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCursorNoMulti </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn off support for displaying multiple cursors on overlapped back-end displays. See #dmxCursorDoMultiCursors. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxcursor.h::dmxHideCursor" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxHideCursor </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine is used by the backend input routines to hide the cursor on a screen that is being used for relative input. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxbackend_8c.html">dmxbackend.c</a> </dd></dl>
+ </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxcursor.h::dmxInitOrigins" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInitOrigins </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize screen origins (and relative position). This is called for each server generation. For dynamic reconfiguration, use <a class="el" href="dmxcursor_8c.html#a21">dmxReInitOrigins()</a> instead. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxcursor.h::dmxInitOverlap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInitOverlap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Detects overlapping dmxScreens and creates circular lists. This uses an O(dmxNumScreens^2) algorithm, but dmxNumScreens is &lt; 100 and the computation only needs to be performed for every server generation or dynamic reconfiguration . </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxcursor.h::dmxMoveCursor" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxMoveCursor </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Move the cursor to coordinates (<em>x</em>, <em>y</em>)on <em>pScreen</em>. This function is usually called via <a class="el" href="dmxcursor_8h.html#a4">dmxPointerSpriteFuncs</a>, except during reconfiguration when the cursor is repositioned to force an update on newley overlapping screens and on screens that no longer overlap. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxcursor.h::dmxOnScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxOnScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Returns non-zero if the global <em>x</em>, <em>y</em> coordinate is on the screen window of the <em>dmxScreen</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxcursor.h::dmxReInitOrigins" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxReInitOrigins </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Recompute origin information in the <a class="el" href="dmxinit_8c.html#a2">dmxScreens</a> list. This is either called from <a class="el" href="dmxcursor_8c.html#a22">dmxInitOrigins()</a> or from #dmxReconfig(). </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a3" doxytag="dmxcursor.h::dmxPointerCursorFuncs" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> miPointerScreenFuncRec <a class="el" href="dmxcursor_8h.html#a3">dmxPointerCursorFuncs</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Cursor functions for mi layer. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxcursor_8c.html">dmxcursor.c</a> <p>
+<a class="el" href="dmxscrinit_8c.html">dmxscrinit.c</a> </dd></dl>
+ </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxcursor.h::dmxPointerSpriteFuncs" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> miPointerSpriteFuncRec <a class="el" href="dmxcursor_8h.html#a4">dmxPointerSpriteFuncs</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Sprite functions for mi layer. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxcursor_8c.html">dmxcursor.c</a> <p>
+<a class="el" href="dmxscrinit_8c.html">dmxscrinit.c</a> </dd></dl>
+ </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdetach_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdetach_8c.html
new file mode 100644
index 000000000..e311a99bd
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdetach_8c.html
@@ -0,0 +1,70 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxdetach.c File Reference</h1><code>#include "<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxextension_8h-source.html">dmxextension.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxdetach_8c.html#a0">dmxInputDetach</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, Bool reserveId)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Provide support and helper functions for input detach and attach.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxdetach.c::dmxInputDetach" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInputDetach </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Bool&nbsp;</td>
+ <td class="mdname" nowrap> <em>reserveId</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Search for input associated with <em>dmxScreen</em>, and detach. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdpms_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdpms_8c.html
new file mode 100644
index 000000000..4ad87da6d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdpms_8c.html
@@ -0,0 +1,128 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxdpms.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxdpms_8h-source.html">dmxdpms.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxlog_8h-source.html">dmxlog.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "dpmsproc.h"</code><br>
+<code>#include "windowstr.h"</code><br>
+<code>#include "X11/extensions/dpms.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxdpms_8c.html#a3">dmxDPMSInit</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxdpms_8c.html#a4">dmxDPMSTerm</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxdpms_8c.html#a5">dmxDPMSWakeup</a> (void)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Provides DPMS support and unifies all DPMS and other screen-saver support in one file. If -dpms is given on the command line, or the Xdmx server is not compiled with DPMS support, then the DPMS extension does not work for clients, but DPMS on the backends is still disables (and restored at Xdmx server shutdown time).<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a3" doxytag="dmxdpms.c::dmxDPMSInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDPMSInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize DPMS support. We save the current settings and turn off DPMS. The settings are restored in <a class="el" href="dmxdpms_8h.html#a1">dmxDPMSTerm</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxdpms.c::dmxDPMSTerm" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDPMSTerm </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Terminate DPMS support on <em>dmxScreen</em>. We restore the settings saved in <a class="el" href="dmxdpms_8h.html#a0">dmxDPMSInit</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxdpms.c::dmxDPMSWakeup" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDPMSWakeup </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Called when activity is detected so that DPMS power-saving mode can be deactivated. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdpms_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdpms_8h-source.html
new file mode 100644
index 000000000..ff74d3ab5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdpms_8h-source.html
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxdpms.h</h1><a href="dmxdpms_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2003 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Author:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _DMXDPMS_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _DMXDPMS_H_</span>
+00040 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxdpms_8c.html#a3">dmxDPMSInit</a>(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen);
+00041 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxdpms_8c.html#a4">dmxDPMSTerm</a>(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen);
+00042 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxdpms_8c.html#a5">dmxDPMSWakeup</a>(<span class="keywordtype">void</span>); <span class="comment">/* Call when input is processed */</span>
+00043 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdpms_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdpms_8h.html
new file mode 100644
index 000000000..45b5a6495
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdpms_8h.html
@@ -0,0 +1,124 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxdpms.h File Reference</h1>
+<p>
+<a href="dmxdpms_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxdpms_8h.html#a0">dmxDPMSInit</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxdpms_8h.html#a1">dmxDPMSTerm</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxdpms_8h.html#a2">dmxDPMSWakeup</a> (void)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for DPMS extension support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxdpms_8c.html">dmxdpms.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxdpms.h::dmxDPMSInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDPMSInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize DPMS support. We save the current settings and turn off DPMS. The settings are restored in <a class="el" href="dmxdpms_8h.html#a1">dmxDPMSTerm</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxdpms.h::dmxDPMSTerm" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDPMSTerm </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Terminate DPMS support on <em>dmxScreen</em>. We restore the settings saved in <a class="el" href="dmxdpms_8h.html#a0">dmxDPMSInit</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxdpms.h::dmxDPMSWakeup" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDPMSWakeup </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Called when activity is detected so that DPMS power-saving mode can be deactivated. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdummy_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdummy_8c.html
new file mode 100644
index 000000000..d497e154a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdummy_8c.html
@@ -0,0 +1,111 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxdummy.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxdummy_8h-source.html">dmxdummy.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxdummy_8c.html#a0">dmxDummyKbdGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxdummy_8c.html#a1">dmxDummyMouGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Provide mouse and keyboard that are sufficient for starting the X server, but that don't actually provide any events. This is useful for testing.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxdummy.c::dmxDummyKbdGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDummyKbdGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return information about the dummy keyboard device specified in <em>pDev</em> into the structure pointed to by <em>info</em>. The keyboard is set up to have 1 valid key code that is <em>NoSymbol</em> </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxdummy.c::dmxDummyMouGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDummyMouGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return information about the dummy mouse device specified in <em>pDev</em> into the structure pointed to by <em>info</em>. They mouse has 3 buttons and two axes. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdummy_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdummy_8h-source.html
new file mode 100644
index 000000000..907b0f0aa
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdummy_8h-source.html
@@ -0,0 +1,63 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxdummy.h</h1><a href="dmxdummy_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _DMXDUMMY_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _DMXDUMMY_H_</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxdummy_8c.html#a1">dmxDummyMouGetInfo</a>(DevicePtr pDev, <a class="code" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info);
+00042 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxdummy_8c.html#a0">dmxDummyKbdGetInfo</a>(DevicePtr pDev, <a class="code" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info);
+00043
+00044 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdummy_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdummy_8h.html
new file mode 100644
index 000000000..ca868f943
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdummy_8h.html
@@ -0,0 +1,111 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxdummy.h File Reference</h1>
+<p>
+<a href="dmxdummy_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxdummy_8h.html#a0">dmxDummyMouGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxdummy_8h.html#a1">dmxDummyKbdGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to dummy input device support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxdummy_8c.html">dmxdummy.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a1" doxytag="dmxdummy.h::dmxDummyKbdGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDummyKbdGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return information about the dummy keyboard device specified in <em>pDev</em> into the structure pointed to by <em>info</em>. The keyboard is set up to have 1 valid key code that is <em>NoSymbol</em> </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxdummy.h::dmxDummyMouGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDummyMouGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return information about the dummy mouse device specified in <em>pDev</em> into the structure pointed to by <em>info</em>. They mouse has 3 buttons and two axes. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxeq_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxeq_8c.html
new file mode 100644
index 000000000..ccf71b829
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxeq_8c.html
@@ -0,0 +1,269 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxeq.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxeq_8h-source.html">dmxeq.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxinput_8h-source.html">dmxinput.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxlog_8h-source.html">dmxlog.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxdpms_8h-source.html">dmxdpms.h</a>"</code><br>
+<code>#include "inputstr.h"</code><br>
+<code>#include "scrnintstr.h"</code><br>
+<code>#include "XIproto.h"</code><br>
+<code>#include "extinit.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__Event.html">_Event</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__EventQueue.html">_EventQueue</a></td></tr>
+
+<tr><td colspan=2><br><h2>Defines</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxeq_8c.html#a4">QUEUE_SIZE</a>&nbsp;&nbsp;&nbsp;256</td></tr>
+
+<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__Event.html">_Event</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxeq_8c.html#a5">EventRec</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__Event.html">_Event</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxeq_8c.html#a6">EventPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__EventQueue.html">_EventQueue</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxeq_8c.html#a7">EventQueueRec</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__EventQueue.html">_EventQueue</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxeq_8c.html#a8">EventQueuePtr</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxeq_8c.html#a13">dmxeqEnqueue</a> (xEvent *e)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxeq_8c.html#a14">dmxeqSwitchScreen</a> (ScreenPtr pScreen, Bool fromDIX)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxeq_8c.html#a16">dmxeqProcessInputEvents</a> (void)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides an event queue that knows about XInput events. All of the code is based on mi/mieq.c and was modified as little as possible to provide XInput event support (the copyright and some of the comments are from The Open Group, Keith Packard, MIT X Consortium). (Another example of similar code is provided in hw/xfree86/common/xf86Xinput.c.)<hr><h2>Define Documentation</h2>
+<a class="anchor" name="a4" doxytag="dmxeq.c::QUEUE_SIZE" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define QUEUE_SIZE&nbsp;&nbsp;&nbsp;256
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+The size of our queue. (The queue provided by mi/mieq.c has a size of 256.) </td>
+ </tr>
+</table>
+<hr><h2>Typedef Documentation</h2>
+<a class="anchor" name="a6" doxytag="dmxeq.c::EventPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__Event.html">_Event</a> * <a class="el" href="struct__Event.html">EventPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Information about the event. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxeq.c::EventQueuePtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__EventQueue.html">_EventQueue</a> * <a class="el" href="struct__EventQueue.html">EventQueuePtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Event queue. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxeq.c::EventQueueRec" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__EventQueue.html">_EventQueue</a> <a class="el" href="struct__EventQueue.html">EventQueueRec</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Event queue. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxeq.c::EventRec" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__Event.html">_Event</a> <a class="el" href="struct__Event.html">EventRec</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Information about the event. </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a13" doxytag="dmxeq.c::dmxeqEnqueue" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxeqEnqueue </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">xEvent *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>e</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This function adds an event to the end of the queue. If the event is an XInput event, then the next event (the valuator event) is also stored in the queue. If the new event has a time before the time of the last event currently on the queue, then the time is updated for the new event.<p>
+Must be reentrant with ProcessInputEvents. Assumption: dmxeqEnqueue will never be interrupted. If this is called from both signal handlers and regular code, make sure the signal is suspended when called from regular code. </td>
+ </tr>
+</table>
+<a class="anchor" name="a16" doxytag="dmxeq.c::dmxeqProcessInputEvents" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxeqProcessInputEvents </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This function is called from <a class="el" href="dmxinput_8c.html#a2">ProcessInputEvents()</a> to remove events from the queue and process them. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmxeq.c::dmxeqSwitchScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxeqSwitchScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Bool&nbsp;</td>
+ <td class="mdname" nowrap> <em>fromDIX</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Make <em>pScreen</em> the new screen for enqueueing events. If <em>fromDIX</em> is TRUE, also make <em>pScreen</em> the new screen for dequeuing events. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxeq_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxeq_8h-source.html
new file mode 100644
index 000000000..dc73d8e2a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxeq_8h-source.html
@@ -0,0 +1,61 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxeq.h</h1><a href="dmxeq_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00040 <span class="preprocessor">#ifndef _DMXEQ_H_</span>
+00041 <span class="preprocessor"></span><span class="preprocessor">#define _DMXEQ_H_</span>
+00042 <span class="preprocessor"></span><span class="keyword">extern</span> Bool dmxeqInit(DevicePtr pKbd, DevicePtr pPtr);
+00043 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxeq_8c.html#a16">dmxeqProcessInputEvents</a>(<span class="keywordtype">void</span>);
+00044 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxeq_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxeq_8h.html
new file mode 100644
index 000000000..255528ce9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxeq_8h.html
@@ -0,0 +1,63 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxeq.h File Reference</h1>
+<p>
+<a href="dmxeq_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxeq_8h.html#a1">dmxeqProcessInputEvents</a> (void)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to the event queue support. Some of these functions are included in <a class="el" href="dmxinput_8h.html">dmxinput.h</a>, since they are used by top-level .c files. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxeq_8c.html">dmxeq.c</a> <p>
+<a class="el" href="dmxinput_8h.html">dmxinput.h</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a1" doxytag="dmxeq.h::dmxeqProcessInputEvents" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxeqProcessInputEvents </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This function is called from <a class="el" href="dmxinput_8c.html#a2">ProcessInputEvents()</a> to remove events from the queue and process them. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxevents_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxevents_8c.html
new file mode 100644
index 000000000..105749a00
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxevents_8c.html
@@ -0,0 +1,284 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxevents.c File Reference</h1><code>#include "<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxevents_8h-source.html">dmxevents.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcb_8h-source.html">dmxcb.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcommon_8h-source.html">dmxcommon.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcursor_8h-source.html">dmxcursor.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxmotion_8h-source.html">dmxmotion.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxeq_8h-source.html">dmxeq.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsigio_8h-source.html">dmxsigio.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxmap_8h-source.html">dmxmap.h</a>"</code><br>
+<code>#include "keysym.h"</code><br>
+<code>#include "opaque.h"</code><br>
+<code>#include "inputstr.h"</code><br>
+<code>#include "mipointer.h"</code><br>
+<code>#include "XIstubs.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxevents_8c.html#a21">dmxGetGlobalPosition</a> (int *x, int *y)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxevents_8c.html#a22">dmxInvalidateGlobalPosition</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxevents_8c.html#a23">dmxMotion</a> (DevicePtr pDev, int *v, int firstAxes, int axesCount, DMXMotionType type, DMXBlockType block)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxevents_8c.html#a27">dmxEnqueue</a> (DevicePtr pDev, int type, int detail, KeySym keySym, XEvent *e, DMXBlockType block)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxevents_8c.html#a28">dmxCheckSpecialKeys</a> (DevicePtr pDev, KeySym keySym)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Provide support and helper functions for enqueing events received by the low-level input drivers.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a28" doxytag="dmxevents.c::dmxCheckSpecialKeys" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxCheckSpecialKeys </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>KeySym&nbsp;</td>
+ <td class="mdname" nowrap> <em>keySym</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+A pointer to this routine is passed to low-level input drivers so that all special keychecking is unified to this file. This function returns 0 if no special keys have been pressed. If the user has requested termination of the DMX server, -1 is returned. If the user has requested a switch to a VT, then the (1-based) number of that VT is returned. </td>
+ </tr>
+</table>
+<a class="anchor" name="a27" doxytag="dmxevents.c::dmxEnqueue" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxEnqueue </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>type</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>detail</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>KeySym&nbsp;</td>
+ <td class="mdname" nowrap> <em>keySym</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>XEvent *&nbsp;</td>
+ <td class="mdname" nowrap> <em>e</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXBlockType&nbsp;</td>
+ <td class="mdname" nowrap> <em>block</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Enqueue a non-motion event from the <em>pDev</em> device with the specified <em>type</em> and <em>detail</em>. If the event is a KeyPress or KeyRelease event, then the <em>keySym</em> is also specified.<p>
+If <em>block</em> is set to <em>DMX_BLOCK</em>, then the SIGIO handler will be blocked around calls to <a class="el" href="dmxinput_8h.html#a24">dmxeqEnqueue()</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a21" doxytag="dmxevents.c::dmxGetGlobalPosition" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxGetGlobalPosition </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return DMX's notion of the pointer position in the global coordinate space. </td>
+ </tr>
+</table>
+<a class="anchor" name="a22" doxytag="dmxevents.c::dmxInvalidateGlobalPosition" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInvalidateGlobalPosition </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Invalidate the global position for #dmxCoreMotion. </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="dmxevents.c::dmxMotion" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxMotion </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>v</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>firstAxes</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>axesCount</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXMotionType&nbsp;</td>
+ <td class="mdname" nowrap> <em>type</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXBlockType&nbsp;</td>
+ <td class="mdname" nowrap> <em>block</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Enqueue a motion event for <em>pDev</em>. The <em>v</em> vector has length <em>axesCount</em>, and contains values for each of the axes, starting at <em>firstAxes</em>.<p>
+The <em>type</em> of the motion may be <em>DMX_RELATIVE</em>, <em>DMX_ABSOLUTE</em>, or <em>DMX_ABSOLUTE_CONFINED</em> (in the latter case, the pointer will not be allowed to move outside the global boundaires).<p>
+If <em>block</em> is set to <em>DMX_BLOCK</em>, then the SIGIO handler will be blocked around calls to <a class="el" href="dmxinput_8h.html#a24">dmxeqEnqueue()</a>. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxevents_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxevents_8h-source.html
new file mode 100644
index 000000000..ead3c2d9f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxevents_8h-source.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxevents.h</h1><a href="dmxevents_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _DMXEVENTS_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _DMXEVENTS_H_</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxevents_8c.html#a23">dmxMotion</a>(DevicePtr pDev, <span class="keywordtype">int</span> *v, <span class="keywordtype">int</span> firstAxis, <span class="keywordtype">int</span> axesCount,
+00042 DMXMotionType type, DMXBlockType block);
+00043 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxevents_8c.html#a27">dmxEnqueue</a>(DevicePtr pDev, <span class="keywordtype">int</span> type, <span class="keywordtype">int</span> detail, KeySym keySym,
+00044 XEvent *e, DMXBlockType block);
+00045 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxevents_8c.html#a28">dmxCheckSpecialKeys</a>(DevicePtr pDev, KeySym keySym);
+00046 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxevents_8c.html#a22">dmxInvalidateGlobalPosition</a>(<span class="keywordtype">void</span>);
+00047 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxevents_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxevents_8h.html
new file mode 100644
index 000000000..2aa5910d1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxevents_8h.html
@@ -0,0 +1,233 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxevents.h File Reference</h1>
+<p>
+<a href="dmxevents_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxevents_8h.html#a0">dmxMotion</a> (DevicePtr pDev, int *v, int firstAxis, int axesCount, DMXMotionType type, DMXBlockType block)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxevents_8h.html#a1">dmxEnqueue</a> (DevicePtr pDev, int type, int detail, KeySym keySym, XEvent *e, DMXBlockType block)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxevents_8h.html#a2">dmxCheckSpecialKeys</a> (DevicePtr pDev, KeySym keySym)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxevents_8h.html#a3">dmxInvalidateGlobalPosition</a> (void)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to event processing functions. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxevents_8h.html">dmxevents.h</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a2" doxytag="dmxevents.h::dmxCheckSpecialKeys" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxCheckSpecialKeys </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>KeySym&nbsp;</td>
+ <td class="mdname" nowrap> <em>keySym</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+A pointer to this routine is passed to low-level input drivers so that all special keychecking is unified to this file. This function returns 0 if no special keys have been pressed. If the user has requested termination of the DMX server, -1 is returned. If the user has requested a switch to a VT, then the (1-based) number of that VT is returned. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxevents.h::dmxEnqueue" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxEnqueue </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>type</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>detail</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>KeySym&nbsp;</td>
+ <td class="mdname" nowrap> <em>keySym</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>XEvent *&nbsp;</td>
+ <td class="mdname" nowrap> <em>e</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXBlockType&nbsp;</td>
+ <td class="mdname" nowrap> <em>block</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Enqueue a non-motion event from the <em>pDev</em> device with the specified <em>type</em> and <em>detail</em>. If the event is a KeyPress or KeyRelease event, then the <em>keySym</em> is also specified.<p>
+If <em>block</em> is set to <em>DMX_BLOCK</em>, then the SIGIO handler will be blocked around calls to <a class="el" href="dmxinput_8h.html#a24">dmxeqEnqueue()</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxevents.h::dmxInvalidateGlobalPosition" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInvalidateGlobalPosition </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Invalidate the global position for #dmxCoreMotion. </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxevents.h::dmxMotion" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxMotion </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>v</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>firstAxes</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>axesCount</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXMotionType&nbsp;</td>
+ <td class="mdname" nowrap> <em>type</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXBlockType&nbsp;</td>
+ <td class="mdname" nowrap> <em>block</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Enqueue a motion event for <em>pDev</em>. The <em>v</em> vector has length <em>axesCount</em>, and contains values for each of the axes, starting at <em>firstAxes</em>.<p>
+The <em>type</em> of the motion may be <em>DMX_RELATIVE</em>, <em>DMX_ABSOLUTE</em>, or <em>DMX_ABSOLUTE_CONFINED</em> (in the latter case, the pointer will not be allowed to move outside the global boundaires).<p>
+If <em>block</em> is set to <em>DMX_BLOCK</em>, then the SIGIO handler will be blocked around calls to <a class="el" href="dmxinput_8h.html#a24">dmxeqEnqueue()</a>. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxext_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxext_8h-source.html
new file mode 100644
index 000000000..e18f0f785
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxext_8h-source.html
@@ -0,0 +1,197 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxext.h</h1><a href="dmxext_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002-2004 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00040 <span class="preprocessor">#ifndef _DMXEXT_H_</span>
+00041 <span class="preprocessor"></span><span class="preprocessor">#define _DMXEXT_H_</span>
+00042 <span class="preprocessor"></span>
+00043 <span class="comment">/* These values must be larger than LastExtensionError.</span>
+00044 <span class="comment"> The values in dmxext.h and dmxproto.h *MUST* match. */</span>
+00045 <span class="preprocessor">#define DmxBadXinerama 1001</span>
+00046 <span class="preprocessor"></span><span class="preprocessor">#define DmxBadValue 1002</span>
+00047 <span class="preprocessor"></span><span class="preprocessor">#define DmxBadReply 1003</span>
+00048 <span class="preprocessor"></span>
+00049 <span class="preprocessor">#define DMXScreenWindowWidth (1L&lt;&lt;0)</span>
+00050 <span class="preprocessor"></span><span class="preprocessor">#define DMXScreenWindowHeight (1L&lt;&lt;1)</span>
+00051 <span class="preprocessor"></span><span class="preprocessor">#define DMXScreenWindowXoffset (1L&lt;&lt;2)</span>
+00052 <span class="preprocessor"></span><span class="preprocessor">#define DMXScreenWindowYoffset (1L&lt;&lt;3)</span>
+00053 <span class="preprocessor"></span><span class="preprocessor">#define DMXRootWindowWidth (1L&lt;&lt;4)</span>
+00054 <span class="preprocessor"></span><span class="preprocessor">#define DMXRootWindowHeight (1L&lt;&lt;5)</span>
+00055 <span class="preprocessor"></span><span class="preprocessor">#define DMXRootWindowXoffset (1L&lt;&lt;6)</span>
+00056 <span class="preprocessor"></span><span class="preprocessor">#define DMXRootWindowYoffset (1L&lt;&lt;7)</span>
+00057 <span class="preprocessor"></span><span class="preprocessor">#define DMXRootWindowXorigin (1L&lt;&lt;8)</span>
+00058 <span class="preprocessor"></span><span class="preprocessor">#define DMXRootWindowYorigin (1L&lt;&lt;9)</span>
+00059 <span class="preprocessor"></span>
+00060 <span class="preprocessor">#define DMXDesktopWidth (1L&lt;&lt;0)</span>
+00061 <span class="preprocessor"></span><span class="preprocessor">#define DMXDesktopHeight (1L&lt;&lt;1)</span>
+00062 <span class="preprocessor"></span><span class="preprocessor">#define DMXDesktopShiftX (1L&lt;&lt;2)</span>
+00063 <span class="preprocessor"></span><span class="preprocessor">#define DMXDesktopShiftY (1L&lt;&lt;3)</span>
+00064 <span class="preprocessor"></span>
+00065 <span class="preprocessor">#define DMXInputType (1L&lt;&lt;0)</span>
+00066 <span class="preprocessor"></span><span class="preprocessor">#define DMXInputPhysicalScreen (1L&lt;&lt;1)</span>
+00067 <span class="preprocessor"></span><span class="preprocessor">#define DMXInputSendsCore (1L&lt;&lt;2)</span>
+00068 <span class="preprocessor"></span>
+00069 <span class="preprocessor">#ifndef _DMX_SERVER_</span>
+00070 <span class="preprocessor"></span>
+<a name="l00073"></a><a class="code" href="structDMXScreenAttributes.html">00073</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00074 <span class="keywordtype">char</span> *displayName;
+00075 <span class="keywordtype">int</span> logicalScreen;
+00076
+00077 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> screenWindowWidth; <span class="comment">/* displayName's coordinate system */</span>
+00078 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> screenWindowHeight; <span class="comment">/* displayName's coordinate system */</span>
+00079 <span class="keywordtype">int</span> screenWindowXoffset; <span class="comment">/* displayName's coordinate system */</span>
+00080 <span class="keywordtype">int</span> screenWindowYoffset; <span class="comment">/* displayName's coordinate system */</span>
+00081
+00082 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> rootWindowWidth; <span class="comment">/* screenWindow's coordinate system */</span>
+00083 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> rootWindowHeight; <span class="comment">/* screenWindow's coordinate system */</span>
+00084 <span class="keywordtype">int</span> rootWindowXoffset; <span class="comment">/* screenWindow's coordinate system */</span>
+00085 <span class="keywordtype">int</span> rootWindowYoffset; <span class="comment">/* screenWindow's coordinate system */</span>
+00086
+00087 <span class="keywordtype">int</span> rootWindowXorigin; <span class="comment">/* global coordinate system */</span>
+00088 <span class="keywordtype">int</span> rootWindowYorigin; <span class="comment">/* global coordinate system */</span>
+00089 } <a class="code" href="structDMXScreenAttributes.html">DMXScreenAttributes</a>;
+00090
+<a name="l00093"></a><a class="code" href="structDMXWindowAttributes.html">00093</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00094 <span class="keywordtype">int</span> screen;
+00095 Window window;
+00096 XRectangle pos, vis;
+00097 } <a class="code" href="structDMXWindowAttributes.html">DMXWindowAttributes</a>;
+00098
+<a name="l00101"></a><a class="code" href="structDMXDesktopAttributes.html">00101</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00102 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> width; <span class="comment">/* global coordinate system */</span>
+00103 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> height; <span class="comment">/* global coordinate system */</span>
+00104 <span class="keywordtype">int</span> shiftX; <span class="comment">/* global coordinate system */</span>
+00105 <span class="keywordtype">int</span> shiftY; <span class="comment">/* global coordinate system */</span>
+00106 } <a class="code" href="structDMXDesktopAttributes.html">DMXDesktopAttributes</a>;
+00107
+<a name="l00110"></a><a class="code" href="dmxext_8h.html#a41">00110</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> {
+00111 DMXLocalInputType,
+00112 DMXConsoleInputType,
+00113 DMXBackendInputType
+00114 } <a class="code" href="dmxext_8h.html#a41">DMXInputEnum</a>;
+00115
+<a name="l00118"></a><a class="code" href="structDMXInputAttributes.html">00118</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00119 <a class="code" href="dmxext_8h.html#a41">DMXInputEnum</a> inputType;
+00120 <span class="keywordtype">int</span> physicalScreen;
+00121 <span class="keywordtype">int</span> physicalId;
+00122 Bool isCore;
+00123 Bool sendsCore;
+00124 <span class="keyword">const</span> <span class="keywordtype">char</span> *name;
+00125 Bool detached;
+00126 } <a class="code" href="structDMXInputAttributes.html">DMXInputAttributes</a>;
+00127
+00128 _XFUNCPROTOBEGIN
+00129
+00130 <span class="keyword">extern</span> Bool <a class="code" href="lib_2dmx_2dmx_8c.html#a10">DMXQueryExtension</a>(Display *dpy,
+00131 <span class="keywordtype">int</span> *event_basep, <span class="keywordtype">int</span> *error_basep);
+00132 <span class="keyword">extern</span> Bool <a class="code" href="lib_2dmx_2dmx_8c.html#a11">DMXQueryVersion</a>(Display *dpy, <span class="keywordtype">int</span> *major_version,
+00133 <span class="keywordtype">int</span> *minor_version, <span class="keywordtype">int</span> *patch_version);
+00134 <span class="keyword">extern</span> Bool <a class="code" href="lib_2dmx_2dmx_8c.html#a12">DMXSync</a>(Display *dpy);
+00135 <span class="keyword">extern</span> Bool <a class="code" href="lib_2dmx_2dmx_8c.html#a13">DMXForceWindowCreation</a>(Display *dpy, Window window);
+00136
+00137
+00138 <span class="keyword">extern</span> Bool <a class="code" href="lib_2dmx_2dmx_8c.html#a14">DMXGetScreenCount</a>(Display *dpy, <span class="keywordtype">int</span> *screen_count);
+00139 <span class="keyword">extern</span> Bool <a class="code" href="lib_2dmx_2dmx_8c.html#a15">DMXGetScreenAttributes</a>(Display *dpy,
+00140 <span class="keywordtype">int</span> screen,
+00141 <a class="code" href="structDMXScreenAttributes.html">DMXScreenAttributes</a> *attr);
+00142 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="lib_2dmx_2dmx_8c.html#a20">DMXChangeScreensAttributes</a>(Display *dpy,
+00143 <span class="keywordtype">int</span> screen_count,
+00144 <span class="keywordtype">int</span> *screens,
+00145 <span class="keywordtype">int</span> mask_count,
+00146 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *masks,
+00147 <a class="code" href="structDMXScreenAttributes.html">DMXScreenAttributes</a> *attr, <span class="comment">/* vector */</span>
+00148 <span class="keywordtype">int</span> *error_screen);
+00149
+00150 <span class="keyword">extern</span> Bool <a class="code" href="lib_2dmx_2dmx_8c.html#a21">DMXAddScreen</a>(Display *dpy,
+00151 <span class="keyword">const</span> <span class="keywordtype">char</span> *displayName,
+00152 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> mask,
+00153 <a class="code" href="structDMXScreenAttributes.html">DMXScreenAttributes</a> *attr,
+00154 <span class="keywordtype">int</span> *screen);
+00155 <span class="keyword">extern</span> Bool <a class="code" href="lib_2dmx_2dmx_8c.html#a22">DMXRemoveScreen</a>(Display *dpy, <span class="keywordtype">int</span> screen);
+00156
+00157 <span class="comment">/* Call DMXGetScreenWindowCount and allocate info to that size. Pass</span>
+00158 <span class="comment"> * the size in available_count. This call can generate a large amount</span>
+00159 <span class="comment"> * of wire traffic and should not be used called with available_count=0</span>
+00160 <span class="comment"> * just to determine the screen_count value -- use DMXGetScreenCount</span>
+00161 <span class="comment"> * instead. NOTE: Also see DMX protocol specification (DMXSpec.txt) for</span>
+00162 <span class="comment"> * usage of DMXSync to flush pending commands. */</span>
+00163 <span class="keyword">extern</span> Bool <a class="code" href="lib_2dmx_2dmx_8c.html#a23">DMXGetWindowAttributes</a>(Display *dpy, Window window,
+00164 <span class="keywordtype">int</span> *screen_count, <span class="keywordtype">int</span> available_count,
+00165 <a class="code" href="structDMXWindowAttributes.html">DMXWindowAttributes</a> *attr);
+00166
+00167 <span class="keyword">extern</span> Bool <a class="code" href="lib_2dmx_2dmx_8c.html#a24">DMXGetDesktopAttributes</a>(Display *dpy, <a class="code" href="structDMXDesktopAttributes.html">DMXDesktopAttributes</a> *attr);
+00168 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="lib_2dmx_2dmx_8c.html#a27">DMXChangeDesktopAttributes</a>(Display *dpy,
+00169 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> mask,
+00170 <a class="code" href="structDMXDesktopAttributes.html">DMXDesktopAttributes</a> *attr);
+00171
+00172 <span class="keyword">extern</span> Bool <a class="code" href="lib_2dmx_2dmx_8c.html#a28">DMXGetInputCount</a>(Display *dpy, <span class="keywordtype">int</span> *input_count);
+00173 <span class="keyword">extern</span> Bool <a class="code" href="lib_2dmx_2dmx_8c.html#a29">DMXGetInputAttributes</a>(Display *dpy, <span class="keywordtype">int</span> id,
+00174 <a class="code" href="structDMXInputAttributes.html">DMXInputAttributes</a> *attr);
+00175
+00176 <span class="keyword">extern</span> Bool <a class="code" href="lib_2dmx_2dmx_8c.html#a30">DMXAddInput</a>(Display *dpy,
+00177 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> mask,
+00178 <a class="code" href="structDMXInputAttributes.html">DMXInputAttributes</a> *attr,
+00179 <span class="keywordtype">int</span> *id);
+00180 <span class="keyword">extern</span> Bool <a class="code" href="lib_2dmx_2dmx_8c.html#a33">DMXRemoveInput</a>(Display *dpy, <span class="keywordtype">int</span> id);
+00181
+00182 <span class="comment">/* These are helper functions that call DMXAddInput. */</span>
+00183 <span class="keyword">extern</span> Bool <a class="code" href="lib_2dmx_2dmx_8c.html#a31">DMXAddBackendInput</a>(Display *dpy, <span class="keywordtype">int</span> screen, <span class="keywordtype">int</span> sendsCore,
+00184 <span class="keywordtype">int</span> *newId);
+00185 <span class="keyword">extern</span> Bool <a class="code" href="lib_2dmx_2dmx_8c.html#a32">DMXAddConsoleInput</a>(Display *dpy, <span class="keyword">const</span> <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> sendsCore,
+00186 <span class="keywordtype">int</span> *newId);
+00187
+00188 _XFUNCPROTOEND
+00189 <span class="preprocessor">#endif</span>
+00190 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxext_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxext_8h.html
new file mode 100644
index 000000000..eb143283f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxext_8h.html
@@ -0,0 +1,926 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxext.h File Reference</h1>
+<p>
+<a href="dmxext_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structDMXDesktopAttributes.html">DMXDesktopAttributes</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structDMXInputAttributes.html">DMXInputAttributes</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structDMXScreenAttributes.html">DMXScreenAttributes</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structDMXWindowAttributes.html">DMXWindowAttributes</a></td></tr>
+
+<tr><td colspan=2><br><h2>Enumerations</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>enum &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a41">DMXInputEnum</a> </td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>_XFUNCPROTOBEGIN Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a23">DMXQueryExtension</a> (Display *dpy, int *event_basep, int *error_basep)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a24">DMXQueryVersion</a> (Display *dpy, int *major_version, int *minor_version, int *patch_version)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a25">DMXSync</a> (Display *dpy)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a26">DMXForceWindowCreation</a> (Display *dpy, Window window)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a27">DMXGetScreenCount</a> (Display *dpy, int *screen_count)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a28">DMXGetScreenAttributes</a> (Display *dpy, int screen, <a class="el" href="structDMXScreenAttributes.html">DMXScreenAttributes</a> *attr)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a29">DMXChangeScreensAttributes</a> (Display *dpy, int screen_count, int *screens, int mask_count, unsigned int *masks, <a class="el" href="structDMXScreenAttributes.html">DMXScreenAttributes</a> *attr, int *error_screen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a30">DMXAddScreen</a> (Display *dpy, const char *displayName, unsigned int mask, <a class="el" href="structDMXScreenAttributes.html">DMXScreenAttributes</a> *attr, int *screen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a31">DMXRemoveScreen</a> (Display *dpy, int screen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a32">DMXGetWindowAttributes</a> (Display *dpy, Window window, int *screen_count, int available_count, <a class="el" href="structDMXWindowAttributes.html">DMXWindowAttributes</a> *attr)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a33">DMXGetDesktopAttributes</a> (Display *dpy, <a class="el" href="structDMXDesktopAttributes.html">DMXDesktopAttributes</a> *attr)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a34">DMXChangeDesktopAttributes</a> (Display *dpy, unsigned int mask, <a class="el" href="structDMXDesktopAttributes.html">DMXDesktopAttributes</a> *attr)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a35">DMXGetInputCount</a> (Display *dpy, int *input_count)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a36">DMXGetInputAttributes</a> (Display *dpy, int id, <a class="el" href="structDMXInputAttributes.html">DMXInputAttributes</a> *attr)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a37">DMXAddInput</a> (Display *dpy, unsigned int mask, <a class="el" href="structDMXInputAttributes.html">DMXInputAttributes</a> *attr, int *id)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a38">DMXRemoveInput</a> (Display *dpy, int id)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a39">DMXAddBackendInput</a> (Display *dpy, int screen, int sendsCore, int *newId)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxext_8h.html#a40">DMXAddConsoleInput</a> (Display *dpy, const char *name, int sendsCore, int *newId)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file describes the interface to the client-side libdmx.a library. All DMX-aware client-side applications should include this file.<hr><h2>Enumeration Type Documentation</h2>
+<a class="anchor" name="a41" doxytag="dmxext.h::DMXInputEnum" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> enum <a class="el" href="dmxext_8h.html#a41">DMXInputEnum</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Enumeration for the #inputType field in the <a class="el" href="structDMXInputAttributes.html">DMXInputAttributes</a> structure. </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a39" doxytag="dmxext.h::DMXAddBackendInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXAddBackendInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>screen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>sendsCore</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>newId</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Add backend input (a helper function that calls <a class="el" href="lib_2dmx_2dmx_8c.html#a30">DMXAddInput</a>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a40" doxytag="dmxext.h::DMXAddConsoleInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXAddConsoleInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>name</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>sendsCore</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>newId</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Add console input (a helper function that calls <a class="el" href="lib_2dmx_2dmx_8c.html#a30">DMXAddInput</a>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a37" doxytag="dmxext.h::DMXAddInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXAddInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="structDMXInputAttributes.html">DMXInputAttributes</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>id</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Add input. </td>
+ </tr>
+</table>
+<a class="anchor" name="a30" doxytag="dmxext.h::DMXAddScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXAddScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>displayName</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="structDMXScreenAttributes.html">DMXScreenAttributes</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>screen</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Add a screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a34" doxytag="dmxext.h::DMXChangeDesktopAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int DMXChangeDesktopAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="structDMXDesktopAttributes.html">DMXDesktopAttributes</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the global bounding box and origin offset.<p>
+Available in DMX Protocol Version 2.0 </td>
+ </tr>
+</table>
+<a class="anchor" name="a29" doxytag="dmxext.h::DMXChangeScreensAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int DMXChangeScreensAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>screen_count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>screens</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask_count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>masks</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="structDMXScreenAttributes.html">DMXScreenAttributes</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>attrs</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>error_screen</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change geometries and positions of the DMX screen and root windows on the back-end X server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a26" doxytag="dmxext.h::DMXForceWindowCreation" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXForceWindowCreation </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Window&nbsp;</td>
+ <td class="mdname" nowrap> <em>window</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+The creation of the specified <em>window</em> will be forced.<p>
+Available in DMX Protocol Version 1.2 Reply added in DMX Protocol Version 2.0 </td>
+ </tr>
+</table>
+<a class="anchor" name="a33" doxytag="dmxext.h::DMXGetDesktopAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXGetDesktopAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="structDMXDesktopAttributes.html">DMXDesktopAttributes</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If the DMXGetDesktopAttributes protocol request returns information correctly, the information will be placed in <em>attr</em>, and True will be returned. Otherwise, False will be returned.<p>
+Available in DMX Protocol Version 2.0 </td>
+ </tr>
+</table>
+<a class="anchor" name="a36" doxytag="dmxext.h::DMXGetInputAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXGetInputAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>id</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="structDMXInputAttributes.html">DMXInputAttributes</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>inf</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If the DMXGetInputAttributes protocol request returns information about the input device with the specified <em>id</em>, information about the input device will be placed in <em>inf</em>, and True will be returned. Otherwise, False will be returned.<p>
+Available in DMX Protocol Version 1.1 </td>
+ </tr>
+</table>
+<a class="anchor" name="a35" doxytag="dmxext.h::DMXGetInputCount" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXGetInputCount </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>input_count</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If the DMXGetInputCount protocol request returns the input count, the value will be placed in <em>input_count</em>, and True will be returned. Otherwise, False will be returned.<p>
+Available in DMX Protocol Version 1.1 </td>
+ </tr>
+</table>
+<a class="anchor" name="a28" doxytag="dmxext.h::DMXGetScreenAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXGetScreenAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>physical_screen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="structDMXScreenAttributes.html">DMXScreenAttributes</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If the DMXGetScreenAttributes protocol request returns information for the specified <em>physical_screen</em>, information about the screen will be placed in <em>attr</em>, and True will be returned. Otherwise, False will be returned.<p>
+Available in DMX Protocol Version 1.0; Modified in Version 2.0 </td>
+ </tr>
+</table>
+<a class="anchor" name="a27" doxytag="dmxext.h::DMXGetScreenCount" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXGetScreenCount </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>screen_count</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If the DMXGetScreenCount protocol request returns the screen count, the value will be placed in <em>screen_count</em>, and True will be returned. Otherwise, False will be returned.<p>
+Available in DMX Protocol Version 1.0 </td>
+ </tr>
+</table>
+<a class="anchor" name="a32" doxytag="dmxext.h::DMXGetWindowAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXGetWindowAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Window&nbsp;</td>
+ <td class="mdname" nowrap> <em>window</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>screen_count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>available_count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="structDMXWindowAttributes.html">DMXWindowAttributes</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>inf</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If the DMXGetWindowAttributes protocol request returns information about the specified <em>window</em>, the number of screens for which information is available will be returned in <em>screen_count</em> and information about the first <em>available_count</em> of those screens will be placed in <em>inf</em>. Because this call transports a great deal of information over the wire, please call <a class="el" href="lib_2dmx_2dmx_8c.html#a14">DMXGetScreenCount</a> first, and make sure <em>inf</em> is that large.<p>
+Note that if the specified <em>window</em> has not yet been mapped when <a class="el" href="lib_2dmx_2dmx_8c.html#a23">DMXGetWindowAttributes</a> is called, then a subsequent XMapWindow call might be buffered in xlib while requests directly to the back-end X servers are processed. This race condition can be solved by calling <a class="el" href="lib_2dmx_2dmx_8c.html#a12">DMXSync</a> before talking directly to the back-end X servers.<p>
+Available in DMX Protocol Version 1.0, but not working correctly until DMX Protocol Version 1.4 </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="dmxext.h::DMXQueryExtension" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> _XFUNCPROTOBEGIN Bool DMXQueryExtension </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>event_basep</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>error_basep</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If the server has the DMX extension, the event and error bases will be placed in <em>event_basep</em> and <em>error_basep</em>, and True will be returned. Otherwise, False will be returned.<p>
+Available in DMX Protocol Version 1.0 </td>
+ </tr>
+</table>
+<a class="anchor" name="a24" doxytag="dmxext.h::DMXQueryVersion" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXQueryVersion </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>majorVersion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>minorVersion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>patchVersion</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If the DMXQueryVersion protocol request returns version information from the server, <em>majorVersion</em>, <em>minorVersion</em>, and <em>patchVersion</em> are filled in with the appropriate information and True is returned. Otherwise, False will be returned.<p>
+Available in DMX Protocol Version 1.0 </td>
+ </tr>
+</table>
+<a class="anchor" name="a38" doxytag="dmxext.h::DMXRemoveInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXRemoveInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>id</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Remove an input. </td>
+ </tr>
+</table>
+<a class="anchor" name="a31" doxytag="dmxext.h::DMXRemoveScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXRemoveScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>screen</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Remove a screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a25" doxytag="dmxext.h::DMXSync" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXSync </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dpy</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Flush all pending dmxSync requests in DMX server.<p>
+Available in DMX Protocol Version 1.5 </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxextension_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxextension_8c.html
new file mode 100644
index 000000000..6bcf8f133
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxextension_8c.html
@@ -0,0 +1,433 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxextension.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxinit_8h-source.html">dmxinit.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxextension_8h-source.html">dmxextension.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxwindow_8h-source.html">dmxwindow.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcb_8h-source.html">dmxcb.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcursor_8h-source.html">dmxcursor.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxpixmap_8h-source.html">dmxpixmap.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxgc_8h-source.html">dmxgc.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxfont_8h-source.html">dmxfont.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcmap_8h-source.html">dmxcmap.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxpict_8h-source.html">dmxpict.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxinput_8h-source.html">dmxinput.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxscrinit_8h-source.html">dmxscrinit.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxinputinit_8h-source.html">input/dmxinputinit.h</a>"</code><br>
+<code>#include "windowstr.h"</code><br>
+<code>#include "inputstr.h"</code><br>
+<code>#include "<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>"</code><br>
+<code>#include "cursorstr.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8c.html#a1">dmxGetScreenAttributes</a> (int physical, DMXScreenAttributesPtr attr)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8c.html#a2">dmxGetWindowAttributes</a> (WindowPtr pWindow, DMXWindowAttributesPtr attr)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8c.html#a4">dmxGetInputCount</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8c.html#a5">dmxGetInputAttributes</a> (int deviceId, DMXInputAttributesPtr attr)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8c.html#a7">dmxAddInput</a> (DMXInputAttributesPtr attr, int *id)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8c.html#a8">dmxRemoveInput</a> (int id)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>unsigned long&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8c.html#a9">dmxGetNumScreens</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8c.html#a10">dmxForceWindowCreation</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8c.html#a11">dmxFlushPendingSyncs</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8c.html#a18">dmxAttachScreen</a> (int idx, DMXScreenAttributesPtr attr)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8c.html#a23">dmxDetachScreen</a> (int idx)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides the only interface to the X server extension support in programs/Xserver/Xext. Those programs should only include <a class="el" href="dmxext_8h.html">dmxext.h</a><hr><h2>Function Documentation</h2>
+<a class="anchor" name="a7" doxytag="dmxextension.c::dmxAddInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxAddInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DMXInputAttributesPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>id</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Add an input with the specified attributes. If the input is added, the physical id is returned in <em>deviceId</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a18" doxytag="dmxextension.c::dmxAttachScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxAttachScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>idx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXScreenAttributesPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Reattach previously detached back-end screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="dmxextension.c::dmxDetachScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxDetachScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>idx</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Detach back-end screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxextension.c::dmxFlushPendingSyncs" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxFlushPendingSyncs </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Flush pending syncs for all screens. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxextension.c::dmxForceWindowCreation" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxForceWindowCreation </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Make sure that <a class="el" href="dmxwindow_8h.html#a14">dmxCreateAndRealizeWindow</a> has been called for <em>pWindow</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxextension.c::dmxGetInputAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxGetInputAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>deviceId</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXInputAttributesPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return information about the device with id = <em>deviceId</em>. This information is primarily for the <a class="el" href="programs_2Xserver_2Xext_2dmx_8c.html#a58">ProcDMXGetInputAttributes()</a> function, which does not have access to the appropriate data structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxextension.c::dmxGetInputCount" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxGetInputCount </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the total number of devices, not just <a class="el" href="dmxinput_8h.html#a4">dmxNumInputs</a>. The number returned should be the same as that returned by XListInputDevices. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxextension.c::dmxGetNumScreens" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> unsigned long dmxGetNumScreens </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the value of <a class="el" href="dmxinit_8c.html#a1">dmxNumScreens</a> -- the total number of backend screens in use (these are logical screens and may be larger than the number of backend displays). </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxextension.c::dmxGetScreenAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxGetScreenAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>physical</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXScreenAttributesPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine provides information to the DMX protocol extension about a particular screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxextension.c::dmxGetWindowAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxGetWindowAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXWindowAttributesPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine provides information to the DMX protocol extension about a particular window. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxextension.c::dmxRemoveInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxRemoveInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>id</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Remove the input with physical id <em>id</em>. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxextension_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxextension_8h-source.html
new file mode 100644
index 000000000..4fd796af5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxextension_8h-source.html
@@ -0,0 +1,131 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxextension.h</h1><a href="dmxextension_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Author:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> * Kevin E. Martin &lt;kem@redhat.com&gt;</span>
+00033 <span class="comment"> *</span>
+00034 <span class="comment"> */</span>
+00035
+00040 <span class="preprocessor">#ifndef _DMXEXTENSION_H_</span>
+00041 <span class="preprocessor"></span><span class="preprocessor">#define _DMXEXTENSION_H_</span>
+00042 <span class="preprocessor"></span>
+<a name="l00045"></a><a class="code" href="structDMXScreenAttributesRec.html">00045</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00046 <span class="keyword">const</span> <span class="keywordtype">char</span> *displayName;
+00047 <span class="keywordtype">int</span> logicalScreen;
+00048
+00049 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> screenWindowWidth; <span class="comment">/* displayName's coordinate system */</span>
+00050 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> screenWindowHeight; <span class="comment">/* displayName's coordinate system */</span>
+00051 <span class="keywordtype">int</span> screenWindowXoffset; <span class="comment">/* displayName's coordinate system */</span>
+00052 <span class="keywordtype">int</span> screenWindowYoffset; <span class="comment">/* displayName's coordinate system */</span>
+00053
+00054 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> rootWindowWidth; <span class="comment">/* screenWindow's coordinate system */</span>
+00055 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> rootWindowHeight; <span class="comment">/* screenWindow's coordinate system */</span>
+00056 <span class="keywordtype">int</span> rootWindowXoffset; <span class="comment">/* screenWindow's coordinate system */</span>
+00057 <span class="keywordtype">int</span> rootWindowYoffset; <span class="comment">/* screenWindow's coordinate system */</span>
+00058
+00059 <span class="keywordtype">int</span> rootWindowXorigin; <span class="comment">/* global coordinate system */</span>
+00060 <span class="keywordtype">int</span> rootWindowYorigin; <span class="comment">/* global coordinate system */</span>
+00061 } <a class="code" href="structDMXScreenAttributesRec.html">DMXScreenAttributesRec</a>, *DMXScreenAttributesPtr;
+00062
+<a name="l00064"></a><a class="code" href="structDMXWindowAttributesRec.html">00064</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00065 <span class="keywordtype">int</span> screen;
+00066 Window window;
+00067 xRectangle pos;
+00068 xRectangle vis;
+00069 } <a class="code" href="structDMXWindowAttributesRec.html">DMXWindowAttributesRec</a>, *DMXWindowAttributesPtr;
+00070
+<a name="l00073"></a><a class="code" href="structDMXDesktopAttributesRec.html">00073</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00074 <span class="keywordtype">int</span> width;
+00075 <span class="keywordtype">int</span> height;
+00076 <span class="keywordtype">int</span> shiftX;
+00077 <span class="keywordtype">int</span> shiftY;
+00078 } <a class="code" href="structDMXDesktopAttributesRec.html">DMXDesktopAttributesRec</a>, *DMXDesktopAttributesPtr;
+00079
+<a name="l00081"></a><a class="code" href="structDMXInputAttributesRec.html">00081</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00082 <span class="keyword">const</span> <span class="keywordtype">char</span> *name;
+00083 <span class="keywordtype">int</span> inputType;
+00084 <span class="keywordtype">int</span> physicalScreen;
+00085 <span class="keywordtype">int</span> physicalId;
+00086 <span class="keywordtype">int</span> isCore;
+00087 <span class="keywordtype">int</span> sendsCore;
+00088 <span class="keywordtype">int</span> detached;
+00089 } <a class="code" href="structDMXInputAttributesRec.html">DMXInputAttributesRec</a>, *DMXInputAttributesPtr;
+00090
+00091
+00092 <span class="keyword">extern</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="dmxextension_8c.html#a9">dmxGetNumScreens</a>(<span class="keywordtype">void</span>);
+00093 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxextension_8c.html#a10">dmxForceWindowCreation</a>(WindowPtr pWindow);
+00094 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxextension_8c.html#a11">dmxFlushPendingSyncs</a>(<span class="keywordtype">void</span>);
+00095 <span class="keyword">extern</span> Bool <a class="code" href="dmxextension_8c.html#a1">dmxGetScreenAttributes</a>(<span class="keywordtype">int</span> physical,
+00096 DMXScreenAttributesPtr attr);
+00097 <span class="keyword">extern</span> Bool <a class="code" href="dmxextension_8c.html#a2">dmxGetWindowAttributes</a>(WindowPtr pWindow,
+00098 DMXWindowAttributesPtr attr);
+00099 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxGetDesktopAttributes(DMXDesktopAttributesPtr attr);
+00100 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxextension_8c.html#a4">dmxGetInputCount</a>(<span class="keywordtype">void</span>);
+00101 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxextension_8c.html#a5">dmxGetInputAttributes</a>(<span class="keywordtype">int</span> deviceId,
+00102 DMXInputAttributesPtr attr);
+00103 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxextension_8c.html#a7">dmxAddInput</a>(DMXInputAttributesPtr attr, <span class="keywordtype">int</span> *deviceId);
+00104 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxextension_8c.html#a8">dmxRemoveInput</a>(<span class="keywordtype">int</span> deviceId);
+00105
+00106 <span class="keyword">extern</span> <span class="keywordtype">int</span> dmxConfigureScreenWindows(<span class="keywordtype">int</span> nscreens,
+00107 CARD32 *screens,
+00108 DMXScreenAttributesPtr attribs,
+00109 <span class="keywordtype">int</span> *errorScreen);
+00110
+00111 <span class="keyword">extern</span> <span class="keywordtype">int</span> dmxConfigureDesktop(DMXDesktopAttributesPtr attribs);
+00112
+00113 <span class="comment">/* dmxUpdateScreenResources exposed for dmxCreateWindow in dmxwindow.c */</span>
+00114 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxUpdateScreenResources(ScreenPtr pScreen,
+00115 <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h);
+00116
+00117 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxextension_8c.html#a18">dmxAttachScreen</a>(<span class="keywordtype">int</span> idx, DMXScreenAttributesPtr attr);
+00118 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxextension_8c.html#a23">dmxDetachScreen</a>(<span class="keywordtype">int</span> idx);
+00119 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxextension_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxextension_8h.html
new file mode 100644
index 000000000..41cdcd3eb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxextension_8h.html
@@ -0,0 +1,426 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxextension.h File Reference</h1>
+<p>
+<a href="dmxextension_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structDMXDesktopAttributesRec.html">DMXDesktopAttributesRec</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structDMXInputAttributesRec.html">DMXInputAttributesRec</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structDMXScreenAttributesRec.html">DMXScreenAttributesRec</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structDMXWindowAttributesRec.html">DMXWindowAttributesRec</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>unsigned long&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8h.html#a4">dmxGetNumScreens</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8h.html#a5">dmxForceWindowCreation</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8h.html#a6">dmxFlushPendingSyncs</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8h.html#a7">dmxGetScreenAttributes</a> (int physical, DMXScreenAttributesPtr attr)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8h.html#a8">dmxGetWindowAttributes</a> (WindowPtr pWindow, DMXWindowAttributesPtr attr)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8h.html#a10">dmxGetInputCount</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8h.html#a11">dmxGetInputAttributes</a> (int deviceId, DMXInputAttributesPtr attr)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8h.html#a12">dmxAddInput</a> (DMXInputAttributesPtr attr, int *deviceId)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8h.html#a13">dmxRemoveInput</a> (int deviceId)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8h.html#a17">dmxAttachScreen</a> (int idx, DMXScreenAttributesPtr attr)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxextension_8h.html#a18">dmxDetachScreen</a> (int idx)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for DMX extension support. These routines are called by function in Xserver/Xext/dmx.c. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxextension_8c.html">dmxextension.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a12" doxytag="dmxextension.h::dmxAddInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxAddInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DMXInputAttributesPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>id</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Add an input with the specified attributes. If the input is added, the physical id is returned in <em>deviceId</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a17" doxytag="dmxextension.h::dmxAttachScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxAttachScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>idx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXScreenAttributesPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Reattach previously detached back-end screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a18" doxytag="dmxextension.h::dmxDetachScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxDetachScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>idx</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Detach back-end screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxextension.h::dmxFlushPendingSyncs" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxFlushPendingSyncs </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Flush pending syncs for all screens. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxextension.h::dmxForceWindowCreation" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxForceWindowCreation </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Make sure that <a class="el" href="dmxwindow_8h.html#a14">dmxCreateAndRealizeWindow</a> has been called for <em>pWindow</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxextension.h::dmxGetInputAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxGetInputAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>deviceId</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXInputAttributesPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return information about the device with id = <em>deviceId</em>. This information is primarily for the <a class="el" href="programs_2Xserver_2Xext_2dmx_8c.html#a58">ProcDMXGetInputAttributes()</a> function, which does not have access to the appropriate data structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxextension.h::dmxGetInputCount" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxGetInputCount </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the total number of devices, not just <a class="el" href="dmxinput_8h.html#a4">dmxNumInputs</a>. The number returned should be the same as that returned by XListInputDevices. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxextension.h::dmxGetNumScreens" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> unsigned long dmxGetNumScreens </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the value of <a class="el" href="dmxinit_8c.html#a1">dmxNumScreens</a> -- the total number of backend screens in use (these are logical screens and may be larger than the number of backend displays). </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxextension.h::dmxGetScreenAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxGetScreenAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>physical</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXScreenAttributesPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine provides information to the DMX protocol extension about a particular screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxextension.h::dmxGetWindowAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxGetWindowAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DMXWindowAttributesPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine provides information to the DMX protocol extension about a particular window. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmxextension.h::dmxRemoveInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxRemoveInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>id</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Remove the input with physical id <em>id</em>. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxfont_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxfont_8c.html
new file mode 100644
index 000000000..b1c6c9f87
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxfont_8c.html
@@ -0,0 +1,257 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxfont.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxfont_8h-source.html">dmxfont.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxlog_8h-source.html">dmxlog.h</a>"</code><br>
+<code>#include "fontstruct.h"</code><br>
+<code>#include "dixfont.h"</code><br>
+<code>#include "dixstruct.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxfont_8c.html#a10">dmxInitFonts</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxfont_8c.html#a11">dmxResetFonts</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxfont_8c.html#a12">dmxBELoadFont</a> (ScreenPtr pScreen, FontPtr pFont)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxfont_8c.html#a13">dmxRealizeFont</a> (ScreenPtr pScreen, FontPtr pFont)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxfont_8c.html#a14">dmxBEFreeFont</a> (ScreenPtr pScreen, FontPtr pFont)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxfont_8c.html#a15">dmxUnrealizeFont</a> (ScreenPtr pScreen, FontPtr pFont)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides support for fonts.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a14" doxytag="dmxfont.c::dmxBEFreeFont" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBEFreeFont </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>FontPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pFont</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Free <em>pFont</em> on the back-end associated with <em>pScreen</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxfont.c::dmxBELoadFont" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBELoadFont </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>FontPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pFont</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Load the font, <em>pFont</em>, on the back-end server associated with <em>pScreen</em>. When a font is loaded, the font path on back-end server is first initialized to that specified on the command line with the -fontpath options, and then the font is loaded. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxfont.c::dmxInitFonts" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInitFonts </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize font support. In addition to the screen function call pointers, DMX also hooks in at the ProcVector[] level. Here the old ProcVector function pointers are saved and the new ProcVector function pointers are initialized. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmxfont.c::dmxRealizeFont" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxRealizeFont </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>FontPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pFont</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Realize the font, <em>pFont</em>, on the back-end server associated with <em>pScreen</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxfont.c::dmxResetFonts" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxResetFonts </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Reset font support by restoring the original ProcVector function pointers. </td>
+ </tr>
+</table>
+<a class="anchor" name="a15" doxytag="dmxfont.c::dmxUnrealizeFont" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxUnrealizeFont </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>FontPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pFont</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Unrealize the font, <em>pFont</em>, on the back-end server associated with <em>pScreen</em>. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxfont_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxfont_8h-source.html
new file mode 100644
index 000000000..18412915d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxfont_8h-source.html
@@ -0,0 +1,78 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxfont.h</h1><a href="dmxfont_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Kevin E. Martin &lt;kem@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef DMXFONT_H</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define DMXFONT_H</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="preprocessor">#include "fontstruct.h"</span>
+00042
+<a name="l00044"></a><a class="code" href="struct__dmxFontPriv.html">00044</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__dmxFontPriv.html">_dmxFontPriv</a> {
+00045 <span class="keywordtype">int</span> refcnt;
+00046 XFontStruct **font;
+00047 } <a class="code" href="struct__dmxFontPriv.html">dmxFontPrivRec</a>, *<a class="code" href="struct__dmxFontPriv.html">dmxFontPrivPtr</a>;
+00048
+00049 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxfont_8c.html#a10">dmxInitFonts</a>(<span class="keywordtype">void</span>);
+00050 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxfont_8c.html#a11">dmxResetFonts</a>(<span class="keywordtype">void</span>);
+00051
+00052 <span class="keyword">extern</span> Bool <a class="code" href="dmxfont_8c.html#a13">dmxRealizeFont</a>(ScreenPtr pScreen, FontPtr pFont);
+00053 <span class="keyword">extern</span> Bool <a class="code" href="dmxfont_8c.html#a15">dmxUnrealizeFont</a>(ScreenPtr pScreen, FontPtr pFont);
+00054
+00055 <span class="keyword">extern</span> Bool <a class="code" href="dmxfont_8c.html#a12">dmxBELoadFont</a>(ScreenPtr pScreen, FontPtr pFont);
+00056 <span class="keyword">extern</span> Bool <a class="code" href="dmxfont_8c.html#a14">dmxBEFreeFont</a>(ScreenPtr pScreen, FontPtr pFont);
+00057
+<a name="l00058"></a><a class="code" href="dmxfont_8h.html#a2">00058</a> <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxfont_8h.html#a2">dmxFontPrivateIndex</a>;
+00059
+00060 <span class="preprocessor">#endif </span><span class="comment">/* DMXFONT_H */</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxfont_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxfont_8h.html
new file mode 100644
index 000000000..503e94697
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxfont_8h.html
@@ -0,0 +1,333 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxfont.h File Reference</h1><code>#include "fontstruct.h"</code><br>
+
+<p>
+<a href="dmxfont_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__dmxFontPriv.html">_dmxFontPriv</a></td></tr>
+
+<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__dmxFontPriv.html">_dmxFontPriv</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxfont_8h.html#a0">dmxFontPrivRec</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__dmxFontPriv.html">_dmxFontPriv</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxfont_8h.html#a1">dmxFontPrivPtr</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxfont_8h.html#a3">dmxInitFonts</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxfont_8h.html#a4">dmxResetFonts</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxfont_8h.html#a5">dmxRealizeFont</a> (ScreenPtr pScreen, FontPtr pFont)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxfont_8h.html#a6">dmxUnrealizeFont</a> (ScreenPtr pScreen, FontPtr pFont)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxfont_8h.html#a7">dmxBELoadFont</a> (ScreenPtr pScreen, FontPtr pFont)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxfont_8h.html#a8">dmxBEFreeFont</a> (ScreenPtr pScreen, FontPtr pFont)</td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxfont_8h.html#a2">dmxFontPrivateIndex</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for font-related functions. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxfont_8c.html">dmxfont.c</a></dd></dl>
+<hr><h2>Typedef Documentation</h2>
+<a class="anchor" name="a1" doxytag="dmxfont.h::dmxFontPrivPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__dmxFontPriv.html">_dmxFontPriv</a> * <a class="el" href="struct__dmxFontPriv.html">dmxFontPrivPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Font private area. </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxfont.h::dmxFontPrivRec" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__dmxFontPriv.html">_dmxFontPriv</a> <a class="el" href="struct__dmxFontPriv.html">dmxFontPrivRec</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Font private area. </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a8" doxytag="dmxfont.h::dmxBEFreeFont" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBEFreeFont </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>FontPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pFont</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Free <em>pFont</em> on the back-end associated with <em>pScreen</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxfont.h::dmxBELoadFont" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBELoadFont </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>FontPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pFont</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Load the font, <em>pFont</em>, on the back-end server associated with <em>pScreen</em>. When a font is loaded, the font path on back-end server is first initialized to that specified on the command line with the -fontpath options, and then the font is loaded. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxfont.h::dmxInitFonts" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInitFonts </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize font support. In addition to the screen function call pointers, DMX also hooks in at the ProcVector[] level. Here the old ProcVector function pointers are saved and the new ProcVector function pointers are initialized. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxfont.h::dmxRealizeFont" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxRealizeFont </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>FontPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pFont</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Realize the font, <em>pFont</em>, on the back-end server associated with <em>pScreen</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxfont.h::dmxResetFonts" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxResetFonts </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Reset font support by restoring the original ProcVector function pointers. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxfont.h::dmxUnrealizeFont" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxUnrealizeFont </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>FontPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pFont</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Unrealize the font, <em>pFont</em>, on the back-end server associated with <em>pScreen</em>. </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a2" doxytag="dmxfont.h::dmxFontPrivateIndex" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxscrinit_8c.html#a4">dmxFontPrivateIndex</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Private index for Fonts </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgc_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgc_8c.html
new file mode 100644
index 000000000..1102958ed
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgc_8c.html
@@ -0,0 +1,456 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxgc.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxgc_8h-source.html">dmxgc.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxgcops_8h-source.html">dmxgcops.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxpixmap_8h-source.html">dmxpixmap.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxfont_8h-source.html">dmxfont.h</a>"</code><br>
+<code>#include "gcstruct.h"</code><br>
+<code>#include "pixmapstr.h"</code><br>
+<code>#include "migc.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8c.html#a2">dmxInitGC</a> (ScreenPtr pScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8c.html#a3">dmxBECreateGC</a> (ScreenPtr pScreen, GCPtr pGC)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8c.html#a4">dmxCreateGC</a> (GCPtr pGC)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8c.html#a5">dmxValidateGC</a> (GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8c.html#a6">dmxChangeGC</a> (GCPtr pGC, unsigned long mask)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8c.html#a7">dmxCopyGC</a> (GCPtr pGCSrc, unsigned long changes, GCPtr pGCDst)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8c.html#a8">dmxBEFreeGC</a> (GCPtr pGC)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8c.html#a9">dmxDestroyGC</a> (GCPtr pGC)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8c.html#a10">dmxChangeClip</a> (GCPtr pGC, int type, pointer pvalue, int nrects)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8c.html#a11">dmxDestroyClip</a> (GCPtr pGC)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8c.html#a12">dmxCopyClip</a> (GCPtr pGCDst, GCPtr pGCSrc)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides support for GCs.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a3" doxytag="dmxgc.c::dmxBECreateGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBECreateGC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create the GC on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxgc.c::dmxBEFreeGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBEFreeGC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pGC</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Free the <em>pGC</em> on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxgc.c::dmxChangeClip" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxChangeClip </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>type</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>pvalue</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nrects</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the clip rects for a GC. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxgc.c::dmxChangeGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxChangeGC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set the values in the graphics context on the back-end server associated with <em>pGC's</em> screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxgc.c::dmxCopyClip" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCopyClip </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGCDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGCSrc</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Copy a GC's clip rects. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxgc.c::dmxCopyGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCopyGC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGCSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>changes</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGCDst</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Copy <em>pGCSrc</em> to <em>pGCDst</em> on the back-end server associated with <em>pGCSrc's</em> screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxgc.c::dmxCreateGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxCreateGC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pGC</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a graphics context on the back-end server associated /a pGC's screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxgc.c::dmxDestroyClip" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDestroyClip </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pGC</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy a GC's clip rects. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxgc.c::dmxDestroyGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDestroyGC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pGC</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy the graphics context, <em>pGC</em> and free the corresponding GC on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxgc.c::dmxInitGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxInitGC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize the GC on <em>pScreen</em>, which currently involves allocating the GC private associated with this screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxgc.c::dmxValidateGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxValidateGC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>changes</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Validate a graphics context, <em>pGC</em>, locally in the DMX server and recompute the composite clip, if necessary. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgc_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgc_8h-source.html
new file mode 100644
index 000000000..9e1df9e31
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgc_8h-source.html
@@ -0,0 +1,106 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxgc.h</h1><a href="dmxgc_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Kevin E. Martin &lt;kem@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef DMXGC_H</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define DMXGC_H</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="preprocessor">#include "gcstruct.h"</span>
+00042
+<a name="l00044"></a><a class="code" href="struct__dmxGCPriv.html">00044</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__dmxGCPriv.html">_dmxGCPriv</a> {
+00045 GCOps *ops;
+00046 GCFuncs *funcs;
+00047 XlibGC gc;
+00048 Bool msc;
+00049 } <a class="code" href="struct__dmxGCPriv.html">dmxGCPrivRec</a>, *<a class="code" href="struct__dmxGCPriv.html">dmxGCPrivPtr</a>;
+00050
+00051
+00052 <span class="keyword">extern</span> Bool <a class="code" href="dmxgc_8c.html#a2">dmxInitGC</a>(ScreenPtr pScreen);
+00053
+00054 <span class="keyword">extern</span> Bool <a class="code" href="dmxgc_8c.html#a4">dmxCreateGC</a>(GCPtr pGC);
+00055 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgc_8c.html#a5">dmxValidateGC</a>(GCPtr pGC, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> changes,
+00056 DrawablePtr pDrawable);
+00057 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgc_8c.html#a6">dmxChangeGC</a>(GCPtr pGC, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> mask);
+00058 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgc_8c.html#a7">dmxCopyGC</a>(GCPtr pGCSrc, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> changes, GCPtr pGCDst);
+00059 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgc_8c.html#a9">dmxDestroyGC</a>(GCPtr pGC);
+00060 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgc_8c.html#a10">dmxChangeClip</a>(GCPtr pGC, <span class="keywordtype">int</span> type, pointer pvalue, <span class="keywordtype">int</span> nrects);
+00061 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgc_8c.html#a11">dmxDestroyClip</a>(GCPtr pGC);
+00062 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgc_8c.html#a12">dmxCopyClip</a>(GCPtr pGCDst, GCPtr pGCSrc);
+00063
+00064 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgc_8c.html#a3">dmxBECreateGC</a>(ScreenPtr pScreen, GCPtr pGC);
+00065 <span class="keyword">extern</span> Bool <a class="code" href="dmxgc_8c.html#a8">dmxBEFreeGC</a>(GCPtr pGC);
+00066
+<a name="l00068"></a><a class="code" href="dmxgc_8h.html#a5">00068</a> <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxgc_8h.html#a5">dmxGCPrivateIndex</a>;
+00069
+<a name="l00071"></a><a class="code" href="dmxgc_8h.html#a0">00071</a> <span class="preprocessor">#define DMX_GET_GC_PRIV(_pGC) \</span>
+00072 <span class="preprocessor"> (dmxGCPrivPtr)(_pGC)-&gt;devPrivates[dmxGCPrivateIndex].ptr</span>
+00073 <span class="preprocessor"></span>
+00074 <span class="preprocessor">#define DMX_GC_FUNC_PROLOGUE(_pGC) \</span>
+00075 <span class="preprocessor">do { \</span>
+00076 <span class="preprocessor"> dmxGCPrivPtr _pGCPriv = DMX_GET_GC_PRIV(_pGC); \</span>
+00077 <span class="preprocessor"> DMX_UNWRAP(funcs, _pGCPriv, (_pGC)); \</span>
+00078 <span class="preprocessor"> if (_pGCPriv-&gt;ops) \</span>
+00079 <span class="preprocessor"> DMX_UNWRAP(ops, _pGCPriv, (_pGC)); \</span>
+00080 <span class="preprocessor">} while (0)</span>
+00081 <span class="preprocessor"></span>
+00082 <span class="preprocessor">#define DMX_GC_FUNC_EPILOGUE(_pGC) \</span>
+00083 <span class="preprocessor">do { \</span>
+00084 <span class="preprocessor"> dmxGCPrivPtr _pGCPriv = DMX_GET_GC_PRIV(_pGC); \</span>
+00085 <span class="preprocessor"> DMX_WRAP(funcs, &amp;dmxGCFuncs, _pGCPriv, (_pGC)); \</span>
+00086 <span class="preprocessor"> if (_pGCPriv-&gt;ops) \</span>
+00087 <span class="preprocessor"> DMX_WRAP(ops, &amp;dmxGCOps, _pGCPriv, (_pGC)); \</span>
+00088 <span class="preprocessor">} while (0)</span>
+00089 <span class="preprocessor"></span>
+00090 <span class="preprocessor">#endif </span><span class="comment">/* DMXGC_H */</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgc_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgc_8h.html
new file mode 100644
index 000000000..f16d40d02
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgc_8h.html
@@ -0,0 +1,561 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxgc.h File Reference</h1><code>#include "gcstruct.h"</code><br>
+
+<p>
+<a href="dmxgc_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__dmxGCPriv.html">_dmxGCPriv</a></td></tr>
+
+<tr><td colspan=2><br><h2>Defines</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8h.html#a0">DMX_GET_GC_PRIV</a>(_pGC)&nbsp;&nbsp;&nbsp;(<a class="el" href="struct__dmxGCPriv.html">dmxGCPrivPtr</a>)(_pGC)-&gt;devPrivates[<a class="el" href="dmxscrinit_8c.html#a2">dmxGCPrivateIndex</a>].ptr</td></tr>
+
+<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__dmxGCPriv.html">_dmxGCPriv</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8h.html#a3">dmxGCPrivRec</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__dmxGCPriv.html">_dmxGCPriv</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8h.html#a4">dmxGCPrivPtr</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8h.html#a6">dmxInitGC</a> (ScreenPtr pScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8h.html#a7">dmxCreateGC</a> (GCPtr pGC)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8h.html#a8">dmxValidateGC</a> (GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8h.html#a9">dmxChangeGC</a> (GCPtr pGC, unsigned long mask)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8h.html#a10">dmxCopyGC</a> (GCPtr pGCSrc, unsigned long changes, GCPtr pGCDst)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8h.html#a11">dmxDestroyGC</a> (GCPtr pGC)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8h.html#a12">dmxChangeClip</a> (GCPtr pGC, int type, pointer pvalue, int nrects)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8h.html#a13">dmxDestroyClip</a> (GCPtr pGC)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8h.html#a14">dmxCopyClip</a> (GCPtr pGCDst, GCPtr pGCSrc)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8h.html#a15">dmxBECreateGC</a> (ScreenPtr pScreen, GCPtr pGC)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8h.html#a16">dmxBEFreeGC</a> (GCPtr pGC)</td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgc_8h.html#a5">dmxGCPrivateIndex</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for GC support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxgc_8c.html">dmxgc.c</a></dd></dl>
+<hr><h2>Define Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxgc.h::DMX_GET_GC_PRIV" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_GET_GC_PRIV</td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">_pGC&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap>&nbsp;&nbsp;&nbsp;(<a class="el" href="struct__dmxGCPriv.html">dmxGCPrivPtr</a>)(_pGC)-&gt;devPrivates[<a class="el" href="dmxscrinit_8c.html#a2">dmxGCPrivateIndex</a>].ptr
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get private. </td>
+ </tr>
+</table>
+<hr><h2>Typedef Documentation</h2>
+<a class="anchor" name="a4" doxytag="dmxgc.h::dmxGCPrivPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__dmxGCPriv.html">_dmxGCPriv</a> * <a class="el" href="struct__dmxGCPriv.html">dmxGCPrivPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+GC private area. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxgc.h::dmxGCPrivRec" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__dmxGCPriv.html">_dmxGCPriv</a> <a class="el" href="struct__dmxGCPriv.html">dmxGCPrivRec</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+GC private area. </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a15" doxytag="dmxgc.h::dmxBECreateGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBECreateGC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create the GC on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a16" doxytag="dmxgc.h::dmxBEFreeGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBEFreeGC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pGC</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Free the <em>pGC</em> on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxgc.h::dmxChangeClip" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxChangeClip </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>type</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>pvalue</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nrects</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the clip rects for a GC. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxgc.h::dmxChangeGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxChangeGC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set the values in the graphics context on the back-end server associated with <em>pGC's</em> screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmxgc.h::dmxCopyClip" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCopyClip </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGCDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGCSrc</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Copy a GC's clip rects. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxgc.h::dmxCopyGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCopyGC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGCSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>changes</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGCDst</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Copy <em>pGCSrc</em> to <em>pGCDst</em> on the back-end server associated with <em>pGCSrc's</em> screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxgc.h::dmxCreateGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxCreateGC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pGC</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a graphics context on the back-end server associated /a pGC's screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmxgc.h::dmxDestroyClip" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDestroyClip </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pGC</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy a GC's clip rects. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxgc.h::dmxDestroyGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDestroyGC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pGC</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy the graphics context, <em>pGC</em> and free the corresponding GC on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxgc.h::dmxInitGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxInitGC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize the GC on <em>pScreen</em>, which currently involves allocating the GC private associated with this screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxgc.h::dmxValidateGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxValidateGC </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>changes</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Validate a graphics context, <em>pGC</em>, locally in the DMX server and recompute the composite clip, if necessary. </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a5" doxytag="dmxgc.h::dmxGCPrivateIndex" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxscrinit_8c.html#a2">dmxGCPrivateIndex</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Private index for GCs </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgcops_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgcops_8c.html
new file mode 100644
index 000000000..d24b53a2c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgcops_8c.html
@@ -0,0 +1,1476 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxgcops.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxgc_8h-source.html">dmxgc.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxgcops_8h-source.html">dmxgcops.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxwindow_8h-source.html">dmxwindow.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxpixmap_8h-source.html">dmxpixmap.h</a>"</code><br>
+<code>#include "mi.h"</code><br>
+<code>#include "gcstruct.h"</code><br>
+<code>#include "pixmapstr.h"</code><br>
+<code>#include "dixfontstr.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a2">dmxFillSpans</a> (DrawablePtr pDrawable, GCPtr pGC, int nInit, DDXPointPtr pptInit, int *pwidthInit, int fSorted)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a3">dmxSetSpans</a> (DrawablePtr pDrawable, GCPtr pGC, char *psrc, DDXPointPtr ppt, int *pwidth, int nspans, int fSorted)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a4">dmxPutImage</a> (DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, int w, int h, int leftPad, int format, char *pBits)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>RegionPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a5">dmxCopyArea</a> (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, int w, int h, int dstx, int dsty)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>RegionPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a6">dmxCopyPlane</a> (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, int width, int height, int dstx, int dsty, unsigned long bitPlane)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a7">dmxPolyPoint</a> (DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a8">dmxPolylines</a> (DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a9">dmxPolySegment</a> (DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSegs)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a10">dmxPolyRectangle</a> (DrawablePtr pDrawable, GCPtr pGC, int nrects, xRectangle *pRects)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a11">dmxPolyArc</a> (DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a12">dmxFillPolygon</a> (DrawablePtr pDrawable, GCPtr pGC, int shape, int mode, int count, DDXPointPtr pPts)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a13">dmxPolyFillRect</a> (DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle *prectInit)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a14">dmxPolyFillArc</a> (DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a15">dmxPolyText8</a> (DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, char *chars)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a16">dmxPolyText16</a> (DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, unsigned short *chars)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a17">dmxImageText8</a> (DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, char *chars)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a18">dmxImageText16</a> (DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, unsigned short *chars)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a19">dmxImageGlyphBlt</a> (DrawablePtr pDrawable, GCPtr pGC, int x, int y, unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a20">dmxPolyGlyphBlt</a> (DrawablePtr pDrawable, GCPtr pGC, int x, int y, unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a21">dmxPushPixels</a> (GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, int w, int h, int x, int y)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a22">dmxGetImage</a> (DrawablePtr pDrawable, int sx, int sy, int w, int h, unsigned int format, unsigned long planeMask, char *pdstLine)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8c.html#a23">dmxGetSpans</a> (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, int *pwidth, int nspans, char *pdstStart)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides support for GC operations.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a5" doxytag="dmxgcops.c::dmxCopyArea" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> RegionPtr dmxCopyArea </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>srcx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>srcy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>w</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>h</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>dstx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>dsty</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Copy area from <em>pSrc</em> drawable to <em>pDst</em> drawable on the back-end server associated with <em>pSrc</em> drawable's screen. If the offscreen optimization is enabled, only copy when both <em>pSrc</em> and <em>pDst</em> are at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxgcops.c::dmxCopyPlane" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> RegionPtr dmxCopyPlane </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>srcx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>srcy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>width</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>height</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>dstx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>dsty</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>bitPlane</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Copy plane number <em>bitPlane</em> from <em>pSrc</em> drawable to <em>pDst</em> drawable on the back-end server associated with <em>pSrc</em> drawable's screen. If the offscreen optimization is enabled, only copy when both <em>pSrc</em> and <em>pDst</em> are at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxgcops.c::dmxFillPolygon" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxFillPolygon </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>shape</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>mode</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DDXPointPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pPts</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render a filled polygons in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxgcops.c::dmxFillSpans" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxFillSpans </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nInit</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DDXPointPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pptInit</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pwidthInit</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>fSorted</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill spans -- this function should never be called. </td>
+ </tr>
+</table>
+<a class="anchor" name="a22" doxytag="dmxgcops.c::dmxGetImage" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxGetImage </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>sx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>sy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>w</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>h</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>planeMask</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pdstLine</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get an image from the back-end server associated with <em>pDrawable's</em> screen. If <em>pDrawable</em> is a window, it must be viewable to get an image from it. If it is not viewable, then get the image from the first ancestor of <em>pDrawable</em> that is viewable. If no viewable ancestor is found, then simply return without getting an image. </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="dmxgcops.c::dmxGetSpans" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxGetSpans </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>wMax</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DDXPointPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>ppt</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pwidth</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nspans</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pdstStart</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get Spans -- this function should never be called. </td>
+ </tr>
+</table>
+<a class="anchor" name="a19" doxytag="dmxgcops.c::dmxImageGlyphBlt" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxImageGlyphBlt </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nglyph</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CharInfoPtr *&nbsp;</td>
+ <td class="mdname" nowrap> <em>ppci</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>pglyphBase</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Image Glyph Blt -- this function should never be called. </td>
+ </tr>
+</table>
+<a class="anchor" name="a18" doxytag="dmxgcops.c::dmxImageText16" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxImageText16 </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned short *&nbsp;</td>
+ <td class="mdname" nowrap> <em>chars</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render string of 16-bit <em>chars</em> (both foreground and background) in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a17" doxytag="dmxgcops.c::dmxImageText8" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxImageText8 </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>chars</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render string of 8-bit <em>chars</em> (both foreground and background) in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxgcops.c::dmxPolyArc" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPolyArc </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>narcs</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xArc *&nbsp;</td>
+ <td class="mdname" nowrap> <em>parcs</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render list of arc outlines, <em>parcs</em> in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmxgcops.c::dmxPolyFillArc" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPolyFillArc </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>narcs</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xArc *&nbsp;</td>
+ <td class="mdname" nowrap> <em>parcs</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render list of filled arcs, <em>parcs</em> in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmxgcops.c::dmxPolyFillRect" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPolyFillRect </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nrectFill</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xRectangle *&nbsp;</td>
+ <td class="mdname" nowrap> <em>prectInit</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render list of filled rectangles, <em>prectInit</em> in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a20" doxytag="dmxgcops.c::dmxPolyGlyphBlt" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPolyGlyphBlt </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nglyph</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CharInfoPtr *&nbsp;</td>
+ <td class="mdname" nowrap> <em>ppci</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>pglyphBase</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Poly Glyph Blt -- this function should never be called. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxgcops.c::dmxPolylines" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPolylines </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>mode</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>npt</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DDXPointPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pptInit</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render list of connected lines, <em>pptInit</em> in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxgcops.c::dmxPolyPoint" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPolyPoint </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>mode</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>npt</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DDXPointPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pptInit</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render list of points, <em>pptInit</em> in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxgcops.c::dmxPolyRectangle" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPolyRectangle </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nrects</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xRectangle *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pRects</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render list of rectangle outlines, <em>pRects</em> in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxgcops.c::dmxPolySegment" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPolySegment </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nseg</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xSegment *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSegs</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render list of disjoint segments, <em>pSegs</em> in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a16" doxytag="dmxgcops.c::dmxPolyText16" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxPolyText16 </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned short *&nbsp;</td>
+ <td class="mdname" nowrap> <em>chars</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render string of 16-bit <em>chars</em> (foreground only) in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a15" doxytag="dmxgcops.c::dmxPolyText8" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxPolyText8 </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>chars</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render string of 8-bit <em>chars</em> (foreground only) in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a21" doxytag="dmxgcops.c::dmxPushPixels" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPushPixels </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PixmapPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pBitMap</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>w</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>h</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Push Pixels -- this function should never be called. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxgcops.c::dmxPutImage" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPutImage </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>depth</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>w</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>h</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>leftPad</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pBits</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Transfer <em>pBits</em> image to back-end server associated with <em>pDrawable's</em> screen. If primitive subdivision optimization is enabled, then only transfer the sections of <em>pBits</em> that are visible (i.e., not-clipped) to the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxgcops.c::dmxSetSpans" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSetSpans </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>psrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DDXPointPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>ppt</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pwidth</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nspans</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>fSorted</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set spans -- this function should never be called. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgcops_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgcops_8h-source.html
new file mode 100644
index 000000000..b232f0b1b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgcops_8h-source.html
@@ -0,0 +1,115 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxgcops.h</h1><a href="dmxgcops_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001,2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Kevin E. Martin &lt;kem@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef DMXGCOPS_H</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define DMXGCOPS_H</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a2">dmxFillSpans</a>(DrawablePtr pDrawable, GCPtr pGC,
+00042 <span class="keywordtype">int</span> nInit, DDXPointPtr pptInit, <span class="keywordtype">int</span> *pwidthInit,
+00043 <span class="keywordtype">int</span> fSorted);
+00044 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a3">dmxSetSpans</a>(DrawablePtr pDrawable, GCPtr pGC,
+00045 <span class="keywordtype">char</span> *psrc, DDXPointPtr ppt, <span class="keywordtype">int</span> *pwidth, <span class="keywordtype">int</span> nspans,
+00046 <span class="keywordtype">int</span> fSorted);
+00047 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a4">dmxPutImage</a>(DrawablePtr pDrawable, GCPtr pGC,
+00048 <span class="keywordtype">int</span> depth, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h,
+00049 <span class="keywordtype">int</span> leftPad, <span class="keywordtype">int</span> format, <span class="keywordtype">char</span> *pBits);
+00050 <span class="keyword">extern</span> RegionPtr <a class="code" href="dmxgcops_8c.html#a5">dmxCopyArea</a>(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+00051 <span class="keywordtype">int</span> srcx, <span class="keywordtype">int</span> srcy, <span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h,
+00052 <span class="keywordtype">int</span> dstx, <span class="keywordtype">int</span> dsty);
+00053 <span class="keyword">extern</span> RegionPtr <a class="code" href="dmxgcops_8c.html#a6">dmxCopyPlane</a>(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+00054 <span class="keywordtype">int</span> srcx, <span class="keywordtype">int</span> srcy, <span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height,
+00055 <span class="keywordtype">int</span> dstx, <span class="keywordtype">int</span> dsty, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> bitPlane);
+00056 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a7">dmxPolyPoint</a>(DrawablePtr pDrawable, GCPtr pGC,
+00057 <span class="keywordtype">int</span> mode, <span class="keywordtype">int</span> npt, DDXPointPtr pptInit);
+00058 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a8">dmxPolylines</a>(DrawablePtr pDrawable, GCPtr pGC,
+00059 <span class="keywordtype">int</span> mode, <span class="keywordtype">int</span> npt, DDXPointPtr pptInit);
+00060 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a9">dmxPolySegment</a>(DrawablePtr pDrawable, GCPtr pGC,
+00061 <span class="keywordtype">int</span> nseg, xSegment *pSegs);
+00062 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a10">dmxPolyRectangle</a>(DrawablePtr pDrawable, GCPtr pGC,
+00063 <span class="keywordtype">int</span> nrects, xRectangle *pRects);
+00064 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a11">dmxPolyArc</a>(DrawablePtr pDrawable, GCPtr pGC,
+00065 <span class="keywordtype">int</span> narcs, xArc *parcs);
+00066 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a12">dmxFillPolygon</a>(DrawablePtr pDrawable, GCPtr pGC,
+00067 <span class="keywordtype">int</span> shape, <span class="keywordtype">int</span> mode, <span class="keywordtype">int</span> count, DDXPointPtr pPts);
+00068 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a13">dmxPolyFillRect</a>(DrawablePtr pDrawable, GCPtr pGC,
+00069 <span class="keywordtype">int</span> nrectFill, xRectangle *prectInit);
+00070 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a14">dmxPolyFillArc</a>(DrawablePtr pDrawable, GCPtr pGC,
+00071 <span class="keywordtype">int</span> narcs, xArc *parcs);
+00072 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxgcops_8c.html#a15">dmxPolyText8</a>(DrawablePtr pDrawable, GCPtr pGC,
+00073 <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> count, <span class="keywordtype">char</span> *chars);
+00074 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxgcops_8c.html#a16">dmxPolyText16</a>(DrawablePtr pDrawable, GCPtr pGC,
+00075 <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> count, <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> *chars);
+00076 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a17">dmxImageText8</a>(DrawablePtr pDrawable, GCPtr pGC,
+00077 <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> count, <span class="keywordtype">char</span> *chars);
+00078 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a18">dmxImageText16</a>(DrawablePtr pDrawable, GCPtr pGC,
+00079 <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> count, <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> *chars);
+00080 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a19">dmxImageGlyphBlt</a>(DrawablePtr pDrawable, GCPtr pGC,
+00081 <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nglyph,
+00082 CharInfoPtr *ppci, pointer pglyphBase);
+00083 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a20">dmxPolyGlyphBlt</a>(DrawablePtr pDrawable, GCPtr pGC,
+00084 <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nglyph,
+00085 CharInfoPtr *ppci, pointer pglyphBase);
+00086 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a21">dmxPushPixels</a>(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst,
+00087 <span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y);
+00088
+00089 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a22">dmxGetImage</a>(DrawablePtr pDrawable, <span class="keywordtype">int</span> sx, <span class="keywordtype">int</span> sy, <span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h,
+00090 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> format, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> planeMask,
+00091 <span class="keywordtype">char</span> *pdstLine);
+00092 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxgcops_8c.html#a23">dmxGetSpans</a>(DrawablePtr pDrawable, <span class="keywordtype">int</span> wMax,
+00093 DDXPointPtr ppt, <span class="keywordtype">int</span> *pwidth, <span class="keywordtype">int</span> nspans,
+00094 <span class="keywordtype">char</span> *pdstStart);
+00095
+00096 <span class="preprocessor">#endif </span><span class="comment">/* DMXGCOPS_H */</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgcops_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgcops_8h.html
new file mode 100644
index 000000000..1f30f11a4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgcops_8h.html
@@ -0,0 +1,1469 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxgcops.h File Reference</h1>
+<p>
+<a href="dmxgcops_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a0">dmxFillSpans</a> (DrawablePtr pDrawable, GCPtr pGC, int nInit, DDXPointPtr pptInit, int *pwidthInit, int fSorted)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a1">dmxSetSpans</a> (DrawablePtr pDrawable, GCPtr pGC, char *psrc, DDXPointPtr ppt, int *pwidth, int nspans, int fSorted)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a2">dmxPutImage</a> (DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, int w, int h, int leftPad, int format, char *pBits)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>RegionPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a3">dmxCopyArea</a> (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, int w, int h, int dstx, int dsty)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>RegionPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a4">dmxCopyPlane</a> (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, int width, int height, int dstx, int dsty, unsigned long bitPlane)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a5">dmxPolyPoint</a> (DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a6">dmxPolylines</a> (DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, DDXPointPtr pptInit)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a7">dmxPolySegment</a> (DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSegs)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a8">dmxPolyRectangle</a> (DrawablePtr pDrawable, GCPtr pGC, int nrects, xRectangle *pRects)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a9">dmxPolyArc</a> (DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a10">dmxFillPolygon</a> (DrawablePtr pDrawable, GCPtr pGC, int shape, int mode, int count, DDXPointPtr pPts)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a11">dmxPolyFillRect</a> (DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle *prectInit)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a12">dmxPolyFillArc</a> (DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a13">dmxPolyText8</a> (DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, char *chars)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a14">dmxPolyText16</a> (DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, unsigned short *chars)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a15">dmxImageText8</a> (DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, char *chars)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a16">dmxImageText16</a> (DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, unsigned short *chars)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a17">dmxImageGlyphBlt</a> (DrawablePtr pDrawable, GCPtr pGC, int x, int y, unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a18">dmxPolyGlyphBlt</a> (DrawablePtr pDrawable, GCPtr pGC, int x, int y, unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a19">dmxPushPixels</a> (GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, int w, int h, int x, int y)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a20">dmxGetImage</a> (DrawablePtr pDrawable, int sx, int sy, int w, int h, unsigned int format, unsigned long planeMask, char *pdstLine)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxgcops_8h.html#a21">dmxGetSpans</a> (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, int *pwidth, int nspans, char *pdstStart)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for gcops support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxgcops_8c.html">dmxgcops.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a3" doxytag="dmxgcops.h::dmxCopyArea" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> RegionPtr dmxCopyArea </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>srcx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>srcy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>w</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>h</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>dstx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>dsty</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Copy area from <em>pSrc</em> drawable to <em>pDst</em> drawable on the back-end server associated with <em>pSrc</em> drawable's screen. If the offscreen optimization is enabled, only copy when both <em>pSrc</em> and <em>pDst</em> are at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxgcops.h::dmxCopyPlane" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> RegionPtr dmxCopyPlane </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>srcx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>srcy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>width</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>height</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>dstx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>dsty</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>bitPlane</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Copy plane number <em>bitPlane</em> from <em>pSrc</em> drawable to <em>pDst</em> drawable on the back-end server associated with <em>pSrc</em> drawable's screen. If the offscreen optimization is enabled, only copy when both <em>pSrc</em> and <em>pDst</em> are at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxgcops.h::dmxFillPolygon" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxFillPolygon </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>shape</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>mode</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DDXPointPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pPts</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render a filled polygons in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxgcops.h::dmxFillSpans" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxFillSpans </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nInit</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DDXPointPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pptInit</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pwidthInit</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>fSorted</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill spans -- this function should never be called. </td>
+ </tr>
+</table>
+<a class="anchor" name="a20" doxytag="dmxgcops.h::dmxGetImage" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxGetImage </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>sx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>sy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>w</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>h</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>planeMask</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pdstLine</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get an image from the back-end server associated with <em>pDrawable's</em> screen. If <em>pDrawable</em> is a window, it must be viewable to get an image from it. If it is not viewable, then get the image from the first ancestor of <em>pDrawable</em> that is viewable. If no viewable ancestor is found, then simply return without getting an image. </td>
+ </tr>
+</table>
+<a class="anchor" name="a21" doxytag="dmxgcops.h::dmxGetSpans" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxGetSpans </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>wMax</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DDXPointPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>ppt</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pwidth</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nspans</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pdstStart</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get Spans -- this function should never be called. </td>
+ </tr>
+</table>
+<a class="anchor" name="a17" doxytag="dmxgcops.h::dmxImageGlyphBlt" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxImageGlyphBlt </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nglyph</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CharInfoPtr *&nbsp;</td>
+ <td class="mdname" nowrap> <em>ppci</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>pglyphBase</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Image Glyph Blt -- this function should never be called. </td>
+ </tr>
+</table>
+<a class="anchor" name="a16" doxytag="dmxgcops.h::dmxImageText16" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxImageText16 </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned short *&nbsp;</td>
+ <td class="mdname" nowrap> <em>chars</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render string of 16-bit <em>chars</em> (both foreground and background) in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a15" doxytag="dmxgcops.h::dmxImageText8" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxImageText8 </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>chars</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render string of 8-bit <em>chars</em> (both foreground and background) in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxgcops.h::dmxPolyArc" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPolyArc </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>narcs</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xArc *&nbsp;</td>
+ <td class="mdname" nowrap> <em>parcs</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render list of arc outlines, <em>parcs</em> in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxgcops.h::dmxPolyFillArc" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPolyFillArc </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>narcs</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xArc *&nbsp;</td>
+ <td class="mdname" nowrap> <em>parcs</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render list of filled arcs, <em>parcs</em> in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxgcops.h::dmxPolyFillRect" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPolyFillRect </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nrectFill</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xRectangle *&nbsp;</td>
+ <td class="mdname" nowrap> <em>prectInit</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render list of filled rectangles, <em>prectInit</em> in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a18" doxytag="dmxgcops.h::dmxPolyGlyphBlt" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPolyGlyphBlt </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nglyph</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CharInfoPtr *&nbsp;</td>
+ <td class="mdname" nowrap> <em>ppci</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>pglyphBase</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Poly Glyph Blt -- this function should never be called. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxgcops.h::dmxPolylines" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPolylines </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>mode</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>npt</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DDXPointPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pptInit</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render list of connected lines, <em>pptInit</em> in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxgcops.h::dmxPolyPoint" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPolyPoint </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>mode</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>npt</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DDXPointPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pptInit</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render list of points, <em>pptInit</em> in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxgcops.h::dmxPolyRectangle" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPolyRectangle </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nrects</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xRectangle *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pRects</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render list of rectangle outlines, <em>pRects</em> in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxgcops.h::dmxPolySegment" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPolySegment </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nseg</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xSegment *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSegs</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render list of disjoint segments, <em>pSegs</em> in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmxgcops.h::dmxPolyText16" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxPolyText16 </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned short *&nbsp;</td>
+ <td class="mdname" nowrap> <em>chars</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render string of 16-bit <em>chars</em> (foreground only) in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmxgcops.h::dmxPolyText8" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxPolyText8 </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>chars</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Render string of 8-bit <em>chars</em> (foreground only) in <em>pDrawable</em> on the back-end server associated with <em>pDrawable's</em> screen. If the offscreen optimization is enabled, only draw when <em>pDrawable</em> is at least partially visible. </td>
+ </tr>
+</table>
+<a class="anchor" name="a19" doxytag="dmxgcops.h::dmxPushPixels" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPushPixels </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PixmapPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pBitMap</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>w</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>h</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Push Pixels -- this function should never be called. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxgcops.h::dmxPutImage" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPutImage </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>depth</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>w</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>h</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>leftPad</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pBits</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Transfer <em>pBits</em> image to back-end server associated with <em>pDrawable's</em> screen. If primitive subdivision optimization is enabled, then only transfer the sections of <em>pBits</em> that are visible (i.e., not-clipped) to the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxgcops.h::dmxSetSpans" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSetSpans </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DrawablePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDrawable</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GCPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pGC</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>psrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DDXPointPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>ppt</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pwidth</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nspans</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>fSorted</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set spans -- this function should never be called. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinit_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinit_8c.html
new file mode 100644
index 000000000..22928e654
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinit_8c.html
@@ -0,0 +1,709 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxinit.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxinit_8h-source.html">dmxinit.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxlog_8h-source.html">dmxlog.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxinput_8h-source.html">dmxinput.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxscrinit_8h-source.html">dmxscrinit.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcursor_8h-source.html">dmxcursor.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxfont_8h-source.html">dmxfont.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxconfig_8h-source.html">config/dmxconfig.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcb_8h-source.html">dmxcb.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxprop_8h-source.html">dmxprop.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxstat_8h-source.html">dmxstat.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxpict_8h-source.html">dmxpict.h</a>"</code><br>
+<code>#include "Xos.h"</code><br>
+<code>#include "dixstruct.h"</code><br>
+<code>#include "panoramiXsrv.h"</code><br>
+<code>#include &lt;signal.h&gt;</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a34">InitOutput</a> (ScreenInfo *pScreenInfo, int argc, char *argv[])</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a36">AbortDDX</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a37">ddxGiveUp</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a38">OsVendorInit</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a39">OsVendorFatalError</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a40">ddxProcessArgument</a> (int argc, char *argv[], int i)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a41">ddxUseMsg</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>CARD32&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a42">GetTimeInMillis</a> (void)</td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a1">dmxNumScreens</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a2">dmxScreens</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a3">dmxNumInputs</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a4">dmxInputs</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a5">dmxShadowFB</a> = FALSE</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>XErrorEvent&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a6">dmxLastErrorEvent</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a7">dmxErrorOccurred</a> = FALSE</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a8">dmxFontPath</a> = NULL</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a9">dmxOffScreenOpt</a> = TRUE</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a10">dmxSubdividePrimitives</a> = TRUE</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a11">dmxLazyWindowCreation</a> = TRUE</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a12">dmxUseXKB</a> = TRUE</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a13">dmxDepth</a> = 0</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a14">dmxNoRender</a> = FALSE</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a16">dmxIgnoreBadFontPaths</a> = FALSE</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinit_8c.html#a17">dmxAddRemoveScreens</a> = FALSE</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Provide expected functions for initialization from the ddx layer and global variables for the DMX server.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a36" doxytag="dmxinit.c::AbortDDX" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void AbortDDX </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This function is called in Xserver/os/utils.c from <em><a class="el" href="dmxlog_8c.html#a3">AbortServer()</a></em>. We must ensure that backend and console state is restored in the event the server shutdown wasn't clean. </td>
+ </tr>
+</table>
+<a class="anchor" name="a37" doxytag="dmxinit.c::ddxGiveUp" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void ddxGiveUp </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This function is called in Xserver/dix/main.c from <em><a class="el" href="xdmxconfig_8c.html#a101">main()</a></em> when dispatchException &amp; DE_TERMINATE (which is the only way to exit the main loop without an interruption. </td>
+ </tr>
+</table>
+<a class="anchor" name="a40" doxytag="dmxinit.c::ddxProcessArgument" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int ddxProcessArgument </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>argc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>argv</em>[], </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>i</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Process our command line arguments. </td>
+ </tr>
+</table>
+<a class="anchor" name="a41" doxytag="dmxinit.c::ddxUseMsg" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void ddxUseMsg </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Provide succinct usage information for the DMX server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a42" doxytag="dmxinit.c::GetTimeInMillis" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> CARD32 GetTimeInMillis </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return wall-clock time in milliseconds. </td>
+ </tr>
+</table>
+<a class="anchor" name="a34" doxytag="dmxinit.c::InitOutput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void InitOutput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenInfo *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreenInfo</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>argc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>argv</em>[]</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine is called in Xserver/dix/main.c from <em><a class="el" href="xdmxconfig_8c.html#a101">main()</a></em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a39" doxytag="dmxinit.c::OsVendorFatalError" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void OsVendorFatalError </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This function is called in Xserver/os/utils.c from <em>FatalError()</em> and <em><a class="el" href="dmxlog_8c.html#a4">VFatalError()</a></em>. (Note that setting the function pointer <em>OsVendorVErrorFProc</em> will cause <em>VErrorF()</em> (which is called by the two routines mentioned here, as well as by others) to use the referenced routine instead of <em>vfprintf()</em>.) </td>
+ </tr>
+</table>
+<a class="anchor" name="a38" doxytag="dmxinit.c::OsVendorInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void OsVendorInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This function is called in Xserver/os/osinit.c from <em>OsInit()</em>. </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a17" doxytag="dmxinit.c::dmxAddRemoveScreens" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="dmxinit_8c.html#a17">dmxAddRemoveScreens</a> = FALSE
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if add and remove screens support is enabled </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmxinit.c::dmxDepth" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxinit_8c.html#a13">dmxDepth</a> = 0
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Requested depth if non-zero </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxinit.c::dmxErrorOccurred" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="dmxinit_8c.html#a7">dmxErrorOccurred</a> = FALSE
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if an error occurred </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxinit.c::dmxFontPath" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> char* <a class="el" href="dmxinit_8c.html#a8">dmxFontPath</a> = NULL
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+NULL if no font path is set on the command line; otherwise, a string of comma separated paths built from the command line specified font paths </td>
+ </tr>
+</table>
+<a class="anchor" name="a16" doxytag="dmxinit.c::dmxIgnoreBadFontPaths" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="dmxinit_8c.html#a16">dmxIgnoreBadFontPaths</a> = FALSE
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if bad font paths should be ignored during server init </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxinit.c::dmxInputs" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a>* <a class="el" href="dmxinput_8h.html#a5">dmxInputs</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+List of inputs </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxinit.c::dmxLastErrorEvent" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> XErrorEvent <a class="el" href="dmxinit_8c.html#a6">dmxLastErrorEvent</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Last error that occurred </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxinit.c::dmxLazyWindowCreation" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="dmxinit_8c.html#a11">dmxLazyWindowCreation</a> = TRUE
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if using the lazy window creation optimization </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmxinit.c::dmxNoRender" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="dmxinit_8c.html#a14">dmxNoRender</a> = FALSE
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if the RENDER extension should be disabled </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxinit.c::dmxNumInputs" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxinput_8h.html#a4">dmxNumInputs</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Number of <a class="el" href="dmxinput_8h.html#a5">dmxInputs</a> </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxinit.c::dmxNumScreens" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxinit_8c.html#a1">dmxNumScreens</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Number of dmxScreens </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxinit.c::dmxOffScreenOpt" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="dmxinit_8c.html#a9">dmxOffScreenOpt</a> = TRUE
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if using off screen optimizations </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxinit.c::dmxScreens" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a>* <a class="el" href="dmxinit_8c.html#a2">dmxScreens</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+List of outputs </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxinit.c::dmxShadowFB" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxinit_8c.html#a5">dmxShadowFB</a> = FALSE
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if using shadow frame-buffer (deprecated) </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxinit.c::dmxSubdividePrimitives" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="dmxinit_8c.html#a10">dmxSubdividePrimitives</a> = TRUE
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if using the primitive subdivision optimization </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxinit.c::dmxUseXKB" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="dmxinit_8c.html#a12">dmxUseXKB</a> = TRUE
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if the XKB extension should be used with the backend servers </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinit_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinit_8h-source.html
new file mode 100644
index 000000000..3217ef4cb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinit_8h-source.html
@@ -0,0 +1,70 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxinit.h</h1><a href="dmxinit_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2004 Red Hat Inc., Raleigh, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Kevin E. Martin &lt;kem@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef DMXINIT_H</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define DMXINIT_H</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="preprocessor">#include "scrnintstr.h"</span>
+00042
+00043 <span class="keyword">extern</span> Bool dmxOpenDisplay(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen);
+00044 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxSetErrorHandler(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen);
+00045 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxCheckForWM(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen);
+00046 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxGetScreenAttribs(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen);
+00047 <span class="keyword">extern</span> Bool dmxGetVisualInfo(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen);
+00048 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxGetColormaps(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen);
+00049 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxGetPixmapFormats(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen);
+00050
+00051 <span class="preprocessor">#endif </span><span class="comment">/* DMXINIT_H */</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinit_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinit_8h.html
new file mode 100644
index 000000000..2890be2c6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinit_8h.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxinit.h File Reference</h1><code>#include "scrnintstr.h"</code><br>
+
+<p>
+<a href="dmxinit_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for initialization. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxinit_8c.html">dmxinit.c</a></dd></dl>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinput_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinput_8c.html
new file mode 100644
index 000000000..09a5ddd05
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinput_8c.html
@@ -0,0 +1,185 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxinput.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxlog_8h-source.html">dmxlog.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxinput_8h-source.html">dmxinput.h</a>"</code><br>
+<code>#include "inputstr.h"</code><br>
+<code>#include "input.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8c.html#a0">LegalModifier</a> (unsigned int key, DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8c.html#a1">InitInput</a> (int argc, char **argv)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8c.html#a2">ProcessInputEvents</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8c.html#a3">dmxUpdateWindowInfo</a> (<a class="el" href="dmxinput_8h.html#a30">DMXUpdateType</a> type, WindowPtr pWindow)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Provide the main entry points for input initialization and processing that arequired by the dix layer.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a3" doxytag="dmxinput.c::dmxUpdateWindowInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxUpdateWindowInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="dmxinput_8h.html#a30">DMXUpdateType</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>type</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine is called from #dmxwindow.c whenever the layout of windows on the display might have changed. This information is used by input drivers (currently only the console driver) that provide information about window layout to the user. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxinput.c::InitInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void InitInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>argc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char **&nbsp;</td>
+ <td class="mdname" nowrap> <em>argv</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Called from dix/main.c on each server generation to initialize inputs. All the work is done in dmxInputInit. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxinput_8h.html#a17">dmxInputInit()</a> </dd></dl>
+ </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxinput.c::LegalModifier" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool LegalModifier </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>key</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Returns TRUE if the key is a valid modifier. For PC-class keyboards, all keys can be used as modifiers, so return TRUE always. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxinput.c::ProcessInputEvents" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void ProcessInputEvents </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Called from dix/dispatch.c in Dispatch() whenever input events require processing. All the work is done in the lower level routines. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinput_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinput_8h-source.html
new file mode 100644
index 000000000..013912f37
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinput_8h-source.html
@@ -0,0 +1,146 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxinput.h</h1><a href="dmxinput_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001,2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * David H. Dawes &lt;dawes@xfree86.org&gt;</span>
+00032 <span class="comment"> * Kevin E. Martin &lt;kem@redhat.com&gt;</span>
+00033 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00034 <span class="comment"> *</span>
+00035 <span class="comment"> */</span>
+00036
+00048 <span class="preprocessor">#ifndef DMXINPUT_H</span>
+00049 <span class="preprocessor"></span><span class="preprocessor">#define DMXINPUT_H</span>
+00050 <span class="preprocessor"></span>
+<a name="l00052"></a><a class="code" href="dmxinput_8h.html#a0">00052</a> <span class="preprocessor">#define DMX_MAX_SIGIO_FDS 4</span>
+00053 <span class="preprocessor"></span>
+00054 <span class="keyword">struct </span><a class="code" href="struct__DMXInputInfo.html">_DMXInputInfo</a>;
+00055
+<a name="l00057"></a><a class="code" href="dmxinput_8h.html#a30">00057</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> {
+00058 <a class="code" href="dmxinput_8h.html#a30a6">DMX_UPDATE_REALIZE</a>,
+00059 <a class="code" href="dmxinput_8h.html#a30a7">DMX_UPDATE_UNREALIZE</a>,
+00060 <a class="code" href="dmxinput_8h.html#a30a8">DMX_UPDATE_RESTACK</a>,
+00061 <a class="code" href="dmxinput_8h.html#a30a9">DMX_UPDATE_COPY</a>,
+00062 <a class="code" href="dmxinput_8h.html#a30a10">DMX_UPDATE_RESIZE</a>,
+00063 <a class="code" href="dmxinput_8h.html#a30a11">DMX_UPDATE_REPARENT</a>
+00064 } <a class="code" href="dmxinput_8h.html#a30">DMXUpdateType</a>;
+00065
+00066 <span class="keyword">typedef</span> void (*ProcessInputEventsProc)(<span class="keyword">struct </span><a class="code" href="struct__DMXInputInfo.html">_DMXInputInfo</a> *);
+00067 <span class="keyword">typedef</span> void (*UpdateWindowInfoProc)(<span class="keyword">struct </span><a class="code" href="struct__DMXInputInfo.html">_DMXInputInfo</a> *,
+00068 <a class="code" href="dmxinput_8h.html#a30">DMXUpdateType</a>, WindowPtr);
+00069
+<a name="l00071"></a><a class="code" href="dmxinput_8h.html#a3">00071</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXLocalInputInfo.html">_DMXLocalInputInfo</a> *<a class="code" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a>;
+00072
+<a name="l00074"></a><a class="code" href="dmxinput_8h.html#a31">00074</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> {
+00075 <a class="code" href="dmxinput_8h.html#a31a12">DMX_NOSIGIO</a> = 0,
+00076 <a class="code" href="dmxinput_8h.html#a31a13">DMX_USESIGIO</a>,
+00079 <a class="code" href="dmxinput_8h.html#a31a14">DMX_ACTIVESIGIO</a>
+00080 } <a class="code" href="dmxinput_8h.html#a31">dmxSigioState</a>;
+00081
+<a name="l00085"></a><a class="code" href="struct__DMXInputInfo.html">00085</a> <span class="keyword">struct </span><a class="code" href="struct__DMXInputInfo.html">_DMXInputInfo</a> {
+<a name="l00086"></a><a class="code" href="struct__DMXInputInfo.html#o0">00086</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="struct__DMXInputInfo.html#o0">name</a>;
+<a name="l00089"></a><a class="code" href="struct__DMXInputInfo.html#o1">00089</a> Bool <a class="code" href="struct__DMXInputInfo.html#o1">freename</a>;
+<a name="l00090"></a><a class="code" href="struct__DMXInputInfo.html#o2">00090</a> Bool <a class="code" href="struct__DMXInputInfo.html#o2">detached</a>;
+<a name="l00091"></a><a class="code" href="struct__DMXInputInfo.html#o3">00091</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXInputInfo.html#o3">inputIdx</a>;
+<a name="l00092"></a><a class="code" href="struct__DMXInputInfo.html#o4">00092</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXInputInfo.html#o4">scrnIdx</a>;
+<a name="l00093"></a><a class="code" href="struct__DMXInputInfo.html#o5">00093</a> Bool <a class="code" href="struct__DMXInputInfo.html#o5">core</a>;
+<a name="l00096"></a><a class="code" href="struct__DMXInputInfo.html#o6">00096</a> Bool <a class="code" href="struct__DMXInputInfo.html#o6">console</a>;
+<a name="l00100"></a><a class="code" href="struct__DMXInputInfo.html#o7">00100</a> Bool <a class="code" href="struct__DMXInputInfo.html#o7">windows</a>;
+00103 ProcessInputEventsProc processInputEvents;
+00104 UpdateWindowInfoProc updateWindowInfo;
+00105
+00106 <span class="comment">/* Local input information */</span>
+<a name="l00107"></a><a class="code" href="struct__DMXInputInfo.html#o10">00107</a> <a class="code" href="dmxinput_8h.html#a31">dmxSigioState</a> <a class="code" href="struct__DMXInputInfo.html#o10">sigioState</a>;
+<a name="l00108"></a><a class="code" href="struct__DMXInputInfo.html#o11">00108</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXInputInfo.html#o11">sigioFdCount</a>;
+<a name="l00109"></a><a class="code" href="struct__DMXInputInfo.html#o12">00109</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXInputInfo.html#o12">sigioFd</a>[<a class="code" href="dmxinput_8h.html#a0">DMX_MAX_SIGIO_FDS</a>];
+<a name="l00110"></a><a class="code" href="struct__DMXInputInfo.html#o13">00110</a> Bool <a class="code" href="struct__DMXInputInfo.html#o13">sigioAdded</a>[<a class="code" href="dmxinput_8h.html#a0">DMX_MAX_SIGIO_FDS</a>];
+<a name="l00114"></a><a class="code" href="struct__DMXInputInfo.html#o14">00114</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXInputInfo.html#o14">vt_switch_pending</a>;
+00115
+<a name="l00117"></a><a class="code" href="struct__DMXInputInfo.html#o15">00117</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXInputInfo.html#o15">vt_switched</a>;
+00118
+<a name="l00120"></a><a class="code" href="struct__DMXInputInfo.html#o16">00120</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXInputInfo.html#o16">numDevs</a>;
+00121
+<a name="l00126"></a><a class="code" href="struct__DMXInputInfo.html#o17">00126</a> <a class="code" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> *<a class="code" href="struct__DMXInputInfo.html#o17">devs</a>;
+00127
+<a name="l00128"></a><a class="code" href="struct__DMXInputInfo.html#o18">00128</a> <span class="keywordtype">char</span> *<a class="code" href="struct__DMXInputInfo.html#o18">keycodes</a>;
+<a name="l00129"></a><a class="code" href="struct__DMXInputInfo.html#o19">00129</a> <span class="keywordtype">char</span> *<a class="code" href="struct__DMXInputInfo.html#o19">symbols</a>;
+<a name="l00130"></a><a class="code" href="struct__DMXInputInfo.html#o20">00130</a> <span class="keywordtype">char</span> *<a class="code" href="struct__DMXInputInfo.html#o20">geometry</a>;
+00131 };
+00132
+<a name="l00133"></a><a class="code" href="dmxinput_8h.html#a4">00133</a> <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxinit_8c.html#a3">dmxNumInputs</a>;
+<a name="l00134"></a><a class="code" href="dmxinput_8h.html#a5">00134</a> <span class="keyword">extern</span> <a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *<a class="code" href="dmxinit_8c.html#a4">dmxInputs</a>;
+00136 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxinputinit_8c.html#a39">dmxInputInit</a>(<a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput);
+00137 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxinputinit_8c.html#a37">dmxInputReInit</a>(<a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput);
+00138 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxinputinit_8c.html#a38">dmxInputLateReInit</a>(<a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput);
+00139 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxinputinit_8c.html#a41">dmxInputFree</a>(<a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput);
+00140 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxinputinit_8c.html#a42">dmxInputLogDevices</a>(<span class="keywordtype">void</span>);
+00141 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxinput_8c.html#a3">dmxUpdateWindowInfo</a>(DMXUpdateType type, WindowPtr pWindow);
+00142
+00143 <span class="comment">/* These functions are defined in input/dmxeq.c */</span>
+00144 <span class="keyword">extern</span> Bool dmxeqInitialized(<span class="keywordtype">void</span>);
+00145 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxeq_8c.html#a13">dmxeqEnqueue</a>(xEvent *e);
+00146 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxeq_8c.html#a14">dmxeqSwitchScreen</a>(ScreenPtr pScreen, Bool fromDIX);
+00147
+00148 <span class="comment">/* This type is used in input/dmxevents.c. Also, these functions are</span>
+00149 <span class="comment"> * defined in input/dmxevents.c */</span>
+00150 <span class="keyword">typedef</span> <span class="keyword">enum</span> {
+00151 DMX_NO_BLOCK = 0,
+00152 DMX_BLOCK = 1
+00153 } DMXBlockType;
+00154
+00155 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxevents_8c.html#a21">dmxGetGlobalPosition</a>(<span class="keywordtype">int</span> *x, <span class="keywordtype">int</span> *y);
+00156 <span class="keyword">extern</span> <a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxFindFirstScreen(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y);
+00157 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxCoreMotion(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> delta,
+00158 DMXBlockType block);
+00159
+00160 <span class="comment">/* Support for dynamic addition of inputs. This functions is defined in</span>
+00161 <span class="comment"> * config/dmxconfig.c */</span>
+00162 <span class="keyword">extern</span> <a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxConfigAddInput(<span class="keyword">const</span> <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> core);
+00163 <span class="preprocessor">#endif </span><span class="comment">/* DMXINPUT_H */</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinput_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinput_8h.html
new file mode 100644
index 000000000..fab2a374d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinput_8h.html
@@ -0,0 +1,534 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxinput.h File Reference</h1>
+<p>
+<a href="dmxinput_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html">_DMXInputInfo</a></td></tr>
+
+<tr><td colspan=2><br><h2>Defines</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8h.html#a0">DMX_MAX_SIGIO_FDS</a>&nbsp;&nbsp;&nbsp;4</td></tr>
+
+<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXLocalInputInfo.html">_DMXLocalInputInfo</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8h.html#a3">DMXLocalInputInfoPtr</a></td></tr>
+
+<tr><td colspan=2><br><h2>Enumerations</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>enum &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8h.html#a30">DMXUpdateType</a> { <br>
+&nbsp;&nbsp;<a class="el" href="dmxinput_8h.html#a30a6">DMX_UPDATE_REALIZE</a>,
+<a class="el" href="dmxinput_8h.html#a30a7">DMX_UPDATE_UNREALIZE</a>,
+<a class="el" href="dmxinput_8h.html#a30a8">DMX_UPDATE_RESTACK</a>,
+<a class="el" href="dmxinput_8h.html#a30a9">DMX_UPDATE_COPY</a>,
+<br>
+&nbsp;&nbsp;<a class="el" href="dmxinput_8h.html#a30a10">DMX_UPDATE_RESIZE</a>,
+<a class="el" href="dmxinput_8h.html#a30a11">DMX_UPDATE_REPARENT</a>
+<br>
+ }</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>enum &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8h.html#a31">dmxSigioState</a> { <a class="el" href="dmxinput_8h.html#a31a12">DMX_NOSIGIO</a> = 0,
+<a class="el" href="dmxinput_8h.html#a31a13">DMX_USESIGIO</a>,
+<a class="el" href="dmxinput_8h.html#a31a14">DMX_ACTIVESIGIO</a>
+ }</td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8h.html#a17">dmxInputInit</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8h.html#a18">dmxInputReInit</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8h.html#a19">dmxInputLateReInit</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8h.html#a20">dmxInputFree</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8h.html#a21">dmxInputLogDevices</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8h.html#a22">dmxUpdateWindowInfo</a> (<a class="el" href="dmxinput_8h.html#a30">DMXUpdateType</a> type, WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8h.html#a24">dmxeqEnqueue</a> (xEvent *e)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8h.html#a25">dmxeqSwitchScreen</a> (ScreenPtr pScreen, Bool fromDIX)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8h.html#a26">dmxGetGlobalPosition</a> (int *x, int *y)</td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8h.html#a4">dmxNumInputs</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinput_8h.html#a5">dmxInputs</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides access to:<ul>
+<li>global variables available to all hw/dmx routines, and</li><li>enumerations and typedefs needed by input routines in hw/dmx (and hw/dmx/input).</li></ul>
+<p>
+The goal is that no files in hw/dmx should include header files from hw/dmx/input -- the interface defined here should be the only interface exported to the hw/dmx layer. <dl compact><dt><b>See also:</b></dt><dd>input/dmxinputinit.c.</dd></dl>
+<hr><h2>Define Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxinput.h::DMX_MAX_SIGIO_FDS" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_MAX_SIGIO_FDS&nbsp;&nbsp;&nbsp;4
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Maximum number of file descriptors for SIGIO handling </td>
+ </tr>
+</table>
+<hr><h2>Typedef Documentation</h2>
+<a class="anchor" name="a3" doxytag="dmxinput.h::DMXLocalInputInfoPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXLocalInputInfo.html">_DMXLocalInputInfo</a>* <a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+An opaque structure that is only exposed in the dmx/input layer. </td>
+ </tr>
+</table>
+<hr><h2>Enumeration Type Documentation</h2>
+<a class="anchor" name="a31" doxytag="dmxinput.h::dmxSigioState" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> enum <a class="el" href="dmxinput_8h.html#a31">dmxSigioState</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+State of the SIGIO engine <dl compact><dt><b>Enumeration values: </b></dt><dd>
+<table border=0 cellspacing=2 cellpadding=0>
+<tr><td valign=top><em><a class="anchor" name="a31a12" doxytag="DMX_NOSIGIO" ></a>DMX_NOSIGIO</em>&nbsp;</td><td>
+Device does not use SIGIO at all. </td></tr>
+<tr><td valign=top><em><a class="anchor" name="a31a13" doxytag="DMX_USESIGIO" ></a>DMX_USESIGIO</em>&nbsp;</td><td>
+Device can use SIGIO, but is not (e.g., because the VT is switch away). </td></tr>
+<tr><td valign=top><em><a class="anchor" name="a31a14" doxytag="DMX_ACTIVESIGIO" ></a>DMX_ACTIVESIGIO</em>&nbsp;</td><td>
+Device is currently using SIGIO. </td></tr>
+</table>
+</dl>
+ </td>
+ </tr>
+</table>
+<a class="anchor" name="a30" doxytag="dmxinput.h::DMXUpdateType" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> enum <a class="el" href="dmxinput_8h.html#a30">DMXUpdateType</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Reason why window layout was updated. <dl compact><dt><b>Enumeration values: </b></dt><dd>
+<table border=0 cellspacing=2 cellpadding=0>
+<tr><td valign=top><em><a class="anchor" name="a30a6" doxytag="DMX_UPDATE_REALIZE" ></a>DMX_UPDATE_REALIZE</em>&nbsp;</td><td>
+Window realized </td></tr>
+<tr><td valign=top><em><a class="anchor" name="a30a7" doxytag="DMX_UPDATE_UNREALIZE" ></a>DMX_UPDATE_UNREALIZE</em>&nbsp;</td><td>
+Window unrealized </td></tr>
+<tr><td valign=top><em><a class="anchor" name="a30a8" doxytag="DMX_UPDATE_RESTACK" ></a>DMX_UPDATE_RESTACK</em>&nbsp;</td><td>
+Stacking order changed </td></tr>
+<tr><td valign=top><em><a class="anchor" name="a30a9" doxytag="DMX_UPDATE_COPY" ></a>DMX_UPDATE_COPY</em>&nbsp;</td><td>
+Window copied </td></tr>
+<tr><td valign=top><em><a class="anchor" name="a30a10" doxytag="DMX_UPDATE_RESIZE" ></a>DMX_UPDATE_RESIZE</em>&nbsp;</td><td>
+Window resized </td></tr>
+<tr><td valign=top><em><a class="anchor" name="a30a11" doxytag="DMX_UPDATE_REPARENT" ></a>DMX_UPDATE_REPARENT</em>&nbsp;</td><td>
+Window reparented </td></tr>
+</table>
+</dl>
+ </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a24" doxytag="dmxinput.h::dmxeqEnqueue" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxeqEnqueue </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">xEvent *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>e</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This function adds an event to the end of the queue. If the event is an XInput event, then the next event (the valuator event) is also stored in the queue. If the new event has a time before the time of the last event currently on the queue, then the time is updated for the new event.<p>
+Must be reentrant with ProcessInputEvents. Assumption: dmxeqEnqueue will never be interrupted. If this is called from both signal handlers and regular code, make sure the signal is suspended when called from regular code. </td>
+ </tr>
+</table>
+<a class="anchor" name="a25" doxytag="dmxinput.h::dmxeqSwitchScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxeqSwitchScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Bool&nbsp;</td>
+ <td class="mdname" nowrap> <em>fromDIX</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Make <em>pScreen</em> the new screen for enqueueing events. If <em>fromDIX</em> is TRUE, also make <em>pScreen</em> the new screen for dequeuing events. </td>
+ </tr>
+</table>
+<a class="anchor" name="a26" doxytag="dmxinput.h::dmxGetGlobalPosition" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxGetGlobalPosition </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return DMX's notion of the pointer position in the global coordinate space. </td>
+ </tr>
+</table>
+<a class="anchor" name="a20" doxytag="dmxinput.h::dmxInputFree" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInputFree </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxInput</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Free all of the memory associated with <em>dmxInput</em> </td>
+ </tr>
+</table>
+<a class="anchor" name="a17" doxytag="dmxinput.h::dmxInputInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInputInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxInput</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize all of the devices described in <em>dmxInput</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a19" doxytag="dmxinput.h::dmxInputLateReInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInputLateReInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxInput</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Re-initialize all the devices described in <em>dmxInput</em>. Called from #dmxReconfig after the cursor is redisplayed. </td>
+ </tr>
+</table>
+<a class="anchor" name="a21" doxytag="dmxinput.h::dmxInputLogDevices" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInputLogDevices </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Log information about all of the known devices using <a class="el" href="dmxlog_8c.html#a7">dmxLog()</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a18" doxytag="dmxinput.h::dmxInputReInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInputReInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxInput</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Re-initialize all the devices described in <em>dmxInput</em>. Called from #dmxReconfig before the cursor is redisplayed. </td>
+ </tr>
+</table>
+<a class="anchor" name="a22" doxytag="dmxinput.h::dmxUpdateWindowInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxUpdateWindowInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="dmxinput_8h.html#a30">DMXUpdateType</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>type</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine is called from #dmxwindow.c whenever the layout of windows on the display might have changed. This information is used by input drivers (currently only the console driver) that provide information about window layout to the user. </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a5" doxytag="dmxinput.h::dmxInputs" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a>* <a class="el" href="dmxinput_8h.html#a5">dmxInputs</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+List of inputs </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxinput.h::dmxNumInputs" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxinput_8h.html#a4">dmxNumInputs</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Number of <a class="el" href="dmxinput_8h.html#a5">dmxInputs</a> </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinputinit_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinputinit_8c.html
new file mode 100644
index 000000000..9b06c5221
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinputinit_8c.html
@@ -0,0 +1,477 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxinputinit.c File Reference</h1><code>#include "<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxextension_8h-source.html">dmxextension.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxdummy_8h-source.html">dmxdummy.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxbackend_8h-source.html">dmxbackend.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxconsole_8h-source.html">dmxconsole.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcommon_8h-source.html">dmxcommon.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxevents_8h-source.html">dmxevents.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxmotion_8h-source.html">dmxmotion.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxeq_8h-source.html">dmxeq.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxprop_8h-source.html">dmxprop.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxconfig_8h-source.html">config/dmxconfig.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcursor_8h-source.html">dmxcursor.h</a>"</code><br>
+<code>#include "<a class="el" href="lnx-keyboard_8h-source.html">lnx-keyboard.h</a>"</code><br>
+<code>#include "<a class="el" href="lnx-ms_8h-source.html">lnx-ms.h</a>"</code><br>
+<code>#include "<a class="el" href="lnx-ps2_8h-source.html">lnx-ps2.h</a>"</code><br>
+<code>#include "<a class="el" href="usb-keyboard_8h-source.html">usb-keyboard.h</a>"</code><br>
+<code>#include "<a class="el" href="usb-mouse_8h-source.html">usb-mouse.h</a>"</code><br>
+<code>#include "<a class="el" href="usb-other_8h-source.html">usb-other.h</a>"</code><br>
+<code>#include "<a class="el" href="usb-common_8h-source.html">usb-common.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsigio_8h-source.html">dmxsigio.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxarg_8h-source.html">dmxarg.h</a>"</code><br>
+<code>#include "inputstr.h"</code><br>
+<code>#include "input.h"</code><br>
+<code>#include "mipointer.h"</code><br>
+<code>#include "windowstr.h"</code><br>
+<code>#include "XI.h"</code><br>
+<code>#include "XIproto.h"</code><br>
+<code>#include "exevents.h"</code><br>
+<code>#include "extinit.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8c.html#a16">dmxChangePointerControl</a> (DeviceIntPtr pDevice, PtrCtrl *ctrl)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8c.html#a18">dmxKeyboardKbdCtrlProc</a> (DeviceIntPtr pDevice, KeybdCtrl *ctrl)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8c.html#a20">dmxKeyboardBellProc</a> (int percent, DeviceIntPtr pDevice, pointer ctrl, int unknown)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8c.html#a33">dmxInputCopyLocal</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput, <a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> s)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8c.html#a37">dmxInputReInit</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8c.html#a38">dmxInputLateReInit</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8c.html#a39">dmxInputInit</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8c.html#a41">dmxInputFree</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8c.html#a42">dmxInputLogDevices</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8c.html#a43">dmxInputDetach</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8c.html#a44">dmxInputDetachAll</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8c.html#a45">dmxInputDetachId</a> (int id)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides generic input support. Functions here set up input and lead to the calling of low-level device drivers for input.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a16" doxytag="dmxinputinit.c::dmxChangePointerControl" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxChangePointerControl </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDevice</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PtrCtrl *&nbsp;</td>
+ <td class="mdname" nowrap> <em>ctrl</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the pointer control information for the <em>pDevice</em>. If the device sends core events, then also change the control information for all of the pointer devices that send core events. </td>
+ </tr>
+</table>
+<a class="anchor" name="a33" doxytag="dmxinputinit.c::dmxInputCopyLocal" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> dmxInputCopyLocal </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxInput</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>s</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Copy the local input information from <em>s</em> into a new <em>devs</em> slot in <em>dmxInput</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a43" doxytag="dmxinputinit.c::dmxInputDetach" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxInputDetach </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxInput</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Detach an input </td>
+ </tr>
+</table>
+<a class="anchor" name="a44" doxytag="dmxinputinit.c::dmxInputDetachAll" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInputDetachAll </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Search for input associated with <em>dmxScreen</em>, and detach. </td>
+ </tr>
+</table>
+<a class="anchor" name="a45" doxytag="dmxinputinit.c::dmxInputDetachId" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxInputDetachId </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>id</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Search for input associated with <em>deviceId</em>, and detach. </td>
+ </tr>
+</table>
+<a class="anchor" name="a41" doxytag="dmxinputinit.c::dmxInputFree" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInputFree </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxInput</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Free all of the memory associated with <em>dmxInput</em> </td>
+ </tr>
+</table>
+<a class="anchor" name="a39" doxytag="dmxinputinit.c::dmxInputInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInputInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxInput</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize all of the devices described in <em>dmxInput</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a38" doxytag="dmxinputinit.c::dmxInputLateReInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInputLateReInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxInput</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Re-initialize all the devices described in <em>dmxInput</em>. Called from #dmxReconfig after the cursor is redisplayed. </td>
+ </tr>
+</table>
+<a class="anchor" name="a42" doxytag="dmxinputinit.c::dmxInputLogDevices" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInputLogDevices </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Log information about all of the known devices using <a class="el" href="dmxlog_8c.html#a7">dmxLog()</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a37" doxytag="dmxinputinit.c::dmxInputReInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInputReInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxInput</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Re-initialize all the devices described in <em>dmxInput</em>. Called from #dmxReconfig before the cursor is redisplayed. </td>
+ </tr>
+</table>
+<a class="anchor" name="a20" doxytag="dmxinputinit.c::dmxKeyboardBellProc" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxKeyboardBellProc </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>percent</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDevice</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>ctrl</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>unknown</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Sound the bell on the device. If the device send core events, then sound the bell on all of the devices that send core events. </td>
+ </tr>
+</table>
+<a class="anchor" name="a18" doxytag="dmxinputinit.c::dmxKeyboardKbdCtrlProc" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxKeyboardKbdCtrlProc </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDevice</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>KeybdCtrl *&nbsp;</td>
+ <td class="mdname" nowrap> <em>ctrl</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the keyboard control information for the <em>pDevice</em>. If the device sends core events, then also change the control information for all of the keyboard devices that send core events. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinputinit_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinputinit_8h-source.html
new file mode 100644
index 000000000..9899c67a0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinputinit_8h-source.html
@@ -0,0 +1,259 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxinputinit.h</h1><a href="dmxinputinit_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _DMXINPUTINIT_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _DMXINPUTINIT_H_</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="preprocessor">#include "<a class="code" href="dmx_8h.html">dmx.h</a>"</span>
+00042 <span class="preprocessor">#include "<a class="code" href="dmxinput_8h.html">dmxinput.h</a>"</span>
+00043 <span class="preprocessor">#include "<a class="code" href="dmxlog_8h.html">dmxlog.h</a>"</span>
+00044
+00045
+00046 <span class="preprocessor">#define DMX_LOCAL_DEFAULT_KEYBOARD "kbd"</span>
+00047 <span class="preprocessor"></span><span class="preprocessor">#define DMX_LOCAL_DEFAULT_POINTER "ps2"</span>
+00048 <span class="preprocessor"></span><span class="preprocessor">#define DMX_MAX_BUTTONS 256</span>
+00049 <span class="preprocessor"></span><span class="preprocessor">#define DMX_MOTION_SIZE 256</span>
+00050 <span class="preprocessor"></span><span class="preprocessor">#define DMX_MAX_VALUATORS 32</span>
+00051 <span class="preprocessor"></span><span class="preprocessor">#define DMX_MAX_AXES 32</span>
+00052 <span class="preprocessor"></span><span class="preprocessor">#define DMX_MAX_XINPUT_EVENT_TYPES 100</span>
+00053 <span class="preprocessor"></span><span class="preprocessor">#define DMX_MAP_ENTRIES 16 </span><span class="comment">/* Must be a power of 2 */</span>
+00054 <span class="preprocessor">#define DMX_MAP_MASK (DMX_MAP_ENTRIES - 1)</span>
+00055 <span class="preprocessor"></span>
+00056 <span class="keyword">typedef</span> <span class="keyword">enum</span> {
+00057 DMX_FUNCTION_GRAB,
+00058 DMX_FUNCTION_TERMINATE,
+00059 DMX_FUNCTION_FINE
+00060 } DMXFunctionType;
+00061
+00062 <span class="keyword">typedef</span> <span class="keyword">enum</span> {
+00063 DMX_LOCAL_HIGHLEVEL,
+00064 DMX_LOCAL_KEYBOARD,
+00065 DMX_LOCAL_MOUSE,
+00066 DMX_LOCAL_OTHER
+00067 } DMXLocalInputType;
+00068
+00069 <span class="keyword">typedef</span> <span class="keyword">enum</span> {
+00070 DMX_LOCAL_TYPE_LOCAL,
+00071 DMX_LOCAL_TYPE_CONSOLE,
+00072 DMX_LOCAL_TYPE_BACKEND,
+00073 DMX_LOCAL_TYPE_COMMON
+00074 } DMXLocalInputExtType;
+00075
+00076 <span class="keyword">typedef</span> <span class="keyword">enum</span> {
+00077 DMX_RELATIVE,
+00078 DMX_ABSOLUTE,
+00079 DMX_ABSOLUTE_CONFINED
+00080 } DMXMotionType;
+00081
+<a name="l00084"></a><a class="code" href="struct__DMXLocalInitInfo.html">00084</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXLocalInitInfo.html">_DMXLocalInitInfo</a> {
+<a name="l00085"></a><a class="code" href="struct__DMXLocalInitInfo.html#o0">00085</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o0">keyboard</a>;
+<a name="l00087"></a><a class="code" href="struct__DMXLocalInitInfo.html#o1">00087</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o1">keyClass</a>;
+<a name="l00088"></a><a class="code" href="struct__DMXLocalInitInfo.html#o2">00088</a> KeySymsRec <a class="code" href="struct__DMXLocalInitInfo.html#o2">keySyms</a>;
+<a name="l00089"></a><a class="code" href="struct__DMXLocalInitInfo.html#o3">00089</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o3">freemap</a>;
+<a name="l00090"></a><a class="code" href="struct__DMXLocalInitInfo.html#o4">00090</a> CARD8 <a class="code" href="struct__DMXLocalInitInfo.html#o4">modMap</a>[MAP_LENGTH];
+00091 <span class="preprocessor">#ifdef XKB</span>
+<a name="l00092"></a><a class="code" href="struct__DMXLocalInitInfo.html#o5">00092</a> <span class="preprocessor"></span> XkbDescPtr <a class="code" href="struct__DMXLocalInitInfo.html#o5">xkb</a>;
+<a name="l00093"></a><a class="code" href="struct__DMXLocalInitInfo.html#o6">00093</a> XkbComponentNamesRec <a class="code" href="struct__DMXLocalInitInfo.html#o6">names</a>;
+<a name="l00094"></a><a class="code" href="struct__DMXLocalInitInfo.html#o7">00094</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o7">freenames</a>;
+<a name="l00095"></a><a class="code" href="struct__DMXLocalInitInfo.html#o8">00095</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o8">force</a>;
+00096 <span class="preprocessor">#endif</span>
+00097 <span class="preprocessor"></span>
+<a name="l00098"></a><a class="code" href="struct__DMXLocalInitInfo.html#o9">00098</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o9">buttonClass</a>;
+<a name="l00099"></a><a class="code" href="struct__DMXLocalInitInfo.html#o10">00099</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o10">numButtons</a>;
+<a name="l00100"></a><a class="code" href="struct__DMXLocalInitInfo.html#o11">00100</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="struct__DMXLocalInitInfo.html#o11">map</a>[DMX_MAX_BUTTONS];
+<a name="l00102"></a><a class="code" href="struct__DMXLocalInitInfo.html#o12">00102</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o12">valuatorClass</a>;
+<a name="l00104"></a><a class="code" href="struct__DMXLocalInitInfo.html#o13">00104</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o13">numRelAxes</a>;
+<a name="l00105"></a><a class="code" href="struct__DMXLocalInitInfo.html#o14">00105</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o14">numAbsAxes</a>;
+<a name="l00106"></a><a class="code" href="struct__DMXLocalInitInfo.html#o15">00106</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o15">minval</a>[DMX_MAX_AXES];
+<a name="l00107"></a><a class="code" href="struct__DMXLocalInitInfo.html#o16">00107</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o16">maxval</a>[DMX_MAX_AXES];
+<a name="l00108"></a><a class="code" href="struct__DMXLocalInitInfo.html#o17">00108</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o17">res</a>[DMX_MAX_AXES];
+<a name="l00109"></a><a class="code" href="struct__DMXLocalInitInfo.html#o18">00109</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o18">minres</a>[DMX_MAX_AXES];
+<a name="l00110"></a><a class="code" href="struct__DMXLocalInitInfo.html#o19">00110</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o19">maxres</a>[DMX_MAX_AXES];
+<a name="l00112"></a><a class="code" href="struct__DMXLocalInitInfo.html#o20">00112</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o20">focusClass</a>;
+<a name="l00114"></a><a class="code" href="struct__DMXLocalInitInfo.html#o21">00114</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o21">proximityClass</a>;
+<a name="l00116"></a><a class="code" href="struct__DMXLocalInitInfo.html#o22">00116</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o22">kbdFeedbackClass</a>;
+<a name="l00118"></a><a class="code" href="struct__DMXLocalInitInfo.html#o23">00118</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o23">ptrFeedbackClass</a>;
+<a name="l00120"></a><a class="code" href="struct__DMXLocalInitInfo.html#o24">00120</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o24">ledFeedbackClass</a>;
+<a name="l00122"></a><a class="code" href="struct__DMXLocalInitInfo.html#o25">00122</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o25">belFeedbackClass</a>;
+<a name="l00124"></a><a class="code" href="struct__DMXLocalInitInfo.html#o26">00124</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o26">intFeedbackClass</a>;
+<a name="l00126"></a><a class="code" href="struct__DMXLocalInitInfo.html#o27">00126</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o27">strFeedbackClass</a>;
+<a name="l00129"></a><a class="code" href="struct__DMXLocalInitInfo.html#o28">00129</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o28">maxSymbols</a>;
+<a name="l00130"></a><a class="code" href="struct__DMXLocalInitInfo.html#o29">00130</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInitInfo.html#o29">maxSymbolsSupported</a>;
+<a name="l00131"></a><a class="code" href="struct__DMXLocalInitInfo.html#o30">00131</a> KeySym *<a class="code" href="struct__DMXLocalInitInfo.html#o30">symbols</a>;
+00132 } <a class="code" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfo</a>, *<a class="code" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>;
+00133
+00134 <span class="keyword">typedef</span> pointer (*dmxCreatePrivateProcPtr)(DeviceIntPtr);
+00135 <span class="keyword">typedef</span> void (*dmxDestroyPrivateProcPtr)(pointer);
+00136
+00137 <span class="keyword">typedef</span> void (*dmxInitProcPtr)(DevicePtr);
+00138 <span class="keyword">typedef</span> void (*dmxReInitProcPtr)(DevicePtr);
+00139 <span class="keyword">typedef</span> void (*dmxLateReInitProcPtr)(DevicePtr);
+00140 <span class="keyword">typedef</span> void (*dmxGetInfoProcPtr)(DevicePtr, <a class="code" href="dmxinputinit_8h.html#a10">DMXLocalInitInfoPtr</a>);
+00141 <span class="keyword">typedef</span> int (*dmxOnProcPtr)(DevicePtr);
+00142 <span class="keyword">typedef</span> void (*dmxOffProcPtr)(DevicePtr);
+00143 <span class="keyword">typedef</span> void (*dmxUpdatePositionProcPtr)(pointer, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y);
+00144
+00145 <span class="keyword">typedef</span> void (*dmxVTPreSwitchProcPtr)(pointer); <span class="comment">/* Turn I/O Off */</span>
+00146 <span class="keyword">typedef</span> void (*dmxVTPostSwitchProcPtr)(pointer); <span class="comment">/* Turn I/O On */</span>
+00147 <span class="keyword">typedef</span> void (*dmxVTSwitchReturnProcPtr)(pointer);
+00148 <span class="keyword">typedef</span> int (*dmxVTSwitchProcPtr)(pointer, <span class="keywordtype">int</span> vt,
+00149 dmxVTSwitchReturnProcPtr, pointer);
+00150
+00151 <span class="keyword">typedef</span> void (*dmxMotionProcPtr)(DevicePtr,
+00152 <span class="keywordtype">int</span> *valuators,
+00153 <span class="keywordtype">int</span> firstAxis,
+00154 <span class="keywordtype">int</span> axesCount,
+00155 DMXMotionType type,
+00156 DMXBlockType block);
+00157 <span class="keyword">typedef</span> void (*dmxEnqueueProcPtr)(DevicePtr, <span class="keywordtype">int</span> type, <span class="keywordtype">int</span> detail,
+00158 KeySym keySym, XEvent *e,
+00159 DMXBlockType block);
+00160 <span class="keyword">typedef</span> int (*dmxCheckSpecialProcPtr)(DevicePtr, KeySym keySym);
+00161 <span class="keyword">typedef</span> void (*dmxCollectEventsProcPtr)(DevicePtr,
+00162 dmxMotionProcPtr,
+00163 dmxEnqueueProcPtr,
+00164 dmxCheckSpecialProcPtr,
+00165 DMXBlockType);
+00166 <span class="keyword">typedef</span> void (*dmxProcessInputProcPtr)(pointer);
+00167 <span class="keyword">typedef</span> void (*dmxUpdateInfoProcPtr)(pointer, <a class="code" href="dmxinput_8h.html#a30">DMXUpdateType</a>, WindowPtr);
+00168 <span class="keyword">typedef</span> int (*dmxFunctionsProcPtr)(pointer, DMXFunctionType);
+00169
+00170 <span class="keyword">typedef</span> void (*dmxKBCtrlProcPtr)(DevicePtr, KeybdCtrl *ctrl);
+00171 <span class="keyword">typedef</span> void (*dmxMCtrlProcPtr)(DevicePtr, PtrCtrl *ctrl);
+00172 <span class="keyword">typedef</span> void (*dmxKBBellProcPtr)(DevicePtr, <span class="keywordtype">int</span> percent,
+00173 <span class="keywordtype">int</span> volume, <span class="keywordtype">int</span> pitch, <span class="keywordtype">int</span> duration);
+00174
+<a name="l00177"></a><a class="code" href="struct__DMXEventMap.html">00177</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXEventMap.html">_DMXEventMap</a> {
+<a name="l00178"></a><a class="code" href="struct__DMXEventMap.html#o0">00178</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXEventMap.html#o0">remote</a>;
+<a name="l00179"></a><a class="code" href="struct__DMXEventMap.html#o1">00179</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXEventMap.html#o1">server</a>;
+00180 } <a class="code" href="struct__DMXEventMap.html">DMXEventMap</a>;
+00181
+<a name="l00185"></a><a class="code" href="struct__DMXLocalInputInfo.html">00185</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXLocalInputInfo.html">_DMXLocalInputInfo</a> {
+<a name="l00186"></a><a class="code" href="struct__DMXLocalInputInfo.html#o0">00186</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="struct__DMXLocalInputInfo.html#o0">name</a>;
+<a name="l00187"></a><a class="code" href="struct__DMXLocalInputInfo.html#o1">00187</a> DMXLocalInputType type;
+<a name="l00188"></a><a class="code" href="struct__DMXLocalInputInfo.html#o2">00188</a> DMXLocalInputExtType <a class="code" href="struct__DMXLocalInputInfo.html#o2">extType</a>;
+<a name="l00189"></a><a class="code" href="struct__DMXLocalInputInfo.html#o3">00189</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInputInfo.html#o3">binding</a>;
+00193 <span class="comment">/* Low-level (e.g., keyboard/mouse drivers) */</span>
+00194
+<a name="l00195"></a><a class="code" href="struct__DMXLocalInputInfo.html#o4">00195</a> dmxCreatePrivateProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o4">create_private</a>;
+<a name="l00198"></a><a class="code" href="struct__DMXLocalInputInfo.html#o5">00198</a> dmxDestroyPrivateProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o5">destroy_private</a>;
+<a name="l00201"></a><a class="code" href="struct__DMXLocalInputInfo.html#o6">00201</a> dmxInitProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o6">init</a>;
+<a name="l00202"></a><a class="code" href="struct__DMXLocalInputInfo.html#o7">00202</a> dmxReInitProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o7">reinit</a>;
+<a name="l00205"></a><a class="code" href="struct__DMXLocalInputInfo.html#o8">00205</a> dmxLateReInitProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o8">latereinit</a>;
+<a name="l00209"></a><a class="code" href="struct__DMXLocalInputInfo.html#o9">00209</a> dmxGetInfoProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o9">get_info</a>;
+<a name="l00210"></a><a class="code" href="struct__DMXLocalInputInfo.html#o10">00210</a> dmxOnProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o10">on</a>;
+<a name="l00211"></a><a class="code" href="struct__DMXLocalInputInfo.html#o11">00211</a> dmxOffProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o11">off</a>;
+<a name="l00212"></a><a class="code" href="struct__DMXLocalInputInfo.html#o12">00212</a> dmxUpdatePositionProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o12">update_position</a>;
+<a name="l00215"></a><a class="code" href="struct__DMXLocalInputInfo.html#o13">00215</a> dmxVTPreSwitchProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o13">vt_pre_switch</a>;
+<a name="l00216"></a><a class="code" href="struct__DMXLocalInputInfo.html#o14">00216</a> dmxVTPostSwitchProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o14">vt_post_switch</a>;
+<a name="l00217"></a><a class="code" href="struct__DMXLocalInputInfo.html#o15">00217</a> dmxVTSwitchProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o15">vt_switch</a>;
+<a name="l00219"></a><a class="code" href="struct__DMXLocalInputInfo.html#o16">00219</a> dmxCollectEventsProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o16">collect_events</a>;
+<a name="l00222"></a><a class="code" href="struct__DMXLocalInputInfo.html#o17">00222</a> dmxProcessInputProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o17">process_input</a>;
+00224 dmxFunctionsProcPtr functions;
+<a name="l00225"></a><a class="code" href="struct__DMXLocalInputInfo.html#o19">00225</a> dmxUpdateInfoProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o19">update_info</a>;
+<a name="l00228"></a><a class="code" href="struct__DMXLocalInputInfo.html#o20">00228</a> dmxMCtrlProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o20">mCtrl</a>;
+<a name="l00229"></a><a class="code" href="struct__DMXLocalInputInfo.html#o21">00229</a> dmxKBCtrlProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o21">kCtrl</a>;
+<a name="l00230"></a><a class="code" href="struct__DMXLocalInputInfo.html#o22">00230</a> dmxKBBellProcPtr <a class="code" href="struct__DMXLocalInputInfo.html#o22">kBell</a>;
+<a name="l00232"></a><a class="code" href="struct__DMXLocalInputInfo.html#o23">00232</a> pointer <span class="keyword">private</span>;
+<a name="l00233"></a><a class="code" href="struct__DMXLocalInputInfo.html#o24">00233</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInputInfo.html#o24">isCore</a>;
+<a name="l00234"></a><a class="code" href="struct__DMXLocalInputInfo.html#o25">00234</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInputInfo.html#o25">sendsCore</a>;
+<a name="l00235"></a><a class="code" href="struct__DMXLocalInputInfo.html#o26">00235</a> KeybdCtrl <a class="code" href="struct__DMXLocalInputInfo.html#o26">kctrl</a>;
+<a name="l00236"></a><a class="code" href="struct__DMXLocalInputInfo.html#o27">00236</a> PtrCtrl <a class="code" href="struct__DMXLocalInputInfo.html#o27">mctrl</a>;
+<a name="l00238"></a><a class="code" href="struct__DMXLocalInputInfo.html#o28">00238</a> DeviceIntPtr <a class="code" href="struct__DMXLocalInputInfo.html#o28">pDevice</a>;
+<a name="l00239"></a><a class="code" href="struct__DMXLocalInputInfo.html#o29">00239</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInputInfo.html#o29">inputIdx</a>;
+<a name="l00240"></a><a class="code" href="struct__DMXLocalInputInfo.html#o31">00240</a> <span class="keywordtype">int</span> lastX, <a class="code" href="struct__DMXLocalInputInfo.html#o31">lastY</a>;
+<a name="l00244"></a><a class="code" href="struct__DMXLocalInputInfo.html#o32">00244</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInputInfo.html#o32">head</a>;
+<a name="l00246"></a><a class="code" href="struct__DMXLocalInputInfo.html#o33">00246</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInputInfo.html#o33">tail</a>;
+<a name="l00248"></a><a class="code" href="struct__DMXLocalInputInfo.html#o34">00248</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *<a class="code" href="struct__DMXLocalInputInfo.html#o34">history</a>;
+<a name="l00249"></a><a class="code" href="struct__DMXLocalInputInfo.html#o35">00249</a> <span class="keywordtype">int</span> *valuators;
+00251 <span class="comment">/* for XInput ChangePointerDevice */</span>
+00252 int (*savedMotionProc)(DeviceIntPtr,
+00253 xTimecoord *,
+00254 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>,
+00255 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>,
+00256 ScreenPtr);
+<a name="l00257"></a><a class="code" href="struct__DMXLocalInputInfo.html#o37">00257</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInputInfo.html#o37">savedMotionEvents</a>;
+<a name="l00258"></a><a class="code" href="struct__DMXLocalInputInfo.html#o38">00258</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInputInfo.html#o38">savedSendsCore</a>;
+<a name="l00260"></a><a class="code" href="struct__DMXLocalInputInfo.html#o39">00260</a> <a class="code" href="struct__DMXEventMap.html">DMXEventMap</a> <a class="code" href="struct__DMXLocalInputInfo.html#o39">map</a>[DMX_MAP_ENTRIES];
+<a name="l00261"></a><a class="code" href="struct__DMXLocalInputInfo.html#o40">00261</a> <span class="keywordtype">int</span> <a class="code" href="struct__DMXLocalInputInfo.html#o40">mapOptimize</a>;
+<a name="l00265"></a><a class="code" href="struct__DMXLocalInputInfo.html#o41">00265</a> <span class="keywordtype">long</span> <a class="code" href="struct__DMXLocalInputInfo.html#o41">deviceId</a>;
+<a name="l00267"></a><a class="code" href="struct__DMXLocalInputInfo.html#o42">00267</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="struct__DMXLocalInputInfo.html#o42">deviceName</a>;
+00269 } <a class="code" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoRec</a>;
+00270
+00271 <span class="keyword">extern</span> <a class="code" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> dmxLocalCorePointer, dmxLocalCoreKeyboard;
+00272
+00273 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxLocalInitInput(<a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput);
+00274 <span class="keyword">extern</span> <a class="code" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> <a class="code" href="dmxinputinit_8c.html#a33">dmxInputCopyLocal</a>(<a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput,
+00275 <a class="code" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> s);
+00276
+00277 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxinputinit_8c.html#a16">dmxChangePointerControl</a>(DeviceIntPtr pDevice, PtrCtrl *ctrl);
+00278 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxinputinit_8c.html#a18">dmxKeyboardKbdCtrlProc</a>(DeviceIntPtr pDevice, KeybdCtrl *ctrl);
+00279 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxinputinit_8c.html#a20">dmxKeyboardBellProc</a>(<span class="keywordtype">int</span> percent, DeviceIntPtr pDevice,
+00280 pointer ctrl, <span class="keywordtype">int</span> unknown);
+00281
+00282 <span class="keyword">extern</span> <span class="keywordtype">int</span> dmxInputExtensionErrorHandler(Display *dsp, <span class="keywordtype">char</span> *name,
+00283 <span class="keywordtype">char</span> *reason);
+00284
+00285 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxinputinit_8c.html#a43">dmxInputDetach</a>(<a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput);
+00286 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxinputinit_8c.html#a44">dmxInputDetachAll</a>(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen);
+00287 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxinputinit_8c.html#a45">dmxInputDetachId</a>(<span class="keywordtype">int</span> id);
+00288 <span class="keyword">extern</span> <a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInputLocateId(<span class="keywordtype">int</span> id);
+00289 <span class="keyword">extern</span> <span class="keywordtype">int</span> dmxInputAttachConsole(<span class="keyword">const</span> <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> isCore,
+00290 <span class="keywordtype">int</span> *id);
+00291 <span class="keyword">extern</span> <span class="keywordtype">int</span> dmxInputAttachBackend(<span class="keywordtype">int</span> physicalScreen, <span class="keywordtype">int</span> isCore,
+00292 <span class="keywordtype">int</span> *id);
+00293
+00294 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinputinit_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinputinit_8h.html
new file mode 100644
index 000000000..03a64d73d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinputinit_8h.html
@@ -0,0 +1,406 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxinputinit.h File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxinput_8h-source.html">dmxinput.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxlog_8h-source.html">dmxlog.h</a>"</code><br>
+
+<p>
+<a href="dmxinputinit_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXEventMap.html">_DMXEventMap</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html">_DMXLocalInitInfo</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html">_DMXLocalInputInfo</a></td></tr>
+
+<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXLocalInitInfo.html">_DMXLocalInitInfo</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8h.html#a9">DMXLocalInitInfo</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXLocalInitInfo.html">_DMXLocalInitInfo</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8h.html#a10">DMXLocalInitInfoPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXEventMap.html">_DMXEventMap</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8h.html#a34">DMXEventMap</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXLocalInputInfo.html">_DMXLocalInputInfo</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8h.html#a35">DMXLocalInputInfoRec</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8h.html#a53">dmxInputCopyLocal</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput, <a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> s)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8h.html#a54">dmxChangePointerControl</a> (DeviceIntPtr pDevice, PtrCtrl *ctrl)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8h.html#a55">dmxKeyboardKbdCtrlProc</a> (DeviceIntPtr pDevice, KeybdCtrl *ctrl)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8h.html#a56">dmxKeyboardBellProc</a> (int percent, DeviceIntPtr pDevice, pointer ctrl, int unknown)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8h.html#a58">dmxInputDetach</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8h.html#a59">dmxInputDetachAll</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxinputinit_8h.html#a60">dmxInputDetachId</a> (int id)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for low-level input support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxinputinit_8c.html">dmxinputinit.c</a></dd></dl>
+<hr><h2>Typedef Documentation</h2>
+<a class="anchor" name="a34" doxytag="dmxinputinit.h::DMXEventMap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXEventMap.html">_DMXEventMap</a> <a class="el" href="struct__DMXEventMap.html">DMXEventMap</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores a mapping between the device id on the remote X server and the id on the DMX server </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxinputinit.h::DMXLocalInitInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXLocalInitInfo.html">_DMXLocalInitInfo</a> <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfo</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores information from low-level device that is used to initialize the device at the dix level. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxinputinit.h::DMXLocalInitInfoPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXLocalInitInfo.html">_DMXLocalInitInfo</a> * <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores information from low-level device that is used to initialize the device at the dix level. </td>
+ </tr>
+</table>
+<a class="anchor" name="a35" doxytag="dmxinputinit.h::DMXLocalInputInfoRec" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXLocalInputInfo.html">_DMXLocalInputInfo</a> <a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoRec</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This is the device-independent structure used by the low-level input routines. The contents are not exposed to top-level .c files (except dmxextensions.c). <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxinput_8h.html">dmxinput.h</a> <p>
+dmxextensions.c </dd></dl>
+ </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a54" doxytag="dmxinputinit.h::dmxChangePointerControl" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxChangePointerControl </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDevice</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PtrCtrl *&nbsp;</td>
+ <td class="mdname" nowrap> <em>ctrl</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the pointer control information for the <em>pDevice</em>. If the device sends core events, then also change the control information for all of the pointer devices that send core events. </td>
+ </tr>
+</table>
+<a class="anchor" name="a53" doxytag="dmxinputinit.h::dmxInputCopyLocal" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> dmxInputCopyLocal </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxInput</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>s</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Copy the local input information from <em>s</em> into a new <em>devs</em> slot in <em>dmxInput</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a58" doxytag="dmxinputinit.h::dmxInputDetach" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxInputDetach </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxInput</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Detach an input </td>
+ </tr>
+</table>
+<a class="anchor" name="a59" doxytag="dmxinputinit.h::dmxInputDetachAll" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInputDetachAll </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Search for input associated with <em>dmxScreen</em>, and detach. </td>
+ </tr>
+</table>
+<a class="anchor" name="a60" doxytag="dmxinputinit.h::dmxInputDetachId" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxInputDetachId </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>id</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Search for input associated with <em>deviceId</em>, and detach. </td>
+ </tr>
+</table>
+<a class="anchor" name="a56" doxytag="dmxinputinit.h::dmxKeyboardBellProc" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxKeyboardBellProc </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>percent</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDevice</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>ctrl</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>unknown</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Sound the bell on the device. If the device send core events, then sound the bell on all of the devices that send core events. </td>
+ </tr>
+</table>
+<a class="anchor" name="a55" doxytag="dmxinputinit.h::dmxKeyboardKbdCtrlProc" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxKeyboardKbdCtrlProc </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDevice</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>KeybdCtrl *&nbsp;</td>
+ <td class="mdname" nowrap> <em>ctrl</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the keyboard control information for the <em>pDevice</em>. If the device sends core events, then also change the control information for all of the keyboard devices that send core events. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxlog_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxlog_8c.html
new file mode 100644
index 000000000..c32a4f9c9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxlog_8c.html
@@ -0,0 +1,602 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxlog.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxlog_8h-source.html">dmxlog.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxinput_8h-source.html">dmxinput.h</a>"</code><br>
+<code>#include "XI.h"</code><br>
+<code>#include "XIproto.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8c.html#a1">dmxSetLogLevel</a> (<a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a> newLevel)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8c.html#a2">dmxGetLogLevel</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8c.html#a3">AbortServer</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8c.html#a7">dmxLog</a> (<a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a> logLevel, const char *format,...)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8c.html#a8">dmxLogCont</a> (<a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a> logLevel, const char *format,...)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8c.html#a9">dmxLogOutput</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, const char *format,...)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8c.html#a10">dmxLogOutputCont</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, const char *format,...)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8c.html#a11">dmxLogOutputWarning</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, const char *format,...)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8c.html#a12">dmxLogInput</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput, const char *format,...)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8c.html#a13">dmxLogInputCont</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput, const char *format,...)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8c.html#a14">dmxLogArgs</a> (<a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a> logLevel, int argc, char **argv)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8c.html#a15">dmxLogVisual</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, XVisualInfo *vi, int defaultVisual)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>const char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8c.html#a16">dmxXInputEventName</a> (int type)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>const char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8c.html#a17">dmxEventName</a> (int type)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file encapsulated all of the logging functions that are used by DMX for informational, warning, and error messages.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a3" doxytag="dmxlog.c::AbortServer" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void AbortServer </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This function was removed between XFree86 4.3.0 and XFree86 4.4.0. </td>
+ </tr>
+</table>
+<a class="anchor" name="a17" doxytag="dmxlog.c::dmxEventName" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> const char* dmxEventName </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>type</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Translate an event <em>type</em> into a human-readable string. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxlog.c::dmxGetLogLevel" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a> dmxGetLogLevel </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Returns the log level set by <a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxlog.c::dmxLog" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLog </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>logLevel</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>...&nbsp;</td>
+ <td class="mdname" nowrap></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Log the specified message at the specified <em>logLevel</em>. <em>format</em> can be a printf-like format expression. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmxlog.c::dmxLogArgs" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLogArgs </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>logLevel</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>argc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char **&nbsp;</td>
+ <td class="mdname" nowrap> <em>argv</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Print <em>argc</em> messages, each describing an element in <em>argv</em>. This is maingly for debugging purposes. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxlog.c::dmxLogCont" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLogCont </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>logLevel</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>...&nbsp;</td>
+ <td class="mdname" nowrap></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Continue a log message without printing the message prefix. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxlog.c::dmxLogInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLogInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxInput</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>...&nbsp;</td>
+ <td class="mdname" nowrap></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Log an informational message (at level <a class="el" href="dmxlog_8h.html#a18a1">dmxInfo</a>) related to input. The message prefix will contain information from <em>dmxInput</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmxlog.c::dmxLogInputCont" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLogInputCont </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxInput</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>...&nbsp;</td>
+ <td class="mdname" nowrap></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Continue a message related to input without printing the message prefix. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxlog.c::dmxLogOutput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLogOutput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>...&nbsp;</td>
+ <td class="mdname" nowrap></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Log an informational message (at level <a class="el" href="dmxlog_8h.html#a18a1">dmxInfo</a>) related to ouput. The message prefix will contain backend information from <em>dmxScreen</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxlog.c::dmxLogOutputCont" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLogOutputCont </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>...&nbsp;</td>
+ <td class="mdname" nowrap></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Continue a message related to output without printing the message prefix. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxlog.c::dmxLogOutputWarning" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLogOutputWarning </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>...&nbsp;</td>
+ <td class="mdname" nowrap></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Log a warning message (at level <a class="el" href="dmxlog_8h.html#a18a2">dmxWarning</a>) related to output. The message prefix will contain backend information from <em>dmxScreen</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a15" doxytag="dmxlog.c::dmxLogVisual" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLogVisual </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>XVisualInfo *&nbsp;</td>
+ <td class="mdname" nowrap> <em>vi</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>defaultVisual</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Print messages at level <a class="el" href="dmxlog_8h.html#a18a1">dmxInfo</a> describing the visuals in <em>vi</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxlog.c::dmxSetLogLevel" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a> dmxSetLogLevel </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>newLevel</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set the default level for logging to <a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>. Returns the previous log level. </td>
+ </tr>
+</table>
+<a class="anchor" name="a16" doxytag="dmxlog.c::dmxXInputEventName" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> const char* dmxXInputEventName </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>type</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Translate a (normalized) XInput event <em>type</em> into a human-readable string. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxlog_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxlog_8h-source.html
new file mode 100644
index 000000000..a345bd809
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxlog_8h-source.html
@@ -0,0 +1,91 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxlog.h</h1><a href="dmxlog_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00039 <span class="preprocessor">#ifndef _DMXLOG_H_</span>
+00040 <span class="preprocessor"></span><span class="preprocessor">#define _DMXLOG_H_</span>
+00041 <span class="preprocessor"></span>
+<a name="l00043"></a><a class="code" href="dmxlog_8h.html#a18">00043</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> {
+00044 <a class="code" href="dmxlog_8h.html#a18a0">dmxDebug</a>,
+00045 <a class="code" href="dmxlog_8h.html#a18a1">dmxInfo</a>,
+00046 <a class="code" href="dmxlog_8h.html#a18a2">dmxWarning</a>,
+00049 <a class="code" href="dmxlog_8h.html#a18a3">dmxError</a>,
+00052 <a class="code" href="dmxlog_8h.html#a18a4">dmxFatal</a>
+00054 } <a class="code" href="dmxlog_8h.html#a18">dmxLogLevel</a>;
+00055
+00056 <span class="comment">/* Logging functions used by Xserver/hw/dmx routines. */</span>
+00057 <span class="keyword">extern</span> <a class="code" href="dmxlog_8h.html#a18">dmxLogLevel</a> <a class="code" href="dmxlog_8c.html#a1">dmxSetLogLevel</a>(dmxLogLevel newLevel);
+00058 <span class="keyword">extern</span> <a class="code" href="dmxlog_8h.html#a18">dmxLogLevel</a> <a class="code" href="dmxlog_8c.html#a2">dmxGetLogLevel</a>(<span class="keywordtype">void</span>);
+00059 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxlog_8c.html#a7">dmxLog</a>(dmxLogLevel logLevel, <span class="keyword">const</span> <span class="keywordtype">char</span> *format, ...);
+00060 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxlog_8c.html#a8">dmxLogCont</a>(dmxLogLevel logLevel, <span class="keyword">const</span> <span class="keywordtype">char</span> *format, ...);
+00061 <span class="keyword">extern</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="dmxlog_8c.html#a17">dmxEventName</a>(<span class="keywordtype">int</span> type);
+00062
+00063 <span class="preprocessor">#ifndef DMX_LOG_STANDALONE</span>
+00064 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxlog_8c.html#a9">dmxLogOutput</a>(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, <span class="keyword">const</span> <span class="keywordtype">char</span> *format, ...);
+00065 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxlog_8c.html#a10">dmxLogOutputCont</a>(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, <span class="keyword">const</span> <span class="keywordtype">char</span> *format,
+00066 ...);
+00067 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxlog_8c.html#a11">dmxLogOutputWarning</a>(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, <span class="keyword">const</span> <span class="keywordtype">char</span> *format,
+00068 ...);
+00069 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxlog_8c.html#a12">dmxLogInput</a>(<a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput, <span class="keyword">const</span> <span class="keywordtype">char</span> *format, ...);
+00070 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxlog_8c.html#a13">dmxLogInputCont</a>(<a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput, <span class="keyword">const</span> <span class="keywordtype">char</span> *format, ...);
+00071 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxlog_8c.html#a14">dmxLogArgs</a>(dmxLogLevel logLevel, <span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv);
+00072 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxlog_8c.html#a15">dmxLogVisual</a>(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, XVisualInfo *vi,
+00073 <span class="keywordtype">int</span> defaultVisual);
+00074 <span class="preprocessor">#ifdef XINPUT</span>
+00075 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="dmxlog_8c.html#a16">dmxXInputEventName</a>(<span class="keywordtype">int</span> type);
+00076 <span class="preprocessor">#endif</span>
+00077 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00078 <span class="preprocessor"></span>
+00079 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxlog_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxlog_8h.html
new file mode 100644
index 000000000..6092d1339
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxlog_8h.html
@@ -0,0 +1,616 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxlog.h File Reference</h1>
+<p>
+<a href="dmxlog_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Enumerations</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>enum &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a> { <br>
+&nbsp;&nbsp;<a class="el" href="dmxlog_8h.html#a18a0">dmxDebug</a>,
+<a class="el" href="dmxlog_8h.html#a18a1">dmxInfo</a>,
+<a class="el" href="dmxlog_8h.html#a18a2">dmxWarning</a>,
+<a class="el" href="dmxlog_8h.html#a18a3">dmxError</a>,
+<br>
+&nbsp;&nbsp;<a class="el" href="dmxlog_8h.html#a18a4">dmxFatal</a>
+<br>
+ }</td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8h.html#a5">dmxSetLogLevel</a> (<a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a> newLevel)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8h.html#a6">dmxGetLogLevel</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8h.html#a7">dmxLog</a> (<a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a> logLevel, const char *format,...)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8h.html#a8">dmxLogCont</a> (<a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a> logLevel, const char *format,...)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>const char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8h.html#a9">dmxEventName</a> (int type)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8h.html#a10">dmxLogOutput</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, const char *format,...)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8h.html#a11">dmxLogOutputCont</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, const char *format,...)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8h.html#a12">dmxLogOutputWarning</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, const char *format,...)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8h.html#a13">dmxLogInput</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput, const char *format,...)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8h.html#a14">dmxLogInputCont</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput, const char *format,...)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8h.html#a15">dmxLogArgs</a> (<a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a> logLevel, int argc, char **argv)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8h.html#a16">dmxLogVisual</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, XVisualInfo *vi, int defaultVisual)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>const char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxlog_8h.html#a17">dmxXInputEventName</a> (int type)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This header is included by all files that need to use the DMX logging facilities.<hr><h2>Enumeration Type Documentation</h2>
+<a class="anchor" name="a18" doxytag="dmxlog.h::dmxLogLevel" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> enum <a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Logging levels -- output is tunable with <a class="el" href="dmxlog_8h.html#a5">dmxSetLogLevel</a>. <dl compact><dt><b>Enumeration values: </b></dt><dd>
+<table border=0 cellspacing=2 cellpadding=0>
+<tr><td valign=top><em><a class="anchor" name="a18a0" doxytag="dmxDebug" ></a>dmxDebug</em>&nbsp;</td><td>
+Usually verbose debugging info </td></tr>
+<tr><td valign=top><em><a class="anchor" name="a18a1" doxytag="dmxInfo" ></a>dmxInfo</em>&nbsp;</td><td>
+Non-warning information </td></tr>
+<tr><td valign=top><em><a class="anchor" name="a18a2" doxytag="dmxWarning" ></a>dmxWarning</em>&nbsp;</td><td>
+A warning that may indicate DMX will not function as the user intends. </td></tr>
+<tr><td valign=top><em><a class="anchor" name="a18a3" doxytag="dmxError" ></a>dmxError</em>&nbsp;</td><td>
+A non-fatal error that probably indicates DMX will not function as desired. </td></tr>
+<tr><td valign=top><em><a class="anchor" name="a18a4" doxytag="dmxFatal" ></a>dmxFatal</em>&nbsp;</td><td>
+A fatal error that will cause DMX to shut down. </td></tr>
+</table>
+</dl>
+ </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a9" doxytag="dmxlog.h::dmxEventName" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> const char* dmxEventName </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>type</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Translate an event <em>type</em> into a human-readable string. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxlog.h::dmxGetLogLevel" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a> dmxGetLogLevel </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Returns the log level set by <a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxlog.h::dmxLog" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLog </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>logLevel</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>...&nbsp;</td>
+ <td class="mdname" nowrap></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Log the specified message at the specified <em>logLevel</em>. <em>format</em> can be a printf-like format expression. </td>
+ </tr>
+</table>
+<a class="anchor" name="a15" doxytag="dmxlog.h::dmxLogArgs" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLogArgs </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>logLevel</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>argc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char **&nbsp;</td>
+ <td class="mdname" nowrap> <em>argv</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Print <em>argc</em> messages, each describing an element in <em>argv</em>. This is maingly for debugging purposes. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxlog.h::dmxLogCont" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLogCont </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>logLevel</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>...&nbsp;</td>
+ <td class="mdname" nowrap></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Continue a log message without printing the message prefix. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmxlog.h::dmxLogInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLogInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxInput</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>...&nbsp;</td>
+ <td class="mdname" nowrap></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Log an informational message (at level <a class="el" href="dmxlog_8h.html#a18a1">dmxInfo</a>) related to input. The message prefix will contain information from <em>dmxInput</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmxlog.h::dmxLogInputCont" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLogInputCont </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxInput</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>...&nbsp;</td>
+ <td class="mdname" nowrap></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Continue a message related to input without printing the message prefix. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxlog.h::dmxLogOutput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLogOutput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>...&nbsp;</td>
+ <td class="mdname" nowrap></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Log an informational message (at level <a class="el" href="dmxlog_8h.html#a18a1">dmxInfo</a>) related to ouput. The message prefix will contain backend information from <em>dmxScreen</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxlog.h::dmxLogOutputCont" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLogOutputCont </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>...&nbsp;</td>
+ <td class="mdname" nowrap></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Continue a message related to output without printing the message prefix. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxlog.h::dmxLogOutputWarning" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLogOutputWarning </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>...&nbsp;</td>
+ <td class="mdname" nowrap></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Log a warning message (at level <a class="el" href="dmxlog_8h.html#a18a2">dmxWarning</a>) related to output. The message prefix will contain backend information from <em>dmxScreen</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a16" doxytag="dmxlog.h::dmxLogVisual" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxLogVisual </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>XVisualInfo *&nbsp;</td>
+ <td class="mdname" nowrap> <em>vi</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>defaultVisual</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Print messages at level <a class="el" href="dmxlog_8h.html#a18a1">dmxInfo</a> describing the visuals in <em>vi</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxlog.h::dmxSetLogLevel" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a> dmxSetLogLevel </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>newLevel</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set the default level for logging to <a class="el" href="dmxlog_8h.html#a18">dmxLogLevel</a>. Returns the previous log level. </td>
+ </tr>
+</table>
+<a class="anchor" name="a17" doxytag="dmxlog.h::dmxXInputEventName" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> const char* dmxXInputEventName </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>type</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Translate a (normalized) XInput event <em>type</em> into a human-readable string. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmap_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmap_8c.html
new file mode 100644
index 000000000..b4230ca30
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmap_8c.html
@@ -0,0 +1,150 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxmap.c File Reference</h1><code>#include "<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxmap_8h-source.html">dmxmap.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxmap_8c.html#a0">dmxMapInsert</a> (<a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> dmxLocal, int remoteEvent, int serverEvent)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxmap_8c.html#a1">dmxMapClear</a> (<a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> dmxLocal)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxmap_8c.html#a2">dmxMapLookup</a> (<a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> dmxLocal, int remoteEvent)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file implements a mapping from remote XInput event types to Xdmx XInput event types.<p>
+The exglobals.h file defines global server-side variables with names Device* to be integers that hold the value of the type of the server-side XInput extension event.<p>
+The client-side X11/extensions/XInput.h file defines macros with THE EXACT SAME Device* names!<p>
+Using those macros to extract remote server event type values from the (opaque) XDevice structure is appropriate, but makes a direct mapping to the Device* integers impossible. So we use the normalized XI_Device* names for these routines.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a1" doxytag="dmxmap.c::dmxMapClear" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxMapClear </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a>&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxLocal</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Remove all mappings there were inserted with <a class="el" href="dmxmap_8h.html#a0">dmxMapInsert</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxmap.c::dmxMapInsert" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxMapInsert </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxLocal</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>remoteEvent</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>serverEvent</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a mapping from <em>remoteEvent</em> to <em>serverEvent</em>. The <em>remoteEvent</em> is the type returned from the remote server. The <em>serverEvent</em> is from the XI_* list of events in include/extensions/XIproto.h. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxmap.c::dmxMapLookup" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxMapLookup </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxLocal</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>remoteEvent</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Lookup a mapping for <em>remoteEvent</em>. The <em>remoteEvent</em> is the type returned from the remote server. The return value is that which was passed into <a class="el" href="dmxmap_8h.html#a0">dmxMapInsert</a> (i.e., a value from the XI_* list in include/extensions/XIproto.h). If a mapping is not available, -1 is returned. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmap_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmap_8h-source.html
new file mode 100644
index 000000000..8a9d6b31c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmap_8h-source.html
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxmap.h</h1><a href="dmxmap_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2003 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> */</span>
+00033
+00037 <span class="preprocessor">#ifndef _DMXMAP_H_</span>
+00038 <span class="preprocessor"></span><span class="preprocessor">#define _DMXMAP_H_</span>
+00039 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxmap_8c.html#a0">dmxMapInsert</a>(<a class="code" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> dmxLocal,
+00040 <span class="keywordtype">int</span> remoteEvent, <span class="keywordtype">int</span> serverEvent);
+00041 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxmap_8c.html#a1">dmxMapClear</a>(<a class="code" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> dmxLocal);
+00042 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxmap_8c.html#a2">dmxMapLookup</a>(<a class="code" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> dmxLocal, <span class="keywordtype">int</span> remoteEvent);
+00043 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmap_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmap_8h.html
new file mode 100644
index 000000000..db69ac6b2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmap_8h.html
@@ -0,0 +1,148 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxmap.h File Reference</h1>
+<p>
+<a href="dmxmap_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxmap_8h.html#a0">dmxMapInsert</a> (<a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> dmxLocal, int remoteEvent, int serverEvent)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxmap_8h.html#a1">dmxMapClear</a> (<a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> dmxLocal)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxmap_8h.html#a2">dmxMapLookup</a> (<a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> dmxLocal, int remoteEvent)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to XInput event mapping support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxmap_8c.html">dmxmap.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a1" doxytag="dmxmap.h::dmxMapClear" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxMapClear </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a>&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxLocal</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Remove all mappings there were inserted with <a class="el" href="dmxmap_8h.html#a0">dmxMapInsert</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxmap.h::dmxMapInsert" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxMapInsert </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxLocal</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>remoteEvent</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>serverEvent</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a mapping from <em>remoteEvent</em> to <em>serverEvent</em>. The <em>remoteEvent</em> is the type returned from the remote server. The <em>serverEvent</em> is from the XI_* list of events in include/extensions/XIproto.h. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxmap.h::dmxMapLookup" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxMapLookup </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxLocal</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>remoteEvent</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Lookup a mapping for <em>remoteEvent</em>. The <em>remoteEvent</em> is the type returned from the remote server. The return value is that which was passed into <a class="el" href="dmxmap_8h.html#a0">dmxMapInsert</a> (i.e., a value from the XI_* list in include/extensions/XIproto.h). If a mapping is not available, -1 is returned. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmotion_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmotion_8c.html
new file mode 100644
index 000000000..ecf9922a6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmotion_8c.html
@@ -0,0 +1,181 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxmotion.c File Reference</h1><code>#include "inputstr.h"</code><br>
+<code>#include "<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcommon_8h-source.html">dmxcommon.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxmotion_8h-source.html">dmxmotion.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxmotion_8c.html#a1">dmxPointerGetMotionBufferSize</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxmotion_8c.html#a2">dmxPointerGetMotionEvents</a> (DeviceIntPtr pDevice, xTimecoord *coords, unsigned long start, unsigned long stop, ScreenPtr pScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxmotion_8c.html#a3">dmxPointerPutMotionEvent</a> (DeviceIntPtr pDevice, int firstAxis, int axesCount, int *v, unsigned long time)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides functions similar to miPointerGetMotionEvents and miPointerPutMotionEvents, with the exception that devices with more than two axes are fully supported. These routines may be used only for motion buffers for extension devices, and are <em>not</em> compatible replacements for the mi routines.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a1" doxytag="dmxmotion.c::dmxPointerGetMotionBufferSize" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxPointerGetMotionBufferSize </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return size of motion buffer. <dl compact><dt><b>See also:</b></dt><dd>DMX_MOTION_SIZE </dd></dl>
+ </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxmotion.c::dmxPointerGetMotionEvents" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxPointerGetMotionEvents </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDevice</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xTimecoord *&nbsp;</td>
+ <td class="mdname" nowrap> <em>coords</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>start</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>stop</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine performs the same function as <em>miPointerGetMotionEvents</em>: the events in the motion history that are between the start and stop times (in mS) are placed in the coords vector, and the count of the number of items so placed is returned. This routine is called from dix/devices.c so that coords can hold valuator-&gt;numMotionEvents events. This routine is called from <em>Xi/gtmotion</em>.c with coords large enough to hold the same number of events in a variable-length extended <em>xTimecoord</em> structure. This provides sufficient data for the <em>XGetDeviceMotionEvents</em> library call, and would be identical to <em>miPointerGetMotionEvents</em> for devices with only 2 axes (i.e., core pointers) if <em>xTimecoord</em> used 32bit integers.<p>
+Because DMX uses the mi* routines for all core devices, this routine only has to support extension devices using the polymorphic coords. Because compatibility with miPointerGetMotionEvents is not possible, it is not provided. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxmotion.c::dmxPointerPutMotionEvent" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPointerPutMotionEvent </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDevice</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>firstAxis</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>axesCount</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>v</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>time</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine adds an event to the motion history. A similar function is performed by miPointerMove for the mi versions of these routines. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmotion_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmotion_8h-source.html
new file mode 100644
index 000000000..1057b7ebb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmotion_8h-source.html
@@ -0,0 +1,69 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxmotion.h</h1><a href="dmxmotion_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _DMXMOTION_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _DMXMOTION_H_</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxmotion_8c.html#a1">dmxPointerGetMotionBufferSize</a>(<span class="keywordtype">void</span>);
+00042 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxmotion_8c.html#a2">dmxPointerGetMotionEvents</a>(DeviceIntPtr pDevice,
+00043 xTimecoord *coords,
+00044 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> start,
+00045 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> stop,
+00046 ScreenPtr pScreen);
+00047 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxmotion_8c.html#a3">dmxPointerPutMotionEvent</a>(DeviceIntPtr pDevice,
+00048 <span class="keywordtype">int</span> firstAxis, <span class="keywordtype">int</span> axesCount, <span class="keywordtype">int</span> *v,
+00049 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> time);
+00050 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmotion_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmotion_8h.html
new file mode 100644
index 000000000..f3f4bedc4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmotion_8h.html
@@ -0,0 +1,180 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxmotion.h File Reference</h1>
+<p>
+<a href="dmxmotion_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxmotion_8h.html#a0">dmxPointerGetMotionBufferSize</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxmotion_8h.html#a1">dmxPointerGetMotionEvents</a> (DeviceIntPtr pDevice, xTimecoord *coords, unsigned long start, unsigned long stop, ScreenPtr pScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxmotion_8h.html#a2">dmxPointerPutMotionEvent</a> (DeviceIntPtr pDevice, int firstAxis, int axesCount, int *v, unsigned long time)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to functions supporting motion events. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxmotion_8c.html">dmxmotion.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxmotion.h::dmxPointerGetMotionBufferSize" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxPointerGetMotionBufferSize </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return size of motion buffer. <dl compact><dt><b>See also:</b></dt><dd>DMX_MOTION_SIZE </dd></dl>
+ </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxmotion.h::dmxPointerGetMotionEvents" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxPointerGetMotionEvents </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDevice</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xTimecoord *&nbsp;</td>
+ <td class="mdname" nowrap> <em>coords</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>start</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>stop</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine performs the same function as <em>miPointerGetMotionEvents</em>: the events in the motion history that are between the start and stop times (in mS) are placed in the coords vector, and the count of the number of items so placed is returned. This routine is called from dix/devices.c so that coords can hold valuator-&gt;numMotionEvents events. This routine is called from <em>Xi/gtmotion</em>.c with coords large enough to hold the same number of events in a variable-length extended <em>xTimecoord</em> structure. This provides sufficient data for the <em>XGetDeviceMotionEvents</em> library call, and would be identical to <em>miPointerGetMotionEvents</em> for devices with only 2 axes (i.e., core pointers) if <em>xTimecoord</em> used 32bit integers.<p>
+Because DMX uses the mi* routines for all core devices, this routine only has to support extension devices using the polymorphic coords. Because compatibility with miPointerGetMotionEvents is not possible, it is not provided. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxmotion.h::dmxPointerPutMotionEvent" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPointerPutMotionEvent </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDevice</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>firstAxis</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>axesCount</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>v</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>time</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This routine adds an event to the motion history. A similar function is performed by miPointerMove for the mi versions of these routines. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxparse_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxparse_8c.html
new file mode 100644
index 000000000..c984dd9f5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxparse_8c.html
@@ -0,0 +1,74 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxparse.c File Reference</h1><code>#include &lt;stdio.h&gt;</code><br>
+<code>#include &lt;stdlib.h&gt;</code><br>
+<code>#include &lt;string.h&gt;</code><br>
+<code>#include &lt;stdarg.h&gt;</code><br>
+<code>#include "<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8c.html#a0">dmxConfigLog</a> (const char *format,...)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides support routines and helper functions to be used by the DMX configuration file parser.<p>
+Because the DMX configuration file parsing should be capable of being used in a stand-alone fashion (i.e., independent from the DMX server source tree), no dependencies on other DMX routines are made.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxparse.c::dmxConfigLog" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigLog </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>...&nbsp;</td>
+ <td class="mdname" nowrap></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+A general error logging routine that does not depend on the dmxLog functions. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxparse_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxparse_8h-source.html
new file mode 100644
index 000000000..c88da9089
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxparse_8h-source.html
@@ -0,0 +1,303 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxparse.h</h1><a href="dmxparse_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _DMXPARSE_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _DMXPARSE_H_</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="preprocessor">#include &lt;stdio.h&gt;</span> <span class="comment">/* For FILE */</span>
+00042
+<a name="l00044"></a><a class="code" href="struct__DMXConfigToken.html">00044</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXConfigToken.html">_DMXConfigToken</a> {
+00045 <span class="keywordtype">int</span> token;
+00046 <span class="keywordtype">int</span> line;
+00047 <span class="keyword">const</span> <span class="keywordtype">char</span> *comment;
+00048 } <a class="code" href="struct__DMXConfigToken.html">DMXConfigToken</a>, *<a class="code" href="struct__DMXConfigToken.html">DMXConfigTokenPtr</a>;
+00049
+<a name="l00051"></a><a class="code" href="struct__DMXConfigString.html">00051</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXConfigString.html">_DMXConfigString</a> {
+00052 <span class="keywordtype">int</span> token;
+00053 <span class="keywordtype">int</span> line;
+00054 <span class="keyword">const</span> <span class="keywordtype">char</span> *comment;
+00055 <span class="keyword">const</span> <span class="keywordtype">char</span> *string;
+00056 <span class="keyword">struct </span><a class="code" href="struct__DMXConfigString.html">_DMXConfigString</a> *next;
+00057 } <a class="code" href="struct__DMXConfigString.html">DMXConfigString</a>, *<a class="code" href="struct__DMXConfigString.html">DMXConfigStringPtr</a>;
+00058
+<a name="l00060"></a><a class="code" href="struct__DMXConfigNumber.html">00060</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXConfigNumber.html">_DMXConfigNumber</a> {
+00061 <span class="keywordtype">int</span> token;
+00062 <span class="keywordtype">int</span> line;
+00063 <span class="keyword">const</span> <span class="keywordtype">char</span> *comment;
+00064 <span class="keywordtype">int</span> number;
+00065 } <a class="code" href="struct__DMXConfigNumber.html">DMXConfigNumber</a>, *<a class="code" href="struct__DMXConfigNumber.html">DMXConfigNumberPtr</a>;
+00066
+<a name="l00068"></a><a class="code" href="struct__DMXConfigPair.html">00068</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXConfigPair.html">_DMXConfigPair</a> {
+00069 <span class="keywordtype">int</span> token;
+00070 <span class="keywordtype">int</span> line;
+00071 <span class="keyword">const</span> <span class="keywordtype">char</span> *comment;
+00072 <span class="keywordtype">int</span> x;
+00073 <span class="keywordtype">int</span> y;
+00074 <span class="keywordtype">int</span> xsign;
+00075 <span class="keywordtype">int</span> ysign;
+00076 } <a class="code" href="struct__DMXConfigPair.html">DMXConfigPair</a>, *<a class="code" href="struct__DMXConfigPair.html">DMXConfigPairPtr</a>;
+00077
+<a name="l00079"></a><a class="code" href="struct__DMXConfigComment.html">00079</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXConfigComment.html">_DMXConfigComment</a> {
+00080 <span class="keywordtype">int</span> token;
+00081 <span class="keywordtype">int</span> line;
+00082 <span class="keyword">const</span> <span class="keywordtype">char</span> *comment;
+00083 } <a class="code" href="struct__DMXConfigComment.html">DMXConfigComment</a>, *<a class="code" href="struct__DMXConfigComment.html">DMXConfigCommentPtr</a>;
+00084
+00085 <span class="keyword">typedef</span> <span class="keyword">enum</span> {
+00086 dmxConfigComment,
+00087 dmxConfigVirtual,
+00088 dmxConfigDisplay,
+00089 dmxConfigWall,
+00090 dmxConfigOption,
+00091 dmxConfigParam
+00092 } DMXConfigType;
+00093
+<a name="l00095"></a><a class="code" href="struct__DMXConfigPartDim.html">00095</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXConfigPartDim.html">_DMXConfigPartDim</a> {
+00096 <a class="code" href="dmxparse_8h.html#a7">DMXConfigPairPtr</a> dim;
+00097 <a class="code" href="dmxparse_8h.html#a7">DMXConfigPairPtr</a> offset;
+00098 } <a class="code" href="struct__DMXConfigPartDim.html">DMXConfigPartDim</a>, *<a class="code" href="struct__DMXConfigPartDim.html">DMXConfigPartDimPtr</a>;
+00099
+<a name="l00101"></a><a class="code" href="struct__DMXConfigFullDim.html">00101</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXConfigFullDim.html">_DMXConfigFullDim</a> {
+00102 <a class="code" href="dmxparse_8h.html#a11">DMXConfigPartDimPtr</a> scrn;
+00103 <a class="code" href="dmxparse_8h.html#a11">DMXConfigPartDimPtr</a> root;
+00104 } <a class="code" href="struct__DMXConfigFullDim.html">DMXConfigFullDim</a>, *<a class="code" href="struct__DMXConfigFullDim.html">DMXConfigFullDimPtr</a>;
+00105
+<a name="l00107"></a><a class="code" href="struct__DMXConfigDisplay.html">00107</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXConfigDisplay.html">_DMXConfigDisplay</a> {
+00108 <span class="comment">/* Summary information */</span>
+00109 <span class="keyword">const</span> <span class="keywordtype">char</span> *name;
+00110 <span class="comment">/* Screen Window Geometry */</span>
+00111 <span class="keywordtype">int</span> scrnWidth, scrnHeight;
+00112 <span class="keywordtype">int</span> scrnX, scrnY;
+00113 <span class="keywordtype">int</span> scrnXSign, scrnYSign;
+00114 <span class="comment">/* Root Window Geometry */</span>
+00115 <span class="keywordtype">int</span> rootWidth, rootHeight;
+00116 <span class="keywordtype">int</span> rootX, rootY;
+00117 <span class="keywordtype">int</span> rootXSign, rootYSign;
+00118 <span class="comment">/* Origin in global space */</span>
+00119 <span class="keywordtype">int</span> rootXOrigin, rootYOrigin;
+00120
+00121 <span class="comment">/* Raw configuration information */</span>
+00122 <a class="code" href="dmxparse_8h.html#a1">DMXConfigTokenPtr</a> start;
+00123 <a class="code" href="dmxparse_8h.html#a3">DMXConfigStringPtr</a> dname;
+00124 <a class="code" href="dmxparse_8h.html#a13">DMXConfigFullDimPtr</a> dim;
+00125 <a class="code" href="dmxparse_8h.html#a7">DMXConfigPairPtr</a> origin;
+00126 <a class="code" href="dmxparse_8h.html#a1">DMXConfigTokenPtr</a> end;
+00127 } <a class="code" href="struct__DMXConfigDisplay.html">DMXConfigDisplay</a>, *<a class="code" href="struct__DMXConfigDisplay.html">DMXConfigDisplayPtr</a>;
+00128
+<a name="l00130"></a><a class="code" href="struct__DMXConfigWall.html">00130</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXConfigWall.html">_DMXConfigWall</a> {
+00131 <span class="comment">/* Summary information */</span>
+00132 <span class="keywordtype">int</span> width, height; <span class="comment">/* dimensions of displays */</span>
+00133 <span class="keywordtype">int</span> xwall, ywall; <span class="comment">/* dimensions of wall, in tiles */</span>
+00134
+00135
+00136 <span class="comment">/* Raw configuration informaiton */</span>
+00137 <a class="code" href="dmxparse_8h.html#a1">DMXConfigTokenPtr</a> start;
+00138 <a class="code" href="dmxparse_8h.html#a7">DMXConfigPairPtr</a> wallDim;
+00139 <a class="code" href="dmxparse_8h.html#a7">DMXConfigPairPtr</a> displayDim;
+00140 <a class="code" href="dmxparse_8h.html#a3">DMXConfigStringPtr</a> nameList;
+00141 <a class="code" href="dmxparse_8h.html#a1">DMXConfigTokenPtr</a> end;
+00142 } <a class="code" href="struct__DMXConfigWall.html">DMXConfigWall</a>, *<a class="code" href="struct__DMXConfigWall.html">DMXConfigWallPtr</a>;
+00143
+<a name="l00145"></a><a class="code" href="struct__DMXConfigOption.html">00145</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXConfigOption.html">_DMXConfigOption</a> {
+00146 <span class="comment">/* Summary information */</span>
+00147 <span class="keywordtype">char</span> *string;
+00148
+00149 <span class="comment">/* Raw configuration informaiton */</span>
+00150 <a class="code" href="dmxparse_8h.html#a1">DMXConfigTokenPtr</a> start;
+00151 <a class="code" href="dmxparse_8h.html#a3">DMXConfigStringPtr</a> option;
+00152 <a class="code" href="dmxparse_8h.html#a1">DMXConfigTokenPtr</a> end;
+00153 } <a class="code" href="struct__DMXConfigOption.html">DMXConfigOption</a>, *<a class="code" href="struct__DMXConfigOption.html">DMXConfigOptionPtr</a>;
+00154
+<a name="l00156"></a><a class="code" href="struct__DMXConfigParam.html">00156</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXConfigParam.html">_DMXConfigParam</a> {
+00157 <span class="keywordtype">int</span> argc;
+00158 <span class="keyword">const</span> <span class="keywordtype">char</span> **argv;
+00159
+00160 <a class="code" href="dmxparse_8h.html#a1">DMXConfigTokenPtr</a> start;
+00161 <a class="code" href="dmxparse_8h.html#a1">DMXConfigTokenPtr</a> open;
+00162 <a class="code" href="dmxparse_8h.html#a3">DMXConfigStringPtr</a> param;
+00163 <a class="code" href="dmxparse_8h.html#a1">DMXConfigTokenPtr</a> close;
+00164 <a class="code" href="dmxparse_8h.html#a1">DMXConfigTokenPtr</a> end; <span class="comment">/* Either open/close OR end */</span>
+00165 <span class="keyword">struct </span><a class="code" href="struct__DMXConfigParam.html">_DMXConfigParam</a> *next;
+00166 } <a class="code" href="struct__DMXConfigParam.html">DMXConfigParam</a>, *<a class="code" href="struct__DMXConfigParam.html">DMXConfigParamPtr</a>;
+00167
+<a name="l00169"></a><a class="code" href="struct__DMXConfigSub.html">00169</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXConfigSub.html">_DMXConfigSub</a> {
+00170 DMXConfigType type;
+00171 <a class="code" href="dmxparse_8h.html#a9">DMXConfigCommentPtr</a> comment;
+00172 <a class="code" href="dmxparse_8h.html#a15">DMXConfigDisplayPtr</a> display;
+00173 <a class="code" href="dmxparse_8h.html#a17">DMXConfigWallPtr</a> wall;
+00174 <a class="code" href="dmxparse_8h.html#a19">DMXConfigOptionPtr</a> option;
+00175 <a class="code" href="dmxparse_8h.html#a21">DMXConfigParamPtr</a> param;
+00176 <span class="keyword">struct </span><a class="code" href="struct__DMXConfigSub.html">_DMXConfigSub</a> *next;
+00177 } <a class="code" href="struct__DMXConfigSub.html">DMXConfigSub</a>, *<a class="code" href="struct__DMXConfigSub.html">DMXConfigSubPtr</a>;
+00178
+<a name="l00180"></a><a class="code" href="struct__DMXConfigVirtual.html">00180</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXConfigVirtual.html">_DMXConfigVirtual</a> {
+00181 <span class="comment">/* Summary information */</span>
+00182 <span class="keyword">const</span> <span class="keywordtype">char</span> *name;
+00183 <span class="keywordtype">int</span> width, height;
+00184
+00185 <span class="comment">/* Raw configuration information */</span>
+00186 <a class="code" href="dmxparse_8h.html#a1">DMXConfigTokenPtr</a> start;
+00187 <a class="code" href="dmxparse_8h.html#a3">DMXConfigStringPtr</a> vname;
+00188 <a class="code" href="dmxparse_8h.html#a7">DMXConfigPairPtr</a> dim;
+00189 <a class="code" href="dmxparse_8h.html#a1">DMXConfigTokenPtr</a> open;
+00190 <a class="code" href="dmxparse_8h.html#a23">DMXConfigSubPtr</a> subentry;
+00191 <a class="code" href="dmxparse_8h.html#a1">DMXConfigTokenPtr</a> close;
+00192 } <a class="code" href="struct__DMXConfigVirtual.html">DMXConfigVirtual</a>, *<a class="code" href="struct__DMXConfigVirtual.html">DMXConfigVirtualPtr</a>;
+00193
+<a name="l00195"></a><a class="code" href="struct__DMXConfigEntry.html">00195</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__DMXConfigEntry.html">_DMXConfigEntry</a> {
+00196 DMXConfigType type;
+00197 <a class="code" href="dmxparse_8h.html#a9">DMXConfigCommentPtr</a> comment;
+00198 <a class="code" href="dmxparse_8h.html#a25">DMXConfigVirtualPtr</a> <span class="keyword">virtual</span>;
+00199 <span class="keyword">struct </span><a class="code" href="struct__DMXConfigEntry.html">_DMXConfigEntry</a> *next;
+00200 } <a class="code" href="struct__DMXConfigEntry.html">DMXConfigEntry</a>, *<a class="code" href="struct__DMXConfigEntry.html">DMXConfigEntryPtr</a>;
+00201
+00202 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a27">DMXConfigEntryPtr</a> dmxConfigEntry;
+00203
+00204 <span class="keyword">extern</span> <span class="keywordtype">int</span> yylex(<span class="keywordtype">void</span>);
+00205 <span class="keyword">extern</span> <span class="keywordtype">int</span> yydebug;
+00206 <span class="keyword">extern</span> <span class="keywordtype">void</span> yyerror(<span class="keyword">const</span> <span class="keywordtype">char</span> *message);
+00207
+00208 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxparse_8c.html#a0">dmxConfigLog</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *format, ...);
+00209 <span class="keyword">extern</span> <span class="keywordtype">void</span> *dmxConfigAlloc(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> bytes);
+00210 <span class="keyword">extern</span> <span class="keywordtype">void</span> *dmxConfigRealloc(<span class="keywordtype">void</span> *orig,
+00211 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> orig_bytes,
+00212 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> bytes);
+00213 <span class="keyword">extern</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *dmxConfigCopyString(<span class="keyword">const</span> <span class="keywordtype">char</span> *string,
+00214 <span class="keywordtype">int</span> length);
+00215 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigFree(<span class="keywordtype">void</span> *area);
+00216 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a1">DMXConfigTokenPtr</a> dmxConfigCreateToken(<span class="keywordtype">int</span> token, <span class="keywordtype">int</span> line,
+00217 <span class="keyword">const</span> <span class="keywordtype">char</span> *comment);
+00218 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigFreeToken(DMXConfigTokenPtr p);
+00219 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a3">DMXConfigStringPtr</a> dmxConfigCreateString(<span class="keywordtype">int</span> token, <span class="keywordtype">int</span> line,
+00220 <span class="keyword">const</span> <span class="keywordtype">char</span> *comment,
+00221 <span class="keyword">const</span> <span class="keywordtype">char</span> *string);
+00222 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigFreeString(DMXConfigStringPtr p);
+00223 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a5">DMXConfigNumberPtr</a> dmxConfigCreateNumber(<span class="keywordtype">int</span> token, <span class="keywordtype">int</span> line,
+00224 <span class="keyword">const</span> <span class="keywordtype">char</span> *comment,
+00225 <span class="keywordtype">int</span> number);
+00226 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigFreeNumber(DMXConfigNumberPtr p);
+00227 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a7">DMXConfigPairPtr</a> dmxConfigCreatePair(<span class="keywordtype">int</span> token, <span class="keywordtype">int</span> line,
+00228 <span class="keyword">const</span> <span class="keywordtype">char</span> *comment,
+00229 <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y,
+00230 <span class="keywordtype">int</span> xsign, <span class="keywordtype">int</span> ysign);
+00231 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigFreePair(DMXConfigPairPtr p);
+00232 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a9">DMXConfigCommentPtr</a> dmxConfigCreateComment(<span class="keywordtype">int</span> token, <span class="keywordtype">int</span> line,
+00233 <span class="keyword">const</span> <span class="keywordtype">char</span> *comment);
+00234 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigFreeComment(DMXConfigCommentPtr p);
+00235 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a11">DMXConfigPartDimPtr</a> dmxConfigCreatePartDim(DMXConfigPairPtr pDim,
+00236 DMXConfigPairPtr pOffset);
+00237 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigFreePartDim(DMXConfigPartDimPtr p);
+00238 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a13">DMXConfigFullDimPtr</a> dmxConfigCreateFullDim(DMXConfigPartDimPtr pScrn,
+00239 DMXConfigPartDimPtr pRoot);
+00240 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigFreeFullDim(DMXConfigFullDimPtr p);
+00241 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a15">DMXConfigDisplayPtr</a> dmxConfigCreateDisplay(DMXConfigTokenPtr pStart,
+00242 DMXConfigStringPtr pName,
+00243 DMXConfigFullDimPtr pDim,
+00244 DMXConfigPairPtr pOrigin,
+00245 DMXConfigTokenPtr pEnd);
+00246 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigFreeDisplay(DMXConfigDisplayPtr p);
+00247 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a17">DMXConfigWallPtr</a> dmxConfigCreateWall(DMXConfigTokenPtr pStart,
+00248 DMXConfigPairPtr pWallDim,
+00249 DMXConfigPairPtr pDisplayDim,
+00250 DMXConfigStringPtr pNameList,
+00251 DMXConfigTokenPtr pEnd);
+00252 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigFreeWall(DMXConfigWallPtr p);
+00253 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a19">DMXConfigOptionPtr</a> dmxConfigCreateOption(DMXConfigTokenPtr pStart,
+00254 DMXConfigStringPtr pOption,
+00255 DMXConfigTokenPtr pEnd);
+00256 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigFreeOption(DMXConfigOptionPtr p);
+00257 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a21">DMXConfigParamPtr</a> dmxConfigCreateParam(DMXConfigTokenPtr pStart,
+00258 DMXConfigTokenPtr pOpen,
+00259 DMXConfigStringPtr pParam,
+00260 DMXConfigTokenPtr pClose,
+00261 DMXConfigTokenPtr pEnd);
+00262 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigFreeParam(DMXConfigParamPtr p);
+00263 <span class="keyword">extern</span> <span class="keyword">const</span> <span class="keywordtype">char</span> **dmxConfigLookupParam(DMXConfigParamPtr p,
+00264 <span class="keyword">const</span> <span class="keywordtype">char</span> *key,
+00265 <span class="keywordtype">int</span> *argc);
+00266 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a23">DMXConfigSubPtr</a> dmxConfigCreateSub(DMXConfigType type,
+00267 DMXConfigCommentPtr comment,
+00268 DMXConfigDisplayPtr display,
+00269 DMXConfigWallPtr wall,
+00270 DMXConfigOptionPtr option,
+00271 DMXConfigParamPtr param);
+00272 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigFreeSub(DMXConfigSubPtr sub);
+00273 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a23">DMXConfigSubPtr</a> dmxConfigSubComment(DMXConfigCommentPtr comment);
+00274 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a23">DMXConfigSubPtr</a> dmxConfigSubDisplay(DMXConfigDisplayPtr display);
+00275 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a23">DMXConfigSubPtr</a> dmxConfigSubWall(DMXConfigWallPtr wall);
+00276 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a23">DMXConfigSubPtr</a> dmxConfigSubOption(DMXConfigOptionPtr option);
+00277 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a23">DMXConfigSubPtr</a> dmxConfigSubParam(DMXConfigParamPtr param);
+00278 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a23">DMXConfigSubPtr</a> dmxConfigAddSub(DMXConfigSubPtr head,
+00279 DMXConfigSubPtr sub);
+00280 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a25">DMXConfigVirtualPtr</a> dmxConfigCreateVirtual(DMXConfigTokenPtr pStart,
+00281 DMXConfigStringPtr pName,
+00282 DMXConfigPairPtr pDim,
+00283 DMXConfigTokenPtr pOpen,
+00284 DMXConfigSubPtr pSubentry,
+00285 DMXConfigTokenPtr pClose);
+00286 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigFreeVirtual(DMXConfigVirtualPtr <span class="keyword">virtual</span>);
+00287 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a27">DMXConfigEntryPtr</a> dmxConfigCreateEntry(DMXConfigType type,
+00288 DMXConfigCommentPtr comment,
+00289 DMXConfigVirtualPtr <span class="keyword">virtual</span>);
+00290 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxConfigFreeEntry(DMXConfigEntryPtr entry);
+00291 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a27">DMXConfigEntryPtr</a> dmxConfigAddEntry(DMXConfigEntryPtr head,
+00292 DMXConfigType type,
+00293 DMXConfigCommentPtr comment,
+00294 DMXConfigVirtualPtr <span class="keyword">virtual</span>);
+00295 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a27">DMXConfigEntryPtr</a> dmxConfigEntryComment(DMXConfigCommentPtr comment);
+00296 <span class="keyword">extern</span> <a class="code" href="dmxparse_8h.html#a27">DMXConfigEntryPtr</a> dmxConfigEntryVirtual(DMXConfigVirtualPtr <span class="keyword">virtual</span>);
+00297
+00298 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxparse_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxparse_8h.html
new file mode 100644
index 000000000..410075337
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxparse_8h.html
@@ -0,0 +1,775 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxparse.h File Reference</h1><code>#include &lt;stdio.h&gt;</code><br>
+
+<p>
+<a href="dmxparse_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXConfigComment.html">_DMXConfigComment</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXConfigDisplay.html">_DMXConfigDisplay</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXConfigEntry.html">_DMXConfigEntry</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXConfigFullDim.html">_DMXConfigFullDim</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXConfigNumber.html">_DMXConfigNumber</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXConfigOption.html">_DMXConfigOption</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXConfigPair.html">_DMXConfigPair</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXConfigParam.html">_DMXConfigParam</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXConfigPartDim.html">_DMXConfigPartDim</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXConfigString.html">_DMXConfigString</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXConfigSub.html">_DMXConfigSub</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXConfigToken.html">_DMXConfigToken</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXConfigVirtual.html">_DMXConfigVirtual</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXConfigWall.html">_DMXConfigWall</a></td></tr>
+
+<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigToken.html">_DMXConfigToken</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a0">DMXConfigToken</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigToken.html">_DMXConfigToken</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a1">DMXConfigTokenPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigString.html">_DMXConfigString</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a2">DMXConfigString</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigString.html">_DMXConfigString</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a3">DMXConfigStringPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigNumber.html">_DMXConfigNumber</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a4">DMXConfigNumber</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigNumber.html">_DMXConfigNumber</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a5">DMXConfigNumberPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigPair.html">_DMXConfigPair</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a6">DMXConfigPair</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigPair.html">_DMXConfigPair</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a7">DMXConfigPairPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigComment.html">_DMXConfigComment</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a8">DMXConfigComment</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigComment.html">_DMXConfigComment</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a9">DMXConfigCommentPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigPartDim.html">_DMXConfigPartDim</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a10">DMXConfigPartDim</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigPartDim.html">_DMXConfigPartDim</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a11">DMXConfigPartDimPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigFullDim.html">_DMXConfigFullDim</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a12">DMXConfigFullDim</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigFullDim.html">_DMXConfigFullDim</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a13">DMXConfigFullDimPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigDisplay.html">_DMXConfigDisplay</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a14">DMXConfigDisplay</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigDisplay.html">_DMXConfigDisplay</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a15">DMXConfigDisplayPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigWall.html">_DMXConfigWall</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a16">DMXConfigWall</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigWall.html">_DMXConfigWall</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a17">DMXConfigWallPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigOption.html">_DMXConfigOption</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a18">DMXConfigOption</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigOption.html">_DMXConfigOption</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a19">DMXConfigOptionPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigParam.html">_DMXConfigParam</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a20">DMXConfigParam</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigParam.html">_DMXConfigParam</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a21">DMXConfigParamPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigSub.html">_DMXConfigSub</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a22">DMXConfigSub</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigSub.html">_DMXConfigSub</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a23">DMXConfigSubPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigVirtual.html">_DMXConfigVirtual</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a24">DMXConfigVirtual</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigVirtual.html">_DMXConfigVirtual</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a25">DMXConfigVirtualPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigEntry.html">_DMXConfigEntry</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a26">DMXConfigEntry</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXConfigEntry.html">_DMXConfigEntry</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a27">DMXConfigEntryPtr</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxparse_8h.html#a38">dmxConfigLog</a> (const char *format,...)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to DMX configuration file parser. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxparse_8c.html">dmxparse.c</a></dd></dl>
+<hr><h2>Typedef Documentation</h2>
+<a class="anchor" name="a8" doxytag="dmxparse.h::DMXConfigComment" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigComment.html">_DMXConfigComment</a> <a class="el" href="struct__DMXConfigComment.html">DMXConfigComment</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed comments not stored with a token. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxparse.h::DMXConfigCommentPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigComment.html">_DMXConfigComment</a> * <a class="el" href="struct__DMXConfigComment.html">DMXConfigCommentPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed comments not stored with a token. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmxparse.h::DMXConfigDisplay" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigDisplay.html">_DMXConfigDisplay</a> <a class="el" href="struct__DMXConfigDisplay.html">DMXConfigDisplay</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed display information. </td>
+ </tr>
+</table>
+<a class="anchor" name="a15" doxytag="dmxparse.h::DMXConfigDisplayPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigDisplay.html">_DMXConfigDisplay</a> * <a class="el" href="struct__DMXConfigDisplay.html">DMXConfigDisplayPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed display information. </td>
+ </tr>
+</table>
+<a class="anchor" name="a26" doxytag="dmxparse.h::DMXConfigEntry" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigEntry.html">_DMXConfigEntry</a> <a class="el" href="struct__DMXConfigEntry.html">DMXConfigEntry</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Heads entry storage. </td>
+ </tr>
+</table>
+<a class="anchor" name="a27" doxytag="dmxparse.h::DMXConfigEntryPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigEntry.html">_DMXConfigEntry</a> * <a class="el" href="struct__DMXConfigEntry.html">DMXConfigEntryPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Heads entry storage. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxparse.h::DMXConfigFullDim" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigFullDim.html">_DMXConfigFullDim</a> <a class="el" href="struct__DMXConfigFullDim.html">DMXConfigFullDim</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores a pair of geometry specifications. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmxparse.h::DMXConfigFullDimPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigFullDim.html">_DMXConfigFullDim</a> * <a class="el" href="struct__DMXConfigFullDim.html">DMXConfigFullDimPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores a pair of geometry specifications. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxparse.h::DMXConfigNumber" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigNumber.html">_DMXConfigNumber</a> <a class="el" href="struct__DMXConfigNumber.html">DMXConfigNumber</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed numbers. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxparse.h::DMXConfigNumberPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigNumber.html">_DMXConfigNumber</a> * <a class="el" href="struct__DMXConfigNumber.html">DMXConfigNumberPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed numbers. </td>
+ </tr>
+</table>
+<a class="anchor" name="a18" doxytag="dmxparse.h::DMXConfigOption" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigOption.html">_DMXConfigOption</a> <a class="el" href="struct__DMXConfigOption.html">DMXConfigOption</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed option information. </td>
+ </tr>
+</table>
+<a class="anchor" name="a19" doxytag="dmxparse.h::DMXConfigOptionPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigOption.html">_DMXConfigOption</a> * <a class="el" href="struct__DMXConfigOption.html">DMXConfigOptionPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed option information. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxparse.h::DMXConfigPair" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigPair.html">_DMXConfigPair</a> <a class="el" href="struct__DMXConfigPair.html">DMXConfigPair</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed pairs (e.g., x y) </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxparse.h::DMXConfigPairPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigPair.html">_DMXConfigPair</a> * <a class="el" href="struct__DMXConfigPair.html">DMXConfigPairPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed pairs (e.g., x y) </td>
+ </tr>
+</table>
+<a class="anchor" name="a20" doxytag="dmxparse.h::DMXConfigParam" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigParam.html">_DMXConfigParam</a> <a class="el" href="struct__DMXConfigParam.html">DMXConfigParam</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed param information. </td>
+ </tr>
+</table>
+<a class="anchor" name="a21" doxytag="dmxparse.h::DMXConfigParamPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigParam.html">_DMXConfigParam</a> * <a class="el" href="struct__DMXConfigParam.html">DMXConfigParamPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed param information. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxparse.h::DMXConfigPartDim" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigPartDim.html">_DMXConfigPartDim</a> <a class="el" href="struct__DMXConfigPartDim.html">DMXConfigPartDim</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores a geometry specification. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxparse.h::DMXConfigPartDimPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigPartDim.html">_DMXConfigPartDim</a> * <a class="el" href="struct__DMXConfigPartDim.html">DMXConfigPartDimPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores a geometry specification. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxparse.h::DMXConfigString" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigString.html">_DMXConfigString</a> <a class="el" href="struct__DMXConfigString.html">DMXConfigString</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed strings. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxparse.h::DMXConfigStringPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigString.html">_DMXConfigString</a> * <a class="el" href="struct__DMXConfigString.html">DMXConfigStringPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed strings. </td>
+ </tr>
+</table>
+<a class="anchor" name="a22" doxytag="dmxparse.h::DMXConfigSub" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigSub.html">_DMXConfigSub</a> <a class="el" href="struct__DMXConfigSub.html">DMXConfigSub</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores options under an entry (subentry). </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="dmxparse.h::DMXConfigSubPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigSub.html">_DMXConfigSub</a> * <a class="el" href="struct__DMXConfigSub.html">DMXConfigSubPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores options under an entry (subentry). </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxparse.h::DMXConfigToken" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigToken.html">_DMXConfigToken</a> <a class="el" href="struct__DMXConfigToken.html">DMXConfigToken</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores tokens not stored in other structures (e.g., keywords and ;) </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxparse.h::DMXConfigTokenPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigToken.html">_DMXConfigToken</a> * <a class="el" href="struct__DMXConfigToken.html">DMXConfigTokenPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores tokens not stored in other structures (e.g., keywords and ;) </td>
+ </tr>
+</table>
+<a class="anchor" name="a24" doxytag="dmxparse.h::DMXConfigVirtual" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigVirtual.html">_DMXConfigVirtual</a> <a class="el" href="struct__DMXConfigVirtual.html">DMXConfigVirtual</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed virtual information. </td>
+ </tr>
+</table>
+<a class="anchor" name="a25" doxytag="dmxparse.h::DMXConfigVirtualPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigVirtual.html">_DMXConfigVirtual</a> * <a class="el" href="struct__DMXConfigVirtual.html">DMXConfigVirtualPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed virtual information. </td>
+ </tr>
+</table>
+<a class="anchor" name="a16" doxytag="dmxparse.h::DMXConfigWall" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigWall.html">_DMXConfigWall</a> <a class="el" href="struct__DMXConfigWall.html">DMXConfigWall</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed wall information. </td>
+ </tr>
+</table>
+<a class="anchor" name="a17" doxytag="dmxparse.h::DMXConfigWallPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXConfigWall.html">_DMXConfigWall</a> * <a class="el" href="struct__DMXConfigWall.html">DMXConfigWallPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Stores parsed wall information. </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a38" doxytag="dmxparse.h::dmxConfigLog" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigLog </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>format</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>...&nbsp;</td>
+ <td class="mdname" nowrap></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+A general error logging routine that does not depend on the dmxLog functions. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpict_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpict_8c.html
new file mode 100644
index 000000000..96fd4fe5f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpict_8c.html
@@ -0,0 +1,1184 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxpict.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxpict_8h-source.html">dmxpict.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxwindow_8h-source.html">dmxwindow.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxpixmap_8h-source.html">dmxpixmap.h</a>"</code><br>
+<code>#include "fb.h"</code><br>
+<code>#include "pixmapstr.h"</code><br>
+<code>#include "dixstruct.h"</code><br>
+<code>#include "render.h"</code><br>
+<code>#include "renderproto.h"</code><br>
+<code>#include "picture.h"</code><br>
+<code>#include "picturestr.h"</code><br>
+<code>#include "mipict.h"</code><br>
+<code>#include "fbpict.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a12">dmxInitRender</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a13">dmxResetRender</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a14">dmxPictureInit</a> (ScreenPtr pScreen, PictFormatPtr formats, int nformats)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a16">dmxBEFreeGlyphSet</a> (ScreenPtr pScreen, GlyphSetPtr glyphSet)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a18">dmxCreatePictureList</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a19">dmxCreatePicture</a> (PicturePtr pPicture)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a20">dmxBEFreePicture</a> (PicturePtr pPicture)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a21">dmxDestroyPictureList</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a22">dmxDestroyPicture</a> (PicturePtr pPicture)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a23">dmxChangePictureClip</a> (PicturePtr pPicture, int clipType, pointer value, int n)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a24">dmxDestroyPictureClip</a> (PicturePtr pPicture)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a25">dmxChangePicture</a> (PicturePtr pPicture, Mask mask)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a26">dmxValidatePicture</a> (PicturePtr pPicture, Mask mask)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a27">dmxComposite</a> (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a28">dmxGlyphs</a> (CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists, GlyphPtr *glyphs)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a29">dmxCompositeRects</a> (CARD8 op, PicturePtr pDst, xRenderColor *color, int nRect, xRectangle *rects)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a30">dmxInitIndexed</a> (ScreenPtr pScreen, PictFormatPtr pFormat)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a31">dmxCloseIndexed</a> (ScreenPtr pScreen, PictFormatPtr pFormat)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a32">dmxUpdateIndexed</a> (ScreenPtr pScreen, PictFormatPtr pFormat, int ndef, xColorItem *pdef)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a33">dmxTrapezoids</a> (CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid *traps)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a34">dmxTriangles</a> (CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int ntri, xTriangle *tris)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a35">dmxTriStrip</a> (CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int npoint, xPointFixed *points)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8c.html#a36">dmxTriFan</a> (CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int npoint, xPointFixed *points)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Provide support for the RENDER extension (version 0.8).<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a16" doxytag="dmxpict.c::dmxBEFreeGlyphSet" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBEFreeGlyphSet </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GlyphSetPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>glyphSet</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Free <em>glyphSet</em> on back-end screen number <em>idx</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a20" doxytag="dmxpict.c::dmxBEFreePicture" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBEFreePicture </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PicturePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pPicture</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy <em>pPicture</em> on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a25" doxytag="dmxpict.c::dmxChangePicture" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxChangePicture </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pPicture</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Mask&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the attributes of the pictures. If the picture has not yet been created due to lazy window creation, save the mask so that it can be used to appropriately initialize the picture's attributes when it is created later. </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="dmxpict.c::dmxChangePictureClip" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxChangePictureClip </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pPicture</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>clipType</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>value</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>n</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the picture's list of clip rectangles. </td>
+ </tr>
+</table>
+<a class="anchor" name="a31" doxytag="dmxpict.c::dmxCloseIndexed" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCloseIndexed </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pFormat</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Indexed color visuals are not yet supported. </td>
+ </tr>
+</table>
+<a class="anchor" name="a27" doxytag="dmxpict.c::dmxComposite" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxComposite </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">CARD8&nbsp;</td>
+ <td class="mdname" nowrap> <em>op</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pMask</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>xSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>ySrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>xMask</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>yMask</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>xDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>yDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CARD16&nbsp;</td>
+ <td class="mdname" nowrap> <em>width</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CARD16&nbsp;</td>
+ <td class="mdname" nowrap> <em>height</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Composite a picture on the appropriate screen by combining the specified rectangle of the transformed src and mask operands with the specified rectangle of the dst using op as the compositing operator. For a complete description see the protocol document of the RENDER library. </td>
+ </tr>
+</table>
+<a class="anchor" name="a29" doxytag="dmxpict.c::dmxCompositeRects" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCompositeRects </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">CARD8&nbsp;</td>
+ <td class="mdname" nowrap> <em>op</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xRenderColor *&nbsp;</td>
+ <td class="mdname" nowrap> <em>color</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nRect</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xRectangle *&nbsp;</td>
+ <td class="mdname" nowrap> <em>rects</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill a rectangle on the appropriate screen by combining the color with the dest picture in the area specified by the list of rectangles. For a complete description see the protocol document of the RENDER library. </td>
+ </tr>
+</table>
+<a class="anchor" name="a19" doxytag="dmxpict.c::dmxCreatePicture" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxCreatePicture </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PicturePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pPicture</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a picture. This function handles the CreatePicture unwrapping/wrapping and calls dmxDoCreatePicture to actually create the picture on the appropriate screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a18" doxytag="dmxpict.c::dmxCreatePictureList" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCreatePictureList </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a list of pictures. This function is called by <a class="el" href="dmxwindow_8c.html#a9">dmxCreateAndRealizeWindow()</a> during the lazy window creation realization process. It creates the entire list of pictures that are associated with the given window. </td>
+ </tr>
+</table>
+<a class="anchor" name="a22" doxytag="dmxpict.c::dmxDestroyPicture" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDestroyPicture </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PicturePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pPicture</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy a picture. This function calls the wrapped function that frees the resources in the DMX server associated with this picture. </td>
+ </tr>
+</table>
+<a class="anchor" name="a24" doxytag="dmxpict.c::dmxDestroyPictureClip" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDestroyPictureClip </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PicturePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pPicture</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy the picture's list of clip rectangles. </td>
+ </tr>
+</table>
+<a class="anchor" name="a21" doxytag="dmxpict.c::dmxDestroyPictureList" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxDestroyPictureList </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy a list of pictures that are associated with the window that is being destroyed. This function is called by <a class="el" href="dmxwindow_8c.html#a12">dmxDestroyWindow()</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a28" doxytag="dmxpict.c::dmxGlyphs" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxGlyphs </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">CARD8&nbsp;</td>
+ <td class="mdname" nowrap> <em>op</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>maskFormat</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>xSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>ySrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nlists</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GlyphListPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>lists</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GlyphPtr *&nbsp;</td>
+ <td class="mdname" nowrap> <em>glyphs</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Null function to catch when/if RENDER calls lower level mi hooks. Compositing glyphs is handled by <a class="el" href="dmxpict_8c.html#a8">dmxProcRenderCompositeGlyphs()</a>. This function should never be called. </td>
+ </tr>
+</table>
+<a class="anchor" name="a30" doxytag="dmxpict.c::dmxInitIndexed" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxInitIndexed </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pFormat</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Indexed color visuals are not yet supported. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxpict.c::dmxInitRender" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInitRender </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize the Proc Vector for the RENDER extension. The functions here cannot be handled by the mi layer RENDER hooks either because the required information is no longer available when it reaches the mi layer or no mi layer hooks exist. This function is called from <a class="el" href="dmxinit_8c.html#a34">InitOutput()</a> since it should be initialized only once per server generation. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmxpict.c::dmxPictureInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxPictureInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>formats</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nformats</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize the RENDER extension, allocate the picture privates and wrap mi function hooks. If the shadow frame buffer is used, then call the appropriate fb initialization function. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmxpict.c::dmxResetRender" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxResetRender </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Reset the Proc Vector for the RENDER extension back to the original functions. This function is called from <a class="el" href="dmxscrinit_8c.html#a9">dmxCloseScreen()</a> during the server reset (only for screen #0). </td>
+ </tr>
+</table>
+<a class="anchor" name="a33" doxytag="dmxpict.c::dmxTrapezoids" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxTrapezoids </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">CARD8&nbsp;</td>
+ <td class="mdname" nowrap> <em>op</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>maskFormat</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>xSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>ySrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>ntrap</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xTrapezoid *&nbsp;</td>
+ <td class="mdname" nowrap> <em>traps</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Composite a list of trapezoids on the appropriate screen. For a complete description see the protocol document of the RENDER library. </td>
+ </tr>
+</table>
+<a class="anchor" name="a34" doxytag="dmxpict.c::dmxTriangles" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxTriangles </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">CARD8&nbsp;</td>
+ <td class="mdname" nowrap> <em>op</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>maskFormat</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>xSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>ySrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>ntri</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xTriangle *&nbsp;</td>
+ <td class="mdname" nowrap> <em>tris</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Composite a list of triangles on the appropriate screen. For a complete description see the protocol document of the RENDER library. </td>
+ </tr>
+</table>
+<a class="anchor" name="a36" doxytag="dmxpict.c::dmxTriFan" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxTriFan </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">CARD8&nbsp;</td>
+ <td class="mdname" nowrap> <em>op</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>maskFormat</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>xSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>ySrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>npoint</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xPointFixed *&nbsp;</td>
+ <td class="mdname" nowrap> <em>points</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Composite a triangle fan on the appropriate screen. For a complete description see the protocol document of the RENDER library. </td>
+ </tr>
+</table>
+<a class="anchor" name="a35" doxytag="dmxpict.c::dmxTriStrip" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxTriStrip </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">CARD8&nbsp;</td>
+ <td class="mdname" nowrap> <em>op</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>maskFormat</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>xSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>ySrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>npoint</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xPointFixed *&nbsp;</td>
+ <td class="mdname" nowrap> <em>points</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Composite a triangle strip on the appropriate screen. For a complete description see the protocol document of the RENDER library. </td>
+ </tr>
+</table>
+<a class="anchor" name="a32" doxytag="dmxpict.c::dmxUpdateIndexed" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxUpdateIndexed </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pFormat</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>ndef</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xColorItem *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pdef</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Indexed color visuals are not yet supported. </td>
+ </tr>
+</table>
+<a class="anchor" name="a26" doxytag="dmxpict.c::dmxValidatePicture" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxValidatePicture </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pPicture</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Mask&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Validate the picture's attributes before rendering to it. Update any picture attributes that have been changed by one of the higher layers. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpict_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpict_8h-source.html
new file mode 100644
index 000000000..1043f82bf
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpict_8h-source.html
@@ -0,0 +1,141 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxpict.h</h1><a href="dmxpict_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Kevin E. Martin &lt;kem@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00042 <span class="preprocessor">#ifndef DMXPICT_H</span>
+00043 <span class="preprocessor"></span><span class="preprocessor">#define DMXPICT_H</span>
+00044 <span class="preprocessor"></span>
+<a name="l00046"></a><a class="code" href="struct__dmxPictPriv.html">00046</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__dmxPictPriv.html">_dmxPictPriv</a> {
+<a name="l00047"></a><a class="code" href="struct__dmxPictPriv.html#o0">00047</a> Picture <a class="code" href="struct__dmxPictPriv.html#o0">pict</a>;
+<a name="l00048"></a><a class="code" href="struct__dmxPictPriv.html#o1">00048</a> Mask <a class="code" href="struct__dmxPictPriv.html#o1">savedMask</a>;
+00050 } <a class="code" href="struct__dmxPictPriv.html">dmxPictPrivRec</a>, *<a class="code" href="struct__dmxPictPriv.html">dmxPictPrivPtr</a>;
+00051
+00052
+<a name="l00054"></a><a class="code" href="struct__dmxGlyphPriv.html">00054</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__dmxGlyphPriv.html">_dmxGlyphPriv</a> {
+<a name="l00055"></a><a class="code" href="struct__dmxGlyphPriv.html#o0">00055</a> GlyphSet *<a class="code" href="struct__dmxGlyphPriv.html#o0">glyphSets</a>;
+00056 } <a class="code" href="struct__dmxGlyphPriv.html">dmxGlyphPrivRec</a>, *<a class="code" href="struct__dmxGlyphPriv.html">dmxGlyphPrivPtr</a>;
+00057
+00058
+00059 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpict_8c.html#a12">dmxInitRender</a>(<span class="keywordtype">void</span>);
+00060 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpict_8c.html#a13">dmxResetRender</a>(<span class="keywordtype">void</span>);
+00061
+00062 <span class="keyword">extern</span> Bool <a class="code" href="dmxpict_8c.html#a14">dmxPictureInit</a>(ScreenPtr pScreen,
+00063 PictFormatPtr formats, <span class="keywordtype">int</span> nformats);
+00064
+00065 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpict_8c.html#a18">dmxCreatePictureList</a>(WindowPtr pWindow);
+00066 <span class="keyword">extern</span> Bool <a class="code" href="dmxpict_8c.html#a21">dmxDestroyPictureList</a>(WindowPtr pWindow);
+00067
+00068 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxpict_8c.html#a19">dmxCreatePicture</a>(PicturePtr pPicture);
+00069 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpict_8c.html#a22">dmxDestroyPicture</a>(PicturePtr pPicture);
+00070 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxpict_8c.html#a23">dmxChangePictureClip</a>(PicturePtr pPicture, <span class="keywordtype">int</span> clipType,
+00071 pointer value, <span class="keywordtype">int</span> n);
+00072 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpict_8c.html#a24">dmxDestroyPictureClip</a>(PicturePtr pPicture);
+00073 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpict_8c.html#a25">dmxChangePicture</a>(PicturePtr pPicture, Mask mask);
+00074 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpict_8c.html#a26">dmxValidatePicture</a>(PicturePtr pPicture, Mask mask);
+00075 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpict_8c.html#a27">dmxComposite</a>(CARD8 op,
+00076 PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
+00077 INT16 xSrc, INT16 ySrc,
+00078 INT16 xMask, INT16 yMask,
+00079 INT16 xDst, INT16 yDst,
+00080 CARD16 width, CARD16 height);
+00081 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpict_8c.html#a28">dmxGlyphs</a>(CARD8 op,
+00082 PicturePtr pSrc, PicturePtr pDst,
+00083 PictFormatPtr maskFormat,
+00084 INT16 xSrc, INT16 ySrc,
+00085 <span class="keywordtype">int</span> nlists, GlyphListPtr lists, GlyphPtr *glyphs);
+00086 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpict_8c.html#a29">dmxCompositeRects</a>(CARD8 op,
+00087 PicturePtr pDst,
+00088 xRenderColor *color,
+00089 <span class="keywordtype">int</span> nRect, xRectangle *rects);
+00090 <span class="keyword">extern</span> Bool <a class="code" href="dmxpict_8c.html#a30">dmxInitIndexed</a>(ScreenPtr pScreen, PictFormatPtr pFormat);
+00091 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpict_8c.html#a31">dmxCloseIndexed</a>(ScreenPtr pScreen, PictFormatPtr pFormat);
+00092 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpict_8c.html#a32">dmxUpdateIndexed</a>(ScreenPtr pScreen, PictFormatPtr pFormat,
+00093 <span class="keywordtype">int</span> ndef, xColorItem *pdef);
+00094 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpict_8c.html#a33">dmxTrapezoids</a>(CARD8 op,
+00095 PicturePtr pSrc, PicturePtr pDst,
+00096 PictFormatPtr maskFormat,
+00097 INT16 xSrc, INT16 ySrc,
+00098 <span class="keywordtype">int</span> ntrap, xTrapezoid *traps);
+00099 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpict_8c.html#a34">dmxTriangles</a>(CARD8 op,
+00100 PicturePtr pSrc, PicturePtr pDst,
+00101 PictFormatPtr maskFormat,
+00102 INT16 xSrc, INT16 ySrc,
+00103 <span class="keywordtype">int</span> ntri, xTriangle *tris);
+00104 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpict_8c.html#a35">dmxTriStrip</a>(CARD8 op,
+00105 PicturePtr pSrc, PicturePtr pDst,
+00106 PictFormatPtr maskFormat,
+00107 INT16 xSrc, INT16 ySrc,
+00108 <span class="keywordtype">int</span> npoint, xPointFixed *points);
+00109 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpict_8c.html#a36">dmxTriFan</a>(CARD8 op,
+00110 PicturePtr pSrc, PicturePtr pDst,
+00111 PictFormatPtr maskFormat,
+00112 INT16 xSrc, INT16 ySrc,
+00113 <span class="keywordtype">int</span> npoint, xPointFixed *points);
+00114
+00115 <span class="keyword">extern</span> Bool <a class="code" href="dmxpict_8c.html#a16">dmxBEFreeGlyphSet</a>(ScreenPtr pScreen, GlyphSetPtr glyphSet);
+00116 <span class="keyword">extern</span> Bool <a class="code" href="dmxpict_8c.html#a20">dmxBEFreePicture</a>(PicturePtr pPicture);
+00117
+<a name="l00118"></a><a class="code" href="dmxpict_8h.html#a7">00118</a> <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxpict_8h.html#a7">dmxPictPrivateIndex</a>;
+<a name="l00119"></a><a class="code" href="dmxpict_8h.html#a8">00119</a> <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxpict_8h.html#a8">dmxGlyphSetPrivateIndex</a>;
+<a name="l00123"></a><a class="code" href="dmxpict_8h.html#a0">00123</a> <span class="preprocessor">#define DMX_GET_PICT_PRIV(_pPict) \</span>
+00124 <span class="preprocessor"> (dmxPictPrivPtr)(_pPict)-&gt;devPrivates[dmxPictPrivateIndex].ptr</span>
+00125 <span class="preprocessor"></span>
+<a name="l00127"></a><a class="code" href="dmxpict_8h.html#a1">00127</a> <span class="preprocessor">#define DMX_SET_GLYPH_PRIV(_pGlyph, _pPriv) \</span>
+00128 <span class="preprocessor"> GlyphSetSetPrivate((_pGlyph), dmxGlyphSetPrivateIndex, (_pPriv))</span>
+00129 <span class="preprocessor"></span>
+<a name="l00130"></a><a class="code" href="dmxpict_8h.html#a2">00130</a> <span class="preprocessor">#define DMX_GET_GLYPH_PRIV(_pGlyph) \</span>
+00131 <span class="preprocessor"> (dmxGlyphPrivPtr)GlyphSetGetPrivate((_pGlyph), dmxGlyphSetPrivateIndex)</span>
+00132 <span class="preprocessor"></span>
+00133 <span class="preprocessor">#endif </span><span class="comment">/* DMXPICT_H */</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpict_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpict_8h.html
new file mode 100644
index 000000000..ea00f7a84
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpict_8h.html
@@ -0,0 +1,1418 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxpict.h File Reference</h1>
+<p>
+<a href="dmxpict_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__dmxGlyphPriv.html">_dmxGlyphPriv</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__dmxPictPriv.html">_dmxPictPriv</a></td></tr>
+
+<tr><td colspan=2><br><h2>Defines</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a0">DMX_GET_PICT_PRIV</a>(_pPict)&nbsp;&nbsp;&nbsp;(<a class="el" href="struct__dmxPictPriv.html">dmxPictPrivPtr</a>)(_pPict)-&gt;devPrivates[<a class="el" href="dmxscrinit_8c.html#a7">dmxPictPrivateIndex</a>].ptr</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a1">DMX_SET_GLYPH_PRIV</a>(_pGlyph, _pPriv)&nbsp;&nbsp;&nbsp;GlyphSetSetPrivate((_pGlyph), <a class="el" href="dmxscrinit_8c.html#a8">dmxGlyphSetPrivateIndex</a>, (_pPriv))</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a2">DMX_GET_GLYPH_PRIV</a>(_pGlyph)&nbsp;&nbsp;&nbsp;(<a class="el" href="struct__dmxGlyphPriv.html">dmxGlyphPrivPtr</a>)GlyphSetGetPrivate((_pGlyph), <a class="el" href="dmxscrinit_8c.html#a8">dmxGlyphSetPrivateIndex</a>)</td></tr>
+
+<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__dmxPictPriv.html">_dmxPictPriv</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a3">dmxPictPrivRec</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__dmxPictPriv.html">_dmxPictPriv</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a4">dmxPictPrivPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__dmxGlyphPriv.html">_dmxGlyphPriv</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a5">dmxGlyphPrivRec</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__dmxGlyphPriv.html">_dmxGlyphPriv</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a6">dmxGlyphPrivPtr</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a9">dmxInitRender</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a10">dmxResetRender</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a11">dmxPictureInit</a> (ScreenPtr pScreen, PictFormatPtr formats, int nformats)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a12">dmxCreatePictureList</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a13">dmxDestroyPictureList</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a14">dmxCreatePicture</a> (PicturePtr pPicture)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a15">dmxDestroyPicture</a> (PicturePtr pPicture)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a16">dmxChangePictureClip</a> (PicturePtr pPicture, int clipType, pointer value, int n)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a17">dmxDestroyPictureClip</a> (PicturePtr pPicture)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a18">dmxChangePicture</a> (PicturePtr pPicture, Mask mask)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a19">dmxValidatePicture</a> (PicturePtr pPicture, Mask mask)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a20">dmxComposite</a> (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a21">dmxGlyphs</a> (CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists, GlyphPtr *glyphs)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a22">dmxCompositeRects</a> (CARD8 op, PicturePtr pDst, xRenderColor *color, int nRect, xRectangle *rects)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a23">dmxInitIndexed</a> (ScreenPtr pScreen, PictFormatPtr pFormat)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a24">dmxCloseIndexed</a> (ScreenPtr pScreen, PictFormatPtr pFormat)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a25">dmxUpdateIndexed</a> (ScreenPtr pScreen, PictFormatPtr pFormat, int ndef, xColorItem *pdef)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a26">dmxTrapezoids</a> (CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid *traps)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a27">dmxTriangles</a> (CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int ntri, xTriangle *tris)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a28">dmxTriStrip</a> (CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int npoint, xPointFixed *points)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a29">dmxTriFan</a> (CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int npoint, xPointFixed *points)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a30">dmxBEFreeGlyphSet</a> (ScreenPtr pScreen, GlyphSetPtr glyphSet)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a31">dmxBEFreePicture</a> (PicturePtr pPicture)</td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a7">dmxPictPrivateIndex</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpict_8h.html#a8">dmxGlyphSetPrivateIndex</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides access to the externally visible RENDER support functions, global variables and macros for DMX.<p>
+FIXME: Move function definitions for non-externally visible function to .c file.<hr><h2>Define Documentation</h2>
+<a class="anchor" name="a2" doxytag="dmxpict.h::DMX_GET_GLYPH_PRIV" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_GET_GLYPH_PRIV</td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">_pGlyph&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap>&nbsp;&nbsp;&nbsp;(<a class="el" href="struct__dmxGlyphPriv.html">dmxGlyphPrivPtr</a>)GlyphSetGetPrivate((_pGlyph), <a class="el" href="dmxscrinit_8c.html#a8">dmxGlyphSetPrivateIndex</a>)
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get the glyphset private data given a glyphset pointer </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxpict.h::DMX_GET_PICT_PRIV" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_GET_PICT_PRIV</td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">_pPict&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap>&nbsp;&nbsp;&nbsp;(<a class="el" href="struct__dmxPictPriv.html">dmxPictPrivPtr</a>)(_pPict)-&gt;devPrivates[<a class="el" href="dmxscrinit_8c.html#a7">dmxPictPrivateIndex</a>].ptr
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get the picture private data given a picture pointer </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxpict.h::DMX_SET_GLYPH_PRIV" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_SET_GLYPH_PRIV</td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">_pGlyph, <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>_pPriv&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap>&nbsp;&nbsp;&nbsp;GlyphSetSetPrivate((_pGlyph), <a class="el" href="dmxscrinit_8c.html#a8">dmxGlyphSetPrivateIndex</a>, (_pPriv))
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set the glyphset private data given a glyphset pointer </td>
+ </tr>
+</table>
+<hr><h2>Typedef Documentation</h2>
+<a class="anchor" name="a6" doxytag="dmxpict.h::dmxGlyphPrivPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__dmxGlyphPriv.html">_dmxGlyphPriv</a> * <a class="el" href="struct__dmxGlyphPriv.html">dmxGlyphPrivPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Glyph Set private structure </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxpict.h::dmxGlyphPrivRec" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__dmxGlyphPriv.html">_dmxGlyphPriv</a> <a class="el" href="struct__dmxGlyphPriv.html">dmxGlyphPrivRec</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Glyph Set private structure </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxpict.h::dmxPictPrivPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__dmxPictPriv.html">_dmxPictPriv</a> * <a class="el" href="struct__dmxPictPriv.html">dmxPictPrivPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Picture private structure </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxpict.h::dmxPictPrivRec" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__dmxPictPriv.html">_dmxPictPriv</a> <a class="el" href="struct__dmxPictPriv.html">dmxPictPrivRec</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Picture private structure </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a30" doxytag="dmxpict.h::dmxBEFreeGlyphSet" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBEFreeGlyphSet </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GlyphSetPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>glyphSet</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Free <em>glyphSet</em> on back-end screen number <em>idx</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a31" doxytag="dmxpict.h::dmxBEFreePicture" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBEFreePicture </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PicturePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pPicture</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy <em>pPicture</em> on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a18" doxytag="dmxpict.h::dmxChangePicture" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxChangePicture </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pPicture</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Mask&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the attributes of the pictures. If the picture has not yet been created due to lazy window creation, save the mask so that it can be used to appropriately initialize the picture's attributes when it is created later. </td>
+ </tr>
+</table>
+<a class="anchor" name="a16" doxytag="dmxpict.h::dmxChangePictureClip" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxChangePictureClip </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pPicture</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>clipType</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>value</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>n</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the picture's list of clip rectangles. </td>
+ </tr>
+</table>
+<a class="anchor" name="a24" doxytag="dmxpict.h::dmxCloseIndexed" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCloseIndexed </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pFormat</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Indexed color visuals are not yet supported. </td>
+ </tr>
+</table>
+<a class="anchor" name="a20" doxytag="dmxpict.h::dmxComposite" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxComposite </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">CARD8&nbsp;</td>
+ <td class="mdname" nowrap> <em>op</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pMask</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>xSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>ySrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>xMask</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>yMask</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>xDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>yDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CARD16&nbsp;</td>
+ <td class="mdname" nowrap> <em>width</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CARD16&nbsp;</td>
+ <td class="mdname" nowrap> <em>height</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Composite a picture on the appropriate screen by combining the specified rectangle of the transformed src and mask operands with the specified rectangle of the dst using op as the compositing operator. For a complete description see the protocol document of the RENDER library. </td>
+ </tr>
+</table>
+<a class="anchor" name="a22" doxytag="dmxpict.h::dmxCompositeRects" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCompositeRects </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">CARD8&nbsp;</td>
+ <td class="mdname" nowrap> <em>op</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xRenderColor *&nbsp;</td>
+ <td class="mdname" nowrap> <em>color</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nRect</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xRectangle *&nbsp;</td>
+ <td class="mdname" nowrap> <em>rects</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill a rectangle on the appropriate screen by combining the color with the dest picture in the area specified by the list of rectangles. For a complete description see the protocol document of the RENDER library. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmxpict.h::dmxCreatePicture" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxCreatePicture </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PicturePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pPicture</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a picture. This function handles the CreatePicture unwrapping/wrapping and calls dmxDoCreatePicture to actually create the picture on the appropriate screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxpict.h::dmxCreatePictureList" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCreatePictureList </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a list of pictures. This function is called by <a class="el" href="dmxwindow_8c.html#a9">dmxCreateAndRealizeWindow()</a> during the lazy window creation realization process. It creates the entire list of pictures that are associated with the given window. </td>
+ </tr>
+</table>
+<a class="anchor" name="a15" doxytag="dmxpict.h::dmxDestroyPicture" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDestroyPicture </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PicturePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pPicture</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy a picture. This function calls the wrapped function that frees the resources in the DMX server associated with this picture. </td>
+ </tr>
+</table>
+<a class="anchor" name="a17" doxytag="dmxpict.h::dmxDestroyPictureClip" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxDestroyPictureClip </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PicturePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pPicture</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy the picture's list of clip rectangles. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmxpict.h::dmxDestroyPictureList" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxDestroyPictureList </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy a list of pictures that are associated with the window that is being destroyed. This function is called by <a class="el" href="dmxwindow_8c.html#a12">dmxDestroyWindow()</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a21" doxytag="dmxpict.h::dmxGlyphs" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxGlyphs </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">CARD8&nbsp;</td>
+ <td class="mdname" nowrap> <em>op</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>maskFormat</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>xSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>ySrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nlists</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GlyphListPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>lists</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>GlyphPtr *&nbsp;</td>
+ <td class="mdname" nowrap> <em>glyphs</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Null function to catch when/if RENDER calls lower level mi hooks. Compositing glyphs is handled by <a class="el" href="dmxpict_8c.html#a8">dmxProcRenderCompositeGlyphs()</a>. This function should never be called. </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="dmxpict.h::dmxInitIndexed" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxInitIndexed </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pFormat</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Indexed color visuals are not yet supported. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxpict.h::dmxInitRender" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxInitRender </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize the Proc Vector for the RENDER extension. The functions here cannot be handled by the mi layer RENDER hooks either because the required information is no longer available when it reaches the mi layer or no mi layer hooks exist. This function is called from <a class="el" href="dmxinit_8c.html#a34">InitOutput()</a> since it should be initialized only once per server generation. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxpict.h::dmxPictureInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxPictureInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>formats</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>nformats</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize the RENDER extension, allocate the picture privates and wrap mi function hooks. If the shadow frame buffer is used, then call the appropriate fb initialization function. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxpict.h::dmxResetRender" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxResetRender </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Reset the Proc Vector for the RENDER extension back to the original functions. This function is called from <a class="el" href="dmxscrinit_8c.html#a9">dmxCloseScreen()</a> during the server reset (only for screen #0). </td>
+ </tr>
+</table>
+<a class="anchor" name="a26" doxytag="dmxpict.h::dmxTrapezoids" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxTrapezoids </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">CARD8&nbsp;</td>
+ <td class="mdname" nowrap> <em>op</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>maskFormat</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>xSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>ySrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>ntrap</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xTrapezoid *&nbsp;</td>
+ <td class="mdname" nowrap> <em>traps</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Composite a list of trapezoids on the appropriate screen. For a complete description see the protocol document of the RENDER library. </td>
+ </tr>
+</table>
+<a class="anchor" name="a27" doxytag="dmxpict.h::dmxTriangles" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxTriangles </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">CARD8&nbsp;</td>
+ <td class="mdname" nowrap> <em>op</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>maskFormat</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>xSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>ySrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>ntri</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xTriangle *&nbsp;</td>
+ <td class="mdname" nowrap> <em>tris</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Composite a list of triangles on the appropriate screen. For a complete description see the protocol document of the RENDER library. </td>
+ </tr>
+</table>
+<a class="anchor" name="a29" doxytag="dmxpict.h::dmxTriFan" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxTriFan </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">CARD8&nbsp;</td>
+ <td class="mdname" nowrap> <em>op</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>maskFormat</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>xSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>ySrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>npoint</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xPointFixed *&nbsp;</td>
+ <td class="mdname" nowrap> <em>points</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Composite a triangle fan on the appropriate screen. For a complete description see the protocol document of the RENDER library. </td>
+ </tr>
+</table>
+<a class="anchor" name="a28" doxytag="dmxpict.h::dmxTriStrip" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxTriStrip </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">CARD8&nbsp;</td>
+ <td class="mdname" nowrap> <em>op</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDst</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>maskFormat</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>xSrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>INT16&nbsp;</td>
+ <td class="mdname" nowrap> <em>ySrc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>npoint</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xPointFixed *&nbsp;</td>
+ <td class="mdname" nowrap> <em>points</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Composite a triangle strip on the appropriate screen. For a complete description see the protocol document of the RENDER library. </td>
+ </tr>
+</table>
+<a class="anchor" name="a25" doxytag="dmxpict.h::dmxUpdateIndexed" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxUpdateIndexed </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>PictFormatPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pFormat</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>ndef</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xColorItem *&nbsp;</td>
+ <td class="mdname" nowrap> <em>pdef</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Indexed color visuals are not yet supported. </td>
+ </tr>
+</table>
+<a class="anchor" name="a19" doxytag="dmxpict.h::dmxValidatePicture" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxValidatePicture </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PicturePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pPicture</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Mask&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Validate the picture's attributes before rendering to it. Update any picture attributes that have been changed by one of the higher layers. </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a8" doxytag="dmxpict.h::dmxGlyphSetPrivateIndex" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxscrinit_8c.html#a8">dmxGlyphSetPrivateIndex</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Private index for GlyphSets </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxpict.h::dmxPictPrivateIndex" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxscrinit_8c.html#a7">dmxPictPrivateIndex</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Private index for Picts </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpixmap_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpixmap_8c.html
new file mode 100644
index 000000000..8c6fc4551
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpixmap_8c.html
@@ -0,0 +1,240 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxpixmap.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxpixmap_8h-source.html">dmxpixmap.h</a>"</code><br>
+<code>#include "pixmapstr.h"</code><br>
+<code>#include "servermd.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpixmap_8c.html#a0">dmxInitPixmap</a> (ScreenPtr pScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpixmap_8c.html#a1">dmxBECreatePixmap</a> (PixmapPtr pPixmap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>PixmapPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpixmap_8c.html#a2">dmxCreatePixmap</a> (ScreenPtr pScreen, int width, int height, int depth)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpixmap_8c.html#a3">dmxBEFreePixmap</a> (PixmapPtr pPixmap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpixmap_8c.html#a4">dmxDestroyPixmap</a> (PixmapPtr pPixmap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>RegionPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpixmap_8c.html#a5">dmxBitmapToRegion</a> (PixmapPtr pPixmap)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Provides pixmap support.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a1" doxytag="dmxpixmap.c::dmxBECreatePixmap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBECreatePixmap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PixmapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pPixmap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a pixmap on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxpixmap.c::dmxBEFreePixmap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBEFreePixmap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PixmapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pPixmap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy the pixmap on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxpixmap.c::dmxBitmapToRegion" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> RegionPtr dmxBitmapToRegion </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PixmapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pPixmap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create and return a region based on the pixmap pointed to by <em>pPixmap</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxpixmap.c::dmxCreatePixmap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> PixmapPtr dmxCreatePixmap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>width</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>height</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>depth</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a pixmap for <em>pScreen</em> with the specified <em>width</em>, <em>height</em>, and <em>depth</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxpixmap.c::dmxDestroyPixmap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxDestroyPixmap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PixmapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pPixmap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy the pixmap pointed to by <em>pPixmap</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxpixmap.c::dmxInitPixmap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxInitPixmap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize a private area in <em>pScreen</em> for pixmap information. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpixmap_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpixmap_8h-source.html
new file mode 100644
index 000000000..faa74a3e0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpixmap_8h-source.html
@@ -0,0 +1,83 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxpixmap.h</h1><a href="dmxpixmap_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Kevin E. Martin &lt;kem@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef DMXPIXMAP_H</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define DMXPIXMAP_H</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="preprocessor">#include "pixmapstr.h"</span>
+00042
+<a name="l00044"></a><a class="code" href="struct__dmxPixPriv.html">00044</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__dmxPixPriv.html">_dmxPixPriv</a> {
+00045 Pixmap pixmap;
+00046 XImage *detachedImage;
+00047 } <a class="code" href="struct__dmxPixPriv.html">dmxPixPrivRec</a>, *<a class="code" href="struct__dmxPixPriv.html">dmxPixPrivPtr</a>;
+00048
+00049
+00050 <span class="keyword">extern</span> Bool <a class="code" href="dmxpixmap_8c.html#a0">dmxInitPixmap</a>(ScreenPtr pScreen);
+00051
+00052 <span class="keyword">extern</span> PixmapPtr <a class="code" href="dmxpixmap_8c.html#a2">dmxCreatePixmap</a>(ScreenPtr pScreen,
+00053 <span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height, <span class="keywordtype">int</span> depth);
+00054 <span class="keyword">extern</span> Bool <a class="code" href="dmxpixmap_8c.html#a4">dmxDestroyPixmap</a>(PixmapPtr pPixmap);
+00055 <span class="keyword">extern</span> RegionPtr <a class="code" href="dmxpixmap_8c.html#a5">dmxBitmapToRegion</a>(PixmapPtr pPixmap);
+00056
+00057 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxpixmap_8c.html#a1">dmxBECreatePixmap</a>(PixmapPtr pPixmap);
+00058 <span class="keyword">extern</span> Bool <a class="code" href="dmxpixmap_8c.html#a3">dmxBEFreePixmap</a>(PixmapPtr pPixmap);
+00059
+<a name="l00061"></a><a class="code" href="dmxpixmap_8h.html#a3">00061</a> <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxpixmap_8h.html#a3">dmxPixPrivateIndex</a>;
+00062
+<a name="l00064"></a><a class="code" href="dmxpixmap_8h.html#a0">00064</a> <span class="preprocessor">#define DMX_GET_PIXMAP_PRIV(_pPix) \</span>
+00065 <span class="preprocessor"> (dmxPixPrivPtr)(_pPix)-&gt;devPrivates[dmxPixPrivateIndex].ptr</span>
+00066 <span class="preprocessor"></span>
+00067 <span class="preprocessor">#endif </span><span class="comment">/* DMXPIXMAP_H */</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpixmap_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpixmap_8h.html
new file mode 100644
index 000000000..27cc6a5da
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpixmap_8h.html
@@ -0,0 +1,351 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxpixmap.h File Reference</h1><code>#include "pixmapstr.h"</code><br>
+
+<p>
+<a href="dmxpixmap_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__dmxPixPriv.html">_dmxPixPriv</a></td></tr>
+
+<tr><td colspan=2><br><h2>Defines</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpixmap_8h.html#a0">DMX_GET_PIXMAP_PRIV</a>(_pPix)&nbsp;&nbsp;&nbsp;(<a class="el" href="struct__dmxPixPriv.html">dmxPixPrivPtr</a>)(_pPix)-&gt;devPrivates[<a class="el" href="dmxpixmap_8h.html#a3">dmxPixPrivateIndex</a>].ptr</td></tr>
+
+<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__dmxPixPriv.html">_dmxPixPriv</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpixmap_8h.html#a1">dmxPixPrivRec</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__dmxPixPriv.html">_dmxPixPriv</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpixmap_8h.html#a2">dmxPixPrivPtr</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpixmap_8h.html#a4">dmxInitPixmap</a> (ScreenPtr pScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>PixmapPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpixmap_8h.html#a5">dmxCreatePixmap</a> (ScreenPtr pScreen, int width, int height, int depth)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpixmap_8h.html#a6">dmxDestroyPixmap</a> (PixmapPtr pPixmap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>RegionPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpixmap_8h.html#a7">dmxBitmapToRegion</a> (PixmapPtr pPixmap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpixmap_8h.html#a8">dmxBECreatePixmap</a> (PixmapPtr pPixmap)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpixmap_8h.html#a9">dmxBEFreePixmap</a> (PixmapPtr pPixmap)</td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxpixmap_8h.html#a3">dmxPixPrivateIndex</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for pixmap support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxpixmap_8c.html">dmxpixmap.c</a></dd></dl>
+<hr><h2>Define Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxpixmap.h::DMX_GET_PIXMAP_PRIV" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_GET_PIXMAP_PRIV</td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">_pPix&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap>&nbsp;&nbsp;&nbsp;(<a class="el" href="struct__dmxPixPriv.html">dmxPixPrivPtr</a>)(_pPix)-&gt;devPrivates[<a class="el" href="dmxpixmap_8h.html#a3">dmxPixPrivateIndex</a>].ptr
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get pixmap private pointer. </td>
+ </tr>
+</table>
+<hr><h2>Typedef Documentation</h2>
+<a class="anchor" name="a2" doxytag="dmxpixmap.h::dmxPixPrivPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__dmxPixPriv.html">_dmxPixPriv</a> * <a class="el" href="struct__dmxPixPriv.html">dmxPixPrivPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Pixmap private area. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxpixmap.h::dmxPixPrivRec" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__dmxPixPriv.html">_dmxPixPriv</a> <a class="el" href="struct__dmxPixPriv.html">dmxPixPrivRec</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Pixmap private area. </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a8" doxytag="dmxpixmap.h::dmxBECreatePixmap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBECreatePixmap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PixmapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pPixmap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a pixmap on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxpixmap.h::dmxBEFreePixmap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBEFreePixmap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PixmapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pPixmap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy the pixmap on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxpixmap.h::dmxBitmapToRegion" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> RegionPtr dmxBitmapToRegion </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PixmapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pPixmap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create and return a region based on the pixmap pointed to by <em>pPixmap</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxpixmap.h::dmxCreatePixmap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> PixmapPtr dmxCreatePixmap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>width</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>height</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>depth</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a pixmap for <em>pScreen</em> with the specified <em>width</em>, <em>height</em>, and <em>depth</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxpixmap.h::dmxDestroyPixmap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxDestroyPixmap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">PixmapPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pPixmap</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy the pixmap pointed to by <em>pPixmap</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxpixmap.h::dmxInitPixmap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxInitPixmap </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize a private area in <em>pScreen</em> for pixmap information. </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a3" doxytag="dmxpixmap.h::dmxPixPrivateIndex" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxpixmap_8h.html#a3">dmxPixPrivateIndex</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Private index. <dl compact><dt><b>See also:</b></dt><dd>dmxpicmap.h <p>
+<a class="el" href="dmxscrinit_8c.html">dmxscrinit.c</a> </dd></dl>
+ </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprint_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprint_8c.html
new file mode 100644
index 000000000..9a439cf6b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprint_8c.html
@@ -0,0 +1,119 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxprint.c File Reference</h1><code>#include "<a class="el" href="dmxconfig_8h-source.html">dmxconfig.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxprint_8h-source.html">dmxprint.h</a>"</code><br>
+<code>#include "parser.h"</code><br>
+<code>#include &lt;stdio.h&gt;</code><br>
+<code>#include &lt;stdarg.h&gt;</code><br>
+<code>#include &lt;ctype.h&gt;</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><b>stack</b></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxprint_8c.html#a25">dmxConfigPrint</a> (FILE *stream, <a class="el" href="struct__DMXConfigEntry.html">DMXConfigEntryPtr</a> entry)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxprint_8c.html#a26">dmxConfigVirtualPrint</a> (FILE *stream, <a class="el" href="struct__DMXConfigVirtual.html">DMXConfigVirtualPtr</a> p)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides support routines and helper functions to be used to pretty-print DMX configurations.<p>
+Because the DMX configuration file parsing should be capable of being used in a stand-alone fashion (i.e., independent from the DMX server source tree), no dependencies on other DMX routines are made.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a25" doxytag="dmxprint.c::dmxConfigPrint" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigPrint </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">FILE *&nbsp;</td>
+ <td class="mdname" nowrap> <em>stream</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXConfigEntry.html">DMXConfigEntryPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>entry</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+The configuration information in <em>entry</em> will be pretty-printed to the <em>stream</em>. If <em>stream</em> is NULL, then stdout will be used. </td>
+ </tr>
+</table>
+<a class="anchor" name="a26" doxytag="dmxprint.c::dmxConfigVirtualPrint" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigVirtualPrint </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">FILE *&nbsp;</td>
+ <td class="mdname" nowrap> <em>stream</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXConfigVirtual.html">DMXConfigVirtualPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>p</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+The configuration information in <em>p</em> will be pretty-printed to the <em>stream</em>. If <em>stream</em> is NULL, then stdout will be used. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprint_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprint_8h-source.html
new file mode 100644
index 000000000..c1a0d4edb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprint_8h-source.html
@@ -0,0 +1,63 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxprint.h</h1><a href="dmxprint_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _DMXPRINT_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _DMXPRINT_H_</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="keywordtype">void</span> <a class="code" href="dmxprint_8c.html#a25">dmxConfigPrint</a>(FILE *str, <a class="code" href="struct__DMXConfigEntry.html">DMXConfigEntryPtr</a> entry);
+00042 <span class="keywordtype">void</span> <a class="code" href="dmxprint_8c.html#a26">dmxConfigVirtualPrint</a>(FILE *str, <a class="code" href="struct__DMXConfigVirtual.html">DMXConfigVirtualPtr</a> p);
+00043
+00044 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprint_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprint_8h.html
new file mode 100644
index 000000000..c12085c7b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprint_8h.html
@@ -0,0 +1,111 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxprint.h File Reference</h1>
+<p>
+<a href="dmxprint_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxprint_8h.html#a0">dmxConfigPrint</a> (FILE *str, <a class="el" href="struct__DMXConfigEntry.html">DMXConfigEntryPtr</a> entry)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxprint_8h.html#a1">dmxConfigVirtualPrint</a> (FILE *str, <a class="el" href="struct__DMXConfigVirtual.html">DMXConfigVirtualPtr</a> p)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to DMX configuration file pretty-printer. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxprint_8c.html">dmxprint.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxprint.h::dmxConfigPrint" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigPrint </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">FILE *&nbsp;</td>
+ <td class="mdname" nowrap> <em>stream</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXConfigEntry.html">DMXConfigEntryPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>entry</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+The configuration information in <em>entry</em> will be pretty-printed to the <em>stream</em>. If <em>stream</em> is NULL, then stdout will be used. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxprint.h::dmxConfigVirtualPrint" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxConfigVirtualPrint </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">FILE *&nbsp;</td>
+ <td class="mdname" nowrap> <em>stream</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXConfigVirtual.html">DMXConfigVirtualPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>p</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+The configuration information in <em>p</em> will be pretty-printed to the <em>stream</em>. If <em>stream</em> is NULL, then stdout will be used. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprop_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprop_8c.html
new file mode 100644
index 000000000..6fa746b53
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprop_8c.html
@@ -0,0 +1,235 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxprop.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxprop_8h-source.html">dmxprop.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxlog_8h-source.html">dmxlog.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Defines</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxprop_8c.html#a0">DMX_ATOMNAME</a>&nbsp;&nbsp;&nbsp;"DMX_NAME"</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxprop_8c.html#a1">DMX_IDENT</a>&nbsp;&nbsp;&nbsp;"Xdmx"</td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxprop_8c.html#a5">dmxPropertyIterate</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *start, void *(*f)(<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, void *), void *closure)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxprop_8c.html#a8">dmxPropertyDisplay</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxprop_8c.html#a9">dmxPropertySameDisplay</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, const char *name)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxprop_8c.html#a10">dmxPropertyWindow</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+It is possible for one of the DMX "backend displays" to actually be smaller than the dimensions of the backend X server. Therefore, it is possible for more than one of the DMX "backend displays" to be physically located on the same backend X server. This situation must be detected so that cursor motion can be handled in an expected fashion.<p>
+We could analyze the names used for the DMX "backend displays" (e.g., the names passed to the -display command-line parameter), but there are many possible names for a single X display, and failing to detect sameness leads to very unexpected results. Therefore, whenever the DMX server opens a window on a backend X server, a property value is queried and set on that backend to detect when another window is already open on that server.<p>
+Further, it is possible that two different DMX server instantiations both have windows on the same physical backend X server. This case is also detected so that pointer input is not taken from that particular backend X server.<p>
+The routines in this file handle the property management.<hr><h2>Define Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxprop.c::DMX_ATOMNAME" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_ATOMNAME&nbsp;&nbsp;&nbsp;"DMX_NAME"
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Holds the window id of all DMX windows on the backend X server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxprop.c::DMX_IDENT" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_IDENT&nbsp;&nbsp;&nbsp;"Xdmx"
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+The identification string of this DMX server </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a8" doxytag="dmxprop.c::dmxPropertyDisplay" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxPropertyDisplay </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Returns 0 if this is the only Xdmx session on the display; 1 otherwise. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxprop.c::dmxPropertyIterate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void* dmxPropertyIterate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>start</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>void *(*&nbsp;</td>
+ <td class="mdname" nowrap> <em>f</em>)(<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, void *), </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>void *&nbsp;</td>
+ <td class="mdname" nowrap> <em>closure</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Starting with the <em>start</em> screen, iterate over all of the screens on the same physical X server as <em>start</em>, calling <em>f</em> with the screen and the <em>closure</em>. (The common case is that <em>start</em> is the only DMX window on the backend X server.) </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxprop.c::dmxPropertySameDisplay" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxPropertySameDisplay </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>name</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Returns 1 if the dmxScreen and the display in <em>name</em> are on the same display, or 0 otherwise. We can't just compare the display names because there can be multiple synonyms for the same display, some of which cannot be determined without accessing the display itself (e.g., domain aliases or machines with multiple NICs). </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxprop.c::dmxPropertyWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPropertyWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Prints a log message if <em>dmxScreen</em> is on the same backend X server as some other DMX backend (output) screen. Modifies the property (<a class="el" href="dmxprop_8c.html#a0">DMX_ATOMNAME</a>) on the backend X server to reflect the creation of <em>dmxScreen</em>.<p>
+The root window of the backend X server holds a list of window ids for all DMX windows (on this DMX server or some other DMX server).<p>
+This list can then be iterated, and the property for each window can be examined. This property contains the following tuple (no quotes):<p>
+"#DMX_IDENT:&lt;hostname running DMX&gt;:&lt;display name of DMX&gt;,&lt;screen number&gt;" </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprop_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprop_8h-source.html
new file mode 100644
index 000000000..a623a3b95
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprop_8h-source.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxprop.h</h1><a href="dmxprop_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002,2003 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _DMXPROP_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _DMXPROP_H_</span>
+00040 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxprop_8c.html#a8">dmxPropertyDisplay</a>(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen);
+00041 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxprop_8c.html#a10">dmxPropertyWindow</a>(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen);
+00042 <span class="keyword">extern</span> <span class="keywordtype">void</span> *<a class="code" href="dmxprop_8c.html#a5">dmxPropertyIterate</a>(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *start,
+00043 <span class="keywordtype">void</span> *(*f)(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen,
+00044 <span class="keywordtype">void</span> *closure),
+00045 <span class="keywordtype">void</span> *closure);
+00046 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxprop_8c.html#a9">dmxPropertySameDisplay</a>(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, <span class="keyword">const</span> <span class="keywordtype">char</span> *name);
+00047 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprop_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprop_8h.html
new file mode 100644
index 000000000..bc8210b47
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprop_8h.html
@@ -0,0 +1,136 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxprop.h File Reference</h1>
+<p>
+<a href="dmxprop_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxprop_8h.html#a0">dmxPropertyDisplay</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxprop_8h.html#a1">dmxPropertyWindow</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxprop_8h.html#a3">dmxPropertySameDisplay</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, const char *name)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for property support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxprop_8c.html">dmxprop.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxprop.h::dmxPropertyDisplay" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxPropertyDisplay </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Returns 0 if this is the only Xdmx session on the display; 1 otherwise. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxprop.h::dmxPropertySameDisplay" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int dmxPropertySameDisplay </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>name</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Returns 1 if the dmxScreen and the display in <em>name</em> are on the same display, or 0 otherwise. We can't just compare the display names because there can be multiple synonyms for the same display, some of which cannot be determined without accessing the display itself (e.g., domain aliases or machines with multiple NICs). </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxprop.h::dmxPropertyWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPropertyWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Prints a log message if <em>dmxScreen</em> is on the same backend X server as some other DMX backend (output) screen. Modifies the property (<a class="el" href="dmxprop_8c.html#a0">DMX_ATOMNAME</a>) on the backend X server to reflect the creation of <em>dmxScreen</em>.<p>
+The root window of the backend X server holds a list of window ids for all DMX windows (on this DMX server or some other DMX server).<p>
+This list can then be iterated, and the property for each window can be examined. This property contains the following tuple (no quotes):<p>
+"#DMX_IDENT:&lt;hostname running DMX&gt;:&lt;display name of DMX&gt;,&lt;screen number&gt;" </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxproto_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxproto_8h-source.html
new file mode 100644
index 000000000..679d60e73
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxproto_8h-source.html
@@ -0,0 +1,431 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxproto.h</h1><a href="dmxproto_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002-2004 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00042 <span class="preprocessor">#ifndef _DMXSTR_H_</span>
+00043 <span class="preprocessor"></span><span class="preprocessor">#define _DMXSTR_H_</span>
+00044 <span class="preprocessor"></span>
+00045 <span class="preprocessor">#define DMX_EXTENSION_NAME "DMX"</span>
+00046 <span class="preprocessor"></span><span class="preprocessor">#define DMX_EXTENSION_MAJOR 2</span>
+00047 <span class="preprocessor"></span><span class="preprocessor">#define DMX_EXTENSION_MINOR 2</span>
+00048 <span class="preprocessor"></span><span class="preprocessor">#define DMX_EXTENSION_PATCH 20040604</span>
+00049 <span class="preprocessor"></span>
+00050 <span class="comment">/* These values must be larger than LastExtensionError.</span>
+00051 <span class="comment"> The values in dmxext.h and dmxproto.h *MUST* match. */</span>
+00052 <span class="preprocessor">#define DMX_BAD_XINERAMA 1001</span>
+00053 <span class="preprocessor"></span><span class="preprocessor">#define DMX_BAD_VALUE 1002</span>
+00054 <span class="preprocessor"></span>
+00055 <span class="preprocessor">#define X_DMXQueryVersion 0</span>
+00056 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXGetScreenCount 1</span>
+00057 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXGetScreenInformationDEPRECATED 2</span>
+00058 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXGetWindowAttributes 3</span>
+00059 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXGetInputCount 4</span>
+00060 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXGetInputAttributes 5</span>
+00061 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXForceWindowCreationDEPRECATED 6</span>
+00062 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXReconfigureScreenDEPRECATED 7</span>
+00063 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXSync 8</span>
+00064 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXForceWindowCreation 9</span>
+00065 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXGetScreenAttributes 10</span>
+00066 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXChangeScreensAttributes 11</span>
+00067 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXAddScreen 12</span>
+00068 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXRemoveScreen 13</span>
+00069 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXGetDesktopAttributes 14</span>
+00070 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXChangeDesktopAttributes 15</span>
+00071 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXAddInput 16</span>
+00072 <span class="preprocessor"></span><span class="preprocessor">#define X_DMXRemoveInput 17</span>
+00073 <span class="preprocessor"></span>
+<a name="l00075"></a><a class="code" href="structxDMXQueryVersionReq.html">00075</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00076 CARD8 reqType; <span class="comment">/* dmxcode */</span>
+00077 CARD8 dmxReqType; <span class="comment">/* X_DMXQueryVersion */</span>
+00078 CARD16 length B16;
+00079 } <a class="code" href="structxDMXQueryVersionReq.html">xDMXQueryVersionReq</a>;
+00080 <span class="preprocessor">#define sz_xDMXQueryVersionReq 4</span>
+00081 <span class="preprocessor"></span>
+<a name="l00083"></a><a class="code" href="structxDMXQueryVersionReply.html">00083</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00084 BYTE type; <span class="comment">/* X_Reply */</span>
+00085 CARD8 ununsed;
+00086 CARD16 sequenceNumber B16;
+00087 CARD32 length B32;
+00088 CARD32 majorVersion B32;
+00089 CARD32 minorVersion B32;
+00090 CARD32 patchVersion B32;
+00091 CARD32 pad0 B32;
+00092 CARD32 pad1 B32;
+00093 CARD32 pad2 B32;
+00094 } <a class="code" href="structxDMXQueryVersionReply.html">xDMXQueryVersionReply</a>;
+00095 <span class="preprocessor">#define sz_xDMXQueryVersionReply 32</span>
+00096 <span class="preprocessor"></span>
+<a name="l00098"></a><a class="code" href="structxDMXSyncReq.html">00098</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00099 CARD8 reqType; <span class="comment">/* DMXCode */</span>
+00100 CARD8 dmxReqType; <span class="comment">/* X_DMXSync */</span>
+00101 CARD16 length B16;
+00102 } <a class="code" href="structxDMXSyncReq.html">xDMXSyncReq</a>;
+00103 <span class="preprocessor">#define sz_xDMXSyncReq 4</span>
+00104 <span class="preprocessor"></span>
+<a name="l00106"></a><a class="code" href="structxDMXSyncReply.html">00106</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00107 BYTE type; <span class="comment">/* X_Reply */</span>
+00108 CARD8 unused;
+00109 CARD16 sequenceNumber B16;
+00110 CARD32 length B32;
+00111 CARD32 status B32;
+00112 CARD32 pad0 B32;
+00113 CARD32 pad1 B32;
+00114 CARD32 pad2 B32;
+00115 CARD32 pad3 B32;
+00116 CARD32 pad4 B32;
+00117 } <a class="code" href="structxDMXSyncReply.html">xDMXSyncReply</a>;
+00118 <span class="preprocessor">#define sz_xDMXSyncReply 32</span>
+00119 <span class="preprocessor"></span>
+<a name="l00121"></a><a class="code" href="structxDMXForceWindowCreationReq.html">00121</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00122 CARD8 reqType; <span class="comment">/* DMXCode */</span>
+00123 CARD8 dmxReqType; <span class="comment">/* X_DMXForceWindowCreation */</span>
+00124 CARD16 length B16;
+00125 CARD32 window B32;
+00126 } <a class="code" href="structxDMXForceWindowCreationReq.html">xDMXForceWindowCreationReq</a>;
+00127 <span class="preprocessor">#define sz_xDMXForceWindowCreationReq 8</span>
+00128 <span class="preprocessor"></span>
+<a name="l00130"></a><a class="code" href="structxDMXForceWindowCreationReply.html">00130</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00131 BYTE type; <span class="comment">/* X_Reply */</span>
+00132 CARD8 unused;
+00133 CARD16 sequenceNumber B16;
+00134 CARD32 length B32;
+00135 CARD32 status B32;
+00136 CARD32 pad0 B32;
+00137 CARD32 pad1 B32;
+00138 CARD32 pad2 B32;
+00139 CARD32 pad3 B32;
+00140 CARD32 pad4 B32;
+00141 } <a class="code" href="structxDMXForceWindowCreationReply.html">xDMXForceWindowCreationReply</a>;
+00142 <span class="preprocessor">#define sz_xDMXForceWindowCreationReply 32</span>
+00143 <span class="preprocessor"></span>
+<a name="l00145"></a><a class="code" href="structxDMXGetScreenCountReq.html">00145</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00146 CARD8 reqType; <span class="comment">/* DMXCode */</span>
+00147 CARD8 dmxReqType; <span class="comment">/* X_DMXGetScreenCount */</span>
+00148 CARD16 length B16;
+00149 } <a class="code" href="structxDMXGetScreenCountReq.html">xDMXGetScreenCountReq</a>;
+00150 <span class="preprocessor">#define sz_xDMXGetScreenCountReq 4</span>
+00151 <span class="preprocessor"></span>
+<a name="l00153"></a><a class="code" href="structxDMXGetScreenCountReply.html">00153</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00154 BYTE type; <span class="comment">/* X_Reply */</span>
+00155 CARD8 unused;
+00156 CARD16 sequenceNumber B16;
+00157 CARD32 length B32;
+00158 CARD32 screenCount B32;
+00159 CARD32 pad0 B32;
+00160 CARD32 pad1 B32;
+00161 CARD32 pad2 B32;
+00162 CARD32 pad3 B32;
+00163 CARD32 pad4 B32;
+00164 } <a class="code" href="structxDMXGetScreenCountReply.html">xDMXGetScreenCountReply</a>;
+00165 <span class="preprocessor">#define sz_xDMXGetScreenCountReply 32</span>
+00166 <span class="preprocessor"></span>
+<a name="l00168"></a><a class="code" href="structxDMXGetScreenAttributesReq.html">00168</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00169 CARD8 reqType; <span class="comment">/* DMXCode */</span>
+00170 CARD8 dmxReqType; <span class="comment">/* X_DMXGetScreenAttributes */</span>
+00171 CARD16 length B16;
+00172 CARD32 physicalScreen B32;
+00173 } <a class="code" href="structxDMXGetScreenAttributesReq.html">xDMXGetScreenAttributesReq</a>;
+00174 <span class="preprocessor">#define sz_xDMXGetScreenAttributesReq 8</span>
+00175 <span class="preprocessor"></span>
+<a name="l00177"></a><a class="code" href="structxDMXGetScreenAttributesReply.html">00177</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00178 BYTE type; <span class="comment">/* X_Reply */</span>
+00179 CARD8 unused;
+00180 CARD16 sequenceNumber B16;
+00181 CARD32 length B32;
+00182 CARD32 displayNameLength B32;
+00183 CARD32 logicalScreen B32;
+00184
+00185 CARD16 screenWindowWidth B16;
+00186 CARD16 screenWindowHeight B16;
+00187 INT16 screenWindowXoffset B16;
+00188 INT16 screenWindowYoffset B16;
+00189
+00190 CARD16 rootWindowWidth B16;
+00191 CARD16 rootWindowHeight B16;
+00192 INT16 rootWindowXoffset B16;
+00193 INT16 rootWindowYoffset B16;
+00194 INT16 rootWindowXorigin B16;
+00195 INT16 rootWindowYorigin B16;
+00196 } <a class="code" href="structxDMXGetScreenAttributesReply.html">xDMXGetScreenAttributesReply</a>;
+00197 <span class="preprocessor">#define sz_xDMXGetScreenAttributesReply 36</span>
+00198 <span class="preprocessor"></span>
+<a name="l00200"></a><a class="code" href="structxDMXChangeScreensAttributesReq.html">00200</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00201 CARD8 reqType; <span class="comment">/* DMXCode */</span>
+00202 CARD8 dmxReqType; <span class="comment">/* X_DMXChangeScreensAttributes */</span>
+00203 CARD16 length B16;
+00204 CARD32 screenCount B32;
+00205 CARD32 maskCount B32;
+00206 } <a class="code" href="structxDMXChangeScreensAttributesReq.html">xDMXChangeScreensAttributesReq</a>;
+00207 <span class="preprocessor">#define sz_xDMXChangeScreensAttributesReq 12</span>
+00208 <span class="preprocessor"></span>
+<a name="l00210"></a><a class="code" href="structxDMXChangeScreensAttributesReply.html">00210</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00211 BYTE type; <span class="comment">/* X_Reply */</span>
+00212 CARD8 unused;
+00213 CARD16 sequenceNumber B16;
+00214 CARD32 length B32;
+00215 CARD32 status B32;
+00216 CARD32 errorScreen B32;
+00217 CARD32 pad0 B32;
+00218 CARD32 pad1 B32;
+00219 CARD32 pad2 B32;
+00220 CARD32 pad3 B32;
+00221 } <a class="code" href="structxDMXChangeScreensAttributesReply.html">xDMXChangeScreensAttributesReply</a>;
+00222 <span class="preprocessor">#define sz_xDMXChangeScreensAttributesReply 32</span>
+00223 <span class="preprocessor"></span>
+<a name="l00225"></a><a class="code" href="structxDMXAddScreenReq.html">00225</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00226 CARD8 reqType; <span class="comment">/* DMXCode */</span>
+00227 CARD8 dmxReqType; <span class="comment">/* X_DMXAddScreen */</span>
+00228 CARD16 length B16;
+00229 CARD32 displayNameLength B32;
+00230 CARD32 physicalScreen B32;
+00231 CARD32 valueMask B32;
+00232 } <a class="code" href="structxDMXAddScreenReq.html">xDMXAddScreenReq</a>;
+00233 <span class="preprocessor">#define sz_xDMXAddScreenReq 16</span>
+00234 <span class="preprocessor"></span>
+<a name="l00236"></a><a class="code" href="structxDMXAddScreenReply.html">00236</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00237 BYTE type; <span class="comment">/* X_Reply */</span>
+00238 CARD8 unused;
+00239 CARD16 sequenceNumber B16;
+00240 CARD32 length B32;
+00241 CARD32 status B32;
+00242 CARD32 physicalScreen B32;
+00243 CARD32 pad0 B32;
+00244 CARD32 pad1 B32;
+00245 CARD32 pad2 B32;
+00246 CARD32 pad3 B32;
+00247 } <a class="code" href="structxDMXAddScreenReply.html">xDMXAddScreenReply</a>;
+00248 <span class="preprocessor">#define sz_xDMXAddScreenReply 32</span>
+00249 <span class="preprocessor"></span>
+<a name="l00251"></a><a class="code" href="structxDMXRemoveScreenReq.html">00251</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00252 CARD8 reqType; <span class="comment">/* DMXCode */</span>
+00253 CARD8 dmxReqType; <span class="comment">/* X_DMXRemoveScreen */</span>
+00254 CARD16 length B16;
+00255 CARD32 physicalScreen B32;
+00256 } <a class="code" href="structxDMXRemoveScreenReq.html">xDMXRemoveScreenReq</a>;
+00257 <span class="preprocessor">#define sz_xDMXRemoveScreenReq 8</span>
+00258 <span class="preprocessor"></span>
+<a name="l00260"></a><a class="code" href="structxDMXRemoveScreenReply.html">00260</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00261 BYTE type; <span class="comment">/* X_Reply */</span>
+00262 CARD8 unused;
+00263 CARD16 sequenceNumber B16;
+00264 CARD32 length B32;
+00265 CARD32 status B32;
+00266 CARD32 pad0 B32;
+00267 CARD32 pad1 B32;
+00268 CARD32 pad2 B32;
+00269 CARD32 pad3 B32;
+00270 CARD32 pad4 B32;
+00271 } <a class="code" href="structxDMXRemoveScreenReply.html">xDMXRemoveScreenReply</a>;
+00272 <span class="preprocessor">#define sz_xDMXRemoveScreenReply 32</span>
+00273 <span class="preprocessor"></span>
+<a name="l00275"></a><a class="code" href="structxDMXGetWindowAttributesReq.html">00275</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00276 CARD8 reqType; <span class="comment">/* DMXCode */</span>
+00277 CARD8 dmxReqType; <span class="comment">/* X_DMXGetWindowAttributes */</span>
+00278 CARD16 length B16;
+00279 CARD32 window B32;
+00280 } <a class="code" href="structxDMXGetWindowAttributesReq.html">xDMXGetWindowAttributesReq</a>;
+00281 <span class="preprocessor">#define sz_xDMXGetWindowAttributesReq 8</span>
+00282 <span class="preprocessor"></span>
+<a name="l00284"></a><a class="code" href="structxDMXGetWindowAttributesReply.html">00284</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00285 BYTE type; <span class="comment">/* X_Reply */</span>
+00286 CARD8 unused;
+00287 CARD16 sequenceNumber B16;
+00288 CARD32 length B32;
+00289 CARD32 screenCount B32;
+00290 CARD32 pad0 B32;
+00291 CARD32 pad1 B32;
+00292 CARD32 pad2 B32;
+00293 CARD32 pad3 B32;
+00294 CARD32 pad4 B32;
+00295 } <a class="code" href="structxDMXGetWindowAttributesReply.html">xDMXGetWindowAttributesReply</a>;
+00296 <span class="preprocessor">#define sz_xDMXGetWindowAttributesReply 32</span>
+00297 <span class="preprocessor"></span>
+<a name="l00299"></a><a class="code" href="structxDMXGetDesktopAttributesReq.html">00299</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00300 CARD8 reqType; <span class="comment">/* DMXCode */</span>
+00301 CARD8 dmxReqType; <span class="comment">/* X_DMXGetDesktopAttributes */</span>
+00302 CARD16 length B16;
+00303 } <a class="code" href="structxDMXGetDesktopAttributesReq.html">xDMXGetDesktopAttributesReq</a>;
+00304 <span class="preprocessor">#define sz_xDMXGetDesktopAttributesReq 4</span>
+00305 <span class="preprocessor"></span>
+<a name="l00307"></a><a class="code" href="structxDMXGetDesktopAttributesReply.html">00307</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00308 BYTE type; <span class="comment">/* X_Reply */</span>
+00309 CARD8 unused;
+00310 CARD16 sequenceNumber B16;
+00311 CARD32 length B32;
+00312 INT16 width;
+00313 INT16 height;
+00314 INT16 shiftX;
+00315 INT16 shiftY;
+00316 CARD32 pad0 B32;
+00317 CARD32 pad1 B32;
+00318 CARD32 pad2 B32;
+00319 CARD32 pad3 B32;
+00320 } <a class="code" href="structxDMXGetDesktopAttributesReply.html">xDMXGetDesktopAttributesReply</a>;
+00321 <span class="preprocessor">#define sz_xDMXGetDesktopAttributesReply 32</span>
+00322 <span class="preprocessor"></span>
+<a name="l00324"></a><a class="code" href="structxDMXChangeDesktopAttributesReq.html">00324</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00325 CARD8 reqType; <span class="comment">/* DMXCode */</span>
+00326 CARD8 dmxReqType; <span class="comment">/* X_DMXChangeDesktopAttributes */</span>
+00327 CARD16 length B16;
+00328 CARD32 valueMask B32;
+00329 } <a class="code" href="structxDMXChangeDesktopAttributesReq.html">xDMXChangeDesktopAttributesReq</a>;
+00330 <span class="preprocessor">#define sz_xDMXChangeDesktopAttributesReq 8</span>
+00331 <span class="preprocessor"></span>
+<a name="l00333"></a><a class="code" href="structxDMXChangeDesktopAttributesReply.html">00333</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00334 BYTE type; <span class="comment">/* X_Reply */</span>
+00335 CARD8 unused;
+00336 CARD16 sequenceNumber B16;
+00337 CARD32 length B32;
+00338 CARD32 status B32;
+00339 CARD32 pad0 B32;
+00340 CARD32 pad1 B32;
+00341 CARD32 pad2 B32;
+00342 CARD32 pad3 B32;
+00343 CARD32 pad4 B32;
+00344 } <a class="code" href="structxDMXChangeDesktopAttributesReply.html">xDMXChangeDesktopAttributesReply</a>;
+00345 <span class="preprocessor">#define sz_xDMXChangeDesktopAttributesReply 32</span>
+00346 <span class="preprocessor"></span>
+<a name="l00348"></a><a class="code" href="structxDMXGetInputCountReq.html">00348</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00349 CARD8 reqType; <span class="comment">/* DMXCode */</span>
+00350 CARD8 dmxReqType; <span class="comment">/* X_DMXGetInputCount */</span>
+00351 CARD16 length B16;
+00352 } <a class="code" href="structxDMXGetInputCountReq.html">xDMXGetInputCountReq</a>;
+00353 <span class="preprocessor">#define sz_xDMXGetInputCountReq 4</span>
+00354 <span class="preprocessor"></span>
+<a name="l00356"></a><a class="code" href="structxDMXGetInputCountReply.html">00356</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00357 BYTE type; <span class="comment">/* X_Reply */</span>
+00358 CARD8 unused;
+00359 CARD16 sequenceNumber B16;
+00360 CARD32 length B32;
+00361 CARD32 inputCount B32;
+00362 CARD32 pad0 B32;
+00363 CARD32 pad1 B32;
+00364 CARD32 pad2 B32;
+00365 CARD32 pad3 B32;
+00366 CARD32 pad4 B32;
+00367 } <a class="code" href="structxDMXGetInputCountReply.html">xDMXGetInputCountReply</a>;
+00368 <span class="preprocessor">#define sz_xDMXGetInputCountReply 32</span>
+00369 <span class="preprocessor"></span>
+<a name="l00371"></a><a class="code" href="structxDMXGetInputAttributesReq.html">00371</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00372 CARD8 reqType; <span class="comment">/* DMXCode */</span>
+00373 CARD8 dmxReqType; <span class="comment">/* X_DMXGetInputAttributes */</span>
+00374 CARD16 length B16;
+00375 CARD32 deviceId B32;
+00376 } <a class="code" href="structxDMXGetInputAttributesReq.html">xDMXGetInputAttributesReq</a>;
+00377 <span class="preprocessor">#define sz_xDMXGetInputAttributesReq 8</span>
+00378 <span class="preprocessor"></span>
+<a name="l00380"></a><a class="code" href="structxDMXGetInputAttributesReply.html">00380</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00381 BYTE type; <span class="comment">/* X_Reply */</span>
+00382 CARD8 unused;
+00383 CARD16 sequenceNumber B16;
+00384 CARD32 length B32;
+00385 CARD32 inputType B32;
+00386 CARD32 physicalScreen B32;
+00387 CARD32 physicalId B32;
+00388 CARD32 nameLength B32;
+00389 BOOL isCore;
+00390 BOOL sendsCore;
+00391 BOOL detached;
+00392 CARD8 pad0;
+00393 CARD32 pad1 B32;
+00394 } <a class="code" href="structxDMXGetInputAttributesReply.html">xDMXGetInputAttributesReply</a>;
+00395 <span class="preprocessor">#define sz_xDMXGetInputAttributesReply 32</span>
+00396 <span class="preprocessor"></span>
+<a name="l00398"></a><a class="code" href="structxDMXAddInputReq.html">00398</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00399 CARD8 reqType; <span class="comment">/* DMXCode */</span>
+00400 CARD8 dmxReqType; <span class="comment">/* X_DMXAddInput */</span>
+00401 CARD16 length B16;
+00402 CARD32 displayNameLength B32;
+00403 CARD32 valueMask;
+00404 } <a class="code" href="structxDMXAddInputReq.html">xDMXAddInputReq</a>;
+00405 <span class="preprocessor">#define sz_xDMXAddInputReq 12</span>
+00406 <span class="preprocessor"></span>
+<a name="l00408"></a><a class="code" href="structxDMXAddInputReply.html">00408</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00409 BYTE type; <span class="comment">/* X_Reply */</span>
+00410 CARD8 unused;
+00411 CARD16 sequenceNumber B16;
+00412 CARD32 length B32;
+00413 CARD32 status B32;
+00414 CARD32 physicalId B32;
+00415 CARD32 pad0 B32;
+00416 CARD32 pad1 B32;
+00417 CARD32 pad2 B32;
+00418 CARD32 pad3 B32;
+00419 } <a class="code" href="structxDMXAddInputReply.html">xDMXAddInputReply</a>;
+00420 <span class="preprocessor">#define sz_xDMXAddInputReply 32</span>
+00421 <span class="preprocessor"></span>
+<a name="l00423"></a><a class="code" href="structxDMXRemoveInputReq.html">00423</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00424 CARD8 reqType; <span class="comment">/* DMXCode */</span>
+00425 CARD8 dmxReqType; <span class="comment">/* X_DMXRemoveInput */</span>
+00426 CARD16 length B16;
+00427 CARD32 physicalId B32;
+00428 } <a class="code" href="structxDMXRemoveInputReq.html">xDMXRemoveInputReq</a>;
+00429 <span class="preprocessor">#define sz_xDMXRemoveInputReq 8</span>
+00430 <span class="preprocessor"></span>
+<a name="l00432"></a><a class="code" href="structxDMXRemoveInputReply.html">00432</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
+00433 BYTE type;
+00434 CARD8 unused;
+00435 CARD16 sequenceNumber B16;
+00436 CARD32 length B32;
+00437 CARD32 status B32;
+00438 CARD32 pad0 B32;
+00439 CARD32 pad1 B32;
+00440 CARD32 pad2 B32;
+00441 CARD32 pad3 B32;
+00442 CARD32 pad4 B32;
+00443 } <a class="code" href="structxDMXRemoveInputReply.html">xDMXRemoveInputReply</a>;
+00444 <span class="preprocessor">#define sz_xDMXRemoveInputReply 32</span>
+00445 <span class="preprocessor"></span>
+00446 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxproto_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxproto_8h.html
new file mode 100644
index 000000000..10353e338
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxproto_8h.html
@@ -0,0 +1,89 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxproto.h File Reference</h1>
+<p>
+<a href="dmxproto_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXAddInputReply.html">xDMXAddInputReply</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXAddInputReq.html">xDMXAddInputReq</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXAddScreenReply.html">xDMXAddScreenReply</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXAddScreenReq.html">xDMXAddScreenReq</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXChangeDesktopAttributesReply.html">xDMXChangeDesktopAttributesReply</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXChangeDesktopAttributesReq.html">xDMXChangeDesktopAttributesReq</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXChangeScreensAttributesReply.html">xDMXChangeScreensAttributesReply</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXChangeScreensAttributesReq.html">xDMXChangeScreensAttributesReq</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXForceWindowCreationReply.html">xDMXForceWindowCreationReply</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXForceWindowCreationReq.html">xDMXForceWindowCreationReq</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXGetDesktopAttributesReply.html">xDMXGetDesktopAttributesReply</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXGetDesktopAttributesReq.html">xDMXGetDesktopAttributesReq</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXGetInputAttributesReply.html">xDMXGetInputAttributesReply</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXGetInputAttributesReq.html">xDMXGetInputAttributesReq</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXGetInputCountReply.html">xDMXGetInputCountReply</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXGetInputCountReq.html">xDMXGetInputCountReq</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXGetScreenAttributesReply.html">xDMXGetScreenAttributesReply</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXGetScreenAttributesReq.html">xDMXGetScreenAttributesReq</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXGetScreenCountReply.html">xDMXGetScreenCountReply</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXGetScreenCountReq.html">xDMXGetScreenCountReq</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXGetWindowAttributesReply.html">xDMXGetWindowAttributesReply</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXGetWindowAttributesReq.html">xDMXGetWindowAttributesReq</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXQueryVersionReply.html">xDMXQueryVersionReply</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXQueryVersionReq.html">xDMXQueryVersionReq</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXRemoveInputReply.html">xDMXRemoveInputReply</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXRemoveInputReq.html">xDMXRemoveInputReq</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXRemoveScreenReply.html">xDMXRemoveScreenReply</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXRemoveScreenReq.html">xDMXRemoveScreenReq</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXSyncReply.html">xDMXSyncReply</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structxDMXSyncReq.html">xDMXSyncReq</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file describes the structures necessary to implement the wire protocol for the DMX protocol extension. It should be included only in files that implement the client-side (or server-side) part of the protocol (i.e., client-side applications should <b>not</b> include this file). <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxscrinit_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxscrinit_8c.html
new file mode 100644
index 000000000..d2425c3be
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxscrinit_8c.html
@@ -0,0 +1,378 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxscrinit.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxshadow_8h-source.html">dmxshadow.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxscrinit_8h-source.html">dmxscrinit.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcursor_8h-source.html">dmxcursor.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxgc_8h-source.html">dmxgc.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxgcops_8h-source.html">dmxgcops.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxwindow_8h-source.html">dmxwindow.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxpixmap_8h-source.html">dmxpixmap.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxfont_8h-source.html">dmxfont.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcmap_8h-source.html">dmxcmap.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxprop_8h-source.html">dmxprop.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxdpms_8h-source.html">dmxdpms.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxpict_8h-source.html">dmxpict.h</a>"</code><br>
+<code>#include "fb.h"</code><br>
+<code>#include "mipointer.h"</code><br>
+<code>#include "micmap.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxscrinit_8c.html#a9">dmxCloseScreen</a> (int idx, ScreenPtr pScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxscrinit_8c.html#a11">dmxBEScreenInit</a> (int idx, ScreenPtr pScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxscrinit_8c.html#a12">dmxScreenInit</a> (int idx, ScreenPtr pScreen, int argc, char *argv[])</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxscrinit_8c.html#a13">dmxBECloseScreen</a> (ScreenPtr pScreen)</td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxscrinit_8c.html#a2">dmxGCPrivateIndex</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxscrinit_8c.html#a3">dmxWinPrivateIndex</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxscrinit_8c.html#a4">dmxFontPrivateIndex</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxscrinit_8c.html#a5">dmxScreenPrivateIndex</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxscrinit_8c.html#a6">dmxColormapPrivateIndex</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxscrinit_8c.html#a7">dmxPictPrivateIndex</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxscrinit_8c.html#a8">dmxGlyphSetPrivateIndex</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides support for screen initialization.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a13" doxytag="dmxscrinit.c::dmxBECloseScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBECloseScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Close the <em>pScreen</em> resources on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxscrinit.c::dmxBEScreenInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBEScreenInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>idx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize the parts of screen <em>idx</em> that require access to the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxscrinit.c::dmxCloseScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxCloseScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>idx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Close screen number <em>idx</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxscrinit.c::dmxScreenInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxScreenInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>idx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>argc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>argv</em>[]</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize screen number <em>idx</em>. </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a6" doxytag="dmxscrinit.c::dmxColormapPrivateIndex" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxscrinit_8c.html#a6">dmxColormapPrivateIndex</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Private index for Colormaps </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxscrinit.c::dmxFontPrivateIndex" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxscrinit_8c.html#a4">dmxFontPrivateIndex</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Private index for Fonts </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxscrinit.c::dmxGCPrivateIndex" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxscrinit_8c.html#a2">dmxGCPrivateIndex</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Private index for GCs </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxscrinit.c::dmxGlyphSetPrivateIndex" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxscrinit_8c.html#a8">dmxGlyphSetPrivateIndex</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Private index for GlyphSets </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxscrinit.c::dmxPictPrivateIndex" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxscrinit_8c.html#a7">dmxPictPrivateIndex</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Private index for Picts </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxscrinit.c::dmxScreenPrivateIndex" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxscrinit_8h.html#a0">dmxScreenPrivateIndex</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Private index for Screens </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxscrinit.c::dmxWinPrivateIndex" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxwindow_8h.html#a10">dmxWinPrivateIndex</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Private index for Windows </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxscrinit_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxscrinit_8h-source.html
new file mode 100644
index 000000000..ab7b22fd3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxscrinit_8h-source.html
@@ -0,0 +1,70 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxscrinit.h</h1><a href="dmxscrinit_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Kevin E. Martin &lt;kem@redhat.com&gt;</span>
+00032 <span class="comment"> * David H. Dawes &lt;dawes@xfree86.org&gt;</span>
+00033 <span class="comment"> *</span>
+00034 <span class="comment"> */</span>
+00035
+00039 <span class="preprocessor">#ifndef DMXSCRINIT_H</span>
+00040 <span class="preprocessor"></span><span class="preprocessor">#define DMXSCRINIT_H</span>
+00041 <span class="preprocessor"></span>
+00042 <span class="preprocessor">#include "scrnintstr.h"</span>
+00043
+<a name="l00045"></a><a class="code" href="dmxscrinit_8h.html#a0">00045</a> <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxscrinit_8c.html#a5">dmxScreenPrivateIndex</a>;
+00046
+00047 <span class="keyword">extern</span> Bool <a class="code" href="dmxscrinit_8c.html#a12">dmxScreenInit</a>(<span class="keywordtype">int</span> idx, ScreenPtr pScreen, <span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]);
+00048
+00049 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxscrinit_8c.html#a11">dmxBEScreenInit</a>(<span class="keywordtype">int</span> idx, ScreenPtr pScreen);
+00050 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxscrinit_8c.html#a13">dmxBECloseScreen</a>(ScreenPtr pScreen);
+00051
+00052 <span class="preprocessor">#endif </span><span class="comment">/* DMXSCRINIT_H */</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxscrinit_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxscrinit_8h.html
new file mode 100644
index 000000000..72415ef97
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxscrinit_8h.html
@@ -0,0 +1,181 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxscrinit.h File Reference</h1><code>#include "scrnintstr.h"</code><br>
+
+<p>
+<a href="dmxscrinit_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxscrinit_8h.html#a1">dmxScreenInit</a> (int idx, ScreenPtr pScreen, int argc, char *argv[])</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxscrinit_8h.html#a2">dmxBEScreenInit</a> (int idx, ScreenPtr pScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxscrinit_8h.html#a3">dmxBECloseScreen</a> (ScreenPtr pScreen)</td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxscrinit_8h.html#a0">dmxScreenPrivateIndex</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for screen initialization. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxscrinit_8c.html">dmxscrinit.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a3" doxytag="dmxscrinit.h::dmxBECloseScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBECloseScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Close the <em>pScreen</em> resources on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxscrinit.h::dmxBEScreenInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxBEScreenInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>idx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize the parts of screen <em>idx</em> that require access to the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxscrinit.h::dmxScreenInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxScreenInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">int&nbsp;</td>
+ <td class="mdname" nowrap> <em>idx</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>argc</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>argv</em>[]</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize screen number <em>idx</em>. </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxscrinit.h::dmxScreenPrivateIndex" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxscrinit_8h.html#a0">dmxScreenPrivateIndex</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Private index for Screens </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxshadow_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxshadow_8c.html
new file mode 100644
index 000000000..0db2bfa8b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxshadow_8c.html
@@ -0,0 +1,71 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxshadow.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxshadow_8h-source.html">dmxshadow.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxshadow_8c.html#a0">dmxShadowUpdateProc</a> (ScreenPtr pScreen, shadowBufPtr pBuf)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides support for the shadow frame buffer.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxshadow.c::dmxShadowUpdateProc" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxShadowUpdateProc </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>shadowBufPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pBuf</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Update the screen from the shadow frame buffer. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxshadow_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxshadow_8h-source.html
new file mode 100644
index 000000000..2253c350b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxshadow_8h-source.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxshadow.h</h1><a href="dmxshadow_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Kevin E. Martin &lt;kem@redhat.com&gt;</span>
+00032 <span class="comment"> * David H. Dawes &lt;dawes@xfree86.org&gt;</span>
+00033 <span class="comment"> *</span>
+00034 <span class="comment"> */</span>
+00035
+00039 <span class="preprocessor">#ifndef DMXSHADOW_H</span>
+00040 <span class="preprocessor"></span><span class="preprocessor">#define DMXSHADOW_H</span>
+00041 <span class="preprocessor"></span>
+00042 <span class="preprocessor">#include "shadow.h"</span>
+00043 <span class="preprocessor">#include "scrnintstr.h"</span>
+00044
+00045 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxshadow_8c.html#a0">dmxShadowUpdateProc</a>(ScreenPtr pScreen, shadowBufPtr pBuf);
+00046
+00047 <span class="preprocessor">#endif </span><span class="comment">/* DMXSHADOW_H */</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxshadow_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxshadow_8h.html
new file mode 100644
index 000000000..05e148ad3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxshadow_8h.html
@@ -0,0 +1,73 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxshadow.h File Reference</h1><code>#include "shadow.h"</code><br>
+<code>#include "scrnintstr.h"</code><br>
+
+<p>
+<a href="dmxshadow_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxshadow_8h.html#a0">dmxShadowUpdateProc</a> (ScreenPtr pScreen, shadowBufPtr pBuf)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for shadow framebuffer support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxshadow_8c.html">dmxshadow.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxshadow.h::dmxShadowUpdateProc" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxShadowUpdateProc </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>shadowBufPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pBuf</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Update the screen from the shadow frame buffer. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsigio_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsigio_8c.html
new file mode 100644
index 000000000..761748dae
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsigio_8c.html
@@ -0,0 +1,230 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxsigio.c File Reference</h1><code>#include "inputstr.h"</code><br>
+<code>#include "<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsigio_8h-source.html">dmxsigio.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxevents_8h-source.html">dmxevents.h</a>"</code><br>
+<code>#include &lt;signal.h&gt;</code><br>
+<code>#include &lt;unistd.h&gt;</code><br>
+<code>#include &lt;sys/fcntl.h&gt;</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsigio_8c.html#a5">dmxSigioBlock</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsigio_8c.html#a6">dmxSigioUnblock</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsigio_8c.html#a11">dmxSigioEnableInput</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsigio_8c.html#a12">dmxSigioDisableInput</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsigio_8c.html#a13">dmxSigioRegister</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput, int fd)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsigio_8c.html#a14">dmxSigioUnregister</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Provides an interface for handling SIGIO signals for input devices.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a5" doxytag="dmxsigio.c::dmxSigioBlock" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSigioBlock </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Block SIGIO handling. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxsigio.c::dmxSigioDisableInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSigioDisableInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Disable SIGIO handling. This removes the hanlder from the OS. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxsigio.c::dmxSigioEnableInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSigioEnableInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Enable SIGIO handling. This instantiates the handler with the OS. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmxsigio.c::dmxSigioRegister" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSigioRegister </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxInput</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>fd</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Make a note that the input device described in <em>dmxInput</em> will be using the file descriptor <em>fd</em> for SIGIO signals. Calls AddEnabledDevice ifi SIGIO handling has been enabled with <a class="el" href="dmxsigio_8c.html#a11">dmxSigioEnableInput()</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxsigio.c::dmxSigioUnblock" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSigioUnblock </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Unblock SIGIO handling. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmxsigio.c::dmxSigioUnregister" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSigioUnregister </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxInput</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Remove the notes that <em>dmxInput</em> is using any file descriptors for SIGIO signals. Calls RemoveEnabledDevice. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsigio_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsigio_8h-source.html
new file mode 100644
index 000000000..4f41eb80e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsigio_8h-source.html
@@ -0,0 +1,65 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxsigio.h</h1><a href="dmxsigio_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _DMXSIGIO_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _DMXSIGIO_H_</span>
+00040 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxsigio_8c.html#a5">dmxSigioBlock</a>(<span class="keywordtype">void</span>);
+00041 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxsigio_8c.html#a6">dmxSigioUnblock</a>(<span class="keywordtype">void</span>);
+00042 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxsigio_8c.html#a11">dmxSigioEnableInput</a>(<span class="keywordtype">void</span>);
+00043 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxsigio_8c.html#a12">dmxSigioDisableInput</a>(<span class="keywordtype">void</span>);
+00044 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxsigio_8c.html#a13">dmxSigioRegister</a>(<a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput, <span class="keywordtype">int</span> fd);
+00045 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxsigio_8c.html#a14">dmxSigioUnregister</a>(<a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput);
+00046 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsigio_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsigio_8h.html
new file mode 100644
index 000000000..1e55b7b83
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsigio_8h.html
@@ -0,0 +1,226 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxsigio.h File Reference</h1>
+<p>
+<a href="dmxsigio_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsigio_8h.html#a0">dmxSigioBlock</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsigio_8h.html#a1">dmxSigioUnblock</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsigio_8h.html#a2">dmxSigioEnableInput</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsigio_8h.html#a3">dmxSigioDisableInput</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsigio_8h.html#a4">dmxSigioRegister</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput, int fd)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsigio_8h.html#a5">dmxSigioUnregister</a> (<a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *dmxInput)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to SIGIO handling support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxsigio_8c.html">dmxsigio.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxsigio.h::dmxSigioBlock" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSigioBlock </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Block SIGIO handling. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxsigio.h::dmxSigioDisableInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSigioDisableInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Disable SIGIO handling. This removes the hanlder from the OS. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxsigio.h::dmxSigioEnableInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSigioEnableInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Enable SIGIO handling. This instantiates the handler with the OS. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxsigio.h::dmxSigioRegister" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSigioRegister </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxInput</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>fd</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Make a note that the input device described in <em>dmxInput</em> will be using the file descriptor <em>fd</em> for SIGIO signals. Calls AddEnabledDevice ifi SIGIO handling has been enabled with <a class="el" href="dmxsigio_8c.html#a11">dmxSigioEnableInput()</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxsigio.h::dmxSigioUnblock" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSigioUnblock </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Unblock SIGIO handling. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxsigio.h::dmxSigioUnregister" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSigioUnregister </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dmxInput</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Remove the notes that <em>dmxInput</em> is using any file descriptors for SIGIO signals. Calls RemoveEnabledDevice. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxstat_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxstat_8c.html
new file mode 100644
index 000000000..9a9ecfc65
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxstat_8c.html
@@ -0,0 +1,274 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxstat.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxstat_8h-source.html">dmxstat.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxlog_8h-source.html">dmxlog.h</a>"</code><br>
+<code>#include "Xos.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXStatAvg.html">_DMXStatAvg</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXStatInfo.html">_DMXStatInfo</a></td></tr>
+
+<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__DMXStatAvg.html">_DMXStatAvg</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8c.html#a0">DMXStatAvg</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8c.html#a6">dmxStatActivate</a> (const char *interval, const char *displays)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__DMXStatInfo.html">DMXStatInfo</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8c.html#a7">dmxStatAlloc</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8c.html#a8">dmxStatFree</a> (<a class="el" href="struct__DMXStatInfo.html">DMXStatInfo</a> *pt)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8c.html#a10">dmxStatSync</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, struct timeval *stop, struct timeval *start, unsigned long pending)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8c.html#a12">dmxStatInit</a> (void)</td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8c.html#a1">dmxStatInterval</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+The DMX server code is written to call <a class="el" href="dmxsync_8c.html#a9">dmxSync()</a> whenever an XSync() might be necessary. However, since XSync() requires a two way communication with the other X server, eliminating unnecessary XSync() calls is a key performance optimization. Support for this optimization is provided in #dmxsync.c. This file provides routines that evaluate this optimization by counting the number of XSync() calls and monitoring their latency. This functionality can be turned on using the -stat command-line parameter.<hr><h2>Typedef Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxstat.c::DMXStatAvg" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__DMXStatAvg.html">_DMXStatAvg</a> <a class="el" href="struct__DMXStatAvg.html">DMXStatAvg</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Used to compute a running average of value. </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a6" doxytag="dmxstat.c::dmxStatActivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxStatActivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>interval</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>displays</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn on XSync statistic gathering and printing. Print every <em>interval</em> seconds, with lines for the first <em>displays</em>. If <em>interval</em> is NULL, 1 will be used. If <em>displays</em> is NULL, 0 will be used (meaning a line for every display will be printed). Note that this function takes string arguments because it will usually be called from <a class="el" href="dmxinit_8c.html#a40">ddxProcessArgument</a> in #dmxinit.c. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxstat.c::dmxStatAlloc" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__DMXStatInfo.html">DMXStatInfo</a>* dmxStatAlloc </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Allocate a <em>DMXStatInfo</em> structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxstat.c::dmxStatFree" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxStatFree </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXStatInfo.html">DMXStatInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pt</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Free the memory used by a <em>DMXStatInfo</em> structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxstat.c::dmxStatInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxStatInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Try to initialize the statistic gathering and printing routines. Initialization only takes place if <a class="el" href="dmxstat_8h.html#a6">dmxStatActivate</a> has already been called. We don't need the same generation protection that we used in dmxSyncInit because our timer is always on a queue -- hence, server generation will always free it. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxstat.c::dmxStatSync" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxStatSync </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>struct timeval *&nbsp;</td>
+ <td class="mdname" nowrap> <em>stop</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>struct timeval *&nbsp;</td>
+ <td class="mdname" nowrap> <em>start</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>pending</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Note that a XSync() was just done on <em>dmxScreen</em> with the <em>start</em> and <em>stop</em> times (from gettimeofday()) and the number of pending-but-not-yet-processed XSync requests. This routine is called from #dmxDoSync in #dmxsync.c </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a1" doxytag="dmxstat.c::dmxStatInterval" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxstat_8h.html#a5">dmxStatInterval</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Only for <a class="el" href="dmxstat_8c.html">dmxstat.c</a> and <a class="el" href="dmxsync_8c.html">dmxsync.c</a> </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxstat_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxstat_8h-source.html
new file mode 100644
index 000000000..d7579a5d8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxstat_8h-source.html
@@ -0,0 +1,74 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxstat.h</h1><a href="dmxstat_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _DMXSTAT_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _DMXSTAT_H_</span>
+00040 <span class="preprocessor"></span>
+<a name="l00041"></a><a class="code" href="dmxstat_8h.html#a0">00041</a> <span class="preprocessor">#define DMX_STAT_LENGTH 10 </span>
+<a name="l00042"></a><a class="code" href="dmxstat_8h.html#a1">00042</a> <span class="preprocessor">#define DMX_STAT_INTERVAL 1000 </span>
+<a name="l00043"></a><a class="code" href="dmxstat_8h.html#a2">00043</a> <span class="preprocessor">#define DMX_STAT_BINS 3 </span>
+<a name="l00044"></a><a class="code" href="dmxstat_8h.html#a3">00044</a> <span class="preprocessor">#define DMX_STAT_BIN0 10000 </span>
+<a name="l00045"></a><a class="code" href="dmxstat_8h.html#a4">00045</a> <span class="preprocessor">#define DMX_STAT_BINMULT 100 </span>
+<a name="l00047"></a><a class="code" href="dmxstat_8h.html#a5">00047</a> <span class="preprocessor">extern int dmxStatInterval; </span>
+00048 <span class="preprocessor">extern void dmxStatActivate(const char *interval, const char *displays);</span>
+00049 <span class="preprocessor"></span><span class="keyword">extern</span> <a class="code" href="struct__DMXStatInfo.html">DMXStatInfo</a> *<a class="code" href="dmxstat_8c.html#a7">dmxStatAlloc</a>(<span class="keywordtype">void</span>);
+00050 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxstat_8c.html#a8">dmxStatFree</a>(<a class="code" href="struct__DMXStatInfo.html">DMXStatInfo</a> *);
+00051 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxstat_8c.html#a12">dmxStatInit</a>(<span class="keywordtype">void</span>);
+00052 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxstat_8c.html#a10">dmxStatSync</a>(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen,
+00053 <span class="keyword">struct</span> timeval *stop, <span class="keyword">struct</span> timeval *start,
+00054 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> pending);
+00055
+00056 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxstat_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxstat_8h.html
new file mode 100644
index 000000000..d4fcb0d9c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxstat_8h.html
@@ -0,0 +1,364 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxstat.h File Reference</h1>
+<p>
+<a href="dmxstat_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Defines</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8h.html#a0">DMX_STAT_LENGTH</a>&nbsp;&nbsp;&nbsp;10</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8h.html#a1">DMX_STAT_INTERVAL</a>&nbsp;&nbsp;&nbsp;1000</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8h.html#a2">DMX_STAT_BINS</a>&nbsp;&nbsp;&nbsp;3</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8h.html#a3">DMX_STAT_BIN0</a>&nbsp;&nbsp;&nbsp;10000</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8h.html#a4">DMX_STAT_BINMULT</a>&nbsp;&nbsp;&nbsp;100</td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8h.html#a6">dmxStatActivate</a> (const char *interval, const char *displays)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__DMXStatInfo.html">DMXStatInfo</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8h.html#a7">dmxStatAlloc</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8h.html#a8">dmxStatFree</a> (<a class="el" href="struct__DMXStatInfo.html">DMXStatInfo</a> *)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8h.html#a9">dmxStatInit</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8h.html#a10">dmxStatSync</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, struct timeval *stop, struct timeval *start, unsigned long pending)</td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxstat_8h.html#a5">dmxStatInterval</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for statistic gathering interface. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxstat_8c.html">dmxstat.c</a></dd></dl>
+<hr><h2>Define Documentation</h2>
+<a class="anchor" name="a3" doxytag="dmxstat.h::DMX_STAT_BIN0" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_STAT_BIN0&nbsp;&nbsp;&nbsp;10000
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+us for bin[0] </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="dmxstat.h::DMX_STAT_BINMULT" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_STAT_BINMULT&nbsp;&nbsp;&nbsp;100
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+multiplier for next bin[] </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxstat.h::DMX_STAT_BINS" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_STAT_BINS&nbsp;&nbsp;&nbsp;3
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+number of bins </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxstat.h::DMX_STAT_INTERVAL" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_STAT_INTERVAL&nbsp;&nbsp;&nbsp;1000
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+msec between printouts </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxstat.h::DMX_STAT_LENGTH" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_STAT_LENGTH&nbsp;&nbsp;&nbsp;10
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+number of events for moving average </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a6" doxytag="dmxstat.h::dmxStatActivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxStatActivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>interval</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>displays</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn on XSync statistic gathering and printing. Print every <em>interval</em> seconds, with lines for the first <em>displays</em>. If <em>interval</em> is NULL, 1 will be used. If <em>displays</em> is NULL, 0 will be used (meaning a line for every display will be printed). Note that this function takes string arguments because it will usually be called from <a class="el" href="dmxinit_8c.html#a40">ddxProcessArgument</a> in #dmxinit.c. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxstat.h::dmxStatAlloc" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__DMXStatInfo.html">DMXStatInfo</a>* dmxStatAlloc </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Allocate a <em>DMXStatInfo</em> structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxstat.h::dmxStatFree" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxStatFree </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXStatInfo.html">DMXStatInfo</a> *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pt</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Free the memory used by a <em>DMXStatInfo</em> structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxstat.h::dmxStatInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxStatInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Try to initialize the statistic gathering and printing routines. Initialization only takes place if <a class="el" href="dmxstat_8h.html#a6">dmxStatActivate</a> has already been called. We don't need the same generation protection that we used in dmxSyncInit because our timer is always on a queue -- hence, server generation will always free it. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxstat.h::dmxStatSync" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxStatSync </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>struct timeval *&nbsp;</td>
+ <td class="mdname" nowrap> <em>stop</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>struct timeval *&nbsp;</td>
+ <td class="mdname" nowrap> <em>start</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>pending</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Note that a XSync() was just done on <em>dmxScreen</em> with the <em>start</em> and <em>stop</em> times (from gettimeofday()) and the number of pending-but-not-yet-processed XSync requests. This routine is called from #dmxDoSync in #dmxsync.c </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a5" doxytag="dmxstat.h::dmxStatInterval" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxstat_8h.html#a5">dmxStatInterval</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Only for <a class="el" href="dmxstat_8c.html">dmxstat.c</a> and <a class="el" href="dmxsync_8c.html">dmxsync.c</a> </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsync_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsync_8c.html
new file mode 100644
index 000000000..76a940dd9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsync_8c.html
@@ -0,0 +1,139 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxsync.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxstat_8h-source.html">dmxstat.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxlog_8h-source.html">dmxlog.h</a>"</code><br>
+<code>#include &lt;sys/time.h&gt;</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsync_8c.html#a7">dmxSyncActivate</a> (const char *interval)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsync_8c.html#a8">dmxSyncInit</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsync_8c.html#a9">dmxSync</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, Bool now)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+The DMX server code is written to call <a class="el" href="dmxsync_8c.html#a9">dmxSync()</a> whenever an XSync() might be necessary. However, since XSync() requires a two way communication with the other X server, eliminating unnecessary XSync() calls is a key performance optimization. Support for this optimization is provided here. Statistics about XSync() calls and latency are gathered in #dmxstat.c.<p>
+During the initial conversion from calling XSync() immediately to the XSync() batching method implemented in this file, it was noted that, out of more than 300 <em>x11perf</em> tests, 8 tests became more than 100 times faster, with 68 more than 50X faster, 114 more than 10X faster, and 181 more than 2X faster.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a9" doxytag="dmxsync.c::dmxSync" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSync </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Bool&nbsp;</td>
+ <td class="mdname" nowrap> <em>now</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Request an XSync() to the display used by <em>dmxScreen</em>. If <em>now</em> is TRUE, call XSync() immediately instead of waiting for the next XSync() batching point. Note that if XSync() batching was deselected with <a class="el" href="dmxsync_8c.html#a7">dmxSyncActivate()</a> before <a class="el" href="dmxsync_8c.html#a8">dmxSyncInit()</a> was called, then no XSync() batching is performed and this function always calles XSync() immediately.<p>
+(Note that this function uses TimerSet but works correctly in the face of a server generation. See the source for details.)<p>
+If <em>dmxScreen</em> is <em>NULL</em>, then all pending syncs will be flushed immediately. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxsync.c::dmxSyncActivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSyncActivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>interval</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Request the XSync() batching optimization with the specified <em>interval</em> (in mS). If the <em>interval</em> is 0, 100mS is used. If the <em>interval</em> is less than 0, then the XSync() batching optimization is not requested (e.g., so the -syncbatch -1 command line option can turn off the default 100mS XSync() batching).<p>
+Note that the parameter to this routine is a string, since it will usually be called from <a class="el" href="dmxinit_8c.html#a40">ddxProcessArgument</a> in #dmxinit.c </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxsync.c::dmxSyncInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSyncInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize the XSync() batching optimization, but only if <a class="el" href="dmxsync_8h.html#a0">dmxSyncActivate</a> was last called with a non-negative value. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsync_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsync_8h-source.html
new file mode 100644
index 000000000..a8c4f0d11
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsync_8h-source.html
@@ -0,0 +1,63 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxsync.h</h1><a href="dmxsync_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _DMXSYNC_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _DMXSYNC_H_</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxsync_8c.html#a7">dmxSyncActivate</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *interval);
+00042 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxsync_8c.html#a8">dmxSyncInit</a>(<span class="keywordtype">void</span>);
+00043 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxsync_8c.html#a9">dmxSync</a>(<a class="code" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, Bool now);
+00044 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsync_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsync_8h.html
new file mode 100644
index 000000000..53edcef9c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsync_8h.html
@@ -0,0 +1,136 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxsync.h File Reference</h1>
+<p>
+<a href="dmxsync_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsync_8h.html#a0">dmxSyncActivate</a> (const char *interval)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsync_8h.html#a1">dmxSyncInit</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxsync_8h.html#a2">dmxSync</a> (<a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *dmxScreen, Bool now)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for sync support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxsync_8c.html">dmxsync.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a2" doxytag="dmxsync.h::dmxSync" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSync </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top"><a class="el" href="struct__DMXScreenInfo.html">DMXScreenInfo</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dmxScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Bool&nbsp;</td>
+ <td class="mdname" nowrap> <em>now</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Request an XSync() to the display used by <em>dmxScreen</em>. If <em>now</em> is TRUE, call XSync() immediately instead of waiting for the next XSync() batching point. Note that if XSync() batching was deselected with <a class="el" href="dmxsync_8c.html#a7">dmxSyncActivate()</a> before <a class="el" href="dmxsync_8c.html#a8">dmxSyncInit()</a> was called, then no XSync() batching is performed and this function always calles XSync() immediately.<p>
+(Note that this function uses TimerSet but works correctly in the face of a server generation. See the source for details.)<p>
+If <em>dmxScreen</em> is <em>NULL</em>, then all pending syncs will be flushed immediately. </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxsync.h::dmxSyncActivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSyncActivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">const char *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>interval</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Request the XSync() batching optimization with the specified <em>interval</em> (in mS). If the <em>interval</em> is 0, 100mS is used. If the <em>interval</em> is less than 0, then the XSync() batching optimization is not requested (e.g., so the -syncbatch -1 command line option can turn off the default 100mS XSync() batching).<p>
+Note that the parameter to this routine is a string, since it will usually be called from <a class="el" href="dmxinit_8c.html#a40">ddxProcessArgument</a> in #dmxinit.c </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxsync.h::dmxSyncInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSyncInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize the XSync() batching optimization, but only if <a class="el" href="dmxsync_8h.html#a0">dmxSyncActivate</a> was last called with a non-negative value. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxvisual_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxvisual_8c.html
new file mode 100644
index 000000000..a0f20c462
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxvisual_8c.html
@@ -0,0 +1,151 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxvisual.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxvisual_8h-source.html">dmxvisual.h</a>"</code><br>
+<code>#include "scrnintstr.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Visual *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxvisual_8c.html#a0">dmxLookupVisual</a> (ScreenPtr pScreen, VisualPtr pVisual)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Visual *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxvisual_8c.html#a1">dmxLookupVisualFromID</a> (ScreenPtr pScreen, VisualID vid)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Colormap&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxvisual_8c.html#a2">dmxColormapFromDefaultVisual</a> (ScreenPtr pScreen, Visual *visual)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides support for visuals.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a2" doxytag="dmxvisual.c::dmxColormapFromDefaultVisual" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Colormap dmxColormapFromDefaultVisual </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Visual *&nbsp;</td>
+ <td class="mdname" nowrap> <em>visual</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the colormap for the <em>visual</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxvisual.c::dmxLookupVisual" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Visual* dmxLookupVisual </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>VisualPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pVisual</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the visual that matched <em>pVisual</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxvisual.c::dmxLookupVisualFromID" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Visual* dmxLookupVisualFromID </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>VisualID&nbsp;</td>
+ <td class="mdname" nowrap> <em>vid</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the visual that matched the <em>vid</em>. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxvisual_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxvisual_8h-source.html
new file mode 100644
index 000000000..cda02947e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxvisual_8h-source.html
@@ -0,0 +1,67 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxvisual.h</h1><a href="dmxvisual_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Kevin E. Martin &lt;kem@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef DMXVISUAL_H</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define DMXVISUAL_H</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="preprocessor">#include "scrnintstr.h"</span>
+00042
+00043 <span class="keyword">extern</span> Visual *<a class="code" href="dmxvisual_8c.html#a0">dmxLookupVisual</a>(ScreenPtr pScreen, VisualPtr pVisual);
+00044 <span class="keyword">extern</span> Visual *<a class="code" href="dmxvisual_8c.html#a1">dmxLookupVisualFromID</a>(ScreenPtr pScreen, VisualID vid);
+00045 <span class="keyword">extern</span> Colormap <a class="code" href="dmxvisual_8c.html#a2">dmxColormapFromDefaultVisual</a>(ScreenPtr pScreen,
+00046 Visual *visual);
+00047
+00048 <span class="preprocessor">#endif </span><span class="comment">/* DMXVISUAL_H */</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxvisual_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxvisual_8h.html
new file mode 100644
index 000000000..d56bb1c9a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxvisual_8h.html
@@ -0,0 +1,152 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxvisual.h File Reference</h1><code>#include "scrnintstr.h"</code><br>
+
+<p>
+<a href="dmxvisual_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Visual *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxvisual_8h.html#a0">dmxLookupVisual</a> (ScreenPtr pScreen, VisualPtr pVisual)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Visual *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxvisual_8h.html#a1">dmxLookupVisualFromID</a> (ScreenPtr pScreen, VisualID vid)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Colormap&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxvisual_8h.html#a2">dmxColormapFromDefaultVisual</a> (ScreenPtr pScreen, Visual *visual)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for visual support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxvisual_8c.html">dmxvisual.c</a></dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a2" doxytag="dmxvisual.h::dmxColormapFromDefaultVisual" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Colormap dmxColormapFromDefaultVisual </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Visual *&nbsp;</td>
+ <td class="mdname" nowrap> <em>visual</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the colormap for the <em>visual</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="dmxvisual.h::dmxLookupVisual" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Visual* dmxLookupVisual </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>VisualPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pVisual</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the visual that matched <em>pVisual</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxvisual.h::dmxLookupVisualFromID" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Visual* dmxLookupVisualFromID </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>VisualID&nbsp;</td>
+ <td class="mdname" nowrap> <em>vid</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Return the visual that matched the <em>vid</em>. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxwindow_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxwindow_8c.html
new file mode 100644
index 000000000..ef3509d3c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxwindow_8c.html
@@ -0,0 +1,865 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxwindow.c File Reference</h1><code>#include "<a class="el" href="dmx_8h-source.html">dmx.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxsync_8h-source.html">dmxsync.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxwindow_8h-source.html">dmxwindow.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxpixmap_8h-source.html">dmxpixmap.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxcmap_8h-source.html">dmxcmap.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxvisual_8h-source.html">dmxvisual.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxinput_8h-source.html">dmxinput.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxextension_8h-source.html">dmxextension.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxpict_8h-source.html">dmxpict.h</a>"</code><br>
+<code>#include "windowstr.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a3">dmxInitWindow</a> (ScreenPtr pScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a5">dmxResizeScreenWindow</a> (ScreenPtr pScreen, int x, int y, int w, int h)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a6">dmxResizeRootWindow</a> (WindowPtr pRoot, int x, int y, int w, int h)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a9">dmxCreateAndRealizeWindow</a> (WindowPtr pWindow, Bool doSync)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a10">dmxCreateWindow</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a11">dmxBEDestroyWindow</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a12">dmxDestroyWindow</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a13">dmxPositionWindow</a> (WindowPtr pWindow, int x, int y)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a14">dmxChangeWindowAttributes</a> (WindowPtr pWindow, unsigned long mask)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a15">dmxRealizeWindow</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a16">dmxUnrealizeWindow</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a17">dmxRestackWindow</a> (WindowPtr pWindow, WindowPtr pOldNextSib)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a19">dmxWindowExposures</a> (WindowPtr pWindow, RegionPtr prgn, RegionPtr other_exposed)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a20">dmxPaintWindowBackground</a> (WindowPtr pWindow, RegionPtr pRegion, int what)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a21">dmxPaintWindowBorder</a> (WindowPtr pWindow, RegionPtr pRegion, int what)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a22">dmxCopyWindow</a> (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a23">dmxResizeWindow</a> (WindowPtr pWindow, int x, int y, unsigned int w, unsigned int h, WindowPtr pSib)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a24">dmxReparentWindow</a> (WindowPtr pWindow, WindowPtr pPriorParent)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a25">dmxChangeBorderWidth</a> (WindowPtr pWindow, unsigned int width)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8c.html#a26">dmxSetShape</a> (WindowPtr pWindow)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file provides support for window-related functions.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a11" doxytag="dmxwindow.c::dmxBEDestroyWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBEDestroyWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy <em>pWindow</em> on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a25" doxytag="dmxwindow.c::dmxChangeBorderWidth" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxChangeBorderWidth </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>width</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change border width for <em>pWindow</em> to <em>width</em> pixels. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmxwindow.c::dmxChangeWindowAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxChangeWindowAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the window attributes of <em>pWindow</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a22" doxytag="dmxwindow.c::dmxCopyWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCopyWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DDXPointRec&nbsp;</td>
+ <td class="mdname" nowrap> <em>ptOldOrg</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>RegionPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>prgnSrc</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Move <em>pWindow</em> on the back-end server. Determine whether or not it is on or offscreen, and realize it if it is newly on screen and the lazy window creation optimization is enabled. </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="dmxwindow.c::dmxCreateAndRealizeWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCreateAndRealizeWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Bool&nbsp;</td>
+ <td class="mdname" nowrap> <em>doSync</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This function handles lazy window creation and realization. Window creation is handled by <a class="el" href="dmxwindow_8c.html#a8">dmxCreateNonRootWindow()</a>. It also handles any stacking changes that have occured since the window was originally created by calling <a class="el" href="dmxwindow_8c.html#a0">dmxDoRestackWindow()</a>. If the window is shaped, the shape is set on the back-end server by calling <a class="el" href="dmxwindow_8c.html#a2">dmxDoSetShape()</a>, and if the window has pictures (from RENDER) associated with it, those pictures are created on the back-end server by calling <a class="el" href="dmxpict_8c.html#a18">dmxCreatePictureList()</a>. If <em>doSync</em> is TRUE, then <a class="el" href="dmxsync_8c.html#a9">dmxSync()</a> is called. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="dmxwindow.c::dmxCreateWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxCreateWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create <em>pWindow</em> on the back-end server. If the lazy window creation optimization is enabled, then the actual creation and realization of the window is handled by <a class="el" href="dmxwindow_8c.html#a9">dmxCreateAndRealizeWindow()</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="dmxwindow.c::dmxDestroyWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxDestroyWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy <em>pWindow</em> on the back-end server. If any RENDER pictures were created, destroy them as well. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxwindow.c::dmxInitWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxInitWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize the private area for the window functions. </td>
+ </tr>
+</table>
+<a class="anchor" name="a20" doxytag="dmxwindow.c::dmxPaintWindowBackground" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPaintWindowBackground </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>RegionPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pRegion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>what</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Paint background of <em>pWindow</em> in <em>pRegion</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a21" doxytag="dmxwindow.c::dmxPaintWindowBorder" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPaintWindowBorder </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>RegionPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pRegion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>what</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Paint window border for <em>pWindow</em> in <em>pRegion</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="dmxwindow.c::dmxPositionWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxPositionWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the position of <em>pWindow</em> to be <em>x</em>, <em>y</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a15" doxytag="dmxwindow.c::dmxRealizeWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxRealizeWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Realize <em>pWindow</em> on the back-end server. If the lazy window creation optimization is enabled, the window is only realized when it at least partially overlaps the screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a24" doxytag="dmxwindow.c::dmxReparentWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxReparentWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pPriorParent</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Reparent <em>pWindow</em> on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxwindow.c::dmxResizeRootWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxResizeRootWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pRoot</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>w</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>h</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the location and size of the "root" window. Called from #dmxReconfigureRootWindow(). </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxwindow.c::dmxResizeScreenWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxResizeScreenWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>w</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>h</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the location and size of the "screen" window. Called from #dmxReconfigureScreenWindow(). </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="dmxwindow.c::dmxResizeWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxResizeWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>w</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>h</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSib</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Resize <em>pWindow</em> on the back-end server. Determine whether or not it is on or offscreen, and realize it if it is newly on screen and the lazy window creation optimization is enabled. </td>
+ </tr>
+</table>
+<a class="anchor" name="a17" doxytag="dmxwindow.c::dmxRestackWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxRestackWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pOldNextSib</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Handle window restacking. The actual restacking occurs in <a class="el" href="dmxwindow_8c.html#a0">dmxDoRestackWindow()</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a26" doxytag="dmxwindow.c::dmxSetShape" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSetShape </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set shape of <em>pWindow</em> on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a16" doxytag="dmxwindow.c::dmxUnrealizeWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxUnrealizeWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Unrealize <em>pWindow</em> on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a19" doxytag="dmxwindow.c::dmxWindowExposures" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxWindowExposures </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>RegionPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>prgn</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>RegionPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>other_exposed</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Handle exposures on <em>pWindow</em>. Since window exposures are handled in DMX, the events that are generated by the back-end server are redundant, so we eat them here. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxwindow_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxwindow_8h-source.html
new file mode 100644
index 000000000..a1bbda691
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxwindow_8h-source.html
@@ -0,0 +1,165 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxwindow.h</h1><a href="dmxwindow_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Kevin E. Martin &lt;kem@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef DMXWINDOW_H</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define DMXWINDOW_H</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="preprocessor">#include "windowstr.h"</span>
+00042
+<a name="l00044"></a><a class="code" href="struct__dmxWinPriv.html">00044</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__dmxWinPriv.html">_dmxWinPriv</a> {
+00045 Window window;
+00046 Bool offscreen;
+00047 Bool mapped;
+00048 Bool restacked;
+00049 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> attribMask;
+00050 Colormap cmap;
+00051 Visual *visual;
+00052 <span class="preprocessor">#ifdef SHAPE</span>
+00053 <span class="preprocessor"></span> Bool isShaped;
+00054 <span class="preprocessor">#endif</span>
+00055 <span class="preprocessor"></span><span class="preprocessor">#ifdef RENDER</span>
+00056 <span class="preprocessor"></span> Bool hasPict;
+00057 <span class="preprocessor">#endif</span>
+00058 <span class="preprocessor"></span><span class="preprocessor">#ifdef GLXEXT</span>
+00059 <span class="preprocessor"></span> <span class="keywordtype">void</span> *swapGroup;
+00060 <span class="keywordtype">int</span> barrier;
+00061 void (*windowDestroyed)(WindowPtr);
+00062 void (*windowUnmapped)(WindowPtr);
+00063 <span class="preprocessor">#endif</span>
+00064 <span class="preprocessor"></span>} <a class="code" href="struct__dmxWinPriv.html">dmxWinPrivRec</a>, *<a class="code" href="struct__dmxWinPriv.html">dmxWinPrivPtr</a>;
+00065
+00066
+00067 <span class="keyword">extern</span> Bool <a class="code" href="dmxwindow_8c.html#a3">dmxInitWindow</a>(ScreenPtr pScreen);
+00068
+00069 <span class="keyword">extern</span> Window dmxCreateRootWindow(WindowPtr pWindow);
+00070
+00071 <span class="keyword">extern</span> <span class="keywordtype">void</span> dmxGetDefaultWindowAttributes(WindowPtr pWindow,
+00072 Colormap *cmap,
+00073 Visual **visual);
+00074 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxwindow_8c.html#a9">dmxCreateAndRealizeWindow</a>(WindowPtr pWindow, Bool doSync);
+00075
+00076 <span class="keyword">extern</span> Bool <a class="code" href="dmxwindow_8c.html#a10">dmxCreateWindow</a>(WindowPtr pWindow);
+00077 <span class="keyword">extern</span> Bool <a class="code" href="dmxwindow_8c.html#a12">dmxDestroyWindow</a>(WindowPtr pWindow);
+00078 <span class="keyword">extern</span> Bool <a class="code" href="dmxwindow_8c.html#a13">dmxPositionWindow</a>(WindowPtr pWindow, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y);
+00079 <span class="keyword">extern</span> Bool <a class="code" href="dmxwindow_8c.html#a14">dmxChangeWindowAttributes</a>(WindowPtr pWindow, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> mask);
+00080 <span class="keyword">extern</span> Bool <a class="code" href="dmxwindow_8c.html#a15">dmxRealizeWindow</a>(WindowPtr pWindow);
+00081 <span class="keyword">extern</span> Bool <a class="code" href="dmxwindow_8c.html#a16">dmxUnrealizeWindow</a>(WindowPtr pWindow);
+00082 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxwindow_8c.html#a17">dmxRestackWindow</a>(WindowPtr pWindow, WindowPtr pOldNextSib);
+00083 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxwindow_8c.html#a19">dmxWindowExposures</a>(WindowPtr pWindow, RegionPtr prgn,
+00084 RegionPtr other_exposed);
+00085 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxwindow_8c.html#a20">dmxPaintWindowBackground</a>(WindowPtr pWindow, RegionPtr pRegion,
+00086 <span class="keywordtype">int</span> what);
+00087 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxwindow_8c.html#a21">dmxPaintWindowBorder</a>(WindowPtr pWindow, RegionPtr pRegion,
+00088 <span class="keywordtype">int</span> what);
+00089 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxwindow_8c.html#a22">dmxCopyWindow</a>(WindowPtr pWindow, DDXPointRec ptOldOrg,
+00090 RegionPtr prgnSrc);
+00091
+00092 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxwindow_8c.html#a23">dmxResizeWindow</a>(WindowPtr pWindow, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y,
+00093 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> w, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> h, WindowPtr pSib);
+00094 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxwindow_8c.html#a24">dmxReparentWindow</a>(WindowPtr pWindow, WindowPtr pPriorParent);
+00095
+00096 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxwindow_8c.html#a25">dmxChangeBorderWidth</a>(WindowPtr pWindow, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> width);
+00097
+00098 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxwindow_8c.html#a5">dmxResizeScreenWindow</a>(ScreenPtr pScreen,
+00099 <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h);
+00100 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxwindow_8c.html#a6">dmxResizeRootWindow</a>(WindowPtr pRoot,
+00101 <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h);
+00102
+00103 <span class="keyword">extern</span> Bool <a class="code" href="dmxwindow_8c.html#a11">dmxBEDestroyWindow</a>(WindowPtr pWindow);
+00104
+00105 <span class="preprocessor">#ifdef SHAPE</span>
+00106 <span class="preprocessor"></span><span class="comment">/* Support for shape extension */</span>
+00107 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="dmxwindow_8c.html#a26">dmxSetShape</a>(WindowPtr pWindow);
+00108 <span class="preprocessor">#endif</span>
+00109 <span class="preprocessor"></span>
+<a name="l00111"></a><a class="code" href="dmxwindow_8h.html#a10">00111</a> <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="dmxscrinit_8c.html#a3">dmxWinPrivateIndex</a>;
+00112
+<a name="l00114"></a><a class="code" href="dmxwindow_8h.html#a0">00114</a> <span class="preprocessor">#define DMX_GET_WINDOW_PRIV(_pWin) \</span>
+00115 <span class="preprocessor"> ((dmxWinPrivPtr)(_pWin)-&gt;devPrivates[dmxWinPrivateIndex].ptr)</span>
+00116 <span class="preprocessor"></span>
+00117 <span class="comment">/* All of these macros are only used in dmxwindow.c */</span>
+00118 <span class="preprocessor">#define DMX_WINDOW_FUNC_PROLOGUE(_pGC) \</span>
+00119 <span class="preprocessor">do { \</span>
+00120 <span class="preprocessor"> dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(_pGC); \</span>
+00121 <span class="preprocessor"> DMX_UNWRAP(funcs, pGCPriv, (_pGC)); \</span>
+00122 <span class="preprocessor"> if (pGCPriv-&gt;ops) \</span>
+00123 <span class="preprocessor"> DMX_UNWRAP(ops, pGCPriv, (_pGC)); \</span>
+00124 <span class="preprocessor">} while (0)</span>
+00125 <span class="preprocessor"></span>
+00126 <span class="preprocessor">#define DMX_WINDOW_FUNC_EPILOGUE(_pGC) \</span>
+00127 <span class="preprocessor">do { \</span>
+00128 <span class="preprocessor"> dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(_pGC); \</span>
+00129 <span class="preprocessor"> DMX_WRAP(funcs, &amp;dmxGCFuncs, pGCPriv, (_pGC)); \</span>
+00130 <span class="preprocessor"> if (pGCPriv-&gt;ops) \</span>
+00131 <span class="preprocessor"> DMX_WRAP(ops, &amp;dmxGCOps, pGCPriv, (_pGC)); \</span>
+00132 <span class="preprocessor">} while (0)</span>
+00133 <span class="preprocessor"></span>
+00134 <span class="preprocessor">#define DMX_WINDOW_X1(_pWin) \</span>
+00135 <span class="preprocessor"> ((_pWin)-&gt;drawable.x - wBorderWidth(_pWin))</span>
+00136 <span class="preprocessor"></span><span class="preprocessor">#define DMX_WINDOW_Y1(_pWin) \</span>
+00137 <span class="preprocessor"> ((_pWin)-&gt;drawable.y - wBorderWidth(_pWin))</span>
+00138 <span class="preprocessor"></span><span class="preprocessor">#define DMX_WINDOW_X2(_pWin) \</span>
+00139 <span class="preprocessor"> ((_pWin)-&gt;drawable.x + wBorderWidth(_pWin) + (_pWin)-&gt;drawable.width) </span>
+00140 <span class="preprocessor"></span><span class="preprocessor">#define DMX_WINDOW_Y2(_pWin) \</span>
+00141 <span class="preprocessor"> ((_pWin)-&gt;drawable.y + wBorderWidth(_pWin) + (_pWin)-&gt;drawable.height) </span>
+00142 <span class="preprocessor"></span>
+00143 <span class="preprocessor">#define DMX_WINDOW_OFFSCREEN(_pWin) \</span>
+00144 <span class="preprocessor"> (DMX_WINDOW_X1(_pWin) &gt;= (_pWin)-&gt;drawable.pScreen-&gt;width || \</span>
+00145 <span class="preprocessor"> DMX_WINDOW_Y1(_pWin) &gt;= (_pWin)-&gt;drawable.pScreen-&gt;height || \</span>
+00146 <span class="preprocessor"> DMX_WINDOW_X2(_pWin) &lt;= 0 || \</span>
+00147 <span class="preprocessor"> DMX_WINDOW_Y2(_pWin) &lt;= 0)</span>
+00148 <span class="preprocessor"></span>
+00149 <span class="preprocessor">#endif </span><span class="comment">/* DMXWINDOW_H */</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxwindow_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxwindow_8h.html
new file mode 100644
index 000000000..f80aae3c3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxwindow_8h.html
@@ -0,0 +1,969 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxwindow.h File Reference</h1><code>#include "windowstr.h"</code><br>
+
+<p>
+<a href="dmxwindow_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__dmxWinPriv.html">_dmxWinPriv</a></td></tr>
+
+<tr><td colspan=2><br><h2>Defines</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a0">DMX_GET_WINDOW_PRIV</a>(_pWin)&nbsp;&nbsp;&nbsp;((<a class="el" href="struct__dmxWinPriv.html">dmxWinPrivPtr</a>)(_pWin)-&gt;devPrivates[<a class="el" href="dmxwindow_8h.html#a10">dmxWinPrivateIndex</a>].ptr)</td></tr>
+
+<tr><td colspan=2><br><h2>Typedefs</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__dmxWinPriv.html">_dmxWinPriv</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a8">dmxWinPrivRec</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>typedef <a class="el" href="struct__dmxWinPriv.html">_dmxWinPriv</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a9">dmxWinPrivPtr</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a11">dmxInitWindow</a> (ScreenPtr pScreen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a14">dmxCreateAndRealizeWindow</a> (WindowPtr pWindow, Bool doSync)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a15">dmxCreateWindow</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a16">dmxDestroyWindow</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a17">dmxPositionWindow</a> (WindowPtr pWindow, int x, int y)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a18">dmxChangeWindowAttributes</a> (WindowPtr pWindow, unsigned long mask)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a19">dmxRealizeWindow</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a20">dmxUnrealizeWindow</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a21">dmxRestackWindow</a> (WindowPtr pWindow, WindowPtr pOldNextSib)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a22">dmxWindowExposures</a> (WindowPtr pWindow, RegionPtr prgn, RegionPtr other_exposed)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a23">dmxPaintWindowBackground</a> (WindowPtr pWindow, RegionPtr pRegion, int what)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a24">dmxPaintWindowBorder</a> (WindowPtr pWindow, RegionPtr pRegion, int what)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a25">dmxCopyWindow</a> (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a26">dmxResizeWindow</a> (WindowPtr pWindow, int x, int y, unsigned int w, unsigned int h, WindowPtr pSib)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a27">dmxReparentWindow</a> (WindowPtr pWindow, WindowPtr pPriorParent)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a28">dmxChangeBorderWidth</a> (WindowPtr pWindow, unsigned int width)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a29">dmxResizeScreenWindow</a> (ScreenPtr pScreen, int x, int y, int w, int h)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a30">dmxResizeRootWindow</a> (WindowPtr pRoot, int x, int y, int w, int h)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a31">dmxBEDestroyWindow</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a32">dmxSetShape</a> (WindowPtr pWindow)</td></tr>
+
+<tr><td colspan=2><br><h2>Variables</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxwindow_8h.html#a10">dmxWinPrivateIndex</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface for window support. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxwindow_8c.html">dmxwindow.c</a></dd></dl>
+<hr><h2>Define Documentation</h2>
+<a class="anchor" name="a0" doxytag="dmxwindow.h::DMX_GET_WINDOW_PRIV" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> #define DMX_GET_WINDOW_PRIV</td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">_pWin&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap>&nbsp;&nbsp;&nbsp;((<a class="el" href="struct__dmxWinPriv.html">dmxWinPrivPtr</a>)(_pWin)-&gt;devPrivates[<a class="el" href="dmxwindow_8h.html#a10">dmxWinPrivateIndex</a>].ptr)
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get window private pointer. </td>
+ </tr>
+</table>
+<hr><h2>Typedef Documentation</h2>
+<a class="anchor" name="a9" doxytag="dmxwindow.h::dmxWinPrivPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__dmxWinPriv.html">_dmxWinPriv</a> * <a class="el" href="struct__dmxWinPriv.html">dmxWinPrivPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Window private area. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxwindow.h::dmxWinPrivRec" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> typedef struct <a class="el" href="struct__dmxWinPriv.html">_dmxWinPriv</a> <a class="el" href="struct__dmxWinPriv.html">dmxWinPrivRec</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Window private area. </td>
+ </tr>
+</table>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a31" doxytag="dmxwindow.h::dmxBEDestroyWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxBEDestroyWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy <em>pWindow</em> on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a28" doxytag="dmxwindow.h::dmxChangeBorderWidth" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxChangeBorderWidth </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>width</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change border width for <em>pWindow</em> to <em>width</em> pixels. </td>
+ </tr>
+</table>
+<a class="anchor" name="a18" doxytag="dmxwindow.h::dmxChangeWindowAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxChangeWindowAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned long&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the window attributes of <em>pWindow</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a25" doxytag="dmxwindow.h::dmxCopyWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCopyWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DDXPointRec&nbsp;</td>
+ <td class="mdname" nowrap> <em>ptOldOrg</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>RegionPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>prgnSrc</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Move <em>pWindow</em> on the back-end server. Determine whether or not it is on or offscreen, and realize it if it is newly on screen and the lazy window creation optimization is enabled. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="dmxwindow.h::dmxCreateAndRealizeWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxCreateAndRealizeWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Bool&nbsp;</td>
+ <td class="mdname" nowrap> <em>doSync</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This function handles lazy window creation and realization. Window creation is handled by <a class="el" href="dmxwindow_8c.html#a8">dmxCreateNonRootWindow()</a>. It also handles any stacking changes that have occured since the window was originally created by calling <a class="el" href="dmxwindow_8c.html#a0">dmxDoRestackWindow()</a>. If the window is shaped, the shape is set on the back-end server by calling <a class="el" href="dmxwindow_8c.html#a2">dmxDoSetShape()</a>, and if the window has pictures (from RENDER) associated with it, those pictures are created on the back-end server by calling <a class="el" href="dmxpict_8c.html#a18">dmxCreatePictureList()</a>. If <em>doSync</em> is TRUE, then <a class="el" href="dmxsync_8c.html#a9">dmxSync()</a> is called. </td>
+ </tr>
+</table>
+<a class="anchor" name="a15" doxytag="dmxwindow.h::dmxCreateWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxCreateWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create <em>pWindow</em> on the back-end server. If the lazy window creation optimization is enabled, then the actual creation and realization of the window is handled by <a class="el" href="dmxwindow_8c.html#a9">dmxCreateAndRealizeWindow()</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a16" doxytag="dmxwindow.h::dmxDestroyWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxDestroyWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy <em>pWindow</em> on the back-end server. If any RENDER pictures were created, destroy them as well. </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="dmxwindow.h::dmxInitWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxInitWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pScreen</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize the private area for the window functions. </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="dmxwindow.h::dmxPaintWindowBackground" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPaintWindowBackground </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>RegionPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pRegion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>what</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Paint background of <em>pWindow</em> in <em>pRegion</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a24" doxytag="dmxwindow.h::dmxPaintWindowBorder" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxPaintWindowBorder </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>RegionPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pRegion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>what</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Paint window border for <em>pWindow</em> in <em>pRegion</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a17" doxytag="dmxwindow.h::dmxPositionWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxPositionWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the position of <em>pWindow</em> to be <em>x</em>, <em>y</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a19" doxytag="dmxwindow.h::dmxRealizeWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxRealizeWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Realize <em>pWindow</em> on the back-end server. If the lazy window creation optimization is enabled, the window is only realized when it at least partially overlaps the screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a27" doxytag="dmxwindow.h::dmxReparentWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxReparentWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pPriorParent</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Reparent <em>pWindow</em> on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a30" doxytag="dmxwindow.h::dmxResizeRootWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxResizeRootWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pRoot</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>w</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>h</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the location and size of the "root" window. Called from #dmxReconfigureRootWindow(). </td>
+ </tr>
+</table>
+<a class="anchor" name="a29" doxytag="dmxwindow.h::dmxResizeScreenWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxResizeScreenWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ScreenPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pScreen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>w</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>h</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the location and size of the "screen" window. Called from #dmxReconfigureScreenWindow(). </td>
+ </tr>
+</table>
+<a class="anchor" name="a26" doxytag="dmxwindow.h::dmxResizeWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxResizeWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>w</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>h</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pSib</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Resize <em>pWindow</em> on the back-end server. Determine whether or not it is on or offscreen, and realize it if it is newly on screen and the lazy window creation optimization is enabled. </td>
+ </tr>
+</table>
+<a class="anchor" name="a21" doxytag="dmxwindow.h::dmxRestackWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxRestackWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pOldNextSib</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Handle window restacking. The actual restacking occurs in <a class="el" href="dmxwindow_8c.html#a0">dmxDoRestackWindow()</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a32" doxytag="dmxwindow.h::dmxSetShape" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxSetShape </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set shape of <em>pWindow</em> on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a20" doxytag="dmxwindow.h::dmxUnrealizeWindow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool dmxUnrealizeWindow </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pWindow</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Unrealize <em>pWindow</em> on the back-end server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a22" doxytag="dmxwindow.h::dmxWindowExposures" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void dmxWindowExposures </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">WindowPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pWindow</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>RegionPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>prgn</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>RegionPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>other_exposed</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Handle exposures on <em>pWindow</em>. Since window exposures are handled in DMX, the events that are generated by the back-end server are redundant, so we eat them here. </td>
+ </tr>
+</table>
+<hr><h2>Variable Documentation</h2>
+<a class="anchor" name="a10" doxytag="dmxwindow.h::dmxWinPrivateIndex" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="dmxwindow_8h.html#a10">dmxWinPrivateIndex</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Private index for Windows </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxxinput_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxxinput_8c.html
new file mode 100644
index 000000000..bd64864a1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/dmxxinput_8c.html
@@ -0,0 +1,396 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxxinput.c File Reference</h1><code>#include "X.h"</code><br>
+<code>#include "Xproto.h"</code><br>
+<code>#include "inputstr.h"</code><br>
+<code>#include "XI.h"</code><br>
+<code>#include "XIproto.h"</code><br>
+<code>#include "XIstubs.h"</code><br>
+<code>#include "mipointer.h"</code><br>
+<code>#include "<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>"</code><br>
+<code>#include "exevents.h"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxxinput_8c.html#a1">ChangeKeyboardDevice</a> (DeviceIntPtr old_dev, DeviceIntPtr new_dev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxxinput_8c.html#a2">ChangePointerDevice</a> (DeviceIntPtr old_dev, DeviceIntPtr new_dev, unsigned char x, unsigned char y)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxxinput_8c.html#a3">CloseInputDevice</a> (DeviceIntPtr d, ClientPtr client)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxxinput_8c.html#a4">AddOtherInputDevices</a> (void)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxxinput_8c.html#a5">OpenInputDevice</a> (DeviceIntPtr dev, ClientPtr client, int *status)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxxinput_8c.html#a6">SetDeviceMode</a> (ClientPtr client, DeviceIntPtr dev, int mode)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxxinput_8c.html#a7">SetDeviceValuators</a> (ClientPtr client, DeviceIntPtr dev, int *valuators, int first_valuator, int num_valuators)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="dmxxinput_8c.html#a8">ChangeDeviceControl</a> (ClientPtr client, DeviceIntPtr dev, xDeviceCtl *control)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file implements support required by the XINPUT extension.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a4" doxytag="dmxxinput.c::AddOtherInputDevices" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void AddOtherInputDevices </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+This is not required by the XINPUT model that DMX uses. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="dmxxinput.c::ChangeDeviceControl" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int ChangeDeviceControl </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ClientPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>client</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>dev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>xDeviceCtl *&nbsp;</td>
+ <td class="mdname" nowrap> <em>control</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change device control. This is not implemented. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="dmxxinput.c::ChangeKeyboardDevice" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int ChangeKeyboardDevice </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>old_dev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>new_dev</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the core keyboard from <em>old_dev</em> to <em>new_dev</em>. Currently this is not implemented. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="dmxxinput.c::ChangePointerDevice" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int ChangePointerDevice </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>old_dev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>new_dev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned char&nbsp;</td>
+ <td class="mdname" nowrap> <em>x</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned char&nbsp;</td>
+ <td class="mdname" nowrap> <em>y</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the core pointer from <em>old_dev</em> to <em>new_dev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="dmxxinput.c::CloseInputDevice" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void CloseInputDevice </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>d</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>ClientPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>client</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Close the input device. This is not required by the XINPUT model that DMX uses. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="dmxxinput.c::OpenInputDevice" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void OpenInputDevice </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>dev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>ClientPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>client</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>status</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Open an input device. This is not required by the XINPUT model that DMX uses. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="dmxxinput.c::SetDeviceMode" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int SetDeviceMode </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ClientPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>client</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>dev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>mode</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set device mode to <em>mode</em>. This is not implemented. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="dmxxinput.c::SetDeviceValuators" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int SetDeviceValuators </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">ClientPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>client</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>DeviceIntPtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>dev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>valuators</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>first_valuator</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>num_valuators</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set device valuators. This is not implemented. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/doxygen.css b/nx-X11/programs/Xserver/hw/dmx/doc/html/doxygen.css
new file mode 100644
index 000000000..841f709a7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/doxygen.css
@@ -0,0 +1,49 @@
+H1 { text-align: center; }
+CAPTION { font-weight: bold }
+A.qindex {}
+A.qindexRef {}
+A.el { text-decoration: none; font-weight: bold }
+A.elRef { font-weight: bold }
+A.code { text-decoration: none; font-weight: normal; color: #4444ee }
+A.codeRef { font-weight: normal; color: #4444ee }
+A:hover { text-decoration: none; background-color: #f2f2ff }
+DL.el { margin-left: -1cm }
+DIV.fragment { width: 100%; border: none; background-color: #eeeeee }
+DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px }
+TD.md { background-color: #f2f2ff; font-weight: bold; }
+TD.mdname1 { background-color: #f2f2ff; font-weight: bold; color: #602020; }
+TD.mdname { background-color: #f2f2ff; font-weight: bold; color: #602020; width: 600px; }
+DIV.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold }
+DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller }
+BODY { background: white }
+TD.indexkey {
+ background-color: #eeeeff;
+ font-weight: bold;
+ padding-right : 10px;
+ padding-top : 2px;
+ padding-left : 10px;
+ padding-bottom : 2px;
+ margin-left : 0px;
+ margin-right : 0px;
+ margin-top : 2px;
+ margin-bottom : 2px
+}
+TD.indexvalue {
+ background-color: #eeeeff;
+ font-style: italic;
+ padding-right : 10px;
+ padding-top : 2px;
+ padding-left : 10px;
+ padding-bottom : 2px;
+ margin-left : 0px;
+ margin-right : 0px;
+ margin-top : 2px;
+ margin-bottom : 2px
+}
+FONT.keyword { color: #008000 }
+FONT.keywordtype { color: #604020 }
+FONT.keywordflow { color: #e08000 }
+FONT.comment { color: #800000 }
+FONT.preprocessor { color: #806020 }
+FONT.stringliteral { color: #002080 }
+FONT.charliteral { color: #008080 }
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/doxygen.png b/nx-X11/programs/Xserver/hw/dmx/doc/html/doxygen.png
new file mode 100644
index 000000000..96ae72c29
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/doxygen.png
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/files.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/files.html
new file mode 100644
index 000000000..339ba7a98
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/files.html
@@ -0,0 +1,120 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindexHL" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>Distributed Multihead X File List</h1>Here is a list of all documented files with brief descriptions:<table>
+ <tr><td class="indexkey"><a class="el" href="ChkNotMaskEv_8c.html">ChkNotMaskEv.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="ChkNotMaskEv_8h.html">ChkNotMaskEv.h</a> <a href="ChkNotMaskEv_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="programs_2Xserver_2Xext_2dmx_8c.html">programs/Xserver/Xext/dmx.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="lib_2dmx_2dmx_8c.html">lib/dmx/dmx.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmx_8h.html">dmx.h</a> <a href="dmx_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><b>dmx_glxvisuals.h</b> <a href="dmx__glxvisuals_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxarg_8c.html">dmxarg.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxarg_8h.html">dmxarg.h</a> <a href="dmxarg_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxbackend_8c.html">dmxbackend.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxbackend_8h.html">dmxbackend.h</a> <a href="dmxbackend_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxcb_8c.html">dmxcb.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxcb_8h.html">dmxcb.h</a> <a href="dmxcb_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxclient_8h.html">dmxclient.h</a> <a href="dmxclient_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxcmap_8c.html">dmxcmap.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxcmap_8h.html">dmxcmap.h</a> <a href="dmxcmap_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxcommon_8c.html">dmxcommon.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxcommon_8h.html">dmxcommon.h</a> <a href="dmxcommon_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxcompat_8c.html">dmxcompat.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxcompat_8h.html">dmxcompat.h</a> <a href="dmxcompat_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxconfig_8c.html">dmxconfig.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxconfig_8h.html">dmxconfig.h</a> <a href="dmxconfig_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxconsole_8c.html">dmxconsole.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxconsole_8h.html">dmxconsole.h</a> <a href="dmxconsole_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxcursor_8c.html">dmxcursor.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxcursor_8h.html">dmxcursor.h</a> <a href="dmxcursor_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxdetach_8c.html">dmxdetach.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxdpms_8c.html">dmxdpms.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxdpms_8h.html">dmxdpms.h</a> <a href="dmxdpms_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxdummy_8c.html">dmxdummy.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxdummy_8h.html">dmxdummy.h</a> <a href="dmxdummy_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxeq_8c.html">dmxeq.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxeq_8h.html">dmxeq.h</a> <a href="dmxeq_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxevents_8c.html">dmxevents.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxevents_8h.html">dmxevents.h</a> <a href="dmxevents_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxext_8h.html">dmxext.h</a> <a href="dmxext_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxextension_8c.html">dmxextension.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxextension_8h.html">dmxextension.h</a> <a href="dmxextension_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxfont_8c.html">dmxfont.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxfont_8h.html">dmxfont.h</a> <a href="dmxfont_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxgc_8c.html">dmxgc.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxgc_8h.html">dmxgc.h</a> <a href="dmxgc_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxgcops_8c.html">dmxgcops.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxgcops_8h.html">dmxgcops.h</a> <a href="dmxgcops_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxinit_8c.html">dmxinit.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxinit_8h.html">dmxinit.h</a> <a href="dmxinit_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxinput_8c.html">dmxinput.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxinput_8h.html">dmxinput.h</a> <a href="dmxinput_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxinputinit_8c.html">dmxinputinit.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxinputinit_8h.html">dmxinputinit.h</a> <a href="dmxinputinit_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxlog_8c.html">dmxlog.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxlog_8h.html">dmxlog.h</a> <a href="dmxlog_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxmap_8c.html">dmxmap.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxmap_8h.html">dmxmap.h</a> <a href="dmxmap_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxmotion_8c.html">dmxmotion.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxmotion_8h.html">dmxmotion.h</a> <a href="dmxmotion_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxparse_8c.html">dmxparse.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxparse_8h.html">dmxparse.h</a> <a href="dmxparse_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxpict_8c.html">dmxpict.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxpict_8h.html">dmxpict.h</a> <a href="dmxpict_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxpixmap_8c.html">dmxpixmap.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxpixmap_8h.html">dmxpixmap.h</a> <a href="dmxpixmap_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxprint_8c.html">dmxprint.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxprint_8h.html">dmxprint.h</a> <a href="dmxprint_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxprop_8c.html">dmxprop.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxprop_8h.html">dmxprop.h</a> <a href="dmxprop_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxproto_8h.html">dmxproto.h</a> <a href="dmxproto_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxscrinit_8c.html">dmxscrinit.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxscrinit_8h.html">dmxscrinit.h</a> <a href="dmxscrinit_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxshadow_8c.html">dmxshadow.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxshadow_8h.html">dmxshadow.h</a> <a href="dmxshadow_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxsigio_8c.html">dmxsigio.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxsigio_8h.html">dmxsigio.h</a> <a href="dmxsigio_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxstat_8c.html">dmxstat.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxstat_8h.html">dmxstat.h</a> <a href="dmxstat_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxsync_8c.html">dmxsync.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxsync_8h.html">dmxsync.h</a> <a href="dmxsync_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxvisual_8c.html">dmxvisual.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxvisual_8h.html">dmxvisual.h</a> <a href="dmxvisual_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxwindow_8c.html">dmxwindow.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxwindow_8h.html">dmxwindow.h</a> <a href="dmxwindow_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="dmxxinput_8c.html">dmxxinput.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="lnx-keyboard_8c.html">lnx-keyboard.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="lnx-keyboard_8h.html">lnx-keyboard.h</a> <a href="lnx-keyboard_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="lnx-ms_8c.html">lnx-ms.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="lnx-ms_8h.html">lnx-ms.h</a> <a href="lnx-ms_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="lnx-ps2_8c.html">lnx-ps2.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="lnx-ps2_8h.html">lnx-ps2.h</a> <a href="lnx-ps2_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="usb-common_8c.html">usb-common.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="usb-common_8h.html">usb-common.h</a> <a href="usb-common_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="usb-keyboard_8c.html">usb-keyboard.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="usb-keyboard_8h.html">usb-keyboard.h</a> <a href="usb-keyboard_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="usb-mouse_8c.html">usb-mouse.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="usb-mouse_8h.html">usb-mouse.h</a> <a href="usb-mouse_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="usb-other_8c.html">usb-other.c</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="usb-other_8h.html">usb-other.h</a> <a href="usb-other_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+ <tr><td class="indexkey"><a class="el" href="usb-private_8h.html">usb-private.h</a> <a href="usb-private_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2blank.png b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2blank.png
new file mode 100644
index 000000000..493c3c0b6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2blank.png
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2doc.png b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2doc.png
new file mode 100644
index 000000000..f72999f92
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2doc.png
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2folderclosed.png b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2folderclosed.png
new file mode 100644
index 000000000..d6d063440
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2folderclosed.png
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2folderopen.png b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2folderopen.png
new file mode 100644
index 000000000..bbe2c913c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2folderopen.png
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2lastnode.png b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2lastnode.png
new file mode 100644
index 000000000..e7b9ba90c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2lastnode.png
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2link.png b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2link.png
new file mode 100644
index 000000000..14f3fed00
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2link.png
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2mlastnode.png b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2mlastnode.png
new file mode 100644
index 000000000..09ceb6adb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2mlastnode.png
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2mnode.png b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2mnode.png
new file mode 100644
index 000000000..3254c0511
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2mnode.png
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2node.png b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2node.png
new file mode 100644
index 000000000..c9f06a57f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2node.png
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2plastnode.png b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2plastnode.png
new file mode 100644
index 000000000..0b07e0091
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2plastnode.png
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2pnode.png b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2pnode.png
new file mode 100644
index 000000000..2001b797b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2pnode.png
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2vertline.png b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2vertline.png
new file mode 100644
index 000000000..b330f3a33
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2vertline.png
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/functions.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/functions.html
new file mode 100644
index 000000000..766de0f8f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/functions.html
@@ -0,0 +1,237 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindexHL" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<div class="qindex"><a class="qindexHL" href="functions.html">All</a> | <a class="qindex" href="functions_vars.html">Variables</a></div>
+<div class="qindex"><a class="qindex" href="#index_a">a</a> | <a class="qindex" href="#index_b">b</a> | <a class="qindex" href="#index_c">c</a> | <a class="qindex" href="#index_d">d</a> | <a class="qindex" href="#index_e">e</a> | <a class="qindex" href="#index_f">f</a> | <a class="qindex" href="#index_g">g</a> | <a class="qindex" href="#index_h">h</a> | <a class="qindex" href="#index_i">i</a> | <a class="qindex" href="#index_k">k</a> | <a class="qindex" href="#index_l">l</a> | <a class="qindex" href="#index_m">m</a> | <a class="qindex" href="#index_n">n</a> | <a class="qindex" href="#index_o">o</a> | <a class="qindex" href="#index_p">p</a> | <a class="qindex" href="#index_r">r</a> | <a class="qindex" href="#index_s">s</a> | <a class="qindex" href="#index_t">t</a> | <a class="qindex" href="#index_u">u</a> | <a class="qindex" href="#index_v">v</a> | <a class="qindex" href="#index_w">w</a> | <a class="qindex" href="#index_x">x</a></div>
+
+<p>
+
+<p>
+Here is a list of all documented struct and union fields with links to the struct/union documentation for each field:<h3><a class="anchor" name="index_a">- a -</a></h3><ul>
+<li>absmap
+: <a class="el" href="struct__myPrivate.html#o61">_myPrivate</a><li>argc
+: <a class="el" href="struct__dmxArg.html#o0">_dmxArg</a><li>argm
+: <a class="el" href="struct__dmxArg.html#o1">_dmxArg</a><li>argv
+: <a class="el" href="struct__dmxArg.html#o2">_dmxArg</a></ul>
+<h3><a class="anchor" name="index_b">- b -</a></h3><ul>
+<li>beBlackPixel
+: <a class="el" href="struct__DMXScreenInfo.html#o18">_DMXScreenInfo</a><li>beBPP
+: <a class="el" href="struct__DMXScreenInfo.html#o6">_DMXScreenInfo</a><li>beDefColormaps
+: <a class="el" href="struct__DMXScreenInfo.html#o17">_DMXScreenInfo</a><li>beDefVisualIndex
+: <a class="el" href="struct__DMXScreenInfo.html#o15">_DMXScreenInfo</a><li>beDepth
+: <a class="el" href="struct__DMXScreenInfo.html#o5">_DMXScreenInfo</a><li>beDepths
+: <a class="el" href="struct__DMXScreenInfo.html#o10">_DMXScreenInfo</a><li>beDisplay
+: <a class="el" href="struct__DMXScreenInfo.html#o2">_DMXScreenInfo</a><li>beHeight
+: <a class="el" href="struct__DMXScreenInfo.html#o4">_DMXScreenInfo</a><li>belFeedbackClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o25">_DMXLocalInitInfo</a><li>beNumDefColormaps
+: <a class="el" href="struct__DMXScreenInfo.html#o16">_DMXScreenInfo</a><li>beNumDepths
+: <a class="el" href="struct__DMXScreenInfo.html#o9">_DMXScreenInfo</a><li>beNumPixmapFormats
+: <a class="el" href="struct__DMXScreenInfo.html#o11">_DMXScreenInfo</a><li>beNumVisuals
+: <a class="el" href="struct__DMXScreenInfo.html#o13">_DMXScreenInfo</a><li>bePixmapFormats
+: <a class="el" href="struct__DMXScreenInfo.html#o12">_DMXScreenInfo</a><li>beVisuals
+: <a class="el" href="struct__DMXScreenInfo.html#o14">_DMXScreenInfo</a><li>beWhitePixel
+: <a class="el" href="struct__DMXScreenInfo.html#o19">_DMXScreenInfo</a><li>beWidth
+: <a class="el" href="struct__DMXScreenInfo.html#o3">_DMXScreenInfo</a><li>beXDPI
+: <a class="el" href="struct__DMXScreenInfo.html#o7">_DMXScreenInfo</a><li>beYDPI
+: <a class="el" href="struct__DMXScreenInfo.html#o8">_DMXScreenInfo</a><li>binding
+: <a class="el" href="struct__DMXLocalInputInfo.html#o3">_DMXLocalInputInfo</a><li>buttonClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o9">_DMXLocalInitInfo</a></ul>
+<h3><a class="anchor" name="index_c">- c -</a></h3><ul>
+<li>CloseScreen
+: <a class="el" href="struct__DMXScreenInfo.html#o59">_DMXScreenInfo</a><li>collect_events
+: <a class="el" href="struct__DMXLocalInputInfo.html#o16">_DMXLocalInputInfo</a><li>console
+: <a class="el" href="struct__DMXInputInfo.html#o6">_DMXInputInfo</a><li>core
+: <a class="el" href="struct__DMXInputInfo.html#o5">_DMXInputInfo</a><li>create_private
+: <a class="el" href="struct__DMXLocalInputInfo.html#o4">_DMXLocalInputInfo</a></ul>
+<h3><a class="anchor" name="index_d">- d -</a></h3><ul>
+<li>destroy_private
+: <a class="el" href="struct__DMXLocalInputInfo.html#o5">_DMXLocalInputInfo</a><li>detached
+: <a class="el" href="struct__DMXInputInfo.html#o2">_DMXInputInfo</a><li>deviceId
+: <a class="el" href="struct__DMXLocalInputInfo.html#o41">_DMXLocalInputInfo</a><li>deviceName
+: <a class="el" href="struct__DMXLocalInputInfo.html#o42">_DMXLocalInputInfo</a><li>devs
+: <a class="el" href="struct__DMXInputInfo.html#o17">_DMXInputInfo</a><li>dmxInput
+: <a class="el" href="struct__myPrivate.html#o62">_myPrivate</a><li>dpmsCapable
+: <a class="el" href="struct__DMXScreenInfo.html#o52">_DMXScreenInfo</a><li>dpmsEnabled
+: <a class="el" href="struct__DMXScreenInfo.html#o53">_DMXScreenInfo</a><li>dpmsOff
+: <a class="el" href="struct__DMXScreenInfo.html#o56">_DMXScreenInfo</a><li>dpmsStandby
+: <a class="el" href="struct__DMXScreenInfo.html#o54">_DMXScreenInfo</a><li>dpmsSuspend
+: <a class="el" href="struct__DMXScreenInfo.html#o55">_DMXScreenInfo</a><li>duration
+: <a class="el" href="struct__myPrivate.html#o50">_myPrivate</a></ul>
+<h3><a class="anchor" name="index_e">- e -</a></h3><ul>
+<li>event
+: <a class="el" href="struct__Event.html#o0">_Event</a><li>events
+: <a class="el" href="struct__EventQueue.html#o4">_EventQueue</a><li>extType
+: <a class="el" href="struct__DMXLocalInputInfo.html#o2">_DMXLocalInputInfo</a></ul>
+<h3><a class="anchor" name="index_f">- f -</a></h3><ul>
+<li>fd
+: <a class="el" href="struct__myPrivate.html#o37">_myPrivate</a><li>focusClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o20">_DMXLocalInitInfo</a><li>force
+: <a class="el" href="struct__DMXLocalInitInfo.html#o8">_DMXLocalInitInfo</a><li>freemap
+: <a class="el" href="struct__DMXLocalInitInfo.html#o3">_DMXLocalInitInfo</a><li>freename
+: <a class="el" href="struct__DMXInputInfo.html#o1">_DMXInputInfo</a><li>freenames
+: <a class="el" href="struct__DMXLocalInitInfo.html#o7">_DMXLocalInitInfo</a></ul>
+<h3><a class="anchor" name="index_g">- g -</a></h3><ul>
+<li>geometry
+: <a class="el" href="struct__DMXInputInfo.html#o20">_DMXInputInfo</a><li>get_info
+: <a class="el" href="struct__DMXLocalInputInfo.html#o9">_DMXLocalInputInfo</a><li>glyphSets
+: <a class="el" href="struct__dmxGlyphPriv.html#o0">_dmxGlyphPriv</a></ul>
+<h3><a class="anchor" name="index_h">- h -</a></h3><ul>
+<li>head
+: <a class="el" href="struct__DMXLocalInputInfo.html#o32">_DMXLocalInputInfo</a>, <a class="el" href="struct__EventQueue.html#o0">_EventQueue</a><li>history
+: <a class="el" href="struct__DMXLocalInputInfo.html#o34">_DMXLocalInputInfo</a></ul>
+<h3><a class="anchor" name="index_i">- i -</a></h3><ul>
+<li>index
+: <a class="el" href="struct__DMXScreenInfo.html#o1">_DMXScreenInfo</a><li>init
+: <a class="el" href="struct__DMXLocalInputInfo.html#o6">_DMXLocalInputInfo</a><li>inputIdx
+: <a class="el" href="struct__DMXLocalInputInfo.html#o29">_DMXLocalInputInfo</a>, <a class="el" href="struct__DMXInputInfo.html#o3">_DMXInputInfo</a><li>intFeedbackClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o26">_DMXLocalInitInfo</a><li>isCore
+: <a class="el" href="struct__DMXLocalInputInfo.html#o24">_DMXLocalInputInfo</a></ul>
+<h3><a class="anchor" name="index_k">- k -</a></h3><ul>
+<li>kbdFeedbackClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o22">_DMXLocalInitInfo</a><li>kbdState
+: <a class="el" href="struct__myPrivate.html#o43">_myPrivate</a><li>kBell
+: <a class="el" href="struct__DMXLocalInputInfo.html#o22">_DMXLocalInputInfo</a><li>kctrl
+: <a class="el" href="struct__DMXLocalInputInfo.html#o26">_DMXLocalInputInfo</a><li>kCtrl
+: <a class="el" href="struct__DMXLocalInputInfo.html#o21">_DMXLocalInputInfo</a><li>keyboard
+: <a class="el" href="struct__DMXLocalInitInfo.html#o0">_DMXLocalInitInfo</a><li>keyClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o1">_DMXLocalInitInfo</a><li>keycodes
+: <a class="el" href="struct__DMXInputInfo.html#o18">_DMXInputInfo</a><li>keySyms
+: <a class="el" href="struct__DMXLocalInitInfo.html#o2">_DMXLocalInitInfo</a></ul>
+<h3><a class="anchor" name="index_l">- l -</a></h3><ul>
+<li>lastEventTime
+: <a class="el" href="struct__EventQueue.html#o2">_EventQueue</a><li>lastMotion
+: <a class="el" href="struct__EventQueue.html#o3">_EventQueue</a><li>lastY
+: <a class="el" href="struct__DMXLocalInputInfo.html#o31">_DMXLocalInputInfo</a><li>latereinit
+: <a class="el" href="struct__DMXLocalInputInfo.html#o8">_DMXLocalInputInfo</a><li>ledFeedbackClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o24">_DMXLocalInitInfo</a></ul>
+<h3><a class="anchor" name="index_m">- m -</a></h3><ul>
+<li>map
+: <a class="el" href="struct__DMXLocalInputInfo.html#o39">_DMXLocalInputInfo</a>, <a class="el" href="struct__DMXLocalInitInfo.html#o11">_DMXLocalInitInfo</a><li>mapOptimize
+: <a class="el" href="struct__DMXLocalInputInfo.html#o40">_DMXLocalInputInfo</a><li>mask
+: <a class="el" href="struct__myPrivate.html#o56">_myPrivate</a><li>maxres
+: <a class="el" href="struct__DMXLocalInitInfo.html#o19">_DMXLocalInitInfo</a><li>maxSymbols
+: <a class="el" href="struct__DMXLocalInitInfo.html#o28">_DMXLocalInitInfo</a><li>maxSymbolsSupported
+: <a class="el" href="struct__DMXLocalInitInfo.html#o29">_DMXLocalInitInfo</a><li>maxval
+: <a class="el" href="struct__DMXLocalInitInfo.html#o16">_DMXLocalInitInfo</a><li>mCtrl
+: <a class="el" href="struct__DMXLocalInputInfo.html#o20">_DMXLocalInputInfo</a><li>mctrl
+: <a class="el" href="struct__DMXLocalInputInfo.html#o27">_DMXLocalInputInfo</a><li>minres
+: <a class="el" href="struct__DMXLocalInitInfo.html#o18">_DMXLocalInitInfo</a><li>minval
+: <a class="el" href="struct__DMXLocalInitInfo.html#o15">_DMXLocalInitInfo</a><li>modMap
+: <a class="el" href="struct__DMXLocalInitInfo.html#o4">_DMXLocalInitInfo</a></ul>
+<h3><a class="anchor" name="index_n">- n -</a></h3><ul>
+<li>name
+: <a class="el" href="struct__DMXLocalInputInfo.html#o0">_DMXLocalInputInfo</a>, <a class="el" href="struct__DMXInputInfo.html#o0">_DMXInputInfo</a>, <a class="el" href="struct__DMXScreenInfo.html#o0">_DMXScreenInfo</a><li>names
+: <a class="el" href="struct__DMXLocalInitInfo.html#o6">_DMXLocalInitInfo</a><li>needsSync
+: <a class="el" href="struct__DMXScreenInfo.html#o58">_DMXScreenInfo</a><li>next
+: <a class="el" href="struct__DMXScreenInfo.html#o28">_DMXScreenInfo</a><li>numAbsAxes
+: <a class="el" href="struct__DMXLocalInitInfo.html#o14">_DMXLocalInitInfo</a><li>numButtons
+: <a class="el" href="struct__DMXLocalInitInfo.html#o10">_DMXLocalInitInfo</a><li>numDevs
+: <a class="el" href="struct__DMXInputInfo.html#o16">_DMXInputInfo</a><li>numLeds
+: <a class="el" href="struct__myPrivate.html#o59">_myPrivate</a><li>numRelAxes
+: <a class="el" href="struct__DMXLocalInitInfo.html#o13">_DMXLocalInitInfo</a></ul>
+<h3><a class="anchor" name="index_o">- o -</a></h3><ul>
+<li>off
+: <a class="el" href="struct__DMXLocalInputInfo.html#o11">_DMXLocalInputInfo</a><li>on
+: <a class="el" href="struct__DMXLocalInputInfo.html#o10">_DMXLocalInputInfo</a><li>over
+: <a class="el" href="struct__DMXScreenInfo.html#o29">_DMXScreenInfo</a></ul>
+<h3><a class="anchor" name="index_p">- p -</a></h3><ul>
+<li>pDequeueScreen
+: <a class="el" href="struct__EventQueue.html#o8">_EventQueue</a><li>pDevice
+: <a class="el" href="struct__myPrivate.html#o55">_myPrivate</a>, <a class="el" href="struct__DMXLocalInputInfo.html#o28">_DMXLocalInputInfo</a><li>pEnqueueScreen
+: <a class="el" href="struct__EventQueue.html#o7">_EventQueue</a><li>pict
+: <a class="el" href="struct__dmxPictPriv.html#o0">_dmxPictPriv</a><li>pitch
+: <a class="el" href="struct__myPrivate.html#o49">_myPrivate</a><li>pPtr
+: <a class="el" href="struct__EventQueue.html#o6">_EventQueue</a><li>private
+: <a class="el" href="struct__DMXLocalInputInfo.html#o23">_DMXLocalInputInfo</a><li>process_input
+: <a class="el" href="struct__DMXLocalInputInfo.html#o17">_DMXLocalInputInfo</a><li>proximityClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o21">_DMXLocalInitInfo</a><li>pScreen
+: <a class="el" href="struct__Event.html#o1">_Event</a><li>ptrFeedbackClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o23">_DMXLocalInitInfo</a></ul>
+<h3><a class="anchor" name="index_r">- r -</a></h3><ul>
+<li>reinit
+: <a class="el" href="struct__DMXLocalInputInfo.html#o7">_DMXLocalInputInfo</a><li>relmap
+: <a class="el" href="struct__myPrivate.html#o60">_myPrivate</a><li>remote
+: <a class="el" href="struct__DMXEventMap.html#o0">_DMXEventMap</a><li>res
+: <a class="el" href="struct__DMXLocalInitInfo.html#o17">_DMXLocalInitInfo</a><li>rootHeight
+: <a class="el" href="struct__DMXScreenInfo.html#o34">_DMXScreenInfo</a><li>rootWidth
+: <a class="el" href="struct__DMXScreenInfo.html#o33">_DMXScreenInfo</a><li>rootWin
+: <a class="el" href="struct__DMXScreenInfo.html#o30">_DMXScreenInfo</a><li>rootX
+: <a class="el" href="struct__DMXScreenInfo.html#o31">_DMXScreenInfo</a><li>rootXOrigin
+: <a class="el" href="struct__DMXScreenInfo.html#o35">_DMXScreenInfo</a><li>rootY
+: <a class="el" href="struct__DMXScreenInfo.html#o32">_DMXScreenInfo</a><li>rootYOrigin
+: <a class="el" href="struct__DMXScreenInfo.html#o36">_DMXScreenInfo</a></ul>
+<h3><a class="anchor" name="index_s">- s -</a></h3><ul>
+<li>savedMask
+: <a class="el" href="struct__dmxPictPriv.html#o1">_dmxPictPriv</a><li>savedMotionEvents
+: <a class="el" href="struct__DMXLocalInputInfo.html#o37">_DMXLocalInputInfo</a><li>savedSendsCore
+: <a class="el" href="struct__DMXLocalInputInfo.html#o38">_DMXLocalInputInfo</a><li>savedTimeout
+: <a class="el" href="struct__DMXScreenInfo.html#o51">_DMXScreenInfo</a><li>scrnDefDrawables
+: <a class="el" href="struct__DMXScreenInfo.html#o27">_DMXScreenInfo</a><li>scrnHeight
+: <a class="el" href="struct__DMXScreenInfo.html#o24">_DMXScreenInfo</a><li>scrnIdx
+: <a class="el" href="struct__DMXInputInfo.html#o4">_DMXInputInfo</a><li>scrnWidth
+: <a class="el" href="struct__DMXScreenInfo.html#o23">_DMXScreenInfo</a><li>scrnWin
+: <a class="el" href="struct__DMXScreenInfo.html#o20">_DMXScreenInfo</a><li>scrnX
+: <a class="el" href="struct__DMXScreenInfo.html#o21">_DMXScreenInfo</a><li>scrnXSign
+: <a class="el" href="struct__DMXScreenInfo.html#o25">_DMXScreenInfo</a><li>scrnY
+: <a class="el" href="struct__DMXScreenInfo.html#o22">_DMXScreenInfo</a><li>scrnYSign
+: <a class="el" href="struct__DMXScreenInfo.html#o26">_DMXScreenInfo</a><li>sendsCore
+: <a class="el" href="struct__DMXLocalInputInfo.html#o25">_DMXLocalInputInfo</a><li>server
+: <a class="el" href="struct__DMXEventMap.html#o1">_DMXEventMap</a><li>shadow
+: <a class="el" href="struct__DMXScreenInfo.html#o37">_DMXScreenInfo</a><li>shadowFBImage
+: <a class="el" href="struct__DMXScreenInfo.html#o39">_DMXScreenInfo</a><li>shadowGC
+: <a class="el" href="struct__DMXScreenInfo.html#o38">_DMXScreenInfo</a><li>shared
+: <a class="el" href="struct__DMXScreenInfo.html#o40">_DMXScreenInfo</a><li>sigioAdded
+: <a class="el" href="struct__DMXInputInfo.html#o13">_DMXInputInfo</a><li>sigioFd
+: <a class="el" href="struct__DMXInputInfo.html#o12">_DMXInputInfo</a><li>sigioFdCount
+: <a class="el" href="struct__DMXInputInfo.html#o11">_DMXInputInfo</a><li>sigioState
+: <a class="el" href="struct__DMXInputInfo.html#o10">_DMXInputInfo</a><li>stat
+: <a class="el" href="struct__DMXScreenInfo.html#o57">_DMXScreenInfo</a><li>strFeedbackClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o27">_DMXLocalInitInfo</a><li>symbols
+: <a class="el" href="struct__DMXLocalInitInfo.html#o30">_DMXLocalInitInfo</a>, <a class="el" href="struct__DMXInputInfo.html#o19">_DMXInputInfo</a></ul>
+<h3><a class="anchor" name="index_t">- t -</a></h3><ul>
+<li>tail
+: <a class="el" href="struct__DMXLocalInputInfo.html#o33">_DMXLocalInputInfo</a>, <a class="el" href="struct__EventQueue.html#o1">_EventQueue</a><li>type
+: <a class="el" href="struct__DMXLocalInputInfo.html#o1">_DMXLocalInputInfo</a></ul>
+<h3><a class="anchor" name="index_u">- u -</a></h3><ul>
+<li>update_info
+: <a class="el" href="struct__DMXLocalInputInfo.html#o19">_DMXLocalInputInfo</a><li>update_position
+: <a class="el" href="struct__DMXLocalInputInfo.html#o12">_DMXLocalInputInfo</a></ul>
+<h3><a class="anchor" name="index_v">- v -</a></h3><ul>
+<li>valuator
+: <a class="el" href="struct__Event.html#o2">_Event</a><li>valuatorClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o12">_DMXLocalInitInfo</a><li>valuators
+: <a class="el" href="struct__DMXLocalInputInfo.html#o35">_DMXLocalInputInfo</a><li>vt_post_switch
+: <a class="el" href="struct__DMXLocalInputInfo.html#o14">_DMXLocalInputInfo</a><li>vt_pre_switch
+: <a class="el" href="struct__DMXLocalInputInfo.html#o13">_DMXLocalInputInfo</a><li>vt_switch
+: <a class="el" href="struct__DMXLocalInputInfo.html#o15">_DMXLocalInputInfo</a><li>vt_switch_pending
+: <a class="el" href="struct__DMXInputInfo.html#o14">_DMXInputInfo</a><li>vt_switched
+: <a class="el" href="struct__DMXInputInfo.html#o15">_DMXInputInfo</a></ul>
+<h3><a class="anchor" name="index_w">- w -</a></h3><ul>
+<li>where
+: <a class="el" href="struct__DMXScreenInfo.html#o47">_DMXScreenInfo</a><li>whereRefScreen
+: <a class="el" href="struct__DMXScreenInfo.html#o50">_DMXScreenInfo</a><li>whereX
+: <a class="el" href="struct__DMXScreenInfo.html#o48">_DMXScreenInfo</a><li>whereY
+: <a class="el" href="struct__DMXScreenInfo.html#o49">_DMXScreenInfo</a><li>windows
+: <a class="el" href="struct__DMXInputInfo.html#o7">_DMXInputInfo</a></ul>
+<h3><a class="anchor" name="index_x">- x -</a></h3><ul>
+<li>xkb
+: <a class="el" href="struct__DMXLocalInitInfo.html#o5">_DMXLocalInitInfo</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/functions_vars.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/functions_vars.html
new file mode 100644
index 000000000..71c36065d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/functions_vars.html
@@ -0,0 +1,237 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindexHL" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<div class="qindex"><a class="qindex" href="functions.html">All</a> | <a class="qindexHL" href="functions_vars.html">Variables</a></div>
+<div class="qindex"><a class="qindex" href="#index_a">a</a> | <a class="qindex" href="#index_b">b</a> | <a class="qindex" href="#index_c">c</a> | <a class="qindex" href="#index_d">d</a> | <a class="qindex" href="#index_e">e</a> | <a class="qindex" href="#index_f">f</a> | <a class="qindex" href="#index_g">g</a> | <a class="qindex" href="#index_h">h</a> | <a class="qindex" href="#index_i">i</a> | <a class="qindex" href="#index_k">k</a> | <a class="qindex" href="#index_l">l</a> | <a class="qindex" href="#index_m">m</a> | <a class="qindex" href="#index_n">n</a> | <a class="qindex" href="#index_o">o</a> | <a class="qindex" href="#index_p">p</a> | <a class="qindex" href="#index_r">r</a> | <a class="qindex" href="#index_s">s</a> | <a class="qindex" href="#index_t">t</a> | <a class="qindex" href="#index_u">u</a> | <a class="qindex" href="#index_v">v</a> | <a class="qindex" href="#index_w">w</a> | <a class="qindex" href="#index_x">x</a></div>
+
+<p>
+
+<p>
+<h3><a class="anchor" name="index_a">- a -</a></h3><ul>
+<li>absmap
+: <a class="el" href="struct__myPrivate.html#o61">_myPrivate</a><li>argc
+: <a class="el" href="struct__dmxArg.html#o0">_dmxArg</a><li>argm
+: <a class="el" href="struct__dmxArg.html#o1">_dmxArg</a><li>argv
+: <a class="el" href="struct__dmxArg.html#o2">_dmxArg</a></ul>
+<h3><a class="anchor" name="index_b">- b -</a></h3><ul>
+<li>beBlackPixel
+: <a class="el" href="struct__DMXScreenInfo.html#o18">_DMXScreenInfo</a><li>beBPP
+: <a class="el" href="struct__DMXScreenInfo.html#o6">_DMXScreenInfo</a><li>beDefColormaps
+: <a class="el" href="struct__DMXScreenInfo.html#o17">_DMXScreenInfo</a><li>beDefVisualIndex
+: <a class="el" href="struct__DMXScreenInfo.html#o15">_DMXScreenInfo</a><li>beDepth
+: <a class="el" href="struct__DMXScreenInfo.html#o5">_DMXScreenInfo</a><li>beDepths
+: <a class="el" href="struct__DMXScreenInfo.html#o10">_DMXScreenInfo</a><li>beDisplay
+: <a class="el" href="struct__DMXScreenInfo.html#o2">_DMXScreenInfo</a><li>beHeight
+: <a class="el" href="struct__DMXScreenInfo.html#o4">_DMXScreenInfo</a><li>belFeedbackClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o25">_DMXLocalInitInfo</a><li>beNumDefColormaps
+: <a class="el" href="struct__DMXScreenInfo.html#o16">_DMXScreenInfo</a><li>beNumDepths
+: <a class="el" href="struct__DMXScreenInfo.html#o9">_DMXScreenInfo</a><li>beNumPixmapFormats
+: <a class="el" href="struct__DMXScreenInfo.html#o11">_DMXScreenInfo</a><li>beNumVisuals
+: <a class="el" href="struct__DMXScreenInfo.html#o13">_DMXScreenInfo</a><li>bePixmapFormats
+: <a class="el" href="struct__DMXScreenInfo.html#o12">_DMXScreenInfo</a><li>beVisuals
+: <a class="el" href="struct__DMXScreenInfo.html#o14">_DMXScreenInfo</a><li>beWhitePixel
+: <a class="el" href="struct__DMXScreenInfo.html#o19">_DMXScreenInfo</a><li>beWidth
+: <a class="el" href="struct__DMXScreenInfo.html#o3">_DMXScreenInfo</a><li>beXDPI
+: <a class="el" href="struct__DMXScreenInfo.html#o7">_DMXScreenInfo</a><li>beYDPI
+: <a class="el" href="struct__DMXScreenInfo.html#o8">_DMXScreenInfo</a><li>binding
+: <a class="el" href="struct__DMXLocalInputInfo.html#o3">_DMXLocalInputInfo</a><li>buttonClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o9">_DMXLocalInitInfo</a></ul>
+<h3><a class="anchor" name="index_c">- c -</a></h3><ul>
+<li>CloseScreen
+: <a class="el" href="struct__DMXScreenInfo.html#o59">_DMXScreenInfo</a><li>collect_events
+: <a class="el" href="struct__DMXLocalInputInfo.html#o16">_DMXLocalInputInfo</a><li>console
+: <a class="el" href="struct__DMXInputInfo.html#o6">_DMXInputInfo</a><li>core
+: <a class="el" href="struct__DMXInputInfo.html#o5">_DMXInputInfo</a><li>create_private
+: <a class="el" href="struct__DMXLocalInputInfo.html#o4">_DMXLocalInputInfo</a></ul>
+<h3><a class="anchor" name="index_d">- d -</a></h3><ul>
+<li>destroy_private
+: <a class="el" href="struct__DMXLocalInputInfo.html#o5">_DMXLocalInputInfo</a><li>detached
+: <a class="el" href="struct__DMXInputInfo.html#o2">_DMXInputInfo</a><li>deviceId
+: <a class="el" href="struct__DMXLocalInputInfo.html#o41">_DMXLocalInputInfo</a><li>deviceName
+: <a class="el" href="struct__DMXLocalInputInfo.html#o42">_DMXLocalInputInfo</a><li>devs
+: <a class="el" href="struct__DMXInputInfo.html#o17">_DMXInputInfo</a><li>dmxInput
+: <a class="el" href="struct__myPrivate.html#o62">_myPrivate</a><li>dpmsCapable
+: <a class="el" href="struct__DMXScreenInfo.html#o52">_DMXScreenInfo</a><li>dpmsEnabled
+: <a class="el" href="struct__DMXScreenInfo.html#o53">_DMXScreenInfo</a><li>dpmsOff
+: <a class="el" href="struct__DMXScreenInfo.html#o56">_DMXScreenInfo</a><li>dpmsStandby
+: <a class="el" href="struct__DMXScreenInfo.html#o54">_DMXScreenInfo</a><li>dpmsSuspend
+: <a class="el" href="struct__DMXScreenInfo.html#o55">_DMXScreenInfo</a><li>duration
+: <a class="el" href="struct__myPrivate.html#o50">_myPrivate</a></ul>
+<h3><a class="anchor" name="index_e">- e -</a></h3><ul>
+<li>event
+: <a class="el" href="struct__Event.html#o0">_Event</a><li>events
+: <a class="el" href="struct__EventQueue.html#o4">_EventQueue</a><li>extType
+: <a class="el" href="struct__DMXLocalInputInfo.html#o2">_DMXLocalInputInfo</a></ul>
+<h3><a class="anchor" name="index_f">- f -</a></h3><ul>
+<li>fd
+: <a class="el" href="struct__myPrivate.html#o37">_myPrivate</a><li>focusClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o20">_DMXLocalInitInfo</a><li>force
+: <a class="el" href="struct__DMXLocalInitInfo.html#o8">_DMXLocalInitInfo</a><li>freemap
+: <a class="el" href="struct__DMXLocalInitInfo.html#o3">_DMXLocalInitInfo</a><li>freename
+: <a class="el" href="struct__DMXInputInfo.html#o1">_DMXInputInfo</a><li>freenames
+: <a class="el" href="struct__DMXLocalInitInfo.html#o7">_DMXLocalInitInfo</a></ul>
+<h3><a class="anchor" name="index_g">- g -</a></h3><ul>
+<li>geometry
+: <a class="el" href="struct__DMXInputInfo.html#o20">_DMXInputInfo</a><li>get_info
+: <a class="el" href="struct__DMXLocalInputInfo.html#o9">_DMXLocalInputInfo</a><li>glyphSets
+: <a class="el" href="struct__dmxGlyphPriv.html#o0">_dmxGlyphPriv</a></ul>
+<h3><a class="anchor" name="index_h">- h -</a></h3><ul>
+<li>head
+: <a class="el" href="struct__DMXLocalInputInfo.html#o32">_DMXLocalInputInfo</a>, <a class="el" href="struct__EventQueue.html#o0">_EventQueue</a><li>history
+: <a class="el" href="struct__DMXLocalInputInfo.html#o34">_DMXLocalInputInfo</a></ul>
+<h3><a class="anchor" name="index_i">- i -</a></h3><ul>
+<li>index
+: <a class="el" href="struct__DMXScreenInfo.html#o1">_DMXScreenInfo</a><li>init
+: <a class="el" href="struct__DMXLocalInputInfo.html#o6">_DMXLocalInputInfo</a><li>inputIdx
+: <a class="el" href="struct__DMXLocalInputInfo.html#o29">_DMXLocalInputInfo</a>, <a class="el" href="struct__DMXInputInfo.html#o3">_DMXInputInfo</a><li>intFeedbackClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o26">_DMXLocalInitInfo</a><li>isCore
+: <a class="el" href="struct__DMXLocalInputInfo.html#o24">_DMXLocalInputInfo</a></ul>
+<h3><a class="anchor" name="index_k">- k -</a></h3><ul>
+<li>kbdFeedbackClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o22">_DMXLocalInitInfo</a><li>kbdState
+: <a class="el" href="struct__myPrivate.html#o43">_myPrivate</a><li>kBell
+: <a class="el" href="struct__DMXLocalInputInfo.html#o22">_DMXLocalInputInfo</a><li>kctrl
+: <a class="el" href="struct__DMXLocalInputInfo.html#o26">_DMXLocalInputInfo</a><li>kCtrl
+: <a class="el" href="struct__DMXLocalInputInfo.html#o21">_DMXLocalInputInfo</a><li>keyboard
+: <a class="el" href="struct__DMXLocalInitInfo.html#o0">_DMXLocalInitInfo</a><li>keyClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o1">_DMXLocalInitInfo</a><li>keycodes
+: <a class="el" href="struct__DMXInputInfo.html#o18">_DMXInputInfo</a><li>keySyms
+: <a class="el" href="struct__DMXLocalInitInfo.html#o2">_DMXLocalInitInfo</a></ul>
+<h3><a class="anchor" name="index_l">- l -</a></h3><ul>
+<li>lastEventTime
+: <a class="el" href="struct__EventQueue.html#o2">_EventQueue</a><li>lastMotion
+: <a class="el" href="struct__EventQueue.html#o3">_EventQueue</a><li>lastY
+: <a class="el" href="struct__DMXLocalInputInfo.html#o31">_DMXLocalInputInfo</a><li>latereinit
+: <a class="el" href="struct__DMXLocalInputInfo.html#o8">_DMXLocalInputInfo</a><li>ledFeedbackClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o24">_DMXLocalInitInfo</a></ul>
+<h3><a class="anchor" name="index_m">- m -</a></h3><ul>
+<li>map
+: <a class="el" href="struct__DMXLocalInputInfo.html#o39">_DMXLocalInputInfo</a>, <a class="el" href="struct__DMXLocalInitInfo.html#o11">_DMXLocalInitInfo</a><li>mapOptimize
+: <a class="el" href="struct__DMXLocalInputInfo.html#o40">_DMXLocalInputInfo</a><li>mask
+: <a class="el" href="struct__myPrivate.html#o56">_myPrivate</a><li>maxres
+: <a class="el" href="struct__DMXLocalInitInfo.html#o19">_DMXLocalInitInfo</a><li>maxSymbols
+: <a class="el" href="struct__DMXLocalInitInfo.html#o28">_DMXLocalInitInfo</a><li>maxSymbolsSupported
+: <a class="el" href="struct__DMXLocalInitInfo.html#o29">_DMXLocalInitInfo</a><li>maxval
+: <a class="el" href="struct__DMXLocalInitInfo.html#o16">_DMXLocalInitInfo</a><li>mCtrl
+: <a class="el" href="struct__DMXLocalInputInfo.html#o20">_DMXLocalInputInfo</a><li>mctrl
+: <a class="el" href="struct__DMXLocalInputInfo.html#o27">_DMXLocalInputInfo</a><li>minres
+: <a class="el" href="struct__DMXLocalInitInfo.html#o18">_DMXLocalInitInfo</a><li>minval
+: <a class="el" href="struct__DMXLocalInitInfo.html#o15">_DMXLocalInitInfo</a><li>modMap
+: <a class="el" href="struct__DMXLocalInitInfo.html#o4">_DMXLocalInitInfo</a></ul>
+<h3><a class="anchor" name="index_n">- n -</a></h3><ul>
+<li>name
+: <a class="el" href="struct__DMXLocalInputInfo.html#o0">_DMXLocalInputInfo</a>, <a class="el" href="struct__DMXInputInfo.html#o0">_DMXInputInfo</a>, <a class="el" href="struct__DMXScreenInfo.html#o0">_DMXScreenInfo</a><li>names
+: <a class="el" href="struct__DMXLocalInitInfo.html#o6">_DMXLocalInitInfo</a><li>needsSync
+: <a class="el" href="struct__DMXScreenInfo.html#o58">_DMXScreenInfo</a><li>next
+: <a class="el" href="struct__DMXScreenInfo.html#o28">_DMXScreenInfo</a><li>numAbsAxes
+: <a class="el" href="struct__DMXLocalInitInfo.html#o14">_DMXLocalInitInfo</a><li>numButtons
+: <a class="el" href="struct__DMXLocalInitInfo.html#o10">_DMXLocalInitInfo</a><li>numDevs
+: <a class="el" href="struct__DMXInputInfo.html#o16">_DMXInputInfo</a><li>numLeds
+: <a class="el" href="struct__myPrivate.html#o59">_myPrivate</a><li>numRelAxes
+: <a class="el" href="struct__DMXLocalInitInfo.html#o13">_DMXLocalInitInfo</a></ul>
+<h3><a class="anchor" name="index_o">- o -</a></h3><ul>
+<li>off
+: <a class="el" href="struct__DMXLocalInputInfo.html#o11">_DMXLocalInputInfo</a><li>on
+: <a class="el" href="struct__DMXLocalInputInfo.html#o10">_DMXLocalInputInfo</a><li>over
+: <a class="el" href="struct__DMXScreenInfo.html#o29">_DMXScreenInfo</a></ul>
+<h3><a class="anchor" name="index_p">- p -</a></h3><ul>
+<li>pDequeueScreen
+: <a class="el" href="struct__EventQueue.html#o8">_EventQueue</a><li>pDevice
+: <a class="el" href="struct__myPrivate.html#o55">_myPrivate</a>, <a class="el" href="struct__DMXLocalInputInfo.html#o28">_DMXLocalInputInfo</a><li>pEnqueueScreen
+: <a class="el" href="struct__EventQueue.html#o7">_EventQueue</a><li>pict
+: <a class="el" href="struct__dmxPictPriv.html#o0">_dmxPictPriv</a><li>pitch
+: <a class="el" href="struct__myPrivate.html#o49">_myPrivate</a><li>pPtr
+: <a class="el" href="struct__EventQueue.html#o6">_EventQueue</a><li>private
+: <a class="el" href="struct__DMXLocalInputInfo.html#o23">_DMXLocalInputInfo</a><li>process_input
+: <a class="el" href="struct__DMXLocalInputInfo.html#o17">_DMXLocalInputInfo</a><li>proximityClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o21">_DMXLocalInitInfo</a><li>pScreen
+: <a class="el" href="struct__Event.html#o1">_Event</a><li>ptrFeedbackClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o23">_DMXLocalInitInfo</a></ul>
+<h3><a class="anchor" name="index_r">- r -</a></h3><ul>
+<li>reinit
+: <a class="el" href="struct__DMXLocalInputInfo.html#o7">_DMXLocalInputInfo</a><li>relmap
+: <a class="el" href="struct__myPrivate.html#o60">_myPrivate</a><li>remote
+: <a class="el" href="struct__DMXEventMap.html#o0">_DMXEventMap</a><li>res
+: <a class="el" href="struct__DMXLocalInitInfo.html#o17">_DMXLocalInitInfo</a><li>rootHeight
+: <a class="el" href="struct__DMXScreenInfo.html#o34">_DMXScreenInfo</a><li>rootWidth
+: <a class="el" href="struct__DMXScreenInfo.html#o33">_DMXScreenInfo</a><li>rootWin
+: <a class="el" href="struct__DMXScreenInfo.html#o30">_DMXScreenInfo</a><li>rootX
+: <a class="el" href="struct__DMXScreenInfo.html#o31">_DMXScreenInfo</a><li>rootXOrigin
+: <a class="el" href="struct__DMXScreenInfo.html#o35">_DMXScreenInfo</a><li>rootY
+: <a class="el" href="struct__DMXScreenInfo.html#o32">_DMXScreenInfo</a><li>rootYOrigin
+: <a class="el" href="struct__DMXScreenInfo.html#o36">_DMXScreenInfo</a></ul>
+<h3><a class="anchor" name="index_s">- s -</a></h3><ul>
+<li>savedMask
+: <a class="el" href="struct__dmxPictPriv.html#o1">_dmxPictPriv</a><li>savedMotionEvents
+: <a class="el" href="struct__DMXLocalInputInfo.html#o37">_DMXLocalInputInfo</a><li>savedSendsCore
+: <a class="el" href="struct__DMXLocalInputInfo.html#o38">_DMXLocalInputInfo</a><li>savedTimeout
+: <a class="el" href="struct__DMXScreenInfo.html#o51">_DMXScreenInfo</a><li>scrnDefDrawables
+: <a class="el" href="struct__DMXScreenInfo.html#o27">_DMXScreenInfo</a><li>scrnHeight
+: <a class="el" href="struct__DMXScreenInfo.html#o24">_DMXScreenInfo</a><li>scrnIdx
+: <a class="el" href="struct__DMXInputInfo.html#o4">_DMXInputInfo</a><li>scrnWidth
+: <a class="el" href="struct__DMXScreenInfo.html#o23">_DMXScreenInfo</a><li>scrnWin
+: <a class="el" href="struct__DMXScreenInfo.html#o20">_DMXScreenInfo</a><li>scrnX
+: <a class="el" href="struct__DMXScreenInfo.html#o21">_DMXScreenInfo</a><li>scrnXSign
+: <a class="el" href="struct__DMXScreenInfo.html#o25">_DMXScreenInfo</a><li>scrnY
+: <a class="el" href="struct__DMXScreenInfo.html#o22">_DMXScreenInfo</a><li>scrnYSign
+: <a class="el" href="struct__DMXScreenInfo.html#o26">_DMXScreenInfo</a><li>sendsCore
+: <a class="el" href="struct__DMXLocalInputInfo.html#o25">_DMXLocalInputInfo</a><li>server
+: <a class="el" href="struct__DMXEventMap.html#o1">_DMXEventMap</a><li>shadow
+: <a class="el" href="struct__DMXScreenInfo.html#o37">_DMXScreenInfo</a><li>shadowFBImage
+: <a class="el" href="struct__DMXScreenInfo.html#o39">_DMXScreenInfo</a><li>shadowGC
+: <a class="el" href="struct__DMXScreenInfo.html#o38">_DMXScreenInfo</a><li>shared
+: <a class="el" href="struct__DMXScreenInfo.html#o40">_DMXScreenInfo</a><li>sigioAdded
+: <a class="el" href="struct__DMXInputInfo.html#o13">_DMXInputInfo</a><li>sigioFd
+: <a class="el" href="struct__DMXInputInfo.html#o12">_DMXInputInfo</a><li>sigioFdCount
+: <a class="el" href="struct__DMXInputInfo.html#o11">_DMXInputInfo</a><li>sigioState
+: <a class="el" href="struct__DMXInputInfo.html#o10">_DMXInputInfo</a><li>stat
+: <a class="el" href="struct__DMXScreenInfo.html#o57">_DMXScreenInfo</a><li>strFeedbackClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o27">_DMXLocalInitInfo</a><li>symbols
+: <a class="el" href="struct__DMXLocalInitInfo.html#o30">_DMXLocalInitInfo</a>, <a class="el" href="struct__DMXInputInfo.html#o19">_DMXInputInfo</a></ul>
+<h3><a class="anchor" name="index_t">- t -</a></h3><ul>
+<li>tail
+: <a class="el" href="struct__DMXLocalInputInfo.html#o33">_DMXLocalInputInfo</a>, <a class="el" href="struct__EventQueue.html#o1">_EventQueue</a><li>type
+: <a class="el" href="struct__DMXLocalInputInfo.html#o1">_DMXLocalInputInfo</a></ul>
+<h3><a class="anchor" name="index_u">- u -</a></h3><ul>
+<li>update_info
+: <a class="el" href="struct__DMXLocalInputInfo.html#o19">_DMXLocalInputInfo</a><li>update_position
+: <a class="el" href="struct__DMXLocalInputInfo.html#o12">_DMXLocalInputInfo</a></ul>
+<h3><a class="anchor" name="index_v">- v -</a></h3><ul>
+<li>valuator
+: <a class="el" href="struct__Event.html#o2">_Event</a><li>valuatorClass
+: <a class="el" href="struct__DMXLocalInitInfo.html#o12">_DMXLocalInitInfo</a><li>valuators
+: <a class="el" href="struct__DMXLocalInputInfo.html#o35">_DMXLocalInputInfo</a><li>vt_post_switch
+: <a class="el" href="struct__DMXLocalInputInfo.html#o14">_DMXLocalInputInfo</a><li>vt_pre_switch
+: <a class="el" href="struct__DMXLocalInputInfo.html#o13">_DMXLocalInputInfo</a><li>vt_switch
+: <a class="el" href="struct__DMXLocalInputInfo.html#o15">_DMXLocalInputInfo</a><li>vt_switch_pending
+: <a class="el" href="struct__DMXInputInfo.html#o14">_DMXInputInfo</a><li>vt_switched
+: <a class="el" href="struct__DMXInputInfo.html#o15">_DMXInputInfo</a></ul>
+<h3><a class="anchor" name="index_w">- w -</a></h3><ul>
+<li>where
+: <a class="el" href="struct__DMXScreenInfo.html#o47">_DMXScreenInfo</a><li>whereRefScreen
+: <a class="el" href="struct__DMXScreenInfo.html#o50">_DMXScreenInfo</a><li>whereX
+: <a class="el" href="struct__DMXScreenInfo.html#o48">_DMXScreenInfo</a><li>whereY
+: <a class="el" href="struct__DMXScreenInfo.html#o49">_DMXScreenInfo</a><li>windows
+: <a class="el" href="struct__DMXInputInfo.html#o7">_DMXInputInfo</a></ul>
+<h3><a class="anchor" name="index_x">- x -</a></h3><ul>
+<li>xkb
+: <a class="el" href="struct__DMXLocalInitInfo.html#o5">_DMXLocalInitInfo</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/globals.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/globals.html
new file mode 100644
index 000000000..5a81930af
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/globals.html
@@ -0,0 +1,522 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindexHL" href="globals.html">Globals</a></div>
+<div class="qindex"><a class="qindexHL" href="globals.html">All</a> | <a class="qindex" href="globals_func.html">Functions</a> | <a class="qindex" href="globals_vars.html">Variables</a> | <a class="qindex" href="globals_type.html">Typedefs</a> | <a class="qindex" href="globals_enum.html">Enumerations</a> | <a class="qindex" href="globals_eval.html">Enumeration&nbsp;values</a> | <a class="qindex" href="globals_defs.html">Defines</a></div>
+<div class="qindex"><a class="qindex" href="#index_a">a</a> | <a class="qindex" href="#index_c">c</a> | <a class="qindex" href="#index_d">d</a> | <a class="qindex" href="#index_e">e</a> | <a class="qindex" href="#index_g">g</a> | <a class="qindex" href="#index_i">i</a> | <a class="qindex" href="#index_k">k</a> | <a class="qindex" href="#index_l">l</a> | <a class="qindex" href="#index_m">m</a> | <a class="qindex" href="#index_o">o</a> | <a class="qindex" href="#index_p">p</a> | <a class="qindex" href="#index_q">q</a> | <a class="qindex" href="#index_s">s</a> | <a class="qindex" href="#index_u">u</a> | <a class="qindex" href="#index_x">x</a></div>
+
+<p>
+
+<p>
+Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation:<h3><a class="anchor" name="index_a">- a -</a></h3><ul>
+<li>AbortDDX()
+: <a class="el" href="dmxinit_8c.html#a36">dmxinit.c</a><li>AbortServer()
+: <a class="el" href="dmxlog_8c.html#a3">dmxlog.c</a><li>AddOtherInputDevices()
+: <a class="el" href="dmxxinput_8c.html#a4">dmxxinput.c</a></ul>
+<h3><a class="anchor" name="index_c">- c -</a></h3><ul>
+<li>ChangeDeviceControl()
+: <a class="el" href="dmxxinput_8c.html#a8">dmxxinput.c</a><li>ChangeKeyboardDevice()
+: <a class="el" href="dmxxinput_8c.html#a1">dmxxinput.c</a><li>ChangePointerDevice()
+: <a class="el" href="dmxxinput_8c.html#a2">dmxxinput.c</a><li>CloseInputDevice()
+: <a class="el" href="dmxxinput_8c.html#a3">dmxxinput.c</a></ul>
+<h3><a class="anchor" name="index_d">- d -</a></h3><ul>
+<li>ddxGiveUp()
+: <a class="el" href="dmxinit_8c.html#a37">dmxinit.c</a><li>ddxProcessArgument()
+: <a class="el" href="dmxinit_8c.html#a40">dmxinit.c</a><li>ddxUseMsg()
+: <a class="el" href="dmxinit_8c.html#a41">dmxinit.c</a><li>DMX_ACTIVESIGIO
+: <a class="el" href="dmxinput_8h.html#a31a14">dmxinput.h</a><li>DMX_ATOMNAME
+: <a class="el" href="dmxprop_8c.html#a0">dmxprop.c</a><li>DMX_GET_COLORMAP_PRIV
+: <a class="el" href="dmxcmap_8h.html#a1">dmxcmap.h</a><li>DMX_GET_GC_PRIV
+: <a class="el" href="dmxgc_8h.html#a0">dmxgc.h</a><li>DMX_GET_GLYPH_PRIV
+: <a class="el" href="dmxpict_8h.html#a2">dmxpict.h</a><li>DMX_GET_PICT_PRIV
+: <a class="el" href="dmxpict_8h.html#a0">dmxpict.h</a><li>DMX_GET_PIXMAP_PRIV
+: <a class="el" href="dmxpixmap_8h.html#a0">dmxpixmap.h</a><li>DMX_GET_WINDOW_PRIV
+: <a class="el" href="dmxwindow_8h.html#a0">dmxwindow.h</a><li>DMX_IDENT
+: <a class="el" href="dmxprop_8c.html#a1">dmxprop.c</a><li>DMX_MAX_SIGIO_FDS
+: <a class="el" href="dmxinput_8h.html#a0">dmxinput.h</a><li>DMX_NOSIGIO
+: <a class="el" href="dmxinput_8h.html#a31a12">dmxinput.h</a><li>DMX_SET_COLORMAP_PRIV
+: <a class="el" href="dmxcmap_8h.html#a0">dmxcmap.h</a><li>DMX_SET_GLYPH_PRIV
+: <a class="el" href="dmxpict_8h.html#a1">dmxpict.h</a><li>DMX_STAT_BIN0
+: <a class="el" href="dmxstat_8h.html#a3">dmxstat.h</a><li>DMX_STAT_BINMULT
+: <a class="el" href="dmxstat_8h.html#a4">dmxstat.h</a><li>DMX_STAT_BINS
+: <a class="el" href="dmxstat_8h.html#a2">dmxstat.h</a><li>DMX_STAT_INTERVAL
+: <a class="el" href="dmxstat_8h.html#a1">dmxstat.h</a><li>DMX_STAT_LENGTH
+: <a class="el" href="dmxstat_8h.html#a0">dmxstat.h</a><li>DMX_UNWRAP
+: <a class="el" href="dmx_8h.html#a1">dmx.h</a><li>DMX_UPDATE_COPY
+: <a class="el" href="dmxinput_8h.html#a30a9">dmxinput.h</a><li>DMX_UPDATE_REALIZE
+: <a class="el" href="dmxinput_8h.html#a30a6">dmxinput.h</a><li>DMX_UPDATE_REPARENT
+: <a class="el" href="dmxinput_8h.html#a30a11">dmxinput.h</a><li>DMX_UPDATE_RESIZE
+: <a class="el" href="dmxinput_8h.html#a30a10">dmxinput.h</a><li>DMX_UPDATE_RESTACK
+: <a class="el" href="dmxinput_8h.html#a30a8">dmxinput.h</a><li>DMX_UPDATE_UNREALIZE
+: <a class="el" href="dmxinput_8h.html#a30a7">dmxinput.h</a><li>DMX_USESIGIO
+: <a class="el" href="dmxinput_8h.html#a31a13">dmxinput.h</a><li>DMX_WRAP
+: <a class="el" href="dmx_8h.html#a0">dmx.h</a><li>DMXAddBackendInput()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a31">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a39">dmxext.h</a><li>DMXAddConsoleInput()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a32">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a40">dmxext.h</a><li>dmxAddInput()
+: <a class="el" href="dmxextension_8h.html#a12">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a7">dmxextension.c</a><li>DMXAddInput()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a30">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a37">dmxext.h</a><li>dmxAddRemoveScreens
+: <a class="el" href="dmxinit_8c.html#a17">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a18">dmx.h</a><li>DMXAddScreen()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a21">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a30">dmxext.h</a><li>dmxArgAdd()
+: <a class="el" href="dmxarg_8h.html#a3">dmxarg.h</a>, <a class="el" href="dmxarg_8c.html#a3">dmxarg.c</a><li>dmxArgC()
+: <a class="el" href="dmxarg_8h.html#a5">dmxarg.h</a>, <a class="el" href="dmxarg_8c.html#a5">dmxarg.c</a><li>dmxArgCreate()
+: <a class="el" href="dmxarg_8h.html#a1">dmxarg.h</a>, <a class="el" href="dmxarg_8c.html#a1">dmxarg.c</a><li>dmxArgFree()
+: <a class="el" href="dmxarg_8h.html#a2">dmxarg.h</a>, <a class="el" href="dmxarg_8c.html#a2">dmxarg.c</a><li>dmxArgParse()
+: <a class="el" href="dmxarg_8h.html#a6">dmxarg.h</a>, <a class="el" href="dmxarg_8c.html#a6">dmxarg.c</a><li>dmxArgV()
+: <a class="el" href="dmxarg_8h.html#a4">dmxarg.h</a>, <a class="el" href="dmxarg_8c.html#a4">dmxarg.c</a><li>dmxAttachScreen()
+: <a class="el" href="dmxextension_8h.html#a17">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a18">dmxextension.c</a><li>dmxBackendCollectEvents()
+: <a class="el" href="dmxbackend_8h.html#a6">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a25">dmxbackend.c</a><li>dmxBackendCreatePrivate()
+: <a class="el" href="dmxbackend_8h.html#a0">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a12">dmxbackend.c</a><li>dmxBackendDestroyPrivate()
+: <a class="el" href="dmxbackend_8h.html#a1">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a13">dmxbackend.c</a><li>dmxBackendFunctions()
+: <a class="el" href="dmxbackend_8h.html#a8">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a33">dmxbackend.c</a><li>dmxBackendInit()
+: <a class="el" href="dmxbackend_8h.html#a2">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a30">dmxbackend.c</a><li>dmxBackendKbdGetInfo()
+: <a class="el" href="dmxbackend_8h.html#a5">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a32">dmxbackend.c</a><li>dmxBackendLateReInit()
+: <a class="el" href="dmxbackend_8h.html#a3">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a29">dmxbackend.c</a><li>dmxBackendMouGetInfo()
+: <a class="el" href="dmxbackend_8h.html#a4">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a31">dmxbackend.c</a><li>dmxBackendProcessInput()
+: <a class="el" href="dmxbackend_8h.html#a7">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a26">dmxbackend.c</a><li>dmxBackendUpdatePosition()
+: <a class="el" href="dmxbackend_8h.html#a9">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a24">dmxbackend.c</a><li>dmxBECloseScreen()
+: <a class="el" href="dmxscrinit_8h.html#a3">dmxscrinit.h</a>, <a class="el" href="dmxscrinit_8c.html#a13">dmxscrinit.c</a><li>dmxBECreateColormap()
+: <a class="el" href="dmxcmap_8h.html#a10">dmxcmap.h</a>, <a class="el" href="dmxcmap_8c.html#a2">dmxcmap.c</a><li>dmxBECreateCursor()
+: <a class="el" href="dmxcursor_8h.html#a13">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a29">dmxcursor.c</a><li>dmxBECreateGC()
+: <a class="el" href="dmxgc_8h.html#a15">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a3">dmxgc.c</a><li>dmxBECreatePixmap()
+: <a class="el" href="dmxpixmap_8h.html#a8">dmxpixmap.h</a>, <a class="el" href="dmxpixmap_8c.html#a1">dmxpixmap.c</a><li>dmxBEDestroyWindow()
+: <a class="el" href="dmxwindow_8h.html#a31">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a11">dmxwindow.c</a><li>dmxBEFreeColormap()
+: <a class="el" href="dmxcmap_8h.html#a11">dmxcmap.h</a>, <a class="el" href="dmxcmap_8c.html#a4">dmxcmap.c</a><li>dmxBEFreeCursor()
+: <a class="el" href="dmxcursor_8h.html#a14">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a31">dmxcursor.c</a><li>dmxBEFreeFont()
+: <a class="el" href="dmxfont_8h.html#a8">dmxfont.h</a>, <a class="el" href="dmxfont_8c.html#a14">dmxfont.c</a><li>dmxBEFreeGC()
+: <a class="el" href="dmxgc_8h.html#a16">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a8">dmxgc.c</a><li>dmxBEFreeGlyphSet()
+: <a class="el" href="dmxpict_8h.html#a30">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a16">dmxpict.c</a><li>dmxBEFreePicture()
+: <a class="el" href="dmxpict_8h.html#a31">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a20">dmxpict.c</a><li>dmxBEFreePixmap()
+: <a class="el" href="dmxpixmap_8h.html#a9">dmxpixmap.h</a>, <a class="el" href="dmxpixmap_8c.html#a3">dmxpixmap.c</a><li>dmxBELoadFont()
+: <a class="el" href="dmxfont_8h.html#a7">dmxfont.h</a>, <a class="el" href="dmxfont_8c.html#a12">dmxfont.c</a><li>dmxBEScreenInit()
+: <a class="el" href="dmxscrinit_8h.html#a2">dmxscrinit.h</a>, <a class="el" href="dmxscrinit_8c.html#a11">dmxscrinit.c</a><li>dmxBitmapToRegion()
+: <a class="el" href="dmxpixmap_8h.html#a7">dmxpixmap.h</a>, <a class="el" href="dmxpixmap_8c.html#a5">dmxpixmap.c</a><li>dmxChangeBorderWidth()
+: <a class="el" href="dmxwindow_8h.html#a28">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a25">dmxwindow.c</a><li>dmxChangeClip()
+: <a class="el" href="dmxgc_8h.html#a12">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a10">dmxgc.c</a><li>DMXChangeDesktopAttributes()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a27">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a34">dmxext.h</a><li>dmxChangeGC()
+: <a class="el" href="dmxgc_8h.html#a9">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a6">dmxgc.c</a><li>dmxChangePicture()
+: <a class="el" href="dmxpict_8h.html#a18">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a25">dmxpict.c</a><li>dmxChangePictureClip()
+: <a class="el" href="dmxpict_8h.html#a16">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a23">dmxpict.c</a><li>dmxChangePointerControl()
+: <a class="el" href="dmxinputinit_8h.html#a54">dmxinputinit.h</a>, <a class="el" href="dmxinputinit_8c.html#a16">dmxinputinit.c</a><li>DMXChangeScreensAttributes()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a20">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a29">dmxext.h</a><li>dmxChangeWindowAttributes()
+: <a class="el" href="dmxwindow_8h.html#a18">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a14">dmxwindow.c</a><li>dmxCheckCursor()
+: <a class="el" href="dmxcursor_8h.html#a10">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a41">dmxcursor.c</a><li>dmxCheckSpecialKeys()
+: <a class="el" href="dmxevents_8h.html#a2">dmxevents.h</a>, <a class="el" href="dmxevents_8c.html#a28">dmxevents.c</a><li>dmxCloseIndexed()
+: <a class="el" href="dmxpict_8h.html#a24">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a31">dmxpict.c</a><li>dmxCloseScreen()
+: <a class="el" href="dmxscrinit_8c.html#a9">dmxscrinit.c</a><li>dmxColormapFromDefaultVisual()
+: <a class="el" href="dmxvisual_8h.html#a2">dmxvisual.h</a>, <a class="el" href="dmxvisual_8c.html#a2">dmxvisual.c</a><li>dmxColormapPrivateIndex
+: <a class="el" href="dmxscrinit_8c.html#a6">dmxscrinit.c</a>, <a class="el" href="dmxcmap_8h.html#a4">dmxcmap.h</a><li>dmxColormapPrivPtr
+: <a class="el" href="dmxcmap_8h.html#a3">dmxcmap.h</a><li>dmxColormapPrivRec
+: <a class="el" href="dmxcmap_8h.html#a2">dmxcmap.h</a><li>dmxCommonCopyPrivate()
+: <a class="el" href="dmxcommon_8h.html#a27">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a26">dmxcommon.c</a><li>dmxCommonKbdBell()
+: <a class="el" href="dmxcommon_8h.html#a16">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a11">dmxcommon.c</a><li>dmxCommonKbdCtrl()
+: <a class="el" href="dmxcommon_8h.html#a15">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a9">dmxcommon.c</a><li>dmxCommonKbdGetInfo()
+: <a class="el" href="dmxcommon_8h.html#a13">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a13">dmxcommon.c</a><li>dmxCommonKbdGetMap()
+: <a class="el" href="dmxcommon_8h.html#a14">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a12">dmxcommon.c</a><li>dmxCommonKbdOff()
+: <a class="el" href="dmxcommon_8h.html#a18">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a15">dmxcommon.c</a><li>dmxCommonKbdOn()
+: <a class="el" href="dmxcommon_8h.html#a17">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a14">dmxcommon.c</a><li>dmxCommonMouCtrl()
+: <a class="el" href="dmxcommon_8h.html#a20">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a10">dmxcommon.c</a><li>dmxCommonMouGetMap()
+: <a class="el" href="dmxcommon_8h.html#a19">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a19">dmxcommon.c</a><li>dmxCommonMouOff()
+: <a class="el" href="dmxcommon_8h.html#a22">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a24">dmxcommon.c</a><li>dmxCommonMouOn()
+: <a class="el" href="dmxcommon_8h.html#a21">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a23">dmxcommon.c</a><li>dmxCommonOthGetInfo()
+: <a class="el" href="dmxcommon_8h.html#a26">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a18">dmxcommon.c</a><li>dmxCommonOthOff()
+: <a class="el" href="dmxcommon_8h.html#a25">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a17">dmxcommon.c</a><li>dmxCommonOthOn()
+: <a class="el" href="dmxcommon_8h.html#a24">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a16">dmxcommon.c</a><li>dmxCommonRestoreState()
+: <a class="el" href="dmxcommon_8h.html#a29">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a28">dmxcommon.c</a><li>dmxCommonSaveState()
+: <a class="el" href="dmxcommon_8h.html#a28">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a27">dmxcommon.c</a><li>dmxComposite()
+: <a class="el" href="dmxpict_8h.html#a20">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a27">dmxpict.c</a><li>dmxCompositeRects()
+: <a class="el" href="dmxpict_8h.html#a22">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a29">dmxpict.c</a><li>dmxComputeWidthHeight()
+: <a class="el" href="dmxcb_8h.html#a5">dmxcb.h</a>, <a class="el" href="dmxcb_8c.html#a8">dmxcb.c</a><li>DMXConfigCmd
+: <a class="el" href="dmxconfig_8c.html#a9">dmxconfig.c</a><li>DMXConfigCmdPtr
+: <a class="el" href="dmxconfig_8c.html#a10">dmxconfig.c</a><li>DMXConfigComment
+: <a class="el" href="dmxparse_8h.html#a8">dmxparse.h</a><li>DMXConfigCommentPtr
+: <a class="el" href="dmxparse_8h.html#a9">dmxparse.h</a><li>dmxConfigConfigure()
+: <a class="el" href="dmxconfig_8h.html#a10">dmxconfig.h</a>, <a class="el" href="dmxconfig_8c.html#a32">dmxconfig.c</a><li>DMXConfigDisplay
+: <a class="el" href="dmxparse_8h.html#a14">dmxparse.h</a><li>DMXConfigDisplayPtr
+: <a class="el" href="dmxparse_8h.html#a15">dmxparse.h</a><li>DMXConfigEntry
+: <a class="el" href="dmxparse_8h.html#a26">dmxparse.h</a><li>DMXConfigEntryPtr
+: <a class="el" href="dmxparse_8h.html#a27">dmxparse.h</a><li>DMXConfigFullDim
+: <a class="el" href="dmxparse_8h.html#a12">dmxparse.h</a><li>DMXConfigFullDimPtr
+: <a class="el" href="dmxparse_8h.html#a13">dmxparse.h</a><li>DMXConfigList
+: <a class="el" href="dmxconfig_8c.html#a7">dmxconfig.c</a><li>DMXConfigListPtr
+: <a class="el" href="dmxconfig_8c.html#a8">dmxconfig.c</a><li>dmxConfigLog()
+: <a class="el" href="dmxparse_8h.html#a38">dmxparse.h</a>, <a class="el" href="dmxparse_8c.html#a0">dmxparse.c</a><li>DMXConfigNumber
+: <a class="el" href="dmxparse_8h.html#a4">dmxparse.h</a><li>DMXConfigNumberPtr
+: <a class="el" href="dmxparse_8h.html#a5">dmxparse.h</a><li>DMXConfigOption
+: <a class="el" href="dmxparse_8h.html#a18">dmxparse.h</a><li>DMXConfigOptionPtr
+: <a class="el" href="dmxparse_8h.html#a19">dmxparse.h</a><li>DMXConfigPair
+: <a class="el" href="dmxparse_8h.html#a6">dmxparse.h</a><li>DMXConfigPairPtr
+: <a class="el" href="dmxparse_8h.html#a7">dmxparse.h</a><li>DMXConfigParam
+: <a class="el" href="dmxparse_8h.html#a20">dmxparse.h</a><li>DMXConfigParamPtr
+: <a class="el" href="dmxparse_8h.html#a21">dmxparse.h</a><li>DMXConfigPartDim
+: <a class="el" href="dmxparse_8h.html#a10">dmxparse.h</a><li>DMXConfigPartDimPtr
+: <a class="el" href="dmxparse_8h.html#a11">dmxparse.h</a><li>dmxConfigPrint()
+: <a class="el" href="dmxprint_8h.html#a0">dmxprint.h</a>, <a class="el" href="dmxprint_8c.html#a25">dmxprint.c</a><li>dmxConfigSetMaxScreens()
+: <a class="el" href="dmxconfig_8h.html#a11">dmxconfig.h</a>, <a class="el" href="dmxconfig_8c.html#a33">dmxconfig.c</a><li>dmxConfigStoreConfig()
+: <a class="el" href="dmxconfig_8h.html#a9">dmxconfig.h</a>, <a class="el" href="dmxconfig_8c.html#a19">dmxconfig.c</a><li>dmxConfigStoreDisplay()
+: <a class="el" href="dmxconfig_8h.html#a5">dmxconfig.h</a>, <a class="el" href="dmxconfig_8c.html#a15">dmxconfig.c</a><li>dmxConfigStoreFile()
+: <a class="el" href="dmxconfig_8h.html#a8">dmxconfig.h</a>, <a class="el" href="dmxconfig_8c.html#a18">dmxconfig.c</a><li>dmxConfigStoreInput()
+: <a class="el" href="dmxconfig_8h.html#a6">dmxconfig.h</a>, <a class="el" href="dmxconfig_8c.html#a16">dmxconfig.c</a><li>dmxConfigStoreXInput()
+: <a class="el" href="dmxconfig_8h.html#a7">dmxconfig.h</a>, <a class="el" href="dmxconfig_8c.html#a17">dmxconfig.c</a><li>DMXConfigString
+: <a class="el" href="dmxparse_8h.html#a2">dmxparse.h</a><li>DMXConfigStringPtr
+: <a class="el" href="dmxparse_8h.html#a3">dmxparse.h</a><li>DMXConfigSub
+: <a class="el" href="dmxparse_8h.html#a22">dmxparse.h</a><li>DMXConfigSubPtr
+: <a class="el" href="dmxparse_8h.html#a23">dmxparse.h</a><li>DMXConfigToken
+: <a class="el" href="dmxparse_8h.html#a0">dmxparse.h</a><li>DMXConfigTokenPtr
+: <a class="el" href="dmxparse_8h.html#a1">dmxparse.h</a><li>DMXConfigVirtual
+: <a class="el" href="dmxparse_8h.html#a24">dmxparse.h</a><li>dmxConfigVirtualPrint()
+: <a class="el" href="dmxprint_8h.html#a1">dmxprint.h</a>, <a class="el" href="dmxprint_8c.html#a26">dmxprint.c</a><li>DMXConfigVirtualPtr
+: <a class="el" href="dmxparse_8h.html#a25">dmxparse.h</a><li>DMXConfigWall
+: <a class="el" href="dmxparse_8h.html#a16">dmxparse.h</a><li>DMXConfigWallPtr
+: <a class="el" href="dmxparse_8h.html#a17">dmxparse.h</a><li>dmxConnectionBlockCallback()
+: <a class="el" href="dmxcb_8h.html#a6">dmxcb.h</a>, <a class="el" href="dmxcb_8c.html#a9">dmxcb.c</a><li>dmxConsoleCapture()
+: <a class="el" href="dmxconsole_8h.html#a10">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a47">dmxconsole.c</a><li>dmxConsoleCollectEvents()
+: <a class="el" href="dmxconsole_8h.html#a6">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a36">dmxconsole.c</a><li>dmxConsoleCreatePrivate()
+: <a class="el" href="dmxconsole_8h.html#a0">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a25">dmxconsole.c</a><li>dmxConsoleDestroyPrivate()
+: <a class="el" href="dmxconsole_8h.html#a1">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a26">dmxconsole.c</a><li>dmxConsoleFunctions()
+: <a class="el" href="dmxconsole_8h.html#a7">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a45">dmxconsole.c</a><li>dmxConsoleInit()
+: <a class="el" href="dmxconsole_8h.html#a2">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a42">dmxconsole.c</a><li>dmxConsoleKbdGetInfo()
+: <a class="el" href="dmxconsole_8h.html#a5">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a44">dmxconsole.c</a><li>dmxConsoleMouGetInfo()
+: <a class="el" href="dmxconsole_8h.html#a4">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a43">dmxconsole.c</a><li>dmxConsoleReInit()
+: <a class="el" href="dmxconsole_8h.html#a3">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a41">dmxconsole.c</a><li>dmxConsoleUncapture()
+: <a class="el" href="dmxconsole_8h.html#a11">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a48">dmxconsole.c</a><li>dmxConsoleUpdateInfo()
+: <a class="el" href="dmxconsole_8h.html#a12">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a32">dmxconsole.c</a><li>dmxConsoleUpdatePosition()
+: <a class="el" href="dmxconsole_8h.html#a8">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a35">dmxconsole.c</a><li>dmxCopyArea()
+: <a class="el" href="dmxgcops_8h.html#a3">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a5">dmxgcops.c</a><li>dmxCopyClip()
+: <a class="el" href="dmxgc_8h.html#a14">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a12">dmxgc.c</a><li>dmxCopyGC()
+: <a class="el" href="dmxgc_8h.html#a10">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a7">dmxgc.c</a><li>dmxCopyPlane()
+: <a class="el" href="dmxgcops_8h.html#a4">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a6">dmxgcops.c</a><li>dmxCopyWindow()
+: <a class="el" href="dmxwindow_8h.html#a25">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a22">dmxwindow.c</a><li>dmxCreateAndRealizeWindow()
+: <a class="el" href="dmxwindow_8h.html#a14">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a9">dmxwindow.c</a><li>dmxCreateColormap()
+: <a class="el" href="dmxcmap_8h.html#a5">dmxcmap.h</a>, <a class="el" href="dmxcmap_8c.html#a3">dmxcmap.c</a><li>dmxCreateDefColormap()
+: <a class="el" href="dmxcmap_8h.html#a9">dmxcmap.h</a>, <a class="el" href="dmxcmap_8c.html#a8">dmxcmap.c</a><li>dmxCreateGC()
+: <a class="el" href="dmxgc_8h.html#a7">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a4">dmxgc.c</a><li>dmxCreatePicture()
+: <a class="el" href="dmxpict_8h.html#a14">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a19">dmxpict.c</a><li>dmxCreatePictureList()
+: <a class="el" href="dmxpict_8h.html#a12">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a18">dmxpict.c</a><li>dmxCreatePixmap()
+: <a class="el" href="dmxpixmap_8h.html#a5">dmxpixmap.h</a>, <a class="el" href="dmxpixmap_8c.html#a2">dmxpixmap.c</a><li>dmxCreateWindow()
+: <a class="el" href="dmxwindow_8h.html#a15">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a10">dmxwindow.c</a><li>dmxCursorNoMulti()
+: <a class="el" href="dmxcursor_8h.html#a8">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a12">dmxcursor.c</a><li>dmxCursorPrivPtr
+: <a class="el" href="dmxcursor_8h.html#a2">dmxcursor.h</a><li>dmxCursorPrivRec
+: <a class="el" href="dmxcursor_8h.html#a1">dmxcursor.h</a><li>dmxDebug
+: <a class="el" href="dmxlog_8h.html#a18a0">dmxlog.h</a><li>dmxDepth
+: <a class="el" href="dmxinit_8c.html#a13">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a14">dmx.h</a><li>dmxDestroyClip()
+: <a class="el" href="dmxgc_8h.html#a13">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a11">dmxgc.c</a><li>dmxDestroyColormap()
+: <a class="el" href="dmxcmap_8h.html#a6">dmxcmap.h</a>, <a class="el" href="dmxcmap_8c.html#a5">dmxcmap.c</a><li>dmxDestroyGC()
+: <a class="el" href="dmxgc_8h.html#a11">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a9">dmxgc.c</a><li>dmxDestroyPicture()
+: <a class="el" href="dmxpict_8h.html#a15">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a22">dmxpict.c</a><li>dmxDestroyPictureClip()
+: <a class="el" href="dmxpict_8h.html#a17">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a24">dmxpict.c</a><li>dmxDestroyPictureList()
+: <a class="el" href="dmxpict_8h.html#a13">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a21">dmxpict.c</a><li>dmxDestroyPixmap()
+: <a class="el" href="dmxpixmap_8h.html#a6">dmxpixmap.h</a>, <a class="el" href="dmxpixmap_8c.html#a4">dmxpixmap.c</a><li>dmxDestroyWindow()
+: <a class="el" href="dmxwindow_8h.html#a16">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a12">dmxwindow.c</a><li>dmxDetachScreen()
+: <a class="el" href="dmxextension_8h.html#a18">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a23">dmxextension.c</a><li>dmxDPMSInit()
+: <a class="el" href="dmxdpms_8h.html#a0">dmxdpms.h</a>, <a class="el" href="dmxdpms_8c.html#a3">dmxdpms.c</a><li>dmxDPMSTerm()
+: <a class="el" href="dmxdpms_8h.html#a1">dmxdpms.h</a>, <a class="el" href="dmxdpms_8c.html#a4">dmxdpms.c</a><li>dmxDPMSWakeup()
+: <a class="el" href="dmxdpms_8h.html#a2">dmxdpms.h</a>, <a class="el" href="dmxdpms_8c.html#a5">dmxdpms.c</a><li>dmxDummyKbdGetInfo()
+: <a class="el" href="dmxdummy_8h.html#a1">dmxdummy.h</a>, <a class="el" href="dmxdummy_8c.html#a0">dmxdummy.c</a><li>dmxDummyMouGetInfo()
+: <a class="el" href="dmxdummy_8h.html#a0">dmxdummy.h</a>, <a class="el" href="dmxdummy_8c.html#a1">dmxdummy.c</a><li>dmxEnqueue()
+: <a class="el" href="dmxevents_8h.html#a1">dmxevents.h</a>, <a class="el" href="dmxevents_8c.html#a27">dmxevents.c</a><li>dmxeqEnqueue()
+: <a class="el" href="dmxeq_8c.html#a13">dmxeq.c</a>, <a class="el" href="dmxinput_8h.html#a24">dmxinput.h</a><li>dmxeqProcessInputEvents()
+: <a class="el" href="dmxeq_8h.html#a1">dmxeq.h</a>, <a class="el" href="dmxeq_8c.html#a16">dmxeq.c</a><li>dmxeqSwitchScreen()
+: <a class="el" href="dmxeq_8c.html#a14">dmxeq.c</a>, <a class="el" href="dmxinput_8h.html#a25">dmxinput.h</a><li>dmxError
+: <a class="el" href="dmxlog_8h.html#a18a3">dmxlog.h</a><li>dmxErrorOccurred
+: <a class="el" href="dmxinit_8c.html#a7">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a9">dmx.h</a><li>DMXEventMap
+: <a class="el" href="dmxinputinit_8h.html#a34">dmxinputinit.h</a><li>dmxEventName()
+: <a class="el" href="dmxlog_8h.html#a9">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a17">dmxlog.c</a><li>DMXExtensionInit()
+: <a class="el" href="programs_2Xserver_2Xext_2dmx_8c.html#a3">programs/Xserver/Xext/dmx.c</a><li>dmxFatal
+: <a class="el" href="dmxlog_8h.html#a18a4">dmxlog.h</a><li>dmxFillPolygon()
+: <a class="el" href="dmxgcops_8h.html#a10">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a12">dmxgcops.c</a><li>dmxFillSpans()
+: <a class="el" href="dmxgcops_8h.html#a0">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a2">dmxgcops.c</a><li>dmxFindPointerScreen()
+: <a class="el" href="dmxcommon_8h.html#a23">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a25">dmxcommon.c</a><li>dmxFlushPendingSyncs()
+: <a class="el" href="dmxextension_8h.html#a6">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a11">dmxextension.c</a><li>dmxFontPath
+: <a class="el" href="dmxinit_8c.html#a8">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a16">dmx.h</a><li>dmxFontPrivateIndex
+: <a class="el" href="dmxscrinit_8c.html#a4">dmxscrinit.c</a>, <a class="el" href="dmxfont_8h.html#a2">dmxfont.h</a><li>dmxFontPrivPtr
+: <a class="el" href="dmxfont_8h.html#a1">dmxfont.h</a><li>dmxFontPrivRec
+: <a class="el" href="dmxfont_8h.html#a0">dmxfont.h</a><li>DMXForceWindowCreation()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a13">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a26">dmxext.h</a><li>dmxForceWindowCreation()
+: <a class="el" href="dmxextension_8h.html#a5">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a10">dmxextension.c</a><li>dmxGCPrivateIndex
+: <a class="el" href="dmxscrinit_8c.html#a2">dmxscrinit.c</a>, <a class="el" href="dmxgc_8h.html#a5">dmxgc.h</a><li>dmxGCPrivPtr
+: <a class="el" href="dmxgc_8h.html#a4">dmxgc.h</a><li>dmxGCPrivRec
+: <a class="el" href="dmxgc_8h.html#a3">dmxgc.h</a><li>DMXGetDesktopAttributes()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a24">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a33">dmxext.h</a><li>dmxGetGlobalPosition()
+: <a class="el" href="dmxevents_8c.html#a21">dmxevents.c</a>, <a class="el" href="dmxinput_8h.html#a26">dmxinput.h</a><li>dmxGetImage()
+: <a class="el" href="dmxgcops_8h.html#a20">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a22">dmxgcops.c</a><li>dmxGetInputAttributes()
+: <a class="el" href="dmxextension_8h.html#a11">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a5">dmxextension.c</a><li>DMXGetInputAttributes()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a29">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a36">dmxext.h</a><li>DMXGetInputCount()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a28">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a35">dmxext.h</a><li>dmxGetInputCount()
+: <a class="el" href="dmxextension_8h.html#a10">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a4">dmxextension.c</a><li>dmxGetLogLevel()
+: <a class="el" href="dmxlog_8h.html#a6">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a2">dmxlog.c</a><li>dmxGetNumScreens()
+: <a class="el" href="dmxextension_8h.html#a4">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a9">dmxextension.c</a><li>DMXGetScreenAttributes()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a15">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a28">dmxext.h</a><li>dmxGetScreenAttributes()
+: <a class="el" href="dmxextension_8h.html#a7">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a1">dmxextension.c</a><li>DMXGetScreenCount()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a14">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a27">dmxext.h</a><li>dmxGetSpans()
+: <a class="el" href="dmxgcops_8h.html#a21">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a23">dmxgcops.c</a><li>DMXGetWindowAttributes()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a23">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a32">dmxext.h</a><li>dmxGetWindowAttributes()
+: <a class="el" href="dmxextension_8h.html#a8">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a2">dmxextension.c</a><li>dmxGlobalHeight
+: <a class="el" href="dmxcb_8h.html#a1">dmxcb.h</a>, <a class="el" href="dmxcb_8c.html#a6">dmxcb.c</a><li>dmxGlobalWidth
+: <a class="el" href="dmxcb_8h.html#a0">dmxcb.h</a>, <a class="el" href="dmxcb_8c.html#a5">dmxcb.c</a><li>dmxGlyphPrivPtr
+: <a class="el" href="dmxpict_8h.html#a6">dmxpict.h</a><li>dmxGlyphPrivRec
+: <a class="el" href="dmxpict_8h.html#a5">dmxpict.h</a><li>dmxGlyphs()
+: <a class="el" href="dmxpict_8h.html#a21">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a28">dmxpict.c</a><li>dmxGlyphSetPrivateIndex
+: <a class="el" href="dmxscrinit_8c.html#a8">dmxscrinit.c</a>, <a class="el" href="dmxpict_8h.html#a8">dmxpict.h</a><li>dmxHideCursor()
+: <a class="el" href="dmxcursor_8h.html#a12">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a40">dmxcursor.c</a><li>dmxIgnoreBadFontPaths
+: <a class="el" href="dmxinit_8c.html#a16">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a17">dmx.h</a><li>dmxImageGlyphBlt()
+: <a class="el" href="dmxgcops_8h.html#a17">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a19">dmxgcops.c</a><li>dmxImageText16()
+: <a class="el" href="dmxgcops_8h.html#a16">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a18">dmxgcops.c</a><li>dmxImageText8()
+: <a class="el" href="dmxgcops_8h.html#a15">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a17">dmxgcops.c</a><li>dmxInfo
+: <a class="el" href="dmxlog_8h.html#a18a1">dmxlog.h</a><li>dmxInitFonts()
+: <a class="el" href="dmxfont_8h.html#a3">dmxfont.h</a>, <a class="el" href="dmxfont_8c.html#a10">dmxfont.c</a><li>dmxInitGC()
+: <a class="el" href="dmxgc_8h.html#a6">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a2">dmxgc.c</a><li>dmxInitIndexed()
+: <a class="el" href="dmxpict_8h.html#a23">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a30">dmxpict.c</a><li>dmxInitOrigins()
+: <a class="el" href="dmxcursor_8h.html#a6">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a22">dmxcursor.c</a><li>dmxInitOverlap()
+: <a class="el" href="dmxcursor_8h.html#a7">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a28">dmxcursor.c</a><li>dmxInitPixmap()
+: <a class="el" href="dmxpixmap_8h.html#a4">dmxpixmap.h</a>, <a class="el" href="dmxpixmap_8c.html#a0">dmxpixmap.c</a><li>dmxInitRender()
+: <a class="el" href="dmxpict_8h.html#a9">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a12">dmxpict.c</a><li>dmxInitWindow()
+: <a class="el" href="dmxwindow_8h.html#a11">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a3">dmxwindow.c</a><li>dmxInputCopyLocal()
+: <a class="el" href="dmxinputinit_8h.html#a53">dmxinputinit.h</a>, <a class="el" href="dmxinputinit_8c.html#a33">dmxinputinit.c</a><li>dmxInputDetach()
+: <a class="el" href="dmxinputinit_8h.html#a58">dmxinputinit.h</a>, <a class="el" href="dmxinputinit_8c.html#a43">dmxinputinit.c</a>, <a class="el" href="dmxdetach_8c.html#a0">dmxdetach.c</a><li>dmxInputDetachAll()
+: <a class="el" href="dmxinputinit_8h.html#a59">dmxinputinit.h</a>, <a class="el" href="dmxinputinit_8c.html#a44">dmxinputinit.c</a><li>dmxInputDetachId()
+: <a class="el" href="dmxinputinit_8h.html#a60">dmxinputinit.h</a>, <a class="el" href="dmxinputinit_8c.html#a45">dmxinputinit.c</a><li>DMXInputEnum
+: <a class="el" href="dmxext_8h.html#a41">dmxext.h</a><li>dmxInputFree()
+: <a class="el" href="dmxinputinit_8c.html#a41">dmxinputinit.c</a>, <a class="el" href="dmxinput_8h.html#a20">dmxinput.h</a><li>DMXInputInfo
+: <a class="el" href="dmx_8h.html#a2">dmx.h</a><li>dmxInputInit()
+: <a class="el" href="dmxinputinit_8c.html#a39">dmxinputinit.c</a>, <a class="el" href="dmxinput_8h.html#a17">dmxinput.h</a><li>dmxInputLateReInit()
+: <a class="el" href="dmxinputinit_8c.html#a38">dmxinputinit.c</a>, <a class="el" href="dmxinput_8h.html#a19">dmxinput.h</a><li>dmxInputLogDevices()
+: <a class="el" href="dmxinputinit_8c.html#a42">dmxinputinit.c</a>, <a class="el" href="dmxinput_8h.html#a21">dmxinput.h</a><li>dmxInputReInit()
+: <a class="el" href="dmxinputinit_8c.html#a37">dmxinputinit.c</a>, <a class="el" href="dmxinput_8h.html#a18">dmxinput.h</a><li>dmxInputs
+: <a class="el" href="dmxinput_8h.html#a5">dmxinput.h</a>, <a class="el" href="dmxinit_8c.html#a4">dmxinit.c</a><li>dmxInstallColormap()
+: <a class="el" href="dmxcmap_8h.html#a7">dmxcmap.h</a>, <a class="el" href="dmxcmap_8c.html#a6">dmxcmap.c</a><li>dmxInvalidateGlobalPosition()
+: <a class="el" href="dmxevents_8h.html#a3">dmxevents.h</a>, <a class="el" href="dmxevents_8c.html#a22">dmxevents.c</a><li>dmxKeyboardBellProc()
+: <a class="el" href="dmxinputinit_8h.html#a56">dmxinputinit.h</a>, <a class="el" href="dmxinputinit_8c.html#a20">dmxinputinit.c</a><li>dmxKeyboardKbdCtrlProc()
+: <a class="el" href="dmxinputinit_8h.html#a55">dmxinputinit.h</a>, <a class="el" href="dmxinputinit_8c.html#a18">dmxinputinit.c</a><li>dmxLastErrorEvent
+: <a class="el" href="dmxinit_8c.html#a6">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a8">dmx.h</a><li>dmxLazyWindowCreation
+: <a class="el" href="dmxinit_8c.html#a11">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a12">dmx.h</a><li>DMXLocalInitInfo
+: <a class="el" href="dmxinputinit_8h.html#a9">dmxinputinit.h</a><li>DMXLocalInitInfoPtr
+: <a class="el" href="dmxinputinit_8h.html#a10">dmxinputinit.h</a><li>DMXLocalInputInfoPtr
+: <a class="el" href="dmxinput_8h.html#a3">dmxinput.h</a><li>DMXLocalInputInfoRec
+: <a class="el" href="dmxinputinit_8h.html#a35">dmxinputinit.h</a><li>dmxLog()
+: <a class="el" href="dmxlog_8h.html#a7">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a7">dmxlog.c</a><li>dmxLogArgs()
+: <a class="el" href="dmxlog_8h.html#a15">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a14">dmxlog.c</a><li>dmxLogCont()
+: <a class="el" href="dmxlog_8h.html#a8">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a8">dmxlog.c</a><li>dmxLogInput()
+: <a class="el" href="dmxlog_8h.html#a13">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a12">dmxlog.c</a><li>dmxLogInputCont()
+: <a class="el" href="dmxlog_8h.html#a14">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a13">dmxlog.c</a><li>dmxLogLevel
+: <a class="el" href="dmxlog_8h.html#a18">dmxlog.h</a><li>dmxLogOutput()
+: <a class="el" href="dmxlog_8h.html#a10">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a9">dmxlog.c</a><li>dmxLogOutputCont()
+: <a class="el" href="dmxlog_8h.html#a11">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a10">dmxlog.c</a><li>dmxLogOutputWarning()
+: <a class="el" href="dmxlog_8h.html#a12">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a11">dmxlog.c</a><li>dmxLogVisual()
+: <a class="el" href="dmxlog_8h.html#a16">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a15">dmxlog.c</a><li>dmxLookupVisual()
+: <a class="el" href="dmxvisual_8h.html#a0">dmxvisual.h</a>, <a class="el" href="dmxvisual_8c.html#a0">dmxvisual.c</a><li>dmxLookupVisualFromID()
+: <a class="el" href="dmxvisual_8h.html#a1">dmxvisual.h</a>, <a class="el" href="dmxvisual_8c.html#a1">dmxvisual.c</a><li>dmxMapClear()
+: <a class="el" href="dmxmap_8h.html#a1">dmxmap.h</a>, <a class="el" href="dmxmap_8c.html#a1">dmxmap.c</a><li>dmxMapInsert()
+: <a class="el" href="dmxmap_8h.html#a0">dmxmap.h</a>, <a class="el" href="dmxmap_8c.html#a0">dmxmap.c</a><li>dmxMapLookup()
+: <a class="el" href="dmxmap_8h.html#a2">dmxmap.h</a>, <a class="el" href="dmxmap_8c.html#a2">dmxmap.c</a><li>dmxMotion()
+: <a class="el" href="dmxevents_8h.html#a0">dmxevents.h</a>, <a class="el" href="dmxevents_8c.html#a23">dmxevents.c</a><li>dmxMoveCursor()
+: <a class="el" href="dmxcursor_8h.html#a9">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a38">dmxcursor.c</a><li>dmxNoRender
+: <a class="el" href="dmxinit_8c.html#a14">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a15">dmx.h</a><li>dmxNumInputs
+: <a class="el" href="dmxinput_8h.html#a4">dmxinput.h</a>, <a class="el" href="dmxinit_8c.html#a3">dmxinit.c</a><li>dmxNumScreens
+: <a class="el" href="dmxinit_8c.html#a1">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a5">dmx.h</a><li>dmxOffScreenOpt
+: <a class="el" href="dmxinit_8c.html#a9">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a10">dmx.h</a><li>dmxOnScreen()
+: <a class="el" href="dmxcursor_8h.html#a11">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a23">dmxcursor.c</a><li>dmxPaintWindowBackground()
+: <a class="el" href="dmxwindow_8h.html#a23">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a20">dmxwindow.c</a><li>dmxPaintWindowBorder()
+: <a class="el" href="dmxwindow_8h.html#a24">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a21">dmxwindow.c</a><li>dmxPictPrivateIndex
+: <a class="el" href="dmxscrinit_8c.html#a7">dmxscrinit.c</a>, <a class="el" href="dmxpict_8h.html#a7">dmxpict.h</a><li>dmxPictPrivPtr
+: <a class="el" href="dmxpict_8h.html#a4">dmxpict.h</a><li>dmxPictPrivRec
+: <a class="el" href="dmxpict_8h.html#a3">dmxpict.h</a><li>dmxPictureInit()
+: <a class="el" href="dmxpict_8h.html#a11">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a14">dmxpict.c</a><li>dmxPixPrivateIndex
+: <a class="el" href="dmxpixmap_8h.html#a3">dmxpixmap.h</a><li>dmxPixPrivPtr
+: <a class="el" href="dmxpixmap_8h.html#a2">dmxpixmap.h</a><li>dmxPixPrivRec
+: <a class="el" href="dmxpixmap_8h.html#a1">dmxpixmap.h</a><li>dmxPointerCursorFuncs
+: <a class="el" href="dmxcursor_8h.html#a3">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a10">dmxcursor.c</a><li>dmxPointerGetMotionBufferSize()
+: <a class="el" href="dmxmotion_8h.html#a0">dmxmotion.h</a>, <a class="el" href="dmxmotion_8c.html#a1">dmxmotion.c</a><li>dmxPointerGetMotionEvents()
+: <a class="el" href="dmxmotion_8h.html#a1">dmxmotion.h</a>, <a class="el" href="dmxmotion_8c.html#a2">dmxmotion.c</a><li>dmxPointerPutMotionEvent()
+: <a class="el" href="dmxmotion_8h.html#a2">dmxmotion.h</a>, <a class="el" href="dmxmotion_8c.html#a3">dmxmotion.c</a><li>dmxPointerSpriteFuncs
+: <a class="el" href="dmxcursor_8h.html#a4">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a11">dmxcursor.c</a><li>dmxPolyArc()
+: <a class="el" href="dmxgcops_8h.html#a9">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a11">dmxgcops.c</a><li>dmxPolyFillArc()
+: <a class="el" href="dmxgcops_8h.html#a12">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a14">dmxgcops.c</a><li>dmxPolyFillRect()
+: <a class="el" href="dmxgcops_8h.html#a11">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a13">dmxgcops.c</a><li>dmxPolyGlyphBlt()
+: <a class="el" href="dmxgcops_8h.html#a18">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a20">dmxgcops.c</a><li>dmxPolylines()
+: <a class="el" href="dmxgcops_8h.html#a6">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a8">dmxgcops.c</a><li>dmxPolyPoint()
+: <a class="el" href="dmxgcops_8h.html#a5">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a7">dmxgcops.c</a><li>dmxPolyRectangle()
+: <a class="el" href="dmxgcops_8h.html#a8">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a10">dmxgcops.c</a><li>dmxPolySegment()
+: <a class="el" href="dmxgcops_8h.html#a7">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a9">dmxgcops.c</a><li>dmxPolyText16()
+: <a class="el" href="dmxgcops_8h.html#a14">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a16">dmxgcops.c</a><li>dmxPolyText8()
+: <a class="el" href="dmxgcops_8h.html#a13">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a15">dmxgcops.c</a><li>dmxPositionWindow()
+: <a class="el" href="dmxwindow_8h.html#a17">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a13">dmxwindow.c</a><li>dmxPropertyDisplay()
+: <a class="el" href="dmxprop_8h.html#a0">dmxprop.h</a>, <a class="el" href="dmxprop_8c.html#a8">dmxprop.c</a><li>dmxPropertyIterate()
+: <a class="el" href="dmxprop_8c.html#a5">dmxprop.c</a><li>dmxPropertySameDisplay()
+: <a class="el" href="dmxprop_8h.html#a3">dmxprop.h</a>, <a class="el" href="dmxprop_8c.html#a9">dmxprop.c</a><li>dmxPropertyWindow()
+: <a class="el" href="dmxprop_8h.html#a1">dmxprop.h</a>, <a class="el" href="dmxprop_8c.html#a10">dmxprop.c</a><li>dmxPushPixels()
+: <a class="el" href="dmxgcops_8h.html#a19">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a21">dmxgcops.c</a><li>dmxPutImage()
+: <a class="el" href="dmxgcops_8h.html#a2">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a4">dmxgcops.c</a><li>DMXQueryExtension()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a10">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a23">dmxext.h</a><li>DMXQueryVersion()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a11">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a24">dmxext.h</a><li>dmxRealizeFont()
+: <a class="el" href="dmxfont_8h.html#a5">dmxfont.h</a>, <a class="el" href="dmxfont_8c.html#a13">dmxfont.c</a><li>dmxRealizeWindow()
+: <a class="el" href="dmxwindow_8h.html#a19">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a15">dmxwindow.c</a><li>DMXRecomputeFlag
+: <a class="el" href="dmxcb_8h.html#a7">dmxcb.h</a><li>dmxReInitOrigins()
+: <a class="el" href="dmxcursor_8h.html#a5">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a21">dmxcursor.c</a><li>dmxRemoveInput()
+: <a class="el" href="dmxextension_8h.html#a13">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a8">dmxextension.c</a><li>DMXRemoveInput()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a33">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a38">dmxext.h</a><li>DMXRemoveScreen()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a22">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a31">dmxext.h</a><li>dmxReparentWindow()
+: <a class="el" href="dmxwindow_8h.html#a27">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a24">dmxwindow.c</a><li>dmxResetFonts()
+: <a class="el" href="dmxfont_8h.html#a4">dmxfont.h</a>, <a class="el" href="dmxfont_8c.html#a11">dmxfont.c</a><li>dmxResetRender()
+: <a class="el" href="dmxpict_8h.html#a10">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a13">dmxpict.c</a><li>dmxResizeRootWindow()
+: <a class="el" href="dmxwindow_8h.html#a30">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a6">dmxwindow.c</a><li>dmxResizeScreenWindow()
+: <a class="el" href="dmxwindow_8h.html#a29">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a5">dmxwindow.c</a><li>dmxResizeWindow()
+: <a class="el" href="dmxwindow_8h.html#a26">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a23">dmxwindow.c</a><li>dmxRestackWindow()
+: <a class="el" href="dmxwindow_8h.html#a21">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a17">dmxwindow.c</a><li>DMXScreenInfo
+: <a class="el" href="dmx_8h.html#a4">dmx.h</a><li>dmxScreenInit()
+: <a class="el" href="dmxscrinit_8h.html#a1">dmxscrinit.h</a>, <a class="el" href="dmxscrinit_8c.html#a12">dmxscrinit.c</a><li>dmxScreenPrivateIndex
+: <a class="el" href="dmxscrinit_8h.html#a0">dmxscrinit.h</a>, <a class="el" href="dmxscrinit_8c.html#a5">dmxscrinit.c</a><li>dmxScreens
+: <a class="el" href="dmxinit_8c.html#a2">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a6">dmx.h</a><li>dmxSetLogLevel()
+: <a class="el" href="dmxlog_8h.html#a5">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a1">dmxlog.c</a><li>dmxSetShape()
+: <a class="el" href="dmxwindow_8h.html#a32">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a26">dmxwindow.c</a><li>dmxSetSpans()
+: <a class="el" href="dmxgcops_8h.html#a1">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a3">dmxgcops.c</a><li>dmxSetWidthHeight()
+: <a class="el" href="dmxcb_8h.html#a4">dmxcb.h</a>, <a class="el" href="dmxcb_8c.html#a7">dmxcb.c</a><li>dmxShadowFB
+: <a class="el" href="dmxinit_8c.html#a5">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a7">dmx.h</a><li>dmxShadowUpdateProc()
+: <a class="el" href="dmxshadow_8h.html#a0">dmxshadow.h</a>, <a class="el" href="dmxshadow_8c.html#a0">dmxshadow.c</a><li>dmxSigioBlock()
+: <a class="el" href="dmxsigio_8h.html#a0">dmxsigio.h</a>, <a class="el" href="dmxsigio_8c.html#a5">dmxsigio.c</a><li>dmxSigioDisableInput()
+: <a class="el" href="dmxsigio_8h.html#a3">dmxsigio.h</a>, <a class="el" href="dmxsigio_8c.html#a12">dmxsigio.c</a><li>dmxSigioEnableInput()
+: <a class="el" href="dmxsigio_8h.html#a2">dmxsigio.h</a>, <a class="el" href="dmxsigio_8c.html#a11">dmxsigio.c</a><li>dmxSigioRegister()
+: <a class="el" href="dmxsigio_8h.html#a4">dmxsigio.h</a>, <a class="el" href="dmxsigio_8c.html#a13">dmxsigio.c</a><li>dmxSigioState
+: <a class="el" href="dmxinput_8h.html#a31">dmxinput.h</a><li>dmxSigioUnblock()
+: <a class="el" href="dmxsigio_8h.html#a1">dmxsigio.h</a>, <a class="el" href="dmxsigio_8c.html#a6">dmxsigio.c</a><li>dmxSigioUnregister()
+: <a class="el" href="dmxsigio_8h.html#a5">dmxsigio.h</a>, <a class="el" href="dmxsigio_8c.html#a14">dmxsigio.c</a><li>dmxStatActivate()
+: <a class="el" href="dmxstat_8h.html#a6">dmxstat.h</a>, <a class="el" href="dmxstat_8c.html#a6">dmxstat.c</a><li>dmxStatAlloc()
+: <a class="el" href="dmxstat_8h.html#a7">dmxstat.h</a>, <a class="el" href="dmxstat_8c.html#a7">dmxstat.c</a><li>DMXStatAvg
+: <a class="el" href="dmxstat_8c.html#a0">dmxstat.c</a><li>dmxStatFree()
+: <a class="el" href="dmxstat_8h.html#a8">dmxstat.h</a>, <a class="el" href="dmxstat_8c.html#a8">dmxstat.c</a><li>DMXStatInfo
+: <a class="el" href="dmx_8h.html#a3">dmx.h</a><li>dmxStatInit()
+: <a class="el" href="dmxstat_8h.html#a9">dmxstat.h</a>, <a class="el" href="dmxstat_8c.html#a12">dmxstat.c</a><li>dmxStatInterval
+: <a class="el" href="dmxstat_8h.html#a5">dmxstat.h</a>, <a class="el" href="dmxstat_8c.html#a1">dmxstat.c</a><li>dmxStatSync()
+: <a class="el" href="dmxstat_8h.html#a10">dmxstat.h</a>, <a class="el" href="dmxstat_8c.html#a10">dmxstat.c</a><li>dmxStoreColors()
+: <a class="el" href="dmxcmap_8h.html#a8">dmxcmap.h</a>, <a class="el" href="dmxcmap_8c.html#a7">dmxcmap.c</a><li>dmxSubdividePrimitives
+: <a class="el" href="dmxinit_8c.html#a10">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a11">dmx.h</a><li>dmxSync()
+: <a class="el" href="dmxsync_8h.html#a2">dmxsync.h</a>, <a class="el" href="dmxsync_8c.html#a9">dmxsync.c</a><li>DMXSync()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a12">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a25">dmxext.h</a><li>dmxSyncActivate()
+: <a class="el" href="dmxsync_8h.html#a0">dmxsync.h</a>, <a class="el" href="dmxsync_8c.html#a7">dmxsync.c</a><li>dmxSyncInit()
+: <a class="el" href="dmxsync_8h.html#a1">dmxsync.h</a>, <a class="el" href="dmxsync_8c.html#a8">dmxsync.c</a><li>dmxTrapezoids()
+: <a class="el" href="dmxpict_8h.html#a26">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a33">dmxpict.c</a><li>dmxTriangles()
+: <a class="el" href="dmxpict_8h.html#a27">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a34">dmxpict.c</a><li>dmxTriFan()
+: <a class="el" href="dmxpict_8h.html#a29">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a36">dmxpict.c</a><li>dmxTriStrip()
+: <a class="el" href="dmxpict_8h.html#a28">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a35">dmxpict.c</a><li>dmxUnrealizeFont()
+: <a class="el" href="dmxfont_8h.html#a6">dmxfont.h</a>, <a class="el" href="dmxfont_8c.html#a15">dmxfont.c</a><li>dmxUnrealizeWindow()
+: <a class="el" href="dmxwindow_8h.html#a20">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a16">dmxwindow.c</a><li>dmxUpdateIndexed()
+: <a class="el" href="dmxpict_8h.html#a25">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a32">dmxpict.c</a><li>DMXUpdateType
+: <a class="el" href="dmxinput_8h.html#a30">dmxinput.h</a><li>dmxUpdateWindowInfo()
+: <a class="el" href="dmxinput_8h.html#a22">dmxinput.h</a>, <a class="el" href="dmxinput_8c.html#a3">dmxinput.c</a><li>dmxUseXKB
+: <a class="el" href="dmxinit_8c.html#a12">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a13">dmx.h</a><li>dmxValidateGC()
+: <a class="el" href="dmxgc_8h.html#a8">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a5">dmxgc.c</a><li>dmxValidatePicture()
+: <a class="el" href="dmxpict_8h.html#a19">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a26">dmxpict.c</a><li>dmxVDLRead()
+: <a class="el" href="dmxcompat_8h.html#a0">dmxcompat.h</a>, <a class="el" href="dmxcompat_8c.html#a4">dmxcompat.c</a><li>dmxWarning
+: <a class="el" href="dmxlog_8h.html#a18a2">dmxlog.h</a><li>dmxWindowExposures()
+: <a class="el" href="dmxwindow_8h.html#a22">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a19">dmxwindow.c</a><li>dmxWinPrivateIndex
+: <a class="el" href="dmxwindow_8h.html#a10">dmxwindow.h</a>, <a class="el" href="dmxscrinit_8c.html#a3">dmxscrinit.c</a><li>dmxWinPrivPtr
+: <a class="el" href="dmxwindow_8h.html#a9">dmxwindow.h</a><li>dmxWinPrivRec
+: <a class="el" href="dmxwindow_8h.html#a8">dmxwindow.h</a><li>dmxXInputEventName()
+: <a class="el" href="dmxlog_8h.html#a17">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a16">dmxlog.c</a></ul>
+<h3><a class="anchor" name="index_e">- e -</a></h3><ul>
+<li>EventPtr
+: <a class="el" href="dmxeq_8c.html#a6">dmxeq.c</a><li>EventQueuePtr
+: <a class="el" href="dmxeq_8c.html#a8">dmxeq.c</a><li>EventQueueRec
+: <a class="el" href="dmxeq_8c.html#a7">dmxeq.c</a><li>EventRec
+: <a class="el" href="dmxeq_8c.html#a5">dmxeq.c</a></ul>
+<h3><a class="anchor" name="index_g">- g -</a></h3><ul>
+<li>GEN
+: <a class="el" href="dmxconfig_8c.html#a0">dmxconfig.c</a><li>GetTimeInMillis()
+: <a class="el" href="dmxinit_8c.html#a42">dmxinit.c</a></ul>
+<h3><a class="anchor" name="index_i">- i -</a></h3><ul>
+<li>InitInput()
+: <a class="el" href="dmxinput_8c.html#a1">dmxinput.c</a><li>InitOutput()
+: <a class="el" href="dmxinit_8c.html#a34">dmxinit.c</a></ul>
+<h3><a class="anchor" name="index_k">- k -</a></h3><ul>
+<li>kbdLinuxBell()
+: <a class="el" href="lnx-keyboard_8h.html#a11">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a26">lnx-keyboard.c</a><li>kbdLinuxCreatePrivate()
+: <a class="el" href="lnx-keyboard_8h.html#a0">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a24">lnx-keyboard.c</a><li>kbdLinuxCtrl()
+: <a class="el" href="lnx-keyboard_8h.html#a10">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a27">lnx-keyboard.c</a><li>kbdLinuxDestroyPrivate()
+: <a class="el" href="lnx-keyboard_8h.html#a1">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a25">lnx-keyboard.c</a><li>kbdLinuxGetInfo()
+: <a class="el" href="lnx-keyboard_8h.html#a3">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a47">lnx-keyboard.c</a><li>kbdLinuxInit()
+: <a class="el" href="lnx-keyboard_8h.html#a2">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a38">lnx-keyboard.c</a><li>kbdLinuxOff()
+: <a class="el" href="lnx-keyboard_8h.html#a5">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a44">lnx-keyboard.c</a><li>kbdLinuxOn()
+: <a class="el" href="lnx-keyboard_8h.html#a4">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a43">lnx-keyboard.c</a><li>kbdLinuxRead()
+: <a class="el" href="lnx-keyboard_8c.html#a42">lnx-keyboard.c</a><li>kbdLinuxVTPostSwitch()
+: <a class="el" href="lnx-keyboard_8h.html#a7">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a33">lnx-keyboard.c</a><li>kbdLinuxVTPreSwitch()
+: <a class="el" href="lnx-keyboard_8h.html#a6">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a32">lnx-keyboard.c</a><li>kbdLinuxVTSwitch()
+: <a class="el" href="lnx-keyboard_8c.html#a34">lnx-keyboard.c</a><li>kbdUSBCtrl()
+: <a class="el" href="usb-keyboard_8h.html#a4">usb-keyboard.h</a>, <a class="el" href="usb-keyboard_8c.html#a20">usb-keyboard.c</a><li>kbdUSBGetInfo()
+: <a class="el" href="usb-keyboard_8h.html#a1">usb-keyboard.h</a>, <a class="el" href="usb-keyboard_8c.html#a26">usb-keyboard.c</a><li>kbdUSBInit()
+: <a class="el" href="usb-keyboard_8h.html#a0">usb-keyboard.h</a>, <a class="el" href="usb-keyboard_8c.html#a21">usb-keyboard.c</a><li>kbdUSBOn()
+: <a class="el" href="usb-keyboard_8h.html#a2">usb-keyboard.h</a>, <a class="el" href="usb-keyboard_8c.html#a24">usb-keyboard.c</a><li>kbdUSBRead()
+: <a class="el" href="usb-keyboard_8c.html#a23">usb-keyboard.c</a></ul>
+<h3><a class="anchor" name="index_l">- l -</a></h3><ul>
+<li>LegalModifier()
+: <a class="el" href="dmxinput_8c.html#a0">dmxinput.c</a></ul>
+<h3><a class="anchor" name="index_m">- m -</a></h3><ul>
+<li>mouUSBGetInfo()
+: <a class="el" href="usb-mouse_8h.html#a2">usb-mouse.h</a>, <a class="el" href="usb-mouse_8c.html#a16">usb-mouse.c</a><li>mouUSBInit()
+: <a class="el" href="usb-mouse_8h.html#a1">usb-mouse.h</a>, <a class="el" href="usb-mouse_8c.html#a13">usb-mouse.c</a><li>mouUSBOn()
+: <a class="el" href="usb-mouse_8h.html#a3">usb-mouse.h</a>, <a class="el" href="usb-mouse_8c.html#a14">usb-mouse.c</a><li>mouUSBRead()
+: <a class="el" href="usb-mouse_8c.html#a12">usb-mouse.c</a><li>msLinuxCreatePrivate()
+: <a class="el" href="lnx-ms_8h.html#a0">lnx-ms.h</a>, <a class="el" href="lnx-ms_8c.html#a24">lnx-ms.c</a><li>msLinuxDestroyPrivate()
+: <a class="el" href="lnx-ms_8h.html#a1">lnx-ms.h</a>, <a class="el" href="lnx-ms_8c.html#a25">lnx-ms.c</a><li>msLinuxGetInfo()
+: <a class="el" href="lnx-ms_8h.html#a4">lnx-ms.h</a>, <a class="el" href="lnx-ms_8c.html#a26">lnx-ms.c</a><li>msLinuxInit()
+: <a class="el" href="lnx-ms_8h.html#a3">lnx-ms.h</a>, <a class="el" href="lnx-ms_8c.html#a18">lnx-ms.c</a><li>msLinuxOff()
+: <a class="el" href="lnx-ms_8h.html#a6">lnx-ms.h</a>, <a class="el" href="lnx-ms_8c.html#a20">lnx-ms.c</a><li>msLinuxOn()
+: <a class="el" href="lnx-ms_8h.html#a5">lnx-ms.h</a>, <a class="el" href="lnx-ms_8c.html#a19">lnx-ms.c</a><li>msLinuxRead()
+: <a class="el" href="lnx-ms_8c.html#a17">lnx-ms.c</a><li>msLinuxVTPostSwitch()
+: <a class="el" href="lnx-ms_8h.html#a9">lnx-ms.h</a>, <a class="el" href="lnx-ms_8c.html#a23">lnx-ms.c</a><li>msLinuxVTPreSwitch()
+: <a class="el" href="lnx-ms_8h.html#a8">lnx-ms.h</a>, <a class="el" href="lnx-ms_8c.html#a22">lnx-ms.c</a><li>myPrivate
+: <a class="el" href="dmxcommon_8c.html#a4">dmxcommon.c</a></ul>
+<h3><a class="anchor" name="index_o">- o -</a></h3><ul>
+<li>OpenInputDevice()
+: <a class="el" href="dmxxinput_8c.html#a5">dmxxinput.c</a><li>OsVendorFatalError()
+: <a class="el" href="dmxinit_8c.html#a39">dmxinit.c</a><li>OsVendorInit()
+: <a class="el" href="dmxinit_8c.html#a38">dmxinit.c</a><li>othUSBGetInfo()
+: <a class="el" href="usb-other_8h.html#a2">usb-other.h</a>, <a class="el" href="usb-other_8c.html#a16">usb-other.c</a><li>othUSBInit()
+: <a class="el" href="usb-other_8h.html#a1">usb-other.h</a>, <a class="el" href="usb-other_8c.html#a14">usb-other.c</a><li>othUSBOn()
+: <a class="el" href="usb-other_8h.html#a3">usb-other.h</a>, <a class="el" href="usb-other_8c.html#a15">usb-other.c</a><li>othUSBRead()
+: <a class="el" href="usb-other_8c.html#a13">usb-other.c</a></ul>
+<h3><a class="anchor" name="index_p">- p -</a></h3><ul>
+<li>ProcessInputEvents()
+: <a class="el" href="dmxinput_8c.html#a2">dmxinput.c</a><li>ps2LinuxCreatePrivate()
+: <a class="el" href="lnx-ps2_8h.html#a0">lnx-ps2.h</a>, <a class="el" href="lnx-ps2_8c.html#a24">lnx-ps2.c</a><li>ps2LinuxDestroyPrivate()
+: <a class="el" href="lnx-ps2_8h.html#a1">lnx-ps2.h</a>, <a class="el" href="lnx-ps2_8c.html#a25">lnx-ps2.c</a><li>ps2LinuxGetInfo()
+: <a class="el" href="lnx-ps2_8h.html#a4">lnx-ps2.h</a>, <a class="el" href="lnx-ps2_8c.html#a26">lnx-ps2.c</a><li>ps2LinuxInit()
+: <a class="el" href="lnx-ps2_8h.html#a3">lnx-ps2.h</a>, <a class="el" href="lnx-ps2_8c.html#a18">lnx-ps2.c</a><li>ps2LinuxOff()
+: <a class="el" href="lnx-ps2_8h.html#a6">lnx-ps2.h</a>, <a class="el" href="lnx-ps2_8c.html#a20">lnx-ps2.c</a><li>ps2LinuxOn()
+: <a class="el" href="lnx-ps2_8h.html#a5">lnx-ps2.h</a>, <a class="el" href="lnx-ps2_8c.html#a19">lnx-ps2.c</a><li>ps2LinuxRead()
+: <a class="el" href="lnx-ps2_8c.html#a17">lnx-ps2.c</a><li>ps2LinuxVTPostSwitch()
+: <a class="el" href="lnx-ps2_8h.html#a9">lnx-ps2.h</a>, <a class="el" href="lnx-ps2_8c.html#a23">lnx-ps2.c</a><li>ps2LinuxVTPreSwitch()
+: <a class="el" href="lnx-ps2_8h.html#a8">lnx-ps2.h</a>, <a class="el" href="lnx-ps2_8c.html#a22">lnx-ps2.c</a></ul>
+<h3><a class="anchor" name="index_q">- q -</a></h3><ul>
+<li>QUEUE_SIZE
+: <a class="el" href="dmxeq_8c.html#a4">dmxeq.c</a></ul>
+<h3><a class="anchor" name="index_s">- s -</a></h3><ul>
+<li>SetDeviceMode()
+: <a class="el" href="dmxxinput_8c.html#a6">dmxxinput.c</a><li>SetDeviceValuators()
+: <a class="el" href="dmxxinput_8c.html#a7">dmxxinput.c</a></ul>
+<h3><a class="anchor" name="index_u">- u -</a></h3><ul>
+<li>usbCreatePrivate()
+: <a class="el" href="usb-common_8h.html#a3">usb-common.h</a>, <a class="el" href="usb-common_8c.html#a25">usb-common.c</a><li>usbDestroyPrivate()
+: <a class="el" href="usb-common_8h.html#a4">usb-common.h</a>, <a class="el" href="usb-common_8c.html#a26">usb-common.c</a><li>usbInit()
+: <a class="el" href="usb-common_8h.html#a6">usb-common.h</a>, <a class="el" href="usb-common_8c.html#a23">usb-common.c</a><li>usbOff()
+: <a class="el" href="usb-common_8h.html#a7">usb-common.h</a>, <a class="el" href="usb-common_8c.html#a24">usb-common.c</a><li>usbRead()
+: <a class="el" href="usb-common_8c.html#a21">usb-common.c</a></ul>
+<h3><a class="anchor" name="index_x">- x -</a></h3><ul>
+<li>XCheckNotMaskEvent()
+: <a class="el" href="ChkNotMaskEv_8h.html#a0">ChkNotMaskEv.h</a>, <a class="el" href="ChkNotMaskEv_8c.html#a2">ChkNotMaskEv.c</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_defs.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_defs.html
new file mode 100644
index 000000000..9fb24cc19
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_defs.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindexHL" href="globals.html">Globals</a></div>
+<div class="qindex"><a class="qindex" href="globals.html">All</a> | <a class="qindex" href="globals_func.html">Functions</a> | <a class="qindex" href="globals_vars.html">Variables</a> | <a class="qindex" href="globals_type.html">Typedefs</a> | <a class="qindex" href="globals_enum.html">Enumerations</a> | <a class="qindex" href="globals_eval.html">Enumeration&nbsp;values</a> | <a class="qindexHL" href="globals_defs.html">Defines</a></div>
+
+<p>
+<ul>
+<li>DMX_ATOMNAME
+: <a class="el" href="dmxprop_8c.html#a0">dmxprop.c</a><li>DMX_GET_COLORMAP_PRIV
+: <a class="el" href="dmxcmap_8h.html#a1">dmxcmap.h</a><li>DMX_GET_GC_PRIV
+: <a class="el" href="dmxgc_8h.html#a0">dmxgc.h</a><li>DMX_GET_GLYPH_PRIV
+: <a class="el" href="dmxpict_8h.html#a2">dmxpict.h</a><li>DMX_GET_PICT_PRIV
+: <a class="el" href="dmxpict_8h.html#a0">dmxpict.h</a><li>DMX_GET_PIXMAP_PRIV
+: <a class="el" href="dmxpixmap_8h.html#a0">dmxpixmap.h</a><li>DMX_GET_WINDOW_PRIV
+: <a class="el" href="dmxwindow_8h.html#a0">dmxwindow.h</a><li>DMX_IDENT
+: <a class="el" href="dmxprop_8c.html#a1">dmxprop.c</a><li>DMX_MAX_SIGIO_FDS
+: <a class="el" href="dmxinput_8h.html#a0">dmxinput.h</a><li>DMX_SET_COLORMAP_PRIV
+: <a class="el" href="dmxcmap_8h.html#a0">dmxcmap.h</a><li>DMX_SET_GLYPH_PRIV
+: <a class="el" href="dmxpict_8h.html#a1">dmxpict.h</a><li>DMX_STAT_BIN0
+: <a class="el" href="dmxstat_8h.html#a3">dmxstat.h</a><li>DMX_STAT_BINMULT
+: <a class="el" href="dmxstat_8h.html#a4">dmxstat.h</a><li>DMX_STAT_BINS
+: <a class="el" href="dmxstat_8h.html#a2">dmxstat.h</a><li>DMX_STAT_INTERVAL
+: <a class="el" href="dmxstat_8h.html#a1">dmxstat.h</a><li>DMX_STAT_LENGTH
+: <a class="el" href="dmxstat_8h.html#a0">dmxstat.h</a><li>DMX_UNWRAP
+: <a class="el" href="dmx_8h.html#a1">dmx.h</a><li>DMX_WRAP
+: <a class="el" href="dmx_8h.html#a0">dmx.h</a><li>GEN
+: <a class="el" href="dmxconfig_8c.html#a0">dmxconfig.c</a><li>QUEUE_SIZE
+: <a class="el" href="dmxeq_8c.html#a4">dmxeq.c</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_enum.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_enum.html
new file mode 100644
index 000000000..09cb593d6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_enum.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindexHL" href="globals.html">Globals</a></div>
+<div class="qindex"><a class="qindex" href="globals.html">All</a> | <a class="qindex" href="globals_func.html">Functions</a> | <a class="qindex" href="globals_vars.html">Variables</a> | <a class="qindex" href="globals_type.html">Typedefs</a> | <a class="qindexHL" href="globals_enum.html">Enumerations</a> | <a class="qindex" href="globals_eval.html">Enumeration&nbsp;values</a> | <a class="qindex" href="globals_defs.html">Defines</a></div>
+
+<p>
+<ul>
+<li>DMXInputEnum
+: <a class="el" href="dmxext_8h.html#a41">dmxext.h</a><li>dmxLogLevel
+: <a class="el" href="dmxlog_8h.html#a18">dmxlog.h</a><li>DMXRecomputeFlag
+: <a class="el" href="dmxcb_8h.html#a7">dmxcb.h</a><li>dmxSigioState
+: <a class="el" href="dmxinput_8h.html#a31">dmxinput.h</a><li>DMXUpdateType
+: <a class="el" href="dmxinput_8h.html#a30">dmxinput.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_eval.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_eval.html
new file mode 100644
index 000000000..15700d509
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_eval.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindexHL" href="globals.html">Globals</a></div>
+<div class="qindex"><a class="qindex" href="globals.html">All</a> | <a class="qindex" href="globals_func.html">Functions</a> | <a class="qindex" href="globals_vars.html">Variables</a> | <a class="qindex" href="globals_type.html">Typedefs</a> | <a class="qindex" href="globals_enum.html">Enumerations</a> | <a class="qindexHL" href="globals_eval.html">Enumeration&nbsp;values</a> | <a class="qindex" href="globals_defs.html">Defines</a></div>
+
+<p>
+<ul>
+<li>DMX_ACTIVESIGIO
+: <a class="el" href="dmxinput_8h.html#a31a14">dmxinput.h</a><li>DMX_NOSIGIO
+: <a class="el" href="dmxinput_8h.html#a31a12">dmxinput.h</a><li>DMX_UPDATE_COPY
+: <a class="el" href="dmxinput_8h.html#a30a9">dmxinput.h</a><li>DMX_UPDATE_REALIZE
+: <a class="el" href="dmxinput_8h.html#a30a6">dmxinput.h</a><li>DMX_UPDATE_REPARENT
+: <a class="el" href="dmxinput_8h.html#a30a11">dmxinput.h</a><li>DMX_UPDATE_RESIZE
+: <a class="el" href="dmxinput_8h.html#a30a10">dmxinput.h</a><li>DMX_UPDATE_RESTACK
+: <a class="el" href="dmxinput_8h.html#a30a8">dmxinput.h</a><li>DMX_UPDATE_UNREALIZE
+: <a class="el" href="dmxinput_8h.html#a30a7">dmxinput.h</a><li>DMX_USESIGIO
+: <a class="el" href="dmxinput_8h.html#a31a13">dmxinput.h</a><li>dmxDebug
+: <a class="el" href="dmxlog_8h.html#a18a0">dmxlog.h</a><li>dmxError
+: <a class="el" href="dmxlog_8h.html#a18a3">dmxlog.h</a><li>dmxFatal
+: <a class="el" href="dmxlog_8h.html#a18a4">dmxlog.h</a><li>dmxInfo
+: <a class="el" href="dmxlog_8h.html#a18a1">dmxlog.h</a><li>dmxWarning
+: <a class="el" href="dmxlog_8h.html#a18a2">dmxlog.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_func.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_func.html
new file mode 100644
index 000000000..85b327b60
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_func.html
@@ -0,0 +1,388 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindexHL" href="globals.html">Globals</a></div>
+<div class="qindex"><a class="qindex" href="globals.html">All</a> | <a class="qindexHL" href="globals_func.html">Functions</a> | <a class="qindex" href="globals_vars.html">Variables</a> | <a class="qindex" href="globals_type.html">Typedefs</a> | <a class="qindex" href="globals_enum.html">Enumerations</a> | <a class="qindex" href="globals_eval.html">Enumeration&nbsp;values</a> | <a class="qindex" href="globals_defs.html">Defines</a></div>
+<div class="qindex"><a class="qindex" href="#index_a">a</a> | <a class="qindex" href="#index_c">c</a> | <a class="qindex" href="#index_d">d</a> | <a class="qindex" href="#index_g">g</a> | <a class="qindex" href="#index_i">i</a> | <a class="qindex" href="#index_k">k</a> | <a class="qindex" href="#index_l">l</a> | <a class="qindex" href="#index_m">m</a> | <a class="qindex" href="#index_o">o</a> | <a class="qindex" href="#index_p">p</a> | <a class="qindex" href="#index_s">s</a> | <a class="qindex" href="#index_u">u</a> | <a class="qindex" href="#index_x">x</a></div>
+
+<p>
+
+<p>
+<h3><a class="anchor" name="index_a">- a -</a></h3><ul>
+<li>AbortDDX()
+: <a class="el" href="dmxinit_8c.html#a36">dmxinit.c</a><li>AbortServer()
+: <a class="el" href="dmxlog_8c.html#a3">dmxlog.c</a><li>AddOtherInputDevices()
+: <a class="el" href="dmxxinput_8c.html#a4">dmxxinput.c</a></ul>
+<h3><a class="anchor" name="index_c">- c -</a></h3><ul>
+<li>ChangeDeviceControl()
+: <a class="el" href="dmxxinput_8c.html#a8">dmxxinput.c</a><li>ChangeKeyboardDevice()
+: <a class="el" href="dmxxinput_8c.html#a1">dmxxinput.c</a><li>ChangePointerDevice()
+: <a class="el" href="dmxxinput_8c.html#a2">dmxxinput.c</a><li>CloseInputDevice()
+: <a class="el" href="dmxxinput_8c.html#a3">dmxxinput.c</a></ul>
+<h3><a class="anchor" name="index_d">- d -</a></h3><ul>
+<li>ddxGiveUp()
+: <a class="el" href="dmxinit_8c.html#a37">dmxinit.c</a><li>ddxProcessArgument()
+: <a class="el" href="dmxinit_8c.html#a40">dmxinit.c</a><li>ddxUseMsg()
+: <a class="el" href="dmxinit_8c.html#a41">dmxinit.c</a><li>DMXAddBackendInput()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a31">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a39">dmxext.h</a><li>DMXAddConsoleInput()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a32">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a40">dmxext.h</a><li>dmxAddInput()
+: <a class="el" href="dmxextension_8h.html#a12">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a7">dmxextension.c</a><li>DMXAddInput()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a30">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a37">dmxext.h</a><li>DMXAddScreen()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a21">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a30">dmxext.h</a><li>dmxArgAdd()
+: <a class="el" href="dmxarg_8h.html#a3">dmxarg.h</a>, <a class="el" href="dmxarg_8c.html#a3">dmxarg.c</a><li>dmxArgC()
+: <a class="el" href="dmxarg_8h.html#a5">dmxarg.h</a>, <a class="el" href="dmxarg_8c.html#a5">dmxarg.c</a><li>dmxArgCreate()
+: <a class="el" href="dmxarg_8h.html#a1">dmxarg.h</a>, <a class="el" href="dmxarg_8c.html#a1">dmxarg.c</a><li>dmxArgFree()
+: <a class="el" href="dmxarg_8h.html#a2">dmxarg.h</a>, <a class="el" href="dmxarg_8c.html#a2">dmxarg.c</a><li>dmxArgParse()
+: <a class="el" href="dmxarg_8h.html#a6">dmxarg.h</a>, <a class="el" href="dmxarg_8c.html#a6">dmxarg.c</a><li>dmxArgV()
+: <a class="el" href="dmxarg_8h.html#a4">dmxarg.h</a>, <a class="el" href="dmxarg_8c.html#a4">dmxarg.c</a><li>dmxAttachScreen()
+: <a class="el" href="dmxextension_8h.html#a17">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a18">dmxextension.c</a><li>dmxBackendCollectEvents()
+: <a class="el" href="dmxbackend_8h.html#a6">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a25">dmxbackend.c</a><li>dmxBackendCreatePrivate()
+: <a class="el" href="dmxbackend_8h.html#a0">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a12">dmxbackend.c</a><li>dmxBackendDestroyPrivate()
+: <a class="el" href="dmxbackend_8h.html#a1">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a13">dmxbackend.c</a><li>dmxBackendFunctions()
+: <a class="el" href="dmxbackend_8h.html#a8">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a33">dmxbackend.c</a><li>dmxBackendInit()
+: <a class="el" href="dmxbackend_8h.html#a2">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a30">dmxbackend.c</a><li>dmxBackendKbdGetInfo()
+: <a class="el" href="dmxbackend_8h.html#a5">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a32">dmxbackend.c</a><li>dmxBackendLateReInit()
+: <a class="el" href="dmxbackend_8h.html#a3">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a29">dmxbackend.c</a><li>dmxBackendMouGetInfo()
+: <a class="el" href="dmxbackend_8h.html#a4">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a31">dmxbackend.c</a><li>dmxBackendProcessInput()
+: <a class="el" href="dmxbackend_8h.html#a7">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a26">dmxbackend.c</a><li>dmxBackendUpdatePosition()
+: <a class="el" href="dmxbackend_8h.html#a9">dmxbackend.h</a>, <a class="el" href="dmxbackend_8c.html#a24">dmxbackend.c</a><li>dmxBECloseScreen()
+: <a class="el" href="dmxscrinit_8h.html#a3">dmxscrinit.h</a>, <a class="el" href="dmxscrinit_8c.html#a13">dmxscrinit.c</a><li>dmxBECreateColormap()
+: <a class="el" href="dmxcmap_8h.html#a10">dmxcmap.h</a>, <a class="el" href="dmxcmap_8c.html#a2">dmxcmap.c</a><li>dmxBECreateCursor()
+: <a class="el" href="dmxcursor_8h.html#a13">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a29">dmxcursor.c</a><li>dmxBECreateGC()
+: <a class="el" href="dmxgc_8h.html#a15">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a3">dmxgc.c</a><li>dmxBECreatePixmap()
+: <a class="el" href="dmxpixmap_8h.html#a8">dmxpixmap.h</a>, <a class="el" href="dmxpixmap_8c.html#a1">dmxpixmap.c</a><li>dmxBEDestroyWindow()
+: <a class="el" href="dmxwindow_8h.html#a31">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a11">dmxwindow.c</a><li>dmxBEFreeColormap()
+: <a class="el" href="dmxcmap_8h.html#a11">dmxcmap.h</a>, <a class="el" href="dmxcmap_8c.html#a4">dmxcmap.c</a><li>dmxBEFreeCursor()
+: <a class="el" href="dmxcursor_8h.html#a14">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a31">dmxcursor.c</a><li>dmxBEFreeFont()
+: <a class="el" href="dmxfont_8h.html#a8">dmxfont.h</a>, <a class="el" href="dmxfont_8c.html#a14">dmxfont.c</a><li>dmxBEFreeGC()
+: <a class="el" href="dmxgc_8h.html#a16">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a8">dmxgc.c</a><li>dmxBEFreeGlyphSet()
+: <a class="el" href="dmxpict_8h.html#a30">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a16">dmxpict.c</a><li>dmxBEFreePicture()
+: <a class="el" href="dmxpict_8h.html#a31">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a20">dmxpict.c</a><li>dmxBEFreePixmap()
+: <a class="el" href="dmxpixmap_8h.html#a9">dmxpixmap.h</a>, <a class="el" href="dmxpixmap_8c.html#a3">dmxpixmap.c</a><li>dmxBELoadFont()
+: <a class="el" href="dmxfont_8h.html#a7">dmxfont.h</a>, <a class="el" href="dmxfont_8c.html#a12">dmxfont.c</a><li>dmxBEScreenInit()
+: <a class="el" href="dmxscrinit_8h.html#a2">dmxscrinit.h</a>, <a class="el" href="dmxscrinit_8c.html#a11">dmxscrinit.c</a><li>dmxBitmapToRegion()
+: <a class="el" href="dmxpixmap_8h.html#a7">dmxpixmap.h</a>, <a class="el" href="dmxpixmap_8c.html#a5">dmxpixmap.c</a><li>dmxChangeBorderWidth()
+: <a class="el" href="dmxwindow_8h.html#a28">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a25">dmxwindow.c</a><li>dmxChangeClip()
+: <a class="el" href="dmxgc_8h.html#a12">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a10">dmxgc.c</a><li>DMXChangeDesktopAttributes()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a27">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a34">dmxext.h</a><li>dmxChangeGC()
+: <a class="el" href="dmxgc_8h.html#a9">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a6">dmxgc.c</a><li>dmxChangePicture()
+: <a class="el" href="dmxpict_8h.html#a18">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a25">dmxpict.c</a><li>dmxChangePictureClip()
+: <a class="el" href="dmxpict_8h.html#a16">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a23">dmxpict.c</a><li>dmxChangePointerControl()
+: <a class="el" href="dmxinputinit_8h.html#a54">dmxinputinit.h</a>, <a class="el" href="dmxinputinit_8c.html#a16">dmxinputinit.c</a><li>DMXChangeScreensAttributes()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a20">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a29">dmxext.h</a><li>dmxChangeWindowAttributes()
+: <a class="el" href="dmxwindow_8h.html#a18">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a14">dmxwindow.c</a><li>dmxCheckCursor()
+: <a class="el" href="dmxcursor_8h.html#a10">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a41">dmxcursor.c</a><li>dmxCheckSpecialKeys()
+: <a class="el" href="dmxevents_8h.html#a2">dmxevents.h</a>, <a class="el" href="dmxevents_8c.html#a28">dmxevents.c</a><li>dmxCloseIndexed()
+: <a class="el" href="dmxpict_8h.html#a24">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a31">dmxpict.c</a><li>dmxCloseScreen()
+: <a class="el" href="dmxscrinit_8c.html#a9">dmxscrinit.c</a><li>dmxColormapFromDefaultVisual()
+: <a class="el" href="dmxvisual_8h.html#a2">dmxvisual.h</a>, <a class="el" href="dmxvisual_8c.html#a2">dmxvisual.c</a><li>dmxCommonCopyPrivate()
+: <a class="el" href="dmxcommon_8h.html#a27">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a26">dmxcommon.c</a><li>dmxCommonKbdBell()
+: <a class="el" href="dmxcommon_8h.html#a16">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a11">dmxcommon.c</a><li>dmxCommonKbdCtrl()
+: <a class="el" href="dmxcommon_8h.html#a15">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a9">dmxcommon.c</a><li>dmxCommonKbdGetInfo()
+: <a class="el" href="dmxcommon_8h.html#a13">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a13">dmxcommon.c</a><li>dmxCommonKbdGetMap()
+: <a class="el" href="dmxcommon_8h.html#a14">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a12">dmxcommon.c</a><li>dmxCommonKbdOff()
+: <a class="el" href="dmxcommon_8h.html#a18">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a15">dmxcommon.c</a><li>dmxCommonKbdOn()
+: <a class="el" href="dmxcommon_8h.html#a17">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a14">dmxcommon.c</a><li>dmxCommonMouCtrl()
+: <a class="el" href="dmxcommon_8h.html#a20">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a10">dmxcommon.c</a><li>dmxCommonMouGetMap()
+: <a class="el" href="dmxcommon_8h.html#a19">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a19">dmxcommon.c</a><li>dmxCommonMouOff()
+: <a class="el" href="dmxcommon_8h.html#a22">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a24">dmxcommon.c</a><li>dmxCommonMouOn()
+: <a class="el" href="dmxcommon_8h.html#a21">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a23">dmxcommon.c</a><li>dmxCommonOthGetInfo()
+: <a class="el" href="dmxcommon_8h.html#a26">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a18">dmxcommon.c</a><li>dmxCommonOthOff()
+: <a class="el" href="dmxcommon_8h.html#a25">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a17">dmxcommon.c</a><li>dmxCommonOthOn()
+: <a class="el" href="dmxcommon_8h.html#a24">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a16">dmxcommon.c</a><li>dmxCommonRestoreState()
+: <a class="el" href="dmxcommon_8h.html#a29">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a28">dmxcommon.c</a><li>dmxCommonSaveState()
+: <a class="el" href="dmxcommon_8h.html#a28">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a27">dmxcommon.c</a><li>dmxComposite()
+: <a class="el" href="dmxpict_8h.html#a20">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a27">dmxpict.c</a><li>dmxCompositeRects()
+: <a class="el" href="dmxpict_8h.html#a22">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a29">dmxpict.c</a><li>dmxComputeWidthHeight()
+: <a class="el" href="dmxcb_8h.html#a5">dmxcb.h</a>, <a class="el" href="dmxcb_8c.html#a8">dmxcb.c</a><li>dmxConfigConfigure()
+: <a class="el" href="dmxconfig_8h.html#a10">dmxconfig.h</a>, <a class="el" href="dmxconfig_8c.html#a32">dmxconfig.c</a><li>dmxConfigLog()
+: <a class="el" href="dmxparse_8h.html#a38">dmxparse.h</a>, <a class="el" href="dmxparse_8c.html#a0">dmxparse.c</a><li>dmxConfigPrint()
+: <a class="el" href="dmxprint_8h.html#a0">dmxprint.h</a>, <a class="el" href="dmxprint_8c.html#a25">dmxprint.c</a><li>dmxConfigSetMaxScreens()
+: <a class="el" href="dmxconfig_8h.html#a11">dmxconfig.h</a>, <a class="el" href="dmxconfig_8c.html#a33">dmxconfig.c</a><li>dmxConfigStoreConfig()
+: <a class="el" href="dmxconfig_8h.html#a9">dmxconfig.h</a>, <a class="el" href="dmxconfig_8c.html#a19">dmxconfig.c</a><li>dmxConfigStoreDisplay()
+: <a class="el" href="dmxconfig_8h.html#a5">dmxconfig.h</a>, <a class="el" href="dmxconfig_8c.html#a15">dmxconfig.c</a><li>dmxConfigStoreFile()
+: <a class="el" href="dmxconfig_8h.html#a8">dmxconfig.h</a>, <a class="el" href="dmxconfig_8c.html#a18">dmxconfig.c</a><li>dmxConfigStoreInput()
+: <a class="el" href="dmxconfig_8h.html#a6">dmxconfig.h</a>, <a class="el" href="dmxconfig_8c.html#a16">dmxconfig.c</a><li>dmxConfigStoreXInput()
+: <a class="el" href="dmxconfig_8h.html#a7">dmxconfig.h</a>, <a class="el" href="dmxconfig_8c.html#a17">dmxconfig.c</a><li>dmxConfigVirtualPrint()
+: <a class="el" href="dmxprint_8h.html#a1">dmxprint.h</a>, <a class="el" href="dmxprint_8c.html#a26">dmxprint.c</a><li>dmxConnectionBlockCallback()
+: <a class="el" href="dmxcb_8h.html#a6">dmxcb.h</a>, <a class="el" href="dmxcb_8c.html#a9">dmxcb.c</a><li>dmxConsoleCapture()
+: <a class="el" href="dmxconsole_8h.html#a10">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a47">dmxconsole.c</a><li>dmxConsoleCollectEvents()
+: <a class="el" href="dmxconsole_8h.html#a6">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a36">dmxconsole.c</a><li>dmxConsoleCreatePrivate()
+: <a class="el" href="dmxconsole_8h.html#a0">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a25">dmxconsole.c</a><li>dmxConsoleDestroyPrivate()
+: <a class="el" href="dmxconsole_8h.html#a1">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a26">dmxconsole.c</a><li>dmxConsoleFunctions()
+: <a class="el" href="dmxconsole_8h.html#a7">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a45">dmxconsole.c</a><li>dmxConsoleInit()
+: <a class="el" href="dmxconsole_8h.html#a2">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a42">dmxconsole.c</a><li>dmxConsoleKbdGetInfo()
+: <a class="el" href="dmxconsole_8h.html#a5">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a44">dmxconsole.c</a><li>dmxConsoleMouGetInfo()
+: <a class="el" href="dmxconsole_8h.html#a4">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a43">dmxconsole.c</a><li>dmxConsoleReInit()
+: <a class="el" href="dmxconsole_8h.html#a3">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a41">dmxconsole.c</a><li>dmxConsoleUncapture()
+: <a class="el" href="dmxconsole_8h.html#a11">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a48">dmxconsole.c</a><li>dmxConsoleUpdateInfo()
+: <a class="el" href="dmxconsole_8h.html#a12">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a32">dmxconsole.c</a><li>dmxConsoleUpdatePosition()
+: <a class="el" href="dmxconsole_8h.html#a8">dmxconsole.h</a>, <a class="el" href="dmxconsole_8c.html#a35">dmxconsole.c</a><li>dmxCopyArea()
+: <a class="el" href="dmxgcops_8h.html#a3">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a5">dmxgcops.c</a><li>dmxCopyClip()
+: <a class="el" href="dmxgc_8h.html#a14">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a12">dmxgc.c</a><li>dmxCopyGC()
+: <a class="el" href="dmxgc_8h.html#a10">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a7">dmxgc.c</a><li>dmxCopyPlane()
+: <a class="el" href="dmxgcops_8h.html#a4">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a6">dmxgcops.c</a><li>dmxCopyWindow()
+: <a class="el" href="dmxwindow_8h.html#a25">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a22">dmxwindow.c</a><li>dmxCreateAndRealizeWindow()
+: <a class="el" href="dmxwindow_8h.html#a14">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a9">dmxwindow.c</a><li>dmxCreateColormap()
+: <a class="el" href="dmxcmap_8h.html#a5">dmxcmap.h</a>, <a class="el" href="dmxcmap_8c.html#a3">dmxcmap.c</a><li>dmxCreateDefColormap()
+: <a class="el" href="dmxcmap_8h.html#a9">dmxcmap.h</a>, <a class="el" href="dmxcmap_8c.html#a8">dmxcmap.c</a><li>dmxCreateGC()
+: <a class="el" href="dmxgc_8h.html#a7">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a4">dmxgc.c</a><li>dmxCreatePicture()
+: <a class="el" href="dmxpict_8h.html#a14">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a19">dmxpict.c</a><li>dmxCreatePictureList()
+: <a class="el" href="dmxpict_8h.html#a12">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a18">dmxpict.c</a><li>dmxCreatePixmap()
+: <a class="el" href="dmxpixmap_8h.html#a5">dmxpixmap.h</a>, <a class="el" href="dmxpixmap_8c.html#a2">dmxpixmap.c</a><li>dmxCreateWindow()
+: <a class="el" href="dmxwindow_8h.html#a15">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a10">dmxwindow.c</a><li>dmxCursorNoMulti()
+: <a class="el" href="dmxcursor_8h.html#a8">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a12">dmxcursor.c</a><li>dmxDestroyClip()
+: <a class="el" href="dmxgc_8h.html#a13">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a11">dmxgc.c</a><li>dmxDestroyColormap()
+: <a class="el" href="dmxcmap_8h.html#a6">dmxcmap.h</a>, <a class="el" href="dmxcmap_8c.html#a5">dmxcmap.c</a><li>dmxDestroyGC()
+: <a class="el" href="dmxgc_8h.html#a11">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a9">dmxgc.c</a><li>dmxDestroyPicture()
+: <a class="el" href="dmxpict_8h.html#a15">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a22">dmxpict.c</a><li>dmxDestroyPictureClip()
+: <a class="el" href="dmxpict_8h.html#a17">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a24">dmxpict.c</a><li>dmxDestroyPictureList()
+: <a class="el" href="dmxpict_8h.html#a13">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a21">dmxpict.c</a><li>dmxDestroyPixmap()
+: <a class="el" href="dmxpixmap_8h.html#a6">dmxpixmap.h</a>, <a class="el" href="dmxpixmap_8c.html#a4">dmxpixmap.c</a><li>dmxDestroyWindow()
+: <a class="el" href="dmxwindow_8h.html#a16">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a12">dmxwindow.c</a><li>dmxDetachScreen()
+: <a class="el" href="dmxextension_8h.html#a18">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a23">dmxextension.c</a><li>dmxDPMSInit()
+: <a class="el" href="dmxdpms_8h.html#a0">dmxdpms.h</a>, <a class="el" href="dmxdpms_8c.html#a3">dmxdpms.c</a><li>dmxDPMSTerm()
+: <a class="el" href="dmxdpms_8h.html#a1">dmxdpms.h</a>, <a class="el" href="dmxdpms_8c.html#a4">dmxdpms.c</a><li>dmxDPMSWakeup()
+: <a class="el" href="dmxdpms_8h.html#a2">dmxdpms.h</a>, <a class="el" href="dmxdpms_8c.html#a5">dmxdpms.c</a><li>dmxDummyKbdGetInfo()
+: <a class="el" href="dmxdummy_8h.html#a1">dmxdummy.h</a>, <a class="el" href="dmxdummy_8c.html#a0">dmxdummy.c</a><li>dmxDummyMouGetInfo()
+: <a class="el" href="dmxdummy_8h.html#a0">dmxdummy.h</a>, <a class="el" href="dmxdummy_8c.html#a1">dmxdummy.c</a><li>dmxEnqueue()
+: <a class="el" href="dmxevents_8h.html#a1">dmxevents.h</a>, <a class="el" href="dmxevents_8c.html#a27">dmxevents.c</a><li>dmxeqEnqueue()
+: <a class="el" href="dmxeq_8c.html#a13">dmxeq.c</a>, <a class="el" href="dmxinput_8h.html#a24">dmxinput.h</a><li>dmxeqProcessInputEvents()
+: <a class="el" href="dmxeq_8h.html#a1">dmxeq.h</a>, <a class="el" href="dmxeq_8c.html#a16">dmxeq.c</a><li>dmxeqSwitchScreen()
+: <a class="el" href="dmxeq_8c.html#a14">dmxeq.c</a>, <a class="el" href="dmxinput_8h.html#a25">dmxinput.h</a><li>dmxEventName()
+: <a class="el" href="dmxlog_8h.html#a9">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a17">dmxlog.c</a><li>DMXExtensionInit()
+: <a class="el" href="programs_2Xserver_2Xext_2dmx_8c.html#a3">programs/Xserver/Xext/dmx.c</a><li>dmxFillPolygon()
+: <a class="el" href="dmxgcops_8h.html#a10">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a12">dmxgcops.c</a><li>dmxFillSpans()
+: <a class="el" href="dmxgcops_8h.html#a0">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a2">dmxgcops.c</a><li>dmxFindPointerScreen()
+: <a class="el" href="dmxcommon_8h.html#a23">dmxcommon.h</a>, <a class="el" href="dmxcommon_8c.html#a25">dmxcommon.c</a><li>dmxFlushPendingSyncs()
+: <a class="el" href="dmxextension_8h.html#a6">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a11">dmxextension.c</a><li>DMXForceWindowCreation()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a13">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a26">dmxext.h</a><li>dmxForceWindowCreation()
+: <a class="el" href="dmxextension_8h.html#a5">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a10">dmxextension.c</a><li>DMXGetDesktopAttributes()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a24">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a33">dmxext.h</a><li>dmxGetGlobalPosition()
+: <a class="el" href="dmxevents_8c.html#a21">dmxevents.c</a>, <a class="el" href="dmxinput_8h.html#a26">dmxinput.h</a><li>dmxGetImage()
+: <a class="el" href="dmxgcops_8h.html#a20">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a22">dmxgcops.c</a><li>dmxGetInputAttributes()
+: <a class="el" href="dmxextension_8h.html#a11">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a5">dmxextension.c</a><li>DMXGetInputAttributes()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a29">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a36">dmxext.h</a><li>DMXGetInputCount()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a28">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a35">dmxext.h</a><li>dmxGetInputCount()
+: <a class="el" href="dmxextension_8h.html#a10">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a4">dmxextension.c</a><li>dmxGetLogLevel()
+: <a class="el" href="dmxlog_8h.html#a6">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a2">dmxlog.c</a><li>dmxGetNumScreens()
+: <a class="el" href="dmxextension_8h.html#a4">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a9">dmxextension.c</a><li>DMXGetScreenAttributes()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a15">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a28">dmxext.h</a><li>dmxGetScreenAttributes()
+: <a class="el" href="dmxextension_8h.html#a7">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a1">dmxextension.c</a><li>DMXGetScreenCount()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a14">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a27">dmxext.h</a><li>dmxGetSpans()
+: <a class="el" href="dmxgcops_8h.html#a21">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a23">dmxgcops.c</a><li>DMXGetWindowAttributes()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a23">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a32">dmxext.h</a><li>dmxGetWindowAttributes()
+: <a class="el" href="dmxextension_8h.html#a8">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a2">dmxextension.c</a><li>dmxGlyphs()
+: <a class="el" href="dmxpict_8h.html#a21">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a28">dmxpict.c</a><li>dmxHideCursor()
+: <a class="el" href="dmxcursor_8h.html#a12">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a40">dmxcursor.c</a><li>dmxImageGlyphBlt()
+: <a class="el" href="dmxgcops_8h.html#a17">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a19">dmxgcops.c</a><li>dmxImageText16()
+: <a class="el" href="dmxgcops_8h.html#a16">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a18">dmxgcops.c</a><li>dmxImageText8()
+: <a class="el" href="dmxgcops_8h.html#a15">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a17">dmxgcops.c</a><li>dmxInitFonts()
+: <a class="el" href="dmxfont_8h.html#a3">dmxfont.h</a>, <a class="el" href="dmxfont_8c.html#a10">dmxfont.c</a><li>dmxInitGC()
+: <a class="el" href="dmxgc_8h.html#a6">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a2">dmxgc.c</a><li>dmxInitIndexed()
+: <a class="el" href="dmxpict_8h.html#a23">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a30">dmxpict.c</a><li>dmxInitOrigins()
+: <a class="el" href="dmxcursor_8h.html#a6">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a22">dmxcursor.c</a><li>dmxInitOverlap()
+: <a class="el" href="dmxcursor_8h.html#a7">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a28">dmxcursor.c</a><li>dmxInitPixmap()
+: <a class="el" href="dmxpixmap_8h.html#a4">dmxpixmap.h</a>, <a class="el" href="dmxpixmap_8c.html#a0">dmxpixmap.c</a><li>dmxInitRender()
+: <a class="el" href="dmxpict_8h.html#a9">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a12">dmxpict.c</a><li>dmxInitWindow()
+: <a class="el" href="dmxwindow_8h.html#a11">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a3">dmxwindow.c</a><li>dmxInputCopyLocal()
+: <a class="el" href="dmxinputinit_8h.html#a53">dmxinputinit.h</a>, <a class="el" href="dmxinputinit_8c.html#a33">dmxinputinit.c</a><li>dmxInputDetach()
+: <a class="el" href="dmxinputinit_8h.html#a58">dmxinputinit.h</a>, <a class="el" href="dmxinputinit_8c.html#a43">dmxinputinit.c</a>, <a class="el" href="dmxdetach_8c.html#a0">dmxdetach.c</a><li>dmxInputDetachAll()
+: <a class="el" href="dmxinputinit_8h.html#a59">dmxinputinit.h</a>, <a class="el" href="dmxinputinit_8c.html#a44">dmxinputinit.c</a><li>dmxInputDetachId()
+: <a class="el" href="dmxinputinit_8h.html#a60">dmxinputinit.h</a>, <a class="el" href="dmxinputinit_8c.html#a45">dmxinputinit.c</a><li>dmxInputFree()
+: <a class="el" href="dmxinputinit_8c.html#a41">dmxinputinit.c</a>, <a class="el" href="dmxinput_8h.html#a20">dmxinput.h</a><li>dmxInputInit()
+: <a class="el" href="dmxinputinit_8c.html#a39">dmxinputinit.c</a>, <a class="el" href="dmxinput_8h.html#a17">dmxinput.h</a><li>dmxInputLateReInit()
+: <a class="el" href="dmxinputinit_8c.html#a38">dmxinputinit.c</a>, <a class="el" href="dmxinput_8h.html#a19">dmxinput.h</a><li>dmxInputLogDevices()
+: <a class="el" href="dmxinputinit_8c.html#a42">dmxinputinit.c</a>, <a class="el" href="dmxinput_8h.html#a21">dmxinput.h</a><li>dmxInputReInit()
+: <a class="el" href="dmxinputinit_8c.html#a37">dmxinputinit.c</a>, <a class="el" href="dmxinput_8h.html#a18">dmxinput.h</a><li>dmxInstallColormap()
+: <a class="el" href="dmxcmap_8h.html#a7">dmxcmap.h</a>, <a class="el" href="dmxcmap_8c.html#a6">dmxcmap.c</a><li>dmxInvalidateGlobalPosition()
+: <a class="el" href="dmxevents_8h.html#a3">dmxevents.h</a>, <a class="el" href="dmxevents_8c.html#a22">dmxevents.c</a><li>dmxKeyboardBellProc()
+: <a class="el" href="dmxinputinit_8h.html#a56">dmxinputinit.h</a>, <a class="el" href="dmxinputinit_8c.html#a20">dmxinputinit.c</a><li>dmxKeyboardKbdCtrlProc()
+: <a class="el" href="dmxinputinit_8h.html#a55">dmxinputinit.h</a>, <a class="el" href="dmxinputinit_8c.html#a18">dmxinputinit.c</a><li>dmxLog()
+: <a class="el" href="dmxlog_8h.html#a7">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a7">dmxlog.c</a><li>dmxLogArgs()
+: <a class="el" href="dmxlog_8h.html#a15">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a14">dmxlog.c</a><li>dmxLogCont()
+: <a class="el" href="dmxlog_8h.html#a8">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a8">dmxlog.c</a><li>dmxLogInput()
+: <a class="el" href="dmxlog_8h.html#a13">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a12">dmxlog.c</a><li>dmxLogInputCont()
+: <a class="el" href="dmxlog_8h.html#a14">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a13">dmxlog.c</a><li>dmxLogOutput()
+: <a class="el" href="dmxlog_8h.html#a10">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a9">dmxlog.c</a><li>dmxLogOutputCont()
+: <a class="el" href="dmxlog_8h.html#a11">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a10">dmxlog.c</a><li>dmxLogOutputWarning()
+: <a class="el" href="dmxlog_8h.html#a12">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a11">dmxlog.c</a><li>dmxLogVisual()
+: <a class="el" href="dmxlog_8h.html#a16">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a15">dmxlog.c</a><li>dmxLookupVisual()
+: <a class="el" href="dmxvisual_8h.html#a0">dmxvisual.h</a>, <a class="el" href="dmxvisual_8c.html#a0">dmxvisual.c</a><li>dmxLookupVisualFromID()
+: <a class="el" href="dmxvisual_8h.html#a1">dmxvisual.h</a>, <a class="el" href="dmxvisual_8c.html#a1">dmxvisual.c</a><li>dmxMapClear()
+: <a class="el" href="dmxmap_8h.html#a1">dmxmap.h</a>, <a class="el" href="dmxmap_8c.html#a1">dmxmap.c</a><li>dmxMapInsert()
+: <a class="el" href="dmxmap_8h.html#a0">dmxmap.h</a>, <a class="el" href="dmxmap_8c.html#a0">dmxmap.c</a><li>dmxMapLookup()
+: <a class="el" href="dmxmap_8h.html#a2">dmxmap.h</a>, <a class="el" href="dmxmap_8c.html#a2">dmxmap.c</a><li>dmxMotion()
+: <a class="el" href="dmxevents_8h.html#a0">dmxevents.h</a>, <a class="el" href="dmxevents_8c.html#a23">dmxevents.c</a><li>dmxMoveCursor()
+: <a class="el" href="dmxcursor_8h.html#a9">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a38">dmxcursor.c</a><li>dmxOnScreen()
+: <a class="el" href="dmxcursor_8h.html#a11">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a23">dmxcursor.c</a><li>dmxPaintWindowBackground()
+: <a class="el" href="dmxwindow_8h.html#a23">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a20">dmxwindow.c</a><li>dmxPaintWindowBorder()
+: <a class="el" href="dmxwindow_8h.html#a24">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a21">dmxwindow.c</a><li>dmxPictureInit()
+: <a class="el" href="dmxpict_8h.html#a11">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a14">dmxpict.c</a><li>dmxPointerGetMotionBufferSize()
+: <a class="el" href="dmxmotion_8h.html#a0">dmxmotion.h</a>, <a class="el" href="dmxmotion_8c.html#a1">dmxmotion.c</a><li>dmxPointerGetMotionEvents()
+: <a class="el" href="dmxmotion_8h.html#a1">dmxmotion.h</a>, <a class="el" href="dmxmotion_8c.html#a2">dmxmotion.c</a><li>dmxPointerPutMotionEvent()
+: <a class="el" href="dmxmotion_8h.html#a2">dmxmotion.h</a>, <a class="el" href="dmxmotion_8c.html#a3">dmxmotion.c</a><li>dmxPolyArc()
+: <a class="el" href="dmxgcops_8h.html#a9">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a11">dmxgcops.c</a><li>dmxPolyFillArc()
+: <a class="el" href="dmxgcops_8h.html#a12">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a14">dmxgcops.c</a><li>dmxPolyFillRect()
+: <a class="el" href="dmxgcops_8h.html#a11">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a13">dmxgcops.c</a><li>dmxPolyGlyphBlt()
+: <a class="el" href="dmxgcops_8h.html#a18">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a20">dmxgcops.c</a><li>dmxPolylines()
+: <a class="el" href="dmxgcops_8h.html#a6">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a8">dmxgcops.c</a><li>dmxPolyPoint()
+: <a class="el" href="dmxgcops_8h.html#a5">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a7">dmxgcops.c</a><li>dmxPolyRectangle()
+: <a class="el" href="dmxgcops_8h.html#a8">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a10">dmxgcops.c</a><li>dmxPolySegment()
+: <a class="el" href="dmxgcops_8h.html#a7">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a9">dmxgcops.c</a><li>dmxPolyText16()
+: <a class="el" href="dmxgcops_8h.html#a14">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a16">dmxgcops.c</a><li>dmxPolyText8()
+: <a class="el" href="dmxgcops_8h.html#a13">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a15">dmxgcops.c</a><li>dmxPositionWindow()
+: <a class="el" href="dmxwindow_8h.html#a17">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a13">dmxwindow.c</a><li>dmxPropertyDisplay()
+: <a class="el" href="dmxprop_8h.html#a0">dmxprop.h</a>, <a class="el" href="dmxprop_8c.html#a8">dmxprop.c</a><li>dmxPropertyIterate()
+: <a class="el" href="dmxprop_8c.html#a5">dmxprop.c</a><li>dmxPropertySameDisplay()
+: <a class="el" href="dmxprop_8h.html#a3">dmxprop.h</a>, <a class="el" href="dmxprop_8c.html#a9">dmxprop.c</a><li>dmxPropertyWindow()
+: <a class="el" href="dmxprop_8h.html#a1">dmxprop.h</a>, <a class="el" href="dmxprop_8c.html#a10">dmxprop.c</a><li>dmxPushPixels()
+: <a class="el" href="dmxgcops_8h.html#a19">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a21">dmxgcops.c</a><li>dmxPutImage()
+: <a class="el" href="dmxgcops_8h.html#a2">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a4">dmxgcops.c</a><li>DMXQueryExtension()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a10">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a23">dmxext.h</a><li>DMXQueryVersion()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a11">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a24">dmxext.h</a><li>dmxRealizeFont()
+: <a class="el" href="dmxfont_8h.html#a5">dmxfont.h</a>, <a class="el" href="dmxfont_8c.html#a13">dmxfont.c</a><li>dmxRealizeWindow()
+: <a class="el" href="dmxwindow_8h.html#a19">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a15">dmxwindow.c</a><li>dmxReInitOrigins()
+: <a class="el" href="dmxcursor_8h.html#a5">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a21">dmxcursor.c</a><li>dmxRemoveInput()
+: <a class="el" href="dmxextension_8h.html#a13">dmxextension.h</a>, <a class="el" href="dmxextension_8c.html#a8">dmxextension.c</a><li>DMXRemoveInput()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a33">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a38">dmxext.h</a><li>DMXRemoveScreen()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a22">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a31">dmxext.h</a><li>dmxReparentWindow()
+: <a class="el" href="dmxwindow_8h.html#a27">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a24">dmxwindow.c</a><li>dmxResetFonts()
+: <a class="el" href="dmxfont_8h.html#a4">dmxfont.h</a>, <a class="el" href="dmxfont_8c.html#a11">dmxfont.c</a><li>dmxResetRender()
+: <a class="el" href="dmxpict_8h.html#a10">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a13">dmxpict.c</a><li>dmxResizeRootWindow()
+: <a class="el" href="dmxwindow_8h.html#a30">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a6">dmxwindow.c</a><li>dmxResizeScreenWindow()
+: <a class="el" href="dmxwindow_8h.html#a29">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a5">dmxwindow.c</a><li>dmxResizeWindow()
+: <a class="el" href="dmxwindow_8h.html#a26">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a23">dmxwindow.c</a><li>dmxRestackWindow()
+: <a class="el" href="dmxwindow_8h.html#a21">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a17">dmxwindow.c</a><li>dmxScreenInit()
+: <a class="el" href="dmxscrinit_8h.html#a1">dmxscrinit.h</a>, <a class="el" href="dmxscrinit_8c.html#a12">dmxscrinit.c</a><li>dmxSetLogLevel()
+: <a class="el" href="dmxlog_8h.html#a5">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a1">dmxlog.c</a><li>dmxSetShape()
+: <a class="el" href="dmxwindow_8h.html#a32">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a26">dmxwindow.c</a><li>dmxSetSpans()
+: <a class="el" href="dmxgcops_8h.html#a1">dmxgcops.h</a>, <a class="el" href="dmxgcops_8c.html#a3">dmxgcops.c</a><li>dmxSetWidthHeight()
+: <a class="el" href="dmxcb_8h.html#a4">dmxcb.h</a>, <a class="el" href="dmxcb_8c.html#a7">dmxcb.c</a><li>dmxShadowUpdateProc()
+: <a class="el" href="dmxshadow_8h.html#a0">dmxshadow.h</a>, <a class="el" href="dmxshadow_8c.html#a0">dmxshadow.c</a><li>dmxSigioBlock()
+: <a class="el" href="dmxsigio_8h.html#a0">dmxsigio.h</a>, <a class="el" href="dmxsigio_8c.html#a5">dmxsigio.c</a><li>dmxSigioDisableInput()
+: <a class="el" href="dmxsigio_8h.html#a3">dmxsigio.h</a>, <a class="el" href="dmxsigio_8c.html#a12">dmxsigio.c</a><li>dmxSigioEnableInput()
+: <a class="el" href="dmxsigio_8h.html#a2">dmxsigio.h</a>, <a class="el" href="dmxsigio_8c.html#a11">dmxsigio.c</a><li>dmxSigioRegister()
+: <a class="el" href="dmxsigio_8h.html#a4">dmxsigio.h</a>, <a class="el" href="dmxsigio_8c.html#a13">dmxsigio.c</a><li>dmxSigioUnblock()
+: <a class="el" href="dmxsigio_8h.html#a1">dmxsigio.h</a>, <a class="el" href="dmxsigio_8c.html#a6">dmxsigio.c</a><li>dmxSigioUnregister()
+: <a class="el" href="dmxsigio_8h.html#a5">dmxsigio.h</a>, <a class="el" href="dmxsigio_8c.html#a14">dmxsigio.c</a><li>dmxStatActivate()
+: <a class="el" href="dmxstat_8h.html#a6">dmxstat.h</a>, <a class="el" href="dmxstat_8c.html#a6">dmxstat.c</a><li>dmxStatAlloc()
+: <a class="el" href="dmxstat_8h.html#a7">dmxstat.h</a>, <a class="el" href="dmxstat_8c.html#a7">dmxstat.c</a><li>dmxStatFree()
+: <a class="el" href="dmxstat_8h.html#a8">dmxstat.h</a>, <a class="el" href="dmxstat_8c.html#a8">dmxstat.c</a><li>dmxStatInit()
+: <a class="el" href="dmxstat_8h.html#a9">dmxstat.h</a>, <a class="el" href="dmxstat_8c.html#a12">dmxstat.c</a><li>dmxStatSync()
+: <a class="el" href="dmxstat_8h.html#a10">dmxstat.h</a>, <a class="el" href="dmxstat_8c.html#a10">dmxstat.c</a><li>dmxStoreColors()
+: <a class="el" href="dmxcmap_8h.html#a8">dmxcmap.h</a>, <a class="el" href="dmxcmap_8c.html#a7">dmxcmap.c</a><li>dmxSync()
+: <a class="el" href="dmxsync_8h.html#a2">dmxsync.h</a>, <a class="el" href="dmxsync_8c.html#a9">dmxsync.c</a><li>DMXSync()
+: <a class="el" href="lib_2dmx_2dmx_8c.html#a12">lib/dmx/dmx.c</a>, <a class="el" href="dmxext_8h.html#a25">dmxext.h</a><li>dmxSyncActivate()
+: <a class="el" href="dmxsync_8h.html#a0">dmxsync.h</a>, <a class="el" href="dmxsync_8c.html#a7">dmxsync.c</a><li>dmxSyncInit()
+: <a class="el" href="dmxsync_8h.html#a1">dmxsync.h</a>, <a class="el" href="dmxsync_8c.html#a8">dmxsync.c</a><li>dmxTrapezoids()
+: <a class="el" href="dmxpict_8h.html#a26">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a33">dmxpict.c</a><li>dmxTriangles()
+: <a class="el" href="dmxpict_8h.html#a27">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a34">dmxpict.c</a><li>dmxTriFan()
+: <a class="el" href="dmxpict_8h.html#a29">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a36">dmxpict.c</a><li>dmxTriStrip()
+: <a class="el" href="dmxpict_8h.html#a28">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a35">dmxpict.c</a><li>dmxUnrealizeFont()
+: <a class="el" href="dmxfont_8h.html#a6">dmxfont.h</a>, <a class="el" href="dmxfont_8c.html#a15">dmxfont.c</a><li>dmxUnrealizeWindow()
+: <a class="el" href="dmxwindow_8h.html#a20">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a16">dmxwindow.c</a><li>dmxUpdateIndexed()
+: <a class="el" href="dmxpict_8h.html#a25">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a32">dmxpict.c</a><li>dmxUpdateWindowInfo()
+: <a class="el" href="dmxinput_8h.html#a22">dmxinput.h</a>, <a class="el" href="dmxinput_8c.html#a3">dmxinput.c</a><li>dmxValidateGC()
+: <a class="el" href="dmxgc_8h.html#a8">dmxgc.h</a>, <a class="el" href="dmxgc_8c.html#a5">dmxgc.c</a><li>dmxValidatePicture()
+: <a class="el" href="dmxpict_8h.html#a19">dmxpict.h</a>, <a class="el" href="dmxpict_8c.html#a26">dmxpict.c</a><li>dmxVDLRead()
+: <a class="el" href="dmxcompat_8h.html#a0">dmxcompat.h</a>, <a class="el" href="dmxcompat_8c.html#a4">dmxcompat.c</a><li>dmxWindowExposures()
+: <a class="el" href="dmxwindow_8h.html#a22">dmxwindow.h</a>, <a class="el" href="dmxwindow_8c.html#a19">dmxwindow.c</a><li>dmxXInputEventName()
+: <a class="el" href="dmxlog_8h.html#a17">dmxlog.h</a>, <a class="el" href="dmxlog_8c.html#a16">dmxlog.c</a></ul>
+<h3><a class="anchor" name="index_g">- g -</a></h3><ul>
+<li>GetTimeInMillis()
+: <a class="el" href="dmxinit_8c.html#a42">dmxinit.c</a></ul>
+<h3><a class="anchor" name="index_i">- i -</a></h3><ul>
+<li>InitInput()
+: <a class="el" href="dmxinput_8c.html#a1">dmxinput.c</a><li>InitOutput()
+: <a class="el" href="dmxinit_8c.html#a34">dmxinit.c</a></ul>
+<h3><a class="anchor" name="index_k">- k -</a></h3><ul>
+<li>kbdLinuxBell()
+: <a class="el" href="lnx-keyboard_8h.html#a11">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a26">lnx-keyboard.c</a><li>kbdLinuxCreatePrivate()
+: <a class="el" href="lnx-keyboard_8h.html#a0">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a24">lnx-keyboard.c</a><li>kbdLinuxCtrl()
+: <a class="el" href="lnx-keyboard_8h.html#a10">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a27">lnx-keyboard.c</a><li>kbdLinuxDestroyPrivate()
+: <a class="el" href="lnx-keyboard_8h.html#a1">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a25">lnx-keyboard.c</a><li>kbdLinuxGetInfo()
+: <a class="el" href="lnx-keyboard_8h.html#a3">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a47">lnx-keyboard.c</a><li>kbdLinuxInit()
+: <a class="el" href="lnx-keyboard_8h.html#a2">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a38">lnx-keyboard.c</a><li>kbdLinuxOff()
+: <a class="el" href="lnx-keyboard_8h.html#a5">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a44">lnx-keyboard.c</a><li>kbdLinuxOn()
+: <a class="el" href="lnx-keyboard_8h.html#a4">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a43">lnx-keyboard.c</a><li>kbdLinuxRead()
+: <a class="el" href="lnx-keyboard_8c.html#a42">lnx-keyboard.c</a><li>kbdLinuxVTPostSwitch()
+: <a class="el" href="lnx-keyboard_8h.html#a7">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a33">lnx-keyboard.c</a><li>kbdLinuxVTPreSwitch()
+: <a class="el" href="lnx-keyboard_8h.html#a6">lnx-keyboard.h</a>, <a class="el" href="lnx-keyboard_8c.html#a32">lnx-keyboard.c</a><li>kbdLinuxVTSwitch()
+: <a class="el" href="lnx-keyboard_8c.html#a34">lnx-keyboard.c</a><li>kbdUSBCtrl()
+: <a class="el" href="usb-keyboard_8h.html#a4">usb-keyboard.h</a>, <a class="el" href="usb-keyboard_8c.html#a20">usb-keyboard.c</a><li>kbdUSBGetInfo()
+: <a class="el" href="usb-keyboard_8h.html#a1">usb-keyboard.h</a>, <a class="el" href="usb-keyboard_8c.html#a26">usb-keyboard.c</a><li>kbdUSBInit()
+: <a class="el" href="usb-keyboard_8h.html#a0">usb-keyboard.h</a>, <a class="el" href="usb-keyboard_8c.html#a21">usb-keyboard.c</a><li>kbdUSBOn()
+: <a class="el" href="usb-keyboard_8h.html#a2">usb-keyboard.h</a>, <a class="el" href="usb-keyboard_8c.html#a24">usb-keyboard.c</a><li>kbdUSBRead()
+: <a class="el" href="usb-keyboard_8c.html#a23">usb-keyboard.c</a></ul>
+<h3><a class="anchor" name="index_l">- l -</a></h3><ul>
+<li>LegalModifier()
+: <a class="el" href="dmxinput_8c.html#a0">dmxinput.c</a></ul>
+<h3><a class="anchor" name="index_m">- m -</a></h3><ul>
+<li>mouUSBGetInfo()
+: <a class="el" href="usb-mouse_8h.html#a2">usb-mouse.h</a>, <a class="el" href="usb-mouse_8c.html#a16">usb-mouse.c</a><li>mouUSBInit()
+: <a class="el" href="usb-mouse_8h.html#a1">usb-mouse.h</a>, <a class="el" href="usb-mouse_8c.html#a13">usb-mouse.c</a><li>mouUSBOn()
+: <a class="el" href="usb-mouse_8h.html#a3">usb-mouse.h</a>, <a class="el" href="usb-mouse_8c.html#a14">usb-mouse.c</a><li>mouUSBRead()
+: <a class="el" href="usb-mouse_8c.html#a12">usb-mouse.c</a><li>msLinuxCreatePrivate()
+: <a class="el" href="lnx-ms_8h.html#a0">lnx-ms.h</a>, <a class="el" href="lnx-ms_8c.html#a24">lnx-ms.c</a><li>msLinuxDestroyPrivate()
+: <a class="el" href="lnx-ms_8h.html#a1">lnx-ms.h</a>, <a class="el" href="lnx-ms_8c.html#a25">lnx-ms.c</a><li>msLinuxGetInfo()
+: <a class="el" href="lnx-ms_8h.html#a4">lnx-ms.h</a>, <a class="el" href="lnx-ms_8c.html#a26">lnx-ms.c</a><li>msLinuxInit()
+: <a class="el" href="lnx-ms_8h.html#a3">lnx-ms.h</a>, <a class="el" href="lnx-ms_8c.html#a18">lnx-ms.c</a><li>msLinuxOff()
+: <a class="el" href="lnx-ms_8h.html#a6">lnx-ms.h</a>, <a class="el" href="lnx-ms_8c.html#a20">lnx-ms.c</a><li>msLinuxOn()
+: <a class="el" href="lnx-ms_8h.html#a5">lnx-ms.h</a>, <a class="el" href="lnx-ms_8c.html#a19">lnx-ms.c</a><li>msLinuxRead()
+: <a class="el" href="lnx-ms_8c.html#a17">lnx-ms.c</a><li>msLinuxVTPostSwitch()
+: <a class="el" href="lnx-ms_8h.html#a9">lnx-ms.h</a>, <a class="el" href="lnx-ms_8c.html#a23">lnx-ms.c</a><li>msLinuxVTPreSwitch()
+: <a class="el" href="lnx-ms_8h.html#a8">lnx-ms.h</a>, <a class="el" href="lnx-ms_8c.html#a22">lnx-ms.c</a></ul>
+<h3><a class="anchor" name="index_o">- o -</a></h3><ul>
+<li>OpenInputDevice()
+: <a class="el" href="dmxxinput_8c.html#a5">dmxxinput.c</a><li>OsVendorFatalError()
+: <a class="el" href="dmxinit_8c.html#a39">dmxinit.c</a><li>OsVendorInit()
+: <a class="el" href="dmxinit_8c.html#a38">dmxinit.c</a><li>othUSBGetInfo()
+: <a class="el" href="usb-other_8h.html#a2">usb-other.h</a>, <a class="el" href="usb-other_8c.html#a16">usb-other.c</a><li>othUSBInit()
+: <a class="el" href="usb-other_8h.html#a1">usb-other.h</a>, <a class="el" href="usb-other_8c.html#a14">usb-other.c</a><li>othUSBOn()
+: <a class="el" href="usb-other_8h.html#a3">usb-other.h</a>, <a class="el" href="usb-other_8c.html#a15">usb-other.c</a><li>othUSBRead()
+: <a class="el" href="usb-other_8c.html#a13">usb-other.c</a></ul>
+<h3><a class="anchor" name="index_p">- p -</a></h3><ul>
+<li>ProcessInputEvents()
+: <a class="el" href="dmxinput_8c.html#a2">dmxinput.c</a><li>ps2LinuxCreatePrivate()
+: <a class="el" href="lnx-ps2_8h.html#a0">lnx-ps2.h</a>, <a class="el" href="lnx-ps2_8c.html#a24">lnx-ps2.c</a><li>ps2LinuxDestroyPrivate()
+: <a class="el" href="lnx-ps2_8h.html#a1">lnx-ps2.h</a>, <a class="el" href="lnx-ps2_8c.html#a25">lnx-ps2.c</a><li>ps2LinuxGetInfo()
+: <a class="el" href="lnx-ps2_8h.html#a4">lnx-ps2.h</a>, <a class="el" href="lnx-ps2_8c.html#a26">lnx-ps2.c</a><li>ps2LinuxInit()
+: <a class="el" href="lnx-ps2_8h.html#a3">lnx-ps2.h</a>, <a class="el" href="lnx-ps2_8c.html#a18">lnx-ps2.c</a><li>ps2LinuxOff()
+: <a class="el" href="lnx-ps2_8h.html#a6">lnx-ps2.h</a>, <a class="el" href="lnx-ps2_8c.html#a20">lnx-ps2.c</a><li>ps2LinuxOn()
+: <a class="el" href="lnx-ps2_8h.html#a5">lnx-ps2.h</a>, <a class="el" href="lnx-ps2_8c.html#a19">lnx-ps2.c</a><li>ps2LinuxRead()
+: <a class="el" href="lnx-ps2_8c.html#a17">lnx-ps2.c</a><li>ps2LinuxVTPostSwitch()
+: <a class="el" href="lnx-ps2_8h.html#a9">lnx-ps2.h</a>, <a class="el" href="lnx-ps2_8c.html#a23">lnx-ps2.c</a><li>ps2LinuxVTPreSwitch()
+: <a class="el" href="lnx-ps2_8h.html#a8">lnx-ps2.h</a>, <a class="el" href="lnx-ps2_8c.html#a22">lnx-ps2.c</a></ul>
+<h3><a class="anchor" name="index_s">- s -</a></h3><ul>
+<li>SetDeviceMode()
+: <a class="el" href="dmxxinput_8c.html#a6">dmxxinput.c</a><li>SetDeviceValuators()
+: <a class="el" href="dmxxinput_8c.html#a7">dmxxinput.c</a></ul>
+<h3><a class="anchor" name="index_u">- u -</a></h3><ul>
+<li>usbCreatePrivate()
+: <a class="el" href="usb-common_8h.html#a3">usb-common.h</a>, <a class="el" href="usb-common_8c.html#a25">usb-common.c</a><li>usbDestroyPrivate()
+: <a class="el" href="usb-common_8h.html#a4">usb-common.h</a>, <a class="el" href="usb-common_8c.html#a26">usb-common.c</a><li>usbInit()
+: <a class="el" href="usb-common_8h.html#a6">usb-common.h</a>, <a class="el" href="usb-common_8c.html#a23">usb-common.c</a><li>usbOff()
+: <a class="el" href="usb-common_8h.html#a7">usb-common.h</a>, <a class="el" href="usb-common_8c.html#a24">usb-common.c</a><li>usbRead()
+: <a class="el" href="usb-common_8c.html#a21">usb-common.c</a></ul>
+<h3><a class="anchor" name="index_x">- x -</a></h3><ul>
+<li>XCheckNotMaskEvent()
+: <a class="el" href="ChkNotMaskEv_8h.html#a0">ChkNotMaskEv.h</a>, <a class="el" href="ChkNotMaskEv_8c.html#a2">ChkNotMaskEv.c</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_type.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_type.html
new file mode 100644
index 000000000..e3aaeb4ca
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_type.html
@@ -0,0 +1,96 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindexHL" href="globals.html">Globals</a></div>
+<div class="qindex"><a class="qindex" href="globals.html">All</a> | <a class="qindex" href="globals_func.html">Functions</a> | <a class="qindex" href="globals_vars.html">Variables</a> | <a class="qindexHL" href="globals_type.html">Typedefs</a> | <a class="qindex" href="globals_enum.html">Enumerations</a> | <a class="qindex" href="globals_eval.html">Enumeration&nbsp;values</a> | <a class="qindex" href="globals_defs.html">Defines</a></div>
+<div class="qindex"><a class="qindex" href="#index_d">d</a> | <a class="qindex" href="#index_e">e</a> | <a class="qindex" href="#index_m">m</a></div>
+
+<p>
+
+<p>
+<h3><a class="anchor" name="index_d">- d -</a></h3><ul>
+<li>dmxColormapPrivPtr
+: <a class="el" href="dmxcmap_8h.html#a3">dmxcmap.h</a><li>dmxColormapPrivRec
+: <a class="el" href="dmxcmap_8h.html#a2">dmxcmap.h</a><li>DMXConfigCmd
+: <a class="el" href="dmxconfig_8c.html#a9">dmxconfig.c</a><li>DMXConfigCmdPtr
+: <a class="el" href="dmxconfig_8c.html#a10">dmxconfig.c</a><li>DMXConfigComment
+: <a class="el" href="dmxparse_8h.html#a8">dmxparse.h</a><li>DMXConfigCommentPtr
+: <a class="el" href="dmxparse_8h.html#a9">dmxparse.h</a><li>DMXConfigDisplay
+: <a class="el" href="dmxparse_8h.html#a14">dmxparse.h</a><li>DMXConfigDisplayPtr
+: <a class="el" href="dmxparse_8h.html#a15">dmxparse.h</a><li>DMXConfigEntry
+: <a class="el" href="dmxparse_8h.html#a26">dmxparse.h</a><li>DMXConfigEntryPtr
+: <a class="el" href="dmxparse_8h.html#a27">dmxparse.h</a><li>DMXConfigFullDim
+: <a class="el" href="dmxparse_8h.html#a12">dmxparse.h</a><li>DMXConfigFullDimPtr
+: <a class="el" href="dmxparse_8h.html#a13">dmxparse.h</a><li>DMXConfigList
+: <a class="el" href="dmxconfig_8c.html#a7">dmxconfig.c</a><li>DMXConfigListPtr
+: <a class="el" href="dmxconfig_8c.html#a8">dmxconfig.c</a><li>DMXConfigNumber
+: <a class="el" href="dmxparse_8h.html#a4">dmxparse.h</a><li>DMXConfigNumberPtr
+: <a class="el" href="dmxparse_8h.html#a5">dmxparse.h</a><li>DMXConfigOption
+: <a class="el" href="dmxparse_8h.html#a18">dmxparse.h</a><li>DMXConfigOptionPtr
+: <a class="el" href="dmxparse_8h.html#a19">dmxparse.h</a><li>DMXConfigPair
+: <a class="el" href="dmxparse_8h.html#a6">dmxparse.h</a><li>DMXConfigPairPtr
+: <a class="el" href="dmxparse_8h.html#a7">dmxparse.h</a><li>DMXConfigParam
+: <a class="el" href="dmxparse_8h.html#a20">dmxparse.h</a><li>DMXConfigParamPtr
+: <a class="el" href="dmxparse_8h.html#a21">dmxparse.h</a><li>DMXConfigPartDim
+: <a class="el" href="dmxparse_8h.html#a10">dmxparse.h</a><li>DMXConfigPartDimPtr
+: <a class="el" href="dmxparse_8h.html#a11">dmxparse.h</a><li>DMXConfigString
+: <a class="el" href="dmxparse_8h.html#a2">dmxparse.h</a><li>DMXConfigStringPtr
+: <a class="el" href="dmxparse_8h.html#a3">dmxparse.h</a><li>DMXConfigSub
+: <a class="el" href="dmxparse_8h.html#a22">dmxparse.h</a><li>DMXConfigSubPtr
+: <a class="el" href="dmxparse_8h.html#a23">dmxparse.h</a><li>DMXConfigToken
+: <a class="el" href="dmxparse_8h.html#a0">dmxparse.h</a><li>DMXConfigTokenPtr
+: <a class="el" href="dmxparse_8h.html#a1">dmxparse.h</a><li>DMXConfigVirtual
+: <a class="el" href="dmxparse_8h.html#a24">dmxparse.h</a><li>DMXConfigVirtualPtr
+: <a class="el" href="dmxparse_8h.html#a25">dmxparse.h</a><li>DMXConfigWall
+: <a class="el" href="dmxparse_8h.html#a16">dmxparse.h</a><li>DMXConfigWallPtr
+: <a class="el" href="dmxparse_8h.html#a17">dmxparse.h</a><li>dmxCursorPrivPtr
+: <a class="el" href="dmxcursor_8h.html#a2">dmxcursor.h</a><li>dmxCursorPrivRec
+: <a class="el" href="dmxcursor_8h.html#a1">dmxcursor.h</a><li>DMXEventMap
+: <a class="el" href="dmxinputinit_8h.html#a34">dmxinputinit.h</a><li>dmxFontPrivPtr
+: <a class="el" href="dmxfont_8h.html#a1">dmxfont.h</a><li>dmxFontPrivRec
+: <a class="el" href="dmxfont_8h.html#a0">dmxfont.h</a><li>dmxGCPrivPtr
+: <a class="el" href="dmxgc_8h.html#a4">dmxgc.h</a><li>dmxGCPrivRec
+: <a class="el" href="dmxgc_8h.html#a3">dmxgc.h</a><li>dmxGlyphPrivPtr
+: <a class="el" href="dmxpict_8h.html#a6">dmxpict.h</a><li>dmxGlyphPrivRec
+: <a class="el" href="dmxpict_8h.html#a5">dmxpict.h</a><li>DMXInputInfo
+: <a class="el" href="dmx_8h.html#a2">dmx.h</a><li>DMXLocalInitInfo
+: <a class="el" href="dmxinputinit_8h.html#a9">dmxinputinit.h</a><li>DMXLocalInitInfoPtr
+: <a class="el" href="dmxinputinit_8h.html#a10">dmxinputinit.h</a><li>DMXLocalInputInfoPtr
+: <a class="el" href="dmxinput_8h.html#a3">dmxinput.h</a><li>DMXLocalInputInfoRec
+: <a class="el" href="dmxinputinit_8h.html#a35">dmxinputinit.h</a><li>dmxPictPrivPtr
+: <a class="el" href="dmxpict_8h.html#a4">dmxpict.h</a><li>dmxPictPrivRec
+: <a class="el" href="dmxpict_8h.html#a3">dmxpict.h</a><li>dmxPixPrivPtr
+: <a class="el" href="dmxpixmap_8h.html#a2">dmxpixmap.h</a><li>dmxPixPrivRec
+: <a class="el" href="dmxpixmap_8h.html#a1">dmxpixmap.h</a><li>DMXScreenInfo
+: <a class="el" href="dmx_8h.html#a4">dmx.h</a><li>DMXStatAvg
+: <a class="el" href="dmxstat_8c.html#a0">dmxstat.c</a><li>DMXStatInfo
+: <a class="el" href="dmx_8h.html#a3">dmx.h</a><li>dmxWinPrivPtr
+: <a class="el" href="dmxwindow_8h.html#a9">dmxwindow.h</a><li>dmxWinPrivRec
+: <a class="el" href="dmxwindow_8h.html#a8">dmxwindow.h</a></ul>
+<h3><a class="anchor" name="index_e">- e -</a></h3><ul>
+<li>EventPtr
+: <a class="el" href="dmxeq_8c.html#a6">dmxeq.c</a><li>EventQueuePtr
+: <a class="el" href="dmxeq_8c.html#a8">dmxeq.c</a><li>EventQueueRec
+: <a class="el" href="dmxeq_8c.html#a7">dmxeq.c</a><li>EventRec
+: <a class="el" href="dmxeq_8c.html#a5">dmxeq.c</a></ul>
+<h3><a class="anchor" name="index_m">- m -</a></h3><ul>
+<li>myPrivate
+: <a class="el" href="dmxcommon_8c.html#a4">dmxcommon.c</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_vars.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_vars.html
new file mode 100644
index 000000000..c1c2d27c6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/globals_vars.html
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindexHL" href="globals.html">Globals</a></div>
+<div class="qindex"><a class="qindex" href="globals.html">All</a> | <a class="qindex" href="globals_func.html">Functions</a> | <a class="qindexHL" href="globals_vars.html">Variables</a> | <a class="qindex" href="globals_type.html">Typedefs</a> | <a class="qindex" href="globals_enum.html">Enumerations</a> | <a class="qindex" href="globals_eval.html">Enumeration&nbsp;values</a> | <a class="qindex" href="globals_defs.html">Defines</a></div>
+
+<p>
+<ul>
+<li>dmxAddRemoveScreens
+: <a class="el" href="dmxinit_8c.html#a17">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a18">dmx.h</a><li>dmxColormapPrivateIndex
+: <a class="el" href="dmxscrinit_8c.html#a6">dmxscrinit.c</a>, <a class="el" href="dmxcmap_8h.html#a4">dmxcmap.h</a><li>dmxDepth
+: <a class="el" href="dmxinit_8c.html#a13">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a14">dmx.h</a><li>dmxErrorOccurred
+: <a class="el" href="dmxinit_8c.html#a7">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a9">dmx.h</a><li>dmxFontPath
+: <a class="el" href="dmxinit_8c.html#a8">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a16">dmx.h</a><li>dmxFontPrivateIndex
+: <a class="el" href="dmxscrinit_8c.html#a4">dmxscrinit.c</a>, <a class="el" href="dmxfont_8h.html#a2">dmxfont.h</a><li>dmxGCPrivateIndex
+: <a class="el" href="dmxscrinit_8c.html#a2">dmxscrinit.c</a>, <a class="el" href="dmxgc_8h.html#a5">dmxgc.h</a><li>dmxGlobalHeight
+: <a class="el" href="dmxcb_8h.html#a1">dmxcb.h</a>, <a class="el" href="dmxcb_8c.html#a6">dmxcb.c</a><li>dmxGlobalWidth
+: <a class="el" href="dmxcb_8h.html#a0">dmxcb.h</a>, <a class="el" href="dmxcb_8c.html#a5">dmxcb.c</a><li>dmxGlyphSetPrivateIndex
+: <a class="el" href="dmxscrinit_8c.html#a8">dmxscrinit.c</a>, <a class="el" href="dmxpict_8h.html#a8">dmxpict.h</a><li>dmxIgnoreBadFontPaths
+: <a class="el" href="dmxinit_8c.html#a16">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a17">dmx.h</a><li>dmxInputs
+: <a class="el" href="dmxinput_8h.html#a5">dmxinput.h</a>, <a class="el" href="dmxinit_8c.html#a4">dmxinit.c</a><li>dmxLastErrorEvent
+: <a class="el" href="dmxinit_8c.html#a6">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a8">dmx.h</a><li>dmxLazyWindowCreation
+: <a class="el" href="dmxinit_8c.html#a11">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a12">dmx.h</a><li>dmxNoRender
+: <a class="el" href="dmxinit_8c.html#a14">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a15">dmx.h</a><li>dmxNumInputs
+: <a class="el" href="dmxinput_8h.html#a4">dmxinput.h</a>, <a class="el" href="dmxinit_8c.html#a3">dmxinit.c</a><li>dmxNumScreens
+: <a class="el" href="dmxinit_8c.html#a1">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a5">dmx.h</a><li>dmxOffScreenOpt
+: <a class="el" href="dmxinit_8c.html#a9">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a10">dmx.h</a><li>dmxPictPrivateIndex
+: <a class="el" href="dmxscrinit_8c.html#a7">dmxscrinit.c</a>, <a class="el" href="dmxpict_8h.html#a7">dmxpict.h</a><li>dmxPixPrivateIndex
+: <a class="el" href="dmxpixmap_8h.html#a3">dmxpixmap.h</a><li>dmxPointerCursorFuncs
+: <a class="el" href="dmxcursor_8h.html#a3">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a10">dmxcursor.c</a><li>dmxPointerSpriteFuncs
+: <a class="el" href="dmxcursor_8h.html#a4">dmxcursor.h</a>, <a class="el" href="dmxcursor_8c.html#a11">dmxcursor.c</a><li>dmxScreenPrivateIndex
+: <a class="el" href="dmxscrinit_8h.html#a0">dmxscrinit.h</a>, <a class="el" href="dmxscrinit_8c.html#a5">dmxscrinit.c</a><li>dmxScreens
+: <a class="el" href="dmxinit_8c.html#a2">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a6">dmx.h</a><li>dmxShadowFB
+: <a class="el" href="dmxinit_8c.html#a5">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a7">dmx.h</a><li>dmxStatInterval
+: <a class="el" href="dmxstat_8h.html#a5">dmxstat.h</a>, <a class="el" href="dmxstat_8c.html#a1">dmxstat.c</a><li>dmxSubdividePrimitives
+: <a class="el" href="dmxinit_8c.html#a10">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a11">dmx.h</a><li>dmxUseXKB
+: <a class="el" href="dmxinit_8c.html#a12">dmxinit.c</a>, <a class="el" href="dmx_8h.html#a13">dmx.h</a><li>dmxWinPrivateIndex
+: <a class="el" href="dmxwindow_8h.html#a10">dmxwindow.h</a>, <a class="el" href="dmxscrinit_8c.html#a3">dmxscrinit.c</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/index.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/index.html
new file mode 100644
index 000000000..722db1aa5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/index.html
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+<title>Distributed Multihead X</title></head>
+<frameset cols="250,*">
+ <frame src="tree.html" name="treefrm">
+ <frame src="main.html" name="basefrm">
+</frameset>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/lib_2dmx_2dmx_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/lib_2dmx_2dmx_8c.html
new file mode 100644
index 000000000..15bb74a1e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/lib_2dmx_2dmx_8c.html
@@ -0,0 +1,894 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmx.c File Reference</h1><code>#include &lt;X11/Xlibint.h&gt;</code><br>
+<code>#include "Xext.h"</code><br>
+<code>#include "extutil.h"</code><br>
+<code>#include "<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxext_8h-source.html">dmxext.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmx_extension_info Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a10">DMXQueryExtension</a> (Display *dpy, int *event_basep, int *error_basep)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a11">DMXQueryVersion</a> (Display *dpy, int *majorVersion, int *minorVersion, int *patchVersion)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a12">DMXSync</a> (Display *dpy)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a13">DMXForceWindowCreation</a> (Display *dpy, Window window)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a14">DMXGetScreenCount</a> (Display *dpy, int *screen_count)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a15">DMXGetScreenAttributes</a> (Display *dpy, int physical_screen, <a class="el" href="structDMXScreenAttributes.html">DMXScreenAttributes</a> *attr)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a20">DMXChangeScreensAttributes</a> (Display *dpy, int screen_count, int *screens, int mask_count, unsigned int *masks, <a class="el" href="structDMXScreenAttributes.html">DMXScreenAttributes</a> *attrs, int *error_screen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a21">DMXAddScreen</a> (Display *dpy, const char *displayName, unsigned int mask, <a class="el" href="structDMXScreenAttributes.html">DMXScreenAttributes</a> *attr, int *screen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a22">DMXRemoveScreen</a> (Display *dpy, int screen)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a23">DMXGetWindowAttributes</a> (Display *dpy, Window window, int *screen_count, int available_count, <a class="el" href="structDMXWindowAttributes.html">DMXWindowAttributes</a> *inf)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a24">DMXGetDesktopAttributes</a> (Display *dpy, <a class="el" href="structDMXDesktopAttributes.html">DMXDesktopAttributes</a> *attr)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a27">DMXChangeDesktopAttributes</a> (Display *dpy, unsigned int mask, <a class="el" href="structDMXDesktopAttributes.html">DMXDesktopAttributes</a> *attr)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a28">DMXGetInputCount</a> (Display *dpy, int *input_count)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a29">DMXGetInputAttributes</a> (Display *dpy, int id, <a class="el" href="structDMXInputAttributes.html">DMXInputAttributes</a> *inf)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a30">DMXAddInput</a> (Display *dpy, unsigned int mask, <a class="el" href="structDMXInputAttributes.html">DMXInputAttributes</a> *attr, int *id)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a31">DMXAddBackendInput</a> (Display *dpy, int screen, int sendsCore, int *newId)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a32">DMXAddConsoleInput</a> (Display *dpy, const char *name, int sendsCore, int *newId)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lib_2dmx_2dmx_8c.html#a33">DMXRemoveInput</a> (Display *dpy, int id)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file implements the client-side part of the DMX protocol. It can be included in client applications by linking with the libdmx.a library.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a31" doxytag="lib/dmx/dmx.c::DMXAddBackendInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXAddBackendInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>screen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>sendsCore</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>newId</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Add backend input (a helper function that calls <a class="el" href="lib_2dmx_2dmx_8c.html#a30">DMXAddInput</a>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a32" doxytag="lib/dmx/dmx.c::DMXAddConsoleInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXAddConsoleInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>name</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>sendsCore</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>newId</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Add console input (a helper function that calls <a class="el" href="lib_2dmx_2dmx_8c.html#a30">DMXAddInput</a>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a30" doxytag="lib/dmx/dmx.c::DMXAddInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXAddInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="structDMXInputAttributes.html">DMXInputAttributes</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>id</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Add input. </td>
+ </tr>
+</table>
+<a class="anchor" name="a21" doxytag="lib/dmx/dmx.c::DMXAddScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXAddScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>const char *&nbsp;</td>
+ <td class="mdname" nowrap> <em>displayName</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="structDMXScreenAttributes.html">DMXScreenAttributes</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>screen</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Add a screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a27" doxytag="lib/dmx/dmx.c::DMXChangeDesktopAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int DMXChangeDesktopAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="structDMXDesktopAttributes.html">DMXDesktopAttributes</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change the global bounding box and origin offset.<p>
+Available in DMX Protocol Version 2.0 </td>
+ </tr>
+</table>
+<a class="anchor" name="a20" doxytag="lib/dmx/dmx.c::DMXChangeScreensAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int DMXChangeScreensAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>screen_count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>screens</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>mask_count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>unsigned int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>masks</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="structDMXScreenAttributes.html">DMXScreenAttributes</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>attrs</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>error_screen</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Change geometries and positions of the DMX screen and root windows on the back-end X server. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="lib/dmx/dmx.c::DMXForceWindowCreation" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXForceWindowCreation </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Window&nbsp;</td>
+ <td class="mdname" nowrap> <em>window</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+The creation of the specified <em>window</em> will be forced.<p>
+Available in DMX Protocol Version 1.2 Reply added in DMX Protocol Version 2.0 </td>
+ </tr>
+</table>
+<a class="anchor" name="a24" doxytag="lib/dmx/dmx.c::DMXGetDesktopAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXGetDesktopAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="structDMXDesktopAttributes.html">DMXDesktopAttributes</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If the DMXGetDesktopAttributes protocol request returns information correctly, the information will be placed in <em>attr</em>, and True will be returned. Otherwise, False will be returned.<p>
+Available in DMX Protocol Version 2.0 </td>
+ </tr>
+</table>
+<a class="anchor" name="a29" doxytag="lib/dmx/dmx.c::DMXGetInputAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXGetInputAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>id</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="structDMXInputAttributes.html">DMXInputAttributes</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>inf</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If the DMXGetInputAttributes protocol request returns information about the input device with the specified <em>id</em>, information about the input device will be placed in <em>inf</em>, and True will be returned. Otherwise, False will be returned.<p>
+Available in DMX Protocol Version 1.1 </td>
+ </tr>
+</table>
+<a class="anchor" name="a28" doxytag="lib/dmx/dmx.c::DMXGetInputCount" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXGetInputCount </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>input_count</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If the DMXGetInputCount protocol request returns the input count, the value will be placed in <em>input_count</em>, and True will be returned. Otherwise, False will be returned.<p>
+Available in DMX Protocol Version 1.1 </td>
+ </tr>
+</table>
+<a class="anchor" name="a15" doxytag="lib/dmx/dmx.c::DMXGetScreenAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXGetScreenAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>physical_screen</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="structDMXScreenAttributes.html">DMXScreenAttributes</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>attr</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If the DMXGetScreenAttributes protocol request returns information for the specified <em>physical_screen</em>, information about the screen will be placed in <em>attr</em>, and True will be returned. Otherwise, False will be returned.<p>
+Available in DMX Protocol Version 1.0; Modified in Version 2.0 </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="lib/dmx/dmx.c::DMXGetScreenCount" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXGetScreenCount </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>screen_count</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If the DMXGetScreenCount protocol request returns the screen count, the value will be placed in <em>screen_count</em>, and True will be returned. Otherwise, False will be returned.<p>
+Available in DMX Protocol Version 1.0 </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="lib/dmx/dmx.c::DMXGetWindowAttributes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXGetWindowAttributes </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>Window&nbsp;</td>
+ <td class="mdname" nowrap> <em>window</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>screen_count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>available_count</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="structDMXWindowAttributes.html">DMXWindowAttributes</a> *&nbsp;</td>
+ <td class="mdname" nowrap> <em>inf</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If the DMXGetWindowAttributes protocol request returns information about the specified <em>window</em>, the number of screens for which information is available will be returned in <em>screen_count</em> and information about the first <em>available_count</em> of those screens will be placed in <em>inf</em>. Because this call transports a great deal of information over the wire, please call <a class="el" href="lib_2dmx_2dmx_8c.html#a14">DMXGetScreenCount</a> first, and make sure <em>inf</em> is that large.<p>
+Note that if the specified <em>window</em> has not yet been mapped when <a class="el" href="lib_2dmx_2dmx_8c.html#a23">DMXGetWindowAttributes</a> is called, then a subsequent XMapWindow call might be buffered in xlib while requests directly to the back-end X servers are processed. This race condition can be solved by calling <a class="el" href="lib_2dmx_2dmx_8c.html#a12">DMXSync</a> before talking directly to the back-end X servers.<p>
+Available in DMX Protocol Version 1.0, but not working correctly until DMX Protocol Version 1.4 </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="lib/dmx/dmx.c::DMXQueryExtension" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmx_extension_info Bool DMXQueryExtension </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>event_basep</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>error_basep</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If the server has the DMX extension, the event and error bases will be placed in <em>event_basep</em> and <em>error_basep</em>, and True will be returned. Otherwise, False will be returned.<p>
+Available in DMX Protocol Version 1.0 </td>
+ </tr>
+</table>
+<a class="anchor" name="a11" doxytag="lib/dmx/dmx.c::DMXQueryVersion" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXQueryVersion </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>majorVersion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>minorVersion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int *&nbsp;</td>
+ <td class="mdname" nowrap> <em>patchVersion</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If the DMXQueryVersion protocol request returns version information from the server, <em>majorVersion</em>, <em>minorVersion</em>, and <em>patchVersion</em> are filled in with the appropriate information and True is returned. Otherwise, False will be returned.<p>
+Available in DMX Protocol Version 1.0 </td>
+ </tr>
+</table>
+<a class="anchor" name="a33" doxytag="lib/dmx/dmx.c::DMXRemoveInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXRemoveInput </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>id</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Remove an input. </td>
+ </tr>
+</table>
+<a class="anchor" name="a22" doxytag="lib/dmx/dmx.c::DMXRemoveScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXRemoveScreen </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname" nowrap> <em>dpy</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>screen</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Remove a screen. </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="lib/dmx/dmx.c::DMXSync" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool DMXSync </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">Display *&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>dpy</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Flush all pending dmxSync requests in DMX server.<p>
+Available in DMX Protocol Version 1.5 </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-keyboard_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-keyboard_8c.html
new file mode 100644
index 000000000..e02182b73
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-keyboard_8c.html
@@ -0,0 +1,511 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>lnx-keyboard.c File Reference</h1><code>#include "<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>"</code><br>
+<code>#include "<a class="el" href="lnx-keyboard_8h-source.html">lnx-keyboard.h</a>"</code><br>
+<code>#include "inputstr.h"</code><br>
+<code>#include "Xos.h"</code><br>
+<code>#include &lt;sys/ioctl.h&gt;</code><br>
+<code>#include &lt;errno.h&gt;</code><br>
+<code>#include &lt;signal.h&gt;</code><br>
+<code>#include &lt;sys/vt.h&gt;</code><br>
+<code>#include &lt;sys/kd.h&gt;</code><br>
+<code>#include &lt;termios.h&gt;</code><br>
+<code>#include "atKeynames.h"</code><br>
+<code>#include "xf86Keymap.h"</code><br>
+<code>#include &lt;linux/keyboard.h&gt;</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html">_myPrivate</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>pointer&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8c.html#a24">kbdLinuxCreatePrivate</a> (DeviceIntPtr pKeyboard)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8c.html#a25">kbdLinuxDestroyPrivate</a> (pointer priv)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8c.html#a26">kbdLinuxBell</a> (DevicePtr pDev, int percent, int volume, int pitch, int duration)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8c.html#a27">kbdLinuxCtrl</a> (DevicePtr pDev, KeybdCtrl *ctrl)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8c.html#a32">kbdLinuxVTPreSwitch</a> (pointer p)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8c.html#a33">kbdLinuxVTPostSwitch</a> (pointer p)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8c.html#a34">kbdLinuxVTSwitch</a> (pointer p, int vt, void(*switch_return)(pointer), pointer switch_return_data)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8c.html#a38">kbdLinuxInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8c.html#a42">kbdLinuxRead</a> (DevicePtr pDev, MOTIONPROC motion, ENQUEUEPROC enqueue, CHECKPROC checkspecial, BLOCK block)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8c.html#a43">kbdLinuxOn</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8c.html#a44">kbdLinuxOff</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8c.html#a47">kbdLinuxGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This code implements a low-level device driver for the Linux keyboard. The code is derived from code by Thomas Roell, Orest Zborowski, and David Dawes (see the source code for complete references).<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a26" doxytag="lnx-keyboard.c::kbdLinuxBell" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxBell </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>percent</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>volume</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>pitch</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>duration</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Ring the bell.<p>
+Note: we completely ignore the <em>volume</em>, since Linux's ioctl() interface does not provide a way to control it. If it did, the XBell manpage tells how the actual volume is a function of the percent and the (base) volume.<p>
+Note that most of the other PC-based bell drivers compute the duration for KDMKTONE as a function of the volume and the duration. For some drivers, the duration is only measured in mS if the volume is 50, and is scaled by the volume for other values. This seems confusing and possibly incorrect (the xset man page says that the bell will be "as closely as it can to the user's specifications" -- if we ignore the volume and set the duration correctly, then we'll get one parameter "wrong" -- but if we use the volume to scale the duration, then we'll get both parameters "wrong"). </td>
+ </tr>
+</table>
+<a class="anchor" name="a24" doxytag="lnx-keyboard.c::kbdLinuxCreatePrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> pointer kbdLinuxCreatePrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pKeyboard</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a private structure for use within this file. </td>
+ </tr>
+</table>
+<a class="anchor" name="a27" doxytag="lnx-keyboard.c::kbdLinuxCtrl" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxCtrl </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>KeybdCtrl *&nbsp;</td>
+ <td class="mdname" nowrap> <em>ctrl</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set the LEDs. </td>
+ </tr>
+</table>
+<a class="anchor" name="a25" doxytag="lnx-keyboard.c::kbdLinuxDestroyPrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxDestroyPrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>priv</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy a private structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a47" doxytag="lnx-keyboard.c::kbdLinuxGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill the <em>info</em> structure with information needed to initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a38" doxytag="lnx-keyboard.c::kbdLinuxInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize the <em>pDev</em> as a Linux keyboard. </td>
+ </tr>
+</table>
+<a class="anchor" name="a44" doxytag="lnx-keyboard.c::kbdLinuxOff" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxOff </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> off (i.e., stop taking input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a43" doxytag="lnx-keyboard.c::kbdLinuxOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int kbdLinuxOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a42" doxytag="lnx-keyboard.c::kbdLinuxRead" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxRead </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>MOTIONPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>motion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>ENQUEUEPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>enqueue</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CHECKPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>checkspecial</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>BLOCK&nbsp;</td>
+ <td class="mdname" nowrap> <em>block</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Read an event from the <em>pDev</em> device. If the event is a motion event, enqueue it with the <em>motion</em> function. Otherwise, check for special keys with the <em>checkspecial</em> function and enqueue the event with the <em>enqueue</em> function. The <em>block</em> type is passed to the functions so that they may block SIGIO handling as appropriate to the caller of this function. </td>
+ </tr>
+</table>
+<a class="anchor" name="a33" doxytag="lnx-keyboard.c::kbdLinuxVTPostSwitch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxVTPostSwitch </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>p</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Currently unused hook called after returning from a VT switch. </td>
+ </tr>
+</table>
+<a class="anchor" name="a32" doxytag="lnx-keyboard.c::kbdLinuxVTPreSwitch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxVTPreSwitch </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>p</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Currently unused hook called prior to an VT switch. </td>
+ </tr>
+</table>
+<a class="anchor" name="a34" doxytag="lnx-keyboard.c::kbdLinuxVTSwitch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int kbdLinuxVTSwitch </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>p</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>vt</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>void(*&nbsp;</td>
+ <td class="mdname" nowrap> <em>switch_return</em>)(pointer), </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>pointer&nbsp;</td>
+ <td class="mdname" nowrap> <em>switch_return_data</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Tell the operating system to switch to <em>vt</em>. The <em>switch_return</em> function is called with the <em>switch_return_data</em> when the VT is switched back to the pre-switch VT (i.e., the user returns to the DMX session). </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-keyboard_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-keyboard_8h-source.html
new file mode 100644
index 000000000..20330c73a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-keyboard_8h-source.html
@@ -0,0 +1,83 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>lnx-keyboard.h</h1><a href="lnx-keyboard_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _LNX_KEYBOARD_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _LNX_KEYBOARD_H_</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="keyword">extern</span> pointer <a class="code" href="lnx-keyboard_8c.html#a24">kbdLinuxCreatePrivate</a>(DeviceIntPtr pKeyboard);
+00042 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-keyboard_8c.html#a25">kbdLinuxDestroyPrivate</a>(pointer <span class="keyword">private</span>);
+00043
+00044 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-keyboard_8c.html#a38">kbdLinuxInit</a>(DevicePtr pDev);
+00045 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-keyboard_8c.html#a47">kbdLinuxGetInfo</a>(DevicePtr pDev, <a class="code" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info);
+00046 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="lnx-keyboard_8c.html#a43">kbdLinuxOn</a>(DevicePtr pDev);
+00047 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-keyboard_8c.html#a44">kbdLinuxOff</a>(DevicePtr pDev);
+00048
+00049 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-keyboard_8c.html#a32">kbdLinuxVTPreSwitch</a>(pointer p);
+00050 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-keyboard_8c.html#a33">kbdLinuxVTPostSwitch</a>(pointer p);
+00051 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="lnx-keyboard_8c.html#a34">kbdLinuxVTSwitch</a>(pointer p, <span class="keywordtype">int</span> vt,
+00052 dmxVTSwitchReturnProcPtr switch_return,
+00053 pointer switch_return_data);
+00054
+00055 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-keyboard_8c.html#a42">kbdLinuxRead</a>(DevicePtr pDev,
+00056 dmxMotionProcPtr motion,
+00057 dmxEnqueueProcPtr enqueue,
+00058 dmxCheckSpecialProcPtr checkspecial,
+00059 DMXBlockType block);
+00060
+00061 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-keyboard_8c.html#a27">kbdLinuxCtrl</a>(DevicePtr pDev, KeybdCtrl *ctrl);
+00062 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-keyboard_8c.html#a26">kbdLinuxBell</a>(DevicePtr pDev, <span class="keywordtype">int</span> percent,
+00063 <span class="keywordtype">int</span> volume, <span class="keywordtype">int</span> pitch, <span class="keywordtype">int</span> duration);
+00064 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-keyboard_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-keyboard_8h.html
new file mode 100644
index 000000000..4811cad59
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-keyboard_8h.html
@@ -0,0 +1,388 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>lnx-keyboard.h File Reference</h1>
+<p>
+<a href="lnx-keyboard_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>pointer&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8h.html#a0">kbdLinuxCreatePrivate</a> (DeviceIntPtr pKeyboard)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8h.html#a1">kbdLinuxDestroyPrivate</a> (pointer private)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8h.html#a2">kbdLinuxInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8h.html#a3">kbdLinuxGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8h.html#a4">kbdLinuxOn</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8h.html#a5">kbdLinuxOff</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8h.html#a6">kbdLinuxVTPreSwitch</a> (pointer p)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8h.html#a7">kbdLinuxVTPostSwitch</a> (pointer p)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8h.html#a10">kbdLinuxCtrl</a> (DevicePtr pDev, KeybdCtrl *ctrl)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-keyboard_8h.html#a11">kbdLinuxBell</a> (DevicePtr pDev, int percent, int volume, int pitch, int duration)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to Linux keyboard driver. <dl compact><dt><b>See also:</b></dt><dd>lnx-keyboard.c</dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a11" doxytag="lnx-keyboard.h::kbdLinuxBell" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxBell </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>percent</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>volume</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>pitch</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>duration</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Ring the bell.<p>
+Note: we completely ignore the <em>volume</em>, since Linux's ioctl() interface does not provide a way to control it. If it did, the XBell manpage tells how the actual volume is a function of the percent and the (base) volume.<p>
+Note that most of the other PC-based bell drivers compute the duration for KDMKTONE as a function of the volume and the duration. For some drivers, the duration is only measured in mS if the volume is 50, and is scaled by the volume for other values. This seems confusing and possibly incorrect (the xset man page says that the bell will be "as closely as it can to the user's specifications" -- if we ignore the volume and set the duration correctly, then we'll get one parameter "wrong" -- but if we use the volume to scale the duration, then we'll get both parameters "wrong"). </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="lnx-keyboard.h::kbdLinuxCreatePrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> pointer kbdLinuxCreatePrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pKeyboard</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a private structure for use within this file. </td>
+ </tr>
+</table>
+<a class="anchor" name="a10" doxytag="lnx-keyboard.h::kbdLinuxCtrl" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxCtrl </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>KeybdCtrl *&nbsp;</td>
+ <td class="mdname" nowrap> <em>ctrl</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set the LEDs. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="lnx-keyboard.h::kbdLinuxDestroyPrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxDestroyPrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>priv</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy a private structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="lnx-keyboard.h::kbdLinuxGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill the <em>info</em> structure with information needed to initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="lnx-keyboard.h::kbdLinuxInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize the <em>pDev</em> as a Linux keyboard. </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="lnx-keyboard.h::kbdLinuxOff" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxOff </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> off (i.e., stop taking input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="lnx-keyboard.h::kbdLinuxOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int kbdLinuxOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="lnx-keyboard.h::kbdLinuxVTPostSwitch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxVTPostSwitch </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>p</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Currently unused hook called after returning from a VT switch. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="lnx-keyboard.h::kbdLinuxVTPreSwitch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdLinuxVTPreSwitch </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>p</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Currently unused hook called prior to an VT switch. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ms_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ms_8c.html
new file mode 100644
index 000000000..e77e562a4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ms_8c.html
@@ -0,0 +1,352 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>lnx-ms.c File Reference</h1><code>#include "inputstr.h"</code><br>
+<code>#include "Xos.h"</code><br>
+<code>#include &lt;errno.h&gt;</code><br>
+<code>#include &lt;termios.h&gt;</code><br>
+<code>#include "<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>"</code><br>
+<code>#include "<a class="el" href="lnx-ms_8h-source.html">lnx-ms.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html">_myPrivate</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8c.html#a17">msLinuxRead</a> (DevicePtr pDev, MOTIONPROC motion, ENQUEUEPROC enqueue, CHECKPROC checkspecial, BLOCK block)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8c.html#a18">msLinuxInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8c.html#a19">msLinuxOn</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8c.html#a20">msLinuxOff</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8c.html#a22">msLinuxVTPreSwitch</a> (pointer p)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8c.html#a23">msLinuxVTPostSwitch</a> (pointer p)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>pointer&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8c.html#a24">msLinuxCreatePrivate</a> (DeviceIntPtr pMouse)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8c.html#a25">msLinuxDestroyPrivate</a> (pointer priv)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8c.html#a26">msLinuxGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This code implements a low-level device driver for a serial MS mouse. The code is derived from code by Juliusz Chroboczek and Keith Packard (see the source code for complete references).<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a24" doxytag="lnx-ms.c::msLinuxCreatePrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> pointer msLinuxCreatePrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pMouse</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a private structure for use within this file. </td>
+ </tr>
+</table>
+<a class="anchor" name="a25" doxytag="lnx-ms.c::msLinuxDestroyPrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void msLinuxDestroyPrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>priv</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy a private structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a26" doxytag="lnx-ms.c::msLinuxGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void msLinuxGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill the <em>info</em> structure with information needed to initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a18" doxytag="lnx-ms.c::msLinuxInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void msLinuxInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a20" doxytag="lnx-ms.c::msLinuxOff" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void msLinuxOff </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> off (i.e., stop taking input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a19" doxytag="lnx-ms.c::msLinuxOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int msLinuxOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a17" doxytag="lnx-ms.c::msLinuxRead" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void msLinuxRead </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>MOTIONPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>motion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>ENQUEUEPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>enqueue</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CHECKPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>checkspecial</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>BLOCK&nbsp;</td>
+ <td class="mdname" nowrap> <em>block</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Read an event from the <em>pDev</em> device. If the event is a motion event, enqueue it with the <em>motion</em> function. Otherwise, check for special keys with the <em>checkspecial</em> function and enqueue the event with the <em>enqueue</em> function. The <em>block</em> type is passed to the functions so that they may block SIGIO handling as appropriate to the caller of this function. </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="lnx-ms.c::msLinuxVTPostSwitch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void msLinuxVTPostSwitch </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>p</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Currently unused hook called after returning from a VT switch. </td>
+ </tr>
+</table>
+<a class="anchor" name="a22" doxytag="lnx-ms.c::msLinuxVTPreSwitch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void msLinuxVTPreSwitch </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>p</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Currently unused hook called prior to an VT switch. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ms_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ms_8h-source.html
new file mode 100644
index 000000000..c900c32b2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ms_8h-source.html
@@ -0,0 +1,75 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>lnx-ms.h</h1><a href="lnx-ms_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _LNX_MS_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _LNX_MS_H_</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="keyword">extern</span> pointer <a class="code" href="lnx-ms_8c.html#a24">msLinuxCreatePrivate</a>(DeviceIntPtr pMouse);
+00042 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-ms_8c.html#a25">msLinuxDestroyPrivate</a>(pointer priv);
+00043 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-ms_8c.html#a17">msLinuxRead</a>(DevicePtr pDev,
+00044 dmxMotionProcPtr motion,
+00045 dmxEnqueueProcPtr enqueue,
+00046 dmxCheckSpecialProcPtr checkspecial,
+00047 DMXBlockType block);
+00048 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-ms_8c.html#a18">msLinuxInit</a>(DevicePtr pDev);
+00049 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-ms_8c.html#a26">msLinuxGetInfo</a>(DevicePtr pDev, <a class="code" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info);
+00050 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="lnx-ms_8c.html#a19">msLinuxOn</a>(DevicePtr pDev);
+00051 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-ms_8c.html#a20">msLinuxOff</a>(DevicePtr pDev);
+00052 <span class="keyword">extern</span> <span class="keywordtype">void</span> msLinuxCtrl(DevicePtr pDev, PtrCtrl *ctrl);
+00053 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-ms_8c.html#a22">msLinuxVTPreSwitch</a>(pointer p);
+00054 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-ms_8c.html#a23">msLinuxVTPostSwitch</a>(pointer p);
+00055
+00056 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ms_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ms_8h.html
new file mode 100644
index 000000000..3bd06c193
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ms_8h.html
@@ -0,0 +1,288 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>lnx-ms.h File Reference</h1>
+<p>
+<a href="lnx-ms_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>pointer&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8h.html#a0">msLinuxCreatePrivate</a> (DeviceIntPtr pMouse)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8h.html#a1">msLinuxDestroyPrivate</a> (pointer priv)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8h.html#a3">msLinuxInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8h.html#a4">msLinuxGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8h.html#a5">msLinuxOn</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8h.html#a6">msLinuxOff</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8h.html#a8">msLinuxVTPreSwitch</a> (pointer p)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ms_8h.html#a9">msLinuxVTPostSwitch</a> (pointer p)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to Linux MS mouse driver. <dl compact><dt><b>See also:</b></dt><dd>lnx-ms.c</dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a0" doxytag="lnx-ms.h::msLinuxCreatePrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> pointer msLinuxCreatePrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pMouse</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a private structure for use within this file. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="lnx-ms.h::msLinuxDestroyPrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void msLinuxDestroyPrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>priv</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy a private structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="lnx-ms.h::msLinuxGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void msLinuxGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill the <em>info</em> structure with information needed to initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="lnx-ms.h::msLinuxInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void msLinuxInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="lnx-ms.h::msLinuxOff" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void msLinuxOff </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> off (i.e., stop taking input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="lnx-ms.h::msLinuxOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int msLinuxOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="lnx-ms.h::msLinuxVTPostSwitch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void msLinuxVTPostSwitch </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>p</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Currently unused hook called after returning from a VT switch. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="lnx-ms.h::msLinuxVTPreSwitch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void msLinuxVTPreSwitch </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>p</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Currently unused hook called prior to an VT switch. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ps2_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ps2_8c.html
new file mode 100644
index 000000000..f0e44c742
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ps2_8c.html
@@ -0,0 +1,352 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>lnx-ps2.c File Reference</h1><code>#include "inputstr.h"</code><br>
+<code>#include "Xos.h"</code><br>
+<code>#include &lt;errno.h&gt;</code><br>
+<code>#include &lt;termios.h&gt;</code><br>
+<code>#include "<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>"</code><br>
+<code>#include "<a class="el" href="lnx-ps2_8h-source.html">lnx-ps2.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html">_myPrivate</a></td></tr>
+
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8c.html#a17">ps2LinuxRead</a> (DevicePtr pDev, MOTIONPROC motion, ENQUEUEPROC enqueue, CHECKPROC checkspecial, BLOCK block)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8c.html#a18">ps2LinuxInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8c.html#a19">ps2LinuxOn</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8c.html#a20">ps2LinuxOff</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8c.html#a22">ps2LinuxVTPreSwitch</a> (pointer p)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8c.html#a23">ps2LinuxVTPostSwitch</a> (pointer p)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>pointer&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8c.html#a24">ps2LinuxCreatePrivate</a> (DeviceIntPtr pMouse)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8c.html#a25">ps2LinuxDestroyPrivate</a> (pointer priv)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8c.html#a26">ps2LinuxGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This code implements a low-level device driver for a serial MS mouse. The code is derived from code by Keith Packard (see the source code for complete references).<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a24" doxytag="lnx-ps2.c::ps2LinuxCreatePrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> pointer ps2LinuxCreatePrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pMouse</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a private structure for use within this file. </td>
+ </tr>
+</table>
+<a class="anchor" name="a25" doxytag="lnx-ps2.c::ps2LinuxDestroyPrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void ps2LinuxDestroyPrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>priv</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy a private structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a26" doxytag="lnx-ps2.c::ps2LinuxGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void ps2LinuxGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill the <em>info</em> structure with information needed to initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a18" doxytag="lnx-ps2.c::ps2LinuxInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void ps2LinuxInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a20" doxytag="lnx-ps2.c::ps2LinuxOff" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void ps2LinuxOff </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> off (i.e., stop taking input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a19" doxytag="lnx-ps2.c::ps2LinuxOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int ps2LinuxOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a17" doxytag="lnx-ps2.c::ps2LinuxRead" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void ps2LinuxRead </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>MOTIONPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>motion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>ENQUEUEPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>enqueue</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CHECKPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>checkspecial</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>BLOCK&nbsp;</td>
+ <td class="mdname" nowrap> <em>block</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Read an event from the <em>pDev</em> device. If the event is a motion event, enqueue it with the <em>motion</em> function. Otherwise, check for special keys with the <em>checkspecial</em> function and enqueue the event with the <em>enqueue</em> function. The <em>block</em> type is passed to the functions so that they may block SIGIO handling as appropriate to the caller of this function. </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="lnx-ps2.c::ps2LinuxVTPostSwitch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void ps2LinuxVTPostSwitch </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>p</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Currently unused hook called after returning from a VT switch. </td>
+ </tr>
+</table>
+<a class="anchor" name="a22" doxytag="lnx-ps2.c::ps2LinuxVTPreSwitch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void ps2LinuxVTPreSwitch </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>p</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Currently unused hook called prior to an VT switch. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ps2_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ps2_8h-source.html
new file mode 100644
index 000000000..f4f76a04e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ps2_8h-source.html
@@ -0,0 +1,75 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>lnx-ps2.h</h1><a href="lnx-ps2_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2001 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _LNX_PS2_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _LNX_PS2_H_</span>
+00040 <span class="preprocessor"></span>
+00041 <span class="keyword">extern</span> pointer <a class="code" href="lnx-ps2_8c.html#a24">ps2LinuxCreatePrivate</a>(DeviceIntPtr pMouse);
+00042 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-ps2_8c.html#a25">ps2LinuxDestroyPrivate</a>(pointer priv);
+00043 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-ps2_8c.html#a17">ps2LinuxRead</a>(DevicePtr pDev,
+00044 dmxMotionProcPtr motion,
+00045 dmxEnqueueProcPtr enqueue,
+00046 dmxCheckSpecialProcPtr checkspecial,
+00047 DMXBlockType block);
+00048 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-ps2_8c.html#a18">ps2LinuxInit</a>(DevicePtr pDev);
+00049 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-ps2_8c.html#a26">ps2LinuxGetInfo</a>(DevicePtr pDev, <a class="code" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info);
+00050 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="lnx-ps2_8c.html#a19">ps2LinuxOn</a>(DevicePtr pDev);
+00051 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-ps2_8c.html#a20">ps2LinuxOff</a>(DevicePtr pDev);
+00052 <span class="keyword">extern</span> <span class="keywordtype">void</span> ps2LinuxCtrl(DevicePtr pDev, PtrCtrl *ctrl);
+00053 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-ps2_8c.html#a22">ps2LinuxVTPreSwitch</a>(pointer p);
+00054 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="lnx-ps2_8c.html#a23">ps2LinuxVTPostSwitch</a>(pointer p);
+00055
+00056 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ps2_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ps2_8h.html
new file mode 100644
index 000000000..2723f9c60
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ps2_8h.html
@@ -0,0 +1,288 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>lnx-ps2.h File Reference</h1>
+<p>
+<a href="lnx-ps2_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>pointer&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8h.html#a0">ps2LinuxCreatePrivate</a> (DeviceIntPtr pMouse)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8h.html#a1">ps2LinuxDestroyPrivate</a> (pointer priv)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8h.html#a3">ps2LinuxInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8h.html#a4">ps2LinuxGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8h.html#a5">ps2LinuxOn</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8h.html#a6">ps2LinuxOff</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8h.html#a8">ps2LinuxVTPreSwitch</a> (pointer p)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="lnx-ps2_8h.html#a9">ps2LinuxVTPostSwitch</a> (pointer p)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to Linux PS/2 mouse driver. <dl compact><dt><b>See also:</b></dt><dd>lnx-ps2.c</dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a0" doxytag="lnx-ps2.h::ps2LinuxCreatePrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> pointer ps2LinuxCreatePrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pMouse</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a private structure for use within this file. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="lnx-ps2.h::ps2LinuxDestroyPrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void ps2LinuxDestroyPrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>priv</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy a private structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="lnx-ps2.h::ps2LinuxGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void ps2LinuxGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill the <em>info</em> structure with information needed to initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="lnx-ps2.h::ps2LinuxInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void ps2LinuxInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="lnx-ps2.h::ps2LinuxOff" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void ps2LinuxOff </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> off (i.e., stop taking input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a5" doxytag="lnx-ps2.h::ps2LinuxOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int ps2LinuxOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a9" doxytag="lnx-ps2.h::ps2LinuxVTPostSwitch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void ps2LinuxVTPostSwitch </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>p</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Currently unused hook called after returning from a VT switch. </td>
+ </tr>
+</table>
+<a class="anchor" name="a8" doxytag="lnx-ps2.h::ps2LinuxVTPreSwitch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void ps2LinuxVTPreSwitch </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>p</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Currently unused hook called prior to an VT switch. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/main.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/main.html
new file mode 100644
index 000000000..86ee52bea
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/main.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindexHL" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>Distributed Multihead X Documentation</h1>
+<p>
+<h3 align="center">dmx-1-2-20040604 and later </h3><ul>
+<li><a href="http://dmx.sourceforge.net">DMX Home Page</a></li><li><a href="http://sourceforge.net/projects/dmx">DMX Project Page (on Source Forge)</a></li><li><a href="http://dmx.sourceforge.net/dmx.html">Distributed Multihead X design</a>, the design document for DMX</li><li><a href="http://dmx.sourceforge.net/DMXSpec.txt">Client-to-Server DMX Extension to the X Protocol</a> </li></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/programs_2Xserver_2Xext_2dmx_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/programs_2Xserver_2Xext_2dmx_8c.html
new file mode 100644
index 000000000..d9fefed76
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/programs_2Xserver_2Xext_2dmx_8c.html
@@ -0,0 +1,71 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmx.c File Reference</h1><code>#include "X.h"</code><br>
+<code>#include "Xproto.h"</code><br>
+<code>#include "misc.h"</code><br>
+<code>#include "os.h"</code><br>
+<code>#include "dixstruct.h"</code><br>
+<code>#include "extnsionst.h"</code><br>
+<code>#include "opaque.h"</code><br>
+<code>#include "<a class="el" href="dmxextension_8h-source.html">dmxextension.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxext_8h-source.html">dmxext.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="programs_2Xserver_2Xext_2dmx_8c.html#a3">DMXExtensionInit</a> (void)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This file implements the server-side part of the DMX protocol. A vector of fucntions is provided at extension initialization time, so most all of the useful functions in this file are declared static and do not appear in the doxygen documentation.<p>
+Much of the low-level work is done by functions in #dmxextension.c<p>
+Please see the Client-to-Server DMX Extension to the X Protocol document for details about the protocol.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a3" doxytag="programs/Xserver/Xext/dmx.c::DMXExtensionInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void DMXExtensionInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">void&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize the extension. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXConfigCmdStruct.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXConfigCmdStruct.html
new file mode 100644
index 000000000..5e1929147
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXConfigCmdStruct.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>DMXConfigCmdStruct Struct Reference</h1><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This stucture stores the parsed configuration information.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxconfig_8c.html">dmxconfig.c</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXConfigListStruct.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXConfigListStruct.html
new file mode 100644
index 000000000..ca55fcce3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXConfigListStruct.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>DMXConfigListStruct Struct Reference</h1><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores lists of configuration information.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxconfig_8c.html">dmxconfig.c</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXDesktopAttributes.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXDesktopAttributes.html
new file mode 100644
index 000000000..ed10c039b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXDesktopAttributes.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>DMXDesktopAttributes Struct Reference</h1><code>#include &lt;<a class="el" href="dmxext_8h-source.html">dmxext.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Client-library desktop information structure, returned by <a class="el" href="lib_2dmx_2dmx_8c.html#a24">DMXGetDesktopAttributes</a>.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxext_8h-source.html">dmxext.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXDesktopAttributesRec.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXDesktopAttributesRec.html
new file mode 100644
index 000000000..ea37ca26d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXDesktopAttributesRec.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>DMXDesktopAttributesRec Struct Reference</h1><code>#include &lt;<a class="el" href="dmxextension_8h-source.html">dmxextension.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Desktop attributes. Used by #ProcDMXGetDesktopAttributes and #ProcDMXChangeDesktopAttributes.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxextension_8h-source.html">dmxextension.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXInputAttributes.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXInputAttributes.html
new file mode 100644
index 000000000..6573b9efc
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXInputAttributes.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>DMXInputAttributes Struct Reference</h1><code>#include &lt;<a class="el" href="dmxext_8h-source.html">dmxext.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Client-library input information structure, returned by <a class="el" href="lib_2dmx_2dmx_8c.html#a29">DMXGetInputAttributes</a>.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxext_8h-source.html">dmxext.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXInputAttributesRec.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXInputAttributesRec.html
new file mode 100644
index 000000000..9e5ee05cf
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXInputAttributesRec.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>DMXInputAttributesRec Struct Reference</h1><code>#include &lt;<a class="el" href="dmxextension_8h-source.html">dmxextension.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Input attributes. Used by #ProcDMXGetInputAttributes.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxextension_8h-source.html">dmxextension.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXScreenAttributes.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXScreenAttributes.html
new file mode 100644
index 000000000..708d4c3cf
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXScreenAttributes.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>DMXScreenAttributes Struct Reference</h1><code>#include &lt;<a class="el" href="dmxext_8h-source.html">dmxext.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Client-library screen information structure, returned by <a class="el" href="lib_2dmx_2dmx_8c.html#a15">DMXGetScreenAttributes</a>.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxext_8h-source.html">dmxext.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXScreenAttributesRec.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXScreenAttributesRec.html
new file mode 100644
index 000000000..595b4aee6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXScreenAttributesRec.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>DMXScreenAttributesRec Struct Reference</h1><code>#include &lt;<a class="el" href="dmxextension_8h-source.html">dmxextension.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Screen attributes. Used by #ProcDMXGetScreenAttributes and #ProcDMXChangeScreenAttributes.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxextension_8h-source.html">dmxextension.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXWindowAttributes.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXWindowAttributes.html
new file mode 100644
index 000000000..18c427819
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXWindowAttributes.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>DMXWindowAttributes Struct Reference</h1><code>#include &lt;<a class="el" href="dmxext_8h-source.html">dmxext.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Client-library window information structure, returned by <a class="el" href="lib_2dmx_2dmx_8c.html#a23">DMXGetWindowAttributes</a>.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxext_8h-source.html">dmxext.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXWindowAttributesRec.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXWindowAttributesRec.html
new file mode 100644
index 000000000..a18b883e6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXWindowAttributesRec.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>DMXWindowAttributesRec Struct Reference</h1><code>#include &lt;<a class="el" href="dmxextension_8h-source.html">dmxextension.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Window attributes. Used by #ProcDMXGetWidowAttributes.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxextension_8h-source.html">dmxextension.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigComment.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigComment.html
new file mode 100644
index 000000000..be011e397
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigComment.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXConfigComment Struct Reference</h1><code>#include &lt;<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores parsed comments not stored with a token.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxparse_8h-source.html">dmxparse.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigDisplay.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigDisplay.html
new file mode 100644
index 000000000..53310fb7a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigDisplay.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXConfigDisplay Struct Reference</h1><code>#include &lt;<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores parsed display information.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxparse_8h-source.html">dmxparse.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigEntry.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigEntry.html
new file mode 100644
index 000000000..644098698
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigEntry.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXConfigEntry Struct Reference</h1><code>#include &lt;<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Heads entry storage.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxparse_8h-source.html">dmxparse.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigFullDim.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigFullDim.html
new file mode 100644
index 000000000..2e564ce87
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigFullDim.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXConfigFullDim Struct Reference</h1><code>#include &lt;<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores a pair of geometry specifications.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxparse_8h-source.html">dmxparse.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigNumber.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigNumber.html
new file mode 100644
index 000000000..f60e11c63
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigNumber.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXConfigNumber Struct Reference</h1><code>#include &lt;<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores parsed numbers.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxparse_8h-source.html">dmxparse.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigOption.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigOption.html
new file mode 100644
index 000000000..1ae073674
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigOption.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXConfigOption Struct Reference</h1><code>#include &lt;<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores parsed option information.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxparse_8h-source.html">dmxparse.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigPair.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigPair.html
new file mode 100644
index 000000000..bd0454be6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigPair.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXConfigPair Struct Reference</h1><code>#include &lt;<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores parsed pairs (e.g., x y)
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxparse_8h-source.html">dmxparse.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigParam.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigParam.html
new file mode 100644
index 000000000..90f017e20
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigParam.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXConfigParam Struct Reference</h1><code>#include &lt;<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores parsed param information.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxparse_8h-source.html">dmxparse.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigPartDim.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigPartDim.html
new file mode 100644
index 000000000..07f4c7757
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigPartDim.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXConfigPartDim Struct Reference</h1><code>#include &lt;<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores a geometry specification.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxparse_8h-source.html">dmxparse.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigString.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigString.html
new file mode 100644
index 000000000..a70f1a51a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigString.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXConfigString Struct Reference</h1><code>#include &lt;<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores parsed strings.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxparse_8h-source.html">dmxparse.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigSub.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigSub.html
new file mode 100644
index 000000000..a27630540
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigSub.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXConfigSub Struct Reference</h1><code>#include &lt;<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores options under an entry (subentry).
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxparse_8h-source.html">dmxparse.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigToken.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigToken.html
new file mode 100644
index 000000000..a7705deb9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigToken.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXConfigToken Struct Reference</h1><code>#include &lt;<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores tokens not stored in other structures (e.g., keywords and ;)
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxparse_8h-source.html">dmxparse.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigVirtual.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigVirtual.html
new file mode 100644
index 000000000..d221fa816
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigVirtual.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXConfigVirtual Struct Reference</h1><code>#include &lt;<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores parsed virtual information.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxparse_8h-source.html">dmxparse.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigWall.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigWall.html
new file mode 100644
index 000000000..fcb27db04
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigWall.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXConfigWall Struct Reference</h1><code>#include &lt;<a class="el" href="dmxparse_8h-source.html">dmxparse.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores parsed wall information.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxparse_8h-source.html">dmxparse.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXEventMap.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXEventMap.html
new file mode 100644
index 000000000..41ae5b368
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXEventMap.html
@@ -0,0 +1,82 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXEventMap Struct Reference</h1><code>#include &lt;<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXEventMap.html#o0">remote</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXEventMap.html#o1">server</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores a mapping between the device id on the remote X server and the id on the DMX server
+<p>
+<hr><h2>Field Documentation</h2>
+<a class="anchor" name="o0" doxytag="_DMXEventMap::remote" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXEventMap.html#o0">_DMXEventMap::remote</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Event number on remote X server </td>
+ </tr>
+</table>
+<a class="anchor" name="o1" doxytag="_DMXEventMap::server" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXEventMap.html#o1">_DMXEventMap::server</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Event number (unbiased) on DMX server </td>
+ </tr>
+</table>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXInputInfo.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXInputInfo.html
new file mode 100644
index 000000000..a89e01f5b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXInputInfo.html
@@ -0,0 +1,490 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXInputInfo Struct Reference</h1><code>#include &lt;<a class="el" href="dmxinput_8h-source.html">dmxinput.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>const char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o0">name</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o1">freename</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o2">detached</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o3">inputIdx</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o4">scrnIdx</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o5">core</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o6">console</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o7">windows</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="dmxinput_8h.html#a31">dmxSigioState</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o10">sigioState</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o11">sigioFdCount</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o12">sigioFd</a> [DMX_MAX_SIGIO_FDS]</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o13">sigioAdded</a> [DMX_MAX_SIGIO_FDS]</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o14">vt_switch_pending</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o15">vt_switched</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o16">numDevs</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o17">devs</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o18">keycodes</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o19">symbols</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXInputInfo.html#o20">geometry</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+DMXInputInfo is typedef'd in #dmx.h so that all routines can have access to the global pointers. However, the elements are only available to input-related routines.
+<p>
+<hr><h2>Field Documentation</h2>
+<a class="anchor" name="o6" doxytag="_DMXInputInfo::console" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="struct__DMXInputInfo.html#o6">_DMXInputInfo::console</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if console and backend input share the same backend display </td>
+ </tr>
+</table>
+<a class="anchor" name="o5" doxytag="_DMXInputInfo::core" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="struct__DMXInputInfo.html#o5">_DMXInputInfo::core</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If True, initialize these devices as devices that send core events </td>
+ </tr>
+</table>
+<a class="anchor" name="o2" doxytag="_DMXInputInfo::detached" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="struct__DMXInputInfo.html#o2">_DMXInputInfo::detached</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If true, input screen is detached </td>
+ </tr>
+</table>
+<a class="anchor" name="o17" doxytag="_DMXInputInfo::devs" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__DMXLocalInputInfo.html">DMXLocalInputInfoPtr</a>* <a class="el" href="struct__DMXInputInfo.html#o17">_DMXInputInfo::devs</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+List of actual input devices. Each _DMXInputInfo structure can refer to more than one device. For example, the keyboard and the pointer of a backend display; or all of the XInput extension devices on a backend display. </td>
+ </tr>
+</table>
+<a class="anchor" name="o1" doxytag="_DMXInputInfo::freename" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="struct__DMXInputInfo.html#o1">_DMXInputInfo::freename</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If true, free name on destroy </td>
+ </tr>
+</table>
+<a class="anchor" name="o20" doxytag="_DMXInputInfo::geometry" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> char* <a class="el" href="struct__DMXInputInfo.html#o20">_DMXInputInfo::geometry</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+XKB geometry from command line </td>
+ </tr>
+</table>
+<a class="anchor" name="o3" doxytag="_DMXInputInfo::inputIdx" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXInputInfo.html#o3">_DMXInputInfo::inputIdx</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Index into <a class="el" href="dmxinput_8h.html#a5">dmxInputs</a> global </td>
+ </tr>
+</table>
+<a class="anchor" name="o18" doxytag="_DMXInputInfo::keycodes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> char* <a class="el" href="struct__DMXInputInfo.html#o18">_DMXInputInfo::keycodes</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+XKB keycodes from command line </td>
+ </tr>
+</table>
+<a class="anchor" name="o0" doxytag="_DMXInputInfo::name" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> const char* <a class="el" href="struct__DMXInputInfo.html#o0">_DMXInputInfo::name</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Name of input display or device (from command line or config file) </td>
+ </tr>
+</table>
+<a class="anchor" name="o16" doxytag="_DMXInputInfo::numDevs" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXInputInfo.html#o16">_DMXInputInfo::numDevs</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Number of devices handled in this _DMXInputInfo structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="o4" doxytag="_DMXInputInfo::scrnIdx" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXInputInfo.html#o4">_DMXInputInfo::scrnIdx</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Index into <a class="el" href="dmxinit_8c.html#a2">dmxScreens</a> global </td>
+ </tr>
+</table>
+<a class="anchor" name="o13" doxytag="_DMXInputInfo::sigioAdded" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="struct__DMXInputInfo.html#o13">_DMXInputInfo::sigioAdded</a>[DMX_MAX_SIGIO_FDS]
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Active fds </td>
+ </tr>
+</table>
+<a class="anchor" name="o12" doxytag="_DMXInputInfo::sigioFd" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXInputInfo.html#o12">_DMXInputInfo::sigioFd</a>[DMX_MAX_SIGIO_FDS]
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+List of fds </td>
+ </tr>
+</table>
+<a class="anchor" name="o11" doxytag="_DMXInputInfo::sigioFdCount" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXInputInfo.html#o11">_DMXInputInfo::sigioFdCount</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Number of fds in use </td>
+ </tr>
+</table>
+<a class="anchor" name="o10" doxytag="_DMXInputInfo::sigioState" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="dmxinput_8h.html#a31">dmxSigioState</a> <a class="el" href="struct__DMXInputInfo.html#o10">_DMXInputInfo::sigioState</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Current stat </td>
+ </tr>
+</table>
+<a class="anchor" name="o19" doxytag="_DMXInputInfo::symbols" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> char* <a class="el" href="struct__DMXInputInfo.html#o19">_DMXInputInfo::symbols</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+XKB symbols from command line </td>
+ </tr>
+</table>
+<a class="anchor" name="o14" doxytag="_DMXInputInfo::vt_switch_pending" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXInputInfo.html#o14">_DMXInputInfo::vt_switch_pending</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if a VT switch is pending, but has not yet happened. </td>
+ </tr>
+</table>
+<a class="anchor" name="o15" doxytag="_DMXInputInfo::vt_switched" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXInputInfo.html#o15">_DMXInputInfo::vt_switched</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if a VT switch has happened. </td>
+ </tr>
+</table>
+<a class="anchor" name="o7" doxytag="_DMXInputInfo::windows" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="struct__DMXInputInfo.html#o7">_DMXInputInfo::windows</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if window outlines are draw in console </td>
+ </tr>
+</table>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxinput_8h-source.html">dmxinput.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXLocalInitInfo.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXLocalInitInfo.html
new file mode 100644
index 000000000..73b3e3ba6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXLocalInitInfo.html
@@ -0,0 +1,778 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXLocalInitInfo Struct Reference</h1><code>#include &lt;<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o0">keyboard</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o1">keyClass</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>KeySymsRec&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o2">keySyms</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o3">freemap</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>CARD8&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o4">modMap</a> [MAP_LENGTH]</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>XkbDescPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o5">xkb</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>XkbComponentNamesRec&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o6">names</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o7">freenames</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o8">force</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o9">buttonClass</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o10">numButtons</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>unsigned char&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o11">map</a> [DMX_MAX_BUTTONS]</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o12">valuatorClass</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o13">numRelAxes</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o14">numAbsAxes</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o15">minval</a> [DMX_MAX_AXES]</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o16">maxval</a> [DMX_MAX_AXES]</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o17">res</a> [DMX_MAX_AXES]</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o18">minres</a> [DMX_MAX_AXES]</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o19">maxres</a> [DMX_MAX_AXES]</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o20">focusClass</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o21">proximityClass</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o22">kbdFeedbackClass</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o23">ptrFeedbackClass</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o24">ledFeedbackClass</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o25">belFeedbackClass</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o26">intFeedbackClass</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o27">strFeedbackClass</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o28">maxSymbols</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o29">maxSymbolsSupported</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>KeySym *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInitInfo.html#o30">symbols</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores information from low-level device that is used to initialize the device at the dix level.
+<p>
+<hr><h2>Field Documentation</h2>
+<a class="anchor" name="o25" doxytag="_DMXLocalInitInfo::belFeedbackClass" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o25">_DMXLocalInitInfo::belFeedbackClass</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if device has a bell </td>
+ </tr>
+</table>
+<a class="anchor" name="o9" doxytag="_DMXLocalInitInfo::buttonClass" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o9">_DMXLocalInitInfo::buttonClass</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if buttons are present </td>
+ </tr>
+</table>
+<a class="anchor" name="o20" doxytag="_DMXLocalInitInfo::focusClass" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o20">_DMXLocalInitInfo::focusClass</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if device can cause focus </td>
+ </tr>
+</table>
+<a class="anchor" name="o8" doxytag="_DMXLocalInitInfo::force" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o8">_DMXLocalInitInfo::force</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Do not allow command line override </td>
+ </tr>
+</table>
+<a class="anchor" name="o3" doxytag="_DMXLocalInitInfo::freemap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o3">_DMXLocalInitInfo::freemap</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+If non-zero, free keySyms.map </td>
+ </tr>
+</table>
+<a class="anchor" name="o7" doxytag="_DMXLocalInitInfo::freenames" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o7">_DMXLocalInitInfo::freenames</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if names should be free'd </td>
+ </tr>
+</table>
+<a class="anchor" name="o26" doxytag="_DMXLocalInitInfo::intFeedbackClass" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o26">_DMXLocalInitInfo::intFeedbackClass</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if device has integer feedback </td>
+ </tr>
+</table>
+<a class="anchor" name="o22" doxytag="_DMXLocalInitInfo::kbdFeedbackClass" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o22">_DMXLocalInitInfo::kbdFeedbackClass</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if device has keyboard feedback </td>
+ </tr>
+</table>
+<a class="anchor" name="o0" doxytag="_DMXLocalInitInfo::keyboard" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o0">_DMXLocalInitInfo::keyboard</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if the device is a keyboard </td>
+ </tr>
+</table>
+<a class="anchor" name="o1" doxytag="_DMXLocalInitInfo::keyClass" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o1">_DMXLocalInitInfo::keyClass</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if keys are present </td>
+ </tr>
+</table>
+<a class="anchor" name="o2" doxytag="_DMXLocalInitInfo::keySyms" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> KeySymsRec <a class="el" href="struct__DMXLocalInitInfo.html#o2">_DMXLocalInitInfo::keySyms</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Key symbols </td>
+ </tr>
+</table>
+<a class="anchor" name="o24" doxytag="_DMXLocalInitInfo::ledFeedbackClass" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o24">_DMXLocalInitInfo::ledFeedbackClass</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if device has LED indicators </td>
+ </tr>
+</table>
+<a class="anchor" name="o11" doxytag="_DMXLocalInitInfo::map" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> unsigned char <a class="el" href="struct__DMXLocalInitInfo.html#o11">_DMXLocalInitInfo::map</a>[DMX_MAX_BUTTONS]
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Button map </td>
+ </tr>
+</table>
+<a class="anchor" name="o19" doxytag="_DMXLocalInitInfo::maxres" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o19">_DMXLocalInitInfo::maxres</a>[DMX_MAX_AXES]
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Maximum resolutions </td>
+ </tr>
+</table>
+<a class="anchor" name="o28" doxytag="_DMXLocalInitInfo::maxSymbols" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o28">_DMXLocalInitInfo::maxSymbols</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Maximum symbols </td>
+ </tr>
+</table>
+<a class="anchor" name="o29" doxytag="_DMXLocalInitInfo::maxSymbolsSupported" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o29">_DMXLocalInitInfo::maxSymbolsSupported</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Maximum symbols supported </td>
+ </tr>
+</table>
+<a class="anchor" name="o16" doxytag="_DMXLocalInitInfo::maxval" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o16">_DMXLocalInitInfo::maxval</a>[DMX_MAX_AXES]
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Maximum values </td>
+ </tr>
+</table>
+<a class="anchor" name="o18" doxytag="_DMXLocalInitInfo::minres" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o18">_DMXLocalInitInfo::minres</a>[DMX_MAX_AXES]
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Minimum resolutions </td>
+ </tr>
+</table>
+<a class="anchor" name="o15" doxytag="_DMXLocalInitInfo::minval" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o15">_DMXLocalInitInfo::minval</a>[DMX_MAX_AXES]
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Minimum values </td>
+ </tr>
+</table>
+<a class="anchor" name="o4" doxytag="_DMXLocalInitInfo::modMap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> CARD8 <a class="el" href="struct__DMXLocalInitInfo.html#o4">_DMXLocalInitInfo::modMap</a>[MAP_LENGTH]
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Modifier map </td>
+ </tr>
+</table>
+<a class="anchor" name="o6" doxytag="_DMXLocalInitInfo::names" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> XkbComponentNamesRec <a class="el" href="struct__DMXLocalInitInfo.html#o6">_DMXLocalInitInfo::names</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+XKB component names </td>
+ </tr>
+</table>
+<a class="anchor" name="o14" doxytag="_DMXLocalInitInfo::numAbsAxes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o14">_DMXLocalInitInfo::numAbsAxes</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Number of absolute axes </td>
+ </tr>
+</table>
+<a class="anchor" name="o10" doxytag="_DMXLocalInitInfo::numButtons" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o10">_DMXLocalInitInfo::numButtons</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Number of buttons </td>
+ </tr>
+</table>
+<a class="anchor" name="o13" doxytag="_DMXLocalInitInfo::numRelAxes" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o13">_DMXLocalInitInfo::numRelAxes</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Number of relative axes </td>
+ </tr>
+</table>
+<a class="anchor" name="o21" doxytag="_DMXLocalInitInfo::proximityClass" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o21">_DMXLocalInitInfo::proximityClass</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if device causes proximity events </td>
+ </tr>
+</table>
+<a class="anchor" name="o23" doxytag="_DMXLocalInitInfo::ptrFeedbackClass" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o23">_DMXLocalInitInfo::ptrFeedbackClass</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if device has pointer feedback </td>
+ </tr>
+</table>
+<a class="anchor" name="o17" doxytag="_DMXLocalInitInfo::res" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o17">_DMXLocalInitInfo::res</a>[DMX_MAX_AXES]
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Resolution </td>
+ </tr>
+</table>
+<a class="anchor" name="o27" doxytag="_DMXLocalInitInfo::strFeedbackClass" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o27">_DMXLocalInitInfo::strFeedbackClass</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if device has string feedback </td>
+ </tr>
+</table>
+<a class="anchor" name="o30" doxytag="_DMXLocalInitInfo::symbols" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> KeySym* <a class="el" href="struct__DMXLocalInitInfo.html#o30">_DMXLocalInitInfo::symbols</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Key symbols </td>
+ </tr>
+</table>
+<a class="anchor" name="o12" doxytag="_DMXLocalInitInfo::valuatorClass" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInitInfo.html#o12">_DMXLocalInitInfo::valuatorClass</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if valuators are present </td>
+ </tr>
+</table>
+<a class="anchor" name="o5" doxytag="_DMXLocalInitInfo::xkb" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> XkbDescPtr <a class="el" href="struct__DMXLocalInitInfo.html#o5">_DMXLocalInitInfo::xkb</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+XKB description </td>
+ </tr>
+</table>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXLocalInputInfo.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXLocalInputInfo.html
new file mode 100644
index 000000000..7893e905f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXLocalInputInfo.html
@@ -0,0 +1,996 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXLocalInputInfo Struct Reference</h1><code>#include &lt;<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>const char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o0">name</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>DMXLocalInputType&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o1">type</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>DMXLocalInputExtType&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o2">extType</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o3">binding</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxCreatePrivateProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o4">create_private</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxDestroyPrivateProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o5">destroy_private</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxInitProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o6">init</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxReInitProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o7">reinit</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxLateReInitProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o8">latereinit</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxGetInfoProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o9">get_info</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxOnProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o10">on</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxOffProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o11">off</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxUpdatePositionProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o12">update_position</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxVTPreSwitchProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o13">vt_pre_switch</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxVTPostSwitchProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o14">vt_post_switch</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxVTSwitchProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o15">vt_switch</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxCollectEventsProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o16">collect_events</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxProcessInputProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o17">process_input</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxUpdateInfoProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o19">update_info</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxMCtrlProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o20">mCtrl</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxKBCtrlProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o21">kCtrl</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>dmxKBBellProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o22">kBell</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>pointer&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o23">private</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o24">isCore</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o25">sendsCore</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>KeybdCtrl&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o26">kctrl</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>PtrCtrl&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o27">mctrl</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>DeviceIntPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o28">pDevice</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o29">inputIdx</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o31">lastY</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o32">head</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o33">tail</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>unsigned long *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o34">history</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o35">valuators</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o37">savedMotionEvents</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o38">savedSendsCore</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__DMXEventMap.html">DMXEventMap</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o39">map</a> [DMX_MAP_ENTRIES]</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o40">mapOptimize</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>long&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o41">deviceId</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>const char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXLocalInputInfo.html#o42">deviceName</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This is the device-independent structure used by the low-level input routines. The contents are not exposed to top-level .c files (except dmxextensions.c). <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="dmxinput_8h.html">dmxinput.h</a> <p>
+dmxextensions.c </dd></dl>
+
+<p>
+<hr><h2>Field Documentation</h2>
+<a class="anchor" name="o3" doxytag="_DMXLocalInputInfo::binding" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInputInfo.html#o3">_DMXLocalInputInfo::binding</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Count of how many consecutive structs are bound to the same device </td>
+ </tr>
+</table>
+<a class="anchor" name="o16" doxytag="_DMXLocalInputInfo::collect_events" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxCollectEventsProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o16">_DMXLocalInputInfo::collect_events</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Collect and enqueue events from the device </td>
+ </tr>
+</table>
+<a class="anchor" name="o4" doxytag="_DMXLocalInputInfo::create_private" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxCreatePrivateProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o4">_DMXLocalInputInfo::create_private</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create device-dependent private </td>
+ </tr>
+</table>
+<a class="anchor" name="o5" doxytag="_DMXLocalInputInfo::destroy_private" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxDestroyPrivateProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o5">_DMXLocalInputInfo::destroy_private</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy device-dependent private </td>
+ </tr>
+</table>
+<a class="anchor" name="o41" doxytag="_DMXLocalInputInfo::deviceId" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> long <a class="el" href="struct__DMXLocalInputInfo.html#o41">_DMXLocalInputInfo::deviceId</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+device id on remote side, if any </td>
+ </tr>
+</table>
+<a class="anchor" name="o42" doxytag="_DMXLocalInputInfo::deviceName" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> const char* <a class="el" href="struct__DMXLocalInputInfo.html#o42">_DMXLocalInputInfo::deviceName</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+devive name on remote side, if any </td>
+ </tr>
+</table>
+<a class="anchor" name="o2" doxytag="_DMXLocalInputInfo::extType" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> DMXLocalInputExtType <a class="el" href="struct__DMXLocalInputInfo.html#o2">_DMXLocalInputInfo::extType</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Extended device type </td>
+ </tr>
+</table>
+<a class="anchor" name="o9" doxytag="_DMXLocalInputInfo::get_info" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxGetInfoProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o9">_DMXLocalInputInfo::get_info</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Get device information </td>
+ </tr>
+</table>
+<a class="anchor" name="o32" doxytag="_DMXLocalInputInfo::head" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInputInfo.html#o32">_DMXLocalInputInfo::head</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+XInput motion history head </td>
+ </tr>
+</table>
+<a class="anchor" name="o34" doxytag="_DMXLocalInputInfo::history" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> unsigned long* <a class="el" href="struct__DMXLocalInputInfo.html#o34">_DMXLocalInputInfo::history</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+XInput motion history </td>
+ </tr>
+</table>
+<a class="anchor" name="o6" doxytag="_DMXLocalInputInfo::init" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxInitProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o6">_DMXLocalInputInfo::init</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize device </td>
+ </tr>
+</table>
+<a class="anchor" name="o29" doxytag="_DMXLocalInputInfo::inputIdx" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInputInfo.html#o29">_DMXLocalInputInfo::inputIdx</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+High-level index </td>
+ </tr>
+</table>
+<a class="anchor" name="o24" doxytag="_DMXLocalInputInfo::isCore" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInputInfo.html#o24">_DMXLocalInputInfo::isCore</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Is a DMX core device </td>
+ </tr>
+</table>
+<a class="anchor" name="o22" doxytag="_DMXLocalInputInfo::kBell" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxKBBellProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o22">_DMXLocalInputInfo::kBell</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Bell control </td>
+ </tr>
+</table>
+<a class="anchor" name="o26" doxytag="_DMXLocalInputInfo::kctrl" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> KeybdCtrl <a class="el" href="struct__DMXLocalInputInfo.html#o26">_DMXLocalInputInfo::kctrl</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Keyboard control </td>
+ </tr>
+</table>
+<a class="anchor" name="o21" doxytag="_DMXLocalInputInfo::kCtrl" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxKBCtrlProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o21">_DMXLocalInputInfo::kCtrl</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Keyboard control </td>
+ </tr>
+</table>
+<a class="anchor" name="o31" doxytag="_DMXLocalInputInfo::lastY" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInputInfo.html#o31">_DMXLocalInputInfo::lastY</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Last known position; for XInput in <a class="el" href="dmxevents_8c.html">dmxevents.c</a> </td>
+ </tr>
+</table>
+<a class="anchor" name="o8" doxytag="_DMXLocalInputInfo::latereinit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxLateReInitProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o8">_DMXLocalInputInfo::latereinit</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Reinitialize a device (called very late during a reconfiguration) </td>
+ </tr>
+</table>
+<a class="anchor" name="o39" doxytag="_DMXLocalInputInfo::map" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__DMXEventMap.html">DMXEventMap</a> <a class="el" href="struct__DMXLocalInputInfo.html#o39">_DMXLocalInputInfo::map</a>[DMX_MAP_ENTRIES]
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+XInput device id map </td>
+ </tr>
+</table>
+<a class="anchor" name="o40" doxytag="_DMXLocalInputInfo::mapOptimize" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInputInfo.html#o40">_DMXLocalInputInfo::mapOptimize</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+XInput device id map optimization </td>
+ </tr>
+</table>
+<a class="anchor" name="o27" doxytag="_DMXLocalInputInfo::mctrl" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> PtrCtrl <a class="el" href="struct__DMXLocalInputInfo.html#o27">_DMXLocalInputInfo::mctrl</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Pointer control </td>
+ </tr>
+</table>
+<a class="anchor" name="o20" doxytag="_DMXLocalInputInfo::mCtrl" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxMCtrlProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o20">_DMXLocalInputInfo::mCtrl</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Pointer control </td>
+ </tr>
+</table>
+<a class="anchor" name="o0" doxytag="_DMXLocalInputInfo::name" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> const char* <a class="el" href="struct__DMXLocalInputInfo.html#o0">_DMXLocalInputInfo::name</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Device name </td>
+ </tr>
+</table>
+<a class="anchor" name="o11" doxytag="_DMXLocalInputInfo::off" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxOffProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o11">_DMXLocalInputInfo::off</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn device off </td>
+ </tr>
+</table>
+<a class="anchor" name="o10" doxytag="_DMXLocalInputInfo::on" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxOnProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o10">_DMXLocalInputInfo::on</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn device on </td>
+ </tr>
+</table>
+<a class="anchor" name="o28" doxytag="_DMXLocalInputInfo::pDevice" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> DeviceIntPtr <a class="el" href="struct__DMXLocalInputInfo.html#o28">_DMXLocalInputInfo::pDevice</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+X-level device </td>
+ </tr>
+</table>
+<a class="anchor" name="o23" doxytag="_DMXLocalInputInfo::private" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> pointer <a class="el" href="struct__DMXLocalInputInfo.html#o23">_DMXLocalInputInfo::private</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Device-dependent private </td>
+ </tr>
+</table>
+<a class="anchor" name="o17" doxytag="_DMXLocalInputInfo::process_input" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxProcessInputProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o17">_DMXLocalInputInfo::process_input</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Process event (from queue) </td>
+ </tr>
+</table>
+<a class="anchor" name="o7" doxytag="_DMXLocalInputInfo::reinit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxReInitProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o7">_DMXLocalInputInfo::reinit</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Reinitialize device (during a reconfiguration) </td>
+ </tr>
+</table>
+<a class="anchor" name="o37" doxytag="_DMXLocalInputInfo::savedMotionEvents" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInputInfo.html#o37">_DMXLocalInputInfo::savedMotionEvents</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Saved motion events </td>
+ </tr>
+</table>
+<a class="anchor" name="o38" doxytag="_DMXLocalInputInfo::savedSendsCore" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInputInfo.html#o38">_DMXLocalInputInfo::savedSendsCore</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Saved sends-core flag </td>
+ </tr>
+</table>
+<a class="anchor" name="o25" doxytag="_DMXLocalInputInfo::sendsCore" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInputInfo.html#o25">_DMXLocalInputInfo::sendsCore</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Sends DMX core events </td>
+ </tr>
+</table>
+<a class="anchor" name="o33" doxytag="_DMXLocalInputInfo::tail" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXLocalInputInfo.html#o33">_DMXLocalInputInfo::tail</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+XInput motion history tail </td>
+ </tr>
+</table>
+<a class="anchor" name="o1" doxytag="_DMXLocalInputInfo::type" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> DMXLocalInputType <a class="el" href="struct__DMXLocalInputInfo.html#o1">_DMXLocalInputInfo::type</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Device type </td>
+ </tr>
+</table>
+<a class="anchor" name="o19" doxytag="_DMXLocalInputInfo::update_info" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxUpdateInfoProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o19">_DMXLocalInputInfo::update_info</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Update window layout information </td>
+ </tr>
+</table>
+<a class="anchor" name="o12" doxytag="_DMXLocalInputInfo::update_position" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxUpdatePositionProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o12">_DMXLocalInputInfo::update_position</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Called when another device updates the cursor position </td>
+ </tr>
+</table>
+<a class="anchor" name="o35" doxytag="_DMXLocalInputInfo::valuators" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int* <a class="el" href="struct__DMXLocalInputInfo.html#o35">_DMXLocalInputInfo::valuators</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Cache of previous values </td>
+ </tr>
+</table>
+<a class="anchor" name="o14" doxytag="_DMXLocalInputInfo::vt_post_switch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxVTPostSwitchProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o14">_DMXLocalInputInfo::vt_post_switch</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Called after a VT switch </td>
+ </tr>
+</table>
+<a class="anchor" name="o13" doxytag="_DMXLocalInputInfo::vt_pre_switch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxVTPreSwitchProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o13">_DMXLocalInputInfo::vt_pre_switch</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Called before a VT switch </td>
+ </tr>
+</table>
+<a class="anchor" name="o15" doxytag="_DMXLocalInputInfo::vt_switch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> dmxVTSwitchProcPtr <a class="el" href="struct__DMXLocalInputInfo.html#o15">_DMXLocalInputInfo::vt_switch</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Causes a VT switch </td>
+ </tr>
+</table>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXScreenInfo.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXScreenInfo.html
new file mode 100644
index 000000000..c83d3f0aa
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXScreenInfo.html
@@ -0,0 +1,1330 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXScreenInfo Struct Reference</h1><code>#include &lt;<a class="el" href="dmx_8h-source.html">dmx.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>const char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o0">name</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o1">index</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Display *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o2">beDisplay</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o3">beWidth</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o4">beHeight</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o5">beDepth</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o6">beBPP</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o7">beXDPI</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o8">beYDPI</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o9">beNumDepths</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o10">beDepths</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o11">beNumPixmapFormats</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>XPixmapFormatValues *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o12">bePixmapFormats</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o13">beNumVisuals</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>XVisualInfo *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o14">beVisuals</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o15">beDefVisualIndex</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o16">beNumDefColormaps</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Colormap *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o17">beDefColormaps</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Pixel&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o18">beBlackPixel</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Pixel&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o19">beWhitePixel</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Window&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o20">scrnWin</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o21">scrnX</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o22">scrnY</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o23">scrnWidth</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o24">scrnHeight</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o25">scrnXSign</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o26">scrnYSign</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Drawable&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o27">scrnDefDrawables</a> [MAXFORMATS]</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__DMXScreenInfo.html">_DMXScreenInfo</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o28">next</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__DMXScreenInfo.html">_DMXScreenInfo</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o29">over</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Window&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o30">rootWin</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o31">rootX</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o32">rootY</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o33">rootWidth</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o34">rootHeight</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o35">rootXOrigin</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o36">rootYOrigin</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o37">shadow</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>XlibGC&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o38">shadowGC</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>XImage *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o39">shadowFBImage</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o40">shared</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>PositionType&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o47">where</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o48">whereX</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o49">whereY</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o50">whereRefScreen</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o51">savedTimeout</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o52">dpmsCapable</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o53">dpmsEnabled</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o54">dpmsStandby</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o55">dpmsSuspend</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o56">dpmsOff</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__DMXStatInfo.html">DMXStatInfo</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o57">stat</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o58">needsSync</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>CloseScreenProcPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__DMXScreenInfo.html#o59">CloseScreen</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Global structure containing information about each backend screen.
+<p>
+<hr><h2>Field Documentation</h2>
+<a class="anchor" name="o18" doxytag="_DMXScreenInfo::beBlackPixel" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Pixel <a class="el" href="struct__DMXScreenInfo.html#o18">_DMXScreenInfo::beBlackPixel</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Default black pixel for BE </td>
+ </tr>
+</table>
+<a class="anchor" name="o6" doxytag="_DMXScreenInfo::beBPP" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o6">_DMXScreenInfo::beBPP</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Bits per pixel of BE display </td>
+ </tr>
+</table>
+<a class="anchor" name="o17" doxytag="_DMXScreenInfo::beDefColormaps" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Colormap* <a class="el" href="struct__DMXScreenInfo.html#o17">_DMXScreenInfo::beDefColormaps</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Default colormaps for DMX server </td>
+ </tr>
+</table>
+<a class="anchor" name="o15" doxytag="_DMXScreenInfo::beDefVisualIndex" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o15">_DMXScreenInfo::beDefVisualIndex</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Default visual index of BE </td>
+ </tr>
+</table>
+<a class="anchor" name="o5" doxytag="_DMXScreenInfo::beDepth" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o5">_DMXScreenInfo::beDepth</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Depth of BE display </td>
+ </tr>
+</table>
+<a class="anchor" name="o10" doxytag="_DMXScreenInfo::beDepths" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int* <a class="el" href="struct__DMXScreenInfo.html#o10">_DMXScreenInfo::beDepths</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Depths from BE server </td>
+ </tr>
+</table>
+<a class="anchor" name="o2" doxytag="_DMXScreenInfo::beDisplay" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Display* <a class="el" href="struct__DMXScreenInfo.html#o2">_DMXScreenInfo::beDisplay</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Back-end X server's display </td>
+ </tr>
+</table>
+<a class="anchor" name="o4" doxytag="_DMXScreenInfo::beHeight" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o4">_DMXScreenInfo::beHeight</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Height of BE display </td>
+ </tr>
+</table>
+<a class="anchor" name="o16" doxytag="_DMXScreenInfo::beNumDefColormaps" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o16">_DMXScreenInfo::beNumDefColormaps</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Number of default colormaps </td>
+ </tr>
+</table>
+<a class="anchor" name="o9" doxytag="_DMXScreenInfo::beNumDepths" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o9">_DMXScreenInfo::beNumDepths</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Number of depths on BE server </td>
+ </tr>
+</table>
+<a class="anchor" name="o11" doxytag="_DMXScreenInfo::beNumPixmapFormats" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o11">_DMXScreenInfo::beNumPixmapFormats</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Number of pixmap formats on BE </td>
+ </tr>
+</table>
+<a class="anchor" name="o13" doxytag="_DMXScreenInfo::beNumVisuals" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o13">_DMXScreenInfo::beNumVisuals</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Number of visuals on BE </td>
+ </tr>
+</table>
+<a class="anchor" name="o12" doxytag="_DMXScreenInfo::bePixmapFormats" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> XPixmapFormatValues* <a class="el" href="struct__DMXScreenInfo.html#o12">_DMXScreenInfo::bePixmapFormats</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Pixmap formats on BE </td>
+ </tr>
+</table>
+<a class="anchor" name="o14" doxytag="_DMXScreenInfo::beVisuals" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> XVisualInfo* <a class="el" href="struct__DMXScreenInfo.html#o14">_DMXScreenInfo::beVisuals</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Visuals from BE server </td>
+ </tr>
+</table>
+<a class="anchor" name="o19" doxytag="_DMXScreenInfo::beWhitePixel" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Pixel <a class="el" href="struct__DMXScreenInfo.html#o19">_DMXScreenInfo::beWhitePixel</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Default white pixel for BE </td>
+ </tr>
+</table>
+<a class="anchor" name="o3" doxytag="_DMXScreenInfo::beWidth" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o3">_DMXScreenInfo::beWidth</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Width of BE display </td>
+ </tr>
+</table>
+<a class="anchor" name="o7" doxytag="_DMXScreenInfo::beXDPI" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o7">_DMXScreenInfo::beXDPI</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Horizontal dots per inch of BE </td>
+ </tr>
+</table>
+<a class="anchor" name="o8" doxytag="_DMXScreenInfo::beYDPI" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o8">_DMXScreenInfo::beYDPI</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Vertical dots per inch of BE </td>
+ </tr>
+</table>
+<a class="anchor" name="o59" doxytag="_DMXScreenInfo::CloseScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> CloseScreenProcPtr <a class="el" href="struct__DMXScreenInfo.html#o59">_DMXScreenInfo::CloseScreen</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Function pointers to wrapped screen functions </td>
+ </tr>
+</table>
+<a class="anchor" name="o52" doxytag="_DMXScreenInfo::dpmsCapable" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o52">_DMXScreenInfo::dpmsCapable</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if backend is DPMS capable </td>
+ </tr>
+</table>
+<a class="anchor" name="o53" doxytag="_DMXScreenInfo::dpmsEnabled" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o53">_DMXScreenInfo::dpmsEnabled</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if DPMS enabled </td>
+ </tr>
+</table>
+<a class="anchor" name="o56" doxytag="_DMXScreenInfo::dpmsOff" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o56">_DMXScreenInfo::dpmsOff</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Original DPMS off value </td>
+ </tr>
+</table>
+<a class="anchor" name="o54" doxytag="_DMXScreenInfo::dpmsStandby" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o54">_DMXScreenInfo::dpmsStandby</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Original DPMS standby value </td>
+ </tr>
+</table>
+<a class="anchor" name="o55" doxytag="_DMXScreenInfo::dpmsSuspend" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o55">_DMXScreenInfo::dpmsSuspend</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Original DPMS suspend value </td>
+ </tr>
+</table>
+<a class="anchor" name="o1" doxytag="_DMXScreenInfo::index" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o1">_DMXScreenInfo::index</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Index into dmxScreens global </td>
+ </tr>
+</table>
+<a class="anchor" name="o0" doxytag="_DMXScreenInfo::name" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> const char* <a class="el" href="struct__DMXScreenInfo.html#o0">_DMXScreenInfo::name</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Name from command line or config file </td>
+ </tr>
+</table>
+<a class="anchor" name="o58" doxytag="_DMXScreenInfo::needsSync" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="struct__DMXScreenInfo.html#o58">_DMXScreenInfo::needsSync</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if an XSync is pending </td>
+ </tr>
+</table>
+<a class="anchor" name="o28" doxytag="_DMXScreenInfo::next" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> struct <a class="el" href="struct__DMXScreenInfo.html">_DMXScreenInfo</a>* <a class="el" href="struct__DMXScreenInfo.html#o28">_DMXScreenInfo::next</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+List of "screens" on same display </td>
+ </tr>
+</table>
+<a class="anchor" name="o29" doxytag="_DMXScreenInfo::over" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> struct <a class="el" href="struct__DMXScreenInfo.html">_DMXScreenInfo</a>* <a class="el" href="struct__DMXScreenInfo.html#o29">_DMXScreenInfo::over</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+List of "screens" that overlap </td>
+ </tr>
+</table>
+<a class="anchor" name="o34" doxytag="_DMXScreenInfo::rootHeight" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o34">_DMXScreenInfo::rootHeight</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Height of "root" window </td>
+ </tr>
+</table>
+<a class="anchor" name="o33" doxytag="_DMXScreenInfo::rootWidth" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o33">_DMXScreenInfo::rootWidth</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Width of "root" window </td>
+ </tr>
+</table>
+<a class="anchor" name="o30" doxytag="_DMXScreenInfo::rootWin" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Window <a class="el" href="struct__DMXScreenInfo.html#o30">_DMXScreenInfo::rootWin</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+"Root" window on backend display </td>
+ </tr>
+</table>
+<a class="anchor" name="o31" doxytag="_DMXScreenInfo::rootX" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o31">_DMXScreenInfo::rootX</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+X offset of "root" window WRT "screen" </td>
+ </tr>
+</table>
+<a class="anchor" name="o35" doxytag="_DMXScreenInfo::rootXOrigin" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o35">_DMXScreenInfo::rootXOrigin</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Global X origin of "root" window </td>
+ </tr>
+</table>
+<a class="anchor" name="o32" doxytag="_DMXScreenInfo::rootY" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o32">_DMXScreenInfo::rootY</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Y offset of "root" window WRT "screen" </td>
+ </tr>
+</table>
+<a class="anchor" name="o36" doxytag="_DMXScreenInfo::rootYOrigin" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o36">_DMXScreenInfo::rootYOrigin</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Global Y origin of "root" window </td>
+ </tr>
+</table>
+<a class="anchor" name="o51" doxytag="_DMXScreenInfo::savedTimeout" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o51">_DMXScreenInfo::savedTimeout</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Original screen saver timeout </td>
+ </tr>
+</table>
+<a class="anchor" name="o27" doxytag="_DMXScreenInfo::scrnDefDrawables" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Drawable <a class="el" href="struct__DMXScreenInfo.html#o27">_DMXScreenInfo::scrnDefDrawables</a>[MAXFORMATS]
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Default drawables for "screen" </td>
+ </tr>
+</table>
+<a class="anchor" name="o24" doxytag="_DMXScreenInfo::scrnHeight" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o24">_DMXScreenInfo::scrnHeight</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Height of "screen" </td>
+ </tr>
+</table>
+<a class="anchor" name="o23" doxytag="_DMXScreenInfo::scrnWidth" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o23">_DMXScreenInfo::scrnWidth</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Width of "screen" </td>
+ </tr>
+</table>
+<a class="anchor" name="o20" doxytag="_DMXScreenInfo::scrnWin" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Window <a class="el" href="struct__DMXScreenInfo.html#o20">_DMXScreenInfo::scrnWin</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+"Screen" window on backend display </td>
+ </tr>
+</table>
+<a class="anchor" name="o21" doxytag="_DMXScreenInfo::scrnX" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o21">_DMXScreenInfo::scrnX</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+X offset of "screen" WRT BE display </td>
+ </tr>
+</table>
+<a class="anchor" name="o25" doxytag="_DMXScreenInfo::scrnXSign" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o25">_DMXScreenInfo::scrnXSign</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+X offset sign of "screen" </td>
+ </tr>
+</table>
+<a class="anchor" name="o22" doxytag="_DMXScreenInfo::scrnY" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o22">_DMXScreenInfo::scrnY</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Y offset of "screen" WRT BE display </td>
+ </tr>
+</table>
+<a class="anchor" name="o26" doxytag="_DMXScreenInfo::scrnYSign" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o26">_DMXScreenInfo::scrnYSign</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Y offset sign of "screen" </td>
+ </tr>
+</table>
+<a class="anchor" name="o37" doxytag="_DMXScreenInfo::shadow" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void* <a class="el" href="struct__DMXScreenInfo.html#o37">_DMXScreenInfo::shadow</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Shadow framebuffer data (if enabled) </td>
+ </tr>
+</table>
+<a class="anchor" name="o39" doxytag="_DMXScreenInfo::shadowFBImage" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> XImage* <a class="el" href="struct__DMXScreenInfo.html#o39">_DMXScreenInfo::shadowFBImage</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Screen image used by shadow FB code </td>
+ </tr>
+</table>
+<a class="anchor" name="o38" doxytag="_DMXScreenInfo::shadowGC" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> XlibGC <a class="el" href="struct__DMXScreenInfo.html#o38">_DMXScreenInfo::shadowGC</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Default GC used by shadow FB code </td>
+ </tr>
+</table>
+<a class="anchor" name="o40" doxytag="_DMXScreenInfo::shared" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o40">_DMXScreenInfo::shared</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Non-zero if another Xdmx is running </td>
+ </tr>
+</table>
+<a class="anchor" name="o57" doxytag="_DMXScreenInfo::stat" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__DMXStatInfo.html">DMXStatInfo</a>* <a class="el" href="struct__DMXScreenInfo.html#o57">_DMXScreenInfo::stat</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Statistics about XSync </td>
+ </tr>
+</table>
+<a class="anchor" name="o47" doxytag="_DMXScreenInfo::where" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> PositionType <a class="el" href="struct__DMXScreenInfo.html#o47">_DMXScreenInfo::where</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Relative layout information </td>
+ </tr>
+</table>
+<a class="anchor" name="o50" doxytag="_DMXScreenInfo::whereRefScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o50">_DMXScreenInfo::whereRefScreen</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Relative layout information </td>
+ </tr>
+</table>
+<a class="anchor" name="o48" doxytag="_DMXScreenInfo::whereX" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o48">_DMXScreenInfo::whereX</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Relative layout information </td>
+ </tr>
+</table>
+<a class="anchor" name="o49" doxytag="_DMXScreenInfo::whereY" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__DMXScreenInfo.html#o49">_DMXScreenInfo::whereY</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Relative layout information </td>
+ </tr>
+</table>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmx_8h-source.html">dmx.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXStatAvg.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXStatAvg.html
new file mode 100644
index 000000000..feb264dcb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXStatAvg.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXStatAvg Struct Reference</h1><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Used to compute a running average of value.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxstat_8c.html">dmxstat.c</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXStatInfo.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXStatInfo.html
new file mode 100644
index 000000000..eff756130
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXStatInfo.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_DMXStatInfo Struct Reference</h1><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Statistical information about XSync calls.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxstat_8c.html">dmxstat.c</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__Event.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__Event.html
new file mode 100644
index 000000000..cb9b65bc3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__Event.html
@@ -0,0 +1,104 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_Event Struct Reference</h1><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>xEvent&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__Event.html#o0">event</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>ScreenPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__Event.html#o1">pScreen</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>deviceValuator&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__Event.html#o2">valuator</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Information about the event.
+<p>
+<hr><h2>Field Documentation</h2>
+<a class="anchor" name="o0" doxytag="_Event::event" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> xEvent <a class="el" href="struct__Event.html#o0">_Event::event</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Event. </td>
+ </tr>
+</table>
+<a class="anchor" name="o1" doxytag="_Event::pScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> ScreenPtr <a class="el" href="struct__Event.html#o1">_Event::pScreen</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Screen on which event occurred. </td>
+ </tr>
+</table>
+<a class="anchor" name="o2" doxytag="_Event::valuator" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> deviceValuator <a class="el" href="struct__Event.html#o2">_Event::valuator</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+XInput device valuator information. </td>
+ </tr>
+</table>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxeq_8c.html">dmxeq.c</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__EventQueue.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__EventQueue.html
new file mode 100644
index 000000000..abcc33aa2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__EventQueue.html
@@ -0,0 +1,224 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_EventQueue Struct Reference</h1><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>HWEventQueueType&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__EventQueue.html#o0">head</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>HWEventQueueType&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__EventQueue.html#o1">tail</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>CARD32&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__EventQueue.html#o2">lastEventTime</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__EventQueue.html#o3">lastMotion</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__Event.html">EventRec</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__EventQueue.html#o4">events</a> [QUEUE_SIZE]</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>DevicePtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__EventQueue.html#o6">pPtr</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>ScreenPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__EventQueue.html#o7">pEnqueueScreen</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>ScreenPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__EventQueue.html#o8">pDequeueScreen</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Event queue.
+<p>
+<hr><h2>Field Documentation</h2>
+<a class="anchor" name="o4" doxytag="_EventQueue::events" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__Event.html">EventRec</a> <a class="el" href="struct__EventQueue.html#o4">_EventQueue::events</a>[QUEUE_SIZE]
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Static allocation for signals. </td>
+ </tr>
+</table>
+<a class="anchor" name="o0" doxytag="_EventQueue::head" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> HWEventQueueType <a class="el" href="struct__EventQueue.html#o0">_EventQueue::head</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Queue head; must be long for SetInputCheck. </td>
+ </tr>
+</table>
+<a class="anchor" name="o2" doxytag="_EventQueue::lastEventTime" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> CARD32 <a class="el" href="struct__EventQueue.html#o2">_EventQueue::lastEventTime</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+To avoid time running backwards. </td>
+ </tr>
+</table>
+<a class="anchor" name="o3" doxytag="_EventQueue::lastMotion" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Bool <a class="el" href="struct__EventQueue.html#o3">_EventQueue::lastMotion</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+True if last event was motion. </td>
+ </tr>
+</table>
+<a class="anchor" name="o8" doxytag="_EventQueue::pDequeueScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> ScreenPtr <a class="el" href="struct__EventQueue.html#o8">_EventQueue::pDequeueScreen</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Screen events are dispatched to. </td>
+ </tr>
+</table>
+<a class="anchor" name="o7" doxytag="_EventQueue::pEnqueueScreen" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> ScreenPtr <a class="el" href="struct__EventQueue.html#o7">_EventQueue::pEnqueueScreen</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Screen events are delivered to. </td>
+ </tr>
+</table>
+<a class="anchor" name="o6" doxytag="_EventQueue::pPtr" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> DevicePtr <a class="el" href="struct__EventQueue.html#o6">_EventQueue::pPtr</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Device pointers (to get funcs) </td>
+ </tr>
+</table>
+<a class="anchor" name="o1" doxytag="_EventQueue::tail" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> HWEventQueueType <a class="el" href="struct__EventQueue.html#o1">_EventQueue::tail</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Queue tail; must be long for SetInputCheck. </td>
+ </tr>
+</table>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxeq_8c.html">dmxeq.c</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxArg.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxArg.html
new file mode 100644
index 000000000..16ef20aed
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxArg.html
@@ -0,0 +1,104 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_dmxArg Struct Reference</h1><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__dmxArg.html#o0">argc</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__dmxArg.html#o1">argm</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>const char **&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__dmxArg.html#o2">argv</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Stores the parsed argument list.
+<p>
+<hr><h2>Field Documentation</h2>
+<a class="anchor" name="o0" doxytag="_dmxArg::argc" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__dmxArg.html#o0">_dmxArg::argc</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Number of arguments in argv </td>
+ </tr>
+</table>
+<a class="anchor" name="o1" doxytag="_dmxArg::argm" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__dmxArg.html#o1">_dmxArg::argm</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Maximum number of arguments store-able in argv </td>
+ </tr>
+</table>
+<a class="anchor" name="o2" doxytag="_dmxArg::argv" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> const char** <a class="el" href="struct__dmxArg.html#o2">_dmxArg::argv</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Arguments </td>
+ </tr>
+</table>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxarg_8c.html">dmxarg.c</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxColormapPriv.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxColormapPriv.html
new file mode 100644
index 000000000..531e96ee2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxColormapPriv.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_dmxColormapPriv Struct Reference</h1><code>#include &lt;<a class="el" href="dmxcmap_8h-source.html">dmxcmap.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Colormap private area.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxcmap_8h-source.html">dmxcmap.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxCursorPriv.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxCursorPriv.html
new file mode 100644
index 000000000..3891b8f3a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxCursorPriv.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_dmxCursorPriv Struct Reference</h1><code>#include &lt;<a class="el" href="dmxcursor_8h-source.html">dmxcursor.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Cursor private area.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxcursor_8h-source.html">dmxcursor.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxFontPriv.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxFontPriv.html
new file mode 100644
index 000000000..adff77f04
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxFontPriv.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_dmxFontPriv Struct Reference</h1><code>#include &lt;<a class="el" href="dmxfont_8h-source.html">dmxfont.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Font private area.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxfont_8h-source.html">dmxfont.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxGCPriv.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxGCPriv.html
new file mode 100644
index 000000000..9a7b0fd25
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxGCPriv.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_dmxGCPriv Struct Reference</h1><code>#include &lt;<a class="el" href="dmxgc_8h-source.html">dmxgc.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+GC private area.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxgc_8h-source.html">dmxgc.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxGlyphPriv.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxGlyphPriv.html
new file mode 100644
index 000000000..c7738a4b6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxGlyphPriv.html
@@ -0,0 +1,58 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_dmxGlyphPriv Struct Reference</h1><code>#include &lt;<a class="el" href="dmxpict_8h-source.html">dmxpict.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>GlyphSet *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__dmxGlyphPriv.html#o0">glyphSets</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Glyph Set private structure
+<p>
+<hr><h2>Field Documentation</h2>
+<a class="anchor" name="o0" doxytag="_dmxGlyphPriv::glyphSets" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> GlyphSet* <a class="el" href="struct__dmxGlyphPriv.html#o0">_dmxGlyphPriv::glyphSets</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Glyph Set IDs from back-end server </td>
+ </tr>
+</table>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxpict_8h-source.html">dmxpict.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxPictPriv.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxPictPriv.html
new file mode 100644
index 000000000..c3034eefa
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxPictPriv.html
@@ -0,0 +1,82 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_dmxPictPriv Struct Reference</h1><code>#include &lt;<a class="el" href="dmxpict_8h-source.html">dmxpict.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>Picture&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__dmxPictPriv.html#o0">pict</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>Mask&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__dmxPictPriv.html#o1">savedMask</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Picture private structure
+<p>
+<hr><h2>Field Documentation</h2>
+<a class="anchor" name="o0" doxytag="_dmxPictPriv::pict" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Picture <a class="el" href="struct__dmxPictPriv.html#o0">_dmxPictPriv::pict</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Picture ID from back-end server </td>
+ </tr>
+</table>
+<a class="anchor" name="o1" doxytag="_dmxPictPriv::savedMask" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> Mask <a class="el" href="struct__dmxPictPriv.html#o1">_dmxPictPriv::savedMask</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Mask of picture attributes saved for lazy window creation. </td>
+ </tr>
+</table>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxpict_8h-source.html">dmxpict.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxPixPriv.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxPixPriv.html
new file mode 100644
index 000000000..a358c0162
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxPixPriv.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_dmxPixPriv Struct Reference</h1><code>#include &lt;<a class="el" href="dmxpixmap_8h-source.html">dmxpixmap.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Pixmap private area.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxpixmap_8h-source.html">dmxpixmap.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxWinPriv.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxWinPriv.html
new file mode 100644
index 000000000..c51978e8f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxWinPriv.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_dmxWinPriv Struct Reference</h1><code>#include &lt;<a class="el" href="dmxwindow_8h-source.html">dmxwindow.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Window private area.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxwindow_8h-source.html">dmxwindow.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__myPrivate.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__myPrivate.html
new file mode 100644
index 000000000..50e532569
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/struct__myPrivate.html
@@ -0,0 +1,272 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>_myPrivate Struct Reference</h1><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html#o37">fd</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>CARD32&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html#o43">kbdState</a> [NUM_STATE_ENTRIES]</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html#o49">pitch</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>unsigned long&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html#o50">duration</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>DeviceIntPtr&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html#o55">pDevice</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>unsigned char&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html#o56">mask</a> [EV_MAX/8+1]</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html#o59">numLeds</a></td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html#o60">relmap</a> [DMX_MAX_AXES]</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html#o61">absmap</a> [DMX_MAX_AXES]</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a> *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html#o62">dmxInput</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Each device has a private area that is visible only from inside the driver code.
+<p>
+<hr><h2>Field Documentation</h2>
+<a class="anchor" name="o61" doxytag="_myPrivate::absmap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__myPrivate.html#o61">_myPrivate::absmap</a>[DMX_MAX_AXES]
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Absolute axis map </td>
+ </tr>
+</table>
+<a class="anchor" name="o62" doxytag="_myPrivate::dmxInput" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> <a class="el" href="struct__DMXInputInfo.html">DMXInputInfo</a>* <a class="el" href="struct__myPrivate.html#o62">_myPrivate::dmxInput</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+For pretty-printing </td>
+ </tr>
+</table>
+<a class="anchor" name="o50" doxytag="_myPrivate::duration" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> unsigned long <a class="el" href="struct__myPrivate.html#o50">_myPrivate::duration</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Bell duration </td>
+ </tr>
+</table>
+<a class="anchor" name="o37" doxytag="_myPrivate::fd" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__myPrivate.html#o37">_myPrivate::fd</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+File descriptor </td>
+ </tr>
+</table>
+<a class="anchor" name="o43" doxytag="_myPrivate::kbdState" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> CARD32 <a class="el" href="struct__myPrivate.html#o43">_myPrivate::kbdState</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Keyboard state </td>
+ </tr>
+</table>
+<a class="anchor" name="o56" doxytag="_myPrivate::mask" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> unsigned char <a class="el" href="struct__myPrivate.html#o56">_myPrivate::mask</a>[EV_MAX/8 + 1]
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Mask </td>
+ </tr>
+</table>
+<a class="anchor" name="o59" doxytag="_myPrivate::numLeds" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__myPrivate.html#o59">_myPrivate::numLeds</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Counts </td>
+ </tr>
+</table>
+<a class="anchor" name="o55" doxytag="_myPrivate::pDevice" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> DeviceIntPtr <a class="el" href="struct__myPrivate.html#o55">_myPrivate::pDevice</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Device (mouse or other) </td>
+ </tr>
+</table>
+<a class="anchor" name="o49" doxytag="_myPrivate::pitch" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__myPrivate.html#o49">_myPrivate::pitch</a>
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Bell pitch </td>
+ </tr>
+</table>
+<a class="anchor" name="o60" doxytag="_myPrivate::relmap" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int <a class="el" href="struct__myPrivate.html#o60">_myPrivate::relmap</a>[DMX_MAX_AXES]
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Relative axis map </td>
+ </tr>
+</table>
+<hr>The documentation for this struct was generated from the following files:<ul>
+<li><a class="el" href="dmxbackend_8c.html">dmxbackend.c</a><li><a class="el" href="dmxcommon_8c.html">dmxcommon.c</a><li><a class="el" href="dmxconsole_8c.html">dmxconsole.c</a><li><a class="el" href="lnx-keyboard_8c.html">lnx-keyboard.c</a><li><a class="el" href="lnx-ms_8c.html">lnx-ms.c</a><li><a class="el" href="lnx-ps2_8c.html">lnx-ps2.c</a><li><a class="el" href="usb-private_8h-source.html">usb-private.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structdmxGlxVisualPrivate.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structdmxGlxVisualPrivate.html
new file mode 100644
index 000000000..2c5584e14
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structdmxGlxVisualPrivate.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>dmxGlxVisualPrivate Struct Reference</h1><code>#include &lt;<a class="el" href="dmx__glxvisuals_8h-source.html">dmx_glxvisuals.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+GLX Visual private area.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmx__glxvisuals_8h-source.html">dmx_glxvisuals.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddInputReply.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddInputReply.html
new file mode 100644
index 000000000..580d1dcc0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddInputReply.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXAddInputReply Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXAddInput protocol reply.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddInputReq.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddInputReq.html
new file mode 100644
index 000000000..8f2a84d5d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddInputReq.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXAddInputReq Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXAddInput protocol request.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddScreenReply.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddScreenReply.html
new file mode 100644
index 000000000..6f1b91d8e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddScreenReply.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXAddScreenReply Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXAddScreen protocol reply.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddScreenReq.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddScreenReq.html
new file mode 100644
index 000000000..ec634882d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddScreenReq.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXAddScreenReq Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXAddScreen protocol request.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeDesktopAttributesReply.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeDesktopAttributesReply.html
new file mode 100644
index 000000000..5ca2fb174
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeDesktopAttributesReply.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXChangeDesktopAttributesReply Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXChangeDesktopAttributes protocol reply.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeDesktopAttributesReq.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeDesktopAttributesReq.html
new file mode 100644
index 000000000..9fb5c4cdf
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeDesktopAttributesReq.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXChangeDesktopAttributesReq Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXChangeDesktopAttributes protocol request.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeScreensAttributesReply.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeScreensAttributesReply.html
new file mode 100644
index 000000000..f7228665f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeScreensAttributesReply.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXChangeScreensAttributesReply Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXChangeScreensAttributes protocol reply.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeScreensAttributesReq.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeScreensAttributesReq.html
new file mode 100644
index 000000000..d744c6a72
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeScreensAttributesReq.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXChangeScreensAttributesReq Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXChangeScreensAttributes protocol request.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXForceWindowCreationReply.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXForceWindowCreationReply.html
new file mode 100644
index 000000000..796791499
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXForceWindowCreationReply.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXForceWindowCreationReply Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXForceWindowCreation protocol reply.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXForceWindowCreationReq.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXForceWindowCreationReq.html
new file mode 100644
index 000000000..b85f6b11c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXForceWindowCreationReq.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXForceWindowCreationReq Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXForceWindowCreation protocol request.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetDesktopAttributesReply.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetDesktopAttributesReply.html
new file mode 100644
index 000000000..6637fb12a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetDesktopAttributesReply.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXGetDesktopAttributesReply Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXGetDesktopAttributes protocol reply.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetDesktopAttributesReq.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetDesktopAttributesReq.html
new file mode 100644
index 000000000..c9ecbc38d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetDesktopAttributesReq.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXGetDesktopAttributesReq Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXGetDesktopAttributes protocol request.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputAttributesReply.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputAttributesReply.html
new file mode 100644
index 000000000..71595c5a1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputAttributesReply.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXGetInputAttributesReply Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXGetInputAttributes protocol reply.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputAttributesReq.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputAttributesReq.html
new file mode 100644
index 000000000..6c7fade50
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputAttributesReq.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXGetInputAttributesReq Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXGetInputAttributes protocol request.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputCountReply.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputCountReply.html
new file mode 100644
index 000000000..375b1415c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputCountReply.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXGetInputCountReply Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXGetInputCount protocol reply.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputCountReq.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputCountReq.html
new file mode 100644
index 000000000..55251bb52
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputCountReq.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXGetInputCountReq Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXGetInputCount protocol request.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenAttributesReply.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenAttributesReply.html
new file mode 100644
index 000000000..89ca021e7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenAttributesReply.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXGetScreenAttributesReply Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXGetScreenAttributes protocol reply.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenAttributesReq.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenAttributesReq.html
new file mode 100644
index 000000000..d7d9e9afd
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenAttributesReq.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXGetScreenAttributesReq Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXGetScreenAttributes protocol request.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenCountReply.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenCountReply.html
new file mode 100644
index 000000000..e694fc90a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenCountReply.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXGetScreenCountReply Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXGetScreenCount protocol reply.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenCountReq.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenCountReq.html
new file mode 100644
index 000000000..f27e1e05a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenCountReq.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXGetScreenCountReq Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXGetScreenCount protocol request.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetWindowAttributesReply.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetWindowAttributesReply.html
new file mode 100644
index 000000000..2e381958b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetWindowAttributesReply.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXGetWindowAttributesReply Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXGetWindowAttributes protocol reply.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetWindowAttributesReq.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetWindowAttributesReq.html
new file mode 100644
index 000000000..9b3e1c053
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetWindowAttributesReq.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXGetWindowAttributesReq Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXGetWindowAttributes protocol request.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXQueryVersionReply.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXQueryVersionReply.html
new file mode 100644
index 000000000..c9a4683f1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXQueryVersionReply.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXQueryVersionReply Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXQueryVersion protocol reply.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXQueryVersionReq.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXQueryVersionReq.html
new file mode 100644
index 000000000..fdc3c3f97
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXQueryVersionReq.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXQueryVersionReq Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXQueryVersion protocol request.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveInputReply.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveInputReply.html
new file mode 100644
index 000000000..66c04a373
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveInputReply.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXRemoveInputReply Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXRemoveInput protocol reply.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveInputReq.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveInputReq.html
new file mode 100644
index 000000000..62f2af182
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveInputReq.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXRemoveInputReq Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXRemoveInput protocol request.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveScreenReply.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveScreenReply.html
new file mode 100644
index 000000000..c446a3442
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveScreenReply.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXRemoveScreenReply Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXRemoveScreen protocol reply.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveScreenReq.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveScreenReq.html
new file mode 100644
index 000000000..3920bff9b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveScreenReq.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXRemoveScreenReq Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXRemoveScreen protocol request.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXSyncReply.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXSyncReply.html
new file mode 100644
index 000000000..0a361cf5d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXSyncReply.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXSyncReply Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXSync protocol reply.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXSyncReq.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXSyncReq.html
new file mode 100644
index 000000000..a1580095d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXSyncReq.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>xDMXSyncReq Struct Reference</h1><code>#include &lt;<a class="el" href="dmxproto_8h-source.html">dmxproto.h</a>&gt;</code>
+<p>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Wire-level description of DMXSync protocol request.
+<p>
+<hr>The documentation for this struct was generated from the following file:<ul>
+<li><a class="el" href="dmxproto_8h-source.html">dmxproto.h</a></ul>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/tree.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/tree.html
new file mode 100644
index 000000000..59560837e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/tree.html
@@ -0,0 +1,295 @@
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <meta http-equiv="Content-Type" content="text/xhtml;charset="iso-8859-1" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <meta http-equiv="Content-Language" content="en" />
+ <link rel="stylesheet" href="doxygen.css">
+ <title>TreeView</title>
+ <style type="text/css">
+ <!--
+ .directory { font-size: 10pt; font-weight: bold; }
+ .directory h3 { margin: 0px; margin-top: 1em; font-size: 11pt; }
+ .directory p { margin: 0px; white-space: nowrap; }
+ .directory div { display: none; margin: 0px; }
+ .directory img { vertical-align: middle; }
+ -->
+ </style>
+ <script type="text/javascript">
+ <!-- // Hide script from old browsers
+
+ function findChildNode(node, name)
+ {
+ var temp;
+ if (node == null)
+ {
+ return null;
+ }
+ node = node.firstChild;
+ while (node != null)
+ {
+ if (node.nodeName == name)
+ {
+ return node;
+ }
+ temp = findChildNode(node, name);
+ if (temp != null)
+ {
+ return temp;
+ }
+ node = node.nextSibling;
+ }
+ return null;
+ }
+
+ function toggleFolder(id, imageNode)
+ {
+ var folder = document.getElementById(id);
+ var l = 0;
+ var vl = "ftv2vertline.png";
+ if (imageNode != null && imageNode.nodeName != "IMG")
+ {
+ imageNode = findChildNode(imageNode, "IMG");
+ if (imageNode!=null) l = imageNode.src.length;
+ }
+ if (folder == null)
+ {
+ }
+ else if (folder.style.display == "block")
+ {
+ while (imageNode != null &&
+ imageNode.src.substring(l-vl.length,l) == vl)
+ {
+ imageNode = imageNode.nextSibling;
+ l = imageNode.src.length;
+ }
+ if (imageNode != null)
+ {
+ l = imageNode.src.length;
+ imageNode.nextSibling.src = "ftv2folderclosed.png";
+ if (imageNode.src.substring(l-13,l) == "ftv2mnode.png")
+ {
+ imageNode.src = "ftv2pnode.png";
+ }
+ else if (imageNode.src.substring(l-17,l) == "ftv2mlastnode.png")
+ {
+ imageNode.src = "ftv2plastnode.png";
+ }
+ }
+ folder.style.display = "none";
+ }
+ else
+ {
+ while (imageNode != null &&
+ imageNode.src.substring(l-vl.length,l) == vl)
+ {
+ imageNode = imageNode.nextSibling;
+ l = imageNode.src.length;
+ }
+ if (imageNode != null)
+ {
+ l = imageNode.src.length;
+ imageNode.nextSibling.src = "ftv2folderopen.png";
+ if (imageNode.src.substring(l-13,l) == "ftv2pnode.png")
+ {
+ imageNode.src = "ftv2mnode.png";
+ }
+ else if (imageNode.src.substring(l-17,l) == "ftv2plastnode.png")
+ {
+ imageNode.src = "ftv2mlastnode.png";
+ }
+ }
+ folder.style.display = "block";
+ }
+ }
+
+ // End script hiding -->
+ </script>
+ </head>
+
+ <body bgcolor="#ffffff">
+ <div class="directory">
+ <h3>Distributed Multihead X</h3>
+ <div style="display: block;">
+ <p><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="main.html" target="basefrm">Main Page</a></p>
+ <p><img src="ftv2pnode.png" alt="o" width=16 height=22 onclick="toggleFolder('folder1', this)"/><img src="ftv2folderclosed.png" alt="+" width=24 height=22 onclick="toggleFolder('folder1', this)"/><a class="el" href="files.html" target="basefrm">File List</a></p>
+ <div id="folder1">
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="ChkNotMaskEv_8c.html" target="basefrm">ChkNotMaskEv.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="ChkNotMaskEv_8h.html" target="basefrm">ChkNotMaskEv.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="programs_2Xserver_2Xext_2dmx_8c.html" target="basefrm">programs/Xserver/Xext/dmx.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="lib_2dmx_2dmx_8c.html" target="basefrm">lib/dmx/dmx.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmx_8h.html" target="basefrm">dmx.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><b>dmx_glxvisuals.h</b></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxarg_8c.html" target="basefrm">dmxarg.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxarg_8h.html" target="basefrm">dmxarg.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxbackend_8c.html" target="basefrm">dmxbackend.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxbackend_8h.html" target="basefrm">dmxbackend.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxcb_8c.html" target="basefrm">dmxcb.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxcb_8h.html" target="basefrm">dmxcb.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxclient_8h.html" target="basefrm">dmxclient.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxcmap_8c.html" target="basefrm">dmxcmap.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxcmap_8h.html" target="basefrm">dmxcmap.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxcommon_8c.html" target="basefrm">dmxcommon.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxcommon_8h.html" target="basefrm">dmxcommon.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxcompat_8c.html" target="basefrm">dmxcompat.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxcompat_8h.html" target="basefrm">dmxcompat.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxconfig_8c.html" target="basefrm">dmxconfig.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxconfig_8h.html" target="basefrm">dmxconfig.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxconsole_8c.html" target="basefrm">dmxconsole.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxconsole_8h.html" target="basefrm">dmxconsole.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxcursor_8c.html" target="basefrm">dmxcursor.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxcursor_8h.html" target="basefrm">dmxcursor.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxdetach_8c.html" target="basefrm">dmxdetach.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxdpms_8c.html" target="basefrm">dmxdpms.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxdpms_8h.html" target="basefrm">dmxdpms.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxdummy_8c.html" target="basefrm">dmxdummy.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxdummy_8h.html" target="basefrm">dmxdummy.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxeq_8c.html" target="basefrm">dmxeq.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxeq_8h.html" target="basefrm">dmxeq.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxevents_8c.html" target="basefrm">dmxevents.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxevents_8h.html" target="basefrm">dmxevents.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxext_8h.html" target="basefrm">dmxext.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxextension_8c.html" target="basefrm">dmxextension.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxextension_8h.html" target="basefrm">dmxextension.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxfont_8c.html" target="basefrm">dmxfont.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxfont_8h.html" target="basefrm">dmxfont.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxgc_8c.html" target="basefrm">dmxgc.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxgc_8h.html" target="basefrm">dmxgc.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxgcops_8c.html" target="basefrm">dmxgcops.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxgcops_8h.html" target="basefrm">dmxgcops.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxinit_8c.html" target="basefrm">dmxinit.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxinit_8h.html" target="basefrm">dmxinit.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxinput_8c.html" target="basefrm">dmxinput.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxinput_8h.html" target="basefrm">dmxinput.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxinputinit_8c.html" target="basefrm">dmxinputinit.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxinputinit_8h.html" target="basefrm">dmxinputinit.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxlog_8c.html" target="basefrm">dmxlog.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxlog_8h.html" target="basefrm">dmxlog.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxmap_8c.html" target="basefrm">dmxmap.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxmap_8h.html" target="basefrm">dmxmap.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxmotion_8c.html" target="basefrm">dmxmotion.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxmotion_8h.html" target="basefrm">dmxmotion.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxparse_8c.html" target="basefrm">dmxparse.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxparse_8h.html" target="basefrm">dmxparse.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxpict_8c.html" target="basefrm">dmxpict.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxpict_8h.html" target="basefrm">dmxpict.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxpixmap_8c.html" target="basefrm">dmxpixmap.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxpixmap_8h.html" target="basefrm">dmxpixmap.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxprint_8c.html" target="basefrm">dmxprint.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxprint_8h.html" target="basefrm">dmxprint.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxprop_8c.html" target="basefrm">dmxprop.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxprop_8h.html" target="basefrm">dmxprop.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxproto_8h.html" target="basefrm">dmxproto.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxscrinit_8c.html" target="basefrm">dmxscrinit.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxscrinit_8h.html" target="basefrm">dmxscrinit.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxshadow_8c.html" target="basefrm">dmxshadow.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxshadow_8h.html" target="basefrm">dmxshadow.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxsigio_8c.html" target="basefrm">dmxsigio.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxsigio_8h.html" target="basefrm">dmxsigio.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxstat_8c.html" target="basefrm">dmxstat.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxstat_8h.html" target="basefrm">dmxstat.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxsync_8c.html" target="basefrm">dmxsync.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxsync_8h.html" target="basefrm">dmxsync.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxvisual_8c.html" target="basefrm">dmxvisual.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxvisual_8h.html" target="basefrm">dmxvisual.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxwindow_8c.html" target="basefrm">dmxwindow.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxwindow_8h.html" target="basefrm">dmxwindow.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="dmxxinput_8c.html" target="basefrm">dmxxinput.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="lnx-keyboard_8c.html" target="basefrm">lnx-keyboard.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="lnx-keyboard_8h.html" target="basefrm">lnx-keyboard.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="lnx-ms_8c.html" target="basefrm">lnx-ms.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="lnx-ms_8h.html" target="basefrm">lnx-ms.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="lnx-ps2_8c.html" target="basefrm">lnx-ps2.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="lnx-ps2_8h.html" target="basefrm">lnx-ps2.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="usb-common_8c.html" target="basefrm">usb-common.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="usb-common_8h.html" target="basefrm">usb-common.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="usb-keyboard_8c.html" target="basefrm">usb-keyboard.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="usb-keyboard_8h.html" target="basefrm">usb-keyboard.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="usb-mouse_8c.html" target="basefrm">usb-mouse.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="usb-mouse_8h.html" target="basefrm">usb-mouse.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="usb-other_8c.html" target="basefrm">usb-other.c</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="usb-other_8h.html" target="basefrm">usb-other.h</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2lastnode.png" alt="\" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="usb-private_8h.html" target="basefrm">usb-private.h</a></p>
+ </div>
+ <p><img src="ftv2pnode.png" alt="o" width=16 height=22 onclick="toggleFolder('folder2', this)"/><img src="ftv2folderclosed.png" alt="+" width=24 height=22 onclick="toggleFolder('folder2', this)"/><a class="el" href="annotated.html" target="basefrm">Data Structures</a></p>
+ <div id="folder2">
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__dmxArg.html" target="basefrm">_dmxArg</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__dmxColormapPriv.html" target="basefrm">_dmxColormapPriv</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXConfigComment.html" target="basefrm">_DMXConfigComment</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXConfigDisplay.html" target="basefrm">_DMXConfigDisplay</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXConfigEntry.html" target="basefrm">_DMXConfigEntry</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXConfigFullDim.html" target="basefrm">_DMXConfigFullDim</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXConfigNumber.html" target="basefrm">_DMXConfigNumber</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXConfigOption.html" target="basefrm">_DMXConfigOption</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXConfigPair.html" target="basefrm">_DMXConfigPair</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXConfigParam.html" target="basefrm">_DMXConfigParam</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXConfigPartDim.html" target="basefrm">_DMXConfigPartDim</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXConfigString.html" target="basefrm">_DMXConfigString</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXConfigSub.html" target="basefrm">_DMXConfigSub</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXConfigToken.html" target="basefrm">_DMXConfigToken</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXConfigVirtual.html" target="basefrm">_DMXConfigVirtual</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXConfigWall.html" target="basefrm">_DMXConfigWall</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__dmxCursorPriv.html" target="basefrm">_dmxCursorPriv</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXEventMap.html" target="basefrm">_DMXEventMap</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__dmxFontPriv.html" target="basefrm">_dmxFontPriv</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__dmxGCPriv.html" target="basefrm">_dmxGCPriv</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__dmxGlyphPriv.html" target="basefrm">_dmxGlyphPriv</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXInputInfo.html" target="basefrm">_DMXInputInfo</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXLocalInitInfo.html" target="basefrm">_DMXLocalInitInfo</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXLocalInputInfo.html" target="basefrm">_DMXLocalInputInfo</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__dmxPictPriv.html" target="basefrm">_dmxPictPriv</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__dmxPixPriv.html" target="basefrm">_dmxPixPriv</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXScreenInfo.html" target="basefrm">_DMXScreenInfo</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXStatAvg.html" target="basefrm">_DMXStatAvg</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__DMXStatInfo.html" target="basefrm">_DMXStatInfo</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__dmxWinPriv.html" target="basefrm">_dmxWinPriv</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__Event.html" target="basefrm">_Event</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__EventQueue.html" target="basefrm">_EventQueue</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="struct__myPrivate.html" target="basefrm">_myPrivate</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structDMXConfigCmdStruct.html" target="basefrm">DMXConfigCmdStruct</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structDMXConfigListStruct.html" target="basefrm">DMXConfigListStruct</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structDMXDesktopAttributes.html" target="basefrm">DMXDesktopAttributes</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structDMXDesktopAttributesRec.html" target="basefrm">DMXDesktopAttributesRec</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structdmxGlxVisualPrivate.html" target="basefrm">dmxGlxVisualPrivate</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structDMXInputAttributes.html" target="basefrm">DMXInputAttributes</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structDMXInputAttributesRec.html" target="basefrm">DMXInputAttributesRec</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structDMXScreenAttributes.html" target="basefrm">DMXScreenAttributes</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structDMXScreenAttributesRec.html" target="basefrm">DMXScreenAttributesRec</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structDMXWindowAttributes.html" target="basefrm">DMXWindowAttributes</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structDMXWindowAttributesRec.html" target="basefrm">DMXWindowAttributesRec</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXAddInputReply.html" target="basefrm">xDMXAddInputReply</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXAddInputReq.html" target="basefrm">xDMXAddInputReq</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXAddScreenReply.html" target="basefrm">xDMXAddScreenReply</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXAddScreenReq.html" target="basefrm">xDMXAddScreenReq</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXChangeDesktopAttributesReply.html" target="basefrm">xDMXChangeDesktopAttributesReply</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXChangeDesktopAttributesReq.html" target="basefrm">xDMXChangeDesktopAttributesReq</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXChangeScreensAttributesReply.html" target="basefrm">xDMXChangeScreensAttributesReply</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXChangeScreensAttributesReq.html" target="basefrm">xDMXChangeScreensAttributesReq</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXForceWindowCreationReply.html" target="basefrm">xDMXForceWindowCreationReply</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXForceWindowCreationReq.html" target="basefrm">xDMXForceWindowCreationReq</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXGetDesktopAttributesReply.html" target="basefrm">xDMXGetDesktopAttributesReply</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXGetDesktopAttributesReq.html" target="basefrm">xDMXGetDesktopAttributesReq</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXGetInputAttributesReply.html" target="basefrm">xDMXGetInputAttributesReply</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXGetInputAttributesReq.html" target="basefrm">xDMXGetInputAttributesReq</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXGetInputCountReply.html" target="basefrm">xDMXGetInputCountReply</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXGetInputCountReq.html" target="basefrm">xDMXGetInputCountReq</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXGetScreenAttributesReply.html" target="basefrm">xDMXGetScreenAttributesReply</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXGetScreenAttributesReq.html" target="basefrm">xDMXGetScreenAttributesReq</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXGetScreenCountReply.html" target="basefrm">xDMXGetScreenCountReply</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXGetScreenCountReq.html" target="basefrm">xDMXGetScreenCountReq</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXGetWindowAttributesReply.html" target="basefrm">xDMXGetWindowAttributesReply</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXGetWindowAttributesReq.html" target="basefrm">xDMXGetWindowAttributesReq</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXQueryVersionReply.html" target="basefrm">xDMXQueryVersionReply</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXQueryVersionReq.html" target="basefrm">xDMXQueryVersionReq</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXRemoveInputReply.html" target="basefrm">xDMXRemoveInputReply</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXRemoveInputReq.html" target="basefrm">xDMXRemoveInputReq</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXRemoveScreenReply.html" target="basefrm">xDMXRemoveScreenReply</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXRemoveScreenReq.html" target="basefrm">xDMXRemoveScreenReq</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXSyncReply.html" target="basefrm">xDMXSyncReply</a></p>
+ <p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2lastnode.png" alt="\" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="structxDMXSyncReq.html" target="basefrm">xDMXSyncReq</a></p>
+ </div>
+ <p><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="functions.html" target="basefrm">Data Fields</a></p>
+ <p><img src="ftv2lastnode.png" alt="\" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="globals.html" target="basefrm">Globals</a></p>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-common_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-common_8c.html
new file mode 100644
index 000000000..3c1882a5b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-common_8c.html
@@ -0,0 +1,222 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>usb-common.c File Reference</h1><code>#include "<a class="el" href="usb-private_8h-source.html">usb-private.h</a>"</code><br>
+<code>#include "<a class="el" href="usb-mouse_8h-source.html">usb-mouse.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-common_8c.html#a21">usbRead</a> (DevicePtr pDev, MOTIONPROC motion, ENQUEUEPROC enqueue, int minButton, BLOCK block)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-common_8c.html#a23">usbInit</a> (DevicePtr pDev, usbType type)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-common_8c.html#a24">usbOff</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>pointer&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-common_8c.html#a25">usbCreatePrivate</a> (DeviceIntPtr pDevice)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-common_8c.html#a26">usbDestroyPrivate</a> (pointer priv)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Routines that are common between #usb-keyboard.c, #usb-mouse.c, and #usb-other.c<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a25" doxytag="usb-common.c::usbCreatePrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> pointer usbCreatePrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDevice</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a private structure for use within this file. </td>
+ </tr>
+</table>
+<a class="anchor" name="a26" doxytag="usb-common.c::usbDestroyPrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void usbDestroyPrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>priv</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy a private structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="usb-common.c::usbInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void usbInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>usbType&nbsp;</td>
+ <td class="mdname" nowrap> <em>type</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialized <em>pDev</em> as a <em>usbMouse</em>, <em>usbKeyboard</em>, or <em>usbOther</em> device. </td>
+ </tr>
+</table>
+<a class="anchor" name="a24" doxytag="usb-common.c::usbOff" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void usbOff </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> off (i.e., stop taking input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a21" doxytag="usb-common.c::usbRead" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void usbRead </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>MOTIONPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>motion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>ENQUEUEPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>enqueue</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>int&nbsp;</td>
+ <td class="mdname" nowrap> <em>minButton</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>BLOCK&nbsp;</td>
+ <td class="mdname" nowrap> <em>block</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Read an event from the <em>pDev</em> device. If the event is a motion event, enqueue it with the <em>motion</em> function. Otherwise, enqueue the event with the <em>enqueue</em> function. The <em>block</em> type is passed to the functions so that they may block SIGIO handling as appropriate to the caller of this function.<p>
+Since USB devices return EV_KEY events for buttons and keys, <em>minButton</em> is used to decide if a Button or Key event should be queued. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-common_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-common_8h-source.html
new file mode 100644
index 000000000..422ce1ff7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-common_8h-source.html
@@ -0,0 +1,74 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>usb-common.h</h1><a href="usb-common_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00039 <span class="preprocessor">#ifndef _USB_COMMON_H_</span>
+00040 <span class="preprocessor"></span><span class="preprocessor">#define _USB_COMMON_H_</span>
+00041 <span class="preprocessor"></span><span class="keyword">typedef</span> <span class="keyword">enum</span> {
+00042 usbMouse,
+00043 usbKeyboard,
+00044 usbOther
+00045 } usbType;
+00046
+00047 <span class="keyword">extern</span> pointer <a class="code" href="usb-common_8c.html#a25">usbCreatePrivate</a>(DeviceIntPtr pDevice);
+00048 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="usb-common_8c.html#a26">usbDestroyPrivate</a>(pointer priv);
+00049 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="usb-common_8c.html#a21">usbRead</a>(DevicePtr pDev,
+00050 dmxMotionProcPtr motion,
+00051 dmxEnqueueProcPtr enqueue,
+00052 <span class="keywordtype">int</span> minButton,
+00053 DMXBlockType block);
+00054 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="usb-common_8c.html#a23">usbInit</a>(DevicePtr pDev, usbType type);
+00055 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="usb-common_8c.html#a24">usbOff</a>(DevicePtr pDev);
+00056 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-common_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-common_8h.html
new file mode 100644
index 000000000..846695551
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-common_8h.html
@@ -0,0 +1,167 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>usb-common.h File Reference</h1>
+<p>
+<a href="usb-common_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>pointer&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-common_8h.html#a3">usbCreatePrivate</a> (DeviceIntPtr pDevice)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-common_8h.html#a4">usbDestroyPrivate</a> (pointer priv)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-common_8h.html#a6">usbInit</a> (DevicePtr pDev, usbType type)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-common_8h.html#a7">usbOff</a> (DevicePtr pDev)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to common USB support. <dl compact><dt><b>See also:</b></dt><dd>usb-common.c <p>
+usb-mouse.c <p>
+usb-keyboard.c <p>
+usb-other.c</dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a3" doxytag="usb-common.h::usbCreatePrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> pointer usbCreatePrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DeviceIntPtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDevice</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Create a private structure for use within this file. </td>
+ </tr>
+</table>
+<a class="anchor" name="a4" doxytag="usb-common.h::usbDestroyPrivate" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void usbDestroyPrivate </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">pointer&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>priv</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Destroy a private structure. </td>
+ </tr>
+</table>
+<a class="anchor" name="a6" doxytag="usb-common.h::usbInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void usbInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>usbType&nbsp;</td>
+ <td class="mdname" nowrap> <em>type</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialized <em>pDev</em> as a <em>usbMouse</em>, <em>usbKeyboard</em>, or <em>usbOther</em> device. </td>
+ </tr>
+</table>
+<a class="anchor" name="a7" doxytag="usb-common.h::usbOff" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void usbOff </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> off (i.e., stop taking input from <em>pDev</em>). </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-keyboard_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-keyboard_8c.html
new file mode 100644
index 000000000..5da5a0b3b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-keyboard_8c.html
@@ -0,0 +1,231 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>usb-keyboard.c File Reference</h1><code>#include "atKeynames.h"</code><br>
+<code>#include "<a class="el" href="usb-private_8h-source.html">usb-private.h</a>"</code><br>
+<code>#include "<a class="el" href="usb-keyboard_8h-source.html">usb-keyboard.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-keyboard_8c.html#a20">kbdUSBCtrl</a> (DevicePtr pDev, KeybdCtrl *ctrl)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-keyboard_8c.html#a21">kbdUSBInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-keyboard_8c.html#a23">kbdUSBRead</a> (DevicePtr pDev, MOTIONPROC motion, ENQUEUEPROC enqueue, CHECKPROC checkspecial, BLOCK block)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-keyboard_8c.html#a24">kbdUSBOn</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-keyboard_8c.html#a26">kbdUSBGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This code implements a low-level device driver for a USB keyboard under Linux. The keymap description is derived from code by Thomas Roell, Orest Zborowski.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a20" doxytag="usb-keyboard.c::kbdUSBCtrl" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdUSBCtrl </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>KeybdCtrl *&nbsp;</td>
+ <td class="mdname" nowrap> <em>ctrl</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set the LEDs. </td>
+ </tr>
+</table>
+<a class="anchor" name="a26" doxytag="usb-keyboard.c::kbdUSBGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdUSBGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill the <em>info</em> structure with information needed to initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a21" doxytag="usb-keyboard.c::kbdUSBInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdUSBInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize <em>pDev</em> using <a class="el" href="usb-common_8h.html#a6">usbInit</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a24" doxytag="usb-keyboard.c::kbdUSBOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int kbdUSBOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a23" doxytag="usb-keyboard.c::kbdUSBRead" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdUSBRead </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>MOTIONPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>motion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>ENQUEUEPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>enqueue</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CHECKPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>checkspecial</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>BLOCK&nbsp;</td>
+ <td class="mdname" nowrap> <em>block</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Read an event from the <em>pDev</em> device. If the event is a motion event, enqueue it with the <em>motion</em> function. Otherwise, check for special keys with the <em>checkspecial</em> function and enqueue the event with the <em>enqueue</em> function. The <em>block</em> type is passed to the functions so that they may block SIGIO handling as appropriate to the caller of this function. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-keyboard_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-keyboard_8h-source.html
new file mode 100644
index 000000000..1f03b2483
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-keyboard_8h-source.html
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>usb-keyboard.h</h1><a href="usb-keyboard_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _USB_KEYBOARD_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _USB_KEYBOARD_H_</span>
+00040 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="usb-keyboard_8c.html#a21">kbdUSBInit</a>(DevicePtr pDev);
+00041 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="usb-keyboard_8c.html#a26">kbdUSBGetInfo</a>(DevicePtr pDev, <a class="code" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info);
+00042 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="usb-keyboard_8c.html#a24">kbdUSBOn</a>(DevicePtr pDev);
+00043 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="usb-keyboard_8c.html#a23">kbdUSBRead</a>(DevicePtr pDev,
+00044 dmxMotionProcPtr motion,
+00045 dmxEnqueueProcPtr enqueue,
+00046 dmxCheckSpecialProcPtr checkspecial,
+00047 DMXBlockType block);
+00048 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="usb-keyboard_8c.html#a20">kbdUSBCtrl</a>(DevicePtr pDev, KeybdCtrl *ctrl);
+00049 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-keyboard_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-keyboard_8h.html
new file mode 100644
index 000000000..23f48a73a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-keyboard_8h.html
@@ -0,0 +1,174 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>usb-keyboard.h File Reference</h1>
+<p>
+<a href="usb-keyboard_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-keyboard_8h.html#a0">kbdUSBInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-keyboard_8h.html#a1">kbdUSBGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-keyboard_8h.html#a2">kbdUSBOn</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-keyboard_8h.html#a4">kbdUSBCtrl</a> (DevicePtr pDev, KeybdCtrl *ctrl)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to USB keyboard driver. <dl compact><dt><b>See also:</b></dt><dd>usb-keyboard.c <p>
+usb-common.c</dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a4" doxytag="usb-keyboard.h::kbdUSBCtrl" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdUSBCtrl </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>KeybdCtrl *&nbsp;</td>
+ <td class="mdname" nowrap> <em>ctrl</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Set the LEDs. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="usb-keyboard.h::kbdUSBGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdUSBGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill the <em>info</em> structure with information needed to initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a0" doxytag="usb-keyboard.h::kbdUSBInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void kbdUSBInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize <em>pDev</em> using <a class="el" href="usb-common_8h.html#a6">usbInit</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a2" doxytag="usb-keyboard.h::kbdUSBOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int kbdUSBOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-mouse_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-mouse_8c.html
new file mode 100644
index 000000000..ea3767d19
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-mouse_8c.html
@@ -0,0 +1,190 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>usb-mouse.c File Reference</h1><code>#include "<a class="el" href="usb-private_8h-source.html">usb-private.h</a>"</code><br>
+<code>#include "<a class="el" href="usb-mouse_8h-source.html">usb-mouse.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-mouse_8c.html#a12">mouUSBRead</a> (DevicePtr pDev, MOTIONPROC motion, ENQUEUEPROC enqueue, CHECKPROC checkspecial, BLOCK block)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-mouse_8c.html#a13">mouUSBInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-mouse_8c.html#a14">mouUSBOn</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-mouse_8c.html#a16">mouUSBGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This code implements a low-level device driver for a USB mouse.<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a16" doxytag="usb-mouse.c::mouUSBGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void mouUSBGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill the <em>info</em> structure with information needed to initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="usb-mouse.c::mouUSBInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void mouUSBInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize <em>pDev</em> using <a class="el" href="usb-common_8h.html#a6">usbInit</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="usb-mouse.c::mouUSBOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int mouUSBOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a12" doxytag="usb-mouse.c::mouUSBRead" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void mouUSBRead </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>MOTIONPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>motion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>ENQUEUEPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>enqueue</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CHECKPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>checkspecial</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>BLOCK&nbsp;</td>
+ <td class="mdname" nowrap> <em>block</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Read the USB device using <a class="el" href="usb-common_8c.html#a21">usbRead</a>. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-mouse_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-mouse_8h-source.html
new file mode 100644
index 000000000..12fbbcd52
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-mouse_8h-source.html
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>usb-mouse.h</h1><a href="usb-mouse_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _USB_MOU_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _USB_MOU_H_</span>
+00040 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="usb-mouse_8c.html#a12">mouUSBRead</a>(DevicePtr pDev,
+00041 dmxMotionProcPtr motion,
+00042 dmxEnqueueProcPtr enqueue,
+00043 dmxCheckSpecialProcPtr checkspecial,
+00044 DMXBlockType block);
+00045 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="usb-mouse_8c.html#a13">mouUSBInit</a>(DevicePtr pDev);
+00046 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="usb-mouse_8c.html#a16">mouUSBGetInfo</a>(DevicePtr pDev, <a class="code" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info);
+00047 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="usb-mouse_8c.html#a14">mouUSBOn</a>(DevicePtr pDev);
+00048 <span class="keyword">extern</span> <span class="keywordtype">void</span> mouUSBCtrl(DevicePtr pDev, PtrCtrl *ctrl);
+00049 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-mouse_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-mouse_8h.html
new file mode 100644
index 000000000..ac03fe55b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-mouse_8h.html
@@ -0,0 +1,134 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>usb-mouse.h File Reference</h1>
+<p>
+<a href="usb-mouse_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-mouse_8h.html#a1">mouUSBInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-mouse_8h.html#a2">mouUSBGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-mouse_8h.html#a3">mouUSBOn</a> (DevicePtr pDev)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to USB mouse driver. <dl compact><dt><b>See also:</b></dt><dd>usb-mouse.c <p>
+usb-common.c</dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a2" doxytag="usb-mouse.h::mouUSBGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void mouUSBGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill the <em>info</em> structure with information needed to initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="usb-mouse.h::mouUSBInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void mouUSBInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize <em>pDev</em> using <a class="el" href="usb-common_8h.html#a6">usbInit</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="usb-mouse.h::mouUSBOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int mouUSBOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-other_8c.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-other_8c.html
new file mode 100644
index 000000000..284b4b79b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-other_8c.html
@@ -0,0 +1,191 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>usb-other.c File Reference</h1><code>#include "<a class="el" href="usb-private_8h-source.html">usb-private.h</a>"</code><br>
+<code>#include "<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>"</code><br>
+<code>#include "<a class="el" href="usb-other_8h-source.html">usb-other.h</a>"</code><br>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-other_8c.html#a13">othUSBRead</a> (DevicePtr pDev, MOTIONPROC motion, ENQUEUEPROC enqueue, CHECKPROC checkspecial, BLOCK block)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-other_8c.html#a14">othUSBInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-other_8c.html#a15">othUSBOn</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-other_8c.html#a16">othUSBGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+This code implements a low-level device driver for a non-keyboard, non-mouse USB device (e.g., a joystick or gamepad).<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a16" doxytag="usb-other.c::othUSBGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void othUSBGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill the <em>info</em> structure with information needed to initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a14" doxytag="usb-other.c::othUSBInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void othUSBInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize <em>pDev</em> using <a class="el" href="usb-common_8h.html#a6">usbInit</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a15" doxytag="usb-other.c::othUSBOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int othUSBOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+<a class="anchor" name="a13" doxytag="usb-other.c::othUSBRead" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void othUSBRead </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>MOTIONPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>motion</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>ENQUEUEPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>enqueue</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>CHECKPROC&nbsp;</td>
+ <td class="mdname" nowrap> <em>checkspecial</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap>BLOCK&nbsp;</td>
+ <td class="mdname" nowrap> <em>block</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Read the USB device using <a class="el" href="usb-common_8c.html#a21">usbRead</a>. </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-other_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-other_8h-source.html
new file mode 100644
index 000000000..d5cd221ff
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-other_8h-source.html
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>usb-other.h</h1><a href="usb-other_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00038 <span class="preprocessor">#ifndef _USB_OTHER_H_</span>
+00039 <span class="preprocessor"></span><span class="preprocessor">#define _USB_OTHER_H_</span>
+00040 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="usb-other_8c.html#a13">othUSBRead</a>(DevicePtr pDev,
+00041 dmxMotionProcPtr motion,
+00042 dmxEnqueueProcPtr enqueue,
+00043 dmxCheckSpecialProcPtr checkspecial,
+00044 DMXBlockType block);
+00045 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="usb-other_8c.html#a14">othUSBInit</a>(DevicePtr pDev);
+00046 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="usb-other_8c.html#a16">othUSBGetInfo</a>(DevicePtr pDev, <a class="code" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info);
+00047 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="usb-other_8c.html#a15">othUSBOn</a>(DevicePtr pDev);
+00048 <span class="keyword">extern</span> <span class="keywordtype">void</span> othUSBCtrl(DevicePtr pDev, PtrCtrl *ctrl);
+00049 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-other_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-other_8h.html
new file mode 100644
index 000000000..d3c80ae02
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-other_8h.html
@@ -0,0 +1,134 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>usb-other.h File Reference</h1>
+<p>
+<a href="usb-other_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Functions</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-other_8h.html#a1">othUSBInit</a> (DevicePtr pDev)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-other_8h.html#a2">othUSBGetInfo</a> (DevicePtr pDev, <a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a> info)</td></tr>
+
+<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="usb-other_8h.html#a3">othUSBOn</a> (DevicePtr pDev)</td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Interface to USB generic driver. <dl compact><dt><b>See also:</b></dt><dd>usb-other.c <p>
+usb-common.c</dd></dl>
+<hr><h2>Function Documentation</h2>
+<a class="anchor" name="a2" doxytag="usb-other.h::othUSBGetInfo" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void othUSBGetInfo </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname" nowrap> <em>pDev</em>, </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td class="md" nowrap><a class="el" href="struct__DMXLocalInitInfo.html">DMXLocalInitInfoPtr</a>&nbsp;</td>
+ <td class="mdname" nowrap> <em>info</em></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td class="md">)&nbsp;</td>
+ <td class="md" colspan="2"></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Fill the <em>info</em> structure with information needed to initialize <em>pDev</em>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a1" doxytag="usb-other.h::othUSBInit" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> void othUSBInit </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Initialize <em>pDev</em> using <a class="el" href="usb-common_8h.html#a6">usbInit</a>. </td>
+ </tr>
+</table>
+<a class="anchor" name="a3" doxytag="usb-other.h::othUSBOn" ></a><p>
+<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
+ <tr>
+ <td class="mdRow">
+ <table cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td class="md" nowrap valign="top"> int othUSBOn </td>
+ <td class="md" valign="top">(&nbsp;</td>
+ <td class="md" nowrap valign="top">DevicePtr&nbsp;</td>
+ <td class="mdname1" valign="top" nowrap> <em>pDev</em> </td>
+ <td class="md" valign="top">&nbsp;)&nbsp;</td>
+ <td class="md" nowrap></td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+</table>
+<table cellspacing=5 cellpadding=0 border=0>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ <td>
+
+<p>
+Turn <em>pDev</em> on (i.e., take input from <em>pDev</em>). </td>
+ </tr>
+</table>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-private_8h-source.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-private_8h-source.html
new file mode 100644
index 000000000..3baac9582
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-private_8h-source.html
@@ -0,0 +1,131 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>usb-private.h</h1><a href="usb-private_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* $XFree86$ */</span>
+00002 <span class="comment">/*</span>
+00003 <span class="comment"> * Copyright 2002 Red Hat Inc., Durham, North Carolina.</span>
+00004 <span class="comment"> *</span>
+00005 <span class="comment"> * All Rights Reserved.</span>
+00006 <span class="comment"> *</span>
+00007 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span>
+00008 <span class="comment"> * a copy of this software and associated documentation files (the</span>
+00009 <span class="comment"> * "Software"), to deal in the Software without restriction, including</span>
+00010 <span class="comment"> * without limitation on the rights to use, copy, modify, merge,</span>
+00011 <span class="comment"> * publish, distribute, sublicense, and/or sell copies of the Software,</span>
+00012 <span class="comment"> * and to permit persons to whom the Software is furnished to do so,</span>
+00013 <span class="comment"> * subject to the following conditions:</span>
+00014 <span class="comment"> *</span>
+00015 <span class="comment"> * The above copyright notice and this permission notice (including the</span>
+00016 <span class="comment"> * next paragraph) shall be included in all copies or substantial</span>
+00017 <span class="comment"> * portions of the Software.</span>
+00018 <span class="comment"> *</span>
+00019 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,</span>
+00020 <span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
+00021 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
+00022 <span class="comment"> * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS</span>
+00023 <span class="comment"> * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN</span>
+00024 <span class="comment"> * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN</span>
+00025 <span class="comment"> * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
+00026 <span class="comment"> * SOFTWARE.</span>
+00027 <span class="comment"> */</span>
+00028
+00029 <span class="comment">/*</span>
+00030 <span class="comment"> * Authors:</span>
+00031 <span class="comment"> * Rickard E. (Rik) Faith &lt;faith@redhat.com&gt;</span>
+00032 <span class="comment"> *</span>
+00033 <span class="comment"> */</span>
+00034
+00041 <span class="preprocessor">#ifndef _USB_PRIVATE_H_</span>
+00042 <span class="preprocessor"></span><span class="preprocessor">#define _USB_PRIVATE_H_</span>
+00043 <span class="preprocessor"></span>
+00044 <span class="preprocessor">#include "<a class="code" href="dmxinputinit_8h.html">dmxinputinit.h</a>"</span>
+00045 <span class="preprocessor">#include "inputstr.h"</span>
+00046 <span class="preprocessor">#include "Xos.h"</span>
+00047 <span class="preprocessor">#include &lt;errno.h&gt;</span>
+00048 <span class="preprocessor">#include &lt;linux/input.h&gt;</span>
+00049 <span class="preprocessor">#include "<a class="code" href="usb-common_8h.html">usb-common.h</a>"</span>
+00050
+00051 <span class="comment">/* Support for force feedback was</span>
+00052 <span class="comment"> * introduced in Linxu 2.4.10 */</span>
+00053 <span class="preprocessor">#ifndef EV_MSC</span>
+00054 <span class="preprocessor"></span><span class="preprocessor">#define EV_MSC 0x04</span>
+00055 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00056 <span class="preprocessor"></span><span class="preprocessor">#ifndef EV_FF</span>
+00057 <span class="preprocessor"></span><span class="preprocessor">#define EV_FF 0x15</span>
+00058 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00059 <span class="preprocessor"></span><span class="preprocessor">#ifndef LED_SLEEP</span>
+00060 <span class="preprocessor"></span><span class="preprocessor">#define LED_SLEEP 0x05</span>
+00061 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00062 <span class="preprocessor"></span><span class="preprocessor">#ifndef LED_SUSPEND</span>
+00063 <span class="preprocessor"></span><span class="preprocessor">#define LED_SUSPEND 0x06</span>
+00064 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00065 <span class="preprocessor"></span><span class="preprocessor">#ifndef LED_MUTE</span>
+00066 <span class="preprocessor"></span><span class="preprocessor">#define LED_MUTE 0x07</span>
+00067 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00068 <span class="preprocessor"></span><span class="preprocessor">#ifndef LED_MISC</span>
+00069 <span class="preprocessor"></span><span class="preprocessor">#define LED_MISC 0x08</span>
+00070 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00071 <span class="preprocessor"></span><span class="preprocessor">#ifndef BTN_DEAD</span>
+00072 <span class="preprocessor"></span><span class="preprocessor">#define BTN_DEAD 0x12f</span>
+00073 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00074 <span class="preprocessor"></span><span class="preprocessor">#ifndef BTN_THUMBL</span>
+00075 <span class="preprocessor"></span><span class="preprocessor">#define BTN_THUMBL 0x13d</span>
+00076 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00077 <span class="preprocessor"></span><span class="preprocessor">#ifndef BTN_THUMBR</span>
+00078 <span class="preprocessor"></span><span class="preprocessor">#define BTN_THUMBR 0x13e</span>
+00079 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00080 <span class="preprocessor"></span><span class="preprocessor">#ifndef MSC_SERIAL</span>
+00081 <span class="preprocessor"></span><span class="preprocessor">#define MSC_SERIAL 0x00</span>
+00082 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00083 <span class="preprocessor"></span><span class="preprocessor">#ifndef MSC_MAX</span>
+00084 <span class="preprocessor"></span><span class="preprocessor">#define MSC_MAX 0x07</span>
+00085 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00086 <span class="preprocessor"></span>
+00087 <span class="comment">/* Support for older kernels. */</span>
+00088 <span class="preprocessor">#ifndef ABS_WHEEL</span>
+00089 <span class="preprocessor"></span><span class="preprocessor">#define ABS_WHEEL 0x08</span>
+00090 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00091 <span class="preprocessor"></span><span class="preprocessor">#ifndef ABS_GAS</span>
+00092 <span class="preprocessor"></span><span class="preprocessor">#define ABS_GAS 0x09</span>
+00093 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00094 <span class="preprocessor"></span><span class="preprocessor">#ifndef ABS_BRAKE</span>
+00095 <span class="preprocessor"></span><span class="preprocessor">#define ABS_BRAKE 0x0a</span>
+00096 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
+00097 <span class="preprocessor"></span>
+00098 <span class="preprocessor">#define NUM_STATE_ENTRIES (256/32)</span>
+00099 <span class="preprocessor"></span>
+00100 <span class="comment">/* Private area for USB devices. */</span>
+00101 <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__myPrivate.html">_myPrivate</a> {
+<a name="l00102"></a><a class="code" href="struct__myPrivate.html#o55">00102</a> DeviceIntPtr <a class="code" href="struct__myPrivate.html#o55">pDevice</a>;
+<a name="l00103"></a><a class="code" href="struct__myPrivate.html#o37">00103</a> <span class="keywordtype">int</span> <a class="code" href="struct__myPrivate.html#o37">fd</a>;
+<a name="l00104"></a><a class="code" href="struct__myPrivate.html#o56">00104</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="struct__myPrivate.html#o56">mask</a>[EV_MAX/8 + 1];
+<a name="l00105"></a><a class="code" href="struct__myPrivate.html#o59">00105</a> <span class="keywordtype">int</span> numRel, numAbs, <a class="code" href="struct__myPrivate.html#o59">numLeds</a>;
+<a name="l00106"></a><a class="code" href="struct__myPrivate.html#o60">00106</a> <span class="keywordtype">int</span> <a class="code" href="struct__myPrivate.html#o60">relmap</a>[DMX_MAX_AXES];
+<a name="l00107"></a><a class="code" href="struct__myPrivate.html#o61">00107</a> <span class="keywordtype">int</span> <a class="code" href="struct__myPrivate.html#o61">absmap</a>[DMX_MAX_AXES];
+<a name="l00109"></a><a class="code" href="struct__myPrivate.html#o43">00109</a> CARD32 <a class="code" href="struct__myPrivate.html#o43">kbdState</a>[NUM_STATE_ENTRIES];
+00110 DeviceIntPtr pKeyboard;
+<a name="l00112"></a><a class="code" href="struct__myPrivate.html#o49">00112</a> <span class="keywordtype">int</span> <a class="code" href="struct__myPrivate.html#o49">pitch</a>;
+<a name="l00113"></a><a class="code" href="struct__myPrivate.html#o50">00113</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="struct__myPrivate.html#o50">duration</a>;
+00115 <span class="comment">/* FIXME: dmxInput is never initialized */</span>
+<a name="l00116"></a><a class="code" href="struct__myPrivate.html#o62">00116</a> <a class="code" href="struct__DMXInputInfo.html">DMXInputInfo</a> *<a class="code" href="struct__myPrivate.html#o62">dmxInput</a>;
+00117 } <a class="code" href="struct__myPrivate.html">myPrivate</a>;
+00118 <span class="preprocessor">#endif</span>
+</pre></div> <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-private_8h.html b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-private_8h.html
new file mode 100644
index 000000000..360d88290
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/html/usb-private_8h.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+ <title>File Index</title>
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+ </head>
+ <body>
+<!-- Generated by Doxygen 1.3.4 -->
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
+<h1>usb-private.h File Reference</h1><code>#include "<a class="el" href="dmxinputinit_8h-source.html">dmxinputinit.h</a>"</code><br>
+<code>#include "inputstr.h"</code><br>
+<code>#include "Xos.h"</code><br>
+<code>#include &lt;errno.h&gt;</code><br>
+<code>#include &lt;linux/input.h&gt;</code><br>
+<code>#include "<a class="el" href="usb-common_8h-source.html">usb-common.h</a>"</code><br>
+
+<p>
+<a href="usb-private_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
+<tr><td></td></tr>
+<tr><td colspan=2><br><h2>Data Structures</h2></td></tr>
+<tr><td class="memItemLeft" nowrap align=right valign=top>struct &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct__myPrivate.html">_myPrivate</a></td></tr>
+
+</table>
+<hr><a name="_details"></a><h2>Detailed Description</h2>
+Private header file for USB support. This file provides Linux-specific include files and the definition of the private structure. <dl compact><dt><b>See also:</b></dt><dd>usb-common.c <p>
+usb-keyboard.c <p>
+usb-mouse.c <p>
+usb-other.c</dd></dl>
+ <hr>
+ <address>
+ <small>
+ Generated June 29, 2004 for <a
+ href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+ <a href="http://www.doxygen.org/index.html">doxygen</a>
+ 1.3.4.
+ </small>
+ </addres>
+ </hr>
+ </body>
+</html>
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/scaled.sgml b/nx-X11/programs/Xserver/hw/dmx/doc/scaled.sgml
new file mode 100644
index 000000000..6b8ee413f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/scaled.sgml
@@ -0,0 +1,707 @@
+<!DOCTYPE linuxdoc PUBLIC "-//XFree86//DTD linuxdoc//EN">
+ <article>
+
+ <!-- Title information -->
+ <title>Scaled Window Support in DMX</title>
+ <author>Rickard E. Faith and Kevin E. Martin</author>
+ <date>15 October 2003 (created 19 September 2003)</date>
+ <abstract>
+ This document investigates the possibility of adding scaled window
+ support to the DMX X server, thereby allowing a window or some
+ selected part of the logical DMX area to be displayed using a
+ scaling factor. For example, this might allow the contents of a
+ window to be magnified for easier viewing. In particular, scaling
+ for the VNC client is explored. <it>Copyright 2003
+ by Red Hat, Inc., Raleigh, North Carolina</it>
+ </abstract>
+
+ <!-- Table of contents -->
+ <toc>
+
+ <!-- Begin the document -->
+ <sect>Introduction
+ <sect1>DMX
+ <p>
+ The DMX X server (Xdmx) is a proxy server that is designed
+ to allow X servers on multiple machines to be combined into
+ a single multi-headed X server. Combined with Xinerama,
+ these heads can appear as a single very high-resolution
+ screen. Typical applications include the creation of a
+ video wall with 16 1280x1024 displays arranged in a
+ rectangle, for a total resolution of of 5120x4096.
+ </p>
+ </sect1>
+ <sect1>Problem Statement
+ <p>
+ Applications displayed on a physically large video wall that
+ provides high pixel-resolution may be difficult to see,
+ especially if the application is designed for use on a
+ typical desktop computer with a relatively small display
+ located close to the human operator. The goal of this paper
+ is to describe and discuss solutions to this problem.
+ </p>
+ <p>
+ The original driving problem for this work is to provide
+ scaling for the <tt>vncviewer</tt> application when
+ displayed using DMX (VNC scaling is currently available only
+ with the Windows client, and there is no plan to extend that
+ capability to other clients). While this specific problem
+ will be addressed in this paper, the general solution space
+ will also be explored, since this may lead to a good
+ solution not only for <tt>vncviewer</tt> but also for
+ other applications.
+ </p>
+ </sect1>
+ <sect1>Task
+ <p>
+ For reference, here is the original description of the task
+ this paper addresses:
+ <itemize>
+ <item>Scaled window support (for VNC)
+ <itemize>
+ <item>
+ Investigate possibility of implementing a "scaled
+ window" extension:
+ <itemize>
+ <item>
+ Add XCreateScaledWindow call that could be used
+ in place of XCreateWindow
+ </item>
+ <item>
+ All primitives drawn to scaled window would be
+ scaled by appropriate (integral?) scaling factor
+ </item>
+ </itemize>
+ </item>
+ <item>
+ Alternate approach: special case VNC support
+ </item>
+ </itemize>
+ </item>
+ </itemize>
+ </p>
+ </sect1>
+ </sect>
+
+ <sect>Previous Work
+ <p>
+ This section reviews relevant previous work.
+ </p>
+ <sect1>VNC
+ <sect2>Scaling under VNC
+ <p>
+ When using the <tt>vncviewer</tt> program for Windows, it
+ is possible to specify a scaling factor (as numerator and
+ denominator). When scaling is in effect, the viewer
+ software uses StretchBlt (instead of BitBlt) to display
+ the pixels for the user. When this call is made, the
+ viewer already has received all of the pixel information
+ (at full unscaled resolution).
+ </p>
+ <p>
+ The scaling in VNC is primitive. It does not conserve
+ bandwidth, it does not treat textual information
+ differently (i.e., by using a suitably scaled font), and
+ it does not provide any anti-aliasing other than that
+ provided by the underlying (Windows-only) system library.
+ </p>
+ </sect2>
+ </sect1>
+ <sect1>The X Video Extension
+ <p>
+ The X Video Extension is a widely-available extension to the
+ X11 protocol that provides support for streaming video.
+ Integral to this support is the ability to arbitrarily scale
+ the output. In version 2.2 of the X Video specification,
+ support for scaled still images was provided, using both
+ shared memory and traditional transport. The API for this
+ support uses calls that are quite similar to XCreateWindow,
+ XPutImage, and XShmPutImage. Currently, most of the drivers
+ implemented in XFree86 only support data in various YUV
+ formats. However, several modern video adaptors support RGB
+ as well.
+ </p>
+ <p>
+ Note, though, that the target output for this scaling is an
+ overlay plane -- so X Video provides functionality that is
+ fundamentally different from that provided by the Windows
+ StrechBlt call.
+ </p>
+ </sect1>
+ </sect>
+
+ <sect>Possible Solutions
+ <p>
+ This section briefly discusses possible solutions, including
+ major advantages and disadvantages from both the
+ implementation and the end-user programmer standpoint.
+ </p>
+ <sect1>VNC-like Scaling
+ <sect2>Software Scaling
+ <p>
+ The <tt>vncviewer</tt> application could be modified to
+ provide software scaling. This is not a general solution,
+ but it does solve one of the goals of this work.
+ </p>
+ <p>
+ A prototype of this solution was implemented and a patch
+ against <tt>vnc-3.3.7-unixsrc</tt> is available in the
+ <tt>dmx/external</tt> directory. Because of limited time
+ available for this work, all of the edge cases were not
+ considered and the solution works well mainly for integer
+ scaling.
+ </p>
+ <p>
+ Currently, <tt>vncviewer</tt> writes to the X display
+ with XPutImage, XCopyArea, and XFillRectangle. All
+ instances of these calls have to be aware of scaling
+ and must round correctly. In the prototype solution,
+ rounding is incorrect and can cause artifacts.
+ </p>
+ <p>
+ A better solution would be to cache all updates to the
+ desktop image in <tt>vncviewer</tt> and only send the
+ damaged area to the X display with XPutImage. This would
+ allow the damaged area to be computed so that rounding
+ errors do not create artifacts. This method is probably
+ similar to what is used in the Window client. (The whole
+ VNC suite is being re-written in C++ and the forthcoming
+ version 4 has not been evaluated.)
+ </p>
+ </sect2>
+ <sect2>Scaling with the X Video Extension
+ <p>
+ The scaling in the Windows <tt>vncviewer</tt> application
+ makes use of a scaled blit that is supplied by the
+ underlying system library. Several video cards currently
+ provide support for a scaled blit, and some X servers
+ (including XFree86) expose this capability to applications
+ via the XvPutImage interface of the X Video Extension.
+ The capability exposed by XvPutImage results in the scaled
+ image being drawn to an overlay plane. Most video cards
+ also provide support for a scaled blit into the normal
+ output planes, but this is not exposed via XvPutImage.
+ </p>
+ <p>
+ The <tt>vncviewer</tt> program could be modified to use
+ the X Video Extension to provide scaling under X11 that is
+ similar to the scaling currently provided under Windows.
+ Unfortunately, Xdmx does not currently export the X Video
+ Extension, so this would not provide an immediate solution
+ usable with DMX.
+ </p>
+ <p>
+ A very early-stage proof-of-concept prototype was
+ implemented and a preliminary patch against
+ <tt>vnc-3.3.7-unixsrc</tt> is available in the
+ <tt>dmx/external</tt> directory. This prototype was
+ implemented to better understand the problems that must be
+ solved to make this solution viable:
+ <itemize>
+ <item>
+ As noted under the software scaling section above,
+ <tt>vncviewer</tt> writes to the X display with
+ several different calls. These calls write to the
+ normal output planes and are compatible with
+ XvPutImage, which writes to an overlay plane. To
+ eliminate artifacts caused by this problem,
+ <tt>vncviewer</tt> should be modified so that a cached
+ copy of the desktop is available, either as a
+ client-side image or a server-side off-screen pixmap,
+ so that XvPutImage would be the only method for
+ writing to the X display.
+ </item>
+ <item>
+ <p>
+ Although several modern graphics adaptors support
+ hardware scaling using an RGB format (e.g., ATI
+ Radeon, nVidia, etc.), XFree86 drivers typically
+ only implement YUV formats. YUV generally compress
+ the pixel information in some way. For example, two
+ commonly implemented formats, YUY2 and UYVY provide
+ intensity information for every RGB pixel, but only
+ provide chroma and luminance information for pairs
+ of horizontal pixels. Since VNC uses
+ pixel-resolution for communicating updates on the
+ wire, additional artifacts are introduced (because
+ there may not be enough information from the wire to
+ update a pair of pixels).
+ <p>
+ Further, the well-known problem with YUV encoding
+ is even more evident when the image is a desktop
+ instead of a movie. For example, consider a
+ 1-pixel-wide vertical window border. If the border
+ changes in color but not intensity (e.g., because a
+ window manager uses color to indicate focus), there
+ may or may not be a change in the YUY2 image,
+ depending on the algorithm used for RGB to YUV
+ conversion and on how the border pixel is ordered in
+ the pair of pixels used by the algorithm.
+ <p>
+ Many of these artifacts could be eliminated if
+ <tt>vncviewer</tt> cached a complete RGB image of
+ the desktop, and only did the conversion to YUV for
+ properly aligned areas of damage. The remaining artifacts
+ could be eliminated if an RGB format was used with X
+ Video (which may require the extension of existing
+ XFree86 drivers to support RGB).
+ </item>
+ <item>
+ Most modern video cards support exactly one overlay
+ plane that is suitable for use with X Video.
+ Therefore, only one application can use X Video at any
+ given time. This is a severe limitation in a desktop
+ environment.
+ </item>
+ </itemize>
+ </p>
+ <sect3>Implementing the X Video Extension for DMX
+ <p>
+ The user-level API for X Video is fairly simple, but the
+ underlying support required for the full specification
+ is large. However, since the API provides a method to
+ query supported capabilities, a usable subset of X
+ Video can be implemented that would support XvPutImage
+ and little else. This would require support for the
+ following:
+ <itemize>
+ <item>
+ X Video Extension API calls, including the
+ following:
+ <itemize>
+ <item>XvQueryExtension</item>
+ <item>XvQueryAdaptors</item>
+ <item>XvQueryPortAttributes</item>
+ <item>XvFreeAdaptorInfo</item>
+ <item>XvListImageFormats</item>
+ <item>XvGrabPort</item>
+ <item>XvCreateImage</item>
+ <item>XvPutImage</item>
+ <item>XvShmCreateImage</item>
+ <item>XvShmPutImage</item>
+ </itemize>
+ </item>
+ <item>
+ Support for querying back-end X Video Extension
+ capabilities.
+ </item>
+ <item>
+ Support for sending the image to the back-ends.
+ Because X Video requires sending full images, there
+ may be a trade-off between bandwidth limitations and
+ additional complexity to divide the image up such
+ that is scales properly.
+ </item>
+ <item>
+ Possible support for a software fall-back. For
+ example, if all of the back-ends do not support the X
+ Video Extension, software scaling can be implemented
+ such that the image is sent to the back-end with
+ XPutImage. This pathway would have poor
+ performance.
+ </item>
+ </itemize>
+ </p>
+ </sect3>
+ <sect3>Supporting RGB formats for the X Video Extension
+ <p>
+ Assuming an XFree86 driver already supports the X Video
+ Extension, and assuming the target hardware supports an
+ RGB format, then adding support for that format is
+ relatively simple and straightforward.
+ </p>
+ </sect3>
+ </sect2>
+ <sect2>Scaling with an XPutImageScaled Extension
+ <p>
+ Instead of (or in addition to) implementing the X Video
+ Extension in DMX, one obvious solution would be to
+ implement a new extension that provides access to
+ hardware-assisted scaled blits, similar to the StretchBlt
+ call available under Windows. This call would scale RGB
+ images and would not use the overlay plane (unlike the X
+ Video Extension).
+ </p>
+ <p>
+ This approach has many of the same advantages and
+ disadvantages as the XCopyAreaScaled Extension, discussed
+ in the next section. Discussion of XPutImageScaled is
+ deferred in favor of XCopyAreaScaled for the following
+ reasons:
+ <itemize>
+ <item>
+ XPutImageScaled can be emulated with XCopyAreaScaled
+ by first using XPutImage to copy the image to an
+ off-screen pixmap, and then calling XCopyAreaScaled
+ between that off-screen pixmap and the target
+ drawable.
+ </item>
+ <item>
+ Since XCopyAreaScaled would copy between two areas of
+ on-screen or off-screen memory, it has additional uses
+ and can be viewed as efficiently providing a superset
+ of XPutImageScaled functionality.
+ </item>
+ </itemize>
+ </p>
+ </sect2>
+ <sect2>Scaling with an XCopyAreaScaled Extension
+ <p>
+ As noted in the previous section, because XCopyAreaScaled
+ provides a superset of the functionality provided by
+ XPutImageScaled, we will consider this extension instead.
+ </p>
+ <p>
+ First, XCopyAreaScaled would provide for RGB scaling
+ between pixmaps (i.e., on-screen or off-screen areas of
+ memory that reside on the video card). Unlike the X Video
+ Extension, which writes into an overlay plane,
+ XCopyAreaScaled would write into the non-overlay areas of
+ the screen. Key points to consider are as follows:
+ <itemize>
+ <item>
+ Because different planes are involved, the two scaling
+ operations are usually implemented in hardware
+ differently, so an XCopyAreaScaled extension could be
+ added in a manner that would neither conflict with nor
+ interact with the X Video extension in any way.
+ </item>
+ <item>
+ The XCopyAreaScaled extension provides new
+ functionality that the X Video Extension does not
+ provide. Based on anecdotal feedback, we believe that
+ many people outside the DMX and VNC communities would
+ be excited about this extension.
+ </item>
+ <item>
+ The main drawback to this extension is that it is new
+ and needs to be implemented at the driver level in
+ XFree86 for each video card to be supported. At the
+ present time, it is more likely that the X Video
+ Extension will be implemented for a particular piece
+ hardware because the X Video extension has multimedia
+ uses. However, over time, we would expect the
+ XCopyAreaScaled extension to be implemented along with
+ the X Video extension, especially if it becomes
+ popular.
+ </item>
+ <item>
+ Another drawback is that not all modern cards provide
+ support for a simple scaled blit operation. However,
+ these cards usually do provide a 3D pipeline which
+ could be used to provide this functionality in a
+ manner that is transparent to the client application
+ that is using the XCopyAreaScaled extension. However,
+ this implementation pathway would make this extension
+ somewhat more difficult to implement on certain cards.
+ </item>
+ </itemize>
+ </p>
+ </sect2>
+ <sect2>Scaling with OpenGL
+ <p>
+ Another general solution to the scaling problem is to use
+ the texture scaling found in all 3D hardware. This
+ ability is already exposed through OpenGL and can be
+ exploited by clients without X server modification (i.e.,
+ other than the ability to support OpenGL). An application
+ using OpenGL would transmit the non-scaled image to the X
+ server as a texture, and would then display a single
+ non-transformed rect using that texture. This also works
+ around the single overlay problem with the X Video
+ Extension as well as the need to implement additional
+ scaled primitive extensions.
+ </p>
+ <p>
+ The downside is that most OpenGL implementations require
+ power of 2 texture sizes and this can be very wasteful of
+ memory if, for example, the application needs to scale a
+ 1025x1025 image, which would require a 2048x2048 texture
+ area (even a 640x480 image would require a 1024x512
+ texture). Another downside is that some OpenGL
+ implementations have a limited about of texture memory and
+ cannot handle textures that are very large. For example,
+ they might limit the texture size to 1024x1024.
+ </p>
+ </sect2>
+ </sect1>
+ <sect1>Application-transparent Scaling for DMX
+ <sect2>Back-end Scaling Without Disconnect/Reconnect
+ <p>
+ VNC does scaling on the client side (in the
+ <tt>vncviewer</tt> application). Implementing a similar
+ solution for DMX would require support in the back-end X
+ servers and, therefore, is not a general solution.
+ </p>
+ <p>
+ XFree86 already implements some support for "scaling" that
+ could be used with DMX: if, in the XF86Config file,
+ multiple Modes are listed in the Display Subsection of the
+ Screen Section, then pressing Ctrl-Alt-Plus and
+ Ctrl-Alt-Minus can be used to iterate through the listed
+ modes. The display dimensions will change to the
+ dimensions in the Modes line, but the logical dimensions
+ of the X server (i.e., the dimensions that Xdmx knows
+ about) will not change.
+ </p>
+ <p>
+ Further, the dimensions of the XFree86 display are under
+ software control (via the XFree86-VidModeExtension), so
+ the Xdmx server could change the screen dimensions on a
+ per-display basis, thereby scaling the information on part
+ of that display.
+ </p>
+ <p>
+ However, this scaling appears to have limited use. For
+ example, assume a 4 by 4 display wall consisting of 16
+ 1280x1024 displays. If all of the back-end servers were
+ simultaneously configured to display 640x480, the left
+ hand corner of each display would be magnified, but the
+ composite result would be unreadable. Magnifying one
+ display at a time could be usable, but could have limited
+ utility, since the result would still be no larger than a
+ single display.
+ </p>
+ </sect2>
+ <sect2>Back-end Scaling With Disconnect/Reconnect
+ <p>
+ Disconnect and reconnect features are not currently
+ supported in DMX, but are scheduled to be implemented in
+ the future. These features, combined with the
+ XFree86-VidModeExtension Extension, would allow an
+ application to do the following:
+ <itemize>
+ <item>
+ Disconnect a specific back-end server (via the DMX
+ Extension),
+ </item>
+ <item>
+ reconfigure the XFree86 back-end server resolution,
+ and
+ </item>
+ <item>
+ reconnect the back-end server to DMX -- at a new
+ origin with the new screen resolution.
+ </item>
+ </itemize>
+ </p>
+ <p>
+ For example, consider a display wall consisting of 16
+ 1280x1024 displays with a total resolution of 5120x4096.
+ All of the screens could be disconnected, repositioned,
+ and reconnected each at a resolution of 640x480. The
+ total resolution of the display wall would be 2560x1920,
+ allowing a view of a selected area approximately
+ one-fourth of the size of the DMX display. This change
+ would be completely application independent (except,
+ perhaps, for a DMX-aware window manager). When work at
+ the increased resolution was completed, the back-end
+ servers could be disconnected, reconfigured, and
+ reconnected for the original 5120x4096 view.
+ </p>
+ <p>
+ Support for this type of scaling can be implemented in a
+ DMX-aware X11 client assuming the DMX server support
+ arbitrary disconnect and reconnect semantics. Because
+ this application cannot be written before
+ disconnect/reconnect is implemented, this solution will
+ not be discussed further in this paper.
+ </p>
+ </sect2>
+ <sect2>Server-side Scaling
+ <p>
+ In earlier versions of DMX, a frame buffer was maintained
+ on the server side, and XPutImage was used to move the
+ information from the server to the client (similar to some
+ early VNC implementations). The use of a server-side
+ frame buffer would allow the server to do scaling, but is
+ not a recommended solution because of overall performance
+ issues and server-side memory issues (i.e., the frame
+ buffer would be very large for large display walls).
+ </p>
+ <p>
+ Exploration of this path is not recommended.
+ </p>
+ </sect2>
+ </sect1>
+ <sect1>XCreateScaledWindow API
+ <p>
+ The implementation of X Video Extension in DMX, and the use
+ of XvPutImage by applications requiring scaling requires
+ significant changes in DMX Further, XvPutImage is,
+ essentially a scaled blit, and it is only useful for
+ applications which are already using (or can be modified to
+ use) XPutImage. Therefore, a more general API will be
+ discussed as another possibility.
+ </p>
+ <p>
+ X applications typically create windows with the
+ XCreateWindow call. A new extension could provide an
+ XCreateScaledWindow call that could be used in place of the
+ XCreateWindow call and be otherwise transparent to the
+ application. This would allow applications, even those that
+ do not depend on XPutImage, to take advantage of window
+ scaling. In this section we describe how the call would
+ work, what transparency it provides, and how to solve the
+ potential problems that transparency creates.
+ </p>
+ <sect2>XCreateWindow
+ <p>
+ The XCreateWindow call takes width and height as
+ parameters. An XCreateScaledWindow call could take all
+ the same parameters, with the addition of a scaling factor.
+ </p>
+ </sect2>
+ <sect2>XSetWindowAttributes
+ <p>
+ An X11 window has several attributes that would have to be
+ scaled:
+ <itemize>
+ <item>Background and border pixmaps</item>
+ <item>Border width</item>
+ <item>Cursor</item>
+ </itemize>
+ </p>
+ </sect2>
+ <sect2>XGetWindowAttributes, XGetGeometry
+ <p>
+ For transparency, calls that query the window attributes
+ should return unscaled information. This suggests that
+ all unscaled pixmaps and window attributes should be
+ cached.
+ </p>
+ <p>
+ Unfortunately, a window manager requires the scaled
+ geometry to properly decorate the window. The X server
+ can probably determine which client is acting as the
+ window manager (e.g., because that client will select
+ events that are used exclusively by the window manager).
+ However, other Scaled Window Extension aware clients may
+ also need to determine the scaled geometry. Therefore, at
+ least two additional extension calls should be
+ implemented: XGetScaledWindowAttributes and
+ XGetScaledGeometry.
+ </p>
+ </sect2>
+ <sect2>Popup and Child window positions
+ <p>
+ Some applications may position popup and child windows
+ based on an unscaled notion of the main window geometry.
+ In this case, additional modifications to the client would
+ be required.
+ </p>
+ </sect2>
+ <sect2>Events
+ <p>
+ Most events (e.g., for mouse motion) return information
+ about the coordinates at which the even occurred. These
+ coordinates would have to be modified so that unscaled
+ values were presented to the client.
+ </p>
+ </sect2>
+ <sect2>Implementation
+ <p>
+ There are many implementation issues, some of which are
+ similar to the issues involved in implementing the X Video
+ Extension for DMX. The window contents must be scaled,
+ either by performing all operations to a frame buffer and
+ then writing the image to the display (perhaps using
+ hardware scaling support), or by modifying all of the
+ various drawing operations to perform scaling. Because of
+ the complexity involved, the frame buffer option is
+ recommended.
+ </p>
+ </sect2>
+ </sect1>
+ </sect>
+
+ <sect>Conclusion and Recommendations
+ <p>
+ We recommend a three phase implementation strategy, based on
+ how an application could be written to take advantage of
+ scaling:
+ <enum>
+ <item>
+ <p>
+ The XCopyAreaScaled extension should be implemented, since
+ this is the ideal solution for applications like VNC, and
+ since making use of this extension will require minimal
+ changes to applications that already use XPutImage or
+ XCopyArea.
+ <p>
+ The initial implementation work would include the design
+ of the X protocol extension, writing this up in the
+ usual format for extension documentation, implementation
+ of the protocol transport pieces in XFree86,
+ implementation of a software fall-back in XFree86 and
+ DMX, one example hardware implementation for XFree86,
+ and implementation of support for this extension in DMX.
+ <p>
+ We suggest implementing the extension first on the ATI
+ Radeon cards. However, since these cards do not provide
+ a 2D scaled blit primitive, the implementation would
+ have to make use of the 3D texture engine to emulate a
+ scaled blit. This is recommended, since other modern
+ graphics cards also do not provide a simple 2D scaled
+ blit operation and an example of the more difficult
+ implementation pathway would be helpful to others.
+ </item>
+ <item>
+ <p>
+ Until XCopyAreaScaled is widely supported, applications
+ that require scaling will have to fall back to another
+ scaling method. We suggest OpenGL as the first fall-back
+ method because it is widely available and supported by
+ DMX.
+ <p>
+ A project centered around OpenGL-based scaling would
+ implement this scaling in VNC as an example. This work
+ would include re-writing the <tt>vncviewer</tt>
+ rendering engine to cache a master copy of the desktop
+ image for all operations.
+ </item>
+ <item>
+ <p>
+ Since OpenGL is not implemented everywhere, and may not
+ provide hardware-assisted performance in every
+ implementation, an application that requires scaling
+ should also fall back to using the X Video Extension.
+ <p>
+ This project would add support for the X Video Extension
+ to DMX and would add support to VNC to take advantage of
+ this extension without introducing artifacts. This
+ would require modifying the <tt>vncviewer</tt> rendering
+ engine to cache a master copy of the desktop image for
+ all operations. This project should also add support
+ for the RGB format to at least one XFree86 driver (e.g.,
+ ATI Radeon).
+ <p>
+ The X Video Extension is one of the few popular
+ extensions that DMX does not support. We recommend
+ implementing the X Video Extension even if scaling is
+ the specific goal of that work.
+ </item>
+ </enum>
+ </p>
+ <p>
+ We do <bf>not</bf> recommend implementation of the
+ XCreateScaledWindow extension because of the complexity
+ involved. We do <bf>not</bf> recommend implementation of the
+ XPutImageScaled extension because it requires the same amount
+ of work as the XCopyAreaScaled extension, but provides less
+ functionality. Further, server-side scaling with a large
+ frame buffer is <bf>not</bf> recommended because of the
+ performance implications.
+ </p>
+ <p>
+ The back-end scaling, especially with disconnect/reconnect
+ support should be explored in the future after
+ disconnect/reconnect is implemented, but not at the present
+ time.
+ </p>
+ </sect>
+
+ </article>
+ <!-- Local Variables: -->
+ <!-- fill-column: 72 -->
+ <!-- End: -->
diff --git a/nx-X11/programs/Xserver/hw/dmx/doc/scaled.txt b/nx-X11/programs/Xserver/hw/dmx/doc/scaled.txt
new file mode 100644
index 000000000..d30105dd2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/doc/scaled.txt
@@ -0,0 +1,579 @@
+ Scaled Window Support in DMX
+ Rickard E. Faith and Kevin E. Martin
+ 15 October 2003 (created 19 September 2003)
+
+ This document investigates the possibility of adding scaled window
+ support to the DMX X server, thereby allowing a window or some
+ selected part of the logical DMX area to be displayed using a scaling
+ factor. For example, this might allow the contents of a window to be
+ magnified for easier viewing. In particular, scaling for the VNC
+ client is explored. _C_o_p_y_r_i_g_h_t _2_0_0_3 _b_y _R_e_d _H_a_t_, _I_n_c_._, _R_a_l_e_i_g_h_, _N_o_r_t_h
+ _C_a_r_o_l_i_n_a
+
+ ______________________________________________________________________
+
+ Table of Contents
+
+
+ 1. Introduction
+ 1.1 DMX
+ 1.2 Problem Statement
+ 1.3 Task
+
+ 2. Previous Work
+ 2.1 VNC
+ 2.1.1 Scaling under VNC
+ 2.2 The X Video Extension
+
+ 3. Possible Solutions
+ 3.1 VNC-like Scaling
+ 3.1.1 Software Scaling
+ 3.1.2 Scaling with the X Video Extension
+ 3.1.2.1 Implementing the X Video Extension for DMX
+ 3.1.2.2 Supporting RGB formats for the X Video Extension
+ 3.1.3 Scaling with an XPutImageScaled Extension
+ 3.1.4 Scaling with an XCopyAreaScaled Extension
+ 3.1.5 Scaling with OpenGL
+ 3.2 Application-transparent Scaling for DMX
+ 3.2.1 Back-end Scaling Without Disconnect/Reconnect
+ 3.2.2 Back-end Scaling With Disconnect/Reconnect
+ 3.2.3 Server-side Scaling
+ 3.3 XCreateScaledWindow API
+ 3.3.1 XCreateWindow
+ 3.3.2 XSetWindowAttributes
+ 3.3.3 XGetWindowAttributes, XGetGeometry
+ 3.3.4 Popup and Child window positions
+ 3.3.5 Events
+ 3.3.6 Implementation
+
+ 4. Conclusion and Recommendations
+
+
+ ______________________________________________________________________
+
+ 11.. IInnttrroodduuccttiioonn
+
+ 11..11.. DDMMXX
+
+ The DMX X server (Xdmx) is a proxy server that is designed to allow X
+ servers on multiple machines to be combined into a single multi-headed
+ X server. Combined with Xinerama, these heads can appear as a single
+ very high-resolution screen. Typical applications include the
+ creation of a video wall with 16 1280x1024 displays arranged in a
+ rectangle, for a total resolution of of 5120x4096.
+
+
+
+ 11..22.. PPrroobblleemm SSttaatteemmeenntt
+
+ Applications displayed on a physically large video wall that provides
+ high pixel-resolution may be difficult to see, especially if the
+ application is designed for use on a typical desktop computer with a
+ relatively small display located close to the human operator. The
+ goal of this paper is to describe and discuss solutions to this
+ problem.
+
+ The original driving problem for this work is to provide scaling for
+ the vncviewer application when displayed using DMX (VNC scaling is
+ currently available only with the Windows client, and there is no plan
+ to extend that capability to other clients). While this specific
+ problem will be addressed in this paper, the general solution space
+ will also be explored, since this may lead to a good solution not only
+ for vncviewer but also for other applications.
+
+ 11..33.. TTaasskk
+
+ For reference, here is the original description of the task this paper
+ addresses:
+
+ +o Scaled window support (for VNC)
+
+ +o Investigate possibility of implementing a "scaled window"
+ extension:
+
+ +o Add XCreateScaledWindow call that could be used in place of
+ XCreateWindow
+
+ +o All primitives drawn to scaled window would be scaled by
+ appropriate (integral?) scaling factor
+
+ +o Alternate approach: special case VNC support
+
+ 22.. PPrreevviioouuss WWoorrkk
+
+ This section reviews relevant previous work.
+
+ 22..11.. VVNNCC
+
+ 22..11..11.. SSccaalliinngg uunnddeerr VVNNCC
+
+ When using the vncviewer program for Windows, it is possible to
+ specify a scaling factor (as numerator and denominator). When scaling
+ is in effect, the viewer software uses StretchBlt (instead of BitBlt)
+ to display the pixels for the user. When this call is made, the
+ viewer already has received all of the pixel information (at full
+ unscaled resolution).
+
+ The scaling in VNC is primitive. It does not conserve bandwidth, it
+ does not treat textual information differently (i.e., by using a
+ suitably scaled font), and it does not provide any anti-aliasing other
+ than that provided by the underlying (Windows-only) system library.
+
+ 22..22.. TThhee XX VViiddeeoo EExxtteennssiioonn
+
+ The X Video Extension is a widely-available extension to the X11
+ protocol that provides support for streaming video. Integral to this
+ support is the ability to arbitrarily scale the output. In version
+ 2.2 of the X Video specification, support for scaled still images was
+ provided, using both shared memory and traditional transport. The API
+ for this support uses calls that are quite similar to XCreateWindow,
+ XPutImage, and XShmPutImage. Currently, most of the drivers
+ implemented in XFree86 only support data in various YUV formats.
+ However, several modern video adaptors support RGB as well.
+ Note, though, that the target output for this scaling is an overlay
+ plane -- so X Video provides functionality that is fundamentally
+ different from that provided by the Windows StrechBlt call.
+
+ 33.. PPoossssiibbllee SSoolluuttiioonnss
+
+ This section briefly discusses possible solutions, including major
+ advantages and disadvantages from both the implementation and the end-
+ user programmer standpoint.
+
+ 33..11.. VVNNCC--lliikkee SSccaalliinngg
+
+ 33..11..11.. SSooffttwwaarree SSccaalliinngg
+
+ The vncviewer application could be modified to provide software
+ scaling. This is not a general solution, but it does solve one of the
+ goals of this work.
+
+ A prototype of this solution was implemented and a patch against
+ vnc-3.3.7-unixsrc is available in the dmx/external directory. Because
+ of limited time available for this work, all of the edge cases were
+ not considered and the solution works well mainly for integer scaling.
+
+ Currently, vncviewer writes to the X display with XPutImage,
+ XCopyArea, and XFillRectangle. All instances of these calls have to
+ be aware of scaling and must round correctly. In the prototype
+ solution, rounding is incorrect and can cause artifacts.
+
+ A better solution would be to cache all updates to the desktop image
+ in vncviewer and only send the damaged area to the X display with
+ XPutImage. This would allow the damaged area to be computed so that
+ rounding errors do not create artifacts. This method is probably
+ similar to what is used in the Window client. (The whole VNC suite is
+ being re-written in C++ and the forthcoming version 4 has not been
+ evaluated.)
+
+ 33..11..22.. SSccaalliinngg wwiitthh tthhee XX VViiddeeoo EExxtteennssiioonn
+
+ The scaling in the Windows vncviewer application makes use of a scaled
+ blit that is supplied by the underlying system library. Several video
+ cards currently provide support for a scaled blit, and some X servers
+ (including XFree86) expose this capability to applications via the
+ XvPutImage interface of the X Video Extension. The capability exposed
+ by XvPutImage results in the scaled image being drawn to an overlay
+ plane. Most video cards also provide support for a scaled blit into
+ the normal output planes, but this is not exposed via XvPutImage.
+
+ The vncviewer program could be modified to use the X Video Extension
+ to provide scaling under X11 that is similar to the scaling currently
+ provided under Windows. Unfortunately, Xdmx does not currently export
+ the X Video Extension, so this would not provide an immediate solution
+ usable with DMX.
+
+ A very early-stage proof-of-concept prototype was implemented and a
+ preliminary patch against vnc-3.3.7-unixsrc is available in the
+ dmx/external directory. This prototype was implemented to better
+ understand the problems that must be solved to make this solution
+ viable:
+
+ +o As noted under the software scaling section above, vncviewer writes
+ to the X display with several different calls. These calls write
+ to the normal output planes and are compatible with XvPutImage,
+ which writes to an overlay plane. To eliminate artifacts caused by
+ this problem, vncviewer should be modified so that a cached copy of
+ the desktop is available, either as a client-side image or a
+ server-side off-screen pixmap, so that XvPutImage would be the only
+ method for writing to the X display.
+
+ +o
+
+ Although several modern graphics adaptors support hardware scaling
+ using an RGB format (e.g., ATI Radeon, nVidia, etc.), XFree86
+ drivers typically only implement YUV formats. YUV generally
+ compress the pixel information in some way. For example, two
+ commonly implemented formats, YUY2 and UYVY provide intensity
+ information for every RGB pixel, but only provide chroma and
+ luminance information for pairs of horizontal pixels. Since VNC
+ uses pixel-resolution for communicating updates on the wire,
+ additional artifacts are introduced (because there may not be
+ enough information from the wire to update a pair of pixels).
+
+ Further, the well-known problem with YUV encoding is even more
+ evident when the image is a desktop instead of a movie. For
+ example, consider a 1-pixel-wide vertical window border. If the
+ border changes in color but not intensity (e.g., because a window
+ manager uses color to indicate focus), there may or may not be a
+ change in the YUY2 image, depending on the algorithm used for RGB
+ to YUV conversion and on how the border pixel is ordered in the
+ pair of pixels used by the algorithm.
+
+ Many of these artifacts could be eliminated if vncviewer cached a
+ complete RGB image of the desktop, and only did the conversion to
+ YUV for properly aligned areas of damage. The remaining artifacts
+ could be eliminated if an RGB format was used with X Video (which
+ may require the extension of existing XFree86 drivers to support
+ RGB).
+
+ +o Most modern video cards support exactly one overlay plane that is
+ suitable for use with X Video. Therefore, only one application can
+ use X Video at any given time. This is a severe limitation in a
+ desktop environment.
+
+ 33..11..22..11.. IImmpplleemmeennttiinngg tthhee XX VViiddeeoo EExxtteennssiioonn ffoorr DDMMXX
+
+ The user-level API for X Video is fairly simple, but the underlying
+ support required for the full specification is large. However, since
+ the API provides a method to query supported capabilities, a usable
+ subset of X Video can be implemented that would support XvPutImage and
+ little else. This would require support for the following:
+
+ +o X Video Extension API calls, including the following:
+
+ +o XvQueryExtension
+
+ +o XvQueryAdaptors
+
+ +o XvQueryPortAttributes
+
+ +o XvFreeAdaptorInfo
+
+ +o XvListImageFormats
+
+ +o XvGrabPort
+
+ +o XvCreateImage
+
+ +o XvPutImage
+
+ +o XvShmCreateImage
+
+ +o XvShmPutImage
+
+ +o Support for querying back-end X Video Extension capabilities.
+
+ +o Support for sending the image to the back-ends. Because X Video
+ requires sending full images, there may be a trade-off between
+ bandwidth limitations and additional complexity to divide the image
+ up such that is scales properly.
+
+ +o Possible support for a software fall-back. For example, if all of
+ the back-ends do not support the X Video Extension, software
+ scaling can be implemented such that the image is sent to the back-
+ end with XPutImage. This pathway would have poor performance.
+
+ 33..11..22..22.. SSuuppppoorrttiinngg RRGGBB ffoorrmmaattss ffoorr tthhee XX VViiddeeoo EExxtteennssiioonn
+
+ Assuming an XFree86 driver already supports the X Video Extension, and
+ assuming the target hardware supports an RGB format, then adding
+ support for that format is relatively simple and straightforward.
+
+ 33..11..33.. SSccaalliinngg wwiitthh aann XXPPuuttIImmaaggeeSSccaalleedd EExxtteennssiioonn
+
+ Instead of (or in addition to) implementing the X Video Extension in
+ DMX, one obvious solution would be to implement a new extension that
+ provides access to hardware-assisted scaled blits, similar to the
+ StretchBlt call available under Windows. This call would scale RGB
+ images and would not use the overlay plane (unlike the X Video
+ Extension).
+
+ This approach has many of the same advantages and disadvantages as the
+ XCopyAreaScaled Extension, discussed in the next section. Discussion
+ of XPutImageScaled is deferred in favor of XCopyAreaScaled for the
+ following reasons:
+
+ +o XPutImageScaled can be emulated with XCopyAreaScaled by first using
+ XPutImage to copy the image to an off-screen pixmap, and then
+ calling XCopyAreaScaled between that off-screen pixmap and the
+ target drawable.
+
+ +o Since XCopyAreaScaled would copy between two areas of on-screen or
+ off-screen memory, it has additional uses and can be viewed as
+ efficiently providing a superset of XPutImageScaled functionality.
+
+ 33..11..44.. SSccaalliinngg wwiitthh aann XXCCooppyyAArreeaaSSccaalleedd EExxtteennssiioonn
+
+ As noted in the previous section, because XCopyAreaScaled provides a
+ superset of the functionality provided by XPutImageScaled, we will
+ consider this extension instead.
+
+ First, XCopyAreaScaled would provide for RGB scaling between pixmaps
+ (i.e., on-screen or off-screen areas of memory that reside on the
+ video card). Unlike the X Video Extension, which writes into an
+ overlay plane, XCopyAreaScaled would write into the non-overlay areas
+ of the screen. Key points to consider are as follows:
+
+ +o Because different planes are involved, the two scaling operations
+ are usually implemented in hardware differently, so an
+ XCopyAreaScaled extension could be added in a manner that would
+ neither conflict with nor interact with the X Video extension in
+ any way.
+
+ +o The XCopyAreaScaled extension provides new functionality that the X
+ Video Extension does not provide. Based on anecdotal feedback, we
+ believe that many people outside the DMX and VNC communities would
+ be excited about this extension.
+
+ +o The main drawback to this extension is that it is new and needs to
+ be implemented at the driver level in XFree86 for each video card
+ to be supported. At the present time, it is more likely that the X
+ Video Extension will be implemented for a particular piece hardware
+ because the X Video extension has multimedia uses. However, over
+ time, we would expect the XCopyAreaScaled extension to be
+ implemented along with the X Video extension, especially if it
+ becomes popular.
+
+ +o Another drawback is that not all modern cards provide support for a
+ simple scaled blit operation. However, these cards usually do
+ provide a 3D pipeline which could be used to provide this
+ functionality in a manner that is transparent to the client
+ application that is using the XCopyAreaScaled extension. However,
+ this implementation pathway would make this extension somewhat more
+ difficult to implement on certain cards.
+
+ 33..11..55.. SSccaalliinngg wwiitthh OOppeennGGLL
+
+ Another general solution to the scaling problem is to use the texture
+ scaling found in all 3D hardware. This ability is already exposed
+ through OpenGL and can be exploited by clients without X server
+ modification (i.e., other than the ability to support OpenGL). An
+ application using OpenGL would transmit the non-scaled image to the X
+ server as a texture, and would then display a single non-transformed
+ rect using that texture. This also works around the single overlay
+ problem with the X Video Extension as well as the need to implement
+ additional scaled primitive extensions.
+
+ The downside is that most OpenGL implementations require power of 2
+ texture sizes and this can be very wasteful of memory if, for example,
+ the application needs to scale a 1025x1025 image, which would require
+ a 2048x2048 texture area (even a 640x480 image would require a
+ 1024x512 texture). Another downside is that some OpenGL
+ implementations have a limited about of texture memory and cannot
+ handle textures that are very large. For example, they might limit
+ the texture size to 1024x1024.
+
+ 33..22.. AApppplliiccaattiioonn--ttrraannssppaarreenntt SSccaalliinngg ffoorr DDMMXX
+
+ 33..22..11.. BBaacckk--eenndd SSccaalliinngg WWiitthhoouutt DDiissccoonnnneecctt//RReeccoonnnneecctt
+
+ VNC does scaling on the client side (in the vncviewer application).
+ Implementing a similar solution for DMX would require support in the
+ back-end X servers and, therefore, is not a general solution.
+
+ XFree86 already implements some support for "scaling" that could be
+ used with DMX: if, in the XF86Config file, multiple Modes are listed
+ in the Display Subsection of the Screen Section, then pressing Ctrl-
+ Alt-Plus and Ctrl-Alt-Minus can be used to iterate through the listed
+ modes. The display dimensions will change to the dimensions in the
+ Modes line, but the logical dimensions of the X server (i.e., the
+ dimensions that Xdmx knows about) will not change.
+
+ Further, the dimensions of the XFree86 display are under software
+ control (via the XFree86-VidModeExtension), so the Xdmx server could
+ change the screen dimensions on a per-display basis, thereby scaling
+ the information on part of that display.
+
+ However, this scaling appears to have limited use. For example,
+ assume a 4 by 4 display wall consisting of 16 1280x1024 displays. If
+ all of the back-end servers were simultaneously configured to display
+ 640x480, the left hand corner of each display would be magnified, but
+ the composite result would be unreadable. Magnifying one display at a
+ time could be usable, but could have limited utility, since the result
+ would still be no larger than a single display.
+
+
+ 33..22..22.. BBaacckk--eenndd SSccaalliinngg WWiitthh DDiissccoonnnneecctt//RReeccoonnnneecctt
+
+ Disconnect and reconnect features are not currently supported in DMX,
+ but are scheduled to be implemented in the future. These features,
+ combined with the XFree86-VidModeExtension Extension, would allow an
+ application to do the following:
+
+ +o Disconnect a specific back-end server (via the DMX Extension),
+
+ +o reconfigure the XFree86 back-end server resolution, and
+
+ +o reconnect the back-end server to DMX -- at a new origin with the
+ new screen resolution.
+
+ For example, consider a display wall consisting of 16 1280x1024
+ displays with a total resolution of 5120x4096. All of the screens
+ could be disconnected, repositioned, and reconnected each at a
+ resolution of 640x480. The total resolution of the display wall would
+ be 2560x1920, allowing a view of a selected area approximately one-
+ fourth of the size of the DMX display. This change would be
+ completely application independent (except, perhaps, for a DMX-aware
+ window manager). When work at the increased resolution was completed,
+ the back-end servers could be disconnected, reconfigured, and
+ reconnected for the original 5120x4096 view.
+
+ Support for this type of scaling can be implemented in a DMX-aware X11
+ client assuming the DMX server support arbitrary disconnect and
+ reconnect semantics. Because this application cannot be written
+ before disconnect/reconnect is implemented, this solution will not be
+ discussed further in this paper.
+
+ 33..22..33.. SSeerrvveerr--ssiiddee SSccaalliinngg
+
+ In earlier versions of DMX, a frame buffer was maintained on the
+ server side, and XPutImage was used to move the information from the
+ server to the client (similar to some early VNC implementations). The
+ use of a server-side frame buffer would allow the server to do
+ scaling, but is not a recommended solution because of overall
+ performance issues and server-side memory issues (i.e., the frame
+ buffer would be very large for large display walls).
+
+ Exploration of this path is not recommended.
+
+ 33..33.. XXCCrreeaatteeSSccaalleeddWWiinnddooww AAPPII
+
+ The implementation of X Video Extension in DMX, and the use of
+ XvPutImage by applications requiring scaling requires significant
+ changes in DMX Further, XvPutImage is, essentially a scaled blit, and
+ it is only useful for applications which are already using (or can be
+ modified to use) XPutImage. Therefore, a more general API will be
+ discussed as another possibility.
+
+ X applications typically create windows with the XCreateWindow call.
+ A new extension could provide an XCreateScaledWindow call that could
+ be used in place of the XCreateWindow call and be otherwise
+ transparent to the application. This would allow applications, even
+ those that do not depend on XPutImage, to take advantage of window
+ scaling. In this section we describe how the call would work, what
+ transparency it provides, and how to solve the potential problems that
+ transparency creates.
+
+ 33..33..11.. XXCCrreeaatteeWWiinnddooww
+
+ The XCreateWindow call takes width and height as parameters. An
+ XCreateScaledWindow call could take all the same parameters, with the
+ addition of a scaling factor.
+ 33..33..22.. XXSSeettWWiinnddoowwAAttttrriibbuutteess
+
+ An X11 window has several attributes that would have to be scaled:
+
+ +o Background and border pixmaps
+
+ +o Border width
+
+ +o Cursor
+
+ 33..33..33.. XXGGeettWWiinnddoowwAAttttrriibbuutteess,, XXGGeettGGeeoommeettrryy
+
+ For transparency, calls that query the window attributes should return
+ unscaled information. This suggests that all unscaled pixmaps and
+ window attributes should be cached.
+
+ Unfortunately, a window manager requires the scaled geometry to
+ properly decorate the window. The X server can probably determine
+ which client is acting as the window manager (e.g., because that
+ client will select events that are used exclusively by the window
+ manager). However, other Scaled Window Extension aware clients may
+ also need to determine the scaled geometry. Therefore, at least two
+ additional extension calls should be implemented:
+ XGetScaledWindowAttributes and XGetScaledGeometry.
+
+ 33..33..44.. PPooppuupp aanndd CChhiilldd wwiinnddooww ppoossiittiioonnss
+
+ Some applications may position popup and child windows based on an
+ unscaled notion of the main window geometry. In this case, additional
+ modifications to the client would be required.
+
+ 33..33..55.. EEvveennttss
+
+ Most events (e.g., for mouse motion) return information about the
+ coordinates at which the even occurred. These coordinates would have
+ to be modified so that unscaled values were presented to the client.
+
+ 33..33..66.. IImmpplleemmeennttaattiioonn
+
+ There are many implementation issues, some of which are similar to the
+ issues involved in implementing the X Video Extension for DMX. The
+ window contents must be scaled, either by performing all operations to
+ a frame buffer and then writing the image to the display (perhaps
+ using hardware scaling support), or by modifying all of the various
+ drawing operations to perform scaling. Because of the complexity
+ involved, the frame buffer option is recommended.
+
+ 44.. CCoonncclluussiioonn aanndd RReeccoommmmeennddaattiioonnss
+
+ We recommend a three phase implementation strategy, based on how an
+ application could be written to take advantage of scaling:
+
+ 1.
+
+ The XCopyAreaScaled extension should be implemented, since this is
+ the ideal solution for applications like VNC, and since making use
+ of this extension will require minimal changes to applications that
+ already use XPutImage or XCopyArea.
+
+ The initial implementation work would include the design of the X
+ protocol extension, writing this up in the usual format for
+ extension documentation, implementation of the protocol transport
+ pieces in XFree86, implementation of a software fall-back in
+ XFree86 and DMX, one example hardware implementation for XFree86,
+ and implementation of support for this extension in DMX.
+
+ We suggest implementing the extension first on the ATI Radeon
+ cards. However, since these cards do not provide a 2D scaled blit
+ primitive, the implementation would have to make use of the 3D
+ texture engine to emulate a scaled blit. This is recommended,
+ since other modern graphics cards also do not provide a simple 2D
+ scaled blit operation and an example of the more difficult
+ implementation pathway would be helpful to others.
+
+ 2.
+
+ Until XCopyAreaScaled is widely supported, applications that
+ require scaling will have to fall back to another scaling method.
+ We suggest OpenGL as the first fall-back method because it is
+ widely available and supported by DMX.
+
+ A project centered around OpenGL-based scaling would implement this
+ scaling in VNC as an example. This work would include re-writing
+ the vncviewer rendering engine to cache a master copy of the
+ desktop image for all operations.
+
+ 3.
+
+ Since OpenGL is not implemented everywhere, and may not provide
+ hardware-assisted performance in every implementation, an
+ application that requires scaling should also fall back to using
+ the X Video Extension.
+
+ This project would add support for the X Video Extension to DMX and
+ would add support to VNC to take advantage of this extension
+ without introducing artifacts. This would require modifying the
+ vncviewer rendering engine to cache a master copy of the desktop
+ image for all operations. This project should also add support for
+ the RGB format to at least one XFree86 driver (e.g., ATI Radeon).
+
+ The X Video Extension is one of the few popular extensions that DMX
+ does not support. We recommend implementing the X Video Extension
+ even if scaling is the specific goal of that work.
+
+ We do nnoott recommend implementation of the XCreateScaledWindow
+ extension because of the complexity involved. We do nnoott recommend
+ implementation of the XPutImageScaled extension because it requires
+ the same amount of work as the XCopyAreaScaled extension, but provides
+ less functionality. Further, server-side scaling with a large frame
+ buffer is nnoott recommended because of the performance implications.
+
+ The back-end scaling, especially with disconnect/reconnect support
+ should be explored in the future after disconnect/reconnect is
+ implemented, but not at the present time.
+
+
+
diff --git a/nx-X11/programs/Xserver/hw/dmx/examples/Imakefile b/nx-X11/programs/Xserver/hw/dmx/examples/Imakefile
new file mode 100644
index 000000000..aa899917f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/examples/Imakefile
@@ -0,0 +1,56 @@
+XCOMM $XFree86$
+
+#include <Server.tmpl>
+
+SRCS = xdmx.c xinput.c dmxwininfo.c xtest.c evi.c res.c dmxreconfig.c xled.c \
+ xbell.c dmxresize.c
+OBJS = xdmx.o xinput.o dmxwininfo.o xtest.o evi.o res.o dmxreconfig.o xled.o \
+ xbell.o dmxresize.o
+INCLUDES = -I$(EXTINCSRC)
+
+all:: $(OBJS)
+
+NormalProgramTarget(xdmx,xdmx.o,NullParameter,$(DMXLIB) $(XLIB),NullParameter)
+AllTarget(ProgramTargetName(xdmx))
+
+NormalProgramTarget(xtest,xtest.o,NullParameter,$(XTESTLIB) $(XLIB),NullParameter)
+AllTarget(ProgramTargetName(xtest))
+
+NormalProgramTarget(evi,evi.o,NullParameter,$(XLIB),NullParameter)
+AllTarget(ProgramTargetName(evi))
+
+NormalProgramTarget(xled,xled.o,NullParameter,$(XLIB),NullParameter)
+AllTarget(ProgramTargetName(xled))
+
+NormalProgramTarget(xbell,xbell.o,NullParameter,$(XLIB),NullParameter)
+AllTarget(ProgramTargetName(xbell))
+
+#if BuildXResLibrary
+NormalProgramTarget(res,res.o,NullParameter,$(XRESLIB) $(XLIB),NullParameter)
+AllTarget(ProgramTargetName(res))
+#endif
+
+NormalProgramTarget(dmxwininfo,dmxwininfo.o,NullParameter,$(DMXLIB) $(XMULIB) $(XLIB),NullParameter)
+AllTarget(ProgramTargetName(dmxwininfo))
+
+XILIBS=$(XILIB) $(XLIB)
+NormalProgramTarget(xinput,xinput.o,NullParameter,$(DMXLIB) $(XILIBS),NullParameter)
+AllTarget(ProgramTargetName(xinput))
+
+NormalProgramTarget(dmxreconfig,dmxreconfig.o,NullParameter,$(DMXLIB) $(XLIB),NullParameter)
+AllTarget(ProgramTargetName(dmxreconfig))
+
+NormalProgramTarget(dmxresize,dmxresize.o,NullParameter,$(DMXLIB) $(XLIB),NullParameter)
+AllTarget(ProgramTargetName(dmxresize))
+
+NormalProgramTarget(dmxaddscreen,dmxaddscreen.o,NullParameter,$(DMXLIB) $(XLIB),NullParameter)
+AllTarget(ProgramTargetName(dmxaddscreen))
+
+NormalProgramTarget(dmxrmscreen,dmxrmscreen.o,NullParameter,$(DMXLIB) $(XLIB),NullParameter)
+AllTarget(ProgramTargetName(dmxrmscreen))
+
+NormalProgramTarget(dmxaddinput,dmxaddinput.o,NullParameter,$(DMXLIB) $(XLIB),NullParameter)
+AllTarget(ProgramTargetName(dmxaddinput))
+
+NormalProgramTarget(dmxrminput,dmxrminput.o,NullParameter,$(DMXLIB) $(XLIB),NullParameter)
+AllTarget(ProgramTargetName(dmxrminput))
diff --git a/nx-X11/programs/Xserver/hw/dmx/examples/dmxaddinput.c b/nx-X11/programs/Xserver/hw/dmx/examples/dmxaddinput.c
new file mode 100644
index 000000000..c391385e9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/examples/dmxaddinput.c
@@ -0,0 +1,84 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003,2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/dmxext.h>
+
+int main(int argc, char **argv)
+{
+ Display *display = NULL;
+ int event_base;
+ int error_base;
+ int major_version, minor_version, patch_version;
+ int id = -1;
+ int status;
+
+ if (argc != 5) {
+ printf("Usage: %s display c|b name|screen isCore\n", argv[0]);
+ return -1;
+ }
+
+ if (!(display = XOpenDisplay(argv[1]))) {
+ printf("Cannot open display %s\n", argv[1]);
+ return -1;
+ }
+
+ if (!DMXQueryExtension(display, &event_base, &error_base)) {
+ printf("DMX extension not present\n");
+ return -1;
+ }
+ printf("DMX extension present: event_base = %d, error_base = %d\n",
+ event_base, error_base);
+
+ if (!DMXQueryVersion(display,
+ &major_version, &minor_version, &patch_version)) {
+ printf("Could not get extension version\n");
+ return -1;
+ }
+ printf("Extension version: %d.%d patch %d\n",
+ major_version, minor_version, patch_version);
+
+ if (argv[2][0] == 'c') {
+ status = DMXAddConsoleInput(display, argv[3], atoi(argv[4]), &id);
+ } else {
+ status = DMXAddBackendInput(display, atoi(argv[3]), atoi(argv[4]),&id);
+ }
+
+ printf("status = %d, id = %d\n", status, id);
+
+ XCloseDisplay(display);
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/examples/dmxaddscreen.c b/nx-X11/programs/Xserver/hw/dmx/examples/dmxaddscreen.c
new file mode 100644
index 000000000..5fa008c21
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/examples/dmxaddscreen.c
@@ -0,0 +1,106 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/dmxext.h>
+
+int main(int argc, char **argv)
+{
+ Display *display = NULL;
+ int event_base;
+ int error_base;
+ int major_version, minor_version, patch_version;
+ int screenNum;
+ DMXScreenAttributes attr;
+ unsigned int mask = 0;
+
+ if (argc != 4 && argc != 14) {
+ printf("Usage: %s display screenNum displayName [scrnx scrny scrnw scrnh rootx rooty rootw rooth originx originy]\n", argv[0]);
+ return -1;
+ }
+
+ if (!(display = XOpenDisplay(argv[1]))) {
+ printf("Cannot open display %s\n", argv[1]);
+ return -1;
+ }
+
+ screenNum = strtol(argv[2], NULL, 0);
+ if (argc == 14) {
+ mask |= (DMXScreenWindowXoffset |
+ DMXScreenWindowYoffset |
+ DMXScreenWindowWidth |
+ DMXScreenWindowHeight);
+ attr.screenWindowXoffset = strtol(argv[4], NULL, 0);
+ attr.screenWindowYoffset = strtol(argv[5], NULL, 0);
+ attr.screenWindowWidth = strtol(argv[6], NULL, 0);
+ attr.screenWindowHeight = strtol(argv[7], NULL, 0);
+
+ mask |= (DMXRootWindowXoffset |
+ DMXRootWindowYoffset |
+ DMXRootWindowWidth |
+ DMXRootWindowHeight);
+ attr.rootWindowXoffset = strtol(argv[8], NULL, 0);
+ attr.rootWindowYoffset = strtol(argv[9], NULL, 0);
+ attr.rootWindowWidth = strtol(argv[10], NULL, 0);
+ attr.rootWindowHeight = strtol(argv[11], NULL, 0);
+
+ mask |= DMXRootWindowXorigin | DMXRootWindowYorigin;
+ attr.rootWindowXorigin = strtol(argv[12], NULL, 0);
+ attr.rootWindowYorigin = strtol(argv[13], NULL, 0);
+ }
+
+ if (!DMXQueryExtension(display, &event_base, &error_base)) {
+ printf("DMX extension not present\n");
+ return -1;
+ }
+ printf("DMX extension present: event_base = %d, error_base = %d\n",
+ event_base, error_base);
+
+ if (!DMXQueryVersion(display,
+ &major_version, &minor_version, &patch_version)) {
+ printf("Could not get extension version\n");
+ return -1;
+ }
+ printf("Extension version: %d.%d patch %d\n",
+ major_version, minor_version, patch_version);
+
+ if (!DMXAddScreen(display, argv[3], mask, &attr, &screenNum))
+ printf("Failed to add %s as screen #%d\n", argv[2], screenNum);
+
+ XCloseDisplay(display);
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/examples/dmxreconfig.c b/nx-X11/programs/Xserver/hw/dmx/examples/dmxreconfig.c
new file mode 100644
index 000000000..efcead86e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/examples/dmxreconfig.c
@@ -0,0 +1,163 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/dmxext.h>
+
+int main(int argc, char **argv)
+{
+ Display *display = NULL;
+ int event_base;
+ int error_base;
+ int major_version, minor_version, patch_version;
+ int screen;
+ DMXScreenAttributes attr;
+ unsigned int mask = 0;
+ int status;
+ int errorScreen;
+
+ if (argc != 13) {
+ fprintf(stderr, "Usage: %s display screen scrnx scrny scrnw scrnh rootx rooty rootw rooth originx originy\n", argv[0]);
+ return -1;
+ }
+
+ if (!(display = XOpenDisplay(argv[1]))) {
+ fprintf(stderr, "Cannot open display %s\n", argv[1]);
+ return -1;
+ }
+
+ screen = strtol(argv[2], NULL, 0);
+
+ mask |= (DMXScreenWindowXoffset |
+ DMXScreenWindowYoffset |
+ DMXScreenWindowWidth |
+ DMXScreenWindowHeight);
+ attr.screenWindowXoffset = strtol(argv[3], NULL, 0);
+ attr.screenWindowYoffset = strtol(argv[4], NULL, 0);
+ attr.screenWindowWidth = strtol(argv[5], NULL, 0);
+ attr.screenWindowHeight = strtol(argv[6], NULL, 0);
+
+ mask |= (DMXRootWindowXoffset |
+ DMXRootWindowYoffset |
+ DMXRootWindowWidth |
+ DMXRootWindowHeight);
+ attr.rootWindowXoffset = strtol(argv[7], NULL, 0);
+ attr.rootWindowYoffset = strtol(argv[8], NULL, 0);
+ attr.rootWindowWidth = strtol(argv[9], NULL, 0);
+ attr.rootWindowHeight = strtol(argv[10], NULL, 0);
+
+ mask |= DMXRootWindowXorigin | DMXRootWindowYorigin;
+ attr.rootWindowXorigin = strtol(argv[11], NULL, 0);
+ attr.rootWindowYorigin = strtol(argv[12], NULL, 0);
+
+ if (!DMXQueryExtension(display, &event_base, &error_base)) {
+ fprintf(stderr, "DMX extension not present\n");
+ return -1;
+ }
+ printf("DMX extension present: event_base = %d, error_base = %d\n",
+ event_base, error_base);
+
+ if (!DMXQueryVersion(display,
+ &major_version, &minor_version, &patch_version)) {
+ fprintf(stderr, "Could not get extension version\n");
+ return -1;
+ }
+ printf("Extension version: %d.%d patch %d\n",
+ major_version, minor_version, patch_version);
+
+ if (major_version == 1 && minor_version < 3) {
+ fprintf(stderr,
+ "ReconfigureScreen not supported in this extension version\n");
+ return -1;
+ }
+
+ if (major_version < 2) {
+ fprintf(stderr,
+ "ChangeScreensAttributes not supported in this extension "
+ "version\n");
+ return -1;
+ }
+
+ if (!(status = DMXChangeScreensAttributes(display, 1, &screen, 1, &mask,
+ &attr, &errorScreen))) {
+ printf("Reconfigured screen #%d to "
+ "%dx%d%s%d%s%d %dx%d%s%d%s%d %s%d%s%d\n",
+ screen,
+ attr.screenWindowWidth,
+ attr.screenWindowHeight,
+ (attr.screenWindowXoffset < 0 ? "" : "+"),
+ attr.screenWindowXoffset,
+ (attr.screenWindowYoffset < 0 ? "" : "+"),
+ attr.screenWindowYoffset,
+ attr.rootWindowWidth,
+ attr.rootWindowHeight,
+ (attr.rootWindowXoffset < 0 ? "" : "+"),
+ attr.rootWindowXoffset,
+ (attr.rootWindowYoffset < 0 ? "" : "+"),
+ attr.rootWindowYoffset,
+ (attr.rootWindowXorigin < 0 ? "" : "+"),
+ attr.rootWindowXorigin,
+ (attr.rootWindowYorigin < 0 ? "" : "+"),
+ attr.rootWindowYorigin);
+ } else {
+ fprintf(stderr,
+ "Could not set screen #%d to "
+ "%dx%d%s%d%s%d %dx%d%s%d%s%d %s%d%s%d\n"
+ "[status = %d, errorScreen=%d]\n",
+ screen,
+ attr.screenWindowWidth,
+ attr.screenWindowHeight,
+ (attr.screenWindowXoffset < 0 ? "" : "+"),
+ attr.screenWindowXoffset,
+ (attr.screenWindowYoffset < 0 ? "" : "+"),
+ attr.screenWindowYoffset,
+ attr.rootWindowWidth,
+ attr.rootWindowHeight,
+ (attr.rootWindowXoffset < 0 ? "" : "+"),
+ attr.rootWindowXoffset,
+ (attr.rootWindowYoffset < 0 ? "" : "+"),
+ attr.rootWindowYoffset,
+ (attr.rootWindowXorigin < 0 ? "" : "+"),
+ attr.rootWindowXorigin,
+ (attr.rootWindowYorigin < 0 ? "" : "+"),
+ attr.rootWindowYorigin,
+ status, errorScreen);
+ return -1;
+ }
+
+ XCloseDisplay(display);
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/examples/dmxresize.c b/nx-X11/programs/Xserver/hw/dmx/examples/dmxresize.c
new file mode 100644
index 000000000..f6fadf70c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/examples/dmxresize.c
@@ -0,0 +1,105 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/dmxext.h>
+
+int main(int argc, char **argv)
+{
+ Display *display = NULL;
+ int event_base;
+ int error_base;
+ int major_version, minor_version, patch_version;
+ int width, height, shiftX, shiftY, status;
+ DMXDesktopAttributes attr;
+ unsigned int mask;
+
+ if (argc != 6) {
+ printf("Usage: %s display width height shiftX shiftY\n", argv[0]);
+ return -1;
+ }
+
+ if (!(display = XOpenDisplay(argv[1]))) {
+ printf("Cannot open display %s\n", argv[1]);
+ return -1;
+ }
+
+ width = strtol(argv[2], NULL, 0);
+ height = strtol(argv[3], NULL, 0);
+ shiftX = strtol(argv[4], NULL, 0);
+ shiftY = strtol(argv[5], NULL, 0);
+
+ if (!DMXQueryExtension(display, &event_base, &error_base)) {
+ printf("DMX extension not present\n");
+ return -1;
+ }
+ printf("DMX extension present: event_base = %d, error_base = %d\n",
+ event_base, error_base);
+
+ if (!DMXQueryVersion(display,
+ &major_version, &minor_version, &patch_version)) {
+ printf("Could not get extension version\n");
+ return -1;
+ }
+ printf("Extension version: %d.%d patch %d\n",
+ major_version, minor_version, patch_version);
+
+ mask = (DMXDesktopWidth |
+ DMXDesktopHeight |
+ DMXDesktopShiftX |
+ DMXDesktopShiftY);
+ attr.width = width;
+ attr.height = height;
+ attr.shiftX = shiftX;
+ attr.shiftY = shiftY;
+ switch (status = DMXChangeDesktopAttributes(display, mask, &attr)) {
+ case DmxBadXinerama:
+ printf("status = %d (No Xinerama)\n", status);
+ break;
+ case DmxBadValue:
+ printf("status = %d (Bad Value)\n", status);
+ break;
+ case Success:
+ printf("status = %d (Success)\n", status);
+ break;
+ default:
+ printf("status = %d (UNKNOWN ERROR *****)\n", status);
+ break;
+ }
+
+ XCloseDisplay(display);
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/examples/dmxrminput.c b/nx-X11/programs/Xserver/hw/dmx/examples/dmxrminput.c
new file mode 100644
index 000000000..3860cc9c6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/examples/dmxrminput.c
@@ -0,0 +1,79 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003,2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/dmxext.h>
+
+int main(int argc, char **argv)
+{
+ Display *display = NULL;
+ int event_base;
+ int error_base;
+ int major_version, minor_version, patch_version;
+ int status;
+
+ if (argc != 3) {
+ printf("Usage: %s display id\n", argv[0]);
+ return -1;
+ }
+
+ if (!(display = XOpenDisplay(argv[1]))) {
+ printf("Cannot open display %s\n", argv[1]);
+ return -1;
+ }
+
+ if (!DMXQueryExtension(display, &event_base, &error_base)) {
+ printf("DMX extension not present\n");
+ return -1;
+ }
+ printf("DMX extension present: event_base = %d, error_base = %d\n",
+ event_base, error_base);
+
+ if (!DMXQueryVersion(display,
+ &major_version, &minor_version, &patch_version)) {
+ printf("Could not get extension version\n");
+ return -1;
+ }
+ printf("Extension version: %d.%d patch %d\n",
+ major_version, minor_version, patch_version);
+
+ status = DMXRemoveInput(display, atoi(argv[2]));
+
+ printf("status = %d\n", status);
+
+ XCloseDisplay(display);
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/examples/dmxrmscreen.c b/nx-X11/programs/Xserver/hw/dmx/examples/dmxrmscreen.c
new file mode 100644
index 000000000..ab3653d24
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/examples/dmxrmscreen.c
@@ -0,0 +1,81 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/dmxext.h>
+
+int main(int argc, char **argv)
+{
+ Display *display = NULL;
+ int event_base;
+ int error_base;
+ int major_version, minor_version, patch_version;
+ int screenNum;
+
+ if (argc != 3) {
+ printf("Usage: %s display screenNum\n", argv[0]);
+ return -1;
+ }
+
+ if (!(display = XOpenDisplay(argv[1]))) {
+ printf("Cannot open display %s\n", argv[1]);
+ return -1;
+ }
+
+ screenNum = strtol(argv[2], NULL, 0);
+
+ if (!DMXQueryExtension(display, &event_base, &error_base)) {
+ printf("DMX extension not present\n");
+ return -1;
+ }
+ printf("DMX extension present: event_base = %d, error_base = %d\n",
+ event_base, error_base);
+
+ if (!DMXQueryVersion(display,
+ &major_version, &minor_version, &patch_version)) {
+ printf("Could not get extension version\n");
+ return -1;
+ }
+ printf("Extension version: %d.%d patch %d\n",
+ major_version, minor_version, patch_version);
+
+ if (!DMXRemoveScreen(display, screenNum))
+ printf("Failed to remove screen #%d\n", screenNum);
+
+ XCloseDisplay(display);
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/examples/dmxwininfo.c b/nx-X11/programs/Xserver/hw/dmx/examples/dmxwininfo.c
new file mode 100644
index 000000000..bbf7f7446
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/examples/dmxwininfo.c
@@ -0,0 +1,497 @@
+/* $XFree86$ */
+/*
+ * Copyright (c) 2003 by the XFree86 Project, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Create a window and use the DMX extension to query the window's
+ * back-end properties. Display the info inside the window itself.
+ *
+ * Brian Paul
+ * 23 Jan 2003
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/extensions/dmxext.h>
+
+static const char *FontName = "fixed";
+
+
+static void
+EventLoop(Display *dpy, Window win, GC gc)
+{
+ XEvent ev;
+ while (1) {
+ XNextEvent( dpy, &ev );
+ switch (ev.type) {
+ case ReparentNotify:
+ break;
+ case MapNotify:
+ break;
+ case ConfigureNotify:
+ case Expose:
+ {
+ int numScreens, count, i;
+ DMXWindowAttributes *winInfo;
+ int x, y;
+ const char *msg = "DMX window info:";
+
+ DMXGetScreenCount(dpy, &numScreens);
+ winInfo
+ = (DMXWindowAttributes *)
+ malloc(numScreens * sizeof(DMXWindowAttributes));
+ assert(winInfo);
+ if (!DMXGetWindowAttributes(dpy, win, &count,
+ numScreens, winInfo)) {
+ printf("Could not get window information for 0x%08lx\n",
+ (long unsigned)win);
+ }
+ x = y = 50;
+ XClearWindow(dpy, win);
+ XDrawString(dpy, win, gc, x, y, msg, strlen(msg));
+ y += 20;
+ for (i = 0; i < count; i++) {
+ char str[500];
+ XmuSnprintf(str, sizeof(str),
+ "screen %d: pos: %dx%d+%d+%d visible: %dx%d+%d+%d",
+ winInfo[i].screen,
+ winInfo[i].pos.width, winInfo[i].pos.height,
+ winInfo[i].pos.x, winInfo[i].pos.y,
+ winInfo[i].vis.width, winInfo[i].vis.height,
+ winInfo[i].vis.x, winInfo[i].vis.y);
+ XDrawString(dpy, win, gc, x, y, str, strlen(str));
+ y += 20;
+ }
+ free(winInfo);
+ }
+ break;
+ default:
+ printf("Event type 0x%x\n", ev.type);
+ }
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ const char *displayName = NULL;
+ Display *dpy;
+ int event_base, error_base;
+ int scr, n;
+ long vinfoMask, attrMask;
+ XVisualInfo vinfoTemp, *visInfo;
+ Visual *vis;
+ Window win, root;
+ XSetWindowAttributes attr;
+ XFontStruct *fontInfo;
+ GC gc;
+
+ if (argc > 1) {
+ displayName = argv[1];
+ }
+
+ dpy = XOpenDisplay(displayName);
+ if (!dpy) {
+ fprintf(stderr, "Unable to open display %s\n", displayName);
+ return -1;
+ }
+
+ if (!DMXQueryExtension(dpy, &event_base, &error_base)) {
+ fprintf(stderr, "DMX extension not available on this display.\n");
+ return -1;
+ }
+
+ scr = DefaultScreen(dpy);
+ root = RootWindow(dpy, scr);
+ vis = DefaultVisual(dpy, scr);
+
+ vinfoMask = VisualIDMask;
+ vinfoTemp.visualid = vis->visualid;
+ visInfo = XGetVisualInfo(dpy, vinfoMask, &vinfoTemp, &n);
+ if (!visInfo || n != 1) {
+ fprintf(stderr, "Unable to get visual!\n");
+ XCloseDisplay(dpy);
+ return -1;
+ }
+
+ attr.background_pixel = 0;
+ attr.border_pixel = 0;
+ attr.colormap = XCreateColormap(dpy, root, visInfo->visual, AllocNone);
+ attr.event_mask = StructureNotifyMask | ExposureMask;
+ attrMask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+
+ win = XCreateWindow(dpy, root,
+ 500, 500, 600, 400, /* x, y, w, h */
+ 0, /* border_width */
+ visInfo->depth, InputOutput,
+ visInfo->visual, attrMask, &attr);
+
+
+ if (!win) {
+ fprintf(stderr, "Unable to create window!\n");
+ XCloseDisplay(dpy);
+ return -1;
+ }
+
+ fontInfo = XLoadQueryFont(dpy, FontName);
+ if (!fontInfo) {
+ fprintf(stderr, "Error: font %s not found\n", FontName);
+ exit(0);
+ }
+
+ gc = XCreateGC(dpy, win, 0, NULL);
+ XSetBackground(dpy, gc, BlackPixel(dpy, scr));
+ XSetForeground(dpy, gc, WhitePixel(dpy, scr));
+ XSetFont(dpy, gc, fontInfo->fid);
+
+ XMapWindow(dpy, win);
+
+ EventLoop(dpy, win, gc);
+
+ XDestroyWindow(dpy, win);
+ XCloseDisplay(dpy);
+ return 0;
+}
+
+#if 00
+
+static void make_window( char *title, int color_flag )
+{
+ int x = 10, y = 10, width = 400, height = 300;
+ Display *dpy;
+ int scr;
+ Window root, win;
+ Colormap cmap;
+ XColor xcolor;
+ int attr_flags;
+ XVisualInfo *visinfo;
+ XSetWindowAttributes attr;
+ XTextProperty tp;
+ XSizeHints sh;
+ XEvent e;
+ XMesaContext context;
+ XMesaVisual visual;
+ XMesaBuffer buffer;
+
+
+ /*
+ * Do the usual X things to make a window.
+ */
+
+ dpy = XOpenDisplay(NULL);
+ if (!dpy) {
+ printf("Couldn't open default display!\n");
+ exit(1);
+ }
+
+ scr = DefaultScreen(dpy);
+ root = RootWindow(dpy, scr);
+
+ /* alloc visinfo struct */
+ visinfo = (XVisualInfo *) malloc( sizeof(XVisualInfo) );
+
+ /* Get a visual and colormap */
+ if (color_flag) {
+ /* Open TrueColor window */
+
+/*
+ if (!XMatchVisualInfo( dpy, scr, 24, TrueColor, visinfo )) {
+ printf("Couldn't get 24-bit TrueColor visual!\n");
+ exit(1);
+ }
+*/
+ if (!XMatchVisualInfo( dpy, scr, 8, PseudoColor, visinfo )) {
+ printf("Couldn't get 8-bit PseudoColor visual!\n");
+ exit(1);
+ }
+
+ cmap = XCreateColormap( dpy, root, visinfo->visual, AllocNone );
+ Black = Red = Green = Blue = 0;
+ }
+ else {
+ /* Open color index window */
+
+ if (!XMatchVisualInfo( dpy, scr, 8, PseudoColor, visinfo )) {
+ printf("Couldn't get 8-bit PseudoColor visual\n");
+ exit(1);
+ }
+
+ cmap = XCreateColormap( dpy, root, visinfo->visual, AllocNone );
+
+ /* Allocate colors */
+ xcolor.red = 0x0;
+ xcolor.green = 0x0;
+ xcolor.blue = 0x0;
+ xcolor.flags = DoRed | DoGreen | DoBlue;
+ if (!XAllocColor( dpy, cmap, &xcolor )) {
+ printf("Couldn't allocate black!\n");
+ exit(1);
+ }
+ Black = xcolor.pixel;
+
+ xcolor.red = 0xffff;
+ xcolor.green = 0x0;
+ xcolor.blue = 0x0;
+ xcolor.flags = DoRed | DoGreen | DoBlue;
+ if (!XAllocColor( dpy, cmap, &xcolor )) {
+ printf("Couldn't allocate red!\n");
+ exit(1);
+ }
+ Red = xcolor.pixel;
+
+ xcolor.red = 0x0;
+ xcolor.green = 0xffff;
+ xcolor.blue = 0x0;
+ xcolor.flags = DoRed | DoGreen | DoBlue;
+ if (!XAllocColor( dpy, cmap, &xcolor )) {
+ printf("Couldn't allocate green!\n");
+ exit(1);
+ }
+ Green = xcolor.pixel;
+
+ xcolor.red = 0x0;
+ xcolor.green = 0x0;
+ xcolor.blue = 0xffff;
+ xcolor.flags = DoRed | DoGreen | DoBlue;
+ if (!XAllocColor( dpy, cmap, &xcolor )) {
+ printf("Couldn't allocate blue!\n");
+ exit(1);
+ }
+ Blue = xcolor.pixel;
+ }
+
+ /* set window attributes */
+ attr.colormap = cmap;
+ attr.event_mask = ExposureMask | StructureNotifyMask;
+ attr.border_pixel = BlackPixel( dpy, scr );
+ attr.background_pixel = BlackPixel( dpy, scr );
+ attr_flags = CWColormap | CWEventMask | CWBorderPixel | CWBackPixel;
+
+ /* Create the window */
+ win = XCreateWindow( dpy, root, x,y, width, height, 0,
+ visinfo->depth, InputOutput,
+ visinfo->visual,
+ attr_flags, &attr);
+ if (!win) {
+ printf("Couldn't open window!\n");
+ exit(1);
+ }
+
+ XStringListToTextProperty(&title, 1, &tp);
+ sh.flags = USPosition | USSize;
+ XSetWMProperties(dpy, win, &tp, &tp, 0, 0, &sh, 0, 0);
+ XMapWindow(dpy, win);
+ while (1) {
+ XNextEvent( dpy, &e );
+ if (e.type == MapNotify && e.xmap.window == win) {
+ break;
+ }
+ }
+
+
+ /*
+ * Now do the special Mesa/Xlib stuff!
+ */
+
+ visual = XMesaCreateVisual( dpy, visinfo,
+ (GLboolean) color_flag,
+ GL_FALSE, /* alpha_flag */
+ GL_FALSE, /* db_flag */
+ GL_FALSE, /* stereo flag */
+ GL_FALSE, /* ximage_flag */
+ 0, /* depth size */
+ 0, /* stencil size */
+ 0,0,0,0, /* accum_size */
+ 0, /* num samples */
+ 0, /* level */
+ 0 /* caveat */
+ );
+ if (!visual) {
+ printf("Couldn't create Mesa/X visual!\n");
+ exit(1);
+ }
+
+ /* Create a Mesa rendering context */
+ context = XMesaCreateContext( visual,
+ NULL /* share_list */
+ );
+ if (!context) {
+ printf("Couldn't create Mesa/X context!\n");
+ exit(1);
+ }
+
+ buffer = XMesaCreateWindowBuffer( visual, win );
+ if (!buffer) {
+ printf("Couldn't create Mesa/X buffer!\n");
+ exit(1);
+ }
+
+
+ XMesaMakeCurrent( context, buffer );
+
+ /* Ready to render! */
+}
+
+
+
+static void draw_cube( void )
+{
+ /* X faces */
+ glIndexi( Red );
+ glColor3f( 1.0, 0.0, 0.0 );
+ glBegin( GL_POLYGON );
+ glVertex3f( 1.0, 1.0, 1.0 );
+ glVertex3f( 1.0, -1.0, 1.0 );
+ glVertex3f( 1.0, -1.0, -1.0 );
+ glVertex3f( 1.0, 1.0, -1.0 );
+ glEnd();
+
+ glBegin( GL_POLYGON );
+ glVertex3f( -1.0, 1.0, 1.0 );
+ glVertex3f( -1.0, 1.0, -1.0 );
+ glVertex3f( -1.0, -1.0, -1.0 );
+ glVertex3f( -1.0, -1.0, 1.0 );
+ glEnd();
+
+ /* Y faces */
+ glIndexi( Green );
+ glColor3f( 0.0, 1.0, 0.0 );
+ glBegin( GL_POLYGON );
+ glVertex3f( 1.0, 1.0, 1.0 );
+ glVertex3f( 1.0, 1.0, -1.0 );
+ glVertex3f( -1.0, 1.0, -1.0 );
+ glVertex3f( -1.0, 1.0, 1.0 );
+ glEnd();
+
+ glBegin( GL_POLYGON );
+ glVertex3f( 1.0, -1.0, 1.0 );
+ glVertex3f( -1.0, -1.0, 1.0 );
+ glVertex3f( -1.0, -1.0, -1.0 );
+ glVertex3f( 1.0, -1.0, -1.0 );
+ glEnd();
+
+ /* Z faces */
+ glIndexi( Blue );
+ glColor3f( 0.0, 0.0, 1.0 );
+ glBegin( GL_POLYGON );
+ glVertex3f( 1.0, 1.0, 1.0 );
+ glVertex3f( -1.0, 1.0, 1.0 );
+ glVertex3f( -1.0, -1.0, 1.0 );
+ glVertex3f( 1.0, -1.0, 1.0 );
+ glEnd();
+
+ glBegin( GL_POLYGON );
+ glVertex3f( 1.0, 1.0, -1.0 );
+ glVertex3f( 1.0,-1.0, -1.0 );
+ glVertex3f( -1.0,-1.0, -1.0 );
+ glVertex3f( -1.0, 1.0, -1.0 );
+ glEnd();
+}
+
+
+
+
+static void display_loop( void )
+{
+ GLfloat xrot, yrot, zrot;
+
+ xrot = yrot = zrot = 0.0;
+
+ glClearColor( 0.0, 0.0, 0.0, 0.0 );
+ glClearIndex( Black );
+
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 1.0, 10.0 );
+ glTranslatef( 0.0, 0.0, -5.0 );
+
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+
+ glCullFace( GL_BACK );
+ glEnable( GL_CULL_FACE );
+
+ glShadeModel( GL_FLAT );
+
+ while (1) {
+ glClear( GL_COLOR_BUFFER_BIT );
+ glPushMatrix();
+ glRotatef( xrot, 1.0, 0.0, 0.0 );
+ glRotatef( yrot, 0.0, 1.0, 0.0 );
+ glRotatef( zrot, 0.0, 0.0, 1.0 );
+
+ draw_cube();
+
+ glPopMatrix();
+ glFinish();
+
+ xrot += 10.0;
+ yrot += 7.0;
+ zrot -= 3.0;
+ }
+
+}
+
+
+
+
+int main( int argc, char *argv[] )
+{
+ int mode = 0;
+
+ if (argc >= 2)
+ {
+ if (strcmp(argv[1],"-ci")==0)
+ mode = 0;
+ else if (strcmp(argv[1],"-rgb")==0)
+ mode = 1;
+ else
+ {
+ printf("Bad flag: %s\n", argv[1]);
+ printf("Specify -ci for 8-bit color index or -rgb for RGB mode\n");
+ exit(1);
+ }
+ }
+ else
+ {
+ printf("Specify -ci for 8-bit color index or -rgb for RGB mode\n");
+ printf("Defaulting to 8-bit color index\n");
+ }
+
+ make_window( argv[0], mode );
+
+ display_loop();
+ return 0;
+}
+
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/examples/ev.c b/nx-X11/programs/Xserver/hw/dmx/examples/ev.c
new file mode 100644
index 000000000..04c47eb11
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/examples/ev.c
@@ -0,0 +1,183 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * This is a simple test program that reads from /dev/input/event*,
+ * decoding events into a human readable form.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <time.h>
+#include <linux/input.h>
+
+struct input_event event;
+
+int main(int argc, char **argv)
+{
+ char name[64]; /* RATS: Use ok, but could be better */
+ char buf[256] = { 0, }; /* RATS: Use ok */
+ unsigned char mask[EV_MAX/8 + 1]; /* RATS: Use ok */
+ int version;
+ int fd = 0;
+ int rc;
+ int i, j;
+ char *tmp;
+
+#define test_bit(bit) (mask[(bit)/8] & (1 << ((bit)%8)))
+
+ for (i = 0; i < 32; i++) {
+ sprintf(name, "/dev/input/event%d", i);
+ if ((fd = open(name, O_RDONLY, 0)) >= 0) {
+ ioctl(fd, EVIOCGVERSION, &version);
+ ioctl(fd, EVIOCGNAME(sizeof(buf)), buf);
+ ioctl(fd, EVIOCGBIT(0, sizeof(mask)), mask);
+ printf("%s\n", name);
+ printf(" evdev version: %d.%d.%d\n",
+ version >> 16, (version >> 8) & 0xff, version & 0xff);
+ printf(" name: %s\n", buf);
+ printf(" features:");
+ for (j = 0; j < EV_MAX; j++) {
+ if (test_bit(j)) {
+ const char *type = "unknown";
+ switch(j) {
+ case EV_KEY: type = "keys/buttons"; break;
+ case EV_REL: type = "relative"; break;
+ case EV_ABS: type = "absolute"; break;
+ case EV_MSC: type = "reserved"; break;
+ case EV_LED: type = "leds"; break;
+ case EV_SND: type = "sound"; break;
+ case EV_REP: type = "repeat"; break;
+ case EV_FF: type = "feedback"; break;
+ }
+ printf(" %s", type);
+ }
+ }
+ printf("\n");
+ close(fd);
+ }
+ }
+
+ if (argc > 1) {
+ sprintf(name, "/dev/input/event%d", atoi(argv[1]));
+ if ((fd = open(name, O_RDWR, 0)) >= 0) {
+ printf("%s: open, fd = %d\n", name, fd);
+ for (i = 0; i < LED_MAX; i++) {
+ event.time.tv_sec = time(0);
+ event.time.tv_usec = 0;
+ event.type = EV_LED;
+ event.code = i;
+ event.value = 0;
+ write(fd, &event, sizeof(event));
+ }
+
+ while ((rc = read(fd, &event, sizeof(event))) > 0) {
+ printf("%-24.24s.%06lu type 0x%04x; code 0x%04x;"
+ " value 0x%08x; ",
+ ctime(&event.time.tv_sec),
+ event.time.tv_usec,
+ event.type, event.code, event.value);
+ switch (event.type) {
+ case EV_KEY:
+ if (event.code > BTN_MISC) {
+ printf("Button %d %s",
+ event.code & 0xff,
+ event.value ? "press" : "release");
+ } else {
+ printf("Key %d (0x%x) %s",
+ event.code & 0xff,
+ event.code & 0xff,
+ event.value ? "press" : "release");
+ }
+ break;
+ case EV_REL:
+ switch (event.code) {
+ case REL_X: tmp = "X"; break;
+ case REL_Y: tmp = "Y"; break;
+ case REL_HWHEEL: tmp = "HWHEEL"; break;
+ case REL_DIAL: tmp = "DIAL"; break;
+ case REL_WHEEL: tmp = "WHEEL"; break;
+ case REL_MISC: tmp = "MISC"; break;
+ default: tmp = "UNKNOWN"; break;
+ }
+ printf("Relative %s %d", tmp, event.value);
+ break;
+ case EV_ABS:
+ switch (event.code) {
+ case ABS_X: tmp = "X"; break;
+ case ABS_Y: tmp = "Y"; break;
+ case ABS_Z: tmp = "Z"; break;
+ case ABS_RX: tmp = "RX"; break;
+ case ABS_RY: tmp = "RY"; break;
+ case ABS_RZ: tmp = "RZ"; break;
+ case ABS_THROTTLE: tmp = "THROTTLE"; break;
+ case ABS_RUDDER: tmp = "RUDDER"; break;
+ case ABS_WHEEL: tmp = "WHEEL"; break;
+ case ABS_GAS: tmp = "GAS"; break;
+ case ABS_BRAKE: tmp = "BRAKE"; break;
+ case ABS_HAT0X: tmp = "HAT0X"; break;
+ case ABS_HAT0Y: tmp = "HAT0Y"; break;
+ case ABS_HAT1X: tmp = "HAT1X"; break;
+ case ABS_HAT1Y: tmp = "HAT1Y"; break;
+ case ABS_HAT2X: tmp = "HAT2X"; break;
+ case ABS_HAT2Y: tmp = "HAT2Y"; break;
+ case ABS_HAT3X: tmp = "HAT3X"; break;
+ case ABS_HAT3Y: tmp = "HAT3Y"; break;
+ case ABS_PRESSURE: tmp = "PRESSURE"; break;
+ case ABS_DISTANCE: tmp = "DISTANCE"; break;
+ case ABS_TILT_X: tmp = "TILT_X"; break;
+ case ABS_TILT_Y: tmp = "TILT_Y"; break;
+ case ABS_MISC: tmp = "MISC"; break;
+ default: tmp = "UNKNOWN"; break;
+ }
+ printf("Absolute %s %d", tmp, event.value);
+ break;
+ case EV_MSC: printf("Misc"); break;
+ case EV_LED: printf("Led"); break;
+ case EV_SND: printf("Snd"); break;
+ case EV_REP: printf("Rep"); break;
+ case EV_FF: printf("FF"); break;
+ break;
+ }
+ printf("\n");
+ }
+ printf("rc = %d, errno = %d (%s)\n", rc, errno, strerror(errno));
+ close(fd);
+ }
+ }
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/examples/evi.c b/nx-X11/programs/Xserver/hw/dmx/examples/evi.c
new file mode 100644
index 000000000..14af95d5a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/examples/evi.c
@@ -0,0 +1,87 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/XEVI.h>
+
+int main(int argc, char **argv)
+{
+ Display *display = NULL;
+ int major_version, minor_version;
+ ExtendedVisualInfo *evi;
+ int count;
+ int i;
+
+ if (argc == 2) {
+ if (!(display = XOpenDisplay(argv[1]))) {
+ printf("Cannot open display %s\n", argv[1]);
+ return -1;
+ }
+ } else {
+ printf("Usage: %s display\n", argv[0]);
+ return -1;
+ }
+
+ if (!display && !(display = XOpenDisplay(NULL))) {
+ printf("Cannot open default display\n");
+ return -1;
+ }
+
+ if (!XeviQueryVersion(display, &major_version, &minor_version)) {
+ printf("EVI extension not present\n");
+ return -1;
+ }
+ printf("EVI Extension version: %d.%d\n", major_version, minor_version);
+
+ XeviGetVisualInfo(display, NULL, 0, &evi, &count);
+
+ for (i = 0; i < count; i++) {
+ printf("%02d vid=0x%02lx screen=%d level=%d type=%u value=%u"
+ " min=%u max=%u conflicts=%u\n",
+ i,
+ (long unsigned)evi[i].core_visual_id,
+ evi[i].screen,
+ evi[i].level,
+ evi[i].transparency_type,
+ evi[i].transparency_value,
+ evi[i].min_hw_colormaps,
+ evi[i].max_hw_colormaps,
+ evi[i].num_colormap_conflicts);
+ }
+
+ XCloseDisplay(display);
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/examples/res.c b/nx-X11/programs/Xserver/hw/dmx/examples/res.c
new file mode 100644
index 000000000..3af5541fa
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/examples/res.c
@@ -0,0 +1,100 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/XRes.h>
+
+int main(int argc, char **argv)
+{
+ Display *display = NULL;
+ int major_version, minor_version;
+ int event, error;
+ int count;
+ int i;
+ XResClient *clients;
+
+ if (argc == 2) {
+ if (!(display = XOpenDisplay(argv[1]))) {
+ printf("Cannot open display %s\n", argv[1]);
+ return -1;
+ }
+ } else {
+ printf("Usage: %s display\n", argv[0]);
+ return -1;
+ }
+
+ if (!display && !(display = XOpenDisplay(NULL))) {
+ printf("Cannot open default display\n");
+ return -1;
+ }
+
+ if (!XResQueryExtension(display, &event, &error)) {
+ printf("X-Resource extension not present\n");
+ return -1;
+ }
+ printf("X-Resource extension present: event=%d error=%d\n", event, error);
+
+ if (!XResQueryVersion(display, &major_version, &minor_version)) {
+ printf("XResQueryVersion call failed\n");
+ return -1;
+ }
+ printf("X-Resource extension version: %d.%d\n",
+ major_version, minor_version);
+
+ XResQueryClients(display, &count, &clients);
+
+ printf("%d clients:\n", count);
+ for (i = 0; i < count; i++) {
+ int c, j;
+ XResType *types;
+
+ XResQueryClientResources(display, clients[i].resource_base,
+ &c, &types);
+ printf(" %3d: base = 0x%lx, mask = 0x%lx, %d resource types:\n",
+ i, (long unsigned)clients[i].resource_base,
+ (long unsigned)clients[i].resource_mask, c);
+ for (j = 0; j < c; j++) {
+ char *name = XGetAtomName(display, types[j].resource_type);
+ printf(" %2d: %s %d\n", j, name, types[j].count);
+ XFree(name);
+ }
+ XFree(types);
+ }
+
+ XFree(clients);
+ XCloseDisplay(display);
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/examples/xbell.c b/nx-X11/programs/Xserver/hw/dmx/examples/xbell.c
new file mode 100644
index 000000000..4d55740a8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/examples/xbell.c
@@ -0,0 +1,102 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+
+static void pkc(XKeyboardControl *kc, unsigned long vm)
+{
+ if (vm&KBKeyClickPercent)
+ printf(" key_click_percent = %d\n", kc->key_click_percent);
+ if (vm&KBBellPercent)
+ printf(" bell_percent = %d\n", kc->bell_percent);
+ if (vm&KBBellPitch)
+ printf(" bell_pitch = %d\n", kc->bell_pitch);
+ if (vm&KBBellDuration)
+ printf(" bell_duration = %d\n", kc->bell_duration);
+ if (vm&KBLed)
+ printf(" led = 0x%x\n", kc->led);
+ if (vm&KBLedMode)
+ printf(" led_mode = %d\n", kc->led_mode);
+ if (vm&KBKey)
+ printf(" key = %d\n", kc->key);
+ if (vm&KBAutoRepeatMode)
+ printf(" auto_repeat_mode = %d\n", kc->auto_repeat_mode);
+}
+
+static void pks(XKeyboardState *ks)
+{
+ printf(" key_click_percent = %d\n", ks->key_click_percent);
+ printf(" bell_percent = %d\n", ks->bell_percent);
+ printf(" bell_pitch = %u\n", ks->bell_pitch);
+ printf(" bell_duration = %u\n", ks->bell_duration);
+ printf(" led_mask = 0x%lx\n", ks->led_mask);
+ printf(" global_auto_repeat = %d\n", ks->global_auto_repeat);
+}
+
+int main(int argc, char **argv)
+{
+ Display *display = XOpenDisplay(NULL);
+ XKeyboardControl kc;
+ XKeyboardState ks;
+ unsigned long vm;
+ int percent;
+
+ if (argc != 5) {
+ printf("Usage: xbell percent baseVolume pitch duration\n");
+ return 1;
+ }
+
+ vm = (KBBellPercent
+ | KBBellPitch
+ | KBBellDuration);
+ percent = atoi(argv[1]);
+ kc.bell_percent = atoi(argv[2]);
+ kc.bell_pitch = atoi(argv[3]);
+ kc.bell_duration = atoi(argv[4]);
+
+ printf("Setting:\n");
+ pkc(&kc, vm);
+ XChangeKeyboardControl(display, vm, &kc);
+
+ printf("Have:\n");
+ XGetKeyboardControl(display, &ks);
+ pks(&ks);
+
+ XBell(display, 100);
+
+ XCloseDisplay(display);
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/examples/xdmx.c b/nx-X11/programs/Xserver/hw/dmx/examples/xdmx.c
new file mode 100644
index 000000000..3fec7dd3d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/examples/xdmx.c
@@ -0,0 +1,240 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001,2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/dmxext.h>
+
+static void indent(int level)
+{
+ int i;
+ for (i = 0; i < level; i++) printf(" ");
+}
+
+static void print_window_id(const char *displayName, Display *display,
+ Window window, int level, int child)
+{
+ char *name;
+
+ if (!XFetchName(display, window, &name)) name = NULL;
+ indent(level);
+ if (child) printf("(%d) ", child);
+ printf("%s window 0x%08lx: %s%s\n",
+ displayName,
+ (long unsigned)window,
+ name ? name : "",
+ (window == DefaultRootWindow(display))
+ ? " (DMX root window)" : "");
+ if (name) XFree(name);
+}
+
+static void print_info(Display *display, Window window, int level, int child)
+{
+ DMXWindowAttributes winfo[128];
+ int count;
+ int i;
+
+ if (!DMXGetWindowAttributes(display, window, &count, 128, winfo)) {
+ printf("Could not get window information for 0x%08lx\n",
+ (long unsigned)window);
+ exit(-2);
+ }
+ printf("\n");
+ print_window_id("DMX", display, window, level, child);
+ for (i = 0; i < count; i++) {
+ DMXScreenAttributes sinfo;
+ Display *backend;
+
+ /* This could also be cached -- the information doesn't change. */
+ if (!DMXGetScreenAttributes(display, winfo[i].screen, &sinfo)) {
+ printf("Could not get screen information for screen %d\n", i);
+ exit(-2);
+ }
+ if (!(backend = XOpenDisplay(sinfo.displayName))) {
+ printf("Cannot open backend display %s\n", sinfo.displayName);
+ exit(-2);
+ }
+ XCloseDisplay(backend);
+
+ indent(level+1);
+ printf("%s window 0x%08lx: %dx%d%+d%+d",
+ sinfo.displayName,
+ (long unsigned)winfo[i].window,
+ winfo[i].pos.width, winfo[i].pos.height,
+ winfo[i].pos.x, winfo[i].pos.y);
+ if (!winfo[i].vis.width
+ && !winfo[i].vis.height
+ && !winfo[i].vis.x
+ && !winfo[i].vis.y) printf(" not visible\n");
+ else if (winfo[i].vis.width == winfo[i].pos.width
+ && winfo[i].vis.height == winfo[i].pos.height) {
+ printf( " %+d%+d\n", winfo[i].vis.x, winfo[i].vis.y);
+ } else {
+ printf( " %dx%d%+d%+d\n",
+ winfo[i].vis.width, winfo[i].vis.height,
+ winfo[i].vis.x, winfo[i].vis.y);
+ }
+ }
+}
+
+static void print_tree(Display *display, Window window, int level, int child)
+{
+ Window root, parent;
+ Window *list;
+ unsigned int count;
+ unsigned int i;
+
+ print_info(display, window, level, child);
+
+ if (!XQueryTree(display, window, &root, &parent, &list, &count)) {
+ printf("Cannot query window tree for 0x%08lx\n",
+ (long unsigned)window);
+ exit(-3);
+ }
+
+ if (count) {
+ indent(level+1);
+ printf("%d child%s:\n", count, count > 1 ? "ren" : "");
+ for (i = 0; i < count; i++) {
+ print_tree(display, list[i], level+1, i+1);
+ }
+ }
+}
+
+static const char *core(DMXInputAttributes *iinfo)
+{
+ if (iinfo->isCore) return "core";
+ else if (iinfo->sendsCore) return "extension (sends core)";
+ else return "extension";
+}
+
+int main(int argc, char **argv)
+{
+ Display *display = NULL;
+ Window window = 0;
+ int event_base;
+ int error_base;
+ int major_version, minor_version, patch_version;
+ DMXScreenAttributes sinfo;
+ DMXInputAttributes iinfo;
+ int count;
+ int i;
+
+ if (argc == 2 || argc == 3) {
+ if (!(display = XOpenDisplay(argv[1]))) {
+ printf("Cannot open display %s\n", argv[1]);
+ return -1;
+ }
+ if (argc == 3) window = strtol(argv[2], NULL, 0);
+ } else {
+ printf("Usage: %s display [windowid]\n", argv[0]);
+ return -1;
+ }
+
+ if (!display && !(display = XOpenDisplay(NULL))) {
+ printf("Cannot open default display\n");
+ return -1;
+ }
+
+ if (!DMXQueryExtension(display, &event_base, &error_base)) {
+ printf("DMX extension not present\n");
+ return -1;
+ }
+ printf("DMX extension present: event_base = %d, error_base = %d\n",
+ event_base, error_base);
+
+ if (!DMXQueryVersion(display,
+ &major_version, &minor_version, &patch_version)) {
+ printf("Could not get extension version\n");
+ return -1;
+ }
+ printf("Extension version: %d.%d patch %d\n",
+ major_version, minor_version, patch_version);
+
+ if (!DMXGetScreenCount(display, &count)) {
+ printf("Could not get screen count\n");
+ return -1;
+ }
+ printf("Screen count = %d\n", count);
+
+ for (i = 0; i < count; i++) {
+ if (!DMXGetScreenAttributes(display, i, &sinfo)) {
+ printf("Could not get screen information for %d\n", i);
+ return -1;
+ }
+ printf("%d: %s %ux%u+%d+%d %d @%dx%d (root: %dx%d%+d%+d)\n",
+ i, sinfo.displayName,
+ sinfo.screenWindowWidth, sinfo.screenWindowHeight,
+ sinfo.screenWindowXoffset, sinfo.screenWindowYoffset,
+ sinfo.logicalScreen,
+ sinfo.rootWindowXorigin, sinfo.rootWindowYorigin,
+ sinfo.rootWindowWidth, sinfo.rootWindowHeight,
+ sinfo.rootWindowXoffset, sinfo.rootWindowYoffset);
+ }
+
+ if (major_version == 1 && minor_version >= 1) {
+ if (!DMXGetInputCount(display, &count)) {
+ printf("Could not get input count\n");
+ return -1;
+ }
+ printf("Input count = %d\n", count);
+ for (i = 0; i < count; i++) {
+ if (!DMXGetInputAttributes(display, i, &iinfo)) {
+ printf("Could not get input information for id %d\n", i);
+ return -1;
+ }
+ switch (iinfo.inputType) {
+ case DMXLocalInputType:
+ printf(" %2d local %-20.20s %s\n", i, "", core(&iinfo));
+ break;
+ case DMXConsoleInputType:
+ printf(" %2d console %-20.20s %s\n",
+ i, iinfo.name, core(&iinfo));
+ break;
+ case DMXBackendInputType:
+ printf(" %2d backend %-20.20s id=%2d screen=%2d %s\n",
+ i, iinfo.name, iinfo.physicalId, iinfo.physicalScreen,
+ core(&iinfo));
+ break;
+ }
+ }
+ }
+
+ if (window) print_info(display, window, 0, 0);
+ else print_tree(display, DefaultRootWindow(display), 0, 0);
+
+ XCloseDisplay(display);
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/examples/xinput.c b/nx-X11/programs/Xserver/hw/dmx/examples/xinput.c
new file mode 100644
index 000000000..c2b9bc0f4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/examples/xinput.c
@@ -0,0 +1,319 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001,2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <X11/Xlib.h>
+#include <X11/XKBlib.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/XKB.h>
+#include <X11/extensions/XKBstr.h>
+#include <X11/extensions/dmxext.h>
+#include <sys/time.h>
+
+static const char *core(DMXInputAttributes *iinf)
+{
+ if (iinf->isCore) return "core";
+ else if (iinf->sendsCore) return "extension (sends core events)";
+ else return "extension";
+}
+
+static void printdmxinfo(Display *display, int id)
+{
+ int event_base;
+ int error_base;
+ int major_version, minor_version, patch_version;
+ DMXInputAttributes iinf;
+ Display *backend;
+ char *backendname = NULL;
+
+ if (!DMXQueryExtension(display, &event_base, &error_base)) return;
+ if (!DMXQueryVersion(display, &major_version, &minor_version,
+ &patch_version)) return;
+ if (major_version == 1 && minor_version == 0) return; /* too old */
+ if (!DMXGetInputAttributes(display, id, &iinf)) return;
+
+ printf(" DMX Information: ");
+ if (iinf.detached) printf("detached ");
+ else printf("active ");
+ switch (iinf.inputType) {
+ case DMXLocalInputType:
+ printf("local, %s", core(&iinf));
+ break;
+ case DMXConsoleInputType:
+ printf("console %s, %s", iinf.name, core(&iinf));
+ break;
+ case DMXBackendInputType:
+ if (iinf.physicalId >= 0) {
+ if ((backend = XOpenDisplay(iinf.name))) {
+ XExtensionVersion *ext = XGetExtensionVersion(backend, INAME);
+ if (ext && ext != (XExtensionVersion *)NoSuchExtension) {
+ int count, i;
+ XDeviceInfo *devInfo = XListInputDevices(backend, &count);
+ if (devInfo) {
+ for (i = 0; i < count; i++) {
+ if ((unsigned)iinf.physicalId == devInfo[i].id
+ && devInfo[i].name) {
+ backendname = strdup(devInfo[i].name);
+ break;
+ }
+ }
+ XFreeDeviceList(devInfo);
+ }
+ }
+ XCloseDisplay(backend);
+ }
+ }
+ printf("backend o%d/%s",iinf.physicalScreen, iinf.name);
+ if (iinf.physicalId >= 0) printf("/id%d", iinf.physicalId);
+ if (backendname) {
+ printf("=%s", backendname);
+ free(backendname);
+ }
+ printf(" %s", core(&iinf));
+ break;
+ }
+ printf("\n");
+}
+
+int main(int argc, char **argv)
+{
+ Display *display = NULL;
+ int device = -1;
+ int newmouse = -1;
+ int newkbd = -1;
+ int count;
+ int i, j;
+ XDeviceInfo *devInfo;
+ XExtensionVersion *ext;
+
+ if (argc == 2 || argc == 3 || argc == 4 || argc == 5) {
+ if (!(display = XOpenDisplay(argv[1]))) {
+ printf("Cannot open display %s\n", argv[1]);
+ return -1;
+ }
+ if (argc >= 3) device = strtol(argv[2], NULL, 0);
+ if (argc >= 4) newmouse = strtol(argv[3], NULL, 0);
+ if (argc >= 5) newkbd = strtol(argv[4], NULL, 0);
+ } else {
+ printf("Usage: %s display [device] [newmouse] [newkbd]\n", argv[0]);
+ return -1;
+ }
+
+ if (!display && !(display = XOpenDisplay(NULL))) {
+ printf("Cannot open default display\n");
+ return -1;
+ }
+
+ ext = XGetExtensionVersion(display, INAME);
+ if (!ext || ext == (XExtensionVersion *)NoSuchExtension) {
+ printf("No XInputExtension\n");
+ return -1;
+ }
+ printf("%s version %d.%d\n",
+ INAME, ext->major_version, ext->minor_version);
+
+ if (!(devInfo = XListInputDevices(display, &count)) || !count) {
+ printf("Cannot list devices\n");
+ return -1;
+ }
+
+ for (i = 0; i < count; i++) {
+ XAnyClassPtr any;
+ const char *kind = "Unknown";
+ int has_key = 0;
+
+ switch (devInfo[i].use) {
+ case IsXPointer: kind = "XPointer"; break;
+ case IsXKeyboard: kind = "XKeyboard"; break;
+ case IsXExtensionDevice: kind = "XExtensionDevice"; break;
+ }
+ printf("%2lu %-20.20s %-16.16s",
+ (long unsigned)devInfo[i].id,
+ devInfo[i].name ? devInfo[i].name : "", kind);
+
+ for (j = 0, any = devInfo[i].inputclassinfo;
+ j < devInfo[i].num_classes;
+ any = (XAnyClassPtr)((char *)any + any->length), j++) {
+ const char *class = "unk";
+ switch (any->class) {
+ case KeyClass: class = "key"; ++has_key; break;
+ case ButtonClass: class = "btn"; break;
+ case ValuatorClass: class = "val"; break;
+ case FeedbackClass: class = "fdb"; break;
+ case ProximityClass: class = "prx"; break;
+ case FocusClass: class = "foc"; break;
+ case OtherClass: class = "oth"; break;
+ }
+ printf(" %s", class);
+ }
+ printf("\n");
+ printdmxinfo(display, i);
+
+ if (has_key) {
+ XkbDescPtr xkb;
+ if ((xkb = XkbGetKeyboard(display,
+ XkbAllComponentsMask,
+ devInfo[i].id))) {
+ printf(" Xkb Information:\n");
+ printf(" Device id = %d\n", xkb->device_spec);
+ printf(" Min keycode = 0x%02x\n", xkb->min_key_code);
+ printf(" Max keycode = 0x%02x\n", xkb->max_key_code);
+#define PRINTNAME(x) \
+ printf(" %s = %s\n", \
+ #x, xkb->names->x ? XGetAtomName(display, xkb->names->x) : "")
+ PRINTNAME(keycodes);
+ PRINTNAME(geometry);
+ PRINTNAME(symbols);
+ PRINTNAME(types);
+ PRINTNAME(compat);
+ }
+ }
+ }
+
+ if (newmouse >= 0) {
+ XDevice *dev;
+
+ printf("Trying to make device %d core mouse\n", newmouse);
+ dev = XOpenDevice(display, devInfo[newmouse].id);
+ printf("Status = %d\n",
+ XChangePointerDevice(display, dev, 0, 1));
+ return 0;
+ }
+
+ if (newkbd >= 0) {
+ XDevice *dev;
+
+ printf("Trying to make device %d core keyboard\n", newkbd);
+ dev = XOpenDevice(display, devInfo[newkbd].id);
+ printf("Status = %d\n",
+ XChangeKeyboardDevice(display, dev));
+ return 0;
+ }
+
+
+ if (device >=0){
+#define MAX_EVENTS 100
+ int cnt = 0;
+ XDevice *dev;
+ XEventClass event_list[MAX_EVENTS];
+ int event_type[MAX_EVENTS];
+ const char *names[MAX_EVENTS];
+ int total = 0;
+
+#define ADD(type) \
+ if (cnt >= MAX_EVENTS) abort(); \
+ names[cnt] = #type; \
+ type(dev, event_type[cnt], event_list[cnt]); \
+ if (event_type[cnt]) ++cnt
+
+
+ dev = XOpenDevice(display, devInfo[device].id);
+ ADD(DeviceKeyPress);
+ ADD(DeviceKeyRelease);
+ ADD(DeviceButtonPress);
+ ADD(DeviceButtonRelease);
+ ADD(DeviceMotionNotify);
+ ADD(DeviceFocusIn);
+ ADD(DeviceFocusOut);
+ ADD(ProximityIn);
+ ADD(ProximityOut);
+ ADD(DeviceStateNotify);
+ ADD(DeviceMappingNotify);
+ ADD(ChangeDeviceNotify);
+
+ for (i = 0; i < cnt; i++) {
+ printf("Waiting for %s events of type %d (%lu) on 0x%08lx\n",
+ names[i],
+ event_type[i], (unsigned long)event_list[i],
+ (long unsigned)DefaultRootWindow(display));
+ }
+ XSelectExtensionEvent(display, DefaultRootWindow(display),
+ event_list, cnt);
+
+ for (;;) {
+ XEvent event;
+ XNextEvent(display, &event);
+ for (i = 0; i < cnt; i++) {
+ XDeviceMotionEvent *e = (XDeviceMotionEvent *)&event;
+ XDeviceButtonEvent *b = (XDeviceButtonEvent *)&event;
+ if (event.type == event_type[i]) {
+ printf("%s id=%lu (%d @ %d,%d; s=0x%04x, d=%d, t=%lu)"
+ " axes_count=%d first=%d %d %d %d %d %d %d\n",
+ names[i],
+ (long unsigned)e->deviceid,
+ e->type,
+ e->x, e->y,
+ e->device_state,
+ b->button,
+ (long unsigned)b->time,
+ e->axes_count,
+ e->first_axis,
+ e->axis_data[0],
+ e->axis_data[1],
+ e->axis_data[2],
+ e->axis_data[3],
+ e->axis_data[4],
+ e->axis_data[5]);
+ }
+ }
+ ++total;
+#if 0
+ /* Used to check motion history for
+ * extension devices. */
+ if (!(total % 10)) {
+ XDeviceTimeCoord *tc;
+ int n, m, a;
+ struct timeval tv;
+ unsigned long ms;
+ gettimeofday(&tv, NULL);
+ ms = tv.tv_sec * 1000 + tv.tv_usec / 1000;
+ tc = XGetDeviceMotionEvents(display, dev, ms-1000, ms,
+ &n, &m, &a);
+ printf("Got %d events of mode %s with %d axes\n",
+ n, m == Absolute ? "Absolute" : "Relative", a);
+ for (i = 0; i < n && i < 10; i++) {
+ printf(" %d: %lu %d %d\n",
+ i, tc[i].time, tc[i].data[0], tc[i].data[1]);
+ }
+ XFreeDeviceMotionEvents(tc);
+ }
+#endif
+ }
+ }
+
+ XCloseDisplay(display);
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/examples/xled.c b/nx-X11/programs/Xserver/hw/dmx/examples/xled.c
new file mode 100644
index 000000000..cb4bcb1ac
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/examples/xled.c
@@ -0,0 +1,125 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <X11/Xlib.h>
+#include <X11/XKBlib.h>
+#include <X11/extensions/XKB.h>
+#include <X11/extensions/XKBstr.h>
+#include <sys/time.h>
+
+int main(int argc, char **argv)
+{
+ Display *display = NULL;
+ int mask = 0;
+ unsigned i;
+ XKeyboardState ks;
+ XKeyboardControl kc;
+ XkbDescPtr xkb;
+ int old[32];
+
+ if (argc == 2 || argc == 3) {
+ if (!(display = XOpenDisplay(argv[1]))) {
+ printf("Cannot open display %s\n", argv[1]);
+ return -1;
+ }
+ if (argc >= 3) mask = strtol(argv[2], NULL, 0);
+ } else {
+ printf("Usage: %s display [mask]\n", argv[0]);
+ return -1;
+ }
+
+ if (!display && !(display = XOpenDisplay(NULL))) {
+ printf("Cannot open default display\n");
+ return -1;
+ }
+
+ if (!(xkb = XkbAllocKeyboard())) {
+ printf("Cannot allocate\n");
+ return -1;
+ }
+ if (XkbGetIndicatorMap(display, XkbAllIndicatorsMask, xkb)) {
+ printf("Cannot Get Indicators\n");
+ return -1;
+ }
+ if (XkbGetNames(display, XkbAllNamesMask, xkb)) {
+ printf("Cannot Get Names\n");
+ return -1;
+ }
+ for (i = 0; i < XkbNumIndicators; i++) {
+ if (xkb->indicators->phys_indicators & (1 << i)) {
+ printf("led %d = %d\n", i, xkb->indicators->maps[i].flags);
+ old[i] = xkb->indicators->maps[i].flags;
+ xkb->indicators->maps[i].flags = XkbIM_NoAutomatic;
+ }
+ }
+ printf("XkbSetIndicatorMap = %d\n", XkbSetIndicatorMap(display, ~0, xkb));
+ XkbFreeKeyboard(xkb, 0, True);
+
+
+ if (!(xkb = XkbAllocKeyboard())) {
+ printf("Cannot allocate\n");
+ return -1;
+ }
+ if (XkbGetIndicatorMap(display, XkbAllIndicatorsMask, xkb)) {
+ printf("Cannot Get Indicators\n");
+ return -1;
+ }
+ for (i = 0; i < XkbNumIndicators; i++) {
+ if (xkb->indicators->phys_indicators & (1 << i))
+ printf("led %d = %d\n", i, xkb->indicators->maps[i].flags);
+ }
+
+ printf("XGetKeyboardControl = %d\n", XGetKeyboardControl(display, &ks));
+ printf("old mask = 0x%08lx\n", ks.led_mask);
+ for (i = 0; i < 5; i++) {
+ kc.led = i + 1;
+ kc.led_mode = (mask & (1 << i)) ? LedModeOn : LedModeOff;
+ printf("XChangeKeyboardControl = %d\n",
+ XChangeKeyboardControl(display, KBLed | KBLedMode, &kc));
+ }
+ printf("XGetKeyboardControl = %d\n", XGetKeyboardControl(display, &ks));
+ printf("new mask = 0x%08lx\n", ks.led_mask);
+
+ for (i = 0; i < XkbNumIndicators; i++)
+ if (xkb->indicators->phys_indicators & (i << 1))
+ xkb->indicators->maps[i].flags = old[i];
+ printf("XkbSetIndicatorMap = %d\n", XkbSetIndicatorMap(display, ~0, xkb));
+
+ XkbFreeKeyboard(xkb, 0, True);
+ XCloseDisplay(display);
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/examples/xtest.c b/nx-X11/programs/Xserver/hw/dmx/examples/xtest.c
new file mode 100644
index 000000000..b6f223d27
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/examples/xtest.c
@@ -0,0 +1,76 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/XTest.h>
+
+int main(int argc, char **argv)
+{
+ Display *display = NULL;
+ int event_base;
+ int error_base;
+ int major_version, minor_version;
+
+ if (argc == 2) {
+ if (!(display = XOpenDisplay(argv[1]))) {
+ printf("Cannot open display %s\n", argv[1]);
+ return -1;
+ }
+ } else {
+ printf("Usage: %s display\n", argv[0]);
+ return -1;
+ }
+
+ if (!display && !(display = XOpenDisplay(NULL))) {
+ printf("Cannot open default display\n");
+ return -1;
+ }
+
+ if (!XTestQueryExtension(display, &event_base, &error_base,
+ &major_version, &minor_version)) {
+ printf("XTEST extension not present\n");
+ return -1;
+ }
+ printf("XTEST extension present: event_base = %d, error_base = %d\n",
+ event_base, error_base);
+ printf("Extension version: %d.%d\n", major_version, minor_version);
+
+ XTestFakeKeyEvent(display, 30, True, 10);
+ XTestFakeKeyEvent(display, 30, False, 10);
+
+ XCloseDisplay(display);
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/Imakefile b/nx-X11/programs/Xserver/hw/dmx/glxProxy/Imakefile
new file mode 100644
index 000000000..f711f3410
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/Imakefile
@@ -0,0 +1,52 @@
+XCOMM $XFree86: xc/programs/Xserver/GL/glx/Imakefile,v 1.9 2001/04/28 13:55:36 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#include <dmx.cf>
+
+#if HasGcc3 && HasGnuMake
+XCOMM This makes the glxProxy subdirectory much less noisy, with respect
+XCOMM to warngings. The code is automatically generated, so we just want
+XCOMM to shut the compiler up at this point. However, some of the suppressed
+XCOMM warnings may point to real errors, so they should be investigated at
+XCOMM some time in the future.
+CFLAGS += -Wno-unused -Wno-implicit -Wno-uninitialized \
+ -Wno-redundant-decls -Wno-sign-compare -Wno-strict-prototypes \
+ -Wno-float-equal -Wno-missing-declarations -Wno-missing-prototypes
+#endif
+
+ SRCS = g_disptab.c glxcmds.c glxext.c glxutil.c g_renderswap.c \
+ render2swap.c renderpixswap.c global.c glxcmdsswap.c \
+ compsize.c glxscreens.c glxvisuals.c \
+ glxsingle.c glxvendor.c glxfbconfig.c glxswap.c $(MSRCS)
+
+ OBJS = g_disptab.o glxcmds.o glxext.o glxutil.o g_renderswap.o \
+ render2swap.o renderpixswap.o global.o glxcmdsswap.o \
+ compsize.o glxscreens.o glxvisuals.o \
+ glxsingle.o glxvendor.o glxfbconfig.o glxswap.o $(MOBJS)
+
+ INCLUDES = -I. -I$(SERVERSRC)/include -I$(INCLUDESRC) \
+ -I$(XINCLUDESRC) -I$(SERVERSRC)/mi \
+ -I$(EXTINCSRC) -I$(FONTINCSRC) -I$(MESASRCDIR)/include \
+ -I$(XF86SRC) -I$(XF86OSSRC) -I$(SERVERSRC)/GL/include \
+ -I$(SERVERSRC)/hw/dmx -I$(SERVERSRC)/Xext \
+ -I$(SERVERSRC)/render
+
+XCOMM If you add "-DDEBUG" in DEFINES, then make sure you also
+XCOMM add DEBUG to the define in ../mesa/src/X/xf86glx.c
+ DEFINES = $(GLX_DEFINES) $(DMX_DEFINES)
+
+
+#if DoLoadableServer
+ModuleObjectRule()
+#else
+NormalLibraryObjectRule()
+#endif
+SubdirLibraryRule($(OBJS))
+LibraryModuleTarget(glxProxy,$(OBJS))
+
+LintLibraryTarget(glxProxy,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/compsize.c b/nx-X11/programs/Xserver/hw/dmx/glxProxy/compsize.c
new file mode 100644
index 000000000..cffa1af8d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/compsize.c
@@ -0,0 +1,564 @@
+/* $XFree86: xc/lib/GL/glx/compsize.c,v 1.3 2001/03/21 16:04:39 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include <GL/gl.h>
+
+GLint __glFogiv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_FOG_COLOR: return 4;
+ case GL_FOG_DENSITY: return 1;
+ case GL_FOG_END: return 1;
+ case GL_FOG_MODE: return 1;
+ case GL_FOG_INDEX: return 1;
+ case GL_FOG_START: return 1;
+ default:
+ return 0;
+ }
+}
+
+GLint __glFogfv_size(GLenum pname)
+{
+ return __glFogiv_size(pname);
+}
+
+GLint __glCallLists_size(GLsizei n, GLenum type)
+{
+ GLint size;
+
+ if (n < 0) return 0;
+ switch (type) {
+ case GL_BYTE: size = 1; break;
+ case GL_UNSIGNED_BYTE: size = 1; break;
+ case GL_SHORT: size = 2; break;
+ case GL_UNSIGNED_SHORT: size = 2; break;
+ case GL_INT: size = 4; break;
+ case GL_UNSIGNED_INT: size = 4; break;
+ case GL_FLOAT: size = 4; break;
+ case GL_2_BYTES: size = 2; break;
+ case GL_3_BYTES: size = 3; break;
+ case GL_4_BYTES: size = 4; break;
+ default:
+ return 0;
+ }
+ return n * size;
+}
+
+GLint __glDrawPixels_size(GLenum format, GLenum type, GLsizei w, GLsizei h)
+{
+ GLint elements, esize;
+
+ switch (format) {
+ case GL_COLOR_INDEX:
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_COMPONENT:
+ elements = 1;
+ break;
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ elements = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ elements = 2;
+ break;
+ case GL_RGB:
+ elements = 3;
+ break;
+ case GL_RGBA:
+ case GL_ABGR_EXT:
+ elements = 4;
+ break;
+ default:
+ return 0;
+ }
+ switch (type) {
+ case GL_BITMAP:
+ if (format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX) {
+ return (h * ((w+7)/8));
+ } else {
+ return 0;
+ }
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ esize = 1;
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ esize = 1;
+ elements = 1;
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ esize = 2;
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ esize = 2;
+ elements = 1;
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ esize = 4;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ esize = 4;
+ elements = 1;
+ break;
+ default:
+ return 0;
+ }
+ return (elements * esize * w * h);
+}
+
+GLint __glBitmap_size(GLsizei w, GLsizei h)
+{
+ return __glDrawPixels_size(GL_COLOR_INDEX, GL_BITMAP, w, h);
+}
+
+GLint __glTexGendv_size(GLenum e)
+{
+ switch (e) {
+ case GL_TEXTURE_GEN_MODE:
+ return 1;
+ case GL_OBJECT_PLANE:
+ case GL_EYE_PLANE:
+ return 4;
+ default:
+ return 0;
+ }
+}
+
+GLint __glTexGenfv_size(GLenum e)
+{
+ return __glTexGendv_size(e);
+}
+
+GLint __glTexGeniv_size(GLenum e)
+{
+ return __glTexGendv_size(e);
+}
+
+GLint __glTexParameterfv_size(GLenum e)
+{
+ switch (e) {
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ case GL_TEXTURE_WRAP_R:
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ return 1;
+ case GL_TEXTURE_BORDER_COLOR:
+ return 4;
+ case GL_TEXTURE_PRIORITY:
+ return 1;
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+GLint __glTexParameteriv_size(GLenum e)
+{
+ return __glTexParameterfv_size(e);
+}
+
+GLint __glTexEnvfv_size(GLenum e)
+{
+ switch (e) {
+ case GL_TEXTURE_ENV_MODE:
+ return 1;
+ case GL_TEXTURE_ENV_COLOR:
+ return 4;
+ default:
+ return 0;
+ }
+}
+
+GLint __glTexEnviv_size(GLenum e)
+{
+ return __glTexEnvfv_size(e);
+}
+
+GLint __glTexImage1D_size(GLenum format, GLenum type, GLsizei w)
+{
+ GLint elements, esize;
+
+ if (w < 0) return 0;
+ switch (format) {
+ case GL_COLOR_INDEX:
+ elements = 1;
+ break;
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ elements = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ elements = 2;
+ break;
+ case GL_RGB:
+ elements = 3;
+ break;
+ case GL_RGBA:
+ case GL_ABGR_EXT:
+ elements = 4;
+ break;
+ default:
+ return 0;
+ }
+ switch (type) {
+ case GL_BITMAP:
+ if (format == GL_COLOR_INDEX) {
+ return (w+7)/8;
+ } else {
+ return 0;
+ }
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ esize = 1;
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ esize = 1;
+ elements = 1;
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ esize = 2;
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ esize = 2;
+ elements = 1;
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ esize = 4;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ esize = 4;
+ elements = 1;
+ break;
+ default:
+ return 0;
+ }
+ return (elements * esize * w);
+}
+
+GLint __glTexImage2D_size(GLenum format, GLenum type, GLsizei w, GLsizei h)
+{
+ GLint elements, esize;
+
+ if (w < 0) return 0;
+ if (h < 0) return 0;
+ switch (format) {
+ case GL_COLOR_INDEX:
+ elements = 1;
+ break;
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ elements = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ elements = 2;
+ break;
+ case GL_RGB:
+ elements = 3;
+ break;
+ case GL_RGBA:
+ case GL_ABGR_EXT:
+ elements = 4;
+ break;
+ default:
+ return 0;
+ }
+ switch (type) {
+ case GL_BITMAP:
+ if (format == GL_COLOR_INDEX) {
+ return (h * ((w+7)/8));
+ } else {
+ return 0;
+ }
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ esize = 1;
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ esize = 1;
+ elements = 1;
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ esize = 2;
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ esize = 2;
+ elements = 1;
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ esize = 4;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ esize = 4;
+ elements = 1;
+ break;
+ default:
+ return 0;
+ }
+ return (elements * esize * w * h);
+}
+
+GLint __glTexImage3D_size(GLenum format, GLenum type, GLsizei w, GLsizei h,
+ GLsizei d)
+{
+ GLint elements, esize;
+
+ if (w < 0) return 0;
+ if (h < 0) return 0;
+ if (d < 0) return 0;
+ switch (format) {
+ case GL_COLOR_INDEX:
+ elements = 1;
+ break;
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ elements = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ elements = 2;
+ break;
+ case GL_RGB:
+ elements = 3;
+ break;
+ case GL_RGBA:
+ case GL_ABGR_EXT:
+ elements = 4;
+ break;
+ default:
+ return 0;
+ }
+ switch (type) {
+ case GL_BITMAP:
+ if (format == GL_COLOR_INDEX) {
+ return (d * (h * ((w+7)/8)));
+ } else {
+ return 0;
+ }
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ esize = 1;
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ esize = 1;
+ elements = 1;
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ esize = 2;
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ esize = 2;
+ elements = 1;
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ esize = 4;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ esize = 4;
+ elements = 1;
+ break;
+ default:
+ return 0;
+ }
+ return (elements * esize * w * h * d);
+}
+
+GLint __glLightfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_SPOT_EXPONENT: return 1;
+ case GL_SPOT_CUTOFF: return 1;
+ case GL_AMBIENT: return 4;
+ case GL_DIFFUSE: return 4;
+ case GL_SPECULAR: return 4;
+ case GL_POSITION: return 4;
+ case GL_SPOT_DIRECTION: return 3;
+ case GL_CONSTANT_ATTENUATION: return 1;
+ case GL_LINEAR_ATTENUATION: return 1;
+ case GL_QUADRATIC_ATTENUATION: return 1;
+ default:
+ return 0;
+ }
+}
+
+GLint __glLightiv_size(GLenum pname)
+{
+ return __glLightfv_size(pname);
+}
+
+GLint __glLightModelfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_LIGHT_MODEL_AMBIENT: return 4;
+ case GL_LIGHT_MODEL_LOCAL_VIEWER: return 1;
+ case GL_LIGHT_MODEL_TWO_SIDE: return 1;
+ case GL_LIGHT_MODEL_COLOR_CONTROL: return 1;
+ default:
+ return 0;
+ }
+}
+
+GLint __glLightModeliv_size(GLenum pname)
+{
+ return __glLightModelfv_size(pname);
+}
+
+GLint __glMaterialfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_SHININESS: return 1;
+ case GL_EMISSION: return 4;
+ case GL_AMBIENT: return 4;
+ case GL_DIFFUSE: return 4;
+ case GL_SPECULAR: return 4;
+ case GL_AMBIENT_AND_DIFFUSE: return 4;
+ case GL_COLOR_INDEXES: return 3;
+ default:
+ return 0;
+ }
+}
+
+GLint __glMaterialiv_size(GLenum pname)
+{
+ return __glMaterialfv_size(pname);
+}
+
+GLint __glColorTableParameterfv_size(GLenum pname)
+{
+ switch (pname) {
+ case GL_COLOR_TABLE_FORMAT:
+ case GL_COLOR_TABLE_WIDTH:
+ case GL_COLOR_TABLE_RED_SIZE:
+ case GL_COLOR_TABLE_GREEN_SIZE:
+ case GL_COLOR_TABLE_BLUE_SIZE:
+ case GL_COLOR_TABLE_ALPHA_SIZE:
+ case GL_COLOR_TABLE_LUMINANCE_SIZE:
+ case GL_COLOR_TABLE_INTENSITY_SIZE:
+ return 1;
+ case GL_COLOR_TABLE_SCALE:
+ case GL_COLOR_TABLE_BIAS:
+ return 4;
+ default:
+ return -1;
+ }
+}
+
+GLint __glColorTableParameteriv_size(GLenum pname)
+{
+ return __glColorTableParameterfv_size(pname);
+}
+
+GLint __glConvolutionParameterfv_size(GLenum pname)
+{
+ switch(pname) {
+ case GL_CONVOLUTION_BORDER_MODE:
+ return 1;
+ case GL_CONVOLUTION_BORDER_COLOR:
+ case GL_CONVOLUTION_FILTER_SCALE:
+ case GL_CONVOLUTION_FILTER_BIAS:
+ return 4;
+ default: /* error: bad enum value */
+ return -1;
+ }
+}
+
+GLint __glConvolutionParameteriv_size(GLenum pname)
+{
+ return __glConvolutionParameterfv_size(pname);
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/g_disptab.c b/nx-X11/programs/Xserver/hw/dmx/glxProxy/g_disptab.c
new file mode 100644
index 000000000..f507a874f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/g_disptab.c
@@ -0,0 +1,612 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/g_disptab.c,v 1.3 2001/03/21 16:29:35 dawes Exp $ */
+/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#include "glxserver.h"
+#include "glxext.h"
+#include "g_disptab.h"
+#include "glxsingle.h"
+
+__GLXdispatchSingleProcPtr __glXSingleTable[] = {
+ __glXNoSuchSingleOpcode,
+ __glXRender,
+ __glXRenderLarge,
+ __glXCreateContext,
+ __glXDestroyContext,
+ __glXMakeCurrent,
+ __glXIsDirect,
+ __glXQueryVersion,
+ __glXWaitGL,
+ __glXWaitX,
+ __glXCopyContext,
+ __glXSwapBuffers,
+ __glXUseXFont,
+ __glXCreateGLXPixmap,
+ __glXGetVisualConfigs,
+ __glXDestroyGLXPixmap,
+ __glXVendorPrivate,
+ __glXVendorPrivateWithReply,
+ __glXQueryExtensionsString,
+ __glXQueryServerString,
+ __glXClientInfo,
+ __glXGetFBConfigs, /* __glXGetFBConfigs */
+ __glXCreatePixmap, /* __glXCreatePixmap,*/
+ __glXDestroyGLXPixmap, /* __glXDestroyPixmap,*/
+ __glXCreateNewContext, /* __glXCreateNewContext,*/
+ __glXQueryContext, /* __glXQueryContext,*/
+ __glXMakeContextCurrent, /* __glXMakeContextCurrent,*/
+ __glXCreatePbuffer, /* __glXCreatePbuffer,*/
+ __glXDestroyPbuffer, /* __glXDestroyPbuffer,*/
+ __glXGetDrawableAttributes, /* __glXGetDrawableAttributes,*/
+ __glXChangeDrawableAttributes, /* __glXChangeDrawableAttributes,*/
+ __glXCreateWindow, /* __glXCreateWindow,*/
+ __glXDestroyWindow, /* __glXDestroyWindow,*/
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXForwardSingleReq, /* __glXDisp_NewList, */
+ __glXForwardSingleReq, /* __glXDisp_EndList, */
+ __glXForwardSingleReq, /* __glXDisp_DeleteLists, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GenLists, */
+ __glXForwardSingleReq, /* __glXDisp_FeedbackBuffer, */
+ __glXForwardSingleReq, /* __glXDisp_SelectBuffer, */
+ __glXForwardAllWithReply, /* __glXDisp_RenderMode, */
+ __glXForwardAllWithReply, /* __glXDisp_Finish, */
+ __glXForwardSingleReq, /* __glXDisp_PixelStoref, */
+ __glXForwardSingleReq, /* __glXDisp_PixelStorei, */
+ __glXDisp_ReadPixels, /* __glXDisp_ReadPixels, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetBooleanv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetClipPlane, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetDoublev, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetError, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetFloatv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetIntegerv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetLightfv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetLightiv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetMapdv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetMapfv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetMapiv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetMaterialfv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetMaterialiv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetPixelMapfv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetPixelMapuiv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetPixelMapusv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetPolygonStipple, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetString, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetTexEnvfv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetTexEnviv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetTexGendv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetTexGenfv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetTexGeniv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetTexImage, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetTexParameterfv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetTexParameteriv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetTexLevelParameterfv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetTexLevelParameteriv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_IsEnabled, */
+ __glXForwardPipe0WithReply, /* __glXDisp_IsList, */
+ __glXForwardSingleReq, /* __glXDisp_Flush, */
+ __glXForwardPipe0WithReply, /* __glXDisp_AreTexturesResident, */
+ __glXForwardSingleReq, /* __glXDisp_DeleteTextures, */
+ __glXForwardAllWithReply, /* __glXDisp_GenTextures, */
+ __glXForwardPipe0WithReply, /* __glXDisp_IsTexture, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetColorTable, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetColorTableParameterfv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetColorTableParameteriv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetConvolutionFilter, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetConvolutionParameterfv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetConvolutionParameteriv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetSeparableFilter, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetHistogram, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetHistogramParameterfv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetHistogramParameteriv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetMinmax, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetMinmaxParameterfv, */
+ __glXForwardPipe0WithReply, /* __glXDisp_GetMinmaxParameteriv, */
+};
+
+__GLXdispatchSingleProcPtr __glXSwapSingleTable[] = {
+ __glXNoSuchSingleOpcode,
+ __glXSwapRender,
+ __glXSwapRenderLarge,
+ __glXSwapCreateContext,
+ __glXSwapDestroyContext,
+ __glXSwapMakeCurrent,
+ __glXSwapIsDirect,
+ __glXSwapQueryVersion,
+ __glXSwapWaitGL,
+ __glXSwapWaitX,
+ __glXSwapCopyContext,
+ __glXSwapSwapBuffers,
+ __glXSwapUseXFont,
+ __glXSwapCreateGLXPixmap,
+ __glXSwapGetVisualConfigs,
+ __glXSwapDestroyGLXPixmap,
+ __glXSwapVendorPrivate,
+ __glXSwapVendorPrivateWithReply,
+ __glXSwapQueryExtensionsString,
+ __glXSwapQueryServerString,
+ __glXSwapClientInfo,
+ __glXSwapGetFBConfigs,
+ __glXSwapCreatePixmap,
+ __glXSwapDestroyGLXPixmap,
+ __glXSwapCreateNewContext,
+ __glXSwapQueryContext,
+ __glXSwapMakeContextCurrent,
+ __glXSwapCreatePbuffer,
+ __glXSwapDestroyPbuffer,
+ __glXSwapGetDrawableAttributes,
+ __glXSwapChangeDrawableAttributes,
+ __glXSwapCreateWindow,
+ __glXSwapDestroyWindow,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXNoSuchSingleOpcode,
+ __glXForwardSingleReqSwap, /* __glXDisp_NewList, */
+ __glXForwardSingleReqSwap, /* __glXDisp_EndList, */
+ __glXForwardSingleReqSwap, /* __glXDisp_DeleteLists, */
+ __glXForwardPipe0WithReplySwap, /* __glXDisp_GenLists, */
+ __glXForwardSingleReqSwap, /* __glXDisp_FeedbackBuffer, */
+ __glXForwardSingleReqSwap, /* __glXDisp_SelectBuffer, */
+ __glXForwardAllWithReplySwapiv, /* __glXDisp_RenderMode, */
+ __glXForwardAllWithReplySwap, /* __glXDisp_Finish, */
+ __glXForwardSingleReqSwap, /* __glXDisp_PixelStoref, */
+ __glXForwardSingleReqSwap, /* __glXDisp_PixelStorei, */
+ __glXDisp_ReadPixels, /* __glXDisp_ReadPixels, */
+ __glXForwardPipe0WithReplySwap, /* __glXDisp_GetBooleanv, */
+ __glXForwardPipe0WithReplySwapdv, /* __glXDisp_GetClipPlane, */
+ __glXForwardPipe0WithReplySwapdv, /* __glXDisp_GetDoublev, */
+ __glXForwardPipe0WithReplySwap, /* __glXDisp_GetError, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetFloatv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetIntegerv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetLightfv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetLightiv, */
+ __glXForwardPipe0WithReplySwapdv, /* __glXDisp_GetMapdv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetMapfv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetMapiv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetMaterialfv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetMaterialiv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetPixelMapfv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetPixelMapuiv, */
+ __glXForwardPipe0WithReplySwapsv, /* __glXDisp_GetPixelMapusv, */
+ __glXForwardPipe0WithReplySwap, /* __glXDisp_GetPolygonStipple, */
+ __glXForwardPipe0WithReplySwap, /* __glXDisp_GetString, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetTexEnvfv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetTexEnviv, */
+ __glXForwardPipe0WithReplySwapdv, /* __glXDisp_GetTexGendv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetTexGenfv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetTexGeniv, */
+ __glXDispSwap_GetTexImage, /* __glXDisp_GetTexImage, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetTexParameterfv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetTexParameteriv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetTexLevelParameterfv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetTexLevelParameteriv, */
+ __glXForwardPipe0WithReplySwap, /* __glXDisp_IsEnabled, */
+ __glXForwardPipe0WithReplySwap, /* __glXDisp_IsList, */
+ __glXForwardSingleReqSwap, /* __glXDisp_Flush, */
+ __glXForwardPipe0WithReplySwap, /* __glXDisp_AreTexturesResident, */
+ __glXForwardSingleReqSwap, /* __glXDisp_DeleteTextures, */
+ __glXForwardAllWithReplySwapiv, /* __glXDisp_GenTextures, */
+ __glXForwardPipe0WithReplySwap, /* __glXDisp_IsTexture, */
+ __glXDispSwap_GetColorTable, /* __glXDisp_GetColorTable, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetColorTableParameterfv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetColorTableParameteriv, */
+ __glXDispSwap_GetColorTable, /* __glXDisp_GetConvolutionFilter, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetConvolutionParameterfv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetConvolutionParameteriv, */
+ __glXDispSwap_GetColorTable, /* __glXDisp_GetSeparableFilter, */
+ __glXDispSwap_GetColorTable, /* __glXDisp_GetHistogram, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetHistogramParameterfv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetHistogramParameteriv, */
+ __glXDispSwap_GetColorTable, /* __glXDisp_GetMinmax, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetMinmaxParameterfv, */
+ __glXForwardPipe0WithReplySwapiv, /* __glXDisp_GetMinmaxParameteriv, */
+};
+
+__GLXdispatchRenderProcPtr __glXSwapRenderTable[] = {
+ __glXNoSuchRenderOpcode,
+ __glXDispSwap_CallList,
+ __glXDispSwap_CallLists,
+ __glXDispSwap_ListBase,
+ __glXDispSwap_Begin,
+ __glXDispSwap_Bitmap,
+ __glXDispSwap_Color3bv,
+ __glXDispSwap_Color3dv,
+ __glXDispSwap_Color3fv,
+ __glXDispSwap_Color3iv,
+ __glXDispSwap_Color3sv,
+ __glXDispSwap_Color3ubv,
+ __glXDispSwap_Color3uiv,
+ __glXDispSwap_Color3usv,
+ __glXDispSwap_Color4bv,
+ __glXDispSwap_Color4dv,
+ __glXDispSwap_Color4fv,
+ __glXDispSwap_Color4iv,
+ __glXDispSwap_Color4sv,
+ __glXDispSwap_Color4ubv,
+ __glXDispSwap_Color4uiv,
+ __glXDispSwap_Color4usv,
+ __glXDispSwap_EdgeFlagv,
+ __glXDispSwap_End,
+ __glXDispSwap_Indexdv,
+ __glXDispSwap_Indexfv,
+ __glXDispSwap_Indexiv,
+ __glXDispSwap_Indexsv,
+ __glXDispSwap_Normal3bv,
+ __glXDispSwap_Normal3dv,
+ __glXDispSwap_Normal3fv,
+ __glXDispSwap_Normal3iv,
+ __glXDispSwap_Normal3sv,
+ __glXDispSwap_RasterPos2dv,
+ __glXDispSwap_RasterPos2fv,
+ __glXDispSwap_RasterPos2iv,
+ __glXDispSwap_RasterPos2sv,
+ __glXDispSwap_RasterPos3dv,
+ __glXDispSwap_RasterPos3fv,
+ __glXDispSwap_RasterPos3iv,
+ __glXDispSwap_RasterPos3sv,
+ __glXDispSwap_RasterPos4dv,
+ __glXDispSwap_RasterPos4fv,
+ __glXDispSwap_RasterPos4iv,
+ __glXDispSwap_RasterPos4sv,
+ __glXDispSwap_Rectdv,
+ __glXDispSwap_Rectfv,
+ __glXDispSwap_Rectiv,
+ __glXDispSwap_Rectsv,
+ __glXDispSwap_TexCoord1dv,
+ __glXDispSwap_TexCoord1fv,
+ __glXDispSwap_TexCoord1iv,
+ __glXDispSwap_TexCoord1sv,
+ __glXDispSwap_TexCoord2dv,
+ __glXDispSwap_TexCoord2fv,
+ __glXDispSwap_TexCoord2iv,
+ __glXDispSwap_TexCoord2sv,
+ __glXDispSwap_TexCoord3dv,
+ __glXDispSwap_TexCoord3fv,
+ __glXDispSwap_TexCoord3iv,
+ __glXDispSwap_TexCoord3sv,
+ __glXDispSwap_TexCoord4dv,
+ __glXDispSwap_TexCoord4fv,
+ __glXDispSwap_TexCoord4iv,
+ __glXDispSwap_TexCoord4sv,
+ __glXDispSwap_Vertex2dv,
+ __glXDispSwap_Vertex2fv,
+ __glXDispSwap_Vertex2iv,
+ __glXDispSwap_Vertex2sv,
+ __glXDispSwap_Vertex3dv,
+ __glXDispSwap_Vertex3fv,
+ __glXDispSwap_Vertex3iv,
+ __glXDispSwap_Vertex3sv,
+ __glXDispSwap_Vertex4dv,
+ __glXDispSwap_Vertex4fv,
+ __glXDispSwap_Vertex4iv,
+ __glXDispSwap_Vertex4sv,
+ __glXDispSwap_ClipPlane,
+ __glXDispSwap_ColorMaterial,
+ __glXDispSwap_CullFace,
+ __glXDispSwap_Fogf,
+ __glXDispSwap_Fogfv,
+ __glXDispSwap_Fogi,
+ __glXDispSwap_Fogiv,
+ __glXDispSwap_FrontFace,
+ __glXDispSwap_Hint,
+ __glXDispSwap_Lightf,
+ __glXDispSwap_Lightfv,
+ __glXDispSwap_Lighti,
+ __glXDispSwap_Lightiv,
+ __glXDispSwap_LightModelf,
+ __glXDispSwap_LightModelfv,
+ __glXDispSwap_LightModeli,
+ __glXDispSwap_LightModeliv,
+ __glXDispSwap_LineStipple,
+ __glXDispSwap_LineWidth,
+ __glXDispSwap_Materialf,
+ __glXDispSwap_Materialfv,
+ __glXDispSwap_Materiali,
+ __glXDispSwap_Materialiv,
+ __glXDispSwap_PointSize,
+ __glXDispSwap_PolygonMode,
+ __glXDispSwap_PolygonStipple,
+ __glXDispSwap_Scissor,
+ __glXDispSwap_ShadeModel,
+ __glXDispSwap_TexParameterf,
+ __glXDispSwap_TexParameterfv,
+ __glXDispSwap_TexParameteri,
+ __glXDispSwap_TexParameteriv,
+ __glXDispSwap_TexImage1D,
+ __glXDispSwap_TexImage2D,
+ __glXDispSwap_TexEnvf,
+ __glXDispSwap_TexEnvfv,
+ __glXDispSwap_TexEnvi,
+ __glXDispSwap_TexEnviv,
+ __glXDispSwap_TexGend,
+ __glXDispSwap_TexGendv,
+ __glXDispSwap_TexGenf,
+ __glXDispSwap_TexGenfv,
+ __glXDispSwap_TexGeni,
+ __glXDispSwap_TexGeniv,
+ __glXDispSwap_InitNames,
+ __glXDispSwap_LoadName,
+ __glXDispSwap_PassThrough,
+ __glXDispSwap_PopName,
+ __glXDispSwap_PushName,
+ __glXDispSwap_DrawBuffer,
+ __glXDispSwap_Clear,
+ __glXDispSwap_ClearAccum,
+ __glXDispSwap_ClearIndex,
+ __glXDispSwap_ClearColor,
+ __glXDispSwap_ClearStencil,
+ __glXDispSwap_ClearDepth,
+ __glXDispSwap_StencilMask,
+ __glXDispSwap_ColorMask,
+ __glXDispSwap_DepthMask,
+ __glXDispSwap_IndexMask,
+ __glXDispSwap_Accum,
+ __glXDispSwap_Disable,
+ __glXDispSwap_Enable,
+ __glXNoSuchRenderOpcode,
+ __glXDispSwap_PopAttrib,
+ __glXDispSwap_PushAttrib,
+ __glXDispSwap_Map1d,
+ __glXDispSwap_Map1f,
+ __glXDispSwap_Map2d,
+ __glXDispSwap_Map2f,
+ __glXDispSwap_MapGrid1d,
+ __glXDispSwap_MapGrid1f,
+ __glXDispSwap_MapGrid2d,
+ __glXDispSwap_MapGrid2f,
+ __glXDispSwap_EvalCoord1dv,
+ __glXDispSwap_EvalCoord1fv,
+ __glXDispSwap_EvalCoord2dv,
+ __glXDispSwap_EvalCoord2fv,
+ __glXDispSwap_EvalMesh1,
+ __glXDispSwap_EvalPoint1,
+ __glXDispSwap_EvalMesh2,
+ __glXDispSwap_EvalPoint2,
+ __glXDispSwap_AlphaFunc,
+ __glXDispSwap_BlendFunc,
+ __glXDispSwap_LogicOp,
+ __glXDispSwap_StencilFunc,
+ __glXDispSwap_StencilOp,
+ __glXDispSwap_DepthFunc,
+ __glXDispSwap_PixelZoom,
+ __glXDispSwap_PixelTransferf,
+ __glXDispSwap_PixelTransferi,
+ __glXDispSwap_PixelMapfv,
+ __glXDispSwap_PixelMapuiv,
+ __glXDispSwap_PixelMapusv,
+ __glXDispSwap_ReadBuffer,
+ __glXDispSwap_CopyPixels,
+ __glXDispSwap_DrawPixels,
+ __glXDispSwap_DepthRange,
+ __glXDispSwap_Frustum,
+ __glXDispSwap_LoadIdentity,
+ __glXDispSwap_LoadMatrixf,
+ __glXDispSwap_LoadMatrixd,
+ __glXDispSwap_MatrixMode,
+ __glXDispSwap_MultMatrixf,
+ __glXDispSwap_MultMatrixd,
+ __glXDispSwap_Ortho,
+ __glXDispSwap_PopMatrix,
+ __glXDispSwap_PushMatrix,
+ __glXDispSwap_Rotated,
+ __glXDispSwap_Rotatef,
+ __glXDispSwap_Scaled,
+ __glXDispSwap_Scalef,
+ __glXDispSwap_Translated,
+ __glXDispSwap_Translatef,
+ __glXDispSwap_Viewport,
+ __glXDispSwap_PolygonOffset,
+ __glXDispSwap_DrawArrays,
+ __glXDispSwap_Indexubv,
+ __glXDispSwap_ColorSubTable,
+ __glXDispSwap_CopyColorSubTable,
+ __glXDispSwap_ActiveTextureARB,
+ __glXDispSwap_MultiTexCoord1dvARB,
+ __glXDispSwap_MultiTexCoord1fvARB,
+ __glXDispSwap_MultiTexCoord1ivARB,
+ __glXDispSwap_MultiTexCoord1svARB,
+ __glXDispSwap_MultiTexCoord2dvARB,
+ __glXDispSwap_MultiTexCoord2fvARB,
+ __glXDispSwap_MultiTexCoord2ivARB,
+ __glXDispSwap_MultiTexCoord2svARB,
+ __glXDispSwap_MultiTexCoord3dvARB,
+ __glXDispSwap_MultiTexCoord3fvARB,
+ __glXDispSwap_MultiTexCoord3ivARB,
+ __glXDispSwap_MultiTexCoord3svARB,
+ __glXDispSwap_MultiTexCoord4dvARB,
+ __glXDispSwap_MultiTexCoord4fvARB,
+ __glXDispSwap_MultiTexCoord4ivARB,
+ __glXDispSwap_MultiTexCoord4svARB,
+};
+
+__GLXRenderSwapInfo __glXSwapRenderTable_EXT[] =
+{
+ {4, 4, NULL}, /* X_GLrop_BlendColorEXT */
+ {4, 1, NULL}, /* X_GLrop_BlendEquationEXT */
+ {4, 2, NULL}, /* X_GLrop_PolygonOffsetEXT */
+ {4, 0, __glXDispSwap_TexSubImage1D}, /* X_GLrop_TexSubImage1DEXT */
+ {4, 0, __glXDispSwap_TexSubImage2D}, /* X_GLrop_TexSubImage2DEXT */
+ {4, 0, __glXDispSwap_ConvolutionFilter1D}, /* X_GLrop_ConvolutionFilter1DEXT */
+ {4, 0, __glXDispSwap_ConvolutionFilter2D}, /* X_GLrop_ConvolutionFilter2DEXT */
+ {4, 3, NULL}, /* X_GLrop_ConvolutionParameterfEXT */
+ {4, 0, __glXDispSwap_ConvolutionParameterfv}, /* X_GLrop_ConvolutionParameterfvEXT */
+ {4, 3, NULL}, /* X_GLrop_ConvolutionParameteriEXT */
+ {4, 0, __glXDispSwap_ConvolutionParameteriv}, /* X_GLrop_ConvolutionParameterivEXT */
+ {4, 0, __glXDispSwap_CopyConvolutionFilter1D}, /* X_GLrop_CopyConvolutionFilter1DEXT */
+ {4, 0, __glXDispSwap_CopyConvolutionFilter2D}, /* X_GLrop_CopyConvolutionFilter2DEXT */
+ {4, 0, __glXDispSwap_SeparableFilter2D}, /* X_GLrop_SeparableFilter2DEXT */
+ {4, 3, NULL}, /* X_GLrop_HistogramEXT */
+ {4, 2, NULL}, /* X_GLrop_MinmaxEXT */
+ {4, 1, NULL}, /* X_GLrop_ResetHistogramEXT */
+ {4, 1, NULL}, /* X_GLrop_ResetMinmaxEXT */
+ {4, 0, __glXDispSwap_TexImage3D}, /* X_GLrop_TexImage3DEXT */
+ {4, 0, __glXDispSwap_TexSubImage3D}, /* X_GLrop_TexSubImage3DEXT */
+ {4, 0, __glXDispSwap_DrawArrays}, /* X_GLrop_DrawArraysEXT */
+ {4, 2, NULL}, /* X_GLrop_BindTextureEXT */
+ {4, 0, __glXDispSwap_PrioritizeTextures}, /* X_GLrop_PrioritizeTexturesEXT */
+ {4, 0, __glXDispSwap_CopyTexImage1D}, /* X_GLrop_CopyTexImage1DEXT */
+ {4, 0, __glXDispSwap_CopyTexImage2D}, /* X_GLrop_CopyTexImage2DEXT */
+ {4, 0, __glXDispSwap_CopyTexSubImage1D}, /* X_GLrop_CopyTexSubImage1DEXT */
+ {4, 0, __glXDispSwap_CopyTexSubImage2D}, /* X_GLrop_CopyTexSubImage2DEXT */
+ {4, 0, __glXDispSwap_CopyTexSubImage3D}, /* X_GLrop_CopyTexSubImage3DEXT */
+
+};
+
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/g_disptab.h b/nx-X11/programs/Xserver/hw/dmx/glxProxy/g_disptab.h
new file mode 100644
index 000000000..0b6d47be7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/g_disptab.h
@@ -0,0 +1,676 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/g_disptab.h,v 1.3 2001/03/21 16:29:35 dawes Exp $ */
+/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED */
+#ifndef _GLX_g_disptab_h_
+#define _GLX_g_disptab_h_
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+extern int __glXRender(__GLXclientState*, GLbyte*);
+extern int __glXRenderLarge(__GLXclientState*, GLbyte*);
+extern int __glXSendLargeCommand(__GLXclientState *cl, GLXContextTag contextTag);
+extern int __glXCreateContext(__GLXclientState*, GLbyte*);
+extern int __glXCreateNewContext(__GLXclientState *cl, GLbyte *pc);
+extern int __glXDestroyContext(__GLXclientState*, GLbyte*);
+extern int __glXMakeCurrent(__GLXclientState*, GLbyte*);
+extern int __glXMakeContextCurrent(__GLXclientState*, GLbyte*);
+extern int __glXCreatePbuffer(__GLXclientState *cl, GLbyte *pc);
+extern int __glXDestroyPbuffer(__GLXclientState *cl, GLbyte *pc);
+extern int __glXGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc);
+extern int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc);
+extern int __glXIsDirect(__GLXclientState*, GLbyte*);
+extern int __glXQueryVersion(__GLXclientState*, GLbyte*);
+extern int __glXWaitGL(__GLXclientState*, GLbyte*);
+extern int __glXWaitX(__GLXclientState*, GLbyte*);
+extern int __glXCopyContext(__GLXclientState*, GLbyte*);
+extern int __glXSwapBuffers(__GLXclientState*, GLbyte*);
+extern int __glXUseXFont(__GLXclientState*, GLbyte*);
+extern int __glXCreateGLXPixmap(__GLXclientState*, GLbyte*);
+extern int __glXCreatePixmap(__GLXclientState *cl, GLbyte *pc);
+extern int __glXGetVisualConfigs(__GLXclientState*, GLbyte*);
+extern int __glXDestroyGLXPixmap(__GLXclientState*, GLbyte*);
+extern int __glXVendorPrivate(__GLXclientState*, GLbyte*);
+extern int __glXVendorPrivateWithReply(__GLXclientState*, GLbyte*);
+extern int __glXQueryExtensionsString(__GLXclientState*, GLbyte*);
+extern int __glXQueryServerString(__GLXclientState*, GLbyte*);
+extern int __glXClientInfo(__GLXclientState*, GLbyte*);
+extern int __glXGetFBConfigs(__GLXclientState*, GLbyte*);
+extern int __glXCreateWindow(__GLXclientState *cl, GLbyte *pc);
+extern int __glXDestroyWindow(__GLXclientState *cl, GLbyte *pc);
+extern int __glXQueryContext(__GLXclientState *cl, GLbyte *pc);
+extern int __glXDisp_NewList(__GLXclientState*, GLbyte*);
+extern int __glXDisp_EndList(__GLXclientState*, GLbyte*);
+extern int __glXDisp_DeleteLists(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GenLists(__GLXclientState*, GLbyte*);
+extern int __glXDisp_FeedbackBuffer(__GLXclientState*, GLbyte*);
+extern int __glXDisp_SelectBuffer(__GLXclientState*, GLbyte*);
+extern int __glXDisp_RenderMode(__GLXclientState*, GLbyte*);
+extern int __glXDisp_Finish(__GLXclientState*, GLbyte*);
+extern int __glXDisp_PixelStoref(__GLXclientState*, GLbyte*);
+extern int __glXDisp_PixelStorei(__GLXclientState*, GLbyte*);
+extern int __glXDisp_ReadPixels(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetBooleanv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetClipPlane(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetDoublev(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetError(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetFloatv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetIntegerv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetLightfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetLightiv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetMapdv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetMapfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetMapiv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetMaterialfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetMaterialiv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetPixelMapfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetPixelMapuiv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetPixelMapusv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetPolygonStipple(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetString(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexEnvfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexEnviv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexGendv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexGenfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexGeniv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexImage(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexLevelParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetTexLevelParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_IsEnabled(__GLXclientState*, GLbyte*);
+extern int __glXDisp_IsList(__GLXclientState*, GLbyte*);
+extern int __glXDisp_Flush(__GLXclientState*, GLbyte*);
+extern int __glXDisp_AreTexturesResident(__GLXclientState*, GLbyte*);
+extern int __glXDisp_DeleteTextures(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GenTextures(__GLXclientState*, GLbyte*);
+extern int __glXDisp_IsTexture(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetColorTable(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetColorTableParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetColorTableParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetConvolutionFilter(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetConvolutionParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetConvolutionParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetSeparableFilter(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetHistogram(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetHistogramParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetHistogramParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetMinmax(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetMinmaxParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDisp_GetMinmaxParameteriv(__GLXclientState*, GLbyte*);
+
+extern void __glXDisp_CallList(GLbyte*);
+extern void __glXDisp_CallLists(GLbyte*);
+extern void __glXDisp_ListBase(GLbyte*);
+extern void __glXDisp_Begin(GLbyte*);
+extern void __glXDisp_Bitmap(GLbyte*);
+extern void __glXDisp_Color3bv(GLbyte*);
+extern void __glXDisp_Color3dv(GLbyte*);
+extern void __glXDisp_Color3fv(GLbyte*);
+extern void __glXDisp_Color3iv(GLbyte*);
+extern void __glXDisp_Color3sv(GLbyte*);
+extern void __glXDisp_Color3ubv(GLbyte*);
+extern void __glXDisp_Color3uiv(GLbyte*);
+extern void __glXDisp_Color3usv(GLbyte*);
+extern void __glXDisp_Color4bv(GLbyte*);
+extern void __glXDisp_Color4dv(GLbyte*);
+extern void __glXDisp_Color4fv(GLbyte*);
+extern void __glXDisp_Color4iv(GLbyte*);
+extern void __glXDisp_Color4sv(GLbyte*);
+extern void __glXDisp_Color4ubv(GLbyte*);
+extern void __glXDisp_Color4uiv(GLbyte*);
+extern void __glXDisp_Color4usv(GLbyte*);
+extern void __glXDisp_EdgeFlagv(GLbyte*);
+extern void __glXDisp_End(GLbyte*);
+extern void __glXDisp_Indexdv(GLbyte*);
+extern void __glXDisp_Indexfv(GLbyte*);
+extern void __glXDisp_Indexiv(GLbyte*);
+extern void __glXDisp_Indexsv(GLbyte*);
+extern void __glXDisp_Normal3bv(GLbyte*);
+extern void __glXDisp_Normal3dv(GLbyte*);
+extern void __glXDisp_Normal3fv(GLbyte*);
+extern void __glXDisp_Normal3iv(GLbyte*);
+extern void __glXDisp_Normal3sv(GLbyte*);
+extern void __glXDisp_RasterPos2dv(GLbyte*);
+extern void __glXDisp_RasterPos2fv(GLbyte*);
+extern void __glXDisp_RasterPos2iv(GLbyte*);
+extern void __glXDisp_RasterPos2sv(GLbyte*);
+extern void __glXDisp_RasterPos3dv(GLbyte*);
+extern void __glXDisp_RasterPos3fv(GLbyte*);
+extern void __glXDisp_RasterPos3iv(GLbyte*);
+extern void __glXDisp_RasterPos3sv(GLbyte*);
+extern void __glXDisp_RasterPos4dv(GLbyte*);
+extern void __glXDisp_RasterPos4fv(GLbyte*);
+extern void __glXDisp_RasterPos4iv(GLbyte*);
+extern void __glXDisp_RasterPos4sv(GLbyte*);
+extern void __glXDisp_Rectdv(GLbyte*);
+extern void __glXDisp_Rectfv(GLbyte*);
+extern void __glXDisp_Rectiv(GLbyte*);
+extern void __glXDisp_Rectsv(GLbyte*);
+extern void __glXDisp_TexCoord1dv(GLbyte*);
+extern void __glXDisp_TexCoord1fv(GLbyte*);
+extern void __glXDisp_TexCoord1iv(GLbyte*);
+extern void __glXDisp_TexCoord1sv(GLbyte*);
+extern void __glXDisp_TexCoord2dv(GLbyte*);
+extern void __glXDisp_TexCoord2fv(GLbyte*);
+extern void __glXDisp_TexCoord2iv(GLbyte*);
+extern void __glXDisp_TexCoord2sv(GLbyte*);
+extern void __glXDisp_TexCoord3dv(GLbyte*);
+extern void __glXDisp_TexCoord3fv(GLbyte*);
+extern void __glXDisp_TexCoord3iv(GLbyte*);
+extern void __glXDisp_TexCoord3sv(GLbyte*);
+extern void __glXDisp_TexCoord4dv(GLbyte*);
+extern void __glXDisp_TexCoord4fv(GLbyte*);
+extern void __glXDisp_TexCoord4iv(GLbyte*);
+extern void __glXDisp_TexCoord4sv(GLbyte*);
+extern void __glXDisp_Vertex2dv(GLbyte*);
+extern void __glXDisp_Vertex2fv(GLbyte*);
+extern void __glXDisp_Vertex2iv(GLbyte*);
+extern void __glXDisp_Vertex2sv(GLbyte*);
+extern void __glXDisp_Vertex3dv(GLbyte*);
+extern void __glXDisp_Vertex3fv(GLbyte*);
+extern void __glXDisp_Vertex3iv(GLbyte*);
+extern void __glXDisp_Vertex3sv(GLbyte*);
+extern void __glXDisp_Vertex4dv(GLbyte*);
+extern void __glXDisp_Vertex4fv(GLbyte*);
+extern void __glXDisp_Vertex4iv(GLbyte*);
+extern void __glXDisp_Vertex4sv(GLbyte*);
+extern void __glXDisp_ClipPlane(GLbyte*);
+extern void __glXDisp_ColorMaterial(GLbyte*);
+extern void __glXDisp_CullFace(GLbyte*);
+extern void __glXDisp_Fogf(GLbyte*);
+extern void __glXDisp_Fogfv(GLbyte*);
+extern void __glXDisp_Fogi(GLbyte*);
+extern void __glXDisp_Fogiv(GLbyte*);
+extern void __glXDisp_FrontFace(GLbyte*);
+extern void __glXDisp_Hint(GLbyte*);
+extern void __glXDisp_Lightf(GLbyte*);
+extern void __glXDisp_Lightfv(GLbyte*);
+extern void __glXDisp_Lighti(GLbyte*);
+extern void __glXDisp_Lightiv(GLbyte*);
+extern void __glXDisp_LightModelf(GLbyte*);
+extern void __glXDisp_LightModelfv(GLbyte*);
+extern void __glXDisp_LightModeli(GLbyte*);
+extern void __glXDisp_LightModeliv(GLbyte*);
+extern void __glXDisp_LineStipple(GLbyte*);
+extern void __glXDisp_LineWidth(GLbyte*);
+extern void __glXDisp_Materialf(GLbyte*);
+extern void __glXDisp_Materialfv(GLbyte*);
+extern void __glXDisp_Materiali(GLbyte*);
+extern void __glXDisp_Materialiv(GLbyte*);
+extern void __glXDisp_PointSize(GLbyte*);
+extern void __glXDisp_PolygonMode(GLbyte*);
+extern void __glXDisp_PolygonStipple(GLbyte*);
+extern void __glXDisp_Scissor(GLbyte*);
+extern void __glXDisp_ShadeModel(GLbyte*);
+extern void __glXDisp_TexParameterf(GLbyte*);
+extern void __glXDisp_TexParameterfv(GLbyte*);
+extern void __glXDisp_TexParameteri(GLbyte*);
+extern void __glXDisp_TexParameteriv(GLbyte*);
+extern void __glXDisp_TexImage1D(GLbyte*);
+extern void __glXDisp_TexImage2D(GLbyte*);
+extern void __glXDisp_TexEnvf(GLbyte*);
+extern void __glXDisp_TexEnvfv(GLbyte*);
+extern void __glXDisp_TexEnvi(GLbyte*);
+extern void __glXDisp_TexEnviv(GLbyte*);
+extern void __glXDisp_TexGend(GLbyte*);
+extern void __glXDisp_TexGendv(GLbyte*);
+extern void __glXDisp_TexGenf(GLbyte*);
+extern void __glXDisp_TexGenfv(GLbyte*);
+extern void __glXDisp_TexGeni(GLbyte*);
+extern void __glXDisp_TexGeniv(GLbyte*);
+extern void __glXDisp_InitNames(GLbyte*);
+extern void __glXDisp_LoadName(GLbyte*);
+extern void __glXDisp_PassThrough(GLbyte*);
+extern void __glXDisp_PopName(GLbyte*);
+extern void __glXDisp_PushName(GLbyte*);
+extern void __glXDisp_DrawBuffer(GLbyte*);
+extern void __glXDisp_Clear(GLbyte*);
+extern void __glXDisp_ClearAccum(GLbyte*);
+extern void __glXDisp_ClearIndex(GLbyte*);
+extern void __glXDisp_ClearColor(GLbyte*);
+extern void __glXDisp_ClearStencil(GLbyte*);
+extern void __glXDisp_ClearDepth(GLbyte*);
+extern void __glXDisp_StencilMask(GLbyte*);
+extern void __glXDisp_ColorMask(GLbyte*);
+extern void __glXDisp_DepthMask(GLbyte*);
+extern void __glXDisp_IndexMask(GLbyte*);
+extern void __glXDisp_Accum(GLbyte*);
+extern void __glXDisp_Disable(GLbyte*);
+extern void __glXDisp_Enable(GLbyte*);
+extern void __glXDisp_PopAttrib(GLbyte*);
+extern void __glXDisp_PushAttrib(GLbyte*);
+extern void __glXDisp_Map1d(GLbyte*);
+extern void __glXDisp_Map1f(GLbyte*);
+extern void __glXDisp_Map2d(GLbyte*);
+extern void __glXDisp_Map2f(GLbyte*);
+extern void __glXDisp_MapGrid1d(GLbyte*);
+extern void __glXDisp_MapGrid1f(GLbyte*);
+extern void __glXDisp_MapGrid2d(GLbyte*);
+extern void __glXDisp_MapGrid2f(GLbyte*);
+extern void __glXDisp_EvalCoord1dv(GLbyte*);
+extern void __glXDisp_EvalCoord1fv(GLbyte*);
+extern void __glXDisp_EvalCoord2dv(GLbyte*);
+extern void __glXDisp_EvalCoord2fv(GLbyte*);
+extern void __glXDisp_EvalMesh1(GLbyte*);
+extern void __glXDisp_EvalPoint1(GLbyte*);
+extern void __glXDisp_EvalMesh2(GLbyte*);
+extern void __glXDisp_EvalPoint2(GLbyte*);
+extern void __glXDisp_AlphaFunc(GLbyte*);
+extern void __glXDisp_BlendFunc(GLbyte*);
+extern void __glXDisp_LogicOp(GLbyte*);
+extern void __glXDisp_StencilFunc(GLbyte*);
+extern void __glXDisp_StencilOp(GLbyte*);
+extern void __glXDisp_DepthFunc(GLbyte*);
+extern void __glXDisp_PixelZoom(GLbyte*);
+extern void __glXDisp_PixelTransferf(GLbyte*);
+extern void __glXDisp_PixelTransferi(GLbyte*);
+extern void __glXDisp_PixelMapfv(GLbyte*);
+extern void __glXDisp_PixelMapuiv(GLbyte*);
+extern void __glXDisp_PixelMapusv(GLbyte*);
+extern void __glXDisp_ReadBuffer(GLbyte*);
+extern void __glXDisp_CopyPixels(GLbyte*);
+extern void __glXDisp_DrawPixels(GLbyte*);
+extern void __glXDisp_DepthRange(GLbyte*);
+extern void __glXDisp_Frustum(GLbyte*);
+extern void __glXDisp_LoadIdentity(GLbyte*);
+extern void __glXDisp_LoadMatrixf(GLbyte*);
+extern void __glXDisp_LoadMatrixd(GLbyte*);
+extern void __glXDisp_MatrixMode(GLbyte*);
+extern void __glXDisp_MultMatrixf(GLbyte*);
+extern void __glXDisp_MultMatrixd(GLbyte*);
+extern void __glXDisp_Ortho(GLbyte*);
+extern void __glXDisp_PopMatrix(GLbyte*);
+extern void __glXDisp_PushMatrix(GLbyte*);
+extern void __glXDisp_Rotated(GLbyte*);
+extern void __glXDisp_Rotatef(GLbyte*);
+extern void __glXDisp_Scaled(GLbyte*);
+extern void __glXDisp_Scalef(GLbyte*);
+extern void __glXDisp_Translated(GLbyte*);
+extern void __glXDisp_Translatef(GLbyte*);
+extern void __glXDisp_Viewport(GLbyte*);
+extern void __glXDisp_PolygonOffset(GLbyte*);
+extern void __glXDisp_DrawArrays(GLbyte*);
+extern void __glXDisp_Indexubv(GLbyte*);
+extern void __glXDisp_ColorSubTable(GLbyte*);
+extern void __glXDisp_CopyColorSubTable(GLbyte*);
+extern void __glXDisp_ActiveTextureARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord1dvARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord1fvARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord1ivARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord1svARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord2dvARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord2fvARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord2ivARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord2svARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord3dvARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord3fvARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord3ivARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord3svARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord4dvARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord4fvARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord4ivARB(GLbyte*);
+extern void __glXDisp_MultiTexCoord4svARB(GLbyte*);
+
+extern int __glXSwapRender(__GLXclientState*, GLbyte*);
+extern int __glXSwapRenderLarge(__GLXclientState*, GLbyte*);
+extern int __glXSwapCreateContext(__GLXclientState*, GLbyte*);
+extern int __glXSwapCreateNewContext(__GLXclientState *cl, GLbyte *pc);
+extern int __glXSwapDestroyContext(__GLXclientState*, GLbyte*);
+extern int __glXSwapMakeCurrent(__GLXclientState*, GLbyte*);
+extern int __glXSwapMakeContextCurrent(__GLXclientState*, GLbyte*);
+extern int __glXSwapCreatePbuffer(__GLXclientState *cl, GLbyte *pc);
+extern int __glXSwapDestroyPbuffer(__GLXclientState *cl, GLbyte *pc);
+extern int __glXSwapGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc);
+extern int __glXSwapChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc);
+extern int __glXSwapIsDirect(__GLXclientState*, GLbyte*);
+extern int __glXSwapQueryVersion(__GLXclientState*, GLbyte*);
+extern int __glXSwapWaitGL(__GLXclientState*, GLbyte*);
+extern int __glXSwapWaitX(__GLXclientState*, GLbyte*);
+extern int __glXSwapCopyContext(__GLXclientState*, GLbyte*);
+extern int __glXSwapSwapBuffers(__GLXclientState*, GLbyte*);
+extern int __glXSwapUseXFont(__GLXclientState*, GLbyte*);
+extern int __glXSwapCreateGLXPixmap(__GLXclientState*, GLbyte*);
+extern int __glXSwapCreatePixmap(__GLXclientState *cl, GLbyte *pc);
+extern int __glXSwapGetVisualConfigs(__GLXclientState*, GLbyte*);
+extern int __glXSwapDestroyGLXPixmap(__GLXclientState*, GLbyte*);
+extern int __glXSwapVendorPrivate(__GLXclientState*, GLbyte*);
+extern int __glXSwapVendorPrivateWithReply(__GLXclientState*, GLbyte*);
+extern int __glXSwapQueryExtensionsString(__GLXclientState*, GLbyte*);
+extern int __glXSwapQueryServerString(__GLXclientState*, GLbyte*);
+extern int __glXSwapClientInfo(__GLXclientState*, GLbyte*);
+extern int __glXSwapGetFBConfigs(__GLXclientState*, GLbyte*);
+extern int __glXSwapCreateWindow(__GLXclientState *cl, GLbyte *pc);
+extern int __glXSwapDestroyWindow(__GLXclientState *cl, GLbyte *pc);
+extern int __glXSwapQueryContext(__GLXclientState *cl, GLbyte *pc);
+extern int __glXDispSwap_NewList(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_EndList(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_DeleteLists(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GenLists(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_FeedbackBuffer(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_SelectBuffer(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_RenderMode(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_Finish(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_PixelStoref(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_PixelStorei(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_ReadPixels(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetBooleanv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetClipPlane(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetDoublev(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetError(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetFloatv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetIntegerv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetLightfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetLightiv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetMapdv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetMapfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetMapiv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetMaterialfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetMaterialiv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetPixelMapfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetPixelMapuiv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetPixelMapusv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetPolygonStipple(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetString(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexEnvfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexEnviv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexGendv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexGenfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexGeniv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexImage(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexLevelParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetTexLevelParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_IsEnabled(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_IsList(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_Flush(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_AreTexturesResident(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_DeleteTextures(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GenTextures(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_IsTexture(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetColorTable(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetColorTableParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetColorTableParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetConvolutionFilter(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetConvolutionParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetConvolutionParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetSeparableFilter(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetHistogram(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetHistogramParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetHistogramParameteriv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetMinmax(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetMinmaxParameterfv(__GLXclientState*, GLbyte*);
+extern int __glXDispSwap_GetMinmaxParameteriv(__GLXclientState*, GLbyte*);
+
+extern void __glXDispSwap_CallList(GLbyte*);
+extern void __glXDispSwap_CallLists(GLbyte*);
+extern void __glXDispSwap_ListBase(GLbyte*);
+extern void __glXDispSwap_Begin(GLbyte*);
+extern void __glXDispSwap_Bitmap(GLbyte*);
+extern void __glXDispSwap_Color3bv(GLbyte*);
+extern void __glXDispSwap_Color3dv(GLbyte*);
+extern void __glXDispSwap_Color3fv(GLbyte*);
+extern void __glXDispSwap_Color3iv(GLbyte*);
+extern void __glXDispSwap_Color3sv(GLbyte*);
+extern void __glXDispSwap_Color3ubv(GLbyte*);
+extern void __glXDispSwap_Color3uiv(GLbyte*);
+extern void __glXDispSwap_Color3usv(GLbyte*);
+extern void __glXDispSwap_Color4bv(GLbyte*);
+extern void __glXDispSwap_Color4dv(GLbyte*);
+extern void __glXDispSwap_Color4fv(GLbyte*);
+extern void __glXDispSwap_Color4iv(GLbyte*);
+extern void __glXDispSwap_Color4sv(GLbyte*);
+extern void __glXDispSwap_Color4ubv(GLbyte*);
+extern void __glXDispSwap_Color4uiv(GLbyte*);
+extern void __glXDispSwap_Color4usv(GLbyte*);
+extern void __glXDispSwap_EdgeFlagv(GLbyte*);
+extern void __glXDispSwap_End(GLbyte*);
+extern void __glXDispSwap_Indexdv(GLbyte*);
+extern void __glXDispSwap_Indexfv(GLbyte*);
+extern void __glXDispSwap_Indexiv(GLbyte*);
+extern void __glXDispSwap_Indexsv(GLbyte*);
+extern void __glXDispSwap_Normal3bv(GLbyte*);
+extern void __glXDispSwap_Normal3dv(GLbyte*);
+extern void __glXDispSwap_Normal3fv(GLbyte*);
+extern void __glXDispSwap_Normal3iv(GLbyte*);
+extern void __glXDispSwap_Normal3sv(GLbyte*);
+extern void __glXDispSwap_RasterPos2dv(GLbyte*);
+extern void __glXDispSwap_RasterPos2fv(GLbyte*);
+extern void __glXDispSwap_RasterPos2iv(GLbyte*);
+extern void __glXDispSwap_RasterPos2sv(GLbyte*);
+extern void __glXDispSwap_RasterPos3dv(GLbyte*);
+extern void __glXDispSwap_RasterPos3fv(GLbyte*);
+extern void __glXDispSwap_RasterPos3iv(GLbyte*);
+extern void __glXDispSwap_RasterPos3sv(GLbyte*);
+extern void __glXDispSwap_RasterPos4dv(GLbyte*);
+extern void __glXDispSwap_RasterPos4fv(GLbyte*);
+extern void __glXDispSwap_RasterPos4iv(GLbyte*);
+extern void __glXDispSwap_RasterPos4sv(GLbyte*);
+extern void __glXDispSwap_Rectdv(GLbyte*);
+extern void __glXDispSwap_Rectfv(GLbyte*);
+extern void __glXDispSwap_Rectiv(GLbyte*);
+extern void __glXDispSwap_Rectsv(GLbyte*);
+extern void __glXDispSwap_TexCoord1dv(GLbyte*);
+extern void __glXDispSwap_TexCoord1fv(GLbyte*);
+extern void __glXDispSwap_TexCoord1iv(GLbyte*);
+extern void __glXDispSwap_TexCoord1sv(GLbyte*);
+extern void __glXDispSwap_TexCoord2dv(GLbyte*);
+extern void __glXDispSwap_TexCoord2fv(GLbyte*);
+extern void __glXDispSwap_TexCoord2iv(GLbyte*);
+extern void __glXDispSwap_TexCoord2sv(GLbyte*);
+extern void __glXDispSwap_TexCoord3dv(GLbyte*);
+extern void __glXDispSwap_TexCoord3fv(GLbyte*);
+extern void __glXDispSwap_TexCoord3iv(GLbyte*);
+extern void __glXDispSwap_TexCoord3sv(GLbyte*);
+extern void __glXDispSwap_TexCoord4dv(GLbyte*);
+extern void __glXDispSwap_TexCoord4fv(GLbyte*);
+extern void __glXDispSwap_TexCoord4iv(GLbyte*);
+extern void __glXDispSwap_TexCoord4sv(GLbyte*);
+extern void __glXDispSwap_Vertex2dv(GLbyte*);
+extern void __glXDispSwap_Vertex2fv(GLbyte*);
+extern void __glXDispSwap_Vertex2iv(GLbyte*);
+extern void __glXDispSwap_Vertex2sv(GLbyte*);
+extern void __glXDispSwap_Vertex3dv(GLbyte*);
+extern void __glXDispSwap_Vertex3fv(GLbyte*);
+extern void __glXDispSwap_Vertex3iv(GLbyte*);
+extern void __glXDispSwap_Vertex3sv(GLbyte*);
+extern void __glXDispSwap_Vertex4dv(GLbyte*);
+extern void __glXDispSwap_Vertex4fv(GLbyte*);
+extern void __glXDispSwap_Vertex4iv(GLbyte*);
+extern void __glXDispSwap_Vertex4sv(GLbyte*);
+extern void __glXDispSwap_ClipPlane(GLbyte*);
+extern void __glXDispSwap_ColorMaterial(GLbyte*);
+extern void __glXDispSwap_CullFace(GLbyte*);
+extern void __glXDispSwap_Fogf(GLbyte*);
+extern void __glXDispSwap_Fogfv(GLbyte*);
+extern void __glXDispSwap_Fogi(GLbyte*);
+extern void __glXDispSwap_Fogiv(GLbyte*);
+extern void __glXDispSwap_FrontFace(GLbyte*);
+extern void __glXDispSwap_Hint(GLbyte*);
+extern void __glXDispSwap_Lightf(GLbyte*);
+extern void __glXDispSwap_Lightfv(GLbyte*);
+extern void __glXDispSwap_Lighti(GLbyte*);
+extern void __glXDispSwap_Lightiv(GLbyte*);
+extern void __glXDispSwap_LightModelf(GLbyte*);
+extern void __glXDispSwap_LightModelfv(GLbyte*);
+extern void __glXDispSwap_LightModeli(GLbyte*);
+extern void __glXDispSwap_LightModeliv(GLbyte*);
+extern void __glXDispSwap_LineStipple(GLbyte*);
+extern void __glXDispSwap_LineWidth(GLbyte*);
+extern void __glXDispSwap_Materialf(GLbyte*);
+extern void __glXDispSwap_Materialfv(GLbyte*);
+extern void __glXDispSwap_Materiali(GLbyte*);
+extern void __glXDispSwap_Materialiv(GLbyte*);
+extern void __glXDispSwap_PointSize(GLbyte*);
+extern void __glXDispSwap_PolygonMode(GLbyte*);
+extern void __glXDispSwap_PolygonStipple(GLbyte*);
+extern void __glXDispSwap_Scissor(GLbyte*);
+extern void __glXDispSwap_ShadeModel(GLbyte*);
+extern void __glXDispSwap_TexParameterf(GLbyte*);
+extern void __glXDispSwap_TexParameterfv(GLbyte*);
+extern void __glXDispSwap_TexParameteri(GLbyte*);
+extern void __glXDispSwap_TexParameteriv(GLbyte*);
+extern void __glXDispSwap_TexImage1D(GLbyte*);
+extern void __glXDispSwap_TexImage2D(GLbyte*);
+extern void __glXDispSwap_TexEnvf(GLbyte*);
+extern void __glXDispSwap_TexEnvfv(GLbyte*);
+extern void __glXDispSwap_TexEnvi(GLbyte*);
+extern void __glXDispSwap_TexEnviv(GLbyte*);
+extern void __glXDispSwap_TexGend(GLbyte*);
+extern void __glXDispSwap_TexGendv(GLbyte*);
+extern void __glXDispSwap_TexGenf(GLbyte*);
+extern void __glXDispSwap_TexGenfv(GLbyte*);
+extern void __glXDispSwap_TexGeni(GLbyte*);
+extern void __glXDispSwap_TexGeniv(GLbyte*);
+extern void __glXDispSwap_InitNames(GLbyte*);
+extern void __glXDispSwap_LoadName(GLbyte*);
+extern void __glXDispSwap_PassThrough(GLbyte*);
+extern void __glXDispSwap_PopName(GLbyte*);
+extern void __glXDispSwap_PushName(GLbyte*);
+extern void __glXDispSwap_DrawBuffer(GLbyte*);
+extern void __glXDispSwap_Clear(GLbyte*);
+extern void __glXDispSwap_ClearAccum(GLbyte*);
+extern void __glXDispSwap_ClearIndex(GLbyte*);
+extern void __glXDispSwap_ClearColor(GLbyte*);
+extern void __glXDispSwap_ClearStencil(GLbyte*);
+extern void __glXDispSwap_ClearDepth(GLbyte*);
+extern void __glXDispSwap_StencilMask(GLbyte*);
+extern void __glXDispSwap_ColorMask(GLbyte*);
+extern void __glXDispSwap_DepthMask(GLbyte*);
+extern void __glXDispSwap_IndexMask(GLbyte*);
+extern void __glXDispSwap_Accum(GLbyte*);
+extern void __glXDispSwap_Disable(GLbyte*);
+extern void __glXDispSwap_Enable(GLbyte*);
+extern void __glXDispSwap_PopAttrib(GLbyte*);
+extern void __glXDispSwap_PushAttrib(GLbyte*);
+extern void __glXDispSwap_Map1d(GLbyte*);
+extern void __glXDispSwap_Map1f(GLbyte*);
+extern void __glXDispSwap_Map2d(GLbyte*);
+extern void __glXDispSwap_Map2f(GLbyte*);
+extern void __glXDispSwap_MapGrid1d(GLbyte*);
+extern void __glXDispSwap_MapGrid1f(GLbyte*);
+extern void __glXDispSwap_MapGrid2d(GLbyte*);
+extern void __glXDispSwap_MapGrid2f(GLbyte*);
+extern void __glXDispSwap_EvalCoord1dv(GLbyte*);
+extern void __glXDispSwap_EvalCoord1fv(GLbyte*);
+extern void __glXDispSwap_EvalCoord2dv(GLbyte*);
+extern void __glXDispSwap_EvalCoord2fv(GLbyte*);
+extern void __glXDispSwap_EvalMesh1(GLbyte*);
+extern void __glXDispSwap_EvalPoint1(GLbyte*);
+extern void __glXDispSwap_EvalMesh2(GLbyte*);
+extern void __glXDispSwap_EvalPoint2(GLbyte*);
+extern void __glXDispSwap_AlphaFunc(GLbyte*);
+extern void __glXDispSwap_BlendFunc(GLbyte*);
+extern void __glXDispSwap_LogicOp(GLbyte*);
+extern void __glXDispSwap_StencilFunc(GLbyte*);
+extern void __glXDispSwap_StencilOp(GLbyte*);
+extern void __glXDispSwap_DepthFunc(GLbyte*);
+extern void __glXDispSwap_PixelZoom(GLbyte*);
+extern void __glXDispSwap_PixelTransferf(GLbyte*);
+extern void __glXDispSwap_PixelTransferi(GLbyte*);
+extern void __glXDispSwap_PixelMapfv(GLbyte*);
+extern void __glXDispSwap_PixelMapuiv(GLbyte*);
+extern void __glXDispSwap_PixelMapusv(GLbyte*);
+extern void __glXDispSwap_ReadBuffer(GLbyte*);
+extern void __glXDispSwap_CopyPixels(GLbyte*);
+extern void __glXDispSwap_DrawPixels(GLbyte*);
+extern void __glXDispSwap_DepthRange(GLbyte*);
+extern void __glXDispSwap_Frustum(GLbyte*);
+extern void __glXDispSwap_LoadIdentity(GLbyte*);
+extern void __glXDispSwap_LoadMatrixf(GLbyte*);
+extern void __glXDispSwap_LoadMatrixd(GLbyte*);
+extern void __glXDispSwap_MatrixMode(GLbyte*);
+extern void __glXDispSwap_MultMatrixf(GLbyte*);
+extern void __glXDispSwap_MultMatrixd(GLbyte*);
+extern void __glXDispSwap_Ortho(GLbyte*);
+extern void __glXDispSwap_PopMatrix(GLbyte*);
+extern void __glXDispSwap_PushMatrix(GLbyte*);
+extern void __glXDispSwap_Rotated(GLbyte*);
+extern void __glXDispSwap_Rotatef(GLbyte*);
+extern void __glXDispSwap_Scaled(GLbyte*);
+extern void __glXDispSwap_Scalef(GLbyte*);
+extern void __glXDispSwap_Translated(GLbyte*);
+extern void __glXDispSwap_Translatef(GLbyte*);
+extern void __glXDispSwap_Viewport(GLbyte*);
+extern void __glXDispSwap_PolygonOffset(GLbyte*);
+extern void __glXDispSwap_DrawArrays(GLbyte*);
+extern void __glXDispSwap_Indexubv(GLbyte*);
+extern void __glXDispSwap_ColorSubTable(GLbyte*);
+extern void __glXDispSwap_CopyColorSubTable(GLbyte*);
+extern void __glXDispSwap_ActiveTextureARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord1dvARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord1fvARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord1ivARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord1svARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord2dvARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord2fvARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord2ivARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord2svARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord3dvARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord3fvARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord3ivARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord3svARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord4dvARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord4fvARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord4ivARB(GLbyte*);
+extern void __glXDispSwap_MultiTexCoord4svARB(GLbyte*);
+
+extern void __glXDispSwap_TexSubImage1D(GLbyte*);
+extern void __glXDispSwap_TexSubImage2D(GLbyte*);
+extern void __glXDispSwap_ConvolutionFilter1D(GLbyte*);
+extern void __glXDispSwap_ConvolutionFilter2D(GLbyte*);
+extern void __glXDispSwap_ConvolutionParameterfv(GLbyte*);
+extern void __glXDispSwap_ConvolutionParameteriv(GLbyte*);
+extern void __glXDispSwap_CopyConvolutionFilter1D(GLbyte*);
+extern void __glXDispSwap_CopyConvolutionFilter2D(GLbyte*);
+extern void __glXDispSwap_SeparableFilter2D(GLbyte*);
+extern void __glXDispSwap_TexImage3D(GLbyte*);
+extern void __glXDispSwap_TexSubImage3D(GLbyte*);
+extern void __glXDispSwap_DrawArrays(GLbyte*);
+extern void __glXDispSwap_PrioritizeTextures(GLbyte*);
+extern void __glXDispSwap_CopyTexImage1D(GLbyte*);
+extern void __glXDispSwap_CopyTexImage2D(GLbyte*);
+extern void __glXDispSwap_CopyTexSubImage1D(GLbyte*);
+extern void __glXDispSwap_CopyTexSubImage2D(GLbyte*);
+extern void __glXDispSwap_CopyTexSubImage3D(GLbyte*);
+
+#define __GLX_MIN_GLXCMD_OPCODE 1
+#define __GLX_MAX_GLXCMD_OPCODE 20
+#define __GLX_MIN_RENDER_OPCODE 1
+#define __GLX_MAX_RENDER_OPCODE 213
+#define __GLX_MIN_SINGLE_OPCODE 1
+#define __GLX_MAX_SINGLE_OPCODE 159
+#define __GLX_SINGLE_TABLE_SIZE 160
+#define __GLX_RENDER_TABLE_SIZE 214
+
+#define __GLX_MIN_RENDER_OPCODE_EXT 4096
+#define __GLX_MAX_RENDER_OPCODE_EXT 4123
+
+extern __GLXdispatchSingleProcPtr __glXSingleTable[__GLX_SINGLE_TABLE_SIZE];
+extern __GLXdispatchSingleProcPtr __glXSwapSingleTable[__GLX_SINGLE_TABLE_SIZE];
+#endif /* _GLX_g_disptab_h_ */
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/g_renderswap.c b/nx-X11/programs/Xserver/hw/dmx/glxProxy/g_renderswap.c
new file mode 100644
index 000000000..4f40dfd01
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/g_renderswap.c
@@ -0,0 +1,2360 @@
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#define NEED_REPLIES
+#include "glxserver.h"
+#include "glxext.h"
+#include "g_disptab.h"
+#include "unpack.h"
+
+void __glXDispSwap_CallList(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_ListBase(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_Begin(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_Color3bv(GLbyte *pc)
+{
+}
+
+void __glXDispSwap_Color3dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_Color3fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 3);
+}
+
+void __glXDispSwap_Color3iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_Color3sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_Color3ubv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+}
+
+void __glXDispSwap_Color3uiv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 3);
+}
+
+void __glXDispSwap_Color3usv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
+}
+
+void __glXDispSwap_Color4bv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+}
+
+void __glXDispSwap_Color4dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 4);
+}
+
+void __glXDispSwap_Color4fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_Color4iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_Color4sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_Color4ubv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+}
+
+void __glXDispSwap_Color4uiv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_Color4usv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_EdgeFlagv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+}
+
+void __glXDispSwap_End(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+}
+
+void __glXDispSwap_Indexdv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 8);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 1);
+
+}
+
+void __glXDispSwap_Indexfv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 1);
+
+}
+
+void __glXDispSwap_Indexiv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 1);
+
+}
+
+void __glXDispSwap_Indexsv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 1);
+
+}
+
+void __glXDispSwap_Normal3bv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+}
+
+void __glXDispSwap_Normal3dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_Normal3fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_Normal3iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_Normal3sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_RasterPos2dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 2);
+
+}
+
+void __glXDispSwap_RasterPos2fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 2);
+
+}
+
+void __glXDispSwap_RasterPos2iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 2);
+
+}
+
+void __glXDispSwap_RasterPos2sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 2);
+
+}
+
+void __glXDispSwap_RasterPos3dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_RasterPos3fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_RasterPos3iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_RasterPos3sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_RasterPos4dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_RasterPos4fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_RasterPos4iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_RasterPos4sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_Rectdv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 2);
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 16, 2);
+
+}
+
+void __glXDispSwap_Rectfv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 2);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, 2);
+
+}
+
+void __glXDispSwap_Rectiv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 2);
+ __GLX_SWAP_INT_ARRAY(pc + 8, 2);
+
+}
+
+void __glXDispSwap_Rectsv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 2);
+ __GLX_SWAP_SHORT_ARRAY(pc + 4, 2);
+
+}
+
+void __glXDispSwap_TexCoord1dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 8);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 1);
+
+}
+
+void __glXDispSwap_TexCoord1fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 1);
+
+}
+
+void __glXDispSwap_TexCoord1iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 1);
+
+}
+
+void __glXDispSwap_TexCoord1sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 1);
+
+}
+
+void __glXDispSwap_TexCoord2dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 2);
+
+}
+
+void __glXDispSwap_TexCoord2fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 2);
+
+}
+
+void __glXDispSwap_TexCoord2iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 2);
+
+}
+
+void __glXDispSwap_TexCoord2sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 2);
+
+}
+
+void __glXDispSwap_TexCoord3dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_TexCoord3fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_TexCoord3iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_TexCoord3sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_TexCoord4dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_TexCoord4fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_TexCoord4iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_TexCoord4sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_Vertex2dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 2);
+
+}
+
+void __glXDispSwap_Vertex2fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 2);
+
+}
+
+void __glXDispSwap_Vertex2iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 2);
+
+}
+
+void __glXDispSwap_Vertex2sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 2);
+
+}
+
+void __glXDispSwap_Vertex3dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_Vertex3fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_Vertex3iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_Vertex3sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_Vertex4dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_Vertex4fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_Vertex4iv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_Vertex4sv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_ClipPlane(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 36);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 32);
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_ColorMaterial(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+}
+
+void __glXDispSwap_CullFace(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_Fogf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+
+}
+
+void __glXDispSwap_Fogfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glFogfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_FLOAT_ARRAY(pc + 4, compsize);
+
+}
+
+void __glXDispSwap_Fogi(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+}
+
+void __glXDispSwap_Fogiv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glFogiv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT_ARRAY(pc + 4, compsize);
+
+}
+
+void __glXDispSwap_FrontFace(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_Hint(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+}
+
+void __glXDispSwap_Lightf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+}
+
+void __glXDispSwap_Lightfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glLightfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, compsize);
+
+}
+
+void __glXDispSwap_Lighti(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+}
+
+void __glXDispSwap_Lightiv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glLightiv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 8, compsize);
+
+}
+
+void __glXDispSwap_LightModelf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+
+}
+
+void __glXDispSwap_LightModelfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glLightModelfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_FLOAT_ARRAY(pc + 4, compsize);
+
+}
+
+void __glXDispSwap_LightModeli(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+}
+
+void __glXDispSwap_LightModeliv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ pname = *(GLenum *)(pc + 0);
+ compsize = __glLightModeliv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT_ARRAY(pc + 4, compsize);
+
+}
+
+void __glXDispSwap_LineStipple(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_SHORT(pc + 4);
+
+}
+
+void __glXDispSwap_LineWidth(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+
+}
+
+void __glXDispSwap_Materialf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+}
+
+void __glXDispSwap_Materialfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glMaterialfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, compsize);
+
+}
+
+void __glXDispSwap_Materiali(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+}
+
+void __glXDispSwap_Materialiv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glMaterialiv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 8, compsize);
+
+}
+
+void __glXDispSwap_PointSize(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+
+}
+
+void __glXDispSwap_PolygonMode(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+}
+
+void __glXDispSwap_Scissor(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+
+}
+
+void __glXDispSwap_ShadeModel(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_TexParameterf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+}
+
+void __glXDispSwap_TexParameterfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glTexParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, compsize);
+
+}
+
+void __glXDispSwap_TexParameteri(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+}
+
+void __glXDispSwap_TexParameteriv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glTexParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 8, compsize);
+
+}
+
+void __glXDispSwap_TexEnvf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+}
+
+void __glXDispSwap_TexEnvfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glTexEnvfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, compsize);
+
+}
+
+void __glXDispSwap_TexEnvi(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+}
+
+void __glXDispSwap_TexEnviv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glTexEnviv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 8, compsize);
+
+}
+
+void __glXDispSwap_TexGend(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_DOUBLE(pc + 0);
+
+}
+
+void __glXDispSwap_TexGendv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint cmdlen;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glTexGendv_size(pname);
+ if (compsize < 0) compsize = 0;
+ cmdlen = __GLX_PAD(8+compsize*8);
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, cmdlen);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 8, compsize);
+
+}
+
+void __glXDispSwap_TexGenf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+}
+
+void __glXDispSwap_TexGenfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glTexGenfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, compsize);
+
+}
+
+void __glXDispSwap_TexGeni(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+}
+
+void __glXDispSwap_TexGeniv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glTexGeniv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 8, compsize);
+
+}
+
+void __glXDispSwap_InitNames(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+}
+
+void __glXDispSwap_LoadName(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_PassThrough(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+
+}
+
+void __glXDispSwap_PopName(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+}
+
+void __glXDispSwap_PushName(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_DrawBuffer(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_Clear(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_ClearAccum(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+ __GLX_SWAP_FLOAT(pc + 12);
+
+}
+
+void __glXDispSwap_ClearIndex(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+
+}
+
+void __glXDispSwap_ClearColor(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+ __GLX_SWAP_FLOAT(pc + 12);
+
+}
+
+void __glXDispSwap_ClearStencil(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_ClearDepth(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 8);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE(pc + 0);
+
+}
+
+void __glXDispSwap_StencilMask(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_ColorMask(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+}
+
+void __glXDispSwap_DepthMask(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+}
+
+void __glXDispSwap_IndexMask(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_Accum(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+
+}
+
+void __glXDispSwap_Disable(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_Enable(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_PopAttrib(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+}
+
+void __glXDispSwap_PushAttrib(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_MapGrid1d(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 20);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+
+}
+
+void __glXDispSwap_MapGrid1f(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+}
+
+void __glXDispSwap_MapGrid2d(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 40);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 32);
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_INT(pc + 36);
+ __GLX_SWAP_DOUBLE(pc + 16);
+ __GLX_SWAP_DOUBLE(pc + 24);
+
+}
+
+void __glXDispSwap_MapGrid2f(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_FLOAT(pc + 16);
+ __GLX_SWAP_FLOAT(pc + 20);
+
+}
+
+void __glXDispSwap_EvalCoord1dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 8);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 1);
+
+}
+
+void __glXDispSwap_EvalCoord1fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 1);
+
+}
+
+void __glXDispSwap_EvalCoord2dv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 2);
+
+}
+
+void __glXDispSwap_EvalCoord2fv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 2);
+
+}
+
+void __glXDispSwap_EvalMesh1(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+}
+
+void __glXDispSwap_EvalPoint1(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_EvalMesh2(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+
+}
+
+void __glXDispSwap_EvalPoint2(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+}
+
+void __glXDispSwap_AlphaFunc(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+
+}
+
+void __glXDispSwap_BlendFunc(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+}
+
+void __glXDispSwap_LogicOp(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_StencilFunc(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+}
+
+void __glXDispSwap_StencilOp(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+}
+
+void __glXDispSwap_DepthFunc(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_PixelZoom(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+
+}
+
+void __glXDispSwap_PixelTransferf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+
+}
+
+void __glXDispSwap_PixelTransferi(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+}
+
+void __glXDispSwap_PixelMapfv(GLbyte *pc)
+{
+ GLint mapsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ mapsize = *(GLint *)(pc + 4);
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, mapsize);
+
+}
+
+void __glXDispSwap_PixelMapuiv(GLbyte *pc)
+{
+ GLint mapsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ mapsize = *(GLint *)(pc + 4);
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 8, mapsize);
+
+}
+
+void __glXDispSwap_PixelMapusv(GLbyte *pc)
+{
+ GLint mapsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ mapsize = *(GLint *)(pc + 4);
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_SHORT_ARRAY(pc + 8, mapsize);
+
+}
+
+void __glXDispSwap_ReadBuffer(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_CopyPixels(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+
+}
+
+void __glXDispSwap_DepthRange(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 16);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+
+}
+
+void __glXDispSwap_Frustum(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 48);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_DOUBLE(pc + 16);
+ __GLX_SWAP_DOUBLE(pc + 24);
+ __GLX_SWAP_DOUBLE(pc + 32);
+ __GLX_SWAP_DOUBLE(pc + 40);
+
+}
+
+void __glXDispSwap_LoadIdentity(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+}
+
+void __glXDispSwap_LoadMatrixf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 16);
+
+}
+
+void __glXDispSwap_LoadMatrixd(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 128);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 16);
+
+}
+
+void __glXDispSwap_MatrixMode(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_MultMatrixf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT_ARRAY(pc + 0, 16);
+
+}
+
+void __glXDispSwap_MultMatrixd(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 128);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 16);
+
+}
+
+void __glXDispSwap_Ortho(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 48);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_DOUBLE(pc + 16);
+ __GLX_SWAP_DOUBLE(pc + 24);
+ __GLX_SWAP_DOUBLE(pc + 32);
+ __GLX_SWAP_DOUBLE(pc + 40);
+
+}
+
+void __glXDispSwap_PopMatrix(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+}
+
+void __glXDispSwap_PushMatrix(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+}
+
+void __glXDispSwap_Rotated(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 32);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_DOUBLE(pc + 16);
+ __GLX_SWAP_DOUBLE(pc + 24);
+
+}
+
+void __glXDispSwap_Rotatef(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+ __GLX_SWAP_FLOAT(pc + 12);
+
+}
+
+void __glXDispSwap_Scaled(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_DOUBLE(pc + 16);
+
+}
+
+void __glXDispSwap_Scalef(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+}
+
+void __glXDispSwap_Translated(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 24);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_DOUBLE(pc + 16);
+
+}
+
+void __glXDispSwap_Translatef(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+}
+
+void __glXDispSwap_Viewport(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+
+}
+
+void __glXDispSwap_PolygonOffset(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+
+}
+
+void __glXDispSwap_CopyTexImage1D(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_INT(pc + 20);
+ __GLX_SWAP_INT(pc + 24);
+
+}
+
+void __glXDispSwap_CopyTexImage2D(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_INT(pc + 20);
+ __GLX_SWAP_INT(pc + 24);
+ __GLX_SWAP_INT(pc + 28);
+
+}
+
+void __glXDispSwap_CopyTexSubImage1D(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_INT(pc + 20);
+
+}
+
+void __glXDispSwap_CopyTexSubImage2D(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_INT(pc + 20);
+ __GLX_SWAP_INT(pc + 24);
+ __GLX_SWAP_INT(pc + 28);
+
+}
+
+void __glXDispSwap_BindTexture(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+}
+
+void __glXDispSwap_PrioritizeTextures(GLbyte *pc)
+{
+ GLsizei n;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ n = *(GLsizei *)(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 4, n);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 4+n*4, n);
+
+}
+
+void __glXDispSwap_Indexubv(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+}
+
+void __glXDispSwap_BlendColor(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_FLOAT(pc + 0);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+ __GLX_SWAP_FLOAT(pc + 12);
+
+}
+
+void __glXDispSwap_BlendEquation(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_ColorTableParameterfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glColorTableParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, compsize);
+
+}
+
+void __glXDispSwap_ColorTableParameteriv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glColorTableParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 8, compsize);
+
+}
+
+void __glXDispSwap_CopyColorTable(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+
+}
+
+void __glXDispSwap_CopyColorSubTable(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+
+}
+
+void __glXDispSwap_ConvolutionParameterf(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+}
+
+void __glXDispSwap_ConvolutionParameterfv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glConvolutionParameterfv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 8, compsize);
+
+}
+
+void __glXDispSwap_ConvolutionParameteri(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+}
+
+void __glXDispSwap_ConvolutionParameteriv(GLbyte *pc)
+{
+ GLenum pname;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ pname = *(GLenum *)(pc + 4);
+ compsize = __glConvolutionParameteriv_size(pname);
+ if (compsize < 0) compsize = 0;
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 8, compsize);
+
+}
+
+void __glXDispSwap_CopyConvolutionFilter1D(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+
+}
+
+void __glXDispSwap_CopyConvolutionFilter2D(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_INT(pc + 20);
+
+}
+
+void __glXDispSwap_Histogram(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+
+}
+
+void __glXDispSwap_Minmax(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+
+}
+
+void __glXDispSwap_ResetHistogram(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_ResetMinmax(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_CopyTexSubImage3D(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_INT(pc + 20);
+ __GLX_SWAP_INT(pc + 24);
+ __GLX_SWAP_INT(pc + 28);
+ __GLX_SWAP_INT(pc + 32);
+
+}
+
+void __glXDispSwap_ActiveTextureARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+
+}
+
+void __glXDispSwap_MultiTexCoord1dvARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 12);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 8);
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 1);
+
+}
+
+void __glXDispSwap_MultiTexCoord1fvARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 4, 1);
+
+}
+
+void __glXDispSwap_MultiTexCoord1ivARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 4, 1);
+
+}
+
+void __glXDispSwap_MultiTexCoord1svARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_SHORT_ARRAY(pc + 4, 1);
+
+}
+
+void __glXDispSwap_MultiTexCoord2dvARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 20);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 2);
+
+}
+
+void __glXDispSwap_MultiTexCoord2fvARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 4, 2);
+
+}
+
+void __glXDispSwap_MultiTexCoord2ivARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 4, 2);
+
+}
+
+void __glXDispSwap_MultiTexCoord2svARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_SHORT_ARRAY(pc + 4, 2);
+
+}
+
+void __glXDispSwap_MultiTexCoord3dvARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 28);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 24);
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 3);
+
+}
+
+void __glXDispSwap_MultiTexCoord3fvARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 4, 3);
+
+}
+
+void __glXDispSwap_MultiTexCoord3ivARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 4, 3);
+
+}
+
+void __glXDispSwap_MultiTexCoord3svARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_SHORT_ARRAY(pc + 4, 3);
+
+}
+
+void __glXDispSwap_MultiTexCoord4dvARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+
+#ifdef __GLX_ALIGN64
+ if ((unsigned long)(pc) & 7) {
+ __GLX_MEM_COPY(pc-4, pc, 36);
+ pc -= 4;
+ }
+#endif
+ __GLX_SWAP_INT(pc + 32);
+ __GLX_SWAP_DOUBLE_ARRAY(pc + 0, 4);
+
+}
+
+void __glXDispSwap_MultiTexCoord4fvARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_FLOAT_ARRAY(pc + 4, 4);
+
+}
+
+void __glXDispSwap_MultiTexCoord4ivARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT_ARRAY(pc + 4, 4);
+
+}
+
+void __glXDispSwap_MultiTexCoord4svARB(GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_SHORT_ARRAY(pc + 4, 4);
+
+}
+
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/global.c b/nx-X11/programs/Xserver/hw/dmx/glxProxy/global.c
new file mode 100644
index 000000000..960021a2b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/global.c
@@ -0,0 +1,77 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/global.c,v 1.3 2001/03/21 16:29:35 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define NEED_REPLIES
+#include "glxserver.h"
+
+/*
+** The last context used by the server. It is the context that is current
+** from the server's perspective.
+*/
+__GLXcontext *__glXLastContext;
+
+/*
+** X resources.
+*/
+RESTYPE __glXContextRes;
+RESTYPE __glXClientRes;
+RESTYPE __glXPixmapRes;
+RESTYPE __glXWindowRes;
+RESTYPE __glXPbufferRes;
+
+/*
+** Error codes with the extension error base already added in.
+*/
+int __glXerrorBase;
+int __glXBadContext, __glXBadContextState, __glXBadDrawable, __glXBadPixmap;
+int __glXBadContextTag, __glXBadCurrentWindow;
+int __glXBadRenderRequest, __glXBadLargeRequest;
+int __glXUnsupportedPrivateRequest;
+int __glXBadFBConfig, __glXBadPbuffer;
+
+/*
+** Reply for most singles.
+*/
+xGLXSingleReply __glXReply;
+
+/*
+** A set of state for each client. The 0th one is unused because client
+** indices start at 1, not 0.
+*/
+__GLXclientState *__glXClients[MAXCLIENTS+1];
+
+int __glXVersionMajor;
+int __glXVersionMinor;
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxcmds.c b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxcmds.c
new file mode 100644
index 000000000..8c466e13c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxcmds.c
@@ -0,0 +1,3636 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxcmds.c,v 1.8 2001/05/02 15:06:05 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxwindow.h"
+#include "dmxpixmap.h"
+#include "dmxfont.h"
+#include "dmxsync.h"
+
+#undef Xmalloc
+#undef Xcalloc
+#undef Xrealloc
+#undef Xfree
+
+#define NEED_REPLIES
+#define FONT_PCF
+#include "glxserver.h"
+#include <GL/glxtokens.h>
+#include "g_disptab.h"
+#include <pixmapstr.h>
+#include <windowstr.h>
+#include "glxutil.h"
+#include "glxext.h"
+#include "unpack.h"
+#include "GL/glx_ansic.h"
+
+#include "GL/glxproto.h"
+#include "glxvendor.h"
+#include "glxvisuals.h"
+#include "glxswap.h"
+
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+extern XID *PanoramiXVisualTable;
+#endif
+
+extern __GLXFBConfig **__glXFBConfigs;
+extern int __glXNumFBConfigs;
+
+extern __GLXFBConfig *glxLookupFBConfig( GLXFBConfigID id );
+extern __GLXFBConfig *glxLookupFBConfigByVID( VisualID vid );
+extern __GLXFBConfig *glxLookupBackEndFBConfig( GLXFBConfigID id, int screen );
+extern int glxIsExtensionSupported( char *ext );
+extern int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc);
+
+#define BE_TO_CLIENT_ERROR(x) \
+ ( (x) >= __glXerrorBase ? \
+ (x) - dmxScreen->glxErrorBase + __glXerrorBase \
+ : (x) )
+
+Display *GetBackEndDisplay( __GLXclientState *cl, int s )
+{
+ if (! cl->be_displays[s] ) {
+ cl->be_displays[s] = XOpenDisplay( DisplayString(dmxScreens[s].beDisplay) );
+ }
+ return( cl->be_displays[s] );
+}
+
+/*
+** Create a GL context with the given properties.
+*/
+static int CreateContext(__GLXclientState *cl,
+ GLXContextID gcId,
+ VisualID vid, GLXFBConfigID fbconfigId,
+ int screen,
+ GLXContextID shareList,
+ int isDirect )
+{
+ ClientPtr client = cl->client;
+ xGLXCreateContextReq *be_req;
+ xGLXCreateNewContextReq *be_new_req;
+ VisualPtr pVisual;
+ ScreenPtr pScreen;
+ __GLXcontext *glxc, *shareglxc;
+ __GLXvisualConfig *pGlxVisual;
+ __GLXscreenInfo *pGlxScreen;
+ VisualID visual = vid;
+ GLint i;
+ int from_screen = screen;
+ int to_screen = screen;
+ DMXScreenInfo *dmxScreen;
+ VisualID be_vid;
+ GLXFBConfigID be_fbconfigId;
+ int num_be_screens;
+ Display *dpy;
+
+ /*
+ ** Check if screen exists.
+ */
+ if (screen >= screenInfo.numScreens) {
+ client->errorValue = screen;
+ return BadValue;
+ }
+
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ /*
+ ** Find the display list space that we want to share.
+ **
+ */
+ if (shareList == None) {
+ shareglxc = NULL;
+ } else {
+ shareglxc = (__GLXcontext *) LookupIDByType(shareList, __glXContextRes);
+ if (!shareglxc) {
+ client->errorValue = shareList;
+ return __glXBadContext;
+ }
+ }
+
+ /*
+ ** Allocate memory for the new context
+ */
+ glxc = (__GLXcontext *) __glXMalloc(sizeof(__GLXcontext));
+ if (!glxc) {
+ return BadAlloc;
+ }
+ __glXMemset(glxc, 0, sizeof(__GLXcontext));
+
+ pScreen = screenInfo.screens[screen];
+ pGlxScreen = &__glXActiveScreens[screen];
+
+ if (fbconfigId != None) {
+ glxc->pFBConfig = glxLookupFBConfig( fbconfigId );
+ if (!glxc->pFBConfig) {
+ client->errorValue = fbconfigId;
+ __glXFree( glxc );
+ return BadValue;
+ }
+ visual = glxc->pFBConfig->associatedVisualId;
+ }
+ else {
+ glxc->pFBConfig = NULL;
+ }
+
+ if (visual != None) {
+ /*
+ ** Check if the visual ID is valid for this screen.
+ */
+ pVisual = pScreen->visuals;
+ for (i = 0; i < pScreen->numVisuals; i++, pVisual++) {
+ if (pVisual->vid == visual) {
+ break;
+ }
+ }
+ if (i == pScreen->numVisuals) {
+ client->errorValue = visual;
+ __glXFree( glxc );
+ return BadValue;
+ }
+
+ pGlxVisual = pGlxScreen->pGlxVisual;
+ for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) {
+ if (pGlxVisual->vid == visual) {
+ break;
+ }
+ }
+ if (i == pGlxScreen->numVisuals) {
+ /*
+ ** Visual not support on this screen by this OpenGL implementation.
+ */
+ client->errorValue = visual;
+ __glXFree( glxc );
+ return BadValue;
+ }
+
+ if ( glxc->pFBConfig == NULL ) {
+ glxc->pFBConfig = glxLookupFBConfigByVID( visual );
+
+ if ( glxc->pFBConfig == NULL ) {
+ /*
+ * visual does not have an FBConfig ???
+ client->errorValue = visual;
+ __glXFree( glxc );
+ return BadValue;
+ */
+ }
+ }
+ }
+ else {
+ pVisual = NULL;
+ pGlxVisual = NULL;
+ }
+
+ glxc->pScreen = pScreen;
+ glxc->pGlxScreen = pGlxScreen;
+ glxc->pVisual = pVisual;
+ glxc->pGlxVisual = pGlxVisual;
+
+ /*
+ * allocate memory for back-end servers info
+ */
+ num_be_screens = to_screen - from_screen + 1;
+ glxc->real_ids = (XID *)__glXMalloc(sizeof(XID) * num_be_screens);
+ if (!glxc->real_ids) {
+ return BadAlloc;
+ }
+ glxc->real_vids = (XID *)__glXMalloc(sizeof(XID) * num_be_screens);
+ if (!glxc->real_vids) {
+ return BadAlloc;
+ }
+
+ for (screen = from_screen; screen <= to_screen; screen++) {
+ int sent = 0;
+ pScreen = screenInfo.screens[screen];
+ pGlxScreen = &__glXActiveScreens[screen];
+ dmxScreen = &dmxScreens[screen];
+
+ if (glxc->pFBConfig) {
+ __GLXFBConfig *beFBConfig = glxLookupBackEndFBConfig( glxc->pFBConfig->id,
+ screen );
+ be_fbconfigId = beFBConfig->id;
+ }
+
+ if (pGlxVisual) {
+
+ be_vid = glxMatchGLXVisualInConfigList( pGlxVisual,
+ dmxScreen->glxVisuals,
+ dmxScreen->numGlxVisuals );
+
+ if (!be_vid) {
+ /* visual is not supported on the back-end server */
+ __glXFree( glxc->real_ids );
+ __glXFree( glxc->real_vids );
+ __glXFree( glxc );
+ return BadValue;
+ }
+ }
+
+ glxc->real_ids[screen-from_screen] = XAllocID(GetBackEndDisplay(cl,screen));
+
+ /* send the create context request to the back-end server */
+ dpy = GetBackEndDisplay(cl,screen);
+ if (glxc->pFBConfig) {
+ /*Since for a certain visual both RGB and COLOR INDEX
+ *can be on then the only parmeter to choose the renderType
+ * should be the class of the colormap since all 4 first
+ * classes does not support RGB mode only COLOR INDEX ,
+ * and so TrueColor and DirectColor does not support COLOR INDEX*/
+ int renderType = glxc->pFBConfig->renderType;
+ if ( pVisual ) {
+ switch ( pVisual->class ){
+ case PseudoColor:
+ case StaticColor:
+ case GrayScale:
+ case StaticGray:
+ renderType = GLX_COLOR_INDEX_TYPE;
+ break;
+ case TrueColor:
+ case DirectColor:
+ default:
+ renderType = GLX_RGBA_TYPE;
+ break;
+ }
+ }
+ if ( __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ LockDisplay(dpy);
+ GetReq(GLXCreateNewContext,be_new_req);
+ be_new_req->reqType = dmxScreen->glxMajorOpcode;
+ be_new_req->glxCode = X_GLXCreateNewContext;
+ be_new_req->context = (unsigned int)glxc->real_ids[screen-from_screen];
+ be_new_req->fbconfig = (unsigned int)be_fbconfigId;
+ be_new_req->screen = DefaultScreen(dpy);
+ be_new_req->renderType = renderType;
+
+ be_new_req->shareList = (shareglxc ? shareglxc->real_ids[screen-from_screen] : 0);
+ be_new_req->isDirect = 0;
+ UnlockDisplay(dpy);
+ glxc->real_vids[screen-from_screen] = be_fbconfigId;
+ sent = 1;
+ }
+ else if (glxIsExtensionSupported("GLX_SGIX_fbconfig")) {
+
+ xGLXCreateContextWithConfigSGIXReq *ext_req;
+ xGLXVendorPrivateReq *vpreq;
+ LockDisplay(dpy);
+ GetReqExtra(GLXVendorPrivate,
+ sz_xGLXCreateContextWithConfigSGIXReq - sz_xGLXVendorPrivateReq,
+ vpreq);
+ ext_req = (xGLXCreateContextWithConfigSGIXReq *)vpreq;
+ ext_req->reqType = dmxScreen->glxMajorOpcode;
+ ext_req->glxCode = X_GLXVendorPrivate;
+ ext_req->vendorCode = X_GLXvop_CreateContextWithConfigSGIX;
+ ext_req->context = (unsigned int)glxc->real_ids[screen-from_screen];
+ ext_req->fbconfig = (unsigned int)be_fbconfigId;
+ ext_req->screen = DefaultScreen(dpy);
+ ext_req->renderType = renderType;
+ ext_req->shareList = (shareglxc ? shareglxc->real_ids[screen-from_screen] : 0);
+ ext_req->isDirect = 0;
+ UnlockDisplay(dpy);
+ glxc->real_vids[screen-from_screen] = be_fbconfigId;
+ sent = 1;
+ }
+ }
+
+ if (!sent) {
+ LockDisplay(dpy);
+ GetReq(GLXCreateContext,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXCreateContext;
+ be_req->context = (unsigned int)glxc->real_ids[screen-from_screen];
+ be_req->visual = (unsigned int)be_vid;
+ be_req->screen = DefaultScreen(dpy);
+ be_req->shareList = (shareglxc ? shareglxc->real_ids[screen-from_screen] : 0);
+ be_req->isDirect = 0;
+ UnlockDisplay(dpy);
+ glxc->real_vids[screen-from_screen] = be_vid;
+ }
+ SyncHandle();
+
+ }
+
+ /*
+ ** Register this context as a resource.
+ */
+ if (!AddResource(gcId, __glXContextRes, (pointer)glxc)) {
+ __glXFree( glxc->real_ids );
+ __glXFree( glxc->real_vids );
+ __glXFree( glxc );
+ client->errorValue = gcId;
+ return BadAlloc;
+ }
+
+ /*
+ ** Finally, now that everything is working, setup the rest of the
+ ** context.
+ */
+ glxc->id = gcId;
+ glxc->share_id = shareList;
+ glxc->idExists = GL_TRUE;
+ glxc->isCurrent = GL_FALSE;
+
+ return Success;
+}
+
+int __glXCreateContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
+
+ return( CreateContext(cl, req->context,req->visual, None,
+ req->screen, req->shareList, req->isDirect) );
+
+}
+
+int __glXCreateNewContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
+
+ return( CreateContext(cl, req->context,None, req->fbconfig,
+ req->screen, req->shareList, req->isDirect) );
+
+}
+
+int __glXCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextWithConfigSGIXReq *req = (xGLXCreateContextWithConfigSGIXReq *) pc;
+
+ return( CreateContext(cl, req->context, None, req->fbconfig,
+ req->screen, req->shareList, req->isDirect) );
+
+}
+
+int __glXQueryMaxSwapBarriersSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXQueryMaxSwapBarriersSGIXReq *req =
+ (xGLXQueryMaxSwapBarriersSGIXReq *)pc;
+ xGLXQueryMaxSwapBarriersSGIXReply reply;
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = 0;
+ reply.max = QueryMaxSwapBarriersSGIX(req->screen);
+
+ if (client->swapped) {
+ __glXSwapQueryMaxSwapBarriersSGIXReply(client, &reply);
+ } else {
+ WriteToClient(client, sz_xGLXQueryMaxSwapBarriersSGIXReply,
+ (char *)&reply);
+ }
+
+ return Success;
+}
+
+int __glXBindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXBindSwapBarrierSGIXReq *req = (xGLXBindSwapBarrierSGIXReq *)pc;
+ DrawablePtr pDraw;
+ __GLXpixmap *pGlxPixmap = NULL;
+ __glXWindow *pGlxWindow = NULL;
+
+ pDraw = (DrawablePtr) LookupDrawable(req->drawable, client);
+ if (!pDraw) {
+ pGlxPixmap = (__GLXpixmap *) LookupIDByType(req->drawable,
+ __glXPixmapRes);
+ if (pGlxPixmap) pDraw = pGlxPixmap->pDraw;
+ }
+
+ if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ pGlxWindow = (__glXWindow *) LookupIDByType(req->drawable,
+ __glXWindowRes);
+ if (pGlxWindow) pDraw = pGlxWindow->pDraw;
+ }
+
+ if (!pDraw) {
+ client->errorValue = req->drawable;
+ return __glXBadDrawable;
+ }
+
+ return BindSwapBarrierSGIX(pDraw, req->barrier);
+}
+
+int __glXJoinSwapGroupSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXJoinSwapGroupSGIXReq *req = (xGLXJoinSwapGroupSGIXReq *)pc;
+ DrawablePtr pDraw, pMember = NULL;
+ __GLXpixmap *pGlxPixmap = NULL;
+ __glXWindow *pGlxWindow = NULL;
+
+ pDraw = (DrawablePtr) LookupDrawable(req->drawable, client);
+ if (!pDraw) {
+ pGlxPixmap = (__GLXpixmap *) LookupIDByType(req->drawable,
+ __glXPixmapRes);
+ if (pGlxPixmap) pDraw = pGlxPixmap->pDraw;
+ }
+
+ if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ pGlxWindow = (__glXWindow *) LookupIDByType(req->drawable,
+ __glXWindowRes);
+ if (pGlxWindow) pDraw = pGlxWindow->pDraw;
+ }
+
+ if (!pDraw) {
+ client->errorValue = req->drawable;
+ return __glXBadDrawable;
+ }
+
+ if (req->member != None) {
+ pMember = (DrawablePtr) LookupDrawable(req->member, client);
+ if (!pMember) {
+ pGlxPixmap = (__GLXpixmap *) LookupIDByType(req->member,
+ __glXPixmapRes);
+ if (pGlxPixmap) pMember = pGlxPixmap->pDraw;
+ }
+
+ if (!pMember && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ pGlxWindow = (__glXWindow *) LookupIDByType(req->member,
+ __glXWindowRes);
+ if (pGlxWindow) pMember = pGlxWindow->pDraw;
+ }
+
+ if (!pMember) {
+ client->errorValue = req->member;
+ return __glXBadDrawable;
+ }
+ }
+
+ return JoinSwapGroupSGIX(pDraw, pMember);
+}
+
+
+/*
+** Destroy a GL context as an X resource.
+*/
+int __glXDestroyContext(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
+ xGLXDestroyContextReq *be_req;
+ GLXContextID gcId = req->context;
+ __GLXcontext *glxc;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+
+ glxc = (__GLXcontext *) LookupIDByType(gcId, __glXContextRes);
+ if (glxc) {
+ /*
+ ** Just free the resource; don't actually destroy the context,
+ ** because it might be in use. The
+ ** destroy method will be called by the resource destruction routine
+ ** if necessary.
+ */
+ FreeResourceByType(gcId, __glXContextRes, FALSE);
+
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+ } else {
+ client->errorValue = gcId;
+ return __glXBadContext;
+ }
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ /*
+ * send DestroyContext request to all back-end servers
+ */
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReq(GLXDestroyContext,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXDestroyContext;
+ be_req->context = glxc->real_ids[s-from_screen];
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+ return Success;
+}
+
+/*****************************************************************************/
+
+/*
+** For each client, the server keeps a table of all the contexts that are
+** current for that client (each thread of a client may have its own current
+** context). These routines add, change, and lookup contexts in the table.
+*/
+
+/*
+** Add a current context, and return the tag that will be used to refer to it.
+*/
+static int AddCurrentContext(__GLXclientState *cl, __GLXcontext *glxc, DrawablePtr pDraw)
+{
+ int i;
+ int num = cl->numCurrentContexts;
+ __GLXcontext **table = cl->currentContexts;
+
+ if (!glxc) return -1;
+
+ /*
+ ** Try to find an empty slot and use it.
+ */
+ for (i=0; i < num; i++) {
+ if (!table[i]) {
+ table[i] = glxc;
+ return i+1;
+ }
+ }
+ /*
+ ** Didn't find a free slot, so we'll have to grow the table.
+ */
+ if (!num) {
+ table = (__GLXcontext **) __glXMalloc(sizeof(__GLXcontext *));
+ cl->currentDrawables = (DrawablePtr *) __glXMalloc(sizeof(DrawablePtr));
+ cl->be_currentCTag = (GLXContextTag *) __glXMalloc(screenInfo.numScreens *sizeof(GLXContextTag));
+ } else {
+ table = (__GLXcontext **) __glXRealloc(table,
+ (num+1)*sizeof(__GLXcontext *));
+ cl->currentDrawables = (DrawablePtr *) __glXRealloc(
+ cl->currentDrawables ,
+ (num+1)*sizeof(DrawablePtr));
+ cl->be_currentCTag = (GLXContextTag *) __glXRealloc(cl->be_currentCTag,
+ (num+1)*screenInfo.numScreens*sizeof(GLXContextTag));
+ }
+ table[num] = glxc;
+ cl->currentDrawables[num] = pDraw;
+ cl->currentContexts = table;
+ cl->numCurrentContexts++;
+
+ __glXMemset(cl->be_currentCTag + num*screenInfo.numScreens, 0,
+ screenInfo.numScreens * sizeof(Display *));
+
+ return num+1;
+}
+
+/*
+** Given a tag, change the current context for the corresponding entry.
+*/
+static void ChangeCurrentContext(__GLXclientState *cl, __GLXcontext *glxc,
+ GLXContextTag tag)
+{
+ __GLXcontext **table = cl->currentContexts;
+ table[tag-1] = glxc;
+}
+
+/*
+** Given a tag, and back-end screen number, retrives the current back-end
+** tag.
+*/
+int GetCurrentBackEndTag(__GLXclientState *cl, GLXContextTag tag, int s)
+{
+ if (tag >0) {
+ return( cl->be_currentCTag[ (tag-1)*screenInfo.numScreens + s ] );
+ }
+ else {
+ return( 0 );
+ }
+}
+
+/*
+** Given a tag, and back-end screen number, sets the current back-end
+** tag.
+*/
+static void SetCurrentBackEndTag(__GLXclientState *cl, GLXContextTag tag, int s, GLXContextTag be_tag)
+{
+ if (tag >0) {
+ cl->be_currentCTag[ (tag-1)*screenInfo.numScreens + s ] = be_tag;
+ }
+}
+
+/*
+** For this implementation we have chosen to simply use the index of the
+** context's entry in the table as the context tag. A tag must be greater
+** than 0.
+*/
+__GLXcontext *__glXLookupContextByTag(__GLXclientState *cl, GLXContextTag tag)
+{
+ int num = cl->numCurrentContexts;
+
+ if (tag < 1 || tag > num) {
+ return 0;
+ } else {
+ return cl->currentContexts[tag-1];
+ }
+}
+
+DrawablePtr __glXLookupDrawableByTag(__GLXclientState *cl, GLXContextTag tag)
+{
+ int num = cl->numCurrentContexts;
+
+ if (tag < 1 || tag > num) {
+ return 0;
+ } else {
+ return cl->currentDrawables[tag-1];
+ }
+}
+
+/*****************************************************************************/
+
+static void StopUsingContext(__GLXcontext *glxc)
+{
+ if (glxc) {
+ if (glxc == __glXLastContext) {
+ /* Tell server GL library */
+ __glXLastContext = 0;
+ }
+ glxc->isCurrent = GL_FALSE;
+ if (!glxc->idExists) {
+ __glXFreeContext(glxc);
+ }
+ }
+}
+
+static void StartUsingContext(__GLXclientState *cl, __GLXcontext *glxc)
+{
+ glxc->isCurrent = GL_TRUE;
+}
+
+/*****************************************************************************/
+/*
+** Make an OpenGL context and drawable current.
+*/
+static int MakeCurrent(__GLXclientState *cl,
+ GLXDrawable drawable,
+ GLXDrawable readdrawable,
+ GLXContextID context,
+ GLXContextTag oldContextTag)
+{
+ ClientPtr client = cl->client;
+ DrawablePtr pDraw = NULL;
+ DrawablePtr pReadDraw = NULL;
+ xGLXMakeCurrentReadSGIReply new_reply;
+ xGLXMakeCurrentReq *be_req;
+ xGLXMakeCurrentReply be_reply;
+ xGLXMakeContextCurrentReq *be_new_req;
+ xGLXMakeContextCurrentReply be_new_reply;
+ GLXDrawable drawId = drawable;
+ GLXDrawable readId = readdrawable;
+ GLXContextID contextId = context;
+ __GLXpixmap *pGlxPixmap = 0;
+ __GLXpixmap *pReadGlxPixmap = 0;
+ __GLXcontext *glxc, *prevglxc;
+ GLXContextTag tag = oldContextTag;
+ WindowPtr pWin = NULL;
+ WindowPtr pReadWin = NULL;
+ __glXWindow *pGlxWindow = NULL;
+ __glXWindow *pGlxReadWindow = NULL;
+ __glXPbuffer *pGlxPbuffer = NULL;
+ __glXPbuffer *pGlxReadPbuffer = NULL;
+#ifdef PANORAMIX
+ PanoramiXRes *pXinDraw = NULL;
+ PanoramiXRes *pXinReadDraw = NULL;
+#endif
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+
+ /*
+ ** If one is None and the other isn't, it's a bad match.
+ */
+ if ((drawId == None && contextId != None) ||
+ (drawId != None && contextId == None)) {
+ return BadMatch;
+ }
+
+ /*
+ ** Lookup old context. If we have one, it must be in a usable state.
+ */
+ if (tag != 0) {
+ prevglxc = __glXLookupContextByTag(cl, tag);
+ if (!prevglxc) {
+ /*
+ ** Tag for previous context is invalid.
+ */
+ return __glXBadContextTag;
+ }
+ } else {
+ prevglxc = 0;
+ }
+
+ /*
+ ** Lookup new context. It must not be current for someone else.
+ */
+ if (contextId != None) {
+ glxc = (__GLXcontext *) LookupIDByType(contextId, __glXContextRes);
+ if (!glxc) {
+ client->errorValue = contextId;
+ return __glXBadContext;
+ }
+ if ((glxc != prevglxc) && glxc->isCurrent) {
+ /* Context is current to somebody else */
+ return BadAccess;
+ }
+ } else {
+ /* Switching to no context. Ignore new drawable. */
+ glxc = 0;
+ }
+
+ if (drawId != None) {
+ pDraw = (DrawablePtr) LookupDrawable(drawId, client);
+ if (pDraw) {
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ /*
+ ** Drawable is an X Window.
+ */
+ VisualID vid;
+ pWin = (WindowPtr)pDraw;
+ vid = wVisual(pWin);
+
+ new_reply.writeVid = (glxc->pFBConfig ? glxc->pFBConfig->id : vid);
+ new_reply.writeType = GLX_WINDOW_TYPE;
+
+ /*
+ ** Check if window and context are similar.
+ */
+ if ((vid != glxc->pVisual->vid) ||
+ (pWin->drawable.pScreen != glxc->pScreen)) {
+ client->errorValue = drawId;
+ return BadMatch;
+ }
+
+ from_screen = to_screen = pWin->drawable.pScreen->myNum;
+
+ } else {
+ /*
+ ** An X Pixmap is not allowed as a parameter (a GLX Pixmap
+ ** is, but it must first be created with glxCreateGLXPixmap).
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ }
+
+ if (!pDraw) {
+ pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId,
+ __glXPixmapRes);
+ if (pGlxPixmap) {
+ /*
+ ** Check if pixmap and context are similar.
+ */
+ if (pGlxPixmap->pScreen != glxc->pScreen ||
+ pGlxPixmap->pGlxVisual != glxc->pGlxVisual) {
+ client->errorValue = drawId;
+ return BadMatch;
+ }
+ pDraw = pGlxPixmap->pDraw;
+
+ new_reply.writeVid = (glxc->pFBConfig ? glxc->pFBConfig->id :
+ pGlxPixmap->pGlxVisual->vid);
+
+ new_reply.writeType = GLX_PIXMAP_TYPE;
+
+ from_screen = to_screen = pGlxPixmap->pScreen->myNum;
+
+ }
+ }
+
+ if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ pGlxWindow = (__glXWindow *) LookupIDByType(drawId, __glXWindowRes);
+ if (pGlxWindow) {
+ /*
+ ** Drawable is a GLXWindow.
+ **
+ ** Check if GLX window and context are similar.
+ */
+ if (pGlxWindow->pScreen != glxc->pScreen ||
+ pGlxWindow->pGlxFBConfig != glxc->pFBConfig) {
+ client->errorValue = drawId;
+ return BadMatch;
+ }
+
+ pDraw = pGlxWindow->pDraw;
+ new_reply.writeVid = pGlxWindow->pGlxFBConfig->id;
+ new_reply.writeType = GLX_GLXWINDOW_TYPE;
+ }
+
+ }
+
+ if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ pGlxPbuffer = (__glXPbuffer *)LookupIDByType(drawId, __glXPbufferRes);
+ if (pGlxPbuffer) {
+ if (pGlxPbuffer->pScreen != glxc->pScreen ||
+ pGlxPbuffer->pFBConfig != glxc->pFBConfig) {
+ client->errorValue = drawId;
+ return BadMatch;
+ }
+
+ pDraw = (DrawablePtr)pGlxPbuffer;
+ new_reply.writeVid = pGlxPbuffer->pFBConfig->id;
+ new_reply.writeType = GLX_PBUFFER_TYPE;
+ }
+ }
+
+ if (!pDraw) {
+ /*
+ ** Drawable is not a Window , GLXWindow or a GLXPixmap.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+
+ } else {
+ pDraw = 0;
+ }
+
+ if (readId != None && readId != drawId ) {
+ pReadDraw = (DrawablePtr) LookupDrawable(readId, client);
+ if (pReadDraw) {
+ if (pReadDraw->type == DRAWABLE_WINDOW) {
+ /*
+ ** Drawable is an X Window.
+ */
+ VisualID vid;
+ pReadWin = (WindowPtr)pDraw;
+ vid = wVisual(pReadWin);
+
+ new_reply.readVid = (glxc->pFBConfig ? glxc->pFBConfig->id : vid);
+ new_reply.readType = GLX_WINDOW_TYPE;
+
+ /*
+ ** Check if window and context are similar.
+ */
+ if ((vid != glxc->pVisual->vid) ||
+ (pReadWin->drawable.pScreen != glxc->pScreen)) {
+ client->errorValue = readId;
+ return BadMatch;
+ }
+
+ } else {
+
+ /*
+ ** An X Pixmap is not allowed as a parameter (a GLX Pixmap
+ ** is, but it must first be created with glxCreateGLXPixmap).
+ */
+ client->errorValue = readId;
+ return __glXBadDrawable;
+ }
+ }
+
+ if (!pReadDraw) {
+ pReadGlxPixmap = (__GLXpixmap *) LookupIDByType(readId,
+ __glXPixmapRes);
+ if (pReadGlxPixmap) {
+ /*
+ ** Check if pixmap and context are similar.
+ */
+ if (pReadGlxPixmap->pScreen != glxc->pScreen ||
+ pReadGlxPixmap->pGlxVisual != glxc->pGlxVisual) {
+ client->errorValue = readId;
+ return BadMatch;
+ }
+ pReadDraw = pReadGlxPixmap->pDraw;
+
+ new_reply.readVid = (glxc->pFBConfig ? glxc->pFBConfig->id :
+ pReadGlxPixmap->pGlxVisual->vid );
+ new_reply.readType = GLX_PIXMAP_TYPE;
+
+ }
+ }
+
+ if (!pReadDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ pGlxReadWindow = (__glXWindow *)
+ LookupIDByType(readId, __glXWindowRes);
+ if (pGlxReadWindow) {
+ /*
+ ** Drawable is a GLXWindow.
+ **
+ ** Check if GLX window and context are similar.
+ */
+ if (pGlxReadWindow->pScreen != glxc->pScreen ||
+ pGlxReadWindow->pGlxFBConfig != glxc->pFBConfig) {
+ client->errorValue = readId;
+ return BadMatch;
+ }
+
+ pReadDraw = pGlxReadWindow->pDraw;
+ new_reply.readVid = pGlxReadWindow->pGlxFBConfig->id;
+ new_reply.readType = GLX_GLXWINDOW_TYPE;
+ }
+ }
+
+ if (!pReadDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ pGlxReadPbuffer = (__glXPbuffer *)LookupIDByType(readId, __glXPbufferRes);
+ if (pGlxReadPbuffer) {
+ if (pGlxReadPbuffer->pScreen != glxc->pScreen ||
+ pGlxReadPbuffer->pFBConfig != glxc->pFBConfig) {
+ client->errorValue = drawId;
+ return BadMatch;
+ }
+
+ pReadDraw = (DrawablePtr)pGlxReadPbuffer;
+ new_reply.readVid = pGlxReadPbuffer->pFBConfig->id;
+ new_reply.readType = GLX_PBUFFER_TYPE;
+ }
+ }
+
+ if (!pReadDraw) {
+ /*
+ ** Drawable is neither a Window nor a GLXPixmap.
+ */
+ client->errorValue = readId;
+ return __glXBadDrawable;
+ }
+
+ } else {
+ pReadDraw = pDraw;
+ pReadGlxPixmap = pGlxPixmap;
+ pReadWin = pWin;
+ new_reply.readVid = new_reply.writeVid;
+ new_reply.readType = new_reply.writeType;
+ }
+
+ if (prevglxc) {
+
+ if (prevglxc->pGlxPixmap) {
+ /*
+ ** The previous drawable was a glx pixmap, release it.
+ */
+ prevglxc->pGlxPixmap->refcnt--;
+ __glXFreeGLXPixmap( prevglxc->pGlxPixmap );
+ prevglxc->pGlxPixmap = 0;
+ }
+
+ if (prevglxc->pGlxReadPixmap &&
+ prevglxc->pGlxReadPixmap != prevglxc->pGlxPixmap ) {
+ /*
+ ** The previous drawable was a glx pixmap, release it.
+ */
+ prevglxc->pGlxReadPixmap->refcnt--;
+ __glXFreeGLXPixmap( prevglxc->pGlxReadPixmap );
+ prevglxc->pGlxReadPixmap = 0;
+ }
+
+ if (prevglxc->pGlxWindow) {
+ /*
+ ** The previous drawable was a glx window, release it.
+ */
+ prevglxc->pGlxWindow->refcnt--;
+ __glXFreeGLXWindow( prevglxc->pGlxWindow );
+ prevglxc->pGlxWindow = 0;
+ }
+
+ if (prevglxc->pGlxReadWindow &&
+ prevglxc->pGlxReadWindow != prevglxc->pGlxWindow) {
+ /*
+ ** The previous drawable was a glx window, release it.
+ */
+ prevglxc->pGlxReadWindow->refcnt--;
+ __glXFreeGLXWindow( prevglxc->pGlxReadWindow );
+ prevglxc->pGlxReadWindow = 0;
+ }
+
+ if (prevglxc->pGlxPbuffer) {
+ /*
+ ** The previous drawable was a glx Pbuffer, release it.
+ */
+ prevglxc->pGlxPbuffer->refcnt--;
+ __glXFreeGLXPbuffer( prevglxc->pGlxPbuffer );
+ prevglxc->pGlxPbuffer = 0;
+ }
+
+ if (prevglxc->pGlxReadPbuffer &&
+ prevglxc->pGlxReadPbuffer != prevglxc->pGlxPbuffer ) {
+ /*
+ ** The previous drawable was a glx Pbuffer, release it.
+ */
+ prevglxc->pGlxReadPbuffer->refcnt--;
+ __glXFreeGLXPbuffer( prevglxc->pGlxReadPbuffer );
+ prevglxc->pGlxReadPbuffer = 0;
+ }
+
+ ChangeCurrentContext(cl, glxc, tag);
+ ChangeCurrentContext(cl, glxc, tag);
+ StopUsingContext(prevglxc);
+ } else {
+ tag = AddCurrentContext(cl, glxc, pDraw);
+ }
+ if (glxc) {
+
+ glxc->pGlxPixmap = pGlxPixmap;
+ glxc->pGlxReadPixmap = pReadGlxPixmap;
+ glxc->pGlxWindow = pGlxWindow;
+ glxc->pGlxReadWindow = pGlxReadWindow;
+ glxc->pGlxPbuffer = pGlxPbuffer;
+ glxc->pGlxReadPbuffer = pGlxReadPbuffer;
+
+ if (pGlxPixmap) {
+ pGlxPixmap->refcnt++;
+ }
+
+ if (pReadGlxPixmap && pReadGlxPixmap != pGlxPixmap) {
+ pReadGlxPixmap->refcnt++;
+ }
+
+ if (pGlxWindow) {
+ pGlxWindow->refcnt++;
+ }
+
+ if (pGlxReadWindow && pGlxReadWindow != pGlxWindow) {
+ pGlxReadWindow->refcnt++;
+ }
+
+ if (pGlxPbuffer) {
+ pGlxPbuffer->refcnt++;
+ }
+
+ if (pGlxReadPbuffer && pGlxReadPbuffer != pGlxPbuffer) {
+ pGlxReadPbuffer->refcnt++;
+ }
+
+ StartUsingContext(cl, glxc);
+ new_reply.contextTag = tag;
+ } else {
+ new_reply.contextTag = 0;
+ }
+ new_reply.length = 0;
+ new_reply.type = X_Reply;
+ new_reply.sequenceNumber = client->sequence;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+
+ if (pDraw && new_reply.writeType != GLX_PBUFFER_TYPE) {
+ pXinDraw = (PanoramiXRes *)
+ SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, SecurityReadAccess);
+ }
+
+ if (pReadDraw && pReadDraw != pDraw &&
+ new_reply.readType != GLX_PBUFFER_TYPE) {
+ pXinReadDraw = (PanoramiXRes *)
+ SecurityLookupIDByClass(client, pReadDraw->id, XRC_DRAWABLE, SecurityReadAccess);
+ }
+ else {
+ pXinReadDraw = pXinDraw;
+ }
+ }
+#endif
+
+
+ /* send the MakeCurrent request to all required
+ * back-end servers.
+ */
+ for (s = from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+ unsigned int be_draw = None;
+ unsigned int be_read_draw = None;
+
+ if (pGlxPixmap) {
+ be_draw = pGlxPixmap->be_xids[s];
+ }
+ else if (pGlxPbuffer) {
+ be_draw = pGlxPbuffer->be_xids[s];
+ }
+#ifdef PANORAMIX
+ else if (pXinDraw) {
+ pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[s].id,
+ client,
+ SecurityReadAccess);
+ }
+#endif
+ else if (pGlxWindow) {
+ pWin = (WindowPtr)pGlxWindow->pDraw;
+ }
+
+ if (pWin && be_draw == None) {
+ be_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
+ if (!be_draw) {
+ /* it might be that the window did not created yet on the */
+ /* back-end server (lazy window creation option), force */
+ /* creation of the window */
+ dmxCreateAndRealizeWindow( pWin, TRUE );
+ be_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
+ }
+ }
+
+ /*
+ * Before sending the MakeCurrent request - sync the
+ * X11 connection to the back-end servers to make sure
+ * that drawable is already created
+ */
+ dmxSync( dmxScreen, 1 );
+
+ if (drawId == readId) {
+ LockDisplay(dpy);
+ GetReq(GLXMakeCurrent, be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXMakeCurrent;
+ be_req->drawable = be_draw;
+ be_req->context = (unsigned int)(glxc ? glxc->real_ids[s-from_screen] : 0);
+ be_req->oldContextTag = GetCurrentBackEndTag(cl, tag, s);
+ if (!_XReply(dpy, (xReply *) &be_reply, 0, False)) {
+
+ /* The make current failed */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return( BE_TO_CLIENT_ERROR(dmxLastErrorEvent.error_code) );
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ SetCurrentBackEndTag( cl, tag, s, be_reply.contextTag );
+ }
+ else {
+
+ if (pReadGlxPixmap) {
+ be_read_draw = pReadGlxPixmap->be_xids[s];
+ }
+ else if (pGlxReadPbuffer) {
+ be_read_draw = pGlxReadPbuffer->be_xids[s];
+ }
+#ifdef PANORAMIX
+ else if (pXinReadDraw) {
+ pReadWin = (WindowPtr)SecurityLookupWindow(pXinReadDraw->info[s].id,
+ client,
+ SecurityReadAccess);
+ }
+#endif
+ else if (pGlxReadWindow) {
+ pReadWin = (WindowPtr)pGlxReadWindow->pDraw;
+ }
+
+ if (pReadWin && be_read_draw == None) {
+ be_read_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pReadWin))->window;
+ if (!be_read_draw) {
+ /* it might be that the window did not created yet on the */
+ /* back-end server (lazy window creation option), force */
+ /* creation of the window */
+ dmxCreateAndRealizeWindow( pReadWin, TRUE );
+ be_read_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pReadWin))->window;
+ dmxSync( dmxScreen, 1 );
+ }
+ }
+
+ if ( __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ LockDisplay(dpy);
+ GetReq(GLXMakeContextCurrent, be_new_req);
+ be_new_req->reqType = dmxScreen->glxMajorOpcode;
+ be_new_req->glxCode = X_GLXMakeContextCurrent;
+ be_new_req->drawable = be_draw;
+ be_new_req->readdrawable = be_read_draw;
+ be_new_req->context = (unsigned int)(glxc ? glxc->real_ids[s-from_screen] : 0);
+ be_new_req->oldContextTag = GetCurrentBackEndTag(cl, tag, s);
+ if (!_XReply(dpy, (xReply *) &be_new_reply, 0, False)) {
+
+ /* The make current failed */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return( BE_TO_CLIENT_ERROR(dmxLastErrorEvent.error_code) );
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ SetCurrentBackEndTag( cl, tag, s, be_new_reply.contextTag );
+ }
+ else if (glxIsExtensionSupported("GLX_SGI_make_current_read")) {
+ xGLXMakeCurrentReadSGIReq *ext_req;
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ xGLXMakeCurrentReadSGIReply ext_reply;
+
+ LockDisplay(dpy);
+ GetReqExtra(GLXVendorPrivateWithReply,
+ sz_xGLXMakeCurrentReadSGIReq - sz_xGLXVendorPrivateWithReplyReq,
+ vpreq);
+ ext_req = (xGLXMakeCurrentReadSGIReq *)vpreq;
+ ext_req->reqType = dmxScreen->glxMajorOpcode;
+ ext_req->glxCode = X_GLXVendorPrivateWithReply;
+ ext_req->vendorCode = X_GLXvop_MakeCurrentReadSGI;
+ ext_req->drawable = be_draw;
+ ext_req->readable = be_read_draw;
+ ext_req->context = (unsigned int)(glxc ? glxc->real_ids[s-from_screen] : 0);
+ ext_req->oldContextTag = GetCurrentBackEndTag(cl, tag, s);
+ if (!_XReply(dpy, (xReply *) &ext_reply, 0, False)) {
+
+ /* The make current failed */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return( BE_TO_CLIENT_ERROR(dmxLastErrorEvent.error_code) );
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ SetCurrentBackEndTag( cl, tag, s, ext_reply.contextTag );
+
+ }
+ else {
+ return BadMatch;
+ }
+ }
+
+ XFlush( dpy );
+ }
+
+ if (client->swapped) {
+ __glXSwapMakeCurrentReply(client, &new_reply);
+ } else {
+ WriteToClient(client, sz_xGLXMakeContextCurrentReply, (char *)&new_reply);
+ }
+
+ return Success;
+}
+
+int __glXMakeCurrent(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc;
+
+ return( MakeCurrent(cl, req->drawable, req->drawable,
+ req->context, req->oldContextTag ) );
+}
+
+int __glXMakeContextCurrent(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc;
+
+ return( MakeCurrent(cl, req->drawable, req->readdrawable,
+ req->context, req->oldContextTag ) );
+}
+
+int __glXMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc;
+
+ return( MakeCurrent(cl, req->drawable, req->readable,
+ req->context, req->oldContextTag ) );
+}
+
+int __glXIsDirect(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
+ xGLXIsDirectReply reply;
+ __GLXcontext *glxc;
+
+ /*
+ ** Find the GL context.
+ */
+ glxc = (__GLXcontext *) LookupIDByType(req->context, __glXContextRes);
+ if (!glxc) {
+ client->errorValue = req->context;
+ return __glXBadContext;
+ }
+
+ reply.isDirect = 0;
+ reply.length = 0;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (client->swapped) {
+ __glXSwapIsDirectReply(client, &reply);
+ } else {
+ WriteToClient(client, sz_xGLXIsDirectReply, (char *)&reply);
+ }
+
+ return Success;
+}
+
+int __glXQueryVersion(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+/* xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc; */
+ xGLXQueryVersionReply reply;
+
+ /*
+ ** Server should take into consideration the version numbers sent by the
+ ** client if it wants to work with older clients; however, in this
+ ** implementation the server just returns its version number.
+ */
+ reply.majorVersion = __glXVersionMajor;
+ reply.minorVersion = __glXVersionMinor;
+ reply.length = 0;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (client->swapped) {
+ __glXSwapQueryVersionReply(client, &reply);
+ } else {
+ WriteToClient(client, sz_xGLXQueryVersionReply, (char *)&reply);
+ }
+ return Success;
+}
+
+int __glXWaitGL(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXWaitGLReq *req = (xGLXWaitGLReq *)pc;
+ xGLXWaitGLReq *be_req = (xGLXWaitGLReq *)pc;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+ __GLXcontext *glxc = NULL;
+
+ if (req->contextTag != 0) {
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (glxc) {
+ from_screen = to_screen = glxc->pScreen->myNum;
+ }
+ }
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReq(GLXWaitGL,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXWaitGL;
+ be_req->contextTag = (glxc ? GetCurrentBackEndTag(cl,req->contextTag,s) : 0);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ XSync(dpy, False);
+ }
+
+ return Success;
+}
+
+int __glXWaitX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXWaitXReq *req = (xGLXWaitXReq *)pc;
+ xGLXWaitXReq *be_req;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+ __GLXcontext *glxc = NULL;
+
+ if (req->contextTag != 0) {
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (glxc) {
+ from_screen = to_screen = glxc->pScreen->myNum;
+ }
+ }
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ dmxSync( dmxScreen, 1 );
+
+ LockDisplay(dpy);
+ GetReq(GLXWaitX,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXWaitX;
+ be_req->contextTag = (glxc ? GetCurrentBackEndTag(cl,req->contextTag,s) : 0);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ XFlush( dpy );
+ }
+
+ return Success;
+}
+
+int __glXCopyContext(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXCopyContextReq *be_req;
+ xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc;
+ GLXContextID source = req->source;
+ GLXContextID dest = req->dest;
+ GLXContextTag tag = req->contextTag;
+ unsigned long mask = req->mask;
+ __GLXcontext *src, *dst;
+ int s;
+ int from_screen = 0;
+ int to_screen = 0;
+
+ /*
+ ** Check that each context exists.
+ */
+ src = (__GLXcontext *) LookupIDByType(source, __glXContextRes);
+ if (!src) {
+ client->errorValue = source;
+ return __glXBadContext;
+ }
+ dst = (__GLXcontext *) LookupIDByType(dest, __glXContextRes);
+ if (!dst) {
+ client->errorValue = dest;
+ return __glXBadContext;
+ }
+
+ /*
+ ** They must be in the same address space, and same screen.
+ */
+ if (src->pGlxScreen != dst->pGlxScreen) {
+ client->errorValue = source;
+ return BadMatch;
+ }
+
+ /*
+ ** The destination context must not be current for any client.
+ */
+ if (dst->isCurrent) {
+ client->errorValue = dest;
+ return BadAccess;
+ }
+
+ if (tag) {
+ __GLXcontext *tagcx = __glXLookupContextByTag(cl, tag);
+
+ if (!tagcx) {
+ return __glXBadContextTag;
+ }
+ if (tagcx != src) {
+ /*
+ ** This would be caused by a faulty implementation of the client
+ ** library.
+ */
+ return BadMatch;
+ }
+ }
+
+ from_screen = to_screen = src->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReq(GLXCopyContext,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXCopyContext;
+ be_req->source = (unsigned int)src->real_ids[s-from_screen];
+ be_req->dest = (unsigned int)dst->real_ids[s-from_screen];
+ be_req->mask = mask;
+ be_req->contextTag = (tag ? GetCurrentBackEndTag(cl,req->contextTag,s) : 0);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+ return Success;
+}
+
+int __glXGetVisualConfigs(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
+ xGLXGetVisualConfigsReply reply;
+ __GLXscreenInfo *pGlxScreen;
+ __GLXvisualConfig *pGlxVisual;
+ CARD32 buf[__GLX_TOTAL_CONFIG];
+ unsigned int screen;
+ int i, p;
+
+ screen = req->screen;
+ if (screen > screenInfo.numScreens) {
+ /* The client library must send a valid screen number. */
+ client->errorValue = screen;
+ return BadValue;
+ }
+ pGlxScreen = &__glXActiveScreens[screen];
+
+ reply.numVisuals = pGlxScreen->numGLXVisuals;
+ reply.numProps = __GLX_TOTAL_CONFIG;
+ reply.length = (pGlxScreen->numGLXVisuals * __GLX_SIZE_CARD32 *
+ __GLX_TOTAL_CONFIG) >> 2;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char *)&reply);
+
+ for (i=0; i < pGlxScreen->numVisuals; i++) {
+ pGlxVisual = &pGlxScreen->pGlxVisual[i];
+ if (!pGlxScreen->isGLXvis[i] || pGlxVisual->vid == 0) {
+ /* not a usable visual */
+ continue;
+ }
+ p = 0;
+ buf[p++] = pGlxVisual->vid;
+ buf[p++] = pGlxVisual->class;
+ buf[p++] = pGlxVisual->rgba;
+
+ buf[p++] = pGlxVisual->redSize;
+ buf[p++] = pGlxVisual->greenSize;
+ buf[p++] = pGlxVisual->blueSize;
+ buf[p++] = pGlxVisual->alphaSize;
+ buf[p++] = pGlxVisual->accumRedSize;
+ buf[p++] = pGlxVisual->accumGreenSize;
+ buf[p++] = pGlxVisual->accumBlueSize;
+ buf[p++] = pGlxVisual->accumAlphaSize;
+
+ buf[p++] = pGlxVisual->doubleBuffer;
+ buf[p++] = pGlxVisual->stereo;
+
+ buf[p++] = pGlxVisual->bufferSize;
+ buf[p++] = pGlxVisual->depthSize;
+ buf[p++] = pGlxVisual->stencilSize;
+ buf[p++] = pGlxVisual->auxBuffers;
+ buf[p++] = pGlxVisual->level;
+ /*
+ ** Add token/value pairs for extensions.
+ */
+ buf[p++] = GLX_VISUAL_CAVEAT_EXT;
+ buf[p++] = pGlxVisual->visualRating;
+ buf[p++] = GLX_TRANSPARENT_TYPE_EXT;
+ buf[p++] = pGlxVisual->transparentPixel;
+ buf[p++] = GLX_TRANSPARENT_RED_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentRed;
+ buf[p++] = GLX_TRANSPARENT_GREEN_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentGreen;
+ buf[p++] = GLX_TRANSPARENT_BLUE_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentBlue;
+ buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentAlpha;
+ buf[p++] = GLX_TRANSPARENT_INDEX_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentIndex;
+ buf[p++] = GLX_SAMPLES_SGIS;
+ buf[p++] = pGlxVisual->multiSampleSize;
+ buf[p++] = GLX_SAMPLE_BUFFERS_SGIS;
+ buf[p++] = pGlxVisual->nMultiSampleBuffers;
+ buf[p++] = GLX_VISUAL_SELECT_GROUP_SGIX;
+ buf[p++] = pGlxVisual->visualSelectGroup;
+
+ WriteToClient(client, __GLX_SIZE_CARD32 * __GLX_TOTAL_CONFIG,
+ (char *)buf);
+ }
+ return Success;
+}
+
+/*
+** Create a GLX Pixmap from an X Pixmap.
+*/
+static int CreateGLXPixmap(__GLXclientState *cl,
+ VisualID visual, GLXFBConfigID fbconfigId,
+ int screenNum, XID pixmapId, XID glxpixmapId )
+{
+ ClientPtr client = cl->client;
+ xGLXCreateGLXPixmapReq *be_req;
+ xGLXCreatePixmapReq *be_new_req;
+ DrawablePtr pDraw;
+ ScreenPtr pScreen;
+ VisualPtr pVisual;
+ __GLXpixmap *pGlxPixmap;
+ __GLXscreenInfo *pGlxScreen;
+ __GLXvisualConfig *pGlxVisual;
+ __GLXFBConfig *pFBConfig;
+ int i;
+ int s;
+ int from_screen, to_screen;
+#ifdef PANORAMIX
+ PanoramiXRes *pXinDraw = NULL;
+#endif
+
+ pDraw = (DrawablePtr) LookupDrawable(pixmapId, client);
+ if (!pDraw || pDraw->type != DRAWABLE_PIXMAP) {
+ client->errorValue = pixmapId;
+ return BadPixmap;
+ }
+
+ /*
+ ** Check if screen of visual matches screen of pixmap.
+ */
+ pScreen = pDraw->pScreen;
+ if (screenNum != pScreen->myNum) {
+ return BadMatch;
+ }
+
+ if (fbconfigId == NULL && visual == NULL) {
+ return BadValue;
+ }
+
+ if (fbconfigId != None) {
+ pFBConfig = glxLookupFBConfig( fbconfigId );
+ if (!pFBConfig) {
+ client->errorValue = fbconfigId;
+ return BadValue;
+ }
+ visual = pFBConfig->associatedVisualId;
+ }
+ else {
+ pFBConfig = NULL;
+ }
+
+ if (visual != None) {
+ /*
+ ** Find the VisualRec for this visual.
+ */
+ pVisual = pScreen->visuals;
+ for (i=0; i < pScreen->numVisuals; i++, pVisual++) {
+ if (pVisual->vid == visual) {
+ break;
+ }
+ }
+ if (i == pScreen->numVisuals) {
+ client->errorValue = visual;
+ return BadValue;
+ }
+ /*
+ ** Check if depth of visual matches depth of pixmap.
+ */
+ if (pVisual->nplanes != pDraw->depth) {
+ client->errorValue = visual;
+ return BadMatch;
+ }
+
+ /*
+ ** Get configuration of the visual.
+ */
+ pGlxScreen = &__glXActiveScreens[screenNum];
+ pGlxVisual = pGlxScreen->pGlxVisual;
+ for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) {
+ if (pGlxVisual->vid == visual) {
+ break;
+ }
+ }
+ if (i == pGlxScreen->numVisuals) {
+ /*
+ ** Visual not support on this screen by this OpenGL implementation.
+ */
+ client->errorValue = visual;
+ return BadValue;
+ }
+
+
+ /* find the FBConfig for that visual (if any) */
+ if ( pFBConfig == NULL ) {
+ pFBConfig = glxLookupFBConfigByVID( visual );
+
+ if ( pFBConfig == NULL ) {
+ /*
+ * visual does not have an FBConfig ???
+ client->errorValue = visual;
+ return BadValue;
+ */
+ }
+ }
+ }
+ else {
+ pVisual = NULL;
+ pGlxVisual = NULL;
+ }
+
+ pGlxPixmap = (__GLXpixmap *) __glXMalloc(sizeof(__GLXpixmap));
+ if (!pGlxPixmap) {
+ return BadAlloc;
+ }
+ pGlxPixmap->be_xids = (XID *) __glXMalloc(sizeof(XID) * screenInfo.numScreens);
+ if (!pGlxPixmap->be_xids) {
+ __glXFree( pGlxPixmap );
+ return BadAlloc;
+ }
+
+ pGlxPixmap->pDraw = pDraw;
+ pGlxPixmap->pGlxScreen = pGlxScreen;
+ pGlxPixmap->pGlxVisual = pGlxVisual;
+ pGlxPixmap->pFBConfig = pFBConfig;
+ pGlxPixmap->pScreen = pScreen;
+ pGlxPixmap->idExists = True;
+ pGlxPixmap->refcnt = 0;
+
+ /*
+ ** Bump the ref count on the X pixmap so it won't disappear.
+ */
+ ((PixmapPtr) pDraw)->refcnt++;
+
+ /*
+ * send the request to the back-end server(s)
+ */
+ from_screen = to_screen = screenNum;
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+
+ pXinDraw = (PanoramiXRes *)
+ SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, SecurityReadAccess);
+ }
+#endif
+
+ for (s=from_screen; s<=to_screen; s++) {
+
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+ Pixmap be_pixmap;
+ DrawablePtr pRealDraw = pDraw;
+
+#ifdef PANORAMIX
+ if (pXinDraw) {
+ pRealDraw = (DrawablePtr) LookupDrawable(pXinDraw->info[s].id,client);
+ }
+#endif
+
+ be_pixmap = (DMX_GET_PIXMAP_PRIV((PixmapPtr)pRealDraw))->pixmap;
+
+ /* make sure pixmap already created on back-end */
+ dmxSync( dmxScreen, 1 );
+
+ if ( pFBConfig && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ __GLXFBConfig *be_FBConfig = glxLookupBackEndFBConfig( pFBConfig->id, s );
+
+ LockDisplay(dpy);
+ pGlxPixmap->be_xids[s] = XAllocID(dpy);
+ GetReq(GLXCreatePixmap,be_new_req);
+ be_new_req->reqType = dmxScreen->glxMajorOpcode;
+ be_new_req->glxCode = X_GLXCreatePixmap;
+ be_new_req->screen = DefaultScreen(dpy);
+ be_new_req->fbconfig = be_FBConfig->id;
+ be_new_req->pixmap = (unsigned int)be_pixmap;
+ be_new_req->glxpixmap = (unsigned int)pGlxPixmap->be_xids[s];
+ be_new_req->numAttribs = 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+ else if (pFBConfig && glxIsExtensionSupported("GLX_SGIX_fbconfig")) {
+ __GLXFBConfig *be_FBConfig = glxLookupBackEndFBConfig( pFBConfig->id, s );
+ xGLXCreateGLXPixmapWithConfigSGIXReq *ext_req;
+ xGLXVendorPrivateReq *vpreq;
+
+ LockDisplay(dpy);
+ pGlxPixmap->be_xids[s] = XAllocID(dpy);
+ GetReqExtra(GLXVendorPrivate,
+ sz_xGLXCreateGLXPixmapWithConfigSGIXReq-sz_xGLXVendorPrivateReq,
+ vpreq);
+ ext_req = (xGLXCreateGLXPixmapWithConfigSGIXReq *)vpreq;
+ ext_req->reqType = dmxScreen->glxMajorOpcode;
+ ext_req->glxCode = X_GLXVendorPrivate;
+ ext_req->vendorCode = X_GLXvop_CreateGLXPixmapWithConfigSGIX;
+ ext_req->screen = DefaultScreen(dpy);
+ ext_req->fbconfig = be_FBConfig->id;
+ ext_req->pixmap = (unsigned int)be_pixmap;
+ ext_req->glxpixmap = (unsigned int)pGlxPixmap->be_xids[s];
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+ else if (pGlxVisual) {
+ LockDisplay(dpy);
+ pGlxPixmap->be_xids[s] = XAllocID(dpy);
+ GetReq(GLXCreateGLXPixmap,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXCreateGLXPixmap;
+ be_req->screen = DefaultScreen(dpy);
+ be_req->visual = (unsigned int)glxMatchGLXVisualInConfigList(
+ pGlxVisual,
+ dmxScreen->glxVisuals,
+ dmxScreen->numGlxVisuals );
+ be_req->pixmap = (unsigned int)be_pixmap;
+ be_req->glxpixmap = (unsigned int)pGlxPixmap->be_xids[s];
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+ else {
+ client->errorValue = ( visual ? visual : fbconfigId );
+ __glXFree( pGlxPixmap );
+ return BadValue;
+ }
+
+ XFlush( dpy );
+ }
+
+ if (!(AddResource(glxpixmapId, __glXPixmapRes, pGlxPixmap))) {
+ __glXFree( pGlxPixmap );
+ return BadAlloc;
+ }
+
+ return Success;
+}
+
+int __glXCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
+
+ return( CreateGLXPixmap(cl, req->visual, None,
+ req->screen, req->pixmap, req->glxpixmap) );
+}
+
+int __glXCreatePixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
+
+ return( CreateGLXPixmap(cl, None, req->fbconfig,
+ req->screen, req->pixmap, req->glxpixmap) );
+}
+
+int __glXDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
+ XID glxpixmap = req->glxpixmap;
+ __GLXpixmap *pGlxPixmap;
+ int s;
+ int from_screen, to_screen;
+
+ /*
+ ** Check if it's a valid GLX pixmap.
+ */
+ pGlxPixmap = (__GLXpixmap *)LookupIDByType(glxpixmap, __glXPixmapRes);
+ if (!pGlxPixmap) {
+ client->errorValue = glxpixmap;
+ return __glXBadPixmap;
+ }
+ FreeResource(glxpixmap, FALSE);
+
+ /*
+ * destroy the pixmap on the back-end server(s).
+ */
+ from_screen = to_screen = pGlxPixmap->pDraw->pScreen->myNum;
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ /* make sure pixmap exist in back-end */
+ dmxSync( dmxScreen, 1 );
+
+ LockDisplay(dpy);
+ GetReq(GLXDestroyGLXPixmap,req);
+ req->reqType = dmxScreen->glxMajorOpcode;
+ req->glxCode = X_GLXDestroyGLXPixmap;
+ req->glxpixmap = (unsigned int)pGlxPixmap->be_xids[s];
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+
+ return Success;
+}
+
+/*****************************************************************************/
+
+/*
+** NOTE: There is no portable implementation for swap buffers as of
+** this time that is of value. Consequently, this code must be
+** implemented by somebody other than SGI.
+*/
+int __glXDoSwapBuffers(__GLXclientState *cl, XID drawId, GLXContextTag tag)
+{
+ ClientPtr client = cl->client;
+ DrawablePtr pDraw;
+ xGLXSwapBuffersReq *be_req;
+ WindowPtr pWin = NULL;
+ __GLXpixmap *pGlxPixmap = NULL;
+ __GLXcontext *glxc = NULL;
+#ifdef PANORAMIX
+ PanoramiXRes *pXinDraw = NULL;
+#endif
+ __glXWindow *pGlxWindow = NULL;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+
+ /*
+ ** Check that the GLX drawable is valid.
+ */
+ pDraw = (DrawablePtr) LookupDrawable(drawId, client);
+ if (pDraw) {
+
+ from_screen = to_screen = pDraw->pScreen->myNum;
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ /*
+ ** Drawable is an X window.
+ */
+ pWin = (WindowPtr)pDraw;
+ } else {
+ /*
+ ** Drawable is an X pixmap, which is not allowed.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ }
+
+ if (!pDraw) {
+ pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId,
+ __glXPixmapRes);
+ if (pGlxPixmap) {
+ /*
+ ** Drawable is a GLX pixmap.
+ */
+ pDraw = pGlxPixmap->pDraw;
+ from_screen = to_screen = pGlxPixmap->pScreen->myNum;
+ }
+ }
+
+ if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ pGlxWindow = (__glXWindow *) LookupIDByType(drawId, __glXWindowRes);
+ if (pGlxWindow) {
+ /*
+ ** Drawable is a GLXWindow.
+ */
+ pDraw = pGlxWindow->pDraw;
+ from_screen = to_screen = pGlxWindow->pScreen->myNum;
+ }
+ }
+
+ if (!pDraw) {
+ /*
+ ** Drawable is neither a X window nor a GLX pixmap.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+
+ if (tag) {
+ glxc = __glXLookupContextByTag(cl, tag);
+ if (!glxc) {
+ return __glXBadContextTag;
+ }
+ }
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ pXinDraw = (PanoramiXRes *)
+ SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, SecurityReadAccess);
+ }
+#endif
+
+ /* If requested, send a glFinish to all back-end servers before swapping. */
+ if (dmxGLXFinishSwap) {
+ for (s=from_screen; s<=to_screen; s++) {
+ Display *dpy = GetBackEndDisplay(cl,s);
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ xGLXSingleReq *finishReq;
+ xGLXSingleReply reply;
+
+#define X_GLXSingle 0 /* needed by GetReq below */
+
+ LockDisplay(dpy);
+ GetReq(GLXSingle,finishReq);
+ finishReq->reqType = dmxScreen->glxMajorOpcode;
+ finishReq->glxCode = X_GLsop_Finish;
+ finishReq->contextTag = (tag ? GetCurrentBackEndTag(cl,tag,s) : 0);
+ (void) _XReply(dpy, (xReply*) &reply, 0, False);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+ }
+
+ /* If requested, send an XSync to all back-end servers before swapping. */
+ if (dmxGLXSyncSwap) {
+ for (s=from_screen; s<=to_screen; s++)
+ XSync(GetBackEndDisplay(cl,s), False);
+ }
+
+
+ /* send the SwapBuffers request to all back-end servers */
+
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+ unsigned int be_draw = 0;
+
+ if (pGlxPixmap) {
+ be_draw = (unsigned int)pGlxPixmap->be_xids[s];
+ }
+#ifdef PANORAMIX
+ else if (pXinDraw) {
+ pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[s].id,
+ client,
+ SecurityReadAccess);
+ }
+#endif
+ else if (pGlxWindow) {
+ pWin = (WindowPtr)pGlxWindow->pDraw;
+ }
+
+ if (pWin && !be_draw) {
+ be_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
+ if (!be_draw) {
+ /* it might be that the window did not created yet on the */
+ /* back-end server (lazy window creation option), force */
+ /* creation of the window */
+ dmxCreateAndRealizeWindow( pWin, TRUE );
+ be_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
+ }
+ }
+
+ dmxSync( dmxScreen, 1 );
+
+ LockDisplay(dpy);
+ GetReq(GLXSwapBuffers,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXSwapBuffers;
+ be_req->drawable = be_draw;
+ be_req->contextTag = ( tag ? GetCurrentBackEndTag(cl,tag,s) : 0 );
+ UnlockDisplay(dpy);
+ SyncHandle();
+ XFlush(dpy);
+ }
+
+ return Success;
+}
+
+int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ DrawablePtr pDraw;
+ xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc;
+ GLXContextTag tag = req->contextTag;
+ XID drawId = req->drawable;
+ __GLXpixmap *pGlxPixmap = NULL;
+ __GLXcontext *glxc = NULL;
+ __glXWindow *pGlxWindow = NULL;
+
+ /*
+ ** Check that the GLX drawable is valid.
+ */
+ pDraw = (DrawablePtr) LookupDrawable(drawId, client);
+ if (pDraw) {
+ if (pDraw->type != DRAWABLE_WINDOW) {
+ /*
+ ** Drawable is an X pixmap, which is not allowed.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ }
+
+ if (!pDraw) {
+ pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId,
+ __glXPixmapRes);
+ if (pGlxPixmap) {
+ /*
+ ** Drawable is a GLX pixmap.
+ */
+ pDraw = pGlxPixmap->pDraw;
+ }
+ }
+
+ if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ pGlxWindow = (__glXWindow *) LookupIDByType(drawId, __glXWindowRes);
+ if (pGlxWindow) {
+ /*
+ ** Drawable is a GLXWindow.
+ */
+ pDraw = pGlxWindow->pDraw;
+ }
+ }
+
+ if (!pDraw) {
+ /*
+ ** Drawable is neither a X window nor a GLX pixmap.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+
+ if (tag) {
+ glxc = __glXLookupContextByTag(cl, tag);
+ if (!glxc) {
+ return __glXBadContextTag;
+ }
+ }
+
+ if (pDraw &&
+ pDraw->type == DRAWABLE_WINDOW &&
+ DMX_GET_WINDOW_PRIV((WindowPtr)pDraw)->swapGroup) {
+ return SGSwapBuffers(cl, drawId, tag, pDraw);
+ }
+
+ return __glXDoSwapBuffers(cl, drawId, tag);
+}
+
+
+/************************************************************************/
+
+/*
+** Render and Renderlarge are not in the GLX API. They are used by the GLX
+** client library to send batches of GL rendering commands.
+*/
+
+/*
+** Execute all the drawing commands in a request.
+*/
+int __glXRender(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXRenderReq *req;
+ xGLXRenderReq *be_req;
+ int size;
+ __GLXcontext *glxc;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+
+ /*
+ ** NOTE: much of this code also appears in the byteswapping version of this
+ ** routine, __glXSwapRender(). Any changes made here should also be
+ ** duplicated there.
+ */
+
+ req = (xGLXRenderReq *) pc;
+
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return 0;
+ }
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ pc += sz_xGLXRenderReq;
+ size = (req->length << 2) - sz_xGLXRenderReq;
+
+ /*
+ * just forward the request to back-end server(s)
+ */
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReq(GLXRender,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXRender;
+ be_req->length = req->length;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
+ _XSend(dpy, (const char *)pc, size);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+ return Success;
+}
+
+/*
+** Execute a large rendering request (one that spans multiple X requests).
+*/
+int __glXRenderLarge(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXRenderLargeReq *req;
+ xGLXRenderLargeReq *be_req;
+ __GLXcontext *glxc;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+
+ /*
+ ** NOTE: much of this code also appears in the byteswapping version of this
+ ** routine, __glXSwapRenderLarge(). Any changes made here should also be
+ ** duplicated there.
+ */
+
+ req = (xGLXRenderLargeReq *) pc;
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return 0;
+ }
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ pc += sz_xGLXRenderLargeReq;
+
+ /*
+ * just forward the request to back-end server(s)
+ */
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ GetReq(GLXRenderLarge,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXRenderLarge;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
+ be_req->length = req->length;
+ be_req->requestNumber = req->requestNumber;
+ be_req->requestTotal = req->requestTotal;
+ be_req->dataBytes = req->dataBytes;
+ Data(dpy, (const char *)pc, req->dataBytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ }
+
+ return Success;
+}
+
+
+/************************************************************************/
+
+int __glXVendorPrivate(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateReq *req;
+
+ req = (xGLXVendorPrivateReq *) pc;
+
+ switch( req->vendorCode ) {
+
+ case X_GLvop_DeleteTexturesEXT:
+ return __glXVForwardSingleReq( cl, pc );
+ break;
+
+ case X_GLXvop_SwapIntervalSGI:
+ if (glxIsExtensionSupported("SGI_swap_control")) {
+ return __glXVForwardSingleReq( cl, pc );
+ }
+ else {
+ return Success;
+ }
+ break;
+
+#if 0 /* glx 1.3 */
+ case X_GLXvop_CreateGLXVideoSourceSGIX:
+ break;
+ case X_GLXvop_DestroyGLXVideoSourceSGIX:
+ break;
+ case X_GLXvop_CreateGLXPixmapWithConfigSGIX:
+ break;
+ case X_GLXvop_DestroyGLXPbufferSGIX:
+ break;
+ case X_GLXvop_ChangeDrawableAttributesSGIX:
+ break;
+#endif
+
+ case X_GLXvop_BindSwapBarrierSGIX:
+ return __glXBindSwapBarrierSGIX( cl, pc );
+ break;
+
+ case X_GLXvop_JoinSwapGroupSGIX:
+ return __glXJoinSwapGroupSGIX( cl, pc );
+ break;
+
+ case X_GLXvop_CreateContextWithConfigSGIX:
+ return __glXCreateContextWithConfigSGIX( cl, pc );
+ break;
+
+ default:
+ /*
+ ** unsupported private request
+ */
+ cl->client->errorValue = req->vendorCode;
+ return __glXUnsupportedPrivateRequest;
+ }
+
+ cl->client->errorValue = req->vendorCode;
+ return __glXUnsupportedPrivateRequest;
+
+}
+
+int __glXVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateWithReplyReq *req;
+
+ req = (xGLXVendorPrivateWithReplyReq *) pc;
+
+ switch( req->vendorCode ) {
+
+ case X_GLvop_GetConvolutionFilterEXT:
+ case X_GLvop_GetConvolutionParameterfvEXT:
+ case X_GLvop_GetConvolutionParameterivEXT:
+ case X_GLvop_GetSeparableFilterEXT:
+ case X_GLvop_GetHistogramEXT:
+ case X_GLvop_GetHistogramParameterivEXT:
+ case X_GLvop_GetMinmaxEXT:
+ case X_GLvop_GetMinmaxParameterfvEXT:
+ case X_GLvop_GetMinmaxParameterivEXT:
+ case X_GLvop_AreTexturesResidentEXT:
+ case X_GLvop_IsTextureEXT:
+ return( __glXVForwardPipe0WithReply(cl, pc) );
+ break;
+
+ case X_GLvop_GenTexturesEXT:
+ return( __glXVForwardAllWithReply(cl, pc) );
+ break;
+
+
+#if 0 /* glx1.3 */
+ case X_GLvop_GetDetailTexFuncSGIS:
+ case X_GLvop_GetSharpenTexFuncSGIS:
+ case X_GLvop_GetColorTableSGI:
+ case X_GLvop_GetColorTableParameterfvSGI:
+ case X_GLvop_GetColorTableParameterivSGI:
+ case X_GLvop_GetTexFilterFuncSGIS:
+ case X_GLvop_GetInstrumentsSGIX:
+ case X_GLvop_InstrumentsBufferSGIX:
+ case X_GLvop_PollInstrumentsSGIX:
+ case X_GLvop_FlushRasterSGIX:
+ case X_GLXvop_CreateGLXPbufferSGIX:
+ case X_GLXvop_GetDrawableAttributesSGIX:
+ case X_GLXvop_QueryHyperpipeNetworkSGIX:
+ case X_GLXvop_QueryHyperpipeConfigSGIX:
+ case X_GLXvop_HyperpipeConfigSGIX:
+ case X_GLXvop_DestroyHyperpipeConfigSGIX:
+#endif
+ case X_GLXvop_QueryMaxSwapBarriersSGIX:
+ return( __glXQueryMaxSwapBarriersSGIX(cl, pc) );
+ break;
+
+ case X_GLXvop_GetFBConfigsSGIX:
+ return( __glXGetFBConfigsSGIX(cl, pc) );
+ break;
+
+ case X_GLXvop_MakeCurrentReadSGI:
+ return( __glXMakeCurrentReadSGI(cl, pc) );
+ break;
+
+ case X_GLXvop_QueryContextInfoEXT:
+ return( __glXQueryContextInfoEXT(cl,pc) );
+ break;
+
+ default:
+ /*
+ ** unsupported private request
+ */
+ cl->client->errorValue = req->vendorCode;
+ return __glXUnsupportedPrivateRequest;
+ }
+
+}
+
+int __glXQueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *) pc;
+ xGLXQueryExtensionsStringReply reply;
+ GLint screen;
+ size_t length;
+ int len, numbytes;
+ char *be_buf;
+
+#ifdef FWD_QUERY_REQ
+ xGLXQueryExtensionsStringReq *be_req;
+ xGLXQueryExtensionsStringReply be_reply;
+ DMXScreenInfo *dmxScreen;
+ Display *dpy;
+ int slop;
+#endif
+
+ screen = req->screen;
+
+ /*
+ ** Check if screen exists.
+ */
+ if ((screen < 0) || (screen >= screenInfo.numScreens)) {
+ client->errorValue = screen;
+ return BadValue;
+ }
+
+#ifdef FWD_QUERY_REQ
+ dmxScreen = &dmxScreens[screen];
+
+ /* Send the glXQueryServerString request */
+ dpy = GetBackEndDisplay(cl,screen);
+ LockDisplay(dpy);
+ GetReq(GLXQueryExtensionsString,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXQueryServerString;
+ be_req->screen = DefaultScreen(dpy);
+ _XReply(dpy, (xReply*) &be_reply, 0, False);
+ len = (int)be_reply.length;
+ numbytes = (int)be_reply.n;
+ slop = numbytes * __GLX_SIZE_INT8 & 3;
+ be_buf = (char *)Xalloc(numbytes);
+ if (!be_buf) {
+ /* Throw data on the floor */
+ _XEatData(dpy, len);
+ } else {
+ _XRead(dpy, (char *)be_buf, numbytes);
+ if (slop) _XEatData(dpy,4-slop);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+#else
+
+ be_buf = __glXGetServerString(GLX_EXTENSIONS);
+ numbytes = strlen(be_buf) + 1;
+ len = __GLX_PAD(numbytes) >> 2;
+
+#endif
+
+ length = len;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = len;
+ reply.n = numbytes;
+
+ if (client->swapped) {
+ glxSwapQueryExtensionsStringReply(client, &reply, be_buf);
+ } else {
+ WriteToClient(client, sz_xGLXQueryExtensionsStringReply,(char *)&reply);
+ WriteToClient(client, (int)(length << 2), (char *)be_buf);
+ }
+
+ return Success;
+}
+
+int __glXQueryServerString(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) pc;
+ xGLXQueryServerStringReply reply;
+ int name;
+ GLint screen;
+ size_t length;
+ int len, numbytes;
+ char *be_buf;
+#ifdef FWD_QUERY_REQ
+ xGLXQueryServerStringReq *be_req;
+ xGLXQueryServerStringReply be_reply;
+ DMXScreenInfo *dmxScreen;
+ Display *dpy;
+ int slop;
+#endif
+
+ name = req->name;
+ screen = req->screen;
+ /*
+ ** Check if screen exists.
+ */
+ if ((screen < 0) || (screen >= screenInfo.numScreens)) {
+ client->errorValue = screen;
+ return BadValue;
+ }
+
+#ifdef FWD_QUERY_REQ
+ dmxScreen = &dmxScreens[screen];
+
+ /* Send the glXQueryServerString request */
+ dpy = GetBackEndDisplay(cl,screen);
+ LockDisplay(dpy);
+ GetReq(GLXQueryServerString,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXQueryServerString;
+ be_req->screen = DefaultScreen(dpy);
+ be_req->name = name;
+ _XReply(dpy, (xReply*) &be_reply, 0, False);
+ len = (int)be_reply.length;
+ numbytes = (int)be_reply.n;
+ slop = numbytes * __GLX_SIZE_INT8 & 3;
+ be_buf = (char *)Xalloc(numbytes);
+ if (!be_buf) {
+ /* Throw data on the floor */
+ _XEatData(dpy, len);
+ } else {
+ _XRead(dpy, (char *)be_buf, numbytes);
+ if (slop) _XEatData(dpy,4-slop);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+#else
+ be_buf = __glXGetServerString(name);
+ numbytes = strlen(be_buf) + 1;
+ len = __GLX_PAD(numbytes) >> 2;
+#endif
+
+ length = len;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = length;
+ reply.n = numbytes;
+
+ if (client->swapped) {
+ glxSwapQueryServerStringReply(client, &reply, be_buf);
+ } else {
+ WriteToClient(client, sz_xGLXQueryServerStringReply, (char *)&reply);
+ WriteToClient(client, (int)(length << 2), be_buf);
+ }
+
+ return Success;
+}
+
+int __glXClientInfo(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXClientInfoReq *req = (xGLXClientInfoReq *) pc;
+ xGLXClientInfoReq *be_req;
+ const char *buf;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+
+ cl->GLClientmajorVersion = req->major;
+ cl->GLClientminorVersion = req->minor;
+ if (cl->GLClientextensions) __glXFree(cl->GLClientextensions);
+ buf = (const char *)(req+1);
+ cl->GLClientextensions = __glXStrdup(buf);
+
+ to_screen = screenInfo.numScreens - 1;
+
+ for (s=from_screen; s<=to_screen; s++)
+ {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReq(GLXClientInfo,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXClientInfo;
+ be_req->major = req->major;
+ be_req->minor = req->minor;
+ be_req->length = req->length;
+ be_req->numbytes = req->numbytes;
+ Data(dpy, buf, req->numbytes);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+ return Success;
+}
+
+int __glXUseXFont(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXUseXFontReq *req;
+ xGLXUseXFontReq *be_req;
+ FontPtr pFont;
+ __GLXcontext *glxc = NULL;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+ dmxFontPrivPtr pFontPriv;
+ DMXScreenInfo *dmxScreen;
+ Display *dpy;
+
+ req = (xGLXUseXFontReq *) pc;
+
+ if (req->contextTag != 0) {
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (glxc) {
+ from_screen = to_screen = glxc->pScreen->myNum;
+ }
+ }
+
+ /*
+ ** Font can actually be either the ID of a font or the ID of a GC
+ ** containing a font.
+ */
+ pFont = (FontPtr)LookupIDByType(req->font, RT_FONT);
+ if (!pFont) {
+ GC *pGC = (GC *)LookupIDByType(req->font, RT_GC);
+ if (!pGC) {
+ client->errorValue = req->font;
+ return BadFont;
+ }
+ pFont = pGC->font;
+ }
+
+ pFontPriv = FontGetPrivate(pFont, dmxFontPrivateIndex);
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+
+ for (s=from_screen; s<=to_screen; s++) {
+ dmxScreen = &dmxScreens[s];
+ dpy = GetBackEndDisplay(cl,s);
+
+ dmxSync( dmxScreen, 1 );
+
+ LockDisplay(dpy);
+ GetReq(GLXUseXFont,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXUseXFont;
+ be_req->contextTag = (glxc ? GetCurrentBackEndTag(cl,req->contextTag,s) : 0);
+ be_req->font = pFontPriv->font[s]->fid;
+ be_req->first = req->first;
+ be_req->count = req->count;
+ be_req->listBase = req->listBase;
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ XSync( dpy, False );
+ }
+
+ return Success;
+}
+
+/*
+ * start GLX 1.3 here
+ */
+
+int __glXGetFBConfigs(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
+ xGLXGetFBConfigsReply reply;
+ __GLXFBConfig *pFBConfig;
+ CARD32 buf[2 * __GLX_TOTAL_FBCONFIG_PROPS];
+ int numAttribs = __GLX_TOTAL_FBCONFIG_PROPS;
+ unsigned int screen = req->screen;
+ int numFBConfigs, i, p;
+ __GLXscreenInfo *pGlxScreen;
+
+ if (screen > screenInfo.numScreens) {
+ /* The client library must send a valid screen number. */
+ client->errorValue = screen;
+ return BadValue;
+ }
+
+ pGlxScreen = &__glXActiveScreens[screen];
+ numFBConfigs = __glXNumFBConfigs;
+
+ reply.numFBConfigs = numFBConfigs;
+ reply.numAttribs = numAttribs;
+ reply.length = (numFBConfigs * 2 * numAttribs * __GLX_SIZE_CARD32) >> 2;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (client->swapped) {
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.numFBConfigs);
+ __GLX_SWAP_INT(&reply.numAttribs);
+ }
+ WriteToClient(client, sz_xGLXGetFBConfigsReply, (char *)&reply);
+
+ for (i=0; i < numFBConfigs; i++) {
+ int associatedVisualId = 0;
+ int drawableTypeIndex;
+ pFBConfig = __glXFBConfigs[ i * (screenInfo.numScreens+1) ];
+
+ p = 0;
+ /* core attributes */
+ buf[p++] = GLX_FBCONFIG_ID;
+ buf[p++] = pFBConfig->id;
+ buf[p++] = GLX_BUFFER_SIZE;
+ buf[p++] = pFBConfig->indexBits;
+ buf[p++] = GLX_LEVEL;
+ buf[p++] = pFBConfig->level;
+ buf[p++] = GLX_DOUBLEBUFFER;
+ buf[p++] = pFBConfig->doubleBufferMode;
+ buf[p++] = GLX_STEREO;
+ buf[p++] = pFBConfig->stereoMode;
+ buf[p++] = GLX_AUX_BUFFERS;
+ buf[p++] = pFBConfig->maxAuxBuffers;
+ buf[p++] = GLX_RED_SIZE;
+ buf[p++] = pFBConfig->redBits;
+ buf[p++] = GLX_GREEN_SIZE;
+ buf[p++] = pFBConfig->greenBits;
+ buf[p++] = GLX_BLUE_SIZE;
+ buf[p++] = pFBConfig->blueBits;
+ buf[p++] = GLX_ALPHA_SIZE;
+ buf[p++] = pFBConfig->alphaBits;
+ buf[p++] = GLX_DEPTH_SIZE;
+ buf[p++] = pFBConfig->depthBits;
+ buf[p++] = GLX_STENCIL_SIZE;
+ buf[p++] = pFBConfig->stencilBits;
+ buf[p++] = GLX_ACCUM_RED_SIZE;
+ buf[p++] = pFBConfig->accumRedBits;
+ buf[p++] = GLX_ACCUM_GREEN_SIZE;
+ buf[p++] = pFBConfig->accumGreenBits;
+ buf[p++] = GLX_ACCUM_BLUE_SIZE;
+ buf[p++] = pFBConfig->accumBlueBits;
+ buf[p++] = GLX_ACCUM_ALPHA_SIZE;
+ buf[p++] = pFBConfig->accumAlphaBits;
+ buf[p++] = GLX_RENDER_TYPE;
+ buf[p++] = pFBConfig->renderType;
+ buf[p++] = GLX_DRAWABLE_TYPE;
+ drawableTypeIndex = p;
+ buf[p++] = pFBConfig->drawableType;
+ buf[p++] = GLX_X_VISUAL_TYPE;
+ buf[p++] = pFBConfig->visualType;
+ buf[p++] = GLX_CONFIG_CAVEAT;
+ buf[p++] = pFBConfig->visualCaveat;
+ buf[p++] = GLX_TRANSPARENT_TYPE;
+ buf[p++] = pFBConfig->transparentType;
+ buf[p++] = GLX_TRANSPARENT_RED_VALUE;
+ buf[p++] = pFBConfig->transparentRed;
+ buf[p++] = GLX_TRANSPARENT_GREEN_VALUE;
+ buf[p++] = pFBConfig->transparentGreen;
+ buf[p++] = GLX_TRANSPARENT_BLUE_VALUE;
+ buf[p++] = pFBConfig->transparentBlue;
+ buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE;
+ buf[p++] = pFBConfig->transparentAlpha;
+ buf[p++] = GLX_TRANSPARENT_INDEX_VALUE;
+ buf[p++] = pFBConfig->transparentIndex;
+ buf[p++] = GLX_MAX_PBUFFER_WIDTH;
+ buf[p++] = pFBConfig->maxPbufferWidth;
+ buf[p++] = GLX_MAX_PBUFFER_HEIGHT;
+ buf[p++] = pFBConfig->maxPbufferHeight;
+ buf[p++] = GLX_MAX_PBUFFER_PIXELS;
+ buf[p++] = pFBConfig->maxPbufferPixels;
+
+ /*
+ * find the visual of the back-end server and match a visual
+ * on the proxy.
+ * do only once - if a visual is not yet associated.
+ */
+ if (pFBConfig->associatedVisualId == (unsigned int)-1) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[screen];
+ __GLXFBConfig *be_pFBConfig = __glXFBConfigs[ i * (screenInfo.numScreens+1)+screen+1 ];
+ __GLXvisualConfig *pGlxVisual = NULL;
+ int v;
+ int found = 0;
+ for (v=0; v<dmxScreen->numGlxVisuals; v++) {
+ if (dmxScreen->glxVisuals[v].vid == be_pFBConfig->associatedVisualId) {
+ pGlxVisual = &dmxScreen->glxVisuals[v];
+ break;
+ }
+ }
+
+ if (pGlxVisual) {
+ for (v=0; v<pGlxScreen->numVisuals; v++) {
+ if (glxVisualsMatch(&pGlxScreen->pGlxVisual[v], pGlxVisual)) {
+ associatedVisualId = pGlxScreen->pGlxVisual[v].vid;
+ found = 1;
+ break;
+ }
+ }
+ }
+
+ if (!found) {
+ associatedVisualId = 0;
+ pFBConfig->drawableType &= ~(GLX_WINDOW_BIT);
+ buf[drawableTypeIndex] = pFBConfig->drawableType;
+ }
+#ifdef PANORAMIX
+ else if (!noPanoramiXExtension) {
+ /* convert the associated visualId to the panoramix one */
+ for (v=0; v<255; v++) {
+ if ( PanoramiXVisualTable[ v * MAXSCREENS + screen ] ==
+ associatedVisualId ) {
+ associatedVisualId = v;
+ break;
+ }
+ }
+ pFBConfig->associatedVisualId = associatedVisualId;
+ }
+#endif
+ }
+ else {
+ associatedVisualId = pFBConfig->associatedVisualId;
+ }
+
+ buf[p++] = GLX_VISUAL_ID;
+ buf[p++] = associatedVisualId;
+
+ /* SGIS_multisample attributes */
+ buf[p++] = GLX_SAMPLES_SGIS;
+ buf[p++] = pFBConfig->multiSampleSize;
+ buf[p++] = GLX_SAMPLE_BUFFERS_SGIS;
+ buf[p++] = pFBConfig->nMultiSampleBuffers;
+
+ /* SGIX_pbuffer specific attributes */
+ buf[p++] = GLX_OPTIMAL_PBUFFER_WIDTH_SGIX;
+ buf[p++] = pFBConfig->optimalPbufferWidth;
+ buf[p++] = GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX;
+ buf[p++] = pFBConfig->optimalPbufferHeight;
+
+ buf[p++] = GLX_VISUAL_SELECT_GROUP_SGIX;
+ buf[p++] = pFBConfig->visualSelectGroup;
+
+ if (client->swapped) {
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_INT_ARRAY((int *)buf, 2*numAttribs);
+ }
+ WriteToClient(client, 2*numAttribs * __GLX_SIZE_CARD32, (char *)buf);
+ }
+ return Success;
+}
+
+int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *)pc;
+ xGLXGetFBConfigsReq new_req;
+
+ new_req.reqType = req->reqType;
+ new_req.glxCode = req->glxCode;
+ new_req.length = req->length;
+ new_req.screen = req->screen;
+
+ return( __glXGetFBConfigs( cl, (GLbyte *)&new_req ) );
+}
+
+
+int __glXCreateWindow(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXCreateWindowReq *req = (xGLXCreateWindowReq *) pc;
+ int screen = req->screen;
+ GLXFBConfigID fbconfigId = req->fbconfig;
+ XID windowId = req->window;
+ XID glxwindowId = req->glxwindow;
+ DrawablePtr pDraw;
+ ScreenPtr pScreen;
+ __glXWindow *pGlxWindow;
+ __GLXFBConfig *pGlxFBConfig = NULL;
+ VisualPtr pVisual;
+ VisualID visId;
+ int i;
+
+ /*
+ ** Check if windowId is valid
+ */
+ pDraw = (DrawablePtr) LookupDrawable(windowId, client);
+ if (!pDraw || pDraw->type != DRAWABLE_WINDOW) {
+ client->errorValue = windowId;
+ return BadWindow;
+ }
+
+ /*
+ ** Check if screen of window matches screen of fbconfig.
+ */
+ pScreen = pDraw->pScreen;
+ if (screen != pScreen->myNum) {
+ return BadMatch;
+ }
+
+ /*
+ ** Find the FBConfigRec for this fbconfigid.
+ */
+ if (!(pGlxFBConfig = glxLookupFBConfig(fbconfigId))) {
+ client->errorValue = fbconfigId;
+ return __glXBadFBConfig;
+ }
+ visId = pGlxFBConfig->associatedVisualId;
+
+ /*
+ ** Check if the fbconfig supports rendering to windows
+ */
+ if( !(pGlxFBConfig->drawableType & GLX_WINDOW_BIT) ) {
+ return BadMatch;
+ }
+
+ if (visId != None) {
+ /*
+ ** Check if the visual ID is valid for this screen.
+ */
+ pVisual = pScreen->visuals;
+ for (i = 0; i < pScreen->numVisuals; i++, pVisual++) {
+ if (pVisual->vid == visId) {
+ break;
+ }
+ }
+ if (i == pScreen->numVisuals) {
+ client->errorValue = visId;
+ return BadValue;
+ }
+
+ /*
+ ** Check if color buffer depth of fbconfig matches depth
+ ** of window.
+ */
+ if (pVisual->nplanes != pDraw->depth) {
+ return BadMatch;
+ }
+ } else
+ /*
+ ** The window was created with no visual that corresponds
+ ** to fbconfig
+ */
+ return BadMatch;
+
+ /*
+ ** Check if there is already a fbconfig associated with this window
+ */
+ if ( LookupIDByType(glxwindowId, __glXWindowRes) ) {
+ client->errorValue = glxwindowId;
+ return BadAlloc;
+ }
+
+ pGlxWindow = (__glXWindow *) xalloc(sizeof(__glXWindow));
+ if (!pGlxWindow) {
+ return BadAlloc;
+ }
+
+ /*
+ ** Register this GLX window as a resource
+ */
+ if (!(AddResource(glxwindowId, __glXWindowRes, pGlxWindow))) {
+ return BadAlloc;
+ }
+
+ pGlxWindow->pDraw = pDraw;
+ pGlxWindow->type = GLX_GLXWINDOW_TYPE;
+ pGlxWindow->idExists = True;
+ pGlxWindow->refcnt = 0;
+ pGlxWindow->pGlxFBConfig = pGlxFBConfig;
+ pGlxWindow->pScreen = pScreen;
+
+ return Success;
+}
+
+int __glXDestroyWindow(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc;
+ XID glxwindow = req->glxwindow;
+
+ /*
+ ** Check if it's a valid GLX window.
+ */
+ if (!LookupIDByType(glxwindow, __glXWindowRes)) {
+ client->errorValue = glxwindow;
+ return __glXBadDrawable;
+ }
+ /*
+ ** The glx window destructor will check whether it's current before
+ ** freeing anything.
+ */
+ FreeResource(glxwindow, RT_NONE);
+
+ return Success;
+}
+
+int __glXQueryContext(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ __GLXcontext *ctx;
+ xGLXQueryContextReq *req;
+ xGLXQueryContextReply reply;
+ int nProps;
+ int *sendBuf, *pSendBuf;
+ int nReplyBytes;
+
+ req = (xGLXQueryContextReq *)pc;
+ ctx = (__GLXcontext *) LookupIDByType(req->context, __glXContextRes);
+ if (!ctx) {
+ client->errorValue = req->context;
+ return __glXBadContext;
+ }
+
+ nProps = 3;
+
+ reply.length = nProps << 1;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.n = nProps;
+
+ nReplyBytes = reply.length << 2;
+ sendBuf = (int *)xalloc(nReplyBytes);
+ pSendBuf = sendBuf;
+ *pSendBuf++ = GLX_FBCONFIG_ID;
+ *pSendBuf++ = (int)(ctx->pFBConfig->id);
+ *pSendBuf++ = GLX_RENDER_TYPE;
+ *pSendBuf++ = (int)(ctx->pFBConfig->renderType);
+ *pSendBuf++ = GLX_SCREEN;
+ *pSendBuf++ = (int)(ctx->pScreen->myNum);
+
+ if (client->swapped) {
+ __glXSwapQueryContextReply(client, &reply, sendBuf);
+ } else {
+ WriteToClient(client, sz_xGLXQueryContextReply, (char *)&reply);
+ WriteToClient(client, nReplyBytes, (char *)sendBuf);
+ }
+ xfree((char *)sendBuf);
+
+ return Success;
+}
+
+int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ __GLXcontext *ctx;
+ xGLXQueryContextInfoEXTReq *req;
+ xGLXQueryContextInfoEXTReply reply;
+ int nProps;
+ int *sendBuf, *pSendBuf;
+ int nReplyBytes;
+
+ req = (xGLXQueryContextInfoEXTReq *)pc;
+ ctx = (__GLXcontext *) SecurityLookupIDByType(client, req->context, __glXContextRes, SecurityReadAccess);
+ if (!ctx) {
+ client->errorValue = req->context;
+ return __glXBadContext;
+ }
+
+ nProps = 4;
+
+ reply.length = nProps << 1;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.n = nProps;
+
+ nReplyBytes = reply.length << 2;
+ sendBuf = (int *)xalloc(nReplyBytes);
+ pSendBuf = sendBuf;
+ *pSendBuf++ = GLX_SHARE_CONTEXT_EXT;
+ *pSendBuf++ = (int)(ctx->share_id);
+ *pSendBuf++ = GLX_VISUAL_ID_EXT;
+ *pSendBuf++ = (int)(ctx->pVisual ? ctx->pVisual->vid : 0);
+ *pSendBuf++ = GLX_SCREEN_EXT;
+ *pSendBuf++ = (int)(ctx->pScreen->myNum);
+ *pSendBuf++ = GLX_FBCONFIG_ID;
+ *pSendBuf++ = (int)(ctx->pFBConfig ? ctx->pFBConfig->id : 0);
+
+ if (client->swapped) {
+ __glXSwapQueryContextInfoEXTReply(client, &reply, sendBuf);
+ } else {
+ WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, (char *)&reply);
+ WriteToClient(client, nReplyBytes, (char *)sendBuf);
+ }
+ xfree((char *)sendBuf);
+
+ return Success;
+}
+
+int __glXCreatePbuffer(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *)pc;
+ xGLXCreatePbufferReq *be_req;
+ int screen = req->screen;
+ GLXFBConfigID fbconfigId = req->fbconfig;
+ GLXPbuffer pbuffer = req->pbuffer;
+ __glXPbuffer *pGlxPbuffer;
+ int numAttribs = req->numAttribs;
+ int *attr;
+ ScreenPtr pScreen;
+ __GLXFBConfig *pGlxFBConfig;
+ __GLXFBConfig *be_pGlxFBConfig;
+ XID be_xid;
+ Display *dpy;
+ DMXScreenInfo *dmxScreen;
+ int s;
+ int from_screen, to_screen;
+
+ /*
+ ** Look up screen and FBConfig.
+ */
+ if (screen > screenInfo.numScreens) {
+ /* The client library must send a valid screen number. */
+ client->errorValue = screen;
+ return BadValue;
+ }
+ pScreen = screenInfo.screens[screen];
+
+ /*
+ ** Find the FBConfigRec for this fbconfigid.
+ */
+ if (!(pGlxFBConfig = glxLookupFBConfig(fbconfigId))) {
+ client->errorValue = fbconfigId;
+ return __glXBadFBConfig;
+ }
+
+ /*
+ ** Create the GLX part of the Pbuffer.
+ */
+ pGlxPbuffer = (__glXPbuffer *) xalloc(sizeof(__glXPbuffer));
+ if (!pGlxPbuffer) {
+ return BadAlloc;
+ }
+
+ pGlxPbuffer->be_xids = (XID *) xalloc( sizeof(XID) * screenInfo.numScreens );
+ if (!pGlxPbuffer->be_xids) {
+ xfree(pGlxPbuffer);
+ return BadAlloc;
+ }
+
+ /*
+ * Allocate an XID on the back-end server(s) and send him the request
+ */
+ from_screen = to_screen = screen;
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ for (s=from_screen; s<=to_screen; s++) {
+ dpy = GetBackEndDisplay(cl,s);
+ be_xid = XAllocID(dpy);
+ dmxScreen = &dmxScreens[s];
+ be_pGlxFBConfig = glxLookupBackEndFBConfig( pGlxFBConfig->id, s );
+
+ attr = (int *)( req+1 );
+
+ LockDisplay(dpy);
+ GetReqExtra(GLXCreatePbuffer, 2 * numAttribs * __GLX_SIZE_CARD32, be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXCreatePbuffer;
+ be_req->screen = be_pGlxFBConfig->screen;
+ be_req->fbconfig = be_pGlxFBConfig->id;
+ be_req->pbuffer = be_xid;
+ be_req->numAttribs = numAttribs;
+
+ /* Send attributes */
+ if ( attr != NULL ) {
+ CARD32 *pc = (CARD32 *)(be_req + 1);
+
+ while (numAttribs-- > 0) {
+ *pc++ = *attr++; /* token */
+ *pc++ = *attr++; /* value */
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ pGlxPbuffer->be_xids[s] = be_xid;
+ }
+
+
+ pGlxPbuffer->idExists = True;
+ pGlxPbuffer->refcnt = 0;
+ pGlxPbuffer->pFBConfig = pGlxFBConfig;
+ pGlxPbuffer->pScreen = pScreen;
+
+ /*
+ ** Register the resource.
+ */
+ if (!(AddResource(pbuffer, __glXPbufferRes, pGlxPbuffer))) {
+ return BadAlloc;
+ }
+
+ return Success;
+
+}
+
+int __glXDestroyPbuffer(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc;
+ xGLXDestroyPbufferReq *be_req;
+ GLXPbuffer pbuffer = req->pbuffer;
+ Display *dpy;
+ int screen;
+ DMXScreenInfo *dmxScreen;
+ __glXPbuffer *pGlxPbuffer;
+ int s;
+ int from_screen, to_screen;
+
+ /*
+ ** Check if it's a valid Pbuffer
+ */
+ pGlxPbuffer = (__glXPbuffer *)LookupIDByType(pbuffer, __glXPbufferRes);
+ if (!pGlxPbuffer) {
+ client->errorValue = pbuffer;
+ return __glXBadPbuffer;
+ }
+
+ screen = pGlxPbuffer->pScreen->myNum;
+
+ from_screen = to_screen = screen;
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ for (s=from_screen; s<=to_screen; s++) {
+ dpy = GetBackEndDisplay(cl,s);
+ dmxScreen = &dmxScreens[s];
+
+ /* send the destroy request to the back-end server */
+ LockDisplay(dpy);
+ GetReq(GLXDestroyPbuffer, be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXDestroyPbuffer;
+ be_req->pbuffer = pGlxPbuffer->be_xids[s];
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+ FreeResource(pbuffer, RT_NONE);
+
+ return Success;
+}
+
+int __glXGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc;
+ xGLXGetDrawableAttributesReq *be_req;
+ xGLXGetDrawableAttributesReply reply;
+ ClientPtr client = cl->client;
+ GLXDrawable drawId = req->drawable;
+ GLXDrawable be_drawable = 0;
+ DrawablePtr pDraw = NULL;
+ Display *dpy;
+ int screen;
+ DMXScreenInfo *dmxScreen;
+ CARD32 *attribs = NULL;
+ int attribs_size;
+#ifdef PANORAMIX
+ PanoramiXRes *pXinDraw = NULL;
+#endif
+
+ if (drawId != None) {
+ pDraw = (DrawablePtr) LookupDrawable(drawId, client);
+ if (pDraw) {
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ WindowPtr pWin = (WindowPtr)pDraw;
+ be_drawable = 0;
+ screen = pWin->drawable.pScreen->myNum;
+
+ }
+ else {
+ /*
+ ** Drawable is not a Window , GLXWindow or a GLXPixmap.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ }
+
+ if (!pDraw) {
+ __GLXpixmap *pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId,
+ __glXPixmapRes);
+ if (pGlxPixmap) {
+ pDraw = pGlxPixmap->pDraw;
+ screen = pGlxPixmap->pScreen->myNum;
+ be_drawable = pGlxPixmap->be_xids[screen];
+ }
+ }
+
+ if (!pDraw) {
+ __glXWindow *pGlxWindow = (__glXWindow *) LookupIDByType(drawId, __glXWindowRes);
+ if (pGlxWindow) {
+ pDraw = pGlxWindow->pDraw;
+ screen = pGlxWindow->pScreen->myNum;
+ be_drawable = 0;
+ }
+ }
+
+ if (!pDraw) {
+ __glXPbuffer *pGlxPbuffer = (__glXPbuffer *)LookupIDByType(drawId, __glXPbufferRes);
+ if (pGlxPbuffer) {
+ pDraw = (DrawablePtr)pGlxPbuffer;
+ screen = pGlxPbuffer->pScreen->myNum;
+ be_drawable = pGlxPbuffer->be_xids[screen];
+ }
+ }
+
+
+ if (!pDraw) {
+ /*
+ ** Drawable is not a Window , GLXWindow or a GLXPixmap.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ }
+
+
+ /* if the drawable is a window or GLXWindow -
+ * we need to find the base id on the back-end server
+ */
+ if (!be_drawable) {
+ WindowPtr pWin = (WindowPtr)pDraw;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ pXinDraw = (PanoramiXRes *)
+ SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, SecurityReadAccess);
+ if (!pXinDraw) {
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+
+ pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[screen].id,
+ client,
+ SecurityReadAccess);
+ }
+#endif
+
+ if (pWin) {
+ be_drawable = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
+ if (!be_drawable) {
+ /* it might be that the window did not created yet on the */
+ /* back-end server (lazy window creation option), force */
+ /* creation of the window */
+ dmxCreateAndRealizeWindow( pWin, TRUE );
+ be_drawable = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
+ }
+ }
+ else {
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ }
+
+
+ /* send the request to the back-end server */
+ dpy = GetBackEndDisplay(cl,screen);
+ dmxScreen = &dmxScreens[screen];
+
+ /* make sure drawable exists on back-end */
+ dmxSync( dmxScreen, 1 );
+
+ LockDisplay(dpy);
+ GetReq(GLXGetDrawableAttributes, be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXGetDrawableAttributes;
+ be_req->drawable = be_drawable;
+ be_req->length = req->length;
+ if (!_XReply(dpy, (xReply *) &reply, 0, False)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return( BE_TO_CLIENT_ERROR(dmxLastErrorEvent.error_code) );
+ }
+
+ if (reply.numAttribs) {
+ attribs_size = 2 * reply.numAttribs * __GLX_SIZE_CARD32;
+ attribs = (CARD32 *) Xalloc(attribs_size);
+ if (attribs == NULL) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadAlloc;
+ }
+
+ _XRead(dpy, (char *) attribs, attribs_size);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+
+ /* send the reply back to the client */
+ reply.sequenceNumber = client->sequence;
+ if (client->swapped) {
+ __glXSwapGetDrawableAttributesReply(client, &reply, (int *)attribs);
+ }
+ else {
+ WriteToClient(client, sz_xGLXGetDrawableAttributesReply, (char *)&reply);
+ WriteToClient(client, attribs_size, (char *)attribs);
+ }
+
+ Xfree(attribs);
+
+ return Success;
+}
+
+int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXChangeDrawableAttributesReq *req = (xGLXChangeDrawableAttributesReq *)pc;
+ xGLXChangeDrawableAttributesReq *be_req;
+ ClientPtr client = cl->client;
+ GLXDrawable drawId = req->drawable;
+ GLXDrawable be_drawable = 0;
+ DrawablePtr pDraw = NULL;
+ Display *dpy;
+ int screen;
+ DMXScreenInfo *dmxScreen;
+ char *attrbuf;
+#ifdef PANORAMIX
+ PanoramiXRes *pXinDraw = NULL;
+ PanoramiXRes *pXinReadDraw = NULL;
+#endif
+
+ if (drawId != None) {
+ pDraw = (DrawablePtr) LookupDrawable(drawId, client);
+ if (pDraw) {
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ WindowPtr pWin = (WindowPtr)pDraw;
+ be_drawable = 0;
+ screen = pWin->drawable.pScreen->myNum;
+
+ }
+ else {
+ /*
+ ** Drawable is not a Window , GLXWindow or a GLXPixmap.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ }
+
+ if (!pDraw) {
+ __GLXpixmap *pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId,
+ __glXPixmapRes);
+ if (pGlxPixmap) {
+ pDraw = pGlxPixmap->pDraw;
+ screen = pGlxPixmap->pScreen->myNum;
+ be_drawable = pGlxPixmap->be_xids[screen];
+ }
+ }
+
+ if (!pDraw) {
+ __glXWindow *pGlxWindow = (__glXWindow *) LookupIDByType(drawId, __glXWindowRes);
+ if (pGlxWindow) {
+ pDraw = pGlxWindow->pDraw;
+ screen = pGlxWindow->pScreen->myNum;
+ be_drawable = 0;
+ }
+ }
+
+ if (!pDraw) {
+ __glXPbuffer *pGlxPbuffer = (__glXPbuffer *)LookupIDByType(drawId, __glXPbufferRes);
+ if (pGlxPbuffer) {
+ pDraw = (DrawablePtr)pGlxPbuffer;
+ screen = pGlxPbuffer->pScreen->myNum;
+ be_drawable = pGlxPbuffer->be_xids[screen];
+ }
+ }
+
+
+ if (!pDraw) {
+ /*
+ ** Drawable is not a Window , GLXWindow or a GLXPixmap.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ }
+
+
+ /* if the drawable is a window or GLXWindow -
+ * we need to find the base id on the back-end server
+ */
+ if (!be_drawable) {
+ WindowPtr pWin = (WindowPtr)pDraw;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ pXinDraw = (PanoramiXRes *)
+ SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, SecurityReadAccess);
+ if (!pXinDraw) {
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+
+ pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[screen].id,
+ client,
+ SecurityReadAccess);
+ }
+#endif
+
+ if (pWin) {
+ be_drawable = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
+ if (!be_drawable) {
+ /* it might be that the window did not created yet on the */
+ /* back-end server (lazy window creation option), force */
+ /* creation of the window */
+ dmxCreateAndRealizeWindow( pWin, TRUE );
+ be_drawable = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
+ }
+ }
+ else {
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ }
+
+
+ /* send the request to the back-end server */
+ dpy = GetBackEndDisplay(cl,screen);
+ dmxScreen = &dmxScreens[screen];
+
+ /* make sure drawable exists on back-end */
+ dmxSync( dmxScreen, 1 );
+
+ LockDisplay(dpy);
+ GetReqExtra(GLXChangeDrawableAttributes,
+ 2 * req->numAttribs * __GLX_SIZE_CARD32, be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXChangeDrawableAttributes;
+ be_req->drawable = be_drawable;
+ be_req->numAttribs = req->numAttribs;
+ be_req->length = req->length;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return Success;
+}
+
+int __glXSendLargeCommand(__GLXclientState *cl, GLXContextTag contextTag)
+{
+ ClientPtr client = cl->client;
+ xGLXRenderLargeReq *req;
+ GLint maxSize, amount;
+ GLint totalRequests, requestNumber;
+ GLint dataLen;
+ GLbyte *data;
+ __GLXcontext *glxc;
+ int s;
+ int from_screen, to_screen;
+
+ maxSize = cl->largeCmdMaxReqDataSize - (GLint)sizeof(xGLXRenderLargeReq);
+ dataLen = cl->largeCmdBytesTotal;
+ totalRequests = (dataLen / maxSize);
+ if (dataLen % maxSize) totalRequests++;
+
+ glxc = __glXLookupContextByTag(cl, contextTag);
+ if (!glxc) {
+ client->errorValue = contextTag;
+ return __glXBadContext;
+ }
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ /*
+ ** Send enough requests until the whole array is sent.
+ */
+ requestNumber = 1;
+ data = cl->largeCmdBuf;
+ while (dataLen > 0) {
+ amount = dataLen;
+ if (amount > maxSize) {
+ amount = maxSize;
+ }
+
+ for (s=from_screen; s<=to_screen; s++) {
+
+ Display *dpy = GetBackEndDisplay(cl,s);
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+
+ LockDisplay(dpy);
+ GetReq(GLXRenderLarge,req);
+ req->reqType = dmxScreen->glxMajorOpcode;
+ req->glxCode = X_GLXRenderLarge;
+ req->contextTag = (glxc ? GetCurrentBackEndTag(cl,contextTag,s) : 0);
+ req->length += (amount + 3) >> 2;
+ req->requestNumber = requestNumber++;
+ req->requestTotal = totalRequests;
+ req->dataBytes = amount;
+ Data(dpy, ((const char*)data), amount);
+ dataLen -= amount;
+ data = ((GLbyte *) data) + amount;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+ }
+
+ return Success;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxcmdsswap.c b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxcmdsswap.c
new file mode 100644
index 000000000..565793e22
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxcmdsswap.c
@@ -0,0 +1,1059 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxcmdsswap.c,v 1.5 2001/03/21 16:29:36 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define NEED_REPLIES
+#define FONT_PCF
+#include "glxserver.h"
+#include "glxutil.h"
+#include <GL/glxtokens.h>
+#include <g_disptab.h>
+#include <pixmapstr.h>
+#include <windowstr.h>
+#include "unpack.h"
+#include "glxext.h"
+#include "GL/glx_ansic.h"
+#include "glxvendor.h"
+
+extern int glxIsExtensionSupported( char *ext );
+
+/************************************************************************/
+
+/*
+** Byteswapping versions of GLX commands. In most cases they just swap
+** the incoming arguments and then call the unswapped routine. For commands
+** that have replies, a separate swapping routine for the reply is provided;
+** it is called at the end of the unswapped routine.
+*/
+
+int __glXSwapCreateContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->visual);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->shareList);
+
+ return __glXCreateContext(cl, pc);
+}
+
+int __glXSwapCreateNewContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->shareList);
+
+ return __glXCreateNewContext(cl, pc);
+}
+
+int __glXSwapCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextWithConfigSGIXReq *req = (xGLXCreateContextWithConfigSGIXReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->shareList);
+
+ return __glXCreateContextWithConfigSGIX(cl, pc);
+}
+
+int __glXSwapQueryMaxSwapBarriersSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXQueryMaxSwapBarriersSGIXReq *req =
+ (xGLXQueryMaxSwapBarriersSGIXReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+
+ return __glXQueryMaxSwapBarriersSGIX(cl, pc);
+}
+
+int __glXSwapBindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXBindSwapBarrierSGIXReq *req = (xGLXBindSwapBarrierSGIXReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+ __GLX_SWAP_INT(&req->barrier);
+
+ return __glXBindSwapBarrierSGIX(cl, pc);
+}
+
+int __glXSwapJoinSwapGroupSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXJoinSwapGroupSGIXReq *req = (xGLXJoinSwapGroupSGIXReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+ __GLX_SWAP_INT(&req->member);
+
+ return __glXJoinSwapGroupSGIX(cl, pc);
+}
+
+int __glXSwapDestroyContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+
+ return __glXDestroyContext(cl, pc);
+}
+
+int __glXSwapMakeCurrent(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->oldContextTag);
+
+ return __glXMakeCurrent(cl, pc);
+}
+
+int __glXSwapMakeContextCurrent(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+ __GLX_SWAP_INT(&req->readdrawable);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->oldContextTag);
+
+ return __glXMakeContextCurrent(cl, pc);
+}
+
+int __glXSwapMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+ __GLX_SWAP_INT(&req->readable);
+ __GLX_SWAP_INT(&req->context);
+ __GLX_SWAP_INT(&req->oldContextTag);
+
+ return __glXMakeCurrentReadSGI(cl, pc);
+}
+
+int __glXSwapIsDirect(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+
+ return __glXIsDirect(cl, pc);
+}
+
+int __glXSwapQueryVersion(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->majorVersion);
+ __GLX_SWAP_INT(&req->minorVersion);
+
+ return __glXQueryVersion(cl, pc);
+}
+
+int __glXSwapWaitGL(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXWaitGLReq *req = (xGLXWaitGLReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ return __glXWaitGL(cl, pc);
+}
+
+int __glXSwapWaitX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXWaitXReq *req = (xGLXWaitXReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ return __glXWaitX(cl, pc);
+}
+
+int __glXSwapCopyContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->source);
+ __GLX_SWAP_INT(&req->dest);
+ __GLX_SWAP_INT(&req->mask);
+
+ return __glXCopyContext(cl, pc);
+}
+
+int __glXSwapGetVisualConfigs(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
+ xGLXGetVisualConfigsReply reply;
+ __GLXscreenInfo *pGlxScreen;
+ __GLXvisualConfig *pGlxVisual;
+ CARD32 buf[__GLX_TOTAL_CONFIG];
+ unsigned int screen;
+ int i, p;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&req->screen);
+ screen = req->screen;
+ if (screen > screenInfo.numScreens) {
+ /* The client library must send a valid screen number. */
+ client->errorValue = screen;
+ return BadValue;
+ }
+ pGlxScreen = &__glXActiveScreens[screen];
+
+ reply.numVisuals = pGlxScreen->numGLXVisuals;
+ reply.numProps = __GLX_TOTAL_CONFIG;
+ reply.length = (pGlxScreen->numGLXVisuals * __GLX_SIZE_CARD32 *
+ __GLX_TOTAL_CONFIG) >> 2;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.numVisuals);
+ __GLX_SWAP_INT(&reply.numProps);
+ WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char *)&reply);
+
+ for (i=0; i < pGlxScreen->numVisuals; i++) {
+ pGlxVisual = &pGlxScreen->pGlxVisual[i];
+ if (!pGlxScreen->isGLXvis[i] || pGlxVisual->vid == 0) {
+ /* not a usable visual */
+ continue;
+ }
+ p = 0;
+ buf[p++] = pGlxVisual->vid;
+ buf[p++] = pGlxVisual->class;
+ buf[p++] = pGlxVisual->rgba;
+
+ buf[p++] = pGlxVisual->redSize;
+ buf[p++] = pGlxVisual->greenSize;
+ buf[p++] = pGlxVisual->blueSize;
+ buf[p++] = pGlxVisual->alphaSize;
+ buf[p++] = pGlxVisual->accumRedSize;
+ buf[p++] = pGlxVisual->accumGreenSize;
+ buf[p++] = pGlxVisual->accumBlueSize;
+ buf[p++] = pGlxVisual->accumAlphaSize;
+
+ buf[p++] = pGlxVisual->doubleBuffer;
+ buf[p++] = pGlxVisual->stereo;
+
+ buf[p++] = pGlxVisual->bufferSize;
+ buf[p++] = pGlxVisual->depthSize;
+ buf[p++] = pGlxVisual->stencilSize;
+ buf[p++] = pGlxVisual->auxBuffers;
+ buf[p++] = pGlxVisual->level;
+ /*
+ ** Add token/value pairs for extensions.
+ */
+ buf[p++] = GLX_VISUAL_CAVEAT_EXT;
+ buf[p++] = pGlxVisual->visualRating;
+ buf[p++] = GLX_TRANSPARENT_TYPE_EXT;
+ buf[p++] = pGlxVisual->transparentPixel;
+ buf[p++] = GLX_TRANSPARENT_RED_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentRed;
+ buf[p++] = GLX_TRANSPARENT_GREEN_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentGreen;
+ buf[p++] = GLX_TRANSPARENT_BLUE_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentBlue;
+ buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentAlpha;
+ buf[p++] = GLX_TRANSPARENT_INDEX_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentIndex;
+
+ __GLX_SWAP_INT_ARRAY(buf, __GLX_TOTAL_CONFIG);
+ WriteToClient(client, __GLX_SIZE_CARD32 * __GLX_TOTAL_CONFIG,
+ (char *)buf);
+ }
+ return Success;
+}
+
+int __glXSwapCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->visual);
+ __GLX_SWAP_INT(&req->pixmap);
+ __GLX_SWAP_INT(&req->glxpixmap);
+
+ return __glXCreateGLXPixmap(cl, pc);
+}
+
+int __glXSwapCreatePixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->pixmap);
+ __GLX_SWAP_INT(&req->glxpixmap);
+ __GLX_SWAP_INT(&req->numAttribs);
+
+ return __glXCreatePixmap(cl, pc);
+}
+
+int __glXSwapDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->glxpixmap);
+
+ return __glXDestroyGLXPixmap(cl, pc);
+}
+
+int __glXSwapSwapBuffers(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+ __GLX_SWAP_INT(&req->drawable);
+
+ return __glXSwapBuffers(cl, pc);
+}
+
+int __glXSwapUseXFont(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXUseXFontReq *req = (xGLXUseXFontReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+ __GLX_SWAP_INT(&req->font);
+ __GLX_SWAP_INT(&req->first);
+ __GLX_SWAP_INT(&req->count);
+ __GLX_SWAP_INT(&req->listBase);
+
+ return __glXUseXFont(cl, pc);
+}
+
+
+int __glXSwapQueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXQueryExtensionsStringReq *req = NULL;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+
+ return __glXQueryExtensionsString(cl, pc);
+}
+
+int __glXSwapQueryServerString(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->name);
+
+ return __glXQueryServerString(cl, pc);
+}
+
+int __glXSwapClientInfo(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXClientInfoReq *req = (xGLXClientInfoReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->major);
+ __GLX_SWAP_INT(&req->minor);
+ __GLX_SWAP_INT(&req->numbytes);
+
+ return __glXClientInfo(cl, pc);
+}
+
+int __glXSwapQueryContextInfoEXT(__GLXclientState *cl, char *pc)
+{
+ xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+
+ return __glXQueryContextInfoEXT(cl, (GLbyte *)pc);
+}
+
+/************************************************************************/
+
+/*
+** Swap replies.
+*/
+
+void __glXSwapMakeCurrentReply(ClientPtr client, xGLXMakeCurrentReadSGIReply *reply)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->contextTag);
+ __GLX_SWAP_INT(&reply->writeVid);
+ __GLX_SWAP_INT(&reply->writeType);
+ __GLX_SWAP_INT(&reply->readVid);
+ __GLX_SWAP_INT(&reply->readType);
+ WriteToClient(client, sz_xGLXMakeCurrentReadSGIReply, (char *)reply);
+}
+
+void __glXSwapIsDirectReply(ClientPtr client, xGLXIsDirectReply *reply)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ WriteToClient(client, sz_xGLXIsDirectReply, (char *)reply);
+}
+
+void __glXSwapQueryVersionReply(ClientPtr client, xGLXQueryVersionReply *reply)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->majorVersion);
+ __GLX_SWAP_INT(&reply->minorVersion);
+ WriteToClient(client, sz_xGLXQueryVersionReply, (char *)reply);
+}
+
+void glxSwapQueryExtensionsStringReply(ClientPtr client,
+ xGLXQueryExtensionsStringReply *reply, char *buf)
+{
+ int length = reply->length;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->n);
+ WriteToClient(client, sz_xGLXQueryExtensionsStringReply, (char *)reply);
+ __GLX_SWAP_INT_ARRAY((int *)buf, length);
+ WriteToClient(client, length << 2, buf);
+}
+
+void glxSwapQueryServerStringReply(ClientPtr client,
+ xGLXQueryServerStringReply *reply, char *buf)
+{
+ int length = reply->length;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->n);
+ WriteToClient(client, sz_xGLXQueryServerStringReply, (char *)reply);
+ /** no swap is needed for an array of chars **/
+ /* __GLX_SWAP_INT_ARRAY((int *)buf, length); */
+ WriteToClient(client, length << 2, buf);
+}
+
+void __glXSwapQueryContextInfoEXTReply(ClientPtr client, xGLXQueryContextInfoEXTReply *reply, int *buf)
+{
+ int length = reply->length;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->n);
+ WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, (char *)reply);
+ __GLX_SWAP_INT_ARRAY((int *)buf, length);
+ WriteToClient(client, length << 2, (char *)buf);
+}
+
+
+void __glXSwapQueryContextReply(ClientPtr client,
+ xGLXQueryContextReply *reply, int *buf)
+{
+ int length = reply->length;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->n);
+ WriteToClient(client, sz_xGLXQueryContextReply, (char *)reply);
+ __GLX_SWAP_INT_ARRAY((int *)buf, length);
+ WriteToClient(client, length << 2, (char *)buf);
+}
+
+void __glXSwapGetDrawableAttributesReply(ClientPtr client,
+ xGLXGetDrawableAttributesReply *reply, int *buf)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->numAttribs);
+ __GLX_SWAP_INT_ARRAY( buf, reply->length );
+ WriteToClient(client, sz_xGLXGetDrawableAttributesReply, (char *)reply);
+ WriteToClient(client, reply->length << 2, (char *)buf);
+}
+
+void __glXSwapQueryMaxSwapBarriersSGIXReply(ClientPtr client, xGLXQueryMaxSwapBarriersSGIXReply *reply)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->max);
+ WriteToClient(client, sz_xGLXQueryMaxSwapBarriersSGIXReply, (char *)reply);
+}
+
+/************************************************************************/
+
+/*
+** Render and Renderlarge are not in the GLX API. They are used by the GLX
+** client library to send batches of GL rendering commands.
+*/
+
+int __glXSwapRender(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXRenderReq *req;
+ int left;
+ __GLXrenderHeader *hdr;
+ ClientPtr client = cl->client;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ /*
+ ** NOTE: much of this code also appears in the nonswapping version of this
+ ** routine, __glXRender(). Any changes made here should also be
+ ** duplicated there.
+ */
+
+ req = (xGLXRenderReq *) pc;
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ pc += sz_xGLXRenderReq;
+ left = (req->length << 2) - sz_xGLXRenderReq;
+ while (left > 0) {
+ void (* proc)(GLbyte *);
+ CARD16 opcode;
+
+ /*
+ ** Verify that the header length and the overall length agree.
+ ** Also, each command must be word aligned.
+ */
+ hdr = (__GLXrenderHeader *) pc;
+ __GLX_SWAP_SHORT(&hdr->length);
+ __GLX_SWAP_SHORT(&hdr->opcode);
+
+ /*
+ * call the command procedure to swap any arguments
+ */
+ opcode = hdr->opcode;
+ if ( (opcode >= __GLX_MIN_RENDER_OPCODE) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE) ) {
+ proc = __glXSwapRenderTable[opcode];
+#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT
+ } else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) {
+ int index = opcode - __GLX_MIN_RENDER_OPCODE_EXT;
+ __GLXRenderSwapInfo *info = &__glXSwapRenderTable_EXT[index];
+ if (info->swapfunc) {
+ proc = info->swapfunc;
+ }
+ else {
+ proc = NULL;
+ if (info->elem_size == 4 && info->nelems > 0) {
+ __GLX_SWAP_INT_ARRAY( (int *)(pc + __GLX_RENDER_HDR_SIZE),
+ info->nelems );
+ }
+ else if (info->elem_size == 2 && info->nelems > 0) {
+ __GLX_SWAP_SHORT_ARRAY( (short *)(pc + __GLX_RENDER_HDR_SIZE),
+ info->nelems );
+ }
+ else if (info->elem_size == 8 && info->nelems > 0) {
+ __GLX_SWAP_DOUBLE_ARRAY( (double *)(pc + __GLX_RENDER_HDR_SIZE),
+ info->nelems );
+ }
+ }
+#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */
+ } else {
+ client->errorValue = 0;
+ return __glXBadRenderRequest;
+ }
+
+ if (proc != NULL)
+ (*proc)(pc + __GLX_RENDER_HDR_SIZE);
+
+ /*
+ * proceed to the next command
+ */
+ pc += hdr->length;
+ left -= hdr->length;
+ }
+
+ return __glXRender( cl, (GLbyte *)req );
+}
+
+/*
+** Execute a large rendering request (one that spans multiple X requests).
+*/
+int __glXSwapRenderLarge(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXRenderLargeReq *req;
+ __GLXrenderLargeHeader *hdr;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ req = (xGLXRenderLargeReq *) pc;
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+ __GLX_SWAP_INT(&req->dataBytes);
+ __GLX_SWAP_SHORT(&req->requestNumber);
+ __GLX_SWAP_SHORT(&req->requestTotal);
+
+ pc += sz_xGLXRenderLargeReq;
+
+ if (req->requestNumber == 1) {
+ void (* proc)(GLbyte *) = NULL;
+ __GLXRenderSwapInfo *info = NULL;
+ CARD16 opcode;
+
+ hdr = (__GLXrenderLargeHeader *) pc;
+ __GLX_SWAP_INT(&hdr->length);
+ __GLX_SWAP_INT(&hdr->opcode);
+
+ /*
+ * call the command procedure to swap any arguments
+ * Note that we are assuming that all arguments that needs to be
+ * swaped are on the first req only !
+ */
+ opcode = hdr->opcode;
+ if ( (opcode >= __GLX_MIN_RENDER_OPCODE) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE) ) {
+ proc = __glXSwapRenderTable[opcode];
+#if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT
+ } else if ( (opcode >= __GLX_MIN_RENDER_OPCODE_EXT) &&
+ (opcode <= __GLX_MAX_RENDER_OPCODE_EXT) ) {
+ int index = opcode - __GLX_MIN_RENDER_OPCODE_EXT;
+ info = &__glXSwapRenderTable_EXT[index];
+ if (info->swapfunc) {
+ proc = info->swapfunc;
+ }
+#endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */
+ } else {
+ client->errorValue = 0;
+ cl->largeCmdRequestsTotal = 0;
+ return __glXBadLargeRequest;
+ }
+
+ /*
+ ** Make enough space in the buffer, then copy the entire request.
+ */
+ if (cl->largeCmdBufSize < hdr->length) {
+ if (!cl->largeCmdBuf) {
+ cl->largeCmdBuf = (GLbyte *) __glXMalloc(hdr->length);
+ } else {
+ cl->largeCmdBuf = (GLbyte *) __glXRealloc(cl->largeCmdBuf, hdr->length);
+ }
+ if (!cl->largeCmdBuf) {
+ cl->largeCmdRequestsTotal = 0;
+ return BadAlloc;
+ }
+ cl->largeCmdBufSize = hdr->length;
+ }
+ __glXMemcpy(cl->largeCmdBuf, pc, req->dataBytes);
+
+ cl->largeCmdBytesSoFar = req->dataBytes;
+ cl->largeCmdBytesTotal = hdr->length;
+ cl->largeCmdRequestsSoFar = 1;
+ cl->largeCmdRequestsTotal = req->requestTotal;
+ cl->largeCmdRequestsSwapProc = proc;
+ cl->largeCmdMaxReqDataSize = req->dataBytes;
+ cl->largeCmdRequestsSwap_info = info;
+
+ return Success;
+
+
+ }
+ else if (req->requestNumber < cl->largeCmdRequestsTotal) {
+ /*
+ * This is not the first nor last request - just copy the data
+ */
+ if ( cl->largeCmdBytesSoFar + req->dataBytes > cl->largeCmdBytesTotal) {
+ cl->largeCmdRequestsTotal = 0;
+ return __glXBadLargeRequest;
+ }
+
+ __glXMemcpy(cl->largeCmdBuf + cl->largeCmdBytesSoFar,
+ pc, req->dataBytes);
+
+ cl->largeCmdBytesSoFar += req->dataBytes;
+
+ if (req->dataBytes > cl->largeCmdMaxReqDataSize)
+ cl->largeCmdMaxReqDataSize = req->dataBytes;
+
+ return Success;
+ }
+ else if (req->requestNumber == cl->largeCmdRequestsTotal) {
+ /*
+ * this is the last request
+ * copy the remainder bytes, call the procedure to swap any
+ * needed data, and then call to transfer the command to all
+ * back-end servers
+ */
+ if ( cl->largeCmdBytesSoFar + req->dataBytes > cl->largeCmdBytesTotal) {
+ cl->largeCmdRequestsTotal = 0;
+ return __glXBadLargeRequest;
+ }
+
+ __glXMemcpy(cl->largeCmdBuf + cl->largeCmdBytesSoFar,
+ pc, req->dataBytes);
+
+ cl->largeCmdBytesSoFar += req->dataBytes;
+
+ if (req->dataBytes > cl->largeCmdMaxReqDataSize)
+ cl->largeCmdMaxReqDataSize = req->dataBytes;
+
+ if (cl->largeCmdRequestsSwapProc != NULL) {
+ (*cl->largeCmdRequestsSwapProc)(cl->largeCmdBuf + __GLX_RENDER_LARGE_HDR_SIZE);
+ }
+ else if (cl->largeCmdRequestsSwap_info &&
+ cl->largeCmdRequestsSwap_info->nelems > 0) {
+ if (cl->largeCmdRequestsSwap_info->elem_size == 4) {
+ __GLX_SWAP_INT_ARRAY( (int *)(pc + __GLX_RENDER_LARGE_HDR_SIZE),
+ cl->largeCmdRequestsSwap_info->nelems );
+ }
+ else if (cl->largeCmdRequestsSwap_info->elem_size == 2) {
+ __GLX_SWAP_SHORT_ARRAY( (short *)(pc + __GLX_RENDER_LARGE_HDR_SIZE),
+ cl->largeCmdRequestsSwap_info->nelems );
+ }
+ else if (cl->largeCmdRequestsSwap_info->elem_size == 8) {
+ __GLX_SWAP_DOUBLE_ARRAY( (double *)(pc + __GLX_RENDER_LARGE_HDR_SIZE),
+ cl->largeCmdRequestsSwap_info->nelems );
+ }
+ }
+
+ cl->largeCmdRequestsTotal = 0;
+ return( __glXSendLargeCommand(cl, req->contextTag) );
+
+ }
+ else {
+ cl->largeCmdRequestsTotal = 0;
+ return __glXBadLargeRequest;
+ }
+
+}
+
+/************************************************************************/
+
+/*
+** No support is provided for the vendor-private requests other than
+** allocating these entry points in the dispatch table.
+*/
+
+int __glXSwapVendorPrivate(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateReq *req;
+ CARD32 vendorCode;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ req = (xGLXVendorPrivateReq *) pc;
+ vendorCode = req->vendorCode;
+ __GLX_SWAP_INT(&vendorCode);
+
+
+ switch( vendorCode ) {
+
+ case X_GLvop_DeleteTexturesEXT:
+ return __glXVForwardSingleReqSwap( cl, pc );
+ break;
+
+ case X_GLXvop_SwapIntervalSGI:
+ if (glxIsExtensionSupported("SGI_swap_control")) {
+ return __glXVForwardSingleReqSwap( cl, pc );
+ }
+ else {
+ return Success;
+ }
+ break;
+
+#if 0 /* glx 1.3 */
+ case X_GLXvop_CreateGLXVideoSourceSGIX:
+ break;
+ case X_GLXvop_DestroyGLXVideoSourceSGIX:
+ break;
+ case X_GLXvop_CreateGLXPixmapWithConfigSGIX:
+ break;
+ case X_GLXvop_DestroyGLXPbufferSGIX:
+ break;
+ case X_GLXvop_ChangeDrawableAttributesSGIX:
+ break;
+#endif
+
+ case X_GLXvop_JoinSwapGroupSGIX:
+ return __glXSwapJoinSwapGroupSGIX( cl, pc );
+ break;
+
+ case X_GLXvop_BindSwapBarrierSGIX:
+ return __glXSwapBindSwapBarrierSGIX( cl, pc );
+ break;
+
+ case X_GLXvop_CreateContextWithConfigSGIX:
+ return __glXSwapCreateContextWithConfigSGIX( cl, pc );
+ break;
+
+ default:
+ /*
+ ** unsupported private request
+ */
+ cl->client->errorValue = req->vendorCode;
+ return __glXUnsupportedPrivateRequest;
+ }
+
+}
+
+int __glXSwapVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateWithReplyReq *req;
+ CARD32 vendorCode;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ req = (xGLXVendorPrivateWithReplyReq *) pc;
+ vendorCode = req->vendorCode;
+ __GLX_SWAP_INT(&vendorCode);
+
+ switch( vendorCode ) {
+
+ case X_GLvop_GetConvolutionFilterEXT:
+ case X_GLvop_GetSeparableFilterEXT:
+ case X_GLvop_GetHistogramEXT:
+ case X_GLvop_GetMinmaxEXT:
+ return( __glXNoSuchSingleOpcode(cl, pc) );
+ break;
+
+ case X_GLvop_GetConvolutionParameterfvEXT:
+ case X_GLvop_GetConvolutionParameterivEXT:
+ case X_GLvop_GetHistogramParameterivEXT:
+ case X_GLvop_GetMinmaxParameterfvEXT:
+ case X_GLvop_GetMinmaxParameterivEXT:
+ case X_GLvop_GenTexturesEXT:
+ return( __glXVForwardAllWithReplySwapiv(cl, pc) );
+ break;
+
+ case X_GLvop_AreTexturesResidentEXT:
+ case X_GLvop_IsTextureEXT:
+ return( __glXVForwardPipe0WithReplySwap(cl, pc) );
+ break;
+
+#if 0 /* glx1.3 */
+ case X_GLvop_GetDetailTexFuncSGIS:
+ case X_GLvop_GetSharpenTexFuncSGIS:
+ case X_GLvop_GetColorTableSGI:
+ case X_GLvop_GetColorTableParameterfvSGI:
+ case X_GLvop_GetColorTableParameterivSGI:
+ case X_GLvop_GetTexFilterFuncSGIS:
+ case X_GLvop_GetInstrumentsSGIX:
+ case X_GLvop_InstrumentsBufferSGIX:
+ case X_GLvop_PollInstrumentsSGIX:
+ case X_GLvop_FlushRasterSGIX:
+ case X_GLXvop_CreateGLXPbufferSGIX:
+ case X_GLXvop_GetDrawableAttributesSGIX:
+ case X_GLXvop_QueryHyperpipeNetworkSGIX:
+ case X_GLXvop_QueryHyperpipeConfigSGIX:
+ case X_GLXvop_HyperpipeConfigSGIX:
+ case X_GLXvop_DestroyHyperpipeConfigSGIX:
+#endif
+ case X_GLXvop_QueryMaxSwapBarriersSGIX:
+ return( __glXSwapQueryMaxSwapBarriersSGIX(cl, pc) );
+ break;
+
+ case X_GLXvop_GetFBConfigsSGIX:
+ return( __glXSwapGetFBConfigsSGIX(cl, pc) );
+ break;
+
+ case X_GLXvop_MakeCurrentReadSGI:
+ return( __glXSwapMakeCurrentReadSGI(cl, pc) );
+ break;
+
+ case X_GLXvop_QueryContextInfoEXT:
+ return( __glXSwapQueryContextInfoEXT(cl,(char *)pc) );
+ break;
+
+ default:
+ /*
+ ** unsupported private request
+ */
+ cl->client->errorValue = req->vendorCode;
+ return __glXUnsupportedPrivateRequest;
+ }
+
+}
+
+int __glXSwapGetFBConfigs(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+
+ return __glXGetFBConfigs(cl, pc);
+}
+
+int __glXSwapGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *)pc;
+ xGLXGetFBConfigsReq new_req;
+
+ new_req.reqType = req->reqType;
+ new_req.glxCode = req->glxCode;
+ new_req.length = req->length;
+ new_req.screen = req->screen;
+
+ return( __glXSwapGetFBConfigs( cl, (GLbyte *)&new_req ) );
+}
+
+int __glXSwapCreateWindow(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateWindowReq *req = (xGLXCreateWindowReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->window);
+ __GLX_SWAP_INT(&req->glxwindow);
+ __GLX_SWAP_INT(&req->numAttribs);
+
+ return( __glXCreateWindow( cl, (GLbyte *)pc ) );
+}
+
+int __glXSwapDestroyWindow(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->glxwindow);
+
+ return( __glXDestroyWindow( cl, (GLbyte *)pc ) );
+}
+
+int __glXSwapQueryContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXQueryContextReq *req = (xGLXQueryContextReq *)pc;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->context);
+
+ return( __glXQueryContext(cl, (GLbyte *)pc) );
+
+}
+
+int __glXSwapCreatePbuffer(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *)pc;
+ int nattr = req->numAttribs;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->screen);
+ __GLX_SWAP_INT(&req->fbconfig);
+ __GLX_SWAP_INT(&req->pbuffer);
+ __GLX_SWAP_INT(&req->numAttribs);
+ __GLX_SWAP_INT_ARRAY( (int *)(req+1), nattr*2 );
+
+ return( __glXCreatePbuffer( cl, pc ) );
+}
+
+int __glXSwapDestroyPbuffer(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->pbuffer);
+
+ return( __glXDestroyPbuffer( cl, (GLbyte *)pc ) );
+}
+
+int __glXSwapGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+
+ return( __glXGetDrawableAttributes(cl, pc) );
+}
+
+int __glXSwapChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXChangeDrawableAttributesReq *req = (xGLXChangeDrawableAttributesReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->drawable);
+ __GLX_SWAP_INT(&req->numAttribs);
+ __GLX_SWAP_INT_ARRAY( (int *)(req+1), req->numAttribs * 2 );
+
+ return( __glXChangeDrawableAttributes(cl, pc) );
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxcontext.h b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxcontext.h
new file mode 100644
index 000000000..465101a97
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxcontext.h
@@ -0,0 +1,117 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxcontext.h,v 1.3 2001/03/21 16:29:36 dawes Exp $ */
+#ifndef _GLX_context_h_
+#define _GLX_context_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+typedef struct __GLXcontextRec __GLXcontext;
+
+#include "GL/internal/glcore.h"
+
+struct __GLXcontextRec {
+ /*
+ ** list of context structs
+ */
+ struct __GLXcontextRec *last;
+ struct __GLXcontextRec *next;
+
+ /*
+ ** Pointer to screen info data for this context. This is set
+ ** when the context is created.
+ */
+ ScreenPtr pScreen;
+ __GLXscreenInfo *pGlxScreen;
+
+ /*
+ ** This context is created with respect to this visual.
+ */
+ VisualRec *pVisual;
+ __GLXvisualConfig *pGlxVisual;
+ __GLXFBConfig *pFBConfig;
+
+ /*
+ ** The XID of this context.
+ */
+ XID id;
+ XID *real_ids;
+
+ /*
+ ** The XID of the shareList context.
+ */
+ XID share_id;
+
+ /*
+ ** Visual id.
+ */
+ VisualID vid;
+ VisualID *real_vids;
+
+ /*
+ ** screen number.
+ */
+ GLint screen;
+
+ /*
+ ** Whether this context's ID still exists.
+ */
+ GLboolean idExists;
+
+ /*
+ ** Whether this context is current for some client.
+ */
+ GLboolean isCurrent;
+
+ /*
+ ** Buffers for feedback and selection.
+ */
+ GLfloat *feedbackBuf;
+ GLint feedbackBufSize; /* number of elements allocated */
+ GLuint *selectBuf;
+ GLint selectBufSize; /* number of elements allocated */
+
+ /*
+ ** Set only if current drawable is a glx pixmap.
+ */
+ __GLXpixmap *pGlxPixmap;
+ __GLXpixmap *pGlxReadPixmap;
+ __glXWindow *pGlxWindow;
+ __glXWindow *pGlxReadWindow;
+ __glXPbuffer *pGlxPbuffer;
+ __glXPbuffer *pGlxReadPbuffer;
+
+};
+
+#endif /* !__GLX_context_h__ */
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxdrawable.h b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxdrawable.h
new file mode 100644
index 000000000..6e00ad62f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxdrawable.h
@@ -0,0 +1,124 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxdrawable.h,v 1.3 2001/03/21 16:29:36 dawes Exp $ */
+#ifndef _GLX_drawable_h_
+#define _GLX_drawable_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+typedef struct {
+
+ DrawablePtr pDraw;
+ __GLXvisualConfig *pGlxVisual;
+ __GLXscreenInfo *pGlxScreen;
+ __GLXFBConfig *pFBConfig;
+ ScreenPtr pScreen;
+ Bool idExists;
+ int refcnt;
+ XID *be_xids;
+
+} __GLXpixmap;
+
+struct __GLXdrawablePrivateRec {
+ /*
+ ** list of drawable private structs
+ */
+ struct __GLXdrawablePrivateRec *last;
+ struct __GLXdrawablePrivateRec *next;
+
+ DrawablePtr pDraw;
+ XID drawId;
+ __GLXpixmap *pGlxPixmap;
+
+ /*
+ ** Either DRAWABLE_PIXMAP or DRAWABLE_WINDOW, copied from pDraw above.
+ ** Needed by the resource freer because pDraw might already have been
+ ** freed.
+ */
+ int type;
+
+ /*
+ ** Configuration of the visual to which this drawable was created.
+ */
+ __GLXvisualConfig *pGlxVisual;
+
+ /*
+ ** cached drawable size and origin
+ */
+ GLint xorigin, yorigin;
+ GLint width, height;
+
+ /*
+ ** list of contexts bound to this drawable
+ */
+ struct __GLXcontextRec *glxc;
+
+ /*
+ ** "methods" that the drawble should be able to respond to.
+ */
+ void (*freeBuffers)(struct __GLXdrawablePrivateRec *);
+ void (*updatePalette)(struct __GLXdrawablePrivateRec *);
+ GLboolean (*swapBuffers)(struct __GLXdrawablePrivateRec *);
+
+ /*
+ ** The GL drawable (information shared between GLX and the GL core)
+ */
+ __GLdrawablePrivate glPriv;
+
+ /*
+ ** reference count
+ */
+ int refCount;
+};
+
+typedef struct {
+ DrawablePtr pDraw;
+ int type;
+ Bool idExists;
+ int refcnt; /* contexts bound */
+ __GLXFBConfig *pGlxFBConfig;
+ ScreenPtr pScreen;
+} __glXWindow;
+
+
+typedef struct {
+ __GLXscreenInfo *pGlxScreen;
+ __GLXFBConfig *pFBConfig;
+ ScreenPtr pScreen;
+ Bool idExists;
+ int refcnt;
+ XID *be_xids;
+} __glXPbuffer;
+
+#endif /* !__GLX_drawable_h__ */
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxerror.h b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxerror.h
new file mode 100644
index 000000000..d75cc2b2e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxerror.h
@@ -0,0 +1,58 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxerror.h,v 1.3 2001/03/21 16:29:36 dawes Exp $ */
+#ifndef _GLX_error_h_
+#define _GLX_error_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+/*
+** Error codes. These have the extension error base added to them
+** when the extension initializes.
+*/
+extern int __glXerrorBase;
+extern int __glXBadContext;
+extern int __glXBadContextState;
+extern int __glXBadDrawable;
+extern int __glXBadPixmap;
+extern int __glXBadCurrentWindow;
+extern int __glXBadContextTag;
+extern int __glXBadRenderRequest;
+extern int __glXBadLargeRequest;
+extern int __glXUnsupportedPrivateRequest;
+extern int __glXBadFBConfig;
+extern int __glXBadPbuffer;
+
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxext.c b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxext.c
new file mode 100644
index 000000000..60338230e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxext.c
@@ -0,0 +1,512 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxext.c,v 1.7 2001/03/21 16:29:36 dawes Exp $
+** The contents of this file are subject to the GLX Public License Version 1.0
+** (the "License"). You may not use this file except in compliance with the
+** License. You may obtain a copy of the License at Silicon Graphics, Inc.,
+** attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA 94043
+** or at http://www.sgi.com/software/opensource/glx/license.html.
+**
+** Software distributed under the License is distributed on an "AS IS"
+** basis. ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY
+** IMPLIED WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
+** PURPOSE OR OF NON- INFRINGEMENT. See the License for the specific
+** language governing rights and limitations under the License.
+**
+** The Original Software is GLX version 1.2 source code, released February,
+** 1999. The developer of the Original Software is Silicon Graphics, Inc.
+** Those portions of the Subject Software created by Silicon Graphics, Inc.
+** are Copyright (c) 1991-9 Silicon Graphics, Inc. All Rights Reserved.
+**
+*/
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+
+#define NEED_REPLIES
+#include "glxserver.h"
+#include <windowstr.h>
+#include <propertyst.h>
+#include <os.h>
+#include "g_disptab.h"
+#include "glxutil.h"
+#include "glxext.h"
+#include "glxvisuals.h"
+#include "micmap.h"
+#include "glxswap.h"
+
+/*
+** Forward declarations.
+*/
+static int __glXSwapDispatch(ClientPtr);
+static int __glXDispatch(ClientPtr);
+
+/*
+** Called when the extension is reset.
+*/
+static void ResetExtension(ExtensionEntry* extEntry)
+{
+ __glXFlushContextCache();
+ __glXScreenReset();
+ SwapBarrierReset();
+}
+
+/*
+** Initialize the per-client context storage.
+*/
+static void ResetClientState(int clientIndex)
+{
+ __GLXclientState *cl = __glXClients[clientIndex];
+ Display **keep_be_displays;
+ int i;
+
+ if (cl->returnBuf) __glXFree(cl->returnBuf);
+ if (cl->currentContexts) __glXFree(cl->currentContexts);
+ if (cl->currentDrawables) __glXFree(cl->currentDrawables);
+ if (cl->largeCmdBuf) __glXFree(cl->largeCmdBuf);
+
+ for (i=0; i< screenInfo.numScreens; i++) {
+ if (cl->be_displays[i])
+ XCloseDisplay( cl->be_displays[i] );
+ }
+
+ keep_be_displays = cl->be_displays;
+ __glXMemset(cl, 0, sizeof(__GLXclientState));
+ cl->be_displays = keep_be_displays;
+
+ /*
+ ** By default, assume that the client supports
+ ** GLX major version 1 minor version 0 protocol.
+ */
+ cl->GLClientmajorVersion = 1;
+ cl->GLClientminorVersion = 0;
+ if (cl->GLClientextensions) __glXFree(cl->GLClientextensions);
+
+ __glXMemset(cl->be_displays, 0, screenInfo.numScreens * sizeof(Display *));
+}
+
+
+/*
+** This procedure is called when the client who created the context goes
+** away OR when glXDestroyContext is called. In either case, all we do is
+** flag that the ID is no longer valid, and (maybe) free the context.
+** use.
+*/
+static int ContextGone(__GLXcontext* cx, XID id)
+{
+ cx->idExists = GL_FALSE;
+ if (!cx->isCurrent) {
+ __glXFreeContext(cx);
+ }
+
+ return True;
+}
+
+/*
+** Free a client's state.
+*/
+static int ClientGone(int clientIndex, XID id)
+{
+ __GLXcontext *cx;
+ __GLXclientState *cl = __glXClients[clientIndex];
+ int i;
+
+ if (cl) {
+ /*
+ ** Free all the contexts that are current for this client.
+ */
+ for (i=0; i < cl->numCurrentContexts; i++) {
+ cx = cl->currentContexts[i];
+ if (cx) {
+ cx->isCurrent = GL_FALSE;
+ if (!cx->idExists) {
+ __glXFreeContext(cx);
+ }
+ }
+ }
+ /*
+ ** Re-initialize the client state structure. Don't free it because
+ ** we'll probably get another client with this index and use the struct
+ ** again. There is a maximum of MAXCLIENTS of these structures.
+ */
+ ResetClientState(clientIndex);
+ }
+
+ return True;
+}
+
+/*
+** Free a GLX Pixmap.
+*/
+void __glXFreeGLXPixmap( __GLXpixmap *pGlxPixmap )
+{
+ if (!pGlxPixmap->idExists &&
+ !pGlxPixmap->refcnt) {
+
+ PixmapPtr pPixmap = (PixmapPtr) pGlxPixmap->pDraw;
+
+ /*
+ ** The DestroyPixmap routine should decrement the refcount and free
+ ** only if it's zero.
+ */
+ (*pGlxPixmap->pScreen->DestroyPixmap)(pPixmap);
+ __glXFree(pGlxPixmap->be_xids);
+ __glXFree(pGlxPixmap);
+ }
+
+}
+
+static int PixmapGone(__GLXpixmap *pGlxPixmap, XID id)
+{
+
+ pGlxPixmap->idExists = False;
+ __glXFreeGLXPixmap( pGlxPixmap );
+
+ return True;
+}
+
+void __glXFreeGLXWindow(__glXWindow *pGlxWindow)
+{
+ if (!pGlxWindow->idExists && !pGlxWindow->refcnt) {
+ WindowPtr pWindow = (WindowPtr) pGlxWindow->pDraw;
+
+ if (LookupIDByType(pWindow->drawable.id, RT_WINDOW) == pWindow) {
+ (*pGlxWindow->pScreen->DestroyWindow)(pWindow);
+ }
+
+ xfree(pGlxWindow);
+ }
+}
+
+static void WindowGone(__glXWindow *pGlxWindow, XID id)
+{
+ pGlxWindow->idExists = False;
+ __glXFreeGLXWindow(pGlxWindow);
+}
+
+void __glXFreeGLXPbuffer(__glXPbuffer *pGlxPbuffer)
+{
+ if (!pGlxPbuffer->idExists && !pGlxPbuffer->refcnt) {
+ xfree(pGlxPbuffer->be_xids);
+ xfree(pGlxPbuffer);
+ }
+}
+
+static void PbufferGone(__glXPbuffer *pGlxPbuffer, XID id)
+{
+ pGlxPbuffer->idExists = False;
+ __glXFreeGLXPbuffer(pGlxPbuffer);
+}
+
+/*
+** Free a context.
+*/
+GLboolean __glXFreeContext(__GLXcontext *cx)
+{
+ if (cx->idExists || cx->isCurrent) return GL_FALSE;
+
+ if (cx->feedbackBuf) __glXFree(cx->feedbackBuf);
+ if (cx->selectBuf) __glXFree(cx->selectBuf);
+ if (cx->real_ids) __glXFree(cx->real_ids);
+ if (cx->real_vids) __glXFree(cx->real_vids);
+
+ if (cx->pGlxPixmap) {
+ /*
+ ** The previous drawable was a glx pixmap, release it.
+ */
+ cx->pGlxPixmap->refcnt--;
+ __glXFreeGLXPixmap( cx->pGlxPixmap );
+ cx->pGlxPixmap = 0;
+ }
+
+ if (cx->pGlxReadPixmap) {
+ /*
+ ** The previous drawable was a glx pixmap, release it.
+ */
+ cx->pGlxReadPixmap->refcnt--;
+ __glXFreeGLXPixmap( cx->pGlxReadPixmap );
+ cx->pGlxReadPixmap = 0;
+ }
+
+ if (cx->pGlxWindow) {
+ /*
+ ** The previous drawable was a glx window, release it.
+ */
+ cx->pGlxWindow->refcnt--;
+ __glXFreeGLXWindow( cx->pGlxWindow );
+ cx->pGlxWindow = 0;
+ }
+
+ if (cx->pGlxReadWindow) {
+ /*
+ ** The previous drawable was a glx window, release it.
+ */
+ cx->pGlxReadWindow->refcnt--;
+ __glXFreeGLXWindow( cx->pGlxReadWindow );
+ cx->pGlxReadWindow = 0;
+ }
+
+ __glXFree(cx);
+
+ if (cx == __glXLastContext) {
+ __glXFlushContextCache();
+ }
+
+ return GL_TRUE;
+}
+
+/*
+** Initialize the GLX extension.
+*/
+void GlxExtensionInit(void)
+{
+ ExtensionEntry *extEntry;
+ int i;
+ int glxSupported = 1;
+
+ /*
+ // do not initialize GLX extension if GLX is not supported
+ // by ALL back-end servers.
+ */
+ for (i=0; i<screenInfo.numScreens; i++) {
+ glxSupported &= (dmxScreens[i].glxMajorOpcode > 0);
+ }
+
+ if (!glxSupported || !dmxGLXProxy) {
+ return;
+ }
+
+ __glXContextRes = CreateNewResourceType((DeleteType)ContextGone);
+ __glXClientRes = CreateNewResourceType((DeleteType)ClientGone);
+ __glXPixmapRes = CreateNewResourceType((DeleteType)PixmapGone);
+ __glXWindowRes = CreateNewResourceType((DeleteType)WindowGone);
+ __glXPbufferRes = CreateNewResourceType((DeleteType)PbufferGone);
+
+ /*
+ ** Add extension to server extensions.
+ */
+ extEntry = AddExtension(GLX_EXTENSION_NAME, __GLX_NUMBER_EVENTS,
+ __GLX_NUMBER_ERRORS, __glXDispatch,
+ __glXSwapDispatch, ResetExtension,
+ StandardMinorOpcode);
+ if (!extEntry) {
+ FatalError("__glXExtensionInit: AddExtensions failed\n");
+ return;
+ }
+ /*
+ if (!AddExtensionAlias(GLX_EXTENSION_ALIAS, extEntry)) {
+ ErrorF("__glXExtensionInit: AddExtensionAlias failed\n");
+ return;
+ }
+ */
+
+ __glXerrorBase = extEntry->errorBase;
+ __glXBadContext = extEntry->errorBase + GLXBadContext;
+ __glXBadContextState = extEntry->errorBase + GLXBadContextState;
+ __glXBadDrawable = extEntry->errorBase + GLXBadDrawable;
+ __glXBadPixmap = extEntry->errorBase + GLXBadPixmap;
+ __glXBadContextTag = extEntry->errorBase + GLXBadContextTag;
+ __glXBadCurrentWindow = extEntry->errorBase + GLXBadCurrentWindow;
+ __glXBadRenderRequest = extEntry->errorBase + GLXBadRenderRequest;
+ __glXBadLargeRequest = extEntry->errorBase + GLXBadLargeRequest;
+ __glXUnsupportedPrivateRequest = extEntry->errorBase +
+ GLXUnsupportedPrivateRequest;
+ __glXBadFBConfig = extEntry->errorBase + GLXBadFBConfig;
+ __glXBadPbuffer = extEntry->errorBase + GLXBadPbuffer;
+
+ /*
+ ** Initialize table of client state. There is never a client 0.
+ */
+ for (i=1; i <= MAXCLIENTS; i++) {
+ __glXClients[i] = 0;
+ }
+
+ /*
+ ** Initialize screen specific data.
+ */
+ __glXScreenInit(screenInfo.numScreens);
+
+ /*
+ ** Initialize swap barrier support.
+ */
+ SwapBarrierInit();
+}
+
+/************************************************************************/
+
+Bool __glXCoreType(void)
+{
+ return 0;
+}
+
+/************************************************************************/
+
+void GlxSetVisualConfigs(int nconfigs,
+ __GLXvisualConfig *configs, void **privates)
+{
+ glxSetVisualConfigs(nconfigs, configs, privates);
+}
+
+static miInitVisualsProcPtr saveInitVisualsProc;
+
+Bool GlxInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
+ int *nvisualp, int *ndepthp,
+ int *rootDepthp, VisualID *defaultVisp,
+ unsigned long sizes, int bitsPerRGB,
+ int preferredVis)
+{
+ Bool ret;
+
+ if (saveInitVisualsProc) {
+ ret = saveInitVisualsProc(visualp, depthp, nvisualp, ndepthp,
+ rootDepthp, defaultVisp, sizes, bitsPerRGB,
+ preferredVis);
+ if (!ret)
+ return False;
+ }
+
+ glxInitVisuals(nvisualp, visualp, defaultVisp, *ndepthp, *depthp,*rootDepthp);
+
+ return True;
+}
+
+void
+GlxWrapInitVisuals(miInitVisualsProcPtr *initVisProc)
+{
+ if (dmxGLXProxy) {
+ saveInitVisualsProc = *initVisProc;
+ *initVisProc = GlxInitVisuals;
+ }
+}
+
+/************************************************************************/
+
+void __glXFlushContextCache(void)
+{
+ __glXLastContext = 0;
+}
+
+/************************************************************************/
+
+/*
+** Top level dispatcher; all commands are executed from here down.
+*/
+static int __glXDispatch(ClientPtr client)
+{
+ REQUEST(xGLXSingleReq);
+ CARD8 opcode;
+ int (*proc)(__GLXclientState *cl, GLbyte *pc);
+ __GLXclientState *cl;
+
+ opcode = stuff->glxCode;
+ cl = __glXClients[client->index];
+ if (!cl) {
+ cl = (__GLXclientState *) __glXMalloc(sizeof(__GLXclientState));
+ __glXClients[client->index] = cl;
+ if (!cl) {
+ return BadAlloc;
+ }
+ __glXMemset(cl, 0, sizeof(__GLXclientState));
+
+ cl->be_displays = (Display **) __glXMalloc( screenInfo.numScreens * sizeof(Display *) );
+ if (!cl->be_displays) {
+ __glXFree( cl );
+ return BadAlloc;
+ }
+ __glXMemset(cl->be_displays, 0, screenInfo.numScreens * sizeof(Display *));
+ }
+
+ if (!cl->inUse) {
+ /*
+ ** This is first request from this client. Associate a resource
+ ** with the client so we will be notified when the client dies.
+ */
+ XID xid = FakeClientID(client->index);
+ if (!AddResource( xid, __glXClientRes, (pointer)(long)client->index)) {
+ return BadAlloc;
+ }
+ ResetClientState(client->index);
+ cl->largeCmdRequestsTotal = 0;
+ cl->inUse = GL_TRUE;
+ cl->client = client;
+ }
+
+ /*
+ ** Check for valid opcode.
+ */
+ if (opcode >= __GLX_SINGLE_TABLE_SIZE) {
+ return BadRequest;
+ }
+
+ /*
+ ** Use the opcode to index into the procedure table.
+ */
+ proc = __glXSingleTable[opcode];
+ return (*proc)(cl, (GLbyte *) stuff);
+}
+
+static int __glXSwapDispatch(ClientPtr client)
+{
+ REQUEST(xGLXSingleReq);
+ CARD8 opcode;
+ int (*proc)(__GLXclientState *cl, GLbyte *pc);
+ __GLXclientState *cl;
+
+ opcode = stuff->glxCode;
+ cl = __glXClients[client->index];
+ if (!cl) {
+ cl = (__GLXclientState *) __glXMalloc(sizeof(__GLXclientState));
+ __glXClients[client->index] = cl;
+ if (!cl) {
+ return BadAlloc;
+ }
+ __glXMemset(cl, 0, sizeof(__GLXclientState));
+
+ cl->be_displays = (Display **) __glXMalloc( screenInfo.numScreens * sizeof(Display *) );
+ if (!cl->be_displays) {
+ __glXFree( cl );
+ return BadAlloc;
+ }
+
+ __glXMemset(cl->be_displays, 0, screenInfo.numScreens * sizeof(Display *));
+ }
+
+ if (!cl->inUse) {
+ /*
+ ** This is first request from this client. Associate a resource
+ ** with the client so we will be notified when the client dies.
+ */
+ XID xid = FakeClientID(client->index);
+ if (!AddResource( xid, __glXClientRes, (pointer)(long)client->index)) {
+ return BadAlloc;
+ }
+ ResetClientState(client->index);
+ cl->inUse = GL_TRUE;
+ cl->client = client;
+ }
+
+ /*
+ ** Check for valid opcode.
+ */
+ if (opcode >= __GLX_SINGLE_TABLE_SIZE) {
+ return BadRequest;
+ }
+
+ /*
+ ** Use the opcode to index into the procedure table.
+ */
+ proc = __glXSwapSingleTable[opcode];
+ return (*proc)(cl, (GLbyte *) stuff);
+}
+
+int __glXNoSuchSingleOpcode(__GLXclientState *cl, GLbyte *pc)
+{
+ return BadRequest;
+}
+
+void __glXNoSuchRenderOpcode(GLbyte *pc)
+{
+ return;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxext.h b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxext.h
new file mode 100644
index 000000000..7e6756f86
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxext.h
@@ -0,0 +1,98 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxext.h,v 1.4 2001/03/21 16:29:36 dawes Exp $ */
+#ifndef _glxext_h_
+#define _glxext_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+/*
+ * Added by VA Linux for XFree86 4.0.x
+ */
+typedef struct {
+ int type;
+ void (*resetExtension)(void);
+ Bool (*initVisuals)(
+ VisualPtr * visualp,
+ DepthPtr * depthp,
+ int * nvisualp,
+ int * ndepthp,
+ int * rootDepthp,
+ VisualID * defaultVisp,
+ unsigned long sizes,
+ int bitsPerRGB
+ );
+ void (*setVisualConfigs)(
+ int nconfigs,
+ __GLXvisualConfig *configs,
+ void **privates
+ );
+} __GLXextensionInfo;
+
+extern GLboolean __glXFreeContext(__GLXcontext *glxc);
+extern void __glXFlushContextCache(void);
+
+extern void __glXFreeGLXWindow(__glXWindow *pGlxWindow);
+extern void __glXFreeGLXPixmap( __GLXpixmap *pGlxPixmap );
+
+extern void __glXNoSuchRenderOpcode(GLbyte*);
+extern int __glXNoSuchSingleOpcode(__GLXclientState*, GLbyte*);
+extern void __glXErrorCallBack(__GLinterface *gc, GLenum code);
+extern void __glXClearErrorOccured(void);
+extern GLboolean __glXErrorOccured(void);
+extern void __glXResetLargeCommandStatus(__GLXclientState*);
+
+extern int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc);
+extern int __glXSwapQueryContextInfoEXT(__GLXclientState *cl, char *pc);
+
+extern void GlxExtensionInit(void);
+
+extern Bool __glXCoreType(void);
+
+extern int GlxInitVisuals(
+#if NeedFunctionPrototypes
+ VisualPtr * visualp,
+ DepthPtr * depthp,
+ int * nvisualp,
+ int * ndepthp,
+ int * rootDepthp,
+ VisualID * defaultVisp,
+ unsigned long sizes,
+ int bitsPerRGB,
+ int preferredVis
+#endif
+);
+
+#endif /* _glxext_h_ */
+
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxfbconfig.c b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxfbconfig.c
new file mode 100644
index 000000000..f2321b10c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxfbconfig.c
@@ -0,0 +1,111 @@
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include "glxfbconfig.h"
+
+int AreFBConfigsMatch( __GLXFBConfig *c1, __GLXFBConfig *c2 )
+{
+ int match;
+
+ match = (
+ (c1->visualType == c2->visualType) &&
+ (c1->transparentType == c2->transparentType) &&
+ (c1->transparentRed == c2->transparentRed) &&
+ (c1->transparentGreen == c2->transparentGreen) &&
+ (c1->transparentBlue == c2->transparentBlue) &&
+ (c1->transparentAlpha == c2->transparentAlpha) &&
+ (c1->transparentIndex == c2->transparentIndex) &&
+ (c1->visualCaveat == c2->visualCaveat) &&
+ (c1->drawableType == c2->drawableType) &&
+ (c1->renderType == c2->renderType) &&
+#if 0
+ (c1->maxPbufferWidth == c2->maxPbufferWidth) &&
+ (c1->maxPbufferHeight == c2->maxPbufferHeight) &&
+ (c1->maxPbufferPixels == c2->maxPbufferPixels) &&
+ (c1->optimalPbufferWidth == c2->optimalPbufferWidth) &&
+ (c1->optimalPbufferHeight == c2->optimalPbufferHeight) &&
+#endif
+ (c1->visualSelectGroup == c2->visualSelectGroup) &&
+ (c1->rgbMode == c2->rgbMode) &&
+ (c1->colorIndexMode == c2->colorIndexMode) &&
+ (c1->doubleBufferMode == c2->doubleBufferMode) &&
+ (c1->stereoMode == c2->stereoMode) &&
+ (c1->haveAccumBuffer == c2->haveAccumBuffer) &&
+ (c1->haveDepthBuffer == c2->haveDepthBuffer) &&
+ (c1->haveStencilBuffer == c2->haveStencilBuffer) &&
+ (c1->accumRedBits == c2->accumRedBits) &&
+ (c1->accumGreenBits == c2->accumGreenBits) &&
+ (c1->accumBlueBits == c2->accumBlueBits) &&
+ (c1->accumAlphaBits == c2->accumAlphaBits) &&
+ (c1->depthBits == c2->depthBits) &&
+ (c1->stencilBits == c2->stencilBits) &&
+ (c1->indexBits == c2->indexBits) &&
+ (c1->redBits == c2->redBits) &&
+ (c1->greenBits == c2->greenBits) &&
+ (c1->blueBits == c2->blueBits) &&
+ (c1->alphaBits == c2->alphaBits) &&
+ (c1->redMask == c2->redMask) &&
+ (c1->greenMask == c2->greenMask) &&
+ (c1->blueMask == c2->blueMask) &&
+ (c1->alphaMask == c2->alphaMask) &&
+ (c1->multiSampleSize == c2->multiSampleSize) &&
+ (c1->nMultiSampleBuffers == c2->nMultiSampleBuffers) &&
+ (c1->maxAuxBuffers == c2->maxAuxBuffers) &&
+ (c1->level == c2->level) &&
+ (c1->extendedRange == c2->extendedRange) &&
+ (c1->minRed == c2->minRed) &&
+ (c1->maxRed == c2->maxRed) &&
+ (c1->minGreen == c2->minGreen) &&
+ (c1->maxGreen == c2->maxGreen) &&
+ (c1->minBlue == c2->minBlue) &&
+ (c1->maxBlue == c2->maxBlue) &&
+ (c1->minAlpha == c2->minAlpha) &&
+ (c1->maxAlpha == c2->maxAlpha)
+ );
+
+ return( match );
+}
+
+__GLXFBConfig *FindMatchingFBConfig( __GLXFBConfig *c, __GLXFBConfig *configs, int nconfigs )
+{
+ int i;
+
+ for (i=0; i<nconfigs; i++) {
+ if ( AreFBConfigsMatch( c, configs + i ) )
+ return( configs + i );
+ }
+
+ return(0);
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxfbconfig.h b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxfbconfig.h
new file mode 100644
index 000000000..67df54137
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxfbconfig.h
@@ -0,0 +1,43 @@
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#ifndef _GLXFBCONFIG_H
+
+#include <GL/glxint.h>
+
+int AreFBConfigsMatch( __GLXFBConfig *c1, __GLXFBConfig *c2 );
+__GLXFBConfig *FindMatchingFBConfig( __GLXFBConfig *c, __GLXFBConfig *configs, int nconfigs );
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxscreens.c b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxscreens.c
new file mode 100644
index 000000000..a7d4ce13d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxscreens.c
@@ -0,0 +1,390 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxscreens.c,v 1.6 2001/03/21 16:29:36 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxlog.h"
+
+#undef Xmalloc
+#undef Xcalloc
+#undef Xrealloc
+#undef Xfree
+
+#include "glxserver.h"
+
+#ifdef IN_MODULE
+#include <xf86_ansic.h>
+#else
+#include <string.h>
+#include <signal.h>
+#endif
+
+#include <windowstr.h>
+
+#include "glxfbconfig.h"
+
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+#endif
+
+__GLXscreenInfo *__glXActiveScreens;
+GLint __glXNumActiveScreens;
+
+__GLXFBConfig **__glXFBConfigs;
+int __glXNumFBConfigs;
+
+static char GLXServerVendorName[] = "SGI DMX/glxProxy";
+static char GLXServerVersion[64];
+static char GLXServerExtensions[] =
+ "GLX_EXT_visual_info "
+ "GLX_EXT_visual_rating "
+ "GLX_EXT_import_context "
+ "GLX_SGIX_fbconfig "
+ "GLX_SGI_make_current_read "
+ "GLX_SGI_swap_control "
+ ;
+
+static char ExtensionsString[1024];
+
+static void CalcServerVersionAndExtensions( void )
+{
+ int s;
+ xGLXQueryVersionReq *req;
+ xGLXQueryVersionReply reply;
+ char **be_extensions;
+ char *ext;
+ char *denied_extensions;
+
+ /*
+ * set the server glx version to be the minimum version
+ * supported by all back-end servers
+ */
+ __glXVersionMajor = 0;
+ __glXVersionMinor = 0;
+ for (s=0; s<__glXNumActiveScreens; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = dmxScreen->beDisplay;
+
+ /* Send the glXQueryVersion request */
+ LockDisplay(dpy);
+ GetReq(GLXQueryVersion,req);
+ req->reqType = dmxScreen->glxMajorOpcode;
+ req->glxCode = X_GLXQueryVersion;
+ req->majorVersion = GLX_SERVER_MAJOR_VERSION;
+ req->minorVersion = GLX_SERVER_MINOR_VERSION;
+ _XReply(dpy, (xReply*) &reply, 0, False);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ if (s == 0) {
+ __glXVersionMajor = reply.majorVersion;
+ __glXVersionMinor = reply.minorVersion;
+ }
+ else {
+ if (reply.majorVersion < __glXVersionMajor) {
+ __glXVersionMajor = reply.majorVersion;
+ __glXVersionMinor = reply.minorVersion;
+ }
+ else if ( (reply.majorVersion == __glXVersionMajor) &&
+ (reply.minorVersion < __glXVersionMinor) ) {
+ __glXVersionMinor = reply.minorVersion;
+ }
+ }
+
+ }
+
+ if (GLX_SERVER_MAJOR_VERSION < __glXVersionMajor) {
+ __glXVersionMajor = GLX_SERVER_MAJOR_VERSION;
+ __glXVersionMinor = GLX_SERVER_MINOR_VERSION;
+ }
+ else if ( (GLX_SERVER_MAJOR_VERSION == __glXVersionMajor) &&
+ (GLX_SERVER_MINOR_VERSION < __glXVersionMinor) ) {
+ __glXVersionMinor = GLX_SERVER_MINOR_VERSION;
+ }
+
+ sprintf(GLXServerVersion, "%d.%d DMX %d back-end server(s)",
+ __glXVersionMajor, __glXVersionMinor, __glXNumActiveScreens );
+ /*
+ * set the ExtensionsString to the minimum extensions string
+ */
+ ExtensionsString[0] = '\0';
+
+ /*
+ * read extensions strings of all back-end servers
+ */
+ be_extensions = (char **)Xalloc( __glXNumActiveScreens * sizeof(char *) );
+ if (!be_extensions)
+ return;
+
+ for (s=0; s<__glXNumActiveScreens; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = dmxScreen->beDisplay;
+ xGLXQueryServerStringReq *req;
+ xGLXQueryServerStringReply reply;
+ int length, numbytes, slop;
+
+ /* Send the glXQueryServerString request */
+ LockDisplay(dpy);
+ GetReq(GLXQueryServerString,req);
+ req->reqType = dmxScreen->glxMajorOpcode;
+ req->glxCode = X_GLXQueryServerString;
+ req->screen = DefaultScreen(dpy);
+ req->name = GLX_EXTENSIONS;
+ _XReply(dpy, (xReply*) &reply, 0, False);
+
+ length = (int)reply.length;
+ numbytes = (int)reply.n;
+ slop = numbytes * __GLX_SIZE_INT8 & 3;
+ be_extensions[s] = (char *)Xalloc(numbytes);
+ if (!be_extensions[s]) {
+ /* Throw data on the floor */
+ _XEatData(dpy, length);
+ } else {
+ _XRead(dpy, (char *)be_extensions[s], numbytes);
+ if (slop) _XEatData(dpy,4-slop);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+ /*
+ * extensions string will include only extensions that our
+ * server supports as well as all back-end servers supports.
+ * extensions that are in the DMX_DENY_EXTENSIONS string will
+ * not be supported.
+ */
+ denied_extensions = getenv("DMX_DENY_GLX_EXTENSIONS");
+ ext = strtok(GLXServerExtensions, " ");
+ while( ext ) {
+ int supported = 1;
+
+ if (denied_extensions && strstr(denied_extensions, ext)) {
+ supported = 0;
+ }
+ else {
+ for (s=0; s<__glXNumActiveScreens && supported; s++) {
+ if ( !strstr(be_extensions[s], ext) ) {
+ supported = 0;
+ }
+ }
+ }
+
+ if (supported) {
+ strcat(ExtensionsString, ext);
+ strcat(ExtensionsString, " ");
+ }
+
+ ext = strtok(NULL, " ");
+ }
+
+ /*
+ * release temporary storage
+ */
+ for (s=0; s<__glXNumActiveScreens; s++) {
+ if (be_extensions[s]) Xfree(be_extensions[s]);
+ }
+ Xfree( be_extensions );
+
+ if (dmxGLXSwapGroupSupport) {
+ if (!denied_extensions ||
+ !strstr(denied_extensions, "GLX_SGIX_swap_group")) {
+ strcat(ExtensionsString, "GLX_SGIX_swap_group");
+ if (!denied_extensions ||
+ !strstr(denied_extensions, "GLX_SGIX_swap_barrier")) {
+ strcat(ExtensionsString, " GLX_SGIX_swap_barrier");
+ }
+ }
+ }
+
+}
+
+void __glXScreenInit(GLint numscreens)
+{
+ int s;
+ int c;
+ DMXScreenInfo *dmxScreen0 = &dmxScreens[0];
+ __glXNumActiveScreens = numscreens;
+
+
+ CalcServerVersionAndExtensions();
+
+
+ __glXFBConfigs = NULL;
+ __glXNumFBConfigs = 0;
+
+ if ( (__glXVersionMajor == 1 && __glXVersionMinor >= 3) ||
+ (__glXVersionMajor > 1) ||
+ ( strstr(ExtensionsString, "GLX_SGIX_fbconfig") ) ) {
+
+ /*
+ // Initialize FBConfig info.
+ // find the set of FBConfigs that are present on all back-end
+ // servers - only those configs will be supported
+ */
+ __glXFBConfigs = (__GLXFBConfig **)Xalloc( dmxScreen0->numFBConfigs *
+ (numscreens+1) * sizeof(__GLXFBConfig *) );
+ __glXNumFBConfigs = 0;
+
+ for (c=0; c<dmxScreen0->numFBConfigs; c++) {
+ __GLXFBConfig *cfg = NULL;
+
+ if (numscreens > 1) {
+ for (s=1; s<numscreens; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ __GLXscreenInfo *glxScreen = &__glXActiveScreens[s];
+
+ cfg = FindMatchingFBConfig( &dmxScreen0->fbconfigs[c],
+ dmxScreen->fbconfigs,
+ dmxScreen->numFBConfigs );
+ __glXFBConfigs[ __glXNumFBConfigs * (numscreens+1) + s + 1 ] = cfg;
+ if (!cfg) {
+ dmxLog(dmxInfo,"screen0 FBConfig 0x%x is missing on screen#%d\n", dmxScreen0->fbconfigs[c].id, s);
+ break;
+ }
+ else {
+ dmxLog(dmxInfo,"screen0 FBConfig 0x%x matched to 0x%x on screen#%d\n", dmxScreen0->fbconfigs[c].id, cfg->id, s);
+ }
+ }
+ }
+ else {
+ cfg = &dmxScreen0->fbconfigs[c];
+ }
+
+ if (cfg) {
+
+ /* filter out overlay visuals */
+ if (cfg->level == 0) {
+ __GLXFBConfig *proxy_cfg;
+
+ __glXFBConfigs[ __glXNumFBConfigs * (numscreens+1) + 1 ] =
+ &dmxScreen0->fbconfigs[c];
+
+ proxy_cfg = Xalloc( sizeof(__GLXFBConfig) );
+ memcpy( proxy_cfg, cfg, sizeof(__GLXFBConfig) );
+ proxy_cfg->id = FakeClientID(0);
+ /* visual will be associated later in __glXGetFBConfigs */
+ proxy_cfg->associatedVisualId = (unsigned int)-1;
+
+ __glXFBConfigs[ __glXNumFBConfigs * (numscreens+1) + 0 ] = proxy_cfg;
+
+ __glXNumFBConfigs++;
+ }
+
+ }
+
+ }
+
+ }
+
+}
+
+void __glXScreenReset(void)
+{
+ __glXNumActiveScreens = 0;
+}
+
+char *__glXGetServerString( unsigned int name )
+{
+ char *ret = NULL;
+
+ switch( name) {
+
+ case GLX_VENDOR:
+ ret = GLXServerVendorName;
+ break;
+
+ case GLX_VERSION:
+ ret = GLXServerVersion;
+ break;
+
+ case GLX_EXTENSIONS:
+ ret = ExtensionsString;
+ break;
+
+ default:
+ break;
+ }
+
+ return( ret );
+
+}
+
+
+__GLXFBConfig *glxLookupFBConfig( GLXFBConfigID id )
+{
+ int i,j;
+
+ for (i=0, j=0; i<__glXNumFBConfigs; i++,j+=(__glXNumActiveScreens+1) ) {
+ if ( __glXFBConfigs[j]->id == id)
+ return( __glXFBConfigs[j] );
+ }
+
+ return(NULL);
+}
+
+__GLXFBConfig *glxLookupFBConfigByVID( VisualID vid )
+{
+ int i,j;
+
+ for (i=0, j=0; i<__glXNumFBConfigs; i++,j+=(__glXNumActiveScreens+1) ) {
+ if ( __glXFBConfigs[j]->associatedVisualId == vid)
+ return( __glXFBConfigs[j] );
+ }
+
+ return(NULL);
+}
+
+__GLXFBConfig *glxLookupBackEndFBConfig( GLXFBConfigID id, int screen )
+{
+ int i;
+ int j;
+
+ for (i=0, j=0; i<__glXNumFBConfigs; i++,j+=(__glXNumActiveScreens+1) ) {
+ if ( __glXFBConfigs[j]->id == id)
+ return( __glXFBConfigs[j+screen+1] );
+ }
+
+ return(NULL);
+
+}
+
+int glxIsExtensionSupported( char *ext )
+{
+ return( strstr(ExtensionsString, ext) != NULL );
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxscreens.h b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxscreens.h
new file mode 100644
index 000000000..22d397171
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxscreens.h
@@ -0,0 +1,63 @@
+#ifndef _GLX_screens_h_
+#define _GLX_screens_h_
+
+/* $XFree86: xc/programs/Xserver/GL/glx/glxscreens.h,v 1.4 2001/03/21 16:29:37 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include "GL/internal/glcore.h"
+
+
+
+typedef struct {
+
+ __GLXvisualConfig *pGlxVisual;
+ GLint numVisuals;
+ GLint numGLXVisuals;
+ GLint *isGLXvis;
+
+ char *GLXvendor;
+ char *GLXversion;
+ char *GLXextensions;
+
+} __GLXscreenInfo;
+
+
+extern void __glXScreenInit(GLint);
+extern void __glXScreenReset(void);
+
+extern char *__glXGetServerString( unsigned int name );
+
+#endif /* !__GLX_screens_h__ */
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxserver.h b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxserver.h
new file mode 100644
index 000000000..7db7efef0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxserver.h
@@ -0,0 +1,327 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxserver.h,v 1.3 2001/03/21 16:29:37 dawes Exp $ */
+#ifndef _GLX_server_h_
+#define _GLX_server_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include "dmx.h"
+
+#include <misc.h>
+#include <dixstruct.h>
+#include <pixmapstr.h>
+#include <gcstruct.h>
+#include <extnsionst.h>
+#include <resource.h>
+#include <scrnintstr.h>
+#include "GL/glx_ansic.h"
+
+
+/*
+** The X header misc.h defines these math functions.
+*/
+#undef abs
+#undef fabs
+
+#define GL_GLEXT_PROTOTYPES /* we want prototypes */
+#include <GL/gl.h>
+#include <GL/glxproto.h>
+#include <GL/glxint.h>
+
+/* For glxscreens.h */
+typedef struct __GLXdrawablePrivateRec __GLXdrawablePrivate;
+
+#include "glxscreens.h"
+#include "glxdrawable.h"
+#include "glxcontext.h"
+#include "glxerror.h"
+
+
+#define GLX_SERVER_MAJOR_VERSION 1
+#define GLX_SERVER_MINOR_VERSION 3
+
+#ifndef True
+#define True 1
+#endif
+#ifndef False
+#define False 0
+#endif
+
+/*
+** GLX resources.
+typedef XID GLXContextID;
+typedef XID GLXPixmap;
+typedef XID GLXDrawable;
+typedef XID GLXWindow;
+typedef XID GLXPbuffer;
+
+typedef struct __GLXcontextRec *GLXContext;
+*/
+typedef struct __GLXclientStateRec __GLXclientState;
+
+extern __GLXscreenInfo *__glXActiveScreens;
+extern GLint __glXNumActiveScreens;
+
+/************************************************************************/
+
+/*
+** The last context used (from the server's persective) is cached.
+*/
+extern __GLXcontext *__glXLastContext;
+extern __GLXcontext *__glXForceCurrent(__GLXclientState*, GLXContextTag, int*);
+
+/*
+** Macros to set, unset, and retrieve the flag that says whether a context
+** has unflushed commands.
+*/
+#define __GLX_NOTE_UNFLUSHED_CMDS(glxc) glxc->hasUnflushedCommands = GL_TRUE
+#define __GLX_NOTE_FLUSHED_CMDS(glxc) glxc->hasUnflushedCommands = GL_FALSE
+#define __GLX_HAS_UNFLUSHED_CMDS(glxc) (glxc->hasUnflushedCommands)
+
+/************************************************************************/
+
+typedef struct {
+ int elem_size; /* element size in bytes */
+ int nelems; /* number of elements to swap */
+ void (*swapfunc)(GLbyte *pc);
+} __GLXRenderSwapInfo;
+
+/*
+** State kept per client.
+*/
+struct __GLXclientStateRec {
+ /*
+ ** Whether this structure is currently being used to support a client.
+ */
+ Bool inUse;
+
+ /*
+ ** Buffer for returned data.
+ */
+ GLbyte *returnBuf;
+ GLint returnBufSize;
+
+ /*
+ ** Keep a list of all the contexts that are current for this client's
+ ** threads.
+ */
+ __GLXcontext **currentContexts;
+ DrawablePtr *currentDrawables;
+ GLint numCurrentContexts;
+
+ /* Back pointer to X client record */
+ ClientPtr client;
+
+ int GLClientmajorVersion;
+ int GLClientminorVersion;
+ char *GLClientextensions;
+
+ GLXContextTag *be_currentCTag;
+ Display **be_displays;
+
+ /*
+ ** Keep track of large rendering commands, which span multiple requests.
+ */
+ GLint largeCmdBytesSoFar; /* bytes received so far */
+ GLint largeCmdBytesTotal; /* total bytes expected */
+ GLint largeCmdRequestsSoFar; /* requests received so far */
+ GLint largeCmdRequestsTotal; /* total requests expected */
+ void (*largeCmdRequestsSwapProc)(GLbyte *);
+ __GLXRenderSwapInfo *largeCmdRequestsSwap_info;
+ GLbyte *largeCmdBuf;
+ GLint largeCmdBufSize;
+ GLint largeCmdMaxReqDataSize;
+
+};
+
+extern __GLXclientState *__glXClients[];
+
+/************************************************************************/
+
+/*
+** Dispatch tables.
+*/
+typedef void (*__GLXdispatchRenderProcPtr)(GLbyte *);
+typedef int (*__GLXdispatchSingleProcPtr)(__GLXclientState *, GLbyte *);
+typedef int (*__GLXdispatchVendorPrivProcPtr)(__GLXclientState *, GLbyte *);
+extern __GLXdispatchSingleProcPtr __glXSingleTable[];
+extern __GLXdispatchVendorPrivProcPtr __glXVendorPrivTable_EXT[];
+extern __GLXdispatchSingleProcPtr __glXSwapSingleTable[];
+extern __GLXdispatchVendorPrivProcPtr __glXSwapVendorPrivTable_EXT[];
+extern __GLXdispatchRenderProcPtr __glXSwapRenderTable[];
+
+extern __GLXRenderSwapInfo __glXSwapRenderTable_EXT[];
+
+/*
+ * Dispatch for GLX commands.
+ */
+typedef int (*__GLXprocPtr)(__GLXclientState *, char *pc);
+extern __GLXprocPtr __glXProcTable[];
+
+/*
+ * Tables for computing the size of each rendering command.
+ */
+typedef struct {
+ int bytes;
+ int (*varsize)(GLbyte *pc, Bool swap);
+} __GLXrenderSizeData;
+extern __GLXrenderSizeData __glXRenderSizeTable[];
+extern __GLXrenderSizeData __glXRenderSizeTable_EXT[];
+
+/************************************************************************/
+
+/*
+** X resources.
+*/
+extern RESTYPE __glXContextRes;
+extern RESTYPE __glXClientRes;
+extern RESTYPE __glXPixmapRes;
+extern RESTYPE __glXDrawableRes;
+extern RESTYPE __glXWindowRes;
+extern RESTYPE __glXPbufferRes;
+
+/************************************************************************/
+
+/*
+** Prototypes.
+*/
+
+
+extern char *__glXcombine_strings(const char *, const char *);
+
+extern void __glXDisp_DrawArrays(GLbyte*);
+extern void __glXDispSwap_DrawArrays(GLbyte*);
+
+
+/*
+** Routines for sending swapped replies.
+*/
+
+extern void __glXSwapMakeCurrentReply(ClientPtr client,
+ xGLXMakeCurrentReadSGIReply *reply);
+
+extern void __glXSwapIsDirectReply(ClientPtr client,
+ xGLXIsDirectReply *reply);
+extern void __glXSwapQueryVersionReply(ClientPtr client,
+ xGLXQueryVersionReply *reply);
+extern void __glXSwapQueryContextInfoEXTReply(ClientPtr client,
+ xGLXQueryContextInfoEXTReply *reply,
+ int *buf);
+extern void glxSwapQueryExtensionsStringReply(ClientPtr client,
+ xGLXQueryExtensionsStringReply *reply, char *buf);
+extern void glxSwapQueryServerStringReply(ClientPtr client,
+ xGLXQueryServerStringReply *reply, char *buf);
+extern void __glXSwapQueryContextReply(ClientPtr client,
+ xGLXQueryContextReply *reply, int *buf);
+extern void __glXSwapGetDrawableAttributesReply(ClientPtr client,
+ xGLXGetDrawableAttributesReply *reply, int *buf);
+extern void __glXSwapQueryMaxSwapBarriersSGIXReply(ClientPtr client,
+ xGLXQueryMaxSwapBarriersSGIXReply *reply);
+
+/*
+ * Routines for computing the size of variably-sized rendering commands.
+ */
+
+extern int __glXTypeSize(GLenum enm);
+extern int __glXImageSize(GLenum format, GLenum type, GLsizei w, GLsizei h,
+ GLint rowLength, GLint skipRows, GLint alignment);
+extern int __glXImage3DSize(GLenum format, GLenum type,
+ GLsizei w, GLsizei h, GLsizei d,
+ GLint imageHeight, GLint rowLength,
+ GLint skipImages, GLint skipRows,
+ GLint alignment);
+
+extern int __glXCallListsReqSize(GLbyte *pc, Bool swap);
+extern int __glXBitmapReqSize(GLbyte *pc, Bool swap);
+extern int __glXFogfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXFogivReqSize(GLbyte *pc, Bool swap);
+extern int __glXLightfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXLightivReqSize(GLbyte *pc, Bool swap);
+extern int __glXLightModelfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXLightModelivReqSize(GLbyte *pc, Bool swap);
+extern int __glXMaterialfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXMaterialivReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexParameterfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexParameterivReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexImage1DReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexImage2DReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexEnvfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexEnvivReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexGendvReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexGenfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexGenivReqSize(GLbyte *pc, Bool swap);
+extern int __glXMap1dReqSize(GLbyte *pc, Bool swap);
+extern int __glXMap1fReqSize(GLbyte *pc, Bool swap);
+extern int __glXMap2dReqSize(GLbyte *pc, Bool swap);
+extern int __glXMap2fReqSize(GLbyte *pc, Bool swap);
+extern int __glXPixelMapfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXPixelMapuivReqSize(GLbyte *pc, Bool swap);
+extern int __glXPixelMapusvReqSize(GLbyte *pc, Bool swap);
+extern int __glXDrawPixelsReqSize(GLbyte *pc, Bool swap);
+extern int __glXDrawArraysSize(GLbyte *pc, Bool swap);
+extern int __glXPrioritizeTexturesReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexSubImage1DReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexSubImage2DReqSize(GLbyte *pc, Bool swap);
+extern int __glXTexImage3DReqSize(GLbyte *pc, Bool swap );
+extern int __glXTexSubImage3DReqSize(GLbyte *pc, Bool swap);
+extern int __glXConvolutionFilter1DReqSize(GLbyte *pc, Bool swap);
+extern int __glXConvolutionFilter2DReqSize(GLbyte *pc, Bool swap);
+extern int __glXConvolutionParameterivReqSize(GLbyte *pc, Bool swap);
+extern int __glXConvolutionParameterfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXSeparableFilter2DReqSize(GLbyte *pc, Bool swap);
+extern int __glXColorTableReqSize(GLbyte *pc, Bool swap);
+extern int __glXColorSubTableReqSize(GLbyte *pc, Bool swap);
+extern int __glXColorTableParameterfvReqSize(GLbyte *pc, Bool swap);
+extern int __glXColorTableParameterivReqSize(GLbyte *pc, Bool swap);
+
+/*
+ * Routines for computing the size of returned data.
+ */
+extern int __glXConvolutionParameterivSize(GLenum pname);
+extern int __glXConvolutionParameterfvSize(GLenum pname);
+extern int __glXColorTableParameterfvSize(GLenum pname);
+extern int __glXColorTableParameterivSize(GLenum pname);
+
+extern void __glXFreeGLXWindow(__glXWindow *pGlxWindow);
+extern void __glXFreeGLXPbuffer(__glXPbuffer *pGlxPbuffer);
+
+extern int __glXVersionMajor;
+extern int __glXVersionMinor;
+
+#define __GLX_IS_VERSION_SUPPORTED(major,minor) \
+ ( (__glXVersionMajor > (major)) || \
+ ((__glXVersionMajor == (major)) && (__glXVersionMinor >= (minor))) )
+
+#endif /* !__GLX_server_h__ */
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxsingle.c b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxsingle.c
new file mode 100644
index 000000000..5a8f72736
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxsingle.c
@@ -0,0 +1,1013 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/g_single.c,v 1.4 2001/03/21 16:29:35 dawes Exp $ */
+/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxwindow.h"
+#include "dmxpixmap.h"
+#include "dmxfont.h"
+#include "dmxcb.h"
+
+#undef Xmalloc
+#undef Xcalloc
+#undef Xrealloc
+#undef Xfree
+
+#define NEED_REPLIES
+#include "glxserver.h"
+#include "glxext.h"
+#include "g_disptab.h"
+/* #include "g_disptab_EXT.h" */
+#include "unpack.h"
+#include "glxutil.h"
+
+#include "GL/glxproto.h"
+
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+#endif
+
+/*
+ * GetReqSingle - this is the equivalent of GetReq macro
+ * from Xlibint.h but it does not set the reqType field (the opcode).
+ * this is because the GL single opcodes has different naming convension
+ * the other X opcodes (ie. X_GLsop_GetFloatv).
+ */
+#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
+#define GetReqSingle(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->length = (SIZEOF(x##name##Req))>>2;\
+ dpy->bufptr += SIZEOF(x##name##Req);\
+ dpy->request++
+
+#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
+#define GetReqSingle(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->length = (SIZEOF(x/**/name/**/Req))>>2;\
+ dpy->bufptr += SIZEOF(x/**/name/**/Req);\
+ dpy->request++
+#endif
+
+#define X_GLXSingle 0 /* needed by GetReqExtra */
+
+extern Display *GetBackEndDisplay( __GLXclientState *cl, int s );
+extern int GetCurrentBackEndTag(__GLXclientState *cl, GLXContextTag tag, int s);
+
+static int swap_vec_element_size = 0;
+
+static void SendSwappedReply( ClientPtr client,
+ xGLXSingleReply *reply,
+ char *buf,
+ int buf_size )
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->retval);
+ __GLX_SWAP_INT(&reply->size);
+
+ if ( (buf_size == 0) && (swap_vec_element_size > 0) ) {
+ /*
+ * the reply has single component - need to swap pad3
+ */
+ if (swap_vec_element_size == 2) {
+ __GLX_SWAP_SHORT(&reply->pad3);
+ }
+ else if (swap_vec_element_size == 4) {
+ __GLX_SWAP_INT(&reply->pad3);
+ __GLX_SWAP_INT(&reply->pad4); /* some requests use also pad4
+ * i.e GetConvolutionFilter
+ */
+ }
+ else if (swap_vec_element_size == 8) {
+ __GLX_SWAP_DOUBLE(&reply->pad3);
+ }
+ }
+ else if ( (buf_size > 0) && (swap_vec_element_size > 0) ) {
+ /*
+ * the reply has vector of elements which needs to be swapped
+ */
+ int vsize = buf_size / swap_vec_element_size;
+ char *p = buf;
+ int i;
+
+ for (i=0; i<vsize; i++) {
+ if (swap_vec_element_size == 2) {
+ __GLX_SWAP_SHORT(p);
+ }
+ else if (swap_vec_element_size == 4) {
+ __GLX_SWAP_INT(p);
+ }
+ else if (swap_vec_element_size == 8) {
+ __GLX_SWAP_DOUBLE(p);
+ }
+
+ p += swap_vec_element_size;
+ }
+
+ /*
+ * swap pad words as well - for case that some single reply uses
+ * them as well
+ */
+ __GLX_SWAP_INT(&reply->pad3);
+ __GLX_SWAP_INT(&reply->pad4);
+ __GLX_SWAP_INT(&reply->pad5);
+ __GLX_SWAP_INT(&reply->pad6);
+
+ }
+
+ WriteToClient(client, sizeof(xGLXSingleReply),(char *)reply);
+ if (buf_size > 0)
+ WriteToClient(client, buf_size, (char *)buf);
+
+}
+
+int __glXForwardSingleReq( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ xGLXSingleReq *be_req;
+ __GLXcontext *glxc;
+ int from_screen = 0;
+ int to_screen = 0;
+ int buf_size;
+ int s;
+
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return 0;
+ }
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ pc += sz_xGLXSingleReq;
+ buf_size = (req->length << 2) - sz_xGLXSingleReq;
+
+ /*
+ * just forward the request to back-end server(s)
+ */
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReqSingle(GLXSingle,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = req->glxCode;
+ be_req->length = req->length;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
+ if (buf_size > 0)
+ _XSend(dpy, (const char *)pc, buf_size);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ if (req->glxCode == X_GLsop_Flush) {
+ XFlush(dpy);
+ }
+
+ }
+
+ return Success;
+}
+
+int __glXForwardPipe0WithReply( __GLXclientState *cl, GLbyte *pc )
+{
+ ClientPtr client = cl->client;
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ xGLXSingleReq *be_req;
+ xGLXSingleReply reply;
+ xGLXSingleReply be_reply;
+ __GLXcontext *glxc;
+ int buf_size;
+ char *be_buf;
+ int be_buf_size;
+ DMXScreenInfo *dmxScreen;
+ Display *dpy;
+
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return __glXBadContext;
+ }
+
+ pc += sz_xGLXSingleReq;
+ buf_size = (req->length << 2) - sz_xGLXSingleReq;
+
+ dmxScreen = &dmxScreens[glxc->pScreen->myNum];
+ dpy = GetBackEndDisplay(cl, glxc->pScreen->myNum);
+
+ /*
+ * send the request to the first back-end server
+ */
+ LockDisplay(dpy);
+ GetReqSingle(GLXSingle,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = req->glxCode;
+ be_req->length = req->length;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,glxc->pScreen->myNum);
+ if (buf_size > 0)
+ _XSend(dpy, (const char *)pc, buf_size);
+
+ /*
+ * get the reply from the back-end server
+ */
+ _XReply(dpy, (xReply*) &be_reply, 0, False);
+ be_buf_size = be_reply.length << 2;
+ if (be_buf_size > 0) {
+ be_buf = (char *)Xalloc( be_buf_size );
+ if (be_buf) {
+ _XRead(dpy, be_buf, be_buf_size);
+ }
+ else {
+ /* Throw data on the floor */
+ _XEatData(dpy, be_buf_size);
+ return BadAlloc;
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ /*
+ * send the reply to the client
+ */
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = be_reply.length;
+ reply.retval = be_reply.retval;
+ reply.size = be_reply.size;
+ reply.pad3 = be_reply.pad3;
+ reply.pad4 = be_reply.pad4;
+
+ if (client->swapped) {
+ SendSwappedReply( client, &reply, be_buf, be_buf_size );
+ }
+ else {
+ WriteToClient(client, sizeof(xGLXSingleReply),(char *)&reply);
+ if (be_buf_size > 0)
+ WriteToClient(client, be_buf_size, (char *)be_buf);
+ }
+
+ if (be_buf_size > 0) Xfree(be_buf);
+
+ return Success;
+}
+
+int __glXForwardAllWithReply( __GLXclientState *cl, GLbyte *pc )
+{
+ ClientPtr client = cl->client;
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ xGLXSingleReq *be_req;
+ xGLXSingleReply reply;
+ xGLXSingleReply be_reply;
+ __GLXcontext *glxc;
+ int buf_size;
+ char *be_buf;
+ int be_buf_size;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+
+ DMXScreenInfo *dmxScreen;
+ Display *dpy;
+
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return 0;
+ }
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ pc += sz_xGLXSingleReq;
+ buf_size = (req->length << 2) - sz_xGLXSingleReq;
+
+ /*
+ * send the request to the first back-end server(s)
+ */
+ for (s=to_screen; s>=from_screen; s--) {
+ dmxScreen = &dmxScreens[s];
+ dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReqSingle(GLXSingle,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = req->glxCode;
+ be_req->length = req->length;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
+ if (buf_size > 0)
+ _XSend(dpy, (const char *)pc, buf_size);
+
+ /*
+ * get the reply from the back-end server
+ */
+ _XReply(dpy, (xReply*) &be_reply, 0, False);
+ be_buf_size = be_reply.length << 2;
+ if (be_buf_size > 0) {
+ be_buf = (char *)Xalloc( be_buf_size );
+ if (be_buf) {
+ _XRead(dpy, be_buf, be_buf_size);
+ }
+ else {
+ /* Throw data on the floor */
+ _XEatData(dpy, be_buf_size);
+ return BadAlloc;
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ if (s > from_screen && be_buf_size > 0) {
+ Xfree(be_buf);
+ }
+ }
+
+ /*
+ * send the reply to the client
+ */
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = be_reply.length;
+ reply.retval = be_reply.retval;
+ reply.size = be_reply.size;
+ reply.pad3 = be_reply.pad3;
+ reply.pad4 = be_reply.pad4;
+
+ if (client->swapped) {
+ SendSwappedReply( client, &reply, be_buf, be_buf_size );
+ }
+ else {
+ WriteToClient(client, sizeof(xGLXSingleReply),(char *)&reply);
+ if (be_buf_size > 0)
+ WriteToClient(client, be_buf_size, (char *)be_buf);
+ }
+
+ if (be_buf_size > 0) Xfree(be_buf);
+
+ return Success;
+}
+
+int __glXForwardSingleReqSwap( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 0;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXForwardSingleReq( cl, pc ) );
+}
+
+int __glXForwardPipe0WithReplySwap( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 0;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXForwardPipe0WithReply( cl, pc ) );
+}
+
+int __glXForwardPipe0WithReplySwapsv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 2;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+
+ return( __glXForwardPipe0WithReply( cl, pc ) );
+}
+
+int __glXForwardPipe0WithReplySwapiv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 4;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+
+ return( __glXForwardPipe0WithReply( cl, pc ) );
+}
+
+int __glXForwardPipe0WithReplySwapdv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 8;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+
+ return( __glXForwardPipe0WithReply( cl, pc ) );
+}
+
+int __glXForwardAllWithReplySwap( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 0;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+
+ return( __glXForwardAllWithReply( cl, pc ) );
+}
+
+int __glXForwardAllWithReplySwapsv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 2;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+
+ return( __glXForwardAllWithReply( cl, pc ) );
+}
+
+int __glXForwardAllWithReplySwapiv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 4;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+
+ return( __glXForwardAllWithReply( cl, pc ) );
+}
+
+int __glXForwardAllWithReplySwapdv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 8;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+
+ return( __glXForwardAllWithReply( cl, pc ) );
+}
+
+static GLint __glReadPixels_size(GLenum format, GLenum type, GLint w, GLint h,
+ int *elementbits_return, int *rowbytes_return )
+{
+ GLint elements, esize;
+ GLint rowsize, padding;
+
+ if (w < 0 || h < 0) {
+ return -1;
+ }
+ switch (format) {
+ case GL_COLOR_INDEX:
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_COMPONENT:
+ elements = 1;
+ break;
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ elements = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ elements = 2;
+ break;
+ case GL_RGB:
+ case GL_BGR:
+ elements = 3;
+ break;
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_ABGR_EXT:
+ elements = 4;
+ break;
+ default:
+ return -1;
+ }
+ /*
+ ** According to the GLX protocol, each row must be padded to a multiple of
+ ** 4 bytes. 4 bytes also happens to be the default alignment in the pixel
+ ** store modes of the GL.
+ */
+ switch (type) {
+ case GL_BITMAP:
+ if (format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX) {
+ rowsize = ((w * elements)+7)/8;
+ padding = rowsize % 4;
+ if (padding) {
+ rowsize += 4 - padding;
+ }
+ if (elementbits_return) *elementbits_return = elements;
+ if (rowbytes_return) *rowbytes_return = rowsize;
+ return (rowsize * h);
+ } else {
+ return -1;
+ }
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ esize = 1;
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ esize = 1;
+ elements = 1;
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ esize = 2;
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ esize = 2;
+ elements = 1;
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ esize = 4;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ esize = 4;
+ elements = 1;
+ break;
+ default:
+ return -1;
+ }
+ rowsize = w * elements * esize;
+ padding = rowsize % 4;
+ if (padding) {
+ rowsize += 4 - padding;
+ }
+
+ if (elementbits_return) *elementbits_return = esize*elements*8;
+ if (rowbytes_return) *rowbytes_return = rowsize;
+
+ return (rowsize * h);
+}
+
+static int intersectRect( int x1, int x2, int y1, int y2,
+ int X1, int X2, int Y1, int Y2,
+ int *ix1, int *ix2, int *iy1, int *iy2 )
+{
+ int right = (x2 < X2 ? x2 : X2);
+ int bottom = (y2 < Y2 ? y2 : Y2);
+ int left = (x1 > X1 ? x1 : X1);
+ int top = (y1 > Y1 ? y1 : Y1);
+ int width = right - left + 1;
+ int height = bottom - top + 1;
+
+ if ( (width <= 0) || (height <= 0) ) {
+ *ix1 = *ix2 = *iy1 = *iy2 = 0;
+ return(0);
+ }
+ else {
+ *ix1 = left;
+ *ix2 = right;
+ *iy1 = top;
+ *iy2 = bottom;
+ return( width * height );
+ }
+
+}
+
+int __glXDisp_ReadPixels(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ xGLXSingleReq *be_req;
+ xGLXReadPixelsReply reply;
+ xGLXReadPixelsReply be_reply;
+ GLbyte *be_pc;
+ GLint x,y;
+ GLsizei width, height;
+ GLenum format, type;
+ GLboolean swapBytes, lsbFirst;
+ ClientPtr client = cl->client;
+ DrawablePtr pDraw;
+ int error;
+ __GLXcontext *glxc;
+ int from_screen = 0;
+ int to_screen = 0;
+ char *buf;
+ int buf_size;
+ int s;
+ int win_x1, win_x2;
+ int win_y1, win_y2;
+ int ebits, rowsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ if (client->swapped) {
+ __GLX_SWAP_INT(&req->contextTag);
+ }
+
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return 0;
+ }
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ pc += sz_xGLXSingleReq;
+ x = *(GLint *)(pc + 0);
+ y = *(GLint *)(pc + 4);
+ width = *(GLsizei *)(pc + 8);
+ height = *(GLsizei *)(pc + 12);
+ format = *(GLenum *)(pc + 16);
+ type = *(GLenum *)(pc + 20);
+ swapBytes = *(GLboolean *)(pc + 24);
+ lsbFirst = *(GLboolean *)(pc + 25);
+
+ if (client->swapped) {
+ __GLX_SWAP_INT(&x);
+ __GLX_SWAP_INT(&y);
+ __GLX_SWAP_INT(&width);
+ __GLX_SWAP_INT(&height);
+ __GLX_SWAP_INT(&format);
+ __GLX_SWAP_INT(&type);
+ swapBytes = !swapBytes;
+ }
+
+ buf_size = __glReadPixels_size(format,type,width,height, &ebits, &rowsize);
+ if (buf_size >= 0) {
+ buf = (char *) Xalloc( buf_size );
+ if ( !buf ) {
+ return( BadAlloc );
+ }
+ }
+ else {
+ buf_size = 0;
+ }
+
+ if (buf_size > 0) {
+ /*
+ * Get the current drawable this context is bound to
+ */
+ pDraw = __glXLookupDrawableByTag( cl, req->contextTag );
+ win_x1 = pDraw->x + x;
+ win_x2 = win_x1 + width - 1;
+ win_y1 = (dmxGlobalHeight - pDraw->y - pDraw->height) + y;
+ win_y2 = win_y1 + height - 1;
+ if (pDraw->type != DRAWABLE_WINDOW) {
+ from_screen = to_screen = 0;
+ }
+
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+ int scr_x1 = dmxScreen->rootXOrigin;
+ int scr_x2 = dmxScreen->rootXOrigin + dmxScreen->scrnWidth - 1;
+ int scr_y1 = dmxScreen->rootYOrigin;
+ int scr_y2 = dmxScreen->rootYOrigin + dmxScreen->scrnHeight - 1;
+ int wx1, wx2, wy1, wy2;
+ int sx, sy, sw, sh;
+ int npixels;
+
+ /*
+ * find the window portion that is on the current screen
+ */
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ npixels = intersectRect( scr_x1, scr_x2, scr_y1, scr_y2,
+ win_x1, win_x2, win_y1, win_y2,
+ &wx1, &wx2, &wy1, &wy2 );
+ }
+ else {
+ wx1 = win_x1;
+ wx2 = win_x2;
+ wy1 = win_y1;
+ wy2 = win_y2;
+ npixels = (wx2-wx1+1) * (wy2-wy1+1);
+ }
+
+ if (npixels > 0) {
+
+ /* send the request to the back-end server */
+ LockDisplay(dpy);
+ GetReqExtra(GLXSingle,__GLX_PAD(26),be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLsop_ReadPixels;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
+ be_pc = ((GLbyte *)(be_req) + sz_xGLXSingleReq);
+
+ sx = wx1 - pDraw->x;
+ sy = wy1 - (dmxGlobalHeight - pDraw->y - pDraw->height);
+ sw = (wx2-wx1+1);
+ sh = (wy2-wy1+1);
+
+ *(GLint *)(be_pc + 0) = sx; /* x */
+ *(GLint *)(be_pc + 4) = sy; /* y */
+ *(GLsizei *)(be_pc + 8) = sw; /* width */
+ *(GLsizei *)(be_pc + 12) = sh; /* height */
+ *(GLenum *)(be_pc + 16) = format;
+ *(GLenum *)(be_pc + 20) = type;
+ *(GLboolean *)(be_pc + 24) = swapBytes;
+ *(GLboolean *)(be_pc + 25) = lsbFirst;
+
+ _XReply(dpy, (xReply*) &be_reply, 0, False);
+
+ if (be_reply.length > 0) {
+ char *be_buf;
+ int be_buf_size = be_reply.length << 2;
+
+ be_buf = (char *) Xalloc( be_buf_size );
+ if (be_buf) {
+ _XRead(dpy, be_buf, be_buf_size);
+
+ /* copy pixels data to the right location of the */
+ /* reply buffer */
+ if ( type != GL_BITMAP ) {
+ int pbytes = ebits / 8;
+ char *dst = buf + (sy-y)*rowsize + (sx-x)*pbytes;
+ char *src = be_buf;
+ int pad = (pbytes * sw) % 4;
+ int r;
+
+ for (r=0; r<sh; r++) {
+ memcpy( dst, src, pbytes*sw );
+ dst += rowsize;
+ src += (pbytes*sw + (pad ? 4-pad : 0) );
+ }
+ }
+ else {
+ /* this is a GL_BITMAP pixel type, should copy bits */
+ int r;
+ int src_rowsize = ((sw * ebits) + 7) / 8;
+ int src_pad = src_rowsize % 4;
+ if ( src_pad ) {
+ src_rowsize += (4 - src_pad);
+ }
+
+ for (r=0; r<sh; r++) {
+ unsigned char dst_mask = 0x80 >> (sx % 8);
+ unsigned char src_mask = 0x80;
+ char *dst = buf + (sy-y+r)*rowsize + (sx-x)/8;
+ char *src = be_buf + r*src_rowsize;
+ int b;
+
+ for (b=0; b<sw*ebits; b++) {
+ if ( *src & src_mask ) {
+ *dst |= dst_mask;
+ }
+ else {
+ *dst &= ~dst_mask;
+ }
+
+ if (dst_mask > 1) dst_mask >>= 1;
+ else {
+ dst_mask = 0x80;
+ dst++;
+ }
+
+ if (src_mask > 1) src_mask >>= 1;
+ else {
+ src_mask = 0x80;
+ src++;
+ }
+ }
+ }
+
+ }
+
+ Xfree( be_buf );
+ }
+ else {
+ /* Throw data on the floor */
+ _XEatData(dpy, be_buf_size);
+ Xfree( buf );
+ return BadAlloc;
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ } /* of npixels > 0 */
+
+ } /* of for loop */
+
+ } /* of if buf_size > 0 */
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = buf_size >> 2;
+
+ if (client->swapped) {
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ }
+
+ WriteToClient(client, sizeof(xGLXReadPixelsReply),(char *)&reply);
+ if (buf_size > 0) {
+ WriteToClient(client, buf_size, (char *)buf);
+ Xfree( buf );
+ }
+
+ return Success;
+}
+
+int __glXDispSwap_GetTexImage(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ GLbyte *lpc = pc;
+
+ lpc += sz_xGLXSingleReq;
+ __GLX_SWAP_INT(lpc+0);
+ __GLX_SWAP_INT(lpc+4);
+ __GLX_SWAP_INT(lpc+8);
+ __GLX_SWAP_INT(lpc+12);
+
+ /* reverse swapBytes */
+ *(GLboolean *)(lpc + 16) = ! *(GLboolean *)(lpc + 16);
+
+ return( __glXForwardPipe0WithReplySwap( cl, pc ) );
+}
+
+int __glXDispSwap_GetColorTable(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ GLbyte *lpc = pc;
+
+ lpc += sz_xGLXSingleReq;
+ __GLX_SWAP_INT(lpc+0);
+ __GLX_SWAP_INT(lpc+4);
+ __GLX_SWAP_INT(lpc+8);
+
+ /* reverse swapBytes */
+ *(GLboolean *)(lpc + 12) = ! *(GLboolean *)(lpc + 12);
+
+ return( __glXForwardPipe0WithReplySwap( cl, pc ) );
+}
+
+
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxsingle.h b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxsingle.h
new file mode 100644
index 000000000..a21d38f84
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxsingle.h
@@ -0,0 +1,59 @@
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#ifndef __GLXSINGLE_H
+#define __GLXSINGLE_H
+
+extern int __glXForwardSingleReq( __GLXclientState *cl, GLbyte *pc );
+extern int __glXForwardPipe0WithReply( __GLXclientState *cl, GLbyte *pc );
+extern int __glXForwardAllWithReply( __GLXclientState *cl, GLbyte *pc );
+
+extern int __glXForwardSingleReqSwap( __GLXclientState *cl, GLbyte *pc );
+
+extern int __glXForwardPipe0WithReplySwap( __GLXclientState *cl, GLbyte *pc );
+extern int __glXForwardPipe0WithReplySwapsv( __GLXclientState *cl, GLbyte *pc );
+extern int __glXForwardPipe0WithReplySwapiv( __GLXclientState *cl, GLbyte *pc );
+extern int __glXForwardPipe0WithReplySwapdv( __GLXclientState *cl, GLbyte *pc );
+
+extern int __glXForwardAllWithReplySwap( __GLXclientState *cl, GLbyte *pc );
+extern int __glXForwardAllWithReplySwapsv( __GLXclientState *cl, GLbyte *pc );
+extern int __glXForwardAllWithReplySwapiv( __GLXclientState *cl, GLbyte *pc );
+extern int __glXForwardAllWithReplySwapdv( __GLXclientState *cl, GLbyte *pc );
+
+extern int __glXDisp_ReadPixels(__GLXclientState *cl, GLbyte *pc);
+extern int __glXDispSwap_GetTexImage(__GLXclientState *cl, GLbyte *pc);
+extern int __glXDispSwap_GetColorTable(__GLXclientState *cl, GLbyte *pc);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxswap.c b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxswap.c
new file mode 100644
index 000000000..f7fcc37ac
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxswap.c
@@ -0,0 +1,539 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003 Red Hat Inc., Raleigh, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxwindow.h"
+#include "glxserver.h"
+#include "glxswap.h"
+
+extern int __glXDoSwapBuffers(__GLXclientState *cl, XID drawId,
+ GLXContextTag tag);
+
+typedef struct _SwapGroup *SwapGroupPtr;
+
+static Bool SwapBarrierIsReadyToSwap(GLuint barrier);
+static void SwapSwapBarrier(GLuint barrier);
+static void UpdateSwapBarrierList(GLuint barrier,
+ SwapGroupPtr pOldSwap,
+ SwapGroupPtr pNewSwap);
+
+
+/************************************************************************
+ *
+ * Swap Groups
+ *
+ ************************************************************************/
+
+typedef struct _SwapGroup {
+ WindowPtr pWin;
+ SwapGroupPtr pNext;
+
+ Bool swapping;
+ Bool sleeping;
+ GLuint barrier;
+
+ XID drawable;
+ GLXContextTag tag;
+ __GLXclientState *clState;
+} SwapGroupRec;
+
+
+static void SwapSwapGroup(SwapGroupPtr pSwap)
+{
+ SwapGroupPtr pCur;
+
+ /* All drawables in swap group are ready to swap, so just swap all
+ * drawables buffers and then wake up those clients that were
+ * previously sleeping */
+
+ for (pCur = pSwap; pCur; pCur = pCur->pNext) {
+ if (pCur->swapping) {
+ /* Swap pCur's buffers */
+ __glXDoSwapBuffers(pCur->clState, pCur->drawable, pCur->tag);
+ pCur->swapping = FALSE;
+ }
+
+ /* Wakeup client */
+ if (pCur->sleeping) {
+ ClientWakeup(pCur->clState->client);
+ pCur->sleeping = FALSE;
+ }
+ }
+}
+
+static Bool SwapGroupIsReadyToSwap(SwapGroupPtr pSwap)
+{
+ Bool isReady = TRUE;
+
+ /* The swap group is ready to swap when all drawables are ready to
+ * swap. NOTE: A drawable is also ready to swap if it is not
+ * currently mapped */
+ for (; pSwap; pSwap = pSwap->pNext) {
+ isReady &= (pSwap->swapping || !pSwap->pWin->mapped);
+ /* FIXME: Should we use pSwap->pWin->mapped or ...->realized ??? */
+ }
+
+ return isReady;
+}
+
+static Bool SGSwapCleanup(ClientPtr client, pointer closure)
+{
+ /* SwapGroupPtr pSwap = (SwapGroupPtr)closure; */
+
+ /* This should not be called unless the client has died in which
+ * case we should remove the buffer from the swap list */
+
+ return TRUE;
+}
+
+int SGSwapBuffers(__GLXclientState *cl, XID drawId, GLXContextTag tag,
+ DrawablePtr pDraw)
+{
+ WindowPtr pWin = (WindowPtr)pDraw;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWin);
+ SwapGroupPtr pSwap = pWinPriv->swapGroup;
+ SwapGroupPtr pCur;
+
+ for (pCur = pSwap; pCur && pCur->pWin != pWin; pCur = pCur->pNext);
+ if (!pCur)
+ return BadDrawable;
+
+ pCur->clState = cl;
+ pCur->drawable = drawId;
+ pCur->tag = tag;
+
+ /* We are now in the process of swapping */
+ pCur->swapping = TRUE;
+
+ if (pSwap->barrier && SwapBarrierIsReadyToSwap(pSwap->barrier)) {
+ /* The swap group is bound to a barrier and the barrier is ready
+ * to swap, so swap all the swap groups that are bound to this
+ * group's swap barrier */
+ SwapSwapBarrier(pSwap->barrier);
+ } else if (!pSwap->barrier && SwapGroupIsReadyToSwap(pSwap)) {
+ /* Do the swap if the entire swap group is ready to swap and the
+ * group is not bound to a swap barrier */
+ SwapSwapGroup(pSwap);
+ } else {
+ /* The swap group/barrier is not yet ready to swap, so put
+ * client to sleep until the rest are ready to swap */
+ ClientSleep(cl->client, SGSwapCleanup, (pointer)pWin);
+ pCur->sleeping = TRUE;
+ }
+
+ return Success;
+}
+
+static void SGWindowUnmapped(WindowPtr pWin)
+{
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWin);
+ SwapGroupPtr pSwap = pWinPriv->swapGroup;
+
+ /* Now that one of the windows in the swap group has been unmapped,
+ * see if the entire swap group/barrier is ready to swap */
+
+ if (pSwap->barrier && SwapBarrierIsReadyToSwap(pSwap->barrier)) {
+ SwapSwapBarrier(pSwap->barrier);
+ } else if (!pSwap->barrier && SwapGroupIsReadyToSwap(pSwap)) {
+ SwapSwapGroup(pSwap);
+ }
+}
+
+static void SGWindowDestroyed(WindowPtr pWin)
+{
+ JoinSwapGroupSGIX((DrawablePtr)pWin, NULL);
+}
+
+static SwapGroupPtr CreateSwapEntry(WindowPtr pWin)
+{
+ SwapGroupPtr pEntry;
+
+ /* Allocate new swap group */
+ pEntry = xalloc(sizeof(*pEntry));
+ if (!pEntry) return NULL;
+
+ /* Initialize swap group */
+ pEntry->pWin = pWin;
+ pEntry->pNext = NULL;
+ pEntry->swapping = FALSE;
+ pEntry->sleeping = FALSE;
+ pEntry->barrier = 0;
+ /* The following are not initialized until SwapBuffers is called:
+ * pEntry->drawable
+ * pEntry->tag
+ * pEntry->clState
+ */
+
+ return pEntry;
+}
+
+static void FreeSwapEntry(SwapGroupPtr pEntry)
+{
+ /* Since we have removed the drawable from its previous swap group
+ * and it won't be added to another swap group, the only thing that
+ * we need to do is to make sure that the drawable's client is not
+ * sleeping. This could happen if one thread is sleeping, while
+ * another thread called glxJoinSwapGroup(). Note that all sleeping
+ * threads should also be swapping, but there is a small window in
+ * the SGSwapBuffer() logic, above, where swapping can be set but
+ * sleeping is not. We check both independently here just to be
+ * pedantic. */
+
+ /* Handle swap buffer request */
+ if (pEntry->swapping)
+ __glXDoSwapBuffers(pEntry->clState, pEntry->drawable, pEntry->tag);
+
+ /* Wake up client */
+ if (pEntry->sleeping)
+ ClientWakeup(pEntry->clState->client);
+
+ /* We can free the pEntry entry since it has already been removed
+ * from the swap group list and it won't be needed any longer */
+ xfree(pEntry);
+}
+
+int JoinSwapGroupSGIX(DrawablePtr pDraw, DrawablePtr pMember)
+{
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ WindowPtr pWin = (WindowPtr)pDraw;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWin);
+ SwapGroupPtr pOldSwap = NULL;
+ SwapGroupPtr pEntry;
+
+ /* If pDraw and pMember are already members of the same swap
+ * group, just return Success since there is nothing to do */
+ for (pEntry = pWinPriv->swapGroup; pEntry; pEntry = pEntry->pNext)
+ if (pEntry->pWin == (WindowPtr)pMember)
+ return Success;
+
+ /* Remove pDraw from its current swap group */
+ if (pWinPriv->swapGroup) {
+ SwapGroupPtr pSwapGroup = pWinPriv->swapGroup;
+ SwapGroupPtr pPrev;
+
+ /* Find old swap entry in swap group and save in pOldSwap
+ * for later use */
+ for (pOldSwap = pWinPriv->swapGroup, pPrev = NULL;
+ pOldSwap && pOldSwap->pWin != pWin;
+ pPrev = pOldSwap, pOldSwap = pOldSwap->pNext);
+ if (!pOldSwap)
+ return BadDrawable;
+
+ /* Remove pDraw's swap group entry from swap group list */
+ if (pPrev) {
+ pPrev->pNext = pOldSwap->pNext;
+ } else {
+ /* pWin is at the head of the swap group list, so we
+ * need to update all other members of this swap
+ * group */
+ for (pEntry = pOldSwap->pNext; pEntry; pEntry = pEntry->pNext)
+ DMX_GET_WINDOW_PRIV(pEntry->pWin)->swapGroup
+ = pOldSwap->pNext;
+
+ /* Update the barrier list as well */
+ if (pOldSwap->barrier)
+ UpdateSwapBarrierList(pOldSwap->barrier,
+ pOldSwap, pOldSwap->pNext);
+
+ /* Set pSwapGroup to point to the swap group without
+ * pOldSwap */
+ pSwapGroup = pOldSwap->pNext;
+ }
+
+ /* Check to see if current swap group can now swap since we
+ * know at this point that pDraw and pMember are guaranteed
+ * to previously be in different swap groups */
+ if (pSwapGroup && SwapGroupIsReadyToSwap(pSwapGroup)) {
+ SwapSwapGroup(pSwapGroup);
+ }
+
+ /* Make the old swap entry a standalone group */
+ pOldSwap->pNext = NULL;
+ pOldSwap->barrier = 0;
+
+ /* Reset pWin's swap group */
+ pWinPriv->swapGroup = NULL;
+ pWinPriv->windowDestroyed = NULL;
+ pWinPriv->windowUnmapped = NULL;
+ }
+
+ if (!pMember || pMember->type != DRAWABLE_WINDOW) {
+ /* Free old swap group since it is no longer needed */
+ if (pOldSwap) FreeSwapEntry(pOldSwap);
+ } else if (pDraw == pMember && pOldSwap) {
+ /* Special case where pDraw was previously created and we
+ * are now just putting it to its own swap group */
+ pWinPriv->swapGroup = pOldSwap;
+ pWinPriv->windowDestroyed = SGWindowDestroyed;
+ pWinPriv->windowUnmapped = SGWindowUnmapped;
+
+ /* Check to see if pDraw is ready to swap */
+ if (SwapGroupIsReadyToSwap(pOldSwap))
+ SwapSwapGroup(pOldSwap);
+ } else if (pMember->type == DRAWABLE_WINDOW) {
+ WindowPtr pMemberWin = (WindowPtr)pMember;
+ dmxWinPrivPtr pMemberPriv = DMX_GET_WINDOW_PRIV(pMemberWin);
+ SwapGroupPtr pMemberSwapGroup = pMemberPriv->swapGroup;
+
+ /* Finally, how we can add pDraw to pMember's swap group */
+
+ /* If pMember is not currently in a swap group, then create
+ * one for it since we are just about to add pDraw to it. */
+ if (!pMemberSwapGroup) {
+ /* Create new swap group */
+ pMemberSwapGroup = CreateSwapEntry(pMemberWin);
+ if (!pMemberSwapGroup) {
+ if (pOldSwap) FreeSwapEntry(pOldSwap);
+ return BadAlloc;
+ }
+
+ /* Set pMember's swap group */
+ pMemberPriv->swapGroup = pMemberSwapGroup;
+ pMemberPriv->windowDestroyed = SGWindowDestroyed;
+ pMemberPriv->windowUnmapped = SGWindowUnmapped;
+ }
+
+ /* If pDraw == pMember, that means pDraw was not a member of
+ * a group previously (or it would have been handled by the
+ * special case above), so no additional work is required
+ * since we just created a new swap group for pMember (i.e.,
+ * pDraw). */
+
+ if (pDraw != pMember) {
+ /* If pDraw was not previously in a swap group, then create
+ * an entry for it */
+ if (!pOldSwap) {
+ /* Create new swap group */
+ pOldSwap = CreateSwapEntry(pWin);
+ if (!pOldSwap) {
+ /* If we just created a swap group for pMember, we
+ * need to free it here */
+ if (pMemberSwapGroup->pNext == NULL) {
+ FreeSwapEntry(pMemberSwapGroup);
+ pMemberPriv->swapGroup = NULL;
+ }
+ return BadAlloc;
+ }
+ }
+
+ /* Find last entry in pMember's swap group */
+ for (pEntry = pMemberSwapGroup;
+ pEntry->pNext;
+ pEntry = pEntry->pNext);
+
+ /* Add pDraw's swap group entry to pMember's swap group list */
+ pEntry->pNext = pOldSwap;
+
+ /* Add pDraw to pMember's swap barrier */
+ pOldSwap->barrier = pEntry->barrier;
+
+ /* Set pDraw's swap group */
+ pWinPriv->swapGroup = pMemberSwapGroup;
+ pWinPriv->windowDestroyed = SGWindowDestroyed;
+ pWinPriv->windowUnmapped = SGWindowUnmapped;
+ }
+ }
+ }
+
+ return Success;
+}
+
+
+/************************************************************************
+ *
+ * Swap Barriers
+ *
+ ************************************************************************/
+
+#define GLX_MAX_SWAP_BARRIERS 10
+
+typedef struct _SwapBarrier *SwapBarrierPtr;
+typedef struct _SwapBarrier {
+ SwapGroupPtr pSwap;
+ SwapBarrierPtr pNext;
+} SwapBarrierRec;
+
+static SwapBarrierPtr SwapBarrierList[GLX_MAX_SWAP_BARRIERS+1];
+
+void SwapBarrierInit(void)
+{
+ int i;
+
+ for (i = 0; i <= GLX_MAX_SWAP_BARRIERS; i++)
+ SwapBarrierList[i] = NULL;
+}
+
+void SwapBarrierReset(void)
+{
+ int i;
+
+ for (i = 0; i <= GLX_MAX_SWAP_BARRIERS; i++) {
+ SwapBarrierPtr pBarrier, pNextBarrier;;
+ for (pBarrier = SwapBarrierList[i];
+ pBarrier;
+ pBarrier = pNextBarrier) {
+ pNextBarrier = pBarrier->pNext;
+ xfree(pBarrier);
+ }
+ SwapBarrierList[i] = NULL;
+ }
+}
+
+int QueryMaxSwapBarriersSGIX(int screen)
+{
+ return GLX_MAX_SWAP_BARRIERS;
+}
+
+static Bool BindSwapGroupToBarrier(GLuint barrier, SwapGroupPtr pSwapGroup)
+{
+ SwapBarrierPtr pBarrier;
+
+ pBarrier = xalloc(sizeof(*pBarrier));
+ if (!pBarrier) return FALSE;
+
+ /* Add the swap group to barrier's list */
+ pBarrier->pSwap = pSwapGroup;
+ pBarrier->pNext = SwapBarrierList[barrier];
+ SwapBarrierList[barrier] = pBarrier;
+
+ return TRUE;
+}
+
+static Bool UnbindSwapGroupFromBarrier(GLuint barrier, SwapGroupPtr pSwapGroup)
+{
+ SwapBarrierPtr pBarrier, pPrevBarrier;
+
+ /* Find the swap group in barrier's list */
+ for (pBarrier = SwapBarrierList[barrier], pPrevBarrier = NULL;
+ pBarrier && pBarrier->pSwap != pSwapGroup;
+ pPrevBarrier = pBarrier, pBarrier = pBarrier->pNext);
+ if (!pBarrier) return FALSE;
+
+ /* Remove the swap group from barrier's list */
+ if (pPrevBarrier) pPrevBarrier->pNext = pBarrier->pNext;
+ else SwapBarrierList[barrier] = pBarrier->pNext;
+
+ /* Free memory */
+ xfree(pBarrier);
+
+ return TRUE;
+}
+
+static void UpdateSwapBarrierList(GLuint barrier,
+ SwapGroupPtr pOldSwap,
+ SwapGroupPtr pNewSwap)
+{
+ SwapBarrierPtr pBarrier;
+
+ /* If the old swap group is being destroyed, then we need to remove
+ * the swap group from the list entirely */
+ if (!pNewSwap) {
+ UnbindSwapGroupFromBarrier(barrier, pOldSwap);
+ return;
+ }
+
+ /* Otherwise, find the old swap group in the barrier list and change
+ * it to the new swap group */
+ for (pBarrier = SwapBarrierList[barrier];
+ pBarrier;
+ pBarrier = pBarrier->pNext) {
+ if (pBarrier->pSwap == pOldSwap) {
+ pBarrier->pSwap = pNewSwap;
+ return;
+ }
+ }
+}
+
+static Bool SwapBarrierIsReadyToSwap(GLuint barrier)
+{
+ SwapBarrierPtr pBarrier;
+ Bool isReady = TRUE;
+
+ /* The swap barier is ready to swap when swap groups that are bound
+ * to barrier are ready to swap */
+ for (pBarrier = SwapBarrierList[barrier];
+ pBarrier;
+ pBarrier = pBarrier->pNext)
+ isReady &= SwapGroupIsReadyToSwap(pBarrier->pSwap);
+
+ return isReady;
+}
+
+static void SwapSwapBarrier(GLuint barrier)
+{
+ SwapBarrierPtr pBarrier;
+
+ /* Swap each group that is a member of this barrier */
+ for (pBarrier = SwapBarrierList[barrier];
+ pBarrier;
+ pBarrier = pBarrier->pNext)
+ SwapSwapGroup(pBarrier->pSwap);
+}
+
+int BindSwapBarrierSGIX(DrawablePtr pDraw, int barrier)
+{
+ /* FIXME: Check for errors when pDraw->type != DRAWABLE_WINDOW */
+
+ if (barrier < 0 || barrier > GLX_MAX_SWAP_BARRIERS)
+ return BadValue;
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ WindowPtr pWin = (WindowPtr)pDraw;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWin);
+ SwapGroupPtr pSwapGroup = pWinPriv->swapGroup;
+ SwapGroupPtr pCur;
+
+ if (!pSwapGroup) return BadDrawable;
+ if (barrier && pSwapGroup->barrier) return BadValue;
+
+ /* Update the swap barrier list */
+ if (barrier) {
+ if (!BindSwapGroupToBarrier(barrier, pSwapGroup))
+ return BadAlloc;
+ } else {
+ if (!UnbindSwapGroupFromBarrier(pSwapGroup->barrier, pSwapGroup))
+ return BadDrawable;
+ }
+
+ /* Set the barrier for each member of this swap group */
+ for (pCur = pSwapGroup; pCur; pCur = pCur->pNext)
+ pCur->barrier = barrier;
+ }
+
+ return Success;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxswap.h b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxswap.h
new file mode 100644
index 000000000..95c433381
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxswap.h
@@ -0,0 +1,47 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003 Red Hat Inc., Raleigh, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+#ifndef __GLX_swap_h__
+#define __GLX_swap_h__
+
+extern int JoinSwapGroupSGIX(DrawablePtr pDraw, DrawablePtr pMember);
+extern int SGSwapBuffers(__GLXclientState *cl, XID drawId, GLXContextTag tag,
+ DrawablePtr pDraw);
+
+extern void SwapBarrierInit(void);
+extern void SwapBarrierReset(void);
+extern int QueryMaxSwapBarriersSGIX(int screen);
+extern int BindSwapBarrierSGIX(DrawablePtr pDraw, int barrier);
+
+#endif /* !__GLX_swap_h__ */
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxutil.c b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxutil.c
new file mode 100644
index 000000000..822ef25a0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxutil.c
@@ -0,0 +1,121 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxutil.c,v 1.5 2001/03/21 16:29:37 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define NEED_REPLIES
+#define FONT_PCF
+#include "glxserver.h"
+#include <GL/glxtokens.h>
+#include <pixmapstr.h>
+#include <windowstr.h>
+#include "glxutil.h"
+#include "GL/glx_ansic.h"
+
+/************************************************************************/
+
+void __glXNop(void) {}
+
+/************************************************************************/
+
+/* Memory Allocation for GLX */
+
+void *
+__glXMalloc(size_t size)
+{
+ void *addr;
+
+ if (size == 0) {
+ return NULL;
+ }
+ addr = (void *) xalloc(size);
+ if (addr == NULL) {
+ /* XXX: handle out of memory error */
+ return NULL;
+ }
+ return addr;
+}
+
+void *
+__glXCalloc(size_t numElements, size_t elementSize)
+{
+ void *addr;
+ size_t size;
+
+ if ((numElements == 0) || (elementSize == 0)) {
+ return NULL;
+ }
+ size = numElements * elementSize;
+ addr = (void *) xalloc(size);
+ if (addr == NULL) {
+ /* XXX: handle out of memory error */
+ return NULL;
+ }
+ __glXMemset(addr, 0, size);
+ return addr;
+}
+
+void *
+__glXRealloc(void *addr, size_t newSize)
+{
+ void *newAddr;
+
+ if (addr) {
+ if (newSize == 0) {
+ xfree(addr);
+ return NULL;
+ } else {
+ newAddr = xrealloc(addr, newSize);
+ }
+ } else {
+ if (newSize == 0) {
+ return NULL;
+ } else {
+ newAddr = xalloc(newSize);
+ }
+ }
+ if (newAddr == NULL) {
+ return NULL; /* XXX: out of memory */
+ }
+
+ return newAddr;
+}
+
+void
+__glXFree(void *addr)
+{
+ if (addr) {
+ xfree(addr);
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxutil.h b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxutil.h
new file mode 100644
index 000000000..176444ee9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxutil.h
@@ -0,0 +1,54 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/glxutil.h,v 1.3 2001/03/21 16:29:37 dawes Exp $ */
+#ifndef _glxcmds_h_
+#define _glxcmds_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+extern void __glXNop(void);
+
+/* memory management */
+extern void *__glXMalloc(size_t size);
+extern void *__glXCalloc(size_t numElements, size_t elementSize);
+extern void *__glXRealloc(void *addr, size_t newSize);
+extern void __glXFree(void *ptr);
+
+/* context helper routines */
+extern __GLXcontext *__glXLookupContextByTag(__GLXclientState*, GLXContextTag);
+extern DrawablePtr __glXLookupDrawableByTag(__GLXclientState *cl, GLXContextTag tag);
+
+
+#endif /* _glxcmds_h_ */
+
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvendor.c b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvendor.c
new file mode 100644
index 000000000..4259974f9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvendor.c
@@ -0,0 +1,583 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/g_single.c,v 1.4 2001/03/21 16:29:35 dawes Exp $ */
+/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxwindow.h"
+#include "dmxpixmap.h"
+#include "dmxfont.h"
+
+#undef Xmalloc
+#undef Xcalloc
+#undef Xrealloc
+#undef Xfree
+
+#define NEED_REPLIES
+#include "glxserver.h"
+#include "glxext.h"
+#include "g_disptab.h"
+/* #include "g_disptab_EXT.h" */
+#include "unpack.h"
+#include "glxutil.h"
+
+#include "GL/glxproto.h"
+
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+#endif
+
+/*
+ * GetReqVendorPrivate - this is the equivalent of GetReq macro
+ * from Xlibint.h but it does not set the reqType field (the opcode).
+ * this is because the GL single opcodes has different naming convension
+ * the other X opcodes (ie. X_GLsop_GetFloatv).
+ */
+#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
+#define GetReqVendorPrivate(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->length = (SIZEOF(x##name##Req))>>2;\
+ dpy->bufptr += SIZEOF(x##name##Req);\
+ dpy->request++
+
+#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
+#define GetReqVendorPrivate(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->length = (SIZEOF(x/**/name/**/Req))>>2;\
+ dpy->bufptr += SIZEOF(x/**/name/**/Req);\
+ dpy->request++
+#endif
+
+extern Display *GetBackEndDisplay( __GLXclientState *cl, int s );
+extern int GetCurrentBackEndTag(__GLXclientState *cl, GLXContextTag tag, int s);
+
+static int swap_vec_element_size = 0;
+
+static void SendSwappedReply( ClientPtr client,
+ xGLXVendorPrivReply *reply,
+ char *buf,
+ int buf_size )
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->retval);
+ __GLX_SWAP_INT(&reply->size);
+
+ if ( (buf_size == 0) && (swap_vec_element_size > 0) ) {
+ /*
+ * the reply has single component - need to swap pad3
+ */
+ if (swap_vec_element_size == 2) {
+ __GLX_SWAP_SHORT(&reply->pad3);
+ }
+ else if (swap_vec_element_size == 4) {
+ __GLX_SWAP_INT(&reply->pad3);
+ __GLX_SWAP_INT(&reply->pad4);
+ }
+ else if (swap_vec_element_size == 8) {
+ __GLX_SWAP_DOUBLE(&reply->pad3);
+ }
+ }
+ else if ( (buf_size > 0) && (swap_vec_element_size > 0) ) {
+ /*
+ * the reply has vector of elements which needs to be swapped
+ */
+ int vsize = buf_size / swap_vec_element_size;
+ char *p = buf;
+ int i;
+
+ for (i=0; i<vsize; i++) {
+ if (swap_vec_element_size == 2) {
+ __GLX_SWAP_SHORT(p);
+ }
+ else if (swap_vec_element_size == 4) {
+ __GLX_SWAP_INT(p);
+ }
+ else if (swap_vec_element_size == 8) {
+ __GLX_SWAP_DOUBLE(p);
+ }
+
+ p += swap_vec_element_size;
+ }
+
+ __GLX_SWAP_INT(&reply->pad3);
+ __GLX_SWAP_INT(&reply->pad4);
+ __GLX_SWAP_INT(&reply->pad5);
+ __GLX_SWAP_INT(&reply->pad6);
+
+ }
+
+ WriteToClient(client, sizeof(xGLXVendorPrivReply),(char *)reply);
+ if (buf_size > 0)
+ WriteToClient(client, buf_size, (char *)buf);
+
+}
+
+int __glXVForwardSingleReq( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ xGLXVendorPrivateReq *be_req;
+ __GLXcontext *glxc;
+ int from_screen = 0;
+ int to_screen = 0;
+ int buf_size;
+ int s;
+
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return 0;
+ }
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ pc += sz_xGLXVendorPrivateReq;
+ buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq;
+
+ /*
+ * just forward the request to back-end server(s)
+ */
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReqVendorPrivate(GLXVendorPrivate,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = req->glxCode;
+ be_req->length = req->length;
+ be_req->vendorCode = req->vendorCode;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
+ if (buf_size > 0)
+ _XSend(dpy, (const char *)pc, buf_size);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+ return Success;
+}
+
+int __glXVForwardPipe0WithReply( __GLXclientState *cl, GLbyte *pc )
+{
+ ClientPtr client = cl->client;
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ xGLXVendorPrivateReq *be_req;
+ xGLXVendorPrivReply reply;
+ xGLXVendorPrivReply be_reply;
+ __GLXcontext *glxc;
+ int buf_size;
+ char *be_buf;
+ int be_buf_size;
+ DMXScreenInfo *dmxScreen;
+ Display *dpy;
+
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return __glXBadContext;
+ }
+
+ pc += sz_xGLXVendorPrivateReq;
+ buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq;
+
+ dmxScreen = &dmxScreens[glxc->pScreen->myNum];
+ dpy = GetBackEndDisplay(cl, glxc->pScreen->myNum);
+
+ /*
+ * send the request to the first back-end server
+ */
+ LockDisplay(dpy);
+ GetReqVendorPrivate(GLXVendorPrivate,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = req->glxCode;
+ be_req->length = req->length;
+ be_req->vendorCode = req->vendorCode;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag, glxc->pScreen->myNum);
+ if (buf_size > 0)
+ _XSend(dpy, (const char *)pc, buf_size);
+
+ /*
+ * get the reply from the back-end server
+ */
+ _XReply(dpy, (xReply*) &be_reply, 0, False);
+ be_buf_size = be_reply.length << 2;
+ if (be_buf_size > 0) {
+ be_buf = (char *)Xalloc( be_buf_size );
+ if (be_buf) {
+ _XRead(dpy, be_buf, be_buf_size);
+ }
+ else {
+ /* Throw data on the floor */
+ _XEatData(dpy, be_buf_size);
+ return BadAlloc;
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ /*
+ * send the reply to the client
+ */
+ memcpy( &reply, &be_reply, sz_xGLXVendorPrivReply );
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (client->swapped) {
+ SendSwappedReply( client, &reply, be_buf, be_buf_size );
+ }
+ else {
+ WriteToClient(client, sizeof(xGLXVendorPrivReply),(char *)&reply);
+ if (be_buf_size > 0)
+ WriteToClient(client, be_buf_size, (char *)be_buf);
+ }
+
+ if (be_buf_size > 0) Xfree(be_buf);
+
+ return Success;
+}
+
+int __glXVForwardAllWithReply( __GLXclientState *cl, GLbyte *pc )
+{
+ ClientPtr client = cl->client;
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ xGLXVendorPrivateReq *be_req;
+ xGLXVendorPrivReply reply;
+ xGLXVendorPrivReply be_reply;
+ __GLXcontext *glxc;
+ int buf_size;
+ char *be_buf;
+ int be_buf_size;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+
+ DMXScreenInfo *dmxScreen;
+ Display *dpy;
+
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return 0;
+ }
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ pc += sz_xGLXVendorPrivateReq;
+ buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq;
+
+ /*
+ * send the request to the first back-end server(s)
+ */
+ for (s=to_screen; s>=from_screen; s--) {
+ dmxScreen = &dmxScreens[s];
+ dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReqVendorPrivate(GLXVendorPrivate,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = req->glxCode;
+ be_req->length = req->length;
+ be_req->vendorCode = req->vendorCode;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
+ if (buf_size > 0)
+ _XSend(dpy, (const char *)pc, buf_size);
+
+ /*
+ * get the reply from the back-end server
+ */
+ _XReply(dpy, (xReply*) &be_reply, 0, False);
+ be_buf_size = be_reply.length << 2;
+ if (be_buf_size > 0) {
+ be_buf = (char *)Xalloc( be_buf_size );
+ if (be_buf) {
+ _XRead(dpy, be_buf, be_buf_size);
+ }
+ else {
+ /* Throw data on the floor */
+ _XEatData(dpy, be_buf_size);
+ return BadAlloc;
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ if (s > from_screen && be_buf_size > 0) {
+ Xfree(be_buf);
+ }
+ }
+
+ /*
+ * send the reply to the client
+ */
+ memcpy( &reply, &be_reply, sz_xGLXVendorPrivReply );
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (client->swapped) {
+ SendSwappedReply( client, &reply, be_buf, be_buf_size );
+ }
+ else {
+ WriteToClient(client, sizeof(xGLXVendorPrivReply),(char *)&reply);
+ if (be_buf_size > 0)
+ WriteToClient(client, be_buf_size, (char *)be_buf);
+ }
+
+ if (be_buf_size > 0) Xfree(be_buf);
+
+ return Success;
+}
+
+int __glXVForwardSingleReqSwap( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 0;
+
+ return( __glXVForwardSingleReq( cl, pc ) );
+}
+
+int __glXVForwardPipe0WithReplySwap( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 0;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXVendorPrivateReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXVendorPrivateReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXVForwardPipe0WithReply( cl, pc ) );
+}
+
+int __glXVForwardPipe0WithReplySwapsv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 2;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXVendorPrivateReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXVendorPrivateReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXVForwardPipe0WithReply( cl, pc ) );
+}
+
+int __glXVForwardPipe0WithReplySwapiv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 4;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXVendorPrivateReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXVendorPrivateReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXVForwardPipe0WithReply( cl, pc ) );
+}
+
+int __glXVForwardPipe0WithReplySwapdv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 8;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXVendorPrivateReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXVendorPrivateReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXVForwardPipe0WithReply( cl, pc ) );
+}
+
+int __glXVForwardAllWithReplySwap( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 0;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXVendorPrivateReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXVendorPrivateReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXVForwardAllWithReply( cl, pc ) );
+}
+
+int __glXVForwardAllWithReplySwapsv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 2;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXVendorPrivateReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXVendorPrivateReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXVForwardAllWithReply( cl, pc ) );
+}
+
+int __glXVForwardAllWithReplySwapiv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 4;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXVendorPrivateReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXVendorPrivateReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXVForwardAllWithReply( cl, pc ) );
+}
+
+int __glXVForwardAllWithReplySwapdv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 8;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXVendorPrivateReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXVendorPrivateReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXVForwardAllWithReply( cl, pc ) );
+}
+
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvendor.h b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvendor.h
new file mode 100644
index 000000000..8245ce102
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvendor.h
@@ -0,0 +1,55 @@
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#ifndef __GLXVENDOR_H
+#define __GLXVENDOR_H
+
+extern int __glXVForwardSingleReq( __GLXclientState *cl, GLbyte *pc );
+extern int __glXVForwardPipe0WithReply( __GLXclientState *cl, GLbyte *pc );
+extern int __glXVForwardAllWithReply( __GLXclientState *cl, GLbyte *pc );
+
+extern int __glXVForwardSingleReqSwap( __GLXclientState *cl, GLbyte *pc );
+
+extern int __glXVForwardPipe0WithReplySwap( __GLXclientState *cl, GLbyte *pc );
+extern int __glXVForwardPipe0WithReplySwapsv( __GLXclientState *cl, GLbyte *pc );
+extern int __glXVForwardPipe0WithReplySwapiv( __GLXclientState *cl, GLbyte *pc );
+extern int __glXVForwardPipe0WithReplySwapdv( __GLXclientState *cl, GLbyte *pc );
+
+extern int __glXVForwardAllWithReplySwap( __GLXclientState *cl, GLbyte *pc );
+extern int __glXVForwardAllWithReplySwapsv( __GLXclientState *cl, GLbyte *pc );
+extern int __glXVForwardAllWithReplySwapiv( __GLXclientState *cl, GLbyte *pc );
+extern int __glXVForwardAllWithReplySwapdv( __GLXclientState *cl, GLbyte *pc );
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvisuals.c b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvisuals.c
new file mode 100644
index 000000000..c20e9551e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvisuals.c
@@ -0,0 +1,542 @@
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "glxserver.h"
+#include "glxutil.h"
+#include "dmx_glxvisuals.h"
+
+static int numConfigs = 0;
+static __GLXvisualConfig *visualConfigs = NULL;
+static void **visualPrivates = NULL;
+
+int glxVisualsMatch( __GLXvisualConfig *v1, __GLXvisualConfig *v2 )
+{
+ if ( (v1->class == v2->class) &&
+ (v1->rgba == v2->rgba) &&
+ (v1->redSize == v2->redSize) &&
+ (v1->greenSize == v2->greenSize) &&
+ (v1->blueSize == v2->blueSize) &&
+ (v1->alphaSize == v2->alphaSize) &&
+ (v1->redMask == v2->redMask) &&
+ (v1->greenMask == v2->greenMask) &&
+ (v1->blueMask == v2->blueMask) &&
+ (v1->alphaMask == v2->alphaMask) &&
+ (v1->accumRedSize == v2->accumRedSize) &&
+ (v1->accumGreenSize == v2->accumGreenSize) &&
+ (v1->accumBlueSize == v2->accumBlueSize) &&
+ (v1->accumAlphaSize == v2->accumAlphaSize) &&
+ (v1->doubleBuffer == v2->doubleBuffer) &&
+ (v1->stereo == v2->stereo) &&
+ (v1->bufferSize == v2->bufferSize) &&
+ (v1->depthSize == v2->depthSize) &&
+ (v1->stencilSize == v2->stencilSize) &&
+ (v1->auxBuffers == v2->auxBuffers) &&
+ (v1->level == v2->level) &&
+ (v1->visualRating == v2->visualRating) &&
+ (v1->transparentPixel == v2->transparentPixel) &&
+ (v1->transparentRed == v2->transparentRed) &&
+ (v1->transparentGreen == v2->transparentGreen) &&
+ (v1->transparentBlue == v2->transparentBlue) &&
+ (v1->transparentAlpha == v2->transparentAlpha) &&
+ (v1->transparentIndex == v2->transparentIndex) &&
+ (v1->multiSampleSize == v2->multiSampleSize) &&
+ (v1->nMultiSampleBuffers == v2->nMultiSampleBuffers) &&
+ (v1->visualSelectGroup == v2->visualSelectGroup) ) {
+
+ return(1);
+
+ }
+
+ return(0);
+
+}
+
+VisualID glxMatchGLXVisualInConfigList( __GLXvisualConfig *pGlxVisual, __GLXvisualConfig *configs, int nconfigs )
+{
+ int i;
+
+ for (i=0; i<nconfigs; i++) {
+
+ if (glxVisualsMatch( pGlxVisual, &configs[i] )) {
+
+ return( configs[i].vid );
+
+ }
+ }
+
+ return(0);
+}
+
+VisualID glxMatchVisualInConfigList( ScreenPtr pScreen, VisualPtr pVisual, __GLXvisualConfig *configs, int nconfigs )
+{
+ __GLXscreenInfo *pGlxScreen;
+ __GLXvisualConfig *pGlxVisual;
+ int i;
+
+ /* check that the glx extension has been initialized */
+ if ( !__glXActiveScreens )
+ return(0);
+
+ pGlxScreen = &__glXActiveScreens[pScreen->myNum];
+ pGlxVisual = pGlxScreen->pGlxVisual;
+
+ /* find the glx visual info for pVisual */
+ for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) {
+ if (pGlxVisual->vid == pVisual->vid) {
+ break;
+ }
+ }
+ if (i == pGlxScreen->numVisuals) {
+ /*
+ * the visual is not supported by glx
+ */
+ return(0);
+ }
+
+ return( glxMatchGLXVisualInConfigList(pGlxVisual, configs, nconfigs) );
+}
+
+VisualPtr glxMatchVisual( ScreenPtr pScreen, VisualPtr pVisual, ScreenPtr pMatchScreen )
+{
+ __GLXscreenInfo *pGlxScreen2;
+ int j;
+ VisualID vid;
+
+ /* check that the glx extension has been initialized */
+ if ( !__glXActiveScreens )
+ return NULL;
+
+ pGlxScreen2 = &__glXActiveScreens[pMatchScreen->myNum];
+
+ vid = glxMatchVisualInConfigList( pScreen, pVisual,
+ pGlxScreen2->pGlxVisual,
+ pGlxScreen2->numVisuals );
+ if (vid) {
+ /*
+ * find the X visual of the matching glx visual
+ */
+ for (j=0; j<pMatchScreen->numVisuals; j++) {
+ if (vid == pMatchScreen->visuals[j].vid) {
+ return( &pMatchScreen->visuals[j] );
+ }
+ }
+ }
+
+ return(0);
+}
+
+void glxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
+ void **privates)
+{
+ numConfigs = nconfigs;
+ visualConfigs = configs;
+ visualPrivates = privates;
+}
+
+static int count_bits(unsigned int n)
+{
+ int bits = 0;
+
+ while (n > 0) {
+ if (n & 1) bits++;
+ n >>= 1;
+ }
+ return bits;
+}
+
+static VisualID FindClosestVisual( VisualPtr pVisual, int rootDepth,
+ DepthPtr pdepth, int ndepths,
+ VisualPtr pNewVisual, int numNewVisuals)
+{
+ int d, v;
+ VisualPtr vis;
+
+ /*
+ * find the first visual with the same or deeper depth
+ * of the same class.
+ */
+ for (d=0; d<ndepths; d++) {
+ if (pdepth[d].depth >= rootDepth) {
+ for (v=0; v<pdepth[d].numVids; v++) {
+
+ /* find the new visual structure */
+ vis = pNewVisual;
+ while( pdepth[d].vids[v] != vis->vid ) vis++;
+
+ if (vis->class == pVisual->class) {
+ return( pdepth[d].vids[v] );
+ }
+ }
+ }
+ }
+
+ /*
+ * did not find any.
+ * try to look for the same class only.
+ */
+ for (d=0; d<ndepths; d++) {
+ for (v=0; v<pdepth[d].numVids; v++) {
+
+ /* find the new visual structure */
+ vis = pNewVisual;
+ while( pdepth[d].vids[v] != vis->vid ) vis++;
+
+ if (vis->class == pVisual->class) {
+ return( pdepth[d].vids[v] );
+ }
+ }
+ }
+
+ /*
+ * if not found - just take the first visual
+ */
+ return( pdepth[0].vids[0] );
+}
+
+Bool glxInitVisuals(int *nvisualp, VisualPtr *visualp,
+ VisualID *defaultVisp,
+ int ndepth, DepthPtr pdepth,
+ int rootDepth)
+{
+ int numRGBconfigs;
+ int numCIconfigs;
+ int numVisuals = *nvisualp;
+ int numNewVisuals;
+ int numNewConfigs;
+ VisualPtr pVisual = *visualp;
+ VisualPtr pVisualNew = NULL;
+ VisualID *orig_vid = NULL;
+ __GLXvisualConfig *glXVisualPtr = NULL;
+ __GLXvisualConfig *pNewVisualConfigs = NULL;
+ void **glXVisualPriv;
+ dmxGlxVisualPrivate **pNewVisualPriv;
+ int found_default;
+ int i, j, k;
+ int numGLXvis = 0;
+ GLint *isGLXvis;
+
+ if (numConfigs > 0)
+ numNewConfigs = numConfigs;
+ else
+ return False;
+
+ MAXSCREENSALLOC(__glXActiveScreens);
+ if (!__glXActiveScreens)
+ return False;
+
+ /* Alloc space for the list of new GLX visuals */
+ pNewVisualConfigs = (__GLXvisualConfig *)
+ __glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig));
+ if (!pNewVisualConfigs) {
+ return FALSE;
+ }
+
+ /* Alloc space for the list of new GLX visual privates */
+ pNewVisualPriv = (dmxGlxVisualPrivate **) __glXMalloc(numNewConfigs * sizeof(dmxGlxVisualPrivate *));
+ if (!pNewVisualPriv) {
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* copy driver's visual config info */
+ for (i = 0; i < numConfigs; i++) {
+ pNewVisualConfigs[i] = visualConfigs[i];
+ pNewVisualPriv[i] = (dmxGlxVisualPrivate *)visualPrivates[i];
+ }
+
+#if 1
+ /* FIXME: This is a hack to workaround a hang in xtest caused by a
+ * mismatch between what the front end (i.e., DMX) server calculates
+ * for the visual configs and what the back-end servers have.
+ */
+ {
+ int numTCRGBconfigs = 0;
+ int numDCRGBconfigs = 0;
+
+ numRGBconfigs = 0;
+ numCIconfigs = 0;
+
+ for (i = 0; i < numNewConfigs; i++) {
+ if (pNewVisualConfigs[i].rgba) {
+ if (pNewVisualConfigs[i].class == TrueColor)
+ numTCRGBconfigs++;
+ else
+ numDCRGBconfigs++;
+ numRGBconfigs++;
+ } else
+ numCIconfigs++;
+ }
+
+ /* Count the total number of visuals to compute */
+ numNewVisuals = 0;
+ for (i = 0; i < numVisuals; i++) {
+ numNewVisuals +=
+ (pVisual[i].class == TrueColor) ? numTCRGBconfigs :
+ (pVisual[i].class == DirectColor) ? numDCRGBconfigs :
+ numCIconfigs;
+ }
+ }
+#else
+ /* Count the number of RGB and CI visual configs */
+ numRGBconfigs = 0;
+ numCIconfigs = 0;
+ for (i = 0; i < numNewConfigs; i++) {
+ if (pNewVisualConfigs[i].rgba)
+ numRGBconfigs++;
+ else
+ numCIconfigs++;
+ }
+
+ /* Count the total number of visuals to compute */
+ numNewVisuals = 0;
+ for (i = 0; i < numVisuals; i++) {
+ numNewVisuals +=
+ (pVisual[i].class == TrueColor || pVisual[i].class == DirectColor)
+ ? numRGBconfigs : numCIconfigs;
+ }
+#endif
+
+ /* Reset variables for use with the next screen/driver's visual configs */
+ visualConfigs = NULL;
+ numConfigs = 0;
+
+ /* Alloc temp space for the list of orig VisualIDs for each new visual */
+ orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID));
+ if (!orig_vid) {
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the list of glXVisuals */
+ glXVisualPtr = (__GLXvisualConfig *)__glXMalloc(numNewVisuals *
+ sizeof(__GLXvisualConfig));
+ if (!glXVisualPtr) {
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the list of glXVisualPrivates */
+ glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *));
+ if (!glXVisualPriv) {
+ __glXFree(glXVisualPtr);
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the new list of the X server's visuals */
+ pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec));
+ if (!pVisualNew) {
+ __glXFree(glXVisualPriv);
+ __glXFree(glXVisualPtr);
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ isGLXvis = (GLint *) __glXMalloc(numNewVisuals * sizeof(GLint));
+ if (!isGLXvis) {
+ __glXFree(glXVisualPriv);
+ __glXFree(glXVisualPtr);
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ __glXFree(pVisualNew);
+ return FALSE;
+ }
+
+ /* Initialize the new visuals */
+ found_default = FALSE;
+ for (i = j = 0; i < numVisuals; i++) {
+
+ for (k = 0; k < numNewConfigs; k++) {
+
+ int new_depth;
+ int depth;
+ int d,v;
+
+ /* find the depth of the new visual config */
+ new_depth = pNewVisualPriv[k]->x_visual_depth;
+
+ /* find the depth of the original visual */
+ depth = 0;
+ d = 0;
+ while( (depth==0) && (d < ndepth) ) {
+ v = 0;
+ while( (depth==0) && (v < pdepth[d].numVids) ) {
+ if (pdepth[d].vids[v] == pVisual[i].vid) {
+ depth = pdepth[d].depth;
+ }
+ v++;
+ }
+ d++;
+ }
+
+ /* check that the visual has the same class and depth
+ * as the new config
+ */
+ if ( pVisual[i].class != pNewVisualPriv[k]->x_visual_class ||
+ (depth != new_depth) )
+ continue;
+
+ /* Initialize the new visual */
+ pVisualNew[j] = pVisual[i];
+ pVisualNew[j].vid = FakeClientID(0);
+
+ /* Check for the default visual */
+ if (!found_default && pVisual[i].vid == *defaultVisp) {
+ *defaultVisp = pVisualNew[j].vid;
+ found_default = TRUE;
+ }
+
+ /* Save the old VisualID */
+ orig_vid[j] = pVisual[i].vid;
+
+ /* Initialize the glXVisual */
+ glXVisualPtr[j] = pNewVisualConfigs[k];
+ glXVisualPtr[j].vid = pVisualNew[j].vid;
+
+ /*
+ * If the class is -1, then assume the X visual information
+ * is identical to what GLX needs, and take them from the X
+ * visual. NOTE: if class != -1, then all other fields MUST
+ * be initialized.
+ */
+ if (glXVisualPtr[j].class == -1) {
+ glXVisualPtr[j].class = pVisual[i].class;
+ glXVisualPtr[j].redSize = count_bits(pVisual[i].redMask);
+ glXVisualPtr[j].greenSize = count_bits(pVisual[i].greenMask);
+ glXVisualPtr[j].blueSize = count_bits(pVisual[i].blueMask);
+ glXVisualPtr[j].alphaSize = glXVisualPtr[j].alphaSize;
+ glXVisualPtr[j].redMask = pVisual[i].redMask;
+ glXVisualPtr[j].greenMask = pVisual[i].greenMask;
+ glXVisualPtr[j].blueMask = pVisual[i].blueMask;
+ glXVisualPtr[j].alphaMask = glXVisualPtr[j].alphaMask;
+ glXVisualPtr[j].bufferSize = rootDepth;
+ }
+
+ /* Save the device-dependent private for this visual */
+ glXVisualPriv[j] = pNewVisualPriv[k];
+
+ isGLXvis[j] = glxMatchGLXVisualInConfigList( &glXVisualPtr[j],
+ dmxScreens[screenInfo.numScreens-1].glxVisuals,
+ dmxScreens[screenInfo.numScreens-1].numGlxVisuals );
+ if (isGLXvis[j]) numGLXvis++;
+
+ j++;
+ }
+ }
+
+ assert(j <= numNewVisuals);
+ numNewVisuals = j; /* correct number of new visuals */
+
+ /* Save the GLX visuals in the screen structure */
+ __glXActiveScreens[screenInfo.numScreens-1].numVisuals = numNewVisuals;
+ __glXActiveScreens[screenInfo.numScreens-1].numGLXVisuals = numGLXvis;
+ __glXActiveScreens[screenInfo.numScreens-1].isGLXvis = isGLXvis;
+ __glXActiveScreens[screenInfo.numScreens-1].pGlxVisual = glXVisualPtr;
+
+
+ /* Set up depth's VisualIDs */
+ for (i = 0; i < ndepth; i++) {
+ int numVids = 0;
+ VisualID *pVids = NULL;
+ int k, n = 0;
+
+ /* Count the new number of VisualIDs at this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numNewVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ numVids++;
+
+ /* Allocate a new list of VisualIDs for this depth */
+ pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID));
+
+ /* Initialize the new list of VisualIDs for this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numNewVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ pVids[n++] = pVisualNew[k].vid;
+
+ /* Update this depth's list of VisualIDs */
+ __glXFree(pdepth[i].vids);
+ pdepth[i].vids = pVids;
+ pdepth[i].numVids = numVids;
+ }
+
+ /*
+ * if the default visual was rejected - need to choose new
+ * default visual !
+ */
+ if ( !found_default ) {
+
+ for (i=0; i<numVisuals; i++)
+ if (pVisual[i].vid == *defaultVisp)
+ break;
+
+ if (i < numVisuals) {
+ *defaultVisp = FindClosestVisual( &pVisual[i], rootDepth, pdepth, ndepth, pVisualNew, numNewVisuals );
+ }
+ }
+
+ /* Update the X server's visuals */
+ *nvisualp = numNewVisuals;
+ *visualp = pVisualNew;
+
+ /* Free the old list of the X server's visuals */
+ __glXFree(pVisual);
+
+ /* Clean up temporary allocations */
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+
+ /* Free the private list created by DDX HW driver */
+ if (visualPrivates)
+ xfree(visualPrivates);
+ visualPrivates = NULL;
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvisuals.h b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvisuals.h
new file mode 100644
index 000000000..50f9b13e6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvisuals.h
@@ -0,0 +1,55 @@
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#ifndef _GLX_VISUALS_H
+#define _GLX_VISUALS_H
+
+int glxVisualsMatch( __GLXvisualConfig *v1, __GLXvisualConfig *v2 );
+
+VisualID glxMatchGLXVisualInConfigList( __GLXvisualConfig *pGlxVisual, __GLXvisualConfig *configs, int nconfigs );
+
+VisualID glxMatchVisualInConfigList( ScreenPtr pScreen, VisualPtr pVisual, __GLXvisualConfig *configs, int nconfigs );
+
+VisualPtr glxMatchVisual( ScreenPtr pScreen, VisualPtr pVisual, ScreenPtr pMatchScreen );
+
+void glxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
+ void **privates);
+
+Bool glxInitVisuals(int *nvisualp, VisualPtr *visualp,
+ VisualID *defaultVisp,
+ int ndepth, DepthPtr pdepth,
+ int rootDepth);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/render2swap.c b/nx-X11/programs/Xserver/hw/dmx/glxProxy/render2swap.c
new file mode 100644
index 000000000..3fb894325
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/render2swap.c
@@ -0,0 +1,348 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/render2swap.c,v 1.5 2001/03/21 16:29:37 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+/* #define NEED_REPLIES */
+#include "glxserver.h"
+#include "unpack.h"
+#include "g_disptab.h"
+
+GLint __glEvalComputeK(GLenum target)
+{
+ switch (target) {
+ case GL_MAP1_VERTEX_4:
+ case GL_MAP1_COLOR_4:
+ case GL_MAP1_TEXTURE_COORD_4:
+ case GL_MAP2_VERTEX_4:
+ case GL_MAP2_COLOR_4:
+ case GL_MAP2_TEXTURE_COORD_4:
+ return 4;
+ case GL_MAP1_VERTEX_3:
+ case GL_MAP1_TEXTURE_COORD_3:
+ case GL_MAP1_NORMAL:
+ case GL_MAP2_VERTEX_3:
+ case GL_MAP2_TEXTURE_COORD_3:
+ case GL_MAP2_NORMAL:
+ return 3;
+ case GL_MAP1_TEXTURE_COORD_2:
+ case GL_MAP2_TEXTURE_COORD_2:
+ return 2;
+ case GL_MAP1_TEXTURE_COORD_1:
+ case GL_MAP2_TEXTURE_COORD_1:
+ case GL_MAP1_INDEX:
+ case GL_MAP2_INDEX:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+void __glXDispSwap_Map1f(GLbyte *pc)
+{
+ GLint order, k;
+ GLfloat u1, u2, *points;
+ GLenum target;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+ target = *(GLenum *)(pc + 0);
+ order = *(GLint *)(pc + 12);
+ u1 = *(GLfloat *)(pc + 4);
+ u2 = *(GLfloat *)(pc + 8);
+ points = (GLfloat *)(pc + 16);
+ k = __glEvalComputeK(target);
+
+ if (order <= 0 || k < 0) {
+ /* Erroneous command. */
+ compsize = 0;
+ } else {
+ compsize = order * k;
+ }
+ __GLX_SWAP_FLOAT_ARRAY(points, compsize);
+
+}
+
+void __glXDispSwap_Map2f(GLbyte *pc)
+{
+ GLint uorder, vorder, ustride, vstride, k;
+ GLfloat u1, u2, v1, v2, *points;
+ GLenum target;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 24);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+ __GLX_SWAP_FLOAT(pc + 16);
+ __GLX_SWAP_FLOAT(pc + 20);
+
+ target = *(GLenum *)(pc + 0);
+ uorder = *(GLint *)(pc + 12);
+ vorder = *(GLint *)(pc + 24);
+ u1 = *(GLfloat *)(pc + 4);
+ u2 = *(GLfloat *)(pc + 8);
+ v1 = *(GLfloat *)(pc + 16);
+ v2 = *(GLfloat *)(pc + 20);
+ points = (GLfloat *)(pc + 28);
+
+ k = __glEvalComputeK(target);
+ ustride = vorder * k;
+ vstride = k;
+
+ if (vorder <= 0 || uorder <= 0 || k < 0) {
+ /* Erroneous command. */
+ compsize = 0;
+ } else {
+ compsize = uorder * vorder * k;
+ }
+ __GLX_SWAP_FLOAT_ARRAY(points, compsize);
+
+}
+
+void __glXDispSwap_Map1d(GLbyte *pc)
+{
+ GLint order, k, compsize;
+ GLenum target;
+ GLdouble u1, u2, *points;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_INT(pc + 20);
+
+ target = *(GLenum*) (pc + 16);
+ order = *(GLint*) (pc + 20);
+ k = __glEvalComputeK(target);
+ if (order <= 0 || k < 0) {
+ /* Erroneous command. */
+ compsize = 0;
+ } else {
+ compsize = order * k;
+ }
+ __GLX_GET_DOUBLE(u1,pc);
+ __GLX_GET_DOUBLE(u2,pc+8);
+ __GLX_SWAP_DOUBLE_ARRAY(pc+24, compsize);
+ pc += 24;
+
+#ifdef __GLX_ALIGN64
+ if (((unsigned long)pc) & 7) {
+ /*
+ ** Copy the doubles up 4 bytes, trashing the command but aligning
+ ** the data in the process
+ */
+ __GLX_MEM_COPY(pc-4, pc, compsize*8);
+ points = (GLdouble*) (pc - 4);
+ } else {
+ points = (GLdouble*) pc;
+ }
+#else
+ points = (GLdouble*) pc;
+#endif
+}
+
+void __glXDispSwap_Map2d(GLbyte *pc)
+{
+ GLdouble u1, u2, v1, v2, *points;
+ GLint uorder, vorder, ustride, vstride, k, compsize;
+ GLenum target;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_DOUBLE(pc + 16);
+ __GLX_SWAP_DOUBLE(pc + 24);
+ __GLX_SWAP_INT(pc + 32);
+ __GLX_SWAP_INT(pc + 36);
+ __GLX_SWAP_INT(pc + 40);
+
+ target = *(GLenum *)(pc + 32);
+ uorder = *(GLint *)(pc + 36);
+ vorder = *(GLint *)(pc + 40);
+ k = __glEvalComputeK(target);
+ if (vorder <= 0 || uorder <= 0 || k < 0) {
+ /* Erroneous command. */
+ compsize = 0;
+ } else {
+ compsize = uorder * vorder * k;
+ }
+ __GLX_GET_DOUBLE(u1,pc);
+ __GLX_GET_DOUBLE(u2,pc+8);
+ __GLX_GET_DOUBLE(v1,pc+16);
+ __GLX_GET_DOUBLE(v2,pc+24);
+ __GLX_SWAP_DOUBLE_ARRAY(pc+44, compsize);
+ pc += 44;
+ ustride = vorder * k;
+ vstride = k;
+
+#ifdef __GLX_ALIGN64
+ if (((unsigned long)pc) & 7) {
+ /*
+ ** Copy the doubles up 4 bytes, trashing the command but aligning
+ ** the data in the process
+ */
+ __GLX_MEM_COPY(pc-4, pc, compsize*8);
+ points = (GLdouble*) (pc - 4);
+ } else {
+ points = (GLdouble*) pc;
+ }
+#else
+ points = (GLdouble*) pc;
+#endif
+}
+
+void __glXDispSwap_CallLists(GLbyte *pc)
+{
+ GLenum type;
+ GLsizei n;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 0);
+ type = *(GLenum *)(pc + 4);
+ n = *(GLsizei *)(pc + 0);
+
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_2_BYTES:
+ case GL_3_BYTES:
+ case GL_4_BYTES:
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ __GLX_SWAP_SHORT_ARRAY(pc+8, n);
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ __GLX_SWAP_INT_ARRAY(pc+8, n);
+ break;
+ case GL_FLOAT:
+ __GLX_SWAP_FLOAT_ARRAY(pc+8, n);
+ break;
+ }
+
+}
+
+static void swapArray(GLint numVals, GLenum datatype,
+ GLint stride, GLint numVertexes, GLbyte *pc)
+{
+ int i,j;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ switch (datatype) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ /* don't need to swap */
+ return;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ for (i=0; i<numVertexes; i++) {
+ GLshort *pVal = (GLshort *) pc;
+ for (j=0; j<numVals; j++) {
+ __GLX_SWAP_SHORT(&pVal[j]);
+ }
+ pc += stride;
+ }
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ for (i=0; i<numVertexes; i++) {
+ GLint *pVal = (GLint *) pc;
+ for (j=0; j<numVals; j++) {
+ __GLX_SWAP_INT(&pVal[j]);
+ }
+ pc += stride;
+ }
+ break;
+ case GL_FLOAT:
+ for (i=0; i<numVertexes; i++) {
+ GLfloat *pVal = (GLfloat *) pc;
+ for (j=0; j<numVals; j++) {
+ __GLX_SWAP_FLOAT(&pVal[j]);
+ }
+ pc += stride;
+ }
+ break;
+ case GL_DOUBLE:
+ for (i=0; i<numVertexes; i++) {
+ GLdouble *pVal = (GLdouble *) pc;
+ for (j=0; j<numVals; j++) {
+ __GLX_SWAP_DOUBLE(&pVal[j]);
+ }
+ pc += stride;
+ }
+ break;
+ default:
+ return;
+ }
+}
+
+void __glXDispSwap_DrawArrays(GLbyte *pc)
+{
+ __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *)pc;
+ __GLXdispatchDrawArraysComponentHeader *compHeader;
+ int i;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&hdr->numVertexes);
+ __GLX_SWAP_INT(&hdr->numComponents);
+ __GLX_SWAP_INT(&hdr->primType);
+
+ pc += sizeof(__GLXdispatchDrawArraysHeader);
+ compHeader = (__GLXdispatchDrawArraysComponentHeader *) pc;
+
+ /* compute stride (same for all component arrays) */
+ for (i=0; i<hdr->numComponents; i++) {
+ __GLX_SWAP_INT(&compHeader[i].datatype);
+ __GLX_SWAP_INT(&compHeader[i].numVals);
+ __GLX_SWAP_INT(&compHeader[i].component);
+
+ }
+
+}
+
+void __glXDispSwap_DrawArraysEXT(GLbyte *pc)
+{
+#ifdef XXX_STUB
+#endif /*XXX_STUB*/
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/renderpixswap.c b/nx-X11/programs/Xserver/hw/dmx/glxProxy/renderpixswap.c
new file mode 100644
index 000000000..bedefe781
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/renderpixswap.c
@@ -0,0 +1,390 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/renderpixswap.c,v 1.5 2001/03/21 16:29:37 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define NEED_REPLIES
+#include "glxserver.h"
+#include "unpack.h"
+#include "g_disptab.h"
+
+void __glXDispSwap_PolygonStipple(GLbyte *pc)
+{
+ __GLXpixelHeader *hdr = (__GLXpixelHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ hdr->swapBytes = !hdr->swapBytes;
+}
+
+void __glXDispSwap_Bitmap(GLbyte *pc)
+{
+ __GLXdispatchBitmapHeader *hdr = (__GLXdispatchBitmapHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_FLOAT((GLbyte *)&hdr->xorig);
+ __GLX_SWAP_FLOAT((GLbyte *)&hdr->yorig);
+ __GLX_SWAP_FLOAT((GLbyte *)&hdr->xmove);
+ __GLX_SWAP_FLOAT((GLbyte *)&hdr->ymove);
+
+ hdr->swapBytes = !hdr->swapBytes;
+
+}
+
+void __glXDispSwap_TexImage1D(GLbyte *pc)
+{
+ __GLXdispatchTexImageHeader *hdr = (__GLXdispatchTexImageHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->level);
+ __GLX_SWAP_INT((GLbyte *)&hdr->components);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_INT((GLbyte *)&hdr->border);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ hdr->swapBytes = !hdr->swapBytes;
+}
+
+void __glXDispSwap_TexImage2D(GLbyte *pc)
+{
+ __GLXdispatchTexImageHeader *hdr = (__GLXdispatchTexImageHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->level);
+ __GLX_SWAP_INT((GLbyte *)&hdr->components);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_INT((GLbyte *)&hdr->border);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ hdr->swapBytes = !hdr->swapBytes;
+}
+
+void __glXDispSwap_TexImage3D(GLbyte *pc)
+{
+ __GLXdispatchTexImage3DHeader *hdr = (__GLXdispatchTexImage3DHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->imageHeight);
+ __GLX_SWAP_INT((GLbyte *)&hdr->imageDepth);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipImages);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipVolumes);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->level);
+ __GLX_SWAP_INT((GLbyte *)&hdr->internalformat);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_INT((GLbyte *)&hdr->depth);
+ __GLX_SWAP_INT((GLbyte *)&hdr->size4d);
+ __GLX_SWAP_INT((GLbyte *)&hdr->border);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ hdr->swapBytes = !hdr->swapBytes;
+}
+
+void __glXDispSwap_DrawPixels(GLbyte *pc)
+{
+ __GLXdispatchDrawPixelsHeader *hdr = (__GLXdispatchDrawPixelsHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ hdr->swapBytes = !hdr->swapBytes;
+}
+
+void __glXDispSwap_TexSubImage1D(GLbyte *pc)
+{
+ __GLXdispatchTexSubImageHeader *hdr = (__GLXdispatchTexSubImageHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->level);
+ __GLX_SWAP_INT((GLbyte *)&hdr->xoffset);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ hdr->swapBytes = !hdr->swapBytes;
+}
+
+void __glXDispSwap_TexSubImage2D(GLbyte *pc)
+{
+ __GLXdispatchTexSubImageHeader *hdr = (__GLXdispatchTexSubImageHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->level);
+ __GLX_SWAP_INT((GLbyte *)&hdr->xoffset);
+ __GLX_SWAP_INT((GLbyte *)&hdr->yoffset);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ hdr->swapBytes = !hdr->swapBytes;
+}
+
+void __glXDispSwap_TexSubImage3D(GLbyte *pc)
+{
+ __GLXdispatchTexSubImage3DHeader *hdr =
+ (__GLXdispatchTexSubImage3DHeader *) pc;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->imageHeight);
+ __GLX_SWAP_INT((GLbyte *)&hdr->imageDepth);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipImages);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipVolumes);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->level);
+ __GLX_SWAP_INT((GLbyte *)&hdr->xoffset);
+ __GLX_SWAP_INT((GLbyte *)&hdr->yoffset);
+ __GLX_SWAP_INT((GLbyte *)&hdr->zoffset);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_INT((GLbyte *)&hdr->depth);
+ __GLX_SWAP_INT((GLbyte *)&hdr->size4d);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ hdr->swapBytes = !hdr->swapBytes;
+}
+
+void __glXDispSwap_ColorTable(GLbyte *pc)
+{
+ __GLXdispatchColorTableHeader *hdr =
+ (__GLXdispatchColorTableHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->internalformat);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ hdr->swapBytes = !hdr->swapBytes;
+}
+
+void __glXDispSwap_ColorSubTable(GLbyte *pc)
+{
+ __GLXdispatchColorSubTableHeader *hdr =
+ (__GLXdispatchColorSubTableHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->start);
+ __GLX_SWAP_INT((GLbyte *)&hdr->count);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ hdr->swapBytes = !hdr->swapBytes;
+}
+
+void __glXDispSwap_ConvolutionFilter1D(GLbyte *pc)
+{
+ __GLXdispatchConvolutionFilterHeader *hdr =
+ (__GLXdispatchConvolutionFilterHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->internalformat);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ hdr->swapBytes = !hdr->swapBytes;
+}
+
+void __glXDispSwap_ConvolutionFilter2D(GLbyte *pc)
+{
+ __GLXdispatchConvolutionFilterHeader *hdr =
+ (__GLXdispatchConvolutionFilterHeader *) pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->internalformat);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ hdr->swapBytes = !hdr->swapBytes;
+}
+
+void __glXDispSwap_SeparableFilter2D(GLbyte *pc)
+{
+ __GLXdispatchConvolutionFilterHeader *hdr =
+ (__GLXdispatchConvolutionFilterHeader *) pc;
+ GLint hdrlen, image1len;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ hdrlen = __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->rowLength);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipRows);
+ __GLX_SWAP_INT((GLbyte *)&hdr->skipPixels);
+ __GLX_SWAP_INT((GLbyte *)&hdr->alignment);
+
+ __GLX_SWAP_INT((GLbyte *)&hdr->target);
+ __GLX_SWAP_INT((GLbyte *)&hdr->internalformat);
+ __GLX_SWAP_INT((GLbyte *)&hdr->width);
+ __GLX_SWAP_INT((GLbyte *)&hdr->height);
+ __GLX_SWAP_INT((GLbyte *)&hdr->format);
+ __GLX_SWAP_INT((GLbyte *)&hdr->type);
+
+ /*
+ ** Just invert swapBytes flag; the GL will figure out if it needs to swap
+ ** the pixel data.
+ */
+ hdr->swapBytes = !hdr->swapBytes;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/glxProxy/unpack.h b/nx-X11/programs/Xserver/hw/dmx/glxProxy/unpack.h
new file mode 100644
index 000000000..abad7b147
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/glxProxy/unpack.h
@@ -0,0 +1,234 @@
+/* $XFree86: xc/programs/Xserver/GL/glx/unpack.h,v 1.3 2001/03/21 16:29:37 dawes Exp $ */
+#ifndef __GLX_unpack_h__
+#define __GLX_unpack_h__
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#define __GLX_PAD(s) (((s)+3) & (GLuint)~3)
+
+/*
+** Fetch the context-id out of a SingleReq request pointed to by pc.
+*/
+#define __GLX_GET_SINGLE_CONTEXT_TAG(pc) (((xGLXSingleReq*)pc)->contextTag)
+#define __GLX_GET_VENDPRIV_CONTEXT_TAG(pc) (((xGLXVendorPrivateReq*)pc)->contextTag)
+
+/*
+** Fetch a double from potentially unaligned memory.
+*/
+#ifdef __GLX_ALIGN64
+#define __GLX_MEM_COPY(dst,src,n) memcpy(dst,src,n)
+#define __GLX_GET_DOUBLE(dst,src) __GLX_MEM_COPY(&dst,src,8)
+#else
+#define __GLX_GET_DOUBLE(dst,src) (dst) = *((GLdouble*)(src))
+#endif
+
+extern void __glXMemInit(void);
+
+extern xGLXSingleReply __glXReply;
+
+#define __GLX_BEGIN_REPLY(size) \
+ __glXReply.length = __GLX_PAD(size) >> 2; \
+ __glXReply.type = X_Reply; \
+ __glXReply.sequenceNumber = client->sequence;
+
+#define __GLX_SEND_HEADER() \
+ WriteToClient( client, sz_xGLXSingleReply, (char *)&__glXReply);
+
+#define __GLX_PUT_RETVAL(a) \
+ __glXReply.retval = (a);
+
+#define __GLX_PUT_SIZE(a) \
+ __glXReply.size = (a);
+
+#define __GLX_PUT_RENDERMODE(m) \
+ __glXReply.pad3 = (m)
+
+/*
+** Get a buffer to hold returned data, with the given alignment. If we have
+** to realloc, allocate size+align, in case the pointer has to be bumped for
+** alignment. The answerBuffer should already be aligned.
+**
+** NOTE: the cast (long)res below assumes a long is large enough to hold a
+** pointer.
+*/
+#define __GLX_GET_ANSWER_BUFFER(res,cl,size,align) \
+ if ((size) > sizeof(answerBuffer)) { \
+ int bump; \
+ if ((cl)->returnBufSize < (size)+(align)) { \
+ (cl)->returnBuf = (GLbyte*)Xrealloc((cl)->returnBuf, \
+ (size)+(align)); \
+ if (!(cl)->returnBuf) { \
+ return BadAlloc; \
+ } \
+ (cl)->returnBufSize = (size)+(align); \
+ } \
+ res = (char*)cl->returnBuf; \
+ bump = (long)(res) % (align); \
+ if (bump) res += (align) - (bump); \
+ } else { \
+ res = (char *)answerBuffer; \
+ }
+
+#define __GLX_PUT_BYTE() \
+ *(GLbyte *)&__glXReply.pad3 = *(GLbyte *)answer
+
+#define __GLX_PUT_SHORT() \
+ *(GLshort *)&__glXReply.pad3 = *(GLshort *)answer
+
+#define __GLX_PUT_INT() \
+ *(GLint *)&__glXReply.pad3 = *(GLint *)answer
+
+#define __GLX_PUT_FLOAT() \
+ *(GLfloat *)&__glXReply.pad3 = *(GLfloat *)answer
+
+#define __GLX_PUT_DOUBLE() \
+ *(GLdouble *)&__glXReply.pad3 = *(GLdouble *)answer
+
+#define __GLX_SEND_BYTE_ARRAY(len) \
+ WriteToClient(client, __GLX_PAD((len)*__GLX_SIZE_INT8), (char *)answer)
+
+#define __GLX_SEND_SHORT_ARRAY(len) \
+ WriteToClient(client, __GLX_PAD((len)*__GLX_SIZE_INT16), (char *)answer)
+
+#define __GLX_SEND_INT_ARRAY(len) \
+ WriteToClient(client, (len)*__GLX_SIZE_INT32, (char *)answer)
+
+#define __GLX_SEND_FLOAT_ARRAY(len) \
+ WriteToClient(client, (len)*__GLX_SIZE_FLOAT32, (char *)answer)
+
+#define __GLX_SEND_DOUBLE_ARRAY(len) \
+ WriteToClient(client, (len)*__GLX_SIZE_FLOAT64, (char *)answer)
+
+
+#define __GLX_SEND_VOID_ARRAY(len) __GLX_SEND_BYTE_ARRAY(len)
+#define __GLX_SEND_UBYTE_ARRAY(len) __GLX_SEND_BYTE_ARRAY(len)
+#define __GLX_SEND_USHORT_ARRAY(len) __GLX_SEND_SHORT_ARRAY(len)
+#define __GLX_SEND_UINT_ARRAY(len) __GLX_SEND_INT_ARRAY(len)
+
+/*
+** PERFORMANCE NOTE:
+** Machine dependent optimizations abound here; these swapping macros can
+** conceivably be replaced with routines that do the job faster.
+*/
+#define __GLX_DECLARE_SWAP_VARIABLES \
+ GLbyte sw; \
+ GLbyte *swapPC; \
+ GLbyte *swapEnd
+
+
+#define __GLX_SWAP_INT(pc) \
+ sw = ((GLbyte *)(pc))[0]; \
+ ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[3]; \
+ ((GLbyte *)(pc))[3] = sw; \
+ sw = ((GLbyte *)(pc))[1]; \
+ ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[2]; \
+ ((GLbyte *)(pc))[2] = sw;
+
+#define __GLX_SWAP_SHORT(pc) \
+ sw = ((GLbyte *)(pc))[0]; \
+ ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[1]; \
+ ((GLbyte *)(pc))[1] = sw;
+
+#define __GLX_SWAP_DOUBLE(pc) \
+ sw = ((GLbyte *)(pc))[0]; \
+ ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[7]; \
+ ((GLbyte *)(pc))[7] = sw; \
+ sw = ((GLbyte *)(pc))[1]; \
+ ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[6]; \
+ ((GLbyte *)(pc))[6] = sw; \
+ sw = ((GLbyte *)(pc))[2]; \
+ ((GLbyte *)(pc))[2] = ((GLbyte *)(pc))[5]; \
+ ((GLbyte *)(pc))[5] = sw; \
+ sw = ((GLbyte *)(pc))[3]; \
+ ((GLbyte *)(pc))[3] = ((GLbyte *)(pc))[4]; \
+ ((GLbyte *)(pc))[4] = sw;
+
+#define __GLX_SWAP_FLOAT(pc) \
+ sw = ((GLbyte *)(pc))[0]; \
+ ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[3]; \
+ ((GLbyte *)(pc))[3] = sw; \
+ sw = ((GLbyte *)(pc))[1]; \
+ ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[2]; \
+ ((GLbyte *)(pc))[2] = sw;
+
+#define __GLX_SWAP_INT_ARRAY(pc, count) \
+ swapPC = ((GLbyte *)(pc)); \
+ swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_INT32;\
+ while (swapPC < swapEnd) { \
+ __GLX_SWAP_INT(swapPC); \
+ swapPC += __GLX_SIZE_INT32; \
+ }
+
+#define __GLX_SWAP_SHORT_ARRAY(pc, count) \
+ swapPC = ((GLbyte *)(pc)); \
+ swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_INT16;\
+ while (swapPC < swapEnd) { \
+ __GLX_SWAP_SHORT(swapPC); \
+ swapPC += __GLX_SIZE_INT16; \
+ }
+
+#define __GLX_SWAP_DOUBLE_ARRAY(pc, count) \
+ swapPC = ((GLbyte *)(pc)); \
+ swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_FLOAT64;\
+ while (swapPC < swapEnd) { \
+ __GLX_SWAP_DOUBLE(swapPC); \
+ swapPC += __GLX_SIZE_FLOAT64; \
+ }
+
+#define __GLX_SWAP_FLOAT_ARRAY(pc, count) \
+ swapPC = ((GLbyte *)(pc)); \
+ swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_FLOAT32;\
+ while (swapPC < swapEnd) { \
+ __GLX_SWAP_FLOAT(swapPC); \
+ swapPC += __GLX_SIZE_FLOAT32; \
+ }
+
+#define __GLX_SWAP_REPLY_HEADER() \
+ __GLX_SWAP_SHORT(&__glXReply.sequenceNumber); \
+ __GLX_SWAP_INT(&__glXReply.length);
+
+#define __GLX_SWAP_REPLY_RETVAL() \
+ __GLX_SWAP_INT(&__glXReply.retval)
+
+#define __GLX_SWAP_REPLY_SIZE() \
+ __GLX_SWAP_INT(&__glXReply.size)
+
+#endif /* !__GLX_unpack_h__ */
+
+
+
+
+
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/ChkNotMaskEv.c b/nx-X11/programs/Xserver/hw/dmx/input/ChkNotMaskEv.c
new file mode 100644
index 000000000..220e1de39
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/ChkNotMaskEv.c
@@ -0,0 +1,108 @@
+/* Derived from Xorg: ChkMaskEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp */
+/*
+ * Copyright 1985, 1987, 1998 The Open Group
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of The Open Group shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from The Open Group.
+ */
+/* $XFree86 */
+
+/*
+ * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/** \file
+ * This file provides a #XCheckNotMaskEvent function that is derived
+ * from the standard Xlib XCheckMaskEvent function. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#define NEED_EVENTS
+#include "dmx.h"
+#include "ChkNotMaskEv.h"
+
+extern long const _Xevent_to_mask[];
+
+/** Check existing events in queue to find if any match. If so, return.
+ * If not, flush buffer and see if any more events are readable. If one
+ * matches, return. If all else fails, tell the user no events found.
+ */
+Bool XCheckNotMaskEvent (Display *dpy, long mask, XEvent *event)
+{
+ register _XQEvent *prev, *qelt;
+ unsigned long qe_serial = 0;
+ int n; /* time through count */
+
+ LockDisplay(dpy);
+ prev = NULL;
+ for (n = 3; --n >= 0;) {
+ for (qelt = prev ? prev->next : dpy->head;
+ qelt;
+ prev = qelt, qelt = qelt->next) {
+ if (qelt->event.type >= LASTEvent
+ || !(_Xevent_to_mask[qelt->event.type] & mask)) {
+ *event = qelt->event;
+ _XDeq(dpy, prev, qelt);
+ UnlockDisplay(dpy);
+ return True;
+ }
+ }
+ if (prev)
+ qe_serial = prev->qserial_num;
+ switch (n) {
+ case 2:
+ _XEventsQueued(dpy, QueuedAfterReading);
+ break;
+ case 1:
+ _XFlush(dpy);
+ break;
+ }
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+ UnlockDisplay(dpy);
+ return False;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/ChkNotMaskEv.h b/nx-X11/programs/Xserver/hw/dmx/input/ChkNotMaskEv.h
new file mode 100644
index 000000000..777d3a28a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/ChkNotMaskEv.h
@@ -0,0 +1,41 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for #XCheckNotMaskEvent function. \see ChkNotMaskEv.c */
+
+#ifndef _CHKNOTMASKEV_H_
+#define _CHKNOTMASKEV_H_
+extern Bool XCheckNotMaskEvent (Display *dpy, long mask, XEvent *event);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/Imakefile b/nx-X11/programs/Xserver/hw/dmx/input/Imakefile
new file mode 100644
index 000000000..65e298ec2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/Imakefile
@@ -0,0 +1,46 @@
+XCOMM $XFree86$
+
+#include <Server.tmpl>
+#include <lnxdoc.rules>
+
+#ifdef __linux__
+RAWSRCS = lnx-keyboard.c lnx-ms.c lnx-ps2.c
+RAWOBJS = lnx-keyboard.o lnx-ms.o lnx-ps2.o
+#endif
+
+#ifdef __linux__
+USBSRCS = usb-keyboard.c usb-mouse.c usb-other.c usb-common.c
+USBOBJS = usb-keyboard.o usb-mouse.o usb-other.o usb-common.o
+#endif
+
+DRVSRCS = dmxdummy.c dmxbackend.c dmxconsole.c dmxcommon.c
+DRVOBJS = dmxdummy.o dmxbackend.o dmxconsole.o dmxcommon.o
+
+DMXSRCS = dmxinputinit.c dmxarg.c dmxsigio.c dmxevents.c \
+ dmxxinput.c dmxmotion.c dmxeq.c dmxmap.c
+DMXOBJS = dmxinputinit.o dmxarg.o dmxsigio.o dmxevents.o \
+ dmxxinput.o dmxmotion.o dmxeq.o dmxmap.o
+
+LIBSRCS = ChkNotMaskEv.c
+LIBOBJS = ChkNotMaskEv.o
+
+SRCS = $(RAWSRCS) $(USBSRCS) $(DRVSRCS) $(DMXSRCS) $(LIBSRCS)
+OBJS = $(RAWOBJS) $(USBOBJS) $(DRVOBJS) $(DMXOBJS) $(LIBOBJS)
+
+#include <dmx.cf>
+
+INCLUDES = -I. -I.. -I$(XBUILDINCDIR) -I$(FONTINCSRC) -I../../../mi \
+ -I../../../include -I../../../render -I$(EXTINCSRC) \
+ -I$(SERVERSRC)/Xext -I$(SERVERSRC)/Xi
+
+DEFINES = $(OS_DEFINES) $(EXT_DEFINES) $(DMX_DEFINES)
+
+all:: $(OBJS)
+
+LinkSourceFile(atKeynames.h,$(XF86COMSRC))
+LinkSourceFile(xf86Keymap.h,$(XF86COMSRC))
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(dmxinput,$(OBJS))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxarg.c b/nx-X11/programs/Xserver/hw/dmx/input/dmxarg.c
new file mode 100644
index 000000000..8708fa009
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxarg.c
@@ -0,0 +1,176 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Generic comma-delimited argument processing. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#define DMX_ARG_TEST 0
+
+#include "dmx.h"
+#include "dmxarg.h"
+#include <stdio.h>
+#include <string.h>
+
+#if DMX_ARG_TEST
+#include <stdlib.h>
+#endif
+
+/** Stores the parsed argument list. */
+struct _dmxArg {
+ int argc; /**< Number of arguments in argv */
+ int argm; /**< Maximum number of arguments store-able in argv */
+ const char **argv; /**< Arguments */
+};
+
+/** Create an (externally opaque) \a dmxArg object. */
+dmxArg dmxArgCreate(void)
+{
+ dmxArg a = malloc(sizeof(*a));
+ a->argc = 0;
+ a->argm = 2;
+ a->argv = malloc(a->argm * sizeof(*a->argv));
+ a->argv[0] = NULL;
+ return a;
+}
+
+/** Free the specified \a dmxArg object. */
+void dmxArgFree(dmxArg a)
+{
+ int i;
+
+ for (i = 0; i < a->argc; i++) free((char *)a->argv[i]);
+ free(a->argv);
+ free(a);
+}
+
+/** Add the \a string as the next argument in the \a dmxArg object. */
+void dmxArgAdd(dmxArg a, const char *string)
+{
+ if (a->argm <= a->argc + 2)
+ a->argv = realloc(a->argv, sizeof(*a->argv) * (a->argm *= 2));
+ a->argv[a->argc++] = strdup(string);
+ a->argv[a->argc] = NULL;
+}
+
+/** Return the argument number \a item in the \a dmxArg object.
+ * Arguments are 0 based. NULL will be returned for values less than 0
+ * or equal to or greater than the number of arguments in the object. */
+const char *dmxArgV(dmxArg a, int item)
+{
+ if (item < 0 || item >= a->argc) return NULL;
+ return a->argv[item];
+}
+
+/** Return the number of arguments in the \a dmxArg object. */
+int dmxArgC(dmxArg a)
+{
+ return a->argc;
+}
+
+/** Parse a string into arguments delimited by commas. Return a new \a
+ * dmxArg object containing the arguments. */
+dmxArg dmxArgParse(const char *string)
+{
+ char *tmp;
+ char *start, *pt;
+ dmxArg a = dmxArgCreate();
+ int done;
+ int len;
+
+ if (!string) return a;
+
+ len = strlen(string) + 2;
+ tmp = malloc(len);
+ strncpy(tmp, string, len);
+
+ for (start = pt = tmp, done = 0; !done && *pt; start = ++pt) {
+ for (;*pt && *pt != ','; pt++);
+ if (!*pt) done = 1;
+ *pt = '\0';
+ dmxArgAdd(a, start);
+ }
+ if (!done) dmxArgAdd(a, ""); /* Final comma */
+
+ free(tmp);
+ return a;
+}
+
+#if DMX_ARG_TEST
+static void dmxArgPrint(dmxArg a)
+{
+ int i;
+
+ printf(" argc = %d\n", dmxArgC(a));
+ for (i = 0; i < dmxArgC(a); i++)
+ printf(" argv[%d] = \"%s\"\n", i, dmxArgV(a, i));
+}
+
+static void dmxArgTest(const char *string)
+{
+ dmxArg a;
+
+ if (!string)
+ printf("Testing NULL\n");
+ else if (!strlen(string))
+ printf("Testing (empty)\n");
+ else
+ printf("Testing \"%s\"\n", string);
+
+ a = dmxArgParse(string);
+ dmxArgPrint(a);
+ dmxArgFree(a);
+}
+
+int main(void)
+{
+ dmxArgTest(NULL);
+ dmxArgTest("");
+ dmxArgTest(",");
+
+ dmxArgTest("a");
+ dmxArgTest("a,");
+ dmxArgTest(",a");
+
+ dmxArgTest("a,b");
+ dmxArgTest("a,b,");
+ dmxArgTest("a,b,,");
+ dmxArgTest("a,b,,c");
+
+ return 0;
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxarg.h b/nx-X11/programs/Xserver/hw/dmx/input/dmxarg.h
new file mode 100644
index 000000000..b377aca70
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxarg.h
@@ -0,0 +1,50 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to argument handling functions. \see dmxarg.c */
+
+#ifndef _DMXARG_H_
+#define _DMXARG_H_
+
+typedef struct _dmxArg *dmxArg;
+
+extern dmxArg dmxArgCreate(void);
+extern void dmxArgFree(dmxArg a);
+extern void dmxArgAdd(dmxArg a, const char *string);
+extern const char *dmxArgV(dmxArg a, int item);
+extern int dmxArgC(dmxArg a);
+extern dmxArg dmxArgParse(const char *string);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxbackend.c b/nx-X11/programs/Xserver/hw/dmx/input/dmxbackend.c
new file mode 100644
index 000000000..8985a1b1d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxbackend.c
@@ -0,0 +1,608 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * David H. Dawes <dawes@xfree86.org>
+ * Kevin E. Martin <kem@redhat.com>
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ */
+
+/** \file
+ * These routines support taking input from devices on the backend
+ * (output) displays. \see dmxcommon.c. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#define DMX_BACKEND_DEBUG 0
+
+#include "dmxinputinit.h"
+#include "dmxbackend.h"
+#include "dmxcommon.h"
+#include "dmxconsole.h"
+#include "dmxcursor.h"
+#include "dmxprop.h"
+#include "dmxsync.h"
+#include "dmxcb.h" /* For dmxGlobalWidth and dmxGlobalHeight */
+#include "dmxevents.h" /* For dmxGetGlobalPosition */
+#include "ChkNotMaskEv.h"
+
+#include "inputstr.h"
+#include "input.h"
+#include <X11/keysym.h>
+#include "mipointer.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+/* Private area for backend devices. */
+typedef struct _myPrivate {
+ DMX_COMMON_PRIVATE;
+ int myScreen;
+ DMXScreenInfo *grabbedScreen;
+
+ int lastX, lastY;
+ int centerX, centerY;
+ int relative;
+ int newscreen;
+ int initialized;
+ DevicePtr mou, kbd;
+ int entered;
+ int offX, offY;
+} myPrivate;
+
+#if DMX_BACKEND_DEBUG
+#define DMXDBG0(f) dmxLog(dmxDebug,f)
+#define DMXDBG1(f,a) dmxLog(dmxDebug,f,a)
+#define DMXDBG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define DMXDBG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define DMXDBG4(f,a,b,c,d) dmxLog(dmxDebug,f,a,b,c,d)
+#define DMXDBG5(f,a,b,c,d,e) dmxLog(dmxDebug,f,a,b,c,d,e)
+#define DMXDBG6(f,a,b,c,d,e,g) dmxLog(dmxDebug,f,a,b,c,d,e,g)
+#define DMXDBG7(f,a,b,c,d,e,g,h) dmxLog(dmxDebug,f,a,b,c,d,e,g,h)
+#define DMXDBG8(f,a,b,c,d,e,g,h,i) dmxLog(dmxDebug,f,a,b,c,d,e,g,h,i)
+#define DMXDBG9(f,a,b,c,d,e,g,h,i,j) dmxLog(dmxDebug,f,a,b,c,d,e,g,h,i,j)
+#else
+#define DMXDBG0(f)
+#define DMXDBG1(f,a)
+#define DMXDBG2(f,a,b)
+#define DMXDBG3(f,a,b,c)
+#define DMXDBG4(f,a,b,c,d)
+#define DMXDBG5(f,a,b,c,d,e)
+#define DMXDBG6(f,a,b,c,d,e,g)
+#define DMXDBG7(f,a,b,c,d,e,g,h)
+#define DMXDBG8(f,a,b,c,d,e,g,h,i)
+#define DMXDBG9(f,a,b,c,d,e,g,h,i,j)
+#endif
+
+/** Create and return a private data structure. */
+pointer dmxBackendCreatePrivate(DeviceIntPtr pDevice)
+{
+ GETDMXLOCALFROMPDEVICE;
+ myPrivate *priv = xalloc(sizeof(*priv));
+ memset(priv, 0, sizeof(*priv));
+ priv->dmxLocal = dmxLocal;
+ return priv;
+}
+
+/** Destroy the private data structure. No checking is performed to
+ * verify that the structure was actually created by
+ * #dmxBackendCreatePrivate. */
+void dmxBackendDestroyPrivate(pointer private)
+{
+ if (private) xfree(private);
+}
+
+static void *dmxBackendTestScreen(DMXScreenInfo *dmxScreen, void *closure)
+{
+ long target = (long)closure;
+
+ if (dmxScreen->index == target) return dmxScreen;
+ return NULL;
+}
+
+/* Return non-zero if screen and priv->myScreen are on the same physical
+ * backend display (1 if they are the same screen, 2 if they are
+ * different screens). Since this is a common operation, the results
+ * are cached. The cache is invalidated if \a priv is NULL (this should
+ * be done with each server generation and reconfiguration). */
+static int dmxBackendSameDisplay(myPrivate *priv, long screen)
+{
+ static myPrivate *oldpriv = NULL;
+ static int oldscreen = -1;
+ static int retcode = 0;
+
+ if (priv == oldpriv && screen == oldscreen) return retcode;
+ if (!priv) { /* Invalidate cache */
+ oldpriv = NULL;
+ oldscreen = -1;
+ retcode = 0;
+ return 0;
+ }
+
+ if (screen == priv->myScreen) retcode = 1;
+ else if (screen < 0 || screen >= dmxNumScreens) retcode = 0;
+ else if (dmxPropertyIterate(priv->be,
+ dmxBackendTestScreen,
+ (void *)screen)) retcode = 2;
+ else retcode = 0;
+
+ oldpriv = priv;
+ oldscreen = screen;
+ return retcode;
+}
+
+static void *dmxBackendTestEvents(DMXScreenInfo *dmxScreen, void *closure)
+{
+ XEvent *X = (XEvent *)closure;
+
+ if (XCheckNotMaskEvent(dmxScreen->beDisplay, ExposureMask, X))
+ return dmxScreen;
+ return NULL;
+}
+
+static void *dmxBackendTestMotionEvent(DMXScreenInfo *dmxScreen, void *closure)
+{
+ XEvent *X = (XEvent *)closure;
+
+ if (XCheckTypedEvent(dmxScreen->beDisplay, MotionNotify, X))
+ return dmxScreen;
+ return NULL;
+}
+
+static DMXScreenInfo *dmxBackendGetEvent(myPrivate *priv, XEvent *X)
+{
+ DMXScreenInfo *dmxScreen;
+
+ if ((dmxScreen = dmxPropertyIterate(priv->be, dmxBackendTestEvents, X)))
+ return dmxScreen;
+ return NULL;
+}
+
+static DMXScreenInfo *dmxBackendPendingMotionEvent(myPrivate *priv, int save)
+{
+ DMXScreenInfo *dmxScreen;
+ XEvent N;
+
+ if ((dmxScreen = dmxPropertyIterate(priv->be,
+ dmxBackendTestMotionEvent, &N))) {
+ if (save) XPutBackEvent(dmxScreen->beDisplay, &N);
+ return dmxScreen;
+ }
+ return NULL;
+}
+
+static void *dmxBackendTestWindow(DMXScreenInfo *dmxScreen, void *closure)
+{
+ Window win = (Window)(long)closure;
+ if (dmxScreen->scrnWin == win) return dmxScreen;
+ return NULL;
+}
+
+static DMXScreenInfo *dmxBackendFindWindow(myPrivate *priv, Window win)
+{
+ return dmxPropertyIterate(priv->be, dmxBackendTestWindow,
+ (void *)(long)win);
+}
+
+/* If the cursor is over a set of overlapping screens and one of those
+ * screens takes backend input, then we want that particular screen to
+ * be current, not one of the other ones. */
+static int dmxBackendFindOverlapping(myPrivate *priv, int screen, int x, int y)
+{
+ DMXScreenInfo *start = &dmxScreens[screen];
+ DMXScreenInfo *pt;
+
+ if (!start->over) return screen;
+
+ for (pt = start->over; /* condition at end of loop */; pt = pt->over) {
+ if (pt->index == priv->myScreen
+ && dmxOnScreen(x, y, &dmxScreens[pt->index])) return pt->index;
+ if (pt == start) break;
+ }
+ return screen;
+}
+
+/* Return non-zero if \a x and \a y are off \a screen. */
+static int dmxBackendOffscreen(int screen, int x, int y)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[screen];
+
+ return (!dmxOnScreen(x, y, dmxScreen));
+}
+
+/** This routine is called from #dmxCoreMotion for each motion
+ * event. #x and #y are global coordinants. */
+void dmxBackendUpdatePosition(pointer private, int x, int y)
+{
+ GETPRIVFROMPRIVATE;
+ int screen = miPointerCurrentScreen()->myNum;
+ DMXScreenInfo *dmxScreen = &dmxScreens[priv->myScreen];
+ int oldRelative = priv->relative;
+ int topscreen = dmxBackendFindOverlapping(priv, screen, x, y);
+ int same = dmxBackendSameDisplay(priv, topscreen);
+ int offscreen = dmxBackendOffscreen(priv->myScreen, x, y);
+ int offthis = dmxBackendOffscreen(screen, x, y);
+
+ DMXDBG9("dmxBackendUpdatePosition(%d,%d) my=%d mi=%d rel=%d"
+ " topscreen=%d same=%d offscreen=%d offthis=%d\n",
+ x, y, priv->myScreen, screen, priv->relative,
+ topscreen, same, offscreen, offthis);
+
+ if (offscreen) {
+ /* If the cursor is off the input screen, it should be moving
+ * relative unless it is visible on a screen of the same display
+ * (i.e., one that shares the mouse). */
+ if (same == 2 && !offthis) {
+ if (priv->relative) {
+ DMXDBG0(" Off screen, but not absolute\n");
+ priv->relative = 0;
+ }
+ } else {
+ if (!priv->relative) {
+ DMXDBG0(" Off screen, but not relative\n");
+ priv->relative = 1;
+ }
+ }
+ } else {
+ if (topscreen != screen) {
+ DMXDBG2(" Using screen %d instead of %d (from mi)\n",
+ topscreen, screen);
+ }
+ if (same) {
+ if (priv->relative) {
+ DMXDBG0(" On screen, but not absolute\n");
+ priv->relative = 0;
+ }
+ } else {
+ if (!priv->relative) {
+ DMXDBG0(" Not on screen, but not relative\n");
+ priv->relative = 1;
+ }
+ }
+ }
+
+ if (oldRelative != priv->relative) {
+ DMXDBG2(" Do switch, relative=%d same=%d\n",
+ priv->relative, same);
+ /* Discard all pre-switch events */
+ dmxSync(dmxScreen, TRUE);
+ while (dmxBackendPendingMotionEvent(priv, FALSE));
+
+ if (dmxInput->console && offscreen) {
+ /* Our special case is a console window and a backend window
+ * share a display. In this case, the cursor is either on
+ * the backend window (taking absolute input), or not (in
+ * which case the cursor needs to be in the console
+ * window). */
+ if (priv->grabbedScreen) {
+ DMXDBG2(" *** force ungrab on %s, display=%p\n",
+ priv->grabbedScreen->name,
+ priv->grabbedScreen->beDisplay);
+ XUngrabPointer(priv->grabbedScreen->beDisplay, CurrentTime);
+ dmxSync(priv->grabbedScreen, TRUE);
+ priv->grabbedScreen = NULL;
+ }
+ DMXDBG0(" Capturing console\n");
+ dmxConsoleCapture(dmxInput);
+ } else {
+ priv->newscreen = 1;
+ if (priv->relative && !dmxInput->console) {
+ DMXDBG5(" Hide cursor; warp from %d,%d to %d,%d on %d\n",
+ priv->lastX, priv->lastY, priv->centerX, priv->centerY,
+ priv->myScreen);
+ dmxConsoleUncapture(dmxInput);
+ dmxHideCursor(dmxScreen);
+ priv->lastX = priv->centerX;
+ priv->lastY = priv->centerY;
+ XWarpPointer(priv->display, None, priv->window,
+ 0, 0, 0, 0, priv->lastX, priv->lastY);
+ dmxSync(dmxScreen, TRUE);
+ } else {
+ DMXDBG0(" Check cursor\n");
+ dmxCheckCursor();
+ }
+ }
+ }
+}
+
+/** Get events from the X queue on the backend servers and put the
+ * events into the DMX event queue. */
+void dmxBackendCollectEvents(DevicePtr pDev,
+ dmxMotionProcPtr motion,
+ dmxEnqueueProcPtr enqueue,
+ dmxCheckSpecialProcPtr checkspecial,
+ DMXBlockType block)
+{
+ GETPRIVFROMPDEV;
+ GETDMXINPUTFROMPRIV;
+ XEvent X;
+ DMXScreenInfo *dmxScreen;
+ int left = 0;
+ int entered = priv->entered;
+ int ignoreLeave = 0;
+ int v[2];
+ int retcode;
+
+ while ((dmxScreen = dmxBackendGetEvent(priv, &X))) {
+ switch (X.type) {
+ case EnterNotify:
+ dmxCommonSaveState(priv);
+ if (entered++) continue;
+ priv->entered = 1;
+ ignoreLeave = 1;
+ DMXDBG5("dmxBackendCollectEvents: Enter %lu %d,%d; GRAB %s %p\n",
+ X.xcrossing.root, X.xcrossing.x, X.xcrossing.y,
+ dmxScreen->name, dmxScreen->beDisplay);
+ XRaiseWindow(dmxScreen->beDisplay, dmxScreen->scrnWin);
+ priv->grabbedScreen = dmxScreen;
+ if ((retcode = XGrabPointer(dmxScreen->beDisplay,
+ dmxScreen->scrnWin,
+ True, 0, GrabModeAsync,
+ GrabModeAsync, None, None,
+ CurrentTime))) {
+ dmxLog(dmxError,
+ "XGrabPointer failed during backend enter (%d)\n",
+ retcode);
+ }
+ break;
+ case LeaveNotify:
+ if (ignoreLeave) {
+ ignoreLeave = 0;
+ continue;
+ }
+ dmxCommonRestoreState(priv);
+ if (left++) continue;
+ DMXDBG7("dmxBackendCollectEvents: Leave %lu %d,%d %d %d %s %s\n",
+ X.xcrossing.root, X.xcrossing.x, X.xcrossing.y,
+ X.xcrossing.detail, X.xcrossing.focus,
+ priv->grabbedScreen ? "UNGRAB" : "",
+ dmxScreen->name);
+ if (priv->grabbedScreen) {
+ XUngrabPointer(priv->grabbedScreen->beDisplay, CurrentTime);
+ dmxSync(priv->grabbedScreen, TRUE);
+ priv->grabbedScreen = NULL;
+ }
+ break;
+ case MotionNotify:
+ DMXDBG9("dmxBackendCollectEvents: MotionNotify %d/%d (mi %d)"
+ " newscreen=%d: %d %d (e=%d; last=%d,%d)\n",
+ dmxScreen->index, priv->myScreen,
+ miPointerCurrentScreen()->myNum,
+ priv->newscreen,
+ X.xmotion.x, X.xmotion.y,
+ entered, priv->lastX, priv->lastY);
+ if (dmxBackendPendingMotionEvent(priv, TRUE)) continue;
+ if (!(dmxScreen = dmxBackendFindWindow(priv, X.xmotion.window)))
+ dmxLog(dmxFatal,
+ " Event on non-existant window %lu\n",
+ X.xmotion.window);
+ if (!priv->relative || dmxInput->console) {
+ int newX = X.xmotion.x - dmxScreen->rootX;
+ int newY = X.xmotion.y - dmxScreen->rootY;
+
+ if (!priv->newscreen) {
+ int width = dmxScreen->rootWidth;
+ int height = dmxScreen->rootHeight;
+ if (!newX) newX = -1;
+ if (newX == width - 1) newX = width;
+ if (!newY) newY = -1;
+ if (newY == height - 1) newY = height;
+ }
+ priv->newscreen = 0;
+ v[0] = dmxScreen->rootXOrigin + newX;
+ v[1] = dmxScreen->rootYOrigin + newY;
+ DMXDBG8(" Absolute move: %d,%d (r=%dx%d+%d+%d s=%dx%d)\n",
+ v[0], v[1],
+ priv->be->rootWidth, priv->be->rootHeight,
+ priv->be->rootX, priv->be->rootY,
+ priv->be->scrnWidth, priv->be->scrnHeight);
+ motion(priv->mou, v, 0, 2, DMX_ABSOLUTE, block);
+ priv->entered = 0;
+ } else {
+ int newX = priv->lastX - X.xmotion.x;
+ int newY = priv->lastY - X.xmotion.y;
+ priv->lastX = X.xmotion.x;
+ priv->lastY = X.xmotion.y;
+ v[0] = newX;
+ v[1] = newY;
+ DMXDBG2(" Relative move: %d, %d\n", v[0], v[1]);
+ motion(priv->mou, v, 0, 2, DMX_RELATIVE, block);
+ }
+ if (entered && priv->relative) {
+ DMXDBG4(" **** Relative %d %d instead of absolute %d %d\n",
+ v[0], v[1],
+ (dmxScreen->rootXOrigin + X.xmotion.x
+ - dmxScreen->rootX),
+ (dmxScreen->rootYOrigin + X.xmotion.y
+ - dmxScreen->rootY));
+ }
+ break;
+
+ case KeyPress:
+ case KeyRelease:
+ enqueue(priv->kbd, X.type, X.xkey.keycode, 0, NULL, block);
+ break;
+ default:
+ /* Pass the whole event here, because
+ * this may be an extension event. */
+ enqueue(priv->mou, X.type, X.xbutton.button, 0, &X, block);
+ break;
+ }
+ }
+}
+
+/** Called after input events are processed from the DMX queue. No
+ * event processing actually takes place here, but this is a convenient
+ * place to update the pointer. */
+void dmxBackendProcessInput(pointer private)
+{
+ GETPRIVFROMPRIVATE;
+
+ DMXDBG6("dmxBackendProcessInput: myScreen=%d relative=%d"
+ " last=%d,%d center=%d,%d\n",
+ priv->myScreen, priv->relative,
+ priv->lastX, priv->lastY,
+ priv->centerX, priv->centerY);
+
+ if (priv->relative
+ && !dmxInput->console
+ && (priv->lastX != priv->centerX || priv->lastY != priv->centerY)) {
+ DMXDBG4(" warping pointer from last=%d,%d to center=%d,%d\n",
+ priv->lastX, priv->lastY, priv->centerX, priv->centerY);
+ priv->lastX = priv->centerX;
+ priv->lastY = priv->centerY;
+ XWarpPointer(priv->display, None, priv->window,
+ 0, 0, 0, 0, priv->lastX, priv->lastY);
+ dmxSync(&dmxScreens[priv->myScreen], TRUE);
+ }
+}
+
+static void dmxBackendComputeCenter(myPrivate *priv)
+{
+ int centerX;
+ int centerY;
+
+ centerX = priv->be->rootWidth / 2 + priv->be->rootX;
+ centerY = priv->be->rootHeight / 2 + priv->be->rootY;
+
+ if (centerX > priv->be->rootWidth) centerX = priv->be->rootWidth - 1;
+ if (centerY > priv->be->rootHeight) centerY = priv->be->rootHeight - 1;
+ if (centerX < 1) centerX = 1;
+ if (centerY < 1) centerY = 1;
+
+ priv->centerX = centerX;
+ priv->centerY = centerY;
+}
+
+static DMXScreenInfo *dmxBackendInitPrivate(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx];
+ DMXScreenInfo *dmxScreen;
+ int i;
+
+ /* Fill in myPrivate */
+ for (i = 0,dmxScreen = &dmxScreens[0]; i<dmxNumScreens; i++,dmxScreen++) {
+ if (dmxPropertySameDisplay(dmxScreen, dmxInput->name)) {
+ priv->display = dmxScreen->beDisplay;
+ priv->window = dmxScreen->scrnWin;
+ priv->be = dmxScreen;
+ break;
+ }
+ }
+
+ if (i >= dmxNumScreens)
+ dmxLog(dmxFatal,
+ "%s is not an existing backend display - cannot initialize\n",
+ dmxInput->name);
+
+ return dmxScreen;
+}
+
+/** Re-initialized the backend device described by \a pDev (after a
+ * reconfig). */
+void dmxBackendLateReInit(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ int x, y;
+
+ DMXDBG1("dmxBackendLateReInit miPointerCurrentScreen() = %p\n",
+ miPointerCurrentScreen());
+
+ dmxBackendSameDisplay(NULL, 0); /* Invalidate cache */
+ dmxBackendInitPrivate(pDev);
+ dmxBackendComputeCenter(priv);
+ dmxGetGlobalPosition(&x, &y);
+ dmxInvalidateGlobalPosition(); /* To force event processing */
+ dmxBackendUpdatePosition(priv, x, y);
+}
+
+/** Initialized the backend device described by \a pDev. */
+void dmxBackendInit(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ DMXScreenInfo *dmxScreen;
+
+ dmxBackendSameDisplay(NULL, 0); /* Invalidate cache */
+
+ if (dmxLocal->type == DMX_LOCAL_MOUSE) priv->mou = pDev;
+ if (dmxLocal->type == DMX_LOCAL_KEYBOARD) priv->kbd = pDev;
+ if (priv->initialized++) return; /* Only do once for mouse/keyboard pair */
+
+ dmxScreen = dmxBackendInitPrivate(pDev);
+
+ /* Finish initialization using computed values or constants. */
+ dmxBackendComputeCenter(priv);
+ priv->eventMask = (EnterWindowMask|LeaveWindowMask);
+ priv->myScreen = dmxScreen->index;
+ priv->lastX = priv->centerX;
+ priv->lastY = priv->centerY;
+ priv->relative = 0;
+ priv->newscreen = 0;
+}
+
+/** Get information about the backend pointer (for initialization). */
+void dmxBackendMouGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ info->buttonClass = 1;
+ dmxCommonMouGetMap(pDev, info->map, &info->numButtons);
+ info->valuatorClass = 1;
+ info->numRelAxes = 2;
+ info->minval[0] = 0;
+ info->maxval[0] = 0;
+ info->res[0] = 1;
+ info->minres[0] = 0;
+ info->maxres[0] = 1;
+ info->ptrFeedbackClass = 1;
+}
+
+/** Get information about the backend keyboard (for initialization). */
+void dmxBackendKbdGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ dmxCommonKbdGetInfo(pDev, info);
+ info->keyboard = 1;
+ info->keyClass = 1;
+ dmxCommonKbdGetMap(pDev, &info->keySyms, info->modMap);
+ info->freemap = 1;
+ info->focusClass = 1;
+ info->kbdFeedbackClass = 1;
+}
+
+/** Process #DMXFunctionType functions. The only function handled here
+ * is to acknowledge a pending server shutdown. */
+int dmxBackendFunctions(pointer private, DMXFunctionType function)
+{
+ switch (function) {
+ case DMX_FUNCTION_TERMINATE:
+ return 1;
+ default:
+ return 0;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxbackend.h b/nx-X11/programs/Xserver/hw/dmx/input/dmxbackend.h
new file mode 100644
index 000000000..64a65f4a6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxbackend.h
@@ -0,0 +1,57 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to backend input device support. \see dmxbackend.c \see
+ * dmxcommon.c */
+
+#ifndef _DMXBACKEND_H_
+#define _DMXBACKEND_H_
+
+extern pointer dmxBackendCreatePrivate(DeviceIntPtr pDevice);
+extern void dmxBackendDestroyPrivate(pointer private);
+extern void dmxBackendInit(DevicePtr pDev);
+extern void dmxBackendLateReInit(DevicePtr pDev);
+extern void dmxBackendMouGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
+extern void dmxBackendKbdGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
+extern void dmxBackendCollectEvents(DevicePtr pDev,
+ dmxMotionProcPtr motion,
+ dmxEnqueueProcPtr enqueue,
+ dmxCheckSpecialProcPtr checkspecial,
+ DMXBlockType block);
+extern void dmxBackendProcessInput(pointer private);
+extern int dmxBackendFunctions(pointer private, DMXFunctionType function);
+extern void dmxBackendUpdatePosition(pointer private, int x, int y);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxcommon.c b/nx-X11/programs/Xserver/hw/dmx/input/dmxcommon.c
new file mode 100644
index 000000000..6a2b840e9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxcommon.c
@@ -0,0 +1,674 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * David H. Dawes <dawes@xfree86.org>
+ * Kevin E. Martin <kem@redhat.com>
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ */
+
+/** \file
+ *
+ * This file implements common routines used by the backend and console
+ * input devices.
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#define DMX_STATE_DEBUG 0
+
+#include "dmxinputinit.h"
+#include "dmxcommon.h"
+#include "dmxconsole.h"
+#include "dmxprop.h"
+#include "dmxsync.h"
+#include "dmxmap.h"
+
+#include "inputstr.h"
+#include "input.h"
+#include <X11/keysym.h>
+#include "mipointer.h"
+#include "scrnintstr.h"
+
+#include <unistd.h> /* For usleep() */
+
+#if DMX_STATE_DEBUG
+#define DMXDBG0(f) dmxLog(dmxDebug,f)
+#else
+#define DMXDBG0(f)
+#endif
+
+/** Each device has a private area that is visible only from inside the
+ * driver code. */
+typedef struct _myPrivate {
+ DMX_COMMON_PRIVATE;
+} myPrivate;
+
+static void dmxCommonKbdSetAR(Display *display,
+ unsigned char *old, unsigned char *new)
+{
+ XKeyboardControl kc;
+ XKeyboardState ks;
+ unsigned long mask = KBKey | KBAutoRepeatMode;
+ int i, j;
+ int minKeycode, maxKeycode;
+
+ if (!old) {
+ XGetKeyboardControl(display, &ks);
+ old = (unsigned char *)ks.auto_repeats;
+ }
+
+ XDisplayKeycodes(display, &minKeycode, &maxKeycode);
+ for (i = 1; i < 32; i++) {
+ if (!old || old[i] != new[i]) {
+ for (j = 0; j < 8; j++) {
+ if ((new[i] & (1 << j)) != (old[i] & (1 << j))) {
+ kc.key = i * 8 + j;
+ kc.auto_repeat_mode = ((new[i] & (1 << j))
+ ? AutoRepeatModeOn
+ : AutoRepeatModeOff);
+ if (kc.key >= minKeycode && kc.key <= maxKeycode)
+ XChangeKeyboardControl(display, mask, &kc);
+ }
+ }
+ }
+ }
+}
+
+static void dmxCommonKbdSetLeds(Display *display, unsigned long new)
+{
+ int i;
+ XKeyboardControl kc;
+
+ for (i = 0; i < 32; i++) {
+ kc.led = i + 1;
+ kc.led_mode = (new & (1 << i)) ? LedModeOn : LedModeOff;
+ XChangeKeyboardControl(display, KBLed | KBLedMode, &kc);
+ }
+}
+
+static void dmxCommonKbdSetCtrl(Display *display,
+ KeybdCtrl *old, KeybdCtrl *new)
+{
+ XKeyboardControl kc;
+ unsigned long mask = KBKeyClickPercent | KBAutoRepeatMode;
+
+ if (!old
+ || old->click != new->click
+ || old->autoRepeat != new->autoRepeat) {
+
+ kc.key_click_percent = new->click;
+ kc.auto_repeat_mode = new->autoRepeat;
+
+ XChangeKeyboardControl(display, mask, &kc);
+ }
+
+ dmxCommonKbdSetLeds(display, new->leds);
+ dmxCommonKbdSetAR(display, old ? old->autoRepeats : NULL,
+ new->autoRepeats);
+}
+
+static void dmxCommonMouSetCtrl(Display *display, PtrCtrl *old, PtrCtrl *new)
+{
+ Bool do_accel, do_threshold;
+
+ if (!old
+ || old->num != new->num
+ || old->den != new->den
+ || old->threshold != new->threshold) {
+ do_accel = (new->num > 0 && new->den > 0);
+ do_threshold = (new->threshold > 0);
+ if (do_accel || do_threshold) {
+ XChangePointerControl(display, do_accel, do_threshold,
+ new->num, new->den, new->threshold);
+ }
+ }
+}
+
+/** Update the keyboard control. */
+void dmxCommonKbdCtrl(DevicePtr pDev, KeybdCtrl *ctrl)
+{
+ GETPRIVFROMPDEV;
+
+ if (!priv->stateSaved && priv->be) dmxCommonSaveState(priv);
+ if (!priv->display || !priv->stateSaved) return;
+ dmxCommonKbdSetCtrl(priv->display,
+ priv->kctrlset ? &priv->kctrl : NULL,
+ ctrl);
+ priv->kctrl = *ctrl;
+ priv->kctrlset = 1;
+}
+
+/** Update the mouse control. */
+void dmxCommonMouCtrl(DevicePtr pDev, PtrCtrl *ctrl)
+{
+ GETPRIVFROMPDEV;
+
+ /* Don't set the acceleration for the
+ * console, because that should be
+ * controlled by the X server that the
+ * console is running on. Otherwise,
+ * the acceleration for the console
+ * window would be unexpected for the
+ * scale of the window. */
+ if (priv->be) {
+ dmxCommonMouSetCtrl(priv->display,
+ priv->mctrlset ? &priv->mctrl : NULL,
+ ctrl);
+ priv->mctrl = *ctrl;
+ priv->mctrlset = 1;
+ }
+}
+
+/** Sound they keyboard bell. */
+void dmxCommonKbdBell(DevicePtr pDev, int percent,
+ int volume, int pitch, int duration)
+{
+ GETPRIVFROMPDEV;
+ XKeyboardControl kc;
+ XKeyboardState ks;
+ unsigned long mask = KBBellPercent | KBBellPitch | KBBellDuration;
+
+ if (!priv->be) XGetKeyboardControl(priv->display, &ks);
+ kc.bell_percent = volume;
+ kc.bell_pitch = pitch;
+ kc.bell_duration = duration;
+ XChangeKeyboardControl(priv->display, mask, &kc);
+ XBell(priv->display, percent);
+ if (!priv->be) {
+ kc.bell_percent = ks.bell_percent;
+ kc.bell_pitch = ks.bell_pitch;
+ kc.bell_duration = ks.bell_duration;
+ XChangeKeyboardControl(priv->display, mask, &kc);
+ }
+}
+
+/** Get the keyboard mapping. */
+void dmxCommonKbdGetMap(DevicePtr pDev, KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ GETPRIVFROMPDEV;
+ int min_keycode;
+ int max_keycode;
+ int map_width;
+ KeySym *keyboard_mapping;
+ XModifierKeymap *modifier_mapping;
+ int i, j;
+
+ /* Compute pKeySyms. Cast
+ * XGetKeyboardMapping because of
+ * compiler warning on 64-bit machines.
+ * We assume pointers to 32-bit and
+ * 64-bit ints are the same. */
+ XDisplayKeycodes(priv->display, &min_keycode, &max_keycode);
+ keyboard_mapping = (KeySym *)XGetKeyboardMapping(priv->display,
+ min_keycode,
+ max_keycode
+ - min_keycode + 1,
+ &map_width);
+ pKeySyms->minKeyCode = min_keycode;
+ pKeySyms->maxKeyCode = max_keycode;
+ pKeySyms->mapWidth = map_width;
+ pKeySyms->map = keyboard_mapping;
+
+
+ /* Compute pModMap */
+ modifier_mapping = XGetModifierMapping(priv->display);
+ for (i = 0; i < MAP_LENGTH; i++) pModMap[i] = 0;
+ for (j = 0; j < 8; j++) {
+ int max_keypermod = modifier_mapping->max_keypermod;
+
+ for (i = 0; i < max_keypermod; i++) {
+ CARD8 keycode = modifier_mapping->modifiermap[j*max_keypermod + i];
+ if (keycode) pModMap[keycode] |= 1 << j;
+ }
+ }
+ XFreeModifiermap(modifier_mapping);
+}
+
+/** Fill in the XKEYBOARD parts of the \a info structure for the
+ * specified \a pDev. */
+void dmxCommonKbdGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+#ifdef XKB
+ GETPRIVFROMPDEV;
+ GETDMXINPUTFROMPRIV;
+ char *pt;
+
+ dmxCommonSaveState(priv);
+ if (priv->xkb) {
+ info->names.keymap = NULL;
+#define NAME(x) \
+ priv->xkb->names->x ? XGetAtomName(priv->display,priv->xkb->names->x) : NULL
+ info->names.keycodes = NAME(keycodes);
+ info->names.types = NAME(types);
+ info->names.compat = NAME(compat);
+ info->names.symbols = NAME(symbols);
+ info->names.geometry = NAME(geometry);
+ info->freenames = 1;
+#undef NAME
+ dmxLogInput(dmxInput,
+ "XKEYBOARD: keycodes = %s\n", info->names.keycodes);
+ dmxLogInput(dmxInput,
+ "XKEYBOARD: symbols = %s\n", info->names.symbols);
+ dmxLogInput(dmxInput,
+ "XKEYBOARD: geometry = %s\n", info->names.geometry);
+ if ((pt = strchr(info->names.keycodes, '+'))) *pt = '\0';
+ }
+ dmxCommonRestoreState(priv);
+#endif
+}
+
+/** Turn \a pDev on (i.e., take input from \a pDev). */
+int dmxCommonKbdOn(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ if (priv->be) dmxCommonSaveState(priv);
+ priv->eventMask |= DMX_KEYBOARD_EVENT_MASK;
+ XSelectInput(priv->display, priv->window, priv->eventMask);
+ if (priv->be)
+ XSetInputFocus(priv->display, priv->window, RevertToPointerRoot,
+ CurrentTime);
+ return -1;
+}
+
+/** Turn \a pDev off. */
+void dmxCommonKbdOff(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ priv->eventMask &= ~DMX_KEYBOARD_EVENT_MASK;
+ XSelectInput(priv->display, priv->window, priv->eventMask);
+ dmxCommonRestoreState(priv);
+}
+
+/** Turn \a pDev on (i.e., take input from \a pDev). */
+int dmxCommonOthOn(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ GETDMXINPUTFROMPRIV;
+ XEventClass event_list[DMX_MAX_XINPUT_EVENT_TYPES];
+ int event_type[DMX_MAX_XINPUT_EVENT_TYPES];
+ int count = 0;
+
+#define ADD(type) \
+ if (count < DMX_MAX_XINPUT_EVENT_TYPES) { \
+ type(priv->xi, event_type[count], event_list[count]); \
+ if (event_type[count]) { \
+ dmxMapInsert(dmxLocal, event_type[count], XI_##type); \
+ ++count; \
+ } \
+ } else { \
+ dmxLog(dmxWarning, "More than %d event types for %s\n", \
+ DMX_MAX_XINPUT_EVENT_TYPES, dmxInput->name); \
+ }
+
+ if (!(priv->xi = XOpenDevice(priv->display, dmxLocal->deviceId))) {
+ dmxLog(dmxWarning, "Cannot open %s device (id=%d) on %s\n",
+ dmxLocal->deviceName ? dmxLocal->deviceName : "(unknown)",
+ dmxLocal->deviceId, dmxInput->name);
+ return -1;
+ }
+ ADD(DeviceKeyPress);
+ ADD(DeviceKeyRelease);
+ ADD(DeviceButtonPress);
+ ADD(DeviceButtonRelease);
+ ADD(DeviceMotionNotify);
+ ADD(DeviceFocusIn);
+ ADD(DeviceFocusOut);
+ ADD(ProximityIn);
+ ADD(ProximityOut);
+ ADD(DeviceStateNotify);
+ ADD(DeviceMappingNotify);
+ ADD(ChangeDeviceNotify);
+ XSelectExtensionEvent(priv->display, priv->window, event_list, count);
+
+ return -1;
+}
+
+/** Turn \a pDev off. */
+void dmxCommonOthOff(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+
+ if (priv->xi) XCloseDevice(priv->display, priv->xi);
+ priv->xi = NULL;
+}
+
+/** Fill the \a info structure with information needed to initialize \a
+ * pDev. */
+void dmxCommonOthGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ GETPRIVFROMPDEV;
+ GETDMXINPUTFROMPRIV;
+ XExtensionVersion *ext;
+ XDeviceInfo *devices;
+ Display *display = priv->display;
+ int num;
+ int i, j, k;
+ int (*handler)(Display *, char *, char *);
+
+ if (!display && !(display = XOpenDisplay(dmxInput->name)))
+ return;
+
+ /* Print out information about the XInput Extension. */
+ handler = XSetExtensionErrorHandler(dmxInputExtensionErrorHandler);
+ ext = XGetExtensionVersion(display, INAME);
+ XSetExtensionErrorHandler(handler);
+
+ if (ext && ext != (XExtensionVersion *)NoSuchExtension) {
+ XFree(ext);
+ devices = XListInputDevices(display, &num);
+ for (i = 0; i < num; i++) {
+ if (devices[i].id == (XID)dmxLocal->deviceId) {
+ XAnyClassPtr any;
+ XKeyInfoPtr ki;
+ XButtonInfoPtr bi;
+ XValuatorInfoPtr vi;
+ for (j = 0, any = devices[i].inputclassinfo;
+ j < devices[i].num_classes;
+ any = (XAnyClassPtr)((char *)any + any->length), j++) {
+ switch (any->class) {
+ case KeyClass:
+ ki = (XKeyInfoPtr)any;
+ info->keyboard = 1;
+ info->keyClass = 1;
+ info->keySyms.minKeyCode = ki->min_keycode;
+ info->keySyms.maxKeyCode = ki->max_keycode;
+ info->kbdFeedbackClass = 1;
+ break;
+ case ButtonClass:
+ bi = (XButtonInfoPtr)any;
+ info->buttonClass = 1;
+ info->numButtons = bi->num_buttons;
+ info->ptrFeedbackClass = 1;
+ break;
+ case ValuatorClass:
+ /* This assume all axes are either
+ * Absolute or Relative. */
+ vi = (XValuatorInfoPtr)any;
+ info->valuatorClass = 1;
+ if (vi->mode == Absolute)
+ info->numAbsAxes = vi->num_axes;
+ else
+ info->numRelAxes = vi->num_axes;
+ for (k = 0; k < vi->num_axes; k++) {
+ info->res[k] = vi->axes[k].resolution;
+ info->minres[k] = vi->axes[k].resolution;
+ info->maxres[k] = vi->axes[k].resolution;
+ info->minval[k] = vi->axes[k].min_value;
+ info->maxval[k] = vi->axes[k].max_value;
+ }
+ break;
+ case FeedbackClass:
+ /* Only keyboard and pointer feedback
+ * are handled at this time. */
+ break;
+ case ProximityClass:
+ info->proximityClass = 1;
+ break;
+ case FocusClass:
+ info->focusClass = 1;
+ break;
+ case OtherClass:
+ break;
+ }
+ }
+ }
+ }
+ XFreeDeviceList(devices);
+ }
+ if (display != priv->display) XCloseDisplay(display);
+}
+
+/** Obtain the mouse button mapping. */
+void dmxCommonMouGetMap(DevicePtr pDev, unsigned char *map, int *nButtons)
+{
+ GETPRIVFROMPDEV;
+ int i;
+
+ *nButtons = XGetPointerMapping(priv->display, map, DMX_MAX_BUTTONS);
+ for (i = 0; i <= *nButtons; i++) map[i] = i;
+}
+
+static void *dmxCommonXSelect(DMXScreenInfo *dmxScreen, void *closure)
+{
+ myPrivate *priv = closure;
+ XSelectInput(dmxScreen->beDisplay, dmxScreen->scrnWin, priv->eventMask);
+ return NULL;
+}
+
+static void *dmxCommonAddEnabledDevice(DMXScreenInfo *dmxScreen, void *closure)
+{
+ AddEnabledDevice(XConnectionNumber(dmxScreen->beDisplay));
+ return NULL;
+}
+
+static void *dmxCommonRemoveEnabledDevice(DMXScreenInfo *dmxScreen,
+ void *closure)
+{
+ RemoveEnabledDevice(XConnectionNumber(dmxScreen->beDisplay));
+ return NULL;
+}
+
+/** Turn \a pDev on (i.e., take input from \a pDev). */
+int dmxCommonMouOn(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ GETDMXINPUTFROMPRIV;
+
+ if (!priv) return -1;
+ priv->eventMask |= DMX_POINTER_EVENT_MASK;
+ if (dmxShadowFB) {
+ XWarpPointer(priv->display, priv->window, priv->window,
+ 0, 0, 0, 0,
+ priv->initPointerX,
+ priv->initPointerY);
+ dmxSync(&dmxScreens[dmxInput->scrnIdx], TRUE);
+ }
+ if (!priv->be) {
+ XSelectInput(priv->display, priv->window, priv->eventMask);
+ AddEnabledDevice(XConnectionNumber(priv->display));
+ } else {
+ dmxPropertyIterate(priv->be, dmxCommonXSelect, priv);
+ dmxPropertyIterate(priv->be, dmxCommonAddEnabledDevice, dmxInput);
+ }
+
+ return -1;
+}
+
+/** Turn \a pDev off. */
+void dmxCommonMouOff(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ GETDMXINPUTFROMPRIV;
+
+ if (!priv) return;
+ priv->eventMask &= ~DMX_POINTER_EVENT_MASK;
+ if (!priv->be) {
+ RemoveEnabledDevice(XConnectionNumber(priv->display));
+ XSelectInput(priv->display, priv->window, priv->eventMask);
+ } else {
+ dmxPropertyIterate(priv->be, dmxCommonRemoveEnabledDevice, dmxInput);
+ dmxPropertyIterate(priv->be, dmxCommonXSelect, priv);
+ }
+}
+
+/** Given the global coordinates \a x and \a y, determine the screen
+ * with the lowest number on which those coordinates lie. If they are
+ * not on any screen, return -1. The number returned is an index into
+ * #dmxScreenInfo and is between -1 and #dmxNumScreens - 1,
+ * inclusive. */
+int dmxFindPointerScreen(int x, int y)
+{
+ int i;
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ if (x >= dixScreenOrigins[i].x
+ && x < dixScreenOrigins[i].x + screenInfo.screens[i]->width
+ && y >= dixScreenOrigins[i].y
+ && y < dixScreenOrigins[i].y + screenInfo.screens[i]->height)
+ return i;
+ }
+ return -1;
+}
+
+/** Returns a pointer to the private area for the device that comes just
+ * prior to \a pDevice in the current \a dmxInput device list. This is
+ * used as the private area for the current device in some situations
+ * (e.g., when a keyboard and mouse form a pair that should share the
+ * same private area). If the requested private area cannot be located,
+ * then NULL is returned. */
+pointer dmxCommonCopyPrivate(DeviceIntPtr pDevice)
+{
+ GETDMXLOCALFROMPDEVICE;
+ DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx];
+ int i;
+
+ for (i = 0; i < dmxInput->numDevs; i++)
+ if (dmxInput->devs[i] == dmxLocal && i)
+ return dmxInput->devs[i-1]->private;
+ return NULL;
+}
+
+/** This routine saves and resets some important state for the backend
+ * and console device drivers:
+ * - the modifier map is saved and set to 0 (so DMX controls the LEDs)
+ * - the key click, bell, led, and repeat masks are saved and set to the
+ * values that DMX claims to be using
+ *
+ * This routine and #dmxCommonRestoreState are used when the pointer
+ * enters and leaves the console window, or when the backend window is
+ * active or not active (for a full-screen window, this only happens at
+ * server startup and server shutdown).
+ */
+void dmxCommonSaveState(pointer private)
+{
+ GETPRIVFROMPRIVATE;
+ XKeyboardState ks;
+ unsigned long i;
+ XModifierKeymap *modmap;
+
+ if (dmxInput->console) priv = dmxInput->devs[0]->private;
+ if (!priv->display || priv->stateSaved) return;
+ DMXDBG0("dmxCommonSaveState\n");
+#ifdef XKB
+ if (dmxUseXKB && (priv->xkb = XkbAllocKeyboard())) {
+ if (XkbGetIndicatorMap(priv->display, XkbAllIndicatorsMask, priv->xkb)
+ || XkbGetNames(priv->display, XkbAllNamesMask, priv->xkb)) {
+ dmxLogInput(dmxInput, "Could not get XKB information\n");
+ XkbFreeKeyboard(priv->xkb, 0, True);
+ priv->xkb = NULL;
+ } else {
+ if (priv->xkb->indicators) {
+ priv->savedIndicators = *priv->xkb->indicators;
+ for (i = 0; i < XkbNumIndicators; i++)
+ if (priv->xkb->indicators->phys_indicators & (1 << i)) {
+ priv->xkb->indicators->maps[i].flags
+ = XkbIM_NoAutomatic;
+ }
+ XkbSetIndicatorMap(priv->display, ~0, priv->xkb);
+ }
+ }
+ }
+#endif
+
+ XGetKeyboardControl(priv->display, &ks);
+ priv->savedKctrl.click = ks.key_click_percent;
+ priv->savedKctrl.bell = ks.bell_percent;
+ priv->savedKctrl.bell_pitch = ks.bell_pitch;
+ priv->savedKctrl.bell_duration = ks.bell_duration;
+ priv->savedKctrl.leds = ks.led_mask;
+ priv->savedKctrl.autoRepeat = ks.global_auto_repeat;
+ for (i = 0; i < 32; i++)
+ priv->savedKctrl.autoRepeats[i] = ks.auto_repeats[i];
+
+ dmxCommonKbdSetCtrl(priv->display, &priv->savedKctrl,
+ &priv->dmxLocal->kctrl);
+
+ priv->savedModMap = XGetModifierMapping(priv->display);
+ modmap = XNewModifiermap(0);
+ XSetModifierMapping(priv->display, modmap);
+ if (dmxInput->scrnIdx != -1)
+ dmxSync(&dmxScreens[dmxInput->scrnIdx], TRUE);
+ XFreeModifiermap(modmap);
+
+ priv->stateSaved = 1;
+}
+
+/** This routine restores all the information saved by #dmxCommonSaveState. */
+void dmxCommonRestoreState(pointer private)
+{
+ GETPRIVFROMPRIVATE;
+ int retcode = -1;
+ CARD32 start;
+
+ if (dmxInput->console) priv = dmxInput->devs[0]->private;
+ if (!priv->stateSaved) return;
+ priv->stateSaved = 0;
+
+ DMXDBG0("dmxCommonRestoreState\n");
+#ifdef XKB
+ if (priv->xkb) {
+ *priv->xkb->indicators = priv->savedIndicators;
+ XkbSetIndicatorMap(priv->display, ~0, priv->xkb);
+ XkbFreeKeyboard(priv->xkb, 0, True);
+ priv->xkb = 0;
+ }
+#endif
+
+ for (start = GetTimeInMillis(); GetTimeInMillis() - start < 5000;) {
+ CARD32 tmp;
+
+ retcode = XSetModifierMapping(priv->display, priv->savedModMap);
+ if (retcode == MappingSuccess) break;
+ if (retcode == MappingBusy)
+ dmxLogInput(dmxInput, "Keyboard busy, waiting\n");
+ else
+ dmxLogInput(dmxInput, "Keyboard error, waiting\n");
+
+ /* Don't generate X11 protocol for a bit */
+ for (tmp = GetTimeInMillis(); GetTimeInMillis() - tmp < 250;) {
+ usleep(250); /* This ends up sleeping only until
+ * the next key press generates an
+ * interruption. We make the delay
+ * relatively short in case the user
+ * pressed they keys quickly. */
+ }
+
+ }
+ if (retcode != MappingSuccess)
+ dmxLog(dmxWarning, "Unable to restore keyboard modifier state!\n");
+
+ XFreeModifiermap(priv->savedModMap);
+ priv->savedModMap = NULL;
+
+ dmxCommonKbdSetCtrl(priv->display, NULL, &priv->savedKctrl);
+ priv->kctrlset = 0; /* Invalidate copy */
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxcommon.h b/nx-X11/programs/Xserver/hw/dmx/input/dmxcommon.h
new file mode 100644
index 000000000..4b8b07d9f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxcommon.h
@@ -0,0 +1,133 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002,2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to functions used by backend and console input devices.
+ * \see dmxcommon.c \see dmxbackend.c \see dmxconsole.c */
+
+#ifndef _DMXCOMMON_H_
+#define _DMXCOMMON_H_
+
+#define DMX_COMMON_OTHER \
+ Display *display; \
+ Window window; \
+ DMXScreenInfo *be; \
+ DMXLocalInputInfoPtr dmxLocal; \
+ int initPointerX; \
+ int initPointerY; \
+ long eventMask; \
+ KeybdCtrl kctrl; \
+ PtrCtrl mctrl; \
+ int kctrlset; \
+ int mctrlset; \
+ KeybdCtrl savedKctrl; \
+ XModifierKeymap *savedModMap; \
+ int stateSaved
+
+#ifdef XKB
+#define DMX_COMMON_XKB \
+ DMX_COMMON_OTHER; \
+ XkbDescPtr xkb; \
+ XkbIndicatorRec savedIndicators
+#else
+#define DMX_COMMON_XKB DMX_COMMON_OTHER
+#endif
+
+#ifdef XINPUT
+#define DMX_COMMON_PRIVATE \
+ DMX_COMMON_XKB; \
+ XDevice *xi
+#else
+#define DMX_COMMON_PRIVATE DMX_COMMON_OTHER
+#endif
+
+#define GETONLYPRIVFROMPRIVATE \
+ myPrivate *priv = private
+
+#define GETPRIVFROMPRIVATE \
+ GETONLYPRIVFROMPRIVATE; \
+ DMXInputInfo *dmxInput = &dmxInputs[priv->dmxLocal->inputIdx]
+
+#define GETDMXLOCALFROMPDEVICE \
+ DevicePtr pDev = &pDevice->public; \
+ DMXLocalInputInfoPtr dmxLocal = pDev->devicePrivate
+
+#define GETDMXINPUTFROMPRIV \
+ DMXInputInfo *dmxInput = &dmxInputs[priv->dmxLocal->inputIdx]
+
+#define GETDMXINPUTFROMPDEVICE \
+ GETDMXLOCALFROMPDEVICE; \
+ DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx]
+
+#define GETDMXLOCALFROMPDEV \
+ DMXLocalInputInfoPtr dmxLocal = pDev->devicePrivate
+
+#define GETDMXINPUTFROMPDEV \
+ GETDMXLOCALFROMPDEV; \
+ DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx]
+
+#define GETPRIVFROMPDEV \
+ GETDMXLOCALFROMPDEV; \
+ myPrivate *priv = dmxLocal->private
+
+#define DMX_KEYBOARD_EVENT_MASK \
+ (KeyPressMask | KeyReleaseMask | KeymapStateMask)
+
+#define DMX_POINTER_EVENT_MASK \
+ (ButtonPressMask | ButtonReleaseMask | PointerMotionMask)
+
+extern void dmxCommonKbdGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
+extern void dmxCommonKbdGetMap(DevicePtr pDev,
+ KeySymsPtr pKeySyms, CARD8 *pModMap);
+extern void dmxCommonKbdCtrl(DevicePtr pDev, KeybdCtrl *ctrl);
+extern void dmxCommonKbdBell(DevicePtr pDev, int percent,
+ int volume, int pitch, int duration);
+extern int dmxCommonKbdOn(DevicePtr pDev);
+extern void dmxCommonKbdOff(DevicePtr pDev);
+extern void dmxCommonMouGetMap(DevicePtr pDev,
+ unsigned char *map, int *nButtons);
+extern void dmxCommonMouCtrl(DevicePtr pDev, PtrCtrl *ctrl);
+extern int dmxCommonMouOn(DevicePtr pDev);
+extern void dmxCommonMouOff(DevicePtr pDev);
+extern int dmxFindPointerScreen(int x, int y);
+
+extern int dmxCommonOthOn(DevicePtr pDev);
+extern void dmxCommonOthOff(DevicePtr pDev);
+extern void dmxCommonOthGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
+
+ /* helper functions */
+extern pointer dmxCommonCopyPrivate(DeviceIntPtr pDevice);
+extern void dmxCommonSaveState(pointer private);
+extern void dmxCommonRestoreState(pointer private);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxconsole.c b/nx-X11/programs/Xserver/hw/dmx/input/dmxconsole.c
new file mode 100644
index 000000000..7a313aadd
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxconsole.c
@@ -0,0 +1,1023 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * David H. Dawes <dawes@xfree86.org>
+ * Kevin E. Martin <kem@redhat.com>
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * This file implements the console input devices.
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#define DMX_CONSOLE_DEBUG 0
+#define DMX_WINDOW_DEBUG 0
+
+#include "dmxinputinit.h"
+#include "dmxevents.h"
+#include "dmxconsole.h"
+#include "dmxcommon.h"
+#include "dmxscrinit.h"
+#include "dmxcb.h"
+#include "dmxsync.h"
+
+#include "inputstr.h"
+#include "input.h"
+#include "mipointer.h"
+#include "windowstr.h"
+
+#define CONSOLE_NUM 3
+#define CONSOLE_DEN 4
+#define DMX_CONSOLE_NAME "DMX Console"
+#define DMX_RES_NAME "Xdmx"
+#define DMX_RES_CLASS "XDmx"
+#define CONSOLE_BG_COLOR "gray75"
+#define CONSOLE_FG_COLOR "black"
+#define CONSOLE_SCREEN_BG_COLOR "white"
+#define CONSOLE_SCREEN_FG_COLOR "black"
+#define CONSOLE_SCREEN_DET_COLOR "gray75"
+#define CONSOLE_SCREEN_CUR_COLOR "red"
+
+#if DMX_CONSOLE_DEBUG
+#define DMXDBG0(f) dmxLog(dmxDebug,f)
+#define DMXDBG1(f,a) dmxLog(dmxDebug,f,a)
+#define DMXDBG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define DMXDBG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define DMXDBG4(f,a,b,c,d) dmxLog(dmxDebug,f,a,b,c,d)
+#define DMXDBG5(f,a,b,c,d,e) dmxLog(dmxDebug,f,a,b,c,d,e)
+#define DMXDBG6(f,a,b,c,d,e,g) dmxLog(dmxDebug,f,a,b,c,d,e,g)
+#define DMXDBG7(f,a,b,c,d,e,g,h) dmxLog(dmxDebug,f,a,b,c,d,e,g,h)
+#else
+#define DMXDBG0(f)
+#define DMXDBG1(f,a)
+#define DMXDBG2(f,a,b)
+#define DMXDBG3(f,a,b,c)
+#define DMXDBG4(f,a,b,c,d)
+#define DMXDBG5(f,a,b,c,d,e)
+#define DMXDBG6(f,a,b,c,d,e,g)
+#define DMXDBG7(f,a,b,c,d,e,g,h)
+#endif
+
+/* Private area for consoles. */
+typedef struct _myPrivate {
+ DMX_COMMON_PRIVATE;
+ int lastX;
+ int lastY;
+ int globalX;
+ int globalY;
+ int curX;
+ int curY;
+ int width;
+ int height;
+ int consWidth;
+ int consHeight;
+ double xScale;
+ double yScale;
+ XlibGC gc, gcDet, gcRev, gcCur;
+ int grabbed, fine, captured;
+ Cursor cursorNormal, cursorGrabbed, cursorEmpty;
+ Pixmap pixmap;
+
+ CloseScreenProcPtr CloseScreen;
+ struct _myPrivate *next; /* for closing multiple consoles */
+ int initialized;
+ DevicePtr mou, kbd;
+} myPrivate;
+
+static int scalex(myPrivate *priv, int x)
+{
+ return (int)((x * priv->xScale) + .5);
+}
+
+static int scaley(myPrivate *priv, int y)
+{
+ return (int)((y * priv->yScale) + .5);
+}
+
+static int unscalex(myPrivate *priv, int x)
+{
+ return (int)((x / priv->xScale) + .5);
+}
+
+static int unscaley(myPrivate *priv, int y)
+{
+ return (int)((y / priv->yScale) + .5);
+}
+
+/** Create the private area for \a pDevice. */
+pointer dmxConsoleCreatePrivate(DeviceIntPtr pDevice)
+{
+ GETDMXLOCALFROMPDEVICE;
+ myPrivate *priv = xalloc(sizeof(*priv));
+ memset(priv, 0, sizeof(*priv));
+ priv->dmxLocal = dmxLocal;
+ return priv;
+}
+
+/** If \a private is non-NULL, free its associated memory. */
+void dmxConsoleDestroyPrivate(pointer private)
+{
+ if (private) xfree(private);
+}
+
+static void dmxConsoleDrawFineCursor(myPrivate *priv, XRectangle *rect)
+{
+ int size = 6;
+ int x, y;
+
+ XDrawLine(priv->display, priv->pixmap, priv->gcCur,
+ x = scalex(priv, priv->globalX) - size,
+ scaley(priv, priv->globalY),
+ scalex(priv, priv->globalX) + size,
+ scaley(priv, priv->globalY));
+ XDrawLine(priv->display, priv->pixmap, priv->gcCur,
+ scalex(priv, priv->globalX),
+ y = scaley(priv, priv->globalY) - size,
+ scalex(priv, priv->globalX),
+ scaley(priv, priv->globalY) + size);
+ if (priv->grabbed) {
+ XDrawLine(priv->display, priv->pixmap, priv->gcCur,
+ scalex(priv, priv->globalX) - (int)(size / 1.4),
+ scaley(priv, priv->globalY) - (int)(size / 1.4),
+ scalex(priv, priv->globalX) + (int)(size / 1.4),
+ scaley(priv, priv->globalY) + (int)(size / 1.4));
+ XDrawLine(priv->display, priv->pixmap, priv->gcCur,
+ scalex(priv, priv->globalX) - (int)(size / 1.4),
+ scaley(priv, priv->globalY) + (int)(size / 1.4),
+ scalex(priv, priv->globalX) + (int)(size / 1.4),
+ scaley(priv, priv->globalY) - (int)(size / 1.4));
+ }
+ if (rect) {
+ rect->x = x;
+ rect->y = y;
+ rect->width = 2 * size;
+ rect->height = 2 * size;
+ }
+}
+
+static void dmxConsoleDrawWindows(pointer private)
+{
+ GETONLYPRIVFROMPRIVATE;
+ Display *dpy = priv->display;
+ int i;
+ Region whole, used, avail;
+ XRectangle rect;
+
+ whole = XCreateRegion();
+ used = XCreateRegion();
+ avail = XCreateRegion();
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = priv->consWidth;
+ rect.height = priv->consHeight;
+ XUnionRectWithRegion(&rect, whole, whole);
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ WindowPtr pRoot = WindowTable[i];
+ WindowPtr pChild;
+
+#if DMX_WINDOW_DEBUG
+ dmxLog(dmxDebug, "%lu %p %p %p 2\n",
+ pRoot->drawable.id,
+ pRoot->parent, pRoot->firstChild, pRoot->lastChild);
+#endif
+
+ for (pChild = pRoot->firstChild; pChild; pChild = pChild->nextSib) {
+ if (pChild->mapped
+ && pChild->realized) {
+#if DMX_WINDOW_DEBUG
+ dmxLog(dmxDebug, " %p %d,%d %dx%d %d %d %d RECTS\n",
+ pChild,
+ pChild->drawable.x,
+ pChild->drawable.y,
+ pChild->drawable.width,
+ pChild->drawable.height,
+ pChild->visibility,
+ pChild->overrideRedirect,
+ REGION_NUM_RECTS(&pChild->clipList));
+#endif
+ rect.x = scalex(priv, pChild->drawable.x
+ + dixScreenOrigins[i].x);
+ rect.y = scaley(priv, pChild->drawable.y
+ + dixScreenOrigins[i].y);
+ rect.width = scalex(priv, pChild->drawable.width);
+ rect.height = scaley(priv, pChild->drawable.height);
+ XDrawRectangle(dpy, priv->pixmap, priv->gc,
+ rect.x, rect.y, rect.width, rect.height);
+ XUnionRectWithRegion(&rect, used, used);
+ XSubtractRegion(whole, used, avail);
+ XSetRegion(dpy, priv->gc, avail);
+ }
+ }
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) break; /* Screen 0 valid with Xinerama */
+#endif
+ }
+ XDestroyRegion(avail);
+ XDestroyRegion(used);
+ XDestroyRegion(whole);
+ XSetClipMask(dpy, priv->gc, None);
+}
+
+static void dmxConsoleDraw(myPrivate *priv, int updateCursor, int update)
+{
+ GETDMXINPUTFROMPRIV;
+ Display *dpy = priv->display;
+ int i;
+
+ XFillRectangle(dpy, priv->pixmap, priv->gc, 0, 0,
+ priv->consWidth, priv->consHeight);
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ XFillRectangle(dpy, priv->pixmap,
+ dmxScreen->beDisplay ? priv->gcRev : priv->gcDet,
+ scalex(priv, dixScreenOrigins[i].x),
+ scaley(priv, dixScreenOrigins[i].y),
+ scalex(priv, screenInfo.screens[i]->width),
+ scaley(priv, screenInfo.screens[i]->height));
+ }
+ for (i = 0; i < dmxNumScreens; i++) {
+ XDrawRectangle(dpy, priv->pixmap, priv->gc,
+ scalex(priv, dixScreenOrigins[i].x),
+ scaley(priv, dixScreenOrigins[i].y),
+ scalex(priv, screenInfo.screens[i]->width),
+ scaley(priv, screenInfo.screens[i]->height));
+ }
+ if (dmxInput->windows) dmxConsoleDrawWindows(priv);
+ if (priv->fine && updateCursor) dmxConsoleDrawFineCursor(priv, 0);
+ if (update) {
+ XCopyArea(priv->display, priv->pixmap, priv->window, priv->gc,
+ 0, 0, priv->consWidth, priv->consHeight, 0, 0);
+ XSync(priv->display, False); /* Not a backend display */
+ }
+}
+
+static void dmxConsoleClearCursor(myPrivate *priv, int x, int y,
+ XRectangle *rect)
+{
+ int cw = 14, ch = 14; /* Clear width and height */
+
+ rect->x = scalex(priv, x) - cw/2;
+ rect->y = scaley(priv, y) - ch/2;
+ rect->width = cw;
+ rect->height = ch;
+ XSetClipRectangles(priv->display, priv->gc, 0, 0, rect, 1, Unsorted);
+ XSetClipRectangles(priv->display, priv->gcDet, 0, 0, rect, 1, Unsorted);
+ XSetClipRectangles(priv->display, priv->gcRev, 0, 0, rect, 1, Unsorted);
+ dmxConsoleDraw(priv, 0, 0);
+ XSetClipMask(priv->display, priv->gc, None);
+ XSetClipMask(priv->display, priv->gcDet, None);
+ XSetClipMask(priv->display, priv->gcRev, None);
+}
+
+
+static void dmxConsoleUpdateFineCursor(myPrivate *priv)
+{
+ int leave = 0;
+ XRectangle rects[2];
+
+ dmxConsoleClearCursor(priv, priv->globalX, priv->globalY, &rects[0]);
+ if (priv->dmxLocal->sendsCore) {
+ dmxGetGlobalPosition(&priv->globalX, &priv->globalY);
+ } else {
+ priv->globalX = priv->dmxLocal->lastX;
+ priv->globalY = priv->dmxLocal->lastY;
+ }
+
+ priv->lastX = scalex(priv, priv->width / 2);
+ priv->lastY = scaley(priv, priv->height / 2);
+
+ /* Compute new warp position, which may be
+ outside the window */
+ if (priv->globalX < 1 || priv->globalX >= priv->width) {
+ if (priv->globalX < 1) priv->lastX = 0;
+ else priv->lastX = scalex(priv, priv->width);
+ priv->lastY = scaley(priv, priv->globalY);
+ ++leave;
+ }
+ if (priv->globalY < 1 || priv->globalY >= priv->height) {
+ if (priv->globalY < 1) priv->lastY = 0;
+ else priv->lastY = scaley(priv, priv->height);
+ priv->lastX = scalex(priv, priv->globalX);
+ ++leave;
+ }
+
+ /* Draw pseudo cursor in window */
+ dmxConsoleDrawFineCursor(priv, &rects[1]);
+
+ XSetClipRectangles(priv->display, priv->gc, 0, 0, rects, 2, Unsorted);
+ XCopyArea(priv->display, priv->pixmap, priv->window, priv->gc,
+ 0, 0, priv->consWidth, priv->consHeight, 0, 0);
+ XSetClipMask(priv->display, priv->gc, None);
+
+ DMXDBG2("dmxConsoleUpdateFineCursor: WARP %d %d\n",
+ priv->lastX, priv->lastY);
+ XWarpPointer(priv->display, priv->window, priv->window,
+ 0, 0, 0, 0, priv->lastX, priv->lastY);
+ XSync(priv->display, False); /* Not a backend display */
+
+ if (leave) {
+ XEvent X;
+ while (XCheckMaskEvent(priv->display, PointerMotionMask, &X)) {
+ if (X.type == MotionNotify) {
+ if (X.xmotion.x != priv->lastX || X.xmotion.y != priv->lastY) {
+ DMXDBG4("Ignoring motion to %d %d after leave frm %d %d\n",
+ X.xmotion.x, X.xmotion.y,
+ priv->lastX, priv->lastY);
+ }
+ } else {
+ dmxLog(dmxInfo, "Ignoring event (%d): %s ****************\n",
+ X.type, dmxEventName(X.type));
+ }
+ }
+ }
+ DMXDBG6("dmxConsoleUpdateFineCursor: Warp %d %d on %d %d [%d %d]\n",
+ priv->lastX, priv->lastY,
+ scalex(priv, priv->width),
+ scaley(priv, priv->height),
+ priv->globalX, priv->globalY);
+}
+
+/** Whenever the window layout (size, position, stacking order) might be
+ * changed, this routine is called with the \a pWindow that changed and
+ * the \a type of change. This routine is called in a conservative
+ * fashion: the actual layout of the windows of the screen might not
+ * have had any human-visible changes. */
+void dmxConsoleUpdateInfo(pointer private, DMXUpdateType type,
+ WindowPtr pWindow)
+{
+ GETONLYPRIVFROMPRIVATE;
+ dmxConsoleDraw(priv, 1, 1);
+}
+
+static void dmxConsoleMoveAbsolute(myPrivate *priv, int x, int y,
+ DevicePtr pDev, dmxMotionProcPtr motion,
+ DMXBlockType block)
+{
+ int tmpX, tmpY, v[2];
+
+ tmpX = unscalex(priv, x);
+ tmpY = unscalex(priv, y);
+ DMXDBG6("dmxConsoleMoveAbsolute(,%d,%d) %d %d =? %d %d\n",
+ x, y, tmpX, tmpY, priv->curX, priv->curY);
+ if (tmpX == priv->curX && tmpY == priv->curY) return;
+ v[0] = unscalex(priv, x);
+ v[1] = unscaley(priv, y);
+ motion(pDev, v, 0, 2, DMX_ABSOLUTE_CONFINED, block);
+ /* dmxConsoleUpdatePosition gets called here by dmxCoreMotion */
+}
+
+static void dmxConsoleMoveRelative(myPrivate *priv, int x, int y,
+ DevicePtr pDev, dmxMotionProcPtr motion,
+ DMXBlockType block)
+{
+ int v[2];
+ /* Ignore the event generated from * warping back to middle */
+ if (x == priv->lastX && y == priv->lastY) return;
+ v[0] = priv->lastX - x;
+ v[1] = priv->lastY - y;
+ motion(pDev, v, 0, 2, DMX_RELATIVE, block);
+ /* dmxConsoleUpdatePosition gets called here by dmxCoreMotion */
+}
+
+/** This routine gets called from #dmxCoreMotion for each motion. This
+ * allows the console's notion of the cursor postion to change when
+ * another input device actually caused the change. */
+void dmxConsoleUpdatePosition(pointer private, int x, int y)
+{
+ GETONLYPRIVFROMPRIVATE;
+ int tmpX, tmpY;
+ Display *dpy = priv->display;
+ static unsigned long dmxGeneration = 0;
+
+
+ tmpX = scalex(priv, x);
+ tmpY = scaley(priv, y);
+ DMXDBG6("dmxConsoleUpdatePosition(,%d,%d) new=%d,%d dims=%d,%d\n",
+ x, y, tmpX, tmpY, priv->consWidth, priv->consHeight);
+
+ if (priv->fine) dmxConsoleUpdateFineCursor(priv);
+ if (tmpX != priv->curX || tmpY != priv->curY) {
+ if (tmpX < 0) tmpX = 0;
+ if (tmpY < 0) tmpY = 0;
+ if (tmpX >= priv->consWidth) tmpX = priv->consWidth - 1;
+ if (tmpY >= priv->consHeight) tmpY = priv->consHeight - 1;
+ priv->curX = tmpX;
+ priv->curY = tmpY;
+ if (!priv->fine) {
+ DMXDBG2(" WARP B %d %d\n", priv->curX, priv->curY);
+ XWarpPointer(dpy, priv->window,
+ priv->window, 0, 0, 0, 0, tmpX, tmpY);
+ XSync(dpy, False); /* Not a backend display */
+ }
+ }
+
+ if (dmxGeneration != serverGeneration) {
+ dmxGeneration = serverGeneration;
+ dmxConsoleDraw(priv, 1, 1);
+ }
+}
+
+/** Collect all pending events from the console's display. Plase these
+ * events on the server event queue using the \a motion and \a enqueue
+ * routines. The \a checkspecial routine is used to check for special
+ * keys that need handling. \a block tells if signals should be blocked
+ * when updating the event queue. */
+void dmxConsoleCollectEvents(DevicePtr pDev,
+ dmxMotionProcPtr motion,
+ dmxEnqueueProcPtr enqueue,
+ dmxCheckSpecialProcPtr checkspecial,
+ DMXBlockType block)
+{
+ GETPRIVFROMPDEV;
+ GETDMXINPUTFROMPRIV;
+ Display *dpy = priv->display;
+ Window win = priv->window;
+ int width = priv->width;
+ int height = priv->height;
+ XEvent X, N;
+ XSetWindowAttributes attribs;
+ static int rInitialized = 0;
+ static Region r;
+ XRectangle rect;
+ static int raising = 0, raiseX, raiseY; /* FIXME */
+
+ while (XPending(dpy)) {
+ XNextEvent(dpy, &X);
+ switch(X.type) {
+ case VisibilityNotify:
+ break;
+ case Expose:
+ DMXDBG5("dmxConsoleCollectEvents: Expose #%d %d %d %d %d\n",
+ X.xexpose.count,
+ X.xexpose.x, X.xexpose.y,
+ X.xexpose.width, X.xexpose.height);
+ if (!rInitialized++) r = XCreateRegion();
+ rect.x = X.xexpose.x;
+ rect.y = X.xexpose.y;
+ rect.width = X.xexpose.width;
+ rect.height = X.xexpose.height;
+ XUnionRectWithRegion(&rect, r, r);
+ if (X.xexpose.count == 0) {
+ XSetRegion(dpy, priv->gc, r);
+ XSetRegion(dpy, priv->gcDet, r);
+ XSetRegion(dpy, priv->gcRev, r);
+ dmxConsoleDraw(priv, 1, 1);
+ XSetClipMask(dpy, priv->gc, None);
+ XSetClipMask(dpy, priv->gcDet, None);
+ XSetClipMask(dpy, priv->gcRev, None);
+ XDestroyRegion(r);
+ rInitialized = 0;
+ }
+ break;
+ case ResizeRequest:
+ DMXDBG2("dmxConsoleCollectEvents: Resize %d %d\n",
+ X.xresizerequest.width, X.xresizerequest.height);
+ priv->consWidth = X.xresizerequest.width;
+ priv->consHeight = X.xresizerequest.height;
+ priv->xScale = (double)priv->consWidth / width;
+ priv->yScale = (double)priv->consHeight / height;
+ attribs.override_redirect = True;
+ XChangeWindowAttributes(dpy, win, CWOverrideRedirect, &attribs);
+ XResizeWindow(dpy, win, priv->consWidth, priv->consHeight);
+ XFreePixmap(dpy, priv->pixmap);
+ priv->pixmap = XCreatePixmap(dpy,
+ RootWindow(dpy, DefaultScreen(dpy)),
+ priv->consWidth,
+ priv->consHeight,
+ DefaultDepth(dpy,DefaultScreen(dpy)));
+ dmxConsoleDraw(priv, 1, 1);
+ attribs.override_redirect = False;
+ XChangeWindowAttributes(dpy, win, CWOverrideRedirect, &attribs);
+ break;
+ case LeaveNotify:
+ DMXDBG4("dmxConsoleCollectEvents: Leave @ %d,%d; r=%d f=%d\n",
+ X.xcrossing.x, X.xcrossing.y, raising, priv->fine);
+ if (!priv->captured) dmxCommonRestoreState(priv);
+ else {
+ dmxConsoleUncapture(dmxInput);
+ dmxCommonRestoreState(priv);
+ }
+ break;
+ case EnterNotify:
+ DMXDBG6("dmxConsoleCollectEvents: Enter %d,%d r=%d f=%d (%d,%d)\n",
+ X.xcrossing.x, X.xcrossing.y, raising, priv->fine,
+ priv->curX, priv->curY);
+ dmxCommonSaveState(priv);
+ if (raising) {
+ raising = 0;
+ dmxConsoleMoveAbsolute(priv, raiseX, raiseY,
+ priv->mou, motion, block);
+ } else {
+ if (priv->fine) {
+ /* The raise will generate an event near the center,
+ * which is not where the cursor should be. So we
+ * save the real position, do the raise, and move
+ * the cursor here again after the raise generates
+ * the event. */
+ raising = 1;
+ raiseX = X.xcrossing.x;
+ raiseY = X.xcrossing.y;
+ XRaiseWindow(dpy, priv->window);
+ }
+ XSync(dpy, False); /* Not a backend display */
+ if (!X.xcrossing.x && !X.xcrossing.y)
+ dmxConsoleMoveAbsolute(priv, priv->curX, priv->curY,
+ priv->mou, motion, block);
+ }
+ break;
+ case MotionNotify:
+ if (priv->curX == X.xmotion.x && priv->curY == X.xmotion.y)
+ continue;
+ if (XPending(dpy)) { /* do motion compression */
+ XPeekEvent(dpy, &N);
+ if (N.type == MotionNotify) continue;
+ }
+ DMXDBG2("dmxConsoleCollectEvents: Motion %d %d\n",
+ X.xmotion.x, X.xmotion.y);
+ if (raising) {
+ raising = 0;
+ dmxConsoleMoveAbsolute(priv, raiseX, raiseY,
+ priv->mou, motion, block);
+ } else {
+ if (priv->fine)
+ dmxConsoleMoveRelative(priv, X.xmotion.x, X.xmotion.y,
+ priv->mou, motion, block);
+ else
+ dmxConsoleMoveAbsolute(priv, X.xmotion.x, X.xmotion.y,
+ priv->mou, motion, block);
+ }
+ break;
+ case KeyPress:
+ case KeyRelease:
+ enqueue(priv->kbd, X.type, X.xkey.keycode, 0, NULL, block);
+ break;
+ default:
+ /* Pass the whole event here, because
+ * this may be an extension event. */
+ enqueue(priv->mou, X.type, X.xbutton.button, 0, &X, block);
+ break;
+ }
+ }
+}
+
+static void dmxCloseConsole(myPrivate *priv)
+{
+ GETDMXINPUTFROMPRIV;
+ dmxCommonRestoreState(priv);
+ if (priv->display) {
+ XFreeGC(priv->display, priv->gc);
+ XFreeGC(priv->display, priv->gcDet);
+ XFreeGC(priv->display, priv->gcRev);
+ XFreeGC(priv->display, priv->gcCur);
+ if (!dmxInput->console) XCloseDisplay(priv->display);
+ }
+ priv->display = NULL;
+}
+
+static Bool dmxCloseConsoleScreen(int idx, ScreenPtr pScreen)
+{
+ myPrivate *priv, *last;
+
+ for (last = priv = pScreen->devPrivates[dmxScreenPrivateIndex].ptr;
+ priv;
+ priv = priv->next) dmxCloseConsole(last = priv);
+
+ DMX_UNWRAP(CloseScreen, last, pScreen);
+ return pScreen->CloseScreen(idx, pScreen);
+}
+
+static Cursor dmxConsoleCreateEmptyCursor(myPrivate *priv)
+{
+ char noCursorData[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ Pixmap pixmap;
+ Cursor cursor;
+ XColor color, tmpColor;
+ Display *dpy = priv->display;
+
+ /* Create empty cursor for window */
+ pixmap = XCreateBitmapFromData(priv->display, priv->window,
+ noCursorData, 8, 8);
+ if (!XAllocNamedColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)),
+ "black",
+ &color,
+ &tmpColor))
+ dmxLog(dmxFatal, "Cannot allocate color for cursor\n");
+ cursor = XCreatePixmapCursor(dpy, pixmap, pixmap, &color, &color, 0, 0);
+ XFreePixmap(dpy, pixmap);
+ return cursor;
+}
+
+static void dmxConsoleComputeWidthHeight(myPrivate *priv,
+ int *width, int *height,
+ double *xScale, double *yScale,
+ int *consWidth, int *consHeight)
+{
+ int screen;
+ Display *dpy = priv->display;
+
+ *width = 0;
+ *height = 0;
+ *xScale = 1.0;
+ *yScale = 1.0;
+
+ screen = DefaultScreen(dpy);
+ *consWidth = DisplayWidth(dpy, screen) * CONSOLE_NUM / CONSOLE_DEN;
+ *consHeight = DisplayHeight(dpy, screen) * CONSOLE_NUM / CONSOLE_DEN;
+
+ if (*consWidth < 1) *consWidth = 1;
+ if (*consHeight < 1) *consHeight = 1;
+
+#if 1
+ /* Always keep the console size similar
+ * to the global bounding box. */
+ *width = dmxGlobalWidth;
+ *height = dmxGlobalHeight;
+#else
+ /* Make the console window as big as
+ * possible by computing the visible
+ * bounding box. */
+ for (i = 0; i < dmxNumScreens; i++) {
+ if (dixScreenOrigins[i].x+screenInfo.screens[i]->width > *width)
+ *width = dixScreenOrigins[i].x+screenInfo.screens[i]->width;
+
+ if (dixScreenOrigins[i].y+screenInfo.screens[i]->height > *height)
+ *height = dixScreenOrigins[i].y+screenInfo.screens[i]->height;
+ }
+#endif
+
+ if ((double)*consWidth / *width < (double)*consHeight / *height)
+ *xScale = *yScale = (double)*consWidth / *width;
+ else
+ *xScale = *yScale = (double)*consHeight / *height;
+
+ *consWidth = scalex(priv, *width);
+ *consHeight = scaley(priv, *height);
+ if (*consWidth < 1) *consWidth = 1;
+ if (*consHeight < 1) *consHeight = 1;
+}
+
+/** Re-initialized the console device described by \a pDev (after a
+ * reconfig). */
+void dmxConsoleReInit(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ Display *dpy = priv->display;
+
+ if (!priv || !priv->initialized) return;
+
+ dmxConsoleComputeWidthHeight(priv,
+ &priv->width, &priv->height,
+ &priv->xScale, &priv->yScale,
+ &priv->consWidth, &priv->consHeight);
+ XResizeWindow(dpy, priv->window, priv->consWidth, priv->consHeight);
+ XFreePixmap(dpy, priv->pixmap);
+ priv->pixmap = XCreatePixmap(dpy,
+ RootWindow(dpy, DefaultScreen(dpy)),
+ priv->consWidth,
+ priv->consHeight,
+ DefaultDepth(dpy,DefaultScreen(dpy)));
+ dmxConsoleDraw(priv, 1, 1);
+}
+
+/** Initialized the console device described by \a pDev. */
+void dmxConsoleInit(DevicePtr pDev)
+{
+ GETPRIVFROMPDEV;
+ DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx];
+ int screen;
+ unsigned long mask;
+ XSetWindowAttributes attribs;
+ Display *dpy;
+ Window win;
+ XGCValues gcvals;
+ XColor color;
+ XClassHint class_hints;
+ unsigned long tmp;
+
+ if (dmxLocal->type == DMX_LOCAL_MOUSE) priv->mou = pDev;
+ if (dmxLocal->type == DMX_LOCAL_KEYBOARD) priv->kbd = pDev;
+ if (priv->initialized++) return; /* Only do once for mouse/keyboard pair */
+
+ if (!(dpy = priv->display = XOpenDisplay(dmxInput->name)))
+ dmxLog(dmxFatal,
+ "dmxOpenConsole: cannot open console display %s\n",
+ dmxInput->name);
+
+ /* Set up defaults */
+ dmxConsoleComputeWidthHeight(priv,
+ &priv->width, &priv->height,
+ &priv->xScale, &priv->yScale,
+ &priv->consWidth, &priv->consHeight);
+
+ /* Private initialization using computed values or constants. */
+ screen = DefaultScreen(dpy);
+ priv->initPointerX = scalex(priv, priv->width / 2);
+ priv->initPointerY = scaley(priv, priv->height / 2);
+ priv->eventMask = (ButtonPressMask
+ | ButtonReleaseMask
+ | PointerMotionMask
+ | EnterWindowMask
+ | LeaveWindowMask
+ | KeyPressMask
+ | KeyReleaseMask
+ | ExposureMask
+ | ResizeRedirectMask);
+
+ mask = CWBackPixel | CWEventMask | CWColormap | CWOverrideRedirect;
+ attribs.colormap = DefaultColormap(dpy, screen);
+ if (XParseColor(dpy, attribs.colormap, CONSOLE_BG_COLOR, &color)
+ && XAllocColor(dpy, attribs.colormap, &color)) {
+ attribs.background_pixel = color.pixel;
+ } else
+ attribs.background_pixel = WhitePixel(dpy, screen);
+
+ attribs.event_mask = priv->eventMask;
+ attribs.override_redirect = False;
+
+ win = priv->window = XCreateWindow(dpy,
+ RootWindow(dpy, screen),
+ 0, 0, priv->consWidth, priv->consHeight,
+ 0,
+ DefaultDepth(dpy, screen),
+ InputOutput,
+ DefaultVisual(dpy, screen),
+ mask, &attribs);
+ priv->pixmap = XCreatePixmap(dpy, RootWindow(dpy, screen),
+ priv->consWidth, priv->consHeight,
+ DefaultDepth(dpy, screen));
+
+ /* Set up properties */
+ XStoreName(dpy, win, DMX_CONSOLE_NAME);
+ class_hints.res_name = DMX_RES_NAME;
+ class_hints.res_class = DMX_RES_CLASS;
+ XSetClassHint(dpy, win, &class_hints);
+
+
+ /* Map the window */
+ XMapWindow(dpy, win);
+
+ /* Create cursors */
+ priv->cursorNormal = XCreateFontCursor(dpy, XC_circle);
+ priv->cursorGrabbed = XCreateFontCursor(dpy, XC_spider);
+ priv->cursorEmpty = dmxConsoleCreateEmptyCursor(priv);
+ XDefineCursor(dpy, priv->window, priv->cursorNormal);
+
+ /* Create GC */
+ mask = (GCFunction | GCPlaneMask | GCClipMask | GCForeground |
+ GCBackground | GCLineWidth | GCLineStyle | GCCapStyle |
+ GCFillStyle | GCGraphicsExposures);
+ gcvals.function = GXcopy;
+ gcvals.plane_mask = AllPlanes;
+ gcvals.clip_mask = None;
+ if (XParseColor(dpy, attribs.colormap, CONSOLE_SCREEN_FG_COLOR, &color)
+ && XAllocColor(dpy, attribs.colormap, &color)) {
+ gcvals.foreground = color.pixel;
+ } else
+ gcvals.foreground = BlackPixel(dpy, screen);
+ if (XParseColor(dpy, attribs.colormap, CONSOLE_SCREEN_BG_COLOR, &color)
+ && XAllocColor(dpy, attribs.colormap, &color)) {
+ gcvals.background = color.pixel;
+ } else
+ gcvals.background = WhitePixel(dpy, screen);
+ gcvals.line_width = 0;
+ gcvals.line_style = LineSolid;
+ gcvals.cap_style = CapNotLast;
+ gcvals.fill_style = FillSolid;
+ gcvals.graphics_exposures = False;
+
+ priv->gc = XCreateGC(dpy, win, mask, &gcvals);
+
+ tmp = gcvals.foreground;
+ if (XParseColor(dpy, attribs.colormap, CONSOLE_SCREEN_DET_COLOR, &color)
+ && XAllocColor(dpy, attribs.colormap, &color)) {
+ gcvals.foreground = color.pixel;
+ } else
+ gcvals.foreground = BlackPixel(dpy, screen);
+ priv->gcDet = XCreateGC(dpy, win, mask, &gcvals);
+ gcvals.foreground = tmp;
+
+ tmp = gcvals.background;
+ gcvals.background = gcvals.foreground;
+ gcvals.foreground = tmp;
+ priv->gcRev = XCreateGC(dpy, win, mask, &gcvals);
+
+ gcvals.background = gcvals.foreground;
+ if (XParseColor(dpy, attribs.colormap, CONSOLE_SCREEN_CUR_COLOR, &color)
+ && XAllocColor(dpy, attribs.colormap, &color)) {
+ gcvals.foreground = color.pixel;
+ } else
+ gcvals.foreground = BlackPixel(dpy, screen);
+ priv->gcCur = XCreateGC(dpy, win, mask, &gcvals);
+
+ dmxConsoleDraw(priv, 1, 1);
+
+ if (screenInfo.screens[0]->devPrivates[dmxScreenPrivateIndex].ptr)
+ priv->next = (screenInfo.screens[0]
+ ->devPrivates[dmxScreenPrivateIndex].ptr);
+ else
+ DMX_WRAP(CloseScreen, dmxCloseConsoleScreen,
+ priv, screenInfo.screens[0]);
+ screenInfo.screens[0]->devPrivates[dmxScreenPrivateIndex].ptr = priv;
+}
+
+/** Fill in the \a info structure for the specified \a pDev. Only used
+ * for pointers. */
+void dmxConsoleMouGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ info->buttonClass = 1;
+ dmxCommonMouGetMap(pDev, info->map, &info->numButtons);
+ info->valuatorClass = 1;
+ info->numRelAxes = 2;
+ info->minval[0] = 0;
+ info->maxval[0] = 0;
+ info->res[0] = 1;
+ info->minres[0] = 0;
+ info->maxres[0] = 1;
+ info->ptrFeedbackClass = 1;
+}
+
+/** Fill in the \a info structure for the specified \a pDev. Only used
+ * for keyboard. */
+void dmxConsoleKbdGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ dmxCommonKbdGetInfo(pDev, info);
+ info->keyboard = 1;
+ info->keyClass = 1;
+ dmxCommonKbdGetMap(pDev, &info->keySyms, info->modMap);
+ info->freemap = 1;
+ info->focusClass = 1;
+ info->kbdFeedbackClass = 1;
+}
+
+/** Handle special console-only keys. */
+int dmxConsoleFunctions(pointer private, DMXFunctionType function)
+{
+ GETONLYPRIVFROMPRIVATE;
+ XRectangle rect;
+ Display *dpy = priv->display;
+
+ switch (function) {
+ case DMX_FUNCTION_FINE:
+ if (priv->fine) {
+ priv->fine = 0;
+ dmxConsoleClearCursor(priv, priv->globalX, priv->globalY, &rect);
+ XSetClipRectangles(dpy, priv->gc, 0, 0, &rect, 1, Unsorted);
+ XCopyArea(dpy, priv->pixmap, priv->window, priv->gc,
+ 0, 0, priv->consWidth, priv->consHeight, 0, 0);
+ XSetClipMask(dpy, priv->gc, None);
+
+ XDefineCursor(dpy, priv->window,
+ priv->grabbed
+ ? priv->cursorGrabbed
+ : priv->cursorNormal);
+ XWarpPointer(dpy, priv->window, priv->window,
+ 0, 0, 0, 0,
+ scalex(priv, priv->globalX),
+ scaley(priv, priv->globalY));
+ XSync(dpy, False); /* Not a backend display */
+ } else {
+ priv->fine = 1;
+ XRaiseWindow(dpy, priv->window);
+ XDefineCursor(dpy, priv->window, priv->cursorEmpty);
+ dmxConsoleUpdateFineCursor(priv);
+ }
+ return 1;
+ case DMX_FUNCTION_GRAB:
+ if (priv->grabbed) {
+ XUngrabKeyboard(dpy, CurrentTime);
+ XUngrabPointer(dpy, CurrentTime);
+ XDefineCursor(dpy, priv->window,
+ priv->fine
+ ? priv->cursorEmpty
+ : priv->cursorNormal);
+ } else {
+ if (XGrabPointer(dpy, priv->window, True,
+ 0, GrabModeAsync, GrabModeAsync, priv->window,
+ None, CurrentTime)) {
+ dmxLog(dmxError, "XGrabPointer failed\n");
+ return 0;
+ }
+ if (XGrabKeyboard(dpy, priv->window, True,
+ GrabModeAsync, GrabModeAsync, CurrentTime)) {
+ dmxLog(dmxError, "XGrabKeyboard failed\n");
+ XUngrabPointer(dpy, CurrentTime);
+ return 0;
+ }
+ XDefineCursor(dpy, priv->window,
+ priv->fine
+ ? priv->cursorEmpty
+ : priv->cursorGrabbed);
+ }
+ priv->grabbed = !priv->grabbed;
+ if (priv->fine) dmxConsoleUpdateFineCursor(priv);
+ return 1;
+ case DMX_FUNCTION_TERMINATE:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+static void dmxDump(void)
+{
+ int i, j;
+ DMXInputInfo *dmxInput;
+ XEvent X;
+
+ for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++) {
+ for (j = 0; j < dmxInput->numDevs; j++) {
+ DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[j];
+ myPrivate *priv = dmxLocal->private;
+ while (priv
+ && priv->display
+ && XCheckTypedEvent(priv->display, MotionNotify, &X)) {
+ DMXDBG4("dmxDump: %s/%d threw event away %d %s\n",
+ dmxInput->name, j, X.type, dmxEventName(X.type));
+ }
+ }
+ }
+}
+
+/** This routine is used to warp the pointer into the console window
+ * from anywhere on the screen. It is used when backend and console
+ * input are both being taken from the same X display. */
+void dmxConsoleCapture(DMXInputInfo *dmxInput)
+{
+ int i;
+ XEvent X;
+
+ DMXDBG0("dmxConsoleCapture\n");
+ dmxSync(NULL, TRUE);
+ for (i = 0; i < dmxInput->numDevs; i++) {
+ DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[i];
+ myPrivate *priv = dmxLocal->private;
+ if (dmxLocal->extType != DMX_LOCAL_TYPE_CONSOLE) continue;
+ if (dmxLocal->type != DMX_LOCAL_MOUSE) continue;
+ if (priv->captured) continue;
+ priv->captured = 2; /* Ungrab only after proximal events. */
+ XRaiseWindow(priv->display, priv->window);
+ XSync(priv->display, False); /* Not a backend display */
+ while (XCheckTypedEvent(priv->display, MotionNotify, &X)) {
+ DMXDBG3(" Ignoring motion to %d %d after capture on %s\n",
+ X.xmotion.x, X.xmotion.y, dmxInput->name);
+ }
+ XWarpPointer(priv->display, None,
+ priv->window, 0, 0, 0, 0, priv->curX, priv->curY);
+ XSync(priv->display, False); /* Not a backend display */
+ dmxDump();
+ if (priv->fine) dmxConsoleUpdateFineCursor(priv);
+ }
+}
+
+/** Undo the capture that was done by #dmxConsoleCapture. */
+void dmxConsoleUncapture(DMXInputInfo *dmxInput)
+{
+ int i;
+
+ DMXDBG0("dmxConsoleUncapture\n");
+ dmxSync(NULL, TRUE);
+ for (i = 0; i < dmxInput->numDevs; i++) {
+ DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[i];
+ myPrivate *priv = dmxLocal->private;
+ if (dmxLocal->extType != DMX_LOCAL_TYPE_CONSOLE) continue;
+ if (dmxLocal->type != DMX_LOCAL_MOUSE) continue;
+ if (!priv->captured) continue;
+ priv->captured = 0;
+ XSync(priv->display, False); /* Not a backend display */
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxconsole.h b/nx-X11/programs/Xserver/hw/dmx/input/dmxconsole.h
new file mode 100644
index 000000000..85516fb5b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxconsole.h
@@ -0,0 +1,60 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for console device support. \see dmxconsole.c \see dmxcommon.c */
+
+#ifndef _DMXCONSOLE_H_
+#define _DMXCONSOLE_H_
+
+extern pointer dmxConsoleCreatePrivate(DeviceIntPtr pDevice);
+extern void dmxConsoleDestroyPrivate(pointer private);
+extern void dmxConsoleInit(DevicePtr pDev);
+extern void dmxConsoleReInit(DevicePtr pDev);
+extern void dmxConsoleMouGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
+extern void dmxConsoleKbdGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
+extern void dmxConsoleCollectEvents(DevicePtr pDev,
+ dmxMotionProcPtr motion,
+ dmxEnqueueProcPtr enqueue,
+ dmxCheckSpecialProcPtr checkspecial,
+ DMXBlockType block);
+extern int dmxConsoleFunctions(pointer private, DMXFunctionType function);
+extern void dmxConsoleUpdatePosition(pointer private, int x, int y);
+extern void dmxConsoleKbdSetCtrl(pointer private, KeybdCtrl *ctrl);
+extern void dmxConsoleCapture(DMXInputInfo *dmxInput);
+extern void dmxConsoleUncapture(DMXInputInfo *dmxInput);
+extern void dmxConsoleUpdateInfo(pointer private,
+ DMXUpdateType, WindowPtr pWindow);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxdetach.c b/nx-X11/programs/Xserver/hw/dmx/input/dmxdetach.c
new file mode 100644
index 000000000..d2e6b652f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxdetach.c
@@ -0,0 +1,59 @@
+/* $XFree86$ */
+/*
+ * Copyright 2004 Red Hat Inc., Raleigh, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Provide support and helper functions for input detach and attach. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmxinputinit.h"
+#include "dmxextension.h" /* For dmxInputCount */
+
+/** Search for input associated with \a dmxScreen, and detach. */
+void dmxInputDetach(DMXScreenInfo *dmxScreen, Bool reserveId)
+{
+ int i;
+
+ for (i = 0; i < dmxNumInputs; i++) {
+ DMXInputInfo *dmxInput = &dmxInputs[i];
+ if (dmxInput->scrnIdx == dmxScreen->index) {
+ dmxLogInput(dmxInput, "Detaching (%sreserved)\n",
+ reserveId ? "" : "not ");
+ dmxInput->detached = True;
+ return;
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxdummy.c b/nx-X11/programs/Xserver/hw/dmx/input/dmxdummy.c
new file mode 100644
index 000000000..d6e614e51
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxdummy.c
@@ -0,0 +1,87 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Provide mouse and keyboard that are sufficient for starting the X
+ * server, but that don't actually provide any events. This is useful
+ * for testing. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxinputinit.h"
+#include "dmxdummy.h"
+
+/** Return information about the dummy keyboard device specified in \a pDev
+ * into the structure pointed to by \a info. The keyboard is set up to
+ * have 1 valid key code that is \a NoSymbol */
+void dmxDummyKbdGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ static KeySym keyboard_mapping = NoSymbol;
+
+ info->keyboard = 1;
+ info->keyClass = 1;
+ info->keySyms.minKeyCode = 8;
+ info->keySyms.maxKeyCode = 8;
+ info->keySyms.mapWidth = 1;
+ info->keySyms.map = &keyboard_mapping;
+ info->freemap = 0;
+ info->focusClass = 1;
+ info->kbdFeedbackClass = 1;
+#ifdef XKB
+ info->force = 1;
+#endif
+}
+
+/** Return information about the dummy mouse device specified in \a pDev
+ * into the structure pointed to by \a info. They mouse has 3 buttons
+ * and two axes. */
+void dmxDummyMouGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ info->buttonClass = 1;
+ info->numButtons = 3;
+ info->map[0] = 1;
+ info->map[1] = 2;
+ info->map[2] = 3;
+ info->valuatorClass = 1;
+ info->numRelAxes = 2;
+ info->minval[0] = 0;
+ info->maxval[0] = 0;
+ info->res[0] = 1;
+ info->minres[0] = 0;
+ info->maxres[0] = 1;
+ info->ptrFeedbackClass = 1;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxdummy.h b/nx-X11/programs/Xserver/hw/dmx/input/dmxdummy.h
new file mode 100644
index 000000000..1f20a38cb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxdummy.h
@@ -0,0 +1,44 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to dummy input device support. \see dmxdummy.c */
+
+#ifndef _DMXDUMMY_H_
+#define _DMXDUMMY_H_
+
+extern void dmxDummyMouGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
+extern void dmxDummyKbdGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxeq.c b/nx-X11/programs/Xserver/hw/dmx/input/dmxeq.c
new file mode 100644
index 000000000..7a6bb11fc
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxeq.c
@@ -0,0 +1,309 @@
+/* $XFree86$ */
+/*
+ * $Xorg: mieq.c,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $
+ *
+ * Copyright 1990, 1998 The Open Group
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of The Open Group shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/*
+ * dmxeq.c is derived from mi/mieq.c so that XInput events can be handled
+ *
+ * Modified by: Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/** \file
+ * This file provides an event queue that knows about XInput events.
+ * All of the code is based on mi/mieq.c and was modified as little as
+ * possible to provide XInput event support (the copyright and some of
+ * the comments are from The Open Group, Keith Packard, MIT X
+ * Consortium). (Another example of similar code is provided in
+ * hw/xfree86/common/xf86Xinput.c.) */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#define DMX_EQ_DEBUG 0
+
+#include "dmx.h"
+#include "dmxeq.h"
+#include "dmxinput.h"
+#include "dmxlog.h"
+#include "dmxdpms.h"
+
+#include "inputstr.h"
+#include "scrnintstr.h" /* For screenInfo */
+
+#ifdef XINPUT
+#include <X11/extensions/XIproto.h>
+#define EXTENSION_PROC_ARGS void *
+#include "extinit.h" /* For LookupDeviceIntRec */
+#endif
+
+#if DMX_EQ_DEBUG
+#define DMXDBG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define DMXDBG5(f,a,b,c,d,e) dmxLog(dmxDebug,f,a,b,c,d,e)
+#else
+#define DMXDBG2(f,a,b)
+#define DMXDBG5(f,a,b,c,d,e)
+#endif
+
+/** The size of our queue. (The queue provided by mi/mieq.c has a size
+ * of 256.) */
+#define QUEUE_SIZE 256
+
+/** Information about the event. */
+typedef struct _Event {
+ xEvent event; /**< Event. */
+ ScreenPtr pScreen; /**< Screen on which event occurred. */
+#ifdef XINPUT
+ deviceValuator valuator; /**< XInput device valuator information. */
+#endif
+} EventRec, *EventPtr;
+
+/** Event queue. */
+typedef struct _EventQueue {
+ HWEventQueueType head; /**< Queue head; must be long for SetInputCheck. */
+ HWEventQueueType tail; /**< Queue tail; must be long for SetInputCheck. */
+ CARD32 lastEventTime; /**< To avoid time running backwards. */
+ Bool lastMotion; /**< True if last event was motion. */
+ EventRec events[QUEUE_SIZE]; /**< Static allocation for signals. */
+ DevicePtr pKbd, pPtr; /**< Device pointers (to get funcs) */
+ ScreenPtr pEnqueueScreen;/**< Screen events are delivered to. */
+ ScreenPtr pDequeueScreen;/**< Screen events are dispatched to. */
+} EventQueueRec, *EventQueuePtr;
+
+static EventQueueRec dmxEventQueue;
+static Bool dmxeqInitializedFlag = FALSE;
+
+Bool dmxeqInitialized(void)
+{
+ return dmxeqInitializedFlag;
+}
+
+Bool dmxeqInit(DevicePtr pKbd, DevicePtr pPtr)
+{
+ static unsigned long dmxGeneration = 0;
+
+ if (dmxGeneration == serverGeneration && dmxeqInitializedFlag)
+ return FALSE;
+ dmxGeneration = serverGeneration;
+ dmxeqInitializedFlag = TRUE;
+ dmxEventQueue.head = 0;
+ dmxEventQueue.tail = 0;
+ dmxEventQueue.lastEventTime = GetTimeInMillis();
+ dmxEventQueue.pKbd = pKbd;
+ dmxEventQueue.pPtr = pPtr;
+ dmxEventQueue.lastMotion = FALSE;
+ dmxEventQueue.pEnqueueScreen = screenInfo.screens[0];
+ dmxEventQueue.pDequeueScreen = dmxEventQueue.pEnqueueScreen;
+ SetInputCheck(&dmxEventQueue.head, &dmxEventQueue.tail);
+ return TRUE;
+}
+
+/**
+ * This function adds an event to the end of the queue. If the event is
+ * an XInput event, then the next event (the valuator event) is also
+ * stored in the queue. If the new event has a time before the time of
+ * the last event currently on the queue, then the time is updated for
+ * the new event.
+ *
+ * Must be reentrant with ProcessInputEvents. Assumption: dmxeqEnqueue
+ * will never be interrupted. If this is called from both signal
+ * handlers and regular code, make sure the signal is suspended when
+ * called from regular code.
+ */
+
+void dmxeqEnqueue(xEvent *e)
+{
+ HWEventQueueType oldtail, newtail;
+ Bool isMotion;
+
+ oldtail = dmxEventQueue.tail;
+ isMotion = e->u.u.type == MotionNotify;
+ if (isMotion
+ && dmxEventQueue.lastMotion
+ && oldtail != dmxEventQueue.head) {
+ if (oldtail == 0) oldtail = QUEUE_SIZE;
+ oldtail = oldtail - 1;
+ } else {
+ newtail = oldtail + 1;
+ if (newtail == QUEUE_SIZE) newtail = 0;
+ /* Toss events which come in late */
+ if (newtail == dmxEventQueue.head) return;
+ dmxEventQueue.tail = newtail;
+ }
+ DMXDBG2("dmxeqEnqueue %d %d\n", dmxEventQueue.head, dmxEventQueue.tail);
+ dmxEventQueue.lastMotion = isMotion;
+ dmxEventQueue.events[oldtail].pScreen = dmxEventQueue.pEnqueueScreen;
+
+ /* Store the event in the queue */
+ dmxEventQueue.events[oldtail].event = *e;
+#ifdef XINPUT
+ {
+ /* If this is an XInput event, store the
+ * valuator event, too */
+ deviceKeyButtonPointer *ev = (deviceKeyButtonPointer *)e;
+ if (e->u.u.type >= LASTEvent && (ev->deviceid & MORE_EVENTS))
+ dmxEventQueue.events[oldtail].valuator = *(deviceValuator *)(ev+1);
+ }
+#endif
+
+ /* Make sure that event times don't go
+ * backwards - this is "unnecessary",
+ * but very useful */
+ if (e->u.keyButtonPointer.time < dmxEventQueue.lastEventTime
+ && dmxEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000) {
+ dmxEventQueue.events[oldtail].event.u.keyButtonPointer.time =
+ dmxEventQueue.lastEventTime;
+ }
+}
+
+/** Make \a pScreen the new screen for enqueueing events. If \a fromDIX
+ * is TRUE, also make \a pScreen the new screen for dequeuing events. */
+void dmxeqSwitchScreen(ScreenPtr pScreen, Bool fromDIX)
+{
+ dmxEventQueue.pEnqueueScreen = pScreen;
+ if (fromDIX) dmxEventQueue.pDequeueScreen = pScreen;
+}
+
+#ifdef XINPUT
+static void dmxeqProcessXInputEvent(xEvent *xe, EventRec *e)
+{
+ deviceKeyButtonPointer *ev = (deviceKeyButtonPointer *)xe;
+ int id = ev->deviceid & DEVICE_BITS;
+ DeviceIntPtr pDevice = LookupDeviceIntRec(id);
+
+ if (!pDevice) {
+ dmxLog(dmxError, "dmxeqProcessInputEvents: id %d not found\n", id);
+ return;
+ }
+
+ if (!pDevice->public.processInputProc) {
+ dmxLog(dmxError,
+ "dmxeqProcessInputEvents: no processInputProc for"
+ " device id %d (%s)\n", id, pDevice->name);
+ return;
+ }
+
+ if (ev->deviceid & MORE_EVENTS) {
+ xe[1] = *(xEvent *)(&e->valuator);
+ pDevice->public.processInputProc(xe, pDevice, 2);
+ } else {
+ pDevice->public.processInputProc(xe, pDevice, 1);
+ }
+}
+#endif
+
+/**
+ * This function is called from #ProcessInputEvents() to remove events
+ * from the queue and process them.
+ */
+void dmxeqProcessInputEvents(void)
+{
+ EventRec *e;
+ int x, y;
+ xEvent xe[2];
+
+ while (dmxEventQueue.head != dmxEventQueue.tail) {
+ dmxDPMSWakeup(); /* Handles screen saver and DPMS */
+ e = &dmxEventQueue.events[dmxEventQueue.head];
+ DMXDBG5("dmxeqProcessInputEvents: type=%d screen=%p,%p root=%d,%d\n",
+ e->event.u.u.type,
+ e->pScreen, dmxEventQueue.pDequeueScreen,
+ e->event.u.keyButtonPointer.rootX,
+ e->event.u.keyButtonPointer.rootY);
+ /*
+ * Assumption - screen switching can only occur on core motion events
+ */
+ if (e->event.u.u.type == MotionNotify
+ && e->pScreen != dmxEventQueue.pDequeueScreen) {
+ dmxEventQueue.pDequeueScreen = e->pScreen;
+ x = e->event.u.keyButtonPointer.rootX;
+ y = e->event.u.keyButtonPointer.rootY;
+ if (dmxEventQueue.head == QUEUE_SIZE - 1) dmxEventQueue.head = 0;
+ else ++dmxEventQueue.head;
+ NewCurrentScreen(dmxEventQueue.pDequeueScreen, x, y);
+ } else {
+ xe[0] = e->event;
+ if (dmxEventQueue.head == QUEUE_SIZE - 1) dmxEventQueue.head = 0;
+ else ++dmxEventQueue.head;
+ switch (xe[0].u.u.type) {
+ case KeyPress:
+ case KeyRelease:
+ if (!dmxEventQueue.pKbd) {
+ dmxLog(dmxError, "dmxeqProcessInputEvents: No keyboard\n");
+ return;
+ }
+ dmxEventQueue.pKbd
+ ->processInputProc(xe,
+ (DeviceIntPtr)dmxEventQueue.pKbd, 1);
+ break;
+ default:
+#ifdef XINPUT
+ dmxeqProcessXInputEvent(xe, e);
+ break;
+#endif
+ /* ifndef XINPUT, fall through */
+ case ButtonPress:
+ case ButtonRelease:
+ case MotionNotify:
+ if (!dmxEventQueue.pPtr) {
+ dmxLog(dmxError, "dmxeqProcessInputEvents: No mouse\n");
+ return;
+ }
+ dmxEventQueue.pPtr
+ ->processInputProc(xe,
+ (DeviceIntPtr)dmxEventQueue.pPtr, 1);
+ break;
+ }
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxeq.h b/nx-X11/programs/Xserver/hw/dmx/input/dmxeq.h
new file mode 100644
index 000000000..64d15f7e8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxeq.h
@@ -0,0 +1,44 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to the event queue support. Some of these functions are
+ * included in dmxinput.h, since they are used by top-level .c
+ * files. \see dmxeq.c \see dmxinput.h */
+
+#ifndef _DMXEQ_H_
+#define _DMXEQ_H_
+extern Bool dmxeqInit(DevicePtr pKbd, DevicePtr pPtr);
+extern void dmxeqProcessInputEvents(void);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxevents.c b/nx-X11/programs/Xserver/hw/dmx/input/dmxevents.c
new file mode 100644
index 000000000..5316f0fdc
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxevents.c
@@ -0,0 +1,716 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Provide support and helper functions for enqueing events received by
+ * the low-level input drivers. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#define DMX_EVENTS_DEBUG 0
+
+#include "dmxinputinit.h"
+#include "dmxevents.h"
+#include "dmxcb.h"
+#include "dmxcommon.h"
+#include "dmxcursor.h"
+#include "dmxmotion.h"
+#include "dmxeq.h"
+#include "dmxsigio.h"
+#include "dmxmap.h"
+
+#include <X11/keysym.h>
+#include "opaque.h"
+#include "inputstr.h"
+#include "mipointer.h"
+
+#ifdef XINPUT
+#include "XIstubs.h"
+#endif
+
+static int dmxGlobalX, dmxGlobalY; /* Global cursor position */
+static int dmxGlobalInvalid; /* Flag indicating dmxCoreMotion
+ * should move the mouse anyway. */
+
+#if DMX_EVENTS_DEBUG
+#define DMXDBG0(f) dmxLog(dmxDebug,f)
+#define DMXDBG1(f,a) dmxLog(dmxDebug,f,a)
+#define DMXDBG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define DMXDBG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define DMXDBG4(f,a,b,c,d) dmxLog(dmxDebug,f,a,b,c,d)
+#define DMXDBG5(f,a,b,c,d,e) dmxLog(dmxDebug,f,a,b,c,d,e)
+#define DMXDBG6(f,a,b,c,d,e,g) dmxLog(dmxDebug,f,a,b,c,d,e,g)
+#define DMXDBG7(f,a,b,c,d,e,g,h) dmxLog(dmxDebug,f,a,b,c,d,e,g,h)
+#else
+#define DMXDBG0(f)
+#define DMXDBG1(f,a)
+#define DMXDBG2(f,a,b)
+#define DMXDBG3(f,a,b,c)
+#define DMXDBG4(f,a,b,c,d)
+#define DMXDBG5(f,a,b,c,d,e)
+#define DMXDBG6(f,a,b,c,d,e,g)
+#define DMXDBG7(f,a,b,c,d,e,g,h)
+#endif
+
+static int dmxApplyFunctions(DMXInputInfo *dmxInput, DMXFunctionType f)
+{
+ int i;
+ int rc = 0;
+
+ for (i = 0; i < dmxInput->numDevs; i+= dmxInput->devs[i]->binding)
+ if (dmxInput->devs[i]->functions)
+ rc += dmxInput->devs[i]->functions(dmxInput->devs[i]->private, f);
+ return rc;
+}
+
+static int dmxCheckFunctionKeys(DMXLocalInputInfoPtr dmxLocal,
+ int type,
+ KeySym keySym)
+{
+ DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx];
+ unsigned short state = 0;
+
+ if (dmxLocal->sendsCore)
+ state = dmxLocalCoreKeyboard->pDevice->key->state;
+ else if (dmxLocal->pDevice->key)
+ state = dmxLocal->pDevice->key->state;
+
+ DMXDBG3("dmxCheckFunctionKeys: keySym=0x%04x %s state=0x%04x\n",
+ keySym, type == KeyPress ? "press" : "release", state);
+
+ if ((state & (ControlMask|Mod1Mask)) != (ControlMask|Mod1Mask)) return 0;
+
+ switch (keySym) {
+ case XK_g:
+ if (type == KeyPress)
+ dmxApplyFunctions(dmxInput, DMX_FUNCTION_GRAB);
+ return 1;
+ case XK_f:
+ if (type == KeyPress)
+ dmxApplyFunctions(dmxInput, DMX_FUNCTION_FINE);
+ return 1;
+ case XK_q:
+ if (type == KeyPress && dmxLocal->sendsCore)
+ if (dmxApplyFunctions(dmxInput, DMX_FUNCTION_TERMINATE)) {
+ dmxLog(dmxInfo, "User request for termination\n");
+ dispatchException |= DE_TERMINATE;
+ }
+ return 1;
+ }
+
+ return 0;
+}
+
+#ifdef XINPUT
+static void dmxEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal, xEvent *e,
+ DMXBlockType block)
+{
+ xEvent xE[2];
+ deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *)xE;
+ deviceValuator *xv = (deviceValuator *)xev+1;
+ DeviceIntPtr pDevice = dmxLocal->pDevice;
+ DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx];
+ int type = e->u.u.type;
+
+ switch (e->u.u.type) {
+ case KeyPress: type = DeviceKeyPress; break;
+ case KeyRelease: type = DeviceKeyRelease; break;
+ case ButtonPress: type = DeviceButtonPress; break;
+ case ButtonRelease: type = DeviceButtonRelease; break;
+ case MotionNotify:
+ dmxLog(dmxError,
+ "dmxEnqueueExtEvent: MotionNotify not allowed here\n");
+ return;
+ default:
+ if (e->u.u.type == ProximityIn || e->u.u.type == ProximityOut) break;
+ dmxLogInput(dmxInput,
+ "dmxEnqueueExtEvent: Unhandled %s event (%d)\n",
+ e->u.u.type >= LASTEvent ? "extension" : "non-extension",
+ e->u.u.type);
+ return;
+ }
+
+ xev->type = type;
+ xev->detail = e->u.u.detail;
+ xev->deviceid = pDevice->id | MORE_EVENTS;
+ xev->time = e->u.keyButtonPointer.time;
+
+ xv->type = DeviceValuator;
+ xv->deviceid = pDevice->id;
+ xv->num_valuators = 0;
+ xv->first_valuator = 0;
+
+ if (block) dmxSigioBlock();
+ dmxeqEnqueue(xE);
+ if (block) dmxSigioUnblock();
+}
+#endif
+
+DMXScreenInfo *dmxFindFirstScreen(int x, int y)
+{
+ int i;
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ if (dmxOnScreen(x, y, dmxScreen)) return dmxScreen;
+ }
+ return NULL;
+}
+
+void dmxCoreMotion(int x, int y, int delta, DMXBlockType block)
+{
+ DMXScreenInfo *dmxScreen;
+ DMXInputInfo *dmxInput;
+ ScreenPtr pScreen;
+ int localX;
+ int localY;
+ int i;
+
+ if (!dmxGlobalInvalid && dmxGlobalX == x && dmxGlobalY == y) return;
+
+ DMXDBG5("dmxCoreMotion(%d,%d,%d) dmxGlobalX=%d dmxGlobalY=%d\n",
+ x, y, delta, dmxGlobalX, dmxGlobalY);
+
+ dmxGlobalInvalid = 0;
+ dmxGlobalX = x;
+ dmxGlobalY = y;
+
+ if (dmxGlobalX < 0) dmxGlobalX = 0;
+ if (dmxGlobalY < 0) dmxGlobalY = 0;
+ if (dmxGlobalX >= dmxGlobalWidth) dmxGlobalX = dmxGlobalWidth + delta -1;
+ if (dmxGlobalY >= dmxGlobalHeight) dmxGlobalY = dmxGlobalHeight + delta -1;
+
+ if ((dmxScreen = dmxFindFirstScreen(dmxGlobalX, dmxGlobalY))) {
+ localX = dmxGlobalX - dmxScreen->rootXOrigin;
+ localY = dmxGlobalY - dmxScreen->rootYOrigin;
+ if ((pScreen = miPointerCurrentScreen())
+ && pScreen->myNum == dmxScreen->index) {
+ /* Screen is old screen */
+ if (block) dmxSigioBlock();
+ miPointerAbsoluteCursor(localX, localY, GetTimeInMillis());
+ if (block) dmxSigioUnblock();
+ } else {
+ /* Screen is new */
+ DMXDBG4(" New screen: old=%d new=%d localX=%d localY=%d\n",
+ pScreen->myNum, dmxScreen->index, localX, localY);
+ if (block) dmxSigioBlock();
+ dmxeqProcessInputEvents();
+ miPointerSetNewScreen(dmxScreen->index, localX, localY);
+ miPointerAbsoluteCursor(localX, localY, GetTimeInMillis());
+ if (block) dmxSigioUnblock();
+ }
+ miPointerPosition(&localX, &localY);
+
+ if ((pScreen = miPointerCurrentScreen())) {
+ dmxGlobalX = localX + dmxScreens[pScreen->myNum].rootXOrigin;
+ dmxGlobalY = localY + dmxScreens[pScreen->myNum].rootYOrigin;
+ DMXDBG6(" Moved to dmxGlobalX=%d dmxGlobalY=%d"
+ " on screen index=%d/%d localX=%d localY=%d\n",
+ dmxGlobalX, dmxGlobalY,
+ dmxScreen ? dmxScreen->index : -1, pScreen->myNum,
+ localX, localY);
+ }
+ }
+ /* Send updates down to all core input
+ * drivers */
+ for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++) {
+ int j;
+
+ for (j = 0; j < dmxInput->numDevs; j += dmxInput->devs[j]->binding)
+ if (!dmxInput->detached
+ && dmxInput->devs[j]->sendsCore
+ && dmxInput->devs[j]->update_position)
+ dmxInput->devs[j]->update_position(dmxInput->devs[j]->private,
+ dmxGlobalX, dmxGlobalY);
+ }
+ if (!dmxScreen) ProcessInputEvents();
+}
+
+#ifdef XINPUT
+#define DMX_MAX_AXES 32 /* Max axes reported by this routine */
+static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
+ int *v, int firstAxis, int axesCount,
+ DMXMotionType type, DMXBlockType block)
+{
+ DeviceIntPtr pDevice = dmxLocal->pDevice;
+ xEvent xE[2 * DMX_MAX_AXES/6];
+ deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *)xE;
+ deviceValuator *xv = (deviceValuator *)xev+1;
+ int thisX = 0;
+ int thisY = 0;
+ int i;
+ int count;
+
+ memset(xE, 0, sizeof(xE));
+
+ if (axesCount > DMX_MAX_AXES) axesCount = DMX_MAX_AXES;
+
+ if (!pDevice->valuator->mode && axesCount == 2) {
+ /* The dmx console is a relative mode
+ * device that sometimes reports
+ * absolute motion. It only has two
+ * axes. */
+ if (type == DMX_RELATIVE) {
+ thisX = -v[0];
+ thisY = -v[1];
+ dmxLocal->lastX += thisX;
+ dmxLocal->lastY += thisY;
+ if (dmxLocal->update_position)
+ dmxLocal->update_position(dmxLocal->private,
+ dmxLocal->lastX, dmxLocal->lastY);
+ } else { /* Convert to relative */
+ if (dmxLocal->lastX || dmxLocal->lastY) {
+ thisX = v[0] - dmxLocal->lastX;
+ thisY = v[1] - dmxLocal->lastY;
+ }
+ dmxLocal->lastX = v[0];
+ dmxLocal->lastY = v[1];
+ }
+ v[0] = thisX;
+ v[1] = thisY;
+ }
+
+ if (axesCount <= 6) {
+ /* Optimize for the common case when
+ * only 1 or 2 axes change. */
+ xev->time = GetTimeInMillis();
+ xev->type = DeviceMotionNotify;
+ xev->detail = 0;
+ xev->deviceid = pDevice->id | MORE_EVENTS;
+
+ xv->type = DeviceValuator;
+ xv->deviceid = pDevice->id;
+ xv->num_valuators = axesCount;
+ xv->first_valuator = firstAxis;
+ switch (xv->num_valuators) {
+ case 6: xv->valuator5 = v[5];
+ case 5: xv->valuator4 = v[4];
+ case 4: xv->valuator3 = v[3];
+ case 3: xv->valuator2 = v[2];
+ case 2: xv->valuator1 = v[1];
+ case 1: xv->valuator0 = v[0];
+ }
+ count = 2;
+ } else {
+ for (i = 0, count = 0; i < axesCount; i += 6) {
+ xev->time = GetTimeInMillis();
+ xev->type = DeviceMotionNotify;
+ xev->detail = 0;
+ xev->deviceid = pDevice->id | MORE_EVENTS;
+ xev += 2;
+
+ xv->type = DeviceValuator;
+ xv->deviceid = pDevice->id;
+ xv->num_valuators = (i+6 >= axesCount ? axesCount - i : 6);
+ xv->first_valuator = firstAxis + i;
+ switch (xv->num_valuators) {
+ case 6: xv->valuator5 = v[i+5];
+ case 5: xv->valuator4 = v[i+4];
+ case 4: xv->valuator3 = v[i+3];
+ case 3: xv->valuator2 = v[i+2];
+ case 2: xv->valuator1 = v[i+1];
+ case 1: xv->valuator0 = v[i+0];
+ }
+ xv += 2;
+ count += 2;
+ }
+ }
+
+ if (block) dmxSigioBlock();
+ dmxPointerPutMotionEvent(pDevice, firstAxis, axesCount, v, xev->time);
+ dmxeqEnqueue(xE);
+ if (block) dmxSigioUnblock();
+}
+
+static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
+ XEvent *e, DMXBlockType block)
+{
+ xEvent xE[2];
+ deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *)xE;
+ deviceValuator *xv = (deviceValuator *)xev+1;
+ int type;
+ int event = -1;
+ XDeviceKeyEvent *ke = (XDeviceKeyEvent *)e;
+ XDeviceMotionEvent *me = (XDeviceMotionEvent *)e;
+
+ if (!e) return -1; /* No extended event passed, cannot handle */
+
+ if ((XID)dmxLocal->deviceId != ke->deviceid) {
+ /* Search for the correct dmxLocal,
+ * since backend and console events are
+ * picked up for the first device on
+ * that X server. */
+ int i;
+ DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx];
+ for (i = 0; i < dmxInput->numDevs; i++) {
+ dmxLocal = dmxInput->devs[i];
+ if ((XID)dmxLocal->deviceId == ke->deviceid) break;
+ }
+ }
+
+ if ((XID)dmxLocal->deviceId != ke->deviceid
+ || (type = dmxMapLookup(dmxLocal, e->type)) < 0)
+ return -1; /* No mapping, so this event is unhandled */
+
+ switch (type) {
+ case XI_DeviceValuator: event = DeviceValuator; break;
+ case XI_DeviceKeyPress: event = DeviceKeyPress; break;
+ case XI_DeviceKeyRelease: event = DeviceKeyRelease; break;
+ case XI_DeviceButtonPress: event = DeviceButtonPress; break;
+ case XI_DeviceButtonRelease: event = DeviceButtonRelease; break;
+ case XI_DeviceMotionNotify: event = DeviceMotionNotify; break;
+ case XI_DeviceFocusIn: event = DeviceFocusIn; break;
+ case XI_DeviceFocusOut: event = DeviceFocusOut; break;
+ case XI_ProximityIn: event = ProximityIn; break;
+ case XI_ProximityOut: event = ProximityOut; break;
+ case XI_DeviceStateNotify: event = DeviceStateNotify; break;
+ case XI_DeviceMappingNotify: event = DeviceMappingNotify; break;
+ case XI_ChangeDeviceNotify: event = ChangeDeviceNotify; break;
+ case XI_DeviceKeystateNotify: event = DeviceStateNotify; break;
+ case XI_DeviceButtonstateNotify: event = DeviceStateNotify; break;
+ }
+
+ switch (type) {
+ case XI_DeviceKeyPress:
+ case XI_DeviceKeyRelease:
+ case XI_DeviceButtonPress:
+ case XI_DeviceButtonRelease:
+ case XI_ProximityIn:
+ case XI_ProximityOut:
+ xev->type = event;
+ xev->detail = ke->keycode; /* same as ->button */
+ xev->deviceid = dmxLocal->pDevice->id | MORE_EVENTS;
+ xev->time = GetTimeInMillis();
+
+ xv->type = DeviceValuator;
+ xv->deviceid = dmxLocal->pDevice->id;
+ xv->num_valuators = ke->axes_count;
+ xv->first_valuator = ke->first_axis;
+ xv->valuator0 = ke->axis_data[0];
+ xv->valuator1 = ke->axis_data[1];
+ xv->valuator2 = ke->axis_data[2];
+ xv->valuator3 = ke->axis_data[3];
+ xv->valuator4 = ke->axis_data[4];
+ xv->valuator5 = ke->axis_data[5];
+
+ if (block) dmxSigioBlock();
+ dmxeqEnqueue(xE);
+ if (block) dmxSigioUnblock();
+ break;
+
+ case XI_DeviceMotionNotify:
+ dmxExtMotion(dmxLocal, me->axis_data, me->first_axis, me->axes_count,
+ DMX_ABSOLUTE, block);
+ break;
+ case XI_DeviceFocusIn:
+ case XI_DeviceFocusOut:
+ case XI_DeviceStateNotify:
+ case XI_DeviceMappingNotify:
+ case XI_ChangeDeviceNotify:
+ case XI_DeviceKeystateNotify:
+ case XI_DeviceButtonstateNotify:
+ /* These are ignored, since DMX will
+ * generate its own events of these
+ * types, as necessary.
+
+ * Perhaps ChangeDeviceNotify should
+ * generate an error, because it is
+ * unexpected? */
+ break;
+ case XI_DeviceValuator:
+ default:
+ dmxLog(dmxWarning,
+ "XInput extension event (remote=%d -> zero-based=%d)"
+ " not supported yet\n", e->type, type);
+ return -1;
+ }
+ return 0;
+}
+#endif
+
+static int dmxGetButtonMapping(DMXLocalInputInfoPtr dmxLocal, int button)
+{
+ ButtonClassPtr b = dmxLocal->pDevice->button;
+
+ if (button > b->numButtons) { /* This shouldn't happen. */
+ dmxLog(dmxWarning, "Button %d pressed, but only %d buttons?!?\n",
+ button, b->numButtons);
+ return button;
+ }
+ return b->map[button];
+}
+
+/** Return DMX's notion of the pointer position in the global coordinate
+ * space. */
+void dmxGetGlobalPosition(int *x, int *y)
+{
+ *x = dmxGlobalX;
+ *y = dmxGlobalY;
+}
+
+/** Invalidate the global position for #dmxCoreMotion. */
+void dmxInvalidateGlobalPosition(void)
+{
+ dmxGlobalInvalid = 1;
+}
+
+/** Enqueue a motion event for \a pDev. The \a v vector has length \a
+ * axesCount, and contains values for each of the axes, starting at \a
+ * firstAxes.
+ *
+ * The \a type of the motion may be \a DMX_RELATIVE, \a DMX_ABSOLUTE, or
+ * \a DMX_ABSOLUTE_CONFINED (in the latter case, the pointer will not be
+ * allowed to move outside the global boundaires).
+ *
+ * If \a block is set to \a DMX_BLOCK, then the SIGIO handler will be
+ * blocked around calls to #dmxeqEnqueue(). */
+void dmxMotion(DevicePtr pDev, int *v, int firstAxes, int axesCount,
+ DMXMotionType type, DMXBlockType block)
+{
+#ifdef XINPUT
+ GETDMXLOCALFROMPDEV;
+
+ if (!dmxLocal->sendsCore) {
+ dmxExtMotion(dmxLocal, v, firstAxes, axesCount, type, block);
+ return;
+ }
+#endif
+ if (axesCount == 2) switch (type) {
+ case DMX_RELATIVE: dmxCoreMotion(dmxGlobalX - v[0],
+ dmxGlobalY - v[1],
+ 0, block); break;
+ case DMX_ABSOLUTE: dmxCoreMotion(v[0], v[1], 0, block); break;
+ case DMX_ABSOLUTE_CONFINED: dmxCoreMotion(v[0], v[1], -1, block); break;
+ }
+}
+
+static KeySym dmxKeyCodeToKeySym(DMXLocalInputInfoPtr dmxLocal,
+ KeyCode keyCode)
+{
+ KeySymsPtr pKeySyms = NULL;
+
+ if (!dmxLocal || !dmxLocal->pDevice || !dmxLocal->pDevice->key)
+ return NoSymbol;
+ pKeySyms = &dmxLocal->pDevice->key->curKeySyms;
+ if (!pKeySyms) return NoSymbol;
+
+ if (keyCode > pKeySyms->minKeyCode && keyCode <= pKeySyms->maxKeyCode) {
+ DMXDBG2("dmxKeyCodeToKeySym: Translated keyCode=%d to keySym=0x%04x\n",
+ keyCode,
+ pKeySyms->map[(keyCode - pKeySyms->minKeyCode)
+ * pKeySyms->mapWidth]);
+
+ return pKeySyms->map[(keyCode - pKeySyms->minKeyCode)
+ * pKeySyms->mapWidth];
+ }
+ return NoSymbol;
+}
+
+static KeyCode dmxKeySymToKeyCode(DMXLocalInputInfoPtr dmxLocal, KeySym keySym,
+ int tryFirst)
+{
+ KeySymsPtr pKeySyms = &dmxLocal->pDevice->key->curKeySyms;
+ int i;
+
+ /* Optimize for similar maps */
+ if (tryFirst >= pKeySyms->minKeyCode
+ && tryFirst <= pKeySyms->maxKeyCode
+ && pKeySyms->map[(tryFirst - pKeySyms->minKeyCode)
+ * pKeySyms->mapWidth] == keySym)
+ return tryFirst;
+
+ for (i = pKeySyms->minKeyCode; i <= pKeySyms->maxKeyCode; i++) {
+ if (pKeySyms->map[(i - pKeySyms->minKeyCode)
+ * pKeySyms->mapWidth] == keySym) {
+ DMXDBG3("dmxKeySymToKeyCode: Translated keySym=0x%04x to"
+ " keyCode=%d (reverses to core keySym=0x%04x)\n",
+ keySym, i, dmxKeyCodeToKeySym(dmxLocalCoreKeyboard,i));
+ return i;
+ }
+ }
+ return 0;
+}
+
+static int dmxFixup(DevicePtr pDev, int detail, KeySym keySym)
+{
+ GETDMXLOCALFROMPDEV;
+ int keyCode;
+
+ if (!dmxLocal->pDevice->key) {
+ dmxLog(dmxWarning, "dmxFixup: not a keyboard device (%s)\n",
+ dmxLocal->pDevice->name);
+ return NoSymbol;
+ }
+ if (!keySym) keySym = dmxKeyCodeToKeySym(dmxLocal, detail);
+ if (keySym == NoSymbol) return detail;
+ keyCode = dmxKeySymToKeyCode(dmxLocalCoreKeyboard, keySym, detail);
+
+ return keyCode ? keyCode : detail;
+}
+
+/** Enqueue a non-motion event from the \a pDev device with the
+ * specified \a type and \a detail. If the event is a KeyPress or
+ * KeyRelease event, then the \a keySym is also specified.
+ *
+ * If \a block is set to \a DMX_BLOCK, then the SIGIO handler will be
+ * blocked around calls to #dmxeqEnqueue(). */
+
+void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
+ XEvent *e, DMXBlockType block)
+{
+ GETDMXINPUTFROMPDEV;
+ xEvent xE;
+
+ DMXDBG2("dmxEnqueue: Enqueuing type=%d detail=0x%0x\n", type, detail);
+
+ switch (type) {
+ case KeyPress:
+ case KeyRelease:
+ if (!keySym) keySym = dmxKeyCodeToKeySym(dmxLocal, detail);
+ if (dmxCheckFunctionKeys(dmxLocal, type, keySym))
+ return;
+ if (dmxLocal->sendsCore && dmxLocal != dmxLocalCoreKeyboard)
+ xE.u.u.detail = dmxFixup(pDev, detail, keySym);
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ detail = dmxGetButtonMapping(dmxLocal, detail);
+ break;
+ case MotionNotify:
+ /* All MotionNotify events should be sent via dmxCoreMotion and
+ * dmxExtMotion -- no input driver should build motion events by
+ * hand. */
+ dmxLog(dmxError, "dmxEnqueueXEvent: MotionNotify not allowed here\n");
+ break;
+ /* Always ignore these events */
+ case EnterNotify:
+ case LeaveNotify:
+ case KeymapNotify:
+ case MappingNotify: /* This is sent because we change the
+ * modifier map on the backend/console
+ * input device so that we have complete
+ * control of the input device LEDs. */
+ return;
+ default:
+#ifdef XINPUT
+ if (type == ProximityIn || type == ProximityOut) {
+ if (dmxLocal->sendsCore) return; /* Not a core event */
+ break;
+ }
+#endif
+ if (type >= LASTEvent) {
+#ifdef XINPUT
+ if (dmxTranslateAndEnqueueExtEvent(dmxLocal, e, block))
+#endif
+ dmxLogInput(dmxInput, "Unhandled extension event: %d\n", type);
+ } else {
+ dmxLogInput(dmxInput, "Unhandled event: %d (%s)\n",
+ type, dmxEventName(type));
+ }
+ return;
+ }
+
+ memset(&xE, 0, sizeof(xE));
+ xE.u.u.type = type;
+ xE.u.u.detail = detail;
+ xE.u.keyButtonPointer.time = GetTimeInMillis();
+
+#ifdef XINPUT
+ if (!dmxLocal->sendsCore) dmxEnqueueExtEvent(dmxLocal, &xE, block);
+ else
+#endif
+ dmxeqEnqueue(&xE);
+}
+
+/** A pointer to this routine is passed to low-level input drivers so
+ * that all special keychecking is unified to this file. This function
+ * returns 0 if no special keys have been pressed. If the user has
+ * requested termination of the DMX server, -1 is returned. If the user
+ * has requested a switch to a VT, then the (1-based) number of that VT
+ * is returned. */
+int dmxCheckSpecialKeys(DevicePtr pDev, KeySym keySym)
+{
+ GETDMXINPUTFROMPDEV;
+ int vt = 0;
+ unsigned short state = 0;
+
+ if (dmxLocal->sendsCore)
+ state = dmxLocalCoreKeyboard->pDevice->key->state;
+ else if (dmxLocal->pDevice->key)
+ state = dmxLocal->pDevice->key->state;
+
+ if (!dmxLocal->sendsCore) return 0; /* Only for core devices */
+
+ DMXDBG2("dmxCheckSpecialKeys: keySym=0x%04x state=0x%04x\n", keySym,state);
+
+ if ((state & (ControlMask|Mod1Mask)) != (ControlMask|Mod1Mask)) return 0;
+
+ switch (keySym) {
+ case XK_F1:
+ case XK_F2:
+ case XK_F3:
+ case XK_F4:
+ case XK_F5:
+ case XK_F6:
+ case XK_F7:
+ case XK_F8:
+ case XK_F9:
+ case XK_F10:
+ vt = keySym - XK_F1 + 1;
+ break;
+
+ case XK_F11:
+ case XK_F12:
+ vt = keySym - XK_F11 + 11;
+ break;
+
+ case XK_q: /* To avoid confusion */
+ case XK_BackSpace:
+ case XK_Delete:
+ case XK_KP_Delete:
+ dmxLog(dmxInfo, "User request for termination\n");
+ dispatchException |= DE_TERMINATE;
+ return -1; /* Terminate */
+ }
+
+ if (vt) {
+ dmxLog(dmxInfo, "Request to switch to VT %d\n", vt);
+ dmxInput->vt_switch_pending = vt;
+ return vt;
+ }
+
+ return 0; /* Do nothing */
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxevents.h b/nx-X11/programs/Xserver/hw/dmx/input/dmxevents.h
new file mode 100644
index 000000000..f8d29d440
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxevents.h
@@ -0,0 +1,47 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to event processing functions. \see dmxevents.h */
+
+#ifndef _DMXEVENTS_H_
+#define _DMXEVENTS_H_
+
+extern void dmxMotion(DevicePtr pDev, int *v, int firstAxis, int axesCount,
+ DMXMotionType type, DMXBlockType block);
+extern void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
+ XEvent *e, DMXBlockType block);
+extern int dmxCheckSpecialKeys(DevicePtr pDev, KeySym keySym);
+extern void dmxInvalidateGlobalPosition(void);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxinputinit.c b/nx-X11/programs/Xserver/hw/dmx/input/dmxinputinit.c
new file mode 100644
index 000000000..5332dccd9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxinputinit.c
@@ -0,0 +1,1298 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * This file provides generic input support. Functions here set up
+ * input and lead to the calling of low-level device drivers for
+ * input. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#define DMX_WINDOW_DEBUG 0
+
+#include "dmxinputinit.h"
+#include "dmxextension.h" /* For dmxInputCount */
+
+#include "dmxdummy.h"
+#include "dmxbackend.h"
+#include "dmxconsole.h"
+#include "dmxcommon.h"
+#include "dmxevents.h"
+#include "dmxmotion.h"
+#include "dmxeq.h"
+#include "dmxprop.h"
+#include "config/dmxconfig.h"
+#include "dmxcursor.h"
+
+#include "lnx-keyboard.h"
+#include "lnx-ms.h"
+#include "lnx-ps2.h"
+#include "usb-keyboard.h"
+#include "usb-mouse.h"
+#include "usb-other.h"
+#include "usb-common.h"
+
+#include "dmxsigio.h"
+#include "dmxarg.h"
+
+#include "inputstr.h"
+#include "input.h"
+#include "mipointer.h"
+#include "windowstr.h"
+
+#ifdef XINPUT
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "exevents.h"
+#define EXTENSION_PROC_ARGS void *
+#include "extinit.h"
+#endif
+
+/* From XI.h */
+#ifndef Relative
+#define Relative 0
+#endif
+#ifndef Absolute
+#define Absolute 1
+#endif
+
+DMXLocalInputInfoPtr dmxLocalCorePointer, dmxLocalCoreKeyboard;
+
+static DMXLocalInputInfoRec DMXDummyMou = {
+ "dummy-mou", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_LOCAL, 1,
+ NULL, NULL, NULL, NULL, NULL, dmxDummyMouGetInfo
+};
+
+static DMXLocalInputInfoRec DMXDummyKbd = {
+ "dummy-kbd", DMX_LOCAL_KEYBOARD, DMX_LOCAL_TYPE_LOCAL, 1,
+ NULL, NULL, NULL, NULL, NULL, dmxDummyKbdGetInfo
+};
+
+static DMXLocalInputInfoRec DMXBackendMou = {
+ "backend-mou", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_BACKEND, 2,
+ dmxBackendCreatePrivate, dmxBackendDestroyPrivate,
+ dmxBackendInit, NULL, dmxBackendLateReInit, dmxBackendMouGetInfo,
+ dmxCommonMouOn, dmxCommonMouOff, dmxBackendUpdatePosition,
+ NULL, NULL, NULL,
+ dmxBackendCollectEvents, dmxBackendProcessInput, dmxBackendFunctions, NULL,
+ dmxCommonMouCtrl
+};
+
+static DMXLocalInputInfoRec DMXBackendKbd = {
+ "backend-kbd", DMX_LOCAL_KEYBOARD, DMX_LOCAL_TYPE_BACKEND,
+ 1, /* With backend-mou or console-mou */
+ dmxCommonCopyPrivate, NULL,
+ dmxBackendInit, NULL, NULL, dmxBackendKbdGetInfo,
+ dmxCommonKbdOn, dmxCommonKbdOff, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, dmxCommonKbdCtrl, dmxCommonKbdBell
+};
+
+static DMXLocalInputInfoRec DMXConsoleMou = {
+ "console-mou", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_CONSOLE, 2,
+ dmxConsoleCreatePrivate, dmxConsoleDestroyPrivate,
+ dmxConsoleInit, dmxConsoleReInit, NULL, dmxConsoleMouGetInfo,
+ dmxCommonMouOn, dmxCommonMouOff, dmxConsoleUpdatePosition,
+ NULL, NULL, NULL,
+ dmxConsoleCollectEvents, NULL, dmxConsoleFunctions, dmxConsoleUpdateInfo,
+ dmxCommonMouCtrl
+};
+
+static DMXLocalInputInfoRec DMXConsoleKbd = {
+ "console-kbd", DMX_LOCAL_KEYBOARD, DMX_LOCAL_TYPE_CONSOLE,
+ 1, /* With backend-mou or console-mou */
+ dmxCommonCopyPrivate, NULL,
+ dmxConsoleInit, dmxConsoleReInit, NULL, dmxConsoleKbdGetInfo,
+ dmxCommonKbdOn, dmxCommonKbdOff, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, dmxCommonKbdCtrl, dmxCommonKbdBell
+};
+
+static DMXLocalInputInfoRec DMXCommonOth = {
+ "common-oth", DMX_LOCAL_OTHER, DMX_LOCAL_TYPE_COMMON, 1,
+ dmxCommonCopyPrivate, NULL,
+ NULL, NULL, NULL, dmxCommonOthGetInfo,
+ dmxCommonOthOn, dmxCommonOthOff
+};
+
+
+static DMXLocalInputInfoRec DMXLocalDevices[] = {
+ /* Dummy drivers that can compile on any OS */
+#ifdef __linux__
+ /* Linux-specific drivers */
+ {
+ "kbd", DMX_LOCAL_KEYBOARD, DMX_LOCAL_TYPE_LOCAL, 1,
+ kbdLinuxCreatePrivate, kbdLinuxDestroyPrivate,
+ kbdLinuxInit, NULL, NULL, kbdLinuxGetInfo,
+ kbdLinuxOn, kbdLinuxOff, NULL,
+ kbdLinuxVTPreSwitch, kbdLinuxVTPostSwitch, kbdLinuxVTSwitch,
+ kbdLinuxRead, NULL, NULL, NULL,
+ NULL, kbdLinuxCtrl, kbdLinuxBell
+ },
+ {
+ "ms", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_LOCAL, 1,
+ msLinuxCreatePrivate, msLinuxDestroyPrivate,
+ msLinuxInit, NULL, NULL, msLinuxGetInfo,
+ msLinuxOn, msLinuxOff, NULL,
+ msLinuxVTPreSwitch, msLinuxVTPostSwitch, NULL,
+ msLinuxRead
+ },
+ {
+ "ps2", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_LOCAL, 1,
+ ps2LinuxCreatePrivate, ps2LinuxDestroyPrivate,
+ ps2LinuxInit, NULL, NULL, ps2LinuxGetInfo,
+ ps2LinuxOn, ps2LinuxOff, NULL,
+ ps2LinuxVTPreSwitch, ps2LinuxVTPostSwitch, NULL,
+ ps2LinuxRead
+ },
+#endif
+#ifdef __linux__
+ /* USB drivers, currently only for
+ Linux, but relatively easy to port to
+ other OSs */
+ {
+ "usb-kbd", DMX_LOCAL_KEYBOARD, DMX_LOCAL_TYPE_LOCAL, 1,
+ usbCreatePrivate, usbDestroyPrivate,
+ kbdUSBInit, NULL, NULL, kbdUSBGetInfo,
+ kbdUSBOn, usbOff, NULL,
+ NULL, NULL, NULL,
+ kbdUSBRead, NULL, NULL, NULL,
+ NULL, kbdUSBCtrl
+ },
+ {
+ "usb-mou", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_LOCAL, 1,
+ usbCreatePrivate, usbDestroyPrivate,
+ mouUSBInit, NULL, NULL, mouUSBGetInfo,
+ mouUSBOn, usbOff, NULL,
+ NULL, NULL, NULL,
+ mouUSBRead
+ },
+ {
+ "usb-oth", DMX_LOCAL_OTHER, DMX_LOCAL_TYPE_LOCAL, 1,
+ usbCreatePrivate, usbDestroyPrivate,
+ othUSBInit, NULL, NULL, othUSBGetInfo,
+ othUSBOn, usbOff, NULL,
+ NULL, NULL, NULL,
+ othUSBRead
+ },
+#endif
+ {
+ "dummy-mou", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_LOCAL, 1,
+ NULL, NULL, NULL, NULL, NULL, dmxDummyMouGetInfo
+ },
+ {
+ "dummy-kbd", DMX_LOCAL_KEYBOARD, DMX_LOCAL_TYPE_LOCAL, 1,
+ NULL, NULL, NULL, NULL, NULL, dmxDummyKbdGetInfo
+ },
+ { NULL } /* Must be last */
+};
+
+static void _dmxChangePointerControl(DMXLocalInputInfoPtr dmxLocal,
+ PtrCtrl *ctrl)
+{
+ if (!dmxLocal) return;
+ dmxLocal->mctrl = *ctrl;
+ if (dmxLocal->mCtrl) dmxLocal->mCtrl(&dmxLocal->pDevice->public, ctrl);
+}
+
+/** Change the pointer control information for the \a pDevice. If the
+ * device sends core events, then also change the control information
+ * for all of the pointer devices that send core events. */
+void dmxChangePointerControl(DeviceIntPtr pDevice, PtrCtrl *ctrl)
+{
+ GETDMXLOCALFROMPDEVICE;
+ int i, j;
+
+ if (dmxLocal->sendsCore) { /* Do for all core devices */
+ for (i = 0; i < dmxNumInputs; i++) {
+ DMXInputInfo *dmxInput = &dmxInputs[i];
+ if (dmxInput->detached) continue;
+ for (j = 0; j < dmxInput->numDevs; j++)
+ if (dmxInput->devs[j]->sendsCore)
+ _dmxChangePointerControl(dmxInput->devs[j], ctrl);
+ }
+ } else { /* Do for this device only */
+ _dmxChangePointerControl(dmxLocal, ctrl);
+ }
+}
+
+static void _dmxKeyboardKbdCtrlProc(DMXLocalInputInfoPtr dmxLocal,
+ KeybdCtrl *ctrl)
+{
+ dmxLocal->kctrl = *ctrl;
+ if (dmxLocal->kCtrl) {
+ dmxLocal->kCtrl(&dmxLocal->pDevice->public, ctrl);
+#ifdef XKB
+ if (!noXkbExtension && dmxLocal->pDevice->kbdfeed) {
+ XkbEventCauseRec cause;
+ XkbSetCauseUnknown(&cause);
+ /* Generate XKB events, as necessary */
+ XkbUpdateIndicators(dmxLocal->pDevice, XkbAllIndicatorsMask, False,
+ NULL, &cause);
+ }
+#endif
+ }
+}
+
+
+/** Change the keyboard control information for the \a pDevice. If the
+ * device sends core events, then also change the control information
+ * for all of the keyboard devices that send core events. */
+void dmxKeyboardKbdCtrlProc(DeviceIntPtr pDevice, KeybdCtrl *ctrl)
+{
+ GETDMXLOCALFROMPDEVICE;
+ int i, j;
+
+ if (dmxLocal->sendsCore) { /* Do for all core devices */
+ for (i = 0; i < dmxNumInputs; i++) {
+ DMXInputInfo *dmxInput = &dmxInputs[i];
+ if (dmxInput->detached) continue;
+ for (j = 0; j < dmxInput->numDevs; j++)
+ if (dmxInput->devs[j]->sendsCore)
+ _dmxKeyboardKbdCtrlProc(dmxInput->devs[j], ctrl);
+ }
+ } else { /* Do for this device only */
+ _dmxKeyboardKbdCtrlProc(dmxLocal, ctrl);
+ }
+}
+
+static void _dmxKeyboardBellProc(DMXLocalInputInfoPtr dmxLocal, int percent)
+{
+ if (dmxLocal->kBell) dmxLocal->kBell(&dmxLocal->pDevice->public,
+ percent,
+ dmxLocal->kctrl.bell,
+ dmxLocal->kctrl.bell_pitch,
+ dmxLocal->kctrl.bell_duration);
+}
+
+/** Sound the bell on the device. If the device send core events, then
+ * sound the bell on all of the devices that send core events. */
+void dmxKeyboardBellProc(int percent, DeviceIntPtr pDevice,
+ pointer ctrl, int unknown)
+{
+ GETDMXLOCALFROMPDEVICE;
+ int i, j;
+
+ if (dmxLocal->sendsCore) { /* Do for all core devices */
+ for (i = 0; i < dmxNumInputs; i++) {
+ DMXInputInfo *dmxInput = &dmxInputs[i];
+ if (dmxInput->detached) continue;
+ for (j = 0; j < dmxInput->numDevs; j++)
+ if (dmxInput->devs[j]->sendsCore)
+ _dmxKeyboardBellProc(dmxInput->devs[j], percent);
+ }
+ } else { /* Do for this device only */
+ _dmxKeyboardBellProc(dmxLocal, percent);
+ }
+}
+
+#ifdef XKB
+static void dmxKeyboardFreeNames(XkbComponentNamesPtr names)
+{
+ if (names->keymap) XFree(names->keymap);
+ if (names->keycodes) XFree(names->keycodes);
+ if (names->types) XFree(names->types);
+ if (names->compat) XFree(names->compat);
+ if (names->symbols) XFree(names->symbols);
+ if (names->geometry) XFree(names->geometry);
+}
+#endif
+
+
+static int dmxKeyboardOn(DeviceIntPtr pDevice, DMXLocalInitInfo *info)
+{
+#ifdef XKB
+ GETDMXINPUTFROMPDEVICE;
+#else
+ DevicePtr pDev = &pDevice->public;
+#endif
+
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ if (!InitKeyboardDeviceStruct(pDev, &info->keySyms, info->modMap,
+ dmxKeyboardBellProc,
+ dmxKeyboardKbdCtrlProc))
+ return BadImplementation;
+#ifdef XKB
+ } else {
+ XkbSetRulesDflts(dmxConfigGetXkbRules(),
+ dmxConfigGetXkbModel(),
+ dmxConfigGetXkbLayout(),
+ dmxConfigGetXkbVariant(),
+ dmxConfigGetXkbOptions());
+ if (XkbInitialMap) { /* Set with -xkbmap */
+ dmxLogInput(dmxInput,
+ "XKEYBOARD: From command line: %s\n", XkbInitialMap);
+ if ((info->names.keymap = strchr(XkbInitialMap, '/')))
+ ++info->names.keymap;
+ else
+ info->names.keymap = XkbInitialMap;
+ info->names.keycodes = NULL;
+ info->names.types = NULL;
+ info->names.compat = NULL;
+ info->names.symbols = NULL;
+ info->names.geometry = NULL;
+ } else {
+ if (!info->force && (dmxInput->keycodes
+ || dmxInput->symbols
+ || dmxInput->geometry)) {
+ if (info->freenames) dmxKeyboardFreeNames(&info->names);
+ info->freenames = 0;
+ info->names.keycodes = dmxInput->keycodes;
+ info->names.types = NULL;
+ info->names.compat = NULL;
+ info->names.symbols = dmxInput->symbols;
+ info->names.geometry = dmxInput->geometry;
+
+ dmxLogInput(dmxInput, "XKEYBOARD: From command line: %s",
+ info->names.keycodes);
+ if (info->names.symbols && *info->names.symbols)
+ dmxLogInputCont(dmxInput, " %s", info->names.symbols);
+ if (info->names.geometry && *info->names.geometry)
+ dmxLogInputCont(dmxInput, " %s", info->names.geometry);
+ dmxLogInputCont(dmxInput, "\n");
+ } else if (info->names.keycodes) {
+ dmxLogInput(dmxInput, "XKEYBOARD: From device: %s",
+ info->names.keycodes);
+ if (info->names.symbols && *info->names.symbols)
+ dmxLogInputCont(dmxInput, " %s", info->names.symbols);
+ if (info->names.geometry && *info->names.geometry)
+ dmxLogInputCont(dmxInput, " %s", info->names.geometry);
+ dmxLogInputCont(dmxInput, "\n");
+ } else {
+ dmxLogInput(dmxInput, "XKEYBOARD: Defaults: %s %s %s %s %s\n",
+ dmxConfigGetXkbRules(),
+ dmxConfigGetXkbLayout(),
+ dmxConfigGetXkbModel(),
+ dmxConfigGetXkbVariant()
+ ? dmxConfigGetXkbVariant() : "",
+ dmxConfigGetXkbOptions()
+ ? dmxConfigGetXkbOptions() : "");
+ }
+ }
+ XkbInitKeyboardDeviceStruct(pDevice,
+ &info->names,
+ &info->keySyms,
+ info->modMap,
+ dmxKeyboardBellProc,
+ dmxKeyboardKbdCtrlProc);
+ }
+ if (info->freenames) dmxKeyboardFreeNames(&info->names);
+#endif
+
+ return Success;
+}
+
+
+static int dmxDeviceOnOff(DeviceIntPtr pDevice, int what)
+{
+ GETDMXINPUTFROMPDEVICE;
+ int fd;
+ DMXLocalInitInfo info;
+#ifdef XINPUT
+ int i;
+#endif
+
+ if (!dmxLocal) return BadImplementation;
+ if (dmxInput->detached) return Success;
+
+ memset(&info, 0, sizeof(info));
+ switch (what) {
+ case DEVICE_INIT:
+ if (dmxLocal->init) dmxLocal->init(pDev);
+ if (dmxLocal->get_info) dmxLocal->get_info(pDev, &info);
+ if (info.keyboard) { /* XKEYBOARD makes this a special case */
+ dmxKeyboardOn(pDevice, &info);
+ break;
+ }
+ if (info.keyClass) {
+ InitKeyClassDeviceStruct(pDevice, &info.keySyms, info.modMap);
+ }
+ if (info.buttonClass) {
+ InitButtonClassDeviceStruct(pDevice, info.numButtons, info.map);
+ }
+ if (info.valuatorClass) {
+ if (info.numRelAxes && dmxLocal->sendsCore) {
+ InitValuatorClassDeviceStruct(pDevice, info.numRelAxes,
+ miPointerGetMotionEvents,
+ miPointerGetMotionBufferSize(),
+ Relative);
+#ifdef XINPUT
+ for (i = 0; i < info.numRelAxes; i++)
+ InitValuatorAxisStruct(pDevice, i, info.minval[0],
+ info.maxval[0], info.res[0],
+ info.minres[0], info.maxres[0]);
+#endif
+ } else if (info.numRelAxes) {
+ InitValuatorClassDeviceStruct(pDevice, info.numRelAxes,
+ dmxPointerGetMotionEvents,
+ dmxPointerGetMotionBufferSize(),
+ Relative);
+#ifdef XINPUT
+ for (i = 0; i < info.numRelAxes; i++)
+ InitValuatorAxisStruct(pDevice, i, info.minval[0],
+ info.maxval[0], info.res[0],
+ info.minres[0], info.maxres[0]);
+#endif
+ } else if (info.numAbsAxes) {
+ InitValuatorClassDeviceStruct(pDevice, info.numAbsAxes,
+ dmxPointerGetMotionEvents,
+ dmxPointerGetMotionBufferSize(),
+ Absolute);
+#ifdef XINPUT
+ for (i = 0; i < info.numAbsAxes; i++)
+ InitValuatorAxisStruct(pDevice, i+info.numRelAxes,
+ info.minval[i+1], info.maxval[i+1],
+ info.res[i+1], info.minres[i+1],
+ info.maxres[i+1]);
+#endif
+ }
+ }
+ if (info.focusClass) InitFocusClassDeviceStruct(pDevice);
+#ifdef XINPUT
+ if (info.proximityClass) InitProximityClassDeviceStruct(pDevice);
+#endif
+ if (info.ptrFeedbackClass)
+ InitPtrFeedbackClassDeviceStruct(pDevice, dmxChangePointerControl);
+ if (info.kbdFeedbackClass)
+ InitKbdFeedbackClassDeviceStruct(pDevice, dmxKeyboardBellProc,
+ dmxKeyboardKbdCtrlProc);
+ if (info.intFeedbackClass || info.strFeedbackClass)
+ dmxLog(dmxWarning,
+ "Integer and string feedback not supported for %s\n",
+ pDevice->name);
+ if (!info.keyboard && (info.ledFeedbackClass || info.belFeedbackClass))
+ dmxLog(dmxWarning,
+ "Led and bel feedback not supported for non-keyboard %s\n",
+ pDevice->name);
+ break;
+ case DEVICE_ON:
+ if (!pDev->on) {
+ if (dmxLocal->on && (fd = dmxLocal->on(pDev)) >= 0)
+ dmxSigioRegister(dmxInput, fd);
+ pDev->on = TRUE;
+ }
+ break;
+ case DEVICE_OFF:
+ case DEVICE_CLOSE:
+ /* This can get called twice consecutively: once for a
+ * detached screen (DEVICE_OFF), and then again at server
+ * generation time (DEVICE_CLOSE). */
+ if (pDev->on) {
+ dmxSigioUnregister(dmxInput);
+ if (dmxLocal->off) dmxLocal->off(pDev);
+ pDev->on = FALSE;
+ }
+ break;
+ }
+ if (info.keySyms.map && info.freemap) {
+ XFree(info.keySyms.map);
+ info.keySyms.map = NULL;
+ }
+#ifdef XKB
+ if (info.xkb) XkbFreeKeyboard(info.xkb, 0, True);
+#endif
+ return Success;
+}
+
+static void dmxProcessInputEvents(DMXInputInfo *dmxInput)
+{
+ int i;
+
+ dmxeqProcessInputEvents();
+ miPointerUpdate();
+ if (dmxInput->detached) return;
+ for (i = 0; i < dmxInput->numDevs; i += dmxInput->devs[i]->binding)
+ if (dmxInput->devs[i]->process_input)
+ dmxInput->devs[i]->process_input(dmxInput->devs[i]->private);
+}
+
+static void dmxUpdateWindowInformation(DMXInputInfo *dmxInput,
+ DMXUpdateType type,
+ WindowPtr pWindow)
+{
+ int i;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension && pWindow && pWindow->parent != WindowTable[0])
+ return;
+#endif
+#if DMX_WINDOW_DEBUG
+ {
+ const char *name = "Unknown";
+ switch (type) {
+ case DMX_UPDATE_REALIZE: name = "Realize"; break;
+ case DMX_UPDATE_UNREALIZE: name = "Unrealize"; break;
+ case DMX_UPDATE_RESTACK: name = "Restack"; break;
+ case DMX_UPDATE_COPY: name = "Copy"; break;
+ case DMX_UPDATE_RESIZE: name = "Resize"; break;
+ case DMX_UPDATE_REPARENT: name = "Repaint"; break;
+ }
+ dmxLog(dmxDebug, "Window %p changed: %s\n", pWindow, name);
+ }
+#endif
+
+ if (dmxInput->detached) return;
+ for (i = 0; i < dmxInput->numDevs; i += dmxInput->devs[i]->binding)
+ if (dmxInput->devs[i]->update_info)
+ dmxInput->devs[i]->update_info(dmxInput->devs[i]->private,
+ type, pWindow);
+}
+
+static void dmxCollectAll(DMXInputInfo *dmxInput)
+{
+ int i;
+
+ if (dmxInput->detached) return;
+ for (i = 0; i < dmxInput->numDevs; i += dmxInput->devs[i]->binding)
+ if (dmxInput->devs[i]->collect_events)
+ dmxInput->devs[i]->collect_events(&dmxInput->devs[i]
+ ->pDevice->public,
+ dmxMotion,
+ dmxEnqueue,
+ dmxCheckSpecialKeys, DMX_BLOCK);
+}
+
+static void dmxBlockHandler(pointer blockData, OSTimePtr pTimeout,
+ pointer pReadMask)
+{
+ DMXInputInfo *dmxInput = &dmxInputs[(int)blockData];
+ static unsigned long generation = 0;
+
+ if (generation != serverGeneration) {
+ generation = serverGeneration;
+ dmxCollectAll(dmxInput);
+ }
+}
+
+static void dmxSwitchReturn(pointer p)
+{
+ DMXInputInfo *dmxInput = p;
+ int i;
+
+ dmxLog(dmxInfo, "Returning from VT %d\n", dmxInput->vt_switched);
+
+ if (!dmxInput->vt_switched)
+ dmxLog(dmxFatal, "dmxSwitchReturn called, but not switched\n");
+ dmxSigioEnableInput();
+ for (i = 0; i < dmxInput->numDevs; i++)
+ if (dmxInput->devs[i]->vt_post_switch)
+ dmxInput->devs[i]->vt_post_switch(dmxInput->devs[i]->private);
+ dmxInput->vt_switched = 0;
+}
+
+static void dmxWakeupHandler(pointer blockData, int result, pointer pReadMask)
+{
+ DMXInputInfo *dmxInput = &dmxInputs[(int)blockData];
+ int i;
+
+ if (dmxInput->vt_switch_pending) {
+ dmxLog(dmxInfo, "Switching to VT %d\n", dmxInput->vt_switch_pending);
+ for (i = 0; i < dmxInput->numDevs; i++)
+ if (dmxInput->devs[i]->vt_pre_switch)
+ dmxInput->devs[i]->vt_pre_switch(dmxInput->devs[i]->private);
+ dmxInput->vt_switched = dmxInput->vt_switch_pending;
+ dmxInput->vt_switch_pending = 0;
+ for (i = 0; i < dmxInput->numDevs; i++) {
+ if (dmxInput->devs[i]->vt_switch) {
+ dmxSigioDisableInput();
+ if (!dmxInput->devs[i]->vt_switch(dmxInput->devs[i]->private,
+ dmxInput->vt_switched,
+ dmxSwitchReturn,
+ dmxInput))
+ dmxSwitchReturn(dmxInput);
+ break; /* Only call one vt_switch routine */
+ }
+ }
+ }
+ dmxCollectAll(dmxInput);
+}
+
+static char *dmxMakeUniqueDeviceName(DMXLocalInputInfoPtr dmxLocal)
+{
+ static int k = 0;
+ static int m = 0;
+ static int o = 0;
+ static unsigned long dmxGeneration = 0;
+#define LEN 32
+ char * buf = xalloc(LEN);
+
+ if (dmxGeneration != serverGeneration) {
+ k = m = o = 0;
+ dmxGeneration = serverGeneration;
+ }
+
+ switch (dmxLocal->type) {
+ case DMX_LOCAL_KEYBOARD: XmuSnprintf(buf, LEN, "Keyboard%d", k++); break;
+ case DMX_LOCAL_MOUSE: XmuSnprintf(buf, LEN, "Mouse%d", m++); break;
+ default: XmuSnprintf(buf, LEN, "Other%d", o++); break;
+ }
+
+ return buf;
+}
+
+static DeviceIntPtr dmxAddDevice(DMXLocalInputInfoPtr dmxLocal)
+{
+ DeviceIntPtr pDevice;
+ Atom atom;
+ const char *name = NULL;
+ void (*registerProcPtr)(DeviceIntPtr) = NULL;
+ char *devname;
+ DMXInputInfo *dmxInput;
+
+ if (!dmxLocal) return NULL;
+ dmxInput = &dmxInputs[dmxLocal->inputIdx];
+
+ if (dmxLocal->sendsCore) {
+ if (dmxLocal->type == DMX_LOCAL_KEYBOARD && !dmxLocalCoreKeyboard) {
+ dmxLocal->isCore = 1;
+ dmxLocalCoreKeyboard = dmxLocal;
+ name = "keyboard";
+ registerProcPtr = _RegisterKeyboardDevice;
+ }
+ if (dmxLocal->type == DMX_LOCAL_MOUSE && !dmxLocalCorePointer) {
+ dmxLocal->isCore = 1;
+ dmxLocalCorePointer = dmxLocal;
+ name = "pointer";
+ registerProcPtr = _RegisterPointerDevice;
+ }
+ }
+
+#ifdef XINPUT
+ if (!name) {
+ name = "extension";
+ registerProcPtr = RegisterOtherDevice;
+ }
+#else
+ if (!name)
+ dmxLog(dmxFatal,
+ "Server not build with XINPUT support (cannot add %s)\n",
+ dmxLocal->name);
+#endif
+
+ if (!name || !registerProcPtr)
+ dmxLog(dmxFatal, "Cannot add device %s\n", dmxLocal->name);
+
+ pDevice = AddInputDevice(dmxDeviceOnOff, TRUE);
+ if (!pDevice) {
+ dmxLog(dmxError, "Too many devices -- cannot add device %s\n",
+ dmxLocal->name);
+ return NULL;
+ }
+ pDevice->public.devicePrivate = dmxLocal;
+ dmxLocal->pDevice = pDevice;
+
+ devname = dmxMakeUniqueDeviceName(dmxLocal);
+ atom = MakeAtom((char *)devname, strlen(devname), TRUE);
+ pDevice->type = atom;
+ pDevice->name = devname;
+
+ registerProcPtr(pDevice);
+
+ if (dmxLocal->isCore && dmxLocal->type == DMX_LOCAL_MOUSE)
+ miRegisterPointerDevice(screenInfo.screens[0], pDevice);
+
+ if (dmxLocal->create_private)
+ dmxLocal->private = dmxLocal->create_private(pDevice);
+
+ dmxLogInput(dmxInput, "Added %s as %s device called %s%s\n",
+ dmxLocal->name, name, devname,
+ dmxLocal->isCore
+ ? " [core]"
+ : (dmxLocal->sendsCore
+ ? " [sends core events]"
+ : ""));
+
+ return pDevice;
+}
+
+static DMXLocalInputInfoPtr dmxLookupLocal(const char *name)
+{
+ DMXLocalInputInfoPtr pt;
+
+ for (pt = &DMXLocalDevices[0]; pt->name; ++pt)
+ if (!strcmp(pt->name, name)) return pt; /* search for device name */
+ return NULL;
+}
+
+/** Copy the local input information from \a s into a new \a devs slot
+ * in \a dmxInput. */
+DMXLocalInputInfoPtr dmxInputCopyLocal(DMXInputInfo *dmxInput,
+ DMXLocalInputInfoPtr s)
+{
+ DMXLocalInputInfoPtr dmxLocal = xalloc(sizeof(*dmxLocal));
+
+ if (!dmxLocal)
+ dmxLog(dmxFatal, "DMXLocalInputInfoPtr: out of memory\n");
+
+ memcpy(dmxLocal, s, sizeof(*dmxLocal));
+ dmxLocal->inputIdx = dmxInput->inputIdx;
+ dmxLocal->sendsCore = dmxInput->core;
+ dmxLocal->savedSendsCore = dmxInput->core;
+ dmxLocal->deviceId = -1;
+
+ ++dmxInput->numDevs;
+ dmxInput->devs = xrealloc(dmxInput->devs,
+ dmxInput->numDevs * sizeof(*dmxInput->devs));
+ dmxInput->devs[dmxInput->numDevs-1] = dmxLocal;
+
+ return dmxLocal;
+}
+
+static void dmxPopulateLocal(DMXInputInfo *dmxInput, dmxArg a)
+{
+ int i;
+ int help = 0;
+ DMXLocalInputInfoRec *pt;
+
+ for (i = 1; i < dmxArgC(a); i++) {
+ const char *name = dmxArgV(a, i);
+ if ((pt = dmxLookupLocal(name))) {
+ dmxInputCopyLocal(dmxInput, pt);
+ } else {
+ if (strlen(name))
+ dmxLog(dmxWarning,
+ "Could not find a driver called %s\n", name);
+ ++help;
+ }
+ }
+ if (help) {
+ dmxLog(dmxInfo, "Available local device drivers:\n");
+ for (pt = &DMXLocalDevices[0]; pt->name; ++pt) {
+ const char *type;
+ switch (pt->type) {
+ case DMX_LOCAL_KEYBOARD: type = "keyboard"; break;
+ case DMX_LOCAL_MOUSE: type = "pointer"; break;
+ default: type = "unknown"; break;
+ }
+ dmxLog(dmxInfo, " %s (%s)\n", pt->name, type);
+ }
+ dmxLog(dmxFatal, "Must have valid local device driver\n");
+ }
+}
+
+int dmxInputExtensionErrorHandler(Display *dsp, char *name, char *reason)
+{
+ return 0;
+}
+
+static void dmxInputScanForExtensions(DMXInputInfo *dmxInput, int doXI)
+{
+ XExtensionVersion *ext;
+ XDeviceInfo *devices;
+ Display *display;
+ int num;
+ int i, j;
+ DMXLocalInputInfoPtr dmxLocal;
+ int (*handler)(Display *, char *, char *);
+
+ if (!(display = XOpenDisplay(dmxInput->name))) return;
+
+ /* Print out information about the XInput Extension. */
+ handler = XSetExtensionErrorHandler(dmxInputExtensionErrorHandler);
+ ext = XGetExtensionVersion(display, INAME);
+ XSetExtensionErrorHandler(handler);
+
+ if (!ext || ext == (XExtensionVersion *)NoSuchExtension) {
+ dmxLogInput(dmxInput, "%s is not available\n", INAME);
+ } else {
+ dmxLogInput(dmxInput, "Locating devices on %s (%s version %d.%d)\n",
+ dmxInput->name, INAME,
+ ext->major_version, ext->minor_version);
+ devices = XListInputDevices(display, &num);
+
+ XFree(ext);
+ ext = NULL;
+
+ /* Print a list of all devices */
+ for (i = 0; i < num; i++) {
+ const char *use = "Unknown";
+ switch (devices[i].use) {
+ case IsXPointer: use = "XPointer"; break;
+ case IsXKeyboard: use = "XKeyboard"; break;
+ case IsXExtensionDevice: use = "XExtensionDevice"; break;
+ }
+ dmxLogInput(dmxInput, " %2d %-10.10s %-16.16s\n",
+ devices[i].id,
+ devices[i].name ? devices[i].name : "",
+ use);
+ }
+
+ /* Search for extensions */
+ for (i = 0; i < num; i++) {
+ switch (devices[i].use) {
+ case IsXKeyboard:
+ for (j = 0; j < dmxInput->numDevs; j++) {
+ DMXLocalInputInfoPtr dmxL = dmxInput->devs[j];
+ if (dmxL->type == DMX_LOCAL_KEYBOARD
+ && dmxL->deviceId < 0) {
+ dmxL->deviceId = devices[i].id;
+ dmxL->deviceName = (devices[i].name
+ ? xstrdup(devices[i].name)
+ : NULL);
+ }
+ }
+ break;
+ case IsXPointer:
+ for (j = 0; j < dmxInput->numDevs; j++) {
+ DMXLocalInputInfoPtr dmxL = dmxInput->devs[j];
+ if (dmxL->type == DMX_LOCAL_MOUSE && dmxL->deviceId < 0) {
+ dmxL->deviceId = devices[i].id;
+ dmxL->deviceName = (devices[i].name
+ ? xstrdup(devices[i].name)
+ : NULL);
+ }
+ }
+ break;
+ case IsXExtensionDevice:
+ if (doXI) {
+ if (!dmxInput->numDevs) {
+ dmxLog(dmxWarning,
+ "Cannot use remote (%s) XInput devices if"
+ " not also using core devices\n",
+ dmxInput->name);
+ } else {
+ dmxLocal = dmxInputCopyLocal(dmxInput,
+ &DMXCommonOth);
+ dmxLocal->isCore = FALSE;
+ dmxLocal->sendsCore = FALSE;
+ dmxLocal->deviceId = devices[i].id;
+ dmxLocal->deviceName = (devices[i].name
+ ? xstrdup(devices[i].name)
+ : NULL);
+ }
+ }
+ break;
+ }
+ }
+ XFreeDeviceList(devices);
+ }
+ XCloseDisplay(display);
+}
+
+/** Re-initialize all the devices described in \a dmxInput. Called from
+ #dmxReconfig before the cursor is redisplayed. */
+void dmxInputReInit(DMXInputInfo *dmxInput)
+{
+ int i;
+
+ for (i = 0; i < dmxInput->numDevs; i++) {
+ DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[i];
+ if (dmxLocal->reinit)
+ dmxLocal->reinit(&dmxLocal->pDevice->public);
+ }
+}
+
+/** Re-initialize all the devices described in \a dmxInput. Called from
+ #dmxReconfig after the cursor is redisplayed. */
+void dmxInputLateReInit(DMXInputInfo *dmxInput)
+{
+ int i;
+
+ for (i = 0; i < dmxInput->numDevs; i++) {
+ DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[i];
+ if (dmxLocal->latereinit)
+ dmxLocal->latereinit(&dmxLocal->pDevice->public);
+ }
+}
+
+/** Initialize all of the devices described in \a dmxInput. */
+void dmxInputInit(DMXInputInfo *dmxInput)
+{
+ DeviceIntPtr pPointer = NULL, pKeyboard = NULL;
+ dmxArg a;
+ const char *name;
+ int i;
+ int doXI = 1; /* Include by default */
+ int forceConsole = 0;
+ int doWindows = 1; /* On by default */
+ int hasXkb = 0;
+
+ a = dmxArgParse(dmxInput->name);
+
+ for (i = 1; i < dmxArgC(a); i++) {
+ switch (hasXkb) {
+ case 1:
+ dmxInput->keycodes = xstrdup(dmxArgV(a, i));
+ ++hasXkb;
+ break;
+ case 2:
+ dmxInput->symbols = xstrdup(dmxArgV(a, i));
+ ++hasXkb;
+ break;
+ case 3:
+ dmxInput->geometry = xstrdup(dmxArgV(a, i));
+ hasXkb = 0;
+ break;
+ case 0:
+ if (!strcmp(dmxArgV(a, i), "noxi")) doXI = 0;
+ else if (!strcmp(dmxArgV(a, i), "xi")) doXI = 1;
+ else if (!strcmp(dmxArgV(a, i), "console")) forceConsole = 1;
+ else if (!strcmp(dmxArgV(a, i), "noconsole")) forceConsole = 0;
+ else if (!strcmp(dmxArgV(a, i), "windows")) doWindows = 1;
+ else if (!strcmp(dmxArgV(a, i), "nowindows")) doWindows = 0;
+ else if (!strcmp(dmxArgV(a, i), "xkb")) hasXkb = 1;
+ else {
+ dmxLog(dmxFatal,
+ "Unknown input argument: %s\n", dmxArgV(a, i));
+ }
+ }
+ }
+
+ name = dmxArgV(a, 0);
+
+ if (!strcmp(name, "local")) {
+ dmxPopulateLocal(dmxInput, a);
+ } else if (!strcmp(name, "dummy")) {
+ dmxInputCopyLocal(dmxInput, &DMXDummyMou);
+ dmxInputCopyLocal(dmxInput, &DMXDummyKbd);
+ dmxLogInput(dmxInput, "Using dummy input\n");
+ } else {
+ int found;
+
+ for (found = 0, i = 0; i < dmxNumScreens; i++) {
+ if (dmxPropertySameDisplay(&dmxScreens[i], name)) {
+ if (dmxScreens[i].shared)
+ dmxLog(dmxFatal,
+ "Cannot take input from shared backend (%s)\n",
+ name);
+ if (!dmxInput->core) {
+ dmxLog(dmxWarning,
+ "Cannot use core devices on a backend (%s)"
+ " as XInput devices\n", name);
+ } else {
+ char *pt;
+ for (pt = (char *)dmxInput->name; pt && *pt; pt++)
+ if (*pt == ',') *pt = '\0';
+ dmxInputCopyLocal(dmxInput, &DMXBackendMou);
+ dmxInputCopyLocal(dmxInput, &DMXBackendKbd);
+ dmxInput->scrnIdx = i;
+ dmxLogInput(dmxInput,
+ "Using backend input from %s\n", name);
+ }
+ ++found;
+ break;
+ }
+ }
+ if (!found || forceConsole) {
+ char *pt;
+ if (found) dmxInput->console = TRUE;
+ for (pt = (char *)dmxInput->name; pt && *pt; pt++)
+ if (*pt == ',') *pt = '\0';
+ dmxInputCopyLocal(dmxInput, &DMXConsoleMou);
+ dmxInputCopyLocal(dmxInput, &DMXConsoleKbd);
+ if (doWindows) {
+ dmxInput->windows = TRUE;
+ dmxInput->updateWindowInfo = dmxUpdateWindowInformation;
+ }
+ dmxLogInput(dmxInput,
+ "Using console input from %s (%s windows)\n",
+ name, doWindows ? "with" : "without");
+ }
+ }
+
+ dmxArgFree(a);
+
+ /* Locate extensions we may be interested in */
+ dmxInputScanForExtensions(dmxInput, doXI);
+
+ for (i = 0; i < dmxInput->numDevs; i++) {
+ DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[i];
+#ifndef XINPUT
+ if (!dmxLocal->isCore)
+ dmxLog(dmxFatal,
+ "This server was not compiled to support the XInput"
+ " extension, but %s is not a core device.\n",
+ dmxLocal->name);
+#endif
+ dmxLocal->pDevice = dmxAddDevice(dmxLocal);
+ if (dmxLocal->isCore) {
+ if (dmxLocal->type == DMX_LOCAL_MOUSE)
+ pPointer = dmxLocal->pDevice;
+ if (dmxLocal->type == DMX_LOCAL_KEYBOARD)
+ pKeyboard = dmxLocal->pDevice;
+ }
+ }
+
+ if (pPointer && pKeyboard) {
+ if (dmxeqInit(&pKeyboard->public, &pPointer->public))
+ dmxLogInput(dmxInput, "Using %s and %s as true core devices\n",
+ pKeyboard->name, pPointer->name);
+ }
+
+ dmxInput->processInputEvents = dmxProcessInputEvents;
+ dmxInput->detached = False;
+
+ RegisterBlockAndWakeupHandlers(dmxBlockHandler,
+ dmxWakeupHandler,
+ (void *)dmxInput->inputIdx);
+}
+
+static void dmxInputFreeLocal(DMXLocalInputInfoRec *local)
+{
+ if (!local) return;
+ if (local->isCore && local->type == DMX_LOCAL_MOUSE)
+ dmxLocalCorePointer = NULL;
+ if (local->isCore && local->type == DMX_LOCAL_KEYBOARD)
+ dmxLocalCoreKeyboard = NULL;
+ if (local->destroy_private) local->destroy_private(local->private);
+ if (local->history) xfree(local->history);
+ if (local->valuators) xfree(local->valuators);
+ if (local->deviceName) xfree(local->deviceName);
+ local->private = NULL;
+ local->history = NULL;
+ local->deviceName = NULL;
+ xfree(local);
+}
+
+/** Free all of the memory associated with \a dmxInput */
+void dmxInputFree(DMXInputInfo *dmxInput)
+{
+ int i;
+
+ if (!dmxInput) return;
+
+ if (dmxInput->keycodes) xfree(dmxInput->keycodes);
+ if (dmxInput->symbols) xfree(dmxInput->symbols);
+ if (dmxInput->geometry) xfree(dmxInput->geometry);
+
+ for (i = 0; i < dmxInput->numDevs; i++) {
+ dmxInputFreeLocal(dmxInput->devs[i]);
+ dmxInput->devs[i] = NULL;
+ }
+ xfree(dmxInput->devs);
+ dmxInput->devs = NULL;
+ dmxInput->numDevs = 0;
+ if (dmxInput->freename) xfree(dmxInput->name);
+ dmxInput->name = NULL;
+}
+
+/** Log information about all of the known devices using #dmxLog(). */
+void dmxInputLogDevices(void)
+{
+ int i, j;
+
+ dmxLog(dmxInfo, "%d devices:\n", dmxGetInputCount());
+ dmxLog(dmxInfo, " Id Name Classes\n");
+ for (j = 0; j < dmxNumInputs; j++) {
+ DMXInputInfo *dmxInput = &dmxInputs[j];
+ const char *pt = strchr(dmxInput->name, ',');
+ int len = (pt
+ ? (size_t)(pt-dmxInput->name)
+ : strlen(dmxInput->name));
+
+ for (i = 0; i < dmxInput->numDevs; i++) {
+ DeviceIntPtr pDevice = dmxInput->devs[i]->pDevice;
+ if (pDevice) {
+ dmxLog(dmxInfo, " %2d%c %-20.20s",
+ pDevice->id,
+ dmxInput->detached ? 'D' : ' ',
+ pDevice->name);
+ if (pDevice->key) dmxLogCont(dmxInfo, " key");
+ if (pDevice->valuator) dmxLogCont(dmxInfo, " val");
+ if (pDevice->button) dmxLogCont(dmxInfo, " btn");
+ if (pDevice->focus) dmxLogCont(dmxInfo, " foc");
+ if (pDevice->kbdfeed) dmxLogCont(dmxInfo, " fb/kbd");
+ if (pDevice->ptrfeed) dmxLogCont(dmxInfo, " fb/ptr");
+ if (pDevice->intfeed) dmxLogCont(dmxInfo, " fb/int");
+ if (pDevice->stringfeed) dmxLogCont(dmxInfo, " fb/str");
+ if (pDevice->bell) dmxLogCont(dmxInfo, " fb/bel");
+ if (pDevice->leds) dmxLogCont(dmxInfo, " fb/led");
+ if (!pDevice->key && !pDevice->valuator && !pDevice->button
+ && !pDevice->focus && !pDevice->kbdfeed
+ && !pDevice->ptrfeed && !pDevice->intfeed
+ && !pDevice->stringfeed && !pDevice->bell
+ && !pDevice->leds) dmxLogCont(dmxInfo, " (none)");
+
+ dmxLogCont(dmxInfo, "\t[i%d/%*.*s",
+ dmxInput->inputIdx, len, len, dmxInput->name);
+ if (dmxInput->devs[i]->deviceId >= 0)
+ dmxLogCont(dmxInfo, "/id%d", dmxInput->devs[i]->deviceId);
+ if (dmxInput->devs[i]->deviceName)
+ dmxLogCont(dmxInfo, "=%s", dmxInput->devs[i]->deviceName);
+ dmxLogCont(dmxInfo, "] %s\n",
+ dmxInput->devs[i]->isCore
+ ? "core"
+ : (dmxInput->devs[i]->sendsCore
+ ? "extension (sends core events)"
+ : "extension"));
+ }
+ }
+ }
+}
+
+/** Detach an input */
+int dmxInputDetach(DMXInputInfo *dmxInput)
+{
+ int i;
+
+ if (dmxInput->detached) return BadAccess;
+
+ for (i = 0; i < dmxInput->numDevs; i++) {
+ DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[i];
+ dmxLogInput(dmxInput, "Detaching device id %d: %s%s\n",
+ dmxLocal->pDevice->id,
+ dmxLocal->pDevice->name,
+ dmxLocal->isCore
+ ? " [core]"
+ : (dmxLocal->sendsCore
+ ? " [sends core events]"
+ : ""));
+ DisableDevice(dmxLocal->pDevice);
+ }
+ dmxInput->detached = True;
+ dmxInputLogDevices();
+ return 0;
+}
+
+/** Search for input associated with \a dmxScreen, and detach. */
+void dmxInputDetachAll(DMXScreenInfo *dmxScreen)
+{
+ int i;
+
+ for (i = 0; i < dmxNumInputs; i++) {
+ DMXInputInfo *dmxInput = &dmxInputs[i];
+ if (dmxInput->scrnIdx == dmxScreen->index) dmxInputDetach(dmxInput);
+ }
+}
+
+/** Search for input associated with \a deviceId, and detach. */
+int dmxInputDetachId(int id)
+{
+ DMXInputInfo *dmxInput = dmxInputLocateId(id);
+
+ if (!dmxInput) return BadValue;
+
+ return dmxInputDetach(dmxInput);
+}
+
+DMXInputInfo *dmxInputLocateId(int id)
+{
+ int i, j;
+
+ for (i = 0; i < dmxNumInputs; i++) {
+ DMXInputInfo *dmxInput = &dmxInputs[i];
+ for (j = 0; j < dmxInput->numDevs; j++) {
+ DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[j];
+ if (dmxLocal->pDevice->id == id) return dmxInput;
+ }
+ }
+ return NULL;
+}
+
+static int dmxInputAttachNew(DMXInputInfo *dmxInput, int *id)
+{
+ dmxInputInit(dmxInput);
+ InitAndStartDevices();
+ if (id && dmxInput->devs) *id = dmxInput->devs[0]->pDevice->id;
+ dmxInputLogDevices();
+ return 0;
+}
+
+static int dmxInputAttachOld(DMXInputInfo *dmxInput, int *id)
+{
+ int i;
+
+ dmxInput->detached = False;
+ for (i = 0; i < dmxInput->numDevs; i++) {
+ DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[i];
+ if (id) *id = dmxLocal->pDevice->id;
+ dmxLogInput(dmxInput,
+ "Attaching device id %d: %s%s\n",
+ dmxLocal->pDevice->id,
+ dmxLocal->pDevice->name,
+ dmxLocal->isCore
+ ? " [core]"
+ : (dmxLocal->sendsCore
+ ? " [sends core events]"
+ : ""));
+ EnableDevice(dmxLocal->pDevice);
+ }
+ dmxInputLogDevices();
+ return 0;
+}
+
+int dmxInputAttachConsole(const char *name, int isCore, int *id)
+{
+ DMXInputInfo *dmxInput;
+ int i;
+
+ for (i = 0; i < dmxNumInputs; i++) {
+ dmxInput = &dmxInputs[i];
+ if (dmxInput->scrnIdx == -1
+ && dmxInput->detached
+ && !strcmp(dmxInput->name, name)) {
+ /* Found match */
+ dmxLogInput(dmxInput, "Reattaching detached console input\n");
+ return dmxInputAttachOld(dmxInput, id);
+ }
+ }
+
+ /* No match found */
+ dmxInput = dmxConfigAddInput(xstrdup(name), isCore);
+ dmxInput->freename = TRUE;
+ dmxLogInput(dmxInput, "Attaching new console input\n");
+ return dmxInputAttachNew(dmxInput, id);
+}
+
+int dmxInputAttachBackend(int physicalScreen, int isCore, int *id)
+{
+ DMXInputInfo *dmxInput;
+ DMXScreenInfo *dmxScreen;
+ int i;
+
+ if (physicalScreen < 0 || physicalScreen >= dmxNumScreens) return BadValue;
+ for (i = 0; i < dmxNumInputs; i++) {
+ dmxInput = &dmxInputs[i];
+ if (dmxInput->scrnIdx != -1 && dmxInput->scrnIdx == physicalScreen) {
+ /* Found match */
+ if (!dmxInput->detached) return BadAccess; /* Already attached */
+ dmxScreen = &dmxScreens[physicalScreen];
+ if (!dmxScreen->beDisplay) return BadAccess; /* Screen detached */
+ dmxLogInput(dmxInput, "Reattaching detached backend input\n");
+ return dmxInputAttachOld(dmxInput, id);
+ }
+ }
+ /* No match found */
+ dmxScreen = &dmxScreens[physicalScreen];
+ if (!dmxScreen->beDisplay) return BadAccess; /* Screen detached */
+ dmxInput = dmxConfigAddInput(dmxScreen->name, isCore);
+ dmxLogInput(dmxInput, "Attaching new backend input\n");
+ return dmxInputAttachNew(dmxInput, id);
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxinputinit.h b/nx-X11/programs/Xserver/hw/dmx/input/dmxinputinit.h
new file mode 100644
index 000000000..c593e267a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxinputinit.h
@@ -0,0 +1,294 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface for low-level input support. \see dmxinputinit.c */
+
+#ifndef _DMXINPUTINIT_H_
+#define _DMXINPUTINIT_H_
+
+#include "dmx.h"
+#include "dmxinput.h"
+#include "dmxlog.h"
+
+
+#define DMX_LOCAL_DEFAULT_KEYBOARD "kbd"
+#define DMX_LOCAL_DEFAULT_POINTER "ps2"
+#define DMX_MAX_BUTTONS 256
+#define DMX_MOTION_SIZE 256
+#define DMX_MAX_VALUATORS 32
+#define DMX_MAX_AXES 32
+#define DMX_MAX_XINPUT_EVENT_TYPES 100
+#define DMX_MAP_ENTRIES 16 /* Must be a power of 2 */
+#define DMX_MAP_MASK (DMX_MAP_ENTRIES - 1)
+
+typedef enum {
+ DMX_FUNCTION_GRAB,
+ DMX_FUNCTION_TERMINATE,
+ DMX_FUNCTION_FINE
+} DMXFunctionType;
+
+typedef enum {
+ DMX_LOCAL_HIGHLEVEL,
+ DMX_LOCAL_KEYBOARD,
+ DMX_LOCAL_MOUSE,
+ DMX_LOCAL_OTHER
+} DMXLocalInputType;
+
+typedef enum {
+ DMX_LOCAL_TYPE_LOCAL,
+ DMX_LOCAL_TYPE_CONSOLE,
+ DMX_LOCAL_TYPE_BACKEND,
+ DMX_LOCAL_TYPE_COMMON
+} DMXLocalInputExtType;
+
+typedef enum {
+ DMX_RELATIVE,
+ DMX_ABSOLUTE,
+ DMX_ABSOLUTE_CONFINED
+} DMXMotionType;
+
+/** Stores information from low-level device that is used to initialize
+ * the device at the dix level. */
+typedef struct _DMXLocalInitInfo {
+ int keyboard; /**< Non-zero if the device is a keyboard */
+
+ int keyClass; /**< Non-zero if keys are present */
+ KeySymsRec keySyms; /**< Key symbols */
+ int freemap; /**< If non-zero, free keySyms.map */
+ CARD8 modMap[MAP_LENGTH]; /**< Modifier map */
+#ifdef XKB
+ XkbDescPtr xkb; /**< XKB description */
+ XkbComponentNamesRec names; /**< XKB component names */
+ int freenames; /**< Non-zero if names should be free'd */
+ int force; /**< Do not allow command line override */
+#endif
+
+ int buttonClass; /**< Non-zero if buttons are present */
+ int numButtons; /**< Number of buttons */
+ unsigned char map[DMX_MAX_BUTTONS]; /**< Button map */
+
+ int valuatorClass; /**< Non-zero if valuators are
+ * present */
+ int numRelAxes; /**< Number of relative axes */
+ int numAbsAxes; /**< Number of absolute axes */
+ int minval[DMX_MAX_AXES]; /**< Minimum values */
+ int maxval[DMX_MAX_AXES]; /**< Maximum values */
+ int res[DMX_MAX_AXES]; /**< Resolution */
+ int minres[DMX_MAX_AXES]; /**< Minimum resolutions */
+ int maxres[DMX_MAX_AXES]; /**< Maximum resolutions */
+
+ int focusClass; /**< Non-zero if device can
+ * cause focus */
+ int proximityClass; /**< Non-zero if device
+ * causes proximity events */
+ int kbdFeedbackClass; /**< Non-zero if device has
+ * keyboard feedback */
+ int ptrFeedbackClass; /**< Non-zero if device has
+ * pointer feedback */
+ int ledFeedbackClass; /**< Non-zero if device has
+ * LED indicators */
+ int belFeedbackClass; /**< Non-zero if device has a
+ * bell */
+ int intFeedbackClass; /**< Non-zero if device has
+ * integer feedback */
+ int strFeedbackClass; /**< Non-zero if device has
+ * string feedback */
+
+ int maxSymbols; /**< Maximum symbols */
+ int maxSymbolsSupported; /**< Maximum symbols supported */
+ KeySym *symbols; /**< Key symbols */
+} DMXLocalInitInfo, *DMXLocalInitInfoPtr;
+
+typedef pointer (*dmxCreatePrivateProcPtr)(DeviceIntPtr);
+typedef void (*dmxDestroyPrivateProcPtr)(pointer);
+
+typedef void (*dmxInitProcPtr)(DevicePtr);
+typedef void (*dmxReInitProcPtr)(DevicePtr);
+typedef void (*dmxLateReInitProcPtr)(DevicePtr);
+typedef void (*dmxGetInfoProcPtr)(DevicePtr, DMXLocalInitInfoPtr);
+typedef int (*dmxOnProcPtr)(DevicePtr);
+typedef void (*dmxOffProcPtr)(DevicePtr);
+typedef void (*dmxUpdatePositionProcPtr)(pointer, int x, int y);
+
+typedef void (*dmxVTPreSwitchProcPtr)(pointer); /* Turn I/O Off */
+typedef void (*dmxVTPostSwitchProcPtr)(pointer); /* Turn I/O On */
+typedef void (*dmxVTSwitchReturnProcPtr)(pointer);
+typedef int (*dmxVTSwitchProcPtr)(pointer, int vt,
+ dmxVTSwitchReturnProcPtr, pointer);
+
+typedef void (*dmxMotionProcPtr)(DevicePtr,
+ int *valuators,
+ int firstAxis,
+ int axesCount,
+ DMXMotionType type,
+ DMXBlockType block);
+typedef void (*dmxEnqueueProcPtr)(DevicePtr, int type, int detail,
+ KeySym keySym, XEvent *e,
+ DMXBlockType block);
+typedef int (*dmxCheckSpecialProcPtr)(DevicePtr, KeySym keySym);
+typedef void (*dmxCollectEventsProcPtr)(DevicePtr,
+ dmxMotionProcPtr,
+ dmxEnqueueProcPtr,
+ dmxCheckSpecialProcPtr,
+ DMXBlockType);
+typedef void (*dmxProcessInputProcPtr)(pointer);
+typedef void (*dmxUpdateInfoProcPtr)(pointer, DMXUpdateType, WindowPtr);
+typedef int (*dmxFunctionsProcPtr)(pointer, DMXFunctionType);
+
+typedef void (*dmxKBCtrlProcPtr)(DevicePtr, KeybdCtrl *ctrl);
+typedef void (*dmxMCtrlProcPtr)(DevicePtr, PtrCtrl *ctrl);
+typedef void (*dmxKBBellProcPtr)(DevicePtr, int percent,
+ int volume, int pitch, int duration);
+
+/** Stores a mapping between the device id on the remote X server and
+ * the id on the DMX server */
+typedef struct _DMXEventMap {
+ int remote; /**< Event number on remote X server */
+ int server; /**< Event number (unbiased) on DMX server */
+} DMXEventMap;
+
+/** This is the device-independent structure used by the low-level input
+ * routines. The contents are not exposed to top-level .c files (except
+ * dmxextensions.c). \see dmxinput.h \see dmxextensions.c */
+typedef struct _DMXLocalInputInfo {
+ const char *name; /**< Device name */
+ DMXLocalInputType type; /**< Device type */
+ DMXLocalInputExtType extType; /**< Extended device type */
+ int binding; /**< Count of how many consecutive
+ * structs are bound to the same
+ * device */
+
+ /* Low-level (e.g., keyboard/mouse drivers) */
+
+ dmxCreatePrivateProcPtr create_private; /**< Create
+ * device-dependent
+ * private */
+ dmxDestroyPrivateProcPtr destroy_private; /**< Destroy
+ * device-dependent
+ * private */
+ dmxInitProcPtr init; /**< Initialize device */
+ dmxReInitProcPtr reinit; /**< Reinitialize device
+ * (during a
+ * reconfiguration) */
+ dmxLateReInitProcPtr latereinit; /**< Reinitialize a device
+ * (called very late
+ * during a
+ * reconfiguration) */
+ dmxGetInfoProcPtr get_info; /**< Get device information */
+ dmxOnProcPtr on; /**< Turn device on */
+ dmxOffProcPtr off; /**< Turn device off */
+ dmxUpdatePositionProcPtr update_position; /**< Called when another
+ * device updates the
+ * cursor position */
+ dmxVTPreSwitchProcPtr vt_pre_switch; /**< Called before a VT switch */
+ dmxVTPostSwitchProcPtr vt_post_switch; /**< Called after a VT switch */
+ dmxVTSwitchProcPtr vt_switch; /**< Causes a VT switch */
+
+ dmxCollectEventsProcPtr collect_events; /**< Collect and enqueue
+ * events from the
+ * device*/
+ dmxProcessInputProcPtr process_input; /**< Process event (from
+ * queue) */
+ dmxFunctionsProcPtr functions;
+ dmxUpdateInfoProcPtr update_info; /**< Update window layout
+ * information */
+
+ dmxMCtrlProcPtr mCtrl; /**< Pointer control */
+ dmxKBCtrlProcPtr kCtrl; /**< Keyboard control */
+ dmxKBBellProcPtr kBell; /**< Bell control */
+
+ pointer private; /**< Device-dependent private */
+ int isCore; /**< Is a DMX core device */
+ int sendsCore; /**< Sends DMX core events */
+ KeybdCtrl kctrl; /**< Keyboard control */
+ PtrCtrl mctrl; /**< Pointer control */
+
+ DeviceIntPtr pDevice; /**< X-level device */
+ int inputIdx; /**< High-level index */
+ int lastX, lastY; /**< Last known position;
+ * for XInput in
+ * dmxevents.c */
+
+ int head; /**< XInput motion history
+ * head */
+ int tail; /**< XInput motion history
+ * tail */
+ unsigned long *history; /**< XInput motion history */
+ int *valuators; /**< Cache of previous values */
+
+ /* for XInput ChangePointerDevice */
+ int (*savedMotionProc)(DeviceIntPtr,
+ xTimecoord *,
+ unsigned long,
+ unsigned long,
+ ScreenPtr);
+ int savedMotionEvents; /**< Saved motion events */
+ int savedSendsCore; /**< Saved sends-core flag */
+
+ DMXEventMap map[DMX_MAP_ENTRIES]; /**< XInput device id map */
+ int mapOptimize; /**< XInput device id
+ * map
+ * optimization */
+
+ long deviceId; /**< device id on remote side,
+ * if any */
+ const char *deviceName; /**< devive name on remote
+ * side, if any */
+} DMXLocalInputInfoRec;
+
+extern DMXLocalInputInfoPtr dmxLocalCorePointer, dmxLocalCoreKeyboard;
+
+extern void dmxLocalInitInput(DMXInputInfo *dmxInput);
+extern DMXLocalInputInfoPtr dmxInputCopyLocal(DMXInputInfo *dmxInput,
+ DMXLocalInputInfoPtr s);
+
+extern void dmxChangePointerControl(DeviceIntPtr pDevice, PtrCtrl *ctrl);
+extern void dmxKeyboardKbdCtrlProc(DeviceIntPtr pDevice, KeybdCtrl *ctrl);
+extern void dmxKeyboardBellProc(int percent, DeviceIntPtr pDevice,
+ pointer ctrl, int unknown);
+
+extern int dmxInputExtensionErrorHandler(Display *dsp, char *name,
+ char *reason);
+
+extern int dmxInputDetach(DMXInputInfo *dmxInput);
+extern void dmxInputDetachAll(DMXScreenInfo *dmxScreen);
+extern int dmxInputDetachId(int id);
+extern DMXInputInfo *dmxInputLocateId(int id);
+extern int dmxInputAttachConsole(const char *name, int isCore,
+ int *id);
+extern int dmxInputAttachBackend(int physicalScreen, int isCore,
+ int *id);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxmap.c b/nx-X11/programs/Xserver/hw/dmx/input/dmxmap.c
new file mode 100644
index 000000000..cf1be5853
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxmap.c
@@ -0,0 +1,122 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ */
+
+/** \file
+ *
+ * This file implements a mapping from remote XInput event types to Xdmx
+ * XInput event types.
+ *
+ * The exglobals.h file defines global server-side variables with names
+ * Device* to be integers that hold the value of the type of the
+ * server-side XInput extension event.
+ *
+ * The client-side X11/extensions/XInput.h file defines macros with THE
+ * EXACT SAME Device* names!
+ *
+ * Using those macros to extract remote server event type values from
+ * the (opaque) XDevice structure is appropriate, but makes a direct
+ * mapping to the Device* integers impossible. So we use the normalized
+ * XI_Device* names for these routines.
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmxinputinit.h"
+#include "dmxmap.h"
+
+/** Create a mapping from \a remoteEvent to \a serverEvent. The \a
+ * remoteEvent is the type returned from the remote server. The \a
+ * serverEvent is from the XI_* list of events in
+ * include/extensions/XIproto.h. */
+void dmxMapInsert(DMXLocalInputInfoPtr dmxLocal,
+ int remoteEvent, int serverEvent)
+{
+ int hash = remoteEvent & DMX_MAP_MASK;
+ int i;
+
+ /* Return if this has already been mapped */
+ if (dmxLocal->map[hash].remote == remoteEvent
+ && dmxLocal->map[hash].server == serverEvent) return;
+
+ if (dmxLocal->map[hash].remote) {
+ dmxLocal->mapOptimize = 0;
+ for (i = 0; i < DMX_MAP_ENTRIES; i++) {
+ if (!dmxLocal->map[i].remote) {
+ dmxLocal->map[i].remote = remoteEvent;
+ dmxLocal->map[i].server = serverEvent;
+ return;
+ }
+ }
+ dmxLog(dmxWarning,
+ "Out of map entries, cannot map remove event type %d\n",
+ remoteEvent);
+ } else {
+ dmxLocal->map[hash].remote = remoteEvent;
+ dmxLocal->map[hash].server = serverEvent;
+ }
+}
+
+/** Remove all mappings there were inserted with #dmxMapInsert. */
+void dmxMapClear(DMXLocalInputInfoPtr dmxLocal)
+{
+ int i;
+
+ for (i = 0; i < DMX_MAP_ENTRIES; i++) dmxLocal->map[i].remote = 0;
+ dmxLocal->mapOptimize = 1;
+}
+
+/** Lookup a mapping for \a remoteEvent. The \a remoteEvent is the type
+ * returned from the remote server. The return value is that which was
+ * passed into #dmxMapInsert (i.e., a value from the XI_* list in
+ * include/extensions/XIproto.h). If a mapping is not available, -1 is
+ * returned. */
+int dmxMapLookup(DMXLocalInputInfoPtr dmxLocal, int remoteEvent)
+{
+ int hash = remoteEvent & DMX_MAP_MASK;
+ int serverEvent = -1;
+ int i;
+
+ if (dmxLocal->mapOptimize && dmxLocal->map[hash].remote == remoteEvent) {
+ serverEvent = dmxLocal->map[hash].server;
+ } else {
+ for (i = 0; i < DMX_MAP_ENTRIES; i++)
+ if (dmxLocal->map[i].remote == remoteEvent) {
+ serverEvent = dmxLocal->map[hash].server;
+ break;
+ }
+ }
+
+ return serverEvent;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxmap.h b/nx-X11/programs/Xserver/hw/dmx/input/dmxmap.h
new file mode 100644
index 000000000..662955636
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxmap.h
@@ -0,0 +1,43 @@
+/* $XFree86$ */
+/*
+ * Copyright 2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ */
+
+/** \file
+ * Interface to XInput event mapping support. \see dmxmap.c */
+
+#ifndef _DMXMAP_H_
+#define _DMXMAP_H_
+extern void dmxMapInsert(DMXLocalInputInfoPtr dmxLocal,
+ int remoteEvent, int serverEvent);
+extern void dmxMapClear(DMXLocalInputInfoPtr dmxLocal);
+extern int dmxMapLookup(DMXLocalInputInfoPtr dmxLocal, int remoteEvent);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxmotion.c b/nx-X11/programs/Xserver/hw/dmx/input/dmxmotion.c
new file mode 100644
index 000000000..7b47c4562
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxmotion.c
@@ -0,0 +1,144 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * This file provides functions similar to miPointerGetMotionEvents and
+ * miPointerPutMotionEvents, with the exception that devices with more
+ * than two axes are fully supported. These routines may be used only
+ * for motion buffers for extension devices, and are \a not compatible
+ * replacements for the mi routines. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "inputstr.h"
+#include "dmxinputinit.h"
+#include "dmxcommon.h"
+#include "dmxmotion.h"
+
+#define OFFSET(offset,element) ((offset) * (numAxes + 1) + (element))
+
+/** Return size of motion buffer. \see DMX_MOTION_SIZE */
+int dmxPointerGetMotionBufferSize(void)
+{
+ return DMX_MOTION_SIZE;
+}
+
+/** This routine performs the same function as \a miPointerGetMotionEvents:
+ * the events in the motion history that are between the start and stop
+ * times (in mS) are placed in the coords vector, and the count of the
+ * number of items so placed is returned. This routine is called from
+ * dix/devices.c so that coords can hold valuator->numMotionEvents
+ * events. This routine is called from \a Xi/gtmotion.c with coords large
+ * enough to hold the same number of events in a variable-length
+ * extended \a xTimecoord structure. This provides sufficient data for the
+ * \a XGetDeviceMotionEvents library call, and would be identical to
+ * \a miPointerGetMotionEvents for devices with only 2 axes (i.e., core
+ * pointers) if \a xTimecoord used 32bit integers.
+ *
+ * Because DMX uses the mi* routines for all core devices, this routine
+ * only has to support extension devices using the polymorphic coords.
+ * Because compatibility with miPointerGetMotionEvents is not possible,
+ * it is not provided. */
+int dmxPointerGetMotionEvents(DeviceIntPtr pDevice,
+ xTimecoord *coords,
+ unsigned long start,
+ unsigned long stop,
+ ScreenPtr pScreen)
+{
+ GETDMXLOCALFROMPDEVICE;
+ int numAxes = pDevice->valuator->numAxes;
+ unsigned long *c = (unsigned long *)coords;
+ int count = 0;
+ int i, j;
+
+ if (!dmxLocal->history) return 0;
+ for (i = dmxLocal->head; i != dmxLocal->tail;) {
+ if (dmxLocal->history[OFFSET(i,0)] >= stop) break;
+ if (dmxLocal->history[OFFSET(i,0)] >= start) {
+ for (j = 0; j < numAxes + 1; j++)
+ c[OFFSET(count,j)] = dmxLocal->history[OFFSET(i,j)];
+ ++count;
+ }
+ if (++i >= DMX_MOTION_SIZE) i = 0;
+ }
+ return count;
+}
+
+/** This routine adds an event to the motion history. A similar
+ * function is performed by miPointerMove for the mi versions of these
+ * routines. */
+void dmxPointerPutMotionEvent(DeviceIntPtr pDevice,
+ int firstAxis, int axesCount, int *v,
+ unsigned long time)
+{
+ GETDMXLOCALFROMPDEVICE;
+ int numAxes = pDevice->valuator->numAxes;
+ int i;
+
+ if (!dmxLocal->history) {
+ dmxLocal->history = xalloc(sizeof(*dmxLocal->history)
+ * (numAxes + 1)
+ * DMX_MOTION_SIZE);
+ dmxLocal->head = 0;
+ dmxLocal->tail = 0;
+ dmxLocal->valuators = xalloc(sizeof(*dmxLocal->valuators) * numAxes);
+ memset(dmxLocal->valuators, 0, sizeof(*dmxLocal->valuators) * numAxes);
+ } else {
+ if (++dmxLocal->tail >= DMX_MOTION_SIZE) dmxLocal->tail = 0;
+ if (dmxLocal->head == dmxLocal->tail)
+ if (++dmxLocal->head >= DMX_MOTION_SIZE) dmxLocal->head = 0;
+ }
+
+ dmxLocal->history[OFFSET(dmxLocal->tail,0)] = time;
+
+ /* Initialize the data from the known
+ * values (if Absolute) or to zero (if
+ * Relative) */
+ if (pDevice->valuator->mode == Absolute) {
+ for (i = 0; i < numAxes; i++)
+ dmxLocal->history[OFFSET(dmxLocal->tail,i+1)]
+ = dmxLocal->valuators[i];
+ } else {
+ for (i = 0; i < numAxes; i++)
+ dmxLocal->history[OFFSET(dmxLocal->tail,i+1)] = 0;
+ }
+
+ for (i = firstAxis; i < axesCount; i++) {
+ dmxLocal->history[OFFSET(dmxLocal->tail,i+i)]
+ = (unsigned long)v[i-firstAxis];
+ dmxLocal->valuators[i] = v[i-firstAxis];
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxmotion.h b/nx-X11/programs/Xserver/hw/dmx/input/dmxmotion.h
new file mode 100644
index 000000000..2928f5f2a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxmotion.h
@@ -0,0 +1,50 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to functions supporting motion events. \see dmxmotion.c */
+
+#ifndef _DMXMOTION_H_
+#define _DMXMOTION_H_
+
+extern int dmxPointerGetMotionBufferSize(void);
+extern int dmxPointerGetMotionEvents(DeviceIntPtr pDevice,
+ xTimecoord *coords,
+ unsigned long start,
+ unsigned long stop,
+ ScreenPtr pScreen);
+extern void dmxPointerPutMotionEvent(DeviceIntPtr pDevice,
+ int firstAxis, int axesCount, int *v,
+ unsigned long time);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxsigio.c b/nx-X11/programs/Xserver/hw/dmx/input/dmxsigio.c
new file mode 100644
index 000000000..840b56641
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxsigio.c
@@ -0,0 +1,234 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * Provides an interface for handling SIGIO signals for input devices. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "inputstr.h"
+#include "dmxinputinit.h"
+#include "dmxsigio.h"
+#include "dmxevents.h"
+#include <signal.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+static int dmxFdCount = 0;
+static Bool dmxInputEnabled = TRUE;
+
+/* Define equivalents for non-POSIX systems (e.g., SGI IRIX, Solaris) */
+#ifndef O_ASYNC
+# ifdef FASYNC
+# define O_ASYNC FASYNC
+# else
+# define O_ASYNC 0
+# endif
+#endif
+#ifndef O_NONBLOCK
+#define O_NONBLOCK FNONBLK
+#endif
+
+static void dmxSigioHandler(int sig)
+{
+ int i, j;
+ DMXInputInfo *dmxInput;
+
+ for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++) {
+ if (dmxInput->sigioState == DMX_ACTIVESIGIO) {
+ for (j = 0; j < dmxInput->numDevs; j++) {
+ DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[j];
+ if (dmxLocal->collect_events) {
+ dmxLocal->collect_events(&dmxLocal->pDevice->public,
+ dmxMotion,
+ dmxEnqueue,
+ dmxCheckSpecialKeys,
+ DMX_NO_BLOCK);
+ }
+ }
+ }
+ }
+}
+
+/** Block SIGIO handling. */
+void dmxSigioBlock(void)
+{
+ sigset_t s;
+
+ sigemptyset(&s);
+ sigaddset(&s, SIGIO);
+ sigprocmask(SIG_BLOCK, &s, 0);
+}
+
+/** Unblock SIGIO handling. */
+void dmxSigioUnblock(void)
+{
+ sigset_t s;
+
+ sigemptyset(&s);
+ sigaddset(&s, SIGIO);
+ sigprocmask(SIG_UNBLOCK, &s, 0);
+}
+
+static void dmxSigioHook(void)
+{
+ struct sigaction a;
+ sigset_t s;
+
+ memset(&a, 0, sizeof(a));
+ a.sa_handler = dmxSigioHandler;
+ sigemptyset(&a.sa_mask);
+ sigaddset(&a.sa_mask, SIGIO);
+ sigaddset(&a.sa_mask, SIGALRM);
+ sigaddset(&a.sa_mask, SIGVTALRM);
+ sigaction(SIGIO, &a, 0);
+
+ sigemptyset(&s);
+ sigprocmask(SIG_SETMASK, &s, 0);
+}
+
+static void dmxSigioUnhook(void)
+{
+ struct sigaction a;
+
+ memset (&a, 0, sizeof(a));
+ a.sa_handler = SIG_IGN;
+ sigemptyset(&a.sa_mask);
+ sigaction(SIGIO, &a, 0);
+}
+
+static void dmxSigioAdd(DMXInputInfo *dmxInput)
+{
+ int flags;
+ int i;
+
+ switch (dmxInput->sigioState) {
+ case DMX_NOSIGIO: return;
+ case DMX_USESIGIO: dmxInput->sigioState = DMX_ACTIVESIGIO; break;
+ case DMX_ACTIVESIGIO: return;
+ }
+
+ for (i = 0; i < dmxInput->sigioFdCount; i++) {
+ if (!dmxInput->sigioAdded[i]) {
+ int fd = dmxInput->sigioFd[i];
+
+ fcntl(fd, F_SETOWN, getpid());
+ flags = fcntl(fd, F_GETFL);
+ flags |= O_ASYNC|O_NONBLOCK;
+ fcntl(fd, F_SETFL, flags);
+
+ AddEnabledDevice(fd);
+ dmxInput->sigioAdded[i] = TRUE;
+
+ if (++dmxFdCount == 1) dmxSigioHook();
+ }
+ }
+}
+
+static void dmxSigioRemove(DMXInputInfo *dmxInput)
+{
+ int flags;
+ int i;
+
+ switch (dmxInput->sigioState) {
+ case DMX_NOSIGIO: return;
+ case DMX_USESIGIO: return;
+ case DMX_ACTIVESIGIO: dmxInput->sigioState = DMX_USESIGIO; break;
+ }
+
+ for (i = 0; i < dmxInput->sigioFdCount; i++) {
+ if (dmxInput->sigioAdded[i]) {
+ int fd = dmxInput->sigioFd[i];
+
+ dmxInput->sigioAdded[i] = FALSE;
+ RemoveEnabledDevice(fd);
+
+ flags = fcntl(fd, F_GETFL);
+ flags &= ~(O_ASYNC|O_NONBLOCK);
+ fcntl(fd, F_SETFL, flags);
+
+ if (!--dmxFdCount) dmxSigioUnhook();
+ }
+ }
+}
+
+/** Enable SIGIO handling. This instantiates the handler with the OS. */
+void dmxSigioEnableInput(void)
+{
+ int i;
+ DMXInputInfo *dmxInput;
+
+ dmxInputEnabled = TRUE;
+ for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++)
+ dmxSigioAdd(dmxInput);
+}
+
+/** Disable SIGIO handling. This removes the hanlder from the OS. */
+void dmxSigioDisableInput(void)
+{
+ int i;
+ DMXInputInfo *dmxInput;
+
+ dmxInputEnabled = FALSE;
+ for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++)
+ dmxSigioRemove(dmxInput);
+}
+
+/** Make a note that the input device described in \a dmxInput will be
+ * using the file descriptor \a fd for SIGIO signals. Calls
+ * AddEnabledDevice ifi SIGIO handling has been enabled with
+ * #dmxSigioEnableInput(). */
+void dmxSigioRegister(DMXInputInfo *dmxInput, int fd)
+{
+ dmxInput->sigioState = DMX_USESIGIO;
+ if (dmxInput->sigioFdCount >= DMX_MAX_SIGIO_FDS)
+ dmxLog(dmxFatal, "Too many SIGIO file descriptors (%d >= %d)\n",
+ dmxInput->sigioFdCount, DMX_MAX_SIGIO_FDS);
+
+ dmxInput->sigioFd[dmxInput->sigioFdCount++] = fd;
+ if (dmxInputEnabled) dmxSigioAdd(dmxInput);
+}
+
+/** Remove the notes that \a dmxInput is using any file descriptors for
+ * SIGIO signals. Calls RemoveEnabledDevice. */
+void dmxSigioUnregister(DMXInputInfo *dmxInput)
+{
+ if (dmxInput->sigioState == DMX_NOSIGIO) return;
+ dmxSigioRemove(dmxInput);
+ dmxInput->sigioState = DMX_NOSIGIO;
+ dmxInput->sigioFdCount = 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxsigio.h b/nx-X11/programs/Xserver/hw/dmx/input/dmxsigio.h
new file mode 100644
index 000000000..869dd6bdf
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxsigio.h
@@ -0,0 +1,46 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to SIGIO handling support. \see dmxsigio.c */
+
+#ifndef _DMXSIGIO_H_
+#define _DMXSIGIO_H_
+extern void dmxSigioBlock(void);
+extern void dmxSigioUnblock(void);
+extern void dmxSigioEnableInput(void);
+extern void dmxSigioDisableInput(void);
+extern void dmxSigioRegister(DMXInputInfo *dmxInput, int fd);
+extern void dmxSigioUnregister(DMXInputInfo *dmxInput);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/dmxxinput.c b/nx-X11/programs/Xserver/hw/dmx/input/dmxxinput.c
new file mode 100644
index 000000000..bd4ace6d0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/dmxxinput.c
@@ -0,0 +1,156 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * This file implements support required by the XINPUT extension.
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "inputstr.h"
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h"
+
+#include "mipointer.h"
+#include "dmxinputinit.h"
+#include "exevents.h"
+
+/** Change the core keyboard from \a old_dev to \a new_dev. Currently
+ * this is not implemented. */
+int ChangeKeyboardDevice(DeviceIntPtr old_dev, DeviceIntPtr new_dev)
+{
+#if 0
+ DMXLocalInputInfoPtr dmxLocalOld = old_dev->public.devicePrivate;
+ DMXLocalInputInfoPtr dmxLocalNew = new_dev->public.devicePrivate;
+
+ /* Switch our notion of core keyboard */
+ dmxLocalOld->isCore = 0;
+ dmxLocalOld->sendsCore = dmxLocalOld->savedSendsCore;
+
+ dmxLocalNew->isCore = 1;
+ dmxLocalNew->savedSendsCore = dmxLocalNew->sendsCore;
+ dmxLocalNew->sendsCore = 1;
+ dmxLocalCorePointer = dmxLocalNew;
+
+ _RegisterKeyboardDevice(new_dev);
+ RegisterOtherDevice(old_dev);
+
+ return Success;
+#endif
+ return BadMatch;
+}
+
+/** Change the core pointer from \a old_dev to \a new_dev. */
+int ChangePointerDevice(DeviceIntPtr old_dev,
+ DeviceIntPtr new_dev,
+ unsigned char x,
+ unsigned char y)
+{
+ DMXLocalInputInfoPtr dmxLocalOld = old_dev->public.devicePrivate;
+ DMXLocalInputInfoPtr dmxLocalNew = new_dev->public.devicePrivate;
+
+ if (x != 0 || y != 1) return BadMatch;
+
+ /* Make sure the new device can focus */
+ InitFocusClassDeviceStruct(old_dev);
+
+ /* Switch the motion history buffers */
+ if (dmxLocalOld->savedMotionProc) {
+ old_dev->valuator->GetMotionProc = dmxLocalOld->savedMotionProc;
+ old_dev->valuator->numMotionEvents = dmxLocalOld->savedMotionEvents;
+ }
+ dmxLocalNew->savedMotionProc = new_dev->valuator->GetMotionProc;
+ dmxLocalNew->savedMotionEvents = new_dev->valuator->numMotionEvents;
+ new_dev->valuator->GetMotionProc = miPointerGetMotionEvents;
+ new_dev->valuator->numMotionEvents = miPointerGetMotionBufferSize();
+
+ /* Switch our notion of core pointer */
+ dmxLocalOld->isCore = 0;
+ dmxLocalOld->sendsCore = dmxLocalOld->savedSendsCore;
+
+ dmxLocalNew->isCore = 1;
+ dmxLocalNew->savedSendsCore = dmxLocalNew->sendsCore;
+ dmxLocalNew->sendsCore = 1;
+ dmxLocalCorePointer = dmxLocalNew;
+
+ return Success;
+}
+
+/** Close the input device. This is not required by the XINPUT model
+ * that DMX uses. */
+void CloseInputDevice (DeviceIntPtr d, ClientPtr client)
+{
+}
+
+/** This is not required by the XINPUT model that DMX uses. */
+void AddOtherInputDevices(void)
+{
+}
+
+/** Open an input device. This is not required by the XINPUT model that
+ * DMX uses. */
+void OpenInputDevice (DeviceIntPtr dev, ClientPtr client, int *status)
+{
+}
+
+/** Set device mode to \a mode. This is not implemented. */
+int SetDeviceMode(ClientPtr client, DeviceIntPtr dev, int mode)
+{
+ return BadMatch;
+}
+
+/** Set device valuators. This is not implemented. */
+int SetDeviceValuators (ClientPtr client,
+ DeviceIntPtr dev,
+ int *valuators,
+ int first_valuator,
+ int num_valuators)
+{
+ return BadMatch;
+}
+
+/** Change device control. This is not implemented. */
+int ChangeDeviceControl(ClientPtr client,
+ DeviceIntPtr dev,
+ xDeviceCtl *control)
+{
+ return BadMatch;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/lnx-keyboard.c b/nx-X11/programs/Xserver/hw/dmx/input/lnx-keyboard.c
new file mode 100644
index 000000000..97cc3077e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/lnx-keyboard.c
@@ -0,0 +1,975 @@
+/* $XFree86$ */
+/* Portions of this file were derived from the following files:
+ *
+ **********************************************************************
+ *
+ * xfree86/common/{xf86Io.c,xf86Kbd.c,xf86Events.c}
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ **********************************************************************
+ *
+ * xfree86/common/xf86KbdLnx.c
+ *
+ * Linux version of keymapping setup. The kernel (since 0.99.14) has support
+ * for fully remapping the keyboard, but there are some differences between
+ * the Linux map and the SVR4 map (esp. in the extended keycodes). We also
+ * remove the restriction on what keycodes can be remapped.
+ * Orest Zborowski.
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ **********************************************************************
+ *
+ * xfree86/os-support/linux/lnx_io.c
+ *
+ * Copyright 1992 by Orest Zborowski <obz@Kodak.com>
+ * Copyright 1993 by David Dawes <dawes@xfree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Orest Zborowski and David Dawes
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Orest Zborowski
+ * and David Dawes make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OREST ZBOROWSKI AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID DAWES BE LIABLE
+ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/*
+ * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * This code implements a low-level device driver for the Linux
+ * keyboard. The code is derived from code by Thomas Roell, Orest
+ * Zborowski, and David Dawes (see the source code for complete
+ * references). */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+/*****************************************************************************/
+/* Define some macros to make it easier to move this file to another
+ * part of the Xserver tree. All calls to the dmx* layer are #defined
+ * here for the .c file. The .h file will also have to be edited. */
+#include "dmxinputinit.h"
+#include "lnx-keyboard.h"
+
+#define GETPRIV myPrivate *priv \
+ = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
+
+#define LOG0(f) dmxLog(dmxDebug,f)
+#define LOG1(f,a) dmxLog(dmxDebug,f,a)
+#define LOG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define FATAL0(f) dmxLog(dmxFatal,f)
+#define FATAL1(f,a) dmxLog(dmxFatal,f,a)
+#define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b)
+#define MOTIONPROC dmxMotionProcPtr
+#define ENQUEUEPROC dmxEnqueueProcPtr
+#define CHECKPROC dmxCheckSpecialProcPtr
+#define SWITCHRETPROC dmxVTSwitchReturnProcPtr
+#define BLOCK DMXBlockType
+#define MESSAGE "\033c\n\n\nDMX taking input from this console..."
+#define FINALMESSAGE "\033cDMX terminated."
+
+/* End of interface definitions. */
+/*****************************************************************************/
+
+#include "inputstr.h"
+#include <X11/Xos.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <signal.h>
+#include <sys/vt.h>
+#include <sys/kd.h>
+#include <termios.h>
+#include "atKeynames.h"
+#include "xf86Keymap.h"
+#include <linux/keyboard.h>
+
+#define NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0]))
+#define NUM_STATE_ENTRIES (256/32)
+
+
+/* Private area for Linux-style keyboards. */
+typedef struct _myPrivate {
+ int fd;
+ int vtno;
+ int vtcurrent;
+ int kbdtrans;
+ struct termios kbdtty;
+ int kbdType;
+ CARD32 kbdState[NUM_STATE_ENTRIES];
+ DeviceIntPtr pKeyboard;
+ unsigned char prefix;
+
+ int switched;
+ SWITCHRETPROC switch_return;
+ void *switch_return_data;
+
+ /* For bell */
+ int pitch;
+ unsigned long duration;
+} myPrivate;
+
+static myPrivate *PRIV = NULL;
+
+#undef SYSCALL
+#define SYSCALL(call) while(((call) == -1) && (errno == EINTR))
+
+static int kbdLinuxKeyDown(myPrivate *priv, int keyCode)
+{
+ CARD8 byte = keyCode >> 5;
+ CARD32 bit = 1 << (keyCode & 0x1f);
+
+ if (byte > NUM_STATE_ENTRIES) return 0;
+ return priv->kbdState[byte] & bit;
+}
+
+static void kbdLinuxKeyState(myPrivate *priv, int type, int keyCode)
+{
+ CARD8 byte = keyCode >> 5;
+ CARD32 bit = 1 << (keyCode & 0x1f);
+
+ if (byte > NUM_STATE_ENTRIES) return;
+ if (type == KeyPress) priv->kbdState[byte] |= bit;
+ else priv->kbdState[byte] &= ~bit;
+}
+
+static KeySym linux_to_x[256] = {
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Escape,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
+ XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
+ XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
+ XK_comma, XK_minus, XK_period, XK_slash,
+ XK_0, XK_1, XK_2, XK_3,
+ XK_4, XK_5, XK_6, XK_7,
+ XK_8, XK_9, XK_colon, XK_semicolon,
+ XK_less, XK_equal, XK_greater, XK_question,
+ XK_at, XK_A, XK_B, XK_C,
+ XK_D, XK_E, XK_F, XK_G,
+ XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O,
+ XK_P, XK_Q, XK_R, XK_S,
+ XK_T, XK_U, XK_V, XK_W,
+ XK_X, XK_Y, XK_Z, XK_bracketleft,
+ XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
+ XK_grave, XK_a, XK_b, XK_c,
+ XK_d, XK_e, XK_f, XK_g,
+ XK_h, XK_i, XK_j, XK_k,
+ XK_l, XK_m, XK_n, XK_o,
+ XK_p, XK_q, XK_r, XK_s,
+ XK_t, XK_u, XK_v, XK_w,
+ XK_x, XK_y, XK_z, XK_braceleft,
+ XK_bar, XK_braceright, XK_asciitilde, XK_BackSpace,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_nobreakspace,XK_exclamdown, XK_cent, XK_sterling,
+ XK_currency, XK_yen, XK_brokenbar, XK_section,
+ XK_diaeresis, XK_copyright, XK_ordfeminine, XK_guillemotleft,
+ XK_notsign, XK_hyphen, XK_registered, XK_macron,
+ XK_degree, XK_plusminus, XK_twosuperior, XK_threesuperior,
+ XK_acute, XK_mu, XK_paragraph, XK_periodcentered,
+ XK_cedilla, XK_onesuperior, XK_masculine, XK_guillemotright,
+ XK_onequarter, XK_onehalf, XK_threequarters,XK_questiondown,
+ XK_Agrave, XK_Aacute, XK_Acircumflex, XK_Atilde,
+ XK_Adiaeresis, XK_Aring, XK_AE, XK_Ccedilla,
+ XK_Egrave, XK_Eacute, XK_Ecircumflex, XK_Ediaeresis,
+ XK_Igrave, XK_Iacute, XK_Icircumflex, XK_Idiaeresis,
+ XK_ETH, XK_Ntilde, XK_Ograve, XK_Oacute,
+ XK_Ocircumflex, XK_Otilde, XK_Odiaeresis, XK_multiply,
+ XK_Ooblique, XK_Ugrave, XK_Uacute, XK_Ucircumflex,
+ XK_Udiaeresis, XK_Yacute, XK_THORN, XK_ssharp,
+ XK_agrave, XK_aacute, XK_acircumflex, XK_atilde,
+ XK_adiaeresis, XK_aring, XK_ae, XK_ccedilla,
+ XK_egrave, XK_eacute, XK_ecircumflex, XK_ediaeresis,
+ XK_igrave, XK_iacute, XK_icircumflex, XK_idiaeresis,
+ XK_eth, XK_ntilde, XK_ograve, XK_oacute,
+ XK_ocircumflex, XK_otilde, XK_odiaeresis, XK_division,
+ XK_oslash, XK_ugrave, XK_uacute, XK_ucircumflex,
+ XK_udiaeresis, XK_yacute, XK_thorn, XK_ydiaeresis
+};
+
+/*
+ * Maps the AT keycodes to Linux keycodes
+ */
+static unsigned char at2lnx[NUM_KEYCODES] =
+{
+ 0x01, /* KEY_Escape */ 0x02, /* KEY_1 */
+ 0x03, /* KEY_2 */ 0x04, /* KEY_3 */
+ 0x05, /* KEY_4 */ 0x06, /* KEY_5 */
+ 0x07, /* KEY_6 */ 0x08, /* KEY_7 */
+ 0x09, /* KEY_8 */ 0x0a, /* KEY_9 */
+ 0x0b, /* KEY_0 */ 0x0c, /* KEY_Minus */
+ 0x0d, /* KEY_Equal */ 0x0e, /* KEY_BackSpace */
+ 0x0f, /* KEY_Tab */ 0x10, /* KEY_Q */
+ 0x11, /* KEY_W */ 0x12, /* KEY_E */
+ 0x13, /* KEY_R */ 0x14, /* KEY_T */
+ 0x15, /* KEY_Y */ 0x16, /* KEY_U */
+ 0x17, /* KEY_I */ 0x18, /* KEY_O */
+ 0x19, /* KEY_P */ 0x1a, /* KEY_LBrace */
+ 0x1b, /* KEY_RBrace */ 0x1c, /* KEY_Enter */
+ 0x1d, /* KEY_LCtrl */ 0x1e, /* KEY_A */
+ 0x1f, /* KEY_S */ 0x20, /* KEY_D */
+ 0x21, /* KEY_F */ 0x22, /* KEY_G */
+ 0x23, /* KEY_H */ 0x24, /* KEY_J */
+ 0x25, /* KEY_K */ 0x26, /* KEY_L */
+ 0x27, /* KEY_SemiColon */ 0x28, /* KEY_Quote */
+ 0x29, /* KEY_Tilde */ 0x2a, /* KEY_ShiftL */
+ 0x2b, /* KEY_BSlash */ 0x2c, /* KEY_Z */
+ 0x2d, /* KEY_X */ 0x2e, /* KEY_C */
+ 0x2f, /* KEY_V */ 0x30, /* KEY_B */
+ 0x31, /* KEY_N */ 0x32, /* KEY_M */
+ 0x33, /* KEY_Comma */ 0x34, /* KEY_Period */
+ 0x35, /* KEY_Slash */ 0x36, /* KEY_ShiftR */
+ 0x37, /* KEY_KP_Multiply */ 0x38, /* KEY_Alt */
+ 0x39, /* KEY_Space */ 0x3a, /* KEY_CapsLock */
+ 0x3b, /* KEY_F1 */ 0x3c, /* KEY_F2 */
+ 0x3d, /* KEY_F3 */ 0x3e, /* KEY_F4 */
+ 0x3f, /* KEY_F5 */ 0x40, /* KEY_F6 */
+ 0x41, /* KEY_F7 */ 0x42, /* KEY_F8 */
+ 0x43, /* KEY_F9 */ 0x44, /* KEY_F10 */
+ 0x45, /* KEY_NumLock */ 0x46, /* KEY_ScrollLock */
+ 0x47, /* KEY_KP_7 */ 0x48, /* KEY_KP_8 */
+ 0x49, /* KEY_KP_9 */ 0x4a, /* KEY_KP_Minus */
+ 0x4b, /* KEY_KP_4 */ 0x4c, /* KEY_KP_5 */
+ 0x4d, /* KEY_KP_6 */ 0x4e, /* KEY_KP_Plus */
+ 0x4f, /* KEY_KP_1 */ 0x50, /* KEY_KP_2 */
+ 0x51, /* KEY_KP_3 */ 0x52, /* KEY_KP_0 */
+ 0x53, /* KEY_KP_Decimal */ 0x54, /* KEY_SysReqest */
+ 0x00, /* 0x55 */ 0x56, /* KEY_Less */
+ 0x57, /* KEY_F11 */ 0x58, /* KEY_F12 */
+ 0x66, /* KEY_Home */ 0x67, /* KEY_Up */
+ 0x68, /* KEY_PgUp */ 0x69, /* KEY_Left */
+ 0x5d, /* KEY_Begin */ 0x6a, /* KEY_Right */
+ 0x6b, /* KEY_End */ 0x6c, /* KEY_Down */
+ 0x6d, /* KEY_PgDown */ 0x6e, /* KEY_Insert */
+ 0x6f, /* KEY_Delete */ 0x60, /* KEY_KP_Enter */
+ 0x61, /* KEY_RCtrl */ 0x77, /* KEY_Pause */
+ 0x63, /* KEY_Print */ 0x62, /* KEY_KP_Divide */
+ 0x64, /* KEY_AltLang */ 0x65, /* KEY_Break */
+ 0x00, /* KEY_LMeta */ 0x00, /* KEY_RMeta */
+ 0x7A, /* KEY_Menu/FOCUS_PF11*/0x00, /* 0x6e */
+ 0x7B, /* FOCUS_PF12 */ 0x00, /* 0x70 */
+ 0x00, /* 0x71 */ 0x00, /* 0x72 */
+ 0x59, /* FOCUS_PF2 */ 0x78, /* FOCUS_PF9 */
+ 0x00, /* 0x75 */ 0x00, /* 0x76 */
+ 0x5A, /* FOCUS_PF3 */ 0x5B, /* FOCUS_PF4 */
+ 0x5C, /* FOCUS_PF5 */ 0x5D, /* FOCUS_PF6 */
+ 0x5E, /* FOCUS_PF7 */ 0x5F, /* FOCUS_PF8 */
+ 0x7C, /* JAP_86 */ 0x79, /* FOCUS_PF10 */
+ 0x00, /* 0x7f */
+};
+
+/** Create a private structure for use within this file. */
+pointer kbdLinuxCreatePrivate(DeviceIntPtr pKeyboard)
+{
+ myPrivate *priv = xalloc(sizeof(*priv));
+ memset(priv, 0, sizeof(*priv));
+ priv->fd = -1;
+ priv->pKeyboard = pKeyboard;
+ return priv;
+}
+
+/** Destroy a private structure. */
+void kbdLinuxDestroyPrivate(pointer priv)
+{
+ if (priv) xfree(priv);
+}
+
+/** Ring the bell.
+ *
+ * Note: we completely ignore the \a volume, since Linux's ioctl()
+ * interface does not provide a way to control it. If it did, the XBell
+ * manpage tells how the actual volume is a function of the percent and
+ * the (base) volume.
+ *
+ * Note that most of the other PC-based bell drivers compute the
+ * duration for KDMKTONE as a function of the volume and the duration.
+ * For some drivers, the duration is only measured in mS if the volume
+ * is 50, and is scaled by the volume for other values. This seems
+ * confusing and possibly incorrect (the xset man page says that the
+ * bell will be "as closely as it can to the user's specifications" --
+ * if we ignore the volume and set the duration correctly, then we'll
+ * get one parameter "wrong" -- but if we use the volume to scale the
+ * duration, then we'll get both parameters "wrong"). */
+void kbdLinuxBell(DevicePtr pDev, int percent,
+ int volume, int pitch, int duration)
+{
+ GETPRIV;
+
+ if (duration && pitch) {
+ ioctl(priv->fd,
+ KDMKTONE,
+ ((1193190 / pitch) & 0xffff) /* Low bits specify cycle time */
+ | (duration << 16)); /* High bits are duration in msec */
+ }
+}
+
+/** Set the LEDs. */
+void kbdLinuxCtrl(DevicePtr pDev, KeybdCtrl *ctrl)
+{
+ GETPRIV;
+
+ ioctl(priv->fd, KDSETLED, ctrl->leds & 0x07);
+}
+
+static int kbdLinuxGetFreeVTNumber(void)
+{
+ int fd = -1;
+ int vtno;
+ int i;
+ const char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
+
+ for (i = 0; tty0[i]; i++)
+ if ((fd = open(tty0[i], O_WRONLY, 0)) >= 0) break;
+ if (fd < 0)
+ FATAL1("kbdLinuxGetFreeVTNumber: Cannot open tty0 (%s)\n",
+ strerror(errno));
+ if (ioctl(fd, VT_OPENQRY, &vtno) < 0 || vtno < 0)
+ FATAL0("kbdLinuxGetFreeVTNumber: Cannot find a free VT\n");
+ return vtno;
+}
+
+static int kbdLinuxOpenVT(int vtno)
+{
+ int fd = -1;
+ int i;
+ const char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
+ char name[64]; /* RATS: Only used in XmuSnprintf */
+
+ for (i = 0; vcs[i]; i++) {
+ XmuSnprintf(name, sizeof(name), vcs[i], vtno);
+ if ((fd = open(name, O_RDWR | O_NONBLOCK, 0)) >= 0) break;
+ }
+ if (fd < 0)
+ FATAL2("kbdLinuxOpenVT: Cannot open VT %d (%s)\n",
+ vtno, strerror(errno));
+ return fd;
+}
+
+static int kbdLinuxGetCurrentVTNumber(int fd)
+{
+ struct vt_stat vts;
+
+ if (!ioctl(fd, VT_GETSTATE, &vts)) return vts.v_active;
+ return -1;
+}
+
+static int kbdLinuxActivate(int fd, int vtno, int setSig);
+
+/** Currently unused hook called prior to an VT switch. */
+void kbdLinuxVTPreSwitch(pointer p)
+{
+}
+
+/** Currently unused hook called after returning from a VT switch. */
+void kbdLinuxVTPostSwitch(pointer p)
+{
+}
+
+/** Tell the operating system to switch to \a vt. The \a switch_return
+ * function is called with the \a switch_return_data when the VT is
+ * switched back to the pre-switch VT (i.e., the user returns to the DMX
+ * session). */
+int kbdLinuxVTSwitch(pointer p, int vt,
+ void (*switch_return)(pointer),
+ pointer switch_return_data)
+{
+ myPrivate *priv = p;
+
+ if (priv->switched) FATAL0("kbdLinuxVTSwitch: already switched...\n");
+ if (priv->vtno == vt) return 0;
+
+ PRIV = priv;
+ priv->switched = 0; /* Will switch to 1 in handler */
+ priv->switch_return = switch_return;
+ priv->switch_return_data = switch_return_data;
+ kbdLinuxActivate(priv->fd, vt, 0);
+ return 1;
+}
+
+/* RATS: This function is only ever used to handle SIGUSR1. */
+static void kbdLinuxVTSignalHandler(int sig)
+{
+ myPrivate *priv = PRIV;
+
+ signal(sig, kbdLinuxVTSignalHandler);
+ if (priv) {
+ ioctl(priv->fd, VT_RELDISP, VT_ACKACQ);
+ priv->switched = !priv->switched;
+ LOG2("kbdLinuxVTSignalHandler: got signal %d, switched = %d\n",
+ sig, priv->switched);
+ if (!priv->switched && priv->switch_return)
+ priv->switch_return(priv->switch_return_data);
+ }
+}
+
+static int kbdLinuxActivate(int fd, int vtno, int setSig)
+{
+ int result;
+ struct vt_mode VT;
+
+ SYSCALL(result = ioctl(fd, VT_ACTIVATE, vtno));
+ if (result) FATAL0("kbdLinuxActivate: VT_ACTIVATE failed\n");
+ SYSCALL(result = ioctl(fd, VT_WAITACTIVE, vtno));
+ if (result) FATAL0("kbdLinuxActivate: VT_WAITACTIVE failed\n");
+ if (setSig) {
+ SYSCALL(result = ioctl(fd, VT_GETMODE, &VT));
+ if (result < 0) FATAL0("kbdLinuxActivate: VT_GETMODE failed\n");
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+ if (ioctl(fd, VT_SETMODE, &VT))
+ FATAL0("kbdLinuxActivate: VT_SETMODE VT_PROCESS failed\n");
+ signal(SIGUSR1, kbdLinuxVTSignalHandler);
+ }
+ return Success;
+}
+
+static void kbdLinuxOpenConsole(DevicePtr pDev)
+{
+ GETPRIV;
+ const char *msg = MESSAGE;
+
+ if (priv->fd >= 0) return;
+ priv->vtno = kbdLinuxGetFreeVTNumber();
+ priv->fd = kbdLinuxOpenVT(priv->vtno);
+ priv->vtcurrent = kbdLinuxGetCurrentVTNumber(priv->fd);
+ LOG2("kbdLinuxOpenConsole: current VT %d; using free VT %d\n",
+ priv->vtcurrent, priv->vtno);
+ kbdLinuxActivate(priv->fd, priv->vtno, 1);
+ ioctl(priv->fd, KDSETMODE, KD_GRAPHICS); /* To turn off gpm */
+ if (msg) write(priv->fd, msg, strlen(msg));
+}
+
+static void kbdLinuxCloseConsole(DevicePtr pDev)
+{
+ GETPRIV;
+ struct vt_mode VT;
+ const char *msg = FINALMESSAGE;
+
+ if (priv->fd < 0) return;
+
+ ioctl(priv->fd, KDSETMODE, KD_TEXT);
+ if (msg) write(priv->fd, msg, strlen(msg));
+ if (ioctl(priv->fd, VT_GETMODE, &VT) != -1) {
+ VT.mode = VT_AUTO;
+ ioctl(priv->fd, VT_SETMODE, &VT);
+ }
+
+ LOG1("kbdLinuxCloseConsole: switching to VT %d\n", priv->vtcurrent);
+ if (priv->vtcurrent >= 0) kbdLinuxActivate(priv->fd, priv->vtcurrent, 0);
+
+ close(priv->fd);
+ priv->fd = -1;
+}
+
+/** Initialize the \a pDev as a Linux keyboard. */
+void kbdLinuxInit(DevicePtr pDev)
+{
+ GETPRIV;
+
+ if (priv->fd <= 0) kbdLinuxOpenConsole(pDev);
+
+ ioctl(priv->fd, KDGKBMODE, &priv->kbdtrans);
+ if (tcgetattr(priv->fd, &priv->kbdtty) < 0)
+ FATAL1("kbdLinuxInit: tcgetattr failed (%s)\n", strerror(errno));
+}
+
+static int kbdLinuxPrefix0Mapping(unsigned char *scanCode)
+{
+ /* Table from xfree86/common/xf86Events.c */
+ switch (*scanCode) {
+ case KEY_KP_7: *scanCode = KEY_Home; break; /* curs home */
+ case KEY_KP_8: *scanCode = KEY_Up; break; /* curs up */
+ case KEY_KP_9: *scanCode = KEY_PgUp; break; /* curs pgup */
+ case KEY_KP_4: *scanCode = KEY_Left; break; /* curs left */
+ case KEY_KP_5: *scanCode = KEY_Begin; break; /* curs begin */
+ case KEY_KP_6: *scanCode = KEY_Right; break; /* curs right */
+ case KEY_KP_1: *scanCode = KEY_End; break; /* curs end */
+ case KEY_KP_2: *scanCode = KEY_Down; break; /* curs down */
+ case KEY_KP_3: *scanCode = KEY_PgDown; break; /* curs pgdown */
+ case KEY_KP_0: *scanCode = KEY_Insert; break; /* curs insert */
+ case KEY_KP_Decimal: *scanCode = KEY_Delete; break; /* curs delete */
+ case KEY_Enter: *scanCode = KEY_KP_Enter; break; /* keypad enter */
+ case KEY_LCtrl: *scanCode = KEY_RCtrl; break; /* right ctrl */
+ case KEY_KP_Multiply: *scanCode = KEY_Print; break; /* print */
+ case KEY_Slash: *scanCode = KEY_KP_Divide; break; /* keyp divide */
+ case KEY_Alt: *scanCode = KEY_AltLang; break; /* right alt */
+ case KEY_ScrollLock: *scanCode = KEY_Break; break; /* curs break */
+ case 0x5b: *scanCode = KEY_LMeta; break;
+ case 0x5c: *scanCode = KEY_RMeta; break;
+ case 0x5d: *scanCode = KEY_Menu; break;
+ case KEY_F3: *scanCode = KEY_F13; break;
+ case KEY_F4: *scanCode = KEY_F14; break;
+ case KEY_F5: *scanCode = KEY_F15; break;
+ case KEY_F6: *scanCode = KEY_F16; break;
+ case KEY_F7: *scanCode = KEY_F17; break;
+ case KEY_KP_Plus: *scanCode = KEY_KP_DEC; break;
+ /*
+ * Ignore virtual shifts (E0 2A, E0 AA, E0 36, E0 B6)
+ */
+ case 0x2A:
+ case 0x36:
+ return 1;
+ default:
+ /*
+ * "Internet" keyboards are generating lots of new codes.
+ * Let them pass. There is little consistency between them,
+ * so don't bother with symbolic names at this level.
+ */
+ scanCode += 0x78;
+ }
+ return 0;
+}
+
+static int kbdLinuxPrefixMapping(myPrivate *priv, unsigned char *scanCode)
+{
+ int pressed = *scanCode & 0x80;
+ unsigned char code = *scanCode & 0x7f;
+
+ /* If we don't have a prefix, check for one */
+ if (!priv->prefix) {
+ switch (code) {
+ case KEY_Prefix0:
+ case KEY_Prefix1:
+ priv->prefix = code;
+ return 1;
+ }
+ return 0; /* No change */
+ }
+
+ /* We have a prefix from the last scanCode */
+ switch (priv->prefix) {
+ case KEY_Prefix0:
+ priv->prefix = 0;
+ if (kbdLinuxPrefix0Mapping(&code)) return 1; /* Skip sequence */
+ break;
+ case KEY_Prefix1:
+ priv->prefix = (code = KEY_LCtrl) ? KEY_LCtrl : 0;
+ return 1; /* Use new prefix */
+ case KEY_LCtrl:
+ priv->prefix = 0;
+ if (code != KEY_NumLock) return 1; /* Skip sequence*/
+ code = KEY_Pause;
+ break;
+ }
+
+ *scanCode = code | (pressed ? 0x80 : 0x00);
+ return 0; /* Use old scanCode */
+}
+
+static void kbdLinuxConvert(DevicePtr pDev,
+ unsigned char scanCode,
+ ENQUEUEPROC enqueue,
+ CHECKPROC checkspecial,
+ BLOCK block)
+{
+ GETPRIV;
+ KeySymsPtr pKeySyms = &priv->pKeyboard->key->curKeySyms;
+ int type;
+ KeySym keySym = NoSymbol;
+ int keyCode;
+ int switching;
+
+ /* Do special PC/AT prefix mapping -- may change scanCode! */
+ if (kbdLinuxPrefixMapping(priv, &scanCode)) return;
+
+ type = (scanCode & 0x80) ? KeyRelease : KeyPress;
+ keyCode = (scanCode & 0x7f) + MIN_KEYCODE;
+
+ /* Handle repeats */
+
+ if (keyCode >= pKeySyms->minKeyCode && keyCode <= pKeySyms->maxKeyCode) {
+ keySym = pKeySyms->map[(keyCode - pKeySyms->minKeyCode)
+ * pKeySyms->mapWidth];
+#if 0
+ switch (keySym) {
+ case XK_Num_Lock:
+ case XK_Scroll_Lock:
+ case XK_Shift_Lock:
+ case XK_Caps_Lock:
+ /* Ignore releases and all but first press */
+ if (kbdLinuxModIgnore(priv, &xE, keySym)) return;
+ if (kbdLinuxKeyDown(priv, &xE)) xE.u.u.type = KeyRelease;
+ else xE.u.u.type = KeyPress;
+ break;
+ }
+#endif
+
+ /* If key is already down, ignore or autorepeat */
+ if (type == KeyPress && kbdLinuxKeyDown(priv, keyCode)) {
+ KbdFeedbackClassRec *feed = priv->pKeyboard->kbdfeed;
+
+ /* No auto-repeat? */
+ if ((feed && !feed->ctrl.autoRepeat)
+ || priv->pKeyboard->key->modifierMap[keyCode]
+ || (feed
+ && !(feed->ctrl.autoRepeats[keyCode >> 3]
+ & (1 << (keyCode & 7))))) return; /* Ignore */
+
+ /* Do auto-repeat */
+ enqueue(pDev, KeyRelease, keyCode, keySym, NULL, block);
+ type = KeyPress;
+ }
+
+ /* If key is already up, ignore */
+ if (type == KeyRelease && !kbdLinuxKeyDown(priv, keyCode)) return;
+ }
+
+ switching = 0;
+ if (checkspecial && type == KeyPress)
+ switching = checkspecial(pDev, keySym);
+ if (!switching) {
+ if (enqueue)
+ enqueue(pDev, type, keyCode, keySym, NULL, block);
+ kbdLinuxKeyState(priv, type, keyCode); /* Update our state bitmap */
+ }
+}
+
+/** Read an event from the \a pDev device. If the event is a motion
+ * event, enqueue it with the \a motion function. Otherwise, check for
+ * special keys with the \a checkspecial function and enqueue the event
+ * with the \a enqueue function. The \a block type is passed to the
+ * functions so that they may block SIGIO handling as appropriate to the
+ * caller of this function. */
+void kbdLinuxRead(DevicePtr pDev,
+ MOTIONPROC motion,
+ ENQUEUEPROC enqueue,
+ CHECKPROC checkspecial,
+ BLOCK block)
+{
+ GETPRIV;
+ unsigned char buf[256]; /* RATS: Only used in length-limited call */
+ unsigned char *pt;
+ int n;
+
+ while ((n = read(priv->fd, buf, sizeof(buf))) > 0)
+ for (pt = buf; n; --n, ++pt)
+ kbdLinuxConvert(pDev, *pt, enqueue, checkspecial, block);
+}
+
+/** Turn \a pDev on (i.e., take input from \a pDev). */
+int kbdLinuxOn(DevicePtr pDev)
+{
+ GETPRIV;
+ struct termios nTty;
+
+ ioctl(priv->fd, KDSKBMODE, K_RAW);
+
+ nTty = priv->kbdtty;
+ nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME] = 0;
+ nTty.c_cc[VMIN] = 1;
+ cfsetispeed(&nTty, B9600);
+ cfsetospeed(&nTty, B9600);
+ if (tcsetattr(priv->fd, TCSANOW, &nTty) < 0)
+ FATAL1("kbdLinuxOn: tcsetattr failed (%s)\n", strerror(errno));
+ return priv->fd;
+}
+
+/** Turn \a pDev off (i.e., stop taking input from \a pDev). */
+void kbdLinuxOff(DevicePtr pDev)
+{
+ GETPRIV;
+
+ ioctl(priv->fd, KDSKBMODE, priv->kbdtrans);
+ tcsetattr(priv->fd, TCSANOW, &priv->kbdtty);
+ kbdLinuxCloseConsole(pDev);
+}
+
+
+static void kbdLinuxReadKernelMapping(int fd, KeySymsPtr pKeySyms)
+{
+ KeySym *k;
+ int i;
+ int maxkey;
+ static unsigned char tbl[GLYPHS_PER_KEY] = { /* RATS: Use ok */
+ 0, /* unshifted */
+ 1, /* shifted */
+ 0, /* modeswitch unshifted */
+ 0 /* modeswitch shifted */
+ };
+
+ /*
+ * Read the mapping from the kernel.
+ * Since we're still using the XFree86 scancode->AT keycode mapping
+ * routines, we need to convert the AT keycodes to Linux keycodes,
+ * then translate the Linux keysyms into X keysyms.
+ *
+ * First, figure out which tables to use for the modeswitch columns
+ * above, from the XF86Config fields.
+ */
+ tbl[2] = 8; /* alt */
+ tbl[3] = tbl[2] | 1;
+
+ k = map+GLYPHS_PER_KEY;
+ maxkey = NUM_AT2LNX;
+
+ for (i = 0; i < maxkey; ++i) {
+ struct kbentry kbe;
+ int j;
+
+ kbe.kb_index = at2lnx[i];
+
+ for (j = 0; j < GLYPHS_PER_KEY; ++j, ++k) {
+ unsigned short kval;
+
+ *k = NoSymbol;
+
+ kbe.kb_table = tbl[j];
+ if (kbe.kb_index == 0 || ioctl(fd, KDGKBENT, &kbe)) continue;
+
+ kval = KVAL(kbe.kb_value);
+ switch (KTYP(kbe.kb_value)) {
+ case KT_LATIN:
+ case KT_LETTER: *k = linux_to_x[kval]; break;
+ case KT_FN:
+ if (kval <= 19) *k = XK_F1 + kval;
+ else switch (kbe.kb_value) {
+ case K_FIND: *k = XK_Home; /* or XK_Find */ break;
+ case K_INSERT: *k = XK_Insert; break;
+ case K_REMOVE: *k = XK_Delete; break;
+ case K_SELECT: *k = XK_End; /* or XK_Select */ break;
+ case K_PGUP: *k = XK_Prior; break;
+ case K_PGDN: *k = XK_Next; break;
+ case K_HELP: *k = XK_Help; break;
+ case K_DO: *k = XK_Execute; break;
+ case K_PAUSE: *k = XK_Pause; break;
+ case K_MACRO: *k = XK_Menu; break;
+ default: break;
+ }
+ break;
+ case KT_SPEC:
+ switch (kbe.kb_value) {
+ case K_ENTER: *k = XK_Return; break;
+ case K_BREAK: *k = XK_Break; break;
+ case K_CAPS: *k = XK_Caps_Lock; break;
+ case K_NUM: *k = XK_Num_Lock; break;
+ case K_HOLD: *k = XK_Scroll_Lock; break;
+ case K_COMPOSE: *k = XK_Multi_key; break;
+ default: break;
+ }
+ break;
+ case KT_PAD:
+ switch (kbe.kb_value) {
+ case K_PPLUS: *k = XK_KP_Add; break;
+ case K_PMINUS: *k = XK_KP_Subtract; break;
+ case K_PSTAR: *k = XK_KP_Multiply; break;
+ case K_PSLASH: *k = XK_KP_Divide; break;
+ case K_PENTER: *k = XK_KP_Enter; break;
+ case K_PCOMMA: *k = XK_KP_Separator; break;
+ case K_PDOT: *k = XK_KP_Decimal; break;
+ case K_PPLUSMINUS: *k = XK_KP_Subtract; break;
+ default: if (kval <= 9) *k = XK_KP_0 + kval; break;
+ }
+ break;
+ case KT_DEAD:
+ /* KT_DEAD keys are for accelerated diacritical creation. */
+ switch (kbe.kb_value) {
+ case K_DGRAVE: *k = XK_dead_grave; break;
+ case K_DACUTE: *k = XK_dead_acute; break;
+ case K_DCIRCM: *k = XK_dead_circumflex; break;
+ case K_DTILDE: *k = XK_dead_tilde; break;
+ case K_DDIERE: *k = XK_dead_diaeresis; break;
+ }
+ break;
+ case KT_CUR:
+ switch (kbe.kb_value) {
+ case K_DOWN: *k = XK_Down; break;
+ case K_LEFT: *k = XK_Left; break;
+ case K_RIGHT: *k = XK_Right; break;
+ case K_UP: *k = XK_Up; break;
+ }
+ break;
+ case KT_SHIFT:
+ switch (kbe.kb_value) {
+ case K_ALTGR: *k = XK_Alt_R; break;
+ case K_ALT:
+ *k = (kbe.kb_index == 0x64 ? XK_Alt_R : XK_Alt_L);
+ break;
+ case K_CTRL:
+ *k = (kbe.kb_index == 0x61 ? XK_Control_R : XK_Control_L);
+ break;
+ case K_CTRLL: *k = XK_Control_L; break;
+ case K_CTRLR: *k = XK_Control_R; break;
+ case K_SHIFT:
+ *k = (kbe.kb_index == 0x36 ? XK_Shift_R : XK_Shift_L);
+ break;
+ case K_SHIFTL: *k = XK_Shift_L; break;
+ case K_SHIFTR: *k = XK_Shift_R; break;
+ default: break;
+ }
+ break;
+ case KT_ASCII:
+ /* KT_ASCII keys accumulate a 3 digit decimal number that
+ * gets emitted when the shift state changes. We can't
+ * emulate that.
+ */
+ break;
+ case KT_LOCK:
+ if (kbe.kb_value == K_SHIFTLOCK) *k = XK_Shift_Lock;
+ break;
+ default: break;
+ }
+ }
+
+ if (k[-1] == k[-2]) k[-1] = NoSymbol;
+ if (k[-2] == k[-3]) k[-2] = NoSymbol;
+ if (k[-3] == k[-4]) k[-3] = NoSymbol;
+ if (k[-4] == k[-2] && k[-3] == k[-1]) k[-2] = k[-1] = NoSymbol;
+ if (k[-1] == k[-4] && k[-2] == k[-3]
+ && k[-2] == NoSymbol) k[-1] = NoSymbol;
+ }
+}
+
+static void kbdLinuxGetMap(DevicePtr pDev, KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ GETPRIV;
+ KeySym *k, *mapCopy;
+ char type;
+ int i;
+
+ mapCopy = xalloc(sizeof(map));
+ memcpy(mapCopy, map, sizeof(map));
+
+ kbdLinuxReadKernelMapping(priv->fd, pKeySyms);
+
+ /* compute the modifier map */
+ for (i = 0; i < MAP_LENGTH; i++)
+ pModMap[i] = NoSymbol; /* make sure it is restored */
+
+ for (k = mapCopy, i = MIN_KEYCODE;
+ i < NUM_KEYCODES + MIN_KEYCODE;
+ i++, k += 4) {
+ switch(*k) {
+ case XK_Shift_L:
+ case XK_Shift_R: pModMap[i] = ShiftMask; break;
+ case XK_Control_L:
+ case XK_Control_R: pModMap[i] = ControlMask; break;
+ case XK_Caps_Lock: pModMap[i] = LockMask; break;
+ case XK_Alt_L:
+ case XK_Alt_R: pModMap[i] = AltMask; break;
+ case XK_Num_Lock: pModMap[i] = NumLockMask; break;
+ case XK_Scroll_Lock: pModMap[i] = ScrollLockMask; break;
+ case XK_Kana_Lock:
+ case XK_Kana_Shift: pModMap[i] = KanaMask; break;
+ case XK_Mode_switch: pModMap[i] = AltLangMask; break;
+ }
+ }
+
+ priv->kbdType = (ioctl(priv->fd, KDGKBTYPE, &type) < 0) ? KB_101 : type;
+
+ pKeySyms->map = mapCopy; /* Must be XFree'able */
+ pKeySyms->mapWidth = GLYPHS_PER_KEY;
+ pKeySyms->minKeyCode = MIN_KEYCODE;
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
+}
+
+/** Fill the \a info structure with information needed to initialize \a
+ * pDev. */
+void kbdLinuxGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ info->keyboard = 1;
+ info->keyClass = 1;
+ kbdLinuxGetMap(pDev, &info->keySyms, info->modMap);
+ info->focusClass = 1;
+ info->kbdFeedbackClass = 1;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/lnx-keyboard.h b/nx-X11/programs/Xserver/hw/dmx/input/lnx-keyboard.h
new file mode 100644
index 000000000..8f7129048
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/lnx-keyboard.h
@@ -0,0 +1,64 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to Linux keyboard driver. \see lnx-keyboard.c */
+
+#ifndef _LNX_KEYBOARD_H_
+#define _LNX_KEYBOARD_H_
+
+extern pointer kbdLinuxCreatePrivate(DeviceIntPtr pKeyboard);
+extern void kbdLinuxDestroyPrivate(pointer private);
+
+extern void kbdLinuxInit(DevicePtr pDev);
+extern void kbdLinuxGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
+extern int kbdLinuxOn(DevicePtr pDev);
+extern void kbdLinuxOff(DevicePtr pDev);
+
+extern void kbdLinuxVTPreSwitch(pointer p);
+extern void kbdLinuxVTPostSwitch(pointer p);
+extern int kbdLinuxVTSwitch(pointer p, int vt,
+ dmxVTSwitchReturnProcPtr switch_return,
+ pointer switch_return_data);
+
+extern void kbdLinuxRead(DevicePtr pDev,
+ dmxMotionProcPtr motion,
+ dmxEnqueueProcPtr enqueue,
+ dmxCheckSpecialProcPtr checkspecial,
+ DMXBlockType block);
+
+extern void kbdLinuxCtrl(DevicePtr pDev, KeybdCtrl *ctrl);
+extern void kbdLinuxBell(DevicePtr pDev, int percent,
+ int volume, int pitch, int duration);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/lnx-ms.c b/nx-X11/programs/Xserver/hw/dmx/input/lnx-ms.c
new file mode 100644
index 000000000..6df4e80d3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/lnx-ms.c
@@ -0,0 +1,323 @@
+/* $XFree86$ */
+/* Portions of this file were derived from the following files:
+ *
+ **********************************************************************
+ *
+ * Xserver/hw/kdrive/linux/ms.c
+ *
+ * Copyright (c) 2001 by Juliusz Chroboczek
+ * Copyright (c) 1999 by Keith Packard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * This code implements a low-level device driver for a serial MS mouse.
+ * The code is derived from code by Juliusz Chroboczek and Keith Packard
+ * (see the source code for complete references). */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "inputstr.h"
+#include <X11/Xos.h>
+#include <errno.h>
+#include <termios.h>
+
+/*****************************************************************************/
+/* Define some macros to make it easier to move this file to another
+ * part of the Xserver tree. All calls to the dmx* layer are #defined
+ * here for the .c file. The .h file will also have to be edited. */
+#include "dmxinputinit.h"
+#include "lnx-ms.h"
+
+#define GETPRIV myPrivate *priv \
+ = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
+
+#define LOG0(f) dmxLog(dmxDebug,f)
+#define LOG1(f,a) dmxLog(dmxDebug,f,a)
+#define LOG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define FATAL0(f) dmxLog(dmxFatal,f)
+#define FATAL1(f,a) dmxLog(dmxFatal,f,a)
+#define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b)
+#define MOTIONPROC dmxMotionProcPtr
+#define ENQUEUEPROC dmxEnqueueProcPtr
+#define CHECKPROC dmxCheckSpecialProcPtr
+#define BLOCK DMXBlockType
+
+/* End of interface definitions. */
+/*****************************************************************************/
+
+/* Private area for MS mouse devices. */
+typedef struct _myPrivate {
+ DeviceIntPtr pMouse;
+ int fd;
+ struct termios tty;
+ enum {
+ button1 = 0x0001,
+ button2 = 0x0002,
+ button3 = 0x0004,
+ button4 = 0x0008,
+ button5 = 0x0010
+ } buttons;
+} myPrivate;
+
+static int msLinuxReadBytes(int fd, unsigned char *buf, int len, int min)
+{
+ int n, tot;
+ fd_set set;
+ struct timeval tv;
+
+ tot = 0;
+ while (len) {
+ n = read(fd, buf, len);
+ if (n > 0) {
+ tot += n;
+ buf += n;
+ len -= n;
+ }
+ if (tot % min == 0) break;
+ FD_ZERO(&set);
+ FD_SET(fd, &set);
+ tv.tv_sec = 0;
+ tv.tv_usec = 100 * 1000;
+ n = select(fd + 1, &set, 0, 0, &tv);
+ if (n <= 0) break;
+ }
+ return tot;
+}
+
+static void msLinuxButton(DevicePtr pDev, ENQUEUEPROC enqueue, int buttons,
+ BLOCK block)
+{
+ GETPRIV;
+
+#define PRESS(b) \
+ do { \
+ enqueue(pDev, ButtonPress, 0, 0, NULL, block); \
+ } while (0)
+
+#define RELEASE(b) \
+ do { \
+ enqueue(pDev, ButtonRelease, 0, 0, NULL, block); \
+ } while (0)
+
+ if ((buttons & button1) && !(priv->buttons & button1)) PRESS(1);
+ if (!(buttons & button1) && (priv->buttons & button1)) RELEASE(1);
+
+ if ((buttons & button2) && !(priv->buttons & button2)) PRESS(2);
+ if (!(buttons & button2) && (priv->buttons & button2)) RELEASE(2);
+
+ if ((buttons & button3) && !(priv->buttons & button3)) PRESS(3);
+ if (!(buttons & button3) && (priv->buttons & button3)) RELEASE(3);
+
+ if ((buttons & button4) && !(priv->buttons & button4)) PRESS(4);
+ if (!(buttons & button4) && (priv->buttons & button4)) RELEASE(4);
+
+ if ((buttons & button5) && !(priv->buttons & button5)) PRESS(5);
+ if (!(buttons & button5) && (priv->buttons & button5)) RELEASE(5);
+
+ priv->buttons = buttons;
+}
+
+/** Read an event from the \a pDev device. If the event is a motion
+ * event, enqueue it with the \a motion function. Otherwise, check for
+ * special keys with the \a checkspecial function and enqueue the event
+ * with the \a enqueue function. The \a block type is passed to the
+ * functions so that they may block SIGIO handling as appropriate to the
+ * caller of this function. */
+void msLinuxRead(DevicePtr pDev,
+ MOTIONPROC motion,
+ ENQUEUEPROC enqueue,
+ CHECKPROC checkspecial,
+ BLOCK block)
+{
+ GETPRIV;
+ unsigned char buf[3 * 200]; /* RATS: Use ok */
+ unsigned char *b;
+ int n;
+ int dx, dy, v[2];
+
+ while ((n = msLinuxReadBytes(priv->fd, buf, sizeof(buf), 3)) > 0) {
+ b = buf;
+ while (n >= 3) {
+ dx = (char)(((b[0] & 0x03) << 6) | (b[1] & 0x3f));
+ dy = (char)(((b[0] & 0x0c) << 4) | (b[2] & 0x3f));
+ v[0] = -dx;
+ v[1] = -dy;
+
+ motion(pDev, v, 0, 2, 1, block);
+ msLinuxButton(pDev, enqueue, (((b[0] & 0x10) ? button3 : 0)
+ | ((b[0] & 0x20) ? button1 : 0)),
+ block);
+ n -= 3;
+ b += 3;
+ }
+ }
+}
+
+/** Initialize \a pDev. */
+void msLinuxInit(DevicePtr pDev)
+{
+ GETPRIV;
+ const char *names[] = { "/dev/serialmouse", "/dev/mouse", NULL };
+ int i;
+
+ if (priv->fd >=0) return;
+
+ for (i = 0; names[i]; i++) {
+ if ((priv->fd = open(names[i], O_RDWR | O_NONBLOCK, 0)) >= 0) break;
+ }
+ if (priv->fd < 0)
+ FATAL1("msLinuxInit: Cannot open mouse port (%s)\n",
+ strerror(errno));
+
+ if (!isatty(priv->fd))
+ FATAL1("msLinuxInit: Mouse port %s is not a tty\n", names[i]);
+
+ if (tcgetattr(priv->fd, &priv->tty) < 0)
+ FATAL1("msLinuxInit: tcgetattr failed (%s)\n", strerror(errno));
+
+ write(priv->fd, "*n", 2); /* 1200 baud */
+ usleep(100000);
+}
+
+/** Turn \a pDev on (i.e., take input from \a pDev). */
+int msLinuxOn(DevicePtr pDev)
+{
+ GETPRIV;
+ struct termios nTty;
+
+ if (priv->fd < 0) msLinuxInit(pDev);
+
+ nTty = priv->tty;
+ nTty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR
+ | IGNCR | ICRNL | IXON | IXOFF);
+ nTty.c_oflag &= ~OPOST;
+ nTty.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
+ nTty.c_cflag &= ~(CSIZE | PARENB);
+ nTty.c_cflag |= CS8 | CLOCAL | CSTOPB;
+ nTty.c_cc[VTIME] = 0;
+ nTty.c_cc[VMIN] = 1;
+ cfsetispeed (&nTty, B1200);
+ cfsetospeed (&nTty, B1200);
+ if (tcsetattr(priv->fd, TCSANOW, &nTty) < 0)
+ FATAL1("msLinuxInit: tcsetattr failed (%s)\n", strerror(errno));
+ write(priv->fd, "*V", 2); /* 2 button 3 byte protocol */
+ return priv->fd;
+}
+
+/** Turn \a pDev off (i.e., stop taking input from \a pDev). */
+void msLinuxOff(DevicePtr pDev)
+{
+ GETPRIV;
+
+ tcsetattr(priv->fd, TCSANOW, &priv->tty);
+ close(priv->fd);
+ priv->fd = -1;
+}
+
+static void msLinuxGetMap(DevicePtr pDev, unsigned char *map, int *nButtons)
+{
+ int i;
+
+ if (nButtons) *nButtons = 3;
+ if (map) for (i = 0; i <= *nButtons; i++) map[i] = i;
+}
+
+/** Currently unused hook called prior to an VT switch. */
+void msLinuxVTPreSwitch(pointer p)
+{
+}
+
+/** Currently unused hook called after returning from a VT switch. */
+void msLinuxVTPostSwitch(pointer p)
+{
+}
+
+/** Create a private structure for use within this file. */
+pointer msLinuxCreatePrivate(DeviceIntPtr pMouse)
+{
+ myPrivate *priv = xalloc(sizeof(*priv));
+ memset(priv, 0, sizeof(*priv));
+ priv->fd = -1;
+ priv->pMouse = pMouse;
+ return priv;
+}
+
+/** Destroy a private structure. */
+void msLinuxDestroyPrivate(pointer priv)
+{
+ if (priv) xfree(priv);
+}
+
+/** Fill the \a info structure with information needed to initialize \a
+ * pDev. */
+void msLinuxGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ info->buttonClass = 1;
+ msLinuxGetMap(pDev, info->map, &info->numButtons);
+ info->valuatorClass = 1;
+ info->numRelAxes = 2;
+ info->minval[0] = 0;
+ info->maxval[0] = 0;
+ info->res[0] = 1;
+ info->minres[0] = 0;
+ info->maxres[0] = 1;
+ info->ptrFeedbackClass = 1;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/lnx-ms.h b/nx-X11/programs/Xserver/hw/dmx/input/lnx-ms.h
new file mode 100644
index 000000000..bc744431a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/lnx-ms.h
@@ -0,0 +1,56 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to Linux MS mouse driver. \see lnx-ms.c */
+
+#ifndef _LNX_MS_H_
+#define _LNX_MS_H_
+
+extern pointer msLinuxCreatePrivate(DeviceIntPtr pMouse);
+extern void msLinuxDestroyPrivate(pointer priv);
+extern void msLinuxRead(DevicePtr pDev,
+ dmxMotionProcPtr motion,
+ dmxEnqueueProcPtr enqueue,
+ dmxCheckSpecialProcPtr checkspecial,
+ DMXBlockType block);
+extern void msLinuxInit(DevicePtr pDev);
+extern void msLinuxGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
+extern int msLinuxOn(DevicePtr pDev);
+extern void msLinuxOff(DevicePtr pDev);
+extern void msLinuxCtrl(DevicePtr pDev, PtrCtrl *ctrl);
+extern void msLinuxVTPreSwitch(pointer p);
+extern void msLinuxVTPostSwitch(pointer p);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/lnx-ps2.c b/nx-X11/programs/Xserver/hw/dmx/input/lnx-ps2.c
new file mode 100644
index 000000000..0c5b870aa
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/lnx-ps2.c
@@ -0,0 +1,291 @@
+/* $XFree86$ */
+/* Portions of this file were derived from the following files:
+ *
+ **********************************************************************
+ *
+ * Xserver/hw/kdrive/linux/ps2.c
+ *
+ * Copyright (c) 1999 by Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/*
+ * Copyright 2001,2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * This code implements a low-level device driver for a serial MS mouse.
+ * The code is derived from code by Keith Packard (see the source code
+ * for complete references). */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "inputstr.h"
+#include <X11/Xos.h>
+#include <errno.h>
+#include <termios.h>
+
+/*****************************************************************************/
+/* Define some macros to make it easier to move this file to another
+ * part of the Xserver tree. All calls to the dmx* layer are #defined
+ * here for the .c file. The .h file will also have to be edited. */
+#include "dmxinputinit.h"
+#include "lnx-ps2.h"
+
+#define GETPRIV myPrivate *priv \
+ = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
+
+#define LOG0(f) dmxLog(dmxDebug,f)
+#define LOG1(f,a) dmxLog(dmxDebug,f,a)
+#define LOG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define FATAL0(f) dmxLog(dmxFatal,f)
+#define FATAL1(f,a) dmxLog(dmxFatal,f,a)
+#define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b)
+#define MOTIONPROC dmxMotionProcPtr
+#define ENQUEUEPROC dmxEnqueueProcPtr
+#define CHECKPROC dmxCheckSpecialProcPtr
+#define BLOCK DMXBlockType
+
+/* End of interface definitions. */
+/*****************************************************************************/
+
+/* Private area for PS/2 devices. */
+typedef struct _myPrivate {
+ DeviceIntPtr pMouse;
+ int fd;
+ enum {
+ button1 = 0x0001,
+ button2 = 0x0002,
+ button3 = 0x0004,
+ button4 = 0x0008,
+ button5 = 0x0010
+ } buttons;
+} myPrivate;
+
+static int ps2LinuxReadBytes(int fd, unsigned char *buf, int len, int min)
+{
+ int n, tot;
+ fd_set set;
+ struct timeval tv;
+
+ tot = 0;
+ while (len) {
+ n = read(fd, buf, len);
+ if (n > 0) {
+ tot += n;
+ buf += n;
+ len -= n;
+ }
+ if (tot % min == 0) break;
+ FD_ZERO(&set);
+ FD_SET(fd, &set);
+ tv.tv_sec = 0;
+ tv.tv_usec = 100 * 1000;
+ n = select(fd + 1, &set, 0, 0, &tv);
+ if (n <= 0) break;
+ }
+ return tot;
+}
+
+static void ps2LinuxButton(DevicePtr pDev, ENQUEUEPROC enqueue,
+ int buttons, BLOCK block)
+{
+ GETPRIV;
+
+#define PRESS(b) \
+ do { \
+ enqueue(pDev, ButtonPress, 0, 0, NULL, block); \
+ } while (0)
+
+#define RELEASE(b) \
+ do { \
+ enqueue(pDev, ButtonRelease, 0, 0, NULL, block); \
+ } while (0)
+
+ if ((buttons & button1) && !(priv->buttons & button1)) PRESS(1);
+ if (!(buttons & button1) && (priv->buttons & button1)) RELEASE(1);
+
+ if ((buttons & button2) && !(priv->buttons & button2)) PRESS(2);
+ if (!(buttons & button2) && (priv->buttons & button2)) RELEASE(2);
+
+ if ((buttons & button3) && !(priv->buttons & button3)) PRESS(3);
+ if (!(buttons & button3) && (priv->buttons & button3)) RELEASE(3);
+
+ if ((buttons & button4) && !(priv->buttons & button4)) PRESS(4);
+ if (!(buttons & button4) && (priv->buttons & button4)) RELEASE(4);
+
+ if ((buttons & button5) && !(priv->buttons & button5)) PRESS(5);
+ if (!(buttons & button5) && (priv->buttons & button5)) RELEASE(5);
+
+ priv->buttons = buttons;
+}
+
+/** Read an event from the \a pDev device. If the event is a motion
+ * event, enqueue it with the \a motion function. Otherwise, check for
+ * special keys with the \a checkspecial function and enqueue the event
+ * with the \a enqueue function. The \a block type is passed to the
+ * functions so that they may block SIGIO handling as appropriate to the
+ * caller of this function. */
+void ps2LinuxRead(DevicePtr pDev, MOTIONPROC motion,
+ ENQUEUEPROC enqueue, CHECKPROC checkspecial, BLOCK block)
+{
+ GETPRIV;
+ unsigned char buf[3 * 200]; /* RATS: Use ok */
+ unsigned char *b;
+ int n;
+ int dx, dy, v[2];
+
+ while ((n = ps2LinuxReadBytes(priv->fd, buf, sizeof(buf), 3)) > 0) {
+ b = buf;
+ while (n >= 3) {
+ dx = b[1] - ((b[0] & 0x10) ? 256 : 0);
+ dy = -b[2] + ((b[0] & 0x20) ? 256 : 0);
+ v[0] = -dx;
+ v[1] = -dy;
+
+ motion(pDev, v, 0, 2, 1, block);
+ ps2LinuxButton(pDev, enqueue, (((b[0] & 4) ? button2 : 0)
+ | ((b[0] & 2) ? button3 : 0)
+ | ((b[0] & 1) ? button1 : 0)),
+ block);
+ n -= 3;
+ b += 3;
+ }
+ }
+}
+
+/** Initialize \a pDev. */
+void ps2LinuxInit(DevicePtr pDev)
+{
+ GETPRIV;
+ const char *names[] = { "/dev/mouse", "/dev/psaux", NULL };
+ int i;
+
+ if (priv->fd >=0) return;
+
+ for (i = 0; names[i]; i++) {
+ if ((priv->fd = open(names[i], O_RDWR | O_NONBLOCK, 0)) >= 0) break;
+ }
+ if (priv->fd < 0)
+ FATAL1("ps2LinuxInit: Cannot open mouse port (%s)\n",
+ strerror(errno));
+}
+
+/** Turn \a pDev on (i.e., take input from \a pDev). */
+int ps2LinuxOn(DevicePtr pDev)
+{
+ GETPRIV;
+
+ if (priv->fd < 0) ps2LinuxInit(pDev);
+ return priv->fd;
+}
+
+/** Turn \a pDev off (i.e., stop taking input from \a pDev). */
+void ps2LinuxOff(DevicePtr pDev)
+{
+ GETPRIV;
+
+ close(priv->fd);
+ priv->fd = -1;
+}
+
+static void ps2LinuxGetMap(DevicePtr pDev, unsigned char *map, int *nButtons)
+{
+ int i;
+
+ if (nButtons) *nButtons = 3;
+ if (map) for (i = 0; i <= *nButtons; i++) map[i] = i;
+}
+
+/** Currently unused hook called prior to an VT switch. */
+void ps2LinuxVTPreSwitch(pointer p)
+{
+}
+
+/** Currently unused hook called after returning from a VT switch. */
+void ps2LinuxVTPostSwitch(pointer p)
+{
+}
+
+/** Create a private structure for use within this file. */
+pointer ps2LinuxCreatePrivate(DeviceIntPtr pMouse)
+{
+ myPrivate *priv = xalloc(sizeof(*priv));
+ memset(priv, 0, sizeof(*priv));
+ priv->fd = -1;
+ priv->pMouse = pMouse;
+ return priv;
+}
+
+/** Destroy a private structure. */
+void ps2LinuxDestroyPrivate(pointer priv)
+{
+ if (priv) xfree(priv);
+}
+
+/** Fill the \a info structure with information needed to initialize \a
+ * pDev. */
+void ps2LinuxGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ info->buttonClass = 1;
+ ps2LinuxGetMap(pDev, info->map, &info->numButtons);
+ info->valuatorClass = 1;
+ info->numRelAxes = 2;
+ info->minval[0] = 0;
+ info->maxval[0] = 0;
+ info->res[0] = 1;
+ info->minres[0] = 0;
+ info->maxres[0] = 1;
+ info->ptrFeedbackClass = 1;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/lnx-ps2.h b/nx-X11/programs/Xserver/hw/dmx/input/lnx-ps2.h
new file mode 100644
index 000000000..e3d751e2f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/lnx-ps2.h
@@ -0,0 +1,56 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to Linux PS/2 mouse driver. \see lnx-ps2.c */
+
+#ifndef _LNX_PS2_H_
+#define _LNX_PS2_H_
+
+extern pointer ps2LinuxCreatePrivate(DeviceIntPtr pMouse);
+extern void ps2LinuxDestroyPrivate(pointer priv);
+extern void ps2LinuxRead(DevicePtr pDev,
+ dmxMotionProcPtr motion,
+ dmxEnqueueProcPtr enqueue,
+ dmxCheckSpecialProcPtr checkspecial,
+ DMXBlockType block);
+extern void ps2LinuxInit(DevicePtr pDev);
+extern void ps2LinuxGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
+extern int ps2LinuxOn(DevicePtr pDev);
+extern void ps2LinuxOff(DevicePtr pDev);
+extern void ps2LinuxCtrl(DevicePtr pDev, PtrCtrl *ctrl);
+extern void ps2LinuxVTPreSwitch(pointer p);
+extern void ps2LinuxVTPostSwitch(pointer p);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/usb-common.c b/nx-X11/programs/Xserver/hw/dmx/input/usb-common.c
new file mode 100644
index 000000000..a6fe7ad3b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/usb-common.c
@@ -0,0 +1,383 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * Routines that are common between #usb-keyboard.c, #usb-mouse.c, and
+ * #usb-other.c */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "usb-private.h"
+
+#define USB_COMMON_DEBUG 1
+
+/*****************************************************************************/
+/* Define some macros to make it easier to move this file to another
+ * part of the Xserver tree. All calls to the dmx* layer are #defined
+ * here for the .c file. The .h file will also have to be edited. */
+#include "usb-mouse.h"
+
+#define GETPRIV myPrivate *priv \
+ = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
+
+#define GETNAME ((DMXLocalInputInfoPtr)(pDevice->public.devicePrivate)) \
+ ->name
+
+#define LOG0(f) dmxLog(dmxDebug,f)
+#define LOG1(f,a) dmxLog(dmxDebug,f,a)
+#define LOG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define LOG1INPUT(p,f,a) dmxLogInput(p->dmxInput,f,a)
+#define LOG3INPUT(p,f,a,b,c) dmxLogInput(p->dmxInput,f,a,b,c)
+#define LOG5INPUT(p,f,a,b,c,d,e) dmxLogInput(p->dmxInput,f,a,b,c,d,e)
+#define FATAL0(f) dmxLog(dmxFatal,f)
+#define FATAL1(f,a) dmxLog(dmxFatal,f,a)
+#define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b)
+#define MOTIONPROC dmxMotionProcPtr
+#define ENQUEUEPROC dmxEnqueueProcPtr
+#define CHECKPROC dmxCheckSpecialProcPtr
+#define BLOCK DMXBlockType
+
+/* End of interface definitions. */
+/*****************************************************************************/
+
+
+/** Read an event from the \a pDev device. If the event is a motion
+ * event, enqueue it with the \a motion function. Otherwise, enqueue
+ * the event with the \a enqueue function. The \a block type is passed
+ * to the functions so that they may block SIGIO handling as appropriate
+ * to the caller of this function.
+ *
+ * Since USB devices return EV_KEY events for buttons and keys, \a
+ * minButton is used to decide if a Button or Key event should be
+ * queued.*/
+void usbRead(DevicePtr pDev,
+ MOTIONPROC motion,
+ ENQUEUEPROC enqueue,
+ int minButton,
+ BLOCK block)
+{
+ GETPRIV;
+ struct input_event raw;
+ int v[DMX_MAX_AXES];
+ int axis;
+
+#define PRESS(b) \
+ do { \
+ enqueue(pDev, ButtonPress, 0, 0, NULL, block); \
+ } while (0)
+
+#define RELEASE(b) \
+ do { \
+ enqueue(pDev, ButtonRelease, 0, 0, NULL, block); \
+ } while (0)
+
+ while (read(priv->fd, &raw, sizeof(raw)) > 0) {
+#if USB_COMMON_DEBUG > 1
+ LOG3("USB: type = %d, code = 0x%02x, value = %d\n",
+ raw.type, raw.code, raw.value);
+#endif
+ switch (raw.type) {
+ case EV_KEY:
+ /* raw.value = 1 for first, 2 for repeat */
+ if (raw.code > minButton) {
+ if (raw.value) PRESS((raw.code & 0x0f) + 1);
+ else RELEASE((raw.code & 0x0f) + 1);
+ } else {
+ enqueue(pDev, raw.value ? KeyPress : KeyRelease,
+ 0, 0, NULL, block);
+ }
+ break;
+ case EV_REL:
+ switch (raw.code) {
+ case REL_X:
+ v[0] = -raw.value;
+ v[1] = 0;
+ motion(pDev, v, 0, 2, DMX_RELATIVE, block);
+ break;
+ case REL_Y:
+ v[0] = 0;
+ v[1] = -raw.value;
+ motion(pDev, v, 0, 2, DMX_RELATIVE, block);
+ break;
+ case REL_WHEEL:
+ if ((int)raw.value > 0) {
+ PRESS(4);
+ RELEASE(4);
+ } else if ((int)raw.value < 0) {
+ PRESS(5);
+ RELEASE(5);
+ }
+ break;
+ default:
+ memset(v, 0, sizeof(v));
+ axis = priv->relmap[raw.code];
+ v[axis] = raw.value;
+ motion(pDev, v, axis, 1, DMX_RELATIVE, block);
+ }
+ break;
+ case EV_ABS:
+ memset(v, 0, sizeof(v));
+ axis = priv->absmap[raw.code];
+ v[axis] = raw.value;
+ motion(pDev, v, axis, 1, DMX_ABSOLUTE, block);
+ break;
+ }
+ }
+}
+
+#define test_bit(bit) (priv->mask[(bit)/8] & (1 << ((bit)%8)))
+#define test_bits(bit) (bits[(bit)/8] & (1 << ((bit)%8)))
+
+static void usbPrint(myPrivate *priv,
+ const char *filename, const char *devname, int fd)
+{
+ int j, k;
+ DeviceIntPtr pDevice = priv->pDevice;
+ unsigned char bits[KEY_MAX/8 + 1]; /* RATS: Use ok assuming that
+ * KEY_MAX is greater than
+ * REL_MAX, ABS_MAX, SND_MAX, and
+ * LED_MAX. */
+
+ LOG3INPUT(priv, "%s (%s) using %s\n", pDevice->name, GETNAME, filename);
+ LOG1INPUT(priv, " %s\n", devname);
+ for (j = 0; j < EV_MAX; j++) {
+ if (test_bit(j)) {
+ const char *type = "unknown";
+ char extra[256]; /* FIXME: may cause buffer overflow */
+ extra[0] = '\0';
+ switch(j) {
+ case EV_KEY: type = "keys/buttons"; break;
+ case EV_REL: type = "relative";
+ memset(bits, 0, sizeof(bits));
+ ioctl(priv->fd, EVIOCGBIT(EV_REL, sizeof(bits)), bits);
+ for (k = 0; k < REL_MAX; k++) {
+ if (test_bits(k)) switch (k) {
+ case REL_X: strcat(extra, " X"); break;
+ case REL_Y: strcat(extra, " Y"); break;
+ case REL_Z: strcat(extra, " Z"); break;
+ case REL_HWHEEL: strcat(extra, " HWheel"); break;
+ case REL_DIAL: strcat(extra, " Dial"); break;
+ case REL_WHEEL: strcat(extra, " Wheel"); break;
+ case REL_MISC: strcat(extra, " Misc"); break;
+ }
+ }
+ break;
+ case EV_ABS: type = "absolute";
+ memset(bits, 0, sizeof(bits));
+ ioctl(priv->fd, EVIOCGBIT(EV_ABS, sizeof(bits)), bits);
+ for (k = 0; k < ABS_MAX; k++) {
+ if (test_bits(k)) switch (k) {
+ case ABS_X: strcat(extra," X"); break;
+ case ABS_Y: strcat(extra," Y"); break;
+ case ABS_Z: strcat(extra," Z"); break;
+ case ABS_RX: strcat(extra," RX"); break;
+ case ABS_RY: strcat(extra," RY"); break;
+ case ABS_RZ: strcat(extra," RZ"); break;
+ case ABS_THROTTLE: strcat(extra," Throttle");break;
+ case ABS_RUDDER: strcat(extra," Rudder"); break;
+ case ABS_WHEEL: strcat(extra," Wheel"); break;
+ case ABS_GAS: strcat(extra," Gas"); break;
+ case ABS_BRAKE: strcat(extra," Break"); break;
+ case ABS_HAT0X: strcat(extra," Hat0X"); break;
+ case ABS_HAT0Y: strcat(extra," Hat0Y"); break;
+ case ABS_HAT1X: strcat(extra," Hat1X"); break;
+ case ABS_HAT1Y: strcat(extra," Hat1Y"); break;
+ case ABS_HAT2X: strcat(extra," Hat2X"); break;
+ case ABS_HAT2Y: strcat(extra," Hat2Y"); break;
+ case ABS_HAT3X: strcat(extra," Hat3X"); break;
+ case ABS_HAT3Y: strcat(extra," Hat3Y"); break;
+ case ABS_PRESSURE: strcat(extra," Pressure");break;
+ case ABS_DISTANCE: strcat(extra," Distance");break;
+ case ABS_TILT_X: strcat(extra," TiltX"); break;
+ case ABS_TILT_Y: strcat(extra," TiltY"); break;
+ case ABS_MISC: strcat(extra," Misc"); break;
+ }
+ }
+ break;
+ case EV_MSC: type = "reserved"; break;
+ case EV_LED: type = "leds";
+ memset(bits, 0, sizeof(bits));
+ ioctl(priv->fd, EVIOCGBIT(EV_LED, sizeof(bits)), bits);
+ for (k = 0; k < LED_MAX; k++) {
+ if (test_bits(k)) switch (k) {
+ case LED_NUML: strcat(extra," NumLock"); break;
+ case LED_CAPSL: strcat(extra," CapsLock"); break;
+ case LED_SCROLLL: strcat(extra," ScrlLock"); break;
+ case LED_COMPOSE: strcat(extra," Compose"); break;
+ case LED_KANA: strcat(extra," Kana"); break;
+ case LED_SLEEP: strcat(extra," Sleep"); break;
+ case LED_SUSPEND: strcat(extra," Suspend"); break;
+ case LED_MUTE: strcat(extra," Mute"); break;
+ case LED_MISC: strcat(extra," Misc"); break;
+ }
+ }
+ break;
+ case EV_SND: type = "sound";
+ memset(bits, 0, sizeof(bits));
+ ioctl(priv->fd, EVIOCGBIT(EV_SND, sizeof(bits)), bits);
+ for (k = 0; k < SND_MAX; k++) {
+ if (test_bits(k)) switch (k) {
+ case SND_CLICK: strcat(extra," Click"); break;
+ case SND_BELL: strcat(extra," Bell"); break;
+ }
+ }
+ break;
+ case EV_REP: type = "repeat"; break;
+ case EV_FF: type = "feedback"; break;
+ }
+ LOG5INPUT(priv, " Feature 0x%02x = %s%s%s%s\n", j, type,
+ extra[0] ? " [" : "",
+ extra[0] ? extra+1 : "",
+ extra[0] ? "]" : "");
+ }
+ }
+}
+
+/** Initialized \a pDev as a \a usbMouse, \a usbKeyboard, or \a usbOther
+device. */
+void usbInit(DevicePtr pDev, usbType type)
+{
+ GETPRIV;
+ char name[64]; /* RATS: Only used in XmuSnprintf */
+ int i, j, k;
+ char buf[256] = { 0, }; /* RATS: Use ok */
+ int version;
+ unsigned char bits[KEY_MAX/8 + 1]; /* RATS: Use ok assuming that
+ * KEY_MAX is greater than
+ * REL_MAX, ABS_MAX, SND_MAX, and
+ * LED_MAX. */
+
+ if (priv->fd >=0) return;
+
+ for (i = 0; i < 32; i++) {
+ XmuSnprintf(name, sizeof(name), "/dev/input/event%d", i);
+ if ((priv->fd = open(name, O_RDWR | O_NONBLOCK, 0)) >= 0) {
+ ioctl(priv->fd, EVIOCGVERSION, &version);
+ ioctl(priv->fd, EVIOCGNAME(sizeof(buf)), buf);
+ memset(priv->mask, 0, sizeof(priv->mask));
+ ioctl(priv->fd, EVIOCGBIT(0, sizeof(priv->mask)), priv->mask);
+
+ for (j = 0; j < EV_MAX; j++) {
+ if (test_bit(j)) {
+ switch(j) {
+ case EV_REL:
+ memset(bits, 0, sizeof(bits));
+ ioctl(priv->fd, EVIOCGBIT(EV_REL, sizeof(bits)), bits);
+ for (k = 0; k < REL_MAX; k++) {
+ if (test_bits(k)) {
+ if (k == REL_X) priv->relmap[k] = 0;
+ else if (k == REL_Y) priv->relmap[k] = 1;
+ else priv->relmap[k] = 2 + priv->numAbs;
+ ++priv->numRel;
+ }
+ }
+ break;
+ case EV_ABS:
+ memset(bits, 0, sizeof(bits));
+ ioctl(priv->fd, EVIOCGBIT(EV_ABS, sizeof(bits)), bits);
+ for (k = 0; k < ABS_MAX; k++) {
+ if (test_bits(k)) {
+ priv->absmap[k] = priv->numAbs;
+ ++priv->numAbs;
+ }
+ }
+ break;
+ case EV_LED:
+ memset(bits, 0, sizeof(bits));
+ ioctl(priv->fd, EVIOCGBIT(EV_LED, sizeof(bits)), bits);
+ for (k = 0; k < LED_MAX; k++) {
+ if (test_bits(k)) ++priv->numLeds;
+ }
+ break;
+ }
+ }
+ }
+ switch (type) {
+ case usbMouse:
+ if (test_bit(EV_REL) && test_bit(EV_KEY))
+ goto found;
+ break;
+ case usbKeyboard:
+ if (test_bit(EV_KEY) && test_bit(EV_LED) && !test_bit(EV_ABS))
+ goto found;
+ break;
+ case usbOther:
+ if (!(test_bit(EV_REL) && test_bit(EV_KEY))
+ && !(test_bit(EV_KEY) && test_bit(EV_LED)
+ && !test_bit(EV_ABS)))
+ goto found;
+ break;
+ }
+ close(priv->fd);
+ priv->fd = -1;
+ }
+ }
+ if (priv->fd < 0)
+ FATAL1("usbInit: Cannot open /dev/input/event* port (%s)\n"
+ " If you have not done so, you may need to:\n"
+ " rmmod mousedev; rmmod keybdev\n"
+ " modprobe evdev\n",
+ strerror(errno));
+ found:
+ usbPrint(priv, name, buf, priv->fd);
+}
+
+/** Turn \a pDev off (i.e., stop taking input from \a pDev). */
+void usbOff(DevicePtr pDev)
+{
+ GETPRIV;
+
+ if (priv->fd >= 0) close(priv->fd);
+ priv->fd = -1;
+}
+
+/** Create a private structure for use within this file. */
+pointer usbCreatePrivate(DeviceIntPtr pDevice)
+{
+ myPrivate *priv = xalloc(sizeof(*priv));
+ memset(priv, 0, sizeof(*priv));
+ priv->fd = -1;
+ priv->pDevice = pDevice;
+ return priv;
+}
+
+/** Destroy a private structure. */
+void usbDestroyPrivate(pointer priv)
+{
+ if (priv) xfree(priv);
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/usb-common.h b/nx-X11/programs/Xserver/hw/dmx/input/usb-common.h
new file mode 100644
index 000000000..768312990
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/usb-common.h
@@ -0,0 +1,56 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to common USB support. \see usb-common.c \see usb-mouse.c
+ * \see usb-keyboard.c \see usb-other.c */
+
+#ifndef _USB_COMMON_H_
+#define _USB_COMMON_H_
+typedef enum {
+ usbMouse,
+ usbKeyboard,
+ usbOther
+} usbType;
+
+extern pointer usbCreatePrivate(DeviceIntPtr pDevice);
+extern void usbDestroyPrivate(pointer priv);
+extern void usbRead(DevicePtr pDev,
+ dmxMotionProcPtr motion,
+ dmxEnqueueProcPtr enqueue,
+ int minButton,
+ DMXBlockType block);
+extern void usbInit(DevicePtr pDev, usbType type);
+extern void usbOff(DevicePtr pDev);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/usb-keyboard.c b/nx-X11/programs/Xserver/hw/dmx/input/usb-keyboard.c
new file mode 100644
index 000000000..4b9439603
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/usb-keyboard.c
@@ -0,0 +1,442 @@
+/* $XFree86$ */
+/* Portions of this file were derived from the following files:
+ *
+ **********************************************************************
+ *
+ * xfree86/common/xf86KbdLnx.c
+ *
+ * Linux version of keymapping setup. The kernel (since 0.99.14) has support
+ * for fully remapping the keyboard, but there are some differences between
+ * the Linux map and the SVR4 map (esp. in the extended keycodes). We also
+ * remove the restriction on what keycodes can be remapped.
+ * Orest Zborowski.
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/*
+ * Copyright 2001,2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * This code implements a low-level device driver for a USB keyboard
+ * under Linux. The keymap description is derived from code by Thomas
+ * Roell, Orest Zborowski. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "atKeynames.h"
+#include "usb-private.h"
+
+#define USB_KEYBOARD_DEBUG 0
+
+/*****************************************************************************/
+/* Define some macros to make it easier to move this file to another
+ * part of the Xserver tree. All calls to the dmx* layer are #defined
+ * here for the .c file. The .h file will also have to be edited. */
+#include "usb-keyboard.h"
+
+#define GETPRIV myPrivate *priv \
+ = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
+
+#define LOG0(f) dmxLog(dmxDebug,f)
+#define LOG1(f,a) dmxLog(dmxDebug,f,a)
+#define LOG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define FATAL0(f) dmxLog(dmxFatal,f)
+#define FATAL1(f,a) dmxLog(dmxFatal,f,a)
+#define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b)
+#define MOTIONPROC dmxMotionProcPtr
+#define ENQUEUEPROC dmxEnqueueProcPtr
+#define CHECKPROC dmxCheckSpecialProcPtr
+#define BLOCK DMXBlockType
+
+/* End of interface definitions. */
+/*****************************************************************************/
+
+#define GLYPHS_PER_KEY 4
+#define NUM_KEYCODES 248
+#define MIN_KEYCODE 8
+#define MAX_KEYCODE (NUM_KEYCODES + MIN_KEYCODE - 1)
+
+static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = {
+/* Table modified from xc/programs/Xserver/hw/xfree86/common/xf86Keymap.h */
+ /* 0x00 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x01 */ XK_Escape, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x02 */ XK_1, XK_exclam, NoSymbol, NoSymbol,
+ /* 0x03 */ XK_2, XK_at, NoSymbol, NoSymbol,
+ /* 0x04 */ XK_3, XK_numbersign, NoSymbol, NoSymbol,
+ /* 0x05 */ XK_4, XK_dollar, NoSymbol, NoSymbol,
+ /* 0x06 */ XK_5, XK_percent, NoSymbol, NoSymbol,
+ /* 0x07 */ XK_6, XK_asciicircum, NoSymbol, NoSymbol,
+ /* 0x08 */ XK_7, XK_ampersand, NoSymbol, NoSymbol,
+ /* 0x09 */ XK_8, XK_asterisk, NoSymbol, NoSymbol,
+ /* 0x0a */ XK_9, XK_parenleft, NoSymbol, NoSymbol,
+ /* 0x0b */ XK_0, XK_parenright, NoSymbol, NoSymbol,
+ /* 0x0c */ XK_minus, XK_underscore, NoSymbol, NoSymbol,
+ /* 0x0d */ XK_equal, XK_plus, NoSymbol, NoSymbol,
+ /* 0x0e */ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x0f */ XK_Tab, XK_ISO_Left_Tab,NoSymbol, NoSymbol,
+ /* 0x10 */ XK_Q, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x11 */ XK_W, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x12 */ XK_E, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x13 */ XK_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x14 */ XK_T, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x15 */ XK_Y, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x16 */ XK_U, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x17 */ XK_I, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x18 */ XK_O, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x19 */ XK_P, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1a */ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol,
+ /* 0x1b */ XK_bracketright,XK_braceright, NoSymbol, NoSymbol,
+ /* 0x1c */ XK_Return, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1d */ XK_Control_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1e */ XK_A, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1f */ XK_S, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x20 */ XK_D, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x21 */ XK_F, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x22 */ XK_G, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x23 */ XK_H, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x24 */ XK_J, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x25 */ XK_K, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x26 */ XK_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x27 */ XK_semicolon, XK_colon, NoSymbol, NoSymbol,
+ /* 0x28 */ XK_quoteright, XK_quotedbl, NoSymbol, NoSymbol,
+ /* 0x29 */ XK_quoteleft, XK_asciitilde, NoSymbol, NoSymbol,
+ /* 0x2a */ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2b */ XK_backslash, XK_bar, NoSymbol, NoSymbol,
+ /* 0x2c */ XK_Z, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2d */ XK_X, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2e */ XK_C, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2f */ XK_V, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x30 */ XK_B, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x31 */ XK_N, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x32 */ XK_M, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x33 */ XK_comma, XK_less, NoSymbol, NoSymbol,
+ /* 0x34 */ XK_period, XK_greater, NoSymbol, NoSymbol,
+ /* 0x35 */ XK_slash, XK_question, NoSymbol, NoSymbol,
+ /* 0x36 */ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x37 */ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x38 */ XK_Alt_L, XK_Meta_L, NoSymbol, NoSymbol,
+ /* 0x39 */ XK_space, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3a */ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3b */ XK_F1, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3c */ XK_F2, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3d */ XK_F3, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3e */ XK_F4, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3f */ XK_F5, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x40 */ XK_F6, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x41 */ XK_F7, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x42 */ XK_F8, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x43 */ XK_F9, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x44 */ XK_F10, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x45 */ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x46 */ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x47 */ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol,
+ /* 0x48 */ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol,
+ /* 0x49 */ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol,
+ /* 0x4a */ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4b */ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol,
+ /* 0x4c */ XK_KP_Begin, XK_KP_5, NoSymbol, NoSymbol,
+ /* 0x4d */ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol,
+ /* 0x4e */ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4f */ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol,
+ /* 0x50 */ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol,
+ /* 0x51 */ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol,
+ /* 0x52 */ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol,
+ /* 0x53 */ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol,
+ /* 0x54 */ XK_Sys_Req, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x55 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x56 */ XK_less, XK_greater, NoSymbol, NoSymbol,
+ /* 0x57 */ XK_F11, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x58 */ XK_F12, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x59 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5d */ XK_Begin, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x60 */ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x61 */ XK_Control_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x62 */ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x63 */ XK_Print, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x64 */ XK_Alt_R, XK_Meta_R, NoSymbol, NoSymbol,
+ /* 0x65 */ XK_Break, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x66 */ XK_Home, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x67 */ XK_Up, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x68 */ XK_Prior, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x69 */ XK_Left, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6a */ XK_Right, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6b */ XK_End, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6c */ XK_Down, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6d */ XK_Next, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6e */ XK_Insert, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6f */ XK_Delete, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x70 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x71 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x72 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x73 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x74 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x75 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x76 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x77 */ XK_Pause, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x78 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x79 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7a */ XK_Menu, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7d */ XK_Super_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7e */ XK_Super_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7f */ XK_Menu, NoSymbol, NoSymbol, NoSymbol,
+};
+
+static int kbdUSBKeyDown(myPrivate *priv, int keyCode)
+{
+ CARD8 byte = keyCode >> 5;
+ CARD32 bit = 1 << (keyCode & 0x1f);
+
+ if (byte > NUM_STATE_ENTRIES) return 0;
+ return priv->kbdState[byte] & bit;
+}
+
+static void kbdUSBKeyState(myPrivate *priv, int type, int keyCode)
+{
+ CARD8 byte = keyCode >> 5;
+ CARD32 bit = 1 << (keyCode & 0x1f);
+
+ if (byte > NUM_STATE_ENTRIES) return;
+ if (type == KeyPress) priv->kbdState[byte] |= bit;
+ else priv->kbdState[byte] &= ~bit;
+}
+
+/** Set the LEDs. */
+void kbdUSBCtrl(DevicePtr pDev, KeybdCtrl *ctrl)
+{
+ GETPRIV;
+ struct timeval tv;
+ struct input_event event;
+ int i, led;
+
+ gettimeofday(&tv, NULL);
+ for (i = 0; i < 5; i++) {
+ event.time.tv_sec = tv.tv_sec;
+ event.time.tv_usec = tv.tv_usec;
+ event.type = EV_LED;
+ if (i == 0) led = 1; /* LED_CAPSL == 0x01 */
+ else if (i == 1) led = 0; /* LED_NUML == 0x00 */
+ else led = i;
+ event.code = led;
+ event.value = !!(ctrl->leds & (1 << led));
+ write(priv->fd, &event, sizeof(event));
+ }
+}
+
+/** Initialize \a pDev using #usbInit. */
+void kbdUSBInit(DevicePtr pDev)
+{
+ usbInit(pDev, usbKeyboard);
+}
+
+static void kbdUSBConvert(DevicePtr pDev,
+ unsigned int scanCode,
+ int value,
+ ENQUEUEPROC enqueue,
+ CHECKPROC checkspecial,
+ BLOCK block)
+{
+ GETPRIV;
+ KeySymsPtr pKeySyms = &priv->pDevice->key->curKeySyms;
+ int type;
+ int keyCode;
+ KeySym keySym = NoSymbol;
+ int switching;
+
+ /* Set up xEvent information */
+ type = value ? KeyPress : KeyRelease;
+ keyCode = (scanCode & 0xff) + MIN_KEYCODE;
+
+ /* Handle repeats */
+
+ if (keyCode >= pKeySyms->minKeyCode && keyCode <= pKeySyms->maxKeyCode) {
+ keySym = pKeySyms->map[(keyCode - pKeySyms->minKeyCode)
+ * pKeySyms->mapWidth];
+#if 0
+ switch (keySym) {
+ case XK_Num_Lock:
+ case XK_Scroll_Lock:
+ case XK_Shift_Lock:
+ case XK_Caps_Lock:
+ /* Ignore releases and all but first press */
+ if (kbdLinuxModIgnore(priv, &xE, keySym)) return;
+ if (kbdLinuxKeyDown(priv, &xE)) xE.u.u.type = KeyRelease;
+ else xE.u.u.type = KeyPress;
+ break;
+ }
+#endif
+
+ /* If key is already down, ignore or autorepeat */
+ if (type == KeyPress && kbdUSBKeyDown(priv, keyCode)) {
+ KbdFeedbackClassRec *feed = priv->pDevice->kbdfeed;
+
+ /* No auto-repeat? */
+ if ((feed && !feed->ctrl.autoRepeat)
+ || priv->pDevice->key->modifierMap[keyCode]
+ || (feed
+ && !(feed->ctrl.autoRepeats[keyCode >> 3]
+ & (1 << (keyCode & 7))))) return; /* Ignore */
+
+ /* Do auto-repeat */
+ enqueue(pDev, KeyRelease, keyCode, keySym, NULL, block);
+ type = KeyPress;
+ }
+
+ /* If key is already up, ignore */
+ if (type == KeyRelease && !kbdUSBKeyDown(priv, keyCode)) return;
+ }
+
+ switching = 0;
+ if (checkspecial && type == KeyPress)
+ switching = checkspecial(pDev, keySym);
+ if (!switching) {
+ if (enqueue)
+ enqueue(pDev, type, keyCode, keySym, NULL, block);
+ kbdUSBKeyState(priv, type, keyCode); /* Update our state bitmap */
+ }
+}
+
+/** Read an event from the \a pDev device. If the event is a motion
+ * event, enqueue it with the \a motion function. Otherwise, check for
+ * special keys with the \a checkspecial function and enqueue the event
+ * with the \a enqueue function. The \a block type is passed to the
+ * functions so that they may block SIGIO handling as appropriate to the
+ * caller of this function. */
+void kbdUSBRead(DevicePtr pDev,
+ MOTIONPROC motion,
+ ENQUEUEPROC enqueue,
+ CHECKPROC checkspecial,
+ BLOCK block)
+{
+ GETPRIV;
+ struct input_event raw;
+
+ while (read(priv->fd, &raw, sizeof(raw)) > 0) {
+#if USB_KEYBOARD_DEBUG
+ LOG3("KBD: type = %d, code = 0x%02x, value = %d\n",
+ raw.type, raw.code, raw.value);
+#endif
+ kbdUSBConvert(pDev, raw.code, raw.value, enqueue, checkspecial, block);
+ }
+}
+
+/** Turn \a pDev on (i.e., take input from \a pDev). */
+int kbdUSBOn(DevicePtr pDev)
+{
+ GETPRIV;
+
+ if (priv->fd < 0) kbdUSBInit(pDev);
+ return priv->fd;
+}
+
+static void kbdUSBGetMap(DevicePtr pDev, KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ KeySym *k, *mapCopy;
+ int i;
+
+ mapCopy = xalloc(sizeof(map));
+ memcpy(mapCopy, map, sizeof(map));
+
+ /* compute the modifier map */
+ for (i = 0; i < MAP_LENGTH; i++)
+ pModMap[i] = NoSymbol; /* make sure it is restored */
+
+ for (k = mapCopy, i = MIN_KEYCODE;
+ i < NUM_KEYCODES + MIN_KEYCODE;
+ i++, k += 4) {
+ switch(*k) {
+ case XK_Shift_L:
+ case XK_Shift_R: pModMap[i] = ShiftMask; break;
+ case XK_Control_L:
+ case XK_Control_R: pModMap[i] = ControlMask; break;
+ case XK_Caps_Lock: pModMap[i] = LockMask; break;
+ case XK_Alt_L:
+ case XK_Alt_R: pModMap[i] = AltMask; break;
+ case XK_Num_Lock: pModMap[i] = NumLockMask; break;
+ case XK_Scroll_Lock: pModMap[i] = ScrollLockMask; break;
+ case XK_Kana_Lock:
+ case XK_Kana_Shift: pModMap[i] = KanaMask; break;
+ case XK_Mode_switch: pModMap[i] = AltLangMask; break;
+ }
+ }
+
+ pKeySyms->map = mapCopy; /* Must be XFree'able */
+ pKeySyms->mapWidth = GLYPHS_PER_KEY;
+ pKeySyms->minKeyCode = MIN_KEYCODE;
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
+}
+
+/** Fill the \a info structure with information needed to initialize \a
+ * pDev. */
+void kbdUSBGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ info->keyboard = 1;
+ info->keyClass = 1;
+ kbdUSBGetMap(pDev, &info->keySyms, info->modMap);
+ info->focusClass = 1;
+ info->kbdFeedbackClass = 1;
+#ifdef XKB
+ info->names.keycodes = xstrdup("powerpcps2");
+ info->force = 1;
+#endif
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/usb-keyboard.h b/nx-X11/programs/Xserver/hw/dmx/input/usb-keyboard.h
new file mode 100644
index 000000000..5a4768a9d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/usb-keyboard.h
@@ -0,0 +1,49 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to USB keyboard driver. \see usb-keyboard.c \see usb-common.c */
+
+#ifndef _USB_KEYBOARD_H_
+#define _USB_KEYBOARD_H_
+extern void kbdUSBInit(DevicePtr pDev);
+extern void kbdUSBGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
+extern int kbdUSBOn(DevicePtr pDev);
+extern void kbdUSBRead(DevicePtr pDev,
+ dmxMotionProcPtr motion,
+ dmxEnqueueProcPtr enqueue,
+ dmxCheckSpecialProcPtr checkspecial,
+ DMXBlockType block);
+extern void kbdUSBCtrl(DevicePtr pDev, KeybdCtrl *ctrl);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/usb-mouse.c b/nx-X11/programs/Xserver/hw/dmx/input/usb-mouse.c
new file mode 100644
index 000000000..eb1a3d123
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/usb-mouse.c
@@ -0,0 +1,127 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * This code implements a low-level device driver for a USB mouse. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "usb-private.h"
+
+/*****************************************************************************/
+/* Define some macros to make it easier to move this file to another
+ * part of the Xserver tree. All calls to the dmx* layer are #defined
+ * here for the .c file. The .h file will also have to be edited. */
+#include "usb-mouse.h"
+
+#define GETPRIV myPrivate *priv \
+ = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
+
+#define LOG0(f) dmxLog(dmxDebug,f)
+#define LOG1(f,a) dmxLog(dmxDebug,f,a)
+#define LOG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define FATAL0(f) dmxLog(dmxFatal,f)
+#define FATAL1(f,a) dmxLog(dmxFatal,f,a)
+#define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b)
+#define MOTIONPROC dmxMotionProcPtr
+#define ENQUEUEPROC dmxEnqueueProcPtr
+#define CHECKPROC dmxCheckSpecialProcPtr
+#define BLOCK DMXBlockType
+
+/* End of interface definitions. */
+/*****************************************************************************/
+
+/** Read the USB device using #usbRead. */
+void mouUSBRead(DevicePtr pDev,
+ MOTIONPROC motion,
+ ENQUEUEPROC enqueue,
+ CHECKPROC checkspecial,
+ BLOCK block)
+{
+ usbRead(pDev, motion, enqueue, BTN_MISC, block);
+}
+
+/** Initialize \a pDev using #usbInit. */
+void mouUSBInit(DevicePtr pDev)
+{
+ usbInit(pDev, usbMouse);
+}
+
+/** Turn \a pDev on (i.e., take input from \a pDev). */
+int mouUSBOn(DevicePtr pDev)
+{
+ GETPRIV;
+
+ if (priv->fd < 0) mouUSBInit(pDev);
+ return priv->fd;
+}
+
+static void mouUSBGetMap(DevicePtr pDev, unsigned char *map, int *nButtons)
+{
+ int i;
+
+ if (nButtons) *nButtons = 5;
+ if (map) for (i = 0; i <= *nButtons; i++) map[i] = i;
+}
+
+/** Fill the \a info structure with information needed to initialize \a
+ * pDev. */
+void mouUSBGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ static KeySym keyboard_mapping = NoSymbol;
+
+ info->buttonClass = 1;
+ mouUSBGetMap(pDev, info->map, &info->numButtons);
+ info->valuatorClass = 1;
+ info->numRelAxes = 2;
+ info->minval[0] = 0;
+ info->maxval[0] = 0;
+ info->res[0] = 1;
+ info->minres[0] = 0;
+ info->maxres[0] = 1;
+ info->ptrFeedbackClass = 1;
+
+ /* Some USB mice devices return key
+ * events from their pair'd
+ * keyboard... */
+ info->keyClass = 1;
+ info->keySyms.minKeyCode = 8;
+ info->keySyms.maxKeyCode = 8;
+ info->keySyms.mapWidth = 1;
+ info->keySyms.map = &keyboard_mapping;
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/usb-mouse.h b/nx-X11/programs/Xserver/hw/dmx/input/usb-mouse.h
new file mode 100644
index 000000000..2439013ee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/usb-mouse.h
@@ -0,0 +1,49 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to USB mouse driver. \see usb-mouse.c \see usb-common.c */
+
+#ifndef _USB_MOU_H_
+#define _USB_MOU_H_
+extern void mouUSBRead(DevicePtr pDev,
+ dmxMotionProcPtr motion,
+ dmxEnqueueProcPtr enqueue,
+ dmxCheckSpecialProcPtr checkspecial,
+ DMXBlockType block);
+extern void mouUSBInit(DevicePtr pDev);
+extern void mouUSBGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
+extern int mouUSBOn(DevicePtr pDev);
+extern void mouUSBCtrl(DevicePtr pDev, PtrCtrl *ctrl);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/usb-other.c b/nx-X11/programs/Xserver/hw/dmx/input/usb-other.c
new file mode 100644
index 000000000..9ac9e16ca
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/usb-other.c
@@ -0,0 +1,162 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ *
+ * This code implements a low-level device driver for a non-keyboard,
+ * non-mouse USB device (e.g., a joystick or gamepad). */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "usb-private.h"
+
+/*****************************************************************************/
+/* Define some macros to make it easier to move this file to another
+ * part of the Xserver tree. All calls to the dmx* layer are #defined
+ * here for the .c file. The .h file will also have to be edited. */
+#include "dmxinputinit.h"
+#include "usb-other.h"
+
+#define GETPRIV myPrivate *priv \
+ = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
+
+#define LOG0(f) dmxLog(dmxDebug,f)
+#define LOG1(f,a) dmxLog(dmxDebug,f,a)
+#define LOG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define FATAL0(f) dmxLog(dmxFatal,f)
+#define FATAL1(f,a) dmxLog(dmxFatal,f,a)
+#define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b)
+#define MOTIONPROC dmxMotionProcPtr
+#define ENQUEUEPROC dmxEnqueueProcPtr
+#define CHECKPROC dmxCheckSpecialProcPtr
+#define BLOCK DMXBlockType
+
+/* End of interface definitions. */
+/*****************************************************************************/
+
+/** Read the USB device using #usbRead. */
+void othUSBRead(DevicePtr pDev,
+ MOTIONPROC motion,
+ ENQUEUEPROC enqueue,
+ CHECKPROC checkspecial,
+ BLOCK block)
+{
+ usbRead(pDev, motion, enqueue, 0xffff, block);
+}
+
+/** Initialize \a pDev using #usbInit. */
+void othUSBInit(DevicePtr pDev)
+{
+ usbInit(pDev, usbOther);
+}
+
+/** Turn \a pDev on (i.e., take input from \a pDev). */
+int othUSBOn(DevicePtr pDev)
+{
+ GETPRIV;
+
+ if (priv->fd < 0) othUSBInit(pDev);
+ return priv->fd;
+}
+
+/** Fill the \a info structure with information needed to initialize \a
+ * pDev. */
+void othUSBGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
+{
+ GETPRIV;
+ int i, j;
+ static KeySym keyboard_mapping = NoSymbol;
+ int absolute[5];
+
+#define test_bit(bit) (priv->mask[(bit)/8] & (1 << ((bit)%8)))
+
+ /* Some USB mice devices return key
+ * events from their pair'd
+ * keyboard... */
+ info->keyClass = 1;
+ info->keySyms.minKeyCode = 8;
+ info->keySyms.maxKeyCode = 8;
+ info->keySyms.mapWidth = 1;
+ info->keySyms.map = &keyboard_mapping;
+
+ for (i = 0; i < EV_MAX; i++) {
+ if (test_bit(i)) {
+ switch (i) {
+ case EV_KEY:
+ /* See above */
+ break;
+ case EV_REL:
+ info->valuatorClass = 1;
+ if (info->numRelAxes + info->numAbsAxes > DMX_MAX_AXES - 1) {
+ info->numRelAxes = DMX_MAX_AXES - info->numAbsAxes - 1;
+ dmxLog(dmxWarning, "Can only use %d relative axes\n",
+ info->numRelAxes);
+ } else
+ info->numRelAxes = priv->numRel;
+ info->minval[0] = 0;
+ info->maxval[0] = 0;
+ info->res[0] = 1;
+ info->minres[0] = 0;
+ info->maxres[0] = 1;
+ break;
+ case EV_ABS:
+ info->valuatorClass = 1;
+ if (info->numRelAxes + info->numAbsAxes > DMX_MAX_AXES - 1) {
+ info->numAbsAxes = DMX_MAX_AXES - info->numRelAxes - 1;
+ dmxLog(dmxWarning, "Can only use %d absolute axes\n",
+ info->numAbsAxes);
+ } else
+ info->numAbsAxes = priv->numAbs;
+ for (j = 0; j < info->numAbsAxes; j++) {
+ ioctl(priv->fd, EVIOCGABS(j), abs);
+ info->minval[1+j] = absolute[1];
+ info->maxval[1+j] = absolute[2];
+ info->res[1+j] = absolute[3];
+ info->minres[1+j] = absolute[3];
+ info->maxres[1+j] = absolute[3];
+ }
+ break;
+ case EV_LED:
+ info->ledFeedbackClass = 0; /* Not supported at this time */
+ break;
+ case EV_SND:
+ info->belFeedbackClass = 0; /* Not supported at this time */
+ break;
+ }
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/usb-other.h b/nx-X11/programs/Xserver/hw/dmx/input/usb-other.h
new file mode 100644
index 000000000..b2279fd8d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/usb-other.h
@@ -0,0 +1,49 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Interface to USB generic driver. \see usb-other.c \see usb-common.c */
+
+#ifndef _USB_OTHER_H_
+#define _USB_OTHER_H_
+extern void othUSBRead(DevicePtr pDev,
+ dmxMotionProcPtr motion,
+ dmxEnqueueProcPtr enqueue,
+ dmxCheckSpecialProcPtr checkspecial,
+ DMXBlockType block);
+extern void othUSBInit(DevicePtr pDev);
+extern void othUSBGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
+extern int othUSBOn(DevicePtr pDev);
+extern void othUSBCtrl(DevicePtr pDev, PtrCtrl *ctrl);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/dmx/input/usb-private.h b/nx-X11/programs/Xserver/hw/dmx/input/usb-private.h
new file mode 100644
index 000000000..eae9c8b7a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/dmx/input/usb-private.h
@@ -0,0 +1,118 @@
+/* $XFree86$ */
+/*
+ * Copyright 2002 Red Hat Inc., Durham, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Private header file for USB support. This file provides
+ * Linux-specific include files and the definition of the private
+ * structure. \see usb-common.c \see usb-keyboard.c \see usb-mouse.c
+ * \see usb-other.c */
+
+#ifndef _USB_PRIVATE_H_
+#define _USB_PRIVATE_H_
+
+#include "dmxinputinit.h"
+#include "inputstr.h"
+#include <X11/Xos.h>
+#include <errno.h>
+#include <linux/input.h>
+#include "usb-common.h"
+
+ /* Support for force feedback was
+ * introduced in Linxu 2.4.10 */
+#ifndef EV_MSC
+#define EV_MSC 0x04
+#endif
+#ifndef EV_FF
+#define EV_FF 0x15
+#endif
+#ifndef LED_SLEEP
+#define LED_SLEEP 0x05
+#endif
+#ifndef LED_SUSPEND
+#define LED_SUSPEND 0x06
+#endif
+#ifndef LED_MUTE
+#define LED_MUTE 0x07
+#endif
+#ifndef LED_MISC
+#define LED_MISC 0x08
+#endif
+#ifndef BTN_DEAD
+#define BTN_DEAD 0x12f
+#endif
+#ifndef BTN_THUMBL
+#define BTN_THUMBL 0x13d
+#endif
+#ifndef BTN_THUMBR
+#define BTN_THUMBR 0x13e
+#endif
+#ifndef MSC_SERIAL
+#define MSC_SERIAL 0x00
+#endif
+#ifndef MSC_MAX
+#define MSC_MAX 0x07
+#endif
+
+ /* Support for older kernels. */
+#ifndef ABS_WHEEL
+#define ABS_WHEEL 0x08
+#endif
+#ifndef ABS_GAS
+#define ABS_GAS 0x09
+#endif
+#ifndef ABS_BRAKE
+#define ABS_BRAKE 0x0a
+#endif
+
+#define NUM_STATE_ENTRIES (256/32)
+
+/* Private area for USB devices. */
+typedef struct _myPrivate {
+ DeviceIntPtr pDevice; /**< Device (mouse or other) */
+ int fd; /**< File descriptor */
+ unsigned char mask[EV_MAX/8 + 1]; /**< Mask */
+ int numRel, numAbs, numLeds; /**< Counts */
+ int relmap[DMX_MAX_AXES]; /**< Relative axis map */
+ int absmap[DMX_MAX_AXES]; /**< Absolute axis map */
+
+ CARD32 kbdState[NUM_STATE_ENTRIES]; /**< Keyboard state */
+ DeviceIntPtr pKeyboard; /** Keyboard device */
+
+ int pitch; /**< Bell pitch */
+ unsigned long duration; /**< Bell duration */
+
+ /* FIXME: dmxInput is never initialized */
+ DMXInputInfo *dmxInput; /**< For pretty-printing */
+} myPrivate;
+#endif
diff --git a/nx-X11/programs/Xserver/hw/kdrive/README b/nx-X11/programs/Xserver/hw/kdrive/README
new file mode 100644
index 000000000..344b6fc0a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/kdrive/README
@@ -0,0 +1,7 @@
+
+
+Kdrive has been removed from this tree as it was outdated.
+Builds of kdrive are no longer supported in the monolithic
+tree. Please turn to
+ http://www.freedesktop.org/Software/xserver
+for more information where to get the sources.
diff --git a/nx-X11/programs/Xserver/hw/sun/Imakefile b/nx-X11/programs/Xserver/hw/sun/Imakefile
new file mode 100644
index 000000000..24f607a0e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/Imakefile
@@ -0,0 +1,90 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:29 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/hw/sun/Imakefile,v 1.6 2001/04/16 20:57:04 herrb Exp $
+
+#include <Server.tmpl>
+
+SRCS1 = sunInit.c \
+ sunCfb.c \
+ sunCfb24.c \
+ sunCursor.c \
+ sunFbs.c \
+ sunIo.c \
+ sunKbd.c \
+ sunMfb.c \
+ sunMouse.c\
+ sunKeyMap.c
+
+OBJS1 = sunCfb.o \
+ sunCfb24.o \
+ sunCursor.o \
+ sunFbs.o \
+ sunIo.o \
+ sunKbd.o \
+ sunMfb.o \
+ sunMouse.o \
+ sunKeyMap.o
+
+SRCS2 = sunGX.c
+OBJS2 = sunGX.o
+
+#ifdef i386Architecture
+SRCS3 = sunInit.c
+OBJS3 = sunInit.o
+#else
+SRCS3 = sunInit.c sunInitExt.c \
+ sunInitMono.c sunInExMono.c \
+ sunInitMulti.c stubs.c
+OBJS3 = sunInit.o sunInitExt.o \
+ sunInitMono.o sunInExMono.o \
+ sunInitMulti.o stubs.o
+
+DEFINES = $(OS_DEFINES) $(EXT_DEFINES) \
+ -UXFree86LOADER -UXF86VIDMODE -UXFreeXDGA \
+ -UXF86MISC -UXF86DRI -UXF86BIGFONT
+#endif
+
+SRCS = $(SRCS1) $(SRCS2) $(SRCS3) kbd_mode.c constype.c
+
+OBJS = $(OBJS1) $(OBJS2)
+
+ INCLUDES = -I. -I../.. -I../../mi -I../../mfb -I../../cfb -I../../cfb32 \
+ -I../../include -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(EXTINCSRC)
+ LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln \
+ ../mfb/llib-lmfb.ln ../mi/llib-lmi.ln ../cfb/llib-lcfb.ln
+
+NormalLibraryObjectRule()
+
+all:: $(OBJS3) kbd_mode constype
+
+lintlib:
+
+NormalLibraryTarget(sun,$(OBJS))
+NormalLintTarget($(SRCS1))
+
+#ifndef i386Architecture
+sunInExMono.o: $(ICONFIGFILES)
+ObjectFromSpecialSource(sunInExMono,../../mi/miinitext, \
+ -UPEXEXT -UGLXEXT -UXV -URENDER)
+LinkFile(sunInitExt.c,../../mi/miinitext.c)
+LinkSourceFile(stubs.c,../../Xi)
+ObjectFromSpecialSource(sunInitMono,sunInit,-DSUNMAXDEPTH=1)
+ObjectFromSpecialSource(sunInitMulti,sunInit,-DSUNMAXDEPTH=32)
+#endif
+
+SingleProgramTarget(kbd_mode, kbd_mode.o,,)
+SingleProgramTarget(constype, constype.o,,)
+InstallProgram(kbd_mode,$(BINDIR))
+InstallProgram(constype,$(BINDIR))
+InstallManPage(kbd_mode,$(MANDIR))
+InstallManPage(constype,$(MANDIR))
+InstallManPage(Xsun,$(MANDIR))
+#ifndef i386Architecture
+InstallManPageAliases(Xsun,$(MANDIR),XsunMono)
+InstallManPageAliases(Xsun,$(MANDIR),Xsun24)
+#endif
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/sun/README b/nx-X11/programs/Xserver/hw/sun/README
new file mode 100644
index 000000000..87ba53584
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/README
@@ -0,0 +1,118 @@
+A joint production of:
+
+ Adam de Boor University of California, Berkeley
+
+ David Rosenthal
+ Stuart Marks
+ Robin Schaufler
+ Mike Schwartz
+ Frances Ho
+ Geoff Lee
+ Mark Opperman Sun Microsystems
+
+ Bob Scheifler MIT Laboratory for Computer Science
+ Keith Packard
+
+This version of the Sun X11 drivers uses ../mi, ../mfb and ../cfb to support
+the following configurations:
+
+ Sun/2 bw2 cg2/3/5
+ Sun/3 bw2 cg2/3/4/5
+ Sun/4 bw2 cg2/4
+ SPARCstation cg3/6
+ Sun/386i mono color
+
+The following configurations are NOT supported:
+
+ Sun/1 bw1 cg1 (requires separate port)
+ Sun/2 gp (use /dev/cgtwo0)
+ Sun/3 gp (use /dev/cgtwo0)
+ Sun/4 gp (use /dev/cgtwo0)
+
+The mfb and cfb code has been substantially tuned for 1- and 8-bit framebuffers
+(with code for both fast and slow cpu-to-memory ratios). It installs and runs
+on these configurations under SunOS 3.2, 3.4, and 4.0. However, we must stress
+that it is completely unsupported, and if you have problems installing or using
+it you are on your own.
+
+
+Things to check before building:
+
+1) config/sun.cf - set the SunOSMajorVersion and SunOSMinorVersion
+ parameters to the right values.
+
+2) config/Project.tmpl - check LIBDIR, FONTDIR, etc.; set
+ define LibDir, FontDir, etc. in site.def as required.
+
+
+
+Then build the system by:
+
+1) Go for it. In the top-level directory, type
+
+ make World
+
+ This takes about forty minutes on a 4/260, and somewhat longer
+ on other Suns.
+
+
+2) Go for it. In the top-level directory, type
+
+ make install
+
+ Otherwise, you'll want to create a bunch of symbolic links to
+ the various executables and data files scattered throughout
+ the hierarchy.
+
+
+
+3) On the console, or from an rlogin connection, put whatever you
+ chose for BINDIR (in Imake.tmpl) in your search path, and then
+ start the server:
+
+ xinit
+ or
+ xinit -- -dev /dev/??? [see below]
+
+ If it's from the console, you probably want to redirect the
+ output thus:
+
+ xinit >& /tmp/x11.out
+
+4) xinit should start up an xterm window that acts as a console. When
+ this xterm terminates, the xinit will kill the server. You can also
+ start up client programs from a terminal or rlogin, but you must
+ first set the DISPLAY environment variable:
+
+ setenv DISPLAY unix:0
+ xterm &
+
+
+5) Make sure that you have special devices in /dev for the appropriate
+ framebuffer. See the manual page for Xsun for details or run the
+ constype program. VME systems require special .o files when more
+ than one of a particular frame buffer type is installed.
+
+
+6) In general, Xsun auto-configures to use all the available framebuffers
+ (see the Xsun manual page). In some circumstances, you may need to
+ use the -dev switch on the command line to specify a specific device
+ to use. In particular, on the GP, GP+, and GP2, you'll need to
+ specify -dev /dev/cgtwo0 your xdm Xservers file or your xinit script.
+
+
+7) To shut the server down, send it a Hangup or Terminate signal.
+
+
+8) If X crashes, it will leave the keyboard in a funny state. There is a
+ program called "kbd_mode" that will reset the mode of the keyboard.
+ "kbd_mode -a" is the appropriate setting for the bare console, and
+ "kbd_mode -e" is the appropriate setting for running with SunWindows.
+ You may have to issue this command from a terminal or from an rlogin
+ connection. If you run from the bare console, you can give the
+ command
+
+ xinit ; kbd_mode -a
+
+ so that the keyboard mode will ALWAYS be set properly when the server
+ terminates.
diff --git a/nx-X11/programs/Xserver/hw/sun/Xsun.man b/nx-X11/programs/Xserver/hw/sun/Xsun.man
new file mode 100644
index 000000000..17c1a9773
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/Xsun.man
@@ -0,0 +1,176 @@
+.\" $Xorg: Xsun.man,v 1.4 2001/02/09 02:04:43 xorgcvs Exp $
+.\" Copyright 1988 Sun Microsystems, Inc.
+.\" Copyright 1993, 1994, 1998 The Open Group
+.\"
+.\" Permission to use, copy, modify, distribute, and sell this software and its
+.\" documentation for any purpose is hereby granted without fee, provided that
+.\" the above copyright notice appear in all copies and that both that
+.\" copyright notice and this permission notice appear in supporting
+.\" documentation.
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of The Open Group shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from The Open Group.
+.\"
+.\" $XFree86: xc/programs/Xserver/hw/sun/Xsun.man,v 1.7 2001/01/27 18:20:40 dawes Exp $
+.\"
+.TH XSUN 1 __xorgversion__
+.SH NAME
+Xsun, XsunMono, Xsun24 \- Sun server for X Version 11
+.SH SYNOPSIS
+.B Xsun
+[ option ] ...
+.SH DESCRIPTION
+.I Xsun
+is the server for Version 11 of the X window system on Sun hardware.
+It will normally be started by the \fIxdm(1)\fP daemon or by a script
+that runs the program \fIxinit(1)\fP.
+.SH CONFIGURATIONS
+.PP
+.I XsunMono
+supports the BW2 monochrome frame buffer.
+.I Xsun
+supports the CG2, CG3, CG4, and CG6 8-bit color frame buffers in
+addition to the BW2 monochrome frame buffer. On Solaris 2.5 it also
+supports the TCX as an 8-bit color frame buffer.
+.I Xsun24
+supports the cgeight 24-bit color frame buffer in addition to the
+8-bit color and monochrome frame buffers that
+.I Xsun
+supports.
+.PP
+If specific framebuffer device files aren't specified on the command
+line with the \fI\-dev\fP switch or in the \fIXDEVICE\fP environment
+variable, the server will search for all installed frame buffers and
+will use all those that it finds.
+.PP
+Finally, if no specific framebuffers are found, the generic framebuffer
+interface \fI/dev/fb\fP is used.
+.PP
+.SH KEYBOARDS
+.PP
+Xsun, Xsun24, and XsunMono support the Type-2, Type-3, and many variations
+of the Type-4 and Type-5 keyboards.
+.PP
+Type-4 and Type-5 keyboards feature a key labeled \fIAltGraph\fP which
+is a mode-shift key. The mode-shift key is used to generate the symbols
+painted on the fronts of the keys. The mode-shift key works exactly like
+the \fIShift\fP, \fIControl\fP, \fIAlt\fP, and \fI<Meta>\fP keys.
+.PP
+The ten function keys on the left side of the Type-5 keyboard may be
+considered as having L1..L10 painted on their fronts. Shift-AltGraph
+will cause different keysyms to be generated for some keys, e.g. the
+Type-5 \fISysRq\fP key.
+.PP
+For compatibility with Sun's X11/NeWS server, the F11 and F12 keys may
+be made to generate the equivalent X11/NeWS keysyms by using mode-switch.
+.PP
+For backwards compatibility, the normal and mode-shifted keysyms for
+the ten function keys on the left side of Type-4 and Type-5 keyboards
+may be swapped via command line option. See \fI-swapLkeys\fP.
+.PP
+The X LEDs 1..4 correspond to the NumLock, ScrollLock, Compose, and
+CapsLock LEDs respectively. Pressing the key once turns the corresponding
+LED on. Pressing the key again turns the LED off. Turning an LED on or
+off with e.g. 'xset [-]led [1234]' is equivalent to pressing the
+corresponding key.
+.SH OPTIONS
+.PP
+In addition to the normal server options described in the \fIXserver(1)\fP
+manual page, \fIXsun\fP accepts the following command line switches:
+.TP 8
+.B "\-ar1 \fImilliseconds\fP"
+This option specifies amount of time in milliseconds before which a
+pressed key should begin to autorepeat.
+.TP 8
+.B "\-ar2 \fImilliseconds\fP"
+This option specifies the interval in milliseconds between autorepeats
+of pressed keys.
+.TP 8
+.B \-swapLkeys
+Swaps the normal keysyms for the function keys on the left side of
+Type-4 and Type-5 keyboards with the alternate keysyms, i.e. the keysyms
+painted on the front of the keys.
+.TP 8
+.B \-flipPixels
+The normal pixel values for white and black are 0 and 1 respectively.
+When -flipPixels is specified these values are reversed.
+.TP 8
+.B \-mono
+When used with the \fBcgtwo\fP, this option indicates that the server
+should emulate a monochrome framebuffer instead of the normal color
+framebuffer. When used with the \fBcgfour\fP, this option indicates
+that the monochrome screen should be numbered 0 and the color screen
+numbered 1 (instead of the other way around).
+.TP 8
+.B \-zaphod
+This option disables switching between screens by sliding the mouse off
+the left or right edges. With this disabled, a window manager function
+must be used to switch between screens.
+.TP 8
+.B \-debug
+This option indicates that the server is being run from a debugger, and
+that it should \fBnot\fP put its standard input, output and error files
+into non-blocking mode.
+.TP 8
+.B "\-dev \fIfilename[:filename]...\fP"
+This option specifies the colon separated names of the framebuffer device
+files to be used.
+.TP 8
+.B "\-fbinfo
+This option indicates that the server should enumerate the available
+frame buffers that it will use.
+.SH ENVIRONMENT
+.TP 8
+\fBXDEVICE\fP
+If present, and if no explicit \fB-dev\fP options are given, specifies
+the (colon separated) list of display devices to use.
+.SH "SEE ALSO"
+.PP
+X(__miscmansuffix__), Xserver(1), xdm(1), xinit(1)
+.SH BUGS
+The auto-configuration depends on there being appropriate special files
+in the
+.I /dev
+directory for the framebuffers which are to be used. Extra entries can
+confuse the server. For example, the X/160C in fact has the hardware
+for a monochrome
+.B bwtwo0
+on the CPU board. So if
+.I /dev
+has a special file for
+.IR /dev/bwtwo0 ,
+the server will use it, even though there is no monitor attached to the
+monochrome framebuffer.
+The server will appear to start, but not to paint a cursor, because the
+cursor is on the monochrome frame buffer. The solution is to remove the
+.I /dev
+entries for any device you don't have a monitor for.
+.PP
+There is a bug in pre-FCS operating systems for the Sun-4 which causes
+the server to crash driving a \fBcgtwo\fP.
+.PP
+.SH AUTHORS
+.TP 8
+U. C. Berkeley
+Adam de Boor.
+.TP 8
+Sun Microsystems
+David Rosenthal, Stuart Marks, Robin Schaufler, Mike Schwartz,
+Frances Ho, Geoff Lee, and Mark Opperman.
+.TP 8
+MIT Laboratory for Computer Science
+.br
+Bob Scheifler, Keith Packard, Kaleb Keithley
diff --git a/nx-X11/programs/Xserver/hw/sun/circleset.h b/nx-X11/programs/Xserver/hw/sun/circleset.h
new file mode 100644
index 000000000..c2c38e402
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/circleset.h
@@ -0,0 +1,136 @@
+#ifdef DO_FILLED_ARCS
+static unsigned short filled_arcs[16][16] = {
+{ /* 1 */
+B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 2 */
+B(0x4000),B(0xc000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 3 */
+B(0x0000),B(0x6000),B(0x6000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 4 */
+B(0x2000),B(0x7000),B(0xf000),B(0x7000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 5 */
+B(0x0000),B(0x7800),B(0x7800),B(0x7800),B(0x7800),B(0x0000),B(0x0000),B(0x0000),
+B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 6 */
+B(0x1000),B(0x7c00),B(0x7c00),B(0xfc00),B(0x7c00),B(0x7c00),B(0x0000),B(0x0000),
+B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 7 */
+B(0x0000),B(0x3c00),B(0x7e00),B(0x7e00),B(0x7e00),B(0x7e00),B(0x3c00),B(0x0000),
+B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 8 */
+B(0x0800),B(0x3e00),B(0x7f00),B(0x7f00),B(0xff00),B(0x7f00),B(0x7f00),B(0x3e00),
+B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 9 */
+B(0x0000),B(0x3f00),B(0x7f80),B(0x7f80),B(0x7f80),B(0x7f80),B(0x7f80),B(0x7f80),
+B(0x3f00),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 10 */
+B(0x0400),B(0x3f00),B(0x7f80),B(0x7fc0),B(0x7fc0),B(0xffc0),B(0x7fc0),B(0x7fc0),
+B(0x7f80),B(0x3f00),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 11 */
+B(0x0000),B(0x1f80),B(0x3fc0),B(0x7fe0),B(0x7fe0),B(0x7fe0),B(0x7fe0),B(0x7fe0),
+B(0x7fe0),B(0x3fc0),B(0x1f80),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 12 */
+B(0x0200),B(0x1fc0),B(0x3fe0),B(0x7ff0),B(0x7ff0),B(0x7ff0),B(0xfff0),B(0x7ff0),
+B(0x7ff0),B(0x7ff0),B(0x3fe0),B(0x1fc0),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 13 */
+B(0x0000),B(0x0fc0),B(0x3ff0),B(0x3ff0),B(0x7ff8),B(0x7ff8),B(0x7ff8),B(0x7ff8),
+B(0x7ff8),B(0x7ff8),B(0x3ff0),B(0x3ff0),B(0x0fc0),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 14 */
+B(0x0100),B(0x0fe0),B(0x1ff0),B(0x3ff8),B(0x7ffc),B(0x7ffc),B(0x7ffc),B(0xfffc),
+B(0x7ffc),B(0x7ffc),B(0x7ffc),B(0x3ff8),B(0x1ff0),B(0x0fe0),B(0x0000),B(0x0000),
+},
+{ /* 15 */
+B(0x0000),B(0x0ff0),B(0x1ff8),B(0x3ffc),B(0x7ffe),B(0x7ffe),B(0x7ffe),B(0x7ffe),
+B(0x7ffe),B(0x7ffe),B(0x7ffe),B(0x7ffe),B(0x3ffc),B(0x1ff8),B(0x0ff0),B(0x0000),
+},
+{ /* 16 */
+B(0x0080),B(0x07f0),B(0x1ffc),B(0x3ffe),B(0x3ffe),B(0x7fff),B(0x7fff),B(0x7fff),
+B(0xffff),B(0x7fff),B(0x7fff),B(0x7fff),B(0x3ffe),B(0x3ffe),B(0x1ffc),B(0x07f0),
+},
+};
+#endif /* DO_FILLED_ARCS */
+#ifdef DO_OUTLINE_ARCS
+static unsigned short outline0_arcs[16][16] = {
+{ /* 1 */
+B(0xc000),B(0xc000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 2 */
+B(0xe000),B(0xa000),B(0xe000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 3 */
+B(0x6000),B(0x9000),B(0x9000),B(0x6000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 4 */
+B(0x7000),B(0x8800),B(0x8800),B(0x8800),B(0x7000),B(0x0000),B(0x0000),B(0x0000),
+B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 5 */
+B(0x3000),B(0x4800),B(0x8400),B(0x8400),B(0x4800),B(0x3000),B(0x0000),B(0x0000),
+B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 6 */
+B(0x3800),B(0x4400),B(0x8200),B(0x8200),B(0x8200),B(0x4400),B(0x3800),B(0x0000),
+B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 7 */
+B(0x3c00),B(0x4200),B(0x8100),B(0x8100),B(0x8100),B(0x8100),B(0x4200),B(0x3c00),
+B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 8 */
+B(0x1c00),B(0x6300),B(0x4100),B(0x8080),B(0x8080),B(0x8080),B(0x4100),B(0x6300),
+B(0x1c00),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 9 */
+B(0x1e00),B(0x2100),B(0x4080),B(0x8040),B(0x8040),B(0x8040),B(0x8040),B(0x4080),
+B(0x2100),B(0x1e00),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 10 */
+B(0x1f00),B(0x2080),B(0x4040),B(0x8020),B(0x8020),B(0x8020),B(0x8020),B(0x8020),
+B(0x4040),B(0x2080),B(0x1f00),B(0x0000),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 11 */
+B(0x0f00),B(0x30c0),B(0x4020),B(0x4020),B(0x8010),B(0x8010),B(0x8010),B(0x8010),
+B(0x4020),B(0x4020),B(0x30c0),B(0x0f00),B(0x0000),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 12 */
+B(0x0f80),B(0x1040),B(0x2020),B(0x4010),B(0x8008),B(0x8008),B(0x8008),B(0x8008),
+B(0x8008),B(0x4010),B(0x2020),B(0x1040),B(0x0f80),B(0x0000),B(0x0000),B(0x0000),
+},
+{ /* 13 */
+B(0x0780),B(0x1860),B(0x2010),B(0x4008),B(0x8004),B(0x8004),B(0x8004),B(0x8004),
+B(0x8004),B(0x8004),B(0x4008),B(0x2010),B(0x1860),B(0x0780),B(0x0000),B(0x0000),
+},
+{ /* 14 */
+B(0x07c0),B(0x1830),B(0x2008),B(0x4004),B(0x4004),B(0x8002),B(0x8002),B(0x8002),
+B(0x8002),B(0x8002),B(0x4004),B(0x4004),B(0x2008),B(0x1830),B(0x07c0),B(0x0000),
+},
+{ /* 15 */
+B(0x07e0),B(0x0810),B(0x300c),B(0x4002),B(0x4002),B(0x8001),B(0x8001),B(0x8001),
+B(0x8001),B(0x8001),B(0x8001),B(0x4002),B(0x4002),B(0x300c),B(0x0810),B(0x07e0),
+},
+{ /* 16 */
+B(0x03e0),B(0x0c18),B(0x1004),B(0x2002),B(0x4001),B(0x4001),B(0x8000),B(0x8000),
+B(0x8000),B(0x8000),B(0x8000),B(0x4001),B(0x4001),B(0x2002),B(0x1004),B(0x0c18),
+},
+};
+#endif /* DO_OUTLINE_ARCS */
diff --git a/nx-X11/programs/Xserver/hw/sun/constype.c b/nx-X11/programs/Xserver/hw/sun/constype.c
new file mode 100644
index 000000000..06a6c345c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/constype.c
@@ -0,0 +1,216 @@
+/* $XdotOrg: xc/programs/Xserver/hw/sun/constype.c,v 1.3 2005/09/28 17:07:55 alanc Exp $
+ * $Xorg: constype.c,v 1.3 2000/08/17 19:48:29 cpqbld Exp $
+ *
+ * consoletype - utility to print out string identifying Sun console type
+ *
+ * Copyright 1988 SRI
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SRI not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SRI makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * Author: Doug Moran, SRI
+ */
+/* $XFree86: xc/programs/Xserver/hw/sun/constype.c,v 3.8 2003/10/07 21:40:07 herrb Exp $ */
+
+/*
+SUN-SPOTS DIGEST Thursday, 17 March 1988 Volume 6 : Issue 31
+
+Date: Wed, 2 Mar 88 14:50:26 PST
+From: Doug Moran <moran@ai.sri.com>
+Subject: Program to determine console type
+
+There have been several requests in this digest for programs to determine
+the type of the console. Below is a program that I wrote to produce an
+identifying string (I start suntools in my .login file and use this pgm to
+determine which arguments to use).
+
+Caveat: my cluster has only a few of these monitor types, so the pgm has
+not been fully tested.
+
+Note on coding style: the function wu_fbid is actually located in a local
+library, accounting for what otherwise might appear to be a strange coding
+style.
+*/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#else
+# if defined(SVR4) || defined(CSRG_BASED)
+# define STDC_HEADERS 1
+# endif
+# if defined(SVR4) || defined(__bsdi__)
+# define HAVE_SYS_FBIO_H 1
+# if defined(SVR4) && defined(sun)
+# define HAVE_SYS_VISUAL_IO_H 1
+# endif
+# elif defined(CSRG_BASED)
+# define HAVE_MACHINE_FBIO_H
+# endif
+#endif
+
+#include <stdio.h>
+#ifdef STDC_HEADERS
+#include <string.h>
+#else
+/* SunOS */
+#include <strings.h>
+#endif
+#include <unistd.h>
+
+static int wu_fbid(const char *devname, char **fbname, int *fbtype);
+
+int
+main (int argc, char **argv)
+{
+ int fbtype = -1;
+ char *fbname, *dev;
+ int print_num = 0;
+ int error;
+
+ if (argc > 1 && argv[1][0] == '/') {
+ dev = argv[1];
+ argc--; argv++;
+ } else
+ dev = "/dev/fb";
+ error = wu_fbid(dev, &fbname, &fbtype );
+ if (argc > 1 && strncmp (argv[1], "-num", strlen(argv[1])) == 0)
+ print_num = 1;
+
+ printf ("%s", fbname ? fbname : "tty");
+ if (print_num) {
+ printf (" %d", fbtype);
+ }
+ putchar ('\n');
+ return error;
+}
+
+#include <sys/ioctl.h>
+#include <sys/file.h>
+#ifdef HAVE_SYS_FBIO_H
+# include <fcntl.h>
+# include <sys/fbio.h>
+# ifdef HAVE_SYS_VISUAL_IO_H
+/* VIS_GETIDENTIFIER ioctl added in Solaris 2.3 */
+# include <sys/visual_io.h>
+# endif
+#else
+# ifndef HAVE_MACHINE_FBIO_H
+# include <sun/fbio.h>
+# else
+# include <machine/fbio.h>
+# endif
+#endif
+
+/* Sun doesn't see fit to update <sys/fbio.h> to reflect the addition
+ * of the TCX
+ */
+#define XFBTYPE_TCX 21
+#define XFBTYPE_LASTPLUSONE 22
+
+/* decoding as of Release 3.4 : fbio.h 1.3 87/01/09 SMI */
+ /* the convention for entries in this table is to translate the
+ * macros for frame buffer codes (in <sun/fbio.h>) to short names
+ * thus:
+ * FBTYPE_SUNxBW becomes bwx
+ * FBTYPE_SUNxCOLOR becomes cgx
+ * FBTYPE_SUNxGP becomes gpx
+ * FBTYPE_NOTSUN[1-9] becomes ns[A-J]
+ */
+static char *decode_fb[] = {
+ "bw1", "cg1",
+ "bw2", "cg2",
+ "gp2",
+ "cg5", "cg3",
+ "cg8", "cg4",
+ "nsA", "nsB", "nsC",
+#ifdef FBTYPE_SUNFAST_COLOR
+ "gx/cg6",
+#endif
+#ifdef FBTYPE_SUNROP_COLOR
+ "rop",
+#endif
+#ifdef FBTYPE_SUNFB_VIDEO
+ "vid",
+#endif
+#ifdef FBTYPE_SUNGIFB
+ "gifb",
+#endif
+#ifdef FBTYPE_SUNGPLAS
+ "plas",
+#endif
+#ifdef FBTYPE_SUNGP3
+ "gp3/cg12",
+#endif
+#ifdef FBTYPE_SUNGT
+ "gt",
+#endif
+#ifdef FBTYPE_SUNLEO
+ "leo/zx",
+#endif
+#ifdef FBTYPE_MDICOLOR
+ "mdi/cg14",
+#endif
+ };
+
+static int
+wu_fbid(const char* devname, char** fbname, int* fbtype)
+{
+ struct fbgattr fbattr;
+ int fd, ioctl_ret;
+#ifdef VIS_GETIDENTIFIER
+ int vistype;
+ struct vis_identifier fbid;
+#endif
+
+ if ( (fd = open(devname, O_RDWR, 0)) == -1 ) {
+ *fbname = "unable to open fb";
+ return 2;
+ }
+
+#ifdef VIS_GETIDENTIFIER
+ if ((vistype = ioctl(fd, VIS_GETIDENTIFIER, &fbid)) >= 0) {
+ *fbname = fbid.name;
+ *fbtype = vistype;
+ close(fd);
+ return 0;
+ }
+#endif
+
+ /* FBIOGATTR fails for early frame buffer types */
+ if ((ioctl_ret = ioctl(fd,FBIOGATTR,&fbattr))<0) /*success=>0(false)*/
+ ioctl_ret = ioctl(fd, FBIOGTYPE, &fbattr.fbtype);
+ close(fd);
+ if ( ioctl_ret == -1 ) {
+ *fbname = "ioctl on fb failed";
+ return 2;
+ }
+ *fbtype = fbattr.fbtype.fb_type;
+ /* The binary is obsolete and needs to be re-compiled:
+ * the ioctl returned a value beyond what was possible
+ * when the program was compiled */
+ if (fbattr.fbtype.fb_type>=FBTYPE_LASTPLUSONE) {
+ if (fbattr.fbtype.fb_type == XFBTYPE_TCX) {
+ *fbname = "tcx";
+ return 0;
+ } else {
+ *fbname = "unk";
+ return 1;
+ }
+ }
+ /* The source is obsolete. The table "decode_fb" does not
+ * have entries for some of the values returned by the ioctl.
+ * Compare <sun/fbio.h> to the entries in "decode_fb" */
+ if ( decode_fb[fbattr.fbtype.fb_type] == NULL ) {
+ *fbname = "unk";
+ return 1;
+ }
+ *fbname = decode_fb[fbattr.fbtype.fb_type];
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/sun/constype.man b/nx-X11/programs/Xserver/hw/sun/constype.man
new file mode 100644
index 000000000..f360825e3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/constype.man
@@ -0,0 +1,80 @@
+.\" $Xorg: constype.man,v 1.3 2000/08/17 19:48:29 cpqbld Exp $
+.\" $XdotOrg: xc/programs/Xserver/hw/sun/constype.man,v 1.3 2005/09/28 17:07:55 alanc Exp $
+.\" $XFree86$
+.\"
+.TH CONSTYPE 1 __xorgversion__
+.SH NAME
+constype \- print type of Sun console
+.SH SYNOPSIS
+.B "constype"
+[
+.I device_name
+] [
+.B \-num
+]
+.SH DESCRIPTION
+.B constype
+prints on the standard output the Sun code for the type of display
+that the specified device is.
+The types output include these:
+.sp 2
+.in +0.5i
+.nf
+bw? Black and White, where ? is 1-4. (eg) 3-50s are bw2
+cg? Colour Graphics display, where ? is 1-6, 8, 12
+gp? Optional Graphics Processor board, where ? is 1-2
+ns? Not Sun display \(em where ? is A-J
+.fi
+.in -0.5i
+.sp 2
+If the OS and device support the VIS_GETIDENTIFIER ioctl, the value
+returned from the ioctl is the value printed by constype. Sample types
+output for these include:
+.sp 2
+.in +0.5i
+.nf
+SUNWffb Sun Creator 3D (ffb) Graphics Accelerator
+SUNWm64 Sun PGX8, PGX24 or PGX64 Frame Buffer
+SUNWtext Generic vgatext console for Solaris x86 graphics devices without specific kernel drivers
+.fi
+.in -0.5i
+.sp 2
+This is useful in determining startup values and defaults for window
+systems.
+.LP
+The
+.I device_name
+argument, if given, is the device to examine.
+If not given,
+.I /dev/fb
+is used.
+.LP
+The
+.B \-num
+option causes
+.I constype
+to follow the type keyword with the numeric value of that type,
+as returned by the FBIOGATTR or FBIOGTYPE ioctl and defined in fbio.h.
+This is useful if the type is not recognized by the program.
+.SH "EXIT STATUS"
+The program exits with status 0 if it identified a known console type,
+1 if the type was unknown, and 2 if the device could not be opened or
+another error occurred.
+.SH BUGS
+Not tested on all frame buffer types
+.SH "SEE ALSO"
+.BR visual_io (7I)
+.SH COPYRIGHT
+Copyright 1988, SRI
+.PP
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted, provided
+that the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation, and that the name of SRI not be used in advertising or
+publicity pertaining to distribution of the software without specific,
+written prior permission. SRI makes no representations about the
+suitability of this software for any purpose. It is provided "as is"
+without express or implied warranty.
+.SH AUTHOR
+Doug Moran <moran@ai.sri.com>
diff --git a/nx-X11/programs/Xserver/hw/sun/kbd_mode.c b/nx-X11/programs/Xserver/hw/sun/kbd_mode.c
new file mode 100644
index 000000000..b59143ac8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/kbd_mode.c
@@ -0,0 +1,155 @@
+/* $Xorg: kbd_mode.c,v 1.3 2000/08/17 19:48:29 cpqbld Exp $ */
+/* $XdotOrg: xc/programs/Xserver/hw/sun/kbd_mode.c,v 1.3 2005/09/28 01:57:47 alanc Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: kbd_mode.c,v 3.11 2002/10/23 16:23:36 tsi Exp $ */
+
+/*
+static char sccsid[] = "@(#)kbd_mode.c 7.1 87/04/13";
+ */
+
+/*
+ * Copyright 1986 by Sun Microsystems, Inc.
+ *
+ * kbd_mode: set keyboard encoding mode
+ */
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#if defined(SVR4) || defined(__SVR4) || defined(__bsdi__)
+#include <fcntl.h>
+#ifndef __bsdi__
+#include <sys/kbio.h>
+#include <sys/kbd.h>
+#else
+#include <unistd.h>
+#include </sys/sparc/dev/kbio.h>
+#include </sys/sparc/dev/kbd.h>
+#endif
+#else
+#ifndef CSRG_BASED
+#include <sundev/kbio.h>
+#include <sundev/kbd.h>
+#else
+#include <machine/kbio.h>
+#include <machine/kbd.h>
+#endif
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static void die(char*);
+static void usage(void);
+static int kbd_fd;
+
+int
+main(argc, argv)
+ int argc;
+ char** argv;
+{
+ int code = 0, translate, direct = -1;
+ char led;
+ int click;
+
+ if ((kbd_fd = open("/dev/kbd", O_RDONLY, 0)) < 0) {
+ die("Couldn't open /dev/kbd");
+ }
+ argc--; argv++;
+ if (argc-- && **argv == '-') {
+ code = *(++*argv);
+ } else {
+ usage();
+ }
+ switch (code) {
+ case 'a':
+ case 'A':
+ translate = TR_ASCII;
+ direct = 0;
+ break;
+ case 'e':
+ case 'E':
+ translate = TR_EVENT;
+ break;
+ case 'n':
+ case 'N':
+ translate = TR_NONE;
+ break;
+ case 'u':
+ case 'U':
+ translate = TR_UNTRANS_EVENT;
+ break;
+ default:
+ usage();
+ }
+#ifdef KIOCSLED
+ led = 0;
+ if (ioctl(kbd_fd, KIOCSLED, &led))
+ die("Couldn't set LEDs");
+#endif
+#ifdef KIOCCMD
+ click = KBD_CMD_NOCLICK;
+ if (ioctl(kbd_fd, KIOCCMD, &click))
+ die("Couldn't set click");
+#endif
+ if (ioctl(kbd_fd, KIOCTRANS, (caddr_t) &translate))
+ die("Couldn't set translation");
+ if (direct != -1 && ioctl(kbd_fd, KIOCSDIRECT, (caddr_t) &direct))
+ die("Couldn't set redirect");
+ return 0;
+}
+
+static void
+die(char *msg)
+{
+ fprintf(stderr, "%s\n", msg);
+ exit(1);
+}
+
+static void
+usage(void)
+{
+ int translate;
+
+ if (ioctl(kbd_fd, KIOCGTRANS, (caddr_t) &translate)) {
+ die("Couldn't inquire current translation");
+ }
+ fprintf(stderr, "kbd_mode {-a | -e | -n | -u }\n");
+ fprintf(stderr, "\tfor ascii, encoded (normal) SunView events,\n");
+ fprintf(stderr, " \tnon-encoded, or unencoded SunView events, resp.\n");
+ fprintf(stderr, "Current mode is %s.\n",
+ ( translate == 0 ? "n (non-translated bytes)" :
+ ( translate == 1 ? "a (ascii bytes)" :
+ ( translate == 2 ? "e (encoded events)" :
+ /* translate == 3 */ "u (unencoded events)"))));
+ exit(1);
+}
+
+
diff --git a/nx-X11/programs/Xserver/hw/sun/kbd_mode.man b/nx-X11/programs/Xserver/hw/sun/kbd_mode.man
new file mode 100644
index 000000000..367b4fc9a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/kbd_mode.man
@@ -0,0 +1,53 @@
+.\" $Xorg: kbd_mode.man,v 1.4 2001/02/09 02:04:43 xorgcvs Exp $
+.\" Copyright 1987 Sun Microsystems, Inc.
+.\" Copyright 1993, 1998 The Open Group
+.\"
+.\" Permission to use, copy, modify, distribute, and sell this software and its
+.\" documentation for any purpose is hereby granted without fee, provided that
+.\" the above copyright notice appear in all copies and that both that
+.\" copyright notice and this permission notice appear in supporting
+.\" documentation.
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of The Open Group shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from The Open Group.
+.\"
+.\" $XFree86: xc/programs/Xserver/hw/sun/kbd_mode.man,v 1.6 2001/01/27 18:20:41 dawes Exp $
+.\"
+.TH KBD_MODE 1 __xorgversion__
+.SH NAME
+kbd_mode \- recover the Sun console keyboard
+.SH SYNOPSIS
+.B kbd_mode
+[ -a -e -n -u ]
+.SH DESCRIPTION
+.I Kbd_mode
+resets the Sun console keyboard to a rational state.
+.SH OPTIONS
+The following options are supported, see \fIkb(4S)\fP for details:
+.TP 8
+.B \-a
+Causes ASCII to be reported.
+.TP 8
+.B \-e
+Causes \fIFirm_events\fP to be reported.
+.TP 8
+.B \-n
+Causes up/down key codes to be reported.
+.TP 8
+.B \-u
+Causes undecoded keyboard values to be reported.
+.SH SEE ALSO
+kb(4S)
diff --git a/nx-X11/programs/Xserver/hw/sun/sun.h b/nx-X11/programs/Xserver/hw/sun/sun.h
new file mode 100644
index 000000000..d01d0a1c2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/sun.h
@@ -0,0 +1,446 @@
+
+/* $Xorg: sun.h,v 1.3 2000/08/17 19:48:29 cpqbld Exp $ */
+
+/*-
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/sun/sun.h,v 3.12 2001/07/25 15:05:01 dawes Exp $ */
+
+#ifndef _SUN_H_
+#define _SUN_H_
+
+/* X headers */
+#include <X11/Xos.h>
+#undef index /* don't mangle silly Sun structure member names */
+#include <X11/X.h>
+#include <X11/Xproto.h>
+
+/* general system headers */
+#ifndef NOSTDHDRS
+# include <stdlib.h>
+#else
+# include <malloc.h>
+extern char *getenv();
+#endif
+
+/* system headers common to both SunOS and Solaris */
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/filio.h>
+#include <sys/ioctl.h>
+#include <sys/resource.h>
+
+#ifdef SVR4
+# ifdef X_POSIX_C_SOURCE
+# define _POSIX_C_SOURCE X_POSIX_C_SOURCE
+# include <signal.h>
+# undef _POSIX_C_SOURCE
+# else
+# define _POSIX_SOURCE
+# include <signal.h>
+# undef _POSIX_SOURCE
+# endif
+#endif
+
+#include <fcntl.h>
+
+#ifndef __bsdi__
+# ifndef CSRG_BASED
+# ifndef i386
+# include <poll.h>
+# else
+# include <sys/poll.h>
+# endif
+# endif
+#else
+# include <unistd.h>
+#endif
+
+#include <errno.h>
+#include <memory.h>
+#include <signal.h>
+
+
+/*
+ * Sun specific headers Sun moved in Solaris, and are different for NetBSD.
+ *
+ * Even if only needed by one source file, I have put them here
+ * to simplify finding them...
+ */
+#ifdef SVR4
+# include <sys/fbio.h>
+# include <sys/kbd.h>
+# include <sys/kbio.h>
+# include <sys/msio.h>
+# include <sys/vuid_event.h>
+# include <sys/memreg.h>
+# include <stropts.h>
+# define usleep(usec) poll((struct pollfd *) 0, (size_t) 0, usec / 1000)
+#else
+# ifndef CSRG_BASED
+# include <sun/fbio.h>
+# include <sundev/kbd.h>
+# include <sundev/kbio.h>
+# include <sundev/msio.h>
+# include <sundev/vuid_event.h>
+# include <pixrect/pixrect.h>
+# include <pixrect/memreg.h>
+extern int ioctl();
+extern int getrlimit();
+extern int setrlimit();
+extern int getpagesize();
+# else
+# if defined(CSRG_BASED) && !defined(__bsdi__)
+# include <machine/fbio.h>
+# include <machine/kbd.h>
+# include <machine/kbio.h>
+# include <machine/vuid_event.h>
+# endif
+# ifdef __bsdi__
+# include <sys/fbio.h>
+# include </sys/sparc/dev/kbd.h>
+# include </sys/sparc/dev/kbio.h>
+# include </sys/sparc/dev/vuid_event.h>
+# endif
+# endif
+#endif
+
+/*
+ * Sun doesn't see fit to add the TCX to <sys/fbio.h>
+ */
+#ifndef SVR4
+/* On SunOS 4.1.x the TCX pretends to be a CG3 */
+#define XFBTYPE_LASTPLUSONE FBTYPE_LASTPLUSONE
+#else
+#define XFBTYPE_TCX 21
+#define XFBTYPE_LASTPLUSONE 22
+#endif
+
+extern int gettimeofday();
+
+/*
+ * Server specific headers
+ */
+#include "misc.h"
+#undef abs /* don't munge function prototypes in headers, sigh */
+#include "scrnintstr.h"
+#ifdef NEED_EVENTS
+# include "inputstr.h"
+#endif
+#include "input.h"
+#include "colormapst.h"
+#include "colormap.h"
+#include "cursorstr.h"
+#include "cursor.h"
+#include "dixstruct.h"
+#include "dix.h"
+#include "opaque.h"
+#include "resource.h"
+#include "servermd.h"
+#include "windowstr.h"
+
+/*
+ * ddx specific headers
+ */
+#ifndef PSZ
+#define PSZ 8
+#endif
+
+#include "mi/mibstore.h"
+#include "mi/mipointer.h"
+
+extern int monitorResolution;
+
+
+/* Frame buffer devices */
+#ifdef SVR4
+# define CGTWO0DEV "/dev/fbs/cgtwo0"
+# define CGTWO1DEV "/dev/fbs/cgtwo1"
+# define CGTWO2DEV "/dev/fbs/cgtwo2"
+# define CGTWO3DEV "/dev/fbs/cgtwo3"
+# define CGTHREE0DEV "/dev/fbs/cgthree0"
+# define CGTHREE1DEV "/dev/fbs/cgthree1"
+# define CGTHREE2DEV "/dev/fbs/cgthree2"
+# define CGTHREE3DEV "/dev/fbs/cgthree3"
+# define CGFOUR0DEV "/dev/fbs/cgfour0"
+# define CGSIX0DEV "/dev/fbs/cgsix0"
+# define CGSIX1DEV "/dev/fbs/cgsix1"
+# define CGSIX2DEV "/dev/fbs/cgsix2"
+# define CGSIX3DEV "/dev/fbs/cgsix3"
+# define BWTWO0DEV "/dev/fbs/bwtwo0"
+# define BWTWO1DEV "/dev/fbs/bwtwo1"
+# define BWTWO2DEV "/dev/fbs/bwtwo2"
+# define BWTWO3DEV "/dev/fbs/bwtwo3"
+# define CGEIGHT0DEV "/dev/fbs/cgeight0"
+# define TCX0DEV "/dev/fbs/tcx0"
+#else
+# define CGTWO0DEV "/dev/cgtwo0"
+# define CGTWO1DEV "/dev/cgtwo1"
+# define CGTWO2DEV "/dev/cgtwo2"
+# define CGTWO3DEV "/dev/cgtwo3"
+# define CGTHREE0DEV "/dev/cgthree0"
+# define CGTHREE1DEV "/dev/cgthree1"
+# define CGTHREE2DEV "/dev/cgthree2"
+# define CGTHREE3DEV "/dev/cgthree3"
+# define CGFOUR0DEV "/dev/cgfour0"
+# define CGSIX0DEV "/dev/cgsix0"
+# define CGSIX1DEV "/dev/cgsix1"
+# define CGSIX2DEV "/dev/cgsix2"
+# define CGSIX3DEV "/dev/cgsix3"
+# define BWTWO0DEV "/dev/bwtwo0"
+# define BWTWO1DEV "/dev/bwtwo1"
+# define BWTWO2DEV "/dev/bwtwo2"
+# define BWTWO3DEV "/dev/bwtwo3"
+# define CGEIGHT0DEV "/dev/cgeight0"
+#endif
+
+/*
+ * MAXEVENTS is the maximum number of events the mouse and keyboard functions
+ * will read on a given call to their GetEvents vectors.
+ */
+#define MAXEVENTS 32
+
+/*
+ * Data private to any sun keyboard.
+ */
+typedef struct {
+ int fd;
+ int type; /* Type of keyboard */
+ int layout; /* The layout of the keyboard */
+ int click; /* kbd click save state */
+ Leds leds; /* last known LED state */
+} sunKbdPrivRec, *sunKbdPrivPtr;
+
+extern sunKbdPrivRec sunKbdPriv;
+
+/*
+ * Data private to any sun pointer device.
+ */
+typedef struct {
+ int fd;
+ int bmask; /* last known button state */
+} sunPtrPrivRec, *sunPtrPrivPtr;
+
+extern sunPtrPrivRec sunPtrPriv;
+
+typedef struct {
+ BYTE key;
+ CARD8 modifiers;
+} SunModmapRec;
+
+typedef struct {
+ int width, height;
+ Bool has_cursor;
+ CursorPtr pCursor; /* current cursor */
+} sunCursorRec, *sunCursorPtr;
+
+typedef struct {
+ ColormapPtr installedMap;
+ CloseScreenProcPtr CloseScreen;
+ void (*UpdateColormap)();
+ void (*GetColormap)();
+ sunCursorRec hardwareCursor;
+ Bool hasHardwareCursor;
+} sunScreenRec, *sunScreenPtr;
+
+#define GetScreenPrivate(s) ((sunScreenPtr) ((s)->devPrivates[sunScreenIndex].ptr))
+#define SetupScreen(s) sunScreenPtr pPrivate = GetScreenPrivate(s)
+
+typedef struct {
+ unsigned char* fb; /* Frame buffer itself */
+ int fd; /* frame buffer for ioctl()s, */
+ struct fbtype info; /* Frame buffer characteristics */
+ void (*EnterLeave)();/* screen switch */
+ unsigned char* fbPriv; /* fbattr stuff, for the real type */
+} fbFd;
+
+typedef Bool (*sunFbInitProc)(
+ int /* screen */,
+ ScreenPtr /* pScreen */,
+ int /* argc */,
+ char** /* argv */
+);
+
+typedef struct {
+ sunFbInitProc init; /* init procedure for this fb */
+ char* name; /* /usr/include/fbio names */
+} sunFbDataRec;
+
+#ifdef XKB
+extern Bool noXkbExtension;
+#endif
+
+extern Bool sunAutoRepeatHandlersInstalled;
+extern long sunAutoRepeatInitiate;
+extern long sunAutoRepeatDelay;
+extern sunFbDataRec sunFbData[];
+extern fbFd sunFbs[];
+extern Bool sunSwapLkeys;
+extern Bool sunFlipPixels;
+extern Bool sunActiveZaphod;
+extern Bool sunFbInfo;
+extern Bool sunCG4Frob;
+extern Bool sunNoGX;
+extern int sunScreenIndex;
+extern int* sunProtected;
+
+extern Bool sunCursorInitialize(
+ ScreenPtr /* pScreen */
+);
+
+extern void sunDisableCursor(
+ ScreenPtr /* pScreen */
+);
+
+extern int sunChangeKbdTranslation(
+ int /* fd */,
+ Bool /* makeTranslated */
+);
+
+extern void sunNonBlockConsoleOff(
+#if defined(SVR4) || defined(CSRG_BASED)
+ void
+#else
+ char* /* arg */
+#endif
+);
+
+extern void sunEnqueueEvents(
+ void
+);
+
+extern int sunGXInit(
+ ScreenPtr /* pScreen */,
+ fbFd* /* fb */
+);
+
+extern Bool sunSaveScreen(
+ ScreenPtr /* pScreen */,
+ int /* on */
+);
+
+extern Bool sunScreenInit(
+ ScreenPtr /* pScreen */
+);
+
+extern pointer sunMemoryMap(
+ size_t /* len */,
+ off_t /* off */,
+ int /* fd */
+);
+
+extern Bool sunScreenAllocate(
+ ScreenPtr /* pScreen */
+);
+
+extern Bool sunInitCommon(
+ int /* scrn */,
+ ScreenPtr /* pScrn */,
+ off_t /* offset */,
+ Bool (* /* init1 */)(),
+ void (* /* init2 */)(),
+ Bool (* /* cr_cm */)(),
+ Bool (* /* save */)(),
+ int /* fb_off */
+);
+
+extern Firm_event* sunKbdGetEvents(
+ int /* fd */,
+ Bool /* on */,
+ int* /* pNumEvents */,
+ Bool* /* pAgain */
+);
+
+extern Firm_event* sunMouseGetEvents(
+ int /* fd */,
+ Bool /* on */,
+ int* /* pNumEvents */,
+ Bool* /* pAgain */
+);
+
+extern void sunKbdEnqueueEvent(
+ DeviceIntPtr /* device */,
+ Firm_event* /* fe */
+);
+
+extern void sunMouseEnqueueEvent(
+ DeviceIntPtr /* device */,
+ Firm_event* /* fe */
+);
+
+extern int sunKbdProc(
+ DeviceIntPtr /* pKeyboard */,
+ int /* what */
+);
+
+extern int sunMouseProc(
+ DeviceIntPtr /* pMouse */,
+ int /* what */
+);
+
+extern void sunKbdWait(
+ void
+);
+
+/*-
+ * TVTOMILLI(tv)
+ * Given a struct timeval, convert its time into milliseconds...
+ */
+#define TVTOMILLI(tv) (((tv).tv_usec/1000)+((tv).tv_sec*1000))
+
+extern Bool sunCfbSetupScreen(
+ ScreenPtr /* pScreen */,
+ pointer /* pbits */, /* pointer to screen bitmap */
+ int /* xsize */, /* in pixels */
+ int /* ysize */,
+ int /* dpix */, /* dots per inch */
+ int /* dpiy */, /* dots per inch */
+ int /* width */, /* pixel width of frame buffer */
+ int /* bpp */ /* bits per pixel of root */
+);
+
+extern Bool sunCfbFinishScreenInit(
+ ScreenPtr /* pScreen */,
+ pointer /* pbits */, /* pointer to screen bitmap */
+ int /* xsize */, /* in pixels */
+ int /* ysize */,
+ int /* dpix */, /* dots per inch */
+ int /* dpiy */, /* dots per inch */
+ int /* width */, /* pixel width of frame buffer */
+ int /* bpp */ /* bits per pixel of root */
+);
+
+extern Bool sunCfbScreenInit(
+ ScreenPtr /* pScreen */,
+ pointer /* pbits */, /* pointer to screen bitmap */
+ int /* xsize */, /* in pixels */
+ int /* ysize */,
+ int /* dpix */, /* dots per inch */
+ int /* dpiy */, /* dots per inch */
+ int /* width */, /* pixel width of frame buffer */
+ int /* bpp */ /* bits per pixel of root */
+);
+
+extern void sunInstallColormap(
+ ColormapPtr /* cmap */
+);
+
+extern void sunUninstallColormap(
+ ColormapPtr /* cmap */
+);
+
+extern int sunListInstalledColormaps(
+ ScreenPtr /* pScreen */,
+ Colormap* /* pCmapList */
+);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/sun/sunCfb.c b/nx-X11/programs/Xserver/hw/sun/sunCfb.c
new file mode 100644
index 000000000..5791e1e82
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/sunCfb.c
@@ -0,0 +1,517 @@
+
+/* $Xorg: sunCfb.c,v 1.5 2001/02/09 02:04:43 xorgcvs Exp $ */
+
+/*
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/* $XFree86: sunCfb.c,v 3.14 2001/12/14 19:59:42 dawes Exp $ */
+
+/*
+ * Copyright 1987 by the Regents of the University of California
+ * Copyright 1987 by Adam de Boor, UC Berkeley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/****************************************************************/
+/* Modified from sunCG4C.c for X11R3 by Tom Jarmolowski */
+/****************************************************************/
+
+/*
+ * Copyright 1991, 1992, 1993 Kaleb S. Keithley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. Kaleb S. Keithley makes no
+ * representations about the suitability of this software for
+ * any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#include "sun.h"
+#include "cfb/cfb.h"
+#include "mi/miline.h"
+
+#define GXZEROLINEBIAS (OCTANT1 | OCTANT3 | OCTANT4 | OCTANT6)
+
+static void CGUpdateColormap(pScreen, dex, count, rmap, gmap, bmap)
+ ScreenPtr pScreen;
+ int dex, count;
+ u_char *rmap, *gmap, *bmap;
+{
+ struct fbcmap sunCmap;
+
+ sunCmap.index = dex;
+ sunCmap.count = count;
+ sunCmap.red = &rmap[dex];
+ sunCmap.green = &gmap[dex];
+ sunCmap.blue = &bmap[dex];
+
+ if (ioctl(sunFbs[pScreen->myNum].fd, FBIOPUTCMAP, &sunCmap) < 0) {
+ Error("CGUpdateColormap");
+ FatalError( "CGUpdateColormap: FBIOPUTCMAP failed\n" );
+ }
+}
+
+static void CGGetColormap(pScreen, dex, count, rmap, gmap, bmap)
+ ScreenPtr pScreen;
+ int dex, count;
+ u_char *rmap, *gmap, *bmap;
+{
+ struct fbcmap sunCmap;
+
+ sunCmap.index = dex;
+ sunCmap.count = count;
+ sunCmap.red = &rmap[dex];
+ sunCmap.green = &gmap[dex];
+ sunCmap.blue = &bmap[dex];
+
+ if (ioctl(sunFbs[pScreen->myNum].fd, FBIOGETCMAP, &sunCmap) < 0) {
+ Error("CGGetColormap");
+ FatalError( "CGGetColormap: FBIOGETCMAP failed\n" );
+ }
+}
+
+void sunInstallColormap(cmap)
+ ColormapPtr cmap;
+{
+ SetupScreen(cmap->pScreen);
+ register int i;
+ register Entry *pent;
+ register VisualPtr pVisual = cmap->pVisual;
+ u_char rmap[256], gmap[256], bmap[256];
+ unsigned long rMask, gMask, bMask;
+ int oRed, oGreen, oBlue;
+
+ if (cmap == pPrivate->installedMap)
+ return;
+ if (pPrivate->installedMap)
+ WalkTree(pPrivate->installedMap->pScreen, TellLostMap,
+ (pointer) &(pPrivate->installedMap->mid));
+ if ((pVisual->class | DynamicClass) == DirectColor) {
+ if (pVisual->ColormapEntries < 256) {
+ rMask = pVisual->redMask;
+ gMask = pVisual->greenMask;
+ bMask = pVisual->blueMask;
+ oRed = pVisual->offsetRed;
+ oGreen = pVisual->offsetGreen;
+ oBlue = pVisual->offsetBlue;
+ } else {
+ rMask = gMask = bMask = 255;
+ oRed = oGreen = oBlue = 0;
+ }
+ for (i = 0; i < 256; i++) {
+ rmap[i] = cmap->red[(i & rMask) >> oRed].co.local.red >> 8;
+ gmap[i] = cmap->green[(i & gMask) >> oGreen].co.local.green >> 8;
+ bmap[i] = cmap->blue[(i & bMask) >> oBlue].co.local.blue >> 8;
+ }
+ } else {
+ (*pPrivate->GetColormap) (cmap->pScreen, 0, 256, rmap, gmap, bmap);
+ for (i = 0, pent = cmap->red;
+ i < pVisual->ColormapEntries;
+ i++, pent++) {
+ if (pent->fShared) {
+ rmap[i] = pent->co.shco.red->color >> 8;
+ gmap[i] = pent->co.shco.green->color >> 8;
+ bmap[i] = pent->co.shco.blue->color >> 8;
+ }
+ else if (pent->refcnt != 0) {
+ rmap[i] = pent->co.local.red >> 8;
+ gmap[i] = pent->co.local.green >> 8;
+ bmap[i] = pent->co.local.blue >> 8;
+ }
+ }
+ }
+ pPrivate->installedMap = cmap;
+ (*pPrivate->UpdateColormap) (cmap->pScreen, 0, 256, rmap, gmap, bmap);
+ WalkTree(cmap->pScreen, TellGainedMap, (pointer) &(cmap->mid));
+}
+
+void sunUninstallColormap(cmap)
+ ColormapPtr cmap;
+{
+ SetupScreen(cmap->pScreen);
+ if (cmap == pPrivate->installedMap) {
+ Colormap defMapID = cmap->pScreen->defColormap;
+
+ if (cmap->mid != defMapID) {
+ ColormapPtr defMap = (ColormapPtr) LookupIDByType(defMapID,
+ RT_COLORMAP);
+
+ if (defMap)
+ (*cmap->pScreen->InstallColormap)(defMap);
+ else
+ ErrorF("sunFbs: Can't find default colormap\n");
+ }
+ }
+}
+
+int sunListInstalledColormaps(pScreen, pCmapList)
+ ScreenPtr pScreen;
+ Colormap *pCmapList;
+{
+ SetupScreen(pScreen);
+ *pCmapList = pPrivate->installedMap->mid;
+ return (1);
+}
+
+static void CGStoreColors(pmap, ndef, pdefs)
+ ColormapPtr pmap;
+ int ndef;
+ xColorItem *pdefs;
+{
+ SetupScreen(pmap->pScreen);
+ u_char rmap[256], gmap[256], bmap[256];
+ xColorItem expanddefs[256];
+ register int i;
+
+ if (pPrivate->installedMap != NULL && pPrivate->installedMap != pmap)
+ return;
+ if ((pmap->pVisual->class | DynamicClass) == DirectColor) {
+ ndef = cfbExpandDirectColors(pmap, ndef, pdefs, expanddefs);
+ pdefs = expanddefs;
+ }
+ while (ndef--) {
+ i = pdefs->pixel;
+ rmap[i] = pdefs->red >> 8;
+ gmap[i] = pdefs->green >> 8;
+ bmap[i] = pdefs->blue >> 8;
+ (*pPrivate->UpdateColormap) (pmap->pScreen, i, 1, rmap, gmap, bmap);
+ pdefs++;
+ }
+}
+
+static void CGScreenInit (pScreen)
+ ScreenPtr pScreen;
+{
+#ifndef STATIC_COLOR /* { */
+ SetupScreen (pScreen);
+ pScreen->InstallColormap = sunInstallColormap;
+ pScreen->UninstallColormap = sunUninstallColormap;
+ pScreen->ListInstalledColormaps = sunListInstalledColormaps;
+ pScreen->StoreColors = CGStoreColors;
+ pPrivate->UpdateColormap = CGUpdateColormap;
+ pPrivate->GetColormap = CGGetColormap;
+ if (sunFlipPixels) {
+ Pixel pixel = pScreen->whitePixel;
+ pScreen->whitePixel = pScreen->blackPixel;
+ pScreen->blackPixel = pixel;
+ }
+#endif /* } */
+}
+
+static void checkMono (argc, argv)
+ int argc;
+ char** argv;
+{
+ int i;
+
+ for (i = 1; i < argc; i++)
+ if (strcmp (argv[i], "-mono") == 0)
+ ErrorF ("-mono not appropriate for CG3/CG4/CG6\n");
+}
+
+/*
+ * CG3_MMAP_OFFSET is #defined in <pixrect/cg3var.h> or <sys/cg3var.h>
+ * on SunOS and Solaris respectively. Under Solaris, cg3var.h
+ * #includes a non-existent file, and causes the make to abort. Other
+ * systems may not have cg3var.h at all. Since all cg3var.h is needed
+ * for is this one #define, we'll just #define it here and let it go at that.
+ */
+
+#define CG3_MMAP_OFFSET 0x04000000
+
+Bool sunCG3Init (screen, pScreen, argc, argv)
+ int screen; /* what screen am I going to be */
+ ScreenPtr pScreen; /* The Screen to initialize */
+ int argc; /* The number of the Server's arguments. */
+ char **argv; /* The arguments themselves. Don't change! */
+{
+ checkMono (argc, argv);
+ sunFbs[screen].EnterLeave = (void (*)())NoopDDA;
+ return sunInitCommon (screen, pScreen, (off_t) CG3_MMAP_OFFSET,
+ sunCfbScreenInit, CGScreenInit,
+ cfbCreateDefColormap, sunSaveScreen, 0);
+}
+
+Bool sunTCXInit (screen, pScreen, argc, argv)
+ int screen; /* what screen am I going to be */
+ ScreenPtr pScreen; /* The Screen to initialize */
+ int argc; /* The number of the Server's arguments. */
+ char **argv; /* The arguments themselves. Don't change! */
+{
+ checkMono (argc, argv);
+ sunFbs[screen].EnterLeave = (void (*)())NoopDDA;
+ return sunInitCommon (screen, pScreen, (off_t) 0,
+ sunCfbScreenInit, CGScreenInit,
+ cfbCreateDefColormap, sunSaveScreen, 0);
+}
+
+#if !defined(i386) /* { */
+
+#ifdef SVR4 /* { */
+#ifdef INCLUDE_CG2_HEADER /* { */
+#include <sys/cg2reg.h>
+#endif /* } INCLUDE_CG2_HEADER */
+#else
+#ifndef CSRG_BASED /* { */
+#include <pixrect/cg2reg.h>
+#else
+#if defined(__sparc__) || defined(__sparc) /* { */
+#if !defined(__bsdi__)
+#include <machine/cgtworeg.h>
+#endif
+#else
+#include <machine/cg2reg.h>
+#endif /* } */
+#endif /* } */
+#endif /* } */
+
+#ifdef INCLUDE_CG2_HEADER
+typedef struct {
+ struct cg2memfb mem;
+ struct cg2fb regs;
+} *CG2Ptr;
+
+static void CG2UpdateColormap(pScreen, index, count, rmap, gmap,bmap)
+ ScreenPtr pScreen;
+ int index, count;
+ u_char *rmap, *gmap, *bmap;
+{
+ CG2Ptr fb = (CG2Ptr) sunFbs[pScreen->myNum].fb;
+ volatile struct cg2statusreg *regp = &fb->regs.status.reg;
+
+ regp->update_cmap = 0;
+ while (count--) {
+ fb->regs.redmap[index] = rmap[index];
+ fb->regs.greenmap[index] = gmap[index];
+ fb->regs.bluemap[index] = bmap[index];
+ index++;
+ }
+ regp->update_cmap = 1;
+}
+
+static void CG2GetColormap(pScreen, index, count, rmap, gmap,bmap)
+ ScreenPtr pScreen;
+ int index, count;
+ u_char *rmap, *gmap, *bmap;
+{
+ CG2Ptr fb = (CG2Ptr) sunFbs[pScreen->myNum].fb;
+
+ /* I don't even know if this works */
+ while (count--) {
+ rmap[index] = fb->regs.redmap[index];
+ gmap[index] = fb->regs.greenmap[index];
+ bmap[index] = fb->regs.bluemap[index];
+ index++;
+ }
+}
+
+static Bool CG2SaveScreen (pScreen, on)
+ ScreenPtr pScreen;
+ int on;
+{
+ CG2Ptr fb = (CG2Ptr) sunFbs[pScreen->myNum].fb;
+ volatile struct cg2statusreg *regp = &fb->regs.status.reg;
+
+ if (on != SCREEN_SAVER_FORCER)
+ regp->video_enab = (on == SCREEN_SAVER_ON) ? 0 : 1;
+ return TRUE;
+}
+
+static void CG2ScreenInit (pScreen)
+ ScreenPtr pScreen;
+{
+ SetupScreen (pScreen);
+ CGScreenInit (pScreen);
+ pPrivate->UpdateColormap = CG2UpdateColormap;
+ pPrivate->GetColormap = CG2GetColormap;
+}
+
+Bool sunCG2Init (screen, pScreen, argc, argv)
+ int screen; /* what screen am I going to be */
+ ScreenPtr pScreen; /* The Screen to initialize */
+ int argc; /* The number of the Server's arguments. */
+ char** argv; /* The arguments themselves. Don't change! */
+{
+ int i;
+ Bool ret;
+ Bool mono = FALSE;
+
+ for (i = 1; i < argc; i++)
+ if (strcmp (argv[i], "-mono") == 0)
+ mono = TRUE;
+
+ sunFbs[screen].EnterLeave = (void (*)())NoopDDA;
+ pScreen->SaveScreen = CG2SaveScreen;
+ if (mono) {
+ pScreen->whitePixel = 0;
+ pScreen->blackPixel = 1;
+ ret = sunInitCommon (screen, pScreen, (off_t) 0,
+ mfbScreenInit, NULL,
+ mfbCreateDefColormap, CG2SaveScreen, 0);
+ ((CG2Ptr) sunFbs[screen].fb)->regs.ppmask.reg = 1;
+ } else {
+ ret = sunInitCommon (screen, pScreen, (off_t) 0,
+ sunCfbScreenInit, CG2ScreenInit,
+ cfbCreateDefColormap, CG2SaveScreen,
+ (int) &((struct cg2memfb *) 0)->pixplane);
+ ((CG2Ptr) sunFbs[screen].fb)->regs.ppmask.reg = 0xFF;
+ }
+ return ret;
+}
+#endif /* INCLUDE_CG2_HEADER */
+
+#define CG4_HEIGHT 900
+#define CG4_WIDTH 1152
+
+#define CG4_MELEN (128*1024)
+
+typedef struct {
+ u_char mpixel[CG4_MELEN]; /* bit-per-pixel memory */
+ u_char epixel[CG4_MELEN]; /* enable plane */
+ u_char cpixel[CG4_HEIGHT][CG4_WIDTH]; /* byte-per-pixel memory */
+} *CG4Ptr;
+
+static void CG4Switch (pScreen, select)
+ ScreenPtr pScreen;
+ int select;
+{
+ CG4Ptr fb = (CG4Ptr) sunFbs[pScreen->myNum].fb;
+
+ (void) memset ((char *)fb->epixel, select ? ~0 : 0, CG4_MELEN);
+}
+
+Bool sunCG4Init (screen, pScreen, argc, argv)
+ int screen; /* what screen am I going to be */
+ ScreenPtr pScreen; /* The Screen to initialize */
+ int argc; /* The number of the Server's arguments. */
+ char** argv; /* The arguments themselves. Don't change! */
+{
+ checkMono (argc, argv);
+ if (sunCG4Frob)
+ sunFbs[screen].EnterLeave = (void (*)())NoopDDA;
+ else
+ sunFbs[screen].EnterLeave = CG4Switch;
+ return sunInitCommon (screen, pScreen, (off_t) 0,
+ sunCfbScreenInit, CGScreenInit,
+ cfbCreateDefColormap, sunSaveScreen, (int) ((CG4Ptr) 0)->cpixel);
+}
+
+#ifdef FBTYPE_SUNFAST_COLOR /* { */
+
+#define CG6_MMAP_OFFSET 0x70000000
+#define CG6_IMAGE_OFFSET 0x16000
+
+Bool sunCG6Init (screen, pScreen, argc, argv)
+ int screen; /* The index of pScreen in the ScreenInfo */
+ ScreenPtr pScreen; /* The Screen to initialize */
+ int argc; /* The number of the Server's arguments. */
+ char** argv; /* The arguments themselves. Don't change! */
+{
+ pointer fb;
+
+ checkMono (argc, argv);
+ if (!sunScreenAllocate (pScreen))
+ return FALSE;
+ if (!sunFbs[screen].fb) {
+/* Sun's VME, Sbus, and SVR4 drivers all return different values */
+#define FBSIZE (size_t) sunFbs[screen].info.fb_width * \
+ sunFbs[screen].info.fb_height + CG6_IMAGE_OFFSET
+ if ((fb = sunMemoryMap (FBSIZE,
+ (off_t) CG6_MMAP_OFFSET,
+ sunFbs[screen].fd)) == NULL)
+ return FALSE;
+ sunFbs[screen].fb = fb;
+#undef FBSIZE
+ }
+ sunFbs[screen].EnterLeave = (void (*)())NoopDDA;
+ if (!sunCfbSetupScreen (pScreen,
+ sunFbs[screen].fb + CG6_IMAGE_OFFSET,
+ sunFbs[screen].info.fb_width,
+ sunFbs[screen].info.fb_height,
+ monitorResolution, monitorResolution,
+ sunFbs[screen].info.fb_width,
+ sunFbs[screen].info.fb_depth))
+ return FALSE;
+ if (sunNoGX == FALSE) {
+ if (!sunGXInit (pScreen, &sunFbs[screen]))
+ return FALSE;
+ }
+ if (!sunCfbFinishScreenInit(pScreen,
+ sunFbs[screen].fb + CG6_IMAGE_OFFSET,
+ sunFbs[screen].info.fb_width,
+ sunFbs[screen].info.fb_height,
+ monitorResolution, monitorResolution,
+ sunFbs[screen].info.fb_width,
+ sunFbs[screen].info.fb_depth))
+ return FALSE;
+ if (sunNoGX == FALSE) {
+ miSetZeroLineBias(pScreen, GXZEROLINEBIAS);
+ }
+ miInitializeBackingStore(pScreen);
+ CGScreenInit (pScreen);
+ if (!sunScreenInit (pScreen))
+ return FALSE;
+ sunSaveScreen (pScreen, SCREEN_SAVER_OFF);
+ return cfbCreateDefColormap(pScreen);
+}
+#endif /* } */
+#endif /* } */
diff --git a/nx-X11/programs/Xserver/hw/sun/sunCfb24.c b/nx-X11/programs/Xserver/hw/sun/sunCfb24.c
new file mode 100644
index 000000000..fa3a58e85
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/sunCfb24.c
@@ -0,0 +1,139 @@
+/* $Xorg: sunCfb24.c,v 1.4 2001/02/09 02:04:43 xorgcvs Exp $ */
+
+/*
+
+Copyright 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X
+CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings in
+this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/sun/sunCfb24.c,v 1.2 2001/10/28 03:33:10 tsi Exp $ */
+
+/*
+ * The CG8 is similar to the CG4 in that it has a mono plane, an enable
+ * plane, and a color plane. While the CG4 only has an 8-bit color
+ * plane the CG8 has a 24-bit color plane.
+ *
+ * If you have a CG4 you know that you can switch between the mono and
+ * the color screens merely by dragging the pointer off the edge of the
+ * screen, causing the other screen to be switched in. However this is
+ * the cause of some consternation on the part of those people who have
+ * both a CG4 and another frame buffer.
+ *
+ * Because of this problem, and some other considerations, I have chosen
+ * to ignore the mono plane of the CG8 in this code.
+ */
+
+#define PSZ 32
+#include "sun.h"
+#include "cfb/cfb.h"
+
+#define PIXPG_24BIT_COLOR 5
+#define PIXPG_24BIT_COLOR_INDEX (PIXPG_24BIT_COLOR << 25)
+#define PR_FORCE_UPDATE (1 << 24)
+
+static void CG24UpdateColormap(pScreen, index, count, rmap, gmap, bmap)
+ ScreenPtr pScreen;
+ int index, count;
+ u_char *rmap, *gmap, *bmap;
+{
+ struct fbcmap sunCmap;
+
+ sunCmap.index = index | PIXPG_24BIT_COLOR_INDEX | PR_FORCE_UPDATE;
+ sunCmap.count = count;
+ sunCmap.red = &rmap[index];
+ sunCmap.green = &gmap[index];
+ sunCmap.blue = &bmap[index];
+
+ if (ioctl(sunFbs[pScreen->myNum].fd, FBIOPUTCMAP, &sunCmap) == -1)
+ FatalError( "CG24UpdateColormap: FBIOPUTCMAP failed\n");
+}
+
+static void CG24StoreColors (pmap, ndef, pdefs)
+ ColormapPtr pmap;
+ int ndef;
+ xColorItem* pdefs;
+{
+ u_char rmap[256], gmap[256], bmap[256];
+ SetupScreen (pmap->pScreen);
+ VisualPtr pVisual = pmap->pVisual;
+ int i;
+
+ if (pPrivate->installedMap != NULL && pPrivate->installedMap != pmap)
+ return;
+ for (i = 0; i < 256; i++) {
+ rmap[i] = pmap->red[i].co.local.red >> 8;
+ gmap[i] = pmap->green[i].co.local.green >> 8;
+ bmap[i] = pmap->blue[i].co.local.blue >> 8;
+ }
+ while (ndef--) {
+ i = pdefs->pixel;
+ if (pdefs->flags & DoRed)
+ rmap[(i & pVisual->redMask) >> pVisual->offsetRed] = (pdefs->red >> 8);
+ if (pdefs->flags & DoGreen)
+ gmap[(i & pVisual->greenMask) >> pVisual->offsetGreen] = (pdefs->green >> 8);
+ if (pdefs->flags & DoBlue)
+ bmap[(i & pVisual->blueMask) >> pVisual->offsetBlue] = (pdefs->blue >> 8);
+ pdefs++;
+ }
+ CG24UpdateColormap (pmap->pScreen, 0, 256, rmap, gmap, bmap);
+}
+
+#define CG8_COLOR_OFFSET 0x40000
+
+static void CG24ScreenInit (pScreen)
+ ScreenPtr pScreen;
+{
+#ifndef STATIC_COLOR
+ SetupScreen (pScreen);
+#endif
+ int i;
+
+ /* Make sure the overlay plane is disabled */
+ for (i = 0; i < CG8_COLOR_OFFSET; i++)
+ sunFbs[pScreen->myNum].fb[i] = 0;
+
+#ifndef STATIC_COLOR
+ pScreen->InstallColormap = sunInstallColormap;
+ pScreen->UninstallColormap = sunUninstallColormap;
+ pScreen->ListInstalledColormaps = sunListInstalledColormaps;
+ pScreen->StoreColors = CG24StoreColors;
+ pPrivate->UpdateColormap = CG24UpdateColormap;
+ if (sunFlipPixels) {
+ Pixel pixel = pScreen->whitePixel;
+ pScreen->whitePixel = pScreen->blackPixel;
+ pScreen->blackPixel = pixel;
+ }
+#endif
+}
+
+Bool sunCG8Init (screen, pScreen, argc, argv)
+ int screen; /* what screen am I going to be */
+ ScreenPtr pScreen; /* The Screen to initialize */
+ int argc; /* The number of the Server's arguments. */
+ char **argv; /* The arguments themselves. Don't change! */
+{
+ sunFbs[screen].EnterLeave = (void (*)())NoopDDA;
+ return sunInitCommon (screen, pScreen, (off_t) 0,
+ cfb32ScreenInit, CG24ScreenInit,
+ cfbCreateDefColormap, sunSaveScreen, CG8_COLOR_OFFSET);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/sun/sunCursor.c b/nx-X11/programs/Xserver/hw/sun/sunCursor.c
new file mode 100644
index 000000000..2d653c753
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/sunCursor.c
@@ -0,0 +1,281 @@
+/* $Xorg: sunCursor.c,v 1.4 2001/02/09 02:04:43 xorgcvs Exp $ */
+/*
+
+Copyright 1988 Sun Microsystems, Inc.
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/sun/sunCursor.c,v 3.5 2001/12/14 19:59:43 dawes Exp $ */
+
+/*-
+ * sunCursor.c --
+ * Functions for maintaining the Sun software cursor...
+ *
+ */
+
+#define NEED_EVENTS
+#include "sun.h"
+#include "cfb.h"
+#include "mfb.h"
+
+#ifdef FBIOGCURMAX /* has hardware cursor kernel support */
+
+#define GetCursorPrivate(s) (&(GetScreenPrivate(s)->hardwareCursor))
+#define SetupCursor(s) sunCursorPtr pCurPriv = GetCursorPrivate(s)
+
+static void sunLoadCursor();
+
+static Bool
+sunRealizeCursor (pScreen, pCursor)
+ ScreenPtr pScreen;
+ CursorPtr pCursor;
+{
+ SetupCursor(pScreen);
+ int x, y;
+
+ /* miRecolorCursor does this */
+ if (pCurPriv->pCursor == pCursor)
+ {
+ miPointerPosition (&x, &y);
+ sunLoadCursor (pScreen, pCursor, x, y);
+ }
+ return TRUE;
+}
+
+static Bool
+sunUnrealizeCursor (pScreen, pCursor)
+ ScreenPtr pScreen;
+ CursorPtr pCursor;
+{
+ return TRUE;
+}
+
+static void
+sunCursorRepad (pScreen, bits, src_bits, dst_bits, ptSrc, w, h)
+ ScreenPtr pScreen;
+ CursorBitsPtr bits;
+ unsigned char *src_bits, *dst_bits;
+ DDXPointPtr ptSrc;
+ int w, h;
+{
+ PixmapPtr src, dst;
+ BoxRec box;
+ RegionRec rgnDst;
+
+ if (!(src = GetScratchPixmapHeader(pScreen, bits->width, bits->height,
+ /*bpp*/ 1, /*depth*/ 1,
+ PixmapBytePad(bits->width,1), src_bits)))
+ return;
+ if (!(dst = GetScratchPixmapHeader(pScreen, w, h, /*bpp*/ 1, /*depth*/ 1,
+ PixmapBytePad(w,1), dst_bits)))
+ {
+ FreeScratchPixmapHeader(src);
+ return;
+ }
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = w;
+ box.y2 = h;
+ REGION_INIT(pScreen, &rgnDst, &box, 1);
+ mfbDoBitblt(&src->drawable, &dst->drawable, GXcopy, &rgnDst, ptSrc);
+ REGION_UNINIT(pScreen, &rgnDst);
+ FreeScratchPixmapHeader(src);
+ FreeScratchPixmapHeader(dst);
+}
+
+static void
+sunLoadCursor (pScreen, pCursor, x, y)
+ ScreenPtr pScreen;
+ CursorPtr pCursor;
+ int x, y;
+{
+ SetupCursor(pScreen);
+ struct fbcursor fbcursor;
+ int w, h;
+ unsigned char r[2], g[2], b[2];
+ DDXPointRec ptSrc;
+ unsigned char source_temp[1024], mask_temp[1024];
+
+ fbcursor.set = FB_CUR_SETALL;
+ fbcursor.enable = 1;
+ fbcursor.pos.x = x;
+ fbcursor.pos.y = y;
+ fbcursor.hot.x = pCursor->bits->xhot;
+ fbcursor.hot.y = pCursor->bits->yhot;
+ r[0] = pCursor->backRed >> 8;
+ g[0] = pCursor->backGreen >> 8;
+ b[0] = pCursor->backBlue >> 8;
+ r[1] = pCursor->foreRed >> 8;
+ g[1] = pCursor->foreGreen >> 8;
+ b[1] = pCursor->foreBlue >> 8;
+ fbcursor.cmap.index = 0;
+ fbcursor.cmap.count = 2;
+ fbcursor.cmap.red = r;
+ fbcursor.cmap.green = g;
+ fbcursor.cmap.blue = b;
+ fbcursor.image = (char *) pCursor->bits->source;
+ fbcursor.mask = (char *) pCursor->bits->mask;
+ w = pCursor->bits->width;
+ h = pCursor->bits->height;
+ if (w > pCurPriv->width || h > pCurPriv->height) {
+ ptSrc.x = 0;
+ ptSrc.y = 0;
+ if (w > pCurPriv->width)
+ w = pCurPriv->width;
+ if (h > pCurPriv->height)
+ h = pCurPriv->height;
+ sunCursorRepad (pScreen, pCursor->bits, pCursor->bits->source,
+ source_temp, &ptSrc, w, h);
+ sunCursorRepad (pScreen, pCursor->bits, pCursor->bits->mask,
+ mask_temp, &ptSrc, w, h);
+ fbcursor.image = (char *) source_temp;
+ fbcursor.mask = (char *) mask_temp;
+ }
+ fbcursor.size.x = w;
+ fbcursor.size.y = h;
+#ifndef Lynx
+ (void) ioctl (sunFbs[pScreen->myNum].fd, FBIOSCURSOR, &fbcursor);
+#else
+ (void) sunIoctl (&sunFbs[pScreen->myNum], FBIOSCURSOR, &fbcursor);
+#endif
+}
+
+static void
+sunSetCursor (pScreen, pCursor, x, y)
+ ScreenPtr pScreen;
+ CursorPtr pCursor;
+ int x, y;
+{
+ SetupCursor(pScreen);
+
+ if (pCursor)
+ sunLoadCursor (pScreen, pCursor, x, y);
+ else
+ sunDisableCursor (pScreen);
+ pCurPriv->pCursor = pCursor;
+}
+
+static void
+sunMoveCursor (pScreen, x, y)
+ ScreenPtr pScreen;
+ int x, y;
+{
+ struct fbcurpos pos;
+
+ pos.x = x;
+ pos.y = y;
+#ifndef Lynx
+ ioctl (sunFbs[pScreen->myNum].fd, FBIOSCURPOS, &pos);
+#else
+ sunIoctl (&sunFbs[pScreen->myNum], FBIOSCURPOS, &pos);
+#endif
+}
+
+miPointerSpriteFuncRec sunPointerSpriteFuncs = {
+ sunRealizeCursor,
+ sunUnrealizeCursor,
+ sunSetCursor,
+ sunMoveCursor,
+};
+
+static void
+sunQueryBestSize (class, pwidth, pheight, pScreen)
+ int class;
+ unsigned short *pwidth, *pheight;
+ ScreenPtr pScreen;
+{
+ SetupCursor (pScreen);
+
+ switch (class)
+ {
+ case CursorShape:
+ if (*pwidth > pCurPriv->width)
+ *pwidth = pCurPriv->width;
+ if (*pheight > pCurPriv->height)
+ *pheight = pCurPriv->height;
+ if (*pwidth > pScreen->width)
+ *pwidth = pScreen->width;
+ if (*pheight > pScreen->height)
+ *pheight = pScreen->height;
+ break;
+ default:
+ mfbQueryBestSize (class, pwidth, pheight, pScreen);
+ break;
+ }
+}
+
+extern miPointerScreenFuncRec sunPointerScreenFuncs;
+
+#endif
+
+Bool sunCursorInitialize (
+ ScreenPtr pScreen)
+{
+#ifdef FBIOGCURMAX
+ SetupCursor (pScreen);
+ struct fbcurpos maxsize;
+
+ pCurPriv->has_cursor = FALSE;
+#ifndef Lynx
+ if (ioctl (sunFbs[pScreen->myNum].fd, FBIOGCURMAX, &maxsize) == -1)
+#else
+ if (sunIoctl (&sunFbs[pScreen->myNum], FBIOGCURMAX, &maxsize) == -1)
+#endif
+ return FALSE;
+ pCurPriv->width = maxsize.x;
+ pCurPriv->height= maxsize.y;
+ pScreen->QueryBestSize = sunQueryBestSize;
+ miPointerInitialize (pScreen,
+ &sunPointerSpriteFuncs,
+ &sunPointerScreenFuncs,
+ FALSE);
+ pCurPriv->has_cursor = TRUE;
+ pCurPriv->pCursor = NULL;
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
+void sunDisableCursor (
+ ScreenPtr pScreen)
+{
+#ifdef FBIOGCURMAX
+ SetupCursor (pScreen);
+ struct fbcursor fbcursor;
+
+ if (pCurPriv->has_cursor)
+ {
+ fbcursor.set = FB_CUR_SETCUR;
+ fbcursor.enable = 0;
+#ifndef Lynx
+ (void) ioctl (sunFbs[pScreen->myNum].fd, FBIOSCURSOR, &fbcursor);
+#else
+ (void) sunIoctl (&sunFbs[pScreen->myNum], FBIOSCURSOR, &fbcursor);
+#endif
+ pCurPriv->pCursor = NULL;
+ }
+#endif
+}
diff --git a/nx-X11/programs/Xserver/hw/sun/sunFbs.c b/nx-X11/programs/Xserver/hw/sun/sunFbs.c
new file mode 100644
index 000000000..1acf2517b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/sunFbs.c
@@ -0,0 +1,259 @@
+
+/* $Xorg: sunFbs.c,v 1.4 2001/02/09 02:04:43 xorgcvs Exp $ */
+
+/*
+Copyright 1990, 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*
+ * Copyright 1987 by the Regents of the University of California
+ * Copyright 1987 by Adam de Boor, UC Berkeley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/sun/sunFbs.c,v 1.7 2002/12/06 00:28:50 tsi Exp $ */
+
+/****************************************************************/
+/* Modified from sunCG4C.c for X11R3 by Tom Jarmolowski */
+/****************************************************************/
+
+#include "sun.h"
+#include <sys/mman.h>
+
+int sunScreenIndex;
+
+static unsigned long generation = 0;
+
+pointer sunMemoryMap (
+ size_t len,
+ off_t off,
+ int fd)
+{
+ int pagemask, mapsize;
+ caddr_t addr;
+ pointer mapaddr;
+
+#ifdef SVR4
+ pagemask = sysconf(_SC_PAGESIZE) - 1;
+#else
+ pagemask = getpagesize() - 1;
+#endif
+ mapsize = ((int) len + pagemask) & ~pagemask;
+ addr = 0;
+
+#if !defined(__bsdi__) && !defined(_MAP_NEW) && !defined(__NetBSD__) && !defined(__OpenBSD__)
+ if ((addr = (caddr_t) valloc (mapsize)) == NULL) {
+ Error ("Couldn't allocate frame buffer memory");
+ (void) close (fd);
+ return NULL;
+ }
+#endif
+
+#if !defined(__NetBSD__) && !defined(__OpenBSD__)
+ /*
+ * try and make it private first, that way once we get it, an
+ * interloper, e.g. another server, can't get this frame buffer,
+ * and if another server already has it, this one won't.
+ */
+ if ((int)(mapaddr = (pointer) mmap (addr,
+ mapsize,
+ PROT_READ | PROT_WRITE, MAP_PRIVATE,
+ fd, off)) == -1)
+#endif
+ mapaddr = (pointer) mmap (addr,
+ mapsize,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ fd, off);
+ if (mapaddr == (pointer) -1) {
+ Error ("mapping frame buffer memory");
+ (void) close (fd);
+ mapaddr = (pointer) NULL;
+ }
+ return mapaddr;
+}
+
+Bool sunScreenAllocate (
+ ScreenPtr pScreen)
+{
+ sunScreenPtr pPrivate;
+ extern int AllocateScreenPrivateIndex();
+
+ if (generation != serverGeneration)
+ {
+ sunScreenIndex = AllocateScreenPrivateIndex();
+ if (sunScreenIndex < 0)
+ return FALSE;
+ generation = serverGeneration;
+ }
+ pPrivate = (sunScreenPtr) xalloc (sizeof (sunScreenRec));
+ if (!pPrivate)
+ return FALSE;
+
+ pScreen->devPrivates[sunScreenIndex].ptr = (pointer) pPrivate;
+ return TRUE;
+}
+
+Bool sunSaveScreen (
+ ScreenPtr pScreen,
+ int on)
+{
+ int state;
+
+ if (on != SCREEN_SAVER_FORCER)
+ {
+ if (on == SCREEN_SAVER_ON)
+ state = 0;
+ else
+ state = 1;
+ (void) ioctl(sunFbs[pScreen->myNum].fd, FBIOSVIDEO, &state);
+ }
+ return( TRUE );
+}
+
+static Bool closeScreen (i, pScreen)
+ int i;
+ ScreenPtr pScreen;
+{
+ SetupScreen(pScreen);
+ Bool ret;
+
+ (void) OsSignal (SIGIO, SIG_IGN);
+ sunDisableCursor (pScreen);
+ pScreen->CloseScreen = pPrivate->CloseScreen;
+ ret = (*pScreen->CloseScreen) (i, pScreen);
+ (void) (*pScreen->SaveScreen) (pScreen, SCREEN_SAVER_OFF);
+ xfree ((pointer) pPrivate);
+ return ret;
+}
+
+Bool sunScreenInit (
+ ScreenPtr pScreen)
+{
+ SetupScreen(pScreen);
+ extern void sunBlockHandler();
+ extern void sunWakeupHandler();
+ static ScreenPtr autoRepeatScreen;
+ extern miPointerScreenFuncRec sunPointerScreenFuncs;
+
+ pPrivate->installedMap = 0;
+ pPrivate->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = closeScreen;
+ pScreen->SaveScreen = sunSaveScreen;
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ /*
+ * Block/Unblock handlers
+ */
+ if (sunAutoRepeatHandlersInstalled == FALSE) {
+ autoRepeatScreen = pScreen;
+ sunAutoRepeatHandlersInstalled = TRUE;
+ }
+
+ if (pScreen == autoRepeatScreen) {
+ pScreen->BlockHandler = sunBlockHandler;
+ pScreen->WakeupHandler = sunWakeupHandler;
+ }
+#ifdef XKB
+ }
+#endif
+ if (!sunCursorInitialize (pScreen))
+ miDCInitialize (pScreen, &sunPointerScreenFuncs);
+ return TRUE;
+}
+
+Bool sunInitCommon (
+ int scrn,
+ ScreenPtr pScrn,
+ off_t offset,
+ Bool (*init1)(),
+ void (*init2)(),
+ Bool (*cr_cm)(),
+ Bool (*save)(),
+ int fb_off)
+{
+ unsigned char* fb = sunFbs[scrn].fb;
+
+ if (!sunScreenAllocate (pScrn))
+ return FALSE;
+ if (!fb) {
+ if ((fb = sunMemoryMap ((size_t) sunFbs[scrn].info.fb_size,
+ offset,
+ sunFbs[scrn].fd)) == NULL)
+ return FALSE;
+ sunFbs[scrn].fb = fb;
+ }
+ /* mfbScreenInit() or cfbScreenInit() */
+ if (!(*init1)(pScrn, fb + fb_off,
+ sunFbs[scrn].info.fb_width,
+ sunFbs[scrn].info.fb_height,
+ monitorResolution, monitorResolution,
+ sunFbs[scrn].info.fb_width,
+ sunFbs[scrn].info.fb_depth))
+ return FALSE;
+ miInitializeBackingStore(pScrn);
+ /* sunCGScreenInit() if cfb... */
+ if (init2)
+ (*init2)(pScrn);
+ if (!sunScreenInit(pScrn))
+ return FALSE;
+ (void) (*save) (pScrn, SCREEN_SAVER_OFF);
+ return (*cr_cm)(pScrn);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/sun/sunGX.c b/nx-X11/programs/Xserver/hw/sun/sunGX.c
new file mode 100644
index 000000000..b6ecaac57
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/sunGX.c
@@ -0,0 +1,2906 @@
+/*
+static char *rid="$Xorg: sunGX.c,v 1.5 2001/02/09 02:04:44 xorgcvs Exp $";
+ */
+/*
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/sun/sunGX.c,v 1.8 2003/07/19 13:22:28 tsi Exp $ */
+
+#include "sun.h"
+
+#include <X11/Xmd.h>
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mistruct.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "cfb/cfb.h"
+#include "cfb/cfbmskbits.h"
+#include "cfb/cfb8bit.h"
+#include "fastblt.h"
+#include "mergerop.h"
+#include "sunGX.h"
+#include "migc.h"
+#include "mispans.h"
+
+#define sunGXFillSpan(gx,y,x1,x2,r) {\
+ (gx)->apointy = (y); \
+ (gx)->apointx = (x1); \
+ (gx)->arectx = (x2); \
+ GXDrawDone(gx,r); \
+}
+
+#define GXSetClip(gx,pbox) {\
+ (gx)->clipminx = (pbox)->x1; \
+ (gx)->clipminy = (pbox)->y1; \
+ (gx)->clipmaxx = (pbox)->x2 - 1; \
+ (gx)->clipmaxy = (pbox)->y2 - 1; \
+}
+
+#define GXSetOff(gx,x,y) {\
+ (gx)->offx = (x); \
+ (gx)->offy = (y); \
+}
+
+#define GXResetClip(gx,pScreen) { \
+ (gx)->clipminx = 0; \
+ (gx)->clipminy = 0; \
+ (gx)->clipmaxx = (pScreen)->width - 1; \
+ (gx)->clipmaxy = (pScreen)->height - 1; \
+}
+
+#define GXResetOff(gx) {\
+ (gx)->offx = 0; \
+ (gx)->offy = 0; \
+}
+
+#define sunGXGetAddrRange(pDrawable,extents,base,lo,hi) {\
+ int __x__; \
+ cfbGetWindowByteWidthAndPointer((WindowPtr)pDrawable,__x__,base); \
+ lo = (base) + WIDTH_MUL((extents)->y1) + (extents)->x1; \
+ hi = (base) + WIDTH_MUL((extents)->y2 - 1) + (extents)->x2 - 1; \
+ (base) = (base) + WIDTH_MUL(pDrawable->y) + pDrawable->x; \
+}
+
+/*
+ rop_tables
+ ==========
+ lookup tables for GX raster ops, with the plane_mask,pixel_mask,pattern_mask
+ ,attrib_sel, polygon_draw,raster_mode encoded into the top half.
+ There is a lookup table for each commonly used combination.
+*/
+
+/* rops for bit blit / copy area
+ with:
+ Plane Mask - use plane mask reg.
+ Pixel Mask - use all ones.
+ Patt Mask - use all ones.
+*/
+
+#define POLY_O GX_POLYG_OVERLAP
+#define POLY_N GX_POLYG_NONOVERLAP
+
+#define ROP_STANDARD (GX_PLANE_MASK |\
+ GX_PIXEL_ONES |\
+ GX_ATTR_SUPP |\
+ GX_RAST_BOOL |\
+ GX_PLOT_PLOT)
+
+/* fg = don't care bg = don't care */
+
+#define ROP_BLIT(O,I) (ROP_STANDARD | \
+ GX_PATTERN_ONES |\
+ GX_ROP_11_1(I) |\
+ GX_ROP_11_0(O) |\
+ GX_ROP_10_1(I) |\
+ GX_ROP_10_0(O) |\
+ GX_ROP_01_1(I) |\
+ GX_ROP_01_0(O) |\
+ GX_ROP_00_1(I) |\
+ GX_ROP_00_0(O))
+
+/* fg = fgPixel bg = don't care */
+
+#define ROP_FILL(O,I) (ROP_STANDARD | \
+ GX_PATTERN_ONES |\
+ GX_ROP_11_1(I) |\
+ GX_ROP_11_0(I) |\
+ GX_ROP_10_1(I) |\
+ GX_ROP_10_0(I) | \
+ GX_ROP_01_1(O) |\
+ GX_ROP_01_0(O) |\
+ GX_ROP_00_1(O) |\
+ GX_ROP_00_0(O))
+
+/* fg = fgPixel bg = don't care */
+
+#define ROP_STIP(O,I) (ROP_STANDARD |\
+ GX_ROP_11_1(I) |\
+ GX_ROP_11_0(GX_ROP_NOOP) |\
+ GX_ROP_10_1(I) |\
+ GX_ROP_10_0(GX_ROP_NOOP) | \
+ GX_ROP_01_1(O) |\
+ GX_ROP_01_0(GX_ROP_NOOP) |\
+ GX_ROP_00_1(O) |\
+ GX_ROP_00_0(GX_ROP_NOOP))
+
+/* fg = fgPixel bg = bgPixel */
+
+#define ROP_OSTP(O,I) (ROP_STANDARD |\
+ GX_ROP_11_1(I) |\
+ GX_ROP_11_0(I) |\
+ GX_ROP_10_1(I) |\
+ GX_ROP_10_0(O) |\
+ GX_ROP_01_1(O) |\
+ GX_ROP_01_0(I) |\
+ GX_ROP_00_1(O) |\
+ GX_ROP_00_0(O))
+
+#define ROP_ITXT(O,I) (ROP_STANDARD |\
+ GX_PATTERN_ONES |\
+ GX_ROP_11_1(I) |\
+ GX_ROP_11_0(I) |\
+ GX_ROP_10_1(I) |\
+ GX_ROP_10_0(O) |\
+ GX_ROP_01_1(O) |\
+ GX_ROP_01_0(I) |\
+ GX_ROP_00_1(O) |\
+ GX_ROP_00_0(O))
+
+#define ROP_PTXT(O,I) (ROP_STANDARD |\
+ GX_PATTERN_ONES |\
+ GX_ROP_11_1(I) |\
+ GX_ROP_11_0(GX_ROP_NOOP) |\
+ GX_ROP_10_1(I) |\
+ GX_ROP_10_0(GX_ROP_NOOP) | \
+ GX_ROP_01_1(O) |\
+ GX_ROP_01_0(GX_ROP_NOOP) |\
+ GX_ROP_00_1(O) |\
+ GX_ROP_00_0(GX_ROP_NOOP))
+
+static Uint gx_blit_rop_table[16]={
+ ROP_BLIT(GX_ROP_CLEAR, GX_ROP_CLEAR), /* GXclear */
+ ROP_BLIT(GX_ROP_CLEAR, GX_ROP_NOOP), /* GXand */
+ ROP_BLIT(GX_ROP_CLEAR, GX_ROP_INVERT), /* GXandReverse */
+ ROP_BLIT(GX_ROP_CLEAR, GX_ROP_SET), /* GXcopy */
+ ROP_BLIT(GX_ROP_NOOP, GX_ROP_CLEAR), /* GXandInverted */
+ ROP_BLIT(GX_ROP_NOOP, GX_ROP_NOOP), /* GXnoop */
+ ROP_BLIT(GX_ROP_NOOP, GX_ROP_INVERT), /* GXxor */
+ ROP_BLIT(GX_ROP_NOOP, GX_ROP_SET), /* GXor */
+ ROP_BLIT(GX_ROP_INVERT, GX_ROP_CLEAR), /* GXnor */
+ ROP_BLIT(GX_ROP_INVERT, GX_ROP_NOOP), /* GXequiv */
+ ROP_BLIT(GX_ROP_INVERT, GX_ROP_INVERT), /* GXinvert */
+ ROP_BLIT(GX_ROP_INVERT, GX_ROP_SET), /* GXorReverse */
+ ROP_BLIT(GX_ROP_SET, GX_ROP_CLEAR), /* GXcopyInverted */
+ ROP_BLIT(GX_ROP_SET, GX_ROP_NOOP), /* GXorInverted */
+ ROP_BLIT(GX_ROP_SET, GX_ROP_INVERT), /* GXnand */
+ ROP_BLIT(GX_ROP_SET, GX_ROP_SET), /* GXset */
+};
+
+/* rops for solid drawing
+ with:
+ Plane Mask - use plane mask reg.
+ Pixel Mask - use all ones.
+ Patt Mask - use all ones.
+*/
+
+static Uint gx_solid_rop_table[16]={
+ ROP_FILL(GX_ROP_CLEAR, GX_ROP_CLEAR), /* GXclear */
+ ROP_FILL(GX_ROP_CLEAR, GX_ROP_NOOP), /* GXand */
+ ROP_FILL(GX_ROP_CLEAR, GX_ROP_INVERT), /* GXandReverse */
+ ROP_FILL(GX_ROP_CLEAR, GX_ROP_SET), /* GXcopy */
+ ROP_FILL(GX_ROP_NOOP, GX_ROP_CLEAR), /* GXandInverted */
+ ROP_FILL(GX_ROP_NOOP, GX_ROP_NOOP), /* GXnoop */
+ ROP_FILL(GX_ROP_NOOP, GX_ROP_INVERT), /* GXxor */
+ ROP_FILL(GX_ROP_NOOP, GX_ROP_SET), /* GXor */
+ ROP_FILL(GX_ROP_INVERT, GX_ROP_CLEAR), /* GXnor */
+ ROP_FILL(GX_ROP_INVERT, GX_ROP_NOOP), /* GXequiv */
+ ROP_FILL(GX_ROP_INVERT, GX_ROP_INVERT), /* GXinvert */
+ ROP_FILL(GX_ROP_INVERT, GX_ROP_SET), /* GXorReverse */
+ ROP_FILL(GX_ROP_SET, GX_ROP_CLEAR), /* GXcopyInverted */
+ ROP_FILL(GX_ROP_SET, GX_ROP_NOOP), /* GXorInverted */
+ ROP_FILL(GX_ROP_SET, GX_ROP_INVERT), /* GXnand */
+ ROP_FILL(GX_ROP_SET, GX_ROP_SET), /* GXset */
+};
+
+static Uint gx_stipple_rop_table[16]={
+ ROP_STIP(GX_ROP_CLEAR, GX_ROP_CLEAR), /* GXclear */
+ ROP_STIP(GX_ROP_CLEAR, GX_ROP_NOOP), /* GXand */
+ ROP_STIP(GX_ROP_CLEAR, GX_ROP_INVERT), /* GXandReverse */
+ ROP_STIP(GX_ROP_CLEAR, GX_ROP_SET), /* GXcopy */
+ ROP_STIP(GX_ROP_NOOP, GX_ROP_CLEAR), /* GXandInverted */
+ ROP_STIP(GX_ROP_NOOP, GX_ROP_NOOP), /* GXnoop */
+ ROP_STIP(GX_ROP_NOOP, GX_ROP_INVERT), /* GXxor */
+ ROP_STIP(GX_ROP_NOOP, GX_ROP_SET), /* GXor */
+ ROP_STIP(GX_ROP_INVERT, GX_ROP_CLEAR), /* GXnor */
+ ROP_STIP(GX_ROP_INVERT, GX_ROP_NOOP), /* GXequiv */
+ ROP_STIP(GX_ROP_INVERT, GX_ROP_INVERT), /* GXinvert */
+ ROP_STIP(GX_ROP_INVERT, GX_ROP_SET), /* GXorReverse */
+ ROP_STIP(GX_ROP_SET, GX_ROP_CLEAR), /* GXcopyInverted */
+ ROP_STIP(GX_ROP_SET, GX_ROP_NOOP), /* GXorInverted */
+ ROP_STIP(GX_ROP_SET, GX_ROP_INVERT), /* GXnand */
+ ROP_STIP(GX_ROP_SET, GX_ROP_SET), /* GXset */
+};
+
+static Uint gx_opaque_stipple_rop_table[16]={
+ ROP_OSTP(GX_ROP_CLEAR, GX_ROP_CLEAR), /* GXclear */
+ ROP_OSTP(GX_ROP_CLEAR, GX_ROP_NOOP), /* GXand */
+ ROP_OSTP(GX_ROP_CLEAR, GX_ROP_INVERT), /* GXandReverse */
+ ROP_OSTP(GX_ROP_CLEAR, GX_ROP_SET), /* GXcopy */
+ ROP_OSTP(GX_ROP_NOOP, GX_ROP_CLEAR), /* GXandInverted */
+ ROP_OSTP(GX_ROP_NOOP, GX_ROP_NOOP), /* GXnoop */
+ ROP_OSTP(GX_ROP_NOOP, GX_ROP_INVERT), /* GXxor */
+ ROP_OSTP(GX_ROP_NOOP, GX_ROP_SET), /* GXor */
+ ROP_OSTP(GX_ROP_INVERT, GX_ROP_CLEAR), /* GXnor */
+ ROP_OSTP(GX_ROP_INVERT, GX_ROP_NOOP), /* GXequiv */
+ ROP_OSTP(GX_ROP_INVERT, GX_ROP_INVERT), /* GXinvert */
+ ROP_OSTP(GX_ROP_INVERT, GX_ROP_SET), /* GXorReverse */
+ ROP_OSTP(GX_ROP_SET, GX_ROP_CLEAR), /* GXcopyInverted */
+ ROP_OSTP(GX_ROP_SET, GX_ROP_NOOP), /* GXorInverted */
+ ROP_OSTP(GX_ROP_SET, GX_ROP_INVERT), /* GXnand */
+ ROP_OSTP(GX_ROP_SET, GX_ROP_SET), /* GXset */
+};
+
+int sunGXScreenPrivateIndex;
+int sunGXGCPrivateIndex;
+int sunGXWindowPrivateIndex;
+int sunGXGeneration;
+
+/*
+ sunGXDoBitBlt
+ =============
+ Bit Blit for all window to window blits.
+*/
+static void
+sunGXDoBitblt(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
+ DrawablePtr pSrc, pDst;
+ int alu;
+ RegionPtr prgnDst;
+ DDXPointPtr pptSrc;
+ unsigned long planemask;
+{
+ register sunGXPtr gx = sunGXGetScreenPrivate (pSrc->pScreen);
+ register long r;
+ register BoxPtr pboxTmp;
+ register DDXPointPtr pptTmp;
+ register int nbox;
+ BoxPtr pboxNext,pboxBase,pbox;
+
+ /* setup GX ( need fg of 0xff for blits ) */
+ GXBlitInit(gx,gx_blit_rop_table[alu]|POLY_O,planemask);
+
+ pbox = REGION_RECTS(prgnDst);
+ nbox = REGION_NUM_RECTS(prgnDst);
+
+ /* need to blit rectangles in different orders, depending on the direction of copy
+ so that an area isnt overwritten before it is blitted */
+ if( (pptSrc->y < pbox->y1) && (nbox > 1) ){
+
+ if( (pptSrc->x < pbox->x1) && (nbox > 1) ){
+
+ /* reverse order of bands and rects in each band */
+ pboxTmp=pbox+nbox;
+ pptTmp=pptSrc+nbox;
+
+ while (nbox--){
+ pboxTmp--;
+ pptTmp--;
+ gx->x0=pptTmp->x;
+ gx->y0=pptTmp->y;
+ gx->x1=pptTmp->x+(pboxTmp->x2-pboxTmp->x1)-1;
+ gx->y1=pptTmp->y+(pboxTmp->y2-pboxTmp->y1)-1;
+ gx->x2=pboxTmp->x1;
+ gx->y2=pboxTmp->y1;
+ gx->x3=pboxTmp->x2-1;
+ gx->y3=pboxTmp->y2-1;
+ GXBlitDone(gx,r);
+ }
+ }
+ else{
+
+ /* keep ordering in each band, reverse order of bands */
+ pboxBase = pboxNext = pbox+nbox-1;
+
+ while (pboxBase >= pbox){ /* for each band */
+
+ /* find first box in band */
+ while ((pboxNext >= pbox) &&
+ (pboxBase->y1 == pboxNext->y1))
+ pboxNext--;
+
+ pboxTmp = pboxNext+1; /* first box in band */
+ pptTmp = pptSrc + (pboxTmp - pbox); /* first point in band */
+
+ while (pboxTmp <= pboxBase){ /* for each box in band */
+ gx->x0=pptTmp->x;
+ gx->y0=pptTmp->y;
+ gx->x1=pptTmp->x+(pboxTmp->x2-pboxTmp->x1)-1;
+ gx->y1=pptTmp->y+(pboxTmp->y2-pboxTmp->y1)-1;
+ gx->x2=pboxTmp->x1;
+ gx->y2=pboxTmp->y1;
+ gx->x3=pboxTmp->x2-1;
+ gx->y3=pboxTmp->y2-1;
+ ++pboxTmp;
+ ++pptTmp;
+ GXBlitDone(gx,r);
+ }
+ pboxBase = pboxNext;
+ }
+ }
+ }
+ else{
+
+ if( (pptSrc->x < pbox->x1) && (nbox > 1) ){
+
+ /* reverse order of rects in each band */
+ pboxBase = pboxNext = pbox;
+
+ while (pboxBase < pbox+nbox){ /* for each band */
+
+ /* find last box in band */
+ while ((pboxNext < pbox+nbox) &&
+ (pboxNext->y1 == pboxBase->y1))
+ pboxNext++;
+
+ pboxTmp = pboxNext; /* last box in band */
+ pptTmp = pptSrc + (pboxTmp - pbox); /* last point in band */
+
+ while (pboxTmp != pboxBase){ /* for each box in band */
+ --pboxTmp;
+ --pptTmp;
+ gx->x0=pptTmp->x;
+ gx->y0=pptTmp->y;
+ gx->x1=pptTmp->x+(pboxTmp->x2-pboxTmp->x1)-1;
+ gx->y1=pptTmp->y+(pboxTmp->y2-pboxTmp->y1)-1;
+ gx->x2=pboxTmp->x1;
+ gx->y2=pboxTmp->y1;
+ gx->x3=pboxTmp->x2-1;
+ gx->y3=pboxTmp->y2-1;
+ GXBlitDone(gx,r);
+ }
+ pboxBase = pboxNext;
+ }
+ }
+ else{
+
+ /* dont need to change order of anything */
+ pptTmp=pptSrc;
+ pboxTmp=pbox;
+
+ while(nbox--){
+ gx->x0=pptTmp->x;
+ gx->y0=pptTmp->y;
+ gx->x1=pptTmp->x+(pboxTmp->x2-pboxTmp->x1)-1;
+ gx->y1=pptTmp->y+(pboxTmp->y2-pboxTmp->y1)-1;
+ gx->x2=pboxTmp->x1;
+ gx->y2=pboxTmp->y1;
+ gx->x3=pboxTmp->x2-1;
+ gx->y3=pboxTmp->y2-1;
+ pboxTmp++;
+ pptTmp++;
+ GXBlitDone(gx,r);
+ }
+ }
+ }
+ GXWait(gx,r);
+}
+
+RegionPtr
+sunGXCopyArea(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty)
+ register DrawablePtr pSrcDrawable;
+ register DrawablePtr pDstDrawable;
+ GC *pGC;
+ int srcx, srcy;
+ int width, height;
+ int dstx, dsty;
+{
+ if (pSrcDrawable->type != DRAWABLE_WINDOW)
+ return cfbCopyArea (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+ return cfbBitBlt (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, sunGXDoBitblt, 0);
+}
+
+static unsigned long copyPlaneFG, copyPlaneBG;
+
+static void
+sunGXCopyPlane1to8 (pSrcDrawable, pDstDrawable, rop, prgnDst, pptSrc, planemask, bitPlane)
+ DrawablePtr pSrcDrawable;
+ DrawablePtr pDstDrawable;
+ int rop;
+ RegionPtr prgnDst;
+ DDXPointPtr pptSrc;
+ unsigned long planemask;
+ unsigned long bitPlane;
+{
+ register sunGXPtr gx = sunGXGetScreenPrivate (pDstDrawable->pScreen);
+ int srcx, srcy, dstx, dsty, width, height;
+ int dstLastx, dstRightx;
+ int xoffSrc, widthSrc, widthRest;
+ int widthLast;
+ unsigned long *psrcBase, *psrc;
+ unsigned long bits, tmp;
+ register int leftShift, rightShift;
+ register int nl, nlMiddle;
+ int nbox;
+ BoxPtr pbox;
+ register int r;
+
+ GXDrawInit (gx, copyPlaneFG,
+ gx_opaque_stipple_rop_table[rop]|GX_PATTERN_ONES,
+ planemask);
+ gx->bg = copyPlaneBG;
+ gx->mode = GX_BLIT_NOSRC | GX_MODE_COLOR1;
+
+ cfbGetLongWidthAndPointer (pSrcDrawable, widthSrc, psrcBase)
+
+ nbox = REGION_NUM_RECTS(prgnDst);
+ pbox = REGION_RECTS(prgnDst);
+ gx->incx = 32;
+ gx->incy = 0;
+ while (nbox--)
+ {
+ dstx = pbox->x1;
+ dsty = pbox->y1;
+ srcx = pptSrc->x;
+ srcy = pptSrc->y;
+ dstLastx = pbox->x2;
+ width = dstLastx - dstx;
+ height = pbox->y2 - dsty;
+ pbox++;
+ pptSrc++;
+ if (!width)
+ continue;
+ psrc = psrcBase + srcy * widthSrc + (srcx >> 5);
+ dstLastx--;
+ dstRightx = dstx + 31;
+ nlMiddle = (width + 31) >> 5;
+ widthLast = width & 31;
+ xoffSrc = srcx & 0x1f;
+ leftShift = xoffSrc;
+ rightShift = 32 - leftShift;
+ widthRest = widthSrc - nlMiddle;
+ if (widthLast)
+ nlMiddle--;
+ if (leftShift == 0)
+ {
+ while (height--)
+ {
+ gx->x0 = dstx;
+ gx->x1 = dstRightx;
+ gx->y0 = dsty++;
+ nl = nlMiddle;
+ while (nl--)
+ gx->font = *psrc++;
+ if (widthLast)
+ {
+ gx->x1 = dstLastx;
+ gx->font = *psrc++;
+ }
+ psrc += widthRest;
+ }
+ }
+ else
+ {
+ widthRest--;
+ while (height--)
+ {
+ gx->x0 = dstx;
+ gx->x1 = dstRightx;
+ gx->y0 = dsty++;
+ bits = *psrc++;
+ nl = nlMiddle;
+ while (nl--)
+ {
+ tmp = BitLeft(bits, leftShift);
+ bits = *psrc++;
+ tmp |= BitRight(bits, rightShift);
+ gx->font = tmp;
+ }
+ if (widthLast)
+ {
+ tmp = BitLeft(bits, leftShift);
+ bits = *psrc++;
+ tmp |= BitRight(bits, rightShift);
+ gx->x1 = dstLastx;
+ gx->font = tmp;
+ }
+ psrc += widthRest;
+ }
+ }
+ }
+ GXWait (gx, r);
+ gx->incx = 0;
+ gx->incy = 0;
+ gx->mode = GX_BLIT_SRC | GX_MODE_COLOR8;
+}
+
+RegionPtr sunGXCopyPlane(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, bitPlane)
+ DrawablePtr pSrcDrawable;
+ DrawablePtr pDstDrawable;
+ GCPtr pGC;
+ int srcx, srcy;
+ int width, height;
+ int dstx, dsty;
+ unsigned long bitPlane;
+{
+ RegionPtr ret;
+
+ if (pSrcDrawable->bitsPerPixel == 1 && pDstDrawable->bitsPerPixel == 8)
+ {
+ if (bitPlane == 1)
+ {
+ copyPlaneFG = pGC->fgPixel;
+ copyPlaneBG = pGC->bgPixel;
+ ret = cfbBitBlt (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, sunGXCopyPlane1to8, bitPlane);
+ }
+ else
+ ret = miHandleExposures (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
+ }
+ else if (pSrcDrawable->bitsPerPixel == 8 && pDstDrawable->bitsPerPixel == 1)
+ {
+ extern int InverseAlu[16];
+ int oldalu;
+
+ oldalu = pGC->alu;
+ if ((pGC->fgPixel & 1) == 0 && (pGC->bgPixel&1) == 1)
+ pGC->alu = InverseAlu[pGC->alu];
+ else if ((pGC->fgPixel & 1) == (pGC->bgPixel & 1))
+ pGC->alu = mfbReduceRop(pGC->alu, pGC->fgPixel);
+ ret = cfbCopyPlaneReduce (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, cfbCopyPlane8to1, bitPlane);
+ pGC->alu = oldalu;
+ }
+ else
+ {
+ PixmapPtr pBitmap;
+ ScreenPtr pScreen = pSrcDrawable->pScreen;
+ GCPtr pGC1;
+
+ pBitmap = (*pScreen->CreatePixmap) (pScreen, width, height, 1);
+ if (!pBitmap)
+ return NULL;
+ pGC1 = GetScratchGC (1, pScreen);
+ if (!pGC1)
+ {
+ (*pScreen->DestroyPixmap) (pBitmap);
+ return NULL;
+ }
+ /*
+ * don't need to set pGC->fgPixel,bgPixel as copyPlane8to1
+ * ignores pixel values, expecting the rop to "do the
+ * right thing", which GXcopy will.
+ */
+ ValidateGC ((DrawablePtr) pBitmap, pGC1);
+ /* no exposures here, scratch GC's don't get graphics expose */
+ (void) cfbCopyPlaneReduce (pSrcDrawable, (DrawablePtr) pBitmap,
+ pGC1, srcx, srcy, width, height, 0, 0, cfbCopyPlane8to1, bitPlane);
+ copyPlaneFG = pGC->fgPixel;
+ copyPlaneBG = pGC->bgPixel;
+ (void) cfbBitBlt ((DrawablePtr) pBitmap, pDstDrawable, pGC,
+ 0, 0, width, height, dstx, dsty, sunGXCopyPlane1to8, 1);
+ FreeScratchGC (pGC1);
+ (*pScreen->DestroyPixmap) (pBitmap);
+ /* compute resultant exposures */
+ ret = miHandleExposures (pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height,
+ dstx, dsty, bitPlane);
+ }
+ return ret;
+}
+
+void
+sunGXFillRectAll (pDrawable, pGC, nBox, pBox)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nBox;
+ BoxPtr pBox;
+{
+ register sunGXPtr gx = sunGXGetScreenPrivate (pDrawable->pScreen);
+ register sunGXPrivGCPtr gxPriv = sunGXGetGCPrivate (pGC);
+ register int r;
+
+ GXDrawInit(gx,pGC->fgPixel,gx_solid_rop_table[pGC->alu]|POLY_N,pGC->planemask);
+ if (gxPriv->stipple)
+ GXStippleInit(gx,gxPriv->stipple);
+ while (nBox--) {
+ gx->arecty = pBox->y1;
+ gx->arectx = pBox->x1;
+ gx->arecty = pBox->y2;
+ gx->arectx = pBox->x2;
+ pBox++;
+ GXDrawDone(gx,r);
+ }
+ GXWait(gx,r);
+}
+
+#define NUM_STACK_RECTS 1024
+
+void
+sunGXPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int nrectFill; /* number of rectangles to fill */
+ xRectangle *prectInit; /* Pointer to first rectangle to fill */
+{
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ register BoxPtr pbox;
+ register BoxPtr pboxClipped;
+ BoxPtr pboxClippedBase;
+ BoxPtr pextent;
+ BoxRec stackRects[NUM_STACK_RECTS];
+ int numRects;
+ int n;
+ int xorg, yorg;
+
+ prgnClip = pGC->pCompositeClip;
+ prect = prectInit;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ if (xorg || yorg)
+ {
+ prect = prectInit;
+ n = nrectFill;
+ while(n--)
+ {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+ prect = prectInit;
+
+ numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
+ if (numRects > NUM_STACK_RECTS)
+ {
+ pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(numRects * sizeof(BoxRec));
+ if (!pboxClippedBase)
+ return;
+ }
+ else
+ pboxClippedBase = stackRects;
+
+ pboxClipped = pboxClippedBase;
+
+ if (REGION_NUM_RECTS(prgnClip) == 1)
+ {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_RECTS(prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--)
+ {
+ if ((pboxClipped->x1 = prect->x) < x1)
+ pboxClipped->x1 = x1;
+
+ if ((pboxClipped->y1 = prect->y) < y1)
+ pboxClipped->y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ pboxClipped->x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ pboxClipped->y2 = by2;
+
+ prect++;
+ if ((pboxClipped->x1 < pboxClipped->x2) &&
+ (pboxClipped->y1 < pboxClipped->y2))
+ {
+ pboxClipped++;
+ }
+ }
+ }
+ else
+ {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--)
+ {
+ BoxRec box;
+
+ if ((box.x1 = prect->x) < x1)
+ box.x1 = x1;
+
+ if ((box.y1 = prect->y) < y1)
+ box.y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ box.x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ box.y2 = by2;
+
+ prect++;
+
+ if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
+ continue;
+
+ n = REGION_NUM_RECTS (prgnClip);
+ pbox = REGION_RECTS(prgnClip);
+
+ /* clip the rectangle to each box in the clip region
+ this is logically equivalent to calling Intersect()
+ */
+ while(n--)
+ {
+ pboxClipped->x1 = max(box.x1, pbox->x1);
+ pboxClipped->y1 = max(box.y1, pbox->y1);
+ pboxClipped->x2 = min(box.x2, pbox->x2);
+ pboxClipped->y2 = min(box.y2, pbox->y2);
+ pbox++;
+
+ /* see if clipping left anything */
+ if(pboxClipped->x1 < pboxClipped->x2 &&
+ pboxClipped->y1 < pboxClipped->y2)
+ {
+ pboxClipped++;
+ }
+ }
+ }
+ }
+ if (pboxClipped != pboxClippedBase)
+ sunGXFillRectAll(pDrawable, pGC,
+ pboxClipped-pboxClippedBase, pboxClippedBase);
+ if (pboxClippedBase != stackRects)
+ DEALLOCATE_LOCAL(pboxClippedBase);
+}
+
+void
+sunGXFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int n; /* number of spans to fill */
+ DDXPointPtr ppt; /* pointer to list of start points */
+ int *pwidth; /* pointer to list of n widths */
+ int fSorted;
+{
+ int x, y;
+ int width;
+ /* next three parameters are post-clip */
+ int nTmp;
+ int *pwidthFree;/* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ register sunGXPtr gx = sunGXGetScreenPrivate (pDrawable->pScreen);
+ cfbPrivGCPtr devPriv = cfbGetGCPrivate(pGC);
+ register sunGXPrivGCPtr gxPriv = sunGXGetGCPrivate (pGC);
+ register int r;
+ BoxPtr extents;
+
+ GXDrawInit(gx,pGC->fgPixel,gx_solid_rop_table[pGC->alu]|POLY_O,pGC->planemask)
+ if (gxPriv->stipple)
+ GXStippleInit(gx,gxPriv->stipple);
+ if (devPriv->oneRect)
+ {
+ extents = &pGC->pCompositeClip->extents;
+ GXSetClip (gx, extents);
+ }
+ else
+ {
+ nTmp = n * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(nTmp * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(nTmp * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ n = miClipSpans(pGC->pCompositeClip, ppt, pwidth, n,
+ pptFree, pwidthFree, fSorted);
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ }
+ while (n--)
+ {
+ x = ppt->x;
+ y = ppt->y;
+ ppt++;
+ width = *pwidth++;
+ if (width)
+ {
+ sunGXFillSpan(gx,y,x,x + width - 1,r);
+ }
+ }
+ GXWait(gx,r);
+ if (devPriv->oneRect)
+ {
+ GXResetClip (gx, pDrawable->pScreen);
+ }
+ else
+ {
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+ }
+}
+
+#ifdef NOTDEF
+/* cfb is faster for dots */
+void
+sunGXPolyPoint(pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode;
+ int npt;
+ xPoint *pptInit;
+{
+ register sunGXPtr gx = sunGXGetScreenPrivate (pDrawable->pScreen);
+ RegionPtr cclip;
+ int nbox;
+ register int i;
+ register BoxPtr pbox;
+ cfbPrivGCPtr devPriv;
+ xPoint *ppt;
+ int x, y;
+ int r;
+ int off;
+
+ devPriv = (cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr);
+ if (devPriv->rop == GXnoop)
+ return;
+ cclip = pGC->pCompositeClip;
+ GXDrawInit(gx,pGC->fgPixel,gx_solid_rop_table[pGC->alu],pGC->planemask);
+ gx->offx = pDrawable->x;
+ gx->offy = pDrawable->y;
+ for (nbox = REGION_NUM_RECTS(cclip), pbox = REGION_RECTS(cclip);
+ --nbox >= 0;
+ pbox++)
+ {
+ sunGXSetClip(gx,pbox);
+ if (mode != CoordModeOrigin)
+ {
+ x = 0;
+ y = 0;
+ for (ppt = pptInit, i = npt; --i >= 0;)
+ {
+ gx->apointy = y += ppt->y;
+ gx->apointx = x += ppt->x;
+ ++ppt;
+ GXDrawDone(gx,r);
+ }
+ }
+ else
+ {
+ for (ppt = pptInit, i = npt; --i >= 0;)
+ {
+ gx->apointy = ppt->y;
+ gx->apointx = ppt->x;
+ ++ppt;
+ GXDrawDone(gx,r);
+ }
+ }
+ }
+ GXWait(gx,r);
+ GXResetOff (gx);
+ GXResetClip(gx,pDrawable->pScreen);
+}
+#endif
+
+#include "mifillarc.h"
+
+#define FILLSPAN(gx,y,x1,x2,r) {\
+ if (x2 >= x1) {\
+ sunGXFillSpan(gx,y,x1,x2,r) \
+ } \
+}
+
+#define FILLSLICESPANS(flip,y) \
+ if (!flip) \
+ { \
+ FILLSPAN(gx,y,xl,xr,r) \
+ } \
+ else \
+ { \
+ xc = xorg - x; \
+ FILLSPAN(gx, y, xc, xr, r) \
+ xc += slw - 1; \
+ FILLSPAN(gx, y, xl, xc, r) \
+ }
+
+static void
+sunGXFillEllipse (pDraw, gx, arc)
+ DrawablePtr pDraw;
+ sunGXPtr gx;
+ xArc *arc;
+{
+ int x, y, e;
+ int yk, xk, ym, xm, dx, dy, xorg, yorg;
+ int y_top, y_bot;
+ miFillArcRec info;
+ register int xpos;
+ int r;
+ int slw;
+
+ miFillArcSetup(arc, &info);
+ MIFILLARCSETUP();
+ y_top = yorg - y;
+ y_bot = yorg + y + dy;
+ while (y)
+ {
+ y_top++;
+ y_bot--;
+ MIFILLARCSTEP(slw);
+ if (!slw)
+ continue;
+ xpos = xorg - x;
+ sunGXFillSpan (gx,y_top,xpos,xpos+slw - 1,r);
+ if (miFillArcLower(slw))
+ sunGXFillSpan (gx,y_bot,xpos,xpos+slw - 1,r);
+ }
+}
+
+
+static void
+sunGXFillArcSlice (pDraw, pGC, gx, arc)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ sunGXPtr gx;
+ xArc *arc;
+{
+ int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
+ register int x, y, e;
+ miFillArcRec info;
+ miArcSliceRec slice;
+ int xl, xr, xc;
+ int y_top, y_bot;
+ int r;
+
+ miFillArcSetup(arc, &info);
+ miFillArcSliceSetup(arc, &slice, pGC);
+ MIFILLARCSETUP();
+ y_top = yorg - y;
+ y_bot = yorg + y + dy;
+ while (y > 0)
+ {
+ y_top++;
+ y_bot--;
+ MIFILLARCSTEP(slw);
+ MIARCSLICESTEP(slice.edge1);
+ MIARCSLICESTEP(slice.edge2);
+ if (miFillSliceUpper(slice))
+ {
+ MIARCSLICEUPPER(xl, xr, slice, slw);
+ FILLSLICESPANS(slice.flip_top, y_top);
+ }
+ if (miFillSliceLower(slice))
+ {
+ MIARCSLICELOWER(xl, xr, slice, slw);
+ FILLSLICESPANS(slice.flip_bot, y_bot);
+ }
+ }
+}
+
+#define FAST_CIRCLES
+#ifdef FAST_CIRCLES
+#if (BITMAP_BIT_ORDER == MSBFirst)
+#define Bits32(v) (v)
+#define Bits16(v) (v)
+#define Bits8(v) (v)
+#else
+#define FlipBits2(a) ((((a) & 0x1) << 1) | (((a) & 0x2) >> 1))
+#define FlipBits4(a) ((FlipBits2(a) << 2) | FlipBits2(a >> 2))
+#define FlipBits8(a) ((FlipBits4(a) << 4) | FlipBits4(a >> 4))
+#define FlipBits16(a) ((FlipBits8(a) << 8) | FlipBits8(a >> 8))
+#define FlipBits32(a) ((FlipBits16(a) << 16) | FlipBits16(a >> 16))
+#define Bits32(v) FlipBits32(v)
+#define Bits16(v) FlipBits16(v)
+#define Bits8(v) FlipBits8(v)
+#endif
+
+#define B(x) Bits16(x)
+#define DO_FILLED_ARCS
+#include "circleset.h"
+#undef B
+#undef Bits8
+#undef Bits16
+#undef Bits32
+#define UNSET_CIRCLE if (old_width) \
+ { \
+ gx->alu = gx_solid_rop_table[pGC->alu]; \
+ old_width = -old_width; \
+ }
+
+#else
+#define UNSET_CIRCLE
+#endif
+
+void
+sunGXPolyFillArc (pDraw, pGC, narcs, parcs)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int narcs;
+ xArc *parcs;
+{
+ register xArc *arc;
+ register int i;
+ int x, y;
+ BoxRec box;
+ BoxPtr extents = NULL;
+ RegionPtr cclip;
+ register sunGXPtr gx = sunGXGetScreenPrivate (pDraw->pScreen);
+ sunGXPrivGCPtr gxPriv = sunGXGetGCPrivate (pGC);
+ cfbPrivGCPtr devPriv;
+ register int r;
+#ifdef FAST_CIRCLES
+ int old_width = 0;
+#endif
+
+ GXDrawInit(gx,pGC->fgPixel,gx_solid_rop_table[pGC->alu]|POLY_O,pGC->planemask);
+ if (gxPriv->stipple)
+ GXStippleInit(gx,gxPriv->stipple);
+ devPriv = (cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr);
+ cclip = pGC->pCompositeClip;
+ GXSetOff(gx,pDraw->x,pDraw->y)
+ if (devPriv->oneRect) {
+ extents = &cclip->extents;
+ GXSetClip(gx,extents);
+ }
+ for (arc = parcs, i = narcs; --i >= 0; arc++)
+ {
+ if (miFillArcEmpty(arc))
+ continue;
+ if (miCanFillArc(arc))
+ {
+ x = arc->x;
+ y = arc->y;
+ if (!devPriv->oneRect)
+ {
+ box.x1 = x + pDraw->x;
+ box.y1 = y + pDraw->y;
+ box.x2 = box.x1 + (int)arc->width + 1;
+ box.y2 = box.y1 + (int)arc->height + 1;
+ }
+ if (devPriv->oneRect ||
+ RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN)
+ {
+ if ((arc->angle2 >= FULLCIRCLE) ||
+ (arc->angle2 <= -FULLCIRCLE))
+ {
+#ifdef FAST_CIRCLES
+/* who really needs fast filled circles? */
+ if (arc->width == arc->height && arc->width <= 16 &&
+ !gxPriv->stipple)
+ {
+ int offx, offy;
+ if (arc->width != old_width)
+ {
+ int i;
+ Uint *sp;
+ VUint *dp;
+
+ if (old_width != -arc->width)
+ {
+ sp = (Uint *) filled_arcs[arc->width-1];
+ dp = gx->pattern;
+ i = 8;
+ while (i--)
+ dp[i] = sp[i];
+ }
+ gx->alu = gx_stipple_rop_table[pGC->alu]|GX_PATTERN_MASK;
+ old_width = arc->width;
+ }
+ offx = 16 - ((x + pDraw->x) & 0x0f);
+ offy = 16 - ((y + pDraw->y) & 0x0f);
+ gx->patalign = (offx << 16) | offy;
+ gx->arecty = y;
+ gx->arectx = x;
+ gx->arecty = y + old_width-1;
+ gx->arectx = x + old_width-1;
+ GXDrawDone (gx, r);
+ }
+ else
+#endif
+ {
+ UNSET_CIRCLE
+ sunGXFillEllipse (pDraw, gx, arc);
+ }
+ }
+ else
+ {
+ UNSET_CIRCLE
+ sunGXFillArcSlice (pDraw, pGC, gx, arc);
+ }
+ continue;
+ }
+ }
+ UNSET_CIRCLE
+ GXWait (gx,r);
+ GXResetOff (gx);
+ if (devPriv->oneRect)
+ GXResetClip (gx, pDraw->pScreen);
+ miPolyFillArc(pDraw, pGC, 1, arc);
+ GXSetOff (gx, pDraw->x, pDraw->y);
+ if (devPriv->oneRect)
+ GXSetClip (gx, extents);
+ }
+ GXWait (gx, r);
+ GXResetOff (gx);
+ if (devPriv->oneRect)
+ GXResetClip (gx, pDraw->pScreen);
+}
+
+void
+sunGXFillPoly1Rect (pDrawable, pGC, shape, mode, count, ptsIn)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int count;
+ DDXPointPtr ptsIn;
+{
+ BoxPtr extents;
+ int x1, x2, x3, x4;
+ int y1, y2, y3, y4;
+ sunGXPtr gx = sunGXGetScreenPrivate (pDrawable->pScreen);
+ sunGXPrivGCPtr gxPriv = sunGXGetGCPrivate (pGC);
+ int r;
+ typedef struct {
+ Uint x;
+ Uint y;
+ Uint z;
+ } GXPointRec, *GXPointPtr;
+ GXPointPtr tri, qua;
+
+ if (count < 3)
+ return;
+ if (shape != Convex && count > 4)
+ {
+ miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+ GXDrawInit(gx,pGC->fgPixel,gx_solid_rop_table[pGC->alu]|POLY_N,pGC->planemask);
+ if (gxPriv->stipple)
+ GXStippleInit(gx,gxPriv->stipple);
+ extents = &pGC->pCompositeClip->extents;
+ GXSetOff(gx,pDrawable->x, pDrawable->y);
+ GXSetClip(gx,extents);
+ if (mode == CoordModeOrigin)
+ {
+ tri = (GXPointPtr) &gx->atrix;
+ qua = (GXPointPtr) &gx->aquadx;
+ }
+ else
+ {
+ tri = (GXPointPtr) &gx->rtrix;
+ qua = (GXPointPtr) &gx->rquadx;
+ }
+ if (count == 3) {
+ gx->apointy = ptsIn[0].y;
+ gx->apointx = ptsIn[0].x;
+ tri->y = ptsIn[1].y;
+ tri->x = ptsIn[1].x;
+ tri->y = ptsIn[2].y;
+ tri->x = ptsIn[2].x;
+ GXDrawDone (gx, r);
+ }
+ else if (count == 4)
+ {
+ gx->apointy = ptsIn[0].y;
+ gx->apointx = ptsIn[0].x;
+ qua->y = ptsIn[1].y;
+ qua->x = ptsIn[1].x;
+ qua->y = ptsIn[2].y;
+ qua->x = ptsIn[2].x;
+ qua->y = ptsIn[3].y;
+ qua->x = ptsIn[3].x;
+ GXDrawDone (gx, r);
+ if (r < 0 && shape != Convex)
+ {
+ GXWait(gx,r);
+ GXResetOff(gx);
+ GXResetClip(gx,pDrawable->pScreen);
+ miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+ }
+ else
+ {
+ y1 = ptsIn[0].y;
+ x1 = ptsIn[0].x;
+ y2 = ptsIn[1].y;
+ x2 = ptsIn[1].x;
+ count -= 2;
+ ptsIn += 2;
+ while (count) {
+ x3 = ptsIn->x;
+ y3 = ptsIn->y;
+ ptsIn++;
+ count--;
+ gx->apointy = y1;
+ gx->apointx = x1;
+ if (count == 0) {
+ tri->y = y2;
+ tri->x = x2;
+ tri->y = y3;
+ tri->x = x3;
+ }
+ else
+ {
+ y4 = ptsIn->y;
+ x4 = ptsIn->x;
+ ptsIn++;
+ count--;
+ qua->y = y2;
+ qua->x = x2;
+ qua->y = y3;
+ qua->x = x3;
+ qua->y = y4;
+ qua->x = x4;
+ if (mode == CoordModeOrigin)
+ {
+ x2 = x4;
+ y2 = y4;
+ }
+ else
+ {
+ x2 = x2 + x3 + x4;
+ y2 = y2 + y3 + y4;
+ }
+ }
+ GXDrawDone (gx, r);
+ }
+ }
+ GXWait(gx,r);
+ GXResetOff(gx);
+ GXResetClip(gx,pDrawable->pScreen);
+}
+
+/*
+ * Note that the GX does not allow CapNotLast, so the code fakes it. This is
+ * expensive to do as the GX is asynchronous and must be synced with GXWait
+ * before fetching and storing the final line point. If only the hardware was
+ * designed for X.
+ */
+
+/* hard code the screen width; otherwise we'd have to check or mul */
+
+#define WIDTH_MUL(y) (((y) << 10) + ((y) << 7))
+#define GX_WIDTH 1152
+#define WID_OK(s) ((s)->width == GX_WIDTH)
+
+void
+sunGXPolySeg1Rect (pDrawable, pGC, nseg, pSeg)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nseg;
+ xSegment *pSeg;
+{
+ sunGXPtr gx = sunGXGetScreenPrivate (pDrawable->pScreen);
+ sunGXPrivGCPtr gxPriv = sunGXGetGCPrivate (pGC);
+ BoxPtr extents;
+ int x, y;
+ int r;
+ unsigned char *baseAddr, *loAddr, *hiAddr, *saveAddr = 0, save = 0;
+
+ GXDrawInit(gx,pGC->fgPixel,gx_solid_rop_table[pGC->alu]|POLY_O,pGC->planemask);
+ if (gxPriv->stipple)
+ GXStippleInit(gx,gxPriv->stipple);
+ GXSetOff (gx, pDrawable->x, pDrawable->y);
+
+ extents = &pGC->pCompositeClip->extents;
+ GXSetClip (gx, extents);
+ if (pGC->capStyle == CapNotLast)
+ {
+ sunGXGetAddrRange(pDrawable,extents,baseAddr,loAddr,hiAddr);
+ while (nseg--)
+ {
+ gx->aliney = pSeg->y1;
+ gx->alinex = pSeg->x1;
+ y = pSeg->y2;
+ x = pSeg->x2;
+ saveAddr = baseAddr + WIDTH_MUL(y) + x;
+ if (saveAddr < loAddr || hiAddr < saveAddr)
+ saveAddr = 0;
+ else
+ save = *saveAddr;
+ gx->aliney = y;
+ gx->alinex = x;
+ GXDrawDone (gx, r);
+ if (saveAddr)
+ {
+ GXWait(gx,r);
+ *saveAddr = save;
+ }
+ pSeg++;
+ }
+ }
+ else
+ {
+ while (nseg--)
+ {
+ gx->aliney = pSeg->y1;
+ gx->alinex = pSeg->x1;
+ gx->aliney = pSeg->y2;
+ gx->alinex = pSeg->x2;
+ pSeg++;
+ GXDrawDone (gx, r);
+ }
+ }
+ GXWait (gx, r);
+ GXResetOff (gx);
+ GXResetClip (gx, pDrawable->pScreen);
+}
+
+void
+sunGXPolylines1Rect (pDrawable, pGC, mode, npt, ppt)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode;
+ int npt;
+ DDXPointPtr ppt;
+{
+ sunGXPtr gx = sunGXGetScreenPrivate (pDrawable->pScreen);
+ sunGXPrivGCPtr gxPriv = sunGXGetGCPrivate (pGC);
+ BoxPtr extents;
+ unsigned char *baseAddr, *loAddr, *hiAddr, *saveAddr, save = 0;
+ int r;
+ Bool careful;
+ Bool capNotLast;
+
+ if (!--npt)
+ return;
+ GXDrawInit(gx,pGC->fgPixel,gx_solid_rop_table[pGC->alu]|POLY_O,pGC->planemask);
+ if (gxPriv->stipple)
+ GXStippleInit(gx,gxPriv->stipple);
+ careful = ((pGC->alu & 0xc) == 0x8 || (pGC->alu & 0x3) == 0x2);
+ capNotLast = pGC->capStyle == CapNotLast;
+
+ extents = &pGC->pCompositeClip->extents;
+ GXSetOff (gx, pDrawable->x, pDrawable->y);
+ GXSetClip (gx, extents);
+ if (careful)
+ {
+ int x, y;
+ sunGXGetAddrRange (pDrawable, extents, baseAddr, loAddr, hiAddr);
+ gx->apointy = y = ppt->y;
+ gx->apointx = x = ppt->x;
+ ppt++;
+ while (npt--)
+ {
+ if (mode == CoordModeOrigin)
+ {
+ y = ppt->y;
+ x = ppt->x;
+ }
+ else
+ {
+ y += ppt->y;
+ x += ppt->x;
+ }
+ ppt++;
+ saveAddr = baseAddr + WIDTH_MUL(y) + x;
+ if (saveAddr < loAddr || hiAddr < saveAddr)
+ saveAddr = 0;
+ else
+ save = *saveAddr;
+ gx->aliney = y;
+ gx->alinex = x;
+ GXDrawDone (gx, r);
+ if (saveAddr)
+ {
+ GXWait(gx,r);
+ *saveAddr = save;
+ }
+ }
+ GXWait(gx,r);
+ }
+ else
+ {
+ int x, y;
+ if (capNotLast)
+ npt--;
+ if (mode == CoordModeOrigin)
+ {
+ x = y = 0;
+ gx->apointy = ppt->y;
+ gx->apointx = ppt->x;
+ ppt++;
+ while (npt--)
+ {
+ gx->aliney = ppt->y;
+ gx->alinex = ppt->x;
+ ++ppt;
+ GXDrawDone(gx,r);
+ }
+ }
+ else
+ {
+ y = gx->apointy = ppt->y;
+ x = gx->apointx = ppt->x;
+ ppt++;
+ while (npt--)
+ {
+ y += gx->rliney = ppt->y;
+ x += gx->rlinex = ppt->x;
+ ++ppt;
+ GXDrawDone(gx,r);
+ }
+ }
+ if (capNotLast)
+ {
+ sunGXGetAddrRange (pDrawable, extents, baseAddr, loAddr, hiAddr);
+ x += ppt->x;
+ y += ppt->y;
+ saveAddr = baseAddr + WIDTH_MUL(y) + x;
+ if (saveAddr < loAddr || hiAddr < saveAddr)
+ saveAddr = 0;
+ else
+ save = *saveAddr;
+ gx->aliney = y;
+ gx->alinex = x;
+ GXDrawDone(gx,r);
+ GXWait(gx,r);
+ if (saveAddr)
+ *saveAddr = save;
+ }
+ else
+ {
+ GXWait(gx,r);
+ }
+ }
+ GXResetOff (gx);
+ GXResetClip (gx, pDrawable->pScreen);
+}
+
+void
+sunGXPolyFillRect1Rect (pDrawable, pGC, nrect, prect)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nrect;
+ xRectangle *prect;
+{
+ sunGXPtr gx = sunGXGetScreenPrivate (pDrawable->pScreen);
+ sunGXPrivGCPtr gxPriv = sunGXGetGCPrivate (pGC);
+ BoxPtr extents = &pGC->pCompositeClip->extents;
+ int r;
+ int x, y;
+
+ GXDrawInit(gx,pGC->fgPixel,gx_solid_rop_table[pGC->alu]|POLY_N,pGC->planemask);
+ if (gxPriv->stipple)
+ GXStippleInit(gx,gxPriv->stipple);
+ GXSetOff (gx, pDrawable->x, pDrawable->y);
+ GXSetClip (gx, extents);
+ while (nrect--)
+ {
+ gx->arecty = y = prect->y;
+ gx->arectx = x = prect->x;
+ gx->arecty = y + (int) prect->height;
+ gx->arectx = x + (int) prect->width;
+ prect++;
+ GXDrawDone (gx, r);
+ }
+ GXWait (gx, r);
+ GXResetOff (gx);
+ GXResetClip (gx, pDrawable->pScreen);
+}
+
+static void
+sunGXPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase;
+{
+ sunGXPtr gx = sunGXGetScreenPrivate (pDrawable->pScreen);
+ int h;
+ int w;
+ CharInfoPtr pci;
+ unsigned long *bits;
+ register int r;
+ RegionPtr clip;
+ BoxPtr extents;
+ BoxRec box;
+
+ clip = pGC->pCompositeClip;
+ extents = &clip->extents;
+
+ if (REGION_NUM_RECTS(clip) == 1)
+ {
+ GXSetClip (gx, extents);
+ }
+ else
+ {
+ /* compute an approximate (but covering) bounding box */
+ box.x1 = 0;
+ if ((ppci[0]->metrics.leftSideBearing < 0))
+ box.x1 = ppci[0]->metrics.leftSideBearing;
+ h = nglyph - 1;
+ w = ppci[h]->metrics.rightSideBearing;
+ while (--h >= 0)
+ w += ppci[h]->metrics.characterWidth;
+ box.x2 = w;
+ box.y1 = -FONTMAXBOUNDS(pGC->font,ascent);
+ box.y2 = FONTMAXBOUNDS(pGC->font,descent);
+
+ box.x1 += pDrawable->x + x;
+ box.x2 += pDrawable->x + x;
+ box.y1 += pDrawable->y + y;
+ box.y2 += pDrawable->y + y;
+
+ switch (RECT_IN_REGION(pGC->pScreen, clip, &box))
+ {
+ case rgnPART:
+ cfbPolyGlyphBlt8 (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ case rgnOUT:
+ return;
+ }
+ }
+
+ GXDrawInit (gx, pGC->fgPixel,
+ gx_stipple_rop_table[pGC->alu]|GX_PATTERN_ONES|POLY_N,
+ pGC->planemask);
+ gx->mode = GX_BLIT_NOSRC | GX_MODE_COLOR1;
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ while (nglyph--)
+ {
+ pci = *ppci++;
+ gx->incx = 0;
+ gx->incy = 1;
+ gx->x0 = x + pci->metrics.leftSideBearing;
+ gx->x1 = (x + pci->metrics.rightSideBearing) - 1;
+ gx->y0 = y - pci->metrics.ascent;
+ h = pci->metrics.ascent + pci->metrics.descent;
+ bits = (unsigned long *) pci->bits;
+ while (h--) {
+ gx->font = *bits++;
+ }
+ x += pci->metrics.characterWidth;
+ }
+ GXWait (gx, r);
+ gx->mode = GX_BLIT_SRC | GX_MODE_COLOR8;
+ GXResetClip (gx, pDrawable->pScreen);
+}
+
+static void
+sunGXTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ sunGXPtr gx = sunGXGetScreenPrivate (pDrawable->pScreen);
+ int h, hTmp;
+ FontPtr pfont = pGC->font;
+ register int r;
+ unsigned long *char1, *char2, *char3, *char4;
+ int widthGlyphs, widthGlyph;
+ BoxRec bbox;
+ BoxPtr extents;
+ RegionPtr clip;
+ unsigned long rop;
+
+ widthGlyph = FONTMAXBOUNDS(pfont,characterWidth);
+ h = FONTASCENT(pfont) + FONTDESCENT(pfont);
+ clip = pGC->pCompositeClip;
+ extents = &clip->extents;
+
+ if (REGION_NUM_RECTS(clip) == 1)
+ {
+ GXSetClip (gx, extents);
+ }
+ else
+ {
+ bbox.x1 = x + pDrawable->x;
+ bbox.x2 = bbox.x1 + (widthGlyph * nglyph);
+ bbox.y1 = y + pDrawable->y - FONTASCENT(pfont);
+ bbox.y2 = bbox.y1 + h;
+
+ switch (RECT_IN_REGION(pGC->pScreen, clip, &bbox))
+ {
+ case rgnPART:
+ if (pglyphBase)
+ cfbPolyGlyphBlt8(pDrawable, pGC, x, y, nglyph, ppci, NULL);
+ else
+ miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ case rgnOUT:
+ return;
+ }
+ }
+
+ rop = gx_opaque_stipple_rop_table[GXcopy] | GX_PATTERN_ONES;
+ if (pglyphBase)
+ rop = gx_stipple_rop_table[pGC->alu] | GX_PATTERN_ONES;
+ GXDrawInit (gx, pGC->fgPixel, rop, pGC->planemask);
+ gx->bg = pGC->bgPixel;
+ gx->mode = GX_BLIT_NOSRC | GX_MODE_COLOR1;
+
+ y = y + pDrawable->y - FONTASCENT(pfont);
+ x += pDrawable->x;
+
+#define LoopIt(count, w, loadup, fetch) \
+ while (nglyph >= count) \
+ { \
+ nglyph -= count; \
+ gx->incx = 0; \
+ gx->incy = 1; \
+ gx->x0 = x; \
+ gx->x1 = (x += w) - 1; \
+ gx->y0 = y; \
+ loadup \
+ hTmp = h; \
+ while (hTmp--) \
+ gx->font = fetch; \
+ }
+
+ if (widthGlyph <= 8)
+ {
+ widthGlyphs = widthGlyph << 2;
+ LoopIt(4, widthGlyphs,
+ char1 = (unsigned long *) (*ppci++)->bits;
+ char2 = (unsigned long *) (*ppci++)->bits;
+ char3 = (unsigned long *) (*ppci++)->bits;
+ char4 = (unsigned long *) (*ppci++)->bits;,
+ (*char1++ | ((*char2++ | ((*char3++ | (*char4++
+ >> widthGlyph))
+ >> widthGlyph))
+ >> widthGlyph)))
+ }
+ else if (widthGlyph <= 10)
+ {
+ widthGlyphs = (widthGlyph << 1) + widthGlyph;
+ LoopIt(3, widthGlyphs,
+ char1 = (unsigned long *) (*ppci++)->bits;
+ char2 = (unsigned long *) (*ppci++)->bits;
+ char3 = (unsigned long *) (*ppci++)->bits;,
+ (*char1++ | ((*char2++ | (*char3++ >> widthGlyph)) >> widthGlyph)))
+ }
+ else if (widthGlyph <= 16)
+ {
+ widthGlyphs = widthGlyph << 1;
+ LoopIt(2, widthGlyphs,
+ char1 = (unsigned long *) (*ppci++)->bits;
+ char2 = (unsigned long *) (*ppci++)->bits;,
+ (*char1++ | (*char2++ >> widthGlyph)))
+ }
+ while (nglyph--) {
+ gx->incx = 0;
+ gx->incy = 1;
+ gx->x0 = x;
+ gx->x1 = (x += widthGlyph) - 1;
+ gx->y0 = y;
+ char1 = (unsigned long *) (*ppci++)->bits;
+ hTmp = h;
+ while (hTmp--)
+ gx->font = *char1++;
+ }
+ gx->incx = 0;
+ gx->incy = 0;
+ GXWait (gx, r);
+ gx->mode = GX_BLIT_SRC | GX_MODE_COLOR8;
+ GXResetClip (gx, pDrawable->pScreen);
+}
+
+static void
+sunGXPolyTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ sunGXTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, (char *) 1);
+}
+
+static void
+sunGXFillBoxSolid (pDrawable, nBox, pBox, pixel)
+ DrawablePtr pDrawable;
+ int nBox;
+ BoxPtr pBox;
+ unsigned long pixel;
+{
+ register sunGXPtr gx = sunGXGetScreenPrivate (pDrawable->pScreen);
+ register int r;
+
+ GXDrawInit(gx,pixel,gx_solid_rop_table[GXcopy]|POLY_N,~0);
+ while (nBox--) {
+ gx->arecty = pBox->y1;
+ gx->arectx = pBox->x1;
+ gx->arecty = pBox->y2;
+ gx->arectx = pBox->x2;
+ pBox++;
+ GXDrawDone(gx,r);
+ }
+ GXWait(gx,r);
+}
+
+void
+sunGXFillBoxStipple (pDrawable, nBox, pBox, stipple)
+ DrawablePtr pDrawable;
+ int nBox;
+ BoxPtr pBox;
+ sunGXStipplePtr stipple;
+{
+ register sunGXPtr gx = sunGXGetScreenPrivate (pDrawable->pScreen);
+ register int r;
+ int patx, paty;
+
+ patx = 16 - (pDrawable->x & 0xf);
+ paty = 16 - (pDrawable->y & 0xf);
+ stipple->patalign = (patx << 16) | paty;
+ GXDrawInit(gx,0,gx_solid_rop_table[GXcopy]|POLY_N,~0);
+ GXStippleInit(gx, stipple);
+ while (nBox--) {
+ gx->arecty = pBox->y1;
+ gx->arectx = pBox->x1;
+ gx->arecty = pBox->y2;
+ gx->arectx = pBox->x2;
+ pBox++;
+ GXDrawDone(gx,r);
+ }
+ GXWait(gx,r);
+}
+
+Bool
+sunGXCheckTile (pPixmap, stipple)
+ PixmapPtr pPixmap;
+ sunGXStipplePtr stipple;
+{
+ unsigned short *sbits;
+ unsigned int fg = (unsigned int)~0, bg = (unsigned int)~0;
+ unsigned char *tilebitsLine, *tilebits, tilebit;
+ unsigned short sbit, mask;
+ int nbwidth;
+ int h, w;
+ int x, y;
+ int s_y, s_x;
+
+ h = pPixmap->drawable.height;
+ if (h > 16 || (h & (h - 1)))
+ return FALSE;
+ w = pPixmap->drawable.width;
+ if (w > 16 || (w & (w - 1)))
+ return FALSE;
+ sbits = (unsigned short *) stipple->bits;
+ tilebitsLine = (unsigned char *) pPixmap->devPrivate.ptr;
+ nbwidth = pPixmap->devKind;
+ for (y = 0; y < h; y++) {
+ tilebits = tilebitsLine;
+ tilebitsLine += nbwidth;
+ sbit = 0;
+ mask = 1 << 15;
+ for (x = 0; x < w; x++)
+ {
+ tilebit = *tilebits++;
+ if (tilebit == fg)
+ sbit |= mask;
+ else if (tilebit != bg)
+ {
+ if (fg == ~0)
+ {
+ fg = tilebit;
+ sbit |= mask;
+ }
+ else if (bg == ~0)
+ {
+ bg = tilebit;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+ mask >>= 1;
+ }
+ for (s_x = w; s_x < 16; s_x <<= 1)
+ sbit = sbit | (sbit >> s_x);
+ for (s_y = y; s_y < 16; s_y += h)
+ sbits[s_y] = sbit;
+ }
+ stipple->fore = fg;
+ stipple->back = bg;
+ return TRUE;
+}
+
+Bool
+sunGXCheckStipple (pPixmap, stipple)
+ PixmapPtr pPixmap;
+ sunGXStipplePtr stipple;
+{
+ unsigned short *sbits;
+ unsigned long *stippleBits;
+ unsigned long sbit, mask;
+ int h, w;
+ int y;
+ int s_y, s_x;
+
+ h = pPixmap->drawable.height;
+ if (h > 16 || (h & (h - 1)))
+ return FALSE;
+ w = pPixmap->drawable.width;
+ if (w > 16 || (w & (w - 1)))
+ return FALSE;
+ sbits = (unsigned short *) stipple->bits;
+ stippleBits = (unsigned long *) pPixmap->devPrivate.ptr;
+ mask = ((1 << w) - 1) << (16 - w);
+ for (y = 0; y < h; y++) {
+ sbit = (*stippleBits++ >> 16) & mask;
+ for (s_x = w; s_x < 16; s_x <<= 1)
+ sbit = sbit | (sbit >> s_x);
+ for (s_y = y; s_y < 16; s_y += h)
+ sbits[s_y] = sbit;
+ }
+ return TRUE;
+}
+
+/* cache one stipple; figuring out if we can use the stipple is as hard as
+ * computing it, so we just use this one and leave it here if it
+ * can't be used this time
+ */
+
+static sunGXStipplePtr tmpStipple;
+
+Bool
+sunGXCheckFill (pGC, pDrawable)
+ GCPtr pGC;
+ DrawablePtr pDrawable;
+{
+ sunGXPrivGCPtr gxPriv = sunGXGetGCPrivate (pGC);
+ sunGXStipplePtr stipple;
+ Uint alu;
+ int xrot, yrot;
+
+ if (pGC->fillStyle == FillSolid)
+ {
+ if (gxPriv->stipple)
+ {
+ xfree (gxPriv->stipple);
+ gxPriv->stipple = 0;
+ }
+ return TRUE;
+ }
+ if (!(stipple = gxPriv->stipple))
+ {
+ if (!tmpStipple)
+ {
+ tmpStipple = (sunGXStipplePtr) xalloc (sizeof *tmpStipple);
+ if (!tmpStipple)
+ return FALSE;
+ }
+ stipple = tmpStipple;
+ }
+ alu = gx_opaque_stipple_rop_table[pGC->alu]|GX_PATTERN_MASK;
+ switch (pGC->fillStyle) {
+ case FillTiled:
+ if (!sunGXCheckTile (pGC->tile.pixmap, stipple))
+ {
+ if (gxPriv->stipple)
+ {
+ xfree (gxPriv->stipple);
+ gxPriv->stipple = 0;
+ }
+ return FALSE;
+ }
+ break;
+ case FillStippled:
+ alu = gx_stipple_rop_table[pGC->alu]|GX_PATTERN_MASK;
+ case FillOpaqueStippled:
+ if (!sunGXCheckStipple (pGC->stipple, stipple))
+ {
+ if (gxPriv->stipple)
+ {
+ xfree (gxPriv->stipple);
+ gxPriv->stipple = 0;
+ }
+ return FALSE;
+ }
+ stipple->fore = pGC->fgPixel;
+ stipple->back = pGC->bgPixel;
+ break;
+ }
+ xrot = (pGC->patOrg.x + pDrawable->x) & 0xf;
+ yrot = (pGC->patOrg.y + pDrawable->y) & 0xf;
+/*
+ stipple->patalign = ((16 - (xrot & 0xf)) << 16) | (16 - (yrot & 0xf));
+*/
+ xrot = 16 - xrot;
+ yrot = 16 - yrot;
+ stipple->patalign = (xrot << 16) | yrot;
+ stipple->alu = alu;
+ gxPriv->stipple = stipple;
+ if (stipple == tmpStipple)
+ tmpStipple = 0;
+ return TRUE;
+}
+
+void sunGXValidateGC ();
+void sunGXDestroyGC ();
+
+GCFuncs sunGXGCFuncs = {
+ sunGXValidateGC,
+ miChangeGC,
+ miCopyGC,
+ sunGXDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip
+};
+
+GCOps sunGXTEOps1Rect = {
+ sunGXFillSpans,
+ cfbSetSpans,
+ cfbPutImage,
+ sunGXCopyArea,
+ sunGXCopyPlane,
+ cfbPolyPoint,
+ sunGXPolylines1Rect,
+ sunGXPolySeg1Rect,
+ miPolyRectangle,
+ cfbZeroPolyArcSS8Copy,
+ sunGXFillPoly1Rect,
+ sunGXPolyFillRect1Rect,
+ sunGXPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ sunGXTEGlyphBlt,
+ sunGXPolyTEGlyphBlt,
+ cfbPushPixels8
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps sunGXTEOps = {
+ sunGXFillSpans,
+ cfbSetSpans,
+ cfbPutImage,
+ sunGXCopyArea,
+ sunGXCopyPlane,
+ cfbPolyPoint,
+ cfbLineSS,
+ cfbSegmentSS,
+ miPolyRectangle,
+ cfbZeroPolyArcSS8Copy,
+ miFillPolygon,
+ sunGXPolyFillRect,
+ sunGXPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ sunGXTEGlyphBlt,
+ sunGXPolyTEGlyphBlt,
+ cfbPushPixels8
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps sunGXNonTEOps1Rect = {
+ sunGXFillSpans,
+ cfbSetSpans,
+ cfbPutImage,
+ sunGXCopyArea,
+ sunGXCopyPlane,
+ cfbPolyPoint,
+ sunGXPolylines1Rect,
+ sunGXPolySeg1Rect,
+ miPolyRectangle,
+ cfbZeroPolyArcSS8Copy,
+ sunGXFillPoly1Rect,
+ sunGXPolyFillRect1Rect,
+ sunGXPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ miImageGlyphBlt,
+ sunGXPolyGlyphBlt,
+ cfbPushPixels8
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps sunGXNonTEOps = {
+ sunGXFillSpans,
+ cfbSetSpans,
+ cfbPutImage,
+ sunGXCopyArea,
+ sunGXCopyPlane,
+ cfbPolyPoint,
+ cfbLineSS,
+ cfbSegmentSS,
+ miPolyRectangle,
+ cfbZeroPolyArcSS8Copy,
+ miFillPolygon,
+ sunGXPolyFillRect,
+ sunGXPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ miImageGlyphBlt,
+ sunGXPolyGlyphBlt,
+ cfbPushPixels8
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+#define FONTWIDTH(font) (FONTMAXBOUNDS(font,rightSideBearing) - \
+ FONTMINBOUNDS(font,leftSideBearing))
+
+GCOps *
+sunGXMatchCommon (pGC, devPriv)
+ GCPtr pGC;
+ cfbPrivGCPtr devPriv;
+{
+ if (pGC->lineWidth != 0)
+ return 0;
+ if (pGC->lineStyle != LineSolid)
+ return 0;
+ if (pGC->fillStyle != FillSolid)
+ return 0;
+ if (devPriv->rop != GXcopy)
+ return 0;
+ if (!WID_OK(pGC->pScreen))
+ return 0;
+ if (pGC->font &&
+ FONTWIDTH (pGC->font) <= 32 &&
+ FONTMINBOUNDS(pGC->font,characterWidth) >= 0)
+ {
+ if (TERMINALFONT(pGC->font))
+ if (devPriv->oneRect)
+ return &sunGXTEOps1Rect;
+ else
+ return &sunGXTEOps;
+ else
+ if (devPriv->oneRect)
+ return &sunGXNonTEOps1Rect;
+ else
+ return &sunGXNonTEOps;
+ }
+ return 0;
+}
+
+void
+sunGXValidateGC (pGC, changes, pDrawable)
+ GCPtr pGC;
+ Mask changes;
+ DrawablePtr pDrawable;
+{
+ int mask; /* stateChanges */
+ int index; /* used for stepping through bitfields */
+ int new_rrop;
+ int new_line, new_text, new_fillspans, new_fillarea;
+ int new_rotate;
+ int xrot, yrot;
+ /* flags for changing the proc vector */
+ cfbPrivGCPtr devPriv;
+ sunGXPrivGCPtr gxPriv;
+ int oneRect;
+ int canGX;
+ int widOK;
+
+ gxPriv = sunGXGetGCPrivate (pGC);
+ widOK = WID_OK(pGC->pScreen);
+ if (pDrawable->type != DRAWABLE_WINDOW)
+ {
+ if (gxPriv->type == DRAWABLE_WINDOW)
+ {
+ extern GCOps cfbNonTEOps;
+
+ miDestroyGCOps (pGC->ops);
+ pGC->ops = &cfbNonTEOps;
+ changes = (1 << (GCLastBit + 1)) - 1;
+ pGC->stateChanges = changes;
+ gxPriv->type = pDrawable->type;
+ }
+ cfbValidateGC (pGC, changes, pDrawable);
+ return;
+ }
+ if (gxPriv->type != DRAWABLE_WINDOW)
+ {
+ changes = (1 << (GCLastBit + 1)) - 1;
+ gxPriv->type = DRAWABLE_WINDOW;
+ }
+
+ new_rotate = pGC->lastWinOrg.x != pDrawable->x ||
+ pGC->lastWinOrg.y != pDrawable->y;
+
+ pGC->lastWinOrg.x = pDrawable->x;
+ pGC->lastWinOrg.y = pDrawable->y;
+
+ devPriv = ((cfbPrivGCPtr) (pGC->devPrivates[cfbGCPrivateIndex].ptr));
+
+ new_rrop = FALSE;
+ new_line = FALSE;
+ new_text = FALSE;
+ new_fillspans = FALSE;
+ new_fillarea = FALSE;
+
+ /*
+ * if the client clip is different or moved OR the subwindowMode has
+ * changed OR the window's clip has changed since the last validation
+ * we need to recompute the composite clip
+ */
+
+ if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
+ (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
+ )
+ {
+ miComputeCompositeClip(pGC, pDrawable);
+ oneRect = REGION_NUM_RECTS(pGC->pCompositeClip) == 1;
+ if (oneRect != devPriv->oneRect)
+ {
+ new_line = TRUE;
+ new_fillarea = TRUE;
+ devPriv->oneRect = oneRect;
+ }
+ }
+
+ mask = changes;
+ while (mask) {
+ index = lowbit (mask);
+ mask &= ~index;
+
+ /*
+ * this switch acculmulates a list of which procedures might have
+ * to change due to changes in the GC. in some cases (e.g.
+ * changing one 16 bit tile for another) we might not really need
+ * a change, but the code is being paranoid. this sort of batching
+ * wins if, for example, the alu and the font have been changed,
+ * or any other pair of items that both change the same thing.
+ */
+ switch (index) {
+ case GCFunction:
+ case GCForeground:
+ new_rrop = TRUE;
+ break;
+ case GCPlaneMask:
+ new_rrop = TRUE;
+ new_text = TRUE;
+ break;
+ case GCBackground:
+ break;
+ case GCLineStyle:
+ case GCLineWidth:
+ new_line = TRUE;
+ break;
+ case GCCapStyle:
+ break;
+ case GCJoinStyle:
+ break;
+ case GCFillStyle:
+ new_text = TRUE;
+ new_fillspans = TRUE;
+ new_line = TRUE;
+ new_fillarea = TRUE;
+ break;
+ case GCFillRule:
+ break;
+ case GCTile:
+ new_fillspans = TRUE;
+ new_fillarea = TRUE;
+ break;
+
+ case GCStipple:
+ new_fillspans = TRUE;
+ new_fillarea = TRUE;
+ break;
+
+ case GCTileStipXOrigin:
+ new_rotate = TRUE;
+ break;
+
+ case GCTileStipYOrigin:
+ new_rotate = TRUE;
+ break;
+
+ case GCFont:
+ new_text = TRUE;
+ break;
+ case GCSubwindowMode:
+ break;
+ case GCGraphicsExposures:
+ break;
+ case GCClipXOrigin:
+ break;
+ case GCClipYOrigin:
+ break;
+ case GCClipMask:
+ break;
+ case GCDashOffset:
+ break;
+ case GCDashList:
+ break;
+ case GCArcMode:
+ break;
+ default:
+ break;
+ }
+ }
+
+ /*
+ * If the drawable has changed, check its depth & ensure suitable
+ * entries are in the proc vector.
+ */
+ if (pDrawable->serialNumber != (pGC->serialNumber & (DRAWABLE_SERIAL_BITS))) {
+ new_fillspans = TRUE; /* deal with FillSpans later */
+ }
+
+ if ((new_rotate || new_fillspans))
+ {
+ Bool new_pix = FALSE;
+ xrot = pGC->patOrg.x + pDrawable->x;
+ yrot = pGC->patOrg.y + pDrawable->y;
+
+ if (!sunGXCheckFill (pGC, pDrawable))
+ {
+ switch (pGC->fillStyle)
+ {
+ case FillTiled:
+ if (!pGC->tileIsPixel)
+ {
+ int width = pGC->tile.pixmap->drawable.width * PSZ;
+
+ if ((width <= 32) && !(width & (width - 1)))
+ {
+ cfbCopyRotatePixmap(pGC->tile.pixmap,
+ &pGC->pRotatedPixmap,
+ xrot, yrot);
+ new_pix = TRUE;
+ }
+ }
+ break;
+ case FillStippled:
+ case FillOpaqueStippled:
+ {
+ int width = pGC->stipple->drawable.width;
+
+ if ((width <= 32) && !(width & (width - 1)))
+ {
+ mfbCopyRotatePixmap(pGC->stipple,
+ &pGC->pRotatedPixmap, xrot, yrot);
+ new_pix = TRUE;
+ }
+ }
+ break;
+ }
+ }
+ if (!new_pix && pGC->pRotatedPixmap)
+ {
+ cfbDestroyPixmap(pGC->pRotatedPixmap);
+ pGC->pRotatedPixmap = (PixmapPtr) NULL;
+ }
+ }
+
+ if (new_rrop)
+ {
+ int old_rrop;
+
+ if (gxPriv->stipple)
+ {
+ if (pGC->fillStyle == FillStippled)
+ gxPriv->stipple->alu = gx_stipple_rop_table[pGC->alu]|GX_PATTERN_MASK;
+ else
+ gxPriv->stipple->alu = gx_opaque_stipple_rop_table[pGC->alu]|GX_PATTERN_MASK;
+ if (pGC->fillStyle != FillTiled)
+ {
+ gxPriv->stipple->fore = pGC->fgPixel;
+ gxPriv->stipple->back = pGC->bgPixel;
+ }
+ }
+ old_rrop = devPriv->rop;
+ devPriv->rop = cfbReduceRasterOp (pGC->alu, pGC->fgPixel,
+ pGC->planemask,
+ &devPriv->and, &devPriv->xor);
+ if (old_rrop == devPriv->rop)
+ new_rrop = FALSE;
+ else
+ {
+ new_line = TRUE;
+ new_text = TRUE;
+ new_fillspans = TRUE;
+ new_fillarea = TRUE;
+ }
+ }
+
+ if (new_rrop || new_fillspans || new_text || new_fillarea || new_line)
+ {
+ GCOps *newops;
+
+ if ((newops = sunGXMatchCommon (pGC, devPriv)))
+ {
+ if (pGC->ops->devPrivate.val)
+ miDestroyGCOps (pGC->ops);
+ pGC->ops = newops;
+ new_rrop = new_line = new_fillspans = new_text = new_fillarea = 0;
+ }
+ else
+ {
+ if (!pGC->ops->devPrivate.val)
+ {
+ pGC->ops = miCreateGCOps (pGC->ops);
+ pGC->ops->devPrivate.val = 1;
+ }
+ }
+ }
+
+ canGX = pGC->fillStyle == FillSolid || gxPriv->stipple;
+
+ /* deal with the changes we've collected */
+ if (new_line)
+ {
+ pGC->ops->FillPolygon = miFillPolygon;
+ if (devPriv->oneRect && canGX)
+ pGC->ops->FillPolygon = sunGXFillPoly1Rect;
+ if (pGC->lineWidth == 0)
+ {
+ if ((pGC->lineStyle == LineSolid) && (pGC->fillStyle == FillSolid))
+ {
+ switch (devPriv->rop)
+ {
+ case GXxor:
+ pGC->ops->PolyArc = cfbZeroPolyArcSS8Xor;
+ break;
+ case GXcopy:
+ pGC->ops->PolyArc = cfbZeroPolyArcSS8Copy;
+ break;
+ default:
+ pGC->ops->PolyArc = cfbZeroPolyArcSS8General;
+ break;
+ }
+ }
+ else
+ pGC->ops->PolyArc = miZeroPolyArc;
+ }
+ else
+ pGC->ops->PolyArc = miPolyArc;
+ pGC->ops->PolySegment = miPolySegment;
+ switch (pGC->lineStyle)
+ {
+ case LineSolid:
+ if(pGC->lineWidth == 0)
+ {
+ if (devPriv->oneRect && canGX && widOK)
+ {
+ pGC->ops->PolySegment = sunGXPolySeg1Rect;
+ pGC->ops->Polylines = sunGXPolylines1Rect;
+ }
+ else if (pGC->fillStyle == FillSolid)
+ {
+ if (devPriv->oneRect)
+ {
+ pGC->ops->Polylines = cfb8LineSS1Rect;
+ pGC->ops->PolySegment = cfb8SegmentSS1Rect;
+ }
+ else
+ {
+ pGC->ops->Polylines = cfbLineSS;
+ pGC->ops->PolySegment = cfbSegmentSS;
+ }
+ }
+ else
+ pGC->ops->Polylines = miZeroLine;
+ }
+ else
+ pGC->ops->Polylines = miWideLine;
+ break;
+ case LineOnOffDash:
+ case LineDoubleDash:
+ if (pGC->lineWidth == 0 && pGC->fillStyle == FillSolid)
+ {
+ pGC->ops->Polylines = cfbLineSD;
+ pGC->ops->PolySegment = cfbSegmentSD;
+ } else
+ pGC->ops->Polylines = miWideDash;
+ break;
+ }
+ }
+
+ if (new_text && (pGC->font))
+ {
+ if (FONTWIDTH(pGC->font) > 32 ||
+ FONTMINBOUNDS(pGC->font,characterWidth) < 0)
+ {
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
+ }
+ else
+ {
+ if (pGC->fillStyle == FillSolid)
+ {
+ if (TERMINALFONT (pGC->font))
+ pGC->ops->PolyGlyphBlt = sunGXPolyTEGlyphBlt;
+ else
+ pGC->ops->PolyGlyphBlt = sunGXPolyGlyphBlt;
+ }
+ else
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ /* special case ImageGlyphBlt for terminal emulator fonts */
+ if (TERMINALFONT(pGC->font))
+ pGC->ops->ImageGlyphBlt = sunGXTEGlyphBlt;
+ else
+ pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
+ }
+ }
+
+
+ if (new_fillspans) {
+ if (canGX)
+ pGC->ops->FillSpans = sunGXFillSpans;
+ else switch (pGC->fillStyle) {
+ case FillTiled:
+ if (pGC->pRotatedPixmap)
+ {
+ if (pGC->alu == GXcopy && (pGC->planemask & PMSK) == PMSK)
+ pGC->ops->FillSpans = cfbTile32FSCopy;
+ else
+ pGC->ops->FillSpans = cfbTile32FSGeneral;
+ }
+ else
+ pGC->ops->FillSpans = cfbUnnaturalTileFS;
+ break;
+ case FillStippled:
+ if (pGC->pRotatedPixmap)
+ pGC->ops->FillSpans = cfb8Stipple32FS;
+ else
+ pGC->ops->FillSpans = cfbUnnaturalStippleFS;
+ break;
+ case FillOpaqueStippled:
+ if (pGC->pRotatedPixmap)
+ pGC->ops->FillSpans = cfb8OpaqueStipple32FS;
+ else
+ pGC->ops->FillSpans = cfbUnnaturalStippleFS;
+ break;
+ default:
+ FatalError("cfbValidateGC: illegal fillStyle\n");
+ }
+ } /* end of new_fillspans */
+
+ if (new_fillarea) {
+ pGC->ops->PolyFillRect = cfbPolyFillRect;
+ pGC->ops->PolyFillArc = miPolyFillArc;
+ if (canGX)
+ {
+ pGC->ops->PolyFillArc = sunGXPolyFillArc;
+ pGC->ops->PolyFillRect = sunGXPolyFillRect;
+ if (devPriv->oneRect)
+ pGC->ops->PolyFillRect = sunGXPolyFillRect1Rect;
+ }
+ pGC->ops->PushPixels = mfbPushPixels;
+ if (pGC->fillStyle == FillSolid && devPriv->rop == GXcopy)
+ pGC->ops->PushPixels = cfbPushPixels8;
+ }
+}
+
+void
+sunGXDestroyGC (pGC)
+ GCPtr pGC;
+{
+ sunGXPrivGCPtr gxPriv = sunGXGetGCPrivate (pGC);
+
+ if (gxPriv->stipple)
+ xfree (gxPriv->stipple);
+ miDestroyGC (pGC);
+}
+
+Bool
+sunGXCreateGC (pGC)
+ GCPtr pGC;
+{
+ sunGXPrivGCPtr gxPriv;
+ if (pGC->depth == 1)
+ return mfbCreateGC (pGC);
+ if (!cfbCreateGC (pGC))
+ return FALSE;
+ pGC->ops = &sunGXNonTEOps;
+ pGC->funcs = &sunGXGCFuncs;
+ gxPriv = sunGXGetGCPrivate(pGC);
+ gxPriv->type = DRAWABLE_WINDOW;
+ gxPriv->stipple = 0;
+ return TRUE;
+}
+
+Bool
+sunGXCreateWindow (pWin)
+ WindowPtr pWin;
+{
+ if (!cfbCreateWindow (pWin))
+ return FALSE;
+ pWin->devPrivates[sunGXWindowPrivateIndex].ptr = 0;
+ return TRUE;
+}
+
+Bool
+sunGXDestroyWindow (pWin)
+ WindowPtr pWin;
+{
+ sunGXStipplePtr stipple = sunGXGetWindowPrivate(pWin);
+ xfree (stipple);
+ return cfbDestroyWindow (pWin);
+}
+
+Bool
+sunGXChangeWindowAttributes (pWin, mask)
+ WindowPtr pWin;
+ Mask mask;
+{
+ sunGXStipplePtr stipple;
+ Mask index;
+ WindowPtr pBgWin;
+ register cfbPrivWin *pPrivWin;
+ int width;
+
+ pPrivWin = (cfbPrivWin *)(pWin->devPrivates[cfbWindowPrivateIndex].ptr);
+ /*
+ * When background state changes from ParentRelative and
+ * we had previously rotated the fast border pixmap to match
+ * the parent relative origin, rerotate to match window
+ */
+ if (mask & (CWBackPixmap | CWBackPixel) &&
+ pWin->backgroundState != ParentRelative &&
+ pPrivWin->fastBorder &&
+ (pPrivWin->oldRotate.x != pWin->drawable.x ||
+ pPrivWin->oldRotate.y != pWin->drawable.y))
+ {
+ cfbXRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ cfbYRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ }
+ while (mask)
+ {
+ index = lowbit(mask);
+ mask &= ~index;
+ switch (index)
+ {
+ case CWBackPixmap:
+ stipple = sunGXGetWindowPrivate(pWin);
+ if (pWin->backgroundState == None ||
+ pWin->backgroundState == ParentRelative)
+ {
+ pPrivWin->fastBackground = FALSE;
+ if (stipple)
+ {
+ xfree (stipple);
+ sunGXSetWindowPrivate(pWin,0);
+ }
+ /* Rotate border to match parent origin */
+ if (pWin->backgroundState == ParentRelative &&
+ pPrivWin->pRotatedBorder)
+ {
+ for (pBgWin = pWin->parent;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+ cfbXRotatePixmap(pPrivWin->pRotatedBorder,
+ pBgWin->drawable.x - pPrivWin->oldRotate.x);
+ cfbYRotatePixmap(pPrivWin->pRotatedBorder,
+ pBgWin->drawable.y - pPrivWin->oldRotate.y);
+ }
+
+ break;
+ }
+ if (!stipple)
+ {
+ if (!tmpStipple)
+ tmpStipple = (sunGXStipplePtr) xalloc (sizeof *tmpStipple);
+ stipple = tmpStipple;
+ }
+ if (stipple && sunGXCheckTile (pWin->background.pixmap, stipple))
+ {
+ stipple->alu = gx_opaque_stipple_rop_table[GXcopy]|GX_PATTERN_MASK;
+ pPrivWin->fastBackground = FALSE;
+ if (stipple == tmpStipple)
+ {
+ sunGXSetWindowPrivate(pWin, stipple);
+ tmpStipple = 0;
+ }
+ break;
+ }
+ if ((stipple = sunGXGetWindowPrivate(pWin)))
+ {
+ xfree (stipple);
+ sunGXSetWindowPrivate(pWin,0);
+ }
+ if (((width = (pWin->background.pixmap->drawable.width * PSZ)) <= 32) &&
+ !(width & (width - 1)))
+ {
+ cfbCopyRotatePixmap(pWin->background.pixmap,
+ &pPrivWin->pRotatedBackground,
+ pWin->drawable.x,
+ pWin->drawable.y);
+ if (pPrivWin->pRotatedBackground)
+ {
+ pPrivWin->fastBackground = TRUE;
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ }
+ else
+ {
+ pPrivWin->fastBackground = FALSE;
+ }
+ break;
+ }
+ pPrivWin->fastBackground = FALSE;
+ break;
+
+ case CWBackPixel:
+ pPrivWin->fastBackground = FALSE;
+ break;
+
+ case CWBorderPixmap:
+ /* don't bother with accelerator for border tiles (just lazy) */
+ if (((width = (pWin->border.pixmap->drawable.width * PSZ)) <= 32) &&
+ !(width & (width - 1)))
+ {
+ for (pBgWin = pWin;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+ cfbCopyRotatePixmap(pWin->border.pixmap,
+ &pPrivWin->pRotatedBorder,
+ pBgWin->drawable.x,
+ pBgWin->drawable.y);
+ if (pPrivWin->pRotatedBorder)
+ {
+ pPrivWin->fastBorder = TRUE;
+ pPrivWin->oldRotate.x = pBgWin->drawable.x;
+ pPrivWin->oldRotate.y = pBgWin->drawable.y;
+ }
+ else
+ {
+ pPrivWin->fastBorder = TRUE;
+ }
+ }
+ else
+ {
+ pPrivWin->fastBorder = FALSE;
+ }
+ break;
+ case CWBorderPixel:
+ pPrivWin->fastBorder = FALSE;
+ break;
+ }
+ }
+ return (TRUE);
+}
+
+void
+sunGXPaintWindow(pWin, pRegion, what)
+ WindowPtr pWin;
+ RegionPtr pRegion;
+ int what;
+{
+ register cfbPrivWin *pPrivWin;
+ sunGXStipplePtr stipple;
+ WindowPtr pBgWin;
+ pPrivWin = (cfbPrivWin *)(pWin->devPrivates[cfbWindowPrivateIndex].ptr);
+
+ switch (what) {
+ case PW_BACKGROUND:
+ stipple = sunGXGetWindowPrivate(pWin);
+ switch (pWin->backgroundState) {
+ case None:
+ return;
+ case ParentRelative:
+ do {
+ pWin = pWin->parent;
+ } while (pWin->backgroundState == ParentRelative);
+ (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
+ what);
+ return;
+ case BackgroundPixmap:
+ if (stipple)
+ {
+ sunGXFillBoxStipple ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ stipple);
+ }
+ else if (pPrivWin->fastBackground)
+ {
+ cfbFillBoxTile32 ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pPrivWin->pRotatedBackground);
+ }
+ else
+ {
+ cfbFillBoxTileOdd ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->background.pixmap,
+ (int) pWin->drawable.x, (int) pWin->drawable.y);
+ }
+ return;
+ case BackgroundPixel:
+ sunGXFillBoxSolid((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->background.pixel);
+ return;
+ }
+ break;
+ case PW_BORDER:
+ if (pWin->borderIsPixel)
+ {
+ sunGXFillBoxSolid((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->border.pixel);
+ return;
+ }
+ else if (pPrivWin->fastBorder)
+ {
+ cfbFillBoxTile32 ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pPrivWin->pRotatedBorder);
+ return;
+ }
+ else
+ {
+ for (pBgWin = pWin;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+
+ cfbFillBoxTileOdd ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->border.pixmap,
+ (int) pBgWin->drawable.x,
+ (int) pBgWin->drawable.y);
+ return;
+ }
+ break;
+ }
+}
+
+void
+sunGXCopyWindow(pWin, ptOldOrg, prgnSrc)
+ WindowPtr pWin;
+ DDXPointRec ptOldOrg;
+ RegionPtr prgnSrc;
+{
+ DDXPointPtr pptSrc;
+ register DDXPointPtr ppt;
+ RegionPtr prgnDst;
+ register BoxPtr pbox;
+ register int dx, dy;
+ register int i, nbox;
+ WindowPtr pwinRoot;
+ extern WindowPtr *WindowTable;
+
+ pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
+
+ prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+ REGION_INTERSECT(pWin->drawable.pScreen, prgnDst, &pWin->borderClip, prgnSrc);
+
+ pbox = REGION_RECTS(prgnDst);
+ nbox = REGION_NUM_RECTS(prgnDst);
+ if(!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
+ return;
+ ppt = pptSrc;
+
+ for (i = nbox; --i >= 0; ppt++, pbox++)
+ {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ sunGXDoBitblt ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
+ GXcopy, prgnDst, pptSrc, ~0L);
+ DEALLOCATE_LOCAL(pptSrc);
+ REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
+}
+
+Bool
+sunGXInit (
+ ScreenPtr pScreen,
+ fbFd *fb)
+{
+ sunGXPtr gx;
+ Uint mode;
+ register long r;
+
+ if (serverGeneration != sunGXGeneration)
+ {
+ sunGXScreenPrivateIndex = AllocateScreenPrivateIndex();
+ if (sunGXScreenPrivateIndex == -1)
+ return FALSE;
+ sunGXGCPrivateIndex = AllocateGCPrivateIndex ();
+ sunGXWindowPrivateIndex = AllocateWindowPrivateIndex ();
+ sunGXGeneration = serverGeneration;
+ }
+ if (!AllocateGCPrivate(pScreen, sunGXGCPrivateIndex, sizeof (sunGXPrivGCRec)))
+ return FALSE;
+ if (!AllocateWindowPrivate(pScreen, sunGXWindowPrivateIndex, 0))
+ return FALSE;
+ gx = (sunGXPtr) fb->fb;
+ mode = gx->mode;
+ GXWait(gx,r);
+ mode &= ~( GX_BLIT_ALL |
+ GX_MODE_ALL |
+ GX_DRAW_ALL |
+ GX_BWRITE0_ALL |
+ GX_BWRITE1_ALL |
+ GX_BREAD_ALL |
+ GX_BDISP_ALL);
+ mode |= GX_BLIT_SRC |
+ GX_MODE_COLOR8 |
+ GX_DRAW_RENDER |
+ GX_BWRITE0_ENABLE |
+ GX_BWRITE1_DISABLE |
+ GX_BREAD_0 |
+ GX_BDISP_0;
+ gx->mode = mode;
+ gx->clip = 0;
+ gx->offx = 0;
+ gx->offy = 0;
+ gx->clipminx = 0;
+ gx->clipminy = 0;
+ gx->clipmaxx = fb->info.fb_width - 1;
+ gx->clipmaxy = fb->info.fb_height - 1;
+ pScreen->devPrivates[sunGXScreenPrivateIndex].ptr = (pointer) gx;
+ /*
+ * Replace various screen functions
+ */
+ pScreen->CreateGC = sunGXCreateGC;
+ pScreen->CreateWindow = sunGXCreateWindow;
+ pScreen->ChangeWindowAttributes = sunGXChangeWindowAttributes;
+ pScreen->DestroyWindow = sunGXDestroyWindow;
+ pScreen->PaintWindowBackground = sunGXPaintWindow;
+ pScreen->PaintWindowBorder = sunGXPaintWindow;
+ pScreen->CopyWindow = sunGXCopyWindow;
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/sun/sunGX.h b/nx-X11/programs/Xserver/hw/sun/sunGX.h
new file mode 100644
index 000000000..ebf1da19f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/sunGX.h
@@ -0,0 +1,238 @@
+/*
+ * $Xorg: sunGX.h,v 1.4 2001/02/09 02:04:44 xorgcvs Exp $
+ *
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/programs/Xserver/hw/sun/sunGX.h,v 1.3 2001/07/29 05:01:13 tsi Exp $ */
+
+typedef unsigned int Uint;
+typedef volatile Uint VUint;
+
+/* modes */
+#define GX_INDEX(n) ((n) << 4)
+#define GX_INDEX_ALL 0x00000030
+#define GX_INDEX_MOD 0x00000040
+#define GX_BDISP_0 0x00000080
+#define GX_BDISP_1 0x00000100
+#define GX_BDISP_ALL 0x00000180
+#define GX_BREAD_0 0x00000200
+#define GX_BREAD_1 0x00000400
+#define GX_BREAD_ALL 0x00000600
+#define GX_BWRITE1_ENABLE 0x00000800
+#define GX_BWRITE1_DISABLE 0x00001000
+#define GX_BWRITE1_ALL 0x00001800
+#define GX_BWRITE0_ENABLE 0x00002000
+#define GX_BWRITE0_DISABLE 0x00004000
+#define GX_BWRITE0_ALL 0x00006000
+#define GX_DRAW_RENDER 0x00008000
+#define GX_DRAW_PICK 0x00010000
+#define GX_DRAW_ALL 0x00018000
+#define GX_MODE_COLOR8 0x00020000
+#define GX_MODE_COLOR1 0x00040000
+#define GX_MODE_HRMONO 0x00060000
+#define GX_MODE_ALL 0x00060000
+#define GX_VBLANK 0x00080000
+#define GX_BLIT_NOSRC 0x00100000
+#define GX_BLIT_SRC 0x00200000
+#define GX_BLIT_ALL 0x00300000
+
+/* rasterops */
+#define GX_ROP_CLEAR 0x0
+#define GX_ROP_INVERT 0x1
+#define GX_ROP_NOOP 0x2
+#define GX_ROP_SET 0x3
+
+#define GX_ROP_00_0(rop) ((rop) << 0)
+#define GX_ROP_00_1(rop) ((rop) << 2)
+#define GX_ROP_01_0(rop) ((rop) << 4)
+#define GX_ROP_01_1(rop) ((rop) << 6)
+#define GX_ROP_10_0(rop) ((rop) << 8)
+#define GX_ROP_10_1(rop) ((rop) << 10)
+#define GX_ROP_11_0(rop) ((rop) << 12)
+#define GX_ROP_11_1(rop) ((rop) << 14)
+#define GX_PLOT_PLOT 0x00000000
+#define GX_PLOT_UNPLOT 0x00020000
+#define GX_RAST_BOOL 0x00000000
+#define GX_RAST_LINEAR 0x00040000
+#define GX_ATTR_UNSUPP 0x00400000
+#define GX_ATTR_SUPP 0x00800000
+#define GX_POLYG_OVERLAP 0x01000000
+#define GX_POLYG_NONOVERLAP 0x02000000
+#define GX_PATTERN_ZEROS 0x04000000
+#define GX_PATTERN_ONES 0x08000000
+#define GX_PATTERN_MASK 0x0c000000
+#define GX_PIXEL_ZEROS 0x10000000
+#define GX_PIXEL_ONES 0x20000000
+#define GX_PIXEL_MASK 0x30000000
+#define GX_PLANE_ZEROS 0x40000000
+#define GX_PLANE_ONES 0x80000000
+#define GX_PLANE_MASK 0xc0000000
+
+typedef struct _sunGX {
+ Uint junk0[1];
+ VUint mode;
+ VUint clip;
+ Uint junk1[1];
+ VUint s;
+ VUint draw;
+ VUint blit;
+ VUint font;
+ Uint junk2[24];
+ VUint x0, y0, z0, color0;
+ VUint x1, y1, z1, color1;
+ VUint x2, y2, z2, color2;
+ VUint x3, y3, z3, color3;
+ VUint offx, offy;
+ Uint junk3[2];
+ VUint incx, incy;
+ Uint junk4[2];
+ VUint clipminx, clipminy;
+ Uint junk5[2];
+ VUint clipmaxx, clipmaxy;
+ Uint junk6[2];
+ VUint fg;
+ VUint bg;
+ VUint alu;
+ VUint pm;
+ VUint pixelm;
+ Uint junk7[2];
+ VUint patalign;
+ VUint pattern[8];
+ Uint junk8[432];
+ VUint apointx, apointy, apointz;
+ Uint junk9[1];
+ VUint rpointx, rpointy, rpointz;
+ Uint junk10[5];
+ VUint pointr, pointg, pointb, pointa;
+ VUint alinex, aliney, alinez;
+ Uint junk11[1];
+ VUint rlinex, rliney, rlinez;
+ Uint junk12[5];
+ VUint liner, lineg, lineb, linea;
+ VUint atrix, atriy, atriz;
+ Uint junk13[1];
+ VUint rtrix, rtriy, rtriz;
+ Uint junk14[5];
+ VUint trir, trig, trib, tria;
+ VUint aquadx, aquady, aquadz;
+ Uint junk15[1];
+ VUint rquadx, rquady, rquadz;
+ Uint junk16[5];
+ VUint quadr, quadg, quadb, quada;
+ VUint arectx, arecty, arectz;
+ Uint junk17[1];
+ VUint rrectx, rrecty, rrectz;
+ Uint junk18[5];
+ VUint rectr, rectg, rectb, recta;
+} sunGX, *sunGXPtr;
+
+/* Macros */
+
+#define GX_ROP_USE_PIXELMASK 0x30000000
+
+#define GX_BLT_INPROGRESS 0x20000000
+
+#define GX_INPROGRESS 0x10000000
+#define GX_FULL 0x20000000
+
+#define GXWait(gx,r)\
+ do\
+ (r) = (int) (gx)->s; \
+ while ((r) & GX_INPROGRESS)
+
+#define GXDrawDone(gx,r) \
+ do \
+ (r) = (int) (gx)->draw; \
+ while ((r) < 0 && ((r) & GX_FULL))
+
+#define GXBlitDone(gx,r)\
+ do\
+ (r)= (int) (gx)->blit; \
+ while ((r) < 0 && ((r) & GX_BLT_INPROGRESS))
+
+#define GXBlitInit(gx,rop,pmsk) {\
+ gx->fg = 0xff;\
+ gx->bg = 0x00;\
+ gx->pixelm = ~0;\
+ gx->s = 0;\
+ gx->alu = rop;\
+ gx->pm = pmsk;\
+ gx->clip = 0;\
+}
+
+#define GXDrawInit(gx,fore,rop,pmsk) {\
+ gx->fg = fore;\
+ gx->bg = 0x00; \
+ gx->pixelm = ~0; \
+ gx->s = 0; \
+ gx->alu = rop; \
+ gx->pm = pmsk; \
+ gx->clip = 0;\
+}
+
+#define GXStippleInit(gx,stipple) {\
+ int _i; \
+ Uint *sp; \
+ VUint *dp; \
+ _i = 8; \
+ sp = stipple->bits; \
+ dp = gx->pattern; \
+ while (_i--) { \
+ dp[_i] = sp[_i]; \
+ } \
+ gx->fg = stipple->fore; \
+ gx->bg = stipple->back; \
+ gx->patalign = stipple->patalign; \
+ gx->alu = stipple->alu; \
+}
+
+extern int sunGXScreenPrivateIndex;
+extern int sunGXGCPrivateIndex;
+extern int sunGXWindowPrivateIndex;
+
+#define sunGXGetScreenPrivate(s) ((sunGXPtr) \
+ (s)->devPrivates[sunGXScreenPrivateIndex].ptr)
+
+typedef struct _sunGXStipple {
+ Uint fore, back;
+ Uint patalign;
+ Uint alu;
+ Uint bits[8]; /* actually 16 shorts */
+} sunGXStippleRec, *sunGXStipplePtr;
+
+typedef struct _sunGXPrivGC {
+ int type;
+ sunGXStipplePtr stipple;
+} sunGXPrivGCRec, *sunGXPrivGCPtr;
+
+#define sunGXGetGCPrivate(g) ((sunGXPrivGCPtr) \
+ (g)->devPrivates[sunGXGCPrivateIndex].ptr)
+
+#define sunGXGetWindowPrivate(w) ((sunGXStipplePtr) \
+ (w)->devPrivates[sunGXWindowPrivateIndex].ptr)
+
+#define sunGXSetWindowPrivate(w,p) (\
+ (w)->devPrivates[sunGXWindowPrivateIndex].ptr = (pointer) p)
+
diff --git a/nx-X11/programs/Xserver/hw/sun/sunInit.c b/nx-X11/programs/Xserver/hw/sun/sunInit.c
new file mode 100644
index 000000000..62cc8c76a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/sunInit.c
@@ -0,0 +1,960 @@
+/* $Xorg: sunInit.c,v 1.4 2000/08/17 19:48:29 cpqbld Exp $ */
+/*
+ * sunInit.c --
+ * Initialization functions for screen/keyboard/mouse, etc.
+ *
+ * Copyright 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/sun/sunInit.c,v 3.12 2002/12/06 02:11:44 tsi Exp $ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+*******************************************************/
+
+#include "sun.h"
+#include "gcstruct.h"
+#include "mi.h"
+#include "mibstore.h"
+#include "cfb.h"
+#include "cfb16.h"
+#include "cfb32.h"
+
+/* maximum pixmap depth */
+#ifndef SUNMAXDEPTH
+#define SUNMAXDEPTH 8
+#endif
+
+#ifdef i386 /* { */
+#define BW2I NULL
+#else /* }{ */
+extern Bool sunBW2Init(
+ int /* screen */,
+ ScreenPtr /* pScreen */,
+ int /* argc */,
+ char** /* argv */
+);
+#define BW2I sunBW2Init
+#endif /* } */
+
+
+#if SUNMAXDEPTH == 1 /* { */
+#define CG2I NULL
+#define CG3I NULL
+#define CG4I NULL
+#define CG6I NULL
+#define CG8I NULL
+#define TCXI NULL
+#else /* }{ */
+extern Bool sunCG3Init(
+ int /* screen */,
+ ScreenPtr /* pScreen */,
+ int /* argc */,
+ char** /* argv */
+);
+#define CG3I sunCG3Init
+#if defined(i386) || defined(__bsdi__) /* { */
+#define CG2I NULL
+#define CG4I NULL
+#else /* }{ */
+#ifdef INCLUDE_CG2_HEADER
+extern Bool sunCG2Init(
+ int /* screen */,
+ ScreenPtr /* pScreen */,
+ int /* argc */,
+ char** /* argv */
+);
+#define CG2I sunCG2Init
+#endif /* INCLUDE_CG2_HEADER */
+extern Bool sunCG4Init(
+ int /* screen */,
+ ScreenPtr /* pScreen */,
+ int /* argc */,
+ char** /* argv */
+);
+#define CG4I sunCG4Init
+#endif /* } */
+#ifdef FBTYPE_SUNFAST_COLOR /* { */
+extern Bool sunCG6Init(
+ int /* screen */,
+ ScreenPtr /* pScreen */,
+ int /* argc */,
+ char** /* argv */
+);
+#define CG6I sunCG6Init
+#else /* }{ */
+#define CG6I NULL
+#endif /* } */
+#ifdef XFBTYPE_TCX /* { */
+extern Bool sunTCXInit(
+ int /* screen */,
+ ScreenPtr /* pScreen */,
+ int /* argc */,
+ char** /* argv */
+);
+#define TCXI sunTCXInit
+#else /* }{ */
+#define TCXI NULL
+#endif /* } */
+#if SUNMAXDEPTH > 8 /* { */
+#ifdef FBTYPE_MEMCOLOR /* { */
+extern Bool sunCG8Init(
+ int /* screen */,
+ ScreenPtr /* pScreen */,
+ int /* argc */,
+ char** /* argv */
+);
+#define CG8I sunCG8Init
+#else /* }{ */
+#define CG8I NULL
+#endif /* } */
+#else /* }{ */
+#define CG8I NULL
+#endif /* } */
+
+#endif /* } */
+
+extern KeySymsRec sunKeySyms[];
+extern SunModmapRec *sunModMaps[];
+extern int sunMaxLayout;
+extern KeySym* sunType4KeyMaps[];
+extern SunModmapRec* sunType4ModMaps[];
+
+static Bool sunDevsInited = FALSE;
+
+Bool sunAutoRepeatHandlersInstalled; /* FALSE each time InitOutput called */
+Bool sunSwapLkeys = FALSE;
+Bool sunFlipPixels = FALSE;
+Bool sunFbInfo = FALSE;
+Bool sunCG4Frob = FALSE;
+Bool sunNoGX = FALSE;
+
+sunKbdPrivRec sunKbdPriv = {
+ -1, /* fd */
+ -1, /* type */
+ -1, /* layout */
+ 0, /* click */
+ (Leds)0, /* leds */
+};
+
+sunPtrPrivRec sunPtrPriv = {
+ -1, /* fd */
+ 0 /* Current button state */
+};
+
+/*
+ * The name member in the following table corresponds to the
+ * FBTYPE_* macros defined in /usr/include/sun/fbio.h file
+ */
+sunFbDataRec sunFbData[XFBTYPE_LASTPLUSONE] = {
+ { NULL, "SUN1BW (bw1)" },
+ { NULL, "SUN1COLOR (cg1)" },
+ { BW2I, "SUN2BW (bw2)" },
+#ifdef INCLUDE_CG2_HEADER
+ { CG2I, "SUN2COLOR (cg2)" },
+#endif /* INCLUDE_CG2_HEADER */
+ { NULL, "SUN2GP (gp1/gp2)" },
+ { NULL, "SUN5COLOR (cg5/386i accel)" },
+ { CG3I, "SUN3COLOR (cg3)" },
+ { CG8I, "MEMCOLOR (cg8)" },
+ { CG4I, "SUN4COLOR (cg4)" },
+ { NULL, "NOTSUN1" },
+ { NULL, "NOTSUN2" },
+ { NULL, "NOTSUN3" }
+#ifndef i386 /* { */
+ ,{ CG6I, "SUNFAST_COLOR (cg6/gx)" },
+ { NULL, "SUNROP_COLOR (cg9)" },
+ { NULL, "SUNFB_VIDEO" },
+ { NULL, "SUNGIFB" },
+ { NULL, "SUNPLAS" },
+#ifdef FBTYPE_SUNGP3
+ { NULL, "SUNGP3 (cg12/gs)" },
+#endif
+#ifdef FBTYPE_SUNGT
+ { NULL, "SUNGT (gt)" },
+#endif
+#ifdef FBTYPE_SUNLEO
+ { NULL, "SUNLEO (zx)" },
+#endif
+#ifdef FBTYPE_MDICOLOR
+ { NULL, "MDICOLOR (cgfourteen)" },
+#endif
+#ifdef XFBTYPE_TCX
+ { TCXI, "TCX (tcx)" },
+#endif
+#endif /* } */
+};
+
+/*
+ * a list of devices to try if there is no environment or command
+ * line list of devices
+ */
+#if SUNMAXDEPTH == 1 /* { */
+static char *fallbackList[] = {
+ BWTWO0DEV, BWTWO1DEV, BWTWO2DEV
+};
+#else /* }{ */
+static char *fallbackList[] = {
+#ifndef i386 /* { */
+ CGTWO0DEV, CGTWO1DEV, CGTWO2DEV,
+#if (MAXSCREENS == 4)
+ CGTWO3DEV,
+#endif
+#endif /* } */
+ CGTHREE0DEV,
+#ifndef i386 /* { */
+ CGTHREE1DEV, CGTHREE2DEV,
+#if (MAXSCREENS == 4)
+ CGTHREE3DEV,
+#endif
+#endif /* } */
+#ifdef FBTYPE_SUNFAST_COLOR /* { */
+ CGSIX0DEV, CGSIX1DEV, CGSIX2DEV,
+#if (MAXSCREENS == 4)
+ CGSIX3DEV,
+#endif
+#endif /* } */
+#ifndef i386 /* { */
+ CGFOUR0DEV, BWTWO0DEV, BWTWO1DEV, BWTWO2DEV,
+#if (MAXSCREENS == 4)
+ BWTWO3DEV,
+#endif
+#endif /* } */
+#if SUNMAXDEPTH > 8 /* { */
+ CGEIGHT0DEV,
+#if 0
+#ifdef XFBTYPE_TCX
+ TCX0DEV,
+#endif
+#endif
+#endif /* } */
+ "/dev/fb"
+};
+#endif /* } */
+
+#define FALLBACK_LIST_LEN sizeof fallbackList / sizeof fallbackList[0]
+
+fbFd sunFbs[MAXSCREENS];
+
+static PixmapFormatRec formats[] = {
+ { 1, 1, BITMAP_SCANLINE_PAD } /* 1-bit deep */
+#if SUNMAXDEPTH > 1
+ ,{ 8, 8, BITMAP_SCANLINE_PAD} /* 8-bit deep */
+#if SUNMAXDEPTH > 8
+ ,{ 12, 24, BITMAP_SCANLINE_PAD } /* 12-bit deep */
+ ,{ 24, 32, BITMAP_SCANLINE_PAD } /* 24-bit deep */
+#endif
+#endif
+};
+#define NUMFORMATS (sizeof formats)/(sizeof formats[0])
+
+/*
+ * OpenFrameBuffer --
+ * Open a frame buffer according to several rules.
+ * Find the device to use by looking in the sunFbData table,
+ * an XDEVICE envariable, a -dev switch or using /dev/fb if trying
+ * to open screen 0 and all else has failed.
+ *
+ * Results:
+ * The fd of the framebuffer.
+ */
+static int OpenFrameBuffer(device, screen)
+ char *device; /* e.g. "/dev/cgtwo0" */
+ int screen; /* what screen am I going to be */
+{
+ int ret = TRUE;
+ struct fbgattr *fbattr;
+ static int devFbUsed;
+
+ sunFbs[screen].fd = -1;
+ if (strcmp (device, "/dev/fb") == 0 && devFbUsed)
+ return FALSE;
+ if (access (device, R_OK | W_OK) == -1)
+ return FALSE;
+ if ((sunFbs[screen].fd = open(device, O_RDWR, 0)) == -1)
+ ret = FALSE;
+ else {
+ fbattr = (struct fbgattr *) xalloc (sizeof (struct fbgattr));
+ if (ioctl(sunFbs[screen].fd, FBIOGATTR, fbattr) == -1) {
+ /*
+ This is probably a bwtwo; the $64,000 question is:
+ is it the mono plane of a cgfour, or is it really a
+ real bwtwo? If there is only a cgfour in the box or
+ only a bwtwo in the box, then it isn't a problem. If
+ it's a 3/60, which has a bwtwo on the mother board *and*
+ a cgfour, then things get tricky because there's no way
+ to tell if the bwtwo is really being emulated by the cgfour.
+ */
+ xfree (fbattr);
+ fbattr = NULL;
+ if (ioctl(sunFbs[screen].fd, FBIOGTYPE, &sunFbs[screen].info) == -1) {
+ Error("unable to get frame buffer attributes");
+ (void) close(sunFbs[screen].fd);
+ sunFbs[screen].fd = -1;
+ return FALSE;
+ }
+ }
+ if (ret) {
+ devFbUsed = TRUE;
+ if (fbattr) {
+ if (fbattr->fbtype.fb_type >= XFBTYPE_LASTPLUSONE) {
+ ErrorF ("%s is an unknown framebuffer type\n", device);
+ (void) close(sunFbs[screen].fd);
+ sunFbs[screen].fd = -1;
+ return FALSE;
+ }
+ sunFbs[screen].info = fbattr->fbtype;
+ }
+ sunFbs[screen].fbPriv = (pointer) fbattr;
+ if (fbattr && !sunFbData[fbattr->fbtype.fb_type].init) {
+ int _i;
+ ret = FALSE;
+ for (_i = 0; _i < FB_ATTR_NEMUTYPES; _i++) {
+ if (sunFbData[fbattr->emu_types[_i]].init) {
+ sunFbs[screen].info.fb_type = fbattr->emu_types[_i];
+ ret = TRUE;
+ if (sunFbInfo)
+ ErrorF ("%s is emulating a %s\n", device,
+ sunFbData[fbattr->fbtype.fb_type].name);
+ break;
+ }
+ }
+ }
+ if (sunFbInfo)
+ ErrorF ("%s is really a %s\n", device,
+ sunFbData[fbattr ? fbattr->fbtype.fb_type : sunFbs[screen].info.fb_type].name);
+ }
+ }
+ if (!ret)
+ sunFbs[screen].fd = -1;
+ return ret;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * SigIOHandler --
+ * Signal handler for SIGIO - input is available.
+ *
+ * Results:
+ * sunSigIO is set - ProcessInputEvents() will be called soon.
+ *
+ * Side Effects:
+ * None
+ *
+ *-----------------------------------------------------------------------
+ */
+/*ARGSUSED*/
+static void SigIOHandler(sig)
+ int sig;
+{
+ int olderrno = errno;
+ sunEnqueueEvents ();
+ errno = olderrno;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunNonBlockConsoleOff --
+ * Turn non-blocking mode on the console off, so you don't get logged
+ * out when the server exits.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------
+ */
+void sunNonBlockConsoleOff(
+#if defined(SVR4) || defined(CSRG_BASED)
+ void
+#else
+ char* arg
+#endif
+)
+{
+ register int i;
+
+ i = fcntl(2, F_GETFL, 0);
+ if (i >= 0)
+ (void) fcntl(2, F_SETFL, i & ~FNDELAY);
+}
+
+static char** GetDeviceList (argc, argv)
+ int argc;
+ char **argv;
+{
+ int i;
+ char *envList = NULL;
+ char *cmdList = NULL;
+ char **deviceList = (char **)NULL;
+
+ for (i = 1; i < argc; i++)
+ if (strcmp (argv[i], "-dev") == 0 && i+1 < argc) {
+ cmdList = argv[i + 1];
+ break;
+ }
+ if (!cmdList)
+ envList = getenv ("XDEVICE");
+
+ if (cmdList || envList) {
+ char *_tmpa;
+ char *_tmpb;
+ int _i1;
+ deviceList = (char **) xalloc ((MAXSCREENS + 1) * sizeof (char *));
+ _tmpa = (cmdList) ? cmdList : envList;
+ for (_i1 = 0; _i1 < MAXSCREENS; _i1++) {
+ _tmpb = strtok (_tmpa, ":");
+ if (_tmpb)
+ deviceList[_i1] = _tmpb;
+ else
+ deviceList[_i1] = NULL;
+ _tmpa = NULL;
+ }
+ deviceList[MAXSCREENS] = NULL;
+ }
+ if (!deviceList) {
+ /* no environment and no cmdline, so default */
+ deviceList =
+ (char **) xalloc ((FALLBACK_LIST_LEN + 1) * sizeof (char *));
+ for (i = 0; i < FALLBACK_LIST_LEN; i++)
+ deviceList[i] = fallbackList[i];
+ deviceList[FALLBACK_LIST_LEN] = NULL;
+ }
+ return deviceList;
+}
+
+static void getKbdType()
+{
+/*
+ * The Sun 386i has system include files that preclude this pre SunOS 4.1
+ * test for the presence of a type 4 keyboard however it really doesn't
+ * matter since no 386i has ever been shipped with a type 3 keyboard.
+ * SunOS 4.1 no longer needs this kludge.
+ */
+#if !defined(i386) && !defined(KIOCGKEY)
+#define TYPE4KEYBOARDOVERRIDE
+#endif
+
+ int ii;
+
+ for (ii = 0; ii < 3; ii++) {
+ sunKbdWait();
+ (void) ioctl (sunKbdPriv.fd, KIOCTYPE, &sunKbdPriv.type);
+#ifdef TYPE4KEYBOARDOVERRIDE
+ /*
+ * Magic. Look for a key which is non-existent on a real type
+ * 3 keyboard but does exist on a type 4 keyboard.
+ */
+ if (sunKbdPriv.type == KB_SUN3) {
+ struct kiockeymap key;
+
+ key.kio_tablemask = 0;
+ key.kio_station = 118;
+ if (ioctl(sunKbdPriv.fd, KIOCGKEY, &key) == -1) {
+ Error( "ioctl KIOCGKEY" );
+ FatalError("Can't KIOCGKEY on fd %d\n", sunKbdPriv.fd);
+ }
+ if (key.kio_entry != HOLE)
+ sunKbdPriv.type = KB_SUN4;
+ }
+#endif
+ switch (sunKbdPriv.type) {
+ case KB_SUN2:
+ case KB_SUN3:
+ case KB_SUN4: return;
+ default:
+ sunChangeKbdTranslation(sunKbdPriv.fd, FALSE);
+ continue;
+ }
+ }
+ FatalError ("Unsupported keyboard type %d\n", sunKbdPriv.type);
+}
+
+void OsVendorInit(
+ void
+)
+{
+ static int inited;
+ if (!inited) {
+#ifndef i386
+ struct rlimit rl;
+
+ /*
+ * one per client, one per screen, one per listen endpoint,
+ * keyboard, mouse, and stderr
+ */
+ int maxfds = MAXCLIENTS + MAXSCREENS + 5;
+
+ if (getrlimit (RLIMIT_NOFILE, &rl) == 0) {
+ rl.rlim_cur = maxfds < rl.rlim_max ? maxfds : rl.rlim_max;
+ (void) setrlimit (RLIMIT_NOFILE, &rl);
+ }
+#endif
+ sunKbdPriv.fd = open ("/dev/kbd", O_RDWR, 0);
+ if (sunKbdPriv.fd < 0)
+ FatalError ("Cannot open /dev/kbd, error %d\n", errno);
+ sunPtrPriv.fd = open ("/dev/mouse", O_RDWR, 0);
+ if (sunPtrPriv.fd < 0)
+ FatalError ("Cannot open /dev/mouse, error %d\n", errno);
+ getKbdType ();
+ if (sunKbdPriv.type == KB_SUN4) {
+ (void) ioctl (sunKbdPriv.fd, KIOCLAYOUT, &sunKbdPriv.layout);
+ if (sunKbdPriv.layout < 0 ||
+ sunKbdPriv.layout > sunMaxLayout ||
+ sunType4KeyMaps[sunKbdPriv.layout] == NULL)
+ FatalError ("Unsupported keyboard type 4 layout %d\n",
+ sunKbdPriv.layout);
+ sunKeySyms[KB_SUN4].map = sunType4KeyMaps[sunKbdPriv.layout];
+ sunModMaps[KB_SUN4] = sunType4ModMaps[sunKbdPriv.layout];
+ }
+ inited = 1;
+ }
+}
+
+#ifdef DDXOSFATALERROR
+void OsVendorFatalError(void)
+{
+}
+#endif
+
+/*-
+ *-----------------------------------------------------------------------
+ * InitOutput --
+ * Initialize screenInfo for all actually accessible framebuffers.
+ * The
+ *
+ * Results:
+ * screenInfo init proc field set
+ *
+ * Side Effects:
+ * None
+ *
+ *-----------------------------------------------------------------------
+ */
+
+void InitOutput(pScreenInfo, argc, argv)
+ ScreenInfo *pScreenInfo;
+ int argc;
+ char **argv;
+{
+ int i, scr;
+ int nonBlockConsole = 0;
+ char **devList;
+ static int setup_on_exit = 0;
+ extern Bool RunFromSmartParent;
+
+ if (!monitorResolution)
+ monitorResolution = 90;
+ if (RunFromSmartParent)
+ nonBlockConsole = 1;
+ for (i = 1; i < argc; i++) {
+ if (!strcmp(argv[i],"-debug"))
+ nonBlockConsole = 0;
+ }
+
+ /*
+ * Writes to /dev/console can block - causing an
+ * excess of error messages to hang the server in
+ * deadlock. So.......
+ */
+ if (nonBlockConsole) {
+ if (!setup_on_exit) {
+#if defined(SVR4) || defined(CSRG_BASED)
+ if (atexit(sunNonBlockConsoleOff))
+#else
+ if (on_exit(sunNonBlockConsoleOff, (char *)0))
+#endif
+ ErrorF("InitOutput: can't register NBIO exit handler\n");
+
+ setup_on_exit = 1;
+ }
+ i = fcntl(2, F_GETFL, 0);
+ if (i >= 0)
+ i = fcntl(2, F_SETFL, i | FNDELAY);
+ if (i < 0) {
+ Error("fcntl");
+ ErrorF("InitOutput: can't put stderr in non-block mode\n");
+ }
+ }
+ pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+ pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+
+ pScreenInfo->numPixmapFormats = NUMFORMATS;
+ for (i=0; i< NUMFORMATS; i++)
+ pScreenInfo->formats[i] = formats[i];
+#ifdef XKB
+ if (noXkbExtension)
+#endif
+ sunAutoRepeatHandlersInstalled = FALSE;
+ if (!sunDevsInited) {
+ /* first time ever */
+ for (scr = 0; scr < MAXSCREENS; scr++)
+ sunFbs[scr].fd = -1;
+ devList = GetDeviceList (argc, argv);
+ for (i = 0, scr = 0; devList[i] != NULL && scr < MAXSCREENS; i++)
+ if (OpenFrameBuffer (devList[i], scr))
+ scr++;
+ sunDevsInited = TRUE;
+ xfree (devList);
+ }
+ for (scr = 0; scr < MAXSCREENS; scr++)
+ if (sunFbs[scr].fd != -1)
+ (void) AddScreen (sunFbData[sunFbs[scr].info.fb_type].init,
+ argc, argv);
+ (void) OsSignal(SIGWINCH, SIG_IGN);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * InitInput --
+ * Initialize all supported input devices...what else is there
+ * besides pointer and keyboard?
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Two DeviceRec's are allocated and registered as the system pointer
+ * and keyboard devices.
+ *
+ *-----------------------------------------------------------------------
+ */
+void InitInput(argc, argv)
+ int argc;
+ char **argv;
+{
+ pointer p, k;
+ extern Bool mieqInit();
+
+ p = AddInputDevice(sunMouseProc, TRUE);
+ k = AddInputDevice(sunKbdProc, TRUE);
+ if (!p || !k)
+ FatalError("failed to create input devices in InitInput");
+
+ RegisterPointerDevice(p);
+ RegisterKeyboardDevice(k);
+ miRegisterPointerDevice(screenInfo.screens[0], p);
+ (void) mieqInit (k, p);
+#define SET_FLOW(fd) fcntl(fd, F_SETFL, FNDELAY | FASYNC)
+#ifdef SVR4
+ (void) OsSignal(SIGPOLL, SigIOHandler);
+#define WANT_SIGNALS(fd) ioctl(fd, I_SETSIG, S_INPUT | S_HIPRI)
+#else
+ (void) OsSignal(SIGIO, SigIOHandler);
+#define WANT_SIGNALS(fd) fcntl(fd, F_SETOWN, getpid())
+#endif
+ if (sunKbdPriv.fd >= 0) {
+ if (SET_FLOW(sunKbdPriv.fd) == -1 || WANT_SIGNALS(sunKbdPriv.fd) == -1) {
+ (void) close (sunKbdPriv.fd);
+ sunKbdPriv.fd = -1;
+ FatalError("Async kbd I/O failed in InitInput");
+ }
+ }
+ if (sunPtrPriv.fd >= 0) {
+ if (SET_FLOW(sunPtrPriv.fd) == -1 || WANT_SIGNALS(sunPtrPriv.fd) == -1) {
+ (void) close (sunPtrPriv.fd);
+ sunPtrPriv.fd = -1;
+ FatalError("Async mouse I/O failed in InitInput");
+ }
+ }
+}
+
+
+#if SUNMAXDEPTH == 8
+
+Bool
+sunCfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp; /* bits per pixel of root */
+{
+ return cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy,
+ width);
+}
+
+Bool
+sunCfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp; /* bits per pixel of root */
+{
+ return cfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy,
+ width);
+}
+
+Bool
+sunCfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp; /* bits per pixel of root */
+{
+ return cfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
+}
+
+#else /* SUNMAXDEPTH != 8 */
+#if SUNMAXDEPTH == 32
+
+static Bool
+sunCfbCreateGC(pGC)
+ GCPtr pGC;
+{
+ if (pGC->depth == 1)
+ {
+ return mfbCreateGC (pGC);
+ }
+ else if (pGC->depth <= 8)
+ {
+ return cfbCreateGC (pGC);
+ }
+ else if (pGC->depth <= 16)
+ {
+ return cfb16CreateGC (pGC);
+ }
+ else if (pGC->depth <= 32)
+ {
+ return cfb32CreateGC (pGC);
+ }
+ return FALSE;
+}
+
+static void
+sunCfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart)
+ DrawablePtr pDrawable; /* drawable from which to get bits */
+ int wMax; /* largest value of all *pwidths */
+ register DDXPointPtr ppt; /* points to start copying from */
+ int *pwidth; /* list of number of bits to copy */
+ int nspans; /* number of scanlines to copy */
+ char *pdstStart; /* where to put the bits */
+{
+ switch (pDrawable->bitsPerPixel) {
+ case 1:
+ mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+ break;
+ case 8:
+ cfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+ break;
+ case 16:
+ cfb16GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+ break;
+ case 32:
+ cfb32GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+ break;
+ }
+ return;
+}
+
+static void
+sunCfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine)
+ DrawablePtr pDrawable;
+ int sx, sy, w, h;
+ unsigned int format;
+ unsigned long planeMask;
+ char *pdstLine;
+{
+ switch (pDrawable->bitsPerPixel)
+ {
+ case 1:
+ mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+ break;
+ case 8:
+ cfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+ break;
+ case 16:
+ cfb16GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+ break;
+ case 32:
+ cfb32GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+ break;
+ }
+}
+
+Bool
+sunCfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp; /* bits per pixel of root */
+{
+ int ret;
+
+ switch (bpp) {
+ case 8:
+ ret = cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
+ break;
+ case 16:
+ ret = cfb16SetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
+ break;
+ case 32:
+ ret = cfb32SetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
+ break;
+ default:
+ return FALSE;
+ }
+ pScreen->CreateGC = sunCfbCreateGC;
+ pScreen->GetImage = sunCfbGetImage;
+ pScreen->GetSpans = sunCfbGetSpans;
+ return ret;
+}
+
+/* Adapt cfb logic */
+#undef CFB_NEED_SCREEN_PRIVATE
+#if !defined(SINGLEDEPTH) || defined(FORDE_SEPARATE_PRIVATE)
+#define CFB_NEED_SCREEN_PRIVATE
+#endif
+
+extern BSFuncRec cfbBSFuncRec, cfb16BSFuncRec, cfb32BSFuncRec;
+extern Bool cfbCloseScreen(), cfb16CloseScreen(), cfb32CloseScreen();
+#ifdef CFB_NEED_SCREEN_PRIVATE
+extern int cfb16ScreenPrivateIndex, cfb32ScreenPrivateIndex;
+#endif
+
+Bool
+sunCfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp;
+{
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ pointer oldDevPrivate;
+#endif
+ VisualPtr visuals;
+ int nvisuals;
+ DepthPtr depths;
+ int ndepths;
+ VisualID defaultVisual;
+ int rootdepth = 0;
+
+ if (!cfbInitVisuals(&visuals, &depths, &nvisuals, &ndepths,
+ &rootdepth, &defaultVisual, 1 << (bpp - 1), 8))
+ return FALSE;
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ oldDevPrivate = pScreen->devPrivate;
+#endif
+ if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
+ rootdepth, ndepths, depths,
+ defaultVisual, nvisuals, visuals))
+ return FALSE;
+ switch (bpp)
+ {
+ case 8:
+ pScreen->CloseScreen = cfbCloseScreen;
+ pScreen->BackingStoreFuncs = cfbBSFuncRec;
+ break;
+ case 16:
+ pScreen->CloseScreen = cfb16CloseScreen;
+ pScreen->BackingStoreFuncs = cfb16BSFuncRec;
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ pScreen->devPrivates[cfb16ScreenPrivateIndex].ptr =
+ pScreen->devPrivate;
+ pScreen->devPrivate = oldDevPrivate;
+#endif
+ break;
+ case 32:
+ pScreen->CloseScreen = cfb32CloseScreen;
+ pScreen->BackingStoreFuncs = cfb32BSFuncRec;
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ pScreen->devPrivates[cfb32ScreenPrivateIndex].ptr =
+ pScreen->devPrivate;
+ pScreen->devPrivate = oldDevPrivate;
+#endif
+ break;
+ }
+ return TRUE;
+}
+
+
+Bool
+sunCfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp;
+{
+ if (!sunCfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy,
+ width, bpp))
+ return FALSE;
+ return sunCfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix,
+ dpiy, width, bpp);
+}
+
+#endif /* SUNMAXDEPTH == 32 */
+#endif /* SUNMAXDEPTH */
+
+#ifdef DPMSExtension
+/**************************************************************
+ * DPMSSet(), DPMSGet(), DPMSSupported()
+ *
+ * stubs
+ *
+ ***************************************************************/
+
+void DPMSSet (level)
+ int level;
+{
+}
+
+int DPMSGet (level)
+ int* level;
+{
+ return -1;
+}
+
+Bool DPMSSupported ()
+{
+ return FALSE;
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/sun/sunIo.c b/nx-X11/programs/Xserver/hw/sun/sunIo.c
new file mode 100644
index 000000000..e8bc68887
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/sunIo.c
@@ -0,0 +1,305 @@
+/* $Xorg: sunIo.c,v 1.4 2001/03/07 17:34:19 pookie Exp $ */
+/*-
+ * sunIo.c --
+ * Functions to handle input from the keyboard and mouse.
+ *
+ * Copyright 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/sun/sunIo.c,v 3.9 2001/12/19 21:28:45 dawes Exp $ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#define NEED_EVENTS
+#include "sun.h"
+#include "mi.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * ProcessInputEvents --
+ * Retrieve all waiting input events and pass them to DIX in their
+ * correct chronological order. Only reads from the system pointer
+ * and keyboard.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Events are passed to the DIX layer.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+ProcessInputEvents ()
+{
+ mieqProcessInputEvents ();
+ miPointerUpdate ();
+}
+
+/*
+ *-----------------------------------------------------------------------
+ * sunEnqueueEvents
+ * When a SIGIO is received, read device hard events and
+ * enqueue them using the mi event queue
+ */
+
+void sunEnqueueEvents (
+ void
+)
+{
+ Firm_event *ptrEvents, /* Current pointer event */
+ *kbdEvents; /* Current keyboard event */
+ int numPtrEvents, /* Number of remaining pointer events */
+ numKbdEvents; /* Number of remaining keyboard events */
+ int nPE, /* Original number of pointer events */
+ nKE; /* Original number of keyboard events */
+ Bool PtrAgain, /* need to (re)read */
+ KbdAgain; /* need to (re)read */
+ DeviceIntPtr pPointer;
+ DeviceIntPtr pKeyboard;
+ sunKbdPrivPtr kbdPriv;
+ sunPtrPrivPtr ptrPriv;
+
+ pPointer = (DeviceIntPtr)LookupPointerDevice();
+ pKeyboard = (DeviceIntPtr)LookupKeyboardDevice();
+ ptrPriv = (sunPtrPrivPtr) pPointer->public.devicePrivate;
+ kbdPriv = (sunKbdPrivPtr) pKeyboard->public.devicePrivate;
+ if (!pPointer->public.on || !pKeyboard->public.on)
+ return;
+
+ numPtrEvents = 0;
+ ptrEvents = NULL;
+ PtrAgain = TRUE;
+ numKbdEvents = 0;
+ kbdEvents = NULL;
+ KbdAgain = TRUE;
+
+ /*
+ * So long as one event from either device remains unprocess, we loop:
+ * Take the oldest remaining event and pass it to the proper module
+ * for processing. The DDXEvent will be sent to ProcessInput by the
+ * function called.
+ */
+ while (1) {
+ /*
+ * Get events from both the pointer and the keyboard, storing the number
+ * of events gotten in nPE and nKE and keeping the start of both arrays
+ * in pE and kE
+ */
+ if ((numPtrEvents == 0) && PtrAgain) {
+ ptrEvents = sunMouseGetEvents (ptrPriv->fd, pPointer->public.on,
+ &nPE, &PtrAgain);
+ numPtrEvents = nPE;
+ }
+ if ((numKbdEvents == 0) && KbdAgain) {
+ kbdEvents = sunKbdGetEvents (kbdPriv->fd, pKeyboard->public.on,
+ &nKE, &KbdAgain);
+ numKbdEvents = nKE;
+ }
+ if ((numPtrEvents == 0) && (numKbdEvents == 0))
+ break;
+ if (numPtrEvents && numKbdEvents) {
+ if (timercmp (&kbdEvents->time, &ptrEvents->time, <)) {
+ sunKbdEnqueueEvent (pKeyboard, kbdEvents);
+ numKbdEvents--;
+ kbdEvents++;
+ } else {
+ sunMouseEnqueueEvent (pPointer, ptrEvents);
+ numPtrEvents--;
+ ptrEvents++;
+ }
+ } else if (numKbdEvents) {
+ sunKbdEnqueueEvent (pKeyboard, kbdEvents);
+ numKbdEvents--;
+ kbdEvents++;
+ } else {
+ sunMouseEnqueueEvent (pPointer, ptrEvents);
+ numPtrEvents--;
+ ptrEvents++;
+ }
+ }
+}
+
+/*
+ * DDX - specific abort routine. Called by AbortServer().
+ */
+void AbortDDX()
+{
+ int i;
+ ScreenPtr pScreen;
+ DevicePtr devPtr;
+
+#ifdef SVR4
+ (void) OsSignal (SIGPOLL, SIG_IGN);
+#else
+ (void) OsSignal (SIGIO, SIG_IGN);
+#endif
+ devPtr = LookupKeyboardDevice();
+ if (devPtr)
+ (void) sunChangeKbdTranslation (((sunKbdPrivPtr)(devPtr->devicePrivate))->fd, FALSE);
+#if defined(SVR4) || defined(CSRG_BASED)
+ sunNonBlockConsoleOff ();
+#else
+ sunNonBlockConsoleOff (NULL);
+#endif
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ pScreen = screenInfo.screens[i];
+ (*pScreen->SaveScreen) (pScreen, SCREEN_SAVER_OFF);
+ sunDisableCursor (pScreen);
+ }
+}
+
+/* Called by GiveUp(). */
+void
+ddxGiveUp()
+{
+ AbortDDX ();
+}
+
+/* ddxInitGlobals - called by |InitGlobals| from os/util.c */
+void ddxInitGlobals(void)
+{
+}
+
+int
+ddxProcessArgument (argc, argv, i)
+ int argc;
+ char *argv[];
+ int i;
+{
+ extern void UseMsg();
+ extern int XprintOptions(int, char **, int);
+
+#ifdef XKB
+ int noxkb = 0, n;
+ /*
+ * peek in argv and see if -kb because noXkbExtension won't
+ * get set until too late to useful here.
+ */
+ for (n = 1; n < argc; n++)
+ if (strcmp (argv[n], "-kb") == 0)
+ noxkb = 1;
+
+ if (noxkb)
+#endif
+ if (strcmp (argv[i], "-ar1") == 0) { /* -ar1 int */
+ if (++i >= argc) UseMsg ();
+ sunAutoRepeatInitiate = 1000 * (long)atoi(argv[i]); /* cvt to usec */
+ if (sunAutoRepeatInitiate > 1000000)
+ sunAutoRepeatInitiate = 999000;
+ return 2;
+ }
+#ifdef XKB
+ if (noxkb)
+#endif
+ if (strcmp (argv[i], "-ar2") == 0) { /* -ar2 int */
+ if (++i >= argc) UseMsg ();
+ sunAutoRepeatDelay = 1000 * (long)atoi(argv[i]); /* cvt to usec */
+ if (sunAutoRepeatDelay > 1000000)
+ sunAutoRepeatDelay = 999000;
+ return 2;
+ }
+ if (strcmp (argv[i], "-swapLkeys") == 0) { /* -swapLkeys */
+ sunSwapLkeys = TRUE;
+ return 1;
+ }
+ if (strcmp (argv[i], "-debug") == 0) { /* -debug */
+ return 1;
+ }
+ if (strcmp (argv[i], "-dev") == 0) { /* -dev /dev/mumble */
+ if (++i >= argc) UseMsg ();
+ return 2;
+ }
+ if (strcmp (argv[i], "-mono") == 0) { /* -mono */
+ return 1;
+ }
+ if (strcmp (argv[i], "-zaphod") == 0) { /* -zaphod */
+ sunActiveZaphod = FALSE;
+ return 1;
+ }
+ if (strcmp (argv[i], "-flipPixels") == 0) { /* -flipPixels */
+ sunFlipPixels = TRUE;
+ return 1;
+ }
+ if (strcmp (argv[i], "-fbinfo") == 0) { /* -fbinfo */
+ sunFbInfo = TRUE;
+ return 1;
+ }
+ if (strcmp (argv[i], "-kbd") == 0) { /* -kbd */
+ if (++i >= argc) UseMsg();
+ return 2;
+ }
+ if (strcmp (argv[i], "-protect") == 0) { /* -protect */
+ if (++i >= argc) UseMsg();
+ return 2;
+ }
+ if (strcmp (argv[i], "-cg4frob") == 0) {
+ sunCG4Frob = TRUE;
+ return 1;
+ }
+ if (strcmp (argv[i], "-noGX") == 0) {
+ sunNoGX = TRUE;
+ return 1;
+ }
+ if (strcmp(argv[i], "-XpFile") == 0) {
+ return XprintOptions(argc, argv, i) - i;
+ }
+ return 0;
+}
+
+void
+ddxUseMsg()
+{
+#ifndef XKB
+ ErrorF("-ar1 int set autorepeat initiate time\n");
+ ErrorF("-ar2 int set autorepeat interval time\n");
+#endif
+ ErrorF("-swapLkeys swap keysyms on L1..L10\n");
+ ErrorF("-debug disable non-blocking console mode\n");
+ ErrorF("-dev fn[:fn][:fn] name of device[s] to open\n");
+ ErrorF("-mono force monochrome-only screen\n");
+ ErrorF("-zaphod disable active Zaphod mode\n");
+ ErrorF("-fbinfo tell more about the found frame buffer(s)\n");
+#ifdef UNDOCUMENTED
+ ErrorF("-cg4frob don't use the mono plane of the cgfour\n");
+ ErrorF("-noGX treat the GX as a dumb frame buffer\n");
+#endif
+ ErrorF("-XpFile specifies an alternate `Xprinters' file (Xprt only)\n");
+}
diff --git a/nx-X11/programs/Xserver/hw/sun/sunKbd.c b/nx-X11/programs/Xserver/hw/sun/sunKbd.c
new file mode 100644
index 000000000..a11026d6f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/sunKbd.c
@@ -0,0 +1,1071 @@
+/* $Xorg: sunKbd.c,v 1.3 2000/08/17 19:48:30 cpqbld Exp $ */
+/*-
+ * Copyright 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/hw/sun/sunKbd.c,v 1.8 2001/10/28 03:33:11 tsi Exp $ */
+
+#define NEED_EVENTS
+#include "sun.h"
+#include "keysym.h"
+#include "Sunkeysym.h"
+#include "mi.h"
+
+#ifdef XKB
+#include <X11/extensions/XKB.h>
+#include <X11/extensions/XKBstr.h>
+#include <X11/extensions/XKBsrv.h>
+#endif
+
+#define SUN_LED_MASK 0x0f
+#define MIN_KEYCODE 7 /* necessary to avoid the mouse buttons */
+#define MAX_KEYCODE 255 /* limited by the protocol */
+#ifndef KB_SUN4
+#define KB_SUN4 4
+#endif
+
+#define AUTOREPEAT_INITIATE 400
+#define AUTOREPEAT_DELAY 50
+
+#define tvminus(tv, tv1, tv2) /* tv = tv1 - tv2 */ \
+ if ((tv1).tv_usec < (tv2).tv_usec) { \
+ (tv1).tv_usec += 1000000; \
+ (tv1).tv_sec -= 1; \
+ } \
+ (tv).tv_usec = (tv1).tv_usec - (tv2).tv_usec; \
+ (tv).tv_sec = (tv1).tv_sec - (tv2).tv_sec;
+
+#define tvplus(tv, tv1, tv2) /* tv = tv1 + tv2 */ \
+ (tv).tv_sec = (tv1).tv_sec + (tv2).tv_sec; \
+ (tv).tv_usec = (tv1).tv_usec + (tv2).tv_usec; \
+ if ((tv).tv_usec > 1000000) { \
+ (tv).tv_usec -= 1000000; \
+ (tv).tv_sec += 1; \
+ }
+
+extern KeySymsRec sunKeySyms[];
+extern SunModmapRec* sunModMaps[];
+
+long sunAutoRepeatInitiate = 1000 * AUTOREPEAT_INITIATE;
+long sunAutoRepeatDelay = 1000 * AUTOREPEAT_DELAY;
+
+static int autoRepeatKeyDown = 0;
+static int autoRepeatReady;
+static int autoRepeatFirst;
+#if defined(_LP64) || defined(_I32LPx)
+static struct timeval32 autoRepeatLastKeyDownTv;
+static struct timeval32 autoRepeatDeltaTv;
+#else
+static struct timeval autoRepeatLastKeyDownTv;
+static struct timeval autoRepeatDeltaTv;
+#endif
+
+void sunKbdWait()
+{
+ static struct timeval lastChngKbdTransTv;
+ struct timeval tv;
+ struct timeval lastChngKbdDeltaTv;
+ unsigned int lastChngKbdDelta;
+
+ X_GETTIMEOFDAY(&tv);
+ if (!lastChngKbdTransTv.tv_sec)
+ lastChngKbdTransTv = tv;
+ tvminus(lastChngKbdDeltaTv, tv, lastChngKbdTransTv);
+ lastChngKbdDelta = TVTOMILLI(lastChngKbdDeltaTv);
+ if (lastChngKbdDelta < 750) {
+ unsigned wait;
+ /*
+ * We need to guarantee at least 750 milliseconds between
+ * calls to KIOCTRANS. YUCK!
+ */
+ wait = (750L - lastChngKbdDelta) * 1000L;
+ usleep (wait);
+ X_GETTIMEOFDAY(&tv);
+ }
+ lastChngKbdTransTv = tv;
+}
+
+static void SwapLKeys(keysyms)
+ KeySymsRec* keysyms;
+{
+ unsigned int i;
+ KeySym k;
+
+ for (i = 2; i < keysyms->maxKeyCode * keysyms->mapWidth; i++)
+ if (keysyms->map[i] == XK_L1 ||
+ keysyms->map[i] == XK_L2 ||
+ keysyms->map[i] == XK_L3 ||
+ keysyms->map[i] == XK_L4 ||
+ keysyms->map[i] == XK_L5 ||
+ keysyms->map[i] == XK_L6 ||
+ keysyms->map[i] == XK_L7 ||
+ keysyms->map[i] == XK_L8 ||
+ keysyms->map[i] == XK_L9 ||
+ keysyms->map[i] == XK_L10) {
+ /* yes, I could have done a clever two line swap! */
+ k = keysyms->map[i - 2];
+ keysyms->map[i - 2] = keysyms->map[i];
+ keysyms->map[i] = k;
+ }
+}
+
+static void SetLights (ctrl, fd)
+ KeybdCtrl* ctrl;
+ int fd;
+{
+#ifdef KIOCSLED
+ static unsigned char led_tab[16] = {
+ 0,
+ LED_NUM_LOCK,
+ LED_SCROLL_LOCK,
+ LED_SCROLL_LOCK | LED_NUM_LOCK,
+ LED_COMPOSE,
+ LED_COMPOSE | LED_NUM_LOCK,
+ LED_COMPOSE | LED_SCROLL_LOCK,
+ LED_COMPOSE | LED_SCROLL_LOCK | LED_NUM_LOCK,
+ LED_CAPS_LOCK,
+ LED_CAPS_LOCK | LED_NUM_LOCK,
+ LED_CAPS_LOCK | LED_SCROLL_LOCK,
+ LED_CAPS_LOCK | LED_SCROLL_LOCK | LED_NUM_LOCK,
+ LED_CAPS_LOCK | LED_COMPOSE,
+ LED_CAPS_LOCK | LED_COMPOSE | LED_NUM_LOCK,
+ LED_CAPS_LOCK | LED_COMPOSE | LED_SCROLL_LOCK,
+ LED_CAPS_LOCK | LED_COMPOSE | LED_SCROLL_LOCK | LED_NUM_LOCK
+ };
+ if (ioctl (fd, KIOCSLED, (caddr_t)&led_tab[ctrl->leds & 0x0f]) == -1)
+ Error("Failed to set keyboard lights");
+#endif
+}
+
+
+static void ModLight (device, on, led)
+ DeviceIntPtr device;
+ Bool on;
+ int led;
+{
+ KeybdCtrl* ctrl = &device->kbdfeed->ctrl;
+ sunKbdPrivPtr pPriv = (sunKbdPrivPtr) device->public.devicePrivate;
+
+ if(on) {
+ ctrl->leds |= led;
+ pPriv->leds |= led;
+ } else {
+ ctrl->leds &= ~led;
+ pPriv->leds &= ~led;
+ }
+ SetLights (ctrl, pPriv->fd);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunBell --
+ * Ring the terminal/keyboard bell
+ *
+ * Results:
+ * Ring the keyboard bell for an amount of time proportional to
+ * "loudness."
+ *
+ * Side Effects:
+ * None, really...
+ *
+ *-----------------------------------------------------------------------
+ */
+
+static void bell (
+ int fd,
+ int duration)
+{
+ int kbdCmd; /* Command to give keyboard */
+
+ kbdCmd = KBD_CMD_BELL;
+ if (ioctl (fd, KIOCCMD, &kbdCmd) == -1) {
+ Error("Failed to activate bell");
+ return;
+ }
+ if (duration) usleep (duration);
+ kbdCmd = KBD_CMD_NOBELL;
+ if (ioctl (fd, KIOCCMD, &kbdCmd) == -1)
+ Error ("Failed to deactivate bell");
+}
+
+static void sunBell (
+ int percent,
+ DeviceIntPtr device,
+ pointer ctrl,
+ int unused)
+{
+ KeybdCtrl* kctrl = (KeybdCtrl*) ctrl;
+ sunKbdPrivPtr pPriv = (sunKbdPrivPtr) device->public.devicePrivate;
+
+ if (percent == 0 || kctrl->bell == 0)
+ return;
+
+ bell (pPriv->fd, kctrl->bell_duration * 1000);
+}
+
+static void sunEnqueueEvent (xE)
+ xEvent* xE;
+{
+#ifndef i386
+ sigset_t holdmask;
+
+#ifdef SVR4
+ (void) sigaddset (&holdmask, SIGPOLL);
+#else
+ (void) sigaddset (&holdmask, SIGIO);
+#endif
+ (void) sigprocmask (SIG_BLOCK, &holdmask, (sigset_t*)NULL);
+ mieqEnqueue (xE);
+ (void) sigprocmask (SIG_UNBLOCK, &holdmask, (sigset_t*)NULL);
+#else
+ int oldmask = sigblock (sigmask (SIGIO));
+
+ mieqEnqueue (xE);
+ sigsetmask (oldmask);
+#endif
+}
+
+
+#define XLED_NUM_LOCK 0x1
+#define XLED_COMPOSE 0x4
+#define XLED_SCROLL_LOCK 0x2
+#define XLED_CAPS_LOCK 0x8
+
+static KeyCode LookupKeyCode (keysym, keysymsrec)
+ KeySym keysym;
+ KeySymsPtr keysymsrec;
+{
+ KeyCode i;
+ int ii, index = 0;
+
+ for (i = keysymsrec->minKeyCode; i < keysymsrec->maxKeyCode; i++)
+ for (ii = 0; ii < keysymsrec->mapWidth; ii++)
+ if (keysymsrec->map[index++] == keysym)
+ return i;
+ return 0;
+}
+
+static void pseudoKey(device, down, keycode)
+ DeviceIntPtr device;
+ Bool down;
+ KeyCode keycode;
+{
+ int bit;
+ CARD8 modifiers;
+ CARD16 mask;
+ BYTE* kptr;
+
+ kptr = &device->key->down[keycode >> 3];
+ bit = 1 << (keycode & 7);
+ modifiers = device->key->modifierMap[keycode];
+ if (down) {
+ /* fool dix into thinking this key is now "down" */
+ int i;
+ *kptr |= bit;
+ device->key->prev_state = device->key->state;
+ for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
+ if (mask & modifiers) {
+ device->key->modifierKeyCount[i]++;
+ device->key->state += mask;
+ modifiers &= ~mask;
+ }
+ } else {
+ /* fool dix into thinking this key is now "up" */
+ if (*kptr & bit) {
+ int i;
+ *kptr &= ~bit;
+ device->key->prev_state = device->key->state;
+ for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
+ if (mask & modifiers) {
+ if (--device->key->modifierKeyCount[i] <= 0) {
+ device->key->state &= ~mask;
+ device->key->modifierKeyCount[i] = 0;
+ }
+ modifiers &= ~mask;
+ }
+ }
+ }
+}
+
+static void DoLEDs(device, ctrl, pPriv)
+ DeviceIntPtr device; /* Keyboard to alter */
+ KeybdCtrl* ctrl;
+ sunKbdPrivPtr pPriv;
+{
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ if ((ctrl->leds & XLED_CAPS_LOCK) && !(pPriv->leds & XLED_CAPS_LOCK))
+ pseudoKey(device, TRUE,
+ LookupKeyCode(XK_Caps_Lock, &device->key->curKeySyms));
+
+ if (!(ctrl->leds & XLED_CAPS_LOCK) && (pPriv->leds & XLED_CAPS_LOCK))
+ pseudoKey(device, FALSE,
+ LookupKeyCode(XK_Caps_Lock, &device->key->curKeySyms));
+
+ if ((ctrl->leds & XLED_NUM_LOCK) && !(pPriv->leds & XLED_NUM_LOCK))
+ pseudoKey(device, TRUE,
+ LookupKeyCode(XK_Num_Lock, &device->key->curKeySyms));
+
+ if (!(ctrl->leds & XLED_NUM_LOCK) && (pPriv->leds & XLED_NUM_LOCK))
+ pseudoKey(device, FALSE,
+ LookupKeyCode(XK_Num_Lock, &device->key->curKeySyms));
+
+ if ((ctrl->leds & XLED_SCROLL_LOCK) && !(pPriv->leds & XLED_SCROLL_LOCK))
+ pseudoKey(device, TRUE,
+ LookupKeyCode(XK_Scroll_Lock, &device->key->curKeySyms));
+
+ if (!(ctrl->leds & XLED_SCROLL_LOCK) && (pPriv->leds & XLED_SCROLL_LOCK))
+ pseudoKey(device, FALSE,
+ LookupKeyCode(XK_Scroll_Lock, &device->key->curKeySyms));
+
+ if ((ctrl->leds & XLED_COMPOSE) && !(pPriv->leds & XLED_COMPOSE))
+ pseudoKey(device, TRUE,
+ LookupKeyCode(SunXK_Compose, &device->key->curKeySyms));
+
+ if (!(ctrl->leds & XLED_COMPOSE) && (pPriv->leds & XLED_COMPOSE))
+ pseudoKey(device, FALSE,
+ LookupKeyCode(SunXK_Compose, &device->key->curKeySyms));
+#ifdef XKB
+ }
+#endif
+ pPriv->leds = ctrl->leds & 0x0f;
+ SetLights (ctrl, pPriv->fd);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunKbdCtrl --
+ * Alter some of the keyboard control parameters
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Some...
+ *
+ *-----------------------------------------------------------------------
+ */
+
+static void sunKbdCtrl (
+ DeviceIntPtr device,
+ KeybdCtrl* ctrl)
+{
+ sunKbdPrivPtr pPriv = (sunKbdPrivPtr) device->public.devicePrivate;
+
+ if (pPriv->fd < 0) return;
+
+ if (ctrl->click != pPriv->click) {
+ int kbdClickCmd;
+
+ pPriv->click = ctrl->click;
+ kbdClickCmd = pPriv->click ? KBD_CMD_CLICK : KBD_CMD_NOCLICK;
+ if (ioctl (pPriv->fd, KIOCCMD, &kbdClickCmd) == -1)
+ Error("Failed to set keyclick");
+ }
+ if ((pPriv->type == KB_SUN4) && (pPriv->leds != (ctrl->leds & 0x0f)))
+ DoLEDs(device, ctrl, pPriv);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunInitKbdNames --
+ * Handle the XKB initialization
+ *
+ * Results:
+ * None.
+ *
+ * Comments:
+ * This function needs considerable work, in conjunctions with
+ * the need to add geometry descriptions of Sun Keyboards.
+ * It would also be nice to have #defines for all the keyboard
+ * layouts so that we don't have to have these hard-coded
+ * numbers.
+ *
+ *-----------------------------------------------------------------------
+ */
+#ifdef XKB
+static void sunInitKbdNames (
+ XkbComponentNamesRec* names,
+ sunKbdPrivPtr pKbd)
+{
+#ifndef XKBBUFSIZE
+#define XKBBUFSIZE 64
+#endif
+ static char keycodesbuf[XKBBUFSIZE];
+ static char geometrybuf[XKBBUFSIZE];
+ static char symbolsbuf[XKBBUFSIZE];
+
+ names->keymap = NULL;
+ names->compat = "compat/complete";
+ names->types = "types/complete";
+ names->keycodes = keycodesbuf;
+ names->geometry = geometrybuf;
+ names->symbols = symbolsbuf;
+ (void) strcpy (keycodesbuf, "keycodes/");
+ (void) strcpy (geometrybuf, "geometry/");
+ (void) strcpy (symbolsbuf, "symbols/");
+
+ /* keycodes & geometry */
+ switch (pKbd->type) {
+ case KB_SUN2:
+ (void) strcat (names->keycodes, "sun(type2)");
+ (void) strcat (names->geometry, "sun(type2)");
+ (void) strcat (names->symbols, "us(sun2)");
+ break;
+ case KB_SUN3:
+ (void) strcat (names->keycodes, "sun(type3)");
+ (void) strcat (names->geometry, "sun(type3)");
+ (void) strcat (names->symbols, "us(sun3)");
+ break;
+ case KB_SUN4:
+ /* First, catch "fully known" models */
+ switch (pKbd->layout) {
+ case 11: /* type4, Sweden */
+ (void) strcat (names->geometry, "sun(type4_se)");
+ (void) strcat (names->keycodes,
+ "sun(type4_se_swapctl)");
+ (void) strcat (names->symbols,
+ "sun/se(sun4)+se(fixdollar)");
+ return;
+ break;
+ case 43: /* type5/5c, Sweden */
+ (void) strcat (names->geometry, "sun(type5c_se)");
+ (void) strcat (names->keycodes, "sun(type5_se)");
+ (void) strcat (names->symbols,
+ "sun/se(sun5)+se(fixdollar)");
+ return;
+ break;
+ case 90: /* "Compact 1", Sweden (???) */
+ break; /* No specific mapping, yet */
+ default:
+ break;
+ }
+
+ if (pKbd->layout == 19) {
+ (void) strcat (names->keycodes, "sun(US101A)");
+ (void) strcat (names->geometry, "pc101-NG"); /* XXX */
+ (void) strcat (names->symbols, "us(pc101)");
+ } else if (pKbd->layout < 33) {
+ (void) strcat (names->keycodes, "sun(type4)");
+ (void) strcat (names->geometry, "sun(type4)");
+ if (sunSwapLkeys)
+ (void) strcat (names->symbols, "sun/us(sun4ol)");
+ else
+ (void) strcat (names->symbols, "sun/us(sun4)");
+ } else {
+ (void) strcat (names->keycodes, "sun(type5)");
+
+ switch (pKbd->layout) {
+ case 33: case 80: /* U.S. */
+ case 47: case 94: /* Korea */
+ case 48: case 95: /* Taiwan */
+ case 49: case 96: /* Japan */
+ (void) strcat (names->geometry, "sun(type5)");
+ break;
+ case 34: case 81: /* U.S. Unix */
+ (void) strcat (names->geometry, "sun(type5unix)");
+ break;
+ default:
+ (void) strcat (names->geometry, "sun(type5euro)");
+ }
+
+ if (sunSwapLkeys)
+ (void) strcat (names->symbols, "sun/us(sun5ol)");
+ else
+ (void) strcat (names->symbols, "sun/us(sun5)");
+ }
+ break;
+ default:
+ names->keycodes = names->geometry = NULL;
+ break;
+ }
+
+ /* extra symbols */
+
+ if (pKbd->type == KB_SUN4) {
+ switch (pKbd->layout) {
+ case 4: case 36: case 83:
+ case 5: case 37: case 84:
+ case 6: case 38: case 85:
+ case 8: case 40: case 87:
+ case 9: case 41: case 88:
+ case 10: case 42: case 89:
+/* case 11: case 43: case 90: */ /* handled earlier */
+ case 12: case 44: case 91:
+ case 13: case 45: case 92:
+ case 14: case 46: case 93:
+ (void) strcat (names->symbols, "+iso9995-3(basic)"); break;
+ }
+ }
+
+ if (pKbd->type == KB_SUN4) {
+ switch (pKbd->layout) {
+ case 0: case 1: case 33: case 34: case 80: case 81:
+ break;
+ case 3:
+ (void) strcat (names->symbols, "+ca"); break;
+ case 4: case 36: case 83:
+ (void) strcat (names->symbols, "+dk"); break;
+ case 5: case 37: case 84:
+ (void) strcat (names->symbols, "+de"); break;
+ case 6: case 38: case 85:
+ (void) strcat (names->symbols, "+it"); break;
+ case 8: case 40: case 87:
+ (void) strcat (names->symbols, "+no"); break;
+ case 9: case 41: case 88:
+ (void) strcat (names->symbols, "+pt"); break;
+ case 10: case 42: case 89:
+ (void) strcat (names->symbols, "+es"); break;
+ /* case 11: case 43: */ /* handled earlier */
+ case 90:
+ (void) strcat (names->symbols, "+se"); break;
+ case 12: case 44: case 91:
+ (void) strcat (names->symbols, "+fr_CH"); break;
+ case 13: case 45: case 92:
+ (void) strcat (names->symbols, "+de_CH"); break;
+ case 14: case 46: case 93:
+ (void) strcat (names->symbols, "+gb"); break; /* s/b en_UK */
+ case 52:
+ (void) strcat (names->symbols, "+pl"); break;
+ case 53:
+ (void) strcat (names->symbols, "+cs"); break;
+ case 54:
+ (void) strcat (names->symbols, "+ru"); break;
+#if 0
+ /* don't have symbols defined for these yet, let them default */
+ case 2:
+ (void) strcat (names->symbols, "+fr_BE"); break;
+ case 7: case 39: case 86:
+ (void) strcat (names->symbols, "+nl"); break;
+ case 50: case 97:
+ (void) strcat (names->symbols, "+fr_CA"); break;
+ case 16: case 47: case 94:
+ (void) strcat (names->symbols, "+ko"); break;
+ case 17: case 48: case 95:
+ (void) strcat (names->symbols, "+tw"); break;
+ case 32: case 49: case 96:
+ (void) strcat (names->symbols, "+jp"); break;
+ case 51:
+ (void) strcat (names->symbols, "+hu"); break;
+#endif
+ /*
+ * by setting the symbols to NULL XKB will use the symbols in
+ * the "default" keymap.
+ */
+ default:
+ names->symbols = NULL; return; break;
+ }
+ }
+}
+#endif /* XKB */
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunKbdProc --
+ * Handle the initialization, etc. of a keyboard.
+ *
+ * Results:
+ * None.
+ *
+ *-----------------------------------------------------------------------
+ */
+
+int sunKbdProc (
+ DeviceIntPtr device,
+ int what)
+{
+ int i;
+ DevicePtr pKeyboard = (DevicePtr) device;
+ sunKbdPrivPtr pPriv;
+ KeybdCtrl* ctrl = &device->kbdfeed->ctrl;
+ extern int XkbDfltRepeatDelay, XkbDfltRepeatInterval;
+
+ static CARD8 *workingModMap = NULL;
+ static KeySymsRec *workingKeySyms;
+
+ switch (what) {
+ case DEVICE_INIT:
+ if (pKeyboard != LookupKeyboardDevice()) {
+ ErrorF ("Cannot open non-system keyboard\n");
+ return (!Success);
+ }
+
+ if (!workingKeySyms) {
+ workingKeySyms = &sunKeySyms[sunKbdPriv.type];
+
+ if (sunKbdPriv.type == KB_SUN4 && sunSwapLkeys)
+ SwapLKeys(workingKeySyms);
+
+ if (workingKeySyms->minKeyCode < MIN_KEYCODE) {
+ workingKeySyms->minKeyCode += MIN_KEYCODE;
+ workingKeySyms->maxKeyCode += MIN_KEYCODE;
+ }
+ if (workingKeySyms->maxKeyCode > MAX_KEYCODE)
+ workingKeySyms->maxKeyCode = MAX_KEYCODE;
+ }
+
+ if (!workingModMap) {
+ workingModMap=(CARD8 *)xalloc(MAP_LENGTH);
+ (void) memset(workingModMap, 0, MAP_LENGTH);
+ for(i=0; sunModMaps[sunKbdPriv.type][i].key != 0; i++)
+ workingModMap[sunModMaps[sunKbdPriv.type][i].key + MIN_KEYCODE] =
+ sunModMaps[sunKbdPriv.type][i].modifiers;
+ }
+
+ (void) memset ((void *) defaultKeyboardControl.autoRepeats,
+ ~0, sizeof defaultKeyboardControl.autoRepeats);
+
+#ifdef XKB
+ if (noXkbExtension) {
+ sunAutoRepeatInitiate = XkbDfltRepeatDelay * 1000;
+ sunAutoRepeatDelay = XkbDfltRepeatInterval * 1000;
+#endif
+ autoRepeatKeyDown = 0;
+#ifdef XKB
+ }
+#endif
+ pKeyboard->devicePrivate = (pointer)&sunKbdPriv;
+ pKeyboard->on = FALSE;
+
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ InitKeyboardDeviceStruct(pKeyboard,
+ workingKeySyms, workingModMap,
+ sunBell, sunKbdCtrl);
+#ifdef XKB
+ } else {
+ XkbComponentNamesRec names;
+ sunInitKbdNames (&names, &sunKbdPriv);
+ XkbInitKeyboardDeviceStruct((DeviceIntPtr) pKeyboard, &names,
+ workingKeySyms, workingModMap,
+ sunBell, sunKbdCtrl);
+ }
+#endif
+ break;
+
+ case DEVICE_ON:
+ pPriv = (sunKbdPrivPtr)pKeyboard->devicePrivate;
+ /*
+ * Set the keyboard into "direct" mode and turn on
+ * event translation.
+ */
+ if (sunChangeKbdTranslation(pPriv->fd,TRUE) == -1)
+ FatalError("Can't set keyboard translation\n");
+ AddEnabledDevice(pPriv->fd);
+ pKeyboard->on = TRUE;
+ break;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ pPriv = (sunKbdPrivPtr)pKeyboard->devicePrivate;
+ if (pPriv->type == KB_SUN4) {
+ /* dumb bug in Sun's keyboard! Turn off LEDS before resetting */
+ pPriv->leds = 0;
+ ctrl->leds = 0;
+ SetLights(ctrl, pPriv->fd);
+ }
+ /*
+ * Restore original keyboard directness and translation.
+ */
+ if (sunChangeKbdTranslation(pPriv->fd,FALSE) == -1)
+ FatalError("Can't reset keyboard translation\n");
+ RemoveEnabledDevice(pPriv->fd);
+ pKeyboard->on = FALSE;
+ break;
+ default:
+ FatalError("Unknown keyboard operation\n");
+ }
+ return Success;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunKbdGetEvents --
+ * Return the events waiting in the wings for the given keyboard.
+ *
+ * Results:
+ * A pointer to an array of Firm_events or (Firm_event *)0 if no events
+ * The number of events contained in the array.
+ * A boolean as to whether more events might be available.
+ *
+ * Side Effects:
+ * None.
+ *-----------------------------------------------------------------------
+ */
+
+Firm_event* sunKbdGetEvents (
+ int fd,
+ Bool on,
+ int* pNumEvents,
+ Bool* pAgain)
+{
+ int nBytes; /* number of bytes of events available. */
+ static Firm_event evBuf[MAXEVENTS]; /* Buffer for Firm_events */
+
+ if ((nBytes = read (fd, evBuf, sizeof(evBuf))) == -1) {
+ if (errno == EWOULDBLOCK) {
+ *pNumEvents = 0;
+ *pAgain = FALSE;
+ } else {
+ Error ("Reading keyboard");
+ FatalError ("Could not read the keyboard");
+ }
+ } else {
+ if (on) {
+ *pNumEvents = nBytes / sizeof (Firm_event);
+ *pAgain = (nBytes == sizeof (evBuf));
+ } else {
+ *pNumEvents = 0;
+ *pAgain = FALSE;
+ }
+ }
+ return evBuf;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunKbdEnqueueEvent --
+ *
+ *-----------------------------------------------------------------------
+ */
+static xEvent autoRepeatEvent;
+static int composeCount;
+
+static Bool DoSpecialKeys(device, xE, fe)
+ DeviceIntPtr device;
+ xEvent* xE;
+ Firm_event* fe;
+{
+ int shift_index, map_index, bit;
+ KeySym ksym;
+ BYTE* kptr;
+ sunKbdPrivPtr pPriv = (sunKbdPrivPtr)device->public.devicePrivate;
+ BYTE keycode = xE->u.u.detail;
+ CARD8 keyModifiers = device->key->modifierMap[keycode];
+
+ /* look up the present idea of the keysym */
+ shift_index = 0;
+ if (device->key->state & ShiftMask)
+ shift_index ^= 1;
+ if (device->key->state & LockMask)
+ shift_index ^= 1;
+ map_index = (fe->id - 1) * device->key->curKeySyms.mapWidth;
+ ksym = device->key->curKeySyms.map[shift_index + map_index];
+ if (ksym == NoSymbol)
+ ksym = device->key->curKeySyms.map[map_index];
+
+ /*
+ * Toggle functionality is hardcoded. This is achieved by always
+ * discarding KeyReleases on these keys, and converting every other
+ * KeyPress into a KeyRelease.
+ */
+ if (xE->u.u.type == KeyRelease
+ && (ksym == XK_Num_Lock
+ || ksym == XK_Scroll_Lock
+ || ksym == SunXK_Compose
+ || (keyModifiers & LockMask)))
+ return TRUE;
+
+ kptr = &device->key->down[keycode >> 3];
+ bit = 1 << (keycode & 7);
+ if ((*kptr & bit) &&
+ (ksym == XK_Num_Lock || ksym == XK_Scroll_Lock ||
+ ksym == SunXK_Compose || (keyModifiers & LockMask)))
+ xE->u.u.type = KeyRelease;
+
+ if (pPriv->type == KB_SUN4) {
+ if (ksym == XK_Num_Lock) {
+ ModLight (device, xE->u.u.type == KeyPress, XLED_NUM_LOCK);
+ } else if (ksym == XK_Scroll_Lock) {
+ ModLight (device, xE->u.u.type == KeyPress, XLED_SCROLL_LOCK);
+ } else if (ksym == SunXK_Compose) {
+ ModLight (device, xE->u.u.type == KeyPress, XLED_COMPOSE);
+ if (xE->u.u.type == KeyPress) composeCount = 2;
+ else composeCount = 0;
+ } else if (keyModifiers & LockMask) {
+ ModLight (device, xE->u.u.type == KeyPress, XLED_CAPS_LOCK);
+ }
+ if (xE->u.u.type == KeyRelease) {
+ if (composeCount > 0 && --composeCount == 0) {
+ pseudoKey(device, FALSE,
+ LookupKeyCode(SunXK_Compose, &device->key->curKeySyms));
+ ModLight (device, FALSE, XLED_COMPOSE);
+ }
+ }
+ }
+
+ if ((xE->u.u.type == KeyPress) && (keyModifiers == 0)) {
+ /* initialize new AutoRepeater event & mark AutoRepeater on */
+ autoRepeatEvent = *xE;
+ autoRepeatFirst = TRUE;
+ autoRepeatKeyDown++;
+ autoRepeatLastKeyDownTv = fe->time;
+ }
+ return FALSE;
+}
+
+void sunKbdEnqueueEvent (
+ DeviceIntPtr device,
+ Firm_event *fe)
+{
+ xEvent xE;
+ BYTE keycode;
+ CARD8 keyModifiers;
+
+ keycode = (fe->id & 0x7f) + MIN_KEYCODE;
+
+ keyModifiers = device->key->modifierMap[keycode];
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ if (autoRepeatKeyDown && (keyModifiers == 0) &&
+ ((fe->value == VKEY_DOWN) || (keycode == autoRepeatEvent.u.u.detail))) {
+ /*
+ * Kill AutoRepeater on any real non-modifier key down, or auto key up
+ */
+ autoRepeatKeyDown = 0;
+ }
+#ifdef XKB
+ }
+#endif
+ xE.u.keyButtonPointer.time = TVTOMILLI(fe->time);
+ xE.u.u.type = ((fe->value == VKEY_UP) ? KeyRelease : KeyPress);
+ xE.u.u.detail = keycode;
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ if (DoSpecialKeys(device, &xE, fe))
+ return;
+#ifdef XKB
+ }
+#endif /* ! XKB */
+ mieqEnqueue (&xE);
+}
+
+void sunEnqueueAutoRepeat ()
+{
+ int delta;
+ int i, mask;
+ DeviceIntPtr device = (DeviceIntPtr)LookupKeyboardDevice();
+ KeybdCtrl* ctrl = &device->kbdfeed->ctrl;
+ sunKbdPrivPtr pPriv = (sunKbdPrivPtr) device->public.devicePrivate;
+
+ if (ctrl->autoRepeat != AutoRepeatModeOn) {
+ autoRepeatKeyDown = 0;
+ return;
+ }
+ i=(autoRepeatEvent.u.u.detail >> 3);
+ mask=(1 << (autoRepeatEvent.u.u.detail & 7));
+ if (!(ctrl->autoRepeats[i] & mask)) {
+ autoRepeatKeyDown = 0;
+ return;
+ }
+
+ /*
+ * Generate auto repeat event. XXX one for now.
+ * Update time & pointer location of saved KeyPress event.
+ */
+
+ delta = TVTOMILLI(autoRepeatDeltaTv);
+ autoRepeatFirst = FALSE;
+
+ /*
+ * Fake a key up event and a key down event
+ * for the last key pressed.
+ */
+ autoRepeatEvent.u.keyButtonPointer.time += delta;
+ autoRepeatEvent.u.u.type = KeyRelease;
+
+ /*
+ * hold off any more inputs while we get these safely queued up
+ * further SIGIO are
+ */
+ sunEnqueueEvent (&autoRepeatEvent);
+ autoRepeatEvent.u.u.type = KeyPress;
+ sunEnqueueEvent (&autoRepeatEvent);
+ if (ctrl->click) bell (pPriv->fd, 0);
+
+ /* Update time of last key down */
+ tvplus(autoRepeatLastKeyDownTv, autoRepeatLastKeyDownTv,
+ autoRepeatDeltaTv);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunChangeKbdTranslation
+ * Makes operating system calls to set keyboard translation
+ * and direction on or off.
+ *
+ * Results:
+ * -1 if failure, else 0.
+ *
+ * Side Effects:
+ * Changes kernel management of keyboard.
+ *
+ *-----------------------------------------------------------------------
+ */
+int sunChangeKbdTranslation(
+ int fd,
+ Bool makeTranslated)
+
+{
+ int tmp;
+#ifndef i386 /* { */
+ sigset_t hold_mask, old_mask;
+#else /* }{ */
+ int old_mask;
+#endif /* } */
+ int toread;
+ char junk[8192];
+
+#ifndef i386 /* { */
+ (void) sigfillset(&hold_mask);
+ (void) sigprocmask(SIG_BLOCK, &hold_mask, &old_mask);
+#else /* }{ */
+ old_mask = sigblock (~0);
+#endif /* } */
+ sunKbdWait();
+ if (makeTranslated) {
+ /*
+ * Next set the keyboard into "direct" mode and turn on
+ * event translation. If either of these fails, we can't go
+ * on.
+ */
+ tmp = 1;
+ if (ioctl (fd, KIOCSDIRECT, &tmp) == -1) {
+ Error ("Setting keyboard direct mode");
+ return -1;
+ }
+ tmp = TR_UNTRANS_EVENT;
+ if (ioctl (fd, KIOCTRANS, &tmp) == -1) {
+ Error ("Setting keyboard translation");
+ ErrorF ("sunChangeKbdTranslation: kbdFd=%d\n", fd);
+ return -1;
+ }
+ } else {
+ /*
+ * Next set the keyboard into "indirect" mode and turn off
+ * event translation.
+ */
+ tmp = 0;
+ (void)ioctl (fd, KIOCSDIRECT, &tmp);
+ tmp = TR_ASCII;
+ (void)ioctl (fd, KIOCTRANS, &tmp);
+ }
+ if (ioctl (fd, FIONREAD, &toread) != -1 && toread > 0) {
+ while (toread) {
+ tmp = toread;
+ if (toread > sizeof (junk))
+ tmp = sizeof (junk);
+ (void) read (fd, junk, tmp);
+ toread -= tmp;
+ }
+ }
+#ifndef i386 /* { */
+ (void) sigprocmask(SIG_SETMASK, &old_mask, (sigset_t *)NULL);
+#else /* }{ */
+ sigsetmask (old_mask);
+#endif /* } */
+ return 0;
+}
+
+/*ARGSUSED*/
+Bool LegalModifier(key, pDev)
+ unsigned int key;
+ DevicePtr pDev;
+{
+ return TRUE;
+}
+
+/*ARGSUSED*/
+void sunBlockHandler(nscreen, pbdata, pptv, pReadmask)
+ int nscreen;
+ pointer pbdata;
+ struct timeval **pptv;
+ pointer pReadmask;
+{
+ KeybdCtrl* ctrl = &((DeviceIntPtr)LookupKeyboardDevice())->kbdfeed->ctrl;
+ static struct timeval artv = { 0, 0 }; /* autorepeat timeval */
+
+ if (!autoRepeatKeyDown)
+ return;
+
+ if (ctrl->autoRepeat != AutoRepeatModeOn)
+ return;
+
+ if (autoRepeatFirst == TRUE)
+ artv.tv_usec = sunAutoRepeatInitiate;
+ else
+ artv.tv_usec = sunAutoRepeatDelay;
+ *pptv = &artv;
+
+}
+
+/*ARGSUSED*/
+void sunWakeupHandler(nscreen, pbdata, err, pReadmask)
+ int nscreen;
+ pointer pbdata;
+ unsigned long err;
+ pointer pReadmask;
+{
+ KeybdCtrl* ctrl = &((DeviceIntPtr)LookupKeyboardDevice())->kbdfeed->ctrl;
+ struct timeval tv;
+
+ if (ctrl->autoRepeat != AutoRepeatModeOn)
+ return;
+
+ if (autoRepeatKeyDown) {
+ X_GETTIMEOFDAY(&tv);
+ tvminus(autoRepeatDeltaTv, tv, autoRepeatLastKeyDownTv);
+ if (autoRepeatDeltaTv.tv_sec > 0 ||
+ (!autoRepeatFirst && autoRepeatDeltaTv.tv_usec >
+ sunAutoRepeatDelay) ||
+ (autoRepeatDeltaTv.tv_usec >
+ sunAutoRepeatInitiate))
+ autoRepeatReady++;
+ }
+
+ if (autoRepeatReady)
+ {
+ sunEnqueueAutoRepeat ();
+ autoRepeatReady = 0;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/sun/sunKeyMap.c b/nx-X11/programs/Xserver/hw/sun/sunKeyMap.c
new file mode 100644
index 000000000..33300fcb6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/sunKeyMap.c
@@ -0,0 +1,5797 @@
+/* $Xorg: sunKeyMap.c,v 1.3 2000/08/17 19:48:30 cpqbld Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/hw/sun/sunKeyMap.c,v 1.3 2001/01/17 22:36:50 dawes Exp $ */
+
+#include "sun.h"
+#define XK_KATAKANA
+#include "keysym.h"
+#include "Sunkeysym.h"
+
+/*
+ By default all keyboards are hardcoded on the theory that people
+ might remove /usr/openwin making it impossible to parse the files
+ in /usr/openwin/share/etc/keytables.
+*/
+#define CAN4
+#define CANFR5
+#define DEN4
+#define DEN5
+#define FR5
+#define FRBE4
+#define GER4
+#define GER5
+#define ITALY4
+#define ITALY5
+#define JAPAN4
+#define JAPAN5
+#define KOREA4
+#define KOREA5
+#define NETH4
+#define NETH5
+#define NORW4
+#define NORW5
+#define PORT4
+#define PORT5
+#define SPAIN5
+#define SPAINLATAM4
+#define SWED5
+#define SWEDFIN4
+#define SWFR4
+#define SWFR5
+#define SWGE4
+#define SWGE5
+#define TAI4
+#define TAI5
+#define UK4
+#define UK5
+#define US101A
+#define US2
+#define US3
+#define US4
+#define US5
+#define US_UNIX5
+
+/*
+ * XXX - Its not clear what to map these to for now.
+ * keysyms.h doesn't define enough function key names.
+ */
+
+#ifndef XK_L1
+#define XK_L1 XK_Cancel
+#define XK_L2 XK_Redo
+#define XK_R1 NoSymbol
+#define XK_R2 NoSymbol
+#define XK_R3 NoSymbol
+#define XK_L3 XK_Menu
+#define XK_L4 XK_Undo
+#define XK_R4 NoSymbol
+#define XK_R5 NoSymbol
+#define XK_R6 NoSymbol
+#define XK_L5 XK_Insert
+#define XK_L6 XK_Select
+#define XK_R7 NoSymbol
+#define XK_R8 XK_Up
+#define XK_R9 NoSymbol
+#define XK_L7 XK_Execute
+#define XK_L8 XK_Print
+#define XK_R10 XK_Left
+#define XK_R11 XK_Home
+#define XK_R12 XK_Right
+#define XK_L9 XK_Find
+#define XK_L10 XK_Help
+#define XK_R13 NoSymbol
+#define XK_R14 XK_Down
+#define XK_R15 NoSymbol
+#endif
+
+/* twm and Motif have hard-coded dependencies on Meta being Mod1 :-( */
+#if 0
+/* This set has optimal characteristics for use in the Toolkit... */
+#define Meta_Mask Mod1Mask
+#define Mode_switch_Mask Mod2Mask
+#define Num_Lock_Mask Mod3Mask
+#define Alt_Mask Mod4Mask
+#else
+/* but this set is compatible with what we shipped in R6. */
+#define Meta_Mask Mod1Mask
+#define Mode_switch_Mask Mod2Mask
+#define Alt_Mask Mod3Mask
+#define Num_Lock_Mask Mod4Mask
+#endif
+
+#ifdef US2
+
+static KeySym US2Keymap[] = {
+ XK_L1, NoSymbol, /* 0x1 */
+ NoSymbol, NoSymbol, /* 0x2 */
+ XK_L2, NoSymbol, /* 0x3 */
+ NoSymbol, NoSymbol, /* 0x4 */
+ XK_F1, NoSymbol, /* 0x5 */
+ XK_F2, NoSymbol, /* 0x6 */
+ NoSymbol, NoSymbol, /* 0x7 */
+ XK_F3, NoSymbol, /* 0x8 */
+ NoSymbol, NoSymbol, /* 0x9 */
+ XK_F4, NoSymbol, /* 0xa */
+ NoSymbol, NoSymbol, /* 0xb */
+ XK_F5, NoSymbol, /* 0xc */
+ NoSymbol, NoSymbol, /* 0xd */
+ XK_F6, NoSymbol, /* 0xe */
+ NoSymbol, NoSymbol, /* 0xf */
+ XK_F7, NoSymbol, /* 0x10 */
+ XK_F8, NoSymbol, /* 0x11 */
+ XK_F9, NoSymbol, /* 0x12 */
+ XK_Break, NoSymbol, /* 0x13 */
+ NoSymbol, NoSymbol, /* 0x14 */
+ XK_R1, NoSymbol, /* 0x15 */
+ XK_R2, NoSymbol, /* 0x16 */
+ XK_R3, NoSymbol, /* 0x17 */
+ NoSymbol, NoSymbol, /* 0x18 */
+ XK_L3, NoSymbol, /* 0x19 */
+ XK_L4, NoSymbol, /* 0x1a */
+ NoSymbol, NoSymbol, /* 0x1b */
+ NoSymbol, NoSymbol, /* 0x1c */
+ XK_Escape, NoSymbol, /* 0x1d */
+ XK_1, XK_exclam, /* 0x1e */
+ XK_2, XK_at, /* 0x1f */
+ XK_3, XK_numbersign, /* 0x20 */
+ XK_4, XK_dollar, /* 0x21 */
+ XK_5, XK_percent, /* 0x22 */
+ XK_6, XK_asciicircum, /* 0x23 */
+ XK_7, XK_ampersand, /* 0x24 */
+ XK_8, XK_asterisk, /* 0x25 */
+ XK_9, XK_parenleft, /* 0x26 */
+ XK_0, XK_parenright, /* 0x27 */
+ XK_minus, XK_underscore, /* 0x28 */
+ XK_equal, XK_plus, /* 0x29 */
+ XK_grave, XK_asciitilde, /* 0x2a */
+ XK_BackSpace, NoSymbol, /* 0x2b */
+ NoSymbol, NoSymbol, /* 0x2c */
+ XK_R4, NoSymbol, /* 0x2d */
+ XK_R5, NoSymbol, /* 0x2e */
+ XK_R6, NoSymbol, /* 0x2f */
+ NoSymbol, NoSymbol, /* 0x30 */
+ XK_L5, NoSymbol, /* 0x31 */
+ NoSymbol, NoSymbol, /* 0x32 */
+ XK_L6, NoSymbol, /* 0x33 */
+ NoSymbol, NoSymbol, /* 0x34 */
+ XK_Tab, NoSymbol, /* 0x35 */
+ XK_Q, NoSymbol, /* 0x36 */
+ XK_W, NoSymbol, /* 0x37 */
+ XK_E, NoSymbol, /* 0x38 */
+ XK_R, NoSymbol, /* 0x39 */
+ XK_T, NoSymbol, /* 0x3a */
+ XK_Y, NoSymbol, /* 0x3b */
+ XK_U, NoSymbol, /* 0x3c */
+ XK_I, NoSymbol, /* 0x3d */
+ XK_O, NoSymbol, /* 0x3e */
+ XK_P, NoSymbol, /* 0x3f */
+ XK_bracketleft, XK_braceleft, /* 0x40 */
+ XK_bracketright, XK_braceright, /* 0x41 */
+ XK_Delete, NoSymbol, /* 0x42 */
+ NoSymbol, NoSymbol, /* 0x43 */
+ XK_R7, NoSymbol, /* 0x44 */
+ XK_Up, XK_R8, /* 0x45 */
+ XK_R9, NoSymbol, /* 0x46 */
+ NoSymbol, NoSymbol, /* 0x47 */
+ XK_L7, NoSymbol, /* 0x48 */
+ XK_L8, NoSymbol, /* 0x49 */
+ NoSymbol, NoSymbol, /* 0x4a */
+ NoSymbol, NoSymbol, /* 0x4b */
+ XK_Control_L, NoSymbol, /* 0x4c */
+ XK_A, NoSymbol, /* 0x4d */
+ XK_S, NoSymbol, /* 0x4e */
+ XK_D, NoSymbol, /* 0x4f */
+ XK_F, NoSymbol, /* 0x50 */
+ XK_G, NoSymbol, /* 0x51 */
+ XK_H, NoSymbol, /* 0x52 */
+ XK_J, NoSymbol, /* 0x53 */
+ XK_K, NoSymbol, /* 0x54 */
+ XK_L, NoSymbol, /* 0x55 */
+ XK_semicolon, XK_colon, /* 0x56 */
+ XK_apostrophe, XK_quotedbl, /* 0x57 */
+ XK_backslash, XK_bar, /* 0x58 */
+ XK_Return, NoSymbol, /* 0x59 */
+ NoSymbol, NoSymbol, /* 0x5a */
+ XK_Left, XK_R10, /* 0x5b */
+ XK_R11, NoSymbol, /* 0x5c */
+ XK_Right, XK_R12, /* 0x5d */
+ NoSymbol, NoSymbol, /* 0x5e */
+ XK_L9, NoSymbol, /* 0x5f */
+ NoSymbol, NoSymbol, /* 0x60 */
+ XK_L10, NoSymbol, /* 0x61 */
+ NoSymbol, NoSymbol, /* 0x62 */
+ XK_Shift_L, NoSymbol, /* 0x63 */
+ XK_Z, NoSymbol, /* 0x64 */
+ XK_X, NoSymbol, /* 0x65 */
+ XK_C, NoSymbol, /* 0x66 */
+ XK_V, NoSymbol, /* 0x67 */
+ XK_B, NoSymbol, /* 0x68 */
+ XK_N, NoSymbol, /* 0x69 */
+ XK_M, NoSymbol, /* 0x6a */
+ XK_comma, XK_less, /* 0x6b */
+ XK_period, XK_greater, /* 0x6c */
+ XK_slash, XK_question, /* 0x6d */
+ XK_Shift_R, NoSymbol, /* 0x6e */
+ XK_Linefeed, NoSymbol, /* 0x6f */
+ XK_R13, NoSymbol, /* 0x70 */
+ XK_Down, XK_R14, /* 0x71 */
+ XK_R15, NoSymbol, /* 0x72 */
+ NoSymbol, NoSymbol, /* 0x73 */
+ NoSymbol, NoSymbol, /* 0x74 */
+ NoSymbol, NoSymbol, /* 0x75 */
+ NoSymbol, NoSymbol, /* 0x76 */
+ NoSymbol, NoSymbol, /* 0x77 */
+ XK_Meta_L, NoSymbol, /* 0x78 */
+ XK_space, NoSymbol, /* 0x79 */
+ XK_Meta_R, NoSymbol, /* 0x7a */
+ NoSymbol, NoSymbol, /* 0x7b */
+ NoSymbol, NoSymbol, /* 0x7c */
+ NoSymbol, NoSymbol, /* 0x7d */
+ NoSymbol, NoSymbol, /* 0x7e */
+ NoSymbol, NoSymbol, /* 0x7f */
+};
+
+static SunModmapRec US2Modmap[] = {
+ { 99, ShiftMask },
+ { 110, ShiftMask },
+ { 76, ControlMask },
+ { 120, Meta_Mask },
+ { 122, Meta_Mask },
+ { 0, 0 }
+};
+
+#else
+
+#define US2Keymap NULL
+#define US2Modmap NULL
+
+#endif /* US2 */
+
+#ifdef US3
+
+static KeySym US3Keymap[] = {
+ XK_L1, NoSymbol, /* 0x1 */
+ NoSymbol, NoSymbol, /* 0x2 */
+ XK_L2, NoSymbol, /* 0x3 */
+ NoSymbol, NoSymbol, /* 0x4 */
+ XK_F1, NoSymbol, /* 0x5 */
+ XK_F2, NoSymbol, /* 0x6 */
+ NoSymbol, NoSymbol, /* 0x7 */
+ XK_F3, NoSymbol, /* 0x8 */
+ NoSymbol, NoSymbol, /* 0x9 */
+ XK_F4, NoSymbol, /* 0xa */
+ NoSymbol, NoSymbol, /* 0xb */
+ XK_F5, NoSymbol, /* 0xc */
+ NoSymbol, NoSymbol, /* 0xd */
+ XK_F6, NoSymbol, /* 0xe */
+ NoSymbol, NoSymbol, /* 0xf */
+ XK_F7, NoSymbol, /* 0x10 */
+ XK_F8, NoSymbol, /* 0x11 */
+ XK_F9, NoSymbol, /* 0x12 */
+ XK_Alt_R, NoSymbol, /* 0x13 */
+ NoSymbol, NoSymbol, /* 0x14 */
+ XK_R1, NoSymbol, /* 0x15 */
+ XK_R2, NoSymbol, /* 0x16 */
+ XK_R3, NoSymbol, /* 0x17 */
+ NoSymbol, NoSymbol, /* 0x18 */
+ XK_L3, NoSymbol, /* 0x19 */
+ XK_L4, NoSymbol, /* 0x1a */
+ NoSymbol, NoSymbol, /* 0x1b */
+ NoSymbol, NoSymbol, /* 0x1c */
+ XK_Escape, NoSymbol, /* 0x1d */
+ XK_1, XK_exclam, /* 0x1e */
+ XK_2, XK_at, /* 0x1f */
+ XK_3, XK_numbersign, /* 0x20 */
+ XK_4, XK_dollar, /* 0x21 */
+ XK_5, XK_percent, /* 0x22 */
+ XK_6, XK_asciicircum, /* 0x23 */
+ XK_7, XK_ampersand, /* 0x24 */
+ XK_8, XK_asterisk, /* 0x25 */
+ XK_9, XK_parenleft, /* 0x26 */
+ XK_0, XK_parenright, /* 0x27 */
+ XK_minus, XK_underscore, /* 0x28 */
+ XK_equal, XK_plus, /* 0x29 */
+ XK_grave, XK_asciitilde, /* 0x2a */
+ XK_BackSpace, NoSymbol, /* 0x2b */
+ NoSymbol, NoSymbol, /* 0x2c */
+ XK_R4, NoSymbol, /* 0x2d */
+ XK_R5, NoSymbol, /* 0x2e */
+ XK_R6, NoSymbol, /* 0x2f */
+ NoSymbol, NoSymbol, /* 0x30 */
+ XK_L5, NoSymbol, /* 0x31 */
+ NoSymbol, NoSymbol, /* 0x32 */
+ XK_L6, NoSymbol, /* 0x33 */
+ NoSymbol, NoSymbol, /* 0x34 */
+ XK_Tab, NoSymbol, /* 0x35 */
+ XK_Q, NoSymbol, /* 0x36 */
+ XK_W, NoSymbol, /* 0x37 */
+ XK_E, NoSymbol, /* 0x38 */
+ XK_R, NoSymbol, /* 0x39 */
+ XK_T, NoSymbol, /* 0x3a */
+ XK_Y, NoSymbol, /* 0x3b */
+ XK_U, NoSymbol, /* 0x3c */
+ XK_I, NoSymbol, /* 0x3d */
+ XK_O, NoSymbol, /* 0x3e */
+ XK_P, NoSymbol, /* 0x3f */
+ XK_bracketleft, XK_braceleft, /* 0x40 */
+ XK_bracketright, XK_braceright, /* 0x41 */
+ XK_Delete, NoSymbol, /* 0x42 */
+ NoSymbol, NoSymbol, /* 0x43 */
+ XK_R7, NoSymbol, /* 0x44 */
+ XK_Up, XK_R8, /* 0x45 */
+ XK_R9, NoSymbol, /* 0x46 */
+ NoSymbol, NoSymbol, /* 0x47 */
+ XK_L7, NoSymbol, /* 0x48 */
+ XK_L8, NoSymbol, /* 0x49 */
+ NoSymbol, NoSymbol, /* 0x4a */
+ NoSymbol, NoSymbol, /* 0x4b */
+ XK_Control_L, NoSymbol, /* 0x4c */
+ XK_A, NoSymbol, /* 0x4d */
+ XK_S, NoSymbol, /* 0x4e */
+ XK_D, NoSymbol, /* 0x4f */
+ XK_F, NoSymbol, /* 0x50 */
+ XK_G, NoSymbol, /* 0x51 */
+ XK_H, NoSymbol, /* 0x52 */
+ XK_J, NoSymbol, /* 0x53 */
+ XK_K, NoSymbol, /* 0x54 */
+ XK_L, NoSymbol, /* 0x55 */
+ XK_semicolon, XK_colon, /* 0x56 */
+ XK_apostrophe, XK_quotedbl, /* 0x57 */
+ XK_backslash, XK_bar, /* 0x58 */
+ XK_Return, NoSymbol, /* 0x59 */
+ NoSymbol, NoSymbol, /* 0x5a */
+ XK_Left, XK_R10, /* 0x5b */
+ XK_R11, NoSymbol, /* 0x5c */
+ XK_Right, XK_R12, /* 0x5d */
+ NoSymbol, NoSymbol, /* 0x5e */
+ XK_L9, NoSymbol, /* 0x5f */
+ NoSymbol, NoSymbol, /* 0x60 */
+ XK_L10, NoSymbol, /* 0x61 */
+ NoSymbol, NoSymbol, /* 0x62 */
+ XK_Shift_L, NoSymbol, /* 0x63 */
+ XK_Z, NoSymbol, /* 0x64 */
+ XK_X, NoSymbol, /* 0x65 */
+ XK_C, NoSymbol, /* 0x66 */
+ XK_V, NoSymbol, /* 0x67 */
+ XK_B, NoSymbol, /* 0x68 */
+ XK_N, NoSymbol, /* 0x69 */
+ XK_M, NoSymbol, /* 0x6a */
+ XK_comma, XK_less, /* 0x6b */
+ XK_period, XK_greater, /* 0x6c */
+ XK_slash, XK_question, /* 0x6d */
+ XK_Shift_R, NoSymbol, /* 0x6e */
+ XK_Linefeed, NoSymbol, /* 0x6f */
+ XK_R13, NoSymbol, /* 0x70 */
+ XK_Down, XK_R14, /* 0x71 */
+ XK_R15, NoSymbol, /* 0x72 */
+ NoSymbol, NoSymbol, /* 0x73 */
+ NoSymbol, NoSymbol, /* 0x74 */
+ NoSymbol, NoSymbol, /* 0x75 */
+ NoSymbol, NoSymbol, /* 0x76 */
+ XK_Caps_Lock, NoSymbol, /* 0x77 */
+ XK_Meta_L, NoSymbol, /* 0x78 */
+ XK_space, NoSymbol, /* 0x79 */
+ XK_Meta_R, NoSymbol, /* 0x7a */
+ NoSymbol, NoSymbol, /* 0x7b */
+ NoSymbol, NoSymbol, /* 0x7c */
+ NoSymbol, NoSymbol, /* 0x7d */
+ NoSymbol, NoSymbol, /* 0x7e */
+ NoSymbol, NoSymbol, /* 0x7f */
+};
+
+static SunModmapRec US3Modmap[] = {
+ { 99, ShiftMask },
+ { 110, ShiftMask },
+ { 76, ControlMask },
+ { 119, LockMask },
+ { 120, Meta_Mask },
+ { 122, Meta_Mask },
+ { 0, 0 }
+};
+
+#else
+
+#define US3Keymap NULL
+#define US3Modmap NULL
+
+#endif /* US3 */
+
+KeySymsRec sunKeySyms[] = {
+ /* map minKeyCode maxKC width */
+ { (KeySym *)NULL, 0, 0, 0 },
+ { (KeySym *)NULL, 0, 0, 0 },
+ { US2Keymap, 1, 0x7a, 2 },
+ { US3Keymap, 1, 0x7a, 2 },
+ { (KeySym *)NULL, 1, 0x7d, 4 }
+};
+
+SunModmapRec *sunModMaps[] = {
+ NULL,
+ NULL,
+ US2Modmap,
+ US3Modmap,
+ NULL
+};
+
+static SunModmapRec Generic5Modmap[] = {
+ { 99, ShiftMask },
+ { 110, ShiftMask },
+ { 119, LockMask },
+ { 76, ControlMask },
+ { 120, Meta_Mask },
+ { 122, Meta_Mask },
+ { 13, Mode_switch_Mask },
+ { 98, Num_Lock_Mask },
+ { 19, Alt_Mask },
+ { 0, 0}
+};
+
+#if defined(DEN4) || defined(SWEDFIN4) || defined(SWFR4) || defined(SWGE4)
+
+static SunModmapRec DenSwedFinSw4Modmap[] = {
+ { 99, ShiftMask },
+ { 110, ShiftMask },
+ { 76, LockMask },
+ { 119, ControlMask },
+ { 120, Meta_Mask },
+ { 122, Meta_Mask },
+ { 67, Mode_switch_Mask },
+ { 98, Num_Lock_Mask },
+ { 19, Alt_Mask },
+ { 0, 0 }
+};
+
+#endif
+
+#if defined(FRBE4) || defined(NETH4)
+
+static SunModmapRec FrBeNeth4Modmap[] = {
+ { 99, ShiftMask },
+ { 110, ShiftMask },
+ { 13, LockMask },
+ { 76, ControlMask },
+ { 120, Meta_Mask },
+ { 122, Meta_Mask },
+ { 119, Mode_switch_Mask },
+ { 98, Num_Lock_Mask },
+ { 19, Alt_Mask },
+ { 0, 0 }
+};
+
+#endif
+
+#if defined(ITALY4) || defined(NORW4) || defined(PORT4) || defined(SPAINLATAM4)
+
+static SunModmapRec ItNorPortSp4Modmap[] = {
+ { 99, ShiftMask },
+ { 110, ShiftMask },
+ { 76, LockMask },
+ { 119, ControlMask },
+ { 120, Meta_Mask },
+ { 122, Meta_Mask },
+ { 13, Mode_switch_Mask },
+ { 98, Num_Lock_Mask },
+ { 19, Alt_Mask },
+ { 0, 0 }
+};
+
+#endif
+
+#ifdef CAN4
+
+static KeySym Canada4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 9*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 11*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ XK_Control_R, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_R1, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_R2, NoSymbol, /* 22*/
+ XK_Break, XK_Scroll_Lock, XK_R3, NoSymbol, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_degree, NoSymbol, XK_notsign, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_at, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, NoSymbol, NoSymbol, /* 32*/
+ XK_4, XK_dollar, NoSymbol, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_question, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_ampersand, XK_braceleft, NoSymbol, /* 36*/
+ XK_8, XK_asterisk, XK_bracketleft, NoSymbol, /* 37*/
+ XK_9, XK_parenleft, XK_bracketright,NoSymbol, /* 38*/
+ XK_0, XK_parenright, XK_braceright, NoSymbol, /* 39*/
+ XK_minus, XK_underscore, XK_bar, NoSymbol, /* 40*/
+ XK_equal, XK_plus, NoSymbol, NoSymbol, /* 41*/
+ XK_Agrave, NoSymbol, XK_grave, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, XK_KP_Equal, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, XK_KP_Divide, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, XK_KP_Multiply, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ SunXK_FA_Circum,SunXK_FA_Diaeresis,XK_asciicircum,NoSymbol, /* 64*/
+ XK_Ccedilla, NoSymbol, XK_asciitilde, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R9, XK_Prior, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_semicolon, XK_colon, NoSymbol, NoSymbol, /* 86*/
+ XK_Egrave, NoSymbol, NoSymbol, NoSymbol, /* 87*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R10, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R11, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R12, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, XK_guillemotleft,NoSymbol, /*100*/
+ XK_X, NoSymbol, XK_guillemotright,NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_apostrophe, XK_less, NoSymbol, /*107*/
+ XK_period, NoSymbol, XK_greater, NoSymbol, /*108*/
+ XK_Eacute, NoSymbol, XK_slash, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_Ugrave, NoSymbol, XK_backslash, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+static SunModmapRec Canada4Modmap[] = {
+ { 99, ShiftMask },
+ { 110, ShiftMask },
+ { 76, LockMask },
+ { 13, ControlMask },
+ { 120, Meta_Mask },
+ { 122, Meta_Mask },
+ { 119, Mode_switch_Mask },
+ { 98, Num_Lock_Mask },
+ { 19, Alt_Mask },
+ { 0, 0}
+};
+
+#else
+
+#define Canada4Keymap NULL
+#define Canada4Modmap NULL
+
+#endif /* CANADA4 */
+
+#ifdef CANFR5
+
+static KeySym CanadaFr5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, XK_Break, XK_R1, XK_R1, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, XK_R3, XK_R3, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, XK_plusminus, NoSymbol, /* 30*/
+ XK_2, XK_at, NoSymbol, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, XK_sterling, NoSymbol, /* 32*/
+ XK_4, XK_dollar, XK_cent, NoSymbol, /* 33*/
+ XK_5, XK_percent, XK_currency, NoSymbol, /* 34*/
+ XK_6, XK_question, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_ampersand, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_asterisk, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenleft, XK_bracketleft, NoSymbol, /* 38*/
+ XK_0, XK_parenright, XK_bracketright,NoSymbol, /* 39*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /* 40*/
+ XK_equal, XK_plus, XK_notsign, NoSymbol, /* 41*/
+ XK_slash, XK_backslash, XK_bar, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, XK_R5, XK_R5, /* 46*/
+ XK_KP_Multiply, NoSymbol, XK_R6, XK_R6, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift,NoSymbol,NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, XK_paragraph, NoSymbol, /* 63*/
+ SunXK_FA_Circum,SunXK_FA_Diaeresis,SunXK_FA_Grave,NoSymbol, /* 64*/
+ XK_Ccedilla, NoSymbol, XK_asciitilde, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, XK_R4, XK_R4, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_semicolon, XK_colon, XK_degree, NoSymbol, /* 86*/
+ XK_Egrave, NoSymbol, NoSymbol, NoSymbol, /* 87*/
+ XK_Agrave, NoSymbol, NoSymbol, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, XK_guillemotleft,NoSymbol, /*100*/
+ XK_X, NoSymbol, XK_guillemotright,NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, XK_mu, NoSymbol, /*106*/
+ XK_comma, XK_quoteright, XK_less, NoSymbol, /*107*/
+ XK_period, XK_quotedbl, XK_greater, NoSymbol, /*108*/
+ XK_Eacute, NoSymbol, XK_quoteleft, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_Uacute, NoSymbol, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define CanadaFr5Modmap Generic5Modmap
+
+#else
+
+#define CanadaFr5Keymap NULL
+#define CanadaFr5Modmap NULL
+
+#endif /* CANFR5 */
+
+
+#ifdef DEN4
+
+static KeySym Denmark4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ XK_asciitilde, XK_asciicircum, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, XK_R1, XK_Pause, NoSymbol, /* 21*/
+ XK_Print, XK_R2, XK_Print, NoSymbol, /* 22*/
+ XK_Break, XK_Scroll_Lock, XK_R3, NoSymbol, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_at, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, XK_sterling, NoSymbol, /* 32*/
+ XK_4, XK_currency, XK_dollar, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_slash, XK_braceleft, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, XK_bracketleft, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_bracketright,NoSymbol, /* 38*/
+ XK_0, XK_equal, XK_braceright, NoSymbol, /* 39*/
+ XK_plus, XK_question, NoSymbol, NoSymbol, /* 40*/
+ SunXK_FA_Acute, SunXK_FA_Grave, XK_bar, NoSymbol, /* 41*/
+ XK_apostrophe, XK_asterisk, XK_grave, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, NoSymbol, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_Aring, NoSymbol, NoSymbol, NoSymbol, /* 64*/
+ SunXK_FA_Diaeresis,SunXK_FA_Circum,SunXK_FA_Tilde,NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R9, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_AE, NoSymbol, NoSymbol, NoSymbol, /* 86*/
+ XK_Ooblique, NoSymbol, NoSymbol, NoSymbol, /* 87*/
+ XK_onehalf, XK_section, NoSymbol, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R10, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R11, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R12, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, XK_backslash, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Denmark4Modmap DenSwedFinSw4Modmap
+
+#else
+
+#define Denmark4Keymap NULL
+#define Denmark4Modmap NULL
+
+#endif /* DENMARK4 */
+
+
+#ifdef DEN5
+
+static KeySym Denmark5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_at, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, XK_sterling, NoSymbol, /* 32*/
+ XK_4, XK_currency, XK_dollar, NoSymbol, /* 33*/
+ XK_5, XK_percent, XK_asciitilde, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, XK_asciicircum, NoSymbol, /* 35*/
+ XK_7, XK_slash, XK_braceleft, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, XK_bracketleft, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_bracketright,NoSymbol, /* 38*/
+ XK_0, XK_equal, XK_braceright, NoSymbol, /* 39*/
+ XK_plus, XK_question, NoSymbol, NoSymbol, /* 40*/
+ SunXK_FA_Acute, SunXK_FA_Grave, XK_bar, NoSymbol, /* 41*/
+ XK_onehalf, XK_section, NoSymbol, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_Aring, NoSymbol, NoSymbol, NoSymbol, /* 64*/
+ SunXK_FA_Diaeresis,SunXK_FA_Circum,SunXK_FA_Tilde,NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_AE, NoSymbol, NoSymbol, NoSymbol, /* 86*/
+ XK_Ooblique, NoSymbol, NoSymbol, NoSymbol, /* 87*/
+ XK_apostrophe, XK_asterisk, XK_grave, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, XK_backslash, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Denmark5Modmap Generic5Modmap
+
+#else
+
+#define Denmark5Keymap NULL
+#define Denmark5Modmap NULL
+
+#endif /* DEN5 */
+
+
+#ifdef FR5
+
+static KeySym France5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_ampersand, XK_1, NoSymbol, NoSymbol, /* 30*/
+ XK_eacute, XK_2, XK_asciitilde, NoSymbol, /* 31*/
+ XK_quotedbl, XK_3, XK_numbersign, NoSymbol, /* 32*/
+ XK_apostrophe, XK_4, XK_braceleft, NoSymbol, /* 33*/
+ XK_parenleft, XK_5, XK_bracketleft, NoSymbol, /* 34*/
+ XK_minus, XK_6, XK_bar, NoSymbol, /* 35*/
+ XK_egrave, XK_7, XK_grave, NoSymbol, /* 36*/
+ XK_underscore, XK_8, XK_backslash, NoSymbol, /* 37*/
+ XK_ccedilla, XK_9, XK_asciicircum, NoSymbol, /* 38*/
+ XK_agrave, XK_0, XK_at, NoSymbol, /* 39*/
+ XK_parenright, XK_degree, XK_bracketright,NoSymbol, /* 40*/
+ XK_equal, XK_plus, XK_braceright, NoSymbol, /* 41*/
+ XK_twosuperior, NoSymbol, NoSymbol, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ SunXK_FA_Circum,SunXK_FA_Diaeresis,NoSymbol, NoSymbol, /* 64*/
+ XK_dollar, XK_sterling, XK_currency, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /* 86*/
+ XK_ugrave, XK_percent, NoSymbol, NoSymbol, /* 87*/
+ XK_asterisk, XK_mu, NoSymbol, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_comma, XK_question, NoSymbol, NoSymbol, /*106*/
+ XK_semicolon, XK_period, NoSymbol, NoSymbol, /*107*/
+ XK_colon, XK_slash, NoSymbol, NoSymbol, /*108*/
+ XK_exclam, XK_section, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, XK_Next, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define France5Modmap Generic5Modmap
+
+#else
+
+#define France5Keymap NULL
+#define France5Modmap NULL
+
+#endif /* FRANCE5 */
+
+
+#ifdef FRBE4
+
+static KeySym FranceBelg4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ XK_bracketright,XK_braceright, XK_guillemotright,NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_R1, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_R2, NoSymbol, /* 22*/
+ XK_Break, XK_Scroll_Lock, XK_R3, NoSymbol, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_ampersand, XK_1, NoSymbol, NoSymbol, /* 30*/
+ XK_eacute, XK_2, XK_twosuperior, NoSymbol, /* 31*/
+ XK_quotedbl, XK_3, XK_threesuperior,NoSymbol, /* 32*/
+ XK_apostrophe, XK_4, XK_acute, NoSymbol, /* 33*/
+ XK_parenleft, XK_5, NoSymbol, NoSymbol, /* 34*/
+ XK_section, XK_6, XK_asciicircum, NoSymbol, /* 35*/
+ XK_egrave, XK_7, NoSymbol, NoSymbol, /* 36*/
+ XK_exclam, XK_8, XK_sterling, NoSymbol, /* 37*/
+ XK_ccedilla, XK_9, XK_backslash, NoSymbol, /* 38*/
+ XK_agrave, XK_0, NoSymbol, NoSymbol, /* 39*/
+ XK_parenright, XK_degree, XK_asciitilde, NoSymbol, /* 40*/
+ XK_minus, XK_underscore, XK_numbersign, NoSymbol, /* 41*/
+ XK_asterisk, XK_bar, XK_currency, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, XK_KP_Equal, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, XK_KP_Divide, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, XK_KP_Multiply, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ SunXK_FA_Circum,SunXK_FA_Diaeresis,NoSymbol, NoSymbol, /* 64*/
+ XK_grave, XK_dollar, XK_at, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R9, NoSymbol, /* 70*/
+ XK_KP_Subtract, XK_KP_Subtract, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_M, NoSymbol, XK_mu, NoSymbol, /* 86*/
+ XK_ugrave, XK_percent, NoSymbol, NoSymbol, /* 87*/
+ XK_bracketleft, XK_braceleft, XK_guillemotleft,NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, XK_KP_Enter, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R10, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R11, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R12, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_comma, XK_question, NoSymbol, NoSymbol, /*106*/
+ XK_semicolon, XK_period, NoSymbol, NoSymbol, /*107*/
+ XK_colon, XK_slash, NoSymbol, NoSymbol, /*108*/
+ XK_equal, XK_plus, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, XK_KP_Add, NoSymbol, NoSymbol, /*125*/
+};
+
+#define FranceBelg4Modmap FrBeNeth4Modmap
+
+#else
+
+#define FranceBelg4Keymap NULL
+#define FranceBelg4Modmap NULL
+
+#endif /* FRANCEBELG4 */
+
+
+#ifdef GER4
+
+static KeySym Germany4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ XK_Alt_R, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ XK_bracketright,XK_braceright,XK_guillemotright,NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_R1, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_R2, NoSymbol, /* 22*/
+ XK_Scroll_Lock, NoSymbol, XK_R3, NoSymbol, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_twosuperior, NoSymbol, /* 31*/
+ XK_3, XK_section, XK_threesuperior,NoSymbol, /* 32*/
+ XK_4, XK_dollar, NoSymbol, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_slash, XK_degree, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, XK_grave, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_apostrophe, NoSymbol, /* 38*/
+ XK_0, XK_equal, XK_bar, NoSymbol, /* 39*/
+ XK_ssharp, XK_question, XK_backslash, NoSymbol, /* 40*/
+ SunXK_FA_Acute, SunXK_FA_Grave, NoSymbol, NoSymbol, /* 41*/
+ XK_numbersign, XK_asciicircum, XK_at, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, NoSymbol, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Delete, XK_KP_Decimal, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_Udiaeresis, NoSymbol, NoSymbol, NoSymbol, /* 64*/
+ XK_plus, XK_asterisk, XK_asciitilde, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R9, NoSymbol, /* 70*/
+ XK_KP_Subtract, XK_KP_Subtract, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_Odiaeresis, NoSymbol, NoSymbol, NoSymbol, /* 86*/
+ XK_Adiaeresis, NoSymbol, NoSymbol, NoSymbol, /* 87*/
+ XK_bracketleft, XK_braceleft, XK_guillemotleft,NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R10, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R11, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R12, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, XK_mu, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+static SunModmapRec Germany4Modmap[] = {
+ { 99, ShiftMask },
+ { 110, ShiftMask },
+ { 76, LockMask },
+ { 119, ControlMask },
+ { 120, Meta_Mask },
+ { 122, Meta_Mask },
+ { 19, Mode_switch_Mask },
+ { 98, Num_Lock_Mask },
+ { 13, Alt_Mask },
+ { 0, 0 }
+};
+
+#else
+
+#define Germany4Keymap NULL
+#define Germany4Modmap NULL
+
+#endif /* GERMANY4 */
+
+
+#ifdef GER5
+
+static KeySym Germany5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_twosuperior, NoSymbol, /* 31*/
+ XK_3, XK_section, XK_threesuperior,NoSymbol, /* 32*/
+ XK_4, XK_dollar, NoSymbol, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_slash, XK_braceleft, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, XK_bracketleft, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_bracketright,NoSymbol, /* 38*/
+ XK_0, XK_equal, XK_braceright, NoSymbol, /* 39*/
+ XK_ssharp, XK_question, XK_backslash, NoSymbol, /* 40*/
+ SunXK_FA_Acute, SunXK_FA_Grave, NoSymbol, NoSymbol, /* 41*/
+ XK_asciicircum, XK_degree, NoSymbol, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Separator,NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_q, XK_Q, XK_at, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_Udiaeresis, NoSymbol, NoSymbol, NoSymbol, /* 64*/
+ XK_plus, XK_asterisk, XK_asciitilde, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_Odiaeresis, NoSymbol, NoSymbol, NoSymbol, /* 86*/
+ XK_Adiaeresis, NoSymbol, NoSymbol, NoSymbol, /* 87*/
+ XK_numbersign, XK_apostrophe, XK_grave, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_m, XK_M, XK_mu, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, XK_bar, NoSymbol, /*124*/
+ XK_KP_Add, XK_KP_Add, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Germany5Modmap Generic5Modmap
+
+#else
+
+#define Germany5Keymap NULL
+#define Germany5Modmap NULL
+
+#endif /* GERMANY5 */
+
+
+#ifdef ITALY4
+
+static KeySym Italy4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ XK_bracketright,XK_braceright, XK_guillemotright,NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_R1, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_R2, NoSymbol, /* 22*/
+ XK_Break, XK_Scroll_Lock, XK_R3, NoSymbol, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_twosuperior, NoSymbol, /* 31*/
+ XK_3, XK_sterling, XK_threesuperior,NoSymbol, /* 32*/
+ XK_4, XK_dollar, NoSymbol, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, XK_notsign, NoSymbol, /* 35*/
+ XK_7, XK_slash, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_backslash, NoSymbol, /* 38*/
+ XK_0, XK_equal, XK_bar, NoSymbol, /* 39*/
+ XK_apostrophe, XK_question, XK_grave, NoSymbol, /* 40*/
+ XK_igrave, XK_asciicircum, NoSymbol, NoSymbol, /* 41*/
+ XK_ugrave, XK_section, NoSymbol, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, NoSymbol, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_egrave, XK_eacute, NoSymbol, NoSymbol, /* 64*/
+ XK_plus, XK_asterisk, XK_asciitilde, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R9, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_ograve, XK_ccedilla, XK_at, NoSymbol, /* 86*/
+ XK_agrave, XK_degree, XK_numbersign, NoSymbol, /* 87*/
+ XK_bracketleft, XK_braceleft, XK_guillemotleft,NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R4, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R5, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R6, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Italy4Modmap ItNorPortSp4Modmap
+
+#else
+
+#define Italy4Keymap NULL
+#define Italy4Modmap NULL
+
+#endif /* ITALY4 */
+
+
+#ifdef ITALY5
+
+static KeySym Italy5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, XK_Break, NoSymbol, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, NoSymbol, NoSymbol, /* 31*/
+ XK_3, XK_sterling, NoSymbol, NoSymbol, /* 32*/
+ XK_4, XK_dollar, NoSymbol, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_slash, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, XK_braceleft, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_braceright, NoSymbol, /* 38*/
+ XK_0, XK_equal, NoSymbol, NoSymbol, /* 39*/
+ XK_apostrophe, XK_question, XK_grave, NoSymbol, /* 40*/
+ XK_igrave, XK_asciicircum, NoSymbol, NoSymbol, /* 41*/
+ XK_backslash, XK_bar, NoSymbol, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, XK_KP_Divide, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, XK_KP_Multiply, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_egrave, XK_eacute, XK_bracketleft, NoSymbol, /* 64*/
+ XK_plus, XK_asterisk, XK_bracketright,NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_ograve, XK_ccedilla, XK_at, NoSymbol, /* 86*/
+ XK_agrave, XK_degree, XK_numbersign, NoSymbol, /* 87*/
+ XK_ugrave, XK_section, XK_asciitilde, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, XK_KP_Enter, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, XK_KP_Add, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Italy5Modmap Generic5Modmap
+
+#else
+
+#define Italy5Keymap NULL
+#define Italy5Modmap NULL
+
+#endif /* ITALY5 */
+
+
+#ifdef JAPAN4
+
+static KeySym Japan4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_R1, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_R2, NoSymbol, /* 22*/
+ XK_Break, XK_Scroll_Lock, XK_R3, NoSymbol, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, XK_kana_NU, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_kana_FU, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, XK_kana_A, XK_kana_a, /* 32*/
+ XK_4, XK_dollar, XK_kana_U, XK_kana_u, /* 33*/
+ XK_5, XK_percent, XK_kana_E, XK_kana_e, /* 34*/
+ XK_6, XK_ampersand, XK_kana_O, XK_kana_o, /* 35*/
+ XK_7, XK_apostrophe, XK_kana_YA, XK_kana_ya, /* 36*/
+ XK_8, XK_parenleft, XK_kana_YU, XK_kana_yu, /* 37*/
+ XK_9, XK_parenright, XK_kana_YO, XK_kana_yo, /* 38*/
+ XK_0, XK_0, XK_kana_WA, XK_kana_WO, /* 39*/
+ XK_minus, XK_equal, XK_kana_HO, NoSymbol, /* 40*/
+ XK_asciicircum, XK_asciitilde, XK_kana_HE, NoSymbol, /* 41*/
+ XK_bracketright,XK_braceright, XK_kana_MU, XK_kana_closingbracket, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, NoSymbol, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_q, XK_Q, XK_kana_TA, NoSymbol, /* 54*/
+ XK_w, XK_W, XK_kana_TE, NoSymbol, /* 55*/
+ XK_e, XK_E, XK_kana_I, XK_kana_i, /* 56*/
+ XK_r, XK_R, XK_kana_SU, NoSymbol, /* 57*/
+ XK_t, XK_T, XK_kana_KA, NoSymbol, /* 58*/
+ XK_y, XK_Y, XK_kana_N, NoSymbol, /* 59*/
+ XK_u, XK_U, XK_kana_NA, NoSymbol, /* 60*/
+ XK_i, XK_I, XK_kana_NI, NoSymbol, /* 61*/
+ XK_o, XK_O, XK_kana_RA, NoSymbol, /* 62*/
+ XK_p, XK_P, XK_kana_SE, NoSymbol, /* 63*/
+ XK_at, XK_grave, XK_voicedsound, NoSymbol, /* 64*/
+ XK_bracketleft, XK_braceleft, XK_semivoicedsound,XK_kana_openingbracket, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R9, NoSymbol, /* 70*/
+ XK_KP_Subtract, XK_KP_Subtract, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_a, XK_A, XK_kana_CHI, NoSymbol, /* 77*/
+ XK_s, XK_S, XK_kana_TO, NoSymbol, /* 78*/
+ XK_d, XK_D, XK_kana_SHI, NoSymbol, /* 79*/
+ XK_f, XK_F, XK_kana_HA, NoSymbol, /* 80*/
+ XK_g, XK_G, XK_kana_KI, NoSymbol, /* 81*/
+ XK_h, XK_H, XK_kana_KU, NoSymbol, /* 82*/
+ XK_j, XK_J, XK_kana_MA, NoSymbol, /* 83*/
+ XK_k, XK_K, XK_kana_NO, NoSymbol, /* 84*/
+ XK_l, XK_L, XK_kana_RI, NoSymbol, /* 85*/
+ XK_semicolon, XK_plus, XK_kana_RE, NoSymbol, /* 86*/
+ XK_colon, XK_asterisk, XK_kana_KE, NoSymbol, /* 87*/
+ XK_backslash, XK_bar, XK_prolongedsound,NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R10, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R11, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R12, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_z, XK_Z, XK_kana_TSU, XK_kana_tsu, /*100*/
+ XK_x, XK_X, XK_kana_SA, NoSymbol, /*101*/
+ XK_c, XK_C, XK_kana_SO, NoSymbol, /*102*/
+ XK_v, XK_V, XK_kana_HI, NoSymbol, /*103*/
+ XK_b, XK_B, XK_kana_KO, NoSymbol, /*104*/
+ XK_n, XK_N, XK_kana_MI, NoSymbol, /*105*/
+ XK_m, XK_M, XK_kana_MO, NoSymbol, /*106*/
+ XK_comma, XK_less, XK_kana_NE, XK_kana_comma, /*107*/
+ XK_period, XK_greater, XK_kana_RU, XK_kana_fullstop, /*108*/
+ XK_slash, XK_question, XK_kana_ME, XK_kana_conjunctive, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_backslash, XK_underscore, XK_kana_RO, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ XK_Execute, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ XK_Kanji, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ XK_Henkan_Mode, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, XK_KP_Add, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Japan4Modmap Generic5Modmap
+
+#else
+
+#define Japan4Keymap NULL
+#define Japan4Modmap NULL
+
+#endif /* JAPAN4 */
+
+
+#ifdef JAPAN5
+
+static KeySym Japan5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, XK_kana_NU, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_kana_FU, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, XK_kana_A, XK_kana_a, /* 32*/
+ XK_4, XK_dollar, XK_kana_U, XK_kana_u, /* 33*/
+ XK_5, XK_percent, XK_kana_E, XK_kana_e, /* 34*/
+ XK_6, XK_ampersand, XK_kana_O, XK_kana_o, /* 35*/
+ XK_7, XK_apostrophe, XK_kana_YA, XK_kana_ya, /* 36*/
+ XK_8, XK_parenleft, XK_kana_YU, XK_kana_yu, /* 37*/
+ XK_9, XK_parenright, XK_kana_YO, XK_kana_yo, /* 38*/
+ XK_0, XK_0, XK_kana_WA, XK_kana_WO, /* 39*/
+ XK_minus, XK_equal, XK_kana_HO, NoSymbol, /* 40*/
+ XK_asciicircum, XK_asciitilde, XK_kana_HE, NoSymbol, /* 41*/
+ XK_backslash, XK_bar, XK_prolongedsound,NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_q, XK_Q, XK_kana_TA, NoSymbol, /* 54*/
+ XK_w, XK_W, XK_kana_TE, NoSymbol, /* 55*/
+ XK_e, XK_E, XK_kana_I, XK_kana_i, /* 56*/
+ XK_r, XK_R, XK_kana_SU, NoSymbol, /* 57*/
+ XK_t, XK_T, XK_kana_KA, NoSymbol, /* 58*/
+ XK_y, XK_Y, XK_kana_N, NoSymbol, /* 59*/
+ XK_u, XK_U, XK_kana_NA, NoSymbol, /* 60*/
+ XK_i, XK_I, XK_kana_NI, NoSymbol, /* 61*/
+ XK_o, XK_O, XK_kana_RA, NoSymbol, /* 62*/
+ XK_p, XK_P, XK_kana_SE, NoSymbol, /* 63*/
+ XK_at, XK_grave, XK_voicedsound, NoSymbol, /* 64*/
+ XK_bracketleft, XK_braceleft, XK_semivoicedsound,XK_kana_openingbracket, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_a, XK_A, XK_kana_CHI, NoSymbol, /* 77*/
+ XK_s, XK_S, XK_kana_TO, NoSymbol, /* 78*/
+ XK_d, XK_D, XK_kana_SHI, NoSymbol, /* 79*/
+ XK_f, XK_F, XK_kana_HA, NoSymbol, /* 80*/
+ XK_g, XK_G, XK_kana_KI, NoSymbol, /* 81*/
+ XK_h, XK_H, XK_kana_KU, NoSymbol, /* 82*/
+ XK_j, XK_J, XK_kana_MA, NoSymbol, /* 83*/
+ XK_k, XK_K, XK_kana_NO, NoSymbol, /* 84*/
+ XK_l, XK_L, XK_kana_RI, NoSymbol, /* 85*/
+ XK_semicolon, XK_plus, XK_kana_RE, NoSymbol, /* 86*/
+ XK_colon, XK_asterisk, XK_kana_KE, NoSymbol, /* 87*/
+ XK_bracketright,XK_braceright, XK_kana_MU, XK_kana_closingbracket, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_z, XK_Z, XK_kana_TSU, XK_kana_tsu, /*100*/
+ XK_x, XK_X, XK_kana_SA, NoSymbol, /*101*/
+ XK_c, XK_C, XK_kana_SO, NoSymbol, /*102*/
+ XK_v, XK_V, XK_kana_HI, NoSymbol, /*103*/
+ XK_b, XK_B, XK_kana_KO, NoSymbol, /*104*/
+ XK_n, XK_N, XK_kana_MI, NoSymbol, /*105*/
+ XK_m, XK_M, XK_kana_MO, NoSymbol, /*106*/
+ XK_comma, XK_less, XK_kana_NE, XK_kana_comma, /*107*/
+ XK_period, XK_greater, XK_kana_RU, XK_kana_fullstop, /*108*/
+ XK_slash, XK_question, XK_kana_ME, XK_kana_conjunctive, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_backslash, XK_underscore, XK_kana_RO, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ XK_Execute, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ XK_Kanji, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ XK_Henkan_Mode, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, XK_KP_Add, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Japan5Modmap Generic5Modmap
+
+#else
+
+#define Japan5Keymap NULL
+#define Japan5Modmap NULL
+
+#endif /* JAPAN5 */
+
+
+#ifdef KOREA4
+
+static KeySym Korea4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_R1, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_R2, NoSymbol, /* 22*/
+ XK_Break, XK_Scroll_Lock, XK_R3, NoSymbol, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_at, NoSymbol, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, NoSymbol, NoSymbol, /* 32*/
+ XK_4, XK_dollar, NoSymbol, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_asciicircum, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_ampersand, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_asterisk, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenleft, NoSymbol, NoSymbol, /* 38*/
+ XK_0, XK_parenright, NoSymbol, NoSymbol, /* 39*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /* 40*/
+ XK_equal, XK_plus, NoSymbol, NoSymbol, /* 41*/
+ XK_grave, XK_asciitilde, XK_acute, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, NoSymbol, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol, /* 64*/
+ XK_bracketright,XK_braceright, NoSymbol, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R9, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_semicolon, XK_colon, NoSymbol, NoSymbol, /* 86*/
+ XK_apostrophe, XK_quotedbl, NoSymbol, NoSymbol, /* 87*/
+ XK_backslash, XK_bar, XK_brokenbar, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R10, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R11, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R12, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_less, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_greater, NoSymbol, NoSymbol, /*108*/
+ XK_slash, XK_question, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+static SunModmapRec Korea4Modmap[] = {
+ { 99, ShiftMask },
+ { 110, ShiftMask },
+ { 119, LockMask },
+ { 76, ControlMask },
+ { 120, Meta_Mask },
+ { 122, Meta_Mask },
+ { 111, Mode_switch_Mask },
+ { 98, Num_Lock_Mask },
+ { 19, Alt_Mask },
+ { 0, 0 }
+};
+
+#else
+
+#define Korea4Keymap NULL
+#define Korea4Modmap NULL
+
+#endif /* KOREA4 */
+
+
+#ifdef KOREA5
+
+static KeySym Korea5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_at, NoSymbol, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, NoSymbol, NoSymbol, /* 32*/
+ XK_4, XK_dollar, NoSymbol, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_asciicircum, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_ampersand, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_asterisk, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenleft, NoSymbol, NoSymbol, /* 38*/
+ XK_0, XK_parenright, NoSymbol, NoSymbol, /* 39*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /* 40*/
+ XK_equal, XK_plus, NoSymbol, NoSymbol, /* 41*/
+ XK_grave, XK_asciitilde, XK_acute, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol, /* 64*/
+ XK_bracketright,XK_braceright, NoSymbol, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_semicolon, XK_colon, NoSymbol, NoSymbol, /* 86*/
+ XK_apostrophe, XK_quotedbl, NoSymbol, NoSymbol, /* 87*/
+ XK_backslash, XK_bar, XK_brokenbar, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_less, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_greater, NoSymbol, NoSymbol, /*108*/
+ XK_slash, XK_question, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Korea5Modmap Generic5Modmap
+
+#else
+
+#define Korea5Keymap NULL
+#define Korea5Modmap NULL
+
+#endif /* KOREA5 */
+
+
+#ifdef NETH4
+
+static KeySym Netherland4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ XK_backslash, XK_bar, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_R1, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_R2, NoSymbol, /* 22*/
+ XK_Break, XK_Scroll_Lock, XK_R3, NoSymbol, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, XK_onesuperior, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_twosuperior, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, XK_threesuperior,NoSymbol, /* 32*/
+ XK_4, XK_dollar, XK_onequarter, NoSymbol, /* 33*/
+ XK_5, XK_percent, XK_onehalf, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, XK_threequarters,NoSymbol, /* 35*/
+ XK_7, XK_underscore, XK_sterling, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, XK_braceleft, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_braceright, NoSymbol, /* 38*/
+ XK_0, XK_apostrophe, XK_grave, NoSymbol, /* 39*/
+ XK_slash, XK_question, NoSymbol, NoSymbol, /* 40*/
+ XK_degree, SunXK_FA_Tilde, SunXK_FA_Cedilla,NoSymbol, /* 41*/
+ XK_less, XK_greater, NoSymbol, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, NoSymbol, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ SunXK_FA_Diaeresis,XK_asciicircum,SunXK_FA_Circum,NoSymbol, /* 64*/
+ XK_asterisk, XK_brokenbar, XK_asciitilde, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R9, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, XK_ssharp, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_plus, XK_plusminus, NoSymbol, NoSymbol, /* 86*/
+ SunXK_FA_Acute, SunXK_FA_Grave, NoSymbol, NoSymbol, /* 87*/
+ XK_at, XK_section, XK_notsign, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R10, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R11, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R12, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, XK_guillemotleft,NoSymbol, /*100*/
+ XK_X, NoSymbol, XK_guillemotright,NoSymbol, /*101*/
+ XK_C, NoSymbol, XK_cent, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, XK_mu, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_equal, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_bracketright,XK_bracketleft, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Netherland4Modmap FrBeNeth4Modmap
+
+#else
+
+#define Netherland4Keymap NULL
+#define Netherland4Modmap NULL
+
+#endif /* NETHERLAND4 */
+
+
+#ifdef NETH5
+
+static KeySym Netherland5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, XK_onesuperior, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_twosuperior, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, XK_threesuperior,NoSymbol, /* 32*/
+ XK_4, XK_dollar, XK_onequarter, NoSymbol, /* 33*/
+ XK_5, XK_percent, XK_onehalf, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, XK_threequarters,NoSymbol, /* 35*/
+ XK_7, XK_underscore, XK_sterling, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, XK_braceleft, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_braceright, NoSymbol, /* 38*/
+ XK_0, XK_apostrophe, XK_grave, NoSymbol, /* 39*/
+ XK_slash, XK_question, XK_backslash, NoSymbol, /* 40*/
+ XK_degree, SunXK_FA_Tilde, SunXK_FA_Cedilla,NoSymbol, /* 41*/
+ XK_at, XK_section, XK_notsign, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Separator,NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ SunXK_FA_Diaeresis,SunXK_FA_Circum,NoSymbol, NoSymbol, /* 64*/
+ XK_asterisk, XK_bar, XK_asciitilde, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, XK_ssharp, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_plus, XK_plusminus, NoSymbol, NoSymbol, /* 86*/
+ SunXK_FA_Acute, SunXK_FA_Grave, NoSymbol, NoSymbol, /* 87*/
+ XK_less, XK_greater, XK_asciicircum, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_z, XK_Z, XK_guillemotleft,NoSymbol, /*100*/
+ XK_x, XK_X, XK_guillemotright,NoSymbol, /*101*/
+ XK_c, XK_C, XK_cent, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_m, XK_M, XK_mu, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, XK_periodcentered,NoSymbol, /*108*/
+ XK_minus, XK_equal, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_bracketright,XK_bracketleft, XK_brokenbar, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Netherland5Modmap Generic5Modmap
+
+#else
+
+#define Netherland5Keymap NULL
+#define Netherland5Modmap NULL
+
+#endif /* NETHERLAND5 */
+
+
+#ifdef NORW4
+
+static KeySym Norway4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ XK_asciitilde, XK_asciicircum, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_R1, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_R2, NoSymbol, /* 22*/
+ XK_Break, XK_Scroll_Lock, XK_R3, NoSymbol, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_at, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, XK_sterling, NoSymbol, /* 32*/
+ XK_4, XK_currency, XK_dollar, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_slash, XK_braceleft, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, XK_bracketleft, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_bracketright,NoSymbol, /* 38*/
+ XK_0, XK_equal, XK_braceright, NoSymbol, /* 39*/
+ XK_plus, XK_question, NoSymbol, NoSymbol, /* 40*/
+ XK_backslash, SunXK_FA_Grave, SunXK_FA_Acute, NoSymbol, /* 41*/
+ XK_apostrophe, XK_asterisk, XK_grave, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, NoSymbol, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_Aring, NoSymbol, NoSymbol, NoSymbol, /* 64*/
+ SunXK_FA_Diaeresis,SunXK_FA_Circum,SunXK_FA_Tilde,NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R9, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_Ooblique, NoSymbol, NoSymbol, NoSymbol, /* 86*/
+ XK_AE, NoSymbol, NoSymbol, NoSymbol, /* 87*/
+ XK_bar, XK_section, NoSymbol, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R10, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R11, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R12, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Norway4Modmap ItNorPortSp4Modmap
+
+#else
+
+#define Norway4Keymap NULL
+#define Norway4Modmap NULL
+
+#endif /* NORWAY4 */
+
+
+#ifdef NORW5
+
+static KeySym Norway5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_at, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, XK_sterling, NoSymbol, /* 32*/
+ XK_4, XK_currency, XK_dollar, NoSymbol, /* 33*/
+ XK_5, XK_percent, XK_asciitilde, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, XK_asciicircum, NoSymbol, /* 35*/
+ XK_7, XK_slash, XK_braceleft, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, XK_bracketleft, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_bracketright,NoSymbol, /* 38*/
+ XK_0, XK_equal, XK_braceright, NoSymbol, /* 39*/
+ XK_plus, XK_question, NoSymbol, NoSymbol, /* 40*/
+ XK_backslash, SunXK_FA_Grave, SunXK_FA_Acute, NoSymbol, /* 41*/
+ XK_bar, XK_section, NoSymbol, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Separator,NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_Aring, NoSymbol, NoSymbol, NoSymbol, /* 64*/
+ SunXK_FA_Diaeresis,SunXK_FA_Circum,SunXK_FA_Tilde,NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_Ooblique, NoSymbol, NoSymbol, NoSymbol, /* 86*/
+ XK_AE, NoSymbol, NoSymbol, NoSymbol, /* 87*/
+ XK_apostrophe, XK_asterisk, XK_grave, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Norway5Modmap Generic5Modmap
+
+#else
+
+#define Norway5Keymap NULL
+#define Norway5Modmap NULL
+
+#endif /* NORWAY5 */
+
+
+#ifdef PORT4
+
+static KeySym Portugal4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ XK_bracketright,XK_braceright, XK_guillemotright,NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_R1, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_R2, NoSymbol, /* 22*/
+ XK_Break, XK_Scroll_Lock, XK_R3, XK_Break, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_at, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, XK_sterling, NoSymbol, /* 32*/
+ XK_4, XK_dollar, XK_section, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, XK_notsign, NoSymbol, /* 35*/
+ XK_7, XK_slash, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_backslash, NoSymbol, /* 38*/
+ XK_0, XK_equal, XK_bar, NoSymbol, /* 39*/
+ XK_apostrophe, XK_question, XK_grave, NoSymbol, /* 40*/
+ XK_exclamdown, XK_questiondown,NoSymbol, NoSymbol, /* 41*/
+ SunXK_FA_Tilde, SunXK_FA_Circum,XK_asciicircum, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, NoSymbol, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ SunXK_FA_Diaeresis,XK_asterisk, XK_plus, NoSymbol, /* 64*/
+ SunXK_FA_Acute, SunXK_FA_Grave, XK_asciitilde, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R9, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_Ccedilla, NoSymbol, NoSymbol, NoSymbol, /* 86*/
+ XK_masculine, XK_ordfeminine, NoSymbol, NoSymbol, /* 87*/
+ XK_bracketleft, XK_braceleft, XK_guillemotleft,NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R10, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R11, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R12, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Portugal4Modmap ItNorPortSp4Modmap
+
+#else
+
+#define Portugal4Keymap NULL
+#define Portugal4Modmap NULL
+
+#endif /* PORTUGAL4 */
+
+
+#ifdef PORT5
+
+static KeySym Portugal5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_at, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, XK_sterling, NoSymbol, /* 32*/
+ XK_4, XK_dollar, XK_section, NoSymbol, /* 33*/
+ XK_5, XK_percent, XK_asciitilde, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, XK_asciicircum, NoSymbol, /* 35*/
+ XK_7, XK_slash, XK_braceleft, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, XK_bracketleft, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_bracketright,NoSymbol, /* 38*/
+ XK_0, XK_equal, XK_braceright, NoSymbol, /* 39*/
+ XK_apostrophe, XK_question, XK_grave, NoSymbol, /* 40*/
+ XK_guillemotleft,XK_guillemotright,NoSymbol, NoSymbol, /* 41*/
+ XK_backslash, XK_bar, NoSymbol, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_plus, XK_asterisk, SunXK_FA_Diaeresis,NoSymbol, /* 64*/
+ SunXK_FA_Acute, SunXK_FA_Grave, NoSymbol, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_Ccedilla, NoSymbol, NoSymbol, NoSymbol, /* 86*/
+ XK_masculine, XK_ordfeminine, NoSymbol, NoSymbol, /* 87*/
+ SunXK_FA_Tilde, SunXK_FA_Circum,NoSymbol, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Portugal5Modmap Generic5Modmap
+
+#else
+
+#define Portugal5Keymap NULL
+#define Portugal5Modmap NULL
+
+#endif /* PORTUGAL5 */
+
+
+#ifdef SPAIN5
+
+static KeySym Spain5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, XK_bar, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_at, NoSymbol, /* 31*/
+ XK_3, XK_periodcentered,XK_numbersign,NoSymbol, /* 32*/
+ XK_4, XK_dollar, XK_asciicircum, NoSymbol, /* 33*/
+ XK_5, XK_percent, XK_asciitilde, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, XK_notsign, NoSymbol, /* 35*/
+ XK_7, XK_slash, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenright, NoSymbol, NoSymbol, /* 38*/
+ XK_0, XK_equal, NoSymbol, NoSymbol, /* 39*/
+ XK_apostrophe, XK_question, XK_grave, NoSymbol, /* 40*/
+ XK_exclamdown, XK_questiondown,NoSymbol, NoSymbol, /* 41*/
+ XK_masculine, XK_ordfeminine, XK_backslash, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ SunXK_FA_Grave, SunXK_FA_Circum,XK_bracketleft, NoSymbol, /* 64*/
+ XK_plus, XK_asterisk, XK_bracketright,NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_Ntilde, NoSymbol, NoSymbol, NoSymbol, /* 86*/
+ SunXK_FA_Acute, SunXK_FA_Diaeresis,XK_braceleft,NoSymbol, /* 87*/
+ XK_ccedilla, XK_Ccedilla, XK_braceright, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Spain5Modmap Generic5Modmap
+
+#else
+
+#define Spain5Keymap NULL
+#define Spain5Modmap NULL
+
+#endif /* SPAIN5 */
+
+
+#ifdef SPAINLATAM4
+
+static KeySym SpainLatAm4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ XK_bracketright,XK_braceright, XK_guillemotright,NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_R1, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_R2, NoSymbol, /* 22*/
+ XK_Scroll_Lock, NoSymbol, XK_R3, XK_Break, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_at, NoSymbol, /* 31*/
+ XK_3, XK_periodcentered,XK_numbersign,NoSymbol, /* 32*/
+ XK_4, XK_dollar, NoSymbol, NoSymbol, /* 33*/
+ XK_5, XK_percent, XK_degree, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, XK_notsign, NoSymbol, /* 35*/
+ XK_7, XK_slash, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_backslash, NoSymbol, /* 38*/
+ XK_0, XK_equal, XK_bar, NoSymbol, /* 39*/
+ XK_apostrophe, XK_question, XK_grave, NoSymbol, /* 40*/
+ XK_exclamdown, XK_questiondown,NoSymbol, NoSymbol, /* 41*/
+ XK_Ccedilla, NoSymbol, NoSymbol, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, NoSymbol, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, XK_masculine, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ SunXK_FA_Grave, SunXK_FA_Circum,XK_asciicircum, NoSymbol, /* 64*/
+ XK_plus, XK_asterisk, XK_asciitilde, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R9, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, XK_ordfeminine, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_Ntilde, NoSymbol, NoSymbol, NoSymbol, /* 86*/
+ SunXK_FA_Acute, SunXK_FA_Diaeresis,NoSymbol, NoSymbol, /* 87*/
+ XK_bracketleft, XK_braceleft, XK_guillemotleft,NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R10, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R11, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R12, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define SpainLatAm4Modmap ItNorPortSp4Modmap
+
+#else
+
+#define SpainLatAm4Keymap NULL
+#define SpainLatAm4Modmap NULL
+
+#endif /* SPAINLATAM4 */
+
+
+#ifdef SWED5
+
+static KeySym Sweden5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_at, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, XK_sterling, NoSymbol, /* 32*/
+ XK_4, XK_currency, XK_dollar, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_slash, XK_braceleft, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, XK_bracketleft, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_bracketright,NoSymbol, /* 38*/
+ XK_0, XK_equal, XK_braceright, NoSymbol, /* 39*/
+ XK_plus, XK_question, XK_backslash, NoSymbol, /* 40*/
+ SunXK_FA_Acute, SunXK_FA_Grave, NoSymbol, NoSymbol, /* 41*/
+ XK_section, XK_onehalf, NoSymbol, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Separator,NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_Aring, NoSymbol, NoSymbol, NoSymbol, /* 64*/
+ SunXK_FA_Diaeresis,XK_asciicircum,XK_asciitilde,NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_Odiaeresis, NoSymbol, NoSymbol, NoSymbol, /* 86*/
+ XK_Adiaeresis, NoSymbol, NoSymbol, NoSymbol, /* 87*/
+ XK_apostrophe, XK_asterisk, XK_grave, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, XK_bar, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Sweden5Modmap Generic5Modmap
+
+#else
+
+#define Sweden5Keymap NULL
+#define Sweden5Modmap NULL
+
+#endif /* SWEDEN5 */
+
+
+#ifdef SWEDFIN4
+
+static KeySym SwedenFin4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ XK_asciitilde, XK_asciicircum, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_R1, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_R2, NoSymbol, /* 22*/
+ XK_Break, XK_Scroll_Lock, XK_R3, NoSymbol, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_at, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, XK_sterling, NoSymbol, /* 32*/
+ XK_4, XK_currency, XK_dollar, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_slash, XK_braceleft, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, XK_bracketleft, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_bracketright,NoSymbol, /* 38*/
+ XK_0, XK_equal, XK_braceright, NoSymbol, /* 39*/
+ XK_plus, XK_question, XK_backslash, NoSymbol, /* 40*/
+ SunXK_FA_Acute, SunXK_FA_Grave, NoSymbol, NoSymbol, /* 41*/
+ XK_apostrophe, XK_asterisk, XK_grave, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, NoSymbol, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_Aring, NoSymbol, NoSymbol, NoSymbol, /* 64*/
+ SunXK_FA_Diaeresis,SunXK_FA_Circum,SunXK_FA_Tilde,NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R8, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_Odiaeresis, NoSymbol, NoSymbol, NoSymbol, /* 86*/
+ XK_Adiaeresis, NoSymbol, NoSymbol, NoSymbol, /* 87*/
+ XK_section, XK_onehalf, NoSymbol, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R10, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R11, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R12, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, XK_bar, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define SwedenFin4Modmap DenSwedFinSw4Modmap
+
+#else
+
+#define SwedenFin4Keymap NULL
+#define SwedenFin4Modmap NULL
+
+#endif /* SWEDENFIN4 */
+
+
+#ifdef SWFR4
+
+static KeySym SwissFr4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ XK_greater, XK_braceright, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_R1, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_R2, NoSymbol, /* 22*/
+ XK_Break, XK_Scroll_Lock, XK_R3, NoSymbol, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_plus, XK_exclam, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_at, NoSymbol, /* 31*/
+ XK_3, XK_asterisk, XK_numbersign, NoSymbol, /* 32*/
+ XK_4, XK_ccedilla, XK_cent, NoSymbol, /* 33*/
+ XK_5, XK_percent, XK_asciitilde, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, XK_section, NoSymbol, /* 35*/
+ XK_7, XK_slash, XK_bar, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, XK_degree, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_backslash, NoSymbol, /* 38*/
+ XK_0, XK_equal, XK_asciicircum, NoSymbol, /* 39*/
+ XK_apostrophe, XK_question, XK_grave, NoSymbol, /* 40*/
+ SunXK_FA_Circum,SunXK_FA_Grave, NoSymbol, NoSymbol, /* 41*/
+ XK_dollar, SunXK_FA_Tilde, XK_sterling, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, NoSymbol, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_egrave, XK_udiaeresis, NoSymbol, NoSymbol, /* 64*/
+ SunXK_FA_Diaeresis,SunXK_FA_Acute,NoSymbol, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R9, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_eacute, XK_odiaeresis, NoSymbol, NoSymbol, /* 86*/
+ XK_agrave, XK_adiaeresis, NoSymbol, NoSymbol, /* 87*/
+ XK_less, XK_braceleft, NoSymbol, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R10, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R11, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R12, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, XK_mu, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_bracketright,XK_bracketleft, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define SwissFr4Modmap DenSwedFinSw4Modmap
+
+#else
+
+#define SwissFr4Keymap NULL
+#define SwissFr4Modmap NULL
+
+#endif /* SWFR4 */
+
+
+#ifdef SWFR5
+
+static KeySym SwissFr5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_plus, XK_bar, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_at, NoSymbol, /* 31*/
+ XK_3, XK_asterisk, XK_numbersign, NoSymbol, /* 32*/
+ XK_4, XK_ccedilla, XK_asciicircum, NoSymbol, /* 33*/
+ XK_5, XK_percent, XK_asciitilde, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_slash, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenright, NoSymbol, NoSymbol, /* 38*/
+ XK_0, XK_equal, XK_grave, NoSymbol, /* 39*/
+ XK_apostrophe, XK_question, SunXK_FA_Acute, NoSymbol, /* 40*/
+ SunXK_FA_Circum,SunXK_FA_Grave, SunXK_FA_Tilde, NoSymbol, /* 41*/
+ XK_section, XK_degree, NoSymbol, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_egrave, XK_udiaeresis, XK_bracketleft, NoSymbol, /* 64*/
+ SunXK_FA_Diaeresis,XK_exclam, XK_bracketright,NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_eacute, XK_odiaeresis, NoSymbol, NoSymbol, /* 86*/
+ XK_agrave, XK_adiaeresis, XK_braceleft, NoSymbol, /* 87*/
+ XK_dollar, XK_sterling, XK_braceright, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, XK_backslash, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define SwissFr5Modmap Generic5Modmap
+
+#else
+
+#define SwissFr5Keymap NULL
+#define SwissFr5Modmap NULL
+
+#endif /* SWFR5 */
+
+
+#ifdef SWGE4
+
+static KeySym SwissGe4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ XK_greater, XK_braceright, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_R1, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_R2, NoSymbol, /* 22*/
+ XK_Break, XK_Scroll_Lock, XK_R3, NoSymbol, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_plus, XK_exclam, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_at, NoSymbol, /* 31*/
+ XK_3, XK_asterisk, XK_numbersign, NoSymbol, /* 32*/
+ XK_4, XK_ccedilla, XK_cent, NoSymbol, /* 33*/
+ XK_5, XK_percent, XK_asciitilde, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, XK_section, NoSymbol, /* 35*/
+ XK_7, XK_slash, XK_bar, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, XK_degree, NoSymbol, /* 37*/
+ XK_9, XK_parenright, XK_backslash, NoSymbol, /* 38*/
+ XK_0, XK_equal, XK_asciicircum, NoSymbol, /* 39*/
+ XK_apostrophe, XK_question, XK_grave, NoSymbol, /* 40*/
+ SunXK_FA_Circum,SunXK_FA_Grave, NoSymbol, NoSymbol, /* 41*/
+ XK_dollar, SunXK_FA_Tilde, XK_sterling, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, NoSymbol, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_udiaeresis, XK_egrave, NoSymbol, NoSymbol, /* 64*/
+ SunXK_FA_Diaeresis,SunXK_FA_Acute,NoSymbol, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R9, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_odiaeresis, XK_eacute, NoSymbol, NoSymbol, /* 86*/
+ XK_adiaeresis, XK_agrave, NoSymbol, NoSymbol, /* 87*/
+ XK_less, XK_braceleft, NoSymbol, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R10, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R11, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R12, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, XK_mu, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_bracketright,XK_bracketleft, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define SwissGe4Modmap DenSwedFinSw4Modmap
+
+#else
+
+#define SwissGe4Keymap NULL
+#define SwissGe4Modmap NULL
+
+#endif /* SWISSGE4 */
+
+
+#ifdef SWGE5
+
+static KeySym SwissGe5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_plus, XK_bar, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, XK_at, NoSymbol, /* 31*/
+ XK_3, XK_asterisk, XK_numbersign, NoSymbol, /* 32*/
+ XK_4, XK_ccedilla, XK_asciicircum, NoSymbol, /* 33*/
+ XK_5, XK_percent, XK_asciitilde, NoSymbol, /* 34*/
+ XK_6, XK_ampersand, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_slash, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_parenleft, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenright, NoSymbol, NoSymbol, /* 38*/
+ XK_0, XK_equal, XK_grave, NoSymbol, /* 39*/
+ XK_apostrophe, XK_question, SunXK_FA_Acute, NoSymbol, /* 40*/
+ SunXK_FA_Circum,SunXK_FA_Grave, SunXK_FA_Tilde, NoSymbol, /* 41*/
+ XK_section, XK_degree, NoSymbol, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_udiaeresis, XK_egrave, XK_bracketleft, NoSymbol, /* 64*/
+ SunXK_FA_Diaeresis,XK_exclam, XK_bracketright,NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_odiaeresis, XK_eacute, NoSymbol, NoSymbol, /* 86*/
+ XK_adiaeresis, XK_agrave, XK_braceleft, NoSymbol, /* 87*/
+ XK_dollar, XK_sterling, XK_braceright, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_semicolon, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_colon, NoSymbol, NoSymbol, /*108*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_less, XK_greater, XK_backslash, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define SwissGe5Modmap Generic5Modmap
+
+#else
+
+#define SwissGe5Keymap NULL
+#define SwissGe5Modmap NULL
+
+#endif /* SWITZER_GE5 */
+
+
+#ifdef TAI4
+
+static KeySym Taiwan4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_R1, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_R2, NoSymbol, /* 22*/
+ XK_Break, XK_Scroll_Lock, XK_R3, NoSymbol, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_at, NoSymbol, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, NoSymbol, NoSymbol, /* 32*/
+ XK_4, XK_dollar, NoSymbol, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_asciicircum, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_ampersand, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_asterisk, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenleft, NoSymbol, NoSymbol, /* 38*/
+ XK_0, XK_parenright, NoSymbol, NoSymbol, /* 39*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /* 40*/
+ XK_equal, XK_plus, NoSymbol, NoSymbol, /* 41*/
+ XK_grave, XK_asciitilde, XK_acute, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, NoSymbol, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol, /* 64*/
+ XK_bracketright,XK_braceright, NoSymbol, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R9, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_semicolon, XK_colon, NoSymbol, NoSymbol, /* 86*/
+ XK_apostrophe, XK_quotedbl, NoSymbol, NoSymbol, /* 87*/
+ XK_backslash, XK_bar, XK_brokenbar, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R10, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R11, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R12, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_less, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_greater, NoSymbol, NoSymbol, /*108*/
+ XK_slash, XK_question, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Taiwan4Modmap Generic5Modmap
+
+#else
+
+#define Taiwan4Keymap NULL
+#define Taiwan4Modmap NULL
+
+#endif /* TAIWAN4 */
+
+
+#ifdef TAI5
+
+static KeySym Taiwan5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_at, NoSymbol, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, NoSymbol, NoSymbol, /* 32*/
+ XK_4, XK_dollar, NoSymbol, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_asciicircum, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_ampersand, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_asterisk, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenleft, NoSymbol, NoSymbol, /* 38*/
+ XK_0, XK_parenright, NoSymbol, NoSymbol, /* 39*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /* 40*/
+ XK_equal, XK_plus, NoSymbol, NoSymbol, /* 41*/
+ XK_grave, XK_asciitilde, XK_acute, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol, /* 64*/
+ XK_bracketright,XK_braceright, NoSymbol, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_semicolon, XK_colon, NoSymbol, NoSymbol, /* 86*/
+ XK_apostrophe, XK_quotedbl, NoSymbol, NoSymbol, /* 87*/
+ XK_backslash, XK_bar, XK_brokenbar, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_less, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_greater, NoSymbol, NoSymbol, /*108*/
+ XK_slash, XK_question, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define Taiwan5Modmap Generic5Modmap
+
+#else
+
+#define Taiwan5Keymap NULL
+#define Taiwan5Modmap NULL
+
+#endif /* TAIWAN5 */
+
+
+#ifdef UK4
+
+static KeySym UK4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_R1, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_R2, NoSymbol, /* 22*/
+ XK_Break, XK_Scroll_Lock, XK_R3, NoSymbol, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, XK_brokenbar, NoSymbol, /* 30*/
+ XK_2, XK_at, NoSymbol, NoSymbol, /* 31*/
+ XK_3, XK_sterling, XK_numbersign, NoSymbol, /* 32*/
+ XK_4, XK_dollar, NoSymbol, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_asciicircum, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_ampersand, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_asterisk, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenleft, NoSymbol, NoSymbol, /* 38*/
+ XK_0, XK_parenright, NoSymbol, NoSymbol, /* 39*/
+ XK_minus, XK_underscore, XK_notsign, NoSymbol, /* 40*/
+ XK_equal, XK_plus, NoSymbol, NoSymbol, /* 41*/
+ XK_grave, XK_asciitilde, XK_acute, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, NoSymbol, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol, /* 64*/
+ XK_bracketright,XK_braceright, NoSymbol, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R9, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_semicolon, XK_colon, NoSymbol, NoSymbol, /* 86*/
+ XK_apostrophe, XK_quotedbl, XK_acute, NoSymbol, /* 87*/
+ XK_backslash, XK_bar, NoSymbol, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R10, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R11, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R12, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_less, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_greater, NoSymbol, NoSymbol, /*108*/
+ XK_slash, XK_question, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define UK4Modmap Generic5Modmap
+
+#else
+
+#define UK4Keymap NULL
+#define UK4Modmap NULL
+
+#endif /* UK4 */
+
+
+#ifdef UK5
+
+static KeySym UK5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_quotedbl, NoSymbol, NoSymbol, /* 31*/
+ XK_3, XK_sterling, NoSymbol, NoSymbol, /* 32*/
+ XK_4, XK_dollar, NoSymbol, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_asciicircum, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_ampersand, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_asterisk, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenleft, NoSymbol, NoSymbol, /* 38*/
+ XK_0, XK_parenright, NoSymbol, NoSymbol, /* 39*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /* 40*/
+ XK_equal, XK_plus, NoSymbol, NoSymbol, /* 41*/
+ XK_grave, XK_notsign, XK_brokenbar, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol, /* 64*/
+ XK_bracketright,XK_braceright, NoSymbol, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_semicolon, XK_colon, NoSymbol, NoSymbol, /* 86*/
+ XK_apostrophe, XK_at, XK_acute, NoSymbol, /* 87*/
+ XK_numbersign, XK_asciitilde, NoSymbol, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_less, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_greater, NoSymbol, NoSymbol, /*108*/
+ XK_slash, XK_question, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ XK_backslash, XK_bar, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define UK5Modmap Generic5Modmap
+
+#else
+
+#define UK5Keymap NULL
+#define UK5Modmap NULL
+
+#endif /* UK5 */
+
+
+#ifdef US101A
+
+static KeySym US101AKeymap[] = {
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 25*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_at, NoSymbol, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, NoSymbol, NoSymbol, /* 32*/
+ XK_4, XK_dollar, NoSymbol, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_asciicircum, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_ampersand, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_asterisk, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenleft, NoSymbol, NoSymbol, /* 38*/
+ XK_0, XK_parenright, NoSymbol, NoSymbol, /* 39*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /* 40*/
+ XK_equal, XK_plus, NoSymbol, NoSymbol, /* 41*/
+ XK_grave, XK_asciitilde, XK_acute, NoSymbol, /* 42*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol, /* 64*/
+ XK_bracketright,XK_braceright, NoSymbol, NoSymbol, /* 65*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 72*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_semicolon, XK_colon, NoSymbol, NoSymbol, /* 86*/
+ XK_apostrophe, XK_quotedbl, XK_acute, NoSymbol, /* 87*/
+ XK_backslash, XK_bar, NoSymbol, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_less, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_greater, NoSymbol, NoSymbol, /*108*/
+ XK_slash, XK_question, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+static SunModmapRec US101AModmap[] = {
+ { 99, ShiftMask },
+ { 110, ShiftMask },
+ { 119, LockMask },
+ { 76, ControlMask },
+ { 122, Meta_Mask },
+ { 98, Num_Lock_Mask },
+ { 120, Alt_Mask },
+ { 0, 0 }
+};
+
+#else
+
+#define US101AKeymap NULL
+#define US101AModmap NULL
+
+#endif /* US101A */
+
+
+#ifdef US4
+
+static KeySym US4Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_R1, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_R2, NoSymbol, /* 22*/
+ XK_Break, XK_Scroll_Lock, XK_R3, NoSymbol, /* 23*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_at, NoSymbol, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, NoSymbol, NoSymbol, /* 32*/
+ XK_4, XK_dollar, NoSymbol, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_asciicircum, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_ampersand, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_asterisk, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenleft, NoSymbol, NoSymbol, /* 38*/
+ XK_0, XK_parenright, NoSymbol, NoSymbol, /* 39*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /* 40*/
+ XK_equal, XK_plus, NoSymbol, NoSymbol, /* 41*/
+ XK_grave, XK_asciitilde, XK_acute, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ XK_KP_Equal, NoSymbol, XK_R4, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, XK_R5, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, XK_R6, NoSymbol, /* 47*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol, /* 64*/
+ XK_bracketright,XK_braceright, NoSymbol, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, XK_R7, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, XK_R8, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, XK_R9, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_semicolon, XK_colon, NoSymbol, NoSymbol, /* 86*/
+ XK_apostrophe, XK_quotedbl, XK_acute, NoSymbol, /* 87*/
+ XK_backslash, XK_bar, NoSymbol, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, XK_R10, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, XK_R11, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, XK_R12, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_less, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_greater, NoSymbol, NoSymbol, /*108*/
+ XK_slash, XK_question, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ XK_Linefeed, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, XK_R13, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, XK_R14, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, XK_R15, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, XK_Help, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define US4Modmap Generic5Modmap
+
+#else
+
+#define US4Keymap NULL
+#define US4Modmap NULL
+
+#endif /* US4 */
+
+
+#ifdef US5
+
+static KeySym US5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_at, NoSymbol, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, NoSymbol, NoSymbol, /* 32*/
+ XK_4, XK_dollar, NoSymbol, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_asciicircum, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_ampersand, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_asterisk, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenleft, NoSymbol, NoSymbol, /* 38*/
+ XK_0, XK_parenright, NoSymbol, NoSymbol, /* 39*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /* 40*/
+ XK_equal, XK_plus, NoSymbol, NoSymbol, /* 41*/
+ XK_grave, XK_asciitilde, XK_acute, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol, /* 64*/
+ XK_bracketright,XK_braceright, NoSymbol, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_semicolon, XK_colon, NoSymbol, NoSymbol, /* 86*/
+ XK_apostrophe, XK_quotedbl, XK_acute, NoSymbol, /* 87*/
+ XK_backslash, XK_bar, NoSymbol, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_less, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_greater, NoSymbol, NoSymbol, /*108*/
+ XK_slash, XK_question, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define US5Modmap Generic5Modmap
+
+#else
+
+#define US5Keymap NULL
+#define US5Modmap NULL
+
+#endif /* US5 */
+
+#ifdef US_UNIX5
+
+static KeySym US_UNIX5Keymap[] = {
+ SunXK_Stop, NoSymbol, XK_L1, NoSymbol, /* 1*/
+ SunXK_AudioLowerVolume,SunXK_VideoLowerBrightness,NoSymbol, NoSymbol, /* 2*/
+ SunXK_Again, NoSymbol, XK_L2, NoSymbol, /* 3*/
+ SunXK_AudioRaiseVolume,SunXK_VideoRaiseBrightness,NoSymbol, NoSymbol, /* 4*/
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 5*/
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 6*/
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 7*/
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 8*/
+ XK_F11, NoSymbol, SunXK_F36, NoSymbol, /* 9*/
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 10*/
+ XK_F12, NoSymbol, SunXK_F37, NoSymbol, /* 11*/
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 12*/
+ SunXK_AltGraph, NoSymbol, NoSymbol, NoSymbol, /* 13*/
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 14*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 15*/
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 16*/
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 17*/
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 18*/
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 19*/
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 20*/
+ XK_Pause, NoSymbol, XK_Break, NoSymbol, /* 21*/
+ XK_Print, NoSymbol, XK_Sys_Req, SunXK_Sys_Req, /* 22*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, /* 23*/
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 24*/
+ SunXK_Props, NoSymbol, XK_L3, NoSymbol, /* 25*/
+ SunXK_Undo, NoSymbol, XK_L4, NoSymbol, /* 26*/
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 27*/
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 28*/
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 29*/
+ XK_1, XK_exclam, NoSymbol, NoSymbol, /* 30*/
+ XK_2, XK_at, NoSymbol, NoSymbol, /* 31*/
+ XK_3, XK_numbersign, NoSymbol, NoSymbol, /* 32*/
+ XK_4, XK_dollar, NoSymbol, NoSymbol, /* 33*/
+ XK_5, XK_percent, NoSymbol, NoSymbol, /* 34*/
+ XK_6, XK_asciicircum, NoSymbol, NoSymbol, /* 35*/
+ XK_7, XK_ampersand, NoSymbol, NoSymbol, /* 36*/
+ XK_8, XK_asterisk, NoSymbol, NoSymbol, /* 37*/
+ XK_9, XK_parenleft, NoSymbol, NoSymbol, /* 38*/
+ XK_0, XK_parenright, NoSymbol, NoSymbol, /* 39*/
+ XK_minus, XK_underscore, NoSymbol, NoSymbol, /* 40*/
+ XK_equal, XK_plus, NoSymbol, NoSymbol, /* 41*/
+ XK_grave, XK_asciitilde, XK_acute, NoSymbol, /* 42*/
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 43*/
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 44*/
+ SunXK_AudioMute,SunXK_VideoDegauss,NoSymbol, NoSymbol, /* 45*/
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 46*/
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 47*/
+ SunXK_PowerSwitch,SunXK_PowerSwitchShift, NoSymbol, NoSymbol, /* 48*/
+ SunXK_Front, NoSymbol, XK_L5, NoSymbol, /* 49*/
+ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, /* 50*/
+ SunXK_Copy, NoSymbol, XK_L6, NoSymbol, /* 51*/
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 52*/
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 53*/
+ XK_Q, NoSymbol, NoSymbol, NoSymbol, /* 54*/
+ XK_W, NoSymbol, NoSymbol, NoSymbol, /* 55*/
+ XK_E, NoSymbol, NoSymbol, NoSymbol, /* 56*/
+ XK_R, NoSymbol, NoSymbol, NoSymbol, /* 57*/
+ XK_T, NoSymbol, NoSymbol, NoSymbol, /* 58*/
+ XK_Y, NoSymbol, NoSymbol, NoSymbol, /* 59*/
+ XK_U, NoSymbol, NoSymbol, NoSymbol, /* 60*/
+ XK_I, NoSymbol, NoSymbol, NoSymbol, /* 61*/
+ XK_O, NoSymbol, NoSymbol, NoSymbol, /* 62*/
+ XK_P, NoSymbol, NoSymbol, NoSymbol, /* 63*/
+ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol, /* 64*/
+ XK_bracketright,XK_braceright, NoSymbol, NoSymbol, /* 65*/
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 66*/
+ SunXK_Compose, NoSymbol, NoSymbol, NoSymbol, /* 67*/
+ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, /* 68*/
+ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, /* 69*/
+ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, /* 70*/
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 71*/
+ SunXK_Open, NoSymbol, XK_L7, NoSymbol, /* 72*/
+ SunXK_Paste, NoSymbol, XK_L8, NoSymbol, /* 73*/
+ XK_End, NoSymbol, NoSymbol, NoSymbol, /* 74*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 75*/
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 76*/
+ XK_A, NoSymbol, NoSymbol, NoSymbol, /* 77*/
+ XK_S, NoSymbol, NoSymbol, NoSymbol, /* 78*/
+ XK_D, NoSymbol, NoSymbol, NoSymbol, /* 79*/
+ XK_F, NoSymbol, NoSymbol, NoSymbol, /* 80*/
+ XK_G, NoSymbol, NoSymbol, NoSymbol, /* 81*/
+ XK_H, NoSymbol, NoSymbol, NoSymbol, /* 82*/
+ XK_J, NoSymbol, NoSymbol, NoSymbol, /* 83*/
+ XK_K, NoSymbol, NoSymbol, NoSymbol, /* 84*/
+ XK_L, NoSymbol, NoSymbol, NoSymbol, /* 85*/
+ XK_semicolon, XK_colon, NoSymbol, NoSymbol, /* 86*/
+ XK_apostrophe, XK_quotedbl, XK_acute, NoSymbol, /* 87*/
+ XK_backslash, XK_bar, NoSymbol, NoSymbol, /* 88*/
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 89*/
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 90*/
+ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, /* 91*/
+ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, /* 92*/
+ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, /* 93*/
+ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, /* 94*/
+ SunXK_Find, NoSymbol, XK_L9, NoSymbol, /* 95*/
+ XK_Prior, NoSymbol, NoSymbol, NoSymbol, /* 96*/
+ SunXK_Cut, NoSymbol, XK_L10, NoSymbol, /* 97*/
+ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, /* 98*/
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 99*/
+ XK_Z, NoSymbol, NoSymbol, NoSymbol, /*100*/
+ XK_X, NoSymbol, NoSymbol, NoSymbol, /*101*/
+ XK_C, NoSymbol, NoSymbol, NoSymbol, /*102*/
+ XK_V, NoSymbol, NoSymbol, NoSymbol, /*103*/
+ XK_B, NoSymbol, NoSymbol, NoSymbol, /*104*/
+ XK_N, NoSymbol, NoSymbol, NoSymbol, /*105*/
+ XK_M, NoSymbol, NoSymbol, NoSymbol, /*106*/
+ XK_comma, XK_less, NoSymbol, NoSymbol, /*107*/
+ XK_period, XK_greater, NoSymbol, NoSymbol, /*108*/
+ XK_slash, XK_question, NoSymbol, NoSymbol, /*109*/
+ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, /*110*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*111*/
+ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, /*112*/
+ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, /*113*/
+ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, /*114*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*115*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*116*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*117*/
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /*118*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /*119*/
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /*120*/
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /*121*/
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /*122*/
+ XK_Next, NoSymbol, NoSymbol, NoSymbol, /*123*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*124*/
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /*125*/
+};
+
+#define US_UNIX5Modmap Generic5Modmap
+
+#else
+
+#define US_UNIX5Keymap NULL
+#define US_UNIX5Modmap NULL
+
+#endif /* US_UNIX5 */
+
+KeySym *sunType4KeyMaps[] = {
+ US4Keymap, /* 0 */
+ US4Keymap, /* 1 */
+ FranceBelg4Keymap, /* 2 */
+ Canada4Keymap, /* 3 */
+ Denmark4Keymap, /* 4 */
+ Germany4Keymap, /* 5 */
+ Italy4Keymap, /* 6 */
+ Netherland4Keymap, /* 7 */
+ Norway4Keymap, /* 8 */
+ Portugal4Keymap, /* 9 */
+ SpainLatAm4Keymap, /* 10 */
+ SwedenFin4Keymap, /* 11 */
+ SwissFr4Keymap, /* 12 */
+ SwissGe4Keymap, /* 13 */
+ UK4Keymap, /* 14 */
+ NULL, /* 15 */
+ Korea4Keymap, /* 16 */
+ Taiwan4Keymap, /* 17 */
+ NULL, /* 18 */
+ US101AKeymap, /* 19 */
+ NULL, /* 20 */
+ NULL, /* 21 */
+ NULL, /* 22 */
+ NULL, /* 23 */
+ NULL, /* 24 */
+ NULL, /* 25 */
+ NULL, /* 26 */
+ NULL, /* 27 */
+ NULL, /* 28 */
+ NULL, /* 29 */
+ NULL, /* 30 */
+ NULL, /* 31 */
+ Japan4Keymap, /* 32 */
+ US5Keymap, /* 33 */
+ US_UNIX5Keymap, /* 34 */
+ France5Keymap, /* 35 */
+ Denmark5Keymap, /* 36 */
+ Germany5Keymap, /* 37 */
+ Italy5Keymap, /* 38 */
+ Netherland5Keymap, /* 39 */
+ Norway5Keymap, /* 40 */
+ Portugal5Keymap, /* 41 */
+ Spain5Keymap, /* 42 */
+ Sweden5Keymap, /* 43 */
+ SwissFr5Keymap, /* 44 */
+ SwissGe5Keymap, /* 45 */
+ UK5Keymap, /* 46 */
+ Korea5Keymap, /* 47 */
+ Taiwan5Keymap, /* 48 */
+ Japan5Keymap, /* 49 */
+ CanadaFr5Keymap, /* 50 */
+ NULL, /* Hungary5 */ /* 51 */
+ NULL, /* Poland5 */ /* 52 */
+ NULL, /* Czech5 */ /* 53 */
+ NULL, /* Russia5 */ /* 54 */
+ NULL, /* 55 */
+ NULL, /* 56 */
+ NULL, /* 57 */
+ NULL, /* 58 */
+ NULL, /* 59 */
+ NULL, /* 60 */
+ NULL, /* 61 */
+ NULL, /* 62 */
+ NULL, /* CanadaFr5+ */ /* 63 */
+ NULL, /* 64 */
+ NULL, /* 65 */
+ NULL, /* 66 */
+ NULL, /* 67 */
+ NULL, /* 68 */
+ NULL, /* 69 */
+ NULL, /* 70 */
+ NULL, /* 71 */
+ NULL, /* 72 */
+ NULL, /* 73 */
+ NULL, /* 74 */
+ NULL, /* 75 */
+ NULL, /* 76 */
+ NULL, /* 77 */
+ NULL, /* 78 */
+ NULL, /* 79 */
+/*
+ * We're punting on SPARC Voyager support for now. The OpenLook server
+ * apparently adds special semantics to Num_Lock, which requires indexing
+ * into column 5 of the keymap, which isn't handled by the core protocol
+ * at all, (it is in XKB.) We could do some tricky remapping, sort of
+ * like what the PC ddxen need to do to deal with funky PC keyboards; but
+ * for now we'll just pretend that Voyager (Hobo) keyboards are the same
+ * as the equivalent Sun5 keyboard.
+ */
+ US5Keymap, /* 80 */
+ US_UNIX5Keymap, /* 81 */
+ France5Keymap, /* 82 */
+ Denmark5Keymap, /* 83 */
+ Germany5Keymap, /* 84 */
+ Italy5Keymap, /* 85 */
+ Netherland5Keymap, /* 86 */
+ Norway5Keymap, /* 87 */
+ Portugal5Keymap, /* 88 */
+ Spain5Keymap, /* 89 */
+ Sweden5Keymap, /* 90 */
+ SwissFr5Keymap, /* 91 */
+ SwissGe5Keymap, /* 92 */
+ UK5Keymap, /* 93 */
+ Korea5Keymap, /* 94 */
+ Taiwan5Keymap, /* 95 */
+ Japan5Keymap, /* 96 */
+ CanadaFr5Keymap, /* 97 */
+};
+
+int sunMaxLayout = sizeof(sunType4KeyMaps) / sizeof(sunType4KeyMaps[0]);
+
+SunModmapRec *sunType4ModMaps[] = {
+ US4Modmap, /* 0 */
+ US4Modmap, /* 1 */
+ FranceBelg4Modmap, /* 2 */
+ Canada4Modmap, /* 3 */
+ Denmark4Modmap, /* 4 */
+ Germany4Modmap, /* 5 */
+ Italy4Modmap, /* 6 */
+ Netherland4Modmap, /* 7 */
+ Norway4Modmap, /* 8 */
+ Portugal4Modmap, /* 9 */
+ SpainLatAm4Modmap, /* 10 */
+ SwedenFin4Modmap, /* 11 */
+ SwissFr4Modmap, /* 12 */
+ SwissGe4Modmap, /* 13 */
+ UK4Modmap, /* 14 */
+ NULL, /* 15 */
+ Korea4Modmap, /* 16 */
+ Taiwan4Modmap, /* 17 */
+ NULL, /* 18 */
+ US101AModmap, /* 19 */
+ NULL, /* 20 */
+ NULL, /* 21 */
+ NULL, /* 22 */
+ NULL, /* 23 */
+ NULL, /* 24 */
+ NULL, /* 25 */
+ NULL, /* 26 */
+ NULL, /* 27 */
+ NULL, /* 28 */
+ NULL, /* 29 */
+ NULL, /* 30 */
+ NULL, /* 31 */
+ Japan4Modmap, /* 32 */
+ US5Modmap, /* 33 */
+ US_UNIX5Modmap, /* 34 */
+ France5Modmap, /* 35 */
+ Denmark5Modmap, /* 36 */
+ Germany5Modmap, /* 37 */
+ Italy5Modmap, /* 38 */
+ Netherland5Modmap, /* 39 */
+ Norway5Modmap, /* 40 */
+ Portugal5Modmap, /* 41 */
+ Spain5Modmap, /* 42 */
+ Sweden5Modmap, /* 43 */
+ SwissFr5Modmap, /* 44 */
+ SwissGe5Modmap, /* 45 */
+ UK5Modmap, /* 46 */
+ Korea5Modmap, /* 47 */
+ Taiwan5Modmap, /* 48 */
+ Japan5Modmap, /* 49 */
+ CanadaFr5Modmap, /* 50 */
+ NULL, /* Hungary5 */ /* 51 */
+ NULL, /* Poland5 */ /* 52 */
+ NULL, /* Czech5 */ /* 53 */
+ NULL, /* Russia5 */ /* 54 */
+ NULL, /* 55 */
+ NULL, /* 56 */
+ NULL, /* 57 */
+ NULL, /* 58 */
+ NULL, /* 59 */
+ NULL, /* 60 */
+ NULL, /* 61 */
+ NULL, /* 62 */
+ NULL, /* CanadaFr5+ */ /* 63 */
+ NULL, /* 64 */
+ NULL, /* 65 */
+ NULL, /* 66 */
+ NULL, /* 67 */
+ NULL, /* 68 */
+ NULL, /* 69 */
+ NULL, /* 70 */
+ NULL, /* 71 */
+ NULL, /* 72 */
+ NULL, /* 73 */
+ NULL, /* 74 */
+ NULL, /* 75 */
+ NULL, /* 76 */
+ NULL, /* 77 */
+ NULL, /* 78 */
+ NULL, /* 79 */
+ US5Modmap, /* 80 */
+ US_UNIX5Modmap, /* 81 */
+ France5Modmap, /* 82 */
+ Denmark5Modmap, /* 83 */
+ Germany5Modmap, /* 84 */
+ Italy5Modmap, /* 85 */
+ Netherland5Modmap, /* 86 */
+ Norway5Modmap, /* 87 */
+ Portugal5Modmap, /* 88 */
+ Spain5Modmap, /* 89 */
+ Sweden5Modmap, /* 90 */
+ SwissFr5Modmap, /* 91 */
+ SwissGe5Modmap, /* 92 */
+ UK5Modmap, /* 93 */
+ Korea5Modmap, /* 94 */
+ Taiwan5Modmap, /* 95 */
+ Japan5Modmap, /* 96 */
+ CanadaFr5Modmap, /* 97 */
+};
diff --git a/nx-X11/programs/Xserver/hw/sun/sunMfb.c b/nx-X11/programs/Xserver/hw/sun/sunMfb.c
new file mode 100644
index 000000000..fa8eb70db
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/sunMfb.c
@@ -0,0 +1,108 @@
+
+/* $Xorg: sunMfb.c,v 1.4 2001/02/09 02:04:44 xorgcvs Exp $ */
+
+/*
+Copyright 1990, 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+/* $XFree86: xc/programs/Xserver/hw/sun/sunMfb.c,v 3.3 2001/01/17 22:36:51 dawes Exp $ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*
+ * Copyright 1987 by the Regents of the University of California
+ * Copyright 1987 by Adam de Boor, UC Berkeley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/****************************************************************/
+/* Modified from sunCG4C.c for X11R3 by Tom Jarmolowski */
+/****************************************************************/
+
+/*
+ * Copyright 1991, 1992, 1993 Kaleb S. Keithley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. Kaleb S. Keithley makes no
+ * representations about the suitability of this software for
+ * any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#include "sun.h"
+#include "mfb.h"
+
+Bool sunBW2Init (screen, pScreen, argc, argv)
+ int screen; /* what screen am I going to be */
+ ScreenPtr pScreen; /* The Screen to initialize */
+ int argc; /* The number of the Server's arguments. */
+ char **argv; /* The arguments themselves. Don't change! */
+{
+ sunFbs[screen].EnterLeave = (void (*)())NoopDDA;
+ if (sunFlipPixels) {
+ pScreen->whitePixel = 1;
+ pScreen->blackPixel = 0;
+ } else {
+ pScreen->whitePixel = 0;
+ pScreen->blackPixel = 1;
+ }
+ return sunInitCommon (screen, pScreen, (off_t) 0,
+ mfbScreenInit, NULL,
+ mfbCreateDefColormap, sunSaveScreen, 0);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/sun/sunMouse.c b/nx-X11/programs/Xserver/hw/sun/sunMouse.c
new file mode 100644
index 000000000..aad46e3d7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/sunMouse.c
@@ -0,0 +1,399 @@
+/* $Xorg: sunMouse.c,v 1.3 2000/08/17 19:48:32 cpqbld Exp $ */
+/*-
+ * Copyright 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/*
+ * Copyright 1991, 1992, 1993 Kaleb S. Keithley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. Kaleb S. Keithley makes no
+ * representations about the suitability of this software for
+ * any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+/* $XFree86: xc/programs/Xserver/hw/sun/sunMouse.c,v 1.3 2001/10/28 03:33:12 tsi Exp $ */
+
+#define NEED_EVENTS
+#include "sun.h"
+#include "mi.h"
+
+Bool sunActiveZaphod = TRUE;
+
+static Bool sunCursorOffScreen();
+static void sunCrossScreen();
+static void sunWarpCursor();
+
+miPointerScreenFuncRec sunPointerScreenFuncs = {
+ sunCursorOffScreen,
+ sunCrossScreen,
+ sunWarpCursor,
+};
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunMouseCtrl --
+ * Alter the control parameters for the mouse. Since acceleration
+ * etc. is done from the PtrCtrl record in the mouse's device record,
+ * there's nothing to do here.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------
+ */
+/*ARGSUSED*/
+static
+void sunMouseCtrl (
+ DeviceIntPtr device,
+ PtrCtrl* ctrl)
+{
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunMouseProc --
+ * Handle the initialization, etc. of a mouse
+ *
+ * Results:
+ * none.
+ *
+ * Side Effects:
+ *
+ * Note:
+ * When using sunwindows, all input comes off a single fd, stored in the
+ * global windowFd. Therefore, only one device should be enabled and
+ * disabled, even though the application still sees both mouse and
+ * keyboard. We have arbitrarily chosen to enable and disable windowFd
+ * in the keyboard routine sunKbdProc rather than in sunMouseProc.
+ *
+ *-----------------------------------------------------------------------
+ */
+int sunMouseProc (
+ DeviceIntPtr device,
+ int what)
+{
+ DevicePtr pMouse = (DevicePtr) device;
+ int format;
+ static int oformat;
+ BYTE map[4];
+
+ switch (what) {
+ case DEVICE_INIT:
+ if (pMouse != LookupPointerDevice()) {
+ ErrorF ("Cannot open non-system mouse");
+ return !Success;
+ }
+ if (sunPtrPriv.fd == -1)
+ return !Success;
+ pMouse->devicePrivate = (pointer) &sunPtrPriv;
+ pMouse->on = FALSE;
+ map[1] = 1;
+ map[2] = 2;
+ map[3] = 3;
+ InitPointerDeviceStruct(
+ pMouse, map, 3, miPointerGetMotionEvents,
+ sunMouseCtrl, miPointerGetMotionBufferSize());
+ break;
+
+ case DEVICE_ON:
+ if (ioctl (sunPtrPriv.fd, VUIDGFORMAT, &oformat) == -1) {
+ Error ("sunMouseProc ioctl VUIDGFORMAT");
+ return !Success;
+ }
+ format = VUID_FIRM_EVENT;
+ if (ioctl (sunPtrPriv.fd, VUIDSFORMAT, &format) == -1) {
+ Error ("sunMouseProc ioctl VUIDSFORMAT");
+ return !Success;
+ }
+ sunPtrPriv.bmask = 0;
+ AddEnabledDevice (sunPtrPriv.fd);
+ pMouse->on = TRUE;
+ break;
+
+ case DEVICE_CLOSE:
+ pMouse->on = FALSE;
+ if (ioctl (sunPtrPriv.fd, VUIDSFORMAT, &oformat) == -1)
+ Error ("sunMouseProc ioctl VUIDSFORMAT");
+ break;
+
+ case DEVICE_OFF:
+ pMouse->on = FALSE;
+ RemoveEnabledDevice (sunPtrPriv.fd);
+ break;
+ }
+ return Success;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunMouseGetEvents --
+ * Return the events waiting in the wings for the given mouse.
+ *
+ * Results:
+ * A pointer to an array of Firm_events or (Firm_event *)0 if no events
+ * The number of events contained in the array.
+ * A boolean as to whether more events might be available.
+ *
+ * Side Effects:
+ * None.
+ *-----------------------------------------------------------------------
+ */
+
+Firm_event* sunMouseGetEvents (
+ int fd,
+ Bool on,
+ int* pNumEvents,
+ Bool* pAgain)
+{
+ int nBytes; /* number of bytes of events available. */
+ static Firm_event evBuf[MAXEVENTS]; /* Buffer for Firm_events */
+
+ if ((nBytes = read (fd, (char *)evBuf, sizeof(evBuf))) == -1) {
+ if (errno == EWOULDBLOCK) {
+ *pNumEvents = 0;
+ *pAgain = FALSE;
+ } else {
+ Error ("sunMouseGetEvents read");
+ FatalError ("Could not read from mouse");
+ }
+ } else {
+ if (on) {
+ *pNumEvents = nBytes / sizeof (Firm_event);
+ *pAgain = (nBytes == sizeof (evBuf));
+ } else {
+ *pNumEvents = 0;
+ *pAgain = FALSE;
+ }
+ }
+ return evBuf;
+}
+
+
+/*-
+ *-----------------------------------------------------------------------
+ * MouseAccelerate --
+ * Given a delta and a mouse, return the acceleration of the delta.
+ *
+ * Results:
+ * The corrected delta
+ *
+ * Side Effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------
+ */
+static short
+MouseAccelerate (device, delta)
+ DeviceIntPtr device;
+ int delta;
+{
+ int sgn = sign(delta);
+ PtrCtrl *pCtrl;
+ short ret;
+
+ delta = abs(delta);
+ pCtrl = &device->ptrfeed->ctrl;
+ if (delta > pCtrl->threshold) {
+ ret =
+ (short) sgn *
+ (pCtrl->threshold + ((delta - pCtrl->threshold) * pCtrl->num) /
+ pCtrl->den);
+ } else {
+ ret = (short) sgn * delta;
+ }
+ return ret;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunMouseEnqueueEvent --
+ * Given a Firm_event for a mouse, pass it off the the dix layer
+ * properly converted...
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * The cursor may be redrawn...? devPrivate/x/y will be altered.
+ *
+ *-----------------------------------------------------------------------
+ */
+
+void sunMouseEnqueueEvent (
+ DeviceIntPtr device,
+ Firm_event *fe)
+{
+ xEvent xE;
+ sunPtrPrivPtr pPriv; /* Private data for pointer */
+ int bmask; /* Temporary button mask */
+ unsigned long time;
+ int x, y;
+
+ pPriv = (sunPtrPrivPtr)device->public.devicePrivate;
+
+ time = xE.u.keyButtonPointer.time = TVTOMILLI(fe->time);
+
+ switch (fe->id) {
+ case MS_LEFT:
+ case MS_MIDDLE:
+ case MS_RIGHT:
+ /*
+ * A button changed state. Sometimes we will get two events
+ * for a single state change. Should we get a button event which
+ * reflects the current state of affairs, that event is discarded.
+ *
+ * Mouse buttons start at 1.
+ */
+ xE.u.u.detail = (fe->id - MS_LEFT) + 1;
+ bmask = 1 << xE.u.u.detail;
+ if (fe->value == VKEY_UP) {
+ if (pPriv->bmask & bmask) {
+ xE.u.u.type = ButtonRelease;
+ pPriv->bmask &= ~bmask;
+ } else {
+ return;
+ }
+ } else {
+ if ((pPriv->bmask & bmask) == 0) {
+ xE.u.u.type = ButtonPress;
+ pPriv->bmask |= bmask;
+ } else {
+ return;
+ }
+ }
+ mieqEnqueue (&xE);
+ break;
+ case LOC_X_DELTA:
+ miPointerDeltaCursor (MouseAccelerate(device,fe->value),0,time);
+ break;
+ case LOC_Y_DELTA:
+ /*
+ * For some reason, motion up generates a positive y delta
+ * and motion down a negative delta, so we must subtract
+ * here instead of add...
+ */
+ miPointerDeltaCursor (0,-MouseAccelerate(device,fe->value),time);
+ break;
+ case LOC_X_ABSOLUTE:
+ miPointerPosition (&x, &y);
+ miPointerAbsoluteCursor (fe->value, y, time);
+ break;
+ case LOC_Y_ABSOLUTE:
+ miPointerPosition (&x, &y);
+ miPointerAbsoluteCursor (x, fe->value, time);
+ break;
+ default:
+ FatalError ("sunMouseEnqueueEvent: unrecognized id\n");
+ break;
+ }
+}
+
+/*ARGSUSED*/
+static Bool
+sunCursorOffScreen (pScreen, x, y)
+ ScreenPtr *pScreen;
+ int *x, *y;
+{
+ int index, ret = FALSE;
+ extern Bool PointerConfinedToScreen();
+
+ if (PointerConfinedToScreen()) return TRUE;
+ /*
+ * Active Zaphod implementation:
+ * increment or decrement the current screen
+ * if the x is to the right or the left of
+ * the current screen.
+ */
+ if (sunActiveZaphod &&
+ screenInfo.numScreens > 1 && (*x >= (*pScreen)->width || *x < 0)) {
+ index = (*pScreen)->myNum;
+ if (*x < 0) {
+ index = (index ? index : screenInfo.numScreens) - 1;
+ *pScreen = screenInfo.screens[index];
+ *x += (*pScreen)->width;
+ } else {
+ *x -= (*pScreen)->width;
+ index = (index + 1) % screenInfo.numScreens;
+ *pScreen = screenInfo.screens[index];
+ }
+ ret = TRUE;
+ }
+ return ret;
+}
+
+static void
+sunCrossScreen (pScreen, entering)
+ ScreenPtr pScreen;
+ Bool entering;
+{
+ if (sunFbs[pScreen->myNum].EnterLeave)
+ (*sunFbs[pScreen->myNum].EnterLeave) (pScreen, entering ? 0 : 1);
+}
+
+static void
+sunWarpCursor (pScreen, x, y)
+ ScreenPtr pScreen;
+ int x, y;
+{
+#ifndef i386
+ sigset_t newsigmask;
+
+ (void) sigemptyset (&newsigmask);
+#ifdef SVR4
+ (void) sigaddset (&newsigmask, SIGPOLL);
+#else
+ (void) sigaddset (&newsigmask, SIGIO);
+#endif
+ (void) sigprocmask (SIG_BLOCK, &newsigmask, (sigset_t *)NULL);
+ miPointerWarpCursor (pScreen, x, y);
+ (void) sigprocmask (SIG_UNBLOCK, &newsigmask, (sigset_t *)NULL);
+#else
+ int oldmask;
+
+ oldmask = sigblock (sigmask (SIGIO));
+ miPointerWarpCursor (pScreen, x, y);
+ sigsetmask (oldmask);
+#endif
+}
diff --git a/nx-X11/programs/Xserver/hw/sun/sunMultiDepth.c b/nx-X11/programs/Xserver/hw/sun/sunMultiDepth.c
new file mode 100644
index 000000000..a8adf353f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sun/sunMultiDepth.c
@@ -0,0 +1,277 @@
+/* $Xorg: sunMultiDepth.c,v 1.4 2001/02/09 02:04:44 xorgcvs Exp $ */
+/*
+
+Copyright 1992, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/* $XFree86: xc/programs/Xserver/hw/sun/sunMultiDepth.c,v 1.5 2001/01/17 22:36:51 dawes Exp $ */
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "resource.h"
+#include "colormap.h"
+#include "colormapst.h"
+#include "mi.h"
+#include "mistruct.h"
+#include "dix.h"
+#include "gcstruct.h"
+#include "mibstore.h"
+
+#ifndef SINGLEDEPTH
+
+static Bool
+sunCfbCreateGC(pGC)
+ GCPtr pGC;
+{
+ if (pGC->depth == 1)
+ {
+ return mfbCreateGC (pGC);
+ }
+ else if (pGC->depth <= 8)
+ {
+ return cfbCreateGC (pGC);
+ }
+ else if (pGC->depth <= 16)
+ {
+ return cfb16CreateGC (pGC);
+ }
+ else if (pGC->depth <= 32)
+ {
+ return cfb32CreateGC (pGC);
+ }
+ return FALSE;
+}
+
+static void
+sunCfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart)
+ DrawablePtr pDrawable; /* drawable from which to get bits */
+ int wMax; /* largest value of all *pwidths */
+ register DDXPointPtr ppt; /* points to start copying from */
+ int *pwidth; /* list of number of bits to copy */
+ int nspans; /* number of scanlines to copy */
+ char *pdstStart; /* where to put the bits */
+{
+ switch (pDrawable->bitsPerPixel) {
+ case 1:
+ mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+ break;
+ case 8:
+ cfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+ break;
+ case 16:
+ cfb16GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+ break;
+ case 32:
+ cfb32GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+ break;
+ }
+ return;
+}
+
+static void
+sunCfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine)
+ DrawablePtr pDrawable;
+ int sx, sy, w, h;
+ unsigned int format;
+ unsigned long planeMask;
+ char *pdstLine;
+{
+ switch (pDrawable->bitsPerPixel)
+ {
+ case 1:
+ mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+ break;
+ case 8:
+ cfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+ break;
+ case 16:
+ cfb16GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+ break;
+ case 32:
+ cfb32GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+ break;
+ }
+}
+
+Bool
+sunCfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp; /* bits per pixel of root */
+{
+ extern int cfbWindowPrivateIndex;
+ extern int cfbGCPrivateIndex;
+ int ret;
+
+ sunRegisterPixmapFormat( /* depth */ 1, /* bits per pixel */ 1);
+ sunRegisterPixmapFormat( /* depth */ 8, /* bits per pixel */ 8);
+ sunRegisterPixmapFormat( /* depth */ 12, /* bits per pixel */ 16);
+ sunRegisterPixmapFormat( /* depth */ 24, /* bits per pixel */ 32);
+
+ switch (bpp) {
+ case 8:
+ ret = cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
+ break;
+ case 16:
+ ret = cfb16SetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
+ break;
+ case 32:
+ ret = cfb32SetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
+ break;
+ default:
+ return FALSE;
+ }
+ pScreen->CreateGC = sunCfbCreateGC;
+ pScreen->GetImage = sunCfbGetImage;
+ pScreen->GetSpans = sunCfbGetSpans;
+ return ret;
+}
+
+extern BSFuncRec cfbBSFuncRec, cfb16BSFuncRec, cfb32BSFuncRec;
+extern int cfb16ScreenPrivateIndex, cfb32ScreenPrivateIndex;
+extern Bool cfbCloseScreen(), cfb16CloseScreen(), cfb32CloseScreen();
+
+Bool
+sunCfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp;
+{
+ int i;
+ pointer oldDevPrivate;
+ VisualPtr visuals;
+ int nvisuals;
+ DepthPtr depths;
+ int ndepths;
+ VisualID defaultVisual;
+ int rootdepth;
+
+ if (!cfbInitVisuals(&visuals, &depths, &nvisuals, &ndepths,
+ &rootdepth, &defaultVisual, 1 << (bpp - 1), 8))
+ return FALSE;
+ oldDevPrivate = pScreen->devPrivate;
+ if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
+ rootdepth, ndepths, depths,
+ defaultVisual, nvisuals, visuals))
+ return FALSE;
+ switch (bpp)
+ {
+ case 8:
+ pScreen->CloseScreen = cfbCloseScreen;
+ pScreen->BackingStoreFuncs = cfbBSFuncRec;
+ break;
+ case 16:
+ pScreen->CloseScreen = cfb16CloseScreen;
+ pScreen->devPrivates[cfb16ScreenPrivateIndex].ptr =
+ pScreen->devPrivate;
+ pScreen->devPrivate = oldDevPrivate;
+ pScreen->BackingStoreFuncs = cfb16BSFuncRec;
+ break;
+ case 32:
+ pScreen->CloseScreen = cfb32CloseScreen;
+ pScreen->devPrivates[cfb32ScreenPrivateIndex].ptr =
+ pScreen->devPrivate;
+ pScreen->devPrivate = oldDevPrivate;
+ pScreen->BackingStoreFuncs = cfb32BSFuncRec;
+ break;
+ }
+ return TRUE;
+}
+
+
+Bool
+sunCfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp;
+{
+ if (!sunCfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy,
+ width, bpp))
+ return FALSE;
+ return sunCfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix,
+ dpiy, width, bpp);
+}
+
+
+#else /* SINGLEDEPTH */
+
+/* stuff for 8-bit only server */
+
+Bool
+sunCfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp; /* bits per pixel of root */
+{
+ sunRegisterPixmapFormat( /* depth */ 1, /* bits per pixel */ 1);
+ sunRegisterPixmapFormat( /* depth */ 8, /* bits per pixel */ 8);
+ return cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy,
+ width);
+}
+
+Bool
+sunCfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp;
+{
+ return cfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy,
+ width);
+}
+
+Bool
+sunCfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp;
+{
+ sunRegisterPixmapFormat( /* depth */ 1, /* bits per pixel */ 1);
+ sunRegisterPixmapFormat( /* depth */ 8, /* bits per pixel */ 8);
+ return cfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
+}
+
+#endif /* SINGLEDEPTH */
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/Imakefile b/nx-X11/programs/Xserver/hw/sunLynx/Imakefile
new file mode 100644
index 000000000..e7e8e916c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/Imakefile
@@ -0,0 +1,78 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:36 cpqbld Exp $
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/hw/sunLynx/Imakefile,v 3.1 1996/12/27 06:51:30 dawes Exp $
+
+#include <Server.tmpl>
+
+SRCS1 = sunLyInit.c \
+ sunLyIo.c \
+ sunLyUtil.c \
+ sunLyMouse.c\
+ sunLyCfb.c \
+ sunLyFbs.c \
+ sunLyKbd.c \
+ sunCursor.c \
+ sunMfb.c \
+ sunGX.c \
+ sunKeyMap.c
+
+XCOMM SRCS = $(SRCS1) kbd_mode.c constype.c
+SRCS = $(SRCS1)
+
+#if XsunLynxMonoServer
+OFILES = sunInitMono.o sunInExMono.o
+#endif
+
+OBJS = sunLyInit.o \
+ sunLyIo.o \
+ sunLyUtil.o \
+ sunLyMouse.o\
+ sunLyCfb.o \
+ sunLyFbs.o \
+ sunLyKbd.o \
+ sunCursor.o \
+ sunMfb.o \
+ sunGX.o \
+ sunKeyMap.o
+
+ INCLUDES = -I. -I../.. -I../../mi -I../../mfb -I../../cfb -I../../cfb32 \
+ -I../../include -I../../os -I$(XINCLUDESRC) -I$(FONTINCSRC)
+ LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln \
+ ../mfb/llib-lmfb.ln ../mi/llib-lmi.ln ../cfb/llib-lcfb.ln
+
+NormalLibraryObjectRule()
+
+XCOMM all:: $(OFILES) kbd_mode constype
+all:: $(OFILES)
+
+lintlib:
+
+NormalLibraryTarget(sun,$(OBJS))
+NormalLintTarget($(SRCS1))
+
+sunInExMono.o: $(ICONFIGFILES)
+ObjectFromSpecialSource(sunInExMono,../../mi/miinitext,$(EXT_DEFINES) -UXIEEXT -UPEXEXT -UXF86VIDMODE)
+ObjectFromSpecialSource(sunInitMono,sunLyInit,-DSUNMAXDEPTH=1)
+
+#if 0
+SingleProgramTarget(kbd_mode, kbd_mode.o,,)
+SingleProgramTarget(constype, constype.o,,)
+InstallProgram(kbd_mode,$(BINDIR))
+InstallProgram(constype,$(BINDIR))
+InstallManPage(kbd_mode,$(MANDIR))
+InstallManPage(constype,$(MANDIR))
+InstallManPage(Xsun,$(MANDIR))
+InstallManPageAliases(Xsun,$(MANDIR),XsunMono)
+#endif
+
+LinkSourceFile(sunGX.h,../sun)
+LinkSourceFile(circleset.h,../sun)
+ObjectFromSpecialSource(sunKeyMap,../sun/sunKeyMap,/**/)
+ObjectFromSpecialSource(sunMfb,../sun/sunMfb,/**/)
+ObjectFromSpecialSource(sunGX,../sun/sunGX,/**/)
+ObjectFromSpecialSource(sunCursor,../sun/sunCursor,/**/)
+
+DependTarget()
+
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/btreg.h b/nx-X11/programs/Xserver/hw/sunLynx/btreg.h
new file mode 100644
index 000000000..cca573cc6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/btreg.h
@@ -0,0 +1,81 @@
+/* $Xorg: btreg.h,v 1.3 2000/08/17 19:48:36 cpqbld Exp $ */
+/*
+ * Copyright (c) 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)btreg.h 8.2 (Berkeley) 1/21/94
+ */
+/* $NetBSD: btreg.h,v 1.2 1994/11/20 20:51:55 deraadt Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/btreg.h,v 3.1 1996/12/27 06:51:31 dawes Exp $ */
+
+/*
+ * Several Sun color frame buffers use some kind of Brooktree video
+ * DAC (e.g., the Bt458, -- in any case, Brooktree make the only
+ * decent color frame buffer chips).
+ *
+ * Color map control on these is a bit funky in a SPARCstation.
+ * To update the color map one would normally do byte writes, but
+ * the hardware takes longword writes. Since there are three
+ * registers for each color map entry (R, then G, then B), we have
+ * to set color 1 with a write to address 0 (setting 0's R/G/B and
+ * color 1's R) followed by a second write to address 1 (setting
+ * color 1's G/B and color 2's R/G). Software must therefore keep
+ * a copy of the current map.
+ *
+ * The colormap address register increments automatically, so the
+ * above write is done as:
+ *
+ * bt->bt_addr = 0;
+ * bt->bt_cmap = R0G0B0R1;
+ * bt->bt_cmap = G1B1R2G2;
+ * ...
+ *
+ * Yow!
+ *
+ * Bonus complication: on the cg6, only the top 8 bits of each 32 bit
+ * register matter, even though the cg3 takes all the bits from all
+ * bytes written to it.
+ */
+struct bt_regs {
+ u_int bt_addr; /* map address register */
+ u_int bt_cmap; /* colormap data register */
+ u_int bt_ctrl; /* control register */
+ u_int bt_omap; /* overlay (cursor) map register */
+};
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/btvar.h b/nx-X11/programs/Xserver/hw/sunLynx/btvar.h
new file mode 100644
index 000000000..054df6f87
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/btvar.h
@@ -0,0 +1,74 @@
+/* $Xorg: btvar.h,v 1.3 2000/08/17 19:48:36 cpqbld Exp $ */
+/*
+ * Copyright (c) 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)btvar.h 8.2 (Berkeley) 1/21/94
+ */
+/* $NetBSD: btvar.h,v 1.2 1994/11/20 20:51:56 deraadt Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/btvar.h,v 3.1 1996/12/27 06:51:32 dawes Exp $ */
+
+/*
+ * Brooktree color frame buffer state variables (see btreg.h).
+ *
+ * Unfortunately, remarkably little code can be shared between the
+ * cg3 and cg6 drivers here, as the cg3 registers do longword-ops
+ * `as expected', but the cg6 ones use only the upper byte.
+ *
+ * Still, the software color map manipulation is not completely trivial.
+ */
+union bt_cmap {
+ u_char cm_map[256][3]; /* 256 R/G/B entries */
+ u_int cm_chip[256 * 3 / 4]; /* the way the chip gets loaded */
+};
+
+/*
+ * Routines in bt_subr.c.
+ */
+int bt_getcmap __P((struct fbcmap *, union bt_cmap *, int));
+int bt_putcmap __P((struct fbcmap *, union bt_cmap *, int));
+
+/*
+ * Compute (x / 4) * 3 and (x / 4) * 4. These are used in turning
+ * RGB indices (which are in multiples of three) into `chip RGB' values
+ * (which are in multiples of four).
+ */
+#define BT_D4M3(x) ((((x) >> 2) << 1) + ((x) >> 2)) /* (x / 4) * 3 */
+#define BT_D4M4(x) ((x) & ~3) /* (x / 4) * 4 */
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/cgsixreg.h b/nx-X11/programs/Xserver/hw/sunLynx/cgsixreg.h
new file mode 100644
index 000000000..0c44c2a58
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/cgsixreg.h
@@ -0,0 +1,206 @@
+/* $Xorg: cgsixreg.h,v 1.3 2000/08/17 19:48:36 cpqbld Exp $ */
+/*
+ * Copyright (c) 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)cgsixreg.h 8.4 (Berkeley) 1/21/94
+ */
+/* $NetBSD: cgsixreg.h,v 1.3 1994/11/20 20:52:00 deraadt Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/cgsixreg.h,v 3.1 1996/12/27 06:51:33 dawes Exp $ */
+
+/*
+ * CG6 display registers. (Note, I got tired of writing `cgsix' about
+ * halfway through and changed everything to cg6, but I probably missed
+ * some. Unfortunately, the way config works, we need to spell out `six'
+ * in some places anyway.)
+ *
+ * The cg6 is a complicated beastie. We have been unable to extract any
+ * documentation and most of the following are guesses based on a limited
+ * amount of reverse engineering.
+ *
+ * A cg6 is composed of numerous groups of control registers, all with TLAs:
+ * FBC - frame buffer control?
+ * FHC - fbc hardware configuration / control? register (32 bits)
+ * DHC - ???
+ * TEC - transform engine control?
+ * THC - TEC Hardware Configuration
+ * ROM - a 64Kbyte ROM with who knows what in it.
+ * colormap - see below
+ * frame buffer memory (video RAM)
+ * possible other stuff
+ *
+ * Like the cg3, the cg6 uses a Brooktree Video DAC (see btreg.h).
+ *
+ * Various revisions of the cgsix have various hardware bugs. So far,
+ * we have only seen rev 1 & 2.
+ */
+
+/* bits in FHC register */
+#define FHC_FBID_MASK 0xff000000 /* bits 24..31 are frame buffer ID */
+#define FHC_FBID_SHIFT 24
+#define FHC_REV_MASK 0x00f00000 /* bits 20..23 are revision */
+#define FHC_REV_SHIFT 20
+#define FHC_FROP_DISABLE 0x00080000 /* disable fast/font? rasterops */
+#define FHC_ROW_DISABLE 0x00040000 /* ??? */
+#define FHC_SRC_DISABLE 0x00020000 /* ??? */
+#define FHC_DST_DISABLE 0x00010000 /* disable destination cache */
+#define FHC_RESET 0x00008000 /* ??? */
+#define FHC_XXX0 0x00004000 /* ??? */
+#define FHC_LEBO 0x00002000 /* set little endian byte order? */
+#define FHC_RES_MASK 0x00001800 /* bits 11&12 are resolution */
+#define FHC_RES_1024 0x00000000 /* res = 1024x768 */
+#define FHC_RES_1152 0x00000800 /* res = 1152x900 */
+#define FHC_RES_1280 0x00001000 /* res = 1280x1024 */
+#define FHC_RES_1600 0x00001800 /* res = 1600x1200 */
+#define FHC_CPU_MASK 0x00000600 /* bits 9&10 are cpu type */
+#define FHC_CPU_SPARC 0x00000000 /* cpu = sparc */
+#define FHC_CPU_68020 0x00000200 /* cpu = 68020 */
+#define FHC_CPU_386 0x00000400 /* cpu = 80386 */
+#define FHC_CPU_XXX 0x00000600 /* ??? */
+#define FHC_TEST 0x00000100 /* ??? test window ??? */
+#define FHC_TESTX_MASK 0x000000f0 /* bits 4..7 are test window X */
+#define FHC_TESTX_SHIFT 4
+#define FHC_TESTY_MASK 0x0000000f /* bits 0..3 are test window Y */
+#define FHC_TESTY_SHIFT 0
+
+/*
+ * The layout of the THC.
+ */
+struct cg6_thc {
+ u_int thc_xxx0[512]; /* ??? */
+ u_int thc_hsync1; /* horizontal sync timing */
+ u_int thc_hsync2; /* more hsync timing */
+ u_int thc_hsync3; /* yet more hsync timing */
+ u_int thc_vsync1; /* vertical sync timing */
+ u_int thc_vsync2; /* only two of these */
+ u_int thc_refresh; /* refresh counter */
+ u_int thc_misc; /* miscellaneous control & status */
+ u_int thc_xxx1[56]; /* ??? */
+ u_int thc_cursxy; /* cursor x,y position (16 bits each) */
+ u_int thc_cursmask[32]; /* cursor mask bits */
+ u_int thc_cursbits[32]; /* what to show where mask enabled */
+};
+
+/* bits in thc_misc */
+#define THC_MISC_XXX0 0xfff00000 /* unused */
+#define THC_MISC_REVMASK 0x000f0000 /* cg6 revision? */
+#define THC_MISC_REVSHIFT 16
+#define THC_MISC_XXX1 0x0000e000 /* unused */
+#define THC_MISC_RESET 0x00001000 /* ??? */
+#define THC_MISC_XXX2 0x00000800 /* unused */
+#define THC_MISC_VIDEN 0x00000400 /* video enable */
+#define THC_MISC_SYNC 0x00000200 /* not sure what ... */
+#define THC_MISC_VSYNC 0x00000100 /* ... these really are */
+#define THC_MISC_SYNCEN 0x00000080 /* sync enable */
+#define THC_MISC_CURSRES 0x00000040 /* cursor resolution */
+#define THC_MISC_INTEN 0x00000020 /* v.retrace intr enable */
+#define THC_MISC_INTR 0x00000010 /* intr pending / ack bit */
+#define THC_MISC_XXX 0x0000000f /* ??? */
+
+/* cursor x / y position value for `off' */
+#define THC_CURSOFF (65536-32) /* i.e., USHRT_MAX+1-32 */
+
+/*
+ * Partial description of TEC (needed to get around FHC rev 1 bugs).
+ */
+struct cg6_tec_xxx {
+ u_int tec_mv; /* matrix stuff */
+ u_int tec_clip; /* clipping stuff */
+ u_int tec_vdc; /* ??? */
+};
+
+/*
+ * This structure exists only to compute the layout of the CG6
+ * hardware. Each of the individual substructures lives on a
+ * separate `page' (where a `page' is at least 4K), and many are
+ * very far apart. We avoid large offsets (which make for lousy
+ * code) by using pointers to the individual interesting pieces,
+ * and map them in independently (to avoid using up PTEs unnecessarily).
+ */
+struct cg6_layout {
+ /* ROM at 0 */
+ union {
+ long un_id; /* ID = ?? */
+ char un_rom[65536]; /* 64K rom */
+ char un_pad[0x200000];
+ } cg6_rom_un;
+
+ /* Brooktree DAC at 0x200000 */
+ union {
+ struct bt_regs un_btregs;
+ char un_pad[0x040000];
+ } cg6_bt_un;
+
+ /* DHC, whatever that is, at 0x240000 */
+ union {
+ char un_pad[0x40000];
+ } cg6_dhc_un;
+
+ /* ALT, whatever that is, at 0x280000 */
+ union {
+ char un_pad[0x80000];
+ } cg6_alt_un;
+
+ /* FHC register at 0x300000 */
+ union {
+ int un_fhc;
+ char un_pad[0x1000];
+ } cg6_fhc_un;
+
+ /* THC at 0x301000 */
+ union {
+ struct cg6_thc un_thc;
+ char un_pad[0x400000 - 0x1000];
+ } cg6_thc_un;
+
+ /* FBC at 0x700000 */
+ union {
+ char un_pad[0x1000];
+ } cg6_fbc_un;
+
+ /* TEC at 0x701000 */
+ union {
+ char un_pad[0x100000 - 0x1000];
+ struct cg6_tec_xxx un_tec;
+ } cg6_tec_un;
+
+ /* Video RAM at 0x800000 */
+ char cg6_ram[1024 * 1024]; /* approx.? */
+};
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/fbio.h b/nx-X11/programs/Xserver/hw/sunLynx/fbio.h
new file mode 100644
index 000000000..324036999
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/fbio.h
@@ -0,0 +1,186 @@
+/* $Xorg: fbio.h,v 1.3 2000/08/17 19:48:36 cpqbld Exp $ */
+/*
+ * Copyright (c) 1992 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software developed by the Computer Systems
+ * Engineering group at Lawrence Berkeley Laboratory under DARPA
+ * contract BG 91-66 and contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)fbio.h 7.2 (Berkeley) 4/1/92
+ */
+
+/*
+ * Frame buffer ioctls (from Sprite, trimmed to essentials for X11).
+ */
+/* $NetBSD: fbio.h,v 1.3 1994/11/20 20:53:03 deraadt Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/fbio.h,v 3.1 1996/12/27 06:51:34 dawes Exp $ */
+
+/*
+ * Frame buffer type codes.
+ */
+#define FBTYPE_SUN1BW 0 /* multibus mono */
+#define FBTYPE_SUN1COLOR 1 /* multibus color */
+#define FBTYPE_SUN2BW 2 /* memory mono */
+#define FBTYPE_SUN2COLOR 3 /* color w/rasterop chips */
+#define FBTYPE_SUN2GP 4 /* GP1/GP2 */
+#define FBTYPE_SUN5COLOR 5 /* RoadRunner accelerator */
+#define FBTYPE_SUN3COLOR 6 /* memory color */
+#define FBTYPE_MEMCOLOR 7 /* memory 24-bit */
+#define FBTYPE_SUN4COLOR 8 /* memory color w/overlay */
+
+#define FBTYPE_NOTSUN1 9 /* reserved for customer */
+#define FBTYPE_NOTSUN2 10 /* reserved for customer */
+#define FBTYPE_NOTSUN3 11 /* reserved for customer */
+
+#define FBTYPE_SUNFAST_COLOR 12 /* accelerated 8bit */
+#define FBTYPE_SUNROP_COLOR 13 /* MEMCOLOR with rop h/w */
+#define FBTYPE_SUNFB_VIDEO 14 /* Simple video mixing */
+#define FBTYPE_RESERVED5 15 /* reserved, do not use */
+#define FBTYPE_RESERVED4 16 /* reserved, do not use */
+#define FBTYPE_RESERVED3 17 /* reserved, do not use */
+#define FBTYPE_RESERVED2 18 /* reserved, do not use */
+#define FBTYPE_RESERVED1 19 /* reserved, do not use */
+
+#define FBTYPE_LASTPLUSONE 20 /* max number of fbs (change as add) */
+
+/*
+ * Frame buffer descriptor as returned by FBIOGTYPE.
+ */
+struct fbtype {
+ int fb_type; /* as defined above */
+ int fb_height; /* in pixels */
+ int fb_width; /* in pixels */
+ int fb_depth; /* bits per pixel */
+ int fb_cmsize; /* size of color map (entries) */
+ int fb_size; /* total size in bytes */
+};
+#define FBIOGTYPE _IOR('F', 0, struct fbtype)
+
+#ifdef notdef
+/*
+ * General purpose structure for passing info in and out of frame buffers
+ * (used for gp1) -- unsupported.
+ */
+struct fbinfo {
+ int fb_physaddr; /* physical frame buffer address */
+ int fb_hwwidth; /* fb board width */
+ int fb_hwheight; /* fb board height */
+ int fb_addrdelta; /* phys addr diff between boards */
+ u_char *fb_ropaddr; /* fb virtual addr */
+ int fb_unit; /* minor devnum of fb */
+};
+#define FBIOGINFO _IOR('F', 2, struct fbinfo)
+#endif
+
+/*
+ * Color map I/O.
+ */
+struct fbcmap {
+ int index; /* first element (0 origin) */
+ int count; /* number of elements */
+ u_char *red; /* red color map elements */
+ u_char *green; /* green color map elements */
+ u_char *blue; /* blue color map elements */
+};
+#define FBIOPUTCMAP _IOW('F', 3, struct fbcmap)
+#define FBIOGETCMAP _IOW('F', 4, struct fbcmap)
+
+/*
+ * Set/get attributes.
+ */
+#define FB_ATTR_NDEVSPECIFIC 8 /* no. of device specific values */
+#define FB_ATTR_NEMUTYPES 4 /* no. of emulation types */
+
+struct fbsattr {
+ int flags; /* flags; see below */
+ int emu_type; /* emulation type (-1 if unused) */
+ int dev_specific[FB_ATTR_NDEVSPECIFIC]; /* catchall */
+};
+#define FB_ATTR_AUTOINIT 1 /* emulation auto init flag */
+#define FB_ATTR_DEVSPECIFIC 2 /* dev. specific stuff valid flag */
+
+struct fbgattr {
+ int real_type; /* real device type */
+ int owner; /* PID of owner, 0 if myself */
+ struct fbtype fbtype; /* fbtype info for real device */
+ struct fbsattr sattr; /* see above */
+ int emu_types[FB_ATTR_NEMUTYPES]; /* possible emulations */
+ /* (-1 if unused) */
+};
+/* FBIOSATTR _IOW('F', 5, struct fbsattr) -- unsupported */
+#define FBIOGATTR _IOR('F', 6, struct fbgattr)
+
+/*
+ * Video control.
+ */
+#define FBVIDEO_OFF 0
+#define FBVIDEO_ON 1
+
+#define FBIOSVIDEO _IOW('F', 7, int)
+#define FBIOGVIDEO _IOR('F', 8, int)
+
+/*
+ * hardware cursor control
+ */
+struct fbcurpos {
+ short x;
+ short y;
+};
+
+#define FB_CUR_SETCUR 0x01
+#define FB_CUR_SETPOS 0x02
+#define FB_CUR_SETHOT 0x04
+#define FB_CUR_SETCMAP 0x08
+#define FB_CUR_SETSHAPE 0x10
+#define FB_CUR_SETALL 0x1F
+
+struct fbcursor {
+ short set; /* what to set */
+ short enable; /* enable/disable cursor */
+ struct fbcurpos pos; /* cursor's position */
+ struct fbcurpos hot; /* cursor's hot spot */
+ struct fbcmap cmap; /* color map info */
+ struct fbcurpos size; /* cursor's bit map size */
+ char *image; /* cursor's image bits */
+ char *mask; /* cursor's mask bits */
+};
+
+/* set/get cursor attributes/shape */
+#define FBIOSCURSOR _IOW('F', 24, struct fbcursor)
+#define FBIOGCURSOR _IOWR('F', 25, struct fbcursor)
+
+/* set/get cursor position */
+#define FBIOSCURPOS _IOW('F', 26, struct fbcurpos)
+#define FBIOGCURPOS _IOW('F', 27, struct fbcurpos)
+
+/* get max cursor size */
+#define FBIOGCURMAX _IOR('F', 28, struct fbcurpos)
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/patch.Console b/nx-X11/programs/Xserver/hw/sunLynx/patch.Console
new file mode 100644
index 000000000..58a2d80f3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/patch.Console
@@ -0,0 +1,428 @@
+diff -crP /cdrom/usr/include/kbd.h /usr/include/kbd.h
+*** /cdrom/usr/include/kbd.h Wed Dec 31 16:00:00 1969
+--- /usr/include/kbd.h Sun May 11 23:22:45 1997
+***************
+*** 0 ****
+--- 1,90 ----
++ /* $NetBSD: kbd.h,v 1.4 1995/07/06 05:36:29 pk Exp $ */
++
++ /*
++ * Copyright (c) 1992, 1993
++ * The Regents of the University of California. All rights reserved.
++ *
++ * This software was developed by the Computer Systems Engineering group
++ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
++ * contributed to Berkeley.
++ *
++ * All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Lawrence Berkeley Laboratory.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 3. All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Berkeley and its contributors.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * @(#)kbd.h 8.1 (Berkeley) 6/11/93
++ */
++
++ /*
++ * Keyboard `registers'. (This should be called kbd_reg.h but we need to
++ * be compatible.)
++ */
++
++ /*
++ * Control codes sent from type 2, 3, and 4 keyboards.
++ *
++ * Note that KBD_RESET is followed by a keyboard ID, while KBD_IDLE is not.
++ * KBD_IDLE does not take the place of any `up' transitions (it merely occurs
++ * after them).
++ */
++ #define KBD_RESET 0xff /* keyboard `reset' response */
++ #define KBD_IDLE 0x7f /* keyboard `all keys are up' code */
++ #define KBD_LAYOUT 0xfe /* keyboard `get layout' response */
++
++ /* Keyboard IDs */
++ #define KB_SUN2 2 /* type 2 keyboard */
++ #define KB_SUN3 3 /* type 3 keyboard */
++ #define KB_SUN4 4 /* type 4 keyboard */
++
++ /* Key codes are in 0x00..0x7e; KBD_UP is set if the key goes up */
++ #define KBD_KEYMASK 0x7f /* keyboard key mask */
++ #define KBD_UP 0x80 /* keyboard `up' transition */
++
++ /* Keyboard codes needed to recognize the L1-A sequence */
++ #define KBD_L1 1 /* keyboard code for `L1' key */
++ #define KBD_A 77 /* keyboard code for `A' key */
++
++ /* Control codes sent to the various keyboards */
++ #define KBD_CMD_RESET 1 /* reset keyboard */
++ #define KBD_CMD_BELL 2 /* turn bell on */
++ #define KBD_CMD_NOBELL 3 /* turn bell off */
++ #define KBD_CMD_CLICK 10 /* turn keyclick on */
++ #define KBD_CMD_NOCLICK 11 /* turn keyclick off */
++ #define KBD_CMD_SETLED 14 /* set LED state (type 4 kbd) */
++ #define KBD_CMD_GLAYOUT 15 /* get DIP switch (type 4 kbd) */
++
++ #define LED_NUM_LOCK 0x1
++ #if !defined(Lynx) || !defined(LED_COMPOSE)
++ #define LED_COMPOSE 0x2
++ #endif
++ #define LED_SCROLL_LOCK 0x4
++ #define LED_CAPS_LOCK 0x8
+diff -crP /cdrom/usr/include/kbio.h /usr/include/kbio.h
+*** /cdrom/usr/include/kbio.h Wed Dec 31 16:00:00 1969
+--- /usr/include/kbio.h Sun May 11 23:22:46 1997
+***************
+*** 0 ****
+--- 1,115 ----
++ /* $NetBSD: kbio.h,v 1.4 1995/05/10 16:07:27 pk Exp $ */
++
++ /*
++ * Copyright (c) 1992, 1993
++ * The Regents of the University of California. All rights reserved.
++ *
++ * This software was developed by the Computer Systems Engineering group
++ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
++ * contributed to Berkeley.
++ *
++ * All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Lawrence Berkeley Laboratory.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 3. All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Berkeley and its contributors.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * @(#)kbio.h 8.1 (Berkeley) 6/11/93
++ */
++
++ /*
++ * The following is a minimal emulation of Sun's `kio' structures
++ * and related operations necessary to make X11 happy (i.e., make it
++ * compile, and make old X11 binaries run).
++ */
++
++ /*
++ * The kiockey structure apparently gets and/or sets keyboard mappings.
++ * It seems to be kind of useless, but X11 uses it (according to the
++ * comments) to figure out when a Sun 386i has a type-4 keyboard but
++ * claims to have a type-3 keyboard. We need just enough to cause the
++ * appropriate ioctl to return the appropriate magic value.
++ *
++ * KIOCGETKEY fills in kio_entry from kio_station. Not sure what tablemask
++ * is for; X sets it before the call, so it is not an output, but we do not
++ * care anyway. KIOCSDIRECT is supposed to tell the kernel whether to send
++ * keys to the console or to X; we just send them to X whenever the keyboard
++ * is open at all. (XXX may need to change this later)
++ *
++ * Keyboard commands and types are defined in kbd.h as they are actually
++ * real hardware commands and type numbers.
++ */
++ struct okiockey { /* Out-dated key translation structure */
++ int kio_tablemask; /* whatever */
++ u_char kio_station; /* key number */
++ u_char kio_entry; /* HOLE if not present */
++ char kio_text[10]; /* the silly escape sequences (unsupported) */
++ };
++
++ struct kiockey {
++ int kio_tablemask; /* whatever */
++ u_char kio_station; /* key number */
++ u_short kio_entry; /* HOLE if not present */
++ char kio_text[10]; /* the silly escape sequences (unsupported) */
++ };
++
++ /*
++ * Values for kio_tablemask. These determine which table to read/modify
++ * in KIOC[SG]KEY ioctls. Currently, we only have "non-shift" and "shift"
++ * tables.
++ */
++ #define KIOC_NOMASK 0x0
++ #define KIOC_CAPSMASK 0x1
++ #define KIOC_SHIFTMASK 0xe
++ #define KIOC_CTRLMASK 0x30
++ #define KIOC_ALTGMASK 0x200
++ #define KIOC_NUMLMASK 0x800
++
++ #define HOLE 0x302 /* value for kio_entry to say `really type 3' */
++
++ #define KIOCTRANS _IOW('k', 0, int) /* set translation mode */
++ /* (we only accept TR_UNTRANS_EVENT) */
++ #define KIOCGETKEY _IOWR('k', 2, struct okiockey) /* fill in kio_entry */
++ #define KIOCGTRANS _IOR('k', 5, int) /* get translation mode */
++ #define KIOCCMD _IOW('k', 8, int) /* X uses this to ring bell */
++ #define KIOCTYPE _IOR('k', 9, int) /* get keyboard type */
++ #define KIOCSDIRECT _IOW('k', 10, int) /* keys to console? */
++ #define KIOCSKEY _IOW('k', 12, struct kiockey) /* set xlat mode */
++ #ifndef Lynx
++ #define KIOCGKEY _IOWR('k', 13, struct kiockey) /* get xlat mode */
++ #endif
++ #define KIOCLAYOUT _IOR('k', 20, int) /* get keyboard layout */
++ #define KIOCSLED _IOW('k', 14, char) /* set LED state */
++ #define KIOCGLED _IOR('k', 15, char) /* get LED state */
++
++ #define TR_NONE 0 /* X compat, unsupported */
++ #define TR_ASCII 1 /* X compat, unsupported */
++ #define TR_EVENT 2 /* X compat, unsupported */
++ #define TR_UNTRANS_EVENT 3
+diff -crP /cdrom/sys/drivers/console/Makefile /sys/drivers/console/Makefile
+*** /cdrom/sys/drivers/console/Makefile Sun Feb 9 04:43:06 1997
+--- /sys/drivers/console/Makefile Sun May 11 23:24:04 1997
+***************
+*** 24,30 ****
+
+ LIBRARY= drivers
+
+! SPECIAL_CFLAGS=-DMOUSESUPPORT
+
+ include ../../OBJ_RULES
+
+--- 24,30 ----
+
+ LIBRARY= drivers
+
+! SPECIAL_CFLAGS=-DMOUSESUPPORT -DXSERVERSUPPORT
+
+ include ../../OBJ_RULES
+
+diff -crP /cdrom/sys/drivers/console/atc.h /sys/drivers/console/atc.h
+*** /cdrom/sys/drivers/console/atc.h Sun Feb 9 04:43:06 1997
+--- /sys/drivers/console/atc.h Sun May 11 23:22:46 1997
+***************
+*** 108,113 ****
+--- 108,119 ----
+ #ifdef MOUSESUPPORT
+ struct ttystatics mousechannel;
+ #endif /* MOUSESUPPORT */
++ #ifdef XSERVERSUPPORT
++ int kbd_pending;
++ int kbd_id; /* keyboard type */
++ int kbd_layout; /* layout on type 4 */
++ int kbd_click; /* kbd click on? */
++ #endif
+ };
+
+ struct kbd_registers_type {
+diff -crP /cdrom/sys/drivers/console/atcdrvr.c /sys/drivers/console/atcdrvr.c
+*** /cdrom/sys/drivers/console/atcdrvr.c Sun Feb 9 04:43:06 1997
+--- /sys/drivers/console/atcdrvr.c Sun May 11 23:25:15 1997
+***************
+*** 38,43 ****
+--- 38,47 ----
+ #ifdef MOUSESUPPORT
+ #include "am8530.h"
+ #endif /* MOUSESUPPORT */
++ #ifdef XSERVERSUPPORT
++ #include <kbd.h>
++ #include <kbio.h>
++ #endif
+
+ char *screen_address; /* is this supposed to be in the driver info? */
+
+***************
+*** 305,310 ****
+--- 309,318 ----
+ int m;
+ int ps;
+ extern int set_kb_lights();
++ #ifdef XSERVERSUPPORT
++ extern int kbd_docmd();
++ int err;
++ #endif
+
+ if (!atc_flag){ pseterr(EIO); return(SYSERR);}
+ #ifdef MOUSESUPPORT
+***************
+*** 354,365 ****
+--- 362,398 ----
+ #ifdef TIOLED
+ case TIOLED:
+ #endif
++ #ifdef XSERVERSUPPORT
++ case KIOCSLED:
++ #endif
+ h->curled = *arg;
+ if (h->ledstate == -1) {
+ if (timeout(set_kb_lights,h,1) != -1)
+ h->ledstate = 0;
+ }
+ return 0;
++ #ifdef XSERVERSUPPORT
++ case KIOCTYPE:
++ if (wbounds(arg) < sizeof(int)) {
++ pseterr(EFAULT);
++ return SYSERR;
++ }
++ *(int *)arg = h->kbd_id;
++ return OK;
++ case KIOCLAYOUT:
++ if (wbounds(arg) < sizeof(int)) {
++ pseterr(EFAULT);
++ return SYSERR;
++ }
++ *(int *)arg = h->kbd_layout;
++ return OK;
++ case KIOCCMD:
++ if (err = kbd_docmd(h, *(int *)arg)) {
++ pseterr(err);
++ return SYSERR;
++ }
++ return OK;
++ #endif
+ case VT_OPENQRY:
+ if (h->multimode == SCM_ONE) {
+ if (!(h->open & 1)) {
+***************
+*** 578,583 ****
+--- 611,622 ----
+ h->open = 0;
+ h->break_code = 0;
+ h->info = info;
++ #ifdef XSERVERSUPPORT
++ h->kbd_pending = 0;
++ h->kbd_id = KB_SUN4; /* query KBD later.... */
++ h->kbd_layout = 0; /* US_ASCII */
++ h->kbd_click = 0; /* silent movie */
++ #endif
+ #ifdef MOUSESUPPORT
+ tmgr_install(&h->mousechannel, &info->sg, 0, mouse_xmit_ena, h);
+ #endif /* MOUSESUPPORT */
+diff -crP /cdrom/sys/drivers/console/atkey.c /sys/drivers/console/atkey.c
+*** /cdrom/sys/drivers/console/atkey.c Sun Feb 9 04:43:07 1997
+--- /sys/drivers/console/atkey.c Sun May 11 23:22:46 1997
+***************
+*** 26,31 ****
+--- 26,35 ----
+ #ifdef MOUSESUPPORT
+ #include "am8530.h"
+ #endif /* MOUSESUPPORT */
++ #ifdef XSERVERSUPPORT
++ #include <kbd.h>
++ #include <kbio.h>
++ #endif
+
+ #define NOTHING_USEFUL -1
+ #define FILL NOTHING_USEFUL
+diff -crP /cdrom/sys/drivers/console/atutils.c /sys/drivers/console/atutils.c
+*** /cdrom/sys/drivers/console/atutils.c Sun Feb 9 04:43:07 1997
+--- /sys/drivers/console/atutils.c Sun May 11 23:22:46 1997
+***************
+*** 361,367 ****
+ }
+
+
+! static int byte_to_keyboard(byt)
+ unsigned char byt;
+ {
+ int i;
+--- 361,370 ----
+ }
+
+
+! #ifndef XSERVERSUPPORT
+! static
+! #endif
+! int byte_to_keyboard(byt)
+ unsigned char byt;
+ {
+ int i;
+***************
+*** 400,402 ****
+--- 403,449 ----
+ break;
+ }
+ }
++
++ #ifdef XSERVERSUPPORT
++ #include <kbd.h>
++ #include <kbio.h>
++
++ /*
++ * Execute a keyboard command; return 0 on success.
++ */
++ kbd_docmd(h, cmd)
++ register struct kdhglobals *h;
++ int cmd;
++ {
++ switch (cmd) {
++
++ case KBD_CMD_BELL:
++ case KBD_CMD_NOBELL:
++ /* Supported by type 2, 3, and 4 keyboards */
++ break;
++
++ case KBD_CMD_CLICK:
++ /* Unsupported by type 2 keyboards */
++ if (h->kbd_id != KB_SUN2) {
++ h->kbd_click = 1;
++ break;
++ }
++ return (EINVAL);
++
++ case KBD_CMD_NOCLICK:
++ /* Unsupported by type 2 keyboards */
++ if (h->kbd_id != KB_SUN2) {
++ h->kbd_click = 0;
++ break;
++ }
++ return (EINVAL);
++
++ default:
++ return (EINVAL); /* ENOTTY? EOPNOTSUPP? */
++ }
++
++ if (timeout(byte_to_keyboard, cmd, 1) < 0)
++ return (ENOSPC); /* ERESTART? */
++ return (0);
++ }
++ #endif
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/patch.Console-2.4.0 b/nx-X11/programs/Xserver/hw/sunLynx/patch.Console-2.4.0
new file mode 100644
index 000000000..41e2d10c3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/patch.Console-2.4.0
@@ -0,0 +1,493 @@
+diff -cPr --exclude-from=Excl.include /mnt/DEV_OS.microSPARC/usr/include/kbd.h /usr/include/kbd.h
+*** /mnt/DEV_OS.microSPARC/usr/include/kbd.h
+--- /usr/include/kbd.h Wed Jul 24 09:37:49 1996
+***************
+*** 0 ****
+--- 1,90 ----
++ /* $NetBSD: kbd.h,v 1.4 1995/07/06 05:36:29 pk Exp $ */
++
++ /*
++ * Copyright (c) 1992, 1993
++ * The Regents of the University of California. All rights reserved.
++ *
++ * This software was developed by the Computer Systems Engineering group
++ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
++ * contributed to Berkeley.
++ *
++ * All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Lawrence Berkeley Laboratory.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 3. All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Berkeley and its contributors.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * @(#)kbd.h 8.1 (Berkeley) 6/11/93
++ */
++
++ /*
++ * Keyboard `registers'. (This should be called kbd_reg.h but we need to
++ * be compatible.)
++ */
++
++ /*
++ * Control codes sent from type 2, 3, and 4 keyboards.
++ *
++ * Note that KBD_RESET is followed by a keyboard ID, while KBD_IDLE is not.
++ * KBD_IDLE does not take the place of any `up' transitions (it merely occurs
++ * after them).
++ */
++ #define KBD_RESET 0xff /* keyboard `reset' response */
++ #define KBD_IDLE 0x7f /* keyboard `all keys are up' code */
++ #define KBD_LAYOUT 0xfe /* keyboard `get layout' response */
++
++ /* Keyboard IDs */
++ #define KB_SUN2 2 /* type 2 keyboard */
++ #define KB_SUN3 3 /* type 3 keyboard */
++ #define KB_SUN4 4 /* type 4 keyboard */
++
++ /* Key codes are in 0x00..0x7e; KBD_UP is set if the key goes up */
++ #define KBD_KEYMASK 0x7f /* keyboard key mask */
++ #define KBD_UP 0x80 /* keyboard `up' transition */
++
++ /* Keyboard codes needed to recognize the L1-A sequence */
++ #define KBD_L1 1 /* keyboard code for `L1' key */
++ #define KBD_A 77 /* keyboard code for `A' key */
++
++ /* Control codes sent to the various keyboards */
++ #define KBD_CMD_RESET 1 /* reset keyboard */
++ #define KBD_CMD_BELL 2 /* turn bell on */
++ #define KBD_CMD_NOBELL 3 /* turn bell off */
++ #define KBD_CMD_CLICK 10 /* turn keyclick on */
++ #define KBD_CMD_NOCLICK 11 /* turn keyclick off */
++ #define KBD_CMD_SETLED 14 /* set LED state (type 4 kbd) */
++ #define KBD_CMD_GLAYOUT 15 /* get DIP switch (type 4 kbd) */
++
++ #define LED_NUM_LOCK 0x1
++ #if !defined(Lynx) || !defined(LED_COMPOSE)
++ #define LED_COMPOSE 0x2
++ #endif
++ #define LED_SCROLL_LOCK 0x4
++ #define LED_CAPS_LOCK 0x8
+diff -cPr --exclude-from=Excl.include /mnt/DEV_OS.microSPARC/usr/include/kbio.h /usr/include/kbio.h
+*** /mnt/DEV_OS.microSPARC/usr/include/kbio.h
+--- /usr/include/kbio.h Wed Aug 14 16:29:26 1996
+***************
+*** 0 ****
+--- 1,115 ----
++ /* $NetBSD: kbio.h,v 1.4 1995/05/10 16:07:27 pk Exp $ */
++
++ /*
++ * Copyright (c) 1992, 1993
++ * The Regents of the University of California. All rights reserved.
++ *
++ * This software was developed by the Computer Systems Engineering group
++ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
++ * contributed to Berkeley.
++ *
++ * All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Lawrence Berkeley Laboratory.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 3. All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Berkeley and its contributors.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * @(#)kbio.h 8.1 (Berkeley) 6/11/93
++ */
++
++ /*
++ * The following is a minimal emulation of Sun's `kio' structures
++ * and related operations necessary to make X11 happy (i.e., make it
++ * compile, and make old X11 binaries run).
++ */
++
++ /*
++ * The kiockey structure apparently gets and/or sets keyboard mappings.
++ * It seems to be kind of useless, but X11 uses it (according to the
++ * comments) to figure out when a Sun 386i has a type-4 keyboard but
++ * claims to have a type-3 keyboard. We need just enough to cause the
++ * appropriate ioctl to return the appropriate magic value.
++ *
++ * KIOCGETKEY fills in kio_entry from kio_station. Not sure what tablemask
++ * is for; X sets it before the call, so it is not an output, but we do not
++ * care anyway. KIOCSDIRECT is supposed to tell the kernel whether to send
++ * keys to the console or to X; we just send them to X whenever the keyboard
++ * is open at all. (XXX may need to change this later)
++ *
++ * Keyboard commands and types are defined in kbd.h as they are actually
++ * real hardware commands and type numbers.
++ */
++ struct okiockey { /* Out-dated key translation structure */
++ int kio_tablemask; /* whatever */
++ u_char kio_station; /* key number */
++ u_char kio_entry; /* HOLE if not present */
++ char kio_text[10]; /* the silly escape sequences (unsupported) */
++ };
++
++ struct kiockey {
++ int kio_tablemask; /* whatever */
++ u_char kio_station; /* key number */
++ u_short kio_entry; /* HOLE if not present */
++ char kio_text[10]; /* the silly escape sequences (unsupported) */
++ };
++
++ /*
++ * Values for kio_tablemask. These determine which table to read/modify
++ * in KIOC[SG]KEY ioctls. Currently, we only have "non-shift" and "shift"
++ * tables.
++ */
++ #define KIOC_NOMASK 0x0
++ #define KIOC_CAPSMASK 0x1
++ #define KIOC_SHIFTMASK 0xe
++ #define KIOC_CTRLMASK 0x30
++ #define KIOC_ALTGMASK 0x200
++ #define KIOC_NUMLMASK 0x800
++
++ #define HOLE 0x302 /* value for kio_entry to say `really type 3' */
++
++ #define KIOCTRANS _IOW('k', 0, int) /* set translation mode */
++ /* (we only accept TR_UNTRANS_EVENT) */
++ #define KIOCGETKEY _IOWR('k', 2, struct okiockey) /* fill in kio_entry */
++ #define KIOCGTRANS _IOR('k', 5, int) /* get translation mode */
++ #define KIOCCMD _IOW('k', 8, int) /* X uses this to ring bell */
++ #define KIOCTYPE _IOR('k', 9, int) /* get keyboard type */
++ #define KIOCSDIRECT _IOW('k', 10, int) /* keys to console? */
++ #define KIOCSKEY _IOW('k', 12, struct kiockey) /* set xlat mode */
++ #ifndef Lynx
++ #define KIOCGKEY _IOWR('k', 13, struct kiockey) /* get xlat mode */
++ #endif
++ #define KIOCLAYOUT _IOR('k', 20, int) /* get keyboard layout */
++ #define KIOCSLED _IOW('k', 14, char) /* set LED state */
++ #define KIOCGLED _IOR('k', 15, char) /* get LED state */
++
++ #define TR_NONE 0 /* X compat, unsupported */
++ #define TR_ASCII 1 /* X compat, unsupported */
++ #define TR_EVENT 2 /* X compat, unsupported */
++ #define TR_UNTRANS_EVENT 3
+diff -cPr --exclude=*.[oa] /mnt/DEV_OS.microSPARC/sys/drivers/console/Makefile sys/drivers/console/Makefile
+*** /mnt/DEV_OS.microSPARC/sys/drivers/console/Makefile Fri Apr 26 23:27:51 1996
+--- sys/drivers/console/Makefile Fri Aug 2 09:03:05 1996
+***************
+*** 31,37 ****
+ # (keyboard) duart. The mouse is attached to this port. It must be
+ # defined for the X server to work.
+ #
+! SPECIAL_CFLAGS = -DMOUSESUPPORT -O
+
+ FILES = atcdrvr.xxx gfont.xxx atkey.xxx atbeep.xxx atterm.xxx atutils.xxx
+ HFILES =
+--- 31,37 ----
+ # (keyboard) duart. The mouse is attached to this port. It must be
+ # defined for the X server to work.
+ #
+! SPECIAL_CFLAGS = -DMOUSESUPPORT -DXSERVERSUPPORT -O
+
+ FILES = atcdrvr.xxx gfont.xxx atkey.xxx atbeep.xxx atterm.xxx atutils.xxx
+ HFILES =
+***************
+*** 117,122 ****
+--- 117,130 ----
+
+ # Just Do It.
+ FORCE:
++
++ atkey.kdb.o : atkey.c
++ $(KERN_CC) -c -o atkey.kdb.o $(SPECIAL_CFLAGS) $(KERN_CFLAGS) \
++ $(SPECIAL_INCLUDES) $(KERN_INCLUDES) -DSKDB atkey.c
++
++ atkey.nokdb.o : atkey.c
++ $(KERN_CC) -c -o atkey.kdb.o $(SPECIAL_CFLAGS) $(KERN_CFLAGS) \
++ $(SPECIAL_INCLUDES) $(KERN_INCLUDES) atkey.c
+
+ # Dependencies as of 5/20/1992
+
+diff -cPr --exclude=*.[oa] /mnt/DEV_OS.microSPARC/sys/drivers/console/atc.h sys/drivers/console/atc.h
+*** /mnt/DEV_OS.microSPARC/sys/drivers/console/atc.h Fri Apr 26 23:27:51 1996
+--- sys/drivers/console/atc.h Wed Jul 24 11:49:21 1996
+***************
+*** 191,196 ****
+--- 191,202 ----
+ #ifdef MOUSESUPPORT
+ struct ttystatics mousechannel;
+ #endif /* MOUSESUPPORT */
++ #ifdef XSERVERSUPPORT
++ int kbd_pending;
++ int kbd_id; /* keyboard type */
++ int kbd_layout; /* layout on type 4 */
++ int kbd_click; /* kbd click on? */
++ #endif
+ };
+
+ struct kbd_registers_type {
+diff -cPr --exclude=*.[oa] /mnt/DEV_OS.microSPARC/sys/drivers/console/atcdrvr.c sys/drivers/console/atcdrvr.c
+*** /mnt/DEV_OS.microSPARC/sys/drivers/console/atcdrvr.c Fri Apr 26 23:27:51 1996
+--- sys/drivers/console/atcdrvr.c Wed Aug 14 16:28:23 1996
+***************
+*** 270,275 ****
+--- 270,279 ----
+ #ifdef MOUSESUPPORT
+ #include "am8530.h"
+ #endif /* MOUSESUPPORT */
++ #ifdef XSERVERSUPPORT
++ #include <kbd.h>
++ #include <kbio.h>
++ #endif
+
+ char *screen_address; /* is this supposed to be in the driver info? */
+
+***************
+*** 537,542 ****
+--- 541,550 ----
+ int m;
+ int ps;
+ extern int set_kb_lights();
++ #ifdef XSERVERSUPPORT
++ extern int kbd_docmd();
++ int err;
++ #endif
+
+ if (!atc_flag){ pseterr(EIO); return(SYSERR);}
+ #ifdef MOUSESUPPORT
+***************
+*** 586,597 ****
+ #ifdef TIOLED
+ case TIOLED:
+ #endif
+ h->curled = *arg;
+ if (h->ledstate == -1) {
+ if (timeout(set_kb_lights,h,1) != -1)
+ h->ledstate = 0;
+ }
+! break;
+ case VT_OPENQRY:
+ if (h->multimode == SCM_ONE) {
+ if (!(h->open & 1)) {
+--- 594,630 ----
+ #ifdef TIOLED
+ case TIOLED:
+ #endif
++ #ifdef XSERVERSUPPORT
++ case KIOCSLED:
++ #endif
+ h->curled = *arg;
+ if (h->ledstate == -1) {
+ if (timeout(set_kb_lights,h,1) != -1)
+ h->ledstate = 0;
+ }
+! return OK;
+! #ifdef XSERVERSUPPORT
+! case KIOCTYPE:
+! if (wbounds(arg) < sizeof(int)) {
+! pseterr(EFAULT);
+! return SYSERR;
+! }
+! *(int *)arg = h->kbd_id;
+! return OK;
+! case KIOCLAYOUT:
+! if (wbounds(arg) < sizeof(int)) {
+! pseterr(EFAULT);
+! return SYSERR;
+! }
+! *(int *)arg = h->kbd_layout;
+! return OK;
+! case KIOCCMD:
+! if (err = kbd_docmd(h, *(int *)arg)) {
+! pseterr(err);
+! return SYSERR;
+! }
+! return OK;
+! #endif
+ case VT_OPENQRY:
+ if (h->multimode == SCM_ONE) {
+ if (!(h->open & 1)) {
+***************
+*** 810,815 ****
+--- 843,854 ----
+ h->open = 0;
+ h->break_code = 0;
+ h->info = info;
++ #ifdef XSERVERSUPPORT
++ h->kbd_pending = 0;
++ h->kbd_id = KB_SUN4; /* query KBD later.... */
++ h->kbd_layout = 0; /* US_ASCII */
++ h->kbd_click = 0; /* silent movie */
++ #endif
+ #ifdef MOUSESUPPORT
+ tmgr_install(&h->mousechannel, &info->sg, 0, mouse_xmit_ena, h);
+ #endif /* MOUSESUPPORT */
+diff -cPr --exclude=*.[oa] /mnt/DEV_OS.microSPARC/sys/drivers/console/atkey.c sys/drivers/console/atkey.c
+*** /mnt/DEV_OS.microSPARC/sys/drivers/console/atkey.c Fri Apr 26 23:27:51 1996
+--- sys/drivers/console/atkey.c Mon Sep 23 09:19:36 1996
+***************
+*** 162,167 ****
+--- 162,171 ----
+ #ifdef MOUSESUPPORT
+ #include "am8530.h"
+ #endif /* MOUSESUPPORT */
++ #ifdef XSERVERSUPPORT
++ #include <kbd.h>
++ #include <kbio.h>
++ #endif
+
+ #define NOTHING_USEFUL -1
+ #define FILL NOTHING_USEFUL
+***************
+*** 474,480 ****
+ #undef DEBUG
+
+ j = *(volatile unsigned char *)KV_KBD_DATA;
+!
+ /* Do the quick scan mode check first. If scanning, stuff and exit */
+ screen_num = (h->g - &h->screen[0]);
+ if (h->screen[screen_num].scan_mode) {
+--- 478,503 ----
+ #undef DEBUG
+
+ j = *(volatile unsigned char *)KV_KBD_DATA;
+! #ifdef XSERVERSUPPORT
+! if (h->kbd_pending == KBD_RESET) {
+! h->kbd_pending = 0;
+! h->kbd_id = j;
+! if (j == KB_SUN4) {
+! extern int byte_to_keyboard();
+! timeout(byte_to_keyboard, KBD_CMD_GLAYOUT, 1);
+! }
+! goto EOIandExit;
+! }
+! if (h->kbd_pending == KBD_LAYOUT) {
+! h->kbd_pending = 0;
+! h->kbd_layout = j;
+! goto EOIandExit;
+! }
+! if (j == KBD_RESET || j == KBD_LAYOUT) {
+! h->kbd_pending = j;
+! goto EOIandExit;
+! }
+! #endif
+ /* Do the quick scan mode check first. If scanning, stuff and exit */
+ screen_num = (h->g - &h->screen[0]);
+ if (h->screen[screen_num].scan_mode) {
+diff -cPr --exclude=*.[oa] /mnt/DEV_OS.microSPARC/sys/drivers/console/atutils.c sys/drivers/console/atutils.c
+*** /mnt/DEV_OS.microSPARC/sys/drivers/console/atutils.c Fri Apr 26 23:27:51 1996
+--- sys/drivers/console/atutils.c Tue Aug 13 11:54:38 1996
+***************
+*** 456,462 ****
+ }
+
+
+! static int byte_to_keyboard(byt)
+ unsigned char byt;
+ {
+ int i;
+--- 456,465 ----
+ }
+
+
+! #ifndef XSERVERSUPPORT
+! static
+! #endif
+! int byte_to_keyboard(byt)
+ unsigned char byt;
+ {
+ int i;
+***************
+*** 495,497 ****
+--- 498,544 ----
+ break;
+ }
+ }
++
++ #ifdef XSERVERSUPPORT
++ #include <kbd.h>
++ #include <kbio.h>
++
++ /*
++ * Execute a keyboard command; return 0 on success.
++ */
++ kbd_docmd(h, cmd)
++ register struct kdhglobals *h;
++ int cmd;
++ {
++ switch (cmd) {
++
++ case KBD_CMD_BELL:
++ case KBD_CMD_NOBELL:
++ /* Supported by type 2, 3, and 4 keyboards */
++ break;
++
++ case KBD_CMD_CLICK:
++ /* Unsupported by type 2 keyboards */
++ if (h->kbd_id != KB_SUN2) {
++ h->kbd_click = 1;
++ break;
++ }
++ return (EINVAL);
++
++ case KBD_CMD_NOCLICK:
++ /* Unsupported by type 2 keyboards */
++ if (h->kbd_id != KB_SUN2) {
++ h->kbd_click = 0;
++ break;
++ }
++ return (EINVAL);
++
++ default:
++ return (EINVAL); /* ENOTTY? EOPNOTSUPP? */
++ }
++
++ if (timeout(byte_to_keyboard, cmd, 1) < 0)
++ return (ENOSPC); /* ERESTART? */
++ return (0);
++ }
++ #endif
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/sun.h b/nx-X11/programs/Xserver/hw/sunLynx/sun.h
new file mode 100644
index 000000000..edca59c19
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/sun.h
@@ -0,0 +1,486 @@
+/* $Xorg: sun.h,v 1.3 2000/08/17 19:48:36 cpqbld Exp $ */
+
+/* This is sun.h modified for LynxOS */
+
+/*-
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/sun.h,v 3.7 2001/07/25 15:05:02 dawes Exp $ */
+
+#ifndef _SUN_H_
+#define _SUN_H_
+
+/* X headers */
+#include <X11/Xos.h>
+#undef index /* don't mangle silly Sun structure member names */
+#include <X11/X.h>
+#include <X11/Xproto.h>
+
+/* general system headers */
+#ifndef NOSTDHDRS
+# include <stdlib.h>
+#else
+# include <malloc.h>
+extern char *getenv();
+#endif
+
+/* system headers common to both SunOS and Solaris */
+#include <sys/param.h>
+#include <sys/file.h>
+#ifndef Lynx
+# include <sys/filio.h>
+#else
+# include <sys/termio.h> /* include this before ioctl.h ... */
+#endif
+#include <sys/ioctl.h>
+#include <sys/resource.h>
+
+#ifdef SVR4
+# ifdef X_POSIX_C_SOURCE
+# define _POSIX_C_SOURCE X_POSIX_C_SOURCE
+# include <signal.h>
+# undef _POSIX_C_SOURCE
+# else
+# define _POSIX_SOURCE
+# include <signal.h>
+# undef _POSIX_SOURCE
+# endif
+#endif
+
+#include <fcntl.h>
+
+#ifndef __bsdi__
+# if !defined(__NetBSD__) && !defined(__OpenBSD__)
+# ifndef Lynx
+# ifndef i386
+# include <poll.h>
+# else
+# include <sys/poll.h>
+# endif
+# endif
+# endif
+#else
+# include <unistd.h>
+#endif
+
+#include <errno.h>
+#include <memory.h>
+
+/*
+ * Sun specific headers Sun moved in Solaris, and are different for NetBSD.
+ *
+ * Even if only needed by one source file, I have put them here
+ * to simplify finding them...
+ */
+#ifdef SVR4
+# include <sys/fbio.h>
+# include <sys/kbd.h>
+# include <sys/kbio.h>
+# include <sys/msio.h>
+# include <sys/vuid_event.h>
+# include <sys/memreg.h>
+# include <stropts.h>
+# define usleep(usec) poll((struct pollfd *) 0, (size_t) 0, usec / 1000)
+#else
+# if !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(Lynx)
+# include <sun/fbio.h>
+# include <sundev/kbd.h>
+# include <sundev/kbio.h>
+# include <sundev/msio.h>
+# include <sundev/vuid_event.h>
+# include <pixrect/pixrect.h>
+# include <pixrect/memreg.h>
+extern int ioctl();
+extern int getrlimit();
+extern int setrlimit();
+extern int getpagesize();
+# else
+# if defined (__NetBSD__) || defined (__OpenBSD__)
+# include <machine/fbio.h>
+# include <machine/kbd.h>
+# include <machine/kbio.h>
+# include <machine/vuid_event.h>
+# endif
+# ifdef __bsdi__
+# include <sys/fbio.h>
+# include </sys/sparc/dev/kbd.h>
+# include </sys/sparc/dev/kbio.h>
+# include </sys/sparc/dev/vuid_event.h>
+# endif
+# ifdef Lynx
+# ifndef __P
+# define __P(x) x
+# endif
+# include <signal.h>
+# ifdef PATCHED_CONSOLE
+# include <kbio.h>
+# include <kbd.h>
+# else
+# define KB_SUN2 2 /* type 2 keyboard */
+# define KB_SUN3 3 /* type 3 keyboard */
+# define KB_SUN4 4 /* type 4 keyboard */
+# define KIOCSLED TIOCLED
+# define LED_NUM_LOCK NUM_LOCK
+# define LED_SCROLL_LOCK SCROL_LOCK
+# define LED_CAPS_LOCK CAPS_LOCK
+# define LED_COMPOSE COMPOSE_LED
+# endif
+# include <smem.h>
+# include "fbio.h"
+# include "vuid_event.h"
+# define FBIORESET _IO('F', 29)
+# endif
+# endif
+#endif
+extern int gettimeofday();
+
+/*
+ * Server specific headers
+ */
+#include "misc.h"
+#undef abs /* don't munge function prototypes in headers, sigh */
+#include "scrnintstr.h"
+#ifdef NEED_EVENTS
+# include "inputstr.h"
+#endif
+#include "input.h"
+#include "colormapst.h"
+#include "colormap.h"
+#include "cursorstr.h"
+#include "cursor.h"
+#include "dixstruct.h"
+#include "dix.h"
+#include "opaque.h"
+#include "resource.h"
+#include "servermd.h"
+#include "windowstr.h"
+
+/*
+ * ddx specific headers
+ */
+#ifndef PSZ
+#define PSZ 8
+#endif
+
+#include "mi/mibstore.h"
+#include "mi/mipointer.h"
+
+extern int monitorResolution;
+
+
+/* Frame buffer devices */
+#ifdef SVR4
+# define CGTWO0DEV "/dev/fbs/cgtwo0"
+# define CGTWO1DEV "/dev/fbs/cgtwo1"
+# define CGTWO2DEV "/dev/fbs/cgtwo2"
+# define CGTWO3DEV "/dev/fbs/cgtwo3"
+# define CGTHREE0DEV "/dev/fbs/cgthree0"
+# define CGTHREE1DEV "/dev/fbs/cgthree1"
+# define CGTHREE2DEV "/dev/fbs/cgthree2"
+# define CGTHREE3DEV "/dev/fbs/cgthree3"
+# define CGFOUR0DEV "/dev/fbs/cgfour0"
+# define CGSIX0DEV "/dev/fbs/cgsix0"
+# define CGSIX1DEV "/dev/fbs/cgsix1"
+# define CGSIX2DEV "/dev/fbs/cgsix2"
+# define CGSIX3DEV "/dev/fbs/cgsix3"
+# define BWTWO0DEV "/dev/fbs/bwtwo0"
+# define BWTWO1DEV "/dev/fbs/bwtwo1"
+# define BWTWO2DEV "/dev/fbs/bwtwo2"
+# define BWTWO3DEV "/dev/fbs/bwtwo3"
+# define CGEIGHT0DEV "/dev/fbs/cgeight0"
+#else
+# define CGTWO0DEV "/dev/cgtwo0"
+# define CGTWO1DEV "/dev/cgtwo1"
+# define CGTWO2DEV "/dev/cgtwo2"
+# define CGTWO3DEV "/dev/cgtwo3"
+# define CGTHREE0DEV "/dev/cgthree0"
+# define CGTHREE1DEV "/dev/cgthree1"
+# define CGTHREE2DEV "/dev/cgthree2"
+# define CGTHREE3DEV "/dev/cgthree3"
+# define CGFOUR0DEV "/dev/cgfour0"
+# define CGSIX0DEV "/dev/cgsix0"
+# define CGSIX1DEV "/dev/cgsix1"
+# define CGSIX2DEV "/dev/cgsix2"
+# define CGSIX3DEV "/dev/cgsix3"
+# define BWTWO0DEV "/dev/bwtwo0"
+# define BWTWO1DEV "/dev/bwtwo1"
+# define BWTWO2DEV "/dev/bwtwo2"
+# define BWTWO3DEV "/dev/bwtwo3"
+# define CGEIGHT0DEV "/dev/cgeight0"
+#endif
+
+/*
+ * MAXEVENTS is the maximum number of events the mouse and keyboard functions
+ * will read on a given call to their GetEvents vectors.
+ */
+#ifndef Lynx
+#define MAXEVENTS 32
+#else
+/* currently our mouse stuff is pretty naive, so we need a lot of events */
+#define MAXEVENTS 256
+#endif
+
+/*
+ * Data private to any sun keyboard.
+ */
+typedef struct {
+ int fd;
+ int type; /* Type of keyboard */
+ int layout; /* The layout of the keyboard */
+ int click; /* kbd click save state */
+ Leds leds; /* last known LED state */
+} sunKbdPrivRec, *sunKbdPrivPtr;
+
+extern sunKbdPrivRec sunKbdPriv;
+
+/*
+ * Data private to any sun pointer device.
+ */
+typedef struct {
+ int fd;
+ int bmask; /* last known button state */
+} sunPtrPrivRec, *sunPtrPrivPtr;
+
+extern sunPtrPrivRec sunPtrPriv;
+
+typedef struct {
+ BYTE key;
+ CARD8 modifiers;
+} SunModmapRec;
+
+typedef struct {
+ int width, height;
+ Bool has_cursor;
+ CursorPtr pCursor; /* current cursor */
+} sunCursorRec, *sunCursorPtr;
+
+typedef struct {
+ ColormapPtr installedMap;
+ CloseScreenProcPtr CloseScreen;
+ void (*UpdateColormap)();
+ sunCursorRec hardwareCursor;
+ Bool hasHardwareCursor;
+} sunScreenRec, *sunScreenPtr;
+
+#define GetScreenPrivate(s) ((sunScreenPtr) ((s)->devPrivates[sunScreenIndex].ptr))
+#define SetupScreen(s) sunScreenPtr pPrivate = GetScreenPrivate(s)
+
+typedef struct {
+#ifndef Lynx
+ unsigned char* fb; /* Frame buffer itself */
+#else
+ unsigned char* fbuf; /* Frame buffer itself */
+ void* ramdac; /* Color LookUp table */
+ void* fb; /* GX FB control registers:
+ * sunGX.c relies on this name
+ */
+ void* tec; /* GX TEC registers */
+ void* thc; /* GX THC registers */
+ void* fhc; /* GX FHC registers */
+#endif
+ int fd; /* frame buffer for ioctl()s, */
+ struct fbtype info; /* Frame buffer characteristics */
+ void (*EnterLeave)();/* screen switch */
+ unsigned char* fbPriv; /* fbattr stuff, for the real type */
+} fbFd;
+
+typedef Bool (*sunFbInitProc)(
+ int /* screen */,
+ ScreenPtr /* pScreen */,
+ int /* argc */,
+ char** /* argv */
+);
+
+typedef struct {
+ sunFbInitProc init; /* init procedure for this fb */
+ char* name; /* /usr/include/fbio names */
+} sunFbDataRec;
+
+#ifdef XKB
+extern Bool noXkbExtension;
+#endif
+
+extern Bool sunAutoRepeatHandlersInstalled;
+extern long sunAutoRepeatInitiate;
+extern long sunAutoRepeatDelay;
+extern sunFbDataRec sunFbData[];
+extern fbFd sunFbs[];
+extern Bool sunSwapLkeys;
+extern Bool sunFlipPixels;
+extern Bool sunActiveZaphod;
+extern Bool sunFbInfo;
+extern Bool sunCG4Frob;
+extern Bool sunNoGX;
+extern int sunScreenIndex;
+extern int* sunProtected;
+
+extern Bool sunCursorInitialize(
+ ScreenPtr /* pScreen */
+);
+
+extern void sunDisableCursor(
+ ScreenPtr /* pScreen */
+);
+
+extern int sunChangeKbdTranslation(
+ int /* fd */,
+ Bool /* makeTranslated */
+);
+
+extern void sunNonBlockConsoleOff(
+#if defined(SVR4) || defined(CSRG_BASED) || defined(Lynx)
+ void
+#else
+ char* /* arg */
+#endif
+);
+
+extern void sunEnqueueEvents(
+ void
+);
+
+extern void sunEnqueueKbdEvents(
+ void
+);
+
+extern void sunEnqueueMseEvents(
+ void
+);
+
+extern int sunGXInit(
+ ScreenPtr /* pScreen */,
+ fbFd* /* fb */
+);
+
+extern Bool sunSaveScreen(
+ ScreenPtr /* pScreen */,
+ int /* on */
+);
+
+extern Bool sunScreenInit(
+ ScreenPtr /* pScreen */
+);
+
+extern pointer sunMemoryMap(
+ size_t /* len */,
+ off_t /* off */,
+ int /* fd */
+#ifdef Lynx
+ , char * /* name */
+#endif
+);
+
+extern Bool sunScreenAllocate(
+ ScreenPtr /* pScreen */
+);
+
+extern Bool sunInitCommon(
+ int /* scrn */,
+ ScreenPtr /* pScrn */,
+ off_t /* offset */,
+ Bool (* /* init1 */)(),
+ void (* /* init2 */)(),
+ Bool (* /* cr_cm */)(),
+ Bool (* /* save */)(),
+ int /* fb_off */
+);
+
+extern Firm_event* sunKbdGetEvents(
+ int /* fd */,
+ Bool /* on */,
+ int* /* pNumEvents */,
+ Bool* /* pAgain */
+);
+
+extern Firm_event* sunMouseGetEvents(
+ int /* fd */,
+ Bool /* on */,
+ int* /* pNumEvents */,
+ Bool* /* pAgain */
+);
+
+extern void sunKbdEnqueueEvent(
+ DeviceIntPtr /* device */,
+ Firm_event* /* fe */
+);
+
+extern void sunMouseEnqueueEvent(
+ DeviceIntPtr /* device */,
+ Firm_event* /* fe */
+);
+
+extern int sunKbdProc(
+ DeviceIntPtr /* pKeyboard */,
+ int /* what */
+);
+
+extern int sunMouseProc(
+ DeviceIntPtr /* pMouse */,
+ int /* what */
+);
+
+extern void sunKbdWait(
+ void
+);
+
+/*-
+ * TVTOMILLI(tv)
+ * Given a struct timeval, convert its time into milliseconds...
+ */
+#define TVTOMILLI(tv) (((tv).tv_usec/1000)+((tv).tv_sec*1000))
+
+extern Bool sunCfbSetupScreen(
+ ScreenPtr /* pScreen */,
+ pointer /* pbits */, /* pointer to screen bitmap */
+ int /* xsize */, /* in pixels */
+ int /* ysize */,
+ int /* dpix */, /* dots per inch */
+ int /* dpiy */, /* dots per inch */
+ int /* width */, /* pixel width of frame buffer */
+ int /* bpp */ /* bits per pixel of root */
+);
+
+extern Bool sunCfbFinishScreenInit(
+ ScreenPtr /* pScreen */,
+ pointer /* pbits */, /* pointer to screen bitmap */
+ int /* xsize */, /* in pixels */
+ int /* ysize */,
+ int /* dpix */, /* dots per inch */
+ int /* dpiy */, /* dots per inch */
+ int /* width */, /* pixel width of frame buffer */
+ int /* bpp */ /* bits per pixel of root */
+);
+
+extern Bool sunCfbScreenInit(
+ ScreenPtr /* pScreen */,
+ pointer /* pbits */, /* pointer to screen bitmap */
+ int /* xsize */, /* in pixels */
+ int /* ysize */,
+ int /* dpix */, /* dots per inch */
+ int /* dpiy */, /* dots per inch */
+ int /* width */, /* pixel width of frame buffer */
+ int /* bpp */ /* bits per pixel of root */
+);
+
+extern void sunInstallColormap(
+ ColormapPtr /* cmap */
+);
+
+extern void sunUninstallColormap(
+ ColormapPtr /* cmap */
+);
+
+extern int sunListInstalledColormaps(
+ ScreenPtr /* pScreen */,
+ Colormap* /* pCmapList */
+);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/sunLyCfb.c b/nx-X11/programs/Xserver/hw/sunLynx/sunLyCfb.c
new file mode 100644
index 000000000..48f63c759
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/sunLyCfb.c
@@ -0,0 +1,372 @@
+/* $Xorg: sunLyCfb.c,v 1.4 2001/02/09 02:04:44 xorgcvs Exp $ */
+/*
+ * This is sunCfb.c modified for LynxOS
+ * Copyright 1996 by Thomas Mueller
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/sunLyCfb.c,v 3.4 2001/01/17 22:36:53 dawes Exp $ */
+
+/*
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*
+ * Copyright 1987 by the Regents of the University of California
+ * Copyright 1987 by Adam de Boor, UC Berkeley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/****************************************************************/
+/* Modified from sunCG4C.c for X11R3 by Tom Jarmolowski */
+/****************************************************************/
+
+/*
+ * Copyright 1991, 1992, 1993 Kaleb S. Keithley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. Kaleb S. Keithley makes no
+ * representations about the suitability of this software for
+ * any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#include "sun.h"
+#include "cfb/cfb.h"
+#include "mi/miline.h"
+
+#define GXZEROLINEBIAS (OCTANT1 | OCTANT3 | OCTANT4 | OCTANT6)
+
+static void CGUpdateColormap(pScreen, dex, count, rmap, gmap, bmap)
+ ScreenPtr pScreen;
+ int dex, count;
+ u_char *rmap, *gmap, *bmap;
+{
+ struct fbcmap sunCmap;
+
+ sunCmap.index = dex;
+ sunCmap.count = count;
+ sunCmap.red = &rmap[dex];
+ sunCmap.green = &gmap[dex];
+ sunCmap.blue = &bmap[dex];
+
+ if (sunIoctl(&sunFbs[pScreen->myNum], FBIOPUTCMAP, &sunCmap) < 0) {
+ Error("CGUpdateColormap");
+ FatalError( "CGUpdateColormap: FBIOPUTCMAP failed\n" );
+ }
+}
+
+void sunInstallColormap(cmap)
+ ColormapPtr cmap;
+{
+ SetupScreen(cmap->pScreen);
+ register int i;
+ register Entry *pent;
+ register VisualPtr pVisual = cmap->pVisual;
+ u_char rmap[256], gmap[256], bmap[256];
+ unsigned long rMask, gMask, bMask;
+ int oRed, oGreen, oBlue;
+
+ if (cmap == pPrivate->installedMap)
+ return;
+ if (pPrivate->installedMap)
+ WalkTree(pPrivate->installedMap->pScreen, TellLostMap,
+ (pointer) &(pPrivate->installedMap->mid));
+ if ((pVisual->class | DynamicClass) == DirectColor) {
+ if (pVisual->ColormapEntries < 256) {
+ rMask = pVisual->redMask;
+ gMask = pVisual->greenMask;
+ bMask = pVisual->blueMask;
+ oRed = pVisual->offsetRed;
+ oGreen = pVisual->offsetGreen;
+ oBlue = pVisual->offsetBlue;
+ } else {
+ rMask = gMask = bMask = 255;
+ oRed = oGreen = oBlue = 0;
+ }
+ for (i = 0; i < 256; i++) {
+ rmap[i] = cmap->red[(i & rMask) >> oRed].co.local.red >> 8;
+ gmap[i] = cmap->green[(i & gMask) >> oGreen].co.local.green >> 8;
+ bmap[i] = cmap->blue[(i & bMask) >> oBlue].co.local.blue >> 8;
+ }
+ } else {
+ for (i = 0, pent = cmap->red;
+ i < pVisual->ColormapEntries;
+ i++, pent++) {
+ if (pent->fShared) {
+ rmap[i] = pent->co.shco.red->color >> 8;
+ gmap[i] = pent->co.shco.green->color >> 8;
+ bmap[i] = pent->co.shco.blue->color >> 8;
+ }
+ else {
+ rmap[i] = pent->co.local.red >> 8;
+ gmap[i] = pent->co.local.green >> 8;
+ bmap[i] = pent->co.local.blue >> 8;
+ }
+ }
+ }
+ pPrivate->installedMap = cmap;
+ (*pPrivate->UpdateColormap) (cmap->pScreen, 0, 256, rmap, gmap, bmap);
+ WalkTree(cmap->pScreen, TellGainedMap, (pointer) &(cmap->mid));
+}
+
+void sunUninstallColormap(cmap)
+ ColormapPtr cmap;
+{
+ SetupScreen(cmap->pScreen);
+ if (cmap == pPrivate->installedMap) {
+ Colormap defMapID = cmap->pScreen->defColormap;
+
+ if (cmap->mid != defMapID) {
+ ColormapPtr defMap = (ColormapPtr) LookupIDByType(defMapID,
+ RT_COLORMAP);
+
+ if (defMap)
+ (*cmap->pScreen->InstallColormap)(defMap);
+ else
+ ErrorF("sunFbs: Can't find default colormap\n");
+ }
+ }
+}
+
+int sunListInstalledColormaps(pScreen, pCmapList)
+ ScreenPtr pScreen;
+ Colormap *pCmapList;
+{
+ SetupScreen(pScreen);
+ *pCmapList = pPrivate->installedMap->mid;
+ return (1);
+}
+
+static void CGStoreColors(pmap, ndef, pdefs)
+ ColormapPtr pmap;
+ int ndef;
+ xColorItem *pdefs;
+{
+ SetupScreen(pmap->pScreen);
+ u_char rmap[256], gmap[256], bmap[256];
+ xColorItem expanddefs[256];
+ register int i;
+
+ if (pPrivate->installedMap != NULL && pPrivate->installedMap != pmap)
+ return;
+ if ((pmap->pVisual->class | DynamicClass) == DirectColor) {
+ ndef = cfbExpandDirectColors(pmap, ndef, pdefs, expanddefs);
+ pdefs = expanddefs;
+ }
+ while (ndef--) {
+ i = pdefs->pixel;
+ rmap[i] = pdefs->red >> 8;
+ gmap[i] = pdefs->green >> 8;
+ bmap[i] = pdefs->blue >> 8;
+ (*pPrivate->UpdateColormap) (pmap->pScreen, i, 1, rmap, gmap, bmap);
+ pdefs++;
+ }
+}
+
+static void CGScreenInit (pScreen)
+ ScreenPtr pScreen;
+{
+#ifndef STATIC_COLOR /* { */
+ SetupScreen (pScreen);
+ pScreen->InstallColormap = sunInstallColormap;
+ pScreen->UninstallColormap = sunUninstallColormap;
+ pScreen->ListInstalledColormaps = sunListInstalledColormaps;
+ pScreen->StoreColors = CGStoreColors;
+ pPrivate->UpdateColormap = CGUpdateColormap;
+ if (sunFlipPixels) {
+ Pixel pixel = pScreen->whitePixel;
+ pScreen->whitePixel = pScreen->blackPixel;
+ pScreen->blackPixel = pixel;
+ }
+#endif /* } */
+}
+
+static void checkMono (argc, argv)
+ int argc;
+ char** argv;
+{
+ int i;
+
+ for (i = 1; i < argc; i++)
+ if (strcmp (argv[i], "-mono") == 0)
+ ErrorF ("-mono not appropriate for CG3/CG6\n");
+}
+
+Bool sunCG3Init (screen, pScreen, argc, argv)
+ int screen; /* what screen am I going to be */
+ ScreenPtr pScreen; /* The Screen to initialize */
+ int argc; /* The number of the Server's arguments. */
+ char **argv; /* The arguments themselves. Don't change! */
+{
+ unsigned long addr;
+
+ checkMono (argc, argv);
+ sunFbs[screen].EnterLeave = (void (*)())NoopDDA;
+ if (ioctl(sunFbs[screen].fd, TIO_QUERYLOC, &addr) < 0) {
+ perror("TIO_QUERYLOC");
+ FatalError("%s:%d can't query FB addr sunFbs[%d].fd=%d\n",
+ __FILE__, __LINE__, screen, sunFbs[screen]);
+ }
+ return sunInitCommon (screen, pScreen, (off_t) addr,
+ sunCfbScreenInit, CGScreenInit,
+ cfbCreateDefColormap, sunSaveScreen, 0);
+}
+
+Bool sunCG6Init (screen, pScreen, argc, argv)
+ int screen; /* The index of pScreen in the ScreenInfo */
+ ScreenPtr pScreen; /* The Screen to initialize */
+ int argc; /* The number of the Server's arguments. */
+ char** argv; /* The arguments themselves. Don't change! */
+{
+ unsigned long dacoffset;
+ unsigned long addr;
+ pointer fbc;
+ pointer fhc;
+ pointer fb;
+
+ checkMono (argc, argv);
+ if (!sunScreenAllocate (pScreen))
+ return FALSE;
+ if (!sunFbs[screen].fbuf) {
+ if (ioctl(sunFbs[screen].fd, TIO_QUERYLOC, &addr) < 0) {
+ perror("TIO_QUERYLOC");
+ FatalError("%s:%d can't query FB addr sunFbs[%d].fd=%d\n",
+ __FILE__, __LINE__, screen, sunFbs[screen]);
+ }
+ if ((fb = sunMemoryMap(0x00100000, (off_t) addr + 0x00800000UL,
+ sunFbs[screen].fd, "FB")) == NULL)
+ return FALSE;
+
+ if ((fbc = sunMemoryMap(0x2000, (off_t) addr + 0x00700000UL,
+ sunFbs[screen].fd, "FBC_TEC")) == NULL)
+ return FALSE;
+
+ if ((fhc = sunMemoryMap(0x2000, (off_t) addr + 0x00300000UL,
+ sunFbs[screen].fd, "FHC_THC")) == NULL)
+ return FALSE;
+
+ sunFbs[screen].fhc = fhc;
+ sunFbs[screen].thc = (char *)fhc + 0x1000;
+ sunFbs[screen].fb = fbc;
+ sunFbs[screen].tec = (char *)fbc + 0x1000;
+ sunFbs[screen].fbuf = fb;
+
+ if (ioctl(sunFbs[screen].fd, TIO_QUERYRAMDAC, &dacoffset) < 0)
+ FatalError("can't query DAC addr\n");
+ if ((sunFbs[screen].ramdac =
+ sunMemoryMap((size_t) sunFbs[screen].info.fb_cmsize * 3,
+ (unsigned long)addr + dacoffset,
+ sunFbs[screen].fd, "DAC")) == NULL)
+ return FALSE;
+ }
+
+ sunFbs[screen].EnterLeave = (void (*)())NoopDDA;
+ if (!sunCfbSetupScreen (pScreen,
+ sunFbs[screen].fbuf,
+ sunFbs[screen].info.fb_width,
+ sunFbs[screen].info.fb_height,
+ monitorResolution, monitorResolution,
+ sunFbs[screen].info.fb_width,
+ sunFbs[screen].info.fb_depth))
+ return FALSE;
+ if (sunNoGX == FALSE) {
+ /* cleanup CG& hardware state */
+ if (sunIoctl(&sunFbs[screen], FBIORESET, 0) < 0)
+ perror("FBIORESET");
+ if (!sunGXInit (pScreen, &sunFbs[screen]))
+ return FALSE;
+ }
+ if (!sunCfbFinishScreenInit(pScreen,
+ sunFbs[screen].fbuf,
+ sunFbs[screen].info.fb_width,
+ sunFbs[screen].info.fb_height,
+ monitorResolution, monitorResolution,
+ sunFbs[screen].info.fb_width,
+ sunFbs[screen].info.fb_depth))
+ return FALSE;
+ miInitializeBackingStore(pScreen);
+ if (sunNoGX == FALSE) {
+ miSetZeroLineBias(pScreen, GXZEROLINEBIAS);
+ }
+ CGScreenInit (pScreen);
+ if (!sunScreenInit (pScreen))
+ return FALSE;
+ sunSaveScreen (pScreen, SCREEN_SAVER_OFF);
+ return cfbCreateDefColormap(pScreen);
+}
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/sunLyFbs.c b/nx-X11/programs/Xserver/hw/sunLynx/sunLyFbs.c
new file mode 100644
index 000000000..25448d91d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/sunLyFbs.c
@@ -0,0 +1,292 @@
+/* $Xorg: sunLyFbs.c,v 1.4 2001/02/09 02:04:44 xorgcvs Exp $ */
+/*
+ * This is sunFbs.c modified for LynxOS
+ * Copyright 1996 by Thomas Mueller
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/sunLyFbs.c,v 3.6 2001/12/14 19:59:44 dawes Exp $ */
+
+/*
+Copyright 1990, 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*
+ * Copyright 1987 by the Regents of the University of California
+ * Copyright 1987 by Adam de Boor, UC Berkeley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/****************************************************************/
+/* Modified from sunCG4C.c for X11R3 by Tom Jarmolowski */
+/****************************************************************/
+
+#include "sun.h"
+#include <smem.h>
+
+int sunScreenIndex;
+
+static unsigned long generation = 0;
+
+pointer sunMemoryMap (
+ size_t len,
+ off_t off,
+ int fd,
+ char *name
+ )
+{
+ int pagemask, mapsize;
+ caddr_t addr;
+ pointer mapaddr;
+
+ pagemask = getpagesize() - 1;
+ mapsize = ((int) len + pagemask) & ~pagemask;
+ addr = 0;
+
+ mapaddr = smem_create(name, (char *)off, mapsize, SM_READ|SM_WRITE);
+ if (mapaddr == (pointer) -1) {
+ Error ("mapping frame buffer memory");
+ (void) close (fd);
+ mapaddr = (pointer) NULL;
+ }
+ return mapaddr;
+}
+
+Bool sunScreenAllocate (
+ ScreenPtr pScreen)
+{
+ sunScreenPtr pPrivate;
+ extern int AllocateScreenPrivateIndex();
+
+ if (generation != serverGeneration)
+ {
+ sunScreenIndex = AllocateScreenPrivateIndex();
+ if (sunScreenIndex < 0)
+ return FALSE;
+ generation = serverGeneration;
+ }
+ pPrivate = (sunScreenPtr) xalloc (sizeof (sunScreenRec));
+ if (!pPrivate)
+ return FALSE;
+
+ pScreen->devPrivates[sunScreenIndex].ptr = (pointer) pPrivate;
+ return TRUE;
+}
+
+Bool sunSaveScreen (
+ ScreenPtr pScreen,
+ int on)
+{
+ int state;
+
+ if (on != SCREEN_SAVER_FORCER)
+ {
+ if (on == SCREEN_SAVER_ON)
+ state = 0;
+ else
+ state = 1;
+ (void) sunIoctl(&sunFbs[pScreen->myNum], FBIOSVIDEO, &state);
+ }
+ return( TRUE );
+}
+
+static Bool closeScreen (i, pScreen)
+ int i;
+ ScreenPtr pScreen;
+{
+ SetupScreen(pScreen);
+ Bool ret;
+ struct fbcmap sunCmap;
+ unsigned char color;
+
+ (void) OsSignal (SIGIO, SIG_IGN);
+ sunDisableCursor (pScreen);
+ pScreen->CloseScreen = pPrivate->CloseScreen;
+ ret = (*pScreen->CloseScreen) (i, pScreen);
+ (void) (*pScreen->SaveScreen) (pScreen, SCREEN_SAVER_OFF);
+ /* probably this doesn't belong here: restore black&white cmap */
+ sunCmap.count = 1;
+ sunCmap.index = 0;
+ sunCmap.red = sunCmap.green = sunCmap.blue = &color;
+ color = 0xff;
+ (void) sunIoctl(&sunFbs[pScreen->myNum], FBIOPUTCMAP, &sunCmap);
+ sunCmap.index = 0xff;
+ color = 0;
+ (void) sunIoctl(&sunFbs[pScreen->myNum], FBIOPUTCMAP, &sunCmap);
+ xfree ((pointer) pPrivate);
+ return ret;
+}
+
+Bool sunScreenInit (
+ ScreenPtr pScreen)
+{
+ SetupScreen(pScreen);
+ extern void sunBlockHandler();
+ extern void sunWakeupHandler();
+ static ScreenPtr autoRepeatScreen;
+ extern miPointerScreenFuncRec sunPointerScreenFuncs;
+
+ pPrivate->installedMap = 0;
+ pPrivate->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = closeScreen;
+ pScreen->SaveScreen = sunSaveScreen;
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ /*
+ * Block/Unblock handlers
+ */
+ if (sunAutoRepeatHandlersInstalled == FALSE) {
+ autoRepeatScreen = pScreen;
+ sunAutoRepeatHandlersInstalled = TRUE;
+ }
+
+ if (pScreen == autoRepeatScreen) {
+ pScreen->BlockHandler = sunBlockHandler;
+ pScreen->WakeupHandler = sunWakeupHandler;
+ }
+#ifdef XKB
+ } else {
+ /* this works around a weird behaviour on LynxOS 2.4.0:
+ * usually we have no problems using true SIGIO driven mouse input
+ * as it is used on the other UN*X Suns. On LynxOS we have a
+ * strange behaviour upon the very first server startup after a
+ * reboot. We won't get SIGIOs from the mouse device. The mouse
+ * will only move if we get SIGIOs from the keyboard.
+ * The solution (for now) is to use a WakeupHandler and
+ * poll the mouse file descriptor.
+ */
+ pScreen->WakeupHandler = sunWakeupHandler;
+ }
+#endif
+ if (!sunCursorInitialize (pScreen))
+ miDCInitialize (pScreen, &sunPointerScreenFuncs);
+ return TRUE;
+}
+
+Bool sunInitCommon (
+ int scrn,
+ ScreenPtr pScrn,
+ off_t offset,
+ Bool (*init1)(),
+ void (*init2)(),
+ Bool (*cr_cm)(),
+ Bool (*save)(),
+ int fb_off)
+{
+ unsigned char* fb = sunFbs[scrn].fbuf;
+ unsigned char* dac = sunFbs[scrn].ramdac;
+
+ if (!sunScreenAllocate (pScrn))
+ return FALSE;
+ if (!fb) {
+ if ((fb = sunMemoryMap ((size_t) sunFbs[scrn].info.fb_size,
+ (unsigned long)offset + 0x00800000UL,
+ sunFbs[scrn].fd, "FB")) == NULL)
+ return FALSE;
+ sunFbs[scrn].fbuf = fb;
+ if (!dac)
+ {
+ unsigned long dacoffset;
+
+ if (ioctl(sunFbs[scrn].fd, TIO_QUERYRAMDAC, &dacoffset) < 0)
+ FatalError("can't query DAC addr\n");
+ if ((dac = sunMemoryMap((size_t) sunFbs[scrn].info.fb_cmsize * 3,
+ (unsigned long)offset + dacoffset,
+ sunFbs[scrn].fd, "DAC")) == NULL)
+ return FALSE;
+
+ sunFbs[scrn].ramdac = dac;
+ }
+ }
+ /* mfbScreenInit() or cfbScreenInit() */
+ if (!(*init1)(pScrn, fb + fb_off,
+ sunFbs[scrn].info.fb_width,
+ sunFbs[scrn].info.fb_height,
+ monitorResolution, monitorResolution,
+ sunFbs[scrn].info.fb_width,
+ sunFbs[scrn].info.fb_depth))
+ return FALSE;
+ miInitializeBackingStore(pScrn);
+ /* sunCGScreenInit() if cfb... */
+ if (init2)
+ (*init2)(pScrn);
+ if (!sunScreenInit(pScrn))
+ return FALSE;
+ (void) (*save) (pScrn, SCREEN_SAVER_OFF);
+ return (*cr_cm)(pScrn);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/sunLyInit.c b/nx-X11/programs/Xserver/hw/sunLynx/sunLyInit.c
new file mode 100644
index 000000000..941b363eb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/sunLyInit.c
@@ -0,0 +1,648 @@
+/* $Xorg: sunLyInit.c,v 1.3 2000/08/17 19:48:36 cpqbld Exp $ */
+/*
+ * This is sunInit.c modified for LynxOS
+ * Copyright 1996 by Thomas Mueller
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/sunLyInit.c,v 3.8 2001/01/17 22:36:53 dawes Exp $ */
+
+/*
+ * Copyright 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+*******************************************************/
+
+#include "sun.h"
+#include "gcstruct.h"
+#include "mi.h"
+#include "mibstore.h"
+#include "cfb.h"
+
+Bool onConsole = FALSE; /* wether stdin is /dev/con */
+
+/* maximum pixmap depth */
+#ifndef SUNMAXDEPTH
+#define SUNMAXDEPTH 8
+#endif
+
+extern Bool sunBW2Init(
+ int /* screen */,
+ ScreenPtr /* pScreen */,
+ int /* argc */,
+ char** /* argv */
+);
+#define BW2I sunBW2Init
+#if SUNMAXDEPTH == 1 /* { */
+#define CG3I NULL
+#define CG6I NULL
+#else /* }{ */
+extern Bool sunCG3Init(
+ int /* screen */,
+ ScreenPtr /* pScreen */,
+ int /* argc */,
+ char** /* argv */
+);
+#define CG3I sunCG3Init
+#ifdef FBTYPE_SUNFAST_COLOR /* { */
+extern Bool sunCG6Init(
+ int /* screen */,
+ ScreenPtr /* pScreen */,
+ int /* argc */,
+ char** /* argv */
+);
+#define CG6I sunCG6Init
+#else /* }{ */
+#define CG6I NULL
+#endif /* } */
+#endif /* } */
+
+extern KeySymsRec sunKeySyms[];
+extern SunModmapRec *sunModMaps[];
+extern int sunMaxLayout;
+extern KeySym* sunType4KeyMaps[];
+extern SunModmapRec* sunType4ModMaps[];
+
+static Bool sunDevsInited = FALSE;
+
+Bool sunAutoRepeatHandlersInstalled; /* FALSE each time InitOutput called */
+Bool sunSwapLkeys = FALSE;
+Bool sunFlipPixels = FALSE;
+Bool sunFbInfo = FALSE;
+Bool sunCG4Frob = FALSE;
+Bool sunNoGX = FALSE;
+
+sunKbdPrivRec sunKbdPriv = {
+ -1, /* fd */
+ -1, /* type */
+ -1, /* layout */
+ 0, /* click */
+ (Leds)0, /* leds */
+};
+
+sunPtrPrivRec sunPtrPriv = {
+ -1, /* fd */
+ 0 /* Current button state */
+};
+
+/*
+ * The name member in the following table corresponds to the
+ * FBTYPE_* macros defined in /usr/include/sun/fbio.h file
+ */
+sunFbDataRec sunFbData[FBTYPE_LASTPLUSONE] = {
+ { NULL, "SUN1BW (bw1)" },
+ { NULL, "SUN1COLOR (cg1)" },
+ { BW2I, "SUN2BW (bw2)" },
+ { NULL, "SUN2COLOR (cg2)" },
+ { NULL, "SUN2GP (gp1/gp2)" },
+ { NULL, "SUN5COLOR (cg5/386i accel)" },
+ { CG3I, "SUN3COLOR (cg3)" },
+ { NULL, "MEMCOLOR (cg8)" },
+ { NULL, "SUN4COLOR (cg4)" },
+ { NULL, "NOTSUN1" },
+ { NULL, "NOTSUN2" },
+ { NULL, "NOTSUN3" },
+ { CG6I, "SUNFAST_COLOR (cg6/gx)" }, /* last we need */
+};
+
+/*
+ * a list of devices to try if there is no environment or command
+ * line list of devices
+ */
+#if SUNMAXDEPTH == 1 /* { */
+static char *fallbackList[] = {
+ "/dev/bwtwo",
+};
+#else /* }{ */
+static char *fallbackList[] = {
+ "/dev/bwtwo", "/dev/cgthree", "/dev/cgsix",
+};
+#endif /* } */
+
+#define FALLBACK_LIST_LEN sizeof fallbackList / sizeof fallbackList[0]
+
+fbFd sunFbs[MAXSCREENS];
+
+static PixmapFormatRec formats[] = {
+ { 1, 1, BITMAP_SCANLINE_PAD } /* 1-bit deep */
+#if SUNMAXDEPTH > 1
+ ,{ 8, 8, BITMAP_SCANLINE_PAD} /* 8-bit deep */
+#endif
+};
+#define NUMFORMATS (sizeof formats)/(sizeof formats[0])
+
+/*
+ * OpenFrameBuffer --
+ * Open a frame buffer according to several rules.
+ * Find the device to use by looking in the sunFbData table,
+ * an XDEVICE envariable, a -dev switch or using /dev/fb if trying
+ * to open screen 0 and all else has failed.
+ *
+ * Results:
+ * The fd of the framebuffer.
+ */
+static int OpenFrameBuffer(device, screen)
+ char *device; /* e.g. "/dev/cgtwo0" */
+ int screen; /* what screen am I going to be */
+{
+ int ret;
+ unsigned long dacoffset;
+ struct fbgattr *fbattr = NULL;
+ static int devFbUsed;
+ static struct fbgattr bw2 = {
+ 0, 0,
+ { FBTYPE_SUN2BW, 900, 1152, 1, 0, 0x00100000 },
+ { 0, -1},
+ -1
+ };
+ static struct fbgattr cg3 = {
+ 0, 0,
+ { FBTYPE_SUN3COLOR, 900, 1152, 8, 256, 0x00100000 },
+ { 0, -1},
+ -1
+ };
+ static struct fbgattr cg6 = {
+ 0, 0,
+ { FBTYPE_SUNFAST_COLOR, 900, 1152, 8, 256, 0x00100000 },
+ { 0, -1},
+ -1
+ };
+
+
+ sunFbs[screen].fd = sunKbdPriv.fd; /* /dev/con or /dev/kbd */
+ devFbUsed = TRUE;
+ /* apply some magic to work out what we're running on.
+ * why couldn't they just spend some time on a little
+ * FBIOGATTR ioctl()
+ */
+
+ ret = FALSE;
+ if (ioctl(sunFbs[screen].fd, TIO_QUERYRAMDAC, &dacoffset) < 0)
+ FatalError("can't query DAC addr\n");
+ if (dacoffset == 0x400000) {
+ if (strcmp(device, "/dev/cgthree") == 0)
+ fbattr = &cg3;
+ }
+ else if (dacoffset == 0x200000) {
+ if (strcmp(device, "/dev/cgsix") == 0)
+ fbattr = &cg6;
+ }
+#ifdef PATCHED_CONSOLE
+ else if (dacoffset == 0) {
+ if (strcmp(device, "/dev/bw2") == 0)
+ fbattr = &bw2;
+ }
+#endif
+ else
+ ErrorF("bogus DAC addr 0x%x, maybe it's the silly BWTWO bug\n", dacoffset);
+
+ if (fbattr) {
+ ret = TRUE;
+ sunFbs[screen].info = fbattr->fbtype;
+ }
+ sunFbs[screen].fbPriv = (pointer) fbattr;
+ if (fbattr && fbattr->fbtype.fb_type < FBTYPE_LASTPLUSONE &&
+ !sunFbData[fbattr->fbtype.fb_type].init) {
+ int _i;
+
+ ret = FALSE;
+ for (_i = 0; _i < FB_ATTR_NEMUTYPES; _i++) {
+ if (sunFbData[fbattr->emu_types[_i]].init) {
+ sunFbs[screen].info.fb_type = fbattr->emu_types[_i];
+ ret = TRUE;
+ if (sunFbInfo)
+ ErrorF ("%s is emulating a %s\n", device,
+ sunFbData[fbattr->fbtype.fb_type].name);
+ break;
+ }
+ }
+ }
+ if (sunFbInfo)
+ ErrorF ("%s is really a %s\n", device,
+ sunFbData[fbattr ? fbattr->fbtype.fb_type : sunFbs[screen].info.fb_type].name);
+ if (!ret)
+ sunFbs[screen].fd = -1;
+ return ret;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * SigIOHandler --
+ * Signal handler for SIGIO - input is available.
+ *
+ * Results:
+ * sunSigIO is set - ProcessInputEvents() will be called soon.
+ *
+ * Side Effects:
+ * None
+ *
+ *-----------------------------------------------------------------------
+ */
+/*ARGSUSED*/
+/*static*/ void SigIOHandler(sig)
+ int sig;
+{
+ int olderrno = errno;
+ sunEnqueueEvents();
+ errno = olderrno;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunNonBlockConsoleOff --
+ * Turn non-blocking mode on the console off, so you don't get logged
+ * out when the server exits.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------
+ */
+void sunNonBlockConsoleOff(
+ void
+)
+{
+ int i;
+
+#if 0
+ if (sunKbdPriv.fd >= 0)
+ {
+ i = fcntl(sunKbdPriv.fd, F_GETFL, 0);
+ if (i >= 0 && (i & FNDELAY)) {
+ (void) fcntl(sunKbdPriv.fd, F_SETFL, i & ~FNDELAY);
+ }
+ }
+#endif
+ for (i = 0; i < MAXSCREENS; i++) {
+ if (sunFbs[i].fbuf) {
+ smem_create(NULL, (char*)sunFbs[i].fbuf, 0, SM_DETACH);
+ smem_remove("FB");
+ sunFbs[i].fbuf = NULL;
+ }
+ if (sunFbs[i].ramdac) {
+ smem_create(NULL, (char*)sunFbs[i].ramdac, 0, SM_DETACH);
+ smem_remove("DAC");
+ sunFbs[i].ramdac = NULL;
+ }
+ if (sunFbs[i].fhc) {
+ smem_create(NULL, (char*)sunFbs[i].fhc, 0, SM_DETACH);
+ smem_remove("FHC_THC");
+ sunFbs[i].fhc = NULL;
+ sunFbs[i].thc = NULL;
+ }
+ if (sunFbs[i].fb) {
+ smem_create(NULL, (char*)sunFbs[i].fb, 0, SM_DETACH);
+ smem_remove("FBC_TEC");
+ sunFbs[i].fb = NULL;
+ sunFbs[i].tec = NULL;
+ }
+ }
+}
+
+static char** GetDeviceList (argc, argv)
+ int argc;
+ char **argv;
+{
+ int i;
+ char *envList = NULL;
+ char *cmdList = NULL;
+ char **deviceList = (char **)NULL;
+
+ for (i = 1; i < argc; i++)
+ if (strcmp (argv[i], "-dev") == 0 && i+1 < argc) {
+ cmdList = argv[i + 1];
+ break;
+ }
+ if (!cmdList)
+ envList = getenv ("XDEVICE");
+
+ if (cmdList || envList) {
+ char *_tmpa;
+ char *_tmpb;
+ int _i1;
+ deviceList = (char **) xalloc ((MAXSCREENS + 1) * sizeof (char *));
+ _tmpa = (cmdList) ? cmdList : envList;
+ for (_i1 = 0; _i1 < MAXSCREENS; _i1++) {
+ _tmpb = strtok (_tmpa, ":");
+ if (_tmpb)
+ deviceList[_i1] = _tmpb;
+ else
+ deviceList[_i1] = NULL;
+ _tmpa = NULL;
+ }
+ deviceList[MAXSCREENS] = NULL;
+ }
+ if (!deviceList) {
+ /* no environment and no cmdline, so default */
+ deviceList =
+ (char **) xalloc ((FALLBACK_LIST_LEN + 1) * sizeof (char *));
+ for (i = 0; i < FALLBACK_LIST_LEN; i++)
+ deviceList[i] = fallbackList[i];
+ deviceList[FALLBACK_LIST_LEN] = NULL;
+ }
+ return deviceList;
+}
+
+static void getKbdType()
+{
+#if defined(PATCHED_CONSOLE)
+ int ii;
+
+ for (ii = 0; ii < 3; ii++) {
+#if 0
+ sunKbdWait();
+#endif
+ if (ioctl (sunKbdPriv.fd, KIOCTYPE, &sunKbdPriv.type) < 0 && errno == EINVAL) {
+ ErrorF("failed to get keyboard type, maybe wrong console driver:");
+ ErrorF(" assuming Type 4 keyboard\n");
+ sunKbdPriv.type = KB_SUN4;
+ return;
+ }
+ switch (sunKbdPriv.type) {
+ case KB_SUN2:
+ case KB_SUN3:
+ case KB_SUN4:
+ return;
+ default:
+ sunChangeKbdTranslation(sunKbdPriv.fd, FALSE);
+ continue;
+ }
+ }
+ FatalError ("Unsupported keyboard type %d\n", sunKbdPriv.type);
+#else
+ sunKbdPriv.type = KB_SUN4;
+#endif
+}
+
+void OsVendorInit(
+ void
+)
+{
+ static int inited;
+ if (!inited) {
+ /* weird hack to prevent logout on X server shutdown */
+ if (onConsole)
+ sunKbdPriv.fd = open ("/dev/con", O_RDWR, 0);
+ else
+ sunKbdPriv.fd = open ("/dev/kbd", O_RDWR, 0);
+ sunPtrPriv.fd = open ("/dev/mouse", O_RDWR, 0);
+
+ getKbdType ();
+ if (sunKbdPriv.type == KB_SUN4) {
+#if defined(PATCHED_CONSOLE)
+ if ( ioctl (sunKbdPriv.fd, KIOCLAYOUT, &sunKbdPriv.layout) < 0 && errno == EINVAL) {
+ ErrorF("failed to get keyboard layout, maybe wrong console driver:");
+ ErrorF(" assuming layout 0\n");
+ sunKbdPriv.layout = 0;
+ }
+ if (sunKbdPriv.layout < 0 ||
+ sunKbdPriv.layout > sunMaxLayout ||
+ sunType4KeyMaps[sunKbdPriv.layout] == NULL)
+ FatalError ("Unsupported keyboard type 4 layout %d\n",
+ sunKbdPriv.layout);
+#else
+ sunKbdPriv.layout = 0; /* default: Type 4 */
+#endif
+ sunKeySyms[KB_SUN4].map = sunType4KeyMaps[sunKbdPriv.layout];
+ sunModMaps[KB_SUN4] = sunType4ModMaps[sunKbdPriv.layout];
+ }
+ inited = 1;
+ }
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * InitOutput --
+ * Initialize screenInfo for all actually accessible framebuffers.
+ * The
+ *
+ * Results:
+ * screenInfo init proc field set
+ *
+ * Side Effects:
+ * None
+ *
+ *-----------------------------------------------------------------------
+ */
+
+void InitOutput(pScreenInfo, argc, argv)
+ ScreenInfo *pScreenInfo;
+ int argc;
+ char **argv;
+{
+ int i, scr;
+ char **devList;
+ static int setup_on_exit = 0;
+ extern Bool RunFromSmartParent;
+
+ if (!monitorResolution)
+ monitorResolution = 90;
+
+ pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+ pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+
+ pScreenInfo->numPixmapFormats = NUMFORMATS;
+ for (i=0; i< NUMFORMATS; i++)
+ pScreenInfo->formats[i] = formats[i];
+#ifdef XKB
+ if (noXkbExtension)
+#endif
+ sunAutoRepeatHandlersInstalled = FALSE;
+ if (!sunDevsInited) {
+ /* first time ever */
+ for (scr = 0; scr < MAXSCREENS; scr++)
+ sunFbs[scr].fd = -1;
+ devList = GetDeviceList (argc, argv);
+ for (i = 0, scr = 0; devList[i] != NULL && scr < MAXSCREENS; i++)
+ if (OpenFrameBuffer (devList[i], scr))
+ scr++;
+ sunDevsInited = TRUE;
+ xfree (devList);
+ }
+ for (scr = 0; scr < MAXSCREENS; scr++)
+ if (sunFbs[scr].fd != -1)
+ (void) AddScreen (sunFbData[sunFbs[scr].info.fb_type].init,
+ argc, argv);
+ (void) OsSignal(SIGWINCH, SIG_IGN);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * InitInput --
+ * Initialize all supported input devices...what else is there
+ * besides pointer and keyboard?
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Two DeviceRec's are allocated and registered as the system pointer
+ * and keyboard devices.
+ *
+ *-----------------------------------------------------------------------
+ */
+void InitInput(argc, argv)
+ int argc;
+ char **argv;
+{
+ DevicePtr p, k;
+ extern Bool mieqInit();
+
+ k = AddInputDevice(sunKbdProc, TRUE);
+ p = AddInputDevice(sunMouseProc, TRUE);
+ if (!p || !k)
+ FatalError("failed to create input devices in InitInput");
+
+ RegisterPointerDevice(p);
+ RegisterKeyboardDevice(k);
+ miRegisterPointerDevice(screenInfo.screens[0], p);
+ (void) mieqInit (k, p);
+
+#define SET_FLOW(fd) fcntl(fd, F_SETFL, FASYNC)
+ (void) OsSignal(SIGIO, SigIOHandler);
+#define WANT_SIGNALS(fd) fcntl(fd, F_SETOWN, getpid())
+ if (sunKbdPriv.fd >= 0) {
+ if (SET_FLOW(sunKbdPriv.fd) == -1 || WANT_SIGNALS(sunKbdPriv.fd) == -1) {
+ (void) close (sunKbdPriv.fd);
+ sunKbdPriv.fd = -1;
+ FatalError("Async kbd I/O failed in InitInput");
+ }
+ }
+ /* SIGIO doesn't work reliable for the mouse device,
+ * esp. for the first server after a reboot. We enable it
+ * anyway, gives smoother movements
+ */
+ if (sunPtrPriv.fd >= 0) {
+ if (SET_FLOW(sunPtrPriv.fd) == -1 || WANT_SIGNALS(sunPtrPriv.fd) == -1) {
+ (void) close (sunPtrPriv.fd);
+ sunPtrPriv.fd = -1;
+ FatalError("ASYNC mouse I/O failed in InitInput");
+ }
+ }
+}
+
+
+#if SUNMAXDEPTH == 8
+
+Bool
+sunCfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp; /* bits per pixel of root */
+{
+ return cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy,
+ width);
+}
+
+Bool
+sunCfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp; /* bits per pixel of root */
+{
+ return cfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy,
+ width);
+}
+
+Bool
+sunCfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp; /* bits per pixel of root */
+{
+ return cfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
+}
+#endif /* SUNMAXDEPTH */
+
+#ifdef DPMSExtension
+/**************************************************************
+ * DPMSSet(), DPMSGet(), DPMSSupported()
+ *
+ * stubs
+ *
+ ***************************************************************/
+
+void DPMSSet (level)
+ int level;
+{
+}
+
+int DPMSGet (level)
+ int* level;
+{
+ return -1;
+}
+
+Bool DPMSSupported ()
+{
+ return FALSE;
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/sunLyIo.c b/nx-X11/programs/Xserver/hw/sunLynx/sunLyIo.c
new file mode 100644
index 000000000..7b1d68519
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/sunLyIo.c
@@ -0,0 +1,389 @@
+/* $Xorg: sunLyIo.c,v 1.3 2000/08/17 19:48:37 cpqbld Exp $ */
+/*-
+ * This is sunIo.c modified for LynxOS
+ * Copyright 1996 by Thomas Mueller
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/sunLyIo.c,v 3.5 2001/05/25 18:40:59 dawes Exp $ */
+
+ /*
+ *
+ * Copyright 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#define NEED_EVENTS
+#include "sun.h"
+#include <stat.h>
+
+/*-
+ *-----------------------------------------------------------------------
+ * ProcessInputEvents --
+ * Retrieve all waiting input events and pass them to DIX in their
+ * correct chronological order. Only reads from the system pointer
+ * and keyboard.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Events are passed to the DIX layer.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+ProcessInputEvents ()
+{
+ mieqProcessInputEvents ();
+ miPointerUpdate ();
+}
+
+/*
+ *-----------------------------------------------------------------------
+ * sunEnqueueEvents
+ * When a SIGIO is received, read device hard events and
+ * enqueue them using the mi event queue
+ */
+
+void sunEnqueueEvents (
+ void
+)
+{
+ Firm_event *ptrEvents, /* Current pointer event */
+ *kbdEvents; /* Current keyboard event */
+ int numPtrEvents, /* Number of remaining pointer events */
+ numKbdEvents; /* Number of remaining keyboard events */
+ int nPE, /* Original number of pointer events */
+ nKE; /* Original number of keyboard events */
+ Bool PtrAgain, /* need to (re)read */
+ KbdAgain; /* need to (re)read */
+ DeviceIntPtr pPointer;
+ DeviceIntPtr pKeyboard;
+ sunKbdPrivPtr kbdPriv;
+ sunPtrPrivPtr ptrPriv;
+
+ pPointer = (DeviceIntPtr)LookupPointerDevice();
+ pKeyboard = (DeviceIntPtr)LookupKeyboardDevice();
+ ptrPriv = (sunPtrPrivPtr) pPointer->public.devicePrivate;
+ kbdPriv = (sunKbdPrivPtr) pKeyboard->public.devicePrivate;
+ if (!pPointer->public.on || !pKeyboard->public.on)
+ return;
+
+ numPtrEvents = 0;
+ PtrAgain = TRUE;
+ numKbdEvents = 0;
+ KbdAgain = TRUE;
+
+ /*
+ * So long as one event from either device remains unprocess, we loop:
+ * Take the oldest remaining event and pass it to the proper module
+ * for processing. The DDXEvent will be sent to ProcessInput by the
+ * function called.
+ */
+ while (1) {
+ /*
+ * Get events from both the pointer and the keyboard, storing the number
+ * of events gotten in nPE and nKE and keeping the start of both arrays
+ * in pE and kE
+ */
+ if ((numPtrEvents == 0) && PtrAgain) {
+ ptrEvents = sunMouseGetEvents (ptrPriv->fd, pPointer->public.on,
+ &nPE, &PtrAgain);
+ numPtrEvents = nPE;
+ }
+ if ((numKbdEvents == 0) && KbdAgain) {
+ kbdEvents = sunKbdGetEvents (kbdPriv->fd, pKeyboard->public.on,
+ &nKE, &KbdAgain);
+ numKbdEvents = nKE;
+ }
+ if ((numPtrEvents == 0) && (numKbdEvents == 0))
+ break;
+ if (numPtrEvents && numKbdEvents) {
+ if (timercmp (&kbdEvents->time, &ptrEvents->time, <)) {
+ sunKbdEnqueueEvent (pKeyboard, kbdEvents);
+ numKbdEvents--;
+ kbdEvents++;
+ } else {
+ sunMouseEnqueueEvent (pPointer, ptrEvents);
+ numPtrEvents--;
+ ptrEvents++;
+ }
+ } else if (numKbdEvents) {
+ sunKbdEnqueueEvent (pKeyboard, kbdEvents);
+ numKbdEvents--;
+ kbdEvents++;
+ } else {
+ sunMouseEnqueueEvent (pPointer, ptrEvents);
+ numPtrEvents--;
+ ptrEvents++;
+ }
+ }
+}
+
+void sunEnqueueKbdEvents (
+ void
+)
+{
+ Firm_event *kbdEvents; /* Current keyboard event */
+ int numKbdEvents; /* Number of remaining keyboard events */
+ int nKE; /* Original number of keyboard events */
+ Bool KbdAgain; /* need to (re)read */
+ DeviceIntPtr pKeyboard;
+ sunKbdPrivPtr kbdPriv;
+
+ pKeyboard = (DeviceIntPtr)LookupKeyboardDevice();
+ kbdPriv = (sunKbdPrivPtr) pKeyboard->public.devicePrivate;
+ if (!pKeyboard->public.on)
+ return;
+
+ numKbdEvents = 0;
+ KbdAgain = TRUE;
+
+ /*
+ * So long as one event from the device remains unprocess, we loop:
+ * Take the oldest remaining event and pass it to the proper module
+ * for processing. The DDXEvent will be sent to ProcessInput by the
+ * function called.
+ */
+ while (1) {
+ /*
+ * Get events from both the keyboard, storing the number
+ * of events gotten in nKE and keeping the start of the array
+ * in kE
+ */
+ if ((numKbdEvents == 0) && KbdAgain) {
+ kbdEvents = sunKbdGetEvents (kbdPriv->fd, pKeyboard->public.on,
+ &nKE, &KbdAgain);
+ numKbdEvents = nKE;
+ }
+ if (numKbdEvents == 0)
+ break;
+ sunKbdEnqueueEvent (pKeyboard, kbdEvents);
+ numKbdEvents--;
+ kbdEvents++;
+ }
+}
+
+void sunEnqueueMseEvents (
+ void
+)
+{
+ Firm_event *ptrEvents; /* Current pointer event */
+ int numPtrEvents; /* Number of remaining pointer events */
+ int nPE; /* Original number of pointer events */
+ Bool PtrAgain; /* need to (re)read */
+ DeviceIntPtr pPointer;
+ sunPtrPrivPtr ptrPriv;
+
+ pPointer = (DeviceIntPtr)LookupPointerDevice();
+ ptrPriv = (sunPtrPrivPtr) pPointer->public.devicePrivate;
+ if (!pPointer->public.on)
+ return;
+
+ numPtrEvents = 0;
+ PtrAgain = TRUE;
+
+ /*
+ * So long as one events from the device remain unprocess, we loop:
+ * Take the oldest remaining event and pass it to the proper module
+ * for processing. The DDXEvent will be sent to ProcessInput by the
+ * function called.
+ */
+ while (1) {
+ /*
+ * Get events from the pointer, storing the number
+ * of events gotten in nPE and keeping the start of the arrays
+ * in pE
+ */
+ if ((numPtrEvents == 0) && PtrAgain) {
+ ptrEvents = sunMouseGetEvents (ptrPriv->fd, pPointer->public.on,
+ &nPE, &PtrAgain);
+ numPtrEvents = nPE;
+ }
+ if (numPtrEvents == 0)
+ break;
+
+ sunMouseEnqueueEvent (pPointer, ptrEvents);
+ numPtrEvents--;
+ ptrEvents++;
+ }
+}
+
+/*
+ * DDX - specific abort routine. Called by AbortServer().
+ */
+void AbortDDX()
+{
+ int i;
+ ScreenPtr pScreen;
+ DevicePtr devPtr;
+
+ (void) OsSignal (SIGIO, SIG_IGN);
+ if (sunKbdPriv.fd != -1) {
+ if (devPtr = LookupKeyboardDevice())
+ (void) sunChangeKbdTranslation (((sunKbdPrivPtr)(devPtr->devicePrivate))->fd, FALSE);
+ }
+ sunNonBlockConsoleOff ();
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ pScreen = screenInfo.screens[i];
+ (*pScreen->SaveScreen) (pScreen, SCREEN_SAVER_OFF);
+ sunDisableCursor (pScreen);
+ }
+}
+
+/* Called by GiveUp(). */
+void
+ddxGiveUp()
+{
+ AbortDDX ();
+}
+
+/* ddxInitGlobals - called by |InitGlobals| from os/util.c */
+void ddxInitGlobals(void)
+{
+}
+
+int
+ddxProcessArgument (argc, argv, i)
+ int argc;
+ char *argv[];
+ int i;
+{
+ extern void UseMsg();
+ extern Bool onConsole;
+ struct stat s0, scon;
+
+ if (fstat(0, &s0) != -1 && stat("/dev/con", &scon) != -1)
+ onConsole = !memcmp(&s0, &scon, sizeof(s0));
+
+#ifndef XKB
+ if (strcmp (argv[i], "-ar1") == 0) { /* -ar1 int */
+ if (++i >= argc) UseMsg ();
+ sunAutoRepeatInitiate = 1000 * (long)atoi(argv[i]);
+ if (sunAutoRepeatInitiate > 1000000)
+ sunAutoRepeatInitiate = 999000;
+ return 2;
+ }
+ if (strcmp (argv[i], "-ar2") == 0) { /* -ar2 int */
+ if (++i >= argc) UseMsg ();
+ sunAutoRepeatDelay = 1000 * (long)atoi(argv[i]);
+ if (sunAutoRepeatDelay > 1000000)
+ sunAutoRepeatDelay = 999000;
+ return 2;
+ }
+#endif
+ if (strcmp (argv[i], "-swapLkeys") == 0) { /* -swapLkeys */
+ sunSwapLkeys = TRUE;
+ return 1;
+ }
+ if (strcmp (argv[i], "-debug") == 0) { /* -debug */
+ return 1;
+ }
+ if (strcmp (argv[i], "-dev") == 0) { /* -dev /dev/mumble */
+ if (++i >= argc) UseMsg ();
+ return 2;
+ }
+ if (strcmp (argv[i], "-mono") == 0) { /* -mono */
+ return 1;
+ }
+ if (strcmp (argv[i], "-zaphod") == 0) { /* -zaphod */
+ sunActiveZaphod = FALSE;
+ return 1;
+ }
+ if (strcmp (argv[i], "-flipPixels") == 0) { /* -flipPixels */
+ sunFlipPixels = TRUE;
+ return 1;
+ }
+ if (strcmp (argv[i], "-fbinfo") == 0) { /* -fbinfo */
+ sunFbInfo = TRUE;
+ return 1;
+ }
+ if (strcmp (argv[i], "-kbd") == 0) { /* -kbd */
+ if (++i >= argc) UseMsg();
+ return 2;
+ }
+ if (strcmp (argv[i], "-protect") == 0) { /* -protect */
+ if (++i >= argc) UseMsg();
+ return 2;
+ }
+ if (strcmp (argv[i], "-noGX") == 0) {
+ sunNoGX = TRUE;
+ return 1;
+ }
+ return 0;
+}
+
+void
+ddxUseMsg()
+{
+#ifndef XKB
+ ErrorF("-ar1 int set autorepeat initiate time\n");
+ ErrorF("-ar2 int set autorepeat interval time\n");
+#endif
+ ErrorF("-swapLkeys swap keysyms on L1..L10\n");
+ ErrorF("-debug disable non-blocking console mode\n");
+ ErrorF("-dev fn[:fn][:fn] name of device[s] to open\n");
+ ErrorF("-mono force monochrome-only screen\n");
+ ErrorF("-zaphod disable active Zaphod mode\n");
+ ErrorF("-fbinfo tell more about the found frame buffer(s)\n");
+#ifdef UNDOCUMENTED
+ ErrorF("-noGX treat the GX as a dumb frame buffer\n");
+#endif
+}
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/sunLyKbd.c b/nx-X11/programs/Xserver/hw/sunLynx/sunLyKbd.c
new file mode 100644
index 000000000..46fe7eb6c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/sunLyKbd.c
@@ -0,0 +1,1080 @@
+/* $Xorg: sunLyKbd.c,v 1.3 2000/08/17 19:48:37 cpqbld Exp $ */
+/*
+ * This is sunKbd.c modified for LynxOS
+ * Copyright 1996 by Thomas Mueller
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/sunLyKbd.c,v 3.6 2001/08/01 00:44:49 tsi Exp $ */
+
+/*-
+ * Copyright 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#define NEED_EVENTS
+#include "sun.h"
+#include "keysym.h"
+#include "Sunkeysym.h"
+#include "osdep.h"
+
+#include <X11/Xpoll.h>
+
+#ifdef XKB
+#include <X11/extensions/XKB.h>
+#include <X11/extensions/XKBstr.h>
+#include <X11/extensions/XKBsrv.h>
+#endif
+
+#define SUN_LED_MASK 0x0f
+#define MIN_KEYCODE 7 /* necessary to avoid the mouse buttons */
+#define MAX_KEYCODE 255 /* limited by the protocol */
+#ifndef KB_SUN4
+#define KB_SUN4 4
+#endif
+
+#define AUTOREPEAT_INITIATE 400
+#define AUTOREPEAT_DELAY 50
+
+#define tvminus(tv, tv1, tv2) /* tv = tv1 - tv2 */ \
+ if ((tv1).tv_usec < (tv2).tv_usec) { \
+ (tv1).tv_usec += 1000000; \
+ (tv1).tv_sec -= 1; \
+ } \
+ (tv).tv_usec = (tv1).tv_usec - (tv2).tv_usec; \
+ (tv).tv_sec = (tv1).tv_sec - (tv2).tv_sec;
+
+#define tvplus(tv, tv1, tv2) /* tv = tv1 + tv2 */ \
+ (tv).tv_sec = (tv1).tv_sec + (tv2).tv_sec; \
+ (tv).tv_usec = (tv1).tv_usec + (tv2).tv_usec; \
+ if ((tv).tv_usec > 1000000) { \
+ (tv).tv_usec -= 1000000; \
+ (tv).tv_sec += 1; \
+ }
+
+extern KeySymsRec sunKeySyms[];
+extern SunModmapRec* sunModMaps[];
+
+long sunAutoRepeatInitiate = 1000 * AUTOREPEAT_INITIATE;
+long sunAutoRepeatDelay = 1000 * AUTOREPEAT_DELAY;
+
+static int autoRepeatKeyDown = 0;
+static int autoRepeatReady;
+static int autoRepeatFirst;
+static struct timeval autoRepeatLastKeyDownTv;
+static struct timeval autoRepeatDeltaTv;
+
+void sunKbdWait()
+{
+ static struct timeval lastChngKbdTransTv;
+ struct timeval tv;
+ struct timeval lastChngKbdDeltaTv;
+ unsigned int lastChngKbdDelta;
+
+ X_GETTIMEOFDAY(&tv);
+ if (!lastChngKbdTransTv.tv_sec)
+ lastChngKbdTransTv = tv;
+ tvminus(lastChngKbdDeltaTv, tv, lastChngKbdTransTv);
+ lastChngKbdDelta = TVTOMILLI(lastChngKbdDeltaTv);
+ if (lastChngKbdDelta < 750) {
+ unsigned wait;
+ /*
+ * We need to guarantee at least 750 milliseconds between
+ * calls to KIOCTRANS. YUCK!
+ */
+ wait = (750L - lastChngKbdDelta) * 1000L;
+ usleep (wait);
+ X_GETTIMEOFDAY(&tv);
+ }
+ lastChngKbdTransTv = tv;
+}
+
+static void SwapLKeys(keysyms)
+ KeySymsRec* keysyms;
+{
+ unsigned int i;
+ KeySym k;
+
+ for (i = 2; i < keysyms->maxKeyCode * keysyms->mapWidth; i++)
+ if (keysyms->map[i] == XK_L1 ||
+ keysyms->map[i] == XK_L2 ||
+ keysyms->map[i] == XK_L3 ||
+ keysyms->map[i] == XK_L4 ||
+ keysyms->map[i] == XK_L5 ||
+ keysyms->map[i] == XK_L6 ||
+ keysyms->map[i] == XK_L7 ||
+ keysyms->map[i] == XK_L8 ||
+ keysyms->map[i] == XK_L9 ||
+ keysyms->map[i] == XK_L10) {
+ /* yes, I could have done a clever two line swap! */
+ k = keysyms->map[i - 2];
+ keysyms->map[i - 2] = keysyms->map[i];
+ keysyms->map[i] = k;
+ }
+}
+
+static void SetLights (ctrl, fd)
+ KeybdCtrl* ctrl;
+ int fd;
+{
+#ifdef KIOCSLED
+ static unsigned char led_tab[16] = {
+ 0,
+ LED_NUM_LOCK,
+ LED_SCROLL_LOCK,
+ LED_SCROLL_LOCK | LED_NUM_LOCK,
+ LED_COMPOSE,
+ LED_COMPOSE | LED_NUM_LOCK,
+ LED_COMPOSE | LED_SCROLL_LOCK,
+ LED_COMPOSE | LED_SCROLL_LOCK | LED_NUM_LOCK,
+ LED_CAPS_LOCK,
+ LED_CAPS_LOCK | LED_NUM_LOCK,
+ LED_CAPS_LOCK | LED_SCROLL_LOCK,
+ LED_CAPS_LOCK | LED_SCROLL_LOCK | LED_NUM_LOCK,
+ LED_CAPS_LOCK | LED_COMPOSE,
+ LED_CAPS_LOCK | LED_COMPOSE | LED_NUM_LOCK,
+ LED_CAPS_LOCK | LED_COMPOSE | LED_SCROLL_LOCK,
+ LED_CAPS_LOCK | LED_COMPOSE | LED_SCROLL_LOCK | LED_NUM_LOCK
+ };
+ if (ioctl (fd, KIOCSLED, (caddr_t)&led_tab[ctrl->leds & 0x0f]) == -1)
+#if defined(PATCHED_CONSOLE)
+ Error("Failed to set keyboard lights");
+#else
+ ; /* silly driver bug always returns error */
+#endif
+#endif
+}
+
+
+static void ModLight (device, on, led)
+ DeviceIntPtr device;
+ Bool on;
+ int led;
+{
+ KeybdCtrl* ctrl = &device->kbdfeed->ctrl;
+ sunKbdPrivPtr pPriv = (sunKbdPrivPtr) device->public.devicePrivate;
+
+ if(on) {
+ ctrl->leds |= led;
+ pPriv->leds |= led;
+ } else {
+ ctrl->leds &= ~led;
+ pPriv->leds &= ~led;
+ }
+ SetLights (ctrl, pPriv->fd);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunBell --
+ * Ring the terminal/keyboard bell
+ *
+ * Results:
+ * Ring the keyboard bell for an amount of time proportional to
+ * "loudness."
+ *
+ * Side Effects:
+ * None, really...
+ *
+ *-----------------------------------------------------------------------
+ */
+
+static void bell (
+ int fd,
+ int duration)
+{
+#if defined(PATCHED_CONSOLE)
+ int kbdCmd; /* Command to give keyboard */
+
+ kbdCmd = KBD_CMD_BELL;
+ if (ioctl (fd, KIOCCMD, &kbdCmd) == -1) {
+ Error("Failed to activate bell");
+ return;
+ }
+ if (duration) usleep (duration);
+ kbdCmd = KBD_CMD_NOBELL;
+ if (ioctl (fd, KIOCCMD, &kbdCmd) == -1)
+ Error ("Failed to deactivate bell");
+#endif
+}
+
+static void sunBell (
+ int percent,
+ DeviceIntPtr device,
+ pointer ctrl,
+ int unused)
+{
+ KeybdCtrl* kctrl = (KeybdCtrl*) ctrl;
+ sunKbdPrivPtr pPriv = (sunKbdPrivPtr) device->public.devicePrivate;
+
+ if (percent == 0 || kctrl->bell == 0)
+ return;
+
+ bell (pPriv->fd, kctrl->bell_duration * 1000);
+}
+
+static void sunEnqueueEvent (xE)
+ xEvent* xE;
+{
+ sigset_t holdmask;
+
+ (void) sigaddset (&holdmask, SIGIO);
+ (void) sigprocmask (SIG_BLOCK, &holdmask, (sigset_t*)NULL);
+ mieqEnqueue (xE);
+ (void) sigprocmask (SIG_UNBLOCK, &holdmask, (sigset_t*)NULL);
+}
+
+
+#define XLED_NUM_LOCK 0x1
+#define XLED_COMPOSE 0x4
+#define XLED_SCROLL_LOCK 0x2
+#define XLED_CAPS_LOCK 0x8
+
+static KeyCode LookupKeyCode (keysym, keysymsrec)
+ KeySym keysym;
+ KeySymsPtr keysymsrec;
+{
+ KeyCode i;
+ int ii, index = 0;
+
+ for (i = keysymsrec->minKeyCode; i < keysymsrec->maxKeyCode; i++)
+ for (ii = 0; ii < keysymsrec->mapWidth; ii++)
+ if (keysymsrec->map[index++] == keysym)
+ return i;
+}
+
+static void pseudoKey(device, down, keycode)
+ DeviceIntPtr device;
+ Bool down;
+ KeyCode keycode;
+{
+ int bit;
+ CARD8 modifiers;
+ CARD16 mask;
+ BYTE* kptr;
+
+ kptr = &device->key->down[keycode >> 3];
+ bit = 1 << (keycode & 7);
+ modifiers = device->key->modifierMap[keycode];
+ if (down) {
+ /* fool dix into thinking this key is now "down" */
+ int i;
+ *kptr |= bit;
+ device->key->prev_state = device->key->state;
+ for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
+ if (mask & modifiers) {
+ device->key->modifierKeyCount[i]++;
+ device->key->state += mask;
+ modifiers &= ~mask;
+ }
+ } else {
+ /* fool dix into thinking this key is now "up" */
+ if (*kptr & bit) {
+ int i;
+ *kptr &= ~bit;
+ device->key->prev_state = device->key->state;
+ for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
+ if (mask & modifiers) {
+ if (--device->key->modifierKeyCount[i] <= 0) {
+ device->key->state &= ~mask;
+ device->key->modifierKeyCount[i] = 0;
+ }
+ modifiers &= ~mask;
+ }
+ }
+ }
+}
+
+static void DoLEDs(device, ctrl, pPriv)
+ DeviceIntPtr device; /* Keyboard to alter */
+ KeybdCtrl* ctrl;
+ sunKbdPrivPtr pPriv;
+{
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ if ((ctrl->leds & XLED_CAPS_LOCK) && !(pPriv->leds & XLED_CAPS_LOCK))
+ pseudoKey(device, TRUE,
+ LookupKeyCode(XK_Caps_Lock, &device->key->curKeySyms));
+
+ if (!(ctrl->leds & XLED_CAPS_LOCK) && (pPriv->leds & XLED_CAPS_LOCK))
+ pseudoKey(device, FALSE,
+ LookupKeyCode(XK_Caps_Lock, &device->key->curKeySyms));
+
+ if ((ctrl->leds & XLED_NUM_LOCK) && !(pPriv->leds & XLED_NUM_LOCK))
+ pseudoKey(device, TRUE,
+ LookupKeyCode(XK_Num_Lock, &device->key->curKeySyms));
+
+ if (!(ctrl->leds & XLED_NUM_LOCK) && (pPriv->leds & XLED_NUM_LOCK))
+ pseudoKey(device, FALSE,
+ LookupKeyCode(XK_Num_Lock, &device->key->curKeySyms));
+
+ if ((ctrl->leds & XLED_SCROLL_LOCK) && !(pPriv->leds & XLED_SCROLL_LOCK))
+ pseudoKey(device, TRUE,
+ LookupKeyCode(XK_Scroll_Lock, &device->key->curKeySyms));
+
+ if (!(ctrl->leds & XLED_SCROLL_LOCK) && (pPriv->leds & XLED_SCROLL_LOCK))
+ pseudoKey(device, FALSE,
+ LookupKeyCode(XK_Scroll_Lock, &device->key->curKeySyms));
+
+ if ((ctrl->leds & XLED_COMPOSE) && !(pPriv->leds & XLED_COMPOSE))
+ pseudoKey(device, TRUE,
+ LookupKeyCode(SunXK_Compose, &device->key->curKeySyms));
+
+ if (!(ctrl->leds & XLED_COMPOSE) && (pPriv->leds & XLED_COMPOSE))
+ pseudoKey(device, FALSE,
+ LookupKeyCode(SunXK_Compose, &device->key->curKeySyms));
+#ifdef XKB
+ }
+#endif
+ pPriv->leds = ctrl->leds & 0x0f;
+ SetLights (ctrl, pPriv->fd);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunKbdCtrl --
+ * Alter some of the keyboard control parameters
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Some...
+ *
+ *-----------------------------------------------------------------------
+ */
+
+static void sunKbdCtrl (
+ DeviceIntPtr device,
+ KeybdCtrl* ctrl)
+{
+ sunKbdPrivPtr pPriv = (sunKbdPrivPtr) device->public.devicePrivate;
+
+ if (pPriv->fd < 0) return;
+
+ if (ctrl->click != pPriv->click) {
+ int kbdClickCmd;
+
+ pPriv->click = ctrl->click;
+#if defined(PATCHED_CONSOLE)
+ kbdClickCmd = pPriv->click ? KBD_CMD_CLICK : KBD_CMD_NOCLICK;
+ if (ioctl (pPriv->fd, KIOCCMD, &kbdClickCmd) == -1)
+ Error("Failed to set keyclick");
+#endif
+ }
+ if (pPriv->type == KB_SUN4 && pPriv->leds != ctrl->leds & 0x0f)
+ DoLEDs(device, ctrl, pPriv);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunInitKbdNames --
+ * Handle the XKB initialization
+ *
+ * Results:
+ * None.
+ *
+ * Comments:
+ * This function needs considerable work, in conjunctions with
+ * the need to add geometry descriptions of Sun Keyboards.
+ * It would also be nice to have #defines for all the keyboard
+ * layouts so that we don't have to have these hard-coded
+ * numbers.
+ *
+ *-----------------------------------------------------------------------
+ */
+#ifdef XKB
+static void sunInitKbdNames (
+ XkbComponentNamesRec* names,
+ sunKbdPrivPtr pKbd)
+{
+#ifndef XKBBUFSIZE
+#define XKBBUFSIZE 64
+#endif
+ static char keycodesbuf[XKBBUFSIZE];
+ static char geometrybuf[XKBBUFSIZE];
+ static char symbolsbuf[XKBBUFSIZE];
+
+ names->keymap = NULL;
+ names->compat = "compat/complete";
+ names->types = "types/complete";
+ names->keycodes = keycodesbuf;
+ names->geometry = geometrybuf;
+ names->symbols = symbolsbuf;
+ (void) strcpy (keycodesbuf, "keycodes/");
+ (void) strcpy (geometrybuf, "geometry/");
+ (void) strcpy (symbolsbuf, "symbols/");
+
+ /* keycodes & geometry */
+ switch (pKbd->type) {
+ case KB_SUN2:
+ (void) strcat (names->keycodes, "sun(type2)");
+ (void) strcat (names->geometry, "sun(type2)");
+ (void) strcat (names->symbols, "us(sun2)");
+ break;
+ case KB_SUN3:
+ (void) strcat (names->keycodes, "sun(type3)");
+ (void) strcat (names->geometry, "sun(type3)");
+ (void) strcat (names->symbols, "us(sun3)");
+ break;
+ case KB_SUN4:
+ if (pKbd->layout == 19) {
+ (void) strcat (names->keycodes, "sun(US101A)");
+ (void) strcat (names->geometry, "pc101-NG"); /* XXX */
+ (void) strcat (names->symbols, "us(pc101)");
+ } else if (pKbd->layout < 33) {
+ (void) strcat (names->keycodes, "sun(type4)");
+ (void) strcat (names->geometry, "sun(type4)");
+ if (sunSwapLkeys)
+ (void) strcat (names->symbols, "sun/us(sun4ol)");
+ else
+ (void) strcat (names->symbols, "sun/us(sun4)");
+ } else {
+ (void) strcat (names->keycodes, "sun(type5)");
+ if (pKbd->layout == 34 || pKbd->layout == 81)
+ (void) strcat (names->geometry, "sun(type5unix)");
+ else
+ (void) strcat (names->geometry, "sun(type5)");
+ if (sunSwapLkeys)
+ (void) strcat (names->symbols, "sun/us(sun5ol)");
+ else
+ (void) strcat (names->symbols, "sun/us(sun5)");
+ }
+ break;
+ default:
+ names->keycodes = names->geometry = NULL;
+ break;
+ }
+
+ /* extra symbols */
+ if (pKbd->type == KB_SUN4) {
+ switch (pKbd->layout) {
+ case 0: case 1: case 33: case 34: case 80: case 81:
+ break;
+ case 3:
+ (void) strcat (names->symbols, "+ca"); break;
+ case 4: case 36: case 83:
+ (void) strcat (names->symbols, "+dk"); break;
+ case 5: case 37: case 84:
+ (void) strcat (names->symbols, "+de"); break;
+ case 6: case 38: case 85:
+ (void) strcat (names->symbols, "+it"); break;
+ case 8: case 40: case 87:
+ (void) strcat (names->symbols, "+no"); break;
+ case 9: case 41: case 88:
+ (void) strcat (names->symbols, "+pt"); break;
+ case 10: case 42: case 89:
+ (void) strcat (names->symbols, "+es"); break;
+ case 11: case 43: case 90:
+ (void) strcat (names->symbols, "+se"); break;
+ case 12: case 44: case 91:
+ (void) strcat (names->symbols, "+fr_CH"); break;
+ case 13: case 45: case 92:
+ (void) strcat (names->symbols, "+de_CH"); break;
+ case 14: case 46: case 93:
+ (void) strcat (names->symbols, "+gb"); break; /* s/b en_UK */
+ case 52:
+ (void) strcat (names->symbols, "+pl"); break;
+ case 53:
+ (void) strcat (names->symbols, "+cs"); break;
+ case 54:
+ (void) strcat (names->symbols, "+ru"); break;
+#if 0
+ /* don't have symbols defined for these yet, let them default */
+ case 2:
+ (void) strcat (names->symbols, "+fr_BE"); break;
+ case 7: case 39: case 86:
+ (void) strcat (names->symbols, "+nl"); break;
+ case 50: case 97:
+ (void) strcat (names->symbols, "+fr_CA"); break;
+ case 16: case 47: case 94:
+ (void) strcat (names->symbols, "+ko"); break;
+ case 17: case 48: case 95:
+ (void) strcat (names->symbols, "+tw"); break;
+ case 32: case 49: case 96:
+ (void) strcat (names->symbols, "+jp"); break;
+ case 51:
+ (void) strcat (names->symbols, "+hu"); break;
+#endif
+ /*
+ * by setting the symbols to NULL XKB will use the symbols in
+ * the "default" keymap.
+ */
+ default:
+ names->symbols = NULL; return; break;
+ }
+ }
+}
+#endif /* XKB */
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunKbdProc --
+ * Handle the initialization, etc. of a keyboard.
+ *
+ * Results:
+ * None.
+ *
+ *-----------------------------------------------------------------------
+ */
+
+int sunKbdProc (
+ DeviceIntPtr device,
+ int what)
+{
+ static int once;
+ static struct termio kbdtty;
+ struct termio tty;
+ int i;
+ DevicePtr pKeyboard = (DevicePtr) device;
+ sunKbdPrivPtr pPriv;
+ KeybdCtrl* ctrl = &device->kbdfeed->ctrl;
+ extern int XkbDfltRepeatDelay, XkbDfltRepeatInterval;
+
+ static CARD8 *workingModMap = NULL;
+ static KeySymsRec *workingKeySyms;
+
+ switch (what) {
+ case DEVICE_INIT:
+ if (pKeyboard != LookupKeyboardDevice()) {
+ ErrorF ("Cannot open non-system keyboard\n");
+ return (!Success);
+ }
+
+ if (!workingKeySyms) {
+ workingKeySyms = &sunKeySyms[sunKbdPriv.type];
+
+ if (sunKbdPriv.type == KB_SUN4 && sunSwapLkeys)
+ SwapLKeys(workingKeySyms);
+
+ if (workingKeySyms->minKeyCode < MIN_KEYCODE) {
+ workingKeySyms->minKeyCode += MIN_KEYCODE;
+ workingKeySyms->maxKeyCode += MIN_KEYCODE;
+ }
+ if (workingKeySyms->maxKeyCode > MAX_KEYCODE)
+ workingKeySyms->maxKeyCode = MAX_KEYCODE;
+ }
+
+ if (!workingModMap) {
+ workingModMap=(CARD8 *)xalloc(MAP_LENGTH);
+ (void) memset(workingModMap, 0, MAP_LENGTH);
+ for(i=0; sunModMaps[sunKbdPriv.type][i].key != 0; i++)
+ workingModMap[sunModMaps[sunKbdPriv.type][i].key + MIN_KEYCODE] =
+ sunModMaps[sunKbdPriv.type][i].modifiers;
+ }
+
+ (void) memset ((void *) defaultKeyboardControl.autoRepeats,
+ ~0, sizeof defaultKeyboardControl.autoRepeats);
+
+#ifdef XKB
+ if (noXkbExtension) {
+ sunAutoRepeatInitiate = XkbDfltRepeatDelay * 1000;
+ sunAutoRepeatDelay = XkbDfltRepeatInterval * 1000;
+#endif
+ autoRepeatKeyDown = 0;
+#ifdef XKB
+ }
+#endif
+ pKeyboard->devicePrivate = (pointer)&sunKbdPriv;
+ pKeyboard->on = FALSE;
+
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ InitKeyboardDeviceStruct(pKeyboard,
+ workingKeySyms, workingModMap,
+ sunBell, sunKbdCtrl);
+#ifdef XKB
+ } else {
+ XkbComponentNamesRec names;
+ sunInitKbdNames (&names, &sunKbdPriv);
+ XkbInitKeyboardDeviceStruct((DeviceIntPtr) pKeyboard, &names,
+ workingKeySyms, workingModMap,
+ sunBell, sunKbdCtrl);
+ }
+#endif
+ break;
+
+ case DEVICE_ON:
+ pPriv = (sunKbdPrivPtr)pKeyboard->devicePrivate;
+ /*
+ * Set the keyboard into "direct" mode and turn on
+ * event translation.
+ */
+ if (sunChangeKbdTranslation(pPriv->fd, TRUE) == -1)
+ FatalError("Can't set keyboard translation\n");
+ /*
+ * for LynxOS, save current termio setting and
+ * set the keyboard into raw mode
+ */
+ if (!once)
+ {
+ ioctl(pPriv->fd, TCGETA, &kbdtty);
+ once = 1;
+ }
+ tty = kbdtty;
+ tty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ tty.c_oflag = 0;
+ tty.c_cflag = CREAD | CS8;
+ tty.c_lflag = 0;
+ tty.c_cc[VTIME] = 0;
+ tty.c_cc[VMIN] = 0;
+ if (ioctl(pPriv->fd, TCSETAW, &tty) < 0)
+ perror("ioctl TCSETAW");
+ AddEnabledDevice(pPriv->fd);
+ pKeyboard->on = TRUE;
+ break;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ pPriv = (sunKbdPrivPtr)pKeyboard->devicePrivate;
+ if (pPriv->type == KB_SUN4) {
+ /* dumb bug in Sun's keyboard! Turn off LEDS before resetting */
+ pPriv->leds = 0;
+ ctrl->leds = 0;
+ SetLights(ctrl, pPriv->fd);
+ }
+ /*
+ * Restore original keyboard directness and translation.
+ */
+ if (sunChangeKbdTranslation(pPriv->fd,FALSE) == -1)
+ FatalError("Can't reset keyboard translation\n");
+ /* restore saved termio setting */
+ if (ioctl(pPriv->fd, TCSETAW, &kbdtty) < 0)
+ perror("ioctl TCSETAW");
+ pKeyboard->on = FALSE;
+ RemoveEnabledDevice(pPriv->fd);
+ break;
+ default:
+ FatalError("Unknown keyboard operation\n");
+ }
+ return Success;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunKbdGetEvents --
+ * Return the events waiting in the wings for the given keyboard.
+ *
+ * Results:
+ * A pointer to an array of Firm_events or (Firm_event *)0 if no events
+ * The number of events contained in the array.
+ * A boolean as to whether more events might be available.
+ *
+ * Side Effects:
+ * None.
+ *-----------------------------------------------------------------------
+ */
+
+Firm_event* sunKbdGetEvents (
+ int fd,
+ Bool on,
+ int* pNumEvents,
+ Bool* pAgain)
+{
+ int nBytes; /* number of bytes of events available. */
+ static Firm_event evBuf[MAXEVENTS]; /* Buffer for Firm_events */
+
+ char buf[64];
+
+ if ((nBytes = read(fd, buf, sizeof(buf))) == -1) {
+ if (errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR)
+ {
+ *pNumEvents = 0;
+ if (errno == EINTR)
+ *pAgain = TRUE;
+ else
+ *pAgain = FALSE;
+ } else {
+ Error ("Reading keyboard");
+ FatalError ("Could not read the keyboard");
+ }
+ } else {
+ int i;
+ struct timeval now;
+
+ if (on) {
+ X_GETTIMEOFDAY(&now);
+ *pNumEvents = nBytes;
+ *pAgain = (nBytes == sizeof(buf)); /* very unlikely... */
+ for (i = 0; i < nBytes; i++)
+ {
+ evBuf[i].id = buf[i] & 0x7f;
+ evBuf[i].value = (buf[i] & 0x80) ? VKEY_UP : VKEY_DOWN;
+ evBuf[i].time = now;
+ }
+ } else {
+ *pNumEvents = 0;
+ *pAgain = FALSE;
+ }
+ }
+ return evBuf;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunKbdEnqueueEvent --
+ *
+ *-----------------------------------------------------------------------
+ */
+static xEvent autoRepeatEvent;
+static int composeCount;
+
+static Bool DoSpecialKeys(device, xE, fe)
+ DeviceIntPtr device;
+ xEvent* xE;
+ Firm_event* fe;
+{
+ int shift_index, map_index, bit;
+ KeySym ksym;
+ BYTE* kptr;
+ sunKbdPrivPtr pPriv = (sunKbdPrivPtr)device->public.devicePrivate;
+ BYTE keycode = xE->u.u.detail;
+ CARD8 keyModifiers = device->key->modifierMap[keycode];
+
+ /* look up the present idea of the keysym */
+ shift_index = 0;
+ if (device->key->state & ShiftMask)
+ shift_index ^= 1;
+ if (device->key->state & LockMask)
+ shift_index ^= 1;
+ map_index = (fe->id - 1) * device->key->curKeySyms.mapWidth;
+ ksym = device->key->curKeySyms.map[shift_index + map_index];
+ if (ksym == NoSymbol)
+ ksym = device->key->curKeySyms.map[map_index];
+
+ /*
+ * Toggle functionality is hardcoded. This is achieved by always
+ * discarding KeyReleases on these keys, and converting every other
+ * KeyPress into a KeyRelease.
+ */
+ if (xE->u.u.type == KeyRelease
+ && (ksym == XK_Num_Lock
+ || ksym == XK_Scroll_Lock
+ || ksym == SunXK_Compose
+ || (keyModifiers & LockMask)))
+ return TRUE;
+
+ kptr = &device->key->down[keycode >> 3];
+ bit = 1 << (keycode & 7);
+ if ((*kptr & bit) &&
+ (ksym == XK_Num_Lock || ksym == XK_Scroll_Lock ||
+ ksym == SunXK_Compose || (keyModifiers & LockMask)))
+ xE->u.u.type = KeyRelease;
+
+ if (pPriv->type == KB_SUN4) {
+ if (ksym == XK_Num_Lock) {
+ ModLight (device, xE->u.u.type == KeyPress, XLED_NUM_LOCK);
+ } else if (ksym == XK_Scroll_Lock) {
+ ModLight (device, xE->u.u.type == KeyPress, XLED_SCROLL_LOCK);
+ } else if (ksym == SunXK_Compose) {
+ ModLight (device, xE->u.u.type == KeyPress, XLED_COMPOSE);
+ if (xE->u.u.type == KeyPress) composeCount = 2;
+ else composeCount = 0;
+ } else if (keyModifiers & LockMask) {
+ ModLight (device, xE->u.u.type == KeyPress, XLED_CAPS_LOCK);
+ }
+ if (xE->u.u.type == KeyRelease) {
+ if (composeCount > 0 && --composeCount == 0) {
+ pseudoKey(device, FALSE,
+ LookupKeyCode(SunXK_Compose, &device->key->curKeySyms));
+ ModLight (device, FALSE, XLED_COMPOSE);
+ }
+ }
+ }
+
+ if ((xE->u.u.type == KeyPress) && (keyModifiers == 0)) {
+ /* initialize new AutoRepeater event & mark AutoRepeater on */
+ autoRepeatEvent = *xE;
+ autoRepeatFirst = TRUE;
+ autoRepeatKeyDown++;
+ autoRepeatLastKeyDownTv = fe->time;
+ }
+ return FALSE;
+}
+
+void sunKbdEnqueueEvent (
+ DeviceIntPtr device,
+ Firm_event *fe)
+{
+ xEvent xE;
+ BYTE keycode;
+ CARD8 keyModifiers;
+
+ keycode = (fe->id & 0x7f) + MIN_KEYCODE;
+
+ keyModifiers = device->key->modifierMap[keycode];
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ if (autoRepeatKeyDown && (keyModifiers == 0) &&
+ ((fe->value == VKEY_DOWN) || (keycode == autoRepeatEvent.u.u.detail))) {
+ /*
+ * Kill AutoRepeater on any real non-modifier key down, or auto key up
+ */
+ autoRepeatKeyDown = 0;
+ }
+#ifdef XKB
+ }
+#endif
+ xE.u.keyButtonPointer.time = TVTOMILLI(fe->time);
+ xE.u.u.type = ((fe->value == VKEY_UP) ? KeyRelease : KeyPress);
+ xE.u.u.detail = keycode;
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ if (DoSpecialKeys(device, &xE, fe))
+ return;
+#ifdef XKB
+ }
+#endif /* ! XKB */
+ mieqEnqueue (&xE);
+}
+
+void sunEnqueueAutoRepeat ()
+{
+ int delta;
+ int i, mask;
+ DeviceIntPtr device = (DeviceIntPtr)LookupKeyboardDevice();
+ KeybdCtrl* ctrl = &device->kbdfeed->ctrl;
+ sunKbdPrivPtr pPriv = (sunKbdPrivPtr) device->public.devicePrivate;
+
+ if (ctrl->autoRepeat != AutoRepeatModeOn) {
+ autoRepeatKeyDown = 0;
+ return;
+ }
+ i=(autoRepeatEvent.u.u.detail >> 3);
+ mask=(1 << (autoRepeatEvent.u.u.detail & 7));
+ if (!(ctrl->autoRepeats[i] & mask)) {
+ autoRepeatKeyDown = 0;
+ return;
+ }
+
+ /*
+ * Generate auto repeat event. XXX one for now.
+ * Update time & pointer location of saved KeyPress event.
+ */
+
+ delta = TVTOMILLI(autoRepeatDeltaTv);
+ autoRepeatFirst = FALSE;
+
+ /*
+ * Fake a key up event and a key down event
+ * for the last key pressed.
+ */
+ autoRepeatEvent.u.keyButtonPointer.time += delta;
+ autoRepeatEvent.u.u.type = KeyRelease;
+
+ /*
+ * hold off any more inputs while we get these safely queued up
+ * further SIGIO are
+ */
+ sunEnqueueEvent (&autoRepeatEvent);
+ autoRepeatEvent.u.u.type = KeyPress;
+ sunEnqueueEvent (&autoRepeatEvent);
+ if (ctrl->click) bell (pPriv->fd, 0);
+
+ /* Update time of last key down */
+ tvplus(autoRepeatLastKeyDownTv, autoRepeatLastKeyDownTv,
+ autoRepeatDeltaTv);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunChangeKbdTranslation
+ * Makes operating system calls to set keyboard translation
+ * and direction on or off.
+ *
+ * Results:
+ * -1 if failure, else 0.
+ *
+ * Side Effects:
+ * Changes kernel management of keyboard.
+ *
+ *-----------------------------------------------------------------------
+ */
+int sunChangeKbdTranslation(
+ int fd,
+ Bool makeTranslated)
+{
+ int tmp;
+ sigset_t hold_mask, old_mask;
+ int toread;
+ char junk[8192];
+
+ (void) sigfillset(&hold_mask);
+ (void) sigprocmask(SIG_BLOCK, &hold_mask, &old_mask);
+ if (makeTranslated) {
+ if (ioctl (fd, TIO_ENSCANMODE, &tmp) == -1) {
+ Error ("Setting keyboard translation TIO_ENSCANMODE");
+ ErrorF ("sunChangeKbdTranslation: kbdFd=%d\n", fd);
+ return -1;
+ }
+ } else {
+ if (ioctl (fd, TIO_DISSCANMODE, &tmp) == -1) {
+ Error ("Setting keyboard translation TIO_DISSCANMODE");
+ ErrorF ("sunChangeKbdTranslation: kbdFd=%d\n", fd);
+ }
+ }
+ if (ioctl (fd, FIONREAD, &toread) != -1 && toread > 0) {
+ while (toread) {
+ tmp = toread;
+ if (toread > sizeof (junk))
+ tmp = sizeof (junk);
+ (void) read (fd, junk, tmp);
+ toread -= tmp;
+ }
+ }
+ (void) sigprocmask(SIG_SETMASK, &old_mask, (sigset_t *)NULL);
+ return 0;
+}
+
+/*ARGSUSED*/
+Bool LegalModifier(key, pDev)
+ unsigned int key;
+ DevicePtr pDev;
+{
+ return TRUE;
+}
+
+/*ARGSUSED*/
+void sunBlockHandler(nscreen, pbdata, pptv, pReadmask)
+ int nscreen;
+ pointer pbdata;
+ struct timeval **pptv;
+ pointer pReadmask;
+{
+ KeybdCtrl* ctrl = &((DeviceIntPtr)LookupKeyboardDevice())->kbdfeed->ctrl;
+ static struct timeval artv = { 0, 0 }; /* autorepeat timeval */
+
+ if (!autoRepeatKeyDown)
+ return;
+
+ if (ctrl->autoRepeat != AutoRepeatModeOn)
+ return;
+
+ if (autoRepeatFirst == TRUE)
+ artv.tv_usec = sunAutoRepeatInitiate;
+ else
+ artv.tv_usec = sunAutoRepeatDelay;
+ *pptv = &artv;
+
+}
+
+/*ARGSUSED*/
+void sunWakeupHandler(nscreen, pbdata, err, pReadmask)
+ int nscreen;
+ pointer pbdata;
+ unsigned long err;
+ pointer pReadmask;
+{
+ KeybdCtrl* ctrl = &((DeviceIntPtr)LookupKeyboardDevice())->kbdfeed->ctrl;
+ struct timeval tv;
+
+ /* this works around a weird behaviour on LynxOS 2.4.0:
+ * usually we have no problems using true SIGIO driven mouse input
+ * as it is used on the other UN*X Suns. On LynxOS we have a
+ * strange behaviour upon the very first server startup after a
+ * reboot. We won't get SIGIOs from the mouse device. The mouse
+ * will only move if we get SIGIOs from the keyboard.
+ * The solution (for now) is to use an additional WakeupHandler and
+ * poll the mouse file descriptor.
+ */
+ struct fd_set devicesWithInput;
+ struct fd_set device;
+ extern struct fd_set EnabledDevices;
+
+ XFD_ANDSET(&devicesWithInput, ((struct fd_set *) pReadmask), &EnabledDevices);
+
+ FD_ZERO(&device);
+ FD_SET(sunPtrPriv.fd, &device);
+ XFD_ANDSET(&device, &device, &devicesWithInput);
+ if (XFD_ANYSET(&device)) {
+ sigset_t newsigmask;
+
+ (void) sigemptyset (&newsigmask);
+ (void) sigaddset (&newsigmask, SIGIO);
+ (void) sigprocmask (SIG_BLOCK, &newsigmask, (sigset_t *)NULL);
+ sunEnqueueMseEvents();
+ (void) sigprocmask (SIG_UNBLOCK, &newsigmask, (sigset_t *)NULL);
+ }
+
+#ifdef XKB
+ if (!noXkbExtension)
+ return;
+#endif
+
+ if (ctrl->autoRepeat != AutoRepeatModeOn)
+ return;
+
+ if (autoRepeatKeyDown) {
+ X_GETTIMEOFDAY(&tv);
+ tvminus(autoRepeatDeltaTv, tv, autoRepeatLastKeyDownTv);
+ if (autoRepeatDeltaTv.tv_sec > 0 ||
+ (!autoRepeatFirst && autoRepeatDeltaTv.tv_usec >
+ sunAutoRepeatDelay) ||
+ (autoRepeatDeltaTv.tv_usec >
+ sunAutoRepeatInitiate))
+ autoRepeatReady++;
+ }
+
+ if (autoRepeatReady)
+ {
+ sunEnqueueAutoRepeat ();
+ autoRepeatReady = 0;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/sunLyMouse.c b/nx-X11/programs/Xserver/hw/sunLynx/sunLyMouse.c
new file mode 100644
index 000000000..00df3db7c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/sunLyMouse.c
@@ -0,0 +1,649 @@
+/* $Xorg: sunLyMouse.c,v 1.3 2000/08/17 19:48:37 cpqbld Exp $ */
+/*
+ * This is sunMouse.c modified for LynxOS
+ * Copyright 1996 by Thomas Mueller
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/sunLyMouse.c,v 3.3 2001/01/17 22:36:53 dawes Exp $ */
+
+/*-
+ * Copyright 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/*
+ * Copyright 1991, 1992, 1993 Kaleb S. Keithley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. Kaleb S. Keithley makes no
+ * representations about the suitability of this software for
+ * any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#define NEED_EVENTS
+#include "sun.h"
+
+Bool sunActiveZaphod = TRUE;
+
+static Bool sunCursorOffScreen();
+static void sunCrossScreen();
+static void sunWarpCursor();
+
+miPointerScreenFuncRec sunPointerScreenFuncs = {
+ sunCursorOffScreen,
+ sunCrossScreen,
+ sunWarpCursor,
+};
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunMouseCtrl --
+ * Alter the control parameters for the mouse. Since acceleration
+ * etc. is done from the PtrCtrl record in the mouse's device record,
+ * there's nothing to do here.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------
+ */
+/*ARGSUSED*/
+static
+void sunMouseCtrl (
+ DeviceIntPtr device,
+ PtrCtrl* ctrl)
+{
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunMouseProc --
+ * Handle the initialization, etc. of a mouse
+ *
+ * Results:
+ * none.
+ *
+ * Side Effects:
+ *
+ * Note:
+ * When using sunwindows, all input comes off a single fd, stored in the
+ * global windowFd. Therefore, only one device should be enabled and
+ * disabled, even though the application still sees both mouse and
+ * keyboard. We have arbitrarily chosen to enable and disable windowFd
+ * in the keyboard routine sunKbdProc rather than in sunMouseProc.
+ *
+ *-----------------------------------------------------------------------
+ */
+int sunMouseProc (
+ DeviceIntPtr device,
+ int what)
+{
+ struct termio tty;
+ DevicePtr pMouse = (DevicePtr) device;
+ int format;
+ static int oformat;
+ BYTE map[4];
+ char *dev;
+
+ switch (what) {
+ case DEVICE_INIT:
+ if (pMouse != LookupPointerDevice()) {
+ ErrorF ("Cannot open non-system mouse");
+ return !Success;
+ }
+ if (sunPtrPriv.fd == -1)
+ return !Success;
+ pMouse->devicePrivate = (pointer) &sunPtrPriv;
+ pMouse->on = FALSE;
+ map[1] = 1;
+ map[2] = 2;
+ map[3] = 3;
+ InitPointerDeviceStruct(
+ pMouse, map, 3, miPointerGetMotionEvents,
+ sunMouseCtrl, miPointerGetMotionBufferSize());
+ break;
+
+ case DEVICE_ON:
+ /* set mouse to raw mode */
+ if (ioctl(sunPtrPriv.fd, TCGETA, &tty) != -1) {
+ tty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ tty.c_oflag = 0;
+ tty.c_cflag = CREAD | CS8;
+ tty.c_lflag = 0;
+ tty.c_line = 0;
+ tty.c_cc[VTIME] = 0;
+ tty.c_cc[VMIN] = 0;
+ if (ioctl(sunPtrPriv.fd, TCSETAW, &tty) < 0)
+ perror("ioctl TCSETAW");
+ } else
+ perror("ioctl TCGETA");
+ sunPtrPriv.bmask = 0;
+ AddEnabledDevice (sunPtrPriv.fd);
+ pMouse->on = TRUE;
+ break;
+
+ case DEVICE_CLOSE:
+ pMouse->on = FALSE;
+ break;
+
+ case DEVICE_OFF:
+ pMouse->on = FALSE;
+ RemoveEnabledDevice (sunPtrPriv.fd);
+ break;
+ }
+ return Success;
+}
+
+/* mouse protocol code from XFree86 */
+
+#define P_MS 0 /* Microsoft */
+#define P_MSC 1 /* Mouse Systems Corp */
+#define P_MM 2 /* MMseries */
+#define P_LOGI 3 /* Logitech */
+#define P_BM 4 /* BusMouse ??? */
+#define P_LOGIMAN 5 /* MouseMan / TrackMan
+ [CHRIS-211092] */
+#define P_PS2 6 /* PS/2 mouse */
+#define P_MMHIT 7 /* MM_HitTab */
+
+static int
+xf86MouseProtocol(rBuf, nBytes, evBuf)
+ unsigned char *rBuf;
+ int nBytes;
+ Firm_event evBuf[];
+{
+ int i, buttons, dx, dy;
+ static int pBufP = 0;
+ static unsigned char pBuf[8];
+ static int lastButtons;
+ int change;
+ int numEvents = 0;
+
+ const int mseType = P_MSC;
+ const int chordMiddle = 0;
+
+ static unsigned char proto[8][5] = {
+ /* hd_mask hd_id dp_mask dp_id nobytes */
+ { 0x40, 0x40, 0x40, 0x00, 3 }, /* MicroSoft */
+ { 0xf8, 0x80, 0x00, 0x00, 5 }, /* MouseSystems */
+ { 0xe0, 0x80, 0x80, 0x00, 3 }, /* MMSeries */
+ { 0xe0, 0x80, 0x80, 0x00, 3 }, /* Logitech */
+ { 0xf8, 0x80, 0x00, 0x00, 5 }, /* BusMouse */
+ { 0x40, 0x40, 0x40, 0x00, 3 }, /* MouseMan
+ [CHRIS-211092] */
+ { 0xc0, 0x00, 0x00, 0x00, 3 }, /* PS/2 mouse */
+ { 0xe0, 0x80, 0x80, 0x00, 3 }, /* MM_HitTablet */
+ };
+
+ for ( i=0; i < nBytes; i++) {
+ /*
+ * Hack for resyncing: We check here for a package that is:
+ * a) illegal (detected by wrong data-package header)
+ * b) invalid (0x80 == -128 and that might be wrong for MouseSystems)
+ * c) bad header-package
+ *
+ * NOTE: b) is a voilation of the MouseSystems-Protocol, since values of
+ * -128 are allowed, but since they are very seldom we can easily
+ * use them as package-header with no button pressed.
+ * NOTE/2: On a PS/2 mouse any byte is valid as a data byte. Furthermore,
+ * 0x80 is not valid as a header byte. For a PS/2 mouse we skip
+ * checking data bytes.
+ * For resyncing a PS/2 mouse we require the two most significant
+ * bits in the header byte to be 0. These are the overflow bits,
+ * and in case of an overflow we actually lose sync. Overflows
+ * are very rare, however, and we quickly gain sync again after
+ * an overflow condition. This is the best we can do. (Actually,
+ * we could use bit 0x08 in the header byte for resyncing, since
+ * that bit is supposed to be always on, but nobody told
+ * Microsoft...)
+ */
+ if (pBufP != 0 && mseType != P_PS2 &&
+ ((rBuf[i] & proto[mseType][2]) != proto[mseType][3]
+ || rBuf[i] == 0x80))
+ {
+ pBufP = 0; /* skip package */
+ }
+
+ if (pBufP == 0 &&
+ (rBuf[i] & proto[mseType][0]) != proto[mseType][1])
+ {
+ /*
+ * Hack for Logitech MouseMan Mouse - Middle button
+ *
+ * Unfortunately this mouse has variable length packets: the standard
+ * Microsoft 3 byte packet plus an optional 4th byte whenever the
+ * middle button status changes.
+ *
+ * We have already processed the standard packet with the movement
+ * and button info. Now post an event message with the old status
+ * of the left and right buttons and the updated middle button.
+ */
+
+ /*
+ * Even worse, different MouseMen and TrackMen differ in the 4th
+ * byte: some will send 0x00/0x20, others 0x01/0x21, or even
+ * 0x02/0x22, so I have to strip off the lower bits. [CHRIS-211092]
+ */
+ if ((mseType == P_MS || mseType == P_LOGIMAN)
+ && (char)(rBuf[i] & ~0x23) == 0)
+ {
+ buttons = ((int)(rBuf[i] & 0x20) >> 4)
+ | (lastButtons & 0x05);
+
+ change = buttons ^ lastButtons;
+ /* a little naive, but sufficient for now */
+ if (change & 4)
+ {
+ evBuf[numEvents].id = MS_LEFT;
+ evBuf[numEvents].value = (buttons & 4) ? VKEY_DOWN : VKEY_UP;
+ ++numEvents;
+ }
+ if (change & 2)
+ {
+ evBuf[numEvents].id = MS_MIDDLE;
+ evBuf[numEvents].value = (buttons & 2) ? VKEY_DOWN : VKEY_UP;
+ ++numEvents;
+ }
+ if (change & 1)
+ {
+ evBuf[numEvents].id = MS_RIGHT;
+ evBuf[numEvents].value = (buttons & 1) ? VKEY_DOWN : VKEY_UP;
+ ++numEvents;
+ }
+ lastButtons = buttons;
+ }
+
+ continue; /* skip package */
+ }
+
+
+ pBuf[pBufP++] = rBuf[i];
+ if (pBufP != proto[mseType][4]) continue;
+
+
+ /*
+ * assembly full package
+ */
+ switch(mseType) {
+
+ case P_LOGIMAN: /* MouseMan / TrackMan [CHRIS-211092] */
+ case P_MS: /* Microsoft */
+ if (chordMiddle)
+ buttons = (((int) pBuf[0] & 0x30) == 0x30) ? 2 :
+ ((int)(pBuf[0] & 0x20) >> 3)
+ | ((int)(pBuf[0] & 0x10) >> 4);
+ else {
+ buttons = (lastButtons & 2)
+ | ((int)(pBuf[0] & 0x20) >> 3)
+ | ((int)(pBuf[0] & 0x10) >> 4);
+ }
+ dx = (char)((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F);
+ dy = (char)((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F);
+ break;
+
+ case P_MSC: /* Mouse Systems Corp */
+ buttons = (~pBuf[0]) & 0x07;
+ dx = (char)(pBuf[1]) + (char)(pBuf[3]);
+ dy = - ((char)(pBuf[2]) + (char)(pBuf[4]));
+ break;
+
+
+ case P_MMHIT: /* MM_HitTablet */
+ buttons = pBuf[0] & 0x07;
+ if (buttons != 0)
+ buttons = 1 << (buttons - 1);
+ dx = (pBuf[0] & 0x10) ? pBuf[1] : - pBuf[1];
+ dy = (pBuf[0] & 0x08) ? - pBuf[2] : pBuf[2];
+ break;
+
+ case P_MM: /* MM Series */
+ case P_LOGI: /* Logitech Mice */
+ buttons = pBuf[0] & 0x07;
+ dx = (pBuf[0] & 0x10) ? pBuf[1] : - pBuf[1];
+ dy = (pBuf[0] & 0x08) ? - pBuf[2] : pBuf[2];
+ break;
+
+ case P_BM: /* BusMouse */
+ buttons = (~pBuf[0]) & 0x07;
+ dx = pBuf[1];
+ dy = - pBuf[2];
+ break;
+
+ case P_PS2: /* PS/2 mouse */
+ buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */
+ (pBuf[0] & 0x02) >> 1 | /* Right */
+ (pBuf[0] & 0x01) << 2; /* Left */
+ dx = (pBuf[0] & 0x10) ? pBuf[1]-256 : pBuf[1];
+ dy = (pBuf[0] & 0x20) ? -(pBuf[2]-256) : -pBuf[2];
+ break;
+ }
+
+ /* a little naive, but sufficient for now */
+ change = buttons ^ lastButtons;
+ if (change & 4)
+ {
+ evBuf[numEvents].id = MS_LEFT;
+ evBuf[numEvents].value = (buttons & 4) ? VKEY_DOWN : VKEY_UP;
+ ++numEvents;
+ }
+ if (change & 2)
+ {
+ evBuf[numEvents].id = MS_MIDDLE;
+ evBuf[numEvents].value = (buttons & 2) ? VKEY_DOWN : VKEY_UP;
+ ++numEvents;
+ }
+ if (change & 1)
+ {
+ evBuf[numEvents].id = MS_RIGHT;
+ evBuf[numEvents].value = (buttons & 1) ? VKEY_DOWN : VKEY_UP;
+ ++numEvents;
+ }
+ lastButtons = buttons;
+
+ if (dx)
+ {
+ evBuf[numEvents].id = LOC_X_DELTA;
+ evBuf[numEvents].value = dx;
+ ++numEvents;
+ }
+ if (dy)
+ {
+ evBuf[numEvents].id = LOC_Y_DELTA;
+ evBuf[numEvents].value = -dy;
+ ++numEvents;
+ }
+ pBufP = 0;
+ }
+ return numEvents;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunMouseGetEvents --
+ * Return the events waiting in the wings for the given mouse.
+ *
+ * Results:
+ * A pointer to an array of Firm_events or (Firm_event *)0 if no events
+ * The number of events contained in the array.
+ * A boolean as to whether more events might be available.
+ *
+ * Side Effects:
+ * None.
+ *-----------------------------------------------------------------------
+ */
+
+Firm_event* sunMouseGetEvents (
+ int fd,
+ Bool on,
+ int* pNumEvents,
+ Bool* pAgain)
+{
+ static Firm_event evBuf[MAXEVENTS]; /* Buffer for Firm_events */
+ int nBytes; /* number of bytes available. */
+ char buf[8];
+
+ if ((nBytes = read(fd, buf, sizeof(buf))) == -1) {
+ if (errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR) {
+ *pNumEvents = 0;
+ if (errno == EINTR)
+ *pAgain = TRUE;
+ else
+ *pAgain = FALSE;
+ } else {
+ Error ("sunMouseGetEvents read");
+ FatalError ("Could not read from mouse");
+ }
+ } else {
+ if (on) {
+ *pAgain = (nBytes == sizeof(buf)); /* very unlikely... */
+ if (*pNumEvents = xf86MouseProtocol(buf, nBytes, evBuf))
+ {
+ struct timeval now;
+ int i;
+
+ X_GETTIMEOFDAY(&now);
+ for (i=0;i<*pNumEvents;i++)
+ evBuf[i].time = now;
+ }
+ } else {
+ *pNumEvents = 0;
+ *pAgain = FALSE;
+ }
+ }
+ return evBuf;
+}
+
+
+/*-
+ *-----------------------------------------------------------------------
+ * MouseAccelerate --
+ * Given a delta and a mouse, return the acceleration of the delta.
+ *
+ * Results:
+ * The corrected delta
+ *
+ * Side Effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------
+ */
+static short
+MouseAccelerate (device, delta)
+ DeviceIntPtr device;
+ int delta;
+{
+ int sgn = sign(delta);
+ PtrCtrl *pCtrl;
+ short ret;
+
+ delta = abs(delta);
+ pCtrl = &device->ptrfeed->ctrl;
+ if (delta > pCtrl->threshold) {
+ ret =
+ (short) sgn *
+ (pCtrl->threshold + ((delta - pCtrl->threshold) * pCtrl->num) /
+ pCtrl->den);
+ } else {
+ ret = (short) sgn * delta;
+ }
+ return ret;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunMouseEnqueueEvent --
+ * Given a Firm_event for a mouse, pass it off the the dix layer
+ * properly converted...
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * The cursor may be redrawn...? devPrivate/x/y will be altered.
+ *
+ *-----------------------------------------------------------------------
+ */
+
+void sunMouseEnqueueEvent (
+ DeviceIntPtr device,
+ Firm_event *fe)
+{
+ xEvent xE;
+ sunPtrPrivPtr pPriv; /* Private data for pointer */
+ int bmask; /* Temporary button mask */
+ unsigned long time;
+ int x, y;
+
+ pPriv = (sunPtrPrivPtr)device->public.devicePrivate;
+
+ time = xE.u.keyButtonPointer.time = TVTOMILLI(fe->time);
+
+ switch (fe->id) {
+ case MS_LEFT:
+ case MS_MIDDLE:
+ case MS_RIGHT:
+ /*
+ * A button changed state. Sometimes we will get two events
+ * for a single state change. Should we get a button event which
+ * reflects the current state of affairs, that event is discarded.
+ *
+ * Mouse buttons start at 1.
+ */
+ xE.u.u.detail = (fe->id - MS_LEFT) + 1;
+ bmask = 1 << xE.u.u.detail;
+ if (fe->value == VKEY_UP) {
+ if (pPriv->bmask & bmask) {
+ xE.u.u.type = ButtonRelease;
+ pPriv->bmask &= ~bmask;
+ } else {
+ return;
+ }
+ } else {
+ if ((pPriv->bmask & bmask) == 0) {
+ xE.u.u.type = ButtonPress;
+ pPriv->bmask |= bmask;
+ } else {
+ return;
+ }
+ }
+ mieqEnqueue (&xE);
+ break;
+ case LOC_X_DELTA:
+ miPointerDeltaCursor (MouseAccelerate(device,fe->value),0,time);
+ break;
+ case LOC_Y_DELTA:
+ /*
+ * For some reason, motion up generates a positive y delta
+ * and motion down a negative delta, so we must subtract
+ * here instead of add...
+ */
+ miPointerDeltaCursor (0,-MouseAccelerate(device,fe->value),time);
+ break;
+ case LOC_X_ABSOLUTE:
+ miPointerPosition (&x, &y);
+ miPointerAbsoluteCursor (fe->value, y, time);
+ break;
+ case LOC_Y_ABSOLUTE:
+ miPointerPosition (&x, &y);
+ miPointerAbsoluteCursor (x, fe->value, time);
+ break;
+ default:
+ FatalError ("sunMouseEnqueueEvent: unrecognized id\n");
+ break;
+ }
+}
+
+/*ARGSUSED*/
+static Bool
+sunCursorOffScreen (pScreen, x, y)
+ ScreenPtr *pScreen;
+ int *x, *y;
+{
+ int index, ret = FALSE;
+ extern Bool PointerConfinedToScreen();
+
+ if (PointerConfinedToScreen()) return TRUE;
+ /*
+ * Active Zaphod implementation:
+ * increment or decrement the current screen
+ * if the x is to the right or the left of
+ * the current screen.
+ */
+ if (sunActiveZaphod &&
+ screenInfo.numScreens > 1 && (*x >= (*pScreen)->width || *x < 0)) {
+ index = (*pScreen)->myNum;
+ if (*x < 0) {
+ index = (index ? index : screenInfo.numScreens) - 1;
+ *pScreen = screenInfo.screens[index];
+ *x += (*pScreen)->width;
+ } else {
+ *x -= (*pScreen)->width;
+ index = (index + 1) % screenInfo.numScreens;
+ *pScreen = screenInfo.screens[index];
+ }
+ ret = TRUE;
+ }
+ return ret;
+}
+
+static void
+sunCrossScreen (pScreen, entering)
+ ScreenPtr pScreen;
+ Bool entering;
+{
+ if (sunFbs[pScreen->myNum].EnterLeave)
+ (*sunFbs[pScreen->myNum].EnterLeave) (pScreen, entering ? 0 : 1);
+}
+
+static void
+sunWarpCursor (pScreen, x, y)
+ ScreenPtr pScreen;
+ int x, y;
+{
+ sigset_t newsigmask;
+
+ (void) sigemptyset (&newsigmask);
+ (void) sigaddset (&newsigmask, SIGIO);
+ (void) sigprocmask (SIG_BLOCK, &newsigmask, (sigset_t *)NULL);
+ miPointerWarpCursor (pScreen, x, y);
+ (void) sigprocmask (SIG_UNBLOCK, &newsigmask, (sigset_t *)NULL);
+}
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/sunLyUtil.c b/nx-X11/programs/Xserver/hw/sunLynx/sunLyUtil.c
new file mode 100644
index 000000000..e260acfee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/sunLyUtil.c
@@ -0,0 +1,509 @@
+/* $Xorg: sunLyUtil.c,v 1.3 2000/08/17 19:48:37 cpqbld Exp $ */
+/*
+ * CG3 and CG6 utility functions for LynxOS, derived from NetBSD
+ * Copyright 1996 by Thomas Mueller
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/sunLyUtil.c,v 3.1 1996/12/27 06:51:42 dawes Exp $ */
+
+/* $NetBSD: bt_subr.c,v 1.4 1994/11/20 20:51:54 deraadt Exp $ */
+
+/*
+ * Copyright (c) 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)bt_subr.c 8.2 (Berkeley) 1/21/94
+ */
+
+/* adaption for LynxOS microSPARC 2.4.0 and X11R6[.1]
+ * Copyright 1996 by Thomas Mueller <tm@systrix.de>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#include "sun.h"
+#include "btreg.h"
+#include "btvar.h"
+#include "cgsixreg.h"
+#define useracc(a,b,c) (1)
+
+/*
+ * Common code for dealing with Brooktree video DACs.
+ * (Contains some software-only code as well, since the colormap
+ * ioctls are shared between the cgthree and cgsix drivers.)
+ */
+
+/*
+ * Implement an FBIOGETCMAP-like ioctl.
+ */
+int
+bt_getcmap(struct fbcmap *p, union bt_cmap *cm, int cmsize)
+{
+ u_int i;
+ u_int start;
+ u_int count;
+ u_char *cp;
+
+ start = p->index;
+ count = p->count;
+ if (start >= cmsize || start + count > cmsize)
+ return (EINVAL);
+ if (!useracc(p->red, count, B_WRITE) ||
+ !useracc(p->green, count, B_WRITE) ||
+ !useracc(p->blue, count, B_WRITE))
+ return (EFAULT);
+ for (cp = &cm->cm_map[start][0], i = 0; i < count; cp += 3, i++) {
+ p->red[i] = cp[0];
+ p->green[i] = cp[1];
+ p->blue[i] = cp[2];
+ }
+ return (0);
+}
+
+/*
+ * Implement the software portion of an FBIOPUTCMAP-like ioctl.
+ */
+int
+bt_putcmap(struct fbcmap *p, union bt_cmap *cm, int cmsize)
+{
+ u_int i;
+ int start;
+ int count;
+ u_char *cp;
+
+ start = p->index;
+ count = p->count;
+ if (start >= cmsize || start + count > cmsize)
+ return (EINVAL);
+ if (!useracc(p->red, count, B_READ) ||
+ !useracc(p->green, count, B_READ) ||
+ !useracc(p->blue, count, B_READ))
+ return (EFAULT);
+ for (cp = &cm->cm_map[start][0], i = 0; i < count; cp += 3, i++) {
+ cp[0] = p->red[i];
+ cp[1] = p->green[i];
+ cp[2] = p->blue[i];
+ }
+ return (0);
+}
+
+union cursor_cmap { /* colormap, like bt_cmap, but tiny */
+ u_char cm_map[2][3]; /* 2 R/G/B entries */
+ u_int cm_chip[2]; /* 2 chip equivalents */
+};
+
+struct cg6_cursor { /* cg6 hardware cursor status */
+ short cc_enable; /* cursor is enabled */
+ struct fbcurpos cc_pos; /* position */
+ struct fbcurpos cc_hot; /* hot-spot */
+ struct fbcurpos cc_size; /* size of mask & image fields */
+ u_int cc_bits[2][32]; /* space for mask & image bits */
+ union cursor_cmap cc_color; /* cursor colormap */
+};
+
+static union bt_cmap sc_cmap; /* local copy of LUT */
+static int blanked = 1; /* to jump-start it ... */
+static struct cg6_cursor sc_cursor; /* cursor info */
+
+/*
+ * Clean up hardware state (e.g., after bootup or after X crashes).
+ */
+static void
+cg6_reset(fbFd * fb)
+{
+ volatile struct cg6_tec_xxx *tec;
+ int fhc;
+ short fhcrev;
+ volatile struct bt_regs *bt;
+
+ /* hide the cursor, just in case */
+ ((volatile struct cg6_thc *) (fb->thc))->thc_cursxy =
+ (THC_CURSOFF << 16) | THC_CURSOFF;
+
+ /* turn off frobs in transform engine (makes X11 work) */
+ tec = fb->tec;
+ tec->tec_mv = 0;
+ tec->tec_clip = 0;
+ tec->tec_vdc = 0;
+
+ /* take care of hardware bugs in old revisions */
+ fhcrev = (*(int *) fb->fhc >> FHC_REV_SHIFT) &
+ (FHC_REV_MASK >> FHC_REV_SHIFT);
+ if (fhcrev < 5) {
+ /*
+ * Keep current resolution; set cpu to 68020, set test
+ * window (size 1Kx1K), and for rev 1, disable dest cache.
+ */
+ fhc = (*(int *) fb->fhc & FHC_RES_MASK) | FHC_CPU_68020 |
+ FHC_TEST |
+ (11 << FHC_TESTX_SHIFT) | (11 << FHC_TESTY_SHIFT);
+ if (fhcrev < 2)
+ fhc |= FHC_DST_DISABLE;
+ *(int *) fb->fhc = fhc;
+ }
+ /* Enable cursor in Brooktree DAC. */
+ bt = fb->ramdac;
+ bt->bt_addr = 0x06 << 24;
+ bt->bt_ctrl |= 0x03 << 24;
+}
+
+static void
+cg6_loadcursor(fbFd * fb)
+{
+ volatile struct cg6_thc *thc;
+ u_int edgemask;
+ u_int m;
+ int i;
+
+ /*
+ * Keep the top size.x bits. Here we *throw out* the top
+ * size.x bits from an all-one-bits word, introducing zeros in
+ * the top size.x bits, then invert all the bits to get what
+ * we really wanted as our mask. But this fails if size.x is
+ * 32---a sparc uses only the low 5 bits of the shift count---
+ * so we have to special case that.
+ */
+ edgemask = ~0;
+ if (sc_cursor.cc_size.x < 32)
+ edgemask = ~(edgemask >> sc_cursor.cc_size.x);
+ thc = (volatile struct cg6_thc *) fb->thc;
+ for (i = 0; i < 32; i++) {
+ m = sc_cursor.cc_bits[0][i] & edgemask;
+ thc->thc_cursmask[i] = m;
+ thc->thc_cursbits[i] = m & sc_cursor.cc_bits[1][i];
+ }
+}
+
+static void
+cg6_setcursor(fbFd * fb)
+{
+ /* we need to subtract the hot-spot value here */
+#define COORD(f) (sc_cursor.cc_pos.f - sc_cursor.cc_hot.f)
+ ((volatile struct cg6_thc *) (fb->thc))->thc_cursxy = sc_cursor.cc_enable ?
+ ((COORD(x) << 16) | (COORD(y) & 0xffff)) :
+ (THC_CURSOFF << 16) | THC_CURSOFF;
+#undef COORD
+}
+
+/*
+ * Load the cursor (overlay `foreground' and `background') colors.
+ */
+static void
+cg6_loadomap(fbFd * fb)
+{
+ volatile struct bt_regs *bt;
+ u_int i;
+
+ bt = (volatile struct bt_regs *) fb->ramdac;
+ bt->bt_addr = 0x01 << 24; /* set background color */
+ i = sc_cursor.cc_color.cm_chip[0];
+ bt->bt_omap = i; /* R */
+ bt->bt_omap = i << 8; /* G */
+ bt->bt_omap = i << 16; /* B */
+
+ bt->bt_addr = 0x03 << 24; /* set foreground color */
+ bt->bt_omap = i << 24; /* R */
+ i = sc_cursor.cc_color.cm_chip[1];
+ bt->bt_omap = i; /* G */
+ bt->bt_omap = i << 8; /* B */
+}
+
+/*
+ * Load a subset of the current (new) colormap into the color DAC.
+ */
+static void
+cg6_loadcmap(fbFd * fb, union bt_cmap *cm, int start, int ncolors)
+{
+ volatile struct bt_regs *bt;
+ u_int *ip;
+ u_int i;
+ int count;
+
+ ip = &cm->cm_chip[BT_D4M3(start)]; /* start/4 * 3 */
+ count = BT_D4M3(start + ncolors - 1) - BT_D4M3(start) + 3;
+ bt = (struct bt_regs *) fb->ramdac;
+ bt->bt_addr = BT_D4M4(start) << 24;
+ while (--count >= 0) {
+ i = *ip++;
+ /* hardware that makes one want to pound boards with hammers */
+ bt->bt_cmap = i;
+ bt->bt_cmap = i << 8;
+ bt->bt_cmap = i << 16;
+ bt->bt_cmap = i << 24;
+ }
+}
+
+/*
+ * Undo the effect of an FBIOSVIDEO that turns the video off on a CG6
+ */
+static void
+cg6_unblank(fbFd * dev)
+{
+ volatile struct cg6_thc *thc = (volatile struct cg6_thc *) dev->thc;
+ unsigned long x;
+ unsigned long y;
+
+ if (blanked) {
+ thc->thc_misc = (thc->thc_misc & ~THC_MISC_VIDEN) | THC_MISC_VIDEN;
+ }
+ blanked = 0;
+}
+
+/*
+ * Load a subset of the current (new) colormap into the Brooktree DAC.
+ */
+static void
+cg3_loadcmap(fbFd * fb, union bt_cmap *cm, int start, int ncolors)
+{
+ volatile struct bt_regs *bt;
+ u_int *ip;
+ int count;
+
+ ip = &cm->cm_chip[BT_D4M3(start)]; /* start/4 * 3 */
+ count = BT_D4M3(start + ncolors - 1) - BT_D4M3(start) + 3;
+ bt = (struct bt_regs *) fb->ramdac;
+ bt->bt_addr = BT_D4M4(start);
+ while (--count >= 0)
+ bt->bt_cmap = *ip++;
+}
+
+/*
+ * Undo the effect of an FBIOSVIDEO that turns the video off on a CG3
+ */
+static void
+cg3_unblank(fbFd * dev)
+{
+ volatile struct bt_regs *bt;
+
+ if (blanked) {
+ bt = (struct bt_regs *) dev->ramdac;
+ /* restore color 0 (and R of color 1) */
+ bt->bt_addr = 0;
+ bt->bt_cmap = sc_cmap.cm_chip[0];
+
+ /* restore read mask */
+ bt->bt_addr = 0x06; /* command reg */
+ bt->bt_ctrl = 0x73; /* overlay plane */
+ bt->bt_addr = 0x04; /* read mask */
+ bt->bt_ctrl = 0xff; /* color planes */
+ }
+ blanked = 0;
+}
+
+int
+sunIoctl(fbFd * fb, int cmd, void *arg)
+{
+ int error;
+ int v;
+ int i;
+ u_int count;
+ union cursor_cmap tcm;
+
+ switch (cmd) {
+ default:
+ errno = EINVAL;
+ return -1;
+ case FBIOPUTCMAP:
+#define q ((struct fbcmap *)arg)
+ if (error = bt_putcmap(q, &sc_cmap, 256))
+ return error;
+ if (fb->thc) { /* CG6 */
+ cg6_loadcmap(fb, &sc_cmap, q->index, q->count);
+ } else { /* CG3 */
+ cg3_loadcmap(fb, &sc_cmap, q->index, q->count);
+ }
+ break;
+ case FBIOSVIDEO:
+ if (fb->thc) { /* CG6 */
+ if (*(int *) arg)
+ cg6_unblank(fb);
+ else {
+ if (!blanked) {
+ volatile struct cg6_thc *thc =
+ (volatile struct cg6_thc *) fb->thc;
+
+ thc->thc_misc = (thc->thc_misc & ~THC_MISC_VIDEN);
+ }
+ blanked = 1;
+ }
+ } else { /* CG3 */
+ if (*(int *) arg)
+ cg3_unblank(fb);
+ else {
+ if (!blanked) {
+ volatile struct bt_regs *bt;
+
+ bt = (struct bt_regs *) fb->ramdac;
+ bt->bt_addr = 0x06; /* command reg */
+ bt->bt_ctrl = 0x70; /* overlay plane */
+ bt->bt_addr = 0x04; /* read mask */
+ bt->bt_ctrl = 0x00; /* color planes */
+
+ /*
+ * Set color 0 to black -- note that this overwrites R of
+ * color 1.
+ */
+ bt->bt_addr = 0;
+ bt->bt_cmap = 0;
+
+ }
+ blanked = 1;
+ }
+ }
+ break;
+/* these are for both FBIOSCURSOR and FBIOGCURSOR */
+#define p ((struct fbcursor *)arg)
+#define cc (&sc_cursor)
+
+ case FBIOSCURSOR:
+ if (!fb->thc) { /* reject non CG6 */
+ errno = EINVAL;
+ return -1;
+ }
+ /*
+ * For setcmap and setshape, verify parameters, so that
+ * we do not get halfway through an update and then crap
+ * out with the software state screwed up.
+ */
+ v = p->set;
+ if (v & FB_CUR_SETCMAP) {
+ /*
+ * This use of a temporary copy of the cursor
+ * colormap is not terribly efficient, but these
+ * copies are small (8 bytes)...
+ */
+ tcm = cc->cc_color;
+ error = bt_putcmap(&p->cmap, (union bt_cmap *) &tcm, 2);
+ if (error)
+ return (error);
+ }
+ if (v & FB_CUR_SETSHAPE) {
+ if ((u_int) p->size.x > 32 || (u_int) p->size.y > 32)
+ return (EINVAL);
+ count = p->size.y * 32 / NBBY;
+ if (!useracc(p->image, count, B_READ) ||
+ !useracc(p->mask, count, B_READ))
+ return (EFAULT);
+ }
+ /* parameters are OK; do it */
+ if (v & (FB_CUR_SETCUR | FB_CUR_SETPOS | FB_CUR_SETHOT)) {
+ if (v & FB_CUR_SETCUR)
+ cc->cc_enable = p->enable;
+ if (v & FB_CUR_SETPOS)
+ cc->cc_pos = p->pos;
+ if (v & FB_CUR_SETHOT)
+ cc->cc_hot = p->hot;
+ cg6_setcursor(fb);
+ }
+ if (v & FB_CUR_SETCMAP) {
+ cc->cc_color = tcm;
+ cg6_loadomap(fb); /* XXX defer to vertical retrace */
+ }
+ if (v & FB_CUR_SETSHAPE) {
+ cc->cc_size = p->size;
+ count = p->size.y * 32 / NBBY;
+ bzero((caddr_t) cc->cc_bits, sizeof cc->cc_bits);
+ bcopy(p->mask, (caddr_t) cc->cc_bits[0], count);
+ bcopy(p->image, (caddr_t) cc->cc_bits[1], count);
+ cg6_loadcursor(fb);
+ }
+ break;
+ case FBIOSCURPOS:
+ if (!fb->thc) { /* reject non CG6 */
+ errno = EINVAL;
+ return -1;
+ }
+ sc_cursor.cc_pos = *(struct fbcurpos *) arg;
+ cg6_setcursor(fb);
+ break;
+
+ case FBIOGCURMAX:
+ if (!fb->thc) { /* reject non CG6 */
+ errno = EINVAL;
+ return -1;
+ }
+ /* max cursor size is 32x32 */
+ ((struct fbcurpos *) arg)->x = 32;
+ ((struct fbcurpos *) arg)->y = 32;
+ break;
+ case FBIORESET:
+ if (!fb->thc) { /* reject non CG6 */
+ errno = EINVAL;
+ return -1;
+ }
+ cg6_reset(fb);
+ }
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/vuid_event.h b/nx-X11/programs/Xserver/hw/sunLynx/vuid_event.h
new file mode 100644
index 000000000..37b3fd5b3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/vuid_event.h
@@ -0,0 +1,88 @@
+/* $Xorg: vuid_event.h,v 1.3 2000/08/17 19:48:38 cpqbld Exp $ */
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)vuid_event.h 8.1 (Berkeley) 6/11/93
+ */
+/* $NetBSD: vuid_event.h,v 1.2 1994/11/20 20:53:39 deraadt Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/vuid_event.h,v 3.1 1996/12/27 06:51:43 dawes Exp $ */
+
+/*
+ * The following is a minimal emulation of Sun's `Firm_event' structures
+ * and related operations necessary to make X11 happy (i.e., make it
+ * compile, and make old X11 binaries run).
+ */
+typedef struct firm_event {
+ u_short id; /* key or MS_* or LOC_[XY]_DELTA */
+ u_short pad; /* unused, at least by X11 */
+ int value; /* VKEY_{UP,DOWN} or locator delta */
+ struct timeval time;
+} Firm_event;
+
+/*
+ * Special `id' fields. These weird numbers simply match the old binaries.
+ * Others are in 0..0x7f and are keyboard key numbers (keyboard dependent!).
+ */
+#define MS_LEFT 0x7f20 /* left mouse button */
+#define MS_MIDDLE 0x7f21 /* middle mouse button */
+#define MS_RIGHT 0x7f22 /* right mouse button */
+#define LOC_X_DELTA 0x7f80 /* mouse delta-X */
+#define LOC_Y_DELTA 0x7f81 /* mouse delta-Y */
+#define LOC_X_ABSOLUTE 0x7f82 /* X compat, unsupported */
+#define LOC_Y_ABSOLUTE 0x7f83 /* X compat, unsupported */
+
+/*
+ * Special `value' fields. These apply to keys and mouse buttons. The
+ * value of a mouse delta is the delta. Note that positive deltas are
+ * left and up (not left and down as you might expect).
+ */
+#define VKEY_UP 0 /* key or button went up */
+#define VKEY_DOWN 1 /* key or button went down */
+
+/*
+ * The following ioctls are clearly intended to take things in and out
+ * of `firm event' mode. Since we always run in this mode (as far as
+ * /dev/kbd and /dev/mouse are concerned, anyway), we always claim to
+ * be in this mode and reject anything else.
+ */
+#define VUIDSFORMAT _IOW('v', 1, int)
+#define VUIDGFORMAT _IOR('v', 2, int)
+#define VUID_FIRM_EVENT 1 /* the only format we support */
diff --git a/nx-X11/programs/Xserver/hw/vfb/Imakefile b/nx-X11/programs/Xserver/hw/vfb/Imakefile
new file mode 100644
index 000000000..b58ff8fab
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/vfb/Imakefile
@@ -0,0 +1,71 @@
+XCOMM $Xorg: Imakefile,v 1.5 2000/08/17 19:48:38 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/hw/vfb/Imakefile,v 3.30 2001/05/31 16:11:10 dawes Exp $
+
+#include <Server.tmpl>
+
+#if HasShm
+SHMDEF = -DHAS_SHM
+#endif
+
+XCOMM add more architectures here as we discover them
+#if defined(HPArchitecture) || \
+ (defined(SparcArchitecture) && !defined(LynxOSArchitecture)) || \
+ SystemV4 || \
+ defined(OSF1Architecture) || \
+ defined(i386BsdArchitecture) || \
+ (defined(KFreeBSDArchitecture) && defined(i386Architecture)) || \
+ defined(LinuxArchitecture) || \
+ defined(DarwinArchitecture)
+MMAPDEF = -DHAS_MMAP
+#endif
+
+#ifdef OS2Architecture
+SRCS1 = os2_stubs.c
+OBJS1 = os2_stubs.o
+#endif
+
+SRCSA = InitInput.c InitOutput.c stubs.c $(SRCS1) miinitext.c $(SRCS2)
+
+OBJSA = InitInput.o InitOutput.o stubs.o $(OBJS1) miinitext.o $(OBJS2)
+
+INCLUDES = -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
+ -I$(SERVERSRC)/fb -I$(SERVERSRC)/mi -I$(SERVERSRC)/include -I../../os \
+ -I$(SERVERSRC)/Xext -I$(EXTINCSRC) -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/render
+
+DEFINES = $(OS_DEFINES) $(SHMDEF) $(MMAPDEF) -UXFree86LOADER
+
+
+#if BuildDPMS
+SRCSC = dpmsstubs.c
+OBJSC = dpmsstubs.o
+#endif
+
+SRCS = $(SRCSA) $(SRCSB) $(SRCSC)
+OBJS = $(OBJSA) $(OBJSB) $(OBJSC)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(vfb,$(OBJS))
+
+#ifdef OS2Architecture
+LinkSourceFile(os2_stubs.c,../xfree86/os-support/os2)
+SpecialCObjectRule(os2_stubs,$(ICONFIGFILES),-DOS2NULLSELECT)
+#endif
+
+LinkSourceFile(stubs.c,../../Xi)
+SpecialCObjectRule(InitInput,$(ICONFIGFILES),$(EXT_DEFINES))
+
+LinkSourceFile(miinitext.c,$(SERVERSRC)/mi)
+SpecialCObjectRule(miinitext,$(ICONFIGFILES),$(EXT_DEFINES) $(PAN_DEFINES) -DNO_HW_ONLY_EXTS -DNO_MODULE_EXTS $(EXT_MODULE_DEFINES) -UXFree86LOADER)
+
+#if BuildDPMS
+LinkSourceFile(dpmsstubs.c,$(SERVERSRC)/Xext)
+SpecialCObjectRule(dpmsstubs,$(ICONFIGFILES),$(EXT_DEFINES))
+#endif
+
+InstallManPage(Xvfb,$(MANDIR))
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/vfb/InitInput.c b/nx-X11/programs/Xserver/hw/vfb/InitInput.c
new file mode 100644
index 000000000..57f466444
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/vfb/InitInput.c
@@ -0,0 +1,344 @@
+/* $Xorg: InitInput.c,v 1.4 2001/02/09 02:04:44 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/vfb/InitInput.c,v 3.9 2001/12/14 19:59:45 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#define NEED_EVENTS
+#include "mi.h"
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "inputstr.h"
+#include <X11/Xos.h>
+#include "mibstore.h"
+#include "mipointer.h"
+#include "lk201kbd.h"
+#include <X11/keysym.h>
+
+Bool
+LegalModifier(unsigned int key, DevicePtr pDev)
+{
+ return TRUE;
+}
+
+void
+ProcessInputEvents()
+{
+ mieqProcessInputEvents();
+ miPointerUpdate();
+}
+
+#define VFB_MIN_KEY 8
+#define VFB_MAX_KEY 255
+KeySym map[MAP_LENGTH * LK201_GLYPHS_PER_KEY];
+
+/* The only reason for using the LK201 mappings here was that they were
+ * easy to lift.
+ */
+static Bool
+GetLK201Mappings(KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+#define INDEX(in) ((in - VFB_MIN_KEY) * LK201_GLYPHS_PER_KEY)
+ int i;
+
+ for (i = 0; i < MAP_LENGTH; i++)
+ pModMap[i] = NoSymbol; /* make sure it is restored */
+ pModMap[ KEY_LOCK ] = LockMask;
+ pModMap[ KEY_SHIFT ] = ShiftMask;
+ pModMap[ KEY_CTRL ] = ControlMask;
+ pModMap[ KEY_COMPOSE ] = Mod1Mask;
+
+ pKeySyms->minKeyCode = VFB_MIN_KEY;
+ pKeySyms->maxKeyCode = VFB_MAX_KEY;
+ pKeySyms->mapWidth = LK201_GLYPHS_PER_KEY;
+ pKeySyms->map = map;
+
+ for (i = 0; i < (MAP_LENGTH * LK201_GLYPHS_PER_KEY); i++)
+ map[i] = NoSymbol; /* make sure it is restored */
+
+ map[INDEX(KEY_F1)] = XK_F1;
+ map[INDEX(KEY_F2)] = XK_F2;
+ map[INDEX(KEY_F3)] = XK_F3;
+ map[INDEX(KEY_F4)] = XK_F4;
+ map[INDEX(KEY_F5)] = XK_F5;
+ map[INDEX(KEY_F6)] = XK_F6;
+ map[INDEX(KEY_F7)] = XK_F7;
+ map[INDEX(KEY_F8)] = XK_F8;
+ map[INDEX(KEY_F9)] = XK_F9;
+ map[INDEX(KEY_F10)] = XK_F10;
+ map[INDEX(KEY_F11)] = XK_F11;
+ map[INDEX(KEY_F12)] = XK_F12;
+ map[INDEX(KEY_F13)] = XK_F13;
+ map[INDEX(KEY_F14)] = XK_F14;
+
+ map[INDEX(KEY_HELP)] = XK_Help;
+ map[INDEX(KEY_MENU)] = XK_Menu;
+
+ map[INDEX(KEY_F17)] = XK_F17;
+ map[INDEX(KEY_F18)] = XK_F18;
+ map[INDEX(KEY_F19)] = XK_F19;
+ map[INDEX(KEY_F20)] = XK_F20;
+
+ map[INDEX(KEY_FIND)] = XK_Find;
+ map[INDEX(KEY_INSERT_HERE)] = XK_Insert;
+ map[INDEX(KEY_REMOVE)] = XK_Delete;
+ map[INDEX(KEY_SELECT)] = XK_Select;
+ map[INDEX(KEY_PREV_SCREEN)] = XK_Prior;
+ map[INDEX(KEY_NEXT_SCREEN)] = XK_Next;
+
+ map[INDEX(KEY_KP_0)] = XK_KP_0;
+ map[INDEX(KEY_KP_PERIOD)] = XK_KP_Decimal;
+ map[INDEX(KEY_KP_ENTER)] = XK_KP_Enter;
+ map[INDEX(KEY_KP_1)] = XK_KP_1;
+ map[INDEX(KEY_KP_2)] = XK_KP_2;
+ map[INDEX(KEY_KP_3)] = XK_KP_3;
+ map[INDEX(KEY_KP_4)] = XK_KP_4;
+ map[INDEX(KEY_KP_5)] = XK_KP_5;
+ map[INDEX(KEY_KP_6)] = XK_KP_6;
+ map[INDEX(KEY_KP_COMMA)] = XK_KP_Separator;
+ map[INDEX(KEY_KP_7)] = XK_KP_7;
+ map[INDEX(KEY_KP_8)] = XK_KP_8;
+ map[INDEX(KEY_KP_9)] = XK_KP_9;
+ map[INDEX(KEY_KP_HYPHEN)] = XK_KP_Subtract;
+ map[INDEX(KEY_KP_PF1)] = XK_KP_F1;
+ map[INDEX(KEY_KP_PF2)] = XK_KP_F2;
+ map[INDEX(KEY_KP_PF3)] = XK_KP_F3;
+ map[INDEX(KEY_KP_PF4)] = XK_KP_F4;
+
+ map[INDEX(KEY_LEFT)] = XK_Left;
+ map[INDEX(KEY_RIGHT)] = XK_Right;
+ map[INDEX(KEY_DOWN)] = XK_Down;
+ map[INDEX(KEY_UP)] = XK_Up;
+
+ map[INDEX(KEY_SHIFT)] = XK_Shift_L;
+ map[INDEX(KEY_CTRL)] = XK_Control_L;
+ map[INDEX(KEY_LOCK)] = XK_Caps_Lock;
+ map[INDEX(KEY_COMPOSE)] = XK_Multi_key;
+ map[INDEX(KEY_COMPOSE)+1] = XK_Meta_L;
+ map[INDEX(KEY_DELETE)] = XK_Delete;
+ map[INDEX(KEY_RETURN)] = XK_Return;
+ map[INDEX(KEY_TAB)] = XK_Tab;
+
+ map[INDEX(KEY_TILDE)] = XK_quoteleft;
+ map[INDEX(KEY_TILDE)+1] = XK_asciitilde;
+
+ map[INDEX(KEY_TR_1)] = XK_1;
+ map[INDEX(KEY_TR_1)+1] = XK_exclam;
+ map[INDEX(KEY_Q)] = XK_Q;
+ map[INDEX(KEY_A)] = XK_A;
+ map[INDEX(KEY_Z)] = XK_Z;
+
+ map[INDEX(KEY_TR_2)] = XK_2;
+ map[INDEX(KEY_TR_2)+1] = XK_at;
+
+ map[INDEX(KEY_W)] = XK_W;
+ map[INDEX(KEY_S)] = XK_S;
+ map[INDEX(KEY_X)] = XK_X;
+
+ map[INDEX(KEY_LANGLE_RANGLE)] = XK_less;
+ map[INDEX(KEY_LANGLE_RANGLE)+1] = XK_greater;
+
+ map[INDEX(KEY_TR_3)] = XK_3;
+ map[INDEX(KEY_TR_3)+1] = XK_numbersign;
+
+ map[INDEX(KEY_E)] = XK_E;
+ map[INDEX(KEY_D)] = XK_D;
+ map[INDEX(KEY_C)] = XK_C;
+
+ map[INDEX(KEY_TR_4)] = XK_4;
+ map[INDEX(KEY_TR_4)+1] = XK_dollar;
+
+ map[INDEX(KEY_R)] = XK_R;
+ map[INDEX(KEY_F)] = XK_F;
+ map[INDEX(KEY_V)] = XK_V;
+ map[INDEX(KEY_SPACE)] = XK_space;
+
+ map[INDEX(KEY_TR_5)] = XK_5;
+ map[INDEX(KEY_TR_5)+1] = XK_percent;
+
+ map[INDEX(KEY_T)] = XK_T;
+ map[INDEX(KEY_G)] = XK_G;
+ map[INDEX(KEY_B)] = XK_B;
+
+ map[INDEX(KEY_TR_6)] = XK_6;
+ map[INDEX(KEY_TR_6)+1] = XK_asciicircum;
+
+ map[INDEX(KEY_Y)] = XK_Y;
+ map[INDEX(KEY_H)] = XK_H;
+ map[INDEX(KEY_N)] = XK_N;
+
+ map[INDEX(KEY_TR_7)] = XK_7;
+ map[INDEX(KEY_TR_7)+1] = XK_ampersand;
+
+ map[INDEX(KEY_U)] = XK_U;
+ map[INDEX(KEY_J)] = XK_J;
+ map[INDEX(KEY_M)] = XK_M;
+
+ map[INDEX(KEY_TR_8)] = XK_8;
+ map[INDEX(KEY_TR_8)+1] = XK_asterisk;
+
+ map[INDEX(KEY_I)] = XK_I;
+ map[INDEX(KEY_K)] = XK_K;
+
+ map[INDEX(KEY_COMMA)] = XK_comma;
+ map[INDEX(KEY_COMMA)+1] = XK_less;
+
+ map[INDEX(KEY_TR_9)] = XK_9;
+ map[INDEX(KEY_TR_9)+1] = XK_parenleft;
+
+ map[INDEX(KEY_O)] = XK_O;
+ map[INDEX(KEY_L)] = XK_L;
+
+ map[INDEX(KEY_PERIOD)] = XK_period;
+ map[INDEX(KEY_PERIOD)+1] = XK_greater;
+
+ map[INDEX(KEY_TR_0)] = XK_0;
+ map[INDEX(KEY_TR_0)+1] = XK_parenright;
+
+ map[INDEX(KEY_P)] = XK_P;
+
+ map[INDEX(KEY_SEMICOLON)] = XK_semicolon;
+ map[INDEX(KEY_SEMICOLON)+1] = XK_colon;
+
+ map[INDEX(KEY_QMARK)] = XK_slash;
+ map[INDEX(KEY_QMARK)+1] = XK_question;
+
+ map[INDEX(KEY_PLUS)] = XK_equal;
+ map[INDEX(KEY_PLUS)+1] = XK_plus;
+
+ map[INDEX(KEY_RBRACE)] = XK_bracketright;
+ map[INDEX(KEY_RBRACE)+1] = XK_braceright;
+
+ map[INDEX(KEY_VBAR)] = XK_backslash;
+ map[INDEX(KEY_VBAR)+1] = XK_bar;
+
+ map[INDEX(KEY_UBAR)] = XK_minus;
+ map[INDEX(KEY_UBAR)+1] = XK_underscore;
+
+ map[INDEX(KEY_LBRACE)] = XK_bracketleft;
+ map[INDEX(KEY_LBRACE)+1] = XK_braceleft;
+
+ map[INDEX(KEY_QUOTE)] = XK_quoteright;
+ map[INDEX(KEY_QUOTE)+1] = XK_quotedbl;
+
+ map[INDEX(KEY_F11)] = XK_Escape;
+
+ return TRUE;
+#undef INDEX
+}
+
+static int
+vfbKeybdProc(DeviceIntPtr pDevice, int onoff)
+{
+ KeySymsRec keySyms;
+ CARD8 modMap[MAP_LENGTH];
+ DevicePtr pDev = (DevicePtr)pDevice;
+
+ switch (onoff)
+ {
+ case DEVICE_INIT:
+ GetLK201Mappings(&keySyms, modMap);
+ InitKeyboardDeviceStruct(pDev, &keySyms, modMap,
+ (BellProcPtr)NoopDDA, (KbdCtrlProcPtr)NoopDDA);
+ break;
+ case DEVICE_ON:
+ pDev->on = TRUE;
+ break;
+ case DEVICE_OFF:
+ pDev->on = FALSE;
+ break;
+ case DEVICE_CLOSE:
+ break;
+ }
+ return Success;
+}
+
+static int
+vfbMouseProc(DeviceIntPtr pDevice, int onoff)
+{
+ BYTE map[4];
+ DevicePtr pDev = (DevicePtr)pDevice;
+
+ switch (onoff)
+ {
+ case DEVICE_INIT:
+ map[1] = 1;
+ map[2] = 2;
+ map[3] = 3;
+ InitPointerDeviceStruct(pDev, map, 3, miPointerGetMotionEvents,
+ (PtrCtrlProcPtr)NoopDDA, miPointerGetMotionBufferSize());
+ break;
+
+ case DEVICE_ON:
+ pDev->on = TRUE;
+ break;
+
+ case DEVICE_OFF:
+ pDev->on = FALSE;
+ break;
+
+ case DEVICE_CLOSE:
+ break;
+ }
+ return Success;
+}
+
+void
+InitInput(int argc, char *argv[])
+{
+ DeviceIntPtr p, k;
+ p = AddInputDevice(vfbMouseProc, TRUE);
+ k = AddInputDevice(vfbKeybdProc, TRUE);
+ RegisterPointerDevice(p);
+ RegisterKeyboardDevice(k);
+ miRegisterPointerDevice(screenInfo.screens[0], p);
+ (void)mieqInit ((DevicePtr) k, (DevicePtr) p);
+}
+
+#ifdef XTESTEXT1
+void
+XTestGenerateEvent(int dev_type, int keycode, int keystate, int mousex,
+ int mousey)
+{
+}
+
+void
+XTestGetPointerPos(short *fmousex, short *fmousey)
+{
+}
+
+void
+XTestJumpPointer(int jx, int jy, int dev_type)
+{
+}
+#endif
+
diff --git a/nx-X11/programs/Xserver/hw/vfb/InitOutput.c b/nx-X11/programs/Xserver/hw/vfb/InitOutput.c
new file mode 100644
index 000000000..630d3e133
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/vfb/InitOutput.c
@@ -0,0 +1,1046 @@
+/* $Xorg: InitOutput.c,v 1.4 2001/02/09 02:04:45 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/vfb/InitOutput.c,v 3.25 2003/11/15 04:01:56 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#if defined(WIN32)
+#include <X11/Xwinsock.h>
+#endif
+#include <stdio.h>
+#include <X11/X.h>
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include <X11/Xos.h>
+#include "scrnintstr.h"
+#include "servermd.h"
+#define PSZ 8
+#include "fb.h"
+#include "mibstore.h"
+#include "colormapst.h"
+#include "gcstruct.h"
+#include "input.h"
+#include "mipointer.h"
+#include "micmap.h"
+#include <sys/types.h>
+#ifdef HAS_MMAP
+#include <sys/mman.h>
+#ifndef MAP_FILE
+#define MAP_FILE 0
+#endif
+#endif /* HAS_MMAP */
+#include <sys/stat.h>
+#include <errno.h>
+#ifndef WIN32
+#include <sys/param.h>
+#endif
+#include <X11/XWDFile.h>
+#ifdef HAS_SHM
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#endif /* HAS_SHM */
+#include "dix.h"
+#include "miline.h"
+
+#define VFB_DEFAULT_WIDTH 1280
+#define VFB_DEFAULT_HEIGHT 1024
+#define VFB_DEFAULT_DEPTH 8
+#define VFB_DEFAULT_WHITEPIXEL 1
+#define VFB_DEFAULT_BLACKPIXEL 0
+#define VFB_DEFAULT_LINEBIAS 0
+#define XWD_WINDOW_NAME_LEN 60
+
+typedef struct
+{
+ int scrnum;
+ int width;
+ int paddedBytesWidth;
+ int paddedWidth;
+ int height;
+ int depth;
+ int bitsPerPixel;
+ int sizeInBytes;
+ int ncolors;
+ char *pfbMemory;
+ XWDColor *pXWDCmap;
+ XWDFileHeader *pXWDHeader;
+ Pixel blackPixel;
+ Pixel whitePixel;
+ unsigned int lineBias;
+ CloseScreenProcPtr closeScreen;
+
+#ifdef HAS_MMAP
+ int mmap_fd;
+ char mmap_file[MAXPATHLEN];
+#endif
+
+#ifdef HAS_SHM
+ int shmid;
+#endif
+} vfbScreenInfo, *vfbScreenInfoPtr;
+
+static int vfbNumScreens;
+static vfbScreenInfo vfbScreens[MAXSCREENS];
+static Bool vfbPixmapDepths[33];
+#ifdef HAS_MMAP
+static char *pfbdir = NULL;
+#endif
+typedef enum { NORMAL_MEMORY_FB, SHARED_MEMORY_FB, MMAPPED_FILE_FB } fbMemType;
+static fbMemType fbmemtype = NORMAL_MEMORY_FB;
+static char needswap = 0;
+static int lastScreen = -1;
+static Bool Render = TRUE;
+
+#define swapcopy16(_dst, _src) \
+ if (needswap) { CARD16 _s = _src; cpswaps(_s, _dst); } \
+ else _dst = _src;
+
+#define swapcopy32(_dst, _src) \
+ if (needswap) { CARD32 _s = _src; cpswapl(_s, _dst); } \
+ else _dst = _src;
+
+
+static void
+vfbInitializePixmapDepths(void)
+{
+ int i;
+ vfbPixmapDepths[1] = TRUE; /* always need bitmaps */
+ for (i = 2; i <= 32; i++)
+ vfbPixmapDepths[i] = FALSE;
+}
+
+static void
+vfbInitializeDefaultScreens(void)
+{
+ int i;
+
+ for (i = 0; i < MAXSCREENS; i++)
+ {
+ vfbScreens[i].scrnum = i;
+ vfbScreens[i].width = VFB_DEFAULT_WIDTH;
+ vfbScreens[i].height = VFB_DEFAULT_HEIGHT;
+ vfbScreens[i].depth = VFB_DEFAULT_DEPTH;
+ vfbScreens[i].blackPixel = VFB_DEFAULT_BLACKPIXEL;
+ vfbScreens[i].whitePixel = VFB_DEFAULT_WHITEPIXEL;
+ vfbScreens[i].lineBias = VFB_DEFAULT_LINEBIAS;
+ vfbScreens[i].pfbMemory = NULL;
+ }
+ vfbNumScreens = 1;
+}
+
+static int
+vfbBitsPerPixel(int depth)
+{
+ if (depth == 1) return 1;
+ else if (depth <= 8) return 8;
+ else if (depth <= 16) return 16;
+ else return 32;
+}
+
+void
+ddxGiveUp()
+{
+ int i;
+
+ /* clean up the framebuffers */
+
+ switch (fbmemtype)
+ {
+#ifdef HAS_MMAP
+ case MMAPPED_FILE_FB:
+ for (i = 0; i < vfbNumScreens; i++)
+ {
+ if (-1 == unlink(vfbScreens[i].mmap_file))
+ {
+ perror("unlink");
+ ErrorF("unlink %s failed, errno %d",
+ vfbScreens[i].mmap_file, errno);
+ }
+ }
+ break;
+#else /* HAS_MMAP */
+ case MMAPPED_FILE_FB:
+ break;
+#endif /* HAS_MMAP */
+
+#ifdef HAS_SHM
+ case SHARED_MEMORY_FB:
+ for (i = 0; i < vfbNumScreens; i++)
+ {
+ if (-1 == shmdt((char *)vfbScreens[i].pXWDHeader))
+ {
+ perror("shmdt");
+ ErrorF("shmdt failed, errno %d", errno);
+ }
+ }
+ break;
+#else /* HAS_SHM */
+ case SHARED_MEMORY_FB:
+ break;
+#endif /* HAS_SHM */
+
+ case NORMAL_MEMORY_FB:
+ for (i = 0; i < vfbNumScreens; i++)
+ {
+ Xfree(vfbScreens[i].pXWDHeader);
+ }
+ break;
+ }
+}
+
+void
+AbortDDX()
+{
+ ddxGiveUp();
+}
+
+#ifdef __DARWIN__
+void
+DarwinHandleGUI(int argc, char *argv[])
+{
+}
+
+void GlxExtensionInit();
+void GlxWrapInitVisuals(void *procPtr);
+
+void
+DarwinGlxExtensionInit()
+{
+ GlxExtensionInit();
+}
+
+void
+DarwinGlxWrapInitVisuals(
+ void *procPtr)
+{
+ GlxWrapInitVisuals(procPtr);
+}
+#endif
+
+void
+OsVendorInit()
+{
+}
+
+void
+OsVendorFatalError()
+{
+}
+
+void ddxBeforeReset(void)
+{
+ return;
+}
+
+void
+ddxUseMsg()
+{
+ ErrorF("-screen scrn WxHxD set screen's width, height, depth\n");
+ ErrorF("-pixdepths list-of-int support given pixmap depths\n");
+#ifdef RENDER
+ ErrorF("+/-render turn on/of RENDER extension support"
+ "(default on)\n");
+#endif
+ ErrorF("-linebias n adjust thin line pixelization\n");
+ ErrorF("-blackpixel n pixel value for black\n");
+ ErrorF("-whitepixel n pixel value for white\n");
+
+#ifdef HAS_MMAP
+ ErrorF("-fbdir directory put framebuffers in mmap'ed files in directory\n");
+#endif
+
+#ifdef HAS_SHM
+ ErrorF("-shmem put framebuffers in shared memory\n");
+#endif
+}
+
+/* ddxInitGlobals - called by |InitGlobals| from os/util.c */
+void ddxInitGlobals(void)
+{
+}
+
+int
+ddxProcessArgument(int argc, char *argv[], int i)
+{
+ static Bool firstTime = TRUE;
+
+ if (firstTime)
+ {
+ vfbInitializeDefaultScreens();
+ vfbInitializePixmapDepths();
+ firstTime = FALSE;
+ }
+
+ if (strcmp (argv[i], "-screen") == 0) /* -screen n WxHxD */
+ {
+ int screenNum;
+ if (i + 2 >= argc) UseMsg();
+ screenNum = atoi(argv[i+1]);
+ if (screenNum < 0 || screenNum >= MAXSCREENS)
+ {
+ ErrorF("Invalid screen number %d\n", screenNum);
+ UseMsg();
+ }
+ if (3 != sscanf(argv[i+2], "%dx%dx%d",
+ &vfbScreens[screenNum].width,
+ &vfbScreens[screenNum].height,
+ &vfbScreens[screenNum].depth))
+ {
+ ErrorF("Invalid screen configuration %s\n", argv[i+2]);
+ UseMsg();
+ }
+
+ if (screenNum >= vfbNumScreens)
+ vfbNumScreens = screenNum + 1;
+ lastScreen = screenNum;
+ return 3;
+ }
+
+ if (strcmp (argv[i], "-pixdepths") == 0) /* -pixdepths list-of-depth */
+ {
+ int depth, ret = 1;
+
+ if (++i >= argc) UseMsg();
+ while ((i < argc) && (depth = atoi(argv[i++])) != 0)
+ {
+ if (depth < 0 || depth > 32)
+ {
+ ErrorF("Invalid pixmap depth %d\n", depth);
+ UseMsg();
+ }
+ vfbPixmapDepths[depth] = TRUE;
+ ret++;
+ }
+ return ret;
+ }
+
+ if (strcmp (argv[i], "+render") == 0) /* +render */
+ {
+ Render = TRUE;
+ return 1;
+ }
+
+ if (strcmp (argv[i], "-render") == 0) /* -render */
+ {
+ Render = FALSE;
+ return 1;
+ }
+
+ if (strcmp (argv[i], "-blackpixel") == 0) /* -blackpixel n */
+ {
+ Pixel pix;
+ if (++i >= argc) UseMsg();
+ pix = atoi(argv[i]);
+ if (-1 == lastScreen)
+ {
+ int i;
+ for (i = 0; i < MAXSCREENS; i++)
+ {
+ vfbScreens[i].blackPixel = pix;
+ }
+ }
+ else
+ {
+ vfbScreens[lastScreen].blackPixel = pix;
+ }
+ return 2;
+ }
+
+ if (strcmp (argv[i], "-whitepixel") == 0) /* -whitepixel n */
+ {
+ Pixel pix;
+ if (++i >= argc) UseMsg();
+ pix = atoi(argv[i]);
+ if (-1 == lastScreen)
+ {
+ int i;
+ for (i = 0; i < MAXSCREENS; i++)
+ {
+ vfbScreens[i].whitePixel = pix;
+ }
+ }
+ else
+ {
+ vfbScreens[lastScreen].whitePixel = pix;
+ }
+ return 2;
+ }
+
+ if (strcmp (argv[i], "-linebias") == 0) /* -linebias n */
+ {
+ unsigned int linebias;
+ if (++i >= argc) UseMsg();
+ linebias = atoi(argv[i]);
+ if (-1 == lastScreen)
+ {
+ int i;
+ for (i = 0; i < MAXSCREENS; i++)
+ {
+ vfbScreens[i].lineBias = linebias;
+ }
+ }
+ else
+ {
+ vfbScreens[lastScreen].lineBias = linebias;
+ }
+ return 2;
+ }
+
+#ifdef HAS_MMAP
+ if (strcmp (argv[i], "-fbdir") == 0) /* -fbdir directory */
+ {
+ if (++i >= argc) UseMsg();
+ pfbdir = argv[i];
+ fbmemtype = MMAPPED_FILE_FB;
+ return 2;
+ }
+#endif /* HAS_MMAP */
+
+#ifdef HAS_SHM
+ if (strcmp (argv[i], "-shmem") == 0) /* -shmem */
+ {
+ fbmemtype = SHARED_MEMORY_FB;
+ return 1;
+ }
+#endif
+
+ return 0;
+}
+
+#ifdef DDXTIME /* from ServerOSDefines */
+CARD32
+GetTimeInMillis()
+{
+ struct timeval tp;
+
+ X_GETTIMEOFDAY(&tp);
+ return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);
+}
+#endif
+
+static ColormapPtr InstalledMaps[MAXSCREENS];
+
+static int
+vfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
+{
+ /* By the time we are processing requests, we can guarantee that there
+ * is always a colormap installed */
+ *pmaps = InstalledMaps[pScreen->myNum]->mid;
+ return (1);
+}
+
+
+static void
+vfbInstallColormap(ColormapPtr pmap)
+{
+ int index = pmap->pScreen->myNum;
+ ColormapPtr oldpmap = InstalledMaps[index];
+
+ if (pmap != oldpmap)
+ {
+ int entries;
+ XWDFileHeader *pXWDHeader;
+ XWDColor *pXWDCmap;
+ VisualPtr pVisual;
+ Pixel * ppix;
+ xrgb * prgb;
+ xColorItem *defs;
+ int i;
+
+ if(oldpmap != (ColormapPtr)None)
+ WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid);
+ /* Install pmap */
+ InstalledMaps[index] = pmap;
+ WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid);
+
+ entries = pmap->pVisual->ColormapEntries;
+ pXWDHeader = vfbScreens[pmap->pScreen->myNum].pXWDHeader;
+ pXWDCmap = vfbScreens[pmap->pScreen->myNum].pXWDCmap;
+ pVisual = pmap->pVisual;
+
+ swapcopy32(pXWDHeader->visual_class, pVisual->class);
+ swapcopy32(pXWDHeader->red_mask, pVisual->redMask);
+ swapcopy32(pXWDHeader->green_mask, pVisual->greenMask);
+ swapcopy32(pXWDHeader->blue_mask, pVisual->blueMask);
+ swapcopy32(pXWDHeader->bits_per_rgb, pVisual->bitsPerRGBValue);
+ swapcopy32(pXWDHeader->colormap_entries, pVisual->ColormapEntries);
+
+ ppix = (Pixel *)ALLOCATE_LOCAL(entries * sizeof(Pixel));
+ prgb = (xrgb *)ALLOCATE_LOCAL(entries * sizeof(xrgb));
+ defs = (xColorItem *)ALLOCATE_LOCAL(entries * sizeof(xColorItem));
+
+ for (i = 0; i < entries; i++) ppix[i] = i;
+ /* XXX truecolor */
+ QueryColors(pmap, entries, ppix, prgb);
+
+ for (i = 0; i < entries; i++) { /* convert xrgbs to xColorItems */
+ defs[i].pixel = ppix[i] & 0xff; /* change pixel to index */
+ defs[i].red = prgb[i].red;
+ defs[i].green = prgb[i].green;
+ defs[i].blue = prgb[i].blue;
+ defs[i].flags = DoRed|DoGreen|DoBlue;
+ }
+ (*pmap->pScreen->StoreColors)(pmap, entries, defs);
+
+ DEALLOCATE_LOCAL(ppix);
+ DEALLOCATE_LOCAL(prgb);
+ DEALLOCATE_LOCAL(defs);
+ }
+}
+
+static void
+vfbUninstallColormap(ColormapPtr pmap)
+{
+ ColormapPtr curpmap = InstalledMaps[pmap->pScreen->myNum];
+
+ if(pmap == curpmap)
+ {
+ if (pmap->mid != pmap->pScreen->defColormap)
+ {
+ curpmap = (ColormapPtr) LookupIDByType(pmap->pScreen->defColormap,
+ RT_COLORMAP);
+ (*pmap->pScreen->InstallColormap)(curpmap);
+ }
+ }
+}
+
+static void
+vfbStoreColors(ColormapPtr pmap, int ndef, xColorItem *pdefs)
+{
+ XWDColor *pXWDCmap;
+ int i;
+
+ if (pmap != InstalledMaps[pmap->pScreen->myNum])
+ {
+ return;
+ }
+
+ pXWDCmap = vfbScreens[pmap->pScreen->myNum].pXWDCmap;
+
+ if ((pmap->pVisual->class | DynamicClass) == DirectColor)
+ {
+ return;
+ }
+
+ for (i = 0; i < ndef; i++)
+ {
+ if (pdefs[i].flags & DoRed)
+ {
+ swapcopy16(pXWDCmap[pdefs[i].pixel].red, pdefs[i].red);
+ }
+ if (pdefs[i].flags & DoGreen)
+ {
+ swapcopy16(pXWDCmap[pdefs[i].pixel].green, pdefs[i].green);
+ }
+ if (pdefs[i].flags & DoBlue)
+ {
+ swapcopy16(pXWDCmap[pdefs[i].pixel].blue, pdefs[i].blue);
+ }
+ }
+}
+
+static Bool
+vfbSaveScreen(ScreenPtr pScreen, int on)
+{
+ return TRUE;
+}
+
+#ifdef HAS_MMAP
+
+/* this flushes any changes to the screens out to the mmapped file */
+static void
+vfbBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
+{
+ int i;
+
+ for (i = 0; i < vfbNumScreens; i++)
+ {
+#ifdef MS_ASYNC
+ if (-1 == msync((caddr_t)vfbScreens[i].pXWDHeader,
+ (size_t)vfbScreens[i].sizeInBytes, MS_ASYNC))
+#else
+ /* silly NetBSD and who else? */
+ if (-1 == msync((caddr_t)vfbScreens[i].pXWDHeader,
+ (size_t)vfbScreens[i].sizeInBytes))
+#endif
+ {
+ perror("msync");
+ ErrorF("msync failed, errno %d", errno);
+ }
+ }
+}
+
+
+static void
+vfbWakeupHandler(pointer blockData, int result, pointer pReadmask)
+{
+}
+
+
+static void
+vfbAllocateMmappedFramebuffer(vfbScreenInfoPtr pvfb)
+{
+#define DUMMY_BUFFER_SIZE 65536
+ char dummyBuffer[DUMMY_BUFFER_SIZE];
+ int currentFileSize, writeThisTime;
+
+ sprintf(pvfb->mmap_file, "%s/Xvfb_screen%d", pfbdir, pvfb->scrnum);
+ if (-1 == (pvfb->mmap_fd = open(pvfb->mmap_file, O_CREAT|O_RDWR, 0666)))
+ {
+ perror("open");
+ ErrorF("open %s failed, errno %d", pvfb->mmap_file, errno);
+ return;
+ }
+
+ /* Extend the file to be the proper size */
+
+ bzero(dummyBuffer, DUMMY_BUFFER_SIZE);
+ for (currentFileSize = 0;
+ currentFileSize < pvfb->sizeInBytes;
+ currentFileSize += writeThisTime)
+ {
+ writeThisTime = min(DUMMY_BUFFER_SIZE,
+ pvfb->sizeInBytes - currentFileSize);
+ if (-1 == write(pvfb->mmap_fd, dummyBuffer, writeThisTime))
+ {
+ perror("write");
+ ErrorF("write %s failed, errno %d", pvfb->mmap_file, errno);
+ return;
+ }
+ }
+
+ /* try to mmap the file */
+
+ pvfb->pXWDHeader = (XWDFileHeader *)mmap((caddr_t)NULL, pvfb->sizeInBytes,
+ PROT_READ|PROT_WRITE,
+ MAP_FILE|MAP_SHARED,
+ pvfb->mmap_fd, 0);
+ if (-1 == (long)pvfb->pXWDHeader)
+ {
+ perror("mmap");
+ ErrorF("mmap %s failed, errno %d", pvfb->mmap_file, errno);
+ pvfb->pXWDHeader = NULL;
+ return;
+ }
+
+ if (!RegisterBlockAndWakeupHandlers(vfbBlockHandler, vfbWakeupHandler,
+ NULL))
+ {
+ pvfb->pXWDHeader = NULL;
+ }
+}
+#endif /* HAS_MMAP */
+
+
+#ifdef HAS_SHM
+static void
+vfbAllocateSharedMemoryFramebuffer(vfbScreenInfoPtr pvfb)
+{
+ /* create the shared memory segment */
+
+ pvfb->shmid = shmget(IPC_PRIVATE, pvfb->sizeInBytes, IPC_CREAT|0777);
+ if (pvfb->shmid < 0)
+ {
+ perror("shmget");
+ ErrorF("shmget %d bytes failed, errno %d", pvfb->sizeInBytes, errno);
+ return;
+ }
+
+ /* try to attach it */
+
+ pvfb->pXWDHeader = (XWDFileHeader *)shmat(pvfb->shmid, 0, 0);
+ if (-1 == (long)pvfb->pXWDHeader)
+ {
+ perror("shmat");
+ ErrorF("shmat failed, errno %d", errno);
+ pvfb->pXWDHeader = NULL;
+ return;
+ }
+
+ ErrorF("screen %d shmid %d\n", pvfb->scrnum, pvfb->shmid);
+}
+#endif /* HAS_SHM */
+
+static char *
+vfbAllocateFramebufferMemory(vfbScreenInfoPtr pvfb)
+{
+ if (pvfb->pfbMemory) return pvfb->pfbMemory; /* already done */
+
+ pvfb->sizeInBytes = pvfb->paddedBytesWidth * pvfb->height;
+
+ /* Calculate how many entries in colormap. This is rather bogus, because
+ * the visuals haven't even been set up yet, but we need to know because we
+ * have to allocate space in the file for the colormap. The number 10
+ * below comes from the MAX_PSEUDO_DEPTH define in cfbcmap.c.
+ */
+
+ if (pvfb->depth <= 10)
+ { /* single index colormaps */
+ pvfb->ncolors = 1 << pvfb->depth;
+ }
+ else
+ { /* decomposed colormaps */
+ int nplanes_per_color_component = pvfb->depth / 3;
+ if (pvfb->depth % 3) nplanes_per_color_component++;
+ pvfb->ncolors = 1 << nplanes_per_color_component;
+ }
+
+ /* add extra bytes for XWDFileHeader, window name, and colormap */
+
+ pvfb->sizeInBytes += SIZEOF(XWDheader) + XWD_WINDOW_NAME_LEN +
+ pvfb->ncolors * SIZEOF(XWDColor);
+
+ pvfb->pXWDHeader = NULL;
+ switch (fbmemtype)
+ {
+#ifdef HAS_MMAP
+ case MMAPPED_FILE_FB: vfbAllocateMmappedFramebuffer(pvfb); break;
+#else
+ case MMAPPED_FILE_FB: break;
+#endif
+
+#ifdef HAS_SHM
+ case SHARED_MEMORY_FB: vfbAllocateSharedMemoryFramebuffer(pvfb); break;
+#else
+ case SHARED_MEMORY_FB: break;
+#endif
+
+ case NORMAL_MEMORY_FB:
+ pvfb->pXWDHeader = (XWDFileHeader *)Xalloc(pvfb->sizeInBytes);
+ break;
+ }
+
+ if (pvfb->pXWDHeader)
+ {
+ pvfb->pXWDCmap = (XWDColor *)((char *)pvfb->pXWDHeader
+ + SIZEOF(XWDheader) + XWD_WINDOW_NAME_LEN);
+ pvfb->pfbMemory = (char *)(pvfb->pXWDCmap + pvfb->ncolors);
+
+ return pvfb->pfbMemory;
+ }
+ else
+ return NULL;
+}
+
+
+static void
+vfbWriteXWDFileHeader(ScreenPtr pScreen)
+{
+ vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum];
+ XWDFileHeader *pXWDHeader = pvfb->pXWDHeader;
+ char hostname[XWD_WINDOW_NAME_LEN];
+ unsigned long swaptest = 1;
+ int i;
+
+ needswap = *(char *) &swaptest;
+
+ pXWDHeader->header_size = (char *)pvfb->pXWDCmap - (char *)pvfb->pXWDHeader;
+ pXWDHeader->file_version = XWD_FILE_VERSION;
+
+ pXWDHeader->pixmap_format = ZPixmap;
+ pXWDHeader->pixmap_depth = pvfb->depth;
+ pXWDHeader->pixmap_height = pXWDHeader->window_height = pvfb->height;
+ pXWDHeader->xoffset = 0;
+ pXWDHeader->byte_order = IMAGE_BYTE_ORDER;
+ pXWDHeader->bitmap_bit_order = BITMAP_BIT_ORDER;
+#ifndef INTERNAL_VS_EXTERNAL_PADDING
+ pXWDHeader->pixmap_width = pXWDHeader->window_width = pvfb->width;
+ pXWDHeader->bitmap_unit = BITMAP_SCANLINE_UNIT;
+ pXWDHeader->bitmap_pad = BITMAP_SCANLINE_PAD;
+#else
+ pXWDHeader->pixmap_width = pXWDHeader->window_width = pvfb->paddedWidth;
+ pXWDHeader->bitmap_unit = BITMAP_SCANLINE_UNIT_PROTO;
+ pXWDHeader->bitmap_pad = BITMAP_SCANLINE_PAD_PROTO;
+#endif
+ pXWDHeader->bits_per_pixel = pvfb->bitsPerPixel;
+ pXWDHeader->bytes_per_line = pvfb->paddedBytesWidth;
+ pXWDHeader->ncolors = pvfb->ncolors;
+
+ /* visual related fields are written when colormap is installed */
+
+ pXWDHeader->window_x = pXWDHeader->window_y = 0;
+ pXWDHeader->window_bdrwidth = 0;
+
+ /* write xwd "window" name: Xvfb hostname:server.screen */
+
+ if (-1 == gethostname(hostname, sizeof(hostname)))
+ hostname[0] = 0;
+ else
+ hostname[XWD_WINDOW_NAME_LEN-1] = 0;
+ sprintf((char *)(pXWDHeader+1), "Xvfb %s:%s.%d", hostname, display,
+ pScreen->myNum);
+
+ /* write colormap pixel slot values */
+
+ for (i = 0; i < pvfb->ncolors; i++)
+ {
+ pvfb->pXWDCmap[i].pixel = i;
+ }
+
+ /* byte swap to most significant byte first */
+
+ if (needswap)
+ {
+ SwapLongs((CARD32 *)pXWDHeader, SIZEOF(XWDheader)/4);
+ for (i = 0; i < pvfb->ncolors; i++)
+ {
+ register char n;
+ swapl(&pvfb->pXWDCmap[i].pixel, n);
+ }
+ }
+}
+
+
+static Bool
+vfbCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y)
+{
+ return FALSE;
+}
+
+static void
+vfbCrossScreen (ScreenPtr pScreen, Bool entering)
+{
+}
+
+static miPointerScreenFuncRec vfbPointerCursorFuncs =
+{
+ vfbCursorOffScreen,
+ vfbCrossScreen,
+ miPointerWarpCursor
+};
+
+static Bool
+vfbCloseScreen(int index, ScreenPtr pScreen)
+{
+ vfbScreenInfoPtr pvfb = &vfbScreens[index];
+ int i;
+
+ pScreen->CloseScreen = pvfb->closeScreen;
+
+ /*
+ * XXX probably lots of stuff to clean. For now,
+ * clear InstalledMaps[] so that server reset works correctly.
+ */
+ for (i = 0; i < MAXSCREENS; i++)
+ InstalledMaps[i] = NULL;
+
+ return pScreen->CloseScreen(index, pScreen);
+}
+
+static Bool
+vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
+{
+ vfbScreenInfoPtr pvfb = &vfbScreens[index];
+ int dpix = monitorResolution, dpiy = monitorResolution;
+ int ret;
+ char *pbits;
+
+ if (dpix == 0)
+ dpix = 100;
+
+ if (dpiy == 0)
+ dpiy = 100;
+
+ pvfb->paddedBytesWidth = PixmapBytePad(pvfb->width, pvfb->depth);
+ pvfb->bitsPerPixel = vfbBitsPerPixel(pvfb->depth);
+ if (pvfb->bitsPerPixel >= 8 )
+ pvfb->paddedWidth = pvfb->paddedBytesWidth / (pvfb->bitsPerPixel / 8);
+ else
+ pvfb->paddedWidth = pvfb->paddedBytesWidth * 8;
+ pbits = vfbAllocateFramebufferMemory(pvfb);
+ if (!pbits) return FALSE;
+
+ miSetPixmapDepths ();
+
+ switch (pvfb->depth) {
+ case 8:
+ miSetVisualTypesAndMasks (8,
+ ((1 << StaticGray) |
+ (1 << GrayScale) |
+ (1 << StaticColor) |
+ (1 << PseudoColor) |
+ (1 << TrueColor) |
+ (1 << DirectColor)),
+ 8, PseudoColor, 0, 0, 0);
+ break;
+#if 0
+ /* 12bit PseudoColor with 12bit color resolution
+ * (to simulate SGI hardware and the 12bit PseudoColor emulation layer) */
+ case 12:
+ miSetVisualTypesAndMasks (12,
+ ((1 << StaticGray) |
+ (1 << GrayScale) |
+ (1 << StaticColor) |
+ (1 << PseudoColor) |
+ (1 << TrueColor) |
+ (1 << DirectColor)),
+ 12, PseudoColor, 0, 0, 0);
+ break;
+#endif
+ case 15:
+ miSetVisualTypesAndMasks (15,
+ ((1 << TrueColor) |
+ (1 << DirectColor)),
+ 8, TrueColor, 0x7c00, 0x03e0, 0x001f);
+ break;
+ case 16:
+ miSetVisualTypesAndMasks (16,
+ ((1 << TrueColor) |
+ (1 << DirectColor)),
+ 8, TrueColor, 0xf800, 0x07e0, 0x001f);
+ break;
+ case 24:
+ miSetVisualTypesAndMasks (24,
+ ((1 << TrueColor) |
+ (1 << DirectColor)),
+ 8, TrueColor, 0xff0000, 0x00ff00, 0x0000ff);
+ break;
+#if 0
+ /* 30bit TrueColor (to simulate Sun's XVR-1000/-4000 high quality
+ * framebuffer series) */
+ case 30:
+ miSetVisualTypesAndMasks (30,
+ ((1 << TrueColor) |
+ (1 << DirectColor)),
+ 10, TrueColor, 0x3ff00000, 0x000ffc00, 0x000003ff);
+ break;
+#endif
+ }
+
+ ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
+ dpix, dpiy, pvfb->paddedWidth,pvfb->bitsPerPixel);
+#ifdef RENDER
+ if (ret && Render)
+ fbPictureInit (pScreen, 0, 0);
+#endif
+
+ if (!ret) return FALSE;
+
+ miInitializeBackingStore(pScreen);
+
+ /*
+ * Circumvent the backing store that was just initialised. This amounts
+ * to a truely bizarre way of initialising SaveDoomedAreas and friends.
+ */
+
+ pScreen->InstallColormap = vfbInstallColormap;
+ pScreen->UninstallColormap = vfbUninstallColormap;
+ pScreen->ListInstalledColormaps = vfbListInstalledColormaps;
+
+ pScreen->SaveScreen = vfbSaveScreen;
+ pScreen->StoreColors = vfbStoreColors;
+
+ miDCInitialize(pScreen, &vfbPointerCursorFuncs);
+
+ vfbWriteXWDFileHeader(pScreen);
+
+ pScreen->blackPixel = pvfb->blackPixel;
+ pScreen->whitePixel = pvfb->whitePixel;
+
+ ret = fbCreateDefColormap(pScreen);
+
+ miSetZeroLineBias(pScreen, pvfb->lineBias);
+
+ pvfb->closeScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = vfbCloseScreen;
+
+ return ret;
+
+} /* end vfbScreenInit */
+
+
+void
+InitOutput(ScreenInfo *screenInfo, int argc, char **argv)
+{
+ int i;
+ int NumFormats = 0;
+
+ /* initialize pixmap formats */
+
+ /* must have a pixmap depth to match every screen depth */
+ for (i = 0; i < vfbNumScreens; i++)
+ {
+ vfbPixmapDepths[vfbScreens[i].depth] = TRUE;
+ }
+
+ /* RENDER needs a good set of pixmaps. */
+ if (Render) {
+ vfbPixmapDepths[1] = TRUE;
+ vfbPixmapDepths[4] = TRUE;
+ vfbPixmapDepths[8] = TRUE;
+#if 0
+ vfbPixmapDepths[12] = TRUE;
+#endif
+/* vfbPixmapDepths[15] = TRUE; */
+ vfbPixmapDepths[16] = TRUE;
+ vfbPixmapDepths[24] = TRUE;
+#if 0
+ vfbPixmapDepths[30] = TRUE;
+#endif
+ vfbPixmapDepths[32] = TRUE;
+ }
+
+ for (i = 1; i <= 32; i++)
+ {
+ if (vfbPixmapDepths[i])
+ {
+ if (NumFormats >= MAXFORMATS)
+ FatalError ("MAXFORMATS is too small for this server\n");
+ screenInfo->formats[NumFormats].depth = i;
+ screenInfo->formats[NumFormats].bitsPerPixel = vfbBitsPerPixel(i);
+ screenInfo->formats[NumFormats].scanlinePad = BITMAP_SCANLINE_PAD;
+ NumFormats++;
+ }
+ }
+
+ screenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+ screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+ screenInfo->numPixmapFormats = NumFormats;
+
+ /* initialize screens */
+
+ for (i = 0; i < vfbNumScreens; i++)
+ {
+ if (-1 == AddScreen(vfbScreenInit, argc, argv))
+ {
+ FatalError("Couldn't add screen %d", i);
+ }
+ }
+
+} /* end InitOutput */
+
+/* this is just to get the server to link on AIX */
+#ifdef AIXV3
+int SelectWaitTime = 10000; /* usec */
+#endif
+
diff --git a/nx-X11/programs/Xserver/hw/vfb/Xvfb.man b/nx-X11/programs/Xserver/hw/vfb/Xvfb.man
new file mode 100644
index 000000000..7499c49f0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/vfb/Xvfb.man
@@ -0,0 +1,132 @@
+.\" $XdotOrg: xc/programs/Xserver/hw/vfb/Xvfb.man,v 1.4 2005/09/08 01:15:47 anholt Exp $
+.\" $Xorg: Xvfb.man,v 1.4 2001/02/09 02:04:45 xorgcvs Exp $
+.\" Copyright 1993, 1998 The Open Group
+.\"
+.\" Permission to use, copy, modify, distribute, and sell this software and its
+.\" documentation for any purpose is hereby granted without fee, provided that
+.\" the above copyright notice appear in all copies and that both that
+.\" copyright notice and this permission notice appear in supporting
+.\" documentation.
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of The Open Group shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from The Open Group.
+.\"
+.\" $XFree86: xc/programs/Xserver/hw/vfb/Xvfb.man,v 1.9 2001/12/14 19:59:45 dawes Exp $
+.\"
+.TH XVFB 1 __xorgversion__
+.SH NAME
+Xvfb \- virtual framebuffer X server for X Version 11
+.SH SYNOPSIS
+.B Xvfb
+[ option ] ...
+.SH DESCRIPTION
+.I Xvfb
+is an X server that can run on machines with no display hardware
+and no physical input devices. It emulates a dumb framebuffer using
+virtual memory.
+.PP
+The primary use of this server was intended to be server testing. The
+fb code for any depth can be exercised with this server
+without the need for real hardware that supports the desired depths.
+The X community has found many other novel uses for \fIXvfb\fP,
+including testing clients against unusual depths and screen
+configurations, doing batch processing with \fIXvfb\fP as a background
+rendering engine, load testing, as an aid to porting the X server to a
+new platform, and providing an unobtrusive way to run applications
+that don't really need an X server but insist on having one anyway.
+.SH BUILDING
+To build \fIXvfb\fP, put the following in your host.def and remake.
+.PP
+\&#define BuildServer YES /\(** if you aren't already building other servers */
+.br
+\&#define XVirtualFramebufferServer YES
+
+.SH OPTIONS
+.PP
+In addition to the normal server options described in the \fIXserver(1)\fP
+manual page, \fIXvfb\fP accepts the following command line switches:
+.TP 4
+.B "\-screen \fIscreennum\fP \fIWxHxD\fP"
+This option creates screen \fIscreennum\fP and sets its width, height,
+and depth to W, H, and D respectively. By default, only screen 0 exists
+and has the dimensions 1280x1024x12.
+.TP 4
+.B "\-pixdepths \fIlist-of-depths\fP"
+This option specifies a list of pixmap depths that the server should
+support in addition to the depths implied by the supported screens.
+\fIlist-of-depths\fP is a space-separated list of integers that can
+have values from 1 to 32.
+.TP 4
+.B "\-fbdir \fIframebuffer-directory\fP"
+This option specifies the directory in which the memory mapped files
+containing the framebuffer memory should be created.
+See FILES.
+This option only exists on machines that have the mmap and msync system
+calls.
+.TP 4
+.B "\-shmem"
+This option specifies that the framebuffer should be put in shared memory.
+The shared memory ID for each screen will be printed by the server.
+The shared memory is in xwd format.
+This option only exists on machines that support the System V shared memory
+interface.
+.PP
+If neither \fB\-shmem\fP nor \fB\-fbdir\fP is specified,
+the framebuffer memory will be allocated with malloc().
+.TP 4
+.B "\-linebias \fIn\fP"
+This option specifies how to adjust the pixelization of thin lines.
+The value \fIn\fP is a bitmask of octants in which to prefer an axial
+step when the Bresenham error term is exactly zero. See the file
+Xserver/mi/miline.h for more information. This option is probably only useful
+to server developers to experiment with the range of line pixelization
+possible with the fb code.
+.TP 4
+.B "\-blackpixel \fIpixel-value\fP, \-whitepixel \fIpixel-value\fP"
+These options specify the black and white pixel values the server should use.
+.SH FILES
+The following files are created if the \-fbdir option is given.
+.TP 4
+\fIframebuffer-directory\fP/Xvfb_screen<n>
+Memory mapped file containing screen n's framebuffer memory, one file
+per screen. The file is in xwd format. Thus, taking a full-screen
+snapshot can be done with a file copy command, and the resulting
+snapshot will even contain the cursor image.
+.SH EXAMPLES
+.TP 8
+Xvfb :1 -screen 0 1600x1200x32
+The server will listen for connections as server number 1, and screen 0
+will be depth 32 1600x1200.
+.TP 8
+Xvfb :1 -screen 1 1600x1200x16
+The server will listen for connections as server number 1, will have the
+default screen configuration (one screen, 1280x1024x12), and screen 1
+will be depth 16 1600x1200.
+.TP 8
+Xvfb -pixdepths 3 27 -fbdir /usr/tmp
+The server will listen for connections as server number 0, will have the
+default screen configuration (one screen, 1280x1024x12),
+will also support pixmap
+depths of 3 and 27,
+and will use memory mapped files in /usr/tmp for the framebuffer.
+.TP 8
+xwud -in /usr/tmp/Xvfb_screen0
+Displays screen 0 of the server started by the preceding example.
+.SH "SEE ALSO"
+.PP
+X(__miscmansuffix__), Xserver(1), xwd(1), xwud(1), XWDFile.h
+.SH AUTHORS
+David P. Wiggins, The Open Group, Inc.
diff --git a/nx-X11/programs/Xserver/hw/vfb/lk201kbd.h b/nx-X11/programs/Xserver/hw/vfb/lk201kbd.h
new file mode 100644
index 000000000..9b4090ed0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/vfb/lk201kbd.h
@@ -0,0 +1,159 @@
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* $Xorg: lk201kbd.h,v 1.4 2001/02/09 02:04:45 xorgcvs Exp $ */
+
+#define MIN_LK201_KEY 86
+#define MAX_LK201_KEY 251
+#define LK201_GLYPHS_PER_KEY 2
+
+#define KEY_F1 86
+#define KEY_F2 87
+#define KEY_F3 88
+#define KEY_F4 89
+#define KEY_F5 90
+#define KEY_F6 100
+#define KEY_F7 101
+#define KEY_F8 102
+#define KEY_F9 103
+#define KEY_F10 104
+#define KEY_F11 113
+#define KEY_F12 114
+#define KEY_F13 115
+#define KEY_F14 116
+#define KEY_HELP 124
+#define KEY_MENU 125
+#define KEY_F17 128
+#define KEY_F18 129
+#define KEY_F19 130
+#define KEY_F20 131
+#define KEY_FIND 138
+#define KEY_INSERT_HERE 139
+#define KEY_REMOVE 140
+#define KEY_SELECT 141
+#define KEY_PREV_SCREEN 142
+#define KEY_NEXT_SCREEN 143
+#define KEY_KP_0 146 /* key pad */
+#define KEY_KP_PERIOD 148 /* key pad */
+#define KEY_KP_ENTER 149 /* key pad */
+#define KEY_KP_1 150 /* key pad */
+#define KEY_KP_2 151 /* key pad */
+#define KEY_KP_3 152 /* key pad */
+#define KEY_KP_4 153 /* key pad */
+#define KEY_KP_5 154 /* key pad */
+#define KEY_KP_6 155 /* key pad */
+#define KEY_KP_COMMA 156 /* key pad */
+#define KEY_KP_7 157 /* key pad */
+#define KEY_KP_8 158 /* key pad */
+#define KEY_KP_9 159 /* key pad */
+#define KEY_KP_HYPHEN 160
+#define KEY_KP_PF1 161
+#define KEY_KP_PF2 162
+#define KEY_KP_PF3 163
+#define KEY_KP_PF4 164
+#define KEY_LEFT 167
+#define KEY_RIGHT 168
+#define KEY_DOWN 169
+#define KEY_UP 170
+#define KEY_SHIFT 174
+#define KEY_CTRL 175
+#define KEY_LOCK 176
+#define KEY_COMPOSE 177
+#define KEY_APPLE 177
+#define KEY_META 177
+#define KEY_DELETE 188
+#define KEY_RETURN 189
+#define KEY_TAB 190
+#define KEY_TILDE 191
+#define KEY_TR_1 192 /* Top Row */
+#define KEY_Q 193
+#define KEY_A 194
+#define KEY_Z 195
+#define KEY_TR_2 197
+#define KEY_W 198
+#define KEY_S 199
+#define KEY_X 200
+#define KEY_LANGLE_RANGLE 201 /* xxx */
+#define KEY_TR_3 203
+#define KEY_E 204
+#define KEY_D 205
+#define KEY_C 206
+#define KEY_TR_4 208
+#define KEY_R 209
+#define KEY_F 210
+#define KEY_V 211
+#define KEY_SPACE 212
+#define KEY_TR_5 214
+#define KEY_T 215
+#define KEY_G 216
+#define KEY_B 217
+#define KEY_TR_6 219
+#define KEY_Y 220
+#define KEY_H 221
+#define KEY_N 222
+#define KEY_TR_7 224
+#define KEY_U 225
+#define KEY_J 226
+#define KEY_M 227
+#define KEY_TR_8 229
+#define KEY_I 230
+#define KEY_K 231
+#define KEY_COMMA 232 /* xxx */
+#define KEY_TR_9 234
+#define KEY_O 235
+#define KEY_L 236
+#define KEY_PERIOD 237 /* xxx */
+#define KEY_TR_0 239
+#define KEY_P 240
+#define KEY_SEMICOLON 242 /* xxx */
+#define KEY_QMARK 243
+#define KEY_PLUS 245 /* xxx */
+#define KEY_RBRACE 246
+#define KEY_VBAR 247 /* xxx */
+#define KEY_UBAR 249 /* xxx */
+#define KEY_LBRACE 250
+#define KEY_QUOTE 251
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/common/Imakefile
new file mode 100644
index 000000000..41bc6781e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/Imakefile
@@ -0,0 +1,275 @@
+XCOMM $XConsortium: Imakefile /main/34 1996/10/27 11:05:08 kaleb $
+
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/common/Imakefile,v 3.154 2003/10/08 14:58:26 dawes Exp $
+
+
+
+#include <Server.tmpl>
+
+#ifdef i386MachArchitecture
+#ifdef GNUMachArchitecture
+ KBD = xf86Kbd
+#else
+ KBD = xf86KbdMach
+#endif /* GNUMachArchitecture */
+#else
+# if defined(i386BsdArchitecture) || defined(AlphaBsdArchitecture) \
+ || defined(OpenBSDArchitecture) || defined(NetBSDArchitecture) \
+ || defined(KFreeBSDArchitecture)
+ KBD = xf86KbdBSD
+# else
+# ifdef LinuxArchitecture
+ KBD = xf86KbdLnx
+# else
+ KBD = xf86Kbd
+# endif
+# endif
+#endif
+
+#if UseDeprecatedKeyboardDriver
+KEYBOARD_DEFS = -DUSE_DEPRECATED_KEYBOARD_DRIVER
+#endif
+
+#if defined(SparcArchitecture) || defined(Sparc64Architecture)
+ SBUSSRC = xf86sbusBus.c
+ SBUSOBJ = xf86sbusBus.o
+#endif
+
+#if BuildXKB
+ XKBDDXSRC = xf86XKB.c
+ XKBDDXOBJ = xf86XKB.o
+#endif
+
+#if BuildDebug
+ DEBUGSRC = xf86Debug.c
+ DEBUGOBJ = xf86Debug.o
+#endif
+
+#if BuildXInputExt
+ XF86_XINPUT_SRC = xf86Xinput.c xisb.c
+ XF86_XINPUT_OBJ = xf86Xinput.o xisb.o
+#endif
+
+#if BuildRandR
+ RANDRINCS = -I../../../randr
+ RANDRSRC = xf86RandR.c
+ RANDROBJ = xf86RandR.o
+#endif
+
+MODPATHDEFINES = -DDEFAULT_MODULE_PATH=\"$(MODULEDIR)\"
+LOGDEFINES = -DDEFAULT_LOGPREFIX=\"$(LOGDIRECTORY)/XLogFile.\"
+
+#if DoLoadableServer
+EXT_MODULES_DEFINES = $(GLX_DEFINES)
+#endif
+
+#if UseMemLeak
+MDEBUGDEFS = -DMEMDEBUG
+#endif
+
+#if defined(SunArchitecture) && ((OSMajorVersion == 5) && (OSMinorVersion >= 9))
+BACKTRACE_DEFS = -DHAVE_WALKCONTEXT
+#elif defined(LinuxCLibMajorVersion) && ((LinuxCLibMajorVersion == 6) && (LinuxCLibMinorVersion >= 1))
+BACKTRACE_DEFS = -DHAVE_EXECINFO_H
+#endif
+
+SRCS = \
+ xf86Configure.c \
+ xf86Bus.c \
+ xf86isaBus.c \
+ xf86pciBus.c \
+ xf86fbBus.c \
+ xf86noBus.c \
+ xf86IniExt.c \
+ xf86Config.c \
+ xf86AutoConfig.c \
+ xf86Cursor.c \
+ xf86DGA.c \
+ xf86DPMS.c \
+ xf86DefModeSet.c \
+ xf86DoProbe.c \
+ xf86DoScanPci.c \
+ xf86Events.c \
+ xf86Globals.c \
+ xf86Helper.c \
+ xf86Init.c \
+ xf86Io.c \
+ xf86MiscExt.c \
+ xf86Mode.c \
+ xf86Option.c \
+ xf86VidMode.c \
+ xf86fbman.c \
+ xf86xv.c \
+ xf86xvmc.c \
+ xf86cmap.c\
+ xf86PM.c \
+ xf86Versions.c \
+ xorgHelper.c \
+ $(DEBUGSRC) \
+ $(KBD).c \
+ $(SBUSSRC) \
+ $(XF86_XINPUT_SRC) \
+ $(XINPUT_DEV_SRCS) \
+ $(XKBDDXSRC) \
+ $(SERVERSRCS) \
+ $(RANDRSRC)
+
+OBJS = \
+ xf86Configure.o \
+ xf86Bus.o \
+ xf86isaBus.o \
+ xf86pciBus.o \
+ xf86fbBus.o \
+ xf86noBus.o \
+ xf86Config.o \
+ xf86AutoConfig.o \
+ xf86Cursor.o \
+ xf86DGA.o \
+ xf86DPMS.o \
+ xf86DefModeSet.o \
+ xf86DoProbe.o \
+ xf86DoScanPci.o \
+ xf86Events.o \
+ xf86Globals.o \
+ xf86Helper.o \
+ xf86Io.o \
+ xf86MiscExt.o \
+ xf86Mode.o \
+ xf86Option.o \
+ xf86VidMode.o \
+ xf86fbman.o \
+ xf86xv.o \
+ xf86xvmc.o \
+ xf86cmap.o\
+ xf86PM.o \
+ xf86Versions.o \
+ xorgHelper.o \
+ $(DEBUGOBJ) \
+ $(SBUSOBJ) \
+ $(XF86_XINPUT_OBJ) \
+ $(XKBDDXOBJ) \
+ $(KBD).o \
+ $(RANDROBJ)
+
+OFILES = \
+ xf86Init.o \
+ xf86IniExt.o
+
+ VGAINCLUDES = -I$(XF86SRC)/vgahw
+ INCLUDES = -I. -I$(XF86OSSRC) -I$(XF86OSSRC)/bus -I$(SERVERSRC)/mfb \
+ -I$(SERVERSRC)/mi -I$(SERVERSRC)/include -I$(SERVERSRC)/os \
+ -I$(XINCLUDESRC) -I$(SERVERSRC)/Xext -I$(EXTINCSRC) \
+ -I$(SERVERSRC)/Xi -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \
+ -I$(FONTLIBSRC)/include -I$(FONTINCSRC) \
+ -I$(XF86SRC) -I$(XF86PARSERSRC) \
+ -I$(XF86SRC)/loader $(VGAINCLUDES) -I$(XF86SRC)/rac \
+ -I$(XF86SRC)/scanpci -I$(XF86SRC)/vbe -I$(XF86SRC)/int10 \
+ -I$(XF86SRC)/ddc -I$(SERVERSRC)/render $(RANDRINCS)
+
+ OSNAME = OSName
+ OSVENDOR = OSVendor
+ OSNAMEDEF = -DOSNAME='" $(OSNAME)"' -DOSVENDOR='" $(OSVENDOR)"'
+#if defined(XorgCustomVersion) || defined(XFree86CustomVersion)
+# if defined(XorgCustomVersion)
+CUSTOMVERSION = XorgCustomVersion
+# else
+CUSTOMVERSION = XFree86CustomVersion
+# endif /* XorgCustomVersion */
+ CUSTOMVERDEF = -DXORG_CUSTOM_VERSION='$(CUSTOMVERSION)'
+#endif /* XorgCustomVersion || XFree86CustomVersion */
+#if defined(BuilderString)
+ BUILDERSTRING = BuilderString
+ BUILDERMSG = -DBUILDERSTRING='$(BUILDERSTRING)'
+#endif
+ XORGREL = XOrgReleaseString
+ XORGREL_DEF = -DXORG_RELEASE="\"$(XORGREL)\""
+#if defined(XorgDateString)
+ XORGDATE = XorgDateString
+ XORGDATE_DEF = -DXORG_DATE='$(XORGDATE)'
+#endif
+
+CONSDEFINES = XFree86ConsoleDefines
+EXP_DEFINES = -DEXPIRY_TIME=XorgServerExpiry $(EXP_FORCE_DEFINES)
+ DRIVERS = XF86CardDrivers
+ IDRIVERS = XInputDrivers
+XCONFIGDEFINES = -DPROJECTROOT='"$(PROJECTROOT)"' \
+ -DBINDIR='"$(BINDIR)"' \
+ -DDRIVERS='"$(DRIVERS)"' \
+ -DIDRIVERS='"$(IDRIVERS)"'
+XF86CONFIGFILE = XConfigFile
+XCONFIGUREDEFINES = -DXF86CONFIGFILE='"$(XF86CONFIGFILE)"'
+
+ DEFINES = $(CONSDEFINES) $(KBDDEFINES) $(EXT_DEFINES) $(OS_DEFINES) \
+ $(CONFIG_DEFINES) $(XKBDEFRULESDEFS) $(VENDORSUPPORTDEFS) \
+ $(VENDOR_DEFINES) -DXF86PM
+
+AllTarget($(OFILES))
+
+SpecialCObjectRule(xf86Bus,NullParameter,$(BUGMSG) $(VGAINCLUDES))
+SpecialCObjectRule(xf86Init,$(ICONFIGFILES),$(OSNAMEDEF) $(BUILDERMSG) $(BUGMSG) $(CUSTOMVERDEF) $(XORGREL_DEF) $(XORGDATE_DEF) $(EXT_DEFINES) $(MDEBUGDEFS) $(KEYBOARD_DEFS))
+SpecialCObjectRule(xf86Events,$(ICONFIGFILES),$(EXT_DEFINES) $(MDEBUGDEFS) $(BACKTRACE_DEFS))
+SpecialCObjectRule(xf86Globals,$(ICONFIGFILES),$(EXT_DEFINES) $(MODPATHDEFINES) $(LOGDEFINES))
+SpecialCObjectRule(xf86AutoConfig,$(ICONFIGFILES),$(XCONFIGDEFINES))
+SpecialCObjectRule(xf86Config,$(ICONFIGFILES),$(XCONFIGDEFINES) $(KEYBOARD_DEFS))
+SpecialCObjectRule(xf86Configure,$(ICONFIGFILES),$(XCONFIGUREDEFINES) $(KEYBOARD_DEFS))
+
+SpecialCObjectRule(xf86IniExt,$(ICONFIGFILES),$(EXT_DEFINES) $(EXT_MODULES_DEFINES))
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(xf86,$(OBJS))
+
+LinkFile(xf86IniExt.c,$(SERVERSRC)/mi/miinitext.c)
+LinkSourceFile(xf86Version.h,..)
+LinkSourceFile(xorgVersion.h,..)
+LinkSourceFile(xf86Pci.h,$(XF86OSSRC)/bus)
+#ifdef SparcArchitecture
+LinkSourceFile(xf86Sbus.h,$(XF86OSSRC)/bus)
+#endif
+
+#if HasPerl
+MODEDEFSRCS = ../etc/vesamodes ../etc/extramodes
+
+MODEDEFS = modedefs
+
+$(MODEDEFS): $(MODEDEFSRCS)
+ RemoveFile($@)
+ cat $(MODEDEFSRCS) > $@
+
+includes:: xf86DefModeSet.c
+
+xf86DefModeSet.c: $(MODEDEFS) modeline2c.pl
+ RemoveFile($@)
+ RunPerlScript(modeline2c.pl, < $(MODEDEFS) > $@)
+
+clean::
+ RemoveFile($(MODEDEFS))
+ RemoveFile(xf86DefModeSet.c)
+#else
+LinkFile(xf86DefModeSet.c,xf86DefModes.c)
+#endif
+
+DependTarget()
+
+InstallDriverSDKNonExecFile(compiler.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(fourcc.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86Module.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86Opt.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86Pci.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86PciInfo.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86Priv.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86Privstr.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86Resources.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86Version.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xorgVersion.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86Xinput.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86cmap.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86fbman.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86str.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86xv.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86xvmc.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xisb.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/atKeynames.h b/nx-X11/programs/Xserver/hw/xfree86/common/atKeynames.h
new file mode 100644
index 000000000..d37f5b0f0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/atKeynames.h
@@ -0,0 +1,298 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/atKeynames.h,v 3.21 2003/10/09 11:43:59 pascal Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*
+ * Copyright (c) 1994-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* $XConsortium: atKeynames.h /main/11 1996/03/09 11:17:41 kaleb $ */
+
+#ifndef _ATKEYNAMES_H
+#define _ATKEYNAMES_H
+
+#define XK_TECHNICAL
+#define XK_KATAKANA
+#include <X11/keysym.h>
+#include <X11/XF86keysym.h>
+
+#define GLYPHS_PER_KEY 4
+#define NUM_KEYCODES 248
+#define MIN_KEYCODE 8
+#define MAX_KEYCODE (NUM_KEYCODES + MIN_KEYCODE - 1)
+
+#define AltMask Mod1Mask
+#define NumLockMask Mod2Mask
+#define AltLangMask Mod3Mask
+#define KanaMask Mod4Mask
+#define ScrollLockMask Mod5Mask
+
+#define KeyPressed(k) (keyc->down[k >> 3] & (1 << (k & 7)))
+#define ModifierDown(k) ((keyc->state & (k)) == (k))
+
+/*
+ * NOTE: The AT/MF keyboards can generate (via the 8042) two (MF: three)
+ * sets of scancodes. Set3 can only be generated by a MF keyboard.
+ * Set2 sends a makecode for keypress, and the same code prefixed by a
+ * F0 for keyrelease. This is a little bit ugly to handle. Thus we use
+ * here for X386 the PC/XT compatible Set1. This set uses 8bit scancodes.
+ * Bit 7 ist set if the key is released. The code E0 switches to a
+ * different meaning to add the new MF cursorkeys, while not breaking old
+ * applications. E1 is another special prefix. Since I assume that there
+ * will be further versions of PC/XT scancode compatible keyboards, we
+ * may be in trouble one day.
+ *
+ * IDEA: 1) Use Set2 on AT84 keyboards and translate it to MF Set3.
+ * 2) Use the keyboards native set and translate it to common keysyms.
+ */
+
+/*
+ * definition of the AT84/MF101/MF102 Keyboard:
+ * ============================================================
+ * Defined Key Cap Glyphs Pressed value
+ * Key Name Main Also (hex) (dec)
+ * ---------------- ---------- ------- ------ ------
+ */
+
+#define KEY_Escape /* Escape 0x01 */ 1
+#define KEY_1 /* 1 ! 0x02 */ 2
+#define KEY_2 /* 2 @ 0x03 */ 3
+#define KEY_3 /* 3 # 0x04 */ 4
+#define KEY_4 /* 4 $ 0x05 */ 5
+#define KEY_5 /* 5 % 0x06 */ 6
+#define KEY_6 /* 6 ^ 0x07 */ 7
+#define KEY_7 /* 7 & 0x08 */ 8
+#define KEY_8 /* 8 * 0x09 */ 9
+#define KEY_9 /* 9 ( 0x0a */ 10
+#define KEY_0 /* 0 ) 0x0b */ 11
+#define KEY_Minus /* - (Minus) _ (Under) 0x0c */ 12
+#define KEY_Equal /* = (Equal) + 0x0d */ 13
+#define KEY_BackSpace /* Back Space 0x0e */ 14
+#define KEY_Tab /* Tab 0x0f */ 15
+#define KEY_Q /* Q 0x10 */ 16
+#define KEY_W /* W 0x11 */ 17
+#define KEY_E /* E 0x12 */ 18
+#define KEY_R /* R 0x13 */ 19
+#define KEY_T /* T 0x14 */ 20
+#define KEY_Y /* Y 0x15 */ 21
+#define KEY_U /* U 0x16 */ 22
+#define KEY_I /* I 0x17 */ 23
+#define KEY_O /* O 0x18 */ 24
+#define KEY_P /* P 0x19 */ 25
+#define KEY_LBrace /* [ { 0x1a */ 26
+#define KEY_RBrace /* ] } 0x1b */ 27
+#define KEY_Enter /* Enter 0x1c */ 28
+#define KEY_LCtrl /* Ctrl(left) 0x1d */ 29
+#define KEY_A /* A 0x1e */ 30
+#define KEY_S /* S 0x1f */ 31
+#define KEY_D /* D 0x20 */ 32
+#define KEY_F /* F 0x21 */ 33
+#define KEY_G /* G 0x22 */ 34
+#define KEY_H /* H 0x23 */ 35
+#define KEY_J /* J 0x24 */ 36
+#define KEY_K /* K 0x25 */ 37
+#define KEY_L /* L 0x26 */ 38
+#define KEY_SemiColon /* ;(SemiColon) :(Colon) 0x27 */ 39
+#define KEY_Quote /* ' (Apostr) " (Quote) 0x28 */ 40
+#define KEY_Tilde /* ` (Accent) ~ (Tilde) 0x29 */ 41
+#define KEY_ShiftL /* Shift(left) 0x2a */ 42
+#define KEY_BSlash /* \(BckSlash) |(VertBar)0x2b */ 43
+#define KEY_Z /* Z 0x2c */ 44
+#define KEY_X /* X 0x2d */ 45
+#define KEY_C /* C 0x2e */ 46
+#define KEY_V /* V 0x2f */ 47
+#define KEY_B /* B 0x30 */ 48
+#define KEY_N /* N 0x31 */ 49
+#define KEY_M /* M 0x32 */ 50
+#define KEY_Comma /* , (Comma) < (Less) 0x33 */ 51
+#define KEY_Period /* . (Period) >(Greater)0x34 */ 52
+#define KEY_Slash /* / (Slash) ? 0x35 */ 53
+#define KEY_ShiftR /* Shift(right) 0x36 */ 54
+#define KEY_KP_Multiply /* * 0x37 */ 55
+#define KEY_Alt /* Alt(left) 0x38 */ 56
+#define KEY_Space /* (SpaceBar) 0x39 */ 57
+#define KEY_CapsLock /* CapsLock 0x3a */ 58
+#define KEY_F1 /* F1 0x3b */ 59
+#define KEY_F2 /* F2 0x3c */ 60
+#define KEY_F3 /* F3 0x3d */ 61
+#define KEY_F4 /* F4 0x3e */ 62
+#define KEY_F5 /* F5 0x3f */ 63
+#define KEY_F6 /* F6 0x40 */ 64
+#define KEY_F7 /* F7 0x41 */ 65
+#define KEY_F8 /* F8 0x42 */ 66
+#define KEY_F9 /* F9 0x43 */ 67
+#define KEY_F10 /* F10 0x44 */ 68
+#define KEY_NumLock /* NumLock 0x45 */ 69
+#define KEY_ScrollLock /* ScrollLock 0x46 */ 70
+#define KEY_KP_7 /* 7 Home 0x47 */ 71
+#define KEY_KP_8 /* 8 Up 0x48 */ 72
+#define KEY_KP_9 /* 9 PgUp 0x49 */ 73
+#define KEY_KP_Minus /* - (Minus) 0x4a */ 74
+#define KEY_KP_4 /* 4 Left 0x4b */ 75
+#define KEY_KP_5 /* 5 0x4c */ 76
+#define KEY_KP_6 /* 6 Right 0x4d */ 77
+#define KEY_KP_Plus /* + (Plus) 0x4e */ 78
+#define KEY_KP_1 /* 1 End 0x4f */ 79
+#define KEY_KP_2 /* 2 Down 0x50 */ 80
+#define KEY_KP_3 /* 3 PgDown 0x51 */ 81
+#define KEY_KP_0 /* 0 Insert 0x52 */ 82
+#define KEY_KP_Decimal /* . (Decimal) Delete 0x53 */ 83
+#define KEY_SysReqest /* SysReqest 0x54 */ 84
+ /* NOTUSED 0x55 */
+#define KEY_Less /* < (Less) >(Greater) 0x56 */ 86
+#define KEY_F11 /* F11 0x57 */ 87
+#define KEY_F12 /* F12 0x58 */ 88
+
+#define KEY_Prefix0 /* special 0x60 */ 96
+#define KEY_Prefix1 /* specail 0x61 */ 97
+
+/*
+ * The 'scancodes' below are generated by the server, because the MF101/102
+ * keyboard sends them as sequence of other scancodes
+ */
+#define KEY_Home /* Home 0x59 */ 89
+#define KEY_Up /* Up 0x5a */ 90
+#define KEY_PgUp /* PgUp 0x5b */ 91
+#define KEY_Left /* Left 0x5c */ 92
+#define KEY_Begin /* Begin 0x5d */ 93
+#define KEY_Right /* Right 0x5e */ 94
+#define KEY_End /* End 0x5f */ 95
+#define KEY_Down /* Down 0x60 */ 96
+#define KEY_PgDown /* PgDown 0x61 */ 97
+#define KEY_Insert /* Insert 0x62 */ 98
+#define KEY_Delete /* Delete 0x63 */ 99
+#define KEY_KP_Enter /* Enter 0x64 */ 100
+#define KEY_RCtrl /* Ctrl(right) 0x65 */ 101
+#define KEY_Pause /* Pause 0x66 */ 102
+#define KEY_Print /* Print 0x67 */ 103
+#define KEY_KP_Divide /* Divide 0x68 */ 104
+#define KEY_AltLang /* AtlLang(right) 0x69 */ 105
+#define KEY_Break /* Break 0x6a */ 106
+#define KEY_LMeta /* Left Meta 0x6b */ 107
+#define KEY_RMeta /* Right Meta 0x6c */ 108
+#define KEY_Menu /* Menu 0x6d */ 109
+#define KEY_F13 /* F13 0x6e */ 110
+#define KEY_F14 /* F14 0x6f */ 111
+#define KEY_F15 /* F15 0x70 */ 112
+#define KEY_HKTG /* Hirugana/Katakana tog 0x70 */ 112
+#define KEY_F16 /* F16 0x71 */ 113
+#define KEY_F17 /* F17 0x72 */ 114
+#define KEY_KP_DEC /* KP_DEC 0x73 */ 115
+#define KEY_BSlash2 /* \ _ 0x73 */ 115
+#define KEY_KP_Equal /* Equal (Keypad) 0x76 */ 118
+#define KEY_XFER /* Kanji Transfer 0x79 */ 121
+#define KEY_NFER /* No Kanji Transfer 0x7b */ 123
+#define KEY_Yen /* Yen 0x7d */ 125
+
+#define KEY_Power /* Power Key 0x84 */ 132
+#define KEY_Mute /* Audio Mute 0x85 */ 133
+#define KEY_AudioLower /* Audio Lower 0x86 */ 134
+#define KEY_AudioRaise /* Audio Raise 0x87 */ 135
+#define KEY_Help /* Help 0x88 */ 136
+#define KEY_L1 /* Stop 0x89 */ 137
+#define KEY_L2 /* Again 0x8a */ 138
+#define KEY_L3 /* Props 0x8b */ 139
+#define KEY_L4 /* Undo 0x8c */ 140
+#define KEY_L5 /* Front 0x8d */ 141
+#define KEY_L6 /* Copy 0x8e */ 142
+#define KEY_L7 /* Open 0x8f */ 143
+#define KEY_L8 /* Paste 0x90 */ 144
+#define KEY_L9 /* Find 0x91 */ 145
+#define KEY_L10 /* Cut 0x92 */ 146
+
+/*
+ * Fake 'scancodes' in the following ranges are generated for 2-byte
+ * codes not handled elsewhere. These correspond to most extended keys
+ * on so-called "Internet" keyboards:
+ *
+ * 0x79-0x93
+ * 0x96-0xa1
+ * 0xa3-0xac
+ * 0xb1-0xb4
+ * 0xba-0xbd
+ * 0xc2
+ * 0xcc-0xd2
+ * 0xd6-0xf7
+ */
+
+/*
+ * Remapped 'scancodes' are generated for single-byte codes in the range
+ * 0x59-0x5f,0x62-0x76. These are used for some extra keys on some keyboards.
+ */
+
+#define KEY_0x59 0x95
+#define KEY_0x5A 0xA2
+#define KEY_0x5B 0xAD
+#define KEY_0x5C KEY_KP_EQUAL
+#define KEY_0x5D 0xAE
+#define KEY_0x5E 0xAF
+#define KEY_0x5F 0xB0
+#define KEY_0x62 0xB5
+#define KEY_0x63 0xB6
+#define KEY_0x64 0xB7
+#define KEY_0x65 0xB8
+#define KEY_0x66 0xB9
+#define KEY_0x67 0xBE
+#define KEY_0x68 0xBF
+#define KEY_0x69 0xC0
+#define KEY_0x6A 0xC1
+#define KEY_0x6B 0xC3
+#define KEY_0x6C 0xC4
+#define KEY_0x6D 0xC5
+#define KEY_0x6E 0xC6
+#define KEY_0x6F 0xC7
+#define KEY_0x70 0xC8
+#define KEY_0x71 0xC9
+#define KEY_0x72 0xCA
+#define KEY_0x73 0xCB
+#define KEY_0x74 0xD3
+#define KEY_0x75 0xD4
+#define KEY_0x76 0xD5
+
+/* These are for "notused" and "unknown" entries in translation maps. */
+#define KEY_NOTUSED 0
+#define KEY_UNKNOWN 255
+
+#endif /* _ATKEYNAMES_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/compiler.h b/nx-X11/programs/Xserver/hw/xfree86/common/compiler.h
new file mode 100644
index 000000000..d323f677b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/compiler.h
@@ -0,0 +1,1863 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.106 2004/02/02 03:55:28 dawes Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*
+ * Copyright (c) 1994-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* $XConsortium: compiler.h /main/16 1996/10/25 15:38:34 kaleb $ */
+
+#ifndef _COMPILER_H
+
+# if !defined(_XF86_ANSIC_H) && defined(XFree86Module)
+# error missing #include "xf86_ansic.h" before #include "compiler.h"
+# endif
+
+# define _COMPILER_H
+
+#if defined(__SUNPRO_C)
+# define DO_PROTOTYPES
+#endif
+
+/* Allow drivers to use the GCC-supported __inline__ and/or __inline. */
+# ifndef __inline__
+# if defined(__GNUC__)
+ /* gcc has __inline__ */
+# elif defined(__HIGHC__)
+# define __inline__ _Inline
+# else
+# define __inline__ /**/
+# endif
+# endif /* __inline__ */
+# ifndef __inline
+# if defined(__GNUC__)
+ /* gcc has __inline */
+# elif defined(__HIGHC__)
+# define __inline _Inline
+# else
+# define __inline /**/
+# endif
+# endif /* __inline */
+
+# if defined(IODEBUG) && defined(__GNUC__)
+# define outb RealOutb
+# define outw RealOutw
+# define outl RealOutl
+# define inb RealInb
+# define inw RealInw
+# define inl RealInl
+# endif
+
+# if defined(QNX4) /* Do this for now to keep Watcom happy */
+# define outb outp
+# define outw outpw
+# define outl outpd
+# define inb inp
+# define inw inpw
+# define inl inpd
+
+/* Define the ffs function for inlining */
+extern int ffs(unsigned long);
+# pragma aux ffs_ = \
+ "bsf edx, eax" \
+ "jnz bits_set" \
+ "xor eax, eax" \
+ "jmp exit1" \
+ "bits_set:" \
+ "mov eax, edx" \
+ "inc eax" \
+ "exit1:" \
+ __parm [eax] \
+ __modify [eax edx] \
+ __value [eax] \
+ ;
+# endif
+
+# if defined(__SUNPRO_C)
+# define DO_PROTOTYPES
+# endif
+
+# if defined(NO_INLINE) || defined(DO_PROTOTYPES)
+
+# if !defined(__arm__)
+# if !defined(__sparc__) && !defined(__arm32__) \
+ && !(defined(__alpha__) && defined(linux)) \
+ && !(defined(__ia64__) && defined(linux)) \
+
+extern void outb(unsigned short, unsigned char);
+extern void outw(unsigned short, unsigned short);
+extern void outl(unsigned short, unsigned int);
+extern unsigned int inb(unsigned short);
+extern unsigned int inw(unsigned short);
+extern unsigned int inl(unsigned short);
+
+# else /* __sparc__, __arm32__, __alpha__*/
+
+extern void outb(unsigned long, unsigned char);
+extern void outw(unsigned long, unsigned short);
+extern void outl(unsigned long, unsigned int);
+extern unsigned int inb(unsigned long);
+extern unsigned int inw(unsigned long);
+extern unsigned int inl(unsigned long);
+
+# endif /* __sparc__, __arm32__, __alpha__ */
+# endif /* __arm__ */
+
+extern unsigned long ldq_u(unsigned long *);
+extern unsigned long ldl_u(unsigned int *);
+extern unsigned long ldw_u(unsigned short *);
+extern void stq_u(unsigned long, unsigned long *);
+extern void stl_u(unsigned long, unsigned int *);
+extern void stw_u(unsigned long, unsigned short *);
+extern void mem_barrier(void);
+extern void write_mem_barrier(void);
+extern void stl_brx(unsigned long, volatile unsigned char *, int);
+extern void stw_brx(unsigned short, volatile unsigned char *, int);
+extern unsigned long ldl_brx(volatile unsigned char *, int);
+extern unsigned short ldw_brx(volatile unsigned char *, int);
+
+# endif
+
+# ifndef NO_INLINE
+# ifdef __GNUC__
+# if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__))
+
+# ifdef linux
+/* for Linux on Alpha, we use the LIBC _inx/_outx routines */
+/* note that the appropriate setup via "ioperm" needs to be done */
+/* *before* any inx/outx is done. */
+
+extern void (*_alpha_outb)(char val, unsigned long port);
+static __inline__ void
+outb(unsigned long port, unsigned char val)
+{
+ _alpha_outb(val, port);
+}
+
+extern void (*_alpha_outw)(short val, unsigned long port);
+static __inline__ void
+outw(unsigned long port, unsigned short val)
+{
+ _alpha_outw(val, port);
+}
+
+extern void (*_alpha_outl)(int val, unsigned long port);
+static __inline__ void
+outl(unsigned long port, unsigned int val)
+{
+ _alpha_outl(val, port);
+}
+
+extern unsigned int (*_alpha_inb)(unsigned long port);
+static __inline__ unsigned int
+inb(unsigned long port)
+{
+ return _alpha_inb(port);
+}
+
+extern unsigned int (*_alpha_inw)(unsigned long port);
+static __inline__ unsigned int
+inw(unsigned long port)
+{
+ return _alpha_inw(port);
+}
+
+extern unsigned int (*_alpha_inl)(unsigned long port);
+static __inline__ unsigned int
+inl(unsigned long port)
+{
+ return _alpha_inl(port);
+}
+
+# endif /* linux */
+
+# if (defined(__FreeBSD__) || defined(__OpenBSD__)) \
+ && !defined(DO_PROTOTYPES)
+
+/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */
+/* inx/outx routines */
+/* note that the appropriate setup via "ioperm" needs to be done */
+/* *before* any inx/outx is done. */
+
+extern void outb(unsigned int port, unsigned char val);
+extern void outw(unsigned int port, unsigned short val);
+extern void outl(unsigned int port, unsigned int val);
+extern unsigned char inb(unsigned int port);
+extern unsigned short inw(unsigned int port);
+extern unsigned int inl(unsigned int port);
+
+# endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
+
+
+#if defined(__NetBSD__)
+#include <machine/pio.h>
+#endif /* __NetBSD__ */
+
+/*
+ * inline functions to do unaligned accesses
+ * from linux/include/asm-alpha/unaligned.h
+ */
+
+/*
+ * EGCS 1.1 knows about arbitrary unaligned loads. Define some
+ * packed structures to talk about such things with.
+ */
+
+struct __una_u64 { unsigned long x __attribute__((packed)); };
+struct __una_u32 { unsigned int x __attribute__((packed)); };
+struct __una_u16 { unsigned short x __attribute__((packed)); };
+
+/*
+ * Elemental unaligned loads
+ */
+/* let's try making these things static */
+
+static __inline__ unsigned long ldq_u(unsigned long * r11)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ const struct __una_u64 *ptr = (const struct __una_u64 *) r11;
+ return ptr->x;
+# else
+ unsigned long r1,r2;
+ __asm__("ldq_u %0,%3\n\t"
+ "ldq_u %1,%4\n\t"
+ "extql %0,%2,%0\n\t"
+ "extqh %1,%2,%1"
+ :"=&r" (r1), "=&r" (r2)
+ :"r" (r11),
+ "m" (*r11),
+ "m" (*(const unsigned long *)(7+(char *) r11)));
+ return r1 | r2;
+# endif
+}
+
+static __inline__ unsigned long ldl_u(unsigned int * r11)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ const struct __una_u32 *ptr = (const struct __una_u32 *) r11;
+ return ptr->x;
+# else
+ unsigned long r1,r2;
+ __asm__("ldq_u %0,%3\n\t"
+ "ldq_u %1,%4\n\t"
+ "extll %0,%2,%0\n\t"
+ "extlh %1,%2,%1"
+ :"=&r" (r1), "=&r" (r2)
+ :"r" (r11),
+ "m" (*r11),
+ "m" (*(const unsigned long *)(3+(char *) r11)));
+ return r1 | r2;
+# endif
+}
+
+static __inline__ unsigned long ldw_u(unsigned short * r11)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ const struct __una_u16 *ptr = (const struct __una_u16 *) r11;
+ return ptr->x;
+# else
+ unsigned long r1,r2;
+ __asm__("ldq_u %0,%3\n\t"
+ "ldq_u %1,%4\n\t"
+ "extwl %0,%2,%0\n\t"
+ "extwh %1,%2,%1"
+ :"=&r" (r1), "=&r" (r2)
+ :"r" (r11),
+ "m" (*r11),
+ "m" (*(const unsigned long *)(1+(char *) r11)));
+ return r1 | r2;
+# endif
+}
+
+/*
+ * Elemental unaligned stores
+ */
+
+static __inline__ void stq_u(unsigned long r5, unsigned long * r11)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ struct __una_u64 *ptr = (struct __una_u64 *) r11;
+ ptr->x = r5;
+# else
+ unsigned long r1,r2,r3,r4;
+
+ __asm__("ldq_u %3,%1\n\t"
+ "ldq_u %2,%0\n\t"
+ "insqh %6,%7,%5\n\t"
+ "insql %6,%7,%4\n\t"
+ "mskqh %3,%7,%3\n\t"
+ "mskql %2,%7,%2\n\t"
+ "bis %3,%5,%3\n\t"
+ "bis %2,%4,%2\n\t"
+ "stq_u %3,%1\n\t"
+ "stq_u %2,%0"
+ :"=m" (*r11),
+ "=m" (*(unsigned long *)(7+(char *) r11)),
+ "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
+ :"r" (r5), "r" (r11));
+# endif
+}
+
+static __inline__ void stl_u(unsigned long r5, unsigned int * r11)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ struct __una_u32 *ptr = (struct __una_u32 *) r11;
+ ptr->x = r5;
+# else
+ unsigned long r1,r2,r3,r4;
+
+ __asm__("ldq_u %3,%1\n\t"
+ "ldq_u %2,%0\n\t"
+ "inslh %6,%7,%5\n\t"
+ "insll %6,%7,%4\n\t"
+ "msklh %3,%7,%3\n\t"
+ "mskll %2,%7,%2\n\t"
+ "bis %3,%5,%3\n\t"
+ "bis %2,%4,%2\n\t"
+ "stq_u %3,%1\n\t"
+ "stq_u %2,%0"
+ :"=m" (*r11),
+ "=m" (*(unsigned long *)(3+(char *) r11)),
+ "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
+ :"r" (r5), "r" (r11));
+# endif
+}
+
+static __inline__ void stw_u(unsigned long r5, unsigned short * r11)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ struct __una_u16 *ptr = (struct __una_u16 *) r11;
+ ptr->x = r5;
+# else
+ unsigned long r1,r2,r3,r4;
+
+ __asm__("ldq_u %3,%1\n\t"
+ "ldq_u %2,%0\n\t"
+ "inswh %6,%7,%5\n\t"
+ "inswl %6,%7,%4\n\t"
+ "mskwh %3,%7,%3\n\t"
+ "mskwl %2,%7,%2\n\t"
+ "bis %3,%5,%3\n\t"
+ "bis %2,%4,%2\n\t"
+ "stq_u %3,%1\n\t"
+ "stq_u %2,%0"
+ :"=m" (*r11),
+ "=m" (*(unsigned long *)(1+(char *) r11)),
+ "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
+ :"r" (r5), "r" (r11));
+# endif
+}
+
+/* to flush the I-cache before jumping to code which just got loaded */
+# define PAL_imb 134
+# define istream_mem_barrier() \
+ __asm__ __volatile__("call_pal %0 #imb" : : "i" (PAL_imb) : "memory")
+# define mem_barrier() __asm__ __volatile__("mb" : : : "memory")
+# ifdef __ELF__
+# define write_mem_barrier() __asm__ __volatile__("wmb" : : : "memory")
+# else /* ECOFF gas 2.6 doesn't know "wmb" :-( */
+# define write_mem_barrier() mem_barrier()
+# endif
+
+
+# elif defined(linux) && defined(__ia64__)
+
+# include <inttypes.h>
+
+# include <sys/io.h>
+
+struct __una_u64 { uint64_t x __attribute__((packed)); };
+struct __una_u32 { uint32_t x __attribute__((packed)); };
+struct __una_u16 { uint16_t x __attribute__((packed)); };
+
+static __inline__ unsigned long
+__uldq (const unsigned long * r11)
+{
+ const struct __una_u64 *ptr = (const struct __una_u64 *) r11;
+ return ptr->x;
+}
+
+static __inline__ unsigned long
+__uldl (const unsigned int * r11)
+{
+ const struct __una_u32 *ptr = (const struct __una_u32 *) r11;
+ return ptr->x;
+}
+
+static __inline__ unsigned long
+__uldw (const unsigned short * r11)
+{
+ const struct __una_u16 *ptr = (const struct __una_u16 *) r11;
+ return ptr->x;
+}
+
+static __inline__ void
+__ustq (unsigned long r5, unsigned long * r11)
+{
+ struct __una_u64 *ptr = (struct __una_u64 *) r11;
+ ptr->x = r5;
+}
+
+static __inline__ void
+__ustl (unsigned long r5, unsigned int * r11)
+{
+ struct __una_u32 *ptr = (struct __una_u32 *) r11;
+ ptr->x = r5;
+}
+
+static __inline__ void
+__ustw (unsigned long r5, unsigned short * r11)
+{
+ struct __una_u16 *ptr = (struct __una_u16 *) r11;
+ ptr->x = r5;
+}
+
+# define ldq_u(p) __uldq(p)
+# define ldl_u(p) __uldl(p)
+# define ldw_u(p) __uldw(p)
+# define stq_u(v,p) __ustq(v,p)
+# define stl_u(v,p) __ustl(v,p)
+# define stw_u(v,p) __ustw(v,p)
+
+# ifndef __INTEL_COMPILER
+# define mem_barrier() __asm__ __volatile__ ("mf" ::: "memory")
+# define write_mem_barrier() __asm__ __volatile__ ("mf" ::: "memory")
+# else
+# include "ia64intrin.h"
+# define mem_barrier() __mf()
+# define write_mem_barrier() __mf()
+# endif
+
+/*
+ * This is overkill, but for different reasons depending on where it is used.
+ * This is thus general enough to be used everywhere cache flushes are needed.
+ * It doesn't handle memory access serialisation by other processors, though.
+ */
+# ifndef __INTEL_COMPILER
+# define ia64_flush_cache(Addr) \
+ __asm__ __volatile__ ( \
+ "fc.i %0;;;" \
+ "sync.i;;;" \
+ "mf;;;" \
+ "srlz.i;;;" \
+ :: "r"(Addr) : "memory")
+# else
+# define ia64_flush_cache(Addr) { \
+ __fc(Addr);\
+ __synci();\
+ __mf();\
+ __isrlz();\
+ }
+# endif
+# undef outb
+# undef outw
+# undef outl
+# undef inb
+# undef inw
+# undef inl
+extern void outb(unsigned long port, unsigned char val);
+extern void outw(unsigned long port, unsigned short val);
+extern void outl(unsigned long port, unsigned int val);
+extern unsigned int inb(unsigned long port);
+extern unsigned int inw(unsigned long port);
+extern unsigned int inl(unsigned long port);
+
+# elif defined(linux) && defined(__amd64__)
+
+# include <inttypes.h>
+
+# define ldq_u(p) (*((unsigned long *)(p)))
+# define ldl_u(p) (*((unsigned int *)(p)))
+# define ldw_u(p) (*((unsigned short *)(p)))
+# define stq_u(v,p) (*(unsigned long *)(p)) = (v)
+# define stl_u(v,p) (*(unsigned int *)(p)) = (v)
+# define stw_u(v,p) (*(unsigned short *)(p)) = (v)
+
+# define mem_barrier() \
+ __asm__ __volatile__ ("lock; addl $0,0(%%rsp)": : :"memory")
+# define write_mem_barrier() \
+ __asm__ __volatile__ ("": : :"memory")
+
+
+static __inline__ void
+outb(unsigned short port, unsigned char val)
+{
+ __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
+}
+
+
+static __inline__ void
+outw(unsigned short port, unsigned short val)
+{
+ __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
+}
+
+static __inline__ void
+outl(unsigned short port, unsigned int val)
+{
+ __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
+}
+
+static __inline__ unsigned int
+inb(unsigned short port)
+{
+ unsigned char ret;
+ __asm__ __volatile__("inb %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inw(unsigned short port)
+{
+ unsigned short ret;
+ __asm__ __volatile__("inw %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("inl %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+# elif (defined(linux) || defined(Lynx) || defined(sun) || defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc__)
+
+# if !defined(Lynx)
+# ifndef ASI_PL
+# define ASI_PL 0x88
+# endif
+
+# define barrier() __asm__ __volatile__(".word 0x8143e00a": : :"memory")
+
+static __inline__ void
+outb(unsigned long port, unsigned char val)
+{
+ __asm__ __volatile__("stba %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (port), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+outw(unsigned long port, unsigned short val)
+{
+ __asm__ __volatile__("stha %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (port), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+outl(unsigned long port, unsigned int val)
+{
+ __asm__ __volatile__("sta %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (port), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ unsigned int
+inb(unsigned long port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("lduba [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (port), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned int
+inw(unsigned long port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("lduha [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (port), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned int
+inl(unsigned long port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("lda [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (port), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned char
+xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned char ret;
+
+ __asm__ __volatile__("lduba [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (addr), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned short
+xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned short ret;
+
+ __asm__ __volatile__("lduh [%1], %0"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+static __inline__ unsigned short
+xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned short ret;
+
+ __asm__ __volatile__("lduha [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (addr), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned int
+xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned int ret;
+
+ __asm__ __volatile__("ld [%1], %0"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+static __inline__ unsigned int
+xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned int ret;
+
+ __asm__ __volatile__("lda [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (addr), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ void
+xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("stba %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sth %0, [%1]"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("stha %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("st %0, [%1]"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sta %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("stba %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+}
+
+static __inline__ void
+xf86WriteMmio16BeNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sth %0, [%1]"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+
+static __inline__ void
+xf86WriteMmio16LeNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("stha %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+}
+
+static __inline__ void
+xf86WriteMmio32BeNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("st %0, [%1]"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+
+static __inline__ void
+xf86WriteMmio32LeNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sta %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+}
+
+# endif /* !Lynx */
+
+/*
+ * EGCS 1.1 knows about arbitrary unaligned loads. Define some
+ * packed structures to talk about such things with.
+ */
+
+# if defined(__arch64__) || defined(__sparcv9)
+struct __una_u64 { unsigned long x __attribute__((packed)); };
+# endif
+struct __una_u32 { unsigned int x __attribute__((packed)); };
+struct __una_u16 { unsigned short x __attribute__((packed)); };
+
+static __inline__ unsigned long ldq_u(unsigned long *p)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+# if defined(__arch64__) || defined(__sparcv9)
+ const struct __una_u64 *ptr = (const struct __una_u64 *) p;
+# else
+ const struct __una_u32 *ptr = (const struct __una_u32 *) p;
+# endif
+ return ptr->x;
+# else
+ unsigned long ret;
+ memmove(&ret, p, sizeof(*p));
+ return ret;
+# endif
+}
+
+static __inline__ unsigned long ldl_u(unsigned int *p)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ const struct __una_u32 *ptr = (const struct __una_u32 *) p;
+ return ptr->x;
+# else
+ unsigned int ret;
+ memmove(&ret, p, sizeof(*p));
+ return ret;
+# endif
+}
+
+static __inline__ unsigned long ldw_u(unsigned short *p)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ const struct __una_u16 *ptr = (const struct __una_u16 *) p;
+ return ptr->x;
+# else
+ unsigned short ret;
+ memmove(&ret, p, sizeof(*p));
+ return ret;
+# endif
+}
+
+static __inline__ void stq_u(unsigned long val, unsigned long *p)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+# if defined(__arch64__) || defined(__sparcv9)
+ struct __una_u64 *ptr = (struct __una_u64 *) p;
+# else
+ struct __una_u32 *ptr = (struct __una_u32 *) p;
+# endif
+ ptr->x = val;
+# else
+ unsigned long tmp = val;
+ memmove(p, &tmp, sizeof(*p));
+# endif
+}
+
+static __inline__ void stl_u(unsigned long val, unsigned int *p)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ struct __una_u32 *ptr = (struct __una_u32 *) p;
+ ptr->x = val;
+# else
+ unsigned int tmp = val;
+ memmove(p, &tmp, sizeof(*p));
+# endif
+}
+
+static __inline__ void stw_u(unsigned long val, unsigned short *p)
+{
+# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+ struct __una_u16 *ptr = (struct __una_u16 *) p;
+ ptr->x = val;
+# else
+ unsigned short tmp = val;
+ memmove(p, &tmp, sizeof(*p));
+# endif
+}
+
+# define mem_barrier() /* XXX: nop for now */
+# define write_mem_barrier() /* XXX: nop for now */
+
+# elif defined(__mips__) || (defined(__arm32__) && !defined(__linux__))
+# ifdef __arm32__
+# define PORT_SIZE long
+# else
+# define PORT_SIZE short
+# endif
+
+unsigned int IOPortBase; /* Memory mapped I/O port area */
+
+static __inline__ void
+outb(unsigned PORT_SIZE port, unsigned char val)
+{
+ *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
+}
+
+static __inline__ void
+outw(unsigned PORT_SIZE port, unsigned short val)
+{
+ *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
+}
+
+static __inline__ void
+outl(unsigned PORT_SIZE port, unsigned int val)
+{
+ *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
+}
+
+static __inline__ unsigned int
+inb(unsigned PORT_SIZE port)
+{
+ return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase);
+}
+
+static __inline__ unsigned int
+inw(unsigned PORT_SIZE port)
+{
+ return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase);
+}
+
+static __inline__ unsigned int
+inl(unsigned PORT_SIZE port)
+{
+ return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase);
+}
+
+
+# if defined(__mips__)
+static __inline__ unsigned long ldq_u(unsigned long * r11)
+{
+ unsigned long r1;
+ __asm__("lwr %0,%2\n\t"
+ "lwl %0,%3\n\t"
+ :"=&r" (r1)
+ :"r" (r11),
+ "m" (*r11),
+ "m" (*(unsigned long *)(3+(char *) r11)));
+ return r1;
+}
+
+static __inline__ unsigned long ldl_u(unsigned int * r11)
+{
+ unsigned long r1;
+ __asm__("lwr %0,%2\n\t"
+ "lwl %0,%3\n\t"
+ :"=&r" (r1)
+ :"r" (r11),
+ "m" (*r11),
+ "m" (*(unsigned long *)(3+(char *) r11)));
+ return r1;
+}
+
+static __inline__ unsigned long ldw_u(unsigned short * r11)
+{
+ unsigned long r1;
+ __asm__("lwr %0,%2\n\t"
+ "lwl %0,%3\n\t"
+ :"=&r" (r1)
+ :"r" (r11),
+ "m" (*r11),
+ "m" (*(unsigned long *)(1+(char *) r11)));
+ return r1;
+}
+
+# ifdef linux /* don't mess with other OSs */
+
+/*
+ * EGCS 1.1 knows about arbitrary unaligned loads (and we don't support older
+ * versions anyway. Define some packed structures to talk about such things
+ * with.
+ */
+
+struct __una_u32 { unsigned int x __attribute__((packed)); };
+struct __una_u16 { unsigned short x __attribute__((packed)); };
+
+static __inline__ void stw_u(unsigned long val, unsigned short *p)
+{
+ struct __una_u16 *ptr = (struct __una_u16 *) p;
+ ptr->x = val;
+}
+
+static __inline__ void stl_u(unsigned long val, unsigned int *p)
+{
+ struct __una_u32 *ptr = (struct __una_u32 *) p;
+ ptr->x = val;
+}
+
+# if X_BYTE_ORDER == X_BIG_ENDIAN
+static __inline__ unsigned int
+xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned int ret;
+
+ __asm__ __volatile__("lw %0, 0(%1)"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+static __inline__ void
+xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sw %0, 0(%1)"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+# endif
+
+# define mem_barrier() \
+ __asm__ __volatile__( \
+ "# prevent instructions being moved around\n\t" \
+ ".set\tnoreorder\n\t" \
+ "# 8 nops to fool the R4400 pipeline\n\t" \
+ "nop;nop;nop;nop;nop;nop;nop;nop\n\t" \
+ ".set\treorder" \
+ : /* no output */ \
+ : /* no input */ \
+ : "memory")
+# define write_mem_barrier() mem_barrier()
+
+# else /* !linux */
+
+# define stq_u(v,p) stl_u(v,p)
+# define stl_u(v,p) (*(unsigned char *)(p)) = (v); \
+ (*(unsigned char *)(p)+1) = ((v) >> 8); \
+ (*(unsigned char *)(p)+2) = ((v) >> 16); \
+ (*(unsigned char *)(p)+3) = ((v) >> 24)
+
+# define stw_u(v,p) (*(unsigned char *)(p)) = (v); \
+ (*(unsigned char *)(p)+1) = ((v) >> 8)
+
+# define mem_barrier() /* NOP */
+# endif /* !linux */
+# endif /* __mips__ */
+
+# if defined(__arm32__)
+# define ldq_u(p) (*((unsigned long *)(p)))
+# define ldl_u(p) (*((unsigned int *)(p)))
+# define ldw_u(p) (*((unsigned short *)(p)))
+# define stq_u(v,p) (*(unsigned long *)(p)) = (v)
+# define stl_u(v,p) (*(unsigned int *)(p)) = (v)
+# define stw_u(v,p) (*(unsigned short *)(p)) = (v)
+# define mem_barrier() /* NOP */
+# define write_mem_barrier() /* NOP */
+# endif /* __arm32__ */
+
+# elif (defined(Lynx) || defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)) && defined(__powerpc__)
+
+# ifndef MAP_FAILED
+# define MAP_FAILED ((void *)-1)
+# endif
+
+extern volatile unsigned char *ioBase;
+
+#if defined(linux) && defined(__powerpc64__)
+# include <asm/memory.h>
+#endif /* defined(linux) && defined(__powerpc64__) */
+#ifndef eieio /* We deal with arch-specific eieio() routines above... */
+# define eieio() __asm__ __volatile__ ("eieio" ::: "memory")
+#endif /* eieio */
+
+static __inline__ unsigned char
+xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned char val;
+ __asm__ __volatile__(
+ "lbzx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+static __inline__ unsigned short
+xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned short val;
+ __asm__ __volatile__(
+ "lhzx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+static __inline__ unsigned short
+xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned short val;
+ __asm__ __volatile__(
+ "lhbrx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+static __inline__ unsigned int
+xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned int val;
+ __asm__ __volatile__(
+ "lwzx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+static __inline__ unsigned int
+xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned int val;
+ __asm__ __volatile__(
+ "lwbrx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+static __inline__ void
+xf86WriteMmioNB8(__volatile__ void *base, const unsigned long offset,
+ const unsigned char val)
+{
+ __asm__ __volatile__(
+ "stbx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ void
+xf86WriteMmioNB16Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
+{
+ __asm__ __volatile__(
+ "sthbrx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ void
+xf86WriteMmioNB16Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
+{
+ __asm__ __volatile__(
+ "sthx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ void
+xf86WriteMmioNB32Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ __asm__ __volatile__(
+ "stwbrx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ void
+xf86WriteMmioNB32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ __asm__ __volatile__(
+ "stwx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ void
+xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
+ const unsigned char val)
+{
+ xf86WriteMmioNB8(base, offset, val);
+ eieio();
+}
+
+static __inline__ void
+xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
+{
+ xf86WriteMmioNB16Le(base, offset, val);
+ eieio();
+}
+
+static __inline__ void
+xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
+{
+ xf86WriteMmioNB16Be(base, offset, val);
+ eieio();
+}
+
+static __inline__ void
+xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ xf86WriteMmioNB32Le(base, offset, val);
+ eieio();
+}
+
+static __inline__ void
+xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ xf86WriteMmioNB32Be(base, offset, val);
+ eieio();
+}
+
+
+static __inline__ void
+outb(unsigned short port, unsigned char value)
+{
+ if(ioBase == MAP_FAILED) return;
+ xf86WriteMmio8((void *)ioBase, port, value);
+}
+
+static __inline__ void
+outw(unsigned short port, unsigned short value)
+{
+ if(ioBase == MAP_FAILED) return;
+ xf86WriteMmio16Le((void *)ioBase, port, value);
+}
+
+static __inline__ void
+outl(unsigned short port, unsigned int value)
+{
+ if(ioBase == MAP_FAILED) return;
+ xf86WriteMmio32Le((void *)ioBase, port, value);
+}
+
+static __inline__ unsigned int
+inb(unsigned short port)
+{
+ if(ioBase == MAP_FAILED) return 0;
+ return xf86ReadMmio8((void *)ioBase, port);
+}
+
+static __inline__ unsigned int
+inw(unsigned short port)
+{
+ if(ioBase == MAP_FAILED) return 0;
+ return xf86ReadMmio16Le((void *)ioBase, port);
+}
+
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ if(ioBase == MAP_FAILED) return 0;
+ return xf86ReadMmio32Le((void *)ioBase, port);
+}
+
+# define ldq_u(p) ldl_u(p)
+# define ldl_u(p) ((*(unsigned char *)(p)) | \
+ (*((unsigned char *)(p)+1)<<8) | \
+ (*((unsigned char *)(p)+2)<<16) | \
+ (*((unsigned char *)(p)+3)<<24))
+# define ldw_u(p) ((*(unsigned char *)(p)) | \
+ (*((unsigned char *)(p)+1)<<8))
+
+# define stq_u(v,p) stl_u(v,p)
+# define stl_u(v,p) (*(unsigned char *)(p)) = (v); \
+ (*((unsigned char *)(p)+1)) = ((v) >> 8); \
+ (*((unsigned char *)(p)+2)) = ((v) >> 16); \
+ (*((unsigned char *)(p)+3)) = ((v) >> 24)
+# define stw_u(v,p) (*(unsigned char *)(p)) = (v); \
+ (*((unsigned char *)(p)+1)) = ((v) >> 8)
+
+# define mem_barrier() eieio()
+# define write_mem_barrier() eieio()
+
+#elif defined(__arm__) && defined(__linux__)
+
+#define ldq_u(p) (*((unsigned long *)(p)))
+#define ldl_u(p) (*((unsigned int *)(p)))
+#define ldw_u(p) (*((unsigned short *)(p)))
+#define stq_u(v,p) (*(unsigned long *)(p)) = (v)
+#define stl_u(v,p) (*(unsigned int *)(p)) = (v)
+#define stw_u(v,p) (*(unsigned short *)(p)) = (v)
+#define mem_barrier() /* NOP */
+#define write_mem_barrier() /* NOP */
+
+/* for Linux on ARM, we use the LIBC inx/outx routines */
+/* note that the appropriate setup via "ioperm" needs to be done */
+/* *before* any inx/outx is done. */
+
+#include <sys/io.h>
+
+static __inline__ void
+xf_outb(unsigned short port, unsigned char val)
+{
+ outb(val, port);
+}
+
+static __inline__ void
+xf_outw(unsigned short port, unsigned short val)
+{
+ outw(val, port);
+}
+
+static __inline__ void
+xf_outl(unsigned short port, unsigned int val)
+{
+ outl(val, port);
+}
+
+#define outb xf_outb
+#define outw xf_outw
+#define outl xf_outl
+
+#define arm_flush_cache(addr) \
+do { \
+ register unsigned long _beg __asm ("a1") = (unsigned long) (addr); \
+ register unsigned long _end __asm ("a2") = (unsigned long) (addr) + 4;\
+ register unsigned long _flg __asm ("a3") = 0; \
+ __asm __volatile ("swi 0x9f0002 @ sys_cacheflush" \
+ : "=r" (_beg) \
+ : "0" (_beg), "r" (_end), "r" (_flg)); \
+} while (0)
+
+# else /* ix86 */
+
+# define ldq_u(p) (*((unsigned long *)(p)))
+# define ldl_u(p) (*((unsigned int *)(p)))
+# define ldw_u(p) (*((unsigned short *)(p)))
+# define stq_u(v,p) (*(unsigned long *)(p)) = (v)
+# define stl_u(v,p) (*(unsigned int *)(p)) = (v)
+# define stw_u(v,p) (*(unsigned short *)(p)) = (v)
+# define mem_barrier() /* NOP */
+# define write_mem_barrier() /* NOP */
+
+# if !defined(__SUNPRO_C)
+# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__)
+# ifdef GCCUSESGAS
+
+/*
+ * If gcc uses gas rather than the native assembler, the syntax of these
+ * inlines has to be different. DHD
+ */
+
+static __inline__ void
+outb(unsigned short port, unsigned char val)
+{
+ __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
+}
+
+
+static __inline__ void
+outw(unsigned short port, unsigned short val)
+{
+ __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
+}
+
+static __inline__ void
+outl(unsigned short port, unsigned int val)
+{
+ __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
+}
+
+static __inline__ unsigned int
+inb(unsigned short port)
+{
+ unsigned char ret;
+ __asm__ __volatile__("inb %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inw(unsigned short port)
+{
+ unsigned short ret;
+ __asm__ __volatile__("inw %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("inl %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+# else /* GCCUSESGAS */
+
+static __inline__ void
+outb(unsigned short port, unsigned char val)
+{
+ __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port));
+}
+
+static __inline__ void
+outw(unsigned short port, unsigned short val)
+{
+ __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port));
+}
+
+static __inline__ void
+outl(unsigned short port, unsigned int val)
+{
+ __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port));
+}
+
+static __inline__ unsigned int
+inb(unsigned short port)
+{
+ unsigned char ret;
+ __asm__ __volatile__("in%B0 (%1)" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inw(unsigned short port)
+{
+ unsigned short ret;
+ __asm__ __volatile__("in%W0 (%1)" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("in%L0 (%1)" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+# endif /* GCCUSESGAS */
+
+# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__)*/
+
+static __inline__ void
+outb(unsigned short port, unsigned char val)
+{
+}
+
+static __inline__ void
+outw(unsigned short port, unsigned short val)
+{
+}
+
+static __inline__ void
+outl(unsigned short port, unsigned int val)
+{
+}
+
+static __inline__ unsigned int
+inb(unsigned short port)
+{
+ return 0;
+}
+
+static __inline__ unsigned int
+inw(unsigned short port)
+{
+ return 0;
+}
+
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ return 0;
+}
+
+# endif /* FAKEIT */
+# endif /* __SUNPRO_C */
+
+# endif /* ix86 */
+
+# elif defined(__powerpc__) /* && !__GNUC__ */
+/*
+ * NON-GCC PowerPC - Presumed to be PowerMAX OS for now
+ */
+# ifndef PowerMAX_OS
+# error - Non-gcc PowerPC and !PowerMAXOS ???
+# endif
+
+# define PPCIO_DEBUG 0
+# define PPCIO_INLINE 1
+# define USE_ABS_MACRO 1
+/*
+ * Use compiler intrinsics to access certain PPC machine instructions
+ */
+# define eieio() __inst_eieio()
+# define stw_brx(val,base,ndx) __inst_sthbrx(val,base,ndx)
+# define stl_brx(val,base,ndx) __inst_stwbrx(val,base,ndx)
+# define ldw_brx(base,ndx) __inst_lhbrx(base,ndx)
+# define ldl_brx(base,ndx) __inst_lwbrx(base,ndx)
+
+# define ldq_u(p) (*((unsigned long long *)(p)))
+# define ldl_u(p) (*((unsigned long *)(p)))
+# define ldw_u(p) (*((unsigned short *)(p)))
+# define stq_u(v,p) (*(unsigned long long *)(p)) = (v)
+# define stl_u(v,p) (*(unsigned long *)(p)) = (v)
+# define stw_u(v,p) (*(unsigned short *)(p)) = (v)
+# define mem_barrier() eieio()
+# define write_mem_barrier() eieio()
+
+extern volatile unsigned char *ioBase;
+
+# if !defined(abs) && defined(USE_ABS_MACRO)
+# define abs(x) ((x) >= 0 ? (x) : -(x))
+# endif
+
+# undef inb
+# undef inw
+# undef inl
+# undef outb
+# undef outw
+# undef outl
+
+# if PPCIO_DEBUG
+
+extern void debug_outb(unsigned int a, unsigned char b, int line, char *file);
+extern void debug_outw(unsigned int a, unsigned short w, int line, char *file);
+extern void debug_outl(unsigned int a, unsigned int l, int line, char *file);
+extern unsigned char debug_inb(unsigned int a, int line, char *file);
+extern unsigned short debug_inw(unsigned int a, int line, char *file);
+extern unsigned int debug_inl(unsigned int a, int line, char *file);
+
+# define outb(a,b) debug_outb(a,b, __LINE__, __FILE__)
+# define outw(a,w) debug_outw(a,w, __LINE__, __FILE__)
+# define outl(a,l) debug_outl(a,l, __LINE__, __FILE__)
+# define inb(a) debug_inb(a, __LINE__, __FILE__)
+# define inw(a) debug_inw(a, __LINE__, __FILE__)
+# define inl(a) debug_inl(a, __LINE__, __FILE__)
+
+# else /* !PPCIO_DEBUG */
+
+extern unsigned char inb(unsigned int a);
+extern unsigned short inw(unsigned int a);
+extern unsigned int inl(unsigned int a);
+
+# if PPCIO_INLINE
+
+# define outb(a,b) \
+ (*((volatile unsigned char *)(ioBase + (a))) = (b), eieio())
+# define outw(a,w) (stw_brx((w),ioBase,(a)), eieio())
+# define outl(a,l) (stl_brx((l),ioBase,(a)), eieio())
+
+# else /* !PPCIO_INLINE */
+
+extern void outb(unsigned int a, unsigned char b);
+extern void outw(unsigned int a, unsigned short w);
+extern void outl(unsigned int a, unsigned int l);
+
+# endif /* PPCIO_INLINE */
+
+# endif /* !PPCIO_DEBUG */
+
+# else /* !GNUC && !PPC */
+# if !defined(QNX4)
+# if defined(__STDC__) && (__STDC__ == 1)
+# ifndef asm
+# define asm __asm
+# endif
+# endif
+# ifndef SCO325
+# if defined(__UNIXWARE__)
+# if defined(IN_MODULE)
+# /* avoid including <sys/types.h> for <sys/inline.h> on UnixWare */
+# define ushort unsigned short
+# define ushort_t unsigned short
+# define ulong unsigned long
+# define ulong_t unsigned long
+# define uint_t unsigned int
+# define uchar_t unsigned char
+# else
+# include <sys/types.h>
+# endif /* IN_MODULE */
+# endif /* __UNIXWARE__ */
+# if !defined(sgi) && !defined(__SUNPRO_C)
+# include <sys/inline.h>
+# endif
+# else
+# include "scoasm.h"
+# endif
+# if (!defined(__HIGHC__) && !defined(sgi) && !defined(__SUNPRO_C)) || \
+ defined(__USLC__)
+# pragma asm partial_optimization outl
+# pragma asm partial_optimization outw
+# pragma asm partial_optimization outb
+# pragma asm partial_optimization inl
+# pragma asm partial_optimization inw
+# pragma asm partial_optimization inb
+# endif
+# endif
+# define ldq_u(p) (*((unsigned long *)(p)))
+# define ldl_u(p) (*((unsigned int *)(p)))
+# define ldw_u(p) (*((unsigned short *)(p)))
+# define stq_u(v,p) (*(unsigned long *)(p)) = (v)
+# define stl_u(v,p) (*(unsigned int *)(p)) = (v)
+# define stw_u(v,p) (*(unsigned short *)(p)) = (v)
+# define mem_barrier() /* NOP */
+# define write_mem_barrier() /* NOP */
+# endif /* __GNUC__ */
+
+# if defined(QNX4)
+# include <sys/types.h>
+extern unsigned inb(unsigned port);
+extern unsigned inw(unsigned port);
+extern unsigned inl(unsigned port);
+extern void outb(unsigned port, unsigned val);
+extern void outw(unsigned port, unsigned val);
+extern void outl(unsigned port, unsigned val);
+# endif /* QNX4 */
+
+# if defined(IODEBUG) && defined(__GNUC__)
+# undef inb
+# undef inw
+# undef inl
+# undef outb
+# undef outw
+# undef outl
+# define inb(a) __extension__ ({unsigned char __c=RealInb(a); ErrorF("inb(0x%03x) = 0x%02x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;})
+# define inw(a) __extension__ ({unsigned short __c=RealInw(a); ErrorF("inw(0x%03x) = 0x%04x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;})
+# define inl(a) __extension__ ({unsigned int __c=RealInl(a); ErrorF("inl(0x%03x) = 0x%08x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;})
+
+# define outb(a,b) (ErrorF("outb(0x%03x, 0x%02x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutb(a,b))
+# define outw(a,b) (ErrorF("outw(0x%03x, 0x%04x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutw(a,b))
+# define outl(a,b) (ErrorF("outl(0x%03x, 0x%08x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutl(a,b))
+# endif
+
+# endif /* NO_INLINE */
+
+# ifdef __alpha__
+/* entry points for Mmio memory access routines */
+extern int (*xf86ReadMmio8)(void *, unsigned long);
+extern int (*xf86ReadMmio16)(void *, unsigned long);
+# ifndef STANDALONE_MMIO
+extern int (*xf86ReadMmio32)(void *, unsigned long);
+# else
+/* Some DRI 3D drivers need MMIO_IN32. */
+static __inline__ int
+xf86ReadMmio32(void *Base, unsigned long Offset)
+{
+ __asm__ __volatile__("mb" : : : "memory");
+ return *(volatile unsigned int*)((unsigned long)Base+(Offset));
+}
+# endif
+extern void (*xf86WriteMmio8)(int, void *, unsigned long);
+extern void (*xf86WriteMmio16)(int, void *, unsigned long);
+extern void (*xf86WriteMmio32)(int, void *, unsigned long);
+extern void (*xf86WriteMmioNB8)(int, void *, unsigned long);
+extern void (*xf86WriteMmioNB16)(int, void *, unsigned long);
+extern void (*xf86WriteMmioNB32)(int, void *, unsigned long);
+extern void xf86JensenMemToBus(char *, long, long, int);
+extern void xf86JensenBusToMem(char *, char *, unsigned long, int);
+extern void xf86SlowBCopyFromBus(unsigned char *, unsigned char *, int);
+extern void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
+
+/* Some macros to hide the system dependencies for MMIO accesses */
+/* Changed to kill noise generated by gcc's -Wcast-align */
+# define MMIO_IN8(base, offset) (*xf86ReadMmio8)(base, offset)
+# define MMIO_IN16(base, offset) (*xf86ReadMmio16)(base, offset)
+# ifndef STANDALONE_MMIO
+# define MMIO_IN32(base, offset) (*xf86ReadMmio32)(base, offset)
+# else
+# define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
+# endif
+
+# if defined (JENSEN_SUPPORT)
+# define MMIO_OUT32(base, offset, val) \
+ (*xf86WriteMmio32)((CARD32)(val), base, offset)
+# define MMIO_ONB32(base, offset, val) \
+ (*xf86WriteMmioNB32)((CARD32)(val), base, offset)
+# else
+# define MMIO_OUT32(base, offset, val) \
+ do { \
+ write_mem_barrier(); \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val); \
+ } while (0)
+# define MMIO_ONB32(base, offset, val) \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
+# endif
+
+# define MMIO_OUT8(base, offset, val) \
+ (*xf86WriteMmio8)((CARD8)(val), base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ (*xf86WriteMmio16)((CARD16)(val), base, offset)
+# define MMIO_ONB8(base, offset, val) \
+ (*xf86WriteMmioNB8)((CARD8)(val), base, offset)
+# define MMIO_ONB16(base, offset, val) \
+ (*xf86WriteMmioNB16)((CARD16)(val), base, offset)
+# define MMIO_MOVE32(base, offset, val) \
+ MMIO_OUT32(base, offset, val)
+
+# elif defined(__powerpc__)
+ /*
+ * we provide byteswapping and no byteswapping functions here
+ * with byteswapping as default,
+ * drivers that don't need byteswapping should define PPC_MMIO_IS_BE
+ */
+# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
+# define MMIO_OUT8(base, offset, val) \
+ xf86WriteMmio8(base, offset, (CARD8)(val))
+# define MMIO_ONB8(base, offset, val) \
+ xf86WriteMmioNB8(base, offset, (CARD8)(val))
+
+# if defined(PPC_MMIO_IS_BE) /* No byteswapping */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Be(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Be(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmioNB16Be(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmioNB32Be(base, offset, (CARD32)(val))
+# else /* byteswapping is the default */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Le(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Le(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmioNB16Le(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmioNB32Le(base, offset, (CARD32)(val))
+# endif
+
+# define MMIO_MOVE32(base, offset, val) \
+ xf86WriteMmio32Be(base, offset, (CARD32)(val))
+
+static __inline__ void ppc_flush_icache(char *addr)
+{
+ __asm__ volatile (
+ "dcbf 0,%0;"
+ "sync;"
+ "icbi 0,%0;"
+ "sync;"
+ "isync;"
+ : : "r"(addr) : "memory");
+}
+
+# elif defined(__sparc__) || defined(sparc)
+ /*
+ * Like powerpc, we provide byteswapping and no byteswapping functions
+ * here with byteswapping as default, drivers that don't need byteswapping
+ * should define SPARC_MMIO_IS_BE (perhaps create a generic macro so that we
+ * do not need to use PPC_MMIO_IS_BE and the sparc one in all the same places
+ * of drivers?).
+ */
+# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
+# define MMIO_OUT8(base, offset, val) \
+ xf86WriteMmio8(base, offset, (CARD8)(val))
+# define MMIO_ONB8(base, offset, val) \
+ xf86WriteMmio8NB(base, offset, (CARD8)(val))
+
+# if defined(SPARC_MMIO_IS_BE) /* No byteswapping */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Be(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Be(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmio16BeNB(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmio32BeNB(base, offset, (CARD32)(val))
+# else /* byteswapping is the default */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Le(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Le(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmio16LeNB(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmio32LeNB(base, offset, (CARD32)(val))
+# endif
+
+# define MMIO_MOVE32(base, offset, val) \
+ xf86WriteMmio32Be(base, offset, (CARD32)(val))
+
+# else /* !__alpha__ && !__powerpc__ && !__sparc__ */
+
+# define MMIO_IN8(base, offset) \
+ *(volatile CARD8 *)(((CARD8*)(base)) + (offset))
+# define MMIO_IN16(base, offset) \
+ *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset))
+# define MMIO_IN32(base, offset) \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset))
+# define MMIO_OUT8(base, offset, val) \
+ *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val)
+# define MMIO_OUT16(base, offset, val) \
+ *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
+# define MMIO_OUT32(base, offset, val) \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
+# define MMIO_ONB8(base, offset, val) MMIO_OUT8(base, offset, val)
+# define MMIO_ONB16(base, offset, val) MMIO_OUT16(base, offset, val)
+# define MMIO_ONB32(base, offset, val) MMIO_OUT32(base, offset, val)
+
+# define MMIO_MOVE32(base, offset, val) MMIO_OUT32(base, offset, val)
+
+# endif /* __alpha__ */
+
+/*
+ * With Intel, the version in os-support/misc/SlowBcopy.s is used.
+ * This avoids port I/O during the copy (which causes problems with
+ * some hardware).
+ */
+# ifdef __alpha__
+# define slowbcopy_tobus(src,dst,count) xf86SlowBCopyToBus(src,dst,count)
+# define slowbcopy_frombus(src,dst,count) xf86SlowBCopyFromBus(src,dst,count)
+# else /* __alpha__ */
+# define slowbcopy_tobus(src,dst,count) xf86SlowBcopy(src,dst,count)
+# define slowbcopy_frombus(src,dst,count) xf86SlowBcopy(src,dst,count)
+# endif /* __alpha__ */
+
+#endif /* _COMPILER_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/fourcc.h b/nx-X11/programs/Xserver/hw/xfree86/common/fourcc.h
new file mode 100644
index 000000000..e60aa4e83
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/fourcc.h
@@ -0,0 +1,161 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/fourcc.h,v 1.5 2003/08/24 17:36:48 dawes Exp $ */
+
+/*
+ * Copyright (c) 2000-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ This header file contains listings of STANDARD guids for video formats.
+ Please do not place non-registered, or incomplete entries in this file.
+ A list of some popular fourcc's are at: http://www.webartz.com/fourcc/
+ For an explanation of fourcc <-> guid mappings see RFC2361.
+*/
+
+#ifndef _XF86_FOURCC_H_
+#define _XF86_FOURCC_H_ 1
+
+#define FOURCC_YUY2 0x32595559
+#define XVIMAGE_YUY2 \
+ { \
+ FOURCC_YUY2, \
+ XvYUV, \
+ LSBFirst, \
+ {'Y','U','Y','2', \
+ 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
+ 16, \
+ XvPacked, \
+ 1, \
+ 0, 0, 0, 0, \
+ 8, 8, 8, \
+ 1, 2, 2, \
+ 1, 1, 1, \
+ {'Y','U','Y','V', \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
+ XvTopToBottom \
+ }
+
+#define FOURCC_YV12 0x32315659
+#define XVIMAGE_YV12 \
+ { \
+ FOURCC_YV12, \
+ XvYUV, \
+ LSBFirst, \
+ {'Y','V','1','2', \
+ 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
+ 12, \
+ XvPlanar, \
+ 3, \
+ 0, 0, 0, 0, \
+ 8, 8, 8, \
+ 1, 2, 2, \
+ 1, 2, 2, \
+ {'Y','V','U', \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
+ XvTopToBottom \
+ }
+
+#define FOURCC_I420 0x30323449
+#define XVIMAGE_I420 \
+ { \
+ FOURCC_I420, \
+ XvYUV, \
+ LSBFirst, \
+ {'I','4','2','0', \
+ 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
+ 12, \
+ XvPlanar, \
+ 3, \
+ 0, 0, 0, 0, \
+ 8, 8, 8, \
+ 1, 2, 2, \
+ 1, 2, 2, \
+ {'Y','U','V', \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
+ XvTopToBottom \
+ }
+
+
+#define FOURCC_UYVY 0x59565955
+#define XVIMAGE_UYVY \
+ { \
+ FOURCC_UYVY, \
+ XvYUV, \
+ LSBFirst, \
+ {'U','Y','V','Y', \
+ 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
+ 16, \
+ XvPacked, \
+ 1, \
+ 0, 0, 0, 0, \
+ 8, 8, 8, \
+ 1, 2, 2, \
+ 1, 1, 1, \
+ {'U','Y','V','Y', \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
+ XvTopToBottom \
+ }
+
+#define FOURCC_IA44 0x34344149
+#define XVIMAGE_IA44 \
+ { \
+ FOURCC_IA44, \
+ XvYUV, \
+ LSBFirst, \
+ {'I','A','4','4', \
+ 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
+ 8, \
+ XvPacked, \
+ 1, \
+ 0, 0, 0, 0, \
+ 8, 8, 8, \
+ 1, 1, 1, \
+ 1, 1, 1, \
+ {'A','I', \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
+ XvTopToBottom \
+ }
+
+#define FOURCC_AI44 0x34344941
+#define XVIMAGE_AI44 \
+ { \
+ FOURCC_AI44, \
+ XvYUV, \
+ LSBFirst, \
+ {'A','I','4','4', \
+ 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
+ 8, \
+ XvPacked, \
+ 1, \
+ 0, 0, 0, 0, \
+ 8, 8, 8, \
+ 1, 1, 1, \
+ 1, 1, 1, \
+ {'I','A', \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
+ XvTopToBottom \
+ }
+
+#endif /* _XF86_FOURCC_H_ */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/modeline2c.pl b/nx-X11/programs/Xserver/hw/xfree86/common/modeline2c.pl
new file mode 100644
index 000000000..cc6c6925e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/modeline2c.pl
@@ -0,0 +1,110 @@
+#!/usr/bin/perl
+
+# automatically generate the xf86DefModeSet.c file from a normal
+# XF86Config style file of Modelines
+#
+# run as
+#
+# perl /modeline2c.pl < [modesfile] > xf86DefModes.c
+#
+# hackish perl - author Dirk Hohndel
+#
+# Copyright 1999-2003 by The XFree86 Project, Inc.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the copyright holder(s)
+# and author(s) shall not be used in advertising or otherwise to promote
+# the sale, use or other dealings in this Software without prior written
+# authorization from the copyright holder(s) and author(s).
+#
+# $XFree86: xc/programs/Xserver/hw/xfree86/common/modeline2c.pl,v 1.10tsi Exp $
+
+#my %flagshash;
+$flagshash{""} = "0";
+# $flagshash{"Interlace"} = "V_INTERLACE";
+# $flagshash{"+hsync"} = "V_PHSYNC";
+# $flagshash{"-hsync"} = "V_NHSYNC";
+# $flagshash{"+vsync"} = "V_PVSYNC";
+# $flagshash{"-vsync"} = "V_NVSYNC";
+# XXX I'm definitely not a perl guru... -- tsi
+$flagshash{"+hsync +vsync"} = "V_PHSYNC | V_PVSYNC";
+$flagshash{"+hsync -vsync"} = "V_PHSYNC | V_NVSYNC";
+$flagshash{"-hsync +vsync"} = "V_NHSYNC | V_PVSYNC";
+$flagshash{"-hsync -vsync"} = "V_NHSYNC | V_NVSYNC";
+$flagshash{"+hsync +vsync interlace"} = "V_PHSYNC | V_PVSYNC | V_INTERLACE";
+$flagshash{"+hsync -vsync interlace"} = "V_PHSYNC | V_NVSYNC | V_INTERLACE";
+$flagshash{"-hsync +vsync interlace"} = "V_NHSYNC | V_PVSYNC | V_INTERLACE";
+$flagshash{"-hsync -vsync interlace"} = "V_NHSYNC | V_NVSYNC | V_INTERLACE";
+
+# stop CVS from expanding the XFree86 Id here...
+
+$proj = "XFree86";
+printf("/* \$$proj\$ */
+
+/* THIS FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT -- LOOK at
+ * modeline2c.pl */
+
+/*
+ * Copyright 1999-2003 by The XFree86 Project, Inc.
+ *
+ * Author: Dirk Hohndel <hohndel\@XFree86.Org>
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define I_NEED_OS2_H
+#endif
+#include \"xf86.h\"
+#include \"xf86Config.h\"
+#include \"xf86Priv.h\"
+#include \"xf86_OSlib.h\"
+
+#include \"globals.h\"
+
+#define MODEPREFIX(name) NULL, NULL, name, MODE_OK, M_T_DEFAULT
+#define MODESUFFIX 0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0
+
+DisplayModeRec xf86DefaultModes [] = {
+");
+while (<>) {
+ if (/^\#/) {
+ s/^\#//;
+ chop;
+ print "/*" . $_ . " */\n";
+ }
+ if (/^ModeLine\s+(\S+)\s+([\d.\s]+)(.*)/i) {
+ $name = $1;
+ $values = $2;
+ $flags = $3;
+ $flags =~ y/A-Z/a-z/;
+ $values =~ /([\d.]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/;
+ printf("\t{MODEPREFIX(%s),%d, %d,%d,%d,%d,0, %d,%d,%d,%d,0, %s, MODESUFFIX},\n",
+ $name,$1*1000,$2,$3,$4,$5,$6,$7,$8,$9,$flagshash{$flags});
+# Also generate half-width doublescanned modes
+ printf("\t{MODEPREFIX(\"%dx%d\"),%d, %d,%d,%d,%d,0, %d,%d,%d,%d,0, %s | V_DBLSCAN, MODESUFFIX},\n",
+ $2/2,$6/2,$1*500,$2/2,$3/2,$4/2,$5/2,$6/2,$7/2,$8/2,$9/2,$flagshash{$flags});
+ }
+
+
+}
+printf("\t{MODEPREFIX(NULL),0,0,0,0,0,0,0,0,0,0,0,0,MODESUFFIX}\n};\n");
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/scoasm.h b/nx-X11/programs/Xserver/hw/xfree86/common/scoasm.h
new file mode 100644
index 000000000..5a5af8eb9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/scoasm.h
@@ -0,0 +1,143 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/scoasm.h,v 3.1 2003/08/24 17:36:49 dawes Exp $ */
+
+/*
+ * Copyright (c) 1996 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * scoasm.h - used to define inline versions of certain functions which
+ * do NOT appear in sys/inline.h.
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#if defined(__SCO__) && defined(__USLC__)
+#ifndef _SCOASM_HDR_INC
+#define _SCOASM_HDR_INC
+
+asm void outl(port,val)
+{
+%reg port,val;
+ movl port, %edx
+ movl val, %eax
+ outl (%dx)
+%reg port; mem val;
+ movl port, %edx
+ movl val, %eax
+ outl (%dx)
+%mem port; reg val;
+ movw port, %dx
+ movl val, %eax
+ outl (%dx)
+%mem port,val;
+ movw port, %dx
+ movl val, %eax
+ outl (%dx)
+}
+
+asm void outw(port,val)
+{
+%reg port,val;
+ movl port, %edx
+ movl val, %eax
+ data16
+ outl (%dx)
+%reg port; mem val;
+ movl port, %edx
+ movw val, %ax
+ data16
+ outl (%dx)
+%mem port; reg val;
+ movw port, %dx
+ movl val, %eax
+ data16
+ outl (%dx)
+%mem port,val;
+ movw port, %dx
+ movw val, %ax
+ data16
+ outl (%dx)
+}
+
+asm void outb(port,val)
+{
+%reg port,val;
+ movl port, %edx
+ movl val, %eax
+ outb (%dx)
+%reg port; mem val;
+ movl port, %edx
+ movb val, %al
+ outb (%dx)
+%mem port; reg val;
+ movw port, %dx
+ movl val, %eax
+ outb (%dx)
+%mem port,val;
+ movw port, %dx
+ movb val, %al
+ outb (%dx)
+}
+
+asm int inl(port)
+{
+%reg port;
+ movl port, %edx
+ inl (%dx)
+%mem port;
+ movw port, %dx
+ inl (%dx)
+}
+
+asm int inw(port)
+{
+%reg port;
+ subl %eax, %eax
+ movl port, %edx
+ data16
+ inl (%dx)
+%mem port;
+ subl %eax, %eax
+ movw port, %dx
+ data16
+ inl (%dx)
+}
+
+asm int inb(port)
+{
+%reg port;
+ subl %eax, %eax
+ movl port, %edx
+ inb (%dx)
+%mem port;
+ subl %eax, %eax
+ movw port, %dx
+ inb (%dx)
+}
+
+#endif /* _SCOASM_HDR_INC */
+#endif /* __SCO__ && __USLC__ */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86.h
new file mode 100644
index 000000000..010360cf3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86.h
@@ -0,0 +1,447 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86.h,v 3.173 2004/01/27 01:31:44 dawes Exp $ */
+
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains declarations for public XFree86 functions and variables,
+ * and definitions of public macros.
+ *
+ * "public" means available to video drivers.
+ */
+
+#ifndef _XF86_H
+#define _XF86_H
+
+#include "xf86str.h"
+#include "xf86Opt.h"
+#include <X11/Xfuncproto.h>
+#ifndef IN_MODULE
+#include <stdarg.h>
+#else
+#include "xf86_ansic.h"
+#endif
+#ifdef RANDR
+#include <X11/extensions/randr.h>
+#endif
+
+#include "propertyst.h"
+
+/* General parameters */
+extern int xf86DoConfigure;
+extern Bool xf86DoConfigurePass1;
+extern int xf86ScreenIndex; /* Index into pScreen.devPrivates */
+extern int xf86CreateRootWindowIndex; /* Index into pScreen.devPrivates */
+extern int xf86PixmapIndex;
+extern Bool xf86ResAccessEnter;
+extern ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
+extern const unsigned char byte_reversed[256];
+extern ScrnInfoPtr xf86CurrentScreen;
+extern Bool pciSlotClaimed;
+extern Bool isaSlotClaimed;
+extern Bool fbSlotClaimed;
+#ifdef __sparc__
+extern Bool sbusSlotClaimed;
+#endif
+extern confDRIRec xf86ConfigDRI;
+extern Bool xf86inSuspend;
+
+#define XF86SCRNINFO(p) ((ScrnInfoPtr)((p)->devPrivates[xf86ScreenIndex].ptr))
+
+#define XF86FLIP_PIXELS() \
+ do { \
+ if (xf86GetFlipPixels()) { \
+ pScreen->whitePixel = (pScreen->whitePixel) ? 0 : 1; \
+ pScreen->blackPixel = (pScreen->blackPixel) ? 0 : 1; \
+ } \
+ while (0)
+
+#define BOOLTOSTRING(b) ((b) ? "TRUE" : "FALSE")
+
+#define PIX24TOBPP(p) (((p) == Pix24Use24) ? 24 : \
+ (((p) == Pix24Use32) ? 32 : 0))
+
+/* variables for debugging */
+#ifdef BUILDDEBUG
+extern char* xf86p8bit[];
+extern CARD32 xf86DummyVar1;
+extern CARD32 xf86DummyVar2;
+extern CARD32 xf86DummyVar3;
+#endif
+
+/* Function Prototypes */
+#ifndef _NO_XF86_PROTOTYPES
+
+/* xf86Bus.c */
+
+Bool xf86CheckPciSlot(int bus, int device, int func);
+int xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp,
+ int chipset, GDevPtr dev, Bool active);
+Bool xf86ParsePciBusString(const char *busID, int *bus, int *device,
+ int *func);
+Bool xf86ComparePciBusString(const char *busID, int bus, int device, int func);
+void xf86FormatPciBusNumber(int busnum, char *buffer);
+pciVideoPtr *xf86GetPciVideoInfo(void);
+pciConfigPtr *xf86GetPciConfigInfo(void);
+void xf86SetPciVideo(pciVideoPtr, resType);
+void xf86PrintResList(int verb, resPtr list);
+resPtr xf86AddRangesToList(resPtr list, resRange *pRange, int entityIndex);
+int xf86ClaimIsaSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
+int xf86GetIsaInfoForScreen(int scrnIndex);
+int xf86GetFbInfoForScreen(int scrnIndex);
+Bool xf86ParseIsaBusString(const char *busID);
+int xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
+int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
+void xf86EnableAccess(ScrnInfoPtr pScrn);
+void xf86SetCurrentAccess(Bool Enable, ScrnInfoPtr pScrn);
+Bool xf86IsPrimaryPci(pciVideoPtr pPci);
+Bool xf86IsPrimaryIsa(void);
+int xf86CheckPciGAType(pciVideoPtr pPci);
+/* new RAC */
+resPtr xf86AddResToList(resPtr rlist, resRange *Range, int entityIndex);
+resPtr xf86JoinResLists(resPtr rlist1, resPtr rlist2);
+resPtr xf86DupResList(const resPtr rlist);
+void xf86FreeResList(resPtr rlist);
+void xf86ClaimFixedResources(resList list, int entityIndex);
+Bool xf86DriverHasEntities(DriverPtr drvp);
+void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex);
+void xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex,
+ int instance);
+int xf86GetNumEntityInstances(int entityIndex);
+GDevPtr xf86GetDevFromEntity(int entityIndex, int instance);
+void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex);
+EntityInfoPtr xf86GetEntityInfo(int entityIndex);
+pciVideoPtr xf86GetPciInfoForEntity(int entityIndex);
+int xf86GetPciEntity(int bus, int dev, int func);
+Bool xf86SetEntityFuncs(int entityIndex, EntityProc init,
+ EntityProc enter, EntityProc leave, pointer);
+void xf86DeallocateResourcesForEntity(int entityIndex, unsigned long type);
+resPtr xf86RegisterResources(int entityIndex, resList list,
+ unsigned long Access);
+Bool xf86CheckPciMemBase(pciVideoPtr pPci, memType base);
+void xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs,
+ xf86SetAccessFuncPtr oldFuncs);
+Bool xf86IsEntityPrimary(int entityIndex);
+Bool xf86FixPciResource(int entityIndex, int prt, memType alignment,
+ unsigned long type);
+resPtr xf86ReallocatePciResources(int entityIndex, resPtr pRes);
+resPtr xf86SetOperatingState(resList list, int entityIndex, int mask);
+void xf86EnterServerState(xf86State state);
+resRange xf86GetBlock(unsigned long type, memType size,
+ memType window_start, memType window_end,
+ memType align_mask, resPtr avoid);
+resRange xf86GetSparse(unsigned long type, memType fixed_bits,
+ memType decode_mask, memType address_mask,
+ resPtr avoid);
+memType xf86ChkConflict(resRange *rgp, int entityIndex);
+Bool xf86IsPciDevPresent(int bus, int dev, int func);
+ScrnInfoPtr xf86FindScreenForEntity(int entityIndex);
+Bool xf86NoSharedResources(int screenIndex, resType res);
+resPtr xf86FindIntersectOfLists(resPtr l1, resPtr l2);
+pciVideoPtr xf86FindPciDeviceVendor(CARD16 vendorID, CARD16 deviceID,
+ char n, pciVideoPtr pvp_exclude);
+pciVideoPtr xf86FindPciClass(CARD8 intf, CARD8 subClass, CARD16 class,
+ char n, pciVideoPtr pvp_exclude);
+#ifdef INCLUDE_DEPRECATED
+void xf86EnablePciBusMaster(pciVideoPtr pPci, Bool enable);
+#endif
+void xf86RegisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func, pointer arg);
+Bool xf86DeregisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func);
+#ifdef async
+Bool xf86QueueAsyncEvent(void (*func)(pointer),pointer arg);
+#endif
+
+int xf86GetLastScrnFlag(int entityIndex);
+void xf86SetLastScrnFlag(int entityIndex, int scrnIndex);
+Bool xf86IsEntityShared(int entityIndex);
+void xf86SetEntityShared(int entityIndex);
+Bool xf86IsEntitySharable(int entityIndex);
+void xf86SetEntitySharable(int entityIndex);
+Bool xf86IsPrimInitDone(int entityIndex);
+void xf86SetPrimInitDone(int entityIndex);
+void xf86ClearPrimInitDone(int entityIndex);
+int xf86AllocateEntityPrivateIndex(void);
+DevUnion *xf86GetEntityPrivate(int entityIndex, int privIndex);
+
+/* xf86Configure.c */
+GDevPtr xf86AddBusDeviceToConfigure(const char *driver, BusType bus,
+ void *busData, int chipset);
+GDevPtr xf86AddDeviceToConfigure(const char *driver, pciVideoPtr pVideo,
+ int chipset);
+
+/* xf86Cursor.c */
+
+void xf86LockZoom(ScreenPtr pScreen, int lock);
+void xf86InitViewport(ScrnInfoPtr pScr);
+void xf86SetViewport(ScreenPtr pScreen, int x, int y);
+void xf86ZoomViewport(ScreenPtr pScreen, int zoom);
+Bool xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode);
+void *xf86GetPointerScreenFuncs(void);
+void xf86InitOrigins(void);
+void xf86ReconfigureLayout(void);
+
+/* xf86DPMS.c */
+
+Bool xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags);
+
+/* xf86DGA.c */
+
+Bool DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, DGAModePtr modes,
+ int num);
+Bool DGAReInitModes(ScreenPtr pScreen, DGAModePtr modes, int num);
+xf86SetDGAModeProc xf86SetDGAMode;
+
+/* xf86Events.c */
+
+void SetTimeSinceLastInputEvent(void);
+pointer xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data);
+int xf86RemoveInputHandler(pointer handler);
+void xf86DisableInputHandler(pointer handler);
+void xf86EnableInputHandler(pointer handler);
+void xf86InterceptSignals(int *signo);
+void xf86InterceptSigIll(void (*sigillhandler)(void));
+Bool xf86EnableVTSwitch(Bool new);
+Bool xf86CommonSpecialKey(int key, Bool down, int modifiers);
+void xf86ProcessActionEvent(ActionEvent action, void *arg);
+
+/* xf86Helper.c */
+
+void xf86AddDriver(DriverPtr driver, pointer module, int flags);
+void xf86DeleteDriver(int drvIndex);
+ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags);
+void xf86DeleteScreen(int scrnIndex, int flags);
+int xf86AllocateScrnInfoPrivateIndex(void);
+Bool xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad);
+Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp, int fbbpp,
+ int depth24flags);
+void xf86PrintDepthBpp(ScrnInfoPtr scrp);
+Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask);
+Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual);
+Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma newGamma);
+void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y);
+void xf86SetBlackWhitePixels(ScreenPtr pScreen);
+void xf86EnableDisableFBAccess(int scrnIndex, Bool enable);
+void xf86VDrvMsgVerb(int scrnIndex, MessageType type, int verb,
+ const char *format, va_list args);
+void xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb,
+ const char *format, ...) _printf_attribute(4,5);
+void xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...)
+ _printf_attribute(3,4);
+void xf86MsgVerb(MessageType type, int verb, const char *format, ...)
+ _printf_attribute(3,4);
+void xf86Msg(MessageType type, const char *format, ...) _printf_attribute(2,3);
+void xf86ErrorFVerb(int verb, const char *format, ...) _printf_attribute(2,3);
+void xf86ErrorF(const char *format, ...) _printf_attribute(1,2);
+const char *xf86TokenToString(SymTabPtr table, int token);
+int xf86StringToToken(SymTabPtr table, const char *string);
+void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from);
+void xf86PrintChipsets(const char *drvname, const char *drvmsg,
+ SymTabPtr chips);
+int xf86MatchDevice(const char *drivername, GDevPtr **driversectlist);
+int xf86MatchPciInstances(const char *driverName, int vendorID,
+ SymTabPtr chipsets, PciChipsets *PCIchipsets,
+ GDevPtr *devList, int numDevs, DriverPtr drvp,
+ int **foundEntities);
+int xf86MatchIsaInstances(const char *driverName, SymTabPtr chipsets,
+ IsaChipsets *ISAchipsets, DriverPtr drvp,
+ FindIsaDevProc FindIsaDevice, GDevPtr *devList,
+ int numDevs, int **foundEntities);
+void xf86GetClocks(ScrnInfoPtr pScrn, int num,
+ Bool (*ClockFunc)(ScrnInfoPtr, int),
+ void (*ProtectRegs)(ScrnInfoPtr, Bool),
+ void (*BlankScreen)(ScrnInfoPtr, Bool),
+ IOADDRESS vertsyncreg, int maskval,
+ int knownclkindex, int knownclkvalue);
+void xf86SetPriority(Bool up);
+const char *xf86GetVisualName(int visual);
+int xf86GetVerbosity(void);
+Pix24Flags xf86GetPix24(void);
+int xf86GetDepth(void);
+rgb xf86GetWeight(void);
+Gamma xf86GetGamma(void);
+Bool xf86GetFlipPixels(void);
+const char *xf86GetServerName(void);
+Bool xf86ServerIsExiting(void);
+Bool xf86ServerIsResetting(void);
+Bool xf86ServerIsInitialising(void);
+Bool xf86ServerIsOnlyDetecting(void);
+Bool xf86ServerIsOnlyProbing(void);
+Bool xf86CaughtSignal(void);
+Bool xf86GetVidModeAllowNonLocal(void);
+Bool xf86GetVidModeEnabled(void);
+Bool xf86GetModInDevAllowNonLocal(void);
+Bool xf86GetModInDevEnabled(void);
+Bool xf86GetAllowMouseOpenFail(void);
+Bool xf86IsPc98(void);
+void xf86DisableRandR(void);
+CARD32 xf86GetVersion(void);
+CARD32 xorgGetVersion(void);
+CARD32 xf86GetModuleVersion(pointer module);
+pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name);
+pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name);
+pointer xf86LoadOneModule(char *name, pointer optlist);
+void xf86UnloadSubModule(pointer mod);
+Bool xf86LoaderCheckSymbol(const char *name);
+void xf86LoaderReqSymLists(const char **, ...);
+void xf86LoaderReqSymbols(const char *, ...);
+void xf86LoaderRefSymLists(const char **, ...);
+void xf86LoaderRefSymbols(const char *, ...);
+void xf86SetBackingStore(ScreenPtr pScreen);
+void xf86SetSilkenMouse(ScreenPtr pScreen);
+int xf86NewSerialNumber(WindowPtr p, pointer unused);
+pointer xf86FindXvOptions(int scrnIndex, int adapt_index, char *port_name,
+ char **adaptor_name, pointer *adaptor_options);
+void xf86GetOS(const char **name, int *major, int *minor, int *teeny);
+ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag,
+ int entityIndex,PciChipsets *p_chip,
+ resList res, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+ScrnInfoPtr xf86ConfigIsaEntity(ScrnInfoPtr pScrn, int scrnFlag,
+ int entityIndex, IsaChipsets *i_chip,
+ resList res, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+ScrnInfoPtr xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag,
+ int entityIndex, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+/* Obsolete! don't use */
+Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn,
+ int entityIndex,PciChipsets *p_chip,
+ resList res, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+/* Obsolete! don't use */
+Bool xf86ConfigActiveIsaEntity(ScrnInfoPtr pScrn,
+ int entityIndex, IsaChipsets *i_chip,
+ resList res, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+void xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip,
+ resList res, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+void xf86ConfigIsaEntityInactive(EntityInfoPtr pEnt, IsaChipsets *i_chip,
+ resList res, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+void xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+Bool xf86IsScreenPrimary(int scrnIndex);
+int xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
+ int format, unsigned long len,
+ pointer value);
+Bool xf86IsUnblank(int mode);
+
+#ifdef XFree86LOADER
+void xf86AddModuleInfo(ModuleInfoPtr info, pointer module);
+void xf86DeleteModuleInfo(int idx);
+#endif
+
+/* xf86Debug.c */
+#ifdef BUILDDEBUG
+ void xf86Break1(void);
+void xf86Break2(void);
+void xf86Break3(void);
+CARD8 xf86PeekFb8(CARD8 *p);
+CARD16 xf86PeekFb16(CARD16 *p);
+CARD32 xf86PeekFb32(CARD32 *p);
+void xf86PokeFb8(CARD8 *p, CARD8 v);
+void xf86PokeFb16(CARD16 *p, CARD16 v);
+void xf86PokeFb32(CARD16 *p, CARD32 v);
+CARD8 xf86PeekMmio8(pointer Base, unsigned long Offset);
+CARD16 xf86PeekMmio16(pointer Base, unsigned long Offset);
+CARD32 xf86PeekMmio32(pointer Base, unsigned long Offset);
+void xf86PokeMmio8(pointer Base, unsigned long Offset, CARD8 v);
+void xf86PokeMmio16(pointer Base, unsigned long Offset, CARD16 v);
+void xf86PokeMmio32(pointer Base, unsigned long Offset, CARD32 v);
+extern void xf86SPTimestamp(xf86TsPtr* timestamp, char* string);
+extern void xf86STimestamp(xf86TsPtr* timestamp);
+#endif
+
+/* xf86Init.c */
+
+PixmapFormatPtr xf86GetPixFormat(ScrnInfoPtr pScrn, int depth);
+int xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth);
+
+/* xf86Mode.c */
+
+int xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
+ int DivFactor, int MulFactor, int *divider);
+const char *xf86ModeStatusToString(ModeStatus status);
+ModeStatus xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
+ ClockRangePtr clockRanges, LookupModeFlags strategy);
+ModeStatus xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor);
+ModeStatus xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
+ ClockRangePtr clockRanges,
+ LookupModeFlags strategy,
+ int maxPitch, int virtualX,
+ int virtualY);
+ModeStatus xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
+ int flags);
+int xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
+ char **modeNames, ClockRangePtr clockRanges,
+ int *linePitches, int minPitch, int maxPitch,
+ int minHeight, int maxHeight, int pitchInc,
+ int virtualX, int virtualY, int apertureSize,
+ LookupModeFlags strategy);
+void xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode);
+void xf86PruneDriverModes(ScrnInfoPtr scrp);
+void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
+void xf86PrintModes(ScrnInfoPtr scrp);
+void xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges);
+
+/* xf86Option.c */
+
+void xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts);
+
+
+/* xf86RandR.c */
+#ifdef RANDR
+Bool xf86RandRInit (ScreenPtr pScreen);
+void xf86RandRSetInitialMode (ScreenPtr pScreen);
+Rotation xf86GetRotation(ScreenPtr pScreen);
+Bool xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
+ int newvirtX, int newvirtY,
+ int newmmWidth, int newmmHeight, Bool resetMode);
+#endif
+
+/* xf86VidModeExtentionInit.c */
+
+Bool VidModeExtensionInit(ScreenPtr pScreen);
+
+/* xf86Versions.c */
+CARD32 xf86GetBuiltinInterfaceVersion(BuiltinInterface iface, int flag);
+Bool xf86RegisterBuiltinInterfaceVersion(BuiltinInterface iface,
+ CARD32 version, int flags);
+
+
+#endif /* _NO_XF86_PROTOTYPES */
+
+#endif /* _XF86_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86AutoConfig.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86AutoConfig.c
new file mode 100644
index 000000000..36e400cd1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86AutoConfig.c
@@ -0,0 +1,368 @@
+/* $DHD: xc/programs/Xserver/hw/xfree86/common/xf86AutoConfig.c,v 1.15 2003/09/24 19:39:36 dawes Exp $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86AutoConfig.c,v 1.4 2005/08/23 20:12:26 alanc Exp $ */
+
+/*
+ * Copyright 2003 by David H. Dawes.
+ * Copyright 2003 by X-Oz Technologies.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ *
+ * Author: David Dawes <dawes@XFree86.Org>.
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86AutoConfig.c,v 1.2 2003/11/03 05:11:01 tsi Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "xf86Config.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+/*
+ * Sections for the default built-in configuration.
+ */
+
+#define BUILTIN_MODULE_SECTION \
+ "Section \"Module\"\n" \
+ "\tLoad\t\"extmod\"\n" \
+ "\tLoad\t\"dbe\"\n" \
+ "\tLoad\t\"glx\"\n" \
+ "\tLoad\t\"freetype\"\n" \
+ "EndSection\n\n"
+
+#define BUILTIN_DEVICE_NAME \
+ "\"Builtin Default %s Device %d\""
+
+#define BUILTIN_DEVICE_SECTION_PRE \
+ "Section \"Device\"\n" \
+ "\tIdentifier\t" BUILTIN_DEVICE_NAME "\n" \
+ "\tDriver\t\"%s\"\n"
+
+#define BUILTIN_DEVICE_SECTION_POST \
+ "EndSection\n\n"
+
+#define BUILTIN_DEVICE_SECTION \
+ BUILTIN_DEVICE_SECTION_PRE \
+ BUILTIN_DEVICE_SECTION_POST
+
+#define BUILTIN_MONITOR_NAME \
+ "\"Builtin Default Monitor\""
+
+#define BUILTIN_MONITOR_SECTION \
+ "Section \"Monitor\"\n" \
+ "\tIdentifier\t" BUILTIN_MONITOR_NAME "\n" \
+ "\tOption\t\"TargetRefresh\"\t\"75.0\"\n" \
+ "EndSection\n\n"
+
+#define BUILTIN_SCREEN_NAME \
+ "\"Builtin Default %s Screen %d\""
+
+#define BUILTIN_SCREEN_SECTION \
+ "Section \"Screen\"\n" \
+ "\tIdentifier\t" BUILTIN_SCREEN_NAME "\n" \
+ "\tDevice\t" BUILTIN_DEVICE_NAME "\n" \
+ "\tMonitor\t" BUILTIN_MONITOR_NAME "\n" \
+ "EndSection\n\n"
+
+#define BUILTIN_LAYOUT_SECTION_PRE \
+ "Section \"ServerLayout\"\n" \
+ "\tIdentifier\t\"Builtin Default Layout\"\n"
+
+#define BUILTIN_LAYOUT_SCREEN_LINE \
+ "\tScreen\t" BUILTIN_SCREEN_NAME "\n"
+
+#define BUILTIN_LAYOUT_SECTION_POST \
+ "EndSection\n\n"
+
+
+#ifndef GET_CONFIG_CMD
+#define GET_CONFIG_CMD "getconfig"
+#endif
+
+#ifndef GETCONFIG_DIR
+#define GETCONFIG_DIR PROJECTROOT "/lib/X11/getconfig"
+#endif
+
+#define GETCONFIG_WHITESPACE " \t\n"
+
+static const char **builtinConfig = NULL;
+static int builtinLines = 0;
+static const char *deviceList[] = {
+ "fbdev",
+ "vesa",
+ "vga",
+ NULL
+};
+
+/*
+ * A built-in config file is stored as an array of strings, with each string
+ * representing a single line. AppendToConfig() breaks up the string "s"
+ * into lines, and appends those lines it to builtinConfig.
+ */
+
+static void
+AppendToList(const char *s, const char ***list, int *lines)
+{
+ char *str, *newstr, *p;
+
+ str = xnfstrdup(s);
+ for (p = strtok(str, "\n"); p; p = strtok(NULL, "\n")) {
+ (*lines)++;
+ *list = xnfrealloc(*list, (*lines + 1) * sizeof(**list));
+ newstr = xnfalloc(strlen(p) + 2);
+ strcpy(newstr, p);
+ strcat(newstr, "\n");
+ (*list)[*lines - 1] = newstr;
+ (*list)[*lines] = NULL;
+ }
+ xfree(str);
+}
+
+static void
+FreeList(const char ***list, int *lines)
+{
+ int i;
+
+ for (i = 0; i < *lines; i++) {
+ if ((*list)[i])
+ xfree((*list)[i]);
+ }
+ xfree(*list);
+ *list = NULL;
+ *lines = 0;
+}
+
+static void
+FreeConfig(void)
+{
+ FreeList(&builtinConfig, &builtinLines);
+}
+
+static void
+AppendToConfig(const char *s)
+{
+ AppendToList(s, &builtinConfig, &builtinLines);
+}
+
+Bool
+xf86AutoConfig(void)
+{
+ const char **p;
+ char buf[1024];
+ pciVideoPtr *pciptr, info = NULL;
+ char *driver = NULL;
+ FILE *gp = NULL;
+ ConfigStatus ret;
+
+ /* Find the primary device, and get some information about it. */
+ if (xf86PciVideoInfo) {
+ for (pciptr = xf86PciVideoInfo; (info = *pciptr); pciptr++) {
+ if (xf86IsPrimaryPci(info)) {
+ break;
+ }
+ }
+ if (!info) {
+ ErrorF("Primary device is not PCI\n");
+ }
+ } else {
+ ErrorF("xf86PciVideoInfo is not set\n");
+ }
+
+ if (info) {
+ char *tmp;
+ char *path = NULL, *a, *b;
+ char *searchPath = NULL;
+
+ /*
+ * Look for the getconfig program first in the xf86ModulePath
+ * directories, then in GETCONFIG_DIR, then in BINDIR. If it
+ * isn't found in any of those locations, just use the normal
+ * search path.
+ */
+
+ if (xf86ModulePath) {
+ a = xnfstrdup(xf86ModulePath);
+ b = strtok(a, ",");
+ while (b) {
+ path = xnfrealloc(path,
+ strlen(b) + 1 + strlen(GET_CONFIG_CMD) + 1);
+ sprintf(path, "%s/%s", b, GET_CONFIG_CMD);
+ if (access(path, X_OK) == 0)
+ break;
+ b = strtok(NULL, ",");
+ }
+ if (!b) {
+ xfree(path);
+ path = NULL;
+ }
+ xfree(a);
+ }
+
+ if (!path) {
+ path = xnfstrdup(GETCONFIG_DIR "/" GET_CONFIG_CMD);
+ if (access(path, X_OK) != 0) {
+ xfree(path);
+ path = NULL;
+ }
+ }
+
+#ifdef BINDIR
+ if (!path) {
+ path = xnfstrdup(BINDIR "/" GET_CONFIG_CMD);
+ if (access(path, X_OK) != 0) {
+ xfree(path);
+ path = NULL;
+ }
+ }
+#endif
+
+ if (!path)
+ path = xnfstrdup(GET_CONFIG_CMD);
+
+ /*
+ * Build up the config file directory search path:
+ *
+ * /etc/X11
+ * PROJECTROOT/etc/X11
+ * xf86ModulePath
+ * PROJECTROOT/lib/X11/getconfig (GETCONFIG_DIR)
+ */
+
+ searchPath = xnfalloc(strlen("/etc/X11") + 1 +
+ strlen(PROJECTROOT "/etc/X11") + 1 +
+ (xf86ModulePath ? strlen(xf86ModulePath) : 0)
+ + 1 +
+ strlen(GETCONFIG_DIR) + 1);
+ strcpy(searchPath, "/etc/X11," PROJECTROOT "/etc/X11,");
+ if (xf86ModulePath && *xf86ModulePath) {
+ strcat(searchPath, xf86ModulePath);
+ strcat(searchPath, ",");
+ }
+ strcat(searchPath, GETCONFIG_DIR);
+
+ ErrorF("xf86AutoConfig: Primary PCI is %d:%d:%d\n",
+ info->bus, info->device, info->func);
+
+ snprintf(buf, sizeof(buf), "%s"
+#ifdef DEBUG
+ " -D"
+#endif
+ " -X %d"
+ " -I %s"
+ " -v 0x%04x -d 0x%04x -r 0x%02x -s 0x%04x"
+ " -b 0x%04x -c 0x%04x",
+ path,
+ (unsigned int)xorgGetVersion(),
+ searchPath,
+ info->vendor, info->chipType, info->chipRev,
+ info->subsysVendor, info->subsysCard,
+ info->class << 8 | info->subclass);
+ ErrorF("Running \"%s\"\n", buf);
+ gp = Popen(buf, "r");
+ if (gp) {
+ if (fgets(buf, sizeof(buf) - 1, gp)) {
+ buf[strlen(buf) - 1] = '\0';
+ tmp = strtok(buf, GETCONFIG_WHITESPACE);
+ if (tmp)
+ driver = xnfstrdup(tmp);
+ }
+ }
+ xfree(path);
+ xfree(searchPath);
+ }
+
+ AppendToConfig(BUILTIN_MODULE_SECTION);
+ AppendToConfig(BUILTIN_MONITOR_SECTION);
+
+ if (driver) {
+ snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION_PRE,
+ driver, 0, driver);
+ AppendToConfig(buf);
+ ErrorF("New driver is \"%s\"\n", driver);
+ buf[0] = '\t';
+ while (fgets(buf + 1, sizeof(buf) - 2, gp)) {
+ AppendToConfig(buf);
+ ErrorF("Extra line: %s", buf);
+ }
+ AppendToConfig(BUILTIN_DEVICE_SECTION_POST);
+ snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION,
+ driver, 0, driver, 0);
+ AppendToConfig(buf);
+ }
+
+ if (gp)
+ Pclose(gp);
+
+ for (p = deviceList; *p; p++) {
+ snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION, *p, 0, *p);
+ AppendToConfig(buf);
+ snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION, *p, 0, *p, 0);
+ AppendToConfig(buf);
+ }
+
+ AppendToConfig(BUILTIN_LAYOUT_SECTION_PRE);
+ if (driver) {
+ snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, driver, 0);
+ AppendToConfig(buf);
+ }
+ for (p = deviceList; *p; p++) {
+ snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, *p, 0);
+ AppendToConfig(buf);
+ }
+ AppendToConfig(BUILTIN_LAYOUT_SECTION_POST);
+
+#ifdef BUILTIN_EXTRA
+ AppendToConfig(BUILTIN_EXTRA);
+#endif
+
+ if (driver)
+ xfree(driver);
+
+ xf86MsgVerb(X_DEFAULT, 0,
+ "Using default built-in configuration (%d lines)\n",
+ builtinLines);
+
+ xf86MsgVerb(X_DEFAULT, 3, "--- Start of built-in configuration ---\n");
+ for (p = builtinConfig; *p; p++)
+ xf86ErrorFVerb(3, "\t%s", *p);
+ xf86MsgVerb(X_DEFAULT, 3, "--- End of built-in configuration ---\n");
+
+ xf86setBuiltinConfig(builtinConfig);
+ ret = xf86HandleConfigFile(TRUE);
+ FreeConfig();
+ switch(ret) {
+ case CONFIG_OK:
+ return TRUE;
+ default:
+ xf86Msg(X_ERROR, "Error parsing the built-in default configuration.\n");
+ return FALSE;
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Bus.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Bus.c
new file mode 100644
index 000000000..e0cc4dd65
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Bus.c
@@ -0,0 +1,3317 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Bus.c,v 1.80 2004/02/05 18:24:59 eich Exp $ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#define REDUCER
+/*
+ * This file contains the interfaces to the bus-specific code
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Resources.h"
+
+/* Bus-specific headers */
+
+#include "xf86Bus.h"
+
+#define XF86_OS_PRIVS
+#define NEED_OS_RAC_PROTOS
+#include "xf86_OSproc.h"
+
+#include "xf86RAC.h"
+
+/* Entity data */
+EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */
+int xf86NumEntities = 0;
+static int xf86EntityPrivateCount = 0;
+BusAccPtr xf86BusAccInfo = NULL;
+
+xf86AccessRec AccessNULL = {NULL,NULL,NULL};
+
+xf86CurrentAccessRec xf86CurrentAccess = {NULL,NULL};
+
+BusRec primaryBus = { BUS_NONE, {{0}}};
+
+Bool xf86ResAccessEnter = FALSE;
+
+#ifdef REDUCER
+/* Resources that temporarily conflict with estimated resources */
+static resPtr AccReducers = NULL;
+#endif
+
+/* resource lists */
+resPtr Acc = NULL;
+resPtr osRes = NULL;
+
+/* allocatable ranges */
+resPtr ResRange = NULL;
+
+/* predefined special resources */
+resRange resVgaExclusive[] = {_VGA_EXCLUSIVE, _END};
+resRange resVgaShared[] = {_VGA_SHARED, _END};
+resRange resVgaMemShared[] = {_VGA_SHARED_MEM,_END};
+resRange resVgaIoShared[] = {_VGA_SHARED_IO,_END};
+resRange resVgaUnusedExclusive[] = {_VGA_EXCLUSIVE_UNUSED, _END};
+resRange resVgaUnusedShared[] = {_VGA_SHARED_UNUSED, _END};
+resRange resVgaSparseExclusive[] = {_VGA_EXCLUSIVE_SPARSE, _END};
+resRange resVgaSparseShared[] = {_VGA_SHARED_SPARSE, _END};
+resRange res8514Exclusive[] = {_8514_EXCLUSIVE, _END};
+resRange res8514Shared[] = {_8514_SHARED, _END};
+
+/* Flag: do we need RAC ? */
+static Bool needRAC = FALSE;
+static Bool doFramebufferMode = FALSE;
+
+/* state change notification callback list */
+static StateChangeNotificationPtr StateChangeNotificationList;
+static void notifyStateChange(xf86NotifyState state);
+
+#undef MIN
+#define MIN(x,y) ((x<y)?x:y)
+
+
+/*
+ * Call the bus probes relevant to the architecture.
+ *
+ * The only one available so far is for PCI and SBUS.
+ */
+
+void
+xf86BusProbe(void)
+{
+ xf86PciProbe();
+#if defined(__sparc__) && !defined(__OpenBSD__)
+ xf86SbusProbe();
+#endif
+}
+
+/*
+ * Determine what bus type the busID string represents. The start of the
+ * bus-dependent part of the string is returned as retID.
+ */
+
+BusType
+StringToBusType(const char* busID, const char **retID)
+{
+ char *p, *s;
+ BusType ret = BUS_NONE;
+
+ /* If no type field, Default to PCI */
+ if (isdigit(busID[0])) {
+ if (retID)
+ *retID = busID;
+ return BUS_PCI;
+ }
+
+ s = xstrdup(busID);
+ p = strtok(s, ":");
+ if (p == NULL || *p == 0) {
+ xfree(s);
+ return BUS_NONE;
+ }
+ if (!xf86NameCmp(p, "pci") || !xf86NameCmp(p, "agp"))
+ ret = BUS_PCI;
+ if (!xf86NameCmp(p, "isa"))
+ ret = BUS_ISA;
+ if (!xf86NameCmp(p, "sbus"))
+ ret = BUS_SBUS;
+ if (ret != BUS_NONE)
+ if (retID)
+ *retID = busID + strlen(p) + 1;
+ xfree(s);
+ return ret;
+}
+
+/*
+ * Entity related code.
+ */
+
+void
+xf86EntityInit(void)
+{
+ int i;
+ resPtr *pprev_next;
+ resPtr res;
+ xf86AccessPtr pacc;
+
+ for (i = 0; i < xf86NumEntities; i++)
+ if (xf86Entities[i]->entityInit) {
+ if (xf86Entities[i]->access->busAcc)
+ ((BusAccPtr)xf86Entities[i]->access->busAcc)->set_f
+ (xf86Entities[i]->access->busAcc);
+ pacc = xf86Entities[i]->access->fallback;
+ if (pacc->AccessEnable)
+ pacc->AccessEnable(pacc->arg);
+ xf86Entities[i]->entityInit(i,xf86Entities[i]->private);
+ if (pacc->AccessDisable)
+ pacc->AccessDisable(pacc->arg);
+ /* remove init resources after init is processed */
+ pprev_next = &Acc;
+ res = Acc;
+ while (res) {
+ if (res->res_type & ResInit && (res->entityIndex == i)) {
+ (*pprev_next) = res->next;
+ xfree(res);
+ } else
+ pprev_next = &(res->next);
+ res = (*pprev_next);
+ }
+ }
+}
+
+int
+xf86AllocateEntity(void)
+{
+ xf86NumEntities++;
+ xf86Entities = xnfrealloc(xf86Entities,
+ sizeof(EntityPtr) * xf86NumEntities);
+ xf86Entities[xf86NumEntities - 1] = xnfcalloc(1,sizeof(EntityRec));
+ xf86Entities[xf86NumEntities - 1]->entityPrivates =
+ xnfcalloc(sizeof(DevUnion) * xf86EntityPrivateCount, 1);
+ return (xf86NumEntities - 1);
+}
+
+static void
+EntityEnter(void)
+{
+ int i;
+ xf86AccessPtr pacc;
+
+ for (i = 0; i < xf86NumEntities; i++)
+ if (xf86Entities[i]->entityEnter) {
+ if (xf86Entities[i]->access->busAcc)
+ ((BusAccPtr)xf86Entities[i]->access->busAcc)->set_f
+ (xf86Entities[i]->access->busAcc);
+ pacc = xf86Entities[i]->access->fallback;
+ if (pacc->AccessEnable)
+ pacc->AccessEnable(pacc->arg);
+ xf86Entities[i]->entityEnter(i,xf86Entities[i]->private);
+ if (pacc->AccessDisable)
+ pacc->AccessDisable(pacc->arg);
+ }
+}
+
+static void
+EntityLeave(void)
+{
+ int i;
+ xf86AccessPtr pacc;
+
+ for (i = 0; i < xf86NumEntities; i++)
+ if (xf86Entities[i]->entityLeave) {
+ if (xf86Entities[i]->access->busAcc)
+ ((BusAccPtr)xf86Entities[i]->access->busAcc)->set_f
+ (xf86Entities[i]->access->busAcc);
+ pacc = xf86Entities[i]->access->fallback;
+ if (pacc->AccessEnable)
+ pacc->AccessEnable(pacc->arg);
+ xf86Entities[i]->entityLeave(i,xf86Entities[i]->private);
+ if (pacc->AccessDisable)
+ pacc->AccessDisable(pacc->arg);
+ }
+}
+
+Bool
+xf86IsEntityPrimary(int entityIndex)
+{
+ EntityPtr pEnt = xf86Entities[entityIndex];
+
+ if (primaryBus.type != pEnt->busType) return FALSE;
+
+ switch (pEnt->busType) {
+ case BUS_PCI:
+ return (pEnt->pciBusId.bus == primaryBus.id.pci.bus &&
+ pEnt->pciBusId.device == primaryBus.id.pci.device &&
+ pEnt->pciBusId.func == primaryBus.id.pci.func);
+ case BUS_ISA:
+ return TRUE;
+ case BUS_SBUS:
+ return (pEnt->sbusBusId.fbNum == primaryBus.id.sbus.fbNum);
+ default:
+ return FALSE;
+ }
+}
+
+Bool
+xf86SetEntityFuncs(int entityIndex, EntityProc init, EntityProc enter,
+ EntityProc leave, pointer private)
+{
+ if (entityIndex >= xf86NumEntities)
+ return FALSE;
+ xf86Entities[entityIndex]->entityInit = init;
+ xf86Entities[entityIndex]->entityEnter = enter;
+ xf86Entities[entityIndex]->entityLeave = leave;
+ xf86Entities[entityIndex]->private = private;
+ return TRUE;
+}
+
+Bool
+xf86DriverHasEntities(DriverPtr drvp)
+{
+ int i;
+ for (i = 0; i < xf86NumEntities; i++) {
+ if (xf86Entities[i]->driver == drvp)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void
+xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)
+{
+ if (entityIndex == -1)
+ return;
+ if (xf86Entities[entityIndex]->inUse &&
+ !(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL))
+ FatalError("Requested Entity already in use!\n");
+
+ pScrn->numEntities++;
+ pScrn->entityList = xnfrealloc(pScrn->entityList,
+ pScrn->numEntities * sizeof(int));
+ pScrn->entityList[pScrn->numEntities - 1] = entityIndex;
+ xf86Entities[entityIndex]->access->next = pScrn->access;
+ pScrn->access = xf86Entities[entityIndex]->access;
+ xf86Entities[entityIndex]->inUse = TRUE;
+ pScrn->entityInstanceList = xnfrealloc(pScrn->entityInstanceList,
+ pScrn->numEntities * sizeof(int));
+ pScrn->entityInstanceList[pScrn->numEntities - 1] = 0;
+ pScrn->domainIOBase = xf86Entities[entityIndex]->domainIO;
+}
+
+void
+xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex, int instance)
+{
+ int i;
+
+ if (entityIndex == -1 || entityIndex >= xf86NumEntities)
+ return;
+
+ for (i = 0; i < pScrn->numEntities; i++) {
+ if (pScrn->entityList[i] == entityIndex) {
+ pScrn->entityInstanceList[i] = instance;
+ break;
+ }
+ }
+}
+
+/*
+ * XXX This needs to be updated for the case where a single entity may have
+ * instances associated with more than one screen.
+ */
+ScrnInfoPtr
+xf86FindScreenForEntity(int entityIndex)
+{
+ int i,j;
+
+ if (entityIndex == -1) return NULL;
+
+ if (xf86Screens) {
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (j = 0; j < xf86Screens[i]->numEntities; j++) {
+ if ( xf86Screens[i]->entityList[j] == entityIndex )
+ return (xf86Screens[i]);
+ }
+ }
+ }
+ return NULL;
+}
+
+void
+xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex)
+{
+ int i;
+ EntityAccessPtr *ptr = (EntityAccessPtr *)&pScrn->access;
+ EntityAccessPtr peacc;
+
+ for (i = 0; i < pScrn->numEntities; i++) {
+ if (pScrn->entityList[i] == entityIndex) {
+ peacc = xf86Entities[pScrn->entityList[i]]->access;
+ (*ptr) = peacc->next;
+ /* disable entity: call disable func */
+ if (peacc->pAccess && peacc->pAccess->AccessDisable)
+ peacc->pAccess->AccessDisable(peacc->pAccess->arg);
+ /* also disable fallback - just in case */
+ if (peacc->fallback && peacc->fallback->AccessDisable)
+ peacc->fallback->AccessDisable(peacc->fallback->arg);
+ for (i++; i < pScrn->numEntities; i++)
+ pScrn->entityList[i-1] = pScrn->entityList[i];
+ pScrn->numEntities--;
+ xf86Entities[entityIndex]->inUse = FALSE;
+ break;
+ }
+ ptr = &(xf86Entities[pScrn->entityList[i]]->access->next);
+ }
+}
+
+/*
+ * xf86ClearEntitiesForScreen() - called when a screen is deleted
+ * to mark it's entities unused. Called by xf86DeleteScreen().
+ */
+void
+xf86ClearEntityListForScreen(int scrnIndex)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ EntityAccessPtr peacc;
+ int i, entityIndex;
+
+ if (pScrn->entityList == NULL || pScrn->numEntities == 0) return;
+
+ for (i = 0; i < pScrn->numEntities; i++) {
+ entityIndex = pScrn->entityList[i];
+ xf86Entities[entityIndex]->inUse = FALSE;
+ /* disable resource: call the disable function */
+ peacc = xf86Entities[entityIndex]->access;
+ if (peacc->pAccess && peacc->pAccess->AccessDisable)
+ peacc->pAccess->AccessDisable(peacc->pAccess->arg);
+ /* and the fallback function */
+ if (peacc->fallback && peacc->fallback->AccessDisable)
+ peacc->fallback->AccessDisable(peacc->fallback->arg);
+ /* shared resources are only needed when entity is active: remove */
+ xf86DeallocateResourcesForEntity(entityIndex, ResShared);
+ }
+ xfree(pScrn->entityList);
+ xfree(pScrn->entityInstanceList);
+ if (pScrn->CurrentAccess->pIoAccess == (EntityAccessPtr)pScrn->access)
+ pScrn->CurrentAccess->pIoAccess = NULL;
+ if (pScrn->CurrentAccess->pMemAccess == (EntityAccessPtr)pScrn->access)
+ pScrn->CurrentAccess->pMemAccess = NULL;
+ pScrn->entityList = NULL;
+ pScrn->entityInstanceList = NULL;
+}
+
+void
+xf86DeallocateResourcesForEntity(int entityIndex, unsigned long type)
+{
+ resPtr *pprev_next = &Acc;
+ resPtr res = Acc;
+
+ while (res) {
+ if (res->entityIndex == entityIndex &&
+ (type & ResAccMask & res->res_type))
+ {
+ (*pprev_next) = res->next;
+ xfree(res);
+ } else
+ pprev_next = &(res->next);
+ res = (*pprev_next);
+ }
+}
+
+/*
+ * Add an extra device section (GDevPtr) to an entity.
+ */
+
+void
+xf86AddDevToEntity(int entityIndex, GDevPtr dev)
+{
+ EntityPtr pEnt;
+
+ if (entityIndex >= xf86NumEntities)
+ return;
+
+ pEnt = xf86Entities[entityIndex];
+ pEnt->numInstances++;
+ pEnt->devices = xnfrealloc(pEnt->devices,
+ pEnt->numInstances * sizeof(GDevPtr));
+ pEnt->devices[pEnt->numInstances - 1] = dev;
+ dev->claimed = TRUE;
+}
+
+/*
+ * xf86GetEntityInfo() -- This function hands information from the
+ * EntityRec struct to the drivers. The EntityRec structure itself
+ * remains invisible to the driver.
+ */
+EntityInfoPtr
+xf86GetEntityInfo(int entityIndex)
+{
+ EntityInfoPtr pEnt;
+ int i;
+
+ if (entityIndex >= xf86NumEntities)
+ return NULL;
+
+ pEnt = xnfcalloc(1,sizeof(EntityInfoRec));
+ pEnt->index = entityIndex;
+ pEnt->location = xf86Entities[entityIndex]->bus;
+ pEnt->active = xf86Entities[entityIndex]->active;
+ pEnt->chipset = xf86Entities[entityIndex]->chipset;
+ pEnt->resources = xf86Entities[entityIndex]->resources;
+ pEnt->driver = xf86Entities[entityIndex]->driver;
+ if ( (xf86Entities[entityIndex]->devices) &&
+ (xf86Entities[entityIndex]->devices[0]) ) {
+ for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++)
+ if (xf86Entities[entityIndex]->devices[i]->screen == 0)
+ break;
+ pEnt->device = xf86Entities[entityIndex]->devices[i];
+ } else
+ pEnt->device = NULL;
+
+ return pEnt;
+}
+
+int
+xf86GetNumEntityInstances(int entityIndex)
+{
+ if (entityIndex >= xf86NumEntities)
+ return -1;
+
+ return xf86Entities[entityIndex]->numInstances;
+}
+
+GDevPtr
+xf86GetDevFromEntity(int entityIndex, int instance)
+{
+ int i;
+
+ /* We might not use AddDevtoEntity */
+ if ( (!xf86Entities[entityIndex]->devices) ||
+ (!xf86Entities[entityIndex]->devices[0]) )
+ return NULL;
+
+ if (entityIndex >= xf86NumEntities ||
+ instance >= xf86Entities[entityIndex]->numInstances)
+ return NULL;
+
+ for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++)
+ if (xf86Entities[entityIndex]->devices[i]->screen == instance)
+ break;
+ return xf86Entities[entityIndex]->devices[i];
+}
+
+/*
+ * general generic disable function.
+ */
+static void
+disableAccess(void)
+{
+ int i;
+ xf86AccessPtr pacc;
+ EntityAccessPtr peacc;
+
+ /* call disable funcs and reset current access pointer */
+ /* the entity specific access funcs are in an enabled */
+ /* state - driver must restore their state explicitely */
+ for (i = 0; i < xf86NumScreens; i++) {
+ peacc = xf86Screens[i]->CurrentAccess->pIoAccess;
+ while (peacc) {
+ if (peacc->pAccess && peacc->pAccess->AccessDisable)
+ peacc->pAccess->AccessDisable(peacc->pAccess->arg);
+ peacc = peacc->next;
+ }
+ xf86Screens[i]->CurrentAccess->pIoAccess = NULL;
+ peacc = xf86Screens[i]->CurrentAccess->pMemAccess;
+ while (peacc) {
+ if (peacc->pAccess && peacc->pAccess->AccessDisable)
+ peacc->pAccess->AccessDisable(peacc->pAccess->arg);
+ peacc = peacc->next;
+ }
+ xf86Screens[i]->CurrentAccess->pMemAccess = NULL;
+ }
+ /* then call the generic entity disable funcs */
+ for (i = 0; i < xf86NumEntities; i++) {
+ pacc = xf86Entities[i]->access->fallback;
+ if (pacc->AccessDisable)
+ pacc->AccessDisable(pacc->arg);
+ }
+}
+
+static void
+clearAccess(void)
+{
+ int i;
+
+ /* call disable funcs and reset current access pointer */
+ /* the entity specific access funcs are in an enabled */
+ /* state - driver must restore their state explicitely */
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86Screens[i]->CurrentAccess->pIoAccess = NULL;
+ xf86Screens[i]->CurrentAccess->pMemAccess = NULL;
+ }
+
+}
+
+/*
+ * Generic interface to bus specific code - add other buses here
+ */
+
+/*
+ * xf86AccessInit() - set up everything needed for access control
+ * called only once on first server generation.
+ */
+void
+xf86AccessInit(void)
+{
+ initPciState();
+ initPciBusState();
+ DisablePciBusAccess();
+ DisablePciAccess();
+
+ xf86ResAccessEnter = TRUE;
+}
+
+/*
+ * xf86AccessEnter() -- gets called to save the text mode VGA IO
+ * resources when reentering the server after a VT switch.
+ */
+void
+xf86AccessEnter(void)
+{
+ if (xf86ResAccessEnter)
+ return;
+
+ /*
+ * on enter we simply disable routing of special resources
+ * to any bus and let the RAC code to "open" the right bridges.
+ */
+ PciBusStateEnter();
+ DisablePciBusAccess();
+ PciStateEnter();
+ disableAccess();
+ EntityEnter();
+ notifyStateChange(NOTIFY_ENTER);
+ xf86EnterServerState(SETUP);
+ xf86ResAccessEnter = TRUE;
+}
+
+/*
+ * xf86AccessLeave() -- prepares access for and calls the
+ * entityLeave() functions.
+ * xf86AccessLeaveState() --- gets called to restore the
+ * access to the VGA IO resources when switching VT or on
+ * server exit.
+ * This was split to call xf86AccessLeaveState() from
+ * ddxGiveUp().
+ */
+void
+xf86AccessLeave(void)
+{
+ if (!xf86ResAccessEnter)
+ return;
+ notifyStateChange(NOTIFY_LEAVE);
+ disableAccess();
+ DisablePciBusAccess();
+ EntityLeave();
+}
+
+void
+xf86AccessLeaveState(void)
+{
+ if (!xf86ResAccessEnter)
+ return;
+ xf86ResAccessEnter = FALSE;
+ PciStateLeave();
+ PciBusStateLeave();
+}
+
+/*
+ * xf86AccessRestoreState() - Restore the access registers to the
+ * state before X was started. This is handy for framebuffers.
+ */
+static void
+xf86AccessRestoreState(void)
+{
+ if (!xf86ResAccessEnter)
+ return;
+ PciStateLeave();
+ PciBusStateLeave();
+}
+
+/*
+ * xf86EnableAccess() -- enable access to controlled resources.
+ * To reduce latency when switching access the ScrnInfoRec has
+ * a linked list of the EntityAccPtr of all screen entities.
+ */
+/*
+ * switching access needs to be done in te following oder:
+ * disable
+ * 1. disable old entity
+ * 2. reroute bus
+ * 3. enable new entity
+ * Otherwise resources needed for access control might be shadowed
+ * by other resources!
+ */
+#ifdef async
+
+static AsyncQPtr *AsyncQ = NULL;
+ScrnInfoPtr xf86CurrentScreen = NULL;
+
+#define SETUP_Q org = AsyncQ; \
+ AsyncQ = &new;
+
+#define PROCESS_Q xf86CurrentScreen = pScrn;
+ if (!new) AsyncQ = org; \
+ else { \
+ AsyncQPtr tmp_Q; \
+ while (1) {\
+ new->func(new->arg);\
+ if (!(new->next)) {\
+ AsyncQ = org; xfree(new); break; \
+ } \
+ tmp_Q = new->next; \
+ xfree(new); \
+ new = tmp_Q; \
+ } \
+ }
+#else
+#define SETUP_Q
+#define PROCESS_Q
+#endif
+
+void
+xf86EnableAccess(ScrnInfoPtr pScrn)
+{
+ register EntityAccessPtr peAcc = (EntityAccessPtr) pScrn->access;
+ register EntityAccessPtr pceAcc;
+ register xf86AccessPtr pAcc;
+ EntityAccessPtr tmp;
+#ifdef async
+ AsyncQPtr *org, new = NULL;
+#endif
+
+#ifdef DEBUG
+ ErrorF("Enable access %i\n",pScrn->scrnIndex);
+#endif
+
+ /* Entity is not under access control or currently enabled */
+ if (!pScrn->access) {
+ if (pScrn->busAccess) {
+ SETUP_Q;
+ ((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess);
+ PROCESS_Q;
+ }
+ return;
+ }
+
+ switch (pScrn->resourceType) {
+ case IO:
+ pceAcc = pScrn->CurrentAccess->pIoAccess;
+ if (peAcc == pceAcc) {
+ return;
+ }
+ SETUP_Q;
+ if (pScrn->CurrentAccess->pMemAccess == pceAcc)
+ pScrn->CurrentAccess->pMemAccess = NULL;
+ while (pceAcc) {
+ pAcc = pceAcc->pAccess;
+ if ( pAcc && pAcc->AccessDisable)
+ (*pAcc->AccessDisable)(pAcc->arg);
+ pceAcc = pceAcc->next;
+ }
+ if (pScrn->busAccess)
+ ((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess);
+ while (peAcc) {
+ pAcc = peAcc->pAccess;
+ if (pAcc && pAcc->AccessEnable)
+ (*pAcc->AccessEnable)(pAcc->arg);
+ peAcc = peAcc->next;
+ }
+ pScrn->CurrentAccess->pIoAccess = (EntityAccessPtr) pScrn->access;
+ PROCESS_Q;
+ return;
+
+ case MEM_IO:
+ pceAcc = pScrn->CurrentAccess->pIoAccess;
+ if (peAcc != pceAcc) { /* current Io != pAccess */
+ SETUP_Q;
+ tmp = pceAcc;
+ while (pceAcc) {
+ pAcc = pceAcc->pAccess;
+ if (pAcc && pAcc->AccessDisable)
+ (*pAcc->AccessDisable)(pAcc->arg);
+ pceAcc = pceAcc->next;
+ }
+ pceAcc = pScrn->CurrentAccess->pMemAccess;
+ if (peAcc != pceAcc /* current Mem != pAccess */
+ && tmp !=pceAcc) {
+ while (pceAcc) {
+ pAcc = pceAcc->pAccess;
+ if (pAcc && pAcc->AccessDisable)
+ (*pAcc->AccessDisable)(pAcc->arg);
+ pceAcc = pceAcc->next;
+ }
+ }
+ } else { /* current Io == pAccess */
+ pceAcc = pScrn->CurrentAccess->pMemAccess;
+ if (pceAcc == peAcc) { /* current Mem == pAccess */
+ return;
+ }
+ SETUP_Q;
+ while (pceAcc) { /* current Mem != pAccess */
+ pAcc = pceAcc->pAccess;
+ if (pAcc && pAcc->AccessDisable)
+ (*pAcc->AccessDisable)(pAcc->arg);
+ pceAcc = pceAcc->next;
+ }
+ }
+ if (pScrn->busAccess)
+ ((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess);
+ while (peAcc) {
+ pAcc = peAcc->pAccess;
+ if (pAcc && pAcc->AccessEnable)
+ (*pAcc->AccessEnable)(pAcc->arg);
+ peAcc = peAcc->next;
+ }
+ pScrn->CurrentAccess->pMemAccess =
+ pScrn->CurrentAccess->pIoAccess = (EntityAccessPtr) pScrn->access;
+ PROCESS_Q;
+ return;
+
+ case MEM:
+ pceAcc = pScrn->CurrentAccess->pMemAccess;
+ if (peAcc == pceAcc) {
+ return;
+ }
+ SETUP_Q;
+ if (pScrn->CurrentAccess->pIoAccess == pceAcc)
+ pScrn->CurrentAccess->pIoAccess = NULL;
+ while (pceAcc) {
+ pAcc = pceAcc->pAccess;
+ if ( pAcc && pAcc->AccessDisable)
+ (*pAcc->AccessDisable)(pAcc->arg);
+ pceAcc = pceAcc->next;
+ }
+ if (pScrn->busAccess)
+ ((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess);
+ while (peAcc) {
+ pAcc = peAcc->pAccess;
+ if (pAcc && pAcc->AccessEnable)
+ (*pAcc->AccessEnable)(pAcc->arg);
+ peAcc = peAcc->next;
+ }
+ pScrn->CurrentAccess->pMemAccess = (EntityAccessPtr) pScrn->access;
+ PROCESS_Q;
+ return;
+
+ case NONE:
+ if (pScrn->busAccess) {
+ SETUP_Q;
+ ((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess);
+ PROCESS_Q;
+ }
+ return;
+ }
+}
+
+void
+xf86SetCurrentAccess(Bool Enable, ScrnInfoPtr pScrn)
+{
+ EntityAccessPtr pceAcc2 = NULL;
+ register EntityAccessPtr pceAcc = NULL;
+ register xf86AccessPtr pAcc;
+
+
+ switch(pScrn->resourceType) {
+ case IO:
+ pceAcc = pScrn->CurrentAccess->pIoAccess;
+ break;
+ case MEM:
+ pceAcc = pScrn->CurrentAccess->pMemAccess;
+ break;
+ case MEM_IO:
+ pceAcc = pScrn->CurrentAccess->pMemAccess;
+ pceAcc2 = pScrn->CurrentAccess->pIoAccess;
+ break;
+ default:
+ break;
+ }
+
+ while (pceAcc) {
+ pAcc = pceAcc->pAccess;
+ if ( pAcc) {
+ if (!Enable) {
+ if (pAcc->AccessDisable)
+ (*pAcc->AccessDisable)(pAcc->arg);
+ } else {
+ if (pAcc->AccessEnable)
+ (*pAcc->AccessEnable)(pAcc->arg);
+ }
+ }
+ pceAcc = pceAcc->next;
+ if (!pceAcc) {
+ pceAcc = pceAcc2;
+ pceAcc2 = NULL;
+ }
+ }
+}
+
+void
+xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs,
+ xf86SetAccessFuncPtr oldFuncs)
+{
+ AccessFuncPtr rac;
+
+ if (!xf86Entities[pEnt->index]->rac)
+ xf86Entities[pEnt->index]->rac = xnfcalloc(1,sizeof(AccessFuncRec));
+
+ rac = xf86Entities[pEnt->index]->rac;
+
+ if (funcs->mem == funcs->io_mem && funcs->mem && funcs->io)
+ xf86Entities[pEnt->index]->entityProp |= NO_SEPARATE_MEM_FROM_IO;
+ if (funcs->io == funcs->io_mem && funcs->mem && funcs->io)
+ xf86Entities[pEnt->index]->entityProp |= NO_SEPARATE_IO_FROM_MEM;
+
+ rac->mem_new = funcs->mem;
+ rac->io_new = funcs->io;
+ rac->io_mem_new = funcs->io_mem;
+
+ rac->old = oldFuncs;
+}
+
+/*
+ * Conflict checking
+ */
+
+static memType
+getMask(memType val)
+{
+ memType mask = 0;
+ memType tmp = 0;
+
+ mask=~mask;
+ tmp = ~((~tmp) >> 1);
+
+ while (!(val & tmp)) {
+ mask = mask >> 1;
+ val = val << 1;
+ }
+ return mask;
+}
+
+/*
+ * checkConflictBlock() -- check for conflicts of a block resource range.
+ * If conflict is found return end of conflicting range. Else return 0.
+ */
+static memType
+checkConflictBlock(resRange *range, resPtr pRes)
+{
+ memType val,tmp,prev;
+ int i;
+
+ switch (pRes->res_type & ResExtMask) {
+ case ResBlock:
+ if (range->rBegin < pRes->block_end &&
+ range->rEnd > pRes->block_begin) {
+#ifdef DEBUG
+ ErrorF("b-b conflict w: %lx %lx\n",
+ pRes->block_begin,pRes->block_end);
+#endif
+ return pRes->block_end < range->rEnd ?
+ pRes->block_end : range->rEnd;
+ }
+ return 0;
+ case ResSparse:
+ if (pRes->sparse_base > range->rEnd) return 0;
+
+ val = (~pRes->sparse_mask | pRes->sparse_base) & getMask(range->rEnd);
+#ifdef DEBUG
+ ErrorF("base = 0x%lx, mask = 0x%lx, begin = 0x%lx, end = 0x%lx ,"
+ "val = 0x%lx\n",
+ pRes->sparse_base, pRes->sparse_mask, range->rBegin,
+ range->rEnd, val);
+#endif
+ i = sizeof(memType) * 8;
+ tmp = prev = pRes->sparse_base;
+
+ while (i) {
+ tmp |= 1<< (--i) & val;
+ if (tmp > range->rEnd)
+ tmp = prev;
+ else
+ prev = tmp;
+ }
+ if (tmp >= range->rBegin) {
+#ifdef DEBUG
+ ErrorF("conflict found at: 0x%lx\n",tmp);
+ ErrorF("b-d conflict w: %lx %lx\n",
+ pRes->sparse_base,pRes->sparse_mask);
+#endif
+ return tmp;
+ }
+ else
+ return 0;
+ }
+ return 0;
+}
+
+/*
+ * checkConflictSparse() -- check for conflicts of a sparse resource range.
+ * If conflict is found return base of conflicting region. Else return 0.
+ */
+#define mt_max ~(memType)0
+#define length sizeof(memType) * 8
+static memType
+checkConflictSparse(resRange *range, resPtr pRes)
+{
+ memType val, tmp, prev;
+ int i;
+
+ switch (pRes->res_type & ResExtMask) {
+ case ResSparse:
+ tmp = pRes->sparse_mask & range->rMask;
+ if ((tmp & pRes->sparse_base) == (tmp & range->rBase)) {
+#ifdef DEBUG
+ ErrorF("s-b conflict w: %lx %lx\n",
+ pRes->sparse_base,pRes->sparse_mask);
+#endif
+ return pRes->sparse_mask;
+ }
+ return 0;
+
+ case ResBlock:
+ if (pRes->block_end < range->rBase) return 0;
+
+ val = (~range->rMask | range->rBase) & getMask(pRes->block_end);
+ i = length;
+ tmp = prev = range->rBase;
+
+ while (i) {
+#ifdef DEBUG
+ ErrorF("tmp = 0x%lx\n",tmp);
+#endif
+ tmp |= 1<< (--i) & val;
+ if (tmp > pRes->block_end)
+ tmp = prev;
+ else
+ prev = tmp;
+ }
+ if (tmp < pRes->block_begin)
+ return 0;
+ else {
+ /*
+ * now we subdivide the block region in sparse regions
+ * with base values = 2^n and find the smallest mask.
+ * This might be done in a simpler way....
+ */
+ memType mask, m_mask = 0, base = pRes->block_begin;
+ int i;
+ while (base < pRes->block_end) {
+ for (i = 1; i < length; i++)
+ if ( base != (base & (mt_max << i))) break;
+ mask = mt_max >> (length - i);
+ do mask >>= 1;
+ while ((mask + base + 1) > pRes->block_end);
+ /* m_mask and are _inverted_ sparse masks */
+ m_mask = mask > m_mask ? mask : m_mask;
+ base = base + mask + 1;
+ }
+#ifdef DEBUG
+ ErrorF("conflict found at: 0x%lx\n",tmp);
+ ErrorF("b-b conflict w: %lx %lx\n",
+ pRes->block_begin,pRes->block_end);
+#endif
+ return ~m_mask;
+ }
+ }
+ return 0;
+}
+#undef mt_max
+#undef length
+
+/*
+ * needCheck() -- this function decides whether to check for conflicts
+ * depending on the types of the resource ranges and their locations
+ */
+static Bool
+needCheck(resPtr pRes, unsigned long type, int entityIndex, xf86State state)
+{
+ /* the same entity shouldn't conflict with itself */
+ ScrnInfoPtr pScrn;
+ int i;
+ BusType loc = BUS_NONE;
+ BusType r_loc = BUS_NONE;
+
+ /* Ignore overlapped ranges that have been nullified */
+ if ((pRes->res_type & ResOverlap) && (pRes->block_begin > pRes->block_end))
+ return FALSE;
+
+ if ((pRes->res_type & ResTypeMask) != (type & ResTypeMask))
+ return FALSE;
+
+ /*
+ * Resources set by BIOS (ResBios) are allowed to conflict
+ * with resources marked (ResBios).
+ */
+ if (pRes->res_type & type & ResBios)
+ return FALSE;
+
+ /*If requested, skip over estimated resources */
+ if (pRes->res_type & type & ResEstimated)
+ return FALSE;
+
+ if (type & pRes->res_type & ResUnused)
+ return FALSE;
+
+ if (state == OPERATING) {
+ if (type & ResDisableOpr || pRes->res_type & ResDisableOpr)
+ return FALSE;
+ if (type & pRes->res_type & ResUnusedOpr) return FALSE;
+ /*
+ * Maybe we should have ResUnused set The resUnusedOpr
+ * bit, too. This way we could avoid this confusion
+ */
+ if ((type & ResUnusedOpr && pRes->res_type & ResUnused) ||
+ (type & ResUnused && pRes->res_type & ResUnusedOpr))
+ return FALSE;
+ }
+
+ if (entityIndex > -1)
+ loc = xf86Entities[entityIndex]->busType;
+ if (pRes->entityIndex > -1)
+ r_loc = xf86Entities[pRes->entityIndex]->busType;
+
+ switch (type & ResAccMask) {
+ case ResExclusive:
+ switch (pRes->res_type & ResAccMask) {
+ case ResExclusive:
+ break;
+ case ResShared:
+ /* ISA buses are only locally exclusive on a PCI system */
+ if (loc == BUS_ISA && r_loc == BUS_PCI)
+ return FALSE;
+ break;
+ }
+ break;
+ case ResShared:
+ switch (pRes->res_type & ResAccMask) {
+ case ResExclusive:
+ /* ISA buses are only locally exclusive on a PCI system */
+ if (loc == BUS_PCI && r_loc == BUS_ISA)
+ return FALSE;
+ break;
+ case ResShared:
+ return FALSE;
+ }
+ break;
+ case ResAny:
+ break;
+ }
+
+ if (pRes->entityIndex == entityIndex) return FALSE;
+
+ if (pRes->entityIndex > -1 &&
+ (pScrn = xf86FindScreenForEntity(entityIndex))) {
+ for (i = 0; i < pScrn->numEntities; i++)
+ if (pScrn->entityList[i] == pRes->entityIndex) return FALSE;
+ }
+ return TRUE;
+}
+
+/*
+ * checkConflict() - main conflict checking function which all other
+ * function call.
+ */
+static memType
+checkConflict(resRange *rgp, resPtr pRes, int entityIndex,
+ xf86State state, Bool ignoreIdentical)
+{
+ memType ret;
+
+ while(pRes) {
+ if (!needCheck(pRes,rgp->type, entityIndex ,state)) {
+ pRes = pRes->next;
+ continue;
+ }
+ switch (rgp->type & ResExtMask) {
+ case ResBlock:
+ if (rgp->rEnd < rgp->rBegin) {
+ xf86Msg(X_ERROR,"end of block range 0x%lx < begin 0x%lx\n",
+ rgp->rEnd,rgp->rBegin);
+ return 0;
+ }
+ if ((ret = checkConflictBlock(rgp, pRes))) {
+ if (!ignoreIdentical || (rgp->rBegin != pRes->block_begin)
+ || (rgp->rEnd != pRes->block_end))
+ return ret;
+ }
+ break;
+ case ResSparse:
+ if ((rgp->rBase & rgp->rMask) != rgp->rBase) {
+ xf86Msg(X_ERROR,"sparse io range (base: 0x%lx mask: 0x%lx)"
+ "doesn't satisfy (base & mask = mask)\n",
+ rgp->rBase, rgp->rMask);
+ return 0;
+ }
+ if ((ret = checkConflictSparse(rgp, pRes))) {
+ if (!ignoreIdentical || (rgp->rBase != pRes->sparse_base)
+ || (rgp->rMask != pRes->sparse_mask))
+ return ret;
+ }
+ break;
+ }
+ pRes = pRes->next;
+ }
+ return 0;
+}
+
+/*
+ * ChkConflict() -- used within xxxBus ; find conflict with any location.
+ */
+memType
+ChkConflict(resRange *rgp, resPtr res, xf86State state)
+{
+ return checkConflict(rgp, res, -2, state,FALSE);
+}
+
+/*
+ * xf86ChkConflict() - This function is the low level interface to
+ * the resource broker that gets exported. Tests all resources ie.
+ * performs test with SETUP flag.
+ */
+memType
+xf86ChkConflict(resRange *rgp, int entityIndex)
+{
+ return checkConflict(rgp, Acc, entityIndex, SETUP,FALSE);
+}
+
+/*
+ * Resources List handling
+ */
+
+resPtr
+xf86JoinResLists(resPtr rlist1, resPtr rlist2)
+{
+ resPtr pRes;
+
+ if (!rlist1)
+ return rlist2;
+
+ if (!rlist2)
+ return rlist1;
+
+ for (pRes = rlist1; pRes->next; pRes = pRes->next)
+ ;
+ pRes->next = rlist2;
+ return rlist1;
+}
+
+resPtr
+xf86AddResToList(resPtr rlist, resRange *range, int entityIndex)
+{
+ resPtr new;
+
+ switch (range->type & ResExtMask) {
+ case ResBlock:
+ if (range->rEnd < range->rBegin) {
+ xf86Msg(X_ERROR,"end of block range 0x%lx < begin 0x%lx\n",
+ range->rEnd,range->rBegin);
+ return rlist;
+ }
+ break;
+ case ResSparse:
+ if ((range->rBase & range->rMask) != range->rBase) {
+ xf86Msg(X_ERROR,"sparse io range (base: 0x%lx mask: 0x%lx)"
+ "doesn't satisfy (base & mask = mask)\n",
+ range->rBase, range->rMask);
+ return rlist;
+ }
+ break;
+ }
+
+ new = xnfalloc(sizeof(resRec));
+ /*
+ * Only background resources may be registered with ResBios
+ * and ResEstimated set. Other resources only set it for
+ * testing.
+ */
+ if (entityIndex != (-1))
+ range->type &= ~(ResBios | ResEstimated);
+ new->val = *range;
+ new->entityIndex = entityIndex;
+ new->next = rlist;
+ return new;
+}
+
+void
+xf86FreeResList(resPtr rlist)
+{
+ resPtr pRes;
+
+ if (!rlist)
+ return;
+
+ for (pRes = rlist->next; pRes; rlist = pRes, pRes = pRes->next)
+ xfree(rlist);
+ xfree(rlist);
+}
+
+resPtr
+xf86DupResList(const resPtr rlist)
+{
+ resPtr pRes, ret, prev, new;
+
+ if (!rlist)
+ return NULL;
+
+ ret = xnfalloc(sizeof(resRec));
+ *ret = *rlist;
+ prev = ret;
+ for (pRes = rlist->next; pRes; pRes = pRes->next) {
+ new = xnfalloc(sizeof(resRec));
+ *new = *pRes;
+ prev->next = new;
+ prev = new;
+ }
+ return ret;
+}
+
+void
+xf86PrintResList(int verb, resPtr list)
+{
+ int i = 0;
+ const char *s, *r;
+ resPtr tmp = list;
+ unsigned long type;
+
+ if (!list)
+ return;
+
+ type = ResMem;
+ r = "M";
+ while (1) {
+ while (list) {
+ if ((list->res_type & ResPhysMask) == type) {
+ switch (list->res_type & ResExtMask) {
+ case ResBlock:
+ xf86ErrorFVerb(verb,
+ "\t[%d] %d\t%ld\t0x%08lx - 0x%08lx (0x%lx)",
+ i, list->entityIndex,
+ (list->res_type & ResDomain) >> 24,
+ list->block_begin, list->block_end,
+ list->block_end - list->block_begin + 1);
+ break;
+ case ResSparse:
+ xf86ErrorFVerb(verb, "\t[%d] %d\t%ld\t0x%08lx - 0x%08lx ",
+ i, list->entityIndex,
+ (list->res_type & ResDomain) >> 24,
+ list->sparse_base,list->sparse_mask);
+ break;
+ default:
+ list = list->next;
+ continue;
+ }
+ xf86ErrorFVerb(verb, " %s", r);
+ switch (list->res_type & ResAccMask) {
+ case ResExclusive:
+ if (list->res_type & ResUnused)
+ s = "x";
+ else
+ s = "X";
+ break;
+ case ResShared:
+ if (list->res_type & ResUnused)
+ s = "s";
+ else
+ s = "S";
+ break;
+ default:
+ s = "?";
+ }
+ xf86ErrorFVerb(verb, "%s", s);
+ switch (list->res_type & ResExtMask) {
+ case ResBlock:
+ s = "[B]";
+ break;
+ case ResSparse:
+ s = "[S]";
+ break;
+ default:
+ s = "[?]";
+ }
+ xf86ErrorFVerb(verb, "%s", s);
+ if (list->res_type & ResEstimated)
+ xf86ErrorFVerb(verb, "E");
+ if (list->res_type & ResOverlap)
+ xf86ErrorFVerb(verb, "O");
+ if (list->res_type & ResInit)
+ xf86ErrorFVerb(verb, "t");
+ if (list->res_type & ResBios)
+ xf86ErrorFVerb(verb, "(B)");
+ if (list->res_type & ResBus)
+ xf86ErrorFVerb(verb, "(b)");
+ if (list->res_type & ResOprMask) {
+ switch (list->res_type & ResOprMask) {
+ case ResUnusedOpr:
+ s = "(OprU)";
+ break;
+ case ResDisableOpr:
+ s = "(OprD)";
+ break;
+ default:
+ s = "(Opr?)";
+ break;
+ }
+ xf86ErrorFVerb(verb, "%s", s);
+ }
+ xf86ErrorFVerb(verb, "\n");
+ i++;
+ }
+ list = list->next;
+ }
+ if (type == ResIo) break;
+ type = ResIo;
+ r = "I";
+ list = tmp;
+ }
+}
+
+resPtr
+xf86AddRangesToList(resPtr list, resRange *pRange, int entityIndex)
+{
+ while(pRange && pRange->type != ResEnd) {
+ list = xf86AddResToList(list,pRange,entityIndex);
+ pRange++;
+ }
+ return list;
+}
+
+void
+xf86ResourceBrokerInit(void)
+{
+ resPtr resPci;
+
+ osRes = NULL;
+
+ /* Get the addressable ranges */
+ ResRange = xf86BusAccWindowsFromOS();
+ xf86MsgVerb(X_INFO, 3, "Addressable bus resource ranges are\n");
+ xf86PrintResList(3, ResRange);
+
+ /* Get the ranges used exclusively by the system */
+ osRes = xf86AccResFromOS(osRes);
+ xf86MsgVerb(X_INFO, 3, "OS-reported resource ranges:\n");
+ xf86PrintResList(3, osRes);
+
+ /* Bus dep initialization */
+ resPci = ResourceBrokerInitPci(&osRes);
+ Acc = xf86JoinResLists(xf86DupResList(osRes), resPci);
+
+ xf86MsgVerb(X_INFO, 3, "All system resource ranges:\n");
+ xf86PrintResList(3, Acc);
+
+}
+
+#define MEM_ALIGN (1024 * 1024)
+
+/*
+ * RemoveOverlaps() -- remove overlaps between resources of the
+ * same kind.
+ * Beware: This function doesn't check for access attributes.
+ * At resource broker initialization this is no problem as this
+ * only deals with exclusive resources.
+ */
+#if 0
+void
+RemoveOverlaps(resPtr target, resPtr list, Bool pow2Alignment, Bool useEstimated)
+{
+ resPtr pRes;
+ memType size, newsize, adjust;
+
+ if (!target)
+ return;
+
+ for (pRes = list; pRes; pRes = pRes->next) {
+ if (pRes != target
+ && ((pRes->res_type & ResTypeMask) ==
+ (target->res_type & ResTypeMask))
+ && pRes->block_begin <= target->block_end
+ && pRes->block_end >= target->block_begin) {
+ /* Possibly ignore estimated resources */
+ if (!useEstimated && (pRes->res_type & ResEstimated)) continue;
+ /*
+ * Target should be a larger region than pRes. If pRes fully
+ * contains target, don't do anything unless target can overlap.
+ */
+ if (pRes->block_begin <= target->block_begin &&
+ pRes->block_end >= target->block_end) {
+ if (target->res_type & ResOverlap) {
+ /* Nullify range but keep its ResOverlap bit on */
+ target->block_end = target->block_begin - 1;
+ return;
+ }
+ continue;
+ }
+ /*
+ * In cases where the target and pRes have the same starting
+ * address, reduce the size of the target (given it's an estimate).
+ */
+ if (pRes->block_begin == target->block_begin) {
+ if (target->res_type & ResOverlap)
+ target->block_end = target->block_begin - 1;
+ else
+ target->block_end = pRes->block_end;
+ }
+ /* Otherwise, trim target to remove the overlap */
+ else if (pRes->block_begin <= target->block_end) {
+ target->block_end = pRes->block_begin - 1;
+ } else if (!pow2Alignment &&
+ pRes->block_end >= target->block_begin) {
+ target->block_begin = pRes->block_end + 1;
+ }
+ if (pow2Alignment) {
+ /*
+ * Align to a power of two. This requires finding the
+ * largest power of two that is smaller than the adjusted
+ * size.
+ */
+ size = target->block_end - target->block_begin + 1;
+ newsize = 1UL << (sizeof(memType) * 8 - 1);
+ while (!(newsize & size))
+ newsize >>= 1;
+ target->block_end = target->block_begin + newsize - 1;
+ } else if (target->block_end > MEM_ALIGN) {
+ /* Align the end to MEM_ALIGN */
+ if ((adjust = (target->block_end + 1) % MEM_ALIGN))
+ target->block_end -= adjust;
+ }
+ }
+ }
+}
+#else
+
+void
+RemoveOverlaps(resPtr target, resPtr list, Bool pow2Alignment, Bool useEstimated)
+{
+ resPtr pRes;
+ memType size, newsize, adjust;
+
+ if (!target)
+ return;
+
+ if (!(target->res_type & ResEstimated) /* Don't touch sure resources */
+ && !(target->res_type & ResOverlap)) /* Unless they may overlap */
+ return;
+
+ for (pRes = list; pRes; pRes = pRes->next) {
+ if (pRes == target
+ || ((pRes->res_type & ResTypeMask) !=
+ (target->res_type & ResTypeMask))
+ || pRes->block_begin > target->block_end
+ || pRes->block_end < target->block_begin)
+ continue;
+
+ if (pRes->block_begin <= target->block_begin) {
+ /* Possibly ignore estimated resources */
+ if (!useEstimated && (pRes->res_type & ResEstimated))
+ continue;
+
+ /* Special cases */
+ if (pRes->block_end >= target->block_end) {
+ /*
+ * If pRes fully contains target, don't do anything
+ * unless target can overlap.
+ */
+ if (target->res_type & ResOverlap) {
+ /* Nullify range but keep its ResOverlap bit on */
+ target->block_end = target->block_begin - 1;
+ return;
+ } else
+ continue;
+ } else {
+#if 0 /* Don't trim start address - we trust what we got */
+ /*
+ * If !pow2Alignment trim start address: !pow2Alingment
+ * is only set when estimated OS addresses are handled.
+ * In cases where the target and pRes have the same
+ * starting address, reduce the size of the target
+ * (given it's an estimate).
+ */
+ if (!pow2Alignment)
+ target->block_begin = pRes->block_end + 1;
+ else
+#endif
+ if (pRes->block_begin == target->block_begin)
+ target->block_end = pRes->block_end;
+ else
+ continue;
+ }
+ } else {
+ /* Trim target to remove the overlap */
+ target->block_end = pRes->block_begin - 1;
+ }
+ if (pow2Alignment) {
+ /*
+ * Align to a power of two. This requires finding the
+ * largest power of two that is smaller than the adjusted
+ * size.
+ */
+ size = target->block_end - target->block_begin + 1;
+ newsize = 1UL << (sizeof(memType) * 8 - 1);
+ while (!(newsize & size))
+ newsize >>= 1;
+ target->block_end = target->block_begin + newsize - 1;
+ } else if (target->block_end > MEM_ALIGN) {
+ /* Align the end to MEM_ALIGN */
+ if ((adjust = (target->block_end + 1) % MEM_ALIGN))
+ target->block_end -= adjust;
+ }
+ }
+}
+
+#endif
+
+/*
+ * Resource request code
+ */
+
+#define ALIGN(x,a) ((x) + a) &~(a)
+
+resRange
+xf86GetBlock(unsigned long type, memType size,
+ memType window_start, memType window_end,
+ memType align_mask, resPtr avoid)
+{
+ memType min, max, tmp;
+ resRange r = {ResEnd,0,0};
+ resPtr res_range = ResRange;
+
+ if (!size) return r;
+ if (window_end < window_start || (window_end - window_start) < (size - 1)) {
+ ErrorF("Requesting insufficient memory window!:"
+ " start: 0x%lx end: 0x%lx size 0x%lx\n",
+ window_start,window_end,size);
+ return r;
+ }
+ type = (type & ~(ResExtMask | ResBios | ResEstimated)) | ResBlock;
+
+ while (res_range) {
+ if ((type & ResTypeMask) == (res_range->res_type & ResTypeMask)) {
+ if (res_range->block_begin > window_start)
+ min = res_range->block_begin;
+ else
+ min = window_start;
+ if (res_range->block_end < window_end)
+ max = res_range->block_end;
+ else
+ max = window_end;
+ min = ALIGN(min,align_mask);
+ /* do not produce an overflow! */
+ while (min < max && (max - min) >= (size - 1)) {
+ RANGE(r,min,min + size - 1,type);
+ tmp = ChkConflict(&r,Acc,SETUP);
+ if (!tmp) {
+ tmp = ChkConflict(&r,avoid,SETUP);
+ if (!tmp) {
+ return r;
+ }
+ }
+ min = ALIGN(tmp,align_mask);
+ }
+ }
+ res_range = res_range->next;
+ }
+ RANGE(r,0,0,ResEnd);
+ return r;
+}
+
+#define mt_max ~(memType)0
+#define length sizeof(memType) * 8
+/*
+ * make_base() -- assign the lowest bits to the bits set in mask.
+ * example: mask 011010 val 0000110 -> 011000
+ */
+static memType
+make_base(memType val, memType mask)
+{
+ int i,j = 0;
+ memType ret = 0
+ ;
+ for (i = 0;i<length;i++) {
+ if ((1 << i) & mask) {
+ ret |= (((val >> j) & 1) << i);
+ j++;
+ }
+ }
+ return ret;
+}
+
+/*
+ * make_base() -- assign the bits set in mask to the lowest bits.
+ * example: mask 011010 , val 010010 -> 000011
+ */
+static memType
+unmake_base(memType val, memType mask)
+{
+ int i,j = 0;
+ memType ret = 0;
+
+ for (i = 0;i<length;i++) {
+ if ((1 << i) & mask) {
+ ret |= (((val >> i) & 1) << j);
+ j++;
+ }
+ }
+ return ret;
+}
+
+static memType
+fix_counter(memType val, memType old_mask, memType mask)
+{
+ mask = old_mask & mask;
+
+ val = make_base(val,old_mask);
+ return unmake_base(val,mask);
+}
+
+resRange
+xf86GetSparse(unsigned long type, memType fixed_bits,
+ memType decode_mask, memType address_mask, resPtr avoid)
+{
+ resRange r = {ResEnd,0,0};
+ memType new_mask;
+ memType mask1;
+ memType base;
+ memType counter = 0;
+ memType counter1;
+ memType max_counter = ~(memType)0;
+ memType max_counter1;
+ memType conflict = 0;
+
+ /* for sanity */
+ type = (type & ~(ResExtMask | ResBios | ResEstimated)) | ResSparse;
+
+ /*
+ * a sparse address consists of 3 parts:
+ * fixed_bits: F bits which hard decoded by the hardware
+ * decode_bits: D bits which are used to decode address
+ * but which may be set by software
+ * address_bits: A bits which are used to address the
+ * sparse range.
+ * the decode_mask marks all decode bits while the address_mask
+ * masks out all address_bits:
+ * F D A
+ * decode_mask: 0 1 0
+ * address_mask: 1 1 0
+ */
+ decode_mask &= address_mask;
+ new_mask = decode_mask;
+
+ /*
+ * We start by setting the decode_mask bits to different values
+ * when a conflict is found the address_mask of the conflicting
+ * resource is returned. We remove those bits from decode_mask
+ * that are also set in the returned address_mask as they always
+ * conflict with resources which use them as address masks.
+ * The resoulting mask is stored in new_mask.
+ * We continue until no conflict is found or until we have
+ * tried all possible settings of new_mask.
+ */
+ while (1) {
+ base = make_base(counter,new_mask) | fixed_bits;
+ RANGE(r,base,address_mask,type);
+ conflict = ChkConflict(&r,Acc,SETUP);
+ if (!conflict) {
+ conflict = ChkConflict(&r,avoid,SETUP);
+ if (!conflict) {
+ return r;
+ }
+ }
+ counter = fix_counter(counter,new_mask,conflict);
+ max_counter = fix_counter(max_counter,new_mask,conflict);
+ new_mask &= conflict;
+ counter ++;
+ if (counter > max_counter) break;
+ }
+ if (!new_mask && (new_mask == decode_mask)) {
+ RANGE(r,0,0,ResEnd);
+ return r;
+ }
+ /*
+ * if we haven't been successful we also try to modify those
+ * bits in decode_mask that are not at the same time set in
+ * new mask. These bits overlap with address_bits of some
+ * resources. If a conflict with a resource of this kind is
+ * found (ie. returned_mask & mask1 != mask1) with
+ * mask1 = decode_mask & ~new_mask we cannot
+ * use our choice of bits in the new_mask part. We try
+ * another choice.
+ */
+ max_counter = fix_counter(mt_max,mt_max,new_mask);
+ mask1 = decode_mask & ~new_mask;
+ max_counter1 = fix_counter(mt_max,mt_max,mask1);
+ counter = 0;
+
+ while (1) {
+ counter1 = 0;
+ while (1) {
+ base = make_base(counter1,mask1);
+ RANGE(r,base,address_mask,type);
+ conflict = ChkConflict(&r,Acc,SETUP);
+ if (!conflict) {
+ conflict = ChkConflict(&r,avoid,SETUP);
+ if (!conflict) {
+ return r;
+ }
+ }
+ counter1 ++;
+ if ((mask1 & conflict) != mask1 || counter1 > max_counter1)
+ break;
+ }
+ counter ++;
+ if (counter > max_counter) break;
+ }
+ RANGE(r,0,0,ResEnd);
+ return r;
+}
+
+#undef length
+#undef mt_max
+
+/*
+ * Resource registrarion
+ */
+
+static resList
+xf86GetResourcesImplicitly(int entityIndex)
+{
+ if (entityIndex >= xf86NumEntities) return NULL;
+
+ switch (xf86Entities[entityIndex]->bus.type) {
+ case BUS_ISA:
+ case BUS_NONE:
+ case BUS_SBUS:
+ return NULL;
+ case BUS_PCI:
+ return GetImplicitPciResources(entityIndex);
+ case BUS_last:
+ return NULL;
+ }
+ return NULL;
+}
+
+static void
+convertRange2Host(int entityIndex, resRange *pRange)
+{
+ if (pRange->type & ResBus) {
+ switch (xf86Entities[entityIndex]->busType) {
+ case BUS_PCI:
+ pciConvertRange2Host(entityIndex,pRange);
+ break;
+ case BUS_ISA:
+ isaConvertRange2Host(pRange);
+ break;
+ default:
+ break;
+ }
+
+ pRange->type &= ~ResBus;
+ }
+}
+
+/*
+ * xf86RegisterResources() -- attempts to register listed resources.
+ * If list is NULL it tries to obtain resources implicitly. Function
+ * returns a resPtr listing all resources not successfully registered.
+ */
+
+resPtr
+xf86RegisterResources(int entityIndex, resList list, unsigned long access)
+{
+ resPtr res = NULL;
+ resRange range;
+ resList list_f = NULL;
+
+ if (!list) {
+ list = xf86GetResourcesImplicitly(entityIndex);
+ /* these resources have to be in host address space already */
+ if (!list) return NULL;
+ list_f = list;
+ }
+
+ while(list->type != ResEnd) {
+ range = *list;
+
+ convertRange2Host(entityIndex,&range);
+
+ if ((access != ResNone) && (access & ResAccMask)) {
+ range.type = (range.type & ~ResAccMask) | (access & ResAccMask);
+ }
+ range.type &= ~ResEstimated; /* Not allowed for drivers */
+#if !((defined(__alpha__) || (defined(__ia64__))) && defined(linux))
+ /* On Alpha Linux, do not check for conflicts, trust the kernel. */
+ if (checkConflict(&range, Acc, entityIndex, SETUP,TRUE))
+ res = xf86AddResToList(res,&range,entityIndex);
+ else
+#endif
+ {
+ Acc = xf86AddResToList(Acc,&range,entityIndex);
+ }
+ list++;
+ }
+ if (list_f)
+ xfree(list_f);
+
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3,"Resources after driver initialization\n");
+ xf86PrintResList(3, Acc);
+ if (res) xf86MsgVerb(X_INFO, 3,
+ "Failed Resources after driver initialization "
+ "for Entity: %i\n",entityIndex);
+ xf86PrintResList(3, res);
+#endif
+ return res;
+
+}
+
+static void
+busTypeSpecific(EntityPtr pEnt, xf86State state, xf86AccessPtr *acc_mem,
+ xf86AccessPtr *acc_io, xf86AccessPtr *acc_mem_io)
+{
+ pciAccPtr *ppaccp;
+
+ switch (pEnt->bus.type) {
+ case BUS_ISA:
+ case BUS_SBUS:
+ *acc_mem = *acc_io = *acc_mem_io = &AccessNULL;
+ break;
+ break;
+ case BUS_PCI:
+ ppaccp = xf86PciAccInfo;
+ while (*ppaccp) {
+ if ((*ppaccp)->busnum == pEnt->pciBusId.bus
+ && (*ppaccp)->devnum == pEnt->pciBusId.device
+ && (*ppaccp)->funcnum == pEnt->pciBusId.func) {
+ *acc_io = &(*ppaccp)->ioAccess;
+ *acc_mem = &(*ppaccp)->memAccess;
+ *acc_mem_io = &(*ppaccp)->io_memAccess;
+ break;
+ }
+ ppaccp++;
+ }
+ break;
+ default:
+ *acc_mem = *acc_io = *acc_mem_io = NULL;
+ break;
+ }
+ return;
+}
+
+static void
+setAccess(EntityPtr pEnt, xf86State state)
+{
+
+ xf86AccessPtr acc_mem, acc_io, acc_mem_io;
+ xf86AccessPtr org_mem = NULL, org_io = NULL, org_mem_io = NULL;
+ int prop;
+
+ busTypeSpecific(pEnt,state,&acc_mem,&acc_io,&acc_mem_io);
+
+ /* The replacement function needs to handle _all_ shared resources */
+ /* unless they are handeled locally and disabled otherwise */
+ if (pEnt->rac) {
+ if (pEnt->rac->io_new) {
+ org_io = acc_io;
+ acc_io = pEnt->rac->io_new;
+ }
+ if (pEnt->rac->mem_new) {
+ org_mem = acc_mem;
+ acc_mem = pEnt->rac->mem_new;
+ }
+ if (pEnt->rac->io_mem_new) {
+ org_mem_io = acc_mem_io;
+ acc_mem_io = pEnt->rac->io_mem_new;
+ }
+ }
+
+ if (state == OPERATING) {
+ prop = pEnt->entityProp;
+ switch(pEnt->entityProp & NEED_SHARED) {
+ case NEED_SHARED:
+ pEnt->access->rt = MEM_IO;
+ break;
+ case NEED_IO_SHARED:
+ pEnt->access->rt = IO;
+ break;
+ case NEED_MEM_SHARED:
+ pEnt->access->rt = MEM;
+ break;
+ default:
+ pEnt->access->rt = NONE;
+ }
+ } else {
+ prop = NEED_SHARED | NEED_MEM | NEED_IO;
+ pEnt->access->rt = MEM_IO;
+ }
+
+ switch(pEnt->access->rt) {
+ case IO:
+ pEnt->access->pAccess = acc_io;
+ break;
+ case MEM:
+ pEnt->access->pAccess = acc_mem;
+ break;
+ case MEM_IO:
+ pEnt->access->pAccess = acc_mem_io;
+ break;
+ default: /* no conflicts at all */
+ pEnt->access->pAccess = NULL; /* remove from RAC */
+ break;
+ }
+
+ if (org_io) {
+ /* does the driver want the old access func? */
+ if (pEnt->rac->old) {
+ /* give it to the driver, leave state disabled */
+ pEnt->rac->old->io = org_io;
+ } else if (org_io->AccessEnable) {
+ /* driver doesn't want it - enable generic access */
+ org_io->AccessEnable(org_io->arg);
+ }
+ }
+
+ if (org_mem_io) {
+ /* does the driver want the old access func? */
+ if (pEnt->rac->old) {
+ /* give it to the driver, leave state disabled */
+ pEnt->rac->old->io_mem = org_mem_io;
+ } else if (org_mem_io->AccessEnable) {
+ /* driver doesn't want it - enable generic access */
+ org_mem_io->AccessEnable(org_mem_io->arg);
+ }
+ }
+
+ if (org_mem) {
+ /* does the driver want the old access func? */
+ if (pEnt->rac->old) {
+ /* give it to the driver, leave state disabled */
+ pEnt->rac->old->mem = org_mem;
+ } else if (org_mem->AccessEnable) {
+ /* driver doesn't want it - enable generic access */
+ org_mem->AccessEnable(org_mem->arg);
+ }
+ }
+
+ if (!(prop & NEED_MEM_SHARED)){
+ if (prop & NEED_MEM) {
+ if (acc_mem && acc_mem->AccessEnable)
+ acc_mem->AccessEnable(acc_mem->arg);
+ } else {
+ if (acc_mem && acc_mem->AccessDisable)
+ acc_mem->AccessDisable(acc_mem->arg);
+ }
+ }
+
+ if (!(prop & NEED_IO_SHARED)) {
+ if (prop & NEED_IO) {
+ if (acc_io && acc_io->AccessEnable)
+ acc_io->AccessEnable(acc_io->arg);
+ } else {
+ if (acc_io && acc_io->AccessDisable)
+ acc_io->AccessDisable(acc_io->arg);
+ }
+ }
+
+ /* disable shared resources */
+ if (pEnt->access->pAccess
+ && pEnt->access->pAccess->AccessDisable)
+ pEnt->access->pAccess->AccessDisable(pEnt->access->pAccess->arg);
+
+ /*
+ * If device is not under access control it is enabled.
+ * If it needs bus routing do it here as it isn't bus
+ * type specific. Any conflicts should be checked at this
+ * stage
+ */
+ if (!pEnt->access->pAccess
+ && (pEnt->entityProp & (state == SETUP ? NEED_VGA_ROUTED_SETUP :
+ NEED_VGA_ROUTED)))
+ ((BusAccPtr)pEnt->busAcc)->set_f(pEnt->busAcc);
+}
+
+
+/*
+ * xf86EnterServerState() -- set state the server is in.
+ */
+
+typedef enum { TRI_UNSET, TRI_TRUE, TRI_FALSE } TriState;
+
+static void
+SetSIGIOForState(xf86State state)
+{
+ static int sigio_state;
+ static TriState sigio_blocked = TRI_UNSET;
+
+ if ((state == SETUP) && (sigio_blocked != TRI_TRUE)) {
+ sigio_state = xf86BlockSIGIO();
+ sigio_blocked = TRI_TRUE;
+ } else if ((state == OPERATING) && (sigio_blocked != TRI_UNSET)) {
+ xf86UnblockSIGIO(sigio_state);
+ sigio_blocked = TRI_FALSE;
+ }
+}
+
+void
+xf86EnterServerState(xf86State state)
+{
+ EntityPtr pEnt;
+ ScrnInfoPtr pScrn;
+ int i,j;
+ int needVGA = 0;
+ resType rt;
+ /*
+ * This is a good place to block SIGIO during SETUP state.
+ * SIGIO should be blocked in SETUP state otherwise (u)sleep()
+ * might get interrupted early.
+ * We take care not to call xf86BlockSIGIO() twice.
+ */
+ SetSIGIOForState(state);
+#ifdef DEBUG
+ if (state == SETUP)
+ ErrorF("Entering SETUP state\n");
+ else
+ ErrorF("Entering OPERATING state\n");
+#endif
+
+ /* When servicing a dumb framebuffer we don't need to do anything */
+ if (doFramebufferMode) return;
+
+ for (i=0; i<xf86NumScreens; i++) {
+ pScrn = xf86Screens[i];
+ j = pScrn->entityList[pScrn->numEntities - 1];
+ pScrn->access = xf86Entities[j]->access;
+
+ for (j = 0; j<xf86Screens[i]->numEntities; j++) {
+ pEnt = xf86Entities[xf86Screens[i]->entityList[j]];
+ if (pEnt->entityProp & (state == SETUP ? NEED_VGA_ROUTED_SETUP
+ : NEED_VGA_ROUTED))
+ xf86Screens[i]->busAccess = pEnt->busAcc;
+ }
+ if (xf86Screens[i]->busAccess)
+ needVGA ++;
+ }
+
+ /*
+ * if we just have one screen we don't have RAC.
+ * Therefore just enable the screen and return.
+ */
+ if (!needRAC) {
+ xf86EnableAccess(xf86Screens[0]);
+ notifyStateChange(NOTIFY_ENABLE);
+ return;
+ }
+
+ if (state == SETUP)
+ notifyStateChange(NOTIFY_SETUP_TRANSITION);
+ else
+ notifyStateChange(NOTIFY_OPERATING_TRANSITION);
+
+ clearAccess();
+ for (i=0; i<xf86NumScreens;i++) {
+
+ rt = NONE;
+
+ for (j = 0; j<xf86Screens[i]->numEntities; j++) {
+ pEnt = xf86Entities[xf86Screens[i]->entityList[j]];
+ setAccess(pEnt,state);
+
+ if (pEnt->access->rt != NONE) {
+ if (rt != NONE && rt != pEnt->access->rt)
+ rt = MEM_IO;
+ else
+ rt = pEnt->access->rt;
+ }
+ }
+ xf86Screens[i]->resourceType = rt;
+ if (rt == NONE) {
+ xf86Screens[i]->access = NULL;
+ if (needVGA < 2)
+ xf86Screens[i]->busAccess = NULL;
+ }
+
+#ifdef DEBUG
+ if (xf86Screens[i]->busAccess)
+ ErrorF("Screen %i setting vga route\n",i);
+#endif
+ switch (rt) {
+ case MEM_IO:
+ xf86MsgVerb(X_INFO, 3, "Screen %i shares mem & io resources\n",i);
+ break;
+ case IO:
+ xf86MsgVerb(X_INFO, 3, "Screen %i shares io resources\n",i);
+ break;
+ case MEM:
+ xf86MsgVerb(X_INFO, 3, "Screen %i shares mem resources\n",i);
+ break;
+ default:
+ xf86MsgVerb(X_INFO, 3, "Entity %i shares no resources\n",i);
+ break;
+ }
+ }
+ if (state == SETUP)
+ notifyStateChange(NOTIFY_SETUP);
+ else
+ notifyStateChange(NOTIFY_OPERATING);
+}
+
+/*
+ * xf86SetOperatingState() -- Set ResOperMask for resources listed.
+ */
+resPtr
+xf86SetOperatingState(resList list, int entityIndex, int mask)
+{
+ resPtr acc;
+ resPtr r_fail = NULL;
+ resRange range;
+
+ while (list->type != ResEnd) {
+ range = *list;
+ convertRange2Host(entityIndex,&range);
+
+ acc = Acc;
+ while (acc) {
+#define MASK (ResTypeMask | ResExtMask)
+ if ((acc->entityIndex == entityIndex)
+ && (acc->val.a == range.a) && (acc->val.b == range.b)
+ && ((acc->val.type & MASK) == (range.type & MASK)))
+ break;
+#undef MASK
+ acc = acc->next;
+ }
+ if (acc)
+ acc->val.type = (acc->val.type & ~ResOprMask)
+ | (mask & ResOprMask);
+ else {
+ r_fail = xf86AddResToList(r_fail,&range,entityIndex);
+ }
+ list ++;
+ }
+
+ return r_fail;
+}
+
+/*
+ * Stage specific code
+ */
+ /*
+ * ProcessEstimatedConflicts() -- Do something about driver-registered
+ * resources that conflict with estimated resources. For now, just register
+ * them with a logged warning.
+ */
+#ifdef REDUCER
+static void
+ProcessEstimatedConflicts(void)
+{
+ if (!AccReducers)
+ return;
+
+ /* Temporary */
+ xf86MsgVerb(X_WARNING, 3,
+ "Registering the following despite conflicts with estimated"
+ " resources:\n");
+ xf86PrintResList(3, AccReducers);
+ Acc = xf86JoinResLists(Acc, AccReducers);
+ AccReducers = NULL;
+}
+#endif
+
+/*
+ * xf86ClaimFixedResources() -- This function gets called from the
+ * driver Probe() function to claim fixed resources.
+ */
+static void
+resError(resList list)
+{
+ FatalError("A driver tried to allocate the %s %sresource at \n"
+ "0x%lx:0x%lx which conflicted with another resource. Send the\n"
+ "output of the server to %s. Please \n"
+ "specify your computer hardware as closely as possible.\n",
+ ResIsBlock(list)?"Block":"Sparse",
+ ResIsMem(list)?"Mem":"Io",
+ ResIsBlock(list)?list->rBegin:list->rBase,
+ ResIsBlock(list)?list->rEnd:list->rMask,BUILDERADDR);
+}
+
+/*
+ * xf86ClaimFixedResources() is used to allocate non-relocatable resources.
+ * This should only be done by a driver's Probe() function.
+ */
+void
+xf86ClaimFixedResources(resList list, int entityIndex)
+{
+ resPtr ptr = NULL;
+ resRange range;
+
+ if (!list) return;
+
+ while (list->type !=ResEnd) {
+ range = *list;
+
+ convertRange2Host(entityIndex,&range);
+
+ range.type &= ~ResEstimated; /* Not allowed for drivers */
+ switch (range.type & ResAccMask) {
+ case ResExclusive:
+ if (!xf86ChkConflict(&range, entityIndex)) {
+ Acc = xf86AddResToList(Acc, &range, entityIndex);
+#ifdef REDUCER
+ } else {
+ range.type |= ResEstimated;
+ if (!xf86ChkConflict(&range, entityIndex) &&
+ !checkConflict(&range, AccReducers, entityIndex,
+ SETUP, FALSE)) {
+ range.type &= ~(ResEstimated | ResBios);
+ AccReducers =
+ xf86AddResToList(AccReducers, &range, entityIndex);
+#endif
+ } else resError(&range); /* no return */
+#ifdef REDUCER
+ }
+#endif
+ break;
+ case ResShared:
+ /* at this stage the resources are just added to the
+ * EntityRec. After the Probe() phase this list is checked by
+ * xf86PostProbe(). All resources which don't
+ * conflict with already allocated ones are allocated
+ * and removed from the EntityRec. Thus a non-empty resource
+ * list in the EntityRec indicates resource conflicts the
+ * driver should either handle or fail.
+ */
+ if (xf86Entities[entityIndex]->active)
+ ptr = xf86AddResToList(ptr,&range,entityIndex);
+ break;
+ }
+ list++;
+ }
+ xf86Entities[entityIndex]->resources =
+ xf86JoinResLists(xf86Entities[entityIndex]->resources,ptr);
+ xf86MsgVerb(X_INFO, 3,
+ "resource ranges after xf86ClaimFixedResources() call:\n");
+ xf86PrintResList(3,Acc);
+#ifdef REDUCER
+ ProcessEstimatedConflicts();
+#endif
+#ifdef DEBUG
+ if (ptr) {
+ xf86MsgVerb(X_INFO, 3, "to be registered later:\n");
+ xf86PrintResList(3,ptr);
+ }
+#endif
+}
+
+static void
+checkRoutingForScreens(xf86State state)
+{
+ resList list = resVgaUnusedExclusive;
+ resPtr pResVGA = NULL;
+ resPtr pResVGAHost;
+ pointer vga = NULL;
+ int i,j;
+ int entityIndex;
+ EntityPtr pEnt;
+ resPtr pAcc;
+ resRange range;
+
+ /*
+ * find devices that need VGA routed: ie the ones that have
+ * registered VGA resources without ResUnused. ResUnused
+ * doesn't conflict with itself therefore use it here.
+ */
+ while (list->type != ResEnd) { /* create resPtr from resList for VGA */
+ range = *list;
+ range.type &= ~(ResBios | ResEstimated); /* if set remove them */
+ pResVGA = xf86AddResToList(pResVGA, &range, -1);
+ list++;
+ }
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (j = 0; j < xf86Screens[i]->numEntities; j++) {
+ entityIndex = xf86Screens[i]->entityList[j];
+ pEnt = xf86Entities[entityIndex];
+ pAcc = Acc;
+ vga = NULL;
+ pResVGAHost = xf86DupResList(pResVGA);
+ xf86ConvertListToHost(entityIndex,pResVGAHost);
+ while (pAcc) {
+ if (pAcc->entityIndex == entityIndex)
+ if (checkConflict(&pAcc->val, pResVGAHost,
+ entityIndex, state, FALSE)) {
+ if (vga && vga != pEnt->busAcc) {
+ xf86Msg(X_ERROR, "Screen %i needs vga routed to"
+ "different buses - deleting\n",i);
+ xf86DeleteScreen(i--,0);
+ }
+#ifdef DEBUG
+ {
+ resPtr rlist = xf86AddResToList(NULL,&pAcc->val,
+ pAcc->entityIndex);
+ xf86MsgVerb(X_INFO,3,"====== %s\n",
+ state == OPERATING ? "OPERATING"
+ : "SETUP");
+ xf86MsgVerb(X_INFO,3,"%s Resource:\n",
+ (pAcc->val.type) & ResMem ? "Mem" :"Io");
+ xf86PrintResList(3,rlist);
+ xf86FreeResList(rlist);
+ xf86MsgVerb(X_INFO,3,"Conflicts with:\n");
+ xf86PrintResList(3,pResVGAHost);
+ xf86MsgVerb(X_INFO,3,"=====\n");
+ }
+#endif
+ vga = pEnt->busAcc;
+ pEnt->entityProp |= (state == SETUP
+ ? NEED_VGA_ROUTED_SETUP : NEED_VGA_ROUTED);
+ if (state == OPERATING) {
+ if (pAcc->val.type & ResMem)
+ pEnt->entityProp |= NEED_VGA_MEM;
+ else
+ pEnt->entityProp |= NEED_VGA_IO;
+ }
+ }
+ pAcc = pAcc->next;
+ }
+ if (vga)
+ xf86MsgVerb(X_INFO, 3,"Setting vga for screen %i.\n",i);
+ xf86FreeResList(pResVGAHost);
+ }
+ }
+ xf86FreeResList(pResVGA);
+}
+
+/*
+ * xf86PostProbe() -- Allocate all non conflicting resources
+ * This function gets called by xf86Init().
+ */
+void
+xf86PostProbe(void)
+{
+ memType val;
+ int i,j;
+ resPtr resp, acc, tmp, resp_x, *pprev_next;
+
+ if (fbSlotClaimed) {
+ if (pciSlotClaimed || isaSlotClaimed
+#if defined(__sparc__) && !defined(__OpenBSD__)
+ || sbusSlotClaimed
+#endif
+ ) {
+ FatalError("Cannot run in framebuffer mode. Please specify busIDs "
+ " for all framebuffer devices\n");
+ return;
+ } else {
+ xf86Msg(X_INFO,"Running in FRAMEBUFFER Mode\n");
+ xf86AccessRestoreState();
+ notifyStateChange(NOTIFY_ENABLE);
+ doFramebufferMode = TRUE;
+
+ return;
+ }
+ }
+ /* don't compare against ResInit - remove it from clone.*/
+ acc = tmp = xf86DupResList(Acc);
+ pprev_next = &acc;
+ while (tmp) {
+ if (tmp->res_type & ResInit) {
+ (*pprev_next) = tmp->next;
+ xfree(tmp);
+ } else
+ pprev_next = &(tmp->next);
+ tmp = (*pprev_next);
+ }
+
+ for (i=0; i<xf86NumEntities; i++) {
+ resp = xf86Entities[i]->resources;
+ xf86Entities[i]->resources = NULL;
+ resp_x = NULL;
+ while (resp) {
+ if (! (val = checkConflict(&resp->val,acc,i,SETUP,FALSE))) {
+ resp->res_type &= ~(ResBios); /* just used for chkConflict() */
+ tmp = resp_x;
+ resp_x = resp;
+ resp = resp->next;
+ resp_x->next = tmp;
+#ifdef REDUCER
+ } else {
+ resp->res_type |= ResEstimated;
+ if (!checkConflict(&resp->val, acc, i, SETUP, FALSE)) {
+ resp->res_type &= ~(ResEstimated | ResBios);
+ tmp = AccReducers;
+ AccReducers = resp;
+ resp = resp->next;
+ AccReducers->next = tmp;
+#endif
+ } else {
+ xf86MsgVerb(X_INFO, 3, "Found conflict at: 0x%lx\n",val);
+ resp->res_type &= ~ResEstimated;
+ tmp = xf86Entities[i]->resources;
+ xf86Entities[i]->resources = resp;
+ resp = resp->next;
+ xf86Entities[i]->resources->next = tmp;
+ }
+#ifdef REDUCER
+ }
+#endif
+ }
+ xf86JoinResLists(Acc,resp_x);
+#ifdef REDUCER
+ ProcessEstimatedConflicts();
+#endif
+ }
+ xf86FreeResList(acc);
+#if !(defined(__alpha__) && defined(linux)) && \
+ !(defined(__ia64__) && defined(linux)) && \
+ !(defined(__sparc64__) && defined(__OpenBSD__))
+ /*
+ * No need to validate on Alpha Linux or OpenBSD/sparc64,
+ * trust the kernel.
+ */
+ ValidatePci();
+#endif
+
+ xf86MsgVerb(X_INFO, 3, "resource ranges after probing:\n");
+ xf86PrintResList(3, Acc);
+ checkRoutingForScreens(SETUP);
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (j = 0; j<xf86Screens[i]->numEntities; j++) {
+ EntityPtr pEnt = xf86Entities[xf86Screens[i]->entityList[j]];
+ if ((pEnt->entityProp & NEED_VGA_ROUTED_SETUP) &&
+ ((xf86Screens[i]->busAccess = pEnt->busAcc)))
+ break;
+ }
+ }
+}
+
+static void
+checkRequiredResources(int entityIndex)
+{
+ resRange range;
+ resPtr pAcc = Acc;
+ const EntityPtr pEnt = xf86Entities[entityIndex];
+ while (pAcc) {
+ if (pAcc->entityIndex == entityIndex) {
+ range = pAcc->val;
+ /* ResAny to find conflicts with anything. */
+ range.type = (range.type & ~ResAccMask) | ResAny | ResBios;
+ if (checkConflict(&range,Acc,entityIndex,OPERATING,FALSE))
+ switch (pAcc->res_type & ResPhysMask) {
+ case ResMem:
+ pEnt->entityProp |= NEED_MEM_SHARED;
+ break;
+ case ResIo:
+ pEnt->entityProp |= NEED_IO_SHARED;
+ break;
+ }
+ if (!(pAcc->res_type & ResOprMask)) {
+ switch (pAcc->res_type & ResPhysMask) {
+ case ResMem:
+ pEnt->entityProp |= NEED_MEM;
+ break;
+ case ResIo:
+ pEnt->entityProp |= NEED_IO;
+ break;
+ }
+ }
+ }
+ pAcc = pAcc->next;
+ }
+
+ /* check if we can separately enable mem/io resources */
+ /* XXX we still need to find out how to set this yet */
+ if ( ((pEnt->entityProp & NO_SEPARATE_MEM_FROM_IO)
+ && (pEnt->entityProp & NEED_MEM_SHARED))
+ || ((pEnt->entityProp & NO_SEPARATE_IO_FROM_MEM)
+ && (pEnt->entityProp & NEED_IO_SHARED)) )
+ pEnt->entityProp |= NEED_SHARED;
+ /*
+ * After we have checked all resources of an entity agains any
+ * other resource we know if the entity need this resource type
+ * (ie. mem/io) at all. if not we can disable this type completely,
+ * so no need to share it either.
+ */
+ if ((pEnt->entityProp & NEED_MEM_SHARED)
+ && (!(pEnt->entityProp & NEED_MEM))
+ && (!(pEnt->entityProp & NO_SEPARATE_MEM_FROM_IO)))
+ pEnt->entityProp &= ~(unsigned long)NEED_MEM_SHARED;
+
+ if ((pEnt->entityProp & NEED_IO_SHARED)
+ && (!(pEnt->entityProp & NEED_IO))
+ && (!(pEnt->entityProp & NO_SEPARATE_IO_FROM_MEM)))
+ pEnt->entityProp &= ~(unsigned long)NEED_IO_SHARED;
+}
+
+void
+xf86PostPreInit()
+{
+ if (doFramebufferMode) return;
+
+ if (xf86NumScreens > 1)
+ needRAC = TRUE;
+
+#ifdef XFree86LOADER
+ xf86MsgVerb(X_INFO, 3, "do I need RAC?");
+
+ if (needRAC) {
+ xf86ErrorFVerb(3, " Yes, I do.\n");
+
+ if (!xf86LoadOneModule("rac",NULL))
+ FatalError("Cannot load RAC module\n");
+ } else
+ xf86ErrorFVerb(3, " No, I don't.\n");
+#endif
+
+ xf86MsgVerb(X_INFO, 3, "resource ranges after preInit:\n");
+ xf86PrintResList(3, Acc);
+}
+
+void
+xf86PostScreenInit(void)
+{
+ int i,j;
+ ScreenPtr pScreen;
+ unsigned int flags;
+ int nummem = 0, numio = 0;
+#ifdef XFree86LOADER
+ pointer xf86RACInit = NULL;
+#endif
+
+ if (doFramebufferMode) {
+ SetSIGIOForState(OPERATING);
+ return;
+ }
+
+#ifdef XFree86LOADER
+ if (needRAC) {
+ xf86RACInit = LoaderSymbol("xf86RACInit");
+ if (!xf86RACInit)
+ FatalError("Cannot resolve symbol \"xf86RACInit\"\n");
+ }
+#endif
+#ifdef DEBUG
+ ErrorF("PostScreenInit generation: %i\n",serverGeneration);
+#endif
+ if (serverGeneration == 1) {
+ checkRoutingForScreens(OPERATING);
+ for (i=0; i<xf86NumEntities; i++) {
+ checkRequiredResources(i);
+ }
+
+ /*
+ * after removing NEED_XXX_SHARED from entities that
+ * don't need need XXX resources at all we might have
+ * a single entity left that has NEED_XXX_SHARED set.
+ * In this case we can delete that, too.
+ */
+ for (i = 0; i < xf86NumEntities; i++) {
+ if (xf86Entities[i]->entityProp & NEED_MEM_SHARED)
+ nummem++;
+ if (xf86Entities[i]->entityProp & NEED_IO_SHARED)
+ numio++;
+ }
+ for (i = 0; i < xf86NumEntities; i++) {
+ if (nummem < 2)
+ xf86Entities[i]->entityProp &= ~NEED_MEM_SHARED;
+ if (numio < 2)
+ xf86Entities[i]->entityProp &= ~NEED_IO_SHARED;
+ }
+ }
+
+ if (xf86Screens && needRAC) {
+ int needRACforVga = 0;
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (j = 0; j < xf86Screens[i]->numEntities; j++) {
+ if (xf86Entities[xf86Screens[i]->entityList[j]]->entityProp
+ & NEED_VGA_ROUTED) {
+ needRACforVga ++;
+ break; /* only count each screen once */
+ }
+ }
+ }
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ Bool needRACforMem = FALSE, needRACforIo = FALSE;
+
+ for (j = 0; j < xf86Screens[i]->numEntities; j++) {
+ if (xf86Entities[xf86Screens[i]->entityList[j]]->entityProp
+ & NEED_MEM_SHARED)
+ needRACforMem = TRUE;
+ if (xf86Entities[xf86Screens[i]->entityList[j]]->entityProp
+ & NEED_IO_SHARED)
+ needRACforIo = TRUE;
+ /*
+ * We may need RAC although we don't share any resources
+ * as we need to route VGA to the correct bus. This can
+ * only be done simultaniously for MEM and IO.
+ */
+ if (needRACforVga > 1) {
+ if (xf86Entities[xf86Screens[i]->entityList[j]]->entityProp
+ & NEED_VGA_MEM)
+ needRACforMem = TRUE;
+ if (xf86Entities[xf86Screens[i]->entityList[j]]->entityProp
+ & NEED_VGA_IO)
+ needRACforIo = TRUE;
+ }
+ }
+
+ pScreen = xf86Screens[i]->pScreen;
+ flags = 0;
+ if (needRACforMem) {
+ flags |= xf86Screens[i]->racMemFlags;
+ xf86ErrorFVerb(3, "Screen %d is using RAC for mem\n", i);
+ }
+ if (needRACforIo) {
+ flags |= xf86Screens[i]->racIoFlags;
+ xf86ErrorFVerb(3, "Screen %d is using RAC for io\n", i);
+ }
+
+#ifdef XFree86LOADER
+ ((Bool(*)(ScreenPtr,unsigned int))xf86RACInit)
+ (pScreen,flags);
+#else
+ xf86RACInit(pScreen,flags);
+#endif
+ }
+ }
+
+ xf86EnterServerState(OPERATING);
+
+}
+
+/*
+ * Sets
+ */
+
+
+static resPtr
+decomposeSparse(resRange range)
+{
+ resRange new;
+ resPtr ret = NULL;
+ memType val = range.rBegin;
+ int i = 0;
+
+ new.type = (range.type & ~ResExtMask) | ResSparse;
+
+ while (1) {
+ if (val & 0x01) {
+ new.rBase = (val << i);
+ new.rMask = ~((1 << i) - 1);
+ ret = xf86AddResToList(ret,&new,-1);
+ val ++;
+ }
+ i++;
+ val >>= 1;
+ if ((((val + 1) << i) - 1) > range.rEnd)
+ break;
+ }
+ i--;
+ val <<= 1;
+
+ while (1) {
+ if((((val + 1) << i) - 1)> range.rEnd) {
+ if (--i < 0) break;
+ val <<= 1;
+ } else {
+ new.rBase = (val << i);
+ new.rMask = ~((1 << i) - 1);
+ val++;
+ ret = xf86AddResToList(ret,&new,-1);
+ }
+ }
+ return ret;
+}
+
+static Bool
+x_isSubsetOf(resRange range, resPtr list1, resPtr list2)
+{
+ resRange range1, range2;
+ memType m1_A_m2;
+ Bool ret;
+ resPtr list;
+
+ if (list1) {
+ list = list1;
+ if ((range.type & ResTypeMask) == (list->res_type & ResTypeMask)) {
+ switch (range.type & ResExtMask) {
+ case ResBlock:
+ if ((list->res_type & ResExtMask) == ResBlock) {
+ if (range.rBegin >= list->block_begin
+ && range.rEnd <= list->block_end)
+ return TRUE;
+ else if (range.rBegin < list->block_begin
+ && range.rEnd > list->block_end) {
+ RANGE(range1, range.rBegin, list->block_begin - 1,
+ range.type);
+ RANGE(range2, list->block_end + 1, range.rEnd,
+ range.type);
+ return (x_isSubsetOf(range1,list->next,list2) &&
+ x_isSubsetOf(range2,list->next,list2));
+ }
+ else if (range.rBegin >= list->block_begin
+ && range.rBegin <= list->block_end) {
+ RANGE(range1, list->block_end + 1, range.rEnd,
+ range.type);
+ return (x_isSubsetOf(range1,list->next,list2));
+ } else if (range.rEnd >= list->block_begin
+ && range.rEnd <= list->block_end) {
+ RANGE(range1,range.rBegin, list->block_begin - 1,
+ range.type);
+ return (x_isSubsetOf(range1,list->next,list2));
+ }
+ }
+ break;
+ case ResSparse:
+ if ((list->res_type & ResExtMask) == ResSparse) {
+ memType test;
+ int i;
+
+ m1_A_m2 = range.rMask & list->sparse_mask;
+ if ((range.rBase ^ list->sparse_base) & m1_A_m2)
+ break;
+ /*
+ * We use the following system:
+ * let 0 ^= mask:1 base:0, 1 ^= mask:1 base:1,
+ * X mask:0 ; S: set TSS: test set for subset
+ * NTSS: new test set after test
+ * S: 1 0 1 0 X X 0 1 X
+ * TSS: 1 0 0 1 1 0 X X X
+ * T: 0 0 1 1 0 0 0 0 0
+ * NTSS: 1 0 0/X 1/X 1 0 1 0 X
+ * R: 0 0 0 0 0 0 1 1 0
+ * If R != 0 TSS and S are disjunct
+ * If R == 0 TSS is subset of S
+ * If R != 0 NTSS contains elements from TSS
+ * which are not also members of S.
+ * If a T is set one of the correspondig bits
+ * in NTSS must be set to the specified value
+ * all other are X
+ */
+ test = list->sparse_mask & ~range.rMask;
+ if (test == 0)
+ return TRUE;
+ for (i = 0; i < sizeof(memType); i++) {
+ if ((test >> i) & 0x1) {
+ RANGE(range1, ((range.rBase & list->sparse_base)
+ | (range.rBase & ~list->sparse_mask)
+ | ((~list->sparse_base & list->sparse_mask)
+ & ~range.rMask)) & range1.rMask,
+ ((range.rMask | list->sparse_mask) & ~test)
+ | (1 << i), range.type);
+ return (x_isSubsetOf(range1,list->next,list2));
+ }
+ }
+ }
+ break;
+ }
+ }
+ return (x_isSubsetOf(range,list->next,list2));
+ } else if (list2) {
+ resPtr tmpList = NULL;
+ switch (range.type & ResExtMask) {
+ case ResBlock:
+ tmpList = decomposeSparse(range);
+ while (tmpList) {
+ if (!x_isSubsetOf(tmpList->val,list2,NULL)) {
+ xf86FreeResList(tmpList);
+ return FALSE;
+ }
+ tmpList = tmpList->next;
+ }
+ xf86FreeResList(tmpList);
+ return TRUE;
+ break;
+ case ResSparse:
+ while (list2) {
+ tmpList = xf86JoinResLists(tmpList,decomposeSparse(list2->val));
+ list2 = list2->next;
+ }
+ ret = x_isSubsetOf(range,tmpList,NULL);
+ xf86FreeResList(tmpList);
+ return ret;
+ break;
+ }
+ } else
+ return FALSE;
+
+ return FALSE;
+}
+
+Bool
+xf86IsSubsetOf(resRange range, resPtr list)
+{
+ resPtr dup = xf86DupResList(list);
+ resPtr r_sp = NULL, r = NULL, tmp = NULL;
+ Bool ret = FALSE;
+
+ while (dup) {
+ tmp = dup;
+ dup = dup->next;
+ switch (tmp->res_type & ResExtMask) {
+ case ResBlock:
+ tmp->next = r;
+ r = tmp;
+ break;
+ case ResSparse:
+ tmp->next = r_sp;
+ r_sp = tmp;
+ break;
+ }
+ }
+
+ switch (range.type & ResExtMask) {
+ case ResBlock:
+ ret = x_isSubsetOf(range,r,r_sp);
+ break;
+ case ResSparse:
+ ret = x_isSubsetOf(range,r_sp,r);
+ break;
+ }
+ xf86FreeResList(r);
+ xf86FreeResList(r_sp);
+
+ return ret;
+}
+
+Bool
+xf86IsListSubsetOf(resPtr list, resPtr BaseList)
+{
+ while (list) {
+ if (! xf86IsSubsetOf(list->val,BaseList))
+ return FALSE;
+ list = list->next;
+ }
+ return TRUE;
+}
+
+resPtr
+findIntersect(resRange Range, resPtr list)
+{
+ resRange range;
+ resPtr new = NULL;
+
+ while (list) {
+ if ((Range.type & ResTypeMask) == (list->res_type & ResTypeMask)) {
+ switch (Range.type & ResExtMask) {
+ case ResBlock:
+ switch (list->res_type & ResExtMask) {
+ case ResBlock:
+ if (Range.rBegin >= list->block_begin)
+ range.rBegin = Range.rBegin;
+ else
+ range.rBegin = list->block_begin;
+ if (Range.rEnd <= list->block_end)
+ range.rEnd = Range.rEnd;
+ else
+ range.rEnd = list->block_end;
+ if (range.rEnd > range.rBegin) {
+ range.type = Range.type;
+ new = xf86AddResToList(new,&range,-1);
+ }
+ break;
+ case ResSparse:
+ new = xf86JoinResLists(new,xf86FindIntersectOfLists(new,decomposeSparse(list->val)));
+ break;
+ }
+ break;
+ case ResSparse:
+ switch (list->res_type & ResExtMask) {
+ case ResSparse:
+ if (!((~(range.rBase ^ list->sparse_base)
+ & (range.rMask & list->sparse_mask)))) {
+ RANGE(range, (range.rBase & list->sparse_base)
+ | (~range.rMask & list->sparse_base)
+ | (~list->sparse_mask & range.rBase),
+ range.rMask | list->sparse_mask,
+ Range.type);
+ new = xf86AddResToList(new,&range,-1);
+ }
+ break;
+ case ResBlock:
+ new = xf86JoinResLists(new,xf86FindIntersectOfLists(
+ decomposeSparse(range),list));
+ break;
+ }
+ }
+ }
+ list = list->next;
+ }
+ return new;
+}
+
+resPtr
+xf86FindIntersectOfLists(resPtr l1, resPtr l2)
+{
+ resPtr ret = NULL;
+
+ while (l1) {
+ ret = xf86JoinResLists(ret,findIntersect(l1->val,l2));
+ l1 = l1->next;
+ }
+ return ret;
+}
+
+#if 0 /* Not used */
+static resPtr
+xf86FindComplement(resRange Range)
+{
+ resRange range;
+ memType tmp;
+ resPtr new = NULL;
+ int i;
+
+ switch (Range.type & ResExtMask) {
+ case ResBlock:
+ if (Range.rBegin > 0) {
+ RANGE(range, 0, Range.rBegin - 1, Range.type);
+ new = xf86AddResToList(new,&range,-1);
+ }
+ if (Range.rEnd < (memType)~0) {
+ RANGE(range,Range.rEnd + 1, (memType)~0, Range.type);
+ new = xf86AddResToList(new,&range,-1);
+ }
+ break;
+ case ResSparse:
+ tmp = Range.rMask;
+ for (i = 0; i < sizeof(memType); i++) {
+ if (tmp & 0x1) {
+ RANGE(range,(~Range.rMask & range.rMask),(1 << i), Range.type);
+ new = xf86AddResToList(new,&range,-1);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ return new;
+}
+#endif
+
+resPtr
+xf86ExtractTypeFromList(resPtr list, unsigned long type)
+{
+ resPtr ret = NULL;
+
+ while (list) {
+ if ((list->res_type & ResTypeMask) == type)
+ ret = xf86AddResToList(ret,&(list->val),list->entityIndex);
+ list = list->next;
+ }
+ return ret;
+}
+
+/*------------------------------------------------------------*/
+static void CheckGenericGA(void);
+
+/*
+ * xf86FindPrimaryDevice() - Find the display device which
+ * was active when the server was started.
+ */
+void
+xf86FindPrimaryDevice()
+{
+ /* if no VGA device is found check for primary PCI device */
+ if (primaryBus.type == BUS_NONE && xorgHWAccess)
+ CheckGenericGA();
+ if (primaryBus.type != BUS_NONE) {
+ char *bus;
+ char *loc = xnfcalloc(1,9);
+ if (loc == NULL) return;
+
+ switch (primaryBus.type) {
+ case BUS_PCI:
+ bus = "PCI";
+ sprintf(loc," %2.2x:%2.2x:%1.1x",primaryBus.id.pci.bus,
+ primaryBus.id.pci.device,primaryBus.id.pci.func);
+ break;
+ case BUS_ISA:
+ bus = "ISA";
+ loc[0] = '\0';
+ break;
+ case BUS_SBUS:
+ bus = "SBUS";
+ sprintf(loc," %2.2x",primaryBus.id.sbus.fbNum);
+ break;
+ default:
+ bus = "";
+ loc[0] = '\0';
+ }
+
+ xf86MsgVerb(X_INFO, 2, "Primary Device is: %s%s\n",bus,loc);
+ xfree(loc);
+ }
+
+}
+
+#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__)
+#include "vgaHW.h"
+#include "compiler.h"
+#endif
+
+/*
+ * CheckGenericGA() - Check for presence of a VGA device.
+ */
+static void
+CheckGenericGA()
+{
+/* This needs to be changed for multiple domains */
+#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) && !defined(__ia64__)
+ IOADDRESS GenericIOBase = VGAHW_GET_IOBASE();
+ CARD8 CurrentValue, TestValue;
+
+ /* VGA CRTC registers are not used here, so don't bother unlocking them */
+
+ /* VGA has one more read/write attribute register than EGA */
+ (void) inb(GenericIOBase + VGA_IN_STAT_1_OFFSET); /* Reset flip-flop */
+ outb(VGA_ATTR_INDEX, 0x14 | 0x20);
+ CurrentValue = inb(VGA_ATTR_DATA_R);
+ outb(VGA_ATTR_DATA_W, CurrentValue ^ 0x0F);
+ outb(VGA_ATTR_INDEX, 0x14 | 0x20);
+ TestValue = inb(VGA_ATTR_DATA_R);
+ outb(VGA_ATTR_DATA_W, CurrentValue);
+
+ if ((CurrentValue ^ 0x0F) == TestValue) {
+ primaryBus.type = BUS_ISA;
+ }
+#endif
+}
+
+Bool
+xf86NoSharedResources(int screenIndex,resType res)
+{
+ int j;
+
+ if (screenIndex > xf86NumScreens)
+ return TRUE;
+
+ for (j = 0; j < xf86Screens[screenIndex]->numEntities; j++) {
+ switch (res) {
+ case IO:
+ if ( xf86Entities[xf86Screens[screenIndex]->entityList[j]]->entityProp
+ & NEED_IO_SHARED)
+ return FALSE;
+ break;
+ case MEM:
+ if ( xf86Entities[xf86Screens[screenIndex]->entityList[j]]->entityProp
+ & NEED_MEM_SHARED)
+ return FALSE;
+ break;
+ case MEM_IO:
+ if ( xf86Entities[xf86Screens[screenIndex]->entityList[j]]->entityProp
+ & NEED_SHARED)
+ return FALSE;
+ break;
+ case NONE:
+ break;
+ }
+ }
+ return TRUE;
+}
+
+void
+xf86ConvertListToHost(int entityIndex, resPtr list)
+{
+ while (list) {
+ convertRange2Host(entityIndex, &list->val);
+ list = list->next;
+ }
+}
+
+void
+xf86RegisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func, pointer arg)
+{
+ StateChangeNotificationPtr ptr =
+ (StateChangeNotificationPtr)xnfalloc(sizeof(StateChangeNotificationRec));
+
+ ptr->func = func;
+ ptr->arg = arg;
+ ptr->next = StateChangeNotificationList;
+ StateChangeNotificationList = ptr;
+}
+
+Bool
+xf86DeregisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func)
+{
+ StateChangeNotificationPtr *ptr = &StateChangeNotificationList;
+ StateChangeNotificationPtr tmp;
+
+ while (*ptr) {
+ if ((*ptr)->func == func) {
+ tmp = (*ptr);
+ (*ptr) = (*ptr)->next;
+ xfree(tmp);
+ return TRUE;
+ }
+ ptr = &((*ptr)->next);
+ }
+ return FALSE;
+}
+
+static void
+notifyStateChange(xf86NotifyState state)
+{
+ StateChangeNotificationPtr ptr = StateChangeNotificationList;
+ while (ptr) {
+ ptr->func(state,ptr->arg);
+ ptr = ptr->next;
+ }
+}
+
+#ifdef async
+Bool
+xf86QueueAsyncEvent(void (*func)(pointer),pointer arg)
+{
+ AsyncQPtr new;
+
+ if (!AsyncQ) return FALSE;
+
+ new = (AsyncQPtr)xfnalloc(sizeof(AsyncQRec));
+ new->func = func;
+ new->arg = arg;
+ (*AsyncQPtr)->next = new;
+ AsyncQPtr = &new;
+ return TRUE;
+}
+#endif
+
+/* Multihead accel sharing accessor functions and entity Private handling */
+
+int
+xf86GetLastScrnFlag(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ return(xf86Entities[entityIndex]->lastScrnFlag);
+ } else {
+ return -1;
+ }
+}
+
+void
+xf86SetLastScrnFlag(int entityIndex, int scrnIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ xf86Entities[entityIndex]->lastScrnFlag = scrnIndex;
+ }
+}
+
+Bool
+xf86IsEntityShared(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ if(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void
+xf86SetEntityShared(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ xf86Entities[entityIndex]->entityProp |= IS_SHARED_ACCEL;
+ }
+}
+
+Bool
+xf86IsEntitySharable(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ if(xf86Entities[entityIndex]->entityProp & ACCEL_IS_SHARABLE) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void
+xf86SetEntitySharable(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ xf86Entities[entityIndex]->entityProp |= ACCEL_IS_SHARABLE;
+ }
+}
+
+Bool
+xf86IsPrimInitDone(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ if(xf86Entities[entityIndex]->entityProp & SA_PRIM_INIT_DONE) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void
+xf86SetPrimInitDone(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ xf86Entities[entityIndex]->entityProp |= SA_PRIM_INIT_DONE;
+ }
+}
+
+void
+xf86ClearPrimInitDone(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ xf86Entities[entityIndex]->entityProp &= ~SA_PRIM_INIT_DONE;
+ }
+}
+
+
+/*
+ * Allocate a private in the entities.
+ */
+
+int
+xf86AllocateEntityPrivateIndex(void)
+{
+ int idx, i;
+ EntityPtr pEnt;
+ DevUnion *nprivs;
+
+ idx = xf86EntityPrivateCount++;
+ for (i = 0; i < xf86NumEntities; i++) {
+ pEnt = xf86Entities[i];
+ nprivs = xnfrealloc(pEnt->entityPrivates,
+ xf86EntityPrivateCount * sizeof(DevUnion));
+ /* Zero the new private */
+ bzero(&nprivs[idx], sizeof(DevUnion));
+ pEnt->entityPrivates = nprivs;
+ }
+ return idx;
+}
+
+DevUnion *
+xf86GetEntityPrivate(int entityIndex, int privIndex)
+{
+ if (entityIndex >= xf86NumEntities || privIndex >= xf86EntityPrivateCount)
+ return NULL;
+
+ return &(xf86Entities[entityIndex]->entityPrivates[privIndex]);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Bus.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Bus.h
new file mode 100644
index 000000000..96da6e6a9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Bus.h
@@ -0,0 +1,162 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Bus.h,v 1.23 2003/08/24 17:36:50 dawes Exp $ */
+
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains definitions of the bus-related data structures/types.
+ * Everything contained here is private to xf86Bus.c. In particular the
+ * video drivers must not include this file.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _XF86_BUS_H
+#define _XF86_BUS_H
+
+#include "xf86pciBus.h"
+#ifdef __sparc__
+#include "xf86sbusBus.h"
+#endif
+
+typedef struct racInfo {
+ xf86AccessPtr mem_new;
+ xf86AccessPtr io_new;
+ xf86AccessPtr io_mem_new;
+ xf86SetAccessFuncPtr old;
+} AccessFuncRec, *AccessFuncPtr;
+
+
+typedef struct {
+ DriverPtr driver;
+ int chipset;
+ int entityProp;
+ EntityProc entityInit;
+ EntityProc entityEnter;
+ EntityProc entityLeave;
+ pointer private;
+ resPtr resources;
+ Bool active;
+ Bool inUse;
+ BusRec bus;
+ EntityAccessPtr access;
+ AccessFuncPtr rac;
+ pointer busAcc;
+ int lastScrnFlag;
+ DevUnion * entityPrivates;
+ int numInstances;
+ GDevPtr * devices;
+ IOADDRESS domainIO;
+} EntityRec, *EntityPtr;
+
+/* asynchronous event handling */
+#ifdef async
+typedef struct _AsyncQRec {
+ void (*func)(pointer);
+ pointer arg;
+ struct _AsyncQRec *next;
+} AsyncQRec, *AsyncQPtr;
+#endif
+
+#define NO_SEPARATE_IO_FROM_MEM 0x0001
+#define NO_SEPARATE_MEM_FROM_IO 0x0002
+#define NEED_VGA_ROUTED 0x0004
+#define NEED_VGA_ROUTED_SETUP 0x0008
+#define NEED_MEM 0x0010
+#define NEED_IO 0x0020
+#define NEED_MEM_SHARED 0x0040
+#define NEED_IO_SHARED 0x0080
+#define ACCEL_IS_SHARABLE 0x0100
+#define IS_SHARED_ACCEL 0x0200
+#define SA_PRIM_INIT_DONE 0x0400
+#define NEED_VGA_MEM 0x1000
+#define NEED_VGA_IO 0x2000
+
+#define NEED_SHARED (NEED_MEM_SHARED | NEED_IO_SHARED)
+
+#define busType bus.type
+#define pciBusId bus.id.pci
+#define isaBusId bus.id.isa
+#define sbusBusId bus.id.sbus
+
+struct x_BusAccRec;
+typedef void (*BusAccProcPtr)(struct x_BusAccRec *ptr);
+
+typedef struct x_BusAccRec {
+ BusAccProcPtr set_f;
+ BusAccProcPtr enable_f;
+ BusAccProcPtr disable_f;
+ BusAccProcPtr save_f;
+ BusAccProcPtr restore_f;
+ struct x_BusAccRec *current; /* pointer to bridge open on this bus */
+ struct x_BusAccRec *primary; /* pointer to the bus connecting to this */
+ struct x_BusAccRec *next; /* this links the different buses together */
+ BusType type;
+ BusType busdep_type;
+ /* Bus-specific fields */
+ union {
+ struct {
+ int bus;
+ int primary_bus;
+ PCITAG acc;
+ pciBridgesSave save;
+ } pci;
+ } busdep;
+} BusAccRec, *BusAccPtr;
+
+/* state change notification callback */
+typedef struct _stateChange {
+ xf86StateChangeNotificationCallbackFunc func;
+ pointer arg;
+ struct _stateChange *next;
+} StateChangeNotificationRec, *StateChangeNotificationPtr;
+
+
+extern EntityPtr *xf86Entities;
+extern int xf86NumEntities;
+extern xf86AccessRec AccessNULL;
+extern BusRec primaryBus;
+extern resPtr Acc;
+extern resPtr osRes;
+extern resPtr ResRange;
+extern BusAccPtr xf86BusAccInfo;
+
+int xf86AllocateEntity(void);
+BusType StringToBusType(const char* busID, const char **retID);
+memType ChkConflict(resRange *rgp, resPtr res, xf86State state);
+Bool xf86IsSubsetOf(resRange range, resPtr list);
+Bool xf86IsListSubsetOf(resPtr list, resPtr BaseList);
+resPtr xf86ExtractTypeFromList(resPtr list, unsigned long type);
+resPtr findIntersect(resRange Range, resPtr list);
+resPtr xf86FindIntersect(resRange Range, resPtr list);
+void RemoveOverlaps(resPtr target, resPtr list, Bool pow2Alignment,
+ Bool useEstimated);
+void xf86ConvertListToHost(int entityIndex, resPtr list);
+
+#endif /* _XF86_BUS_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Config.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Config.c
new file mode 100644
index 000000000..0f03560a7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Config.c
@@ -0,0 +1,2740 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 1.21 2005/12/20 22:30:50 alanc Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.276 2003/10/08 14:58:26 dawes Exp $ */
+
+
+/*
+ * Loosely based on code bearing the following copyright:
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ */
+
+/*
+ * Copyright 1992-2003 by The XFree86 Project, Inc.
+ * Copyright 1997 by Metro Link, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ *
+ * Authors:
+ * Dirk Hohndel <hohndel@XFree86.Org>
+ * David Dawes <dawes@XFree86.Org>
+ * Marc La France <tsi@XFree86.Org>
+ * Egbert Eich <eich@XFree86.Org>
+ * ... and others
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef XF86DRI
+#include <sys/types.h>
+#include <grp.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define I_NEED_OS2_H
+#endif
+
+#include "xf86.h"
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "xf86Config.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include "globals.h"
+
+#ifdef XINPUT
+#include "xf86Xinput.h"
+extern DeviceAssocRec mouse_assoc;
+#endif
+
+#ifdef XKB
+#define XKB_IN_SERVER
+#include <X11/extensions/XKBsrv.h>
+#endif
+
+#ifdef RENDER
+#include "picture.h"
+#endif
+
+#if (defined(i386) || defined(__i386__)) && \
+ (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
+ defined(__NetBSD__) || defined(linux) || \
+ (defined(SVR4) && !defined(sun)) || defined(__GNU__))
+#define SUPPORT_PC98
+#endif
+
+/*
+ * These paths define the way the config file search is done. The escape
+ * sequences are documented in parser/scan.c.
+ */
+#ifndef ROOT_CONFIGPATH
+#define ROOT_CONFIGPATH "%A," "%R," \
+ "/etc/X11/%R," "%P/etc/X11/%R," \
+ "%E," "%F," \
+ "/etc/X11/%F," "%P/etc/X11/%F," \
+ "%D/%X," \
+ "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
+ "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+ "%P/etc/X11/%X," \
+ "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+ "%P/lib/X11/%X"
+#endif
+#ifndef USER_CONFIGPATH
+#define USER_CONFIGPATH "/etc/X11/%S," "%P/etc/X11/%S," \
+ "/etc/X11/%G," "%P/etc/X11/%G," \
+ "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
+ "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+ "%P/etc/X11/%X," \
+ "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+ "%P/lib/X11/%X"
+#endif
+#ifndef PROJECTROOT
+#define PROJECTROOT "/usr/X11R6"
+#endif
+
+static char *fontPath = NULL;
+
+/* Forward declarations */
+static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen,
+ int scrnum, MessageType from);
+static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor);
+static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device,
+ Bool active);
+static Bool configInput(IDevPtr inputp, XF86ConfInputPtr conf_input,
+ MessageType from);
+static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display);
+static Bool addDefaultModes(MonPtr monitorp);
+#ifdef XF86DRI
+static Bool configDRI(XF86ConfDRIPtr drip);
+#endif
+static Bool configExtensions(XF86ConfExtensionsPtr conf_ext);
+
+/*
+ * xf86GetPathElem --
+ * Extract a single element from the font path string starting at
+ * pnt. The font path element will be returned, and pnt will be
+ * updated to point to the start of the next element, or set to
+ * NULL if there are no more.
+ */
+static char *
+xf86GetPathElem(char **pnt)
+{
+ char *p1;
+
+ p1 = *pnt;
+ *pnt = index(*pnt, ',');
+ if (*pnt != NULL) {
+ **pnt = '\0';
+ *pnt += 1;
+ }
+ return(p1);
+}
+
+/*
+ * xf86ValidateFontPath --
+ * Validates the user-specified font path. Each element that
+ * begins with a '/' is checked to make sure the directory exists.
+ * If the directory exists, the existence of a file named 'fonts.dir'
+ * is checked. If either check fails, an error is printed and the
+ * element is removed from the font path.
+ */
+
+#define DIR_FILE "/fonts.dir"
+static char *
+xf86ValidateFontPath(char *path)
+{
+ char *tmp_path, *out_pnt, *path_elem, *next, *p1, *dir_elem;
+ struct stat stat_buf;
+ int flag;
+ int dirlen;
+
+ tmp_path = xcalloc(1,strlen(path)+1);
+ out_pnt = tmp_path;
+ path_elem = NULL;
+ next = path;
+ while (next != NULL) {
+ path_elem = xf86GetPathElem(&next);
+ if (*path_elem == '/') {
+#ifndef __UNIXOS2__
+ dir_elem = xnfcalloc(1, strlen(path_elem) + 1);
+ if ((p1 = strchr(path_elem, ':')) != 0)
+#else
+ /* OS/2 must prepend X11ROOT */
+ path_elem = (char*)__XOS2RedirRoot(path_elem);
+ dir_elem = xnfcalloc(1, strlen(path_elem) + 1);
+ if (p1 = strchr(path_elem+2, ':'))
+#endif
+ dirlen = p1 - path_elem;
+ else
+ dirlen = strlen(path_elem);
+ strncpy(dir_elem, path_elem, dirlen);
+ dir_elem[dirlen] = '\0';
+ flag = stat(dir_elem, &stat_buf);
+ if (flag == 0)
+ if (!S_ISDIR(stat_buf.st_mode))
+ flag = -1;
+ if (flag != 0) {
+ xf86Msg(X_WARNING, "The directory \"%s\" does not exist.\n", dir_elem);
+ xf86ErrorF("\tEntry deleted from font path.\n");
+ xfree(dir_elem);
+ continue;
+ }
+ else {
+ p1 = xnfalloc(strlen(dir_elem)+strlen(DIR_FILE)+1);
+ strcpy(p1, dir_elem);
+ strcat(p1, DIR_FILE);
+ flag = stat(p1, &stat_buf);
+ if (flag == 0)
+ if (!S_ISREG(stat_buf.st_mode))
+ flag = -1;
+#ifndef __UNIXOS2__
+ xfree(p1);
+#endif
+ if (flag != 0) {
+ xf86Msg(X_WARNING,
+ "`fonts.dir' not found (or not valid) in \"%s\".\n",
+ dir_elem);
+ xf86ErrorF("\tEntry deleted from font path.\n");
+ xf86ErrorF("\t(Run 'mkfontdir' on \"%s\").\n", dir_elem);
+ xfree(dir_elem);
+ continue;
+ }
+ }
+ xfree(dir_elem);
+ }
+
+ /*
+ * Either an OK directory, or a font server name. So add it to
+ * the path.
+ */
+ if (out_pnt != tmp_path)
+ *out_pnt++ = ',';
+ strcat(out_pnt, path_elem);
+ out_pnt += strlen(path_elem);
+ }
+ return(tmp_path);
+}
+
+
+/*
+ * use the datastructure that the parser provides and pick out the parts
+ * that we need at this point
+ */
+char **
+xf86ModulelistFromConfig(pointer **optlist)
+{
+ int count = 0;
+ char **modulearray;
+ pointer *optarray;
+ XF86LoadPtr modp;
+
+ /*
+ * make sure the config file has been parsed and that we have a
+ * ModulePath set; if no ModulePath was given, use the default
+ * ModulePath
+ */
+ if (xf86configptr == NULL) {
+ xf86Msg(X_ERROR, "Cannot access global config data structure\n");
+ return NULL;
+ }
+
+ if (xf86configptr->conf_modules) {
+ /*
+ * Walk the list of modules in the "Module" section to determine how
+ * many we have.
+ */
+ modp = xf86configptr->conf_modules->mod_load_lst;
+ while (modp) {
+ count++;
+ modp = (XF86LoadPtr) modp->list.next;
+ }
+ }
+ if (count == 0)
+ return NULL;
+
+ /*
+ * allocate the memory and walk the list again to fill in the pointers
+ */
+ modulearray = xnfalloc((count + 1) * sizeof(char*));
+ optarray = xnfalloc((count + 1) * sizeof(pointer));
+ count = 0;
+ if (xf86configptr->conf_modules) {
+ modp = xf86configptr->conf_modules->mod_load_lst;
+ while (modp) {
+ modulearray[count] = modp->load_name;
+ optarray[count] = modp->load_opt;
+ count++;
+ modp = (XF86LoadPtr) modp->list.next;
+ }
+ }
+ modulearray[count] = NULL;
+ optarray[count] = NULL;
+ if (optlist)
+ *optlist = optarray;
+ else
+ xfree(optarray);
+ return modulearray;
+}
+
+
+char **
+xf86DriverlistFromConfig()
+{
+ int count = 0;
+ int j;
+ char **modulearray;
+ screenLayoutPtr slp;
+
+ /*
+ * make sure the config file has been parsed and that we have a
+ * ModulePath set; if no ModulePath was given, use the default
+ * ModulePath
+ */
+ if (xf86configptr == NULL) {
+ xf86Msg(X_ERROR, "Cannot access global config data structure\n");
+ return NULL;
+ }
+
+ /*
+ * Walk the list of driver lines in active "Device" sections to
+ * determine now many implicitly loaded modules there are.
+ *
+ */
+ if (xf86ConfigLayout.screens) {
+ slp = xf86ConfigLayout.screens;
+ while ((slp++)->screen) {
+ count++;
+ }
+ }
+
+ /*
+ * Handle the set of inactive "Device" sections.
+ */
+ j = 0;
+ while (xf86ConfigLayout.inactives[j++].identifier)
+ count++;
+
+ if (count == 0)
+ return NULL;
+
+ /*
+ * allocate the memory and walk the list again to fill in the pointers
+ */
+ modulearray = xnfalloc((count + 1) * sizeof(char*));
+ count = 0;
+ slp = xf86ConfigLayout.screens;
+ while (slp->screen) {
+ modulearray[count] = slp->screen->device->driver;
+ count++;
+ slp++;
+ }
+
+ j = 0;
+
+ while (xf86ConfigLayout.inactives[j].identifier)
+ modulearray[count++] = xf86ConfigLayout.inactives[j++].driver;
+
+ modulearray[count] = NULL;
+
+ /* Remove duplicates */
+ for (count = 0; modulearray[count] != NULL; count++) {
+ int i;
+
+ for (i = 0; i < count; i++)
+ if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
+ modulearray[count] = "";
+ break;
+ }
+ }
+ return modulearray;
+}
+
+
+Bool
+xf86BuiltinInputDriver(const char *name)
+{
+#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
+ if (xf86NameCmp(name, "keyboard") == 0)
+ return TRUE;
+ else
+#endif
+ return FALSE;
+}
+
+char **
+xf86InputDriverlistFromConfig()
+{
+ int count = 0;
+ char **modulearray;
+ IDevPtr idp;
+
+ /*
+ * make sure the config file has been parsed and that we have a
+ * ModulePath set; if no ModulePath was given, use the default
+ * ModulePath
+ */
+ if (xf86configptr == NULL) {
+ xf86Msg(X_ERROR, "Cannot access global config data structure\n");
+ return NULL;
+ }
+
+ /*
+ * Walk the list of driver lines in active "InputDevice" sections to
+ * determine now many implicitly loaded modules there are.
+ */
+ if (xf86ConfigLayout.inputs) {
+ idp = xf86ConfigLayout.inputs;
+ while (idp->identifier) {
+ if (!xf86BuiltinInputDriver(idp->driver))
+ count++;
+ idp++;
+ }
+ }
+
+ if (count == 0)
+ return NULL;
+
+ /*
+ * allocate the memory and walk the list again to fill in the pointers
+ */
+ modulearray = xnfalloc((count + 1) * sizeof(char*));
+ count = 0;
+ idp = xf86ConfigLayout.inputs;
+ while (idp->identifier) {
+ if (!xf86BuiltinInputDriver(idp->driver)) {
+ modulearray[count] = idp->driver;
+ count++;
+ }
+ idp++;
+ }
+ modulearray[count] = NULL;
+
+ /* Remove duplicates */
+ for (count = 0; modulearray[count] != NULL; count++) {
+ int i;
+
+ for (i = 0; i < count; i++)
+ if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
+ modulearray[count] = "";
+ break;
+ }
+ }
+ return modulearray;
+}
+
+static void
+fixup_video_driver_list(char **drivers)
+{
+ static const char *fallback[5] = { "vga", "vesa", "fbdev", "wsfb", NULL };
+ char **end, **drv;
+ char *x;
+ char **ati, **atimisc;
+ int i;
+
+ /* walk to the end of the list */
+ for (end = drivers; *end && **end; end++) ;
+ end--;
+
+ /*
+ * for each of the fallback drivers, if we find it in the list,
+ * swap it with the last available non-fallback driver.
+ */
+ for (i = 0; fallback[i]; i++) {
+ for (drv = drivers; drv != end; drv++) {
+ if (strstr(*drv, fallback[i])) {
+ x = *drv; *drv = *end; *end = x;
+ end--;
+ break;
+ }
+ }
+ }
+ /*
+ * since the ati wrapper driver is gross and awful, sort ati before
+ * atimisc, which makes sure all the ati symbols are visible in xorgcfg.
+ */
+ for (drv = drivers; drv != end; drv++) {
+ if (!strcmp(*drv, "atimisc")) {
+ atimisc = drv;
+ for (drv = atimisc; drv != end; drv++) {
+ if (!strcmp(*drv, "ati")) {
+ ati = drv;
+ x = *ati; *ati = *atimisc; *atimisc = x;
+ return;
+ }
+ }
+ /* if we get here, ati was already ahead of atimisc */
+ return;
+ }
+ }
+}
+
+
+/*
+ * Generate a compiled-in list of driver names. This is used to produce a
+ * consistent probe order. For the loader server, we also look for vendor-
+ * provided modules, pre-pending them to our own list.
+ */
+static char **
+GenerateDriverlist(char * dirname, char * drivernames)
+{
+#ifdef XFree86LOADER
+ char **ret;
+ char *subdirs[] = { dirname, NULL };
+ static const char *patlist[] = {"(.*)_drv\\.so", "(.*)_drv\\.o", NULL};
+ ret = LoaderListDirs(subdirs, patlist);
+
+ /* fix up the probe order for video drivers */
+ if (strstr(dirname, "drivers"))
+ fixup_video_driver_list(ret);
+
+ return ret;
+#else /* non-loadable server */
+ char *cp, **driverlist;
+ int count;
+
+ /* Count the number needed */
+ count = 0;
+ cp = drivernames;
+ while (*cp) {
+ while (*cp && isspace(*cp)) cp++;
+ if (!*cp) break;
+ count++;
+ while (*cp && !isspace(*cp)) cp++;
+ }
+
+ if (!count)
+ return NULL;
+
+ /* Now allocate the array of pointers to 0-terminated driver names */
+ driverlist = (char **)xnfalloc((count + 1) * sizeof(char *));
+ count = 0;
+ cp = drivernames;
+ while (*cp) {
+ while (*cp && isspace(*cp)) cp++;
+ if (!*cp) break;
+ driverlist[count++] = cp;
+ while (*cp && !isspace(*cp)) cp++;
+ if (!*cp) break;
+ *cp++ = 0;
+ }
+ driverlist[count] = NULL;
+
+ return driverlist;
+#endif
+}
+
+
+char **
+xf86DriverlistFromCompile(void)
+{
+ static char **driverlist = NULL;
+ static Bool generated = FALSE;
+
+ /* This string is modified in-place */
+ static char drivernames[] = DRIVERS;
+
+ if (!generated) {
+ generated = TRUE;
+ driverlist = GenerateDriverlist("drivers", drivernames);
+ }
+
+ return driverlist;
+}
+
+
+char **
+xf86InputDriverlistFromCompile(void)
+{
+ static char **driverlist = NULL;
+ static Bool generated = FALSE;
+
+ /* This string is modified in-place */
+ static char drivernames[] = IDRIVERS;
+
+ if (!generated) {
+ generated = TRUE;
+ driverlist = GenerateDriverlist("input", drivernames);
+ }
+
+ return driverlist;
+}
+
+
+/*
+ * xf86ConfigError --
+ * Print a READABLE ErrorMessage!!! All information that is
+ * available is printed.
+ */
+static void
+xf86ConfigError(char *msg, ...)
+{
+ va_list ap;
+
+ ErrorF("\nConfig Error:\n");
+ va_start(ap, msg);
+ VErrorF(msg, ap);
+ va_end(ap);
+ ErrorF("\n");
+ return;
+}
+
+static Bool
+configFiles(XF86ConfFilesPtr fileconf)
+{
+ MessageType pathFrom = X_DEFAULT;
+
+ /* FontPath */
+
+ /* Try XF86Config FontPath first */
+ if (!xf86fpFlag) {
+ if (fileconf) {
+ if (fileconf->file_fontpath) {
+ char *f = xf86ValidateFontPath(fileconf->file_fontpath);
+ pathFrom = X_CONFIG;
+ if (*f)
+ defaultFontPath = f;
+ else {
+ xf86Msg(X_WARNING,
+ "FontPath is completely invalid. Using compiled-in default.\n");
+ fontPath = NULL;
+ pathFrom = X_DEFAULT;
+ }
+ }
+ } else {
+ xf86Msg(X_WARNING,
+ "No FontPath specified. Using compiled-in default.\n");
+ pathFrom = X_DEFAULT;
+ }
+ } else {
+ /* Use fontpath specified with '-fp' */
+ if (fontPath)
+ {
+ fontPath = NULL;
+ }
+ pathFrom = X_CMDLINE;
+ }
+ if (!fileconf) {
+ /* xf86ValidateFontPath will write into it's arg, but defaultFontPath
+ could be static, so we make a copy. */
+ char *f = xnfalloc(strlen(defaultFontPath) + 1);
+ f[0] = '\0';
+ strcpy (f, defaultFontPath);
+ defaultFontPath = xf86ValidateFontPath(f);
+ xfree(f);
+ } else {
+ if (fileconf) {
+ if (!fileconf->file_fontpath) {
+ /* xf86ValidateFontPath will write into it's arg, but defaultFontPath
+ could be static, so we make a copy. */
+ char *f = xnfalloc(strlen(defaultFontPath) + 1);
+ f[0] = '\0';
+ strcpy (f, defaultFontPath);
+ defaultFontPath = xf86ValidateFontPath(f);
+ xfree(f);
+ }
+ }
+ }
+
+ /* If defaultFontPath is still empty, exit here */
+
+ if (! *defaultFontPath)
+ FatalError("No valid FontPath could be found.");
+
+ xf86Msg(pathFrom, "FontPath set to \"%s\"\n", defaultFontPath);
+
+ /* RgbPath */
+
+ pathFrom = X_DEFAULT;
+
+ if (xf86coFlag)
+ pathFrom = X_CMDLINE;
+ else if (fileconf) {
+ if (fileconf->file_rgbpath) {
+ rgbPath = fileconf->file_rgbpath;
+ pathFrom = X_CONFIG;
+ }
+ }
+
+ xf86Msg(pathFrom, "RgbPath set to \"%s\"\n", rgbPath);
+
+ if (fileconf && fileconf->file_inputdevs) {
+ xf86InputDeviceList = fileconf->file_inputdevs;
+ xf86Msg(X_CONFIG, "Input device list set to \"%s\"\n",
+ xf86InputDeviceList);
+ }
+
+
+#ifdef XFree86LOADER
+ /* ModulePath */
+
+ if (fileconf) {
+ if (xf86ModPathFrom != X_CMDLINE && fileconf->file_modulepath) {
+ xf86ModulePath = fileconf->file_modulepath;
+ xf86ModPathFrom = X_CONFIG;
+ }
+ }
+
+ xf86Msg(xf86ModPathFrom, "ModulePath set to \"%s\"\n", xf86ModulePath);
+#endif
+
+#if 0
+ /* LogFile */
+ /*
+ * XXX The problem with this is that the log file is already open.
+ * One option might be to copy the exiting contents to the new location.
+ * and re-open it. The down side is that the default location would
+ * already have been overwritten. Another option would be to start with
+ * unique temporary location, then copy it once the correct name is known.
+ * A problem with this is what happens if the server exits before that
+ * happens.
+ */
+ if (xf86LogFileFrom == X_DEFAULT && fileconf->file_logfile) {
+ xf86LogFile = fileconf->file_logfile;
+ xf86LogFileFrom = X_CONFIG;
+ }
+#endif
+
+ return TRUE;
+}
+
+typedef enum {
+ FLAG_NOTRAPSIGNALS,
+ FLAG_DONTVTSWITCH,
+ FLAG_DONTZAP,
+ FLAG_DONTZOOM,
+ FLAG_DISABLEVIDMODE,
+ FLAG_ALLOWNONLOCAL,
+ FLAG_DISABLEMODINDEV,
+ FLAG_MODINDEVALLOWNONLOCAL,
+ FLAG_ALLOWMOUSEOPENFAIL,
+ FLAG_VTINIT,
+ FLAG_VTSYSREQ,
+ FLAG_XKBDISABLE,
+ FLAG_PCIPROBE1,
+ FLAG_PCIPROBE2,
+ FLAG_PCIFORCECONFIG1,
+ FLAG_PCIFORCECONFIG2,
+ FLAG_PCIFORCENONE,
+ FLAG_PCIOSCONFIG,
+ FLAG_SAVER_BLANKTIME,
+ FLAG_DPMS_STANDBYTIME,
+ FLAG_DPMS_SUSPENDTIME,
+ FLAG_DPMS_OFFTIME,
+ FLAG_PIXMAP,
+ FLAG_PC98,
+ FLAG_ESTIMATE_SIZES_AGGRESSIVELY,
+ FLAG_NOPM,
+ FLAG_XINERAMA,
+ FLAG_ALLOW_DEACTIVATE_GRABS,
+ FLAG_ALLOW_CLOSEDOWN_GRABS,
+ FLAG_LOG,
+ FLAG_RENDER_COLORMAP_MODE,
+ FLAG_HANDLE_SPECIAL_KEYS,
+ FLAG_RANDR
+} FlagValues;
+
+static OptionInfoRec FlagOptions[] = {
+ { FLAG_NOTRAPSIGNALS, "NoTrapSignals", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_DONTVTSWITCH, "DontVTSwitch", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_DONTZAP, "DontZap", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_DONTZOOM, "DontZoom", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_DISABLEVIDMODE, "DisableVidModeExtension", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_ALLOWNONLOCAL, "AllowNonLocalXvidtune", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_DISABLEMODINDEV, "DisableModInDev", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_MODINDEVALLOWNONLOCAL, "AllowNonLocalModInDev", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_ALLOWMOUSEOPENFAIL, "AllowMouseOpenFail", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_VTINIT, "VTInit", OPTV_STRING,
+ {0}, FALSE },
+ { FLAG_VTSYSREQ, "VTSysReq", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_XKBDISABLE, "XkbDisable", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_PCIPROBE1, "PciProbe1" , OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_PCIPROBE2, "PciProbe2", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_PCIFORCECONFIG1, "PciForceConfig1", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_PCIFORCECONFIG2, "PciForceConfig2", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_PCIFORCENONE, "PciForceNone", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_PCIOSCONFIG, "PciOsConfig", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_SAVER_BLANKTIME, "BlankTime" , OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_DPMS_STANDBYTIME, "StandbyTime", OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_DPMS_SUSPENDTIME, "SuspendTime", OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_DPMS_OFFTIME, "OffTime", OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_PIXMAP, "Pixmap", OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_PC98, "PC98", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_ESTIMATE_SIZES_AGGRESSIVELY,"EstimateSizesAggressively",OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_NOPM, "NoPM", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_XINERAMA, "Xinerama", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_ALLOW_DEACTIVATE_GRABS,"AllowDeactivateGrabs", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_ALLOW_CLOSEDOWN_GRABS, "AllowClosedownGrabs", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_LOG, "Log", OPTV_STRING,
+ {0}, FALSE },
+ { FLAG_RENDER_COLORMAP_MODE, "RenderColormapMode", OPTV_STRING,
+ {0}, FALSE },
+ { FLAG_HANDLE_SPECIAL_KEYS, "HandleSpecialKeys", OPTV_STRING,
+ {0}, FALSE },
+ { FLAG_RANDR, "RandR", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { -1, NULL, OPTV_NONE,
+ {0}, FALSE },
+};
+
+#if defined(i386) || defined(__i386__)
+static Bool
+detectPC98(void)
+{
+#ifdef SUPPORT_PC98
+ unsigned char buf[2];
+
+ if (xf86ReadBIOS(0xf8000, 0xe80, buf, 2) != 2)
+ return FALSE;
+ if ((buf[0] == 0x98) && (buf[1] == 0x21))
+ return TRUE;
+ else
+ return FALSE;
+#else
+ return FALSE;
+#endif
+}
+#endif /* __i386__ */
+
+static Bool
+configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
+{
+ XF86OptionPtr optp, tmp;
+ int i;
+ Pix24Flags pix24 = Pix24DontCare;
+ Bool value;
+ MessageType from;
+
+ /*
+ * Merge the ServerLayout and ServerFlags options. The former have
+ * precedence over the latter.
+ */
+ optp = NULL;
+ if (flagsconf && flagsconf->flg_option_lst)
+ optp = xf86optionListDup(flagsconf->flg_option_lst);
+ if (layoutopts) {
+ tmp = xf86optionListDup(layoutopts);
+ if (optp)
+ optp = xf86optionListMerge(optp, tmp);
+ else
+ optp = tmp;
+ }
+
+ xf86ProcessOptions(-1, optp, FlagOptions);
+
+ xf86GetOptValBool(FlagOptions, FLAG_NOTRAPSIGNALS, &xf86Info.notrapSignals);
+ xf86GetOptValBool(FlagOptions, FLAG_DONTVTSWITCH, &xf86Info.dontVTSwitch);
+ xf86GetOptValBool(FlagOptions, FLAG_DONTZAP, &xf86Info.dontZap);
+ xf86GetOptValBool(FlagOptions, FLAG_DONTZOOM, &xf86Info.dontZoom);
+
+ xf86GetOptValBool(FlagOptions, FLAG_ALLOW_DEACTIVATE_GRABS,
+ &(xf86Info.grabInfo.allowDeactivate));
+ xf86GetOptValBool(FlagOptions, FLAG_ALLOW_CLOSEDOWN_GRABS,
+ &(xf86Info.grabInfo.allowClosedown));
+
+ /*
+ * Set things up based on the config file information. Some of these
+ * settings may be overridden later when the command line options are
+ * checked.
+ */
+#ifdef XF86VIDMODE
+ if (xf86GetOptValBool(FlagOptions, FLAG_DISABLEVIDMODE, &value))
+ xf86Info.vidModeEnabled = !value;
+ if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWNONLOCAL, &value))
+ xf86Info.vidModeAllowNonLocal = value;
+#endif
+
+#ifdef XF86MISC
+ if (xf86GetOptValBool(FlagOptions, FLAG_DISABLEMODINDEV, &value))
+ xf86Info.miscModInDevEnabled = !value;
+ if (xf86GetOptValBool(FlagOptions, FLAG_MODINDEVALLOWNONLOCAL, &value))
+ xf86Info.miscModInDevAllowNonLocal = value;
+#endif
+
+ if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWMOUSEOPENFAIL, &value))
+ xf86Info.allowMouseOpenFail = value;
+
+ if (xf86GetOptValBool(FlagOptions, FLAG_VTSYSREQ, &value)) {
+#ifdef USE_VT_SYSREQ
+ xf86Info.vtSysreq = value;
+ xf86Msg(X_CONFIG, "VTSysReq %s\n", value ? "enabled" : "disabled");
+#else
+ if (value)
+ xf86Msg(X_WARNING, "VTSysReq is not supported on this OS\n");
+#endif
+ }
+
+ if (xf86GetOptValBool(FlagOptions, FLAG_XKBDISABLE, &value)) {
+#ifdef XKB
+ noXkbExtension = value;
+ xf86Msg(X_CONFIG, "Xkb %s\n", value ? "disabled" : "enabled");
+#else
+ if (!value)
+ xf86Msg(X_WARNING, "Xserver doesn't support XKB\n");
+#endif
+ }
+
+ xf86Info.vtinit = xf86GetOptValString(FlagOptions, FLAG_VTINIT);
+
+ if (xf86IsOptionSet(FlagOptions, FLAG_PCIPROBE1))
+ xf86Info.pciFlags = PCIProbe1;
+ if (xf86IsOptionSet(FlagOptions, FLAG_PCIPROBE2))
+ xf86Info.pciFlags = PCIProbe2;
+ if (xf86IsOptionSet(FlagOptions, FLAG_PCIFORCECONFIG1))
+ xf86Info.pciFlags = PCIForceConfig1;
+ if (xf86IsOptionSet(FlagOptions, FLAG_PCIFORCECONFIG2))
+ xf86Info.pciFlags = PCIForceConfig2;
+ if (xf86IsOptionSet(FlagOptions, FLAG_PCIOSCONFIG))
+ xf86Info.pciFlags = PCIOsConfig;
+ if (xf86IsOptionSet(FlagOptions, FLAG_PCIFORCENONE))
+ xf86Info.pciFlags = PCIForceNone;
+
+ xf86Info.pmFlag = TRUE;
+ if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value))
+ xf86Info.pmFlag = !value;
+ {
+ const char *s;
+ if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) {
+ if (!xf86NameCmp(s,"flush")) {
+ xf86Msg(X_CONFIG, "Flushing logfile enabled\n");
+ xf86Info.log = LogFlush;
+ LogSetParameter(XLOG_FLUSH, TRUE);
+ } else if (!xf86NameCmp(s,"sync")) {
+ xf86Msg(X_CONFIG, "Syncing logfile enabled\n");
+ xf86Info.log = LogSync;
+ LogSetParameter(XLOG_SYNC, TRUE);
+ } else {
+ xf86Msg(X_WARNING,"Unknown Log option\n");
+ }
+ }
+ }
+
+#ifdef RENDER
+ {
+ const char *s;
+
+ if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))){
+ int policy = PictureParseCmapPolicy (s);
+ if (policy == PictureCmapPolicyInvalid)
+ xf86Msg(X_WARNING, "Unknown colormap policy \"%s\"\n", s);
+ else
+ {
+ xf86Msg(X_CONFIG, "Render colormap policy set to %s\n", s);
+ PictureCmapPolicy = policy;
+ }
+ }
+ }
+#endif
+ {
+ const char *s;
+ if ((s = xf86GetOptValString(FlagOptions, FLAG_HANDLE_SPECIAL_KEYS))) {
+ if (!xf86NameCmp(s,"always")) {
+ xf86Msg(X_CONFIG, "Always handling special keys in DDX\n");
+ xf86Info.ddxSpecialKeys = SKAlways;
+ } else if (!xf86NameCmp(s,"whenneeded")) {
+ xf86Msg(X_CONFIG, "Special keys handled in DDX only if needed\n");
+ xf86Info.ddxSpecialKeys = SKWhenNeeded;
+ } else if (!xf86NameCmp(s,"never")) {
+ xf86Msg(X_CONFIG, "Never handling special keys in DDX\n");
+ xf86Info.ddxSpecialKeys = SKNever;
+ } else {
+ xf86Msg(X_WARNING,"Unknown HandleSpecialKeys option\n");
+ }
+ }
+ }
+#ifdef RANDR
+ xf86Info.disableRandR = FALSE;
+ xf86Info.randRFrom = X_DEFAULT;
+ if (xf86GetOptValBool(FlagOptions, FLAG_RANDR, &value)) {
+ xf86Info.disableRandR = !value;
+ xf86Info.randRFrom = X_CONFIG;
+ }
+#endif
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_ESTIMATE_SIZES_AGGRESSIVELY, &i);
+ if (i >= 0)
+ xf86Info.estimateSizesAggressively = i;
+ else
+ xf86Info.estimateSizesAggressively = 0;
+
+/* Make sure that timers don't overflow CARD32's after multiplying */
+#define MAX_TIME_IN_MIN (0x7fffffff / MILLI_PER_MIN)
+
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_SAVER_BLANKTIME, &i);
+ if ((i >= 0) && (i < MAX_TIME_IN_MIN))
+ ScreenSaverTime = defaultScreenSaverTime = i * MILLI_PER_MIN;
+ else if (i != -1)
+ xf86ConfigError("BlankTime value %d outside legal range of 0 - %d minutes",
+ i, MAX_TIME_IN_MIN);
+
+#ifdef DPMSExtension
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_DPMS_STANDBYTIME, &i);
+ if ((i >= 0) && (i < MAX_TIME_IN_MIN))
+ DPMSStandbyTime = defaultDPMSStandbyTime = i * MILLI_PER_MIN;
+ else if (i != -1)
+ xf86ConfigError("StandbyTime value %d outside legal range of 0 - %d minutes",
+ i, MAX_TIME_IN_MIN);
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_DPMS_SUSPENDTIME, &i);
+ if ((i >= 0) && (i < MAX_TIME_IN_MIN))
+ DPMSSuspendTime = defaultDPMSSuspendTime = i * MILLI_PER_MIN;
+ else if (i != -1)
+ xf86ConfigError("SuspendTime value %d outside legal range of 0 - %d minutes",
+ i, MAX_TIME_IN_MIN);
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_DPMS_OFFTIME, &i);
+ if ((i >= 0) && (i < MAX_TIME_IN_MIN))
+ DPMSOffTime = defaultDPMSOffTime = i * MILLI_PER_MIN;
+ else if (i != -1)
+ xf86ConfigError("OffTime value %d outside legal range of 0 - %d minutes",
+ i, MAX_TIME_IN_MIN);
+#endif
+
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_PIXMAP, &i);
+ switch (i) {
+ case 24:
+ pix24 = Pix24Use24;
+ break;
+ case 32:
+ pix24 = Pix24Use32;
+ break;
+ case -1:
+ break;
+ default:
+ xf86ConfigError("Pixmap option's value (%d) must be 24 or 32\n", i);
+ return FALSE;
+ }
+ if (xf86Pix24 != Pix24DontCare) {
+ xf86Info.pixmap24 = xf86Pix24;
+ xf86Info.pix24From = X_CMDLINE;
+ } else if (pix24 != Pix24DontCare) {
+ xf86Info.pixmap24 = pix24;
+ xf86Info.pix24From = X_CONFIG;
+ } else {
+ xf86Info.pixmap24 = Pix24DontCare;
+ xf86Info.pix24From = X_DEFAULT;
+ }
+#if defined(i386) || defined(__i386__)
+ if (xf86GetOptValBool(FlagOptions, FLAG_PC98, &value)) {
+ xf86Info.pc98 = value;
+ if (value) {
+ xf86Msg(X_CONFIG, "Japanese PC98 architecture\n");
+ }
+ } else
+ if (detectPC98()) {
+ xf86Info.pc98 = TRUE;
+ xf86Msg(X_PROBED, "Japanese PC98 architecture\n");
+ }
+#endif
+
+#ifdef PANORAMIX
+ from = X_DEFAULT;
+ if (!noPanoramiXExtension)
+ from = X_CMDLINE;
+ else if (xf86GetOptValBool(FlagOptions, FLAG_XINERAMA, &value)) {
+ noPanoramiXExtension = !value;
+ from = X_CONFIG;
+ }
+ if (!noPanoramiXExtension)
+ xf86Msg(from, "Xinerama: enabled\n");
+#endif
+
+ return TRUE;
+}
+
+/*
+ * XXX This function is temporary, and will be removed when the keyboard
+ * driver is converted into a regular input driver.
+ */
+static Bool
+configInputKbd(IDevPtr inputp)
+{
+ char *s;
+ MessageType from = X_DEFAULT;
+ Bool customKeycodesDefault = FALSE;
+ int verb = 0;
+#if defined(XQUEUE)
+ char *kbdproto = "Xqueue";
+#else
+ char *kbdproto = "standard";
+#endif
+
+ /* Initialize defaults */
+ xf86Info.xleds = 0L;
+ xf86Info.kbdDelay = 500;
+ xf86Info.kbdRate = 30;
+
+ xf86Info.kbdProc = NULL;
+ xf86Info.vtinit = NULL;
+ xf86Info.vtSysreq = VT_SYSREQ_DEFAULT;
+#if defined(SVR4) && defined(i386)
+ xf86Info.panix106 = FALSE;
+#endif
+ xf86Info.kbdCustomKeycodes = FALSE;
+#ifdef WSCONS_SUPPORT
+ xf86Info.kbdFd = -1;
+#endif
+#ifdef XKB
+ if (!xf86IsPc98()) {
+ xf86Info.xkbrules = __XKBDEFRULES__;
+ xf86Info.xkbmodel = "pc105";
+ xf86Info.xkblayout = "us";
+ xf86Info.xkbvariant = NULL;
+ xf86Info.xkboptions = NULL;
+ } else {
+ xf86Info.xkbrules = "xfree98";
+ xf86Info.xkbmodel = "pc98";
+ xf86Info.xkblayout = "nec/jp";
+ xf86Info.xkbvariant = NULL;
+ xf86Info.xkboptions = NULL;
+ }
+ xf86Info.xkbcomponents_specified = FALSE;
+ /* Should discourage the use of these. */
+ xf86Info.xkbkeymap = NULL;
+ xf86Info.xkbtypes = NULL;
+ xf86Info.xkbcompat = NULL;
+ xf86Info.xkbkeycodes = NULL;
+ xf86Info.xkbsymbols = NULL;
+ xf86Info.xkbgeometry = NULL;
+#endif
+
+ s = xf86SetStrOption(inputp->commonOptions, "Protocol", kbdproto);
+ if (xf86NameCmp(s, "standard") == 0) {
+ xf86Info.kbdProc = xf86KbdProc;
+ xf86Info.kbdEvents = xf86KbdEvents;
+ xfree(s);
+ } else if (xf86NameCmp(s, "xqueue") == 0) {
+#ifdef __UNIXWARE__
+ /*
+ * To retain compatibility with older config files, on UnixWare, we
+ * accept the xqueue protocol but use the normal keyboard procs.
+ */
+ xf86Info.kbdProc = xf86KbdProc;
+ xf86Info.kbdEvents = xf86KbdEvents;
+#else
+#ifdef XQUEUE
+ xf86Info.kbdProc = xf86XqueKbdProc;
+ xf86Info.kbdEvents = xf86XqueEvents;
+ xf86Msg(X_CONFIG, "Xqueue selected for keyboard input\n");
+#endif
+#endif
+ xfree(s);
+#ifdef WSCONS_SUPPORT
+ } else if (xf86NameCmp(s, "wskbd") == 0) {
+ xf86Info.kbdProc = xf86KbdProc;
+ xf86Info.kbdEvents = xf86WSKbdEvents;
+ xfree(s);
+ s = xf86SetStrOption(inputp->commonOptions, "Device", NULL);
+ xf86Msg(X_CONFIG, "Keyboard: Protocol: wskbd\n");
+ if (s == NULL) {
+ xf86ConfigError("A \"device\" option is required with"
+ " the \"wskbd\" keyboard protocol");
+ return FALSE;
+ }
+ xf86Info.kbdFd = open(s, O_RDWR | O_NONBLOCK | O_EXCL);
+ if (xf86Info.kbdFd == -1) {
+ xf86ConfigError("cannot open \"%s\"", s);
+ xfree(s);
+ return FALSE;
+ }
+ xfree(s);
+ /* Find out keyboard type */
+ if (ioctl(xf86Info.kbdFd, WSKBDIO_GTYPE, &xf86Info.wsKbdType) == -1) {
+ xf86ConfigError("cannot get keyboard type");
+ close(xf86Info.kbdFd);
+ return FALSE;
+ }
+ switch (xf86Info.wsKbdType) {
+ case WSKBD_TYPE_PC_XT:
+ xf86Msg(X_PROBED, "Keyboard type: XT\n");
+ break;
+ case WSKBD_TYPE_PC_AT:
+ xf86Msg(X_PROBED, "Keyboard type: AT\n");
+ break;
+ case WSKBD_TYPE_USB:
+ xf86Msg(X_PROBED, "Keyboard type: USB\n");
+ break;
+#ifdef WSKBD_TYPE_ADB
+ case WSKBD_TYPE_ADB:
+ xf86Msg(X_PROBED, "Keyboard type: ADB\n");
+ break;
+#endif
+#ifdef WSKBD_TYPE_SUN
+ case WSKBD_TYPE_SUN:
+ xf86Msg(X_PROBED, "Keyboard type: Sun\n");
+ break;
+#endif
+#ifdef WSKBD_TYPE_SUN5
+ case WSKBD_TYPE_SUN5:
+ xf86Msg(X_PROBED, "Keyboard type: Sun5\n");
+ break;
+#endif
+ default:
+ xf86ConfigError("Unsupported wskbd type \"%d\"",
+ xf86Info.wsKbdType);
+ close(xf86Info.kbdFd);
+ return FALSE;
+ }
+#endif
+ } else {
+ xf86ConfigError("\"%s\" is not a valid keyboard protocol name", s);
+ xfree(s);
+ return FALSE;
+ }
+
+ s = xf86SetStrOption(inputp->commonOptions, "AutoRepeat", NULL);
+ if (s) {
+ if (sscanf(s, "%d %d", &xf86Info.kbdDelay, &xf86Info.kbdRate) != 2) {
+ xf86ConfigError("\"%s\" is not a valid AutoRepeat value", s);
+ xfree(s);
+ return FALSE;
+ }
+ xfree(s);
+ }
+
+ s = xf86SetStrOption(inputp->commonOptions, "XLeds", NULL);
+ if (s) {
+ char *l, *end;
+ unsigned int i;
+ l = strtok(s, " \t\n");
+ while (l) {
+ i = strtoul(l, &end, 0);
+ if (*end == '\0')
+ xf86Info.xleds |= 1L << (i - 1);
+ else {
+ xf86ConfigError("\"%s\" is not a valid XLeds value", l);
+ xfree(s);
+ return FALSE;
+ }
+ l = strtok(NULL, " \t\n");
+ }
+ xfree(s);
+ }
+
+#ifdef XKB
+ from = X_DEFAULT;
+ if (noXkbExtension)
+ from = X_CMDLINE;
+ else if (xf86FindOption(inputp->commonOptions, "XkbDisable")) {
+ xf86Msg(X_WARNING, "KEYBOARD: XKB should be disabled in the "
+ "ServerFlags section instead\n"
+ "\tof in the \"keyboard\" InputDevice section.\n");
+ noXkbExtension =
+ xf86SetBoolOption(inputp->commonOptions, "XkbDisable", FALSE);
+ from = X_CONFIG;
+ }
+ if (noXkbExtension)
+ xf86Msg(from, "XKB: disabled\n");
+
+#define NULL_IF_EMPTY(s) (s[0] ? s : (xfree(s), (char *)NULL))
+
+ if (!noXkbExtension && !XkbInitialMap) {
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbKeymap", NULL))) {
+ xf86Info.xkbkeymap = NULL_IF_EMPTY(s);
+ xf86Msg(X_CONFIG, "XKB: keymap: \"%s\" "
+ "(overrides other XKB settings)\n", xf86Info.xkbkeymap);
+ } else {
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbCompat", NULL))) {
+ xf86Info.xkbcompat = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: compat: \"%s\"\n", s);
+ }
+
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbTypes", NULL))) {
+ xf86Info.xkbtypes = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: types: \"%s\"\n", s);
+ }
+
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbKeycodes", NULL))) {
+ xf86Info.xkbkeycodes = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: keycodes: \"%s\"\n", s);
+ }
+
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbGeometry", NULL))) {
+ xf86Info.xkbgeometry = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: geometry: \"%s\"\n", s);
+ }
+
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbSymbols", NULL))) {
+ xf86Info.xkbsymbols = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: symbols: \"%s\"\n", s);
+ }
+
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbRules", NULL))) {
+ xf86Info.xkbrules = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: rules: \"%s\"\n", s);
+ }
+
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbModel", NULL))) {
+ xf86Info.xkbmodel = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: model: \"%s\"\n", s);
+ }
+
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbLayout", NULL))) {
+ xf86Info.xkblayout = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: layout: \"%s\"\n", s);
+ }
+
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbVariant", NULL))) {
+ xf86Info.xkbvariant = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: variant: \"%s\"\n", s);
+ }
+
+ if ((s = xf86SetStrOption(inputp->commonOptions, "XkbOptions", NULL))) {
+ xf86Info.xkboptions = NULL_IF_EMPTY(s);
+ xf86Info.xkbcomponents_specified = TRUE;
+ xf86Msg(X_CONFIG, "XKB: options: \"%s\"\n", s);
+ }
+ }
+ }
+#undef NULL_IF_EMPTY
+#endif
+#if defined(SVR4) && defined(i386)
+ if ((xf86Info.panix106 =
+ xf86SetBoolOption(inputp->commonOptions, "Panix106", FALSE))) {
+ xf86Msg(X_CONFIG, "PANIX106: enabled\n");
+ }
+#endif
+
+ /*
+ * This was once a compile time option (ASSUME_CUSTOM_KEYCODES)
+ * defaulting to 1 on Linux/PPC. It is no longer necessary, but for
+ * backwards compatibility we provide 'Option "CustomKeycodes"'
+ * and try to autoprobe on Linux/PPC.
+ */
+ from = X_DEFAULT;
+ verb = 2;
+#if defined(__linux__) && defined(__powerpc__)
+ {
+ FILE *f;
+
+ f = fopen("/proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes","r");
+ if (f) {
+ if (fgetc(f) == '0') {
+ customKeycodesDefault = TRUE;
+ from = X_PROBED;
+ verb = 1;
+ }
+ fclose(f);
+ }
+ }
+#endif
+ if (xf86FindOption(inputp->commonOptions, "CustomKeycodes")) {
+ from = X_CONFIG;
+ verb = 1;
+ }
+ xf86Info.kbdCustomKeycodes =
+ xf86SetBoolOption(inputp->commonOptions, "CustomKeycodes",
+ customKeycodesDefault);
+ xf86MsgVerb(from, verb, "Keyboard: CustomKeycode %s\n",
+ xf86Info.kbdCustomKeycodes ? "enabled" : "disabled");
+
+ return TRUE;
+}
+
+/*
+ * Locate the core input devices. These can be specified/located in
+ * the following ways, in order of priority:
+ *
+ * 1. The InputDevices named by the -pointer and -keyboard command line
+ * options.
+ * 2. The "CorePointer" and "CoreKeyboard" InputDevices referred to by
+ * the active ServerLayout.
+ * 3. The first InputDevices marked as "CorePointer" and "CoreKeyboard".
+ * 4. The first InputDevices that use the 'mouse' and 'keyboard' or 'kbd'
+ * drivers.
+ * 5. Default devices with an empty (default) configuration. These defaults
+ * will reference the 'mouse' and 'keyboard' drivers.
+ */
+
+static Bool
+checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
+{
+ IDevPtr corePointer = NULL, coreKeyboard = NULL;
+ Bool foundPointer = FALSE, foundKeyboard = FALSE;
+ const char *pointerMsg = NULL, *keyboardMsg = NULL;
+ IDevPtr indp;
+ IDevRec Pointer, Keyboard;
+ XF86ConfInputPtr confInput;
+ XF86ConfInputRec defPtr, defKbd;
+ int count = 0;
+ MessageType from = X_DEFAULT;
+
+ /*
+ * First check if a core pointer or core keyboard have been specified
+ * in the active ServerLayout. If more than one is specified for either,
+ * remove the core attribute from the later ones.
+ */
+ for (indp = servlayoutp->inputs; indp->identifier; indp++) {
+ pointer opt1 = NULL, opt2 = NULL;
+ if (indp->commonOptions &&
+ xf86CheckBoolOption(indp->commonOptions, "CorePointer", FALSE)) {
+ opt1 = indp->commonOptions;
+ }
+ if (indp->extraOptions &&
+ xf86CheckBoolOption(indp->extraOptions, "CorePointer", FALSE)) {
+ opt2 = indp->extraOptions;
+ }
+ if (opt1 || opt2) {
+ if (!corePointer) {
+ corePointer = indp;
+ } else {
+ if (opt1)
+ xf86ReplaceBoolOption(opt1, "CorePointer", FALSE);
+ if (opt2)
+ xf86ReplaceBoolOption(opt2, "CorePointer", FALSE);
+ xf86Msg(X_WARNING, "Duplicate core pointer devices. "
+ "Removing core pointer attribute from \"%s\"\n",
+ indp->identifier);
+ }
+ }
+ opt1 = opt2 = NULL;
+ if (indp->commonOptions &&
+ xf86CheckBoolOption(indp->commonOptions, "CoreKeyboard", FALSE)) {
+ opt1 = indp->commonOptions;
+ }
+ if (indp->extraOptions &&
+ xf86CheckBoolOption(indp->extraOptions, "CoreKeyboard", FALSE)) {
+ opt2 = indp->extraOptions;
+ }
+ if (opt1 || opt2) {
+ if (!coreKeyboard) {
+ coreKeyboard = indp;
+ } else {
+ if (opt1)
+ xf86ReplaceBoolOption(opt1, "CoreKeyboard", FALSE);
+ if (opt2)
+ xf86ReplaceBoolOption(opt2, "CoreKeyboard", FALSE);
+ xf86Msg(X_WARNING, "Duplicate core keyboard devices. "
+ "Removing core keyboard attribute from \"%s\"\n",
+ indp->identifier);
+ }
+ }
+ count++;
+ }
+
+ confInput = NULL;
+
+ /* 1. Check for the -pointer command line option. */
+ if (xf86PointerName) {
+ confInput = xf86findInput(xf86PointerName,
+ xf86configptr->conf_input_lst);
+ if (!confInput) {
+ xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
+ xf86PointerName);
+ return FALSE;
+ }
+ from = X_CMDLINE;
+ /*
+ * If one was already specified in the ServerLayout, it needs to be
+ * removed.
+ */
+ if (corePointer) {
+ for (indp = servlayoutp->inputs; indp->identifier; indp++)
+ if (indp == corePointer)
+ break;
+ for (; indp->identifier; indp++)
+ indp[0] = indp[1];
+ count--;
+ }
+ corePointer = NULL;
+ foundPointer = TRUE;
+ }
+
+ /* 2. ServerLayout-specified core pointer. */
+ if (corePointer) {
+ foundPointer = TRUE;
+ from = X_CONFIG;
+ }
+
+ /* 3. First core pointer device. */
+ if (!foundPointer) {
+ XF86ConfInputPtr p;
+
+ for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
+ if (p->inp_option_lst &&
+ xf86CheckBoolOption(p->inp_option_lst, "CorePointer", FALSE)) {
+ confInput = p;
+ foundPointer = TRUE;
+ from = X_DEFAULT;
+ pointerMsg = "first core pointer device";
+ break;
+ }
+ }
+ }
+
+ /* 4. First pointer with 'mouse' as the driver. */
+ if (!foundPointer) {
+ confInput = xf86findInput(CONF_IMPLICIT_POINTER,
+ xf86configptr->conf_input_lst);
+ if (!confInput) {
+ confInput = xf86findInputByDriver("mouse",
+ xf86configptr->conf_input_lst);
+ }
+ if (confInput) {
+ foundPointer = TRUE;
+ from = X_DEFAULT;
+ pointerMsg = "first mouse device";
+ }
+ }
+
+ /* 5. Built-in default. */
+ if (!foundPointer) {
+ bzero(&defPtr, sizeof(defPtr));
+ defPtr.inp_identifier = "<default pointer>";
+ defPtr.inp_driver = "mouse";
+ confInput = &defPtr;
+ foundPointer = TRUE;
+ from = X_DEFAULT;
+ pointerMsg = "default mouse configuration";
+ }
+
+ /* Add the core pointer device to the layout, and set it to Core. */
+ if (foundPointer && confInput) {
+ foundPointer = configInput(&Pointer, confInput, from);
+ if (foundPointer) {
+ count++;
+ indp = xnfrealloc(servlayoutp->inputs,
+ (count + 1) * sizeof(IDevRec));
+ indp[count - 1] = Pointer;
+ indp[count - 1].extraOptions =
+ xf86addNewOption(NULL, "CorePointer", NULL);
+ indp[count].identifier = NULL;
+ servlayoutp->inputs = indp;
+ }
+ }
+
+ if (!foundPointer) {
+ /* This shouldn't happen. */
+ xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
+ return FALSE;
+ }
+
+ confInput = NULL;
+
+ /* 1. Check for the -keyboard command line option. */
+ if (xf86KeyboardName) {
+ confInput = xf86findInput(xf86KeyboardName,
+ xf86configptr->conf_input_lst);
+ if (!confInput) {
+ xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
+ xf86KeyboardName);
+ return FALSE;
+ }
+ from = X_CMDLINE;
+ /*
+ * If one was already specified in the ServerLayout, it needs to be
+ * removed.
+ */
+ if (coreKeyboard) {
+ for (indp = servlayoutp->inputs; indp->identifier; indp++)
+ if (indp == coreKeyboard)
+ break;
+ for (; indp->identifier; indp++)
+ indp[0] = indp[1];
+ count--;
+ }
+ coreKeyboard = NULL;
+ foundKeyboard = TRUE;
+ }
+
+ /* 2. ServerLayout-specified core keyboard. */
+ if (coreKeyboard) {
+ foundKeyboard = TRUE;
+ from = X_CONFIG;
+ }
+
+ /* 3. First core keyboard device. */
+ if (!foundKeyboard) {
+ XF86ConfInputPtr p;
+
+ for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
+ if (p->inp_option_lst &&
+ xf86CheckBoolOption(p->inp_option_lst, "CoreKeyboard", FALSE)) {
+ confInput = p;
+ foundKeyboard = TRUE;
+ from = X_DEFAULT;
+ keyboardMsg = "first core keyboard device";
+ break;
+ }
+ }
+ }
+
+ /* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */
+ if (!foundKeyboard) {
+ confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD,
+ xf86configptr->conf_input_lst);
+ if (!confInput) {
+ confInput = xf86findInputByDriver("kbd",
+ xf86configptr->conf_input_lst);
+ }
+ if (!confInput) {
+ confInput = xf86findInputByDriver("keyboard",
+ xf86configptr->conf_input_lst);
+ }
+ if (confInput) {
+ foundKeyboard = TRUE;
+ from = X_DEFAULT;
+ keyboardMsg = "first keyboard device";
+ }
+ }
+
+ /* 5. Built-in default. */
+ if (!foundKeyboard) {
+ bzero(&defKbd, sizeof(defKbd));
+ defKbd.inp_identifier = "<default keyboard>";
+ defKbd.inp_driver = "kbd";
+ confInput = &defKbd;
+ foundKeyboard = TRUE;
+ keyboardMsg = "default keyboard configuration";
+ from = X_DEFAULT;
+ }
+
+ /* Add the core keyboard device to the layout, and set it to Core. */
+ if (foundKeyboard && confInput) {
+ foundKeyboard = configInput(&Keyboard, confInput, from);
+ if (foundKeyboard) {
+ count++;
+ indp = xnfrealloc(servlayoutp->inputs,
+ (count + 1) * sizeof(IDevRec));
+ indp[count - 1] = Keyboard;
+ indp[count - 1].extraOptions =
+ xf86addNewOption(NULL, "CoreKeyboard", NULL);
+ indp[count].identifier = NULL;
+ servlayoutp->inputs = indp;
+ }
+ }
+
+ if (!foundKeyboard) {
+ /* This shouldn't happen. */
+ xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
+ return FALSE;
+ }
+
+ if (pointerMsg) {
+ xf86Msg(X_WARNING, "The core pointer device wasn't specified "
+ "explicitly in the layout.\n"
+ "\tUsing the %s.\n", pointerMsg);
+ }
+
+ if (keyboardMsg) {
+ xf86Msg(X_WARNING, "The core keyboard device wasn't specified "
+ "explicitly in the layout.\n"
+ "\tUsing the %s.\n", keyboardMsg);
+ }
+
+ return TRUE;
+}
+
+typedef enum {
+ LAYOUT_ISOLATEDEVICE,
+ LAYOUT_SINGLECARD
+} LayoutValues;
+
+static OptionInfoRec LayoutOptions[] = {
+ { LAYOUT_ISOLATEDEVICE, "IsolateDevice", OPTV_STRING,
+ {0}, FALSE },
+ { LAYOUT_SINGLECARD, "SingleCard", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { -1, NULL, OPTV_NONE,
+ {0}, FALSE },
+};
+
+/*
+ * figure out which layout is active, which screens are used in that layout,
+ * which drivers and monitors are used in these screens
+ */
+static Bool
+configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
+ char *default_layout)
+{
+ XF86ConfAdjacencyPtr adjp;
+ XF86ConfInactivePtr idp;
+ XF86ConfInputrefPtr irp;
+ int count = 0;
+ int scrnum;
+ XF86ConfLayoutPtr l;
+ MessageType from;
+ screenLayoutPtr slp;
+ GDevPtr gdp;
+ IDevPtr indp;
+ int i = 0, j;
+
+ if (!servlayoutp)
+ return FALSE;
+
+ /*
+ * which layout section is the active one?
+ *
+ * If there is a -layout command line option, use that one, otherwise
+ * pick the first one.
+ */
+ from = X_DEFAULT;
+ if (xf86LayoutName != NULL)
+ from = X_CMDLINE;
+ else if (default_layout) {
+ xf86LayoutName = default_layout;
+ from = X_CONFIG;
+ }
+ if (xf86LayoutName != NULL) {
+ if ((l = xf86findLayout(xf86LayoutName, conf_layout)) == NULL) {
+ xf86Msg(X_ERROR, "No ServerLayout section called \"%s\"\n",
+ xf86LayoutName);
+ return FALSE;
+ }
+ conf_layout = l;
+ }
+ xf86Msg(from, "ServerLayout \"%s\"\n", conf_layout->lay_identifier);
+ adjp = conf_layout->lay_adjacency_lst;
+
+ /*
+ * we know that each screen is referenced exactly once on the left side
+ * of a layout statement in the Layout section. So to allocate the right
+ * size for the array we do a quick walk of the list to figure out how
+ * many sections we have
+ */
+ while (adjp) {
+ count++;
+ adjp = (XF86ConfAdjacencyPtr)adjp->list.next;
+ }
+#ifdef DEBUG
+ ErrorF("Found %d screens in the layout section %s",
+ count, conf_layout->lay_identifier);
+#endif
+ slp = xnfcalloc(1, (count + 1) * sizeof(screenLayoutRec));
+ slp[count].screen = NULL;
+ /*
+ * now that we have storage, loop over the list again and fill in our
+ * data structure; at this point we do not fill in the adjacency
+ * information as it is not clear if we need it at all
+ */
+ adjp = conf_layout->lay_adjacency_lst;
+ count = 0;
+ while (adjp) {
+ slp[count].screen = xnfcalloc(1, sizeof(confScreenRec));
+ if (adjp->adj_scrnum < 0)
+ scrnum = count;
+ else
+ scrnum = adjp->adj_scrnum;
+ if (!configScreen(slp[count].screen, adjp->adj_screen, scrnum,
+ X_CONFIG))
+ return FALSE;
+ slp[count].x = adjp->adj_x;
+ slp[count].y = adjp->adj_y;
+ slp[count].refname = adjp->adj_refscreen;
+ switch (adjp->adj_where) {
+ case CONF_ADJ_OBSOLETE:
+ slp[count].where = PosObsolete;
+ slp[count].topname = adjp->adj_top_str;
+ slp[count].bottomname = adjp->adj_bottom_str;
+ slp[count].leftname = adjp->adj_left_str;
+ slp[count].rightname = adjp->adj_right_str;
+ break;
+ case CONF_ADJ_ABSOLUTE:
+ slp[count].where = PosAbsolute;
+ break;
+ case CONF_ADJ_RIGHTOF:
+ slp[count].where = PosRightOf;
+ break;
+ case CONF_ADJ_LEFTOF:
+ slp[count].where = PosLeftOf;
+ break;
+ case CONF_ADJ_ABOVE:
+ slp[count].where = PosAbove;
+ break;
+ case CONF_ADJ_BELOW:
+ slp[count].where = PosBelow;
+ break;
+ case CONF_ADJ_RELATIVE:
+ slp[count].where = PosRelative;
+ break;
+ }
+ count++;
+ adjp = (XF86ConfAdjacencyPtr)adjp->list.next;
+ }
+
+ /* XXX Need to tie down the upper left screen. */
+
+ /* Fill in the refscreen and top/bottom/left/right values */
+ for (i = 0; i < count; i++) {
+ for (j = 0; j < count; j++) {
+ if (slp[i].refname &&
+ strcmp(slp[i].refname, slp[j].screen->id) == 0) {
+ slp[i].refscreen = slp[j].screen;
+ }
+ if (slp[i].topname &&
+ strcmp(slp[i].topname, slp[j].screen->id) == 0) {
+ slp[i].top = slp[j].screen;
+ }
+ if (slp[i].bottomname &&
+ strcmp(slp[i].bottomname, slp[j].screen->id) == 0) {
+ slp[i].bottom = slp[j].screen;
+ }
+ if (slp[i].leftname &&
+ strcmp(slp[i].leftname, slp[j].screen->id) == 0) {
+ slp[i].left = slp[j].screen;
+ }
+ if (slp[i].rightname &&
+ strcmp(slp[i].rightname, slp[j].screen->id) == 0) {
+ slp[i].right = slp[j].screen;
+ }
+ }
+ if (slp[i].where != PosObsolete
+ && slp[i].where != PosAbsolute
+ && !slp[i].refscreen) {
+ xf86Msg(X_ERROR,"Screen %s doesn't exist: deleting placement\n",
+ slp[i].refname);
+ slp[i].where = PosAbsolute;
+ slp[i].x = 0;
+ slp[i].y = 0;
+ }
+ }
+
+#ifdef LAYOUT_DEBUG
+ ErrorF("Layout \"%s\"\n", conf_layout->lay_identifier);
+ for (i = 0; i < count; i++) {
+ ErrorF("Screen: \"%s\" (%d):\n", slp[i].screen->id,
+ slp[i].screen->screennum);
+ switch (slp[i].where) {
+ case PosObsolete:
+ ErrorF("\tObsolete format: \"%s\" \"%s\" \"%s\" \"%s\"\n",
+ slp[i].top, slp[i].bottom, slp[i].left, slp[i].right);
+ break;
+ case PosAbsolute:
+ if (slp[i].x == -1)
+ if (slp[i].screen->screennum == 0)
+ ErrorF("\tImplicitly left-most\n");
+ else
+ ErrorF("\tImplicitly right of screen %d\n",
+ slp[i].screen->screennum - 1);
+ else
+ ErrorF("\t%d %d\n", slp[i].x, slp[i].y);
+ break;
+ case PosRightOf:
+ ErrorF("\tRight of \"%s\"\n", slp[i].refscreen->id);
+ break;
+ case PosLeftOf:
+ ErrorF("\tLeft of \"%s\"\n", slp[i].refscreen->id);
+ break;
+ case PosAbove:
+ ErrorF("\tAbove \"%s\"\n", slp[i].refscreen->id);
+ break;
+ case PosBelow:
+ ErrorF("\tBelow \"%s\"\n", slp[i].refscreen->id);
+ break;
+ case PosRelative:
+ ErrorF("\t%d %d relative to \"%s\"\n", slp[i].x, slp[i].y,
+ slp[i].refscreen->id);
+ break;
+ }
+ }
+#endif
+ /*
+ * Count the number of inactive devices.
+ */
+ count = 0;
+ idp = conf_layout->lay_inactive_lst;
+ while (idp) {
+ count++;
+ idp = (XF86ConfInactivePtr)idp->list.next;
+ }
+#ifdef DEBUG
+ ErrorF("Found %d inactive devices in the layout section %s",
+ count, conf_layout->lay_identifier);
+#endif
+ gdp = xnfalloc((count + 1) * sizeof(GDevRec));
+ gdp[count].identifier = NULL;
+ idp = conf_layout->lay_inactive_lst;
+ count = 0;
+ while (idp) {
+ if (!configDevice(&gdp[count], idp->inactive_device, FALSE))
+ return FALSE;
+ count++;
+ idp = (XF86ConfInactivePtr)idp->list.next;
+ }
+ /*
+ * Count the number of input devices.
+ */
+ count = 0;
+ irp = conf_layout->lay_input_lst;
+ while (irp) {
+ count++;
+ irp = (XF86ConfInputrefPtr)irp->list.next;
+ }
+#ifdef DEBUG
+ ErrorF("Found %d input devices in the layout section %s",
+ count, conf_layout->lay_identifier);
+#endif
+ indp = xnfalloc((count + 1) * sizeof(IDevRec));
+ indp[count].identifier = NULL;
+ irp = conf_layout->lay_input_lst;
+ count = 0;
+ while (irp) {
+ if (!configInput(&indp[count], irp->iref_inputdev, X_CONFIG))
+ return FALSE;
+ indp[count].extraOptions = irp->iref_option_lst;
+ count++;
+ irp = (XF86ConfInputrefPtr)irp->list.next;
+ }
+ servlayoutp->id = conf_layout->lay_identifier;
+ servlayoutp->screens = slp;
+ servlayoutp->inactives = gdp;
+ servlayoutp->inputs = indp;
+ servlayoutp->options = conf_layout->lay_option_lst;
+ from = X_DEFAULT;
+
+ if (!checkCoreInputDevices(servlayoutp, FALSE))
+ return FALSE;
+ return TRUE;
+}
+
+/*
+ * No layout section, so find the first Screen section and set that up as
+ * the only active screen.
+ */
+static Bool
+configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen)
+{
+ MessageType from;
+ XF86ConfScreenPtr s;
+ screenLayoutPtr slp;
+ IDevPtr indp;
+
+ if (!servlayoutp)
+ return FALSE;
+
+ if (conf_screen == NULL) {
+ xf86ConfigError("No Screen sections present\n");
+ return FALSE;
+ }
+
+ /*
+ * which screen section is the active one?
+ *
+ * If there is a -screen option, use that one, otherwise use the first
+ * one.
+ */
+
+ from = X_CONFIG;
+ if (xf86ScreenName != NULL) {
+ if ((s = xf86findScreen(xf86ScreenName, conf_screen)) == NULL) {
+ xf86Msg(X_ERROR, "No Screen section called \"%s\"\n",
+ xf86ScreenName);
+ return FALSE;
+ }
+ conf_screen = s;
+ from = X_CMDLINE;
+ }
+
+ /* We have exactly one screen */
+
+ slp = xnfcalloc(1, 2 * sizeof(screenLayoutRec));
+ slp[0].screen = xnfcalloc(1, sizeof(confScreenRec));
+ slp[1].screen = NULL;
+ if (!configScreen(slp[0].screen, conf_screen, 0, from))
+ return FALSE;
+ servlayoutp->id = "(implicit)";
+ servlayoutp->screens = slp;
+ servlayoutp->inactives = xnfcalloc(1, sizeof(GDevRec));
+ servlayoutp->options = NULL;
+ /* Set up an empty input device list, then look for some core devices. */
+ indp = xnfalloc(sizeof(IDevRec));
+ indp->identifier = NULL;
+ servlayoutp->inputs = indp;
+ if (!checkCoreInputDevices(servlayoutp, TRUE))
+ return FALSE;
+
+ return TRUE;
+}
+
+static Bool
+configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor)
+{
+ int count = 0;
+ XF86ConfVideoPortPtr conf_port;
+
+ xf86Msg(X_CONFIG, "| |-->VideoAdaptor \"%s\"\n",
+ conf_adaptor->va_identifier);
+ adaptor->identifier = conf_adaptor->va_identifier;
+ adaptor->options = conf_adaptor->va_option_lst;
+ if (conf_adaptor->va_busid || conf_adaptor->va_driver) {
+ xf86Msg(X_CONFIG, "| | Unsupported device type, skipping entry\n");
+ return FALSE;
+ }
+
+ /*
+ * figure out how many videoport subsections there are and fill them in
+ */
+ conf_port = conf_adaptor->va_port_lst;
+ while(conf_port) {
+ count++;
+ conf_port = (XF86ConfVideoPortPtr)conf_port->list.next;
+ }
+ adaptor->ports = xnfalloc((count) * sizeof(confXvPortRec));
+ adaptor->numports = count;
+ count = 0;
+ conf_port = conf_adaptor->va_port_lst;
+ while(conf_port) {
+ adaptor->ports[count].identifier = conf_port->vp_identifier;
+ adaptor->ports[count].options = conf_port->vp_option_lst;
+ count++;
+ conf_port = (XF86ConfVideoPortPtr)conf_port->list.next;
+ }
+
+ return TRUE;
+}
+
+static Bool
+configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
+ MessageType from)
+{
+ int count = 0;
+ XF86ConfDisplayPtr dispptr;
+ XF86ConfAdaptorLinkPtr conf_adaptor;
+ Bool defaultMonitor = FALSE;
+
+ xf86Msg(from, "|-->Screen \"%s\" (%d)\n", conf_screen->scrn_identifier,
+ scrnum);
+ /*
+ * now we fill in the elements of the screen
+ */
+ screenp->id = conf_screen->scrn_identifier;
+ screenp->screennum = scrnum;
+ screenp->defaultdepth = conf_screen->scrn_defaultdepth;
+ screenp->defaultbpp = conf_screen->scrn_defaultbpp;
+ screenp->defaultfbbpp = conf_screen->scrn_defaultfbbpp;
+ screenp->monitor = xnfcalloc(1, sizeof(MonRec));
+ /* If no monitor is specified, create a default one. */
+ if (!conf_screen->scrn_monitor) {
+ XF86ConfMonitorRec defMon;
+
+ bzero(&defMon, sizeof(defMon));
+ defMon.mon_identifier = "<default monitor>";
+ /*
+ * TARGET_REFRESH_RATE may be defined to effectively limit the
+ * default resolution to the largest that has a "good" refresh
+ * rate.
+ */
+#ifdef TARGET_REFRESH_RATE
+ defMon.mon_option_lst = xf86ReplaceRealOption(defMon.mon_option_lst,
+ "TargetRefresh",
+ TARGET_REFRESH_RATE);
+#endif
+ if (!configMonitor(screenp->monitor, &defMon))
+ return FALSE;
+ defaultMonitor = TRUE;
+ } else {
+ if (!configMonitor(screenp->monitor,conf_screen->scrn_monitor))
+ return FALSE;
+ }
+ screenp->device = xnfcalloc(1, sizeof(GDevRec));
+ configDevice(screenp->device,conf_screen->scrn_device, TRUE);
+ screenp->device->myScreenSection = screenp;
+ screenp->options = conf_screen->scrn_option_lst;
+
+ /*
+ * figure out how many display subsections there are and fill them in
+ */
+ dispptr = conf_screen->scrn_display_lst;
+ while(dispptr) {
+ count++;
+ dispptr = (XF86ConfDisplayPtr)dispptr->list.next;
+ }
+ screenp->displays = xnfalloc((count) * sizeof(DispRec));
+ screenp->numdisplays = count;
+ count = 0;
+ dispptr = conf_screen->scrn_display_lst;
+ while(dispptr) {
+ configDisplay(&(screenp->displays[count]),dispptr);
+ count++;
+ dispptr = (XF86ConfDisplayPtr)dispptr->list.next;
+ }
+
+ /*
+ * figure out how many videoadaptor references there are and fill them in
+ */
+ conf_adaptor = conf_screen->scrn_adaptor_lst;
+ while(conf_adaptor) {
+ count++;
+ conf_adaptor = (XF86ConfAdaptorLinkPtr)conf_adaptor->list.next;
+ }
+ screenp->xvadaptors = xnfalloc((count) * sizeof(confXvAdaptorRec));
+ screenp->numxvadaptors = 0;
+ conf_adaptor = conf_screen->scrn_adaptor_lst;
+ while(conf_adaptor) {
+ if (configXvAdaptor(&(screenp->xvadaptors[screenp->numxvadaptors]),
+ conf_adaptor->al_adaptor))
+ screenp->numxvadaptors++;
+ conf_adaptor = (XF86ConfAdaptorLinkPtr)conf_adaptor->list.next;
+ }
+
+ if (defaultMonitor) {
+ xf86Msg(X_WARNING, "No monitor specified for screen \"%s\".\n"
+ "\tUsing a default monitor configuration.\n", screenp->id);
+ }
+ return TRUE;
+}
+
+static Bool
+configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
+{
+ int count;
+ DisplayModePtr mode,last = NULL;
+ XF86ConfModeLinePtr cmodep;
+ XF86ConfModesPtr modes;
+ XF86ConfModesLinkPtr modeslnk = conf_monitor->mon_modes_sect_lst;
+ Gamma zeros = {0.0, 0.0, 0.0};
+ float badgamma = 0.0;
+
+ xf86Msg(X_CONFIG, "| |-->Monitor \"%s\"\n",
+ conf_monitor->mon_identifier);
+ monitorp->id = conf_monitor->mon_identifier;
+ monitorp->vendor = conf_monitor->mon_vendor;
+ monitorp->model = conf_monitor->mon_modelname;
+ monitorp->Modes = NULL;
+ monitorp->Last = NULL;
+ monitorp->gamma = zeros;
+ monitorp->widthmm = conf_monitor->mon_width;
+ monitorp->heightmm = conf_monitor->mon_height;
+ monitorp->options = conf_monitor->mon_option_lst;
+
+ /*
+ * fill in the monitor structure
+ */
+ for( count = 0 ;
+ count < conf_monitor->mon_n_hsync && count < MAX_HSYNC;
+ count++) {
+ monitorp->hsync[count].hi = conf_monitor->mon_hsync[count].hi;
+ monitorp->hsync[count].lo = conf_monitor->mon_hsync[count].lo;
+ }
+ monitorp->nHsync = count;
+ for( count = 0 ;
+ count < conf_monitor->mon_n_vrefresh && count < MAX_VREFRESH;
+ count++) {
+ monitorp->vrefresh[count].hi = conf_monitor->mon_vrefresh[count].hi;
+ monitorp->vrefresh[count].lo = conf_monitor->mon_vrefresh[count].lo;
+ }
+ monitorp->nVrefresh = count;
+
+ /*
+ * first we collect the mode lines from the UseModes directive
+ */
+ while(modeslnk)
+ {
+ modes = xf86findModes (modeslnk->ml_modes_str,
+ xf86configptr->conf_modes_lst);
+ modeslnk->ml_modes = modes;
+
+
+ /* now add the modes found in the modes
+ section to the list of modes for this
+ monitor unless it has been added before
+ because we are reusing the same section
+ for another screen */
+ if (xf86itemNotSublist(
+ (GenericListPtr)conf_monitor->mon_modeline_lst,
+ (GenericListPtr)modes->mon_modeline_lst)) {
+ conf_monitor->mon_modeline_lst = (XF86ConfModeLinePtr)
+ xf86addListItem(
+ (GenericListPtr)conf_monitor->mon_modeline_lst,
+ (GenericListPtr)modes->mon_modeline_lst);
+ }
+ modeslnk = modeslnk->list.next;
+ }
+
+ /*
+ * we need to hook in the mode lines now
+ * here both data structures use lists, only our internal one
+ * is double linked
+ */
+ cmodep = conf_monitor->mon_modeline_lst;
+ while( cmodep ) {
+ mode = xnfalloc(sizeof(DisplayModeRec));
+ memset(mode,'\0',sizeof(DisplayModeRec));
+ mode->type = 0;
+ mode->Clock = cmodep->ml_clock;
+ mode->HDisplay = cmodep->ml_hdisplay;
+ mode->HSyncStart = cmodep->ml_hsyncstart;
+ mode->HSyncEnd = cmodep->ml_hsyncend;
+ mode->HTotal = cmodep->ml_htotal;
+ mode->VDisplay = cmodep->ml_vdisplay;
+ mode->VSyncStart = cmodep->ml_vsyncstart;
+ mode->VSyncEnd = cmodep->ml_vsyncend;
+ mode->VTotal = cmodep->ml_vtotal;
+ mode->Flags = cmodep->ml_flags;
+ mode->HSkew = cmodep->ml_hskew;
+ mode->VScan = cmodep->ml_vscan;
+ mode->name = xnfstrdup(cmodep->ml_identifier);
+ if( last ) {
+ mode->prev = last;
+ last->next = mode;
+ }
+ else {
+ /*
+ * this is the first mode
+ */
+ monitorp->Modes = mode;
+ mode->prev = NULL;
+ }
+ last = mode;
+ cmodep = (XF86ConfModeLinePtr)cmodep->list.next;
+ }
+ if(last){
+ last->next = NULL;
+ }
+ monitorp->Last = last;
+
+ /* add the (VESA) default modes */
+ if (! addDefaultModes(monitorp) )
+ return FALSE;
+
+ if (conf_monitor->mon_gamma_red > GAMMA_ZERO)
+ monitorp->gamma.red = conf_monitor->mon_gamma_red;
+ if (conf_monitor->mon_gamma_green > GAMMA_ZERO)
+ monitorp->gamma.green = conf_monitor->mon_gamma_green;
+ if (conf_monitor->mon_gamma_blue > GAMMA_ZERO)
+ monitorp->gamma.blue = conf_monitor->mon_gamma_blue;
+
+ /* Check that the gamma values are within range */
+ if (monitorp->gamma.red > GAMMA_ZERO &&
+ (monitorp->gamma.red < GAMMA_MIN ||
+ monitorp->gamma.red > GAMMA_MAX)) {
+ badgamma = monitorp->gamma.red;
+ } else if (monitorp->gamma.green > GAMMA_ZERO &&
+ (monitorp->gamma.green < GAMMA_MIN ||
+ monitorp->gamma.green > GAMMA_MAX)) {
+ badgamma = monitorp->gamma.green;
+ } else if (monitorp->gamma.blue > GAMMA_ZERO &&
+ (monitorp->gamma.blue < GAMMA_MIN ||
+ monitorp->gamma.blue > GAMMA_MAX)) {
+ badgamma = monitorp->gamma.blue;
+ }
+ if (badgamma > GAMMA_ZERO) {
+ xf86ConfigError("Gamma value %.f is out of range (%.2f - %.1f)\n",
+ badgamma, GAMMA_MIN, GAMMA_MAX);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static int
+lookupVisual(const char *visname)
+{
+ int i;
+
+ if (!visname || !*visname)
+ return -1;
+
+ for (i = 0; i <= DirectColor; i++) {
+ if (!xf86nameCompare(visname, xf86VisualNames[i]))
+ break;
+ }
+
+ if (i <= DirectColor)
+ return i;
+
+ return -1;
+}
+
+
+static Bool
+configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display)
+{
+ int count = 0;
+ XF86ModePtr modep;
+
+ displayp->frameX0 = conf_display->disp_frameX0;
+ displayp->frameY0 = conf_display->disp_frameY0;
+ displayp->virtualX = conf_display->disp_virtualX;
+ displayp->virtualY = conf_display->disp_virtualY;
+ displayp->depth = conf_display->disp_depth;
+ displayp->fbbpp = conf_display->disp_bpp;
+ displayp->weight.red = conf_display->disp_weight.red;
+ displayp->weight.green = conf_display->disp_weight.green;
+ displayp->weight.blue = conf_display->disp_weight.blue;
+ displayp->blackColour.red = conf_display->disp_black.red;
+ displayp->blackColour.green = conf_display->disp_black.green;
+ displayp->blackColour.blue = conf_display->disp_black.blue;
+ displayp->whiteColour.red = conf_display->disp_white.red;
+ displayp->whiteColour.green = conf_display->disp_white.green;
+ displayp->whiteColour.blue = conf_display->disp_white.blue;
+ displayp->options = conf_display->disp_option_lst;
+ if (conf_display->disp_visual) {
+ displayp->defaultVisual = lookupVisual(conf_display->disp_visual);
+ if (displayp->defaultVisual == -1) {
+ xf86ConfigError("Invalid visual name: \"%s\"",
+ conf_display->disp_visual);
+ return FALSE;
+ }
+ } else {
+ displayp->defaultVisual = -1;
+ }
+
+ /*
+ * now hook in the modes
+ */
+ modep = conf_display->disp_mode_lst;
+ while(modep) {
+ count++;
+ modep = (XF86ModePtr)modep->list.next;
+ }
+ displayp->modes = xnfalloc((count+1) * sizeof(char*));
+ modep = conf_display->disp_mode_lst;
+ count = 0;
+ while(modep) {
+ displayp->modes[count] = modep->mode_name;
+ count++;
+ modep = (XF86ModePtr)modep->list.next;
+ }
+ displayp->modes[count] = NULL;
+
+ return TRUE;
+}
+
+static Bool
+configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
+{
+ int i;
+
+ if (active)
+ xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n",
+ conf_device->dev_identifier);
+ else
+ xf86Msg(X_CONFIG, "|-->Inactive Device \"%s\"\n",
+ conf_device->dev_identifier);
+
+ devicep->identifier = conf_device->dev_identifier;
+ devicep->vendor = conf_device->dev_vendor;
+ devicep->board = conf_device->dev_board;
+ devicep->chipset = conf_device->dev_chipset;
+ devicep->ramdac = conf_device->dev_ramdac;
+ devicep->driver = conf_device->dev_driver;
+ devicep->active = active;
+ devicep->videoRam = conf_device->dev_videoram;
+ devicep->BiosBase = conf_device->dev_bios_base;
+ devicep->MemBase = conf_device->dev_mem_base;
+ devicep->IOBase = conf_device->dev_io_base;
+ devicep->clockchip = conf_device->dev_clockchip;
+ devicep->busID = conf_device->dev_busid;
+ devicep->textClockFreq = conf_device->dev_textclockfreq;
+ devicep->chipID = conf_device->dev_chipid;
+ devicep->chipRev = conf_device->dev_chiprev;
+ devicep->options = conf_device->dev_option_lst;
+ devicep->irq = conf_device->dev_irq;
+ devicep->screen = conf_device->dev_screen;
+
+ for (i = 0; i < MAXDACSPEEDS; i++) {
+ if (i < CONF_MAXDACSPEEDS)
+ devicep->dacSpeeds[i] = conf_device->dev_dacSpeeds[i];
+ else
+ devicep->dacSpeeds[i] = 0;
+ }
+ devicep->numclocks = conf_device->dev_clocks;
+ if (devicep->numclocks > MAXCLOCKS)
+ devicep->numclocks = MAXCLOCKS;
+ for (i = 0; i < devicep->numclocks; i++) {
+ devicep->clock[i] = conf_device->dev_clock[i];
+ }
+ devicep->claimed = FALSE;
+
+ return TRUE;
+}
+
+#ifdef XF86DRI
+static Bool
+configDRI(XF86ConfDRIPtr drip)
+{
+ int count = 0;
+ XF86ConfBuffersPtr bufs;
+ int i;
+ struct group *grp;
+
+ xf86ConfigDRI.group = -1;
+ xf86ConfigDRI.mode = 0;
+ xf86ConfigDRI.bufs_count = 0;
+ xf86ConfigDRI.bufs = NULL;
+
+ if (drip) {
+ if (drip->dri_group_name) {
+ if ((grp = getgrnam(drip->dri_group_name)))
+ xf86ConfigDRI.group = grp->gr_gid;
+ } else {
+ if (drip->dri_group >= 0)
+ xf86ConfigDRI.group = drip->dri_group;
+ }
+ xf86ConfigDRI.mode = drip->dri_mode;
+ for (bufs = drip->dri_buffers_lst; bufs; bufs = bufs->list.next)
+ ++count;
+
+ xf86ConfigDRI.bufs_count = count;
+ xf86ConfigDRI.bufs = xnfalloc(count * sizeof(*xf86ConfigDRI.bufs));
+
+ for (i = 0, bufs = drip->dri_buffers_lst;
+ i < count;
+ i++, bufs = bufs->list.next) {
+
+ xf86ConfigDRI.bufs[i].count = bufs->buf_count;
+ xf86ConfigDRI.bufs[i].size = bufs->buf_size;
+ /* FIXME: Flags not implemented. These
+ could be used, for example, to specify a
+ contiguous block and/or write-combining
+ cache policy. */
+ xf86ConfigDRI.bufs[i].flags = 0;
+ }
+ }
+
+ return TRUE;
+}
+#endif
+
+static Bool
+configExtensions(XF86ConfExtensionsPtr conf_ext)
+{
+ XF86OptionPtr o;
+
+ /* Extension enable/disable in miinitext.c */
+ extern Bool EnableDisableExtension(char *name, Bool enable);
+
+ if (conf_ext && conf_ext->ext_option_lst) {
+ for (o = conf_ext->ext_option_lst; o; o = xf86NextOption(o)) {
+ char *name = xf86OptionName(o);
+ char *val = xf86OptionValue(o);
+ char *n;
+ Bool enable = TRUE;
+
+ /* Handle "No<ExtensionName>" */
+ n = xf86NormalizeName(name);
+ if (strncmp(n, "no", 2) == 0) {
+ name += 2;
+ enable = FALSE;
+ }
+
+ if (!val ||
+ xf86NameCmp(val, "enable") == 0 ||
+ xf86NameCmp(val, "enabled") == 0 ||
+ xf86NameCmp(val, "on") == 0 ||
+ xf86NameCmp(val, "1") == 0 ||
+ xf86NameCmp(val, "yes") == 0 ||
+ xf86NameCmp(val, "true") == 0) {
+ /* NOTHING NEEDED -- enabling is handled below */
+ } else if (xf86NameCmp(val, "disable") == 0 ||
+ xf86NameCmp(val, "disabled") == 0 ||
+ xf86NameCmp(val, "off") == 0 ||
+ xf86NameCmp(val, "0") == 0 ||
+ xf86NameCmp(val, "no") == 0 ||
+ xf86NameCmp(val, "false") == 0) {
+ enable = !enable;
+ } else {
+ xf86Msg(X_ERROR,
+ "%s is not a valid value for the Extension option\n",
+ val);
+ return FALSE;
+ }
+
+ if (EnableDisableExtension(name, enable)) {
+ xf86Msg(X_CONFIG, "Extension \"%s\" is %s\n",
+ name, enable ? "enabled" : "disabled");
+ } else {
+ xf86Msg(X_WARNING, "Ignoring unrecognized extension \"%s\"\n",
+ name);
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+static Bool
+configInput(IDevPtr inputp, XF86ConfInputPtr conf_input, MessageType from)
+{
+ xf86Msg(from, "|-->Input Device \"%s\"\n", conf_input->inp_identifier);
+ inputp->identifier = conf_input->inp_identifier;
+ inputp->driver = conf_input->inp_driver;
+ inputp->commonOptions = conf_input->inp_option_lst;
+ inputp->extraOptions = NULL;
+
+ /* XXX This is required until the keyboard driver is converted */
+ if (!xf86NameCmp(inputp->driver, "keyboard"))
+ return configInputKbd(inputp);
+
+ return TRUE;
+}
+
+static Bool
+modeIsPresent(char * modename,MonPtr monitorp)
+{
+ DisplayModePtr knownmodes = monitorp->Modes;
+
+ /* all I can think of is a linear search... */
+ while(knownmodes != NULL)
+ {
+ if(!strcmp(modename,knownmodes->name) &&
+ !(knownmodes->type & M_T_DEFAULT))
+ return TRUE;
+ knownmodes = knownmodes->next;
+ }
+ return FALSE;
+}
+
+static Bool
+addDefaultModes(MonPtr monitorp)
+{
+ DisplayModePtr mode;
+ DisplayModePtr last = monitorp->Last;
+ int i = 0;
+
+ while (xf86DefaultModes[i].name != NULL)
+ {
+ if ( ! modeIsPresent(xf86DefaultModes[i].name,monitorp) )
+ do
+ {
+ mode = xnfalloc(sizeof(DisplayModeRec));
+ memcpy(mode,&xf86DefaultModes[i],sizeof(DisplayModeRec));
+ if (xf86DefaultModes[i].name)
+ mode->name = xnfstrdup(xf86DefaultModes[i].name);
+ if( last ) {
+ mode->prev = last;
+ last->next = mode;
+ }
+ else {
+ /* this is the first mode */
+ monitorp->Modes = mode;
+ mode->prev = NULL;
+ }
+ last = mode;
+ i++;
+ }
+ while((xf86DefaultModes[i].name != NULL) &&
+ (!strcmp(xf86DefaultModes[i].name,xf86DefaultModes[i-1].name)));
+ else
+ i++;
+ }
+ monitorp->Last = last;
+
+ return TRUE;
+}
+
+/*
+ * load the config file and fill the global data structure
+ */
+ConfigStatus
+xf86HandleConfigFile(Bool autoconfig)
+{
+ const char *filename;
+ char *searchpath;
+ MessageType from = X_DEFAULT;
+ char *scanptr;
+ Bool singlecard = 0;
+
+ if (!autoconfig) {
+ if (getuid() == 0)
+ searchpath = ROOT_CONFIGPATH;
+ else
+ searchpath = USER_CONFIGPATH;
+
+ if (xf86ConfigFile)
+ from = X_CMDLINE;
+
+ filename = xf86openConfigFile(searchpath, xf86ConfigFile, PROJECTROOT);
+ if (filename) {
+ xf86MsgVerb(from, 0, "Using config file: \"%s\"\n", filename);
+ xf86ConfigFile = xnfstrdup(filename);
+ } else {
+ xf86Msg(X_ERROR, "Unable to locate/open config file");
+ if (xf86ConfigFile)
+ xf86ErrorFVerb(0, ": \"%s\"", xf86ConfigFile);
+ xf86ErrorFVerb(0, "\n");
+ return CONFIG_NOFILE;
+ }
+ }
+
+ if ((xf86configptr = xf86readConfigFile ()) == NULL) {
+ xf86Msg(X_ERROR, "Problem parsing the config file\n");
+ return CONFIG_PARSE_ERROR;
+ }
+ xf86closeConfigFile ();
+
+ /* Initialise a few things. */
+
+ /*
+ * now we convert part of the information contained in the parser
+ * structures into our own structures.
+ * The important part here is to figure out which Screen Sections
+ * in the XF86Config file are active so that we can piece together
+ * the modes that we need later down the road.
+ * And while we are at it, we'll decode the rest of the stuff as well
+ */
+
+ /* First check if a layout section is present, and if it is valid. */
+
+ if (xf86configptr->conf_layout_lst == NULL || xf86ScreenName != NULL) {
+ if (xf86ScreenName == NULL) {
+ xf86Msg(X_WARNING,
+ "No Layout section. Using the first Screen section.\n");
+ }
+ if (!configImpliedLayout(&xf86ConfigLayout,
+ xf86configptr->conf_screen_lst)) {
+ xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
+ return CONFIG_PARSE_ERROR;
+ }
+ } else {
+ if (xf86configptr->conf_flags != NULL) {
+ char *dfltlayout = NULL;
+ pointer optlist = xf86configptr->conf_flags->flg_option_lst;
+
+ if (optlist && xf86FindOption(optlist, "defaultserverlayout"))
+ dfltlayout = xf86SetStrOption(optlist, "defaultserverlayout", NULL);
+ if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
+ dfltlayout)) {
+ xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
+ return CONFIG_PARSE_ERROR;
+ }
+ } else {
+ if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
+ NULL)) {
+ xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
+ return CONFIG_PARSE_ERROR;
+ }
+ }
+ }
+
+ xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions);
+
+ if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_ISOLATEDEVICE))) {
+ ; /* IsolateDevice specified; overrides SingleCard */
+ } else {
+ xf86GetOptValBool(LayoutOptions, LAYOUT_SINGLECARD, &singlecard);
+ if (singlecard)
+ scanptr = xf86ConfigLayout.screens->screen->device->busID;
+ }
+ if (scanptr) {
+ int bus, device, func, stroffset = 0;
+ if (strncmp(scanptr, "PCI:", 4) != 0) {
+ xf86Msg(X_WARNING, "Bus types other than PCI not yet isolable.\n"
+ "\tIgnoring IsolateDevice option.\n");
+ } else if (sscanf(scanptr, "PCI:%d:%d:%d", &bus, &device, &func) == 3) {
+ xf86IsolateDevice.bus = bus;
+ xf86IsolateDevice.device = device;
+ xf86IsolateDevice.func = func;
+ xf86Msg(X_INFO,
+ "Isolating PCI bus \"%d:%d:%d\"\n", bus, device, func);
+ }
+ }
+
+ /* Now process everything else */
+
+ if (!configFiles(xf86configptr->conf_files) ||
+ !configServerFlags(xf86configptr->conf_flags,
+ xf86ConfigLayout.options) ||
+ !configExtensions(xf86configptr->conf_extensions)
+#ifdef XF86DRI
+ || !configDRI(xf86configptr->conf_dri)
+#endif
+ ) {
+ ErrorF ("Problem when converting the config data structures\n");
+ return CONFIG_PARSE_ERROR;
+ }
+
+ /*
+ * Handle some command line options that can override some of the
+ * ServerFlags settings.
+ */
+#ifdef XF86VIDMODE
+ if (xf86VidModeDisabled)
+ xf86Info.vidModeEnabled = FALSE;
+ if (xf86VidModeAllowNonLocal)
+ xf86Info.vidModeAllowNonLocal = TRUE;
+#endif
+
+#ifdef XF86MISC
+ if (xf86MiscModInDevDisabled)
+ xf86Info.miscModInDevEnabled = FALSE;
+ if (xf86MiscModInDevAllowNonLocal)
+ xf86Info.miscModInDevAllowNonLocal = TRUE;
+#endif
+
+ if (xf86AllowMouseOpenFail)
+ xf86Info.allowMouseOpenFail = TRUE;
+
+ return CONFIG_OK;
+}
+
+
+/* These make the equivalent parser functions visible to the common layer. */
+Bool
+xf86PathIsAbsolute(const char *path)
+{
+ return (xf86pathIsAbsolute(path) != 0);
+}
+
+Bool
+xf86PathIsSafe(const char *path)
+{
+ return (xf86pathIsSafe(path) != 0);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Config.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Config.h
new file mode 100644
index 000000000..77b25ed32
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Config.h
@@ -0,0 +1,63 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.h,v 1.7 2003/10/08 14:58:27 dawes Exp $ */
+
+/*
+ * Copyright (c) 1997-2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _xf86_config_h
+#define _xf86_config_h
+
+#ifdef HAVE_PARSER_DECLS
+/*
+ * global structure that holds the result of parsing the config file
+ */
+extern XF86ConfigPtr xf86configptr;
+#endif
+
+typedef enum _ConfigStatus {
+ CONFIG_OK = 0,
+ CONFIG_PARSE_ERROR,
+ CONFIG_NOFILE
+} ConfigStatus;
+
+/*
+ * prototypes
+ */
+char ** xf86ModulelistFromConfig(pointer **);
+char ** xf86DriverlistFromConfig(void);
+char ** xf86DriverlistFromCompile(void);
+char ** xf86InputDriverlistFromConfig(void);
+char ** xf86InputDriverlistFromCompile(void);
+Bool xf86BuiltinInputDriver(const char *);
+ConfigStatus xf86HandleConfigFile(Bool);
+
+Bool xf86AutoConfig(void);
+
+#endif /* _xf86_config_h */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Configure.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Configure.c
new file mode 100644
index 000000000..208961f6a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Configure.c
@@ -0,0 +1,1049 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Configure.c,v 3.80 2003/10/08 14:58:27 dawes Exp $ */
+/*
+ * Copyright 2000-2002 by Alan Hourihane, Flint Mountain, North Wales.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Alan Hourihane, alanh@fairlite.demon.co.uk
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "os.h"
+#ifdef XFree86LOADER
+#include "loaderProcs.h"
+#endif
+#include "xf86.h"
+#include "xf86Config.h"
+#include "xf86_OSlib.h"
+#include "xf86Priv.h"
+#include "xf86PciData.h"
+#define IN_XSERVER
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+#include "vbe.h"
+#include "xf86DDC.h"
+#if defined(__sparc__) && !defined(__OpenBSD__)
+#include "xf86Bus.h"
+#include "xf86Sbus.h"
+#endif
+#include "globals.h"
+
+typedef struct _DevToConfig {
+ GDevRec GDev;
+ pciVideoPtr pVideo;
+#if defined(__sparc__) && !defined(__OpenBSD__)
+ sbusDevicePtr sVideo;
+#endif
+ int iDriver;
+} DevToConfigRec, *DevToConfigPtr;
+
+static DevToConfigPtr DevToConfig = NULL;
+static int nDevToConfig = 0, CurrentDriver;
+
+xf86MonPtr ConfiguredMonitor;
+Bool xf86DoConfigurePass1 = TRUE;
+Bool foundMouse = FALSE;
+
+#if defined(__UNIXOS2__)
+#define DFLT_MOUSE_DEV "mouse$"
+#define DFLT_MOUSE_PROTO "OS2Mouse"
+#elif defined(__SCO__)
+static char *DFLT_MOUSE_PROTO = "OSMouse";
+#elif defined(__UNIXWARE__)
+static char *DFLT_MOUSE_PROTO = "Xqueue";
+static char *DFLT_MOUSE_DEV = "/dev/mouse";
+#elif defined(QNX4)
+static char *DFLT_MOUSE_PROTO = "OSMouse";
+static char *DFLT_MOUSE_DEV = "/dev/mouse";
+#elif defined(__QNXNTO__)
+static char *DFLT_MOUSE_PROTO = "OSMouse";
+static char *DFLT_MOUSE_DEV = "/dev/devi/mouse0";
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+static char *DFLT_MOUSE_DEV = "/dev/sysmouse";
+static char *DFLT_MOUSE_PROTO = "auto";
+#else
+static char *DFLT_MOUSE_DEV = "/dev/mouse";
+static char *DFLT_MOUSE_PROTO = "auto";
+#endif
+
+/*
+ * This is called by the driver, either through xf86Match???Instances() or
+ * directly. We allocate a GDevRec and fill it in as much as we can, letting
+ * the caller fill in the rest and/or change it as it sees fit.
+ */
+GDevPtr
+xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset)
+{
+ int i, j;
+ pciVideoPtr pVideo = NULL;
+ Bool isPrimary = FALSE;
+
+ if (xf86DoProbe || !xf86DoConfigure || !xf86DoConfigurePass1)
+ return NULL;
+
+ /* Check for duplicates */
+ switch (bus) {
+ case BUS_PCI:
+ pVideo = (pciVideoPtr) busData;
+ for (i = 0; i < nDevToConfig; i++)
+ if (DevToConfig[i].pVideo &&
+ (DevToConfig[i].pVideo->bus == pVideo->bus) &&
+ (DevToConfig[i].pVideo->device == pVideo->device) &&
+ (DevToConfig[i].pVideo->func == pVideo->func))
+ return NULL;
+ isPrimary = xf86IsPrimaryPci(pVideo);
+ break;
+ case BUS_ISA:
+ /*
+ * This needs to be revisited as it doesn't allow for non-PCI
+ * multihead.
+ */
+ if (!xf86IsPrimaryIsa())
+ return NULL;
+ isPrimary = TRUE;
+ for (i = 0; i < nDevToConfig; i++)
+ if (!DevToConfig[i].pVideo)
+ return NULL;
+ break;
+#if defined(__sparc__) && !defined(__OpenBSD__)
+ case BUS_SBUS:
+ for (i = 0; i < nDevToConfig; i++)
+ if (DevToConfig[i].sVideo &&
+ DevToConfig[i].sVideo->fbNum == ((sbusDevicePtr) busData)->fbNum)
+ return NULL;
+ break;
+#endif
+ default:
+ return NULL;
+ }
+
+ /* Allocate new structure occurrence */
+ i = nDevToConfig++;
+ DevToConfig =
+ xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec));
+#if 1 /* Doesn't work when a driver detects more than one adapter */
+ if ((i > 0) && isPrimary) {
+ memmove(DevToConfig + 1,DevToConfig,
+ (nDevToConfig - 1) * sizeof(DevToConfigRec));
+ i = 0;
+ }
+#endif
+ memset(DevToConfig + i, 0, sizeof(DevToConfigRec));
+
+# define NewDevice DevToConfig[i]
+
+ NewDevice.GDev.chipID = NewDevice.GDev.chipRev = NewDevice.GDev.irq = -1;
+
+ NewDevice.iDriver = CurrentDriver;
+
+ /* Fill in what we know, converting the driver name to lower case */
+ NewDevice.GDev.driver = xnfalloc(strlen(driver) + 1);
+ for (j = 0; (NewDevice.GDev.driver[j] = tolower(driver[j])); j++);
+
+ switch (bus) {
+ case BUS_PCI: {
+ const char *VendorName;
+ const char *CardName;
+ char busnum[8];
+
+ NewDevice.pVideo = pVideo;
+ xf86FindPciNamesByDevice(pVideo->vendor, pVideo->chipType,
+ NOVENDOR, NOSUBSYS,
+ &VendorName, &CardName, NULL, NULL);
+
+ if (!VendorName) {
+ VendorName = xnfalloc(15);
+ sprintf((char*)VendorName, "Unknown Vendor");
+ }
+
+ if (!CardName) {
+ CardName = xnfalloc(14);
+ sprintf((char*)CardName, "Unknown Board");
+ }
+
+ NewDevice.GDev.identifier =
+ xnfalloc(strlen(VendorName) + strlen(CardName) + 2);
+ sprintf(NewDevice.GDev.identifier, "%s %s", VendorName, CardName);
+
+ NewDevice.GDev.vendor = (char *)VendorName;
+ NewDevice.GDev.board = (char *)CardName;
+
+ NewDevice.GDev.busID = xnfalloc(16);
+ xf86FormatPciBusNumber(pVideo->bus, busnum);
+ sprintf(NewDevice.GDev.busID, "PCI:%s:%d:%d",
+ busnum, pVideo->device, pVideo->func);
+
+ NewDevice.GDev.chipID = pVideo->chipType;
+ NewDevice.GDev.chipRev = pVideo->chipRev;
+
+ if (chipset < 0)
+ chipset = (pVideo->vendor << 16) | pVideo->chipType;
+ }
+ break;
+ case BUS_ISA:
+ NewDevice.GDev.identifier = "ISA Adapter";
+ NewDevice.GDev.busID = "ISA";
+ break;
+#if defined(__sparc__) && !defined(__OpenBSD__)
+ case BUS_SBUS: {
+ char *promPath = NULL;
+ NewDevice.sVideo = (sbusDevicePtr) busData;
+ NewDevice.GDev.identifier = NewDevice.sVideo->descr;
+ if (sparcPromInit() >= 0) {
+ promPath = sparcPromNode2Pathname(&NewDevice.sVideo->node);
+ sparcPromClose();
+ }
+ if (promPath) {
+ NewDevice.GDev.busID = xnfalloc(strlen(promPath) + 6);
+ sprintf(NewDevice.GDev.busID, "SBUS:%s", promPath);
+ xfree(promPath);
+ } else {
+ NewDevice.GDev.busID = xnfalloc(12);
+ sprintf(NewDevice.GDev.busID, "SBUS:fb%d", NewDevice.sVideo->fbNum);
+ }
+ }
+ break;
+#endif
+ default:
+ break;
+ }
+
+ /* Get driver's available options */
+ if (xf86DriverList[CurrentDriver]->AvailableOptions)
+ NewDevice.GDev.options = (OptionInfoPtr)
+ (*xf86DriverList[CurrentDriver]->AvailableOptions)(chipset,
+ bus);
+
+ return &NewDevice.GDev;
+
+# undef NewDevice
+}
+
+/*
+ * Backwards compatibility
+ */
+GDevPtr
+xf86AddDeviceToConfigure(const char *driver, pciVideoPtr pVideo, int chipset)
+{
+ return xf86AddBusDeviceToConfigure(driver, pVideo ? BUS_PCI : BUS_ISA,
+ pVideo, chipset);
+}
+
+static XF86ConfInputPtr
+configureInputSection (void)
+{
+ XF86ConfInputPtr mouse = NULL;
+ parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
+
+ ptr->inp_identifier = "Keyboard0";
+#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
+ ptr->inp_driver = "keyboard";
+#else
+ ptr->inp_driver = "kbd";
+#endif
+ ptr->list.next = NULL;
+
+ /* Crude mechanism to auto-detect mouse (os dependent) */
+ {
+ int fd;
+#if 0 && defined linux
+ /* Our autodetection code can do a better job */
+ int len;
+ char path[32];
+
+ if ((len = readlink(DFLT_MOUSE_DEV, path, sizeof(path) - 1)) > 0) {
+ path[len] = '\0';
+ if (strstr(path, "psaux") != NULL)
+ DFLT_MOUSE_PROTO = "PS/2";
+ }
+#endif
+#ifdef WSCONS_SUPPORT
+ fd = open("/dev/wsmouse", 0);
+ if (fd > 0) {
+ DFLT_MOUSE_DEV = "/dev/wsmouse";
+ DFLT_MOUSE_PROTO = "wsmouse";
+ close(fd);
+ } else {
+ ErrorF("cannot open /dev/wsmouse\n");
+ }
+#endif
+
+#ifndef __SCO__
+ fd = open(DFLT_MOUSE_DEV, 0);
+ if (fd != -1) {
+ foundMouse = TRUE;
+ close(fd);
+ }
+#else
+ foundMouse = TRUE;
+#endif
+ }
+
+ mouse = xf86confmalloc(sizeof(XF86ConfInputRec));
+ memset((XF86ConfInputPtr)mouse,0,sizeof(XF86ConfInputRec));
+ mouse->inp_identifier = "Mouse0";
+ mouse->inp_driver = "mouse";
+ mouse->inp_option_lst =
+ xf86addNewOption(mouse->inp_option_lst, "Protocol", DFLT_MOUSE_PROTO);
+#ifndef __SCO__
+ mouse->inp_option_lst =
+ xf86addNewOption(mouse->inp_option_lst, "Device", DFLT_MOUSE_DEV);
+#endif
+ mouse->inp_option_lst =
+ xf86addNewOption(mouse->inp_option_lst, "ZAxisMapping", "4 5 6 7");
+ ptr = (XF86ConfInputPtr)xf86addListItem((glp)ptr, (glp)mouse);
+ return ptr;
+}
+
+static XF86ConfDRIPtr
+configureDRISection (void)
+{
+#ifdef NOTYET
+ parsePrologue (XF86ConfDRIPtr, XF86ConfDRIRec)
+
+ return ptr;
+#else
+ return NULL;
+#endif
+}
+
+static XF86ConfVendorPtr
+configureVendorSection (void)
+{
+ parsePrologue (XF86ConfVendorPtr, XF86ConfVendorRec)
+
+ return NULL;
+#if 0
+ return ptr;
+#endif
+}
+
+static XF86ConfScreenPtr
+configureScreenSection (int screennum)
+{
+ int i;
+ int depths[] = { 1, 4, 8, 15, 16, 24/*, 32*/ };
+ parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
+
+ ptr->scrn_identifier = xf86confmalloc(18);
+ sprintf(ptr->scrn_identifier, "Screen%d", screennum);
+ ptr->scrn_monitor_str = xf86confmalloc(19);
+ sprintf(ptr->scrn_monitor_str, "Monitor%d", screennum);
+ ptr->scrn_device_str = xf86confmalloc(16);
+ sprintf(ptr->scrn_device_str, "Card%d", screennum);
+
+ for (i=0; i<sizeof(depths)/sizeof(depths[0]); i++)
+ {
+ XF86ConfDisplayPtr display;
+
+ display = xf86confmalloc(sizeof(XF86ConfDisplayRec));
+ memset((XF86ConfDisplayPtr)display,0,sizeof(XF86ConfDisplayRec));
+ display->disp_depth = depths[i];
+ display->disp_black.red = display->disp_white.red = -1;
+ display->disp_black.green = display->disp_white.green = -1;
+ display->disp_black.blue = display->disp_white.blue = -1;
+ ptr->scrn_display_lst = (XF86ConfDisplayPtr)xf86addListItem(
+ (glp)ptr->scrn_display_lst, (glp)display);
+ }
+
+ return ptr;
+}
+
+static const char*
+optionTypeToSting(OptionValueType type)
+{
+ switch (type) {
+ case OPTV_NONE:
+ return "";
+ case OPTV_INTEGER:
+ return "<i>";
+ case OPTV_STRING:
+ return "<str>";
+ case OPTV_ANYSTR:
+ return "[<str>]";
+ case OPTV_REAL:
+ return "<f>";
+ case OPTV_BOOLEAN:
+ return "[<bool>]";
+ case OPTV_FREQ:
+ return "<freq>";
+ default:
+ return "";
+ }
+}
+
+static XF86ConfDevicePtr
+configureDeviceSection (int screennum)
+{
+ char identifier[16];
+ OptionInfoPtr p;
+ int i = 0;
+#ifdef DO_FBDEV_PROBE
+ Bool foundFBDEV = FALSE;
+#endif
+ parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
+
+ /* Move device info to parser structure */
+ sprintf(identifier, "Card%d", screennum);
+ ptr->dev_identifier = strdup(identifier);
+/* ptr->dev_identifier = DevToConfig[screennum].GDev.identifier;*/
+ ptr->dev_vendor = DevToConfig[screennum].GDev.vendor;
+ ptr->dev_board = DevToConfig[screennum].GDev.board;
+ ptr->dev_chipset = DevToConfig[screennum].GDev.chipset;
+ ptr->dev_busid = DevToConfig[screennum].GDev.busID;
+ ptr->dev_driver = DevToConfig[screennum].GDev.driver;
+ ptr->dev_ramdac = DevToConfig[screennum].GDev.ramdac;
+ for (i = 0; (i < MAXDACSPEEDS) && (i < CONF_MAXDACSPEEDS); i++)
+ ptr->dev_dacSpeeds[i] = DevToConfig[screennum].GDev.dacSpeeds[i];
+ ptr->dev_videoram = DevToConfig[screennum].GDev.videoRam;
+ ptr->dev_textclockfreq = DevToConfig[screennum].GDev.textClockFreq;
+ ptr->dev_bios_base = DevToConfig[screennum].GDev.BiosBase;
+ ptr->dev_mem_base = DevToConfig[screennum].GDev.MemBase;
+ ptr->dev_io_base = DevToConfig[screennum].GDev.IOBase;
+ ptr->dev_clockchip = DevToConfig[screennum].GDev.clockchip;
+ for (i = 0; (i < MAXCLOCKS) && (i < DevToConfig[screennum].GDev.numclocks); i++)
+ ptr->dev_clock[i] = DevToConfig[screennum].GDev.clock[i];
+ ptr->dev_clocks = i;
+ ptr->dev_chipid = DevToConfig[screennum].GDev.chipID;
+ ptr->dev_chiprev = DevToConfig[screennum].GDev.chipRev;
+ ptr->dev_irq = DevToConfig[screennum].GDev.irq;
+
+ /* Make sure older drivers don't segv */
+ if (DevToConfig[screennum].GDev.options) {
+ /* Fill in the available driver options for people to use */
+ const char *descrip =
+ " ### Available Driver options are:-\n"
+ " ### Values: <i>: integer, <f>: float, "
+ "<bool>: \"True\"/\"False\",\n"
+ " ### <string>: \"String\", <freq>: \"<f> Hz/kHz/MHz\"\n"
+ " ### [arg]: arg optional\n";
+ ptr->dev_comment = xstrdup(descrip);
+ if (ptr->dev_comment) {
+ for (p = DevToConfig[screennum].GDev.options;
+ p->name != NULL; p++) {
+ char *p_e;
+ const char *prefix = " #Option ";
+ const char *middle = " \t# ";
+ const char *suffix = "\n";
+ const char *opttype = optionTypeToSting(p->type);
+ char *optname;
+ int len = strlen(ptr->dev_comment) + strlen(prefix) +
+ strlen(middle) + strlen(suffix) + 1;
+
+ optname = xalloc(strlen(p->name) + 2 + 1);
+ if (!optname)
+ break;
+ sprintf(optname, "\"%s\"", p->name);
+
+ len += max(20, strlen(optname));
+ len += strlen(opttype);
+
+ ptr->dev_comment = xrealloc(ptr->dev_comment, len);
+ if (!ptr->dev_comment)
+ break;
+ p_e = ptr->dev_comment + strlen(ptr->dev_comment);
+ sprintf(p_e, "%s%-20s%s%s%s", prefix, optname, middle,
+ opttype, suffix);
+ xfree(optname);
+ }
+ }
+ }
+
+#ifdef DO_FBDEV_PROBE
+ /* Crude mechanism to auto-detect fbdev (os dependent) */
+ /* Skip it for now. Options list it anyway, and we can't
+ * determine which screen/driver this belongs too anyway. */
+ {
+ int fd;
+
+ fd = open("/dev/fb0", 0);
+ if (fd != -1) {
+ foundFBDEV = TRUE;
+ close(fd);
+ }
+ }
+
+ if (foundFBDEV) {
+ XF86OptionPtr fbdev;
+
+ fbdev = xf86confmalloc(sizeof(XF86OptionRec));
+ memset((XF86OptionPtr)fbdev,0,sizeof(XF86OptionRec));
+ fbdev->opt_name = "UseFBDev";
+ fbdev->opt_val = "ON";
+ ptr->dev_option_lst = (XF86OptionPtr)xf86addListItem(
+ (glp)ptr->dev_option_lst, (glp)fbdev);
+ }
+#endif
+
+ return ptr;
+}
+
+static XF86ConfLayoutPtr
+configureLayoutSection (void)
+{
+ int scrnum = 0;
+ parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
+
+ ptr->lay_identifier = "X.org Configured";
+
+ {
+ XF86ConfInputrefPtr iptr;
+
+ iptr = xf86confmalloc (sizeof (XF86ConfInputrefRec));
+ iptr->list.next = NULL;
+ iptr->iref_option_lst = NULL;
+ iptr->iref_inputdev_str = "Mouse0";
+ iptr->iref_option_lst =
+ xf86addNewOption (iptr->iref_option_lst, "CorePointer", NULL);
+ ptr->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
+ }
+
+ {
+ XF86ConfInputrefPtr iptr;
+
+ iptr = xf86confmalloc (sizeof (XF86ConfInputrefRec));
+ iptr->list.next = NULL;
+ iptr->iref_option_lst = NULL;
+ iptr->iref_inputdev_str = "Keyboard0";
+ iptr->iref_option_lst =
+ xf86addNewOption (iptr->iref_option_lst, "CoreKeyboard", NULL);
+ ptr->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
+ }
+
+ for (scrnum = 0; scrnum < nDevToConfig; scrnum++) {
+ XF86ConfAdjacencyPtr aptr;
+
+ aptr = xf86confmalloc (sizeof (XF86ConfAdjacencyRec));
+ aptr->list.next = NULL;
+ aptr->adj_x = 0;
+ aptr->adj_y = 0;
+ aptr->adj_scrnum = scrnum;
+ aptr->adj_screen_str = xnfalloc(18);
+ sprintf(aptr->adj_screen_str, "Screen%d", scrnum);
+ if (scrnum == 0) {
+ aptr->adj_where = CONF_ADJ_ABSOLUTE;
+ aptr->adj_refscreen = NULL;
+ }
+ else {
+ aptr->adj_where = CONF_ADJ_RIGHTOF;
+ aptr->adj_refscreen = xnfalloc(18);
+ sprintf(aptr->adj_refscreen, "Screen%d", scrnum - 1);
+ }
+ ptr->lay_adjacency_lst =
+ (XF86ConfAdjacencyPtr)xf86addListItem((glp)ptr->lay_adjacency_lst,
+ (glp)aptr);
+ }
+
+ return ptr;
+}
+
+static XF86ConfModesPtr
+configureModesSection (void)
+{
+#ifdef NOTYET
+ parsePrologue (XF86ConfModesPtr, XF86ConfModesRec)
+
+ return ptr;
+#else
+ return NULL;
+#endif
+}
+
+static XF86ConfVideoAdaptorPtr
+configureVideoAdaptorSection (void)
+{
+ parsePrologue (XF86ConfVideoAdaptorPtr, XF86ConfVideoAdaptorRec)
+
+ return NULL;
+#if 0
+ return ptr;
+#endif
+}
+
+static XF86ConfFlagsPtr
+configureFlagsSection (void)
+{
+ parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
+
+ return ptr;
+}
+
+static XF86ConfModulePtr
+configureModuleSection (void)
+{
+#ifdef XFree86LOADER
+ char **elist, **el;
+ /* Find the list of extension modules. */
+ const char *esubdirs[] = {
+ "extensions",
+ NULL
+ };
+ const char *fsubdirs[] = {
+ "fonts",
+ NULL
+ };
+#endif
+ parsePrologue (XF86ConfModulePtr, XF86ConfModuleRec)
+
+#ifdef XFree86LOADER
+ elist = LoaderListDirs(esubdirs, NULL);
+ if (elist) {
+ for (el = elist; *el; el++) {
+ XF86LoadPtr module;
+
+ module = xf86confmalloc(sizeof(XF86LoadRec));
+ memset((XF86LoadPtr)module,0,sizeof(XF86LoadRec));
+ module->load_name = *el;
+ /* HACK, remove GLcore, glx, loads it as a submodule */
+ if (strcmp(*el, "GLcore"))
+ ptr->mod_load_lst = (XF86LoadPtr)xf86addListItem(
+ (glp)ptr->mod_load_lst, (glp)module);
+ }
+ xfree(elist);
+ }
+
+ /* Process list of font backends separately to include only required ones */
+ elist = LoaderListDirs(fsubdirs, NULL);
+ if (elist) {
+ for (el = elist; *el; el++) {
+ XF86LoadPtr module;
+
+ module = xf86confmalloc(sizeof(XF86LoadRec));
+ memset((XF86LoadPtr)module,0,sizeof(XF86LoadRec));
+ module->load_name = *el;
+
+ /* Add only those font backends which are referenced by fontpath */
+ /* 'strstr(dFP,"/dir")' is meant as 'dFP =~ m(/dir\W)' */
+ if (defaultFontPath && (
+ (strcmp(*el, "freetype") == 0 &&
+ strstr(defaultFontPath, "/TTF")) ||
+ (strcmp(*el, "type1") == 0 &&
+ strstr(defaultFontPath, "/Type1")) ||
+ (strcmp(*el, "speedo") == 0 &&
+ strstr(defaultFontPath, "/Speedo"))))
+ ptr->mod_load_lst = (XF86LoadPtr)xf86addListItem(
+ (glp)ptr->mod_load_lst, (glp)module);
+ }
+ xfree(elist);
+ }
+#endif
+
+ return ptr;
+}
+
+static XF86ConfFilesPtr
+configureFilesSection (void)
+{
+ parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec)
+
+#ifdef XFree86LOADER
+ if (xf86ModulePath)
+ ptr->file_modulepath = strdup(xf86ModulePath);
+#endif
+ if (defaultFontPath)
+ ptr->file_fontpath = strdup(defaultFontPath);
+ if (rgbPath)
+ ptr->file_rgbpath = strdup(rgbPath);
+
+ return ptr;
+}
+
+static XF86ConfMonitorPtr
+configureMonitorSection (int screennum)
+{
+ parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
+
+ ptr->mon_identifier = xf86confmalloc(19);
+ sprintf(ptr->mon_identifier, "Monitor%d", screennum);
+ ptr->mon_vendor = strdup("Monitor Vendor");
+ ptr->mon_modelname = strdup("Monitor Model");
+
+ return ptr;
+}
+
+static XF86ConfMonitorPtr
+configureDDCMonitorSection (int screennum)
+{
+ int i = 0;
+ int len, mon_width, mon_height;
+#define displaySizeMaxLen 80
+ char displaySize_string[displaySizeMaxLen];
+ int displaySizeLen;
+
+ parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
+
+ ptr->mon_identifier = xf86confmalloc(19);
+ sprintf(ptr->mon_identifier, "Monitor%d", screennum);
+ ptr->mon_vendor = strdup(ConfiguredMonitor->vendor.name);
+ ptr->mon_modelname = xf86confmalloc(12);
+ sprintf(ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id);
+
+ /* features in centimetres, we want millimetres */
+ mon_width = 10 * ConfiguredMonitor->features.hsize ;
+ mon_height = 10 * ConfiguredMonitor->features.vsize ;
+
+#ifdef CONFIGURE_DISPLAYSIZE
+ ptr->mon_width = mon_width;
+ ptr->mon_height = mon_height;
+#else
+ if (mon_width && mon_height) {
+ /* when values available add DisplaySize option AS A COMMENT */
+
+ displaySizeLen = snprintf(displaySize_string, displaySizeMaxLen,
+ "\t#DisplaySize\t%5d %5d\t# mm\n",
+ mon_width, mon_height);
+
+ if (displaySizeLen>0 && displaySizeLen<displaySizeMaxLen) {
+ if (ptr->mon_comment) {
+ len = strlen(ptr->mon_comment);
+ } else {
+ len = 0;
+ }
+ if ((ptr->mon_comment =
+ xf86confrealloc(ptr->mon_comment,
+ len+strlen(displaySize_string)))) {
+ strcpy(ptr->mon_comment + len, displaySize_string);
+ }
+ }
+ }
+#endif /* def CONFIGURE_DISPLAYSIZE */
+
+ for (i=0;i<4;i++) {
+ switch (ConfiguredMonitor->det_mon[i].type) {
+ case DS_NAME:
+ ptr->mon_modelname = xf86confrealloc(ptr->mon_modelname,
+ strlen((char*)(ConfiguredMonitor->det_mon[i].section.name))
+ + 1);
+ strcpy(ptr->mon_modelname,
+ (char*)(ConfiguredMonitor->det_mon[i].section.name));
+ break;
+ case DS_RANGES:
+ ptr->mon_hsync[ptr->mon_n_hsync].lo =
+ ConfiguredMonitor->det_mon[i].section.ranges.min_h;
+ ptr->mon_hsync[ptr->mon_n_hsync].hi =
+ ConfiguredMonitor->det_mon[i].section.ranges.max_h;
+ ptr->mon_n_vrefresh = 1;
+ ptr->mon_vrefresh[ptr->mon_n_hsync].lo =
+ ConfiguredMonitor->det_mon[i].section.ranges.min_v;
+ ptr->mon_vrefresh[ptr->mon_n_hsync].hi =
+ ConfiguredMonitor->det_mon[i].section.ranges.max_v;
+ ptr->mon_n_hsync++;
+ default:
+ break;
+ }
+ }
+
+ if (ConfiguredMonitor->features.dpms) {
+ ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, "DPMS", NULL);
+ }
+
+ return ptr;
+}
+
+void
+DoConfigure()
+{
+ int i,j, screennum = -1;
+ char *home = NULL;
+ char *filename = NULL;
+ XF86ConfigPtr xf86config = NULL;
+ char **vlist, **vl;
+ int *dev2screen;
+
+ vlist = xf86DriverlistFromCompile();
+
+ if (!vlist) {
+ ErrorF("Missing output drivers. Configuration failed.\n");
+ goto bail;
+ }
+
+ ErrorF("List of video drivers:\n");
+ for (vl = vlist; *vl; vl++)
+ ErrorF("\t%s\n", *vl);
+
+#ifdef XFree86LOADER
+ /* Load all the drivers that were found. */
+ xf86LoadModules(vlist, NULL);
+#endif /* XFree86LOADER */
+
+ xfree(vlist);
+
+ for (i = 0; i < xf86NumDrivers; i++) {
+ xorgHWFlags flags;
+ if (!xf86DriverList[i]->driverFunc
+ || !xf86DriverList[i]->driverFunc(NULL,
+ GET_REQUIRED_HW_INTERFACES,
+ &flags)
+ || NEED_IO_ENABLED(flags)) {
+ xorgHWAccess = TRUE;
+ break;
+ }
+ }
+ /* Enable full I/O access */
+ if (xorgHWAccess) {
+ if(!xf86EnableIO())
+ /* oops, we have failed */
+ xorgHWAccess = FALSE;
+ }
+
+ /* Disable PCI devices */
+ xf86ResourceBrokerInit();
+ xf86AccessInit();
+ xf86FindPrimaryDevice();
+
+ /* Create XF86Config file structure */
+ xf86config = malloc(sizeof(XF86ConfigRec));
+ memset ((XF86ConfigPtr)xf86config, 0, sizeof(XF86ConfigRec));
+ xf86config->conf_device_lst = NULL;
+ xf86config->conf_screen_lst = NULL;
+ xf86config->conf_monitor_lst = NULL;
+
+ /* Call all of the probe functions, reporting the results. */
+ for (CurrentDriver = 0; CurrentDriver < xf86NumDrivers; CurrentDriver++) {
+ xorgHWFlags flags;
+
+ if (!xorgHWAccess) {
+ if (!xf86DriverList[CurrentDriver]->driverFunc
+ || !xf86DriverList[CurrentDriver]->driverFunc(NULL,
+ GET_REQUIRED_HW_INTERFACES,
+ &flags)
+ || NEED_IO_ENABLED(flags))
+ continue;
+ }
+
+ if (xf86DriverList[CurrentDriver]->Probe == NULL) continue;
+
+ if ((*xf86DriverList[CurrentDriver]->Probe)(
+ xf86DriverList[CurrentDriver], PROBE_DETECT) &&
+ xf86DriverList[CurrentDriver]->Identify)
+ (*xf86DriverList[CurrentDriver]->Identify)(0);
+ }
+
+ if (nDevToConfig <= 0) {
+ ErrorF("No devices to configure. Configuration failed.\n");
+ goto bail;
+ }
+
+ /* Add device, monitor and screen sections for detected devices */
+ for (screennum = 0; screennum < nDevToConfig; screennum++) {
+ XF86ConfDevicePtr DevicePtr;
+ XF86ConfMonitorPtr MonitorPtr;
+ XF86ConfScreenPtr ScreenPtr;
+
+ DevicePtr = configureDeviceSection(screennum);
+ xf86config->conf_device_lst = (XF86ConfDevicePtr)xf86addListItem(
+ (glp)xf86config->conf_device_lst, (glp)DevicePtr);
+ MonitorPtr = configureMonitorSection(screennum);
+ xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
+ (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
+ ScreenPtr = configureScreenSection(screennum);
+ xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
+ (glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
+ }
+
+ xf86config->conf_files = configureFilesSection();
+ xf86config->conf_modules = configureModuleSection();
+ xf86config->conf_flags = configureFlagsSection();
+ xf86config->conf_videoadaptor_lst = configureVideoAdaptorSection();
+ xf86config->conf_modes_lst = configureModesSection();
+ xf86config->conf_vendor_lst = configureVendorSection();
+ xf86config->conf_dri = configureDRISection();
+ xf86config->conf_input_lst = configureInputSection();
+ xf86config->conf_layout_lst = configureLayoutSection();
+
+ if (!(home = getenv("HOME")))
+ home = "/";
+ {
+#ifdef __UNIXOS2__
+#define PATH_MAX 2048
+#endif
+#if !defined(PATH_MAX)
+#define PATH_MAX 1024
+#endif
+ const char* configfile = XF86CONFIGFILE".new";
+ char homebuf[PATH_MAX];
+ /* getenv might return R/O memory, as with OS/2 */
+ strncpy(homebuf,home,PATH_MAX-1);
+ homebuf[PATH_MAX-1] = '\0';
+ home = homebuf;
+ if (!(filename =
+ (char *)ALLOCATE_LOCAL(strlen(home) +
+ strlen(configfile) + 3)))
+
+ if (home[0] == '/' && home[1] == '\0')
+ home[0] = '\0';
+#ifndef QNX4
+ sprintf(filename, "%s/%s", home,configfile);
+#else
+ sprintf(filename, "//%d%s/%s", getnid(),home,configfile);
+#endif
+
+ }
+
+ xf86writeConfigFile(filename, xf86config);
+
+ xf86DoConfigurePass1 = FALSE;
+ /* Try to get DDC information filled in */
+ xf86ConfigFile = filename;
+ if (xf86HandleConfigFile(FALSE) != CONFIG_OK) {
+ goto bail;
+ }
+
+ xf86DoConfigurePass1 = FALSE;
+
+ dev2screen = xnfcalloc(1,xf86NumDrivers*sizeof(int));
+
+ {
+ Bool *driverProbed = xnfcalloc(1,xf86NumDrivers*sizeof(Bool));
+ for (screennum = 0; screennum < nDevToConfig; screennum++) {
+ int k,l,n,oldNumScreens;
+
+ i = DevToConfig[screennum].iDriver;
+
+ if (driverProbed[i]) continue;
+ driverProbed[i] = TRUE;
+
+ oldNumScreens = xf86NumScreens;
+
+ (*xf86DriverList[i]->Probe)(xf86DriverList[i], 0);
+
+ /* reorder */
+ k = screennum > 0 ? screennum : 1;
+ for (l = oldNumScreens; l < xf86NumScreens; l++) {
+ /* is screen primary? */
+ Bool primary = FALSE;
+ for (n = 0; n<xf86Screens[l]->numEntities; n++) {
+ if (xf86IsEntityPrimary(xf86Screens[l]->entityList[n])) {
+ dev2screen[0] = l;
+ primary = TRUE;
+ break;
+ }
+ }
+ if (primary) continue;
+ /* not primary: assign it to next device of same driver */
+ /*
+ * NOTE: we assume that devices in DevToConfig
+ * and xf86Screens[] have the same order except
+ * for the primary device which always comes first.
+ */
+ for (; k < nDevToConfig; k++) {
+ if (DevToConfig[k].iDriver == i) {
+ dev2screen[k++] = l;
+ break;
+ }
+ }
+ }
+ xf86SetPciVideo(NULL,NONE);
+ }
+ xfree(driverProbed);
+ }
+
+
+ if (nDevToConfig != xf86NumScreens) {
+ ErrorF("Number of created screens does not match number of detected"
+ " devices.\n Configuration failed.\n");
+ goto bail;
+ }
+
+ xf86PostProbe();
+ xf86EntityInit();
+
+ for (j = 0; j < xf86NumScreens; j++) {
+ xf86Screens[j]->scrnIndex = j;
+ }
+
+ xf86freeMonitorList(xf86config->conf_monitor_lst);
+ xf86config->conf_monitor_lst = NULL;
+ xf86freeScreenList(xf86config->conf_screen_lst);
+ xf86config->conf_screen_lst = NULL;
+ for (j = 0; j < xf86NumScreens; j++) {
+ XF86ConfMonitorPtr MonitorPtr;
+ XF86ConfScreenPtr ScreenPtr;
+
+ ConfiguredMonitor = NULL;
+
+ xf86EnableAccess(xf86Screens[dev2screen[j]]);
+ if ((*xf86Screens[dev2screen[j]]->PreInit)(xf86Screens[dev2screen[j]],
+ PROBE_DETECT) &&
+ ConfiguredMonitor) {
+ MonitorPtr = configureDDCMonitorSection(j);
+ } else {
+ MonitorPtr = configureMonitorSection(j);
+ }
+ ScreenPtr = configureScreenSection(j);
+ xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
+ (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
+ xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
+ (glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
+ }
+
+ xf86writeConfigFile(filename, xf86config);
+
+ ErrorF("\n");
+
+#ifdef __SCO__
+ ErrorF("\n"__XSERVERNAME__
+ " is using the kernel event driver to access the mouse.\n"
+ "If you wish to use the internal "__XSERVERNAME__
+ " mouse drivers, please\n"
+ "edit the file and correct the Device.\n");
+#else /* !__SCO__ */
+ if (!foundMouse) {
+ ErrorF("\n"__XSERVERNAME__" is not able to detect your mouse.\n"
+ "Edit the file and correct the Device.\n");
+ } else {
+#ifndef __UNIXOS2__ /* OS/2 definitely has a mouse */
+ ErrorF("\n"__XSERVERNAME__" detected your mouse at device %s.\n"
+ "Please check your config if the mouse is still not\n"
+ "operational, as by default "__XSERVERNAME__
+ " tries to autodetect\n"
+ "the protocol.\n",DFLT_MOUSE_DEV);
+#endif
+ }
+#endif /* !__SCO__ */
+
+ if (xf86NumScreens > 1) {
+ ErrorF("\n"__XSERVERNAME__
+ " has configured a multihead system, please check your config.\n");
+ }
+
+ ErrorF("\nYour %s file is %s\n\n", XF86CONFIGFILE ,filename);
+ ErrorF("To test the server, run 'X -config %s'\n\n", filename);
+
+bail:
+ OsCleanup(TRUE);
+ AbortDDX();
+ fflush(stderr);
+ exit(0);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Cursor.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Cursor.c
new file mode 100644
index 000000000..0e2d77492
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Cursor.c
@@ -0,0 +1,788 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c,v 3.37 2003/11/07 22:20:17 dawes Exp $ */
+/*
+ * Copyright (c) 1994-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* $XConsortium: xf86Cursor.c /main/10 1996/10/19 17:58:23 kaleb $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "input.h"
+#include "cursor.h"
+#include "mipointer.h"
+#include "scrnintstr.h"
+#include "globals.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSproc.h"
+
+#ifdef XINPUT
+#include <X11/extensions/XIproto.h>
+#include "xf86Xinput.h"
+#endif
+
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+
+typedef struct _xf86EdgeRec {
+ short screen;
+ short start;
+ short end;
+ DDXPointRec offset;
+ struct _xf86EdgeRec *next;
+} xf86EdgeRec, *xf86EdgePtr;
+
+typedef struct {
+ xf86EdgePtr left, right, up, down;
+} xf86ScreenLayoutRec, *xf86ScreenLayoutPtr;
+
+static Bool xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y);
+static void xf86CrossScreen(ScreenPtr pScreen, Bool entering);
+static void xf86WarpCursor(ScreenPtr pScreen, int x, int y);
+
+static void xf86PointerMoved(int scrnIndex, int x, int y);
+
+static miPointerScreenFuncRec xf86PointerScreenFuncs = {
+ xf86CursorOffScreen,
+ xf86CrossScreen,
+ xf86WarpCursor,
+#ifdef XINPUT
+ xf86eqEnqueue,
+ xf86eqSwitchScreen
+#else
+ /* let miPointerInitialize take care of these */
+ NULL,
+ NULL
+#endif
+};
+
+static xf86ScreenLayoutRec xf86ScreenLayout[MAXSCREENS];
+
+static Bool HardEdges;
+
+/*
+ * xf86InitViewport --
+ * Initialize paning & zooming parameters, so that a driver must only
+ * check what resolutions are possible and whether the virtual area
+ * is valid if specified.
+ */
+
+void
+xf86InitViewport(ScrnInfoPtr pScr)
+{
+
+ pScr->PointerMoved = xf86PointerMoved;
+
+ /*
+ * Compute the initial Viewport if necessary
+ */
+ if (pScr->display) {
+ if (pScr->display->frameX0 < 0) {
+ pScr->frameX0 = (pScr->virtualX - pScr->modes->HDisplay) / 2;
+ pScr->frameY0 = (pScr->virtualY - pScr->modes->VDisplay) / 2;
+ } else {
+ pScr->frameX0 = pScr->display->frameX0;
+ pScr->frameY0 = pScr->display->frameY0;
+ }
+ }
+
+ pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
+ pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
+
+ /*
+ * Now adjust the initial Viewport, so it lies within the virtual area
+ */
+ if (pScr->frameX1 >= pScr->virtualX)
+ {
+ pScr->frameX0 = pScr->virtualX - pScr->modes->HDisplay;
+ pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
+ }
+
+ if (pScr->frameY1 >= pScr->virtualY)
+ {
+ pScr->frameY0 = pScr->virtualY - pScr->modes->VDisplay;
+ pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
+ }
+}
+
+
+/*
+ * xf86SetViewport --
+ * Scroll the visual part of the screen so the pointer is visible.
+ */
+
+void
+xf86SetViewport(ScreenPtr pScreen, int x, int y)
+{
+ ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+
+ (*pScr->PointerMoved)(pScreen->myNum, x, y);
+}
+
+
+static void
+xf86PointerMoved(int scrnIndex, int x, int y)
+{
+ Bool frameChanged = FALSE;
+ ScrnInfoPtr pScr = xf86Screens[scrnIndex];
+
+ /*
+ * check wether (x,y) belongs to the visual part of the screen
+ * if not, change the base of the displayed frame accoring
+ */
+ if ( pScr->frameX0 > x) {
+ pScr->frameX0 = x;
+ pScr->frameX1 = x + pScr->currentMode->HDisplay - 1;
+ frameChanged = TRUE ;
+ }
+
+ if ( pScr->frameX1 < x) {
+ pScr->frameX1 = x + 1;
+ pScr->frameX0 = x - pScr->currentMode->HDisplay + 1;
+ frameChanged = TRUE ;
+ }
+
+ if ( pScr->frameY0 > y) {
+ pScr->frameY0 = y;
+ pScr->frameY1 = y + pScr->currentMode->VDisplay - 1;
+ frameChanged = TRUE;
+ }
+
+ if ( pScr->frameY1 < y) {
+ pScr->frameY1 = y;
+ pScr->frameY0 = y - pScr->currentMode->VDisplay + 1;
+ frameChanged = TRUE;
+ }
+
+ if (frameChanged && pScr->AdjustFrame != NULL)
+ pScr->AdjustFrame(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
+}
+
+/*
+ * xf86LockZoom --
+ * Enable/disable ZoomViewport
+ */
+
+void
+xf86LockZoom(ScreenPtr pScreen, Bool lock)
+{
+ XF86SCRNINFO(pScreen)->zoomLocked = lock;
+}
+
+/*
+ * xf86SwitchMode --
+ * This is called by both keyboard processing and the VidMode extension to
+ * set a new mode.
+ */
+
+Bool
+xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
+{
+ ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+ ScreenPtr pCursorScreen;
+ Bool Switched;
+ int px, py;
+
+ if (!pScr->vtSema || !mode || !pScr->SwitchMode)
+ return FALSE;
+
+#ifdef XFreeXDGA
+ if (DGAActive(pScr->scrnIndex))
+ return FALSE;
+#endif
+
+ if (mode == pScr->currentMode)
+ return TRUE;
+
+ if (mode->HDisplay > pScr->virtualX || mode->VDisplay > pScr->virtualY)
+ return FALSE;
+
+ pCursorScreen = miPointerCurrentScreen();
+ if (pScreen == pCursorScreen)
+ miPointerPosition(&px, &py);
+
+ xf86EnterServerState(SETUP);
+ Switched = (*pScr->SwitchMode)(pScr->scrnIndex, mode, 0);
+ xf86EnterServerState(OPERATING);
+ if (Switched) {
+ pScr->currentMode = mode;
+
+ /*
+ * Adjust frame for new display size.
+ */
+ if (pScreen == pCursorScreen)
+ pScr->frameX0 = px - (mode->HDisplay / 2) + 1;
+ else
+ pScr->frameX0 = (pScr->frameX0 + pScr->frameX1 + 1 - mode->HDisplay) / 2;
+
+ if (pScr->frameX0 < 0)
+ pScr->frameX0 = 0;
+
+ pScr->frameX1 = pScr->frameX0 + mode->HDisplay - 1;
+ if (pScr->frameX1 >= pScr->virtualX) {
+ pScr->frameX0 = pScr->virtualX - mode->HDisplay;
+ pScr->frameX1 = pScr->virtualX - 1;
+ }
+
+ if (pScreen == pCursorScreen)
+ pScr->frameY0 = py - (mode->VDisplay / 2) + 1;
+ else
+ pScr->frameY0 = (pScr->frameY0 + pScr->frameY1 + 1 - mode->VDisplay) / 2;
+
+ if (pScr->frameY0 < 0)
+ pScr->frameY0 = 0;
+
+ pScr->frameY1 = pScr->frameY0 + mode->VDisplay - 1;
+ if (pScr->frameY1 >= pScr->virtualY) {
+ pScr->frameY0 = pScr->virtualY - mode->VDisplay;
+ pScr->frameY1 = pScr->virtualY - 1;
+ }
+ }
+
+ if (pScr->AdjustFrame)
+ (*pScr->AdjustFrame)(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
+
+ if (pScreen == pCursorScreen)
+ xf86WarpCursor(pScreen, px, py);
+
+ return Switched;
+}
+
+/*
+ * xf86ZoomViewport --
+ * Reinitialize the visual part of the screen for another mode.
+ */
+
+void
+xf86ZoomViewport(ScreenPtr pScreen, int zoom)
+{
+ ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+ DisplayModePtr mode;
+
+ if (pScr->zoomLocked || !(mode = pScr->currentMode))
+ return;
+
+ do {
+ if (zoom > 0)
+ mode = mode->next;
+ else
+ mode = mode->prev;
+ } while (mode != pScr->currentMode && !(mode->type & M_T_USERDEF));
+
+ (void)xf86SwitchMode(pScreen, mode);
+}
+
+
+static xf86EdgePtr
+FindEdge(xf86EdgePtr edge, int val)
+{
+ while(edge && (edge->end <= val))
+ edge = edge->next;
+
+ if(edge && (edge->start <= val))
+ return edge;
+
+ return NULL;
+}
+
+/*
+ * xf86CursorOffScreen --
+ * Check whether it is necessary to switch to another screen
+ */
+
+static Bool
+xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
+{
+ xf86EdgePtr edge;
+ int tmp;
+
+ if(screenInfo.numScreens == 1)
+ return FALSE;
+
+ if(*x < 0) {
+ tmp = *y;
+ if(tmp < 0) tmp = 0;
+ if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1;
+
+ if((edge = xf86ScreenLayout[(*pScreen)->myNum].left))
+ edge = FindEdge(edge, tmp);
+
+ if(!edge) *x = 0;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ *pScreen = xf86Screens[edge->screen]->pScreen;
+ }
+ }
+
+ if(*x >= (*pScreen)->width) {
+ tmp = *y;
+ if(tmp < 0) tmp = 0;
+ if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1;
+
+ if((edge = xf86ScreenLayout[(*pScreen)->myNum].right))
+ edge = FindEdge(edge, tmp);
+
+ if(!edge) *x = (*pScreen)->width - 1;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ *pScreen = xf86Screens[edge->screen]->pScreen;
+ }
+ }
+
+ if(*y < 0) {
+ tmp = *x;
+ if(tmp < 0) tmp = 0;
+ if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1;
+
+ if((edge = xf86ScreenLayout[(*pScreen)->myNum].up))
+ edge = FindEdge(edge, tmp);
+
+ if(!edge) *y = 0;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ *pScreen = xf86Screens[edge->screen]->pScreen;
+ }
+ }
+
+ if(*y >= (*pScreen)->height) {
+ tmp = *x;
+ if(tmp < 0) tmp = 0;
+ if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1;
+
+ if((edge = xf86ScreenLayout[(*pScreen)->myNum].down))
+ edge = FindEdge(edge, tmp);
+
+ if(!edge) *y = (*pScreen)->height - 1;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ (*pScreen) = xf86Screens[edge->screen]->pScreen;
+ }
+ }
+
+
+#if 0
+ /* This presents problems for overlapping screens when
+ HardEdges is used. Have to think about the logic more */
+ if((*x < 0) || (*x >= (*pScreen)->width) ||
+ (*y < 0) || (*y >= (*pScreen)->height)) {
+ /* We may have crossed more than one screen */
+ xf86CursorOffScreen(pScreen, x, y);
+ }
+#endif
+
+ return TRUE;
+}
+
+
+
+/*
+ * xf86CrossScreen --
+ * Switch to another screen
+ */
+
+/* NEED TO CHECK THIS */
+/* ARGSUSED */
+static void
+xf86CrossScreen (ScreenPtr pScreen, Bool entering)
+{
+#if 0
+ if (xf86Info.sharedMonitor)
+ (XF86SCRNINFO(pScreen)->EnterLeaveMonitor)(entering);
+ (XF86SCRNINFO(pScreen)->EnterLeaveCursor)(entering);
+#endif
+}
+
+
+/*
+ * xf86WarpCursor --
+ * Warp possible to another screen
+ */
+
+/* ARGSUSED */
+static void
+xf86WarpCursor (ScreenPtr pScreen, int x, int y)
+{
+ int sigstate;
+ sigstate = xf86BlockSIGIO ();
+ miPointerWarpCursor(pScreen,x,y);
+
+ xf86Info.currentScreen = pScreen;
+ xf86UnblockSIGIO (sigstate);
+}
+
+
+void *
+xf86GetPointerScreenFuncs(void)
+{
+ return (void *)&xf86PointerScreenFuncs;
+}
+
+
+static xf86EdgePtr
+AddEdge(
+ xf86EdgePtr edge,
+ short min,
+ short max,
+ short dx,
+ short dy,
+ short screen
+){
+ xf86EdgePtr pEdge = edge, pPrev = NULL, pNew;
+
+ while(1) {
+ while(pEdge && (min >= pEdge->end)) {
+ pPrev = pEdge;
+ pEdge = pEdge->next;
+ }
+
+ if(!pEdge) {
+ if(!(pNew = xalloc(sizeof(xf86EdgeRec))))
+ break;
+
+ pNew->screen = screen;
+ pNew->start = min;
+ pNew->end = max;
+ pNew->offset.x = dx;
+ pNew->offset.y = dy;
+ pNew->next = NULL;
+
+ if(pPrev)
+ pPrev->next = pNew;
+ else
+ edge = pNew;
+
+ break;
+ } else if (min < pEdge->start) {
+ if(!(pNew = xalloc(sizeof(xf86EdgeRec))))
+ break;
+
+ pNew->screen = screen;
+ pNew->start = min;
+ pNew->offset.x = dx;
+ pNew->offset.y = dy;
+ pNew->next = pEdge;
+
+ if(pPrev) pPrev->next = pNew;
+ else edge = pNew;
+
+ if(max <= pEdge->start) {
+ pNew->end = max;
+ break;
+ } else {
+ pNew->end = pEdge->start;
+ min = pEdge->end;
+ }
+ } else
+ min = pEdge->end;
+
+ pPrev = pEdge;
+ pEdge = pEdge->next;
+
+ if(max <= min) break;
+ }
+
+ return edge;
+}
+
+static void
+FillOutEdge(xf86EdgePtr pEdge, int limit)
+{
+ xf86EdgePtr pNext;
+ int diff;
+
+ if(pEdge->start > 0) pEdge->start = 0;
+
+ while((pNext = pEdge->next)) {
+ diff = pNext->start - pEdge->end;
+ if(diff > 0) {
+ pEdge->end += diff >> 1;
+ pNext->start -= diff - (diff >> 1);
+ }
+ pEdge = pNext;
+ }
+
+ if(pEdge->end < limit)
+ pEdge->end = limit;
+}
+
+/*
+ * xf86InitOrigins() can deal with a maximum of 32 screens
+ * on 32 bit architectures, 64 on 64 bit architectures.
+ */
+
+void
+xf86InitOrigins(void)
+{
+ unsigned long screensLeft, prevScreensLeft, mask;
+ screenLayoutPtr screen;
+ ScreenPtr pScreen;
+ int x1, x2, y1, y2, left, right, top, bottom;
+ int i, j, ref, minX, minY, min, max;
+ xf86ScreenLayoutPtr pLayout;
+ Bool OldStyleConfig = FALSE;
+
+ /* need to have this set up with a config file option */
+ HardEdges = FALSE;
+
+ bzero(xf86ScreenLayout, MAXSCREENS * sizeof(xf86ScreenLayoutRec));
+
+ screensLeft = prevScreensLeft = (1 << xf86NumScreens) - 1;
+
+ while(1) {
+ for(mask = screensLeft, i = 0; mask; mask >>= 1, i++) {
+ if(!(mask & 1L)) continue;
+
+ screen = &xf86ConfigLayout.screens[i];
+
+ switch(screen->where) {
+ case PosObsolete:
+ OldStyleConfig = TRUE;
+ pLayout = &xf86ScreenLayout[i];
+ /* force edge lists */
+ if(screen->left) {
+ ref = screen->left->screennum;
+ pLayout->left = AddEdge(pLayout->left,
+ 0, xf86Screens[i]->pScreen->height,
+ xf86Screens[ref]->pScreen->width, 0, ref);
+ }
+ if(screen->right) {
+ ref = screen->right->screennum;
+ pScreen = xf86Screens[i]->pScreen;
+ pLayout->right = AddEdge(pLayout->right,
+ 0, pScreen->height, -pScreen->width, 0, ref);
+ }
+ if(screen->top) {
+ ref = screen->top->screennum;
+ pLayout->up = AddEdge(pLayout->up,
+ 0, xf86Screens[i]->pScreen->width,
+ 0, xf86Screens[ref]->pScreen->height, ref);
+ }
+ if(screen->bottom) {
+ ref = screen->bottom->screennum;
+ pScreen = xf86Screens[i]->pScreen;
+ pLayout->down = AddEdge(pLayout->down,
+ 0, pScreen->width, 0, -pScreen->height, ref);
+ }
+ /* we could also try to place it based on those
+ relative locations if we wanted to */
+ screen->x = screen->y = 0;
+ /* FALLTHROUGH */
+ case PosAbsolute:
+ dixScreenOrigins[i].x = screen->x;
+ dixScreenOrigins[i].y = screen->y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosRelative:
+ ref = screen->refscreen->screennum;
+ if(screensLeft & (1 << ref)) break;
+ dixScreenOrigins[i].x = dixScreenOrigins[ref].x + screen->x;
+ dixScreenOrigins[i].y = dixScreenOrigins[ref].y + screen->y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosRightOf:
+ ref = screen->refscreen->screennum;
+ if(screensLeft & (1 << ref)) break;
+ pScreen = xf86Screens[ref]->pScreen;
+ dixScreenOrigins[i].x =
+ dixScreenOrigins[ref].x + pScreen->width;
+ dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosLeftOf:
+ ref = screen->refscreen->screennum;
+ if(screensLeft & (1 << ref)) break;
+ pScreen = xf86Screens[i]->pScreen;
+ dixScreenOrigins[i].x =
+ dixScreenOrigins[ref].x - pScreen->width;
+ dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosBelow:
+ ref = screen->refscreen->screennum;
+ if(screensLeft & (1 << ref)) break;
+ pScreen = xf86Screens[ref]->pScreen;
+ dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
+ dixScreenOrigins[i].y =
+ dixScreenOrigins[ref].y + pScreen->height;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosAbove:
+ ref = screen->refscreen->screennum;
+ if(screensLeft & (1 << ref)) break;
+ pScreen = xf86Screens[i]->pScreen;
+ dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
+ dixScreenOrigins[i].y =
+ dixScreenOrigins[ref].y - pScreen->height;
+ screensLeft &= ~(1 << i);
+ break;
+ default:
+ ErrorF("Illegal placement keyword in Layout!\n");
+ break;
+ }
+
+ }
+
+ if(!screensLeft) break;
+
+ if(screensLeft == prevScreensLeft) {
+ /* All the remaining screens are referencing each other.
+ Assign a value to one of them and go through again */
+ i = 0;
+ while(!((1 << i) & screensLeft)){ i++; }
+
+ ref = xf86ConfigLayout.screens[i].refscreen->screennum;
+ dixScreenOrigins[ref].x = dixScreenOrigins[ref].y = 0;
+ screensLeft &= ~(1 << ref);
+ }
+
+ prevScreensLeft = screensLeft;
+ }
+
+ /* justify the topmost and leftmost to (0,0) */
+ minX = dixScreenOrigins[0].x;
+ minY = dixScreenOrigins[0].y;
+
+ for(i = 1; i < xf86NumScreens; i++) {
+ if(dixScreenOrigins[i].x < minX)
+ minX = dixScreenOrigins[i].x;
+ if(dixScreenOrigins[i].y < minY)
+ minY = dixScreenOrigins[i].y;
+ }
+
+ if (minX || minY) {
+ for(i = 0; i < xf86NumScreens; i++) {
+ dixScreenOrigins[i].x -= minX;
+ dixScreenOrigins[i].y -= minY;
+ }
+ }
+
+
+ /* Create the edge lists */
+
+ if(!OldStyleConfig) {
+ for(i = 0; i < xf86NumScreens; i++) {
+ pLayout = &xf86ScreenLayout[i];
+
+ pScreen = xf86Screens[i]->pScreen;
+
+ left = dixScreenOrigins[i].x;
+ right = left + pScreen->width;
+ top = dixScreenOrigins[i].y;
+ bottom = top + pScreen->height;
+
+ for(j = 0; j < xf86NumScreens; j++) {
+ if(i == j) continue;
+
+ x1 = dixScreenOrigins[j].x;
+ x2 = x1 + xf86Screens[j]->pScreen->width;
+ y1 = dixScreenOrigins[j].y;
+ y2 = y1 + xf86Screens[j]->pScreen->height;
+
+ if((bottom > y1) && (top < y2)) {
+ min = y1 - top;
+ if(min < 0) min = 0;
+ max = pScreen->height - (bottom - y2);
+ if(max > pScreen->height) max = pScreen->height;
+
+ if(((left - 1) >= x1) && ((left - 1) < x2))
+ pLayout->left = AddEdge(pLayout->left, min, max,
+ dixScreenOrigins[i].x - dixScreenOrigins[j].x,
+ dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+
+ if((right >= x1) && (right < x2))
+ pLayout->right = AddEdge(pLayout->right, min, max,
+ dixScreenOrigins[i].x - dixScreenOrigins[j].x,
+ dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+ }
+
+
+ if((left < x2) && (right > x1)) {
+ min = x1 - left;
+ if(min < 0) min = 0;
+ max = pScreen->width - (right - x2);
+ if(max > pScreen->width) max = pScreen->width;
+
+ if(((top - 1) >= y1) && ((top - 1) < y2))
+ pLayout->up = AddEdge(pLayout->up, min, max,
+ dixScreenOrigins[i].x - dixScreenOrigins[j].x,
+ dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+
+ if((bottom >= y1) && (bottom < y2))
+ pLayout->down = AddEdge(pLayout->down, min, max,
+ dixScreenOrigins[i].x - dixScreenOrigins[j].x,
+ dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+ }
+ }
+ }
+ }
+
+ if(!HardEdges && !OldStyleConfig) {
+ for(i = 0; i < xf86NumScreens; i++) {
+ pLayout = &xf86ScreenLayout[i];
+ pScreen = xf86Screens[i]->pScreen;
+ if(pLayout->left)
+ FillOutEdge(pLayout->left, pScreen->height);
+ if(pLayout->right)
+ FillOutEdge(pLayout->right, pScreen->height);
+ if(pLayout->up)
+ FillOutEdge(pLayout->up, pScreen->width);
+ if(pLayout->down)
+ FillOutEdge(pLayout->down, pScreen->width);
+ }
+ }
+}
+
+void
+xf86ReconfigureLayout(void)
+{
+ int i;
+
+ for (i = 0; i < MAXSCREENS; i++) {
+ xf86ScreenLayoutPtr sl = &xf86ScreenLayout[i];
+ /* we don't have to zero these, xf86InitOrigins() takes care of that */
+ if (sl->left) xfree(sl->left);
+ if (sl->right) xfree(sl->right);
+ if (sl->up) xfree(sl->up);
+ if (sl->down) xfree(sl->down);
+ }
+
+ xf86InitOrigins();
+}
+
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86DGA.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86DGA.c
new file mode 100644
index 000000000..a213e39e2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86DGA.c
@@ -0,0 +1,1267 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86DGA.c,v 1.7 2005/11/08 03:12:43 alanc Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86DGA.c,v 1.46 2002/12/03 18:17:40 tsi Exp $ */
+/*
+ * Copyright (c) 1998-2002 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ *
+ * Written by Mark Vojkovich
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86str.h"
+#include "xf86Priv.h"
+#include "dgaproc.h"
+#include <X11/extensions/xf86dgastr.h>
+#include "colormapst.h"
+#include "pixmapstr.h"
+#include "inputstr.h"
+#include "globals.h"
+#include "servermd.h"
+#include "micmap.h"
+#ifdef XKB
+#include <X11/extensions/XKBsrv.h>
+#endif
+#include "xf86Xinput.h"
+
+static unsigned long DGAGeneration = 0;
+static int DGAScreenIndex = -1;
+
+static Bool DGACloseScreen(int i, ScreenPtr pScreen);
+static void DGADestroyColormap(ColormapPtr pmap);
+static void DGAInstallColormap(ColormapPtr pmap);
+static void DGAUninstallColormap(ColormapPtr pmap);
+
+static void
+DGACopyModeInfo(
+ DGAModePtr mode,
+ XDGAModePtr xmode
+);
+
+#if defined(XFree86LOADER) || !defined(XFreeXDGA)
+int *XDGAEventBase = NULL;
+#else
+int *XDGAEventBase = &DGAEventBase;
+#endif
+
+#define DGA_GET_SCREEN_PRIV(pScreen) \
+ ((DGAScreenPtr)((pScreen)->devPrivates[DGAScreenIndex].ptr))
+
+
+typedef struct _FakedVisualList{
+ Bool free;
+ VisualPtr pVisual;
+ struct _FakedVisualList *next;
+} FakedVisualList;
+
+
+typedef struct {
+ ScrnInfoPtr pScrn;
+ int numModes;
+ DGAModePtr modes;
+ CloseScreenProcPtr CloseScreen;
+ DestroyColormapProcPtr DestroyColormap;
+ InstallColormapProcPtr InstallColormap;
+ UninstallColormapProcPtr UninstallColormap;
+ DGADevicePtr current;
+ DGAFunctionPtr funcs;
+ int input;
+ ClientPtr client;
+ int pixmapMode;
+ FakedVisualList *fakedVisuals;
+ ColormapPtr dgaColormap;
+ ColormapPtr savedColormap;
+ Bool grabMouse;
+ Bool grabKeyboard;
+} DGAScreenRec, *DGAScreenPtr;
+
+
+Bool
+DGAInit(
+ ScreenPtr pScreen,
+ DGAFunctionPtr funcs,
+ DGAModePtr modes,
+ int num
+){
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ DGAScreenPtr pScreenPriv;
+ int i;
+
+ if(!funcs || !funcs->SetMode || !funcs->OpenFramebuffer)
+ return FALSE;
+
+ if(!modes || num <= 0)
+ return FALSE;
+
+ if(DGAGeneration != serverGeneration) {
+ if((DGAScreenIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+ DGAGeneration = serverGeneration;
+ }
+
+ if(!(pScreenPriv = (DGAScreenPtr)xalloc(sizeof(DGAScreenRec))))
+ return FALSE;
+
+ pScreenPriv->pScrn = pScrn;
+ pScreenPriv->numModes = num;
+ pScreenPriv->modes = modes;
+ pScreenPriv->current = NULL;
+
+ pScreenPriv->funcs = funcs;
+ pScreenPriv->input = 0;
+ pScreenPriv->client = NULL;
+ pScreenPriv->fakedVisuals = NULL;
+ pScreenPriv->dgaColormap = NULL;
+ pScreenPriv->savedColormap = NULL;
+ pScreenPriv->grabMouse = FALSE;
+ pScreenPriv->grabKeyboard = FALSE;
+
+ for(i = 0; i < num; i++)
+ modes[i].num = i + 1;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ for(i = 0; i < num; i++)
+ modes[i].flags &= ~DGA_PIXMAP_AVAILABLE;
+#endif
+
+
+ pScreen->devPrivates[DGAScreenIndex].ptr = (pointer)pScreenPriv;
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = DGACloseScreen;
+ pScreenPriv->DestroyColormap = pScreen->DestroyColormap;
+ pScreen->DestroyColormap = DGADestroyColormap;
+ pScreenPriv->InstallColormap = pScreen->InstallColormap;
+ pScreen->InstallColormap = DGAInstallColormap;
+ pScreenPriv->UninstallColormap = pScreen->UninstallColormap;
+ pScreen->UninstallColormap = DGAUninstallColormap;
+
+ /*
+ * This is now set in InitOutput().
+ *
+ pScrn->SetDGAMode = xf86SetDGAMode;
+ */
+
+ return TRUE;
+}
+
+/* DGAReInitModes allows the driver to re-initialize
+ * the DGA mode list.
+ */
+
+Bool
+DGAReInitModes(
+ ScreenPtr pScreen,
+ DGAModePtr modes,
+ int num
+){
+ DGAScreenPtr pScreenPriv;
+ int i;
+
+ /* No DGA? Ignore call (but don't make it look like it failed) */
+ if(DGAScreenIndex < 0)
+ return TRUE;
+
+ pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+
+ /* Same as above */
+ if(!pScreenPriv)
+ return TRUE;
+
+ /* Can't do this while DGA is active */
+ if(pScreenPriv->current)
+ return FALSE;
+
+ /* Quick sanity check */
+ if(!num)
+ modes = NULL;
+ else if(!modes)
+ num = 0;
+
+ pScreenPriv->numModes = num;
+ pScreenPriv->modes = modes;
+
+ /* This practically disables DGA. So be it. */
+ if(!num)
+ return TRUE;
+
+ for(i = 0; i < num; i++)
+ modes[i].num = i + 1;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ for(i = 0; i < num; i++)
+ modes[i].flags &= ~DGA_PIXMAP_AVAILABLE;
+#endif
+
+ return TRUE;
+}
+
+static void
+FreeMarkedVisuals(ScreenPtr pScreen)
+{
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+ FakedVisualList *prev, *curr, *tmp;
+
+ if(!pScreenPriv->fakedVisuals)
+ return;
+
+ prev = NULL;
+ curr = pScreenPriv->fakedVisuals;
+
+ while(curr) {
+ if(curr->free) {
+ tmp = curr;
+ curr = curr->next;
+ if(prev)
+ prev->next = curr;
+ else
+ pScreenPriv->fakedVisuals = curr;
+ xfree(tmp->pVisual);
+ xfree(tmp);
+ } else {
+ prev = curr;
+ curr = curr->next;
+ }
+ }
+}
+
+
+static Bool
+DGACloseScreen(int i, ScreenPtr pScreen)
+{
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+
+ FreeMarkedVisuals(pScreen);
+
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+ pScreen->DestroyColormap = pScreenPriv->DestroyColormap;
+ pScreen->InstallColormap = pScreenPriv->InstallColormap;
+ pScreen->UninstallColormap = pScreenPriv->UninstallColormap;
+
+ /* DGAShutdown() should have ensured that no DGA
+ screen were active by here */
+
+ xfree(pScreenPriv);
+
+ return((*pScreen->CloseScreen)(i, pScreen));
+}
+
+
+static void
+DGADestroyColormap(ColormapPtr pmap)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+ VisualPtr pVisual = pmap->pVisual;
+
+ if(pScreenPriv->fakedVisuals) {
+ FakedVisualList *curr = pScreenPriv->fakedVisuals;
+
+ while(curr) {
+ if(curr->pVisual == pVisual) {
+ /* We can't get rid of them yet since FreeColormap
+ still needs the pVisual during the cleanup */
+ curr->free = TRUE;
+ break;
+ }
+ curr = curr->next;
+ }
+ }
+
+ if(pScreenPriv->DestroyColormap) {
+ pScreen->DestroyColormap = pScreenPriv->DestroyColormap;
+ (*pScreen->DestroyColormap)(pmap);
+ pScreen->DestroyColormap = DGADestroyColormap;
+ }
+}
+
+
+static void
+DGAInstallColormap(ColormapPtr pmap)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+
+ if(pScreenPriv->current && pScreenPriv->dgaColormap) {
+ if (pmap != pScreenPriv->dgaColormap) {
+ pScreenPriv->savedColormap = pmap;
+ pmap = pScreenPriv->dgaColormap;
+ }
+ }
+
+ pScreen->InstallColormap = pScreenPriv->InstallColormap;
+ (*pScreen->InstallColormap)(pmap);
+ pScreen->InstallColormap = DGAInstallColormap;
+}
+
+static void
+DGAUninstallColormap(ColormapPtr pmap)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+
+ if(pScreenPriv->current && pScreenPriv->dgaColormap) {
+ if (pmap == pScreenPriv->dgaColormap) {
+ pScreenPriv->dgaColormap = NULL;
+ }
+ }
+
+ pScreen->UninstallColormap = pScreenPriv->UninstallColormap;
+ (*pScreen->UninstallColormap)(pmap);
+ pScreen->UninstallColormap = DGAUninstallColormap;
+}
+
+int
+xf86SetDGAMode(
+ int index,
+ int num,
+ DGADevicePtr devRet
+){
+ ScreenPtr pScreen = screenInfo.screens[index];
+ DGAScreenPtr pScreenPriv;
+ ScrnInfoPtr pScrn;
+ DGADevicePtr device;
+ PixmapPtr pPix = NULL;
+ DGAModePtr pMode = NULL;
+
+ /* First check if DGAInit was successful on this screen */
+ if (DGAScreenIndex < 0)
+ return BadValue;
+ pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+ if (!pScreenPriv)
+ return BadValue;
+ pScrn = pScreenPriv->pScrn;
+
+ if(!num) {
+ if(pScreenPriv->current) {
+ PixmapPtr oldPix = pScreenPriv->current->pPix;
+ if(oldPix) {
+ if(oldPix->drawable.id)
+ FreeResource(oldPix->drawable.id, RT_NONE);
+ else
+ (*pScreen->DestroyPixmap)(oldPix);
+ }
+ xfree(pScreenPriv->current);
+ pScreenPriv->current = NULL;
+ pScrn->vtSema = TRUE;
+ (*pScreenPriv->funcs->SetMode)(pScrn, NULL);
+ if(pScreenPriv->savedColormap) {
+ (*pScreen->InstallColormap)(pScreenPriv->savedColormap);
+ pScreenPriv->savedColormap = NULL;
+ }
+ pScreenPriv->dgaColormap = NULL;
+ (*pScrn->EnableDisableFBAccess)(index, TRUE);
+
+ FreeMarkedVisuals(pScreen);
+ }
+
+ pScreenPriv->grabMouse = FALSE;
+ pScreenPriv->grabKeyboard = FALSE;
+
+ return Success;
+ }
+
+ if(!pScrn->vtSema && !pScreenPriv->current) /* Really switched away */
+ return BadAlloc;
+
+ if((num > 0) && (num <= pScreenPriv->numModes))
+ pMode = &(pScreenPriv->modes[num - 1]);
+ else
+ return BadValue;
+
+ if(!(device = (DGADevicePtr)xalloc(sizeof(DGADeviceRec))))
+ return BadAlloc;
+
+ if(!pScreenPriv->current) {
+ Bool oldVTSema = pScrn->vtSema;
+
+ pScrn->vtSema = FALSE; /* kludge until we rewrite VT switching */
+ (*pScrn->EnableDisableFBAccess)(index, FALSE);
+ pScrn->vtSema = oldVTSema;
+ }
+
+ if(!(*pScreenPriv->funcs->SetMode)(pScrn, pMode)) {
+ xfree(device);
+ return BadAlloc;
+ }
+
+ pScrn->currentMode = pMode->mode;
+
+ if(!pScreenPriv->current && !pScreenPriv->input) {
+ /* if it's multihead we need to warp the cursor off of
+ our screen so it doesn't get trapped */
+ }
+
+ pScrn->vtSema = FALSE;
+
+ if(pScreenPriv->current) {
+ PixmapPtr oldPix = pScreenPriv->current->pPix;
+ if(oldPix) {
+ if(oldPix->drawable.id)
+ FreeResource(oldPix->drawable.id, RT_NONE);
+ else
+ (*pScreen->DestroyPixmap)(oldPix);
+ }
+ xfree(pScreenPriv->current);
+ pScreenPriv->current = NULL;
+ }
+
+ if(pMode->flags & DGA_PIXMAP_AVAILABLE) {
+ if((pPix = (*pScreen->CreatePixmap)(pScreen, 0, 0, pMode->depth))) {
+ (*pScreen->ModifyPixmapHeader)(pPix,
+ pMode->pixmapWidth, pMode->pixmapHeight,
+ pMode->depth, pMode->bitsPerPixel,
+ pMode->bytesPerScanline,
+ (pointer)(pMode->address));
+ }
+ }
+
+ devRet->mode = device->mode = pMode;
+ devRet->pPix = device->pPix = pPix;
+ pScreenPriv->current = device;
+ pScreenPriv->pixmapMode = FALSE;
+ pScreenPriv->grabMouse = TRUE;
+ pScreenPriv->grabKeyboard = TRUE;
+
+ return Success;
+}
+
+
+
+/*********** exported ones ***************/
+
+void
+DGASetInputMode(int index, Bool keyboard, Bool mouse)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+
+ if (pScreenPriv)
+ {
+ pScreenPriv->grabMouse = mouse;
+ pScreenPriv->grabKeyboard = keyboard;
+ }
+}
+
+Bool
+DGAChangePixmapMode(int index, int *x, int *y, int mode)
+{
+ DGAScreenPtr pScreenPriv;
+ DGADevicePtr pDev;
+ DGAModePtr pMode;
+ PixmapPtr pPix;
+
+ if(DGAScreenIndex < 0)
+ return FALSE;
+
+ pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ if(!pScreenPriv || !pScreenPriv->current || !pScreenPriv->current->pPix)
+ return FALSE;
+
+ pDev = pScreenPriv->current;
+ pPix = pDev->pPix;
+ pMode = pDev->mode;
+
+ if(mode) {
+ int shift = 2;
+
+ if(*x > (pMode->pixmapWidth - pMode->viewportWidth))
+ *x = pMode->pixmapWidth - pMode->viewportWidth;
+ if(*y > (pMode->pixmapHeight - pMode->viewportHeight))
+ *y = pMode->pixmapHeight - pMode->viewportHeight;
+
+ switch(xf86Screens[index]->bitsPerPixel) {
+ case 16: shift = 1; break;
+ case 32: shift = 0; break;
+ default: break;
+ }
+
+ if(BITMAP_SCANLINE_PAD == 64)
+ shift++;
+
+ *x = (*x >> shift) << shift;
+
+ pPix->drawable.x = *x;
+ pPix->drawable.y = *y;
+ pPix->drawable.width = pMode->viewportWidth;
+ pPix->drawable.height = pMode->viewportHeight;
+ } else {
+ pPix->drawable.x = 0;
+ pPix->drawable.y = 0;
+ pPix->drawable.width = pMode->pixmapWidth;
+ pPix->drawable.height = pMode->pixmapHeight;
+ }
+ pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pScreenPriv->pixmapMode = mode;
+
+ return TRUE;
+}
+
+Bool
+DGAAvailable(int index)
+{
+ if(DGAScreenIndex < 0)
+ return FALSE;
+
+ if (!xf86NoSharedResources(((ScrnInfoPtr)screenInfo.screens[index]->
+ devPrivates[xf86ScreenIndex].ptr)->scrnIndex,MEM))
+ return FALSE;
+
+ if(DGA_GET_SCREEN_PRIV(screenInfo.screens[index]))
+ return TRUE;
+
+ return FALSE;
+}
+
+Bool
+DGAActive(int index)
+{
+ DGAScreenPtr pScreenPriv;
+
+ if(DGAScreenIndex < 0)
+ return FALSE;
+
+ pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ if(pScreenPriv && pScreenPriv->current)
+ return TRUE;
+
+ return FALSE;
+}
+
+
+
+/* Called by the event code in case the server is abruptly terminated */
+
+void
+DGAShutdown()
+{
+ ScrnInfoPtr pScrn;
+ int i;
+
+ if(DGAScreenIndex < 0)
+ return;
+
+ for(i = 0; i < screenInfo.numScreens; i++) {
+ pScrn = xf86Screens[i];
+
+ (void)(*pScrn->SetDGAMode)(pScrn->scrnIndex, 0, NULL);
+ }
+}
+
+/* Called by the extension to initialize a mode */
+
+int
+DGASetMode(
+ int index,
+ int num,
+ XDGAModePtr mode,
+ PixmapPtr *pPix
+){
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ DGADeviceRec device;
+ int ret;
+
+ /* We rely on the extension to check that DGA is available */
+
+ ret = (*pScrn->SetDGAMode)(index, num, &device);
+ if((ret == Success) && num) {
+ DGACopyModeInfo(device.mode, mode);
+ *pPix = device.pPix;
+ }
+
+ return ret;
+}
+
+/* Called from the extension to let the DDX know which events are requested */
+
+void
+DGASelectInput(
+ int index,
+ ClientPtr client,
+ long mask
+){
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ /* We rely on the extension to check that DGA is available */
+ pScreenPriv->client = client;
+ pScreenPriv->input = mask;
+}
+
+int
+DGAGetViewportStatus(int index)
+{
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ /* We rely on the extension to check that DGA is active */
+
+ if (!pScreenPriv->funcs->GetViewport)
+ return 0;
+
+ return (*pScreenPriv->funcs->GetViewport)(pScreenPriv->pScrn);
+}
+
+int
+DGASetViewport(
+ int index,
+ int x, int y,
+ int mode
+){
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ if (pScreenPriv->funcs->SetViewport)
+ (*pScreenPriv->funcs->SetViewport)(pScreenPriv->pScrn, x, y, mode);
+ return Success;
+}
+
+
+static int
+BitsClear(CARD32 data)
+{
+ int bits = 0;
+ CARD32 mask;
+
+ for(mask = 1; mask; mask <<= 1) {
+ if(!(data & mask)) bits++;
+ else break;
+ }
+
+ return bits;
+}
+
+int
+DGACreateColormap(int index, ClientPtr client, int id, int mode, int alloc)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+ FakedVisualList *fvlp;
+ VisualPtr pVisual;
+ DGAModePtr pMode;
+ ColormapPtr pmap;
+
+ if(!mode || (mode > pScreenPriv->numModes))
+ return BadValue;
+
+ if((alloc != AllocNone) && (alloc != AllocAll))
+ return BadValue;
+
+ pMode = &(pScreenPriv->modes[mode - 1]);
+
+ if(!(pVisual = xalloc(sizeof(VisualRec))))
+ return BadAlloc;
+
+ pVisual->vid = FakeClientID(0);
+ pVisual->class = pMode->visualClass;
+ pVisual->nplanes = pMode->depth;
+ pVisual->ColormapEntries = 1 << pMode->depth;
+ pVisual->bitsPerRGBValue = (pMode->depth + 2) / 3;
+
+ switch (pVisual->class) {
+ case PseudoColor:
+ case GrayScale:
+ case StaticGray:
+ pVisual->bitsPerRGBValue = 8; /* not quite */
+ pVisual->redMask = 0;
+ pVisual->greenMask = 0;
+ pVisual->blueMask = 0;
+ pVisual->offsetRed = 0;
+ pVisual->offsetGreen = 0;
+ pVisual->offsetBlue = 0;
+ break;
+ case DirectColor:
+ case TrueColor:
+ pVisual->ColormapEntries = 1 << pVisual->bitsPerRGBValue;
+ /* fall through */
+ case StaticColor:
+ pVisual->redMask = pMode->red_mask;
+ pVisual->greenMask = pMode->green_mask;
+ pVisual->blueMask = pMode->blue_mask;
+ pVisual->offsetRed = BitsClear(pVisual->redMask);
+ pVisual->offsetGreen = BitsClear(pVisual->greenMask);
+ pVisual->offsetBlue = BitsClear(pVisual->blueMask);
+ }
+
+ if(!(fvlp = xalloc(sizeof(FakedVisualList)))) {
+ xfree(pVisual);
+ return BadAlloc;
+ }
+
+ fvlp->free = FALSE;
+ fvlp->pVisual = pVisual;
+ fvlp->next = pScreenPriv->fakedVisuals;
+ pScreenPriv->fakedVisuals = fvlp;
+
+ LEGAL_NEW_RESOURCE(id, client);
+
+ return CreateColormap(id, pScreen, pVisual, &pmap, alloc, client->index);
+}
+
+/* Called by the extension to install a colormap on DGA active screens */
+
+void
+DGAInstallCmap(ColormapPtr cmap)
+{
+ ScreenPtr pScreen = cmap->pScreen;
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+
+ /* We rely on the extension to check that DGA is active */
+
+ if(!pScreenPriv->dgaColormap)
+ pScreenPriv->savedColormap = miInstalledMaps[pScreen->myNum];
+
+ pScreenPriv->dgaColormap = cmap;
+
+ (*pScreen->InstallColormap)(cmap);
+}
+
+int
+DGASync(int index)
+{
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ /* We rely on the extension to check that DGA is active */
+
+ if (pScreenPriv->funcs->Sync)
+ (*pScreenPriv->funcs->Sync)(pScreenPriv->pScrn);
+
+ return Success;
+}
+
+int
+DGAFillRect(
+ int index,
+ int x, int y, int w, int h,
+ unsigned long color
+){
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ /* We rely on the extension to check that DGA is active */
+
+ if(pScreenPriv->funcs->FillRect &&
+ (pScreenPriv->current->mode->flags & DGA_FILL_RECT)) {
+
+ (*pScreenPriv->funcs->FillRect)(pScreenPriv->pScrn, x, y, w, h, color);
+ return Success;
+ }
+ return BadMatch;
+}
+
+int
+DGABlitRect(
+ int index,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty
+){
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ /* We rely on the extension to check that DGA is active */
+
+ if(pScreenPriv->funcs->BlitRect &&
+ (pScreenPriv->current->mode->flags & DGA_BLIT_RECT)) {
+
+ (*pScreenPriv->funcs->BlitRect)(pScreenPriv->pScrn,
+ srcx, srcy, w, h, dstx, dsty);
+ return Success;
+ }
+ return BadMatch;
+}
+
+int
+DGABlitTransRect(
+ int index,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty,
+ unsigned long color
+){
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ /* We rely on the extension to check that DGA is active */
+
+ if(pScreenPriv->funcs->BlitTransRect &&
+ (pScreenPriv->current->mode->flags & DGA_BLIT_RECT_TRANS)) {
+
+ (*pScreenPriv->funcs->BlitTransRect)(pScreenPriv->pScrn,
+ srcx, srcy, w, h, dstx, dsty, color);
+ return Success;
+ }
+ return BadMatch;
+}
+
+
+int
+DGAGetModes(int index)
+{
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+ /* We rely on the extension to check that DGA is available */
+
+ return pScreenPriv->numModes;
+}
+
+
+int
+DGAGetModeInfo(
+ int index,
+ XDGAModePtr mode,
+ int num
+){
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+ /* We rely on the extension to check that DGA is available */
+
+ if((num <= 0) || (num > pScreenPriv->numModes))
+ return BadValue;
+
+ DGACopyModeInfo(&(pScreenPriv->modes[num - 1]), mode);
+
+ return Success;
+}
+
+
+static void
+DGACopyModeInfo(
+ DGAModePtr mode,
+ XDGAModePtr xmode
+){
+ DisplayModePtr dmode = mode->mode;
+
+ xmode->num = mode->num;
+ xmode->name = dmode->name;
+ xmode->VSync_num = (int)(dmode->VRefresh * 1000.0);
+ xmode->VSync_den = 1000;
+ xmode->flags = mode->flags;
+ xmode->imageWidth = mode->imageWidth;
+ xmode->imageHeight = mode->imageHeight;
+ xmode->pixmapWidth = mode->pixmapWidth;
+ xmode->pixmapHeight = mode->pixmapHeight;
+ xmode->bytesPerScanline = mode->bytesPerScanline;
+ xmode->byteOrder = mode->byteOrder;
+ xmode->depth = mode->depth;
+ xmode->bitsPerPixel = mode->bitsPerPixel;
+ xmode->red_mask = mode->red_mask;
+ xmode->green_mask = mode->green_mask;
+ xmode->blue_mask = mode->blue_mask;
+ xmode->visualClass = mode->visualClass;
+ xmode->viewportWidth = mode->viewportWidth;
+ xmode->viewportHeight = mode->viewportHeight;
+ xmode->xViewportStep = mode->xViewportStep;
+ xmode->yViewportStep = mode->yViewportStep;
+ xmode->maxViewportX = mode->maxViewportX;
+ xmode->maxViewportY = mode->maxViewportY;
+ xmode->viewportFlags = mode->viewportFlags;
+ xmode->reserved1 = mode->reserved1;
+ xmode->reserved2 = mode->reserved2;
+ xmode->offset = mode->offset;
+
+ if(dmode->Flags & V_INTERLACE) xmode->flags |= DGA_INTERLACED;
+ if(dmode->Flags & V_DBLSCAN) xmode->flags |= DGA_DOUBLESCAN;
+}
+
+
+Bool
+DGAVTSwitch(void)
+{
+ ScreenPtr pScreen;
+ int i;
+
+ for(i = 0; i < screenInfo.numScreens; i++) {
+ pScreen = screenInfo.screens[i];
+
+ /* Alternatively, this could send events to DGA clients */
+
+ if(DGAScreenIndex >= 0) {
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+
+ if(pScreenPriv && pScreenPriv->current)
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+
+/* We have the power to steal or modify events that are about to get queued */
+
+Bool
+DGAStealKeyEvent(int index, xEvent *e)
+{
+ DGAScreenPtr pScreenPriv;
+ dgaEvent de;
+
+ if(DGAScreenIndex < 0) /* no DGA */
+ return FALSE;
+
+ pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ if(!pScreenPriv || !pScreenPriv->grabKeyboard) /* no direct mode */
+ return FALSE;
+
+ de.u.u.type = e->u.u.type + *XDGAEventBase;
+ de.u.u.detail = e->u.u.detail;
+ de.u.event.time = e->u.keyButtonPointer.time;
+ xf86eqEnqueue ((xEvent *) &de);
+ return TRUE;
+}
+
+static int DGAMouseX, DGAMouseY;
+
+Bool
+DGAStealMouseEvent(int index, xEvent *e, int dx, int dy)
+{
+ DGAScreenPtr pScreenPriv;
+ dgaEvent de;
+
+ if(DGAScreenIndex < 0) /* no DGA */
+ return FALSE;
+
+ pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ if(!pScreenPriv || !pScreenPriv->grabMouse) /* no direct mode */
+ return FALSE;
+
+ DGAMouseX += dx;
+ if (DGAMouseX < 0)
+ DGAMouseX = 0;
+ else if (DGAMouseX > screenInfo.screens[index]->width)
+ DGAMouseX = screenInfo.screens[index]->width;
+ DGAMouseY += dy;
+ if (DGAMouseY < 0)
+ DGAMouseY = 0;
+ else if (DGAMouseY > screenInfo.screens[index]->height)
+ DGAMouseY = screenInfo.screens[index]->height;
+ de.u.u.type = e->u.u.type + *XDGAEventBase;
+ de.u.u.detail = e->u.u.detail;
+ de.u.event.time = e->u.keyButtonPointer.time;
+ de.u.event.dx = dx;
+ de.u.event.dy = dy;
+ de.u.event.pad1 = DGAMouseX;
+ de.u.event.pad2 = DGAMouseY;
+ xf86eqEnqueue ((xEvent *) &de);
+ return TRUE;
+}
+
+Bool
+DGAIsDgaEvent (xEvent *e)
+{
+ int coreEquiv;
+ if (DGAScreenIndex < 0 || XDGAEventBase == 0)
+ return FALSE;
+ coreEquiv = e->u.u.type - *XDGAEventBase;
+ if (KeyPress <= coreEquiv && coreEquiv <= MotionNotify)
+ return TRUE;
+ return FALSE;
+}
+
+#define NoSuchEvent 0x80000000 /* so doesn't match NoEventMask */
+static Mask filters[] =
+{
+ NoSuchEvent, /* 0 */
+ NoSuchEvent, /* 1 */
+ KeyPressMask, /* KeyPress */
+ KeyReleaseMask, /* KeyRelease */
+ ButtonPressMask, /* ButtonPress */
+ ButtonReleaseMask, /* ButtonRelease */
+ PointerMotionMask, /* MotionNotify (initial state) */
+};
+
+static void
+DGAProcessKeyboardEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr keybd)
+{
+ int key, bit;
+ register BYTE *kptr;
+ register int i;
+ register CARD8 modifiers;
+ register CARD16 mask;
+ int coreEquiv;
+ xEvent core;
+ KeyClassPtr keyc = keybd->key;
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+
+ coreEquiv = de->u.u.type - *XDGAEventBase;
+
+ /*
+ * Fill in remaining event state
+ */
+ de->u.event.dx = 0;
+ de->u.event.dy = 0;
+ de->u.event.screen = pScreen->myNum;
+ de->u.event.state = keyc->state | (inputInfo.pointer)->button->state;
+
+ /*
+ * Keep the core state in sync by duplicating what
+ * CoreProcessKeyboardEvent does
+ */
+ key = de->u.u.detail;
+ kptr = &keyc->down[key >> 3];
+ bit = 1 << (key & 7);
+ modifiers = keyc->modifierMap[key];
+ switch (coreEquiv)
+ {
+ case KeyPress:
+ inputInfo.pointer->valuator->motionHintWindow = NullWindow;
+ *kptr |= bit;
+ keyc->prev_state = keyc->state;
+#ifdef XKB
+ if (noXkbExtension)
+#endif
+ {
+
+ for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
+ {
+ if (mask & modifiers)
+ {
+ /* This key affects modifier "i" */
+ keyc->modifierKeyCount[i]++;
+ keyc->state |= mask;
+ modifiers &= ~mask;
+ }
+ }
+ }
+ break;
+ case KeyRelease:
+ inputInfo.pointer->valuator->motionHintWindow = NullWindow;
+ *kptr &= ~bit;
+ keyc->prev_state = keyc->state;
+#ifdef XKB
+ if (noXkbExtension)
+#endif
+ {
+ for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
+ {
+ if (mask & modifiers) {
+ /* This key affects modifier "i" */
+ if (--keyc->modifierKeyCount[i] <= 0) {
+ keyc->state &= ~mask;
+ keyc->modifierKeyCount[i] = 0;
+ }
+ modifiers &= ~mask;
+ }
+ }
+ }
+ break;
+ }
+ /*
+ * Deliver the DGA event
+ */
+ if (pScreenPriv->client)
+ {
+ /* If the DGA client has selected input, then deliver based on the usual filter */
+ TryClientEvents (pScreenPriv->client, (xEvent *) de, 1,
+ filters[coreEquiv], pScreenPriv->input, 0);
+ }
+ else
+ {
+ /* If the keyboard is actively grabbed, deliver a grabbed core event */
+ if (keybd->grab && !keybd->fromPassiveGrab)
+ {
+ core.u.u.type = coreEquiv;
+ core.u.u.detail = de->u.u.detail;
+ core.u.keyButtonPointer.time = de->u.event.time;
+ core.u.keyButtonPointer.eventX = de->u.event.dx;
+ core.u.keyButtonPointer.eventY = de->u.event.dy;
+ core.u.keyButtonPointer.rootX = de->u.event.dx;
+ core.u.keyButtonPointer.rootY = de->u.event.dy;
+ core.u.keyButtonPointer.state = de->u.event.state;
+ DeliverGrabbedEvent (&core, keybd, FALSE, 1);
+ }
+ }
+}
+
+static void
+DGAProcessPointerEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr mouse)
+{
+ ButtonClassPtr butc = mouse->button;
+ int coreEquiv;
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+ xEvent core;
+
+ coreEquiv = de->u.u.type - *XDGAEventBase;
+ /*
+ * Fill in remaining event state
+ */
+ de->u.event.screen = pScreen->myNum;
+ de->u.event.state = butc->state | inputInfo.keyboard->key->state;
+ /*
+ * Keep the core state in sync by duplicating what
+ * CoreProcessPointerEvent does
+ */
+ if (coreEquiv != MotionNotify)
+ {
+ register int key;
+ register BYTE *kptr;
+ int bit;
+
+ key = de->u.u.detail;
+ kptr = &butc->down[key >> 3];
+ bit = 1 << (key & 7);
+ switch (coreEquiv)
+ {
+ case ButtonPress:
+ mouse->valuator->motionHintWindow = NullWindow;
+ if (!(*kptr & bit))
+ butc->buttonsDown++;
+ butc->motionMask = ButtonMotionMask;
+ *kptr |= bit;
+ if (key <= 5)
+ butc->state |= (Button1Mask >> 1) << key;
+ break;
+ case ButtonRelease:
+ mouse->valuator->motionHintWindow = NullWindow;
+ if (*kptr & bit)
+ --butc->buttonsDown;
+ if (!butc->buttonsDown)
+ butc->motionMask = 0;
+ *kptr &= ~bit;
+ if (key == 0)
+ return;
+ if (key <= 5)
+ butc->state &= ~((Button1Mask >> 1) << key);
+ break;
+ }
+ }
+ /*
+ * Deliver the DGA event
+ */
+ if (pScreenPriv->client)
+ {
+ /* If the DGA client has selected input, then deliver based on the usual filter */
+ TryClientEvents (pScreenPriv->client, (xEvent *) de, 1,
+ filters[coreEquiv], pScreenPriv->input, 0);
+ }
+ else
+ {
+ /* If the pointer is actively grabbed, deliver a grabbed core event */
+ if (mouse->grab && !mouse->fromPassiveGrab)
+ {
+ core.u.u.type = coreEquiv;
+ core.u.u.detail = de->u.u.detail;
+ core.u.keyButtonPointer.time = de->u.event.time;
+ core.u.keyButtonPointer.eventX = de->u.event.dx;
+ core.u.keyButtonPointer.eventY = de->u.event.dy;
+ core.u.keyButtonPointer.rootX = de->u.event.dx;
+ core.u.keyButtonPointer.rootY = de->u.event.dy;
+ core.u.keyButtonPointer.state = de->u.event.state;
+ DeliverGrabbedEvent (&core, mouse, FALSE, 1);
+ }
+ }
+}
+
+Bool
+DGADeliverEvent (ScreenPtr pScreen, xEvent *e)
+{
+ dgaEvent *de = (dgaEvent *) e;
+ DGAScreenPtr pScreenPriv;
+ int coreEquiv;
+
+ /* no DGA */
+ if (DGAScreenIndex < 0 || XDGAEventBase == 0)
+ return FALSE;
+ pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+
+ /* DGA not initialized on this screen */
+ if (!pScreenPriv)
+ return FALSE;
+
+ coreEquiv = de->u.u.type - *XDGAEventBase;
+ /* Not a DGA event */
+ if (coreEquiv < KeyPress || coreEquiv > MotionNotify)
+ return FALSE;
+
+ switch (coreEquiv) {
+ case KeyPress:
+ case KeyRelease:
+ DGAProcessKeyboardEvent (pScreen, de, inputInfo.keyboard);
+ break;
+ default:
+ DGAProcessPointerEvent (pScreen, de, inputInfo.pointer);
+ break;
+ }
+ return TRUE;
+}
+
+Bool
+DGAOpenFramebuffer(
+ int index,
+ char **name,
+ unsigned char **mem,
+ int *size,
+ int *offset,
+ int *flags
+){
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ /* We rely on the extension to check that DGA is available */
+
+ return (*pScreenPriv->funcs->OpenFramebuffer)(pScreenPriv->pScrn,
+ name, mem, size, offset, flags);
+}
+
+void
+DGACloseFramebuffer(int index)
+{
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+ /* We rely on the extension to check that DGA is available */
+ if(pScreenPriv->funcs->CloseFramebuffer)
+ (*pScreenPriv->funcs->CloseFramebuffer)(pScreenPriv->pScrn);
+}
+
+/* For DGA 1.0 backwards compatibility only */
+
+int
+DGAGetOldDGAMode(int index)
+{
+ DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+ ScrnInfoPtr pScrn = pScreenPriv->pScrn;
+ DGAModePtr mode;
+ int i, w, h, p;
+
+ /* We rely on the extension to check that DGA is available */
+
+ w = pScrn->currentMode->HDisplay;
+ h = pScrn->currentMode->VDisplay;
+ p = ((pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)) + 3) & ~3L;
+
+ for(i = 0; i < pScreenPriv->numModes; i++) {
+ mode = &(pScreenPriv->modes[i]);
+
+ if((mode->viewportWidth == w) && (mode->viewportHeight == h) &&
+ (mode->bytesPerScanline == p) &&
+ (mode->bitsPerPixel == pScrn->bitsPerPixel) &&
+ (mode->depth == pScrn->depth)) {
+
+ return mode->num;
+ }
+ }
+
+ return 0;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86DPMS.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86DPMS.c
new file mode 100644
index 000000000..f02585a0f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86DPMS.c
@@ -0,0 +1,222 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86DPMS.c,v 1.11 2003/11/11 21:02:28 dawes Exp $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86DPMS.c,v 1.8 2005/07/03 08:53:42 daniels Exp $ */
+
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains the DPMS functions required by the extension.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "globals.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#ifdef DPMSExtension
+#define DPMS_SERVER
+#include <X11/extensions/dpms.h>
+#include "dpmsproc.h"
+#endif
+
+
+#ifdef DPMSExtension
+static int DPMSGeneration = 0;
+static int DPMSIndex = -1;
+static Bool DPMSClose(int i, ScreenPtr pScreen);
+static int DPMSCount = 0;
+#endif
+
+
+Bool
+xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)
+{
+#ifdef DPMSExtension
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ DPMSPtr pDPMS;
+ pointer DPMSOpt;
+
+ if (serverGeneration != DPMSGeneration) {
+ if ((DPMSIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+ DPMSGeneration = serverGeneration;
+ }
+
+ if (DPMSDisabledSwitch)
+ DPMSEnabled = FALSE;
+ if (!(pScreen->devPrivates[DPMSIndex].ptr = xcalloc(sizeof(DPMSRec), 1)))
+ return FALSE;
+
+ pDPMS = (DPMSPtr)pScreen->devPrivates[DPMSIndex].ptr;
+ pScrn->DPMSSet = set;
+ pDPMS->Flags = flags;
+ DPMSOpt = xf86FindOption(pScrn->options, "dpms");
+ if (DPMSOpt) {
+ if ((pDPMS->Enabled
+ = xf86SetBoolOption(pScrn->options, "dpms", FALSE))
+ && !DPMSDisabledSwitch)
+ DPMSEnabled = TRUE;
+ xf86MarkOptionUsed(DPMSOpt);
+ xf86DrvMsg(pScreen->myNum, X_CONFIG, "DPMS enabled\n");
+ } else if (DPMSEnabledSwitch) {
+ if (!DPMSDisabledSwitch)
+ DPMSEnabled = TRUE;
+ pDPMS->Enabled = TRUE;
+ }
+ else {
+ pDPMS->Enabled = defaultDPMSEnabled;
+ }
+ pDPMS->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = DPMSClose;
+ DPMSCount++;
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
+
+#ifdef DPMSExtension
+
+static Bool
+DPMSClose(int i, ScreenPtr pScreen)
+{
+ DPMSPtr pDPMS;
+
+ /* This shouldn't happen */
+ if (DPMSIndex < 0)
+ return FALSE;
+
+ pDPMS = (DPMSPtr)pScreen->devPrivates[DPMSIndex].ptr;
+
+ /* This shouldn't happen */
+ if (!pDPMS)
+ return FALSE;
+
+ pScreen->CloseScreen = pDPMS->CloseScreen;
+
+ /*
+ * Turn on DPMS when shutting down. If this function can be used
+ * depends on the order the driver wraps things. If this is called
+ * after the driver has shut down everything the driver will have
+ * to deal with this internally.
+ */
+ if (xf86Screens[i]->vtSema && xf86Screens[i]->DPMSSet) {
+ xf86Screens[i]->DPMSSet(xf86Screens[i],DPMSModeOn,0);
+ }
+
+ xfree((pointer)pDPMS);
+ pScreen->devPrivates[DPMSIndex].ptr = NULL;
+ if (--DPMSCount == 0)
+ DPMSIndex = -1;
+ return pScreen->CloseScreen(i, pScreen);
+}
+
+
+/*
+ * DPMSSet --
+ * Device dependent DPMS mode setting hook. This is called whenever
+ * the DPMS mode is to be changed.
+ */
+void
+DPMSSet(int level)
+{
+ int i;
+ DPMSPtr pDPMS;
+ ScrnInfoPtr pScrn;
+
+ DPMSPowerLevel = level;
+
+ if (DPMSIndex < 0)
+ return;
+
+ if (level != DPMSModeOn)
+ SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverActive);
+
+ /* For each screen, set the DPMS level */
+ for (i = 0; i < xf86NumScreens; i++) {
+ pScrn = xf86Screens[i];
+ pDPMS = (DPMSPtr)screenInfo.screens[i]->devPrivates[DPMSIndex].ptr;
+ if (pDPMS && pScrn->DPMSSet && pDPMS->Enabled && pScrn->vtSema) {
+ xf86EnableAccess(pScrn);
+ pScrn->DPMSSet(pScrn, level, 0);
+ }
+ }
+}
+
+
+/*
+ * DPMSSupported --
+ * Return TRUE if any screen supports DPMS.
+ */
+Bool
+DPMSSupported(void)
+{
+ int i;
+ DPMSPtr pDPMS;
+ ScrnInfoPtr pScrn;
+
+ if (DPMSIndex < 0) {
+ return FALSE;
+ }
+
+ /* For each screen, check if DPMS is supported */
+ for (i = 0; i < xf86NumScreens; i++) {
+ pScrn = xf86Screens[i];
+ pDPMS = (DPMSPtr)screenInfo.screens[i]->devPrivates[DPMSIndex].ptr;
+ if (pDPMS && pScrn->DPMSSet)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+/*
+ * DPMSGet --
+ * Device dependent DPMS mode getting hook. This returns the current
+ * DPMS mode, or -1 if DPMS is not supported.
+ *
+ * This should hook in to the appropriate driver-level function, which
+ * will be added to the ScrnInfoRec.
+ *
+ * NOTES:
+ * 1. the calling interface should be changed to specify which
+ * screen to check.
+ * 2. It isn't clear that this function is ever used or what it should
+ * return.
+ */
+int
+DPMSGet(int *level)
+{
+ return DPMSPowerLevel;
+}
+
+#endif /* DPMSExtension */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Debug.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Debug.c
new file mode 100644
index 000000000..15c267232
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Debug.c
@@ -0,0 +1,197 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Debug.c,v 1.7 2003/09/24 02:43:17 dawes Exp $ */
+
+/*
+ * Copyright (c) 2000-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define I_NEED_OS2_H
+#endif
+
+#include <sys/time.h>
+#include <unistd.h>
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "compiler.h"
+
+void xf86Break1(void)
+{
+}
+
+void xf86Break2(void)
+{
+}
+
+void xf86Break3(void)
+{
+}
+
+char *xf86p8bit[] = { "00000000", "00000001", "00000010", "00000011",
+ "00000100", "00000101", "00000110", "00000111",
+ "00001000", "00001001", "00001010", "00001011",
+ "00001100", "00001101", "00001110", "00001111",
+ "00010000", "00010001", "00010010", "00010011",
+ "00010100", "00010101", "00010110", "00010111",
+ "00011000", "00011001", "00011010", "00011011",
+ "00011100", "00011101", "00011110", "00011111",
+ "00100000", "00100001", "00100010", "00100011",
+ "00100100", "00100101", "00100110", "00100111",
+ "00101000", "00101001", "00101010", "00101011",
+ "00101100", "00101101", "00101110", "00101111",
+ "00110000", "00110001", "00110010", "00110011",
+ "00110100", "00110101", "00110110", "00110111",
+ "00111000", "00111001", "00111010", "00111011",
+ "00111100", "00111101", "00111110", "00111111",
+ "01000000", "01000001", "01000010", "01000011",
+ "01000100", "01000101", "01000110", "01000111",
+ "01001000", "01001001", "01001010", "01001011",
+ "01001100", "01001101", "01001110", "01001111",
+ "01010000", "01010001", "01010010", "01010011",
+ "01010100", "01010101", "01010110", "01010111",
+ "01011000", "01011001", "01011010", "01011011",
+ "01011100", "01011101", "01011110", "01011111",
+ "01100000", "01100001", "01100010", "01100011",
+ "01100100", "01100101", "01100110", "01100111",
+ "01101000", "01101001", "01101010", "01101011",
+ "01101100", "01101101", "01101110", "01101111",
+ "01110000", "01110001", "01110010", "01110011",
+ "01110100", "01110101", "01110110", "01110111",
+ "01111000", "01111001", "01111010", "01111011",
+ "01111100", "01111101", "01111110", "01111111",
+ "10000000", "10000001", "10000010", "10000011",
+ "10000100", "10000101", "10000110", "10000111",
+ "10001000", "10001001", "10001010", "10001011",
+ "10001100", "10001101", "10001110", "10001111",
+ "10010000", "10010001", "10010010", "10010011",
+ "10010100", "10010101", "10010110", "10010111",
+ "10011000", "10011001", "10011010", "10011011",
+ "10011100", "10011101", "10011110", "10011111",
+ "10100000", "10100001", "10100010", "10100011",
+ "10100100", "10100101", "10100110", "10100111",
+ "10101000", "10101001", "10101010", "10101011",
+ "10101100", "10101101", "10101110", "10101111",
+ "10110000", "10110001", "10110010", "10110011",
+ "10110100", "10110101", "10110110", "10110111",
+ "10111000", "10111001", "10111010", "10111011",
+ "10111100", "10111101", "10111110", "10111111",
+ "11000000", "11000001", "11000010", "11000011",
+ "11000100", "11000101", "11000110", "11000111",
+ "11001000", "11001001", "11001010", "11001011",
+ "11001100", "11001101", "11001110", "11001111",
+ "11010000", "11010001", "11010010", "11010011",
+ "11010100", "11010101", "11010110", "11010111",
+ "11011000", "11011001", "11011010", "11011011",
+ "11011100", "11011101", "11011110", "11011111",
+ "11100000", "11100001", "11100010", "11100011",
+ "11100100", "11100101", "11100110", "11100111",
+ "11101000", "11101001", "11101010", "11101011",
+ "11101100", "11101101", "11101110", "11101111",
+ "11110000", "11110001", "11110010", "11110011",
+ "11110100", "11110101", "11110110", "11110111",
+ "11111000", "11111001", "11111010", "11111011",
+ "11111100", "11111101", "11111110", "11111111"
+};
+
+CARD32 xf86DummyVar1;
+CARD32 xf86DummyVar2;
+CARD32 xf86DummyVar3;
+
+CARD8 xf86PeekFb8(CARD8 *p) { return *p; }
+CARD16 xf86PeekFb16(CARD16 *p) { return *p; }
+CARD32 xf86PeekFb32(CARD32 *p) { return *p; }
+void xf86PokeFb8(CARD8 *p, CARD8 v) { *p = v; }
+void xf86PokeFb16(CARD16 *p, CARD16 v) { *p = v; }
+void xf86PokeFb32(CARD16 *p, CARD32 v) { *p = v; }
+
+CARD8 xf86PeekMmio8(pointer Base, unsigned long Offset)
+{
+ return MMIO_IN8(Base,Offset);
+}
+
+CARD16 xf86PeekMmio16(pointer Base, unsigned long Offset)
+{
+ return MMIO_IN16(Base,Offset);
+}
+
+CARD32 xf86PeekMmio32(pointer Base, unsigned long Offset)
+{
+ return MMIO_IN32(Base,Offset);
+}
+
+void xf86PokeMmio8(pointer Base, unsigned long Offset, CARD8 v)
+{
+ MMIO_OUT8(Base,Offset,v);
+}
+
+void xf86PokeMmio16(pointer Base, unsigned long Offset, CARD16 v)
+{
+ MMIO_OUT16(Base,Offset,v);
+}
+
+void xf86PokeMmio32(pointer Base, unsigned long Offset, CARD32 v)
+{
+ MMIO_OUT32(Base,Offset,v);
+}
+
+
+void
+xf86STimestamp(xf86TsPtr* timestamp)
+{
+ if (*timestamp) {
+ gettimeofday((struct timeval*)*timestamp,NULL);
+ } else {
+ *timestamp = xnfalloc(sizeof(xf86TsRec));
+ gettimeofday((struct timeval*)*timestamp,NULL);
+ }
+}
+
+void
+xf86SPTimestamp(xf86TsPtr* timestamp, char *str)
+{
+ if (*timestamp) {
+ long diff;
+ struct timeval ts;
+ ts = **(struct timeval**)timestamp;
+ gettimeofday((struct timeval*)*timestamp,NULL);
+ if (ts.tv_usec > (*timestamp)->usec)
+ diff = ((*timestamp)->sec - ts.tv_sec - 1) * 1000
+ + (ts.tv_usec - (*timestamp)->usec) / 1000;
+ else
+ diff = ((*timestamp)->sec - ts.tv_sec) * 1000
+ +(- ts.tv_usec + (*timestamp)->usec) / 1000;
+ ErrorF("%s Elapsed: %li\n",str,diff);
+ } else {
+ *timestamp = xnfalloc(sizeof(xf86TsRec));
+ gettimeofday((struct timeval*)*timestamp,NULL);
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86DefModes.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86DefModes.c
new file mode 100644
index 000000000..a39d0a212
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86DefModes.c
@@ -0,0 +1,160 @@
+/* $XFree86$ */
+
+/* THIS FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT -- LOOK at
+ * modeline2c.pl */
+
+/*
+ * Copyright 1999-2003 by The XFree86 Project, Inc.
+ *
+ * Author: Dirk Hohndel <hohndel@XFree86.Org>
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define I_NEED_OS2_H
+#endif
+#include "xf86.h"
+#include "xf86Config.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include "globals.h"
+
+#define MODEPREFIX(name) NULL, NULL, name, MODE_OK, M_T_DEFAULT
+#define MODESUFFIX 0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0
+
+DisplayModeRec xf86DefaultModes [] = {
+/* 640x350 @ 85Hz (VESA) hsync: 37.9kHz */
+ {MODEPREFIX("640x350"),31500, 640,672,736,832,0, 350,382,385,445,0, V_PHSYNC | V_NVSYNC, MODESUFFIX},
+ {MODEPREFIX("320x175"),15750, 320,336,368,416,0, 175,191,192,222,0, V_PHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 640x400 @ 85Hz (VESA) hsync: 37.9kHz */
+ {MODEPREFIX("640x400"),31500, 640,672,736,832,0, 400,401,404,445,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("320x200"),15750, 320,336,368,416,0, 200,200,202,222,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 720x400 @ 85Hz (VESA) hsync: 37.9kHz */
+ {MODEPREFIX("720x400"),35500, 720,756,828,936,0, 400,401,404,446,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("360x200"),17750, 360,378,414,468,0, 200,200,202,223,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 640x480 @ 60Hz (Industry standard) hsync: 31.5kHz */
+ {MODEPREFIX("640x480"),25200, 640,656,752,800,0, 480,490,492,525,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
+ {MODEPREFIX("320x240"),12600, 320,328,376,400,0, 240,245,246,262,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 640x480 @ 72Hz (VESA) hsync: 37.9kHz */
+ {MODEPREFIX("640x480"),31500, 640,664,704,832,0, 480,489,491,520,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
+ {MODEPREFIX("320x240"),15750, 320,332,352,416,0, 240,244,245,260,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 640x480 @ 75Hz (VESA) hsync: 37.5kHz */
+ {MODEPREFIX("640x480"),31500, 640,656,720,840,0, 480,481,484,500,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
+ {MODEPREFIX("320x240"),15750, 320,328,360,420,0, 240,240,242,250,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 640x480 @ 85Hz (VESA) hsync: 43.3kHz */
+ {MODEPREFIX("640x480"),36000, 640,696,752,832,0, 480,481,484,509,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
+ {MODEPREFIX("320x240"),18000, 320,348,376,416,0, 240,240,242,254,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 800x600 @ 56Hz (VESA) hsync: 35.2kHz */
+ {MODEPREFIX("800x600"),36000, 800,824,896,1024,0, 600,601,603,625,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("400x300"),18000, 400,412,448,512,0, 300,300,301,312,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 800x600 @ 60Hz (VESA) hsync: 37.9kHz */
+ {MODEPREFIX("800x600"),40000, 800,840,968,1056,0, 600,601,605,628,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("400x300"),20000, 400,420,484,528,0, 300,300,302,314,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 800x600 @ 72Hz (VESA) hsync: 48.1kHz */
+ {MODEPREFIX("800x600"),50000, 800,856,976,1040,0, 600,637,643,666,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("400x300"),25000, 400,428,488,520,0, 300,318,321,333,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 800x600 @ 75Hz (VESA) hsync: 46.9kHz */
+ {MODEPREFIX("800x600"),49500, 800,816,896,1056,0, 600,601,604,625,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("400x300"),24750, 400,408,448,528,0, 300,300,302,312,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 800x600 @ 85Hz (VESA) hsync: 53.7kHz */
+ {MODEPREFIX("800x600"),56300, 800,832,896,1048,0, 600,601,604,631,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("400x300"),28150, 400,416,448,524,0, 300,300,302,315,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1024x768i @ 43Hz (industry standard) hsync: 35.5kHz */
+ {MODEPREFIX("1024x768"),44900, 1024,1032,1208,1264,0, 768,768,776,817,0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX},
+ {MODEPREFIX("512x384"),22450, 512,516,604,632,0, 384,384,388,408,0, V_PHSYNC | V_PVSYNC | V_INTERLACE | V_DBLSCAN, MODESUFFIX},
+/* 1024x768 @ 60Hz (VESA) hsync: 48.4kHz */
+ {MODEPREFIX("1024x768"),65000, 1024,1048,1184,1344,0, 768,771,777,806,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
+ {MODEPREFIX("512x384"),32500, 512,524,592,672,0, 384,385,388,403,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1024x768 @ 70Hz (VESA) hsync: 56.5kHz */
+ {MODEPREFIX("1024x768"),75000, 1024,1048,1184,1328,0, 768,771,777,806,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
+ {MODEPREFIX("512x384"),37500, 512,524,592,664,0, 384,385,388,403,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1024x768 @ 75Hz (VESA) hsync: 60.0kHz */
+ {MODEPREFIX("1024x768"),78800, 1024,1040,1136,1312,0, 768,769,772,800,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("512x384"),39400, 512,520,568,656,0, 384,384,386,400,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1024x768 @ 85Hz (VESA) hsync: 68.7kHz */
+ {MODEPREFIX("1024x768"),94500, 1024,1072,1168,1376,0, 768,769,772,808,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("512x384"),47250, 512,536,584,688,0, 384,384,386,404,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1152x864 @ 75Hz (VESA) hsync: 67.5kHz */
+ {MODEPREFIX("1152x864"),108000, 1152,1216,1344,1600,0, 864,865,868,900,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("576x432"),54000, 576,608,672,800,0, 432,432,434,450,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1280x960 @ 60Hz (VESA) hsync: 60.0kHz */
+ {MODEPREFIX("1280x960"),108000, 1280,1376,1488,1800,0, 960,961,964,1000,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("640x480"),54000, 640,688,744,900,0, 480,480,482,500,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1280x960 @ 85Hz (VESA) hsync: 85.9kHz */
+ {MODEPREFIX("1280x960"),148500, 1280,1344,1504,1728,0, 960,961,964,1011,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("640x480"),74250, 640,672,752,864,0, 480,480,482,505,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1280x1024 @ 60Hz (VESA) hsync: 64.0kHz */
+ {MODEPREFIX("1280x1024"),108000, 1280,1328,1440,1688,0, 1024,1025,1028,1066,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("640x512"),54000, 640,664,720,844,0, 512,512,514,533,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1280x1024 @ 75Hz (VESA) hsync: 80.0kHz */
+ {MODEPREFIX("1280x1024"),135000, 1280,1296,1440,1688,0, 1024,1025,1028,1066,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("640x512"),67500, 640,648,720,844,0, 512,512,514,533,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1280x1024 @ 85Hz (VESA) hsync: 91.1kHz */
+ {MODEPREFIX("1280x1024"),157500, 1280,1344,1504,1728,0, 1024,1025,1028,1072,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("640x512"),78750, 640,672,752,864,0, 512,512,514,536,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1600x1200 @ 60Hz (VESA) hsync: 75.0kHz */
+ {MODEPREFIX("1600x1200"),162000, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("800x600"),81000, 800,832,928,1080,0, 600,600,602,625,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1600x1200 @ 65Hz (VESA) hsync: 81.3kHz */
+ {MODEPREFIX("1600x1200"),175500, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("800x600"),87750, 800,832,928,1080,0, 600,600,602,625,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1600x1200 @ 70Hz (VESA) hsync: 87.5kHz */
+ {MODEPREFIX("1600x1200"),189000, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("800x600"),94500, 800,832,928,1080,0, 600,600,602,625,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1600x1200 @ 75Hz (VESA) hsync: 93.8kHz */
+ {MODEPREFIX("1600x1200"),202500, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("800x600"),101250, 800,832,928,1080,0, 600,600,602,625,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1600x1200 @ 85Hz (VESA) hsync: 106.3kHz */
+ {MODEPREFIX("1600x1200"),229500, 1600,1664,1856,2160,0, 1200,1201,1204,1250,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("800x600"),114750, 800,832,928,1080,0, 600,600,602,625,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1792x1344 @ 60Hz (VESA) hsync: 83.6kHz */
+ {MODEPREFIX("1792x1344"),204800, 1792,1920,2120,2448,0, 1344,1345,1348,1394,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("896x672"),102400, 896,960,1060,1224,0, 672,672,674,697,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1792x1344 @ 75Hz (VESA) hsync: 106.3kHz */
+ {MODEPREFIX("1792x1344"),261000, 1792,1888,2104,2456,0, 1344,1345,1348,1417,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("896x672"),130500, 896,944,1052,1228,0, 672,672,674,708,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1856x1392 @ 60Hz (VESA) hsync: 86.3kHz */
+ {MODEPREFIX("1856x1392"),218300, 1856,1952,2176,2528,0, 1392,1393,1396,1439,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("928x696"),109150, 928,976,1088,1264,0, 696,696,698,719,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1856x1392 @ 75Hz (VESA) hsync: 112.5kHz */
+ {MODEPREFIX("1856x1392"),288000, 1856,1984,2208,2560,0, 1392,1393,1396,1500,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("928x696"),144000, 928,992,1104,1280,0, 696,696,698,750,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1920x1440 @ 60Hz (VESA) hsync: 90.0kHz */
+ {MODEPREFIX("1920x1440"),234000, 1920,2048,2256,2600,0, 1440,1441,1444,1500,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("960x720"),117000, 960,1024,1128,1300,0, 720,720,722,750,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1920x1440 @ 75Hz (VESA) hsync: 112.5kHz */
+ {MODEPREFIX("1920x1440"),297000, 1920,2064,2288,2640,0, 1440,1441,1444,1500,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("960x720"),148500, 960,1032,1144,1320,0, 720,720,722,750,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 832x624 @ 75Hz (74.55Hz) (fix if the official/Apple spec is different) hsync: 49.725kHz */
+ {MODEPREFIX("832x624"),57284, 832,864,928,1152,0, 624,625,628,667,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
+ {MODEPREFIX("416x312"),28642, 416,432,464,576,0, 312,312,314,333,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1152x768 @ 54.8Hz (Titanium PowerBook) hsync: 44.2kHz */
+ {MODEPREFIX("1152x768"),64995, 1152,1178,1314,1472,0, 768,771,777,806,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("576x384"),32497, 576,589,657,736,0, 384,385,388,403,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1400x1050 @ 60Hz (VESA GTF) hsync: 65.5kHz */
+ {MODEPREFIX("1400x1050"),122000, 1400,1488,1640,1880,0, 1050,1052,1064,1082,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("700x525"),61000, 700,744,820,940,0, 525,526,532,541,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1400x1050 @ 75Hz (VESA GTF) hsync: 82.2kHz */
+ {MODEPREFIX("1400x1050"),155800, 1400,1464,1784,1912,0, 1050,1052,1064,1090,0, V_PHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("700x525"),77900, 700,732,892,956,0, 525,526,532,545,0, V_PHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1600x1024 @ 60Hz (SGI 1600SW) hsync: 64.0kHz */
+ {MODEPREFIX("1600x1024"),106910, 1600,1620,1640,1670,0, 1024,1027,1030,1067,0, V_NHSYNC | V_NVSYNC, MODESUFFIX},
+ {MODEPREFIX("800x512"),53455, 800,810,820,835,0, 512,513,515,533,0, V_NHSYNC | V_NVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 1920x1440 @ 85Hz (VESA GTF) hsync: 128.5kHz */
+ {MODEPREFIX("1920x1440"),341350, 1920,2072,2288,2656,0, 1440,1441,1444,1512,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("960x720"),170675, 960,1036,1144,1328,0, 720,720,722,756,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 2048x1536 @ 60Hz (VESA GTF) hsync: 95.3kHz */
+ {MODEPREFIX("2048x1536"),266950, 2048,2200,2424,2800,0, 1536,1537,1540,1589,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("1024x768"),133475, 1024,1100,1212,1400,0, 768,768,770,794,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 2048x1536 @ 75Hz (VESA GTF) hsync: 120.2kHz */
+ {MODEPREFIX("2048x1536"),340480, 2048,2216,2440,2832,0, 1536,1537,1540,1603,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("1024x768"),170240, 1024,1108,1220,1416,0, 768,768,770,801,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+/* 2048x1536 @ 85Hz (VESA GTF) hsync: 137.0kHz */
+ {MODEPREFIX("2048x1536"),388040, 2048,2216,2440,2832,0, 1536,1537,1540,1612,0, V_NHSYNC | V_PVSYNC, MODESUFFIX},
+ {MODEPREFIX("1024x768"),194020, 1024,1108,1220,1416,0, 768,768,770,806,0, V_NHSYNC | V_PVSYNC | V_DBLSCAN, MODESUFFIX},
+ {MODEPREFIX(NULL),0,0,0,0,0,0,0,0,0,0,0,0,MODESUFFIX}
+};
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86DoProbe.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86DoProbe.c
new file mode 100644
index 000000000..2f5b03eb1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86DoProbe.c
@@ -0,0 +1,129 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86DoProbe.c,v 1.14 2003/10/29 04:17:21 dawes Exp $ */
+/*
+ * Copyright (c) 1999-2002 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * finish setting up the server
+ * Load the driver modules and call their probe functions.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "os.h"
+#ifdef XFree86LOADER
+#include "loaderProcs.h"
+#include "xf86Config.h"
+#endif /* XFree86LOADER */
+#include "xf86_OSlib.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+
+void
+DoProbeArgs(int argc, char **argv, int i)
+{
+}
+
+void
+DoProbe()
+{
+ int i;
+ Bool probeResult;
+ Bool ioEnableFailed = FALSE;
+
+#ifdef XFree86LOADER
+ /* Find the list of video driver modules. */
+ char **list = xf86DriverlistFromCompile();
+ char **l;
+
+ if (list) {
+ ErrorF("List of video driver modules:\n");
+ for (l = list; *l; l++)
+ ErrorF("\t%s\n", *l);
+ } else {
+ ErrorF("No video driver modules found\n");
+ }
+
+ /* Load all the drivers that were found. */
+ xf86LoadModules(list, NULL);
+#endif /* XFree86LOADER */
+
+ /* Disable PCI devices */
+ xf86AccessInit();
+
+ /* Call all of the probe functions, reporting the results. */
+ for (i = 0; i < xf86NumDrivers; i++) {
+
+ if (!xorgHWAccess) {
+ xorgHWFlags flags;
+ if (!xf86DriverList[i]->driverFunc
+ || !xf86DriverList[i]->driverFunc(NULL,
+ GET_REQUIRED_HW_INTERFACES,
+ &flags)
+ || NEED_IO_ENABLED(flags)) {
+ if (ioEnableFailed)
+ continue;
+ if (!xf86EnableIO()) {
+ ioEnableFailed = TRUE;
+ continue;
+ }
+ xorgHWAccess = TRUE;
+ }
+ }
+
+ if (xf86DriverList[i]->Probe == NULL) continue;
+
+ xf86MsgVerb(X_INFO, 3, "Probing in driver %s\n",
+ xf86DriverList[i]->driverName);
+ probeResult =
+ (*xf86DriverList[i]->Probe)(xf86DriverList[i], PROBE_DETECT);
+ if (!probeResult) {
+ xf86ErrorF("Probe in driver `%s' returns FALSE\n",
+ xf86DriverList[i]->driverName);
+ } else {
+ xf86ErrorF("Probe in driver `%s' returns TRUE\n",
+ xf86DriverList[i]->driverName);
+
+ /* If we have a result, then call driver's Identify function */
+ if (xf86DriverList[i]->Identify != NULL) {
+ int verbose = xf86SetVerbosity(1);
+ (*xf86DriverList[i]->Identify)(0);
+ xf86SetVerbosity(verbose);
+ }
+ }
+ }
+
+ OsCleanup(TRUE);
+ AbortDDX();
+ fflush(stderr);
+ exit(0);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86DoScanPci.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86DoScanPci.c
new file mode 100644
index 000000000..9f8c15651
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86DoScanPci.c
@@ -0,0 +1,130 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86DoScanPci.c,v 1.15 2003/09/23 06:43:46 dawes Exp $ */
+/*
+ * Copyright (c) 1999-2002 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * Finish setting up the server.
+ * Call the functions from the scanpci module.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "os.h"
+#ifdef XFree86LOADER
+#include "loaderProcs.h"
+#endif
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Pci.h"
+#include "xf86ScanPci.h"
+
+
+void DoScanPci(int argc, char **argv, int i)
+{
+ int j,skip,globalVerbose,scanpciVerbose;
+ ScanPciSetupProcPtr PciSetup;
+ ScanPciDisplayCardInfoProcPtr DisplayPCICardInfo;
+#ifdef XFree86LOADER
+ int errmaj, errmin;
+#endif
+
+ /*
+ * first we need to finish setup of the OS so that we can call other
+ * functions in the server
+ */
+ OsInit();
+
+ /*
+ * The old verbosity processing that was here isn't useful anymore, but
+ * for compatibility purposes, ignore verbosity changes after the -scanpci
+ * flag.
+ */
+ globalVerbose = xf86Verbose;
+
+ /*
+ * next we process the arguments that are remaining on the command line,
+ * so that things like the module path can be set there
+ */
+ for ( j = i+1; j < argc; j++ ) {
+ if ((skip = ddxProcessArgument(argc, argv, j)))
+ j += (skip - 1);
+ }
+
+ /*
+ * Was the verbosity level increased? If so, set it back.
+ */
+ if (xf86Verbose > globalVerbose)
+ xf86SetVerbosity(globalVerbose);
+
+ /*
+ * Setting scanpciVerbose to 0 will ensure that the output will go to
+ * stderr for all reasonable default stderr verbosity levels.
+ */
+ scanpciVerbose = 0;
+
+ /*
+ * now get the loader set up and load the scanpci module
+ */
+#ifdef XFree86LOADER
+ /* Initialise the loader */
+ LoaderInit();
+ /* Tell the loader the default module search path */
+ LoaderSetPath(xf86ModulePath);
+
+ if (!LoadModule("scanpci", NULL, NULL, NULL, NULL, NULL,
+ &errmaj, &errmin)) {
+ LoaderErrorMsg(NULL, "scanpci", errmaj, errmin);
+ exit(1);
+ }
+ if (LoaderCheckUnresolved(LD_RESOLV_IFDONE)) {
+ /* For now, just a warning */
+ xf86Msg(X_WARNING, "Some symbols could not be resolved!\n");
+ }
+ PciSetup = (ScanPciSetupProcPtr)LoaderSymbol("ScanPciSetupPciIds");
+ DisplayPCICardInfo =
+ (ScanPciDisplayCardInfoProcPtr)LoaderSymbol("ScanPciDisplayPCICardInfo");
+#else
+ PciSetup = ScanPciSetupPciIds;
+ DisplayPCICardInfo = ScanPciDisplayPCICardInfo;
+#endif
+
+ if (!(*PciSetup)())
+ FatalError("ScanPciSetupPciIds() failed\n");
+ (*DisplayPCICardInfo)(scanpciVerbose);
+
+ /*
+ * That's it; we really should clean things up, but a simple
+ * exit seems to be all we need.
+ */
+ exit(0);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Events.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Events.c
new file mode 100644
index 000000000..c1b478ee2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Events.c
@@ -0,0 +1,1865 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 3.159 2003/11/22 04:22:11 dawes Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*
+ * Copyright (c) 1994-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* $XConsortium: xf86Events.c /main/46 1996/10/25 11:36:30 kaleb $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 1.21 2005/11/08 06:33:28 jkj Exp $ */
+
+/* [JCH-96/01/21] Extended std reverse map to four buttons. */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define I_NEED_OS2_H
+#endif
+
+#include <X11/X.h>
+#include <X11/Xpoll.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
+#include "xf86_OSlib.h"
+#include "atKeynames.h"
+
+
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+
+#ifdef XINPUT
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#else
+#include "inputstr.h"
+#endif
+#include "xf86Xinput.h"
+
+#include "mi.h"
+#include "mipointer.h"
+
+#ifdef XF86BIGFONT
+#define _XF86BIGFONT_SERVER_
+#include <X11/extensions/xf86bigfont.h>
+#endif
+
+#ifdef XKB
+extern Bool noXkbExtension;
+#endif
+
+#ifdef DPMSExtension
+#define DPMS_SERVER
+#include <X11/extensions/dpms.h>
+#include "dpmsproc.h"
+#endif
+
+#define XE_POINTER 1
+#define XE_KEYBOARD 2
+
+#ifdef XINPUT
+#define __EqEnqueue(ev) xf86eqEnqueue(ev)
+#else
+#define __EqEnqueue(ev) mieqEnqueue(ev)
+#endif
+
+#define EqEnqueue(ev) { \
+ int __sigstate = xf86BlockSIGIO (); \
+ __EqEnqueue (ev); \
+ xf86UnblockSIGIO(__sigstate); \
+}
+
+#ifdef XTESTEXT1
+
+#define XTestSERVER_SIDE
+#include <X11/extensions/xtestext1.h>
+extern short xtest_mousex;
+extern short xtest_mousey;
+extern int on_steal_input;
+extern Bool XTestStealKeyData();
+extern void XTestStealMotionData();
+#define ENQUEUE(ev, code, direction, dev_type) \
+ (ev)->u.u.detail = (code); \
+ (ev)->u.u.type = (direction); \
+ if (!on_steal_input || \
+ XTestStealKeyData((ev)->u.u.detail, (ev)->u.u.type, dev_type, \
+ xtest_mousex, xtest_mousey)) \
+ EqEnqueue((ev))
+#else /* ! XTESTEXT1 */
+
+#define ENQUEUE(ev, code, direction, dev_type) \
+ (ev)->u.u.detail = (code); \
+ (ev)->u.u.type = (direction); \
+ EqEnqueue((ev))
+
+#endif
+
+/*
+ * The first of many hacks to get VT switching to work under
+ * Solaris 2.1 for x86. The basic problem is that Solaris is supposed
+ * to be SVR4. It is for the most part, except where the video interface
+ * is concerned. These hacks work around those problems.
+ * See the comments for Linux, and SCO.
+ *
+ * This is a toggling variable:
+ * FALSE = No VT switching keys have been pressed last time around
+ * TRUE = Possible VT switch Pending
+ * (DWH - 12/2/93)
+ *
+ * This has been generalised to work with Linux and *BSD+syscons (DHD)
+ */
+
+#ifdef USE_VT_SYSREQ
+Bool VTSysreqToggle = FALSE;
+#endif /* !USE_VT_SYSREQ */
+Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for
+ *BSD and for avoiding VT
+ switches when using the DRI
+ automatic full screen mode.*/
+
+extern fd_set EnabledDevices;
+
+#if defined(XQUEUE)
+extern void xf86XqueRequest(void);
+#endif
+#ifdef XF86PM
+extern void (*xf86OSPMClose)(void);
+#endif
+
+static void xf86VTSwitch(void);
+
+/*
+ * Allow arbitrary drivers or other XFree86 code to register with our main
+ * Wakeup handler.
+ */
+typedef struct x_IHRec {
+ int fd;
+ InputHandlerProc ihproc;
+ pointer data;
+ Bool enabled;
+ struct x_IHRec * next;
+} IHRec, *IHPtr;
+
+static IHPtr InputHandlers = NULL;
+
+
+/*
+ * TimeSinceLastInputEvent --
+ * Function used for screensaver purposes by the os module. Returns the
+ * time in milliseconds since there last was any input.
+ */
+
+int
+TimeSinceLastInputEvent()
+{
+ if (xf86Info.lastEventTime == 0) {
+ xf86Info.lastEventTime = GetTimeInMillis();
+ }
+ return GetTimeInMillis() - xf86Info.lastEventTime;
+}
+
+
+
+/*
+ * SetTimeSinceLastInputEvent --
+ * Set the lastEventTime to now.
+ */
+
+void
+SetTimeSinceLastInputEvent()
+{
+ xf86Info.lastEventTime = GetTimeInMillis();
+}
+
+
+
+/*
+ * ProcessInputEvents --
+ * Retrieve all waiting input events and pass them to DIX in their
+ * correct chronological order. Only reads from the system pointer
+ * and keyboard.
+ */
+
+void
+ProcessInputEvents ()
+{
+ int x, y;
+#ifdef INHERIT_LOCK_STATE
+ static int generation = 0;
+#endif
+
+ /*
+ * With INHERIT_LOCK_STATE defined, the initial state of CapsLock, NumLock
+ * and ScrollLock will be set to match that of the VT the server is
+ * running on.
+ */
+#ifdef INHERIT_LOCK_STATE
+ if (generation != serverGeneration) {
+ xEvent kevent;
+ DevicePtr pKeyboard = xf86Info.pKeyboard;
+ extern unsigned int xf86InitialCaps, xf86InitialNum, xf86InitialScroll;
+
+ generation = serverGeneration;
+ kevent.u.keyButtonPointer.time = GetTimeInMillis();
+ kevent.u.keyButtonPointer.rootX = 0;
+ kevent.u.keyButtonPointer.rootY = 0;
+ kevent.u.u.type = KeyPress;
+
+
+ if (xf86InitialCaps) {
+ kevent.u.u.detail = xf86InitialCaps;
+ (* pKeyboard->processInputProc)(&kevent, (DeviceIntPtr)pKeyboard, 1);
+ xf86InitialCaps = 0;
+ }
+ if (xf86InitialNum) {
+ kevent.u.u.detail = xf86InitialNum;
+ (* pKeyboard->processInputProc)(&kevent, (DeviceIntPtr)pKeyboard, 1);
+ xf86InitialNum = 0;
+ }
+ if (xf86InitialScroll) {
+ kevent.u.u.detail = xf86InitialScroll;
+ (* pKeyboard->processInputProc)(&kevent, (DeviceIntPtr)pKeyboard, 1);
+ xf86InitialScroll = 0;
+ }
+ }
+#endif
+
+ xf86Info.inputPending = FALSE;
+
+#ifdef XINPUT
+ xf86eqProcessInputEvents();
+#else
+ mieqProcessInputEvents();
+#endif
+ miPointerUpdate();
+
+ miPointerPosition(&x, &y);
+ xf86SetViewport(xf86Info.currentScreen, x, y);
+}
+
+void
+xf86GrabServerCallback(CallbackListPtr *callbacks, pointer data, pointer args)
+{
+ ServerGrabInfoRec *grab = (ServerGrabInfoRec*)args;
+
+ xf86Info.grabInfo.server.client = grab->client;
+ xf86Info.grabInfo.server.grabstate = grab->grabstate;
+}
+
+/*
+ * Handle keyboard events that cause some kind of "action"
+ * (i.e., server termination, video mode changes, VT switches, etc.)
+ */
+void
+xf86ProcessActionEvent(ActionEvent action, void *arg)
+{
+#ifdef DEBUG
+ ErrorF("ProcessActionEvent(%d,%x)\n", (int) action, arg);
+#endif
+ switch (action) {
+ case ACTION_TERMINATE:
+ if (!xf86Info.dontZap) {
+#ifdef XFreeXDGA
+ DGAShutdown();
+#endif
+ GiveUp(0);
+ }
+ break;
+ case ACTION_NEXT_MODE:
+ if (!xf86Info.dontZoom)
+ xf86ZoomViewport(xf86Info.currentScreen, 1);
+ break;
+ case ACTION_PREV_MODE:
+ if (!xf86Info.dontZoom)
+ xf86ZoomViewport(xf86Info.currentScreen, -1);
+ break;
+ case ACTION_DISABLEGRAB:
+ if (!xf86Info.grabInfo.disabled && xf86Info.grabInfo.allowDeactivate) {
+ if (inputInfo.pointer && inputInfo.pointer->grab != NULL &&
+ inputInfo.pointer->DeactivateGrab)
+ inputInfo.pointer->DeactivateGrab(inputInfo.pointer);
+ if (inputInfo.keyboard && inputInfo.keyboard->grab != NULL &&
+ inputInfo.keyboard->DeactivateGrab)
+ inputInfo.keyboard->DeactivateGrab(inputInfo.keyboard);
+ }
+ break;
+ case ACTION_CLOSECLIENT:
+ if (!xf86Info.grabInfo.disabled && xf86Info.grabInfo.allowClosedown) {
+ ClientPtr pointer, keyboard, server;
+
+ pointer = keyboard = server = NULL;
+ if (inputInfo.pointer && inputInfo.pointer->grab != NULL)
+ pointer = clients[CLIENT_ID(inputInfo.pointer->grab->resource)];
+ if (inputInfo.keyboard && inputInfo.keyboard->grab != NULL) {
+ keyboard = clients[CLIENT_ID(inputInfo.keyboard->grab->resource)];
+ if (keyboard == pointer)
+ keyboard = NULL;
+ }
+ if ((xf86Info.grabInfo.server.grabstate == SERVER_GRABBED) &&
+ (((server = xf86Info.grabInfo.server.client) == pointer) ||
+ (server == keyboard)))
+ server = NULL;
+
+ if (pointer)
+ CloseDownClient(pointer);
+ if (keyboard)
+ CloseDownClient(keyboard);
+ if (server)
+ CloseDownClient(server);
+ }
+ break;
+#if !defined(__SOL8__) && !defined(__UNIXOS2__) && !defined(sgi) && \
+ (!defined(sun) || defined(i386)) && defined(VT_ACTIVATE)
+ case ACTION_SWITCHSCREEN:
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch && arg) {
+ int vtno = *((int *) arg);
+#if defined(__SCO__) || defined(__UNIXWARE__)
+ vtno--;
+#endif
+#if defined(QNX4)
+ xf86Info.vtRequestsPending = vtno;
+#else
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno) < 0)
+ ErrorF("Failed to switch consoles (%s)\n", strerror(errno));
+#endif
+ }
+ break;
+ case ACTION_SWITCHSCREEN_NEXT:
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch) {
+/* Shouldn't this be true for (sun) && (i386) && (SVR4) ? */
+#if defined(__SCO__) || defined(__UNIXWARE__)
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0)
+#else
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno + 1) < 0)
+#endif
+#if defined (__SCO__) || (defined(sun) && defined (i386) && defined (SVR4)) || defined(__UNIXWARE__)
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 0) < 0)
+#else
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) < 0)
+#endif
+ ErrorF("Failed to switch consoles (%s)\n", strerror(errno));
+ }
+ break;
+ case ACTION_SWITCHSCREEN_PREV:
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch && xf86Info.vtno > 0) {
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno - 1) < 0)
+ ErrorF("Failed to switch consoles (%s)\n", strerror(errno));
+ }
+ break;
+#endif
+ case ACTION_MESSAGE:
+ {
+ char *retstr, *message = (char *) arg;
+ ScrnInfoPtr pScr = XF86SCRNINFO(xf86Info.currentScreen);
+
+#ifdef DEBUG
+ ErrorF("ActionMessage: '%s'\n", message);
+#endif
+ /* Okay the message made it to the ddx. The common layer */
+ /* can check for relevant messages here and react to any */
+ /* that have a global effect. For example: */
+ /* */
+ /* if (!strcmp(message, "foo") { */
+ /* do_foo(); break */
+ /* } */
+ /* */
+ /* otherwise fallback to sending a key event message to */
+ /* the current screen's driver: */
+ if (*pScr->HandleMessage != NULL) {
+ (void) (*pScr->HandleMessage)(pScr->scrnIndex,
+ "KeyEventMessage", message, &retstr);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+/*
+ * xf86PostKbdEvent --
+ * Translate the raw hardware KbdEvent into an XEvent, and tell DIX
+ * about it. Scancode preprocessing and so on is done ...
+ *
+ * OS/2 specific xf86PostKbdEvent(key) has been moved to os-support/os2/os2_kbd.c
+ * as some things differ, and I did not want to scatter this routine with
+ * ifdefs further (hv).
+ */
+
+#ifdef __linux__
+extern u_char SpecialServerMap[];
+#endif
+
+#if !defined(__UNIXOS2__)
+void
+xf86PostKbdEvent(unsigned key)
+{
+ int scanCode = (key & 0x7f);
+ int specialkey = 0;
+ Bool down = (key & 0x80 ? FALSE : TRUE);
+ KeyClassRec *keyc = ((DeviceIntPtr)xf86Info.pKeyboard)->key;
+ Bool updateLeds = FALSE;
+ Bool UsePrefix = FALSE;
+ Bool Direction = FALSE;
+ xEvent kevent;
+ KeySym *keysym;
+ int keycode;
+ static int lockkeys = 0;
+#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
+ static Bool first_time = TRUE;
+#endif
+#if defined(__sparc__) && defined(__linux__)
+ static int kbdSun = -1;
+#endif
+ /* Disable any keyboard processing while in suspend */
+ if (xf86inSuspend)
+ return;
+
+#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
+ if (first_time)
+ {
+ first_time = FALSE;
+ VTSwitchEnabled = (xf86Info.consType == SYSCONS)
+ || (xf86Info.consType == PCVT);
+ }
+#endif
+
+#if defined (__sparc__) && defined(__linux__)
+ if (kbdSun == -1) {
+ if ((xf86Info.xkbmodel && !strcmp(xf86Info.xkbmodel, "sun"))
+ || (xf86Info.xkbrules && !strcmp(xf86Info.xkbrules, "sun")))
+ kbdSun = 1;
+ else
+ kbdSun = 0;
+ }
+ if (kbdSun)
+ goto special;
+#endif /* __sparc__ && __linux__ */
+
+#ifdef __linux__
+ if (xf86Info.kbdCustomKeycodes) {
+ specialkey = SpecialServerMap[scanCode];
+ goto customkeycodes;
+ }
+#endif
+
+ /*
+ * First do some special scancode remapping ...
+ */
+ if (xf86Info.scanPrefix == 0) {
+
+ switch (scanCode) {
+ case KEY_Prefix0:
+ case KEY_Prefix1:
+#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
+ if (xf86Info.consType == PCCONS || xf86Info.consType == SYSCONS
+ || xf86Info.consType == PCVT
+#ifdef WSCONS_SUPPORT
+ || (xf86Info.consType == WSCONS && xf86Info.kbdEvents != xf86WSKbdEvents)
+#endif
+ ) {
+#endif
+ xf86Info.scanPrefix = scanCode; /* special prefixes */
+ return;
+#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
+ }
+ break;
+#endif
+ }
+#if defined (i386) && defined (SVR4)
+ /*
+ * PANIX returns DICOP standards based keycodes in using 106jp
+ * keyboard. We need to remap some keys.
+ */
+ if(xf86Info.panix106 == TRUE){
+ switch (scanCode) {
+ case 0x56: scanCode = KEY_BSlash2; break; /* Backslash */
+ case 0x5A: scanCode = KEY_NFER; break; /* No Kanji Transfer*/
+ case 0x5B: scanCode = KEY_XFER; break; /* Kanji Tranfer */
+ case 0x5C: scanCode = KEY_Yen; break; /* Yen curs pgup */
+ case 0x6B: scanCode = KEY_Left; break; /* Cur Left */
+ case 0x6F: scanCode = KEY_PgUp; break; /* Cur PageUp */
+ case 0x72: scanCode = KEY_AltLang; break; /* AltLang(right) */
+ case 0x73: scanCode = KEY_RCtrl; break; /* not needed */
+ }
+ } else
+#endif /* i386 && SVR4 */
+ {
+ switch (scanCode) {
+ case 0x59: scanCode = KEY_0x59; break;
+ case 0x5a: scanCode = KEY_0x5A; break;
+ case 0x5b: scanCode = KEY_0x5B; break;
+ case 0x5c: scanCode = KEY_KP_Equal; break; /* Keypad Equal */
+ case 0x5d: scanCode = KEY_0x5D; break;
+ case 0x5e: scanCode = KEY_0x5E; break;
+ case 0x5f: scanCode = KEY_0x5F; break;
+ case 0x62: scanCode = KEY_0x62; break;
+ case 0x63: scanCode = KEY_0x63; break;
+ case 0x64: scanCode = KEY_0x64; break;
+ case 0x65: scanCode = KEY_0x65; break;
+ case 0x66: scanCode = KEY_0x66; break;
+ case 0x67: scanCode = KEY_0x67; break;
+ case 0x68: scanCode = KEY_0x68; break;
+ case 0x69: scanCode = KEY_0x69; break;
+ case 0x6a: scanCode = KEY_0x6A; break;
+ case 0x6b: scanCode = KEY_0x6B; break;
+ case 0x6c: scanCode = KEY_0x6C; break;
+ case 0x6d: scanCode = KEY_0x6D; break;
+ case 0x6e: scanCode = KEY_0x6E; break;
+ case 0x6f: scanCode = KEY_0x6F; break;
+ case 0x70: scanCode = KEY_0x70; break;
+ case 0x71: scanCode = KEY_0x71; break;
+ case 0x72: scanCode = KEY_0x72; break;
+ case 0x73: scanCode = KEY_0x73; break;
+ case 0x74: scanCode = KEY_0x74; break;
+ case 0x75: scanCode = KEY_0x75; break;
+ case 0x76: scanCode = KEY_0x76; break;
+ }
+ }
+ }
+
+ else if (
+#ifdef CSRG_BASED
+ (xf86Info.consType == PCCONS || xf86Info.consType == SYSCONS
+ || xf86Info.consType == PCVT
+#ifdef WSCONS_SUPPORT
+ || (xf86Info.consType == WSCONS && xf86Info.kbdEvents !=
+ xf86WSKbdEvents)
+#endif
+ ) &&
+#endif
+ (xf86Info.scanPrefix == KEY_Prefix0)) {
+ xf86Info.scanPrefix = 0;
+
+ switch (scanCode) {
+ case KEY_KP_7: scanCode = KEY_Home; break; /* curs home */
+ case KEY_KP_8: scanCode = KEY_Up; break; /* curs up */
+ case KEY_KP_9: scanCode = KEY_PgUp; break; /* curs pgup */
+ case KEY_KP_4: scanCode = KEY_Left; break; /* curs left */
+ case KEY_KP_5: scanCode = KEY_Begin; break; /* curs begin */
+ case KEY_KP_6: scanCode = KEY_Right; break; /* curs right */
+ case KEY_KP_1: scanCode = KEY_End; break; /* curs end */
+ case KEY_KP_2: scanCode = KEY_Down; break; /* curs down */
+ case KEY_KP_3: scanCode = KEY_PgDown; break; /* curs pgdown */
+ case KEY_KP_0: scanCode = KEY_Insert; break; /* curs insert */
+ case KEY_KP_Decimal: scanCode = KEY_Delete; break; /* curs delete */
+ case KEY_Enter: scanCode = KEY_KP_Enter; break; /* keypad enter */
+ case KEY_LCtrl: scanCode = KEY_RCtrl; break; /* right ctrl */
+ case KEY_KP_Multiply: scanCode = KEY_Print; break; /* print */
+ case KEY_Slash: scanCode = KEY_KP_Divide; break; /* keyp divide */
+ case KEY_Alt: scanCode = KEY_AltLang; break; /* right alt */
+ case KEY_ScrollLock: scanCode = KEY_Break; break; /* curs break */
+ case 0x5b: scanCode = KEY_LMeta; break;
+ case 0x5c: scanCode = KEY_RMeta; break;
+ case 0x5d: scanCode = KEY_Menu; break;
+ case KEY_F3: scanCode = KEY_F13; break;
+ case KEY_F4: scanCode = KEY_F14; break;
+ case KEY_F5: scanCode = KEY_F15; break;
+ case KEY_F6: scanCode = KEY_F16; break;
+ case KEY_F7: scanCode = KEY_F17; break;
+ case KEY_KP_Plus: scanCode = KEY_KP_DEC; break;
+ /*
+ * Ignore virtual shifts (E0 2A, E0 AA, E0 36, E0 B6)
+ */
+ case 0x2A:
+ case 0x36:
+ return;
+ default:
+ xf86MsgVerb(X_INFO, 4, "Unreported Prefix0 scancode: 0x%02x\n",
+ scanCode);
+ /*
+ * "Internet" keyboards are generating lots of new codes. Let them
+ * pass. There is little consistency between them, so don't bother
+ * with symbolic names at this level.
+ */
+ scanCode += 0x78;
+ }
+ }
+
+ else if (xf86Info.scanPrefix == KEY_Prefix1)
+ {
+ xf86Info.scanPrefix = (scanCode == KEY_LCtrl) ? KEY_LCtrl : 0;
+ return;
+ }
+
+ else if (xf86Info.scanPrefix == KEY_LCtrl)
+ {
+ xf86Info.scanPrefix = 0;
+ if (scanCode != KEY_NumLock) return;
+ scanCode = KEY_Pause; /* pause */
+ }
+
+#ifndef __sparc64__
+ /*
+ * PC keyboards generate separate key codes for
+ * Alt+Print and Control+Pause but in the X keyboard model
+ * they need to get the same key code as the base key on the same
+ * physical keyboard key.
+ */
+ if (scanCode == KEY_SysReqest)
+ scanCode = KEY_Print;
+ else if (scanCode == KEY_Break)
+ scanCode = KEY_Pause;
+#endif
+
+ /*
+ * and now get some special keysequences
+ */
+
+ specialkey = scanCode;
+
+#ifdef __linux__
+customkeycodes:
+#endif
+#if defined(i386) || defined(__i386__)
+ if (xf86IsPc98()) {
+ switch (scanCode) {
+ case 0x0e: specialkey = 0x0e; break; /* KEY_BackSpace */
+ case 0x40: specialkey = 0x4a; break; /* KEY_KP_Minus */
+ case 0x49: specialkey = 0x4e; break; /* KEY_KP_Plus */
+
+ /* XXX needs cases for KEY_KP_Divide and KEY_KP_Multiply */
+
+ case 0x62: specialkey = 0x3b; break; /* KEY_F1 */
+ case 0x63: specialkey = 0x3c; break; /* KEY_F2 */
+ case 0x64: specialkey = 0x3d; break; /* KEY_F3 */
+ case 0x65: specialkey = 0x3e; break; /* KEY_F4 */
+ case 0x66: specialkey = 0x3f; break; /* KEY_F5 */
+ case 0x67: specialkey = 0x40; break; /* KEY_F6 */
+ case 0x68: specialkey = 0x41; break; /* KEY_F7 */
+ case 0x69: specialkey = 0x42; break; /* KEY_F8 */
+ case 0x6a: specialkey = 0x43; break; /* KEY_F9 */
+ case 0x6b: specialkey = 0x44; break; /* KEY_F10 */
+ /* case 0x73: specialkey = 0x38; break; KEY_Alt */
+ /* case 0x74: specialkey = 0x1d; break; KEY_LCtrl */
+ default: specialkey = 0x00; break;
+ }
+ }
+#endif
+#if defined (__sparc__) && defined(__linux__)
+special:
+ if (kbdSun) {
+ switch (scanCode) {
+ case 0x2b: specialkey = KEY_BackSpace; break;
+ case 0x47: specialkey = KEY_KP_Minus; break;
+ case 0x7d: specialkey = KEY_KP_Plus; break;
+
+ /* XXX needs cases for KEY_KP_Divide and KEY_KP_Multiply */
+
+ case 0x05: specialkey = KEY_F1; break;
+ case 0x06: specialkey = KEY_F2; break;
+ case 0x08: specialkey = KEY_F3; break;
+ case 0x0a: specialkey = KEY_F4; break;
+ case 0x0c: specialkey = KEY_F5; break;
+ case 0x0e: specialkey = KEY_F6; break;
+ case 0x10: specialkey = KEY_F7; break;
+ case 0x11: specialkey = KEY_F8; break;
+ case 0x12: specialkey = KEY_F9; break;
+ case 0x07: specialkey = KEY_F10; break;
+ case 0x09: specialkey = KEY_F11; break;
+ case 0x0b: specialkey = KEY_F12; break;
+ default: specialkey = 0; break;
+ }
+ /*
+ * XXX XXX XXX:
+ *
+ * I really don't know what's wrong here, but passing the real
+ * scanCode offsets by one from XKB's point of view.
+ *
+ * (ecd@skynet.be, 980405)
+ */
+ scanCode--;
+ }
+#endif /* defined (__sparc__) && defined(__linux__) */
+
+#ifdef XKB
+ if ((xf86Info.ddxSpecialKeys == SKWhenNeeded &&
+ !xf86Info.ActionKeyBindingsSet) ||
+ noXkbExtension || xf86Info.ddxSpecialKeys == SKAlways) {
+#endif
+ if (!(ModifierDown(ShiftMask)) &&
+ ((ModifierDown(ControlMask | AltMask)) ||
+ (ModifierDown(ControlMask | AltLangMask))))
+ {
+ switch (specialkey) {
+
+ case KEY_BackSpace:
+ xf86ProcessActionEvent(ACTION_TERMINATE, NULL);
+ break;
+
+ /*
+ * Check grabs
+ */
+ case KEY_KP_Divide:
+ xf86ProcessActionEvent(ACTION_DISABLEGRAB, NULL);
+ break;
+ case KEY_KP_Multiply:
+ xf86ProcessActionEvent(ACTION_CLOSECLIENT, NULL);
+ break;
+
+ /*
+ * Video mode switches
+ */
+ case KEY_KP_Minus: /* Keypad - */
+ if (down) xf86ProcessActionEvent(ACTION_PREV_MODE, NULL);
+ if (!xf86Info.dontZoom) return;
+ break;
+
+ case KEY_KP_Plus: /* Keypad + */
+ if (down) xf86ProcessActionEvent(ACTION_NEXT_MODE, NULL);
+ if (!xf86Info.dontZoom) return;
+ break;
+
+ /* Under QNX4, we set the vtPending flag for VT switching and
+ * let the VT switch function do the rest...
+ * This is a little different from the other OS'es.
+ */
+#if defined(QNX4)
+ case KEY_1:
+ case KEY_2:
+ case KEY_3:
+ case KEY_4:
+ case KEY_5:
+ case KEY_6:
+ case KEY_7:
+ case KEY_8:
+ case KEY_9:
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch) {
+ if (down) {
+ int vtno = specialkey - KEY_1 + 1;
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN, (void *) &vtno);
+ }
+ return;
+ }
+ break;
+#endif
+
+#if defined(linux) || (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT))) || defined(__SCO__) || defined(__UNIXWARE__)
+ /*
+ * Under Linux, the raw keycodes are consumed before the kernel
+ * does any processing on them, so we must emulate the vt switching
+ * we want ourselves.
+ */
+ case KEY_F1:
+ case KEY_F2:
+ case KEY_F3:
+ case KEY_F4:
+ case KEY_F5:
+ case KEY_F6:
+ case KEY_F7:
+ case KEY_F8:
+ case KEY_F9:
+ case KEY_F10:
+ case KEY_F11:
+ case KEY_F12:
+ if ((VTSwitchEnabled && !xf86Info.vtSysreq && !xf86Info.dontVTSwitch)
+#if (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)))
+ && (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
+#endif
+ ) {
+ int vtno = specialkey - KEY_F1 + 1;
+ if (specialkey == KEY_F11 || specialkey == KEY_F12)
+ vtno = specialkey - KEY_F11 + 11;
+ if (down)
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN, (void *) &vtno);
+ return;
+ }
+ break;
+#endif /* linux || BSD with VTs */
+
+ /* just worth mentioning here: any 386bsd keyboard driver
+ * (pccons.c or co_kbd.c) catches CTRL-ALT-DEL and CTRL-ALT-ESC
+ * before any application (e.g. XF86) will see it
+ * OBS: syscons does not, nor does pcvt !
+ */
+ }
+ }
+
+ /*
+ * Start of actual Solaris VT switching code.
+ * This should pretty much emulate standard SVR4 switching keys.
+ *
+ * DWH 12/2/93
+ */
+
+#ifdef USE_VT_SYSREQ
+ if (VTSwitchEnabled && xf86Info.vtSysreq && !xf86Info.dontVTSwitch)
+ {
+ switch (specialkey)
+ {
+ /*
+ * syscons on *BSD doesn't have a VT #0 -- don't think Linux does
+ * either
+ */
+#if defined (sun) && defined (i386) && defined (SVR4)
+ case KEY_H:
+ if (VTSysreqToggle && down)
+ {
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN, NULL);
+ VTSysreqToggle = 0;
+ return;
+ }
+ break;
+
+ /*
+ * Yah, I know the N, and P keys seem backwards, however that's
+ * how they work under Solaris
+ * XXXX N means go to next active VT not necessarily vtno+1 (or vtno-1)
+ */
+
+ case KEY_N:
+ if (VTSysreqToggle && down)
+ {
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN_NEXT, NULL);
+ VTSysreqToggle = FALSE;
+ return;
+ }
+ break;
+
+ case KEY_P:
+ if (VTSysreqToggle && down)
+ {
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN_NEXT, NULL);
+ VTSysreqToggle = FALSE;
+ return;
+ }
+ break;
+#endif
+
+ case KEY_F1:
+ case KEY_F2:
+ case KEY_F3:
+ case KEY_F4:
+ case KEY_F5:
+ case KEY_F6:
+ case KEY_F7:
+ case KEY_F8:
+ case KEY_F9:
+ case KEY_F10:
+ case KEY_F11:
+ case KEY_F12:
+ if (VTSysreqToggle && down)
+ { int vtno = specialkey - KEY_F1 + 1;
+ if (specialkey == KEY_F11 || specialkey == KEY_F12)
+ vtno = specialkey - KEY_F11 + 11;
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN, (void *) &vtno);
+ VTSysreqToggle = FALSE;
+ return;
+ }
+ break;
+
+ /* Ignore these keys -- ie don't let them cancel an alt-sysreq */
+ case KEY_Alt:
+ case KEY_AltLang:
+ break;
+
+ case KEY_SysReqest:
+ if (down && (ModifierDown(AltMask) || ModifierDown(AltLangMask)))
+ VTSysreqToggle = TRUE;
+ break;
+
+ default:
+ if (VTSysreqToggle)
+ {
+ /*
+ * We only land here when Alt-SysReq is followed by a
+ * non-switching key.
+ */
+ VTSysreqToggle = FALSE;
+
+ }
+ }
+ }
+
+#endif /* USE_VT_SYSREQ */
+
+#ifdef __SCO__
+ /*
+ * With the console in raw mode, SCO will not switch consoles,
+ * you get around this by activating the next console along, if
+ * this fails then go back to console 0, if there is only one
+ * then it doesn't matter, switching to yourself is a nop as far
+ * as the console driver is concerned.
+ * We could do something similar to linux here but SCO ODT uses
+ * Ctrl-PrintScrn, so why change?
+ */
+ if (specialkey == KEY_Print && ModifierDown(ControlMask)) {
+ if (down)
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN_NEXT, NULL);
+ return;
+ }
+#endif /* __SCO__ */
+#ifdef XKB
+ }
+#endif
+
+ /*
+ * Now map the scancodes to real X-keycodes ...
+ */
+ keycode = scanCode + MIN_KEYCODE;
+ keysym = (keyc->curKeySyms.map +
+ keyc->curKeySyms.mapWidth *
+ (keycode - keyc->curKeySyms.minKeyCode));
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ /*
+ * Filter autorepeated caps/num/scroll lock keycodes.
+ */
+#define CAPSFLAG 0x01
+#define NUMFLAG 0x02
+#define SCROLLFLAG 0x04
+#define MODEFLAG 0x08
+ if( down ) {
+ switch( keysym[0] ) {
+ case XK_Caps_Lock :
+ if (lockkeys & CAPSFLAG)
+ return;
+ else
+ lockkeys |= CAPSFLAG;
+ break;
+
+ case XK_Num_Lock :
+ if (lockkeys & NUMFLAG)
+ return;
+ else
+ lockkeys |= NUMFLAG;
+ break;
+
+ case XK_Scroll_Lock :
+ if (lockkeys & SCROLLFLAG)
+ return;
+ else
+ lockkeys |= SCROLLFLAG;
+ break;
+ }
+ if (keysym[1] == XF86XK_ModeLock)
+ {
+ if (lockkeys & MODEFLAG)
+ return;
+ else
+ lockkeys |= MODEFLAG;
+ }
+
+ }
+ else {
+ switch( keysym[0] ) {
+ case XK_Caps_Lock :
+ lockkeys &= ~CAPSFLAG;
+ break;
+
+ case XK_Num_Lock :
+ lockkeys &= ~NUMFLAG;
+ break;
+
+ case XK_Scroll_Lock :
+ lockkeys &= ~SCROLLFLAG;
+ break;
+ }
+ if (keysym[1] == XF86XK_ModeLock)
+ lockkeys &= ~MODEFLAG;
+ }
+
+ /*
+ * LockKey special handling:
+ * ignore releases, toggle on & off on presses.
+ * Don't deal with the Caps_Lock keysym directly, but check the lock modifier
+ */
+ if (keyc->modifierMap[keycode] & LockMask ||
+ keysym[0] == XK_Scroll_Lock ||
+ keysym[1] == XF86XK_ModeLock ||
+ keysym[0] == XK_Num_Lock)
+ {
+ Bool flag;
+
+ if (!down) return;
+ if (KeyPressed(keycode)) {
+ down = !down;
+ flag = FALSE;
+ }
+ else
+ flag = TRUE;
+
+ if (keyc->modifierMap[keycode] & LockMask) xf86Info.capsLock = flag;
+ if (keysym[0] == XK_Num_Lock) xf86Info.numLock = flag;
+ if (keysym[0] == XK_Scroll_Lock) xf86Info.scrollLock = flag;
+ if (keysym[1] == XF86XK_ModeLock) xf86Info.modeSwitchLock = flag;
+ updateLeds = TRUE;
+ }
+
+ if (!xf86Info.kbdCustomKeycodes) {
+ /*
+ * normal, non-keypad keys
+ */
+ if (scanCode < KEY_KP_7 || scanCode > KEY_KP_Decimal) {
+#if !defined(CSRG_BASED) && \
+ !defined(__GNU__) && \
+ defined(KB_84)
+ /*
+ * magic ALT_L key on AT84 keyboards for multilingual support
+ */
+ if (xf86Info.kbdType == KB_84 &&
+ ModifierDown(AltMask) &&
+ keysym[2] != NoSymbol)
+ {
+ UsePrefix = TRUE;
+ Direction = TRUE;
+ }
+#endif /* !CSRG_BASED && ... */
+ }
+ }
+ if (updateLeds) xf86UpdateKbdLeds();
+#ifdef XKB
+ }
+#endif
+
+ /*
+ * check for an autorepeat-event
+ */
+ if (down && KeyPressed(keycode)) {
+ KbdFeedbackClassRec *kbdfeed = ((DeviceIntPtr)xf86Info.pKeyboard)->kbdfeed;
+ if ((xf86Info.autoRepeat != AutoRepeatModeOn) ||
+ keyc->modifierMap[keycode] ||
+ (kbdfeed && !(kbdfeed->ctrl.autoRepeats[keycode>>3] & ( 1<<(keycode&7) ))))
+ return;
+ }
+
+
+ xf86Info.lastEventTime = kevent.u.keyButtonPointer.time = GetTimeInMillis();
+ /*
+ * And now send these prefixes ...
+ * NOTE: There cannot be multiple Mode_Switch keys !!!!
+ */
+ if (UsePrefix)
+ {
+ ENQUEUE(&kevent,
+ keyc->modifierKeyMap[keyc->maxKeysPerModifier*7],
+ (Direction ? KeyPress : KeyRelease),
+ XE_KEYBOARD);
+ ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD);
+ ENQUEUE(&kevent,
+ keyc->modifierKeyMap[keyc->maxKeysPerModifier*7],
+ (Direction ? KeyRelease : KeyPress),
+ XE_KEYBOARD);
+ }
+ else
+ {
+ ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD);
+ }
+}
+#endif /* !__UNIXOS2__ */
+
+#define ModifierIsSet(k) ((modifiers & (k)) == (k))
+
+Bool
+xf86CommonSpecialKey(int key, Bool down, int modifiers)
+{
+ if ((!ModifierIsSet(ShiftMask)) &&
+ (((ModifierIsSet(ControlMask | AltMask)) ||
+ (ModifierIsSet(ControlMask | AltLangMask))))) {
+ switch (key) {
+
+ case KEY_BackSpace:
+ xf86ProcessActionEvent(ACTION_TERMINATE, NULL);
+ break;
+
+ /*
+ * Check grabs
+ */
+ case KEY_KP_Divide:
+ xf86ProcessActionEvent(ACTION_DISABLEGRAB, NULL);
+ break;
+ case KEY_KP_Multiply:
+ xf86ProcessActionEvent(ACTION_CLOSECLIENT, NULL);
+ break;
+
+ /*
+ * The idea here is to pass the scancode down to a list of
+ * registered routines. There should be some standard conventions
+ * for processing certain keys.
+ */
+ case KEY_KP_Minus: /* Keypad - */
+ if (down) xf86ProcessActionEvent(ACTION_PREV_MODE, NULL);
+ if (!xf86Info.dontZoom) return TRUE;
+ break;
+
+ case KEY_KP_Plus: /* Keypad + */
+ if (down) xf86ProcessActionEvent(ACTION_NEXT_MODE, NULL);
+ if (!xf86Info.dontZoom) return TRUE;
+ break;
+ }
+ }
+ return FALSE;
+}
+
+/*
+ * xf86Wakeup --
+ * Os wakeup handler.
+ */
+
+/* ARGSUSED */
+void
+xf86Wakeup(pointer blockData, int err, pointer pReadmask)
+{
+#if !defined(__UNIXOS2__) && !defined(__QNX__)
+ fd_set* LastSelectMask = (fd_set*)pReadmask;
+ fd_set devicesWithInput;
+ InputInfoPtr pInfo;
+
+ if (err >= 0) {
+
+ XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices);
+ if (XFD_ANYSET(&devicesWithInput)) {
+ if (xf86Info.kbdEvents)
+ (xf86Info.kbdEvents)();
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ if (pInfo->read_input && pInfo->fd >= 0 &&
+ (FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) {
+ int sigstate = xf86BlockSIGIO();
+
+ pInfo->read_input(pInfo);
+ xf86UnblockSIGIO(sigstate);
+ /*
+ * Remove the descriptior from the set because more than one
+ * device may share the same file descriptor.
+ */
+ FD_CLR(pInfo->fd, &devicesWithInput);
+ }
+ pInfo = pInfo->next;
+ }
+ }
+ }
+#else /* __UNIXOS2__ and __QNX__ */
+
+ InputInfoPtr pInfo;
+
+ (xf86Info.kbdEvents)(); /* Under OS/2 and QNX, always call */
+
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ if (pInfo->read_input && pInfo->fd >= 0) {
+ int sigstate = xf86BlockSIGIO();
+
+ pInfo->read_input(pInfo);
+ xf86UnblockSIGIO(sigstate);
+ /*
+ * Must break here because more than one device may share
+ * the same file descriptor.
+ */
+ break;
+ }
+ pInfo = pInfo->next;
+ }
+
+#endif /* __UNIXOS2__ and __QNX__ */
+
+ if (err >= 0) { /* we don't want the handlers called if select() */
+ IHPtr ih; /* returned with an error condition, do we? */
+
+ for (ih = InputHandlers; ih; ih = ih->next) {
+ if (ih->enabled && ih->fd >= 0 && ih->ihproc &&
+ (FD_ISSET(ih->fd, ((fd_set *)pReadmask)) != 0)) {
+ ih->ihproc(ih->fd, ih->data);
+ }
+ }
+ }
+
+ if (xf86VTSwitchPending()) xf86VTSwitch();
+
+ if (xf86Info.inputPending) ProcessInputEvents();
+}
+
+
+/*
+ * xf86SigioReadInput --
+ * signal handler for the SIGIO signal.
+ */
+static void
+xf86SigioReadInput(int fd,
+ void *closure)
+{
+ int sigstate = xf86BlockSIGIO();
+ InputInfoPtr pInfo = (InputInfoPtr) closure;
+
+ pInfo->read_input(pInfo);
+
+ xf86UnblockSIGIO(sigstate);
+}
+
+/*
+ * xf86AddEnabledDevice --
+ *
+ */
+void
+xf86AddEnabledDevice(InputInfoPtr pInfo)
+{
+ if (!xf86InstallSIGIOHandler (pInfo->fd, xf86SigioReadInput, pInfo)) {
+ AddEnabledDevice(pInfo->fd);
+ }
+}
+
+/*
+ * xf86RemoveEnabledDevice --
+ *
+ */
+void
+xf86RemoveEnabledDevice(InputInfoPtr pInfo)
+{
+ if (!xf86RemoveSIGIOHandler (pInfo->fd)) {
+ RemoveEnabledDevice(pInfo->fd);
+ }
+}
+
+static int *xf86SignalIntercept = NULL;
+
+void
+xf86InterceptSignals(int *signo)
+{
+ if ((xf86SignalIntercept = signo))
+ *signo = -1;
+}
+
+static void (*xf86SigIllHandler)(void) = NULL;
+
+void
+xf86InterceptSigIll(void (*sigillhandler)(void))
+{
+ xf86SigIllHandler = sigillhandler;
+}
+
+#ifdef HAVE_EXECINFO_H
+#define HAVE_BACKTRACE
+#include <execinfo.h>
+#endif
+
+#ifdef HAVE_BACKTRACE
+
+static __inline__ void xorg_backtrace(void)
+{
+ void *array[32]; /* deeper nesting than this means something's wrong */
+ size_t size, i;
+ char **strings;
+ ErrorF("\nBacktrace:\n");
+ size = backtrace(array, 32);
+ strings = backtrace_symbols(array, size);
+ for (i = 0; i < size; i++)
+ ErrorF("%d: %s\n", i, strings[i]);
+ free(strings);
+}
+
+#else /* not glibc or glibc < 2.1 */
+
+# if defined(sun) && defined(__SVR4)
+# define HAVE_PSTACK
+# endif
+
+# if defined(HAVE_WALKCONTEXT) /* Solaris 9 & later */
+
+# include <ucontext.h>
+# include <signal.h>
+# include <dlfcn.h>
+# include <sys/elf.h>
+
+#ifdef _LP64
+# define ElfSym Elf64_Sym
+#else
+# define ElfSym Elf32_Sym
+#endif
+
+/* Called for each frame on the stack to print it's contents */
+static int xorg_backtrace_frame(uintptr_t pc, int signo, void *arg)
+{
+ Dl_info dlinfo;
+ ElfSym *dlsym;
+ char header[32];
+ int depth = *((int *) arg);
+
+ if (signo) {
+ char signame[SIG2STR_MAX];
+
+ if (sig2str(signo, signame) != 0) {
+ strcpy(signame, "unknown");
+ }
+
+ ErrorF("** Signal %d (%s)\n", signo, signame);
+ }
+
+ snprintf(header, sizeof(header), "%d: 0x%lx", depth, pc);
+ *((int *) arg) = depth + 1;
+
+ /* Ask system dynamic loader for info on the address */
+ if (dladdr1((void *) pc, &dlinfo, (void **) &dlsym, RTLD_DL_SYMENT)) {
+ unsigned long offset = pc - (uintptr_t) dlinfo.dli_saddr;
+ const char *symname;
+
+ if (offset < dlsym->st_size) { /* inside a function */
+ symname = dlinfo.dli_sname;
+ } else { /* found which file it was in, but not which function */
+ symname = "<section start>";
+ offset = pc - (uintptr_t)dlinfo.dli_fbase;
+ }
+ ErrorF("%s: %s:%s+0x%lx\n", header, dlinfo.dli_fname,
+ symname, offset);
+
+ } else {
+ /* Couldn't find symbol info from system dynamic loader, should
+ * probably poke elfloader here, but haven't written that code yet,
+ * so we just print the pc.
+ */
+ ErrorF("%s\n", header);
+ }
+
+ return 0;
+}
+# endif /* HAVE_WALKCONTEXT */
+
+# ifdef HAVE_PSTACK
+static int xorg_backtrace_pstack(void) {
+ pid_t kidpid;
+ int pipefd[2];
+
+ if (pipe(pipefd) != 0) {
+ return -1;
+ }
+
+ kidpid = fork1();
+
+ if (kidpid == -1) {
+ /* ERROR */
+ return -1;
+ } else if (kidpid == 0) {
+ /* CHILD */
+ char parent[16];
+
+ seteuid(0);
+ close(STDIN_FILENO);
+ close(STDOUT_FILENO);
+ dup2(pipefd[1],STDOUT_FILENO);
+ closefrom(STDERR_FILENO);
+
+ snprintf(parent, sizeof(parent), "%d", getppid());
+ execle("/usr/bin/pstack", "pstack", parent, NULL);
+ exit(1);
+ } else {
+ /* PARENT */
+ char btline[256];
+ int kidstat;
+ int bytesread;
+ int done = 0;
+
+ close(pipefd[1]);
+
+ while (!done) {
+ bytesread = read(pipefd[0], btline, sizeof(btline) - 1);
+
+ if (bytesread > 0) {
+ btline[bytesread] = 0;
+ ErrorF("%s", btline);
+ }
+ else if ((bytesread < 0) ||
+ ((errno != EINTR) && (errno != EAGAIN)))
+ done = 1;
+ }
+ close(pipefd[0]);
+ waitpid(kidpid, &kidstat, 0);
+ if (kidstat != 0)
+ return -1;
+ }
+ return 0;
+}
+# endif /* HAVE_PSTACK */
+
+
+# if defined(HAVE_PSTACK) || defined(HAVE_WALKCONTEXT)
+
+static __inline__ void xorg_backtrace(void) {
+
+ ErrorF("\nBacktrace:\n");
+
+# ifdef HAVE_PSTACK
+/* First try fork/exec of pstack - otherwise fall back to walkcontext
+ pstack is preferred since it can print names of non-exported functions */
+
+ if (xorg_backtrace_pstack() < 0)
+# endif
+ {
+# ifdef HAVE_WALKCONTEXT
+ ucontext_t u;
+ int depth = 1;
+
+ if (getcontext(&u) == 0)
+ walkcontext(&u, xorg_backtrace_frame, &depth);
+ else
+# endif
+ Error("Failed to get backtrace info");
+ }
+ ErrorF("\n");
+}
+
+# else
+
+/* Default fallback if we can't find any way to get a backtrace */
+static __inline__ void xorg_backtrace(void) { return; }
+
+# endif
+#endif
+
+/*
+ * xf86SigHandler --
+ * Catch unexpected signals and exit or continue cleanly.
+ */
+void
+xf86SigHandler(int signo)
+{
+ if ((signo == SIGILL) && xf86SigIllHandler) {
+ (*xf86SigIllHandler)();
+ /* Re-arm handler just in case we unexpectedly return here */
+ (void) signal(signo, xf86SigHandler);
+ return;
+ }
+
+ if (xf86SignalIntercept && (*xf86SignalIntercept < 0)) {
+ *xf86SignalIntercept = signo;
+ /* Re-arm handler just in case */
+ (void) signal(signo, xf86SigHandler);
+ return;
+ }
+
+ signal(signo,SIG_IGN);
+ xf86Info.caughtSignal = TRUE;
+#ifdef XF86BIGFONT
+ XF86BigfontCleanup();
+#endif
+#if defined(XFree86LOADER)
+ if (xf86Initialising)
+ LoaderCheckUnresolved(LD_RESOLV_IFDONE);
+ ErrorF("\n"
+ " *** If unresolved symbols were reported above, they might not\n"
+ " *** be the reason for the server aborting.\n");
+#endif
+
+ xorg_backtrace();
+
+ FatalError("Caught signal %d. Server aborting\n", signo);
+}
+
+#ifdef MEMDEBUG
+void
+xf86SigMemDebug(int signo)
+{
+ CheckMemory();
+ (void) signal(signo, xf86SigMemDebug);
+ return;
+}
+#endif
+
+/*
+ * xf86VTSwitch --
+ * Handle requests for switching the vt.
+ */
+static void
+xf86VTSwitch()
+{
+ int i, prevSIGIO;
+ InputInfoPtr pInfo;
+ IHPtr ih;
+
+#ifdef DEBUG
+ ErrorF("xf86VTSwitch()\n");
+#endif
+
+#ifdef XFreeXDGA
+ if(!DGAVTSwitch())
+ return;
+#endif
+
+ /*
+ * Since all screens are currently all in the same state it is sufficient
+ * check the first. This might change in future.
+ */
+ if (xf86Screens[0]->vtSema) {
+
+#ifdef DEBUG
+ ErrorF("xf86VTSwitch: Leaving, xf86Exiting is %s\n",
+ BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE));
+#endif
+#ifdef DPMSExtension
+ if (DPMSPowerLevel != DPMSModeOn)
+ DPMSSet(DPMSModeOn);
+#endif
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (!(dispatchException & DE_TERMINATE))
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
+ }
+#if !defined(__UNIXOS2__)
+
+ /*
+ * Keep the order: Disable Device > LeaveVT
+ * EnterVT > EnableDevice
+ */
+ DisableDevice((DeviceIntPtr)xf86Info.pKeyboard);
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ DisableDevice(pInfo->dev);
+ pInfo = pInfo->next;
+ }
+#endif /* !__UNIXOS2__ */
+ xf86EnterServerState(SETUP);
+ for (i = 0; i < xf86NumScreens; i++)
+ xf86Screens[i]->LeaveVT(i, 0);
+
+ for (ih = InputHandlers; ih; ih = ih->next)
+ xf86DisableInputHandler(ih);
+ xf86AccessLeave(); /* We need this here, otherwise */
+ xf86AccessLeaveState(); /* console won't be restored */
+
+ if (!xf86VTSwitchAway()) {
+ /*
+ * switch failed
+ */
+
+#ifdef DEBUG
+ ErrorF("xf86VTSwitch: Leave failed\n");
+#endif
+ prevSIGIO = xf86BlockSIGIO();
+ xf86AccessEnter();
+ xf86EnterServerState(SETUP);
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (!xf86Screens[i]->EnterVT(i, 0))
+ FatalError("EnterVT failed for screen %d\n", i);
+ }
+ xf86EnterServerState(OPERATING);
+ if (!(dispatchException & DE_TERMINATE)) {
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
+ }
+ }
+ SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset);
+
+#if !defined(__UNIXOS2__)
+ EnableDevice((DeviceIntPtr)xf86Info.pKeyboard);
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ EnableDevice(pInfo->dev);
+ pInfo = pInfo->next;
+ }
+#endif /* !__UNIXOS2__ */
+ for (ih = InputHandlers; ih; ih = ih->next)
+ xf86EnableInputHandler(ih);
+
+ xf86UnblockSIGIO(prevSIGIO);
+
+ } else {
+#ifdef XF86PM
+ if (xf86OSPMClose)
+ xf86OSPMClose();
+ xf86OSPMClose = NULL;
+#endif
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ /*
+ * zero all access functions to
+ * trap calls when switched away.
+ */
+ xf86Screens[i]->vtSema = FALSE;
+ xf86Screens[i]->access = NULL;
+ xf86Screens[i]->busAccess = NULL;
+ }
+ if (xorgHWAccess)
+ xf86DisableIO();
+ }
+ } else {
+
+#ifdef DEBUG
+ ErrorF("xf86VTSwitch: Entering\n");
+#endif
+ if (!xf86VTSwitchTo()) return;
+
+ prevSIGIO = xf86BlockSIGIO();
+#ifdef XF86PM
+ xf86OSPMClose = xf86OSPMOpen();
+#endif
+
+ if (xorgHWAccess)
+ xf86EnableIO();
+ xf86AccessEnter();
+ xf86EnterServerState(SETUP);
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86Screens[i]->vtSema = TRUE;
+ if (!xf86Screens[i]->EnterVT(i, 0))
+ FatalError("EnterVT failed for screen %d\n", i);
+ }
+ xf86EnterServerState(OPERATING);
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess)(i, TRUE);
+ }
+
+ /* Turn screen saver off when switching back */
+ SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset);
+
+#if !defined(__UNIXOS2__)
+ EnableDevice((DeviceIntPtr)xf86Info.pKeyboard);
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ EnableDevice(pInfo->dev);
+ pInfo = pInfo->next;
+ }
+#endif /* !__UNIXOS2__ */
+
+ for (ih = InputHandlers; ih; ih = ih->next)
+ xf86EnableInputHandler(ih);
+
+ xf86UnblockSIGIO(prevSIGIO);
+ }
+}
+
+
+/* Input handler registration */
+
+pointer
+xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
+{
+ IHPtr ih;
+
+ if (fd < 0 || !proc)
+ return NULL;
+
+ ih = xcalloc(sizeof(*ih), 1);
+ if (!ih)
+ return NULL;
+
+ ih->fd = fd;
+ ih->ihproc = proc;
+ ih->data = data;
+ ih->enabled = TRUE;
+
+ ih->next = InputHandlers;
+ InputHandlers = ih;
+
+ AddEnabledDevice(fd);
+
+ return ih;
+}
+
+int
+xf86RemoveInputHandler(pointer handler)
+{
+ IHPtr ih, p;
+ int fd;
+
+ if (!handler)
+ return -1;
+
+ ih = handler;
+ fd = ih->fd;
+
+ if (ih->fd >= 0)
+ RemoveEnabledDevice(ih->fd);
+
+ if (ih == InputHandlers)
+ InputHandlers = ih->next;
+ else {
+ p = InputHandlers;
+ while (p && p->next != ih)
+ p = p->next;
+ if (ih)
+ p->next = ih->next;
+ }
+ xfree(ih);
+ return fd;
+}
+
+void
+xf86DisableInputHandler(pointer handler)
+{
+ IHPtr ih;
+
+ if (!handler)
+ return;
+
+ ih = handler;
+ ih->enabled = FALSE;
+ if (ih->fd >= 0)
+ RemoveEnabledDevice(ih->fd);
+}
+
+void
+xf86EnableInputHandler(pointer handler)
+{
+ IHPtr ih;
+
+ if (!handler)
+ return;
+
+ ih = handler;
+ ih->enabled = TRUE;
+ if (ih->fd >= 0)
+ AddEnabledDevice(ih->fd);
+}
+
+/*
+ * As used currently by the DRI, the return value is ignored.
+ */
+Bool
+xf86EnableVTSwitch(Bool new)
+{
+ static Bool def = TRUE;
+ Bool old;
+
+ old = VTSwitchEnabled;
+ if (!new) {
+ /* Disable VT switching */
+ def = VTSwitchEnabled;
+ VTSwitchEnabled = FALSE;
+ } else {
+ /* Restore VT switching to default */
+ VTSwitchEnabled = def;
+ }
+ return old;
+}
+
+#ifdef XTESTEXT1
+
+void
+XTestGetPointerPos(short *fmousex, short *fmousey)
+{
+ int x,y;
+
+ miPointerPosition(&x, &y);
+ *fmousex = x;
+ *fmousey = y;
+}
+
+
+
+void
+XTestJumpPointer(int jx, int jy, int dev_type)
+{
+ miPointerAbsoluteCursor(jx, jy, GetTimeInMillis() );
+}
+
+void
+XTestGenerateEvent(int dev_type, int keycode, int keystate, int mousex,
+ int mousey)
+{
+ xEvent tevent;
+
+ tevent.u.u.type = (dev_type == XE_POINTER) ?
+ (keystate == XTestKEY_UP) ? ButtonRelease : ButtonPress :
+ (keystate == XTestKEY_UP) ? KeyRelease : KeyPress;
+ tevent.u.u.detail = keycode;
+ tevent.u.keyButtonPointer.rootX = mousex;
+ tevent.u.keyButtonPointer.rootY = mousey;
+ tevent.u.keyButtonPointer.time = xf86Info.lastEventTime = GetTimeInMillis();
+#ifdef XINPUT
+ xf86eqEnqueue(&tevent);
+#else
+ mieqEnqueue(&tevent);
+#endif
+ xf86Info.inputPending = TRUE; /* virtual event */
+}
+
+#endif /* XTESTEXT1 */
+
+void
+xf86ReloadInputDevs(int sig)
+{
+ InputInfoPtr pInfo;
+
+ signal(sig, (void(*)(int))xf86ReloadInputDevs);
+
+ DisableDevice((DeviceIntPtr)xf86Info.pKeyboard);
+ EnableDevice((DeviceIntPtr)xf86Info.pKeyboard);
+
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ DisableDevice(pInfo->dev);
+ EnableDevice(pInfo->dev);
+ pInfo = pInfo->next;
+ }
+
+ return;
+}
+
+#ifdef WSCONS_SUPPORT
+
+/* XXX Currently XKB is mandatory. */
+
+extern int WSKbdToKeycode(int);
+
+void
+xf86PostWSKbdEvent(struct wscons_event *event)
+{
+ int type = event->type;
+ int value = event->value;
+ unsigned int keycode;
+ int blocked;
+
+ if (type == WSCONS_EVENT_KEY_UP || type == WSCONS_EVENT_KEY_DOWN) {
+ Bool down = (type == WSCONS_EVENT_KEY_DOWN ? TRUE : FALSE);
+
+ /* map the scancodes to standard XFree86 scancode */
+ keycode = WSKbdToKeycode(value);
+ if (!down) keycode |= 0x80;
+ /* It seems better to block SIGIO there */
+ blocked = xf86BlockSIGIO();
+ xf86PostKbdEvent(keycode);
+ xf86UnblockSIGIO(blocked);
+ }
+}
+#endif /* WSCONS_SUPPORT */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Globals.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Globals.c
new file mode 100644
index 000000000..30fe10554
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Globals.c
@@ -0,0 +1,254 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Globals.c,v 1.42 2004/01/27 01:31:44 dawes Exp $ */
+
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains all the XFree86 global variables.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "windowstr.h"
+#include "propertyst.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Parser.h"
+#include "xf86Xinput.h"
+#include "xf86InPriv.h"
+
+/* Globals that video drivers may access */
+
+int xf86ScreenIndex = -1; /* Index of ScrnInfo in pScreen.devPrivates */
+int xf86CreateRootWindowIndex = -1; /* Index into pScreen.devPrivates */
+ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */
+int xf86PixmapIndex = 0;
+const unsigned char byte_reversed[256] =
+{
+ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+ 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+ 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+ 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+ 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+ 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+ 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+ 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+ 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+ 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+ 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+ 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+ 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+ 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+ 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+ 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+ 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+ 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+ 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+ 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+ 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+ 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+ 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+ 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+ 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+ 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+ 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+ 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+ 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+ 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+ 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+ 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
+};
+
+/* Globals that input drivers may access */
+InputInfoPtr xf86InputDevs = NULL;
+
+
+/* Globals that video drivers may not access */
+
+xf86InfoRec xf86Info = {
+ NULL, /* pKeyboard */
+ NULL, /* kbdProc */
+ NULL, /* kbdEvents */
+ -1, /* consoleFd */
+ -1, /* kbdFd */
+ -1, /* vtno */
+ -1, /* kbdType */
+ -1, /* kbdRate */
+ -1, /* kbdDelay */
+ -1, /* bell_pitch */
+ -1, /* bell_duration */
+ TRUE, /* autoRepeat */
+ 0, /* leds */
+ 0, /* xleds */
+ NULL, /* vtinit */
+ 0, /* scanPrefix */
+ FALSE, /* capsLock */
+ FALSE, /* numLock */
+ FALSE, /* scrollLock */
+ FALSE, /* modeSwitchLock */
+ FALSE, /* composeLock */
+ FALSE, /* vtSysreq */
+ SKWhenNeeded, /* ddxSpecialKeys */
+ FALSE, /* ActionKeyBindingsSet */
+#if defined(SVR4) && defined(i386)
+ FALSE, /* panix106 */
+#endif
+#if defined(__OpenBSD__) || defined(__NetBSD__)
+ 0, /* wskbdType */
+#endif
+ NULL, /* pMouse */
+#ifdef XINPUT
+ NULL, /* mouseLocal */
+#endif
+ -1, /* lastEventTime */
+ FALSE, /* vtRequestsPending */
+ FALSE, /* inputPending */
+ FALSE, /* dontVTSwitch */
+ FALSE, /* dontZap */
+ FALSE, /* dontZoom */
+ FALSE, /* notrapSignals */
+ FALSE, /* caughtSignal */
+ FALSE, /* sharedMonitor */
+ NULL, /* currentScreen */
+#ifdef CSRG_BASED
+ -1, /* screenFd */
+ -1, /* consType */
+#endif
+#ifdef XKB
+ NULL, /* xkbkeymap */
+ NULL, /* xkbkeycodes */
+ NULL, /* xkbtypes */
+ NULL, /* xkbcompat */
+ NULL, /* xkbsymbols */
+ NULL, /* xkbgeometry */
+ FALSE, /* xkbcomponents_specified */
+ NULL, /* xkbrules */
+ NULL, /* xkbmodel */
+ NULL, /* xkblayout */
+ NULL, /* xkbvariant */
+ NULL, /* xkboptions */
+#endif
+ FALSE, /* allowMouseOpenFail */
+ TRUE, /* vidModeEnabled */
+ FALSE, /* vidModeAllowNonLocal */
+ TRUE, /* miscModInDevEnabled */
+ FALSE, /* miscModInDevAllowNonLocal */
+ PCIOsConfig, /* pciFlags */
+ Pix24DontCare, /* pixmap24 */
+ X_DEFAULT, /* pix24From */
+#if defined(i386) || defined(__i386__)
+ FALSE, /* pc98 */
+#endif
+ TRUE, /* pmFlag */
+ LogNone, /* syncLog */
+ 0, /* estimateSizesAggressively */
+ FALSE, /* kbdCustomKeycodes */
+ FALSE, /* disableRandR */
+ X_DEFAULT /* randRFrom */
+};
+const char *xf86ConfigFile = NULL;
+const char *xf86InputDeviceList = NULL;
+const char *xf86ModulePath = DEFAULT_MODULE_PATH;
+MessageType xf86ModPathFrom = X_DEFAULT;
+const char *xf86LogFile = DEFAULT_LOGPREFIX;
+MessageType xf86LogFileFrom = X_DEFAULT;
+Bool xf86LogFileWasOpened = FALSE;
+serverLayoutRec xf86ConfigLayout = {NULL, };
+confDRIRec xf86ConfigDRI = {0, };
+XF86ConfigPtr xf86configptr = NULL;
+Bool xf86Resetting = FALSE;
+Bool xf86Initialising = FALSE;
+Bool xf86ProbeFailed = FALSE;
+Bool xf86DoProbe = FALSE;
+Bool xf86DoConfigure = FALSE;
+#ifdef XFree86LOADER
+DriverPtr *xf86DriverList = NULL;
+int xf86NumDrivers = 0;
+InputDriverPtr *xf86InputDriverList = NULL;
+int xf86NumInputDrivers = 0;
+ModuleInfoPtr *xf86ModuleInfoList = NULL;
+int xf86NumModuleInfos = 0;
+#endif
+int xf86NumScreens = 0;
+
+const char *xf86VisualNames[] = {
+ "StaticGray",
+ "GrayScale",
+ "StaticColor",
+ "PseudoColor",
+ "TrueColor",
+ "DirectColor"
+};
+
+/* Parameters set only from the command line */
+char *xf86ServerName = "no-name";
+Bool xf86fpFlag = FALSE;
+Bool xf86coFlag = FALSE;
+Bool xf86sFlag = FALSE;
+Bool xf86bsEnableFlag = FALSE;
+Bool xf86bsDisableFlag = FALSE;
+Bool xf86silkenMouseDisableFlag = FALSE;
+Bool xf86acpiDisableFlag = FALSE;
+char *xf86LayoutName = NULL;
+char *xf86ScreenName = NULL;
+char *xf86PointerName = NULL;
+char *xf86KeyboardName = NULL;
+Bool xf86ProbeOnly = FALSE;
+int xf86Verbose = DEFAULT_VERBOSE;
+int xf86LogVerbose = DEFAULT_LOG_VERBOSE;
+int xf86FbBpp = -1;
+Pix24Flags xf86Pix24 = Pix24DontCare;
+int xf86Depth = -1;
+rgb xf86Weight = {0, 0, 0};
+Bool xf86FlipPixels = FALSE;
+Gamma xf86Gamma = {0.0, 0.0, 0.0};
+Bool xf86ShowUnresolved = DEFAULT_UNRESOLVED;
+Bool xf86BestRefresh = DEFAULT_BEST_REFRESH;
+Bool xf86AllowMouseOpenFail = FALSE;
+#ifdef XF86VIDMODE
+Bool xf86VidModeDisabled = FALSE;
+Bool xf86VidModeAllowNonLocal = FALSE;
+#endif
+#ifdef XF86MISC
+Bool xf86MiscModInDevDisabled = FALSE;
+Bool xf86MiscModInDevAllowNonLocal = FALSE;
+#endif
+RootWinPropPtr *xf86RegisteredPropertiesTable = NULL;
+Bool xf86inSuspend = FALSE;
+Bool xorgHWAccess = FALSE;
+PciBusId xf86IsolateDevice;
+
+#ifdef DLOPEN_HACK
+/*
+ * This stuff is a hack to allow dlopen() modules to work. It is intended
+ * only to be used when using dlopen() modules for debugging purposes.
+ */
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Helper.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Helper.c
new file mode 100644
index 000000000..a6c7d5c89
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Helper.c
@@ -0,0 +1,2983 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Helper.c,v 1.136 2004/01/27 01:31:45 dawes Exp $ */
+
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * Authors: Dirk Hohndel <hohndel@XFree86.Org>
+ * David Dawes <dawes@XFree86.Org>
+ * ... and others
+ *
+ * This file includes the helper functions that the server provides for
+ * different drivers.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "servermd.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "propertyst.h"
+#include "gcstruct.h"
+#include "loaderProcs.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "micmap.h"
+#include "xf86PciInfo.h"
+#include "xf86DDC.h"
+#include "xf86Xinput.h"
+#include "xf86InPriv.h"
+#include "mivalidate.h"
+#include "xf86RAC.h"
+#include "xf86Bus.h"
+#include "xf86Version.h"
+
+/* For xf86GetClocks */
+#if defined(CSRG_BASED) || defined(__GNU__)
+#define HAS_SETPRIORITY
+#include <sys/resource.h>
+#endif
+
+static int xf86ScrnInfoPrivateCount = 0;
+
+
+#ifdef XFree86LOADER
+/* Add a pointer to a new DriverRec to xf86DriverList */
+
+void
+xf86AddDriver(DriverPtr driver, pointer module, int flags)
+{
+ /* Don't add null entries */
+ if (!driver)
+ return;
+
+ if (xf86DriverList == NULL)
+ xf86NumDrivers = 0;
+
+ xf86NumDrivers++;
+ xf86DriverList = xnfrealloc(xf86DriverList,
+ xf86NumDrivers * sizeof(DriverPtr));
+ xf86DriverList[xf86NumDrivers - 1] = xnfalloc(sizeof(DriverRec));
+ if (flags & HaveDriverFuncs)
+ *xf86DriverList[xf86NumDrivers - 1] = *driver;
+ else {
+ memcpy(xf86DriverList[xf86NumDrivers - 1], driver, sizeof(DriverRec1));
+ xf86DriverList[xf86NumDrivers - 1]->driverFunc = NULL;
+ }
+ xf86DriverList[xf86NumDrivers - 1]->module = module;
+ xf86DriverList[xf86NumDrivers - 1]->refCount = 0;
+}
+
+void
+xf86DeleteDriver(int drvIndex)
+{
+ if (xf86DriverList[drvIndex]
+ && (!xf86DriverHasEntities(xf86DriverList[drvIndex]))) {
+ if (xf86DriverList[drvIndex]->module)
+ UnloadModule(xf86DriverList[drvIndex]->module);
+ xfree(xf86DriverList[drvIndex]);
+ xf86DriverList[drvIndex] = NULL;
+ }
+}
+
+/* Add a pointer to a new InputDriverRec to xf86InputDriverList */
+
+void
+xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags)
+{
+ /* Don't add null entries */
+ if (!driver)
+ return;
+
+ if (xf86InputDriverList == NULL)
+ xf86NumInputDrivers = 0;
+
+ xf86NumInputDrivers++;
+ xf86InputDriverList = xnfrealloc(xf86InputDriverList,
+ xf86NumInputDrivers * sizeof(InputDriverPtr));
+ xf86InputDriverList[xf86NumInputDrivers - 1] =
+ xnfalloc(sizeof(InputDriverRec));
+ *xf86InputDriverList[xf86NumInputDrivers - 1] = *driver;
+ xf86InputDriverList[xf86NumInputDrivers - 1]->module = module;
+ xf86InputDriverList[xf86NumInputDrivers - 1]->refCount = 0;
+}
+
+void
+xf86DeleteInputDriver(int drvIndex)
+{
+ if (xf86InputDriverList[drvIndex] && xf86InputDriverList[drvIndex]->module)
+ UnloadModule(xf86InputDriverList[drvIndex]->module);
+ xfree(xf86InputDriverList[drvIndex]);
+ xf86InputDriverList[drvIndex] = NULL;
+}
+
+void
+xf86AddModuleInfo(ModuleInfoPtr info, pointer module)
+{
+ /* Don't add null entries */
+ if (!module)
+ return;
+
+ if (xf86ModuleInfoList == NULL)
+ xf86NumModuleInfos = 0;
+
+ xf86NumModuleInfos++;
+ xf86ModuleInfoList = xnfrealloc(xf86ModuleInfoList,
+ xf86NumModuleInfos * sizeof(ModuleInfoPtr));
+ xf86ModuleInfoList[xf86NumModuleInfos - 1] = xnfalloc(sizeof(ModuleInfoRec));
+ *xf86ModuleInfoList[xf86NumModuleInfos - 1] = *info;
+ xf86ModuleInfoList[xf86NumModuleInfos - 1]->module = module;
+ xf86ModuleInfoList[xf86NumModuleInfos - 1]->refCount = 0;
+}
+
+void
+xf86DeleteModuleInfo(int idx)
+{
+ if (xf86ModuleInfoList[idx]) {
+ if (xf86ModuleInfoList[idx]->module)
+ UnloadModule(xf86ModuleInfoList[idx]->module);
+ xfree(xf86ModuleInfoList[idx]);
+ xf86ModuleInfoList[idx] = NULL;
+ }
+}
+#endif
+
+
+/* Allocate a new ScrnInfoRec in xf86Screens */
+
+ScrnInfoPtr
+xf86AllocateScreen(DriverPtr drv, int flags)
+{
+ int i;
+
+ if (xf86Screens == NULL)
+ xf86NumScreens = 0;
+
+ i = xf86NumScreens++;
+ xf86Screens = xnfrealloc(xf86Screens, xf86NumScreens * sizeof(ScrnInfoPtr));
+ xf86Screens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1);
+ xf86Screens[i]->scrnIndex = i; /* Changes when a screen is removed */
+ xf86Screens[i]->origIndex = i; /* This never changes */
+ xf86Screens[i]->privates = xnfcalloc(sizeof(DevUnion),
+ xf86ScrnInfoPrivateCount);
+ /*
+ * EnableDisableFBAccess now gets initialized in InitOutput()
+ * xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess;
+ */
+
+ xf86Screens[i]->drv = drv;
+ drv->refCount++;
+#ifdef XFree86LOADER
+ xf86Screens[i]->module = DuplicateModule(drv->module, NULL);
+#else
+ xf86Screens[i]->module = NULL;
+#endif
+ /*
+ * set the initial access state. This will be modified after PreInit.
+ * XXX Or should we do it some other place?
+ */
+ xf86Screens[i]->CurrentAccess = &xf86CurrentAccess;
+ xf86Screens[i]->resourceType = MEM_IO;
+
+#ifdef DEBUG
+ /* OOps -- What's this ? */
+ ErrorF("xf86AllocateScreen - xf86Screens[%d]->pScreen = %p\n",
+ i, xf86Screens[i]->pScreen );
+ if ( NULL != xf86Screens[i]->pScreen ) {
+ ErrorF("xf86Screens[%d]->pScreen->CreateWindow = %p\n",
+ i, xf86Screens[i]->pScreen->CreateWindow );
+ }
+#endif
+
+ xf86Screens[i]->DriverFunc = drv->driverFunc;
+
+ return xf86Screens[i];
+}
+
+
+/*
+ * Remove an entry from xf86Screens. Ideally it should free all allocated
+ * data. To do this properly may require a driver hook.
+ */
+
+void
+xf86DeleteScreen(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn;
+ int i;
+
+ /* First check if the screen is valid */
+ if (xf86NumScreens == 0 || xf86Screens == NULL)
+ return;
+
+ if (scrnIndex > xf86NumScreens - 1)
+ return;
+
+ if (!(pScrn = xf86Screens[scrnIndex]))
+ return;
+
+ /* If a FreeScreen function is defined, call it here */
+ if (pScrn->FreeScreen != NULL)
+ pScrn->FreeScreen(scrnIndex, 0);
+
+ while (pScrn->modes)
+ xf86DeleteMode(&pScrn->modes, pScrn->modes);
+
+ while (pScrn->modePool)
+ xf86DeleteMode(&pScrn->modePool, pScrn->modePool);
+
+ xf86OptionListFree(pScrn->options);
+
+#ifdef XFree86LOADER
+ if (pScrn->module)
+ UnloadModule(pScrn->module);
+#endif
+
+ if (pScrn->drv)
+ pScrn->drv->refCount--;
+
+ if (pScrn->privates)
+ xfree(pScrn->privates);
+
+ xf86ClearEntityListForScreen(scrnIndex);
+
+ xfree(pScrn);
+
+ /* Move the other entries down, updating their scrnIndex fields */
+
+ xf86NumScreens--;
+
+ for (i = scrnIndex; i < xf86NumScreens; i++) {
+ xf86Screens[i] = xf86Screens[i + 1];
+ xf86Screens[i]->scrnIndex = i;
+ /* Also need to take care of the screen layout settings */
+ }
+}
+
+/*
+ * Allocate a private in ScrnInfoRec.
+ */
+
+int
+xf86AllocateScrnInfoPrivateIndex(void)
+{
+ int idx, i;
+ ScrnInfoPtr pScr;
+ DevUnion *nprivs;
+
+ idx = xf86ScrnInfoPrivateCount++;
+ for (i = 0; i < xf86NumScreens; i++) {
+ pScr = xf86Screens[i];
+ nprivs = xnfrealloc(pScr->privates,
+ xf86ScrnInfoPrivateCount * sizeof(DevUnion));
+ /* Zero the new private */
+ bzero(&nprivs[idx], sizeof(DevUnion));
+ pScr->privates = nprivs;
+ }
+ return idx;
+}
+
+/* Allocate a new InputInfoRec and add it to the head xf86InputDevs. */
+
+InputInfoPtr
+xf86AllocateInput(InputDriverPtr drv, int flags)
+{
+ InputInfoPtr new;
+
+ if (!(new = xcalloc(sizeof(InputInfoRec), 1)))
+ return NULL;
+
+ new->drv = drv;
+ drv->refCount++;
+#ifdef XFree86LOADER
+ new->module = DuplicateModule(drv->module, NULL);
+#else
+ new->module = NULL;
+#endif
+ new->next = xf86InputDevs;
+ xf86InputDevs = new;
+ return new;
+}
+
+
+/*
+ * Remove an entry from xf86InputDevs. Ideally it should free all allocated
+ * data. To do this properly may require a driver hook.
+ */
+
+void
+xf86DeleteInput(InputInfoPtr pInp, int flags)
+{
+ InputInfoPtr p;
+
+ /* First check if the inputdev is valid. */
+ if (pInp == NULL)
+ return;
+
+#if 0
+ /* If a free function is defined, call it here. */
+ if (pInp->free)
+ pInp->free(pInp, 0);
+#endif
+
+#ifdef XFree86LOADER
+ if (pInp->module)
+ UnloadModule(pInp->module);
+#endif
+
+ if (pInp->drv)
+ pInp->drv->refCount--;
+
+ if (pInp->private)
+ xfree(pInp->private);
+
+ /* Remove the entry from the list. */
+ if (pInp == xf86InputDevs)
+ xf86InputDevs = pInp->next;
+ else {
+ p = xf86InputDevs;
+ while (p && p->next != pInp)
+ p = p->next;
+ if (p)
+ p->next = pInp->next;
+ /* Else the entry wasn't in the xf86InputDevs list (ignore this). */
+ }
+ xfree(pInp);
+}
+
+Bool
+xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad)
+{
+ int i;
+
+ if (pScrn->numFormats >= MAXFORMATS)
+ return FALSE;
+
+ if (bpp <= 0) {
+ if (depth == 1)
+ bpp = 1;
+ else if (depth <= 8)
+ bpp = 8;
+ else if (depth <= 16)
+ bpp = 16;
+ else if (depth <= 32)
+ bpp = 32;
+ else
+ return FALSE;
+ }
+ if (pad <= 0)
+ pad = BITMAP_SCANLINE_PAD;
+
+ i = pScrn->numFormats++;
+ pScrn->formats[i].depth = depth;
+ pScrn->formats[i].bitsPerPixel = bpp;
+ pScrn->formats[i].scanlinePad = pad;
+ return TRUE;
+}
+
+/*
+ * Set the depth we are using based on (in the following order of preference):
+ * - values given on the command line
+ * - values given in the config file
+ * - values provided by the driver
+ * - an overall default when nothing else is given
+ *
+ * Also find a Display subsection matching the depth/bpp found.
+ *
+ * Sets the following ScrnInfoRec fields:
+ * bitsPerPixel, pixmap24, depth, display, imageByteOrder,
+ * bitmapScanlinePad, bitmapScanlineUnit, bitmapBitOrder, numFormats,
+ * formats, fbFormat.
+ */
+
+/* Can the screen handle 24 bpp pixmaps */
+#define DO_PIX24(f) ((f & Support24bppFb) || \
+ ((f & Support32bppFb) && (f & SupportConvert24to32)))
+
+/* Can the screen handle 32 bpp pixmaps */
+#define DO_PIX32(f) ((f & Support32bppFb) || \
+ ((f & Support24bppFb) && (f & SupportConvert32to24)))
+
+/* Does the screen prefer 32bpp fb for 24bpp pixmaps */
+#define CHOOSE32FOR24(f) ((f & Support32bppFb) && (f & SupportConvert24to32) \
+ && (f & PreferConvert24to32))
+
+/* Does the screen prefer 24bpp fb for 32bpp pixmaps */
+#define CHOOSE24FOR32(f) ((f & Support24bppFb) && (f & SupportConvert32to24) \
+ && (f & PreferConvert32to24))
+
+/* Can the screen handle 32bpp pixmaps for 24bpp fb */
+#define DO_PIX32FOR24(f) ((f & Support24bppFb) && (f & SupportConvert32to24))
+
+/* Can the screen handle 24bpp pixmaps for 32bpp fb */
+#define DO_PIX24FOR32(f) ((f & Support32bppFb) && (f & SupportConvert24to32))
+
+#ifndef GLOBAL_DEFAULT_DEPTH
+#define GLOBAL_DEFAULT_DEPTH 16
+#endif
+
+#ifndef GLOBAL_DEFAULT_FBBPP
+#define GLOBAL_DEFAULT_FBBPP 16
+#endif
+
+Bool
+xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp,
+ int depth24flags)
+{
+ int i;
+ DispPtr disp;
+ Pix24Flags pix24 = xf86Info.pixmap24;
+ Bool nomatch = FALSE;
+
+ scrp->bitsPerPixel = -1;
+ scrp->depth = -1;
+ scrp->pixmap24 = Pix24DontCare;
+ scrp->bitsPerPixelFrom = X_DEFAULT;
+ scrp->depthFrom = X_DEFAULT;
+
+#if BITMAP_SCANLINE_UNIT == 64
+ /*
+ * For platforms with 64-bit scanlines, modify the driver's depth24flags
+ * to remove preferences for packed 24bpp modes, which are not currently
+ * supported on these platforms.
+ */
+ depth24flags &= ~(SupportConvert32to24 | SupportConvert32to24 |
+ PreferConvert24to32 | PreferConvert32to24);
+#endif
+
+ if (xf86FbBpp > 0) {
+ scrp->bitsPerPixel = xf86FbBpp;
+ scrp->bitsPerPixelFrom = X_CMDLINE;
+ }
+
+ if (xf86Depth > 0) {
+ scrp->depth = xf86Depth;
+ scrp->depthFrom = X_CMDLINE;
+ }
+
+ if (xf86FbBpp < 0 && xf86Depth < 0) {
+ if (scrp->confScreen->defaultfbbpp > 0) {
+ scrp->bitsPerPixel = scrp->confScreen->defaultfbbpp;
+ scrp->bitsPerPixelFrom = X_CONFIG;
+ }
+ if (scrp->confScreen->defaultdepth > 0) {
+ scrp->depth = scrp->confScreen->defaultdepth;
+ scrp->depthFrom = X_CONFIG;
+ }
+
+ if (scrp->confScreen->defaultfbbpp <= 0 &&
+ scrp->confScreen->defaultdepth <= 0) {
+ /*
+ * Check for DefaultDepth and DefaultFbBpp options in the
+ * Device sections.
+ */
+ int i;
+ GDevPtr device;
+ Bool found = FALSE;
+
+ for (i = 0; i < scrp->numEntities; i++) {
+ device = xf86GetDevFromEntity(scrp->entityList[i],
+ scrp->entityInstanceList[i]);
+ if (device && device->options) {
+ if (xf86FindOption(device->options, "DefaultDepth")) {
+ scrp->depth = xf86SetIntOption(device->options,
+ "DefaultDepth", -1);
+ scrp->depthFrom = X_CONFIG;
+ found = TRUE;
+ }
+ if (xf86FindOption(device->options, "DefaultFbBpp")) {
+ scrp->bitsPerPixel = xf86SetIntOption(device->options,
+ "DefaultFbBpp",
+ -1);
+ scrp->bitsPerPixelFrom = X_CONFIG;
+ found = TRUE;
+ }
+ }
+ if (found)
+ break;
+ }
+ }
+ }
+
+ /* If none of these is set, pick a default */
+ if (scrp->bitsPerPixel < 0 && scrp->depth < 0) {
+ if (fbbpp > 0 || depth > 0) {
+ if (fbbpp > 0)
+ scrp->bitsPerPixel = fbbpp;
+ if (depth > 0)
+ scrp->depth = depth;
+ } else {
+ scrp->bitsPerPixel = GLOBAL_DEFAULT_FBBPP;
+ scrp->depth = GLOBAL_DEFAULT_DEPTH;
+ }
+ }
+
+ /* If any are not given, determine a default for the others */
+
+ if (scrp->bitsPerPixel < 0) {
+ /* The depth must be set */
+ if (scrp->depth > -1) {
+ if (scrp->depth == 1)
+ scrp->bitsPerPixel = 1;
+ else if (scrp->depth <= 4)
+ scrp->bitsPerPixel = 4;
+ else if (scrp->depth <= 8)
+ scrp->bitsPerPixel = 8;
+ else if (scrp->depth <= 16)
+ scrp->bitsPerPixel = 16;
+ else if (scrp->depth <= 24) {
+ /*
+ * Figure out if a choice is possible based on the depth24
+ * and pix24 flags.
+ */
+ /* Check pix24 first */
+ if (pix24 != Pix24DontCare) {
+ if (pix24 == Pix24Use32) {
+ if (DO_PIX32(depth24flags)) {
+ if (CHOOSE24FOR32(depth24flags))
+ scrp->bitsPerPixel = 24;
+ else
+ scrp->bitsPerPixel = 32;
+ } else {
+ nomatch = TRUE;
+ }
+ } else if (pix24 == Pix24Use24) {
+ if (DO_PIX24(depth24flags)) {
+ if (CHOOSE32FOR24(depth24flags))
+ scrp->bitsPerPixel = 32;
+ else
+ scrp->bitsPerPixel = 24;
+ } else {
+ nomatch = TRUE;
+ }
+ }
+ } else {
+ if (DO_PIX32(depth24flags)) {
+ if (CHOOSE24FOR32(depth24flags))
+ scrp->bitsPerPixel = 24;
+ else
+ scrp->bitsPerPixel = 32;
+ } else if (DO_PIX24(depth24flags)) {
+ if (CHOOSE32FOR24(depth24flags))
+ scrp->bitsPerPixel = 32;
+ else
+ scrp->bitsPerPixel = 24;
+ }
+ }
+ } else if (scrp->depth <= 32)
+ scrp->bitsPerPixel = 32;
+ else {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Specified depth (%d) is greater than 32\n",
+ scrp->depth);
+ return FALSE;
+ }
+ } else {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "xf86SetDepthBpp: internal error: depth and fbbpp"
+ " are both not set\n");
+ return FALSE;
+ }
+ if (scrp->bitsPerPixel < 0) {
+ if (nomatch)
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Driver can't support depth 24 pixmap format (%d)\n",
+ PIX24TOBPP(pix24));
+ else if ((depth24flags & (Support24bppFb | Support32bppFb)) ==
+ NoDepth24Support)
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Driver can't support depth 24\n");
+ else
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Can't find fbbpp for depth 24\n");
+ return FALSE;
+ }
+ scrp->bitsPerPixelFrom = X_PROBED;
+ }
+
+ if (scrp->depth <= 0) {
+ /* bitsPerPixel is already set */
+ switch (scrp->bitsPerPixel) {
+ case 32:
+ scrp->depth = 24;
+ break;
+ default:
+ /* 1, 4, 8, 16 and 24 */
+ scrp->depth = scrp->bitsPerPixel;
+ break;
+ }
+ scrp->depthFrom = X_PROBED;
+ }
+
+ /* Sanity checks */
+ if (scrp->depth < 1 || scrp->depth > 32) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Specified depth (%d) is not in the range 1-32\n",
+ scrp->depth);
+ return FALSE;
+ }
+ switch (scrp->bitsPerPixel) {
+ case 1:
+ case 4:
+ case 8:
+ case 16:
+ case 24:
+ case 32:
+ break;
+ default:
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Specified fbbpp (%d) is not a permitted value\n",
+ scrp->bitsPerPixel);
+ return FALSE;
+ }
+ if (scrp->depth > scrp->bitsPerPixel) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Specified depth (%d) is greater than the fbbpp (%d)\n",
+ scrp->depth, scrp->bitsPerPixel);
+ return FALSE;
+ }
+
+ /* set scrp->pixmap24 if the driver isn't flexible */
+ if (scrp->bitsPerPixel == 24 && !DO_PIX32FOR24(depth24flags)) {
+ scrp->pixmap24 = Pix24Use24;
+ }
+ if (scrp->bitsPerPixel == 32 && !DO_PIX24FOR32(depth24flags)) {
+ scrp->pixmap24 = Pix24Use32;
+ }
+
+ /*
+ * Find the Display subsection matching the depth/fbbpp and initialise
+ * scrp->display with it.
+ */
+ for (i = 0, disp = scrp->confScreen->displays;
+ i < scrp->confScreen->numdisplays; i++, disp++) {
+ if ((disp->depth == scrp->depth && disp->fbbpp == scrp->bitsPerPixel)
+ || (disp->depth == scrp->depth && disp->fbbpp <= 0)
+ || (disp->fbbpp == scrp->bitsPerPixel && disp->depth <= 0)) {
+ scrp->display = disp;
+ break;
+ }
+ }
+
+ /*
+ * If an exact match can't be found, see if there is one with no
+ * depth or fbbpp specified.
+ */
+ if (i == scrp->confScreen->numdisplays) {
+ for (i = 0, disp = scrp->confScreen->displays;
+ i < scrp->confScreen->numdisplays; i++, disp++) {
+ if (disp->depth <= 0 && disp->fbbpp <= 0) {
+ scrp->display = disp;
+ break;
+ }
+ }
+ }
+
+ /*
+ * If all else fails, create a default one.
+ */
+ if (i == scrp->confScreen->numdisplays) {
+ scrp->confScreen->numdisplays++;
+ scrp->confScreen->displays =
+ xnfrealloc(scrp->confScreen->displays,
+ scrp->confScreen->numdisplays * sizeof(DispRec));
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Creating default Display subsection in Screen section\n"
+ "\t\"%s\" for depth/fbbpp %d/%d\n",
+ scrp->confScreen->id, scrp->depth, scrp->bitsPerPixel);
+ memset(&scrp->confScreen->displays[i], 0, sizeof(DispRec));
+ scrp->confScreen->displays[i].blackColour.red = -1;
+ scrp->confScreen->displays[i].blackColour.green = -1;
+ scrp->confScreen->displays[i].blackColour.blue = -1;
+ scrp->confScreen->displays[i].whiteColour.red = -1;
+ scrp->confScreen->displays[i].whiteColour.green = -1;
+ scrp->confScreen->displays[i].whiteColour.blue = -1;
+ scrp->confScreen->displays[i].defaultVisual = -1;
+ scrp->confScreen->displays[i].modes = xnfalloc(sizeof(char *));
+ scrp->confScreen->displays[i].modes[0] = NULL;
+ scrp->confScreen->displays[i].depth = depth;
+ scrp->confScreen->displays[i].fbbpp = fbbpp;
+ scrp->display = &scrp->confScreen->displays[i];
+ }
+
+ /*
+ * Setup defaults for the display-wide attributes the framebuffer will
+ * need. These defaults should eventually be set globally, and not
+ * dependent on the screens.
+ */
+ scrp->imageByteOrder = IMAGE_BYTE_ORDER;
+ scrp->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ if (scrp->depth < 8) {
+ /* Planar modes need these settings */
+ scrp->bitmapScanlineUnit = 8;
+ scrp->bitmapBitOrder = MSBFirst;
+ } else {
+ scrp->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ scrp->bitmapBitOrder = BITMAP_BIT_ORDER;
+ }
+
+ /*
+ * If an unusual depth is required, add it to scrp->formats. The formats
+ * for the common depths are handled globally in InitOutput
+ */
+ switch (scrp->depth) {
+ case 1:
+ case 4:
+ case 8:
+ case 15:
+ case 16:
+ case 24:
+ /* Common depths. Nothing to do for them */
+ break;
+ default:
+ if (!xf86AddPixFormat(scrp, scrp->depth, 0, 0)) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Can't add pixmap format for depth %d\n", scrp->depth);
+ return FALSE;
+ }
+ }
+
+ /* Initialise the framebuffer format for this screen */
+ scrp->fbFormat.depth = scrp->depth;
+ scrp->fbFormat.bitsPerPixel = scrp->bitsPerPixel;
+ scrp->fbFormat.scanlinePad = BITMAP_SCANLINE_PAD;
+
+ return TRUE;
+}
+
+/*
+ * Print out the selected depth and bpp.
+ */
+void
+xf86PrintDepthBpp(ScrnInfoPtr scrp)
+{
+ xf86DrvMsg(scrp->scrnIndex, scrp->depthFrom, "Depth %d, ", scrp->depth);
+ xf86Msg(scrp->bitsPerPixelFrom, "framebuffer bpp %d\n", scrp->bitsPerPixel);
+}
+
+/*
+ * xf86SetWeight sets scrp->weight, scrp->mask, scrp->offset, and for depths
+ * greater than MAX_PSEUDO_DEPTH also scrp->rgbBits.
+ */
+Bool
+xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask)
+{
+ MessageType weightFrom = X_DEFAULT;
+
+ scrp->weight.red = 0;
+ scrp->weight.green = 0;
+ scrp->weight.blue = 0;
+
+ if (xf86Weight.red > 0 && xf86Weight.green > 0 && xf86Weight.blue > 0) {
+ scrp->weight = xf86Weight;
+ weightFrom = X_CMDLINE;
+ } else if (scrp->display->weight.red > 0 && scrp->display->weight.green > 0
+ && scrp->display->weight.blue > 0) {
+ scrp->weight = scrp->display->weight;
+ weightFrom = X_CONFIG;
+ } else if (weight.red > 0 && weight.green > 0 && weight.blue > 0) {
+ scrp->weight = weight;
+ } else {
+ switch (scrp->depth) {
+ case 1:
+ case 4:
+ case 8:
+ scrp->weight.red = scrp->weight.green =
+ scrp->weight.blue = scrp->rgbBits;
+ break;
+ case 15:
+ scrp->weight.red = scrp->weight.green = scrp->weight.blue = 5;
+ break;
+ case 16:
+ scrp->weight.red = scrp->weight.blue = 5;
+ scrp->weight.green = 6;
+ break;
+ case 24:
+ scrp->weight.red = scrp->weight.green = scrp->weight.blue = 8;
+ break;
+ case 30:
+ scrp->weight.red = scrp->weight.green = scrp->weight.blue = 10;
+ break;
+ }
+ }
+
+ if (scrp->weight.red)
+ xf86DrvMsg(scrp->scrnIndex, weightFrom, "RGB weight %d%d%d\n",
+ (int)scrp->weight.red, (int)scrp->weight.green,
+ (int)scrp->weight.blue);
+
+ if (scrp->depth > MAX_PSEUDO_DEPTH &&
+ (scrp->depth != scrp->weight.red + scrp->weight.green +
+ scrp->weight.blue)) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Weight given (%d%d%d) is inconsistent with the "
+ "depth (%d)\n",
+ (int)scrp->weight.red, (int)scrp->weight.green,
+ (int)scrp->weight.blue, scrp->depth);
+ return FALSE;
+ }
+ if (scrp->depth > MAX_PSEUDO_DEPTH && scrp->weight.red) {
+ /*
+ * XXX Does this even mean anything for TrueColor visuals?
+ * If not, we shouldn't even be setting it here. However, this
+ * matches the behaviour of 3.x versions of XFree86.
+ */
+ scrp->rgbBits = scrp->weight.red;
+ if (scrp->weight.green > scrp->rgbBits)
+ scrp->rgbBits = scrp->weight.green;
+ if (scrp->weight.blue > scrp->rgbBits)
+ scrp->rgbBits = scrp->weight.blue;
+ }
+
+ /* Set the mask and offsets */
+ if (mask.red == 0 || mask.green == 0 || mask.blue == 0) {
+ /* Default to a setting common to PC hardware */
+ scrp->offset.red = scrp->weight.green + scrp->weight.blue;
+ scrp->offset.green = scrp->weight.blue;
+ scrp->offset.blue = 0;
+ scrp->mask.red = ((1 << scrp->weight.red) - 1) << scrp->offset.red;
+ scrp->mask.green = ((1 << scrp->weight.green) - 1)
+ << scrp->offset.green;
+ scrp->mask.blue = (1 << scrp->weight.blue) - 1;
+ } else {
+ /* Initialise to the values passed */
+ scrp->mask.red = mask.red;
+ scrp->mask.green = mask.green;
+ scrp->mask.blue = mask.blue;
+ scrp->offset.red = ffs(mask.red);
+ scrp->offset.green = ffs(mask.green);
+ scrp->offset.blue = ffs(mask.blue);
+ }
+ return TRUE;
+}
+
+Bool
+xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual)
+{
+ MessageType visualFrom = X_DEFAULT;
+
+ if (defaultColorVisualClass >= 0) {
+ scrp->defaultVisual = defaultColorVisualClass;
+ visualFrom = X_CMDLINE;
+ } else if (scrp->display->defaultVisual >= 0) {
+ scrp->defaultVisual = scrp->display->defaultVisual;
+ visualFrom = X_CONFIG;
+ } else if (visual >= 0) {
+ scrp->defaultVisual = visual;
+ } else {
+ if (scrp->depth == 1)
+ scrp->defaultVisual = StaticGray;
+ else if (scrp->depth == 4)
+ scrp->defaultVisual = StaticColor;
+ else if (scrp->depth <= MAX_PSEUDO_DEPTH)
+ scrp->defaultVisual = PseudoColor;
+ else
+ scrp->defaultVisual = TrueColor;
+ }
+ switch (scrp->defaultVisual) {
+ case StaticGray:
+ case GrayScale:
+ case StaticColor:
+ case PseudoColor:
+ case TrueColor:
+ case DirectColor:
+ xf86DrvMsg(scrp->scrnIndex, visualFrom, "Default visual is %s\n",
+ xf86VisualNames[scrp->defaultVisual]);
+ return TRUE;
+ default:
+
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Invalid default visual class (%d)\n", scrp->defaultVisual);
+ return FALSE;
+ }
+}
+
+#define TEST_GAMMA(g) \
+ (g).red > GAMMA_ZERO || (g).green > GAMMA_ZERO || (g).blue > GAMMA_ZERO
+
+#define SET_GAMMA(g) \
+ (g) > GAMMA_ZERO ? (g) : 1.0
+
+Bool
+xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma)
+{
+ MessageType from = X_DEFAULT;
+#if 0
+ xf86MonPtr DDC = (xf86MonPtr)(scrp->monitor->DDC);
+#endif
+ if (TEST_GAMMA(xf86Gamma)) {
+ from = X_CMDLINE;
+ scrp->gamma.red = SET_GAMMA(xf86Gamma.red);
+ scrp->gamma.green = SET_GAMMA(xf86Gamma.green);
+ scrp->gamma.blue = SET_GAMMA(xf86Gamma.blue);
+ } else if (TEST_GAMMA(scrp->monitor->gamma)) {
+ from = X_CONFIG;
+ scrp->gamma.red = SET_GAMMA(scrp->monitor->gamma.red);
+ scrp->gamma.green = SET_GAMMA(scrp->monitor->gamma.green);
+ scrp->gamma.blue = SET_GAMMA(scrp->monitor->gamma.blue);
+#if 0
+ } else if ( DDC && DDC->features.gamma > GAMMA_ZERO ) {
+ from = X_PROBED;
+ scrp->gamma.red = SET_GAMMA(DDC->features.gamma);
+ scrp->gamma.green = SET_GAMMA(DDC->features.gamma);
+ scrp->gamma.blue = SET_GAMMA(DDC->features.gamma);
+ /* EDID structure version 2 gives optional seperate red, green & blue gamma values
+ * in bytes 0x57-0x59 */
+#endif
+ } else if (TEST_GAMMA(gamma)) {
+ scrp->gamma.red = SET_GAMMA(gamma.red);
+ scrp->gamma.green = SET_GAMMA(gamma.green);
+ scrp->gamma.blue = SET_GAMMA(gamma.blue);
+ } else {
+ scrp->gamma.red = 1.0;
+ scrp->gamma.green = 1.0;
+ scrp->gamma.blue = 1.0;
+ }
+ xf86DrvMsg(scrp->scrnIndex, from,
+ "Using gamma correction (%.1f, %.1f, %.1f)\n",
+ scrp->gamma.red, scrp->gamma.green, scrp->gamma.blue);
+
+ return TRUE;
+}
+
+#undef TEST_GAMMA
+#undef SET_GAMMA
+
+
+/*
+ * Set the DPI from the command line option. XXX should allow it to be
+ * calculated from the widthmm/heightmm values.
+ */
+
+#undef MMPERINCH
+#define MMPERINCH 25.4
+
+void
+xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
+{
+ MessageType from = X_DEFAULT;
+ xf86MonPtr DDC = (xf86MonPtr)(pScrn->monitor->DDC);
+ int ddcWidthmm, ddcHeightmm;
+ int widthErr, heightErr;
+
+ /* XXX Maybe there is no need for widthmm/heightmm in ScrnInfoRec */
+ pScrn->widthmm = pScrn->monitor->widthmm;
+ pScrn->heightmm = pScrn->monitor->heightmm;
+
+ if (DDC && (DDC->features.hsize > 0 && DDC->features.vsize > 0) ) {
+ /* DDC gives display size in mm for individual modes,
+ * but cm for monitor
+ */
+ ddcWidthmm = DDC->features.hsize * 10; /* 10mm in 1cm */
+ ddcHeightmm = DDC->features.vsize * 10; /* 10mm in 1cm */
+ } else {
+ ddcWidthmm = ddcHeightmm = 0;
+ }
+
+ if (monitorResolution > 0) {
+ pScrn->xDpi = monitorResolution;
+ pScrn->yDpi = monitorResolution;
+ from = X_CMDLINE;
+ } else if (pScrn->widthmm > 0 || pScrn->heightmm > 0) {
+ from = X_CONFIG;
+ if (pScrn->widthmm > 0) {
+ pScrn->xDpi =
+ (int)((double)pScrn->virtualX * MMPERINCH / pScrn->widthmm);
+ }
+ if (pScrn->heightmm > 0) {
+ pScrn->yDpi =
+ (int)((double)pScrn->virtualY * MMPERINCH / pScrn->heightmm);
+ }
+ if (pScrn->xDpi > 0 && pScrn->yDpi <= 0)
+ pScrn->yDpi = pScrn->xDpi;
+ if (pScrn->yDpi > 0 && pScrn->xDpi <= 0)
+ pScrn->xDpi = pScrn->yDpi;
+ xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n",
+ pScrn->widthmm, pScrn->heightmm);
+
+ /* Warn if config and probe disagree about display size */
+ if ( ddcWidthmm && ddcHeightmm ) {
+ if (pScrn->widthmm > 0) {
+ widthErr = abs(ddcWidthmm - pScrn->widthmm);
+ } else {
+ widthErr = 0;
+ }
+ if (pScrn->heightmm > 0) {
+ heightErr = abs(ddcHeightmm - pScrn->heightmm);
+ } else {
+ heightErr = 0;
+ }
+ if (widthErr>10 || heightErr>10) {
+ /* Should include config file name for monitor here */
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Probed monitor is %dx%d mm, using Displaysize %dx%d mm\n",
+ ddcWidthmm,ddcHeightmm, pScrn->widthmm,pScrn->heightmm);
+ }
+ }
+ } else if ( ddcWidthmm && ddcHeightmm ) {
+ from = X_PROBED;
+ xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n",
+ ddcWidthmm, ddcHeightmm );
+ pScrn->widthmm = ddcWidthmm;
+ pScrn->heightmm = ddcHeightmm;
+ if (pScrn->widthmm > 0) {
+ pScrn->xDpi =
+ (int)((double)pScrn->virtualX * MMPERINCH / pScrn->widthmm);
+ }
+ if (pScrn->heightmm > 0) {
+ pScrn->yDpi =
+ (int)((double)pScrn->virtualY * MMPERINCH / pScrn->heightmm);
+ }
+ if (pScrn->xDpi > 0 && pScrn->yDpi <= 0)
+ pScrn->yDpi = pScrn->xDpi;
+ if (pScrn->yDpi > 0 && pScrn->xDpi <= 0)
+ pScrn->xDpi = pScrn->yDpi;
+ } else {
+ if (x > 0)
+ pScrn->xDpi = x;
+ else
+ pScrn->xDpi = DEFAULT_DPI;
+ if (y > 0)
+ pScrn->yDpi = y;
+ else
+ pScrn->yDpi = DEFAULT_DPI;
+ }
+ xf86DrvMsg(pScrn->scrnIndex, from, "DPI set to (%d, %d)\n",
+ pScrn->xDpi, pScrn->yDpi);
+}
+
+#undef MMPERINCH
+
+
+void
+xf86SetBlackWhitePixels(ScreenPtr pScreen)
+{
+ if (xf86FlipPixels) {
+ pScreen->whitePixel = 0;
+ pScreen->blackPixel = 1;
+ } else {
+ pScreen->whitePixel = 1;
+ pScreen->blackPixel = 0;
+ }
+}
+
+/*
+ * xf86SetRootClip --
+ * Enable or disable rendering to the screen by
+ * setting the root clip list and revalidating
+ * all of the windows
+ */
+
+static void
+xf86SetRootClip (ScreenPtr pScreen, Bool enable)
+{
+ WindowPtr pWin = WindowTable[pScreen->myNum];
+ WindowPtr pChild;
+ Bool WasViewable = (Bool)(pWin->viewable);
+ Bool anyMarked = FALSE;
+ RegionPtr pOldClip = NULL, bsExposed;
+#ifdef DO_SAVE_UNDERS
+ Bool dosave = FALSE;
+#endif
+ WindowPtr pLayerWin;
+ BoxRec box;
+
+ if (WasViewable)
+ {
+ for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
+ {
+ (void) (*pScreen->MarkOverlappedWindows)(pChild,
+ pChild,
+ &pLayerWin);
+ }
+ (*pScreen->MarkWindow) (pWin);
+ anyMarked = TRUE;
+ if (pWin->valdata)
+ {
+ if (HasBorder (pWin))
+ {
+ RegionPtr borderVisible;
+
+ borderVisible = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_SUBTRACT(pScreen, borderVisible,
+ &pWin->borderClip, &pWin->winSize);
+ pWin->valdata->before.borderVisible = borderVisible;
+ }
+ pWin->valdata->before.resized = TRUE;
+ }
+ }
+
+ /*
+ * Use REGION_BREAK to avoid optimizations in ValidateTree
+ * that assume the root borderClip can't change well, normally
+ * it doesn't...)
+ */
+ if (enable)
+ {
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pScreen->width;
+ box.y2 = pScreen->height;
+ REGION_INIT (pScreen, &pWin->winSize, &box, 1);
+ REGION_INIT (pScreen, &pWin->borderSize, &box, 1);
+ if (WasViewable)
+ REGION_RESET(pScreen, &pWin->borderClip, &box);
+ pWin->drawable.width = pScreen->width;
+ pWin->drawable.height = pScreen->height;
+ REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+ }
+ else
+ {
+ REGION_EMPTY(pScreen, &pWin->borderClip);
+ REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+ }
+
+ ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
+
+ if (WasViewable)
+ {
+ if (pWin->backStorage)
+ {
+ pOldClip = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_COPY(pScreen, pOldClip, &pWin->clipList);
+ }
+
+ if (pWin->firstChild)
+ {
+ anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild,
+ pWin->firstChild,
+ (WindowPtr *)NULL);
+ }
+ else
+ {
+ (*pScreen->MarkWindow) (pWin);
+ anyMarked = TRUE;
+ }
+
+#ifdef DO_SAVE_UNDERS
+ if (DO_SAVE_UNDERS(pWin))
+ {
+ dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin);
+ }
+#endif /* DO_SAVE_UNDERS */
+
+ if (anyMarked)
+ (*pScreen->ValidateTree)(pWin, NullWindow, VTOther);
+ }
+
+ if (pWin->backStorage &&
+ ((pWin->backingStore == Always) || WasViewable))
+ {
+ if (!WasViewable)
+ pOldClip = &pWin->clipList; /* a convenient empty region */
+ bsExposed = (*pScreen->TranslateBackingStore)
+ (pWin, 0, 0, pOldClip,
+ pWin->drawable.x, pWin->drawable.y);
+ if (WasViewable)
+ REGION_DESTROY(pScreen, pOldClip);
+ if (bsExposed)
+ {
+ RegionPtr valExposed = NullRegion;
+
+ if (pWin->valdata)
+ valExposed = &pWin->valdata->after.exposed;
+ (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
+ if (valExposed)
+ REGION_EMPTY(pScreen, valExposed);
+ REGION_DESTROY(pScreen, bsExposed);
+ }
+ }
+ if (WasViewable)
+ {
+ if (anyMarked)
+ (*pScreen->HandleExposures)(pWin);
+#ifdef DO_SAVE_UNDERS
+ if (dosave)
+ (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin);
+#endif /* DO_SAVE_UNDERS */
+ if (anyMarked && pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pWin, NullWindow, VTOther);
+ }
+ if (pWin->realized)
+ WindowsRestructured ();
+ FlushAllOutput ();
+}
+
+/*
+ * Function to enable/disable access to the frame buffer
+ *
+ * This is used when VT switching and when entering/leaving DGA direct mode.
+ *
+ * This has been rewritten again to eliminate the saved pixmap. The
+ * devPrivate field in the screen pixmap is set to NULL to catch code
+ * accidentally referencing the frame buffer while the X server is not
+ * supposed to touch it.
+ *
+ * Here, we exchange the pixmap private data, rather than the pixmaps
+ * themselves to avoid having to find and change any references to the screen
+ * pixmap such as GC's, window privates etc. This also means that this code
+ * does not need to know exactly how the pixmap pixels are accessed. Further,
+ * this exchange is >not< done through the screen's ModifyPixmapHeader()
+ * vector. This means the called frame buffer code layers can determine
+ * whether they are switched in or out by keeping track of the root pixmap's
+ * private data, and therefore don't need to access pScrnInfo->vtSema.
+ */
+void
+xf86EnableDisableFBAccess(int scrnIndex, Bool enable)
+{
+ ScrnInfoPtr pScrnInfo = xf86Screens[scrnIndex];
+ ScreenPtr pScreen = pScrnInfo->pScreen;
+ PixmapPtr pspix;
+
+ pspix = (*pScreen->GetScreenPixmap) (pScreen);
+ if (enable)
+ {
+ /*
+ * Restore the screen pixmap devPrivate field
+ */
+ pspix->devPrivate = pScrnInfo->pixmapPrivate;
+ /*
+ * Restore all of the clip lists on the screen
+ */
+ if (!xf86Resetting)
+ xf86SetRootClip (pScreen, TRUE);
+
+ }
+ else
+ {
+ /*
+ * Empty all of the clip lists on the screen
+ */
+ xf86SetRootClip (pScreen, FALSE);
+ /*
+ * save the screen pixmap devPrivate field and
+ * replace it with NULL so accidental references
+ * to the frame buffer are caught
+ */
+ pScrnInfo->pixmapPrivate = pspix->devPrivate;
+ pspix->devPrivate.ptr = NULL;
+ }
+}
+
+/* Print driver messages in the standard format */
+
+#undef PREFIX_SIZE
+#define PREFIX_SIZE 14
+
+void
+xf86VDrvMsgVerb(int scrnIndex, MessageType type, int verb, const char *format,
+ va_list args)
+{
+ char *tmpFormat;
+
+ /* Prefix the scrnIndex name to the format string. */
+ if (scrnIndex >= 0 && scrnIndex < xf86NumScreens &&
+ xf86Screens[scrnIndex]->name) {
+ tmpFormat = xalloc(strlen(format) +
+ strlen(xf86Screens[scrnIndex]->name) +
+ PREFIX_SIZE + 1);
+ if (!tmpFormat)
+ return;
+
+ snprintf(tmpFormat, PREFIX_SIZE + 1, "%s(%d): ",
+ xf86Screens[scrnIndex]->name, scrnIndex);
+
+ strcat(tmpFormat, format);
+ LogVMessageVerb(type, verb, tmpFormat, args);
+ xfree(tmpFormat);
+ } else
+ LogVMessageVerb(type, verb, format, args);
+}
+#undef PREFIX_SIZE
+
+/* Print driver messages, with verbose level specified directly */
+void
+xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb, const char *format,
+ ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ xf86VDrvMsgVerb(scrnIndex, type, verb, format, ap);
+ va_end(ap);
+}
+
+/* Print driver messages, with verbose level of 1 (default) */
+void
+xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ xf86VDrvMsgVerb(scrnIndex, type, 1, format, ap);
+ va_end(ap);
+}
+
+/* Print non-driver messages with verbose level specified directly */
+void
+xf86MsgVerb(MessageType type, int verb, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ xf86VDrvMsgVerb(-1, type, verb, format, ap);
+ va_end(ap);
+}
+
+/* Print non-driver messages with verbose level of 1 (default) */
+void
+xf86Msg(MessageType type, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ xf86VDrvMsgVerb(-1, type, 1, format, ap);
+ va_end(ap);
+}
+
+/* Just like ErrorF, but with the verbose level checked */
+void
+xf86ErrorFVerb(int verb, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (xf86Verbose >= verb || xf86LogVerbose >= verb)
+ LogVWrite(verb, format, ap);
+ va_end(ap);
+}
+
+/* Like xf86ErrorFVerb, but with an implied verbose level of 1 */
+void
+xf86ErrorF(const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (xf86Verbose >= 1 || xf86LogVerbose >= 1)
+ LogVWrite(1, format, ap);
+ va_end(ap);
+}
+
+
+void
+xf86LogInit()
+{
+ char *lf;
+
+#define LOGSUFFIX ".log"
+#define LOGOLDSUFFIX ".old"
+
+ /* Get the log file name */
+ if (xf86LogFileFrom == X_DEFAULT) {
+ /* Append the display number and ".log" */
+ lf = malloc(strlen(xf86LogFile) + strlen("%s") +
+ strlen(LOGSUFFIX) + 1);
+ if (!lf)
+ FatalError("Cannot allocate space for the log file name\n");
+ sprintf(lf, "%s%%s" LOGSUFFIX, xf86LogFile);
+ xf86LogFile = lf;
+ }
+
+ xf86LogFile = LogInit(xf86LogFile, LOGOLDSUFFIX);
+ xf86LogFileWasOpened = TRUE;
+
+ xf86SetVerbosity(xf86Verbose);
+ xf86SetLogVerbosity(xf86LogVerbose);
+
+#undef LOGSUFFIX
+#undef LOGOLDSUFFIX
+}
+
+void
+xf86CloseLog()
+{
+ LogClose();
+}
+
+
+/*
+ * Drivers can use these for using their own SymTabRecs.
+ */
+
+const char *
+xf86TokenToString(SymTabPtr table, int token)
+{
+ int i;
+
+ for (i = 0; table[i].token >= 0 && table[i].token != token; i++)
+ ;
+
+ if (table[i].token < 0)
+ return NULL;
+ else
+ return(table[i].name);
+}
+
+int
+xf86StringToToken(SymTabPtr table, const char *string)
+{
+ int i;
+
+ if (string == NULL)
+ return -1;
+
+ for (i = 0; table[i].token >= 0 && xf86NameCmp(string, table[i].name); i++)
+ ;
+
+ return(table[i].token);
+}
+
+/*
+ * helper to display the clocks found on a card
+ */
+void
+xf86ShowClocks(ScrnInfoPtr scrp, MessageType from)
+{
+ int j;
+
+ xf86DrvMsg(scrp->scrnIndex, from, "Pixel clocks available:");
+ for (j=0; j < scrp->numClocks; j++) {
+ if ((j % 4) == 0) {
+ xf86ErrorF("\n");
+ xf86DrvMsg(scrp->scrnIndex, from, "pixel clocks:");
+ }
+ xf86ErrorF(" %7.3f", (double)scrp->clock[j] / 1000.0);
+ }
+ xf86ErrorF("\n");
+}
+
+
+/*
+ * This prints out the driver identify message, including the names of
+ * the supported chipsets.
+ *
+ * XXX This makes assumptions about the line width, etc. Maybe we could
+ * use a more general "pretty print" function for messages.
+ */
+void
+xf86PrintChipsets(const char *drvname, const char *drvmsg, SymTabPtr chips)
+{
+ int len, i;
+
+ len = 6 + strlen(drvname) + 2 + strlen(drvmsg) + 2;
+ xf86Msg(X_INFO, "%s: %s:", drvname, drvmsg);
+ for (i = 0; chips[i].name != NULL; i++) {
+ if (i != 0) {
+ xf86ErrorF(",");
+ len++;
+ }
+ if (len + 2 + strlen(chips[i].name) < 78) {
+ xf86ErrorF(" ");
+ len++;
+ } else {
+ xf86ErrorF("\n\t");
+ len = 8;
+ }
+ xf86ErrorF("%s", chips[i].name);
+ len += strlen(chips[i].name);
+ }
+ xf86ErrorF("\n");
+}
+
+
+#define MAXDRIVERS 64 /* A >hack<, to be sure ... */
+
+
+int
+xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
+{
+ GDevPtr gdp, *pgdp = NULL;
+ confScreenPtr screensecptr;
+ int i,j;
+
+ if (sectlist)
+ *sectlist = NULL;
+
+ if (xf86DoProbe) return 1;
+
+ if (xf86DoConfigure && xf86DoConfigurePass1) return 1;
+
+ /*
+ * This is a very important function that matches the device sections
+ * as they show up in the config file with the drivers that the server
+ * loads at run time.
+ *
+ * ChipProbe can call
+ * int xf86MatchDevice(char * drivername, GDevPtr ** sectlist)
+ * with its driver name. The function allocates an array of GDevPtr and
+ * returns this via sectlist and returns the number of elements in
+ * this list as return value. 0 means none found, -1 means fatal error.
+ *
+ * It can figure out which of the Device sections to use for which card
+ * (using things like the Card statement, etc). For single headed servers
+ * there will of course be just one such Device section.
+ */
+ i = 0;
+
+ /*
+ * first we need to loop over all the Screens sections to get to all
+ * 'active' device sections
+ */
+ for (j=0; xf86ConfigLayout.screens[j].screen != NULL; j++) {
+ screensecptr = xf86ConfigLayout.screens[j].screen;
+ if ((screensecptr->device->driver != NULL)
+ && (xf86NameCmp( screensecptr->device->driver,drivername) == 0)
+ && (! screensecptr->device->claimed)) {
+ /*
+ * we have a matching driver that wasn't claimed, yet
+ */
+ pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr));
+ pgdp[i++] = screensecptr->device;
+ }
+ }
+
+ /* Then handle the inactive devices */
+ j = 0;
+ while (xf86ConfigLayout.inactives[j].identifier) {
+ gdp = &xf86ConfigLayout.inactives[j];
+ if (gdp->driver && !gdp->claimed &&
+ !xf86NameCmp(gdp->driver,drivername)) {
+ /* we have a matching driver that wasn't claimed yet */
+ pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr));
+ pgdp[i++] = gdp;
+ }
+ j++;
+ }
+
+ /*
+ * make the array NULL terminated and return its address
+ */
+ if (i)
+ pgdp[i] = NULL;
+
+ if (sectlist)
+ *sectlist = pgdp;
+ else
+ xfree(pgdp);
+ return i;
+}
+
+struct Inst {
+ pciVideoPtr pci;
+ GDevPtr dev;
+ Bool foundHW; /* PCIid in list of supported chipsets */
+ Bool claimed; /* BusID matches with a device section */
+ int chip;
+ int screen;
+};
+
+int
+xf86MatchPciInstances(const char *driverName, int vendorID,
+ SymTabPtr chipsets, PciChipsets *PCIchipsets,
+ GDevPtr *devList, int numDevs, DriverPtr drvp,
+ int **foundEntities)
+{
+ int i,j;
+ MessageType from;
+ pciVideoPtr pPci, *ppPci;
+ struct Inst {
+ pciVideoPtr pci;
+ GDevPtr dev;
+ Bool foundHW; /* PCIid in list of supported chipsets */
+ Bool claimed; /* BusID matches with a device section */
+ int chip;
+ int screen;
+ } *instances = NULL;
+ int numClaimedInstances = 0;
+ int allocatedInstances = 0;
+ int numFound = 0;
+ SymTabRec *c;
+ PciChipsets *id;
+ GDevPtr devBus = NULL;
+ GDevPtr dev = NULL;
+ int *retEntities = NULL;
+
+ *foundEntities = NULL;
+
+ if (vendorID == 0) {
+ for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) {
+ Bool foundVendor = FALSE;
+ for (id = PCIchipsets; id->PCIid != -1; id++) {
+ if ( (((id->PCIid & 0xFFFF0000) >> 16) == (*ppPci)->vendor)) {
+ if (!foundVendor) {
+ ++allocatedInstances;
+ instances = xnfrealloc(instances,
+ allocatedInstances * sizeof(struct Inst));
+ instances[allocatedInstances - 1].pci = *ppPci;
+ instances[allocatedInstances - 1].dev = NULL;
+ instances[allocatedInstances - 1].claimed = FALSE;
+ instances[allocatedInstances - 1].foundHW = FALSE;
+ instances[allocatedInstances - 1].screen = 0;
+ foundVendor = TRUE;
+ }
+ if ((id->PCIid & 0x0000FFFF) == (*ppPci)->chipType) {
+ instances[allocatedInstances - 1].foundHW = TRUE;
+ instances[allocatedInstances - 1].chip = id->numChipset;
+ numFound++;
+ }
+ }
+ }
+ }
+ } else if (vendorID == PCI_VENDOR_GENERIC) {
+ for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) {
+ for (id = PCIchipsets; id->PCIid != -1; id++) {
+ if (id->PCIid == xf86CheckPciGAType(*ppPci)) {
+ ++allocatedInstances;
+ instances = xnfrealloc(instances,
+ allocatedInstances * sizeof(struct Inst));
+ instances[allocatedInstances - 1].pci = *ppPci;
+ instances[allocatedInstances - 1].dev = NULL;
+ instances[allocatedInstances - 1].claimed = FALSE;
+ instances[allocatedInstances - 1].foundHW = TRUE;
+ instances[allocatedInstances - 1].chip = id->numChipset;
+ instances[allocatedInstances - 1].screen = 0;
+ numFound++;
+ }
+ }
+ }
+ } else {
+ /* Find PCI devices that match the given vendor ID */
+ for (ppPci = xf86PciVideoInfo; (ppPci != NULL)
+ && (*ppPci != NULL); ppPci++) {
+ if ((*ppPci)->vendor == vendorID) {
+ ++allocatedInstances;
+ instances = xnfrealloc(instances,
+ allocatedInstances * sizeof(struct Inst));
+ instances[allocatedInstances - 1].pci = *ppPci;
+ instances[allocatedInstances - 1].dev = NULL;
+ instances[allocatedInstances - 1].claimed = FALSE;
+ instances[allocatedInstances - 1].foundHW = FALSE;
+ instances[allocatedInstances - 1].screen = 0;
+
+ /* Check if the chip type is listed in the chipsets table */
+ for (id = PCIchipsets; id->PCIid != -1; id++) {
+ if (id->PCIid == (*ppPci)->chipType) {
+ instances[allocatedInstances - 1].chip
+ = id->numChipset;
+ instances[allocatedInstances - 1].foundHW = TRUE;
+ numFound++;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * This may be debatable, but if no PCI devices with a matching vendor
+ * type is found, return zero now. It is probably not desirable to
+ * allow the config file to override this.
+ */
+ if (allocatedInstances <= 0) {
+ xfree(instances);
+ return 0;
+ }
+
+ if (xf86DoProbe) {
+ xfree(instances);
+ return numFound;
+ }
+
+ if (xf86DoConfigure && xf86DoConfigurePass1) {
+ GDevPtr pGDev;
+ int actualcards = 0;
+ for (i = 0; i < allocatedInstances; i++) {
+ pPci = instances[i].pci;
+ if (instances[i].foundHW) {
+ if (!xf86CheckPciSlot(pPci->bus, pPci->device, pPci->func))
+ continue;
+ actualcards++;
+ pGDev = xf86AddDeviceToConfigure(drvp->driverName,
+ instances[i].pci, -1);
+ if (pGDev) {
+ /*
+ * XF86Match???Instances() treat chipID and chipRev as
+ * overrides, so clobber them here.
+ */
+ pGDev->chipID = pGDev->chipRev = -1;
+ }
+ }
+ }
+ xfree(instances);
+ return actualcards;
+ }
+
+#ifdef DEBUG
+ ErrorF("%s instances found: %d\n", driverName, allocatedInstances);
+#endif
+
+ /*
+ * Check for devices that need duplicated instances. This is required
+ * when there is more than one screen per entity.
+ *
+ * XXX This currently doesn't work for cases where the BusID isn't
+ * specified explicitly in the config file.
+ */
+
+ for (j = 0; j < numDevs; j++) {
+ if (devList[j]->screen > 0 && devList[j]->busID
+ && *devList[j]->busID) {
+ for (i = 0; i < allocatedInstances; i++) {
+ pPci = instances[i].pci;
+ if (xf86ComparePciBusString(devList[j]->busID, pPci->bus,
+ pPci->device,
+ pPci->func)) {
+ allocatedInstances++;
+ instances = xnfrealloc(instances,
+ allocatedInstances *
+ sizeof(struct Inst));
+ instances[allocatedInstances - 1] = instances[i];
+ instances[allocatedInstances - 1].screen =
+ devList[j]->screen;
+ numFound++;
+ break;
+ }
+ }
+ }
+ }
+
+ for (i = 0; i < allocatedInstances; i++) {
+ pPci = instances[i].pci;
+ devBus = NULL;
+ dev = NULL;
+ for (j = 0; j < numDevs; j++) {
+ if (devList[j]->busID && *devList[j]->busID) {
+ if (xf86ComparePciBusString(devList[j]->busID, pPci->bus,
+ pPci->device,
+ pPci->func) &&
+ devList[j]->screen == instances[i].screen) {
+
+ if (devBus)
+ xf86MsgVerb(X_WARNING,0,
+ "%s: More than one matching Device section for "
+ "instances\n\t(BusID: %s) found: %s\n",
+ driverName, devList[j]->busID,
+ devList[j]->identifier);
+ else
+ devBus = devList[j];
+ }
+ } else {
+ /*
+ * if device section without BusID is found
+ * only assign to it to the primary device.
+ */
+ if (xf86IsPrimaryPci(pPci)) {
+ xf86Msg(X_PROBED, "Assigning device section with no busID"
+ " to primary device\n");
+ if (dev || devBus)
+ xf86MsgVerb(X_WARNING, 0,
+ "%s: More than one matching Device section "
+ "found: %s\n", driverName, devList[j]->identifier);
+ else
+ dev = devList[j];
+ }
+ }
+ }
+ if (devBus) dev = devBus; /* busID preferred */
+ if (!dev) {
+ if (xf86CheckPciSlot(pPci->bus, pPci->device, pPci->func)) {
+ xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section "
+ "for instance (BusID PCI:%i:%i:%i) found\n",
+ driverName, pPci->bus, pPci->device, pPci->func);
+ }
+ } else {
+ numClaimedInstances++;
+ instances[i].claimed = TRUE;
+ instances[i].dev = dev;
+ }
+ }
+#ifdef DEBUG
+ ErrorF("%s instances found: %d\n", driverName, numClaimedInstances);
+#endif
+ /*
+ * Now check that a chipset or chipID override in the device section
+ * is valid. Chipset has precedence over chipID.
+ * If chipset is not valid ignore BusSlot completely.
+ */
+ for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
+ if (!instances[i].claimed) {
+ continue;
+ }
+ from = X_PROBED;
+ if (instances[i].dev->chipset) {
+ for (c = chipsets; c->token >= 0; c++) {
+ if (xf86NameCmp(c->name, instances[i].dev->chipset) == 0)
+ break;
+ }
+ if (c->token == -1) {
+ instances[i].claimed = FALSE;
+ numClaimedInstances--;
+ xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
+ "section \"%s\" isn't valid for this driver\n",
+ driverName, instances[i].dev->chipset,
+ instances[i].dev->identifier);
+ } else {
+ instances[i].chip = c->token;
+
+ for (id = PCIchipsets; id->numChipset >= 0; id++) {
+ if (id->numChipset == instances[i].chip)
+ break;
+ }
+ if(id->numChipset >=0){
+ xf86Msg(X_CONFIG,"Chipset override: %s\n",
+ instances[i].dev->chipset);
+ from = X_CONFIG;
+ } else {
+ instances[i].claimed = FALSE;
+ numClaimedInstances--;
+ xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
+ "section \"%s\" isn't a valid PCI chipset\n",
+ driverName, instances[i].dev->chipset,
+ instances[i].dev->identifier);
+ }
+ }
+ } else if (instances[i].dev->chipID > 0) {
+ for (id = PCIchipsets; id->numChipset >= 0; id++) {
+ if (id->PCIid == instances[i].dev->chipID)
+ break;
+ }
+ if (id->numChipset == -1) {
+ instances[i].claimed = FALSE;
+ numClaimedInstances--;
+ xf86MsgVerb(X_WARNING, 0, "%s: ChipID 0x%04X in Device "
+ "section \"%s\" isn't valid for this driver\n",
+ driverName, instances[i].dev->chipID,
+ instances[i].dev->identifier);
+ } else {
+ instances[i].chip = id->numChipset;
+
+ xf86Msg( X_CONFIG,"ChipID override: 0x%04X\n",
+ instances[i].dev->chipID);
+ from = X_CONFIG;
+ }
+ } else if (!instances[i].foundHW) {
+ /*
+ * This means that there was no override and the PCI chipType
+ * doesn't match one that is supported
+ */
+ instances[i].claimed = FALSE;
+ numClaimedInstances--;
+ }
+ if (instances[i].claimed == TRUE){
+ for (c = chipsets; c->token >= 0; c++) {
+ if (c->token == instances[i].chip)
+ break;
+ }
+ xf86Msg(from,"Chipset %s found\n",
+ c->name);
+ }
+ }
+
+ /*
+ * Of the claimed instances, check that another driver hasn't already
+ * claimed its slot.
+ */
+ numFound = 0;
+ for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
+
+ if (!instances[i].claimed)
+ continue;
+ pPci = instances[i].pci;
+
+
+ /*
+ * Allow the same entity to be used more than once for devices with
+ * multiple screens per entity. This assumes implicitly that there
+ * will be a screen == 0 instance.
+ *
+ * XXX Need to make sure that two different drivers don't claim
+ * the same screen > 0 instance.
+ */
+ if (instances[i].screen == 0 &&
+ !xf86CheckPciSlot(pPci->bus, pPci->device, pPci->func))
+ continue;
+
+#ifdef DEBUG
+ ErrorF("%s: card at %d:%d:%d is claimed by a Device section\n",
+ driverName, pPci->bus, pPci->device, pPci->func);
+#endif
+
+ /* Allocate an entry in the lists to be returned */
+ numFound++;
+ retEntities = xnfrealloc(retEntities, numFound * sizeof(int));
+ retEntities[numFound - 1]
+ = xf86ClaimPciSlot(pPci->bus, pPci->device,
+ pPci->func,drvp, instances[i].chip,
+ instances[i].dev,instances[i].dev->active ?
+ TRUE : FALSE);
+ if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) {
+ for (j = 0; j < xf86NumEntities; j++) {
+ EntityPtr pEnt = xf86Entities[j];
+ if (pEnt->busType != BUS_PCI)
+ continue;
+ if (pEnt->pciBusId.bus == pPci->bus &&
+ pEnt->pciBusId.device == pPci->device &&
+ pEnt->pciBusId.func == pPci->func) {
+ retEntities[numFound - 1] = j;
+ xf86AddDevToEntity(j, instances[i].dev);
+ break;
+ }
+ }
+ }
+ }
+ xfree(instances);
+ if (numFound > 0) {
+ *foundEntities = retEntities;
+ }
+
+ return numFound;
+}
+
+int
+xf86MatchIsaInstances(const char *driverName, SymTabPtr chipsets,
+ IsaChipsets *ISAchipsets, DriverPtr drvp,
+ FindIsaDevProc FindIsaDevice, GDevPtr *devList,
+ int numDevs, int **foundEntities)
+{
+ SymTabRec *c;
+ IsaChipsets *Chips;
+ int i;
+ int numFound = 0;
+ int foundChip = -1;
+ int *retEntities = NULL;
+
+ *foundEntities = NULL;
+
+#if defined(__sparc__) || defined(__powerpc__)
+ FindIsaDevice = NULL; /* Temporary */
+#endif
+
+ if (xf86DoProbe || (xf86DoConfigure && xf86DoConfigurePass1)) {
+ if (FindIsaDevice &&
+ ((foundChip = (*FindIsaDevice)(NULL)) != -1)) {
+ xf86AddDeviceToConfigure(drvp->driverName, NULL, foundChip);
+ return 1;
+ }
+ return 0;
+ }
+
+ for (i = 0; i < numDevs; i++) {
+ MessageType from = X_CONFIG;
+ GDevPtr dev = NULL;
+ GDevPtr devBus = NULL;
+
+ if (devList[i]->busID && *devList[i]->busID) {
+ if (xf86ParseIsaBusString(devList[i]->busID)) {
+ if (devBus) xf86MsgVerb(X_WARNING,0,
+ "%s: More than one matching Device "
+ "section for ISA-Bus found: %s\n",
+ driverName,devList[i]->identifier);
+ else devBus = devList[i];
+ }
+ } else {
+ if (xf86IsPrimaryIsa()) {
+ if (dev) xf86MsgVerb(X_WARNING,0,
+ "%s: More than one matching "
+ "Device section found: %s\n",
+ driverName,devList[i]->identifier);
+ else dev = devList[i];
+ }
+ }
+ if (devBus) dev = devBus;
+ if (dev) {
+ if (dev->chipset) {
+ for (c = chipsets; c->token >= 0; c++) {
+ if (xf86NameCmp(c->name, dev->chipset) == 0)
+ break;
+ }
+ if (c->token == -1) {
+ xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
+ "section \"%s\" isn't valid for this driver\n",
+ driverName, dev->chipset,
+ dev->identifier);
+ } else
+ foundChip = c->token;
+ } else {
+ if (FindIsaDevice) foundChip = (*FindIsaDevice)(dev);
+ /* Probe it */
+ from = X_PROBED;
+ }
+ }
+
+ /* Check if the chip type is listed in the chipset table - for sanity*/
+
+ if (foundChip >= 0){
+ for (Chips = ISAchipsets; Chips->numChipset >= 0; Chips++) {
+ if (Chips->numChipset == foundChip)
+ break;
+ }
+ if (Chips->numChipset == -1){
+ foundChip = -1;
+ xf86MsgVerb(X_WARNING,0,
+ "%s: Driver detected unknown ISA-Bus Chipset\n",
+ driverName);
+ }
+ }
+ if (foundChip != -1) {
+ numFound++;
+ retEntities = xnfrealloc(retEntities,numFound * sizeof(int));
+ retEntities[numFound - 1] =
+ xf86ClaimIsaSlot(drvp,foundChip,dev, dev->active ? TRUE : FALSE);
+ for (c = chipsets; c->token >= 0; c++) {
+ if (c->token == foundChip)
+ break;
+ }
+ xf86Msg(from, "Chipset %s found\n", c->name);
+ }
+ }
+ *foundEntities = retEntities;
+
+ return numFound;
+}
+
+/*
+ * xf86GetClocks -- get the dot-clocks via a BIG BAD hack ...
+ */
+void
+xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int),
+ void (*ProtectRegs)(ScrnInfoPtr, Bool),
+ void (*BlankScreen)(ScrnInfoPtr, Bool), IOADDRESS vertsyncreg,
+ int maskval, int knownclkindex, int knownclkvalue)
+{
+ register int status = vertsyncreg;
+ unsigned long i, cnt, rcnt, sync;
+
+ /* First save registers that get written on */
+ (*ClockFunc)(pScrn, CLK_REG_SAVE);
+
+ xf86SetPriority(TRUE);
+
+ if (num > MAXCLOCKS)
+ num = MAXCLOCKS;
+
+ for (i = 0; i < num; i++)
+ {
+ if (ProtectRegs)
+ (*ProtectRegs)(pScrn, TRUE);
+ if (!(*ClockFunc)(pScrn, i))
+ {
+ pScrn->clock[i] = -1;
+ continue;
+ }
+ if (ProtectRegs)
+ (*ProtectRegs)(pScrn, FALSE);
+ if (BlankScreen)
+ (*BlankScreen)(pScrn, FALSE);
+
+ usleep(50000); /* let VCO stabilise */
+
+ cnt = 0;
+ sync = 200000;
+
+ /* XXX How critical is this? */
+ if (!xf86DisableInterrupts())
+ {
+ (*ClockFunc)(pScrn, CLK_REG_RESTORE);
+ ErrorF("Failed to disable interrupts during clock probe. If\n");
+ ErrorF("your OS does not support disabling interrupts, then you\n");
+ FatalError("must specify a Clocks line in the XF86Config file.\n");
+ }
+ while ((inb(status) & maskval) == 0x00)
+ if (sync-- == 0) goto finish;
+ /* Something appears to be happening, so reset sync count */
+ sync = 200000;
+ while ((inb(status) & maskval) == maskval)
+ if (sync-- == 0) goto finish;
+ /* Something appears to be happening, so reset sync count */
+ sync = 200000;
+ while ((inb(status) & maskval) == 0x00)
+ if (sync-- == 0) goto finish;
+
+ for (rcnt = 0; rcnt < 5; rcnt++)
+ {
+ while (!(inb(status) & maskval))
+ cnt++;
+ while ((inb(status) & maskval))
+ cnt++;
+ }
+
+finish:
+ xf86EnableInterrupts();
+
+ pScrn->clock[i] = cnt ? cnt : -1;
+ if (BlankScreen)
+ (*BlankScreen)(pScrn, TRUE);
+ }
+
+ xf86SetPriority(FALSE);
+
+ for (i = 0; i < num; i++)
+ {
+ if (i != knownclkindex)
+ {
+ if (pScrn->clock[i] == -1)
+ {
+ pScrn->clock[i] = 0;
+ }
+ else
+ {
+ pScrn->clock[i] = (int)(0.5 +
+ (((float)knownclkvalue) * pScrn->clock[knownclkindex]) /
+ (pScrn->clock[i]));
+ /* Round to nearest 10KHz */
+ pScrn->clock[i] += 5;
+ pScrn->clock[i] /= 10;
+ pScrn->clock[i] *= 10;
+ }
+ }
+ }
+
+ pScrn->clock[knownclkindex] = knownclkvalue;
+ pScrn->numClocks = num;
+
+ /* Restore registers that were written on */
+ (*ClockFunc)(pScrn, CLK_REG_RESTORE);
+}
+
+void
+xf86SetPriority(Bool up)
+{
+ static int saved_nice;
+
+ if (up) {
+#ifdef HAS_SETPRIORITY
+ saved_nice = getpriority(PRIO_PROCESS, 0);
+ setpriority(PRIO_PROCESS, 0, -20);
+#endif
+#if defined(SYSV) || defined(SVR4) || defined(linux)
+ saved_nice = nice(0);
+ nice(-20 - saved_nice);
+#endif
+ } else {
+#ifdef HAS_SETPRIORITY
+ setpriority(PRIO_PROCESS, 0, saved_nice);
+#endif
+#if defined(SYSV) || defined(SVR4) || defined(linux)
+ nice(20 + saved_nice);
+#endif
+ }
+}
+
+const char *
+xf86GetVisualName(int visual)
+{
+ if (visual < 0 || visual > DirectColor)
+ return NULL;
+
+ return xf86VisualNames[visual];
+}
+
+
+int
+xf86GetVerbosity()
+{
+ return max(xf86Verbose, xf86LogVerbose);
+}
+
+Pix24Flags
+xf86GetPix24()
+{
+ return xf86Info.pixmap24;
+}
+
+
+int
+xf86GetDepth()
+{
+ return xf86Depth;
+}
+
+
+rgb
+xf86GetWeight()
+{
+ return xf86Weight;
+}
+
+
+Gamma
+xf86GetGamma()
+{
+ return xf86Gamma;
+}
+
+
+Bool
+xf86GetFlipPixels()
+{
+ return xf86FlipPixels;
+}
+
+
+const char *
+xf86GetServerName()
+{
+ return xf86ServerName;
+}
+
+
+Bool
+xf86ServerIsExiting()
+{
+ return (dispatchException & DE_TERMINATE) == DE_TERMINATE;
+}
+
+
+Bool
+xf86ServerIsResetting()
+{
+ return xf86Resetting;
+}
+
+
+Bool
+xf86ServerIsInitialising()
+{
+ return xf86Initialising;
+}
+
+
+Bool
+xf86ServerIsOnlyDetecting(void)
+{
+ return xf86DoProbe || xf86DoConfigure;
+}
+
+
+Bool
+xf86ServerIsOnlyProbing(void)
+{
+ return xf86ProbeOnly;
+}
+
+
+Bool
+xf86CaughtSignal()
+{
+ return xf86Info.caughtSignal;
+}
+
+
+Bool
+xf86GetVidModeAllowNonLocal()
+{
+ return xf86Info.vidModeAllowNonLocal;
+}
+
+
+Bool
+xf86GetVidModeEnabled()
+{
+ return xf86Info.vidModeEnabled;
+}
+
+Bool
+xf86GetModInDevAllowNonLocal()
+{
+ return xf86Info.miscModInDevAllowNonLocal;
+}
+
+
+Bool
+xf86GetModInDevEnabled()
+{
+ return xf86Info.miscModInDevEnabled;
+}
+
+
+Bool
+xf86GetAllowMouseOpenFail()
+{
+ return xf86Info.allowMouseOpenFail;
+}
+
+
+Bool
+xf86IsPc98()
+{
+#if defined(i386) || defined(__i386__)
+ return xf86Info.pc98;
+#else
+ return FALSE;
+#endif
+}
+
+void
+xf86DisableRandR()
+{
+ xf86Info.disableRandR = TRUE;
+ xf86Info.randRFrom = X_PROBED;
+}
+
+CARD32
+xf86GetVersion()
+{
+ return XF86_VERSION_CURRENT;
+}
+
+CARD32
+xf86GetModuleVersion(pointer module)
+{
+#ifdef XFree86LOADER
+ return (CARD32)LoaderGetModuleVersion(module);
+#else
+ return 0;
+#endif
+}
+
+pointer
+xf86LoadDrvSubModule(DriverPtr drv, const char *name)
+{
+#ifdef XFree86LOADER
+ pointer ret;
+ int errmaj = 0, errmin = 0;
+
+ ret = LoadSubModule(drv->module, name, NULL, NULL, NULL, NULL,
+ &errmaj, &errmin);
+ if (!ret)
+ LoaderErrorMsg(NULL, name, errmaj, errmin);
+ return ret;
+#else
+ return (pointer)1;
+#endif
+}
+
+pointer
+xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name)
+{
+#ifdef XFree86LOADER
+ pointer ret;
+ int errmaj = 0, errmin = 0;
+
+ ret = LoadSubModule(pScrn->module, name, NULL, NULL, NULL, NULL,
+ &errmaj, &errmin);
+ if (!ret)
+ LoaderErrorMsg(pScrn->name, name, errmaj, errmin);
+ return ret;
+#else
+ return (pointer)1;
+#endif
+}
+
+/*
+ * xf86LoadOneModule loads a single module.
+ */
+pointer
+xf86LoadOneModule(char *name, pointer opt)
+{
+#ifdef XFree86LOADER
+ int errmaj, errmin;
+#endif
+ char *Name;
+ pointer mod;
+
+ if (!name)
+ return NULL;
+
+#ifndef NORMALISE_MODULE_NAME
+ Name = xstrdup(name);
+#else
+ /* Normalise the module name */
+ Name = xf86NormalizeName(name);
+#endif
+
+ /* Skip empty names */
+ if (Name == NULL)
+ return NULL;
+ if (*Name == '\0') {
+ xfree(Name);
+ return NULL;
+ }
+
+#ifdef XFree86LOADER
+ mod = LoadModule(Name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin);
+ if (!mod)
+ LoaderErrorMsg(NULL, Name, errmaj, errmin);
+#else
+ mod = (pointer)1;
+#endif
+ xfree(Name);
+ return mod;
+}
+
+void
+xf86UnloadSubModule(pointer mod)
+{
+ /*
+ * This is disabled for now. The loader isn't smart enough yet to undo
+ * relocations.
+ */
+#if defined(XFree86LOADER) && 0
+ UnloadSubModule(mod);
+#endif
+}
+
+Bool
+xf86LoaderCheckSymbol(const char *name)
+{
+#ifdef XFree86LOADER
+ return LoaderSymbol(name) != NULL;
+#else
+ return TRUE;
+#endif
+}
+
+void
+xf86LoaderReqSymLists(const char **list0, ...)
+{
+#ifdef XFree86LOADER
+ va_list ap;
+
+ va_start(ap, list0);
+ LoaderVReqSymLists(list0, ap);
+ va_end(ap);
+#endif
+}
+
+void
+xf86LoaderReqSymbols(const char *sym0, ...)
+{
+#ifdef XFree86LOADER
+ va_list ap;
+
+ va_start(ap, sym0);
+ LoaderVReqSymbols(sym0, ap);
+ va_end(ap);
+#endif
+}
+
+void
+xf86LoaderRefSymLists(const char **list0, ...)
+{
+#ifdef XFree86LOADER
+ va_list ap;
+
+ va_start(ap, list0);
+ LoaderVRefSymLists(list0, ap);
+ va_end(ap);
+#endif
+}
+
+void
+xf86LoaderRefSymbols(const char *sym0, ...)
+{
+#ifdef XFree86LOADER
+ va_list ap;
+
+ va_start(ap, sym0);
+ LoaderVRefSymbols(sym0, ap);
+ va_end(ap);
+#endif
+}
+
+
+typedef enum {
+ OPTION_BACKING_STORE
+} BSOpts;
+
+static const OptionInfoRec BSOptions[] = {
+ { OPTION_BACKING_STORE, "BackingStore", OPTV_BOOLEAN, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+
+void
+xf86SetBackingStore(ScreenPtr pScreen)
+{
+ Bool useBS = FALSE;
+ MessageType from = X_DEFAULT;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ OptionInfoPtr options;
+
+ options = xnfalloc(sizeof(BSOptions));
+ (void)memcpy(options, BSOptions, sizeof(BSOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
+
+ /* check for commandline option here */
+ if (xf86bsEnableFlag) {
+ from = X_CMDLINE;
+ useBS = TRUE;
+ } else if (xf86bsDisableFlag) {
+ from = X_CMDLINE;
+ useBS = FALSE;
+ } else {
+ if (xf86GetOptValBool(options, OPTION_BACKING_STORE, &useBS))
+ from = X_CONFIG;
+ }
+ xfree(options);
+ pScreen->backingStoreSupport = useBS ? Always : NotUseful;
+ if (serverGeneration == 1)
+ xf86DrvMsg(pScreen->myNum, from, "Backing store %s\n",
+ useBS ? "enabled" : "disabled");
+}
+
+
+typedef enum {
+ OPTION_SILKEN_MOUSE
+} SMOpts;
+
+static const OptionInfoRec SMOptions[] = {
+ { OPTION_SILKEN_MOUSE, "SilkenMouse", OPTV_BOOLEAN, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+
+void
+xf86SetSilkenMouse (ScreenPtr pScreen)
+{
+ Bool useSM = TRUE;
+ MessageType from = X_DEFAULT;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ OptionInfoPtr options;
+
+ options = xnfalloc(sizeof(SMOptions));
+ (void)memcpy(options, SMOptions, sizeof(SMOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
+
+ /* check for commandline option here */
+ /* disable if screen shares resources */
+ if (((pScrn->racMemFlags & RAC_CURSOR) &&
+ !xf86NoSharedResources(pScrn->scrnIndex,MEM)) ||
+ ((pScrn->racIoFlags & RAC_CURSOR) &&
+ !xf86NoSharedResources(pScrn->scrnIndex,IO))) {
+ useSM = FALSE;
+ from = X_PROBED;
+ } else if (xf86silkenMouseDisableFlag) {
+ from = X_CMDLINE;
+ useSM = FALSE;
+ } else {
+ if (xf86GetOptValBool(options, OPTION_SILKEN_MOUSE, &useSM))
+ from = X_CONFIG;
+ }
+ xfree(options);
+ /*
+ * XXX quick hack to report correctly for OSs that can't do SilkenMouse
+ * yet. Should handle this differently so that alternate async methods
+ * like Xqueue work correctly with this too.
+ */
+ pScrn->silkenMouse = useSM && xf86SIGIOSupported();
+ if (serverGeneration == 1)
+ xf86DrvMsg(pScreen->myNum, from, "Silken mouse %s\n",
+ pScrn->silkenMouse ? "enabled" : "disabled");
+}
+
+/* Wrote this function for the PM2 Xv driver, preliminary. */
+
+pointer
+xf86FindXvOptions(int scrnIndex, int adaptor_index, char *port_name,
+ char **adaptor_name, pointer *adaptor_options)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ confXvAdaptorPtr adaptor;
+ int i;
+
+ if (adaptor_index >= pScrn->confScreen->numxvadaptors) {
+ if (adaptor_name) *adaptor_name = NULL;
+ if (adaptor_options) *adaptor_options = NULL;
+ return NULL;
+ }
+
+ adaptor = &pScrn->confScreen->xvadaptors[adaptor_index];
+ if (adaptor_name) *adaptor_name = adaptor->identifier;
+ if (adaptor_options) *adaptor_options = adaptor->options;
+
+ for (i = 0; i < adaptor->numports; i++)
+ if (!xf86NameCmp(adaptor->ports[i].identifier, port_name))
+ return adaptor->ports[i].options;
+
+ return NULL;
+}
+
+/* Rather than duplicate loader's get OS function, just include it directly */
+#define LoaderGetOS xf86GetOS
+#include "loader/os.c"
+
+/* new RAC */
+/*
+ * xf86ConfigIsa/PciEntity() -- These helper functions assign an
+ * active entity to a screen, registers its fixed resources, assign
+ * special enter/leave functions and their private scratch area to
+ * this entity, take the dog for a walk...
+ */
+ScrnInfoPtr
+xf86ConfigIsaEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
+ IsaChipsets *i_chip, resList res, EntityProc init,
+ EntityProc enter, EntityProc leave, pointer private)
+{
+ IsaChipsets *i_id;
+ EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
+ if (!pEnt) return pScrn;
+
+ if (!(pEnt->location.type == BUS_ISA)) {
+ xfree(pEnt);
+ return pScrn;
+ }
+
+ if (!pEnt->active) {
+ xf86ConfigIsaEntityInactive(pEnt, i_chip, res, init, enter,
+ leave, private);
+ return pScrn;
+ }
+
+ if (!pScrn)
+ pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
+ xf86AddEntityToScreen(pScrn,entityIndex);
+
+ if (i_chip) {
+ for (i_id = i_chip; i_id->numChipset != -1; i_id++) {
+ if (pEnt->chipset == i_id->numChipset) break;
+ }
+ xf86ClaimFixedResources(i_id->resList,entityIndex);
+ }
+ xfree(pEnt);
+ xf86ClaimFixedResources(res,entityIndex);
+ xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
+
+ return pScrn;
+}
+
+ScrnInfoPtr
+xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
+ PciChipsets *p_chip, resList res, EntityProc init,
+ EntityProc enter, EntityProc leave, pointer private)
+{
+ PciChipsets *p_id;
+ EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
+ if (!pEnt) return pScrn;
+
+ if (!(pEnt->location.type == BUS_PCI)
+ || !xf86GetPciInfoForEntity(entityIndex)) {
+ xfree(pEnt);
+ return pScrn;
+ }
+ if (!pEnt->active) {
+ xf86ConfigPciEntityInactive(pEnt, p_chip, res, init, enter,
+ leave, private);
+ return pScrn;
+ }
+
+ if (!pScrn)
+ pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
+ if (xf86IsEntitySharable(entityIndex)) {
+ xf86SetEntityShared(entityIndex);
+ }
+ xf86AddEntityToScreen(pScrn,entityIndex);
+ if (xf86IsEntityShared(entityIndex)) {
+ return pScrn;
+ }
+ if (p_chip) {
+ for (p_id = p_chip; p_id->numChipset != -1; p_id++) {
+ if (pEnt->chipset == p_id->numChipset) break;
+ }
+ xf86ClaimFixedResources(p_id->resList,entityIndex);
+ }
+ xfree(pEnt);
+
+ xf86ClaimFixedResources(res,entityIndex);
+ xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
+
+ return pScrn;
+}
+
+ScrnInfoPtr
+xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
+ EntityProc init, EntityProc enter, EntityProc leave,
+ pointer private)
+{
+ EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
+ if (!pEnt) return pScrn;
+
+ if (!(pEnt->location.type == BUS_NONE)) {
+ xfree(pEnt);
+ return pScrn;
+ }
+
+ if (!pEnt->active) {
+ xf86ConfigFbEntityInactive(pEnt, init, enter, leave, private);
+ return pScrn;
+ }
+
+ if (!pScrn)
+ pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
+ xf86AddEntityToScreen(pScrn,entityIndex);
+
+ xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
+
+ return pScrn;
+}
+
+/*
+ *
+ * OBSOLETE ! xf86ConfigActiveIsaEntity() and xf86ConfigActivePciEntity()
+ * are obsolete functions. They the are likely to be removed
+ * Don't use!
+ */
+Bool
+xf86ConfigActiveIsaEntity(ScrnInfoPtr pScrn, int entityIndex,
+ IsaChipsets *i_chip, resList res, EntityProc init,
+ EntityProc enter, EntityProc leave, pointer private)
+{
+ IsaChipsets *i_id;
+ EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
+ if (!pEnt) return FALSE;
+
+ if (!pEnt->active || !(pEnt->location.type == BUS_ISA)) {
+ xfree(pEnt);
+ return FALSE;
+ }
+
+ xf86AddEntityToScreen(pScrn,entityIndex);
+
+ if (i_chip) {
+ for (i_id = i_chip; i_id->numChipset != -1; i_id++) {
+ if (pEnt->chipset == i_id->numChipset) break;
+ }
+ xf86ClaimFixedResources(i_id->resList,entityIndex);
+ }
+ xfree(pEnt);
+ xf86ClaimFixedResources(res,entityIndex);
+ if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private))
+ return FALSE;
+
+ return TRUE;
+}
+
+Bool
+xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
+ PciChipsets *p_chip, resList res, EntityProc init,
+ EntityProc enter, EntityProc leave, pointer private)
+{
+ PciChipsets *p_id;
+ EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
+ if (!pEnt) return FALSE;
+
+ if (!pEnt->active || !(pEnt->location.type == BUS_PCI)) {
+ xfree(pEnt);
+ return FALSE;
+ }
+ xf86AddEntityToScreen(pScrn,entityIndex);
+
+ if (p_chip) {
+ for (p_id = p_chip; p_id->numChipset != -1; p_id++) {
+ if (pEnt->chipset == p_id->numChipset) break;
+ }
+ xf86ClaimFixedResources(p_id->resList,entityIndex);
+ }
+ xfree(pEnt);
+
+ xf86ClaimFixedResources(res,entityIndex);
+ if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private))
+ return FALSE;
+
+ return TRUE;
+}
+
+/*
+ * xf86ConfigPci/IsaEntityInactive() -- These functions can be used
+ * to configure an inactive entity as well as to reconfigure an
+ * previously active entity inactive. If the entity has been
+ * assigned to a screen before it will be removed. If p_pci(p_isa) is
+ * non-NULL all static resources listed there will be registered.
+ */
+void
+xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip,
+ resList res, EntityProc init, EntityProc enter,
+ EntityProc leave, pointer private)
+{
+ PciChipsets *p_id;
+ ScrnInfoPtr pScrn;
+
+ if ((pScrn = xf86FindScreenForEntity(pEnt->index)))
+ xf86RemoveEntityFromScreen(pScrn,pEnt->index);
+ else if (p_chip) {
+ for (p_id = p_chip; p_id->numChipset != -1; p_id++) {
+ if (pEnt->chipset == p_id->numChipset) break;
+ }
+ xf86ClaimFixedResources(p_id->resList,pEnt->index);
+ }
+ xf86ClaimFixedResources(res,pEnt->index);
+ /* shared resources are only needed when entity is active: remove */
+ xf86DeallocateResourcesForEntity(pEnt->index, ResShared);
+ xf86SetEntityFuncs(pEnt->index,init,enter,leave,private);
+}
+
+void
+xf86ConfigIsaEntityInactive(EntityInfoPtr pEnt, IsaChipsets *i_chip,
+ resList res, EntityProc init, EntityProc enter,
+ EntityProc leave, pointer private)
+{
+ IsaChipsets *i_id;
+ ScrnInfoPtr pScrn;
+
+ if ((pScrn = xf86FindScreenForEntity(pEnt->index)))
+ xf86RemoveEntityFromScreen(pScrn,pEnt->index);
+ else if (i_chip) {
+ for (i_id = i_chip; i_id->numChipset != -1; i_id++) {
+ if (pEnt->chipset == i_id->numChipset) break;
+ }
+ xf86ClaimFixedResources(i_id->resList,pEnt->index);
+ }
+ xf86ClaimFixedResources(res,pEnt->index);
+ /* shared resources are only needed when entity is active: remove */
+ xf86DeallocateResourcesForEntity(pEnt->index, ResShared);
+ xf86SetEntityFuncs(pEnt->index,init,enter,leave,private);
+}
+
+void
+xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init,
+ EntityProc enter, EntityProc leave, pointer private)
+{
+ ScrnInfoPtr pScrn;
+
+ if ((pScrn = xf86FindScreenForEntity(pEnt->index)))
+ xf86RemoveEntityFromScreen(pScrn,pEnt->index);
+ xf86SetEntityFuncs(pEnt->index,init,enter,leave,private);
+}
+
+Bool
+xf86IsScreenPrimary(int scrnIndex)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ int i;
+
+ for (i=0 ; i < pScrn->numEntities; i++) {
+ if (xf86IsEntityPrimary(i))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+int
+xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
+ int format, unsigned long len, pointer value )
+{
+ RootWinPropPtr pNewProp = NULL, pRegProp;
+ int i;
+ Bool existing = FALSE;
+
+#ifdef DEBUG
+ ErrorF("xf86RegisterRootWindowProperty(%d, %ld, %ld, %d, %ld, %p)\n",
+ ScrnIndex, property, type, format, len, value);
+#endif
+
+ if (ScrnIndex<0 || ScrnIndex>=xf86NumScreens) {
+ return(BadMatch);
+ }
+
+ if (xf86RegisteredPropertiesTable &&
+ xf86RegisteredPropertiesTable[ScrnIndex]) {
+ for (pNewProp = xf86RegisteredPropertiesTable[ScrnIndex];
+ pNewProp; pNewProp = pNewProp->next) {
+ if (strcmp(pNewProp->name, NameForAtom(property)) == 0)
+ break;
+ }
+ }
+
+ if (!pNewProp) {
+ if ((pNewProp = (RootWinPropPtr)xalloc(sizeof(RootWinProp))) == NULL) {
+ return(BadAlloc);
+ }
+ /*
+ * We will put this property at the end of the list so that
+ * the changes are made in the order they were requested.
+ */
+ pNewProp->next = NULL;
+ } else {
+ if (pNewProp->name)
+ xfree(pNewProp->name);
+ existing = TRUE;
+ }
+
+ pNewProp->name = xnfstrdup(NameForAtom(property));
+ pNewProp->type = type;
+ pNewProp->format = format;
+ pNewProp->size = len;
+ pNewProp->data = value;
+
+#ifdef DEBUG
+ ErrorF("new property filled\n");
+#endif
+
+ if (NULL==xf86RegisteredPropertiesTable) {
+#ifdef DEBUG
+ ErrorF("creating xf86RegisteredPropertiesTable[] size %d\n",
+ xf86NumScreens);
+#endif
+ if ( NULL==(xf86RegisteredPropertiesTable=(RootWinPropPtr*)xnfcalloc(sizeof(RootWinProp),xf86NumScreens) )) {
+ return(BadAlloc);
+ }
+ for (i=0; i<xf86NumScreens; i++) {
+ xf86RegisteredPropertiesTable[i] = NULL;
+ }
+ }
+
+#ifdef DEBUG
+ ErrorF("xf86RegisteredPropertiesTable %p\n",
+ (void *)xf86RegisteredPropertiesTable);
+ ErrorF("xf86RegisteredPropertiesTable[%d] %p\n",
+ ScrnIndex, (void *)xf86RegisteredPropertiesTable[ScrnIndex]);
+#endif
+
+ if (!existing) {
+ if ( xf86RegisteredPropertiesTable[ScrnIndex] == NULL) {
+ xf86RegisteredPropertiesTable[ScrnIndex] = pNewProp;
+ } else {
+ pRegProp = xf86RegisteredPropertiesTable[ScrnIndex];
+ while (pRegProp->next != NULL) {
+#ifdef DEBUG
+ ErrorF("- next %p\n", (void *)pRegProp);
+#endif
+ pRegProp = pRegProp->next;
+ }
+ pRegProp->next = pNewProp;
+ }
+ }
+#ifdef DEBUG
+ ErrorF("xf86RegisterRootWindowProperty succeeded\n");
+#endif
+ return(Success);
+}
+
+Bool
+xf86IsUnblank(int mode)
+{
+ switch(mode) {
+ case SCREEN_SAVER_OFF:
+ case SCREEN_SAVER_FORCER:
+ return TRUE;
+ case SCREEN_SAVER_ON:
+ case SCREEN_SAVER_CYCLE:
+ return FALSE;
+ default:
+ xf86MsgVerb(X_WARNING, 0, "Unexpected save screen mode: %d\n", mode);
+ return TRUE;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86InPriv.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86InPriv.h
new file mode 100644
index 000000000..4a02606d3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86InPriv.h
@@ -0,0 +1,48 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86InPriv.h,v 1.5 2003/08/24 17:36:52 dawes Exp $ */
+
+/*
+ * Copyright (c) 1999 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _xf86InPriv_h
+#define _xf86InPriv_h
+
+/* xf86Globals.c */
+#ifdef XFree86LOADER
+extern InputDriverPtr *xf86InputDriverList;
+#else
+extern InputDriverPtr xf86InputDriverList[];
+#endif
+extern int xf86NumInputDrivers;
+
+/* xf86Xinput.c */
+void xf86ActivateDevice(InputInfoPtr pInfo);
+
+#endif /* _xf86InPriv_h */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Init.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Init.c
new file mode 100644
index 000000000..e504c300a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Init.c
@@ -0,0 +1,2035 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 3.212 2004/01/27 01:31:45 dawes Exp $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 1.29 2005/12/14 20:12:00 ajax Exp $ */
+
+/*
+ * Loosely based on code bearing the following copyright:
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ */
+/*
+ * Copyright (c) 1992-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdlib.h>
+
+#undef HAS_UTSNAME
+#if !defined(WIN32) && !defined(__UNIXOS2__)
+#define HAS_UTSNAME 1
+#include <sys/utsname.h>
+#endif
+
+#define NEED_EVENTS
+#ifdef __UNIXOS2__
+#define I_NEED_OS2_H
+#endif
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include <X11/Xatom.h>
+#include "input.h"
+#include "servermd.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "site.h"
+#include "mi.h"
+
+#include "compiler.h"
+
+#ifdef XFree86LOADER
+#include "loaderProcs.h"
+#endif
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+
+#define XF86_OS_PRIVS
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Config.h"
+#include "xf86_OSlib.h"
+#include "xorgVersion.h"
+#include "xf86Date.h"
+#include "xf86Build.h"
+#include "mipointer.h"
+#ifdef XINPUT
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#else
+#include "inputstr.h"
+#endif
+#include "xf86DDC.h"
+#include "xf86Xinput.h"
+#include "xf86InPriv.h"
+#ifdef RENDER
+#include "picturestr.h"
+#endif
+
+#include "globals.h"
+
+#ifdef XTESTEXT1
+#include "atKeynames.h"
+extern int xtest_command_key;
+#endif /* XTESTEXT1 */
+
+#ifdef DPMSExtension
+#define DPMS_SERVER
+#include <X11/extensions/dpms.h>
+#include "dpmsproc.h"
+#endif
+
+
+/* forward declarations */
+
+static void xf86PrintBanner(void);
+static void xf86PrintMarkers(void);
+static void xf86RunVtInit(void);
+
+#ifdef __UNIXOS2__
+extern void os2ServerVideoAccess();
+#endif
+
+#ifdef XF86PM
+void (*xf86OSPMClose)(void) = NULL;
+#endif
+
+#ifdef XFree86LOADER
+static char *baseModules[] = {
+ "bitmap",
+ "pcidata",
+ NULL
+};
+#endif
+
+/* Common pixmap formats */
+
+static PixmapFormatRec formats[MAXFORMATS] = {
+ { 1, 1, BITMAP_SCANLINE_PAD },
+ { 4, 8, BITMAP_SCANLINE_PAD },
+ { 8, 8, BITMAP_SCANLINE_PAD },
+ { 15, 16, BITMAP_SCANLINE_PAD },
+ { 16, 16, BITMAP_SCANLINE_PAD },
+ { 24, 32, BITMAP_SCANLINE_PAD },
+#ifdef RENDER
+ { 32, 32, BITMAP_SCANLINE_PAD },
+#endif
+};
+#ifdef RENDER
+static int numFormats = 7;
+#else
+static int numFormats = 6;
+#endif
+static Bool formatsDone = FALSE;
+
+InputDriverRec XF86KEYBOARD = {
+ 1,
+ "keyboard",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 0
+};
+
+static Bool
+xf86CreateRootWindow(WindowPtr pWin)
+{
+ int ret = TRUE;
+ int err = Success;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RootWinPropPtr pProp;
+ CreateWindowProcPtr CreateWindow =
+ (CreateWindowProcPtr)(pScreen->devPrivates[xf86CreateRootWindowIndex].ptr);
+
+#ifdef DEBUG
+ ErrorF("xf86CreateRootWindow(%p)\n", pWin);
+#endif
+
+ if ( pScreen->CreateWindow != xf86CreateRootWindow ) {
+ /* Can't find hook we are hung on */
+ xf86DrvMsg(pScreen->myNum, X_WARNING /* X_ERROR */,
+ "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n",
+ (void *)xf86CreateRootWindow,
+ (void *)pScreen->CreateWindow );
+ }
+
+ /* Unhook this function ... */
+ pScreen->CreateWindow = CreateWindow;
+ pScreen->devPrivates[xf86CreateRootWindowIndex].ptr = NULL;
+
+ /* ... and call the previous CreateWindow fuction, if any */
+ if (NULL!=pScreen->CreateWindow) {
+ ret = (*pScreen->CreateWindow)(pWin);
+ }
+
+ /* Now do our stuff */
+ if (xf86RegisteredPropertiesTable != NULL) {
+ if (pWin->parent == NULL && xf86RegisteredPropertiesTable != NULL) {
+ for (pProp = xf86RegisteredPropertiesTable[pScreen->myNum];
+ pProp != NULL && err==Success;
+ pProp = pProp->next )
+ {
+ Atom prop;
+
+ prop = MakeAtom(pProp->name, strlen(pProp->name), TRUE);
+ err = ChangeWindowProperty(pWin,
+ prop, pProp->type,
+ pProp->format, PropModeReplace,
+ pProp->size, pProp->data,
+ FALSE
+ );
+ }
+
+ /* Look at err */
+ ret &= (err==Success);
+
+ } else {
+ xf86Msg(X_ERROR, "xf86CreateRootWindow unexpectedly called with "
+ "non-root window %p (parent %p)\n",
+ (void *)pWin, (void *)pWin->parent);
+ ret = FALSE;
+ }
+ }
+
+#ifdef DEBUG
+ ErrorF("xf86CreateRootWindow() returns %d\n", ret);
+#endif
+ return (ret);
+}
+
+
+/*
+ * InitOutput --
+ * Initialize screenInfo for all actually accessible framebuffers.
+ * That includes vt-manager setup, querying all possible devices and
+ * collecting the pixmap formats.
+ */
+
+static void
+PostConfigInit(void)
+{
+ /*
+ * Install signal handler for unexpected signals
+ */
+ xf86Info.caughtSignal=FALSE;
+ if (!xf86Info.notrapSignals) {
+ signal(SIGSEGV,xf86SigHandler);
+ signal(SIGILL,xf86SigHandler);
+#ifdef SIGEMT
+ signal(SIGEMT,xf86SigHandler);
+#endif
+ signal(SIGFPE,xf86SigHandler);
+#ifdef SIGBUS
+ signal(SIGBUS,xf86SigHandler);
+#endif
+#ifdef SIGSYS
+ signal(SIGSYS,xf86SigHandler);
+#endif
+#ifdef SIGXCPU
+ signal(SIGXCPU,xf86SigHandler);
+#endif
+#ifdef SIGXFSZ
+ signal(SIGXFSZ,xf86SigHandler);
+#endif
+#ifdef MEMDEBUG
+ signal(SIGUSR2,xf86SigMemDebug);
+#endif
+ }
+
+#ifdef XF86PM
+ xf86OSPMClose = xf86OSPMOpen();
+#endif
+
+ /* Run an external VT Init program if specified in the config file */
+ xf86RunVtInit();
+
+ /* Do this after XF86Config is read (it's normally in OsInit()) */
+ OsInitColors();
+}
+
+void
+InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ int i, j, k, scr_index;
+ static unsigned long generation = 0;
+#ifdef XFree86LOADER
+ char **modulelist;
+ pointer *optionlist;
+#endif
+ screenLayoutPtr layout;
+ Pix24Flags screenpix24, pix24;
+ MessageType pix24From = X_DEFAULT;
+ Bool pix24Fail = FALSE;
+ Bool autoconfig = FALSE;
+
+#ifdef __UNIXOS2__
+ os2ServerVideoAccess(); /* See if we have access to the screen before doing anything */
+#endif
+
+ xf86Initialising = TRUE;
+
+ /* Do this early? */
+ if (generation != serverGeneration) {
+ xf86ScreenIndex = AllocateScreenPrivateIndex();
+ xf86CreateRootWindowIndex = AllocateScreenPrivateIndex();
+ xf86PixmapIndex = AllocatePixmapPrivateIndex();
+ generation = serverGeneration;
+ }
+
+ if (serverGeneration == 1) {
+
+ pScreenInfo->numScreens = 0;
+
+ if ((xf86ServerName = strrchr(argv[0], '/')) != 0)
+ xf86ServerName++;
+ else
+ xf86ServerName = argv[0];
+
+ xf86PrintBanner();
+ xf86PrintMarkers();
+ if (xf86LogFile) {
+ time_t t;
+ const char *ct;
+ t = time(NULL);
+ ct = ctime(&t);
+ xf86MsgVerb(xf86LogFileFrom, 0, "Log file: \"%s\", Time: %s",
+ xf86LogFile, ct);
+ }
+
+ /* Read and parse the config file */
+ if (!xf86DoProbe && !xf86DoConfigure) {
+ switch (xf86HandleConfigFile(FALSE)) {
+ case CONFIG_OK:
+ break;
+ case CONFIG_PARSE_ERROR:
+ xf86Msg(X_ERROR, "Error parsing the config file\n");
+ return;
+ case CONFIG_NOFILE:
+ autoconfig = TRUE;
+ break;
+ }
+ }
+
+ if (!autoconfig)
+ PostConfigInit();
+
+#ifdef XFree86LOADER
+ /* Initialise the loader */
+ LoaderInit();
+
+ /* Tell the loader the default module search path */
+ LoaderSetPath(xf86ModulePath);
+
+#ifdef TESTING
+ {
+ char **list, **l;
+ const char *subdirs[] = {
+ "drivers",
+ NULL
+ };
+ const char *patlist[] = {
+ "(.*)_drv\\.so",
+ "(.*)_drv\\.o",
+ NULL
+ };
+ ErrorF("Getting module listing...\n");
+ list = LoaderListDirs(NULL, NULL);
+ if (list)
+ for (l = list; *l; l++)
+ ErrorF("module: %s\n", *l);
+ LoaderFreeDirList(list);
+ ErrorF("Getting video driver listing...\n");
+ list = LoaderListDirs(subdirs, NULL);
+ if (list)
+ for (l = list; *l; l++)
+ ErrorF("video driver: %s\n", *l);
+ LoaderFreeDirList(list);
+ ErrorF("Getting driver listing...\n");
+ list = LoaderListDirs(NULL, patlist);
+ if (list)
+ for (l = list; *l; l++)
+ ErrorF("video driver: %s\n", *l);
+ LoaderFreeDirList(list);
+ }
+#endif
+
+ /* Force load mandatory base modules */
+ if (!xf86LoadModules(baseModules, NULL))
+ FatalError("Unable to load required base modules, Exiting...\n");
+
+#endif
+
+ xf86OpenConsole();
+
+ /* Do a general bus probe. This will be a PCI probe for x86 platforms */
+ xf86BusProbe();
+
+ if (xf86DoProbe)
+ DoProbe();
+
+ if (xf86DoConfigure)
+ DoConfigure();
+
+ if (autoconfig) {
+ if (!xf86AutoConfig()) {
+ xf86Msg(X_ERROR, "Auto configuration failed\n");
+ return;
+ }
+ PostConfigInit();
+ }
+
+ /* Initialise the resource broker */
+ xf86ResourceBrokerInit();
+
+#ifdef XFree86LOADER
+ /* Load all modules specified explicitly in the config file */
+ if ((modulelist = xf86ModulelistFromConfig(&optionlist))) {
+ xf86LoadModules(modulelist, optionlist);
+ xfree(modulelist);
+ xfree(optionlist);
+ }
+
+ /* Load all driver modules specified in the config file */
+ if ((modulelist = xf86DriverlistFromConfig())) {
+ xf86LoadModules(modulelist, NULL);
+ xfree(modulelist);
+ }
+
+#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
+ /* Setup the builtin input drivers */
+ xf86AddInputDriver(&XF86KEYBOARD, NULL, 0);
+#endif
+ /* Load all input driver modules specified in the config file. */
+ if ((modulelist = xf86InputDriverlistFromConfig())) {
+ xf86LoadModules(modulelist, NULL);
+ xfree(modulelist);
+ }
+
+ /*
+ * It is expected that xf86AddDriver()/xf86AddInputDriver will be
+ * called for each driver as it is loaded. Those functions save the
+ * module pointers for drivers.
+ * XXX Nothing keeps track of them for other modules.
+ */
+ /* XXX What do we do if not all of these could be loaded? */
+#endif
+
+ /*
+ * At this point, xf86DriverList[] is all filled in with entries for
+ * each of the drivers to try and xf86NumDrivers has the number of
+ * drivers. If there are none, return now.
+ */
+
+ if (xf86NumDrivers == 0) {
+ xf86Msg(X_ERROR, "No drivers available.\n");
+ return;
+ }
+
+ /*
+ * Call each of the Identify functions and call the driverFunc to check
+ * if HW access is required. The Identify functions print out some
+ * identifying information, and anything else that might be
+ * needed at this early stage.
+ */
+
+ for (i = 0; i < xf86NumDrivers; i++) {
+ xorgHWFlags flags;
+ /* The Identify function is mandatory, but if it isn't there continue */
+ if (xf86DriverList[i]->Identify != NULL)
+ xf86DriverList[i]->Identify(0);
+ else {
+ xf86Msg(X_WARNING, "Driver `%s' has no Identify function\n",
+ xf86DriverList[i]->driverName ? xf86DriverList[i]->driverName
+ : "noname");
+ }
+ if (!xorgHWAccess
+ && (!xf86DriverList[i]->driverFunc
+ || !xf86DriverList[i]->driverFunc(NULL,
+ GET_REQUIRED_HW_INTERFACES,
+ &flags)
+ || NEED_IO_ENABLED(flags)))
+ xorgHWAccess = TRUE;
+ }
+
+ /* Enable full I/O access */
+ if (xorgHWAccess) {
+ if(!xf86EnableIO())
+ /* oops, we have failed */
+ xorgHWAccess = FALSE;
+ }
+
+ /*
+ * Locate bus slot that had register IO enabled at server startup
+ */
+
+ xf86AccessInit();
+ xf86FindPrimaryDevice();
+
+ /*
+ * Now call each of the Probe functions. Each successful probe will
+ * result in an extra entry added to the xf86Screens[] list for each
+ * instance of the hardware found.
+ */
+
+ for (i = 0; i < xf86NumDrivers; i++) {
+ xorgHWFlags flags;
+ if (!xorgHWAccess) {
+ if (!xf86DriverList[i]->driverFunc
+ || !xf86DriverList[i]->driverFunc(NULL,
+ GET_REQUIRED_HW_INTERFACES,
+ &flags)
+ || NEED_IO_ENABLED(flags))
+ continue;
+ }
+
+ if (xf86DriverList[i]->Probe != NULL)
+ xf86DriverList[i]->Probe(xf86DriverList[i], PROBE_DEFAULT);
+ else {
+ xf86MsgVerb(X_WARNING, 0,
+ "Driver `%s' has no Probe function (ignoring)\n",
+ xf86DriverList[i]->driverName
+ ? xf86DriverList[i]->driverName : "noname");
+ }
+ xf86SetPciVideo(NULL,NONE);
+ }
+
+ /*
+ * If nothing was detected, return now.
+ */
+
+ if (xf86NumScreens == 0) {
+ xf86Msg(X_ERROR, "No devices detected.\n");
+ return;
+ }
+
+ /*
+ * Match up the screens found by the probes against those specified
+ * in the config file. Remove the ones that won't be used. Sort
+ * them in the order specified.
+ */
+
+ /*
+ * What is the best way to do this?
+ *
+ * For now, go through the screens allocated by the probes, and
+ * look for screen config entry which refers to the same device
+ * section as picked out by the probe.
+ *
+ */
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (layout = xf86ConfigLayout.screens; layout->screen != NULL;
+ layout++) {
+ Bool found = FALSE;
+ for (j = 0; j < xf86Screens[i]->numEntities; j++) {
+
+ GDevPtr dev =
+ xf86GetDevFromEntity(xf86Screens[i]->entityList[j],
+ xf86Screens[i]->entityInstanceList[j]);
+
+ if (dev == layout->screen->device) {
+ /* A match has been found */
+ xf86Screens[i]->confScreen = layout->screen;
+ found = TRUE;
+ break;
+ }
+ }
+ if (found) break;
+ }
+ if (layout->screen == NULL) {
+ /* No match found */
+ xf86Msg(X_ERROR,
+ "Screen %d deleted because of no matching config section.\n", i);
+ xf86DeleteScreen(i--, 0);
+ }
+ }
+
+ /*
+ * If no screens left, return now.
+ */
+
+ if (xf86NumScreens == 0) {
+ xf86Msg(X_ERROR,
+ "Device(s) detected, but none match those in the config file.\n");
+ return;
+ }
+
+ xf86PostProbe();
+ xf86EntityInit();
+
+ /*
+ * Sort the drivers to match the requested ording. Using a slow
+ * bubble sort.
+ */
+ for (j = 0; j < xf86NumScreens - 1; j++) {
+ for (i = 0; i < xf86NumScreens - j - 1; i++) {
+ if (xf86Screens[i + 1]->confScreen->screennum <
+ xf86Screens[i]->confScreen->screennum) {
+ ScrnInfoPtr tmpScrn = xf86Screens[i + 1];
+ xf86Screens[i + 1] = xf86Screens[i];
+ xf86Screens[i] = tmpScrn;
+ }
+ }
+ }
+ /* Fix up the indexes */
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86Screens[i]->scrnIndex = i;
+ }
+
+ /*
+ * Call the driver's PreInit()'s to complete initialisation for the first
+ * generation.
+ */
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86EnableAccess(xf86Screens[i]);
+ if (xf86Screens[i]->PreInit &&
+ xf86Screens[i]->PreInit(xf86Screens[i], 0))
+ xf86Screens[i]->configured = TRUE;
+ }
+ for (i = 0; i < xf86NumScreens; i++)
+ if (!xf86Screens[i]->configured)
+ xf86DeleteScreen(i--, 0);
+
+ /*
+ * If no screens left, return now.
+ */
+
+ if (xf86NumScreens == 0) {
+ xf86Msg(X_ERROR,
+ "Screen(s) found, but none have a usable configuration.\n");
+ return;
+ }
+
+ /* This could be moved into a separate function */
+
+ /*
+ * Check that all screens have initialised the mandatory function
+ * entry points. Delete those which have not.
+ */
+
+#define WARN_SCREEN(func) \
+ xf86Msg(X_ERROR, "Driver `%s' has no %s function, deleting.\n", \
+ xf86Screens[i]->name, (warned++, func))
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ int warned = 0;
+ if (xf86Screens[i]->name == NULL) {
+ xf86Screens[i]->name = xnfalloc(strlen("screen") + 1 + 1);
+ if (i < 10)
+ sprintf(xf86Screens[i]->name, "screen%c", i + '0');
+ else
+ sprintf(xf86Screens[i]->name, "screen%c", i - 10 + 'A');
+ xf86MsgVerb(X_WARNING, 0,
+ "Screen driver %d has no name set, using `%s'.\n",
+ i, xf86Screens[i]->name);
+ }
+ if (xf86Screens[i]->ScreenInit == NULL)
+ WARN_SCREEN("ScreenInit");
+ if (xf86Screens[i]->EnterVT == NULL)
+ WARN_SCREEN("EnterVT");
+ if (xf86Screens[i]->LeaveVT == NULL)
+ WARN_SCREEN("LeaveVT");
+ if (warned)
+ xf86DeleteScreen(i--, 0);
+ }
+
+ /*
+ * If no screens left, return now.
+ */
+
+ if (xf86NumScreens == 0) {
+ xf86Msg(X_ERROR, "Screen(s) found, but drivers were unusable.\n");
+ return;
+ }
+
+ /* XXX Should this be before or after loading dependent modules? */
+ if (xf86ProbeOnly)
+ {
+ OsCleanup(TRUE);
+ AbortDDX();
+ fflush(stderr);
+ exit(0);
+ }
+
+#ifdef XFree86LOADER
+ /* Remove (unload) drivers that are not required */
+ for (i = 0; i < xf86NumDrivers; i++)
+ if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0)
+ xf86DeleteDriver(i);
+#endif
+
+ /*
+ * At this stage we know how many screens there are.
+ */
+
+ for (i = 0; i < xf86NumScreens; i++)
+ xf86InitViewport(xf86Screens[i]);
+
+ /*
+ * Collect all pixmap formats and check for conflicts at the display
+ * level. Should we die here? Or just delete the offending screens?
+ * Also, should this be done for -probeonly?
+ */
+ screenpix24 = Pix24DontCare;
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->imageByteOrder !=
+ xf86Screens[0]->imageByteOrder)
+ FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
+ if (xf86Screens[i]->bitmapScanlinePad !=
+ xf86Screens[0]->bitmapScanlinePad)
+ FatalError("Inconsistent display bitmapScanlinePad. Exiting\n");
+ if (xf86Screens[i]->bitmapScanlineUnit !=
+ xf86Screens[0]->bitmapScanlineUnit)
+ FatalError("Inconsistent display bitmapScanlineUnit. Exiting\n");
+ if (xf86Screens[i]->bitmapBitOrder !=
+ xf86Screens[0]->bitmapBitOrder)
+ FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
+
+ /* Determine the depth 24 pixmap format the screens would like */
+ if (xf86Screens[i]->pixmap24 != Pix24DontCare) {
+ if (screenpix24 == Pix24DontCare)
+ screenpix24 = xf86Screens[i]->pixmap24;
+ else if (screenpix24 != xf86Screens[i]->pixmap24)
+ FatalError("Inconsistent depth 24 pixmap format. Exiting\n");
+ }
+ }
+ /* check if screenpix24 is consistent with the config/cmdline */
+ if (xf86Info.pixmap24 != Pix24DontCare) {
+ pix24 = xf86Info.pixmap24;
+ pix24From = xf86Info.pix24From;
+ if (screenpix24 != Pix24DontCare && screenpix24 != xf86Info.pixmap24)
+ pix24Fail = TRUE;
+ } else if (screenpix24 != Pix24DontCare) {
+ pix24 = screenpix24;
+ pix24From = X_PROBED;
+ } else
+ pix24 = Pix24Use32;
+
+ if (pix24Fail)
+ FatalError("Screen(s) can't use the required depth 24 pixmap format"
+ " (%d). Exiting\n", PIX24TOBPP(pix24));
+
+ /* Initialise the depth 24 format */
+ for (j = 0; j < numFormats && formats[j].depth != 24; j++)
+ ;
+ formats[j].bitsPerPixel = PIX24TOBPP(pix24);
+
+ /* Collect additional formats */
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (j = 0; j < xf86Screens[i]->numFormats; j++) {
+ for (k = 0; ; k++) {
+ if (k >= numFormats) {
+ if (k >= MAXFORMATS)
+ FatalError("Too many pixmap formats! Exiting\n");
+ formats[k] = xf86Screens[i]->formats[j];
+ numFormats++;
+ break;
+ }
+ if (formats[k].depth == xf86Screens[i]->formats[j].depth) {
+ if ((formats[k].bitsPerPixel ==
+ xf86Screens[i]->formats[j].bitsPerPixel) &&
+ (formats[k].scanlinePad ==
+ xf86Screens[i]->formats[j].scanlinePad))
+ break;
+ FatalError("Inconsistent pixmap format for depth %d."
+ " Exiting\n", formats[k].depth);
+ }
+ }
+ }
+ }
+ formatsDone = TRUE;
+
+ if (xf86Info.vtno >= 0 ) {
+#define VT_ATOM_NAME "XFree86_VT"
+ Atom VTAtom=-1;
+ CARD32 *VT = NULL;
+ int ret;
+
+ /* This memory needs to stay available until the screen has been
+ initialized, and we can create the property for real.
+ */
+ if ( (VT = xalloc(sizeof(CARD32)))==NULL ) {
+ FatalError("Unable to make VT property - out of memory. Exiting...\n");
+ }
+ *VT = xf86Info.vtno;
+
+ VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME), TRUE);
+
+ for (i = 0, ret = Success; i < xf86NumScreens && ret == Success; i++) {
+ ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
+ VTAtom, XA_INTEGER, 32,
+ 1, VT );
+ if (ret != Success)
+ xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
+ "Failed to register VT property\n");
+ }
+ }
+
+ /* If a screen uses depth 24, show what the pixmap format is */
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->depth == 24) {
+ xf86Msg(pix24From, "Depth 24 pixmap format is %d bpp\n",
+ PIX24TOBPP(pix24));
+ break;
+ }
+ }
+
+#if BITMAP_SCANLINE_UNIT == 64
+ /*
+ * cfb24 doesn't currently work on architectures with a 64 bit
+ * BITMAP_SCANLINE_UNIT, so check for 24 bit pixel size for pixmaps
+ * or framebuffers.
+ */
+ {
+ Bool usesCfb24 = FALSE;
+
+ if (PIX24TOBPP(pix24) == 24)
+ usesCfb24 = TRUE;
+ for (i = 0; i < xf86NumScreens; i++)
+ if (xf86Screens[i]->bitsPerPixel == 24)
+ usesCfb24 = TRUE;
+ if (usesCfb24) {
+ FatalError("24-bit pixel size is not supported on systems with"
+ " 64-bit scanlines.\n");
+ }
+ }
+#endif
+
+#ifdef XKB
+ xf86InitXkb();
+#endif
+ /* set up the proper access funcs */
+ xf86PostPreInit();
+
+ AddCallback(&ServerGrabCallback, xf86GrabServerCallback, NULL);
+
+ } else {
+ /*
+ * serverGeneration != 1; some OSs have to do things here, too.
+ */
+ xf86OpenConsole();
+
+#ifdef XF86PM
+ /*
+ should we reopen it here? We need to deal with an already opened
+ device. We could leave this to the OS layer. For now we simply
+ close it here
+ */
+ if (xf86OSPMClose)
+ xf86OSPMClose();
+ if ((xf86OSPMClose = xf86OSPMOpen()) != NULL)
+ xf86MsgVerb(X_INFO, 3, "APM registered successfully\n");
+#endif
+
+ /* Make sure full I/O access is enabled */
+ if (xorgHWAccess)
+ xf86EnableIO();
+ }
+
+#if 0
+ /*
+ * Install signal handler for unexpected signals
+ */
+ xf86Info.caughtSignal=FALSE;
+ if (!xf86Info.notrapSignals)
+ {
+ signal(SIGSEGV,xf86SigHandler);
+ signal(SIGILL,xf86SigHandler);
+#ifdef SIGEMT
+ signal(SIGEMT,xf86SigHandler);
+#endif
+ signal(SIGFPE,xf86SigHandler);
+#ifdef SIGBUS
+ signal(SIGBUS,xf86SigHandler);
+#endif
+#ifdef SIGSYS
+ signal(SIGSYS,xf86SigHandler);
+#endif
+#ifdef SIGXCPU
+ signal(SIGXCPU,xf86SigHandler);
+#endif
+#ifdef SIGXFSZ
+ signal(SIGXFSZ,xf86SigHandler);
+#endif
+ }
+#endif
+
+ /*
+ * Use the previously collected parts to setup pScreenInfo
+ */
+
+ pScreenInfo->imageByteOrder = xf86Screens[0]->imageByteOrder;
+ pScreenInfo->bitmapScanlinePad = xf86Screens[0]->bitmapScanlinePad;
+ pScreenInfo->bitmapScanlineUnit = xf86Screens[0]->bitmapScanlineUnit;
+ pScreenInfo->bitmapBitOrder = xf86Screens[0]->bitmapBitOrder;
+ pScreenInfo->numPixmapFormats = numFormats;
+ for (i = 0; i < numFormats; i++)
+ pScreenInfo->formats[i] = formats[i];
+
+ /* Make sure the server's VT is active */
+
+ if (serverGeneration != 1) {
+ xf86Resetting = TRUE;
+ /* All screens are in the same state, so just check the first */
+ if (!xf86Screens[0]->vtSema) {
+#ifdef HAS_USL_VTS
+ ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ);
+#endif
+ xf86AccessEnter();
+ xf86EnterServerState(SETUP);
+ }
+ }
+#ifdef SCO325
+ else {
+ /*
+ * Under SCO we must ack that we got the console at startup,
+ * I think this is the safest way to assure it.
+ */
+ static int once = 1;
+ if (once) {
+ once = 0;
+ if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
+ xf86Msg(X_WARNING, "VT_ACKACQ failed");
+ }
+ }
+#endif /* SCO325 */
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86EnableAccess(xf86Screens[i]);
+ /*
+ * Almost everything uses these defaults, and many of those that
+ * don't, will wrap them.
+ */
+ xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess;
+ xf86Screens[i]->SetDGAMode = xf86SetDGAMode;
+ xf86Screens[i]->DPMSSet = NULL;
+ xf86Screens[i]->LoadPalette = NULL;
+ xf86Screens[i]->SetOverscan = NULL;
+ xf86Screens[i]->DriverFunc = NULL;
+ xf86Screens[i]->pScreen = NULL;
+ scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv);
+ if (scr_index == i) {
+ /*
+ * Hook in our ScrnInfoRec, and initialise some other pScreen
+ * fields.
+ */
+ screenInfo.screens[scr_index]->devPrivates[xf86ScreenIndex].ptr
+ = (pointer)xf86Screens[i];
+ xf86Screens[i]->pScreen = screenInfo.screens[scr_index];
+ /* The driver should set this, but make sure it is set anyway */
+ xf86Screens[i]->vtSema = TRUE;
+ } else {
+ /* This shouldn't normally happen */
+ FatalError("AddScreen/ScreenInit failed for driver %d\n", i);
+ }
+
+#ifdef DEBUG
+ ErrorF("InitOutput - xf86Screens[%d]->pScreen = %p\n",
+ i, xf86Screens[i]->pScreen );
+ ErrorF("xf86Screens[%d]->pScreen->CreateWindow = %p\n",
+ i, xf86Screens[i]->pScreen->CreateWindow );
+#endif
+
+ screenInfo.screens[scr_index]->devPrivates[xf86CreateRootWindowIndex].ptr
+ = (void*)(xf86Screens[i]->pScreen->CreateWindow);
+ xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow;
+
+#ifdef RENDER
+ if (PictureGetSubpixelOrder (xf86Screens[i]->pScreen) == SubPixelUnknown)
+ {
+ xf86MonPtr DDC = (xf86MonPtr)(xf86Screens[i]->monitor->DDC);
+ PictureSetSubpixelOrder (xf86Screens[i]->pScreen,
+ DDC ?
+ (DDC->features.input_type ?
+ SubPixelHorizontalRGB : SubPixelNone) :
+ SubPixelUnknown);
+ }
+#endif
+#ifdef RANDR
+ if (!xf86Info.disableRandR)
+ xf86RandRInit (screenInfo.screens[scr_index]);
+ xf86Msg(xf86Info.randRFrom, "RandR %s\n",
+ xf86Info.disableRandR ? "disabled" : "enabled");
+#endif
+#ifdef NOT_USED
+ /*
+ * Here we have to let the driver getting access of the VT. Note that
+ * this doesn't mean that the graphics board may access automatically
+ * the monitor. If the monitor is shared this is done in xf86CrossScreen!
+ */
+ if (!xf86Info.sharedMonitor) (xf86Screens[i]->EnterLeaveMonitor)(ENTER);
+#endif
+ }
+
+#ifdef XFree86LOADER
+ if ((serverGeneration == 1) && LoaderCheckUnresolved(LD_RESOLV_IFDONE)) {
+ /* For now, just a warning */
+ xf86Msg(X_WARNING, "Some symbols could not be resolved!\n");
+ }
+#endif
+
+ xf86PostScreenInit();
+
+ xf86InitOrigins();
+
+ xf86Resetting = FALSE;
+ xf86Initialising = FALSE;
+
+ RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, xf86Wakeup,
+ NULL);
+}
+
+
+static InputDriverPtr
+MatchInput(IDevPtr pDev)
+{
+ int i;
+
+ for (i = 0; i < xf86NumInputDrivers; i++) {
+ if (xf86InputDriverList[i] && xf86InputDriverList[i]->driverName &&
+ xf86NameCmp(pDev->driver, xf86InputDriverList[i]->driverName) == 0)
+ return xf86InputDriverList[i];
+ }
+ return NULL;
+}
+
+
+/*
+ * InitInput --
+ * Initialize all supported input devices.
+ */
+
+void
+InitInput(argc, argv)
+ int argc;
+ char **argv;
+{
+ IDevPtr pDev;
+ InputDriverPtr pDrv;
+ InputInfoPtr pInfo;
+ static InputInfoPtr coreKeyboard = NULL, corePointer = NULL;
+
+ xf86Info.vtRequestsPending = FALSE;
+ xf86Info.inputPending = FALSE;
+#ifdef XTESTEXT1
+ xtest_command_key = KEY_Begin + MIN_KEYCODE;
+#endif /* XTESTEXT1 */
+
+ if (serverGeneration == 1) {
+ /* Call the PreInit function for each input device instance. */
+ for (pDev = xf86ConfigLayout.inputs; pDev && pDev->identifier; pDev++) {
+#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
+ /* XXX The keyboard driver is a special case for now. */
+ if (!xf86NameCmp(pDev->driver, "keyboard")) {
+ xf86MsgVerb(X_WARNING, 0, "*** WARNING the legacy keyboard driver \"keyboard\" is deprecated\n");
+ xf86MsgVerb(X_WARNING, 0, "*** and will be removed in the next release of the Xorg server.\n");
+ xf86MsgVerb(X_WARNING, 0, "*** Please consider using the the new \"kbd\" driver for \"%s\".\n",
+ pDev->identifier);
+
+ continue;
+ }
+#endif
+
+ if ((pDrv = MatchInput(pDev)) == NULL) {
+ xf86Msg(X_ERROR, "No Input driver matching `%s'\n", pDev->driver);
+ /* XXX For now, just continue. */
+ continue;
+ }
+ if (!pDrv->PreInit) {
+ xf86MsgVerb(X_WARNING, 0,
+ "Input driver `%s' has no PreInit function (ignoring)\n",
+ pDrv->driverName);
+ continue;
+ }
+ pInfo = pDrv->PreInit(pDrv, pDev, 0);
+ if (!pInfo) {
+ xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n",
+ pDev->identifier);
+ continue;
+ } else if (!(pInfo->flags & XI86_CONFIGURED)) {
+ xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
+ pDev->identifier);
+ xf86DeleteInput(pInfo, 0);
+ continue;
+ }
+ if (pInfo->flags & XI86_CORE_KEYBOARD) {
+ if (coreKeyboard) {
+ xf86Msg(X_ERROR,
+ "Attempt to register more than one core keyboard (%s)\n",
+ pInfo->name);
+ pInfo->flags &= ~XI86_CORE_KEYBOARD;
+ } else {
+ if (!(pInfo->flags & XI86_KEYBOARD_CAPABLE)) {
+ /* XXX just a warning for now */
+ xf86Msg(X_WARNING,
+ "%s: does not have core keyboard capabilities\n",
+ pInfo->name);
+ }
+ coreKeyboard = pInfo;
+ }
+ }
+ if (pInfo->flags & XI86_CORE_POINTER) {
+ if (corePointer) {
+ xf86Msg(X_ERROR,
+ "Attempt to register more than one core pointer (%s)\n",
+ pInfo->name);
+ pInfo->flags &= ~XI86_CORE_POINTER;
+ } else {
+ if (!(pInfo->flags & XI86_POINTER_CAPABLE)) {
+ /* XXX just a warning for now */
+ xf86Msg(X_WARNING,
+ "%s: does not have core pointer capabilities\n",
+ pInfo->name);
+ }
+ corePointer = pInfo;
+ }
+ }
+ }
+ if (!corePointer) {
+ xf86Msg(X_WARNING, "No core pointer registered\n");
+ /* XXX register a dummy core pointer */
+ }
+#ifdef NEW_KBD
+ if (!coreKeyboard) {
+ xf86Msg(X_WARNING, "No core keyboard registered\n");
+ /* XXX register a dummy core keyboard */
+ }
+#endif
+ }
+
+ /* Initialise all input devices. */
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ xf86ActivateDevice(pInfo);
+ pInfo = pInfo->next;
+ }
+
+ if (coreKeyboard) {
+ xf86Info.pKeyboard = coreKeyboard->dev;
+ xf86Info.kbdEvents = NULL; /* to prevent the internal keybord driver usage*/
+ }
+ else {
+#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
+ /* Only set this if we're allowing the old driver. */
+ if (xf86Info.kbdProc != NULL)
+ xf86Info.pKeyboard = AddInputDevice(xf86Info.kbdProc, TRUE);
+#endif
+ }
+ if (corePointer)
+ xf86Info.pMouse = corePointer->dev;
+ if (xf86Info.pKeyboard)
+ RegisterKeyboardDevice(xf86Info.pKeyboard);
+
+ miRegisterPointerDevice(screenInfo.screens[0], xf86Info.pMouse);
+#ifdef XINPUT
+ xf86eqInit ((DevicePtr)xf86Info.pKeyboard, (DevicePtr)xf86Info.pMouse);
+#else
+ mieqInit ((DevicePtr)xf86Info.pKeyboard, (DevicePtr)xf86Info.pMouse);
+#endif
+}
+
+#ifndef SET_STDERR_NONBLOCKING
+#define SET_STDERR_NONBLOCKING 1
+#endif
+
+/*
+ * OsVendorInit --
+ * OS/Vendor-specific initialisations. Called from OsInit(), which
+ * is called by dix before establishing the well known sockets.
+ */
+
+void
+OsVendorInit()
+{
+ static Bool beenHere = FALSE;
+
+ /* xf86WrapperInit() is called directly from OsInit() */
+#ifdef SIGCHLD
+ signal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */
+#endif
+ OsDelayInitColors = TRUE;
+#ifdef XFree86LOADER
+ loadableFonts = TRUE;
+#endif
+
+ if (!beenHere)
+ xf86LogInit();
+
+#if SET_STDERR_NONBLOCKING
+ /* Set stderr to non-blocking. */
+#ifndef O_NONBLOCK
+#if defined(FNDELAY)
+#define O_NONBLOCK FNDELAY
+#elif defined(O_NDELAY)
+#define O_NONBLOCK O_NDELAY
+#endif
+#endif
+
+#ifdef O_NONBLOCK
+ if (!beenHere) {
+#if !defined(__EMX__)
+ if (geteuid() == 0 && getuid() != geteuid())
+#endif
+ {
+ int status;
+
+ status = fcntl(fileno(stderr), F_GETFL, 0);
+ if (status != -1) {
+ fcntl(fileno(stderr), F_SETFL, status | O_NONBLOCK);
+ }
+ }
+ }
+#endif
+#endif
+
+ beenHere = TRUE;
+}
+
+/*
+ * ddxGiveUp --
+ * Device dependent cleanup. Called by by dix before normal server death.
+ * For SYSV386 we must switch the terminal back to normal mode. No error-
+ * checking here, since there should be restored as much as possible.
+ */
+
+void
+ddxGiveUp()
+{
+ int i;
+
+#ifdef XF86PM
+ if (xf86OSPMClose)
+ xf86OSPMClose();
+ xf86OSPMClose = NULL;
+#endif
+
+ xf86AccessLeaveState();
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ /*
+ * zero all access functions to
+ * trap calls when switched away.
+ */
+ xf86Screens[i]->vtSema = FALSE;
+ xf86Screens[i]->access = NULL;
+ xf86Screens[i]->busAccess = NULL;
+ }
+
+#ifdef USE_XF86_SERVERLOCK
+ xf86UnlockServer();
+#endif
+#ifdef XFreeXDGA
+ DGAShutdown();
+#endif
+
+ xf86CloseConsole();
+
+ xf86CloseLog();
+
+ /* If an unexpected signal was caught, dump a core for debugging */
+ if (xf86Info.caughtSignal)
+ abort();
+}
+
+
+
+/*
+ * AbortDDX --
+ * DDX - specific abort routine. Called by AbortServer(). The attempt is
+ * made to restore all original setting of the displays. Also all devices
+ * are closed.
+ */
+
+void
+AbortDDX()
+{
+ int i;
+
+ /*
+ * try to deinitialize all input devices
+ */
+ if (xf86Info.kbdProc && xf86Info.pKeyboard)
+ (xf86Info.kbdProc)(xf86Info.pKeyboard, DEVICE_CLOSE);
+
+ /*
+ * try to restore the original video state
+ */
+#ifdef HAS_USL_VTS
+ /* Need the sleep when starting X from within another X session */
+ sleep(1);
+#endif
+#ifdef DPMSExtension /* Turn screens back on */
+ if (DPMSPowerLevel != DPMSModeOn)
+ DPMSSet(DPMSModeOn);
+#endif
+ if (xf86Screens) {
+ if (xf86Screens[0]->vtSema)
+ xf86EnterServerState(SETUP);
+ for (i = 0; i < xf86NumScreens; i++)
+ if (xf86Screens[i]->vtSema) {
+ /*
+ * if we are aborting before ScreenInit() has finished
+ * we might not have been wrapped yet. Therefore enable
+ * screen explicitely.
+ */
+ xf86EnableAccess(xf86Screens[i]);
+ (xf86Screens[i]->LeaveVT)(i, 0);
+ }
+ }
+
+ xf86AccessLeave();
+
+ /*
+ * This is needed for an abnormal server exit, since the normal exit stuff
+ * MUST also be performed (i.e. the vt must be left in a defined state)
+ */
+ ddxGiveUp();
+}
+
+void
+OsVendorFatalError()
+{
+#ifdef VENDORSUPPORT
+ ErrorF("\nPlease refer to your Operating System Vendor support pages\n"
+ "at %s for support on this crash.\n",VENDORSUPPORT);
+#else
+ ErrorF("\nPlease consult the "XVENDORNAME" support \n"
+ "\t at "__VENDORDWEBSUPPORT__"\n for help. \n");
+#endif
+ if (xf86LogFile && xf86LogFileWasOpened)
+ ErrorF("Please also check the log file at \"%s\" for additional "
+ "information.\n", xf86LogFile);
+ ErrorF("\n");
+}
+
+int
+xf86SetVerbosity(int verb)
+{
+ int save = xf86Verbose;
+
+ xf86Verbose = verb;
+ LogSetParameter(XLOG_VERBOSITY, verb);
+ return save;
+}
+
+int
+xf86SetLogVerbosity(int verb)
+{
+ int save = xf86LogVerbose;
+
+ xf86LogVerbose = verb;
+ LogSetParameter(XLOG_FILE_VERBOSITY, verb);
+ return save;
+}
+
+/*
+ * ddxProcessArgument --
+ * Process device-dependent command line args. Returns 0 if argument is
+ * not device dependent, otherwise Count of number of elements of argv
+ * that are part of a device dependent commandline option.
+ *
+ */
+
+
+
+/* ARGSUSED */
+int
+ddxProcessArgument(int argc, char **argv, int i)
+{
+ /*
+ * Note: can't use xalloc/xfree here because OsInit() hasn't been called
+ * yet. Use malloc/free instead.
+ */
+
+#define CHECK_FOR_REQUIRED_ARGUMENT() \
+ if (((i + 1) >= argc) || (!argv[i + 1])) { \
+ ErrorF("Required argument to %s not specified\n", argv[i]); \
+ UseMsg(); \
+ FatalError("Required argument to %s not specified\n", argv[i]); \
+ }
+
+ /* First the options that are only allowed for root */
+ if (getuid() == 0 || geteuid() != 0)
+ {
+ if (!strcmp(argv[i], "-modulepath"))
+ {
+ char *mp;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ mp = malloc(strlen(argv[i + 1]) + 1);
+ if (!mp)
+ FatalError("Can't allocate memory for ModulePath\n");
+ strcpy(mp, argv[i + 1]);
+ xf86ModulePath = mp;
+ xf86ModPathFrom = X_CMDLINE;
+ return 2;
+ }
+ else if (!strcmp(argv[i], "-logfile"))
+ {
+ char *lf;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ lf = malloc(strlen(argv[i + 1]) + 1);
+ if (!lf)
+ FatalError("Can't allocate memory for LogFile\n");
+ strcpy(lf, argv[i + 1]);
+ xf86LogFile = lf;
+ xf86LogFileFrom = X_CMDLINE;
+ return 2;
+ }
+ } else if (!strcmp(argv[i], "-modulepath") || !strcmp(argv[i], "-logfile")) {
+ FatalError("The '%s' option can only be used by root.\n", argv[i]);
+ }
+ if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) {
+ FatalError("\nInvalid argument for %s\n"
+ "\tFor non-root users, the file specified with %s must be\n"
+ "\ta relative path and must not contain any \"..\" elements.\n"
+ "\tUsing default "__XCONFIGFILE__" search path.\n\n",
+ argv[i], argv[i]);
+ }
+ xf86ConfigFile = argv[i + 1];
+ return 2;
+ }
+ if (!strcmp(argv[i],"-showunresolved"))
+ {
+ xf86ShowUnresolved = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i],"-probeonly"))
+ {
+ xf86ProbeOnly = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i],"-flipPixels"))
+ {
+ xf86FlipPixels = TRUE;
+ return 1;
+ }
+#ifdef XF86VIDMODE
+ if (!strcmp(argv[i],"-disableVidMode"))
+ {
+ xf86VidModeDisabled = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i],"-allowNonLocalXvidtune"))
+ {
+ xf86VidModeAllowNonLocal = TRUE;
+ return 1;
+ }
+#endif
+#ifdef XF86MISC
+ if (!strcmp(argv[i],"-disableModInDev"))
+ {
+ xf86MiscModInDevDisabled = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i],"-allowNonLocalModInDev"))
+ {
+ xf86MiscModInDevAllowNonLocal = TRUE;
+ return 1;
+ }
+#endif
+ if (!strcmp(argv[i],"-allowMouseOpenFail"))
+ {
+ xf86AllowMouseOpenFail = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i],"-bestRefresh"))
+ {
+ xf86BestRefresh = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i],"-ignoreABI"))
+ {
+#ifdef XFree86LOADER
+ LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
+#endif
+ return 1;
+ }
+ if (!strcmp(argv[i],"-verbose"))
+ {
+ if (++i < argc && argv[i])
+ {
+ char *end;
+ long val;
+ val = strtol(argv[i], &end, 0);
+ if (*end == '\0')
+ {
+ xf86SetVerbosity(val);
+ return 2;
+ }
+ }
+ xf86SetVerbosity(++xf86Verbose);
+ return 1;
+ }
+ if (!strcmp(argv[i],"-logverbose"))
+ {
+ if (++i < argc && argv[i])
+ {
+ char *end;
+ long val;
+ val = strtol(argv[i], &end, 0);
+ if (*end == '\0')
+ {
+ xf86SetLogVerbosity(val);
+ return 2;
+ }
+ }
+ xf86SetLogVerbosity(++xf86LogVerbose);
+ return 1;
+ }
+ if (!strcmp(argv[i],"-quiet"))
+ {
+ xf86SetVerbosity(0);
+ return 1;
+ }
+ if (!strcmp(argv[i],"-showconfig") || !strcmp(argv[i],"-version"))
+ {
+ xf86PrintBanner();
+ exit(0);
+ }
+ /* Notice the -fp flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "-fp"))
+ {
+ xf86fpFlag = TRUE;
+ return 0;
+ }
+ /* Notice the -co flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "-co"))
+ {
+ xf86coFlag = TRUE;
+ return 0;
+ }
+ /* Notice the -bs flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "-bs"))
+ {
+ xf86bsDisableFlag = TRUE;
+ return 0;
+ }
+ /* Notice the +bs flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "+bs"))
+ {
+ xf86bsEnableFlag = TRUE;
+ return 0;
+ }
+ /* Notice the -s flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "-s"))
+ {
+ xf86sFlag = TRUE;
+ return 0;
+ }
+ if (!strcmp(argv[i], "-bpp"))
+ {
+ ErrorF("The -bpp option is no longer supported.\n"
+ "\tUse -depth to set the color depth, and use -fbbpp if you really\n"
+ "\tneed to force a non-default framebuffer (hardware) pixel format.\n");
+ if (++i >= argc)
+ return 1;
+ return 2;
+ }
+ if (!strcmp(argv[i], "-pixmap24"))
+ {
+ xf86Pix24 = Pix24Use24;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-pixmap32"))
+ {
+ xf86Pix24 = Pix24Use32;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-fbbpp"))
+ {
+ int bpp;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (sscanf(argv[++i], "%d", &bpp) == 1)
+ {
+ xf86FbBpp = bpp;
+ return 2;
+ }
+ else
+ {
+ ErrorF("Invalid fbbpp\n");
+ return 0;
+ }
+ }
+ if (!strcmp(argv[i], "-depth"))
+ {
+ int depth;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (sscanf(argv[++i], "%d", &depth) == 1)
+ {
+ xf86Depth = depth;
+ return 2;
+ }
+ else
+ {
+ ErrorF("Invalid depth\n");
+ return 0;
+ }
+ }
+ if (!strcmp(argv[i], "-weight"))
+ {
+ int red, green, blue;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (sscanf(argv[++i], "%1d%1d%1d", &red, &green, &blue) == 3)
+ {
+ xf86Weight.red = red;
+ xf86Weight.green = green;
+ xf86Weight.blue = blue;
+ return 2;
+ }
+ else
+ {
+ ErrorF("Invalid weighting\n");
+ return 0;
+ }
+ }
+ if (!strcmp(argv[i], "-gamma") || !strcmp(argv[i], "-rgamma") ||
+ !strcmp(argv[i], "-ggamma") || !strcmp(argv[i], "-bgamma"))
+ {
+ double gamma;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (sscanf(argv[++i], "%lf", &gamma) == 1) {
+ if (gamma < GAMMA_MIN || gamma > GAMMA_MAX) {
+ ErrorF("gamma out of range, only %.2f <= gamma_value <= %.1f"
+ " is valid\n", GAMMA_MIN, GAMMA_MAX);
+ return 0;
+ }
+ if (!strcmp(argv[i-1], "-gamma"))
+ xf86Gamma.red = xf86Gamma.green = xf86Gamma.blue = gamma;
+ else if (!strcmp(argv[i-1], "-rgamma")) xf86Gamma.red = gamma;
+ else if (!strcmp(argv[i-1], "-ggamma")) xf86Gamma.green = gamma;
+ else if (!strcmp(argv[i-1], "-bgamma")) xf86Gamma.blue = gamma;
+ return 2;
+ }
+ }
+ if (!strcmp(argv[i], "-layout"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ xf86LayoutName = argv[++i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-screen"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ xf86ScreenName = argv[++i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-pointer"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ xf86PointerName = argv[++i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-keyboard"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ xf86KeyboardName = argv[++i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-nosilk"))
+ {
+ xf86silkenMouseDisableFlag = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-noacpi"))
+ {
+ xf86acpiDisableFlag = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-scanpci"))
+ {
+ DoScanPci(argc, argv, i);
+ }
+ if (!strcmp(argv[i], "-probe"))
+ {
+ xf86DoProbe = TRUE;
+#if 0
+ DoProbe(argc, argv, i);
+#endif
+ return 1;
+ }
+ if (!strcmp(argv[i], "-configure"))
+ {
+ if (getuid() != 0 && geteuid() == 0) {
+ ErrorF("The '-configure' option can only be used by root.\n");
+ exit(1);
+ }
+ xf86DoConfigure = TRUE;
+ xf86AllowMouseOpenFail = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-isolateDevice"))
+ {
+ int bus, device, func;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (strncmp(argv[++i], "PCI:", 4)) {
+ FatalError("Bus types other than PCI not yet isolable\n");
+ }
+ if (sscanf(argv[i], "PCI:%d:%d:%d", &bus, &device, &func) == 3) {
+ xf86IsolateDevice.bus = bus;
+ xf86IsolateDevice.device = device;
+ xf86IsolateDevice.func = func;
+ return 2;
+ } else {
+ FatalError("Invalid isolated device specification\n");
+ }
+ }
+ /* OS-specific processing */
+ return xf86ProcessArgument(argc, argv, i);
+}
+
+/* ddxInitGlobals - called by |InitGlobals| from os/util.c */
+void ddxInitGlobals(void)
+{
+}
+
+/*
+ * ddxUseMsg --
+ * Print out correct use of device dependent commandline options.
+ * Maybe the user now knows what really to do ...
+ */
+
+void
+ddxUseMsg()
+{
+ ErrorF("\n");
+ ErrorF("\n");
+ ErrorF("Device Dependent Usage\n");
+ if (getuid() == 0 || geteuid() != 0)
+ {
+ ErrorF("-modulepath paths specify the module search path\n");
+ ErrorF("-logfile file specify a log file name\n");
+ ErrorF("-configure probe for devices and write an "__XCONFIGFILE__"\n");
+ }
+ ErrorF("-config file specify a configuration file, relative to the\n");
+ ErrorF(" "__XCONFIGFILE__" search path, only root can use absolute\n");
+ ErrorF("-probeonly probe for devices, then exit\n");
+ ErrorF("-scanpci execute the scanpci module and exit\n");
+ ErrorF("-verbose [n] verbose startup messages\n");
+ ErrorF("-logverbose [n] verbose log messages\n");
+ ErrorF("-quiet minimal startup messages\n");
+ ErrorF("-pixmap24 use 24bpp pixmaps for depth 24\n");
+ ErrorF("-pixmap32 use 32bpp pixmaps for depth 24\n");
+ ErrorF("-fbbpp n set bpp for the framebuffer. Default: 8\n");
+ ErrorF("-depth n set colour depth. Default: 8\n");
+ ErrorF("-gamma f set gamma value (0.1 < f < 10.0) Default: 1.0\n");
+ ErrorF("-rgamma f set gamma value for red phase\n");
+ ErrorF("-ggamma f set gamma value for green phase\n");
+ ErrorF("-bgamma f set gamma value for blue phase\n");
+ ErrorF("-weight nnn set RGB weighting at 16 bpp. Default: 565\n");
+ ErrorF("-layout name specify the ServerLayout section name\n");
+ ErrorF("-screen name specify the Screen section name\n");
+ ErrorF("-keyboard name specify the core keyboard InputDevice name\n");
+ ErrorF("-pointer name specify the core pointer InputDevice name\n");
+ ErrorF("-nosilk disable Silken Mouse\n");
+ ErrorF("-flipPixels swap default black/white Pixel values\n");
+#ifdef XF86VIDMODE
+ ErrorF("-disableVidMode disable mode adjustments with xvidtune\n");
+ ErrorF("-allowNonLocalXvidtune allow xvidtune to be run as a non-local client\n");
+#endif
+#ifdef XF86MISC
+ ErrorF("-disableModInDev disable dynamic modification of input device settings\n");
+ ErrorF("-allowNonLocalModInDev allow changes to keyboard and mouse settings\n");
+ ErrorF(" from non-local clients\n");
+ ErrorF("-allowMouseOpenFail start server even if the mouse can't be initialized\n");
+#endif
+ ErrorF("-bestRefresh choose modes with the best refresh rate\n");
+ ErrorF("-ignoreABI make module ABI mismatches non-fatal\n");
+ ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n");
+ ErrorF("-version show the server version\n");
+ /* OS-specific usage */
+ xf86UseMsg();
+ ErrorF("\n");
+}
+
+
+#ifndef OSNAME
+#define OSNAME " unknown"
+#endif
+#ifndef OSVENDOR
+#define OSVENDOR ""
+#endif
+#ifndef PRE_RELEASE
+#define PRE_RELEASE XORG_VERSION_SNAP
+#endif
+
+static void
+xf86PrintBanner()
+{
+#if PRE_RELEASE
+ ErrorF("\n"
+ "This is a pre-release version of the X server from " XVENDORNAME ".\n"
+ "It is not supported in any way.\n"
+ "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n"
+ "Select the \"xorg\" product for bugs you find in this release.\n"
+ "Before reporting bugs in pre-release versions please check the\n"
+ "latest version in the X.Org Foundation CVS repository.\n"
+ "See http://wiki.x.org/wiki/CvsPage for CVS access instructions.\n");
+#endif
+ ErrorF("\nX Window System Version %d.%d.%d",
+ XORG_VERSION_MAJOR,
+ XORG_VERSION_MINOR,
+ XORG_VERSION_PATCH);
+#if XORG_VERSION_SNAP > 0
+ ErrorF(".%d", XORG_VERSION_SNAP);
+#endif
+
+#if XORG_VERSION_SNAP >= 900
+ /* When the minor number is 99, that signifies that the we are making
+ * a release candidate for a major version. (X.0.0)
+ * When the patch number is 99, that signifies that the we are making
+ * a release candidate for a minor version. (X.Y.0)
+ * When the patch number is < 99, then we are making a release
+ * candidate for the next point release. (X.Y.Z)
+ */
+#if XORG_VERSION_MINOR >= 99
+ ErrorF(" (%d.0.0 RC %d)", XORG_VERSION_MAJOR+1, XORG_VERSION_SNAP - 900);
+#elif XORG_VERSION_PATCH == 99
+ ErrorF(" (%d.%d.0 RC %d)", XORG_VERSION_MAJOR, XORG_VERSION_MINOR + 1,
+ XORG_VERSION_SNAP - 900);
+#else
+ ErrorF(" (%d.%d.%d RC %d)", XORG_VERSION_MAJOR, XORG_VERSION_MINOR,
+ XORG_VERSION_PATCH + 1, XORG_VERSION_SNAP - 900);
+#endif
+#endif
+
+#ifdef XORG_CUSTOM_VERSION
+ ErrorF(" (%s)", XORG_CUSTOM_VERSION);
+#endif
+#ifndef XORG_DATE
+#define XORG_DATE XF86_DATE
+#endif
+ ErrorF("\nRelease Date: %s\n", XORG_DATE);
+ ErrorF("X Protocol Version %d, Revision %d, %s\n",
+ X_PROTOCOL, X_PROTOCOL_REVISION, XORG_RELEASE );
+ ErrorF("Build Operating System:%s%s\n", OSNAME, OSVENDOR);
+#ifdef HAS_UTSNAME
+ {
+ struct utsname name;
+
+ /* Linux & BSD state that 0 is success, SysV (including Solaris, HP-UX,
+ and Irix) and Single Unix Spec 3 just say that non-negative is success.
+ All agree that failure is represented by a negative number.
+ */
+ if (uname(&name) >= 0) {
+ ErrorF("Current Operating System: %s %s %s %s %s\n",
+ name.sysname, name.nodename, name.release, name.version, name.machine);
+ }
+ }
+#endif
+#if defined(BUILD_DATE) && (BUILD_DATE > 19000000)
+ {
+ struct tm t;
+ char buf[100];
+
+ bzero(&t, sizeof(t));
+ bzero(buf, sizeof(buf));
+ t.tm_mday = BUILD_DATE % 100;
+ t.tm_mon = (BUILD_DATE / 100) % 100 - 1;
+ t.tm_year = BUILD_DATE / 10000 - 1900;
+ if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
+ ErrorF("Build Date: %s\n", buf);
+ }
+#endif
+#if defined(CLOG_DATE) && (CLOG_DATE > 19000000)
+ {
+ struct tm t;
+ char buf[100];
+
+ bzero(&t, sizeof(t));
+ bzero(buf, sizeof(buf));
+ t.tm_mday = CLOG_DATE % 100;
+ t.tm_mon = (CLOG_DATE / 100) % 100 - 1;
+ t.tm_year = CLOG_DATE / 10000 - 1900;
+ if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
+ ErrorF("Changelog Date: %s\n", buf);
+ }
+#endif
+#if defined(BUILDERSTRING)
+ ErrorF("%s \n",BUILDERSTRING);
+#endif
+ ErrorF("\tBefore reporting problems, check "__VENDORDWEBSUPPORT__"\n"
+ "\tto make sure that you have the latest version.\n");
+#ifdef XFree86LOADER
+ ErrorF("Module Loader present\n");
+#endif
+}
+
+static void
+xf86PrintMarkers()
+{
+ LogPrintMarkers();
+}
+
+static void
+xf86RunVtInit(void)
+{
+ int i;
+
+ /*
+ * If VTInit was set, run that program with consoleFd as stdin and stdout
+ */
+
+ if (xf86Info.vtinit) {
+ switch(fork()) {
+ case -1:
+ FatalError("xf86RunVtInit: fork failed (%s)\n", strerror(errno));
+ break;
+ case 0: /* child */
+ if (setuid(getuid()) == -1) {
+ xf86Msg(X_ERROR, "xf86RunVtInit: setuid failed (%s)\n",
+ strerror(errno));
+ exit(255);
+ }
+ /* set stdin, stdout to the consoleFd */
+ for (i = 0; i < 2; i++) {
+ if (xf86Info.consoleFd != i) {
+ close(i);
+ dup(xf86Info.consoleFd);
+ }
+ }
+ execl("/bin/sh", "sh", "-c", xf86Info.vtinit, (void *)NULL);
+ xf86Msg(X_WARNING, "exec of /bin/sh failed for VTInit (%s)\n",
+ strerror(errno));
+ exit(255);
+ break;
+ default: /* parent */
+ wait(NULL);
+ }
+ }
+}
+
+#ifdef XFree86LOADER
+/*
+ * xf86LoadModules iterates over a list that is being passed in.
+ */
+Bool
+xf86LoadModules(char **list, pointer *optlist)
+{
+ int errmaj, errmin;
+ pointer opt;
+ int i;
+ char *name;
+ Bool failed = FALSE;
+
+ if (!list)
+ return TRUE;
+
+ for (i = 0; list[i] != NULL; i++) {
+
+#ifndef NORMALISE_MODULE_NAME
+ name = xstrdup(list[i]);
+#else
+ /* Normalise the module name */
+ name = xf86NormalizeName(list[i]);
+#endif
+
+ /* Skip empty names */
+ if (name == NULL || *name == '\0')
+ continue;
+
+ if (optlist)
+ opt = optlist[i];
+ else
+ opt = NULL;
+
+ if (!LoadModule(name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin)) {
+ LoaderErrorMsg(NULL, name, errmaj, errmin);
+ failed = TRUE;
+ }
+ xfree(name);
+ }
+ return !failed;
+}
+
+#endif
+
+/* Pixmap format stuff */
+
+PixmapFormatPtr
+xf86GetPixFormat(ScrnInfoPtr pScrn, int depth)
+{
+ int i;
+ static PixmapFormatRec format; /* XXX not reentrant */
+
+ /*
+ * When the formats[] list initialisation isn't complete, check the
+ * depth 24 pixmap config/cmdline options and screen-specified formats.
+ */
+
+ if (!formatsDone) {
+ if (depth == 24) {
+ Pix24Flags pix24 = Pix24DontCare;
+
+ format.depth = 24;
+ format.scanlinePad = BITMAP_SCANLINE_PAD;
+ if (xf86Info.pixmap24 != Pix24DontCare)
+ pix24 = xf86Info.pixmap24;
+ else if (pScrn->pixmap24 != Pix24DontCare)
+ pix24 = pScrn->pixmap24;
+ if (pix24 == Pix24Use24)
+ format.bitsPerPixel = 24;
+ else
+ format.bitsPerPixel = 32;
+ return &format;
+ }
+ }
+
+ for (i = 0; i < numFormats; i++)
+ if (formats[i].depth == depth)
+ break;
+ if (i != numFormats)
+ return &formats[i];
+ else if (!formatsDone) {
+ /* Check for screen-specified formats */
+ for (i = 0; i < pScrn->numFormats; i++)
+ if (pScrn->formats[i].depth == depth)
+ break;
+ if (i != pScrn->numFormats)
+ return &pScrn->formats[i];
+ }
+ return NULL;
+}
+
+int
+xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth)
+{
+ PixmapFormatPtr format;
+
+
+ format = xf86GetPixFormat(pScrn, depth);
+ if (format)
+ return format->bitsPerPixel;
+ else
+ return 0;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Io.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Io.c
new file mode 100644
index 000000000..ef0fddf99
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Io.c
@@ -0,0 +1,507 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 3.56 2003/11/03 05:11:02 tsi Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*
+ * Copyright (c) 1992-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* $XConsortium: xf86Io.c /main/27 1996/10/19 17:58:55 kaleb $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 1.5 2005/07/03 07:01:24 daniels Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
+#include "xf86_OSlib.h"
+#include "mipointer.h"
+
+#ifdef XINPUT
+#include "xf86Xinput.h"
+#include <X11/extensions/XIproto.h>
+#include "exevents.h"
+#endif
+
+#ifdef XKB
+#include <X11/extensions/XKB.h>
+#include <X11/extensions/XKBstr.h>
+#include <X11/extensions/XKBsrv.h>
+#endif
+
+unsigned int xf86InitialCaps = 0;
+unsigned int xf86InitialNum = 0;
+unsigned int xf86InitialScroll = 0;
+
+#include "atKeynames.h"
+
+/*
+ * xf86KbdBell --
+ * Ring the terminal/keyboard bell for an amount of time proportional to
+ * "loudness".
+ */
+
+void
+xf86KbdBell(percent, pKeyboard, ctrl, unused)
+ int percent; /* Percentage of full volume */
+ DeviceIntPtr pKeyboard; /* Keyboard to ring */
+ pointer ctrl;
+ int unused;
+{
+ xf86SoundKbdBell(percent, xf86Info.bell_pitch, xf86Info.bell_duration);
+}
+
+void
+xf86UpdateKbdLeds()
+{
+ int leds = 0;
+ if (xf86Info.capsLock) leds |= XLED1;
+ if (xf86Info.numLock) leds |= XLED2;
+ if (xf86Info.scrollLock || xf86Info.modeSwitchLock) leds |= XLED3;
+ if (xf86Info.composeLock) leds |= XLED4;
+ xf86Info.leds = (xf86Info.leds & xf86Info.xleds) | (leds & ~xf86Info.xleds);
+ xf86KbdLeds();
+}
+
+void
+xf86KbdLeds ()
+{
+ int leds, real_leds = 0;
+
+#if defined (__sparc__) && defined(__linux__)
+ static int kbdSun = -1;
+ if (kbdSun == -1) {
+ if ((xf86Info.xkbmodel && !strcmp(xf86Info.xkbmodel, "sun")) ||
+ (xf86Info.xkbrules && !strcmp(xf86Info.xkbrules, "sun")))
+ kbdSun = 1;
+ else
+ kbdSun = 0;
+ }
+ if (kbdSun) {
+ if (xf86Info.leds & 0x08) real_leds |= XLED1;
+ if (xf86Info.leds & 0x04) real_leds |= XLED3;
+ if (xf86Info.leds & 0x02) real_leds |= XLED4;
+ if (xf86Info.leds & 0x01) real_leds |= XLED2;
+ leds = real_leds;
+ real_leds = 0;
+ } else {
+ leds = xf86Info.leds;
+ }
+#else
+ leds = xf86Info.leds;
+#endif /* defined (__sparc__) */
+
+#ifdef LED_CAP
+ if (leds & XLED1) real_leds |= LED_CAP;
+ if (leds & XLED2) real_leds |= LED_NUM;
+ if (leds & XLED3) real_leds |= LED_SCR;
+#ifdef LED_COMP
+ if (leds & XLED4) real_leds |= LED_COMP;
+#else
+ if (leds & XLED4) real_leds |= LED_SCR;
+#endif
+#endif
+#ifdef sun
+ /* Pass through any additional LEDs, such as Kana LED on Sun Japanese kbd */
+ real_leds |= (leds & 0xFFFFFFF0);
+#endif
+ xf86SetKbdLeds(real_leds);
+ (void)leds;
+}
+
+/*
+ * xf86KbdCtrl --
+ * Alter some of the keyboard control parameters. All special protocol
+ * values are handled by dix (ProgChangeKeyboardControl)
+ */
+
+void
+xf86KbdCtrl (pKeyboard, ctrl)
+ DevicePtr pKeyboard; /* Keyboard to alter */
+ KeybdCtrl *ctrl;
+{
+ int leds;
+ xf86Info.bell_pitch = ctrl->bell_pitch;
+ xf86Info.bell_duration = ctrl->bell_duration;
+ xf86Info.autoRepeat = ctrl->autoRepeat;
+
+ xf86Info.composeLock = (ctrl->leds & XCOMP) ? TRUE : FALSE;
+
+ leds = (ctrl->leds & ~(XCAPS | XNUM | XSCR));
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ xf86Info.leds = (leds & xf86Info.xleds)|(xf86Info.leds & ~xf86Info.xleds);
+#ifdef XKB
+ } else {
+ xf86Info.leds = leds;
+ }
+#endif
+
+ xf86KbdLeds();
+}
+
+/*
+ * xf86InitKBD --
+ * Reinitialize the keyboard. Only set Lockkeys according to ours leds.
+ * Depress all other keys.
+ */
+
+void
+xf86InitKBD(init)
+Bool init;
+{
+ char leds = 0, rad;
+ unsigned int i;
+ xEvent kevent;
+ DeviceIntPtr pKeyboard = xf86Info.pKeyboard;
+ KeyClassRec *keyc = xf86Info.pKeyboard->key;
+ KeySym *map = keyc->curKeySyms.map;
+
+ kevent.u.keyButtonPointer.time = GetTimeInMillis();
+ kevent.u.keyButtonPointer.rootX = 0;
+ kevent.u.keyButtonPointer.rootY = 0;
+
+ /*
+ * Hmm... here is the biggest hack of every time !
+ * It may be possible that a switch-vt procedure has finished BEFORE
+ * you released all keys neccessary to do this. That peculiar behavior
+ * can fool the X-server pretty much, cause it assumes that some keys
+ * were not released. TWM may stuck alsmost completly....
+ * OK, what we are doing here is after returning from the vt-switch
+ * exeplicitely unrelease all keyboard keys before the input-devices
+ * are reenabled.
+ */
+ for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map;
+ i < keyc->curKeySyms.maxKeyCode;
+ i++, map += keyc->curKeySyms.mapWidth)
+ if (KeyPressed(i))
+ {
+ switch (*map) {
+ /* Don't release the lock keys */
+ case XK_Caps_Lock:
+ case XK_Shift_Lock:
+ case XK_Num_Lock:
+ case XK_Scroll_Lock:
+ case XK_Kana_Lock:
+ break;
+ default:
+ kevent.u.u.detail = i;
+ kevent.u.u.type = KeyRelease;
+ (* pKeyboard->public.processInputProc)(&kevent, pKeyboard, 1);
+ }
+ }
+
+ xf86Info.scanPrefix = 0;
+
+ if (init)
+ {
+ /*
+ * we must deal here with the fact, that on some cases the numlock or
+ * capslock key are enabled BEFORE the server is started up. So look
+ * here at the state on the according LEDS to determine whether a
+ * lock-key is already set.
+ */
+
+ xf86Info.capsLock = FALSE;
+ xf86Info.numLock = FALSE;
+ xf86Info.scrollLock = FALSE;
+ xf86Info.modeSwitchLock = FALSE;
+ xf86Info.composeLock = FALSE;
+
+#ifdef LED_CAP
+#ifdef INHERIT_LOCK_STATE
+ leds = xf86Info.leds;
+
+ for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map;
+ i < keyc->curKeySyms.maxKeyCode;
+ i++, map += keyc->curKeySyms.mapWidth)
+
+ switch(*map) {
+
+ case XK_Caps_Lock:
+ case XK_Shift_Lock:
+ if (leds & LED_CAP)
+ {
+ xf86InitialCaps = i;
+ xf86Info.capsLock = TRUE;
+ }
+ break;
+
+ case XK_Num_Lock:
+ if (leds & LED_NUM)
+ {
+ xf86InitialNum = i;
+ xf86Info.numLock = TRUE;
+ }
+ break;
+
+ case XK_Scroll_Lock:
+ case XK_Kana_Lock:
+ if (leds & LED_SCR)
+ {
+ xf86InitialScroll = i;
+ xf86Info.scrollLock = TRUE;
+ }
+ break;
+ }
+#endif /* INHERIT_LOCK_STATE */
+ xf86SetKbdLeds(leds);
+#endif /* LED_CAP */
+ (void)leds;
+
+ if (xf86Info.kbdDelay <= 375) rad = 0x00;
+ else if (xf86Info.kbdDelay <= 625) rad = 0x20;
+ else if (xf86Info.kbdDelay <= 875) rad = 0x40;
+ else rad = 0x60;
+
+ if (xf86Info.kbdRate <= 2) rad |= 0x1F;
+ else if (xf86Info.kbdRate >= 30) rad |= 0x00;
+ else rad |= ((58 / xf86Info.kbdRate) - 2);
+
+ xf86SetKbdRepeat(rad);
+ }
+}
+
+/*
+ * xf86KbdProc --
+ * Handle the initialization, etc. of a keyboard.
+ */
+
+int
+xf86KbdProc (pKeyboard, what)
+ DeviceIntPtr pKeyboard; /* Keyboard to manipulate */
+ int what; /* What to do to it */
+{
+ KeySymsRec keySyms;
+ CARD8 modMap[MAP_LENGTH];
+ int kbdFd;
+
+ switch (what) {
+
+ case DEVICE_INIT:
+ /*
+ * First open and find the current state of the keyboard.
+ */
+
+ xf86KbdInit();
+
+ xf86KbdGetMapping(&keySyms, modMap);
+
+
+#ifndef XKB
+ defaultKeyboardControl.leds = xf86GetKbdLeds();
+#else
+ defaultKeyboardControl.leds = 0;
+#endif
+
+ /*
+ * Perform final initialization of the system private keyboard
+ * structure and fill in various slots in the device record
+ * itself which couldn't be filled in before.
+ */
+
+ pKeyboard->public.on = FALSE;
+
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ InitKeyboardDeviceStruct((DevicePtr)xf86Info.pKeyboard,
+ &keySyms,
+ modMap,
+ xf86KbdBell,
+ (KbdCtrlProcPtr)xf86KbdCtrl);
+#ifdef XKB
+ } else {
+ XkbComponentNamesRec names;
+ XkbDescPtr desc;
+ Bool foundTerminate = FALSE;
+ int keyc;
+ if (XkbInitialMap) {
+ if ((xf86Info.xkbkeymap = strchr(XkbInitialMap, '/')) != NULL)
+ xf86Info.xkbkeymap++;
+ else
+ xf86Info.xkbkeymap = XkbInitialMap;
+ }
+ if (xf86Info.xkbkeymap) {
+ names.keymap = xf86Info.xkbkeymap;
+ names.keycodes = NULL;
+ names.types = NULL;
+ names.compat = NULL;
+ names.symbols = NULL;
+ names.geometry = NULL;
+ } else {
+ names.keymap = NULL;
+ names.keycodes = xf86Info.xkbkeycodes;
+ names.types = xf86Info.xkbtypes;
+ names.compat = xf86Info.xkbcompat;
+ names.symbols = xf86Info.xkbsymbols;
+ names.geometry = xf86Info.xkbgeometry;
+ }
+ if ((xf86Info.xkbkeymap || xf86Info.xkbcomponents_specified)
+ && (xf86Info.xkbmodel == NULL || xf86Info.xkblayout == NULL)) {
+ xf86Info.xkbrules = NULL;
+ }
+ XkbSetRulesDflts(xf86Info.xkbrules, xf86Info.xkbmodel,
+ xf86Info.xkblayout, xf86Info.xkbvariant,
+ xf86Info.xkboptions);
+
+ XkbInitKeyboardDeviceStruct(pKeyboard,
+ &names,
+ &keySyms,
+ modMap,
+ xf86KbdBell,
+ (KbdCtrlProcPtr)xf86KbdCtrl);
+
+ /* Search keymap for Terminate action */
+ desc = pKeyboard->key->xkbInfo->desc;
+ for (keyc = desc->min_key_code; keyc <= desc->max_key_code; keyc++) {
+ int i;
+ for (i = 1; i <= XkbKeyNumActions(desc, keyc); i++) {
+ if (XkbKeyAction(desc, keyc, i)
+ && XkbKeyAction(desc, keyc, i)->type == XkbSA_Terminate) {
+ foundTerminate = TRUE;
+ goto searchdone;
+ }
+ }
+ }
+searchdone:
+ xf86Info.ActionKeyBindingsSet = foundTerminate;
+ if (!foundTerminate)
+ xf86Msg(X_INFO, "Server_Terminate keybinding not found\n");
+ }
+#endif
+
+ xf86InitKBD(TRUE);
+ break;
+
+ case DEVICE_ON:
+ /*
+ * Set the keyboard into "direct" mode and turn on
+ * event translation.
+ */
+
+ kbdFd = xf86KbdOn();
+ /*
+ * Discard any pending input after a VT switch to prevent the server
+ * passing on parts of the VT switch sequence.
+ */
+ sleep(1);
+#if defined(WSCONS_SUPPORT)
+ if (xf86Info.consType != WSCONS) {
+#endif
+ if (kbdFd != -1) {
+ char buf[16];
+ read(kbdFd, buf, 16);
+ }
+#if defined(WSCONS_SUPPORT)
+ }
+#endif
+
+#if !defined(__UNIXOS2__) /* Under EMX, keyboard cannot be select()'ed */
+ if (kbdFd != -1)
+ AddEnabledDevice(kbdFd);
+#endif /* __UNIXOS2__ */
+
+ pKeyboard->public.on = TRUE;
+ xf86InitKBD(FALSE);
+ break;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ /*
+ * Restore original keyboard directness and translation.
+ */
+
+ kbdFd = xf86KbdOff();
+
+ if (kbdFd != -1)
+ RemoveEnabledDevice(kbdFd);
+
+ pKeyboard->public.on = FALSE;
+ break;
+
+ }
+ return (Success);
+}
+
+#if defined(DDXTIME) && !defined(QNX4)
+/*
+ * These are getting tossed in here until I can think of where
+ * they really belong
+ */
+#define HALFMONTH ((unsigned long) 1<<31)
+CARD32
+GetTimeInMillis()
+{
+ struct timeval tp;
+ register CARD32 val;
+ register INT32 diff;
+ static CARD32 oldval = 0;
+ static CARD32 time = 0;
+
+ gettimeofday(&tp, 0);
+ val = (tp.tv_sec * 1000) + (tp.tv_usec / 1000);
+ if (oldval) {
+ diff = val - oldval;
+ if (diff > 0)
+ time += diff;
+ }
+ oldval = val;
+
+ return time;
+}
+#endif /* DDXTIME && !QNX4 */
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Kbd.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Kbd.c
new file mode 100644
index 000000000..85f9e3406
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Kbd.c
@@ -0,0 +1,395 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Kbd.c,v 3.26 2003/08/24 17:36:53 dawes Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*
+ * Copyright (c) 1992-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* $XConsortium: xf86Kbd.c /main/10 1996/02/21 17:38:32 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define I_NEED_OS2_H
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "atKeynames.h"
+#include "xf86Config.h"
+
+#include "xf86Keymap.h"
+
+#if defined(KDGKBTYPE) && \
+ !defined(Lynx) && \
+ !defined(__UNIXOS2__) && !defined(__mips__) && \
+ !defined(__arm32__) && !defined(__GNU__) && !defined(__QNX__)
+#define HAS_GETKBTYPE
+#endif
+#if defined(GIO_KEYMAP) && \
+ !defined(Lynx) && \
+ !defined(__UNIXOS2__) && !defined(__mips__) && \
+ !defined(__arm32__) && !defined(__GNU__) && !defined(DGUX) && \
+ !defined(__QNX__)
+#define HAS_GETKEYMAP
+
+#define KD_GET_ENTRY(i,n) \
+ eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]]
+
+/*
+ * NOTE: Not all possible remappable symbols are remapped. There are two main
+ * reasons:
+ * a) The mapping between scancode and SYSV/386 - symboltable
+ * is inconsistent between different versions and has some
+ * BIG mistakes.
+ * b) In X-Windows there is a difference between numpad-keys
+ * and normal keys. SYSV/386 uses for both kinds of keys
+ * the same symbol.
+ *
+ * Thus only the alpha keypad and the function keys are translated.
+ * Also CapsLock, NumLock, ScrollLock, Shift, Control & Alt.
+ */
+
+static unsigned char remap[128] = {
+ 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0, /* 0x30 - 0x37 */
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38 - 0x3f */
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0, /* 0x40 - 0x47 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */
+ 0, 0, 0, 0, 0, 0, 0x56, 0x57, /* 0x50 - 0x57 */
+ 0x58, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x67 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68 - 0x6f */
+ 0, 0, 0x69, 0x65, 0, 0, 0, 0, /* 0x70 - 0x77 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */
+};
+
+static KeySym eascii_to_x[512] = {
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, XK_Return, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Escape,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
+ XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
+ XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
+ XK_comma, XK_minus, XK_period, XK_slash,
+ XK_0, XK_1, XK_2, XK_3,
+ XK_4, XK_5, XK_6, XK_7,
+ XK_8, XK_9, XK_colon, XK_semicolon,
+ XK_less, XK_equal, XK_greater, XK_question,
+ XK_at, XK_A, XK_B, XK_C,
+ XK_D, XK_E, XK_F, XK_G,
+ XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O,
+ XK_P, XK_Q, XK_R, XK_S,
+ XK_T, XK_U, XK_V, XK_W,
+ XK_X, XK_Y, XK_Z, XK_bracketleft,
+ XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
+ XK_grave, XK_a, XK_b, XK_c,
+ XK_d, XK_e, XK_f, XK_g,
+ XK_h, XK_i, XK_j, XK_k,
+ XK_l, XK_m, XK_n, XK_o,
+ XK_p, XK_q, XK_r, XK_s,
+ XK_t, XK_u, XK_v, XK_w,
+ XK_x, XK_y, XK_z, XK_braceleft,
+ XK_bar, XK_braceright, XK_asciitilde, XK_Delete,
+ XK_Ccedilla, XK_udiaeresis, XK_eacute, XK_acircumflex,
+ XK_adiaeresis, XK_agrave, XK_aring, XK_ccedilla,
+ XK_ecircumflex, XK_ediaeresis, XK_egrave, XK_idiaeresis,
+ XK_icircumflex, XK_igrave, XK_Adiaeresis, XK_Aring,
+ XK_Eacute, XK_ae, XK_AE, XK_ocircumflex,
+ XK_odiaeresis, XK_ograve, XK_ucircumflex, XK_ugrave,
+ XK_ydiaeresis, XK_Odiaeresis, XK_Udiaeresis, XK_cent,
+ XK_sterling, XK_yen, XK_paragraph, XK_section,
+ XK_aacute, XK_iacute, XK_oacute, XK_uacute,
+ XK_ntilde, XK_Ntilde, XK_ordfeminine, XK_masculine,
+ XK_questiondown,XK_hyphen, XK_notsign, XK_onehalf,
+ XK_onequarter, XK_exclamdown, XK_guillemotleft,XK_guillemotright,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_Greek_alpha, XK_ssharp, XK_Greek_GAMMA, XK_Greek_pi,
+ XK_Greek_SIGMA, XK_Greek_sigma, XK_mu, XK_Greek_tau,
+ XK_Greek_PHI, XK_Greek_THETA, XK_Greek_OMEGA, XK_Greek_delta,
+ XK_infinity, XK_Ooblique, XK_Greek_epsilon, XK_intersection,
+ XK_identical, XK_plusminus, XK_greaterthanequal, XK_lessthanequal,
+ XK_topintegral, XK_botintegral, XK_division, XK_similarequal,
+ XK_degree, NoSymbol, NoSymbol, XK_radical,
+ XK_Greek_eta, XK_twosuperior, XK_periodcentered, NoSymbol,
+
+ /*
+ * special marked entries (256 + x)
+ */
+
+ NoSymbol, NoSymbol, XK_Shift_L, XK_Shift_R,
+ XK_Caps_Lock, XK_Num_Lock, XK_Scroll_Lock, XK_Alt_L,
+ NoSymbol, XK_Control_L, XK_Alt_L, XK_Alt_R,
+ XK_Control_L, XK_Control_R, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_F1,
+ XK_F2, XK_F3, XK_F4, XK_F5,
+ XK_F6, XK_F7, XK_F8, XK_F9,
+ XK_F10, XK_F11, XK_F12, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ };
+
+#endif /* HAS_GETKEYMAP */
+
+/*
+ * LegalModifier --
+ * determine whether a key is a legal modifier key, i.e send a
+ * press/release sequence.
+ */
+
+/*ARGSUSED*/
+Bool
+LegalModifier(key, pDev)
+ unsigned int key;
+ DevicePtr pDev;
+{
+ return (TRUE);
+}
+
+
+
+/*
+ * xf86KbdGetMapping --
+ * Get the national keyboard mapping. The keyboard type is set, a new map
+ * and the modifiermap is computed.
+ */
+
+void
+xf86KbdGetMapping (pKeySyms, pModMap)
+ KeySymsPtr pKeySyms;
+ CARD8 *pModMap;
+{
+ KeySym *k;
+#ifdef HAS_GETKEYMAP
+ keymap_t keymap;
+#endif
+ int i;
+ KeySym *pMap;
+
+#ifdef HAS_GETKBTYPE
+ char type;
+
+ xf86Info.kbdType =
+ ioctl(xf86Info.consoleFd, KDGKBTYPE, &type) != -1 ? type : KB_101;
+ if (xf86Info.kbdType == KB_84)
+ pMap = map84;
+ else
+ pMap = map;
+#else
+/* OS/2 sets the keyboard type during xf86OpenKbd */
+#ifndef __UNIXOS2__
+ xf86Info.kbdType = 0;
+#endif
+ pMap = map;
+#endif
+
+#ifdef HAS_GETKEYMAP
+ /*
+ * use the keymap, which can be gotten from our oringinal vt??.
+ * ( ttymap(1) !!!! )
+ */
+ if (ioctl(xf86Info.consoleFd, GIO_KEYMAP, &keymap) != -1) {
+ for (i = 0; i < keymap.n_keys && i < NUM_KEYCODES; i++)
+
+ if (remap[i]) {
+
+ k = pMap + (remap[i] << 2);
+
+ k[0] = KD_GET_ENTRY(i,0); /* non-shifed */
+ k[1] = KD_GET_ENTRY(i,1); /* shifted */
+ k[2] = KD_GET_ENTRY(i,4); /* alt */
+ k[3] = KD_GET_ENTRY(i,5); /* alt - shifted */
+
+ if (k[3] == k[2]) k[3] = NoSymbol;
+ if (k[2] == k[1]) k[2] = NoSymbol;
+ if (k[1] == k[0]) k[1] = NoSymbol;
+ if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
+ }
+ }
+#endif
+
+ /*
+ * compute the modifier map
+ */
+ for (i = 0; i < MAP_LENGTH; i++)
+ pModMap[i] = NoSymbol; /* make sure it is restored */
+
+ for (k = pMap, i = MIN_KEYCODE;
+ i < (NUM_KEYCODES + MIN_KEYCODE);
+ i++, k += 4)
+
+ switch(*k) {
+
+ case XK_Shift_L:
+ case XK_Shift_R:
+ pModMap[i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ case XK_Control_R:
+ pModMap[i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ pModMap[i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ case XK_Alt_R:
+ pModMap[i] = AltMask;
+ break;
+
+ case XK_Num_Lock:
+ pModMap[i] = NumLockMask;
+ break;
+
+ case XK_Scroll_Lock:
+ pModMap[i] = ScrollLockMask;
+ break;
+
+ /* kana support */
+ case XK_Kana_Lock:
+ case XK_Kana_Shift:
+ pModMap[i] = KanaMask;
+ break;
+
+ /* alternate toggle for multinational support */
+ case XK_Mode_switch:
+ pModMap[i] = AltLangMask;
+ break;
+
+ }
+
+ pKeySyms->map = pMap;
+ pKeySyms->mapWidth = GLYPHS_PER_KEY;
+ pKeySyms->minKeyCode = MIN_KEYCODE;
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c
new file mode 100644
index 000000000..c1f6156e3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c
@@ -0,0 +1,1266 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c,v 3.22 2003/10/07 22:00:52 herrb Exp $ */
+/*
+ * Derived from xf86Kbd.c by S_ren Schmidt (sos@login.dkuug.dk)
+ * which is Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ * and from xf86KbdCODrv.c by Holger Veit
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+ * Copyright (c) 1994-2002 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* $XConsortium: xf86KbdBSD.c /main/6 1996/10/23 13:12:27 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "atKeynames.h"
+#include "xf86Keymap.h"
+
+#if (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)) && defined(GIO_KEYMAP)
+#define KD_GET_ENTRY(i,n) \
+ eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]]
+
+static unsigned char remap[NUM_KEYCODES] = {
+ 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0, /* 0x30 - 0x37 */
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38 - 0x3f */
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0, /* 0x40 - 0x47 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */
+ 0, 0, 0, 0, 0, 0, 0x56, 0x57, /* 0x50 - 0x57 */
+ 0x58, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x67 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68 - 0x6f */
+ 0, 0, 0x69, 0x65, 0, 0, 0, 0, /* 0x70 - 0x77 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */
+};
+
+/* This table assumes the ibm code page 437 coding for characters
+ * > 0x80. They are returned in this form by PCVT */
+static KeySym eascii_to_x[512] = {
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, XK_Return, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Escape,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
+ XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
+ XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
+ XK_comma, XK_minus, XK_period, XK_slash,
+ XK_0, XK_1, XK_2, XK_3,
+ XK_4, XK_5, XK_6, XK_7,
+ XK_8, XK_9, XK_colon, XK_semicolon,
+ XK_less, XK_equal, XK_greater, XK_question,
+ XK_at, XK_A, XK_B, XK_C,
+ XK_D, XK_E, XK_F, XK_G,
+ XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O,
+ XK_P, XK_Q, XK_R, XK_S,
+ XK_T, XK_U, XK_V, XK_W,
+ XK_X, XK_Y, XK_Z, XK_bracketleft,
+ XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
+ XK_grave, XK_a, XK_b, XK_c,
+ XK_d, XK_e, XK_f, XK_g,
+ XK_h, XK_i, XK_j, XK_k,
+ XK_l, XK_m, XK_n, XK_o,
+ XK_p, XK_q, XK_r, XK_s,
+ XK_t, XK_u, XK_v, XK_w,
+ XK_x, XK_y, XK_z, XK_braceleft,
+ XK_bar, XK_braceright, XK_asciitilde, XK_Delete,
+ XK_Ccedilla, XK_udiaeresis, XK_eacute, XK_acircumflex,
+ XK_adiaeresis, XK_agrave, XK_aring, XK_ccedilla,
+ XK_ecircumflex, XK_ediaeresis, XK_egrave, XK_idiaeresis,
+ XK_icircumflex, XK_igrave, XK_Adiaeresis, XK_Aring,
+ XK_Eacute, XK_ae, XK_AE, XK_ocircumflex,
+ XK_odiaeresis, XK_ograve, XK_ucircumflex, XK_ugrave,
+ XK_ydiaeresis, XK_Odiaeresis, XK_Udiaeresis, XK_cent,
+ XK_sterling, XK_yen, XK_paragraph, XK_section,
+ XK_aacute, XK_iacute, XK_oacute, XK_uacute,
+ XK_ntilde, XK_Ntilde, XK_ordfeminine, XK_masculine,
+ XK_questiondown,XK_hyphen, XK_notsign, XK_onehalf,
+ XK_onequarter, XK_exclamdown, XK_guillemotleft,XK_guillemotright,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_Greek_alpha, XK_ssharp, XK_Greek_GAMMA, XK_Greek_pi,
+ XK_Greek_SIGMA, XK_Greek_sigma, XK_mu, XK_Greek_tau,
+ XK_Greek_PHI, XK_Greek_THETA, XK_Greek_OMEGA, XK_Greek_delta,
+ XK_infinity, XK_Ooblique, XK_Greek_epsilon, XK_intersection,
+ XK_identical, XK_plusminus, XK_greaterthanequal, XK_lessthanequal,
+ XK_topintegral, XK_botintegral, XK_division, XK_similarequal,
+ XK_degree, NoSymbol, NoSymbol, XK_radical,
+ XK_Greek_eta, XK_twosuperior, XK_periodcentered, NoSymbol,
+
+ /*
+ * special marked entries (256 + x)
+ */
+
+#if 1
+ /* This has been checked against what syscons actually does */
+ NoSymbol, NoSymbol, XK_Shift_L, XK_Shift_R,
+ XK_Caps_Lock, XK_Num_Lock, XK_Scroll_Lock, XK_Alt_L,
+ XK_ISO_Left_Tab,XK_Control_L, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_F1,
+ XK_F2, XK_F3, XK_F4, XK_F5,
+ XK_F6, XK_F7, XK_F8, XK_F9,
+ XK_F10, XK_F11, XK_F12, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_Control_R, XK_Alt_R, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol
+#else
+ /* The old table, supposedly for pcvt. */
+ NoSymbol, NoSymbol, XK_Shift_L, XK_Shift_R,
+ XK_Caps_Lock, XK_Num_Lock, XK_Scroll_Lock, XK_Alt_L,
+ NoSymbol, XK_Control_L, XK_Alt_L, XK_Alt_R,
+ XK_Control_L, XK_Control_R, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_F1,
+ XK_F2, XK_F3, XK_F4, XK_F5,
+ XK_F6, XK_F7, XK_F8, XK_F9,
+ XK_F10, XK_F11, XK_F12, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol
+#endif
+ };
+
+#ifdef __OpenBSD__
+/* don't mark AltR and CtrlR for remapping, since they
+ * cannot be remapped by pccons */
+static unsigned char pccons_remap[128] = {
+ 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0, /* 0x30 - 0x37 */
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38 - 0x3f */
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0, /* 0x40 - 0x47 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */
+ 0, 0, 0, 0, 0, 0, 0x56, 0x57, /* 0x50 - 0x57 */
+ 0x58, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x67 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68 - 0x6f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 - 0x77 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */
+};
+
+/* This table assumes an iso8859_1 encoding for the characters
+ * > 80, as returned by pccons */
+static KeySym latin1_to_x[256] = {
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, XK_Return, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Escape,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
+ XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
+ XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
+ XK_comma, XK_minus, XK_period, XK_slash,
+ XK_0, XK_1, XK_2, XK_3,
+ XK_4, XK_5, XK_6, XK_7,
+ XK_8, XK_9, XK_colon, XK_semicolon,
+ XK_less, XK_equal, XK_greater, XK_question,
+ XK_at, XK_A, XK_B, XK_C,
+ XK_D, XK_E, XK_F, XK_G,
+ XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O,
+ XK_P, XK_Q, XK_R, XK_S,
+ XK_T, XK_U, XK_V, XK_W,
+ XK_X, XK_Y, XK_Z, XK_bracketleft,
+ XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
+ XK_grave, XK_a, XK_b, XK_c,
+ XK_d, XK_e, XK_f, XK_g,
+ XK_h, XK_i, XK_j, XK_k,
+ XK_l, XK_m, XK_n, XK_o,
+ XK_p, XK_q, XK_r, XK_s,
+ XK_t, XK_u, XK_v, XK_w,
+ XK_x, XK_y, XK_z, XK_braceleft,
+ XK_bar, XK_braceright, XK_asciitilde, XK_Delete,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_nobreakspace,XK_exclamdown, XK_cent, XK_sterling,
+ XK_currency, XK_yen, XK_brokenbar, XK_section,
+ XK_diaeresis, XK_copyright, XK_ordfeminine, XK_guillemotleft,
+ XK_notsign, XK_hyphen, XK_registered, XK_macron,
+ XK_degree, XK_plusminus, XK_twosuperior, XK_threesuperior,
+ XK_acute, XK_mu, XK_paragraph, XK_periodcentered,
+ XK_cedilla, XK_onesuperior, XK_masculine, XK_guillemotright,
+ XK_onequarter, XK_onehalf, XK_threequarters,XK_questiondown,
+ XK_Agrave, XK_Aacute, XK_Acircumflex, XK_Atilde,
+ XK_Adiaeresis, XK_Aring, XK_AE, XK_Ccedilla,
+ XK_Egrave, XK_Eacute, XK_Ecircumflex, XK_Ediaeresis,
+ XK_Igrave, XK_Iacute, XK_Icircumflex, XK_Idiaeresis,
+ XK_ETH, XK_Ntilde, XK_Ograve, XK_Oacute,
+ XK_Ocircumflex, XK_Otilde, XK_Odiaeresis, XK_multiply,
+ XK_Ooblique, XK_Ugrave, XK_Uacute, XK_Ucircumflex,
+ XK_Udiaeresis, XK_Yacute, XK_THORN, XK_ssharp,
+ XK_agrave, XK_aacute, XK_acircumflex, XK_atilde,
+ XK_adiaeresis, XK_aring, XK_ae, XK_ccedilla,
+ XK_egrave, XK_eacute, XK_ecircumflex, XK_ediaeresis,
+ XK_igrave, XK_iacute, XK_icircumflex, XK_idiaeresis,
+ XK_eth, XK_ntilde, XK_ograve, XK_oacute,
+ XK_ocircumflex, XK_otilde, XK_odiaeresis, XK_division,
+ XK_oslash, XK_ugrave, XK_uacute, XK_ucircumflex,
+ XK_udiaeresis, XK_yacute, XK_thorn, XK_ydiaeresis
+ };
+#endif
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+/*
+ * LegalModifier --
+ * determine whether a key is a legal modifier key, i.e send a
+ * press/release sequence.
+ */
+
+/*ARGSUSED*/
+Bool
+LegalModifier(key, pDev)
+ unsigned int key;
+ DevicePtr pDev;
+{
+ return (TRUE);
+}
+
+/*
+ * xf86KbdGetMapping --
+ * Get the national keyboard mapping. The keyboard type is set, a new map
+ * and the modifiermap is computed.
+ */
+
+void
+xf86KbdGetMapping (pKeySyms, pModMap)
+ KeySymsPtr pKeySyms;
+ CARD8 *pModMap;
+{
+ KeySym *k;
+ int i;
+
+#ifndef __bsdi__
+ switch (xf86Info.consType) {
+
+#ifdef PCCONS_SUPPORT
+ case PCCONS:
+#if defined(__OpenBSD__)
+ /*
+ * on OpenBSD, the pccons keymap is programmable, too
+ */
+ {
+ pccons_keymap_t keymap[KB_NUM_KEYS];
+ if (ioctl(xf86Info.consoleFd, CONSOLE_GET_KEYMAP, &keymap) != -1) {
+ for (i = 0; i < KB_NUM_KEYS; i++)
+ if (pccons_remap[i]) {
+ k = map + (pccons_remap[i] << 2);
+ switch (keymap[i].type) {
+ case KB_ASCII:
+ /* For ASCII keys, there is only one char in the keymap */
+ k[0] = latin1_to_x[(unsigned char)keymap[i].unshift[0]];
+ k[1] = latin1_to_x[(unsigned char)keymap[i].shift[0]];
+ k[2] = latin1_to_x[(unsigned char)keymap[i].altgr[0]];
+ k[3] = latin1_to_x[(unsigned char)keymap[i].shift_altgr[0]];
+ break;
+ case KB_SCROLL:
+ k[0] = XK_Scroll_Lock;
+ goto special;
+ case KB_NUM:
+ k[0] = XK_Num_Lock;
+ goto special;
+ case KB_CAPS:
+ k[0] = XK_Caps_Lock;
+ goto special;
+ case KB_SHIFT:
+ switch (keymap[i].unshift[0]) {
+ case 1:
+ /* left shift */
+ k[0] = XK_Shift_L;
+ break;
+ case 2:
+ /* right shift */
+ k[0] = XK_Shift_R;
+ break;
+ default:
+ k[0] = NoSymbol;
+ }
+ goto special;
+ case KB_CTL:
+ k[0] = XK_Control_L;
+ goto special;
+ case KB_ALT:
+ k[0] = XK_Alt_L;
+ goto special;
+ case KB_FUNC:
+ switch (keymap[i].unshift[2]) {
+ case 'M':
+ k[0] = XK_F1;
+ break;
+ case 'N':
+ k[0] = XK_F2;
+ break;
+ case 'O':
+ k[0] = XK_F3;
+ break;
+ case 'P':
+ k[0] = XK_F4;
+ break;
+ case 'Q':
+ k[0] = XK_F5;
+ break;
+ case 'R':
+ k[0] = XK_F6;
+ break;
+ case 'S':
+ k[0] = XK_F7;
+ break;
+ case 'T':
+ k[0] = XK_F8;
+ break;
+ case 'U':
+ k[0] = XK_F9;
+ break;
+ case 'V':
+ k[0] = XK_F10;
+ break;
+ case 'W':
+ k[0] = XK_F11;
+ break;
+ case 'X':
+ k[0] = XK_F12;
+ break;
+ default:
+ k[0] = NoSymbol;
+ break;
+ }
+ goto special;
+ default:
+ k[0] = NoSymbol;
+ special:
+ k[1] = k[2] = k[3] = NoSymbol;
+ }
+ }
+ } else {
+ ErrorF("Can't read pccons keymap\n");
+ }
+ }
+#endif /* __OpenBSD__ */
+ break;
+#endif
+
+/*
+ * XXX wscons has no GIO_KEYMAP
+ */
+#if (defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)) && defined(GIO_KEYMAP)
+ case SYSCONS:
+ case PCVT:
+ {
+ keymap_t keymap;
+
+ if (ioctl(xf86Info.consoleFd, GIO_KEYMAP, &keymap) != -1) {
+ for (i = 0; i < keymap.n_keys && i < NUM_KEYCODES; i++)
+ if (remap[i]) {
+ k = map + (remap[i] << 2);
+ k[0] = KD_GET_ENTRY(i,0); /* non-shifed */
+ k[1] = KD_GET_ENTRY(i,1); /* shifted */
+ k[2] = KD_GET_ENTRY(i,4); /* alt */
+ k[3] = KD_GET_ENTRY(i,5); /* alt - shifted */
+ if (k[3] == k[2]) k[3] = NoSymbol;
+ if (k[2] == k[1]) k[2] = NoSymbol;
+ if (k[1] == k[0]) k[1] = NoSymbol;
+ if (k[0] == k[2] && k[1] == k[3])
+ k[2] = k[3] = NoSymbol;
+ }
+ }
+ }
+ break;
+#endif /* SYSCONS || PCVT */
+
+ }
+#endif /* !bsdi */
+
+ /*
+ * compute the modifier map
+ */
+ for (i = 0; i < MAP_LENGTH; i++)
+ pModMap[i] = NoSymbol; /* make sure it is restored */
+
+ for (k = map, i = MIN_KEYCODE;
+ i < (NUM_KEYCODES + MIN_KEYCODE);
+ i++, k += 4)
+
+ switch(*k) {
+
+ case XK_Shift_L:
+ case XK_Shift_R:
+ pModMap[i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ case XK_Control_R:
+ pModMap[i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ pModMap[i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ case XK_Alt_R:
+ pModMap[i] = AltMask;
+ break;
+
+ case XK_Num_Lock:
+ pModMap[i] = NumLockMask;
+ break;
+
+ case XK_Scroll_Lock:
+ pModMap[i] = ScrollLockMask;
+ break;
+
+ /* kana support */
+ case XK_Kana_Lock:
+ case XK_Kana_Shift:
+ pModMap[i] = KanaMask;
+ break;
+
+ /* alternate toggle for multinational support */
+ case XK_Mode_switch:
+ pModMap[i] = AltLangMask;
+ break;
+
+ }
+
+ xf86Info.kbdType = 0;
+
+ pKeySyms->map = map;
+ pKeySyms->mapWidth = GLYPHS_PER_KEY;
+ pKeySyms->minKeyCode = MIN_KEYCODE;
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
+
+}
+
+#ifdef WSCONS_SUPPORT
+#include "atKeynames.h"
+
+static CARD8 wsUsbMap[] = {
+ /* 0 */ KEY_NOTUSED,
+ /* 1 */ KEY_NOTUSED,
+ /* 2 */ KEY_NOTUSED,
+ /* 3 */ KEY_NOTUSED,
+ /* 4 */ KEY_A,
+ /* 5 */ KEY_B,
+ /* 6 */ KEY_C,
+ /* 7 */ KEY_D,
+ /* 8 */ KEY_E,
+ /* 9 */ KEY_F,
+ /* 10 */ KEY_G,
+ /* 11 */ KEY_H,
+ /* 12 */ KEY_I,
+ /* 13 */ KEY_J,
+ /* 14 */ KEY_K,
+ /* 15 */ KEY_L,
+ /* 16 */ KEY_M,
+ /* 17 */ KEY_N,
+ /* 18 */ KEY_O,
+ /* 19 */ KEY_P,
+ /* 20 */ KEY_Q,
+ /* 21 */ KEY_R,
+ /* 22 */ KEY_S,
+ /* 23 */ KEY_T,
+ /* 24 */ KEY_U,
+ /* 25 */ KEY_V,
+ /* 26 */ KEY_W,
+ /* 27 */ KEY_X,
+ /* 28 */ KEY_Y,
+ /* 29 */ KEY_Z,
+ /* 30 */ KEY_1, /* 1 !*/
+ /* 31 */ KEY_2, /* 2 @ */
+ /* 32 */ KEY_3, /* 3 # */
+ /* 33 */ KEY_4, /* 4 $ */
+ /* 34 */ KEY_5, /* 5 % */
+ /* 35 */ KEY_6, /* 6 ^ */
+ /* 36 */ KEY_7, /* 7 & */
+ /* 37 */ KEY_8, /* 8 * */
+ /* 38 */ KEY_9, /* 9 ( */
+ /* 39 */ KEY_0, /* 0 ) */
+ /* 40 */ KEY_Enter, /* Return */
+ /* 41 */ KEY_Escape, /* Escape */
+ /* 42 */ KEY_BackSpace, /* Backspace Delete */
+ /* 43 */ KEY_Tab, /* Tab */
+ /* 44 */ KEY_Space, /* Space */
+ /* 45 */ KEY_Minus, /* - _ */
+ /* 46 */ KEY_Equal, /* = + */
+ /* 47 */ KEY_LBrace, /* [ { */
+ /* 48 */ KEY_RBrace, /* ] } */
+ /* 49 */ KEY_BSlash, /* \ | */
+ /* 50 */ KEY_BSlash2, /* \ _ # ~ on some keyboards */
+ /* 51 */ KEY_SemiColon, /* ; : */
+ /* 52 */ KEY_Quote, /* ' " */
+ /* 53 */ KEY_Tilde, /* ` ~ */
+ /* 54 */ KEY_Comma, /* , < */
+ /* 55 */ KEY_Period, /* . > */
+ /* 56 */ KEY_Slash, /* / ? */
+ /* 57 */ KEY_CapsLock, /* Caps Lock */
+ /* 58 */ KEY_F1, /* F1 */
+ /* 59 */ KEY_F2, /* F2 */
+ /* 60 */ KEY_F3, /* F3 */
+ /* 61 */ KEY_F4, /* F4 */
+ /* 62 */ KEY_F5, /* F5 */
+ /* 63 */ KEY_F6, /* F6 */
+ /* 64 */ KEY_F7, /* F7 */
+ /* 65 */ KEY_F8, /* F8 */
+ /* 66 */ KEY_F9, /* F9 */
+ /* 67 */ KEY_F10, /* F10 */
+ /* 68 */ KEY_F11, /* F11 */
+ /* 69 */ KEY_F12, /* F12 */
+ /* 70 */ KEY_Print, /* PrintScrn SysReq */
+ /* 71 */ KEY_ScrollLock, /* Scroll Lock */
+ /* 72 */ KEY_Pause, /* Pause Break */
+ /* 73 */ KEY_Insert, /* Insert XXX Help on some Mac Keyboards */
+ /* 74 */ KEY_Home, /* Home */
+ /* 75 */ KEY_PgUp, /* Page Up */
+ /* 76 */ KEY_Delete, /* Delete */
+ /* 77 */ KEY_End, /* End */
+ /* 78 */ KEY_PgDown, /* Page Down */
+ /* 79 */ KEY_Right, /* Right Arrow */
+ /* 80 */ KEY_Left, /* Left Arrow */
+ /* 81 */ KEY_Down, /* Down Arrow */
+ /* 82 */ KEY_Up, /* Up Arrow */
+ /* 83 */ KEY_NumLock, /* Num Lock */
+ /* 84 */ KEY_KP_Divide, /* Keypad / */
+ /* 85 */ KEY_KP_Multiply, /* Keypad * */
+ /* 86 */ KEY_KP_Minus, /* Keypad - */
+ /* 87 */ KEY_KP_Plus, /* Keypad + */
+ /* 88 */ KEY_KP_Enter, /* Keypad Enter */
+ /* 89 */ KEY_KP_1, /* Keypad 1 End */
+ /* 90 */ KEY_KP_2, /* Keypad 2 Down */
+ /* 91 */ KEY_KP_3, /* Keypad 3 Pg Down */
+ /* 92 */ KEY_KP_4, /* Keypad 4 Left */
+ /* 93 */ KEY_KP_5, /* Keypad 5 */
+ /* 94 */ KEY_KP_6, /* Keypad 6 */
+ /* 95 */ KEY_KP_7, /* Keypad 7 Home */
+ /* 96 */ KEY_KP_8, /* Keypad 8 Up */
+ /* 97 */ KEY_KP_9, /* KEypad 9 Pg Up */
+ /* 98 */ KEY_KP_0, /* Keypad 0 Ins */
+ /* 99 */ KEY_KP_Decimal, /* Keypad . Del */
+ /* 100 */ KEY_Less, /* < > on some keyboards */
+ /* 101 */ KEY_Menu, /* Menu */
+ /* 102 */ KEY_NOTUSED,
+ /* 103 */ KEY_KP_Equal, /* Keypad = on Mac keyboards */
+ /* 104 */ KEY_NOTUSED,
+ /* 105 */ KEY_NOTUSED,
+ /* 106 */ KEY_NOTUSED,
+ /* 107 */ KEY_NOTUSED,
+ /* 108 */ KEY_NOTUSED,
+ /* 109 */ KEY_NOTUSED,
+ /* 110 */ KEY_NOTUSED,
+ /* 111 */ KEY_NOTUSED,
+ /* 112 */ KEY_NOTUSED,
+ /* 113 */ KEY_NOTUSED,
+ /* 114 */ KEY_NOTUSED,
+ /* 115 */ KEY_NOTUSED,
+ /* 116 */ KEY_NOTUSED,
+ /* 117 */ KEY_NOTUSED,
+ /* 118 */ KEY_NOTUSED,
+ /* 119 */ KEY_NOTUSED,
+ /* 120 */ KEY_NOTUSED,
+ /* 121 */ KEY_NOTUSED,
+ /* 122 */ KEY_NOTUSED,
+ /* 123 */ KEY_NOTUSED,
+ /* 124 */ KEY_NOTUSED,
+ /* 125 */ KEY_NOTUSED,
+ /* 126 */ KEY_NOTUSED,
+ /* 127 */ KEY_NOTUSED,
+ /* 128 */ KEY_NOTUSED,
+ /* 129 */ KEY_NOTUSED,
+ /* 130 */ KEY_NOTUSED,
+ /* 131 */ KEY_NOTUSED,
+ /* 132 */ KEY_NOTUSED,
+ /* 133 */ KEY_NOTUSED,
+ /* 134 */ KEY_NOTUSED,
+ /* 135 */ KEY_NOTUSED,
+ /* 136 */ KEY_NOTUSED,
+ /* 137 */ KEY_NOTUSED,
+ /* 138 */ KEY_NOTUSED,
+ /* 139 */ KEY_NOTUSED,
+ /* 140 */ KEY_NOTUSED,
+ /* 141 */ KEY_NOTUSED,
+ /* 142 */ KEY_NOTUSED,
+ /* 143 */ KEY_NOTUSED,
+ /* 144 */ KEY_NOTUSED,
+ /* 145 */ KEY_NOTUSED,
+ /* 146 */ KEY_NOTUSED,
+ /* 147 */ KEY_NOTUSED,
+ /* 148 */ KEY_NOTUSED,
+ /* 149 */ KEY_NOTUSED,
+ /* 150 */ KEY_NOTUSED,
+ /* 151 */ KEY_NOTUSED,
+ /* 152 */ KEY_NOTUSED,
+ /* 153 */ KEY_NOTUSED,
+ /* 154 */ KEY_NOTUSED,
+ /* 155 */ KEY_NOTUSED,
+ /* 156 */ KEY_NOTUSED,
+ /* 157 */ KEY_NOTUSED,
+ /* 158 */ KEY_NOTUSED,
+ /* 159 */ KEY_NOTUSED,
+ /* 160 */ KEY_NOTUSED,
+ /* 161 */ KEY_NOTUSED,
+ /* 162 */ KEY_NOTUSED,
+ /* 163 */ KEY_NOTUSED,
+ /* 164 */ KEY_NOTUSED,
+ /* 165 */ KEY_NOTUSED,
+ /* 166 */ KEY_NOTUSED,
+ /* 167 */ KEY_NOTUSED,
+ /* 168 */ KEY_NOTUSED,
+ /* 169 */ KEY_NOTUSED,
+ /* 170 */ KEY_NOTUSED,
+ /* 171 */ KEY_NOTUSED,
+ /* 172 */ KEY_NOTUSED,
+ /* 173 */ KEY_NOTUSED,
+ /* 174 */ KEY_NOTUSED,
+ /* 175 */ KEY_NOTUSED,
+ /* 176 */ KEY_NOTUSED,
+ /* 177 */ KEY_NOTUSED,
+ /* 178 */ KEY_NOTUSED,
+ /* 179 */ KEY_NOTUSED,
+ /* 180 */ KEY_NOTUSED,
+ /* 181 */ KEY_NOTUSED,
+ /* 182 */ KEY_NOTUSED,
+ /* 183 */ KEY_NOTUSED,
+ /* 184 */ KEY_NOTUSED,
+ /* 185 */ KEY_NOTUSED,
+ /* 186 */ KEY_NOTUSED,
+ /* 187 */ KEY_NOTUSED,
+ /* 188 */ KEY_NOTUSED,
+ /* 189 */ KEY_NOTUSED,
+ /* 190 */ KEY_NOTUSED,
+ /* 191 */ KEY_NOTUSED,
+ /* 192 */ KEY_NOTUSED,
+ /* 193 */ KEY_NOTUSED,
+ /* 194 */ KEY_NOTUSED,
+ /* 195 */ KEY_NOTUSED,
+ /* 196 */ KEY_NOTUSED,
+ /* 197 */ KEY_NOTUSED,
+ /* 198 */ KEY_NOTUSED,
+ /* 199 */ KEY_NOTUSED,
+ /* 200 */ KEY_NOTUSED,
+ /* 201 */ KEY_NOTUSED,
+ /* 202 */ KEY_NOTUSED,
+ /* 203 */ KEY_NOTUSED,
+ /* 204 */ KEY_NOTUSED,
+ /* 205 */ KEY_NOTUSED,
+ /* 206 */ KEY_NOTUSED,
+ /* 207 */ KEY_NOTUSED,
+ /* 208 */ KEY_NOTUSED,
+ /* 209 */ KEY_NOTUSED,
+ /* 210 */ KEY_NOTUSED,
+ /* 211 */ KEY_NOTUSED,
+ /* 212 */ KEY_NOTUSED,
+ /* 213 */ KEY_NOTUSED,
+ /* 214 */ KEY_NOTUSED,
+ /* 215 */ KEY_NOTUSED,
+ /* 216 */ KEY_NOTUSED,
+ /* 217 */ KEY_NOTUSED,
+ /* 218 */ KEY_NOTUSED,
+ /* 219 */ KEY_NOTUSED,
+ /* 220 */ KEY_NOTUSED,
+ /* 221 */ KEY_NOTUSED,
+ /* 222 */ KEY_NOTUSED,
+ /* 223 */ KEY_NOTUSED,
+ /* 224 */ KEY_LCtrl, /* Left Control */
+ /* 225 */ KEY_ShiftL, /* Left Shift */
+ /* 226 */ KEY_Alt, /* Left Alt */
+ /* 227 */ KEY_LMeta, /* Left Meta */
+ /* 228 */ KEY_RCtrl, /* Right Control */
+ /* 229 */ KEY_ShiftR, /* Right Shift */
+ /* 230 */ KEY_AltLang, /* Right Alt, AKA AltGr */
+ /* 231 */ KEY_LMeta, /* Right Meta XXX */
+};
+
+#define WS_USB_MAP_SIZE (sizeof(wsUsbMap)/sizeof(unsigned char))
+
+/* Map for adb keyboards */
+static CARD8 wsAdbMap[] = {
+ /* 0 */ KEY_A,
+ /* 1 */ KEY_S,
+ /* 2 */ KEY_D,
+ /* 3 */ KEY_F,
+ /* 4 */ KEY_H,
+ /* 5 */ KEY_G,
+ /* 6 */ KEY_Z,
+ /* 7 */ KEY_X,
+ /* 8 */ KEY_C,
+ /* 9 */ KEY_V,
+ /* 10 */ KEY_UNKNOWN, /* @ # on french keyboards */
+ /* 11 */ KEY_B,
+ /* 12 */ KEY_Q,
+ /* 13 */ KEY_W,
+ /* 14 */ KEY_E,
+ /* 15 */ KEY_R,
+ /* 16 */ KEY_Y,
+ /* 17 */ KEY_T,
+ /* 18 */ KEY_1,
+ /* 19 */ KEY_2,
+ /* 20 */ KEY_3,
+ /* 21 */ KEY_4,
+ /* 22 */ KEY_6,
+ /* 23 */ KEY_5,
+ /* 24 */ KEY_Equal,
+ /* 25 */ KEY_9,
+ /* 26 */ KEY_7,
+ /* 27 */ KEY_Minus,
+ /* 28 */ KEY_8,
+ /* 29 */ KEY_0,
+ /* 30 */ KEY_RBrace,
+ /* 31 */ KEY_O,
+ /* 32 */ KEY_U,
+ /* 33 */ KEY_LBrace,
+ /* 34 */ KEY_I,
+ /* 35 */ KEY_P,
+ /* 36 */ KEY_Enter,
+ /* 37 */ KEY_L,
+ /* 38 */ KEY_J,
+ /* 39 */ KEY_Quote,
+ /* 40 */ KEY_K,
+ /* 41 */ KEY_SemiColon,
+ /* 42 */ KEY_BSlash,
+ /* 43 */ KEY_Comma,
+ /* 44 */ KEY_Slash,
+ /* 45 */ KEY_N,
+ /* 46 */ KEY_M,
+ /* 47 */ KEY_Period,
+ /* 48 */ KEY_Tab,
+ /* 49 */ KEY_Space,
+ /* 50 */ KEY_Tilde,
+ /* 51 */ KEY_Delete,
+ /* 52 */ KEY_AltLang,
+ /* 53 */ KEY_Escape,
+ /* 54 */ KEY_LCtrl,
+ /* 55 */ KEY_Alt,
+ /* 56 */ KEY_ShiftL,
+ /* 57 */ KEY_CapsLock,
+ /* 58 */ KEY_LMeta,
+ /* 59 */ KEY_Left,
+ /* 60 */ KEY_Right,
+ /* 61 */ KEY_Down,
+ /* 62 */ KEY_Up,
+ /* 63 */ KEY_UNKNOWN, /* Fn */
+ /* 64 */ KEY_NOTUSED,
+ /* 65 */ KEY_KP_Decimal,
+ /* 66 */ KEY_NOTUSED,
+ /* 67 */ KEY_KP_Multiply,
+ /* 68 */ KEY_NOTUSED,
+ /* 69 */ KEY_KP_Plus,
+ /* 70 */ KEY_NOTUSED,
+ /* 71 */ KEY_UNKNOWN, /* Clear */
+ /* 72 */ KEY_NOTUSED,
+ /* 73 */ KEY_NOTUSED,
+ /* 74 */ KEY_NOTUSED,
+ /* 75 */ KEY_KP_Divide,
+ /* 76 */ KEY_KP_Enter,
+ /* 77 */ KEY_NOTUSED,
+ /* 78 */ KEY_KP_Minus,
+ /* 79 */ KEY_NOTUSED,
+ /* 80 */ KEY_NOTUSED,
+ /* 81 */ KEY_KP_Equal, /* Keypad = */
+ /* 82 */ KEY_KP_0,
+ /* 83 */ KEY_KP_1,
+ /* 84 */ KEY_KP_2,
+ /* 85 */ KEY_KP_3,
+ /* 86 */ KEY_KP_4,
+ /* 87 */ KEY_KP_5,
+ /* 88 */ KEY_KP_6,
+ /* 89 */ KEY_KP_7,
+ /* 90 */ KEY_NOTUSED,
+ /* 91 */ KEY_KP_8,
+ /* 92 */ KEY_KP_9,
+ /* 93 */ KEY_NOTUSED,
+ /* 94 */ KEY_NOTUSED,
+ /* 95 */ KEY_UNKNOWN, /* Keypad , */
+ /* 96 */ KEY_F5,
+ /* 97 */ KEY_F6,
+ /* 98 */ KEY_F7,
+ /* 99 */ KEY_F3,
+ /* 100 */ KEY_F8,
+ /* 101 */ KEY_F9,
+ /* 102 */ KEY_NOTUSED,
+ /* 103 */ KEY_F11,
+ /* 104 */ KEY_NOTUSED,
+ /* 105 */ KEY_NOTUSED,
+ /* 106 */ KEY_KP_Enter,
+ /* 107 */ KEY_NOTUSED,
+ /* 108 */ KEY_NOTUSED,
+ /* 109 */ KEY_F10,
+ /* 110 */ KEY_NOTUSED,
+ /* 111 */ KEY_F12,
+ /* 112 */ KEY_NOTUSED,
+ /* 113 */ KEY_NOTUSED,
+ /* 114 */ KEY_NOTUSED,
+ /* 115 */ KEY_Home,
+ /* 116 */ KEY_PgUp,
+ /* 117 */ KEY_NOTUSED,
+ /* 118 */ KEY_F4,
+ /* 119 */ KEY_End,
+ /* 120 */ KEY_F2,
+ /* 121 */ KEY_PgDown,
+ /* 122 */ KEY_F1,
+ /* 123 */ KEY_NOTUSED,
+ /* 124 */ KEY_NOTUSED,
+ /* 125 */ KEY_NOTUSED,
+ /* 126 */ KEY_NOTUSED,
+ /* 127 */ KEY_NOTUSED,
+ /* 128 */ KEY_NOTUSED,
+ /* 129 */ KEY_NOTUSED,
+ /* 130 */ KEY_NOTUSED,
+ /* 131 */ KEY_NOTUSED,
+ /* 132 */ KEY_NOTUSED,
+ /* 133 */ KEY_NOTUSED,
+ /* 134 */ KEY_NOTUSED,
+ /* 135 */ KEY_NOTUSED,
+ /* 136 */ KEY_NOTUSED,
+ /* 137 */ KEY_NOTUSED,
+ /* 138 */ KEY_NOTUSED,
+ /* 139 */ KEY_NOTUSED,
+ /* 140 */ KEY_NOTUSED,
+ /* 141 */ KEY_NOTUSED,
+ /* 142 */ KEY_NOTUSED,
+ /* 143 */ KEY_NOTUSED,
+ /* 144 */ KEY_NOTUSED,
+ /* 145 */ KEY_NOTUSED,
+ /* 146 */ KEY_NOTUSED,
+ /* 147 */ KEY_NOTUSED,
+ /* 148 */ KEY_NOTUSED,
+ /* 149 */ KEY_NOTUSED,
+ /* 150 */ KEY_NOTUSED,
+ /* 151 */ KEY_NOTUSED,
+ /* 152 */ KEY_NOTUSED,
+ /* 153 */ KEY_NOTUSED,
+ /* 154 */ KEY_NOTUSED,
+ /* 155 */ KEY_NOTUSED,
+ /* 156 */ KEY_NOTUSED,
+ /* 157 */ KEY_NOTUSED,
+ /* 158 */ KEY_NOTUSED,
+ /* 159 */ KEY_NOTUSED,
+ /* 160 */ KEY_NOTUSED,
+ /* 161 */ KEY_NOTUSED,
+ /* 162 */ KEY_NOTUSED,
+ /* 163 */ KEY_NOTUSED,
+ /* 164 */ KEY_NOTUSED,
+ /* 165 */ KEY_NOTUSED,
+ /* 166 */ KEY_NOTUSED,
+ /* 167 */ KEY_NOTUSED,
+ /* 168 */ KEY_NOTUSED,
+ /* 169 */ KEY_NOTUSED,
+ /* 170 */ KEY_NOTUSED,
+ /* 171 */ KEY_NOTUSED,
+ /* 172 */ KEY_NOTUSED,
+ /* 173 */ KEY_NOTUSED,
+ /* 174 */ KEY_NOTUSED,
+ /* 175 */ KEY_NOTUSED,
+ /* 176 */ KEY_NOTUSED,
+ /* 177 */ KEY_NOTUSED,
+ /* 178 */ KEY_NOTUSED,
+ /* 179 */ KEY_NOTUSED,
+ /* 180 */ KEY_NOTUSED,
+ /* 181 */ KEY_NOTUSED,
+ /* 182 */ KEY_NOTUSED,
+ /* 183 */ KEY_NOTUSED,
+ /* 184 */ KEY_NOTUSED,
+ /* 185 */ KEY_NOTUSED,
+ /* 186 */ KEY_NOTUSED,
+ /* 187 */ KEY_NOTUSED,
+ /* 188 */ KEY_NOTUSED,
+ /* 189 */ KEY_NOTUSED,
+ /* 190 */ KEY_NOTUSED,
+ /* 191 */ KEY_NOTUSED,
+ /* 192 */ KEY_NOTUSED,
+ /* 193 */ KEY_NOTUSED,
+ /* 194 */ KEY_NOTUSED,
+ /* 195 */ KEY_NOTUSED,
+ /* 196 */ KEY_NOTUSED,
+ /* 197 */ KEY_NOTUSED,
+ /* 198 */ KEY_NOTUSED,
+ /* 199 */ KEY_NOTUSED,
+ /* 200 */ KEY_NOTUSED,
+ /* 201 */ KEY_NOTUSED,
+ /* 202 */ KEY_NOTUSED,
+ /* 203 */ KEY_NOTUSED,
+ /* 204 */ KEY_NOTUSED,
+ /* 205 */ KEY_NOTUSED,
+ /* 206 */ KEY_NOTUSED,
+ /* 207 */ KEY_NOTUSED,
+ /* 208 */ KEY_NOTUSED,
+ /* 209 */ KEY_NOTUSED,
+ /* 210 */ KEY_NOTUSED,
+ /* 211 */ KEY_NOTUSED,
+ /* 212 */ KEY_NOTUSED,
+ /* 213 */ KEY_NOTUSED,
+ /* 214 */ KEY_NOTUSED,
+ /* 215 */ KEY_NOTUSED,
+ /* 216 */ KEY_NOTUSED,
+ /* 217 */ KEY_NOTUSED,
+ /* 218 */ KEY_NOTUSED,
+ /* 219 */ KEY_NOTUSED,
+ /* 220 */ KEY_NOTUSED,
+ /* 221 */ KEY_NOTUSED,
+ /* 222 */ KEY_NOTUSED,
+ /* 223 */ KEY_NOTUSED,
+};
+
+#define WS_ADB_MAP_SIZE (sizeof(wsAdbMap)/sizeof(unsigned char))
+
+static CARD8 wsSunMap[] = {
+ /* 0x00 */ KEY_NOTUSED,
+ /* 0x01 */ KEY_NOTUSED, /* stop */
+ /* 0x02 */ KEY_NOTUSED, /* BrightnessDown / S-VolumeDown */
+ /* 0x03 */ KEY_NOTUSED, /* again */
+ /* 0x04 */ KEY_NOTUSED, /* BridgtnessUp / S-VolumeUp */
+ /* 0x05 */ KEY_F1,
+ /* 0x06 */ KEY_F2,
+ /* 0x07 */ KEY_F10,
+ /* 0x08 */ KEY_F3,
+ /* 0x09 */ KEY_F11,
+ /* 0x0a */ KEY_F4,
+ /* 0x0b */ KEY_F12,
+ /* 0x0c */ KEY_F5,
+ /* 0x0d */ KEY_AltLang,
+ /* 0x0e */ KEY_F6,
+ /* 0x0f */ KEY_NOTUSED,
+ /* 0x10 */ KEY_F7,
+ /* 0x11 */ KEY_F8,
+ /* 0x12 */ KEY_F9,
+ /* 0x13 */ KEY_Alt,
+ /* 0x14 */ KEY_Up,
+ /* 0x15 */ KEY_Pause,
+ /* 0x16 */ KEY_Print,
+ /* 0x17 */ KEY_NOTUSED, /* props */
+ /* 0x18 */ KEY_Left,
+ /* 0x19 */ KEY_ScrollLock,
+ /* 0x1a */ KEY_NOTUSED, /* undo */
+ /* 0x1b */ KEY_Down,
+ /* 0x1c */ KEY_Right,
+ /* 0x1d */ KEY_Escape,
+ /* 0x1e */ KEY_1,
+ /* 0x1f */ KEY_2,
+ /* 0x20 */ KEY_3,
+ /* 0x21 */ KEY_4,
+ /* 0x22 */ KEY_5,
+ /* 0x23 */ KEY_6,
+ /* 0x24 */ KEY_7,
+ /* 0x25 */ KEY_8,
+ /* 0x26 */ KEY_9,
+ /* 0x27 */ KEY_0,
+ /* 0x28 */ KEY_Minus,
+ /* 0x29 */ KEY_Equal,
+ /* 0x2a */ KEY_Tilde,
+ /* 0x2b */ KEY_BackSpace,
+ /* 0x2c */ KEY_Insert,
+ /* 0x2d */ KEY_KP_Equal,
+ /* 0x2e */ KEY_KP_Divide,
+ /* 0x2f */ KEY_KP_Multiply,
+ /* 0x30 */ KEY_NOTUSED,
+ /* 0x31 */ KEY_NOTUSED, /* front */
+ /* 0x32 */ KEY_KP_Decimal,
+ /* 0x33 */ KEY_NOTUSED, /* copy */
+ /* 0x34 */ KEY_Home,
+ /* 0x35 */ KEY_Tab,
+ /* 0x36 */ KEY_Q,
+ /* 0x37 */ KEY_W,
+ /* 0x38 */ KEY_E,
+ /* 0x39 */ KEY_R,
+ /* 0x3a */ KEY_T,
+ /* 0x3b */ KEY_Y,
+ /* 0x3c */ KEY_U,
+ /* 0x3d */ KEY_I,
+ /* 0x3e */ KEY_O,
+ /* 0x3f */ KEY_P,
+ /* 0x40 */ KEY_LBrace,
+ /* 0x41 */ KEY_RBrace,
+ /* 0x42 */ KEY_Delete,
+ /* 0x43 */ KEY_NOTUSED, /* compose */
+ /* 0x44 */ KEY_KP_7,
+ /* 0x45 */ KEY_KP_8,
+ /* 0x46 */ KEY_KP_9,
+ /* 0x47 */ KEY_KP_Minus,
+ /* 0x48 */ KEY_NOTUSED, /* open */
+ /* 0x49 */ KEY_NOTUSED, /* paste */
+ /* 0x4a */ KEY_End,
+ /* 0x4b */ KEY_NOTUSED,
+ /* 0x4c */ KEY_LCtrl,
+ /* 0x4d */ KEY_A,
+ /* 0x4e */ KEY_S,
+ /* 0x4f */ KEY_D,
+ /* 0x50 */ KEY_F,
+ /* 0x51 */ KEY_G,
+ /* 0x52 */ KEY_H,
+ /* 0x53 */ KEY_J,
+ /* 0x54 */ KEY_K,
+ /* 0x55 */ KEY_L,
+ /* 0x56 */ KEY_SemiColon,
+ /* 0x57 */ KEY_Quote,
+ /* 0x58 */ KEY_BSlash,
+ /* 0x59 */ KEY_Enter,
+ /* 0x5a */ KEY_KP_Enter,
+ /* 0x5b */ KEY_KP_4,
+ /* 0x5c */ KEY_KP_5,
+ /* 0x5d */ KEY_KP_6,
+ /* 0x5e */ KEY_KP_0,
+ /* 0x5f */ KEY_NOTUSED, /* find */
+ /* 0x60 */ KEY_PgUp,
+ /* 0x61 */ KEY_NOTUSED, /* cut */
+ /* 0x62 */ KEY_NumLock,
+ /* 0x63 */ KEY_ShiftL,
+ /* 0x64 */ KEY_Z,
+ /* 0x65 */ KEY_X,
+ /* 0x66 */ KEY_C,
+ /* 0x67 */ KEY_V,
+ /* 0x68 */ KEY_B,
+ /* 0x69 */ KEY_N,
+ /* 0x6a */ KEY_M,
+ /* 0x6b */ KEY_Comma,
+ /* 0x6c */ KEY_Period,
+ /* 0x6d */ KEY_Slash,
+ /* 0x6e */ KEY_ShiftR,
+ /* 0x6f */ KEY_NOTUSED, /* linefeed */
+ /* 0x70 */ KEY_KP_1,
+ /* 0x71 */ KEY_KP_2,
+ /* 0x72 */ KEY_KP_3,
+ /* 0x73 */ KEY_NOTUSED,
+ /* 0x74 */ KEY_NOTUSED,
+ /* 0x75 */ KEY_NOTUSED,
+ /* 0x76 */ KEY_NOTUSED, /* help */
+ /* 0x77 */ KEY_CapsLock,
+ /* 0x78 */ KEY_LMeta,
+ /* 0x79 */ KEY_Space,
+ /* 0x7a */ KEY_RMeta,
+ /* 0x7b */ KEY_PgDown,
+ /* 0x7c */ KEY_NOTUSED,
+ /* 0x7d */ KEY_KP_Plus,
+ /* 0x7e */ KEY_NOTUSED,
+ /* 0x7f */ KEY_NOTUSED
+};
+
+#define WS_SUN_MAP_SIZE (sizeof(wsSunMap)/sizeof(unsigned char))
+
+/*
+ * Translate raw wskbd keyboard event values to XFree86 standard keycodes
+ * (based on the AT keyboard scan codes using the tables above
+ */
+int
+WSKbdToKeycode(int keycode)
+{
+ switch (xf86Info.wsKbdType) {
+ case WSKBD_TYPE_PC_XT:
+ case WSKBD_TYPE_PC_AT:
+ /* No translation needed */
+ return keycode;
+ case WSKBD_TYPE_USB:
+ if (keycode < 0 || keycode >= WS_USB_MAP_SIZE)
+ return KEY_UNKNOWN;
+ else
+ return wsUsbMap[keycode];
+#ifdef WSKBD_TYPE_ADB
+ case WSKBD_TYPE_ADB:
+ if (keycode < 0 || keycode >= WS_ADB_MAP_SIZE)
+ return KEY_UNKNOWN;
+ else
+ return wsAdbMap[keycode];
+#endif
+#ifdef WSKBD_TYPE_SUN
+ case WSKBD_TYPE_SUN:
+#ifdef WSKBD_TYPE_SUN5
+ case WSKBD_TYPE_SUN5:
+#endif
+ if (keycode < 0 || keycode >= WS_SUN_MAP_SIZE)
+ return KEY_UNKNOWN;
+ else
+ return wsSunMap[keycode];
+#endif
+ default:
+ ErrorF("Unknown wskbd type %d\n", xf86Info.wsKbdType);
+ return KEY_UNKNOWN;
+ }
+}
+
+#endif /* WSCONS_SUPPORT */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86KbdLnx.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86KbdLnx.c
new file mode 100644
index 000000000..c5361f5d9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86KbdLnx.c
@@ -0,0 +1,651 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdLnx.c,v 3.17 2003/08/24 17:36:53 dawes Exp $ */
+/*
+ * Linux version of keymapping setup. The kernel (since 0.99.14) has support
+ * for fully remapping the keyboard, but there are some differences between
+ * the Linux map and the SVR4 map (esp. in the extended keycodes). We also
+ * remove the restriction on what keycodes can be remapped.
+ * Orest Zborowski.
+ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*
+ * Copyright (c) 1994-2001 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* $XConsortium: xf86KbdLnx.c /main/7 1996/10/19 17:59:00 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "atKeynames.h"
+
+#include "xf86Keymap.h"
+
+/*
+ * LegalModifier --
+ * determine whether a key is a legal modifier key, i.e send a
+ * press/release sequence.
+ */
+
+/*ARGSUSED*/
+Bool
+LegalModifier(unsigned int key, DevicePtr pDev)
+{
+ return (TRUE);
+}
+
+/*
+ * xf86KbdGetMapping --
+ * Get the national keyboard mapping. The keyboard type is set, a new map
+ * and the modifiermap is computed.
+ */
+
+static void readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap);
+
+void
+xf86KbdGetMapping (KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ KeySym *k;
+ char type;
+ int i;
+
+ readKernelMapping(pKeySyms, pModMap);
+
+ /*
+ * compute the modifier map
+ */
+ for (i = 0; i < MAP_LENGTH; i++)
+ pModMap[i] = NoSymbol; /* make sure it is restored */
+
+ for (k = map, i = MIN_KEYCODE;
+ i < (NUM_KEYCODES + MIN_KEYCODE);
+ i++, k += 4)
+
+ switch(*k) {
+
+ case XK_Shift_L:
+ case XK_Shift_R:
+ pModMap[i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ case XK_Control_R:
+ pModMap[i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ pModMap[i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ case XK_Alt_R:
+ pModMap[i] = AltMask;
+ break;
+
+ case XK_Num_Lock:
+ pModMap[i] = NumLockMask;
+ break;
+
+ case XK_Scroll_Lock:
+ pModMap[i] = ScrollLockMask;
+ break;
+
+ /* kana support */
+ case XK_Kana_Lock:
+ case XK_Kana_Shift:
+ pModMap[i] = KanaMask;
+ break;
+
+ /* alternate toggle for multinational support */
+ case XK_Mode_switch:
+ pModMap[i] = AltLangMask;
+ break;
+
+ }
+
+ xf86Info.kbdType =
+ ioctl(xf86Info.consoleFd, KDGKBTYPE, &type) != -1 ? type : KB_101;
+
+ pKeySyms->map = map;
+ pKeySyms->mapWidth = GLYPHS_PER_KEY;
+ pKeySyms->minKeyCode = MIN_KEYCODE;
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
+}
+
+#include <linux/keyboard.h>
+
+static KeySym linux_to_x[256] = {
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Escape,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
+ XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
+ XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
+ XK_comma, XK_minus, XK_period, XK_slash,
+ XK_0, XK_1, XK_2, XK_3,
+ XK_4, XK_5, XK_6, XK_7,
+ XK_8, XK_9, XK_colon, XK_semicolon,
+ XK_less, XK_equal, XK_greater, XK_question,
+ XK_at, XK_A, XK_B, XK_C,
+ XK_D, XK_E, XK_F, XK_G,
+ XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O,
+ XK_P, XK_Q, XK_R, XK_S,
+ XK_T, XK_U, XK_V, XK_W,
+ XK_X, XK_Y, XK_Z, XK_bracketleft,
+ XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
+ XK_grave, XK_a, XK_b, XK_c,
+ XK_d, XK_e, XK_f, XK_g,
+ XK_h, XK_i, XK_j, XK_k,
+ XK_l, XK_m, XK_n, XK_o,
+ XK_p, XK_q, XK_r, XK_s,
+ XK_t, XK_u, XK_v, XK_w,
+ XK_x, XK_y, XK_z, XK_braceleft,
+ XK_bar, XK_braceright, XK_asciitilde, XK_BackSpace,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_nobreakspace,XK_exclamdown, XK_cent, XK_sterling,
+ XK_currency, XK_yen, XK_brokenbar, XK_section,
+ XK_diaeresis, XK_copyright, XK_ordfeminine, XK_guillemotleft,
+ XK_notsign, XK_hyphen, XK_registered, XK_macron,
+ XK_degree, XK_plusminus, XK_twosuperior, XK_threesuperior,
+ XK_acute, XK_mu, XK_paragraph, XK_periodcentered,
+ XK_cedilla, XK_onesuperior, XK_masculine, XK_guillemotright,
+ XK_onequarter, XK_onehalf, XK_threequarters,XK_questiondown,
+ XK_Agrave, XK_Aacute, XK_Acircumflex, XK_Atilde,
+ XK_Adiaeresis, XK_Aring, XK_AE, XK_Ccedilla,
+ XK_Egrave, XK_Eacute, XK_Ecircumflex, XK_Ediaeresis,
+ XK_Igrave, XK_Iacute, XK_Icircumflex, XK_Idiaeresis,
+ XK_ETH, XK_Ntilde, XK_Ograve, XK_Oacute,
+ XK_Ocircumflex, XK_Otilde, XK_Odiaeresis, XK_multiply,
+ XK_Ooblique, XK_Ugrave, XK_Uacute, XK_Ucircumflex,
+ XK_Udiaeresis, XK_Yacute, XK_THORN, XK_ssharp,
+ XK_agrave, XK_aacute, XK_acircumflex, XK_atilde,
+ XK_adiaeresis, XK_aring, XK_ae, XK_ccedilla,
+ XK_egrave, XK_eacute, XK_ecircumflex, XK_ediaeresis,
+ XK_igrave, XK_iacute, XK_icircumflex, XK_idiaeresis,
+ XK_eth, XK_ntilde, XK_ograve, XK_oacute,
+ XK_ocircumflex, XK_otilde, XK_odiaeresis, XK_division,
+ XK_oslash, XK_ugrave, XK_uacute, XK_ucircumflex,
+ XK_udiaeresis, XK_yacute, XK_thorn, XK_ydiaeresis
+};
+
+/*
+ * Maps the AT keycodes to Linux keycodes
+ */
+static unsigned char at2lnx[NUM_KEYCODES] =
+{
+ 0x01, /* KEY_Escape */ 0x02, /* KEY_1 */
+ 0x03, /* KEY_2 */ 0x04, /* KEY_3 */
+ 0x05, /* KEY_4 */ 0x06, /* KEY_5 */
+ 0x07, /* KEY_6 */ 0x08, /* KEY_7 */
+ 0x09, /* KEY_8 */ 0x0a, /* KEY_9 */
+ 0x0b, /* KEY_0 */ 0x0c, /* KEY_Minus */
+ 0x0d, /* KEY_Equal */ 0x0e, /* KEY_BackSpace */
+ 0x0f, /* KEY_Tab */ 0x10, /* KEY_Q */
+ 0x11, /* KEY_W */ 0x12, /* KEY_E */
+ 0x13, /* KEY_R */ 0x14, /* KEY_T */
+ 0x15, /* KEY_Y */ 0x16, /* KEY_U */
+ 0x17, /* KEY_I */ 0x18, /* KEY_O */
+ 0x19, /* KEY_P */ 0x1a, /* KEY_LBrace */
+ 0x1b, /* KEY_RBrace */ 0x1c, /* KEY_Enter */
+ 0x1d, /* KEY_LCtrl */ 0x1e, /* KEY_A */
+ 0x1f, /* KEY_S */ 0x20, /* KEY_D */
+ 0x21, /* KEY_F */ 0x22, /* KEY_G */
+ 0x23, /* KEY_H */ 0x24, /* KEY_J */
+ 0x25, /* KEY_K */ 0x26, /* KEY_L */
+ 0x27, /* KEY_SemiColon */ 0x28, /* KEY_Quote */
+ 0x29, /* KEY_Tilde */ 0x2a, /* KEY_ShiftL */
+ 0x2b, /* KEY_BSlash */ 0x2c, /* KEY_Z */
+ 0x2d, /* KEY_X */ 0x2e, /* KEY_C */
+ 0x2f, /* KEY_V */ 0x30, /* KEY_B */
+ 0x31, /* KEY_N */ 0x32, /* KEY_M */
+ 0x33, /* KEY_Comma */ 0x34, /* KEY_Period */
+ 0x35, /* KEY_Slash */ 0x36, /* KEY_ShiftR */
+ 0x37, /* KEY_KP_Multiply */ 0x38, /* KEY_Alt */
+ 0x39, /* KEY_Space */ 0x3a, /* KEY_CapsLock */
+ 0x3b, /* KEY_F1 */ 0x3c, /* KEY_F2 */
+ 0x3d, /* KEY_F3 */ 0x3e, /* KEY_F4 */
+ 0x3f, /* KEY_F5 */ 0x40, /* KEY_F6 */
+ 0x41, /* KEY_F7 */ 0x42, /* KEY_F8 */
+ 0x43, /* KEY_F9 */ 0x44, /* KEY_F10 */
+ 0x45, /* KEY_NumLock */ 0x46, /* KEY_ScrollLock */
+ 0x47, /* KEY_KP_7 */ 0x48, /* KEY_KP_8 */
+ 0x49, /* KEY_KP_9 */ 0x4a, /* KEY_KP_Minus */
+ 0x4b, /* KEY_KP_4 */ 0x4c, /* KEY_KP_5 */
+ 0x4d, /* KEY_KP_6 */ 0x4e, /* KEY_KP_Plus */
+ 0x4f, /* KEY_KP_1 */ 0x50, /* KEY_KP_2 */
+ 0x51, /* KEY_KP_3 */ 0x52, /* KEY_KP_0 */
+ 0x53, /* KEY_KP_Decimal */ 0x54, /* KEY_SysReqest */
+ 0x00, /* 0x55 */ 0x56, /* KEY_Less */
+ 0x57, /* KEY_F11 */ 0x58, /* KEY_F12 */
+ 0x66, /* KEY_Home */ 0x67, /* KEY_Up */
+ 0x68, /* KEY_PgUp */ 0x69, /* KEY_Left */
+ 0x5d, /* KEY_Begin */ 0x6a, /* KEY_Right */
+ 0x6b, /* KEY_End */ 0x6c, /* KEY_Down */
+ 0x6d, /* KEY_PgDown */ 0x6e, /* KEY_Insert */
+ 0x6f, /* KEY_Delete */ 0x60, /* KEY_KP_Enter */
+ 0x61, /* KEY_RCtrl */ 0x77, /* KEY_Pause */
+ 0x63, /* KEY_Print */ 0x62, /* KEY_KP_Divide */
+ 0x64, /* KEY_AltLang */ 0x65, /* KEY_Break */
+ 0x00, /* KEY_LMeta */ 0x00, /* KEY_RMeta */
+ 0x7A, /* KEY_Menu/FOCUS_PF11*/0x00, /* 0x6e */
+ 0x7B, /* FOCUS_PF12 */ 0x00, /* 0x70 */
+ 0x00, /* 0x71 */ 0x00, /* 0x72 */
+ 0x59, /* FOCUS_PF2 */ 0x78, /* FOCUS_PF9 */
+ 0x00, /* 0x75 */ 0x00, /* 0x76 */
+ 0x5A, /* FOCUS_PF3 */ 0x5B, /* FOCUS_PF4 */
+ 0x5C, /* FOCUS_PF5 */ 0x5D, /* FOCUS_PF6 */
+ 0x5E, /* FOCUS_PF7 */ 0x5F, /* FOCUS_PF8 */
+ 0x7C, /* JAP_86 */ 0x79, /* FOCUS_PF10 */
+ 0x00, /* 0x7f */
+};
+#define NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0]))
+
+#define NUM_CUSTOMKEYS NR_KEYS
+
+u_char SpecialServerMap[NUM_CUSTOMKEYS];
+
+static void
+readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ KeySym *k;
+ int i;
+ int maxkey;
+ static unsigned char tbl[GLYPHS_PER_KEY] =
+ {
+ 0, /* unshifted */
+ 1, /* shifted */
+ 0, /* modeswitch unshifted */
+ 0 /* modeswitch shifted */
+ };
+
+ /*
+ * Read the mapping from the kernel.
+ * Since we're still using the XFree86 scancode->AT keycode mapping
+ * routines, we need to convert the AT keycodes to Linux keycodes,
+ * then translate the Linux keysyms into X keysyms.
+ *
+ * First, figure out which tables to use for the modeswitch columns
+ * above, from the XF86Config fields.
+ */
+ tbl[2] = 8; /* alt */
+ tbl[3] = tbl[2] | 1;
+
+ if (xf86Info.kbdCustomKeycodes) {
+ k = map;
+ maxkey = NUM_CUSTOMKEYS;
+ }
+ else {
+ k = map+GLYPHS_PER_KEY;
+ maxkey = NUM_AT2LNX;
+ }
+
+ for (i = 0; i < maxkey; ++i)
+ {
+ struct kbentry kbe;
+ int j;
+
+ if (xf86Info.kbdCustomKeycodes)
+ kbe.kb_index = i;
+ else
+ kbe.kb_index = at2lnx[i];
+
+ for (j = 0; j < GLYPHS_PER_KEY; ++j, ++k)
+ {
+ unsigned short kval;
+
+ *k = NoSymbol;
+
+ kbe.kb_table = tbl[j];
+ if (
+ (!xf86Info.kbdCustomKeycodes && kbe.kb_index == 0) ||
+ ioctl(xf86Info.consoleFd, KDGKBENT, &kbe))
+ continue;
+
+ kval = KVAL(kbe.kb_value);
+ switch (KTYP(kbe.kb_value))
+ {
+ case KT_LATIN:
+ case KT_LETTER:
+ *k = linux_to_x[kval];
+ break;
+
+ case KT_FN:
+ if (kval <= 19)
+ *k = XK_F1 + kval;
+ else switch (kbe.kb_value)
+ {
+ case K_FIND:
+ *k = XK_Home; /* or XK_Find */
+ break;
+ case K_INSERT:
+ *k = XK_Insert;
+ break;
+ case K_REMOVE:
+ *k = XK_Delete;
+ break;
+ case K_SELECT:
+ *k = XK_End; /* or XK_Select */
+ break;
+ case K_PGUP:
+ *k = XK_Prior;
+ break;
+ case K_PGDN:
+ *k = XK_Next;
+ break;
+ case K_HELP:
+ *k = XK_Help;
+ break;
+ case K_DO:
+ *k = XK_Execute;
+ break;
+ case K_PAUSE:
+ *k = XK_Pause;
+ break;
+ case K_MACRO:
+ *k = XK_Menu;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case KT_SPEC:
+ switch (kbe.kb_value)
+ {
+ case K_ENTER:
+ *k = XK_Return;
+ break;
+ case K_BREAK:
+ *k = XK_Break;
+ break;
+ case K_CAPS:
+ *k = XK_Caps_Lock;
+ break;
+ case K_NUM:
+ *k = XK_Num_Lock;
+ break;
+ case K_HOLD:
+ *k = XK_Scroll_Lock;
+ break;
+ case K_COMPOSE:
+ *k = XK_Multi_key;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case KT_PAD:
+ switch (kbe.kb_value)
+ {
+ case K_PPLUS:
+ *k = XK_KP_Add;
+ break;
+ case K_PMINUS:
+ *k = XK_KP_Subtract;
+ break;
+ case K_PSTAR:
+ *k = XK_KP_Multiply;
+ break;
+ case K_PSLASH:
+ *k = XK_KP_Divide;
+ break;
+ case K_PENTER:
+ *k = XK_KP_Enter;
+ break;
+ case K_PCOMMA:
+ *k = XK_KP_Separator;
+ break;
+ case K_PDOT:
+ *k = XK_KP_Decimal;
+ break;
+ case K_PPLUSMINUS:
+ *k = XK_KP_Subtract;
+ break;
+ default:
+ if (kval <= 9)
+ *k = XK_KP_0 + kval;
+ break;
+ }
+ break;
+
+ /*
+ * KT_DEAD keys are for accelerated diacritical creation.
+ */
+ case KT_DEAD:
+ switch (kbe.kb_value)
+ {
+ case K_DGRAVE:
+ *k = XK_dead_grave;
+ break;
+ case K_DACUTE:
+ *k = XK_dead_acute;
+ break;
+ case K_DCIRCM:
+ *k = XK_dead_circumflex;
+ break;
+ case K_DTILDE:
+ *k = XK_dead_tilde;
+ break;
+ case K_DDIERE:
+ *k = XK_dead_diaeresis;
+ break;
+ }
+ break;
+
+ case KT_CUR:
+ switch (kbe.kb_value)
+ {
+ case K_DOWN:
+ *k = XK_Down;
+ break;
+ case K_LEFT:
+ *k = XK_Left;
+ break;
+ case K_RIGHT:
+ *k = XK_Right;
+ break;
+ case K_UP:
+ *k = XK_Up;
+ break;
+ }
+ break;
+
+ case KT_SHIFT:
+ switch (kbe.kb_value)
+ {
+ case K_ALTGR:
+ *k = XK_Alt_R;
+ break;
+ case K_ALT:
+ *k = (kbe.kb_index == 0x64 ?
+ XK_Alt_R : XK_Alt_L);
+ break;
+ case K_CTRL:
+ *k = (kbe.kb_index == 0x61 ?
+ XK_Control_R : XK_Control_L);
+ break;
+ case K_CTRLL:
+ *k = XK_Control_L;
+ break;
+ case K_CTRLR:
+ *k = XK_Control_R;
+ break;
+ case K_SHIFT:
+ *k = (kbe.kb_index == 0x36 ?
+ XK_Shift_R : XK_Shift_L);
+ break;
+ case K_SHIFTL:
+ *k = XK_Shift_L;
+ break;
+ case K_SHIFTR:
+ *k = XK_Shift_R;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ /*
+ * KT_ASCII keys accumulate a 3 digit decimal number that gets
+ * emitted when the shift state changes. We can't emulate that.
+ */
+ case KT_ASCII:
+ break;
+
+ case KT_LOCK:
+ if (kbe.kb_value == K_SHIFTLOCK)
+ *k = XK_Shift_Lock;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if (k[-1] == k[-2]) k[-1] = NoSymbol;
+ if (k[-2] == k[-3]) k[-2] = NoSymbol;
+ if (k[-3] == k[-4]) k[-3] = NoSymbol;
+ if (k[-4] == k[-2] && k[-3] == k[-1]) k[-2] = k[-1] = NoSymbol;
+ if (k[-1] == k[-4] && k[-2] == k[-3] && k[-2] == NoSymbol) k[-1] =NoSymbol;
+ }
+
+ if (!xf86Info.kbdCustomKeycodes)
+ return;
+
+ /*
+ * Find the Mapping for the special server functions
+ */
+ for (i = 0; i < NUM_CUSTOMKEYS; ++i) {
+ struct kbentry kbe;
+ int special = 0;
+
+ kbe.kb_index = i;
+ kbe.kb_table = 0; /* Plain map */
+ if (!ioctl(xf86Info.consoleFd, KDGKBENT, &kbe))
+ switch (kbe.kb_value) {
+ case K(KT_LATIN,0x7f): /* This catches DEL too... But who cares? */
+ special = KEY_BackSpace;
+ break;
+ case K_PMINUS:
+ special = KEY_KP_Minus;
+ break;
+ case K_PPLUS:
+ special = KEY_KP_Plus;
+ break;
+ case K_F1:
+ special = KEY_F1;
+ break;
+ case K_F2:
+ special = KEY_F2;
+ break;
+ case K_F3:
+ special = KEY_F3;
+ break;
+ case K_F4:
+ special = KEY_F4;
+ break;
+ case K_F5:
+ special = KEY_F5;
+ break;
+ case K_F6:
+ special = KEY_F6;
+ break;
+ case K_F7:
+ special = KEY_F7;
+ break;
+ case K_F8:
+ special = KEY_F8;
+ break;
+ case K_F9:
+ special = KEY_F9;
+ break;
+ case K_F10:
+ special = KEY_F10;
+ break;
+ case K_F11:
+ special = KEY_F11;
+ break;
+ case K_F12:
+ special = KEY_F12;
+ break;
+ case K_ALT:
+ special = KEY_Alt;
+ break;
+ case K_ALTGR:
+ special = KEY_AltLang;
+ break;
+ case K_CONS:
+ special = KEY_SysReqest;
+ break;
+ }
+ SpecialServerMap[i] = special;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86KbdMach.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86KbdMach.c
new file mode 100644
index 000000000..89c23c24a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86KbdMach.c
@@ -0,0 +1,317 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdMach.c,v 3.7.4.2 1998/06/04 17:35:20 dawes Exp $ */
+/*
+ *****************************************************************************
+ * HISTORY
+ * Log: xf86KbdMach.c,v
+ * Revision 2.1.2.1 92/06/25 10:32:08 moore
+ * Incorporate the Elliot Dresselhaus's, Ernest Hua's and local changes
+ * to run Thomas Roell's I386 color X11R5. Original code only worked
+ * with SCO Unix. New code works with 2.5 and 3.0 Mach
+ * [92/06/24 rvb]
+ *
+ * EndLog
+ *
+ *****************************************************************************
+ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: xf86KbdMach.c /main/9 1996/02/21 17:38:43 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "atKeynames.h"
+#include "xf86Config.h"
+
+#include "xf86Keymap.h"
+
+static KeySym ascii_to_x[256] = {
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, XK_Return, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Escape,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
+ XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
+ XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
+ XK_comma, XK_minus, XK_period, XK_slash,
+ XK_0, XK_1, XK_2, XK_3,
+ XK_4, XK_5, XK_6, XK_7,
+ XK_8, XK_9, XK_colon, XK_semicolon,
+ XK_less, XK_equal, XK_greater, XK_question,
+ XK_at, XK_A, XK_B, XK_C,
+ XK_D, XK_E, XK_F, XK_G,
+ XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O,
+ XK_P, XK_Q, XK_R, XK_S,
+ XK_T, XK_U, XK_V, XK_W,
+ XK_X, XK_Y, XK_Z, XK_bracketleft,
+ XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
+ XK_grave, XK_a, XK_b, XK_c,
+ XK_d, XK_e, XK_f, XK_g,
+ XK_h, XK_i, XK_j, XK_k,
+ XK_l, XK_m, XK_n, XK_o,
+ XK_p, XK_q, XK_r, XK_s,
+ XK_t, XK_u, XK_v, XK_w,
+ XK_x, XK_y, XK_z, XK_braceleft,
+ XK_bar, XK_braceright, XK_asciitilde, XK_Delete,
+ XK_Ccedilla, XK_udiaeresis, XK_eacute, XK_acircumflex,
+ XK_adiaeresis, XK_agrave, XK_aring, XK_ccedilla,
+ XK_ecircumflex, XK_ediaeresis, XK_egrave, XK_idiaeresis,
+ XK_icircumflex, XK_igrave, XK_Adiaeresis, XK_Aring,
+ XK_Eacute, XK_ae, XK_AE, XK_ocircumflex,
+ XK_odiaeresis, XK_ograve, XK_ucircumflex, XK_ugrave,
+ XK_ydiaeresis, XK_Odiaeresis, XK_Udiaeresis, XK_cent,
+ XK_sterling, XK_yen, XK_paragraph, XK_section,
+ XK_aacute, XK_iacute, XK_oacute, XK_uacute,
+ XK_ntilde, XK_Ntilde, XK_ordfeminine, XK_masculine,
+ XK_questiondown,XK_hyphen, XK_notsign, XK_onehalf,
+ XK_onequarter, XK_exclamdown, XK_guillemotleft,XK_guillemotright,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_Greek_alpha, XK_ssharp, XK_Greek_GAMMA, XK_Greek_pi,
+ XK_Greek_SIGMA, XK_Greek_sigma, XK_mu, XK_Greek_tau,
+ XK_Greek_PHI, XK_Greek_THETA, XK_Greek_OMEGA, XK_Greek_delta,
+ XK_infinity, XK_Ooblique, XK_Greek_epsilon, XK_intersection,
+ XK_identical, XK_plusminus, XK_greaterthanequal, XK_lessthanequal,
+ XK_topintegral, XK_botintegral, XK_division, XK_similarequal,
+ XK_degree, NoSymbol, NoSymbol, XK_radical,
+ XK_Greek_eta, XK_twosuperior, XK_periodcentered, NoSymbol,
+ };
+
+/*
+ * LegalModifier --
+ * determine whether a key is a legal modifier key, i.e send a
+ * press/release sequence.
+ */
+
+/*ARGSUSED*/
+Bool
+LegalModifier(key, pDev)
+ unsigned int key;
+ DevicePtr pDev;
+{
+ return (TRUE);
+}
+
+
+
+/*
+ * xf86KbdGetMapping --
+ * Get the national keyboard mapping. The keyboard type is set, a new map
+ * and the modifiermap is computed.
+ */
+
+void
+xf86KbdGetMapping (pKeySyms, pModMap)
+ KeySymsPtr pKeySyms;
+ CARD8 *pModMap;
+{
+ KeySym *k;
+ struct kbentry kbe;
+ char type;
+ int i, j;
+
+ for (i = 0; i < NUMKEYS; i++)
+ {
+ static int states[] = { NORM_STATE, SHIFT_STATE, ALT_STATE, SHIFT_ALT };
+ int j;
+
+ k = &map[i*4];
+ kbe.kb_index = i;
+
+ for (j = 0; j < 4; j++)
+ {
+ kbe.kb_state = states[j];
+
+ if (ioctl (xf86Info.consoleFd, KDGKBENT, &kbe) != -1)
+ continue;
+
+ if (kbe.kb_value [0] == K_SCAN)
+ {
+ int keycode = -1;
+ switch (kbe.kb_value [1])
+ {
+ case K_CTLSC: keycode = XK_Control_L; break;
+ case K_LSHSC: keycode = XK_Shift_L; break;
+ case K_RSHSC: keycode = XK_Shift_R; break;
+ case K_ALTSC: keycode = XK_Alt_L; break;
+ case K_CLCKSC: keycode = XK_Caps_Lock; break;
+ case K_NLCKSC: keycode = XK_Num_Lock; break;
+ default: break;
+ }
+ if (keycode > 0)
+ k[j] = keycode;
+ }
+ else if (kbe.kb_value[1] != NC)
+ {
+ /* How to handle multiple characters?
+ Ignore them for now. */
+ }
+ else
+ {
+ k[j] = ascii_to_x[kbe.kb_value[0]];
+ }
+ }
+ }
+
+ /*
+ * Apply the special key mapping specified in XF86Config
+ */
+ for (k = map, i = MIN_KEYCODE;
+ i < (NUM_KEYCODES + MIN_KEYCODE);
+ i++, k += 4) {
+ switch (k[0]) {
+ case XK_Alt_L:
+ j = K_INDEX_LEFTALT;
+ break;
+ case XK_Alt_R:
+ j = K_INDEX_RIGHTALT;
+ break;
+ case XK_Scroll_Lock:
+ j = K_INDEX_SCROLLLOCK;
+ break;
+ case XK_Control_R:
+ j = K_INDEX_RIGHTCTL;
+ break;
+ default:
+ j = -1;
+ }
+ if (j >= 0)
+ switch (xf86Info.specialKeyMap[j]) {
+ case KM_META:
+ if (k[0] == XK_Alt_R)
+ k[1] = XK_Meta_R;
+ else {
+ k[0] = XK_Alt_L;
+ k[1] = XK_Meta_L;
+ }
+ break;
+ case KM_COMPOSE:
+ k[0] = XK_Multi_key;
+ break;
+ case KM_MODESHIFT:
+ k[0] = XK_Mode_switch;
+ k[1] = NoSymbol;
+ break;
+ case KM_MODELOCK:
+ k[0] = XK_Mode_switch;
+ k[1] = XF86XK_ModeLock;
+ break;
+ case KM_SCROLLLOCK:
+ k[0] = XK_Scroll_Lock;
+ break;
+ case KM_CONTROL:
+ k[0] = XK_Control_R;
+ break;
+ }
+ }
+
+ /*
+ * compute the modifier map
+ */
+ for (i = 0; i < MAP_LENGTH; i++)
+ pModMap[i] = NoSymbol; /* make sure it is restored */
+
+ for (k = map, i = MIN_KEYCODE;
+ i < (NUM_KEYCODES + MIN_KEYCODE);
+ i++, k += 4)
+
+ switch(*k) {
+
+ case XK_Shift_L:
+ case XK_Shift_R:
+ pModMap[i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ case XK_Control_R:
+ pModMap[i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ pModMap[i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ case XK_Alt_R:
+ pModMap[i] = AltMask;
+ break;
+
+ case XK_Num_Lock:
+ if (!xf86Info.serverNumLock) pModMap[i] = NumLockMask;
+ break;
+
+ case XK_Scroll_Lock:
+ pModMap[i] = ScrollLockMask;
+ break;
+
+ /* kana support */
+ case XK_Kana_Lock:
+ case XK_Kana_Shift:
+ pModMap[i] = KanaMask;
+ break;
+
+ /* alternate toggle for multinational support */
+ case XK_Mode_switch:
+ pModMap[i] = AltLangMask;
+ break;
+
+ }
+
+ xf86Info.kbdType =
+ ioctl(xf86Info.kbdFd, KDGKBDTYPE, &type) != -1 ? type : KB_VANILLAKB;
+
+ pKeySyms->map = map;
+ pKeySyms->mapWidth = GLYPHS_PER_KEY;
+ pKeySyms->minKeyCode = MIN_KEYCODE;
+ if (xf86Info.serverNumLock)
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
+ else
+ pKeySyms->maxKeyCode = MAX_STD_KEYCODE;
+
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Keymap.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Keymap.h
new file mode 100644
index 000000000..f0998ba9b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Keymap.h
@@ -0,0 +1,455 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Keymap.h,v 3.20 2003/08/24 17:36:53 dawes Exp $ */
+
+/*
+ * Copyright (c) 1994-2002 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ *
+ * For Scancodes see notes in atKeynames.h !!!!
+ *
+ */
+/* $XConsortium: xf86Keymap.h /main/14 1996/02/21 17:38:47 kaleb $ */
+
+static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = {
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#if !defined(__SOL8__) && (!defined(sun) || defined(i386))
+
+ /* 0x00 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x01 */ XK_Escape, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x02 */ XK_1, XK_exclam, NoSymbol, NoSymbol,
+ /* 0x03 */ XK_2, XK_at, NoSymbol, NoSymbol,
+ /* 0x04 */ XK_3, XK_numbersign, NoSymbol, NoSymbol,
+ /* 0x05 */ XK_4, XK_dollar, NoSymbol, NoSymbol,
+ /* 0x06 */ XK_5, XK_percent, NoSymbol, NoSymbol,
+ /* 0x07 */ XK_6, XK_asciicircum, NoSymbol, NoSymbol,
+ /* 0x08 */ XK_7, XK_ampersand, NoSymbol, NoSymbol,
+ /* 0x09 */ XK_8, XK_asterisk, NoSymbol, NoSymbol,
+ /* 0x0a */ XK_9, XK_parenleft, NoSymbol, NoSymbol,
+ /* 0x0b */ XK_0, XK_parenright, NoSymbol, NoSymbol,
+ /* 0x0c */ XK_minus, XK_underscore, NoSymbol, NoSymbol,
+ /* 0x0d */ XK_equal, XK_plus, NoSymbol, NoSymbol,
+ /* 0x0e */ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x0f */ XK_Tab, XK_ISO_Left_Tab,NoSymbol, NoSymbol,
+ /* 0x10 */ XK_Q, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x11 */ XK_W, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x12 */ XK_E, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x13 */ XK_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x14 */ XK_T, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x15 */ XK_Y, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x16 */ XK_U, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x17 */ XK_I, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x18 */ XK_O, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x19 */ XK_P, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1a */ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol,
+ /* 0x1b */ XK_bracketright,XK_braceright, NoSymbol, NoSymbol,
+ /* 0x1c */ XK_Return, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1d */ XK_Control_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1e */ XK_A, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1f */ XK_S, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x20 */ XK_D, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x21 */ XK_F, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x22 */ XK_G, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x23 */ XK_H, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x24 */ XK_J, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x25 */ XK_K, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x26 */ XK_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x27 */ XK_semicolon, XK_colon, NoSymbol, NoSymbol,
+ /* 0x28 */ XK_quoteright, XK_quotedbl, NoSymbol, NoSymbol,
+ /* 0x29 */ XK_quoteleft, XK_asciitilde, NoSymbol, NoSymbol,
+ /* 0x2a */ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2b */ XK_backslash, XK_bar, NoSymbol, NoSymbol,
+ /* 0x2c */ XK_Z, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2d */ XK_X, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2e */ XK_C, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2f */ XK_V, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x30 */ XK_B, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x31 */ XK_N, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x32 */ XK_M, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x33 */ XK_comma, XK_less, NoSymbol, NoSymbol,
+ /* 0x34 */ XK_period, XK_greater, NoSymbol, NoSymbol,
+ /* 0x35 */ XK_slash, XK_question, NoSymbol, NoSymbol,
+ /* 0x36 */ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x37 */ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x38 */ XK_Alt_L, XK_Meta_L, NoSymbol, NoSymbol,
+ /* 0x39 */ XK_space, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3a */ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3b */ XK_F1, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3c */ XK_F2, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3d */ XK_F3, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3e */ XK_F4, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3f */ XK_F5, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x40 */ XK_F6, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x41 */ XK_F7, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x42 */ XK_F8, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x43 */ XK_F9, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x44 */ XK_F10, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x45 */ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x46 */ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x47 */ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol,
+ /* 0x48 */ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol,
+ /* 0x49 */ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol,
+ /* 0x4a */ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4b */ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol,
+ /* 0x4c */ XK_KP_Begin, XK_KP_5, NoSymbol, NoSymbol,
+ /* 0x4d */ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol,
+ /* 0x4e */ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4f */ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol,
+ /* 0x50 */ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol,
+ /* 0x51 */ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol,
+ /* 0x52 */ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol,
+ /* 0x53 */ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol,
+ /* 0x54 */ XK_Sys_Req, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x55 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x56 */ XK_less, XK_greater, NoSymbol, NoSymbol,
+ /* 0x57 */ XK_F11, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x58 */ XK_F12, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x59 */ XK_Home, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5a */ XK_Up, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5b */ XK_Prior, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5c */ XK_Left, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5d */ XK_Begin, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5e */ XK_Right, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5f */ XK_End, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x60 */ XK_Down, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x61 */ XK_Next, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x62 */ XK_Insert, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x63 */ XK_Delete, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x64 */ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x65 */ XK_Control_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x66 */ XK_Pause, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x67 */ XK_Print, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x68 */ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x69 */ XK_Alt_R, XK_Meta_R, NoSymbol, NoSymbol,
+ /* 0x6a */ XK_Break, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6b */ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6c */ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6d */ XK_Menu, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6e */ XK_F13, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6f */ XK_F14, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x70 */ XK_F15, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x71 */ XK_F16, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x72 */ XK_F17, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x73 */ XK_backslash, XK_underscore, NoSymbol, NoSymbol,
+ /* 0x74 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x75 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x76 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x77 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x78 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x79 */ XK_Henkan, XK_Mode_switch, NoSymbol, NoSymbol,
+ /* 0x7a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7b */ XK_Muhenkan, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7d */ XK_backslash, XK_bar, NoSymbol, NoSymbol,
+ /* 0x7e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+
+#else /* SunOS */
+
+/* Assumes a US English keyboard as default - sorry 'bout that
+ *
+ * Hopefully it'll be enough someone can have a sorta working
+ * keyboard, if they're not using XKB
+ *
+ * DWH 9/12/99
+ */
+
+ /* 0x00 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x01 */ XK_quoteleft, XK_asciitilde, NoSymbol, NoSymbol,
+ /* 0x02 */ XK_1, XK_exclam, NoSymbol, NoSymbol,
+ /* 0x03 */ XK_2, XK_at, NoSymbol, NoSymbol,
+ /* 0x04 */ XK_3, XK_numbersign, NoSymbol, NoSymbol,
+ /* 0x05 */ XK_4, XK_dollar, NoSymbol, NoSymbol,
+ /* 0x06 */ XK_5, XK_percent, NoSymbol, NoSymbol,
+ /* 0x07 */ XK_6, XK_asciicircum, NoSymbol, NoSymbol,
+ /* 0x08 */ XK_7, XK_ampersand, NoSymbol, NoSymbol,
+ /* 0x09 */ XK_8, XK_asterisk, NoSymbol, NoSymbol,
+ /* 0x0a */ XK_9, XK_parenleft, NoSymbol, NoSymbol,
+ /* 0x0b */ XK_0, XK_parenright, NoSymbol, NoSymbol,
+ /* 0x0c */ XK_minus, XK_underscore, NoSymbol, NoSymbol,
+ /* 0x0d */ XK_equal, XK_plus, NoSymbol, NoSymbol,
+ /* 0x0e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x0f */ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x10 */ XK_Tab, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x11 */ XK_Q, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x12 */ XK_W, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x13 */ XK_E, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x14 */ XK_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x15 */ XK_T, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x16 */ XK_Y, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x17 */ XK_U, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x18 */ XK_I, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x19 */ XK_O, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1a */ XK_P, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1b */ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol,
+ /* 0x1c */ XK_bracketright,XK_braceright, NoSymbol, NoSymbol,
+ /* 0x1d */ XK_backslash, XK_bar, NoSymbol, NoSymbol,
+ /* 0x1e */ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1f */ XK_A, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x20 */ XK_S, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x21 */ XK_D, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x22 */ XK_F, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x23 */ XK_G, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x24 */ XK_H, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x25 */ XK_J, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x26 */ XK_K, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x27 */ XK_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x28 */ XK_semicolon, XK_colon, NoSymbol, NoSymbol,
+ /* 0x29 */ XK_quoteright, XK_quotedbl, NoSymbol, NoSymbol,
+ /* 0x2a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2b */ XK_Return, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2c */ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2e */ XK_Z, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2f */ XK_X, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x30 */ XK_C, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x31 */ XK_V, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x32 */ XK_B, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x33 */ XK_N, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x34 */ XK_M, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x35 */ XK_comma, XK_less, NoSymbol, NoSymbol,
+ /* 0x36 */ XK_period, XK_greater, NoSymbol, NoSymbol,
+ /* 0x37 */ XK_slash, XK_question, NoSymbol, NoSymbol,
+ /* 0x38 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x39 */ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3a */ XK_Control_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3c */ XK_Alt_L, XK_Meta_L, NoSymbol, NoSymbol,
+ /* 0x3d */ XK_space, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3e */ XK_Alt_R, XK_Meta_R, NoSymbol, NoSymbol,
+ /* 0x3f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x40 */ XK_Control_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x41 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x42 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x43 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x44 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x45 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x46 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x47 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x48 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x49 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4b */ XK_Insert, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4c */ XK_Delete, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4f */ XK_Left, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x50 */ XK_Home, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x51 */ XK_End, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x52 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x53 */ XK_Up, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x54 */ XK_Down, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x55 */ XK_Prior, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x56 */ XK_Next, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x57 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x58 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x59 */ XK_Right, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5a */ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5b */ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol,
+ /* 0x5c */ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol,
+ /* 0x5d */ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol,
+ /* 0x5e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5f */ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x60 */ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol,
+ /* 0x61 */ NoSymbol, XK_KP_5, NoSymbol, NoSymbol,
+ /* 0x62 */ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol,
+ /* 0x63 */ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol,
+ /* 0x64 */ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x65 */ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol,
+ /* 0x66 */ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol,
+ /* 0x67 */ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol,
+ /* 0x68 */ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol,
+ /* 0x69 */ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6a */ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6c */ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6e */ XK_Escape, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x70 */ XK_F1, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x71 */ XK_F2, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x72 */ XK_F3, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x73 */ XK_F4, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x74 */ XK_F5, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x75 */ XK_F6, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x76 */ XK_F7, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x77 */ XK_F8, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x78 */ XK_F9, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x79 */ XK_F10, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7a */ XK_F11, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7b */ XK_F12, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7c */ XK_Print, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7d */ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7e */ XK_Pause, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+
+#endif /* SunOS */
+
+};
+
+#if !defined(Lynx) && \
+ !defined(__UNIXOS2__) && \
+ !defined(__mips__) && \
+ !defined(linux) && \
+ !defined(CSRG_BASED) && \
+ !defined(__CYGWIN__) && \
+ !defined(__SOL8__) && \
+ (!defined(sun) || defined(i386))
+
+static KeySym map84[NUM_KEYCODES * GLYPHS_PER_KEY] = {
+ /* 0x00 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x01 */ XK_Escape, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x02 */ XK_1, XK_exclam, NoSymbol, NoSymbol,
+ /* 0x03 */ XK_2, XK_at, NoSymbol, NoSymbol,
+ /* 0x04 */ XK_3, XK_numbersign, NoSymbol, NoSymbol,
+ /* 0x05 */ XK_4, XK_dollar, NoSymbol, NoSymbol,
+ /* 0x06 */ XK_5, XK_percent, NoSymbol, NoSymbol,
+ /* 0x07 */ XK_6, XK_asciicircum, NoSymbol, NoSymbol,
+ /* 0x08 */ XK_7, XK_ampersand, NoSymbol, NoSymbol,
+ /* 0x09 */ XK_8, XK_asterisk, NoSymbol, NoSymbol,
+ /* 0x0a */ XK_9, XK_parenleft, NoSymbol, NoSymbol,
+ /* 0x0b */ XK_0, XK_parenright, NoSymbol, NoSymbol,
+ /* 0x0c */ XK_minus, XK_underscore, NoSymbol, NoSymbol,
+ /* 0x0d */ XK_equal, XK_plus, NoSymbol, NoSymbol,
+ /* 0x0e */ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x0f */ XK_Tab, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x10 */ XK_Q, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x11 */ XK_W, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x12 */ XK_E, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x13 */ XK_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x14 */ XK_T, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x15 */ XK_Y, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x16 */ XK_U, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x17 */ XK_I, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x18 */ XK_O, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x19 */ XK_P, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1a */ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol,
+ /* 0x1b */ XK_bracketright,XK_braceright, NoSymbol, NoSymbol,
+ /* 0x1c */ XK_Return, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1d */ XK_Control_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1e */ XK_A, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1f */ XK_S, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x20 */ XK_D, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x21 */ XK_F, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x22 */ XK_G, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x23 */ XK_H, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x24 */ XK_J, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x25 */ XK_K, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x26 */ XK_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x27 */ XK_semicolon, XK_colon, NoSymbol, NoSymbol,
+ /* 0x28 */ XK_quoteright, XK_quotedbl, NoSymbol, NoSymbol,
+ /* 0x29 */ XK_quoteleft, XK_asciitilde, NoSymbol, NoSymbol,
+ /* 0x2a */ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2b */ XK_backslash, XK_bar, NoSymbol, NoSymbol,
+ /* 0x2c */ XK_Z, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2d */ XK_X, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2e */ XK_C, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2f */ XK_V, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x30 */ XK_B, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x31 */ XK_N, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x32 */ XK_M, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x33 */ XK_comma, XK_less, NoSymbol, NoSymbol,
+ /* 0x34 */ XK_period, XK_greater, NoSymbol, NoSymbol,
+ /* 0x35 */ XK_slash, XK_question, NoSymbol, NoSymbol,
+ /* 0x36 */ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x37 */ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x38 */ XK_Alt_L, XK_Meta_L, NoSymbol, NoSymbol,
+ /* 0x39 */ XK_space, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3a */ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3b */ XK_F1, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3c */ XK_F2, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3d */ XK_F3, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3e */ XK_F4, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3f */ XK_F5, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x40 */ XK_F6, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x41 */ XK_F7, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x42 */ XK_F8, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x43 */ XK_F9, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x44 */ XK_F10, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x45 */ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x46 */ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x47 */ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol,
+ /* 0x48 */ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol,
+ /* 0x49 */ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol,
+ /* 0x4a */ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4b */ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol,
+ /* 0x4c */ NoSymbol, XK_KP_5, NoSymbol, NoSymbol,
+ /* 0x4d */ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol,
+ /* 0x4e */ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4f */ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol,
+ /* 0x50 */ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol,
+ /* 0x51 */ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol,
+ /* 0x52 */ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol,
+ /* 0x53 */ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol,
+ /* 0x54 */ XK_Sys_Req, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x55 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x56 */ XK_less, XK_greater, NoSymbol, NoSymbol,
+ /* 0x57 */ XK_F11, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x58 */ XK_F12, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x59 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x60 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x61 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x62 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x63 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x64 */ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x65 */ XK_Control_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x66 */ XK_Pause, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x67 */ XK_Print, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x68 */ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x69 */ XK_Alt_R, XK_Meta_R, NoSymbol, NoSymbol,
+ /* 0x6a */ XK_Break, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6b */ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6c */ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6d */ XK_Menu, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x70 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x71 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x72 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x73 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x74 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x75 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x76 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x77 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x78 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x79 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+};
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86MiscExt.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86MiscExt.c
new file mode 100644
index 000000000..54c0cd510
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86MiscExt.c
@@ -0,0 +1,656 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c,v 1.16 2003/11/03 05:11:02 tsi Exp $ */
+/*
+ * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains the Pointer/Keyboard functions needed by the
+ * XFree86-Misc extension.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define I_NEED_OS2_H
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+
+#ifdef XF86MISC
+#define _XF86MISC_SERVER_
+#include <X11/extensions/xf86misc.h>
+#include "xf86miscproc.h"
+#endif
+
+#define XF86_OS_PRIVS
+#include "xf86_OSlib.h"
+
+#ifdef XINPUT
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "xf86Xinput.h"
+#else
+#include "inputstr.h"
+#endif
+
+#include "xf86OSmouse.h"
+
+#ifdef DEBUG
+# define DEBUG_P(x) ErrorF(x"\n");
+#else
+# define DEBUG_P(x) /**/
+#endif
+
+#ifdef XF86MISC
+
+typedef struct {
+ int type;
+ int baudrate;
+ int samplerate;
+ int resolution;
+ int buttons;
+ Bool em3buttons;
+ int em3timeout;
+ Bool chordmiddle;
+ int flags;
+ char* device;
+ pointer private;
+} mseParamsRec, *mseParamsPtr;
+
+typedef struct {
+ int type;
+ int rate;
+ int delay;
+ int serverNumLock; /* obsolete */
+} kbdParamsRec, *kbdParamsPtr;
+
+/*
+ Sigh...
+
+ The extension should probably be changed to use protocol
+ names instead of ID numbers
+*/
+static struct mouse_map {
+ int mtype;
+ MouseProtocolID proto;
+} m_map[] =
+{
+ { MTYPE_MICROSOFT, PROT_MS },
+ { MTYPE_MOUSESYS, PROT_MSC },
+ { MTYPE_MMSERIES, PROT_MM },
+ { MTYPE_LOGITECH, PROT_LOGI },
+ { MTYPE_LOGIMAN, PROT_LOGIMAN },
+ { MTYPE_MMHIT, PROT_MMHIT },
+ { MTYPE_GLIDEPOINT, PROT_GLIDE },
+ { MTYPE_IMSERIAL, PROT_IMSERIAL },
+ { MTYPE_THINKING, PROT_THINKING },
+ { MTYPE_ACECAD, PROT_ACECAD },
+ { MTYPE_PS_2, PROT_PS2 },
+ { MTYPE_IMPS2, PROT_IMPS2 },
+ { MTYPE_EXPPS2, PROT_EXPPS2 },
+ { MTYPE_THINKINGPS2, PROT_THINKPS2 },
+ { MTYPE_MMANPLUSPS2, PROT_MMPS2 },
+ { MTYPE_GLIDEPOINTPS2, PROT_GLIDEPS2 },
+ { MTYPE_NETPS2, PROT_NETPS2 },
+ { MTYPE_NETSCROLLPS2, PROT_NETSCPS2 },
+ { MTYPE_BUSMOUSE, PROT_BM },
+ { MTYPE_AUTOMOUSE, PROT_AUTO },
+ { MTYPE_SYSMOUSE, PROT_SYSMOUSE },
+ { MTYPE_UNKNOWN, PROT_UNKNOWN }
+};
+
+static int
+MapMseProtoToMisc(MouseProtocolID proto)
+{
+ int i;
+
+ for (i = 0; m_map[i].proto != PROT_UNKNOWN; i++)
+ if (proto == m_map[i].proto)
+ return m_map[i].mtype;
+
+ return MTYPE_UNKNOWN;
+}
+
+static MouseProtocolID
+MapMseMiscToProto(int proto)
+{
+ int i;
+
+ for (i = 0; m_map[i].mtype != MTYPE_UNKNOWN; i++)
+ if (proto == m_map[i].mtype)
+ return m_map[i].proto;
+
+ return PROT_UNKNOWN;
+}
+
+Bool
+MiscExtGetMouseSettings(pointer *mouse, char **devname)
+{
+ mseParamsPtr mseptr;
+
+ DEBUG_P("MiscExtGetMouseSettings");
+
+ mseptr = MiscExtCreateStruct(MISC_POINTER);
+ if (!mseptr)
+ return FALSE;
+
+ {
+ InputInfoPtr pInfo = mseptr->private;
+ MouseDevPtr pMse;
+
+ *devname = xf86FindOptionValue(pInfo->options, "Device");
+ pMse = pInfo->private;
+
+ mseptr->type = MapMseProtoToMisc(pMse->protocolID);
+ mseptr->baudrate = pMse->baudRate;
+ mseptr->samplerate = pMse->sampleRate;
+ mseptr->resolution = pMse->resolution;
+ mseptr->buttons = pMse->buttons;
+ mseptr->em3buttons = pMse->emulate3Buttons;
+ mseptr->em3timeout = pMse->emulate3Timeout;
+ mseptr->chordmiddle = pMse->chordMiddle;
+ mseptr->flags = pMse->mouseFlags;
+ }
+ *mouse = mseptr;
+ return TRUE;
+}
+
+int
+MiscExtGetMouseValue(pointer mouse, MiscExtMseValType valtype)
+{
+ mseParamsPtr mse = mouse;
+
+ DEBUG_P("MiscExtGetMouseValue");
+
+ switch (valtype) {
+ case MISC_MSE_PROTO: return mse->type;
+ case MISC_MSE_BAUDRATE: return mse->baudrate;
+ case MISC_MSE_SAMPLERATE: return mse->samplerate;
+ case MISC_MSE_RESOLUTION: return mse->resolution;
+ case MISC_MSE_BUTTONS: return mse->buttons;
+ case MISC_MSE_EM3BUTTONS: return mse->em3buttons;
+ case MISC_MSE_EM3TIMEOUT: return mse->em3timeout;
+ case MISC_MSE_CHORDMIDDLE: return mse->chordmiddle;
+ case MISC_MSE_FLAGS: return mse->flags;
+ }
+ return 0;
+}
+
+Bool
+MiscExtSetMouseValue(pointer mouse, MiscExtMseValType valtype, int value)
+{
+ mseParamsPtr mse = mouse;
+
+ DEBUG_P("MiscExtSetMouseValue");
+
+ switch (valtype) {
+ case MISC_MSE_PROTO:
+ mse->type = value;
+ return TRUE;
+ case MISC_MSE_BAUDRATE:
+ mse->baudrate = value;
+ return TRUE;
+ case MISC_MSE_SAMPLERATE:
+ mse->samplerate = value;
+ return TRUE;
+ case MISC_MSE_RESOLUTION:
+ mse->resolution = value;
+ return TRUE;
+ case MISC_MSE_BUTTONS:
+ mse->buttons = value;
+ return TRUE;
+ case MISC_MSE_EM3BUTTONS:
+ mse->em3buttons = value;
+ return TRUE;
+ case MISC_MSE_EM3TIMEOUT:
+ mse->em3timeout = value;
+ return TRUE;
+ case MISC_MSE_CHORDMIDDLE:
+ mse->chordmiddle = value;
+ return TRUE;
+ case MISC_MSE_FLAGS:
+ mse->flags = value;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+Bool
+MiscExtSetMouseDevice(pointer mouse, char* device)
+{
+ mseParamsPtr mse = mouse;
+
+ mse->device = device;
+
+ return TRUE;
+}
+
+Bool
+MiscExtGetKbdSettings(pointer *kbd)
+{
+ kbdParamsPtr kbdptr;
+
+ DEBUG_P("MiscExtGetKbdSettings");
+
+ kbdptr = MiscExtCreateStruct(MISC_KEYBOARD);
+ if (!kbdptr)
+ return FALSE;
+ kbdptr->type = xf86Info.kbdType;
+ kbdptr->rate = xf86Info.kbdRate;
+ kbdptr->delay = xf86Info.kbdDelay;
+ *kbd = kbdptr;
+ return TRUE;
+}
+
+int
+MiscExtGetKbdValue(pointer keyboard, MiscExtKbdValType valtype)
+{
+ kbdParamsPtr kbd = keyboard;
+
+ DEBUG_P("MiscExtGetKbdValue");
+ switch (valtype) {
+ case MISC_KBD_TYPE: return kbd->type;
+ case MISC_KBD_RATE: return kbd->rate;
+ case MISC_KBD_DELAY: return kbd->delay;
+ case MISC_KBD_SERVNUMLOCK: return 0;
+ }
+ return 0;
+}
+
+Bool
+MiscExtSetKbdValue(pointer keyboard, MiscExtKbdValType valtype, int value)
+{
+ kbdParamsPtr kbd = keyboard;
+
+ DEBUG_P("MiscExtSetKbdValue");
+ switch (valtype) {
+ case MISC_KBD_TYPE:
+ kbd->type = value;
+ return TRUE;
+ case MISC_KBD_RATE:
+ kbd->rate = value;
+ return TRUE;
+ case MISC_KBD_DELAY:
+ kbd->delay = value;
+ return TRUE;
+ case MISC_KBD_SERVNUMLOCK:
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static void
+MiscExtClientStateCallback(CallbackListPtr *callbacks,
+ pointer data, pointer args)
+{
+ NewClientInfoRec *clientinfo = (NewClientInfoRec*)args;
+
+ if (clientinfo->client == xf86Info.grabInfo.override &&
+ clientinfo->client->clientState == ClientStateGone) {
+ xf86Info.grabInfo.override = NULL;
+ xf86Info.grabInfo.disabled = 0;
+ DeleteCallback(&ClientStateCallback, MiscExtClientStateCallback, NULL);
+ }
+}
+
+#define MiscExtGrabStateSuccess 0 /* No errors */
+#define MiscExtGrabStateLocked 1 /* A client already requested that
+ * grabs cannot be removed/killed */
+#define MiscExtGrabStateAlready 2 /* Request for enabling/disabling
+ * grab removeal/kill already done */
+int
+MiscExtSetGrabKeysState(ClientPtr client, int state)
+{
+ DEBUG_P("MiscExtSetGrabKeysState");
+
+ if (xf86Info.grabInfo.override == NULL ||
+ xf86Info.grabInfo.override == client) {
+ if (state == 0 && xf86Info.grabInfo.disabled == 0) {
+ xf86Info.grabInfo.disabled = 1;
+ AddCallback(&ClientStateCallback,
+ MiscExtClientStateCallback, NULL);
+ xf86Info.grabInfo.override = client;
+ }
+ else if (state == 1 && xf86Info.grabInfo.disabled == 1) {
+ xf86Info.grabInfo.disabled = 0;
+ DeleteCallback(&ClientStateCallback,
+ MiscExtClientStateCallback, NULL);
+ xf86Info.grabInfo.override = NULL;
+ }
+ else
+ return MiscExtGrabStateAlready;
+
+ return MiscExtGrabStateSuccess;
+ }
+
+ return MiscExtGrabStateLocked;
+}
+
+pointer
+MiscExtCreateStruct(MiscExtStructType mse_or_kbd)
+{
+ DEBUG_P("MiscExtCreateStruct");
+
+ switch (mse_or_kbd) {
+ case MISC_POINTER:
+ {
+ mseParamsPtr mseptr;
+ InputInfoPtr pInfo = xf86InputDevs;
+
+ while (pInfo) {
+ if (xf86IsCorePointer(pInfo->dev))
+ break;
+ pInfo = pInfo->next;
+ }
+ if (!pInfo)
+ return NULL;
+
+ mseptr = xcalloc(sizeof(mseParamsRec),1);
+ if (mseptr)
+ mseptr->private = pInfo;
+ return mseptr;
+ }
+ case MISC_KEYBOARD:
+ return xcalloc(sizeof(kbdParamsRec),1);
+ }
+ return 0;
+}
+
+void
+MiscExtDestroyStruct(pointer structure, MiscExtStructType mse_or_kbd)
+{
+ DEBUG_P("MiscExtDestroyStruct");
+
+ switch (mse_or_kbd) {
+ case MISC_POINTER:
+ case MISC_KEYBOARD:
+ xfree(structure);
+ }
+}
+
+static Bool
+MiscExtAuthorizeDevice(InputInfoPtr pInfo, char *device)
+{
+ Bool authorized = FALSE;
+ char *elem;
+ struct stat dev, dev_list;
+ const char *olddev = xf86FindOptionValue(pInfo->options, "Device");
+
+ if (stat(device,&dev))
+ return FALSE;
+
+ if (!S_ISCHR(dev.st_mode))
+ return FALSE;
+
+ if (!stat(olddev,&dev_list)) {
+ if (dev_list.st_dev == dev.st_dev
+ && dev_list.st_ino == dev.st_ino) {
+ authorized = TRUE;
+ }
+ }
+
+ if (!authorized) {
+ char *path;
+
+ if (!xf86InputDeviceList
+ || (path = strdup(xf86InputDeviceList)) == NULL)
+ return FALSE;
+
+ elem = strtok(path,",");
+
+ while (elem) {
+
+ if (!stat(elem,&dev_list)) {
+ if (dev_list.st_dev == dev.st_dev
+ && dev_list.st_ino == dev.st_ino) {
+ authorized = TRUE;
+ break;
+
+ }
+ }
+ elem = strtok(NULL,",");
+ }
+ xfree(path);
+ }
+#if 0
+ ErrorF("AUTHORIZED: %s\n",authorized?"Yes":"No");
+#endif
+ return (authorized);
+}
+
+MiscExtReturn
+MiscExtApply(pointer structure, MiscExtStructType mse_or_kbd)
+{
+ DEBUG_P("MiscExtApply");
+
+ if (mse_or_kbd == MISC_POINTER) {
+ Bool protoChanged = FALSE;
+ int oldflags;
+ Bool reopen = FALSE;
+ MouseProtocolID newProtocol;
+ mseParamsPtr mse = structure;
+ InputInfoPtr pInfo;
+ MouseDevPtr pMse;
+#ifdef XFree86LOADER
+ pointer xf86MouseProtocolIDToName
+ = LoaderSymbol("xf86MouseProtocolIDToName");
+ if (!xf86MouseProtocolIDToName)
+ return MISC_RET_NOMODULE;
+#endif
+ if (mse->type < MTYPE_MICROSOFT
+ || ( mse->type > MTYPE_EXPPS2
+ && (mse->type!=MTYPE_OSMOUSE && mse->type!=MTYPE_XQUEUE)))
+ return MISC_RET_BADMSEPROTO;
+#ifdef OSMOUSE_ONLY
+ if (mse->type != MTYPE_OSMOUSE)
+ return MISC_RET_BADMSEPROTO;
+#else
+ if (mse->type == MTYPE_XQUEUE)
+ return MISC_RET_BADMSEPROTO;
+ if (mse->type == MTYPE_OSMOUSE)
+ return MISC_RET_BADMSEPROTO;
+#endif /* OSMOUSE_ONLY */
+
+ if (mse->em3timeout < 0)
+ return MISC_RET_BADVAL;
+
+ if (mse->type == MTYPE_LOGIMAN
+ && !(mse->baudrate == 0
+ || mse->baudrate == 1200
+ || mse->baudrate == 9600))
+ return MISC_RET_BADBAUDRATE;
+ if (mse->type == MTYPE_LOGIMAN && mse->samplerate)
+ return MISC_RET_BADCOMBO;
+
+ if (mse->flags & MF_REOPEN) {
+ reopen = TRUE;
+ mse->flags &= ~MF_REOPEN;
+ }
+ if (mse->type != MTYPE_OSMOUSE
+ && mse->type != MTYPE_XQUEUE
+ && mse->type != MTYPE_PS_2
+ && mse->type != MTYPE_BUSMOUSE
+ && mse->type != MTYPE_IMPS2
+ && mse->type != MTYPE_THINKINGPS2
+ && mse->type != MTYPE_MMANPLUSPS2
+ && mse->type != MTYPE_GLIDEPOINTPS2
+ && mse->type != MTYPE_NETPS2
+ && mse->type != MTYPE_NETSCROLLPS2
+ && mse->type != MTYPE_SYSMOUSE)
+ {
+ if (mse->baudrate % 1200 != 0
+ || (mse->baudrate != 0 && mse->baudrate < 1200)
+ || mse->baudrate > 9600)
+ return MISC_RET_BADBAUDRATE;
+ }
+ if ((mse->flags & (MF_CLEAR_DTR|MF_CLEAR_RTS))
+ && (mse->type != MTYPE_MOUSESYS))
+ return MISC_RET_BADFLAGS;
+
+ if (mse->type != MTYPE_OSMOUSE
+ && mse->type != MTYPE_XQUEUE
+ && mse->type != MTYPE_BUSMOUSE)
+ {
+ if (mse->samplerate < 0)
+ return MISC_RET_BADVAL;
+ }
+
+ if (mse->resolution < 0)
+ return MISC_RET_BADVAL;
+ if (mse->chordmiddle)
+ {
+ if (mse->em3buttons || !(mse->type == MTYPE_MICROSOFT
+ || mse->type == MTYPE_LOGIMAN) )
+ return MISC_RET_BADCOMBO;
+ }
+
+ /* XXX - This still needs work */
+
+ pInfo = mse->private;
+ pMse = pInfo->private;
+ oldflags = pMse->mouseFlags;
+
+ newProtocol = MapMseMiscToProto(mse->type);
+ protoChanged = pMse->protocolID != newProtocol;
+ if (protoChanged
+ || pMse->baudRate != mse->baudrate
+ || pMse->sampleRate != mse->samplerate
+ || pMse->resolution != mse->resolution
+ || pMse->mouseFlags != mse->flags)
+ reopen = TRUE;
+
+ if (mse->device)
+ reopen = TRUE;
+
+ if (reopen)
+ (pMse->device->deviceProc)(pMse->device, DEVICE_CLOSE);
+
+ pMse->protocolID = newProtocol;
+ pMse->baudRate = mse->baudrate;
+ pMse->sampleRate = mse->samplerate;
+ pMse->resolution = mse->resolution;
+ pMse->buttons = mse->buttons;
+ pMse->emulate3Buttons = mse->em3buttons;
+ pMse->emulate3Timeout = mse->em3timeout;
+ pMse->chordMiddle = mse->chordmiddle;
+ pMse->mouseFlags = mse->flags;
+
+#ifdef XFree86LOADER
+ pMse->protocol = ((const char *(*)(MouseProtocolID))
+ xf86MouseProtocolIDToName)(pMse->protocolID);
+#else
+ pMse->protocol = xf86MouseProtocolIDToName(pMse->protocolID);
+#endif
+
+ if (mse->device) {
+ if (MiscExtAuthorizeDevice(pInfo, mse->device)) {
+ xf86ReplaceStrOption(pInfo->options, "Device", mse->device);
+ } else {
+ return MISC_RET_BADVAL;
+ }
+ }
+
+ if (reopen) {
+ /* Only if protocol is changed explicitely disable auto detect */
+ if (protoChanged)
+ pMse->autoProbe = FALSE;
+ (pMse->device->deviceProc)(pMse->device, DEVICE_ON);
+ }
+ /* Set pInfo->options too */
+
+ if ((oldflags & MF_CLEAR_DTR) != (pMse->mouseFlags & MF_CLEAR_DTR))
+ xf86ReplaceBoolOption(pInfo->options, "ClearDTR",
+ pMse->mouseFlags | MF_CLEAR_DTR);
+ if ((oldflags & MF_CLEAR_RTS) != (pMse->mouseFlags & MF_CLEAR_RTS))
+ xf86ReplaceBoolOption(pInfo->options, "ClearRTS",
+ pMse->mouseFlags | MF_CLEAR_RTS);
+ }
+ if (mse_or_kbd == MISC_KEYBOARD) {
+ kbdParamsPtr kbd = structure;
+
+ if (kbd->rate < 0)
+ return MISC_RET_BADVAL;
+ if (kbd->delay < 0)
+ return MISC_RET_BADVAL;
+ if (kbd->type < KTYPE_UNKNOWN || kbd->type > KTYPE_XQUEUE)
+ return MISC_RET_BADKBDTYPE;
+
+ if (xf86Info.kbdRate!=kbd->rate || xf86Info.kbdDelay!=kbd->delay) {
+ char rad;
+
+ xf86Info.kbdRate = kbd->rate;
+ xf86Info.kbdDelay = kbd->delay;
+ if (xf86Info.kbdDelay <= 375) rad = 0x00;
+ else if (xf86Info.kbdDelay <= 625) rad = 0x20;
+ else if (xf86Info.kbdDelay <= 875) rad = 0x40;
+ else rad = 0x60;
+
+ if (xf86Info.kbdRate <= 2) rad |= 0x1F;
+ else if (xf86Info.kbdRate >= 30) rad |= 0x00;
+ else rad |= ((58/xf86Info.kbdRate)-2);
+
+ xf86SetKbdRepeat(rad);
+ }
+#if 0 /* Not done yet */
+ xf86Info.kbdType = kbd->kbdtype;
+#endif
+ }
+ return MISC_RET_SUCCESS;
+}
+
+Bool
+MiscExtGetFilePaths(const char **configfile, const char **modulepath,
+ const char **logfile)
+{
+ DEBUG_P("MiscExtGetFilePaths");
+
+ *configfile = xf86ConfigFile;
+ *modulepath = xf86ModulePath;
+ *logfile = xf86LogFile;
+
+ return TRUE;
+}
+
+int
+MiscExtPassMessage(int scrnIndex, const char *msgtype, const char *msgval,
+ char **retstr)
+{
+ ScrnInfoPtr pScr = xf86Screens[scrnIndex];
+
+ DEBUG_P("MiscExtPassMessage");
+
+ if (*pScr->HandleMessage == NULL)
+ return BadImplementation;
+ return (*pScr->HandleMessage)(scrnIndex, msgtype, msgval, retstr);
+}
+
+#endif /* XF86MISC */
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Mode.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Mode.c
new file mode 100644
index 000000000..2abbd2213
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Mode.c
@@ -0,0 +1,2185 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Mode.c,v 1.7 2005/07/03 08:53:42 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Mode.c,v 1.69 2003/10/08 14:58:28 dawes Exp $ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * Authors: Dirk Hohndel <hohndel@XFree86.Org>
+ * David Dawes <dawes@XFree86.Org>
+ * Marc La France <tsi@XFree86.Org>
+ * ... and others
+ *
+ * This file includes helper functions for mode related things.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "servermd.h"
+#include "mibank.h"
+#include "globals.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86DDC.h"
+
+/*
+ * xf86GetNearestClock --
+ * Find closest clock to given frequency (in kHz). This assumes the
+ * number of clocks is greater than zero.
+ */
+int
+xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
+ int DivFactor, int MulFactor, int *divider)
+{
+ int nearestClock = 0, nearestDiv = 1;
+ int minimumGap = abs(freq - scrp->clock[0]);
+ int i, j, k, gap;
+
+ if (allowDiv2)
+ k = 2;
+ else
+ k = 1;
+
+ /* Must set this here in case the best match is scrp->clock[0] */
+ if (divider != NULL)
+ *divider = 0;
+
+ for (i = 0; i < scrp->numClocks; i++) {
+ for (j = 1; j <= k; j++) {
+ gap = abs((freq * j) - ((scrp->clock[i] * DivFactor) / MulFactor));
+ if ((gap < minimumGap) ||
+ ((gap == minimumGap) && (j < nearestDiv))) {
+ minimumGap = gap;
+ nearestClock = i;
+ nearestDiv = j;
+ if (divider != NULL)
+ *divider = (j - 1) * V_CLKDIV2;
+ }
+ }
+ }
+ return nearestClock;
+}
+
+/*
+ * xf86ModeStatusToString
+ *
+ * Convert a ModeStatus value to a printable message
+ */
+
+const char *
+xf86ModeStatusToString(ModeStatus status)
+{
+ switch (status) {
+ case MODE_OK:
+ return "Mode OK";
+ case MODE_HSYNC:
+ return "hsync out of range";
+ case MODE_VSYNC:
+ return "vrefresh out of range";
+ case MODE_H_ILLEGAL:
+ return "illegal horizontal timings";
+ case MODE_V_ILLEGAL:
+ return "illegal vertical timings";
+ case MODE_BAD_WIDTH:
+ return "width requires unsupported line pitch";
+ case MODE_NOMODE:
+ return "no mode of this name";
+ case MODE_NO_INTERLACE:
+ return "interlace mode not supported";
+ case MODE_NO_DBLESCAN:
+ return "doublescan mode not supported";
+ case MODE_NO_VSCAN:
+ return "multiscan mode not supported";
+ case MODE_MEM:
+ return "insufficient memory for mode";
+ case MODE_VIRTUAL_X:
+ return "width too large for virtual size";
+ case MODE_VIRTUAL_Y:
+ return "height too large for virtual size";
+ case MODE_MEM_VIRT:
+ return "insufficient memory given virtual size";
+ case MODE_NOCLOCK:
+ return "no clock available for mode";
+ case MODE_CLOCK_HIGH:
+ return "mode clock too high";
+ case MODE_CLOCK_LOW:
+ return "mode clock too low";
+ case MODE_CLOCK_RANGE:
+ return "bad mode clock/interlace/doublescan";
+ case MODE_BAD_HVALUE:
+ return "horizontal timing out of range";
+ case MODE_BAD_VVALUE:
+ return "vertical timing out of range";
+ case MODE_BAD_VSCAN:
+ return "VScan value out of range";
+ case MODE_HSYNC_NARROW:
+ return "horizontal sync too narrow";
+ case MODE_HSYNC_WIDE:
+ return "horizontal sync too wide";
+ case MODE_HBLANK_NARROW:
+ return "horizontal blanking too narrow";
+ case MODE_HBLANK_WIDE:
+ return "horizontal blanking too wide";
+ case MODE_VSYNC_NARROW:
+ return "vertical sync too narrow";
+ case MODE_VSYNC_WIDE:
+ return "vertical sync too wide";
+ case MODE_VBLANK_NARROW:
+ return "vertical blanking too narrow";
+ case MODE_VBLANK_WIDE:
+ return "vertical blanking too wide";
+ case MODE_PANEL:
+ return "exceeds panel dimensions";
+ case MODE_INTERLACE_WIDTH:
+ return "width too large for interlaced mode";
+ case MODE_ONE_WIDTH:
+ return "all modes must have the same width";
+ case MODE_ONE_HEIGHT:
+ return "all modes must have the same height";
+ case MODE_ONE_SIZE:
+ return "all modes must have the same resolution";
+ case MODE_BAD:
+ return "unknown reason";
+ case MODE_ERROR:
+ return "internal error";
+ default:
+ return "unknown";
+ }
+}
+
+/*
+ * xf86ShowClockRanges() -- Print the clock ranges allowed
+ * and the clock values scaled by ClockMulFactor and ClockDivFactor
+ */
+void
+xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges)
+{
+ ClockRangePtr cp;
+ int MulFactor = 1;
+ int DivFactor = 1;
+ int i, j;
+ int scaledClock;
+
+ for (cp = clockRanges; cp != NULL; cp = cp->next) {
+ DivFactor = max(1, cp->ClockDivFactor);
+ MulFactor = max(1, cp->ClockMulFactor);
+ if (scrp->progClock) {
+ if (cp->minClock) {
+ if (cp->maxClock) {
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Clock range: %6.2f to %6.2f MHz\n",
+ (double)cp->minClock / 1000.0,
+ (double)cp->maxClock / 1000.0);
+ } else {
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Minimum clock: %6.2f MHz\n",
+ (double)cp->minClock / 1000.0);
+ }
+ } else {
+ if (cp->maxClock) {
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Maximum clock: %6.2f MHz\n",
+ (double)cp->maxClock / 1000.0);
+ }
+ }
+ } else if (DivFactor > 1 || MulFactor > 1) {
+ j = 0;
+ for (i = 0; i < scrp->numClocks; i++) {
+ scaledClock = (scrp->clock[i] * DivFactor) / MulFactor;
+ if (scaledClock >= cp->minClock && scaledClock <= cp->maxClock) {
+ if ((j % 8) == 0) {
+ if (j > 0)
+ xf86ErrorF("\n");
+ xf86DrvMsg(scrp->scrnIndex, X_INFO, "scaled clocks:");
+ }
+ xf86ErrorF(" %6.2f", (double)scaledClock / 1000.0);
+ j++;
+ }
+ }
+ xf86ErrorF("\n");
+ }
+ }
+}
+
+
+/*
+ * xf86FindClockRangeForMode() [... like the name says ...]
+ */
+static ClockRangePtr
+xf86FindClockRangeForMode(ClockRangePtr clockRanges, DisplayModePtr p)
+{
+ ClockRangePtr cp;
+
+ for (cp = clockRanges; ; cp = cp->next)
+ if (!cp ||
+ ((p->Clock >= cp->minClock) &&
+ (p->Clock <= cp->maxClock) &&
+ (cp->interlaceAllowed || !(p->Flags & V_INTERLACE)) &&
+ (cp->doubleScanAllowed ||
+ ((p->VScan <= 1) && !(p->Flags & V_DBLSCAN)))))
+ return cp;
+}
+
+
+/*
+ * xf86HandleBuiltinMode() - handles built-in modes
+ */
+static ModeStatus
+xf86HandleBuiltinMode(ScrnInfoPtr scrp,
+ DisplayModePtr p,
+ DisplayModePtr modep,
+ ClockRangePtr clockRanges,
+ Bool allowDiv2)
+{
+ ClockRangePtr cp;
+ int extraFlags = 0;
+ int MulFactor = 1;
+ int DivFactor = 1;
+ int clockIndex;
+
+ /* Reject previously rejected modes */
+ if (p->status != MODE_OK)
+ return p->status;
+
+ /* Reject previously considered modes */
+ if (p->prev)
+ return MODE_NOMODE;
+
+ if ((p->type & M_T_CLOCK_C) == M_T_CLOCK_C) {
+ /* Check clock is in range */
+ cp = xf86FindClockRangeForMode(clockRanges, p);
+ if (cp == NULL){
+ modep->type = p->type;
+ p->status = MODE_CLOCK_RANGE;
+ return MODE_CLOCK_RANGE;
+ }
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ if (!scrp->progClock) {
+ clockIndex = xf86GetNearestClock(scrp, p->Clock, allowDiv2,
+ cp->ClockDivFactor,
+ cp->ClockMulFactor, &extraFlags);
+ modep->Clock = (scrp->clock[clockIndex] * DivFactor)
+ / MulFactor;
+ modep->ClockIndex = clockIndex;
+ modep->SynthClock = scrp->clock[clockIndex];
+ if (extraFlags & V_CLKDIV2) {
+ modep->Clock /= 2;
+ modep->SynthClock /= 2;
+ }
+ } else {
+ modep->Clock = p->Clock;
+ modep->ClockIndex = -1;
+ modep->SynthClock = (modep->Clock * MulFactor)
+ / DivFactor;
+ }
+ modep->PrivFlags = cp->PrivFlags;
+ } else {
+ if(!scrp->progClock) {
+ modep->Clock = p->Clock;
+ modep->ClockIndex = p->ClockIndex;
+ modep->SynthClock = p->SynthClock;
+ } else {
+ modep->Clock = p->Clock;
+ modep->ClockIndex = -1;
+ modep->SynthClock = p->SynthClock;
+ }
+ modep->PrivFlags = p->PrivFlags;
+ }
+ modep->type = p->type;
+ modep->HDisplay = p->HDisplay;
+ modep->HSyncStart = p->HSyncStart;
+ modep->HSyncEnd = p->HSyncEnd;
+ modep->HTotal = p->HTotal;
+ modep->HSkew = p->HSkew;
+ modep->VDisplay = p->VDisplay;
+ modep->VSyncStart = p->VSyncStart;
+ modep->VSyncEnd = p->VSyncEnd;
+ modep->VTotal = p->VTotal;
+ modep->VScan = p->VScan;
+ modep->Flags = p->Flags | extraFlags;
+ modep->CrtcHDisplay = p->CrtcHDisplay;
+ modep->CrtcHBlankStart = p->CrtcHBlankStart;
+ modep->CrtcHSyncStart = p->CrtcHSyncStart;
+ modep->CrtcHSyncEnd = p->CrtcHSyncEnd;
+ modep->CrtcHBlankEnd = p->CrtcHBlankEnd;
+ modep->CrtcHTotal = p->CrtcHTotal;
+ modep->CrtcHSkew = p->CrtcHSkew;
+ modep->CrtcVDisplay = p->CrtcVDisplay;
+ modep->CrtcVBlankStart = p->CrtcVBlankStart;
+ modep->CrtcVSyncStart = p->CrtcVSyncStart;
+ modep->CrtcVSyncEnd = p->CrtcVSyncEnd;
+ modep->CrtcVBlankEnd = p->CrtcVBlankEnd;
+ modep->CrtcVTotal = p->CrtcVTotal;
+ modep->CrtcHAdjusted = p->CrtcHAdjusted;
+ modep->CrtcVAdjusted = p->CrtcVAdjusted;
+ modep->HSync = p->HSync;
+ modep->VRefresh = p->VRefresh;
+ modep->Private = p->Private;
+ modep->PrivSize = p->PrivSize;
+
+ p->prev = modep;
+
+ return MODE_OK;
+}
+
+static double
+ModeHSync(DisplayModePtr mode)
+{
+ double hsync = 0.0;
+
+ if (mode->HSync > 0.0)
+ hsync = mode->HSync;
+ else if (mode->HTotal > 0)
+ hsync = (float)mode->Clock / (float)mode->HTotal;
+
+ return hsync;
+}
+
+static double
+ModeVRefresh(DisplayModePtr mode)
+{
+ double refresh = 0.0;
+
+ if (mode->VRefresh > 0.0)
+ refresh = mode->VRefresh;
+ else if (mode->HTotal > 0 && mode->VTotal > 0) {
+ refresh = mode->Clock * 1000.0 / mode->HTotal / mode->VTotal;
+ if (mode->Flags & V_INTERLACE)
+ refresh *= 2.0;
+ if (mode->Flags & V_DBLSCAN)
+ refresh /= 2.0;
+ if (mode->VScan > 1)
+ refresh /= (float)(mode->VScan);
+ }
+ return refresh;
+}
+
+/*
+ * xf86LookupMode
+ *
+ * This function returns a mode from the given list which matches the
+ * given name. When multiple modes with the same name are available,
+ * the method of picking the matching mode is determined by the
+ * strategy selected.
+ *
+ * This function takes the following parameters:
+ * scrp ScrnInfoPtr
+ * modep pointer to the returned mode, which must have the name
+ * field filled in.
+ * clockRanges a list of clock ranges. This is optional when all the
+ * modes are built-in modes.
+ * strategy how to decide which mode to use from multiple modes with
+ * the same name
+ *
+ * In addition, the following fields from the ScrnInfoRec are used:
+ * modePool the list of monitor modes compatible with the driver
+ * clocks a list of discrete clocks
+ * numClocks number of discrete clocks
+ * progClock clock is programmable
+ *
+ * If a mode was found, its values are filled in to the area pointed to
+ * by modep, If a mode was not found the return value indicates the
+ * reason.
+ */
+
+ModeStatus
+xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
+ ClockRangePtr clockRanges, LookupModeFlags strategy)
+{
+ DisplayModePtr p, bestMode = NULL;
+ ClockRangePtr cp;
+ int i, k, gap, minimumGap = CLOCK_TOLERANCE + 1;
+ double refresh, bestRefresh = 0.0;
+ Bool found = FALSE;
+ int extraFlags = 0;
+ int clockIndex = -1;
+ int MulFactor = 1;
+ int DivFactor = 1;
+ int ModePrivFlags = 0;
+ ModeStatus status = MODE_NOMODE;
+ Bool allowDiv2 = (strategy & LOOKUP_CLKDIV2) != 0;
+ Bool haveBuiltin;
+
+ strategy &= ~(LOOKUP_CLKDIV2 | LOOKUP_OPTIONAL_TOLERANCES);
+
+ /* Some sanity checking */
+ if (scrp == NULL || scrp->modePool == NULL ||
+ (!scrp->progClock && scrp->numClocks == 0)) {
+ ErrorF("xf86LookupMode: called with invalid scrnInfoRec\n");
+ return MODE_ERROR;
+ }
+ if (modep == NULL || modep->name == NULL) {
+ ErrorF("xf86LookupMode: called with invalid modep\n");
+ return MODE_ERROR;
+ }
+ for (cp = clockRanges; cp != NULL; cp = cp->next) {
+ /* DivFactor and MulFactor must be > 0 */
+ cp->ClockDivFactor = max(1, cp->ClockDivFactor);
+ cp->ClockMulFactor = max(1, cp->ClockMulFactor);
+ }
+
+ haveBuiltin = FALSE;
+ /* Scan the mode pool for matching names */
+ for (p = scrp->modePool; p != NULL; p = p->next) {
+ if (strcmp(p->name, modep->name) == 0) {
+ /*
+ * Requested mode is a built-in mode. Don't let the user
+ * override it.
+ * Since built-in modes always come before user specified
+ * modes it will always be found first.
+ */
+ if (p->type & M_T_BUILTIN) {
+ haveBuiltin = TRUE;
+ }
+
+ if (haveBuiltin && !(p->type & M_T_BUILTIN))
+ continue;
+
+ /* Skip over previously rejected modes */
+ if (p->status != MODE_OK) {
+ if (!found)
+ status = p->status;
+ continue;
+ }
+
+ /* Skip over previously considered modes */
+ if (p->prev)
+ continue;
+
+ if (p->type & M_T_BUILTIN) {
+ return xf86HandleBuiltinMode(scrp, p,modep, clockRanges,
+ allowDiv2);
+ }
+
+ /* Check clock is in range */
+ cp = xf86FindClockRangeForMode(clockRanges, p);
+ if (cp == NULL) {
+ /*
+ * XXX Could do more here to provide a more detailed
+ * reason for not finding a mode.
+ */
+ p->status = MODE_CLOCK_RANGE;
+ if (!found)
+ status = MODE_CLOCK_RANGE;
+ continue;
+ }
+
+ /*
+ * If programmable clock and strategy is not LOOKUP_BEST_REFRESH,
+ * the required mode has been found, otherwise record the refresh
+ * and continue looking.
+ */
+ if (scrp->progClock) {
+ found = TRUE;
+ if (strategy != LOOKUP_BEST_REFRESH) {
+ bestMode = p;
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ break;
+ }
+ refresh = ModeVRefresh(p);
+ if (p->Flags & V_INTERLACE)
+ refresh /= INTERLACE_REFRESH_WEIGHT;
+ if (refresh > bestRefresh) {
+ bestMode = p;
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ bestRefresh = refresh;
+ }
+ continue;
+ }
+
+ /*
+ * Clock is in range, so if it is not a programmable clock, find
+ * a matching clock.
+ */
+
+ i = xf86GetNearestClock(scrp, p->Clock, allowDiv2,
+ cp->ClockDivFactor, cp->ClockMulFactor, &k);
+ /*
+ * If the clock is too far from the requested clock, this
+ * mode is no good.
+ */
+ if (k & V_CLKDIV2)
+ gap = abs((p->Clock * 2) -
+ ((scrp->clock[i] * cp->ClockDivFactor) / cp->ClockMulFactor));
+ else
+ gap = abs(p->Clock -
+ ((scrp->clock[i] * cp->ClockDivFactor) / cp->ClockMulFactor));
+ if (gap > minimumGap) {
+ p->status = MODE_NOCLOCK;
+ if (!found)
+ status = MODE_NOCLOCK;
+ continue;
+ }
+ found = TRUE;
+
+ if (strategy == LOOKUP_BEST_REFRESH) {
+ refresh = ModeVRefresh(p);
+ if (p->Flags & V_INTERLACE)
+ refresh /= INTERLACE_REFRESH_WEIGHT;
+ if (refresh > bestRefresh) {
+ bestMode = p;
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ extraFlags = k;
+ clockIndex = i;
+ bestRefresh = refresh;
+ }
+ continue;
+ }
+ if (strategy == LOOKUP_CLOSEST_CLOCK) {
+ if (gap < minimumGap) {
+ bestMode = p;
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ extraFlags = k;
+ clockIndex = i;
+ minimumGap = gap;
+ }
+ continue;
+ }
+ /*
+ * If strategy is neither LOOKUP_BEST_REFRESH or
+ * LOOKUP_CLOSEST_CLOCK the required mode has been found.
+ */
+ bestMode = p;
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ extraFlags = k;
+ clockIndex = i;
+ break;
+ }
+ }
+ if (!found || bestMode == NULL)
+ return status;
+
+ /* Fill in the mode parameters */
+ if (scrp->progClock) {
+ modep->Clock = bestMode->Clock;
+ modep->ClockIndex = -1;
+ modep->SynthClock = (modep->Clock * MulFactor) / DivFactor;
+ } else {
+ modep->Clock = (scrp->clock[clockIndex] * DivFactor) / MulFactor;
+ modep->ClockIndex = clockIndex;
+ modep->SynthClock = scrp->clock[clockIndex];
+ if (extraFlags & V_CLKDIV2) {
+ modep->Clock /= 2;
+ modep->SynthClock /= 2;
+ }
+ }
+ modep->type = bestMode->type;
+ modep->PrivFlags = ModePrivFlags;
+ modep->HDisplay = bestMode->HDisplay;
+ modep->HSyncStart = bestMode->HSyncStart;
+ modep->HSyncEnd = bestMode->HSyncEnd;
+ modep->HTotal = bestMode->HTotal;
+ modep->HSkew = bestMode->HSkew;
+ modep->VDisplay = bestMode->VDisplay;
+ modep->VSyncStart = bestMode->VSyncStart;
+ modep->VSyncEnd = bestMode->VSyncEnd;
+ modep->VTotal = bestMode->VTotal;
+ modep->VScan = bestMode->VScan;
+ modep->Flags = bestMode->Flags | extraFlags;
+ modep->CrtcHDisplay = bestMode->CrtcHDisplay;
+ modep->CrtcHBlankStart = bestMode->CrtcHBlankStart;
+ modep->CrtcHSyncStart = bestMode->CrtcHSyncStart;
+ modep->CrtcHSyncEnd = bestMode->CrtcHSyncEnd;
+ modep->CrtcHBlankEnd = bestMode->CrtcHBlankEnd;
+ modep->CrtcHTotal = bestMode->CrtcHTotal;
+ modep->CrtcHSkew = bestMode->CrtcHSkew;
+ modep->CrtcVDisplay = bestMode->CrtcVDisplay;
+ modep->CrtcVBlankStart = bestMode->CrtcVBlankStart;
+ modep->CrtcVSyncStart = bestMode->CrtcVSyncStart;
+ modep->CrtcVSyncEnd = bestMode->CrtcVSyncEnd;
+ modep->CrtcVBlankEnd = bestMode->CrtcVBlankEnd;
+ modep->CrtcVTotal = bestMode->CrtcVTotal;
+ modep->CrtcHAdjusted = bestMode->CrtcHAdjusted;
+ modep->CrtcVAdjusted = bestMode->CrtcVAdjusted;
+ modep->HSync = bestMode->HSync;
+ modep->VRefresh = bestMode->VRefresh;
+ modep->Private = bestMode->Private;
+ modep->PrivSize = bestMode->PrivSize;
+
+ bestMode->prev = modep;
+
+ return MODE_OK;
+}
+
+
+/*
+ * xf86SetModeCrtc
+ *
+ * Initialises the Crtc parameters for a mode. The initialisation includes
+ * adjustments for interlaced and double scan modes.
+ */
+static void
+xf86SetModeCrtc(DisplayModePtr p, int adjustFlags)
+{
+ if ((p == NULL) || ((p->type & M_T_CRTC_C) == M_T_BUILTIN))
+ return;
+
+ p->CrtcHDisplay = p->HDisplay;
+ p->CrtcHSyncStart = p->HSyncStart;
+ p->CrtcHSyncEnd = p->HSyncEnd;
+ p->CrtcHTotal = p->HTotal;
+ p->CrtcHSkew = p->HSkew;
+ p->CrtcVDisplay = p->VDisplay;
+ p->CrtcVSyncStart = p->VSyncStart;
+ p->CrtcVSyncEnd = p->VSyncEnd;
+ p->CrtcVTotal = p->VTotal;
+ if (p->Flags & V_INTERLACE) {
+ if (adjustFlags & INTERLACE_HALVE_V) {
+ p->CrtcVDisplay /= 2;
+ p->CrtcVSyncStart /= 2;
+ p->CrtcVSyncEnd /= 2;
+ p->CrtcVTotal /= 2;
+ }
+ /* Force interlaced modes to have an odd VTotal */
+ /* maybe we should only do this when INTERLACE_HALVE_V is set? */
+ p->CrtcVTotal |= 1;
+ }
+
+ if (p->Flags & V_DBLSCAN) {
+ p->CrtcVDisplay *= 2;
+ p->CrtcVSyncStart *= 2;
+ p->CrtcVSyncEnd *= 2;
+ p->CrtcVTotal *= 2;
+ }
+ if (p->VScan > 1) {
+ p->CrtcVDisplay *= p->VScan;
+ p->CrtcVSyncStart *= p->VScan;
+ p->CrtcVSyncEnd *= p->VScan;
+ p->CrtcVTotal *= p->VScan;
+ }
+ p->CrtcHAdjusted = FALSE;
+ p->CrtcVAdjusted = FALSE;
+
+ /*
+ * XXX
+ *
+ * The following is taken from VGA, but applies to other cores as well.
+ */
+ p->CrtcVBlankStart = min(p->CrtcVSyncStart, p->CrtcVDisplay);
+ p->CrtcVBlankEnd = max(p->CrtcVSyncEnd, p->CrtcVTotal);
+ if ((p->CrtcVBlankEnd - p->CrtcVBlankStart) >= 127) {
+ /*
+ * V Blanking size must be < 127.
+ * Moving blank start forward is safer than moving blank end
+ * back, since monitors clamp just AFTER the sync pulse (or in
+ * the sync pulse), but never before.
+ */
+ p->CrtcVBlankStart = p->CrtcVBlankEnd - 127;
+ /*
+ * If VBlankStart is now > VSyncStart move VBlankStart
+ * to VSyncStart using the maximum width that fits into
+ * VTotal.
+ */
+ if (p->CrtcVBlankStart > p->CrtcVSyncStart) {
+ p->CrtcVBlankStart = p->CrtcVSyncStart;
+ p->CrtcVBlankEnd = min(p->CrtcHBlankStart + 127, p->CrtcVTotal);
+ }
+ }
+ p->CrtcHBlankStart = min(p->CrtcHSyncStart, p->CrtcHDisplay);
+ p->CrtcHBlankEnd = max(p->CrtcHSyncEnd, p->CrtcHTotal);
+
+ if ((p->CrtcHBlankEnd - p->CrtcHBlankStart) >= 63 * 8) {
+ /*
+ * H Blanking size must be < 63*8. Same remark as above.
+ */
+ p->CrtcHBlankStart = p->CrtcHBlankEnd - 63 * 8;
+ if (p->CrtcHBlankStart > p->CrtcHSyncStart) {
+ p->CrtcHBlankStart = p->CrtcHSyncStart;
+ p->CrtcHBlankEnd = min(p->CrtcHBlankStart + 63 * 8, p->CrtcHTotal);
+ }
+ }
+}
+
+/*
+ * xf86CheckModeForMonitor
+ *
+ * This function takes a mode and monitor description, and determines
+ * if the mode is valid for the monitor.
+ */
+ModeStatus
+xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor)
+{
+ int i;
+
+ /* Sanity checks */
+ if (mode == NULL || monitor == NULL) {
+ ErrorF("xf86CheckModeForMonitor: called with invalid parameters\n");
+ return MODE_ERROR;
+ }
+
+#ifdef DEBUG
+ ErrorF("xf86CheckModeForMonitor(%p %s, %p %s)\n",
+ mode, mode->name, monitor, monitor->id);
+#endif
+
+ if (monitor->DDC) {
+ xf86MonPtr DDC = (xf86MonPtr)(monitor->DDC);
+ struct detailed_monitor_section* detMon;
+ struct monitor_ranges *mon_range;
+ int i;
+
+ mon_range = NULL;
+ for (i = 0; i < 4; i++) {
+ detMon = &DDC->det_mon[i];
+ if(detMon->type == DS_RANGES) {
+ mon_range = &detMon->section.ranges;
+ }
+ }
+ if (mon_range) {
+ /* mode->Clock in kHz, DDC in MHz */
+ if (mon_range->max_clock < 2550 &&
+ mode->Clock / 1000.0 > mon_range->max_clock) {
+ xf86Msg(X_WARNING,
+ "(%s,%s) mode clock %gMHz exceeds DDC maximum %dMHz\n",
+ mode->name, monitor->id,
+ mode->Clock/1000.0, mon_range->max_clock);
+ }
+ }
+ }
+
+ /* Some basic mode validity checks */
+ if (0 >= mode->HDisplay || mode->HDisplay > mode->HSyncStart ||
+ mode->HSyncStart >= mode->HSyncEnd || mode->HSyncEnd >= mode->HTotal)
+ return MODE_H_ILLEGAL;
+
+ if (0 >= mode->VDisplay || mode->VDisplay > mode->VSyncStart ||
+ mode->VSyncStart >= mode->VSyncEnd || mode->VSyncEnd >= mode->VTotal)
+ return MODE_V_ILLEGAL;
+
+ if (monitor->nHsync > 0) {
+ /* Check hsync against the allowed ranges */
+ float hsync = ModeHSync(mode);
+ for (i = 0; i < monitor->nHsync; i++)
+ if ((hsync > monitor->hsync[i].lo * (1.0 - SYNC_TOLERANCE)) &&
+ (hsync < monitor->hsync[i].hi * (1.0 + SYNC_TOLERANCE)))
+ break;
+
+ /* Now see whether we ran out of sync ranges without finding a match */
+ if (i == monitor->nHsync)
+ return MODE_HSYNC;
+ }
+
+ if (monitor->nVrefresh > 0) {
+ /* Check vrefresh against the allowed ranges */
+ float vrefrsh = ModeVRefresh(mode);
+ for (i = 0; i < monitor->nVrefresh; i++)
+ if ((vrefrsh > monitor->vrefresh[i].lo * (1.0 - SYNC_TOLERANCE)) &&
+ (vrefrsh < monitor->vrefresh[i].hi * (1.0 + SYNC_TOLERANCE)))
+ break;
+
+ /* Now see whether we ran out of refresh ranges without finding a match */
+ if (i == monitor->nVrefresh)
+ return MODE_VSYNC;
+ }
+
+ /* Force interlaced modes to have an odd VTotal */
+ if (mode->Flags & V_INTERLACE)
+ mode->CrtcVTotal = mode->VTotal |= 1;
+
+ return MODE_OK;
+}
+
+/*
+ * xf86CheckModeSize
+ *
+ * An internal routine to check if a mode fits in video memory. This tries to
+ * avoid overflows that would otherwise occur when video memory size is greater
+ * than 256MB.
+ */
+static Bool
+xf86CheckModeSize(ScrnInfoPtr scrp, int w, int x, int y)
+{
+ int bpp = scrp->fbFormat.bitsPerPixel,
+ pad = scrp->fbFormat.scanlinePad;
+ int lineWidth, lastWidth;
+
+ if (scrp->depth == 4)
+ pad *= 4; /* 4 planes */
+
+ /* Sanity check */
+ if ((w < 0) || (x < 0) || (y <= 0))
+ return FALSE;
+
+ lineWidth = (((w * bpp) + pad - 1) / pad) * pad;
+ lastWidth = x * bpp;
+
+ /*
+ * At this point, we need to compare
+ *
+ * (lineWidth * (y - 1)) + lastWidth
+ *
+ * against
+ *
+ * scrp->videoRam * (1024 * 8)
+ *
+ * These are bit quantities. To avoid overflows, do the comparison in
+ * terms of BITMAP_SCANLINE_PAD units. This assumes BITMAP_SCANLINE_PAD
+ * is a power of 2. We currently use 32, which limits us to a video
+ * memory size of 8GB.
+ */
+
+ lineWidth = (lineWidth + (BITMAP_SCANLINE_PAD - 1)) / BITMAP_SCANLINE_PAD;
+ lastWidth = (lastWidth + (BITMAP_SCANLINE_PAD - 1)) / BITMAP_SCANLINE_PAD;
+
+ if ((lineWidth * (y - 1) + lastWidth) >
+ (scrp->videoRam * ((1024 * 8) / BITMAP_SCANLINE_PAD)))
+ return FALSE;
+
+ return TRUE;
+}
+
+/*
+ * xf86InitialCheckModeForDriver
+ *
+ * This function checks if a mode satisfies a driver's initial requirements:
+ * - mode size fits within the available pixel area (memory)
+ * - width lies within the range of supported line pitches
+ * - mode size fits within virtual size (if fixed)
+ * - horizontal timings are in range
+ *
+ * This function takes the following parameters:
+ * scrp ScrnInfoPtr
+ * mode mode to check
+ * maxPitch (optional) maximum line pitch
+ * virtualX (optional) virtual width requested
+ * virtualY (optional) virtual height requested
+ *
+ * In addition, the following fields from the ScrnInfoRec are used:
+ * monitor pointer to structure for monitor section
+ * fbFormat pixel format for the framebuffer
+ * videoRam video memory size (in kB)
+ * maxHValue maximum horizontal timing value
+ * maxVValue maximum vertical timing value
+ */
+
+ModeStatus
+xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
+ ClockRangePtr clockRanges,
+ LookupModeFlags strategy,
+ int maxPitch, int virtualX, int virtualY)
+{
+ ClockRangePtr cp;
+ ModeStatus status;
+ Bool allowDiv2 = (strategy & LOOKUP_CLKDIV2) != 0;
+ int i, needDiv2;
+
+ /* Sanity checks */
+ if (!scrp || !mode || !clockRanges) {
+ ErrorF("xf86InitialCheckModeForDriver: "
+ "called with invalid parameters\n");
+ return MODE_ERROR;
+ }
+
+#ifdef DEBUG
+ ErrorF("xf86InitialCheckModeForDriver(%p, %p %s, %p, 0x%x, %d, %d, %d)\n",
+ scrp, mode, mode->name , clockRanges, strategy, maxPitch, virtualX, virtualY);
+#endif
+
+ /* Some basic mode validity checks */
+ if (0 >= mode->HDisplay || mode->HDisplay > mode->HSyncStart ||
+ mode->HSyncStart >= mode->HSyncEnd || mode->HSyncEnd >= mode->HTotal)
+ return MODE_H_ILLEGAL;
+
+ if (0 >= mode->VDisplay || mode->VDisplay > mode->VSyncStart ||
+ mode->VSyncStart >= mode->VSyncEnd || mode->VSyncEnd >= mode->VTotal)
+ return MODE_V_ILLEGAL;
+
+ if (!xf86CheckModeSize(scrp, mode->HDisplay, mode->HDisplay,
+ mode->VDisplay))
+ return MODE_MEM;
+
+ if (maxPitch > 0 && mode->HDisplay > maxPitch)
+ return MODE_BAD_WIDTH;
+
+ if (virtualX > 0 && mode->HDisplay > virtualX)
+ return MODE_VIRTUAL_X;
+
+ if (virtualY > 0 && mode->VDisplay > virtualY)
+ return MODE_VIRTUAL_Y;
+
+ if (scrp->maxHValue > 0 && mode->HTotal > scrp->maxHValue)
+ return MODE_BAD_HVALUE;
+
+ if (scrp->maxVValue > 0 && mode->VTotal > scrp->maxVValue)
+ return MODE_BAD_VVALUE;
+
+ /*
+ * The use of the DisplayModeRec's Crtc* and SynthClock elements below is
+ * provisional, in that they are later reused by the driver at mode-set
+ * time. Here, they are temporarily enlisted to contain the mode timings
+ * as seen by the CRT or panel (rather than the CRTC). The driver's
+ * ValidMode() is allowed to modify these so it can deal with such things
+ * as mode stretching and/or centering. The driver should >NOT< modify the
+ * user-supplied values as these are reported back when mode validation is
+ * said and done.
+ */
+ /*
+ * NOTE: We (ab)use the mode->Crtc* values here to store timing
+ * information for the calculation of Hsync and Vrefresh. Before
+ * these values are calculated the driver is given the opportunity
+ * to either set these HSync and VRefresh itself or modify the timing
+ * values.
+ * The difference to the final calculation is small but imortand:
+ * here we pass the flag INTERLACE_HALVE_V regardless if the driver
+ * sets it or not. This way our calculation of VRefresh has the same
+ * effect as if we do if (flags & V_INTERLACE) refresh *= 2.0
+ * This dual use of the mode->Crtc* values will certainly create
+ * confusion and is bad software design. However since it's part of
+ * the driver API it's hard to change.
+ */
+
+ if (scrp->ValidMode) {
+
+ xf86SetModeCrtc(mode, INTERLACE_HALVE_V);
+
+ cp = xf86FindClockRangeForMode(clockRanges, mode);
+ if (!cp)
+ return MODE_CLOCK_RANGE;
+
+ if (cp->ClockMulFactor < 1)
+ cp->ClockMulFactor = 1;
+ if (cp->ClockDivFactor < 1)
+ cp->ClockDivFactor = 1;
+
+ /*
+ * XXX The effect of clock dividers and multipliers on the monitor's
+ * pixel clock needs to be verified.
+ */
+ if (scrp->progClock) {
+ mode->SynthClock = mode->Clock;
+ } else {
+ i = xf86GetNearestClock(scrp, mode->Clock, allowDiv2,
+ cp->ClockDivFactor, cp->ClockMulFactor,
+ &needDiv2);
+ mode->SynthClock = (scrp->clock[i] * cp->ClockDivFactor) /
+ cp->ClockMulFactor;
+ if (needDiv2 & V_CLKDIV2)
+ mode->SynthClock /= 2;
+ }
+
+ status = (*scrp->ValidMode)(scrp->scrnIndex, mode, FALSE,
+ MODECHECK_INITIAL);
+ if (status != MODE_OK)
+ return status;
+
+ if (mode->HSync <= 0.0)
+ mode->HSync = (float)mode->SynthClock / (float)mode->CrtcHTotal;
+ if (mode->VRefresh <= 0.0)
+ mode->VRefresh = (mode->SynthClock * 1000.0)
+ / (mode->CrtcHTotal * mode->CrtcVTotal);
+ }
+
+ mode->HSync = ModeHSync(mode);
+ mode->VRefresh = ModeVRefresh(mode);
+
+ /* Assume it is OK */
+ return MODE_OK;
+}
+
+/*
+ * xf86CheckModeForDriver
+ *
+ * This function is for checking modes while the server is running (for
+ * use mainly by the VidMode extension).
+ *
+ * This function checks if a mode satisfies a driver's requirements:
+ * - width lies within the line pitch
+ * - mode size fits within virtual size
+ * - horizontal/vertical timings are in range
+ *
+ * This function takes the following parameters:
+ * scrp ScrnInfoPtr
+ * mode mode to check
+ * flags not (currently) used
+ *
+ * In addition, the following fields from the ScrnInfoRec are used:
+ * maxHValue maximum horizontal timing value
+ * maxVValue maximum vertical timing value
+ * virtualX virtual width
+ * virtualY virtual height
+ * clockRanges allowable clock ranges
+ */
+
+ModeStatus
+xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode, int flags)
+{
+ ClockRangesPtr cp;
+ int i, k, gap, minimumGap = CLOCK_TOLERANCE + 1;
+ int extraFlags = 0;
+ int clockIndex = -1;
+ int MulFactor = 1;
+ int DivFactor = 1;
+ int ModePrivFlags = 0;
+ Bool allowDiv2;
+ ModeStatus status = MODE_NOMODE;
+
+ /* Some sanity checking */
+ if (scrp == NULL || (!scrp->progClock && scrp->numClocks == 0)) {
+ ErrorF("xf86CheckModeForDriver: called with invalid scrnInfoRec\n");
+ return MODE_ERROR;
+ }
+ if (mode == NULL) {
+ ErrorF("xf86CheckModeForDriver: called with invalid modep\n");
+ return MODE_ERROR;
+ }
+
+ /* Check the mode size */
+ if (mode->HDisplay > scrp->virtualX)
+ return MODE_VIRTUAL_X;
+
+ if (mode->VDisplay > scrp->virtualY)
+ return MODE_VIRTUAL_Y;
+
+ if (scrp->maxHValue > 0 && mode->HTotal > scrp->maxHValue)
+ return MODE_BAD_HVALUE;
+
+ if (scrp->maxVValue > 0 && mode->VTotal > scrp->maxVValue)
+ return MODE_BAD_VVALUE;
+
+ for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) {
+ /* DivFactor and MulFactor must be > 0 */
+ cp->ClockDivFactor = max(1, cp->ClockDivFactor);
+ cp->ClockMulFactor = max(1, cp->ClockMulFactor);
+ }
+
+ if (scrp->progClock) {
+ /* Check clock is in range */
+ for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) {
+ if ((cp->minClock <= mode->Clock) &&
+ (cp->maxClock >= mode->Clock) &&
+ (cp->interlaceAllowed || !(mode->Flags & V_INTERLACE)) &&
+ (cp->doubleScanAllowed ||
+ ((!(mode->Flags & V_DBLSCAN)) && (mode->VScan <= 1))))
+ break;
+ }
+ if (cp == NULL) {
+ return MODE_CLOCK_RANGE;
+ }
+ /*
+ * If programmable clock the required mode has been found
+ */
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ } else {
+ status = MODE_CLOCK_RANGE;
+ /* Check clock is in range */
+ for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) {
+ if ((cp->minClock <= mode->Clock) &&
+ (cp->maxClock >= mode->Clock) &&
+ (cp->interlaceAllowed || !(mode->Flags & V_INTERLACE)) &&
+ (cp->doubleScanAllowed ||
+ ((!(mode->Flags & V_DBLSCAN)) && (mode->VScan <= 1)))) {
+
+ /*
+ * Clock is in range, so if it is not a programmable clock,
+ * find a matching clock.
+ */
+
+ allowDiv2 = (cp->strategy & LOOKUP_CLKDIV2) != 0;
+ i = xf86GetNearestClock(scrp, mode->Clock, allowDiv2,
+ cp->ClockDivFactor, cp->ClockMulFactor, &k);
+ /*
+ * If the clock is too far from the requested clock, this
+ * mode is no good.
+ */
+ if (k & V_CLKDIV2)
+ gap = abs((mode->Clock * 2) -
+ ((scrp->clock[i] * cp->ClockDivFactor) /
+ cp->ClockMulFactor));
+ else
+ gap = abs(mode->Clock -
+ ((scrp->clock[i] * cp->ClockDivFactor) /
+ cp->ClockMulFactor));
+ if (gap > minimumGap) {
+ status = MODE_NOCLOCK;
+ continue;
+ }
+
+ DivFactor = cp->ClockDivFactor;
+ MulFactor = cp->ClockMulFactor;
+ ModePrivFlags = cp->PrivFlags;
+ extraFlags = k;
+ clockIndex = i;
+ break;
+ }
+ }
+ if (cp == NULL)
+ return status;
+ }
+
+ /* Fill in the mode parameters */
+ if (scrp->progClock) {
+ mode->ClockIndex = -1;
+ mode->SynthClock = (mode->Clock * MulFactor) / DivFactor;
+ } else {
+ mode->Clock = (scrp->clock[clockIndex] * DivFactor) / MulFactor;
+ mode->ClockIndex = clockIndex;
+ mode->SynthClock = scrp->clock[clockIndex];
+ if (extraFlags & V_CLKDIV2) {
+ mode->Clock /= 2;
+ mode->SynthClock /= 2;
+ }
+ }
+ mode->PrivFlags = ModePrivFlags;
+
+ return MODE_OK;
+}
+
+/*
+ * xf86ValidateModes
+ *
+ * This function takes a set of mode names, modes and limiting conditions,
+ * and selects a set of modes and parameters based on those conditions.
+ *
+ * This function takes the following parameters:
+ * scrp ScrnInfoPtr
+ * availModes the list of modes available for the monitor
+ * modeNames (optional) list of mode names that the screen is requesting
+ * clockRanges a list of clock ranges
+ * linePitches (optional) a list of line pitches
+ * minPitch (optional) minimum line pitch (in pixels)
+ * maxPitch (optional) maximum line pitch (in pixels)
+ * pitchInc (mandatory) pitch increment (in bits)
+ * minHeight (optional) minimum virtual height (in pixels)
+ * maxHeight (optional) maximum virtual height (in pixels)
+ * virtualX (optional) virtual width requested (in pixels)
+ * virtualY (optional) virtual height requested (in pixels)
+ * apertureSize size of video aperture (in bytes)
+ * strategy how to decide which mode to use from multiple modes with
+ * the same name
+ *
+ * In addition, the following fields from the ScrnInfoRec are used:
+ * clocks a list of discrete clocks
+ * numClocks number of discrete clocks
+ * progClock clock is programmable
+ * monitor pointer to structure for monitor section
+ * fbFormat format of the framebuffer
+ * videoRam video memory size
+ * maxHValue maximum horizontal timing value
+ * maxVValue maximum vertical timing value
+ * xInc horizontal timing increment (defaults to 8 pixels)
+ *
+ * The function fills in the following ScrnInfoRec fields:
+ * modePool A subset of the modes available to the monitor which
+ * are compatible with the driver.
+ * modes one mode entry for each of the requested modes, with the
+ * status field filled in to indicate if the mode has been
+ * accepted or not.
+ * virtualX the resulting virtual width
+ * virtualY the resulting virtual height
+ * displayWidth the resulting line pitch
+ *
+ * The function's return value is the number of matching modes found, or -1
+ * if an unrecoverable error was encountered.
+ */
+
+int
+xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
+ char **modeNames, ClockRangePtr clockRanges,
+ int *linePitches, int minPitch, int maxPitch, int pitchInc,
+ int minHeight, int maxHeight, int virtualX, int virtualY,
+ int apertureSize, LookupModeFlags strategy)
+{
+ DisplayModePtr p, q, r, new, last, *endp;
+ int i, numModes = 0;
+ ModeStatus status;
+ int linePitch = -1, virtX = 0, virtY = 0;
+ int newLinePitch, newVirtX, newVirtY;
+ int modeSize; /* in pixels */
+ Bool validateAllDefaultModes = FALSE;
+ Bool userModes = FALSE;
+ int saveType;
+ PixmapFormatRec *BankFormat;
+ ClockRangePtr cp;
+ ClockRangesPtr storeClockRanges;
+ struct monitor_ranges *mon_range = NULL;
+ double targetRefresh = 0.0;
+ int numTimings = 0;
+ range hsync[MAX_HSYNC];
+ range vrefresh[MAX_VREFRESH];
+
+#ifdef DEBUG
+ ErrorF("xf86ValidateModes(%p, %p, %p, %p,\n\t\t %p, %d, %d, %d, %d, %d, %d, %d, %d, 0x%x)\n",
+ scrp, availModes, modeNames, clockRanges,
+ linePitches, minPitch, maxPitch, pitchInc,
+ minHeight, maxHeight, virtualX, virtualY,
+ apertureSize, strategy
+ );
+#endif
+
+ /* Some sanity checking */
+ if (scrp == NULL || scrp->name == NULL || !scrp->monitor ||
+ (!scrp->progClock && scrp->numClocks == 0)) {
+ ErrorF("xf86ValidateModes: called with invalid scrnInfoRec\n");
+ return -1;
+ }
+ if (linePitches != NULL && linePitches[0] <= 0) {
+ ErrorF("xf86ValidateModes: called with invalid linePitches\n");
+ return -1;
+ }
+ if (pitchInc <= 0) {
+ ErrorF("xf86ValidateModes: called with invalid pitchInc\n");
+ return -1;
+ }
+ if ((virtualX > 0) != (virtualY > 0)) {
+ ErrorF("xf86ValidateModes: called with invalid virtual resolution\n");
+ return -1;
+ }
+
+ /*
+ * Probe monitor so that we can enforce/warn about its limits.
+ * If one or more DS_RANGES descriptions are present, use the parameters
+ * that they provide. Otherwise, deduce limits based on the modes that
+ * are shown as supported via standard and detailed timings.
+ *
+ * XXX The full potential of the DDC/EDID data still isn't being tapped.
+ */
+ if (scrp->monitor->DDC) {
+ MonPtr monitor = scrp->monitor;
+ xf86MonPtr DDC = (xf86MonPtr)(scrp->monitor->DDC);
+ int i, j;
+ float hmin = 1e6, hmax = 0.0, vmin = 1e6, vmax = 0.0;
+ float h;
+ struct std_timings *t;
+ struct detailed_timings *dt;
+
+ numTimings = 0;
+ for (i = 0; i < DET_TIMINGS; i++) {
+ switch (DDC->det_mon[i].type) {
+ case DS_RANGES:
+ mon_range = &DDC->det_mon[i].section.ranges;
+ hsync[numTimings].lo = mon_range->min_h;
+ hsync[numTimings].hi = mon_range->max_h;
+ vrefresh[numTimings].lo = mon_range->min_v;
+ vrefresh[numTimings].hi = mon_range->max_v;
+ numTimings++;
+ break;
+
+ case DS_STD_TIMINGS:
+ t = DDC->det_mon[i].section.std_t;
+ for (j = 0; j < 5; j++) {
+ if (t[j].hsize > 256) { /* sanity check */
+ if (t[j].refresh < vmin)
+ vmin = t[i].refresh;
+ if (t[j].refresh > vmax)
+ vmax = t[i].refresh;
+ /*
+ * For typical modes this is a reasonable estimate
+ * of the horizontal sync rate.
+ */
+ h = t[j].refresh * 1.07 * t[j].vsize / 1000.0;
+ if (h < hmin)
+ hmin = h;
+ if (h > hmax)
+ hmax = h;
+ }
+ }
+ break;
+
+ case DT:
+ dt = &DDC->det_mon[i].section.d_timings;
+ if (dt->clock > 15000000) { /* sanity check */
+ float v;
+ h = (float)dt->clock / (dt->h_active + dt->h_blanking);
+ v = h / (dt->v_active + dt->v_blanking);
+ h /= 1000.0;
+ if (dt->interlaced)
+ v /= 2.0;
+
+ if (v < vmin)
+ vmin = v;
+ if (v > vmax)
+ vmax = v;
+ if (h < hmin)
+ hmin = h;
+ if (h > hmax)
+ hmax = h;
+ }
+ break;
+ }
+
+ if (numTimings > MAX_HSYNC)
+ break;
+ }
+
+ if (numTimings == 0) {
+ t = DDC->timings2;
+ for (i = 0; i < STD_TIMINGS; i++) {
+ if (t[i].hsize > 256) { /* sanity check */
+ if (t[i].refresh < vmin)
+ vmin = t[i].refresh;
+ if (t[i].refresh > vmax)
+ vmax = t[i].refresh;
+ /*
+ * For typical modes this is a reasonable estimate
+ * of the horizontal sync rate.
+ */
+ h = t[i].refresh * 1.07 * t[i].vsize / 1000.0;
+ if (h < hmin)
+ hmin = h;
+ if (h > hmax)
+ hmax = h;
+ }
+ }
+
+ if (hmax > 0.0) {
+ hsync[numTimings].lo = hmin;
+ hsync[numTimings].hi = hmax;
+ vrefresh[numTimings].lo = vmin;
+ vrefresh[numTimings].hi = vmax;
+ numTimings++;
+ }
+ }
+
+ if (numTimings > 0) {
+
+#ifdef DEBUG
+ for (i = 0; i < numTimings; i++) {
+ ErrorF("DDC - Hsync %.1f-%.1f kHz - Vrefresh %.1f-%.1f Hz\n",
+ hsync[i].lo, hsync[i].hi,
+ vrefresh[i].lo, vrefresh[i].hi);
+ }
+#endif
+
+#define DDC_SYNC_TOLERANCE SYNC_TOLERANCE
+ if (monitor->nHsync > 0) {
+ for (i = 0; i < monitor->nHsync; i++) {
+ Bool good = FALSE;
+ for (j = 0; j < numTimings; j++) {
+ if ((1.0 - DDC_SYNC_TOLERANCE) * hsync[j].lo <=
+ monitor->hsync[i].lo &&
+ (1.0 + DDC_SYNC_TOLERANCE) * hsync[j].hi >=
+ monitor->hsync[i].hi) {
+ good = TRUE;
+ break;
+ }
+ }
+ if (!good) {
+ xf86DrvMsg(scrp->scrnIndex, X_WARNING,
+ "config file hsync range %g-%gkHz not within DDC "
+ "hsync ranges.\n",
+ monitor->hsync[i].lo, monitor->hsync[i].hi);
+ }
+ }
+ }
+
+ if (monitor->nVrefresh > 0) {
+ for (i = 0; i < monitor->nVrefresh; i++) {
+ Bool good = FALSE;
+ for (j = 0; j < numTimings; j++) {
+ if ((1.0 - DDC_SYNC_TOLERANCE) * vrefresh[j].lo <=
+ monitor->vrefresh[0].lo &&
+ (1.0 + DDC_SYNC_TOLERANCE) * vrefresh[j].hi >=
+ monitor->vrefresh[0].hi) {
+ good = TRUE;
+ break;
+ }
+ }
+ if (!good) {
+ xf86DrvMsg(scrp->scrnIndex, X_WARNING,
+ "config file vrefresh range %g-%gHz not within DDC "
+ "vrefresh ranges.\n",
+ monitor->vrefresh[i].lo, monitor->vrefresh[i].hi);
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * If requested by the driver, allow missing hsync and/or vrefresh ranges
+ * in the monitor section.
+ */
+ if (strategy & LOOKUP_OPTIONAL_TOLERANCES) {
+ strategy &= ~LOOKUP_OPTIONAL_TOLERANCES;
+ } else {
+ const char *type = "";
+
+ if (scrp->monitor->nHsync <= 0) {
+ if (numTimings > 0) {
+ scrp->monitor->nHsync = numTimings;
+ for (i = 0; i < numTimings; i++) {
+ scrp->monitor->hsync[i].lo = hsync[i].lo;
+ scrp->monitor->hsync[i].hi = hsync[i].hi;
+ }
+ } else {
+ scrp->monitor->hsync[0].lo = 28;
+ scrp->monitor->hsync[0].hi = 33;
+ scrp->monitor->nHsync = 1;
+ }
+ type = "default ";
+ }
+ for (i = 0; i < scrp->monitor->nHsync; i++) {
+ if (scrp->monitor->hsync[i].lo == scrp->monitor->hsync[i].hi)
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "%s: Using %shsync value of %.2f kHz\n",
+ scrp->monitor->id, type,
+ scrp->monitor->hsync[i].lo);
+ else
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "%s: Using %shsync range of %.2f-%.2f kHz\n",
+ scrp->monitor->id, type,
+ scrp->monitor->hsync[i].lo,
+ scrp->monitor->hsync[i].hi);
+ }
+
+ type = "";
+ if (scrp->monitor->nVrefresh <= 0) {
+ if (numTimings > 0) {
+ scrp->monitor->nVrefresh = numTimings;
+ for (i = 0; i < numTimings; i++) {
+ scrp->monitor->vrefresh[i].lo = vrefresh[i].lo;
+ scrp->monitor->vrefresh[i].hi = vrefresh[i].hi;
+ }
+ } else {
+ scrp->monitor->vrefresh[0].lo = 43;
+ scrp->monitor->vrefresh[0].hi = 72;
+ scrp->monitor->nVrefresh = 1;
+ }
+ type = "default ";
+ }
+ for (i = 0; i < scrp->monitor->nVrefresh; i++) {
+ if (scrp->monitor->vrefresh[i].lo == scrp->monitor->vrefresh[i].hi)
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "%s: Using %svrefresh value of %.2f Hz\n",
+ scrp->monitor->id, type,
+ scrp->monitor->vrefresh[i].lo);
+ else
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "%s: Using %svrefresh range of %.2f-%.2f Hz\n",
+ scrp->monitor->id, type,
+ scrp->monitor->vrefresh[i].lo,
+ scrp->monitor->vrefresh[i].hi);
+ }
+ }
+
+ /*
+ * Store the clockRanges for later use by the VidMode extension. Must
+ * also store the strategy, since ClockDiv2 flag is stored there.
+ */
+ storeClockRanges = scrp->clockRanges;
+ while (storeClockRanges != NULL) {
+ storeClockRanges = storeClockRanges->next;
+ }
+ for (cp = clockRanges; cp != NULL; cp = cp->next,
+ storeClockRanges = storeClockRanges->next) {
+ storeClockRanges = xnfalloc(sizeof(ClockRanges));
+ if (scrp->clockRanges == NULL)
+ scrp->clockRanges = storeClockRanges;
+ memcpy(storeClockRanges, cp, sizeof(ClockRange));
+ storeClockRanges->strategy = strategy;
+ }
+
+ /* Determine which pixmap format to pass to miScanLineWidth() */
+ if (scrp->depth > 4)
+ BankFormat = &scrp->fbFormat;
+ else
+ BankFormat = xf86GetPixFormat(scrp, 1); /* >not< scrp->depth! */
+
+ if (scrp->xInc <= 0)
+ scrp->xInc = 8; /* Suitable for VGA and others */
+
+#define _VIRTUALX(x) ((((x) + scrp->xInc - 1) / scrp->xInc) * scrp->xInc)
+
+ /*
+ * Determine maxPitch if it wasn't given explicitly. Note linePitches
+ * always takes precedence if is non-NULL. In that case the minPitch and
+ * maxPitch values passed are ignored.
+ */
+ if (linePitches) {
+ minPitch = maxPitch = linePitches[0];
+ for (i = 1; linePitches[i] > 0; i++) {
+ if (linePitches[i] > maxPitch)
+ maxPitch = linePitches[i];
+ if (linePitches[i] < minPitch)
+ minPitch = linePitches[i];
+ }
+ }
+
+ /* Initial check of virtual size against other constraints */
+ scrp->virtualFrom = X_PROBED;
+ /*
+ * Initialise virtX and virtY if the values are fixed.
+ */
+ if (virtualY > 0) {
+ if (maxHeight > 0 && virtualY > maxHeight) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Virtual height (%d) is too large for the hardware "
+ "(max %d)\n", virtualY, maxHeight);
+ return -1;
+ }
+
+ if (minHeight > 0 && virtualY < minHeight) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Virtual height (%d) is too small for the hardware "
+ "(min %d)\n", virtualY, minHeight);
+ return -1;
+ }
+
+ virtualX = _VIRTUALX(virtualX);
+ if (linePitches != NULL) {
+ for (i = 0; linePitches[i] != 0; i++) {
+ if ((linePitches[i] >= virtualX) &&
+ (linePitches[i] ==
+ miScanLineWidth(virtualX, virtualY, linePitches[i],
+ apertureSize, BankFormat, pitchInc))) {
+ linePitch = linePitches[i];
+ break;
+ }
+ }
+ } else {
+ linePitch = miScanLineWidth(virtualX, virtualY, minPitch,
+ apertureSize, BankFormat, pitchInc);
+ }
+
+ if ((linePitch < minPitch) || (linePitch > maxPitch)) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Virtual width (%d) is too large for the hardware "
+ "(max %d)\n", virtualX, maxPitch);
+ return -1;
+ }
+
+ if (!xf86CheckModeSize(scrp, linePitch, virtualX, virtualY)) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Virtual size (%dx%d) (pitch %d) exceeds video memory\n",
+ virtualX, virtualY, linePitch);
+ return -1;
+ }
+
+ virtX = virtualX;
+ virtY = virtualY;
+ scrp->virtualFrom = X_CONFIG;
+ }
+
+ /* Print clock ranges and scaled clocks */
+ xf86ShowClockRanges(scrp, clockRanges);
+
+ /*
+ * If scrp->modePool hasn't been setup yet, set it up now. This allows the
+ * modes that the driver definitely can't use to be weeded out early. Note
+ * that a modePool mode's prev field is used to hold a pointer to the
+ * member of the scrp->modes list for which a match was considered.
+ */
+ if (scrp->modePool == NULL) {
+ q = NULL;
+ for (p = availModes; p != NULL; p = p->next) {
+ status = xf86InitialCheckModeForDriver(scrp, p, clockRanges,
+ strategy, maxPitch,
+ virtualX, virtualY);
+
+ if (status == MODE_OK) {
+ status = xf86CheckModeForMonitor(p, scrp->monitor);
+ }
+
+ if (status == MODE_OK) {
+ new = xnfalloc(sizeof(DisplayModeRec));
+ *new = *p;
+ new->next = NULL;
+ if (!q) {
+ scrp->modePool = new;
+ } else {
+ q->next = new;
+ }
+ new->prev = NULL;
+ q = new;
+ q->name = xnfstrdup(p->name);
+ q->status = MODE_OK;
+ } else {
+ if (p->type & M_T_BUILTIN)
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Not using built-in mode \"%s\" (%s)\n",
+ p->name, xf86ModeStatusToString(status));
+ else if (p->type & M_T_DEFAULT)
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Not using default mode \"%s\" (%s)\n", p->name,
+ xf86ModeStatusToString(status));
+ else
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Not using mode \"%s\" (%s)\n", p->name,
+ xf86ModeStatusToString(status));
+ }
+ }
+
+ if (scrp->modePool == NULL) {
+ xf86DrvMsg(scrp->scrnIndex, X_WARNING, "Mode pool is empty\n");
+ return 0;
+ }
+ } else {
+ for (p = scrp->modePool; p != NULL; p = p->next) {
+ p->prev = NULL;
+ p->status = MODE_OK;
+ }
+ }
+
+ /*
+ * Go through the mode pool and see if any modes match the target
+ * refresh rate, (if specified). If no modes match, abandon the target.
+ */
+ targetRefresh = xf86SetRealOption(scrp->options,
+ "TargetRefresh", 0.0);
+ if (targetRefresh > 0.0) {
+ for (p = scrp->modePool; p != NULL; p = p->next) {
+ if (ModeVRefresh(p) > targetRefresh * (1.0 - SYNC_TOLERANCE))
+ break;
+ }
+ if (!p)
+ targetRefresh = 0.0;
+ }
+
+ if (targetRefresh > 0.0) {
+ xf86DrvMsg(scrp->scrnIndex, X_CONFIG,
+ "Target refresh rate is %.1f Hz\n", targetRefresh);
+ }
+
+ /*
+ * Allocate one entry in scrp->modes for each named mode.
+ */
+ while (scrp->modes)
+ xf86DeleteMode(&scrp->modes, scrp->modes);
+ endp = &scrp->modes;
+ last = NULL;
+ if (modeNames != NULL) {
+ for (i = 0; modeNames[i] != NULL; i++) {
+ userModes = TRUE;
+ new = xnfcalloc(1, sizeof(DisplayModeRec));
+ new->prev = last;
+ new->type = M_T_USERDEF;
+ new->name = xnfalloc(strlen(modeNames[i]) + 1);
+ strcpy(new->name, modeNames[i]);
+ if (new->prev)
+ new->prev->next = new;
+ *endp = last = new;
+ endp = &new->next;
+ }
+ }
+
+ /* Lookup each mode */
+#ifdef RANDR
+ if (!xf86Info.disableRandR
+#ifdef PANORAMIX
+ && noPanoramiXExtension
+#endif
+ )
+ validateAllDefaultModes = TRUE;
+#endif
+
+ for (p = scrp->modes; ; p = p->next) {
+ Bool repeat;
+
+ /*
+ * If the supplied mode names don't produce a valid mode, scan through
+ * unconsidered modePool members until one survives validation. This
+ * is done in decreasing order by mode pixel area.
+ */
+
+ if (p == NULL) {
+ if ((numModes > 0) && !validateAllDefaultModes)
+ break;
+
+ validateAllDefaultModes = TRUE;
+ r = NULL;
+ modeSize = 0;
+ for (q = scrp->modePool; q != NULL; q = q->next) {
+ if ((q->prev == NULL) && (q->status == MODE_OK)) {
+ /*
+ * Deal with the case where this mode wasn't considered
+ * because of a builtin mode of the same name.
+ */
+ for (p = scrp->modes; p != NULL; p = p->next) {
+ if ((p->status != MODE_OK) &&
+ !strcmp(p->name, q->name))
+ break;
+ }
+
+ if (p != NULL)
+ q->prev = p;
+ else {
+ /*
+ * A quick check to not allow default modes with
+ * horizontal timing parameters that CRTs may have
+ * problems with.
+ */
+ if ((q->type & M_T_DEFAULT) &&
+ ((double)q->HTotal / (double)q->HDisplay) < 1.15)
+ continue;
+
+ /*
+ * If there is a target refresh rate, skip modes that
+ * don't match up.
+ */
+ if (ModeVRefresh(q) <
+ (1.0 - SYNC_TOLERANCE) * targetRefresh)
+ continue;
+
+ if (modeSize < (q->HDisplay * q->VDisplay)) {
+ r = q;
+ modeSize = q->HDisplay * q->VDisplay;
+ }
+ }
+ }
+ }
+
+ if (r == NULL)
+ break;
+
+ p = xnfcalloc(1, sizeof(DisplayModeRec));
+ p->prev = last;
+ p->name = xnfalloc(strlen(r->name) + 1);
+ if (!userModes)
+ p->type = M_T_USERDEF;
+ strcpy(p->name, r->name);
+ if (p->prev)
+ p->prev->next = p;
+ *endp = last = p;
+ endp = &p->next;
+ }
+
+ repeat = FALSE;
+ lookupNext:
+ if (repeat && ((status = p->status) != MODE_OK)) {
+ if (p->type & M_T_BUILTIN)
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Not using built-in mode \"%s\" (%s)\n",
+ p->name, xf86ModeStatusToString(status));
+ else if (p->type & M_T_DEFAULT)
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Not using default mode \"%s\" (%s)\n", p->name,
+ xf86ModeStatusToString(status));
+ else
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Not using mode \"%s\" (%s)\n", p->name,
+ xf86ModeStatusToString(status));
+ }
+ saveType = p->type;
+ status = xf86LookupMode(scrp, p, clockRanges, strategy);
+ if (repeat && status == MODE_NOMODE) {
+ continue;
+ }
+ if (status != MODE_OK) {
+ if (p->type & M_T_BUILTIN)
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Not using built-in mode \"%s\" (%s)\n",
+ p->name, xf86ModeStatusToString(status));
+ else if (p->type & M_T_DEFAULT)
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Not using default mode \"%s\" (%s)\n", p->name,
+ xf86ModeStatusToString(status));
+ else
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Not using mode \"%s\" (%s)\n", p->name,
+ xf86ModeStatusToString(status));
+ }
+ if (status == MODE_ERROR) {
+ ErrorF("xf86ValidateModes: "
+ "unexpected result from xf86LookupMode()\n");
+ return -1;
+ }
+ if (status != MODE_OK) {
+ if (p->status == MODE_OK)
+ p->status = status;
+ continue;
+ }
+ p->type |= saveType;
+ repeat = TRUE;
+
+ newLinePitch = linePitch;
+ newVirtX = virtX;
+ newVirtY = virtY;
+
+ /*
+ * Don't let non-user defined modes increase the virtual size
+ */
+ if (!(p->type & M_T_USERDEF) && (numModes > 0)) {
+ if (p->HDisplay > virtX) {
+ p->status = MODE_VIRTUAL_X;
+ goto lookupNext;
+ }
+ if (p->VDisplay > virtY) {
+ p->status = MODE_VIRTUAL_Y;
+ goto lookupNext;
+ }
+ }
+ /*
+ * Adjust virtual width and height if the mode is too large for the
+ * current values and if they are not fixed.
+ */
+ if (virtualX <= 0 && p->HDisplay > newVirtX)
+ newVirtX = _VIRTUALX(p->HDisplay);
+ if (virtualY <= 0 && p->VDisplay > newVirtY) {
+ if (maxHeight > 0 && p->VDisplay > maxHeight) {
+ p->status = MODE_VIRTUAL_Y; /* ? */
+ goto lookupNext;
+ }
+ newVirtY = p->VDisplay;
+ }
+
+ /*
+ * If virtual resolution is to be increased, revalidate it.
+ */
+ if ((virtX != newVirtX) || (virtY != newVirtY)) {
+ if (linePitches != NULL) {
+ newLinePitch = -1;
+ for (i = 0; linePitches[i] != 0; i++) {
+ if ((linePitches[i] >= newVirtX) &&
+ (linePitches[i] >= linePitch) &&
+ (linePitches[i] ==
+ miScanLineWidth(newVirtX, newVirtY, linePitches[i],
+ apertureSize, BankFormat, pitchInc))) {
+ newLinePitch = linePitches[i];
+ break;
+ }
+ }
+ } else {
+ if (linePitch < minPitch)
+ linePitch = minPitch;
+ newLinePitch = miScanLineWidth(newVirtX, newVirtY, linePitch,
+ apertureSize, BankFormat,
+ pitchInc);
+ }
+ if ((newLinePitch < minPitch) || (newLinePitch > maxPitch)) {
+ p->status = MODE_BAD_WIDTH;
+ goto lookupNext;
+ }
+
+ /*
+ * Check that the pixel area required by the new virtual height
+ * and line pitch isn't too large.
+ */
+ if (!xf86CheckModeSize(scrp, newLinePitch, newVirtX, newVirtY)) {
+ p->status = MODE_MEM_VIRT;
+ goto lookupNext;
+ }
+ }
+
+ if (scrp->ValidMode) {
+ /*
+ * Give the driver a final say, passing it the proposed virtual
+ * geometry.
+ */
+ scrp->virtualX = newVirtX;
+ scrp->virtualY = newVirtY;
+ scrp->displayWidth = newLinePitch;
+ p->status = (scrp->ValidMode)(scrp->scrnIndex, p, FALSE,
+ MODECHECK_FINAL);
+
+ if (p->status != MODE_OK) {
+ goto lookupNext;
+ }
+ }
+
+ /* Mode has passed all the tests */
+ virtX = newVirtX;
+ virtY = newVirtY;
+ linePitch = newLinePitch;
+ p->status = MODE_OK;
+ numModes++;
+ }
+
+#undef _VIRTUALX
+
+ /* Update the ScrnInfoRec parameters */
+
+ scrp->virtualX = virtX;
+ scrp->virtualY = virtY;
+ scrp->displayWidth = linePitch;
+
+ if (numModes <= 0)
+ return 0;
+
+ /* Make the mode list into a circular list by joining up the ends */
+ p = scrp->modes;
+ while (p->next != NULL)
+ p = p->next;
+ /* p is now the last mode on the list */
+ p->next = scrp->modes;
+ scrp->modes->prev = p;
+
+ if (minHeight > 0 && virtY < minHeight) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Virtual height (%d) is too small for the hardware "
+ "(min %d)\n", virtY, minHeight);
+ return -1;
+ }
+
+ return numModes;
+}
+
+/*
+ * xf86DeleteMode
+ *
+ * This function removes a mode from a list of modes.
+ *
+ * There are different types of mode lists:
+ *
+ * - singly linked linear lists, ending in NULL
+ * - doubly linked linear lists, starting and ending in NULL
+ * - doubly linked circular lists
+ *
+ */
+
+void
+xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode)
+{
+ /* Catch the easy/insane cases */
+ if (modeList == NULL || *modeList == NULL || mode == NULL)
+ return;
+
+ /* If the mode is at the start of the list, move the start of the list */
+ if (*modeList == mode)
+ *modeList = mode->next;
+
+ /* If mode is the only one on the list, set the list to NULL */
+ if ((mode == mode->prev) && (mode == mode->next)) {
+ *modeList = NULL;
+ } else {
+ if ((mode->prev != NULL) && (mode->prev->next == mode))
+ mode->prev->next = mode->next;
+ if ((mode->next != NULL) && (mode->next->prev == mode))
+ mode->next->prev = mode->prev;
+ }
+
+ xfree(mode->name);
+ xfree(mode);
+}
+
+/*
+ * xf86PruneDriverModes
+ *
+ * Remove modes from the driver's mode list which have been marked as
+ * invalid.
+ */
+
+void
+xf86PruneDriverModes(ScrnInfoPtr scrp)
+{
+ DisplayModePtr first, p, n;
+
+ p = scrp->modes;
+ if (p == NULL)
+ return;
+
+ do {
+ if (!(first = scrp->modes))
+ return;
+ n = p->next;
+ if (p->status != MODE_OK) {
+#if 0
+ if (p->type & M_T_BUILTIN)
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Not using built-in mode \"%s\" (%s)\n", p->name,
+ xf86ModeStatusToString(p->status));
+ else if (p->type & M_T_DEFAULT)
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Not using default mode \"%s\" (%s)\n", p->name,
+ xf86ModeStatusToString(p->status));
+ else
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Not using mode \"%s\" (%s)\n", p->name,
+ xf86ModeStatusToString(p->status));
+#endif
+ xf86DeleteMode(&(scrp->modes), p);
+ }
+ p = n;
+ } while (p != NULL && p != first);
+
+ /* modePool is no longer needed, turf it */
+ while (scrp->modePool) {
+ /*
+ * A modePool mode's prev field is used to hold a pointer to the
+ * member of the scrp->modes list for which a match was considered.
+ * Clear that pointer first, otherwise xf86DeleteMode might get
+ * confused
+ */
+ scrp->modePool->prev = NULL;
+ xf86DeleteMode(&scrp->modePool, scrp->modePool);
+ }
+}
+
+
+/*
+ * xf86SetCrtcForModes
+ *
+ * Goes through the screen's mode list, and initialises the Crtc
+ * parameters for each mode. The initialisation includes adjustments
+ * for interlaced and double scan modes.
+ */
+void
+xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags)
+{
+ DisplayModePtr p;
+
+ /*
+ * Store adjustFlags for use with the VidMode extension. There is an
+ * implicit assumption here that SetCrtcForModes is called once.
+ */
+ scrp->adjustFlags = adjustFlags;
+
+ p = scrp->modes;
+ if (p == NULL)
+ return;
+
+ do {
+ xf86SetModeCrtc(p, adjustFlags);
+#ifdef DEBUG
+ ErrorF("%sMode %s: %d (%d) %d %d (%d) %d %d (%d) %d %d (%d) %d\n",
+ (p->type & M_T_DEFAULT) ? "Default " : "",
+ p->name, p->CrtcHDisplay, p->CrtcHBlankStart,
+ p->CrtcHSyncStart, p->CrtcHSyncEnd, p->CrtcHBlankEnd,
+ p->CrtcHTotal, p->CrtcVDisplay, p->CrtcVBlankStart,
+ p->CrtcVSyncStart, p->CrtcVSyncEnd, p->CrtcVBlankEnd,
+ p->CrtcVTotal);
+#endif
+ p = p->next;
+ } while (p != NULL && p != scrp->modes);
+}
+
+
+static void
+add(char **p, char *new)
+{
+ *p = xnfrealloc(*p, strlen(*p) + strlen(new) + 2);
+ strcat(*p, " ");
+ strcat(*p, new);
+}
+
+static void
+PrintModeline(int scrnIndex,DisplayModePtr mode)
+{
+ char tmp[256];
+ char *flags = xnfcalloc(1, 1);
+
+ if (mode->HSkew) {
+ snprintf(tmp, 256, "hskew %i", mode->HSkew);
+ add(&flags, tmp);
+ }
+ if (mode->VScan) {
+ snprintf(tmp, 256, "vscan %i", mode->VScan);
+ add(&flags, tmp);
+ }
+ if (mode->Flags & V_INTERLACE) add(&flags, "interlace");
+ if (mode->Flags & V_CSYNC) add(&flags, "composite");
+ if (mode->Flags & V_DBLSCAN) add(&flags, "doublescan");
+ if (mode->Flags & V_BCAST) add(&flags, "bcast");
+ if (mode->Flags & V_PHSYNC) add(&flags, "+hsync");
+ if (mode->Flags & V_NHSYNC) add(&flags, "-hsync");
+ if (mode->Flags & V_PVSYNC) add(&flags, "+vsync");
+ if (mode->Flags & V_NVSYNC) add(&flags, "-vsync");
+ if (mode->Flags & V_PCSYNC) add(&flags, "+csync");
+ if (mode->Flags & V_NCSYNC) add(&flags, "-csync");
+#if 0
+ if (mode->Flags & V_CLKDIV2) add(&flags, "vclk/2");
+#endif
+ xf86DrvMsgVerb(scrnIndex, X_INFO, 3,
+ "Modeline \"%s\" %6.2f %i %i %i %i %i %i %i %i%s\n",
+ mode->name, mode->Clock/1000., mode->HDisplay,
+ mode->HSyncStart, mode->HSyncEnd, mode->HTotal,
+ mode->VDisplay, mode->VSyncStart, mode->VSyncEnd,
+ mode->VTotal, flags);
+ xfree(flags);
+}
+
+void
+xf86PrintModes(ScrnInfoPtr scrp)
+{
+ DisplayModePtr p;
+ float hsync, refresh = 0;
+ char *desc, *desc2, *prefix, *uprefix;
+
+ if (scrp == NULL)
+ return;
+
+ xf86DrvMsg(scrp->scrnIndex, scrp->virtualFrom, "Virtual size is %dx%d "
+ "(pitch %d)\n", scrp->virtualX, scrp->virtualY,
+ scrp->displayWidth);
+
+ p = scrp->modes;
+ if (p == NULL)
+ return;
+
+ do {
+ desc = desc2 = "";
+ hsync = ModeHSync(p);
+ refresh = ModeVRefresh(p);
+ if (p->Flags & V_INTERLACE) {
+ desc = " (I)";
+ }
+ if (p->Flags & V_DBLSCAN) {
+ desc = " (D)";
+ }
+ if (p->VScan > 1) {
+ desc2 = " (VScan)";
+ }
+ if (p->type & M_T_BUILTIN)
+ prefix = "Built-in mode";
+ else if (p->type & M_T_DEFAULT)
+ prefix = "Default mode";
+ else
+ prefix = "Mode";
+ if (p->type & M_T_USERDEF)
+ uprefix = "*";
+ else
+ uprefix = " ";
+ if (hsync == 0 || refresh == 0) {
+ if (p->name)
+ xf86DrvMsg(scrp->scrnIndex, X_CONFIG,
+ "%s%s \"%s\"\n", uprefix, prefix, p->name);
+ else
+ xf86DrvMsg(scrp->scrnIndex, X_PROBED,
+ "%s%s %dx%d (unnamed)\n",
+ uprefix, prefix, p->HDisplay, p->VDisplay);
+ } else if (p->Clock == p->SynthClock) {
+ xf86DrvMsg(scrp->scrnIndex, X_CONFIG,
+ "%s%s \"%s\": %.1f MHz, %.1f kHz, %.1f Hz%s%s\n",
+ uprefix, prefix, p->name, p->Clock / 1000.0,
+ hsync, refresh, desc, desc2);
+ } else {
+ xf86DrvMsg(scrp->scrnIndex, X_CONFIG,
+ "%s%s \"%s\": %.1f MHz (scaled from %.1f MHz), "
+ "%.1f kHz, %.1f Hz%s%s\n",
+ uprefix, prefix, p->name, p->Clock / 1000.0,
+ p->SynthClock / 1000.0, hsync, refresh, desc, desc2);
+ }
+ if (hsync != 0 && refresh != 0)
+ PrintModeline(scrp->scrnIndex,p);
+ p = p->next;
+ } while (p != NULL && p != scrp->modes);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Module.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Module.h
new file mode 100644
index 000000000..84c3e32c3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Module.h
@@ -0,0 +1,226 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Module.h,v 1.37 2003/08/24 17:36:54 dawes Exp $ */
+
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains the parts of the loader interface that are visible
+ * to modules. This is the only loader-related header that modules should
+ * include.
+ *
+ * It should include a bare minimum of other headers.
+ *
+ * Longer term, the module/loader code should probably live directly under
+ * Xserver/.
+ *
+ * XXX This file arguably belongs in xfree86/loader/.
+ */
+
+#ifndef _XF86MODULE_H
+#define _XF86MODULE_H
+
+#include "misc.h"
+#include "xf86Version.h"
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
+typedef enum {
+ LD_RESOLV_IFDONE = 0, /* only check if no more
+ delays pending */
+ LD_RESOLV_NOW = 1, /* finish one delay step */
+ LD_RESOLV_FORCE = 2 /* force checking... */
+} LoaderResolveOptions;
+
+#define DEFAULT_LIST ((char *)-1)
+
+/* This indicates a special module that doesn't have the usual entry point */
+#define EXTERN_MODULE ((pointer)-1)
+
+/* Built-in ABI classes. These definitions must not be changed. */
+#define ABI_CLASS_NONE NULL
+#define ABI_CLASS_ANSIC "X.Org ANSI C Emulation"
+#define ABI_CLASS_VIDEODRV "X.Org Video Driver"
+#define ABI_CLASS_XINPUT "X.Org XInput driver"
+#define ABI_CLASS_EXTENSION "X.Org Server Extension"
+#define ABI_CLASS_FONT "X.Org Font Renderer"
+
+#define ABI_MINOR_MASK 0x0000FFFF
+#define ABI_MAJOR_MASK 0xFFFF0000
+#define GET_ABI_MINOR(v) ((v) & ABI_MINOR_MASK)
+#define GET_ABI_MAJOR(v) (((v) & ABI_MAJOR_MASK) >> 16)
+#define SET_ABI_VERSION(maj, min) \
+ ((((maj) << 16) & ABI_MAJOR_MASK) | ((min) & ABI_MINOR_MASK))
+
+/*
+ * ABI versions. Each version has a major and minor revision. Modules
+ * using lower minor revisions must work with servers of a higher minor
+ * revision. There is no compatibility between different major revisions.
+ * Whenever the ABI_ANSIC_VERSION is changed, the others must also be
+ * changed. The minor revision mask is 0x0000FFFF and the major revision
+ * mask is 0xFFFF0000.
+ */
+#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 2)
+#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(0, 8)
+#define ABI_XINPUT_VERSION SET_ABI_VERSION(0, 5)
+#define ABI_EXTENSION_VERSION SET_ABI_VERSION(0, 2)
+#define ABI_FONT_VERSION SET_ABI_VERSION(0, 4)
+
+#define MODINFOSTRING1 0xef23fdc5
+#define MODINFOSTRING2 0x10dc023a
+
+#ifndef MODULEVENDORSTRING
+#ifndef __OS2ELF__
+#define MODULEVENDORSTRING "X.Org Foundation"
+#else
+#define MODULEVENDORSTRING "X.Org Foundation - OS2"
+#endif
+#endif
+
+/* Error return codes for errmaj. New codes must only be added at the end. */
+typedef enum {
+ LDR_NOERROR = 0,
+ LDR_NOMEM, /* memory allocation failed */
+ LDR_NOENT, /* Module file does not exist */
+ LDR_NOSUBENT, /* pre-requsite file to be sub-loaded does not exist */
+ LDR_NOSPACE, /* internal module array full */
+ LDR_NOMODOPEN, /* module file could not be opened (check errmin) */
+ LDR_UNKTYPE, /* file is not a recognized module type */
+ LDR_NOLOAD, /* type specific loader failed */
+ LDR_ONCEONLY, /* Module should only be loaded once (not an error) */
+ LDR_NOPORTOPEN, /* could not open port (check errmin) */
+ LDR_NOHARDWARE, /* could not query/initialize the hardware device */
+ LDR_MISMATCH, /* the module didn't match the spec'd requirments */
+ LDR_BADUSAGE, /* LoadModule is called with bad arguments */
+ LDR_INVALID, /* The module doesn't have a valid ModuleData object */
+ LDR_BADOS, /* The module doesn't support the OS */
+ LDR_MODSPECIFIC /* A module-specific error in the SetupProc */
+} LoaderErrorCode;
+
+/*
+ * Some common module classes. The moduleclass can be used to identify
+ * that modules loaded are of the correct type. This is a finer
+ * classification than the ABI classes even though the default set of
+ * classes have the same names. For example, not all modules that require
+ * the video driver ABI are themselves video drivers.
+ */
+#define MOD_CLASS_NONE NULL
+#define MOD_CLASS_VIDEODRV "X.Org Video Driver"
+#define MOD_CLASS_XINPUT "X.Org XInput Driver"
+#define MOD_CLASS_FONT "X.Org Font Renderer"
+#define MOD_CLASS_EXTENSION "X.Org Server Extension"
+
+/* This structure is expected to be returned by the initfunc */
+typedef struct {
+ const char * modname; /* name of module, e.g. "foo" */
+ const char * vendor; /* vendor specific string */
+ CARD32 _modinfo1_; /* constant MODINFOSTRING1/2 to find */
+ CARD32 _modinfo2_; /* infoarea with a binary editor or sign tool */
+ CARD32 xf86version; /* contains XF86_VERSION_CURRENT */
+ CARD8 majorversion; /* module-specific major version */
+ CARD8 minorversion; /* module-specific minor version */
+ CARD16 patchlevel; /* module-specific patch level */
+ const char * abiclass; /* ABI class that the module uses */
+ CARD32 abiversion; /* ABI version */
+ const char * moduleclass; /* module class description */
+ CARD32 checksum[4]; /* contains a digital signature of the */
+ /* version info structure */
+} XF86ModuleVersionInfo;
+
+/*
+ * This structure can be used to callers of LoadModule and LoadSubModule to
+ * specify version and/or ABI requirements.
+ */
+typedef struct {
+ CARD8 majorversion; /* module-specific major version */
+ CARD8 minorversion; /* moudle-specific minor version */
+ CARD16 patchlevel; /* module-specific patch level */
+ const char * abiclass; /* ABI class that the module uses */
+ CARD32 abiversion; /* ABI version */
+ const char * moduleclass; /* module class */
+} XF86ModReqInfo;
+
+/* values to indicate unspecified fields in XF86ModReqInfo. */
+#define MAJOR_UNSPEC 0xFF
+#define MINOR_UNSPEC 0xFF
+#define PATCH_UNSPEC 0xFFFF
+#define ABI_VERS_UNSPEC 0xFFFFFFFF
+
+#define MODULE_VERSION_NUMERIC(maj, min, patch) \
+ ((((maj) & 0xFF) << 24) | (((min) & 0xFF) << 16) | (patch & 0xFFFF))
+#define GET_MODULE_MAJOR_VERSION(vers) (((vers) >> 24) & 0xFF)
+#define GET_MODULE_MINOR_VERSION(vers) (((vers) >> 16) & 0xFF)
+#define GET_MODULE_PATCHLEVEL(vers) ((vers) & 0xFFFF)
+
+#define INITARGS void
+
+typedef void (*InitExtension)(INITARGS);
+
+typedef struct {
+ InitExtension initFunc;
+ const char * name;
+ Bool *disablePtr;
+ InitExtension setupFunc;
+ const char ** initDependencies;
+} ExtensionModule;
+
+extern ExtensionModule *ExtensionModuleList;
+
+/* Prototypes for Loader functions that are exported to modules */
+#ifndef IN_LOADER
+/* Prototypes with opaque pointers for use by modules */
+pointer LoadSubModule(pointer, const char *, const char **,
+ const char **, pointer, const XF86ModReqInfo *,
+ int *, int *);
+void UnloadSubModule(pointer);
+void LoadFont(pointer);
+void UnloadModule (pointer);
+#endif
+pointer LoaderSymbol(const char *);
+char **LoaderListDirs(const char **, const char **);
+void LoaderFreeDirList(char **);
+void LoaderErrorMsg(const char *, const char *, int, int);
+void LoadExtension(ExtensionModule *, Bool);
+void LoaderRefSymLists(const char **, ...);
+void LoaderRefSymbols(const char *, ...);
+void LoaderReqSymLists(const char **, ...);
+void LoaderReqSymbols(const char *, ...);
+int LoaderCheckUnresolved(int);
+void LoaderGetOS(const char **name, int *major, int *minor, int *teeny);
+
+typedef pointer (*ModuleSetupProc)(pointer, pointer, int *, int *);
+typedef void (*ModuleTearDownProc)(pointer);
+#define MODULESETUPPROTO(func) pointer func(pointer, pointer, int*, int*)
+#define MODULETEARDOWNPROTO(func) void func(pointer)
+
+typedef struct {
+ XF86ModuleVersionInfo * vers;
+ ModuleSetupProc setup;
+ ModuleTearDownProc teardown;
+} XF86ModuleData;
+
+#endif /* _XF86STR_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Opt.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Opt.h
new file mode 100644
index 000000000..718732353
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Opt.h
@@ -0,0 +1,114 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Opt.h,v 1.15 2003/10/08 14:30:38 dawes Exp $ */
+
+/*
+ * Copyright (c) 1998-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* Option handling things that ModuleSetup procs can use */
+
+#ifndef _XF86_OPT_H_
+#define _XF86_OPT_H_
+
+typedef struct {
+ double freq;
+ int units;
+} OptFrequency;
+
+typedef union {
+ unsigned long num;
+ char * str;
+ double realnum;
+ Bool bool;
+ OptFrequency freq;
+} ValueUnion;
+
+typedef enum {
+ OPTV_NONE = 0,
+ OPTV_INTEGER,
+ OPTV_STRING, /* a non-empty string */
+ OPTV_ANYSTR, /* Any string, including an empty one */
+ OPTV_REAL,
+ OPTV_BOOLEAN,
+ OPTV_FREQ
+} OptionValueType;
+
+typedef enum {
+ OPTUNITS_HZ = 1,
+ OPTUNITS_KHZ,
+ OPTUNITS_MHZ
+} OptFreqUnits;
+
+typedef struct {
+ int token;
+ const char* name;
+ OptionValueType type;
+ ValueUnion value;
+ Bool found;
+} OptionInfoRec, *OptionInfoPtr;
+
+int xf86SetIntOption(pointer optlist, const char *name, int deflt);
+double xf86SetRealOption(pointer optlist, const char *name, double deflt);
+char *xf86SetStrOption(pointer optlist, const char *name, char *deflt);
+int xf86SetBoolOption(pointer list, const char *name, int deflt );
+int xf86CheckIntOption(pointer optlist, const char *name, int deflt);
+double xf86CheckRealOption(pointer optlist, const char *name, double deflt);
+char *xf86CheckStrOption(pointer optlist, const char *name, char *deflt);
+int xf86CheckBoolOption(pointer list, const char *name, int deflt );
+pointer xf86AddNewOption(pointer head, const char *name, const char *val );
+pointer xf86NewOption(char *name, char *value );
+pointer xf86NextOption(pointer list );
+pointer xf86OptionListCreate(const char **options, int count, int used);
+pointer xf86OptionListMerge(pointer head, pointer tail);
+void xf86OptionListFree(pointer opt);
+char *xf86OptionName(pointer opt);
+char *xf86OptionValue(pointer opt);
+void xf86OptionListReport(pointer parm);
+pointer xf86FindOption(pointer options, const char *name);
+char *xf86FindOptionValue(pointer options, const char *name);
+void xf86MarkOptionUsed(pointer option);
+void xf86MarkOptionUsedByName(pointer options, const char *name);
+Bool xf86CheckIfOptionUsed(pointer option);
+Bool xf86CheckIfOptionUsedByName(pointer options, const char *name);
+void xf86ShowUnusedOptions(int scrnIndex, pointer options);
+void xf86ProcessOptions(int scrnIndex, pointer options, OptionInfoPtr optinfo);
+OptionInfoPtr xf86TokenToOptinfo(const OptionInfoRec *table, int token);
+const char *xf86TokenToOptName(const OptionInfoRec *table, int token);
+Bool xf86IsOptionSet(const OptionInfoRec *table, int token);
+char *xf86GetOptValString(const OptionInfoRec *table, int token);
+Bool xf86GetOptValInteger(const OptionInfoRec *table, int token, int *value);
+Bool xf86GetOptValULong(const OptionInfoRec *table, int token, unsigned long *value);
+Bool xf86GetOptValReal(const OptionInfoRec *table, int token, double *value);
+Bool xf86GetOptValFreq(const OptionInfoRec *table, int token,
+ OptFreqUnits expectedUnits, double *value);
+Bool xf86GetOptValBool(const OptionInfoRec *table, int token, Bool *value);
+Bool xf86ReturnOptValBool(const OptionInfoRec *table, int token, Bool def);
+int xf86NameCmp(const char *s1, const char *s2);
+char *xf86NormalizeName(const char *s);
+pointer xf86ReplaceIntOption(pointer optlist, const char *name, const int val);
+pointer xf86ReplaceRealOption(pointer optlist, const char *name, const double val);
+pointer xf86ReplaceBoolOption(pointer optlist, const char *name, const Bool val);
+pointer xf86ReplaceStrOption(pointer optlist, const char *name, const char* val);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Option.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Option.c
new file mode 100644
index 000000000..9bffdee70
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Option.c
@@ -0,0 +1,884 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Option.c,v 1.29 2003/10/18 12:34:19 dawes Exp $ */
+/*
+ * Copyright (c) 1998-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * Author: David Dawes <dawes@xfree86.org>
+ *
+ * This file includes public option handling functions.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Xinput.h"
+#include "xf86Optrec.h"
+
+static Bool ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
+ Bool markUsed);
+
+/*
+ * xf86CollectOptions collects the options from each of the config file
+ * sections used by the screen and puts the combined list in pScrn->options.
+ * This function requires that the following have been initialised:
+ *
+ * pScrn->confScreen
+ * pScrn->Entities[i]->device
+ * pScrn->display
+ * pScrn->monitor
+ *
+ * The extraOpts parameter may optionally contain a list of additional options
+ * to include.
+ *
+ * The order of precedence for options is:
+ *
+ * extraOpts, display, confScreen, monitor, device
+ */
+
+void
+xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts)
+{
+ XF86OptionPtr tmp;
+ XF86OptionPtr extras = (XF86OptionPtr)extraOpts;
+ GDevPtr device;
+
+ int i;
+
+ pScrn->options = NULL;
+
+ for (i=pScrn->numEntities - 1; i >= 0; i--) {
+ device = xf86GetDevFromEntity(pScrn->entityList[i],
+ pScrn->entityInstanceList[i]);
+ if (device && device->options) {
+ tmp = xf86optionListDup(device->options);
+ if (pScrn->options)
+ xf86optionListMerge(pScrn->options,tmp);
+ else
+ pScrn->options = tmp;
+ }
+ }
+ if (pScrn->monitor->options) {
+ tmp = xf86optionListDup(pScrn->monitor->options);
+ if (pScrn->options)
+ pScrn->options = xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
+ }
+ if (pScrn->confScreen->options) {
+ tmp = xf86optionListDup(pScrn->confScreen->options);
+ if (pScrn->options)
+ pScrn->options = xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
+ }
+ if (pScrn->display->options) {
+ tmp = xf86optionListDup(pScrn->display->options);
+ if (pScrn->options)
+ pScrn->options = xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
+ }
+ if (extras) {
+ tmp = xf86optionListDup(extras);
+ if (pScrn->options)
+ pScrn->options = xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
+ }
+}
+
+/*
+ * xf86CollectInputOptions collects the options for an InputDevice.
+ * This function requires that the following has been initialised:
+ *
+ * pInfo->conf_idev
+ *
+ * The extraOpts parameter may optionally contain a list of additional options
+ * to include.
+ *
+ * The order of precedence for options is:
+ *
+ * extraOpts, pInfo->conf_idev->extraOptions,
+ * pInfo->conf_idev->commonOptions, defaultOpts
+ */
+
+void
+xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts,
+ pointer extraOpts)
+{
+ XF86OptionPtr tmp;
+ XF86OptionPtr extras = (XF86OptionPtr)extraOpts;
+
+ pInfo->options = NULL;
+ if (defaultOpts) {
+ pInfo->options = xf86OptionListCreate(defaultOpts, -1, 0);
+ }
+ if (pInfo->conf_idev->commonOptions) {
+ tmp = xf86optionListDup(pInfo->conf_idev->commonOptions);
+ if (pInfo->options)
+ pInfo->options = xf86optionListMerge(pInfo->options, tmp);
+ else
+ pInfo->options = tmp;
+ }
+ if (pInfo->conf_idev->extraOptions) {
+ tmp = xf86optionListDup(pInfo->conf_idev->extraOptions);
+ if (pInfo->options)
+ pInfo->options = xf86optionListMerge(pInfo->options, tmp);
+ else
+ pInfo->options = tmp;
+ }
+ if (extras) {
+ tmp = xf86optionListDup(extras);
+ if (pInfo->options)
+ pInfo->options = xf86optionListMerge(pInfo->options, tmp);
+ else
+ pInfo->options = tmp;
+ }
+}
+
+/* Created for new XInput stuff -- essentially extensions to the parser */
+
+static int
+LookupIntOption(pointer optlist, const char *name, int deflt, Bool markUsed)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_INTEGER;
+ if (ParseOptionValue(-1, optlist, &o, markUsed))
+ deflt = o.value.num;
+ return deflt;
+}
+
+
+static double
+LookupRealOption(pointer optlist, const char *name, double deflt,
+ Bool markUsed)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_REAL;
+ if (ParseOptionValue(-1, optlist, &o, markUsed))
+ deflt = o.value.realnum;
+ return deflt;
+}
+
+
+static char *
+LookupStrOption(pointer optlist, const char *name, char *deflt, Bool markUsed)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_STRING;
+ if (ParseOptionValue(-1, optlist, &o, markUsed))
+ deflt = o.value.str;
+ if (deflt)
+ return xstrdup(deflt);
+ else
+ return NULL;
+}
+
+
+static int
+LookupBoolOption(pointer optlist, const char *name, int deflt, Bool markUsed)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_BOOLEAN;
+ if (ParseOptionValue(-1, optlist, &o, markUsed))
+ deflt = o.value.bool;
+ return deflt;
+}
+
+/* These xf86Set* functions are intended for use by non-screen specific code */
+
+int
+xf86SetIntOption(pointer optlist, const char *name, int deflt)
+{
+ return LookupIntOption(optlist, name, deflt, TRUE);
+}
+
+
+double
+xf86SetRealOption(pointer optlist, const char *name, double deflt)
+{
+ return LookupRealOption(optlist, name, deflt, TRUE);
+}
+
+
+char *
+xf86SetStrOption(pointer optlist, const char *name, char *deflt)
+{
+ return LookupStrOption(optlist, name, deflt, TRUE);
+}
+
+
+int
+xf86SetBoolOption(pointer optlist, const char *name, int deflt)
+{
+ return LookupBoolOption(optlist, name, deflt, TRUE);
+}
+
+/*
+ * These are like the Set*Option functions, but they don't mark the options
+ * as used.
+ */
+int
+xf86CheckIntOption(pointer optlist, const char *name, int deflt)
+{
+ return LookupIntOption(optlist, name, deflt, FALSE);
+}
+
+
+double
+xf86CheckRealOption(pointer optlist, const char *name, double deflt)
+{
+ return LookupRealOption(optlist, name, deflt, FALSE);
+}
+
+
+char *
+xf86CheckStrOption(pointer optlist, const char *name, char *deflt)
+{
+ return LookupStrOption(optlist, name, deflt, FALSE);
+}
+
+
+int
+xf86CheckBoolOption(pointer optlist, const char *name, int deflt)
+{
+ return LookupBoolOption(optlist, name, deflt, FALSE);
+}
+
+/*
+ * addNewOption() has the required property of replacing the option value
+ * if the option is already present.
+ */
+pointer
+xf86ReplaceIntOption(pointer optlist, const char *name, const int val)
+{
+ char *tmp = xnfalloc(16);
+ sprintf(tmp,"%i",val);
+ return xf86AddNewOption(optlist,name,tmp);
+}
+
+pointer
+xf86ReplaceRealOption(pointer optlist, const char *name, const double val)
+{
+ char *tmp = xnfalloc(32);
+ snprintf(tmp,32,"%f",val);
+ return xf86AddNewOption(optlist,name,tmp);
+}
+
+pointer
+xf86ReplaceBoolOption(pointer optlist, const char *name, const Bool val)
+{
+ return xf86AddNewOption(optlist,name,val?"True":"False");
+}
+
+pointer
+xf86ReplaceStrOption(pointer optlist, const char *name, const char* val)
+{
+ return xf86AddNewOption(optlist,name,val);
+}
+
+pointer
+xf86AddNewOption(pointer head, const char *name, const char *val)
+{
+ /* XXX These should actually be allocated in the parser library. */
+ char *tmp = strdup(val);
+ char *tmp_name = strdup(name);
+
+ return xf86addNewOption(head, tmp_name, tmp);
+}
+
+
+pointer
+xf86NewOption(char *name, char *value)
+{
+ return xf86newOption(name, value);
+}
+
+
+pointer
+xf86NextOption(pointer list)
+{
+ return xf86nextOption(list);
+}
+
+pointer
+xf86OptionListCreate(const char **options, int count, int used)
+{
+ return xf86optionListCreate(options, count, used);
+}
+
+pointer
+xf86OptionListMerge(pointer head, pointer tail)
+{
+ return xf86optionListMerge(head, tail);
+}
+
+void
+xf86OptionListFree(pointer opt)
+{
+ xf86optionListFree(opt);
+}
+
+char *
+xf86OptionName(pointer opt)
+{
+ return xf86optionName(opt);
+}
+
+char *
+xf86OptionValue(pointer opt)
+{
+ return xf86optionValue(opt);
+}
+
+void
+xf86OptionListReport(pointer parm)
+{
+ XF86OptionPtr opts = parm;
+
+ while(opts) {
+ if (xf86optionValue(opts))
+ xf86ErrorFVerb(5, "\tOption \"%s\" \"%s\"\n",
+ xf86optionName(opts), xf86optionValue(opts));
+ else
+ xf86ErrorFVerb( 5, "\tOption \"%s\"\n", xf86optionName(opts));
+ opts = xf86nextOption(opts);
+ }
+}
+
+/* End of XInput-caused section */
+
+pointer
+xf86FindOption(pointer options, const char *name)
+{
+ return xf86findOption(options, name);
+}
+
+
+char *
+xf86FindOptionValue(pointer options, const char *name)
+{
+ return xf86findOptionValue(options, name);
+}
+
+
+void
+xf86MarkOptionUsed(pointer option)
+{
+ if (option != NULL)
+ ((XF86OptionPtr)option)->opt_used = TRUE;
+}
+
+
+void
+xf86MarkOptionUsedByName(pointer options, const char *name)
+{
+ XF86OptionPtr opt;
+
+ opt = xf86findOption(options, name);
+ if (opt != NULL)
+ opt->opt_used = TRUE;
+}
+
+Bool
+xf86CheckIfOptionUsed(pointer option)
+{
+ if (option != NULL)
+ return ((XF86OptionPtr)option)->opt_used;
+ else
+ return FALSE;
+}
+
+Bool
+xf86CheckIfOptionUsedByName(pointer options, const char *name)
+{
+ XF86OptionPtr opt;
+
+ opt = xf86findOption(options, name);
+ if (opt != NULL)
+ return opt->opt_used;
+ else
+ return FALSE;
+}
+
+void
+xf86ShowUnusedOptions(int scrnIndex, pointer options)
+{
+ XF86OptionPtr opt = options;
+
+ while (opt) {
+ if (opt->opt_name && !opt->opt_used) {
+ xf86DrvMsg(scrnIndex, X_WARNING, "Option \"%s\" is not used\n",
+ opt->opt_name);
+ }
+ opt = opt->list.next;
+ }
+}
+
+
+static Bool
+GetBoolValue(OptionInfoPtr p, const char *s)
+{
+ if (*s == '\0') {
+ p->value.bool = TRUE;
+ } else {
+ if (xf86NameCmp(s, "1") == 0)
+ p->value.bool = TRUE;
+ else if (xf86NameCmp(s, "on") == 0)
+ p->value.bool = TRUE;
+ else if (xf86NameCmp(s, "true") == 0)
+ p->value.bool = TRUE;
+ else if (xf86NameCmp(s, "yes") == 0)
+ p->value.bool = TRUE;
+ else if (xf86NameCmp(s, "0") == 0)
+ p->value.bool = FALSE;
+ else if (xf86NameCmp(s, "off") == 0)
+ p->value.bool = FALSE;
+ else if (xf86NameCmp(s, "false") == 0)
+ p->value.bool = FALSE;
+ else if (xf86NameCmp(s, "no") == 0)
+ p->value.bool = FALSE;
+ else
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static Bool
+ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
+ Bool markUsed)
+{
+ char *s, *end;
+ Bool wasUsed = FALSE;
+
+ if ((s = xf86findOptionValue(options, p->name)) != NULL) {
+ if (markUsed) {
+ wasUsed = xf86CheckIfOptionUsedByName(options, p->name);
+ xf86MarkOptionUsedByName(options, p->name);
+ }
+ switch (p->type) {
+ case OPTV_INTEGER:
+ if (*s == '\0') {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires an integer value\n",
+ p->name);
+ p->found = FALSE;
+ } else {
+ p->value.num = strtoul(s, &end, 0);
+ if (*end == '\0') {
+ p->found = TRUE;
+ } else {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires an integer value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ }
+ break;
+ case OPTV_STRING:
+ if (*s == '\0') {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires an string value\n",
+ p->name);
+ p->found = FALSE;
+ } else {
+ p->value.str = s;
+ p->found = TRUE;
+ }
+ break;
+ case OPTV_ANYSTR:
+ p->value.str = s;
+ p->found = TRUE;
+ break;
+ case OPTV_REAL:
+ if (*s == '\0') {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a floating point value\n",
+ p->name);
+ p->found = FALSE;
+ } else {
+ p->value.realnum = strtod(s, &end);
+ if (*end == '\0') {
+ p->found = TRUE;
+ } else {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a floating point value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ }
+ break;
+ case OPTV_BOOLEAN:
+ if (GetBoolValue(p, s)) {
+ p->found = TRUE;
+ } else {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a boolean value\n", p->name);
+ p->found = FALSE;
+ }
+ break;
+ case OPTV_FREQ:
+ if (*s == '\0') {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a frequency value\n",
+ p->name);
+ p->found = FALSE;
+ } else {
+ double freq = strtod(s, &end);
+ int units = 0;
+
+ if (end != s) {
+ p->found = TRUE;
+ if (!xf86NameCmp(end, "Hz"))
+ units = 1;
+ else if (!xf86NameCmp(end, "kHz") ||
+ !xf86NameCmp(end, "k"))
+ units = 1000;
+ else if (!xf86NameCmp(end, "MHz") ||
+ !xf86NameCmp(end, "M"))
+ units = 1000000;
+ else {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a frequency value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ if (p->found)
+ freq *= (double)units;
+ } else {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a frequency value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ if (p->found) {
+ p->value.freq.freq = freq;
+ p->value.freq.units = units;
+ }
+ }
+ break;
+ case OPTV_NONE:
+ /* Should never get here */
+ p->found = FALSE;
+ break;
+ }
+ if (p->found && markUsed) {
+ int verb = 2;
+ if (wasUsed)
+ verb = 4;
+ xf86DrvMsgVerb(scrnIndex, X_CONFIG, verb, "Option \"%s\"", p->name);
+ if (!(p->type == OPTV_BOOLEAN && *s == 0)) {
+ xf86ErrorFVerb(verb, " \"%s\"", s);
+ }
+ xf86ErrorFVerb(verb, "\n");
+ }
+ } else if (p->type == OPTV_BOOLEAN) {
+ /* Look for matches with options with or without a "No" prefix. */
+ char *n, *newn;
+ OptionInfoRec opt;
+
+ n = xf86NormalizeName(p->name);
+ if (!n) {
+ p->found = FALSE;
+ return FALSE;
+ }
+ if (strncmp(n, "no", 2) == 0) {
+ newn = n + 2;
+ } else {
+ xfree(n);
+ n = xalloc(strlen(p->name) + 2 + 1);
+ if (!n) {
+ p->found = FALSE;
+ return FALSE;
+ }
+ strcpy(n, "No");
+ strcat(n, p->name);
+ newn = n;
+ }
+ if ((s = xf86findOptionValue(options, newn)) != NULL) {
+ if (markUsed)
+ xf86MarkOptionUsedByName(options, newn);
+ if (GetBoolValue(&opt, s)) {
+ p->value.bool = !opt.value.bool;
+ p->found = TRUE;
+ } else {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a boolean value\n", newn);
+ p->found = FALSE;
+ }
+ } else {
+ p->found = FALSE;
+ }
+ if (p->found && markUsed) {
+ xf86DrvMsgVerb(scrnIndex, X_CONFIG, 2, "Option \"%s\"", newn);
+ if (*s != 0) {
+ xf86ErrorFVerb(2, " \"%s\"", s);
+ }
+ xf86ErrorFVerb(2, "\n");
+ }
+ xfree(n);
+ } else {
+ p->found = FALSE;
+ }
+ return p->found;
+}
+
+
+void
+xf86ProcessOptions(int scrnIndex, pointer options, OptionInfoPtr optinfo)
+{
+ OptionInfoPtr p;
+
+ for (p = optinfo; p->name != NULL; p++) {
+ ParseOptionValue(scrnIndex, options, p, TRUE);
+ }
+}
+
+
+OptionInfoPtr
+xf86TokenToOptinfo(const OptionInfoRec *table, int token)
+{
+ const OptionInfoRec *p, *match = NULL, *set = NULL;
+
+ if (!table) {
+ ErrorF("xf86TokenToOptinfo: table is NULL\n");
+ return NULL;
+ }
+
+ for (p = table; p->token >= 0; p++) {
+ if (p->token == token) {
+ match = p;
+ if (p->found)
+ set = p;
+ }
+ }
+
+ if (set)
+ return (OptionInfoPtr)set;
+ else if (match)
+ return (OptionInfoPtr)match;
+ else
+ return NULL;
+}
+
+
+const char *
+xf86TokenToOptName(const OptionInfoRec *table, int token)
+{
+ const OptionInfoRec *p;
+
+ p = xf86TokenToOptinfo(table, token);
+ return p->name;
+}
+
+
+Bool
+xf86IsOptionSet(const OptionInfoRec *table, int token)
+{
+ OptionInfoPtr p;
+
+ p = xf86TokenToOptinfo(table, token);
+ return (p && p->found);
+}
+
+
+char *
+xf86GetOptValString(const OptionInfoRec *table, int token)
+{
+ OptionInfoPtr p;
+
+ p = xf86TokenToOptinfo(table, token);
+ if (p && p->found)
+ return p->value.str;
+ else
+ return NULL;
+}
+
+
+Bool
+xf86GetOptValInteger(const OptionInfoRec *table, int token, int *value)
+{
+ OptionInfoPtr p;
+
+ p = xf86TokenToOptinfo(table, token);
+ if (p && p->found) {
+ *value = p->value.num;
+ return TRUE;
+ } else
+ return FALSE;
+}
+
+
+Bool
+xf86GetOptValULong(const OptionInfoRec *table, int token, unsigned long *value)
+{
+ OptionInfoPtr p;
+
+ p = xf86TokenToOptinfo(table, token);
+ if (p && p->found) {
+ *value = p->value.num;
+ return TRUE;
+ } else
+ return FALSE;
+}
+
+
+Bool
+xf86GetOptValReal(const OptionInfoRec *table, int token, double *value)
+{
+ OptionInfoPtr p;
+
+ p = xf86TokenToOptinfo(table, token);
+ if (p && p->found) {
+ *value = p->value.realnum;
+ return TRUE;
+ } else
+ return FALSE;
+}
+
+
+Bool
+xf86GetOptValFreq(const OptionInfoRec *table, int token,
+ OptFreqUnits expectedUnits, double *value)
+{
+ OptionInfoPtr p;
+
+ p = xf86TokenToOptinfo(table, token);
+ if (p && p->found) {
+ if (p->value.freq.units > 0) {
+ /* Units give, so the scaling is known. */
+ switch (expectedUnits) {
+ case OPTUNITS_HZ:
+ *value = p->value.freq.freq;
+ break;
+ case OPTUNITS_KHZ:
+ *value = p->value.freq.freq / 1000.0;
+ break;
+ case OPTUNITS_MHZ:
+ *value = p->value.freq.freq / 1000000.0;
+ break;
+ }
+ } else {
+ /* No units given, so try to guess the scaling. */
+ switch (expectedUnits) {
+ case OPTUNITS_HZ:
+ *value = p->value.freq.freq;
+ break;
+ case OPTUNITS_KHZ:
+ if (p->value.freq.freq > 1000.0)
+ *value = p->value.freq.freq / 1000.0;
+ else
+ *value = p->value.freq.freq;
+ break;
+ case OPTUNITS_MHZ:
+ if (p->value.freq.freq > 1000000.0)
+ *value = p->value.freq.freq / 1000000.0;
+ else if (p->value.freq.freq > 1000.0)
+ *value = p->value.freq.freq / 1000.0;
+ else
+ *value = p->value.freq.freq;
+ }
+ }
+ return TRUE;
+ } else
+ return FALSE;
+}
+
+
+Bool
+xf86GetOptValBool(const OptionInfoRec *table, int token, Bool *value)
+{
+ OptionInfoPtr p;
+
+ p = xf86TokenToOptinfo(table, token);
+ if (p && p->found) {
+ *value = p->value.bool;
+ return TRUE;
+ } else
+ return FALSE;
+}
+
+
+Bool
+xf86ReturnOptValBool(const OptionInfoRec *table, int token, Bool def)
+{
+ OptionInfoPtr p;
+
+ p = xf86TokenToOptinfo(table, token);
+ if (p && p->found) {
+ return p->value.bool;
+ } else
+ return def;
+}
+
+
+int
+xf86NameCmp(const char *s1, const char *s2)
+{
+ return xf86nameCompare(s1, s2);
+}
+
+char *
+xf86NormalizeName(const char *s)
+{
+ char *ret, *q;
+ const char *p;
+
+ if (s == NULL)
+ return NULL;
+
+ ret = xalloc(strlen(s) + 1);
+ for (p = s, q = ret; *p != 0; p++) {
+ switch (*p) {
+ case '_':
+ case ' ':
+ case '\t':
+ continue;
+ default:
+ if (isupper(*p))
+ *q++ = tolower(*p);
+ else
+ *q++ = *p;
+ }
+ }
+ *q = '\0';
+ return ret;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86PM.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86PM.c
new file mode 100644
index 000000000..0262be3df
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86PM.c
@@ -0,0 +1,225 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PM.c,v 3.9 2003/08/24 17:36:54 dawes Exp $ */
+/*
+ * Copyright (c) 2000-2002 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Xinput.h"
+
+int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num) = NULL;
+pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event) = NULL;
+
+static Bool suspended = FALSE;
+
+static int
+eventName(pmEvent event, char **str)
+{
+ switch(event) {
+ case XF86_APM_SYS_STANDBY: *str="System Standby Request"; return 0;
+ case XF86_APM_SYS_SUSPEND: *str="System Suspend Request"; return 0;
+ case XF86_APM_CRITICAL_SUSPEND: *str="Critical Suspend"; return 0;
+ case XF86_APM_USER_STANDBY: *str="User System Standby Request"; return 0;
+ case XF86_APM_USER_SUSPEND: *str="User System Suspend Request"; return 0;
+ case XF86_APM_STANDBY_RESUME: *str="System Standby Resume"; return 0;
+ case XF86_APM_NORMAL_RESUME: *str="Normal Resume System"; return 0;
+ case XF86_APM_CRITICAL_RESUME: *str="Critical Resume System"; return 0;
+ case XF86_APM_LOW_BATTERY: *str="Battery Low"; return 3;
+ case XF86_APM_POWER_STATUS_CHANGE: *str="Power Status Change";return 3;
+ case XF86_APM_UPDATE_TIME: *str="Update Time";return 3;
+ case XF86_APM_CAPABILITY_CHANGED: *str="Capability Changed"; return 3;
+ case XF86_APM_STANDBY_FAILED: *str="Standby Request Failed"; return 0;
+ case XF86_APM_SUSPEND_FAILED: *str="Suspend Request Failed"; return 0;
+ default: *str="Unknown Event"; return 0;
+ }
+}
+
+static void
+suspend (pmEvent event, Bool undo)
+{
+ int i;
+ InputInfoPtr pInfo;
+
+ xf86inSuspend = TRUE;
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86EnableAccess(xf86Screens[i]);
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
+ }
+#if !defined(__EMX__)
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ DisableDevice(pInfo->dev);
+ pInfo = pInfo->next;
+ }
+#endif
+ xf86EnterServerState(SETUP);
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86EnableAccess(xf86Screens[i]);
+ if (xf86Screens[i]->PMEvent)
+ xf86Screens[i]->PMEvent(i,event,undo);
+ else {
+ xf86Screens[i]->LeaveVT(i, 0);
+ xf86Screens[i]->vtSema = FALSE;
+ }
+ }
+ xf86AccessLeave();
+ xf86AccessLeaveState();
+}
+
+static void
+resume(pmEvent event, Bool undo)
+{
+ int i;
+ InputInfoPtr pInfo;
+
+ xf86AccessEnter();
+ xf86EnterServerState(SETUP);
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86EnableAccess(xf86Screens[i]);
+ if (xf86Screens[i]->PMEvent)
+ xf86Screens[i]->PMEvent(i,event,undo);
+ else {
+ xf86Screens[i]->vtSema = TRUE;
+ xf86Screens[i]->EnterVT(i, 0);
+ }
+ }
+ xf86EnterServerState(OPERATING);
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86EnableAccess(xf86Screens[i]);
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
+ }
+ SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset);
+#if !defined(__EMX__)
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ EnableDevice(pInfo->dev);
+ pInfo = pInfo->next;
+ }
+#endif
+ xf86inSuspend = FALSE;
+}
+
+static void
+DoApmEvent(pmEvent event, Bool undo)
+{
+ /*
+ * we leave that as a global function for now. I don't know if
+ * this might cause problems in the future. It is a global server
+ * variable therefore it needs to be in a server info structure
+ */
+ int i, setup = 0;
+
+ switch(event) {
+#if 0
+ case XF86_APM_SYS_STANDBY:
+ case XF86_APM_USER_STANDBY:
+#endif
+ case XF86_APM_SYS_SUSPEND:
+ case XF86_APM_CRITICAL_SUSPEND: /*do we want to delay a critical suspend?*/
+ case XF86_APM_USER_SUSPEND:
+ /* should we do this ? */
+ if (!undo && !suspended) {
+ suspend(event,undo);
+ suspended = TRUE;
+ } else if (undo && suspended) {
+ resume(event,undo);
+ suspended = FALSE;
+ }
+ break;
+#if 0
+ case XF86_APM_STANDBY_RESUME:
+#endif
+ case XF86_APM_NORMAL_RESUME:
+ case XF86_APM_CRITICAL_RESUME:
+ if (suspended) {
+ resume(event,undo);
+ suspended = FALSE;
+ }
+ break;
+ default:
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->PMEvent) {
+ if (!setup) xf86EnterServerState(SETUP);
+ setup = 1;
+ xf86EnableAccess(xf86Screens[i]);
+ xf86Screens[i]->PMEvent(i,event,undo);
+ }
+ }
+ if (setup) xf86EnterServerState(OPERATING);
+ break;
+ }
+}
+
+#define MAX_NO_EVENTS 8
+
+void
+xf86HandlePMEvents(int fd, pointer data)
+{
+ pmEvent events[MAX_NO_EVENTS];
+ int i,n;
+ Bool wait = FALSE;
+
+ if (!xf86PMGetEventFromOs)
+ return;
+
+ if ((n = xf86PMGetEventFromOs(fd,events,MAX_NO_EVENTS))) {
+ do {
+ for (i = 0; i < n; i++) {
+ char *str = NULL;
+ int verb = eventName(events[i],&str);
+
+ xf86MsgVerb(X_INFO,verb,"PM Event received: %s\n",str);
+ DoApmEvent(events[i],FALSE);
+ switch (xf86PMConfirmEventToOs(fd,events[i])) {
+ case PM_WAIT:
+ wait = TRUE;
+ break;
+ case PM_CONTINUE:
+ wait = FALSE;
+ break;
+ case PM_FAILED:
+ DoApmEvent(events[i],TRUE);
+ wait = FALSE;
+ break;
+ default:
+ break;
+ }
+ }
+ if (wait)
+ n = xf86PMGetEventFromOs(fd,events,MAX_NO_EVENTS);
+ else
+ break;
+ } while (1);
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86PciInfo.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
new file mode 100644
index 000000000..183797e24
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
@@ -0,0 +1,726 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h,v 1.156 2003/10/30 15:26:33 tsi Exp $ */
+
+/*
+ * Copyright (c) 1995-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains macros for the PCI Vendor and Device IDs for video
+ * cards plus a few other things that are needed in drivers or elsewhere.
+ * This information is used in several ways:
+ * 1. It is used by drivers and/or other code.
+ * 2. It is used by the pciid2c.pl script to determine what vendor data to
+ * include in the pcidata module that the X server loads.
+ * 3. A side-effect of 2. affects how config-generation works for
+ * otherwise "unknown" cards.
+ *
+ * Don't add entries here for vendors that don't make video cards,
+ * or for non-video devices unless they're needed by a driver or elsewhere.
+ * A comprehensive set of PCI vendor, device and subsystem data is
+ * auto-generated from the ../etc/pci.ids file using the pciids2c.pl script,
+ * and is used in both the scanpci module and the scanpci utility. Don't
+ * modify the pci.ids file. If new/corrected entries are required, add them
+ * to ../etc/extrapci.ids.
+ */
+
+#ifndef _XF86_PCIINFO_H
+#define _XF86_PCIINFO_H
+
+/* PCI Pseudo Vendor */
+#define PCI_VENDOR_GENERIC 0x00FF
+
+#define PCI_VENDOR_REAL3D 0x003D
+#define PCI_VENDOR_COMPAQ 0x0E11
+#define PCI_VENDOR_ATI 0x1002
+#define PCI_VENDOR_AVANCE 0x1005
+#define PCI_VENDOR_TSENG 0x100C
+#define PCI_VENDOR_NS 0x100B
+#define PCI_VENDOR_WEITEK 0x100E
+#define PCI_VENDOR_VIDEOLOGIC 0x1010
+#define PCI_VENDOR_DIGITAL 0x1011
+#define PCI_VENDOR_CIRRUS 0x1013
+#define PCI_VENDOR_AMD 0x1022
+#define PCI_VENDOR_TRIDENT 0x1023
+#define PCI_VENDOR_ALI 0x1025
+#define PCI_VENDOR_DELL 0x1028
+#define PCI_VENDOR_MATROX 0x102B
+#define PCI_VENDOR_CHIPSTECH 0x102C
+#define PCI_VENDOR_MIRO 0x1031
+#define PCI_VENDOR_NEC 0x1033
+#define PCI_VENDOR_SIS 0x1039
+#define PCI_VENDOR_HP 0x103C
+#define PCI_VENDOR_SGS 0x104A
+#define PCI_VENDOR_TI 0x104C
+#define PCI_VENDOR_SONY 0x104D
+#define PCI_VENDOR_OAK 0x104E
+#define PCI_VENDOR_MOTOROLA 0x1057
+#define PCI_VENDOR_NUMNINE 0x105D
+#define PCI_VENDOR_CYRIX 0x1078
+#define PCI_VENDOR_SUN 0x108E
+#define PCI_VENDOR_DIAMOND 0x1092
+#define PCI_VENDOR_BROOKTREE 0x109E
+#define PCI_VENDOR_NEOMAGIC 0x10C8
+#define PCI_VENDOR_NVIDIA 0x10DE
+#define PCI_VENDOR_IMS 0x10E0
+#define PCI_VENDOR_INTEGRAPHICS 0x10EA
+#define PCI_VENDOR_ALLIANCE 0x1142
+#define PCI_VENDOR_RENDITION 0x1163
+#define PCI_VENDOR_3DFX 0x121A
+#define PCI_VENDOR_SMI 0x126F
+#define PCI_VENDOR_TRITECH 0x1292
+#define PCI_VENDOR_NVIDIA_SGS 0x12D2
+#define PCI_VENDOR_VMWARE 0x15AD
+#define PCI_VENDOR_3DLABS 0x3D3D
+#define PCI_VENDOR_AVANCE_2 0x4005
+#define PCI_VENDOR_HERCULES 0x4843
+#define PCI_VENDOR_S3 0x5333
+#define PCI_VENDOR_INTEL 0x8086
+#define PCI_VENDOR_ARK 0xEDD8
+
+
+/* Generic */
+#define PCI_CHIP_VGA 0x0000
+#define PCI_CHIP_8514 0x0001
+
+/* Real 3D */
+#define PCI_CHIP_I740_PCI 0x00D1
+
+/* Compaq */
+#define PCI_CHIP_QV1280 0x3033
+
+/* ATI */
+#define PCI_CHIP_RV380_3150 0x3150
+#define PCI_CHIP_RV380_3151 0x3151
+#define PCI_CHIP_RV380_3152 0x3152
+#define PCI_CHIP_RV380_3153 0x3153
+#define PCI_CHIP_RV380_3154 0x3154
+#define PCI_CHIP_RV380_3156 0x3156
+#define PCI_CHIP_RV380_3E50 0x3E50
+#define PCI_CHIP_RV380_3E51 0x3E51
+#define PCI_CHIP_RV380_3E52 0x3E52
+#define PCI_CHIP_RV380_3E53 0x3E53
+#define PCI_CHIP_RV380_3E54 0x3E54
+#define PCI_CHIP_RV380_3E56 0x3E56
+#define PCI_CHIP_RS100_4136 0x4136
+#define PCI_CHIP_RS200_4137 0x4137
+#define PCI_CHIP_R300_AD 0x4144
+#define PCI_CHIP_R300_AE 0x4145
+#define PCI_CHIP_R300_AF 0x4146
+#define PCI_CHIP_R300_AG 0x4147
+#define PCI_CHIP_R350_AH 0x4148
+#define PCI_CHIP_R350_AI 0x4149
+#define PCI_CHIP_R350_AJ 0x414A
+#define PCI_CHIP_R350_AK 0x414B
+#define PCI_CHIP_RV350_AP 0x4150
+#define PCI_CHIP_RV350_AQ 0x4151
+#define PCI_CHIP_RV360_AR 0x4152
+#define PCI_CHIP_RV350_AS 0x4153
+#define PCI_CHIP_RV350_AT 0x4154
+#define PCI_CHIP_RV350_4155 0x4155
+#define PCI_CHIP_RV350_AV 0x4156
+#define PCI_CHIP_MACH32 0x4158
+#define PCI_CHIP_RS250_4237 0x4237
+#define PCI_CHIP_R200_BB 0x4242
+#define PCI_CHIP_R200_BC 0x4243
+#define PCI_CHIP_RS100_4336 0x4336
+#define PCI_CHIP_RS200_4337 0x4337
+#define PCI_CHIP_MACH64CT 0x4354
+#define PCI_CHIP_MACH64CX 0x4358
+#define PCI_CHIP_RS250_4437 0x4437
+#define PCI_CHIP_MACH64ET 0x4554
+#define PCI_CHIP_MACH64GB 0x4742
+#define PCI_CHIP_MACH64GD 0x4744
+#define PCI_CHIP_MACH64GI 0x4749
+#define PCI_CHIP_MACH64GL 0x474C
+#define PCI_CHIP_MACH64GM 0x474D
+#define PCI_CHIP_MACH64GN 0x474E
+#define PCI_CHIP_MACH64GO 0x474F
+#define PCI_CHIP_MACH64GP 0x4750
+#define PCI_CHIP_MACH64GQ 0x4751
+#define PCI_CHIP_MACH64GR 0x4752
+#define PCI_CHIP_MACH64GS 0x4753
+#define PCI_CHIP_MACH64GT 0x4754
+#define PCI_CHIP_MACH64GU 0x4755
+#define PCI_CHIP_MACH64GV 0x4756
+#define PCI_CHIP_MACH64GW 0x4757
+#define PCI_CHIP_MACH64GX 0x4758
+#define PCI_CHIP_MACH64GY 0x4759
+#define PCI_CHIP_MACH64GZ 0x475A
+#define PCI_CHIP_RV250_Id 0x4964
+#define PCI_CHIP_RV250_Ie 0x4965
+#define PCI_CHIP_RV250_If 0x4966
+#define PCI_CHIP_RV250_Ig 0x4967
+#define PCI_CHIP_R420_JH 0x4A48
+#define PCI_CHIP_R420_JI 0x4A49
+#define PCI_CHIP_R420_JJ 0x4A4A
+#define PCI_CHIP_R420_JK 0x4A4B
+#define PCI_CHIP_R420_JL 0x4A4C
+#define PCI_CHIP_R420_JM 0x4A4D
+#define PCI_CHIP_R420_JN 0x4A4E
+#define PCI_CHIP_R420_4A4F 0x4A4F
+#define PCI_CHIP_R420_JP 0x4A50
+#define PCI_CHIP_R481_4B49 0x4B49
+#define PCI_CHIP_R481_4B4A 0x4B4A
+#define PCI_CHIP_R481_4B4B 0x4B4B
+#define PCI_CHIP_R481_4B4C 0x4B4C
+#define PCI_CHIP_MACH64LB 0x4C42
+#define PCI_CHIP_MACH64LD 0x4C44
+#define PCI_CHIP_RAGE128LE 0x4C45
+#define PCI_CHIP_RAGE128LF 0x4C46
+#define PCI_CHIP_MACH64LG 0x4C47
+#define PCI_CHIP_MACH64LI 0x4C49
+#define PCI_CHIP_MACH64LM 0x4C4D
+#define PCI_CHIP_MACH64LN 0x4C4E
+#define PCI_CHIP_MACH64LP 0x4C50
+#define PCI_CHIP_MACH64LQ 0x4C51
+#define PCI_CHIP_MACH64LR 0x4C52
+#define PCI_CHIP_MACH64LS 0x4C53
+#define PCI_CHIP_RADEON_LW 0x4C57
+#define PCI_CHIP_RADEON_LX 0x4C58
+#define PCI_CHIP_RADEON_LY 0x4C59
+#define PCI_CHIP_RADEON_LZ 0x4C5A
+#define PCI_CHIP_RV250_Ld 0x4C64
+#define PCI_CHIP_RV250_Le 0x4C65
+#define PCI_CHIP_RV250_Lf 0x4C66
+#define PCI_CHIP_RV250_Lg 0x4C67
+#define PCI_CHIP_RV250_Ln 0x4C6E
+#define PCI_CHIP_RAGE128MF 0x4D46
+#define PCI_CHIP_RAGE128ML 0x4D4C
+#define PCI_CHIP_R300_ND 0x4E44
+#define PCI_CHIP_R300_NE 0x4E45
+#define PCI_CHIP_R300_NF 0x4E46
+#define PCI_CHIP_R300_NG 0x4E47
+#define PCI_CHIP_R350_NH 0x4E48
+#define PCI_CHIP_R350_NI 0x4E49
+#define PCI_CHIP_R360_NJ 0x4E4A
+#define PCI_CHIP_R350_NK 0x4E4B
+#define PCI_CHIP_RV350_NP 0x4E50
+#define PCI_CHIP_RV350_NQ 0x4E51
+#define PCI_CHIP_RV350_NR 0x4E52
+#define PCI_CHIP_RV350_NS 0x4E53
+#define PCI_CHIP_RV350_NT 0x4E54
+#define PCI_CHIP_RV350_NV 0x4E56
+#define PCI_CHIP_RAGE128PA 0x5041
+#define PCI_CHIP_RAGE128PB 0x5042
+#define PCI_CHIP_RAGE128PC 0x5043
+#define PCI_CHIP_RAGE128PD 0x5044
+#define PCI_CHIP_RAGE128PE 0x5045
+#define PCI_CHIP_RAGE128PF 0x5046
+#define PCI_CHIP_RAGE128PG 0x5047
+#define PCI_CHIP_RAGE128PH 0x5048
+#define PCI_CHIP_RAGE128PI 0x5049
+#define PCI_CHIP_RAGE128PJ 0x504A
+#define PCI_CHIP_RAGE128PK 0x504B
+#define PCI_CHIP_RAGE128PL 0x504C
+#define PCI_CHIP_RAGE128PM 0x504D
+#define PCI_CHIP_RAGE128PN 0x504E
+#define PCI_CHIP_RAGE128PO 0x504F
+#define PCI_CHIP_RAGE128PP 0x5050
+#define PCI_CHIP_RAGE128PQ 0x5051
+#define PCI_CHIP_RAGE128PR 0x5052
+#define PCI_CHIP_RAGE128PS 0x5053
+#define PCI_CHIP_RAGE128PT 0x5054
+#define PCI_CHIP_RAGE128PU 0x5055
+#define PCI_CHIP_RAGE128PV 0x5056
+#define PCI_CHIP_RAGE128PW 0x5057
+#define PCI_CHIP_RAGE128PX 0x5058
+#define PCI_CHIP_RADEON_QD 0x5144
+#define PCI_CHIP_RADEON_QE 0x5145
+#define PCI_CHIP_RADEON_QF 0x5146
+#define PCI_CHIP_RADEON_QG 0x5147
+#define PCI_CHIP_R200_QH 0x5148
+#define PCI_CHIP_R200_QI 0x5149
+#define PCI_CHIP_R200_QJ 0x514A
+#define PCI_CHIP_R200_QK 0x514B
+#define PCI_CHIP_R200_QL 0x514C
+#define PCI_CHIP_R200_QM 0x514D
+#define PCI_CHIP_R200_QN 0x514E
+#define PCI_CHIP_R200_QO 0x514F
+#define PCI_CHIP_RV200_QW 0x5157
+#define PCI_CHIP_RV200_QX 0x5158
+#define PCI_CHIP_RV100_QY 0x5159
+#define PCI_CHIP_RV100_QZ 0x515A
+#define PCI_CHIP_RN50_515E 0x515E
+#define PCI_CHIP_RAGE128RE 0x5245
+#define PCI_CHIP_RAGE128RF 0x5246
+#define PCI_CHIP_RAGE128RG 0x5247
+#define PCI_CHIP_RAGE128RK 0x524B
+#define PCI_CHIP_RAGE128RL 0x524C
+#define PCI_CHIP_RAGE128SE 0x5345
+#define PCI_CHIP_RAGE128SF 0x5346
+#define PCI_CHIP_RAGE128SG 0x5347
+#define PCI_CHIP_RAGE128SH 0x5348
+#define PCI_CHIP_RAGE128SK 0x534B
+#define PCI_CHIP_RAGE128SL 0x534C
+#define PCI_CHIP_RAGE128SM 0x534D
+#define PCI_CHIP_RAGE128SN 0x534E
+#define PCI_CHIP_RAGE128TF 0x5446
+#define PCI_CHIP_RAGE128TL 0x544C
+#define PCI_CHIP_RAGE128TR 0x5452
+#define PCI_CHIP_RAGE128TS 0x5453
+#define PCI_CHIP_RAGE128TT 0x5454
+#define PCI_CHIP_RAGE128TU 0x5455
+#define PCI_CHIP_RV370_5460 0x5460
+#define PCI_CHIP_RV370_5461 0x5461
+#define PCI_CHIP_RV370_5462 0x5462
+#define PCI_CHIP_RV370_5463 0x5463
+#define PCI_CHIP_RV370_5464 0x5464
+#define PCI_CHIP_RV370_5465 0x5465
+#define PCI_CHIP_RV370_5466 0x5466
+#define PCI_CHIP_RV370_5467 0x5467
+#define PCI_CHIP_R423_UH 0x5548
+#define PCI_CHIP_R423_UI 0x5549
+#define PCI_CHIP_R423_UJ 0x554A
+#define PCI_CHIP_R423_UK 0x554B
+#define PCI_CHIP_R430_554C 0x554C
+#define PCI_CHIP_R430_554D 0x554D
+#define PCI_CHIP_R430_554E 0x554E
+#define PCI_CHIP_R430_554F 0x554F
+#define PCI_CHIP_R423_5550 0x5550
+#define PCI_CHIP_R423_UQ 0x5551
+#define PCI_CHIP_R423_UR 0x5552
+#define PCI_CHIP_R423_UT 0x5554
+#define PCI_CHIP_RV410_564A 0x564A
+#define PCI_CHIP_RV410_564B 0x564B
+#define PCI_CHIP_RV410_5652 0x5652
+#define PCI_CHIP_RV410_5653 0x5653
+#define PCI_CHIP_MACH64VT 0x5654
+#define PCI_CHIP_MACH64VU 0x5655
+#define PCI_CHIP_MACH64VV 0x5656
+#define PCI_CHIP_RS300_5834 0x5834
+#define PCI_CHIP_RS300_5835 0x5835
+#define PCI_CHIP_RS300_5836 0x5836
+#define PCI_CHIP_RS300_5837 0x5837
+#define PCI_CHIP_RS480_5954 0x5954
+#define PCI_CHIP_RS480_5955 0x5955
+#define PCI_CHIP_RV280_5960 0x5960
+#define PCI_CHIP_RV280_5961 0x5961
+#define PCI_CHIP_RV280_5962 0x5962
+#define PCI_CHIP_RV280_5964 0x5964
+#define PCI_CHIP_RV280_5965 0x5965
+#define PCI_CHIP_RN50_5969 0x5969
+#define PCI_CHIP_RS482_5974 0x5974
+#define PCI_CHIP_RS482_5975 0x5975
+#define PCI_CHIP_RS400_5A41 0x5A41
+#define PCI_CHIP_RS400_5A42 0x5A42
+#define PCI_CHIP_RC410_5A61 0x5A61
+#define PCI_CHIP_RC410_5A62 0x5A62
+#define PCI_CHIP_RV370_5B60 0x5B60
+#define PCI_CHIP_RV370_5B61 0x5B61
+#define PCI_CHIP_RV370_5B62 0x5B62
+#define PCI_CHIP_RV370_5B63 0x5B63
+#define PCI_CHIP_RV370_5B64 0x5B64
+#define PCI_CHIP_RV370_5B65 0x5B65
+#define PCI_CHIP_RV370_5B66 0x5B66
+#define PCI_CHIP_RV370_5B67 0x5B67
+#define PCI_CHIP_RV280_5C61 0x5C61
+#define PCI_CHIP_RV280_5C63 0x5C63
+#define PCI_CHIP_R430_5D48 0x5D48
+#define PCI_CHIP_R430_5D49 0x5D49
+#define PCI_CHIP_R430_5D4A 0x5D4A
+#define PCI_CHIP_R480_5D4C 0x5D4C
+#define PCI_CHIP_R480_5D4D 0x5D4D
+#define PCI_CHIP_R480_5D4E 0x5D4E
+#define PCI_CHIP_R480_5D4F 0x5D4F
+#define PCI_CHIP_R480_5D50 0x5D50
+#define PCI_CHIP_R480_5D52 0x5D52
+#define PCI_CHIP_R423_5D57 0x5D57
+#define PCI_CHIP_RV410_5E48 0x5E48
+#define PCI_CHIP_RV410_5E4A 0x5E4A
+#define PCI_CHIP_RV410_5E4B 0x5E4B
+#define PCI_CHIP_RV410_5E4C 0x5E4C
+#define PCI_CHIP_RV410_5E4D 0x5E4D
+#define PCI_CHIP_RV410_5E4F 0x5E4F
+#define PCI_CHIP_RS350_7834 0x7834
+#define PCI_CHIP_RS350_7835 0x7835
+
+/* Avance Logic */
+#define PCI_CHIP_ALG2064 0x2064
+#define PCI_CHIP_ALG2301 0x2301
+#define PCI_CHIP_ALG2501 0x2501
+
+/* Tseng */
+#define PCI_CHIP_ET4000_W32P_A 0x3202
+#define PCI_CHIP_ET4000_W32P_B 0x3205
+#define PCI_CHIP_ET4000_W32P_D 0x3206
+#define PCI_CHIP_ET4000_W32P_C 0x3207
+#define PCI_CHIP_ET6000 0x3208
+#define PCI_CHIP_ET6300 0x4702
+
+/* Weitek */
+#define PCI_CHIP_P9000 0x9001
+#define PCI_CHIP_P9100 0x9100
+
+/* Digital */
+#define PCI_CHIP_DC21050 0x0001
+#define PCI_CHIP_DEC21030 0x0004
+#define PCI_CHIP_TGA2 0x000D
+
+/* Cirrus Logic */
+#define PCI_CHIP_GD7548 0x0038
+#define PCI_CHIP_GD7555 0x0040
+#define PCI_CHIP_GD5430 0x00A0
+#define PCI_CHIP_GD5434_4 0x00A4
+#define PCI_CHIP_GD5434_8 0x00A8
+#define PCI_CHIP_GD5436 0x00AC
+#define PCI_CHIP_GD5446 0x00B8
+#define PCI_CHIP_GD5480 0x00BC
+#define PCI_CHIP_GD5462 0x00D0
+#define PCI_CHIP_GD5464 0x00D4
+#define PCI_CHIP_GD5464BD 0x00D5
+#define PCI_CHIP_GD5465 0x00D6
+#define PCI_CHIP_6729 0x1100
+#define PCI_CHIP_6832 0x1110
+#define PCI_CHIP_GD7542 0x1200
+#define PCI_CHIP_GD7543 0x1202
+#define PCI_CHIP_GD7541 0x1204
+
+/* AMD */
+#define PCI_CHIP_AMD761 0x700E
+
+/* Trident */
+#define PCI_CHIP_2100 0x2100
+#define PCI_CHIP_8400 0x8400
+#define PCI_CHIP_8420 0x8420
+#define PCI_CHIP_8500 0x8500
+#define PCI_CHIP_8520 0x8520
+#define PCI_CHIP_8600 0x8600
+#define PCI_CHIP_8620 0x8620
+#define PCI_CHIP_8820 0x8820
+#define PCI_CHIP_9320 0x9320
+#define PCI_CHIP_9388 0x9388
+#define PCI_CHIP_9397 0x9397
+#define PCI_CHIP_939A 0x939A
+#define PCI_CHIP_9420 0x9420
+#define PCI_CHIP_9440 0x9440
+#define PCI_CHIP_9520 0x9520
+#define PCI_CHIP_9525 0x9525
+#define PCI_CHIP_9540 0x9540
+#define PCI_CHIP_9660 0x9660
+#define PCI_CHIP_9750 0x9750
+#define PCI_CHIP_9850 0x9850
+#define PCI_CHIP_9880 0x9880
+#define PCI_CHIP_9910 0x9910
+
+/* ALI */
+#define PCI_CHIP_M1435 0x1435
+
+/* Matrox */
+#define PCI_CHIP_MGA2085 0x0518
+#define PCI_CHIP_MGA2064 0x0519
+#define PCI_CHIP_MGA1064 0x051A
+#define PCI_CHIP_MGA2164 0x051B
+#define PCI_CHIP_MGA2164_AGP 0x051F
+#define PCI_CHIP_MGAG200_PCI 0x0520
+#define PCI_CHIP_MGAG200 0x0521
+#define PCI_CHIP_MGAG400 0x0525
+#define PCI_CHIP_MGAG550 0x2527
+#define PCI_CHIP_IMPRESSION 0x0D10
+#define PCI_CHIP_MGAG100_PCI 0x1000
+#define PCI_CHIP_MGAG100 0x1001
+
+#define PCI_CARD_G400_TH 0x2179
+#define PCI_CARD_MILL_G200_SD 0xFF00
+#define PCI_CARD_PROD_G100_SD 0xFF01
+#define PCI_CARD_MYST_G200_SD 0xFF02
+#define PCI_CARD_MILL_G200_SG 0xFF03
+#define PCI_CARD_MARV_G200_SD 0xFF04
+
+/* Chips & Tech */
+#define PCI_CHIP_65545 0x00D8
+#define PCI_CHIP_65548 0x00DC
+#define PCI_CHIP_65550 0x00E0
+#define PCI_CHIP_65554 0x00E4
+#define PCI_CHIP_65555 0x00E5
+#define PCI_CHIP_68554 0x00F4
+#define PCI_CHIP_69000 0x00C0
+#define PCI_CHIP_69030 0x0C30
+
+/* Miro */
+#define PCI_CHIP_ZR36050 0x5601
+
+/* NEC */
+#define PCI_CHIP_POWER_VR 0x0046
+
+/* SiS */
+#define PCI_CHIP_SG86C201 0x0001
+#define PCI_CHIP_SG86C202 0x0002
+#define PCI_CHIP_SG85C503 0x0008
+#define PCI_CHIP_SIS5597 0x0200
+/* Agregado por Carlos Duclos & Manuel Jander */
+#define PCI_CHIP_SIS82C204 0x0204
+#define PCI_CHIP_SG86C205 0x0205
+#define PCI_CHIP_SG86C215 0x0215
+#define PCI_CHIP_SG86C225 0x0225
+#define PCI_CHIP_85C501 0x0406
+#define PCI_CHIP_85C496 0x0496
+#define PCI_CHIP_85C601 0x0601
+#define PCI_CHIP_85C5107 0x5107
+#define PCI_CHIP_85C5511 0x5511
+#define PCI_CHIP_85C5513 0x5513
+#define PCI_CHIP_SIS5571 0x5571
+#define PCI_CHIP_SIS5597_2 0x5597
+#define PCI_CHIP_SIS530 0x6306
+#define PCI_CHIP_SIS6326 0x6326
+#define PCI_CHIP_SIS7001 0x7001
+#define PCI_CHIP_SIS300 0x0300
+#define PCI_CHIP_SIS315H 0x0310
+#define PCI_CHIP_SIS315PRO 0x0325
+#define PCI_CHIP_SIS330 0x0330
+#define PCI_CHIP_SIS630 0x6300
+#define PCI_CHIP_SIS540 0x5300
+#define PCI_CHIP_SIS550 0x5315
+#define PCI_CHIP_SIS650 0x6325
+#define PCI_CHIP_SIS730 0x7300
+
+/* Hewlett-Packard */
+#define PCI_CHIP_ELROY 0x1054
+#define PCI_CHIP_ZX1_SBA 0x1229
+#define PCI_CHIP_ZX1_IOC 0x122A
+#define PCI_CHIP_ZX1_LBA 0x122E /* a.k.a. Mercury */
+#define PCI_CHIP_ZX1_AGP8 0x12B4 /* a.k.a. QuickSilver */
+#define PCI_CHIP_ZX2_LBA 0x12EE
+#define PCI_CHIP_ZX2_SBA 0x4030
+#define PCI_CHIP_ZX2_IOC 0x4031
+
+/* SGS */
+#define PCI_CHIP_STG2000 0x0008
+#define PCI_CHIP_STG1764 0x0009
+#define PCI_CHIP_KYROII 0x0010
+
+/* Texas Instruments */
+#define PCI_CHIP_TI_PERMEDIA 0x3D04
+#define PCI_CHIP_TI_PERMEDIA2 0x3D07
+
+/* Oak */
+#define PCI_CHIP_OTI107 0x0107
+
+/* Number Nine */
+#define PCI_CHIP_I128 0x2309
+#define PCI_CHIP_I128_2 0x2339
+#define PCI_CHIP_I128_T2R 0x493D
+#define PCI_CHIP_I128_T2R4 0x5348
+
+/* Sun */
+#define PCI_CHIP_EBUS 0x1000
+#define PCI_CHIP_HAPPY_MEAL 0x1001
+#define PCI_CHIP_SIMBA 0x5000
+#define PCI_CHIP_PSYCHO 0x8000
+#define PCI_CHIP_SCHIZO 0x8001
+#define PCI_CHIP_SABRE 0xA000
+#define PCI_CHIP_HUMMINGBIRD 0xA001
+
+/* BrookTree */
+#define PCI_CHIP_BT848 0x0350
+#define PCI_CHIP_BT849 0x0351
+
+/* NVIDIA */
+#define PCI_CHIP_NV1 0x0008
+#define PCI_CHIP_DAC64 0x0009
+#define PCI_CHIP_TNT 0x0020
+#define PCI_CHIP_TNT2 0x0028
+#define PCI_CHIP_UTNT2 0x0029
+#define PCI_CHIP_VTNT2 0x002C
+#define PCI_CHIP_UVTNT2 0x002D
+#define PCI_CHIP_ITNT2 0x00A0
+#define PCI_CHIP_GEFORCE_256 0x0100
+#define PCI_CHIP_GEFORCE_DDR 0x0101
+#define PCI_CHIP_QUADRO 0x0103
+#define PCI_CHIP_GEFORCE2_MX 0x0110
+#define PCI_CHIP_GEFORCE2_MX_100 0x0111
+#define PCI_CHIP_GEFORCE2_GO 0x0112
+#define PCI_CHIP_QUADRO2_MXR 0x0113
+#define PCI_CHIP_GEFORCE2_GTS 0x0150
+#define PCI_CHIP_GEFORCE2_TI 0x0151
+#define PCI_CHIP_GEFORCE2_ULTRA 0x0152
+#define PCI_CHIP_QUADRO2_PRO 0x0153
+#define PCI_CHIP_GEFORCE4_MX_460 0x0170
+#define PCI_CHIP_GEFORCE4_MX_440 0x0171
+#define PCI_CHIP_GEFORCE4_MX_420 0x0172
+#define PCI_CHIP_GEFORCE4_440_GO 0x0174
+#define PCI_CHIP_GEFORCE4_420_GO 0x0175
+#define PCI_CHIP_GEFORCE4_420_GO_M32 0x0176
+#define PCI_CHIP_QUADRO4_500XGL 0x0178
+#define PCI_CHIP_GEFORCE4_440_GO_M64 0x0179
+#define PCI_CHIP_QUADRO4_200 0x017A
+#define PCI_CHIP_QUADRO4_550XGL 0x017B
+#define PCI_CHIP_QUADRO4_500_GOGL 0x017C
+#define PCI_CHIP_IGEFORCE2 0x01A0
+#define PCI_CHIP_GEFORCE3 0x0200
+#define PCI_CHIP_GEFORCE3_TI_200 0x0201
+#define PCI_CHIP_GEFORCE3_TI_500 0x0202
+#define PCI_CHIP_QUADRO_DCC 0x0203
+#define PCI_CHIP_GEFORCE4_TI_4600 0x0250
+#define PCI_CHIP_GEFORCE4_TI_4400 0x0251
+#define PCI_CHIP_GEFORCE4_TI_4200 0x0253
+#define PCI_CHIP_QUADRO4_900XGL 0x0258
+#define PCI_CHIP_QUADRO4_750XGL 0x0259
+#define PCI_CHIP_QUADRO4_700XGL 0x025B
+
+/* NVIDIA & SGS */
+#define PCI_CHIP_RIVA128 0x0018
+
+/* IMS */
+#define PCI_CHIP_IMSTT128 0x9128
+#define PCI_CHIP_IMSTT3D 0x9135
+
+/* Alliance Semiconductor */
+#define PCI_CHIP_AP6410 0x3210
+#define PCI_CHIP_AP6422 0x6422
+#define PCI_CHIP_AT24 0x6424
+#define PCI_CHIP_AT3D 0x643D
+
+/* 3dfx Interactive */
+#define PCI_CHIP_VOODOO_GRAPHICS 0x0001
+#define PCI_CHIP_VOODOO2 0x0002
+#define PCI_CHIP_BANSHEE 0x0003
+#define PCI_CHIP_VOODOO3 0x0005
+#define PCI_CHIP_VOODOO5 0x0009
+
+#define PCI_CARD_VOODOO3_2000 0x0036
+#define PCI_CARD_VOODOO3_3000 0x003A
+
+/* Rendition */
+#define PCI_CHIP_V1000 0x0001
+#define PCI_CHIP_V2x00 0x2000
+
+/* 3Dlabs */
+#define PCI_CHIP_300SX 0x0001
+#define PCI_CHIP_500TX 0x0002
+#define PCI_CHIP_DELTA 0x0003
+#define PCI_CHIP_PERMEDIA 0x0004
+#define PCI_CHIP_MX 0x0006
+#define PCI_CHIP_PERMEDIA2 0x0007
+#define PCI_CHIP_GAMMA 0x0008
+#define PCI_CHIP_PERMEDIA2V 0x0009
+#define PCI_CHIP_PERMEDIA3 0x000A
+#define PCI_CHIP_PERMEDIA4 0x000C
+#define PCI_CHIP_R4 0x000D
+#define PCI_CHIP_GAMMA2 0x000E
+#define PCI_CHIP_R4ALT 0x0011
+
+/* S3 */
+#define PCI_CHIP_PLATO 0x0551
+#define PCI_CHIP_VIRGE 0x5631
+#define PCI_CHIP_TRIO 0x8811
+#define PCI_CHIP_AURORA64VP 0x8812
+#define PCI_CHIP_TRIO64UVP 0x8814
+#define PCI_CHIP_VIRGE_VX 0x883D
+#define PCI_CHIP_868 0x8880
+#define PCI_CHIP_928 0x88B0
+#define PCI_CHIP_864_0 0x88C0
+#define PCI_CHIP_864_1 0x88C1
+#define PCI_CHIP_964_0 0x88D0
+#define PCI_CHIP_964_1 0x88D1
+#define PCI_CHIP_968 0x88F0
+#define PCI_CHIP_TRIO64V2_DXGX 0x8901
+#define PCI_CHIP_PLATO_PX 0x8902
+#define PCI_CHIP_Trio3D 0x8904
+#define PCI_CHIP_VIRGE_DXGX 0x8A01
+#define PCI_CHIP_VIRGE_GX2 0x8A10
+#define PCI_CHIP_Trio3D_2X 0x8A13
+#define PCI_CHIP_SAVAGE3D 0x8A20
+#define PCI_CHIP_SAVAGE3D_MV 0x8A21
+#define PCI_CHIP_SAVAGE4 0x8A22
+#define PCI_CHIP_PROSAVAGE_PM 0x8A25
+#define PCI_CHIP_PROSAVAGE_KM 0x8A26
+#define PCI_CHIP_VIRGE_MX 0x8C01
+#define PCI_CHIP_VIRGE_MXPLUS 0x8C02
+#define PCI_CHIP_VIRGE_MXP 0x8C03
+#define PCI_CHIP_SAVAGE_MX_MV 0x8C10
+#define PCI_CHIP_SAVAGE_MX 0x8C11
+#define PCI_CHIP_SAVAGE_IX_MV 0x8C12
+#define PCI_CHIP_SAVAGE_IX 0x8C13
+#define PCI_CHIP_SUPSAV_MX128 0x8C22
+#define PCI_CHIP_SUPSAV_MX64 0x8C24
+#define PCI_CHIP_SUPSAV_MX64C 0x8C26
+#define PCI_CHIP_SUPSAV_IX128SDR 0x8C2A
+#define PCI_CHIP_SUPSAV_IX128DDR 0x8C2B
+#define PCI_CHIP_SUPSAV_IX64SDR 0x8C2C
+#define PCI_CHIP_SUPSAV_IX64DDR 0x8C2D
+#define PCI_CHIP_SUPSAV_IXCSDR 0x8C2E
+#define PCI_CHIP_SUPSAV_IXCDDR 0x8C2F
+#define PCI_CHIP_S3TWISTER_P 0x8D01
+#define PCI_CHIP_S3TWISTER_K 0x8D02
+#define PCI_CHIP_PROSAVAGE_DDR 0x8D03
+#define PCI_CHIP_PROSAVAGE_DDRK 0x8D04
+#define PCI_CHIP_SAVAGE2000 0x9102
+
+/* ARK Logic */
+#define PCI_CHIP_1000PV 0xA091
+#define PCI_CHIP_2000PV 0xA099
+#define PCI_CHIP_2000MT 0xA0A1
+#define PCI_CHIP_2000MI 0xA0A9
+
+/* Tritech Microelectronics */
+#define PCI_CHIP_TR25202 0xFC02
+
+/* Neomagic */
+#define PCI_CHIP_NM2070 0x0001
+#define PCI_CHIP_NM2090 0x0002
+#define PCI_CHIP_NM2093 0x0003
+#define PCI_CHIP_NM2097 0x0083
+#define PCI_CHIP_NM2160 0x0004
+#define PCI_CHIP_NM2200 0x0005
+#define PCI_CHIP_NM2230 0x0025
+#define PCI_CHIP_NM2360 0x0006
+#define PCI_CHIP_NM2380 0x0016
+
+/* Intel */
+#define PCI_CHIP_I815_BRIDGE 0x1130
+#define PCI_CHIP_I815 0x1132
+#define PCI_CHIP_82801_P2P 0x244E
+#define PCI_CHIP_845_G_BRIDGE 0x2560
+#define PCI_CHIP_845_G 0x2562
+#define PCI_CHIP_I830_M_BRIDGE 0x3575
+#define PCI_CHIP_I830_M 0x3577
+#define PCI_CHIP_I810_BRIDGE 0x7120
+#define PCI_CHIP_I810 0x7121
+#define PCI_CHIP_I810_DC100_BRIDGE 0x7122
+#define PCI_CHIP_I810_DC100 0x7123
+#define PCI_CHIP_I810_E_BRIDGE 0x7124
+#define PCI_CHIP_I810_E 0x7125
+#define PCI_CHIP_I740_AGP 0x7800
+#define PCI_CHIP_460GX_PXB 0x84CB
+#define PCI_CHIP_460GX_SAC 0x84E0
+#define PCI_CHIP_460GX_GXB_2 0x84E2 /* PCI function 2 */
+#define PCI_CHIP_460GX_WXB 0x84E6
+#define PCI_CHIP_460GX_GXB_1 0x84EA /* PCI function 1 */
+
+/* Silicon Motion Inc. */
+#define PCI_CHIP_SMI910 0x0910
+#define PCI_CHIP_SMI810 0x0810
+#define PCI_CHIP_SMI820 0x0820
+#define PCI_CHIP_SMI710 0x0710
+#define PCI_CHIP_SMI712 0x0712
+#define PCI_CHIP_SMI720 0x0720
+#define PCI_CHIP_SMI731 0x0730
+
+/* VMware */
+#define PCI_CHIP_VMWARE0405 0x0405
+#define PCI_CHIP_VMWARE0710 0x0710
+
+#endif /* _XF86_PCIINFO_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Priv.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Priv.h
new file mode 100644
index 000000000..f32fa768d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Priv.h
@@ -0,0 +1,228 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Priv.h,v 3.83 2004/01/27 01:31:45 dawes Exp $ */
+
+/*
+ * Copyright (c) 1997-2002 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains declarations for private XFree86 functions and variables,
+ * and definitions of private macros.
+ *
+ * "private" means not available to video drivers.
+ */
+
+#ifndef _XF86PRIV_H
+#define _XF86PRIV_H
+
+#include "xf86Privstr.h"
+#include "propertyst.h"
+
+/*
+ * Parameters set ONLY from the command line options
+ * The global state of these things is held in xf86InfoRec (when appropriate).
+ */
+extern const char *xf86ConfigFile;
+extern Bool xf86AllowMouseOpenFail;
+#ifdef XF86VIDMODE
+extern Bool xf86VidModeDisabled;
+extern Bool xf86VidModeAllowNonLocal;
+#endif
+#ifdef XF86MISC
+extern Bool xf86MiscModInDevDisabled;
+extern Bool xf86MiscModInDevAllowNonLocal;
+#endif
+extern Bool xf86fpFlag;
+extern Bool xf86coFlag;
+extern Bool xf86sFlag;
+extern Bool xf86bsEnableFlag;
+extern Bool xf86bsDisableFlag;
+extern Bool xf86silkenMouseDisableFlag;
+extern Bool xf86acpiDisableFlag;
+extern char *xf86LayoutName;
+extern char *xf86ScreenName;
+extern char *xf86PointerName;
+extern char *xf86KeyboardName;
+#ifdef KEEPBPP
+extern int xf86Bpp;
+#endif
+extern int xf86FbBpp;
+extern int xf86Depth;
+extern Pix24Flags xf86Pix24;
+extern rgb xf86Weight;
+extern Bool xf86FlipPixels;
+extern Bool xf86BestRefresh;
+extern Gamma xf86Gamma;
+extern char *xf86ServerName;
+extern Bool xf86ShowUnresolved;
+extern PciBusId xf86IsolateDevice;
+
+/* Other parameters */
+
+extern xf86InfoRec xf86Info;
+extern const char *xf86InputDeviceList;
+extern const char *xf86ModulePath;
+extern MessageType xf86ModPathFrom;
+extern const char *xf86LogFile;
+extern MessageType xf86LogFileFrom;
+extern Bool xf86LogFileWasOpened;
+extern serverLayoutRec xf86ConfigLayout;
+extern Pix24Flags xf86ConfigPix24;
+
+extern unsigned short xf86MouseCflags[];
+extern Bool xf86SupportedMouseTypes[];
+extern int xf86NumMouseTypes;
+
+#ifdef XFree86LOADER
+extern DriverPtr *xf86DriverList;
+extern ModuleInfoPtr *xf86ModuleInfoList;
+extern int xf86NumModuleInfos;
+#else
+extern DriverPtr xf86DriverList[];
+#endif
+extern int xf86NumDrivers;
+extern Bool xf86Resetting;
+extern Bool xf86Initialising;
+extern Bool xf86ProbeFailed;
+extern int xf86NumScreens;
+extern pciVideoPtr *xf86PciVideoInfo;
+extern xf86CurrentAccessRec xf86CurrentAccess;
+extern const char *xf86VisualNames[];
+extern int xf86Verbose; /* verbosity level */
+extern int xf86LogVerbose; /* log file verbosity level */
+extern Bool xf86ProbeOnly;
+extern Bool xf86DoProbe;
+extern Bool xorgHWAccess;
+
+extern RootWinPropPtr *xf86RegisteredPropertiesTable;
+
+#ifndef DEFAULT_VERBOSE
+#define DEFAULT_VERBOSE 0
+#endif
+#ifndef DEFAULT_LOG_VERBOSE
+#define DEFAULT_LOG_VERBOSE 3
+#endif
+#ifndef DEFAULT_DPI
+#define DEFAULT_DPI 75
+#endif
+
+#define DEFAULT_UNRESOLVED TRUE
+#define DEFAULT_BEST_REFRESH FALSE
+
+/* Function Prototypes */
+#ifndef _NO_XF86_PROTOTYPES
+
+/* xf86Bus.c */
+
+void xf86BusProbe(void);
+void xf86ChangeBusIndex(int oldIndex, int newIndex);
+void xf86AccessInit(void);
+void xf86AccessEnter(void);
+void xf86AccessLeave(void);
+void xf86EntityInit(void);
+void xf86EntityEnter(void);
+void xf86EntityLeave(void);
+void xf86AccessLeaveState(void);
+
+void xf86FindPrimaryDevice(void);
+/* new RAC */
+void xf86ResourceBrokerInit(void);
+void xf86PostProbe(void);
+void xf86ClearEntityListForScreen(int scrnIndex);
+void xf86AddDevToEntity(int entityIndex, GDevPtr dev);
+extern void xf86PostPreInit(void);
+extern void xf86PostScreenInit(void);
+extern memType getValidBIOSBase(PCITAG tag, int num);
+extern int pciTestMultiDeviceCard(int bus, int dev, int func, PCITAG** pTag);
+
+/* xf86Config.c */
+
+Bool xf86PathIsAbsolute(const char *path);
+Bool xf86PathIsSafe(const char *path);
+
+/* xf86DefaultModes */
+
+extern DisplayModeRec xf86DefaultModes [];
+
+/* xf86DoScanPci.c */
+
+void DoScanPci(int argc, char **argv, int i);
+
+/* xf86DoProbe.c */
+void DoProbeArgs(int argc, char **argv, int i);
+void DoProbe(void);
+void DoConfigure(void);
+
+/* xf86Events.c */
+
+void xf86PostKbdEvent(unsigned key);
+void xf86PostMseEvent(DeviceIntPtr device, int buttons, int dx, int dy);
+void xf86Wakeup(pointer blockData, int err, pointer pReadmask);
+void xf86SigHandler(int signo);
+#ifdef MEMDEBUG
+void xf86SigMemDebug(int signo);
+#endif
+void xf86HandlePMEvents(int fd, pointer data);
+extern int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num);
+extern pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event);
+void xf86GrabServerCallback(CallbackListPtr *, pointer, pointer);
+
+/* xf86Helper.c */
+void xf86LogInit(void);
+void xf86CloseLog(void);
+
+/* xf86Init.c */
+Bool xf86LoadModules(char **list, pointer *optlist);
+int xf86SetVerbosity(int verb);
+int xf86SetLogVerbosity(int verb);
+
+/* xf86Io.c */
+
+void xf86KbdBell(int percent, DeviceIntPtr pKeyboard, pointer ctrl,
+ int unused);
+void xf86KbdLeds(void);
+void xf86UpdateKbdLeds(void);
+void xf86KbdCtrl(DevicePtr pKeyboard, KeybdCtrl *ctrl);
+void xf86InitKBD(Bool init);
+int xf86KbdProc(DeviceIntPtr pKeyboard, int what);
+
+/* xf86Kbd.c */
+
+void xf86KbdGetMapping(KeySymsPtr pKeySyms, CARD8 *pModMap);
+
+/* xf86Lock.c */
+
+#ifdef USE_XF86_SERVERLOCK
+void xf86UnlockServer(void);
+#endif
+
+/* xf86XKB.c */
+
+void xf86InitXkb(void);
+
+#endif /* _NO_XF86_PROTOTYPES */
+
+
+#endif /* _XF86PRIV_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Privstr.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Privstr.h
new file mode 100644
index 000000000..2f15e14cb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Privstr.h
@@ -0,0 +1,234 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h,v 1.41 2004/01/27 01:31:45 dawes Exp $ */
+
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains definitions of the private XFree86 data structures/types.
+ * None of the data structures here should be used by video drivers.
+ */
+
+#ifndef _XF86PRIVSTR_H
+#define _XF86PRIVSTR_H
+
+#include "xf86Pci.h"
+#include "xf86str.h"
+
+/* PCI probe flags */
+
+typedef enum {
+ PCIProbe1 = 0,
+ PCIProbe2,
+ PCIForceConfig1,
+ PCIForceConfig2,
+ PCIForceNone,
+ PCIOsConfig
+} PciProbeType;
+
+typedef enum {
+ LogNone,
+ LogFlush,
+ LogSync
+} Log;
+
+typedef enum {
+ SKNever,
+ SKWhenNeeded,
+ SKAlways
+} SpecialKeysInDDX;
+
+/*
+ * xf86InfoRec contains global parameters which the video drivers never
+ * need to access. Global parameters which the video drivers do need
+ * should be individual globals.
+ */
+
+typedef struct {
+
+ /* keyboard part */
+ DeviceIntPtr pKeyboard;
+ DeviceProc kbdProc; /* procedure for initializing */
+ void (* kbdEvents)(void); /* proc for processing events */
+ int consoleFd;
+ int kbdFd;
+ int vtno;
+ int kbdType; /* AT84 / AT101 */
+ int kbdRate;
+ int kbdDelay;
+ int bell_pitch;
+ int bell_duration;
+ Bool autoRepeat;
+ unsigned long leds;
+ unsigned long xleds;
+ char * vtinit;
+ int scanPrefix; /* scancode-state */
+ Bool capsLock;
+ Bool numLock;
+ Bool scrollLock;
+ Bool modeSwitchLock;
+ Bool composeLock;
+ Bool vtSysreq;
+ SpecialKeysInDDX ddxSpecialKeys;
+ Bool ActionKeyBindingsSet;
+#if defined(SVR4) && defined(i386)
+ Bool panix106;
+#endif /* SVR4 && i386 */
+#if defined(__OpenBSD__) || defined(__NetBSD__)
+ int wsKbdType;
+#endif
+
+ /* mouse part */
+ DeviceIntPtr pMouse;
+#ifdef XINPUT
+ pointer mouseLocal;
+#endif
+
+ /* event handler part */
+ int lastEventTime;
+ Bool vtRequestsPending;
+ Bool inputPending;
+ Bool dontVTSwitch;
+ Bool dontZap;
+ Bool dontZoom;
+ Bool notrapSignals; /* don't exit cleanly - die at fault */
+ Bool caughtSignal;
+
+ /* graphics part */
+ Bool sharedMonitor;
+ ScreenPtr currentScreen;
+#if defined(CSRG_BASED) || defined(__FreeBSD_kernel__)
+ int screenFd; /* fd for memory mapped access to
+ * vga card */
+ int consType; /* Which console driver? */
+#endif
+
+#ifdef XKB
+ /*
+ * would like to use an XkbComponentNamesRec here but can't without
+ * pulling in a bunch of header files. :-(
+ */
+ char * xkbkeymap;
+ char * xkbkeycodes;
+ char * xkbtypes;
+ char * xkbcompat;
+ char * xkbsymbols;
+ char * xkbgeometry;
+ Bool xkbcomponents_specified;
+ char * xkbrules;
+ char * xkbmodel;
+ char * xkblayout;
+ char * xkbvariant;
+ char * xkboptions;
+#endif
+
+ /* Other things */
+ Bool allowMouseOpenFail;
+ Bool vidModeEnabled; /* VidMode extension enabled */
+ Bool vidModeAllowNonLocal; /* allow non-local VidMode
+ * connections */
+ Bool miscModInDevEnabled; /* Allow input devices to be
+ * changed */
+ Bool miscModInDevAllowNonLocal;
+ PciProbeType pciFlags;
+ Pix24Flags pixmap24;
+ MessageType pix24From;
+#if defined(i386) || defined(__i386__)
+ Bool pc98;
+#endif
+ Bool pmFlag;
+ Log log;
+ int estimateSizesAggressively;
+ Bool kbdCustomKeycodes;
+ Bool disableRandR;
+ MessageType randRFrom;
+ struct {
+ Bool disabled; /* enable/disable deactivating
+ * grabs or closing the
+ * connection to the grabbing
+ * client */
+ ClientPtr override; /* client that disabled
+ * grab deactivation.
+ */
+ Bool allowDeactivate;
+ Bool allowClosedown;
+ ServerGrabInfoRec server;
+ } grabInfo;
+} xf86InfoRec, *xf86InfoPtr;
+
+#ifdef DPMSExtension
+/* Private info for DPMS */
+typedef struct {
+ CloseScreenProcPtr CloseScreen;
+ Bool Enabled;
+ int Flags;
+} DPMSRec, *DPMSPtr;
+#endif
+
+#ifdef XF86VIDMODE
+/* Private info for Video Mode Extentsion */
+typedef struct {
+ DisplayModePtr First;
+ DisplayModePtr Next;
+ int Flags;
+ CloseScreenProcPtr CloseScreen;
+} VidModeRec, *VidModePtr;
+#endif
+
+/* Information for root window properties. */
+typedef struct _RootWinProp {
+ struct _RootWinProp * next;
+ char * name;
+ Atom type;
+ short format;
+ long size;
+ pointer data;
+} RootWinProp, *RootWinPropPtr;
+
+/* private resource types */
+#define ResNoAvoid ResBios
+
+/* ISC's cc can't handle ~ of UL constants, so explicitly type cast them. */
+#define XLED1 ((unsigned long) 0x00000001)
+#define XLED2 ((unsigned long) 0x00000002)
+#define XLED3 ((unsigned long) 0x00000004)
+#define XLED4 ((unsigned long) 0x00000008)
+#define XCAPS ((unsigned long) 0x20000000)
+#define XNUM ((unsigned long) 0x40000000)
+#define XSCR ((unsigned long) 0x80000000)
+#define XCOMP ((unsigned long) 0x00008000)
+
+/* BSD console driver types (consType) */
+#if defined(CSRG_BASED) || defined(__FreeBSD_kernel__)
+#define PCCONS 0
+#define CODRV011 1
+#define CODRV01X 2
+#define SYSCONS 8
+#define PCVT 16
+#define WSCONS 32
+#endif
+
+#endif /* _XF86PRIVSTR_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86RandR.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86RandR.c
new file mode 100644
index 000000000..4fb844a0f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86RandR.c
@@ -0,0 +1,438 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86RandR.c,v 1.25 2005/10/30 17:38:49 twini Exp $ */
+/*
+ * $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86RandR.c,v 1.7tsi Exp $
+ *
+ * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "mibank.h"
+#include "globals.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86DDC.h"
+#include "mipointer.h"
+#include <randrstr.h>
+
+typedef struct _xf86RandRInfo {
+ CreateScreenResourcesProcPtr CreateScreenResources;
+ CloseScreenProcPtr CloseScreen;
+ int virtualX;
+ int virtualY;
+ int mmWidth;
+ int mmHeight;
+ Rotation rotation;
+} XF86RandRInfoRec, *XF86RandRInfoPtr;
+
+static int xf86RandRIndex = -1;
+static int xf86RandRGeneration;
+
+#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) (p)->devPrivates[xf86RandRIndex].ptr)
+
+static int
+xf86RandRModeRefresh (DisplayModePtr mode)
+{
+ if (mode->VRefresh)
+ return (int) (mode->VRefresh + 0.5);
+ else
+ return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5);
+}
+
+static Bool
+xf86RandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
+{
+ RRScreenSizePtr pSize;
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ DisplayModePtr mode;
+ int refresh0 = 60;
+ xorgRRModeMM RRModeMM;
+
+ *rotations = RR_Rotate_0;
+
+ for (mode = scrp->modes; ; mode = mode->next)
+ {
+ int refresh = xf86RandRModeRefresh (mode);
+
+ if (mode == scrp->modes)
+ refresh0 = refresh;
+
+ RRModeMM.mode = mode;
+ RRModeMM.virtX = randrp->virtualX;
+ RRModeMM.virtY = randrp->virtualY;
+ RRModeMM.mmWidth = randrp->mmWidth;
+ RRModeMM.mmHeight = randrp->mmHeight;
+
+ if(scrp->DriverFunc) {
+ (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM);
+ }
+
+ pSize = RRRegisterSize (pScreen,
+ mode->HDisplay, mode->VDisplay,
+ RRModeMM.mmWidth, RRModeMM.mmHeight);
+ if (!pSize)
+ return FALSE;
+ RRRegisterRate (pScreen, pSize, refresh);
+ if (mode == scrp->currentMode &&
+ mode->HDisplay == scrp->virtualX && mode->VDisplay == scrp->virtualY)
+ RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize);
+ if (mode->next == scrp->modes)
+ break;
+ }
+ if (scrp->currentMode->HDisplay != randrp->virtualX ||
+ scrp->currentMode->VDisplay != randrp->virtualY)
+ {
+ mode = scrp->modes;
+
+ RRModeMM.mode = NULL;
+ RRModeMM.virtX = randrp->virtualX;
+ RRModeMM.virtY = randrp->virtualY;
+ RRModeMM.mmWidth = randrp->mmWidth;
+ RRModeMM.mmHeight = randrp->mmHeight;
+
+ if(scrp->DriverFunc) {
+ (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM);
+ }
+
+ pSize = RRRegisterSize (pScreen,
+ randrp->virtualX, randrp->virtualY,
+ RRModeMM.mmWidth, RRModeMM.mmHeight);
+ if (!pSize)
+ return FALSE;
+ RRRegisterRate (pScreen, pSize, refresh0);
+ if (scrp->virtualX == randrp->virtualX &&
+ scrp->virtualY == randrp->virtualY)
+ {
+ RRSetCurrentConfig (pScreen, randrp->rotation, refresh0, pSize);
+ }
+ }
+
+ /* If there is driver support for randr, let it set our supported rotations */
+ if(scrp->DriverFunc) {
+ xorgRRRotation RRRotation;
+
+ RRRotation.RRRotations = *rotations;
+ if (!(*scrp->DriverFunc)(scrp, RR_GET_INFO, &RRRotation))
+ return TRUE;
+ *rotations = RRRotation.RRRotations;
+ }
+
+ return TRUE;
+}
+
+static Bool
+xf86RandRSetMode (ScreenPtr pScreen,
+ DisplayModePtr mode,
+ Bool useVirtual,
+ int mmWidth,
+ int mmHeight)
+{
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ int oldWidth = pScreen->width;
+ int oldHeight = pScreen->height;
+ int oldmmWidth = pScreen->mmWidth;
+ int oldmmHeight = pScreen->mmHeight;
+ WindowPtr pRoot = WindowTable[pScreen->myNum];
+ Bool ret = TRUE;
+
+ if (pRoot)
+ (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE);
+ if (useVirtual)
+ {
+ scrp->virtualX = randrp->virtualX;
+ scrp->virtualY = randrp->virtualY;
+ }
+ else
+ {
+ scrp->virtualX = mode->HDisplay;
+ scrp->virtualY = mode->VDisplay;
+ }
+ if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270))
+ {
+ /* If the screen is rotated 90 or 270 degrees, swap the sizes. */
+ pScreen->width = scrp->virtualY;
+ pScreen->height = scrp->virtualX;
+ pScreen->mmWidth = mmHeight;
+ pScreen->mmHeight = mmWidth;
+ }
+ else
+ {
+ pScreen->width = scrp->virtualX;
+ pScreen->height = scrp->virtualY;
+ pScreen->mmWidth = mmWidth;
+ pScreen->mmHeight = mmHeight;
+ }
+ if (!xf86SwitchMode (pScreen, mode))
+ {
+ scrp->virtualX = pScreen->width = oldWidth;
+ scrp->virtualY = pScreen->height = oldHeight;
+ pScreen->mmWidth = oldmmWidth;
+ pScreen->mmHeight = oldmmHeight;
+ ret = FALSE;
+ }
+ /*
+ * Make sure the layout is correct
+ */
+ xf86ReconfigureLayout();
+
+ /*
+ * Make sure the whole screen is visible
+ */
+ xf86SetViewport (pScreen, pScreen->width, pScreen->height);
+ xf86SetViewport (pScreen, 0, 0);
+ if (pRoot)
+ (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE);
+ return ret;
+}
+
+static Bool
+xf86RandRSetConfig (ScreenPtr pScreen,
+ Rotation rotation,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ DisplayModePtr mode;
+ int px, py;
+ Bool useVirtual = FALSE;
+ Rotation oldRotation = randrp->rotation;
+
+ miPointerPosition (&px, &py);
+ for (mode = scrp->modes; ; mode = mode->next)
+ {
+ if (mode->HDisplay == pSize->width &&
+ mode->VDisplay == pSize->height &&
+ (rate == 0 || xf86RandRModeRefresh (mode) == rate))
+ break;
+ if (mode->next == scrp->modes)
+ {
+ if (pSize->width == randrp->virtualX &&
+ pSize->height == randrp->virtualY)
+ {
+ mode = scrp->modes;
+ useVirtual = TRUE;
+ break;
+ }
+ return FALSE;
+ }
+ }
+
+ if (randrp->rotation != rotation) {
+
+ /* Have the driver do its thing. */
+ if (scrp->DriverFunc) {
+ xorgRRRotation RRRotation;
+ RRRotation.RRConfig.rotation = rotation;
+ RRRotation.RRConfig.rate = rate;
+ RRRotation.RRConfig.width = pSize->width;
+ RRRotation.RRConfig.height = pSize->height;
+
+ /*
+ * Currently we need to rely on HW support for rotation.
+ */
+ if (!(*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation))
+ return FALSE;
+ } else
+ return FALSE;
+
+ randrp->rotation = rotation;
+ }
+
+ if (!xf86RandRSetMode (pScreen, mode, useVirtual, pSize->mmWidth, pSize->mmHeight)) {
+ if(randrp->rotation != oldRotation) {
+ /* Have the driver undo its thing. */
+ if (scrp->DriverFunc) {
+ xorgRRRotation RRRotation;
+ RRRotation.RRConfig.rotation = oldRotation;
+ RRRotation.RRConfig.rate = xf86RandRModeRefresh (scrp->currentMode);
+ RRRotation.RRConfig.width = pScreen->width;
+ RRRotation.RRConfig.height = pScreen->height;
+ (*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation);
+ }
+
+ randrp->rotation = oldRotation;
+ }
+ return FALSE;
+ }
+ /*
+ * Move the cursor back where it belongs; SwitchMode repositions it
+ */
+ if (pScreen == miPointerCurrentScreen ())
+ {
+ px = (px >= pScreen->width ? (pScreen->width - 1) : px);
+ py = (py >= pScreen->height ? (pScreen->height - 1) : py);
+
+ xf86SetViewport(pScreen, px, py);
+
+ (*pScreen->SetCursorPosition) (pScreen, px, py, FALSE);
+ }
+
+ return TRUE;
+}
+
+/*
+ * Wait until the screen is initialized before whacking the
+ * sizes around; otherwise the screen pixmap will be allocated
+ * at the current mode size rather than the maximum size
+ */
+static Bool
+xf86RandRCreateScreenResources (ScreenPtr pScreen)
+{
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+#if 0
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ DisplayModePtr mode;
+#endif
+
+ pScreen->CreateScreenResources = randrp->CreateScreenResources;
+ if (!(*pScreen->CreateScreenResources) (pScreen))
+ return FALSE;
+
+#if 0
+ mode = scrp->currentMode;
+ if (mode)
+ xf86RandRSetMode (pScreen, mode, TRUE);
+#endif
+
+ return TRUE;
+}
+
+/*
+ * Reset size back to original
+ */
+static Bool
+xf86RandRCloseScreen (int index, ScreenPtr pScreen)
+{
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+
+ scrp->virtualX = pScreen->width = randrp->virtualX;
+ scrp->virtualY = pScreen->height = randrp->virtualY;
+ scrp->currentMode = scrp->modes;
+ pScreen->CloseScreen = randrp->CloseScreen;
+ xfree (randrp);
+ pScreen->devPrivates[xf86RandRIndex].ptr = 0;
+ return (*pScreen->CloseScreen) (index, pScreen);
+}
+
+Rotation
+xf86GetRotation(ScreenPtr pScreen)
+{
+ if (xf86RandRIndex == -1)
+ return RR_Rotate_0;
+
+ return XF86RANDRINFO(pScreen)->rotation;
+}
+
+/* Function to change RandR's idea of the virtual screen size */
+Bool
+xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
+ int newvirtX, int newvirtY, int newmmWidth, int newmmHeight,
+ Bool resetMode)
+{
+ XF86RandRInfoPtr randrp;
+
+ if (xf86RandRIndex == -1)
+ return FALSE;
+
+ randrp = XF86RANDRINFO(pScreen);
+ if (randrp == NULL)
+ return FALSE;
+
+ if (newvirtX > 0)
+ randrp->virtualX = newvirtX;
+
+ if (newvirtY > 0)
+ randrp->virtualY = newvirtY;
+
+ if (newmmWidth > 0)
+ randrp->mmWidth = newmmWidth;
+
+ if (newmmHeight > 0)
+ randrp->mmHeight = newmmHeight;
+
+ /* This is only for during server start */
+ if (resetMode) {
+ return (xf86RandRSetMode(pScreen,
+ XF86SCRNINFO(pScreen)->currentMode,
+ TRUE,
+ pScreen->mmWidth, pScreen->mmHeight));
+ }
+
+ return TRUE;
+}
+
+Bool
+xf86RandRInit (ScreenPtr pScreen)
+{
+ rrScrPrivPtr rp;
+ XF86RandRInfoPtr randrp;
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+
+#ifdef PANORAMIX
+ /* XXX disable RandR when using Xinerama */
+ if (!noPanoramiXExtension)
+ return TRUE;
+#endif
+ if (xf86RandRGeneration != serverGeneration)
+ {
+ xf86RandRIndex = AllocateScreenPrivateIndex();
+ xf86RandRGeneration = serverGeneration;
+ }
+
+ randrp = xalloc (sizeof (XF86RandRInfoRec));
+ if (!randrp)
+ return FALSE;
+
+ if (!RRScreenInit (pScreen))
+ {
+ xfree (randrp);
+ return FALSE;
+ }
+ rp = rrGetScrPriv(pScreen);
+ rp->rrGetInfo = xf86RandRGetInfo;
+ rp->rrSetConfig = xf86RandRSetConfig;
+
+ randrp->virtualX = scrp->virtualX;
+ randrp->virtualY = scrp->virtualY;
+ randrp->mmWidth = pScreen->mmWidth;
+ randrp->mmHeight = pScreen->mmHeight;
+
+ randrp->CreateScreenResources = pScreen->CreateScreenResources;
+ pScreen->CreateScreenResources = xf86RandRCreateScreenResources;
+
+ randrp->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = xf86RandRCloseScreen;
+
+ randrp->rotation = RR_Rotate_0;
+
+ pScreen->devPrivates[xf86RandRIndex].ptr = randrp;
+ return TRUE;
+}
+
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Resources.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Resources.h
new file mode 100644
index 000000000..ce2c62bb3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Resources.h
@@ -0,0 +1,140 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Resources.h,v 1.15 2003/08/24 17:36:55 dawes Exp $ */
+
+/*
+ * Copyright (c) 1999-2002 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifndef _XF86_RESOURCES_H
+
+#define _XF86_RESOURCES_H
+
+#include "xf86str.h"
+
+#define _END {ResEnd,0,0}
+
+#define _VGA_EXCLUSIVE \
+ {ResExcMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\
+ {ResExcMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\
+ {ResExcMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\
+ {ResExcIoBlock | ResBios | ResBus, 0x03B0, 0x03BB},\
+ {ResExcIoBlock | ResBios | ResBus, 0x03C0, 0x03DF}
+
+#define _VGA_SHARED \
+ {ResShrMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\
+ {ResShrMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\
+ {ResShrMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\
+ {ResShrIoBlock | ResBios | ResBus, 0x03B0, 0x03BB},\
+ {ResShrIoBlock | ResBios | ResBus, 0x03C0, 0x03DF}
+
+#define _VGA_SHARED_MEM \
+ {ResShrMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\
+ {ResShrMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\
+ {ResShrMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF}
+
+#define _VGA_SHARED_IO \
+ {ResShrIoBlock | ResBios | ResBus, 0x03B0, 0x03BB},\
+ {ResShrIoBlock | ResBios | ResBus, 0x03C0, 0x03DF}
+
+/*
+ * Exclusive unused VGA: resources unneeded but cannot be disabled.
+ * Like old Millennium.
+ */
+#define _VGA_EXCLUSIVE_UNUSED \
+ {ResExcUusdMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\
+ {ResExcUusdMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\
+ {ResExcUusdMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\
+ {ResExcUusdIoBlock | ResBios | ResBus, 0x03B0, 0x03BB},\
+ {ResExcUusdIoBlock | ResBios | ResBus, 0x03C0, 0x03DF}
+
+/*
+ * Shared unused VGA: resources unneeded but cannot be disabled
+ * independently. This is used to determine if a device needs RAC.
+ */
+#define _VGA_SHARED_UNUSED \
+ {ResShrUusdMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\
+ {ResShrUusdMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\
+ {ResShrUusdMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\
+ {ResShrUusdIoBlock | ResBios | ResBus, 0x03B0, 0x03BB},\
+ {ResShrUusdIoBlock | ResBios | ResBus, 0x03C0, 0x03DF}
+
+/*
+ * Sparse versions of the above for those adapters that respond to all ISA
+ * aliases of VGA ports.
+ */
+#define _VGA_EXCLUSIVE_SPARSE \
+ {ResExcMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\
+ {ResExcMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\
+ {ResExcMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\
+ {ResExcIoSparse | ResBios | ResBus, 0x03B0, 0x03F8},\
+ {ResExcIoSparse | ResBios | ResBus, 0x03B8, 0x03FC},\
+ {ResExcIoSparse | ResBios | ResBus, 0x03C0, 0x03E0}
+
+#define _VGA_SHARED_SPARSE \
+ {ResShrMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\
+ {ResShrMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\
+ {ResShrMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\
+ {ResShrIoSparse | ResBios | ResBus, 0x03B0, 0x03F8},\
+ {ResShrIoSparse | ResBios | ResBus, 0x03B8, 0x03FC},\
+ {ResShrIoSparse | ResBios | ResBus, 0x03C0, 0x03E0}
+
+#define _8514_EXCLUSIVE \
+ {ResExcIoSparse | ResBios | ResBus, 0x02E8, 0x03F8}
+
+#define _8514_SHARED \
+ {ResShrIoSparse | ResBios | ResBus, 0x02E8, 0x03F8}
+
+/* Predefined resources */
+extern resRange resVgaExclusive[];
+extern resRange resVgaShared[];
+extern resRange resVgaIoShared[];
+extern resRange resVgaMemShared[];
+extern resRange resVgaUnusedExclusive[];
+extern resRange resVgaUnusedShared[];
+extern resRange resVgaSparseExclusive[];
+extern resRange resVgaSparseShared[];
+extern resRange res8514Exclusive[];
+extern resRange res8514Shared[];
+
+/* Less misleading aliases for xf86SetOperatingState() */
+#define resVgaMem resVgaMemShared
+#define resVgaIo resVgaIoShared
+#define resVga resVgaShared
+
+/* Old style names */
+#define RES_EXCLUSIVE_VGA resVgaExclusive
+#define RES_SHARED_VGA resVgaShared
+#define RES_EXCLUSIVE_8514 res8514Exclusive
+#define RES_SHARED_8514 res8514Shared
+
+#define _PCI_AVOID_PC_STYLE \
+ {ResExcIoSparse | ResBus, 0x0100, 0x0300},\
+ {ResExcIoSparse | ResBus, 0x0200, 0x0200},\
+ {ResExcMemBlock | ResBus, 0xA0000,0xFFFFF}
+
+extern resRange PciAvoid[];
+
+#define RES_UNDEFINED NULL
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Versions.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Versions.c
new file mode 100644
index 000000000..6de7d53c2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Versions.c
@@ -0,0 +1,81 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Versions.c,v 1.2 2003/08/24 20:01:19 dawes Exp $ */
+/*
+ * Copyright (c) 2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86OSmouse.h"
+#include "xf86OSKbd.h"
+
+static CARD32 registeredVersions[NUM_BUILTIN_IFS];
+
+CARD32
+xf86GetBuiltinInterfaceVersion(BuiltinInterface iface, int flags)
+{
+ if (iface < 0 || iface >= NUM_BUILTIN_IFS) {
+ xf86Msg(X_ERROR, "xf86GetBuiltinInterfaceVersion: Unexpected interface"
+ "query: %d\n", iface);
+ return 0;
+ }
+
+ if (registeredVersions[iface])
+ return registeredVersions[iface];
+
+ /* Most built-in interfaces are handled this way. */
+ switch (iface) {
+ case BUILTIN_IF_OSMOUSE:
+ return OS_MOUSE_VERSION_CURRENT;
+ case BUILTIN_IF_OSKBD:
+ return OS_KBD_VERSION_CURRENT;
+ default:
+ xf86Msg(X_ERROR, "xf86GetBuiltinInterfaceVersion: internal error: "
+ "interface %d not handled\n", iface);
+ return 0;
+ }
+}
+
+Bool
+xf86RegisterBuiltinInterfaceVersion(BuiltinInterface iface, CARD32 version,
+ int flags)
+{
+ if (iface < 0 || iface >= NUM_BUILTIN_IFS) {
+ xf86Msg(X_ERROR, "xf86RegisterBuiltinInterfaceVersion: "
+ "unexpected interface number: %d\n", iface);
+ return FALSE;
+ }
+ if (version == 0) {
+ xf86Msg(X_ERROR, "xf86RegisterBuiltinInterfaceVersion: "
+ "versions must be greater than zero\n");
+ return FALSE;
+ }
+ registeredVersions[iface] = version;
+ return TRUE;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86VidMode.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86VidMode.c
new file mode 100644
index 000000000..81e4b969e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86VidMode.c
@@ -0,0 +1,722 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86VidMode.c,v 1.17 2003/08/24 17:36:55 dawes Exp $ */
+/*
+ * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains the VidMode functions required by the extension.
+ * These have been added to avoid the need for the higher level extension
+ * code to access the private XFree86 data structures directly. Wherever
+ * possible this code uses the functions in xf86Mode.c to do the work,
+ * so that two version of code that do similar things don't have to be
+ * maintained.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+
+#ifdef XF86VIDMODE
+#include "vidmodeproc.h"
+#include "xf86cmap.h"
+
+static int VidModeGeneration = 0;
+static int VidModeIndex = -1;
+static int VidModeCount = 0;
+static Bool VidModeClose(int i, ScreenPtr pScreen);
+
+#define VMPTR(p) ((VidModePtr)(p)->devPrivates[VidModeIndex].ptr)
+
+#endif
+
+#ifdef DEBUG
+# define DEBUG_P(x) ErrorF(x"\n");
+#else
+# define DEBUG_P(x) /**/
+#endif
+
+Bool
+VidModeExtensionInit(ScreenPtr pScreen)
+{
+#ifdef XF86VIDMODE
+ VidModePtr pVidMode;
+
+ DEBUG_P("VidModeExtensionInit");
+
+ if (!xf86GetVidModeEnabled()) {
+ DEBUG_P("!xf86GetVidModeEnabled()");
+ return FALSE;
+ }
+
+ if (serverGeneration != VidModeGeneration) {
+ if ((VidModeIndex = AllocateScreenPrivateIndex()) < 0) {
+ DEBUG_P("AllocateScreenPrivateIndex() failed");
+ return FALSE;
+ }
+ VidModeGeneration = serverGeneration;
+ }
+
+ if (!(pScreen->devPrivates[VidModeIndex].ptr = xcalloc(sizeof(VidModeRec), 1))) {
+ DEBUG_P("xcalloc failed");
+ return FALSE;
+ }
+
+ pVidMode = VMPTR(pScreen);
+ pVidMode->Flags = 0;
+ pVidMode->Next = NULL;
+ pVidMode->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = VidModeClose;
+ VidModeCount++;
+ return TRUE;
+#else
+ DEBUG_P("no vidmode extension");
+ return FALSE;
+#endif
+}
+
+
+#ifdef XF86VIDMODE
+
+static Bool
+VidModeClose(int i, ScreenPtr pScreen)
+{
+ VidModePtr pVidMode = VMPTR(pScreen);
+
+ DEBUG_P("VidModeClose");
+
+ /* This shouldn't happen */
+ if (!pVidMode)
+ return FALSE;
+
+ pScreen->CloseScreen = pVidMode->CloseScreen;
+
+ if (--VidModeCount == 0) {
+ if (pScreen->devPrivates[VidModeIndex].ptr)
+ xfree(pScreen->devPrivates[VidModeIndex].ptr);
+ pScreen->devPrivates[VidModeIndex].ptr = NULL;
+ VidModeIndex = -1;
+ }
+ return pScreen->CloseScreen(i, pScreen);
+}
+
+Bool
+VidModeAvailable(int scrnIndex)
+{
+ ScrnInfoPtr pScrn;
+ VidModePtr pVidMode;
+
+ DEBUG_P("VidModeAvailable");
+
+ if (VidModeIndex < 0) {
+ DEBUG_P("VidModeIndex < 0");
+ return FALSE;
+ }
+
+ pScrn = xf86Screens[scrnIndex];
+ if (pScrn == NULL) {
+ DEBUG_P("pScrn == NULL");
+ return FALSE;
+ }
+
+ pVidMode = VMPTR(pScrn->pScreen);
+ if (pVidMode)
+ return TRUE;
+ else {
+ DEBUG_P("pVidMode == NULL");
+ return FALSE;
+ }
+}
+
+Bool
+VidModeGetCurrentModeline(int scrnIndex, pointer *mode, int *dotClock)
+{
+ ScrnInfoPtr pScrn;
+
+ DEBUG_P("VidModeGetCurrentModeline");
+
+ if (!VidModeAvailable(scrnIndex))
+ return FALSE;
+
+ pScrn = xf86Screens[scrnIndex];
+ *mode = (pointer)(pScrn->currentMode);
+ *dotClock = pScrn->currentMode->Clock;
+
+ return TRUE;
+}
+
+int
+VidModeGetDotClock(int scrnIndex, int Clock)
+{
+ ScrnInfoPtr pScrn;
+
+ DEBUG_P("VidModeGetDotClock");
+
+ if (!VidModeAvailable(scrnIndex))
+ return 0;
+
+ pScrn = xf86Screens[scrnIndex];
+ if ((pScrn->progClock) || (Clock > MAXCLOCKS))
+ return Clock;
+ else
+ return pScrn->clock[Clock];
+}
+
+int
+VidModeGetNumOfClocks(int scrnIndex, Bool *progClock)
+{
+ ScrnInfoPtr pScrn;
+
+ DEBUG_P("VidModeGetNumOfClocks");
+
+ if (!VidModeAvailable(scrnIndex))
+ return 0;
+
+ pScrn = xf86Screens[scrnIndex];
+ if (pScrn->progClock){
+ *progClock = TRUE;
+ return 0;
+ } else {
+ *progClock = FALSE;
+ return pScrn->numClocks;
+ }
+}
+
+Bool
+VidModeGetClocks(int scrnIndex, int *Clocks)
+{
+ ScrnInfoPtr pScrn;
+ int i;
+
+ DEBUG_P("VidModeGetClocks");
+
+ if (!VidModeAvailable(scrnIndex))
+ return FALSE;
+
+ pScrn = xf86Screens[scrnIndex];
+
+ if (pScrn->progClock)
+ return FALSE;
+
+ for (i = 0; i < pScrn->numClocks; i++)
+ *Clocks++ = pScrn->clock[i];
+
+ return TRUE;
+}
+
+
+Bool
+VidModeGetFirstModeline(int scrnIndex, pointer *mode, int *dotClock)
+{
+ ScrnInfoPtr pScrn;
+ VidModePtr pVidMode;
+
+ DEBUG_P("VidModeGetFirstModeline");
+
+ if (!VidModeAvailable(scrnIndex))
+ return FALSE;
+
+ pScrn = xf86Screens[scrnIndex];
+ pVidMode = VMPTR(pScrn->pScreen);
+ pVidMode->First = pScrn->modes;
+ pVidMode->Next = pVidMode->First->next;
+
+ if (pVidMode->First->status == MODE_OK) {
+ *mode = (pointer)(pVidMode->First);
+ *dotClock = VidModeGetDotClock(scrnIndex, pVidMode->First->Clock);
+ return TRUE;
+ }
+
+ return VidModeGetNextModeline(scrnIndex, mode, dotClock);
+}
+
+Bool
+VidModeGetNextModeline(int scrnIndex, pointer *mode, int *dotClock)
+{
+ ScrnInfoPtr pScrn;
+ VidModePtr pVidMode;
+ DisplayModePtr p;
+
+ DEBUG_P("VidModeGetNextModeline");
+
+ if (!VidModeAvailable(scrnIndex))
+ return FALSE;
+
+ pScrn = xf86Screens[scrnIndex];
+ pVidMode = VMPTR(pScrn->pScreen);
+
+ for (p = pVidMode->Next; p != NULL && p != pVidMode->First; p = p->next) {
+ if (p->status == MODE_OK) {
+ pVidMode->Next = p->next;
+ *mode = (pointer)p;
+ *dotClock = VidModeGetDotClock(scrnIndex, p->Clock);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+Bool
+VidModeDeleteModeline(int scrnIndex, pointer mode)
+{
+ ScrnInfoPtr pScrn;
+
+ DEBUG_P("VidModeDeleteModeline");
+
+ if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
+ return FALSE;
+
+ pScrn = xf86Screens[scrnIndex];
+ xf86DeleteMode(&(pScrn->modes), (DisplayModePtr)mode);
+ return TRUE;
+}
+
+Bool
+VidModeZoomViewport(int scrnIndex, int zoom)
+{
+ ScrnInfoPtr pScrn;
+
+ DEBUG_P("VidModeZoomViewPort");
+
+ if (!VidModeAvailable(scrnIndex))
+ return FALSE;
+
+ pScrn = xf86Screens[scrnIndex];
+ xf86ZoomViewport(pScrn->pScreen, zoom);
+ return TRUE;
+}
+
+Bool
+VidModeSetViewPort(int scrnIndex, int x, int y)
+{
+ ScrnInfoPtr pScrn;
+
+ DEBUG_P("VidModeSetViewPort");
+
+ if (!VidModeAvailable(scrnIndex))
+ return FALSE;
+
+ pScrn = xf86Screens[scrnIndex];
+ pScrn->frameX0 = min( max(x, 0),
+ pScrn->virtualX - pScrn->currentMode->HDisplay );
+ pScrn->frameX1 = pScrn->frameX0 + pScrn->currentMode->HDisplay - 1;
+ pScrn->frameY0 = min( max(y, 0),
+ pScrn->virtualY - pScrn->currentMode->VDisplay );
+ pScrn->frameY1 = pScrn->frameY0 + pScrn->currentMode->VDisplay - 1;
+ if (pScrn->AdjustFrame != NULL)
+ (pScrn->AdjustFrame)(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
+ return TRUE;
+}
+
+Bool
+VidModeGetViewPort(int scrnIndex, int *x, int *y)
+{
+ ScrnInfoPtr pScrn;
+
+ DEBUG_P("VidModeGetViewPort");
+
+ if (!VidModeAvailable(scrnIndex))
+ return FALSE;
+
+ pScrn = xf86Screens[scrnIndex];
+ *x = pScrn->frameX0;
+ *y = pScrn->frameY0;
+ return TRUE;
+}
+
+Bool
+VidModeSwitchMode(int scrnIndex, pointer mode)
+{
+ ScrnInfoPtr pScrn;
+ DisplayModePtr pTmpMode;
+ Bool retval;
+
+ DEBUG_P("VidModeSwitchMode");
+
+ if (!VidModeAvailable(scrnIndex))
+ return FALSE;
+
+ pScrn = xf86Screens[scrnIndex];
+ /* save in case we fail */
+ pTmpMode = pScrn->currentMode;
+ /* Force a mode switch */
+ pScrn->currentMode = NULL;
+ retval = xf86SwitchMode(pScrn->pScreen, mode);
+ /* we failed: restore it */
+ if (retval == FALSE)
+ pScrn->currentMode = pTmpMode;
+ return retval;
+}
+
+Bool
+VidModeLockZoom(int scrnIndex, Bool lock)
+{
+ ScrnInfoPtr pScrn;
+
+ DEBUG_P("VidModeLockZoom");
+
+ if (!VidModeAvailable(scrnIndex))
+ return FALSE;
+
+ pScrn = xf86Screens[scrnIndex];
+
+ if (xf86Info.dontZoom)
+ return FALSE;
+
+ xf86LockZoom(pScrn->pScreen, lock);
+ return TRUE;
+}
+
+Bool
+VidModeGetMonitor(int scrnIndex, pointer *monitor)
+{
+ ScrnInfoPtr pScrn;
+
+ DEBUG_P("VidModeGetMonitor");
+
+ if (!VidModeAvailable(scrnIndex))
+ return FALSE;
+
+ pScrn = xf86Screens[scrnIndex];
+ *monitor = (pointer)(pScrn->monitor);
+
+ return TRUE;
+}
+
+ModeStatus
+VidModeCheckModeForMonitor(int scrnIndex, pointer mode)
+{
+ ScrnInfoPtr pScrn;
+
+ DEBUG_P("VidModeCheckModeForMonitor");
+
+ if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
+ return MODE_ERROR;
+
+ pScrn = xf86Screens[scrnIndex];
+
+ return xf86CheckModeForMonitor((DisplayModePtr)mode, pScrn->monitor);
+}
+
+ModeStatus
+VidModeCheckModeForDriver(int scrnIndex, pointer mode)
+{
+ ScrnInfoPtr pScrn;
+
+ DEBUG_P("VidModeCheckModeForDriver");
+
+ if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
+ return MODE_ERROR;
+
+ pScrn = xf86Screens[scrnIndex];
+
+ return xf86CheckModeForDriver(pScrn, (DisplayModePtr)mode, 0);
+}
+
+void
+VidModeSetCrtcForMode(int scrnIndex, pointer mode)
+{
+ ScrnInfoPtr pScrn;
+ DisplayModePtr ScreenModes;
+
+ DEBUG_P("VidModeSetCrtcForMode");
+
+ if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
+ return;
+
+ /* Ugly hack so that the xf86Mode.c function can be used without change */
+ pScrn = xf86Screens[scrnIndex];
+ ScreenModes = pScrn->modes;
+ pScrn->modes = (DisplayModePtr)mode;
+
+ xf86SetCrtcForModes(pScrn, pScrn->adjustFlags);
+ pScrn->modes = ScreenModes;
+ return;
+}
+
+Bool
+VidModeAddModeline(int scrnIndex, pointer mode)
+{
+ ScrnInfoPtr pScrn;
+
+ DEBUG_P("VidModeAddModeline");
+
+ if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
+ return FALSE;
+
+ pScrn = xf86Screens[scrnIndex];
+
+ ((DisplayModePtr)mode)->name = strdup(""); /* freed by deletemode */
+ ((DisplayModePtr)mode)->status = MODE_OK;
+ ((DisplayModePtr)mode)->next = pScrn->modes->next;
+ ((DisplayModePtr)mode)->prev = pScrn->modes;
+ pScrn->modes->next = (DisplayModePtr)mode;
+ if( ((DisplayModePtr)mode)->next != NULL )
+ ((DisplayModePtr)mode)->next->prev = (DisplayModePtr)mode;
+
+ return TRUE;
+}
+
+int
+VidModeGetNumOfModes(int scrnIndex)
+{
+ pointer mode = NULL;
+ int dotClock= 0, nummodes = 0;
+
+ DEBUG_P("VidModeGetNumOfModes");
+
+ if (!VidModeGetFirstModeline(scrnIndex, &mode, &dotClock))
+ return nummodes;
+
+ do {
+ nummodes++;
+ if (!VidModeGetNextModeline(scrnIndex, &mode, &dotClock))
+ return nummodes;
+ } while (TRUE);
+}
+
+Bool
+VidModeSetGamma(int scrnIndex, float red, float green, float blue)
+{
+ ScrnInfoPtr pScrn;
+ Gamma gamma;
+
+ DEBUG_P("VidModeSetGamma");
+
+ if (!VidModeAvailable(scrnIndex))
+ return FALSE;
+
+ pScrn = xf86Screens[scrnIndex];
+ gamma.red = red;
+ gamma.green = green;
+ gamma.blue = blue;
+ if (xf86ChangeGamma(pScrn->pScreen, gamma) != Success)
+ return FALSE;
+ else
+ return TRUE;
+}
+
+Bool
+VidModeGetGamma(int scrnIndex, float *red, float *green, float *blue)
+{
+ ScrnInfoPtr pScrn;
+
+ DEBUG_P("VidModeGetGamma");
+
+ if (!VidModeAvailable(scrnIndex))
+ return FALSE;
+
+ pScrn = xf86Screens[scrnIndex];
+ *red = pScrn->gamma.red;
+ *green = pScrn->gamma.green;
+ *blue = pScrn->gamma.blue;
+ return TRUE;
+}
+
+Bool
+VidModeSetGammaRamp(int scrnIndex, int size, CARD16 *r, CARD16 *g, CARD16 *b)
+{
+ ScrnInfoPtr pScrn;
+
+ if (!VidModeAvailable(scrnIndex))
+ return FALSE;
+
+ pScrn = xf86Screens[scrnIndex];
+ xf86ChangeGammaRamp(pScrn->pScreen, size, r, g, b);
+ return TRUE;
+}
+
+Bool
+VidModeGetGammaRamp(int scrnIndex, int size, CARD16 *r, CARD16 *g, CARD16 *b)
+{
+ ScrnInfoPtr pScrn;
+
+ if (!VidModeAvailable(scrnIndex))
+ return FALSE;
+
+ pScrn = xf86Screens[scrnIndex];
+ xf86GetGammaRamp(pScrn->pScreen, size, r, g, b);
+ return TRUE;
+}
+
+int
+VidModeGetGammaRampSize(int scrnIndex)
+{
+ if (!VidModeAvailable(scrnIndex))
+ return 0;
+
+ return xf86GetGammaRampSize(xf86Screens[scrnIndex]->pScreen);
+}
+
+pointer
+VidModeCreateMode(void)
+{
+ DisplayModePtr mode;
+
+ mode = xalloc(sizeof(DisplayModeRec));
+ if (mode != NULL) {
+ mode->name = "";
+ mode->VScan = 1; /* divides refresh rate. default = 1 */
+ mode->Private = NULL;
+ mode->next = mode;
+ mode->prev = mode;
+ }
+ return mode;
+}
+
+void
+VidModeCopyMode(pointer modefrom, pointer modeto)
+{
+ memcpy(modeto, modefrom, sizeof(DisplayModeRec));
+}
+
+
+int
+VidModeGetModeValue(pointer mode, int valtyp)
+{
+ int ret = 0;
+
+ switch (valtyp) {
+ case VIDMODE_H_DISPLAY:
+ ret = ((DisplayModePtr) mode)->HDisplay;
+ break;
+ case VIDMODE_H_SYNCSTART:
+ ret = ((DisplayModePtr)mode)->HSyncStart;
+ break;
+ case VIDMODE_H_SYNCEND:
+ ret = ((DisplayModePtr)mode)->HSyncEnd;
+ break;
+ case VIDMODE_H_TOTAL:
+ ret = ((DisplayModePtr)mode)->HTotal;
+ break;
+ case VIDMODE_H_SKEW:
+ ret = ((DisplayModePtr)mode)->HSkew;
+ break;
+ case VIDMODE_V_DISPLAY:
+ ret = ((DisplayModePtr)mode)->VDisplay;
+ break;
+ case VIDMODE_V_SYNCSTART:
+ ret = ((DisplayModePtr)mode)->VSyncStart;
+ break;
+ case VIDMODE_V_SYNCEND:
+ ret = ((DisplayModePtr)mode)->VSyncEnd;
+ break;
+ case VIDMODE_V_TOTAL:
+ ret = ((DisplayModePtr)mode)->VTotal;
+ break;
+ case VIDMODE_FLAGS:
+ ret = ((DisplayModePtr)mode)->Flags;
+ break;
+ case VIDMODE_CLOCK:
+ ret = ((DisplayModePtr)mode)->Clock;
+ break;
+ }
+ return ret;
+}
+
+void
+VidModeSetModeValue(pointer mode, int valtyp, int val)
+{
+ switch (valtyp) {
+ case VIDMODE_H_DISPLAY:
+ ((DisplayModePtr)mode)->HDisplay = val;
+ break;
+ case VIDMODE_H_SYNCSTART:
+ ((DisplayModePtr)mode)->HSyncStart = val;
+ break;
+ case VIDMODE_H_SYNCEND:
+ ((DisplayModePtr)mode)->HSyncEnd = val;
+ break;
+ case VIDMODE_H_TOTAL:
+ ((DisplayModePtr)mode)->HTotal = val;
+ break;
+ case VIDMODE_H_SKEW:
+ ((DisplayModePtr)mode)->HSkew = val;
+ break;
+ case VIDMODE_V_DISPLAY:
+ ((DisplayModePtr)mode)->VDisplay = val;
+ break;
+ case VIDMODE_V_SYNCSTART:
+ ((DisplayModePtr)mode)->VSyncStart = val;
+ break;
+ case VIDMODE_V_SYNCEND:
+ ((DisplayModePtr)mode)->VSyncEnd = val;
+ break;
+ case VIDMODE_V_TOTAL:
+ ((DisplayModePtr)mode)->VTotal = val;
+ break;
+ case VIDMODE_FLAGS:
+ ((DisplayModePtr)mode)->Flags = val;
+ break;
+ case VIDMODE_CLOCK:
+ ((DisplayModePtr)mode)->Clock = val;
+ break;
+ }
+ return;
+}
+
+vidMonitorValue
+VidModeGetMonitorValue(pointer monitor, int valtyp, int indx)
+{
+ vidMonitorValue ret;
+
+ switch (valtyp) {
+ case VIDMODE_MON_VENDOR:
+ ret.ptr = (((MonPtr)monitor)->vendor);
+ break;
+ case VIDMODE_MON_MODEL:
+ ret.ptr = (((MonPtr)monitor)->model);
+ break;
+ case VIDMODE_MON_NHSYNC:
+ ret.i = ((MonPtr)monitor)->nHsync;
+ break;
+ case VIDMODE_MON_NVREFRESH:
+ ret.i = ((MonPtr)monitor)->nVrefresh;
+ break;
+ case VIDMODE_MON_HSYNC_LO:
+ ret.f = (100.0 * ((MonPtr)monitor)->hsync[indx].lo);
+ break;
+ case VIDMODE_MON_HSYNC_HI:
+ ret.f = (100.0 * ((MonPtr)monitor)->hsync[indx].hi);
+ break;
+ case VIDMODE_MON_VREFRESH_LO:
+ ret.f = (100.0 * ((MonPtr)monitor)->vrefresh[indx].lo);
+ break;
+ case VIDMODE_MON_VREFRESH_HI:
+ ret.f = (100.0 * ((MonPtr)monitor)->vrefresh[indx].hi);
+ break;
+ }
+ return ret;
+}
+
+
+#endif /* XF86VIDMODE */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86XKB.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86XKB.c
new file mode 100644
index 000000000..68be17c3a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86XKB.c
@@ -0,0 +1,82 @@
+/* $XConsortium: xf86XKB.c /main/4 1996/02/04 09:28:04 kaleb $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/*
+ * Copyright (c) 1994-2002 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86XKB.c,v 3.12 2003/08/24 17:36:55 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/extensions/XI.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
+#include "xf86_OSlib.h"
+
+#include <X11/extensions/XKBsrv.h>
+
+void
+xf86InitXkb(void)
+{
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Xinput.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Xinput.c
new file mode 100644
index 000000000..cc9e76361
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Xinput.c
@@ -0,0 +1,1513 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c,v 3.70 2003/11/03 05:11:02 tsi Exp $ */
+/*
+ * Copyright 1995-1999 by Frederic Lepied, France. <Lepied@XFree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Frederic Lepied not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Frederic Lepied makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*
+ * Copyright (c) 2000-2002 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+/* $XConsortium: xf86Xinput.c /main/14 1996/10/27 11:05:25 kaleb $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c,v 1.7 2005/10/21 19:06:13 ajax Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/Xfuncproto.h>
+#include <X11/Xmd.h>
+#ifdef XINPUT
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#endif
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Xinput.h"
+#ifdef XINPUT
+#include "XIstubs.h"
+#endif
+#include "mipointer.h"
+#include "xf86InPriv.h"
+
+#ifdef DPMSExtension
+#define DPMS_SERVER
+#include <X11/extensions/dpms.h>
+#include "dpmsproc.h"
+#endif
+
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+
+#include "exevents.h" /* AddInputDevice */
+#include "exglobals.h"
+
+#define EXTENSION_PROC_ARGS void *
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+
+#include "windowstr.h" /* screenIsSaved */
+
+#include <stdarg.h>
+
+#include "osdep.h" /* EnabledDevices */
+#include <X11/Xpoll.h>
+#include "xf86_OSproc.h" /* sigio stuff */
+
+/******************************************************************************
+ * debugging macro
+ *****************************************************************************/
+#ifdef DBG
+#undef DBG
+#endif
+#ifdef DEBUG
+#undef DEBUG
+#endif
+
+#define DEBUG 0
+
+#if DEBUG
+static int debug_level = 0;
+
+#define DBG(lvl, f) {if ((lvl) <= debug_level) f;}
+#else
+#define DBG(lvl, f)
+#endif
+
+/******************************************************************************
+ * macros
+ *****************************************************************************/
+#define ENQUEUE(e) xf86eqEnqueue((e))
+
+/***********************************************************************
+ *
+ * xf86AlwaysCoreControl --
+ *
+ * Control proc for the integer feedback that controls the always
+ * core feature.
+ *
+ ***********************************************************************
+ */
+static void
+xf86AlwaysCoreControl(DeviceIntPtr device,
+ IntegerCtrl *control)
+{
+}
+
+/***********************************************************************
+ *
+ * Core devices functions --
+ *
+ * Test if device is the core device by checking the
+ * value of always core feedback and the inputInfo struct.
+ *
+ ***********************************************************************
+ */
+int
+xf86IsCorePointer(DeviceIntPtr device)
+{
+ return(device == inputInfo.pointer);
+}
+
+static int
+xf86ShareCorePointer(DeviceIntPtr device)
+{
+ LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
+
+ return((local->always_core_feedback &&
+ local->always_core_feedback->ctrl.integer_displayed));
+}
+
+static Bool
+xf86SendDragEvents(DeviceIntPtr device)
+{
+ LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
+
+ if (inputInfo.pointer->button->buttonsDown > 0)
+ return (local->flags & XI86_SEND_DRAG_EVENTS);
+ else
+ return (TRUE);
+}
+
+int
+xf86IsCoreKeyboard(DeviceIntPtr device)
+{
+ LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
+
+ return((local->flags & XI86_ALWAYS_CORE) ||
+ (device == inputInfo.keyboard));
+}
+
+void
+xf86XInputSetSendCoreEvents(LocalDevicePtr local, Bool always)
+{
+ if (always) {
+ local->flags |= XI86_ALWAYS_CORE;
+ } else {
+ local->flags &= ~XI86_ALWAYS_CORE;
+ }
+}
+
+static int xf86CoreButtonState;
+
+/***********************************************************************
+ *
+ * xf86CheckButton --
+ *
+ * Test if the core pointer button state is coherent with
+ * the button event to send.
+ *
+ ***********************************************************************
+ */
+Bool
+xf86CheckButton(int button,
+ int down)
+{
+ int check;
+ int bit = (1 << (button - 1));
+
+ check = xf86CoreButtonState & bit;
+
+ DBG(5, ErrorF("xf86CheckButton "
+ "button=%d down=%d state=%d check=%d returns ",
+ button, down, xf86CoreButtonState, check));
+ if ((check && down) || (!check && !down)) {
+ DBG(5, ErrorF("FALSE\n"));
+ return FALSE;
+ }
+ xf86CoreButtonState ^= bit;
+
+ DBG(5, ErrorF("TRUE\n"));
+ return TRUE;
+}
+
+/***********************************************************************
+ *
+ * xf86ProcessCommonOptions --
+ *
+ * Process global options.
+ *
+ ***********************************************************************
+ */
+void
+xf86ProcessCommonOptions(LocalDevicePtr local,
+ pointer list)
+{
+ if (xf86SetBoolOption(list, "AlwaysCore", 0) ||
+ xf86SetBoolOption(list, "SendCoreEvents", 0)) {
+ local->flags |= XI86_ALWAYS_CORE;
+ xf86Msg(X_CONFIG, "%s: always reports core events\n", local->name);
+ }
+
+ if (xf86SetBoolOption(list, "CorePointer", 0)) {
+ local->flags |= XI86_CORE_POINTER;
+ xf86Msg(X_CONFIG, "%s: Core Pointer\n", local->name);
+ }
+
+ if (xf86SetBoolOption(list, "CoreKeyboard", 0)) {
+ local->flags |= XI86_CORE_KEYBOARD;
+ xf86Msg(X_CONFIG, "%s: Core Keyboard\n", local->name);
+ }
+
+ if (xf86SetBoolOption(list, "SendDragEvents", 1)) {
+ local->flags |= XI86_SEND_DRAG_EVENTS;
+ } else {
+ xf86Msg(X_CONFIG, "%s: doesn't report drag events\n", local->name);
+ }
+
+ local->history_size = xf86SetIntOption(list, "HistorySize", 0);
+
+ if (local->history_size > 0) {
+ xf86Msg(X_CONFIG, "%s: has a history of %d motions\n", local->name,
+ local->history_size);
+ }
+}
+
+/***********************************************************************
+ *
+ * xf86XinputFinalizeInit --
+ *
+ * Create and initialize an integer feedback to control the always
+ * core feature.
+ *
+ ***********************************************************************
+ */
+void
+xf86XinputFinalizeInit(DeviceIntPtr dev)
+{
+ LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate;
+
+ local->dxremaind = 0.0;
+ local->dyremaind = 0.0;
+
+ if (InitIntegerFeedbackClassDeviceStruct(dev, xf86AlwaysCoreControl) == FALSE) {
+ ErrorF("Unable to init integer feedback for always core feature\n");
+ } else {
+ local->always_core_feedback = dev->intfeed;
+ dev->intfeed->ctrl.integer_displayed = (local->flags & XI86_ALWAYS_CORE) ? 1 : 0;
+ }
+}
+
+/***********************************************************************
+ *
+ * xf86ActivateDevice --
+ *
+ * Initialize an input device.
+ *
+ ***********************************************************************
+ */
+void
+xf86ActivateDevice(LocalDevicePtr local)
+{
+ DeviceIntPtr dev;
+
+ if (local->flags & XI86_CONFIGURED) {
+ int open_on_init;
+
+ open_on_init = local->flags &
+ (XI86_OPEN_ON_INIT |
+ XI86_ALWAYS_CORE | XI86_CORE_POINTER | XI86_CORE_KEYBOARD);
+
+ dev = AddInputDevice(local->device_control,
+ open_on_init);
+ if (dev == NULL)
+ FatalError("Too many input devices");
+
+ local->atom = MakeAtom(local->type_name,
+ strlen(local->type_name),
+ TRUE);
+ AssignTypeAndName (dev, local->atom, local->name);
+ dev->public.devicePrivate = (pointer) local;
+ local->dev = dev;
+
+ xf86XinputFinalizeInit(dev);
+
+ /*
+ * XXX Can a single device instance be both core keyboard and
+ * core pointer? If so, this should be changed.
+ */
+ if (local->flags & XI86_CORE_POINTER)
+ RegisterPointerDevice(dev);
+ else if (local->flags & XI86_CORE_KEYBOARD)
+ RegisterKeyboardDevice(dev);
+#ifdef XINPUT
+ else
+ RegisterOtherDevice(dev);
+#endif
+
+ if (serverGeneration == 1)
+ xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n",
+ local->name, local->type_name);
+ }
+}
+
+
+#ifdef XINPUT
+/***********************************************************************
+ *
+ * Caller: ProcXOpenDevice
+ *
+ * This is the implementation-dependent routine to open an input device.
+ * Some implementations open all input devices when the server is first
+ * initialized, and never close them. Other implementations open only
+ * the X pointer and keyboard devices during server initialization,
+ * and only open other input devices when some client makes an
+ * XOpenDevice request. This entry point is for the latter type of
+ * implementation.
+ *
+ * If the physical device is not already open, do it here. In this case,
+ * you need to keep track of the fact that one or more clients has the
+ * device open, and physically close it when the last client that has
+ * it open does an XCloseDevice.
+ *
+ * The default implementation is to do nothing (assume all input devices
+ * are opened during X server initialization and kept open).
+ *
+ ***********************************************************************
+ */
+
+void
+OpenInputDevice(DeviceIntPtr dev,
+ ClientPtr client,
+ int *status)
+{
+ if (!dev->inited) {
+ *status = BadDevice;
+ } else {
+ if (!dev->public.on) {
+ if (!EnableDevice(dev)) {
+ *status = BadDevice;
+ } else {
+ /* to prevent ProcXOpenDevice to call EnableDevice again */
+ dev->startup = FALSE;
+ }
+ }
+ }
+}
+
+
+/***********************************************************************
+ *
+ * Caller: ProcXChangeKeyboardDevice
+ *
+ * This procedure does the implementation-dependent portion of the work
+ * needed to change the keyboard device.
+ *
+ * The X keyboard device has a FocusRec. If the device that has been
+ * made into the new X keyboard did not have a FocusRec,
+ * ProcXChangeKeyboardDevice will allocate one for it.
+ *
+ * If you do not want clients to be able to focus the old X keyboard
+ * device, call DeleteFocusClassDeviceStruct to free the FocusRec.
+ *
+ * If you support input devices with keys that you do not want to be
+ * used as the X keyboard, you need to check for them here and return
+ * a BadDevice error.
+ *
+ * The default implementation is to do nothing (assume you do want
+ * clients to be able to focus the old X keyboard). The commented-out
+ * sample code shows what you might do if you don't want the default.
+ *
+ ***********************************************************************
+ */
+
+int
+ChangeKeyboardDevice (DeviceIntPtr old_dev, DeviceIntPtr new_dev)
+{
+ /**********************************************************************
+ * DeleteFocusClassDeviceStruct(old_dev); * defined in xchgptr.c *
+ **********************************************************************/
+ return !Success;
+}
+
+
+/***********************************************************************
+ *
+ * Caller: ProcXChangePointerDevice
+ *
+ * This procedure does the implementation-dependent portion of the work
+ * needed to change the pointer device.
+ *
+ * The X pointer device does not have a FocusRec. If the device that
+ * has been made into the new X pointer had a FocusRec,
+ * ProcXChangePointerDevice will free it.
+ *
+ * If you want clients to be able to focus the old pointer device that
+ * has now become accessible through the input extension, you need to
+ * add a FocusRec to it here.
+ *
+ * The XChangePointerDevice protocol request also allows the client
+ * to choose which axes of the new pointer device are used to move
+ * the X cursor in the X- and Y- directions. If the axes are different
+ * than the default ones, you need to keep track of that here.
+ *
+ * If you support input devices with valuators that you do not want to be
+ * used as the X pointer, you need to check for them here and return a
+ * BadDevice error.
+ *
+ * The default implementation is to do nothing (assume you don't want
+ * clients to be able to focus the old X pointer). The commented-out
+ * sample code shows what you might do if you don't want the default.
+ *
+ ***********************************************************************
+ */
+
+int
+ChangePointerDevice (
+ DeviceIntPtr old_dev,
+ DeviceIntPtr new_dev,
+ unsigned char x,
+ unsigned char y)
+{
+ /************************************************************************
+ InitFocusClassDeviceStruct(old_dev); * allow focusing old ptr*
+
+ x_axis = x; * keep track of new x-axis*
+ y_axis = y; * keep track of new y-axis*
+ if (x_axis != 0 || y_axis != 1)
+ axes_changed = TRUE; * remember axes have changed*
+ else
+ axes_changed = FALSE;
+ *************************************************************************/
+
+ /*
+ * We don't allow axis swap or other exotic features.
+ */
+ if (x == 0 && y == 1) {
+ LocalDevicePtr old_local = (LocalDevicePtr)old_dev->public.devicePrivate;
+ LocalDevicePtr new_local = (LocalDevicePtr)new_dev->public.devicePrivate;
+
+ InitFocusClassDeviceStruct(old_dev);
+
+ /* Restore Extended motion history information */
+ old_dev->valuator->GetMotionProc = old_local->motion_history_proc;
+ old_dev->valuator->numMotionEvents = old_local->history_size;
+
+ /* Save Extended motion history information */
+ new_local->motion_history_proc = new_dev->valuator->GetMotionProc;
+ new_local->history_size = new_dev->valuator->numMotionEvents;
+
+ /* Set Core motion history information */
+ new_dev->valuator->GetMotionProc = miPointerGetMotionEvents;
+ new_dev->valuator->numMotionEvents = miPointerGetMotionBufferSize();
+
+ return Success;
+ }
+ else
+ return !Success;
+}
+
+
+/***********************************************************************
+ *
+ * Caller: ProcXCloseDevice
+ *
+ * Take care of implementation-dependent details of closing a device.
+ * Some implementations may actually close the device, others may just
+ * remove this clients interest in that device.
+ *
+ * The default implementation is to do nothing (assume all input devices
+ * are initialized during X server initialization and kept open).
+ *
+ ***********************************************************************
+ */
+
+void
+CloseInputDevice (DeviceIntPtr d, ClientPtr client)
+{
+ ErrorF("ProcXCloseDevice to close or not ?\n");
+}
+
+
+/***********************************************************************
+ *
+ * Caller: ProcXListInputDevices
+ *
+ * This is the implementation-dependent routine to initialize an input
+ * device to the point that information about it can be listed.
+ * Some implementations open all input devices when the server is first
+ * initialized, and never close them. Other implementations open only
+ * the X pointer and keyboard devices during server initialization,
+ * and only open other input devices when some client makes an
+ * XOpenDevice request. If some other process has the device open, the
+ * server may not be able to get information about the device to list it.
+ *
+ * This procedure should be used by implementations that do not initialize
+ * all input devices at server startup. It should do device-dependent
+ * initialization for any devices not previously initialized, and call
+ * AddInputDevice for each of those devices so that a DeviceIntRec will be
+ * created for them.
+ *
+ * The default implementation is to do nothing (assume all input devices
+ * are initialized during X server initialization and kept open).
+ * The commented-out sample code shows what you might do if you don't want
+ * the default.
+ *
+ ***********************************************************************
+ */
+
+void
+AddOtherInputDevices ()
+{
+}
+
+
+/****************************************************************************
+ *
+ * Caller: ProcXSetDeviceMode
+ *
+ * Change the mode of an extension device.
+ * This function is used to change the mode of a device from reporting
+ * relative motion to reporting absolute positional information, and
+ * vice versa.
+ * The default implementation below is that no such devices are supported.
+ *
+ ***********************************************************************
+ */
+
+int
+SetDeviceMode (ClientPtr client, DeviceIntPtr dev, int mode)
+{
+ LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate;
+
+ if (local->switch_mode) {
+ return (*local->switch_mode)(client, dev, mode);
+ }
+ else
+ return BadMatch;
+}
+
+
+/***********************************************************************
+ *
+ * Caller: ProcXSetDeviceValuators
+ *
+ * Set the value of valuators on an extension input device.
+ * This function is used to set the initial value of valuators on
+ * those input devices that are capable of reporting either relative
+ * motion or an absolute position, and allow an initial position to be set.
+ * The default implementation below is that no such devices are supported.
+ *
+ ***********************************************************************
+ */
+
+int
+SetDeviceValuators (ClientPtr client, DeviceIntPtr dev, int *valuators,
+ int first_valuator, int num_valuators)
+{
+ return BadMatch;
+}
+
+
+/***********************************************************************
+ *
+ * Caller: ProcXChangeDeviceControl
+ *
+ * Change the specified device controls on an extension input device.
+ *
+ ***********************************************************************
+ */
+
+int
+ChangeDeviceControl (ClientPtr client, DeviceIntPtr dev, xDeviceCtl *control)
+{
+ LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate;
+
+ if (!local->control_proc) {
+ return (BadMatch);
+ }
+ else {
+ return (*local->control_proc)(local, control);
+ }
+}
+#endif
+
+/*
+ * adapted from mieq.c to support extended events
+ *
+ */
+#define QUEUE_SIZE 256
+
+typedef struct _Event {
+ xEvent event;
+#ifdef XINPUT
+ deviceValuator val;
+#endif
+ ScreenPtr pScreen;
+} EventRec, *EventPtr;
+
+typedef struct _EventQueue {
+ HWEventQueueType head, tail;
+ CARD32 lastEventTime; /* to avoid time running backwards */
+ Bool lastMotion;
+ EventRec events[QUEUE_SIZE]; /* static allocation for signals */
+ DevicePtr pKbd, pPtr; /* device pointer, to get funcs */
+ ScreenPtr pEnqueueScreen; /* screen events are being delivered to */
+ ScreenPtr pDequeueScreen; /* screen events are being dispatched to */
+} EventQueueRec, *EventQueuePtr;
+
+static EventQueueRec xf86EventQueue;
+
+Bool
+xf86eqInit (DevicePtr pKbd, DevicePtr pPtr)
+{
+ xf86EventQueue.head = xf86EventQueue.tail = 0;
+ xf86EventQueue.lastEventTime = GetTimeInMillis ();
+ xf86EventQueue.pKbd = pKbd;
+ xf86EventQueue.pPtr = pPtr;
+ xf86EventQueue.lastMotion = FALSE;
+ xf86EventQueue.pEnqueueScreen = screenInfo.screens[0];
+ xf86EventQueue.pDequeueScreen = xf86EventQueue.pEnqueueScreen;
+ SetInputCheck (&xf86EventQueue.head, &xf86EventQueue.tail);
+ return TRUE;
+}
+
+/*
+ * Must be reentrant with ProcessInputEvents. Assumption: xf86eqEnqueue
+ * will never be interrupted. If this is called from both signal
+ * handlers and regular code, make sure the signal is suspended when
+ * called from regular code.
+ */
+
+void
+xf86eqEnqueue (xEvent *e)
+{
+ int oldtail, newtail;
+ Bool isMotion;
+#ifdef XINPUT
+ int count;
+
+ xf86AssertBlockedSIGIO ("xf86eqEnqueue");
+ switch (e->u.u.type) {
+ case KeyPress:
+ case KeyRelease:
+#ifdef XFreeXDGA
+ /* we do this here, because nobody seems to be calling
+ xf86PostKeyEvent(). We can't steal MotionNotify events here
+ because the motion-relative information has been lost already. */
+ if(DGAStealKeyEvent(xf86EventQueue.pEnqueueScreen->myNum, e))
+ return;
+#endif
+ /* fall through */
+ case ButtonPress:
+ case ButtonRelease:
+ case MotionNotify:
+ count = 1;
+ break;
+ default:
+#ifdef XFreeXDGA
+ if (DGAIsDgaEvent (e))
+ {
+ count = 1;
+ break;
+ }
+#endif
+ if (!((deviceKeyButtonPointer *) e)->deviceid & MORE_EVENTS) {
+ count = 1;
+ }
+ else {
+ count = 2;
+ }
+ break;
+ }
+#endif
+
+ oldtail = xf86EventQueue.tail;
+ isMotion = e->u.u.type == MotionNotify;
+ if (isMotion && xf86EventQueue.lastMotion && oldtail != xf86EventQueue.head) {
+ if (oldtail == 0)
+ oldtail = QUEUE_SIZE;
+ oldtail = oldtail - 1;
+ }
+ else {
+ newtail = oldtail + 1;
+ if (newtail == QUEUE_SIZE)
+ newtail = 0;
+ /* Toss events which come in late */
+ if (newtail == xf86EventQueue.head)
+ return;
+ xf86EventQueue.tail = newtail;
+ }
+
+ xf86EventQueue.lastMotion = isMotion;
+ xf86EventQueue.events[oldtail].event = *e;
+#ifdef XINPUT
+ if (count == 2) {
+ xf86EventQueue.events[oldtail].val = *((deviceValuator *) (((deviceKeyButtonPointer *) e)+1));
+ }
+#endif
+ /*
+ * Make sure that event times don't go backwards - this
+ * is "unnecessary", but very useful
+ */
+ if (e->u.keyButtonPointer.time < xf86EventQueue.lastEventTime &&
+ xf86EventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000) {
+
+ xf86EventQueue.events[oldtail].event.u.keyButtonPointer.time =
+ xf86EventQueue.lastEventTime;
+ }
+ xf86EventQueue.events[oldtail].pScreen = xf86EventQueue.pEnqueueScreen;
+}
+
+/*
+ * Call this from ProcessInputEvents()
+ */
+void
+xf86eqProcessInputEvents ()
+{
+ EventRec *e;
+ int x, y;
+ struct {
+ xEvent event;
+#ifdef XINPUT
+ deviceValuator val;
+#endif
+ } xe;
+#ifdef XINPUT
+ DeviceIntPtr dev;
+ int id, count;
+ deviceKeyButtonPointer *dev_xe;
+#endif
+
+ while (xf86EventQueue.head != xf86EventQueue.tail) {
+ if (screenIsSaved == SCREEN_SAVER_ON)
+ SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
+#ifdef DPMSExtension
+ if (DPMSPowerLevel != DPMSModeOn)
+ DPMSSet(DPMSModeOn);
+#endif
+
+ e = &xf86EventQueue.events[xf86EventQueue.head];
+ /*
+ * Assumption - screen switching can only occur on motion events
+ */
+ if (e->pScreen != xf86EventQueue.pDequeueScreen) {
+ xf86EventQueue.pDequeueScreen = e->pScreen;
+ x = e->event.u.keyButtonPointer.rootX;
+ y = e->event.u.keyButtonPointer.rootY;
+ if (xf86EventQueue.head == QUEUE_SIZE - 1)
+ xf86EventQueue.head = 0;
+ else
+ ++xf86EventQueue.head;
+ NewCurrentScreen (xf86EventQueue.pDequeueScreen, x, y);
+ }
+ else {
+ xe.event = e->event;
+ xe.val = e->val;
+ if (xf86EventQueue.head == QUEUE_SIZE - 1)
+ xf86EventQueue.head = 0;
+ else
+ ++xf86EventQueue.head;
+ switch (xe.event.u.u.type) {
+ case KeyPress:
+ case KeyRelease:
+ (*xf86EventQueue.pKbd->processInputProc)
+ (&xe.event, (DeviceIntPtr)xf86EventQueue.pKbd, 1);
+ break;
+#ifdef XINPUT
+ case ButtonPress:
+ case ButtonRelease:
+ case MotionNotify:
+ (*(inputInfo.pointer->public.processInputProc))
+ (&xe.event, (DeviceIntPtr)inputInfo.pointer, 1);
+ break;
+
+ default:
+#ifdef XFreeXDGA
+ if (DGADeliverEvent (xf86EventQueue.pDequeueScreen, &xe.event))
+ break;
+#endif
+ dev_xe = (deviceKeyButtonPointer *) &xe.event;
+ id = dev_xe->deviceid & DEVICE_BITS;
+ if (!(dev_xe->deviceid & MORE_EVENTS)) {
+ count = 1;
+ }
+ else {
+ count = 2;
+ }
+ dev = LookupDeviceIntRec(id);
+ if (dev == NULL) {
+ ErrorF("LookupDeviceIntRec id=0x%x not found\n", id);
+/* FatalError("xf86eqProcessInputEvents : device not found.\n");
+ */
+ break;
+ }
+ if (!dev->public.processInputProc) {
+ FatalError("xf86eqProcessInputEvents : device has no input proc.\n");
+ break;
+ }
+ (*dev->public.processInputProc)(&xe.event, dev, count);
+#else
+ default:
+ (*xf86EventQueue.pPtr->processInputProc)
+ (&xe.event, (DeviceIntPtr)xf86EventQueue.pPtr, 1);
+#endif
+ break;
+ }
+ }
+ }
+}
+
+void
+xf86eqSwitchScreen(ScreenPtr pScreen,
+ Bool fromDIX)
+{
+ xf86EventQueue.pEnqueueScreen = pScreen;
+
+ if (fromDIX)
+ xf86EventQueue.pDequeueScreen = pScreen;
+}
+
+/*
+ * convenient functions to post events
+ */
+
+void
+xf86PostMotionEvent(DeviceIntPtr device,
+ int is_absolute,
+ int first_valuator,
+ int num_valuators,
+ ...)
+{
+ va_list var;
+ int loop;
+ xEvent xE[2];
+ deviceKeyButtonPointer *xev = (deviceKeyButtonPointer*) xE;
+ deviceValuator *xv = (deviceValuator*) xev+1;
+ LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
+ char *buff = 0;
+ Time current;
+ Bool is_core = xf86IsCorePointer(device);
+ Bool is_shared = xf86ShareCorePointer(device);
+ Bool drag = xf86SendDragEvents(device);
+ ValuatorClassPtr val = device->valuator;
+ int valuator[6];
+ int oldaxis[6];
+ int *axisvals;
+ int dx = 0, dy = 0;
+ float mult;
+ int x, y;
+ int loop_start;
+ int i;
+ int num;
+
+ DBG(5, ErrorF("xf86PostMotionEvent BEGIN 0x%x(%s) is_core=%s is_shared=%s is_absolute=%s\n",
+ device, device->name,
+ is_core ? "True" : "False",
+ is_shared ? "True" : "False",
+ is_absolute ? "True" : "False"));
+
+ xf86Info.lastEventTime = xev->time = current = GetTimeInMillis();
+
+ if (!is_core) {
+ if (HAS_MOTION_HISTORY(local)) {
+ buff = ((char *)local->motion_history +
+ (sizeof(INT32) * local->dev->valuator->numAxes + sizeof(Time)) * local->last);
+ }
+ }
+
+ if (num_valuators && (!val || (first_valuator + num_valuators > val->numAxes))) {
+ ErrorF("Bad valuators reported for device \"%s\"\n", device->name);
+ return;
+ }
+
+ axisvals = val->axisVal;
+
+ va_start(var, num_valuators);
+
+ loop_start = first_valuator;
+ for(loop=0; loop<num_valuators; loop++) {
+
+ valuator[loop%6] = va_arg(var,int);
+
+ if (loop % 6 == 5 || loop == num_valuators - 1) {
+ num = loop % 6 + 1;
+ /*
+ * Adjust first two relative valuators
+ */
+ if (!is_absolute && num_valuators >= 2 && loop_start == 0) {
+
+ dx = valuator[0];
+ dy = valuator[1];
+
+ /*
+ * Accelerate
+ */
+ if (device->ptrfeed && device->ptrfeed->ctrl.num) {
+ /* modeled from xf86Events.c */
+ if (device->ptrfeed->ctrl.threshold) {
+ if ((abs(dx) + abs(dy)) >= device->ptrfeed->ctrl.threshold) {
+ local->dxremaind = ((float)dx * (float)(device->ptrfeed->ctrl.num)) /
+ (float)(device->ptrfeed->ctrl.den) + local->dxremaind;
+ valuator[0] = (int)local->dxremaind;
+ local->dxremaind = local->dxremaind - (float)valuator[0];
+
+ local->dyremaind = ((float)dy * (float)(device->ptrfeed->ctrl.num)) /
+ (float)(device->ptrfeed->ctrl.den) + local->dyremaind;
+ valuator[1] = (int)local->dyremaind;
+ local->dyremaind = local->dyremaind - (float)valuator[1];
+ }
+ }
+ else if (dx || dy) {
+ mult = pow((float)(dx*dx+dy*dy),
+ ((float)(device->ptrfeed->ctrl.num) /
+ (float)(device->ptrfeed->ctrl.den) - 1.0) /
+ 2.0) / 2.0;
+ if (dx) {
+ local->dxremaind = mult * (float)dx + local->dxremaind;
+ valuator[0] = (int)local->dxremaind;
+ local->dxremaind = local->dxremaind - (float)valuator[0];
+ }
+ if (dy) {
+ local->dyremaind = mult * (float)dy + local->dyremaind;
+ valuator[1] = (int)local->dyremaind;
+ local->dyremaind = local->dyremaind - (float)valuator[1];
+ }
+ }
+ DBG(6, ErrorF("xf86PostMotionEvent acceleration v0=%d v1=%d\n",
+ valuator[0], valuator[1]));
+ }
+
+ /*
+ * Map current position back to device space in case
+ * the cursor was warped
+ */
+ if (is_core || is_shared)
+ {
+ miPointerPosition (&x, &y);
+ if (local->reverse_conversion_proc)
+ (*local->reverse_conversion_proc)(local, x, y, axisvals);
+ else
+ {
+ axisvals[0] = x;
+ axisvals[1] = y;
+ }
+ }
+ }
+
+ /*
+ * Update axes
+ */
+ for (i = 0; i < num; i++)
+ {
+ oldaxis[i] = axisvals[loop_start + i];
+ if (is_absolute)
+ axisvals[loop_start + i] = valuator[i];
+ else
+ axisvals[loop_start + i] += valuator[i];
+ }
+
+ /*
+ * Deliver extension event
+ */
+ if (!is_core) {
+ xev->type = DeviceMotionNotify;
+ xev->detail = 0;
+ xev->deviceid = device->id | MORE_EVENTS;
+
+ xv->type = DeviceValuator;
+ xv->deviceid = device->id;
+
+ xv->device_state = 0;
+ xv->num_valuators = num;
+ xv->first_valuator = loop_start;
+ memcpy (&xv->valuator0, &axisvals[loop_start],
+ sizeof(INT32)*xv->num_valuators);
+
+ if (HAS_MOTION_HISTORY(local)) {
+ *(Time*)buff = current;
+ memcpy(buff+sizeof(Time)+sizeof(INT32)*xv->first_valuator,
+ &axisvals[loop_start],
+ sizeof(INT32)*xv->num_valuators);
+ }
+ ENQUEUE(xE);
+ }
+
+ /*
+ * Deliver core event
+ */
+ if (is_core ||
+ (is_shared && num_valuators >= 2 && loop_start == 0)) {
+#ifdef XFreeXDGA
+ /*
+ * Let DGA peek at the event and steal it
+ */
+ xev->type = MotionNotify;
+ xev->detail = 0;
+ if (is_absolute)
+ {
+ dx = axisvals[0] - oldaxis[0];
+ dy = axisvals[1] - oldaxis[1];
+ }
+ if (DGAStealMouseEvent(xf86EventQueue.pEnqueueScreen->myNum,
+ xE, dx, dy))
+ continue;
+#endif
+ if (!(*local->conversion_proc)(local, loop_start, num,
+ axisvals[0], axisvals[1],
+ axisvals[2], axisvals[3],
+ axisvals[4], axisvals[5],
+ &x, &y))
+ continue;
+
+ if (drag)
+ miPointerAbsoluteCursor (x, y, current);
+ /*
+ * Retrieve the position
+ */
+ miPointerPosition (&x, &y);
+ if (local->reverse_conversion_proc)
+ (*local->reverse_conversion_proc)(local, x, y, axisvals);
+ else
+ {
+ axisvals[0] = x;
+ axisvals[1] = y;
+ }
+ }
+ loop_start += 6;
+ }
+ }
+ va_end(var);
+ if (HAS_MOTION_HISTORY(local)) {
+ local->last = (local->last + 1) % device->valuator->numMotionEvents;
+ if (local->last == local->first)
+ local->first = (local->first + 1) % device->valuator->numMotionEvents;
+ }
+ DBG(5, ErrorF("xf86PostMotionEvent END 0x%x(%s) is_core=%s is_shared=%s\n",
+ device, device->name,
+ is_core ? "True" : "False",
+ is_shared ? "True" : "False"));
+}
+
+void
+xf86PostProximityEvent(DeviceIntPtr device,
+ int is_in,
+ int first_valuator,
+ int num_valuators,
+ ...)
+{
+ va_list var;
+ int loop;
+ xEvent xE[2];
+ deviceKeyButtonPointer *xev = (deviceKeyButtonPointer*) xE;
+ deviceValuator *xv = (deviceValuator*) xev+1;
+ ValuatorClassPtr val = device->valuator;
+ Bool is_core = xf86IsCorePointer(device);
+ Bool is_absolute = val && ((val->mode & 1) == Relative);
+
+ DBG(5, ErrorF("xf86PostProximityEvent BEGIN 0x%x(%s) prox=%s is_core=%s is_absolute=%s\n",
+ device, device->name, is_in ? "true" : "false",
+ is_core ? "True" : "False",
+ is_absolute ? "True" : "False"));
+
+ if (is_core) {
+ return;
+ }
+
+ if (num_valuators && (!val || (first_valuator + num_valuators > val->numAxes))) {
+ ErrorF("Bad valuators reported for device \"%s\"\n", device->name);
+ return;
+ }
+
+ xev->type = is_in ? ProximityIn : ProximityOut;
+ xev->detail = 0;
+ xev->deviceid = device->id | MORE_EVENTS;
+
+ xv->type = DeviceValuator;
+ xv->deviceid = device->id;
+ xv->device_state = 0;
+
+ if ((device->valuator->mode & 1) == Relative) {
+ num_valuators = 0;
+ }
+
+ if (num_valuators != 0) {
+ int *axisvals = val->axisVal;
+
+ va_start(var, num_valuators);
+
+ for(loop=0; loop<num_valuators; loop++) {
+ switch (loop % 6) {
+ case 0:
+ xv->valuator0 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 1:
+ xv->valuator1 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 2:
+ xv->valuator2 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 3:
+ xv->valuator3 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 4:
+ xv->valuator4 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 5:
+ xv->valuator5 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ }
+ if ((loop % 6 == 5) || (loop == num_valuators - 1)) {
+ xf86Info.lastEventTime = xev->time = GetTimeInMillis();
+
+ xv->num_valuators = (loop % 6) + 1;
+ xv->first_valuator = first_valuator + (loop / 6) * 6;
+ ENQUEUE(xE);
+ }
+ }
+ va_end(var);
+ }
+ else {
+ /* no valuator */
+ xf86Info.lastEventTime = xev->time = GetTimeInMillis();
+
+ xv->num_valuators = 0;
+ xv->first_valuator = 0;
+ ENQUEUE(xE);
+ }
+ DBG(5, ErrorF("xf86PostProximityEvent END 0x%x(%s) prox=%s is_core=%s is_absolute=%s\n",
+ device, device->name, is_in ? "true" : "false",
+ is_core ? "True" : "False",
+ is_absolute ? "True" : "False"));
+
+}
+
+void
+xf86PostButtonEvent(DeviceIntPtr device,
+ int is_absolute,
+ int button,
+ int is_down,
+ int first_valuator,
+ int num_valuators,
+ ...)
+{
+ va_list var;
+ int loop;
+ xEvent xE[2];
+ deviceKeyButtonPointer *xev = (deviceKeyButtonPointer*) xE;
+ deviceValuator *xv = (deviceValuator*) xev+1;
+ ValuatorClassPtr val = device->valuator;
+ Bool is_core = xf86IsCorePointer(device);
+ Bool is_shared = xf86ShareCorePointer(device);
+
+ DBG(5, ErrorF("xf86PostButtonEvent BEGIN 0x%x(%s) button=%d down=%s is_core=%s is_shared=%s is_absolute=%s\n",
+ device, device->name, button,
+ is_down ? "True" : "False",
+ is_core ? "True" : "False",
+ is_shared ? "True" : "False",
+ is_absolute ? "True" : "False"));
+
+ /* Check the core pointer button state not to send an inconsistent
+ * event. This can happen with the AlwaysCore feature.
+ */
+ if ((is_core || is_shared) &&
+ !xf86CheckButton(device->button->map[button], is_down))
+ {
+ return;
+ }
+
+ if (num_valuators && (!val || (first_valuator + num_valuators > val->numAxes))) {
+ ErrorF("Bad valuators reported for device \"%s\"\n", device->name);
+ return;
+ }
+
+ if (!is_core) {
+ xev->type = is_down ? DeviceButtonPress : DeviceButtonRelease;
+ xev->detail = button;
+ xev->deviceid = device->id | MORE_EVENTS;
+
+ xv->type = DeviceValuator;
+ xv->deviceid = device->id;
+ xv->device_state = 0;
+
+ if (num_valuators != 0) {
+ int *axisvals = val->axisVal;
+
+ va_start(var, num_valuators);
+
+ for(loop=0; loop<num_valuators; loop++) {
+ switch (loop % 6) {
+ case 0:
+ xv->valuator0 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 1:
+ xv->valuator1 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 2:
+ xv->valuator2 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 3:
+ xv->valuator3 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 4:
+ xv->valuator4 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ case 5:
+ xv->valuator5 = is_absolute ? va_arg(var, int) : axisvals[loop];
+ break;
+ }
+ if ((loop % 6 == 5) || (loop == num_valuators - 1)) {
+ xf86Info.lastEventTime = xev->time = GetTimeInMillis();
+ xv->num_valuators = (loop % 6) + 1;
+ xv->first_valuator = first_valuator + (loop / 6) * 6;
+ ENQUEUE(xE);
+
+ }
+ }
+ va_end(var);
+ }
+ else {
+ /* no valuator */
+ xf86Info.lastEventTime = xev->time = GetTimeInMillis();
+ xv->num_valuators = 0;
+ xv->first_valuator = 0;
+ ENQUEUE(xE);
+ }
+ }
+
+ /* removed rootX/rootY as DIX sets these fields */
+ if (is_core || is_shared) {
+ xE->u.u.type = is_down ? ButtonPress : ButtonRelease;
+ xE->u.u.detail = device->button->map[button];
+ xf86Info.lastEventTime = xE->u.keyButtonPointer.time = GetTimeInMillis();
+
+#ifdef XFreeXDGA
+ if (!DGAStealMouseEvent(xf86EventQueue.pEnqueueScreen->myNum, xE, 0, 0))
+#endif
+ ENQUEUE(xE);
+ }
+ DBG(5, ErrorF("xf86PostButtonEvent END\n"));
+}
+
+void
+xf86PostKeyEvent(DeviceIntPtr device,
+ unsigned int key_code,
+ int is_down,
+ int is_absolute,
+ int first_valuator,
+ int num_valuators,
+ ...)
+{
+ va_list var;
+ int loop;
+ xEvent xE[2];
+ deviceKeyButtonPointer *xev = (deviceKeyButtonPointer*) xE;
+ deviceValuator *xv = (deviceValuator*) xev+1;
+
+ va_start(var, num_valuators);
+
+ for(loop=0; loop<num_valuators; loop++) {
+ switch (loop % 6) {
+ case 0:
+ xv->valuator0 = va_arg(var, int);
+ break;
+ case 1:
+ xv->valuator1 = va_arg(var, int);
+ break;
+ case 2:
+ xv->valuator2 = va_arg(var, int);
+ break;
+ case 3:
+ xv->valuator3 = va_arg(var, int);
+ break;
+ case 4:
+ xv->valuator4 = va_arg(var, int);
+ break;
+ case 5:
+ xv->valuator5 = va_arg(var, int);
+ break;
+ }
+ if (((loop % 6 == 5) || (loop == num_valuators - 1))) {
+ xev->type = is_down ? DeviceKeyPress : DeviceKeyRelease;
+ xev->detail = key_code;
+
+ xf86Info.lastEventTime = xev->time = GetTimeInMillis();
+ xev->deviceid = device->id | MORE_EVENTS;
+
+ xv->type = DeviceValuator;
+ xv->deviceid = device->id;
+ xv->device_state = 0;
+ /* if the device is in the relative mode we don't have to send valuators */
+ xv->num_valuators = is_absolute ? (loop % 6) + 1 : 0;
+ xv->first_valuator = first_valuator + (loop / 6) * 6;
+
+ ENQUEUE(xE);
+ /* if the device is in the relative mode only one event is needed */
+ if (!is_absolute) break;
+ }
+ }
+ va_end(var);
+}
+
+void
+xf86PostKeyboardEvent(DeviceIntPtr device,
+ unsigned int key_code,
+ int is_down)
+{
+ xEvent xE[2];
+ deviceKeyButtonPointer *xev = (deviceKeyButtonPointer*) xE;
+
+ if (xf86IsCoreKeyboard(device)) {
+ xev->type = is_down ? KeyPress : KeyRelease;
+ } else {
+ xev->type = is_down ? DeviceKeyPress : DeviceKeyRelease;
+ }
+ xev->detail = key_code;
+ xf86Info.lastEventTime = xev->time = GetTimeInMillis();
+
+#ifdef XFreeXDGA
+ /* if(!DGAStealKeyEvent(xf86EventQueue.pEnqueueScreen->myNum, xE)) */
+#endif
+ ENQUEUE(xE);
+}
+
+/*
+ * Motion history management.
+ */
+
+void
+xf86MotionHistoryAllocate(LocalDevicePtr local)
+{
+ ValuatorClassPtr valuator = local->dev->valuator;
+
+ if (!HAS_MOTION_HISTORY(local))
+ return;
+ if (local->motion_history) xfree(local->motion_history);
+ local->motion_history = xalloc((sizeof(INT32) * valuator->numAxes + sizeof(Time))
+ * valuator->numMotionEvents);
+ local->first = 0;
+ local->last = 0;
+}
+
+int
+xf86GetMotionEvents(DeviceIntPtr dev,
+ xTimecoord *buff,
+ unsigned long start,
+ unsigned long stop,
+ ScreenPtr pScreen)
+{
+ LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate;
+ ValuatorClassPtr valuator = dev->valuator;
+ int num = 0;
+ int loop = local->first;
+ int size;
+ Time current;
+
+ if (!HAS_MOTION_HISTORY(local))
+ return 0;
+
+ size = (sizeof(INT32) * valuator->numAxes + sizeof(Time));
+
+ while (loop != local->last) {
+ current = *(Time*)(((char *)local->motion_history)+loop*size);
+ if (current > stop)
+ return num;
+ if (current >= start) {
+ memcpy(((char *)buff)+size*num,
+ ((char *)local->motion_history)+loop*size, size);
+ num++;
+ }
+ loop = (loop + 1) % valuator->numMotionEvents;
+ }
+ return num;
+}
+
+LocalDevicePtr
+xf86FirstLocalDevice()
+{
+ return xf86InputDevs;
+}
+
+/*
+ * Cx - raw data from touch screen
+ * Sxhigh - scaled highest dimension
+ * (remember, this is of rows - 1 because of 0 origin)
+ * Sxlow - scaled lowest dimension
+ * Rxhigh - highest raw value from touch screen calibration
+ * Rxlow - lowest raw value from touch screen calibration
+ *
+ * This function is the same for X or Y coordinates.
+ * You may have to reverse the high and low values to compensate for
+ * different orgins on the touch screen vs X.
+ */
+
+int
+xf86ScaleAxis(int Cx,
+ int Sxhigh,
+ int Sxlow,
+ int Rxhigh,
+ int Rxlow )
+{
+ int X;
+ int dSx = Sxhigh - Sxlow;
+ int dRx = Rxhigh - Rxlow;
+
+ dSx = Sxhigh - Sxlow;
+ if (dRx) {
+ X = ((dSx * (Cx - Rxlow)) / dRx) + Sxlow;
+ }
+ else {
+ X = 0;
+ ErrorF ("Divide by Zero in xf86ScaleAxis");
+ }
+
+ if (X > Sxlow)
+ X = Sxlow;
+ if (X < Sxhigh)
+ X = Sxhigh;
+
+ return (X);
+}
+
+/*
+ * This function checks the given screen against the current screen and
+ * makes changes if appropriate. It should be called from an XInput driver's
+ * ReadInput function before any events are posted, if the device is screen
+ * specific like a touch screen.
+ */
+void
+xf86XInputSetScreen(LocalDevicePtr local,
+ int screen_number,
+ int x,
+ int y)
+{
+ if ((xf86IsCorePointer(local->dev) || xf86ShareCorePointer(local->dev)) &&
+ (miPointerCurrentScreen() != screenInfo.screens[screen_number])) {
+ miPointerSetNewScreen (screen_number, x, y);
+ }
+}
+
+
+void
+xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval, int maxval,
+ int resolution, int min_res, int max_res)
+{
+#ifdef XINPUT
+ if (maxval == -1) {
+ if (axnum == 0)
+ maxval = screenInfo.screens[0]->width - 1;
+ else if (axnum == 1)
+ maxval = screenInfo.screens[0]->height - 1;
+ /* else? */
+ }
+ InitValuatorAxisStruct(dev, axnum, minval, maxval, resolution, min_res,
+ max_res);
+#endif
+}
+
+/*
+ * Set the valuator values to be in synch with dix/event.c
+ * DefineInitialRootWindow().
+ */
+void
+xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum)
+{
+#ifdef XINPUT
+ if (axnum == 0)
+ dev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
+ else if (axnum == 1)
+ dev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
+#endif
+}
+
+/* end of xf86Xinput.c */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86Xinput.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Xinput.h
new file mode 100644
index 000000000..0c20f78fe
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86Xinput.h
@@ -0,0 +1,220 @@
+/* $XConsortium: xf86Xinput.h /main/11 1996/10/27 11:05:29 kaleb $ */
+/*
+ * Copyright 1995-1999 by Frederic Lepied, France. <Lepied@XFree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Frederic Lepied not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Frederic Lepied makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/*
+ * Copyright (c) 2000-2002 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h,v 3.36 2003/08/24 17:36:55 dawes Exp $ */
+
+#ifndef _xf86Xinput_h
+#define _xf86Xinput_h
+
+#ifndef NEED_EVENTS
+#define NEED_EVENTS
+#endif
+#include "xf86str.h"
+#include "inputstr.h"
+#ifdef XINPUT
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h"
+#endif
+
+/* Input device flags */
+#define XI86_OPEN_ON_INIT 0x01 /* open the device at startup time */
+#define XI86_CONFIGURED 0x02 /* the device has been configured */
+#define XI86_ALWAYS_CORE 0x04 /* device always controls the pointer */
+/* the device sends Xinput and core pointer events */
+#define XI86_SEND_CORE_EVENTS XI86_ALWAYS_CORE
+/* if the device is the core pointer or is sending core events, and
+ * SEND_DRAG_EVENTS is false, and a buttons is done, then no motion events
+ * (mouse drag action) are sent. This is mainly to allow a touch screen to be
+ * used with netscape and other browsers which do strange things if the mouse
+ * moves between button down and button up. With a touch screen, this motion
+ * is common due to the user's finger moving slightly.
+ */
+#define XI86_SEND_DRAG_EVENTS 0x08
+#define XI86_CORE_POINTER 0x10 /* device is the core pointer */
+#define XI86_CORE_KEYBOARD 0x20 /* device is the core keyboard */
+#define XI86_POINTER_CAPABLE 0x40 /* capable of being a core pointer */
+#define XI86_KEYBOARD_CAPABLE 0x80 /* capable of being a core keyboard */
+
+#define XI_PRIVATE(dev) \
+ (((LocalDevicePtr)((dev)->public.devicePrivate))->private)
+
+#ifdef DBG
+#undef DBG
+#endif
+#define DBG(lvl, f) {if ((lvl) <= xf86GetVerbosity()) f;}
+
+#ifdef HAS_MOTION_HISTORY
+#undef HAS_MOTION_HISTORY
+#endif
+#define HAS_MOTION_HISTORY(local) ((local)->dev->valuator && (local)->dev->valuator->numMotionEvents)
+
+#ifdef XINPUT
+/* This holds the input driver entry and module information. */
+typedef struct _InputDriverRec {
+ int driverVersion;
+ char * driverName;
+ void (*Identify)(int flags);
+ struct _LocalDeviceRec *(*PreInit)(struct _InputDriverRec *drv,
+ IDevPtr dev, int flags);
+ void (*UnInit)(struct _InputDriverRec *drv,
+ struct _LocalDeviceRec *pInfo,
+ int flags);
+ pointer module;
+ int refCount;
+} InputDriverRec, *InputDriverPtr;
+#endif
+
+/* This is to input devices what the ScrnInfoRec is to screens. */
+
+typedef struct _LocalDeviceRec {
+ struct _LocalDeviceRec *next;
+ char * name;
+ int flags;
+
+ Bool (*device_control)(DeviceIntPtr device, int what);
+ void (*read_input)(struct _LocalDeviceRec *local);
+ int (*control_proc)(struct _LocalDeviceRec *local,
+ xDeviceCtl *control);
+ void (*close_proc)(struct _LocalDeviceRec *local);
+ int (*switch_mode)(ClientPtr client, DeviceIntPtr dev,
+ int mode);
+ Bool (*conversion_proc)(struct _LocalDeviceRec *local,
+ int first, int num, int v0,
+ int v1, int v2, int v3, int v4,
+ int v5, int *x, int *y);
+ Bool (*reverse_conversion_proc)(
+ struct _LocalDeviceRec *local,
+ int x, int y, int *valuators);
+
+ int fd;
+ Atom atom;
+ DeviceIntPtr dev;
+ pointer private;
+ int private_flags;
+ pointer motion_history;
+ ValuatorMotionProcPtr motion_history_proc;
+ unsigned int history_size; /* only for configuration purpose */
+ unsigned int first;
+ unsigned int last;
+ int old_x;
+ int old_y;
+ float dxremaind;
+ float dyremaind;
+ char * type_name;
+ IntegerFeedbackPtr always_core_feedback;
+ IDevPtr conf_idev;
+ InputDriverPtr drv;
+ pointer module;
+ pointer options;
+} LocalDeviceRec, *LocalDevicePtr, InputInfoRec, *InputInfoPtr;
+
+typedef struct _DeviceAssocRec
+{
+ char * config_section_name;
+ LocalDevicePtr (*device_allocate)(void);
+} DeviceAssocRec, *DeviceAssocPtr;
+
+/* xf86Globals.c */
+extern InputInfoPtr xf86InputDevs;
+
+/* xf86Xinput.c */
+int xf86IsCorePointer(DeviceIntPtr dev);
+int xf86IsCoreKeyboard(DeviceIntPtr dev);
+void xf86XInputSetSendCoreEvents(LocalDevicePtr local, Bool always);
+#define xf86AlwaysCore(a,b) xf86XInputSetSendCoreEvents(a,b)
+
+void InitExtInput(void);
+Bool xf86eqInit(DevicePtr pKbd, DevicePtr pPtr);
+void xf86eqEnqueue(struct _xEvent *event);
+void xf86eqProcessInputEvents (void);
+void xf86eqSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
+void xf86PostMotionEvent(DeviceIntPtr device, int is_absolute,
+ int first_valuator, int num_valuators, ...);
+void xf86PostProximityEvent(DeviceIntPtr device, int is_in,
+ int first_valuator, int num_valuators, ...);
+void xf86PostButtonEvent(DeviceIntPtr device, int is_absolute, int button,
+ int is_down, int first_valuator, int num_valuators,
+ ...);
+void xf86PostKeyEvent(DeviceIntPtr device, unsigned int key_code, int is_down,
+ int is_absolute, int first_valuator, int num_valuators,
+ ...);
+void xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int key_code,
+ int is_down);
+void xf86MotionHistoryAllocate(LocalDevicePtr local);
+int xf86GetMotionEvents(DeviceIntPtr dev, xTimecoord *buff,
+ unsigned long start, unsigned long stop,
+ ScreenPtr pScreen);
+void xf86XinputFinalizeInit(DeviceIntPtr dev);
+Bool xf86CheckButton(int button, int down);
+void xf86SwitchCoreDevice(LocalDevicePtr device, DeviceIntPtr core);
+LocalDevicePtr xf86FirstLocalDevice(void);
+int xf86ScaleAxis(int Cx, int Sxhigh, int Sxlow, int Rxhigh, int Rxlow);
+void xf86XInputSetScreen(LocalDevicePtr local, int screen_number, int x, int y);
+void xf86ProcessCommonOptions(InputInfoPtr pInfo, pointer options);
+void xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval,
+ int maxval, int resolution, int min_res,
+ int max_res);
+void xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum);
+void xf86AddEnabledDevice(InputInfoPtr pInfo);
+void xf86RemoveEnabledDevice(InputInfoPtr pInfo);
+
+/* xf86Helper.c */
+void xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags);
+void xf86DeleteInputDriver(int drvIndex);
+InputInfoPtr xf86AllocateInput(InputDriverPtr drv, int flags);
+void xf86DeleteInput(InputInfoPtr pInp, int flags);
+
+/* xf86Option.c */
+void xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts,
+ pointer extraOpts);
+
+#endif /* _xf86Xinput_h */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86cmap.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86cmap.c
new file mode 100644
index 000000000..b77e9fb47
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86cmap.c
@@ -0,0 +1,1123 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86cmap.c,v 1.9 2005/09/05 07:43:51 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86cmap.c,v 1.25 2003/10/17 20:02:12 alanh Exp $ */
+/*
+ * Copyright (c) 1998-2001 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#if defined(_XOPEN_SOURCE) || defined(__QNXNTO__) \
+ || (defined(sun) && defined(__SVR4))
+#include <math.h>
+#else
+#define _XOPEN_SOURCE /* to get prototype for pow on some systems */
+#include <math.h>
+#undef _XOPEN_SOURCE
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include <X11/Xproto.h>
+#include "colormapst.h"
+#include "scrnintstr.h"
+
+#include "resource.h"
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86str.h"
+#include "micmap.h"
+
+#ifdef XFreeXDGA
+#define _XF86DGA_SERVER_
+#include <X11/extensions/xf86dgastr.h>
+#include "dgaproc.h"
+#endif
+
+#include "xf86cmap.h"
+
+#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \
+ ((CMapScreenPtr) (pScreen)->devPrivates[CMapScreenIndex].ptr)->field)
+#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
+ ((pScreen)->field = wrapper)
+
+#define LOAD_PALETTE(pmap, index) \
+ ((pmap == miInstalledMaps[index]) && \
+ ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) || \
+ xf86Screens[index]->vtSema || pScreenPriv->isDGAmode))
+
+
+typedef struct _CMapLink {
+ ColormapPtr cmap;
+ struct _CMapLink *next;
+} CMapLink, *CMapLinkPtr;
+
+typedef struct {
+ ScrnInfoPtr pScrn;
+ CloseScreenProcPtr CloseScreen;
+ CreateColormapProcPtr CreateColormap;
+ DestroyColormapProcPtr DestroyColormap;
+ InstallColormapProcPtr InstallColormap;
+ StoreColorsProcPtr StoreColors;
+ Bool (*EnterVT)(int, int);
+ Bool (*SwitchMode)(int, DisplayModePtr, int);
+ int (*SetDGAMode)(int, int, DGADevicePtr);
+ int maxColors;
+ int sigRGBbits;
+ int gammaElements;
+ LOCO *gamma;
+ int *PreAllocIndices;
+ CMapLinkPtr maps;
+ unsigned int flags;
+ Bool isDGAmode;
+} CMapScreenRec, *CMapScreenPtr;
+
+typedef struct {
+ int numColors;
+ LOCO *colors;
+ Bool recalculate;
+ int overscan;
+} CMapColormapRec, *CMapColormapPtr;
+
+static unsigned long CMapGeneration = 0;
+static int CMapScreenIndex = -1;
+static int CMapColormapIndex = -1;
+
+static void CMapInstallColormap(ColormapPtr);
+static void CMapStoreColors(ColormapPtr, int, xColorItem *);
+static Bool CMapCloseScreen (int, ScreenPtr);
+static Bool CMapCreateColormap (ColormapPtr);
+static void CMapDestroyColormap (ColormapPtr);
+
+static Bool CMapEnterVT(int, int);
+static Bool CMapSwitchMode(int, DisplayModePtr, int);
+static int CMapSetDGAMode(int, int, DGADevicePtr);
+static int CMapChangeGamma(int, Gamma);
+
+static void ComputeGamma(CMapScreenPtr);
+static Bool CMapAllocateColormapPrivate(ColormapPtr);
+static Bool CMapInitDefMap(ColormapPtr,int);
+static void CMapRefreshColors(ColormapPtr, int, int*);
+static void CMapSetOverscan(ColormapPtr, int, int *);
+static void CMapReinstallMap(ColormapPtr);
+static void CMapUnwrapScreen(ScreenPtr pScreen);
+
+
+
+Bool xf86HandleColormaps(
+ ScreenPtr pScreen,
+ int maxColors,
+ int sigRGBbits,
+ xf86LoadPaletteProc *loadPalette,
+ xf86SetOverscanProc *setOverscan,
+ unsigned int flags
+){
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ ColormapPtr pDefMap = NULL;
+ CMapScreenPtr pScreenPriv;
+ LOCO *gamma;
+ int *indices;
+ int elements;
+
+ if(!maxColors || !sigRGBbits || !loadPalette)
+ return FALSE;
+
+ if(CMapGeneration != serverGeneration) {
+ if(((CMapScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
+ ((CMapColormapIndex = AllocateColormapPrivateIndex(
+ CMapInitDefMap)) < 0))
+ return FALSE;
+ CMapGeneration = serverGeneration;
+ }
+
+ elements = 1 << sigRGBbits;
+
+ if(!(gamma = xalloc(elements * sizeof(LOCO))))
+ return FALSE;
+
+ if(!(indices = xalloc(maxColors * sizeof(int)))) {
+ xfree(gamma);
+ return FALSE;
+ }
+
+ if(!(pScreenPriv = xalloc(sizeof(CMapScreenRec)))) {
+ xfree(gamma);
+ xfree(indices);
+ return FALSE;
+ }
+
+ pScreen->devPrivates[CMapScreenIndex].ptr = (pointer)pScreenPriv;
+
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreenPriv->CreateColormap = pScreen->CreateColormap;
+ pScreenPriv->DestroyColormap = pScreen->DestroyColormap;
+ pScreenPriv->InstallColormap = pScreen->InstallColormap;
+ pScreenPriv->StoreColors = pScreen->StoreColors;
+ pScreen->CloseScreen = CMapCloseScreen;
+ pScreen->CreateColormap = CMapCreateColormap;
+ pScreen->DestroyColormap = CMapDestroyColormap;
+ pScreen->InstallColormap = CMapInstallColormap;
+ pScreen->StoreColors = CMapStoreColors;
+
+ pScreenPriv->pScrn = pScrn;
+ pScrn->LoadPalette = loadPalette;
+ pScrn->SetOverscan = setOverscan;
+ pScreenPriv->maxColors = maxColors;
+ pScreenPriv->sigRGBbits = sigRGBbits;
+ pScreenPriv->gammaElements = elements;
+ pScreenPriv->gamma = gamma;
+ pScreenPriv->PreAllocIndices = indices;
+ pScreenPriv->maps = NULL;
+ pScreenPriv->flags = flags;
+ pScreenPriv->isDGAmode = FALSE;
+
+ pScreenPriv->EnterVT = pScrn->EnterVT;
+ pScreenPriv->SwitchMode = pScrn->SwitchMode;
+ pScreenPriv->SetDGAMode = pScrn->SetDGAMode;
+
+ if (!(flags & CMAP_LOAD_EVEN_IF_OFFSCREEN)) {
+ pScrn->EnterVT = CMapEnterVT;
+ if ((flags & CMAP_RELOAD_ON_MODE_SWITCH) && pScrn->SwitchMode)
+ pScrn->SwitchMode = CMapSwitchMode;
+ }
+#ifdef XFreeXDGA
+ pScrn->SetDGAMode = CMapSetDGAMode;
+#endif
+ pScrn->ChangeGamma = CMapChangeGamma;
+
+ ComputeGamma(pScreenPriv);
+
+ /* get the default map */
+
+ pDefMap = (ColormapPtr) LookupIDByType(pScreen->defColormap, RT_COLORMAP);
+
+ if(!CMapAllocateColormapPrivate(pDefMap)) {
+ CMapUnwrapScreen(pScreen);
+ return FALSE;
+ }
+
+ /* Force the initial map to be loaded */
+ miInstalledMaps[pScreen->myNum] = NULL;
+ CMapInstallColormap(pDefMap);
+ return TRUE;
+}
+
+static Bool
+CMapInitDefMap(ColormapPtr cmap, int index)
+{
+ return TRUE;
+}
+
+
+/**** Screen functions ****/
+
+
+static Bool
+CMapCloseScreen (int i, ScreenPtr pScreen)
+{
+ CMapUnwrapScreen(pScreen);
+
+ return (*pScreen->CloseScreen) (i, pScreen);
+}
+
+static Bool
+CMapColormapUseMax(VisualPtr pVisual, CMapScreenPtr pScreenPriv)
+{
+ if (pVisual->nplanes > 16)
+ return TRUE;
+ return ((1 << pVisual->nplanes) > pScreenPriv->maxColors);
+}
+
+static Bool
+CMapAllocateColormapPrivate(ColormapPtr pmap)
+{
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapColormapPtr pColPriv;
+ CMapLinkPtr pLink;
+ int numColors;
+ LOCO *colors;
+
+ if (CMapColormapUseMax(pmap->pVisual, pScreenPriv))
+ numColors = pmap->pVisual->ColormapEntries;
+ else
+ numColors = 1 << pmap->pVisual->nplanes;
+
+ if(!(colors = xalloc(numColors * sizeof(LOCO))))
+ return FALSE;
+
+ if(!(pColPriv = xalloc(sizeof(CMapColormapRec)))) {
+ xfree(colors);
+ return FALSE;
+ }
+
+ pmap->devPrivates[CMapColormapIndex].ptr = (pointer)pColPriv;
+
+ pColPriv->numColors = numColors;
+ pColPriv->colors = colors;
+ pColPriv->recalculate = TRUE;
+ pColPriv->overscan = -1;
+
+ /* add map to list */
+ pLink = xalloc(sizeof(CMapLink));
+ if(pLink) {
+ pLink->cmap = pmap;
+ pLink->next = pScreenPriv->maps;
+ pScreenPriv->maps = pLink;
+ }
+
+ return TRUE;
+}
+
+static Bool
+CMapCreateColormap (ColormapPtr pmap)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ Bool ret = FALSE;
+
+ pScreen->CreateColormap = pScreenPriv->CreateColormap;
+ if((*pScreen->CreateColormap)(pmap)) {
+ if(CMapAllocateColormapPrivate(pmap))
+ ret = TRUE;
+ }
+ pScreen->CreateColormap = CMapCreateColormap;
+
+ return ret;
+}
+
+static void
+CMapDestroyColormap (ColormapPtr cmap)
+{
+ ScreenPtr pScreen = cmap->pScreen;
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapColormapPtr pColPriv =
+ (CMapColormapPtr) cmap->devPrivates[CMapColormapIndex].ptr;
+ CMapLinkPtr prevLink = NULL, pLink = pScreenPriv->maps;
+
+ if(pColPriv) {
+ if(pColPriv->colors) xfree(pColPriv->colors);
+ xfree(pColPriv);
+ }
+
+ /* remove map from list */
+ while(pLink) {
+ if(pLink->cmap == cmap) {
+ if(prevLink)
+ prevLink->next = pLink->next;
+ else
+ pScreenPriv->maps = pLink->next;
+ xfree(pLink);
+ break;
+ }
+ prevLink = pLink;
+ pLink = pLink->next;
+ }
+
+ if(pScreenPriv->DestroyColormap) {
+ pScreen->DestroyColormap = pScreenPriv->DestroyColormap;
+ (*pScreen->DestroyColormap)(cmap);
+ pScreen->DestroyColormap = CMapDestroyColormap;
+ }
+}
+
+
+
+static void
+CMapStoreColors(
+ ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs
+){
+ ScreenPtr pScreen = pmap->pScreen;
+ VisualPtr pVisual = pmap->pVisual;
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ int *indices = pScreenPriv->PreAllocIndices;
+ int num = ndef;
+
+ /* At the moment this isn't necessary since there's nobody below us */
+ pScreen->StoreColors = pScreenPriv->StoreColors;
+ (*pScreen->StoreColors)(pmap, ndef, pdefs);
+ pScreen->StoreColors = CMapStoreColors;
+
+ /* should never get here for these */
+ if( (pVisual->class == TrueColor) ||
+ (pVisual->class == StaticColor) ||
+ (pVisual->class == StaticGray))
+ return;
+
+ if(pVisual->class == DirectColor) {
+ CMapColormapPtr pColPriv =
+ (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr;
+ int i;
+
+ if (CMapColormapUseMax(pVisual, pScreenPriv)) {
+ int index;
+
+ num = 0;
+ while(ndef--) {
+ if(pdefs[ndef].flags & DoRed) {
+ index = (pdefs[ndef].pixel & pVisual->redMask) >>
+ pVisual->offsetRed;
+ i = num;
+ while(i--)
+ if(indices[i] == index) break;
+ if(i == -1)
+ indices[num++] = index;
+ }
+ if(pdefs[ndef].flags & DoGreen) {
+ index = (pdefs[ndef].pixel & pVisual->greenMask) >>
+ pVisual->offsetGreen;
+ i = num;
+ while(i--)
+ if(indices[i] == index) break;
+ if(i == -1)
+ indices[num++] = index;
+ }
+ if(pdefs[ndef].flags & DoBlue) {
+ index = (pdefs[ndef].pixel & pVisual->blueMask) >>
+ pVisual->offsetBlue;
+ i = num;
+ while(i--)
+ if(indices[i] == index) break;
+ if(i == -1)
+ indices[num++] = index;
+ }
+ }
+
+ } else {
+ /* not really as overkill as it seems */
+ num = pColPriv->numColors;
+ for(i = 0; i < pColPriv->numColors; i++)
+ indices[i] = i;
+ }
+ } else {
+ while(ndef--)
+ indices[ndef] = pdefs[ndef].pixel;
+ }
+
+ CMapRefreshColors(pmap, num, indices);
+}
+
+
+static void
+CMapInstallColormap(ColormapPtr pmap)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+ int index = pScreen->myNum;
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+
+ if (pmap == miInstalledMaps[index])
+ return;
+
+ pScreen->InstallColormap = pScreenPriv->InstallColormap;
+ (*pScreen->InstallColormap)(pmap);
+ pScreen->InstallColormap = CMapInstallColormap;
+
+ /* Important. We let the lower layers, namely DGA,
+ overwrite the choice of Colormap to install */
+ if (miInstalledMaps[index])
+ pmap = miInstalledMaps[index];
+
+ if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
+ (pmap->pVisual->class == TrueColor) &&
+ CMapColormapUseMax(pmap->pVisual, pScreenPriv))
+ return;
+
+ if(LOAD_PALETTE(pmap, index))
+ CMapReinstallMap(pmap);
+}
+
+
+/**** ScrnInfoRec functions ****/
+
+static Bool
+CMapEnterVT(int index, int flags)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+
+ if((*pScreenPriv->EnterVT)(index, flags)) {
+ if(miInstalledMaps[index])
+ CMapReinstallMap(miInstalledMaps[index]);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+static Bool
+CMapSwitchMode(int index, DisplayModePtr mode, int flags)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+
+ if((*pScreenPriv->SwitchMode)(index, mode, flags)) {
+ if(miInstalledMaps[index])
+ CMapReinstallMap(miInstalledMaps[index]);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+#ifdef XFreeXDGA
+static int
+CMapSetDGAMode(int index, int num, DGADevicePtr dev)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ int ret;
+
+ ret = (*pScreenPriv->SetDGAMode)(index, num, dev);
+
+ pScreenPriv->isDGAmode = DGAActive(index);
+
+ if(!pScreenPriv->isDGAmode && miInstalledMaps[index]
+ && xf86Screens[pScreen->myNum]->vtSema)
+ CMapReinstallMap(miInstalledMaps[index]);
+
+ return ret;
+}
+#endif
+
+
+/**** Utilities ****/
+
+static void
+CMapReinstallMap(ColormapPtr pmap)
+{
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapColormapPtr cmapPriv =
+ (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr;
+ ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
+ int i = cmapPriv->numColors;
+ int *indices = pScreenPriv->PreAllocIndices;
+
+ while(i--)
+ indices[i] = i;
+
+ if(cmapPriv->recalculate)
+ CMapRefreshColors(pmap, cmapPriv->numColors, indices);
+ else {
+ (*pScrn->LoadPalette)(pScrn, cmapPriv->numColors,
+ indices, cmapPriv->colors, pmap->pVisual);
+ if (pScrn->SetOverscan) {
+#ifdef DEBUGOVERSCAN
+ ErrorF("SetOverscan() called from CMapReinstallMap\n");
+#endif
+ pScrn->SetOverscan(pScrn, cmapPriv->overscan);
+ }
+ }
+
+ cmapPriv->recalculate = FALSE;
+}
+
+
+static void
+CMapRefreshColors(ColormapPtr pmap, int defs, int* indices)
+{
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapColormapPtr pColPriv =
+ (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr;
+ VisualPtr pVisual = pmap->pVisual;
+ ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
+ int numColors, i;
+ LOCO *gamma, *colors;
+ EntryPtr entry;
+ int reds, greens, blues, maxValue, index, shift;
+
+ numColors = pColPriv->numColors;
+ shift = 16 - pScreenPriv->sigRGBbits;
+ maxValue = (1 << pScreenPriv->sigRGBbits) - 1;
+ gamma = pScreenPriv->gamma;
+ colors = pColPriv->colors;
+
+ reds = pVisual->redMask >> pVisual->offsetRed;
+ greens = pVisual->greenMask >> pVisual->offsetGreen;
+ blues = pVisual->blueMask >> pVisual->offsetBlue;
+
+ switch(pVisual->class) {
+ case StaticGray:
+ for(i = 0; i <= numColors - 1; i++) {
+ index = i * maxValue / numColors;
+ colors[i].red = gamma[index].red;
+ colors[i].green = gamma[index].green;
+ colors[i].blue = gamma[index].blue;
+ }
+ break;
+ case TrueColor:
+ if (CMapColormapUseMax(pVisual, pScreenPriv)) {
+ for(i = 0; i <= reds; i++)
+ colors[i].red = gamma[i * maxValue / reds].red;
+ for(i = 0; i <= greens; i++)
+ colors[i].green = gamma[i * maxValue / greens].green;
+ for(i = 0; i <= blues; i++)
+ colors[i].blue = gamma[i * maxValue / blues].blue;
+ break;
+ }
+ for(i = 0; i < numColors; i++) {
+ colors[i].red = gamma[((i >> pVisual->offsetRed) & reds) *
+ maxValue / reds].red;
+ colors[i].green = gamma[((i >> pVisual->offsetGreen) & greens) *
+ maxValue / greens].green;
+ colors[i].blue = gamma[((i >> pVisual->offsetBlue) & blues) *
+ maxValue / blues].blue;
+ }
+ break;
+ case StaticColor:
+ case PseudoColor:
+ case GrayScale:
+ for(i = 0; i < defs; i++) {
+ index = indices[i];
+ entry = (EntryPtr)&pmap->red[index];
+
+ if(entry->fShared) {
+ colors[index].red =
+ gamma[entry->co.shco.red->color >> shift].red;
+ colors[index].green =
+ gamma[entry->co.shco.green->color >> shift].green;
+ colors[index].blue =
+ gamma[entry->co.shco.blue->color >> shift].blue;
+ } else {
+ colors[index].red =
+ gamma[entry->co.local.red >> shift].red;
+ colors[index].green =
+ gamma[entry->co.local.green >> shift].green;
+ colors[index].blue =
+ gamma[entry->co.local.blue >> shift].blue;
+ }
+ }
+ break;
+ case DirectColor:
+ if (CMapColormapUseMax(pVisual, pScreenPriv)) {
+ for(i = 0; i < defs; i++) {
+ index = indices[i];
+ if(index <= reds)
+ colors[index].red =
+ gamma[pmap->red[index].co.local.red >> shift].red;
+ if(index <= greens)
+ colors[index].green =
+ gamma[pmap->green[index].co.local.green >> shift].green;
+ if(index <= blues)
+ colors[index].blue =
+ gamma[pmap->blue[index].co.local.blue >> shift].blue;
+
+ }
+ break;
+ }
+ for(i = 0; i < defs; i++) {
+ index = indices[i];
+
+ colors[index].red = gamma[pmap->red[
+ (index >> pVisual->offsetRed) & reds
+ ].co.local.red >> shift].red;
+ colors[index].green = gamma[pmap->green[
+ (index >> pVisual->offsetGreen) & greens
+ ].co.local.green >> shift].green;
+ colors[index].blue = gamma[pmap->blue[
+ (index >> pVisual->offsetBlue) & blues
+ ].co.local.blue >> shift].blue;
+ }
+ break;
+ }
+
+
+ if(LOAD_PALETTE(pmap, pmap->pScreen->myNum))
+ (*pScrn->LoadPalette)(pScreenPriv->pScrn, defs, indices,
+ colors, pmap->pVisual);
+
+ if (pScrn->SetOverscan)
+ CMapSetOverscan(pmap, defs, indices);
+
+}
+
+static Bool
+CMapCompareColors(LOCO *color1, LOCO *color2)
+{
+ /* return TRUE if the color1 is "closer" to black than color2 */
+#ifdef DEBUGOVERSCAN
+ ErrorF("#%02x%02x%02x vs #%02x%02x%02x (%d vs %d)\n",
+ color1->red, color1->green, color1->blue,
+ color2->red, color2->green, color2->blue,
+ color1->red + color1->green + color1->blue,
+ color2->red + color2->green + color2->blue);
+#endif
+ return (color1->red + color1->green + color1->blue <
+ color2->red + color2->green + color2->blue);
+}
+
+static void
+CMapSetOverscan(ColormapPtr pmap, int defs, int *indices)
+{
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapColormapPtr pColPriv =
+ (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr;
+ ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
+ VisualPtr pVisual = pmap->pVisual;
+ int i;
+ LOCO *colors;
+ int index;
+ Bool newOverscan = FALSE;
+ int overscan, tmpOverscan;
+
+ colors = pColPriv->colors;
+ overscan = pColPriv->overscan;
+
+ /*
+ * Search for a new overscan index in the following cases:
+ *
+ * - The index hasn't yet been initialised.  In this case search
+ * for an index that is black or a close match to black.
+ *
+ * - The colour of the old index is changed. In this case search
+ * all indices for a black or close match to black.
+ *
+ * - The colour of the old index wasn't black. In this case only
+ * search the indices that were changed for a better match to black.
+ */
+
+ switch (pVisual->class) {
+ case StaticGray:
+ case TrueColor:
+ /* Should only come here once. Initialise the overscan index to 0 */
+ overscan = 0;
+ newOverscan = TRUE;
+ break;
+ case StaticColor:
+ /*
+ * Only come here once, but search for the overscan in the same way
+ * as for the other cases.
+ */
+ case DirectColor:
+ case PseudoColor:
+ case GrayScale:
+ if (overscan < 0 || overscan > pScreenPriv->maxColors - 1) {
+ /* Uninitialised */
+ newOverscan = TRUE;
+ } else {
+ /* Check if the overscan was changed */
+ for (i = 0; i < defs; i++) {
+ index = indices[i];
+ if (index == overscan) {
+ newOverscan = TRUE;
+ break;
+ }
+ }
+ }
+ if (newOverscan) {
+ /* The overscan is either uninitialised or it has been changed */
+
+ if (overscan < 0 || overscan > pScreenPriv->maxColors - 1)
+ tmpOverscan = pScreenPriv->maxColors - 1;
+ else
+ tmpOverscan = overscan;
+
+ /* search all entries for a close match to black */
+ for (i = pScreenPriv->maxColors - 1; i >= 0; i--) {
+ if (colors[i].red == 0 && colors[i].green == 0 &&
+ colors[i].blue == 0) {
+ overscan = i;
+#ifdef DEBUGOVERSCAN
+ ErrorF("Black found at index 0x%02x\n", i);
+#endif
+ break;
+ } else {
+#ifdef DEBUGOVERSCAN
+ ErrorF("0x%02x: ", i);
+#endif
+ if (CMapCompareColors(&colors[i], &colors[tmpOverscan])) {
+ tmpOverscan = i;
+#ifdef DEBUGOVERSCAN
+ ErrorF("possible \"Black\" at index 0x%02x\n", i);
+#endif
+ }
+ }
+ }
+ if (i < 0)
+ overscan = tmpOverscan;
+ } else {
+ /* Check of the old overscan wasn't black */
+ if (colors[overscan].red != 0 || colors[overscan].green != 0 ||
+ colors[overscan].blue != 0) {
+ int oldOverscan = tmpOverscan = overscan;
+ /* See of there is now a better match */
+ for (i = 0; i < defs; i++) {
+ index = indices[i];
+ if (colors[index].red == 0 && colors[index].green == 0 &&
+ colors[index].blue == 0) {
+ overscan = index;
+#ifdef DEBUGOVERSCAN
+ ErrorF("Black found at index 0x%02x\n", index);
+#endif
+ break;
+ } else {
+#ifdef DEBUGOVERSCAN
+ ErrorF("0x%02x: ", index);
+#endif
+ if (CMapCompareColors(&colors[index],
+ &colors[tmpOverscan])) {
+ tmpOverscan = index;
+#ifdef DEBUGOVERSCAN
+ ErrorF("possible \"Black\" at index 0x%02x\n",
+ index);
+#endif
+ }
+ }
+ }
+ if (i == defs)
+ overscan = tmpOverscan;
+ if (overscan != oldOverscan)
+ newOverscan = TRUE;
+ }
+ }
+ break;
+ }
+ if (newOverscan) {
+ pColPriv->overscan = overscan;
+ if (LOAD_PALETTE(pmap, pmap->pScreen->myNum)) {
+#ifdef DEBUGOVERSCAN
+ ErrorF("SetOverscan() called from CmapSetOverscan\n");
+#endif
+ pScrn->SetOverscan(pScreenPriv->pScrn, overscan);
+ }
+ }
+}
+
+static void
+CMapUnwrapScreen(ScreenPtr pScreen)
+{
+ CMapScreenPtr pScreenPriv =
+ (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+ pScreen->CreateColormap = pScreenPriv->CreateColormap;
+ pScreen->DestroyColormap = pScreenPriv->DestroyColormap;
+ pScreen->InstallColormap = pScreenPriv->InstallColormap;
+ pScreen->StoreColors = pScreenPriv->StoreColors;
+
+ pScrn->EnterVT = pScreenPriv->EnterVT;
+ pScrn->SwitchMode = pScreenPriv->SwitchMode;
+ pScrn->SetDGAMode = pScreenPriv->SetDGAMode;
+
+ xfree(pScreenPriv->gamma);
+ xfree(pScreenPriv->PreAllocIndices);
+ xfree(pScreenPriv);
+}
+
+
+static void
+ComputeGamma(CMapScreenPtr priv)
+{
+ int elements = priv->gammaElements - 1;
+ double RedGamma, GreenGamma, BlueGamma;
+ int i;
+
+#ifndef DONT_CHECK_GAMMA
+ /* This check is to catch drivers that are not initialising pScrn->gamma */
+ if (priv->pScrn->gamma.red < GAMMA_MIN ||
+ priv->pScrn->gamma.red > GAMMA_MAX ||
+ priv->pScrn->gamma.green < GAMMA_MIN ||
+ priv->pScrn->gamma.green > GAMMA_MAX ||
+ priv->pScrn->gamma.blue < GAMMA_MIN ||
+ priv->pScrn->gamma.blue > GAMMA_MAX) {
+
+ xf86DrvMsgVerb(priv->pScrn->scrnIndex, X_WARNING, 0,
+ "The %s driver didn't call xf86SetGamma() to initialise\n"
+ "\tthe gamma values.\n", priv->pScrn->driverName);
+ xf86DrvMsgVerb(priv->pScrn->scrnIndex, X_WARNING, 0,
+ "PLEASE FIX THE `%s' DRIVER!\n", priv->pScrn->driverName);
+ priv->pScrn->gamma.red = 1.0;
+ priv->pScrn->gamma.green = 1.0;
+ priv->pScrn->gamma.blue = 1.0;
+ }
+#endif
+
+ RedGamma = 1.0 / (double)priv->pScrn->gamma.red;
+ GreenGamma = 1.0 / (double)priv->pScrn->gamma.green;
+ BlueGamma = 1.0 / (double)priv->pScrn->gamma.blue;
+
+ for(i = 0; i <= elements; i++) {
+ if(RedGamma == 1.0)
+ priv->gamma[i].red = i;
+ else
+ priv->gamma[i].red = (CARD16)(pow((double)i/(double)elements,
+ RedGamma) * (double)elements + 0.5);
+
+ if(GreenGamma == 1.0)
+ priv->gamma[i].green = i;
+ else
+ priv->gamma[i].green = (CARD16)(pow((double)i/(double)elements,
+ GreenGamma) * (double)elements + 0.5);
+
+ if(BlueGamma == 1.0)
+ priv->gamma[i].blue = i;
+ else
+ priv->gamma[i].blue = (CARD16)(pow((double)i/(double)elements,
+ BlueGamma) * (double)elements + 0.5);
+ }
+}
+
+
+int
+CMapChangeGamma(
+ int index,
+ Gamma gamma
+){
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ ScreenPtr pScreen = pScrn->pScreen;
+ CMapColormapPtr pColPriv;
+ CMapScreenPtr pScreenPriv;
+ CMapLinkPtr pLink;
+
+ /* Is this sufficient checking ? */
+ if(CMapScreenIndex == -1)
+ return BadImplementation;
+
+ pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ if(!pScreenPriv)
+ return BadImplementation;
+
+ if (gamma.red < GAMMA_MIN || gamma.red > GAMMA_MAX ||
+ gamma.green < GAMMA_MIN || gamma.green > GAMMA_MAX ||
+ gamma.blue < GAMMA_MIN || gamma.blue > GAMMA_MAX)
+ return BadValue;
+
+ pScrn->gamma.red = gamma.red;
+ pScrn->gamma.green = gamma.green;
+ pScrn->gamma.blue = gamma.blue;
+
+ ComputeGamma(pScreenPriv);
+
+ /* mark all colormaps on this screen */
+ pLink = pScreenPriv->maps;
+ while(pLink) {
+ pColPriv =
+ (CMapColormapPtr) pLink->cmap->devPrivates[CMapColormapIndex].ptr;
+ pColPriv->recalculate = TRUE;
+ pLink = pLink->next;
+ }
+
+ if(miInstalledMaps[pScreen->myNum] &&
+ ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) ||
+ pScrn->vtSema || pScreenPriv->isDGAmode)) {
+ ColormapPtr pMap = miInstalledMaps[pScreen->myNum];
+
+ if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
+ (pMap->pVisual->class == TrueColor) &&
+ CMapColormapUseMax(pMap->pVisual, pScreenPriv)) {
+
+ /* if the current map doesn't have a palette look
+ for another map to change the gamma on. */
+
+ pLink = pScreenPriv->maps;
+ while(pLink) {
+ if(pLink->cmap->pVisual->class == PseudoColor)
+ break;
+ pLink = pLink->next;
+ }
+
+ if(pLink) {
+ /* need to trick CMapRefreshColors() into thinking
+ this is the currently installed map */
+ miInstalledMaps[pScreen->myNum] = pLink->cmap;
+ CMapReinstallMap(pLink->cmap);
+ miInstalledMaps[pScreen->myNum] = pMap;
+ }
+ } else
+ CMapReinstallMap(pMap);
+ }
+
+ return Success;
+}
+
+
+static void
+ComputeGammaRamp (
+ CMapScreenPtr priv,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue
+){
+ int elements = priv->gammaElements;
+ LOCO *entry = priv->gamma;
+ int shift = 16 - priv->sigRGBbits;
+
+ while(elements--) {
+ entry->red = *(red++) >> shift;
+ entry->green = *(green++) >> shift;
+ entry->blue = *(blue++) >> shift;
+ entry++;
+ }
+}
+
+int
+xf86ChangeGammaRamp(
+ ScreenPtr pScreen,
+ int size,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue
+){
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ CMapColormapPtr pColPriv;
+ CMapScreenPtr pScreenPriv;
+ CMapLinkPtr pLink;
+
+ if(CMapScreenIndex == -1)
+ return BadImplementation;
+
+ pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ if(!pScreenPriv)
+ return BadImplementation;
+
+ if(pScreenPriv->gammaElements != size)
+ return BadValue;
+
+ ComputeGammaRamp(pScreenPriv, red, green, blue);
+
+ /* mark all colormaps on this screen */
+ pLink = pScreenPriv->maps;
+ while(pLink) {
+ pColPriv =
+ (CMapColormapPtr) pLink->cmap->devPrivates[CMapColormapIndex].ptr;
+ pColPriv->recalculate = TRUE;
+ pLink = pLink->next;
+ }
+
+ if(miInstalledMaps[pScreen->myNum] &&
+ ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) ||
+ pScrn->vtSema || pScreenPriv->isDGAmode)) {
+ ColormapPtr pMap = miInstalledMaps[pScreen->myNum];
+
+ if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) &&
+ (pMap->pVisual->class == TrueColor) &&
+ CMapColormapUseMax(pMap->pVisual, pScreenPriv)) {
+
+ /* if the current map doesn't have a palette look
+ for another map to change the gamma on. */
+
+ pLink = pScreenPriv->maps;
+ while(pLink) {
+ if(pLink->cmap->pVisual->class == PseudoColor)
+ break;
+ pLink = pLink->next;
+ }
+
+ if(pLink) {
+ /* need to trick CMapRefreshColors() into thinking
+ this is the currently installed map */
+ miInstalledMaps[pScreen->myNum] = pLink->cmap;
+ CMapReinstallMap(pLink->cmap);
+ miInstalledMaps[pScreen->myNum] = pMap;
+ }
+ } else
+ CMapReinstallMap(pMap);
+ }
+
+ return Success;
+}
+
+int
+xf86GetGammaRampSize(ScreenPtr pScreen)
+{
+ CMapScreenPtr pScreenPriv;
+
+ if(CMapScreenIndex == -1) return 0;
+
+ pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ if(!pScreenPriv) return 0;
+
+ return pScreenPriv->gammaElements;
+}
+
+int
+xf86GetGammaRamp(
+ ScreenPtr pScreen,
+ int size,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue
+){
+ CMapScreenPtr pScreenPriv;
+ LOCO *entry;
+ int shift, sigbits;
+
+ if(CMapScreenIndex == -1)
+ return BadImplementation;
+
+ pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ if(!pScreenPriv)
+ return BadImplementation;
+
+ if(size > pScreenPriv->gammaElements)
+ return BadValue;
+
+ entry = pScreenPriv->gamma;
+ sigbits = pScreenPriv->sigRGBbits;
+
+ while(size--) {
+ *red = entry->red << (16 - sigbits);
+ *green = entry->green << (16 - sigbits);
+ *blue = entry->blue << (16 - sigbits);
+ shift = sigbits;
+ while(shift < 16) {
+ *red |= *red >> shift;
+ *green |= *green >> shift;
+ *blue |= *blue >> shift;
+ shift += sigbits;
+ }
+ red++; green++; blue++;
+ entry++;
+ }
+
+ return Success;
+}
+
+int
+xf86ChangeGamma(
+ ScreenPtr pScreen,
+ Gamma gamma
+){
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ if(pScrn->ChangeGamma)
+ return (*pScrn->ChangeGamma)(pScreen->myNum, gamma);
+
+ return Success; /* Success? */
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86cmap.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86cmap.h
new file mode 100644
index 000000000..4291b971a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86cmap.h
@@ -0,0 +1,76 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86cmap.h,v 1.9 2003/10/17 20:02:12 alanh Exp $ */
+
+/*
+ * Copyright (c) 1998-2001 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifndef _XF86CMAP_H
+#define _XF86CMAP_H
+
+#include "xf86str.h"
+#include "colormapst.h"
+
+#define CMAP_PALETTED_TRUECOLOR 0x0000001
+#define CMAP_RELOAD_ON_MODE_SWITCH 0x0000002
+#define CMAP_LOAD_EVEN_IF_OFFSCREEN 0x0000004
+
+Bool xf86HandleColormaps(
+ ScreenPtr pScreen,
+ int maxCol,
+ int sigRGBbits,
+ xf86LoadPaletteProc *loadPalette,
+ xf86SetOverscanProc *setOverscan,
+ unsigned int flags
+);
+
+int
+xf86ChangeGamma(
+ ScreenPtr pScreen,
+ Gamma newGamma
+);
+
+int
+xf86ChangeGammaRamp(
+ ScreenPtr pScreen,
+ int size,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue
+);
+
+int xf86GetGammaRampSize(ScreenPtr pScreen);
+
+int
+xf86GetGammaRamp(
+ ScreenPtr pScreen,
+ int size,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue
+);
+
+#endif /* _XF86CMAP_H */
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86fbBus.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86fbBus.c
new file mode 100644
index 000000000..28a65302d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86fbBus.c
@@ -0,0 +1,97 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86fbBus.c,v 1.3 2003/08/24 17:36:55 dawes Exp $ */
+
+/*
+ * Copyright (c) 2000-2001 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains the interfaces to the bus-specific code
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Resources.h"
+
+#include "xf86Bus.h"
+
+#define XF86_OS_PRIVS
+#define NEED_OS_RAC_PROTOS
+#include "xf86_OSproc.h"
+
+#include "xf86RAC.h"
+
+Bool fbSlotClaimed = FALSE;
+
+int
+xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active)
+{
+ EntityPtr p;
+ int num;
+
+ num = xf86AllocateEntity();
+ p = xf86Entities[num];
+ p->driver = drvp;
+ p->chipset = 0;
+ p->busType = BUS_NONE;
+ p->active = active;
+ p->inUse = FALSE;
+ xf86AddDevToEntity(num, dev);
+ p->access = xnfcalloc(1,sizeof(EntityAccessRec));
+ p->access->fallback = &AccessNULL;
+ p->access->pAccess = &AccessNULL;
+ p->busAcc = NULL;
+
+ fbSlotClaimed = TRUE;
+ return num;
+}
+
+/*
+ * Get the list of FB "slots" claimed by a screen
+ */
+int
+xf86GetFbInfoForScreen(int scrnIndex)
+{
+ int num = 0;
+ int i;
+ EntityPtr p;
+
+ for (i = 0; i < xf86Screens[scrnIndex]->numEntities; i++) {
+ p = xf86Entities[xf86Screens[scrnIndex]->entityList[i]];
+ if (p->busType == BUS_NONE) {
+ num++;
+ }
+ }
+ return num;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86fbman.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86fbman.c
new file mode 100644
index 000000000..31c84c49f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86fbman.c
@@ -0,0 +1,1445 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86fbman.c,v 1.28 2003/11/03 05:11:03 tsi Exp $ */
+
+/*
+ * Copyright (c) 1998-2001 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "regionstr.h"
+#include "xf86fbman.h"
+
+/*
+#define DEBUG
+*/
+
+static int xf86FBMangerIndex = -1;
+static unsigned long xf86ManagerGeneration = 0;
+
+Bool xf86RegisterOffscreenManager(
+ ScreenPtr pScreen,
+ FBManagerFuncsPtr funcs
+){
+
+ if(xf86ManagerGeneration != serverGeneration) {
+ if((xf86FBMangerIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+ xf86ManagerGeneration = serverGeneration;
+ }
+
+ pScreen->devPrivates[xf86FBMangerIndex].ptr = (pointer)funcs;
+
+ return TRUE;
+}
+
+
+Bool
+xf86FBManagerRunning(ScreenPtr pScreen)
+{
+ if(xf86FBMangerIndex < 0)
+ return FALSE;
+ if(!pScreen->devPrivates[xf86FBMangerIndex].ptr)
+ return FALSE;
+
+ return TRUE;
+}
+
+Bool
+xf86RegisterFreeBoxCallback(
+ ScreenPtr pScreen,
+ FreeBoxCallbackProcPtr FreeBoxCallback,
+ pointer devPriv
+){
+ FBManagerFuncsPtr funcs;
+
+ if(xf86FBMangerIndex < 0)
+ return FALSE;
+ if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ return FALSE;
+
+ return (*funcs->RegisterFreeBoxCallback)(pScreen, FreeBoxCallback, devPriv);
+}
+
+
+FBAreaPtr
+xf86AllocateOffscreenArea(
+ ScreenPtr pScreen,
+ int w, int h,
+ int gran,
+ MoveAreaCallbackProcPtr moveCB,
+ RemoveAreaCallbackProcPtr removeCB,
+ pointer privData
+){
+ FBManagerFuncsPtr funcs;
+
+ if(xf86FBMangerIndex < 0)
+ return NULL;
+ if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ return NULL;
+
+ return (*funcs->AllocateOffscreenArea)(
+ pScreen, w, h, gran, moveCB, removeCB, privData);
+}
+
+
+FBLinearPtr
+xf86AllocateOffscreenLinear(
+ ScreenPtr pScreen,
+ int length,
+ int gran,
+ MoveLinearCallbackProcPtr moveCB,
+ RemoveLinearCallbackProcPtr removeCB,
+ pointer privData
+){
+ FBManagerFuncsPtr funcs;
+
+ if(xf86FBMangerIndex < 0)
+ return NULL;
+ if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ return NULL;
+
+ return (*funcs->AllocateOffscreenLinear)(
+ pScreen, length, gran, moveCB, removeCB, privData);
+}
+
+
+void
+xf86FreeOffscreenArea(FBAreaPtr area)
+{
+ FBManagerFuncsPtr funcs;
+
+ if(!area) return;
+
+ if(xf86FBMangerIndex < 0)
+ return;
+ if(!(funcs =
+ (FBManagerFuncsPtr)area->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ return;
+
+ (*funcs->FreeOffscreenArea)(area);
+
+ return;
+}
+
+
+void
+xf86FreeOffscreenLinear(FBLinearPtr linear)
+{
+ FBManagerFuncsPtr funcs;
+
+ if(!linear) return;
+
+ if(xf86FBMangerIndex < 0)
+ return;
+ if(!(funcs =
+ (FBManagerFuncsPtr)linear->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ return;
+
+ (*funcs->FreeOffscreenLinear)(linear);
+
+ return;
+}
+
+
+Bool
+xf86ResizeOffscreenArea(
+ FBAreaPtr resize,
+ int w, int h
+){
+ FBManagerFuncsPtr funcs;
+
+ if(!resize) return FALSE;
+
+ if(xf86FBMangerIndex < 0)
+ return FALSE;
+ if(!(funcs =
+ (FBManagerFuncsPtr)resize->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ return FALSE;
+
+ return (*funcs->ResizeOffscreenArea)(resize, w, h);
+}
+
+Bool
+xf86ResizeOffscreenLinear(
+ FBLinearPtr resize,
+ int size
+){
+ FBManagerFuncsPtr funcs;
+
+ if(!resize) return FALSE;
+
+ if(xf86FBMangerIndex < 0)
+ return FALSE;
+ if(!(funcs =
+ (FBManagerFuncsPtr)resize->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ return FALSE;
+
+ return (*funcs->ResizeOffscreenLinear)(resize, size);
+}
+
+
+Bool
+xf86QueryLargestOffscreenArea(
+ ScreenPtr pScreen,
+ int *w, int *h,
+ int gran,
+ int preferences,
+ int severity
+){
+ FBManagerFuncsPtr funcs;
+
+ *w = 0;
+ *h = 0;
+
+ if(xf86FBMangerIndex < 0)
+ return FALSE;
+ if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ return FALSE;
+
+ return (*funcs->QueryLargestOffscreenArea)(
+ pScreen, w, h, gran, preferences, severity);
+}
+
+Bool
+xf86QueryLargestOffscreenLinear(
+ ScreenPtr pScreen,
+ int *size,
+ int gran,
+ int severity
+){
+ FBManagerFuncsPtr funcs;
+
+ *size = 0;
+
+ if(xf86FBMangerIndex < 0)
+ return FALSE;
+ if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ return FALSE;
+
+ return (*funcs->QueryLargestOffscreenLinear)(
+ pScreen, size, gran, severity);
+}
+
+
+Bool
+xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
+{
+ FBManagerFuncsPtr funcs;
+
+ if(xf86FBMangerIndex < 0)
+ return FALSE;
+ if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ return FALSE;
+
+ return (*funcs->PurgeOffscreenAreas)(pScreen);
+}
+
+/************************************************************\
+
+ Below is a specific implementation of an offscreen manager.
+
+\************************************************************/
+
+static unsigned long xf86FBGeneration = 0;
+static int xf86FBScreenIndex = -1;
+
+typedef struct _FBLink {
+ FBArea area;
+ struct _FBLink *next;
+} FBLink, *FBLinkPtr;
+
+typedef struct _FBLinearLink {
+ FBLinear linear;
+ int free; /* need to add free here as FBLinear is publicly accessible */
+ FBAreaPtr area; /* only used if allocation came from XY area */
+ struct _FBLinearLink *next;
+} FBLinearLink, *FBLinearLinkPtr;
+
+
+typedef struct {
+ ScreenPtr pScreen;
+ RegionPtr InitialBoxes;
+ RegionPtr FreeBoxes;
+ FBLinkPtr UsedAreas;
+ int NumUsedAreas;
+ FBLinearLinkPtr LinearAreas;
+ CloseScreenProcPtr CloseScreen;
+ int NumCallbacks;
+ FreeBoxCallbackProcPtr *FreeBoxesUpdateCallback;
+ DevUnion *devPrivates;
+} FBManager, *FBManagerPtr;
+
+
+static void
+SendCallFreeBoxCallbacks(FBManagerPtr offman)
+{
+ int i = offman->NumCallbacks;
+
+ while(i--) {
+ (*offman->FreeBoxesUpdateCallback[i])(
+ offman->pScreen, offman->FreeBoxes, offman->devPrivates[i].ptr);
+ }
+}
+
+static Bool
+localRegisterFreeBoxCallback(
+ ScreenPtr pScreen,
+ FreeBoxCallbackProcPtr FreeBoxCallback,
+ pointer devPriv
+){
+ FBManagerPtr offman;
+ FreeBoxCallbackProcPtr *newCallbacks;
+ DevUnion *newPrivates;
+
+ offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+
+ newCallbacks = xrealloc( offman->FreeBoxesUpdateCallback,
+ sizeof(FreeBoxCallbackProcPtr) * (offman->NumCallbacks + 1));
+
+ newPrivates = xrealloc(offman->devPrivates,
+ sizeof(DevUnion) * (offman->NumCallbacks + 1));
+
+ if(!newCallbacks || !newPrivates)
+ return FALSE;
+
+ offman->FreeBoxesUpdateCallback = newCallbacks;
+ offman->devPrivates = newPrivates;
+
+ offman->FreeBoxesUpdateCallback[offman->NumCallbacks] = FreeBoxCallback;
+ offman->devPrivates[offman->NumCallbacks].ptr = devPriv;
+ offman->NumCallbacks++;
+
+ SendCallFreeBoxCallbacks(offman);
+
+ return TRUE;
+}
+
+
+static FBAreaPtr
+AllocateArea(
+ FBManagerPtr offman,
+ int w, int h,
+ int granularity,
+ MoveAreaCallbackProcPtr moveCB,
+ RemoveAreaCallbackProcPtr removeCB,
+ pointer privData
+){
+ ScreenPtr pScreen = offman->pScreen;
+ FBLinkPtr link = NULL;
+ FBAreaPtr area = NULL;
+ RegionRec NewReg;
+ int i, x = 0, num;
+ BoxPtr boxp;
+
+ if(granularity <= 1) granularity = 0;
+
+ boxp = REGION_RECTS(offman->FreeBoxes);
+ num = REGION_NUM_RECTS(offman->FreeBoxes);
+
+ /* look through the free boxes */
+ for(i = 0; i < num; i++, boxp++) {
+ x = boxp->x1;
+ if(granularity) {
+ int tmp = x % granularity;
+ if(tmp) x += (granularity - tmp);
+ }
+
+ if(((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w))
+ continue;
+
+ link = xalloc(sizeof(FBLink));
+ if(!link) return NULL;
+
+ area = &(link->area);
+ link->next = offman->UsedAreas;
+ offman->UsedAreas = link;
+ offman->NumUsedAreas++;
+ break;
+ }
+
+ /* try to boot a removeable one out if we are not expendable ourselves */
+ if(!area && !removeCB) {
+ link = offman->UsedAreas;
+
+ while(link) {
+ if(!link->area.RemoveAreaCallback) {
+ link = link->next;
+ continue;
+ }
+
+ boxp = &(link->area.box);
+ x = boxp->x1;
+ if(granularity) {
+ int tmp = x % granularity;
+ if(tmp) x += (granularity - tmp);
+ }
+
+ if(((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w)) {
+ link = link->next;
+ continue;
+ }
+
+ /* bye, bye */
+ (*link->area.RemoveAreaCallback)(&link->area);
+ REGION_INIT(pScreen, &NewReg, &(link->area.box), 1);
+ REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &NewReg);
+ REGION_UNINIT(pScreen, &NewReg);
+
+ area = &(link->area);
+ break;
+ }
+ }
+
+ if(area) {
+ area->pScreen = pScreen;
+ area->granularity = granularity;
+ area->box.x1 = x;
+ area->box.x2 = x + w;
+ area->box.y1 = boxp->y1;
+ area->box.y2 = boxp->y1 + h;
+ area->MoveAreaCallback = moveCB;
+ area->RemoveAreaCallback = removeCB;
+ area->devPrivate.ptr = privData;
+
+ REGION_INIT(pScreen, &NewReg, &(area->box), 1);
+ REGION_SUBTRACT(pScreen, offman->FreeBoxes, offman->FreeBoxes, &NewReg);
+ REGION_UNINIT(pScreen, &NewReg);
+ }
+
+ return area;
+}
+
+static FBAreaPtr
+localAllocateOffscreenArea(
+ ScreenPtr pScreen,
+ int w, int h,
+ int gran,
+ MoveAreaCallbackProcPtr moveCB,
+ RemoveAreaCallbackProcPtr removeCB,
+ pointer privData
+){
+ FBManagerPtr offman;
+ FBAreaPtr area = NULL;
+
+ offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+
+ if((area = AllocateArea(offman, w, h, gran, moveCB, removeCB, privData)))
+ SendCallFreeBoxCallbacks(offman);
+
+ return area;
+}
+
+
+static void
+localFreeOffscreenArea(FBAreaPtr area)
+{
+ FBManagerPtr offman;
+ FBLinkPtr pLink, pLinkPrev = NULL;
+ RegionRec FreedRegion;
+ ScreenPtr pScreen;
+
+ pScreen = area->pScreen;
+ offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+
+ pLink = offman->UsedAreas;
+ if(!pLink) return;
+
+ while(&(pLink->area) != area) {
+ pLinkPrev = pLink;
+ pLink = pLink->next;
+ if(!pLink) return;
+ }
+
+ /* put the area back into the pool */
+ REGION_INIT(pScreen, &FreedRegion, &(pLink->area.box), 1);
+ REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedRegion);
+ REGION_UNINIT(pScreen, &FreedRegion);
+
+ if(pLinkPrev)
+ pLinkPrev->next = pLink->next;
+ else offman->UsedAreas = pLink->next;
+
+ xfree(pLink);
+ offman->NumUsedAreas--;
+
+ SendCallFreeBoxCallbacks(offman);
+}
+
+
+
+static Bool
+localResizeOffscreenArea(
+ FBAreaPtr resize,
+ int w, int h
+){
+ FBManagerPtr offman;
+ ScreenPtr pScreen;
+ BoxRec OrigArea;
+ RegionRec FreedReg;
+ FBAreaPtr area = NULL;
+ FBLinkPtr pLink, newLink, pLinkPrev = NULL;
+
+ pScreen = resize->pScreen;
+ offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+
+ /* find this link */
+ if(!(pLink = offman->UsedAreas))
+ return FALSE;
+
+ while(&(pLink->area) != resize) {
+ pLinkPrev = pLink;
+ pLink = pLink->next;
+ if(!pLink) return FALSE;
+ }
+
+ OrigArea.x1 = resize->box.x1;
+ OrigArea.x2 = resize->box.x2;
+ OrigArea.y1 = resize->box.y1;
+ OrigArea.y2 = resize->box.y2;
+
+ /* if it's smaller, this is easy */
+
+ if((w <= (resize->box.x2 - resize->box.x1)) &&
+ (h <= (resize->box.y2 - resize->box.y1))) {
+ RegionRec NewReg;
+
+ resize->box.x2 = resize->box.x1 + w;
+ resize->box.y2 = resize->box.y1 + h;
+
+ if((resize->box.y2 == OrigArea.y2) &&
+ (resize->box.x2 == OrigArea.x2))
+ return TRUE;
+
+ REGION_INIT(pScreen, &FreedReg, &OrigArea, 1);
+ REGION_INIT(pScreen, &NewReg, &(resize->box), 1);
+ REGION_SUBTRACT(pScreen, &FreedReg, &FreedReg, &NewReg);
+ REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
+ REGION_UNINIT(pScreen, &FreedReg);
+ REGION_UNINIT(pScreen, &NewReg);
+
+ SendCallFreeBoxCallbacks(offman);
+
+ return TRUE;
+ }
+
+
+ /* otherwise we remove the old region */
+
+ REGION_INIT(pScreen, &FreedReg, &OrigArea, 1);
+ REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
+
+ /* remove the old link */
+ if(pLinkPrev)
+ pLinkPrev->next = pLink->next;
+ else offman->UsedAreas = pLink->next;
+
+ /* and try to add a new one */
+
+ if((area = AllocateArea(offman, w, h, resize->granularity,
+ resize->MoveAreaCallback, resize->RemoveAreaCallback,
+ resize->devPrivate.ptr))) {
+
+ /* copy data over to our link and replace the new with old */
+ memcpy(resize, area, sizeof(FBArea));
+
+ pLinkPrev = NULL;
+ newLink = offman->UsedAreas;
+
+ while(&(newLink->area) != area) {
+ pLinkPrev = newLink;
+ newLink = newLink->next;
+ }
+
+ if(pLinkPrev)
+ pLinkPrev->next = newLink->next;
+ else offman->UsedAreas = newLink->next;
+
+ pLink->next = offman->UsedAreas;
+ offman->UsedAreas = pLink;
+
+ xfree(newLink);
+
+ /* AllocateArea added one but we really only exchanged one */
+ offman->NumUsedAreas--;
+ } else {
+ /* reinstate the old region */
+ REGION_SUBTRACT(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
+ REGION_UNINIT(pScreen, &FreedReg);
+
+ pLink->next = offman->UsedAreas;
+ offman->UsedAreas = pLink;
+ return FALSE;
+ }
+
+
+ REGION_UNINIT(pScreen, &FreedReg);
+
+ SendCallFreeBoxCallbacks(offman);
+
+ return TRUE;
+}
+
+static Bool
+localQueryLargestOffscreenArea(
+ ScreenPtr pScreen,
+ int *width, int *height,
+ int granularity,
+ int preferences,
+ int severity
+){
+ FBManagerPtr offman;
+ RegionPtr newRegion = NULL;
+ BoxPtr pbox;
+ int nbox;
+ int x, w, h, area, oldArea;
+
+ *width = *height = oldArea = 0;
+
+ if(granularity <= 1) granularity = 0;
+
+ if((preferences < 0) || (preferences > 3))
+ return FALSE;
+
+ offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+
+ if(severity < 0) severity = 0;
+ if(severity > 2) severity = 2;
+
+ switch(severity) {
+ case 2:
+ if(offman->NumUsedAreas) {
+ FBLinkPtr pLink;
+ RegionRec tmpRegion;
+ newRegion = REGION_CREATE(pScreen, NULL, 1);
+ REGION_COPY(pScreen, newRegion, offman->InitialBoxes);
+ pLink = offman->UsedAreas;
+
+ while(pLink) {
+ if(!pLink->area.RemoveAreaCallback) {
+ REGION_INIT(pScreen, &tmpRegion, &(pLink->area.box), 1);
+ REGION_SUBTRACT(pScreen, newRegion, newRegion, &tmpRegion);
+ REGION_UNINIT(pScreen, &tmpRegion);
+ }
+ pLink = pLink->next;
+ }
+
+ nbox = REGION_NUM_RECTS(newRegion);
+ pbox = REGION_RECTS(newRegion);
+ break;
+ }
+ case 1:
+ if(offman->NumUsedAreas) {
+ FBLinkPtr pLink;
+ RegionRec tmpRegion;
+ newRegion = REGION_CREATE(pScreen, NULL, 1);
+ REGION_COPY(pScreen, newRegion, offman->FreeBoxes);
+ pLink = offman->UsedAreas;
+
+ while(pLink) {
+ if(pLink->area.RemoveAreaCallback) {
+ REGION_INIT(pScreen, &tmpRegion, &(pLink->area.box), 1);
+ REGION_APPEND(pScreen, newRegion, &tmpRegion);
+ REGION_UNINIT(pScreen, &tmpRegion);
+ }
+ pLink = pLink->next;
+ }
+
+ nbox = REGION_NUM_RECTS(newRegion);
+ pbox = REGION_RECTS(newRegion);
+ break;
+ }
+ default:
+ nbox = REGION_NUM_RECTS(offman->FreeBoxes);
+ pbox = REGION_RECTS(offman->FreeBoxes);
+ break;
+ }
+
+ while(nbox--) {
+ x = pbox->x1;
+ if(granularity) {
+ int tmp = x % granularity;
+ if(tmp) x += (granularity - tmp);
+ }
+
+ w = pbox->x2 - x;
+ h = pbox->y2 - pbox->y1;
+ area = w * h;
+
+ if(w > 0) {
+ Bool gotIt = FALSE;
+ switch(preferences) {
+ case FAVOR_AREA_THEN_WIDTH:
+ if((area > oldArea) || ((area == oldArea) && (w > *width)))
+ gotIt = TRUE;
+ break;
+ case FAVOR_AREA_THEN_HEIGHT:
+ if((area > oldArea) || ((area == oldArea) && (h > *height)))
+ gotIt = TRUE;
+ break;
+ case FAVOR_WIDTH_THEN_AREA:
+ if((w > *width) || ((w == *width) && (area > oldArea)))
+ gotIt = TRUE;
+ break;
+ case FAVOR_HEIGHT_THEN_AREA:
+ if((h > *height) || ((h == *height) && (area > oldArea)))
+ gotIt = TRUE;
+ break;
+ }
+ if(gotIt) {
+ *width = w;
+ *height = h;
+ oldArea = area;
+ }
+ }
+ pbox++;
+ }
+
+ if(newRegion)
+ REGION_DESTROY(pScreen, newRegion);
+
+ return TRUE;
+}
+
+static Bool
+localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
+{
+ FBManagerPtr offman;
+ FBLinkPtr pLink, tmp, pPrev = NULL;
+ RegionRec FreedRegion;
+ Bool anyUsed = FALSE;
+
+ offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+
+ pLink = offman->UsedAreas;
+ if(!pLink) return TRUE;
+
+ while(pLink) {
+ if(pLink->area.RemoveAreaCallback) {
+ (*pLink->area.RemoveAreaCallback)(&pLink->area);
+
+ REGION_INIT(pScreen, &FreedRegion, &(pLink->area.box), 1);
+ REGION_APPEND(pScreen, offman->FreeBoxes, &FreedRegion);
+ REGION_UNINIT(pScreen, &FreedRegion);
+
+ if(pPrev)
+ pPrev->next = pLink->next;
+ else offman->UsedAreas = pLink->next;
+
+ tmp = pLink;
+ pLink = pLink->next;
+ xfree(tmp);
+ offman->NumUsedAreas--;
+ anyUsed = TRUE;
+ } else {
+ pPrev = pLink;
+ pLink = pLink->next;
+ }
+ }
+
+ if(anyUsed) {
+ REGION_VALIDATE(pScreen, offman->FreeBoxes, &anyUsed);
+ SendCallFreeBoxCallbacks(offman);
+ }
+
+ return TRUE;
+}
+
+static void
+LinearMoveCBWrapper(FBAreaPtr from, FBAreaPtr to)
+{
+ /* this will never get called */
+}
+
+static void
+LinearRemoveCBWrapper(FBAreaPtr area)
+{
+ FBManagerPtr offman;
+ FBLinearLinkPtr pLink, pLinkPrev = NULL;
+ ScreenPtr pScreen = area->pScreen;
+
+ offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+
+ pLink = offman->LinearAreas;
+ if(!pLink) return;
+
+ while(pLink->area != area) {
+ pLinkPrev = pLink;
+ pLink = pLink->next;
+ if(!pLink) return;
+ }
+
+ /* give the user the callback it is expecting */
+ (*pLink->linear.RemoveLinearCallback)(&(pLink->linear));
+
+ if(pLinkPrev)
+ pLinkPrev->next = pLink->next;
+ else offman->LinearAreas = pLink->next;
+
+ xfree(pLink);
+}
+
+#ifdef DEBUG
+static void
+Dump(FBLinearLinkPtr pLink)
+{
+ if (!pLink) ErrorF("MMmm, PLINK IS NULL!\n");
+
+ while (pLink) {
+ ErrorF(" Offset:%08x, Size:%08x, %s,%s\n",
+ pLink->linear.offset,
+ pLink->linear.size,
+ pLink->free ? "Free" : "Used",
+ pLink->area ? "Area" : "Linear");
+
+ pLink = pLink->next;
+ }
+}
+#endif
+
+static FBLinearPtr
+AllocateLinear(
+ FBManagerPtr offman,
+ int size,
+ int granularity,
+ pointer privData
+){
+ ScreenPtr pScreen = offman->pScreen;
+ FBLinearLinkPtr linear = NULL;
+ FBLinearLinkPtr newlink = NULL;
+ int offset, end;
+
+ if(size <= 0) return NULL;
+
+ if (!offman->LinearAreas) return NULL;
+
+ linear = offman->LinearAreas;
+ while (linear) {
+ /* Make sure we get a free area that's not an XY fallback case */
+ if (!linear->area && linear->free) {
+ offset = (linear->linear.offset + granularity) & ~granularity;
+ end = offset+size;
+ if (end <= (linear->linear.offset + linear->linear.size))
+ break;
+ }
+ linear = linear->next;
+ }
+ if (!linear)
+ return NULL;
+
+ /* break left */
+ if (offset > linear->linear.offset) {
+ newlink = xalloc(sizeof(FBLinearLink));
+ if (!newlink)
+ return NULL;
+ newlink->area = NULL;
+ newlink->linear.offset = offset;
+ newlink->linear.size = linear->linear.size - (offset - linear->linear.offset);
+ newlink->free = 1;
+ newlink->next = linear->next;
+ linear->linear.size -= newlink->linear.size;
+ linear->next = newlink;
+ linear = newlink;
+ }
+
+ /* break right */
+ if (size < linear->linear.size) {
+ newlink = xalloc(sizeof(FBLinearLink));
+ if (!newlink)
+ return NULL;
+ newlink->area = NULL;
+ newlink->linear.offset = offset + size;
+ newlink->linear.size = linear->linear.size - size;
+ newlink->free = 1;
+ newlink->next = linear->next;
+ linear->linear.size = size;
+ linear->next = newlink;
+ }
+
+ /* p = middle block */
+ linear->linear.granularity = granularity;
+ linear->free = 0;
+ linear->linear.pScreen = pScreen;
+ linear->linear.MoveLinearCallback = NULL;
+ linear->linear.RemoveLinearCallback = NULL;
+ linear->linear.devPrivate.ptr = NULL;
+
+#ifdef DEBUG
+ Dump(offman->LinearAreas);
+#endif
+
+ return &(linear->linear);
+}
+
+static FBLinearPtr
+localAllocateOffscreenLinear(
+ ScreenPtr pScreen,
+ int length,
+ int gran,
+ MoveLinearCallbackProcPtr moveCB,
+ RemoveLinearCallbackProcPtr removeCB,
+ pointer privData
+){
+ FBManagerPtr offman;
+ FBLinearLinkPtr link;
+ FBAreaPtr area;
+ FBLinearPtr linear = NULL;
+ BoxPtr extents;
+ int w, h, pitch;
+
+ offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+
+ /* Try to allocate from linear memory first...... */
+#ifdef DEBUG
+ ErrorF("ALLOCATING LINEAR\n");
+#endif
+ if ((linear = AllocateLinear(offman, length, gran, privData)))
+ return linear;
+
+#ifdef DEBUG
+ ErrorF("NOPE, ALLOCATING AREA\n");
+#endif
+
+ if(!(link = xalloc(sizeof(FBLinearLink))))
+ return NULL;
+
+ /* No linear available, so try and pinch some from the XY areas */
+ extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
+ pitch = extents->x2 - extents->x1;
+
+ if(gran && ((gran > pitch) || (pitch % gran))) {
+ /* we can't match the specified alignment with XY allocations */
+ xfree(link);
+ return NULL;
+ }
+
+ if(length < pitch) { /* special case */
+ w = length;
+ h = 1;
+ } else {
+ w = pitch;
+ h = (length + pitch - 1) / pitch;
+ }
+
+ if((area = localAllocateOffscreenArea(pScreen, w, h, gran,
+ moveCB ? LinearMoveCBWrapper : NULL,
+ removeCB ? LinearRemoveCBWrapper : NULL,
+ privData)))
+ {
+ link->area = area;
+ link->free = 0;
+ link->next = offman->LinearAreas;
+ offman->LinearAreas = link;
+ linear = &(link->linear);
+ linear->pScreen = pScreen;
+ linear->size = h * w;
+ linear->offset = (pitch * area->box.y1) + area->box.x1;
+ linear->granularity = gran;
+ linear->MoveLinearCallback = moveCB;
+ linear->RemoveLinearCallback = removeCB;
+ linear->devPrivate.ptr = privData;
+ } else
+ xfree(link);
+
+#ifdef DEBUG
+ Dump(offman->LinearAreas);
+#endif
+
+ return linear;
+}
+
+
+static void
+localFreeOffscreenLinear(FBLinearPtr linear)
+{
+ FBManagerPtr offman;
+ FBLinearLinkPtr pLink, pLinkPrev = NULL;
+ ScreenPtr pScreen = linear->pScreen;
+
+ offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+
+ pLink = offman->LinearAreas;
+ if(!pLink) return;
+
+ while(&(pLink->linear) != linear) {
+ pLinkPrev = pLink;
+ pLink = pLink->next;
+ if(!pLink) return;
+ }
+
+ if(pLink->area) { /* really an XY area */
+#ifdef DEBUG
+ ErrorF("FREEING AREA\n");
+#endif
+ localFreeOffscreenArea(pLink->area);
+ if(pLinkPrev)
+ pLinkPrev->next = pLink->next;
+ else offman->LinearAreas = pLink->next;
+ xfree(pLink);
+#ifdef DEBUG
+ Dump(offman->LinearAreas);
+#endif
+ return;
+ }
+
+ pLink->free = 1;
+
+ if (pLink->next && pLink->next->free) {
+ FBLinearLinkPtr p = pLink->next;
+ pLink->linear.size += p->linear.size;
+ pLink->next = p->next;
+ free(p);
+ }
+
+ if(pLinkPrev) {
+ if (pLinkPrev->next && pLinkPrev->next->free && !pLinkPrev->area) {
+ FBLinearLinkPtr p = pLinkPrev->next;
+ pLinkPrev->linear.size += p->linear.size;
+ pLinkPrev->next = p->next;
+ free(p);
+ }
+ }
+
+#ifdef DEBUG
+ ErrorF("FREEING LINEAR\n");
+ Dump(offman->LinearAreas);
+#endif
+}
+
+
+static Bool
+localResizeOffscreenLinear(FBLinearPtr resize, int length)
+{
+ FBManagerPtr offman;
+ FBLinearLinkPtr pLink;
+ ScreenPtr pScreen = resize->pScreen;
+
+ offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+
+ pLink = offman->LinearAreas;
+ if(!pLink) return FALSE;
+
+ while(&(pLink->linear) != resize) {
+ pLink = pLink->next;
+ if(!pLink) return FALSE;
+ }
+
+ /* This could actually be alot smarter and try to move allocations
+ from XY to linear when available. For now if it was XY, we keep
+ it XY */
+
+ if(pLink->area) { /* really an XY area */
+ BoxPtr extents;
+ int pitch, w, h;
+
+ extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
+ pitch = extents->x2 - extents->x1;
+
+ if(length < pitch) { /* special case */
+ w = length;
+ h = 1;
+ } else {
+ w = pitch;
+ h = (length + pitch - 1) / pitch;
+ }
+
+ if(localResizeOffscreenArea(pLink->area, w, h)) {
+ resize->size = h * w;
+ resize->offset = (pitch * pLink->area->box.y1) + pLink->area->box.x1;
+ return TRUE;
+ }
+ } else {
+ /* TODO!!!! resize the linear area */
+ }
+
+ return FALSE;
+}
+
+
+static Bool
+localQueryLargestOffscreenLinear(
+ ScreenPtr pScreen,
+ int *size,
+ int gran,
+ int priority
+)
+{
+ FBManagerPtr offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+ FBLinearLinkPtr pLink;
+ FBLinearLinkPtr pLinkRet;
+
+ *size = 0;
+
+ pLink = offman->LinearAreas;
+
+ if (pLink && !pLink->area) {
+ pLinkRet = pLink;
+ while (pLink) {
+ if (pLink->free) {
+ if (pLink->linear.size > pLinkRet->linear.size)
+ pLinkRet = pLink;
+ }
+ pLink = pLink->next;
+ }
+
+ if (pLinkRet->free) {
+ *size = pLinkRet->linear.size;
+ return TRUE;
+ }
+ } else {
+ int w, h;
+
+ if(localQueryLargestOffscreenArea(pScreen, &w, &h, gran,
+ FAVOR_WIDTH_THEN_AREA, priority))
+ {
+ FBManagerPtr offman;
+ BoxPtr extents;
+
+ offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+ extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
+ if((extents->x2 - extents->x1) == w)
+ *size = w * h;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+
+
+static FBManagerFuncs xf86FBManFuncs = {
+ localAllocateOffscreenArea,
+ localFreeOffscreenArea,
+ localResizeOffscreenArea,
+ localQueryLargestOffscreenArea,
+ localRegisterFreeBoxCallback,
+ localAllocateOffscreenLinear,
+ localFreeOffscreenLinear,
+ localResizeOffscreenLinear,
+ localQueryLargestOffscreenLinear,
+ localPurgeUnlockedOffscreenAreas
+ };
+
+
+static Bool
+xf86FBCloseScreen (int i, ScreenPtr pScreen)
+{
+ FBLinkPtr pLink, tmp;
+ FBLinearLinkPtr pLinearLink, tmp2;
+ FBManagerPtr offman =
+ (FBManagerPtr) pScreen->devPrivates[xf86FBScreenIndex].ptr;
+
+
+ pScreen->CloseScreen = offman->CloseScreen;
+
+ pLink = offman->UsedAreas;
+ while(pLink) {
+ tmp = pLink;
+ pLink = pLink->next;
+ xfree(tmp);
+ }
+
+ pLinearLink = offman->LinearAreas;
+ while(pLinearLink) {
+ tmp2 = pLinearLink;
+ pLinearLink = pLinearLink->next;
+ xfree(tmp2);
+ }
+
+ REGION_DESTROY(pScreen, offman->InitialBoxes);
+ REGION_DESTROY(pScreen, offman->FreeBoxes);
+
+ xfree(offman->FreeBoxesUpdateCallback);
+ xfree(offman->devPrivates);
+ xfree(offman);
+ pScreen->devPrivates[xf86FBScreenIndex].ptr = NULL;
+
+ return (*pScreen->CloseScreen) (i, pScreen);
+}
+
+Bool
+xf86InitFBManager(
+ ScreenPtr pScreen,
+ BoxPtr FullBox
+){
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ RegionRec ScreenRegion;
+ RegionRec FullRegion;
+ BoxRec ScreenBox;
+ Bool ret;
+
+ ScreenBox.x1 = 0;
+ ScreenBox.y1 = 0;
+ ScreenBox.x2 = pScrn->virtualX;
+ ScreenBox.y2 = pScrn->virtualY;
+
+ if((FullBox->x1 > ScreenBox.x1) || (FullBox->y1 > ScreenBox.y1) ||
+ (FullBox->x2 < ScreenBox.x2) || (FullBox->y2 < ScreenBox.y2)) {
+ return FALSE;
+ }
+
+ if (FullBox->y2 < FullBox->y1) return FALSE;
+ if (FullBox->x2 < FullBox->x2) return FALSE;
+
+ REGION_INIT(pScreen, &ScreenRegion, &ScreenBox, 1);
+ REGION_INIT(pScreen, &FullRegion, FullBox, 1);
+
+ REGION_SUBTRACT(pScreen, &FullRegion, &FullRegion, &ScreenRegion);
+
+ ret = xf86InitFBManagerRegion(pScreen, &FullRegion);
+
+ REGION_UNINIT(pScreen, &ScreenRegion);
+ REGION_UNINIT(pScreen, &FullRegion);
+
+ return ret;
+}
+
+Bool
+xf86InitFBManagerArea(
+ ScreenPtr pScreen,
+ int PixelArea,
+ int Verbosity
+)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xRectangle Rect[3];
+ RegionPtr pRegion, pScreenRegion;
+ int nRect;
+ Bool ret = FALSE;
+
+ if (PixelArea < (pScrn->displayWidth * pScrn->virtualY))
+ return FALSE;
+
+ Rect[0].x = Rect[0].y = 0;
+ Rect[0].width = pScrn->displayWidth;
+ Rect[0].height = PixelArea / pScrn->displayWidth;
+ nRect = 1;
+
+ /* Add a possible partial scanline */
+ if ((Rect[1].height = Rect[1].width = PixelArea % pScrn->displayWidth)) {
+ Rect[1].x = 0;
+ Rect[1].y = Rect[0].height;
+ Rect[1].height = 1;
+ nRect++;
+ }
+
+ /* Factor out virtual resolution */
+ pRegion = RECTS_TO_REGION(pScreen, nRect, Rect, 0);
+ if (pRegion) {
+ if (!REGION_NAR(pRegion)) {
+ Rect[2].x = Rect[2].y = 0;
+ Rect[2].width = pScrn->virtualX;
+ Rect[2].height = pScrn->virtualY;
+
+ pScreenRegion = RECTS_TO_REGION(pScreen, 1, &Rect[2], 0);
+ if (pScreenRegion) {
+ if (!REGION_NAR(pScreenRegion)) {
+ REGION_SUBTRACT(pScreen, pRegion, pRegion, pScreenRegion);
+
+ ret = xf86InitFBManagerRegion(pScreen, pRegion);
+
+ if (ret && xf86GetVerbosity() >= Verbosity) {
+ int scrnIndex = pScrn->scrnIndex;
+
+ xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
+ "Largest offscreen areas (with overlaps):\n");
+
+ if (Rect[2].width < Rect[0].width) {
+ xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
+ "\t%d x %d rectangle at %d,0\n",
+ Rect[0].width - Rect[2].width,
+ Rect[0].height,
+ Rect[2].width);
+ }
+ if (Rect[2].width < Rect[1].width) {
+ xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
+ "\t%d x %d rectangle at %d,0\n",
+ Rect[1].width - Rect[2].width,
+ Rect[0].height + Rect[1].height,
+ Rect[2].width);
+ }
+ if (Rect[2].height < Rect[0].height) {
+ xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
+ "\t%d x %d rectangle at 0,%d\n",
+ Rect[0].width,
+ Rect[0].height - Rect[2].height,
+ Rect[2].height);
+ }
+ if (Rect[1].height) {
+ xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity,
+ "\t%d x %d rectangle at 0,%d\n",
+ Rect[1].width,
+ Rect[0].height - Rect[2].height +
+ Rect[1].height,
+ Rect[2].height);
+ }
+ }
+ }
+
+ REGION_DESTROY(pScreen, pScreenRegion);
+ }
+ }
+
+ REGION_DESTROY(pScreen, pRegion);
+ }
+
+ return ret;
+}
+
+Bool
+xf86InitFBManagerRegion(
+ ScreenPtr pScreen,
+ RegionPtr FullRegion
+){
+ FBManagerPtr offman;
+
+ if(REGION_NIL(FullRegion))
+ return FALSE;
+
+ if(xf86FBGeneration != serverGeneration) {
+ if((xf86FBScreenIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+ xf86FBGeneration = serverGeneration;
+ }
+
+ if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs))
+ return FALSE;
+
+ offman = xalloc(sizeof(FBManager));
+ if(!offman) return FALSE;
+
+ pScreen->devPrivates[xf86FBScreenIndex].ptr = (pointer)offman;
+
+ offman->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = xf86FBCloseScreen;
+
+ offman->InitialBoxes = REGION_CREATE(pScreen, NULL, 1);
+ offman->FreeBoxes = REGION_CREATE(pScreen, NULL, 1);
+
+ REGION_COPY(pScreen, offman->InitialBoxes, FullRegion);
+ REGION_COPY(pScreen, offman->FreeBoxes, FullRegion);
+
+ offman->pScreen = pScreen;
+ offman->UsedAreas = NULL;
+ offman->LinearAreas = NULL;
+ offman->NumUsedAreas = 0;
+ offman->NumCallbacks = 0;
+ offman->FreeBoxesUpdateCallback = NULL;
+ offman->devPrivates = NULL;
+
+ return TRUE;
+}
+
+Bool
+xf86InitFBManagerLinear(
+ ScreenPtr pScreen,
+ int offset,
+ int size
+){
+ FBManagerPtr offman;
+ FBLinearLinkPtr link;
+ FBLinearPtr linear;
+
+ if (size <= 0)
+ return FALSE;
+
+ /* we expect people to have called the Area setup first for pixmap cache */
+ if (!pScreen->devPrivates[xf86FBScreenIndex].ptr)
+ return FALSE;
+
+ offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+
+ offman->LinearAreas = xalloc(sizeof(FBLinearLink));
+ if (!offman->LinearAreas)
+ return FALSE;
+
+ link = offman->LinearAreas;
+ link->area = NULL;
+ link->next = NULL;
+ link->free = 1;
+ linear = &(link->linear);
+ linear->pScreen = pScreen;
+ linear->size = size;
+ linear->offset = offset;
+ linear->granularity = 0;
+ linear->MoveLinearCallback = NULL;
+ linear->RemoveLinearCallback = NULL;
+ linear->devPrivate.ptr = NULL;
+
+ return TRUE;
+}
+
+
+/* This is an implementation specific function and should
+ disappear after the next release. People should use the
+ real linear functions instead */
+
+FBAreaPtr
+xf86AllocateLinearOffscreenArea (
+ ScreenPtr pScreen,
+ int length,
+ int gran,
+ MoveAreaCallbackProcPtr moveCB,
+ RemoveAreaCallbackProcPtr removeCB,
+ pointer privData
+){
+ FBManagerFuncsPtr funcs;
+ FBManagerPtr offman;
+ BoxPtr extents;
+ int w, h;
+
+ if(xf86FBMangerIndex < 0)
+ return NULL;
+ if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ return NULL;
+
+ offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+
+ extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
+ w = extents->x2 - extents->x1;
+
+ if(gran && ((gran > w) || (w % gran))) {
+ /* we can't match the specified alignment with XY allocations */
+ return NULL;
+ }
+
+ if(length <= w) { /* special case */
+ h = 1;
+ w = length;
+ } else {
+ h = (length + w - 1) / w;
+ }
+
+ return (*funcs->AllocateOffscreenArea)(
+ pScreen, w, h, gran, moveCB, removeCB, privData);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86fbman.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86fbman.h
new file mode 100644
index 000000000..adb26a1f1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86fbman.h
@@ -0,0 +1,227 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86fbman.h,v 1.14 2003/10/09 12:40:54 alanh Exp $ */
+
+/*
+ * Copyright (c) 1998-2001 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifndef _XF86FBMAN_H
+#define _XF86FBMAN_H
+
+
+#include "scrnintstr.h"
+#include "regionstr.h"
+
+
+#define FAVOR_AREA_THEN_WIDTH 0
+#define FAVOR_AREA_THEN_HEIGHT 1
+#define FAVOR_WIDTH_THEN_AREA 2
+#define FAVOR_HEIGHT_THEN_AREA 3
+
+#define PRIORITY_LOW 0
+#define PRIORITY_NORMAL 1
+#define PRIORITY_EXTREME 2
+
+
+typedef struct _FBArea {
+ ScreenPtr pScreen;
+ BoxRec box;
+ int granularity;
+ void (*MoveAreaCallback)(struct _FBArea*, struct _FBArea*);
+ void (*RemoveAreaCallback)(struct _FBArea*);
+ DevUnion devPrivate;
+} FBArea, *FBAreaPtr;
+
+typedef struct _FBLinear {
+ ScreenPtr pScreen;
+ int size;
+ int offset;
+ int granularity;
+ void (*MoveLinearCallback)(struct _FBLinear*, struct _FBLinear*);
+ void (*RemoveLinearCallback)(struct _FBLinear*);
+ DevUnion devPrivate;
+} FBLinear, *FBLinearPtr;
+
+typedef void (*FreeBoxCallbackProcPtr)(ScreenPtr, RegionPtr, pointer);
+typedef void (*MoveAreaCallbackProcPtr)(FBAreaPtr, FBAreaPtr);
+typedef void (*RemoveAreaCallbackProcPtr)(FBAreaPtr);
+
+typedef void (*MoveLinearCallbackProcPtr)(FBLinearPtr, FBLinearPtr);
+typedef void (*RemoveLinearCallbackProcPtr)(FBLinearPtr);
+
+
+typedef struct {
+ FBAreaPtr (*AllocateOffscreenArea)(
+ ScreenPtr pScreen,
+ int w, int h,
+ int granularity,
+ MoveAreaCallbackProcPtr moveCB,
+ RemoveAreaCallbackProcPtr removeCB,
+ pointer privData);
+ void (*FreeOffscreenArea)(FBAreaPtr area);
+ Bool (*ResizeOffscreenArea)(FBAreaPtr area, int w, int h);
+ Bool (*QueryLargestOffscreenArea)(
+ ScreenPtr pScreen,
+ int *width, int *height,
+ int granularity,
+ int preferences,
+ int priority);
+ Bool (*RegisterFreeBoxCallback)(
+ ScreenPtr pScreen,
+ FreeBoxCallbackProcPtr FreeBoxCallback,
+ pointer devPriv);
+/* linear functions */
+ FBLinearPtr (*AllocateOffscreenLinear)(
+ ScreenPtr pScreen,
+ int size,
+ int granularity,
+ MoveLinearCallbackProcPtr moveCB,
+ RemoveLinearCallbackProcPtr removeCB,
+ pointer privData);
+ void (*FreeOffscreenLinear)(FBLinearPtr area);
+ Bool (*ResizeOffscreenLinear)(FBLinearPtr area, int size);
+ Bool (*QueryLargestOffscreenLinear)(
+ ScreenPtr pScreen,
+ int *size,
+ int granularity,
+ int priority);
+ Bool (*PurgeOffscreenAreas) (ScreenPtr);
+} FBManagerFuncs, *FBManagerFuncsPtr;
+
+
+Bool xf86RegisterOffscreenManager(
+ ScreenPtr pScreen,
+ FBManagerFuncsPtr funcs
+);
+
+Bool
+xf86InitFBManagerRegion(
+ ScreenPtr pScreen,
+ RegionPtr ScreenRegion
+);
+
+Bool
+xf86InitFBManagerArea(
+ ScreenPtr pScreen,
+ int PixalArea,
+ int Verbosity
+);
+
+Bool
+xf86InitFBManager(
+ ScreenPtr pScreen,
+ BoxPtr FullBox
+);
+
+Bool
+xf86InitFBManagerLinear(
+ ScreenPtr pScreen,
+ int offset,
+ int size
+);
+
+Bool
+xf86FBManagerRunning(
+ ScreenPtr pScreen
+);
+
+FBAreaPtr
+xf86AllocateOffscreenArea (
+ ScreenPtr pScreen,
+ int w, int h,
+ int granularity,
+ MoveAreaCallbackProcPtr moveCB,
+ RemoveAreaCallbackProcPtr removeCB,
+ pointer privData
+);
+
+FBAreaPtr
+xf86AllocateLinearOffscreenArea (
+ ScreenPtr pScreen,
+ int length,
+ int granularity,
+ MoveAreaCallbackProcPtr moveCB,
+ RemoveAreaCallbackProcPtr removeCB,
+ pointer privData
+);
+
+FBLinearPtr
+xf86AllocateOffscreenLinear (
+ ScreenPtr pScreen,
+ int length,
+ int granularity,
+ MoveLinearCallbackProcPtr moveCB,
+ RemoveLinearCallbackProcPtr removeCB,
+ pointer privData
+);
+
+void xf86FreeOffscreenArea(FBAreaPtr area);
+void xf86FreeOffscreenLinear(FBLinearPtr area);
+
+Bool
+xf86ResizeOffscreenArea(
+ FBAreaPtr resize,
+ int w, int h
+);
+
+Bool
+xf86ResizeOffscreenLinear(
+ FBLinearPtr resize,
+ int size
+);
+
+
+Bool
+xf86RegisterFreeBoxCallback(
+ ScreenPtr pScreen,
+ FreeBoxCallbackProcPtr FreeBoxCallback,
+ pointer devPriv
+);
+
+Bool
+xf86PurgeUnlockedOffscreenAreas(
+ ScreenPtr pScreen
+);
+
+
+Bool
+xf86QueryLargestOffscreenArea(
+ ScreenPtr pScreen,
+ int *width, int *height,
+ int granularity,
+ int preferences,
+ int priority
+);
+
+Bool
+xf86QueryLargestOffscreenLinear(
+ ScreenPtr pScreen,
+ int *size,
+ int granularity,
+ int priority
+);
+
+
+#endif /* _XF86FBMAN_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86isaBus.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86isaBus.c
new file mode 100644
index 000000000..2cad85de8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86isaBus.c
@@ -0,0 +1,142 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c,v 3.6 2003/08/24 17:36:55 dawes Exp $ */
+/*
+ * Copyright (c) 1997-2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/*
+ * This file contains the interfaces to the bus-specific code
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Resources.h"
+
+#include "xf86Bus.h"
+
+#define XF86_OS_PRIVS
+#define NEED_OS_RAC_PROTOS
+#include "xf86_OSproc.h"
+
+#include "xf86RAC.h"
+
+Bool isaSlotClaimed = FALSE;
+
+/*
+ * If the slot requested is already in use, return FALSE.
+ * Otherwise, claim the slot for the screen requesting it.
+ */
+
+int
+xf86ClaimIsaSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active)
+{
+ EntityPtr p;
+ BusAccPtr pbap = xf86BusAccInfo;
+ int num;
+
+ num = xf86AllocateEntity();
+ p = xf86Entities[num];
+ p->driver = drvp;
+ p->chipset = chipset;
+ p->busType = BUS_ISA;
+ p->active = active;
+ p->inUse = FALSE;
+ xf86AddDevToEntity(num, dev);
+ p->access = xnfcalloc(1,sizeof(EntityAccessRec));
+ p->access->fallback = &AccessNULL;
+ p->access->pAccess = &AccessNULL;
+ p->busAcc = NULL;
+ while (pbap) {
+ if (pbap->type == BUS_ISA)
+ p->busAcc = pbap;
+ pbap = pbap->next;
+ }
+ isaSlotClaimed = TRUE;
+ return num;
+}
+
+/*
+ * Get the list of ISA "slots" claimed by a screen
+ *
+ * Note: The ISA implementation here assumes that only one ISA "slot" type
+ * can be claimed by any one screen. That means a return value other than
+ * 0 or 1 isn't useful.
+ */
+int
+xf86GetIsaInfoForScreen(int scrnIndex)
+{
+ int num = 0;
+ int i;
+ EntityPtr p;
+
+ for (i = 0; i < xf86Screens[scrnIndex]->numEntities; i++) {
+ p = xf86Entities[xf86Screens[scrnIndex]->entityList[i]];
+ if (p->busType == BUS_ISA) {
+ num++;
+ }
+ }
+ return num;
+}
+
+/*
+ * Parse a BUS ID string, and return True if it is a ISA bus id.
+ */
+
+Bool
+xf86ParseIsaBusString(const char *busID)
+{
+ /*
+ * The format assumed to be "isa" or "isa:"
+ */
+ return (StringToBusType(busID,NULL) == BUS_ISA);
+}
+
+
+/*
+ * xf86IsPrimaryIsa() -- return TRUE if primary device
+ * is ISA.
+ */
+
+Bool
+xf86IsPrimaryIsa(void)
+{
+ return ( primaryBus.type == BUS_ISA );
+}
+
+void
+isaConvertRange2Host(resRange *pRange)
+{
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86noBus.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86noBus.c
new file mode 100644
index 000000000..09f2f4407
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86noBus.c
@@ -0,0 +1,75 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86noBus.c,v 1.2 2003/08/24 17:36:55 dawes Exp $ */
+
+/*
+ * Copyright (c) 2000-2002 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains the interfaces to the bus-specific code
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Resources.h"
+
+#include "xf86Bus.h"
+
+#define XF86_OS_PRIVS
+#define NEED_OS_RAC_PROTOS
+#include "xf86_OSproc.h"
+
+#include "xf86RAC.h"
+
+int
+xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active)
+{
+ EntityPtr p;
+ int num;
+
+ num = xf86AllocateEntity();
+ p = xf86Entities[num];
+ p->driver = drvp;
+ p->chipset = 0;
+ p->busType = BUS_NONE;
+ p->active = active;
+ p->inUse = FALSE;
+ xf86AddDevToEntity(num, dev);
+ p->access = xnfcalloc(1,sizeof(EntityAccessRec));
+ p->access->fallback = &AccessNULL;
+ p->access->pAccess = &AccessNULL;
+ p->busAcc = NULL;
+
+ return num;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86pciBus.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86pciBus.c
new file mode 100644
index 000000000..8fa199872
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86pciBus.c
@@ -0,0 +1,3506 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c,v 3.77 2003/11/03 05:11:03 tsi Exp $ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains the interfaces to the bus-specific code
+ */
+#define INCLUDE_DEPRECATED 1
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <X11/X.h>
+#include "os.h"
+#include "Pci.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Resources.h"
+
+/* Bus-specific headers */
+#include "xf86PciData.h"
+
+#include "xf86Bus.h"
+
+#define XF86_OS_PRIVS
+#define NEED_OS_RAC_PROTOS
+#include "xf86_OSproc.h"
+
+#include "xf86RAC.h"
+
+/* Bus-specific globals */
+Bool pciSlotClaimed = FALSE;
+pciConfigPtr *xf86PciInfo = NULL; /* Full PCI probe info */
+pciVideoPtr *xf86PciVideoInfo = NULL; /* PCI probe for video hw */
+pciAccPtr * xf86PciAccInfo = NULL; /* PCI access related */
+
+/* pcidata globals */
+ScanPciSetupProcPtr xf86SetupPciIds = NULL;
+ScanPciCloseProcPtr xf86ClosePciIds = NULL;
+ScanPciFindByDeviceProcPtr xf86FindPciNamesByDevice = NULL;
+ScanPciFindBySubsysProcPtr xf86FindPciNamesBySubsys = NULL;
+ScanPciFindClassBySubsysProcPtr xf86FindPciClassBySubsys = NULL;
+ScanPciFindClassByDeviceProcPtr xf86FindPciClassByDevice = NULL;
+
+static resPtr pciAvoidRes = NULL;
+
+/* PCI buses */
+static PciBusPtr xf86PciBus = NULL;
+/* Bus-specific probe/sorting functions */
+
+/* PCI classes that get included in xf86PciVideoInfo */
+#define PCIINFOCLASSES(b,s) \
+ (((b) == PCI_CLASS_PREHISTORIC) || \
+ ((b) == PCI_CLASS_DISPLAY) || \
+ ((b) == PCI_CLASS_MULTIMEDIA && (s) == PCI_SUBCLASS_MULTIMEDIA_VIDEO) || \
+ ((b) == PCI_CLASS_PROCESSOR && (s) == PCI_SUBCLASS_PROCESSOR_COPROC))
+
+/*
+ * PCI classes that have messages printed always. The others are only
+ * have a message printed when the vendor/dev IDs are recognised.
+ */
+#define PCIALWAYSPRINTCLASSES(b,s) \
+ (((b) == PCI_CLASS_PREHISTORIC && (s) == PCI_SUBCLASS_PREHISTORIC_VGA) || \
+ ((b) == PCI_CLASS_DISPLAY) || \
+ ((b) == PCI_CLASS_MULTIMEDIA && (s) == PCI_SUBCLASS_MULTIMEDIA_VIDEO))
+
+/*
+ * PCI classes for which potentially destructive checking of the map sizes
+ * may be done. Any classes where this may be unsafe should be omitted
+ * from this list.
+ */
+#define PCINONSYSTEMCLASSES(b,s) PCIALWAYSPRINTCLASSES(b,s)
+
+/*
+ * PCI classes that use RAC
+ */
+#define PCISHAREDIOCLASSES(b,s) \
+ (((b) == PCI_CLASS_PREHISTORIC && (s) == PCI_SUBCLASS_PREHISTORIC_VGA) || \
+ ((b) == PCI_CLASS_DISPLAY && (s) == PCI_SUBCLASS_DISPLAY_VGA))
+
+#define PCI_MEM32_LENGTH_MAX 0xFFFFFFFF
+
+#define B2M(tag,base) pciBusAddrToHostAddr(tag,PCI_MEM,base)
+#define B2I(tag,base) pciBusAddrToHostAddr(tag,PCI_IO,base)
+#define B2H(tag,base,type) (((type & ResPhysMask) == ResMem) ? \
+ B2M(tag, base) : B2I(tag, base))
+#define M2B(tag,base) pciHostAddrToBusAddr(tag,PCI_MEM,base)
+#define I2B(tag,base) pciHostAddrToBusAddr(tag,PCI_IO,base)
+#define H2B(tag,base,type) (((type & ResPhysMask) == ResMem) ? \
+ M2B(tag, base) : I2B(tag, base))
+#define TAG(pvp) (pciTag(pvp->bus,pvp->device,pvp->func))
+#define SIZE(size) ((1 << size) - 1)
+#define PCI_SIZE(type,tag,size) (((type & ResPhysMask) == ResMem) \
+ ? pciBusAddrToHostAddr(tag,PCI_MEM_SIZE,size) \
+ : pciBusAddrToHostAddr(tag,PCI_IO_SIZE,size))
+#define PCI_M_RANGE(range,tag,begin,end,type) \
+ { \
+ RANGE(range, B2M(tag, begin), B2M(tag, end), \
+ RANGE_TYPE(type, xf86GetPciDomain(tag))); \
+ }
+#define PCI_I_RANGE(range,tag,begin,end,type) \
+ { \
+ RANGE(range, B2I(tag, begin), B2I(tag, end), \
+ RANGE_TYPE(type, xf86GetPciDomain(tag))); \
+ }
+#define PCI_X_RANGE(range,tag,begin,end,type) \
+{ if ((type & ResPhysMask) == ResMem) PCI_M_RANGE(range,tag,begin,end,type); \
+ else PCI_I_RANGE(range,tag,begin,end,type); }
+#define P_M_RANGE(range,tag,begin,size,type) \
+ PCI_M_RANGE(range,tag,begin,(begin + SIZE(size)),type)
+#define P_I_RANGE(range,tag,begin,size,type) \
+ PCI_I_RANGE(range,tag,begin,(begin + SIZE(size)),type)
+#define P_X_RANGE(range,tag,begin,size,type) \
+{ if ((type & ResPhysMask) == ResMem) P_M_RANGE(range,tag,begin,size,type); \
+ else P_I_RANGE(range,tag,begin,size,type); }
+#define PV_M_RANGE(range,pvp,i,type) \
+ P_M_RANGE(range,TAG(pvp),pvp->memBase[i],pvp->size[i],type)
+#define PV_B_RANGE(range,pvp,type) \
+ P_M_RANGE(range,TAG(pvp),pvp->biosBase,pvp->biosSize,type)
+#define PV_I_RANGE(range,pvp,i,type) \
+ P_I_RANGE(range,TAG(pvp),pvp->ioBase[i],pvp->size[i],type)
+
+static void getPciClassFlags(pciConfigPtr *pcrpp);
+static void pciConvertListToHost(int bus, int dev, int func, resPtr list);
+static PciBusPtr xf86GetPciBridgeInfo(void);
+
+void
+xf86FormatPciBusNumber(int busnum, char *buffer)
+{
+ /* 'buffer' should be at least 8 characters long */
+ if (busnum < 256)
+ sprintf(buffer, "%d", busnum);
+ else
+ sprintf(buffer, "%d@%d", busnum & 0x00ff, busnum >> 8);
+}
+
+static Bool
+IsBaseUnassigned(CARD32 base)
+{
+ CARD32 mask;
+
+ if (base & PCI_MAP_IO)
+ mask = ~PCI_MAP_IO_ATTR_MASK;
+ else
+ mask = ~PCI_MAP_MEMORY_ATTR_MASK;
+
+ base &= mask;
+ return (!base || (base == mask));
+}
+
+static Bool
+IsBaseUnassigned64(CARD32 base0, CARD32 base1)
+{
+ base0 &= ~PCI_MAP_MEMORY_ATTR_MASK;
+ base1 &= 0xffffffff;
+
+ return ((!base0 && !base1)
+ || ((base0 == ~PCI_MAP_MEMORY_ATTR_MASK)
+ && (base1 == 0xffffffff)));
+}
+
+static void
+FindPCIVideoInfo(void)
+{
+ pciConfigPtr pcrp, *pcrpp;
+ int i = 0, j, k;
+ int num = 0;
+ pciVideoPtr info;
+ int DoIsolateDeviceCheck = 0;
+
+ if (xf86IsolateDevice.bus || xf86IsolateDevice.device || xf86IsolateDevice.func)
+ DoIsolateDeviceCheck = 1;
+ pcrpp = xf86PciInfo = xf86scanpci(0);
+ getPciClassFlags(pcrpp);
+
+ if (pcrpp == NULL) {
+ xf86PciVideoInfo = NULL;
+ return;
+ }
+ xf86PciBus = xf86GetPciBridgeInfo();
+
+ while ((pcrp = pcrpp[i])) {
+ int baseclass;
+ int subclass;
+
+ if (pcrp->listed_class & 0xffff) {
+ baseclass = (pcrp->listed_class >> 8) & 0xff;
+ subclass = pcrp->listed_class & 0xff;
+ } else {
+ baseclass = pcrp->pci_base_class;
+ subclass = pcrp->pci_sub_class;
+ }
+
+ if (PCIINFOCLASSES(baseclass, subclass) &&
+ (DoIsolateDeviceCheck ?
+ (xf86IsolateDevice.bus == pcrp->busnum &&
+ xf86IsolateDevice.device == pcrp->devnum &&
+ xf86IsolateDevice.func == pcrp->funcnum) : 1)) {
+ num++;
+ xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo,
+ sizeof(pciVideoPtr) * (num + 1));
+ xf86PciVideoInfo[num] = NULL;
+ info = xf86PciVideoInfo[num - 1] = xnfalloc(sizeof(pciVideoRec));
+ info->validSize = FALSE;
+ info->vendor = pcrp->pci_vendor;
+ info->chipType = pcrp->pci_device;
+ info->chipRev = pcrp->pci_rev_id;
+ info->subsysVendor = pcrp->pci_subsys_vendor;
+ info->subsysCard = pcrp->pci_subsys_card;
+ info->bus = pcrp->busnum;
+ info->device = pcrp->devnum;
+ info->func = pcrp->funcnum;
+ info->class = baseclass;
+ info->subclass = pcrp->pci_sub_class;
+ info->interface = pcrp->pci_prog_if;
+ info->biosBase = PCIGETROM(pcrp->pci_baserom);
+ info->biosSize = pciGetBaseSize(pcrp->tag, 6, TRUE, NULL);
+ info->thisCard = pcrp;
+ info->validate = FALSE;
+#ifdef INCLUDE_XF86_NO_DOMAIN
+ if ((PCISHAREDIOCLASSES(baseclass, subclass))
+ && (pcrp->pci_command & PCI_CMD_IO_ENABLE) &&
+ (pcrp->pci_prog_if == 0)) {
+
+ /*
+ * Attempt to ensure that VGA is actually routed to this
+ * adapter on entry. This needs to be fixed when we finally
+ * grok host bridges (and multiple bus trees).
+ */
+ j = info->bus;
+ while (TRUE) {
+ PciBusPtr pBus = xf86PciBus;
+ while (pBus && j != pBus->secondary)
+ pBus = pBus->next;
+ if (!pBus || !(pBus->brcontrol & PCI_PCI_BRIDGE_VGA_EN))
+ break;
+ if (j == pBus->primary) {
+ if (primaryBus.type == BUS_NONE) {
+ /* assumption: primary adapter is always VGA */
+ primaryBus.type = BUS_PCI;
+ primaryBus.id.pci.bus = pcrp->busnum;
+ primaryBus.id.pci.device = pcrp->devnum;
+ primaryBus.id.pci.func = pcrp->funcnum;
+ } else if (primaryBus.type < BUS_last) {
+ xf86Msg(X_NOTICE,
+ "More than one primary device found\n");
+ primaryBus.type ^= (BusType)(-1);
+ }
+ break;
+ }
+ j = pBus->primary;
+ }
+ }
+#endif
+
+ for (j = 0; j < 6; j++) {
+ info->memBase[j] = 0;
+ info->ioBase[j] = 0;
+ if (PCINONSYSTEMCLASSES(baseclass, subclass)) {
+ info->size[j] =
+ pciGetBaseSize(pcrp->tag, j, TRUE, &info->validSize);
+ pcrp->minBasesize = info->validSize;
+ } else {
+ info->size[j] = pcrp->basesize[j];
+ info->validSize = pcrp->minBasesize;
+ }
+ info->type[j] = 0;
+ }
+
+ if (PCINONSYSTEMCLASSES(baseclass, subclass)) {
+ /*
+ * Check of a PCI base is unassigned. If so
+ * attempt to fix it. Validation will determine
+ * if the value was correct later on.
+ */
+ CARD32 *base = &pcrp->pci_base0;
+
+ for (j = 0; j < 6; j++) {
+ if (!PCI_MAP_IS64BITMEM(base[j])) {
+ if (info->size[j] && IsBaseUnassigned(base[j]))
+ base[j] = pciCheckForBrokenBase(pcrp->tag, j);
+ } else {
+ if (j == 5) /* bail out */
+ break;
+ if (info->size[j]
+ && IsBaseUnassigned64(base[j],base[j+1])) {
+ base[j] = pciCheckForBrokenBase(pcrp->tag, j);
+ j++;
+ base[j] = pciCheckForBrokenBase(pcrp->tag, j);
+ }
+ }
+ }
+ }
+
+ /*
+ * 64-bit base addresses are checked for and avoided on 32-bit
+ * platforms.
+ */
+ for (j = 0; j < 6; ++j) {
+ CARD32 bar = (&pcrp->pci_base0)[j];
+
+ if (bar != 0) {
+ if (bar & PCI_MAP_IO) {
+ info->ioBase[j] = (memType)PCIGETIO(bar);
+ info->type[j] = bar & PCI_MAP_IO_ATTR_MASK;
+ } else {
+ info->type[j] = bar & PCI_MAP_MEMORY_ATTR_MASK;
+ info->memBase[j] = (memType)PCIGETMEMORY(bar);
+ if (PCI_MAP_IS64BITMEM(bar)) {
+ if (j == 5) {
+ xf86MsgVerb(X_WARNING, 0,
+ "****BAR5 specified as 64-bit wide, "
+ "which is not possible. "
+ "Ignoring BAR5.****\n");
+ info->memBase[j] = 0;
+ } else {
+ CARD32 bar_hi = PCIGETMEMORY64HIGH((&pcrp->pci_base0)[j]);
+#if defined(LONG64) || defined(WORD64)
+ /* 64 bit architecture */
+ info->memBase[j] |=
+ (memType)bar_hi << 32;
+#else
+ if (bar_hi != 0)
+ info->memBase[j] = 0;
+#endif
+ ++j; /* Step over the next BAR */
+ }
+ }
+ }
+ }
+ }
+ info->listed_class = pcrp->listed_class;
+ }
+ i++;
+ }
+
+ /* If we haven't found a primary device try a different heuristic */
+ if (primaryBus.type == BUS_NONE && num) {
+ for (i = 0; i < num; i++) {
+ info = xf86PciVideoInfo[i];
+ pcrp = info->thisCard;
+
+ if ((pcrp->pci_command & PCI_CMD_MEM_ENABLE) &&
+ (num == 1 ||
+ ((info->class == PCI_CLASS_DISPLAY) &&
+ (info->subclass == PCI_SUBCLASS_DISPLAY_VGA)))) {
+ if (primaryBus.type == BUS_NONE) {
+ primaryBus.type = BUS_PCI;
+ primaryBus.id.pci.bus = pcrp->busnum;
+ primaryBus.id.pci.device = pcrp->devnum;
+ primaryBus.id.pci.func = pcrp->funcnum;
+ } else {
+ xf86Msg(X_NOTICE,
+ "More than one possible primary device found\n");
+ primaryBus.type ^= (BusType)(-1);
+ }
+ }
+ }
+ }
+
+ /* Print a summary of the video devices found */
+ for (k = 0; k < num; k++) {
+ const char *vendorname = NULL, *chipname = NULL;
+ const char *prim = " ";
+ char busnum[8];
+ Bool memdone = FALSE, iodone = FALSE;
+
+ i = 0;
+ info = xf86PciVideoInfo[k];
+ xf86FormatPciBusNumber(info->bus, busnum);
+ xf86FindPciNamesByDevice(info->vendor, info->chipType,
+ NOVENDOR, NOSUBSYS,
+ &vendorname, &chipname, NULL, NULL);
+ if ((!vendorname || !chipname) &&
+ !PCIALWAYSPRINTCLASSES(info->class, info->subclass))
+ continue;
+ if (xf86IsPrimaryPci(info))
+ prim = "*";
+
+ xf86Msg(X_PROBED, "PCI:%s(%s:%d:%d) ", prim, busnum, info->device,
+ info->func);
+ if (vendorname)
+ xf86ErrorF("%s ", vendorname);
+ else
+ xf86ErrorF("unknown vendor (0x%04x) ", info->vendor);
+ if (chipname)
+ xf86ErrorF("%s ", chipname);
+ else
+ xf86ErrorF("unknown chipset (0x%04x) ", info->chipType);
+ xf86ErrorF("rev %d", info->chipRev);
+ for (i = 0; i < 6; i++) {
+ if (info->memBase[i] &&
+ (info->memBase[i] < (memType)(-1 << info->size[i]))) {
+ if (!memdone) {
+ xf86ErrorF(", Mem @ ");
+ memdone = TRUE;
+ } else
+ xf86ErrorF(", ");
+ xf86ErrorF("0x%08lx/%d", info->memBase[i], info->size[i]);
+ }
+ }
+ for (i = 0; i < 6; i++) {
+ if (info->ioBase[i] &&
+ (info->ioBase[i] < (memType)(-1 << info->size[i]))) {
+ if (!iodone) {
+ xf86ErrorF(", I/O @ ");
+ iodone = TRUE;
+ } else
+ xf86ErrorF(", ");
+ xf86ErrorF("0x%04lx/%d", info->ioBase[i], info->size[i]);
+ }
+ }
+ if (info->biosBase &&
+ (info->biosBase < (memType)(-1 << info->biosSize)))
+ xf86ErrorF(", BIOS @ 0x%08lx/%d", info->biosBase, info->biosSize);
+ xf86ErrorF("\n");
+ }
+}
+
+/*
+ * fixPciSizeInfo() -- fix pci size info by testing it destructively
+ * (if not already done), fix pciVideoInfo and entry in the resource
+ * list.
+ */
+/*
+ * Note: once we have OS support to read the sizes GetBaseSize() will
+ * have to be wrapped by the OS layer. fixPciSizeInfo() should also
+ * be wrapped by the OS layer to do nothing if the size is always
+ * returned correctly by GetBaseSize(). It should however set validate
+ * in pciVideoRec if validation is required. ValidatePci() also needs
+ * to be wrapped by the OS layer. This may do nothing if the OS has
+ * already taken care of validation. fixPciResource() may be moved to
+ * OS layer with minimal changes. Once the wrapping layer is in place
+ * the common level and drivers should not reference these functions
+ * directly but thru the OS layer.
+ */
+
+static void
+fixPciSizeInfo(int entityIndex)
+{
+ pciVideoPtr pvp;
+ resPtr pAcc;
+ PCITAG tag;
+ int j;
+
+ if (! (pvp = xf86GetPciInfoForEntity(entityIndex))) return;
+ if (pvp->validSize) return;
+
+ tag = pciTag(pvp->bus,pvp->device,pvp->func);
+
+ for (j = 0; j < 6; j++) {
+ pAcc = Acc;
+ if (pvp->memBase[j])
+ while (pAcc) {
+ if (((pAcc->res_type & (ResPhysMask | ResBlock))
+ == (ResMem | ResBlock))
+ && (pAcc->block_begin == B2M(TAG(pvp),pvp->memBase[j]))
+ && (pAcc->block_end == B2M(TAG(pvp),pvp->memBase[j]
+ + SIZE(pvp->size[j])))) break;
+ pAcc = pAcc->next;
+ }
+ else if (pvp->ioBase[j])
+ while (pAcc) {
+ if (((pAcc->res_type & (ResPhysMask | ResBlock)) ==
+ (ResIo | ResBlock))
+ && (pAcc->block_begin == B2I(TAG(pvp),pvp->ioBase[j]))
+ && (pAcc->block_end == B2I(TAG(pvp),pvp->ioBase[j]
+ + SIZE(pvp->size[j])))) break;
+ pAcc = pAcc->next;
+ }
+ else continue;
+ pvp->size[j] = pciGetBaseSize(tag, j, TRUE, &pvp->validSize);
+ if (pAcc) {
+ pAcc->block_end = pvp->memBase[j] ?
+ B2M(TAG(pvp),pvp->memBase[j] + SIZE(pvp->size[j]))
+ : B2I(TAG(pvp),pvp->ioBase[j] + SIZE(pvp->size[j]));
+ pAcc->res_type &= ~ResEstimated;
+ pAcc->res_type |= ResBios;
+ }
+ }
+ if (pvp->biosBase) {
+ pAcc = Acc;
+ while (pAcc) {
+ if (((pAcc->res_type & (ResPhysMask | ResBlock)) ==
+ (ResMem | ResBlock))
+ && (pAcc->block_begin == B2M(TAG(pvp),pvp->biosBase))
+ && (pAcc->block_end == B2M(TAG(pvp),pvp->biosBase
+ + SIZE(pvp->biosSize)))) break;
+ pAcc = pAcc->next;
+ }
+ pvp->biosSize = pciGetBaseSize(tag, 6, TRUE, &pvp->validSize);
+ if (pAcc) {
+ pAcc->block_end = B2M(TAG(pvp),pvp->biosBase+SIZE(pvp->biosSize));
+ pAcc->res_type &= ~ResEstimated;
+ pAcc->res_type |= ResBios;
+ }
+ }
+}
+
+/*
+ * IO enable/disable related routines for PCI
+ */
+#define pArg ((pciArg*)arg)
+#define SETBITS PCI_CMD_IO_ENABLE
+static void
+pciIoAccessEnable(void* arg)
+{
+#ifdef DEBUG
+ ErrorF("pciIoAccessEnable: 0x%05lx\n", *(PCITAG *)arg);
+#endif
+ pArg->ctrl |= SETBITS | PCI_CMD_MASTER_ENABLE;
+ pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl);
+}
+
+static void
+pciIoAccessDisable(void* arg)
+{
+#ifdef DEBUG
+ ErrorF("pciIoAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
+#endif
+ pArg->ctrl &= ~SETBITS;
+ pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl);
+}
+
+#undef SETBITS
+#define SETBITS (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE)
+static void
+pciIo_MemAccessEnable(void* arg)
+{
+#ifdef DEBUG
+ ErrorF("pciIo_MemAccessEnable: 0x%05lx\n", *(PCITAG *)arg);
+#endif
+ pArg->ctrl |= SETBITS | PCI_CMD_MASTER_ENABLE;
+ pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl);
+}
+
+static void
+pciIo_MemAccessDisable(void* arg)
+{
+#ifdef DEBUG
+ ErrorF("pciIo_MemAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
+#endif
+ pArg->ctrl &= ~SETBITS;
+ pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl);
+}
+
+#undef SETBITS
+#define SETBITS (PCI_CMD_MEM_ENABLE)
+static void
+pciMemAccessEnable(void* arg)
+{
+#ifdef DEBUG
+ ErrorF("pciMemAccessEnable: 0x%05lx\n", *(PCITAG *)arg);
+#endif
+ pArg->ctrl |= SETBITS | PCI_CMD_MASTER_ENABLE;
+ pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl);
+}
+
+static void
+pciMemAccessDisable(void* arg)
+{
+#ifdef DEBUG
+ ErrorF("pciMemAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
+#endif
+ pArg->ctrl &= ~SETBITS;
+ pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl);
+}
+#undef SETBITS
+#undef pArg
+
+
+/* move to OS layer */
+#define MASKBITS (PCI_PCI_BRIDGE_VGA_EN | PCI_PCI_BRIDGE_MASTER_ABORT_EN)
+static void
+pciBusAccessEnable(BusAccPtr ptr)
+{
+ PCITAG tag = ptr->busdep.pci.acc;
+ CARD16 ctrl;
+
+#ifdef DEBUG
+ ErrorF("pciBusAccessEnable: bus=%d\n", ptr->busdep.pci.bus);
+#endif
+ ctrl = pciReadWord(tag, PCI_PCI_BRIDGE_CONTROL_REG);
+ if ((ctrl & MASKBITS) != PCI_PCI_BRIDGE_VGA_EN) {
+ ctrl = (ctrl | PCI_PCI_BRIDGE_VGA_EN) &
+ ~(PCI_PCI_BRIDGE_MASTER_ABORT_EN | PCI_PCI_BRIDGE_SECONDARY_RESET);
+ pciWriteWord(tag, PCI_PCI_BRIDGE_CONTROL_REG, ctrl);
+ }
+}
+
+/* move to OS layer */
+static void
+pciBusAccessDisable(BusAccPtr ptr)
+{
+ PCITAG tag = ptr->busdep.pci.acc;
+ CARD16 ctrl;
+
+#ifdef DEBUG
+ ErrorF("pciBusAccessDisable: bus=%d\n", ptr->busdep.pci.bus);
+#endif
+ ctrl = pciReadWord(tag, PCI_PCI_BRIDGE_CONTROL_REG);
+ if (ctrl & MASKBITS) {
+ ctrl &= ~(MASKBITS | PCI_PCI_BRIDGE_SECONDARY_RESET);
+ pciWriteWord(tag, PCI_PCI_BRIDGE_CONTROL_REG, ctrl);
+ }
+}
+#undef MASKBITS
+
+/* move to OS layer */
+static void
+pciDrvBusAccessEnable(BusAccPtr ptr)
+{
+ int bus = ptr->busdep.pci.bus;
+
+#ifdef DEBUG
+ ErrorF("pciDrvBusAccessEnable: bus=%d\n", bus);
+#endif
+ (*pciBusInfo[bus]->funcs->pciControlBridge)(bus,
+ PCI_PCI_BRIDGE_VGA_EN,
+ PCI_PCI_BRIDGE_VGA_EN);
+}
+
+/* move to OS layer */
+static void
+pciDrvBusAccessDisable(BusAccPtr ptr)
+{
+ int bus = ptr->busdep.pci.bus;
+
+#ifdef DEBUG
+ ErrorF("pciDrvBusAccessDisable: bus=%d\n", bus);
+#endif
+ (*pciBusInfo[bus]->funcs->pciControlBridge)(bus,
+ PCI_PCI_BRIDGE_VGA_EN, 0);
+}
+
+
+static void
+pciSetBusAccess(BusAccPtr ptr)
+{
+#ifdef DEBUG
+ ErrorF("pciSetBusAccess: route VGA to bus %d\n", ptr->busdep.pci.bus);
+#endif
+
+ if (!ptr->primary && !ptr->current)
+ return;
+
+ if (ptr->current && ptr->current->disable_f)
+ (*ptr->current->disable_f)(ptr->current);
+ ptr->current = NULL;
+
+ /* walk down */
+ while (ptr->primary) { /* No enable for root bus */
+ if (ptr != ptr->primary->current) {
+ if (ptr->primary->current && ptr->primary->current->disable_f)
+ (*ptr->primary->current->disable_f)(ptr->primary->current);
+ if (ptr->enable_f)
+ (*ptr->enable_f)(ptr);
+ ptr->primary->current = ptr;
+ }
+ ptr = ptr->primary;
+ }
+}
+
+/* move to OS layer */
+static void
+savePciState(PCITAG tag, pciSavePtr ptr)
+{
+ int i;
+
+ ptr->command = pciReadLong(tag, PCI_CMD_STAT_REG);
+ for (i=0; i < 6; i++)
+ ptr->base[i] = pciReadLong(tag, PCI_CMD_BASE_REG + i*4);
+ ptr->biosBase = pciReadLong(tag, PCI_CMD_BIOS_REG);
+}
+
+/* move to OS layer */
+static void
+restorePciState(PCITAG tag, pciSavePtr ptr)
+{
+ int i;
+
+ /* disable card before setting anything */
+ pciSetBitsLong(tag, PCI_CMD_STAT_REG,
+ PCI_CMD_MEM_ENABLE | PCI_CMD_IO_ENABLE , 0);
+ pciWriteLong(tag,PCI_CMD_BIOS_REG, ptr->biosBase);
+ for (i=0; i<6; i++)
+ pciWriteLong(tag, PCI_CMD_BASE_REG + i*4, ptr->base[i]);
+ pciWriteLong(tag, PCI_CMD_STAT_REG, ptr->command);
+}
+
+/* move to OS layer */
+static void
+savePciBusState(BusAccPtr ptr)
+{
+ PCITAG tag = ptr->busdep.pci.acc;
+
+ ptr->busdep.pci.save.control =
+ pciReadWord(tag, PCI_PCI_BRIDGE_CONTROL_REG) &
+ ~PCI_PCI_BRIDGE_SECONDARY_RESET;
+ /* Allow master aborts to complete normally on non-root buses */
+ if (ptr->busdep.pci.save.control & PCI_PCI_BRIDGE_MASTER_ABORT_EN)
+ pciWriteWord(tag, PCI_PCI_BRIDGE_CONTROL_REG,
+ ptr->busdep.pci.save.control & ~PCI_PCI_BRIDGE_MASTER_ABORT_EN);
+}
+
+/* move to OS layer */
+#define MASKBITS (PCI_PCI_BRIDGE_VGA_EN | PCI_PCI_BRIDGE_MASTER_ABORT_EN)
+static void
+restorePciBusState(BusAccPtr ptr)
+{
+ PCITAG tag = ptr->busdep.pci.acc;
+ CARD16 ctrl;
+
+ /* Only restore the bits we've changed (and don't cause resets) */
+ ctrl = pciReadWord(tag, PCI_PCI_BRIDGE_CONTROL_REG);
+ if ((ctrl ^ ptr->busdep.pci.save.control) & MASKBITS) {
+ ctrl &= ~(MASKBITS | PCI_PCI_BRIDGE_SECONDARY_RESET);
+ ctrl |= ptr->busdep.pci.save.control & MASKBITS;
+ pciWriteWord(tag, PCI_PCI_BRIDGE_CONTROL_REG, ctrl);
+ }
+}
+#undef MASKBITS
+
+/* move to OS layer */
+static void
+savePciDrvBusState(BusAccPtr ptr)
+{
+ int bus = ptr->busdep.pci.bus;
+
+ ptr->busdep.pci.save.control =
+ (*pciBusInfo[bus]->funcs->pciControlBridge)(bus, 0, 0);
+ /* Allow master aborts to complete normally on this bus */
+ (*pciBusInfo[bus]->funcs->pciControlBridge)(bus,
+ PCI_PCI_BRIDGE_MASTER_ABORT_EN,
+ 0);
+}
+
+/* move to OS layer */
+static void
+restorePciDrvBusState(BusAccPtr ptr)
+{
+ int bus = ptr->busdep.pci.bus;
+
+ (*pciBusInfo[bus]->funcs->pciControlBridge)(bus, (CARD16)(-1),
+ ptr->busdep.pci.save.control);
+}
+
+
+static void
+disablePciBios(PCITAG tag)
+{
+ pciSetBitsLong(tag, PCI_CMD_BIOS_REG, PCI_CMD_BIOS_ENABLE, 0);
+}
+
+/* ????? */
+static void
+correctPciSize(memType base, memType oldsize, memType newsize,
+ unsigned long type)
+{
+ pciConfigPtr pcrp, *pcrpp;
+ pciVideoPtr pvp, *pvpp;
+ CARD32 *basep;
+ int i;
+ int old_bits = 0, new_bits = 0;
+
+ if (oldsize + 1) while (oldsize & 1) {
+ old_bits ++;
+ oldsize >>= 1;
+ }
+ if (newsize + 1) while (newsize & 1) {
+ new_bits ++;
+ newsize >>= 1;
+ }
+
+ for (pcrpp = xf86PciInfo, pcrp = *pcrpp; pcrp; pcrp = *++(pcrpp)) {
+
+ /* Only process devices with type 0 headers */
+ if ((pcrp->pci_header_type & 0x7f) != 0)
+ continue;
+
+ basep = &pcrp->pci_base0;
+ for (i = 0; i < 6; i++) {
+ if (basep[i] && (pcrp->basesize[i] == old_bits)) {
+ if ((((type & ResPhysMask) == ResIo) &&
+ PCI_MAP_IS_IO(basep[i]) &&
+ B2I(pcrp->tag,PCIGETIO(basep[i]) == base)) ||
+ (((type & ResPhysMask) == ResMem) &&
+ PCI_MAP_IS_MEM(basep[i]) &&
+ (((!PCI_MAP_IS64BITMEM(basep[i])) &&
+ (B2M(pcrp->tag,PCIGETMEMORY(basep[i])) == base))
+#if defined(LONG64) || defined(WORD64)
+ ||
+ (B2M(pcrp->tag,PCIGETMEMORY64(basep[i])) == base)
+#else
+ ||
+ (!basep[i+1]
+ && (B2M(pcrp->tag,PCIGETMEMORY(basep[i])) == base))
+#endif
+ ))) {
+ pcrp->basesize[i] = new_bits;
+ break; /* to next device */
+ }
+ }
+ if (PCI_MAP_IS64BITMEM(basep[i])) i++;
+ }
+ }
+
+ if (xf86PciVideoInfo) {
+ for (pvpp = xf86PciVideoInfo, pvp = *pvpp; pvp; pvp = *(++pvpp)) {
+
+ for (i = 0; i < 6; i++) {
+ if (pvp->size[i] == old_bits) {
+ if ((((type & ResPhysMask) == ResIo) && pvp->ioBase[i]
+ && (B2I(TAG(pvp),pvp->ioBase[i]) == base)) ||
+ (((type & ResPhysMask) == ResMem) && pvp->memBase[i]
+ && (B2M(TAG(pvp),pvp->memBase[i]) == base))) {
+ pvp->size[i] = new_bits;
+ break; /* to next device */
+ }
+ }
+ }
+ }
+ }
+}
+
+/* ????? */
+static void
+removeOverlapsWithBridges(int busIndex, resPtr target)
+{
+ PciBusPtr pbp;
+ resPtr tmp,bridgeRes = NULL;
+ resRange range;
+
+ if (!target)
+ return;
+
+ if (!ResCanOverlap(&target->val))
+ return;
+
+ range = target->val;
+
+ for (pbp=xf86PciBus; pbp; pbp = pbp->next) {
+ if (pbp->primary == busIndex) {
+ tmp = xf86DupResList(pbp->preferred_io);
+ bridgeRes = xf86JoinResLists(tmp,bridgeRes);
+ tmp = xf86DupResList(pbp->preferred_mem);
+ bridgeRes = xf86JoinResLists(tmp,bridgeRes);
+ tmp = xf86DupResList(pbp->preferred_pmem);
+ bridgeRes = xf86JoinResLists(tmp,bridgeRes);
+ }
+ }
+
+ RemoveOverlaps(target, bridgeRes, TRUE, TRUE);
+ if (range.rEnd > target->block_end) {
+ correctPciSize(range.rBegin, range.rEnd - range.rBegin,
+ target->block_end - target->block_begin,
+ target->res_type);
+ xf86MsgVerb(X_INFO, 3,
+ "PCI %s resource overlap reduced 0x%08lx from 0x%08lx to 0x%08lx\n",
+ ((target->res_type & ResPhysMask) == ResMem) ? "Memory" : "I/O",
+ range.rBegin, range.rEnd, target->block_end);
+ }
+ xf86FreeResList(bridgeRes);
+}
+
+/* ????? */
+static void
+xf86GetPciRes(resPtr *activeRes, resPtr *inactiveRes)
+{
+ pciConfigPtr pcrp, *pcrpp;
+ pciVideoPtr pvp, *pvpp;
+ CARD32 *basep;
+ int i;
+ resPtr pRes, tmp;
+ resRange range;
+ long resMisc;
+
+ if (activeRes)
+ *activeRes = NULL;
+ if (inactiveRes)
+ *inactiveRes = NULL;
+
+ if (!activeRes || !inactiveRes || !xf86PciInfo)
+ return;
+
+ if (xf86PciVideoInfo)
+ for (pvpp = xf86PciVideoInfo, pvp = *pvpp; pvp; pvp = *(++pvpp)) {
+ resPtr *res;
+
+ if (PCINONSYSTEMCLASSES(pvp->class, pvp->subclass))
+ resMisc = ResBios;
+ else
+ resMisc = 0;
+
+ if (((pciConfigPtr)pvp->thisCard)->pci_command
+ & (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE))
+ res = activeRes;
+ else
+ res = inactiveRes;
+
+ if (!pvp->validSize)
+ resMisc |= ResEstimated;
+
+ for (i = 0; i < 6; i++) {
+ if (pvp->ioBase[i] &&
+ (pvp->ioBase[i] < (memType)(-1 << pvp->size[i]))) {
+ PV_I_RANGE(range,pvp,i,ResExcIoBlock | resMisc);
+ tmp = xf86AddResToList(NULL, &range, -1);
+ removeOverlapsWithBridges(pvp->bus,tmp);
+ *res = xf86JoinResLists(tmp,*res);
+ } else if (pvp->memBase[i] &&
+ (pvp->memBase[i] < (memType)(-1 << pvp->size[i]))) {
+ PV_M_RANGE(range, pvp,i, ResExcMemBlock | resMisc);
+ tmp = xf86AddResToList(NULL, &range, -1);
+ removeOverlapsWithBridges(pvp->bus,tmp);
+ *res = xf86JoinResLists(tmp,*res);
+ }
+ }
+ /* FIXME!!!: Don't use BIOS resources for overlap
+ * checking but reserve them!
+ */
+ if (pvp->biosBase &&
+ (pvp->biosBase < (memType)(-1 << pvp->biosSize))) {
+ PV_B_RANGE(range, pvp, ResExcMemBlock | resMisc);
+ tmp = xf86AddResToList(NULL, &range, -1);
+ removeOverlapsWithBridges(pvp->bus,tmp);
+ *res = xf86JoinResLists(tmp,*res);
+ }
+ }
+
+ for (pcrpp = xf86PciInfo, pcrp = *pcrpp; pcrp; pcrp = *++(pcrpp)) {
+ resPtr *res;
+ CARD8 baseclass, subclass;
+
+ if (pcrp->listed_class & 0x0ffff) {
+ baseclass = pcrp->listed_class >> 8;
+ subclass = pcrp->listed_class;
+ } else {
+ baseclass = pcrp->pci_base_class;
+ subclass = pcrp->pci_sub_class;
+ }
+
+ if (PCIINFOCLASSES(baseclass, subclass))
+ continue;
+
+ /* Only process devices with type 0 headers */
+ if ((pcrp->pci_header_type & 0x7f) != 0)
+ continue;
+
+ if (!pcrp->minBasesize)
+ resMisc = ResEstimated;
+ else
+ resMisc = 0;
+
+ /*
+ * Allow resources allocated to host bridges to overlap. Perhaps, this
+ * needs to be specific to AGP-capable chipsets. AGP "memory"
+ * sometimes gets allocated within the range routed to the AGP bus.
+ */
+ if ((baseclass == PCI_CLASS_BRIDGE) &&
+ (subclass == PCI_SUBCLASS_BRIDGE_HOST))
+ resMisc |= ResOverlap;
+
+ basep = &pcrp->pci_base0;
+ for (i = 0; i < 6; i++) {
+ if (basep[i]) {
+ if (PCI_MAP_IS_IO(basep[i])) {
+ if (pcrp->pci_command & PCI_CMD_IO_ENABLE)
+ res = activeRes;
+ else
+ res = inactiveRes;
+ P_I_RANGE(range, pcrp->tag, PCIGETIO(basep[i]),
+ pcrp->basesize[i], ResExcIoBlock | resMisc)
+ } else if (!PCI_MAP_IS64BITMEM(basep[i])) {
+ if (pcrp->pci_command & PCI_CMD_MEM_ENABLE)
+ res = activeRes;
+ else
+ res = inactiveRes;
+ P_M_RANGE(range, pcrp->tag, PCIGETMEMORY(basep[i]),
+ pcrp->basesize[i], ResExcMemBlock | resMisc)
+ } else {
+ i++;
+#if defined(LONG64) || defined(WORD64)
+ P_M_RANGE(range,pcrp->tag,PCIGETMEMORY64(basep[i - 1]),
+ pcrp->basesize[i - 1], ResExcMemBlock | resMisc)
+#else
+ if (basep[i])
+ continue;
+ P_M_RANGE(range, pcrp->tag, PCIGETMEMORY(basep[i - 1]),
+ pcrp->basesize[i - 1], ResExcMemBlock | resMisc)
+#endif
+ if (pcrp->pci_command & PCI_CMD_MEM_ENABLE)
+ res = activeRes;
+ else
+ res = inactiveRes;
+ }
+ if (range.rBegin) { /* catch cases where PCI base is unset */
+ tmp = xf86AddResToList(NULL, &range, -1);
+ removeOverlapsWithBridges(pcrp->busnum,tmp);
+ *res = xf86JoinResLists(tmp,*res);
+ }
+ }
+ }
+
+ /* Ignore disabled non-video ROMs */
+ if ((pcrp->pci_command & PCI_CMD_MEM_ENABLE) &&
+ (pcrp->pci_baserom & PCI_MAP_ROM_DECODE_ENABLE)) {
+ P_M_RANGE(range,pcrp->tag,PCIGETROM(pcrp->pci_baserom),
+ pcrp->basesize[6], ResExcMemBlock | resMisc);
+ if (range.rBegin) {
+ tmp = xf86AddResToList(NULL, &range, -1);
+ removeOverlapsWithBridges(pcrp->busnum, tmp);
+ *activeRes = xf86JoinResLists(tmp, *activeRes);
+ }
+ }
+ }
+
+ if (*activeRes) {
+ xf86MsgVerb(X_INFO, 3, "Active PCI resource ranges:\n");
+ xf86PrintResList(3, *activeRes);
+ }
+ if (*inactiveRes) {
+ xf86MsgVerb(X_INFO, 3, "Inactive PCI resource ranges:\n");
+ xf86PrintResList(3, *inactiveRes);
+ }
+
+ /*
+ * Adjust ranges based on the assumption that there are no real
+ * overlaps in the PCI base allocations. This assumption should be
+ * reasonable in most cases. It may be possible to refine the
+ * approximated PCI base sizes by considering bus mapping information
+ * from PCI-PCI bridges.
+ */
+
+ if (*activeRes) {
+ /* Check for overlaps */
+ for (pRes = *activeRes; pRes; pRes = pRes->next) {
+ if (ResCanOverlap(&pRes->val)) {
+ range = pRes->val;
+
+ RemoveOverlaps(pRes, *activeRes, TRUE, TRUE);
+ RemoveOverlaps(pRes, *inactiveRes, TRUE,
+ (xf86Info.estimateSizesAggressively > 0));
+
+ if (range.rEnd > pRes->block_end) {
+ correctPciSize(range.rBegin, range.rEnd - range.rBegin,
+ pRes->block_end - pRes->block_begin,
+ pRes->res_type);
+ xf86MsgVerb(X_INFO, 3,
+ "PCI %s resource overlap reduced 0x%08lx"
+ " from 0x%08lx to 0x%08lx\n",
+ ((pRes->res_type & ResPhysMask) == ResMem) ?
+ "Memory" : "I/O",
+ range.rBegin, range.rEnd, pRes->block_end);
+ }
+ }
+ }
+ xf86MsgVerb(X_INFO, 3,
+ "Active PCI resource ranges after removing overlaps:\n");
+ xf86PrintResList(3, *activeRes);
+ }
+
+ if (*inactiveRes) {
+ /* Check for overlaps */
+ for (pRes = *inactiveRes; pRes; pRes = pRes->next) {
+ if (ResCanOverlap(&pRes->val)) {
+ range = pRes->val;
+
+ RemoveOverlaps(pRes, *activeRes, TRUE,
+ (xf86Info.estimateSizesAggressively > 1));
+ RemoveOverlaps(pRes, *inactiveRes, TRUE,
+ (xf86Info.estimateSizesAggressively > 1));
+
+ if (range.rEnd > pRes->block_end) {
+ correctPciSize(range.rBegin, range.rEnd - range.rBegin,
+ pRes->block_end - pRes->block_begin,
+ pRes->res_type);
+ xf86MsgVerb(X_INFO, 3,
+ "PCI %s resource overlap reduced 0x%08lx"
+ " from 0x%08lx to 0x%08lx\n",
+ ((pRes->res_type & ResPhysMask) == ResMem) ?
+ "Memory" : "I/O",
+ range.rBegin, range.rEnd, pRes->block_end);
+ }
+
+ }
+ }
+ xf86MsgVerb(X_INFO, 3,
+ "Inactive PCI resource ranges after removing overlaps:\n");
+ xf86PrintResList(3, *inactiveRes);
+ }
+}
+
+resPtr
+ResourceBrokerInitPci(resPtr *osRes)
+{
+ resPtr activeRes, inactiveRes;
+ resPtr tmp;
+
+ /* Get bus-specific system resources (PCI) */
+ xf86GetPciRes(&activeRes, &inactiveRes);
+
+ /*
+ * Adjust OS-reported resource ranges based on the assumption that there
+ * are no overlaps with the PCI base allocations. This should be a good
+ * assumption because writes to PCI address space won't be routed directly
+ * to host memory.
+ */
+
+ for (tmp = *osRes; tmp; tmp = tmp->next)
+ RemoveOverlaps(tmp, activeRes, FALSE, TRUE);
+
+ xf86MsgVerb(X_INFO, 3, "OS-reported resource ranges after removing"
+ " overlaps with PCI:\n");
+ xf86PrintResList(3, *osRes);
+
+ pciAvoidRes = xf86AddRangesToList(pciAvoidRes,PciAvoid,-1);
+ for (tmp = pciAvoidRes; tmp; tmp = tmp->next)
+ RemoveOverlaps(tmp, activeRes, FALSE, TRUE);
+ tmp = xf86DupResList(*osRes);
+ pciAvoidRes = xf86JoinResLists(pciAvoidRes,tmp);
+
+ return (xf86JoinResLists(activeRes,inactiveRes));
+}
+
+
+/*
+ * PCI Resource modification
+ */
+static Bool
+fixPciResource(int prt, memType alignment, pciVideoPtr pvp, unsigned long type)
+{
+ int res_n;
+ memType *p_base;
+ int *p_size;
+ unsigned char p_type;
+ resPtr AccTmp = NULL;
+ resPtr orgAcc = NULL;
+ resPtr *pAcc = &AccTmp;
+ resPtr avoid = NULL;
+ resRange range;
+ resPtr resSize = NULL;
+ resPtr w_tmp, w = NULL, w_2nd = NULL;
+ PCITAG tag;
+ PciBusPtr pbp = xf86PciBus;
+ pciConfigPtr pcp;
+ resPtr tmp;
+
+ if (!pvp) return FALSE;
+ tag = pciTag(pvp->bus,pvp->device,pvp->func);
+ pcp = pvp->thisCard;
+
+ type &= ResAccMask;
+ if (!type) type = ResShared;
+ if (prt < 6) {
+ if (pvp->memBase[prt]) {
+ type |= ResMem;
+ res_n = prt;
+ p_base = &(pvp->memBase[res_n]);
+ p_size = &(pvp->size[res_n]);
+ p_type = pvp->type[res_n];
+ if (!PCI_MAP_IS64BITMEM(pvp->type[res_n])) {
+ PCI_M_RANGE(range,tag,0,0xffffffff,ResExcMemBlock);
+ resSize = xf86AddResToList(resSize,&range,-1);
+ }
+ } else if (pvp->ioBase[prt]){
+ type |= ResIo;
+ res_n = prt;
+ p_base = &(pvp->ioBase[res_n]);
+ p_size = &(pvp->size[res_n]);
+ p_type = pvp->type[res_n];
+ PCI_I_RANGE(range, tag, 0, 0xffffffff, ResExcIoBlock);
+ resSize = xf86AddResToList(resSize, &range, -1);
+ } else return FALSE;
+ } else if (prt == 6) {
+ type |= ResMem;
+ res_n = 0xff; /* special flag for bios rom */
+ p_base = &(pvp->biosBase);
+ p_size = &(pvp->biosSize);
+ /* XXX This should also include the PCI_MAP_MEMORY_TYPE_MASK part */
+ p_type = 0;
+ PCI_M_RANGE(range,tag,0,0xffffffff,ResExcMemBlock);
+ resSize = xf86AddResToList(resSize,&range,-1);
+ } else return FALSE;
+
+ if (! *p_base) return FALSE;
+
+ type |= (range.type & ResDomain) | ResBlock;
+
+ /* setup avoid: PciAvoid is bus range: convert later */
+ avoid = xf86DupResList(pciAvoidRes);
+
+ while (pbp) {
+ if (pbp->secondary == pvp->bus) {
+ if ((type & ResPhysMask) == ResMem) {
+ if (((p_type & PCI_MAP_MEMORY_CACHABLE)
+#if 0 /*EE*/
+ || (res_n == 0xff)/* bios should also be prefetchable */
+#endif
+ )) {
+ if (pbp->preferred_pmem)
+ w = xf86FindIntersectOfLists(pbp->preferred_pmem,
+ ResRange);
+ else if (pbp->pmem)
+ w = xf86FindIntersectOfLists(pbp->pmem,ResRange);
+
+ if (pbp->preferred_mem)
+ w_2nd = xf86FindIntersectOfLists(pbp->preferred_mem,
+ ResRange);
+ else if (pbp->mem)
+ w_2nd = xf86FindIntersectOfLists(pbp->mem,
+ ResRange);
+ } else {
+ if (pbp->preferred_mem)
+ w = xf86FindIntersectOfLists(pbp->preferred_mem,
+ ResRange);
+ else if (pbp->mem)
+ w = xf86FindIntersectOfLists(pbp->mem,ResRange);
+ }
+ } else {
+ if (pbp->preferred_io)
+ w = xf86FindIntersectOfLists(pbp->preferred_io,ResRange);
+ if (pbp->io)
+ w = xf86FindIntersectOfLists(pbp->io,ResRange);
+ }
+ } else if (pbp->primary == pvp->bus) {
+ if ((type & ResPhysMask) == ResMem) {
+ tmp = xf86DupResList(pbp->preferred_pmem);
+ avoid = xf86JoinResLists(avoid, tmp);
+ tmp = xf86DupResList(pbp->preferred_mem);
+ avoid = xf86JoinResLists(avoid, tmp);
+ } else {
+ tmp = xf86DupResList(pbp->preferred_io);
+ avoid = xf86JoinResLists(avoid, tmp);
+ }
+ }
+ pbp = pbp->next;
+ }
+
+ /* convert bus based entries in avoid list to host base */
+ pciConvertListToHost(pvp->bus,pvp->device,pvp->func, avoid);
+
+ if (!w)
+ w = xf86DupResList(ResRange);
+ xf86MsgVerb(X_INFO, 3, "window:\n");
+ xf86PrintResList(3, w);
+ xf86MsgVerb(X_INFO, 3, "resSize:\n");
+ xf86PrintResList(3, resSize);
+
+ if (resSize) {
+ w_tmp = w;
+ w = xf86FindIntersectOfLists(w,resSize);
+ xf86FreeResList(w_tmp);
+ if (w_2nd) {
+ w_tmp = w_2nd;
+ w_2nd = xf86FindIntersectOfLists(w_2nd,resSize);
+ xf86FreeResList(w_tmp);
+ }
+ xf86FreeResList(resSize);
+ }
+ xf86MsgVerb(X_INFO, 3, "window fixed:\n");
+ xf86PrintResList(3, w);
+
+ if (!alignment)
+ alignment = (1 << (*p_size)) - 1;
+
+ /* Access list holds bios resources -- remove this one */
+#ifdef NOTYET
+ AccTmp = xf86DupResList(Acc);
+ while ((*pAcc)) {
+ if ((((*pAcc)->res_type & (type & ~ResAccMask))
+ == (type & ~ResAccMask))
+ && ((*pAcc)->block_begin == (B2H(tag,(*p_base),type)))
+ && ((*pAcc)->block_end == (B2H(tag,
+ (*p_base)+SIZE(*p_size),type)))) {
+ resPtr acc_tmp = (*pAcc)->next;
+ xfree((*pAcc));
+ (*pAcc) = acc_tmp;
+ break;
+ } else
+ pAcc = &((*pAcc)->next);
+ }
+ /* check if we really need to fix anything */
+ P_X_RANGE(range,tag,(*p_base),(*p_base) + SIZE((*p_size)),type);
+ if (!ChkConflict(&range,avoid,SETUP)
+ && !ChkConflict(&range,AccTmp,SETUP)
+ && ((B2H(tag,(*p_base),type) & PCI_SIZE(type,tag,alignment)
+ == range->block_begin)
+ && ((xf86IsSubsetOf(range,w)
+ || (w_2nd && xf86IsSubsetOf(range,w_2n))))) {
+#ifdef DEBUG
+ ErrorF("nothing to fix\n");
+#endif
+ xf86FreeResList(AccTmp);
+ xf86FreeResList(w);
+ xf86FreeResList(w_2nd);
+ xf86FreeResList(avoid);
+ return TRUE;
+ }
+#ifdef DEBUG
+ ErrorF("removing old resource\n");
+#endif
+ orgAcc = Acc;
+ Acc = AccTmp;
+#else
+ orgAcc = xf86DupResList(Acc);
+ pAcc = &Acc;
+ while (*pAcc) {
+ if ((((*pAcc)->res_type & (ResTypeMask|ResExtMask)) ==
+ (type & ~ResAccMask))
+ && ((*pAcc)->block_begin == B2H(tag,(*p_base),type))
+ && ((*pAcc)->block_end == B2H(tag,(*p_base) + SIZE(*p_size),
+ type))) {
+#ifdef DEBUG
+ ErrorF("removing old resource\n");
+#endif
+ tmp = *pAcc;
+ *pAcc = (*pAcc)->next;
+ tmp->next = NULL;
+ xf86FreeResList(tmp);
+ break;
+ } else
+ pAcc = &((*pAcc)->next);
+ }
+#endif
+
+#ifdef DEBUG
+ ErrorF("base: 0x%lx alignment: 0x%lx host alignment: 0x%lx size[bit]: 0x%x\n",
+ (*p_base),alignment,PCI_SIZE(type,tag,alignment),(*p_size));
+ xf86MsgVerb(X_INFO, 3, "window:\n");
+ xf86PrintResList(3, w);
+ if (w_2nd)
+ xf86MsgVerb(X_INFO, 3, "2nd window:\n");
+ xf86PrintResList(3, w_2nd);
+ xf86ErrorFVerb(3,"avoid:\n");
+ xf86PrintResList(3,avoid);
+#endif
+ w_tmp = w;
+ while (w) {
+ if ((type & ResTypeMask) == (w->res_type & ResTypeMask)) {
+#ifdef DEBUG
+ ErrorF("block_begin: 0x%lx block_end: 0x%lx\n",w->block_begin,
+ w->block_end);
+#endif
+ range = xf86GetBlock(type,PCI_SIZE(type,tag,alignment + 1),
+ w->block_begin, w->block_end,
+ PCI_SIZE(type,tag,alignment),avoid);
+ if (range.type != ResEnd)
+ break;
+ }
+ w = w->next;
+ }
+ xf86FreeResList(w_tmp);
+ /* if unsuccessful and memory prefetchable try non-prefetchable */
+ if (range.type == ResEnd && w_2nd) {
+ w_tmp = w_2nd;
+ while (w_2nd) {
+ if ((type & ResTypeMask) == (w_2nd->res_type & ResTypeMask)) {
+#ifdef DEBUG
+ ErrorF("block_begin: 0x%lx block_end: 0x%lx\n",w_2nd->block_begin,
+ w_2nd->block_end);
+#endif
+ range = xf86GetBlock(type,PCI_SIZE(type,tag,alignment + 1),
+ w_2nd->block_begin, w_2nd->block_end,
+ PCI_SIZE(type,tag,alignment),avoid);
+ if (range.type != ResEnd)
+ break;
+ }
+ w_2nd = w_2nd->next;
+ }
+ xf86FreeResList(w_tmp);
+ }
+ xf86FreeResList(avoid);
+
+ if (range.type == ResEnd) {
+ xf86MsgVerb(X_ERROR,3,"Cannot find a replacement memory range\n");
+ xf86FreeResList(Acc);
+ Acc = orgAcc;
+ return FALSE;
+ }
+ xf86FreeResList(orgAcc);
+#ifdef DEBUG
+ ErrorF("begin: 0x%lx, end: 0x%lx\n",range.a,range.b);
+#endif
+
+ (*p_size) = 0;
+ while (alignment >> (*p_size))
+ (*p_size)++;
+ (*p_base) = H2B(tag,range.rBegin,type);
+#ifdef DEBUG
+ ErrorF("New PCI res %i base: 0x%lx, size: 0x%lx, type %s\n",
+ res_n,(*p_base),(1 << (*p_size)),
+ ((type & ResPhysMask) == ResMem) ? "Mem" : "Io");
+#endif
+ if (res_n != 0xff) {
+ if ((type & ResPhysMask) == ResMem)
+ pvp->memBase[prt] = range.rBegin;
+ else
+ pvp->ioBase[prt] = range.rBegin;
+ ((CARD32 *)(&(pcp->pci_base0)))[res_n] =
+ (CARD32)(*p_base) | (CARD32)(p_type);
+ pciWriteLong(tag, PCI_CMD_BASE_REG + res_n * sizeof(CARD32),
+ ((CARD32 *)(&(pcp->pci_base0)))[res_n]);
+ if (PCI_MAP_IS64BITMEM(p_type)) {
+#if defined(LONG64) || defined(WORD64)
+ ((CARD32 *)(&(pcp->pci_base0)))[res_n + 1] =
+ (CARD32)(*p_base >> 32);
+ pciWriteLong(tag, PCI_CMD_BASE_REG + (res_n + 1) * sizeof(CARD32),
+ ((CARD32 *)(&(pcp->pci_base0)))[res_n + 1]);
+#else
+ ((CARD32 *)(&(pcp->pci_base0)))[res_n + 1] = 0;
+ pciWriteLong(tag, PCI_CMD_BASE_REG + (res_n + 1) * sizeof(CARD32),
+ 0);
+#endif
+ }
+ } else {
+ pvp->biosBase = range.rBegin;
+ pcp->pci_baserom = (pciReadLong(tag,PCI_CMD_BIOS_REG) & 0x01) |
+ (CARD32)(*p_base);
+ pciWriteLong(tag, PCI_CMD_BIOS_REG, pcp->pci_baserom);
+ }
+ /* @@@ fake BIOS allocated resource */
+ range.type |= ResBios;
+ Acc = xf86AddResToList(Acc, &range,-1);
+
+ return TRUE;
+
+}
+
+Bool
+xf86FixPciResource(int entityIndex, int prt, memType alignment,
+ unsigned long type)
+{
+ pciVideoPtr pvp = xf86GetPciInfoForEntity(entityIndex);
+ return fixPciResource(prt, alignment, pvp, type);
+}
+
+resPtr
+xf86ReallocatePciResources(int entityIndex, resPtr pRes)
+{
+ pciVideoPtr pvp = xf86GetPciInfoForEntity(entityIndex);
+ resPtr pBad = NULL,pResTmp;
+ unsigned int prt = 0;
+ int i;
+
+ if (!pvp) return pRes;
+
+ while (pRes) {
+ switch (pRes->res_type & ResPhysMask) {
+ case ResMem:
+ if (pRes->block_begin == B2M(TAG(pvp),pvp->biosBase) &&
+ pRes->block_end == B2M(TAG(pvp),pvp->biosBase
+ + SIZE(pvp->biosSize)))
+ prt = 6;
+ else for (i = 0 ; i < 6; i++)
+ if ((pRes->block_begin == B2M(TAG(pvp),pvp->memBase[i]))
+ && (pRes->block_end == B2M(TAG(pvp),pvp->memBase[i]
+ + SIZE(pvp->size[i])))) {
+ prt = i;
+ break;
+ }
+ break;
+ case ResIo:
+ for (i = 0 ; i < 6; i++)
+ if (pRes->block_begin == B2I(TAG(pvp),pvp->ioBase[i])
+ && pRes->block_end == B2I(TAG(pvp),pvp->ioBase[i]
+ + SIZE(pvp->size[i]))) {
+ prt = i;
+ break;
+ }
+ break;
+ }
+
+ if (!prt) return pRes;
+
+ pResTmp = pRes->next;
+ if (! fixPciResource(prt, 0, pvp, pRes->res_type)) {
+ pRes->next = pBad;
+ pBad = pRes;
+ } else
+ xfree(pRes);
+
+ pRes = pResTmp;
+ }
+ return pBad;
+}
+
+/*
+ * BIOS releated
+ */
+memType
+getValidBIOSBase(PCITAG tag, int num)
+{
+ pciVideoPtr pvp = NULL;
+ PciBusPtr pbp;
+ resPtr m = NULL;
+ resPtr tmp, avoid, mem = NULL;
+ resRange range;
+ memType ret;
+ int n = 0;
+ int i;
+ CARD32 biosSize, alignment;
+
+ if (!xf86PciVideoInfo) return 0;
+
+ while ((pvp = xf86PciVideoInfo[n++])) {
+ if (pciTag(pvp->bus,pvp->device,pvp->func) == tag)
+ break;
+ }
+ if (!pvp) return 0;
+
+ biosSize = pvp->biosSize;
+ alignment = (1 << biosSize) - 1;
+ if (biosSize > 24)
+ biosSize = 24;
+
+ switch ((romBaseSource)num) {
+ case ROM_BASE_PRESET:
+ return 0; /* This should not happen */
+ case ROM_BASE_BIOS:
+ /* In some cases the BIOS base register contains the size mask */
+ if ((memType)(-1 << biosSize) == PCIGETROM(pvp->biosBase))
+ return 0;
+ /* Make sure we don't conflict with our own mem resources */
+ for (i = 0; i < 6; i++) {
+ if (!pvp->memBase[i])
+ continue;
+ P_M_RANGE(range,TAG(pvp),pvp->memBase[i],pvp->size[i],
+ ResExcMemBlock);
+ mem = xf86AddResToList(mem,&range,-1);
+ }
+ P_M_RANGE(range, TAG(pvp),pvp->biosBase,biosSize,ResExcMemBlock);
+ ret = pvp->biosBase;
+ break;
+ case ROM_BASE_MEM0:
+ case ROM_BASE_MEM1:
+ case ROM_BASE_MEM2:
+ case ROM_BASE_MEM3:
+ case ROM_BASE_MEM4:
+ case ROM_BASE_MEM5:
+ if (!pvp->memBase[num] || (pvp->size[num] < biosSize))
+ return 0;
+ P_M_RANGE(range, TAG(pvp),pvp->memBase[num],biosSize,
+ ResExcMemBlock);
+ ret = pvp->memBase[num];
+ break;
+ case ROM_BASE_FIND:
+ ret = 0;
+ break;
+ default:
+ return 0; /* This should not happen */
+ }
+
+ /* Now find the ranges for validation */
+ avoid = xf86DupResList(pciAvoidRes);
+ pbp = xf86PciBus;
+ while (pbp) {
+ if (pbp->secondary == pvp->bus) {
+ if (pbp->preferred_pmem)
+ tmp = xf86DupResList(pbp->preferred_pmem);
+ else
+ tmp = xf86DupResList(pbp->pmem);
+ m = xf86JoinResLists(m,tmp);
+ if (pbp->preferred_mem)
+ tmp = xf86DupResList(pbp->preferred_mem);
+ else
+ tmp = xf86DupResList(pbp->mem);
+ m = xf86JoinResLists(m,tmp);
+ tmp = m;
+ while (tmp) {
+ tmp->block_end = min(tmp->block_end,PCI_MEM32_LENGTH_MAX);
+ tmp = tmp->next;
+ }
+ } else if ((pbp->primary == pvp->bus) &&
+ (pbp->secondary >= 0) &&
+ (pbp->primary != pbp->secondary)) {
+ tmp = xf86DupResList(pbp->preferred_pmem);
+ avoid = xf86JoinResLists(avoid, tmp);
+ tmp = xf86DupResList(pbp->pmem);
+ avoid = xf86JoinResLists(avoid, tmp);
+ tmp = xf86DupResList(pbp->preferred_mem);
+ avoid = xf86JoinResLists(avoid, tmp);
+ tmp = xf86DupResList(pbp->mem);
+ avoid = xf86JoinResLists(avoid, tmp);
+ }
+ pbp = pbp->next;
+ }
+ pciConvertListToHost(pvp->bus,pvp->device,pvp->func, avoid);
+ if (mem)
+ pciConvertListToHost(pvp->bus,pvp->device,pvp->func, mem);
+
+ if (!ret) {
+ /* Return a possible window */
+ while (m) {
+ range = xf86GetBlock(RANGE_TYPE(ResExcMemBlock, xf86GetPciDomain(tag)),
+ PCI_SIZE(ResMem, TAG(pvp), 1 << biosSize),
+ m->block_begin, m->block_end,
+ PCI_SIZE(ResMem, TAG(pvp), alignment),
+ avoid);
+ if (range.type != ResEnd) {
+ ret = M2B(TAG(pvp), range.rBase);
+ break;
+ }
+ m = m->next;
+ }
+ } else {
+#if !defined(__ia64__) /* on ia64, trust the kernel, don't look for overlaps */
+ if (!xf86IsSubsetOf(range, m) ||
+ ChkConflict(&range, avoid, SETUP)
+ || (mem && ChkConflict(&range, mem, SETUP)))
+ ret = 0;
+#endif
+ }
+
+ xf86FreeResList(avoid);
+ xf86FreeResList(m);
+ return ret;
+}
+
+/*
+ * xf86Bus.c interface
+ */
+
+void
+xf86PciProbe(void)
+{
+ /*
+ * Initialise the pcidata entry points.
+ */
+#ifdef XFree86LOADER
+ xf86SetupPciIds = (ScanPciSetupProcPtr)LoaderSymbol("ScanPciSetupPciIds");
+ xf86ClosePciIds = (ScanPciCloseProcPtr)LoaderSymbol("ScanPciClosePciIds");
+ xf86FindPciNamesByDevice =
+ (ScanPciFindByDeviceProcPtr)LoaderSymbol("ScanPciFindPciNamesByDevice");
+ xf86FindPciNamesBySubsys =
+ (ScanPciFindBySubsysProcPtr)LoaderSymbol("ScanPciFindPciNamesBySubsys");
+ xf86FindPciClassBySubsys =
+ (ScanPciFindClassBySubsysProcPtr)LoaderSymbol("ScanPciFindPciClassBySubsys");
+ xf86FindPciClassByDevice =
+ (ScanPciFindClassByDeviceProcPtr)LoaderSymbol("ScanPciFindPciClassByDevice");
+#else
+ xf86SetupPciIds = ScanPciSetupPciIds;
+ xf86ClosePciIds = ScanPciClosePciIds;
+ xf86FindPciNamesByDevice = ScanPciFindPciNamesByDevice;
+ xf86FindPciNamesBySubsys = ScanPciFindPciNamesBySubsys;
+ xf86FindPciClassBySubsys = ScanPciFindPciClassBySubsys;
+ xf86FindPciClassByDevice = ScanPciFindPciClassByDevice;
+#endif
+
+ if (!xf86SetupPciIds())
+ FatalError("xf86SetupPciIds() failed\n");
+
+ FindPCIVideoInfo();
+}
+
+static void alignBridgeRanges(PciBusPtr PciBusBase, PciBusPtr primary);
+
+static void
+printBridgeInfo(PciBusPtr PciBus)
+{
+ char primary[8], secondary[8], subordinate[8], brbus[8];
+
+ xf86FormatPciBusNumber(PciBus->primary, primary);
+ xf86FormatPciBusNumber(PciBus->secondary, secondary);
+ xf86FormatPciBusNumber(PciBus->subordinate, subordinate);
+ xf86FormatPciBusNumber(PciBus->brbus, brbus);
+
+ xf86MsgVerb(X_INFO, 3, "Bus %s: bridge is at (%s:%d:%d), (%s,%s,%s),"
+ " BCTRL: 0x%04x (VGA_EN is %s)\n",
+ secondary, brbus, PciBus->brdev, PciBus->brfunc,
+ primary, secondary, subordinate, PciBus->brcontrol,
+ (PciBus->brcontrol & PCI_PCI_BRIDGE_VGA_EN) ?
+ "set" : "cleared");
+ if (PciBus->preferred_io) {
+ xf86MsgVerb(X_INFO, 3,
+ "Bus %s I/O range:\n", secondary);
+ xf86PrintResList(3, PciBus->preferred_io);
+ }
+ if (PciBus->preferred_mem) {
+ xf86MsgVerb(X_INFO, 3,
+ "Bus %s non-prefetchable memory range:\n", secondary);
+ xf86PrintResList(3, PciBus->preferred_mem);
+ }
+ if (PciBus->preferred_pmem) {
+ xf86MsgVerb(X_INFO, 3,
+ "Bus %s prefetchable memory range:\n", secondary);
+ xf86PrintResList(3, PciBus->preferred_pmem);
+ }
+}
+
+static PciBusPtr
+xf86GetPciBridgeInfo(void)
+{
+ const pciConfigPtr *pcrpp;
+ pciConfigPtr pcrp;
+ pciBusInfo_t *pBusInfo;
+ resRange range;
+ PciBusPtr PciBus, PciBusBase = NULL;
+ PciBusPtr *pnPciBus = &PciBusBase;
+ int MaxBus = 0;
+ int i, domain;
+ int primary, secondary, subordinate;
+ memType base, limit;
+
+ resPtr pciBusAccWindows = xf86PciBusAccWindowsFromOS();
+
+ if (xf86PciInfo == NULL)
+ return NULL;
+
+ /* Add each bridge */
+ for (pcrpp = xf86PciInfo, pcrp = *pcrpp; pcrp; pcrp = *(++pcrpp)) {
+ if (pcrp->busnum > MaxBus)
+ MaxBus = pcrp->busnum;
+ if ((pcrp->pci_base_class == PCI_CLASS_BRIDGE) ||
+ (((pcrp->listed_class >> 8) & 0xff) == PCI_CLASS_BRIDGE)) {
+ int sub_class;
+ sub_class = (pcrp->listed_class & 0xffff) ?
+ (pcrp->listed_class & 0xff) : pcrp->pci_sub_class;
+ domain = xf86GetPciDomain(pcrp->tag);
+
+ switch (sub_class) {
+ case PCI_SUBCLASS_BRIDGE_PCI:
+ /* something fishy about the header? If so: just ignore! */
+ if ((pcrp->pci_header_type & 0x7f) != 0x01) {
+ xf86MsgVerb(X_WARNING, 3, "PCI-PCI bridge at %x:%x:%x has"
+ " unexpected header: 0x%x",
+ pcrp->busnum, pcrp->devnum,
+ pcrp->funcnum, pcrp->pci_header_type);
+ break;
+ }
+
+ domain = pcrp->busnum & 0x0000FF00;
+ primary = pcrp->busnum;
+ secondary = domain | pcrp->pci_secondary_bus_number;
+ subordinate = domain | pcrp->pci_subordinate_bus_number;
+
+ /* Is this the correct bridge? If not, ignore it */
+ pBusInfo = pcrp->businfo;
+ if (pBusInfo && (pcrp != pBusInfo->bridge)) {
+ xf86MsgVerb(X_WARNING, 3, "PCI bridge mismatch for bus %x:"
+ " %x:%x:%x and %x:%x:%x\n", secondary,
+ pcrp->busnum, pcrp->devnum, pcrp->funcnum,
+ pBusInfo->bridge->busnum,
+ pBusInfo->bridge->devnum,
+ pBusInfo->bridge->funcnum);
+ break;
+ }
+
+ if (pBusInfo && pBusInfo->funcs->pciGetBridgeBuses)
+ (*pBusInfo->funcs->pciGetBridgeBuses)(secondary,
+ &primary,
+ &secondary,
+ &subordinate);
+
+ if (!pcrp->fakeDevice && (primary >= secondary)) {
+ xf86MsgVerb(X_WARNING, 3, "Misconfigured PCI bridge"
+ " %x:%x:%x (%x,%x)\n",
+ pcrp->busnum, pcrp->devnum, pcrp->funcnum,
+ primary, secondary);
+ break;
+ }
+
+ *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec));
+ pnPciBus = &PciBus->next;
+
+ PciBus->primary = primary;
+ PciBus->secondary = secondary;
+ PciBus->subordinate = subordinate;
+
+ PciBus->brbus = pcrp->busnum;
+ PciBus->brdev = pcrp->devnum;
+ PciBus->brfunc = pcrp->funcnum;
+
+ PciBus->subclass = sub_class;
+ PciBus->interface = pcrp->pci_prog_if;
+
+ if (pBusInfo && pBusInfo->funcs->pciControlBridge)
+ PciBus->brcontrol =
+ (*pBusInfo->funcs->pciControlBridge)(secondary, 0, 0);
+ else
+ PciBus->brcontrol = pcrp->pci_bridge_control;
+
+ if (pBusInfo && pBusInfo->funcs->pciGetBridgeResources) {
+ (*pBusInfo->funcs->pciGetBridgeResources)(secondary,
+ (pointer *)&PciBus->preferred_io,
+ (pointer *)&PciBus->preferred_mem,
+ (pointer *)&PciBus->preferred_pmem);
+ break;
+ }
+
+ if ((pcrp->pci_command & PCI_CMD_IO_ENABLE) &&
+ (pcrp->pci_upper_io_base || pcrp->pci_io_base ||
+ pcrp->pci_upper_io_limit || pcrp->pci_io_limit)) {
+ base = (pcrp->pci_upper_io_base << 16) |
+ ((pcrp->pci_io_base & 0xf0u) << 8);
+ limit = (pcrp->pci_upper_io_limit << 16) |
+ ((pcrp->pci_io_limit & 0xf0u) << 8) | 0x0fff;
+ /*
+ * Deal with bridge ISA mode (256 wide ranges spaced 1K
+ * apart, but only in the first 64K).
+ */
+ if (pcrp->pci_bridge_control & PCI_PCI_BRIDGE_ISA_EN) {
+ while ((base <= (CARD16)(-1)) && (base <= limit)) {
+ PCI_I_RANGE(range, pcrp->tag,
+ base, base + (CARD8)(-1),
+ ResIo | ResBlock | ResExclusive);
+ PciBus->preferred_io =
+ xf86AddResToList(PciBus->preferred_io,
+ &range, -1);
+ base += 0x0400;
+ }
+ }
+ if (base <= limit) {
+ PCI_I_RANGE(range, pcrp->tag, base, limit,
+ ResIo | ResBlock | ResExclusive);
+ PciBus->preferred_io =
+ xf86AddResToList(PciBus->preferred_io, &range, -1);
+ }
+ }
+ if (pcrp->pci_command & PCI_CMD_MEM_ENABLE) {
+ /*
+ * The P2P spec requires these next two, but some bridges
+ * don't comply. Err on the side of caution, making the not
+ * so bold assumption that no bridge would ever re-route the
+ * bottom megabyte.
+ */
+ if (pcrp->pci_mem_base || pcrp->pci_mem_limit) {
+ base = pcrp->pci_mem_base & 0xfff0u;
+ limit = pcrp->pci_mem_limit & 0xfff0u;
+ if (base <= limit) {
+ PCI_M_RANGE(range, pcrp->tag,
+ base << 16, (limit << 16) | 0x0fffff,
+ ResMem | ResBlock | ResExclusive);
+ PciBus->preferred_mem =
+ xf86AddResToList(PciBus->preferred_mem, &range, -1);
+ }
+ }
+
+ if (pcrp->pci_prefetch_mem_base ||
+ pcrp->pci_prefetch_mem_limit ||
+ pcrp->pci_prefetch_upper_mem_base ||
+ pcrp->pci_prefetch_upper_mem_limit) {
+ base = pcrp->pci_prefetch_mem_base & 0xfff0u;
+ limit = pcrp->pci_prefetch_mem_limit & 0xfff0u;
+#if defined(LONG64) || defined(WORD64)
+ base |= (memType)pcrp->pci_prefetch_upper_mem_base << 16;
+ limit |= (memType)pcrp->pci_prefetch_upper_mem_limit << 16;
+#endif
+ if (base <= limit) {
+ PCI_M_RANGE(range, pcrp->tag,
+ base << 16, (limit << 16) | 0xfffff,
+ ResMem | ResBlock | ResExclusive);
+ PciBus->preferred_pmem =
+ xf86AddResToList(PciBus->preferred_pmem,
+ &range, -1);
+ }
+ }
+ }
+ break;
+
+ case PCI_SUBCLASS_BRIDGE_CARDBUS:
+ /* something fishy about the header? If so: just ignore! */
+ if ((pcrp->pci_header_type & 0x7f) != 0x02) {
+ xf86MsgVerb(X_WARNING, 3, "PCI-CardBus bridge at %x:%x:%x"
+ " has unexpected header: 0x%x",
+ pcrp->busnum, pcrp->devnum,
+ pcrp->funcnum, pcrp->pci_header_type);
+ break;
+ }
+
+ domain = pcrp->busnum & 0x0000FF00;
+ primary = pcrp->busnum;
+ secondary = domain | pcrp->pci_cb_cardbus_bus_number;
+ subordinate = domain | pcrp->pci_subordinate_bus_number;
+
+ /* Is this the correct bridge? If not, ignore it */
+ pBusInfo = pcrp->businfo;
+ if (pBusInfo && (pcrp != pBusInfo->bridge)) {
+ xf86MsgVerb(X_WARNING, 3, "CardBus bridge mismatch for bus"
+ " %x: %x:%x:%x and %x:%x:%x\n", secondary,
+ pcrp->busnum, pcrp->devnum, pcrp->funcnum,
+ pBusInfo->bridge->busnum,
+ pBusInfo->bridge->devnum,
+ pBusInfo->bridge->funcnum);
+ break;
+ }
+
+ if (pBusInfo && pBusInfo->funcs->pciGetBridgeBuses)
+ (*pBusInfo->funcs->pciGetBridgeBuses)(secondary,
+ &primary,
+ &secondary,
+ &subordinate);
+
+ if (primary >= secondary) {
+ if (pcrp->pci_cb_cardbus_bus_number != 0)
+ xf86MsgVerb(X_WARNING, 3, "Misconfigured CardBus"
+ " bridge %x:%x:%x (%x,%x)\n",
+ pcrp->busnum, pcrp->devnum, pcrp->funcnum,
+ primary, secondary);
+ break;
+ }
+
+ *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec));
+ pnPciBus = &PciBus->next;
+
+ PciBus->primary = primary;
+ PciBus->secondary = secondary;
+ PciBus->subordinate = subordinate;
+
+ PciBus->brbus = pcrp->busnum;
+ PciBus->brdev = pcrp->devnum;
+ PciBus->brfunc = pcrp->funcnum;
+
+ PciBus->subclass = sub_class;
+ PciBus->interface = pcrp->pci_prog_if;
+
+ if (pBusInfo && pBusInfo->funcs->pciControlBridge)
+ PciBus->brcontrol =
+ (*pBusInfo->funcs->pciControlBridge)(secondary, 0, 0);
+ else
+ PciBus->brcontrol = pcrp->pci_bridge_control;
+
+ if (pBusInfo && pBusInfo->funcs->pciGetBridgeResources) {
+ (*pBusInfo->funcs->pciGetBridgeResources)(secondary,
+ (pointer *)&PciBus->preferred_io,
+ (pointer *)&PciBus->preferred_mem,
+ (pointer *)&PciBus->preferred_pmem);
+ break;
+ }
+
+ if (pcrp->pci_command & PCI_CMD_IO_ENABLE) {
+ if (pcrp->pci_cb_iobase0) {
+ base = PCI_CB_IOBASE(pcrp->pci_cb_iobase0);
+ limit = PCI_CB_IOLIMIT(pcrp->pci_cb_iolimit0);
+
+ /*
+ * Deal with bridge ISA mode (256-wide ranges spaced 1K
+ * apart (start to start), but only in the first 64K).
+ */
+ if (pcrp->pci_bridge_control & PCI_PCI_BRIDGE_ISA_EN) {
+ while ((base <= (CARD16)(-1)) &&
+ (base <= limit)) {
+ PCI_I_RANGE(range, pcrp->tag,
+ base, base + (CARD8)(-1),
+ ResIo | ResBlock | ResExclusive);
+ PciBus->preferred_io =
+ xf86AddResToList(PciBus->preferred_io,
+ &range, -1);
+ base += 0x0400;
+ }
+ }
+
+ if (base <= limit) {
+ PCI_I_RANGE(range, pcrp->tag, base, limit,
+ ResIo | ResBlock | ResExclusive);
+ PciBus->preferred_io =
+ xf86AddResToList(PciBus->preferred_io,
+ &range, -1);
+ }
+ }
+
+ if (pcrp->pci_cb_iobase1) {
+ base = PCI_CB_IOBASE(pcrp->pci_cb_iobase1);
+ limit = PCI_CB_IOLIMIT(pcrp->pci_cb_iolimit1);
+
+ /*
+ * Deal with bridge ISA mode (256-wide ranges spaced 1K
+ * apart (start to start), but only in the first 64K).
+ */
+ if (pcrp->pci_bridge_control & PCI_PCI_BRIDGE_ISA_EN) {
+ while ((base <= (CARD16)(-1)) &&
+ (base <= limit)) {
+ PCI_I_RANGE(range, pcrp->tag,
+ base, base + (CARD8)(-1),
+ ResIo | ResBlock | ResExclusive);
+ PciBus->preferred_io =
+ xf86AddResToList(PciBus->preferred_io,
+ &range, -1);
+ base += 0x0400;
+ }
+ }
+
+ if (base <= limit) {
+ PCI_I_RANGE(range, pcrp->tag, base, limit,
+ ResIo | ResBlock | ResExclusive);
+ PciBus->preferred_io =
+ xf86AddResToList(PciBus->preferred_io,
+ &range, -1);
+ }
+ }
+ }
+
+ if (pcrp->pci_command & PCI_CMD_MEM_ENABLE) {
+ if ((pcrp->pci_cb_membase0) &&
+ (pcrp->pci_cb_membase0 <= pcrp->pci_cb_memlimit0)) {
+ PCI_M_RANGE(range, pcrp->tag,
+ pcrp->pci_cb_membase0 & ~0x0fff,
+ pcrp->pci_cb_memlimit0 | 0x0fff,
+ ResMem | ResBlock | ResExclusive);
+ if (pcrp->pci_bridge_control &
+ PCI_CB_BRIDGE_CTL_PREFETCH_MEM0)
+ PciBus->preferred_pmem =
+ xf86AddResToList(PciBus->preferred_pmem,
+ &range, -1);
+ else
+ PciBus->preferred_mem =
+ xf86AddResToList(PciBus->preferred_mem,
+ &range, -1);
+ }
+ if ((pcrp->pci_cb_membase1) &&
+ (pcrp->pci_cb_membase1 <= pcrp->pci_cb_memlimit1)) {
+ PCI_M_RANGE(range, pcrp->tag,
+ pcrp->pci_cb_membase1 & ~0x0fff,
+ pcrp->pci_cb_memlimit1 | 0x0fff,
+ ResMem | ResBlock | ResExclusive);
+ if (pcrp->pci_bridge_control &
+ PCI_CB_BRIDGE_CTL_PREFETCH_MEM1)
+ PciBus->preferred_pmem =
+ xf86AddResToList(PciBus->preferred_pmem,
+ &range, -1);
+ else
+ PciBus->preferred_mem =
+ xf86AddResToList(PciBus->preferred_mem,
+ &range, -1);
+ }
+ }
+
+ break;
+
+ case PCI_SUBCLASS_BRIDGE_ISA:
+ case PCI_SUBCLASS_BRIDGE_EISA:
+ case PCI_SUBCLASS_BRIDGE_MC:
+ *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec));
+ pnPciBus = &PciBus->next;
+ PciBus->primary = pcrp->busnum;
+ PciBus->secondary = PciBus->subordinate = -1;
+ PciBus->brbus = pcrp->busnum;
+ PciBus->brdev = pcrp->devnum;
+ PciBus->brfunc = pcrp->funcnum;
+ PciBus->subclass = sub_class;
+ PciBus->brcontrol = PCI_PCI_BRIDGE_VGA_EN;
+ break;
+
+ case PCI_SUBCLASS_BRIDGE_HOST:
+ /* Is this the correct bridge? If not, ignore bus info */
+ pBusInfo = pcrp->businfo;
+
+ if (!pBusInfo || pBusInfo == HOST_NO_BUS)
+ break;
+
+ secondary = 0;
+ /* Find "secondary" bus segment */
+ while (pBusInfo != pciBusInfo[secondary])
+ secondary++;
+ if (pcrp != pBusInfo->bridge) {
+ xf86MsgVerb(X_WARNING, 3, "Host bridge mismatch for"
+ " bus %x: %x:%x:%x and %x:%x:%x\n",
+ pBusInfo->primary_bus,
+ pcrp->busnum, pcrp->devnum, pcrp->funcnum,
+ pBusInfo->bridge->busnum,
+ pBusInfo->bridge->devnum,
+ pBusInfo->bridge->funcnum);
+ pBusInfo = NULL;
+ }
+
+ *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec));
+ pnPciBus = &PciBus->next;
+
+
+ PciBus->primary = PciBus->secondary = secondary;
+ PciBus->subordinate = pciNumBuses - 1;
+
+ if (pBusInfo->funcs->pciGetBridgeBuses)
+ (*pBusInfo->funcs->pciGetBridgeBuses)
+ (secondary,
+ &PciBus->primary,
+ &PciBus->secondary,
+ &PciBus->subordinate);
+
+ PciBus->brbus = pcrp->busnum;
+ PciBus->brdev = pcrp->devnum;
+ PciBus->brfunc = pcrp->funcnum;
+
+ PciBus->subclass = sub_class;
+
+ if (pBusInfo && pBusInfo->funcs->pciControlBridge)
+ PciBus->brcontrol =
+ (*pBusInfo->funcs->pciControlBridge)(secondary, 0, 0);
+ else
+ PciBus->brcontrol = PCI_PCI_BRIDGE_VGA_EN;
+
+ if (pBusInfo && pBusInfo->funcs->pciGetBridgeResources) {
+ (*pBusInfo->funcs->pciGetBridgeResources)
+ (secondary,
+ (pointer *)&PciBus->preferred_io,
+ (pointer *)&PciBus->preferred_mem,
+ (pointer *)&PciBus->preferred_pmem);
+ break;
+ }
+
+ PciBus->preferred_io =
+ xf86ExtractTypeFromList(pciBusAccWindows,
+ RANGE_TYPE(ResIo, domain));
+ PciBus->preferred_mem =
+ xf86ExtractTypeFromList(pciBusAccWindows,
+ RANGE_TYPE(ResMem, domain));
+ PciBus->preferred_pmem =
+ xf86ExtractTypeFromList(pciBusAccWindows,
+ RANGE_TYPE(ResMem, domain));
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ for (i = 0; i <= MaxBus; i++) { /* find PCI buses not attached to bridge */
+ if (!pciBusInfo[i])
+ continue;
+ for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next)
+ if (PciBus->secondary == i) break;
+ if (!PciBus) { /* We assume it's behind a HOST-PCI bridge */
+ /*
+ * Find the 'smallest' free HOST-PCI bridge, where 'small' is in
+ * the order of pciTag().
+ */
+ PCITAG minTag = 0xFFFFFFFF, tag;
+ PciBusPtr PciBusFound = NULL;
+ for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next)
+ if ((PciBus->subclass == PCI_SUBCLASS_BRIDGE_HOST) &&
+ (PciBus->secondary == -1) &&
+ ((tag = pciTag(PciBus->brbus,PciBus->brdev,PciBus->brfunc))
+ < minTag) ) {
+ minTag = tag;
+ PciBusFound = PciBus;
+ }
+ if (PciBusFound)
+ PciBusFound->secondary = i;
+ else { /* if nothing found it may not be visible: create new */
+ /* Find a device on this bus */
+ domain = 0;
+ for (pcrpp = xf86PciInfo; (pcrp = *pcrpp); pcrpp++) {
+ if (pcrp->busnum == i) {
+ domain = xf86GetPciDomain(pcrp->tag);
+ break;
+ }
+ }
+ *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec));
+ pnPciBus = &PciBus->next;
+ PciBus->primary = PciBus->secondary = i;
+ PciBus->subclass = PCI_SUBCLASS_BRIDGE_HOST;
+ PciBus->brcontrol = PCI_PCI_BRIDGE_VGA_EN;
+ PciBus->preferred_io =
+ xf86ExtractTypeFromList(pciBusAccWindows,
+ RANGE_TYPE(ResIo, domain));
+ PciBus->preferred_mem =
+ xf86ExtractTypeFromList(pciBusAccWindows,
+ RANGE_TYPE(ResMem, domain));
+ PciBus->preferred_pmem =
+ xf86ExtractTypeFromList(pciBusAccWindows,
+ RANGE_TYPE(ResMem, domain));
+ }
+ }
+ }
+
+ for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next) {
+ if (PciBus->primary == PciBus->secondary) {
+ alignBridgeRanges(PciBusBase, PciBus);
+ }
+ }
+
+ for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next) {
+ switch (PciBus->subclass) {
+ case PCI_SUBCLASS_BRIDGE_PCI:
+ if (PciBus->interface == PCI_IF_BRIDGE_PCI_SUBTRACTIVE)
+ xf86MsgVerb(X_INFO, 3, "Subtractive PCI-to-PCI bridge:\n");
+ else
+ xf86MsgVerb(X_INFO, 3, "PCI-to-PCI bridge:\n");
+ break;
+ case PCI_SUBCLASS_BRIDGE_CARDBUS:
+ xf86MsgVerb(X_INFO, 3, "PCI-to-CardBus bridge:\n");
+ break;
+ case PCI_SUBCLASS_BRIDGE_HOST:
+ xf86MsgVerb(X_INFO, 3, "Host-to-PCI bridge:\n");
+ break;
+ case PCI_SUBCLASS_BRIDGE_ISA:
+ xf86MsgVerb(X_INFO, 3, "PCI-to-ISA bridge:\n");
+ break;
+ case PCI_SUBCLASS_BRIDGE_EISA:
+ xf86MsgVerb(X_INFO, 3, "PCI-to-EISA bridge:\n");
+ break;
+ case PCI_SUBCLASS_BRIDGE_MC:
+ xf86MsgVerb(X_INFO, 3, "PCI-to-MCA bridge:\n");
+ break;
+ default:
+ break;
+ }
+ printBridgeInfo(PciBus);
+ }
+ xf86FreeResList(pciBusAccWindows);
+ return PciBusBase;
+}
+
+static void
+alignBridgeRanges(PciBusPtr PciBusBase, PciBusPtr primary)
+{
+ PciBusPtr PciBus;
+
+ for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next) {
+ if ((PciBus != primary) && (PciBus->primary != -1)
+ && (PciBus->primary == primary->secondary)) {
+ resPtr tmp;
+ tmp = xf86FindIntersectOfLists(primary->preferred_io,
+ PciBus->preferred_io);
+ xf86FreeResList(PciBus->preferred_io);
+ PciBus->preferred_io = tmp;
+ tmp = xf86FindIntersectOfLists(primary->preferred_pmem,
+ PciBus->preferred_pmem);
+ xf86FreeResList(PciBus->preferred_pmem);
+ PciBus->preferred_pmem = tmp;
+ tmp = xf86FindIntersectOfLists(primary->preferred_mem,
+ PciBus->preferred_mem);
+ xf86FreeResList(PciBus->preferred_mem);
+ PciBus->preferred_mem = tmp;
+
+ /* Deal with subtractive decoding */
+ switch (PciBus->subclass) {
+ case PCI_SUBCLASS_BRIDGE_PCI:
+ if (PciBus->interface != PCI_IF_BRIDGE_PCI_SUBTRACTIVE)
+ break;
+ /* Fall through */
+#if 0 /* Not yet */
+ case PCI_SUBCLASS_BRIDGE_ISA:
+ case PCI_SUBCLASS_BRIDGE_EISA:
+ case PCI_SUBCLASS_BRIDGE_MC:
+#endif
+ if (!(PciBus->io = primary->io))
+ PciBus->io = primary->preferred_io;
+ if (!(PciBus->mem = primary->mem))
+ PciBus->mem = primary->preferred_mem;
+ if (!(PciBus->pmem = primary->pmem))
+ PciBus->pmem = primary->preferred_pmem;
+ default:
+ break;
+ }
+
+ alignBridgeRanges(PciBusBase, PciBus);
+ }
+ }
+}
+
+void
+ValidatePci(void)
+{
+ pciVideoPtr pvp, pvp1;
+ PciBusPtr pbp;
+ pciConfigPtr pcrp, *pcrpp;
+ CARD32 *basep;
+ resPtr Sys;
+ resRange range;
+ int n = 0, m, i;
+
+ if (!xf86PciVideoInfo) return;
+
+ /*
+ * Mark all pciInfoRecs that need to be validated. These are
+ * the ones which have been assigned to a screen.
+ */
+ Sys = xf86DupResList(osRes);
+ /* Only validate graphics devices in use */
+ for (i=0; i<xf86NumScreens; i++) {
+ for (m = 0; m < xf86Screens[i]->numEntities; m++)
+ if ((pvp = xf86GetPciInfoForEntity(xf86Screens[i]->entityList[m])))
+ pvp->validate = TRUE;
+ }
+
+ /*
+ * Collect all background PCI resources we need to validate against.
+ * These are all resources which don't belong to PCINONSYSTEMCLASSES
+ * and which have not been assigned to an entity.
+ */
+ /* First get the PCIINFOCLASSES */
+ m = 0;
+ while ((pvp = xf86PciVideoInfo[m++])) {
+ /* is it a PCINONSYSTEMCLASS? */
+ if (PCINONSYSTEMCLASSES(pvp->class, pvp->subclass))
+ continue;
+ /* has it an Entity assigned to it? */
+ for (i=0; i<xf86NumEntities; i++) {
+ EntityPtr p = xf86Entities[i];
+ if (p->busType != BUS_PCI)
+ continue;
+ if (p->pciBusId.bus == pvp->bus
+ && p->pciBusId.device == pvp->device
+ && p->pciBusId.func == pvp->func)
+ break;
+ }
+ if (i != xf86NumEntities) /* found an Entity for this one */
+ continue;
+
+ for (i = 0; i<6; i++) {
+ if (pvp->ioBase[i]) {
+ PV_I_RANGE(range,pvp,i,ResExcIoBlock);
+ Sys = xf86AddResToList(Sys,&range,-1);
+ } else if (pvp->memBase[i]) {
+ PV_M_RANGE(range,pvp,i,ResExcMemBlock);
+ Sys = xf86AddResToList(Sys,&range,-1);
+ }
+ }
+ }
+ for (pcrpp = xf86PciInfo, pcrp = *pcrpp; pcrp; pcrp = *++(pcrpp)) {
+
+ /* These were handled above */
+ if (PCIINFOCLASSES(pcrp->pci_base_class, pcrp->pci_sub_class))
+ continue;
+
+ if ((pcrp->pci_header_type & 0x7f) ||
+ !(pcrp->pci_command & (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE)))
+ continue;
+
+ basep = &pcrp->pci_base0;
+ for (i = 0; i < 6; i++) {
+ if (basep[i]) {
+ if (PCI_MAP_IS_IO(basep[i])) {
+ if (!(pcrp->pci_command & PCI_CMD_IO_ENABLE))
+ continue;
+ P_I_RANGE(range, pcrp->tag, PCIGETIO(basep[i]),
+ pcrp->basesize[i], ResExcIoBlock)
+ } else if (!PCI_MAP_IS64BITMEM(basep[i])) {
+ if (!(pcrp->pci_command & PCI_CMD_MEM_ENABLE))
+ continue;
+ P_M_RANGE(range, pcrp->tag, PCIGETMEMORY(basep[i]),
+ pcrp->basesize[i], ResExcMemBlock)
+ } else {
+ i++;
+ if (!(pcrp->pci_command & PCI_CMD_MEM_ENABLE))
+ continue;
+#if defined(LONG64) || defined(WORD64)
+ P_M_RANGE(range, pcrp->tag, PCIGETMEMORY64(basep[i-1]),
+ pcrp->basesize[i-1], ResExcMemBlock)
+#else
+ if (basep[i])
+ continue;
+ P_M_RANGE(range, pcrp->tag, PCIGETMEMORY(basep[i-1]),
+ pcrp->basesize[i-1], ResExcMemBlock)
+#endif
+ }
+ Sys = xf86AddResToList(Sys, &range, -1);
+ }
+ }
+ if ((pcrp->pci_baserom) &&
+ (pcrp->pci_command & PCI_CMD_MEM_ENABLE) &&
+ (pcrp->pci_baserom & PCI_MAP_ROM_DECODE_ENABLE)) {
+ P_M_RANGE(range,pcrp->tag,PCIGETROM(pcrp->pci_baserom),
+ pcrp->basesize[6],ResExcMemBlock);
+ Sys = xf86AddResToList(Sys, &range, -1);
+ }
+ }
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3,"Sys:\n");
+ xf86PrintResList(3,Sys);
+#endif
+
+ /*
+ * The order the video devices are listed in is
+ * just right: the lower buses come first.
+ * This way we attempt to fix a conflict of
+ * a lower bus device with a higher bus device
+ * where we have more room to find different
+ * resources.
+ */
+ while ((pvp = xf86PciVideoInfo[n++])) {
+ resPtr res_mp = NULL, res_m_io = NULL;
+ resPtr NonSys;
+ resPtr tmp, avoid = NULL;
+
+ if (!pvp->validate) continue;
+ NonSys = xf86DupResList(Sys);
+ m = n;
+ while ((pvp1 = xf86PciVideoInfo[m++])) {
+ if (!pvp1->validate) continue;
+ for (i = 0; i<6; i++) {
+ if (pvp1->ioBase[i]) {
+ PV_I_RANGE(range,pvp1,i,ResExcIoBlock);
+ NonSys = xf86AddResToList(NonSys,&range,-1);
+ } else if (pvp1->memBase[i]) {
+ PV_M_RANGE(range,pvp1,i,ResExcMemBlock);
+ NonSys = xf86AddResToList(NonSys,&range,-1);
+ }
+ }
+ }
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3,"NonSys:\n");
+ xf86PrintResList(3,NonSys);
+#endif
+ pbp = xf86PciBus;
+ while (pbp) {
+ if (pbp->secondary == pvp->bus) {
+ if (pbp->preferred_pmem) {
+ /* keep prefetchable separate */
+ res_mp =
+ xf86FindIntersectOfLists(pbp->preferred_pmem, ResRange);
+ }
+ if (pbp->pmem) {
+ res_mp = xf86FindIntersectOfLists(pbp->pmem, ResRange);
+ }
+ if (pbp->preferred_mem) {
+ res_m_io =
+ xf86FindIntersectOfLists(pbp->preferred_mem, ResRange);
+ }
+ if (pbp->mem) {
+ res_m_io = xf86FindIntersectOfLists(pbp->mem, ResRange);
+ }
+ if (pbp->preferred_io) {
+ res_m_io = xf86JoinResLists(res_m_io,
+ xf86FindIntersectOfLists(pbp->preferred_io, ResRange));
+ }
+ if (pbp->io) {
+ res_m_io = xf86JoinResLists(res_m_io,
+ xf86FindIntersectOfLists(pbp->preferred_io, ResRange));
+ }
+ } else if ((pbp->primary == pvp->bus) &&
+ (pbp->secondary >= 0) &&
+ (pbp->primary != pbp->secondary)) {
+ tmp = xf86DupResList(pbp->preferred_pmem);
+ avoid = xf86JoinResLists(avoid, tmp);
+ tmp = xf86DupResList(pbp->preferred_mem);
+ avoid = xf86JoinResLists(avoid, tmp);
+ tmp = xf86DupResList(pbp->preferred_io);
+ avoid = xf86JoinResLists(avoid, tmp);
+ }
+ pbp = pbp->next;
+ }
+ if (res_m_io == NULL)
+ res_m_io = xf86DupResList(ResRange);
+
+ pciConvertListToHost(pvp->bus,pvp->device,pvp->func, avoid);
+
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3,"avoid:\n");
+ xf86PrintResList(3,avoid);
+ xf86MsgVerb(X_INFO, 3,"prefetchable Memory:\n");
+ xf86PrintResList(3,res_mp);
+ xf86MsgVerb(X_INFO, 3,"MEM/IO:\n");
+ xf86PrintResList(3,res_m_io);
+#endif
+ for (i = 0; i < 6; i++) {
+ int j;
+ resPtr own = NULL;
+ for (j = i+1; j < 6; j++) {
+ if (pvp->ioBase[j]) {
+ PV_I_RANGE(range,pvp,j,ResExcIoBlock);
+ own = xf86AddResToList(own,&range,-1);
+ } else if (pvp->memBase[j]) {
+ PV_M_RANGE(range,pvp,j,ResExcMemBlock);
+ own = xf86AddResToList(own,&range,-1);
+ }
+ }
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "own:\n");
+ xf86PrintResList(3, own);
+#endif
+ if (pvp->ioBase[i]) {
+ PV_I_RANGE(range,pvp,i,ResExcIoBlock);
+ if (xf86IsSubsetOf(range,res_m_io)
+ && ! ChkConflict(&range,own,SETUP)
+ && ! ChkConflict(&range,avoid,SETUP)
+ && ! ChkConflict(&range,NonSys,SETUP)) {
+ xf86FreeResList(own);
+ continue;
+ }
+ xf86MsgVerb(X_WARNING, 0,
+ "****INVALID IO ALLOCATION**** b: 0x%lx e: 0x%lx "
+ "correcting\a\n", range.rBegin,range.rEnd);
+#ifdef DEBUG
+ sleep(2);
+#endif
+ fixPciResource(i, 0, pvp, range.type);
+ } else if (pvp->memBase[i]) {
+ PV_M_RANGE(range,pvp,i,ResExcMemBlock);
+ if (pvp->type[i] & PCI_MAP_MEMORY_CACHABLE) {
+ if (xf86IsSubsetOf(range,res_mp)
+ && ! ChkConflict(&range,own,SETUP)
+ && ! ChkConflict(&range,avoid,SETUP)
+ && ! ChkConflict(&range,NonSys,SETUP)) {
+ xf86FreeResList(own);
+ continue;
+ }
+ }
+ if (xf86IsSubsetOf(range,res_m_io)
+ && ! ChkConflict(&range,own,SETUP)
+ && ! ChkConflict(&range,avoid,SETUP)
+ && ! ChkConflict(&range,NonSys,SETUP)) {
+ xf86FreeResList(own);
+ continue;
+ }
+ xf86MsgVerb(X_WARNING, 0,
+ "****INVALID MEM ALLOCATION**** b: 0x%lx e: 0x%lx "
+ "correcting\a\n", range.rBegin,range.rEnd);
+ if (ChkConflict(&range,own,SETUP)) {
+ xf86MsgVerb(X_INFO,3,"own\n");
+ xf86PrintResList(3,own);
+ }
+ if (ChkConflict(&range,avoid,SETUP)) {
+ xf86MsgVerb(X_INFO,3,"avoid\n");
+ xf86PrintResList(3,avoid);
+ }
+ if (ChkConflict(&range,NonSys,SETUP)) {
+ xf86MsgVerb(X_INFO,3,"NonSys\n");
+ xf86PrintResList(3,NonSys);
+ }
+
+#ifdef DEBUG
+ sleep(2);
+#endif
+ fixPciResource(i, 0, pvp, range.type);
+ }
+ xf86FreeResList(own);
+ }
+ xf86FreeResList(avoid);
+ xf86FreeResList(NonSys);
+ xf86FreeResList(res_mp);
+ xf86FreeResList(res_m_io);
+ }
+ xf86FreeResList(Sys);
+}
+
+resList
+GetImplicitPciResources(int entityIndex)
+{
+ pciVideoPtr pvp;
+ int i;
+ resList list = NULL;
+ int num = 0;
+
+ if (! (pvp = xf86GetPciInfoForEntity(entityIndex))) return NULL;
+
+ for (i = 0; i < 6; i++) {
+ if (pvp->ioBase[i]) {
+ list = xnfrealloc(list,sizeof(resRange) * (++num));
+ PV_I_RANGE(list[num - 1],pvp,i,ResShrIoBlock | ResBios);
+ } else if (pvp->memBase[i]) {
+ list = xnfrealloc(list,sizeof(resRange) * (++num));
+ PV_M_RANGE(list[num - 1],pvp,i,ResShrMemBlock | ResBios);
+ }
+ }
+#if 0
+ if (pvp->biosBase) {
+ list = xnfrealloc(list,sizeof(resRange) * (++num));
+ PV_B_RANGE(list[num - 1],pvp,ResShrMemBlock | ResBios);
+ }
+#endif
+ list = xnfrealloc(list,sizeof(resRange) * (++num));
+ list[num - 1].type = ResEnd;
+
+ return list;
+}
+
+void
+initPciState(void)
+{
+ int i = 0;
+ int j = 0;
+ pciVideoPtr pvp;
+ pciAccPtr pcaccp;
+
+ if (xf86PciAccInfo != NULL)
+ return;
+
+ if (xf86PciVideoInfo == NULL)
+ return;
+
+ while ((pvp = xf86PciVideoInfo[i]) != NULL) {
+ i++;
+ j++;
+ xf86PciAccInfo = xnfrealloc(xf86PciAccInfo,
+ sizeof(pciAccPtr) * (j + 1));
+ xf86PciAccInfo[j] = NULL;
+ pcaccp = xf86PciAccInfo[j - 1] = xnfalloc(sizeof(pciAccRec));
+ pcaccp->busnum = pvp->bus;
+ pcaccp->devnum = pvp->device;
+ pcaccp->funcnum = pvp->func;
+ pcaccp->arg.tag = pciTag(pvp->bus, pvp->device, pvp->func);
+ pcaccp->ioAccess.AccessDisable = pciIoAccessDisable;
+ pcaccp->ioAccess.AccessEnable = pciIoAccessEnable;
+ pcaccp->ioAccess.arg = &pcaccp->arg;
+ pcaccp->io_memAccess.AccessDisable = pciIo_MemAccessDisable;
+ pcaccp->io_memAccess.AccessEnable = pciIo_MemAccessEnable;
+ pcaccp->io_memAccess.arg = &pcaccp->arg;
+ pcaccp->memAccess.AccessDisable = pciMemAccessDisable;
+ pcaccp->memAccess.AccessEnable = pciMemAccessEnable;
+ pcaccp->memAccess.arg = &pcaccp->arg;
+ if (PCISHAREDIOCLASSES(pvp->class, pvp->subclass))
+ pcaccp->ctrl = TRUE;
+ else
+ pcaccp->ctrl = FALSE;
+ savePciState(pcaccp->arg.tag, &pcaccp->save);
+ pcaccp->arg.ctrl = pcaccp->save.command;
+ }
+}
+
+/*
+ * initPciBusState() - fill out the BusAccRec for a PCI bus.
+ * Theory: each bus is associated with one bridge connecting it
+ * to its parent bus. The address of a bridge is therefore stored
+ * in the BusAccRec of the bus it connects to. Each bus can
+ * have several bridges connecting secondary buses to it. Only one
+ * of these bridges can be open. Therefore the status of a bridge
+ * associated with a bus is stored in the BusAccRec of the parent
+ * the bridge connects to. The first member of the structure is
+ * a pointer to a function that open access to this bus. This function
+ * receives a pointer to the structure itself as argument. This
+ * design should be common to BusAccRecs of any type of buses we
+ * support. The remeinder of the structure is bus type specific.
+ * In this case it contains a pointer to the structure of the
+ * parent bus. Thus enabling access to a specific bus is simple:
+ * 1. Close any bridge going to secondary buses.
+ * 2. Climb down the ladder and enable any bridge on buses
+ * on the path from the CPU to this bus.
+ */
+
+void
+initPciBusState(void)
+{
+ BusAccPtr pbap, pbap_tmp;
+ PciBusPtr pbp = xf86PciBus;
+ pciBusInfo_t *pBusInfo;
+
+ while (pbp) {
+ pbap = xnfcalloc(1,sizeof(BusAccRec));
+ pbap->busdep.pci.bus = pbp->secondary;
+ pbap->busdep.pci.primary_bus = pbp->primary;
+ pbap->busdep_type = BUS_PCI;
+ pbap->busdep.pci.acc = PCITAG_SPECIAL;
+
+ if ((pbp->secondary >= 0) && (pbp->secondary < pciNumBuses) &&
+ (pBusInfo = pciBusInfo[pbp->secondary]) &&
+ pBusInfo->funcs->pciControlBridge) {
+ pbap->type = BUS_PCI;
+ pbap->save_f = savePciDrvBusState;
+ pbap->restore_f = restorePciDrvBusState;
+ pbap->set_f = pciSetBusAccess;
+ pbap->enable_f = pciDrvBusAccessEnable;
+ pbap->disable_f = pciDrvBusAccessDisable;
+ savePciDrvBusState(pbap);
+ } else switch (pbp->subclass) {
+ case PCI_SUBCLASS_BRIDGE_HOST:
+ pbap->type = BUS_PCI;
+ pbap->set_f = pciSetBusAccess;
+ break;
+ case PCI_SUBCLASS_BRIDGE_PCI:
+ case PCI_SUBCLASS_BRIDGE_CARDBUS:
+ pbap->type = BUS_PCI;
+ pbap->save_f = savePciBusState;
+ pbap->restore_f = restorePciBusState;
+ pbap->set_f = pciSetBusAccess;
+ pbap->enable_f = pciBusAccessEnable;
+ pbap->disable_f = pciBusAccessDisable;
+ pbap->busdep.pci.acc = pciTag(pbp->brbus,pbp->brdev,pbp->brfunc);
+ savePciBusState(pbap);
+ break;
+ case PCI_SUBCLASS_BRIDGE_ISA:
+ case PCI_SUBCLASS_BRIDGE_EISA:
+ case PCI_SUBCLASS_BRIDGE_MC:
+ pbap->type = BUS_ISA;
+ pbap->set_f = pciSetBusAccess;
+ break;
+ }
+ pbap->next = xf86BusAccInfo;
+ xf86BusAccInfo = pbap;
+ pbp = pbp->next;
+ }
+
+ pbap = xf86BusAccInfo;
+
+ while (pbap) {
+ pbap->primary = NULL;
+ if (pbap->busdep_type == BUS_PCI
+ && pbap->busdep.pci.primary_bus > -1) {
+ pbap_tmp = xf86BusAccInfo;
+ while (pbap_tmp) {
+ if (pbap_tmp->busdep_type == BUS_PCI &&
+ pbap_tmp->busdep.pci.bus == pbap->busdep.pci.primary_bus) {
+ /* Don't create loops */
+ if (pbap == pbap_tmp)
+ break;
+ pbap->primary = pbap_tmp;
+ break;
+ }
+ pbap_tmp = pbap_tmp->next;
+ }
+ }
+ pbap = pbap->next;
+ }
+}
+
+void
+PciStateEnter(void)
+{
+ pciAccPtr paccp;
+ int i = 0;
+
+ if (xf86PciAccInfo == NULL)
+ return;
+
+ while ((paccp = xf86PciAccInfo[i]) != NULL) {
+ i++;
+ if (!paccp->ctrl)
+ continue;
+ savePciState(paccp->arg.tag, &paccp->save);
+ restorePciState(paccp->arg.tag, &paccp->restore);
+ paccp->arg.ctrl = paccp->restore.command;
+ }
+}
+
+void
+PciBusStateEnter(void)
+{
+ BusAccPtr pbap = xf86BusAccInfo;
+
+ while (pbap) {
+ if (pbap->save_f)
+ pbap->save_f(pbap);
+ pbap = pbap->next;
+ }
+}
+
+void
+PciStateLeave(void)
+{
+ pciAccPtr paccp;
+ int i = 0;
+
+ if (xf86PciAccInfo == NULL)
+ return;
+
+ while ((paccp = xf86PciAccInfo[i]) != NULL) {
+ i++;
+ if (!paccp->ctrl)
+ continue;
+ savePciState(paccp->arg.tag, &paccp->restore);
+ restorePciState(paccp->arg.tag, &paccp->save);
+ }
+}
+
+void
+PciBusStateLeave(void)
+{
+ BusAccPtr pbap = xf86BusAccInfo;
+
+ while (pbap) {
+ if (pbap->restore_f)
+ pbap->restore_f(pbap);
+ pbap = pbap->next;
+ }
+}
+
+void
+DisablePciAccess(void)
+{
+ int i = 0;
+ pciAccPtr paccp;
+ if (xf86PciAccInfo == NULL)
+ return;
+
+ while ((paccp = xf86PciAccInfo[i]) != NULL) {
+ i++;
+ if (!paccp->ctrl) /* disable devices that are under control initially*/
+ continue;
+ pciIo_MemAccessDisable(paccp->io_memAccess.arg);
+ }
+}
+
+void
+DisablePciBusAccess(void)
+{
+ BusAccPtr pbap = xf86BusAccInfo;
+
+ while (pbap) {
+ if (pbap->disable_f)
+ pbap->disable_f(pbap);
+ if (pbap->primary)
+ pbap->primary->current = NULL;
+ pbap = pbap->next;
+ }
+}
+
+/*
+ * Public functions
+ */
+
+Bool
+xf86IsPciDevPresent(int bus, int dev, int func)
+{
+ int i = 0;
+ pciConfigPtr pcp;
+
+ while ((pcp = xf86PciInfo[i]) != NULL) {
+ if ((pcp->busnum == bus)
+ && (pcp->devnum == dev)
+ && (pcp->funcnum == func))
+ return TRUE;
+ i++;
+ }
+ return FALSE;
+}
+
+/*
+ * If the slot requested is already in use, return -1.
+ * Otherwise, claim the slot for the screen requesting it.
+ */
+
+int
+xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp,
+ int chipset, GDevPtr dev, Bool active)
+{
+ EntityPtr p = NULL;
+ pciAccPtr *ppaccp = xf86PciAccInfo;
+ BusAccPtr pbap = xf86BusAccInfo;
+
+ int num;
+
+ if (xf86CheckPciSlot(bus, device, func)) {
+ num = xf86AllocateEntity();
+ p = xf86Entities[num];
+ p->driver = drvp;
+ p->chipset = chipset;
+ p->busType = BUS_PCI;
+ p->pciBusId.bus = bus;
+ p->pciBusId.device = device;
+ p->pciBusId.func = func;
+ p->active = active;
+ p->inUse = FALSE;
+ if (dev)
+ xf86AddDevToEntity(num, dev);
+ /* Here we initialize the access structure */
+ p->access = xnfcalloc(1,sizeof(EntityAccessRec));
+ while (ppaccp && *ppaccp) {
+ if ((*ppaccp)->busnum == bus
+ && (*ppaccp)->devnum == device
+ && (*ppaccp)->funcnum == func) {
+ p->access->fallback = &(*ppaccp)->io_memAccess;
+ p->access->pAccess = &(*ppaccp)->io_memAccess;
+ (*ppaccp)->ctrl = TRUE; /* mark control if not already */
+ break;
+ }
+ ppaccp++;
+ }
+ if (!ppaccp || !*ppaccp) {
+ p->access->fallback = &AccessNULL;
+ p->access->pAccess = &AccessNULL;
+ }
+
+ p->busAcc = NULL;
+ while (pbap) {
+ if (pbap->type == BUS_PCI && pbap->busdep.pci.bus == bus)
+ p->busAcc = pbap;
+ pbap = pbap->next;
+ }
+ fixPciSizeInfo(num);
+
+ /* in case bios is enabled disable it */
+ disablePciBios(pciTag(bus,device,func));
+ pciSlotClaimed = TRUE;
+
+ if (active) {
+ /* Map in this domain's I/O space */
+ p->domainIO = xf86MapDomainIO(-1, VIDMEM_MMIO,
+ pciTag(bus, device, func), 0, 1);
+ }
+
+ return num;
+ } else
+ return -1;
+}
+
+/*
+ * Get xf86PciVideoInfo for a driver.
+ */
+pciVideoPtr *
+xf86GetPciVideoInfo(void)
+{
+ return xf86PciVideoInfo;
+}
+
+/* --- Used by ATI driver, but also more generally useful */
+
+/*
+ * Get the full xf86scanpci data.
+ */
+pciConfigPtr *
+xf86GetPciConfigInfo(void)
+{
+ return xf86PciInfo;
+}
+
+/*
+ * Enable a device and route VGA to it. This is intended for a driver's
+ * Probe(), before creating EntityRec's. Only one device can be thus enabled
+ * at any one time, and should be disabled when the driver is done with it.
+ *
+ * The following special calls are also available:
+ *
+ * pvp == NULL && rt == NONE disable previously enabled device
+ * pvp != NULL && rt == NONE ensure device is disabled
+ * pvp == NULL && rt != NONE disable >all< subsequent calls to this function
+ * (done from xf86PostProbe())
+ * The last combination has been removed! To do this cleanly we have
+ * to implement stages and need to test at each stage dependent function
+ * if it is allowed to execute.
+ *
+ * The device represented by pvp may not have been previously claimed.
+ */
+void
+xf86SetPciVideo(pciVideoPtr pvp, resType rt)
+{
+ static BusAccPtr pbap = NULL;
+ static xf86AccessPtr pAcc = NULL;
+ static Bool DoneProbes = FALSE;
+ pciAccPtr pcaccp;
+ int i;
+
+ if (DoneProbes)
+ return;
+
+ /* Disable previous access */
+ if (pAcc) {
+ if (pAcc->AccessDisable)
+ (*pAcc->AccessDisable)(pAcc->arg);
+ pAcc = NULL;
+ }
+ if (pbap) {
+ while (pbap->primary) {
+ if (pbap->disable_f)
+ (*pbap->disable_f)(pbap);
+ pbap->primary->current = NULL;
+ pbap = pbap->primary;
+ }
+ pbap = NULL;
+ }
+
+ /* Check for xf86PostProbe's magic combo */
+ if (!pvp) {
+ if (rt != NONE)
+ DoneProbes = TRUE;
+ return;
+ }
+
+ /* Validate device */
+ if (!xf86PciVideoInfo || !xf86PciAccInfo || !xf86BusAccInfo)
+ return;
+
+ for (i = 0; pvp != xf86PciVideoInfo[i]; i++)
+ if (!xf86PciVideoInfo[i])
+ return;
+
+ /* Ignore request for claimed adapters */
+ if (!xf86CheckPciSlot(pvp->bus, pvp->device, pvp->func))
+ return;
+
+ /* Find pciAccRec structure */
+ for (i = 0; ; i++) {
+ if (!(pcaccp = xf86PciAccInfo[i]))
+ return;
+ if ((pvp->bus == pcaccp->busnum) &&
+ (pvp->device == pcaccp->devnum) &&
+ (pvp->func == pcaccp->funcnum))
+ break;
+ }
+
+ if (rt == NONE) {
+ /* This is a call to ensure the adapter is disabled */
+ if (pcaccp->io_memAccess.AccessDisable)
+ (*pcaccp->io_memAccess.AccessDisable)(pcaccp->io_memAccess.arg);
+ return;
+ }
+
+ /* Find BusAccRec structure */
+ for (pbap = xf86BusAccInfo; ; pbap = pbap->next) {
+ if (!pbap)
+ return;
+ if (pvp->bus == pbap->busdep.pci.bus)
+ break;
+ }
+
+ /* Route VGA */
+ if (pbap->set_f)
+ (*pbap->set_f)(pbap);
+
+ /* Enable device */
+ switch (rt) {
+ case IO:
+ pAcc = &pcaccp->ioAccess;
+ break;
+ case MEM_IO:
+ pAcc = &pcaccp->io_memAccess;
+ break;
+ case MEM:
+ pAcc = &pcaccp->memAccess;
+ break;
+ default: /* no compiler noise */
+ break;
+ }
+
+ if (pAcc && pAcc->AccessEnable)
+ (*pAcc->AccessEnable)(pAcc->arg);
+}
+
+/*
+ * Parse a BUS ID string, and return the PCI bus parameters if it was
+ * in the correct format for a PCI bus id.
+ */
+
+Bool
+xf86ParsePciBusString(const char *busID, int *bus, int *device, int *func)
+{
+ /*
+ * The format is assumed to be "bus[@domain]:device[:func]", where domain,
+ * bus, device and func are decimal integers. domain and func may be
+ * omitted and assumed to be zero, although doing this isn't encouraged.
+ */
+
+ char *p, *s, *d;
+ const char *id;
+ int i;
+
+ if (StringToBusType(busID, &id) != BUS_PCI)
+ return FALSE;
+
+ s = xstrdup(id);
+ p = strtok(s, ":");
+ if (p == NULL || *p == 0) {
+ xfree(s);
+ return FALSE;
+ }
+ d = strpbrk(p, "@");
+ if (d != NULL) {
+ *(d++) = 0;
+ for (i = 0; d[i] != 0; i++) {
+ if (!isdigit(d[i])) {
+ xfree(s);
+ return FALSE;
+ }
+ }
+ }
+ for (i = 0; p[i] != 0; i++) {
+ if (!isdigit(p[i])) {
+ xfree(s);
+ return FALSE;
+ }
+ }
+ *bus = atoi(p);
+ if (d != NULL && *d != 0)
+ *bus += atoi(d) << 8;
+ p = strtok(NULL, ":");
+ if (p == NULL || *p == 0) {
+ xfree(s);
+ return FALSE;
+ }
+ for (i = 0; p[i] != 0; i++) {
+ if (!isdigit(p[i])) {
+ xfree(s);
+ return FALSE;
+ }
+ }
+ *device = atoi(p);
+ *func = 0;
+ p = strtok(NULL, ":");
+ if (p == NULL || *p == 0) {
+ xfree(s);
+ return TRUE;
+ }
+ for (i = 0; p[i] != 0; i++) {
+ if (!isdigit(p[i])) {
+ xfree(s);
+ return FALSE;
+ }
+ }
+ *func = atoi(p);
+ xfree(s);
+ return TRUE;
+}
+
+/*
+ * Compare a BUS ID string with a PCI bus id. Return TRUE if they match.
+ */
+
+Bool
+xf86ComparePciBusString(const char *busID, int bus, int device, int func)
+{
+ int ibus, idevice, ifunc;
+
+ if (xf86ParsePciBusString(busID, &ibus, &idevice, &ifunc)) {
+ return bus == ibus && device == idevice && func == ifunc;
+ } else {
+ return FALSE;
+ }
+}
+
+/*
+ * xf86IsPrimaryPci() -- return TRUE if primary device
+ * is PCI and bus, dev and func numbers match.
+ */
+
+Bool
+xf86IsPrimaryPci(pciVideoPtr pPci)
+{
+ if (primaryBus.type != BUS_PCI) return FALSE;
+ return (pPci->bus == primaryBus.id.pci.bus &&
+ pPci->device == primaryBus.id.pci.device &&
+ pPci->func == primaryBus.id.pci.func);
+}
+
+/*
+ * xf86CheckPciGAType() -- return type of PCI graphics adapter.
+ */
+int
+xf86CheckPciGAType(pciVideoPtr pPci)
+{
+ int i = 0;
+ pciConfigPtr pcp;
+
+ while ((pcp = xf86PciInfo[i]) != NULL) {
+ if (pPci->bus == pcp->busnum && pPci->device == pcp->devnum
+ && pPci->func == pcp->funcnum) {
+ if (pcp->pci_base_class == PCI_CLASS_PREHISTORIC &&
+ pcp->pci_sub_class == PCI_SUBCLASS_PREHISTORIC_VGA)
+ return PCI_CHIP_VGA ;
+ if (pcp->pci_base_class == PCI_CLASS_DISPLAY &&
+ pcp->pci_sub_class == PCI_SUBCLASS_DISPLAY_VGA) {
+ if (pcp->pci_prog_if == 0)
+ return PCI_CHIP_VGA ;
+ if (pcp->pci_prog_if == 1)
+ return PCI_CHIP_8514;
+ }
+ return -1;
+ }
+ i++;
+ }
+ return -1;
+}
+
+/*
+ * xf86GetPciInfoForEntity() -- Get the pciVideoRec of entity.
+ */
+pciVideoPtr
+xf86GetPciInfoForEntity(int entityIndex)
+{
+ pciVideoPtr *ppPci;
+ EntityPtr p;
+
+ if (entityIndex >= xf86NumEntities)
+ return NULL;
+
+ p = xf86Entities[entityIndex];
+ if (p->busType != BUS_PCI)
+ return NULL;
+
+ for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) {
+ if (p->pciBusId.bus == (*ppPci)->bus &&
+ p->pciBusId.device == (*ppPci)->device &&
+ p->pciBusId.func == (*ppPci)->func)
+ return (*ppPci);
+ }
+ return NULL;
+}
+
+int
+xf86GetPciEntity(int bus, int dev, int func)
+{
+ int i;
+
+ for (i = 0; i < xf86NumEntities; i++) {
+ EntityPtr p = xf86Entities[i];
+ if (p->busType != BUS_PCI) continue;
+
+ if (p->pciBusId.bus == bus &&
+ p->pciBusId.device == dev &&
+ p->pciBusId.func == func)
+ return i;
+ }
+ return -1;
+}
+
+/*
+ * xf86CheckPciMemBase() checks that the memory base value matches one of the
+ * PCI base address register values for the given PCI device.
+ */
+Bool
+xf86CheckPciMemBase(pciVideoPtr pPci, memType base)
+{
+ int i;
+
+ for (i = 0; i < 6; i++)
+ if (base == pPci->memBase[i])
+ return TRUE;
+ return FALSE;
+}
+
+/*
+ * Check if the slot requested is free. If it is already in use, return FALSE.
+ */
+
+Bool
+xf86CheckPciSlot(int bus, int device, int func)
+{
+ int i;
+ EntityPtr p;
+
+ for (i = 0; i < xf86NumEntities; i++) {
+ p = xf86Entities[i];
+ /* Check if this PCI slot is taken */
+ if (p->busType == BUS_PCI && p->pciBusId.bus == bus &&
+ p->pciBusId.device == device && p->pciBusId.func == func)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * This used to load the scanpci module. The pcidata module is now used
+ * (which the server always loads early). The main difference between the
+ * two modules is size, and the scanpci module should only ever be loaded
+ * when the X server is run with the -scanpci flag.
+ *
+ * To make sure that the required information is present in the pcidata
+ * module, add a PCI_VENDOR_* macro for the relevant vendor to xf86PciInfo.h,
+ * and add the class override data to ../etc/extrapci.ids.
+ */
+
+static void
+getPciClassFlags(pciConfigPtr *pcrpp)
+{
+ pciConfigPtr pcrp;
+ int i = 0;
+
+ if (!pcrpp)
+ return;
+ while ((pcrp = pcrpp[i])) {
+ if (!(pcrp->listed_class =
+ xf86FindPciClassBySubsys(pcrp->pci_subsys_vendor,
+ pcrp->pci_subsys_card))) {
+ pcrp->listed_class =
+ xf86FindPciClassByDevice(pcrp->pci_vendor, pcrp->pci_device);
+ }
+ i++;
+ }
+}
+
+/*
+ * xf86FindPciVendorDevice() xf86FindPciClass(): These functions
+ * are meant to be used by the pci bios emulation. Some bioses
+ * need to see if there are _other_ chips of the same type around
+ * so by setting pvp_exclude one pci device can be explicitely
+ * _excluded if required.
+ */
+pciVideoPtr
+xf86FindPciDeviceVendor(CARD16 vendorID, CARD16 deviceID,
+ char n, pciVideoPtr pvp_exclude)
+{
+ pciVideoPtr pvp, *ppvp;
+ n++;
+
+ for (ppvp = xf86PciVideoInfo, pvp =*ppvp; pvp ; pvp = *(++ppvp)) {
+ if (pvp == pvp_exclude) continue;
+ if ((pvp->vendor == vendorID) && (pvp->chipType == deviceID)) {
+ if (!(--n)) break;
+ }
+ }
+ return pvp;
+}
+
+pciVideoPtr
+xf86FindPciClass(CARD8 intf, CARD8 subClass, CARD16 class,
+ char n, pciVideoPtr pvp_exclude)
+{
+ pciVideoPtr pvp, *ppvp;
+ n++;
+
+ for (ppvp = xf86PciVideoInfo, pvp =*ppvp; pvp ; pvp = *(++ppvp)) {
+ if (pvp == pvp_exclude) continue;
+ if ((pvp->interface == intf) && (pvp->subclass == subClass)
+ && (pvp->class == class)) {
+ if (!(--n)) break;
+ }
+ }
+ return pvp;
+}
+
+/*
+ * This attempts to detect a multi-device card and sets up a list
+ * of pci tags of the devices of this card. On some of these
+ * cards the BIOS is not visible from all chipsets. We therefore
+ * need to use the BIOS from a chipset where it is visible.
+ * We do the following heuristics:
+ * If we detect only identical pci devices on a bus we assume it's
+ * a multi-device card. This assumption isn't true always, however.
+ * One might just use identical cards on a bus. We therefore don't
+ * detect this situation when we set up the PCI video info. Instead
+ * we wait until an attempt to read the BIOS fails.
+ */
+int
+pciTestMultiDeviceCard(int bus, int dev, int func, PCITAG** pTag)
+{
+ pciConfigPtr *ppcrp = xf86PciInfo;
+ pciConfigPtr pcrp = NULL;
+ int i,j;
+ Bool multicard = FALSE;
+ Bool multifunc = FALSE;
+ char str[256];
+ char *str1;
+
+ str1 = str;
+ if (!pTag)
+ return 0;
+
+ *pTag = NULL;
+
+ for (i=0; i < 8; i++) {
+ j = 0;
+
+ while (ppcrp[j]) {
+ if (ppcrp[j]->busnum == bus && ppcrp[j]->funcnum == i) {
+ pcrp = ppcrp[j];
+ break;
+ }
+ j++;
+ }
+
+ if (!pcrp) return 0;
+
+ /*
+ * we check all functions here: since multifunc devices need
+ * to implement func 0 we catch all devices on the bus when
+ * i = 0
+ */
+ if (pcrp->pci_header_type &0x80)
+ multifunc = TRUE;
+
+ j = 0;
+
+ while (ppcrp[j]) {
+ if (ppcrp[j]->busnum == bus && ppcrp[j]->funcnum == i
+ && ppcrp[j]->devnum != pcrp->devnum) {
+ /* don't test subsys ID here. It might be set by POST
+ - however some cards might not have been POSTed */
+ if (ppcrp[j]->pci_device_vendor != pcrp->pci_device_vendor
+ || ppcrp[j]->pci_header_type != pcrp->pci_header_type )
+ return 0;
+ else
+ multicard = TRUE;
+ }
+ j++;
+ }
+ if (!multifunc)
+ break;
+ }
+
+ if (!multicard)
+ return 0;
+
+ j = 0;
+ i = 0;
+ while (ppcrp[i]) {
+ if (ppcrp[i]->busnum == bus && ppcrp[i]->funcnum == func) {
+ str1 += sprintf(str1,"[%x:%x:%x]",ppcrp[i]->busnum,
+ ppcrp[i]->devnum,ppcrp[i]->funcnum);
+ *pTag = xnfrealloc(*pTag,sizeof(PCITAG) * (j + 1));
+ (*pTag)[j++] = pciTag(ppcrp[i]->busnum,
+ ppcrp[i]->devnum,ppcrp[i]->funcnum);
+ }
+ i++;
+ }
+ xf86MsgVerb(X_INFO,3,"Multi Device Card detected: %s\n",str);
+ return j;
+}
+
+static void
+pciTagConvertRange2Host(PCITAG tag, resRange *pRange)
+{
+ if (!(pRange->type & ResBus))
+ return;
+
+ switch(pRange->type & ResPhysMask) {
+ case ResMem:
+ switch(pRange->type & ResExtMask) {
+ case ResBlock:
+ pRange->rBegin = pciBusAddrToHostAddr(tag,PCI_MEM, pRange->rBegin);
+ pRange->rEnd = pciBusAddrToHostAddr(tag,PCI_MEM, pRange->rEnd);
+ break;
+ case ResSparse:
+ pRange->rBase = pciBusAddrToHostAddr(tag,PCI_MEM_SPARSE_BASE,
+ pRange->rBegin);
+ pRange->rMask = pciBusAddrToHostAddr(tag,PCI_MEM_SPARSE_MASK,
+ pRange->rEnd);
+ break;
+ }
+ break;
+ case ResIo:
+ switch(pRange->type & ResExtMask) {
+ case ResBlock:
+ pRange->rBegin = pciBusAddrToHostAddr(tag,PCI_IO, pRange->rBegin);
+ pRange->rEnd = pciBusAddrToHostAddr(tag,PCI_IO, pRange->rEnd);
+ break;
+ case ResSparse:
+ pRange->rBase = pciBusAddrToHostAddr(tag,PCI_IO_SPARSE_BASE
+ , pRange->rBegin);
+ pRange->rMask = pciBusAddrToHostAddr(tag,PCI_IO_SPARSE_MASK
+ , pRange->rEnd);
+ break;
+ }
+ break;
+ }
+
+ /* Set domain number */
+ pRange->type &= ~(ResDomain | ResBus);
+ pRange->type |= xf86GetPciDomain(tag) << 24;
+}
+
+static void
+pciConvertListToHost(int bus, int dev, int func, resPtr list)
+{
+ PCITAG tag = pciTag(bus,dev,func);
+ while (list) {
+ pciTagConvertRange2Host(tag, &list->val);
+ list = list->next;
+ }
+}
+
+static void
+updateAccessInfoStatusControlInfo(PCITAG tag, CARD32 ctrl)
+{
+ int i;
+
+ if (!xf86PciAccInfo)
+ return;
+
+ for (i = 0; xf86PciAccInfo[i] != NULL; i++) {
+ if (xf86PciAccInfo[i]->arg.tag == tag)
+ xf86PciAccInfo[i]->arg.ctrl = ctrl;
+ }
+}
+
+void
+pciConvertRange2Host(int entityIndex, resRange *pRange)
+{
+ PCITAG tag;
+ pciVideoPtr pvp;
+
+ pvp = xf86GetPciInfoForEntity(entityIndex);
+ if (!pvp) return;
+ tag = TAG(pvp);
+ pciTagConvertRange2Host(tag, pRange);
+}
+
+
+#ifdef INCLUDE_DEPRECATED
+void
+xf86EnablePciBusMaster(pciVideoPtr pPci, Bool enable)
+{
+ CARD32 temp;
+ PCITAG tag;
+
+ if (!pPci) return;
+
+ tag = pciTag(pPci->bus, pPci->device, pPci->func);
+ temp = pciReadLong(tag, PCI_CMD_STAT_REG);
+ if (enable) {
+ updateAccessInfoStatusControlInfo(tag, temp | PCI_CMD_MASTER_ENABLE);
+ pciWriteLong(tag, PCI_CMD_STAT_REG, temp | PCI_CMD_MASTER_ENABLE);
+ } else {
+ updateAccessInfoStatusControlInfo(tag, temp & ~PCI_CMD_MASTER_ENABLE);
+ pciWriteLong(tag, PCI_CMD_STAT_REG, temp & ~PCI_CMD_MASTER_ENABLE);
+ }
+}
+#endif /* INCLUDE_DEPRECATED */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86pciBus.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86pciBus.h
new file mode 100644
index 000000000..75d82fbcf
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86pciBus.h
@@ -0,0 +1,99 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86pciBus.h,v 3.10 2003/08/24 17:36:56 dawes Exp $ */
+
+/*
+ * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _XF86_PCI_BUS_H
+#define _XF86_PCI_BUS_H
+
+#define PCITAG_SPECIAL pciTag(0xFF,0xFF,0xFF)
+
+typedef struct {
+ CARD32 command;
+ CARD32 base[6];
+ CARD32 biosBase;
+} pciSave, *pciSavePtr;
+
+typedef struct {
+ PCITAG tag;
+ CARD32 ctrl;
+} pciArg;
+
+typedef struct {
+ int busnum;
+ int devnum;
+ int funcnum;
+ pciArg arg;
+ xf86AccessRec ioAccess;
+ xf86AccessRec io_memAccess;
+ xf86AccessRec memAccess;
+ pciSave save;
+ pciSave restore;
+ Bool ctrl;
+} pciAccRec, *pciAccPtr;
+
+typedef union {
+ CARD16 control;
+} pciBridgesSave, *pciBridgesSavePtr;
+
+typedef struct pciBusRec {
+ int brbus, brdev, brfunc; /* ID of the bridge to this bus */
+ int primary, secondary, subordinate;
+ int subclass; /* bridge type */
+ int interface;
+ resPtr preferred_io; /* I/O range */
+ resPtr preferred_mem; /* non-prefetchable memory range */
+ resPtr preferred_pmem; /* prefetchable memory range */
+ resPtr io; /* for subtractive PCI-PCI bridges */
+ resPtr mem;
+ resPtr pmem;
+ int brcontrol; /* bridge_control byte */
+ struct pciBusRec *next;
+} PciBusRec, *PciBusPtr;
+
+void xf86PciProbe(void);
+void ValidatePci(void);
+resList GetImplicitPciResources(int entityIndex);
+void initPciState(void);
+void initPciBusState(void);
+void DisablePciAccess(void);
+void DisablePciBusAccess(void);
+void PciStateEnter(void);
+void PciBusStateEnter(void);
+void PciStateLeave(void);
+void PciBusStateLeave(void);
+resPtr ResourceBrokerInitPci(resPtr *osRes);
+void pciConvertRange2Host(int entityIndex, resRange *pRange);
+void isaConvertRange2Host(resRange *pRange);
+
+extern pciAccPtr * xf86PciAccInfo;
+
+#endif /* _XF86_PCI_BUS_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86sbusBus.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86sbusBus.c
new file mode 100644
index 000000000..3d6576f52
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86sbusBus.c
@@ -0,0 +1,709 @@
+/*
+ * SBUS bus-specific code.
+ *
+ * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.c,v 3.6 2001/03/03 22:16:35 tsi Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86Resources.h"
+#include "xf86cmap.h"
+
+#include "xf86Bus.h"
+
+#include "xf86sbusBus.h"
+#include "xf86Sbus.h"
+
+Bool sbusSlotClaimed = FALSE;
+
+static int xf86nSbusInfo;
+
+static void
+CheckSbusDevice(const char *device, int fbNum)
+{
+ int fd, i;
+ struct fbgattr fbattr;
+ sbusDevicePtr psdp;
+
+ fd = open(device, O_RDONLY, 0);
+ if (fd < 0)
+ return;
+ memset(&fbattr, 0, sizeof(fbattr));
+ if (ioctl(fd, FBIOGATTR, &fbattr) < 0) {
+ if (ioctl(fd, FBIOGTYPE, &fbattr.fbtype) < 0) {
+ close(fd);
+ return;
+ }
+ }
+ close(fd);
+ for (i = 0; sbusDeviceTable[i].devId; i++)
+ if (sbusDeviceTable[i].fbType == fbattr.fbtype.fb_type)
+ break;
+ if (! sbusDeviceTable[i].devId)
+ return;
+ xf86SbusInfo = xnfrealloc(xf86SbusInfo, sizeof(psdp) * (++xf86nSbusInfo + 1));
+ xf86SbusInfo[xf86nSbusInfo] = NULL;
+ xf86SbusInfo[xf86nSbusInfo - 1] = psdp = xnfcalloc(sizeof (sbusDevice), 1);
+ psdp->devId = sbusDeviceTable[i].devId;
+ psdp->fbNum = fbNum;
+ psdp->device = xnfstrdup(device);
+ psdp->width = fbattr.fbtype.fb_width;
+ psdp->height = fbattr.fbtype.fb_height;
+ psdp->fd = -1;
+}
+
+void
+xf86SbusProbe(void)
+{
+ int i, useProm = 0;
+ char fbDevName[32];
+ sbusDevicePtr psdp, *psdpp;
+
+ xf86SbusInfo = xalloc(sizeof(psdp));
+ *xf86SbusInfo = NULL;
+ for (i = 0; i < 32; i++) {
+ sprintf(fbDevName, "/dev/fb%d", i);
+ CheckSbusDevice(fbDevName, i);
+ }
+ if (sparcPromInit() >= 0) {
+ useProm = 1;
+ sparcPromAssignNodes();
+ }
+ for (psdpp = xf86SbusInfo; (psdp = *psdpp); psdpp++) {
+ for (i = 0; sbusDeviceTable[i].devId; i++)
+ if (sbusDeviceTable[i].devId == psdp->devId)
+ psdp->descr = sbusDeviceTable[i].descr;
+ /*
+ * If we can use PROM information and found the PROM node for this
+ * device, we can tell more about the card.
+ */
+ if (useProm && psdp->node.node) {
+ char *prop, *promPath;
+ int len, chiprev, vmsize;
+
+ switch (psdp->devId) {
+ case SBUS_DEVICE_MGX:
+ prop = sparcPromGetProperty(&psdp->node, "fb_size", &len);
+ if (prop && len == 4 && *(int *)prop == 0x400000)
+ psdp->descr = "Quantum 3D MGXplus with 4M VRAM";
+ break;
+ case SBUS_DEVICE_CG6:
+ chiprev = 0;
+ vmsize = 0;
+ prop = sparcPromGetProperty(&psdp->node, "chiprev", &len);
+ if (prop && len == 4)
+ chiprev = *(int *)prop;
+ prop = sparcPromGetProperty(&psdp->node, "vmsize", &len);
+ if (prop && len == 4)
+ vmsize = *(int *)prop;
+ switch (chiprev) {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ psdp->descr = "Sun Double width GX"; break;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ psdp->descr = "Sun Single width GX"; break;
+ case 11:
+ switch (vmsize) {
+ case 2:
+ psdp->descr = "Sun Turbo GX with 1M VSIMM"; break;
+ case 4:
+ psdp->descr = "Sun Turbo GX Plus"; break;
+ default:
+ psdp->descr = "Sun Turbo GX"; break;
+ }
+ }
+ break;
+ case SBUS_DEVICE_CG14:
+ prop = sparcPromGetProperty(&psdp->node, "reg", &len);
+ vmsize = 0;
+ if (prop && !(len % 12) && len > 0)
+ vmsize = *(int *)(prop + len - 4);
+ switch (vmsize) {
+ case 0x400000:
+ psdp->descr = "Sun SX with 4M VSIMM"; break;
+ case 0x800000:
+ psdp->descr = "Sun SX with 8M VSIMM"; break;
+ }
+ break;
+ case SBUS_DEVICE_LEO:
+ prop = sparcPromGetProperty(&psdp->node, "model", &len);
+ if (prop && len > 0 && !strstr(prop, "501-2503"))
+ psdp->descr = "Sun Turbo ZX";
+ break;
+ case SBUS_DEVICE_TCX:
+ if (sparcPromGetBool(&psdp->node, "tcx-8-bit"))
+ psdp->descr = "Sun TCX (8bit)";
+ else
+ psdp->descr = "Sun TCX (S24)";
+ break;
+ case SBUS_DEVICE_FFB:
+ prop = sparcPromGetProperty(&psdp->node, "name", &len);
+ chiprev = 0;
+ prop = sparcPromGetProperty(&psdp->node, "board_type", &len);
+ if (prop && len == 4)
+ chiprev = *(int *)prop;
+ if (strstr (prop, "afb")) {
+ if (chiprev == 3)
+ psdp->descr = "Sun|Elite3D-M6 Horizontal";
+ } else {
+ switch (chiprev) {
+ case 0x08:
+ psdp->descr = "Sun FFB 67MHz Creator"; break;
+ case 0x0b:
+ psdp->descr = "Sun FFB 67MHz Creator 3D"; break;
+ case 0x1b:
+ psdp->descr = "Sun FFB 75MHz Creator 3D"; break;
+ case 0x20:
+ case 0x28:
+ psdp->descr = "Sun FFB2 Vertical Creator"; break;
+ case 0x23:
+ case 0x2b:
+ psdp->descr = "Sun FFB2 Vertical Creator 3D"; break;
+ case 0x30:
+ psdp->descr = "Sun FFB2+ Vertical Creator"; break;
+ case 0x33:
+ psdp->descr = "Sun FFB2+ Vertical Creator 3D"; break;
+ case 0x40:
+ case 0x48:
+ psdp->descr = "Sun FFB2 Horizontal Creator"; break;
+ case 0x43:
+ case 0x4b:
+ psdp->descr = "Sun FFB2 Horizontal Creator 3D"; break;
+ }
+ }
+ break;
+ }
+
+ xf86Msg(X_PROBED, "SBUS:(0x%08x) %s", psdp->node.node, psdp->descr);
+ promPath = sparcPromNode2Pathname (&psdp->node);
+ if (promPath) {
+ xf86ErrorF(" at %s", promPath);
+ xfree(promPath);
+ }
+ } else
+ xf86Msg(X_PROBED, "SBUS: %s", psdp->descr);
+ xf86ErrorF("\n");
+ }
+ if (useProm)
+ sparcPromClose();
+}
+
+/*
+ * Parse a BUS ID string, and return the SBUS bus parameters if it was
+ * in the correct format for a SBUS bus id.
+ */
+
+Bool
+xf86ParseSbusBusString(const char *busID, int *fbNum)
+{
+ /*
+ * The format is assumed to be one of:
+ * "fbN", e.g. "fb1", which means the device corresponding to /dev/fbN
+ * "nameN", e.g. "cgsix0", which means Nth instance of card NAME
+ * "/prompath", e.g. "/sbus@0,10001000/cgsix@3,0" which is PROM pathname
+ * to the device.
+ */
+
+ const char *id;
+ int i, len;
+
+ if (StringToBusType(busID, &id) != BUS_SBUS)
+ return FALSE;
+
+ if (*id != '/') {
+ if (!strncmp (id, "fb", 2)) {
+ if (!isdigit(id[2]))
+ return FALSE;
+ *fbNum = atoi(id + 2);
+ return TRUE;
+ } else {
+ sbusDevicePtr *psdpp;
+ int devId;
+
+ for (i = 0, len = 0; sbusDeviceTable[i].devId; i++) {
+ len = strlen(sbusDeviceTable[i].promName);
+ if (!strncmp (sbusDeviceTable[i].promName, id, len)
+ && isdigit(id[len]))
+ break;
+ }
+ devId = sbusDeviceTable[i].devId;
+ if (!devId) return FALSE;
+ i = atoi(id + len);
+ for (psdpp = xf86SbusInfo; *psdpp; ++psdpp) {
+ if ((*psdpp)->devId != devId)
+ continue;
+ if (!i) {
+ *fbNum = (*psdpp)->fbNum;
+ return TRUE;
+ }
+ i--;
+ }
+ }
+ return FALSE;
+ }
+
+ if (sparcPromInit() >= 0) {
+ i = sparcPromPathname2Node(id);
+ sparcPromClose();
+ if (i) {
+ sbusDevicePtr *psdpp;
+ for (psdpp = xf86SbusInfo; *psdpp; ++psdpp) {
+ if ((*psdpp)->node.node == i) {
+ *fbNum = (*psdpp)->fbNum;
+ return TRUE;
+ }
+ }
+ }
+ }
+ return FALSE;
+}
+
+/*
+ * Compare a BUS ID string with a SBUS bus id. Return TRUE if they match.
+ */
+
+Bool
+xf86CompareSbusBusString(const char *busID, int fbNum)
+{
+ int iFbNum;
+
+ if (xf86ParseSbusBusString(busID, &iFbNum)) {
+ return fbNum == iFbNum;
+ } else {
+ return FALSE;
+ }
+}
+
+/*
+ * Check if the slot requested is free. If it is already in use, return FALSE.
+ */
+
+Bool
+xf86CheckSbusSlot(int fbNum)
+{
+ int i;
+ EntityPtr p;
+
+ for (i = 0; i < xf86NumEntities; i++) {
+ p = xf86Entities[i];
+ /* Check if this SBUS slot is taken */
+ if (p->busType == BUS_SBUS && p->sbusBusId.fbNum == fbNum)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*
+ * If the slot requested is already in use, return -1.
+ * Otherwise, claim the slot for the screen requesting it.
+ */
+
+int
+xf86ClaimSbusSlot(sbusDevicePtr psdp, DriverPtr drvp,
+ GDevPtr dev, Bool active)
+{
+ EntityPtr p = NULL;
+
+ int num;
+
+ if (xf86CheckSbusSlot(psdp->fbNum)) {
+ num = xf86AllocateEntity();
+ p = xf86Entities[num];
+ p->driver = drvp;
+ p->chipset = -1;
+ p->busType = BUS_SBUS;
+ xf86AddDevToEntity(num, dev);
+ p->sbusBusId.fbNum = psdp->fbNum;
+ p->active = active;
+ p->inUse = FALSE;
+ /* Here we initialize the access structure */
+ p->access = xnfcalloc(1,sizeof(EntityAccessRec));
+ p->access->fallback = &AccessNULL;
+ p->access->pAccess = &AccessNULL;
+ sbusSlotClaimed = TRUE;
+ return num;
+ } else
+ return -1;
+}
+
+int
+xf86MatchSbusInstances(const char *driverName, int sbusDevId,
+ GDevPtr *devList, int numDevs, DriverPtr drvp,
+ int **foundEntities)
+{
+ int i,j;
+ sbusDevicePtr psdp, *psdpp;
+ int numClaimedInstances = 0;
+ int allocatedInstances = 0;
+ int numFound = 0;
+ GDevPtr devBus = NULL;
+ GDevPtr dev = NULL;
+ int *retEntities = NULL;
+ int useProm = 0;
+
+ struct Inst {
+ sbusDevicePtr sbus;
+ GDevPtr dev;
+ Bool claimed; /* BusID matches with a device section */
+ } *instances = NULL;
+
+ *foundEntities = NULL;
+ for (psdpp = xf86SbusInfo, psdp = *psdpp; psdp; psdp = *++psdpp) {
+ if (psdp->devId != sbusDevId)
+ continue;
+ if (psdp->fd == -2)
+ continue;
+ ++allocatedInstances;
+ instances = xnfrealloc(instances,
+ allocatedInstances * sizeof(struct Inst));
+ instances[allocatedInstances - 1].sbus = psdp;
+ instances[allocatedInstances - 1].dev = NULL;
+ instances[allocatedInstances - 1].claimed = FALSE;
+ numFound++;
+ }
+
+ /*
+ * This may be debatable, but if no SBUS devices with a matching vendor
+ * type is found, return zero now. It is probably not desirable to
+ * allow the config file to override this.
+ */
+ if (allocatedInstances <= 0) {
+ xfree(instances);
+ return 0;
+ }
+
+ if (xf86DoProbe) {
+ xfree(instances);
+ return numFound;
+ }
+
+ if (sparcPromInit() >= 0)
+ useProm = 1;
+
+ if (xf86DoConfigure && xf86DoConfigurePass1) {
+ GDevPtr pGDev;
+ int actualcards = 0;
+ for (i = 0; i < allocatedInstances; i++) {
+ actualcards++;
+ pGDev = xf86AddBusDeviceToConfigure(drvp->driverName, BUS_SBUS,
+ instances[i].sbus, -1);
+ if (pGDev) {
+ /*
+ * XF86Match???Instances() treat chipID and chipRev as
+ * overrides, so clobber them here.
+ */
+ pGDev->chipID = pGDev->chipRev = -1;
+ }
+ }
+ xfree(instances);
+ if (useProm)
+ sparcPromClose();
+ return actualcards;
+ }
+
+#ifdef DEBUG
+ ErrorF("%s instances found: %d\n", driverName, allocatedInstances);
+#endif
+
+ for (i = 0; i < allocatedInstances; i++) {
+ char *promPath = NULL;
+
+ psdp = instances[i].sbus;
+ devBus = NULL;
+ dev = NULL;
+ if (useProm && psdp->node.node)
+ promPath = sparcPromNode2Pathname(&psdp->node);
+
+ for (j = 0; j < numDevs; j++) {
+ if (devList[j]->busID && *devList[j]->busID) {
+ if (xf86CompareSbusBusString(devList[j]->busID, psdp->fbNum)) {
+ if (devBus)
+ xf86MsgVerb(X_WARNING,0,
+ "%s: More than one matching Device section for "
+ "instance (BusID: %s) found: %s\n",
+ driverName,devList[j]->identifier,
+ devList[j]->busID);
+ else
+ devBus = devList[j];
+ }
+ } else {
+ if (!dev && !devBus) {
+ if (promPath)
+ xf86Msg(X_PROBED, "Assigning device section with no busID to SBUS:%s\n",
+ promPath);
+ else
+ xf86Msg(X_PROBED, "Assigning device section with no busID to SBUS:fb%d\n",
+ psdp->fbNum);
+ dev = devList[j];
+ } else
+ xf86MsgVerb(X_WARNING, 0,
+ "%s: More than one matching Device section "
+ "found: %s\n", driverName, devList[j]->identifier);
+ }
+ }
+ if (devBus) dev = devBus; /* busID preferred */
+ if (!dev && psdp->fd != -2) {
+ if (promPath) {
+ xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section "
+ "for instance (BusID SBUS:%s) found\n",
+ driverName, promPath);
+ } else
+ xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section "
+ "for instance (BusID SBUS:fb%d) found\n",
+ driverName, psdp->fbNum);
+ } else if (dev) {
+ numClaimedInstances++;
+ instances[i].claimed = TRUE;
+ instances[i].dev = dev;
+ }
+ if (promPath)
+ xfree(promPath);
+ }
+
+#ifdef DEBUG
+ ErrorF("%s instances found: %d\n", driverName, numClaimedInstances);
+#endif
+
+ /*
+ * Of the claimed instances, check that another driver hasn't already
+ * claimed its slot.
+ */
+ numFound = 0;
+ for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
+ if (!instances[i].claimed)
+ continue;
+ psdp = instances[i].sbus;
+ if (!xf86CheckSbusSlot(psdp->fbNum))
+ continue;
+
+#ifdef DEBUG
+ ErrorF("%s: card at fb%d %08x is claimed by a Device section\n",
+ driverName, psdp->fbNum, psdp->node.node);
+#endif
+
+ /* Allocate an entry in the lists to be returned */
+ numFound++;
+ retEntities = xnfrealloc(retEntities, numFound * sizeof(int));
+ retEntities[numFound - 1]
+ = xf86ClaimSbusSlot(psdp, drvp, instances[i].dev,instances[i].dev->active ?
+ TRUE : FALSE);
+ }
+ xfree(instances);
+ if (numFound > 0) {
+ *foundEntities = retEntities;
+ }
+
+ if (useProm)
+ sparcPromClose();
+
+ return numFound;
+}
+
+/*
+ * xf86GetSbusInfoForEntity() -- Get the sbusDevicePtr of entity.
+ */
+sbusDevicePtr
+xf86GetSbusInfoForEntity(int entityIndex)
+{
+ sbusDevicePtr *psdpp;
+ EntityPtr p = xf86Entities[entityIndex];
+
+ if (entityIndex >= xf86NumEntities
+ || p->busType != BUS_SBUS) return NULL;
+
+ for (psdpp = xf86SbusInfo; *psdpp != NULL; psdpp++) {
+ if (p->sbusBusId.fbNum == (*psdpp)->fbNum)
+ return (*psdpp);
+ }
+ return NULL;
+}
+
+int
+xf86GetEntityForSbusInfo(sbusDevicePtr psdp)
+{
+ int i;
+
+ for (i = 0; i < xf86NumEntities; i++) {
+ EntityPtr p = xf86Entities[i];
+ if (p->busType != BUS_SBUS) continue;
+
+ if (p->sbusBusId.fbNum == psdp->fbNum)
+ return i;
+ }
+ return -1;
+}
+
+void
+xf86SbusUseBuiltinMode(ScrnInfoPtr pScrn, sbusDevicePtr psdp)
+{
+ DisplayModePtr mode;
+
+ mode = xnfcalloc(sizeof(DisplayModeRec), 1);
+ mode->name = "current";
+ mode->next = mode;
+ mode->prev = mode;
+ mode->type = M_T_BUILTIN;
+ mode->Clock = 100000000;
+ mode->HDisplay = psdp->width;
+ mode->HSyncStart = psdp->width;
+ mode->HSyncEnd = psdp->width;
+ mode->HTotal = psdp->width;
+ mode->VDisplay = psdp->height;
+ mode->VSyncStart = psdp->height;
+ mode->VSyncEnd = psdp->height;
+ mode->VTotal = psdp->height;
+ mode->SynthClock = mode->Clock;
+ mode->CrtcHDisplay = mode->HDisplay;
+ mode->CrtcHSyncStart = mode->HSyncStart;
+ mode->CrtcHSyncEnd = mode->HSyncEnd;
+ mode->CrtcHTotal = mode->HTotal;
+ mode->CrtcVDisplay = mode->VDisplay;
+ mode->CrtcVSyncStart = mode->VSyncStart;
+ mode->CrtcVSyncEnd = mode->VSyncEnd;
+ mode->CrtcVTotal = mode->VTotal;
+ mode->CrtcHAdjusted = FALSE;
+ mode->CrtcVAdjusted = FALSE;
+ pScrn->modes = mode;
+ pScrn->virtualX = psdp->width;
+ pScrn->virtualY = psdp->height;
+}
+
+static int sbusPaletteIndex = -1;
+static unsigned long sbusPaletteGeneration = 0;
+typedef struct _sbusCmap {
+ sbusDevicePtr psdp;
+ CloseScreenProcPtr CloseScreen;
+ Bool origCmapValid;
+ unsigned char origRed[16];
+ unsigned char origGreen[16];
+ unsigned char origBlue[16];
+} sbusCmapRec, *sbusCmapPtr;
+
+#define SBUSCMAPPTR(pScreen) ((sbusCmapPtr)((pScreen)->devPrivates[sbusPaletteIndex].ptr))
+
+static void
+xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
+ LOCO *colors, VisualPtr pVisual)
+{
+ int i, index;
+ sbusCmapPtr cmap;
+ struct fbcmap fbcmap;
+ unsigned char *data = ALLOCATE_LOCAL(numColors*3);
+
+ cmap = SBUSCMAPPTR(pScrn->pScreen);
+ if (!cmap) return;
+ fbcmap.count = 0;
+ fbcmap.index = indices[0];
+ fbcmap.red = data;
+ fbcmap.green = data + numColors;
+ fbcmap.blue = fbcmap.green + numColors;
+ for (i = 0; i < numColors; i++) {
+ index = indices[i];
+ if (fbcmap.count && index != fbcmap.index + fbcmap.count) {
+ ioctl (cmap->psdp->fd, FBIOPUTCMAP, &fbcmap);
+ fbcmap.count = 0;
+ fbcmap.index = index;
+ }
+ fbcmap.red[fbcmap.count] = colors[index].red;
+ fbcmap.green[fbcmap.count] = colors[index].green;
+ fbcmap.blue[fbcmap.count++] = colors[index].blue;
+ }
+ ioctl (cmap->psdp->fd, FBIOPUTCMAP, &fbcmap);
+ DEALLOCATE_LOCAL(data);
+}
+
+static Bool
+xf86SbusCmapCloseScreen(int i, ScreenPtr pScreen)
+{
+ sbusCmapPtr cmap;
+ struct fbcmap fbcmap;
+
+ cmap = SBUSCMAPPTR(pScreen);
+ if (cmap->origCmapValid) {
+ fbcmap.index = 0;
+ fbcmap.count = 16;
+ fbcmap.red = cmap->origRed;
+ fbcmap.green = cmap->origGreen;
+ fbcmap.blue = cmap->origBlue;
+ ioctl (cmap->psdp->fd, FBIOPUTCMAP, &fbcmap);
+ }
+ pScreen->CloseScreen = cmap->CloseScreen;
+ xfree (cmap);
+ return (*pScreen->CloseScreen) (i, pScreen);
+}
+
+Bool
+xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp)
+{
+ sbusCmapPtr cmap;
+ struct fbcmap fbcmap;
+ unsigned char data[2];
+
+ if(sbusPaletteGeneration != serverGeneration) {
+ if((sbusPaletteIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+ sbusPaletteGeneration = serverGeneration;
+ }
+ cmap = xnfcalloc(1, sizeof(sbusCmapRec));
+ pScreen->devPrivates[sbusPaletteIndex].ptr = cmap;
+ cmap->psdp = psdp;
+ fbcmap.index = 0;
+ fbcmap.count = 16;
+ fbcmap.red = cmap->origRed;
+ fbcmap.green = cmap->origGreen;
+ fbcmap.blue = cmap->origBlue;
+ if (ioctl (psdp->fd, FBIOGETCMAP, &fbcmap) >= 0)
+ cmap->origCmapValid = TRUE;
+ fbcmap.index = 0;
+ fbcmap.count = 2;
+ fbcmap.red = data;
+ fbcmap.green = data;
+ fbcmap.blue = data;
+ if (pScreen->whitePixel == 0) {
+ data[0] = 255;
+ data[1] = 0;
+ } else {
+ data[0] = 0;
+ data[1] = 255;
+ }
+ ioctl (psdp->fd, FBIOPUTCMAP, &fbcmap);
+ cmap->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = xf86SbusCmapCloseScreen;
+ return xf86HandleColormaps(pScreen, 256, 8,
+ xf86SbusCmapLoadPalette, NULL, 0);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86sbusBus.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86sbusBus.h
new file mode 100644
index 000000000..81c1b84ac
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86sbusBus.h
@@ -0,0 +1,98 @@
+/*
+ * SBUS bus-specific declarations
+ *
+ * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.h,v 3.4 2001/10/28 03:33:19 tsi Exp $ */
+
+#ifndef _XF86_SBUSBUS_H
+#define _XF86_SBUSBUS_H
+
+#include "xf86str.h"
+
+#define SBUS_DEVICE_BW2 0x0001
+#define SBUS_DEVICE_CG2 0x0002
+#define SBUS_DEVICE_CG3 0x0003
+#define SBUS_DEVICE_CG4 0x0004
+#define SBUS_DEVICE_CG6 0x0005
+#define SBUS_DEVICE_CG8 0x0006
+#define SBUS_DEVICE_CG12 0x0007
+#define SBUS_DEVICE_CG14 0x0008
+#define SBUS_DEVICE_LEO 0x0009
+#define SBUS_DEVICE_TCX 0x000a
+#define SBUS_DEVICE_FFB 0x000b
+#define SBUS_DEVICE_GT 0x000c
+#define SBUS_DEVICE_MGX 0x000d
+
+typedef struct sbus_prom_node {
+ int node;
+ /* Because of misdesigned openpromio */
+ int cookie[2];
+} sbusPromNode, *sbusPromNodePtr;
+
+typedef struct sbus_device {
+ int devId;
+ int fbNum;
+ int fd;
+ int width, height;
+ sbusPromNode node;
+ char *descr;
+ char *device;
+} sbusDevice, *sbusDevicePtr;
+
+extern struct sbus_devtable {
+ int devId;
+ int fbType;
+ char *promName;
+ char *descr;
+} sbusDeviceTable[];
+
+void xf86SbusProbe(void);
+extern sbusDevicePtr *xf86SbusInfo;
+
+int xf86MatchSbusInstances(const char *driverName, int sbusDevId,
+ GDevPtr *devList, int numDevs, DriverPtr drvp,
+ int **foundEntities);
+sbusDevicePtr xf86GetSbusInfoForEntity(int entityIndex);
+int xf86GetEntityForSbusInfo(sbusDevicePtr psdp);
+void xf86SbusUseBuiltinMode(ScrnInfoPtr pScrn, sbusDevicePtr psdp);
+pointer xf86MapSbusMem(sbusDevicePtr psdp, unsigned long offset,
+ unsigned long size);
+void xf86UnmapSbusMem(sbusDevicePtr psdp, pointer addr, unsigned long size);
+void xf86SbusHideOsHwCursor(sbusDevicePtr psdp);
+void xf86SbusSetOsHwCursorCmap(sbusDevicePtr psdp, int bg, int fg);
+Bool xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp);
+
+extern int promRootNode;
+
+int promGetSibling(int node);
+int promGetChild(int node);
+char * promGetProperty(const char *prop, int *lenp);
+int promGetBool(const char *prop);
+
+int sparcPromInit(void);
+void sparcPromClose(void);
+char * sparcPromGetProperty(sbusPromNodePtr pnode, const char *prop, int *lenp);
+int sparcPromGetBool(sbusPromNodePtr pnode, const char *prop);
+void sparcPromAssignNodes(void);
+char * sparcPromNode2Pathname(sbusPromNodePtr pnode);
+int sparcPromPathname2Node(const char *pathName);
+
+#endif /* _XF86_SBUSBUS_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86str.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86str.h
new file mode 100644
index 000000000..82faaaac1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86str.h
@@ -0,0 +1,1140 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86str.h,v 1.97 2003/10/30 17:36:56 tsi Exp $ */
+
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains definitions of the public XFree86 data structures/types.
+ * Any data structures that video drivers need to access should go here.
+ */
+
+#ifndef _XF86STR_H
+#define _XF86STR_H
+
+#include "misc.h"
+#include "input.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "colormapst.h"
+#include "xf86Module.h"
+#include "xf86Opt.h"
+#include "xf86Pci.h"
+
+/*
+ * memType is of the size of the addressable memory (machine size)
+ * usually unsigned long.
+ */
+typedef unsigned long memType;
+
+/* Video mode flags */
+
+typedef enum {
+ V_PHSYNC = 0x0001,
+ V_NHSYNC = 0x0002,
+ V_PVSYNC = 0x0004,
+ V_NVSYNC = 0x0008,
+ V_INTERLACE = 0x0010,
+ V_DBLSCAN = 0x0020,
+ V_CSYNC = 0x0040,
+ V_PCSYNC = 0x0080,
+ V_NCSYNC = 0x0100,
+ V_HSKEW = 0x0200, /* hskew provided */
+ V_BCAST = 0x0400,
+ V_PIXMUX = 0x1000,
+ V_DBLCLK = 0x2000,
+ V_CLKDIV2 = 0x4000
+} ModeFlags;
+
+typedef enum {
+ INTERLACE_HALVE_V = 0x0001 /* Halve V values for interlacing */
+} CrtcAdjustFlags;
+
+/* Flags passed to ChipValidMode() */
+typedef enum {
+ MODECHECK_INITIAL = 0,
+ MODECHECK_FINAL = 1
+} ModeCheckFlags;
+
+/* These are possible return values for xf86CheckMode() and ValidMode() */
+typedef enum {
+ MODE_OK = 0, /* Mode OK */
+ MODE_HSYNC, /* hsync out of range */
+ MODE_VSYNC, /* vsync out of range */
+ MODE_H_ILLEGAL, /* mode has illegal horizontal timings */
+ MODE_V_ILLEGAL, /* mode has illegal horizontal timings */
+ MODE_BAD_WIDTH, /* requires an unsupported linepitch */
+ MODE_NOMODE, /* no mode with a maching name */
+ MODE_NO_INTERLACE, /* interlaced mode not supported */
+ MODE_NO_DBLESCAN, /* doublescan mode not supported */
+ MODE_NO_VSCAN, /* multiscan mode not supported */
+ MODE_MEM, /* insufficient video memory */
+ MODE_VIRTUAL_X, /* mode width too large for specified virtual size */
+ MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */
+ MODE_MEM_VIRT, /* insufficient video memory given virtual size */
+ MODE_NOCLOCK, /* no fixed clock available */
+ MODE_CLOCK_HIGH, /* clock required is too high */
+ MODE_CLOCK_LOW, /* clock required is too low */
+ MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */
+ MODE_BAD_HVALUE, /* horizontal timing was out of range */
+ MODE_BAD_VVALUE, /* vertical timing was out of range */
+ MODE_BAD_VSCAN, /* VScan value out of range */
+ MODE_HSYNC_NARROW, /* horizontal sync too narrow */
+ MODE_HSYNC_WIDE, /* horizontal sync too wide */
+ MODE_HBLANK_NARROW, /* horizontal blanking too narrow */
+ MODE_HBLANK_WIDE, /* horizontal blanking too wide */
+ MODE_VSYNC_NARROW, /* vertical sync too narrow */
+ MODE_VSYNC_WIDE, /* vertical sync too wide */
+ MODE_VBLANK_NARROW, /* vertical blanking too narrow */
+ MODE_VBLANK_WIDE, /* vertical blanking too wide */
+ MODE_PANEL, /* exceeds panel dimensions */
+ MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
+ MODE_ONE_WIDTH, /* only one width is supported */
+ MODE_ONE_HEIGHT, /* only one height is supported */
+ MODE_ONE_SIZE, /* only one resolution is supported */
+ MODE_BAD = -2, /* unspecified reason */
+ MODE_ERROR = -1 /* error condition */
+} ModeStatus;
+
+# define M_T_BUILTIN 0x01 /* built-in mode */
+# define M_T_CLOCK_C (0x02 | M_T_BUILTIN) /* built-in mode - configure clock */
+# define M_T_CRTC_C (0x04 | M_T_BUILTIN) /* built-in mode - configure CRTC */
+# define M_T_CLOCK_CRTC_C (M_T_CLOCK_C | M_T_CRTC_C)
+ /* built-in mode - configure CRTC and clock */
+# define M_T_DEFAULT 0x10 /* (VESA) default modes */
+# define M_T_USERDEF 0x20 /* One of the modes from the config file */
+
+/* Video mode */
+typedef struct _DisplayModeRec {
+ struct _DisplayModeRec * prev;
+ struct _DisplayModeRec * next;
+ char * name; /* identifier for the mode */
+ ModeStatus status;
+ int type;
+
+ /* These are the values that the user sees/provides */
+ int Clock; /* pixel clock freq (kHz) */
+ int HDisplay; /* horizontal timing */
+ int HSyncStart;
+ int HSyncEnd;
+ int HTotal;
+ int HSkew;
+ int VDisplay; /* vertical timing */
+ int VSyncStart;
+ int VSyncEnd;
+ int VTotal;
+ int VScan;
+ int Flags;
+
+ /* These are the values the hardware uses */
+ int ClockIndex;
+ int SynthClock; /* Actual clock freq to
+ * be programmed (kHz) */
+ int CrtcHDisplay;
+ int CrtcHBlankStart;
+ int CrtcHSyncStart;
+ int CrtcHSyncEnd;
+ int CrtcHBlankEnd;
+ int CrtcHTotal;
+ int CrtcHSkew;
+ int CrtcVDisplay;
+ int CrtcVBlankStart;
+ int CrtcVSyncStart;
+ int CrtcVSyncEnd;
+ int CrtcVBlankEnd;
+ int CrtcVTotal;
+ Bool CrtcHAdjusted;
+ Bool CrtcVAdjusted;
+ int PrivSize;
+ INT32 * Private;
+ int PrivFlags;
+
+ float HSync, VRefresh;
+} DisplayModeRec, *DisplayModePtr;
+
+/* The monitor description */
+
+#define MAX_HSYNC 8
+#define MAX_VREFRESH 8
+
+typedef struct { float hi, lo; } range;
+
+typedef struct { CARD32 red, green, blue; } rgb;
+
+typedef struct { float red, green, blue; } Gamma;
+
+/* The permitted gamma range is 1 / GAMMA_MAX <= g <= GAMMA_MAX */
+#define GAMMA_MAX 10.0
+#define GAMMA_MIN (1.0 / GAMMA_MAX)
+#define GAMMA_ZERO (GAMMA_MIN / 100.0)
+
+typedef struct {
+ char * id;
+ char * vendor;
+ char * model;
+ int nHsync;
+ range hsync[MAX_HSYNC];
+ int nVrefresh;
+ range vrefresh[MAX_VREFRESH];
+ DisplayModePtr Modes; /* Start of the monitor's mode list */
+ DisplayModePtr Last; /* End of the monitor's mode list */
+ Gamma gamma; /* Gamma of the monitor */
+ int widthmm;
+ int heightmm;
+ pointer options;
+ pointer DDC;
+} MonRec, *MonPtr;
+
+/* the list of clock ranges */
+typedef struct x_ClockRange {
+ struct x_ClockRange *next;
+ int minClock; /* (kHz) */
+ int maxClock; /* (kHz) */
+ int clockIndex; /* -1 for programmable clocks */
+ Bool interlaceAllowed;
+ Bool doubleScanAllowed;
+ int ClockMulFactor;
+ int ClockDivFactor;
+ int PrivFlags;
+} ClockRange, *ClockRangePtr;
+
+/* Need to store the strategy with clockRange for VidMode extension */
+typedef struct x_ClockRanges {
+ struct x_ClockRanges *next;
+ int minClock;
+ int maxClock;
+ int clockIndex; /* -1 for programmable clocks */
+ Bool interlaceAllowed;
+ Bool doubleScanAllowed;
+ int ClockMulFactor;
+ int ClockDivFactor;
+ int PrivFlags;
+ int strategy;
+} ClockRanges, *ClockRangesPtr;
+
+/*
+ * The driverFunc. xorgDriverFuncOp specifies the action driver should
+ * perform. If requested option is not supported function should return
+ * FALSE. pointer can be used to pass arguments to the function or
+ * to return data to the caller.
+ */
+typedef struct _ScrnInfoRec *ScrnInfoPtr;
+
+/* do not change order */
+typedef enum {
+ RR_GET_INFO,
+ RR_SET_CONFIG,
+ RR_GET_MODE_MM,
+ GET_REQUIRED_HW_INTERFACES = 10
+} xorgDriverFuncOp;
+
+typedef Bool xorgDriverFuncProc (ScrnInfoPtr, xorgDriverFuncOp,
+ pointer);
+
+/* RR_GET_INFO, RR_SET_CONFIG */
+typedef struct {
+ int rotation;
+ int rate;
+ int width;
+ int height;
+} xorgRRConfig;
+
+typedef union {
+ short RRRotations;
+ xorgRRConfig RRConfig;
+} xorgRRRotation, *xorgRRRotationPtr;
+
+/* RR_GET_MODE_MM */
+typedef struct {
+ DisplayModePtr mode;
+ int virtX;
+ int virtY;
+ int mmWidth;
+ int mmHeight;
+} xorgRRModeMM, *xorgRRModeMMPtr;
+
+/* GET_REQUIRED_HW_INTERFACES */
+#define HW_IO 1
+#define HW_MMIO 2
+#define NEED_IO_ENABLED(x) (x & HW_IO)
+
+typedef CARD32 xorgHWFlags;
+
+/*
+ * The driver list struct. This contains the information required for each
+ * driver before a ScrnInfoRec has been allocated.
+ */
+struct _DriverRec;
+
+typedef struct {
+ int driverVersion;
+ char * driverName;
+ void (*Identify)(int flags);
+ Bool (*Probe)(struct _DriverRec *drv, int flags);
+ const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype);
+ pointer module;
+ int refCount;
+} DriverRec1;
+
+typedef struct _DriverRec {
+ int driverVersion;
+ char * driverName;
+ void (*Identify)(int flags);
+ Bool (*Probe)(struct _DriverRec *drv, int flags);
+ const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype);
+ pointer module;
+ int refCount;
+ xorgDriverFuncProc *driverFunc;
+} DriverRec, *DriverPtr;
+
+/*
+ * AddDriver flags
+ */
+#define HaveDriverFuncs 1
+
+
+#ifdef XFree86LOADER
+/*
+ * The optional module list struct. This allows modules exporting helping
+ * functions to configuration tools, the Xserver, or any other
+ * application/module interested in such information.
+ */
+typedef struct _ModuleInfoRec {
+ int moduleVersion;
+ char * moduleName;
+ pointer module;
+ int refCount;
+ const OptionInfoRec * (*AvailableOptions)(void *unused);
+ pointer unused[8]; /* leave some space for more fields */
+} ModuleInfoRec, *ModuleInfoPtr;
+#endif
+
+/*
+ * These are the private bus types. New types can be added here. Types
+ * required for the public interface should be added to xf86str.h, with
+ * function prototypes added to xf86.h.
+ */
+
+/* Tolerate prior #include <linux/input.h> */
+#if defined(linux) && defined(_INPUT_H)
+#undef BUS_NONE
+#undef BUS_ISA
+#undef BUS_PCI
+#undef BUS_SBUS
+#undef BUS_last
+#endif
+
+typedef enum {
+ BUS_NONE,
+ BUS_ISA,
+ BUS_PCI,
+ BUS_SBUS,
+ BUS_last /* Keep last */
+} BusType;
+
+typedef struct {
+ int bus;
+ int device;
+ int func;
+} PciBusId;
+
+typedef struct {
+ unsigned int dummy;
+} IsaBusId;
+
+typedef struct {
+ int fbNum;
+} SbusBusId;
+
+typedef struct _bus {
+ BusType type;
+ union {
+ IsaBusId isa;
+ PciBusId pci;
+ SbusBusId sbus;
+ } id;
+} BusRec, *BusPtr;
+
+#define MAXCLOCKS 128
+typedef enum {
+ DAC_BPP8 = 0,
+ DAC_BPP16,
+ DAC_BPP24,
+ DAC_BPP32,
+ MAXDACSPEEDS
+} DacSpeedIndex;
+
+typedef struct {
+ char * identifier;
+ char * vendor;
+ char * board;
+ char * chipset;
+ char * ramdac;
+ char * driver;
+ struct _confscreenrec * myScreenSection;
+ Bool claimed;
+ int dacSpeeds[MAXDACSPEEDS];
+ int numclocks;
+ int clock[MAXCLOCKS];
+ char * clockchip;
+ char * busID;
+ Bool active;
+ Bool inUse;
+ int videoRam;
+ int textClockFreq;
+ unsigned long BiosBase; /* Base address of video BIOS */
+ unsigned long MemBase; /* Frame buffer base address */
+ unsigned long IOBase;
+ int chipID;
+ int chipRev;
+ pointer options;
+ int irq;
+ int screen; /* For multi-CRTC cards */
+} GDevRec, *GDevPtr;
+
+typedef int (*FindIsaDevProc)(GDevPtr dev);
+
+typedef struct {
+ char * identifier;
+ char * driver;
+ pointer commonOptions;
+ pointer extraOptions;
+} IDevRec, *IDevPtr;
+
+typedef struct {
+ int vendor;
+ int chipType;
+ int chipRev;
+ int subsysVendor;
+ int subsysCard;
+ int bus;
+ int device;
+ int func;
+ int class;
+ int subclass;
+ int interface;
+ memType memBase[6];
+ memType ioBase[6];
+ int size[6];
+ unsigned char type[6];
+ memType biosBase;
+ int biosSize;
+ pointer thisCard;
+ Bool validSize;
+ Bool validate;
+ CARD32 listed_class;
+} pciVideoRec, *pciVideoPtr;
+
+typedef struct {
+ int frameX0;
+ int frameY0;
+ int virtualX;
+ int virtualY;
+ int depth;
+ int fbbpp;
+ rgb weight;
+ rgb blackColour;
+ rgb whiteColour;
+ int defaultVisual;
+ char ** modes;
+ pointer options;
+} DispRec, *DispPtr;
+
+typedef struct _confxvportrec {
+ char * identifier;
+ pointer options;
+} confXvPortRec, *confXvPortPtr;
+
+typedef struct _confxvadaptrec {
+ char * identifier;
+ int numports;
+ confXvPortPtr ports;
+ pointer options;
+} confXvAdaptorRec, *confXvAdaptorPtr;
+
+typedef struct _confscreenrec {
+ char * id;
+ int screennum;
+ int defaultdepth;
+ int defaultbpp;
+ int defaultfbbpp;
+ MonPtr monitor;
+ GDevPtr device;
+ int numdisplays;
+ DispPtr displays;
+ int numxvadaptors;
+ confXvAdaptorPtr xvadaptors;
+ pointer options;
+} confScreenRec, *confScreenPtr;
+
+typedef enum {
+ PosObsolete = -1,
+ PosAbsolute = 0,
+ PosRightOf,
+ PosLeftOf,
+ PosAbove,
+ PosBelow,
+ PosRelative
+} PositionType;
+
+typedef struct _screenlayoutrec {
+ confScreenPtr screen;
+ char * topname;
+ confScreenPtr top;
+ char * bottomname;
+ confScreenPtr bottom;
+ char * leftname;
+ confScreenPtr left;
+ char * rightname;
+ confScreenPtr right;
+ PositionType where;
+ int x;
+ int y;
+ char * refname;
+ confScreenPtr refscreen;
+} screenLayoutRec, *screenLayoutPtr;
+
+typedef struct _serverlayoutrec {
+ char * id;
+ screenLayoutPtr screens;
+ GDevPtr inactives;
+ IDevPtr inputs;
+ pointer options;
+} serverLayoutRec, *serverLayoutPtr;
+
+typedef struct _confdribufferrec {
+ int count;
+ int size;
+ enum {
+ XF86DRI_WC_HINT = 0x0001 /* Placeholder: not implemented */
+ } flags;
+} confDRIBufferRec, *confDRIBufferPtr;
+
+typedef struct _confdrirec {
+ int group;
+ int mode;
+ int bufs_count;
+ confDRIBufferRec *bufs;
+} confDRIRec, *confDRIPtr;
+
+/* These values should be adjusted when new fields are added to ScrnInfoRec */
+#define NUM_RESERVED_INTS 16
+#define NUM_RESERVED_POINTERS 15
+#define NUM_RESERVED_FUNCS 11
+
+typedef pointer (*funcPointer)(void);
+
+/* flags for depth 24 pixmap options */
+typedef enum {
+ Pix24DontCare = 0,
+ Pix24Use24,
+ Pix24Use32
+} Pix24Flags;
+
+/* Power management events: so far we only support APM */
+
+typedef enum {
+ XF86_APM_UNKNOWN = -1,
+ XF86_APM_SYS_STANDBY,
+ XF86_APM_SYS_SUSPEND,
+ XF86_APM_CRITICAL_SUSPEND,
+ XF86_APM_USER_STANDBY,
+ XF86_APM_USER_SUSPEND,
+ XF86_APM_STANDBY_RESUME,
+ XF86_APM_NORMAL_RESUME,
+ XF86_APM_CRITICAL_RESUME,
+ XF86_APM_LOW_BATTERY,
+ XF86_APM_POWER_STATUS_CHANGE,
+ XF86_APM_UPDATE_TIME,
+ XF86_APM_CAPABILITY_CHANGED,
+ XF86_APM_STANDBY_FAILED,
+ XF86_APM_SUSPEND_FAILED
+} pmEvent;
+
+typedef enum {
+ PM_WAIT,
+ PM_CONTINUE,
+ PM_FAILED,
+ PM_NONE
+} pmWait;
+
+/*
+ * The IO access enabler struct. This contains the address for
+ * the IOEnable/IODisable funcs for their specific bus along
+ * with a pointer to data needed by them
+ */
+typedef struct _AccessRec {
+ void (*AccessDisable)(void *arg);
+ void (*AccessEnable)(void *arg);
+ void *arg;
+} xf86AccessRec, *xf86AccessPtr;
+
+typedef struct {
+ xf86AccessPtr mem;
+ xf86AccessPtr io;
+ xf86AccessPtr io_mem;
+} xf86SetAccessFuncRec, *xf86SetAccessFuncPtr;
+
+/* bus-access-related types */
+typedef enum {
+ NONE,
+ IO,
+ MEM_IO,
+ MEM
+} resType;
+
+typedef struct _EntityAccessRec {
+ xf86AccessPtr fallback;
+ xf86AccessPtr pAccess;
+ resType rt;
+ pointer busAcc;
+ struct _EntityAccessRec *next;
+} EntityAccessRec, *EntityAccessPtr;
+
+typedef struct _CurrAccRec {
+ EntityAccessPtr pMemAccess;
+ EntityAccessPtr pIoAccess;
+} xf86CurrentAccessRec, *xf86CurrentAccessPtr;
+
+/* new RAC */
+
+/* Resource Type values */
+#define ResNone ((unsigned long)(-1))
+
+#define ResMem 0x0001
+#define ResIo 0x0002
+#define ResIrq 0x0003
+#define ResDma 0x0004
+#define ResPciCfg 0x000e /* PCI Configuration space */
+#define ResPhysMask 0x000F
+
+#define ResExclusive 0x0010
+#define ResShared 0x0020
+#define ResAny 0x0040
+#define ResAccMask 0x0070
+#define ResUnused 0x0080
+
+#define ResUnusedOpr 0x0100
+#define ResDisableOpr 0x0200
+#define ResOprMask 0x0300
+
+#define ResBlock 0x0400
+#define ResSparse 0x0800
+#define ResExtMask 0x0C00
+
+#define ResEstimated 0x001000
+#define ResInit 0x002000
+#define ResBios 0x004000
+#define ResMiscMask 0x00F000
+
+#define ResBus 0x010000
+#define ResOverlap 0x020000
+
+#if defined(__alpha__) && defined(linux)
+# define ResDomain 0x1ff000000ul
+#else
+# define ResDomain 0xff000000ul
+#endif
+#define ResTypeMask (ResPhysMask | ResDomain) /* For conflict check */
+
+#define ResEnd ResNone
+
+#define ResExcMemBlock (ResMem | ResExclusive | ResBlock)
+#define ResExcIoBlock (ResIo | ResExclusive | ResBlock)
+#define ResShrMemBlock (ResMem | ResShared | ResBlock)
+#define ResShrIoBlock (ResIo | ResShared | ResBlock)
+#define ResExcUusdMemBlock (ResMem | ResExclusive | ResUnused | ResBlock)
+#define ResExcUusdIoBlock (ResIo | ResExclusive | ResUnused | ResBlock)
+#define ResShrUusdMemBlock (ResMem | ResShared | ResUnused | ResBlock)
+#define ResShrUusdIoBlock (ResIo | ResShared | ResUnused | ResBlock)
+#define ResExcUusdMemSparse (ResMem | ResExclusive | ResUnused | ResSparse)
+#define ResExcUusdIoSparse (ResIo | ResExclusive | ResUnused | ResSparse)
+#define ResShrUusdMemSparse (ResMem | ResShared | ResUnused | ResSparse)
+#define ResShrUusdIoSparse (ResIo | ResShared | ResUnused | ResSparse)
+
+#define ResExcMemSparse (ResMem | ResExclusive | ResSparse)
+#define ResExcIoSparse (ResIo | ResExclusive | ResSparse)
+#define ResShrMemSparse (ResMem | ResShared | ResSparse)
+#define ResShrIoSparse (ResIo | ResShared | ResSparse)
+#define ResUusdMemSparse (ResMem | ResUnused | ResSparse)
+#define ResUusdIoSparse (ResIo | ResUnused | ResSparse)
+
+#define ResIsMem(r) (((r)->type & ResPhysMask) == ResMem)
+#define ResIsIo(r) (((r)->type & ResPhysMask) == ResIo)
+#define ResIsExclusive(r) (((r)->type & ResAccMask) == ResExclusive)
+#define ResIsShared(r) (((r)->type & ResAccMask) == ResShared)
+#define ResIsUnused(r) (((r)->type & ResAccMask) == ResUnused)
+#define ResIsBlock(r) (((r)->type & ResExtMask) == ResBlock)
+#define ResIsSparse(r) (((r)->type & ResExtMask) == ResSparse)
+#define ResIsEstimated(r) (((r)->type & ResMiscMask) == ResEstimated)
+#define ResCanOverlap(r) (ResIsEstimated(r) || ((r)->type & ResOverlap))
+
+typedef struct {
+ unsigned long type; /* shared, exclusive, unused etc. */
+ memType a;
+ memType b;
+} resRange, *resList;
+
+#define RANGE_TYPE(type, domain) \
+ (((unsigned long)(domain) << 24) | ((type) & ~ResBus))
+#define RANGE(r,u,v,t) {\
+ (r).a = (u);\
+ (r).b = (v);\
+ (r).type = (t);\
+ }
+
+#define rBase a
+#define rMask b
+#define rBegin a
+#define rEnd b
+
+/* resource record */
+typedef struct _resRec *resPtr;
+typedef struct _resRec {
+ resRange val;
+ int entityIndex; /* who owns the resource */
+ resPtr next;
+} resRec;
+
+#define sparse_base val.rBase
+#define sparse_mask val.rMask
+#define block_begin val.rBegin
+#define block_end val.rEnd
+#define res_type val.type
+
+typedef struct {
+ int numChipset;
+ resRange *resList;
+} IsaChipsets;
+
+typedef struct {
+ int numChipset;
+ int PCIid;
+ resRange *resList;
+} PciChipsets;
+
+/* Entity properties */
+typedef void (*EntityProc)(int entityIndex,pointer private);
+
+typedef struct _entityInfo {
+ int index;
+ BusRec location;
+ int chipset;
+ Bool active;
+ resPtr resources;
+ GDevPtr device;
+ DriverPtr driver;
+} EntityInfoRec, *EntityInfoPtr;
+
+/* server states */
+
+typedef enum {
+ SETUP,
+ OPERATING
+} xf86State;
+
+typedef enum {
+ NOTIFY_SETUP_TRANSITION,
+ NOTIFY_SETUP,
+ NOTIFY_OPERATING,
+ NOTIFY_OPERATING_TRANSITION,
+ NOTIFY_ENABLE,
+ NOTIFY_ENTER,
+ NOTIFY_LEAVE
+} xf86NotifyState;
+
+typedef void (*xf86StateChangeNotificationCallbackFunc)(xf86NotifyState state,pointer);
+
+/* DGA */
+
+typedef struct {
+ int num; /* A unique identifier for the mode (num > 0) */
+ DisplayModePtr mode;
+ int flags; /* DGA_CONCURRENT_ACCESS, etc... */
+ int imageWidth; /* linear accessible portion (pixels) */
+ int imageHeight;
+ int pixmapWidth; /* Xlib accessible portion (pixels) */
+ int pixmapHeight; /* both fields ignored if no concurrent access */
+ int bytesPerScanline;
+ int byteOrder; /* MSBFirst, LSBFirst */
+ int depth;
+ int bitsPerPixel;
+ unsigned long red_mask;
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ short visualClass;
+ int viewportWidth;
+ int viewportHeight;
+ int xViewportStep; /* viewport position granularity */
+ int yViewportStep;
+ int maxViewportX; /* max viewport origin */
+ int maxViewportY;
+ int viewportFlags; /* types of page flipping possible */
+ int offset; /* offset into physical memory */
+ unsigned char *address; /* server's mapped framebuffer */
+ int reserved1;
+ int reserved2;
+} DGAModeRec, *DGAModePtr;
+
+typedef struct {
+ DGAModePtr mode;
+ PixmapPtr pPix;
+} DGADeviceRec, *DGADevicePtr;
+
+/*
+ * Flags for driver Probe() functions.
+ */
+#define PROBE_DEFAULT 0x00
+#define PROBE_DETECT 0x01
+#define PROBE_TRYHARD 0x02
+
+/*
+ * Driver entry point types
+ */
+
+typedef Bool xf86ProbeProc (DriverPtr, int);
+typedef Bool xf86PreInitProc (ScrnInfoPtr, int);
+typedef Bool xf86ScreenInitProc (int, ScreenPtr, int, char**);
+typedef Bool xf86SwitchModeProc (int, DisplayModePtr, int);
+typedef void xf86AdjustFrameProc (int, int, int, int);
+typedef Bool xf86EnterVTProc (int, int);
+typedef void xf86LeaveVTProc (int, int);
+typedef void xf86FreeScreenProc (int, int);
+typedef ModeStatus xf86ValidModeProc (int, DisplayModePtr, Bool, int);
+typedef void xf86EnableDisableFBAccessProc(int, Bool);
+typedef int xf86SetDGAModeProc (int, int, DGADevicePtr);
+typedef int xf86ChangeGammaProc (int, Gamma);
+typedef void xf86PointerMovedProc (int, int, int);
+typedef Bool xf86PMEventProc (int, pmEvent, Bool);
+typedef int xf86HandleMessageProc (int, const char*, const char*, char**);
+typedef void xf86DPMSSetProc (ScrnInfoPtr, int, int);
+typedef void xf86LoadPaletteProc (ScrnInfoPtr, int, int *, LOCO *, VisualPtr);
+typedef void xf86SetOverscanProc (ScrnInfoPtr, int);
+
+
+/*
+ * ScrnInfoRec
+ *
+ * There is one of these for each screen, and it holds all the screen-specific
+ * information.
+ *
+ * Note: the size and layout must be kept the same across versions. New
+ * fields are to be added in place of the "reserved*" fields. No fields
+ * are to be dependent on compile-time defines.
+ */
+
+
+typedef struct _ScrnInfoRec {
+ int driverVersion;
+ char * driverName; /* canonical name used in */
+ /* the config file */
+ ScreenPtr pScreen; /* Pointer to the ScreenRec */
+ int scrnIndex; /* Number of this screen */
+ Bool configured; /* Is this screen valid */
+ int origIndex; /* initial number assigned to
+ * this screen before
+ * finalising the number of
+ * available screens */
+
+ /* Display-wide screenInfo values needed by this screen */
+ int imageByteOrder;
+ int bitmapScanlineUnit;
+ int bitmapScanlinePad;
+ int bitmapBitOrder;
+ int numFormats;
+ PixmapFormatRec formats[MAXFORMATS];
+ PixmapFormatRec fbFormat;
+
+ int bitsPerPixel; /* fb bpp */
+ Pix24Flags pixmap24; /* pixmap pref for depth 24 */
+ int depth; /* depth of default visual */
+ MessageType depthFrom; /* set from config? */
+ MessageType bitsPerPixelFrom; /* set from config? */
+ rgb weight; /* r/g/b weights */
+ rgb mask; /* rgb masks */
+ rgb offset; /* rgb offsets */
+ int rgbBits; /* Number of bits in r/g/b */
+ Gamma gamma; /* Gamma of the monitor */
+ int defaultVisual; /* default visual class */
+ int maxHValue; /* max horizontal timing */
+ int maxVValue; /* max vertical timing value */
+ int virtualX; /* Virtual width */
+ int virtualY; /* Virtual height */
+ int xInc; /* Horizontal timing increment */
+ MessageType virtualFrom; /* set from config? */
+ int displayWidth; /* memory pitch */
+ int frameX0; /* viewport position */
+ int frameY0;
+ int frameX1;
+ int frameY1;
+ int zoomLocked; /* Disallow mode changes */
+ DisplayModePtr modePool; /* list of compatible modes */
+ DisplayModePtr modes; /* list of actual modes */
+ DisplayModePtr currentMode; /* current mode
+ * This was previously
+ * overloaded with the modes
+ * field, which is a pointer
+ * into a circular list */
+ confScreenPtr confScreen; /* Screen config info */
+ MonPtr monitor; /* Monitor information */
+ DispPtr display; /* Display information */
+ int * entityList; /* List of device entities */
+ int numEntities;
+ int widthmm; /* physical display dimensions
+ * in mm */
+ int heightmm;
+ int xDpi; /* width DPI */
+ int yDpi; /* height DPI */
+ char * name; /* Name to prefix messages */
+ pointer driverPrivate; /* Driver private area */
+ DevUnion * privates; /* Other privates can hook in
+ * here */
+ DriverPtr drv; /* xf86DriverList[] entry */
+ pointer module; /* Pointer to module head */
+ int colorKey;
+ int overlayFlags;
+
+ /* Some of these may be moved out of here into the driver private area */
+
+ char * chipset; /* chipset name */
+ char * ramdac; /* ramdac name */
+ char * clockchip; /* clock name */
+ Bool progClock; /* clock is programmable */
+ int numClocks; /* number of clocks */
+ int clock[MAXCLOCKS]; /* list of clock frequencies */
+ int videoRam; /* amount of video ram (kb) */
+ unsigned long biosBase; /* Base address of video BIOS */
+ unsigned long memPhysBase; /* Physical address of FB */
+ unsigned long fbOffset; /* Offset of FB in the above */
+ IOADDRESS domainIOBase; /* Domain I/O base address */
+ int memClk; /* memory clock */
+ int textClockFreq; /* clock of text mode */
+ Bool flipPixels; /* swap default black/white */
+ pointer options;
+
+ int chipID;
+ int chipRev;
+ int racMemFlags;
+ int racIoFlags;
+ pointer access;
+ xf86CurrentAccessPtr CurrentAccess;
+ resType resourceType;
+ pointer busAccess;
+
+ /* Allow screens to be enabled/disabled individually */
+ Bool vtSema;
+ DevUnion pixmapPrivate; /* saved devPrivate from pixmap */
+
+ /* hw cursor moves at SIGIO time */
+ Bool silkenMouse;
+
+ /* Storage for clockRanges and adjustFlags for use with the VidMode ext */
+ ClockRangesPtr clockRanges;
+ int adjustFlags;
+
+ /*
+ * These can be used when the minor ABI version is incremented.
+ * The NUM_* parameters must be reduced appropriately to keep the
+ * structure size and alignment unchanged.
+ */
+ int reservedInt[NUM_RESERVED_INTS];
+
+ int * entityInstanceList;
+ pointer reservedPtr[NUM_RESERVED_POINTERS];
+
+ /*
+ * Driver entry points.
+ *
+ */
+
+ xf86ProbeProc *Probe;
+ xf86PreInitProc *PreInit;
+ xf86ScreenInitProc *ScreenInit;
+ xf86SwitchModeProc *SwitchMode;
+ xf86AdjustFrameProc *AdjustFrame;
+ xf86EnterVTProc *EnterVT;
+ xf86LeaveVTProc *LeaveVT;
+ xf86FreeScreenProc *FreeScreen;
+ xf86ValidModeProc *ValidMode;
+ xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
+ xf86SetDGAModeProc *SetDGAMode;
+ xf86ChangeGammaProc *ChangeGamma;
+ xf86PointerMovedProc *PointerMoved;
+ xf86PMEventProc *PMEvent;
+ xf86HandleMessageProc *HandleMessage;
+ xf86DPMSSetProc *DPMSSet;
+ xf86LoadPaletteProc *LoadPalette;
+ xf86SetOverscanProc *SetOverscan;
+ xorgDriverFuncProc *DriverFunc;
+
+ /*
+ * This can be used when the minor ABI version is incremented.
+ * The NUM_* parameter must be reduced appropriately to keep the
+ * structure size and alignment unchanged.
+ */
+ funcPointer reservedFuncs[NUM_RESERVED_FUNCS];
+
+} ScrnInfoRec;
+
+
+typedef struct {
+ Bool (*OpenFramebuffer)(
+ ScrnInfoPtr pScrn,
+ char **name,
+ unsigned char **mem,
+ int *size,
+ int *offset,
+ int *extra
+ );
+ void (*CloseFramebuffer)(ScrnInfoPtr pScrn);
+ Bool (*SetMode)(ScrnInfoPtr pScrn, DGAModePtr pMode);
+ void (*SetViewport)(ScrnInfoPtr pScrn, int x, int y, int flags);
+ int (*GetViewport)(ScrnInfoPtr pScrn);
+ void (*Sync)(ScrnInfoPtr);
+ void (*FillRect)(
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned long color
+ );
+ void (*BlitRect)(
+ ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty
+ );
+ void (*BlitTransRect)(
+ ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty,
+ unsigned long color
+ );
+} DGAFunctionRec, *DGAFunctionPtr;
+
+typedef struct {
+ int token; /* id of the token */
+ const char * name; /* token name */
+} SymTabRec, *SymTabPtr;
+
+/* flags for xf86LookupMode */
+typedef enum {
+ LOOKUP_DEFAULT = 0, /* Use default mode lookup method */
+ LOOKUP_BEST_REFRESH, /* Pick modes with best refresh */
+ LOOKUP_CLOSEST_CLOCK, /* Pick modes with the closest clock */
+ LOOKUP_LIST_ORDER, /* Pick first useful mode in list */
+ LOOKUP_CLKDIV2 = 0x0100, /* Allow half clocks */
+ LOOKUP_OPTIONAL_TOLERANCES = 0x0200 /* Allow missing hsync/vrefresh */
+} LookupModeFlags;
+
+#define NoDepth24Support 0x00
+#define Support24bppFb 0x01 /* 24bpp framebuffer supported */
+#define Support32bppFb 0x02 /* 32bpp framebuffer supported */
+#define SupportConvert24to32 0x04 /* Can convert 24bpp pixmap to 32bpp */
+#define SupportConvert32to24 0x08 /* Can convert 32bpp pixmap to 24bpp */
+#define PreferConvert24to32 0x10 /* prefer 24bpp pixmap to 32bpp conv */
+#define PreferConvert32to24 0x20 /* prefer 32bpp pixmap to 24bpp conv */
+
+
+/* For DPMS */
+typedef void (*DPMSSetProcPtr)(ScrnInfoPtr, int, int);
+
+/* Input handler proc */
+typedef void (*InputHandlerProc)(int fd, pointer data);
+
+/* These are used by xf86GetClocks */
+#define CLK_REG_SAVE -1
+#define CLK_REG_RESTORE -2
+
+/* xf86Debug.c */
+#ifdef BUILDDEBUG
+typedef struct {
+ long sec;
+ long usec;
+} xf86TsRec, *xf86TsPtr;
+#endif
+
+/*
+ * misc constants
+ */
+#define INTERLACE_REFRESH_WEIGHT 1.5
+#define SYNC_TOLERANCE 0.01 /* 1 percent */
+#define CLOCK_TOLERANCE 2000 /* Clock matching tolerance (2MHz) */
+
+
+#define OVERLAY_8_32_DUALFB 0x00000001
+#define OVERLAY_8_24_DUALFB 0x00000002
+#define OVERLAY_8_16_DUALFB 0x00000004
+#define OVERLAY_8_32_PLANAR 0x00000008
+
+#if 0
+#define LD_RESOLV_IFDONE 0 /* only check if no more
+ delays pending */
+#define LD_RESOLV_NOW 1 /* finish one delay step */
+#define LD_RESOLV_FORCE 2 /* force checking... */
+#endif
+
+/* Values of xf86Info.mouseFlags */
+#define MF_CLEAR_DTR 1
+#define MF_CLEAR_RTS 2
+
+/* Action Events */
+typedef enum {
+ ACTION_TERMINATE = 0, /* Terminate Server */
+ ACTION_NEXT_MODE = 10, /* Switch to next video mode */
+ ACTION_PREV_MODE,
+ ACTION_DISABLEGRAB = 20, /* Cancel server/pointer/kbd grabs */
+ ACTION_CLOSECLIENT, /* Kill client holding grab */
+ ACTION_SWITCHSCREEN = 100, /* VT switch */
+ ACTION_SWITCHSCREEN_NEXT,
+ ACTION_SWITCHSCREEN_PREV,
+ ACTION_MESSAGE = 9999 /* Generic message passing */
+} ActionEvent;
+
+/* xf86Versions.c */
+/*
+ * Never change existing values, and always assign values explicitly.
+ * NUM_BUILTIN_IFS must always be the last entry.
+ */
+typedef enum {
+ BUILTIN_IF_OSMOUSE = 0,
+ BUILTIN_IF_OSKBD = 1,
+ NUM_BUILTIN_IFS
+} BuiltinInterface;
+
+/*
+ * These are intentionally the same as the module version macros.
+ * It is possible to register a module as providing a specific interface,
+ * in which case the module's version is used. This feature isn't
+ * really ready for use yet though.
+ */
+
+#define BUILTIN_INTERFACE_VERSION_NUMERIC(maj, min, patch) \
+ ((((maj) & 0xFF) << 24) | (((min) & 0xFF) << 16) | (patch & 0xFFFF))
+#define GET_BUILTIN_INTERFACE_MAJOR_VERSION(vers) (((vers) >> 24) & 0xFF)
+#define GET_BUILTIN_INTERFACE_MINOR_VERSION(vers) (((vers) >> 16) & 0xFF)
+#define GET_BUILTIN_INTERFACE_PATCH_VERSION(vers) ((vers) & 0xFFFF)
+
+#endif /* _XF86STR_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86xv.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86xv.c
new file mode 100644
index 000000000..35695bd9e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86xv.c
@@ -0,0 +1,2050 @@
+/*
+ * XFree86 Xv DDX written by Mark Vojkovich (markv@valinux.com)
+ */
+/*
+ * Copyright (c) 1998-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.c,v 1.37 2003/11/10 18:22:15 tsi Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "regionstr.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "mivalidate.h"
+#include "validate.h"
+#include "resource.h"
+#include "gcstruct.h"
+#include "dixstruct.h"
+
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/Xvproto.h>
+#include "xvdix.h"
+#ifdef XFree86LOADER
+#include "xvmodproc.h"
+#endif
+
+#include "xf86xvpriv.h"
+
+
+/* XvScreenRec fields */
+
+static Bool xf86XVCloseScreen(int, ScreenPtr);
+static int xf86XVQueryAdaptors(ScreenPtr, XvAdaptorPtr *, int *);
+
+/* XvAdaptorRec fields */
+
+static int xf86XVAllocatePort(unsigned long, XvPortPtr, XvPortPtr*);
+static int xf86XVFreePort(XvPortPtr);
+static int xf86XVPutVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int xf86XVPutStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int xf86XVGetVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int xf86XVGetStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int xf86XVStopVideo(ClientPtr, XvPortPtr, DrawablePtr);
+static int xf86XVSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32);
+static int xf86XVGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32*);
+static int xf86XVQueryBestSize(ClientPtr, XvPortPtr, CARD8,
+ CARD16, CARD16,CARD16, CARD16,
+ unsigned int*, unsigned int*);
+static int xf86XVPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16,
+ XvImagePtr, unsigned char*, Bool,
+ CARD16, CARD16);
+static int xf86XVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr,
+ CARD16*, CARD16*, int*, int*);
+
+
+/* ScreenRec fields */
+
+static Bool xf86XVDestroyWindow(WindowPtr pWin);
+static void xf86XVWindowExposures(WindowPtr pWin, RegionPtr r1, RegionPtr r2);
+static void xf86XVClipNotify(WindowPtr pWin, int dx, int dy);
+
+/* ScrnInfoRec functions */
+
+static Bool xf86XVEnterVT(int, int);
+static void xf86XVLeaveVT(int, int);
+static void xf86XVAdjustFrame(int index, int x, int y, int flags);
+
+/* misc */
+
+static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr*, int);
+
+
+int XF86XVWindowIndex = -1;
+int XF86XvScreenIndex = -1;
+static unsigned long XF86XVGeneration = 0;
+static unsigned long PortResource = 0;
+
+#ifdef XFree86LOADER
+int (*XvGetScreenIndexProc)(void) = NULL;
+unsigned long (*XvGetRTPortProc)(void) = NULL;
+int (*XvScreenInitProc)(ScreenPtr) = NULL;
+#else
+int (*XvGetScreenIndexProc)(void) = XvGetScreenIndex;
+unsigned long (*XvGetRTPortProc)(void) = XvGetRTPort;
+int (*XvScreenInitProc)(ScreenPtr) = XvScreenInit;
+#endif
+
+
+#define GET_XV_SCREEN(pScreen) \
+ ((XvScreenPtr)((pScreen)->devPrivates[XF86XvScreenIndex].ptr))
+
+#define GET_XF86XV_SCREEN(pScreen) \
+ ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
+
+#define GET_XF86XV_WINDOW(pWin) \
+ ((XF86XVWindowPtr)((pWin)->devPrivates[XF86XVWindowIndex].ptr))
+
+static xf86XVInitGenericAdaptorPtr *GenDrivers = NULL;
+static int NumGenDrivers = 0;
+
+int
+xf86XVRegisterGenericAdaptorDriver(
+ xf86XVInitGenericAdaptorPtr InitFunc
+){
+ xf86XVInitGenericAdaptorPtr *newdrivers;
+
+ newdrivers = xrealloc(GenDrivers, sizeof(xf86XVInitGenericAdaptorPtr) *
+ (1 + NumGenDrivers));
+ if (!newdrivers)
+ return 0;
+ GenDrivers = newdrivers;
+
+ GenDrivers[NumGenDrivers++] = InitFunc;
+
+ return 1;
+}
+
+int
+xf86XVListGenericAdaptors(
+ ScrnInfoPtr pScrn,
+ XF86VideoAdaptorPtr **adaptors
+){
+ int i,j,n,num;
+ XF86VideoAdaptorPtr *DrivAdap,*new;
+
+ num = 0;
+ *adaptors = NULL;
+ /*
+ * The v4l driver registers itself first, but can use surfaces registered
+ * by other drivers. So, call the v4l driver last.
+ */
+ for (i = NumGenDrivers; --i >= 0; ) {
+ DrivAdap = NULL;
+ n = (*GenDrivers[i])(pScrn, &DrivAdap);
+ if (0 == n)
+ continue;
+ new = xrealloc(*adaptors, sizeof(XF86VideoAdaptorPtr) * (num+n));
+ if (NULL == new)
+ continue;
+ *adaptors = new;
+ for (j = 0; j < n; j++, num++)
+ (*adaptors)[num] = DrivAdap[j];
+ }
+ return num;
+}
+
+
+/**************** Offscreen surface stuff *******************/
+
+typedef struct {
+ XF86OffscreenImagePtr images;
+ int num;
+} OffscreenImageRec;
+
+static OffscreenImageRec OffscreenImages[MAXSCREENS];
+
+Bool
+xf86XVRegisterOffscreenImages(
+ ScreenPtr pScreen,
+ XF86OffscreenImagePtr images,
+ int num
+){
+ OffscreenImages[pScreen->myNum].num = num;
+ OffscreenImages[pScreen->myNum].images = images;
+
+ return TRUE;
+}
+
+XF86OffscreenImagePtr
+xf86XVQueryOffscreenImages(
+ ScreenPtr pScreen,
+ int *num
+){
+ *num = OffscreenImages[pScreen->myNum].num;
+ return OffscreenImages[pScreen->myNum].images;
+}
+
+
+XF86VideoAdaptorPtr
+xf86XVAllocateVideoAdaptorRec(ScrnInfoPtr pScrn)
+{
+ return xcalloc(1, sizeof(XF86VideoAdaptorRec));
+}
+
+void
+xf86XVFreeVideoAdaptorRec(XF86VideoAdaptorPtr ptr)
+{
+ xfree(ptr);
+}
+
+
+Bool
+xf86XVScreenInit(
+ ScreenPtr pScreen,
+ XF86VideoAdaptorPtr *adaptors,
+ int num
+){
+ ScrnInfoPtr pScrn;
+ XF86XVScreenPtr ScreenPriv;
+ XvScreenPtr pxvs;
+
+ if(num <= 0 ||
+ !XvGetScreenIndexProc || !XvGetRTPortProc || !XvScreenInitProc)
+ return FALSE;
+
+ if(XF86XVGeneration != serverGeneration) {
+ if((XF86XVWindowIndex = AllocateWindowPrivateIndex()) < 0)
+ return FALSE;
+ XF86XVGeneration = serverGeneration;
+ }
+
+ if(!AllocateWindowPrivate(pScreen,XF86XVWindowIndex,0))
+ return FALSE;
+
+ if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
+
+ XF86XvScreenIndex = (*XvGetScreenIndexProc)();
+ PortResource = (*XvGetRTPortProc)();
+
+ pxvs = GET_XV_SCREEN(pScreen);
+
+ /* Anyone initializing the Xv layer must provide these two.
+ The Xv di layer calls them without even checking if they exist! */
+
+ pxvs->ddCloseScreen = xf86XVCloseScreen;
+ pxvs->ddQueryAdaptors = xf86XVQueryAdaptors;
+
+ /* The Xv di layer provides us with a private hook so that we don't
+ have to allocate our own screen private. They also provide
+ a CloseScreen hook so that we don't have to wrap it. I'm not
+ sure that I appreciate that. */
+
+ ScreenPriv = xalloc(sizeof(XF86XVScreenRec));
+ pxvs->devPriv.ptr = (pointer)ScreenPriv;
+
+ if(!ScreenPriv) return FALSE;
+
+ pScrn = xf86Screens[pScreen->myNum];
+
+ ScreenPriv->videoGC = NULL; /* for the helper */
+
+ ScreenPriv->DestroyWindow = pScreen->DestroyWindow;
+ ScreenPriv->WindowExposures = pScreen->WindowExposures;
+ ScreenPriv->ClipNotify = pScreen->ClipNotify;
+ ScreenPriv->EnterVT = pScrn->EnterVT;
+ ScreenPriv->LeaveVT = pScrn->LeaveVT;
+ ScreenPriv->AdjustFrame = pScrn->AdjustFrame;
+
+ pScreen->DestroyWindow = xf86XVDestroyWindow;
+ pScreen->WindowExposures = xf86XVWindowExposures;
+ pScreen->ClipNotify = xf86XVClipNotify;
+ pScrn->EnterVT = xf86XVEnterVT;
+ pScrn->LeaveVT = xf86XVLeaveVT;
+ if(pScrn->AdjustFrame)
+ pScrn->AdjustFrame = xf86XVAdjustFrame;
+
+ if(!xf86XVInitAdaptors(pScreen, adaptors, num))
+ return FALSE;
+
+ return TRUE;
+}
+
+static void
+xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor)
+{
+ int i;
+
+ xfree(pAdaptor->name);
+
+ if(pAdaptor->pEncodings) {
+ XvEncodingPtr pEncode = pAdaptor->pEncodings;
+
+ for(i = 0; i < pAdaptor->nEncodings; i++, pEncode++)
+ xfree(pEncode->name);
+ xfree(pAdaptor->pEncodings);
+ }
+
+ xfree(pAdaptor->pFormats);
+
+ if(pAdaptor->pPorts) {
+ XvPortPtr pPort = pAdaptor->pPorts;
+ XvPortRecPrivatePtr pPriv;
+
+ for(i = 0; i < pAdaptor->nPorts; i++, pPort++) {
+ pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
+ if(pPriv) {
+ if(pPriv->clientClip)
+ REGION_DESTROY(pAdaptor->pScreen, pPriv->clientClip);
+ if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ REGION_DESTROY(pAdaptor->pScreen, pPriv->pCompositeClip);
+ xfree(pPriv);
+ }
+ }
+ xfree(pAdaptor->pPorts);
+ }
+
+ if(pAdaptor->nAttributes) {
+ XvAttributePtr pAttribute = pAdaptor->pAttributes;
+
+ for(i = 0; i < pAdaptor->nAttributes; i++, pAttribute++)
+ xfree(pAttribute->name);
+ xfree(pAdaptor->pAttributes);
+ }
+
+ xfree(pAdaptor->pImages);
+ xfree(pAdaptor->devPriv.ptr);
+}
+
+static Bool
+xf86XVInitAdaptors(
+ ScreenPtr pScreen,
+ XF86VideoAdaptorPtr *infoPtr,
+ int number
+) {
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ XF86VideoAdaptorPtr adaptorPtr;
+ XvAdaptorPtr pAdaptor, pa;
+ XvAdaptorRecPrivatePtr adaptorPriv;
+ int na, numAdaptor;
+ XvPortRecPrivatePtr portPriv;
+ XvPortPtr pPort, pp;
+ int numPort;
+ XF86AttributePtr attributePtr;
+ XvAttributePtr pAttribute, pat;
+ XF86VideoFormatPtr formatPtr;
+ XvFormatPtr pFormat, pf;
+ int numFormat, totFormat;
+ XF86VideoEncodingPtr encodingPtr;
+ XvEncodingPtr pEncode, pe;
+ XF86ImagePtr imagePtr;
+ XvImagePtr pImage, pi;
+ int numVisuals;
+ VisualPtr pVisual;
+ int i;
+
+ pxvs->nAdaptors = 0;
+ pxvs->pAdaptors = NULL;
+
+ if(!(pAdaptor = xcalloc(number, sizeof(XvAdaptorRec))))
+ return FALSE;
+
+ for(pa = pAdaptor, na = 0, numAdaptor = 0; na < number; na++, adaptorPtr++) {
+ adaptorPtr = infoPtr[na];
+
+ if(!adaptorPtr->StopVideo || !adaptorPtr->SetPortAttribute ||
+ !adaptorPtr->GetPortAttribute || !adaptorPtr->QueryBestSize)
+ continue;
+
+ /* client libs expect at least one encoding */
+ if(!adaptorPtr->nEncodings || !adaptorPtr->pEncodings)
+ continue;
+
+ pa->type = adaptorPtr->type;
+
+ if(!adaptorPtr->PutVideo && !adaptorPtr->GetVideo)
+ pa->type &= ~XvVideoMask;
+
+ if(!adaptorPtr->PutStill && !adaptorPtr->GetStill)
+ pa->type &= ~XvStillMask;
+
+ if(!adaptorPtr->PutImage || !adaptorPtr->QueryImageAttributes)
+ pa->type &= ~XvImageMask;
+
+ if(!adaptorPtr->PutVideo && !adaptorPtr->PutImage &&
+ !adaptorPtr->PutStill)
+ pa->type &= ~XvInputMask;
+
+ if(!adaptorPtr->GetVideo && !adaptorPtr->GetStill)
+ pa->type &= ~XvOutputMask;
+
+ if(!(adaptorPtr->type & (XvPixmapMask | XvWindowMask)))
+ continue;
+ if(!(adaptorPtr->type & (XvImageMask | XvVideoMask | XvStillMask)))
+ continue;
+
+ pa->pScreen = pScreen;
+ pa->ddAllocatePort = xf86XVAllocatePort;
+ pa->ddFreePort = xf86XVFreePort;
+ pa->ddPutVideo = xf86XVPutVideo;
+ pa->ddPutStill = xf86XVPutStill;
+ pa->ddGetVideo = xf86XVGetVideo;
+ pa->ddGetStill = xf86XVGetStill;
+ pa->ddStopVideo = xf86XVStopVideo;
+ pa->ddPutImage = xf86XVPutImage;
+ pa->ddSetPortAttribute = xf86XVSetPortAttribute;
+ pa->ddGetPortAttribute = xf86XVGetPortAttribute;
+ pa->ddQueryBestSize = xf86XVQueryBestSize;
+ pa->ddQueryImageAttributes = xf86XVQueryImageAttributes;
+ if((pa->name = xalloc(strlen(adaptorPtr->name) + 1)))
+ strcpy(pa->name, adaptorPtr->name);
+
+ if(adaptorPtr->nEncodings &&
+ (pEncode = xcalloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) {
+
+ for(pe = pEncode, encodingPtr = adaptorPtr->pEncodings, i = 0;
+ i < adaptorPtr->nEncodings; pe++, i++, encodingPtr++)
+ {
+ pe->id = encodingPtr->id;
+ pe->pScreen = pScreen;
+ if((pe->name = xalloc(strlen(encodingPtr->name) + 1)))
+ strcpy(pe->name, encodingPtr->name);
+ pe->width = encodingPtr->width;
+ pe->height = encodingPtr->height;
+ pe->rate.numerator = encodingPtr->rate.numerator;
+ pe->rate.denominator = encodingPtr->rate.denominator;
+ }
+ pa->nEncodings = adaptorPtr->nEncodings;
+ pa->pEncodings = pEncode;
+ }
+
+ if(adaptorPtr->nImages &&
+ (pImage = xcalloc(adaptorPtr->nImages, sizeof(XvImageRec)))) {
+
+ for(i = 0, pi = pImage, imagePtr = adaptorPtr->pImages;
+ i < adaptorPtr->nImages; i++, pi++, imagePtr++)
+ {
+ pi->id = imagePtr->id;
+ pi->type = imagePtr->type;
+ pi->byte_order = imagePtr->byte_order;
+ memcpy(pi->guid, imagePtr->guid, 16);
+ pi->bits_per_pixel = imagePtr->bits_per_pixel;
+ pi->format = imagePtr->format;
+ pi->num_planes = imagePtr->num_planes;
+ pi->depth = imagePtr->depth;
+ pi->red_mask = imagePtr->red_mask;
+ pi->green_mask = imagePtr->green_mask;
+ pi->blue_mask = imagePtr->blue_mask;
+ pi->y_sample_bits = imagePtr->y_sample_bits;
+ pi->u_sample_bits = imagePtr->u_sample_bits;
+ pi->v_sample_bits = imagePtr->v_sample_bits;
+ pi->horz_y_period = imagePtr->horz_y_period;
+ pi->horz_u_period = imagePtr->horz_u_period;
+ pi->horz_v_period = imagePtr->horz_v_period;
+ pi->vert_y_period = imagePtr->vert_y_period;
+ pi->vert_u_period = imagePtr->vert_u_period;
+ pi->vert_v_period = imagePtr->vert_v_period;
+ memcpy(pi->component_order, imagePtr->component_order, 32);
+ pi->scanline_order = imagePtr->scanline_order;
+ }
+ pa->nImages = adaptorPtr->nImages;
+ pa->pImages = pImage;
+ }
+
+ if(adaptorPtr->nAttributes &&
+ (pAttribute = xcalloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec))))
+ {
+ for(pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i = 0;
+ i < adaptorPtr->nAttributes; pat++, i++, attributePtr++)
+ {
+ pat->flags = attributePtr->flags;
+ pat->min_value = attributePtr->min_value;
+ pat->max_value = attributePtr->max_value;
+ if((pat->name = xalloc(strlen(attributePtr->name) + 1)))
+ strcpy(pat->name, attributePtr->name);
+ }
+ pa->nAttributes = adaptorPtr->nAttributes;
+ pa->pAttributes = pAttribute;
+ }
+
+
+ totFormat = adaptorPtr->nFormats;
+
+ if(!(pFormat = xcalloc(totFormat, sizeof(XvFormatRec)))) {
+ xf86XVFreeAdaptor(pa);
+ continue;
+ }
+ for(pf = pFormat, i = 0, numFormat = 0, formatPtr = adaptorPtr->pFormats;
+ i < adaptorPtr->nFormats; i++, formatPtr++)
+ {
+ numVisuals = pScreen->numVisuals;
+ pVisual = pScreen->visuals;
+
+ while(numVisuals--) {
+ if((pVisual->class == formatPtr->class) &&
+ (pVisual->nplanes == formatPtr->depth)) {
+
+ if(numFormat >= totFormat) {
+ void *moreSpace;
+ totFormat *= 2;
+ moreSpace = xrealloc(pFormat,
+ totFormat * sizeof(XvFormatRec));
+ if(!moreSpace) break;
+ pFormat = moreSpace;
+ pf = pFormat + numFormat;
+ }
+
+ pf->visual = pVisual->vid;
+ pf->depth = formatPtr->depth;
+
+ pf++;
+ numFormat++;
+ }
+ pVisual++;
+ }
+ }
+ pa->nFormats = numFormat;
+ pa->pFormats = pFormat;
+ if(!numFormat) {
+ xf86XVFreeAdaptor(pa);
+ continue;
+ }
+
+ if(!(adaptorPriv = xcalloc(1, sizeof(XvAdaptorRecPrivate)))) {
+ xf86XVFreeAdaptor(pa);
+ continue;
+ }
+
+ adaptorPriv->flags = adaptorPtr->flags;
+ adaptorPriv->PutVideo = adaptorPtr->PutVideo;
+ adaptorPriv->PutStill = adaptorPtr->PutStill;
+ adaptorPriv->GetVideo = adaptorPtr->GetVideo;
+ adaptorPriv->GetStill = adaptorPtr->GetStill;
+ adaptorPriv->StopVideo = adaptorPtr->StopVideo;
+ adaptorPriv->SetPortAttribute = adaptorPtr->SetPortAttribute;
+ adaptorPriv->GetPortAttribute = adaptorPtr->GetPortAttribute;
+ adaptorPriv->QueryBestSize = adaptorPtr->QueryBestSize;
+ adaptorPriv->QueryImageAttributes = adaptorPtr->QueryImageAttributes;
+ adaptorPriv->PutImage = adaptorPtr->PutImage;
+ adaptorPriv->ReputImage = adaptorPtr->ReputImage;
+
+ pa->devPriv.ptr = (pointer)adaptorPriv;
+
+ if(!(pPort = xcalloc(adaptorPtr->nPorts, sizeof(XvPortRec)))) {
+ xf86XVFreeAdaptor(pa);
+ continue;
+ }
+ for(pp = pPort, i = 0, numPort = 0;
+ i < adaptorPtr->nPorts; i++) {
+
+ if(!(pp->id = FakeClientID(0)))
+ continue;
+
+ if(!(portPriv = xcalloc(1, sizeof(XvPortRecPrivate))))
+ continue;
+
+ if(!AddResource(pp->id, PortResource, pp)) {
+ xfree(portPriv);
+ continue;
+ }
+
+ pp->pAdaptor = pa;
+ pp->pNotify = (XvPortNotifyPtr)NULL;
+ pp->pDraw = (DrawablePtr)NULL;
+ pp->client = (ClientPtr)NULL;
+ pp->grab.client = (ClientPtr)NULL;
+ pp->time = currentTime;
+ pp->devPriv.ptr = portPriv;
+
+ portPriv->pScrn = pScrn;
+ portPriv->AdaptorRec = adaptorPriv;
+ portPriv->DevPriv.ptr = adaptorPtr->pPortPrivates[i].ptr;
+
+ pp++;
+ numPort++;
+ }
+ pa->nPorts = numPort;
+ pa->pPorts = pPort;
+ if(!numPort) {
+ xf86XVFreeAdaptor(pa);
+ continue;
+ }
+
+ pa->base_id = pPort->id;
+
+ pa++;
+ numAdaptor++;
+ }
+
+ if(numAdaptor) {
+ pxvs->nAdaptors = numAdaptor;
+ pxvs->pAdaptors = pAdaptor;
+ } else {
+ xfree(pAdaptor);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Video should be clipped to the intersection of the window cliplist
+ and the client cliplist specified in the GC for which the video was
+ initialized. When we need to reclip a window, the GC that started
+ the video may not even be around anymore. That's why we save the
+ client clip from the GC when the video is initialized. We then
+ use xf86XVUpdateCompositeClip to calculate the new composite clip
+ when we need it. This is different from what DEC did. They saved
+ the GC and used it's clip list when they needed to reclip the window,
+ even if the client clip was different from the one the video was
+ initialized with. If the original GC was destroyed, they had to stop
+ the video. I like the new method better (MArk).
+
+ This function only works for windows. Will need to rewrite when
+ (if) we support pixmap rendering.
+*/
+
+static void
+xf86XVUpdateCompositeClip(XvPortRecPrivatePtr portPriv)
+{
+ RegionPtr pregWin, pCompositeClip;
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ Bool freeCompClip = FALSE;
+
+ if(portPriv->pCompositeClip)
+ return;
+
+ pWin = (WindowPtr)portPriv->pDraw;
+ pScreen = pWin->drawable.pScreen;
+
+ /* get window clip list */
+ if(portPriv->subWindowMode == IncludeInferiors) {
+ pregWin = NotClippedByChildren(pWin);
+ freeCompClip = TRUE;
+ } else
+ pregWin = &pWin->clipList;
+
+ if(!portPriv->clientClip) {
+ portPriv->pCompositeClip = pregWin;
+ portPriv->FreeCompositeClip = freeCompClip;
+ return;
+ }
+
+ pCompositeClip = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_COPY(pScreen, pCompositeClip, portPriv->clientClip);
+ REGION_TRANSLATE(pScreen, pCompositeClip,
+ portPriv->pDraw->x + portPriv->clipOrg.x,
+ portPriv->pDraw->y + portPriv->clipOrg.y);
+ REGION_INTERSECT(pScreen, pCompositeClip, pregWin, pCompositeClip);
+
+ portPriv->pCompositeClip = pCompositeClip;
+ portPriv->FreeCompositeClip = TRUE;
+
+ if(freeCompClip) {
+ REGION_DESTROY(pScreen, pregWin);
+ }
+}
+
+/* Save the current clientClip and update the CompositeClip whenever
+ we have a fresh GC */
+
+static void
+xf86XVCopyClip(
+ XvPortRecPrivatePtr portPriv,
+ GCPtr pGC
+){
+ ScreenPtr pScreen = pGC->pScreen;
+
+ /* copy the new clip if it exists */
+ if((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
+ if(!portPriv->clientClip)
+ portPriv->clientClip = REGION_CREATE(pScreen, NullBox, 1);
+ /* Note: this is in window coordinates */
+ REGION_COPY(pScreen, portPriv->clientClip, pGC->clientClip);
+ } else if(portPriv->clientClip) { /* free the old clientClip */
+ REGION_DESTROY(pScreen, portPriv->clientClip);
+ portPriv->clientClip = NULL;
+ }
+
+ /* get rid of the old clip list */
+ if(portPriv->pCompositeClip && portPriv->FreeCompositeClip) {
+ REGION_DESTROY(pScreen, portPriv->pCompositeClip);
+ }
+
+ portPriv->clipOrg = pGC->clipOrg;
+ portPriv->pCompositeClip = pGC->pCompositeClip;
+ portPriv->FreeCompositeClip = FALSE;
+ portPriv->subWindowMode = pGC->subWindowMode;
+}
+
+static int
+xf86XVRegetVideo(XvPortRecPrivatePtr portPriv)
+{
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ ScreenPtr pScreen;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ pScreen = portPriv->pDraw->pScreen;
+ xf86XVUpdateCompositeClip(portPriv);
+
+ /* translate the video region to the screen */
+ WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
+ WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
+ WinBox.x2 = WinBox.x1 + portPriv->drw_w;
+ WinBox.y2 = WinBox.y1 + portPriv->drw_h;
+
+ /* clip to the window composite clip */
+ REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
+ REGION_NULL(pScreen, &ClipRegion);
+ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
+ /* that's all if it's totally obscured */
+ if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->pScrn,
+ portPriv->vid_x, portPriv->vid_y,
+ WinBox.x1, WinBox.y1,
+ portPriv->vid_w, portPriv->vid_h,
+ portPriv->drw_w, portPriv->drw_h,
+ &ClipRegion, portPriv->DevPriv.ptr);
+
+ if(ret == Success)
+ portPriv->isOn = XV_ON;
+
+CLIP_VIDEO_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && portPriv->isOn == XV_ON) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if(!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ REGION_UNINIT(pScreen, &WinRegion);
+ REGION_UNINIT(pScreen, &ClipRegion);
+
+ return ret;
+}
+
+
+static int
+xf86XVReputVideo(XvPortRecPrivatePtr portPriv)
+{
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ ScreenPtr pScreen;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ pScreen = portPriv->pDraw->pScreen;
+
+ xf86XVUpdateCompositeClip(portPriv);
+
+ /* translate the video region to the screen */
+ WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
+ WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
+ WinBox.x2 = WinBox.x1 + portPriv->drw_w;
+ WinBox.y2 = WinBox.y1 + portPriv->drw_h;
+
+ /* clip to the window composite clip */
+ REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
+ REGION_NULL(pScreen, &ClipRegion);
+ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
+ /* clip and translate to the viewport */
+ if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = portPriv->pScrn->frameX0;
+ VPBox.y1 = portPriv->pScrn->frameY0;
+ VPBox.x2 = portPriv->pScrn->frameX1;
+ VPBox.y2 = portPriv->pScrn->frameY1;
+
+ REGION_INIT(pScreen, &VPReg, &VPBox, 1);
+ REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg);
+ REGION_UNINIT(pScreen, &VPReg);
+ }
+
+ /* that's all if it's totally obscured */
+ if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+
+ /* bailout if we have to clip but the hardware doesn't support it */
+ if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = REGION_RECTS(&ClipRegion);
+ if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
+ {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->pScrn,
+ portPriv->vid_x, portPriv->vid_y,
+ WinBox.x1, WinBox.y1,
+ portPriv->vid_w, portPriv->vid_h,
+ portPriv->drw_w, portPriv->drw_h,
+ &ClipRegion, portPriv->DevPriv.ptr);
+
+ if(ret == Success) portPriv->isOn = XV_ON;
+
+CLIP_VIDEO_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if(!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ REGION_UNINIT(pScreen, &WinRegion);
+ REGION_UNINIT(pScreen, &ClipRegion);
+
+ return ret;
+}
+
+static int
+xf86XVReputImage(XvPortRecPrivatePtr portPriv)
+{
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ ScreenPtr pScreen;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ pScreen = portPriv->pDraw->pScreen;
+
+ xf86XVUpdateCompositeClip(portPriv);
+
+ /* translate the video region to the screen */
+ WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
+ WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
+ WinBox.x2 = WinBox.x1 + portPriv->drw_w;
+ WinBox.y2 = WinBox.y1 + portPriv->drw_h;
+
+ /* clip to the window composite clip */
+ REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
+ REGION_NULL(pScreen, &ClipRegion);
+ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
+ /* clip and translate to the viewport */
+ if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = portPriv->pScrn->frameX0;
+ VPBox.y1 = portPriv->pScrn->frameY0;
+ VPBox.x2 = portPriv->pScrn->frameX1;
+ VPBox.y2 = portPriv->pScrn->frameY1;
+
+ REGION_INIT(pScreen, &VPReg, &VPBox, 1);
+ REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg);
+ REGION_UNINIT(pScreen, &VPReg);
+ }
+
+ /* that's all if it's totally obscured */
+ if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+
+ /* bailout if we have to clip but the hardware doesn't support it */
+ if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = REGION_RECTS(&ClipRegion);
+ if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
+ {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->pScrn,
+ WinBox.x1, WinBox.y1,
+ &ClipRegion, portPriv->DevPriv.ptr);
+
+ portPriv->isOn = (ret == Success) ? XV_ON : XV_OFF;
+
+CLIP_VIDEO_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if(!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ REGION_UNINIT(pScreen, &WinRegion);
+ REGION_UNINIT(pScreen, &ClipRegion);
+
+ return ret;
+}
+
+
+static int
+xf86XVReputAllVideo(WindowPtr pWin, pointer data)
+{
+ XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
+
+ while(WinPriv) {
+ if(WinPriv->PortRec->type == XvInputMask)
+ xf86XVReputVideo(WinPriv->PortRec);
+ else
+ xf86XVRegetVideo(WinPriv->PortRec);
+ WinPriv = WinPriv->next;
+ }
+
+ return WT_WALKCHILDREN;
+}
+
+static int
+xf86XVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
+{
+ XF86XVWindowPtr winPriv, PrivRoot;
+
+ winPriv = PrivRoot = GET_XF86XV_WINDOW(pWin);
+
+ /* Enlist our port in the window private */
+ while(winPriv) {
+ if(winPriv->PortRec == portPriv) /* we're already listed */
+ break;
+ winPriv = winPriv->next;
+ }
+
+ if(!winPriv) {
+ winPriv = xalloc(sizeof(XF86XVWindowRec));
+ if(!winPriv) return BadAlloc;
+ winPriv->PortRec = portPriv;
+ winPriv->next = PrivRoot;
+ pWin->devPrivates[XF86XVWindowIndex].ptr = (pointer)winPriv;
+ }
+ return Success;
+}
+
+
+static void
+xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
+{
+ XF86XVWindowPtr winPriv, prevPriv = NULL;
+
+ winPriv = GET_XF86XV_WINDOW(pWin);
+
+ while(winPriv) {
+ if(winPriv->PortRec == portPriv) {
+ if(prevPriv)
+ prevPriv->next = winPriv->next;
+ else
+ pWin->devPrivates[XF86XVWindowIndex].ptr =
+ (pointer)winPriv->next;
+ xfree(winPriv);
+ break;
+ }
+ prevPriv = winPriv;
+ winPriv = winPriv->next;
+ }
+ portPriv->pDraw = NULL;
+}
+
+/**** ScreenRec fields ****/
+
+static Bool
+xf86XVDestroyWindow(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ XF86XVWindowPtr tmp, WinPriv = GET_XF86XV_WINDOW(pWin);
+ int ret;
+
+ while(WinPriv) {
+ XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
+
+ if(pPriv->isOn > XV_OFF) {
+ (*pPriv->AdaptorRec->StopVideo)(
+ pPriv->pScrn, pPriv->DevPriv.ptr, TRUE);
+ pPriv->isOn = XV_OFF;
+ }
+
+ pPriv->pDraw = NULL;
+ tmp = WinPriv;
+ WinPriv = WinPriv->next;
+ xfree(tmp);
+ }
+
+ pWin->devPrivates[XF86XVWindowIndex].ptr = NULL;
+
+ pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
+ ret = (*pScreen->DestroyWindow)(pWin);
+ pScreen->DestroyWindow = xf86XVDestroyWindow;
+
+ return ret;
+}
+
+
+static void
+xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
+ XF86XVWindowPtr pPrev;
+ XvPortRecPrivatePtr pPriv;
+ Bool AreasExposed;
+
+ AreasExposed = (WinPriv && reg1 && REGION_NOTEMPTY(pScreen, reg1));
+
+ pScreen->WindowExposures = ScreenPriv->WindowExposures;
+ (*pScreen->WindowExposures)(pWin, reg1, reg2);
+ pScreen->WindowExposures = xf86XVWindowExposures;
+
+ /* filter out XClearWindow/Area */
+ if (!pWin->valdata) return;
+
+ pPrev = NULL;
+
+ while(WinPriv) {
+ pPriv = WinPriv->PortRec;
+
+ /* Reput anyone with a reput function */
+
+ switch(pPriv->type) {
+ case XvInputMask:
+ xf86XVReputVideo(pPriv);
+ break;
+ case XvOutputMask:
+ xf86XVRegetVideo(pPriv);
+ break;
+ default: /* overlaid still/image*/
+ if (pPriv->AdaptorRec->ReputImage)
+ xf86XVReputImage(pPriv);
+ else if(AreasExposed) {
+ XF86XVWindowPtr tmp;
+
+ if (pPriv->isOn == XV_ON) {
+ (*pPriv->AdaptorRec->StopVideo)(
+ pPriv->pScrn, pPriv->DevPriv.ptr, FALSE);
+ pPriv->isOn = XV_PENDING;
+ }
+ pPriv->pDraw = NULL;
+
+ if(!pPrev)
+ pWin->devPrivates[XF86XVWindowIndex].ptr =
+ (pointer)(WinPriv->next);
+ else
+ pPrev->next = WinPriv->next;
+ tmp = WinPriv;
+ WinPriv = WinPriv->next;
+ xfree(tmp);
+ continue;
+ }
+ break;
+ }
+ pPrev = WinPriv;
+ WinPriv = WinPriv->next;
+ }
+}
+
+
+static void
+xf86XVClipNotify(WindowPtr pWin, int dx, int dy)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
+ XF86XVWindowPtr tmp, pPrev = NULL;
+ XvPortRecPrivatePtr pPriv;
+ Bool visible = (pWin->visibility == VisibilityUnobscured) ||
+ (pWin->visibility == VisibilityPartiallyObscured);
+
+ while(WinPriv) {
+ pPriv = WinPriv->PortRec;
+
+ if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+
+ pPriv->pCompositeClip = NULL;
+
+ /* Stop everything except images, but stop them too if the
+ window isn't visible. But we only remove the images. */
+
+ if(pPriv->type || !visible) {
+ if(pPriv->isOn == XV_ON) {
+ (*pPriv->AdaptorRec->StopVideo)(
+ pPriv->pScrn, pPriv->DevPriv.ptr, FALSE);
+ pPriv->isOn = XV_PENDING;
+ }
+
+ if(!pPriv->type) { /* overlaid still/image */
+ pPriv->pDraw = NULL;
+
+ if(!pPrev)
+ pWin->devPrivates[XF86XVWindowIndex].ptr =
+ (pointer)(WinPriv->next);
+ else
+ pPrev->next = WinPriv->next;
+ tmp = WinPriv;
+ WinPriv = WinPriv->next;
+ xfree(tmp);
+ continue;
+ }
+ }
+
+ pPrev = WinPriv;
+ WinPriv = WinPriv->next;
+ }
+
+ if(ScreenPriv->ClipNotify) {
+ pScreen->ClipNotify = ScreenPriv->ClipNotify;
+ (*pScreen->ClipNotify)(pWin, dx, dy);
+ pScreen->ClipNotify = xf86XVClipNotify;
+ }
+}
+
+
+
+/**** Required XvScreenRec fields ****/
+
+static Bool
+xf86XVCloseScreen(int i, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ XvAdaptorPtr pa;
+ int c;
+
+ /* Clear offscreen images */
+ (void)memset(&OffscreenImages[pScreen->myNum], 0, sizeof(OffscreenImages[0]));
+
+ if(!ScreenPriv) return TRUE;
+
+ if(ScreenPriv->videoGC) {
+ FreeGC(ScreenPriv->videoGC, 0);
+ ScreenPriv->videoGC = NULL;
+ }
+
+ pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
+ pScreen->WindowExposures = ScreenPriv->WindowExposures;
+ pScreen->ClipNotify = ScreenPriv->ClipNotify;
+
+ pScrn->EnterVT = ScreenPriv->EnterVT;
+ pScrn->LeaveVT = ScreenPriv->LeaveVT;
+ pScrn->AdjustFrame = ScreenPriv->AdjustFrame;
+
+ for(c = 0, pa = pxvs->pAdaptors; c < pxvs->nAdaptors; c++, pa++) {
+ xf86XVFreeAdaptor(pa);
+ }
+
+ xfree(pxvs->pAdaptors);
+ xfree(ScreenPriv);
+ return TRUE;
+}
+
+
+static int
+xf86XVQueryAdaptors(
+ ScreenPtr pScreen,
+ XvAdaptorPtr *p_pAdaptors,
+ int *p_nAdaptors
+){
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+
+ *p_nAdaptors = pxvs->nAdaptors;
+ *p_pAdaptors = pxvs->pAdaptors;
+
+ return (Success);
+}
+
+
+/**** ScrnInfoRec fields ****/
+
+static Bool
+xf86XVEnterVT(int index, int flags)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ Bool ret;
+
+ ret = (*ScreenPriv->EnterVT)(index, flags);
+
+ if(ret) WalkTree(pScreen, xf86XVReputAllVideo, 0);
+
+ return ret;
+}
+
+static void
+xf86XVLeaveVT(int index, int flags)
+{
+ ScreenPtr pScreen = screenInfo.screens[index];
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ XvAdaptorPtr pAdaptor;
+ XvPortPtr pPort;
+ XvPortRecPrivatePtr pPriv;
+ int i, j;
+
+ for(i = 0; i < pxvs->nAdaptors; i++) {
+ pAdaptor = &pxvs->pAdaptors[i];
+ for(j = 0; j < pAdaptor->nPorts; j++) {
+ pPort = &pAdaptor->pPorts[j];
+ pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
+ if(pPriv->isOn > XV_OFF) {
+
+ (*pPriv->AdaptorRec->StopVideo)(
+ pPriv->pScrn, pPriv->DevPriv.ptr, TRUE);
+ pPriv->isOn = XV_OFF;
+
+ if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+
+ pPriv->pCompositeClip = NULL;
+
+ if(!pPriv->type && pPriv->pDraw) { /* still */
+ xf86XVRemovePortFromWindow((WindowPtr)pPriv->pDraw, pPriv);
+ }
+ }
+ }
+ }
+
+ (*ScreenPriv->LeaveVT)(index, flags);
+}
+
+static void
+xf86XVAdjustFrame(int index, int x, int y, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ ScreenPtr pScreen = pScrn->pScreen;
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ WindowPtr pWin;
+ XvAdaptorPtr pa;
+ int c, i;
+
+ if(ScreenPriv->AdjustFrame) {
+ pScrn->AdjustFrame = ScreenPriv->AdjustFrame;
+ (*pScrn->AdjustFrame)(index, x, y, flags);
+ pScrn->AdjustFrame = xf86XVAdjustFrame;
+ }
+
+ for(c = pxvs->nAdaptors, pa = pxvs->pAdaptors; c > 0; c--, pa++) {
+ XvPortPtr pPort = pa->pPorts;
+ XvPortRecPrivatePtr pPriv;
+
+ for(i = pa->nPorts; i > 0; i--, pPort++) {
+ pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
+
+ if(!pPriv->type && (pPriv->isOn == XV_ON)) { /* overlaid still/image */
+
+ if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+
+ pPriv->pCompositeClip = NULL;
+
+ pWin = (WindowPtr)pPriv->pDraw;
+
+ if ((pPriv->AdaptorRec->ReputImage) &&
+ ((pWin->visibility == VisibilityUnobscured) ||
+ (pWin->visibility == VisibilityPartiallyObscured)))
+ {
+ xf86XVReputImage(pPriv);
+ } else {
+ (*pPriv->AdaptorRec->StopVideo)(
+ pPriv->pScrn, pPriv->DevPriv.ptr, FALSE);
+ xf86XVRemovePortFromWindow(pWin, pPriv);
+ pPriv->isOn = XV_PENDING;
+ continue;
+ }
+ }
+ }
+ }
+}
+
+
+/**** XvAdaptorRec fields ****/
+
+static int
+xf86XVAllocatePort(
+ unsigned long port,
+ XvPortPtr pPort,
+ XvPortPtr *ppPort
+){
+ *ppPort = pPort;
+ return Success;
+}
+
+
+
+static int
+xf86XVFreePort(XvPortPtr pPort)
+{
+ return Success;
+}
+
+
+static int
+xf86XVPutVideo(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+ int result;
+
+ /* No dumping video to pixmaps... For now anyhow */
+ if(pDraw->type != DRAWABLE_WINDOW) {
+ pPort->pDraw = (DrawablePtr)NULL;
+ return BadAlloc;
+ }
+
+ /* If we are changing windows, unregister our port in the old window */
+ if(portPriv->pDraw && (portPriv->pDraw != pDraw))
+ xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+
+ /* Register our port with the new window */
+ result = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
+ if(result != Success) return result;
+
+ portPriv->pDraw = pDraw;
+ portPriv->type = XvInputMask;
+
+ /* save a copy of these parameters */
+ portPriv->vid_x = vid_x; portPriv->vid_y = vid_y;
+ portPriv->vid_w = vid_w; portPriv->vid_h = vid_h;
+ portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
+ portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
+
+ /* make sure we have the most recent copy of the clientClip */
+ xf86XVCopyClip(portPriv, pGC);
+
+ /* To indicate to the DI layer that we were successful */
+ pPort->pDraw = pDraw;
+
+ if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
+
+ return(xf86XVReputVideo(portPriv));
+}
+
+static int
+xf86XVPutStill(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+ ScreenPtr pScreen;
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
+
+ pScreen = pDraw->pScreen;
+
+ WinBox.x1 = pDraw->x + drw_x;
+ WinBox.y1 = pDraw->y + drw_y;
+ WinBox.x2 = WinBox.x1 + drw_w;
+ WinBox.y2 = WinBox.y1 + drw_h;
+
+ REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
+ REGION_NULL(pScreen, &ClipRegion);
+ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+
+ if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = portPriv->pScrn->frameX0;
+ VPBox.y1 = portPriv->pScrn->frameY0;
+ VPBox.x2 = portPriv->pScrn->frameX1;
+ VPBox.y2 = portPriv->pScrn->frameY1;
+
+ REGION_INIT(pScreen, &VPReg, &VPBox, 1);
+ REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg);
+ REGION_UNINIT(pScreen, &VPReg);
+ }
+
+ if(portPriv->pDraw) {
+ xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+ }
+
+ if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
+ goto PUT_STILL_BAILOUT;
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = REGION_RECTS(&ClipRegion);
+ if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
+ {
+ clippedAway = TRUE;
+ goto PUT_STILL_BAILOUT;
+ }
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->PutStill)(portPriv->pScrn,
+ vid_x, vid_y, WinBox.x1, WinBox.y1,
+ vid_w, vid_h, drw_w, drw_h,
+ &ClipRegion, portPriv->DevPriv.ptr);
+
+ if((ret == Success) &&
+ (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_STILLS)) {
+
+ xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
+ portPriv->isOn = XV_ON;
+ portPriv->pDraw = pDraw;
+ portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
+ portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
+ portPriv->type = 0; /* no mask means it's transient and should
+ not be reput once it's removed */
+ pPort->pDraw = pDraw; /* make sure we can get stop requests */
+ }
+
+PUT_STILL_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ REGION_UNINIT(pScreen, &WinRegion);
+ REGION_UNINIT(pScreen, &ClipRegion);
+
+ return ret;
+}
+
+static int
+xf86XVGetVideo(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+ int result;
+
+ /* No pixmaps... For now anyhow */
+ if(pDraw->type != DRAWABLE_WINDOW) {
+ pPort->pDraw = (DrawablePtr)NULL;
+ return BadAlloc;
+ }
+
+ /* If we are changing windows, unregister our port in the old window */
+ if(portPriv->pDraw && (portPriv->pDraw != pDraw))
+ xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+
+ /* Register our port with the new window */
+ result = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
+ if(result != Success) return result;
+
+ portPriv->pDraw = pDraw;
+ portPriv->type = XvOutputMask;
+
+ /* save a copy of these parameters */
+ portPriv->vid_x = vid_x; portPriv->vid_y = vid_y;
+ portPriv->vid_w = vid_w; portPriv->vid_h = vid_h;
+ portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
+ portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
+
+ /* make sure we have the most recent copy of the clientClip */
+ xf86XVCopyClip(portPriv, pGC);
+
+ /* To indicate to the DI layer that we were successful */
+ pPort->pDraw = pDraw;
+
+ if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
+
+ return(xf86XVRegetVideo(portPriv));
+}
+
+static int
+xf86XVGetStill(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+ ScreenPtr pScreen;
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
+
+ pScreen = pDraw->pScreen;
+
+ WinBox.x1 = pDraw->x + drw_x;
+ WinBox.y1 = pDraw->y + drw_y;
+ WinBox.x2 = WinBox.x1 + drw_w;
+ WinBox.y2 = WinBox.y1 + drw_h;
+
+ REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
+ REGION_NULL(pScreen, &ClipRegion);
+ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+
+ if(portPriv->pDraw) {
+ xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+ }
+
+ if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
+ goto GET_STILL_BAILOUT;
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->GetStill)(portPriv->pScrn,
+ vid_x, vid_y, WinBox.x1, WinBox.y1,
+ vid_w, vid_h, drw_w, drw_h,
+ &ClipRegion, portPriv->DevPriv.ptr);
+
+GET_STILL_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ REGION_UNINIT(pScreen, &WinRegion);
+ REGION_UNINIT(pScreen, &ClipRegion);
+
+ return ret;
+}
+
+
+
+static int
+xf86XVStopVideo(
+ ClientPtr client,
+ XvPortPtr pPort,
+ DrawablePtr pDraw
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+
+ if(pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ xf86XVRemovePortFromWindow((WindowPtr)pDraw, portPriv);
+
+ if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
+
+ /* Must free resources. */
+
+ if(portPriv->isOn > XV_OFF) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, TRUE);
+ portPriv->isOn = XV_OFF;
+ }
+
+ return Success;
+}
+
+static int
+xf86XVSetPortAttribute(
+ ClientPtr client,
+ XvPortPtr pPort,
+ Atom attribute,
+ INT32 value
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+
+ return((*portPriv->AdaptorRec->SetPortAttribute)(portPriv->pScrn,
+ attribute, value, portPriv->DevPriv.ptr));
+}
+
+
+static int
+xf86XVGetPortAttribute(
+ ClientPtr client,
+ XvPortPtr pPort,
+ Atom attribute,
+ INT32 *p_value
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+
+ return((*portPriv->AdaptorRec->GetPortAttribute)(portPriv->pScrn,
+ attribute, p_value, portPriv->DevPriv.ptr));
+}
+
+
+
+static int
+xf86XVQueryBestSize(
+ ClientPtr client,
+ XvPortPtr pPort,
+ CARD8 motion,
+ CARD16 vid_w, CARD16 vid_h,
+ CARD16 drw_w, CARD16 drw_h,
+ unsigned int *p_w, unsigned int *p_h
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+
+ (*portPriv->AdaptorRec->QueryBestSize)(portPriv->pScrn,
+ (Bool)motion, vid_w, vid_h, drw_w, drw_h,
+ p_w, p_h, portPriv->DevPriv.ptr);
+
+ return Success;
+}
+
+
+static int
+xf86XVPutImage(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 src_x, INT16 src_y,
+ CARD16 src_w, CARD16 src_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h,
+ XvImagePtr format,
+ unsigned char* data,
+ Bool sync,
+ CARD16 width, CARD16 height
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+ ScreenPtr pScreen;
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
+
+ pScreen = pDraw->pScreen;
+
+ WinBox.x1 = pDraw->x + drw_x;
+ WinBox.y1 = pDraw->y + drw_y;
+ WinBox.x2 = WinBox.x1 + drw_w;
+ WinBox.y2 = WinBox.y1 + drw_h;
+
+ REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
+ REGION_NULL(pScreen, &ClipRegion);
+ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+
+ if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = portPriv->pScrn->frameX0;
+ VPBox.y1 = portPriv->pScrn->frameY0;
+ VPBox.x2 = portPriv->pScrn->frameX1 + 1;
+ VPBox.y2 = portPriv->pScrn->frameY1 + 1;
+
+ REGION_INIT(pScreen, &VPReg, &VPBox, 1);
+ REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg);
+ REGION_UNINIT(pScreen, &VPReg);
+ }
+
+ if(portPriv->pDraw) {
+ xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+ }
+
+ if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
+ goto PUT_IMAGE_BAILOUT;
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = REGION_RECTS(&ClipRegion);
+ if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
+ {
+ clippedAway = TRUE;
+ goto PUT_IMAGE_BAILOUT;
+ }
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->PutImage)(portPriv->pScrn,
+ src_x, src_y, WinBox.x1, WinBox.y1,
+ src_w, src_h, drw_w, drw_h, format->id, data, width, height,
+ sync, &ClipRegion, portPriv->DevPriv.ptr);
+
+ if((ret == Success) &&
+ (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) {
+
+ xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
+ portPriv->isOn = XV_ON;
+ portPriv->pDraw = pDraw;
+ portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
+ portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
+ portPriv->type = 0; /* no mask means it's transient and should
+ not be reput once it's removed */
+ pPort->pDraw = pDraw; /* make sure we can get stop requests */
+ }
+
+PUT_IMAGE_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ REGION_UNINIT(pScreen, &WinRegion);
+ REGION_UNINIT(pScreen, &ClipRegion);
+
+ return ret;
+}
+
+
+static int
+xf86XVQueryImageAttributes(
+ ClientPtr client,
+ XvPortPtr pPort,
+ XvImagePtr format,
+ CARD16 *width,
+ CARD16 *height,
+ int *pitches,
+ int *offsets
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+
+ return (*portPriv->AdaptorRec->QueryImageAttributes)(portPriv->pScrn,
+ format->id, width, height, pitches, offsets);
+}
+
+void
+xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes)
+{
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ DrawablePtr root = &WindowTable[pScreen->myNum]->drawable;
+ XID pval[2];
+ BoxPtr pbox = REGION_RECTS(clipboxes);
+ int i, nbox = REGION_NUM_RECTS(clipboxes);
+ xRectangle *rects;
+
+ if(!xf86Screens[pScreen->myNum]->vtSema) return;
+
+ if(!ScreenPriv->videoGC) {
+ int status;
+ pval[0] = key;
+ pval[1] = IncludeInferiors;
+ ScreenPriv->videoGC = CreateGC(root, GCForeground | GCSubwindowMode,
+ pval, &status);
+ if(!ScreenPriv->videoGC) return;
+ ValidateGC(root, ScreenPriv->videoGC);
+ } else if (key != ScreenPriv->videoGC->fgPixel){
+ pval[0] = key;
+ ChangeGC(ScreenPriv->videoGC, GCForeground, pval);
+ ValidateGC(root, ScreenPriv->videoGC);
+ }
+
+ rects = ALLOCATE_LOCAL(nbox * sizeof(xRectangle));
+
+ for(i = 0; i < nbox; i++, pbox++) {
+ rects[i].x = pbox->x1;
+ rects[i].y = pbox->y1;
+ rects[i].width = pbox->x2 - pbox->x1;
+ rects[i].height = pbox->y2 - pbox->y1;
+ }
+
+ (*ScreenPriv->videoGC->ops->PolyFillRect)(
+ root, ScreenPriv->videoGC, nbox, rects);
+
+ DEALLOCATE_LOCAL(rects);
+}
+
+/* xf86XVClipVideoHelper -
+
+ Takes the dst box in standard X BoxRec form (top and left
+ edges inclusive, bottom and right exclusive). The new dst
+ box is returned. The source boundaries are given (x1, y1
+ inclusive, x2, y2 exclusive) and returned are the new source
+ boundaries in 16.16 fixed point.
+*/
+
+#define DummyScreen screenInfo.screens[0]
+
+Bool
+xf86XVClipVideoHelper(
+ BoxPtr dst,
+ INT32 *xa,
+ INT32 *xb,
+ INT32 *ya,
+ INT32 *yb,
+ RegionPtr reg,
+ INT32 width,
+ INT32 height
+){
+ double xsw, xdw, ysw, ydw;
+ INT32 delta;
+ BoxPtr extents = REGION_EXTENTS(DummyScreen, reg);
+ int diff;
+
+ xsw = (*xb - *xa) << 16;
+ xdw = dst->x2 - dst->x1;
+ ysw = (*yb - *ya) << 16;
+ ydw = dst->y2 - dst->y1;
+
+ *xa <<= 16; *xb <<= 16;
+ *ya <<= 16; *yb <<= 16;
+
+ diff = extents->x1 - dst->x1;
+ if (diff > 0) {
+ dst->x1 = extents->x1;
+ *xa += (diff * xsw) / xdw;
+ }
+ diff = dst->x2 - extents->x2;
+ if (diff > 0) {
+ dst->x2 = extents->x2;
+ *xb -= (diff * xsw) / xdw;
+ }
+ diff = extents->y1 - dst->y1;
+ if (diff > 0) {
+ dst->y1 = extents->y1;
+ *ya += (diff * ysw) / ydw;
+ }
+ diff = dst->y2 - extents->y2;
+ if (diff > 0) {
+ dst->y2 = extents->y2;
+ *yb -= (diff * ysw) / ydw;
+ }
+
+ if (*xa < 0) {
+ diff = (((-*xa) * xdw) + xsw - 1) / xsw;
+ dst->x1 += diff;
+ *xa += (diff * xsw) / xdw;
+ }
+ delta = *xb - (width << 16);
+ if (delta > 0) {
+ diff = ((delta * xdw) + xsw - 1) / xsw;
+ dst->x2 -= diff;
+ *xb -= (diff * xsw) / xdw;
+ }
+ if (*xa >= *xb) return FALSE;
+
+ if (*ya < 0) {
+ diff = (((-*ya) * ydw) + ysw - 1) / ysw;
+ dst->y1 += diff;
+ *ya += (diff * ysw) / ydw;
+ }
+ delta = *yb - (height << 16);
+ if (delta > 0) {
+ diff = ((delta * ydw) + ysw - 1) / ysw;
+ dst->y2 -= diff;
+ *yb -= (diff * ysw) / ydw;
+ }
+ if (*ya >= *yb) return FALSE;
+
+ if ((dst->x1 > extents->x1) || (dst->x2 < extents->x2) ||
+ (dst->y1 > extents->y1) || (dst->y2 < extents->y2))
+ {
+ RegionRec clipReg;
+ REGION_INIT(DummyScreen, &clipReg, dst, 1);
+ REGION_INTERSECT(DummyScreen, reg, reg, &clipReg);
+ REGION_UNINIT(DummyScreen, &clipReg);
+ }
+ return TRUE;
+}
+
+void
+xf86XVCopyYUV12ToPacked(
+ const void *srcy,
+ const void *srcv,
+ const void *srcu,
+ void *dst,
+ int srcPitchy,
+ int srcPitchuv,
+ int dstPitch,
+ int h,
+ int w
+){
+ CARD32 *Dst;
+ const CARD8 *Y, *U, *V;
+ int i, j;
+
+ w >>= 1;
+
+ for (j = 0; j < h; j++) {
+ Dst = dst;
+ Y = srcy; V = srcv; U = srcu;
+ i = w;
+ while (i >= 4) {
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+ Dst[0] = Y[0] | (Y[1] << 16) | (U[0] << 8) | (V[0] << 24);
+ Dst[1] = Y[2] | (Y[3] << 16) | (U[1] << 8) | (V[1] << 24);
+ Dst[2] = Y[4] | (Y[5] << 16) | (U[2] << 8) | (V[2] << 24);
+ Dst[3] = Y[6] | (Y[7] << 16) | (U[3] << 8) | (V[3] << 24);
+#else
+ /* This assumes a little-endian framebuffer */
+ Dst[0] = (Y[0] << 24) | (Y[1] << 8) | (U[0] << 16) | V[0];
+ Dst[1] = (Y[2] << 24) | (Y[3] << 8) | (U[1] << 16) | V[1];
+ Dst[2] = (Y[4] << 24) | (Y[5] << 8) | (U[2] << 16) | V[2];
+ Dst[3] = (Y[6] << 24) | (Y[7] << 8) | (U[3] << 16) | V[3];
+#endif
+ Dst += 4; Y += 8; V += 4; U += 4;
+ i -= 4;
+ }
+
+ while (i--) {
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+ Dst[0] = Y[0] | (Y[1] << 16) | (U[0] << 8) | (V[0] << 24);
+#else
+ /* This assumes a little-endian framebuffer */
+ Dst[0] = (Y[0] << 24) | (Y[1] << 8) | (U[0] << 16) | V[0];
+#endif
+ Dst++; Y += 2; V++; U++;
+ }
+
+ dst = (CARD8 *)dst + dstPitch;
+ srcy = (const CARD8 *)srcy + srcPitchy;
+ if (j & 1) {
+ srcu = (const CARD8 *)srcu + srcPitchuv;
+ srcv = (const CARD8 *)srcv + srcPitchuv;
+ }
+ }
+}
+
+void
+xf86XVCopyPacked(
+ const void *src,
+ void *dst,
+ int srcPitch,
+ int dstPitch,
+ int h,
+ int w
+){
+ const CARD32 *Src;
+ CARD32 *Dst;
+ int i;
+
+ w >>= 1;
+ while (--h >= 0) {
+ do {
+ Dst = dst; Src = src;
+ i = w;
+ while (i >= 4) {
+ Dst[0] = Src[0];
+ Dst[1] = Src[1];
+ Dst[2] = Src[2];
+ Dst[3] = Src[3];
+ Dst += 4; Src += 4; i -= 4;
+ }
+ if (!i) break;
+ Dst[0] = Src[0];
+ if (i == 1) break;
+ Dst[1] = Src[1];
+ if (i == 2) break;
+ Dst[2] = Src[2];
+ } while (0);
+
+ src = (const CARD8 *)src + srcPitch;
+ dst = (CARD8 *)dst + dstPitch;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86xv.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86xv.h
new file mode 100644
index 000000000..316d6c9e5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86xv.h
@@ -0,0 +1,271 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.h,v 1.25 2003/08/24 17:36:56 dawes Exp $ */
+
+/*
+ * Copyright (c) 1998-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifndef _XF86XV_H_
+#define _XF86XV_H_
+
+#include "xvdix.h"
+#include "xf86str.h"
+
+#define VIDEO_NO_CLIPPING 0x00000001
+#define VIDEO_INVERT_CLIPLIST 0x00000002
+#define VIDEO_OVERLAID_IMAGES 0x00000004
+#define VIDEO_OVERLAID_STILLS 0x00000008
+#define VIDEO_CLIP_TO_VIEWPORT 0x00000010
+
+typedef struct {
+ int id;
+ int type;
+ int byte_order;
+ unsigned char guid[16];
+ int bits_per_pixel;
+ int format;
+ int num_planes;
+
+ /* for RGB formats only */
+ int depth;
+ unsigned int red_mask;
+ unsigned int green_mask;
+ unsigned int blue_mask;
+
+ /* for YUV formats only */
+ unsigned int y_sample_bits;
+ unsigned int u_sample_bits;
+ unsigned int v_sample_bits;
+ unsigned int horz_y_period;
+ unsigned int horz_u_period;
+ unsigned int horz_v_period;
+ unsigned int vert_y_period;
+ unsigned int vert_u_period;
+ unsigned int vert_v_period;
+ char component_order[32];
+ int scanline_order;
+} XF86ImageRec, *XF86ImagePtr;
+
+
+typedef struct {
+ ScrnInfoPtr pScrn;
+ int id;
+ unsigned short width, height;
+ int *pitches; /* bytes */
+ int *offsets; /* in bytes from start of framebuffer */
+ DevUnion devPrivate;
+} XF86SurfaceRec, *XF86SurfacePtr;
+
+
+typedef int (* PutVideoFuncPtr)( ScrnInfoPtr pScrn,
+ short vid_x, short vid_y, short drw_x, short drw_y,
+ short vid_w, short vid_h, short drw_w, short drw_h,
+ RegionPtr clipBoxes, pointer data );
+typedef int (* PutStillFuncPtr)( ScrnInfoPtr pScrn,
+ short vid_x, short vid_y, short drw_x, short drw_y,
+ short vid_w, short vid_h, short drw_w, short drw_h,
+ RegionPtr clipBoxes, pointer data );
+typedef int (* GetVideoFuncPtr)( ScrnInfoPtr pScrn,
+ short vid_x, short vid_y, short drw_x, short drw_y,
+ short vid_w, short vid_h, short drw_w, short drw_h,
+ RegionPtr clipBoxes, pointer data );
+typedef int (* GetStillFuncPtr)( ScrnInfoPtr pScrn,
+ short vid_x, short vid_y, short drw_x, short drw_y,
+ short vid_w, short vid_h, short drw_w, short drw_h,
+ RegionPtr clipBoxes, pointer data );
+typedef void (* StopVideoFuncPtr)(ScrnInfoPtr pScrn, pointer data, Bool Exit);
+typedef int (* SetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, Atom attribute,
+ INT32 value, pointer data);
+typedef int (* GetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, Atom attribute,
+ INT32 *value, pointer data);
+typedef void (* QueryBestSizeFuncPtr)(ScrnInfoPtr pScrn, Bool motion,
+ short vid_w, short vid_h, short drw_w, short drw_h,
+ unsigned int *p_w, unsigned int *p_h, pointer data);
+typedef int (* PutImageFuncPtr)( ScrnInfoPtr pScrn,
+ short src_x, short src_y, short drw_x, short drw_y,
+ short src_w, short src_h, short drw_w, short drw_h,
+ int image, unsigned char* buf, short width, short height, Bool Sync,
+ RegionPtr clipBoxes, pointer data );
+typedef int (* ReputImageFuncPtr)( ScrnInfoPtr pScrn, short drw_x, short drw_y,
+ RegionPtr clipBoxes, pointer data );
+typedef int (*QueryImageAttributesFuncPtr)(ScrnInfoPtr pScrn,
+ int image, unsigned short *width, unsigned short *height,
+ int *pitches, int *offsets);
+
+typedef enum {
+ XV_OFF,
+ XV_PENDING,
+ XV_ON
+} XvStatus;
+
+/*** this is what the driver needs to fill out ***/
+
+typedef struct {
+ int id;
+ char *name;
+ unsigned short width, height;
+ XvRationalRec rate;
+} XF86VideoEncodingRec, *XF86VideoEncodingPtr;
+
+typedef struct {
+ char depth;
+ short class;
+} XF86VideoFormatRec, *XF86VideoFormatPtr;
+
+typedef struct {
+ int flags;
+ int min_value;
+ int max_value;
+ char *name;
+} XF86AttributeRec, *XF86AttributePtr;
+
+typedef struct {
+ unsigned int type;
+ int flags;
+ char *name;
+ int nEncodings;
+ XF86VideoEncodingPtr pEncodings;
+ int nFormats;
+ XF86VideoFormatPtr pFormats;
+ int nPorts;
+ DevUnion *pPortPrivates;
+ int nAttributes;
+ XF86AttributePtr pAttributes;
+ int nImages;
+ XF86ImagePtr pImages;
+ PutVideoFuncPtr PutVideo;
+ PutStillFuncPtr PutStill;
+ GetVideoFuncPtr GetVideo;
+ GetStillFuncPtr GetStill;
+ StopVideoFuncPtr StopVideo;
+ SetPortAttributeFuncPtr SetPortAttribute;
+ GetPortAttributeFuncPtr GetPortAttribute;
+ QueryBestSizeFuncPtr QueryBestSize;
+ PutImageFuncPtr PutImage;
+ ReputImageFuncPtr ReputImage;
+ QueryImageAttributesFuncPtr QueryImageAttributes;
+} XF86VideoAdaptorRec, *XF86VideoAdaptorPtr;
+
+typedef struct {
+ XF86ImagePtr image;
+ int flags;
+ int (*alloc_surface)(ScrnInfoPtr pScrn,
+ int id,
+ unsigned short width,
+ unsigned short height,
+ XF86SurfacePtr surface);
+ int (*free_surface)(XF86SurfacePtr surface);
+ int (*display) (XF86SurfacePtr surface,
+ short vid_x, short vid_y,
+ short drw_x, short drw_y,
+ short vid_w, short vid_h,
+ short drw_w, short drw_h,
+ RegionPtr clipBoxes);
+ int (*stop) (XF86SurfacePtr surface);
+ int (*getAttribute) (ScrnInfoPtr pScrn, Atom attr, INT32 *value);
+ int (*setAttribute) (ScrnInfoPtr pScrn, Atom attr, INT32 value);
+ int max_width;
+ int max_height;
+ int num_attributes;
+ XF86AttributePtr attributes;
+} XF86OffscreenImageRec, *XF86OffscreenImagePtr;
+
+Bool
+xf86XVScreenInit(
+ ScreenPtr pScreen,
+ XF86VideoAdaptorPtr *Adaptors,
+ int num
+);
+
+typedef int (* xf86XVInitGenericAdaptorPtr)(ScrnInfoPtr pScrn,
+ XF86VideoAdaptorPtr **Adaptors);
+
+int
+xf86XVRegisterGenericAdaptorDriver(
+ xf86XVInitGenericAdaptorPtr InitFunc
+);
+
+int
+xf86XVListGenericAdaptors(
+ ScrnInfoPtr pScrn,
+ XF86VideoAdaptorPtr **Adaptors
+);
+
+Bool
+xf86XVRegisterOffscreenImages(
+ ScreenPtr pScreen,
+ XF86OffscreenImagePtr images,
+ int num
+);
+
+XF86OffscreenImagePtr
+xf86XVQueryOffscreenImages(
+ ScreenPtr pScreen,
+ int *num
+);
+
+XF86VideoAdaptorPtr xf86XVAllocateVideoAdaptorRec(ScrnInfoPtr pScrn);
+
+void xf86XVFreeVideoAdaptorRec(XF86VideoAdaptorPtr ptr);
+
+void
+xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes);
+
+Bool
+xf86XVClipVideoHelper(
+ BoxPtr dst,
+ INT32 *xa,
+ INT32 *xb,
+ INT32 *ya,
+ INT32 *yb,
+ RegionPtr reg,
+ INT32 width,
+ INT32 height
+);
+
+void
+xf86XVCopyYUV12ToPacked(
+ const void *srcy,
+ const void *srcv,
+ const void *srcu,
+ void *dst,
+ int srcPitchy,
+ int srcPitchuv,
+ int dstPitch,
+ int h,
+ int w
+);
+
+void
+xf86XVCopyPacked(
+ const void *src,
+ void *dst,
+ int srcPitch,
+ int dstPitch,
+ int h,
+ int w
+);
+
+#endif /* _XF86XV_H_ */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86xvmc.c b/nx-X11/programs/Xserver/hw/xfree86/common/xf86xvmc.c
new file mode 100644
index 000000000..a39e1bd4d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86xvmc.c
@@ -0,0 +1,243 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xvmc.c,v 1.6 2003/10/08 22:31:59 mvojkovi Exp $ */
+
+/*
+ * Copyright (c) 2001-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "resource.h"
+#include "dixstruct.h"
+
+#ifdef XFree86LOADER
+#include "xvmodproc.h"
+#endif
+
+#include "xf86xvpriv.h"
+#include "xf86xvmc.h"
+
+#ifdef XFree86LOADER
+int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr) = NULL;
+#else
+int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr) = XvMCScreenInit;
+#endif
+
+
+typedef struct {
+ CloseScreenProcPtr CloseScreen;
+ int num_adaptors;
+ XF86MCAdaptorPtr *adaptors;
+ XvMCAdaptorPtr dixinfo;
+} xf86XvMCScreenRec, *xf86XvMCScreenPtr;
+
+static unsigned long XF86XvMCGeneration = 0;
+static int XF86XvMCScreenIndex = -1;
+
+#define XF86XVMC_GET_PRIVATE(pScreen) \
+ (xf86XvMCScreenPtr)((pScreen)->devPrivates[XF86XvMCScreenIndex].ptr)
+
+
+static int
+xf86XvMCCreateContext (
+ XvPortPtr pPort,
+ XvMCContextPtr pContext,
+ int *num_priv,
+ CARD32 **priv
+)
+{
+ xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+
+ pContext->port_priv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+
+ return (*pScreenPriv->adaptors[pContext->adapt_num]->CreateContext)(
+ pScrn, pContext, num_priv, priv);
+}
+
+static void
+xf86XvMCDestroyContext ( XvMCContextPtr pContext)
+{
+ xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+
+ (*pScreenPriv->adaptors[pContext->adapt_num]->DestroyContext)(
+ pScrn, pContext);
+}
+
+static int
+xf86XvMCCreateSurface (
+ XvMCSurfacePtr pSurface,
+ int *num_priv,
+ CARD32 **priv
+)
+{
+ XvMCContextPtr pContext = pSurface->context;
+ xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+
+ return (*pScreenPriv->adaptors[pContext->adapt_num]->CreateSurface)(
+ pScrn, pSurface, num_priv, priv);
+}
+
+static void
+xf86XvMCDestroySurface (XvMCSurfacePtr pSurface)
+{
+ XvMCContextPtr pContext = pSurface->context;
+ xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+
+ (*pScreenPriv->adaptors[pContext->adapt_num]->DestroySurface)(
+ pScrn, pSurface);
+}
+
+static int
+xf86XvMCCreateSubpicture (
+ XvMCSubpicturePtr pSubpicture,
+ int *num_priv,
+ CARD32 **priv
+)
+{
+ XvMCContextPtr pContext = pSubpicture->context;
+ xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+
+ return (*pScreenPriv->adaptors[pContext->adapt_num]->CreateSubpicture)(
+ pScrn, pSubpicture, num_priv, priv);
+}
+
+static void
+xf86XvMCDestroySubpicture (XvMCSubpicturePtr pSubpicture)
+{
+ XvMCContextPtr pContext = pSubpicture->context;
+ xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+
+ (*pScreenPriv->adaptors[pContext->adapt_num]->DestroySubpicture)(
+ pScrn, pSubpicture);
+}
+
+
+static Bool
+xf86XvMCCloseScreen (int i, ScreenPtr pScreen)
+{
+ xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pScreen);
+
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+
+ xfree(pScreenPriv->dixinfo);
+ xfree(pScreenPriv);
+
+ return (*pScreen->CloseScreen)(i, pScreen);
+}
+
+Bool xf86XvMCScreenInit(
+ ScreenPtr pScreen,
+ int num_adaptors,
+ XF86MCAdaptorPtr *adaptors
+)
+{
+ XvMCAdaptorPtr pAdapt;
+ xf86XvMCScreenPtr pScreenPriv;
+ XvScreenPtr pxvs =
+ (XvScreenPtr)(pScreen->devPrivates[XF86XvScreenIndex].ptr);
+
+ int i, j;
+
+ if(!XvMCScreenInitProc) return FALSE;
+
+ if(XF86XvMCGeneration != serverGeneration) {
+ if((XF86XvMCScreenIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+ XF86XvMCGeneration = serverGeneration;
+ }
+
+ if(!(pAdapt = xalloc(sizeof(XvMCAdaptorRec) * num_adaptors)))
+ return FALSE;
+
+ if(!(pScreenPriv = xalloc(sizeof(xf86XvMCScreenRec)))) {
+ xfree(pAdapt);
+ return FALSE;
+ }
+
+ pScreen->devPrivates[XF86XvMCScreenIndex].ptr = (pointer)pScreenPriv;
+
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = xf86XvMCCloseScreen;
+
+ pScreenPriv->num_adaptors = num_adaptors;
+ pScreenPriv->adaptors = adaptors;
+ pScreenPriv->dixinfo = pAdapt;
+
+ for(i = 0; i < num_adaptors; i++) {
+ pAdapt[i].xv_adaptor = NULL;
+ for(j = 0; j < pxvs->nAdaptors; j++) {
+ if(!strcmp((*adaptors)->name, pxvs->pAdaptors[j].name)) {
+ pAdapt[i].xv_adaptor = &(pxvs->pAdaptors[j]);
+ break;
+ }
+ }
+ if(!pAdapt[i].xv_adaptor) {
+ /* no adaptor by that name */
+ xfree(pAdapt);
+ return FALSE;
+ }
+ pAdapt[i].num_surfaces = (*adaptors)->num_surfaces;
+ pAdapt[i].surfaces = (XvMCSurfaceInfoPtr*)((*adaptors)->surfaces);
+ pAdapt[i].num_subpictures = (*adaptors)->num_subpictures;
+ pAdapt[i].subpictures = (XvImagePtr*)((*adaptors)->subpictures);
+ pAdapt[i].CreateContext = xf86XvMCCreateContext;
+ pAdapt[i].DestroyContext = xf86XvMCDestroyContext;
+ pAdapt[i].CreateSurface = xf86XvMCCreateSurface;
+ pAdapt[i].DestroySurface = xf86XvMCDestroySurface;
+ pAdapt[i].CreateSubpicture = xf86XvMCCreateSubpicture;
+ pAdapt[i].DestroySubpicture = xf86XvMCDestroySubpicture;
+ adaptors++;
+ }
+
+ if(Success != (*XvMCScreenInitProc)(pScreen, num_adaptors, pAdapt))
+ return FALSE;
+
+ return TRUE;
+}
+
+XF86MCAdaptorPtr xf86XvMCCreateAdaptorRec (void)
+{
+ return xcalloc(1, sizeof(XF86MCAdaptorRec));
+}
+
+void xf86XvMCDestroyAdaptorRec(XF86MCAdaptorPtr adaptor)
+{
+ xfree(adaptor);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86xvmc.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86xvmc.h
new file mode 100644
index 000000000..0b073aac8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86xvmc.h
@@ -0,0 +1,164 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xvmc.h,v 1.7 2003/10/08 22:31:59 mvojkovi Exp $ */
+
+/*
+ * Copyright (c) 2001 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifndef _XF86XVMC_H
+#define _XF86XVMC_H
+
+#include "xvmcext.h"
+#include "xf86xv.h"
+
+typedef struct {
+ int num_xvimages;
+ int *xvimage_ids; /* reference the subpictures in the XF86MCAdaptorRec */
+} XF86MCImageIDList;
+
+typedef struct {
+ int surface_type_id; /* Driver generated. Must be unique on the port */
+ int chroma_format;
+ int color_description; /* no longer used */
+ unsigned short max_width;
+ unsigned short max_height;
+ unsigned short subpicture_max_width;
+ unsigned short subpicture_max_height;
+ int mc_type;
+ int flags;
+ XF86MCImageIDList *compatible_subpictures; /* can be null, if none */
+} XF86MCSurfaceInfoRec, *XF86MCSurfaceInfoPtr;
+
+
+/*
+ xf86XvMCCreateContextProc
+
+ DIX will fill everything out in the context except the driver_priv.
+ The port_priv holds the private data specified for the port when
+ Xv was initialized by the driver.
+ The driver may store whatever it wants in driver_priv and edit
+ the width, height and flags. If the driver wants to return something
+ to the client it can allocate space in priv and specify the number
+ of 32 bit words in num_priv. This must be dynamically allocated
+ space because DIX will free it after it passes it to the client.
+*/
+
+
+typedef int (*xf86XvMCCreateContextProcPtr) (
+ ScrnInfoPtr pScrn,
+ XvMCContextPtr context,
+ int *num_priv,
+ CARD32 **priv
+);
+
+typedef void (*xf86XvMCDestroyContextProcPtr) (
+ ScrnInfoPtr pScrn,
+ XvMCContextPtr context
+);
+
+/*
+ xf86XvMCCreateSurfaceProc
+
+ DIX will fill everything out in the surface except the driver_priv.
+ The driver may store whatever it wants in driver_priv. The driver
+ may pass data back to the client in the same manner as the
+ xf86XvMCCreateContextProc.
+*/
+
+
+typedef int (*xf86XvMCCreateSurfaceProcPtr) (
+ ScrnInfoPtr pScrn,
+ XvMCSurfacePtr surface,
+ int *num_priv,
+ CARD32 **priv
+);
+
+typedef void (*xf86XvMCDestroySurfaceProcPtr) (
+ ScrnInfoPtr pScrn,
+ XvMCSurfacePtr surface
+);
+
+/*
+ xf86XvMCCreateSubpictureProc
+
+ DIX will fill everything out in the subpicture except the driver_priv,
+ num_palette_entries, entry_bytes and component_order. The driver may
+ store whatever it wants in driver_priv and edit the width and height.
+ If it is a paletted subpicture the driver needs to fill out the
+ num_palette_entries, entry_bytes and component_order. These are
+ not communicated to the client until the time the surface is
+ created.
+
+ The driver may pass data back to the client in the same manner as the
+ xf86XvMCCreateContextProc.
+*/
+
+
+typedef int (*xf86XvMCCreateSubpictureProcPtr) (
+ ScrnInfoPtr pScrn,
+ XvMCSubpicturePtr subpicture,
+ int *num_priv,
+ CARD32 **priv
+);
+
+typedef void (*xf86XvMCDestroySubpictureProcPtr) (
+ ScrnInfoPtr pScrn,
+ XvMCSubpicturePtr subpicture
+);
+
+
+typedef struct {
+ char *name;
+ int num_surfaces;
+ XF86MCSurfaceInfoPtr *surfaces;
+ int num_subpictures;
+ XF86ImagePtr *subpictures;
+ xf86XvMCCreateContextProcPtr CreateContext;
+ xf86XvMCDestroyContextProcPtr DestroyContext;
+ xf86XvMCCreateSurfaceProcPtr CreateSurface;
+ xf86XvMCDestroySurfaceProcPtr DestroySurface;
+ xf86XvMCCreateSubpictureProcPtr CreateSubpicture;
+ xf86XvMCDestroySubpictureProcPtr DestroySubpicture;
+} XF86MCAdaptorRec, *XF86MCAdaptorPtr;
+
+/*
+ xf86XvMCScreenInit
+
+ Unlike Xv, the adaptor data is not copied from this structure.
+ This structure's data is used so it must stick around for the
+ life of the server. Note that it's an array of pointers not
+ an array of structures.
+*/
+
+Bool xf86XvMCScreenInit(
+ ScreenPtr pScreen,
+ int num_adaptors,
+ XF86MCAdaptorPtr *adaptors
+);
+
+XF86MCAdaptorPtr xf86XvMCCreateAdaptorRec (void);
+void xf86XvMCDestroyAdaptorRec(XF86MCAdaptorPtr adaptor);
+
+#endif /* _XF86XVMC_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xf86xvpriv.h b/nx-X11/programs/Xserver/hw/xfree86/common/xf86xvpriv.h
new file mode 100644
index 000000000..0d1efdafb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xf86xvpriv.h
@@ -0,0 +1,86 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xvpriv.h,v 1.2 2003/08/24 17:36:56 dawes Exp $ */
+
+/*
+ * Copyright (c) 2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifndef _XF86XVPRIV_H_
+#define _XF86XVPRIV_H_
+
+#include "xf86xv.h"
+
+/*** These are DDX layer privates ***/
+
+extern int XF86XvScreenIndex;
+
+typedef struct {
+ DestroyWindowProcPtr DestroyWindow;
+ ClipNotifyProcPtr ClipNotify;
+ WindowExposuresProcPtr WindowExposures;
+ void (*AdjustFrame)(int, int, int, int);
+ Bool (*EnterVT)(int, int);
+ void (*LeaveVT)(int, int);
+ GCPtr videoGC;
+} XF86XVScreenRec, *XF86XVScreenPtr;
+
+typedef struct {
+ int flags;
+ PutVideoFuncPtr PutVideo;
+ PutStillFuncPtr PutStill;
+ GetVideoFuncPtr GetVideo;
+ GetStillFuncPtr GetStill;
+ StopVideoFuncPtr StopVideo;
+ SetPortAttributeFuncPtr SetPortAttribute;
+ GetPortAttributeFuncPtr GetPortAttribute;
+ QueryBestSizeFuncPtr QueryBestSize;
+ PutImageFuncPtr PutImage;
+ ReputImageFuncPtr ReputImage;
+ QueryImageAttributesFuncPtr QueryImageAttributes;
+} XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr;
+
+typedef struct {
+ ScrnInfoPtr pScrn;
+ DrawablePtr pDraw;
+ unsigned char type;
+ unsigned int subWindowMode;
+ DDXPointRec clipOrg;
+ RegionPtr clientClip;
+ RegionPtr pCompositeClip;
+ Bool FreeCompositeClip;
+ XvAdaptorRecPrivatePtr AdaptorRec;
+ XvStatus isOn;
+ Bool moved;
+ int vid_x, vid_y, vid_w, vid_h;
+ int drw_x, drw_y, drw_w, drw_h;
+ DevUnion DevPriv;
+} XvPortRecPrivate, *XvPortRecPrivatePtr;
+
+typedef struct _XF86XVWindowRec{
+ XvPortRecPrivatePtr PortRec;
+ struct _XF86XVWindowRec *next;
+} XF86XVWindowRec, *XF86XVWindowPtr;
+
+#endif /* _XF86XVPRIV_H_ */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xisb.c b/nx-X11/programs/Xserver/hw/xfree86/common/xisb.c
new file mode 100644
index 000000000..4ffc3ede4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xisb.c
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xisb.c,v 1.5 2000/11/06 19:24:07 dawes Exp $ */
+
+/*
+ X Input Serial Buffer routines for use in any XInput driver that accesses
+ a serial device.
+*/
+
+
+/*****************************************************************************
+ * Standard Headers
+ ****************************************************************************/
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define I_NEED_OS2_H
+#endif
+
+#include <misc.h>
+#include <xf86.h>
+#include <xf86Version.h>
+#include <xf86_OSproc.h>
+#include <xf86_OSlib.h>
+#include <xf86Xinput.h>
+#include "xisb.h"
+
+/*****************************************************************************
+ * Local Headers
+ ****************************************************************************/
+
+/*****************************************************************************
+ * Variables without includable headers
+ ****************************************************************************/
+
+/*****************************************************************************
+ * Local Variables
+ ****************************************************************************/
+
+/*****************************************************************************
+ * Function Definitions
+ ****************************************************************************/
+
+XISBuffer *
+XisbNew (int fd, xf86ssize_t size)
+{
+ XISBuffer *b;
+
+ b = xalloc (sizeof (XISBuffer));
+ if (!b)
+ return (NULL);
+ b->buf = xalloc ((sizeof (unsigned char) * size));
+ if (!b->buf)
+ {
+ xfree (b);
+ return (NULL);
+ }
+
+ b->fd = fd;
+ b->trace = 0;
+ b->block_duration = 0;
+ b->current = 1; /* force it to be past the end to trigger initial read */
+ b->end = 0;
+ b->buffer_size = size;
+ return (b);
+}
+
+void
+XisbFree (XISBuffer *b)
+{
+ xfree (b->buf);
+ xfree (b);
+}
+
+int
+XisbRead (XISBuffer *b)
+{
+ int ret;
+
+ if (b->current >= b->end)
+ {
+ if (b->block_duration >= 0)
+ {
+ if (xf86WaitForInput (b->fd, b->block_duration) < 1)
+ return (-1);
+ }
+ else
+ {
+ /*
+ * automatically clear it so if XisbRead is called in a loop
+ * the next call will make sure there is data with select and
+ * thus prevent a blocking read
+ */
+ b->block_duration = 0;
+ }
+
+ ret = xf86ReadSerial (b->fd, b->buf, b->buffer_size);
+ switch (ret)
+ {
+ case 0:
+ return (-1); /* timeout */
+ case -1:
+ return (-2); /* error */
+ default:
+ b->end = ret;
+ b->current = 0;
+ break;
+ }
+ }
+ if (b->trace)
+ ErrorF ("read 0x%02x (%c)\n", b->buf[b->current],
+ isprint(b->buf[b->current])?b->buf[b->current]:'.');
+
+ return (b->buf[b->current++]);
+}
+
+/* the only purpose of this function is to provide output tracing */
+xf86ssize_t
+XisbWrite (XISBuffer *b, unsigned char *msg, xf86ssize_t len)
+{
+ if (b->trace)
+ {
+ int i = 0;
+ for (i = 0; i < len; i++)
+ ErrorF ("\t\twrote 0x%02x (%c)\n", msg[i], msg[i]);
+ }
+ return (xf86WriteSerial (b->fd, msg, len));
+}
+
+/* turn tracing of this buffer on (1) or off (0) */
+void
+XisbTrace (XISBuffer *b, int trace)
+{
+ b->trace = trace;
+}
+
+/*
+ * specify a block_duration of -1 when you know the buffer's fd is ready to
+ * read. After a read, it is automatically set to 0 so that the next read
+ * will use check to select for data and prevent a block.
+ * It is the caller's responsibility to set the block_duration to -1 if it
+ * knows that there is data to read (because the main select loop triggered
+ * the read) and want's to avoid the unnecessary overhead of the select call
+ *
+ * a zero or positive block duration will cause the select to block for the
+ * give duration in usecs.
+ */
+
+void
+XisbBlockDuration (XISBuffer *b, int block_duration)
+{
+ b->block_duration = block_duration;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xisb.h b/nx-X11/programs/Xserver/hw/xfree86/common/xisb.h
new file mode 100644
index 000000000..39ae2ee11
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xisb.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/* $XFree86$ */
+
+#ifndef _xisb_H_
+#define _xisb_H_
+
+/******************************************************************************
+ * Definitions
+ * structs, typedefs, #defines, enums
+ *****************************************************************************/
+
+typedef struct _XISBuffer
+{
+ int fd;
+ int trace;
+ int block_duration;
+ xf86ssize_t current; /* bytes read */
+ xf86ssize_t end;
+ xf86ssize_t buffer_size;
+ unsigned char *buf;
+} XISBuffer;
+
+/******************************************************************************
+ * Declarations
+ * variables: use xisb_LOC in front
+ * of globals.
+ * put locals in the .c file.
+ *****************************************************************************/
+XISBuffer * XisbNew (int fd, xf86ssize_t size);
+void XisbFree (XISBuffer *b);
+int XisbRead (XISBuffer *b);
+xf86ssize_t XisbWrite (XISBuffer *b, unsigned char *msg, xf86ssize_t len);
+void XisbTrace (XISBuffer *b, int trace);
+void XisbBlockDuration (XISBuffer *b, int block_duration);
+
+/*
+ * DO NOT PUT ANYTHING AFTER THIS ENDIF
+ */
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/common/xorgHelper.c b/nx-X11/programs/Xserver/hw/xfree86/common/xorgHelper.c
new file mode 100644
index 000000000..408583da8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/common/xorgHelper.c
@@ -0,0 +1,24 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xorgHelper.c,v 1.6 2005/07/03 08:53:42 daniels Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "servermd.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "propertyst.h"
+#include "gcstruct.h"
+#include "loaderProcs.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xorgVersion.h"
+
+
+CARD32
+xorgGetVersion()
+{
+ return XORG_VERSION_CURRENT;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/Imakefile
new file mode 100644
index 000000000..648fdc762
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/Imakefile
@@ -0,0 +1,130 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/Imakefile,v 3.61 2003/11/03 05:11:51 tsi Exp $
+
+
+
+
+
+XCOMM $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/Imakefile,v 1.6 2005/12/01 02:15:38 ajax Exp $
+XCOMM $XConsortium: Imakefile /main/9 1996/10/25 15:38:46 kaleb $
+
+#include <Server.tmpl>
+
+#define IHaveSubdirs
+
+#if defined(i386Architecture) || defined(ia64Architecture) || \
+ (defined(SunArchitecture) && defined(SparcArchitecture)) || \
+ (defined(KFreeBSDArchitecture) && defined(AlphaArchitecture)) || \
+ (defined(KFreeBSDArchitecture) && defined(Sparc64Architecture)) || \
+ (defined(KFreeBSDArchitecture) && defined(PpcArchitecture)) || \
+ (defined(KNetBSDArchitecture) && defined(AlphaArchitecture)) || \
+ (defined(KNetBSDArchitecture) && defined(PpcArchitecture)) || \
+ (defined(KNetBSDArchitecture) && defined(SparcArchitecture)) || \
+ defined(KOpenBSDArchitecture) || defined(SGIArchitecture) || \
+ (defined(LynxOSArchitecture) && defined(PpcArchitecture)) || \
+ defined(AMD64Architecture) || defined(LinuxArchitecture) || \
+ defined(GNUMachArchitecture)
+BUS_SUBDIR = bus
+#endif
+
+#if defined(QNX4Architecture)
+OS_SUBDIR = qnx4
+#endif
+
+#if defined(NTOArchitecture)
+OS_SUBDIR = nto
+#endif
+
+#if defined(SVR3Architecture)
+# if defined(i386ScoArchitecture)
+OS_SUBDIR = sco
+# else
+OS_SUBDIR = sysv
+# endif
+#endif
+
+#if defined(SVR4Architecture)
+# if defined(SunArchitecture)
+OS_SUBDIR = sunos
+# elif defined(PmaxOSArchitecture)
+OS_SUBDIR = pmax
+# elif defined(DguxArchitecture)
+OS_SUBDIR = dgux
+# elif defined(SGIArchitecture)
+OS_SUBDIR = irix
+# elif defined(UnixWareArchitecture)
+OS_SUBDIR = usl
+# else
+OS_SUBDIR = sysv
+# endif
+#endif
+
+#if defined(LinuxArchitecture)
+OS_SUBDIR = linux
+#endif
+
+#if defined(LynxOSArchitecture)
+OS_SUBDIR = lynxos
+#endif
+
+#if defined(KFreeBSDArchitecture) || defined(NetBSDArchitecture) || \
+ defined(OpenBSDArchitecture)
+OS_SUBDIR = bsd
+#endif
+
+#if defined(BSDOSArchitecture)
+OS_SUBDIR = bsdi
+#endif
+
+#if defined(GNUMachArchitecture)
+OS_SUBDIR = hurd
+#endif
+
+#if defined(OS2Architecture)
+OS_SUBDIR = os2
+#endif
+
+#if defined(i386Sco325Architecture)
+OS_SUBDIR = sco
+#endif
+
+#if !DoLoadableServer
+
+#if BuildXF86DRI
+DRM_SRC = $(OS_SUBDIR)/drm/?*.c
+DRM_OBJ = $(OS_SUBDIR)/drm/?*.o
+DRM_DONES = $(OS_SUBDIR)/drm/DONE
+#endif
+
+#endif
+
+LIBDRM_DIR = ../../../../../extras/drm/libdrm
+
+SUBDIRS = $(OS_SUBDIR) $(BUS_SUBDIR) misc
+
+SRCS = $(OS_SUBDIR)/?*.c $(BUS_SUBDIR)/?*.c misc/?*.c $(DRM_SRC)
+OBJS = $(OS_SUBDIR)/?*.o $(BUS_SUBDIR)/?*.o misc/?*.o $(DRM_OBJ)
+
+DONES = $(OS_SUBDIR)/DONE $(BUS_SUBDIR)/DONE misc/DONE $(DRM_DONES)
+
+#if HasParallelMake
+MakeMutex($(SUBDIRS) $(OBJS) $(DONES))
+#endif
+
+#if HasGnuMake || HasBsdMake
+$(DONES): $(SUBDIRS)
+#endif
+
+NormalDepLibraryTarget(xf86_os,$(SUBDIRS) $(DONES),$(OBJS))
+
+ForceSubdirs($(SUBDIRS))
+
+DependSubdirs($(SUBDIRS))
+
+LinkSourceFile(xf86drm.h,$(LIBDRM_DIR))
+
+InstallDriverSDKNonExecFile(xf86_OSproc.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86_OSlib.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86_ansic.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86_libc.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86drm.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(assyntax.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/README.OS-lib b/nx-X11/programs/Xserver/hw/xfree86/os-support/README.OS-lib
new file mode 100644
index 000000000..43312e4e8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/README.OS-lib
@@ -0,0 +1,506 @@
+
+ README for XFree86 OS-support Layer
+ -----------------------------------
+
+Contents
+--------
+ 1) Overview
+ 2) Directory Layout
+ 3) Adding a new OS
+ 4) OS Support API
+
+1 - Overview
+------------
+ This directory contains the OS support layer functions for the XFree86
+servers. In addition, some miscellaneous server support functions (not
+OS-dependent) are included here, to take advantage of the fact that this
+library comes last in the linking order.
+
+Most of the functionality required to support a new OS is encapsulated in
+this library. It is hoped that all OS-specific details can be encapsulated,
+but that is not likely ever to be completely possible. Hence some minor
+changes will wind up being made in other parts of the server. The major
+design principles for this library are maintainability, readability, and
+portability. Sometimes these goals conflict; some somewhat arbitrary choices
+have been made in implementation.
+
+2 - Directory Layout
+--------------------
+ os-support/ Contains headers and documentation; no code
+ misc/ Non-OS-specific miscellaneous functions that
+ fit best into the link architecture this way.
+ shared/ Contains files with functions used by more than one
+ OS. These are symlinked into the OS subdirectories
+ at build time via Imakefile rules. This is alway
+ preferable to reproducing functions in more than one
+ OS library.
+ bsd/ OS support for the 386BSD/NetBSD/FreeBSD operating
+ systems.
+ bsdi/ OS support for the BSD/386 operating system.
+ linux/ OS support for the Linux operating system.
+ os2/ OS support for OS/2 2.11 and OS/2 Warp
+ sco/ OS support for the SCO SVR3.x operating system.
+ solx86/ OS support for the Solaris x86 operating system.
+ sysv/ OS support for all SVR4.0 and SVR4.2, and for
+ ISC and AT&T SVR3.2 operating systems.
+
+3 - Adding A New OS
+-------------------
+ Adding a support for a new operating system entails implementing all of
+the functions described in the API below. Many of these functions are no-ops
+for many operating systems, and appropriate files with dummy declarations are
+available in the 'shared' subdirectory.
+
+If your OS is sufficiently similar to an existing OS, you can make use of
+the existing subdirectory. One of the reasons for implementing this OS
+library was the unmaintainability of the spagetti-#ifdef code that existed
+before. You should try to avoid cluttering the code with #ifdef's. If
+you find that the subdirectory is getting cluttered, split off into a
+seperate subdirectory (e.g. as was done for SCO, rather than cluttering
+the 'sysv' subdirectory). You can split functions out of an existing
+subdirectory into the 'shared' subdirectory, if that is appropriate. Just
+remember to update the Imakefile for the old subdirectory.
+
+You will still likely have to make some small changes to other parts of
+the server. You should not put OS-specific #define's or #include's anywhere
+else in the server. These should all go in the "xf86_OSlib.h" header file
+in this directory.
+
+4 - OS Support API
+-----------------
+void xf86OpenConsole(void)
+{
+ /*
+ * Open console device, activate VTs, etc, etc. Fill in requisite
+ * pieces of xf86Info. Most of this code comes from xf86Init.c
+ */
+}
+
+void xf86CloseConsole(void)
+{
+ /*
+ * Close console at server exit.
+ */
+}
+
+Bool xf86VTSwitchPending(void)
+{
+ /*
+ * Returns TRUE iff there is a VT switch operation pending for
+ * the server. In the USL VT model, this is indicated via a
+ * signal handler. Should return FALSE always for OSs without
+ * VTs.
+ */
+}
+
+Bool xf86VTSwitchAway(void)
+{
+ /*
+ * Handles the OS-specific action for switching away from the active
+ * VT. Returns FALSE if the switch away fails. Should return
+ * FALSE always for OSs without VTs (then again, this function
+ * should never be called in that case).
+ */
+}
+
+Bool xf86VTSwitchTo(void)
+{
+ /*
+ * Handles the OS-specific action for switching to the active VT.
+ * Returns FALSE if the switch to fails. Should return TRUE
+ * always for OSs without VTs (then again, this function should
+ * never be called in that case).
+ */
+}
+
+Bool xf86LinearVidMem(void)
+{
+ /*
+ * Returns TRUE if the OS supports mapping linear frame buffers
+ * (ie memory at addresses above physical memory).
+ */
+}
+
+pointer xf86MapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ /*
+ * Handle mapping the video memory. Returns (pointer *)0 for
+ * failure; causes server exit. It is allowable to call FatalError()
+ * from inside this function and exit directly.
+ */
+}
+
+void xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ /*
+ * Handle unmapping the video memory. This should undo what
+ * xf86MapVidMem() does. Base is a pointer obtained from
+ * a previous call to xf86MapVidMem().
+ */
+}
+
+void xf86MapDisplay(int ScreenNum, int Region)
+{
+ /*
+ * For OSs that require the screen be mapped when entering a VT.
+ * A dummy function will be defined for OSs that don't require
+ * this (or don't have VTs at all).
+ */
+}
+
+void xf86UnMapDisplay(int ScreenNum, int Region)
+{
+ /*
+ * For Os that require that the screen be unmapped when leaving a
+ * VT. A dummy function will be defined for OSs that don't require
+ * this (or don't have VTs at all).
+ */
+}
+
+int xf86ReadBIOS(unsigned long Base, unsigned long Offset,
+ unsigned char *Buf, int Len)
+{
+ /*
+ * Read Len bytes from the BIOS at address Base, offset Offset,
+ * into buffer Buf. Returns -1 for failure or if the OS does
+ * not support reading the BIOS. This causes a driver probe
+ * to fail, but does not cause the server to abort.
+ */
+}
+
+
+void xf86EnableIOPorts(int ScreenNum)
+{
+ /*
+ * Enables I/O permissions. The OS layer should
+ * enable all I/O port access.
+ */
+}
+
+void xf86DisableIOPorts(int ScreenNum)
+{
+ /*
+ * Disables I/O permissions.
+ */
+}
+
+Bool xf86DisableInterrupts(void)
+{
+ /*
+ * Disable interrupts if allowed for this OS. Returns FALSE if
+ * this is not allowed or if the attempt fails for some reason.
+ */
+}
+
+void xf86EnableInterrupts(void)
+{
+ /*
+ * Reenable interrupts
+ */
+}
+
+int xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Process OS-specific command-line arguments. See
+ * ddxProcessArgument() for more info.
+ */
+}
+
+void xf86UseMsg(void)
+{
+ /*
+ * Print list of OS-specific command-line arguments. See
+ * ddxUseMsg() for more info.
+ */
+}
+
+void xf86SoundKbdBell(int loudness, int pitch, int duration)
+{
+ /*
+ * Sound the keyboard bell. pitch is in Hz, duration in ms,
+ * loudness is in the range 0-100 (0 -> off). For systems
+ * where the loudness can't be controlled, scale the duration
+ * by loudness/50.
+ */
+}
+
+void xf86SetKbdLeds(int leds)
+{
+ /*
+ * Set the keyboard LEDs to the state indicated in leds
+ */
+}
+
+int xf86GetKbdLeds(void)
+{
+ /*
+ * Return the state of the keyboard LEDs. If the OS doesn't
+ * support this, return 0.
+ */
+}
+
+void xf86SetKbdRepeat(char rad)
+{
+ /*
+ * Set the keyboard repeat rate and delay according the
+ * the rad value. The lower 5 bits determine the repeat
+ * rate (lower value -> higher rate). The next 2 bits
+ * determine the delay.
+ * This should possibly be changed to take separate rate and
+ * delay parameters.
+ */
+}
+
+void xf86KbdInit(void)
+{
+ /*
+ * Save initial keyboard state. This is called at the start of
+ * each server generation.
+ */
+}
+
+int xf86KbdOn(void)
+{
+ /*
+ * Set the keyboard up for use with X. This is called whenever
+ * the server becomes active (ie at the start of each generation and
+ * whenever its VT becomes active). Return the file descriptor
+ * for keyboard input. Return -1 if there is no file descriptor
+ * to add as an input device. If there are errors encountered,
+ * call FatalError(). A return value of -1 is not considered an
+ * error condition.
+ */
+}
+
+int xf86KbdOff(void)
+{
+ /*
+ * Return the keyboard to the state saved by xf86KbdInit(). This is
+ * called at the end of a server generation, and also when the
+ * server's VT ceases being active. Returns the keyboard file
+ * descriptor. Returns -1 if there is no file descriptor to be
+ * removed as an input device. Errors should be handled the same
+ * way as in xf86KbdOn().
+ */
+}
+
+void xf86KbdEvents(void)
+{
+ /*
+ * Read characters from the keyboard device, and post the events
+ * by calling xf86PostKbdEvent(). Read as much as is available
+ * without waiting.
+ */
+}
+
+void xf86SetMouseSpeed(int old, int new, unsigned cflag)
+{
+ /*
+ * Set the speed of the mouse port. old is the previous speed,
+ * new is the new speed, and cflag is the value of the termio[s]
+ * c_cflag field. For mice that have programmable speed operation,
+ * this should send the appropriate commands to the mouse.
+ */
+}
+
+void xf86MouseInit(void)
+{
+ /*
+ * This is called at the start of each server generation. In most
+ * cases this is a noop. If the mouse must not be opened/closed
+ * when VT switching, the open should be done here.
+ */
+}
+
+int xf86MousedOn(void)
+{
+ /*
+ * Set the mouse up for use with X. This is called whenever
+ * the server becomes active (ie at the start of each generation and
+ * whenever its VT becomes active). This function normally opens
+ * the mouse device, and may call xf86SetupMouse() to initialise
+ * the mouse parameters. Return the file descriptor for mouse input.
+ * Return -1 if there is no file descriptor to add as an input
+ * device. If there are errors encountered, call FatalError().
+ * A return value of -1 is not considered an error condition.
+ */
+}
+
+int xf86MouseOff(Bool doclose)
+{
+ /*
+ * Release the mouse from use with X. This is called at the end
+ * of a server generation (with doclose==TRUE), and also when the
+ * server's VT ceases being active (with doclose==FALSE). If the
+ * mouse should not be opened/closed when VT switching, the close
+ * should be done here when doclose==TRUE. For other systems, the
+ * mouse device should be closed regardless of the doclose value.
+ * Returns the mouse file descriptor. Returns -1 if there is no
+ * file descriptor to be removed as an input device. Errors
+ * should be handled the same way as in xf86MouseOn().
+ */
+}
+
+void xf86MouseEvents(void)
+{
+ /*
+ * Read characters from the mouse device, and post the events
+ * by calling xf86PostMseEvent(). Read as much as is available
+ * without waiting. If the OS doesn't handle the mouse protocol
+ * translation, xf86MouseProtocol() may be called to do the
+ * translation and event posting. If the OS does handle the protocol
+ * translation, MOUSE_PROTOCOL_IN_KERNEL should be #define'd in
+ * xf86_OSlib.h.
+ */
+}
+
+int xf86OsMouseProc(DevicePtr pPointer, int what)
+{
+ /*
+ * Implements the device-proc for the pointer device when an
+ * OS-based mouse driver is being used (as opposed to the
+ * server's internal mouse driver). Implemented as any other
+ * device-proc in the server.
+ *
+ * This function only needs to be implemented if USE_OSMOUSE is
+ * defined for the OS.
+ */
+}
+
+int xf86OsMouseEvents(void)
+{
+ /*
+ * When supporting an OS-based mouse driver (as opposed to the
+ * server's internal mouse driver), read some events from the device
+ * and post them to the DIX layer through xf86PostMseEvent().
+ *
+ * This function only needs to be implemented if USE_OSMOUSE is
+ * defined for the OS.
+ */
+}
+
+void xf86OsMouseOption(int token, pointer lex_ptr)
+{
+ /*
+ * Used in parsing an OsMouse keyword from the Xconfig file.
+ * Passed the token type and a pointer to the token value.
+ * The function should do whatever is appropriate for the OS's
+ * mouse driver.
+ *
+ * This function only needs to be implemented if USE_OSMOUSE is
+ * defined for the OS.
+ */
+}
+
+/*
+ * The following functions are simply wrappers around the OS specific
+ * libc functions
+ */
+
+void *
+xf86memmove(void * dest, const void * src, INT32 n)
+{
+ return(memmove(dest,src,n));
+}
+
+void *
+xf86memset(void * s, int c, INT32 n)
+{
+ return(memset(s,c,n));
+}
+
+void *
+xf86memcpy(void * dest, const void * src, INT32 n)
+{
+ return(memcpy(dest,src,n));
+}
+
+int
+xf86memcmp(const void * s1, const void * s2, INT32 n)
+{
+ return(memcmp(s1,s2,n));
+}
+
+char *
+xf86strcat(char * dest, const char * src)
+{
+ return(strcat(dest,src));
+}
+
+char *
+xf86strcpy(char * dest, const char * src)
+{
+ return(strcpy(dest,src));
+}
+
+int
+xf86strcmp(const char * s1, const char * s2)
+{
+ return(strcmp(s1,s2));
+}
+
+int
+xf86strncmp(const char * s1, const char * s2, INT32 n)
+{
+ return(strncmp(s1,s2,n));
+}
+
+size_t
+xf86strlen(const char * s)
+{
+ return(strlen(s));
+}
+
+void
+xf86getsecs(INT32 * secs, INT32 * usecs)
+{
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+ *secs = tv.tv_sec;
+ *usecs= tv.tv_usec;
+
+ return;
+}
+
+double
+xf86exp(double x)
+{
+ return(exp(x));
+}
+
+double
+xf86log(double x)
+{
+ return(log(x));
+}
+
+double
+xf86pow(double x, double y)
+{
+ return(pow(x,y));
+}
+
+double
+xf86sqrt(double x)
+{
+ return(sqrt(x));
+}
+
+double
+xf86cos(double x)
+{
+ return(cos(x));
+}
+
+
+
+
+$XFree86: xc/programs/Xserver/hw/xfree86/os-support/README.OS-lib,v 3.9 2001/07/23 13:15:48 dawes Exp $
+
+
+
+
+
+$XConsortium: README.OS-lib /main/5 1996/02/21 17:50:28 kaleb $
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/assyntax.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/assyntax.h
new file mode 100644
index 000000000..13cc2f3e0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/assyntax.h
@@ -0,0 +1,753 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/assyntax.h,v 3.13 2003/08/24 17:37:03 dawes Exp $ */
+
+#ifndef __ASSYNTAX_H__
+#define __ASSYNTAX_H__
+
+/*
+ * Copyright 1992 Vrije Universiteit, The Netherlands
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the Vrije Universiteit not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The Vrije Universiteit makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * The Vrije Universiteit DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL The Vrije Universiteit BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+ * Copyright (c) 1993-1999 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* $XConsortium: assyntax.h /main/5 1996/02/21 17:50:49 kaleb $ */
+
+ /*
+ * assyntax.h
+ *
+ * Select the syntax appropriate to the 386 assembler being used
+ * To add support for more assemblers add more columns to the CHOICE
+ * macro. Note that register names must also have uppercase names
+ * to avoid macro recursion. e.g., #define ah %ah recurses!
+ *
+ * NB 1. Some of the macros for certain assemblers imply that the code is to
+ * run in protected mode!! Caveat emptor.
+ *
+ * NB 2. 486 specific instructions are not included. This is to discourage
+ * their accidental use in code that is intended to run on 386 and 486
+ * systems.
+ *
+ * Supported assemblers:
+ *
+ * (a) AT&T SysVr4 as(1): default
+ * (b) GNU Assembler gas: define USE_GAS or GNU_ASSEMBLER
+ * (c) Amsterdam Compiler kit: define ACK_ASSEMBLER
+ *
+ * The following naming conventions have been used to identify the various
+ * data types:
+ * _SR = segment register version
+ * Integer:
+ * _Q = quadword = 64 bits
+ * _L = long = 32 bits
+ * _W = short = 16 bits
+ * _B = byte = 8 bits
+ * Floating-point:
+ * _X = m80real = 80 bits
+ * _D = double = 64 bits
+ * _S = single = 32 bits
+ *
+ * Author: Gregory J. Sharp, Sept 1992
+ * Vrije Universiteit, Amsterdam, The Netherlands
+ */
+
+#if defined(USE_GAS) && !defined(GNU_ASSEMBLER)
+#define GNU_ASSEMBLER
+#endif
+
+#if (defined(__STDC__) && !defined(UNIXCPP)) || (defined (sun) && defined (i386) && defined (SVR4) && defined (__STDC__) && !defined (__GNUC__))
+#define CONCAT(x, y) x ## y
+#else
+#define CONCAT(x, y) x/**/y
+#endif
+
+#ifdef ACK_ASSEMBLER
+
+/* Assume we write code for 32-bit protected mode! */
+
+/* Redefine register names for GAS & AT&T assemblers */
+#define AL al
+#define AH ah
+#define AX ax
+#define EAX ax
+#define BL bl
+#define BH bh
+#define BX bx
+#define EBX bx
+#define CL cl
+#define CH ch
+#define CX cx
+#define ECX cx
+#define DL dl
+#define DH dh
+#define DX dx
+#define EDX dx
+#define BP bp
+#define EBP bp
+#define SI si
+#define ESI si
+#define DI di
+#define EDI di
+#define SP sp
+#define ESP sp
+#define CS cs
+#define SS ss
+#define DS ds
+#define ES es
+#define FS fs
+#define GS gs
+/* Control Registers */
+#define CR0 cr0
+#define CR1 cr1
+#define CR2 cr2
+#define CR3 cr3
+/* Debug Registers */
+#define DR0 dr0
+#define DR1 dr1
+#define DR2 dr2
+#define DR3 dr3
+#define DR4 dr4
+#define DR5 dr5
+#define DR6 dr6
+#define DR7 dr7
+/* Floating-point Stack */
+#define ST st
+
+#define AS_BEGIN .sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text
+
+
+#define _WTOG o16 /* word toggle for _W instructions */
+#define _LTOG /* long toggle for _L instructions */
+#define ADDR_TOGGLE a16
+#define OPSZ_TOGGLE o16
+#define USE16 .use16
+#define USE32 .use32
+
+#define CHOICE(a,b,c) c
+
+#else /* AT&T or GAS */
+
+/* Redefine register names for GAS & AT&T assemblers */
+#define AL %al
+#define AH %ah
+#define AX %ax
+#define EAX %eax
+#define BL %bl
+#define BH %bh
+#define BX %bx
+#define EBX %ebx
+#define CL %cl
+#define CH %ch
+#define CX %cx
+#define ECX %ecx
+#define DL %dl
+#define DH %dh
+#define DX %dx
+#define EDX %edx
+#define BP %bp
+#define EBP %ebp
+#define SI %si
+#define ESI %esi
+#define DI %di
+#define EDI %edi
+#define SP %sp
+#define ESP %esp
+#define CS %cs
+#define SS %ss
+#define DS %ds
+#define ES %es
+#define FS %fs
+#define GS %gs
+/* Control Registers */
+#define CR0 %cr0
+#define CR1 %cr1
+#define CR2 %cr2
+#define CR3 %cr3
+/* Debug Registers */
+#define DR0 %db0
+#define DR1 %db1
+#define DR2 %db2
+#define DR3 %db3
+#define DR4 %db4
+#define DR5 %db5
+#define DR6 %db6
+#define DR7 %db7
+/* Floating-point Stack */
+#define ST %st
+
+#define AS_BEGIN
+#define USE16
+#define USE32
+
+#ifdef GNU_ASSEMBLER
+
+#define ADDR_TOGGLE aword
+#define OPSZ_TOGGLE word
+
+#define CHOICE(a,b,c) b
+
+#else
+/*
+ * AT&T ASSEMBLER SYNTAX
+ * *********************
+ */
+#define CHOICE(a,b,c) a
+
+#define ADDR_TOGGLE addr16
+#define OPSZ_TOGGLE data16
+
+#endif /* GNU_ASSEMBLER */
+#endif /* ACK_ASSEMBLER */
+
+
+#if defined(__QNX__) || defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__) || defined(__GNU__)
+#define GLNAME(a) a
+#else
+#define GLNAME(a) CONCAT(_,a)
+#endif
+
+
+ /****************************************/
+ /* */
+ /* Select the various choices */
+ /* */
+ /****************************************/
+
+
+/* Redefine assembler directives */
+/*********************************/
+#define GLOBL CHOICE(.globl, .globl, .extern)
+#define ALIGNTEXT4 CHOICE(.align 4, .align ARG2(2,0x90), .align 4)
+#define ALIGNTEXT2 CHOICE(.align 2, .align ARG2(1,0x90), .align 2)
+/* ALIGNTEXT4ifNOP is the same as ALIGNTEXT4, but only if the space is
+ * guaranteed to be filled with NOPs. Otherwise it does nothing.
+ */
+#define ALIGNTEXT4ifNOP CHOICE(.align 4, .align ARG2(2,0x90), /*can't do it*/)
+#define ALIGNDATA4 CHOICE(.align 4, .align ARG2(2,0x0), .align 4)
+#define ALIGNDATA2 CHOICE(.align 2, .align ARG2(1,0x0), .align 2)
+#define FILE(s) CHOICE(.file s, .file s, .file s)
+#define STRING(s) CHOICE(.string s, .asciz s, .asciz s)
+#define D_LONG CHOICE(.long, .long, .data4)
+#define D_WORD CHOICE(.value, .short, .data2)
+#define D_BYTE CHOICE(.byte, .byte, .data1)
+#define SPACE CHOICE(.comm, .space, .space)
+#define COMM CHOICE(.comm, .comm, .comm)
+#define SEG_DATA CHOICE(.data, .data, .sect .data)
+#define SEG_TEXT CHOICE(.text, .text, .sect .text)
+#define SEG_BSS CHOICE(.bss, .bss, .sect .bss)
+
+#ifdef GNU_ASSEMBLER
+#define D_SPACE(n) . = . + n
+#else
+#define D_SPACE(n) .space n
+#endif
+
+/* Addressing Modes */
+/* Immediate Mode */
+#define ADDR(a) CHOICE(CONCAT($,a), CONCAT($,a), a)
+#define CONST(a) CHOICE(CONCAT($,a), CONCAT($,a), a)
+
+/* Indirect Mode */
+#define CONTENT(a) CHOICE(a, a, (a)) /* take contents of variable */
+#define REGIND(a) CHOICE((a), (a), (a)) /* Register a indirect */
+/* Register b indirect plus displacement a */
+#define REGOFF(a, b) CHOICE(a(b), a(b), a(b))
+/* Reg indirect Base + Index + Displacement - this is mainly for 16-bit mode
+ * which has no scaling
+ */
+#define REGBID(b,i,d) CHOICE(d(b,i), d(b,i), d(b)(i))
+/* Reg indirect Base + (Index * Scale) + Displacement */
+#define REGBISD(b,i,s,d) CHOICE(d(b,i,s), d(b,i,s), d(b)(i*s))
+/* Displaced Scaled Index: */
+#define REGDIS(d,i,s) CHOICE(d(,i,s), d(,i,s), d(i * s))
+/* Indexed Base: */
+#define REGBI(b,i) CHOICE((b,i), (b,i), (b)(i))
+/* Displaced Base: */
+#define REGDB(d,b) CHOICE(d(b), d(b), d(b))
+/* Variable indirect: */
+#define VARINDIRECT(var) CHOICE(*var, *var, (var))
+/* Use register contents as jump/call target: */
+#define CODEPTR(reg) CHOICE(*reg, *reg, reg)
+
+/* For expressions requiring bracketing
+ * eg. (CRT0_PM | CRT_EM)
+ */
+
+#define EXPR(a) CHOICE([a], (a), [a])
+#define ENOT(a) CHOICE(0!a, ~a, ~a)
+#define EMUL(a,b) CHOICE(a\*b, a*b, a*b)
+#define EDIV(a,b) CHOICE(a\/b, a/b, a/b)
+
+/*
+ * We have to beat the problem of commas within arguments to choice.
+ * eg. choice (add a,b, add b,a) will get argument mismatch. Luckily ANSI
+ * and other known cpp definitions evaluate arguments before substitution
+ * so the following works.
+ */
+#define ARG2(a, b) a,b
+#define ARG3(a,b,c) a,b,c
+
+/* Redefine assembler commands */
+#define AAA CHOICE(aaa, aaa, aaa)
+#define AAD CHOICE(aad, aad, aad)
+#define AAM CHOICE(aam, aam, aam)
+#define AAS CHOICE(aas, aas, aas)
+#define ADC_L(a, b) CHOICE(adcl ARG2(a,b), adcl ARG2(a,b), _LTOG adc ARG2(b,a))
+#define ADC_W(a, b) CHOICE(adcw ARG2(a,b), adcw ARG2(a,b), _WTOG adc ARG2(b,a))
+#define ADC_B(a, b) CHOICE(adcb ARG2(a,b), adcb ARG2(a,b), adcb ARG2(b,a))
+#define ADD_L(a, b) CHOICE(addl ARG2(a,b), addl ARG2(a,b), _LTOG add ARG2(b,a))
+#define ADD_W(a, b) CHOICE(addw ARG2(a,b), addw ARG2(a,b), _WTOG add ARG2(b,a))
+#define ADD_B(a, b) CHOICE(addb ARG2(a,b), addb ARG2(a,b), addb ARG2(b,a))
+#define AND_L(a, b) CHOICE(andl ARG2(a,b), andl ARG2(a,b), _LTOG and ARG2(b,a))
+#define AND_W(a, b) CHOICE(andw ARG2(a,b), andw ARG2(a,b), _WTOG and ARG2(b,a))
+#define AND_B(a, b) CHOICE(andb ARG2(a,b), andb ARG2(a,b), andb ARG2(b,a))
+#define ARPL(a,b) CHOICE(arpl ARG2(a,b), arpl ARG2(a,b), arpl ARG2(b,a))
+#define BOUND_L(a, b) CHOICE(boundl ARG2(a,b), boundl ARG2(b,a), _LTOG bound ARG2(b,a))
+#define BOUND_W(a, b) CHOICE(boundw ARG2(a,b), boundw ARG2(b,a), _WTOG bound ARG2(b,a))
+#define BSF_L(a, b) CHOICE(bsfl ARG2(a,b), bsfl ARG2(a,b), _LTOG bsf ARG2(b,a))
+#define BSF_W(a, b) CHOICE(bsfw ARG2(a,b), bsfw ARG2(a,b), _WTOG bsf ARG2(b,a))
+#define BSR_L(a, b) CHOICE(bsrl ARG2(a,b), bsrl ARG2(a,b), _LTOG bsr ARG2(b,a))
+#define BSR_W(a, b) CHOICE(bsrw ARG2(a,b), bsrw ARG2(a,b), _WTOG bsr ARG2(b,a))
+#define BT_L(a, b) CHOICE(btl ARG2(a,b), btl ARG2(a,b), _LTOG bt ARG2(b,a))
+#define BT_W(a, b) CHOICE(btw ARG2(a,b), btw ARG2(a,b), _WTOG bt ARG2(b,a))
+#define BTC_L(a, b) CHOICE(btcl ARG2(a,b), btcl ARG2(a,b), _LTOG btc ARG2(b,a))
+#define BTC_W(a, b) CHOICE(btcw ARG2(a,b), btcw ARG2(a,b), _WTOG btc ARG2(b,a))
+#define BTR_L(a, b) CHOICE(btrl ARG2(a,b), btrl ARG2(a,b), _LTOG btr ARG2(b,a))
+#define BTR_W(a, b) CHOICE(btrw ARG2(a,b), btrw ARG2(a,b), _WTOG btr ARG2(b,a))
+#define BTS_L(a, b) CHOICE(btsl ARG2(a,b), btsl ARG2(a,b), _LTOG bts ARG2(b,a))
+#define BTS_W(a, b) CHOICE(btsw ARG2(a,b), btsw ARG2(a,b), _WTOG bts ARG2(b,a))
+#define CALL(a) CHOICE(call a, call a, call a)
+#define CALLF(s,a) CHOICE(lcall ARG2(s,a), lcall ARG2(s,a), callf s:a)
+#define CBW CHOICE(cbtw, cbw, cbw)
+#define CWDE CHOICE(cwtd, cwde, cwde)
+#define CLC CHOICE(clc, clc, clc)
+#define CLD CHOICE(cld, cld, cld)
+#define CLI CHOICE(cli, cli, cli)
+#define CLTS CHOICE(clts, clts, clts)
+#define CMC CHOICE(cmc, cmc, cmc)
+#define CMP_L(a, b) CHOICE(cmpl ARG2(a,b), cmpl ARG2(a,b), _LTOG cmp ARG2(b,a))
+#define CMP_W(a, b) CHOICE(cmpw ARG2(a,b), cmpw ARG2(a,b), _WTOG cmp ARG2(b,a))
+#define CMP_B(a, b) CHOICE(cmpb ARG2(a,b), cmpb ARG2(a,b), cmpb ARG2(b,a))
+#define CMPS_L CHOICE(cmpsl, cmpsl, _LTOG cmps)
+#define CMPS_W CHOICE(cmpsw, cmpsw, _WTOG cmps)
+#define CMPS_B CHOICE(cmpsb, cmpsb, cmpsb)
+#define CWD CHOICE(cwtl, cwd, cwd)
+#define CDQ CHOICE(cltd, cdq, cdq)
+#define DAA CHOICE(daa, daa, daa)
+#define DAS CHOICE(das, das, das)
+#define DEC_L(a) CHOICE(decl a, decl a, _LTOG dec a)
+#define DEC_W(a) CHOICE(decw a, decw a, _WTOG dec a)
+#define DEC_B(a) CHOICE(decb a, decb a, decb a)
+#define DIV_L(a) CHOICE(divl a, divl a, div a)
+#define DIV_W(a) CHOICE(divw a, divw a, div a)
+#define DIV_B(a) CHOICE(divb a, divb a, divb a)
+#define ENTER(a,b) CHOICE(enter ARG2(a,b), enter ARG2(a,b), enter ARG2(b,a))
+#define HLT CHOICE(hlt, hlt, hlt)
+#define IDIV_L(a) CHOICE(idivl a, idivl a, _LTOG idiv a)
+#define IDIV_W(a) CHOICE(idivw a, idivw a, _WTOG idiv a)
+#define IDIV_B(a) CHOICE(idivb a, idivb a, idivb a)
+/* More forms than this for imul!! */
+#define IMUL_L(a, b) CHOICE(imull ARG2(a,b), imull ARG2(a,b), _LTOG imul ARG2(b,a))
+#define IMUL_W(a, b) CHOICE(imulw ARG2(a,b), imulw ARG2(a,b), _WTOG imul ARG2(b,a))
+#define IMUL_B(a) CHOICE(imulb a, imulb a, imulb a)
+#define IN_L CHOICE(inl (DX), inl ARG2(DX,EAX), _LTOG in DX)
+#define IN_W CHOICE(inw (DX), inw ARG2(DX,AX), _WTOG in DX)
+#define IN_B CHOICE(inb (DX), inb ARG2(DX,AL), inb DX)
+/* Please AS code writer: use the following ONLY, if you refer to ports<256
+ * directly, but not in IN1_W(DX), for instance, even if IN1_ looks nicer
+ */
+#if defined (sun)
+#define IN1_L(a) CHOICE(inl (a), inl ARG2(a,EAX), _LTOG in a)
+#define IN1_W(a) CHOICE(inw (a), inw ARG2(a,AX), _WTOG in a)
+#define IN1_B(a) CHOICE(inb (a), inb ARG2(a,AL), inb a)
+#else
+#define IN1_L(a) CHOICE(inl a, inl ARG2(a,EAX), _LTOG in a)
+#define IN1_W(a) CHOICE(inw a, inw ARG2(a,AX), _WTOG in a)
+#define IN1_B(a) CHOICE(inb a, inb ARG2(a,AL), inb a)
+#endif
+#define INC_L(a) CHOICE(incl a, incl a, _LTOG inc a)
+#define INC_W(a) CHOICE(incw a, incw a, _WTOG inc a)
+#define INC_B(a) CHOICE(incb a, incb a, incb a)
+#define INS_L CHOICE(insl, insl, _LTOG ins)
+#define INS_W CHOICE(insw, insw, _WTOG ins)
+#define INS_B CHOICE(insb, insb, insb)
+#define INT(a) CHOICE(int a, int a, int a)
+#define INT3 CHOICE(int CONST(3), int3, int CONST(3))
+#define INTO CHOICE(into, into, into)
+#define IRET CHOICE(iret, iret, iret)
+#define IRETD CHOICE(iret, iret, iretd)
+#define JA(a) CHOICE(ja a, ja a, ja a)
+#define JAE(a) CHOICE(jae a, jae a, jae a)
+#define JB(a) CHOICE(jb a, jb a, jb a)
+#define JBE(a) CHOICE(jbe a, jbe a, jbe a)
+#define JC(a) CHOICE(jc a, jc a, jc a)
+#define JE(a) CHOICE(je a, je a, je a)
+#define JG(a) CHOICE(jg a, jg a, jg a)
+#define JGE(a) CHOICE(jge a, jge a, jge a)
+#define JL(a) CHOICE(jl a, jl a, jl a)
+#define JLE(a) CHOICE(jle a, jle a, jle a)
+#define JNA(a) CHOICE(jna a, jna a, jna a)
+#define JNAE(a) CHOICE(jnae a, jnae a, jnae a)
+#define JNB(a) CHOICE(jnb a, jnb a, jnb a)
+#define JNBE(a) CHOICE(jnbe a, jnbe a, jnbe a)
+#define JNC(a) CHOICE(jnc a, jnc a, jnc a)
+#define JNE(a) CHOICE(jne a, jne a, jne a)
+#define JNG(a) CHOICE(jng a, jng a, jng a)
+#define JNGE(a) CHOICE(jnge a, jnge a, jnge a)
+#define JNL(a) CHOICE(jnl a, jnl a, jnl a)
+#define JNLE(a) CHOICE(jnle a, jnle a, jnle a)
+#define JNO(a) CHOICE(jno a, jno a, jno a)
+#define JNP(a) CHOICE(jnp a, jnp a, jnp a)
+#define JNS(a) CHOICE(jns a, jns a, jns a)
+#define JNZ(a) CHOICE(jnz a, jnz a, jnz a)
+#define JO(a) CHOICE(jo a, jo a, jo a)
+#define JP(a) CHOICE(jp a, jp a, jp a)
+#define JPE(a) CHOICE(jpe a, jpe a, jpe a)
+#define JPO(a) CHOICE(jpo a, jpo a, jpo a)
+#define JS(a) CHOICE(js a, js a, js a)
+#define JZ(a) CHOICE(jz a, jz a, jz a)
+#define JMP(a) CHOICE(jmp a, jmp a, jmp a)
+#define JMPF(s,a) CHOICE(ljmp ARG2(s,a), ljmp ARG2(s,a), jmpf s:a)
+#define LAHF CHOICE(lahf, lahf, lahf)
+#if !defined(_REAL_MODE) && !defined(_V86_MODE)
+#define LAR(a, b) CHOICE(lar ARG2(a, b), lar ARG2(a, b), lar ARG2(b, a))
+#endif
+#define LEA_L(a, b) CHOICE(leal ARG2(a,b), leal ARG2(a,b), _LTOG lea ARG2(b,a))
+#define LEA_W(a, b) CHOICE(leaw ARG2(a,b), leaw ARG2(a,b), _WTOG lea ARG2(b,a))
+#define LEAVE CHOICE(leave, leave, leave)
+#define LGDT(a) CHOICE(lgdt a, lgdt a, lgdt a)
+#define LIDT(a) CHOICE(lidt a, lidt a, lidt a)
+#define LDS(a, b) CHOICE(ldsl ARG2(a,b), lds ARG2(a,b), lds ARG2(b,a))
+#define LES(a, b) CHOICE(lesl ARG2(a,b), les ARG2(a,b), les ARG2(b,a))
+#define LFS(a, b) CHOICE(lfsl ARG2(a,b), lfs ARG2(a,b), lfs ARG2(b,a))
+#define LGS(a, b) CHOICE(lgsl ARG2(a,b), lgs ARG2(a,b), lgs ARG2(b,a))
+#define LSS(a, b) CHOICE(lssl ARG2(a,b), lss ARG2(a,b), lss ARG2(b,a))
+#define LLDT(a) CHOICE(lldt a, lldt a, lldt a)
+#define LMSW(a) CHOICE(lmsw a, lmsw a, lmsw a)
+#define LOCK CHOICE(lock, lock, lock)
+#define LODS_L CHOICE(lodsl, lodsl, _LTOG lods)
+#define LODS_W CHOICE(lodsw, lodsw, _WTOG lods)
+#define LODS_B CHOICE(lodsb, lodsb, lodsb)
+#define LOOP(a) CHOICE(loop a, loop a, loop a)
+#define LOOPE(a) CHOICE(loope a, loope a, loope a)
+#define LOOPZ(a) CHOICE(loopz a, loopz a, loopz a)
+#define LOOPNE(a) CHOICE(loopne a, loopne a, loopne a)
+#define LOOPNZ(a) CHOICE(loopnz a, loopnz a, loopnz a)
+#if !defined(_REAL_MODE) && !defined(_V86_MODE)
+#define LSL(a, b) CHOICE(lsl ARG2(a,b), lsl ARG2(a,b), lsl ARG2(b,a))
+#endif
+#define LTR(a) CHOICE(ltr a, ltr a, ltr a)
+#define MOV_SR(a, b) CHOICE(movw ARG2(a,b), mov ARG2(a,b), mov ARG2(b,a))
+#define MOV_L(a, b) CHOICE(movl ARG2(a,b), movl ARG2(a,b), _LTOG mov ARG2(b,a))
+#define MOV_W(a, b) CHOICE(movw ARG2(a,b), movw ARG2(a,b), _WTOG mov ARG2(b,a))
+#define MOV_B(a, b) CHOICE(movb ARG2(a,b), movb ARG2(a,b), movb ARG2(b,a))
+#define MOVS_L CHOICE(movsl, movsl, _LTOG movs)
+#define MOVS_W CHOICE(movsw, movsw, _WTOG movs)
+#define MOVS_B CHOICE(movsb, movsb, movsb)
+#define MOVSX_BL(a, b) CHOICE(movsbl ARG2(a,b), movsbl ARG2(a,b), movsx ARG2(b,a))
+#define MOVSX_BW(a, b) CHOICE(movsbw ARG2(a,b), movsbw ARG2(a,b), movsx ARG2(b,a))
+#define MOVSX_WL(a, b) CHOICE(movswl ARG2(a,b), movswl ARG2(a,b), movsx ARG2(b,a))
+#define MOVZX_BL(a, b) CHOICE(movzbl ARG2(a,b), movzbl ARG2(a,b), movzx ARG2(b,a))
+#define MOVZX_BW(a, b) CHOICE(movzbw ARG2(a,b), movzbw ARG2(a,b), movzx ARG2(b,a))
+#define MOVZX_WL(a, b) CHOICE(movzwl ARG2(a,b), movzwl ARG2(a,b), movzx ARG2(b,a))
+#define MUL_L(a) CHOICE(mull a, mull a, _LTOG mul a)
+#define MUL_W(a) CHOICE(mulw a, mulw a, _WTOG mul a)
+#define MUL_B(a) CHOICE(mulb a, mulb a, mulb a)
+#define NEG_L(a) CHOICE(negl a, negl a, _LTOG neg a)
+#define NEG_W(a) CHOICE(negw a, negw a, _WTOG neg a)
+#define NEG_B(a) CHOICE(negb a, negb a, negb a)
+#define NOP CHOICE(nop, nop, nop)
+#define NOT_L(a) CHOICE(notl a, notl a, _LTOG not a)
+#define NOT_W(a) CHOICE(notw a, notw a, _WTOG not a)
+#define NOT_B(a) CHOICE(notb a, notb a, notb a)
+#define OR_L(a,b) CHOICE(orl ARG2(a,b), orl ARG2(a,b), _LTOG or ARG2(b,a))
+#define OR_W(a,b) CHOICE(orw ARG2(a,b), orw ARG2(a,b), _WTOG or ARG2(b,a))
+#define OR_B(a,b) CHOICE(orb ARG2(a,b), orb ARG2(a,b), orb ARG2(b,a))
+#define OUT_L CHOICE(outl (DX), outl ARG2(EAX,DX), _LTOG out DX)
+#define OUT_W CHOICE(outw (DX), outw ARG2(AX,DX), _WTOG out DX)
+#define OUT_B CHOICE(outb (DX), outb ARG2(AL,DX), outb DX)
+/* Please AS code writer: use the following ONLY, if you refer to ports<256
+ * directly, but not in OUT1_W(DX), for instance, even if OUT1_ looks nicer
+ */
+#define OUT1_L(a) CHOICE(outl (a), outl ARG2(EAX,a), _LTOG out a)
+#define OUT1_W(a) CHOICE(outw (a), outw ARG2(AX,a), _WTOG out a)
+#define OUT1_B(a) CHOICE(outb (a), outb ARG2(AL,a), outb a)
+#define OUTS_L CHOICE(outsl, outsl, _LTOG outs)
+#define OUTS_W CHOICE(outsw, outsw, _WTOG outs)
+#define OUTS_B CHOICE(outsb, outsb, outsb)
+#define POP_SR(a) CHOICE(pop a, pop a, pop a)
+#define POP_L(a) CHOICE(popl a, popl a, _LTOG pop a)
+#define POP_W(a) CHOICE(popw a, popw a, _WTOG pop a)
+#define POPA_L CHOICE(popal, popal, _LTOG popa)
+#define POPA_W CHOICE(popaw, popaw, _WTOG popa)
+#define POPF_L CHOICE(popfl, popfl, _LTOG popf)
+#define POPF_W CHOICE(popfw, popfw, _WTOG popf)
+#define PUSH_SR(a) CHOICE(push a, push a, push a)
+#define PUSH_L(a) CHOICE(pushl a, pushl a, _LTOG push a)
+#define PUSH_W(a) CHOICE(pushw a, pushw a, _WTOG push a)
+#define PUSH_B(a) CHOICE(push a, pushb a, push a)
+#define PUSHA_L CHOICE(pushal, pushal, _LTOG pusha)
+#define PUSHA_W CHOICE(pushaw, pushaw, _WTOG pusha)
+#define PUSHF_L CHOICE(pushfl, pushfl, _LTOG pushf)
+#define PUSHF_W CHOICE(pushfw, pushfw, _WTOG pushf)
+#define RCL_L(a, b) CHOICE(rcll ARG2(a,b), rcll ARG2(a,b), _LTOG rcl ARG2(b,a))
+#define RCL_W(a, b) CHOICE(rclw ARG2(a,b), rclw ARG2(a,b), _WTOG rcl ARG2(b,a))
+#define RCL_B(a, b) CHOICE(rclb ARG2(a,b), rclb ARG2(a,b), rclb ARG2(b,a))
+#define RCR_L(a, b) CHOICE(rcrl ARG2(a,b), rcrl ARG2(a,b), _LTOG rcr ARG2(b,a))
+#define RCR_W(a, b) CHOICE(rcrw ARG2(a,b), rcrw ARG2(a,b), _WTOG rcr ARG2(b,a))
+#define RCR_B(a, b) CHOICE(rcrb ARG2(a,b), rcrb ARG2(a,b), rcrb ARG2(b,a))
+#define ROL_L(a, b) CHOICE(roll ARG2(a,b), roll ARG2(a,b), _LTOG rol ARG2(b,a))
+#define ROL_W(a, b) CHOICE(rolw ARG2(a,b), rolw ARG2(a,b), _WTOG rol ARG2(b,a))
+#define ROL_B(a, b) CHOICE(rolb ARG2(a,b), rolb ARG2(a,b), rolb ARG2(b,a))
+#define ROR_L(a, b) CHOICE(rorl ARG2(a,b), rorl ARG2(a,b), _LTOG ror ARG2(b,a))
+#define ROR_W(a, b) CHOICE(rorw ARG2(a,b), rorw ARG2(a,b), _WTOG ror ARG2(b,a))
+#define ROR_B(a, b) CHOICE(rorb ARG2(a,b), rorb ARG2(a,b), rorb ARG2(b,a))
+#define REP CHOICE(rep ;, rep ;, repe)
+#define REPE CHOICE(repz ;, repe ;, repe)
+#define REPNE CHOICE(repnz ;, repne ;, repne)
+#define REPNZ REPNE
+#define REPZ REPE
+#define RET CHOICE(ret, ret, ret)
+#define SAHF CHOICE(sahf, sahf, sahf)
+#define SAL_L(a, b) CHOICE(sall ARG2(a,b), sall ARG2(a,b), _LTOG sal ARG2(b,a))
+#define SAL_W(a, b) CHOICE(salw ARG2(a,b), salw ARG2(a,b), _WTOG sal ARG2(b,a))
+#define SAL_B(a, b) CHOICE(salb ARG2(a,b), salb ARG2(a,b), salb ARG2(b,a))
+#define SAR_L(a, b) CHOICE(sarl ARG2(a,b), sarl ARG2(a,b), _LTOG sar ARG2(b,a))
+#define SAR_W(a, b) CHOICE(sarw ARG2(a,b), sarw ARG2(a,b), _WTOG sar ARG2(b,a))
+#define SAR_B(a, b) CHOICE(sarb ARG2(a,b), sarb ARG2(a,b), sarb ARG2(b,a))
+#define SBB_L(a, b) CHOICE(sbbl ARG2(a,b), sbbl ARG2(a,b), _LTOG sbb ARG2(b,a))
+#define SBB_W(a, b) CHOICE(sbbw ARG2(a,b), sbbw ARG2(a,b), _WTOG sbb ARG2(b,a))
+#define SBB_B(a, b) CHOICE(sbbb ARG2(a,b), sbbb ARG2(a,b), sbbb ARG2(b,a))
+#define SCAS_L CHOICE(scasl, scasl, _LTOG scas)
+#define SCAS_W CHOICE(scasw, scasw, _WTOG scas)
+#define SCAS_B CHOICE(scasb, scasb, scasb)
+#define SETA(a) CHOICE(seta a, seta a, seta a)
+#define SETAE(a) CHOICE(setae a, setae a, setae a)
+#define SETB(a) CHOICE(setb a, setb a, setb a)
+#define SETBE(a) CHOICE(setbe a, setbe a, setbe a)
+#define SETC(a) CHOICE(setc a, setb a, setb a)
+#define SETE(a) CHOICE(sete a, sete a, sete a)
+#define SETG(a) CHOICE(setg a, setg a, setg a)
+#define SETGE(a) CHOICE(setge a, setge a, setge a)
+#define SETL(a) CHOICE(setl a, setl a, setl a)
+#define SETLE(a) CHOICE(setle a, setle a, setle a)
+#define SETNA(a) CHOICE(setna a, setna a, setna a)
+#define SETNAE(a) CHOICE(setnae a, setnae a, setnae a)
+#define SETNB(a) CHOICE(setnb a, setnb a, setnb a)
+#define SETNBE(a) CHOICE(setnbe a, setnbe a, setnbe a)
+#define SETNC(a) CHOICE(setnc a, setnb a, setnb a)
+#define SETNE(a) CHOICE(setne a, setne a, setne a)
+#define SETNG(a) CHOICE(setng a, setng a, setng a)
+#define SETNGE(a) CHOICE(setnge a, setnge a, setnge a)
+#define SETNL(a) CHOICE(setnl a, setnl a, setnl a)
+#define SETNLE(a) CHOICE(setnle a, setnle a, setnle a)
+#define SETNO(a) CHOICE(setno a, setno a, setno a)
+#define SETNP(a) CHOICE(setnp a, setnp a, setnp a)
+#define SETNS(a) CHOICE(setns a, setns a, setna a)
+#define SETNZ(a) CHOICE(setnz a, setnz a, setnz a)
+#define SETO(a) CHOICE(seto a, seto a, seto a)
+#define SETP(a) CHOICE(setp a, setp a, setp a)
+#define SETPE(a) CHOICE(setpe a, setpe a, setpe a)
+#define SETPO(a) CHOICE(setpo a, setpo a, setpo a)
+#define SETS(a) CHOICE(sets a, sets a, seta a)
+#define SETZ(a) CHOICE(setz a, setz a, setz a)
+#define SGDT(a) CHOICE(sgdt a, sgdt a, sgdt a)
+#define SIDT(a) CHOICE(sidt a, sidt a, sidt a)
+#define SHL_L(a, b) CHOICE(shll ARG2(a,b), shll ARG2(a,b), _LTOG shl ARG2(b,a))
+#define SHL_W(a, b) CHOICE(shlw ARG2(a,b), shlw ARG2(a,b), _WTOG shl ARG2(b,a))
+#define SHL_B(a, b) CHOICE(shlb ARG2(a,b), shlb ARG2(a,b), shlb ARG2(b,a))
+#define SHLD_L(a,b,c) CHOICE(shldl ARG3(a,b,c), shldl ARG3(a,b,c), _LTOG shld ARG3(c,b,a))
+#define SHLD2_L(a,b) CHOICE(shldl ARG2(a,b), shldl ARG3(CL,a,b), _LTOG shld ARG3(b,a,CL))
+#define SHLD_W(a,b,c) CHOICE(shldw ARG3(a,b,c), shldw ARG3(a,b,c), _WTOG shld ARG3(c,b,a))
+#define SHLD2_W(a,b) CHOICE(shldw ARG2(a,b), shldw ARG3(CL,a,b), _WTOG shld ARG3(b,a,CL))
+#define SHR_L(a, b) CHOICE(shrl ARG2(a,b), shrl ARG2(a,b), _LTOG shr ARG2(b,a))
+#define SHR_W(a, b) CHOICE(shrw ARG2(a,b), shrw ARG2(a,b), _WTOG shr ARG2(b,a))
+#define SHR_B(a, b) CHOICE(shrb ARG2(a,b), shrb ARG2(a,b), shrb ARG2(b,a))
+#define SHRD_L(a,b,c) CHOICE(shrdl ARG3(a,b,c), shrdl ARG3(a,b,c), _LTOG shrd ARG3(c,b,a))
+#define SHRD2_L(a,b) CHOICE(shrdl ARG2(a,b), shrdl ARG3(CL,a,b), _LTOG shrd ARG3(b,a,CL))
+#define SHRD_W(a,b,c) CHOICE(shrdw ARG3(a,b,c), shrdw ARG3(a,b,c), _WTOG shrd ARG3(c,b,a))
+#define SHRD2_W(a,b) CHOICE(shrdw ARG2(a,b), shrdw ARG3(CL,a,b), _WTOG shrd ARG3(b,a,CL))
+#define SLDT(a) CHOICE(sldt a, sldt a, sldt a)
+#define SMSW(a) CHOICE(smsw a, smsw a, smsw a)
+#define STC CHOICE(stc, stc, stc)
+#define STD CHOICE(std, std, std)
+#define STI CHOICE(sti, sti, sti)
+#define STOS_L CHOICE(stosl, stosl, _LTOG stos)
+#define STOS_W CHOICE(stosw, stosw, _WTOG stos)
+#define STOS_B CHOICE(stosb, stosb, stosb)
+#define STR(a) CHOICE(str a, str a, str a)
+#define SUB_L(a, b) CHOICE(subl ARG2(a,b), subl ARG2(a,b), _LTOG sub ARG2(b,a))
+#define SUB_W(a, b) CHOICE(subw ARG2(a,b), subw ARG2(a,b), _WTOG sub ARG2(b,a))
+#define SUB_B(a, b) CHOICE(subb ARG2(a,b), subb ARG2(a,b), subb ARG2(b,a))
+#define TEST_L(a, b) CHOICE(testl ARG2(a,b), testl ARG2(a,b), _LTOG test ARG2(b,a))
+#define TEST_W(a, b) CHOICE(testw ARG2(a,b), testw ARG2(a,b), _WTOG test ARG2(b,a))
+#define TEST_B(a, b) CHOICE(testb ARG2(a,b), testb ARG2(a,b), testb ARG2(b,a))
+#define VERR(a) CHOICE(verr a, verr a, verr a)
+#define VERW(a) CHOICE(verw a, verw a, verw a)
+#define WAIT CHOICE(wait, wait, wait)
+#define XCHG_L(a, b) CHOICE(xchgl ARG2(a,b), xchgl ARG2(a,b), _LTOG xchg ARG2(b,a))
+#define XCHG_W(a, b) CHOICE(xchgw ARG2(a,b), xchgw ARG2(a,b), _WTOG xchg ARG2(b,a))
+#define XCHG_B(a, b) CHOICE(xchgb ARG2(a,b), xchgb ARG2(a,b), xchgb ARG2(b,a))
+#define XLAT CHOICE(xlat, xlat, xlat)
+#define XOR_L(a, b) CHOICE(xorl ARG2(a,b), xorl ARG2(a,b), _LTOG xor ARG2(b,a))
+#define XOR_W(a, b) CHOICE(xorw ARG2(a,b), xorw ARG2(a,b), _WTOG xor ARG2(b,a))
+#define XOR_B(a, b) CHOICE(xorb ARG2(a,b), xorb ARG2(a,b), xorb ARG2(b,a))
+
+
+/* Floating Point Instructions */
+#define F2XM1 CHOICE(f2xm1, f2xm1, f2xm1)
+#define FABS CHOICE(fabs, fabs, fabs)
+#define FADD_D(a) CHOICE(faddl a, faddl a, faddd a)
+#define FADD_S(a) CHOICE(fadds a, fadds a, fadds a)
+#define FADD2(a, b) CHOICE(fadd ARG2(a,b), fadd ARG2(a,b), fadd ARG2(b,a))
+#define FADDP(a, b) CHOICE(faddp ARG2(a,b), faddp ARG2(a,b), faddp ARG2(b,a))
+#define FIADD_L(a) CHOICE(fiaddl a, fiaddl a, fiaddl a)
+#define FIADD_W(a) CHOICE(fiadd a, fiadds a, fiadds a)
+#define FBLD(a) CHOICE(fbld a, fbld a, fbld a)
+#define FBSTP(a) CHOICE(fbstp a, fbstp a, fbstp a)
+#define FCHS CHOICE(fchs, fchs, fchs)
+#define FCLEX CHOICE(fclex, wait; fnclex, wait; fclex)
+#define FNCLEX CHOICE(fnclex, fnclex, fclex)
+#define FCOM(a) CHOICE(fcom a, fcom a, fcom a)
+#define FCOM_D(a) CHOICE(fcoml a, fcoml a, fcomd a)
+#define FCOM_S(a) CHOICE(fcoms a, fcoms a, fcoms a)
+#define FCOMP(a) CHOICE(fcomp a, fcomp a, fcomp a)
+#define FCOMP_D(a) CHOICE(fcompl a, fcompl a, fcompd a)
+#define FCOMP_S(a) CHOICE(fcomps a, fcomps a, fcomps a)
+#define FCOMPP CHOICE(fcompp, fcompp, fcompp)
+#define FCOS CHOICE(fcos, fcos, fcos)
+#define FDECSTP CHOICE(fdecstp, fdecstp, fdecstp)
+#define FDIV_D(a) CHOICE(fdivl a, fdivl a, fdivd a)
+#define FDIV_S(a) CHOICE(fdivs a, fdivs a, fdivs a)
+#define FDIV2(a, b) CHOICE(fdiv ARG2(a,b), fdiv ARG2(a,b), fdiv ARG2(b,a))
+#define FDIVP(a, b) CHOICE(fdivp ARG2(a,b), fdivp ARG2(a,b), fdivp ARG2(b,a))
+#define FIDIV_L(a) CHOICE(fidivl a, fidivl a, fidivl a)
+#define FIDIV_W(a) CHOICE(fidiv a, fidivs a, fidivs a)
+#define FDIVR_D(a) CHOICE(fdivrl a, fdivrl a, fdivrd a)
+#define FDIVR_S(a) CHOICE(fdivrs a, fdivrs a, fdivrs a)
+#define FDIVR2(a, b) CHOICE(fdivr ARG2(a,b), fdivr ARG2(a,b), fdivr ARG2(b,a))
+#define FDIVRP(a, b) CHOICE(fdivrp ARG2(a,b), fdivrp ARG2(a,b), fdivrp ARG2(b,a))
+#define FIDIVR_L(a) CHOICE(fidivrl a, fidivrl a, fidivrl a)
+#define FIDIVR_W(a) CHOICE(fidivr a, fidivrs a, fidivrs a)
+#define FFREE(a) CHOICE(ffree a, ffree a, ffree a)
+#define FICOM_L(a) CHOICE(ficoml a, ficoml a, ficoml a)
+#define FICOM_W(a) CHOICE(ficom a, ficoms a, ficoms a)
+#define FICOMP_L(a) CHOICE(ficompl a, ficompl a, ficompl a)
+#define FICOMP_W(a) CHOICE(ficomp a, ficomps a, ficomps a)
+#define FILD_Q(a) CHOICE(fildll a, fildq a, fildq a)
+#define FILD_L(a) CHOICE(fildl a, fildl a, fildl a)
+#define FILD_W(a) CHOICE(fild a, filds a, filds a)
+#define FINCSTP CHOICE(fincstp, fincstp, fincstp)
+#define FINIT CHOICE(finit, wait; fninit, wait; finit)
+#define FNINIT CHOICE(fninit, fninit, finit)
+#define FIST_L(a) CHOICE(fistl a, fistl a, fistl a)
+#define FIST_W(a) CHOICE(fist a, fists a, fists a)
+#define FISTP_Q(a) CHOICE(fistpll a, fistpq a, fistpq a)
+#define FISTP_L(a) CHOICE(fistpl a, fistpl a, fistpl a)
+#define FISTP_W(a) CHOICE(fistp a, fistps a, fistps a)
+#define FLD_X(a) CHOICE(fldt a, fldt a, fldx a) /* 80 bit data type! */
+#define FLD_D(a) CHOICE(fldl a, fldl a, fldd a)
+#define FLD_S(a) CHOICE(flds a, flds a, flds a)
+#define FLD1 CHOICE(fld1, fld1, fld1)
+#define FLDL2T CHOICE(fldl2t, fldl2t, fldl2t)
+#define FLDL2E CHOICE(fldl2e, fldl2e, fldl2e)
+#define FLDPI CHOICE(fldpi, fldpi, fldpi)
+#define FLDLG2 CHOICE(fldlg2, fldlg2, fldlg2)
+#define FLDLN2 CHOICE(fldln2, fldln2, fldln2)
+#define FLDZ CHOICE(fldz, fldz, fldz)
+#define FLDCW(a) CHOICE(fldcw a, fldcw a, fldcw a)
+#define FLDENV(a) CHOICE(fldenv a, fldenv a, fldenv a)
+#define FMUL_S(a) CHOICE(fmuls a, fmuls a, fmuls a)
+#define FMUL_D(a) CHOICE(fmull a, fmull a, fmuld a)
+#define FMUL2(a, b) CHOICE(fmul ARG2(a,b), fmul ARG2(a,b), fmul ARG2(b,a))
+#define FMULP(a, b) CHOICE(fmulp ARG2(a,b), fmulp ARG2(a,b), fmulp ARG2(b,a))
+#define FIMUL_L(a) CHOICE(fimull a, fimull a, fimull a)
+#define FIMUL_W(a) CHOICE(fimul a, fimuls a, fimuls a)
+#define FNOP CHOICE(fnop, fnop, fnop)
+#define FPATAN CHOICE(fpatan, fpatan, fpatan)
+#define FPREM CHOICE(fprem, fprem, fprem)
+#define FPREM1 CHOICE(fprem1, fprem1, fprem1)
+#define FPTAN CHOICE(fptan, fptan, fptan)
+#define FRNDINT CHOICE(frndint, frndint, frndint)
+#define FRSTOR(a) CHOICE(frstor a, frstor a, frstor a)
+#define FSAVE(a) CHOICE(fsave a, wait; fnsave a, wait; fsave a)
+#define FNSAVE(a) CHOICE(fnsave a, fnsave a, fsave a)
+#define FSCALE CHOICE(fscale, fscale, fscale)
+#define FSIN CHOICE(fsin, fsin, fsin)
+#define FSINCOS CHOICE(fsincos, fsincos, fsincos)
+#define FSQRT CHOICE(fsqrt, fsqrt, fsqrt)
+#define FST_D(a) CHOICE(fstl a, fstl a, fstd a)
+#define FST_S(a) CHOICE(fsts a, fsts a, fsts a)
+#define FSTP_X(a) CHOICE(fstpt a, fstpt a, fstpx a)
+#define FSTP_D(a) CHOICE(fstpl a, fstpl a, fstpd a)
+#define FSTP_S(a) CHOICE(fstps a, fstps a, fstps a)
+#define FSTCW(a) CHOICE(fstcw a, wait; fnstcw a, wait; fstcw a)
+#define FNSTCW(a) CHOICE(fnstcw a, fnstcw a, fstcw a)
+#define FSTENV(a) CHOICE(fstenv a, wait; fnstenv a, fstenv a)
+#define FNSTENV(a) CHOICE(fnstenv a, fnstenv a, fstenv a)
+#define FSTSW(a) CHOICE(fstsw a, wait; fnstsw a, wait; fstsw a)
+#define FNSTSW(a) CHOICE(fnstsw a, fnstsw a, fstsw a)
+#define FSUB_S(a) CHOICE(fsubs a, fsubs a, fsubs a)
+#define FSUB_D(a) CHOICE(fsubl a, fsubl a, fsubd a)
+#define FSUB2(a, b) CHOICE(fsub ARG2(a,b), fsub ARG2(a,b), fsub ARG2(b,a))
+#define FSUBP(a, b) CHOICE(fsubp ARG2(a,b), fsubp ARG2(a,b), fsubp ARG2(b,a))
+#define FISUB_L(a) CHOICE(fisubl a, fisubl a, fisubl a)
+#define FISUB_W(a) CHOICE(fisub a, fisubs a, fisubs a)
+#define FSUBR_S(a) CHOICE(fsubrs a, fsubrs a, fsubrs a)
+#define FSUBR_D(a) CHOICE(fsubrl a, fsubrl a, fsubrd a)
+#define FSUBR2(a, b) CHOICE(fsubr ARG2(a,b), fsubr ARG2(a,b), fsubr ARG2(b,a))
+#define FSUBRP(a, b) CHOICE(fsubrp ARG2(a,b), fsubrp ARG2(a,b), fsubrp ARG2(b,a))
+#define FISUBR_L(a) CHOICE(fisubrl a, fisubrl a, fisubrl a)
+#define FISUBR_W(a) CHOICE(fisubr a, fisubrs a, fisubrs a)
+#define FTST CHOICE(ftst, ftst, ftst)
+#define FUCOM(a) CHOICE(fucom a, fucom a, fucom a)
+#define FUCOMP(a) CHOICE(fucomp a, fucomp a, fucomp a)
+#define FUCOMPP CHOICE(fucompp, fucompp, fucompp)
+#define FWAIT CHOICE(wait, wait, wait)
+#define FXAM CHOICE(fxam, fxam, fxam)
+#define FXCH(a) CHOICE(fxch a, fxch a, fxch a)
+#define FXTRACT CHOICE(fxtract, fxtract, fxtract)
+#define FYL2X CHOICE(fyl2x, fyl2x, fyl2x)
+#define FYL2XP1 CHOICE(fyl2xp1, fyl2xp1, fyl2xp1)
+
+#endif /* __ASSYNTAX_H__ */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile
new file mode 100644
index 000000000..00309690e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile
@@ -0,0 +1,242 @@
+XCOMM $XConsortium: Imakefile /main/12 1996/10/27 11:06:35 kaleb $
+
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile,v 3.61 2003/10/07 22:30:00 herrb Exp $
+
+#include <Server.tmpl>
+
+#if defined(KFreeBSDArchitecture) || defined(NetBSDArchitecture) || defined(OpenBSDArchitecture)
+#if BuildXInputExt
+# if JoystickSupport
+ JOYSTICK_SRC = bsd_jstk.c
+# endif
+# if DoLoadableServer
+SHARED_CFLAGS = PositionIndependentCFlags
+# else
+# if JoystickSupport
+ JOYSTICK_OBJ = bsd_jstk.o
+# endif
+# endif
+#endif
+#endif
+
+#if defined(NetBSDArchitecture) \
+ && ((OSMajorVersion == 1 && OSMinorVersion >= 1) || OSMajorVersion >= 2)
+# if defined(AlphaArchitecture)
+ IOPERMDEFINES = -DUSE_ALPHA_PIO
+# elif defined(ArcArchitecture)
+ IOPERMDEFINES = -DUSE_ARC_MMAP
+# elif defined(Arm32Architecture)
+ IOPERMDEFINES = -DUSE_ARM32_MMAP
+# elif defined(PpcArchitecture) || \
+ defined(Sparc64Architecture)
+ IOPERM_SRC = ioperm_noop.c
+ IOPERM_OBJ = ioperm_noop.o
+# else
+ IOPERMDEFINES = -DUSE_I386_IOPL
+# endif
+#elif defined(OpenBSDArchitecture)
+# if defined(i386Architecture)
+ IOPERMDEFINES = -DUSE_I386_IOPL
+# elif defined(AMD64Architecture)
+ IOPERMDEFINES = -DUSE_AMD64_IOPL
+# else
+ IOPERM_SRC = ioperm_noop.c
+ IOPERM_OBJ = ioperm_noop.o
+# endif
+#elif defined(KFreeBSDArchitecture)
+# if defined(i386Architecture) || defined(AMD64Architecture)
+ IOPERMDEFINES = -DUSE_DEV_IO
+# elif defined(AlphaBsdArchitecture)
+ IOPERMDEFINES = -DUSE_ALPHA_PORTS
+# else
+ IOPERM_SRC = ioperm_noop.c
+ IOPERM_OBJ = ioperm_noop.o
+# endif
+#endif
+
+#if BuildXF86DRI
+DRI_SRC = sigio.c
+DRI_OBJ = sigio.o
+#endif
+
+MOUSESRC = bsd_mouse.c
+MOUSEOBJ = bsd_mouse.o
+
+KBDSRC = bsd_kbd.c bsd_KbdMap.c at_scancode.c
+KBDOBJ = bsd_kbd.o bsd_KbdMap.o at_scancode.o
+
+#if HasMTRRSupport
+MTRRDEFINES = -DHAS_MTRR_SUPPORT
+#endif
+
+#if defined(NetBSDArchitecture) && defined(HasMTRRBuiltin)
+MTRRDEFINES = -DHAS_MTRR_BUILTIN
+#endif
+
+SYSVIPCDEFINES = -DHAVE_SYSV_IPC
+
+#if UsbMouseSupport
+USBMOUSEDEFINES1 = -DUSBMOUSE_SUPPORT
+#if !HasLibUsb
+LIBUSBINCLUDES = -Ilibusb
+#define IHaveSubdirs
+SUBDIRS = libusb
+#else
+#if HasLibUsbHid
+USBMOUSEDEFINES2 = -DHAS_LIB_USB_HID
+#endif
+#endif
+#endif
+USBMOUSEDEFINES = $(USBMOUSEDEFINES1) $(USBMOUSEDEFINES2)
+
+#if (defined(OpenBSDArchitecture) || defined(NetBSDArchitecture)) && defined(i386Architecture)
+# if !defined(HasApmKqueue) || !HasApmKqueue
+APMSRC = bsd_apm.c
+APMOBJ = bsd_apm.o
+# else
+APMSRC = bsd_kqueue_apm.c
+APMOBJ = bsd_kqueue_apm.o
+# endif
+#else
+APMSRC = pm_noop.c
+APMOBJ = pm_noop.o
+#endif
+
+#if defined(KFreeBSDArchitecture) && (OSMajorVersion > 2)
+KMODSRC = bsd_kmod.c
+KMODOBJ = bsd_kmod.o
+#else
+KMODSRC = kmod_noop.c
+KMODOBJ = kmod_noop.o
+#endif
+
+#if defined(i386Architecture) || defined(ia64Architecture)
+RES_SRC=stdResource.c
+RES_OBJ=stdResource.o
+#else
+RES_SRC=bsdResource.c
+RES_OBJ=bsdResource.o
+#endif
+
+#if defined(AlphaArchitecture)
+AXP_SRC=bsd_ev56.c xf86Axp.c bsd_axp.c
+AXP_OBJ=bsd_ev56.o xf86Axp.o bsd_axp.o
+#endif
+
+#if (defined(KFreeBSDArchitecture) || defined(NetBSDArchitecture) || \
+ defined(OpenBSDArchitecture)) && HasAgpGart
+AGP_SRC=lnx_agp.c
+AGP_OBJ=lnx_agp.o
+#else
+AGP_SRC=agp_noop.c
+AGP_OBJ=agp_noop.o
+#endif
+
+#if defined(i386Architecture) || defined(AMD64Architecture)
+VIDEO_SRC = i386_video.c
+VIDEO_OBJ = i386_video.o
+#elif defined(AlphaArchitecture)
+VIDEO_SRC = alpha_video.c
+VIDEO_OBJ = alpha_video.o
+#elif defined(PpcArchitecture)
+VIDEO_SRC = ppc_video.c
+VIDEO_OBJ = ppc_video.o
+#elif defined(Arm32Architecture)
+VIDEO_SRC = arm_video.c
+VIDEO_OBJ = arm_video.o
+#elif defined(SparcArchitecture) || defined(Sparc64Architecture)
+VIDEO_SRC = sparc64_video.c
+VIDEO_OBJ = sparc64_video.o
+#else
+#error Unknown architecture !
+#endif
+
+SRCS = bsd_init.c $(VIDEO_SRC) bsd_io.c bsd_VTsw.c \
+ libc_wrapper.c $(IOPERM_SRC) std_kbdEv.c posix_tty.c $(MOUSESRC) \
+ $(RES_SRC) stdPci.c vidmem.c $(JOYSTICK_SRC) sigio.c $(APMSRC) \
+ $(AXP_SRC) $(KMODSRC) $(AGP_SRC) $(KBDSRC)
+
+OBJS = bsd_init.o $(VIDEO_OBJ) bsd_io.o bsd_VTsw.o \
+ libc_wrapper.o $(IOPERM_OBJ) std_kbdEv.o posix_tty.o $(MOUSEOBJ) \
+ $(RES_OBJ) stdPci.o vidmem.o $(JOYSTICK_OBJ) sigio.o $(APMOBJ) \
+ $(AXP_OBJ) $(KMODOBJ) $(AGP_OBJ) $(KBDOBJ)
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/mi $(APINCLUDES) \
+ $(LIBUSBINCLUDES) -I$(XF86OSSRC)/shared -I$(DRMSRCDIR)/shared-core
+
+CONSDEFINES = XFree86ConsoleDefines
+RESDEFINES = -DUSESTDRES
+
+#if defined(HasNetBSDApertureDriver) && HasNetBSDApertureDriver
+APDEFINES = -DHAS_APERTURE_DRV
+#endif
+
+DEFINES = $(CONSDEFINES) $(APDEFINES) $(IOPERMDEFINES) $(RESDEFINES) \
+ $(MTRRDEFINES) $(USBMOUSEDEFINES) $(SYSVIPCDEFINES)
+
+#if defined(AlphaArchitecture)
+SpecialObjectRule(bsd_ev56.o, bsd_ev56.c, -mcpu=ev56)
+#endif
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+#if BuildXF86DRI
+#define IHaveSubdirs
+SUBDIRS = drm
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+#if BuildXInputExt
+# if DoLoadableServer
+# if JoystickSupport
+AllTarget(bsd_jstk.o)
+#if 0
+InstallDynamicModule(bsd_jstk.o,$(MODULEDIR),input)
+#endif
+# endif
+# endif
+#endif
+
+#if !defined(NetBSDArchitecture) && !defined(OpenBSDArchitecture) || \
+ !defined(i386Architecture)
+LinkSourceFile(pm_noop.c,../shared)
+#endif
+LinkSourceFile(ioperm_noop.c,../shared)
+LinkSourceFile(std_kbdEv.c,../shared)
+LinkSourceFile(at_scancode.c,../shared)
+LinkSourceFile(posix_tty.c,../shared)
+LinkSourceFile(libc_wrapper.c,../shared)
+LinkSourceFile(stdResource.c,../shared)
+LinkSourceFile(stdPci.c,../shared)
+LinkSourceFile(vidmem.c,../shared)
+LinkSourceFile(sigio.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
+#if (defined(KFreeBSDArchitecture) || defined(NetBSDArchitecture) || \
+ defined(OpenBSDArchitecture)) && HasAgpGart
+LinkSourceFile(lnx_agp.c,../linux)
+#else
+LinkSourceFile(agp_noop.c,../shared)
+#endif
+#if defined(AlphaArchitecture)
+LinkSourceFile(xf86Axp.c,../shared)
+#endif
+
+DependTarget()
+
+#if UsbMouseSupport && !HasLibUsb
+MakeSubdirs($(SUBDIRS))
+
+DependSubdirs($(SUBDIRS))
+#endif
+
+#if 0
+InstallDriverSDKDynamicModule(bsd_jstk.o,$(DRIVERSDKMODULEDIR))
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/alpha_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/alpha_video.c
new file mode 100644
index 000000000..ca0f0f8e7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/alpha_video.c
@@ -0,0 +1,735 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/alpha_video.c,v 1.6 2003/12/30 15:18:30 herrb Exp $ */
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/* $XConsortium: bsd_video.c /main/10 1996/10/25 11:37:57 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+
+#include <sys/param.h>
+#ifndef __NetBSD__
+# include <sys/sysctl.h>
+# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+# include <machine/sysarch.h>
+# endif
+# else
+# include <machine/sysarch.h>
+#endif
+
+#include "xf86Axp.h"
+
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#if defined(__NetBSD__) && !defined(MAP_FILE)
+#define MAP_FLAGS MAP_SHARED
+#else
+#define MAP_FLAGS (MAP_FILE | MAP_SHARED)
+#endif
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)-1)
+#endif
+
+axpDevice bsdGetAXP(void);
+
+#ifndef __NetBSD__
+extern unsigned long dense_base(void);
+
+static int axpSystem = -1;
+static unsigned long hae_thresh;
+static unsigned long hae_mask;
+static unsigned long bus_base;
+static unsigned long sparse_size;
+
+static unsigned long
+memory_base(void)
+{
+ static unsigned long base = 0;
+
+ if (base == 0) {
+ size_t len = sizeof(base);
+ int error;
+#ifdef __OpenBSD__
+ int mib[3];
+
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_CHIPSET;
+ mib[2] = CPU_CHIPSET_MEM;
+
+ if ((error = sysctl(mib, 3, &base, &len, NULL, 0)) < 0)
+#else
+ if ((error = sysctlbyname("hw.chipset.memory", &base, &len,
+ 0, 0)) < 0)
+#endif
+ FatalError("xf86MapVidMem: can't find memory\n");
+ }
+
+ return base;
+}
+
+static int
+has_bwx(void)
+{
+ static int bwx = 0;
+ size_t len = sizeof(bwx);
+ int error;
+#ifdef __OpenBSD__
+ int mib[3];
+
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_CHIPSET;
+ mib[2] = CPU_CHIPSET_BWX;
+
+ if ((error = sysctl(mib, 3, &bwx, &len, NULL, 0)) < 0)
+ return FALSE;
+ else
+ return bwx;
+#else
+ if ((error = sysctlbyname("hw.chipset.bwx", &bwx, &len, 0, 0)) < 0)
+ return FALSE;
+ else
+ return bwx;
+#endif
+}
+#else /* __NetBSD__ */
+static unsigned long hae_thresh = (1UL << 24);
+static unsigned long hae_mask = 0xf8000000UL; /* XXX - should use xf86AXP.c */
+static struct alpha_bus_window *abw;
+static int abw_count = -1;
+
+static void
+init_abw(void)
+{
+ if (abw_count < 0) {
+ abw_count = alpha_bus_getwindows(ALPHA_BUS_TYPE_PCI_MEM, &abw);
+ if (abw_count <= 0)
+ FatalError("init_abw: alpha_bus_getwindows failed\n");
+ }
+}
+
+static int
+has_bwx(void)
+{
+ if (abw_count < 0)
+ init_abw();
+
+ xf86Msg(X_INFO, "has_bwx = %d\n",
+ abw[0].abw_abst.abst_flags & ABST_BWX ? 1 : 0); /* XXXX */
+ return abw[0].abw_abst.abst_flags & ABST_BWX;
+}
+
+static unsigned long
+dense_base(void)
+{
+ if (abw_count < 0)
+ init_abw();
+
+ /* XXX check abst_flags for ABST_DENSE just to be safe? */
+ xf86Msg(X_INFO, "dense base = %#lx\n",
+ abw[0].abw_abst.abst_sys_start); /* XXXX */
+ return abw[0].abw_abst.abst_sys_start;
+}
+
+static unsigned long
+memory_base(void)
+{
+ if (abw_count < 0)
+ init_abw();
+
+ if (abw_count > 0) {
+ xf86Msg(X_INFO, "memory base = %#lx\n",
+ abw[1].abw_abst.abst_sys_start); /* XXXX */
+ return abw[1].abw_abst.abst_sys_start;
+ } else {
+ xf86Msg(X_INFO, "no memory base\n"); /* XXXX */
+ return 0;
+ }
+}
+#endif /* __NetBSD__ */
+
+#define BUS_BASE dense_base()
+#define BUS_BASE_BWX memory_base()
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+#ifdef __OpenBSD__
+#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\
+ "\tin /etc/sysctl.conf and reboot your machine\n" \
+ "\trefer to xf86(4) for details"
+#endif
+
+static Bool useDevMem = FALSE;
+static int devMemFd = -1;
+
+#ifdef HAS_APERTURE_DRV
+#define DEV_APERTURE "/dev/xf86"
+#endif
+#define DEV_MEM "/dev/mem"
+
+static pointer mapVidMem(int, unsigned long, unsigned long, int);
+static void unmapVidMem(int, pointer, unsigned long);
+static pointer mapVidMemSparse(int, unsigned long, unsigned long, int);
+static void unmapVidMemSparse(int, pointer, unsigned long);
+
+/*
+ * Check if /dev/mem can be mmap'd. If it can't print a warning when
+ * "warn" is TRUE.
+ */
+static void
+checkDevMem(Bool warn)
+{
+ static Bool devMemChecked = FALSE;
+ int fd;
+ pointer base;
+
+ if (devMemChecked)
+ return;
+ devMemChecked = TRUE;
+
+#ifdef HAS_APERTURE_DRV
+ /* Try the aperture driver first */
+ if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) {
+ /* Try to map a page at the VGA address */
+ base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
+
+ if (base != MAP_FAILED) {
+ munmap((caddr_t)base, 4096);
+ devMemFd = fd;
+ useDevMem = TRUE;
+ xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n",
+ DEV_APERTURE);
+ return;
+ } else {
+ if (warn) {
+ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
+ DEV_APERTURE, strerror(errno));
+ }
+ }
+ }
+#endif
+ if ((fd = open(DEV_MEM, O_RDWR)) >= 0) {
+ /* Try to map a page at the VGA address */
+ base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
+
+ if (base != MAP_FAILED) {
+ munmap((caddr_t)base, 4096);
+ devMemFd = fd;
+ useDevMem = TRUE;
+ return;
+ } else {
+ if (warn) {
+ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ }
+ }
+ if (warn) {
+#ifndef HAS_APERTURE_DRV
+ xf86Msg(X_WARNING, "checkDevMem: failed to open/mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+#else
+#ifndef __OpenBSD__
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
+ "\t(%s)\n", DEV_APERTURE, DEV_MEM, strerror(errno));
+#else /* __OpenBSD__ */
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
+ "\t(%s)\n%s", DEV_APERTURE, DEV_MEM, strerror(errno),
+ SYSCTL_MSG);
+#endif /* __OpenBSD__ */
+#endif
+ xf86ErrorF("\tlinear framebuffer access unavailable\n");
+ }
+ useDevMem = FALSE;
+ return;
+}
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ checkDevMem(TRUE);
+ pVidMem->linearSupported = useDevMem;
+
+ if (has_bwx()) {
+ xf86Msg(X_PROBED,"Machine type has 8/16 bit access\n");
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+ } else {
+ xf86Msg(X_PROBED,"Machine needs sparse mapping\n");
+ pVidMem->mapMem = mapVidMemSparse;
+ pVidMem->unmapMem = unmapVidMemSparse;
+#ifndef __NetBSD__
+ if (axpSystem == -1)
+ axpSystem = bsdGetAXP();
+ hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
+ hae_mask = xf86AXPParams[axpSystem].hae_mask;
+ sparse_size = xf86AXPParams[axpSystem].size;
+#endif /* __NetBSD__ */
+ }
+ pVidMem->initialised = TRUE;
+}
+
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ pointer base;
+
+ checkDevMem(FALSE);
+ Base = Base & ((1L<<32) - 1);
+
+ if (useDevMem)
+ {
+ if (devMemFd < 0)
+ {
+ FatalError("xf86MapVidMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ base = mmap((caddr_t)0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX);
+ if (base == MAP_FAILED)
+ {
+ FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)\n",
+ "xf86MapVidMem", DEV_MEM, Size, Base,
+ strerror(errno));
+ }
+ return(base);
+ }
+
+ /* else, mmap /dev/vga */
+ if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
+ {
+ FatalError("%s: Address 0x%lx outside allowable range\n",
+ "xf86MapVidMem", Base);
+ }
+ base = mmap(0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, xf86Info.screenFd,
+ (unsigned long)Base + BUS_BASE);
+ if (base == MAP_FAILED)
+ {
+ FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
+ strerror(errno));
+ }
+ return(base);
+}
+
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap((caddr_t)Base, Size);
+}
+
+/*
+ * Read BIOS via mmap()ing DEV_MEM
+ */
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ unsigned char *ptr;
+ int psize;
+ int mlen;
+
+ checkDevMem(TRUE);
+ if (devMemFd == -1) {
+ return(-1);
+ }
+
+ psize = xf86getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
+ MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE);
+ if ((long)ptr == -1)
+ {
+ xf86Msg(X_WARNING,
+ "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n",
+ DEV_MEM, Len, Base, Offset, strerror(errno));
+ return(-1);
+ }
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
+ Base, ptr[0] | (ptr[1] << 8));
+#endif
+ (void)memcpy(Buf, (void *)(ptr + Offset), Len);
+ (void)munmap((caddr_t)ptr, mlen);
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
+ "-> %02x %02x %02x %02x...\n",
+ Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
+#endif
+ return(Len);
+}
+
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+
+extern int ioperm(unsigned long from, unsigned long num, int on);
+
+Bool
+xf86EnableIO()
+{
+ if (!ioperm(0, 65536, TRUE))
+ return TRUE;
+ return FALSE;
+}
+
+void
+xf86DisableIO()
+{
+ return;
+}
+
+#endif /* __FreeBSD_kernel__ || __OpenBSD__ */
+
+#ifdef USE_ALPHA_PIO
+
+Bool
+xf86EnableIO()
+{
+ alpha_pci_io_enable(1);
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ alpha_pci_io_enable(0);
+}
+
+#endif /* USE_ALPHA_PIO */
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+Bool
+xf86DisableInterrupts()
+{
+
+ return(TRUE);
+}
+
+void
+xf86EnableInterrupts()
+{
+ return;
+}
+
+
+#define vuip volatile unsigned int *
+
+static unsigned long msb_set = 0;
+static pointer memSBase = 0;
+static pointer memBase = 0;
+
+extern int readDense8(pointer Base, register unsigned long Offset);
+extern int readDense16(pointer Base, register unsigned long Offset);
+extern int readDense32(pointer Base, register unsigned long Offset);
+extern void
+writeDenseNB8(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDenseNB16(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDenseNB32(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDense8(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDense16(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDense32(int Value, pointer Base, register unsigned long Offset);
+
+static int readSparse8(pointer Base, register unsigned long Offset);
+static int readSparse16(pointer Base, register unsigned long Offset);
+static int readSparse32(pointer Base, register unsigned long Offset);
+static void
+writeSparseNB8(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseNB16(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseNB32(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparse8(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparse16(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparse32(int Value, pointer Base, register unsigned long Offset);
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+extern int sysarch(int, void *);
+#endif
+
+struct parms {
+ u_int64_t hae;
+};
+
+#ifndef __NetBSD__
+static int
+sethae(u_int64_t hae)
+{
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#ifndef ALPHA_SETHAE
+#define ALPHA_SETHAE 0
+#endif
+ struct parms p;
+ p.hae = hae;
+ return (sysarch(ALPHA_SETHAE, (char *)&p));
+#endif
+#ifdef __OpenBSD__
+ return -1;
+#endif
+}
+#endif /* __NetBSD__ */
+
+static pointer
+mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ static Bool was_here = FALSE;
+
+ if (!was_here) {
+ was_here = TRUE;
+
+ checkDevMem(FALSE);
+
+ xf86WriteMmio8 = writeSparse8;
+ xf86WriteMmio16 = writeSparse16;
+ xf86WriteMmio32 = writeSparse32;
+ xf86WriteMmioNB8 = writeSparseNB8;
+ xf86WriteMmioNB16 = writeSparseNB16;
+ xf86WriteMmioNB32 = writeSparseNB32;
+ xf86ReadMmio8 = readSparse8;
+ xf86ReadMmio16 = readSparse16;
+ xf86ReadMmio32 = readSparse32;
+
+ memBase = mmap((caddr_t)0, 0x100000000,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, devMemFd,
+ (off_t) BUS_BASE);
+ memSBase = mmap((caddr_t)0, 0x100000000,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, devMemFd,
+ (off_t) BUS_BASE_BWX);
+
+ if (memSBase == MAP_FAILED || memBase == MAP_FAILED) {
+ FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n",
+ strerror(errno));
+ }
+ }
+ return (pointer)((unsigned long)memBase + Base);
+}
+
+static void
+unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size)
+{
+}
+
+static int
+readSparse8(pointer Base, register unsigned long Offset)
+{
+ register unsigned long result, shift;
+ register unsigned long msb;
+ mem_barrier();
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ shift = (Offset & 0x3) << 3;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ result = *(vuip) ((unsigned long)memSBase + (Offset << 5));
+ result >>= shift;
+ return 0xffUL & result;
+}
+
+static int
+readSparse16(pointer Base, register unsigned long Offset)
+{
+ register unsigned long result, shift;
+ register unsigned long msb;
+
+ mem_barrier();
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ shift = (Offset & 0x2) << 3;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ result = *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2)));
+ result >>= shift;
+ return 0xffffUL & result;
+}
+
+static int
+readSparse32(pointer Base, register unsigned long Offset)
+{
+ mem_barrier();
+ return *(vuip)((unsigned long)Base+(Offset));
+}
+
+static void
+writeSparse8(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int b = Value & 0xffU;
+
+ write_mem_barrier();
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101;
+}
+
+static void
+writeSparse16(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int w = Value & 0xffffU;
+
+ write_mem_barrier();
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) =
+ w * 0x00010001;
+
+}
+
+static void
+writeSparse32(int Value, pointer Base, register unsigned long Offset)
+{
+ write_mem_barrier();
+ *(vuip)((unsigned long)Base + (Offset)) = Value;
+ return;
+}
+
+static void
+writeSparseNB8(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int b = Value & 0xffU;
+
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101;
+}
+
+static void
+writeSparseNB16(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int w = Value & 0xffffU;
+
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask ;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) =
+ w * 0x00010001;
+}
+
+static void
+writeSparseNB32(int Value, pointer Base, register unsigned long Offset)
+{
+ *(vuip)((unsigned long)Base + (Offset)) = Value;
+ return;
+}
+
+void (*xf86WriteMmio8)(int Value, pointer Base, unsigned long Offset)
+ = writeDense8;
+void (*xf86WriteMmio16)(int Value, pointer Base, unsigned long Offset)
+ = writeDense16;
+void (*xf86WriteMmio32)(int Value, pointer Base, unsigned long Offset)
+ = writeDense32;
+void (*xf86WriteMmioNB8)(int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB8;
+void (*xf86WriteMmioNB16)(int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB16;
+void (*xf86WriteMmioNB32)(int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB32;
+int (*xf86ReadMmio8)(pointer Base, unsigned long Offset)
+ = readDense8;
+int (*xf86ReadMmio16)(pointer Base, unsigned long Offset)
+ = readDense16;
+int (*xf86ReadMmio32)(pointer Base, unsigned long Offset)
+ = readDense32;
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/arm_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/arm_video.c
new file mode 100644
index 000000000..98fb8f993
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/arm_video.c
@@ -0,0 +1,690 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/arm_video.c,v 1.1tsi Exp $ */
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/*
+ * The ARM32 code here carries the following copyright:
+ *
+ * Copyright 1997
+ * Digital Equipment Corporation. All rights reserved.
+ * This software is furnished under license and may be used and copied only in
+ * accordance with the following terms and conditions. Subject to these
+ * conditions, you may download, copy, install, use, modify and distribute
+ * this software in source and/or binary form. No title or ownership is
+ * transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce and retain
+ * this copyright notice and list of conditions as they appear in the
+ * source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or logo of Digital
+ * Equipment Corporation. Neither the "Digital Equipment Corporation"
+ * name nor any trademark or logo of Digital Equipment Corporation may be
+ * used to endorse or promote products derived from this software without
+ * the prior written permission of Digital Equipment Corporation.
+ *
+ * 3) This software is provided "AS-IS" and any express or implied warranties,
+ * including but not limited to, any implied warranties of merchantability,
+ * fitness for a particular purpose, or non-infringement are disclaimed.
+ * In no event shall DIGITAL be liable for any damages whatsoever, and in
+ * particular, DIGITAL shall not be liable for special, indirect,
+ * consequential, or incidental damages or damages for lost profits, loss
+ * of revenue or loss of use, whether such damages arise in contract,
+ * negligence, tort, under statute, in equity, at law or otherwise, even
+ * if advised of the possibility of such damage.
+ *
+ */
+
+/* $XConsortium: bsd_video.c /main/10 1996/10/25 11:37:57 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#ifdef __arm32__
+#include "machine/devmap.h"
+struct memAccess
+{
+ int ioctl;
+ struct map_info memInfo;
+ pointer regionVirtBase;
+ Bool Checked;
+ Bool OK;
+};
+
+static pointer xf86MapInfoMap();
+static void xf86MapInfoUnmap();
+static struct memAccess *checkMapInfo();
+extern int vgaPhysLinearBase;
+
+/* A memAccess structure is needed for each possible region */
+struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL,
+ FALSE, FALSE };
+struct memAccess linearMemInfo = { CONSOLE_GET_LINEAR_INFO, NULL, NULL,
+ FALSE, FALSE };
+struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL,
+ FALSE, FALSE };
+#endif /* __arm32__ */
+
+#if defined(__NetBSD__) && !defined(MAP_FILE)
+#define MAP_FLAGS MAP_SHARED
+#else
+#define MAP_FLAGS (MAP_FILE | MAP_SHARED)
+#endif
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)-1)
+#endif
+
+
+#define BUS_BASE 0L
+#define BUS_BASE_BWX 0L
+
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+static Bool useDevMem = FALSE;
+static int devMemFd = -1;
+
+#define DEV_MEM "/dev/mem"
+
+static pointer mapVidMem(int, unsigned long, unsigned long, int);
+static void unmapVidMem(int, pointer, unsigned long);
+
+/*
+ * Check if /dev/mem can be mmap'd. If it can't print a warning when
+ * "warn" is TRUE.
+ */
+static void
+checkDevMem(Bool warn)
+{
+ static Bool devMemChecked = FALSE;
+ int fd;
+ pointer base;
+
+ if (devMemChecked)
+ return;
+ devMemChecked = TRUE;
+
+ if ((fd = open(DEV_MEM, O_RDWR)) >= 0)
+ {
+ /* Try to map a page at the VGA address */
+ base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
+
+ if (base != MAP_FAILED)
+ {
+ munmap((caddr_t)base, 4096);
+ devMemFd = fd;
+ useDevMem = TRUE;
+ return;
+ } else {
+ /* This should not happen */
+ if (warn)
+ {
+ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ useDevMem = FALSE;
+ return;
+ }
+ }
+ if (warn)
+ {
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ useDevMem = FALSE;
+ return;
+}
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+
+ checkDevMem(TRUE);
+ pVidMem->linearSupported = useDevMem;
+ pVidMem->mapMem = armMapVidMem;
+ pVidMem->unmapVidMem = armUnmapVidMem;
+
+ pVidMem->initialised = TRUE;
+}
+
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ pointer base;
+
+ checkDevMem(FALSE);
+
+ if (useDevMem)
+ {
+ if (devMemFd < 0)
+ {
+ FatalError("xf86MapVidMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ base = mmap((caddr_t)0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX);
+ if (base == MAP_FAILED)
+ {
+ FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n",
+ "xf86MapVidMem", DEV_MEM, Size, Base,
+ strerror(errno));
+ }
+ return(base);
+ }
+
+ /* else, mmap /dev/vga */
+ if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
+ {
+ FatalError("%s: Address 0x%x outside allowable range\n",
+ "xf86MapVidMem", Base);
+ }
+ base = mmap(0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, xf86Info.screenFd,
+ (unsigned long)Base - 0xA0000);
+ if (base == MAP_FAILED)
+ {
+ FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
+ strerror(errno));
+ }
+ return(base);
+}
+
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap((caddr_t)Base, Size);
+}
+
+/*
+ * Read BIOS via mmap()ing DEV_MEM
+ */
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ unsigned char *ptr;
+ int psize;
+ int mlen;
+
+ checkDevMem(TRUE);
+ if (devMemFd == -1) {
+ return(-1);
+ }
+
+ psize = xf86getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
+ MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE);
+ if ((long)ptr == -1)
+ {
+ xf86Msg(X_WARNING,
+ "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n",
+ DEV_MEM, Len, Base, Offset, strerror(errno));
+ return(-1);
+ }
+#ifdef DEBUG
+ ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
+ Base, ptr[0] | (ptr[1] << 8));
+#endif
+ (void)memcpy(Buf, (void *)(ptr + Offset), Len);
+ (void)munmap((caddr_t)ptr, mlen);
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
+ "-> %02x %02x %02x %02x...\n",
+ Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
+#endif
+ return(Len);
+}
+
+
+/* XXX This needs to be updated for the ND */
+
+/*
+** Find out whether the console driver provides memory mapping information
+** for the specified region and return the map_info pointer. Print a warning if required.
+*/
+static struct memAccess *
+checkMapInfo(Bool warn, int Region)
+{
+ struct memAccess *memAccP;
+
+ switch (Region)
+ {
+ case VGA_REGION:
+ memAccP = &vgaMemInfo;
+ break;
+
+ case LINEAR_REGION:
+ memAccP = &linearMemInfo;
+ break;
+
+ case MMIO_REGION:
+ memAccP = &ioMemInfo;
+ break;
+
+ default:
+ return NULL;
+ break;
+ }
+
+ if(!memAccP->Checked)
+ {
+ if(ioctl(xf86Info.screenFd, memAccP->ioctl, &(memAccP->memInfo)) == -1)
+ {
+ if(warn)
+ {
+ xf86Msg(X_WARNING,
+ "checkMapInfo: failed to get map info for region %d\n\t(%s)\n",
+ Region, strerror(errno));
+ }
+ }
+ else
+ {
+ if(memAccP->memInfo.u.map_info_mmap.map_offset
+ != MAP_INFO_UNKNOWN)
+ memAccP->OK = TRUE;
+ }
+ memAccP->Checked = TRUE;
+ }
+ if (memAccP->OK)
+ {
+ return memAccP;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+static pointer
+xf86MapInfoMap(struct memAccess *memInfoP, pointer Base, unsigned long Size)
+{
+ struct map_info *mapInfoP = &(memInfoP->memInfo);
+
+ if (mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN)
+ {
+ Size = (unsigned long)Base + Size;
+ }
+ else
+ {
+ Size = mapInfoP->u.map_info_mmap.map_size;
+ }
+
+ switch(mapInfoP->method)
+ {
+ case MAP_MMAP:
+ /* Need to remap if size is unknown because we may not have
+ mapped the whole region initially */
+ if(memInfoP->regionVirtBase == NULL ||
+ mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN)
+ {
+ if((memInfoP->regionVirtBase =
+ mmap((caddr_t)0,
+ Size,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED,
+ xf86Info.screenFd,
+ (unsigned long)mapInfoP->u.map_info_mmap.map_offset))
+ == (pointer)-1)
+ {
+ FatalError("xf86MapInfoMap: Failed to map memory at 0x%x\n\t%s\n",
+ mapInfoP->u.map_info_mmap.map_offset, strerror(errno));
+ }
+ if(mapInfoP->u.map_info_mmap.internal_offset > 0)
+ memInfoP->regionVirtBase +=
+ mapInfoP->u.map_info_mmap.internal_offset;
+ }
+ break;
+
+ default:
+ FatalError("xf86MapInfoMap: Unsuported mapping method\n");
+ break;
+ }
+
+ return (pointer)((int)memInfoP->regionVirtBase + (int)Base);
+}
+
+static void
+xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size)
+{
+ struct map_info *mapInfoP = &(memInfoP->memInfo);
+
+ switch(mapInfoP->method)
+ {
+ case MAP_MMAP:
+ if(memInfoP->regionVirtBase != NULL)
+ {
+ if(mapInfoP->u.map_info_mmap.map_size != MAP_INFO_UNKNOWN)
+ Size = mapInfoP->u.map_info_mmap.map_size;
+ munmap((caddr_t)memInfoP->regionVirtBase, Size);
+ memInfoP->regionVirtBase = NULL;
+ }
+ break;
+ default:
+ FatalError("xf86MapInfoMap: Unsuported mapping method\n");
+ break;
+ }
+}
+
+static pointer
+armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ struct memAccess *memInfoP;
+
+ if((memInfoP = checkMapInfo(FALSE, Region)) != NULL)
+ {
+ /*
+ ** xf86 passes in a physical address offset from the start
+ ** of physical memory, but xf86MapInfoMap expects an
+ ** offset from the start of the specified region - it gets
+ ** the physical address of the region from the display driver.
+ */
+ switch(Region)
+ {
+ case LINEAR_REGION:
+ if (vgaPhysLinearBase)
+ {
+ Base -= vgaPhysLinearBase;
+ }
+ break;
+ case VGA_REGION:
+ Base -= 0xA0000;
+ break;
+ }
+
+ base = xf86MapInfoMap(memInfoP, Base, Size);
+ return (base);
+ }
+ return mapVidMem(ScreenNum, Base, Size, flags);
+}
+
+static void
+armUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ struct memAccess *memInfoP;
+
+ if((memInfoP = checkMapInfo(FALSE, Region)) != NULL)
+ {
+ xf86MapInfoUnmap(memInfoP, Base, Size);
+ }
+ unmapVidMem(ScreenNum, Base, Size);
+}
+
+#ifdef USE_DEV_IO
+static int IoFd = -1;
+
+Bool
+xf86EnableIO()
+{
+ if (IoFd >= 0)
+ return TRUE;
+
+ if ((IoFd = open("/dev/io", O_RDWR)) == -1)
+ {
+ xf86Msg(X_WARNING,"xf86EnableIO: "
+ "Failed to open /dev/io for extended I/O\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ if (IoFd < 0)
+ return;
+
+ close(IoFd);
+ IoFd = -1;
+ return;
+}
+
+#endif
+
+#if defined(USE_ARC_MMAP) || defined(__arm32__)
+
+Bool
+xf86EnableIO()
+{
+ int fd;
+ pointer base;
+
+ if (ExtendedEnabled)
+ return TRUE;
+
+ if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
+ /* Try to map a page at the pccons I/O space */
+ base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0x0000);
+
+ if (base != (pointer)-1) {
+ IOPortBase = base;
+ }
+ else {
+ xf86Msg(X_WARNING,"EnableIO: failed to mmap %s (%s)\n",
+ "/dev/ttyC0", strerror(errno));
+ return FALSE;
+ }
+ }
+ else {
+ xf86Msg("EnableIO: failed to open %s (%s)\n",
+ "/dev/ttyC0", strerror(errno));
+ return FALSE;
+ }
+
+ ExtendedEnabled = TRUE;
+
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ return;
+}
+
+#endif /* USE_ARC_MMAP */
+
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+Bool
+xf86DisableInterrupts()
+{
+
+ return(TRUE);
+}
+
+void
+xf86EnableInterrupts()
+{
+
+ return;
+}
+
+
+
+#if 0
+/*
+ * XXX This is here for reference. It needs to be handled differently for the
+ * ND.
+ */
+#if defined(USE_ARC_MMAP) || defined(__arm32__)
+
+#ifdef USE_ARM32_MMAP
+#define DEV_MEM_IOBASE 0x43000000
+#endif
+
+static Bool ScreenEnabled[MAXSCREENS];
+static Bool ExtendedEnabled = FALSE;
+static Bool InitDone = FALSE;
+
+Bool
+xf86EnableIOPorts(ScreenNum)
+int ScreenNum;
+{
+ int i;
+ int fd;
+ pointer base;
+
+#ifdef __arm32__
+ struct memAccess *memInfoP;
+ int *Size;
+#endif
+
+ ScreenEnabled[ScreenNum] = TRUE;
+
+ if (ExtendedEnabled)
+ return TRUE;
+
+#ifdef USE_ARC_MMAP
+ if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
+ /* Try to map a page at the pccons I/O space */
+ base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0x0000);
+
+ if (base != (pointer)-1) {
+ IOPortBase = base;
+ }
+ else {
+ xf86Msg(X_ERROR,
+ "EnableIOPorts: failed to mmap %s (%s)\n",
+ "/dev/ttyC0", strerror(errno));
+ }
+ }
+ else {
+ xf86Msg(X_ERROR, "EnableIOPorts: failed to open %s (%s)\n",
+ "/dev/ttyC0", strerror(errno));
+ }
+#endif
+
+#ifdef __arm32__
+ IOPortBase = (unsigned int)-1;
+
+ if((memInfoP = checkMapInfo(TRUE, MMIO_REGION)) != NULL)
+ {
+ /*
+ * xf86MapInfoMap maps an offset from the start of video IO
+ * space (e.g. 0x3B0), but IOPortBase is expected to map to
+ * physical address 0x000, so subtract the start of video I/O
+ * space from the result. This is safe for now becase we
+ * actually mmap the start of the page, then the start of video
+ * I/O space is added as an internal offset.
+ */
+ IOPortBase = (unsigned int)xf86MapInfoMap(memInfoP,
+ (caddr_t)0x0, 0L)
+ - memInfoP->memInfo.u.map_info_mmap.internal_offset;
+ ExtendedEnabled = TRUE;
+ return TRUE;
+ }
+#ifdef USE_ARM32_MMAP
+ checkDevMem(TRUE);
+
+ if (devMemFd >= 0 && useDevMem)
+ {
+ base = (pointer)mmap((caddr_t)0, 0x400, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, devMemFd, (off_t)DEV_MEM_IOBASE);
+
+ if (base != (pointer)-1)
+ IOPortBase = (unsigned int)base;
+ }
+
+ if (IOPortBase == (unsigned int)-1)
+ {
+ xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\
+Make sure you have the Aperture Driver installed, or a kernel built with the INSECURE option\n");
+ return FALSE;
+ }
+#else
+ /* We don't have the IOBASE, so we can't map the address */
+ xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\
+Try building the server with USE_ARM32_MMAP defined\n");
+ return FALSE;
+#endif
+#endif
+
+ ExtendedEnabled = TRUE;
+
+ return TRUE;
+}
+
+void
+xf86DisableIOPorts(ScreenNum)
+int ScreenNum;
+{
+ int i;
+#ifdef __arm32__
+ struct memAccess *memInfoP;
+#endif
+
+ ScreenEnabled[ScreenNum] = FALSE;
+
+#ifdef __arm32__
+ if((memInfoP = checkMapInfo(FALSE, MMIO_REGION)) != NULL)
+ {
+ xf86MapInfoUnmap(memInfoP, 0);
+ }
+#endif
+
+#ifdef USE_ARM32_MMAP
+ if (!ExtendedEnabled)
+ return;
+
+ for (i = 0; i < MAXSCREENS; i++)
+ if (ScreenEnabled[i])
+ return;
+
+ munmap((caddr_t)IOPortBase, 0x400);
+ IOPortBase = (unsigned int)-1;
+ ExtendedEnabled = FALSE;
+#endif
+
+ return;
+}
+
+#endif /* USE_ARC_MMAP || USE_ARM32_MMAP */
+#endif
+
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c
new file mode 100644
index 000000000..d38230a83
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c
@@ -0,0 +1,194 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c,v 1.6 2001/02/16 14:45:10 tsi Exp $ */
+
+/* Resource information code */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Privstr.h"
+#include "xf86Pci.h"
+#include "xf86Resources.h"
+#define NEED_OS_RAC_PROTOS
+#include "xf86_OSlib.h"
+
+/* Avoid Imakefile changes */
+#include "bus/Pci.h"
+
+resRange PciAvoid[] = {_PCI_AVOID_PC_STYLE, _END};
+
+#ifdef INCLUDE_XF86_NO_DOMAIN
+
+#if defined(__alpha__) || defined(__sparc64__) || defined(__amd64__)
+
+resPtr
+xf86BusAccWindowsFromOS(void)
+{
+ resPtr ret = NULL;
+ resRange range;
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ return ret;
+}
+
+resPtr
+xf86PciBusAccWindowsFromOS(void)
+{
+ resPtr ret = NULL;
+ resRange range;
+
+ /*
+ * Only allow the upper half of the pci memory range to be used
+ * for allocation. The lower half includes magic regions for DMA.
+ * XXX this is not right for XP1000's and similar where we use the
+ * region 0x40000000-0xbfffffff for DMA but this only matters if
+ * the bios screws up the pci region mappings.
+ */
+ RANGE(range, 0x80000000, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ return ret;
+}
+
+#ifdef INCLUDE_UNUSED
+
+resPtr
+xf86IsaBusAccWindowsFromOS(void)
+{
+ resPtr ret = NULL;
+ resRange range;
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ return ret;
+}
+
+#endif /* INCLUDE_UNUSED */
+
+resPtr
+xf86AccResFromOS(resPtr ret)
+{
+ resRange range;
+
+ /*
+ * Fallback is to claim the following areas:
+ *
+ * 0x000c0000 - 0x000effff location of VGA and other extensions ROMS
+ */
+
+ RANGE(range, 0x000c0000, 0x000effff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ /*
+ * Fallback would be to claim well known ports in the 0x0 - 0x3ff range
+ * along with their sparse I/O aliases, but that's too imprecise. Instead
+ * claim a bare minimum here.
+ */
+ RANGE(range, 0x00000000, 0x000000ff, ResExcIoBlock); /* For mainboard */
+ ret = xf86AddResToList(ret, &range, -1);
+
+ /*
+ * At minimum, the top and bottom resources must be claimed, so that
+ * resources that are (or appear to be) unallocated can be relocated.
+ */
+ RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+/* RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1); */
+ RANGE(range, 0xffffffff, 0xffffffff, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ /* XXX add others */
+ return ret;
+}
+
+#elif defined(__powerpc__)
+
+resPtr
+xf86BusAccWindowsFromOS(void)
+{
+ resPtr ret = NULL;
+ resRange range;
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ return ret;
+}
+
+resPtr
+xf86PciBusAccWindowsFromOS(void)
+{
+ resPtr ret = NULL;
+ resRange range;
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ return ret;
+}
+
+#ifdef INCLUDE_UNUSED
+
+resPtr
+xf86IsaBusAccWindowsFromOS(void)
+{
+ resPtr ret = NULL;
+ resRange range;
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ return ret;
+}
+
+#endif /* INCLUDE_UNUSED */
+
+resPtr
+xf86AccResFromOS(resPtr ret)
+{
+ resRange range;
+
+ /*
+ * At minimum, the top and bottom resources must be claimed, so that
+ * resources that are (or appear to be) unallocated can be relocated.
+ */
+ RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x0000ffff, 0x0000ffff, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ return ret;
+}
+
+#else
+
+#error : Put your platform dependent code here!!
+
+#endif
+
+#endif /* INCLUDE_XF86_NO_DOMAIN */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_KbdMap.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_KbdMap.c
new file mode 100644
index 000000000..d225c1f38
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_KbdMap.c
@@ -0,0 +1,1087 @@
+/* $XFree86$ */
+
+/*
+ * Slightly modified xf86KbdBSD.c which is
+ *
+ * Derived from xf86Kbd.c by S_ren Schmidt (sos@login.dkuug.dk)
+ * which is Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ * and from xf86KbdCODrv.c by Holger Veit
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86Xinput.h"
+#include "xf86OSKbd.h"
+#include "atKeynames.h"
+#include "xf86Keymap.h"
+#include "bsd_kbd.h"
+
+#if (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)) && defined(GIO_KEYMAP)
+#define KD_GET_ENTRY(i,n) \
+ eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]]
+
+static unsigned char remap[NUM_KEYCODES] = {
+ 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0, /* 0x30 - 0x37 */
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38 - 0x3f */
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0, /* 0x40 - 0x47 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */
+ 0, 0, 0, 0, 0, 0, 0x56, 0x57, /* 0x50 - 0x57 */
+ 0x58, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x67 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68 - 0x6f */
+ 0, 0, 0x69, 0x65, 0, 0, 0, 0, /* 0x70 - 0x77 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */
+};
+
+/* This table assumes the ibm code page 437 coding for characters
+ * > 0x80. They are returned in this form by PCVT */
+static KeySym eascii_to_x[512] = {
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, XK_Return, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Escape,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
+ XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
+ XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
+ XK_comma, XK_minus, XK_period, XK_slash,
+ XK_0, XK_1, XK_2, XK_3,
+ XK_4, XK_5, XK_6, XK_7,
+ XK_8, XK_9, XK_colon, XK_semicolon,
+ XK_less, XK_equal, XK_greater, XK_question,
+ XK_at, XK_A, XK_B, XK_C,
+ XK_D, XK_E, XK_F, XK_G,
+ XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O,
+ XK_P, XK_Q, XK_R, XK_S,
+ XK_T, XK_U, XK_V, XK_W,
+ XK_X, XK_Y, XK_Z, XK_bracketleft,
+ XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
+ XK_grave, XK_a, XK_b, XK_c,
+ XK_d, XK_e, XK_f, XK_g,
+ XK_h, XK_i, XK_j, XK_k,
+ XK_l, XK_m, XK_n, XK_o,
+ XK_p, XK_q, XK_r, XK_s,
+ XK_t, XK_u, XK_v, XK_w,
+ XK_x, XK_y, XK_z, XK_braceleft,
+ XK_bar, XK_braceright, XK_asciitilde, XK_Delete,
+ XK_Ccedilla, XK_udiaeresis, XK_eacute, XK_acircumflex,
+ XK_adiaeresis, XK_agrave, XK_aring, XK_ccedilla,
+ XK_ecircumflex, XK_ediaeresis, XK_egrave, XK_idiaeresis,
+ XK_icircumflex, XK_igrave, XK_Adiaeresis, XK_Aring,
+ XK_Eacute, XK_ae, XK_AE, XK_ocircumflex,
+ XK_odiaeresis, XK_ograve, XK_ucircumflex, XK_ugrave,
+ XK_ydiaeresis, XK_Odiaeresis, XK_Udiaeresis, XK_cent,
+ XK_sterling, XK_yen, XK_paragraph, XK_section,
+ XK_aacute, XK_iacute, XK_oacute, XK_uacute,
+ XK_ntilde, XK_Ntilde, XK_ordfeminine, XK_masculine,
+ XK_questiondown,XK_hyphen, XK_notsign, XK_onehalf,
+ XK_onequarter, XK_exclamdown, XK_guillemotleft,XK_guillemotright,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_Greek_alpha, XK_ssharp, XK_Greek_GAMMA, XK_Greek_pi,
+ XK_Greek_SIGMA, XK_Greek_sigma, XK_mu, XK_Greek_tau,
+ XK_Greek_PHI, XK_Greek_THETA, XK_Greek_OMEGA, XK_Greek_delta,
+ XK_infinity, XK_Ooblique, XK_Greek_epsilon, XK_intersection,
+ XK_identical, XK_plusminus, XK_greaterthanequal, XK_lessthanequal,
+ XK_topintegral, XK_botintegral, XK_division, XK_similarequal,
+ XK_degree, NoSymbol, NoSymbol, XK_radical,
+ XK_Greek_eta, XK_twosuperior, XK_periodcentered, NoSymbol,
+
+ /*
+ * special marked entries (256 + x)
+ */
+
+ /* This has been checked against what syscons actually does */
+ NoSymbol, NoSymbol, XK_Shift_L, XK_Shift_R,
+ XK_Caps_Lock, XK_Num_Lock, XK_Scroll_Lock, XK_Alt_L,
+ XK_ISO_Left_Tab,XK_Control_L, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_F1,
+ XK_F2, XK_F3, XK_F4, XK_F5,
+ XK_F6, XK_F7, XK_F8, XK_F9,
+ XK_F10, XK_F11, XK_F12, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_Control_R, XK_Alt_R, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol
+};
+
+#ifdef __OpenBSD__
+/* don't mark AltR and CtrlR for remapping, since they
+ * cannot be remapped by pccons */
+static unsigned char pccons_remap[128] = {
+ 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0, /* 0x30 - 0x37 */
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38 - 0x3f */
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0, /* 0x40 - 0x47 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */
+ 0, 0, 0, 0, 0, 0, 0x56, 0x57, /* 0x50 - 0x57 */
+ 0x58, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x67 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68 - 0x6f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 - 0x77 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */
+};
+
+/* This table assumes an iso8859_1 encoding for the characters
+ * > 80, as returned by pccons */
+static KeySym latin1_to_x[256] = {
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, XK_Return, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Escape,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
+ XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
+ XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
+ XK_comma, XK_minus, XK_period, XK_slash,
+ XK_0, XK_1, XK_2, XK_3,
+ XK_4, XK_5, XK_6, XK_7,
+ XK_8, XK_9, XK_colon, XK_semicolon,
+ XK_less, XK_equal, XK_greater, XK_question,
+ XK_at, XK_A, XK_B, XK_C,
+ XK_D, XK_E, XK_F, XK_G,
+ XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O,
+ XK_P, XK_Q, XK_R, XK_S,
+ XK_T, XK_U, XK_V, XK_W,
+ XK_X, XK_Y, XK_Z, XK_bracketleft,
+ XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
+ XK_grave, XK_a, XK_b, XK_c,
+ XK_d, XK_e, XK_f, XK_g,
+ XK_h, XK_i, XK_j, XK_k,
+ XK_l, XK_m, XK_n, XK_o,
+ XK_p, XK_q, XK_r, XK_s,
+ XK_t, XK_u, XK_v, XK_w,
+ XK_x, XK_y, XK_z, XK_braceleft,
+ XK_bar, XK_braceright, XK_asciitilde, XK_Delete,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_nobreakspace,XK_exclamdown, XK_cent, XK_sterling,
+ XK_currency, XK_yen, XK_brokenbar, XK_section,
+ XK_diaeresis, XK_copyright, XK_ordfeminine, XK_guillemotleft,
+ XK_notsign, XK_hyphen, XK_registered, XK_macron,
+ XK_degree, XK_plusminus, XK_twosuperior, XK_threesuperior,
+ XK_acute, XK_mu, XK_paragraph, XK_periodcentered,
+ XK_cedilla, XK_onesuperior, XK_masculine, XK_guillemotright,
+ XK_onequarter, XK_onehalf, XK_threequarters,XK_questiondown,
+ XK_Agrave, XK_Aacute, XK_Acircumflex, XK_Atilde,
+ XK_Adiaeresis, XK_Aring, XK_AE, XK_Ccedilla,
+ XK_Egrave, XK_Eacute, XK_Ecircumflex, XK_Ediaeresis,
+ XK_Igrave, XK_Iacute, XK_Icircumflex, XK_Idiaeresis,
+ XK_ETH, XK_Ntilde, XK_Ograve, XK_Oacute,
+ XK_Ocircumflex, XK_Otilde, XK_Odiaeresis, XK_multiply,
+ XK_Ooblique, XK_Ugrave, XK_Uacute, XK_Ucircumflex,
+ XK_Udiaeresis, XK_Yacute, XK_THORN, XK_ssharp,
+ XK_agrave, XK_aacute, XK_acircumflex, XK_atilde,
+ XK_adiaeresis, XK_aring, XK_ae, XK_ccedilla,
+ XK_egrave, XK_eacute, XK_ecircumflex, XK_ediaeresis,
+ XK_igrave, XK_iacute, XK_icircumflex, XK_idiaeresis,
+ XK_eth, XK_ntilde, XK_ograve, XK_oacute,
+ XK_ocircumflex, XK_otilde, XK_odiaeresis, XK_division,
+ XK_oslash, XK_ugrave, XK_uacute, XK_ucircumflex,
+ XK_udiaeresis, XK_yacute, XK_thorn, XK_ydiaeresis
+ };
+#endif
+
+#ifdef SYSCONS_SUPPORT
+static
+unsigned char sysconsCODEMap[] = {
+ KEY_KP_Enter, KEY_RCtrl, KEY_KP_Divide, KEY_Print,
+ KEY_AltLang, KEY_KP_7, KEY_KP_8, KEY_KP_9,
+ KEY_KP_4, KEY_KP_6, KEY_KP_1, KEY_KP_2,
+ KEY_KP_3, KEY_KP_0, KEY_KP_Decimal, KEY_Pause,
+ KEY_LMeta, KEY_RMeta, KEY_Menu, KEY_Break
+};
+static
+TransMapRec sysconsCODE = {
+ 0x59,
+ 0x6d,
+ sysconsCODEMap
+};
+#endif
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+
+#ifdef WSCONS_SUPPORT
+
+static CARD8 wsUsbMap[] = {
+ /* 0 */ KEY_NOTUSED,
+ /* 1 */ KEY_NOTUSED,
+ /* 2 */ KEY_NOTUSED,
+ /* 3 */ KEY_NOTUSED,
+ /* 4 */ KEY_A,
+ /* 5 */ KEY_B,
+ /* 6 */ KEY_C,
+ /* 7 */ KEY_D,
+ /* 8 */ KEY_E,
+ /* 9 */ KEY_F,
+ /* 10 */ KEY_G,
+ /* 11 */ KEY_H,
+ /* 12 */ KEY_I,
+ /* 13 */ KEY_J,
+ /* 14 */ KEY_K,
+ /* 15 */ KEY_L,
+ /* 16 */ KEY_M,
+ /* 17 */ KEY_N,
+ /* 18 */ KEY_O,
+ /* 19 */ KEY_P,
+ /* 20 */ KEY_Q,
+ /* 21 */ KEY_R,
+ /* 22 */ KEY_S,
+ /* 23 */ KEY_T,
+ /* 24 */ KEY_U,
+ /* 25 */ KEY_V,
+ /* 26 */ KEY_W,
+ /* 27 */ KEY_X,
+ /* 28 */ KEY_Y,
+ /* 29 */ KEY_Z,
+ /* 30 */ KEY_1, /* 1 !*/
+ /* 31 */ KEY_2, /* 2 @ */
+ /* 32 */ KEY_3, /* 3 # */
+ /* 33 */ KEY_4, /* 4 $ */
+ /* 34 */ KEY_5, /* 5 % */
+ /* 35 */ KEY_6, /* 6 ^ */
+ /* 36 */ KEY_7, /* 7 & */
+ /* 37 */ KEY_8, /* 8 * */
+ /* 38 */ KEY_9, /* 9 ( */
+ /* 39 */ KEY_0, /* 0 ) */
+ /* 40 */ KEY_Enter, /* Return */
+ /* 41 */ KEY_Escape, /* Escape */
+ /* 42 */ KEY_BackSpace, /* Backspace Delete */
+ /* 43 */ KEY_Tab, /* Tab */
+ /* 44 */ KEY_Space, /* Space */
+ /* 45 */ KEY_Minus, /* - _ */
+ /* 46 */ KEY_Equal, /* = + */
+ /* 47 */ KEY_LBrace, /* [ { */
+ /* 48 */ KEY_RBrace, /* ] } */
+ /* 49 */ KEY_BSlash, /* \ | */
+ /* 50 */ KEY_BSlash2, /* \ _ # ~ on some keyboards */
+ /* 51 */ KEY_SemiColon, /* ; : */
+ /* 52 */ KEY_Quote, /* ' " */
+ /* 53 */ KEY_Tilde, /* ` ~ */
+ /* 54 */ KEY_Comma, /* , < */
+ /* 55 */ KEY_Period, /* . > */
+ /* 56 */ KEY_Slash, /* / ? */
+ /* 57 */ KEY_CapsLock, /* Caps Lock */
+ /* 58 */ KEY_F1, /* F1 */
+ /* 59 */ KEY_F2, /* F2 */
+ /* 60 */ KEY_F3, /* F3 */
+ /* 61 */ KEY_F4, /* F4 */
+ /* 62 */ KEY_F5, /* F5 */
+ /* 63 */ KEY_F6, /* F6 */
+ /* 64 */ KEY_F7, /* F7 */
+ /* 65 */ KEY_F8, /* F8 */
+ /* 66 */ KEY_F9, /* F9 */
+ /* 67 */ KEY_F10, /* F10 */
+ /* 68 */ KEY_F11, /* F11 */
+ /* 69 */ KEY_F12, /* F12 */
+ /* 70 */ KEY_Print, /* PrintScrn SysReq */
+ /* 71 */ KEY_ScrollLock, /* Scroll Lock */
+ /* 72 */ KEY_Pause, /* Pause Break */
+ /* 73 */ KEY_Insert, /* Insert XXX Help on some Mac Keyboards */
+ /* 74 */ KEY_Home, /* Home */
+ /* 75 */ KEY_PgUp, /* Page Up */
+ /* 76 */ KEY_Delete, /* Delete */
+ /* 77 */ KEY_End, /* End */
+ /* 78 */ KEY_PgDown, /* Page Down */
+ /* 79 */ KEY_Right, /* Right Arrow */
+ /* 80 */ KEY_Left, /* Left Arrow */
+ /* 81 */ KEY_Down, /* Down Arrow */
+ /* 82 */ KEY_Up, /* Up Arrow */
+ /* 83 */ KEY_NumLock, /* Num Lock */
+ /* 84 */ KEY_KP_Divide, /* Keypad / */
+ /* 85 */ KEY_KP_Multiply, /* Keypad * */
+ /* 86 */ KEY_KP_Minus, /* Keypad - */
+ /* 87 */ KEY_KP_Plus, /* Keypad + */
+ /* 88 */ KEY_KP_Enter, /* Keypad Enter */
+ /* 89 */ KEY_KP_1, /* Keypad 1 End */
+ /* 90 */ KEY_KP_2, /* Keypad 2 Down */
+ /* 91 */ KEY_KP_3, /* Keypad 3 Pg Down */
+ /* 92 */ KEY_KP_4, /* Keypad 4 Left */
+ /* 93 */ KEY_KP_5, /* Keypad 5 */
+ /* 94 */ KEY_KP_6, /* Keypad 6 */
+ /* 95 */ KEY_KP_7, /* Keypad 7 Home */
+ /* 96 */ KEY_KP_8, /* Keypad 8 Up */
+ /* 97 */ KEY_KP_9, /* KEypad 9 Pg Up */
+ /* 98 */ KEY_KP_0, /* Keypad 0 Ins */
+ /* 99 */ KEY_KP_Decimal, /* Keypad . Del */
+ /* 100 */ KEY_Less, /* < > on some keyboards */
+ /* 101 */ KEY_Menu, /* Menu */
+ /* 102 */ KEY_NOTUSED,
+ /* 103 */ KEY_KP_Equal, /* Keypad = on Mac keyboards */
+ /* 104 */ KEY_NOTUSED,
+ /* 105 */ KEY_NOTUSED,
+ /* 106 */ KEY_NOTUSED,
+ /* 107 */ KEY_NOTUSED,
+ /* 108 */ KEY_NOTUSED,
+ /* 109 */ KEY_NOTUSED,
+ /* 110 */ KEY_NOTUSED,
+ /* 111 */ KEY_NOTUSED,
+ /* 112 */ KEY_NOTUSED,
+ /* 113 */ KEY_NOTUSED,
+ /* 114 */ KEY_NOTUSED,
+ /* 115 */ KEY_NOTUSED,
+ /* 116 */ KEY_NOTUSED,
+ /* 117 */ KEY_NOTUSED,
+ /* 118 */ KEY_NOTUSED,
+ /* 119 */ KEY_NOTUSED,
+ /* 120 */ KEY_NOTUSED,
+ /* 121 */ KEY_NOTUSED,
+ /* 122 */ KEY_NOTUSED,
+ /* 123 */ KEY_NOTUSED,
+ /* 124 */ KEY_NOTUSED,
+ /* 125 */ KEY_NOTUSED,
+ /* 126 */ KEY_NOTUSED,
+ /* 127 */ KEY_NOTUSED,
+ /* 128 */ KEY_NOTUSED,
+ /* 129 */ KEY_NOTUSED,
+ /* 130 */ KEY_NOTUSED,
+ /* 131 */ KEY_NOTUSED,
+ /* 132 */ KEY_NOTUSED,
+ /* 133 */ KEY_NOTUSED,
+ /* 134 */ KEY_NOTUSED,
+ /* 135 */ KEY_NOTUSED,
+ /* 136 */ KEY_NOTUSED,
+ /* 137 */ KEY_NOTUSED,
+ /* 138 */ KEY_NOTUSED,
+ /* 139 */ KEY_NOTUSED,
+ /* 140 */ KEY_NOTUSED,
+ /* 141 */ KEY_NOTUSED,
+ /* 142 */ KEY_NOTUSED,
+ /* 143 */ KEY_NOTUSED,
+ /* 144 */ KEY_NOTUSED,
+ /* 145 */ KEY_NOTUSED,
+ /* 146 */ KEY_NOTUSED,
+ /* 147 */ KEY_NOTUSED,
+ /* 148 */ KEY_NOTUSED,
+ /* 149 */ KEY_NOTUSED,
+ /* 150 */ KEY_NOTUSED,
+ /* 151 */ KEY_NOTUSED,
+ /* 152 */ KEY_NOTUSED,
+ /* 153 */ KEY_NOTUSED,
+ /* 154 */ KEY_NOTUSED,
+ /* 155 */ KEY_NOTUSED,
+ /* 156 */ KEY_NOTUSED,
+ /* 157 */ KEY_NOTUSED,
+ /* 158 */ KEY_NOTUSED,
+ /* 159 */ KEY_NOTUSED,
+ /* 160 */ KEY_NOTUSED,
+ /* 161 */ KEY_NOTUSED,
+ /* 162 */ KEY_NOTUSED,
+ /* 163 */ KEY_NOTUSED,
+ /* 164 */ KEY_NOTUSED,
+ /* 165 */ KEY_NOTUSED,
+ /* 166 */ KEY_NOTUSED,
+ /* 167 */ KEY_NOTUSED,
+ /* 168 */ KEY_NOTUSED,
+ /* 169 */ KEY_NOTUSED,
+ /* 170 */ KEY_NOTUSED,
+ /* 171 */ KEY_NOTUSED,
+ /* 172 */ KEY_NOTUSED,
+ /* 173 */ KEY_NOTUSED,
+ /* 174 */ KEY_NOTUSED,
+ /* 175 */ KEY_NOTUSED,
+ /* 176 */ KEY_NOTUSED,
+ /* 177 */ KEY_NOTUSED,
+ /* 178 */ KEY_NOTUSED,
+ /* 179 */ KEY_NOTUSED,
+ /* 180 */ KEY_NOTUSED,
+ /* 181 */ KEY_NOTUSED,
+ /* 182 */ KEY_NOTUSED,
+ /* 183 */ KEY_NOTUSED,
+ /* 184 */ KEY_NOTUSED,
+ /* 185 */ KEY_NOTUSED,
+ /* 186 */ KEY_NOTUSED,
+ /* 187 */ KEY_NOTUSED,
+ /* 188 */ KEY_NOTUSED,
+ /* 189 */ KEY_NOTUSED,
+ /* 190 */ KEY_NOTUSED,
+ /* 191 */ KEY_NOTUSED,
+ /* 192 */ KEY_NOTUSED,
+ /* 193 */ KEY_NOTUSED,
+ /* 194 */ KEY_NOTUSED,
+ /* 195 */ KEY_NOTUSED,
+ /* 196 */ KEY_NOTUSED,
+ /* 197 */ KEY_NOTUSED,
+ /* 198 */ KEY_NOTUSED,
+ /* 199 */ KEY_NOTUSED,
+ /* 200 */ KEY_NOTUSED,
+ /* 201 */ KEY_NOTUSED,
+ /* 202 */ KEY_NOTUSED,
+ /* 203 */ KEY_NOTUSED,
+ /* 204 */ KEY_NOTUSED,
+ /* 205 */ KEY_NOTUSED,
+ /* 206 */ KEY_NOTUSED,
+ /* 207 */ KEY_NOTUSED,
+ /* 208 */ KEY_NOTUSED,
+ /* 209 */ KEY_NOTUSED,
+ /* 210 */ KEY_NOTUSED,
+ /* 211 */ KEY_NOTUSED,
+ /* 212 */ KEY_NOTUSED,
+ /* 213 */ KEY_NOTUSED,
+ /* 214 */ KEY_NOTUSED,
+ /* 215 */ KEY_NOTUSED,
+ /* 216 */ KEY_NOTUSED,
+ /* 217 */ KEY_NOTUSED,
+ /* 218 */ KEY_NOTUSED,
+ /* 219 */ KEY_NOTUSED,
+ /* 220 */ KEY_NOTUSED,
+ /* 221 */ KEY_NOTUSED,
+ /* 222 */ KEY_NOTUSED,
+ /* 223 */ KEY_NOTUSED,
+ /* 224 */ KEY_LCtrl, /* Left Control */
+ /* 225 */ KEY_ShiftL, /* Left Shift */
+ /* 226 */ KEY_Alt, /* Left Alt */
+ /* 227 */ KEY_LMeta, /* Left Meta */
+ /* 228 */ KEY_RCtrl, /* Right Control */
+ /* 229 */ KEY_ShiftR, /* Right Shift */
+ /* 230 */ KEY_AltLang, /* Right Alt, AKA AltGr */
+ /* 231 */ KEY_LMeta, /* Right Meta XXX */
+};
+#define WS_USB_MAP_SIZE (sizeof(wsUsbMap)/sizeof(unsigned char))
+
+static
+TransMapRec wsUsb = {
+ 0,
+ WS_USB_MAP_SIZE,
+ wsUsbMap
+};
+
+/* Map for adb keyboards */
+static CARD8 wsAdbMap[] = {
+ /* 0 */ KEY_A,
+ /* 1 */ KEY_S,
+ /* 2 */ KEY_D,
+ /* 3 */ KEY_F,
+ /* 4 */ KEY_H,
+ /* 5 */ KEY_G,
+ /* 6 */ KEY_Z,
+ /* 7 */ KEY_X,
+ /* 8 */ KEY_C,
+ /* 9 */ KEY_V,
+ /* 10 */ KEY_UNKNOWN, /* @ # on french keyboards */
+ /* 11 */ KEY_B,
+ /* 12 */ KEY_Q,
+ /* 13 */ KEY_W,
+ /* 14 */ KEY_E,
+ /* 15 */ KEY_R,
+ /* 16 */ KEY_Y,
+ /* 17 */ KEY_T,
+ /* 18 */ KEY_1,
+ /* 19 */ KEY_2,
+ /* 20 */ KEY_3,
+ /* 21 */ KEY_4,
+ /* 22 */ KEY_6,
+ /* 23 */ KEY_5,
+ /* 24 */ KEY_Equal,
+ /* 25 */ KEY_9,
+ /* 26 */ KEY_7,
+ /* 27 */ KEY_Minus,
+ /* 28 */ KEY_8,
+ /* 29 */ KEY_0,
+ /* 30 */ KEY_RBrace,
+ /* 31 */ KEY_O,
+ /* 32 */ KEY_U,
+ /* 33 */ KEY_LBrace,
+ /* 34 */ KEY_I,
+ /* 35 */ KEY_P,
+ /* 36 */ KEY_Enter,
+ /* 37 */ KEY_L,
+ /* 38 */ KEY_J,
+ /* 39 */ KEY_Quote,
+ /* 40 */ KEY_K,
+ /* 41 */ KEY_SemiColon,
+ /* 42 */ KEY_BSlash,
+ /* 43 */ KEY_Comma,
+ /* 44 */ KEY_Slash,
+ /* 45 */ KEY_N,
+ /* 46 */ KEY_M,
+ /* 47 */ KEY_Period,
+ /* 48 */ KEY_Tab,
+ /* 49 */ KEY_Space,
+ /* 50 */ KEY_Tilde,
+ /* 51 */ KEY_Delete,
+ /* 52 */ KEY_AltLang,
+ /* 53 */ KEY_Escape,
+ /* 54 */ KEY_LCtrl,
+ /* 55 */ KEY_Alt,
+ /* 56 */ KEY_ShiftL,
+ /* 57 */ KEY_CapsLock,
+ /* 58 */ KEY_LMeta,
+ /* 59 */ KEY_Left,
+ /* 60 */ KEY_Right,
+ /* 61 */ KEY_Down,
+ /* 62 */ KEY_Up,
+ /* 63 */ KEY_UNKNOWN, /* Fn */
+ /* 64 */ KEY_NOTUSED,
+ /* 65 */ KEY_KP_Decimal,
+ /* 66 */ KEY_NOTUSED,
+ /* 67 */ KEY_KP_Multiply,
+ /* 68 */ KEY_NOTUSED,
+ /* 69 */ KEY_KP_Plus,
+ /* 70 */ KEY_NOTUSED,
+ /* 71 */ KEY_UNKNOWN, /* Clear */
+ /* 72 */ KEY_NOTUSED,
+ /* 73 */ KEY_NOTUSED,
+ /* 74 */ KEY_NOTUSED,
+ /* 75 */ KEY_KP_Divide,
+ /* 76 */ KEY_KP_Enter,
+ /* 77 */ KEY_NOTUSED,
+ /* 78 */ KEY_KP_Minus,
+ /* 79 */ KEY_NOTUSED,
+ /* 80 */ KEY_NOTUSED,
+ /* 81 */ KEY_KP_Equal, /* Keypad = */
+ /* 82 */ KEY_KP_0,
+ /* 83 */ KEY_KP_1,
+ /* 84 */ KEY_KP_2,
+ /* 85 */ KEY_KP_3,
+ /* 86 */ KEY_KP_4,
+ /* 87 */ KEY_KP_5,
+ /* 88 */ KEY_KP_6,
+ /* 89 */ KEY_KP_7,
+ /* 90 */ KEY_NOTUSED,
+ /* 91 */ KEY_KP_8,
+ /* 92 */ KEY_KP_9,
+ /* 93 */ KEY_NOTUSED,
+ /* 94 */ KEY_NOTUSED,
+ /* 95 */ KEY_UNKNOWN, /* Keypad , */
+ /* 96 */ KEY_F5,
+ /* 97 */ KEY_F6,
+ /* 98 */ KEY_F7,
+ /* 99 */ KEY_F3,
+ /* 100 */ KEY_F8,
+ /* 101 */ KEY_F9,
+ /* 102 */ KEY_NOTUSED,
+ /* 103 */ KEY_F11,
+ /* 104 */ KEY_NOTUSED,
+ /* 105 */ KEY_NOTUSED,
+ /* 106 */ KEY_KP_Enter,
+ /* 107 */ KEY_NOTUSED,
+ /* 108 */ KEY_NOTUSED,
+ /* 109 */ KEY_F10,
+ /* 110 */ KEY_NOTUSED,
+ /* 111 */ KEY_F12,
+ /* 112 */ KEY_NOTUSED,
+ /* 113 */ KEY_NOTUSED,
+ /* 114 */ KEY_NOTUSED,
+ /* 115 */ KEY_Home,
+ /* 116 */ KEY_PgUp,
+ /* 117 */ KEY_NOTUSED,
+ /* 118 */ KEY_F4,
+ /* 119 */ KEY_End,
+ /* 120 */ KEY_F2,
+ /* 121 */ KEY_PgDown,
+ /* 122 */ KEY_F1
+};
+#define WS_ADB_MAP_SIZE (sizeof(wsAdbMap)/sizeof(unsigned char))
+
+static
+TransMapRec wsAdb = {
+ 0,
+ WS_ADB_MAP_SIZE,
+ wsAdbMap
+};
+
+static CARD8 wsSunMap[] = {
+ /* 0x00 */ KEY_Help,
+ /* 0x01 */ KEY_L1, /* stop */
+ /* 0x02 */ KEY_AudioLower, /* BrightnessDown / S-VolumeDown */
+ /* 0x03 */ KEY_L2, /* again */
+ /* 0x04 */ KEY_AudioRaise, /* BridgtnessUp / S-VolumeUp */
+ /* 0x05 */ KEY_F1,
+ /* 0x06 */ KEY_F2,
+ /* 0x07 */ KEY_F10,
+ /* 0x08 */ KEY_F3,
+ /* 0x09 */ KEY_F11,
+ /* 0x0a */ KEY_F4,
+ /* 0x0b */ KEY_F12,
+ /* 0x0c */ KEY_F5,
+ /* 0x0d */ KEY_AltLang,
+ /* 0x0e */ KEY_F6,
+ /* 0x0f */ KEY_NOTUSED,
+ /* 0x10 */ KEY_F7,
+ /* 0x11 */ KEY_F8,
+ /* 0x12 */ KEY_F9,
+ /* 0x13 */ KEY_Alt,
+ /* 0x14 */ KEY_Up,
+ /* 0x15 */ KEY_Pause,
+ /* 0x16 */ KEY_Print,
+ /* 0x17 */ KEY_ScrollLock,
+ /* 0x18 */ KEY_Left,
+ /* 0x19 */ KEY_L3, /* props */
+ /* 0x1a */ KEY_L4, /* undo */
+ /* 0x1b */ KEY_Down,
+ /* 0x1c */ KEY_Right,
+ /* 0x1d */ KEY_Escape,
+ /* 0x1e */ KEY_1,
+ /* 0x1f */ KEY_2,
+ /* 0x20 */ KEY_3,
+ /* 0x21 */ KEY_4,
+ /* 0x22 */ KEY_5,
+ /* 0x23 */ KEY_6,
+ /* 0x24 */ KEY_7,
+ /* 0x25 */ KEY_8,
+ /* 0x26 */ KEY_9,
+ /* 0x27 */ KEY_0,
+ /* 0x28 */ KEY_Minus,
+ /* 0x29 */ KEY_Equal,
+ /* 0x2a */ KEY_Tilde,
+ /* 0x2b */ KEY_BackSpace,
+ /* 0x2c */ KEY_Insert,
+ /* 0x2d */ KEY_Mute, /* Audio Mute */
+ /* 0x2e */ KEY_KP_Divide,
+ /* 0x2f */ KEY_KP_Multiply,
+ /* 0x30 */ KEY_NOTUSED,
+ /* 0x31 */ KEY_L5, /* front */
+ /* 0x32 */ KEY_KP_Decimal,
+ /* 0x33 */ KEY_L6, /* copy */
+ /* 0x34 */ KEY_Home,
+ /* 0x35 */ KEY_Tab,
+ /* 0x36 */ KEY_Q,
+ /* 0x37 */ KEY_W,
+ /* 0x38 */ KEY_E,
+ /* 0x39 */ KEY_R,
+ /* 0x3a */ KEY_T,
+ /* 0x3b */ KEY_Y,
+ /* 0x3c */ KEY_U,
+ /* 0x3d */ KEY_I,
+ /* 0x3e */ KEY_O,
+ /* 0x3f */ KEY_P,
+ /* 0x40 */ KEY_LBrace,
+ /* 0x41 */ KEY_RBrace,
+ /* 0x42 */ KEY_Delete,
+ /* 0x43 */ KEY_Menu, /* compose */
+ /* 0x44 */ KEY_KP_7,
+ /* 0x45 */ KEY_KP_8,
+ /* 0x46 */ KEY_KP_9,
+ /* 0x47 */ KEY_KP_Minus,
+ /* 0x48 */ KEY_L7, /* open */
+ /* 0x49 */ KEY_L8, /* paste */
+ /* 0x4a */ KEY_End,
+ /* 0x4b */ KEY_NOTUSED,
+ /* 0x4c */ KEY_LCtrl,
+ /* 0x4d */ KEY_A,
+ /* 0x4e */ KEY_S,
+ /* 0x4f */ KEY_D,
+ /* 0x50 */ KEY_F,
+ /* 0x51 */ KEY_G,
+ /* 0x52 */ KEY_H,
+ /* 0x53 */ KEY_J,
+ /* 0x54 */ KEY_K,
+ /* 0x55 */ KEY_L,
+ /* 0x56 */ KEY_SemiColon,
+ /* 0x57 */ KEY_Quote,
+ /* 0x58 */ KEY_BSlash,
+ /* 0x59 */ KEY_Enter,
+ /* 0x5a */ KEY_KP_Enter,
+ /* 0x5b */ KEY_KP_4,
+ /* 0x5c */ KEY_KP_5,
+ /* 0x5d */ KEY_KP_6,
+ /* 0x5e */ KEY_KP_0,
+ /* 0x5f */ KEY_L9, /* find */
+ /* 0x60 */ KEY_PgUp,
+ /* 0x61 */ KEY_L10, /* cut */
+ /* 0x62 */ KEY_NumLock,
+ /* 0x63 */ KEY_ShiftL,
+ /* 0x64 */ KEY_Z,
+ /* 0x65 */ KEY_X,
+ /* 0x66 */ KEY_C,
+ /* 0x67 */ KEY_V,
+ /* 0x68 */ KEY_B,
+ /* 0x69 */ KEY_N,
+ /* 0x6a */ KEY_M,
+ /* 0x6b */ KEY_Comma,
+ /* 0x6c */ KEY_Period,
+ /* 0x6d */ KEY_Slash,
+ /* 0x6e */ KEY_ShiftR,
+ /* 0x6f */ KEY_NOTUSED, /* linefeed */
+ /* 0x70 */ KEY_KP_1,
+ /* 0x71 */ KEY_KP_2,
+ /* 0x72 */ KEY_KP_3,
+ /* 0x73 */ KEY_NOTUSED,
+ /* 0x74 */ KEY_NOTUSED,
+ /* 0x75 */ KEY_NOTUSED,
+ /* 0x76 */ KEY_NOTUSED, /* help */
+ /* 0x77 */ KEY_CapsLock,
+ /* 0x78 */ KEY_LMeta,
+ /* 0x79 */ KEY_Space,
+ /* 0x7a */ KEY_RMeta,
+ /* 0x7b */ KEY_PgDown,
+ /* 0x7c */ KEY_Less, /* < > on some keyboards */
+ /* 0x7d */ KEY_KP_Plus,
+ /* 0x7e */ KEY_NOTUSED,
+ /* 0x7f */ KEY_NOTUSED
+};
+#define WS_SUN_MAP_SIZE (sizeof(wsSunMap)/sizeof(unsigned char))
+
+static
+TransMapRec wsSun = {
+ 0,
+ WS_SUN_MAP_SIZE,
+ wsSunMap
+};
+
+#endif /* WSCONS_SUPPORT */
+
+/*ARGSUSED*/
+
+/*
+ * KbdGetMapping --
+ * Get the national keyboard mapping. The keyboard type is set, a new map
+ * and the modifiermap is computed.
+ */
+
+void
+KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ KeySym *k;
+ int i;
+
+#ifndef __bsdi__
+ switch (pKbd->consType) {
+
+#ifdef PCCONS_SUPPORT
+ case PCCONS:
+#if defined(__OpenBSD__)
+ /*
+ * on OpenBSD, the pccons keymap is programmable, too
+ */
+ {
+ pccons_keymap_t keymap[KB_NUM_KEYS];
+ if (ioctl(pInfo->fd, CONSOLE_GET_KEYMAP, &keymap) != -1) {
+ for (i = 0; i < KB_NUM_KEYS; i++)
+ if (pccons_remap[i]) {
+ k = map + (pccons_remap[i] << 2);
+ switch (keymap[i].type) {
+ case KB_ASCII:
+ /* For ASCII keys, there is only one char in the keymap */
+ k[0] = latin1_to_x[(unsigned char)keymap[i].unshift[0]];
+ k[1] = latin1_to_x[(unsigned char)keymap[i].shift[0]];
+ k[2] = latin1_to_x[(unsigned char)keymap[i].altgr[0]];
+ k[3] = latin1_to_x[(unsigned char)keymap[i].shift_altgr[0]];
+ break;
+ case KB_SCROLL:
+ k[0] = XK_Scroll_Lock;
+ goto special;
+ case KB_NUM:
+ k[0] = XK_Num_Lock;
+ goto special;
+ case KB_CAPS:
+ k[0] = XK_Caps_Lock;
+ goto special;
+ case KB_SHIFT:
+ switch (keymap[i].unshift[0]) {
+ case 1:
+ /* left shift */
+ k[0] = XK_Shift_L;
+ break;
+ case 2:
+ /* right shift */
+ k[0] = XK_Shift_R;
+ break;
+ default:
+ k[0] = NoSymbol;
+ }
+ goto special;
+ case KB_CTL:
+ k[0] = XK_Control_L;
+ goto special;
+ case KB_ALT:
+ k[0] = XK_Alt_L;
+ goto special;
+ case KB_FUNC:
+ switch (keymap[i].unshift[2]) {
+ case 'M':
+ k[0] = XK_F1;
+ break;
+ case 'N':
+ k[0] = XK_F2;
+ break;
+ case 'O':
+ k[0] = XK_F3;
+ break;
+ case 'P':
+ k[0] = XK_F4;
+ break;
+ case 'Q':
+ k[0] = XK_F5;
+ break;
+ case 'R':
+ k[0] = XK_F6;
+ break;
+ case 'S':
+ k[0] = XK_F7;
+ break;
+ case 'T':
+ k[0] = XK_F8;
+ break;
+ case 'U':
+ k[0] = XK_F9;
+ break;
+ case 'V':
+ k[0] = XK_F10;
+ break;
+ case 'W':
+ k[0] = XK_F11;
+ break;
+ case 'X':
+ k[0] = XK_F12;
+ break;
+ default:
+ k[0] = NoSymbol;
+ break;
+ }
+ goto special;
+ default:
+ k[0] = NoSymbol;
+ special:
+ k[1] = k[2] = k[3] = NoSymbol;
+ }
+ }
+ } else {
+ ErrorF("Can't read pccons keymap\n");
+ }
+ }
+#endif /* __OpenBSD__ */
+ break;
+#endif
+
+/*
+ * XXX wscons has no GIO_KEYMAP
+ */
+#if (defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)) && defined(GIO_KEYMAP)
+ case SYSCONS:
+ case PCVT:
+ {
+ keymap_t keymap;
+
+ if (ioctl(pInfo->fd, GIO_KEYMAP, &keymap) != -1) {
+ for (i = 0; i < keymap.n_keys && i < NUM_KEYCODES; i++)
+ if (remap[i]) {
+ k = map + (remap[i] << 2);
+ k[0] = KD_GET_ENTRY(i,0); /* non-shifed */
+ k[1] = KD_GET_ENTRY(i,1); /* shifted */
+ k[2] = KD_GET_ENTRY(i,4); /* alt */
+ k[3] = KD_GET_ENTRY(i,5); /* alt - shifted */
+ if (k[3] == k[2]) k[3] = NoSymbol;
+ if (k[2] == k[1]) k[2] = NoSymbol;
+ if (k[1] == k[0]) k[1] = NoSymbol;
+ if (k[0] == k[2] && k[1] == k[3])
+ k[2] = k[3] = NoSymbol;
+ }
+ }
+ }
+ break;
+#endif /* SYSCONS || PCVT */
+
+ }
+#endif /* !bsdi */
+
+ /*
+ * compute the modifier map
+ */
+ for (i = 0; i < MAP_LENGTH; i++)
+ pModMap[i] = NoSymbol; /* make sure it is restored */
+
+ for (k = map, i = MIN_KEYCODE;
+ i < (NUM_KEYCODES + MIN_KEYCODE);
+ i++, k += 4)
+
+ switch(*k) {
+
+ case XK_Shift_L:
+ case XK_Shift_R:
+ pModMap[i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ case XK_Control_R:
+ pModMap[i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ pModMap[i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ case XK_Alt_R:
+ pModMap[i] = AltMask;
+ break;
+
+ case XK_Num_Lock:
+ pModMap[i] = NumLockMask;
+ break;
+
+ case XK_Scroll_Lock:
+ pModMap[i] = ScrollLockMask;
+ break;
+
+ /* kana support */
+ case XK_Kana_Lock:
+ case XK_Kana_Shift:
+ pModMap[i] = KanaMask;
+ break;
+
+ /* alternate toggle for multinational support */
+ case XK_Mode_switch:
+ pModMap[i] = AltLangMask;
+ break;
+
+ }
+
+ pKbd->kbdType = 0;
+
+ pKeySyms->map = map;
+ pKeySyms->mapWidth = GLYPHS_PER_KEY;
+ pKeySyms->minKeyCode = MIN_KEYCODE;
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
+
+ switch(pKbd->consType) {
+#ifdef SYSCONS_SUPPORT
+ case SYSCONS:
+ if (pKbd->CustomKeycodes)
+ pKbd->scancodeMap = &sysconsCODE;
+ else
+ pKbd->RemapScanCode = ATScancode;
+ break;
+#endif
+#if defined(PCCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case PCCONS:
+ case PCVT:
+ pKbd->RemapScanCode = ATScancode;
+ break;
+#endif
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ if (!pKbd->isConsole) {
+ switch (pKbd->wsKbdType) {
+ case WSKBD_TYPE_PC_XT:
+ case WSKBD_TYPE_PC_AT:
+ pKbd->RemapScanCode = ATScancode;
+ break;
+ case WSKBD_TYPE_USB:
+ pKbd->scancodeMap = &wsUsb;
+ break;
+#ifdef WSKBD_TYPE_ADB
+ case WSKBD_TYPE_ADB:
+ pKbd->scancodeMap = &wsAdb;
+ break;
+#endif
+#ifdef WSKBD_TYPE_SUN
+#ifdef WSKBD_TYPE_SUN5
+ case WSKBD_TYPE_SUN5:
+#endif
+ case WSKBD_TYPE_SUN:
+ pKbd->scancodeMap = &wsSun;
+ break;
+#endif
+ default:
+ ErrorF("Unknown wskbd type %d\n", pKbd->wsKbdType);
+ }
+ } else {
+ pKbd->RemapScanCode = ATScancode;
+ }
+ break;
+#endif
+ }
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_VTsw.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_VTsw.c
new file mode 100644
index 000000000..d97782dc6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_VTsw.c
@@ -0,0 +1,96 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_VTsw.c,v 3.5.4.3 1998/06/05 16:23:03 dawes Exp $ */
+/*
+ * Derived from VTsw_usl.c which is
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ * by S_ren Schmidt (sos@login.dkuug.dk)
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: bsd_VTsw.c /main/4 1996/02/21 17:50:57 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+/*
+ * Handle the VT-switching interface for OSs that use USL-style ioctl()s
+ * (the bsd, sysv, sco, and linux subdirs).
+ */
+
+/*
+ * This function is the signal handler for the VT-switching signal. It
+ * is only referenced inside the OS-support layer.
+ */
+void
+xf86VTRequest(int sig)
+{
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
+ xf86Info.vtRequestsPending = TRUE;
+ }
+#endif
+ return;
+}
+
+Bool
+xf86VTSwitchPending()
+{
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
+ return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+ }
+#endif
+ return FALSE;
+}
+
+Bool
+xf86VTSwitchAway()
+{
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
+ xf86Info.vtRequestsPending = FALSE;
+ if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0)
+ return(FALSE);
+ else
+ return(TRUE);
+ }
+#endif
+ return FALSE;
+}
+
+Bool
+xf86VTSwitchTo()
+{
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
+ xf86Info.vtRequestsPending = FALSE;
+ if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
+ return(FALSE);
+ else
+ return(TRUE);
+ }
+#endif
+ return(TRUE);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_apm.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_apm.c
new file mode 100644
index 000000000..c8e204307
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_apm.c
@@ -0,0 +1,141 @@
+/* $XFree86$ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
+#include "xf86_OSproc.h"
+#include "xf86_OSlib.h"
+
+#include <machine/apmvar.h>
+
+#define APM_DEVICE "/dev/apm"
+
+static pointer APMihPtr = NULL;
+static void bsdCloseAPM(void);
+
+static struct {
+ u_int apmBsd;
+ pmEvent xf86;
+} bsdToXF86Array [] = {
+ { APM_STANDBY_REQ, XF86_APM_SYS_STANDBY },
+ { APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND },
+ { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME },
+ { APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME },
+ { APM_BATTERY_LOW, XF86_APM_LOW_BATTERY },
+ { APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE },
+ { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME },
+ { APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND },
+ { APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY },
+ { APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND },
+ { APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME },
+#ifdef APM_CAPABILITY_CHANGE
+ { APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED },
+#endif
+};
+
+#define numApmEvents (sizeof(bsdToXF86Array) / sizeof(bsdToXF86Array[0]))
+
+static pmEvent
+bsdToXF86(int type)
+{
+ int i;
+
+ for (i = 0; i < numApmEvents; i++) {
+ if (type == bsdToXF86Array[i].apmBsd) {
+ return bsdToXF86Array[i].xf86;
+ }
+ }
+ return XF86_APM_UNKNOWN;
+}
+
+/*
+ * APM events can be requested direclty from /dev/apm
+ */
+static int
+bsdPMGetEventFromOS(int fd, pmEvent *events, int num)
+{
+ struct apm_event_info bsdEvent;
+ int i;
+
+ for (i = 0; i < num; i++) {
+
+ if (ioctl(fd, APM_IOC_NEXTEVENT, &bsdEvent) < 0) {
+ if (errno != EAGAIN) {
+ xf86Msg(X_WARNING, "bsdPMGetEventFromOS: APM_IOC_NEXTEVENT"
+ " errno = %d\n", errno);
+ }
+ break;
+ }
+ events[i] = bsdToXF86(bsdEvent.type);
+ }
+ return i;
+}
+
+/*
+ * XXX This won't work on /dev/apm !
+ * We should either use /dev/apm_ctl (and kill apmd(8))
+ * or talk to apmd (but its protocol is not publically available)...
+ */
+static pmWait
+bsdPMConfirmEventToOs(int fd, pmEvent event)
+{
+ switch (event) {
+ case XF86_APM_SYS_STANDBY:
+ case XF86_APM_USER_STANDBY:
+ if (ioctl( fd, APM_IOC_STANDBY, NULL ) == 0)
+ return PM_WAIT; /* should we stop the Xserver in standby, too? */
+ else
+ return PM_NONE;
+ case XF86_APM_SYS_SUSPEND:
+ case XF86_APM_CRITICAL_SUSPEND:
+ case XF86_APM_USER_SUSPEND:
+ if (ioctl( fd, APM_IOC_SUSPEND, NULL ) == 0)
+ return PM_WAIT;
+ else
+ return PM_NONE;
+ case XF86_APM_STANDBY_RESUME:
+ case XF86_APM_NORMAL_RESUME:
+ case XF86_APM_CRITICAL_RESUME:
+ case XF86_APM_STANDBY_FAILED:
+ case XF86_APM_SUSPEND_FAILED:
+ return PM_CONTINUE;
+ default:
+ return PM_NONE;
+ }
+}
+
+PMClose
+xf86OSPMOpen(void)
+{
+ int fd;
+
+ if (APMihPtr || !xf86Info.pmFlag) {
+ return NULL;
+ }
+
+ if ((fd = open(APM_DEVICE, O_RDWR)) == -1) {
+ return NULL;
+ }
+ xf86PMGetEventFromOs = bsdPMGetEventFromOS;
+ xf86PMConfirmEventToOs = bsdPMConfirmEventToOs;
+ APMihPtr = xf86AddInputHandler(fd, xf86HandlePMEvents, NULL);
+ return bsdCloseAPM;
+}
+
+static void
+bsdCloseAPM(void)
+{
+ int fd;
+
+ if (APMihPtr) {
+ fd = xf86RemoveInputHandler(APMihPtr);
+ close(fd);
+ APMihPtr = NULL;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_axp.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_axp.c
new file mode 100644
index 000000000..00b928a5e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_axp.c
@@ -0,0 +1,73 @@
+/* $XFree86: bsd_axp.c,v 1.2 2002/10/29 23:19:13 herrb Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Axp.h"
+#include <sys/param.h>
+#include "xf86_OSlib.h"
+#include <stdio.h>
+#include <sys/sysctl.h>
+
+axpDevice bsdGetAXP(void);
+
+/*
+ * BSD does a very nice job providing system information to
+ * user space programs. Unfortunately it doesn't provide all
+ * the information required. Therefore we just obtain the
+ * system type and look up the rest from a list we maintain
+ * ourselves.
+ */
+
+typedef struct {
+ char *name;
+ int type;
+} _AXP;
+
+static _AXP axpList[] = {
+ {"apecs",APECS},
+ {"pyxis",PYXIS},
+ {"cia",CIA},
+ {"irongate",IRONGATE},
+ {"lca",LCA},
+ {"t2",T2},
+ {"tsunami",TSUNAMI},
+ {NULL,NONE}
+};
+
+axpDevice
+bsdGetAXP(void)
+{
+ int i;
+ char sysname[64];
+ size_t len = sizeof(sysname);
+
+#ifdef __OpenBSD__
+ int mib[3];
+ int error;
+
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_CHIPSET;
+ mib[2] = CPU_CHIPSET_TYPE;
+
+ if ((error = sysctl(mib, 3, &sysname, &len, NULL, 0)) < 0)
+#else
+ if ((sysctlbyname("hw.chipset.type", &sysname, &len,
+ 0, 0)) < 0)
+#endif
+ FatalError("bsdGetAXP: can't find machine type\n");
+#ifdef DEBUG
+ xf86Msg(X_INFO,"AXP is a: %s\n",sysname);
+#endif
+ for (i=0;;i++) {
+ if (axpList[i].name == NULL)
+ return NONE;
+ if (!strcmp(sysname, axpList[i].name))
+ return axpList[i].type;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_ev56.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_ev56.c
new file mode 100644
index 000000000..62952a343
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_ev56.c
@@ -0,0 +1,91 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_ev56.c,v 1.1 2000/03/05 16:59:17 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "input.h"
+#include "scrnintstr.h"
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+int readDense8(pointer Base, register unsigned long Offset);
+int readDense16(pointer Base, register unsigned long Offset);
+int readDense32(pointer Base, register unsigned long Offset);
+void
+writeDenseNB8(int Value, pointer Base, register unsigned long Offset);
+void
+writeDenseNB16(int Value, pointer Base, register unsigned long Offset);
+void
+writeDenseNB32(int Value, pointer Base, register unsigned long Offset);
+void
+writeDense8(int Value, pointer Base, register unsigned long Offset);
+void
+writeDense16(int Value, pointer Base, register unsigned long Offset);
+void
+writeDense32(int Value, pointer Base, register unsigned long Offset);
+
+int
+readDense8(pointer Base, register unsigned long Offset)
+{
+ mem_barrier();
+ return *(volatile CARD8*) ((unsigned long)Base+(Offset));
+}
+
+int
+readDense16(pointer Base, register unsigned long Offset)
+{
+ mem_barrier();
+ return *(volatile CARD16*) ((unsigned long)Base+(Offset));
+}
+
+int
+readDense32(pointer Base, register unsigned long Offset)
+{
+ mem_barrier();
+ return *(volatile CARD32*)((unsigned long)Base+(Offset));
+}
+
+void
+writeDenseNB8(int Value, pointer Base, register unsigned long Offset)
+{
+ *(volatile CARD8*)((unsigned long)Base+(Offset)) = Value;
+}
+
+void
+writeDenseNB16(int Value, pointer Base, register unsigned long Offset)
+{
+ *(volatile CARD16*)((unsigned long)Base + (Offset)) = Value;
+}
+
+void
+writeDenseNB32(int Value, pointer Base, register unsigned long Offset)
+{
+ *(volatile CARD32*)((unsigned long)Base+(Offset)) = Value;
+}
+
+void
+writeDense8(int Value, pointer Base, register unsigned long Offset)
+{
+ write_mem_barrier();
+ *(volatile CARD8 *)((unsigned long)Base+(Offset)) = Value;
+}
+
+void
+writeDense16(int Value, pointer Base, register unsigned long Offset)
+{
+ write_mem_barrier();
+ *(volatile CARD16 *)((unsigned long)Base+(Offset)) = Value;
+}
+
+void
+writeDense32(int Value, pointer Base, register unsigned long Offset)
+{
+ write_mem_barrier();
+ *(volatile CARD32 *)((unsigned long)Base+(Offset)) = Value;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c
new file mode 100644
index 000000000..4d883a2be
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c
@@ -0,0 +1,738 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c,v 3.21 2003/09/24 02:43:34 dawes Exp $ */
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: bsd_init.c /main/8 1996/10/23 13:13:05 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include <sys/utsname.h>
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <errno.h>
+
+static Bool KeepTty = FALSE;
+static int devConsoleFd = -1;
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+static int VTnum = -1;
+static int initialVT = -1;
+#endif
+
+#ifdef PCCONS_SUPPORT
+/* Stock 0.1 386bsd pccons console driver interface */
+#ifndef __OpenBSD__
+# define PCCONS_CONSOLE_DEV1 "/dev/ttyv0"
+#else
+# define PCCONS_CONSOLE_DEV1 "/dev/ttyC0"
+#endif
+#define PCCONS_CONSOLE_DEV2 "/dev/vga"
+#define PCCONS_CONSOLE_MODE O_RDWR|O_NDELAY
+#endif
+
+#ifdef SYSCONS_SUPPORT
+/* The FreeBSD 1.1 version syscons driver uses /dev/ttyv0 */
+#define SYSCONS_CONSOLE_DEV1 "/dev/ttyv0"
+#define SYSCONS_CONSOLE_DEV2 "/dev/vga"
+#define SYSCONS_CONSOLE_MODE O_RDWR|O_NDELAY
+#endif
+
+#ifdef PCVT_SUPPORT
+/* Hellmuth Michaelis' pcvt driver */
+#ifndef __OpenBSD__
+# define PCVT_CONSOLE_DEV "/dev/ttyv0"
+#else
+# define PCVT_CONSOLE_DEV "/dev/ttyC0"
+#endif
+#define PCVT_CONSOLE_MODE O_RDWR|O_NDELAY
+#endif
+
+#if defined(WSCONS_SUPPORT) && defined(__NetBSD__)
+/* NetBSD's new console driver */
+#define WSCONS_PCVT_COMPAT_CONSOLE_DEV "/dev/ttyE0"
+#endif
+
+#ifdef __GLIBC__
+#define setpgrp setpgid
+#endif
+
+#define CHECK_DRIVER_MSG \
+ "Check your kernel's console driver configuration and /dev entries"
+
+static char *supported_drivers[] = {
+#ifdef PCCONS_SUPPORT
+ "pccons (with X support)",
+#endif
+#ifdef SYSCONS_SUPPORT
+ "syscons",
+#endif
+#ifdef PCVT_SUPPORT
+ "pcvt",
+#endif
+#ifdef WSCONS_SUPPORT
+ "wscons",
+#endif
+};
+
+
+/*
+ * Functions to probe for the existance of a supported console driver.
+ * Any function returns either a valid file descriptor (driver probed
+ * succesfully), -1 (driver not found), or uses FatalError() if the
+ * driver was found but proved to not support the required mode to run
+ * an X server.
+ */
+
+typedef int (*xf86ConsOpen_t)(void);
+
+#ifdef PCCONS_SUPPORT
+static int xf86OpenPccons(void);
+#endif /* PCCONS_SUPPORT */
+
+#ifdef SYSCONS_SUPPORT
+static int xf86OpenSyscons(void);
+#endif /* SYSCONS_SUPPORT */
+
+#ifdef PCVT_SUPPORT
+static int xf86OpenPcvt(void);
+#endif /* PCVT_SUPPORT */
+
+#ifdef WSCONS_SUPPORT
+static int xf86OpenWScons(void);
+#endif
+
+/*
+ * The sequence of the driver probes is important; start with the
+ * driver that is best distinguishable, and end with the most generic
+ * driver. (Otherwise, pcvt would also probe as syscons, and either
+ * pcvt or syscons might succesfully probe as pccons.)
+ */
+static xf86ConsOpen_t xf86ConsTab[] = {
+#ifdef PCVT_SUPPORT
+ xf86OpenPcvt,
+#endif
+#ifdef SYSCONS_SUPPORT
+ xf86OpenSyscons,
+#endif
+#ifdef PCCONS_SUPPORT
+ xf86OpenPccons,
+#endif
+#ifdef WSCONS_SUPPORT
+ xf86OpenWScons,
+#endif
+ (xf86ConsOpen_t)NULL
+};
+
+
+void
+xf86OpenConsole()
+{
+ int i, fd = -1;
+ xf86ConsOpen_t *driver;
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ int result;
+ struct utsname uts;
+ vtmode_t vtmode;
+#endif
+
+ if (serverGeneration == 1)
+ {
+ /* check if we are run with euid==0 */
+ if (geteuid() != 0)
+ {
+ FatalError("xf86OpenConsole: Server must be suid root");
+ }
+
+ if (!KeepTty)
+ {
+ /*
+ * detaching the controlling tty solves problems of kbd character
+ * loss. This is not interesting for CO driver, because it is
+ * exclusive.
+ */
+ setpgrp(0, getpid());
+ if ((i = open("/dev/tty",O_RDWR)) >= 0)
+ {
+ ioctl(i,TIOCNOTTY,(char *)0);
+ close(i);
+ }
+ }
+
+ /* detect which driver we are running on */
+ for (driver = xf86ConsTab; *driver; driver++)
+ {
+ if ((fd = (*driver)()) >= 0)
+ break;
+ }
+
+ /* Check that a supported console driver was found */
+ if (fd < 0)
+ {
+ char cons_drivers[80] = {0, };
+ for (i = 0; i < sizeof(supported_drivers) / sizeof(char *); i++)
+ {
+ if (i)
+ {
+ strcat(cons_drivers, ", ");
+ }
+ strcat(cons_drivers, supported_drivers[i]);
+ }
+ FatalError(
+ "%s: No console driver found\n\tSupported drivers: %s\n\t%s",
+ "xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG);
+ }
+#if 0 /* stdin is already closed in OsInit() */
+ fclose(stdin);
+#endif
+ xf86Info.consoleFd = fd;
+ xf86Info.screenFd = fd;
+
+ switch (xf86Info.consType)
+ {
+#ifdef PCCONS_SUPPORT
+ case PCCONS:
+ if (ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_ON, 0) < 0)
+ {
+ FatalError("%s: CONSOLE_X_MODE_ON failed (%s)\n%s",
+ "xf86OpenConsole", strerror(errno),
+ CHECK_DRIVER_MSG);
+ }
+ /*
+ * Hack to prevent keyboard hanging when syslogd closes
+ * /dev/console
+ */
+ if ((devConsoleFd = open("/dev/console", O_WRONLY,0)) < 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: couldn't open /dev/console (%s)\n",
+ strerror(errno));
+ }
+ break;
+#endif
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ /* as of FreeBSD 2.2.8, syscons driver does not need the #1 vt
+ * switching anymore. Here we check for FreeBSD 3.1 and up.
+ * Add cases for other *BSD that behave the same.
+ */
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ uname (&uts);
+ i = atof(uts.release) * 100;
+ if (i >= 310) goto acquire_vt;
+#endif
+ /* otherwise fall through */
+ case PCVT:
+ /*
+ * First activate the #1 VT. This is a hack to allow a server
+ * to be started while another one is active. There should be
+ * a better way.
+ */
+ if (initialVT != 1) {
+
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) != 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ sleep(1);
+ }
+
+acquire_vt:
+ /*
+ * now get the VT
+ */
+ SYSCALL(result =
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
+ if (result != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ SYSCALL(result =
+ ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno));
+ if (result != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+ }
+
+ signal(SIGUSR1, xf86VTRequest);
+
+ vtmode.mode = VT_PROCESS;
+ vtmode.relsig = SIGUSR1;
+ vtmode.acqsig = SIGUSR1;
+ vtmode.frsig = SIGUSR1;
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0)
+ {
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed");
+ }
+#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
+ if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
+ {
+ FatalError("xf86OpenConsole: KDENABIO failed (%s)",
+ strerror(errno));
+ }
+#endif
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ {
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
+ }
+ break;
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ fprintf(stderr, "xf86OpenConsole\n");
+ /* xf86Info.consoleFd = open("/dev/wskbd0", 0); */
+ break;
+#endif
+ }
+ }
+ else
+ {
+ /* serverGeneration != 1 */
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
+ {
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ }
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+ }
+ return;
+}
+
+
+#ifdef PCCONS_SUPPORT
+
+static int
+xf86OpenPccons()
+{
+ int fd = -1;
+
+ if ((fd = open(PCCONS_CONSOLE_DEV1, PCCONS_CONSOLE_MODE, 0))
+ >= 0 ||
+ (fd = open(PCCONS_CONSOLE_DEV2, PCCONS_CONSOLE_MODE, 0))
+ >= 0)
+ {
+ if (ioctl(fd, CONSOLE_X_MODE_OFF, 0) < 0)
+ {
+ FatalError(
+ "%s: CONSOLE_X_MODE_OFF failed (%s)\n%s\n%s",
+ "xf86OpenPccons",
+ strerror(errno),
+ "Was expecting pccons driver with X support",
+ CHECK_DRIVER_MSG);
+ }
+ xf86Info.consType = PCCONS;
+ xf86Msg(X_PROBED, "Using pccons driver with X support\n");
+ }
+ return fd;
+}
+
+#endif /* PCCONS_SUPPORT */
+
+#ifdef SYSCONS_SUPPORT
+
+static int
+xf86OpenSyscons()
+{
+ int fd = -1;
+ vtmode_t vtmode;
+ char vtname[12];
+ struct stat status;
+ long syscons_version;
+ MessageType from;
+
+ /* Check for syscons */
+ if ((fd = open(SYSCONS_CONSOLE_DEV1, SYSCONS_CONSOLE_MODE, 0)) >= 0
+ || (fd = open(SYSCONS_CONSOLE_DEV2, SYSCONS_CONSOLE_MODE, 0)) >= 0)
+ {
+ if (ioctl(fd, VT_GETMODE, &vtmode) >= 0)
+ {
+ /* Get syscons version */
+ if (ioctl(fd, CONS_GETVERS, &syscons_version) < 0)
+ {
+ syscons_version = 0;
+ }
+
+ xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
+
+#ifdef VT_GETACTIVE
+ if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
+ initialVT = -1;
+#endif
+ if (xf86Info.vtno == -1)
+ {
+ /*
+ * For old syscons versions (<0x100), VT_OPENQRY returns
+ * the current VT rather than the next free VT. In this
+ * case, the server gets started on the current VT instead
+ * of the next free VT.
+ */
+
+#if 0
+ /* check for the fixed VT_OPENQRY */
+ if (syscons_version >= 0x100)
+ {
+#endif
+ if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0)
+ {
+ /* No free VTs */
+ xf86Info.vtno = -1;
+ }
+#if 0
+ }
+#endif
+
+ if (xf86Info.vtno == -1)
+ {
+ /*
+ * All VTs are in use. If initialVT was found, use it.
+ * Otherwise, if stdin is a VT, use that one.
+ * XXX stdin is already closed, so this won't work.
+ */
+ if (initialVT != -1)
+ {
+ xf86Info.vtno = initialVT;
+ }
+ else if ((fstat(0, &status) >= 0)
+ && S_ISCHR(status.st_mode)
+ && (ioctl(0, VT_GETMODE, &vtmode) >= 0))
+ {
+ /* stdin is a VT */
+ xf86Info.vtno = minor(status.st_rdev) + 1;
+ }
+ else
+ {
+ if (syscons_version >= 0x100)
+ {
+ FatalError("%s: Cannot find a free VT",
+ "xf86OpenSyscons");
+ }
+ /* Should no longer reach here */
+ FatalError("%s: %s %s\n\t%s %s",
+ "xf86OpenSyscons",
+ "syscons versions prior to 1.0 require",
+ "either the",
+ "server's stdin be a VT",
+ "or the use of the vtxx server option");
+ }
+ }
+ from = X_PROBED;
+ }
+
+ close(fd);
+#ifndef __OpenBSD__
+ sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1);
+#else
+ sprintf(vtname, "/dev/ttyC%01x", xf86Info.vtno - 1);
+#endif
+ if ((fd = open(vtname, SYSCONS_CONSOLE_MODE, 0)) < 0)
+ {
+ FatalError("xf86OpenSyscons: Cannot open %s (%s)",
+ vtname, strerror(errno));
+ }
+ if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
+ {
+ FatalError("xf86OpenSyscons: VT_GETMODE failed");
+ }
+ xf86Info.consType = SYSCONS;
+ xf86Msg(X_PROBED, "Using syscons driver with X support");
+ if (syscons_version >= 0x100)
+ {
+ xf86ErrorF(" (version %ld.%ld)\n", syscons_version >> 8,
+ syscons_version & 0xFF);
+ }
+ else
+ {
+ xf86ErrorF(" (version 0.x)\n");
+ }
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+ }
+ else
+ {
+ /* VT_GETMODE failed, probably not syscons */
+ close(fd);
+ fd = -1;
+ }
+ }
+ return fd;
+}
+
+#endif /* SYSCONS_SUPPORT */
+
+
+#ifdef PCVT_SUPPORT
+
+static int
+xf86OpenPcvt()
+{
+ /* This looks much like syscons, since pcvt is API compatible */
+ int fd = -1;
+ vtmode_t vtmode;
+ char vtname[12], *vtprefix;
+ struct stat status;
+ struct pcvtid pcvt_version;
+
+#ifndef __OpenBSD__
+ vtprefix = "/dev/ttyv";
+#else
+ vtprefix = "/dev/ttyC";
+#endif
+
+ fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
+#ifdef WSCONS_PCVT_COMPAT_CONSOLE_DEV
+ if (fd < 0)
+ {
+ fd = open(WSCONS_PCVT_COMPAT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
+ vtprefix = "/dev/ttyE";
+ }
+#endif
+ if (fd >= 0)
+ {
+ if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0)
+ {
+ if(ioctl(fd, VT_GETMODE, &vtmode) < 0)
+ {
+ FatalError("%s: VT_GETMODE failed\n%s%s\n%s",
+ "xf86OpenPcvt",
+ "Found pcvt driver but X11 seems to be",
+ " not supported.", CHECK_DRIVER_MSG);
+ }
+
+ xf86Info.vtno = VTnum;
+
+ if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
+ initialVT = -1;
+
+ if (xf86Info.vtno == -1)
+ {
+ if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0)
+ {
+ /* No free VTs */
+ xf86Info.vtno = -1;
+ }
+
+ if (xf86Info.vtno == -1)
+ {
+ /*
+ * All VTs are in use. If initialVT was found, use it.
+ * Otherwise, if stdin is a VT, use that one.
+ * XXX stdin is already closed, so this won't work.
+ */
+ if (initialVT != -1)
+ {
+ xf86Info.vtno = initialVT;
+ }
+ else if ((fstat(0, &status) >= 0)
+ && S_ISCHR(status.st_mode)
+ && (ioctl(0, VT_GETMODE, &vtmode) >= 0))
+ {
+ /* stdin is a VT */
+ xf86Info.vtno = minor(status.st_rdev) + 1;
+ }
+ else
+ {
+ FatalError("%s: Cannot find a free VT",
+ "xf86OpenPcvt");
+ }
+ }
+ }
+
+ close(fd);
+ sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
+ if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0)
+ {
+ FatalError("xf86OpenPcvt: Cannot open %s (%s)",
+ vtname, strerror(errno));
+ }
+ if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
+ {
+ FatalError("xf86OpenPcvt: VT_GETMODE failed");
+ }
+ xf86Info.consType = PCVT;
+#ifdef WSCONS_SUPPORT
+ xf86Msg(X_PROBED,
+ "Using wscons driver in pcvt compatibility mode "
+ "(version %d.%d)\n",
+ pcvt_version.rmajor, pcvt_version.rminor);
+#else
+ xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n",
+ pcvt_version.rmajor, pcvt_version.rminor);
+#endif
+ }
+ else
+ {
+ /* Not pcvt */
+ close(fd);
+ fd = -1;
+ }
+ }
+ return fd;
+}
+
+#endif /* PCVT_SUPPORT */
+
+#ifdef WSCONS_SUPPORT
+
+static int
+xf86OpenWScons()
+{
+ int fd = -1;
+ int mode = WSDISPLAYIO_MODE_MAPPED;
+ int i;
+ char ttyname[16];
+
+ /* XXX Is this ok? */
+ for (i = 0; i < 8; i++) {
+#if defined(__NetBSD__)
+ sprintf(ttyname, "/dev/ttyE%d", i);
+#elif defined(__OpenBSD__)
+ sprintf(ttyname, "/dev/ttyC%d", i);
+#endif
+ if ((fd = open(ttyname, 2)) != -1)
+ break;
+ }
+ if (fd != -1) {
+ if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) {
+ FatalError("%s: WSDISPLAYIO_MODE_MAPPED failed (%s)\n%s",
+ "xf86OpenConsole", strerror(errno),
+ CHECK_DRIVER_MSG);
+ }
+ xf86Info.consType = WSCONS;
+ xf86Msg(X_PROBED, "Using wscons driver\n");
+ }
+ return fd;
+}
+
+#endif /* WSCONS_SUPPORT */
+
+void
+xf86CloseConsole()
+{
+#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
+ struct vt_mode VT;
+#endif
+
+ switch (xf86Info.consType)
+ {
+#ifdef PCCONS_SUPPORT
+ case PCCONS:
+ ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_OFF, 0);
+ break;
+#endif /* PCCONS_SUPPORT */
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ case PCVT:
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode */
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
+ {
+ VT.mode = VT_AUTO;
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
+ }
+#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
+ if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0)
+ {
+ xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)",
+ strerror(errno));
+ }
+#endif
+ if (initialVT != -1)
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT);
+ break;
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ {
+ int mode = WSDISPLAYIO_MODE_EMUL;
+ ioctl(xf86Info.screenFd, WSDISPLAYIO_SMODE, &mode);
+ break;
+ }
+#endif
+ }
+
+ if (xf86Info.screenFd != xf86Info.consoleFd)
+ {
+ close(xf86Info.screenFd);
+ close(xf86Info.consoleFd);
+ if ((xf86Info.consoleFd = open("/dev/console",O_RDONLY,0)) <0)
+ {
+ xf86FatalError("xf86CloseConsole: Cannot open /dev/console (%s)",
+ strerror(errno));
+ }
+ }
+ close(xf86Info.consoleFd);
+ if (devConsoleFd >= 0)
+ close(devConsoleFd);
+ return;
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty"))
+ {
+ KeepTty = TRUE;
+ return(1);
+ }
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+ {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0 ||
+ VTnum < 1 || VTnum > 12)
+ {
+ UseMsg();
+ VTnum = -1;
+ return(0);
+ }
+ return(1);
+ }
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+ return(0);
+}
+
+void
+xf86UseMsg()
+{
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ ErrorF("vtXX use the specified VT number (1-12)\n");
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c
new file mode 100644
index 000000000..3b1f58889
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c
@@ -0,0 +1,294 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c,v 3.22 2002/05/18 21:15:16 herrb Exp $ */
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Dawes <dawes@xfree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Dawes
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Dawes make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID DAWES BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: bsd_io.c /main/11 1996/10/19 18:06:07 kaleb $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <termios.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#ifdef WSCONS_SUPPORT
+#define KBD_FD(i) ((i).kbdFd != -1 ? (i).kbdFd : (i).consoleFd)
+#endif
+
+void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
+{
+#ifdef WSCONS_SUPPORT
+ struct wskbd_bell_data wsb;
+#endif
+
+ if (loudness && pitch)
+ {
+#ifdef PCCONS_SUPPORT
+ int data[2];
+#endif
+
+ switch (xf86Info.consType) {
+
+#ifdef PCCONS_SUPPORT
+ case PCCONS:
+ data[0] = pitch;
+ data[1] = (duration * loudness) / 50;
+ ioctl(xf86Info.consoleFd, CONSOLE_X_BELL, data);
+ break;
+#endif
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ case PCVT:
+ ioctl(xf86Info.consoleFd, KDMKTONE,
+ ((1193190 / pitch) & 0xffff) |
+ (((unsigned long)duration*loudness/50)<<16));
+ break;
+#endif
+#if defined (WSCONS_SUPPORT)
+ case WSCONS:
+ wsb.which = WSKBD_BELL_DOALL;
+ wsb.pitch = pitch;
+ wsb.period = duration;
+ wsb.volume = loudness;
+ ioctl(KBD_FD(xf86Info), WSKBDIO_COMPLEXBELL,
+ &wsb);
+ break;
+#endif
+ }
+ }
+}
+
+void
+xf86SetKbdLeds(int leds)
+{
+ switch (xf86Info.consType) {
+
+ case PCCONS:
+ break;
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ case PCVT:
+ ioctl(xf86Info.consoleFd, KDSETLED, leds);
+ break;
+#endif
+#if defined(WSCONS_SUPPORT)
+ case WSCONS:
+ ioctl(KBD_FD(xf86Info), WSKBDIO_SETLEDS, &leds);
+ break;
+#endif
+ }
+}
+
+int
+xf86GetKbdLeds()
+{
+ int leds = 0;
+
+ switch (xf86Info.consType) {
+
+ case PCCONS:
+ break;
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ case PCVT:
+ ioctl(xf86Info.consoleFd, KDGETLED, &leds);
+ break;
+#endif
+#if defined(WSCONS_SUPPORT)
+ case WSCONS:
+ ioctl(KBD_FD(xf86Info), WSKBDIO_GETLEDS, &leds);
+ break;
+#endif
+ }
+ return(leds);
+}
+
+void
+xf86SetKbdRepeat(char rad)
+{
+ switch (xf86Info.consType) {
+
+ case PCCONS:
+ break;
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ case PCVT:
+ ioctl(xf86Info.consoleFd, KDSETRAD, rad);
+ break;
+#endif
+ }
+}
+
+#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
+static struct termios kbdtty;
+#endif
+
+void
+xf86KbdInit()
+{
+ switch (xf86Info.consType) {
+
+#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case PCCONS:
+ case SYSCONS:
+ case PCVT:
+ tcgetattr(xf86Info.consoleFd, &kbdtty);
+ break;
+#endif
+#if defined WSCONS_SUPPORT
+ case WSCONS:
+ if (xf86Info.kbdFd != -1)
+ xf86FlushInput(xf86Info.kbdFd);
+ else
+ tcgetattr(xf86Info.consoleFd, &kbdtty);
+ break;
+#endif
+ }
+}
+
+int
+xf86KbdOn()
+{
+ struct termios nTty;
+#ifdef WSCONS_SUPPORT
+ int option;
+#endif
+
+
+ switch (xf86Info.consType) {
+
+#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT)
+ case SYSCONS:
+ case PCCONS:
+ case PCVT:
+ nTty = kbdtty;
+ nTty.c_iflag = IGNPAR | IGNBRK;
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME] = 0;
+ nTty.c_cc[VMIN] = 1;
+ cfsetispeed(&nTty, 9600);
+ cfsetospeed(&nTty, 9600);
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
+
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW);
+#endif
+ break;
+#endif
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ if (xf86Info.kbdFd == -1) {
+ nTty = kbdtty;
+ nTty.c_iflag = IGNPAR | IGNBRK;
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME] = 0;
+ nTty.c_cc[VMIN] = 1;
+ cfsetispeed(&nTty, 9600);
+ cfsetospeed(&nTty, 9600);
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
+ option = WSKBD_RAW;
+ if (ioctl(xf86Info.consoleFd, WSKBDIO_SETMODE,
+ &option) == -1)
+ FatalError("can't switch keyboard to raw mode. "
+ "Enable support for it in the kernel\n"
+ "or use for example:\n\n"
+ "Option \"Protocol\" \"wskbd\"\n"
+ "Option \"Device\" \"/dev/wskbd0\"\n"
+ "\nin your XF86Config(5) file\n");
+ } else {
+ return xf86Info.kbdFd;
+ }
+#endif
+ }
+ return(xf86Info.consoleFd);
+}
+
+int
+xf86KbdOff()
+{
+#ifdef WSCONS_SUPPORT
+ int option;
+#endif
+
+ switch (xf86Info.consType) {
+
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ case PCVT:
+ ioctl(xf86Info.consoleFd, KDSKBMODE, K_XLATE);
+ /* FALL THROUGH */
+#endif
+#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT)
+ case PCCONS:
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty);
+ break;
+#endif
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ if (xf86Info.kbdFd != -1) {
+ return xf86Info.kbdFd;
+ } else {
+ option = WSKBD_TRANSLATED;
+ ioctl(xf86Info.consoleFd, WSKBDIO_SETMODE, &option);
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty);
+ }
+ break;
+#endif
+ }
+ return(xf86Info.consoleFd);
+}
+
+#ifdef WSCONS_SUPPORT
+
+#define NUMEVENTS 64
+
+void
+xf86WSKbdEvents(void)
+{
+ static struct wscons_event events[NUMEVENTS];
+ int n, i;
+
+ n = read(xf86Info.kbdFd, events, sizeof events);
+ if (n <= 0)
+ return;
+ n /= sizeof(struct wscons_event);
+ for (i = 0; i < n; i++)
+ xf86PostWSKbdEvent(&events[i]);
+}
+
+#endif /* WSCONS_SUPPORT */
+
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_jstk.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_jstk.c
new file mode 100644
index 000000000..00f457b88
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_jstk.c
@@ -0,0 +1,189 @@
+/*
+ * Copyright 1995 by Frederic Lepied, France. <fred@sugix.frmug.fr.net>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Frederic Lepied not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Frederic Lepied makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/* Modified for FreeBSD by David Dawes <dawes@XFree86.org> */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_jstk.c,v 3.7 1998/07/25 16:56:34 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <machine/joystick.h>
+#include <fcntl.h>
+
+#ifdef XFree86LOADER
+#include "misc.h"
+#include "xf86_libc.h"
+#endif
+#include "xf86.h"
+
+#define JS_RETURN sizeof(struct joystick)
+
+/***********************************************************************
+ *
+ * xf86JoystickOn --
+ *
+ * open the device and init timeout according to the device value.
+ *
+ ***********************************************************************
+ */
+
+int
+xf86JoystickOn(char * name, int *timeout, int *centerX, int *centerY)
+{
+ int status;
+ int changed = 0;
+ int timeinmicros;
+ struct joystick js;
+
+#ifdef DEBUG
+ ErrorF("xf86JoystickOn: %s\n", name);
+#endif
+
+ if ((status = open(name, O_RDWR | O_NDELAY, 0)) < 0)
+ {
+ xf86Msg(X_WARNING, "xf86JoystickOn: Cannot open joystick '%s' (%s)\n",
+ name, strerror(errno));
+ return -1;
+ }
+
+ if (*timeout <= 0) {
+ /* Use the current setting */
+ ioctl(status, JOY_GETTIMEOUT, (char *)&timeinmicros);
+ *timeout = timeinmicros / 1000;
+ if (*timeout == 0)
+ *timeout = 1;
+ changed = 1;
+ }
+ /* Maximum allowed timeout in the FreeBSD driver is 10ms */
+ if (*timeout > 10) {
+ *timeout = 10;
+ changed = 1;
+ }
+
+ if (changed)
+ xf86Msg(X_PROBED, "Joystick: timeout value = %d\n", *timeout);
+
+ timeinmicros = *timeout * 1000;
+
+ /* Assume the joystick is centred when this is called */
+ read(status, &js, JS_RETURN);
+ if (*centerX < 0) {
+ *centerX = js.x;
+ xf86Msg(X_PROBED, "Joystick: CenterX set to %d\n", *centerX);
+ }
+ if (*centerY < 0) {
+ *centerY = js.y;
+ xf86Msg(X_PROBED, "Joystick: CenterY set to %d\n", *centerY);
+ }
+
+ return status;
+}
+
+/***********************************************************************
+ *
+ * xf86JoystickInit --
+ *
+ * called when X device is initialized.
+ *
+ ***********************************************************************
+ */
+
+void
+xf86JoystickInit()
+{
+ return;
+}
+
+/***********************************************************************
+ *
+ * xf86JoystickOff --
+ *
+ * close the handle.
+ *
+ ***********************************************************************
+ */
+
+int
+xf86JoystickOff(int *fd, int doclose)
+{
+ int oldfd;
+
+ if (((oldfd = *fd) >= 0) && doclose) {
+ close(*fd);
+ *fd = -1;
+ }
+ return oldfd;
+}
+
+/***********************************************************************
+ *
+ * xf86JoystickGetState --
+ *
+ * return the state of buttons and the position of the joystick.
+ *
+ ***********************************************************************
+ */
+
+int
+xf86JoystickGetState(int fd, int *x, int *y, int *buttons)
+{
+ struct joystick js;
+ int status;
+
+ status = read(fd, &js, JS_RETURN);
+
+ if (status != JS_RETURN)
+ {
+ Error("Joystick read");
+ return 0;
+ }
+
+ *x = js.x;
+ *y = js.y;
+ *buttons = js.b1 | (js.b2 << 1);
+#ifdef DEBUG
+ ErrorF("xf86JoystickGetState: x = %d, y = %d, buttons = %d\n", *x, *y,
+ *buttons);
+#endif
+
+ return 1;
+}
+
+#ifdef XFree86LOADER
+/*
+ * Entry point for XFree86 Loader
+ */
+void
+bsd_jstkModuleInit(pointer *data, INT32 *magic)
+{
+ *magic = MAGIC_DONE;
+ *data = NULL;
+}
+#endif
+/* end of bsd_jstk.c */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kbd.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kbd.c
new file mode 100644
index 000000000..18219e5bc
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kbd.c
@@ -0,0 +1,573 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kbd.c,v 1.8 2003/11/04 03:16:58 tsi Exp $ */
+
+/*
+ * Copyright (c) 2002 by The XFree86 Project, Inc.
+ * Author: Ivan Pascal.
+ *
+ * Based on the code from bsd_io.c which is
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Dawes <dawes@xfree86.org>
+ */
+
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <termios.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include "xf86Xinput.h"
+#include "xf86OSKbd.h"
+#include "atKeynames.h"
+#include "bsd_kbd.h"
+
+extern Bool VTSwitchEnabled;
+#ifdef USE_VT_SYSREQ
+extern Bool VTSysreqToggle;
+#endif
+
+static KbdProtocolRec protocols[] = {
+ {"standard", PROT_STD },
+#ifdef WSCONS_SUPPORT
+ {"wskbd", PROT_WSCONS },
+#endif
+ { NULL, PROT_UNKNOWN_KBD }
+};
+
+typedef struct {
+ struct termios kbdtty;
+} BsdKbdPrivRec, *BsdKbdPrivPtr;
+
+static
+int KbdInit(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ BsdKbdPrivPtr priv = (BsdKbdPrivPtr) pKbd->private;
+
+ if (pKbd->isConsole) {
+ switch (pKbd->consType) {
+#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) || defined (WSCONS_SUPPORT)
+ case PCCONS:
+ case SYSCONS:
+ case PCVT:
+#if defined WSCONS_SUPPORT
+ case WSCONS:
+#endif
+ tcgetattr(pInfo->fd, &(priv->kbdtty));
+#endif
+ break;
+ }
+ }
+
+ return Success;
+}
+
+static void
+SetKbdLeds(InputInfoPtr pInfo, int leds)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ int real_leds = 0;
+
+#ifdef LED_CAP
+ if (leds & XLED1) real_leds |= LED_CAP;
+#endif
+#ifdef LED_NUM
+ if (leds & XLED2) real_leds |= LED_NUM;
+#endif
+#ifdef LED_SCR
+ if (leds & XLED3) real_leds |= LED_SCR;
+ if (leds & XLED4) real_leds |= LED_SCR;
+#endif
+
+ switch (pKbd->consType) {
+
+ case PCCONS:
+ break;
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ case PCVT:
+ ioctl(pInfo->fd, KDSETLED, real_leds);
+ break;
+#endif
+#if defined(WSCONS_SUPPORT)
+ case WSCONS:
+ ioctl(pInfo->fd, WSKBDIO_SETLEDS, &real_leds);
+ break;
+#endif
+ }
+}
+
+static int
+GetKbdLeds(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ int leds = 0, real_leds = 0;
+
+ switch (pKbd->consType) {
+ case PCCONS:
+ break;
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ case PCVT:
+ ioctl(pInfo->fd, KDGETLED, &real_leds);
+ break;
+#endif
+#if defined(WSCONS_SUPPORT)
+ case WSCONS:
+ ioctl(pInfo->fd, WSKBDIO_GETLEDS, &real_leds);
+ break;
+#endif
+ }
+
+#ifdef LED_CAP
+ if (real_leds & LED_CAP) leds |= XLED1;
+#endif
+#ifdef LED_NUM
+ if (real_leds & LED_NUM) leds |= XLED2;
+#endif
+#ifdef LED_SCR
+ if (real_leds & LED_SCR) leds |= XLED3;
+#endif
+
+ return(leds);
+}
+
+static void
+SetKbdRepeat(InputInfoPtr pInfo, char rad)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ switch (pKbd->consType) {
+
+ case PCCONS:
+ break;
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ case PCVT:
+ ioctl(pInfo->fd, KDSETRAD, rad);
+ break;
+#endif
+ }
+}
+
+static int
+KbdOn(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
+ BsdKbdPrivPtr priv = (BsdKbdPrivPtr) pKbd->private;
+ struct termios nTty;
+#endif
+#ifdef WSCONS_SUPPORT
+ int option;
+#endif
+
+ if (pKbd->isConsole) {
+ switch (pKbd->consType) {
+
+#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
+ case SYSCONS:
+ case PCCONS:
+ case PCVT:
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+#endif
+ nTty = priv->kbdtty;
+ nTty.c_iflag = IGNPAR | IGNBRK;
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME] = 0;
+ nTty.c_cc[VMIN] = 1;
+ cfsetispeed(&nTty, 9600);
+ cfsetospeed(&nTty, 9600);
+ if (tcsetattr(pInfo->fd, TCSANOW, &nTty) < 0) {
+ xf86Msg(X_ERROR, "KbdOn: tcsetattr: %s\n",
+ strerror(errno));
+ }
+ break;
+#endif
+ }
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) || defined (WSCONS_SUPPORT)
+ switch (pKbd->consType) {
+ case SYSCONS:
+ case PCVT:
+#ifdef K_CODE
+ if (pKbd->CustomKeycodes)
+ ioctl(pInfo->fd, KDSKBMODE, K_CODE);
+ else
+ ioctl(pInfo->fd, KDSKBMODE, K_RAW);
+#else
+ ioctl(pInfo->fd, KDSKBMODE, K_RAW);
+#endif
+ break;
+#endif
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ option = WSKBD_RAW;
+ if (ioctl(pInfo->fd, WSKBDIO_SETMODE, &option) == -1) {
+ FatalError("can't switch keyboard to raw mode. "
+ "Enable support for it in the kernel\n"
+ "or use for example:\n\n"
+ "Option \"Protocol\" \"wskbd\"\n"
+ "Option \"Device\" \"/dev/wskbd0\"\n"
+ "\nin your xorg.conf(5) file\n");
+ }
+ break;
+#endif
+ }
+ }
+ return Success;
+}
+
+static int
+KbdOff(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ BsdKbdPrivPtr priv = (BsdKbdPrivPtr) pKbd->private;
+#ifdef WSCONS_SUPPORT
+ int option;
+#endif
+
+ if (pKbd->isConsole) {
+ switch (pKbd->consType) {
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ case PCVT:
+ ioctl(pInfo->fd, KDSKBMODE, K_XLATE);
+ /* FALL THROUGH */
+#endif
+#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT)
+ case PCCONS:
+ tcsetattr(pInfo->fd, TCSANOW, &(priv->kbdtty));
+ break;
+#endif
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ option = WSKBD_TRANSLATED;
+ ioctl(xf86Info.consoleFd, WSKBDIO_SETMODE, &option);
+ tcsetattr(pInfo->fd, TCSANOW, &(priv->kbdtty));
+ break;
+#endif
+ }
+ }
+ return Success;
+}
+
+static void
+SoundBell(InputInfoPtr pInfo, int loudness, int pitch, int duration)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+#ifdef WSCONS_SUPPORT
+ struct wskbd_bell_data wsb;
+#endif
+
+ if (loudness && pitch) {
+ switch (pKbd->consType) {
+#ifdef PCCONS_SUPPORT
+ case PCCONS:
+ { int data[2];
+ data[0] = pitch;
+ data[1] = (duration * loudness) / 50;
+ ioctl(pInfo->fd, CONSOLE_X_BELL, data);
+ break;
+ }
+#endif
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ case PCVT:
+ ioctl(pInfo->fd, KDMKTONE,
+ ((1193190 / pitch) & 0xffff) |
+ (((unsigned long)duration*loudness/50)<<16));
+ break;
+#endif
+#if defined (WSCONS_SUPPORT)
+ case WSCONS:
+ wsb.which = WSKBD_BELL_DOALL;
+ wsb.pitch = pitch;
+ wsb.period = duration;
+ wsb.volume = loudness;
+ ioctl(pInfo->fd, WSKBDIO_COMPLEXBELL, &wsb);
+ break;
+#endif
+ }
+ }
+}
+
+#define ModifierSet(k) ((modifiers & (k)) == (k))
+
+static
+Bool SpecialKey(InputInfoPtr pInfo, int key, Bool down, int modifiers)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+
+ if(!pKbd->vtSwitchSupported)
+ return FALSE;
+
+ if ((ModifierSet(ControlMask | AltMask)) ||
+ (ModifierSet(ControlMask | AltLangMask))) {
+ if (VTSwitchEnabled && !xf86Info.vtSysreq && !xf86Info.dontVTSwitch) {
+ switch (key) {
+ case KEY_F1:
+ case KEY_F2:
+ case KEY_F3:
+ case KEY_F4:
+ case KEY_F5:
+ case KEY_F6:
+ case KEY_F7:
+ case KEY_F8:
+ case KEY_F9:
+ case KEY_F10:
+#ifdef VT_ACTIVATE
+ if (down) {
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F1 + 1);
+ return TRUE;
+ }
+#endif
+ case KEY_F11:
+ case KEY_F12:
+#ifdef VT_ACTIVATE
+ if (down) {
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F11 + 11);
+ return TRUE;
+ }
+#endif
+ }
+ }
+ }
+#ifdef USE_VT_SYSREQ
+ if (VTSwitchEnabled && xf86Info.vtSysreq && !xf86Info.dontVTSwitch) {
+ switch (key) {
+ case KEY_F1:
+ case KEY_F2:
+ case KEY_F3:
+ case KEY_F4:
+ case KEY_F5:
+ case KEY_F6:
+ case KEY_F7:
+ case KEY_F8:
+ case KEY_F9:
+ case KEY_F10:
+ if (VTSysreqToggle && down) {
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F1 + 1);
+ VTSysreqToggle = FALSE;
+ return TRUE;
+ }
+ break;
+ case KEY_F11:
+ case KEY_F12:
+ if (VTSysreqToggle && down) {
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F11 + 11);
+ VTSysreqToggle = FALSE;
+ return TRUE;
+ }
+ break;
+ /* Ignore these keys -- ie don't let them cancel an alt-sysreq */
+ case KEY_Alt:
+ case KEY_AltLang:
+ break;
+ case KEY_SysReqest:
+ if ((ModifierSet(AltMask) || ModifierSet(AltLangMask)) && down)
+ VTSysreqToggle = TRUE;
+ break;
+ default:
+ /*
+ * We only land here when Alt-SysReq is followed by a
+ * non-switching key.
+ */
+ if (VTSysreqToggle)
+ VTSysreqToggle = FALSE;
+ }
+ }
+#endif /* USE_VT_SYSREQ */
+
+ return FALSE;
+}
+
+static void
+stdReadInput(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ unsigned char rBuf[64];
+ int nBytes, i;
+ if ((nBytes = read( pInfo->fd, (char *)rBuf, sizeof(rBuf))) > 0) {
+ for (i = 0; i < nBytes; i++)
+ pKbd->PostEvent(pInfo, rBuf[i] & 0x7f,
+ rBuf[i] & 0x80 ? FALSE : TRUE);
+ }
+}
+
+#ifdef WSCONS_SUPPORT
+
+static void
+WSReadInput(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ struct wscons_event events[64];
+ int type;
+ int blocked, n, i;
+
+ if ((n = read( pInfo->fd, events, sizeof(events))) > 0) {
+ n /= sizeof(struct wscons_event);
+ for (i = 0; i < n; i++) {
+ type = events[i].type;
+ if (type == WSCONS_EVENT_KEY_UP || type == WSCONS_EVENT_KEY_DOWN) {
+ /* It seems better to block SIGIO there */
+ blocked = xf86BlockSIGIO();
+ pKbd->PostEvent(pInfo, (unsigned int)(events[i].value),
+ type == WSCONS_EVENT_KEY_DOWN ? TRUE : FALSE);
+ xf86UnblockSIGIO(blocked);
+ }
+ } /* for */
+ }
+}
+
+static void
+printWsType(char *type, char *devname)
+{
+ xf86Msg(X_PROBED, "%s: Keyboard type: %s\n", type, devname);
+}
+#endif
+
+static Bool
+OpenKeyboard(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ int i;
+ KbdProtocolId prot = PROT_UNKNOWN_KBD;
+ char *s;
+
+ s = xf86SetStrOption(pInfo->options, "Protocol", NULL);
+ for (i = 0; protocols[i].name; i++) {
+ if (xf86NameCmp(s, protocols[i].name) == 0) {
+ prot = protocols[i].id;
+ break;
+ }
+ }
+
+ switch (prot) {
+ case PROT_STD:
+ pInfo->read_input = stdReadInput;
+ break;
+#ifdef WSCONS_SUPPORT
+ case PROT_WSCONS:
+ pInfo->read_input = WSReadInput;
+ break;
+#endif
+ default:
+ xf86Msg(X_ERROR,"\"%s\" is not a valid keyboard protocol name\n", s);
+ xfree(s);
+ return FALSE;
+ }
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, s);
+ xfree(s);
+
+ s = xf86SetStrOption(pInfo->options, "Device", NULL);
+ if (s == NULL) {
+ if (prot == PROT_WSCONS) {
+ xf86Msg(X_ERROR,"A \"device\" option is required with"
+ " the \"wskbd\" keyboard protocol\n");
+ return FALSE;
+ } else {
+ pInfo->fd = xf86Info.consoleFd;
+ pKbd->isConsole = TRUE;
+ pKbd->consType = xf86Info.consType;
+ }
+ } else {
+ pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL);
+ if (pInfo->fd == -1) {
+ xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s);
+ xfree(s);
+ return FALSE;
+ }
+ pKbd->isConsole = FALSE;
+ pKbd->consType = xf86Info.consType;
+ xfree(s);
+ }
+
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ if (pKbd->isConsole &&
+ ((pKbd->consType == SYSCONS) || (pKbd->consType == PCVT)))
+ pKbd->vtSwitchSupported = TRUE;
+#endif
+
+#ifdef WSCONS_SUPPORT
+ if( prot == PROT_WSCONS) {
+ pKbd->consType = WSCONS;
+ /* Find out keyboard type */
+ if (ioctl(pInfo->fd, WSKBDIO_GTYPE, &(pKbd->wsKbdType)) == -1) {
+ xf86Msg(X_ERROR, "%s: cannot get keyboard type", pInfo->name);
+ close(pInfo->fd);
+ return FALSE;
+ }
+ switch (pKbd->wsKbdType) {
+ case WSKBD_TYPE_PC_XT:
+ printWsType("XT", pInfo->name);
+ break;
+ case WSKBD_TYPE_PC_AT:
+ printWsType("AT", pInfo->name);
+ break;
+ case WSKBD_TYPE_USB:
+ printWsType("USB", pInfo->name);
+ break;
+#ifdef WSKBD_TYPE_ADB
+ case WSKBD_TYPE_ADB:
+ printWsType("ADB", pInfo->name);
+ break;
+#endif
+#ifdef WSKBD_TYPE_SUN
+ case WSKBD_TYPE_SUN:
+ printWsType("Sun", pInfo->name);
+ break;
+#endif
+#ifdef WSKBD_TYPE_SUN5
+ case WSKBD_TYPE_SUN5:
+ xf86Msg(X_PROBED, "Keyboard type: Sun5\n");
+ break;
+#endif
+ default:
+ xf86Msg(X_ERROR, "%s: Unsupported wskbd type \"%d\"",
+ pInfo->name, pKbd->wsKbdType);
+ close(pInfo->fd);
+ return FALSE;
+ }
+ }
+#endif
+ return TRUE;
+}
+
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = pInfo->private;
+
+ pKbd->KbdInit = KbdInit;
+ pKbd->KbdOn = KbdOn;
+ pKbd->KbdOff = KbdOff;
+ pKbd->Bell = SoundBell;
+ pKbd->SetLeds = SetKbdLeds;
+ pKbd->GetLeds = GetKbdLeds;
+ pKbd->SetKbdRepeat = SetKbdRepeat;
+ pKbd->KbdGetMapping = KbdGetMapping;
+ pKbd->SpecialKey = SpecialKey;
+
+ pKbd->RemapScanCode = NULL;
+ pKbd->GetSpecialKey = NULL;
+
+ pKbd->OpenKeyboard = OpenKeyboard;
+ pKbd->vtSwitchSupported = FALSE;
+ pKbd->CustomKeycodes = FALSE;
+
+ pKbd->private = xcalloc(sizeof(BsdKbdPrivRec), 1);
+ if (pKbd->private == NULL) {
+ xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kbd.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kbd.h
new file mode 100644
index 000000000..7b9cd434e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kbd.h
@@ -0,0 +1,5 @@
+/* $XFree86$ */
+
+extern void KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms,
+ CARD8 *pModMap);
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kmod.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kmod.c
new file mode 100644
index 000000000..ecaf78028
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kmod.c
@@ -0,0 +1,31 @@
+/* $XFree86$ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <sys/linker.h>
+
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+
+/*
+ * Load a FreeBSD kernel module.
+ * This is used by the DRI/DRM to load a DRM kernel module when
+ * the X server starts. It could be used for other purposes in the future.
+ * Input:
+ * modName - name of the kernel module (Ex: "tdfx")
+ * Return:
+ * 0 for failure, 1 for success
+ */
+int xf86LoadKernelModule(const char *modName)
+{
+ if (kldload(modName) != -1)
+ return 1;
+ else
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c
new file mode 100644
index 000000000..5215d54e4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c
@@ -0,0 +1,203 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c,v 1.5 2002/07/30 23:24:32 herrb Exp $ */
+/*
+ * Copyright (C) 2001 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from the XFree86 Project.
+ */
+/* $OpenBSD: bsd_kqueue_apm.c,v 1.5 2002/07/30 23:07:42 matthieu Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
+#include "xf86_OSproc.h"
+#include "xf86_OSlib.h"
+
+#include <sys/event.h>
+#include <machine/apmvar.h>
+
+#define _PATH_APM_SOCKET "/var/run/apmdev"
+#define _PATH_APM_DEV "/dev/apm"
+#define _PATH_APM_CTLDEV "/dev/apmctl"
+
+static pointer APMihPtr = NULL;
+static int devFd = -1;
+static int ctlFd = -1;
+static void bsdCloseAPM(void);
+
+static struct {
+ u_int apmBsd;
+ pmEvent xf86;
+} bsdToXF86Array [] = {
+ { APM_STANDBY_REQ, XF86_APM_SYS_STANDBY },
+ { APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND },
+ { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME },
+ { APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME },
+ { APM_BATTERY_LOW, XF86_APM_LOW_BATTERY },
+ { APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE },
+ { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME },
+ { APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND },
+ { APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY },
+ { APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND },
+ { APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME },
+#ifdef APM_CAPABILITY_CHANGE
+ { APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED },
+#endif
+};
+
+#define numApmEvents (sizeof(bsdToXF86Array) / sizeof(bsdToXF86Array[0]))
+
+static pmEvent
+bsdToXF86(int type)
+{
+ int i;
+
+ for (i = 0; i < numApmEvents; i++) {
+ if (type == bsdToXF86Array[i].apmBsd) {
+ return bsdToXF86Array[i].xf86;
+ }
+ }
+ return XF86_APM_UNKNOWN;
+}
+
+/*
+ * APM events can be requested direclty from /dev/apm
+ */
+static int
+bsdPMGetEventFromOS(int kq, pmEvent *events, int num)
+{
+ struct kevent ev;
+ int i, result;
+ struct timespec ts = { 0, 0 };
+
+ for (i = 0; i < num; i++) {
+ result = kevent(kq, NULL, 0, &ev, 1, &ts);
+ if (result == 0 || APM_EVENT_TYPE(ev.data) == APM_NOEVENT) {
+ /* no event */
+ break;
+ } else if (result < 0) {
+ xf86Msg(X_WARNING, "bsdPMGetEventFromOS: kevent returns"
+ " errno = %d\n", errno);
+ break;
+ }
+ events[i] = bsdToXF86(APM_EVENT_TYPE(ev.data));
+ }
+ return i;
+}
+
+/*
+ * If apmd(8) is running, he will get the events and handle them,
+ * so, we've nothing to do here.
+ * Otherwise, opening /dev/apmctl will succeed and we have to send the
+ * confirmations to /dev/apmctl.
+ */
+static pmWait
+bsdPMConfirmEventToOs(int dummyfd, pmEvent event)
+{
+ if (ctlFd < 0) {
+ if ((ctlFd = open(_PATH_APM_CTLDEV, O_RDWR)) < 0) {
+ return PM_NONE;
+ }
+ }
+ /* apmctl open succeedeed */
+ switch (event) {
+ case XF86_APM_SYS_STANDBY:
+ case XF86_APM_USER_STANDBY:
+ if (ioctl( ctlFd, APM_IOC_STANDBY, NULL ) == 0)
+ return PM_WAIT; /* should we stop the Xserver in standby, too? */
+ else
+ return PM_NONE;
+
+ case XF86_APM_SYS_SUSPEND:
+ case XF86_APM_CRITICAL_SUSPEND:
+ case XF86_APM_USER_SUSPEND:
+ if (ioctl( ctlFd, APM_IOC_SUSPEND, NULL ) == 0)
+ return PM_WAIT;
+ else
+ return PM_NONE;
+ break;
+ case XF86_APM_STANDBY_RESUME:
+ case XF86_APM_NORMAL_RESUME:
+ case XF86_APM_CRITICAL_RESUME:
+ case XF86_APM_STANDBY_FAILED:
+ case XF86_APM_SUSPEND_FAILED:
+ return PM_CONTINUE;
+ break;
+ default:
+ return PM_NONE;
+ }
+}
+
+PMClose
+xf86OSPMOpen(void)
+{
+ int kq;
+ struct kevent ev;
+
+ if (APMihPtr || !xf86Info.pmFlag) {
+ return NULL;
+ }
+ if ((devFd = open(_PATH_APM_DEV, O_RDONLY)) == -1) {
+ return NULL;
+ }
+ if ((kq = kqueue()) <= 0) {
+ close(devFd);
+ return NULL;
+ }
+ EV_SET(&ev, devFd, EVFILT_READ, EV_ADD | EV_ENABLE | EV_CLEAR,
+ 0, 0, NULL);
+ if (kevent(kq, &ev, 1, NULL, 0, NULL) < 0) {
+ close(devFd);
+ return NULL;
+ }
+
+ xf86PMGetEventFromOs = bsdPMGetEventFromOS;
+ xf86PMConfirmEventToOs = bsdPMConfirmEventToOs;
+ APMihPtr = xf86AddInputHandler(kq, xf86HandlePMEvents, NULL);
+ return bsdCloseAPM;
+}
+
+static void
+bsdCloseAPM(void)
+{
+ int kq;
+
+ if (APMihPtr) {
+ kq = xf86RemoveInputHandler(APMihPtr);
+ close(devFd);
+ devFd = -1;
+ close(kq);
+ if (ctlFd >= 0) {
+ close(ctlFd);
+ ctlFd = -1;
+ }
+ APMihPtr = NULL;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_mouse.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_mouse.c
new file mode 100644
index 000000000..6ef300197
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_mouse.c
@@ -0,0 +1,792 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_mouse.c,v 1.28 2004/02/06 17:15:36 tsi Exp $ */
+
+/*
+ * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+#include "xisb.h"
+#include "mipointer.h"
+#ifdef WSCONS_SUPPORT
+#include <dev/wscons/wsconsio.h>
+#endif
+#ifdef USBMOUSE_SUPPORT
+#ifdef HAS_LIB_USB_HID
+#include <usbhid.h>
+#else
+#include "usb.h"
+#endif
+
+#include <dev/usb/usb.h>
+#ifdef USB_GET_REPORT_ID
+#define USB_NEW_HID
+#endif
+
+#define HUP_GENERIC_DESKTOP 0x0001
+#define HUP_BUTTON 0x0009
+
+#define HUG_X 0x0030
+#define HUG_Y 0x0031
+#define HUG_Z 0x0032
+#define HUG_WHEEL 0x0038
+
+#define HID_USAGE2(p,u) (((p) << 16) | u)
+
+/* The UMS mices have middle button as number 3 */
+#define UMS_BUT(i) ((i) == 0 ? 2 : (i) == 1 ? 0 : (i) == 2 ? 1 : (i))
+#endif /* USBMOUSE_SUPPORT */
+
+#ifdef USBMOUSE_SUPPORT
+static void usbSigioReadInput (int fd, void *closure);
+#endif
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+/* These are for FreeBSD */
+#define DEFAULT_MOUSE_DEV "/dev/mouse"
+#define DEFAULT_SYSMOUSE_DEV "/dev/sysmouse"
+#define DEFAULT_PS2_DEV "/dev/psm0"
+
+static const char *mouseDevs[] = {
+ DEFAULT_MOUSE_DEV,
+ DEFAULT_SYSMOUSE_DEV,
+ DEFAULT_PS2_DEV,
+ NULL
+};
+#elif defined(__OpenBSD__) && defined(WSCONS_SUPPORT)
+/* Only wsmouse mices are autoconfigured for now on OpenBSD */
+#define DEFAULT_WSMOUSE_DEV "/dev/wsmouse"
+#define DEFAULT_WSMOUSE0_DEV "/dev/wsmouse0"
+
+static const char *mouseDevs[] = {
+ DEFAULT_WSMOUSE_DEV,
+ DEFAULT_WSMOUSE0_DEV,
+ NULL
+};
+#endif
+
+static int
+SupportedInterfaces(void)
+{
+#if defined(__NetBSD__)
+ return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO;
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO | MSE_MISC;
+#else
+ return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_AUTO;
+#endif
+}
+
+/* Names of protocols that are handled internally here. */
+static const char *internalNames[] = {
+#if defined(WSCONS_SUPPORT)
+ "WSMouse",
+#endif
+#if defined(USBMOUSE_SUPPORT)
+ "usb",
+#endif
+ NULL
+};
+
+/*
+ * Names of MSC_MISC protocols that the OS supports. These are decoded by
+ * main "mouse" driver.
+ */
+static const char *miscNames[] = {
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ "SysMouse",
+#endif
+ NULL
+};
+
+static const char **
+BuiltinNames(void)
+{
+ return internalNames;
+}
+
+static Bool
+CheckProtocol(const char *protocol)
+{
+ int i;
+
+ for (i = 0; internalNames[i]; i++)
+ if (xf86NameCmp(protocol, internalNames[i]) == 0)
+ return TRUE;
+ for (i = 0; miscNames[i]; i++)
+ if (xf86NameCmp(protocol, miscNames[i]) == 0)
+ return TRUE;
+ return FALSE;
+}
+
+static const char *
+DefaultProtocol(void)
+{
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ return "Auto";
+#elif defined(__OpenBSD__) && defined(WSCONS_SUPPORT)
+ return "WSMouse";
+#else
+ return NULL;
+#endif
+}
+
+#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && defined(MOUSE_PROTO_SYSMOUSE)
+static struct {
+ int dproto;
+ const char *name;
+} devproto[] = {
+ { MOUSE_PROTO_MS, "Microsoft" },
+ { MOUSE_PROTO_MSC, "MouseSystems" },
+ { MOUSE_PROTO_LOGI, "Logitech" },
+ { MOUSE_PROTO_MM, "MMSeries" },
+ { MOUSE_PROTO_LOGIMOUSEMAN, "MouseMan" },
+ { MOUSE_PROTO_BUS, "BusMouse" },
+ { MOUSE_PROTO_INPORT, "BusMouse" },
+ { MOUSE_PROTO_PS2, "PS/2" },
+ { MOUSE_PROTO_HITTAB, "MMHitTab" },
+ { MOUSE_PROTO_GLIDEPOINT, "GlidePoint" },
+ { MOUSE_PROTO_INTELLI, "Intellimouse" },
+ { MOUSE_PROTO_THINK, "ThinkingMouse" },
+ { MOUSE_PROTO_SYSMOUSE, "SysMouse" }
+};
+
+static const char *
+SetupAuto(InputInfoPtr pInfo, int *protoPara)
+{
+ int i;
+ mousehw_t hw;
+ mousemode_t mode;
+
+ if (pInfo->fd == -1)
+ return NULL;
+
+ /* set the driver operation level, if applicable */
+ i = 1;
+ ioctl(pInfo->fd, MOUSE_SETLEVEL, &i);
+
+ /* interrogate the driver and get some intelligence on the device. */
+ hw.iftype = MOUSE_IF_UNKNOWN;
+ hw.model = MOUSE_MODEL_GENERIC;
+ ioctl(pInfo->fd, MOUSE_GETHWINFO, &hw);
+ xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: hw.iftype is %d, hw.model is %d\n",
+ pInfo->name, hw.iftype, hw.model);
+ if (ioctl(pInfo->fd, MOUSE_GETMODE, &mode) == 0) {
+ for (i = 0; i < sizeof(devproto)/sizeof(devproto[0]); ++i) {
+ if (mode.protocol == devproto[i].dproto) {
+ /* override some parameters */
+ if (protoPara) {
+ protoPara[4] = mode.packetsize;
+ protoPara[0] = mode.syncmask[0];
+ protoPara[1] = mode.syncmask[1];
+ }
+ xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: protocol is %s\n",
+ pInfo->name, devproto[i].name);
+ return devproto[i].name;
+ }
+ }
+ }
+ return NULL;
+}
+
+static void
+SetSysMouseRes(InputInfoPtr pInfo, const char *protocol, int rate, int res)
+{
+ mousemode_t mode;
+ MouseDevPtr pMse;
+
+ pMse = pInfo->private;
+
+ mode.rate = rate > 0 ? rate : -1;
+ mode.resolution = res > 0 ? res : -1;
+ mode.accelfactor = -1;
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ if (pMse->autoProbe ||
+ (protocol && xf86NameCmp(protocol, "SysMouse") == 0)) {
+ /*
+ * As the FreeBSD sysmouse driver defaults to protocol level 0
+ * everytime it is opened we enforce protocol level 1 again at
+ * this point.
+ */
+ mode.level = 1;
+ } else
+ mode.level = -1;
+#else
+ mode.level = -1;
+#endif
+ ioctl(pInfo->fd, MOUSE_SETMODE, &mode);
+}
+#endif
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+
+#define MOUSED_PID_FILE "/var/run/moused.pid"
+
+/*
+ * Try to check if moused is running. DEFAULT_SYSMOUSE_DEV is useless without
+ * it. There doesn't seem to be a better way of checking.
+ */
+static Bool
+MousedRunning(void)
+{
+ FILE *f = NULL;
+ unsigned int pid;
+
+ if ((f = fopen(MOUSED_PID_FILE, "r")) != NULL) {
+ if (fscanf(f, "%u", &pid) == 1 && pid > 0) {
+ if (kill(pid, 0) == 0) {
+ fclose(f);
+ return TRUE;
+ }
+ }
+ fclose(f);
+ }
+ return FALSE;
+}
+
+static const char *
+FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ int fd = -1;
+ const char **pdev, *dev = NULL;
+ Bool devMouse = FALSE;
+ struct stat devMouseStat;
+ struct stat sb;
+
+ for (pdev = mouseDevs; *pdev; pdev++) {
+ SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK));
+ if (fd == -1) {
+#ifdef DEBUG
+ ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno));
+#endif
+ } else {
+ /*
+ * /dev/mouse is held until checks for matches with other devices
+ * are done. This is so that when it points to /dev/sysmouse,
+ * the test for whether /dev/sysmouse is usable can be made.
+ */
+ if (!strcmp(*pdev, DEFAULT_MOUSE_DEV)) {
+ if (fstat(fd, &devMouseStat) == 0)
+ devMouse = TRUE;
+ close(fd);
+ continue;
+ } else if (!strcmp(*pdev, DEFAULT_SYSMOUSE_DEV)) {
+ /* Check if /dev/mouse is the same as /dev/sysmouse. */
+ if (devMouse && fstat(fd, &sb) == 0 &&
+ devMouseStat.st_dev == sb.st_dev &&
+ devMouseStat.st_ino == sb.st_ino) {
+ /* If the same, use /dev/sysmouse. */
+ devMouse = FALSE;
+ }
+ close(fd);
+ if (MousedRunning())
+ break;
+ else {
+#ifdef DEBUG
+ ErrorF("moused isn't running\n");
+#endif
+ }
+ } else {
+ close(fd);
+ break;
+ }
+ }
+ }
+
+ if (*pdev)
+ dev = *pdev;
+ else if (devMouse)
+ dev = DEFAULT_MOUSE_DEV;
+
+ if (dev) {
+ /* Set the Device option. */
+ pInfo->conf_idev->commonOptions =
+ xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", dev);
+ xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
+ pInfo->name, dev);
+ }
+
+ return *pdev;
+}
+#endif
+
+#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT)
+
+/* Only support wsmouse configuration for now */
+static const char *
+SetupAuto(InputInfoPtr pInfo, int *protoPara)
+{
+
+ xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: protocol is %s\n",
+ pInfo->name, "wsmouse");
+ return "wsmouse";
+}
+
+static void
+SetMouseRes(InputInfoPtr pInfo, const char *protocol, int rate, int res)
+{
+
+ xf86MsgVerb(X_INFO, 3, "%s: SetMouseRes: protocol %s rate %d res %d\n",
+ pInfo->name, protocol, rate, res);
+}
+
+static const char *
+FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ int fd = -1;
+ const char **pdev;
+
+ for (pdev = mouseDevs; *pdev; pdev++) {
+ SYSCALL(fd = open(*pdev, O_RDWR | O_NONBLOCK));
+ if (fd != -1) {
+ /* Set the Device option. */
+ pInfo->conf_idev->commonOptions =
+ xf86AddNewOption(pInfo->conf_idev->commonOptions,
+ "Device", *pdev);
+ xf86Msg(X_INFO, "%s: found Device \"%s\"\n",
+ pInfo->name, *pdev);
+ close(fd);
+ break;
+ }
+ }
+ return *pdev;
+}
+#endif /* __OpenBSD__ && WSCONS_SUPPORT */
+
+#ifdef WSCONS_SUPPORT
+#define NUMEVENTS 64
+
+static void
+wsconsReadInput(InputInfoPtr pInfo)
+{
+ MouseDevPtr pMse;
+ static struct wscons_event eventList[NUMEVENTS];
+ int n, c;
+ struct wscons_event *event = eventList;
+ unsigned char *pBuf;
+
+ pMse = pInfo->private;
+
+ XisbBlockDuration(pMse->buffer, -1);
+ pBuf = (unsigned char *)eventList;
+ n = 0;
+ while ((c = XisbRead(pMse->buffer)) >= 0 && n < sizeof(eventList)) {
+ pBuf[n++] = (unsigned char)c;
+ }
+
+ if (n == 0)
+ return;
+
+ n /= sizeof(struct wscons_event);
+ while( n-- ) {
+ int buttons = pMse->lastButtons;
+ int dx = 0, dy = 0, dz = 0, dw = 0;
+ switch (event->type) {
+ case WSCONS_EVENT_MOUSE_UP:
+#define BUTBIT (1 << (event->value <= 2 ? 2 - event->value : event->value))
+ buttons &= ~BUTBIT;
+ break;
+ case WSCONS_EVENT_MOUSE_DOWN:
+ buttons |= BUTBIT;
+ break;
+ case WSCONS_EVENT_MOUSE_DELTA_X:
+ dx = event->value;
+ break;
+ case WSCONS_EVENT_MOUSE_DELTA_Y:
+ dy = -event->value;
+ break;
+#ifdef WSCONS_EVENT_MOUSE_DELTA_Z
+ case WSCONS_EVENT_MOUSE_DELTA_Z:
+ dz = event->value;
+ break;
+#endif
+ default:
+ xf86Msg(X_WARNING, "%s: bad wsmouse event type=%d\n", pInfo->name,
+ event->type);
+ ++event;
+ continue;
+ }
+
+ pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw);
+ ++event;
+ }
+ return;
+}
+
+
+/* This function is called when the protocol is "wsmouse". */
+static Bool
+wsconsPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ MouseDevPtr pMse = pInfo->private;
+
+ pMse->protocol = protocol;
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
+
+ /* Collect the options, and process the common options. */
+ xf86CollectInputOptions(pInfo, NULL, NULL);
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
+
+ /* Check if the device can be opened. */
+ pInfo->fd = xf86OpenSerial(pInfo->options);
+ if (pInfo->fd == -1) {
+ if (xf86GetAllowMouseOpenFail())
+ xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
+ else {
+ xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
+ xfree(pMse);
+ return FALSE;
+ }
+ }
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+
+ /* Process common mouse options (like Emulate3Buttons, etc). */
+ pMse->CommonOptions(pInfo);
+
+ /* Setup the local input proc. */
+ pInfo->read_input = wsconsReadInput;
+ pMse->xisbscale = sizeof(struct wscons_event);
+
+ pInfo->flags |= XI86_CONFIGURED;
+ return TRUE;
+}
+#endif
+
+#if defined(USBMOUSE_SUPPORT)
+
+typedef struct _UsbMseRec {
+ int packetSize;
+ int iid;
+ hid_item_t loc_x; /* x locator item */
+ hid_item_t loc_y; /* y locator item */
+ hid_item_t loc_z; /* z (wheel) locator item */
+ hid_item_t loc_btn[MSE_MAXBUTTONS]; /* buttons locator items */
+ unsigned char *buffer;
+} UsbMseRec, *UsbMsePtr;
+
+static int
+usbMouseProc(DeviceIntPtr pPointer, int what)
+{
+ InputInfoPtr pInfo;
+ MouseDevPtr pMse;
+ UsbMsePtr pUsbMse;
+ unsigned char map[MSE_MAXBUTTONS + 1];
+ int nbuttons;
+
+ pInfo = pPointer->public.devicePrivate;
+ pMse = pInfo->private;
+ pMse->device = pPointer;
+ pUsbMse = pMse->mousePriv;
+
+ switch (what) {
+ case DEVICE_INIT:
+ pPointer->public.on = FALSE;
+
+ for (nbuttons = 0; nbuttons < MSE_MAXBUTTONS; ++nbuttons)
+ map[nbuttons + 1] = nbuttons + 1;
+
+ InitPointerDeviceStruct((DevicePtr)pPointer,
+ map,
+ min(pMse->buttons, MSE_MAXBUTTONS),
+ miPointerGetMotionEvents,
+ pMse->Ctrl,
+ miPointerGetMotionBufferSize());
+
+ /* X valuator */
+ xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 0);
+ /* Y valuator */
+ xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 1);
+ xf86MotionHistoryAllocate(pInfo);
+ break;
+
+ case DEVICE_ON:
+ pInfo->fd = xf86OpenSerial(pInfo->options);
+ if (pInfo->fd == -1)
+ xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
+ else {
+ pMse->buffer = XisbNew(pInfo->fd, pUsbMse->packetSize);
+ if (!pMse->buffer) {
+ xfree(pMse);
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ } else {
+ xf86FlushInput(pInfo->fd);
+ if (!xf86InstallSIGIOHandler (pInfo->fd, usbSigioReadInput,
+ pInfo))
+ AddEnabledDevice(pInfo->fd);
+ }
+ }
+ pMse->lastButtons = 0;
+ pMse->lastMappedButtons = 0;
+ pMse->emulateState = 0;
+ pPointer->public.on = TRUE;
+ break;
+
+ case DEVICE_OFF:
+ case DEVICE_CLOSE:
+ if (pInfo->fd != -1) {
+ RemoveEnabledDevice(pInfo->fd);
+ if (pUsbMse->packetSize > 8 && pUsbMse->buffer) {
+ xfree(pUsbMse->buffer);
+ }
+ if (pMse->buffer) {
+ XisbFree(pMse->buffer);
+ pMse->buffer = NULL;
+ }
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ }
+ pPointer->public.on = FALSE;
+ usleep(300000);
+ break;
+ }
+ return Success;
+}
+
+static void
+usbReadInput(InputInfoPtr pInfo)
+{
+ MouseDevPtr pMse;
+ UsbMsePtr pUsbMse;
+ int buttons = pMse->lastButtons;
+ int dx = 0, dy = 0, dz = 0, dw = 0;
+ int n, c;
+ unsigned char *pBuf;
+
+ pMse = pInfo->private;
+ pUsbMse = pMse->mousePriv;
+
+ XisbBlockDuration(pMse->buffer, -1);
+ pBuf = pUsbMse->buffer;
+ n = 0;
+ while ((c = XisbRead(pMse->buffer)) >= 0 && n < pUsbMse->packetSize) {
+ pBuf[n++] = (unsigned char)c;
+ }
+ if (n == 0)
+ return;
+ if (n != pUsbMse->packetSize) {
+ xf86Msg(X_WARNING, "%s: incomplete packet, size %d\n", pInfo->name,
+ n);
+ }
+ /* discard packets with an id that don't match the mouse */
+ /* XXX this is probably not the right thing */
+ if (pUsbMse->iid != 0) {
+ if (*pBuf++ != pUsbMse->iid)
+ return;
+ }
+ dx = hid_get_data(pBuf, &pUsbMse->loc_x);
+ dy = hid_get_data(pBuf, &pUsbMse->loc_y);
+ dz = hid_get_data(pBuf, &pUsbMse->loc_z);
+
+ buttons = 0;
+ for (n = 0; n < pMse->buttons; n++) {
+ if (hid_get_data(pBuf, &pUsbMse->loc_btn[n]))
+ buttons |= (1 << UMS_BUT(n));
+ }
+ pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw);
+ return;
+}
+
+static void
+usbSigioReadInput (int fd, void *closure)
+{
+ usbReadInput ((InputInfoPtr) closure);
+}
+
+/* This function is called when the protocol is "usb". */
+static Bool
+usbPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ MouseDevPtr pMse = pInfo->private;
+ UsbMsePtr pUsbMse;
+ report_desc_t reportDesc;
+ int i;
+
+ pUsbMse = xalloc(sizeof(UsbMseRec));
+ if (pUsbMse == NULL) {
+ xf86Msg(X_ERROR, "%s: cannot allocate UsbMouseRec\n", pInfo->name);
+ xfree(pMse);
+ return FALSE;
+ }
+
+ pMse->protocol = protocol;
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
+
+ /* Collect the options, and process the common options. */
+ xf86CollectInputOptions(pInfo, NULL, NULL);
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
+
+ /* Check if the device can be opened. */
+ pInfo->fd = xf86OpenSerial(pInfo->options);
+ if (pInfo->fd == -1) {
+ if (xf86GetAllowMouseOpenFail())
+ xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
+ else {
+ xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
+ xfree(pUsbMse);
+ xfree(pMse);
+ return FALSE;
+ }
+ }
+ /* Get USB informations */
+ reportDesc = hid_get_report_desc(pInfo->fd);
+ /* Get packet size & iid */
+#ifdef USB_NEW_HID
+ if (ioctl(pInfo->fd, USB_GET_REPORT_ID, &pUsbMse->iid) == -1) {
+ xf86Msg(X_ERROR, "Error ioctl USB_GET_REPORT_ID on %s : %s\n",
+ pInfo->name, strerror(errno));
+ return FALSE;
+ }
+ pUsbMse->packetSize = hid_report_size(reportDesc, hid_input,
+ pUsbMse->iid);
+#else
+ pUsbMse->packetSize = hid_report_size(reportDesc, hid_input,
+ &pUsbMse->iid);
+#endif
+ /* Allocate buffer */
+ if (pUsbMse->packetSize <= 8) {
+ pUsbMse->buffer = pMse->protoBuf;
+ } else {
+ pUsbMse->buffer = xalloc(pUsbMse->packetSize);
+ }
+ if (pUsbMse->buffer == NULL) {
+ xf86Msg(X_ERROR, "%s: cannot allocate buffer\n", pInfo->name);
+ xfree(pUsbMse);
+ xfree(pMse);
+ xf86CloseSerial(pInfo->fd);
+ return FALSE;
+ }
+#ifdef USB_NEW_HID
+ if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X),
+ hid_input, &pUsbMse->loc_x, pUsbMse->iid) < 0) {
+ xf86Msg(X_WARNING, "%s: no x locator\n", pInfo->name);
+ }
+ if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y),
+ hid_input, &pUsbMse->loc_y, pUsbMse->iid) < 0) {
+ xf86Msg(X_WARNING, "%s: no y locator\n", pInfo->name);
+ }
+ if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_WHEEL),
+ hid_input, &pUsbMse->loc_z, pUsbMse->iid) < 0) {
+ }
+#else
+ if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X),
+ hid_input, &pUsbMse->loc_x) < 0) {
+ xf86Msg(X_WARNING, "%s: no x locator\n", pInfo->name);
+ }
+ if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y),
+ hid_input, &pUsbMse->loc_y) < 0) {
+ xf86Msg(X_WARNING, "%s: no y locator\n", pInfo->name);
+ }
+ if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_WHEEL),
+ hid_input, &pUsbMse->loc_z) < 0) {
+ }
+#endif
+ /* Probe for number of buttons */
+ for (i = 1; i <= MSE_MAXBUTTONS; i++) {
+ if (!hid_locate(reportDesc, HID_USAGE2(HUP_BUTTON, i),
+ hid_input, &pUsbMse->loc_btn[i-1]
+#ifdef USB_NEW_HID
+ , pUsbMse->iid
+#endif
+ ))
+ break;
+ }
+ pMse->buttons = i-1;
+
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+
+ /* Private structure */
+ pMse->mousePriv = pUsbMse;
+
+ /* Process common mouse options (like Emulate3Buttons, etc). */
+ pMse->CommonOptions(pInfo);
+
+ /* Setup the local procs. */
+ pInfo->device_control = usbMouseProc;
+ pInfo->read_input = usbReadInput;
+
+ pInfo->flags |= XI86_CONFIGURED;
+ return TRUE;
+}
+#endif /* USBMOUSE */
+
+static Bool
+bsdMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ /* The protocol is guaranteed to be one of the internalNames[] */
+#ifdef WSCONS_SUPPORT
+ if (xf86NameCmp(protocol, "WSMouse") == 0) {
+ return wsconsPreInit(pInfo, protocol, flags);
+ }
+#endif
+#ifdef USBMOUSE_SUPPORT
+ if (xf86NameCmp(protocol, "usb") == 0) {
+ return usbPreInit(pInfo, protocol, flags);
+ }
+#endif
+ return TRUE;
+}
+
+OSMouseInfoPtr
+xf86OSMouseInit(int flags)
+{
+ OSMouseInfoPtr p;
+
+ p = xcalloc(sizeof(OSMouseInfoRec), 1);
+ if (!p)
+ return NULL;
+ p->SupportedInterfaces = SupportedInterfaces;
+ p->BuiltinNames = BuiltinNames;
+ p->DefaultProtocol = DefaultProtocol;
+ p->CheckProtocol = CheckProtocol;
+#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && defined(MOUSE_PROTO_SYSMOUSE)
+ p->SetupAuto = SetupAuto;
+ p->SetPS2Res = SetSysMouseRes;
+ p->SetBMRes = SetSysMouseRes;
+ p->SetMiscRes = SetSysMouseRes;
+#endif
+#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT)
+ p->SetupAuto = SetupAuto;
+ p->SetMiscRes = SetMouseRes;
+#endif
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+ p->FindDevice = FindDevice;
+#endif
+ p->PreInit = bsdMousePreInit;
+ return p;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile
new file mode 100644
index 000000000..9cb04a516
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile
@@ -0,0 +1,63 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile,v 1.14 2003/05/08 21:49:01 herrb Exp $
+XCOMM $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile,v 1.7 1999/09/14 19:55:15 faith Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#if DoLoadableServer
+MSRC = drmmodule.c
+MOBJ = drmmodule.o
+#endif
+
+#if BuildXF86DRI
+#if HasMTRRSupport
+MTRR_DEFINES = -DHAS_MTRR_SUPPORT
+#endif
+
+#if defined(KFreeBSDArchitecture)
+OS_SUBDIR = freebsd
+#elif defined(NetBSDArchitecture)
+OS_SUBDIR = netbsd
+#elif defined(OpenBSDArchitecture)
+OS_SUBDIR = openbsd
+#else
+OS_SUBDIR = extensions
+#endif
+
+ SRCS = xf86drm.c \
+ xf86drmHash.c \
+ xf86drmRandom.c \
+ xf86drmSL.c \
+ $(MSRC)
+
+ OBJS = xf86drm.o \
+ xf86drmHash.o \
+ xf86drmRandom.o \
+ xf86drmSL.o \
+ $(MOBJ)
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(EXTINCSRC) -I../.. -I$(DRMSRCDIR)/bsd-core \
+ -I$(DRMSRCDIR)/shared-core
+
+DEFINES = $(MTRR_DEFINES) $(GLX_DEFINES)
+
+ModuleObjectRule()
+LibraryModuleTarget(drm,$(OBJS))
+NormalLintTarget($(SRCS))
+
+InstallLibraryModule(drm,$(MODULEDIR),$(OS_SUBDIR))
+#endif
+
+DependTarget()
+
+LIBDRM_DIR = ../../../../../../../extras/drm/libdrm
+#if DoLoadableServer
+LinkSourceFile(drmmodule.c,$(XF86OSSRC)/linux/drm)
+#endif
+LinkSourceFile(xf86drm.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmHash.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmRandom.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmSL.c,$(LIBDRM_DIR))
+
+InstallDriverSDKLibraryModule(drm,$(DRIVERSDKMODULEDIR),$(OS_SUBDIR))
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/i386_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/i386_video.c
new file mode 100644
index 000000000..3f4cdb010
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/i386_video.c
@@ -0,0 +1,999 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/i386_video.c,v 1.4 2003/09/24 02:43:34 dawes Exp $ */
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/* $XConsortium: bsd_video.c /main/10 1996/10/25 11:37:57 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+
+#include <errno.h>
+#include <sys/mman.h>
+
+#ifdef HAS_MTRR_SUPPORT
+#ifndef __NetBSD__
+#include <sys/types.h>
+#include <sys/memrange.h>
+#else
+#include "memrange.h"
+#endif
+#define X_MTRR_ID "XFree86"
+#endif
+
+#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
+#include <machine/mtrr.h>
+#include <machine/sysarch.h>
+#include <sys/queue.h>
+#endif
+
+#if defined(__OpenBSD__) && defined(__amd64__)
+#include <machine/mtrr.h>
+#include <machine/sysarch.h>
+#endif
+
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#if defined(__NetBSD__) && !defined(MAP_FILE)
+#define MAP_FLAGS MAP_SHARED
+#else
+#define MAP_FLAGS (MAP_FILE | MAP_SHARED)
+#endif
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)-1)
+#endif
+
+#ifdef __OpenBSD__
+#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\
+ "\tin /etc/sysctl.conf and reboot your machine\n" \
+ "\trefer to xf86(4) for details"
+#define SYSCTL_MSG2 \
+ "Check that you have set 'machdep.allowaperture=2'\n" \
+ "\tin /etc/sysctl.conf and reboot your machine\n" \
+ "\trefer to xf86(4) for details"
+#endif
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+static Bool useDevMem = FALSE;
+static int devMemFd = -1;
+
+#ifdef HAS_APERTURE_DRV
+#define DEV_APERTURE "/dev/xf86"
+#endif
+#define DEV_MEM "/dev/mem"
+
+static pointer mapVidMem(int, unsigned long, unsigned long, int);
+static void unmapVidMem(int, pointer, unsigned long);
+
+#ifdef HAS_MTRR_SUPPORT
+static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType);
+static void undoWC(int, pointer);
+static Bool cleanMTRR(void);
+#endif
+#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
+static pointer NetBSDsetWC(int, unsigned long, unsigned long, Bool,
+ MessageType);
+static void NetBSDundoWC(int, pointer);
+#endif
+#if defined(__amd64__) && defined(__OpenBSD__)
+static pointer amd64setWC(int, unsigned long, unsigned long, Bool,
+ MessageType);
+static void amd64undoWC(int, pointer);
+#endif
+
+/*
+ * Check if /dev/mem can be mmap'd. If it can't print a warning when
+ * "warn" is TRUE.
+ */
+static void
+checkDevMem(Bool warn)
+{
+ static Bool devMemChecked = FALSE;
+ int fd;
+ pointer base;
+
+ if (devMemChecked)
+ return;
+ devMemChecked = TRUE;
+
+ if ((fd = open(DEV_MEM, O_RDWR)) >= 0)
+ {
+ /* Try to map a page at the VGA address */
+ base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0xA0000);
+
+ if (base != MAP_FAILED)
+ {
+ munmap((caddr_t)base, 4096);
+ devMemFd = fd;
+ useDevMem = TRUE;
+ return;
+ } else {
+ /* This should not happen */
+ if (warn)
+ {
+ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ useDevMem = FALSE;
+ return;
+ }
+ }
+#ifndef HAS_APERTURE_DRV
+ if (warn)
+ {
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ useDevMem = FALSE;
+ return;
+#else
+ /* Failed to open /dev/mem, try the aperture driver */
+ if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0)
+ {
+ /* Try to map a page at the VGA address */
+ base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0xA0000);
+
+ if (base != MAP_FAILED)
+ {
+ munmap((caddr_t)base, 4096);
+ devMemFd = fd;
+ useDevMem = TRUE;
+ xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n",
+ DEV_APERTURE);
+ return;
+ } else {
+
+ if (warn)
+ {
+ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
+ DEV_APERTURE, strerror(errno));
+ }
+ }
+ } else {
+ if (warn)
+ {
+#ifndef __OpenBSD__
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
+ "\t(%s)\n", DEV_MEM, DEV_APERTURE, strerror(errno));
+#else /* __OpenBSD__ */
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
+ "\t(%s)\n%s", DEV_MEM, DEV_APERTURE, strerror(errno),
+ SYSCTL_MSG);
+#endif /* __OpenBSD__ */
+ }
+ }
+
+ useDevMem = FALSE;
+ return;
+
+#endif
+}
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ checkDevMem(TRUE);
+ pVidMem->linearSupported = useDevMem;
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+
+#ifdef HAS_MTRR_SUPPORT
+ if (useDevMem) {
+ if (cleanMTRR()) {
+ pVidMem->setWC = setWC;
+ pVidMem->undoWC = undoWC;
+ }
+ }
+#endif
+#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
+ pVidMem->setWC = NetBSDsetWC;
+ pVidMem->undoWC = NetBSDundoWC;
+#endif
+#if defined(__amd64__) && defined(__OpenBSD__)
+ pVidMem->setWC = amd64setWC;
+ pVidMem->undoWC = amd64undoWC;
+#endif
+ pVidMem->initialised = TRUE;
+}
+
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ pointer base;
+
+ checkDevMem(FALSE);
+
+ if (useDevMem)
+ {
+ if (devMemFd < 0)
+ {
+ FatalError("xf86MapVidMem: failed to open %s (%s)",
+ DEV_MEM, strerror(errno));
+ }
+ base = mmap((caddr_t)0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, devMemFd, (off_t)Base);
+ if (base == MAP_FAILED)
+ {
+ FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)",
+ "xf86MapVidMem", DEV_MEM, Size, Base,
+ strerror(errno));
+ }
+ return(base);
+ }
+
+ /* else, mmap /dev/vga */
+ if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
+ {
+ FatalError("%s: Address 0x%lx outside allowable range",
+ "xf86MapVidMem", Base);
+ }
+ base = mmap(0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, xf86Info.screenFd,
+ (unsigned long)Base - 0xA0000
+ );
+ if (base == MAP_FAILED)
+ {
+ FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)",
+ strerror(errno));
+ }
+ return(base);
+}
+
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap((caddr_t)Base, Size);
+}
+
+/*
+ * Read BIOS via mmap()ing DEV_MEM
+ */
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ unsigned char *ptr;
+ int psize;
+ int mlen;
+
+ checkDevMem(TRUE);
+ if (devMemFd == -1) {
+ return(-1);
+ }
+
+ psize = xf86getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
+ MAP_SHARED, devMemFd, (off_t)Base);
+ if ((long)ptr == -1)
+ {
+ xf86Msg(X_WARNING,
+ "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n",
+ DEV_MEM, Len, Base, Offset, strerror(errno));
+#ifdef __OpenBSD__
+ if (Base < 0xa0000) {
+ xf86Msg(X_WARNING, SYSCTL_MSG2);
+ }
+#endif
+ return(-1);
+ }
+#ifdef DEBUG
+ ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
+ Base, ptr[0] | (ptr[1] << 8));
+#endif
+ (void)memcpy(Buf, (void *)(ptr + Offset), Len);
+ (void)munmap((caddr_t)ptr, mlen);
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
+ "-> %02x %02x %02x %02x...\n",
+ Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
+#endif
+ return(Len);
+}
+
+#ifdef USE_I386_IOPL
+/***************************************************************************/
+/* I/O Permissions section */
+/***************************************************************************/
+
+static Bool ExtendedEnabled = FALSE;
+
+Bool
+xf86EnableIO()
+{
+ if (ExtendedEnabled)
+ return TRUE;
+
+ if (i386_iopl(TRUE) < 0)
+ {
+#ifndef __OpenBSD__
+ xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O",
+ "xf86EnableIO");
+#else
+ xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O\n%s",
+ "xf86EnableIO", SYSCTL_MSG);
+#endif
+ return FALSE;
+ }
+ ExtendedEnabled = TRUE;
+
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ if (!ExtendedEnabled)
+ return;
+
+ i386_iopl(FALSE);
+ ExtendedEnabled = FALSE;
+
+ return;
+}
+
+#endif /* USE_I386_IOPL */
+
+#ifdef USE_AMD64_IOPL
+/***************************************************************************/
+/* I/O Permissions section */
+/***************************************************************************/
+
+static Bool ExtendedEnabled = FALSE;
+
+Bool
+xf86EnableIO()
+{
+ if (ExtendedEnabled)
+ return TRUE;
+
+ if (amd64_iopl(TRUE) < 0)
+ {
+#ifndef __OpenBSD__
+ xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O",
+ "xf86EnableIO");
+#else
+ xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O\n%s",
+ "xf86EnableIO", SYSCTL_MSG);
+#endif
+ return FALSE;
+ }
+ ExtendedEnabled = TRUE;
+
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ if (!ExtendedEnabled)
+ return;
+
+ if (amd64_iopl(FALSE) == 0) {
+ ExtendedEnabled = FALSE;
+ }
+ /* Otherwise, the X server has revoqued its root uid,
+ and thus cannot give up IO privileges any more */
+
+ return;
+}
+
+#endif /* USE_AMD64_IOPL */
+
+#ifdef USE_DEV_IO
+static int IoFd = -1;
+
+Bool
+xf86EnableIO()
+{
+ if (IoFd >= 0)
+ return TRUE;
+
+ if ((IoFd = open("/dev/io", O_RDWR)) == -1)
+ {
+ xf86Msg(X_WARNING,"xf86EnableIO: "
+ "Failed to open /dev/io for extended I/O");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ if (IoFd < 0)
+ return;
+
+ close(IoFd);
+ IoFd = -1;
+ return;
+}
+
+#endif
+
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+Bool
+xf86DisableInterrupts()
+{
+
+#ifdef __GNUC__
+ __asm__ __volatile__("cli");
+#else
+ asm("cli");
+#endif /* __GNUC__ */
+
+ return(TRUE);
+}
+
+void
+xf86EnableInterrupts()
+{
+
+#ifdef __GNUC__
+ __asm__ __volatile__("sti");
+#else
+ asm("sti");
+#endif /* __GNUC__ */
+
+ return;
+}
+
+
+#ifdef __NetBSD__
+/***************************************************************************/
+/* Set TV output mode */
+/***************************************************************************/
+void
+xf86SetTVOut(int mode)
+{
+ switch (xf86Info.consType)
+ {
+#ifdef PCCONS_SUPPORT
+ case PCCONS:{
+
+ if (ioctl (xf86Info.consoleFd, CONSOLE_X_TV_ON, &mode) < 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86SetTVOut: Could not set console to TV output, %s\n",
+ strerror(errno));
+ }
+ }
+ break;
+#endif /* PCCONS_SUPPORT */
+
+ default:
+ FatalError("Xf86SetTVOut: Unsupported console");
+ break;
+ }
+ return;
+}
+
+void
+xf86SetRGBOut()
+{
+ switch (xf86Info.consType)
+ {
+#ifdef PCCONS_SUPPORT
+ case PCCONS:{
+
+ if (ioctl (xf86Info.consoleFd, CONSOLE_X_TV_OFF, 0) < 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86SetTVOut: Could not set console to RGB output, %s\n",
+ strerror(errno));
+ }
+ }
+ break;
+#endif /* PCCONS_SUPPORT */
+
+ default:
+ FatalError("Xf86SetTVOut: Unsupported console");
+ break;
+ }
+ return;
+}
+#endif
+
+#ifdef HAS_MTRR_SUPPORT
+/* memory range (MTRR) support for FreeBSD */
+
+/*
+ * This code is experimental. Some parts may be overkill, and other parts
+ * may be incomplete.
+ */
+
+/*
+ * getAllRanges returns the full list of memory ranges with attributes set.
+ */
+
+static struct mem_range_desc *
+getAllRanges(int *nmr)
+{
+ struct mem_range_desc *mrd;
+ struct mem_range_op mro;
+
+ /*
+ * Find how many ranges there are. If this fails, then the kernel
+ * probably doesn't have MTRR support.
+ */
+ mro.mo_arg[0] = 0;
+ if (ioctl(devMemFd, MEMRANGE_GET, &mro))
+ return NULL;
+ *nmr = mro.mo_arg[0];
+ mrd = xnfalloc(*nmr * sizeof(struct mem_range_desc));
+ mro.mo_arg[0] = *nmr;
+ mro.mo_desc = mrd;
+ if (ioctl(devMemFd, MEMRANGE_GET, &mro)) {
+ xfree(mrd);
+ return NULL;
+ }
+ return mrd;
+}
+
+/*
+ * cleanMTRR removes any memory attribute that may be left by a previous
+ * X server. Normally there won't be any, but this takes care of the
+ * case where a server crashed without being able finish cleaning up.
+ */
+
+static Bool
+cleanMTRR()
+{
+ struct mem_range_desc *mrd;
+ struct mem_range_op mro;
+ int nmr, i;
+
+ /* This shouldn't happen */
+ if (devMemFd < 0)
+ return FALSE;
+
+ if (!(mrd = getAllRanges(&nmr)))
+ return FALSE;
+
+ for (i = 0; i < nmr; i++) {
+ if (strcmp(mrd[i].mr_owner, X_MTRR_ID) == 0 &&
+ (mrd[i].mr_flags & MDF_ACTIVE)) {
+#ifdef DEBUG
+ ErrorF("Clean for (0x%lx,0x%lx)\n",
+ (unsigned long)mrd[i].mr_base,
+ (unsigned long)rd[i].mr_len);
+#endif
+ if (mrd[i].mr_flags & MDF_FIXACTIVE) {
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ mrd[i].mr_flags = MDF_UNCACHEABLE;
+ } else {
+ mro.mo_arg[0] = MEMRANGE_SET_REMOVE;
+ }
+ mro.mo_desc = mrd + i;
+ ioctl(devMemFd, MEMRANGE_SET, &mro);
+ }
+ }
+#ifdef DEBUG
+ sleep(10);
+#endif
+ xfree(mrd);
+ return TRUE;
+}
+
+typedef struct x_RangeRec {
+ struct mem_range_desc mrd;
+ Bool wasWC;
+ struct x_RangeRec * next;
+} RangeRec, *RangePtr;
+
+static void
+freeRangeList(RangePtr range)
+{
+ RangePtr rp;
+
+ while (range) {
+ rp = range;
+ range = rp->next;
+ xfree(rp);
+ }
+}
+
+static RangePtr
+dupRangeList(RangePtr list)
+{
+ RangePtr new = NULL, rp, p;
+
+ rp = list;
+ while (rp) {
+ p = xnfalloc(sizeof(RangeRec));
+ *p = *rp;
+ p->next = new;
+ new = p;
+ rp = rp->next;
+ }
+ return new;
+}
+
+static RangePtr
+sortRangeList(RangePtr list)
+{
+ RangePtr rp1, rp2, copy, sorted = NULL, minp, prev, minprev;
+ unsigned long minBase;
+
+ /* Sort by base address */
+ rp1 = copy = dupRangeList(list);
+ while (rp1) {
+ minBase = rp1->mrd.mr_base;
+ minp = rp1;
+ minprev = NULL;
+ prev = rp1;
+ rp2 = rp1->next;
+ while (rp2) {
+ if (rp2->mrd.mr_base < minBase) {
+ minBase = rp2->mrd.mr_base;
+ minp = rp2;
+ minprev = prev;
+ }
+ prev = rp2;
+ rp2 = rp2->next;
+ }
+ if (minprev) {
+ minprev->next = minp->next;
+ rp1 = copy;
+ } else {
+ rp1 = minp->next;
+ }
+ minp->next = sorted;
+ sorted = minp;
+ }
+ return sorted;
+}
+
+/*
+ * findRanges returns a list of ranges that overlap the specified range.
+ */
+
+static void
+findRanges(unsigned long base, unsigned long size, RangePtr *ucp, RangePtr *wcp)
+{
+ struct mem_range_desc *mrd;
+ int nmr, i;
+ RangePtr rp, *p;
+
+ if (!(mrd = getAllRanges(&nmr)))
+ return;
+
+ for (i = 0; i < nmr; i++) {
+ if ((mrd[i].mr_flags & MDF_ACTIVE) &&
+ mrd[i].mr_base < base + size &&
+ mrd[i].mr_base + mrd[i].mr_len > base) {
+ if (mrd[i].mr_flags & MDF_WRITECOMBINE)
+ p = wcp;
+ else if (mrd[i].mr_flags & MDF_UNCACHEABLE)
+ p = ucp;
+ else
+ continue;
+ rp = xnfalloc(sizeof(RangeRec));
+ rp->mrd = mrd[i];
+ rp->next = *p;
+ *p = rp;
+ }
+ }
+ xfree(mrd);
+}
+
+/*
+ * This checks if the existing overlapping ranges fully cover the requested
+ * range. Is this overkill?
+ */
+
+static Bool
+fullCoverage(unsigned long base, unsigned long size, RangePtr overlap)
+{
+ RangePtr rp1, sorted = NULL;
+ unsigned long end;
+
+ sorted = sortRangeList(overlap);
+ /* Look for gaps */
+ rp1 = sorted;
+ end = base + size;
+ while (rp1) {
+ if (rp1->mrd.mr_base > base) {
+ freeRangeList(sorted);
+ return FALSE;
+ } else {
+ base = rp1->mrd.mr_base + rp1->mrd.mr_len;
+ }
+ if (base >= end) {
+ freeRangeList(sorted);
+ return TRUE;
+ }
+ rp1 = rp1->next;
+ }
+ freeRangeList(sorted);
+ return FALSE;
+}
+
+static pointer
+addWC(int screenNum, unsigned long base, unsigned long size, MessageType from)
+{
+ RangePtr uc = NULL, wc = NULL, retlist = NULL;
+ struct mem_range_desc mrd;
+ struct mem_range_op mro;
+
+ findRanges(base, size, &uc, &wc);
+
+ /* See of the full range is already WC */
+ if (!uc && fullCoverage(base, size, wc)) {
+ xf86DrvMsg(screenNum, from,
+ "Write-combining range (0x%lx,0x%lx) was already set\n",
+ base, size);
+ return NULL;
+ }
+
+ /* Otherwise, try to add the new range */
+ mrd.mr_base = base;
+ mrd.mr_len = size;
+ strcpy(mrd.mr_owner, X_MTRR_ID);
+ mrd.mr_flags = MDF_WRITECOMBINE;
+ mro.mo_desc = &mrd;
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "Failed to set write-combining range "
+ "(0x%lx,0x%lx)\n", base, size);
+ return NULL;
+ } else {
+ xf86DrvMsg(screenNum, from,
+ "Write-combining range (0x%lx,0x%lx)\n", base, size);
+ retlist = xnfalloc(sizeof(RangeRec));
+ retlist->mrd = mrd;
+ retlist->wasWC = FALSE;
+ retlist->next = NULL;
+ return retlist;
+ }
+}
+
+static pointer
+delWC(int screenNum, unsigned long base, unsigned long size, MessageType from)
+{
+ RangePtr uc = NULL, wc = NULL, retlist = NULL;
+ struct mem_range_desc mrd;
+ struct mem_range_op mro;
+
+ findRanges(base, size, &uc, &wc);
+
+ /*
+ * See of the full range is already not WC, or if there is full
+ * coverage from UC ranges.
+ */
+ if (!wc || fullCoverage(base, size, uc)) {
+ xf86DrvMsg(screenNum, from,
+ "Write-combining range (0x%lx,0x%lx) was already clear\n",
+ base, size);
+ return NULL;
+ }
+
+ /* Otherwise, try to add the new range */
+ mrd.mr_base = base;
+ mrd.mr_len = size;
+ strcpy(mrd.mr_owner, X_MTRR_ID);
+ mrd.mr_flags = MDF_UNCACHEABLE;
+ mro.mo_desc = &mrd;
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "Failed to remove write-combining range "
+ "(0x%lx,0x%lx)\n", base, size);
+ /* XXX Should then remove all of the overlapping WC ranges */
+ return NULL;
+ } else {
+ xf86DrvMsg(screenNum, from,
+ "Removed Write-combining range (0x%lx,0x%lx)\n",
+ base, size);
+ retlist = xnfalloc(sizeof(RangeRec));
+ retlist->mrd = mrd;
+ retlist->wasWC = TRUE;
+ retlist->next = NULL;
+ return retlist;
+ }
+}
+
+static pointer
+setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
+ MessageType from)
+{
+ if (enable)
+ return addWC(screenNum, base, size, from);
+ else
+ return delWC(screenNum, base, size, from);
+}
+
+static void
+undoWC(int screenNum, pointer list)
+{
+ RangePtr rp;
+ struct mem_range_op mro;
+ Bool failed;
+
+ rp = list;
+ while (rp) {
+#ifdef DEBUG
+ ErrorF("Undo for (0x%lx,0x%lx), %d\n",
+ (unsigned long)rp->mrd.mr_base,
+ (unsigned long)rp->mrd.mr_len, rp->wasWC);
+#endif
+ failed = FALSE;
+ if (rp->wasWC) {
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ rp->mrd.mr_flags = MDF_WRITECOMBINE;
+ strcpy(rp->mrd.mr_owner, "unknown");
+ } else {
+ mro.mo_arg[0] = MEMRANGE_SET_REMOVE;
+ }
+ mro.mo_desc = &rp->mrd;
+
+ if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
+ if (!rp->wasWC) {
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ rp->mrd.mr_flags = MDF_UNCACHEABLE;
+ strcpy(rp->mrd.mr_owner, "unknown");
+ if (ioctl(devMemFd, MEMRANGE_SET, &mro))
+ failed = TRUE;
+ } else
+ failed = TRUE;
+ }
+ if (failed) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "Failed to restore MTRR range (0x%lx,0x%lx)\n",
+ (unsigned long)rp->mrd.mr_base,
+ (unsigned long)rp->mrd.mr_len);
+ }
+ rp = rp->next;
+ }
+}
+
+#endif /* HAS_MTRR_SUPPORT */
+
+
+#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
+static pointer
+NetBSDsetWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
+ MessageType from)
+{
+ struct mtrr *mtrrp;
+ int n;
+
+ xf86DrvMsg(screenNum, X_WARNING,
+ "%s MTRR %lx - %lx\n", enable ? "set" : "remove",
+ base, (base + size));
+
+ mtrrp = xnfalloc(sizeof (struct mtrr));
+ mtrrp->base = base;
+ mtrrp->len = size;
+ mtrrp->type = MTRR_TYPE_WC;
+
+ /*
+ * MTRR_PRIVATE will make this MTRR get reset automatically
+ * if this process exits, so we have no need for an explicit
+ * cleanup operation when starting a new server.
+ */
+
+ if (enable)
+ mtrrp->flags = MTRR_VALID | MTRR_PRIVATE;
+ else
+ mtrrp->flags = 0;
+ n = 1;
+
+ if (i386_set_mtrr(mtrrp, &n) < 0) {
+ xfree(mtrrp);
+ return NULL;
+ }
+ return mtrrp;
+}
+
+static void
+NetBSDundoWC(int screenNum, pointer list)
+{
+ struct mtrr *mtrrp = (struct mtrr *)list;
+ int n;
+
+ if (mtrrp == NULL)
+ return;
+ n = 1;
+ mtrrp->flags &= ~MTRR_VALID;
+ i386_set_mtrr(mtrrp, &n);
+ xfree(mtrrp);
+}
+#endif
+
+#if defined(__OpenBSD__) && defined(__amd64__)
+static pointer
+amd64setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
+ MessageType from)
+{
+ struct mtrr *mtrrp;
+ int n;
+
+ xf86DrvMsg(screenNum, X_WARNING,
+ "%s MTRR %lx - %lx\n", enable ? "set" : "remove",
+ base, (base + size));
+
+ mtrrp = xnfalloc(sizeof (struct mtrr));
+ mtrrp->base = base;
+ mtrrp->len = size;
+ mtrrp->type = MTRR_TYPE_WC;
+
+ /*
+ * MTRR_PRIVATE will make this MTRR get reset automatically
+ * if this process exits, so we have no need for an explicit
+ * cleanup operation when starting a new server.
+ */
+
+ if (enable)
+ mtrrp->flags = MTRR_VALID | MTRR_PRIVATE;
+ else
+ mtrrp->flags = 0;
+ n = 1;
+
+ if (amd64_set_mtrr(mtrrp, &n) < 0) {
+ xfree(mtrrp);
+ return NULL;
+ }
+ return mtrrp;
+}
+
+static void
+amd64undoWC(int screenNum, pointer list)
+{
+ struct mtrr *mtrrp = (struct mtrr *)list;
+ int n;
+
+ if (mtrrp == NULL)
+ return;
+ n = 1;
+ mtrrp->flags &= ~MTRR_VALID;
+ amd64_set_mtrr(mtrrp, &n);
+ xfree(mtrrp);
+}
+#endif /* OpenBSD/amd64 */
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/Imakefile
new file mode 100644
index 000000000..15b784797
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/Imakefile
@@ -0,0 +1,10 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/libusb/Imakefile,v 1.1.2.1 1999/12/01 12:49:27 hohndel Exp $
+
+#include <Server.tmpl>
+
+SRCS = data.c descr.c parse.c usage.c
+OBJS = data.o descr.o parse.o usage.o
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(usb,$(OBJS))
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/data.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/data.c
new file mode 100644
index 000000000..0ac1a63bc
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/data.c
@@ -0,0 +1,95 @@
+/* $NetBSD: data.c,v 1.6 1999/09/20 04:48:12 lukem Exp $ */
+
+/*
+ * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/libusb/data.c,v 1.1.2.2 1999/12/03 10:12:41 hohndel Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <assert.h>
+#include <stdlib.h>
+#include "usb.h"
+
+int
+hid_get_data(void *p, hid_item_t *h)
+{
+ unsigned char *buf;
+ unsigned int hpos;
+ unsigned int hsize;
+ int data;
+ int i, end, offs;
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(h != NULL);
+
+ buf = p;
+ hpos = h->pos; /* bit position of data */
+ hsize = h->report_size; /* bit length of data */
+
+ if (hsize == 0)
+ return (0);
+ offs = hpos / 8;
+ end = (hpos + hsize) / 8 - offs;
+ data = 0;
+ for (i = 0; i <= end; i++)
+ data |= buf[offs + i] << (i*8);
+ data >>= hpos % 8;
+ data &= (1 << hsize) - 1;
+ if (h->logical_minimum < 0) {
+ /* Need to sign extend */
+ hsize = sizeof data * 8 - hsize;
+ data = (data << hsize) >> hsize;
+ }
+ return (data);
+}
+
+void
+hid_set_data(void *p, hid_item_t *h, int data)
+{
+ unsigned char *buf;
+ unsigned int hpos;
+ unsigned int hsize;
+ int i, end, offs;
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(h != NULL);
+
+ buf = p;
+ hpos = h->pos; /* bit position of data */
+ hsize = h->report_size; /* bit length of data */
+
+ if (hsize != 32)
+ data &= (1 << hsize) - 1;
+ data <<= (hpos % 8);
+
+ offs = hpos / 8;
+ end = (hpos + hsize) / 8 - offs;
+ data = 0;
+ for (i = 0; i <= end; i++)
+ buf[offs + i] |= (data >> (i*8)) & 0xff;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/descr.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/descr.c
new file mode 100644
index 000000000..2306d2f58
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/descr.c
@@ -0,0 +1,76 @@
+/* $NetBSD: descr.c,v 1.7 1999/10/13 17:48:04 drochner Exp $ */
+
+/*
+ * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/libusb/descr.c,v 1.1.2.2 1999/12/03 10:12:42 hohndel Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/types.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+#include <dev/usb/usb.h>
+
+#include "usb.h"
+#include "usbvar.h"
+
+report_desc_t
+hid_get_report_desc(fd)
+ int fd;
+{
+ struct usb_ctl_report_desc rep;
+ report_desc_t r;
+
+ _DIAGASSERT(fd != -1);
+
+ rep.size = 0;
+ if (ioctl(fd, USB_GET_REPORT_DESC, &rep) < 0)
+ return (0);
+ r = malloc(sizeof *r + rep.size);
+ if (r == 0) {
+ errno = ENOMEM;
+ return (0);
+ }
+ r->size = rep.size;
+ memcpy(r->data, rep.data, (unsigned int)rep.size);
+ return (r);
+}
+
+void
+hid_dispose_report_desc(r)
+ report_desc_t r;
+{
+
+ free(r);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/parse.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/parse.c
new file mode 100644
index 000000000..feff9779a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/parse.c
@@ -0,0 +1,404 @@
+/* $NetBSD: parse.c,v 1.7 1999/10/13 17:48:04 drochner Exp $ */
+
+/*
+ * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/libusb/parse.c,v 1.1.2.2 1999/12/03 10:12:42 hohndel Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbhid.h>
+
+#include "usb.h"
+#include "usbvar.h"
+
+#define MAXUSAGE 100
+struct hid_data {
+ u_char *start;
+ u_char *end;
+ u_char *p;
+ hid_item_t cur;
+ unsigned int usages[MAXUSAGE];
+ int nusage;
+ int minset;
+ int multi;
+ int multimax;
+ int kindset;
+};
+
+static int min(int x, int y) { return x < y ? x : y; }
+
+static void
+hid_clear_local(hid_item_t *c)
+{
+
+ _DIAGASSERT(c != NULL);
+
+ c->usage = 0;
+ c->usage_minimum = 0;
+ c->usage_maximum = 0;
+ c->designator_index = 0;
+ c->designator_minimum = 0;
+ c->designator_maximum = 0;
+ c->string_index = 0;
+ c->string_minimum = 0;
+ c->string_maximum = 0;
+ c->set_delimiter = 0;
+}
+
+hid_data_t
+hid_start_parse(report_desc_t d, int kindset)
+{
+ struct hid_data *s;
+
+ _DIAGASSERT(d != NULL);
+
+ s = malloc(sizeof *s);
+ memset(s, 0, sizeof *s);
+ s->start = s->p = d->data;
+ s->end = d->data + d->size;
+ s->kindset = kindset;
+ return (s);
+}
+
+void
+hid_end_parse(hid_data_t s)
+{
+
+ _DIAGASSERT(s != NULL);
+
+ while (s->cur.next) {
+ hid_item_t *hi = s->cur.next->next;
+ free(s->cur.next);
+ s->cur.next = hi;
+ }
+ free(s);
+}
+
+int
+hid_get_item(hid_data_t s, hid_item_t *h)
+{
+ hid_item_t *c;
+ unsigned int bTag = 0, bType = 0, bSize;
+ unsigned char *data;
+ int dval;
+ unsigned char *p;
+ hid_item_t *hi;
+ int i;
+
+ _DIAGASSERT(s != NULL);
+ _DIAGASSERT(h != NULL);
+
+ c = &s->cur;
+
+ top:
+ if (s->multimax) {
+ if (s->multi < s->multimax) {
+ c->usage = s->usages[min(s->multi, s->nusage-1)];
+ s->multi++;
+ *h = *c;
+ c->pos += c->report_size;
+ h->next = 0;
+ return (1);
+ } else {
+ c->report_count = s->multimax;
+ s->multimax = 0;
+ s->nusage = 0;
+ hid_clear_local(c);
+ }
+ }
+ for (;;) {
+ p = s->p;
+ if (p >= s->end)
+ return (0);
+
+ bSize = *p++;
+ if (bSize == 0xfe) {
+ /* long item */
+ bSize = *p++;
+ bSize |= *p++ << 8;
+ bTag = *p++;
+ data = p;
+ p += bSize;
+ } else {
+ /* short item */
+ bTag = bSize >> 4;
+ bType = (bSize >> 2) & 3;
+ bSize &= 3;
+ if (bSize == 3) bSize = 4;
+ data = p;
+ p += bSize;
+ }
+ s->p = p;
+ /*
+ * The spec is unclear if the data is signed or unsigned.
+ */
+ switch(bSize) {
+ case 0:
+ dval = 0;
+ break;
+ case 1:
+ dval = (int8_t)*data++;
+ break;
+ case 2:
+ dval = *data++;
+ dval |= *data++ << 8;
+ dval = (int16_t)dval;
+ break;
+ case 4:
+ dval = *data++;
+ dval |= *data++ << 8;
+ dval |= *data++ << 16;
+ dval |= *data++ << 24;
+ break;
+ default:
+ return (-1);
+ }
+
+ switch (bType) {
+ case 0: /* Main */
+ switch (bTag) {
+ case 8: /* Input */
+ if (!(s->kindset & (1 << hid_input)))
+ continue;
+ c->kind = hid_input;
+ c->flags = dval;
+ ret:
+ if (c->flags & HIO_VARIABLE) {
+ s->multimax = c->report_count;
+ s->multi = 0;
+ c->report_count = 1;
+ if (s->minset) {
+ for (i = c->usage_minimum;
+ i <= c->usage_maximum;
+ i++) {
+ s->usages[s->nusage] = i;
+ if (s->nusage < MAXUSAGE-1)
+ s->nusage++;
+ }
+ s->minset = 0;
+ }
+ goto top;
+ } else {
+ if (s->minset)
+ c->usage = c->usage_minimum;
+ *h = *c;
+ h->next = 0;
+ c->pos += c->report_size * c->report_count;
+ hid_clear_local(c);
+ s->minset = 0;
+ return (1);
+ }
+ case 9: /* Output */
+ if (!(s->kindset & (1 << hid_output)))
+ continue;
+ c->kind = hid_output;
+ c->flags = dval;
+ goto ret;
+ case 10: /* Collection */
+ c->kind = hid_collection;
+ c->collection = dval;
+ c->collevel++;
+ *h = *c;
+ hid_clear_local(c);
+ s->nusage = 0;
+ return (1);
+ case 11: /* Feature */
+ if (!(s->kindset & (1 << hid_feature)))
+ continue;
+ c->kind = hid_feature;
+ c->flags = dval;
+ goto ret;
+ case 12: /* End collection */
+ c->kind = hid_endcollection;
+ c->collevel--;
+ *h = *c;
+ hid_clear_local(c);
+ s->nusage = 0;
+ return (1);
+ default:
+ return (-2);
+ }
+
+ case 1: /* Global */
+ switch (bTag) {
+ case 0:
+ c->_usage_page = dval << 16;
+ break;
+ case 1:
+ c->logical_minimum = dval;
+ break;
+ case 2:
+ c->logical_maximum = dval;
+ break;
+ case 3:
+ c->physical_maximum = dval;
+ break;
+ case 4:
+ c->physical_maximum = dval;
+ break;
+ case 5:
+ c->unit_exponent = dval;
+ break;
+ case 6:
+ c->unit = dval;
+ break;
+ case 7:
+ c->report_size = dval;
+ break;
+ case 8:
+ c->report_ID = dval;
+ break;
+ case 9:
+ c->report_count = dval;
+ break;
+ case 10: /* Push */
+ hi = malloc(sizeof *hi);
+ *hi = s->cur;
+ c->next = hi;
+ break;
+ case 11: /* Pop */
+ hi = c->next;
+ s->cur = *hi;
+ free(hi);
+ break;
+ default:
+ return (-3);
+ }
+ break;
+ case 2: /* Local */
+ switch (bTag) {
+ case 0:
+ if (bSize == 1)
+ dval = c->_usage_page | (dval&0xff);
+ else if (bSize == 2)
+ dval = c->_usage_page | (dval&0xffff);
+ c->usage = dval;
+ if (s->nusage < MAXUSAGE)
+ s->usages[s->nusage++] = dval;
+ /* else XXX */
+ break;
+ case 1:
+ s->minset = 1;
+ if (bSize == 1)
+ dval = c->_usage_page | (dval&0xff);
+ else if (bSize == 2)
+ dval = c->_usage_page | (dval&0xffff);
+ c->usage_minimum = dval;
+ break;
+ case 2:
+ if (bSize == 1)
+ dval = c->_usage_page | (dval&0xff);
+ else if (bSize == 2)
+ dval = c->_usage_page | (dval&0xffff);
+ c->usage_maximum = dval;
+ break;
+ case 3:
+ c->designator_index = dval;
+ break;
+ case 4:
+ c->designator_minimum = dval;
+ break;
+ case 5:
+ c->designator_maximum = dval;
+ break;
+ case 7:
+ c->string_index = dval;
+ break;
+ case 8:
+ c->string_minimum = dval;
+ break;
+ case 9:
+ c->string_maximum = dval;
+ break;
+ case 10:
+ c->set_delimiter = dval;
+ break;
+ default:
+ return (-4);
+ }
+ break;
+ default:
+ return (-5);
+ }
+ }
+}
+
+int
+hid_report_size(report_desc_t r, enum hid_kind k, int *idp)
+{
+ struct hid_data *d;
+ hid_item_t h;
+ int size, id;
+
+ _DIAGASSERT(r != NULL);
+ /* idp may be NULL */
+
+ id = 0;
+ if (idp)
+ *idp = 0;
+ memset(&h, 0, sizeof h);
+ for (d = hid_start_parse(r, 1<<k); hid_get_item(d, &h); ) {
+ if (h.report_ID != 0) {
+ if (idp)
+ *idp = h.report_ID;
+ id = 8;
+ }
+ }
+ hid_end_parse(d);
+ size = h.pos + id;
+ return ((size + 7) / 8);
+}
+
+int
+hid_locate(desc, u, k, h)
+ report_desc_t desc;
+ unsigned int u;
+ enum hid_kind k;
+ hid_item_t *h;
+{
+ hid_data_t d;
+
+ _DIAGASSERT(desc != NULL);
+ _DIAGASSERT(h != NULL);
+
+ for (d = hid_start_parse(desc, 1<<k); hid_get_item(d, h); ) {
+ if (h->kind == k && !(h->flags & HIO_CONST) && h->usage == u) {
+ hid_end_parse(d);
+ return (1);
+ }
+ }
+ hid_end_parse(d);
+ h->report_size = 0;
+ return (0);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usage.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usage.c
new file mode 100644
index 000000000..f909ee691
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usage.c
@@ -0,0 +1,199 @@
+/* $NetBSD: usage.c,v 1.4 1999/07/02 15:46:53 simonb Exp $ */
+
+/*
+ * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/libusb/usage.c,v 1.1.2.2 1999/12/03 10:12:42 hohndel Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "usb.h"
+
+#define _PATH_HIDTABLE "/usr/share/misc/usb_hid_usages"
+
+struct usage_in_page {
+ char *name;
+ int usage;
+};
+
+static struct usage_page {
+ char *name;
+ int usage;
+ struct usage_in_page *page_contents;
+ int pagesize, pagesizemax;
+} *pages;
+static int npages, npagesmax;
+
+#ifdef DEBUG
+void
+dump_hid_table(void)
+{
+ int i, j;
+
+ for (i = 0; i < npages; i++) {
+ printf("%d\t%s\n", pages[i].usage, pages[i].name);
+ for (j = 0; j < pages[i].pagesize; j++) {
+ printf("\t%d\t%s\n", pages[i].page_contents[j].usage,
+ pages[i].page_contents[j].name);
+ }
+ }
+}
+#endif
+
+void
+hid_init(char *hidname)
+{
+ FILE *f;
+ char line[100], name[100], *p, *n;
+ int no;
+ int lineno;
+ struct usage_page *curpage = 0;
+
+ if (hidname == 0)
+ hidname = _PATH_HIDTABLE;
+
+ f = fopen(hidname, "r");
+ if (f == NULL)
+ err(1, "%s", hidname);
+ for (lineno = 1; ; lineno++) {
+ if (fgets(line, sizeof line, f) == NULL)
+ break;
+ if (line[0] == '#')
+ continue;
+ for (p = line; *p && isspace(*p); p++)
+ ;
+ if (!*p)
+ continue;
+ if (sscanf(line, " * %[^\n]", name) == 1)
+ no = -1;
+ else if (sscanf(line, " 0x%x %[^\n]", &no, name) != 2 &&
+ sscanf(line, " %d %[^\n]", &no, name) != 2)
+ errx(1, "file %s, line %d, syntax error\n",
+ hidname, lineno);
+ for (p = name; *p; p++)
+ if (isspace(*p) || *p == '.')
+ *p = '_';
+ n = strdup(name);
+ if (!n)
+ err(1, "strdup");
+ if (isspace(line[0])) {
+ if (!curpage)
+ errx(1, "file %s, line %d, syntax error\n",
+ hidname, lineno);
+ if (curpage->pagesize >= curpage->pagesizemax) {
+ curpage->pagesizemax += 10;
+ curpage->page_contents =
+ realloc(curpage->page_contents,
+ curpage->pagesizemax *
+ sizeof (struct usage_in_page));
+ if (!curpage->page_contents)
+ err(1, "realloc");
+ }
+ curpage->page_contents[curpage->pagesize].name = n;
+ curpage->page_contents[curpage->pagesize].usage = no;
+ curpage->pagesize++;
+ } else {
+ if (npages >= npagesmax) {
+ if (pages == 0) {
+ npagesmax = 5;
+ pages = malloc(npagesmax *
+ sizeof (struct usage_page));
+ } else {
+ npagesmax += 5;
+ pages = realloc(pages,
+ npagesmax *
+ sizeof (struct usage_page));
+ }
+ if (!pages)
+ err(1, "alloc");
+ }
+ curpage = &pages[npages++];
+ curpage->name = n;
+ curpage->usage = no;
+ curpage->pagesize = 0;
+ curpage->pagesizemax = 10;
+ curpage->page_contents =
+ malloc(curpage->pagesizemax *
+ sizeof (struct usage_in_page));
+ if (!curpage->page_contents)
+ err(1, "malloc");
+ }
+ }
+ fclose(f);
+#ifdef DEBUG
+ dump_hid_table();
+#endif
+}
+
+char *
+hid_usage_page(int i)
+{
+ static char b[10];
+ int k;
+
+ if (!pages)
+ errx(1, "no hid table\n");
+
+ for (k = 0; k < npages; k++)
+ if (pages[k].usage == i)
+ return pages[k].name;
+ sprintf(b, "0x%02x", i);
+ return b;
+}
+
+char *
+hid_usage_in_page(unsigned int u)
+{
+ int page = HID_PAGE(u);
+ int i = HID_USAGE(u);
+ static char b[100];
+ int j, k, us;
+
+ for (k = 0; k < npages; k++)
+ if (pages[k].usage == page)
+ break;
+ if (k >= npages)
+ goto bad;
+ for (j = 0; j < pages[k].pagesize; j++) {
+ us = pages[k].page_contents[j].usage;
+ if (us == -1) {
+ sprintf(b, pages[k].page_contents[j].name, i);
+ return b;
+ }
+ if (us == i)
+ return pages[k].page_contents[j].name;
+ }
+ bad:
+ sprintf(b, "0x%02x", i);
+ return b;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb.3 b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb.3
new file mode 100644
index 000000000..db0b1b08f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb.3
@@ -0,0 +1,191 @@
+.\" $NetBSD: usb.3,v 1.9 1999/11/08 22:33:40 augustss Exp $
+.\"
+.\" Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/os-support/libusb/usb.3,v 1.1.2.2 1999/12/03 10:12:42 hohndel Exp $
+.\"
+.Dd May 11, 1999
+.Dt USB 3
+.Os
+.Sh NAME
+.Nm usb ,
+.Nm hid_get_report_desc ,
+.Nm hid_dispose_report_desc ,
+.Nm hid_start_parse ,
+.Nm hid_end_parse ,
+.Nm hid_get_item ,
+.Nm hid_report_size ,
+.Nm hid_locate ,
+.Nm hid_usage_page ,
+.Nm hid_usage_in_page ,
+.Nm hid_init ,
+.Nm hid_get_data ,
+.Nm hid_set_data
+.Nd USB HID access routines
+.Sh LIBRARY
+.Lb libusb
+.Sh SYNOPSIS
+.Fd #include <usb.h>
+.Ft report_desc_t
+.Fn hid_get_report_desc "int file"
+.Ft void
+.Fn hid_dispose_report_desc "report_desc_t d"
+.Ft hid_data_t
+.Fn hid_start_parse "report_desc_t d" "int kindset"
+.Ft void
+.Fn hid_end_parse "hid_data_t s"
+.Ft int
+.Fn hid_get_item "hid_data_t s" "hid_item_t *h"
+.Ft int
+.Fn hid_report_size "report_desc_t d" "hid_kind_t k" "int *idp"
+.Ft int
+.Fn hid_locate "report_desc_t d" "u_int usage" "hid_kind_t k" "hid_item_t *h"
+.Ft char *
+.Fn hid_usage_page "int i"
+.Ft char *
+.Fn hid_usage_in_page "u_int u"
+.Ft void
+.Fn hid_init "char *file"
+.Ft int
+.Fn hid_get_data "void *data" "hid_item_t *h"
+.Ft void
+.Fn hid_set_data "void *data" "hid_item_t *h" "u_int data"
+.Sh DESCRIPTION
+The
+.Nm
+library provides routines to extract data from USB Human Interface Devices.
+.Ss INTRODUCTION
+USB HID devices send and receive data layed out a device dependent
+way. The
+.Nm
+library contains routines to extract the
+.Em report descriptor
+which contains the data layout information and then use this information.
+.Pp
+The routines can be divided into four parts: extraction of the descriptor,
+parsing of the descriptor, translating to/from symbolic names, and
+data manipulation.
+.Ss DESCRIPTOR FUNCTIONS
+A report descriptor can be obtained by calling
+.Fn hid_get_report_desc
+with a file descriptor obtained by opening a
+.Xr uhid 4
+device.
+When the report descriptor is no longer needed it should be freed
+by calling
+.Fn hid_dispose_report_desc .
+The type
+.Fa report_desc_t
+is opaque and should be used when calling the parsing functions.
+.Ss DESCRIPTOR PARSING FUNCTIONS
+To parse the report descriptor the
+.Fn hid_start_parse
+function should be called with a report descriptor and a set that
+describes which items that are interesting. The set is obtained
+by oring together values
+.Fa "(1 << k)"
+where
+.Fa k
+is an item of type
+.Fa hid_kind_t .
+The function returns
+.Fa NULL
+if the initialization fails, otherwise an opaque value to be used
+in subsequent calls.
+After parsing the
+.Fn hid_end_parse
+function should be called to free internal data structures.
+.Pp
+To iterate through all the items in the report descriptor
+.Fn hid_get_item
+should be called while it returns a value greater than 0.
+When the report descriptor ends it will returns 0; a syntax
+error within the report descriptor will cause a return value less
+than 0.
+The struct pointed to by
+.Fa h
+will be filled with the relevant data for the item.
+The definition of
+.Fa hid_item_t
+can be found in
+.Pa <usb.h>
+and the meaning of the components in the USB HID documentation.
+.Pp
+Data should be read/written to the device in the size of
+the report. The size of a report (of a certain kind) can be
+computed by the
+.Fn hid_report_size
+function. If the report is prefixed by an ID byte it is
+stored at
+.Fa idp ,
+otherwise it will contain 0.
+.Pp
+To locate a single item the
+.Fn hid_locate
+function can be used. It should be given the usage code of
+the item and its kind and it will fill the item and return
+non-zero if the item was found.
+.Pp
+.Ss NAME TRANSLATION FUNCTIONS
+The function
+.Fn hid_usage_page
+will return the symbolic name of a usage page, and the function
+.Fn hid_usage_in_page
+will return the symbolic name of the usage within the page.
+Both these functions may return a pointer to static data.
+Before either of these functions can be called the usage table
+must be parsed, this is done by calling
+.Fn hid_init
+with the name of the table. Passing
+.Fa NULL
+to this function will cause it to use the default table.
+.Ss DATA EXTRACTION FUNCTIONS
+Given the data obtained from a HID device and an item in the
+report descriptor the
+.Fn hid_get_data
+function extracts the value of the item.
+Conversely
+.Fn hid_set_data
+can be used to put data into a report (which must be zeroed first).
+.Sh EXAMPLE
+Not yet.
+.Sh FILES
+.Pa /usr/share/misc/usb_hid_usages
+The default HID usage table.
+.Sh BUGS
+This man page is woefully incomplete.
+.Sh SEE ALSO
+The
+.Tn USB
+specifications can be found at
+.Dv http://www.usb.org/developers/docs.htm .
+.Pp
+.Xr hid 4 ,
+.Xr usb 4 .
+.Sh HISTORY
+The
+.Nm
+library first appeared in
+.Nx 1.5 .
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb.h
new file mode 100644
index 000000000..445428118
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb.h
@@ -0,0 +1,95 @@
+/* $NetBSD: usb.h,v 1.5 1999/07/02 15:46:53 simonb Exp $ */
+
+/*
+ * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/libusb/usb.h,v 1.1.2.2 1999/12/03 10:12:43 hohndel Exp $ */
+
+#define _DIAGASSERT(e) assert(e)
+
+typedef struct report_desc *report_desc_t;
+
+typedef struct hid_data *hid_data_t;
+
+typedef enum hid_kind {
+ hid_input, hid_output, hid_feature, hid_collection, hid_endcollection
+}hid_kind_t;
+
+typedef struct hid_item {
+ /* Global */
+ int _usage_page;
+ int logical_minimum;
+ int logical_maximum;
+ int physical_minimum;
+ int physical_maximum;
+ int unit_exponent;
+ int unit;
+ int report_size;
+ int report_ID;
+ int report_count;
+ /* Local */
+ unsigned int usage;
+ int usage_minimum;
+ int usage_maximum;
+ int designator_index;
+ int designator_minimum;
+ int designator_maximum;
+ int string_index;
+ int string_minimum;
+ int string_maximum;
+ int set_delimiter;
+ /* Misc */
+ int collection;
+ int collevel;
+ enum hid_kind kind;
+ unsigned int flags;
+ /* Absolute data position (bits) */
+ unsigned int pos;
+ /* */
+ struct hid_item *next;
+} hid_item_t;
+
+#define HID_PAGE(u) ((u) >> 16)
+#define HID_USAGE(u) ((u) & 0xffff)
+
+/* Obtaining a report descriptor, descr.c: */
+report_desc_t hid_get_report_desc __P((int file));
+void hid_dispose_report_desc __P((report_desc_t));
+
+/* Parsing of a HID report descriptor, parse.c: */
+hid_data_t hid_start_parse __P((report_desc_t d, int kindset));
+void hid_end_parse __P((hid_data_t s));
+int hid_get_item __P((hid_data_t s, hid_item_t *h));
+int hid_report_size __P((report_desc_t d, enum hid_kind k, int *idp));
+int hid_locate __P((report_desc_t d, unsigned int usage, enum hid_kind k, hid_item_t *h));
+
+/* Conversion to/from usage names, usage.c: */
+char *hid_usage_page __P((int i));
+char *hid_usage_in_page __P((unsigned int u));
+void hid_init __P((char *file));
+
+/* Extracting/insertion of data, data.c: */
+int hid_get_data __P((void *p, hid_item_t *h));
+void hid_set_data __P((void *p, hid_item_t *h, int data));
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb_hid_usages b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb_hid_usages
new file mode 100644
index 000000000..02f122028
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb_hid_usages
@@ -0,0 +1,1079 @@
+# $NetBSD: usb_hid_usages,v 1.3 1999/07/02 15:46:53 simonb Exp $
+#
+# USB HID usage table
+# Syntax:
+# - lines that do not start with a white space give the number and name of
+# a usage page.
+# - lines that start with a white space give the number and name of
+# a usage with the last given page.
+# If the number is * then the line matches all usages and the name
+# is a printf formatting string that will be given the usage number.
+#
+# $XFree86: xc/programs/Xserver/hw/xfree86/os-support/libusb/usb_hid_usages,v 1.1.2.2 1999/12/03 10:12:43 hohndel Exp $
+#
+1 Generic Desktop
+ 0x00 Undefined
+ 0x01 Pointer
+ 0x02 Mouse
+ 0x03 Reserved
+ 0x04 Joystick
+ 0x05 Game Pad
+ 0x06 Keyboard
+ 0x07 Keypad
+ 0x08 Multi-axis Controller
+ 0x30 X
+ 0x31 Y
+ 0x32 Z
+ 0x33 Rx
+ 0x34 Ry
+ 0x35 Rz
+ 0x36 Slider
+ 0x37 Dial
+ 0x38 Wheel
+ 0x39 Hat Switch
+ 0x3A Counted Buffer
+ 0x3B Byte Count
+ 0x3C Motion Wakeup
+ 0x40 Vx
+ 0x41 Vy
+ 0x42 Vz
+ 0x43 Vbrx
+ 0x44 Vbry
+ 0x45 Vbrx
+ 0x46 Vno
+ 0x80 System Control
+ 0x81 System Power Down
+ 0x82 System Sleep
+ 0x83 System Wake Up
+ 0x84 System Context Menu
+ 0x85 System Main Menu
+ 0x86 System App Menu
+ 0x87 System Menu Help
+ 0x88 System Menu Exit
+ 0x89 System Menu Select
+ 0x8A System Menu Right
+ 0x8B System Menu Left
+ 0x8C System Menu Up
+ 0x8D System Menu Down
+ 0x90 D-pad Up
+ 0x91 D-pad Down
+ 0x92 D-pad Right
+ 0x93 D-pad Left
+
+2 Simulation Controls
+ 0x00 Undefined
+ 0x01 Flight Simulation Device
+ 0x02 Automobile Simulation Device
+ 0x03 Tank Simulation Device
+ 0x04 Spaceship Simulation Device
+ 0x05 Submarine Simulation Device
+ 0x06 Sailing Simulation Device
+ 0x07 Motorcycle Simulation Device
+ 0x08 Sports Simulation Device
+ 0x09 Airplane Simulation Device
+ 0x0A Helicopter Simulation Device
+ 0x0B Magic Carpet Simulation Device
+ 0x0C Bicycle
+ 0x20 Flight Control Stick
+ 0x21 Flight Stick
+ 0x22 Cyclic Control
+ 0x23 Cyclic Trim
+ 0x24 Flight Yoke
+ 0x25 Track Control
+ 0x26 Driving Control
+ 0xB0 Aileron
+ 0xB1 Aileron Trim
+ 0xB2 Anti-Torque Control
+ 0xB3 Auto-pilot Enable
+ 0xB4 Chaff Release
+ 0xB5 Collective Control
+ 0xB6 Dive Brake
+ 0xB7 Electronic Counter Measures
+ 0xB8 Elevator
+ 0xB9 Elevator Trim
+ 0xBA Rudder
+ 0xBB Throttle
+ 0xBC Flight Communication
+ 0xBD Flare Release
+ 0xBE Landing Gear
+ 0xBF Toe Brake
+ 0xC0 Trigger
+ 0xC1 Weapons Arm
+ 0xC2 Weapons Select
+ 0xC3 Wing Flaps
+ 0xC4 Accelerator
+ 0xC5 Brake
+ 0xC6 Clutch
+ 0xC7 Shifter
+ 0xC8 Steering
+ 0xC9 Turret Direction
+ 0xCA Barrel Elevation
+ 0xCB Dive Plane
+ 0xCC Ballast
+ 0xCD Bicycle Crank
+ 0xCE Handle Bars
+ 0xCF Front Brake
+ 0xD0 Rear Brake
+
+3 VR Controls
+ 0x00 Unidentified
+ 0x01 Belt
+ 0x02 Body Suit
+ 0x03 Flexor
+ 0x04 Glove
+ 0x05 Head Tracker
+ 0x06 Head Mounted Display
+ 0x07 Hand Tracker
+ 0x08 Oculometer
+ 0x09 Vest
+ 0x0A Animatronic Device
+ 0x20 Stereo Enable
+ 0x21 Display Enable
+
+4 Sports Controls
+ 0x00 Unidentified
+ 0x01 Baseball Bat
+ 0x02 Golf Club
+ 0x03 Rowing Machine
+ 0x04 Treadmill
+ 0x30 Oar
+ 0x31 Slope
+ 0x32 Rate
+ 0x33 Stick Speed
+ 0x34 Stick Face Angle
+ 0x35 Stick Heel/Toe
+ 0x36 Stick Follow Through
+ 0x37 Stick Tempo
+ 0x38 Stick Type
+ 0x39 Stick Height
+ 0x50 Putter
+ 0x51 1 Iron
+ 0x52 2 Iron
+ 0x53 3 Iron
+ 0x54 4 Iron
+ 0x55 5 Iron
+ 0x56 6 Iron
+ 0x57 7 Iron
+ 0x58 8 Iron
+ 0x59 9 Iron
+ 0x5A 10 Iron
+ 0x5B 11 Iron
+ 0x5C Sand Wedge
+ 0x5D Loft Wedge
+ 0x5E Power Wedge
+ 0x5F 1 Wood
+ 0x60 3 Wood
+ 0x61 5 Wood
+ 0x62 7 Wood
+ 0x63 9 Wood
+
+5 Game Controls
+ 0x00 Undefined
+ 0x01 3D Game Controller
+ 0x02 Pinball Device
+ 0x03 Gun Device
+ 0x20 Point of View
+ 0x21 Turn Right/Left
+ 0x22 Pitch Right/Left
+ 0x23 Roll Forward/Backward
+ 0x24 Move Right/Left
+ 0x25 Move Forward/Backward
+ 0x26 Move Up/Down
+ 0x27 Lean Right/Left
+ 0x28 Lean Forward/Backward
+ 0x29 Height of POV
+ 0x2A Flipper
+ 0x2B Secondary Flipper
+ 0x2C Bump
+ 0x2D New Game
+ 0x2E Shoot Ball
+ 0x2F Player
+ 0x30 Gun Bolt
+ 0x31 Gun Clip
+ 0x32 Gun Selector
+ 0x33 Gun Single Shot
+ 0x34 Gun Burst
+ 0x35 Gun Automatic
+ 0x36 Gun Safety
+ 0x37 Gamepad Fire/Jump
+ 0x39 Gamepad Trigger
+
+7 Keyboard
+ 0x00 Reserved (no event indicated)
+ 0x01 Keyboard ErrorRollOver
+ 0x02 Keyboard POSTFail
+ 0x03 Keyboard ErrorUndefined
+ 0x04 Keyboard a and A
+ 0x05 Keyboard b and B
+ 0x06 Keyboard c and C
+ 0x07 Keyboard d and D
+ 0x08 Keyboard e and E
+ 0x09 Keyboard f and F
+ 0x0A Keyboard g and G
+ 0x0B Keyboard h and H
+ 0x0C Keyboard i and I
+ 0x0D Keyboard j and J
+ 0x0E Keyboard k and K
+ 0x0F Keyboard l and L
+ 0x10 Keyboard m and M
+ 0x11 Keyboard n and N
+ 0x12 Keyboard o and O
+ 0x13 Keyboard p and P
+ 0x14 Keyboard q and Q
+ 0x15 Keyboard r and R
+ 0x16 Keyboard s and S
+ 0x17 Keyboard t and T
+ 0x18 Keyboard u and U
+ 0x19 Keyboard v and V
+ 0x1A Keyboard w and W
+ 0x1B Keyboard x and X
+ 0x1C Keyboard y and Y
+ 0x1D Keyboard z and Z
+ 0x1E Keyboard 1 and !
+ 0x1F Keyboard 2 and @
+ 0x20 Keyboard 3 and #
+ 0x21 Keyboard 4 and $
+ 0x22 Keyboard 5 and %
+ 0x23 Keyboard 6 and ^
+ 0x24 Keyboard 7 and &
+ 0x25 Keyboard 8 and *
+ 0x26 Keyboard 9 and (
+ 0x27 Keyboard 0 and )
+ 0x28 Keyboard Return (ENTER)
+ 0x29 Keyboard ESCAPE
+ 0x2A Keyboard DELETE (Backspace)
+ 0x2B Keyboard Tab
+ 0x2C Keyboard Spacebar
+ 0x2D Keyboard - and (underscore)
+ 0x2E Keyboard = and +
+ 0x2F Keyboard [ and {
+ 0x30 Keyboard ] and }
+ 0x31 Keyboard \ and |
+ 0x32 Keyboard Non-US # and ~
+ 0x33 Keyboard ; and :
+ 0x34 Keyboard ' and "
+ 0x35 Keyboard Grave Accent and Tilde
+ 0x36 Keyboard, and <
+ 0x37 Keyboard . and >
+ 0x38 Keyboard / and ?
+ 0x39 Keyboard Caps Lock
+ 0x3A Keyboard F1
+ 0x3B Keyboard F2
+ 0x3C Keyboard F3
+ 0x3D Keyboard F4
+ 0x3E Keyboard F5
+ 0x3F Keyboard F6
+ 0x40 Keyboard F7
+ 0x41 Keyboard F8
+ 0x42 Keyboard F9
+ 0x43 Keyboard F10
+ 0x44 Keyboard F11
+ 0x45 Keyboard F12
+ 0x46 Keyboard PrintScreen
+ 0x47 Keyboard Scroll Lock
+ 0x48 Keyboard Pause
+ 0x49 Keyboard Insert
+ 0x4A Keyboard Home
+ 0x4B Keyboard PageUp
+ 0x4C Keyboard Delete Forward
+ 0x4D Keyboard End
+ 0x4E Keyboard PageDown
+ 0x4F Keyboard RightArrow
+ 0x50 Keyboard LeftArrow
+ 0x51 Keyboard DownArrow
+ 0x52 Keyboard UpArrow
+ 0x53 Keypad Num Lock and Clear
+ 0x54 Keypad /
+ 0x55 Keypad *
+ 0x56 Keypad -
+ 0x57 Keypad +
+ 0x58 Keypad ENTER
+ 0x59 Keypad 1 and End
+ 0x5A Keypad 2 and Down Arrow
+ 0x5B Keypad 3 and PageDn
+ 0x5C Keypad 4 and Left Arrow
+ 0x5D Keypad 5
+ 0x5E Keypad 6 and Right Arrow
+ 0x5F Keypad 7 and Home
+ 0x60 Keypad 8 and Up Arrow
+ 0x61 Keypad 9 and PageUp
+ 0x62 Keypad 0 and Insert
+ 0x63 Keypad . and Delete
+ 0x64 Keyboard Non-US \ and |
+ 0x65 Keyboard Application
+ 0x66 Keyboard Power
+ 0x67 Keypad =
+ 0x68 Keyboard F13
+ 0x69 Keyboard F14
+ 0x6A Keyboard F15
+ 0x6B Keyboard F16
+ 0x6C Keyboard F17
+ 0x6D Keyboard F18
+ 0x6E Keyboard F19
+ 0x6F Keyboard F20
+ 0x70 Keyboard F21
+ 0x71 Keyboard F22
+ 0x72 Keyboard F23
+ 0x73 Keyboard F24
+ 0x74 Keyboard Execute
+ 0x75 Keyboard Help
+ 0x76 Keyboard Menu
+ 0x77 Keyboard Select
+ 0x78 Keyboard Stop
+ 0x79 Keyboard Again
+ 0x7A Keyboard Undo
+ 0x7B Keyboard Cut
+ 0x7C Keyboard Copy
+ 0x7D Keyboard Paste
+ 0x7E Keyboard Find
+ 0x7F Keyboard Mute
+ 0x80 Keyboard Volume Up
+ 0x81 Keyboard Volume Down
+ 0x82 Keyboard Locking Caps Lock
+ 0x83 Keyboard Locking Num Lock
+ 0x84 Keyboard Locking Scroll Lock
+ 0x85 Keypad Comma
+ 0x86 Keypad Equal Sign
+ 0x87 Keyboard International1
+ 0x88 Keyboard International2
+ 0x89 Keyboard International3
+ 0x8A Keyboard International4
+ 0x8B Keyboard International5
+ 0x8C Keyboard International6
+ 0x8D Keyboard International7
+ 0x8E Keyboard International8
+ 0x8F Keyboard International9
+ 0x90 Keyboard LANG1
+ 0x91 Keyboard LANG2
+ 0x92 Keyboard LANG3
+ 0x93 Keyboard LANG4
+ 0x94 Keyboard LANG5
+ 0x95 Keyboard LANG6
+ 0x96 Keyboard LANG7
+ 0x97 Keyboard LANG8
+ 0x98 Keyboard LANG9
+ 0x99 Keyboard Alternate Erase
+ 0x9A Keyboard SysReq/Attention
+ 0x9B Keyboard Cancel
+ 0x9C Keyboard Clear
+ 0x9D Keyboard Prior
+ 0x9E Keyboard Return
+ 0x9F Keyboard Separator
+ 0xA0 Keyboard Out
+ 0xA1 Keyboard Oper
+ 0xA2 Keyboard Clear/Again
+ 0xA3 Keyboard CrSel/Props
+ 0xA4 Keyboard ExSel
+ 0xE0 Keyboard LeftControl
+ 0xE1 Keyboard LeftShift
+ 0xE2 Keyboard LeftAlt
+ 0xE3 Keyboard Left GUI
+ 0xE4 Keyboard RightControl
+ 0xE5 Keyboard RightShift
+ 0xE6 Keyboard RightAlt
+ 0xE7 Keyboard Right GUI
+
+8 LEDs
+ 0x00 Undefined
+ 0x01 Num Lock
+ 0x02 Caps Lock
+ 0x03 Scroll Lock
+ 0x04 Compose
+ 0x05 Kana
+ 0x06 Power
+ 0x07 Shift
+ 0x08 Do Not Disturb
+ 0x09 Mute
+ 0x0A Tone Enable
+ 0x0B High Cut Filter
+ 0x0C Low Cut Filter
+ 0x0D Equalizer Enable
+ 0x0E Sound Field On
+ 0x0F Surround Field On
+ 0x10 Repeat
+ 0x11 Stereo
+ 0x12 Sampling Rate Detect
+ 0x13 Spinning
+ 0x14 CAV
+ 0x15 CLV
+ 0x16 Recording Format Detect
+ 0x17 Off-Hook
+ 0x18 Ring
+ 0x19 Message Waiting
+ 0x1A Data Mode
+ 0x1B Battery Operation
+ 0x1C Battery OK
+ 0x1D Battery Low
+ 0x1E Speaker
+ 0x1F Head Set
+ 0x20 Hold
+ 0x21 Microphone
+ 0x22 Coverage
+ 0x23 Night Mode
+ 0x24 Send Calls
+ 0x25 Call Pickup
+ 0x26 Conference
+ 0x27 Stand-by
+ 0x28 Camera On
+ 0x29 Camera Off
+ 0x2A On-Line
+ 0x2B Off-Line
+ 0x2C Busy
+ 0x2D Ready
+ 0x2E Paper-Out
+ 0x2F Paper-Jam
+ 0x30 Remote
+ 0x31 Forward
+ 0x32 Reverse
+ 0x33 Stop
+ 0x34 Rewind
+ 0x35 Fast Forward
+ 0x36 Play
+ 0x37 Pause
+ 0x38 Record
+ 0x39 Error
+ 0x3A Usage Selected Indicator
+ 0x3B Usage In Use Indicator
+ 0x3C Usage Multi Mode Indicator
+ 0x3D Indicator On
+ 0x3E Indicator Flash
+ 0x3F Indicator Slow Blink
+ 0x40 Indicator Fast Blink
+ 0x41 Indicator Off
+ 0x42 Flash On Time
+ 0x43 Slow Blink On Time
+ 0x44 Slow Blink Off Time
+ 0x45 Fast Blink On Time
+ 0x46 Fast Blink Off Time
+ 0x47 Usage Indicator Color
+ 0x48 Red
+ 0x49 Green
+ 0x4A Amber
+ 0x4B Generic Indicator
+ 0x4C System Suspend
+ 0x4D External Power Connected
+ 0x4C-FFFF Reserved
+
+9 Button
+ 0x00 No Button Pressed
+ * Button %d
+
+10 Ordinal
+ 0x00 Unused
+ * Instance %d
+
+11 Telephony
+ 0x00 Unassigned
+ 0x01 Phone
+ 0x02 Answering Machine
+ 0x03 Message Controls
+ 0x04 Handset
+ 0x05 Headset
+ 0x06 Telephony Key Pad
+ 0x07 Programmable Button
+ 0x20 Hook Switch
+ 0x21 Flash
+ 0x22 Feature
+ 0x23 Hold
+ 0x24 Redial
+ 0x25 Transfer
+ 0x26 Drop
+ 0x27 Park
+ 0x28 Forward Calls
+ 0x29 Alternate Function
+ 0x2A Line
+ 0x2B Speaker Phone
+ 0x2C Conference
+ 0x2D Ring Enable
+ 0x2E Ring Select
+ 0x2F Phone Mute
+ 0x30 Caller ID
+ 0x50 Speed Dial
+ 0x51 Store Number
+ 0x52 Recall Number
+ 0x53 Phone Directory
+ 0x70 Voice Mail
+ 0x71 Screen Calls
+ 0x72 Do Not Disturb
+ 0x73 Message
+ 0x74 Answer On/Off
+ 0x90 Inside Dial Tone
+ 0x91 Outside Dial Tone
+ 0x92 Inside Ring Tone
+ 0x93 Outside Ring Tone
+ 0x94 Priority Ring Tone
+ 0x95 Inside Ringback
+ 0x96 Priority Ringback
+ 0x97 Line Busy Tone
+ 0x98 Reorder Tone
+ 0x99 Call Waiting Tone
+ 0x9A Confirmation Tone 1
+ 0x9B Confirmation Tone 2
+ 0x9C Tones Off
+ 0xB0 Phone Key 0
+ 0xB1 Phone Key 1
+ 0xB2 Phone Key 2
+ 0xB3 Phone Key 3
+ 0xB4 Phone Key 4
+ 0xB5 Phone Key 5
+ 0xB6 Phone Key 6
+ 0xB7 Phone Key 7
+ 0xB8 Phone Key 8
+ 0xB9 Phone Key 9
+ 0xBA Phone Key Star
+ 0xBB Phone Key Pound
+ 0xBC Phone Key A
+ 0xBD Phone Key B
+ 0xBE Phone Key C
+ 0xBF Phone Key D
+
+12 Consumer
+ 0x00 Unassigned
+ 0x01 Consumer Control
+ 0x02 Numeric Key Pad
+ 0x03 Programmable Buttons
+ 0x20 +10
+ 0x21 +100
+ 0x22 AM/PM
+ 0x30 Power
+ 0x31 Reset
+ 0x32 Sleep
+ 0x33 Sleep After
+ 0x34 Sleep Mode
+ 0x35 Illumination
+ 0x36 Function Buttons
+ 0x40 Menu
+ 0x41 Menu Pick
+ 0x42 Menu Up
+ 0x43 Menu Down
+ 0x44 Menu Left
+ 0x45 Menu Right
+ 0x46 Menu Escape
+ 0x47 Menu Value Increase
+ 0x48 Menu Value Decrease
+ 0x60 Data On Screen
+ 0x61 Closed Caption
+ 0x62 Closed Caption Select
+ 0x63 VCR/TV
+ 0x64 Broadcast Mode
+ 0x65 Snapshot
+ 0x66 Still
+ 0x80 Selection
+ 0x81 Assign Selection
+ 0x82 Mode Step
+ 0x83 Recall Last
+ 0x84 Enter Channel
+ 0x85 Order Movie
+ 0x86 Channel
+ 0x87 Media Selection
+ 0x88 Media Select Computer
+ 0x89 Media Select TV
+ 0x8A Media Select WWW
+ 0x8B Media Select DVD
+ 0x8C Media Select Telephone
+ 0x8D Media Select Program Guide
+ 0x8E Media Select Video Phone
+ 0x8F Media Select Games
+ 0x90 Media Select Messages
+ 0x91 Media Select CD
+ 0x92 Media Select VCR
+ 0x93 Media Select Tuner
+ 0x94 Quit
+ 0x95 Help
+ 0x96 Media Select Tape
+ 0x97 Media Select Cable
+ 0x98 Media Select Satellite
+ 0x99 Media Select Security
+ 0x9A Media Select Home
+ 0x9B Media Select Call
+ 0x9C Channel Increment
+ 0x9D Channel Decrement
+ 0x9E Media Select SAP
+ 0xA0 VCR Plus
+ 0xA1 Once
+ 0xA2 Daily
+ 0xA3 Weekly
+ 0xA4 Monthly
+ 0xB0 Play
+ 0xB1 Pause
+ 0xB2 Record
+ 0xB3 Fast Forward
+ 0xB4 Rewind
+ 0xB5 Scan Next Track
+ 0xB6 Scan Previous Track
+ 0xB7 Stop
+ 0xB8 Eject
+ 0xB9 Random Play
+ 0xBA Select DisC
+ 0xBB Enter Disc
+ 0xBC Repeat
+ 0xBD Tracking
+ 0xBE Track Normal
+ 0xBF Slow Tracking
+ 0xC0 Frame Forward
+ 0xC1 Frame Back
+ 0xC2 Mark
+ 0xC3 Clear Mark
+ 0xC4 Repeat From Mark
+ 0xC5 Return To Mark
+ 0xC6 Search Mark Forward
+ 0xC7 Search Mark Backwards
+ 0xC8 Counter Reset
+ 0xC9 Show Counter
+ 0xCA Tracking Increment
+ 0xCB Tracking Decrement
+ 0xE0 Volume
+ 0xE1 Balance
+ 0xE2 Mute
+ 0xE3 Bass
+ 0xE4 Treble
+ 0xE5 Bass Boost
+ 0xE6 Surround Mode
+ 0xE7 Loudness
+ 0xE8 MPX
+ 0xE9 Volume Up
+ 0xEA Volume Down
+ 0xF0 Speed Select
+ 0xF1 Playback Speed
+ 0xF2 Standard Play
+ 0xF3 Long Play
+ 0xF4 Extended Play
+ 0xF5 Slow
+ 0x100 Fan Enable
+ 0x101 Fan Speed
+ 0x102 Light
+ 0x103 Light Illumination Level
+ 0x104 Climate Control Enable
+ 0x105 Room Temperature
+ 0x106 Security Enable
+ 0x107 Fire Alarm
+ 0x108 Police Alarm
+ 0x150 Balance Right
+ 0x151 Balance Left
+ 0x152 Bass Increment
+ 0x153 Bass Decrement
+ 0x154 Treble Increment
+ 0x155 Treble Decrement
+ 0x160 Speaker System
+ 0x161 Channel Left
+ 0x162 Channel Right
+ 0x163 Channel Center
+ 0x164 Channel Front
+ 0x165 Channel Center Front
+ 0x166 Channel Side
+ 0x167 Channel Surround
+ 0x168 Channel Low Frequency Enhancement
+ 0x169 Channel Top
+ 0x16A Channel Unknown
+ 0x170 Sub-channel
+ 0x171 Sub-channel Increment
+ 0x172 Sub-channel Decrement
+ 0x173 Alternate Audio Increment
+ 0x174 Alternate Audio Decrement
+ 0x180 Application Launch Buttons
+ 0x181 AL Launch Button Configuration Tool
+ 0x182 AL Programmable Button Configuration
+ 0x183 AL Consumer Control Configuration
+ 0x184 AL Word Processor
+ 0x185 AL Text Editor
+ 0x186 AL Spreadsheet
+ 0x187 AL Graphics Editor
+ 0x188 AL Presentation App
+ 0x189 AL Database App
+ 0x18A AL Email Reader
+ 0x18B AL Newsreader
+ 0x18C AL Voicemail
+ 0x18D AL Contacts/Address Book
+ 0x18E AL Calendar/Schedule
+ 0x18F AL Task/Project Manager
+ 0x190 AL Log/Journal/Timecard
+ 0x191 AL Checkbook/Finance
+ 0x192 AL Calculator
+ 0x193 AL A/V Capture/Playback
+ 0x194 AL Local Machine Browser
+ 0x195 AL LAN/WAN Browser
+ 0x196 AL Internet Browser
+ 0x197 AL Remote Networking/ISP Connect
+ 0x198 AL Network Conference
+ 0x199 AL Network Chat
+ 0x19A AL Telephony/Dialer
+ 0x19B AL Logon
+ 0x19C AL Logoff
+ 0x19D AL Logon/Logoff
+ 0x19E AL Terminal Lock/Screensaver
+ 0x19F AL Control Panel
+ 0x1A0 AL Command Line Processor/Run
+ 0x1A1 AL Process/Task Manager
+ 0x1A2 AL Select Tast/Application
+ 0x1A3 AL Next Task/Application
+ 0x1A4 AL Previous Task/Application
+ 0x1A5 AL Preemptive Halt Task/Application
+ 0x200 Generic GUI Application Controls
+ 0x201 AC New
+ 0x202 AC Open
+ 0x203 AC Close
+ 0x204 AC Exit
+ 0x205 AC Maximize
+ 0x206 AC Minimize
+ 0x207 AC Save
+ 0x208 AC Print
+ 0x209 AC Properties
+ 0x21A AC Undo
+ 0x21B AC Copy
+ 0x21C AC Cut
+ 0x21D AC Paste
+ 0x21E AC Select All
+ 0x21F AC Find
+ 0x220 AC Find and Replace
+ 0x221 AC Search
+ 0x222 AC Go To
+ 0x223 AC Home
+ 0x224 AC Back
+ 0x225 AC Forward
+ 0x226 AC Stop
+ 0x227 AC Refresh
+ 0x228 AC Previous Link
+ 0x229 AC Next Link
+ 0x22A AC Bookmarks
+ 0x22B AC History
+ 0x22C AC Subscriptions
+ 0x22D AC Zoom In
+ 0x22E AC Zoom Out
+ 0x22F AC Zoom
+ 0x230 AC Full Screen View
+ 0x231 AC Normal View
+ 0x232 AC View Toggle
+ 0x233 AC Scroll Up
+ 0x234 AC Scroll Down
+ 0x235 AC Scroll
+ 0x236 AC Pan Left
+ 0x237 AC Pan Right
+ 0x238 AC Pan
+ 0x239 AC New Window
+ 0x23A AC Tile Horizontally
+ 0x23B AC Tile Vertically
+ 0x23C AC Format
+
+13 Digitizer
+ 0x00 Undefined
+ 0x01 Digitizer
+ 0x02 Pen
+ 0x03 Light Pen
+ 0x04 Touch Screen
+ 0x05 Touch Pad
+ 0x06 White Board
+ 0x07 Coordinate Measuring Machine
+ 0x08 3-D Digitizer
+ 0x09 Stereo Plotter
+ 0x0A Articulated Arm
+ 0x0B Armature
+ 0x0C Multiple Point Digitizer
+ 0x0D Free Space Wand
+ 0x20 Stylus
+ 0x21 Puck
+ 0x22 Finger
+ 0x30 Tip Pressure
+ 0x31 Barrel Pressure
+ 0x32 In Range
+ 0x33 Touch
+ 0x34 Untouch
+ 0x35 Tap
+ 0x36 Quality
+ 0x37 Data Valid
+ 0x38 Transducer Index
+ 0x39 Tablet Function Keys
+ 0x3A Program Change Keys
+ 0x3B Battery Strength
+ 0x3C Invert
+ 0x3D X Tilt
+ 0x3E Y Tilt
+ 0x3F Azimuth
+ 0x40 Altitude
+ 0x41 Twist
+ 0x42 Tip Switch
+ 0x43 Secondary Tip Switch
+ 0x44 Barrel Switch
+ 0x45 Eraser
+ 0x46 Tablet Pick
+
+15 Physical Interface Device
+
+16 Unicode
+ * Unicode Char u%04x
+
+20 Alphnumeric Display
+ 0x00 Undefined
+ 0x01 Alphanumeric Display
+ 0x20 Display Attributes Report
+ 0x21 ASCII Character Set
+ 0x22 Data Read Back
+ 0x23 Font Read Back
+ 0x24 Display Control Report
+ 0x25 Clear Display
+ 0x26 Display Enable
+ 0x27 Screen Saver Delay
+ 0x28 Screen Saver Enable
+ 0x29 Vertical Scroll
+ 0x2A Horizontal Scroll
+ 0x2B Character Report
+ 0x2C Display Data
+ 0x2D Display Status
+ 0x2E Stat Not Ready
+ 0x2F Stat Ready
+ 0x30 Err Not a loadable character
+ 0x31 Err Font data cannot be read
+ 0x32 Cursor Position Report
+ 0x33 Row
+ 0x34 Column
+ 0x35 Rows
+ 0x36 Columns
+ 0x37 Cursor Pixel Positioning
+ 0x38 Cursor Mode
+ 0x39 Cursor Enable
+ 0x3A Cursor Blink
+ 0x3B Font Report
+ 0x3C Font Data
+ 0x3D Character Width
+ 0x3E Character Height
+ 0x3F Character Spacing Horizontal
+ 0x40 Character Spacing Vertical
+ 0x41 Unicode Character Set
+
+128 Monitor
+ 0x00 Undefined
+ 0x01 Monitor Control
+ 0x02 EDID Information
+ 0x03 VDIF Information
+ 0x04 VESA Version
+ 0x05 On Screen Display
+ 0x06 Auto Size Center
+ 0x07 Polarity Horz Synch
+ 0x08 Polarity Vert Synch
+ 0x09 Sync Type
+ 0x0A Screen Position
+ 0x0B Horizontal Frequency
+ 0x0C Vertical Frequency
+
+129 Monitor Enumerated Values
+ 0x00 unassigned
+ * ENUM %d
+
+130 VESA Virtual Controls
+ 0x10 Brightness
+ 0x12 Contrast
+ 0x16 Video Gain Red
+ 0x18 Video Gain Green
+ 0x1A Video Gain Blue
+ 0x1C Focus
+ 0x20 Horizontal Position
+ 0x22 Horizontal Size
+ 0x24 Horizontal Pincushion
+ 0x26 Horizontal Pincushion Balance
+ 0x28 Horizontal Misconvergence
+ 0x2A Horizontal Linearity
+ 0x2C Horizontal Linearity Balance
+ 0x30 Vertical Position
+ 0x32 Vertical Size
+ 0x34 Vertical Pincushion
+ 0x36 Vertical Pincushion Balance
+ 0x38 Vertical Misconvergence
+ 0x3A Vertical Linearity
+ 0x3C Vertical Linearity Balance
+ 0x40 Parallelogram Distortion
+ 0x42 Trapezoidal Distortion
+ 0x44 Tilt
+ 0x46 Top Corner Distortion Control
+ 0x48 Top Corner Distortion Balance
+ 0x4A Bottom Corner Distortion Control
+ 0x4C Bottom Corner Distortion Balance
+ 0x56 Moiré Horizontal
+ 0x58 Moiré Vertical
+ 0x5E Input Level Select
+ 0x60 Input Source Select
+ 0x62 Stereo Mode
+ 0x6C Video Black Level Red
+ 0x6E Video Black Level Green
+ 0x70 Video Black Level Blue
+
+131 VESA Command
+ 0x00 Undefined
+ 0x01 Settings
+ 0x02 Degauss
+
+132 Power Device
+ 0x00 Undefined
+ 0x01 iName
+ 0x02 PresentStatus
+ 0x03 ChangedStatus
+ 0x04 UPS
+ 0x05 PowerSupply
+ 0x10 BatterySystem
+ 0x11 BatterySystemID
+ 0x12 Battery
+ 0x13 BatteryID
+ 0x14 Charger
+ 0x15 ChargerID
+ 0x16 PowerConverter
+ 0x17 PowerConverterID
+ 0x18 OutletSystem
+ 0x19 OutletSystemID
+ 0x1A Input
+ 0x1B InputID
+ 0x1C Output
+ 0x1D OutputID
+ 0x1E Flow
+ 0x1F FlowID
+ 0x20 Outlet
+ 0x21 OutletID
+ 0x22 Gang
+ 0x23 GangID
+ 0x24 Sink
+ 0x25 SinkID
+ 0x30 Voltage
+ 0x31 Current
+ 0x32 Frequency
+ 0x33 ApparentPower
+ 0x34 ActivePower
+ 0x35 PercentLoad
+ 0x36 Temperature
+ 0x37 Humidity
+ 0x40 ConfigVoltage
+ 0x41 ConfigCurrent
+ 0x42 ConfigFrequency
+ 0x43 ConfigApparentPower
+ 0x44 ConfigActivePower
+ 0x45 ConfigPercentLoad
+ 0x46 ConfigTemperature
+ 0x47 ConfigHumidity
+ 0x50 SwitchOnControl
+ 0x51 SwitchOffControl
+ 0x52 ToggleControl
+ 0x53 LowVoltageTransfer
+ 0x54 HighVoltageTransfer
+ 0x55 DelayBeforeReboot
+ 0x56 DelayBeforeStartup
+ 0x57 DelayBeforeShutdown
+ 0x58 Test
+ 0x59 Vendorspecificcommand
+ 0x60 Present
+ 0x61 Good
+ 0x62 InternalFailure
+ 0x63 VoltageOutOfRange
+ 0x64 FrequencyOutOfRange
+ 0x65 Overload
+ 0x66 OverCharged
+ 0x67 OverTemperature
+ 0x68 ShutdownRequested
+ 0x69 ShutdownImminent
+ 0x6A VendorSpecificAnswerValid
+ 0x6B SwitchOn/Off
+ 0x6C Switcheble
+ 0x6D Used
+ 0x6E Boost
+ 0x6F Buck
+ 0x70 Initialized
+ 0x71 Tested
+
+133 Battery System
+ 0x00 Undefined
+ 0x01 SMBBatteryMode
+ 0x02 SMBBatteryStatus
+ 0x03 SMBAlarmWarning
+ 0x04 SMBChargerMode
+ 0x05 SMBChargerStatus
+ 0x06 SMBChargerSpecInfo
+ 0x07 SMBSelectorState
+ 0x08 SMBSelectorPreset
+ 0x09 SMBSelectorInfo
+ 0x10 OptionalMfgFunction1
+ 0x11 OptionalMfgFunction2
+ 0x12 OptionalMfgFunction3
+ 0x13 OptionalMfgFunction4
+ 0x14 OptionalMfgFunction5
+ 0x15 ConnectionToSMBus
+ 0x16 OutputConnection
+ 0x17 ChargerConnection
+ 0x18 BatteryInsertion
+ 0x19 Usenext
+ 0x1A OKToUse
+ 0x28 ManufacturerAccess
+ 0x29 RemainingCapacityLimit
+ 0x2A RemainingTimeLimit
+ 0x2B AtRate
+ 0x2C CapacityMode
+ 0x2D BroadcastToCharger
+ 0x2E PrimaryBattery
+ 0x2F ChargeController
+ 0x40 TerminateCharge
+ 0x41 TermminateDischarge
+ 0x42 BelowRemainingCapacityLimit
+ 0x43 RemainingTimeLimitExpired
+ 0x44 Charging
+ 0x45 Discharging
+ 0x46 FullyCharged
+ 0x47 FullyDischarged
+ 0x48 ConditionningFlag
+ 0x49 AtRateOK
+ 0x4A SMBErrorCode
+ 0x4B NeedReplacement
+ 0x60 AtRateTimeToFull
+ 0x61 AtRateTimeToEmpty
+ 0x62 AverageCurrent
+ 0x63 Maxerror
+ 0x64 RelativeStateOfCharge
+ 0x65 AbsoluteStateOfCharge
+ 0x66 RemainingCapacity
+ 0x67 FullChargeCapacity
+ 0x68 RunTimeToEmpty
+ 0x69 AverageTimeToEmpty
+ 0x6A AverageTimeToFull
+ 0x6B CycleCount
+ 0x80 BattPackModelLevel
+ 0x81 InternalChargeController
+ 0x82 PrimaryBatterySupport
+ 0x83 DesignCapacity
+ 0x84 SpecificationInfo
+ 0x85 ManufacturerDate
+ 0x86 SerialNumber
+ 0x87 iManufacturerName
+ 0x88 iDevicename
+ 0x89 iDeviceChemistery
+ 0x8A iManufacturerData
+ 0x8B Rechargeable
+ 0x8C WarningCapacityLimit
+ 0x8D CapacityGranularity1
+ 0x8E CapacityGranularity2
+ 0xC0 InhibitCharge
+ 0xC1 EnablePolling
+ 0xC2 ResetToZero
+ 0xD0 ACPresent
+ 0xD1 BatteryPresent
+ 0xD2 PowerFail
+ 0xD3 AlarmInhibited
+ 0xD4 ThermistorUnderRange
+ 0xD5 ThermistorHot
+ 0xD6 ThermistorCold
+ 0xD7 ThermistorOverRange
+ 0xD8 VoltageOutOfRange
+ 0xD9 CurrentOutOfRange
+ 0xDA CurrentNotRegulated
+ 0xDB VoltageNotRegulated
+ 0xDC MasterMode
+ 0xDD ChargerBattery/HostControlled
+ 0xF0 ChargerSpecInfo
+ 0xF1 ChargerSpecRef
+ 0xF2 Level2
+ 0xF3 Level3
+
+140 Bar Code Scanner
+
+141 Scale Device
+
+144 Camera Control
+
+145 Arcade Device
+
+# Some Micro$oft non-standard extensions
+0xff00 Microsoft
+ 0xe9 Base Up
+ 0xea Base Down
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usbvar.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usbvar.h
new file mode 100644
index 000000000..60883dd47
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usbvar.h
@@ -0,0 +1,34 @@
+/* $NetBSD: usbvar.h,v 1.2 1999/05/11 21:15:46 augustss Exp $ */
+
+/*
+ * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/libusb/usbvar.h,v 1.1.2.2 1999/12/03 10:12:43 hohndel Exp $ */
+
+struct report_desc {
+ unsigned int size;
+ unsigned char data[1];
+};
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/memrange.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/memrange.h
new file mode 100644
index 000000000..0f4b270f4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/memrange.h
@@ -0,0 +1,72 @@
+/*
+ * Memory range attribute operations, peformed on /dev/mem
+ *
+ * $FreeBSD: src/sys/sys/memrange.h,v 1.4 1999/12/29 04:24:44 peter Exp $
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _MEMRANGE_H
+#define _MEMRANGE_H
+
+/* Memory range attributes */
+#define MDF_UNCACHEABLE (1<<0) /* region not cached */
+#define MDF_WRITECOMBINE (1<<1) /* region supports "write combine"
+ * action */
+#define MDF_WRITETHROUGH (1<<2) /* write-through cached */
+#define MDF_WRITEBACK (1<<3) /* write-back cached */
+#define MDF_WRITEPROTECT (1<<4) /* read-only region */
+#define MDF_ATTRMASK (0x00ffffff)
+
+#define MDF_FIXBASE (1<<24) /* fixed base */
+#define MDF_FIXLEN (1<<25) /* fixed length */
+#define MDF_FIRMWARE (1<<26) /* set by firmware (XXX not useful?) */
+#define MDF_ACTIVE (1<<27) /* currently active */
+#define MDF_BOGUS (1<<28) /* we don't like it */
+#define MDF_FIXACTIVE (1<<29) /* can't be turned off */
+#define MDF_BUSY (1<<30) /* range is in use */
+
+struct mem_range_desc {
+ u_int64_t mr_base;
+ u_int64_t mr_len;
+ int mr_flags;
+ char mr_owner[8];
+};
+
+struct mem_range_op {
+ struct mem_range_desc *mo_desc;
+ int mo_arg[2];
+#define MEMRANGE_SET_UPDATE 0
+#define MEMRANGE_SET_REMOVE 1
+ /* XXX want a flag that says "set and undo when I exit" */
+};
+#define MEMRANGE_GET _IOWR('m', 50, struct mem_range_op)
+#define MEMRANGE_SET _IOW('m', 51, struct mem_range_op)
+
+#ifdef _KERNEL
+
+struct mem_range_softc;
+struct mem_range_ops {
+ void (*init) __P((struct mem_range_softc * sc));
+ int (*set) __P((struct mem_range_softc * sc, struct mem_range_desc * mrd, int *arg));
+ void (*initAP) __P((struct mem_range_softc * sc));
+};
+
+struct mem_range_softc {
+ struct mem_range_ops *mr_op;
+ int mr_cap;
+ int mr_ndesc;
+ struct mem_range_desc *mr_desc;
+};
+
+extern struct mem_range_softc mem_range_softc;
+
+extern int mem_range_attr_get __P((struct mem_range_desc * mrd, int *arg));
+extern int mem_range_attr_set __P((struct mem_range_desc * mrd, int *arg));
+extern void mem_range_AP_init __P((void));
+#endif
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/ppc_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/ppc_video.c
new file mode 100644
index 000000000..edcb20c1b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/ppc_video.c
@@ -0,0 +1,141 @@
+/* $XFree86: ppc_video.c,v 1.5 2003/03/14 13:46:04 tsi Exp $ */
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/* $XConsortium: bsd_video.c /main/10 1996/10/25 11:37:57 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#include "bus/Pci.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)-1)
+#endif
+
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+#ifndef __OpenBSD__
+#define DEV_MEM "/dev/mem"
+#else
+#define DEV_MEM "/dev/xf86"
+#endif
+
+static pointer ppcMapVidMem(int, unsigned long, unsigned long, int flags);
+static void ppcUnmapVidMem(int, pointer, unsigned long);
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->linearSupported = TRUE;
+ pVidMem->mapMem = ppcMapVidMem;
+ pVidMem->unmapMem = ppcUnmapVidMem;
+ pVidMem->initialised = TRUE;
+}
+
+
+volatile unsigned char *ioBase = MAP_FAILED;
+
+static pointer
+ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ int fd = xf86Info.screenFd;
+ pointer base;
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d",
+ Base, Size, fd);
+#endif
+
+ base = mmap(0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_SHARED, fd, Base);
+ if (base == MAP_FAILED)
+ FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)",
+ "xf86MapVidMem", Size, Base, strerror(errno));
+
+ return base;
+}
+
+static void
+ppcUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap(Base, Size);
+}
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ int rv;
+ static int kmem = -1;
+
+ if (kmem == -1) {
+ kmem = open(DEV_MEM, 2);
+ if (kmem == -1) {
+ FatalError("xf86ReadBIOS: open %s", DEV_MEM);
+ }
+ }
+
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n",
+ Base, Offset, Len);
+#endif
+
+
+ lseek(kmem, Base + Offset, 0);
+ rv = read(kmem, Buf, Len);
+
+ return rv;
+}
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+Bool
+xf86DisableInterrupts()
+{
+
+ return(TRUE);
+}
+
+void
+xf86EnableInterrupts()
+{
+
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/sparc64_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/sparc64_video.c
new file mode 100644
index 000000000..d9dfcca31
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/sparc64_video.c
@@ -0,0 +1,113 @@
+/* $XFree86: sparc64_video.c,v 1.2 2003/03/14 13:46:04 tsi Exp $ */
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+
+/* $XConsortium: bsd_video.c /main/10 1996/10/25 11:37:57 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)-1)
+#endif
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+static pointer sparc64MapVidMem(int, unsigned long, unsigned long, int);
+static void sparc64UnmapVidMem(int, pointer, unsigned long);
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->linearSupported = TRUE;
+ pVidMem->mapMem = sparc64MapVidMem;
+ pVidMem->unmapMem = sparc64UnmapVidMem;
+ pVidMem->initialised = TRUE;
+}
+
+static pointer
+sparc64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size,
+ int flags)
+{
+ int fd = xf86Info.screenFd;
+ pointer base;
+
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d",
+ Base, Size, fd);
+#endif
+
+ base = mmap(0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_SHARED, fd, Base);
+ if (base == MAP_FAILED)
+ FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)",
+ "xf86MapVidMem", Size, Base, strerror(errno));
+ return base;
+}
+
+static void
+sparc64UnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap(Base, Size);
+}
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+
+ return (0);
+}
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+Bool
+xf86DisableInterrupts()
+{
+
+ return(TRUE);
+}
+
+void
+xf86EnableInterrupts()
+{
+
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile
new file mode 100644
index 000000000..820f76c20
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile
@@ -0,0 +1,46 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile,v 3.14 2002/10/11 01:46:58 dawes Exp $
+
+
+
+
+XCOMM $XConsortium: Imakefile /main/4 1996/09/28 17:23:38 rws $
+
+#include <Server.tmpl>
+
+MOUSESRC = bsdi_mouse.c
+MOUSEOBJ = bsdi_mouse.o
+
+SRCS = bsdi_init.c bsdi_video.c bsdi_io.c bios_devmem.c \
+ VTsw_noop.c std_kbdEv.c posix_tty.c $(MOUSESRC) \
+ libc_wrapper.c stdResource.c stdPci.c sigiostubs.c pm_noop.c \
+ kmod_noop.c agp_noop.c
+
+OBJS = bsdi_init.o bsdi_video.o bsdi_io.o bios_devmem.o \
+ VTsw_noop.o std_kbdEv.o posix_tty.o $(MOUSEOBJ) \
+ libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o \
+ kmod_noop.o agp_noop.o
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+RESDEFINES = -DUSESTDRES
+
+DEFINES = $(RESDEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+LinkSourceFile(bios_devmem.c,../shared)
+LinkSourceFile(VTsw_noop.c,../shared)
+LinkSourceFile(std_kbdEv.c,../shared)
+LinkSourceFile(posix_tty.c,../shared)
+LinkSourceFile(libc_wrapper.c,../shared)
+LinkSourceFile(stdResource.c,../shared)
+LinkSourceFile(stdPci.c,../shared)
+LinkSourceFile(sigiostubs.c,../shared)
+LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
+LinkSourceFile(agp_noop.c,../shared)
+
+DependTarget()
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_init.c
new file mode 100644
index 000000000..5a166ed26
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_init.c
@@ -0,0 +1,156 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_init.c,v 3.5.4.2 1998/06/05 16:23:08 dawes Exp $ */
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: bsdi_init.c /main/5 1996/02/21 17:51:15 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include <sys/param.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+extern Bool RunFromSmartParent;
+
+static Bool KeepTty = FALSE;
+
+#if BSD >= 199306
+static void
+NonBlockConsoleOff()
+{
+ register int i;
+
+ i = fcntl(2, F_GETFL, 0);
+ if (i >= 0)
+ (void) fcntl(2, F_SETFL, i & ~FNDELAY);
+}
+#endif
+
+void
+xf86OpenConsole()
+{
+ int i, fd;
+
+ if (serverGeneration == 1)
+ {
+ /* check if we're run with euid==0 */
+ if (geteuid() != 0)
+ {
+ FatalError("xf86OpenConsole: Server must be suid root\n");
+ }
+
+ if (!KeepTty)
+ {
+#if BSD >= 199306
+ if (RunFromSmartParent) {
+ if (atexit(NonBlockConsoleOff))
+ xf86Msg(X_WARNING,
+ "InitOutput: can't register NBIO exit handler\n");
+ i = fcntl(2, F_GETFL, 0);
+ if (i >= 0)
+ i = fcntl(2, F_SETFL, i | FNDELAY);
+ if (i < 0)
+ xf86Msg(X_WARNING,
+ "InitOutput: can't put stderr in non-block mode\n");
+ }
+#else
+ /*
+ * detaching the controlling tty solves problems of kbd character
+ * loss. This is not interesting for CO driver, because it is
+ * exclusive.
+ */
+ setpgrp(0, getpid());
+ if ((i = open("/dev/tty",O_RDWR)) >= 0)
+ {
+ ioctl(i,TIOCNOTTY,(char *)0);
+ close(i);
+ }
+#endif
+ }
+
+ if ((xf86Info.consoleFd = open("/dev/kbd", O_RDWR|O_NDELAY,0)) < 0)
+ {
+ FatalError("xf86OpenConsole: Cannot open /dev/kbd (%s)\n",
+ strerror(errno));
+ }
+ if ((xf86Info.screenFd = open("/dev/vga", O_RDWR|O_NDELAY,0)) < 0)
+ {
+ FatalError("xf86OpenConsole: Cannot open /dev/vga (%s)\n",
+ strerror(errno));
+ }
+
+ if (ioctl(xf86Info.consoleFd, PCCONIOCRAW, 0) < 0)
+ {
+ FatalError("%s: PCCONIOCRAW failed (%s)\n",
+ "xf86OpenConsole", strerror(errno));
+ }
+ }
+ return;
+}
+
+void
+xf86CloseConsole()
+{
+ ioctl (xf86Info.consoleFd, PCCONIOCCOOK, 0);
+
+ if (xf86Info.screenFd != xf86Info.consoleFd)
+ {
+ close(xf86Info.screenFd);
+ }
+ close(xf86Info.consoleFd);
+ return;
+}
+
+int
+xf86ProcessArgument (int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty"))
+ {
+ KeepTty = TRUE;
+ return(1);
+ }
+ return(0);
+}
+
+void
+xf86UseMsg()
+{
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_io.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_io.c
new file mode 100644
index 000000000..e37bf308c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_io.c
@@ -0,0 +1,110 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_io.c,v 3.13 2002/10/11 01:40:34 dawes Exp $ */
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Dawes <dawes@xfree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Dawes
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Dawes make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID DAWES BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: bsdi_io.c /main/10 1996/10/19 18:06:13 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
+{
+ if (loudness && pitch)
+ {
+ int data[2];
+
+ data[0] = pitch;
+ data[1] = (duration * loudness) / 50;
+ ioctl(xf86Info.consoleFd, PCCONIOCBEEP, data);
+ }
+}
+
+void
+xf86SetKbdLeds(int leds)
+{
+ ioctl(xf86Info.consoleFd, PCCONIOCSETLED, &leds);
+}
+
+int
+xf86GetKbdLeds()
+{
+ return(0);
+}
+
+void
+xf86SetKbdRepeat(char rad)
+{
+ return;
+}
+
+static struct termio kbdtty;
+
+void
+xf86KbdInit()
+{
+ tcgetattr(xf86Info.consoleFd, &kbdtty);
+}
+
+int
+xf86KbdOn()
+{
+ struct termios nTty;
+
+ nTty = kbdtty;
+ nTty.c_iflag = IGNPAR | IGNBRK;
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME] = 0;
+ nTty.c_cc[VMIN] = 1;
+ cfsetispeed(&nTty, 9600);
+ cfsetospeed(&nTty, 9600);
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
+ return(xf86Info.consoleFd);
+}
+
+int
+xf86KbdOff()
+{
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty);
+ return(xf86Info.consoleFd);
+}
+
+#include "xf86OSKbd.h"
+
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+ return FALSE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_mouse.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_mouse.c
new file mode 100644
index 000000000..fb50cfcee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_mouse.c
@@ -0,0 +1,34 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_mouse.c,v 1.1 1999/05/22 08:40:10 dawes Exp $ */
+
+/*
+ * Copyright 1999 by The XFree86 Project, Inc.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+
+static int
+SupportedInterfaces(void)
+{
+ /* XXX This needs to be checked. */
+ return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_AUTO;
+}
+
+OSMouseInfoPtr
+xf86OSMouseInit(int flags)
+{
+ OSMouseInfoPtr p;
+
+ p = xcalloc(sizeof(OSMouseInfoRec), 1);
+ if (!p)
+ return NULL;
+ p->SupportedInterfaces = SupportedInterfaces;
+ return p;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_video.c
new file mode 100644
index 000000000..5b1e474c7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_video.c
@@ -0,0 +1,182 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_video.c,v 3.10 2003/03/14 13:46:05 tsi Exp $ */
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: bsdi_video.c /main/4 1996/02/21 17:51:22 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+pointer
+xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size)
+{
+ pointer base;
+
+ /* just try the mapping, and either it will work, or not */
+ base = mmap(0, Size,
+ (Flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FILE, xf86Info.screenFd, Base - 0xA0000);
+ if (base == MAP_FAILED)
+ {
+ FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s) at 0x%x\n",
+ strerror(errno), Base);
+ }
+ return(base);
+}
+
+void
+xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap((caddr_t)Base, Size);
+}
+
+Bool
+xf86LinearVidMem()
+{
+ return(TRUE);
+}
+
+/***************************************************************************/
+/* I/O Permissions section */
+/***************************************************************************/
+
+/*
+ * BSDI has a single system-wide TSS I/O bitmap that covers ports up to
+ * 0xFFFF. By default, the TSS has ports 0x3B0-0x3DF enabled.
+ *
+ * It also allows the IOPL to be enabled or disabled on a per-process
+ * basis. Here, we use the IOPL only.
+ */
+
+static Bool ExtendedEnabled = FALSE;
+
+Bool
+xf86EnableIO()
+{
+ if (ExtendedEnabled)
+ return TRUE;
+
+ if (ioctl(xf86Info.consoleFd, PCCONENABIOPL, 0) < 0)
+ {
+ xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O\n",
+ "xf86EnableIOPorts");
+ return FALSE;
+ }
+ ExtendedEnabled = TRUE;
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ if (!ExtendedEnabled)
+ return;
+
+ ioctl(xf86Info.consoleFd, PCCONDISABIOPL, 0);
+ ExtendedEnabled = FALSE;
+}
+
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+Bool
+xf86DisableInterrupts()
+{
+ if (!ExtendedEnabled)
+ {
+ if (ioctl(xf86Info.consoleFd, PCCONENABIOPL, 0) < 0)
+ {
+ return(FALSE);
+ }
+ }
+
+#ifdef __GNUC__
+ __asm__ __volatile__("cli");
+#else
+ asm("cli");
+#endif /* __GNUC__ */
+
+ if (!ExtendedEnabled)
+ {
+ ioctl(xf86Info.consoleFd, PCCONDISABIOPL, 0);
+ }
+
+ return(TRUE);
+}
+
+void
+xf86EnableInterrupts()
+{
+ if (!ExtendedEnabled)
+ {
+ ioctl(xf86Info.consoleFd, PCCONENABIOPL, 0);
+ }
+
+#ifdef __GNUC__
+ __asm__ __volatile__("sti");
+#else
+ asm("sti");
+#endif /* __GNUC__ */
+
+ if (!ExtendedEnabled)
+ {
+ ioctl(xf86Info.consoleFd, PCCONDISABIOPL, 0);
+ }
+
+ return;
+}
+
+void
+xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base,
+ unsigned long Size)
+{
+}
+
+Bool
+xf86CheckMTRR(int ScreenNum)
+{
+ return FALSE;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/460gxPCI.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/460gxPCI.c
new file mode 100644
index 000000000..255dfa12f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/460gxPCI.c
@@ -0,0 +1,470 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/460gxPCI.c,v 1.4 2003/08/29 21:08:06 tsi Exp $ */
+/*
+ * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+/*
+ * This file contains the glue necessary for support of Intel's 460GX chipset.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "460gxPCI.h"
+#include "xf86.h"
+#include "Pci.h"
+
+/* 460GX register definitions */
+/* SAC at 0:10:0 */
+#define CBN 0x0040
+/* SAC at CBN:0:0 */
+#define DEVNPRES 0x0070
+/* SAC at CBN:1[0-7]:0 */
+#define BUSNO 0x0048
+#define SUBNO 0x0049
+#define VGASE 0x0080
+#define PCIS 0x0084
+#define IOR 0x008C
+#define IORD 0x008E /* CBN:10:0 only */
+/* PXB at CBN:1[0-7]:1 */
+#define ERRCMD 0x0046
+
+static int cbn_460gx = -1;
+static CARD32 cbdevs_460gx = 0;
+static CARD16 iord_460gx;
+static int busno_460gx[8], subno_460gx[8];
+static CARD8 pcis_460gx[8], ior_460gx[8];
+static CARD8 has_err_460gx[8], err_460gx[8];
+static CARD8 iomap_460gx[16]; /* One for each 4k */
+static pciBusFuncs_t BusFuncs_460gx;
+
+static pciConfigPtr
+Verify460GXBus(int bus)
+{
+ pciConfigPtr pPCI;
+
+ if ((bus < 0) || (bus >= pciNumBuses) ||
+ !pciBusInfo[bus] || !(pPCI = pciBusInfo[bus]->bridge) ||
+ (pPCI->busnum != cbn_460gx) || (pPCI->funcnum != 0) ||
+ (pPCI->devnum < 0x10) || (pPCI->devnum > 0x17))
+ return NULL;
+
+ return pPCI;
+}
+
+/*
+ * This function is called to emulate the various settings in a P2P or CardBus
+ * bridge's control register using one of a 460GX's SAC host bridges.
+ */
+static CARD16
+Control460GXBridge(int bus, CARD16 mask, CARD16 value)
+{
+ pciConfigPtr pPCI;
+ PCITAG tag;
+ CARD16 current = 0;
+ CARD8 tmp;
+
+ if ((pPCI = Verify460GXBus(bus))) {
+ /* Start with VGA enablement */
+ tmp = pciReadByte(pPCI->tag, VGASE);
+ if (tmp & 0x01) {
+ current |= PCI_PCI_BRIDGE_VGA_EN;
+ if ((mask & PCI_PCI_BRIDGE_VGA_EN) &&
+ !(value & PCI_PCI_BRIDGE_VGA_EN))
+ pciWriteByte(pPCI->tag, VGASE, tmp & ~0x01);
+ } else {
+ if (mask & value & PCI_PCI_BRIDGE_VGA_EN)
+ pciWriteByte(pPCI->tag, VGASE, tmp | 0x01);
+ }
+
+ /* Move on to master abort failure enablement */
+ if (has_err_460gx[pPCI->devnum - 0x10]) {
+ tag = PCI_MAKE_TAG(pPCI->busnum, pPCI->devnum, pPCI->funcnum + 1);
+ tmp = pciReadByte(tag, ERRCMD);
+ if (tmp & 0x01) {
+ current |= PCI_PCI_BRIDGE_MASTER_ABORT_EN;
+ if ((mask & PCI_PCI_BRIDGE_MASTER_ABORT_EN) &&
+ !(value & PCI_PCI_BRIDGE_MASTER_ABORT_EN))
+ pciWriteByte(tag, ERRCMD, tmp & ~0x01);
+ } else {
+ if (mask & value & PCI_PCI_BRIDGE_MASTER_ABORT_EN)
+ pciWriteByte(tag, ERRCMD, tmp | 0x01);
+ }
+ }
+
+ /* Put emulation of any other P2P bridge control here */
+ }
+
+ return (current & ~mask) | (value & mask);
+}
+
+/*
+ * Retrieve various bus numbers representing the connections provided by 460GX
+ * host bridges.
+ */
+static void
+Get460GXBridgeBuses(int bus, int *primary, int *secondary, int *subordinate)
+{
+ pciConfigPtr pPCI = Verify460GXBus(bus);
+ int i;
+
+ /* The returned bus numbers are initialised by the caller */
+
+ if (!pPCI)
+ return;
+
+ i = pPCI->devnum - 0x10;
+
+ /* These are not modified, so no need to re-read them */
+ if (primary)
+ *primary = pPCI->busnum;
+ if (secondary)
+ *secondary = busno_460gx[i];
+ if (subordinate)
+ *subordinate = subno_460gx[i];
+}
+
+/* Retrieves a list of the resources routed to a host bridge's secondary bus */
+static void
+Get460GXBridgeResources(int bus,
+ pointer *ppIoRes,
+ pointer *ppMemRes,
+ pointer *ppPmemRes)
+{
+ pciConfigPtr pPCI = Verify460GXBus(bus);
+ resRange range;
+ unsigned int i, j;
+
+ if (ppIoRes) {
+ xf86FreeResList(*ppIoRes);
+ *ppIoRes = NULL;
+
+ if (pPCI) {
+ for (i = 0; i <= 0x0F; i++) {
+ if (iomap_460gx[i] != pPCI->devnum)
+ continue;
+
+ RANGE(range, i << 12, ((i + 1) << 12) - 1,
+ RANGE_TYPE(ResExcIoBlock, 0));
+ *ppIoRes = xf86AddResToList(*ppIoRes, &range, -1);
+ }
+ }
+ }
+
+ if (ppMemRes) {
+ xf86FreeResList(*ppMemRes);
+ *ppMemRes = NULL;
+
+ if (pPCI) {
+ if (!(i = (pPCI->devnum - 0x10)))
+ j = 127; /* (4GB - 32M) / 32M */
+ else
+ j = pcis_460gx[i - 1] & 0x7F;
+
+ i = pcis_460gx[i] & 0x7F;
+ if (i < j) {
+ RANGE(range, i << 25, (j << 25) - 1,
+ RANGE_TYPE(ResExcMemBlock, 0));
+ *ppMemRes = xf86AddResToList(*ppMemRes, &range, -1);
+ }
+ }
+ }
+
+ if (ppPmemRes) {
+ xf86FreeResList(*ppPmemRes);
+ *ppPmemRes = NULL;
+ }
+}
+
+/*
+ * This checks for, and validates, the presence of the 460GX chipset, and sets
+ * cbn_460gx to a positive value accordingly. This function returns TRUE if
+ * the chipset scan is to be stopped, or FALSE if the scan is to move on to the
+ * next chipset.
+ */
+
+Bool
+xorgProbe460GX(scanpciWrapperOpt flags)
+{
+ pciBusInfo_t *pBusInfo;
+ PCITAG tag;
+
+ /* Bus zero should already be set up */
+ if (!(pBusInfo = pciBusInfo[0])) {
+ cbn_460gx = -1;
+ return FALSE;
+ }
+ /* First look for a 460GX's primary host bridge */
+ tag = PCI_MAKE_TAG(0, 0x10, 0);
+ if (pciReadLong(tag, PCI_ID_REG) == DEVID(VENDOR_INTEL, CHIP_460GX_SAC)) {
+ return TRUE;
+ }
+
+ cbn_460gx = -1;
+
+ return FALSE;
+}
+
+void
+xf86PreScan460GX(void)
+{
+ pciBusInfo_t *pBusInfo;
+ PCITAG tag;
+ CARD32 tmp;
+ int i, devno;
+
+ if (!(pBusInfo = pciBusInfo[0]))
+ return;
+
+ /* Get CBN (Chipset bus number) */
+ tag = PCI_MAKE_TAG(0, 0x10, 0);
+ if (!(cbn_460gx = (unsigned int)pciReadByte(tag, CBN))) {
+ /* Sanity check failed */
+ cbn_460gx = -1;
+ return;
+ }
+
+ if (pciNumBuses <= cbn_460gx)
+ pciNumBuses = cbn_460gx + 1;
+
+ /* Set up bus CBN */
+ if (!pciBusInfo[cbn_460gx]) {
+ pciBusInfo[cbn_460gx] = xnfalloc(sizeof(pciBusInfo_t));
+ *pciBusInfo[cbn_460gx] = *pBusInfo;
+ }
+
+ tag = PCI_MAKE_TAG(cbn_460gx, 0, 0);
+ if (pciReadLong(tag, PCI_ID_REG) != DEVID(VENDOR_INTEL, CHIP_460GX_SAC)) {
+ /* Sanity check failed */
+ cbn_460gx = -1;
+ return;
+ }
+
+ /*
+ * Find out which CBN devices the firmware thinks are present. Of these,
+ * we are only interested in devices 0x10 through 0x17.
+ */
+ cbdevs_460gx = pciReadLong(tag, DEVNPRES);
+
+ for (i = 0, devno = 0x10; devno <= 0x17; i++, devno++) {
+ tag = PCI_MAKE_TAG(cbn_460gx, devno, 0);
+ if (pciReadLong(tag, PCI_ID_REG) !=
+ DEVID(VENDOR_INTEL, CHIP_460GX_SAC)) {
+ /* Sanity check failed */
+ cbn_460gx = -1;
+ return;
+ }
+
+ if (devno == 0x10)
+ iord_460gx = pciReadWord(tag, IORD);
+
+ busno_460gx[i] = (unsigned int)pciReadByte(tag, BUSNO);
+ subno_460gx[i] = (unsigned int)pciReadByte(tag, SUBNO);
+ pcis_460gx[i] = pciReadByte(tag, PCIS);
+ ior_460gx[i] = pciReadByte(tag, IOR);
+
+ has_err_460gx[i] = err_460gx[i] = 0; /* Insurance */
+
+ tag = PCI_MAKE_TAG(cbn_460gx, devno, 1);
+ tmp = pciReadLong(tag, PCI_ID_REG);
+ switch (tmp) {
+ case DEVID(VENDOR_INTEL, CHIP_460GX_PXB):
+ case DEVID(VENDOR_INTEL, CHIP_460GX_WXB):
+ if (cbdevs_460gx & (1 << devno)) {
+ /* Sanity check failed */
+ cbn_460gx = -1;
+ return;
+ }
+
+ /*
+ * XXX I don't have WXB docs, but PCI register dumps indicate that
+ * the registers we are interested in are consistent with those of
+ * the PXB.
+ */
+ err_460gx[i] = pciReadByte(tag, ERRCMD);
+ has_err_460gx[i] = 1;
+ break;
+
+ case DEVID(VENDOR_INTEL, CHIP_460GX_GXB_1):
+ if (cbdevs_460gx & (1 << devno)) {
+ /* Sanity check failed */
+ cbn_460gx = -1;
+ return;
+ }
+
+ /*
+ * XXX GXB isn't documented to have an ERRCMD register, nor any
+ * other means of failing master aborts. For now, assume master
+ * aborts are always allowed to complete normally.
+ */
+ break;
+
+ default:
+ if (((CARD16)(tmp + 1U) <= (CARD16)1U) &&
+ (cbdevs_460gx & (1U << devno)))
+ break;
+ /* Sanity check failed */
+ cbn_460gx = -1;
+ return;
+ }
+ }
+
+ /* Allow master aborts to complete normally */
+ for (i = 0, devno = 0x10; devno <= 0x17; i++, devno++) {
+ if (!(err_460gx[i] & 0x01))
+ continue;
+
+ pciWriteByte(PCI_MAKE_TAG(cbn_460gx, devno, 1),
+ ERRCMD, err_460gx[i] & ~0x01);
+ }
+
+ /*
+ * The 460GX spec says that any access to buses higher than CBN will be
+ * master-aborted. It seems possible however that this is not the case in
+ * all 460GX implementations. For now, limit the bus scan to CBN, unless
+ * we have already found a higher bus number.
+ */
+ for (i = 0; subno_460gx[i] < cbn_460gx; ) {
+ if (++i < 8)
+ continue;
+
+ pciMaxBusNum = cbn_460gx + 1;
+ break;
+ }
+
+ return;
+}
+
+/* This does some 460GX-related processing after the PCI bus scan */
+void
+xf86PostScan460GX(void)
+{
+ pciConfigPtr pPCI, *ppPCI;
+ pciBusInfo_t *pBusInfo;
+ int i, j, devno;
+
+ if (cbn_460gx <= 0)
+ return;
+
+ /* Set up our extra bus functions */
+ BusFuncs_460gx = *(pciBusInfo[0]->funcs);
+ BusFuncs_460gx.pciControlBridge = Control460GXBridge;
+ BusFuncs_460gx.pciGetBridgeBuses = Get460GXBridgeBuses;
+ BusFuncs_460gx.pciGetBridgeResources = Get460GXBridgeResources;
+
+ /*
+ * Mark all host bridges so that they are ignored by the upper-level
+ * xf86GetPciBridgeInfo() function. This marking is later clobbered by the
+ * tail end of xf86scanpci() for those bridges that actually have bus
+ * segments associated with them.
+ */
+ ppPCI = xf86scanpci(0); /* Recursion is only apparent */
+ while ((pPCI = *ppPCI++)) {
+ if ((pPCI->pci_base_class == PCI_CLASS_BRIDGE) &&
+ (pPCI->pci_sub_class == PCI_SUBCLASS_BRIDGE_HOST))
+ pPCI->businfo = HOST_NO_BUS;
+ }
+
+ ppPCI = xf86scanpci(0); /* Recursion is only apparent */
+ j = 0;
+
+ /*
+ * Fix up CBN bus linkage. This is somewhat arbitrary. The bridge chosen
+ * for this must be a CBN device so that bus CBN can be recognised as the
+ * root segment. It also cannot be any of the bus expanders (devices
+ * CBN:0x10:0 through CBN:0x17:0 nor any of their functions). For now, we
+ * chose the SAC host bridge at CBN:0:0.
+ */
+ pBusInfo = pciBusInfo[cbn_460gx];
+ pBusInfo->bridge = pciBusInfo[0]->bridge; /* Just in case */
+ while ((pPCI = *ppPCI++)) {
+ if (pPCI->busnum < cbn_460gx)
+ continue;
+ if (pPCI->busnum > cbn_460gx)
+ break;
+ if (pPCI->devnum < 0)
+ continue;
+ if (pPCI->devnum > 0)
+ break;
+ if (pPCI->funcnum < 0)
+ continue;
+ if (pPCI->funcnum > 0)
+ break;
+
+ pBusInfo->bridge = pPCI;
+ pBusInfo->secondary = FALSE;
+ pBusInfo->primary_bus = cbn_460gx;
+ break;
+ }
+
+ for (i = 0, devno = 0x10; devno <= 0x17; i++, devno++) {
+ /* Restore ERRCMD registers */
+ if (err_460gx[i] & 0x01)
+ pciWriteByte(PCI_MAKE_TAG(cbn_460gx, devno, 1),
+ ERRCMD, err_460gx[i]);
+
+ if (!(cbdevs_460gx & (1 << devno))) {
+ while ((pPCI = *ppPCI++)) {
+ if (pPCI->busnum < cbn_460gx)
+ continue;
+ if (pPCI->busnum > cbn_460gx)
+ break;
+ if (pPCI->devnum < devno)
+ continue;
+ if (pPCI->devnum > devno)
+ break;
+ if (pPCI->funcnum < 0)
+ continue;
+ if (pPCI->funcnum > 0)
+ break;
+
+ if ((pBusInfo == pciBusInfo[busno_460gx[i]]))
+ break;
+
+ /* Fix bus linkage */
+ pBusInfo->bridge = pPCI;
+ pBusInfo->secondary = TRUE;
+ pBusInfo->primary_bus = cbn_460gx;
+
+ /* Plug in chipset routines */
+ pBusInfo->funcs = &BusFuncs_460gx;
+ break;
+ }
+ }
+
+ /* Decode IOR registers */
+ for(; j <= (ior_460gx[i] & 0x0F); j++)
+ iomap_460gx[j] = devno;
+ }
+
+ /* The bottom 4k of I/O space is always routed to PCI0a */
+ iomap_460gx[0] = 0x10;
+
+ /* Decode IORD register */
+ for (j = 1; j <= 0x0F; j++)
+ if (iord_460gx & (1 << j))
+ iomap_460gx[j] = 0x10;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/460gxPCI.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/460gxPCI.h
new file mode 100644
index 000000000..65a19b2f0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/460gxPCI.h
@@ -0,0 +1,42 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/460gxPCI.h,v 1.1 2003/01/02 18:12:48 tsi Exp $ */
+/*
+ * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef PCI_460GX_H
+#define PCI_460GX_H 1
+
+#include <X11/Xdefs.h>
+#include <Pci.h>
+
+Bool xorgProbe460GX(scanpciWrapperOpt flags);
+void xf86PreScan460GX(void);
+void xf86PostScan460GX(void);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Imakefile
new file mode 100644
index 000000000..bae6ee7c2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Imakefile
@@ -0,0 +1,165 @@
+XCOMM $XConsortium: Imakefile /main/16 1996/10/27 18:07:43 kaleb $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile,v 1.29tsi Exp $
+
+#include <Server.tmpl>
+
+#if defined(LinuxArchitecture) && defined(AlphaArchitecture)
+
+XCOMM Alpha (Linux) PCI driver
+
+PCIDRVRSRC = axpPci.c
+PCIDRVROBJ = axpPci.o
+
+#elif defined(LinuxArchitecture) && defined(SparcArchitecture)
+
+XCOMM Sparc SBUS driver and generic Linux PCI driver
+
+PCIDRVRSRC = sparcPci.c linuxPci.c
+PCIDRVROBJ = sparcPci.o linuxPci.o
+SBUSDRVSRC = Sbus.c
+SBUSDRVOBJ = Sbus.o
+
+#elif defined(SunArchitecture) && defined(SparcArchitecture)
+
+XCOMM Sparc SBUS & PCI drivers
+
+PCIDRVRSRC = sparcPci.c
+PCIDRVROBJ = sparcPci.o
+SBUSDRVSRC = Sbus.c
+SBUSDRVOBJ = Sbus.o
+
+#elif defined(LinuxArchitecture) && \
+ (defined(PpcArchitecture) || \
+ defined(Ppc64Architecture) || \
+ defined(MipsArchitecture) || \
+ defined(ia64Architecture) || \
+ defined(Mc68020Architecture) || \
+ defined(Arm32Architecture) || \
+ defined(HPArchitecture) || \
+ defined(s390Architecture) || \
+ defined(SuperHArchitecture) || \
+ defined(SuperHebArchitecture))
+
+XCOMM generic linux PCI driver (using /proc/bus/pci, requires kernel 2.2)
+
+PCIDRVRSRC = linuxPci.c
+PCIDRVROBJ = linuxPci.o
+
+#elif defined(OpenBSDArchitecture) && \
+ (defined(PpcArchitecture) || \
+ defined(AlphaArchitecture) || \
+ defined(Sparc64Architecture))
+
+XCOMM OpenBSD/alpha, OpenBSD/powerpc and OpenBSD/sparc64
+
+PCIDRVRSRC = freebsdPci.c
+PCIDRVROBJ = freebsdPci.o
+
+#elif defined(NetBSDArchitecture) && defined(PpcArchitecture)
+
+XCOMM NetBSD/powerpc
+
+PCIDRVRSRC = netbsdPci.c
+PCIDRVROBJ = netbsdPci.o
+
+#elif defined(FreeBSDArchitecture) && defined(PpcArchitecture)
+
+XCOMM FreeBSD/PowerPC PCI driver (using /dev/pci)
+
+PCIDRVRSRC = freebsdPci.c
+PCIDRVROBJ = freebsdPci.o
+
+#elif defined(PpcArchitecture)
+
+XCOMM PowerPC PCI drivers
+
+PCIDRVRSRC = ppcPci.c
+PCIDRVROBJ = ppcPci.o
+
+#elif defined(LinuxArchitecture) && \
+ (defined(i386Architecture) || defined(AMD64Architecture))
+
+XCOMM ix86 PCI driver with OS fallback for Linux
+
+PCIDRVRSRC = ix86Pci.c linuxPci.c
+PCIDRVROBJ = ix86Pci.o linuxPci.o
+
+#elif defined(KFreeBSDArchitecture) && \
+ (defined(AlphaArchitecture) || defined(AMD64Architecture))
+
+XCOMM generic FreeBSD PCI driver (using /dev/pci)
+
+PCIDRVRSRC = freebsdPci.c
+PCIDRVROBJ = freebsdPci.o
+
+#elif defined(KFreeBSDArchitecture) && defined(Sparc64Architecture)
+
+XCOMM Sparc SBUS & PCI drivers
+
+PCIDRVRSRC = freebsdPci.c
+PCIDRVROBJ = freebsdPci.o
+SBUSDRVSRC = Sbus.c
+SBUSDRVOBJ = Sbus.o
+
+#elif defined(NetBSDArchitecture) && defined(AlphaArchitecture)
+
+XCOMM Alpha (NetBSD) PCI driver
+
+PCIDRVRSRC = netbsdPci.c
+PCIDRVROBJ = netbsdPci.o
+
+#elif defined(i386Architecture) || \
+ defined(ia64Architecture) || \
+ defined(AMD64Architecture)
+
+XCOMM ix86 PCI driver
+
+PCIDRVRSRC = ix86Pci.c
+PCIDRVROBJ = ix86Pci.o
+XCOMM PCIDRVRSRC = linuxPci.c
+XCOMM PCIDRVROBJ = linuxPci.o
+
+#else
+XCOMM no PCI driver -- shouldn't get here
+#endif
+
+#if defined(SparcArchitecture)
+# if !defined(SunArchitecture)
+PCIARCHSRC = sparcPci.c
+PCIARCHOBJ = sparcPci.o
+# endif
+#elif defined(ia64Architecture)
+PCIARCHSRC = 460gxPCI.c e8870PCI.c zx1PCI.c altixPCI.c
+PCIARCHOBJ = 460gxPCI.o e8870PCI.o zx1PCI.o altixPCI.o
+#endif
+
+SRCS = Pci.c $(PCIDRVRSRC) $(SBUSDRVSRC) $(PCIARCHSRC)
+OBJS = Pci.o $(PCIDRVROBJ) $(SBUSDRVOBJ) $(PCIARCHOBJ)
+
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC)
+
+NormalLibraryObjectRule()
+SubdirLibraryRule($(OBJS))
+
+/*
+ * egcs 1.1.2 as provided with some Linux distributions has an optimisation
+ * bug that results in bad code for this file.
+ */
+#if Egcs112Bug
+SpecialCObjectRule(Pci,NullParameter,-O0)
+#endif
+
+#if defined(SunArchitecture) && defined(SparcArchitecture)
+
+LFS_DEFINES = `getconf LFS_CFLAGS`
+
+SpecialCObjectRule(sparcPci,NullParameter,$(LFS_DEFINES))
+
+#endif
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Pci.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Pci.c
new file mode 100644
index 000000000..4e71eb614
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Pci.c
@@ -0,0 +1,1453 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c,v 1.82 2004/01/16 15:39:04 tsi Exp $ */
+/*
+ * Pci.c - New server PCI access functions
+ *
+ * The XFree86 server PCI access functions have been reimplemented as a
+ * framework that allows each supported platform/OS to have their own
+ * platform/OS specific pci driver.
+ *
+ * All of the public PCI access functions exported to the other parts of
+ * the server are declared in Pci.h and defined herein. These include:
+ * pciInit() - Initialize PCI access functions
+ * pciFindFirst() - Find a PCI device by dev/vend id
+ * pciFindNext() - Find another PCI device by dev/vend id
+ * pciReadLong() - Read a 32 bit value from a device's cfg space
+ * pciReadWord() - Read a 16 bit value from a device's cfg space
+ * pciReadByte() - Read an 8 bit value from a device's cfg space
+ * pciWriteLong() - Write a 32 bit value to a device's cfg space
+ * pciWriteWord() - Write a 16 bit value to a device's cfg space
+ * pciWriteByte() - Write an 8 bit value to a device's cfg space
+ * pciSetBitsLong() - Write a 32 bit value against a mask
+ * pciSetBitsByte() - Write an 8 bit value against a mask
+ * pciTag() - Return tag for a given PCI bus, device, &
+ * function
+ * pciBusAddrToHostAddr() - Convert a PCI address to a host address
+ * pciHostAddrToBusAddr() - Convert a host address to a PCI address
+ * pciGetBaseSize() - Returns the number of bits in a PCI base
+ * addr mapping
+ * xf86MapPciMem() - Like xf86MapVidMem() except function expects
+ * a PCI address and a PCITAG that identifies
+ * a PCI device
+ * xf86ReadPciBIOS() - Like xf86ReadBIOS() but can handle PCI/host
+ * address translation and BIOS decode enabling
+ * xf86scanpci() - Return info about all PCI devices
+ * xf86GetPciDomain() - Return domain number from a PCITAG
+ * xf86MapDomainMemory() - Like xf86MapPciMem() but can handle
+ * domain/host address translation
+ * xf86MapDomainIO() - Maps PCI I/O spaces
+ * xf86ReadDomainMemory() - Like xf86ReadPciBIOS() but can handle
+ * domain/host address translation
+ *
+ * The actual PCI backend driver is selected by the pciInit() function
+ * (see below) using either compile time definitions, run-time checks,
+ * or both.
+ *
+ * Certain generic functions are provided that make the implementation
+ * of certain well behaved platforms (e.g. those supporting PCI config
+ * mechanism 1 or some thing close to it) very easy.
+ *
+ * Less well behaved platforms/OS's can roll their own functions.
+ *
+ * To add support for another platform/OS, add a call to fooPciInit() within
+ * pciInit() below under the correct compile time definition or run-time
+ * conditional.
+ *
+ * The fooPciInit() procedure must do three things:
+ * 1) Initialize the pciBusTable[] for all primary PCI buses including
+ * the per domain PCI access functions (readLong, writeLong,
+ * addrBusToHost, and addrHostToBus).
+ *
+ * 2) Add entries to pciBusTable[] for configured secondary buses. This
+ * step may be skipped if a platform is using the generic findFirst/
+ * findNext functions because these procedures will automatically
+ * discover and add secondary buses dynamically.
+ *
+ * 3) Overide default settings for global PCI access functions if
+ * required. These include pciFindFirstFP, pciFindNextFP,
+ * Of course, if you choose not to use one of the generic
+ * functions, you will need to provide a platform specifc replacement.
+ *
+ * Gary Barton
+ * Concurrent Computer Corporation
+ * garyb@gate.net
+ *
+ */
+
+/*
+ * Copyright 1998 by Concurrent Computer Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Concurrent Computer
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Concurrent Computer Corporation makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Copyright 1998 by Metro Link Incorporated
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * This software is derived from the original XFree86 PCI code
+ * which includes the following copyright notices as well:
+ *
+ * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the above listed copyright holder(s)
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. The above listed
+ * copyright holder(s) make(s) no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * This code is also based heavily on the code in FreeBSD-current, which was
+ * written by Wolfgang Stanglmeier, and contains the following copyright:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+/*
+ * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <errno.h>
+#include <signal.h>
+#include <X11/Xarch.h>
+#include "compiler.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
+#include "xf86_OSproc.h"
+#include "Pci.h"
+
+#define PCI_MFDEV_SUPPORT 1 /* Include PCI multifunction device support */
+#define PCI_BRIDGE_SUPPORT 1 /* Include support for PCI-to-PCI bridges */
+
+/*
+ * Global data
+ */
+static int pciInitialized = 0;
+
+CARD32 pciDevid; /* Requested device/vendor ID (after mask) */
+CARD32 pciDevidMask; /* Bit mask applied (AND) before comparison */
+ /* of real devid's with requested */
+
+int pciBusNum; /* Bus Number of current device */
+int pciDevNum; /* Device number of current device */
+int pciFuncNum; /* Function number of current device */
+PCITAG pciDeviceTag; /* Tag for current device */
+
+pciBusInfo_t *pciBusInfo[MAX_PCI_BUSES] = { NULL, };
+int pciNumBuses = 0; /* Actual number of PCI buses */
+int pciMaxBusNum = MAX_PCI_BUSES;
+static Bool inProbe = FALSE;
+
+static pciConfigPtr pci_devp[MAX_PCI_DEVICES + 1] = {NULL, };
+
+/*
+ * Platform specific PCI function pointers.
+ *
+ * NOTE: A platform/OS specific pci init procedure can override these defaults
+ * by setting them to the appropriate platform dependent functions.
+ */
+PCITAG (*pciFindFirstFP)(void) = pciGenFindFirst;
+PCITAG (*pciFindNextFP)(void) = pciGenFindNext;
+
+/*
+ * pciInit - choose correct platform/OS specific PCI init routine
+ */
+void
+pciInit()
+{
+ if (pciInitialized)
+ return;
+
+ pciInitialized = 1;
+
+ /* XXX */
+#if defined(DEBUGPCI)
+ if (DEBUGPCI >= xf86Verbose)
+ xf86Verbose = DEBUGPCI;
+#endif
+
+ ARCH_PCI_INIT();
+#if defined(ARCH_PCI_OS_INIT)
+ if (pciNumBuses <= 0)
+ ARCH_PCI_OS_INIT();
+#endif
+}
+
+PCITAG
+pciFindFirst(CARD32 id, CARD32 mask)
+{
+#ifdef DEBUGPCI
+ ErrorF("pciFindFirst(0x%lx, 0x%lx), pciInit = %d\n", id, mask, pciInitialized);
+#endif
+ pciInit();
+
+ pciDevid = id & mask;
+ pciDevidMask = mask;
+
+ return((*pciFindFirstFP)());
+}
+
+PCITAG
+pciFindNext(void)
+{
+#ifdef DEBUGPCI
+ ErrorF("pciFindNext(), pciInit = %d\n", pciInitialized);
+#endif
+ pciInit();
+
+ return((*pciFindNextFP)());
+}
+
+CARD32
+pciReadLong(PCITAG tag, int offset)
+{
+ int bus = PCI_BUS_FROM_TAG(tag);
+
+#ifdef DEBUGPCI
+ ErrorF("pciReadLong(0x%lx, %d)\n", tag, offset);
+#endif
+ pciInit();
+
+ if ((bus >= 0) && ((bus < pciNumBuses) || inProbe) && pciBusInfo[bus] &&
+ pciBusInfo[bus]->funcs->pciReadLong) {
+ CARD32 rv = (*pciBusInfo[bus]->funcs->pciReadLong)(tag, offset);
+
+ PCITRACE(1, ("pciReadLong: tag=0x%x [b=%d,d=%d,f=%d] returns 0x%08x\n",
+ tag, bus, PCI_DEV_FROM_TAG(tag), PCI_FUNC_FROM_TAG(tag), rv));
+ return(rv);
+ }
+
+ return(PCI_NOT_FOUND);
+}
+
+CARD16
+pciReadWord(PCITAG tag, int offset)
+{
+ CARD32 tmp;
+ int shift = (offset & 3) * 8;
+ int aligned_offset = offset & ~3;
+ int bus = PCI_BUS_FROM_TAG(tag);
+
+ if (shift != 0 && shift != 16)
+ FatalError("pciReadWord: Alignment error: Cannot read 16 bits "
+ "at offset %d\n", offset);
+
+ pciInit();
+
+ if ((bus >= 0) && ((bus < pciNumBuses) || inProbe) && pciBusInfo[bus] &&
+ pciBusInfo[bus]->funcs->pciReadWord) {
+ CARD32 rv = (*pciBusInfo[bus]->funcs->pciReadWord)(tag, offset);
+
+ return(rv);
+ } else {
+ tmp = pciReadLong(tag, aligned_offset);
+
+ return((CARD16)((tmp >> shift) & 0xffff));
+ }
+}
+
+CARD8
+pciReadByte(PCITAG tag, int offset)
+{
+ CARD32 tmp;
+ int shift = (offset & 3) * 8;
+ int aligned_offset = offset & ~3;
+ int bus = PCI_BUS_FROM_TAG(tag);
+
+ pciInit();
+
+ if ((bus >= 0) && ((bus < pciNumBuses) || inProbe) && pciBusInfo[bus] &&
+ pciBusInfo[bus]->funcs->pciReadByte) {
+ CARD8 rv = (*pciBusInfo[bus]->funcs->pciReadByte)(tag, offset);
+
+ return(rv);
+ } else {
+ tmp = pciReadLong(tag, aligned_offset);
+
+ return((CARD8)((tmp >> shift) & 0xff));
+ }
+}
+
+void
+pciWriteLong(PCITAG tag, int offset, CARD32 val)
+{
+ int bus = PCI_BUS_FROM_TAG(tag);
+
+ pciInit();
+
+ if ((bus >= 0) && (bus < pciNumBuses) && pciBusInfo[bus] &&
+ pciBusInfo[bus]->funcs->pciWriteLong)
+ (*pciBusInfo[bus]->funcs->pciWriteLong)(tag, offset, val);
+}
+
+void
+pciWriteWord(PCITAG tag, int offset, CARD16 val)
+{
+ CARD32 tmp;
+ int aligned_offset = offset & ~3;
+ int shift = (offset & 3) * 8;
+ int bus = PCI_BUS_FROM_TAG(tag);
+
+ if (shift != 0 && shift != 16)
+ FatalError("pciWriteWord: Alignment Error: Cannot read 16 bits "
+ "from offset %d\n", offset);
+
+ pciInit();
+
+ if ((bus >= 0) && (bus < pciNumBuses) && pciBusInfo[bus] &&
+ pciBusInfo[bus]->funcs->pciWriteWord) {
+ (*pciBusInfo[bus]->funcs->pciWriteWord)(tag, offset, val);
+ } else {
+ tmp = pciReadLong(tag, aligned_offset);
+
+ tmp &= ~(0xffffL << shift);
+ tmp |= (((CARD32)val) << shift);
+
+ pciWriteLong(tag, aligned_offset, tmp);
+ }
+}
+
+void
+pciWriteByte(PCITAG tag, int offset, CARD8 val)
+{
+ CARD32 tmp;
+ int aligned_offset = offset & ~3;
+ int shift = (offset & 3) *8 ;
+ int bus = PCI_BUS_FROM_TAG(tag);
+
+ pciInit();
+
+ if ((bus >= 0) && (bus < pciNumBuses) && pciBusInfo[bus] &&
+ pciBusInfo[bus]->funcs->pciWriteByte) {
+ (*pciBusInfo[bus]->funcs->pciWriteByte)(tag, offset, val);
+ } else {
+
+ tmp = pciReadLong(tag, aligned_offset);
+
+ tmp &= ~(0xffL << shift);
+ tmp |= (((CARD32)val) << shift);
+
+ pciWriteLong(tag, aligned_offset, tmp);
+ }
+}
+
+void
+pciSetBitsLong(PCITAG tag, int offset, CARD32 mask, CARD32 val)
+{
+ int bus = PCI_BUS_FROM_TAG(tag);
+
+#ifdef DEBUGPCI
+ ErrorF("pciReadLong(0x%lx, %d)\n", tag, offset);
+#endif
+ pciInit();
+
+ if ((bus >= 0) && (bus < pciNumBuses) && pciBusInfo[bus] &&
+ pciBusInfo[bus]->funcs->pciSetBitsLong) {
+ (*pciBusInfo[bus]->funcs->pciSetBitsLong)(tag, offset, mask, val);
+ }
+}
+
+void
+pciSetBitsByte(PCITAG tag, int offset, CARD8 mask, CARD8 val)
+{
+ CARD32 tmp_mask, tmp_val;
+ int aligned_offset = offset & ~3;
+ int shift = (offset & 3) *8 ;
+
+ tmp_mask = mask << shift;
+ tmp_val = val << shift;
+ pciSetBitsLong(tag, aligned_offset, tmp_mask, tmp_val);
+}
+
+ADDRESS
+pciBusAddrToHostAddr(PCITAG tag, PciAddrType type, ADDRESS addr)
+{
+ int bus = PCI_BUS_FROM_TAG(tag);
+
+ pciInit();
+
+ if ((bus >= 0) && (bus < pciNumBuses) && pciBusInfo[bus] &&
+ pciBusInfo[bus]->funcs->pciAddrBusToHost)
+ return (*pciBusInfo[bus]->funcs->pciAddrBusToHost)(tag, type, addr);
+ else
+ return(addr);
+}
+
+ADDRESS
+pciHostAddrToBusAddr(PCITAG tag, PciAddrType type, ADDRESS addr)
+{
+ int bus = PCI_BUS_FROM_TAG(tag);
+
+ pciInit();
+
+ if ((bus >= 0) && (bus < pciNumBuses) && pciBusInfo[bus] &&
+ pciBusInfo[bus]->funcs->pciAddrHostToBus)
+ return (*pciBusInfo[bus]->funcs->pciAddrHostToBus)(tag, type, addr);
+ else
+ return(addr);
+}
+
+/*
+ * pciGetBaseSize() returns the size of a PCI base address mapping in bits.
+ * The index identifies the base register: 0-5 are the six standard registers,
+ * and 6 is the ROM base register. If destructive is TRUE, it will write
+ * to the base address register to get an accurate result. Otherwise it
+ * makes a conservative guess based on the alignment of the already allocated
+ * address. If the result is accurate (ie, not an over-estimate), this is
+ * indicated by setting *min to TRUE (when min is non-NULL). This happens
+ * when either the destructive flag is set, the information is supplied by
+ * the OS if the OS supports this.
+ */
+
+int
+pciGetBaseSize(PCITAG tag, int index, Bool destructive, Bool *min)
+{
+ int offset;
+ CARD32 addr1;
+ CARD32 addr2;
+ CARD32 mask1;
+ CARD32 mask2;
+ int bits = 0;
+
+ /*
+ * Eventually a function for this should be added to pciBusFuncs_t, but for
+ * now we'll just use a simple method based on the alignment of the already
+ * allocated address.
+ */
+
+ /*
+ * silently ignore bogus index values. Valid values are 0-6. 0-5 are
+ * the 6 base address registers, and 6 is the ROM base address register.
+ */
+ if (index < 0 || index > 6)
+ return 0;
+
+ pciInit();
+
+ if (xf86GetPciSizeFromOS(tag, index, &bits)) {
+ if (min)
+ *min = TRUE;
+ return bits;
+ }
+
+ if (min)
+ *min = destructive;
+
+ /* Get the PCI offset */
+ if (index == 6)
+ offset = PCI_MAP_ROM_REG;
+ else
+ offset = PCI_MAP_REG_START + (index << 2);
+
+ addr1 = pciReadLong(tag, offset);
+ /*
+ * Check if this is the second part of a 64 bit address.
+ * XXX need to check how endianness affects 64 bit addresses.
+ */
+ if (index > 0 && index < 6) {
+ addr2 = pciReadLong(tag, offset - 4);
+ if (PCI_MAP_IS_MEM(addr2) && PCI_MAP_IS64BITMEM(addr2))
+ return 0;
+ }
+
+ if (destructive) {
+ pciWriteLong(tag, offset, 0xffffffff);
+ mask1 = pciReadLong(tag, offset);
+ pciWriteLong(tag, offset, addr1);
+ } else {
+ mask1 = addr1;
+ }
+
+ /* Check if this is the first part of a 64 bit address. */
+ if (index < 5 && PCI_MAP_IS_MEM(mask1) && PCI_MAP_IS64BITMEM(mask1)) {
+ if (PCIGETMEMORY(mask1) == 0) {
+ addr2 = pciReadLong(tag, offset + 4);
+ if (destructive) {
+ pciWriteLong(tag, offset + 4, 0xffffffff);
+ mask2 = pciReadLong(tag, offset + 4);
+ pciWriteLong(tag, offset + 4, addr2);
+ } else {
+ mask2 = addr2;
+ }
+ if (mask2 == 0)
+ return 0;
+ bits = 32;
+ while ((mask2 & 1) == 0) {
+ bits++;
+ mask2 >>= 1;
+ }
+ if (bits > 32)
+ return bits;
+ }
+ }
+ if (index < 6)
+ if (PCI_MAP_IS_MEM(mask1))
+ mask1 = PCIGETMEMORY(mask1);
+ else
+ mask1 = PCIGETIO(mask1);
+ else
+ mask1 = PCIGETROM(mask1);
+ if (mask1 == 0)
+ return 0;
+ bits = 0;
+ while ((mask1 & 1) == 0) {
+ bits++;
+ mask1 >>= 1;
+ }
+ /* I/O maps can be no larger than 8 bits */
+
+ if ((index < 6) && PCI_MAP_IS_IO(addr1) && bits > 8)
+ bits = 8;
+ /* ROM maps can be no larger than 24 bits */
+ if (index == 6 && bits > 24)
+ bits = 24;
+ return bits;
+}
+
+PCITAG
+pciTag(int busnum, int devnum, int funcnum)
+{
+ return(PCI_MAKE_TAG(busnum,devnum,funcnum));
+}
+
+#if defined(PCI_MFDEV_SUPPORT) || defined(PowerMAX_OS)
+
+Bool
+pciMfDev(int busnum, int devnum)
+{
+ PCITAG tag0, tag1;
+ CARD32 id0, id1, val;
+
+ /* Detect a multi-function device that complies to the PCI 2.0 spec */
+
+ tag0 = PCI_MAKE_TAG(busnum, devnum, 0);
+ id0 = pciReadLong(tag0, PCI_ID_REG);
+ if ((CARD16)(id0 + 1) <= (CARD16)1UL)
+ return FALSE;
+
+ val = pciReadLong(tag0, PCI_HEADER_MISC) & 0x00ff0000;
+ if ((val != 0x00ff0000) && (val & PCI_HEADER_MULTIFUNCTION))
+ return TRUE;
+
+ /*
+ * Now, to find non-compliant devices...
+ * If there is a valid ID for function 1 and the ID for func 0 and 1
+ * are different, or the base0 values of func 0 and 1 are differend,
+ * then assume there is a multi-function device.
+ */
+ tag1 = PCI_MAKE_TAG(busnum, devnum, 1);
+ id1 = pciReadLong(tag1, PCI_ID_REG);
+ if ((CARD16)(id1 + 1) <= (CARD16)1UL)
+ return FALSE;
+
+ /* Vendor IDs should match */
+ if ((id0 ^ id1) & 0x0000ffff)
+ return FALSE;
+
+ if ((id0 != id1) ||
+ /* Note the following test is valid for header types 0, 1 and 2 */
+ (pciReadLong(tag0, PCI_MAP_REG_START) !=
+ pciReadLong(tag1, PCI_MAP_REG_START)))
+ return TRUE;
+
+ return FALSE;
+}
+
+#endif
+
+/*
+ * Generic find/read/write functions
+ */
+PCITAG
+pciGenFindNext(void)
+{
+ CARD32 devid, tmp;
+ int sec_bus, pri_bus;
+ static int previousBus = 0;
+ Bool speculativeProbe = FALSE;
+ unsigned char base_class, sub_class;
+
+#ifdef DEBUGPCI
+ ErrorF("pciGenFindNext\n");
+#endif
+
+ for (;;) {
+
+#ifdef DEBUGPCI
+ ErrorF("pciGenFindNext: pciBusNum %d\n", pciBusNum);
+#endif
+ if (pciBusNum == -1) {
+ /*
+ * Start at top of the order
+ */
+ if (pciNumBuses <= 0)
+ return(PCI_NOT_FOUND);
+
+ /* Skip ahead to the first bus defined by pciInit() */
+ for (pciBusNum = 0; !pciBusInfo[pciBusNum]; ++pciBusNum);
+ pciFuncNum = 0;
+ pciDevNum = 0;
+ previousBus = pciBusNum; /* make sure previousBus exists */
+ } else {
+#ifdef PCI_MFDEV_SUPPORT
+#ifdef DEBUGPCI
+ ErrorF("pciGenFindNext: pciFuncNum %d\n", pciFuncNum);
+#endif
+ /*
+ * Somewhere in middle of order. Determine who's
+ * next up
+ */
+ if (pciFuncNum == 0) {
+ /*
+ * Is current dev a multifunction device?
+ */
+ if (!speculativeProbe && pciMfDev(pciBusNum, pciDevNum))
+ /* Probe for other functions */
+ pciFuncNum = 1;
+ else
+ /*
+ * No more functions this device. Next
+ * device please
+ */
+ pciDevNum ++;
+ } else if (++pciFuncNum >= 8) {
+ /* No more functions for this device. Next device please */
+ pciFuncNum = 0;
+ pciDevNum ++;
+ }
+#else
+ pciDevNum ++;
+#endif
+ if (pciDevNum >= 32 ||
+ !pciBusInfo[pciBusNum] ||
+ pciDevNum >= pciBusInfo[pciBusNum]->numDevices) {
+#ifdef DEBUGPCI
+ ErrorF("pciGenFindNext: next bus\n");
+#endif
+ /*
+ * No more devices for this bus. Next bus please
+ */
+ if (speculativeProbe) {
+ NextSpeculativeBus:
+ xfree(pciBusInfo[pciBusNum]);
+ pciBusInfo[pciBusNum] = NULL;
+ speculativeProbe = FALSE;
+ }
+
+ if (++pciBusNum >= pciMaxBusNum) {
+#ifdef DEBUGPCI
+ ErrorF("pciGenFindNext: out of buses\n");
+#endif
+ /* No more buses. All done for now */
+ return(PCI_NOT_FOUND);
+ }
+
+ pciDevNum = 0;
+ }
+ }
+
+#ifdef DEBUGPCI
+ ErrorF("pciGenFindNext: pciBusInfo[%d] = 0x%lx\n", pciBusNum, pciBusInfo[pciBusNum]);
+#endif
+ if (!pciBusInfo[pciBusNum]) {
+ pciBusInfo[pciBusNum] = xnfalloc(sizeof(pciBusInfo_t));
+ *pciBusInfo[pciBusNum] = *pciBusInfo[previousBus];
+
+ speculativeProbe = TRUE;
+ }
+
+ /*
+ * At this point, pciBusNum, pciDevNum, and pciFuncNum have been
+ * advanced to the next device. Compute the tag, and read the
+ * device/vendor ID field.
+ */
+#ifdef DEBUGPCI
+ ErrorF("pciGenFindNext: [%d, %d, %d]\n", pciBusNum, pciDevNum, pciFuncNum);
+#endif
+ pciDeviceTag = PCI_MAKE_TAG(pciBusNum, pciDevNum, pciFuncNum);
+ inProbe = TRUE;
+ devid = pciReadLong(pciDeviceTag, PCI_ID_REG);
+ inProbe = FALSE;
+#ifdef DEBUGPCI
+ ErrorF("pciGenFindNext: pciDeviceTag = 0x%lx, devid = 0x%lx\n", pciDeviceTag, devid);
+#endif
+ if ((CARD16)(devid + 1U) <= (CARD16)1UL)
+ continue; /* Nobody home. Next device please */
+
+ /*
+ * Some devices mis-decode configuration cycles in such a way as to
+ * create phantom buses.
+ */
+ if (speculativeProbe && (pciDevNum == 0) && (pciFuncNum == 0) &&
+ (PCI_BUS_NO_DOMAIN(pciBusNum) > 0)) {
+ for (;;) {
+ if (++pciDevNum >= pciBusInfo[pciBusNum]->numDevices)
+ goto NextSpeculativeBus;
+ if (devid !=
+ pciReadLong(PCI_MAKE_TAG(pciBusNum, pciDevNum, 0),
+ PCI_ID_REG))
+ break;
+ }
+
+ pciDevNum = 0;
+ }
+
+ if (pciNumBuses <= pciBusNum)
+ pciNumBuses = pciBusNum + 1;
+
+ speculativeProbe = FALSE;
+ previousBus = pciBusNum;
+
+#ifdef PCI_BRIDGE_SUPPORT
+ /*
+ * Before checking for a specific devid, look for enabled
+ * PCI to PCI bridge devices. If one is found, create and
+ * initialize a bus info record (if one does not already exist).
+ */
+ tmp = pciReadLong(pciDeviceTag, PCI_CLASS_REG);
+ base_class = PCI_CLASS_EXTRACT(tmp);
+ sub_class = PCI_SUBCLASS_EXTRACT(tmp);
+ if ((base_class == PCI_CLASS_BRIDGE) &&
+ ((sub_class == PCI_SUBCLASS_BRIDGE_PCI) ||
+ (sub_class == PCI_SUBCLASS_BRIDGE_CARDBUS))) {
+ tmp = pciReadLong(pciDeviceTag, PCI_PCI_BRIDGE_BUS_REG);
+ sec_bus = PCI_SECONDARY_BUS_EXTRACT(tmp, pciDeviceTag);
+ pri_bus = PCI_PRIMARY_BUS_EXTRACT(tmp, pciDeviceTag);
+#ifdef DEBUGPCI
+ ErrorF("pciGenFindNext: pri_bus %d sec_bus %d\n",
+ pri_bus, sec_bus);
+#endif
+ if (pciBusNum != pri_bus) {
+ /* Some bridges do not implement the primary bus register */
+ if ((PCI_BUS_NO_DOMAIN(pri_bus) != 0) ||
+ (sub_class != PCI_SUBCLASS_BRIDGE_CARDBUS))
+ xf86Msg(X_WARNING,
+ "pciGenFindNext: primary bus mismatch on PCI"
+ " bridge 0x%08lx (0x%02x, 0x%02x)\n",
+ pciDeviceTag, pciBusNum, pri_bus);
+ pri_bus = pciBusNum;
+ }
+ if ((pri_bus < sec_bus) && (sec_bus < pciMaxBusNum) &&
+ pciBusInfo[pri_bus]) {
+ /*
+ * Found a secondary PCI bus
+ */
+ if (!pciBusInfo[sec_bus]) {
+ pciBusInfo[sec_bus] = xnfalloc(sizeof(pciBusInfo_t));
+
+ /* Copy parents settings... */
+ *pciBusInfo[sec_bus] = *pciBusInfo[pri_bus];
+ }
+
+ /* ...but not everything same as parent */
+ pciBusInfo[sec_bus]->primary_bus = pri_bus;
+ pciBusInfo[sec_bus]->secondary = TRUE;
+ pciBusInfo[sec_bus]->numDevices = 32;
+
+ if (pciNumBuses <= sec_bus)
+ pciNumBuses = sec_bus + 1;
+ }
+ }
+#endif
+
+ /*
+ * Does this device match the requested devid after
+ * applying mask?
+ */
+#ifdef DEBUGPCI
+ ErrorF("pciGenFindNext: pciDevidMask = 0x%lx, pciDevid = 0x%lx\n", pciDevidMask, pciDevid);
+#endif
+ if ((devid & pciDevidMask) == pciDevid)
+ /* Yes - Return it. Otherwise, next device */
+ return(pciDeviceTag); /* got a match */
+
+ } /* for */
+ /*NOTREACHED*/
+}
+
+PCITAG
+pciGenFindFirst(void)
+{
+ /* Reset PCI bus number to start from top */
+ pciBusNum = -1;
+
+ return pciGenFindNext();
+}
+
+CARD32
+pciByteSwap(CARD32 u)
+{
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+# if defined(__powerpc__) && defined(PowerMAX_OS)
+ CARD32 tmp;
+
+ __inst_stwbrx(u, &tmp, 0);
+
+ return(tmp);
+
+# else /* !PowerMAX_OS */
+
+ return lswapl(u);
+
+# endif /* !PowerMAX_OS */
+
+#else /* !BIG_ENDIAN */
+
+ return(u);
+
+#endif
+}
+
+ADDRESS
+pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS addr)
+{
+ return(addr);
+}
+
+pciConfigPtr *
+xf86scanpci(int flags)
+{
+ pciConfigPtr devp;
+ pciBusInfo_t *busp;
+ int idx = 0, i;
+ PCITAG tag;
+ static Bool done = FALSE;
+
+ /*
+ * if we haven't found PCI devices checking for pci_devp may
+ * result in an endless recursion if platform/OS specific PCI
+ * bus probing code calls this function from with in it.
+ */
+ if (done || pci_devp[0])
+ return pci_devp;
+
+ done = TRUE;
+
+ pciInit();
+
+#ifdef XF86SCANPCI_WRAPPER
+ XF86SCANPCI_WRAPPER(SCANPCI_INIT);
+#endif
+
+ tag = pciFindFirst(0,0); /* 0 mask means match any valid device */
+ /* Check if no devices, return now */
+ if (tag == PCI_NOT_FOUND) {
+#ifdef XF86SCANPCI_WRAPPER
+ XF86SCANPCI_WRAPPER(SCANPCI_TERM);
+#endif
+ return NULL;
+ }
+
+#ifdef DEBUGPCI
+ ErrorF("xf86scanpci: tag = 0x%lx\n", tag);
+#endif
+#ifndef OLD_FORMAT
+ xf86MsgVerb(X_INFO, 2, "PCI: PCI scan (all values are in hex)\n");
+#endif
+
+ while (idx < MAX_PCI_DEVICES && tag != PCI_NOT_FOUND) {
+ devp = xcalloc(1, sizeof(pciDevice));
+ if (!devp) {
+ xf86Msg(X_ERROR,
+ "xf86scanpci: Out of memory after %d devices!!\n", idx);
+ return (pciConfigPtr *)NULL;
+ }
+
+ /* Identify pci device by bus, dev, func, and tag */
+ devp->tag = tag;
+ devp->busnum = PCI_BUS_FROM_TAG(tag);
+ devp->devnum = PCI_DEV_FROM_TAG(tag);
+ devp->funcnum = PCI_FUNC_FROM_TAG(tag);
+
+ /* Read config space for this device */
+ for (i = 0; i < 17; i++) /* PCI hdr plus 1st dev spec dword */
+ devp->cfgspc.dwords[i] = pciReadLong(tag, i * sizeof(CARD32));
+
+ /* Some broken devices don't implement this field... */
+ if (devp->pci_header_type == 0xff)
+ devp->pci_header_type = 0;
+
+ switch (devp->pci_header_type & 0x7f) {
+ case 0:
+ /* Get base address sizes for type 0 headers */
+ for (i = 0; i < 7; i++)
+ devp->basesize[i] =
+ pciGetBaseSize(tag, i, FALSE, &devp->minBasesize);
+ break;
+
+ case 1:
+ case 2:
+ /* Allow master aborts to complete normally on secondary buses */
+ if (!(devp->pci_bridge_control & PCI_PCI_BRIDGE_MASTER_ABORT_EN))
+ break;
+ pciWriteByte(tag, PCI_PCI_BRIDGE_CONTROL_REG,
+ devp->pci_bridge_control &
+ ~(PCI_PCI_BRIDGE_MASTER_ABORT_EN |
+ PCI_PCI_BRIDGE_SECONDARY_RESET));
+ break;
+
+ default:
+ break;
+ }
+
+#ifdef OLD_FORMAT
+ xf86MsgVerb(X_INFO, 2, "PCI: BusID 0x%.2x,0x%02x,0x%1x "
+ "ID 0x%04x,0x%04x Rev 0x%02x Class 0x%02x,0x%02x\n",
+ devp->busnum, devp->devnum, devp->funcnum,
+ devp->pci_vendor, devp->pci_device, devp->pci_rev_id,
+ devp->pci_base_class, devp->pci_sub_class);
+#else
+ xf86MsgVerb(X_INFO, 2, "PCI: %.2x:%02x:%1x: chip %04x,%04x"
+ " card %04x,%04x rev %02x class %02x,%02x,%02x hdr %02x\n",
+ devp->busnum, devp->devnum, devp->funcnum,
+ devp->pci_vendor, devp->pci_device,
+ devp->pci_subsys_vendor, devp->pci_subsys_card,
+ devp->pci_rev_id, devp->pci_base_class,
+ devp->pci_sub_class, devp->pci_prog_if,
+ devp->pci_header_type);
+#endif
+
+ pci_devp[idx++] = devp;
+ tag = pciFindNext();
+
+#ifdef DEBUGPCI
+ ErrorF("xf86scanpci: tag = pciFindNext = 0x%lx\n", tag);
+#endif
+ }
+
+ /* Restore modified data (in reverse order), and link buses */
+ while (--idx >= 0) {
+ devp = pci_devp[idx];
+ switch (devp->pci_header_type & 0x7f) {
+ case 0:
+ if ((devp->pci_base_class != PCI_CLASS_BRIDGE) ||
+ (devp->pci_sub_class != PCI_SUBCLASS_BRIDGE_HOST))
+ break;
+ pciBusInfo[devp->busnum]->bridge = devp;
+ pciBusInfo[devp->busnum]->primary_bus = devp->busnum;
+ break;
+
+ case 1:
+ case 2:
+ i = PCI_SECONDARY_BUS_EXTRACT(devp->pci_pp_bus_register, devp->tag);
+ if (i > devp->busnum) {
+ if (pciBusInfo[i]) {
+ pciBusInfo[i]->bridge = devp;
+ /*
+ * The back link needs to be set here, and is unlikely to
+ * change.
+ */
+ devp->businfo = pciBusInfo[i];
+ }
+#ifdef ARCH_PCI_PCI_BRIDGE
+ ARCH_PCI_PCI_BRIDGE(devp);
+#endif
+ }
+ if (!(devp->pci_bridge_control & PCI_PCI_BRIDGE_MASTER_ABORT_EN))
+ break;
+ pciWriteByte(devp->tag, PCI_PCI_BRIDGE_CONTROL_REG,
+ devp->pci_bridge_control & ~PCI_PCI_BRIDGE_SECONDARY_RESET);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+#ifdef XF86SCANPCI_WRAPPER
+ XF86SCANPCI_WRAPPER(SCANPCI_TERM);
+#endif
+
+ /*
+ * Lastly, link bridges to their secondary bus, after the architecture has
+ * had a chance to modify these assignments.
+ */
+ for (idx = 0; idx < pciNumBuses; idx++) {
+ if (!(busp = pciBusInfo[idx]) || !(devp = busp->bridge))
+ continue;
+ devp->businfo = busp;
+ }
+
+#ifndef OLD_FORMAT
+ xf86MsgVerb(X_INFO, 2, "PCI: End of PCI scan\n");
+#endif
+
+ return pci_devp;
+}
+
+CARD32
+pciCheckForBrokenBase(PCITAG Tag,int basereg)
+{
+ pciWriteLong(Tag, PCI_MAP_REG_START + (basereg << 2), 0xffffffff);
+ return pciReadLong(Tag, PCI_MAP_REG_START + (basereg << 2));
+}
+
+#if defined(INCLUDE_XF86_MAP_PCI_MEM)
+
+pointer
+xf86MapPciMem(int ScreenNum, int Flags, PCITAG Tag, ADDRESS Base,
+ unsigned long Size)
+{
+ ADDRESS hostbase = pciBusAddrToHostAddr(Tag, PCI_MEM,Base);
+ pointer base;
+ CARD32 save = 0;
+
+ /*
+ * If there are possible read side-effects, disable memory while
+ * doing the mapping.
+ */
+ if (Flags & VIDMEM_READSIDEEFFECT) {
+ save = pciReadLong(Tag, PCI_CMD_STAT_REG);
+ pciWriteLong(Tag, PCI_CMD_STAT_REG,
+ save & ~PCI_CMD_MEM_ENABLE);
+ }
+ base = xf86MapDomainMemory(ScreenNum, Flags, Tag, hostbase, Size);
+ if (!base) {
+ FatalError("xf86MapPciMem: Could not mmap PCI memory "
+ "[base=0x%lx,hostbase=0x%lx,size=%lx] (%s)\n",
+ Base, hostbase, Size, strerror(errno));
+ }
+ /*
+ * If read side-effects, do whatever might be needed to prevent
+ * unintended reads, then restore PCI_CMD_STAT_REG.
+ */
+ if (Flags & VIDMEM_READSIDEEFFECT) {
+ xf86MapReadSideEffects(ScreenNum, Flags, base, Size);
+ pciWriteLong(Tag, PCI_CMD_STAT_REG, save);
+ }
+ return((pointer)base);
+}
+
+static int
+handlePciBIOS(PCITAG Tag, int basereg,
+ int (*func)(PCITAG, CARD8*, ADDRESS, pointer),
+ pointer args)
+{
+ CARD32 romsave = 0;
+ int i;
+ romBaseSource b_reg;
+ ADDRESS hostbase;
+ CARD8 tmp[64];
+ int ret = 0;
+
+ romsave = pciReadLong(Tag, PCI_MAP_ROM_REG);
+
+ for (i = ROM_BASE_PRESET; i <= ROM_BASE_FIND; i++) {
+ memType savebase = 0, newbase, romaddr;
+
+ switch (i) {
+ case ROM_BASE_PRESET:
+ /* Does the driver have a preference? */
+ if (basereg > ROM_BASE_PRESET && basereg <= ROM_BASE_FIND)
+ b_reg = basereg;
+ else
+ b_reg = ++i;
+ break;
+ case ROM_BASE_FIND:
+ /*
+ * If we have something that looks like a valid address
+ * in romsave, it's probably not going to help to try
+ * to guess a new address and reprogram it.
+ */
+ if (PCIGETROM(romsave)) {
+ pciWriteLong(Tag, PCI_MAP_ROM_REG, PCI_MAP_ROM_ADDRESS_MASK);
+ if (romsave != pciReadLong(Tag, PCI_MAP_ROM_REG)) {
+ pciWriteLong(Tag, PCI_MAP_ROM_REG, romsave);
+ continue;
+ }
+ }
+ default:
+ b_reg = i;
+ }
+
+ if (!(newbase = getValidBIOSBase(Tag, b_reg)))
+ continue; /* no valid address found */
+
+ romaddr = PCIGETROM(newbase);
+
+ /* if we use a mem base save it and move it out of the way */
+ if (b_reg >= 0 && b_reg <= 5) {
+ savebase = pciReadLong(Tag, PCI_MAP_REG_START+(b_reg<<2));
+ xf86MsgVerb(X_INFO,5,"xf86ReadPciBios: modifying membase[%i]"
+ " for device %i:%i:%i\n", basereg,
+ (int)PCI_BUS_FROM_TAG(Tag), (int)PCI_DEV_FROM_TAG(Tag),
+ (int)PCI_FUNC_FROM_TAG(Tag));
+ pciWriteLong(Tag, PCI_MAP_REG_START + (b_reg << 2),
+ (CARD32)~0);
+ }
+ /* Set ROM base address and enable ROM address decoding */
+ pciWriteLong(Tag, PCI_MAP_ROM_REG, romaddr
+ | PCI_MAP_ROM_DECODE_ENABLE);
+
+ hostbase = pciBusAddrToHostAddr(Tag, PCI_MEM, PCIGETROM(romaddr));
+
+ if ((xf86ReadDomainMemory(Tag, hostbase, sizeof(tmp), tmp) !=
+ sizeof(tmp)) ||
+ (tmp[0] != 0x55) || (tmp[1] != 0xaa) || !tmp[2] ) {
+ /* Restore the base registers if they were changed. */
+ pciWriteLong(Tag, PCI_MAP_ROM_REG, romsave);
+ if (savebase) pciWriteLong(Tag, PCI_MAP_REG_START + (b_reg << 2),
+ (CARD32) savebase);
+
+ /* No BIOS found: try another address */
+ continue;
+ }
+
+ ret = (*func)(Tag, tmp, hostbase, args);
+
+ /* Restore the base register if it was changed. */
+ if (savebase) pciWriteLong(Tag, PCI_MAP_REG_START + (b_reg << 2),
+ (CARD32) savebase);
+ /* Restore ROM address decoding */
+ pciWriteLong(Tag, PCI_MAP_ROM_REG, romsave);
+
+ return ret;
+ }
+ /* Restore ROM address decoding */
+ pciWriteLong(Tag, PCI_MAP_ROM_REG, romsave);
+ return 0;
+}
+
+typedef struct {
+ unsigned long Offset;
+ int Len;
+ unsigned char *Buf;
+ PciBiosType BiosType;
+} readBios, *readBiosPtr;
+
+static int
+readPciBios(PCITAG Tag, CARD8* tmp, ADDRESS hostbase, pointer args)
+{
+ unsigned int image_length = 0;
+ readBiosPtr rd = args;
+ int ret;
+
+ /* We found a PCI BIOS Image. Now we look for the correct type */
+ while ((tmp[0] == 0x55) && (tmp[1] == 0xAA)) {
+ unsigned short data_off = tmp[0x18] | (tmp[0x19] << 8);
+ unsigned char data[0x18];
+ unsigned char type;
+
+ if ((xf86ReadDomainMemory(Tag, hostbase + data_off, sizeof(data), data)
+ != sizeof(data)) ||
+ (data[0] != 'P') ||
+ (data[1] != 'C') ||
+ (data[2] != 'I') ||
+ (data[3] != 'R'))
+ break;
+ type = data[0x14];
+#ifdef PRINT_PCI
+ ErrorF("data segment in BIOS: 0x%x, type: 0x%x\n", data_off, type);
+#endif
+ if (type != rd->BiosType) { /* not correct image: find next one */
+ unsigned char indicator = data[0x15];
+ unsigned int i_length;
+ if (indicator & 0x80) /* last image */
+ break;
+ i_length = (data[0x10] | (data[0x11] << 8)) << 9;
+#ifdef PRINT_PCI
+ ErrorF("data image length: 0x%x, ind: 0x%x\n",
+ image_length, indicator);
+#endif
+ hostbase += i_length;
+ if (xf86ReadDomainMemory(Tag, hostbase, sizeof(tmp), tmp)
+ != sizeof(tmp))
+ break;
+ continue;
+ }
+ /* OK, we have a PCI BIOS Image of the correct type */
+
+ if (rd->BiosType == PCI_BIOS_PC)
+ image_length = tmp[2] << 9;
+ else
+ image_length = (data[0x10] | (data[0x11] << 8)) << 9;
+#ifdef PRINT_PCI
+ ErrorF("BIOS length: 0x%x\n", image_length);
+#endif
+ break;
+ }
+
+ ret = 0;
+ if (image_length) {
+
+ /*
+ * if no length is given return the full lenght,
+ * Offset 0. Beware: Area pointed to by Buf must
+ * be large enough!
+ */
+ if (rd->Len == 0) {
+ rd->Len = image_length;
+ rd->Offset = 0;
+ }
+ if ((rd->Offset) > (image_length)) {
+ xf86Msg(X_WARNING,"xf86ReadPciBios: requesting data past "
+ "end of BIOS %li > %i\n",(rd->Offset) , (image_length));
+ } else {
+ if ((rd->Offset + rd->Len) > (image_length)) {
+ rd->Len = (image_length) - rd->Offset;
+ xf86MsgVerb(X_INFO,3,"Truncating PCI BIOS Length to %i\n",rd->Len);
+ }
+ }
+
+ /* Read BIOS */
+ ret = xf86ReadDomainMemory(Tag, hostbase + rd->Offset, rd->Len, rd->Buf);
+ }
+
+ return ret;
+}
+
+static int
+getPciBIOSTypes(PCITAG Tag, CARD8* tmp, ADDRESS hostbase, pointer arg)
+{
+ int n = 0;
+ PciBiosType *Buf = arg;
+
+ /* We found a PCI BIOS Image. Now we collect the types type */
+ do {
+ unsigned short data_off = tmp[0x18] | (tmp[0x19] << 8);
+ unsigned char data[0x16];
+ unsigned int i_length;
+
+ if ((xf86ReadDomainMemory(Tag, hostbase + data_off, sizeof(data), data)
+ != sizeof(data)) ||
+ (data[0] != 'P') ||
+ (data[1] != 'C') ||
+ (data[2] != 'I') ||
+ (data[3] != 'R'))
+ break;
+
+ if (data[0x14] >= PCI_BIOS_OTHER)
+ *Buf++ = PCI_BIOS_OTHER;
+ else
+ *Buf++ = data[0x14];
+
+ n++;
+ if (data[0x15] & 0x80) /* last image */
+ break;
+#ifdef PRINT_PCI
+ ErrorF("data segment in BIOS: 0x%x, type: 0x%x\n", data_off, type);
+#endif
+ i_length = (data[0x10] | (data[0x11] << 8)) << 9;
+#ifdef PRINT_PCI
+ ErrorF("data image length: 0x%x, ind: 0x%x\n",
+ image_length, indicator);
+#endif
+ hostbase += i_length;
+ if (xf86ReadDomainMemory(Tag, hostbase, sizeof(tmp), tmp)
+ != sizeof(tmp))
+ break;
+ continue;
+ } while ((tmp[0] == 0x55) && (tmp[1] == 0xAA));
+ return n;
+}
+
+typedef CARD32 (*ReadProcPtr)(PCITAG, int);
+typedef void (*WriteProcPtr)(PCITAG, int, CARD32);
+
+static int
+HandlePciBios(PCITAG Tag, int basereg,
+ int (*func)(PCITAG, CARD8*, ADDRESS, pointer),
+ pointer ptr)
+{
+ int n, num;
+ CARD32 Acc1, Acc2;
+ PCITAG *pTag;
+ int i;
+
+ n = handlePciBIOS(Tag,basereg,func,ptr);
+ if (n)
+ return n;
+
+ num = pciTestMultiDeviceCard(PCI_BUS_FROM_TAG(Tag),
+ PCI_DEV_FROM_TAG(Tag),
+ PCI_FUNC_FROM_TAG(Tag),&pTag);
+
+ if (!num) return 0;
+
+#define PCI_ENA (PCI_CMD_MEM_ENABLE | PCI_CMD_IO_ENABLE)
+ Acc1 = pciReadLong(Tag, PCI_CMD_STAT_REG);
+ pciWriteLong(Tag, PCI_CMD_STAT_REG, (Acc1 & ~PCI_ENA));
+
+ for (i = 0; i < num; i++) {
+ Acc2 = pciReadLong(pTag[i], PCI_CMD_STAT_REG);
+ pciWriteLong(pTag[i], PCI_CMD_STAT_REG, (Acc2 | PCI_ENA));
+
+ n = handlePciBIOS(pTag[i],0,func,ptr);
+
+ pciWriteLong(pTag[i], PCI_CMD_STAT_REG, Acc2);
+ if (n)
+ break;
+ }
+ pciWriteLong(Tag, PCI_CMD_STAT_REG, Acc1);
+ return n;
+}
+
+int
+xf86ReadPciBIOS(unsigned long Offset, PCITAG Tag, int basereg,
+ unsigned char *Buf, int Len)
+{
+ return xf86ReadPciBIOSByType(Offset, Tag, basereg, Buf, Len, PCI_BIOS_PC);
+}
+
+int
+xf86ReadPciBIOSByType(unsigned long Offset, PCITAG Tag, int basereg,
+ unsigned char *Buf, int Len, PciBiosType Type)
+{
+
+ readBios rb;
+ rb.Offset = Offset;
+ rb.Len = Len;
+ rb.Buf = Buf;
+ rb.BiosType = Type;
+
+ return HandlePciBios(Tag, basereg, readPciBios, &rb);
+}
+
+int
+xf86GetAvailablePciBIOSTypes(PCITAG Tag, int basereg, PciBiosType *Buf)
+{
+ return HandlePciBios(Tag, basereg, getPciBIOSTypes, (pointer) Buf);
+}
+
+#endif /* INCLUDE_XF86_MAP_PCI_MEM */
+
+#ifdef INCLUDE_XF86_NO_DOMAIN
+
+int
+xf86GetPciDomain(PCITAG Tag)
+{
+ return 0;
+}
+
+pointer
+xf86MapDomainMemory(int ScreenNum, int Flags, PCITAG Tag,
+ ADDRESS Base, unsigned long Size)
+{
+ return xf86MapVidMem(ScreenNum, Flags, Base, Size);
+}
+
+IOADDRESS
+xf86MapDomainIO(int ScreenNum, int Flags, PCITAG Tag,
+ IOADDRESS Base, unsigned long Size)
+{
+ return Base;
+}
+
+int
+xf86ReadDomainMemory(PCITAG Tag, ADDRESS Base, int Len, unsigned char *Buf)
+{
+ int ret, length, rlength;
+
+ /* Read in 64kB chunks */
+ ret = 0;
+ while ((length = Len) > 0) {
+ if (length > 0x010000) length = 0x010000;
+ rlength = xf86ReadBIOS(Base, 0, Buf, length);
+ if (rlength < 0) {
+ ret = rlength;
+ break;
+ }
+ ret += rlength;
+ if (rlength < length) break;
+ Base += rlength;
+ Buf += rlength;
+ Len -= rlength;
+ }
+
+ return ret;
+}
+
+#endif /* INCLUDE_XF86_NO_DOMAIN */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Pci.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Pci.h
new file mode 100644
index 000000000..70293d3f4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Pci.h
@@ -0,0 +1,449 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h,v 1.45 2004/02/02 03:55:31 dawes Exp $ */
+/*
+ * Copyright 1998 by Concurrent Computer Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Concurrent Computer
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Concurrent Computer Corporation makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Copyright 1998 by Metro Link Incorporated
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * This file is derived in part from the original xf86_PCI.h that included
+ * following copyright message:
+ *
+ * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the above listed copyright holder(s)
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. The above listed
+ * copyright holder(s) make(s) no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*
+ * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/*
+ * This file has the private Pci definitions. The public ones are imported
+ * from xf86Pci.h. Drivers should not use this file.
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _PCI_H
+#define _PCI_H 1
+
+#include <X11/Xarch.h>
+#include <X11/Xfuncproto.h>
+#include "xf86Pci.h"
+#include "xf86PciInfo.h"
+
+/*
+ * Global Definitions
+ */
+#define MAX_PCI_DEVICES 128 /* Max number of devices accomodated */
+ /* by xf86scanpci */
+#if defined(sun) && defined(SVR4) && defined(sparc)
+# define MAX_PCI_BUSES 4096 /* Max number of PCI buses */
+#elif defined(__alpha__) && defined (linux)
+# define MAX_PCI_DOMAINS 512
+# define PCI_DOM_MASK 0x01fful
+# define MAX_PCI_BUSES (MAX_PCI_DOMAINS*256) /* 256 per domain */
+#else
+# define MAX_PCI_BUSES 256 /* Max number of PCI buses */
+#endif
+
+#define DEVID(vendor, device) \
+ ((CARD32)((PCI_##device << 16) | PCI_##vendor))
+
+#ifndef PCI_DOM_MASK
+# define PCI_DOM_MASK 0x0ffu
+#endif
+#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu)
+
+/*
+ * "b" contains an optional domain number.
+ */
+#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \
+ (((d) & 0x00001fu) << 11) | \
+ (((f) & 0x000007u) << 8))
+
+#define PCI_MAKE_BUS(d,b) ((((d) & (PCI_DOM_MASK)) << 8) | ((b) & 0xffu))
+
+#define PCI_DOM_FROM_TAG(tag) (((tag) >> 24) & (PCI_DOM_MASK))
+#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK))
+#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11)
+#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8)
+
+#define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00u) >> 8)
+#define PCI_BDEV_FROM_TAG(tag) ((tag) & 0x00fff800u)
+
+#define PCI_DOM_FROM_BUS(bus) (((bus) >> 8) & (PCI_DOM_MASK))
+#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
+#define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u)
+
+/*
+ * Macros for bus numbers found in P2P headers.
+ */
+#define PCI_PRIMARY_BUS_EXTRACT(x, tag) \
+ ((((x) & PCI_PRIMARY_BUS_MASK ) >> 0) | (PCI_DOM_FROM_TAG(tag) << 8))
+#define PCI_SECONDARY_BUS_EXTRACT(x, tag) \
+ ((((x) & PCI_SECONDARY_BUS_MASK ) >> 8) | (PCI_DOM_FROM_TAG(tag) << 8))
+#define PCI_SUBORDINATE_BUS_EXTRACT(x, tag) \
+ ((((x) & PCI_SUBORDINATE_BUS_MASK) >> 16) | (PCI_DOM_FROM_TAG(tag) << 8))
+
+#define PCI_PRIMARY_BUS_INSERT(x, y) \
+ (((x) & ~PCI_PRIMARY_BUS_MASK ) | (((y) & 0xffu) << 0))
+#define PCI_SECONDARY_BUS_INSERT(x, y) \
+ (((x) & ~PCI_SECONDARY_BUS_MASK ) | (((y) & 0xffu) << 8))
+#define PCI_SUBORDINATE_BUS_INSERT(x, y) \
+ (((x) & ~PCI_SUBORDINATE_BUS_MASK) | (((y) & 0xffu) << 16))
+
+/* Ditto for CardBus bridges */
+#define PCI_CB_PRIMARY_BUS_EXTRACT(x, tag) \
+ PCI_PRIMARY_BUS_EXTRACT(x, tag)
+#define PCI_CB_CARDBUS_BUS_EXTRACT(x, tag) \
+ PCI_SECONDARY_BUS_EXTRACT(x, tag)
+#define PCI_CB_SUBORDINATE_BUS_EXTRACT(x, tag) \
+ PCI_SUBORDINATE_BUS_EXTRACT(x, tag)
+
+#define PCI_CB_PRIMARY_BUS_INSERT(x, tag) \
+ PCI_PRIMARY_BUS_INSERT(x, tag)
+#define PCI_CB_CARDBUS_BUS_INSERT(x, tag) \
+ PCI_SECONDARY_BUS_INSERT(x, tag)
+#define PCI_CB_SUBORDINATE_BUS_INSERT(x, tag) \
+ PCI_SUBORDINATE_BUS_INSERT(x, tag)
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+#define PCI_CPU(val) (((val >> 24) & 0x000000ff) | \
+ ((val >> 8) & 0x0000ff00) | \
+ ((val << 8) & 0x00ff0000) | \
+ ((val << 24) & 0xff000000))
+#define PCI_CPU16(val) (((val >> 8) & 0x000000ff) | \
+ ((val << 8) & 0x0000ff00))
+#else
+#define PCI_CPU(val) (val)
+#define PCI_CPU16(val) (val)
+#endif
+
+/*
+ * Debug Macros/Definitions
+ */
+/* #define DEBUGPCI 2 */ /* Disable/enable trace in PCI code */
+
+#if defined(DEBUGPCI)
+
+# define PCITRACE(lvl,printfargs) \
+ if (lvl > xf86Verbose) { \
+ ErrorF printfargs; \
+ }
+
+#else /* !defined(DEBUGPCI) */
+
+# define PCITRACE(lvl,printfargs)
+
+#endif /* !defined(DEBUGPCI) */
+
+/*
+ * PCI Config mechanism definitions
+ */
+#define PCI_EN 0x80000000
+
+#define PCI_CFGMECH1_ADDRESS_REG 0xCF8
+#define PCI_CFGMECH1_DATA_REG 0xCFC
+
+#define PCI_CFGMECH1_MAXDEV 32
+
+/*
+ * Select architecture specific PCI init function
+ */
+#if defined(__alpha__)
+# if defined(linux)
+# define ARCH_PCI_INIT axpPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# elif defined(__FreeBSD__) || defined(__OpenBSD__)
+# define ARCH_PCI_INIT freebsdPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# elif defined(__NetBSD__)
+# define ARCH_PCI_INIT netbsdPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# endif
+#elif defined(__arm__)
+# if defined(linux)
+# define ARCH_PCI_INIT linuxPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# endif
+#elif defined(__hppa__)
+# if defined(linux)
+# define ARCH_PCI_INIT linuxPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# endif
+#elif defined(__ia64__)
+# if defined(linux)
+# define ARCH_PCI_INIT linuxPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# elif defined(FreeBSD)
+# define ARCH_PCI_INIT freebsdPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# endif
+# define XF86SCANPCI_WRAPPER ia64ScanPCIWrapper
+#elif defined(__i386__) || defined(i386)
+# define ARCH_PCI_INIT ix86PciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# if defined(linux)
+# define ARCH_PCI_OS_INIT linuxPciInit
+# endif
+#elif defined(__mc68000__)
+# if defined(linux)
+# define ARCH_PCI_INIT linuxPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# endif
+#elif defined(__mips__)
+# if defined(linux)
+# define ARCH_PCI_INIT linuxPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# endif
+#elif defined(__powerpc__) || defined(__powerpc64__)
+# if defined(linux)
+# define ARCH_PCI_INIT linuxPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN /* Needs kernel work to remove */
+# elif defined(__FreeBSD__) || defined(__OpenBSD__)
+# define ARCH_PCI_INIT freebsdPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# elif defined(__NetBSD__)
+# define ARCH_PCI_INIT netbsdPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# elif defined(PowerMAX_OS) /* This port is broken */
+# define ARCH_PCI_INIT ppcPciInit
+# else
+# define ARCH_PCI_INIT ppcPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# endif
+#elif defined(__s390__)
+# if defined(linux)
+# define ARCH_PCI_INIT linuxPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# endif
+#elif defined(__sh__)
+# if defined(linux)
+# define ARCH_PCI_INIT linuxPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# endif
+#elif defined(__sparc__) || defined(sparc)
+# if defined(linux)
+# define ARCH_PCI_INIT linuxPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# elif defined(sun)
+# define ARCH_PCI_INIT sparcPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# elif (defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc64__)
+# define ARCH_PCI_INIT freebsdPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# endif
+# if !defined(__FreeBSD__)
+# define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge
+# endif
+#elif defined(__amd64__) || defined(__amd64)
+# if defined(__FreeBSD__)
+# define ARCH_PCI_INIT freebsdPciInit
+# else
+# define ARCH_PCI_INIT ix86PciInit
+# endif
+# define INCLUDE_XF86_MAP_PCI_MEM
+# define INCLUDE_XF86_NO_DOMAIN
+# if defined(linux)
+# define ARCH_PCI_OS_INIT linuxPciInit
+# endif
+#endif
+
+#ifndef ARCH_PCI_INIT
+#error No PCI support available for this architecture/OS combination
+#endif
+
+extern void ARCH_PCI_INIT(void);
+#if defined(ARCH_PCI_OS_INIT)
+extern void ARCH_PCI_OS_INIT(void);
+#endif
+
+#if defined(ARCH_PCI_PCI_BRIDGE)
+extern void ARCH_PCI_PCI_BRIDGE(pciConfigPtr pPCI);
+#endif
+
+#if defined(XF86SCANPCI_WRAPPER)
+typedef enum {
+ SCANPCI_INIT,
+ SCANPCI_TERM
+} scanpciWrapperOpt;
+extern void XF86SCANPCI_WRAPPER(scanpciWrapperOpt flags);
+#endif
+
+/*
+ * Table of functions used to access a specific PCI bus domain
+ * (e.g. a primary PCI bus and all of its secondaries)
+ */
+typedef struct pci_bus_funcs {
+ CARD32 (*pciReadLong)(PCITAG, int);
+ void (*pciWriteLong)(PCITAG, int, CARD32);
+ void (*pciSetBitsLong)(PCITAG, int, CARD32, CARD32);
+ ADDRESS (*pciAddrHostToBus)(PCITAG, PciAddrType, ADDRESS);
+ ADDRESS (*pciAddrBusToHost)(PCITAG, PciAddrType, ADDRESS);
+ /*
+ * The next three are optional. If NULL, the corresponding function is
+ * to be performed generically.
+ */
+ CARD16 (*pciControlBridge)(int, CARD16, CARD16);
+ void (*pciGetBridgeBuses)(int, int *, int *, int *);
+ /* Use pointer's to avoid #include recursion */
+ void (*pciGetBridgeResources)(int, pointer *, pointer *, pointer *);
+
+ /* These are optional and will be implemented using read long
+ * if not present. */
+ CARD8 (*pciReadByte)(PCITAG, int);
+ void (*pciWriteByte)(PCITAG, int, CARD8);
+ CARD16 (*pciReadWord)(PCITAG, int);
+ void (*pciWriteWord)(PCITAG, int, CARD16);
+
+} pciBusFuncs_t, *pciBusFuncs_p;
+
+/*
+ * pciBusInfo_t - One structure per defined PCI bus
+ */
+typedef struct pci_bus_info {
+ unsigned char configMech; /* PCI config type to use */
+ unsigned char numDevices; /* Range of valid devnums */
+ unsigned char secondary; /* Boolean: bus is a secondary */
+ int primary_bus; /* Parent bus */
+#ifdef PowerMAX_OS
+ unsigned long ppc_io_base; /* PowerPC I/O spc membase */
+ unsigned long ppc_io_size; /* PowerPC I/O spc size */
+#endif
+ pciBusFuncs_p funcs; /* PCI access functions */
+ void *pciBusPriv; /* Implementation private data */
+ pciConfigPtr bridge; /* bridge that opens this bus */
+} pciBusInfo_t;
+
+#define HOST_NO_BUS ((pciBusInfo_t *)(-1))
+
+/* configMech values */
+#define PCI_CFG_MECH_UNKNOWN 0 /* Not yet known */
+#define PCI_CFG_MECH_1 1 /* Most machines */
+#define PCI_CFG_MECH_2 2 /* Older PC's */
+#define PCI_CFG_MECH_OTHER 3 /* Something else */
+
+/* Generic PCI service functions and helpers */
+PCITAG pciGenFindFirst(void);
+PCITAG pciGenFindNext(void);
+CARD32 pciCfgMech1Read(PCITAG tag, int offset);
+void pciCfgMech1Write(PCITAG tag, int offset, CARD32 val);
+void pciCfgMech1SetBits(PCITAG tag, int offset, CARD32 mask,
+ CARD32 val);
+CARD32 pciByteSwap(CARD32);
+Bool pciMfDev(int, int);
+ADDRESS pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS);
+
+extern PCITAG (*pciFindFirstFP)(void);
+extern PCITAG (*pciFindNextFP)(void);
+
+extern CARD32 pciDevid;
+extern CARD32 pciDevidMask;
+
+extern int pciMaxBusNum;
+
+extern int pciBusNum;
+extern int pciDevNum;
+extern int pciFuncNum;
+extern PCITAG pciDeviceTag;
+
+extern pciBusInfo_t *pciBusInfo[];
+
+#endif /* _PCI_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Sbus.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Sbus.c
new file mode 100644
index 000000000..168bc669e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Sbus.c
@@ -0,0 +1,637 @@
+/*
+ * SBUS and OpenPROM access functions.
+ *
+ * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Sbus.c,v 1.2tsi Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#ifdef sun
+#include <sys/utsname.h>
+#endif
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include "xf86sbusBus.h"
+#include "xf86Sbus.h"
+
+int promRootNode;
+
+static int promFd = -1;
+static int promCurrentNode;
+static int promOpenCount = 0;
+static int promP1275 = -1;
+#define MAX_PROP 128
+#define MAX_VAL (4096-128-4)
+static struct openpromio *promOpio;
+
+sbusDevicePtr *xf86SbusInfo = NULL;
+
+struct sbus_devtable sbusDeviceTable[] = {
+ { SBUS_DEVICE_BW2, FBTYPE_SUN2BW, "bwtwo", "Sun Monochrome (bwtwo)" },
+ { SBUS_DEVICE_CG2, FBTYPE_SUN2COLOR, "cgtwo", "Sun Color2 (cgtwo)" },
+ { SBUS_DEVICE_CG3, FBTYPE_SUN3COLOR, "cgthree", "Sun Color3 (cgthree)" },
+ { SBUS_DEVICE_CG4, FBTYPE_SUN4COLOR, "cgfour", "Sun Color4 (cgfour)" },
+ { SBUS_DEVICE_CG6, FBTYPE_SUNFAST_COLOR, "cgsix", "Sun GX" },
+ { SBUS_DEVICE_CG8, FBTYPE_MEMCOLOR, "cgeight", "Sun CG8/RasterOps" },
+ { SBUS_DEVICE_CG12, FBTYPE_SUNGP3, "cgtwelve", "Sun GS (cgtwelve)" },
+ { SBUS_DEVICE_CG14, FBTYPE_MDICOLOR, "cgfourteen", "Sun SX" },
+ { SBUS_DEVICE_GT, FBTYPE_SUNGT, "gt", "Sun Graphics Tower" },
+ { SBUS_DEVICE_MGX, -1, "mgx", "Quantum 3D MGXplus" },
+ { SBUS_DEVICE_LEO, FBTYPE_SUNLEO, "leo", "Sun ZX or Turbo ZX" },
+ { SBUS_DEVICE_TCX, FBTYPE_TCXCOLOR, "tcx", "Sun TCX" },
+ { SBUS_DEVICE_FFB, FBTYPE_CREATOR, "ffb", "Sun FFB" },
+ { SBUS_DEVICE_FFB, FBTYPE_CREATOR, "afb", "Sun Elite3D" },
+ { 0, 0, NULL }
+};
+
+int
+promGetSibling(int node)
+{
+ promOpio->oprom_size = sizeof(int);
+
+ if (node == -1) return 0;
+ *(int *)promOpio->oprom_array = node;
+ if (ioctl(promFd, OPROMNEXT, promOpio) < 0)
+ return 0;
+ promCurrentNode = *(int *)promOpio->oprom_array;
+ return *(int *)promOpio->oprom_array;
+}
+
+int
+promGetChild(int node)
+{
+ promOpio->oprom_size = sizeof(int);
+
+ if (!node || node == -1) return 0;
+ *(int *)promOpio->oprom_array = node;
+ if (ioctl(promFd, OPROMCHILD, promOpio) < 0)
+ return 0;
+ promCurrentNode = *(int *)promOpio->oprom_array;
+ return *(int *)promOpio->oprom_array;
+}
+
+char *
+promGetProperty(const char *prop, int *lenp)
+{
+ promOpio->oprom_size = MAX_VAL;
+
+ strcpy(promOpio->oprom_array, prop);
+ if (ioctl(promFd, OPROMGETPROP, promOpio) < 0)
+ return 0;
+ if (lenp) *lenp = promOpio->oprom_size;
+ return promOpio->oprom_array;
+}
+
+int
+promGetBool(const char *prop)
+{
+ promOpio->oprom_size = 0;
+
+ *(int *)promOpio->oprom_array = 0;
+ for (;;) {
+ promOpio->oprom_size = MAX_PROP;
+ if (ioctl(promFd, OPROMNXTPROP, promOpio) < 0)
+ return 0;
+ if (!promOpio->oprom_size)
+ return 0;
+ if (!strcmp(promOpio->oprom_array, prop))
+ return 1;
+ }
+}
+
+#define PROM_NODE_SIBLING 0x01
+#define PROM_NODE_PREF 0x02
+#define PROM_NODE_SBUS 0x04
+#define PROM_NODE_EBUS 0x08
+#define PROM_NODE_PCI 0x10
+
+static int
+promSetNode(sbusPromNodePtr pnode)
+{
+ int node;
+
+ if (!pnode->node || pnode->node == -1)
+ return -1;
+ if (pnode->cookie[0] & PROM_NODE_SIBLING)
+ node = promGetSibling(pnode->cookie[1]);
+ else
+ node = promGetChild(pnode->cookie[1]);
+ if (pnode->node != node)
+ return -1;
+ return 0;
+}
+
+static void
+promIsP1275(void)
+{
+#ifdef linux
+ FILE *f;
+ char buffer[1024];
+
+ if (promP1275 != -1)
+ return;
+ promP1275 = 0;
+ f = fopen("/proc/cpuinfo","r");
+ if (!f) return;
+ while (fgets(buffer, 1024, f) != NULL)
+ if (!strncmp (buffer, "type", 4) && strstr (buffer, "sun4u")) {
+ promP1275 = 1;
+ break;
+ }
+ fclose(f);
+#elif defined(sun)
+ struct utsname buffer;
+
+ if ((uname(&buffer) >= 0) && !strcmp(buffer.machine, "sun4u"))
+ promP1275 = TRUE;
+ else
+ promP1275 = FALSE;
+#elif defined(__FreeBSD__)
+ promP1275 = TRUE;
+#else
+#error Missing promIsP1275() function for this OS
+#endif
+}
+
+void
+sparcPromClose(void)
+{
+ if (promOpenCount > 1) {
+ promOpenCount--;
+ return;
+ }
+ if (promFd != -1) {
+ close(promFd);
+ promFd = -1;
+ }
+ if (promOpio) {
+ xfree(promOpio);
+ promOpio = NULL;
+ }
+ promOpenCount = 0;
+}
+
+int
+sparcPromInit(void)
+{
+ if (promOpenCount) {
+ promOpenCount++;
+ return 0;
+ }
+ promFd = open("/dev/openprom", O_RDONLY, 0);
+ if (promFd == -1)
+ return -1;
+ promOpio = (struct openpromio *)xalloc(4096);
+ if (!promOpio) {
+ sparcPromClose();
+ return -1;
+ }
+ promRootNode = promGetSibling(0);
+ if (!promRootNode) {
+ sparcPromClose();
+ return -1;
+ }
+ promIsP1275();
+ promOpenCount++;
+
+ return 0;
+}
+
+char *
+sparcPromGetProperty(sbusPromNodePtr pnode, const char *prop, int *lenp)
+{
+ if (promSetNode(pnode))
+ return NULL;
+ return promGetProperty(prop, lenp);
+}
+
+int
+sparcPromGetBool(sbusPromNodePtr pnode, const char *prop)
+{
+ if (promSetNode(pnode))
+ return 0;
+ return promGetBool(prop);
+}
+
+static void
+promWalkAssignNodes(int node, int oldnode, int flags, sbusDevicePtr *devicePtrs)
+{
+ int nextnode;
+ int len, sbus = flags & PROM_NODE_SBUS;
+ char *prop;
+ int devId, i, j;
+ sbusPromNode pNode, pNode2;
+
+ prop = promGetProperty("device_type", &len);
+ if (prop && (len > 0)) do {
+ if (!strcmp(prop, "display")) {
+ prop = promGetProperty("name", &len);
+ if (!prop || len <= 0)
+ break;
+ while ((*prop >= 'A' && *prop <= 'Z') || *prop == ',')
+ prop++;
+ for (i = 0; sbusDeviceTable[i].devId; i++)
+ if (!strcmp(prop, sbusDeviceTable[i].promName))
+ break;
+ devId = sbusDeviceTable[i].devId;
+ if (!devId)
+ break;
+ if (!sbus) {
+ if (devId == SBUS_DEVICE_FFB) {
+ /*
+ * All /SUNW,ffb outside of SBUS tree come before all
+ * /SUNW,afb outside of SBUS tree in Linux.
+ */
+ if (!strcmp(prop, "afb"))
+ flags |= PROM_NODE_PREF;
+ } else if (devId != SBUS_DEVICE_CG14)
+ break;
+ }
+ for (i = 0; i < 32; i++) {
+ if (!devicePtrs[i] || devicePtrs[i]->devId != devId)
+ continue;
+ if (devicePtrs[i]->node.node) {
+ if ((devicePtrs[i]->node.cookie[0] & ~PROM_NODE_SIBLING) <=
+ (flags & ~PROM_NODE_SIBLING))
+ continue;
+ for (j = i + 1, pNode = devicePtrs[i]->node; j < 32; j++) {
+ if (!devicePtrs[j] || devicePtrs[j]->devId != devId)
+ continue;
+ pNode2 = devicePtrs[j]->node;
+ devicePtrs[j]->node = pNode;
+ pNode = pNode2;
+ }
+ }
+ devicePtrs[i]->node.node = node;
+ devicePtrs[i]->node.cookie[0] = flags;
+ devicePtrs[i]->node.cookie[1] = oldnode;
+ break;
+ }
+ break;
+ }
+ } while (0);
+
+ prop = promGetProperty("name", &len);
+ if (prop && len > 0) {
+ if (!strcmp(prop, "sbus") || !strcmp(prop, "sbi"))
+ sbus = PROM_NODE_SBUS;
+ }
+
+ nextnode = promGetChild(node);
+ if (nextnode)
+ promWalkAssignNodes(nextnode, node, sbus, devicePtrs);
+
+ nextnode = promGetSibling(node);
+ if (nextnode)
+ promWalkAssignNodes(nextnode, node, PROM_NODE_SIBLING | sbus, devicePtrs);
+}
+
+void
+sparcPromAssignNodes(void)
+{
+ sbusDevicePtr psdp, *psdpp;
+ int n, holes = 0, i, j;
+ FILE *f;
+ sbusDevicePtr devicePtrs[32];
+
+ (void)memset(devicePtrs, 0, sizeof(devicePtrs));
+ for (psdpp = xf86SbusInfo, n = 0; (psdp = *psdpp); psdpp++, n++) {
+ if (psdp->fbNum != n)
+ holes = 1;
+ devicePtrs[psdp->fbNum] = psdp;
+ }
+ if (holes && (f = fopen("/proc/fb", "r")) != NULL) {
+ /* We could not open one of fb devices, check /proc/fb to see what
+ * were the types of the cards missed. */
+ char buffer[64];
+ int fbNum, devId;
+ static struct {
+ int devId;
+ char *prefix;
+ } procFbPrefixes[] = {
+ { SBUS_DEVICE_BW2, "BWtwo" },
+ { SBUS_DEVICE_CG14, "CGfourteen" },
+ { SBUS_DEVICE_CG6, "CGsix" },
+ { SBUS_DEVICE_CG3, "CGthree" },
+ { SBUS_DEVICE_FFB, "Creator" },
+ { SBUS_DEVICE_FFB, "Elite 3D" },
+ { SBUS_DEVICE_LEO, "Leo" },
+ { SBUS_DEVICE_TCX, "TCX" },
+ { 0, NULL },
+ };
+
+ while (fscanf(f, "%d %63s\n", &fbNum, buffer) == 2) {
+ for (i = 0; procFbPrefixes[i].devId; i++)
+ if (! strncmp(procFbPrefixes[i].prefix, buffer,
+ strlen(procFbPrefixes[i].prefix)))
+ break;
+ devId = procFbPrefixes[i].devId;
+ if (! devId) continue;
+ if (devicePtrs[fbNum]) {
+ if (devicePtrs[fbNum]->devId != devId)
+ xf86ErrorF("Inconsistent /proc/fb with FBIOGATTR\n");
+ } else if (!devicePtrs[fbNum]) {
+ devicePtrs[fbNum] = psdp = xnfcalloc(sizeof (sbusDevice), 1);
+ psdp->devId = devId;
+ psdp->fbNum = fbNum;
+ psdp->fd = -2;
+ }
+ }
+ fclose(f);
+ }
+ promGetSibling(0);
+ promWalkAssignNodes(promRootNode, 0, PROM_NODE_PREF, devicePtrs);
+ for (i = 0, j = 0; i < 32; i++)
+ if (devicePtrs[i] && devicePtrs[i]->fbNum == -1)
+ j++;
+ xf86SbusInfo = xnfrealloc(xf86SbusInfo, sizeof(psdp) * (n + j + 1));
+ for (i = 0, psdpp = xf86SbusInfo; i < 32; i++)
+ if (devicePtrs[i]) {
+ if (devicePtrs[i]->fbNum == -1) {
+ memmove(psdpp + 1, psdpp, sizeof(psdpp) * (n + 1));
+ *psdpp = devicePtrs[i];
+ } else
+ n--;
+ }
+}
+
+static char *
+promGetReg(int type)
+{
+ char *prop;
+ int len;
+ static char regstr[40];
+
+ regstr[0] = 0;
+ prop = promGetProperty("reg", &len);
+ if (prop && len >= 4) {
+ unsigned int *reg = (unsigned int *)prop;
+ if (!promP1275 || (type == PROM_NODE_SBUS) || (type == PROM_NODE_EBUS))
+ sprintf (regstr, "@%x,%x", reg[0], reg[1]);
+ else if (type == PROM_NODE_PCI) {
+ if ((reg[0] >> 8) & 7)
+ sprintf (regstr, "@%x,%x", (reg[0] >> 11) & 0x1f, (reg[0] >> 8) & 7);
+ else
+ sprintf (regstr, "@%x", (reg[0] >> 11) & 0x1f);
+ } else if (len == 4)
+ sprintf (regstr, "@%x", reg[0]);
+ else {
+ unsigned int regs[2];
+
+ /* Things get more complicated on UPA. If upa-portid exists,
+ then address is @upa-portid,second-int-in-reg, otherwise
+ it is @first-int-in-reg/16,second-int-in-reg (well, probably
+ upa-portid always exists, but just to be safe). */
+ memcpy (regs, reg, sizeof(regs));
+ prop = promGetProperty("upa-portid", &len);
+ if (prop && len == 4) {
+ reg = (unsigned int *)prop;
+ sprintf (regstr, "@%x,%x", reg[0], regs[1]);
+ } else
+ sprintf (regstr, "@%x,%x", regs[0] >> 4, regs[1]);
+ }
+ }
+ return regstr;
+}
+
+static int
+promWalkNode2Pathname(char *path, int parent, int node, int searchNode, int type)
+{
+ int nextnode;
+ int len, ntype = type;
+ char *prop, *p;
+
+ prop = promGetProperty("name", &len);
+ *path = '/';
+ if (!prop || len <= 0)
+ return 0;
+ if ((!strcmp(prop, "sbus") || !strcmp(prop, "sbi")) && !type)
+ ntype = PROM_NODE_SBUS;
+ else if (!strcmp(prop, "ebus") && type == PROM_NODE_PCI)
+ ntype = PROM_NODE_EBUS;
+ else if (!strcmp(prop, "pci") && !type)
+ ntype = PROM_NODE_PCI;
+ strcpy (path + 1, prop);
+ p = promGetReg(type);
+ if (*p)
+ strcat (path, p);
+ if (node == searchNode)
+ return 1;
+ nextnode = promGetChild(node);
+ if (nextnode &&
+ promWalkNode2Pathname(strchr(path, 0), node, nextnode, searchNode, ntype))
+ return 1;
+ nextnode = promGetSibling(node);
+ if (nextnode &&
+ promWalkNode2Pathname(path, parent, nextnode, searchNode, type))
+ return 1;
+ return 0;
+}
+
+char *
+sparcPromNode2Pathname(sbusPromNodePtr pnode)
+{
+ char *ret;
+
+ if (!pnode->node) return NULL;
+ ret = xalloc(4096);
+ if (!ret) return NULL;
+ if (promWalkNode2Pathname(ret, promRootNode, promGetChild(promRootNode), pnode->node, 0))
+ return ret;
+ xfree(ret);
+ return NULL;
+}
+
+static int
+promWalkPathname2Node(char *name, char *regstr, int parent, int type)
+{
+ int len, node, ret;
+ char *prop, *p;
+
+ for (;;) {
+ prop = promGetProperty("name", &len);
+ if (!prop || len <= 0)
+ return 0;
+ if ((!strcmp(prop, "sbus") || !strcmp(prop, "sbi")) && !type)
+ type = PROM_NODE_SBUS;
+ else if (!strcmp(prop, "ebus") && type == PROM_NODE_PCI)
+ type = PROM_NODE_EBUS;
+ else if (!strcmp(prop, "pci") && !type)
+ type = PROM_NODE_PCI;
+ for (node = promGetChild(parent); node; node = promGetSibling(node)) {
+ prop = promGetProperty("name", &len);
+ if (!prop || len <= 0)
+ continue;
+ if (*name && strcmp(name, prop))
+ continue;
+ if (*regstr) {
+ p = promGetReg(type);
+ if (! *p || strcmp(p + 1, regstr))
+ continue;
+ }
+ break;
+ }
+ if (!node) {
+ for (node = promGetChild(parent); node; node = promGetSibling(node)) {
+ ret = promWalkPathname2Node(name, regstr, node, type);
+ if (ret) return ret;
+ }
+ return 0;
+ }
+ name = strchr(regstr, 0) + 1;
+ if (! *name)
+ return node;
+ p = strchr(name, '/');
+ if (p)
+ *p = 0;
+ else
+ p = strchr(name, 0);
+ regstr = strchr(name, '@');
+ if (regstr)
+ *regstr++ = 0;
+ else
+ regstr = p;
+ if (name == regstr)
+ return 0;
+ parent = node;
+ }
+}
+
+int
+sparcPromPathname2Node(const char *pathName)
+{
+ int i;
+ char *name, *regstr, *p;
+
+ i = strlen(pathName);
+ name = xalloc(i + 2);
+ if (! name) return 0;
+ strcpy (name, pathName);
+ name [i + 1] = 0;
+ if (name[0] != '/')
+ return 0;
+ p = strchr(name + 1, '/');
+ if (p)
+ *p = 0;
+ else
+ p = strchr(name, 0);
+ regstr = strchr(name, '@');
+ if (regstr)
+ *regstr++ = 0;
+ else
+ regstr = p;
+ if (name + 1 == regstr)
+ return 0;
+ promGetSibling(0);
+ i = promWalkPathname2Node(name + 1, regstr, promRootNode, 0);
+ xfree(name);
+ return i;
+}
+
+pointer
+xf86MapSbusMem(sbusDevicePtr psdp, unsigned long offset, unsigned long size)
+{
+ pointer ret;
+ unsigned long pagemask = xf86getpagesize() - 1;
+ unsigned long off = offset & ~pagemask;
+ unsigned long len = ((offset + size + pagemask) & ~pagemask) - off;
+
+ if (psdp->fd == -1) {
+ psdp->fd = open(psdp->device, O_RDWR);
+ if (psdp->fd == -1)
+ return NULL;
+ } else if (psdp->fd < 0)
+ return NULL;
+
+ ret = (pointer) mmap (NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE,
+ psdp->fd, off);
+ if (ret == (pointer) -1) {
+ ret = (pointer) mmap (NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED,
+ psdp->fd, off);
+ }
+ if (ret == (pointer) -1)
+ return NULL;
+
+ return (char *)ret + (offset - off);
+}
+
+void
+xf86UnmapSbusMem(sbusDevicePtr psdp, pointer addr, unsigned long size)
+{
+ unsigned long mask = xf86getpagesize() - 1;
+ unsigned long base = (unsigned long)addr & ~mask;
+ unsigned long len = (((unsigned long)addr + size + mask) & ~mask) - base;
+
+ munmap ((pointer)base, len);
+}
+
+/* Tell OS that we are driving the HW cursor ourselves. */
+void
+xf86SbusHideOsHwCursor(sbusDevicePtr psdp)
+{
+ struct fbcursor fbcursor;
+ unsigned char zeros[8];
+
+ memset(&fbcursor, 0, sizeof(fbcursor));
+ memset(&zeros, 0, sizeof(zeros));
+ fbcursor.cmap.count = 2;
+ fbcursor.cmap.red = zeros;
+ fbcursor.cmap.green = zeros;
+ fbcursor.cmap.blue = zeros;
+ fbcursor.image = (char *)zeros;
+ fbcursor.mask = (char *)zeros;
+ fbcursor.size.x = 32;
+ fbcursor.size.y = 1;
+ fbcursor.set = FB_CUR_SETALL;
+ ioctl(psdp->fd, FBIOSCURSOR, &fbcursor);
+}
+
+/* Set HW cursor colormap. */
+void
+xf86SbusSetOsHwCursorCmap(sbusDevicePtr psdp, int bg, int fg)
+{
+ struct fbcursor fbcursor;
+ unsigned char red[2], green[2], blue[2];
+
+ memset(&fbcursor, 0, sizeof(fbcursor));
+ red[0] = bg >> 16;
+ green[0] = bg >> 8;
+ blue[0] = bg;
+ red[1] = fg >> 16;
+ green[1] = fg >> 8;
+ blue[1] = fg;
+ fbcursor.cmap.count = 2;
+ fbcursor.cmap.red = red;
+ fbcursor.cmap.green = green;
+ fbcursor.cmap.blue = blue;
+ fbcursor.set = FB_CUR_SETCMAP;
+ ioctl(psdp->fd, FBIOSCURSOR, &fbcursor);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/altixPCI.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/altixPCI.c
new file mode 100644
index 000000000..010f6619a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/altixPCI.c
@@ -0,0 +1,120 @@
+/*
+ * This file contains the glue necessary for support of SGI's Altix chipset.
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include <unistd.h>
+#include "altixPCI.h"
+#include "xf86.h"
+#include "Pci.h"
+
+/*
+ * get_dev_on_bus - Return the first device we find on segnum, busnum
+ *
+ * Walk all the PCI devices and return the first one found on segnum, busnum.
+ * There may be a better way to do this in some xf86* function I don't know
+ * about.
+ */
+static pciDevice *get_dev_on_bus(unsigned int segnum, unsigned int busnum)
+{
+ pciDevice **pdev = xf86scanpci(0);
+ int i;
+
+ for (i = 0; pdev[i] != NULL; i++)
+ if (PCI_DOM_FROM_TAG(pdev[i]->tag) == segnum &&
+ pdev[i]->busnum == busnum)
+ return pdev[i];
+ /* Should never get here... */
+ ErrorF("No PCI device found on %04x:%02x??", segnum, busnum);
+ return NULL;
+}
+
+/*
+ * get_bridge_info - fill in the bridge info for bus_info based on pdev
+ *
+ * Find the parent bus for pdev if it exists, otherwise assume pdev *is*
+ * the parent bus. We need this on Altix because our bridges are transparent.
+ */
+static void get_bridge_info(pciBusInfo_t *bus_info, pciDevice *pdev)
+{
+ unsigned int parent_segnum, segnum = PCI_DOM_FROM_TAG(pdev->tag);
+ unsigned int parent_busnum, busnum = pdev->busnum;
+ char bridge_path[] = "/sys/class/pci_bus/0000:00/bridge";
+ char bridge_target[] = "../../../devices/pci0000:00";
+
+ /* Path to this device's bridge */
+ sprintf(bridge_path, "/sys/class/pci_bus/%04x:%02x/bridge", segnum,
+ busnum);
+
+ if (readlink(bridge_path, bridge_target, strlen(bridge_target)) < 0) {
+ perror("failed to dereference bridge link");
+ ErrorF("failed to dereference bridge link, aborting\n");
+ exit(-1);
+ }
+
+ sscanf(bridge_target, "../../../devices/pci%04x:%02x", &parent_segnum,
+ &parent_busnum);
+
+ /*
+ * If there's no bridge or the bridge points to the device, use
+ * pdev as the bridge
+ */
+ if (segnum == parent_segnum && busnum == parent_busnum) {
+ bus_info->bridge = pdev;
+ bus_info->secondary = FALSE;
+ bus_info->primary_bus = busnum;
+ } else {
+ bus_info->bridge = get_dev_on_bus(parent_segnum,
+ parent_busnum);
+ bus_info->secondary = TRUE;
+ bus_info->primary_bus = parent_busnum;
+ }
+ pdev->businfo = bus_info;
+ pdev->pci_base_class = PCI_CLASS_DISPLAY;
+ pdev->pci_sub_class = PCI_SUBCLASS_PREHISTORIC_VGA;
+}
+
+void xf86PreScanAltix(void)
+{
+ /* Nothing to see here... */
+}
+
+void xf86PostScanAltix(void)
+{
+ pciConfigPtr *pdev;
+ pciBusInfo_t *bus_info;
+ int prevBusNum, curBusNum, idx;
+
+ /*
+ * Altix PCI bridges are invisible to userspace, so we make each device
+ * look like it's its own bridge unless it actually has a parent (as in
+ * the case of PCI to PCI bridges).
+ */
+ bus_info = pciBusInfo[0];
+ pdev = xf86scanpci(0);
+ prevBusNum = curBusNum = pdev[0]->busnum;
+ bus_info = pciBusInfo[curBusNum];
+ bus_info->bridge = pdev[0];
+ bus_info->secondary = FALSE;
+ bus_info->primary_bus = curBusNum;
+
+ /* Walk all the PCI devices, assigning their bridge info */
+ for (idx = 0; pdev[idx] != NULL; idx++) {
+ if (pdev[idx]->busnum == prevBusNum)
+ continue; /* Already fixed up this bus */
+
+ curBusNum = pdev[idx]->busnum;
+ bus_info = pciBusInfo[curBusNum];
+
+ /*
+ * Fill in bus_info for pdev. The bridge field will either
+ * be pdev[idx] or a device on the parent bus.
+ */
+ get_bridge_info(bus_info, pdev[idx]);
+ prevBusNum = curBusNum;
+ }
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/altixPCI.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/altixPCI.h
new file mode 100644
index 000000000..2a738f362
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/altixPCI.h
@@ -0,0 +1,20 @@
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef PCI_ALTIX_H
+#define PCI_ALTIX_H 1
+
+#include <X11/Xdefs.h>
+#include <Pci.h>
+
+Bool xorgProbeAltix(scanpciWrapperOpt flags);
+void xf86PreScanAltix(void);
+void xf86PostScanAltix(void);
+
+/* Some defines for PCI */
+#define VENDOR_SGI 0x10A9
+#define CHIP_TIO_CA 0x1010
+#define CHIP_PIC_PCI 0x1011
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/axpPci.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/axpPci.c
new file mode 100644
index 000000000..08c7fbd39
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/axpPci.c
@@ -0,0 +1,478 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/axpPci.c,v 1.14 2002/12/11 02:44:28 dawes Exp $ */
+/*
+ * Copyright 1998 by Concurrent Computer Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Concurrent Computer
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Concurrent Computer Corporation makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Copyright 1998 by Metro Link Incorporated
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include "compiler.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "Pci.h"
+
+#include <asm/unistd.h>
+#include "../linux/lnx.h" /* for _iobase */
+
+/*
+ * Alpha/Linux platform specific PCI access functions
+ */
+static CARD32 axpPciCfgRead(PCITAG tag, int off);
+static void axpPciCfgWrite(PCITAG, int off, CARD32 val);
+static void axpPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits);
+
+static pciBusFuncs_t axpFuncs0 = {
+/* pciReadLong */ axpPciCfgRead,
+/* pciWriteLong */ axpPciCfgWrite,
+/* pciSetBitsLong */ axpPciCfgSetBits,
+/* pciAddrHostToBus */ pciAddrNOOP,
+/* pciAddrBusToHost */ pciAddrNOOP
+};
+
+typedef struct _axpDomainRec {
+ int domain, hose;
+ int root_bus;
+ unsigned long dense_io, sparse_io;
+ unsigned long dense_mem, sparse_mem;
+ IOADDRESS mapped_io;
+} axpDomainRec, *axpDomainPtr;
+
+#define MAX_DOMAINS (MAX_PCI_BUSES / 256)
+static axpDomainPtr xf86DomainInfo[MAX_DOMAINS] = { NULL, };
+static int pciNumDomains = 0;
+
+/*
+ * For debug, domain assignment can start downward from a fixed base
+ * (instead of up from 0) by defining FORCE_HIGH_DOMAINS. This allows
+ * debug of large domain numbers and sparse domain numbering on systems
+ * which don't have as many hoses.
+ */
+#if 0
+# define FORCE_HIGH_DOMAINS MAX_DOMAINS /* assign domains downward from here */
+#endif
+
+/*
+ * If FORCE_HIGH_DOMAINS is set, make sure it's not larger than the
+ * max domain
+ */
+#if defined(FORCE_HIGH_DOMAINS) && (FORCE_HIGH_DOMAINS > MAX_DOMAINS)
+# undef FORCE_HIGH_DOMAINS
+# define FORCE_HIGH_DOMAINS MAX_DOMAINS
+#endif
+
+static int
+axpSetupDomains(void)
+{
+ axpDomainRec axpDomain;
+ int numDomains = 0;
+ int hose;
+
+#ifndef INCLUDE_XF86_NO_DOMAIN
+
+#ifdef FORCE_HIGH_DOMAINS
+ xf86Msg(X_WARNING,
+ "DEBUG OPTION FORCE_HIGH_DOMAINS in use - DRI will *NOT* work\n");
+ numDomains = FORCE_HIGH_DOMAINS;
+#endif
+
+ /*
+ * Since each hose has a different address space, hoses are a perfect
+ * overlay for domains, so set up one domain for each hose present
+ * in the system. We have to loop through all possible hoses because
+ * some systems allow sparse I/O controllers.
+ */
+ for(hose = 0; hose < MAX_DOMAINS; hose++) {
+ axpDomain.root_bus = _iobase(IOBASE_ROOT_BUS, hose, -1, -1);
+ if (axpDomain.root_bus < 0) continue;
+
+ axpDomain.hose = hose;
+
+#ifndef FORCE_HIGH_DOMAINS
+
+ axpDomain.domain = axpDomain.hose = hose;
+ numDomains = axpDomain.domain + 1;
+
+#else /* FORCE_HIGH_DOMAINS */
+
+ axpDomain.domain = numDomains - hose - 1;
+
+ xf86Msg(X_WARNING,
+ "FORCE_HIGH_DOMAINS - assigned hose %d to domain %d\n",
+ axpDomain.hose, axpDomain.domain);
+
+#endif /* FORCE_HIGH_DOMAINS */
+
+ axpDomain.dense_io = _iobase(IOBASE_DENSE_IO, hose, -1, -1);
+ axpDomain.sparse_io = _iobase(IOBASE_SPARSE_IO, hose, -1, -1);
+ axpDomain.mapped_io = 0;
+ axpDomain.dense_mem = _iobase(IOBASE_DENSE_MEM, hose, -1, -1);
+ axpDomain.sparse_mem = _iobase(IOBASE_SPARSE_MEM, hose, -1, -1);
+
+ xf86DomainInfo[axpDomain.domain] = xnfalloc(sizeof(axpDomainRec));
+ *(xf86DomainInfo[axpDomain.domain]) = axpDomain;
+
+ /*
+ * For now, only allow a single domain (hose) on sparse i/o systems.
+ *
+ * Allowing multiple domains on sparse systems would require:
+ * 1) either
+ * a) revamping the sparse video mapping code to allow
+ * for multiple unrelated address regions
+ * -- OR --
+ * b) implementing sparse mapping directly in
+ * xf86MapDomainMemory
+ * 2) revaming read/write sparse routines to correctly handle
+ * the solution to 1)
+ * 3) implementing a sparse I/O system (mapping, inX/outX)
+ * independent of glibc, since the glibc version only
+ * supports hose 0
+ */
+ if (axpDomain.sparse_io) {
+ if (_iobase(IOBASE_ROOT_BUS, hose + 1, -1, -1) >= 0) {
+ /*
+ * It's a sparse i/o system with (at least) one more hose,
+ * show a message indicating that video is constrained to
+ * hose 0
+ */
+ xf86Msg(X_INFO,
+ "Sparse I/O system - constraining video to hose 0\n");
+ }
+ break;
+ }
+ }
+
+#else /* INCLUDE_XF86_NO_DOMAIN */
+
+ /*
+ * domain support is not included, so just set up a single domain (0)
+ * to represent the first hose so that axpPciInit will still have
+ * be able to set up the root bus
+ */
+ xf86DomainInfo[0] = xnfalloc(sizeof(axpDomainRec));
+ *(xf86DomainInfo[0]) = axpDomain;
+ numDomains = 1;
+
+#endif /* INCLUDE_XF86_NO_DOMAIN */
+
+ return numDomains;
+}
+
+void
+axpPciInit()
+{
+ axpDomainPtr pDomain;
+ int domain, bus;
+
+ pciNumDomains = axpSetupDomains();
+
+ for(domain = 0; domain < pciNumDomains; domain++) {
+ if (!(pDomain = xf86DomainInfo[domain])) continue;
+
+ /*
+ * Since any bridged buses will be behind a probed pci-pci bridge,
+ * only set up the root bus for each domain (hose) and the bridged
+ * buses will be set up as they are found.
+ */
+ bus = PCI_MAKE_BUS(domain, 0);
+ pciBusInfo[bus] = xnfalloc(sizeof(pciBusInfo_t));
+ (void)memset(pciBusInfo[bus], 0, sizeof(pciBusInfo_t));
+
+ pciBusInfo[bus]->configMech = PCI_CFG_MECH_OTHER;
+ pciBusInfo[bus]->numDevices = 32;
+ pciBusInfo[bus]->funcs = &axpFuncs0;
+ pciBusInfo[bus]->pciBusPriv = pDomain;
+
+ pciNumBuses = bus + 1;
+ }
+
+ pciFindFirstFP = pciGenFindFirst;
+ pciFindNextFP = pciGenFindNext;
+}
+
+/*
+ * Alpha/Linux PCI configuration space access routines
+ */
+static int
+axpPciBusFromTag(PCITAG tag)
+{
+ pciBusInfo_t *pBusInfo;
+ axpDomainPtr pDomain;
+ int bus, dfn;
+
+ bus = PCI_BUS_FROM_TAG(tag);
+ if ((bus >= pciNumBuses)
+ || !(pBusInfo = pciBusInfo[bus])
+ || !(pDomain = pBusInfo->pciBusPriv)
+ || (pDomain->domain != PCI_DOM_FROM_TAG(tag))) return -1;
+
+ bus = PCI_BUS_NO_DOMAIN(bus) + pDomain->root_bus;
+ dfn = PCI_DFN_FROM_TAG(tag);
+ if (_iobase(IOBASE_HOSE, -1, bus, dfn) != pDomain->hose) return -1;
+
+ return bus;
+}
+
+static CARD32
+axpPciCfgRead(PCITAG tag, int off)
+{
+ int bus, dfn;
+ CARD32 val = 0xffffffff;
+
+ if ((bus = axpPciBusFromTag(tag)) >= 0) {
+ dfn = PCI_DFN_FROM_TAG(tag);
+
+ syscall(__NR_pciconfig_read, bus, dfn, off, 4, &val);
+ }
+ return(val);
+}
+
+static void
+axpPciCfgWrite(PCITAG tag, int off, CARD32 val)
+{
+ int bus, dfn;
+
+ if ((bus = axpPciBusFromTag(tag)) >= 0) {
+ dfn = PCI_DFN_FROM_TAG(tag);
+ syscall(__NR_pciconfig_write, bus, dfn, off, 4, &val);
+ }
+}
+
+static void
+axpPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits)
+{
+ int bus, dfn;
+ CARD32 val = 0xffffffff;
+
+ if ((bus = axpPciBusFromTag(tag)) >= 0) {
+ dfn = PCI_DFN_FROM_TAG(tag);
+
+ syscall(__NR_pciconfig_read, bus, dfn, off, 4, &val);
+ val = (val & ~mask) | (bits & mask);
+ syscall(__NR_pciconfig_write, bus, dfn, off, 4, &val);
+ }
+}
+
+#ifndef INCLUDE_XF86_NO_DOMAIN
+
+/*
+ * Alpha/Linux addressing domain support
+ */
+
+int
+xf86GetPciDomain(PCITAG Tag)
+{
+ return PCI_DOM_FROM_TAG(Tag);
+}
+
+pointer
+xf86MapDomainMemory(int ScreenNum, int Flags, PCITAG Tag,
+ ADDRESS Base, unsigned long Size)
+{
+ axpDomainPtr pDomain;
+ int domain = PCI_DOM_FROM_TAG(Tag);
+
+ if ((domain < 0) || (domain >= pciNumDomains) ||
+ !(pDomain = xf86DomainInfo[domain]))
+ FatalError("%s called with invalid parameters\n", __FUNCTION__);
+
+ /*
+ * xf86MapVidMem already does what we need, but remember to subtract
+ * _bus_base() (the physical dense memory root of hose 0) since
+ * xf86MapVidMem is expecting an offset relative to _bus_base() rather
+ * than an actual physical address.
+ */
+ return xf86MapVidMem(ScreenNum, Flags,
+ pDomain->dense_mem + Base - _bus_base(), Size);
+}
+
+IOADDRESS
+xf86MapDomainIO(int ScreenNum, int Flags, PCITAG Tag,
+ IOADDRESS Base, unsigned long Size)
+{
+ axpDomainPtr pDomain;
+ int domain = PCI_DOM_FROM_TAG(Tag);
+
+ if ((domain < 0) || (domain >= pciNumDomains) ||
+ !(pDomain = xf86DomainInfo[domain]))
+ FatalError("%s called with invalid parameters\n", __FUNCTION__);
+
+ /*
+ * Use glibc inx/outx routines for sparse I/O, so just return the
+ * base [this is ok since we also constrain sparse I/O systems to
+ * a single domain in axpSetupDomains()]
+ */
+ if (pDomain->sparse_io) return Base;
+
+ /*
+ * I/O addresses on Alpha are really just different physical memory
+ * addresses that the system corelogic turns into I/O commands on the
+ * bus, so just use xf86MapVidMem to map I/O as well, but remember
+ * to subtract _bus_base() (the physical dense memory root of hose 0)
+ * since xf86MapVidMem is expecting an offset relative to _bus_base()
+ * rather than an actual physical address.
+ *
+ * Map the entire I/O space (64kB) at once and only once.
+ */
+ if (!pDomain->mapped_io)
+ pDomain->mapped_io = (IOADDRESS)xf86MapVidMem(ScreenNum, Flags,
+ pDomain->dense_io - _bus_base(),
+ 0x10000);
+
+ return pDomain->mapped_io + Base;
+}
+
+int
+xf86ReadDomainMemory(PCITAG Tag, ADDRESS Base, int Len, unsigned char *Buf)
+{
+ static unsigned long pagemask = 0;
+ unsigned char *MappedAddr;
+ unsigned long MapSize;
+ ADDRESS MapBase;
+ int i;
+
+ if (!pagemask) pagemask = xf86getpagesize() - 1;
+
+ /* Ensure page boundaries */
+ MapBase = Base & ~pagemask;
+ MapSize = ((Base + Len + pagemask) & ~pagemask) - MapBase;
+
+ /*
+ * VIDMEM_MMIO in order to get sparse mapping on sparse memory systems
+ * so we can use mmio functions to read (that way we can really get byte
+ * at a time reads on dense memory systems with byte/word instructions.
+ */
+ MappedAddr = xf86MapDomainMemory(-1, VIDMEM_READONLY | VIDMEM_MMIO,
+ Tag, MapBase, MapSize);
+
+ for (i = 0; i < Len; i++) {
+ *Buf++ = xf86ReadMmio8(MappedAddr, Base - MapBase + i);
+ }
+
+ xf86UnMapVidMem(-1, MappedAddr, MapSize);
+ return Len;
+}
+
+resPtr
+xf86PciBusAccWindowsFromOS(void)
+{
+ resPtr pRes = NULL;
+ resRange range;
+ int domain;
+
+ for(domain = 0; domain < pciNumDomains; domain++) {
+ if (!xf86DomainInfo[domain]) continue;
+
+ RANGE(range, 0, 0xffffffffUL,
+ RANGE_TYPE(ResExcMemBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+
+ RANGE(range, 0, 0x0000ffffUL,
+ RANGE_TYPE(ResExcIoBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+ }
+
+ return pRes;
+}
+
+resPtr
+xf86BusAccWindowsFromOS(void)
+{
+ return xf86PciBusAccWindowsFromOS();
+}
+
+resPtr
+xf86AccResFromOS(resPtr pRes)
+{
+ resRange range;
+ int domain;
+
+ for(domain = 0; domain < pciNumDomains; domain++) {
+ if (!xf86DomainInfo[domain]) continue;
+
+ /*
+ * Fallback is to claim the following areas:
+ *
+ * 0x000c0000 - 0x000effff location of VGA and other extensions ROMS
+ */
+
+ RANGE(range, 0x000c0000, 0x000effff,
+ RANGE_TYPE(ResExcMemBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+
+ /*
+ * Fallback would be to claim well known ports in the 0x0 - 0x3ff
+ * range along with their sparse I/O aliases, but that's too
+ * imprecise. Instead claim a bare minimum here.
+ */
+ RANGE(range, 0x00000000, 0x000000ff,
+ RANGE_TYPE(ResExcIoBlock, domain)); /* For mainboard */
+ pRes = xf86AddResToList(pRes, &range, -1);
+
+ /*
+ * At minimum, the top and bottom resources must be claimed, so that
+ * resources that are (or appear to be) unallocated can be relocated.
+ */
+ RANGE(range, 0x00000000, 0x00000000,
+ RANGE_TYPE(ResExcMemBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+ RANGE(range, 0xffffffff, 0xffffffff,
+ RANGE_TYPE(ResExcMemBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+/* RANGE(range, 0x00000000, 0x00000000,
+ RANGE_TYPE(ResExcIoBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1); */
+ RANGE(range, 0xffffffff, 0xffffffff,
+ RANGE_TYPE(ResExcIoBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+ }
+
+ return pRes;
+}
+
+#endif /* !INCLUDE_XF86_NO_DOMAIN */
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/e8870PCI.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/e8870PCI.c
new file mode 100644
index 000000000..65b0c0474
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/e8870PCI.c
@@ -0,0 +1,64 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/e8870PCI.c,v 1.2 2003/07/17 15:08:22 tsi Exp $ */
+/*
+ * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+/*
+ * This file contains the glue necessary for support of Intel's E8870 chipset.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "e8870PCI.h"
+#include "xf86.h"
+#include "Pci.h"
+
+Bool
+xorgProbeE8870(scanpciWrapperOpt flags)
+{
+ PCITAG tag;
+
+ /* Look for an E8870's Hub interface */
+ tag = PCI_MAKE_TAG(0, 0x1E, 0);
+ if (pciReadLong(tag, PCI_ID_REG) == DEVID(VENDOR_INTEL, CHIP_82801_P2P))
+ return TRUE;
+
+ return FALSE;
+}
+
+void
+xf86PreScanE8870(void)
+{
+ /* XXX Fill me in... */
+ return;
+}
+
+void
+xf86PostScanE8870(void)
+{
+ /* XXX Fill me in... */
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/e8870PCI.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/e8870PCI.h
new file mode 100644
index 000000000..9efa0ed6d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/e8870PCI.h
@@ -0,0 +1,42 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/e8870PCI.h,v 1.1 2003/02/23 20:26:49 tsi Exp $ */
+/*
+ * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef PCI_E8870_H
+#define PCI_E8870_H 1
+
+#include <X11/Xdefs.h>
+#include <Pci.h>
+
+Bool xorgProbeE8870(scanpciWrapperOpt flags);
+void xf86PreScanE8870(void);
+void xf86PostScanE8870(void);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c
new file mode 100644
index 000000000..f6d6f8a6d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c
@@ -0,0 +1,171 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c,v 1.4 2002/07/24 19:06:52 tsi Exp $ */
+/*
+ * Copyright 1998 by Concurrent Computer Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Concurrent Computer
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Concurrent Computer Corporation makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Copyright 1998 by Metro Link Incorporated
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include "compiler.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "Pci.h"
+
+#include <sys/pciio.h>
+
+/*
+ * freebsd platform specific PCI access functions -- using /dev/pci
+ * needs kernel version 2.2.x
+ */
+static CARD32 freebsdPciCfgRead(PCITAG tag, int off);
+static void freebsdPciCfgWrite(PCITAG, int off, CARD32 val);
+static void freebsdPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits);
+
+static pciBusFuncs_t freebsdFuncs0 = {
+/* pciReadLong */ freebsdPciCfgRead,
+/* pciWriteLong */ freebsdPciCfgWrite,
+/* pciSetBitsLong */ freebsdPciCfgSetBits,
+/* pciAddrHostToBus */ pciAddrNOOP,
+/* pciAddrBusToHost */ pciAddrNOOP
+};
+
+static pciBusInfo_t freebsdPci0 = {
+/* configMech */ PCI_CFG_MECH_OTHER,
+/* numDevices */ 32,
+/* secondary */ FALSE,
+/* primary_bus */ 0,
+#ifdef PowerMAX_OS
+/* ppc_io_base */ 0,
+/* ppc_io_size */ 0,
+#endif
+/* funcs */ &freebsdFuncs0,
+/* pciBusPriv */ NULL,
+/* bridge */ NULL
+};
+
+#if !defined(__OpenBSD__) && !defined(__FreeBSD__)
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+#ifdef __sparc__
+#ifndef ASI_PL
+#define ASI_PL 0x88
+#endif
+#define PCI_CPU(val) ({ \
+int __ret; \
+__asm__ __volatile__("lduwa [%1] %2, %0" : "=r" (__ret) : "r" (&val), "i" (ASI_PL)); \
+__ret; \
+})
+#else
+#define PCI_CPU(val) (((val >> 24) & 0x000000ff) | \
+ ((val >> 8) & 0x0000ff00) | \
+ ((val << 8) & 0x00ff0000) | \
+ ((val << 24) & 0xff000000))
+#endif
+#else
+#define PCI_CPU(val) (val)
+#endif
+#else /* ! OpenBSD */
+/* OpenBSD has already the bytes in the right order
+ for all architectures */
+#define PCI_CPU(val) (val)
+#endif
+
+
+#define BUS(tag) (((tag)>>16)&0xff)
+#define DFN(tag) (((tag)>>8)&0xff)
+
+static int pciFd = -1;
+
+void
+freebsdPciInit()
+{
+ pciFd = open("/dev/pci", O_RDWR);
+ if (pciFd < 0)
+ return;
+
+ pciNumBuses = 1;
+ pciBusInfo[0] = &freebsdPci0;
+ pciFindFirstFP = pciGenFindFirst;
+ pciFindNextFP = pciGenFindNext;
+}
+
+static CARD32
+freebsdPciCfgRead(PCITAG tag, int off)
+{
+ struct pci_io io;
+ int error;
+ io.pi_sel.pc_bus = BUS(tag);
+ io.pi_sel.pc_dev = DFN(tag) >> 3;
+ io.pi_sel.pc_func = DFN(tag) & 7;
+ io.pi_reg = off;
+ io.pi_width = 4;
+ error = ioctl(pciFd, PCIOCREAD, &io);
+ if (error)
+ return ~0;
+ return PCI_CPU(io.pi_data);
+}
+
+static void
+freebsdPciCfgWrite(PCITAG tag, int off, CARD32 val)
+{
+ struct pci_io io;
+ io.pi_sel.pc_bus = BUS(tag);
+ io.pi_sel.pc_dev = DFN(tag) >> 3;
+ io.pi_sel.pc_func = DFN(tag) & 7;
+ io.pi_reg = off;
+ io.pi_width = 4;
+ io.pi_data = PCI_CPU(val);
+ ioctl(pciFd, PCIOCWRITE, &io);
+}
+
+static void
+freebsdPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits)
+{
+ CARD32 val = freebsdPciCfgRead(tag, off);
+ val = (val & ~mask) | (bits & mask);
+ freebsdPciCfgWrite(tag, off, val);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/ix86Pci.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/ix86Pci.c
new file mode 100644
index 000000000..6e2b650d1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/ix86Pci.c
@@ -0,0 +1,704 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/ix86Pci.c,v 1.25 2003/09/24 02:43:34 dawes Exp $ */
+/*
+ * ix86Pci.c - x86 PCI driver
+ *
+ * The XFree86 server PCI access functions have been reimplemented as a
+ * framework that allows each supported platform/OS to have their own
+ * platform/OS specific PCI driver.
+ *
+ * Most of the code of these functions was simply lifted from the
+ * Intel architecture specifric portion of the original Xfree86
+ * PCI code in hw/xfree86/common_hw/xf86_PCI.C...
+ *
+ * Gary Barton
+ * Concurrent Computer Corporation
+ * garyb@gate.net
+ */
+
+/*
+ * Copyright 1998 by Concurrent Computer Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Concurrent Computer
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Concurrent Computer Corporation makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Copyright 1998 by Metro Link Incorporated
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * This software is derived from the original XFree86 PCI code
+ * which includes the following copyright notices as well:
+ *
+ * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the above listed copyright holder(s)
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. The above listed
+ * copyright holder(s) make(s) no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * This code is also based heavily on the code in FreeBSD-current, which was
+ * written by Wolfgang Stanglmeier, and contains the following copyright:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include "compiler.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "Pci.h"
+
+#ifdef PC98
+#define outb(port,data) _outb(port,data)
+#define outl(port,data) _outl(port,data)
+#define inb(port) _inb(port)
+#define inl(port) _inl(port)
+#endif
+
+#define PCI_CFGMECH2_ENABLE_REG 0xCF8
+#ifdef PC98
+#define PCI_CFGMECH2_FORWARD_REG 0xCF9
+#else
+#define PCI_CFGMECH2_FORWARD_REG 0xCFA
+#endif
+
+#define PCI_CFGMECH2_MAXDEV 16
+
+#define PCI_ADDR_FROM_TAG_CFG1(tag,reg) (PCI_EN | tag | (reg & 0xfc))
+#define PCI_FORWARD_FROM_TAG(tag) PCI_BUS_FROM_TAG(tag)
+#define PCI_ENABLE_FROM_TAG(tag) (0xf0 | (((tag) & 0x00000700) >> 7))
+#define PCI_ADDR_FROM_TAG_CFG2(tag,reg) (0xc000 | (((tag) & 0x0000f800) >> 3) \
+ | (reg & 0xfc))
+
+/*
+ * Intel x86 platform specific PCI access functions
+ */
+static CARD32 ix86PciReadLongSetup(PCITAG tag, int off);
+static void ix86PciWriteLongSetup(PCITAG, int off, CARD32 val);
+static void ix86PciSetBitsLongSetup(PCITAG, int off, CARD32 mask, CARD32 val);
+static CARD32 ix86PciReadLongCFG1(PCITAG tag, int off);
+static void ix86PciWriteLongCFG1(PCITAG, int off, CARD32 val);
+static void ix86PciSetBitsLongCFG1(PCITAG, int off, CARD32 mask, CARD32 val);
+static CARD32 ix86PciReadLongCFG2(PCITAG tag, int off);
+static void ix86PciWriteLongCFG2(PCITAG, int off, CARD32 val);
+static void ix86PciSetBitsLongCFG2(PCITAG, int off, CARD32 mask, CARD32 val);
+
+static pciBusFuncs_t ix86Funcs0 = {
+/* pciReadLong */ ix86PciReadLongSetup,
+/* pciWriteLong */ ix86PciWriteLongSetup,
+/* pciSetBitsLong */ ix86PciSetBitsLongSetup,
+/* pciAddrHostToBus */ pciAddrNOOP,
+/* pciAddrBusToHost */ pciAddrNOOP
+};
+
+static pciBusFuncs_t ix86Funcs1 = {
+/* pciReadLong */ ix86PciReadLongCFG1,
+/* pciWriteLong */ ix86PciWriteLongCFG1,
+/* pciSetBitsLong */ ix86PciSetBitsLongCFG1,
+/* pciAddrHostToBus */ pciAddrNOOP,
+/* pciAddrBusToHost */ pciAddrNOOP
+};
+
+static pciBusFuncs_t ix86Funcs2 = {
+/* pciReadLong */ ix86PciReadLongCFG2,
+/* pciWriteLong */ ix86PciWriteLongCFG2,
+/* pciSetBitsLong */ ix86PciSetBitsLongCFG2,
+/* pciAddrHostToBus */ pciAddrNOOP,
+/* pciAddrBusToHost */ pciAddrNOOP
+};
+
+static pciBusInfo_t ix86Pci0 = {
+/* configMech */ PCI_CFG_MECH_UNKNOWN, /* Set by ix86PciInit() */
+/* numDevices */ 0, /* Set by ix86PciInit() */
+/* secondary */ FALSE,
+/* primary_bus */ 0,
+#ifdef PowerMAX_OS
+/* ppc_io_base */ 0,
+/* ppc_io_size */ 0,
+#endif
+/* funcs */ &ix86Funcs0, /* Set by ix86PciInit() */
+/* pciBusPriv */ NULL,
+/* bridge */ NULL
+};
+
+static Bool
+ix86PciBusCheck(void)
+{
+ PCITAG tag;
+ CARD32 id, class;
+ CARD8 device;
+
+ for (device = 0; device < ix86Pci0.numDevices; device++) {
+ tag = PCI_MAKE_TAG(0, device, 0);
+ id = (*ix86Pci0.funcs->pciReadLong)(tag, PCI_ID_REG);
+
+ if ((CARD16)(id + 1U) <= (CARD16)1UL)
+ continue;
+
+ /* The rest of this is inspired by the Linux kernel */
+ class = (*ix86Pci0.funcs->pciReadLong)(tag, PCI_CLASS_REG);
+
+ /* Ignore revision id and programming interface */
+ switch (class >> 16) {
+ case (PCI_CLASS_PREHISTORIC << 8) | PCI_SUBCLASS_PREHISTORIC_MISC:
+ /* Check for vendors of known buggy chipsets */
+ id &= 0x0000ffff;
+ if ((id == PCI_VENDOR_INTEL) || (id == PCI_VENDOR_COMPAQ))
+ return TRUE;
+ continue;
+
+ case (PCI_CLASS_PREHISTORIC << 8) | PCI_SUBCLASS_PREHISTORIC_VGA:
+ case (PCI_CLASS_DISPLAY << 8) | PCI_SUBCLASS_DISPLAY_VGA:
+ case (PCI_CLASS_BRIDGE << 8) | PCI_SUBCLASS_BRIDGE_HOST:
+ return TRUE;
+
+ default:
+ break;
+ }
+ }
+ return FALSE;
+}
+
+static
+void ix86PciSelectCfgmech(void)
+{
+ static Bool beenhere = FALSE;
+ CARD32 mode1Res1 = 0, mode1Res2 = 0, oldVal1 = 0;
+ CARD8 mode2Res1 = 0, mode2Res2 = 0, oldVal2 = 0;
+ int stages = 0;
+
+ if (beenhere)
+ return; /* Been there, done that */
+
+ beenhere = TRUE;
+
+ /*
+ * Determine if motherboard chipset supports PCI Config Mech 1 or 2
+ * We rely on xf86Info.pciFlags to tell which mechanisms to try....
+ */
+ switch (xf86Info.pciFlags) {
+
+ case PCIOsConfig:
+#ifdef ARCH_PCI_OS_INIT
+ return;
+#endif
+
+ case PCIProbe1:
+ if (!xf86EnableIO())
+ return;
+
+ xf86MsgVerb(X_INFO, 2,
+ "PCI: Probing config type using method 1\n");
+ oldVal1 = inl(PCI_CFGMECH1_ADDRESS_REG);
+
+#ifdef DEBUGPCI
+ if (xf86Verbose > 2) {
+ ErrorF("Checking config type 1:\n"
+ "\tinitial value of MODE1_ADDR_REG is 0x%08x\n", oldVal1);
+ ErrorF("\tChecking that all bits in mask 0x7f000000 are clear\n");
+ }
+#endif
+
+ /* Assuming config type 1 to start with */
+ if ((oldVal1 & 0x7f000000) == 0) {
+
+ stages |= 0x01;
+
+#ifdef DEBUGPCI
+ if (xf86Verbose > 2) {
+ ErrorF("\tValue indicates possibly config type 1\n");
+ ErrorF("\tWriting 32-bit value 0x%08x to MODE1_ADDR_REG\n", PCI_EN);
+#if 0
+ ErrorF("\tWriting 8-bit value 0x00 to MODE1_ADDR_REG + 3\n");
+#endif
+ }
+#endif
+
+ ix86Pci0.configMech = PCI_CFG_MECH_1;
+ ix86Pci0.numDevices = PCI_CFGMECH1_MAXDEV;
+ ix86Pci0.funcs = &ix86Funcs1;
+
+ outl(PCI_CFGMECH1_ADDRESS_REG, PCI_EN);
+
+#if 0
+ /*
+ * This seems to cause some Neptune-based PCI machines to switch
+ * from config type 1 to config type 2
+ */
+ outb(PCI_CFGMECH1_ADDRESS_REG + 3, 0);
+#endif
+ mode1Res1 = inl(PCI_CFGMECH1_ADDRESS_REG);
+
+#ifdef DEBUGPCI
+ if (xf86Verbose > 2) {
+ ErrorF("\tValue read back from MODE1_ADDR_REG is 0x%08x\n",
+ mode1Res1);
+ ErrorF("\tRestoring original contents of MODE1_ADDR_REG\n");
+ }
+#endif
+
+ outl(PCI_CFGMECH1_ADDRESS_REG, oldVal1);
+
+ if (mode1Res1) {
+
+ stages |= 0x02;
+
+#ifdef DEBUGPCI
+ if (xf86Verbose > 2) {
+ ErrorF("\tValue read back is non-zero, and indicates possible"
+ " config type 1\n");
+ }
+#endif
+
+ if (ix86PciBusCheck()) {
+
+#ifdef DEBUGPCI
+ if (xf86Verbose > 2)
+ ErrorF("\tBus check Confirms this: ");
+#endif
+
+ xf86MsgVerb(X_INFO, 2, "PCI: Config type is 1\n");
+ xf86MsgVerb(X_INFO, 3,
+ "PCI: stages = 0x%02x, oldVal1 = 0x%08lx, mode1Res1"
+ " = 0x%08lx\n", stages, (unsigned long)oldVal1,
+ (unsigned long)mode1Res1);
+ return;
+ }
+
+#ifdef DEBUGPCI
+ if (xf86Verbose > 2) {
+ ErrorF("\tBus check fails to confirm this, continuing type 1"
+ " check ...\n");
+ }
+#endif
+
+ }
+
+ stages |= 0x04;
+
+#ifdef DEBUGPCI
+ if (xf86Verbose > 2) {
+ ErrorF("\tWriting 0xff000001 to MODE1_ADDR_REG\n");
+ }
+#endif
+ outl(PCI_CFGMECH1_ADDRESS_REG, 0xff000001);
+ mode1Res2 = inl(PCI_CFGMECH1_ADDRESS_REG);
+
+#ifdef DEBUGPCI
+ if (xf86Verbose > 2) {
+ ErrorF("\tValue read back from MODE1_ADDR_REG is 0x%08x\n",
+ mode1Res2);
+ ErrorF("\tRestoring original contents of MODE1_ADDR_REG\n");
+ }
+#endif
+
+ outl(PCI_CFGMECH1_ADDRESS_REG, oldVal1);
+
+ if ((mode1Res2 & 0x80000001) == 0x80000000) {
+
+ stages |= 0x08;
+
+#ifdef DEBUGPCI
+ if (xf86Verbose > 2) {
+ ErrorF("\tValue read back has only the msb set\n"
+ "\tThis indicates possible config type 1\n");
+ }
+#endif
+
+ if (ix86PciBusCheck()) {
+
+#ifdef DEBUGPCI
+ if (xf86Verbose > 2)
+ ErrorF("\tBus check Confirms this: ");
+#endif
+
+ xf86MsgVerb(X_INFO, 2, "PCI: Config type is 1\n");
+ xf86MsgVerb(X_INFO, 3,
+ "PCI: stages = 0x%02x, oldVal1 = 0x%08lx,\n"
+ "\tmode1Res1 = 0x%08lx, mode1Res2 = 0x%08lx\n",
+ stages, (unsigned long)oldVal1,
+ (unsigned long)mode1Res1, (unsigned long)mode1Res2);
+ return;
+ }
+
+#ifdef DEBUGPCI
+ if (xf86Verbose > 2) {
+ ErrorF("\tBus check fails to confirm this.\n");
+ }
+#endif
+
+ }
+ }
+
+ xf86MsgVerb(X_INFO, 3, "PCI: Standard check for type 1 failed.\n");
+ xf86MsgVerb(X_INFO, 3, "PCI: stages = 0x%02x, oldVal1 = 0x%08lx,\n"
+ "\tmode1Res1 = 0x%08lx, mode1Res2 = 0x%08lx\n",
+ stages, (unsigned long)oldVal1, (unsigned long)mode1Res1,
+ (unsigned long)mode1Res2);
+
+ /* Try config type 2 */
+ oldVal2 = inb(PCI_CFGMECH2_ENABLE_REG);
+ if ((oldVal2 & 0xf0) == 0) {
+ ix86Pci0.configMech = PCI_CFG_MECH_2;
+ ix86Pci0.numDevices = PCI_CFGMECH2_MAXDEV;
+ ix86Pci0.funcs = &ix86Funcs2;
+
+ outb(PCI_CFGMECH2_ENABLE_REG, 0x0e);
+ mode2Res1 = inb(PCI_CFGMECH2_ENABLE_REG);
+ outb(PCI_CFGMECH2_ENABLE_REG, oldVal2);
+
+ if (mode2Res1 == 0x0e) {
+ if (ix86PciBusCheck()) {
+ xf86MsgVerb(X_INFO, 2, "PCI: Config type is 2\n");
+ return;
+ }
+ }
+ }
+ break; /* } */
+
+ case PCIProbe2: /* { */
+ if (!xf86EnableIO())
+ return;
+
+ /* The scanpci-style detection method */
+
+ xf86MsgVerb(X_INFO, 2, "PCI: Probing config type using method 2\n");
+
+ outb(PCI_CFGMECH2_ENABLE_REG, 0x00);
+ outb(PCI_CFGMECH2_FORWARD_REG, 0x00);
+ mode2Res1 = inb(PCI_CFGMECH2_ENABLE_REG);
+ mode2Res2 = inb(PCI_CFGMECH2_FORWARD_REG);
+
+ if (mode2Res1 == 0 && mode2Res2 == 0) {
+ xf86MsgVerb(X_INFO, 2, "PCI: Config type is 2\n");
+ ix86Pci0.configMech = PCI_CFG_MECH_2;
+ ix86Pci0.numDevices = PCI_CFGMECH2_MAXDEV;
+ ix86Pci0.funcs = &ix86Funcs2;
+ return;
+ }
+
+ oldVal1 = inl(PCI_CFGMECH1_ADDRESS_REG);
+ outl(PCI_CFGMECH1_ADDRESS_REG, PCI_EN);
+ mode1Res1 = inl(PCI_CFGMECH1_ADDRESS_REG);
+ outl(PCI_CFGMECH1_ADDRESS_REG, oldVal1);
+ if (mode1Res1 == PCI_EN) {
+ xf86MsgVerb(X_INFO, 2, "PCI: Config type is 1\n");
+ ix86Pci0.configMech = PCI_CFG_MECH_1;
+ ix86Pci0.numDevices = PCI_CFGMECH1_MAXDEV;
+ ix86Pci0.funcs = &ix86Funcs1;
+ return;
+ }
+ break; /* } */
+
+ case PCIForceConfig1:
+ if (!xf86EnableIO())
+ return;
+
+ xf86MsgVerb(X_INFO, 2, "PCI: Forcing config type 1\n");
+
+ ix86Pci0.configMech = PCI_CFG_MECH_1;
+ ix86Pci0.numDevices = PCI_CFGMECH1_MAXDEV;
+ ix86Pci0.funcs = &ix86Funcs1;
+ return;
+
+ case PCIForceConfig2:
+ if (!xf86EnableIO())
+ return;
+
+ xf86MsgVerb(X_INFO, 2, "PCI: Forcing config type 2\n");
+
+ ix86Pci0.configMech = PCI_CFG_MECH_2;
+ ix86Pci0.numDevices = PCI_CFGMECH2_MAXDEV;
+ ix86Pci0.funcs = &ix86Funcs2;
+ return;
+
+ case PCIForceNone:
+ break;
+ }
+
+ /* No PCI found */
+ ix86Pci0.configMech = PCI_CFG_MECH_UNKNOWN;
+ xf86MsgVerb(X_INFO, 2, "PCI: No PCI bus found or probed for\n");
+}
+
+#if 0
+static pciTagRec
+ix86PcibusTag(CARD8 bus, CARD8 cardnum, CARD8 func)
+{
+ pciTagRec tag;
+
+ tag.cfg1 = 0;
+
+ if (func > 7 || cardnum >= pciBusInfo[bus]->numDevices)
+ return tag;
+
+ switch (ix86Pci0.configMech) {
+ case PCI_CFG_MECH_1:
+ tag.cfg1 = PCI_EN | ((CARD32)bus << 16) |
+ ((CARD32)cardnum << 11) |
+ ((CARD32)func << 8);
+ break;
+
+ case PCI_CFG_MECH_2:
+ tag.cfg2.port = 0xc000 | ((CARD16)cardnum << 8);
+ tag.cfg2.enable = 0xf0 | (func << 1);
+ tag.cfg2.forward = bus;
+ break;
+ }
+
+ return tag;
+}
+#endif
+
+static CARD32
+ix86PciReadLongSetup(PCITAG Tag, int reg)
+{
+ ix86PciSelectCfgmech();
+ return (*ix86Pci0.funcs->pciReadLong)(Tag,reg);
+}
+
+static CARD32
+ix86PciReadLongCFG1(PCITAG Tag, int reg)
+{
+ CARD32 addr, data = 0;
+
+#ifdef DEBUGPCI
+ ErrorF("ix86PciReadLong 0x%lx, %d\n", Tag, reg);
+#endif
+
+ addr = PCI_ADDR_FROM_TAG_CFG1(Tag,reg);
+ outl(PCI_CFGMECH1_ADDRESS_REG, addr);
+ data = inl(PCI_CFGMECH1_DATA_REG);
+ outl(PCI_CFGMECH1_ADDRESS_REG, 0);
+
+#ifdef DEBUGPCI
+ ErrorF("ix86PciReadLong 0x%lx\n", data);
+#endif
+
+ return data;
+}
+
+static CARD32
+ix86PciReadLongCFG2(PCITAG Tag, int reg)
+{
+ CARD32 addr, data = 0;
+ CARD8 forward, enable;
+
+#ifdef DEBUGPCI
+ ErrorF("ix86PciReadLong 0x%lx, %d\n", Tag, reg);
+#endif
+
+ forward = PCI_FORWARD_FROM_TAG(Tag);
+ enable = PCI_ENABLE_FROM_TAG(Tag);
+ addr = PCI_ADDR_FROM_TAG_CFG2(Tag,reg);
+
+ outb(PCI_CFGMECH2_ENABLE_REG, enable);
+ outb(PCI_CFGMECH2_FORWARD_REG, forward);
+ data = inl((CARD16)addr);
+ outb(PCI_CFGMECH2_ENABLE_REG, 0);
+ outb(PCI_CFGMECH2_FORWARD_REG, 0);
+
+#ifdef DEBUGPCI
+ ErrorF("ix86PciReadLong 0x%lx\n", data);
+#endif
+
+ return data;
+}
+
+static void
+ix86PciWriteLongSetup(PCITAG Tag, int reg, CARD32 data)
+{
+ ix86PciSelectCfgmech();
+ (*ix86Pci0.funcs->pciWriteLong)(Tag,reg,data);
+}
+
+static void
+ix86PciWriteLongCFG1(PCITAG Tag, int reg, CARD32 data)
+{
+ CARD32 addr;
+
+ addr = PCI_ADDR_FROM_TAG_CFG1(Tag,reg);
+ outl(PCI_CFGMECH1_ADDRESS_REG, addr);
+ outl(PCI_CFGMECH1_DATA_REG, data);
+ outl(PCI_CFGMECH1_ADDRESS_REG, 0);
+}
+
+static void
+ix86PciWriteLongCFG2(PCITAG Tag, int reg, CARD32 data)
+{
+ CARD32 addr;
+ CARD8 forward, enable;
+
+ forward = PCI_FORWARD_FROM_TAG(Tag);
+ enable = PCI_ENABLE_FROM_TAG(Tag);
+ addr = PCI_ADDR_FROM_TAG_CFG2(Tag,reg);
+
+ outb(PCI_CFGMECH2_ENABLE_REG, enable);
+ outb(PCI_CFGMECH2_FORWARD_REG, forward);
+ outl((CARD16)addr, data);
+ outb(PCI_CFGMECH2_ENABLE_REG, 0);
+ outb(PCI_CFGMECH2_FORWARD_REG, 0);
+}
+
+static void
+ix86PciSetBitsLongSetup(PCITAG Tag, int reg, CARD32 mask, CARD32 val)
+{
+ ix86PciSelectCfgmech();
+ (*ix86Pci0.funcs->pciSetBitsLong)(Tag,reg,mask,val);
+}
+
+static void
+ix86PciSetBitsLongCFG1(PCITAG Tag, int reg, CARD32 mask, CARD32 val)
+{
+ CARD32 addr, data = 0;
+
+#ifdef DEBUGPCI
+ ErrorF("ix86PciSetBitsLong 0x%lx, %d\n", Tag, reg);
+#endif
+
+ addr = PCI_ADDR_FROM_TAG_CFG1(Tag,reg);
+ outl(PCI_CFGMECH1_ADDRESS_REG, addr);
+ data = inl(PCI_CFGMECH1_DATA_REG);
+ data = (data & ~mask) | (val & mask);
+ outl(PCI_CFGMECH1_DATA_REG, data);
+ outl(PCI_CFGMECH1_ADDRESS_REG, 0);
+}
+
+static void
+ix86PciSetBitsLongCFG2(PCITAG Tag, int reg, CARD32 mask, CARD32 val)
+{
+ CARD32 addr, data = 0;
+ CARD8 enable, forward;
+
+#ifdef DEBUGPCI
+ ErrorF("ix86PciSetBitsLong 0x%lx, %d\n", Tag, reg);
+#endif
+
+ forward = PCI_FORWARD_FROM_TAG(Tag);
+ enable = PCI_ENABLE_FROM_TAG(Tag);
+ addr = PCI_ADDR_FROM_TAG_CFG2(Tag,reg);
+
+ outb(PCI_CFGMECH2_ENABLE_REG, enable);
+ outb(PCI_CFGMECH2_FORWARD_REG, forward);
+ data = inl((CARD16)addr);
+ data = (data & ~mask) | (val & mask);
+ outl((CARD16)addr, data);
+ outb(PCI_CFGMECH2_ENABLE_REG, 0);
+ outb(PCI_CFGMECH2_FORWARD_REG, 0);
+}
+
+void
+ix86PciInit()
+{
+ /* Initialize pciBusInfo[] array and function pointers */
+ pciNumBuses = 1;
+ pciBusInfo[0] = &ix86Pci0;
+ pciFindFirstFP = pciGenFindFirst;
+ pciFindNextFP = pciGenFindNext;
+
+ /* Make sure that there is a PCI bus present. */
+ ix86PciSelectCfgmech();
+ if (ix86Pci0.configMech == PCI_CFG_MECH_UNKNOWN) {
+ pciNumBuses = 0;
+ pciBusInfo[0] = NULL;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/linuxPci.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/linuxPci.c
new file mode 100644
index 000000000..40fb4604b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/linuxPci.c
@@ -0,0 +1,894 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/linuxPci.c,v 1.9 2002/09/24 16:14:16 tsi Exp $ */
+/*
+ * Copyright 1998 by Concurrent Computer Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Concurrent Computer
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Concurrent Computer Corporation makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Copyright 1998 by Metro Link Incorporated
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include "compiler.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "Pci.h"
+
+/*
+ * linux platform specific PCI access functions -- using /proc/bus/pci
+ * needs kernel version 2.2.x
+ */
+static CARD32 linuxPciCfgRead(PCITAG tag, int off);
+static void linuxPciCfgWrite(PCITAG, int off, CARD32 val);
+static void linuxPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits);
+static ADDRESS linuxTransAddrBusToHost(PCITAG tag, PciAddrType type, ADDRESS addr);
+#if defined(__powerpc__)
+static ADDRESS linuxPpcBusAddrToHostAddr(PCITAG, PciAddrType, ADDRESS);
+static ADDRESS linuxPpcHostAddrToBusAddr(PCITAG, PciAddrType, ADDRESS);
+#endif
+
+static CARD8 linuxPciCfgReadByte(PCITAG tag, int off);
+static void linuxPciCfgWriteByte(PCITAG tag, int off, CARD8 val);
+static CARD16 linuxPciCfgReadWord(PCITAG tag, int off);
+static void linuxPciCfgWriteWord(PCITAG tag, int off, CARD16 val);
+
+static pciBusFuncs_t linuxFuncs0 = {
+/* pciReadLong */ linuxPciCfgRead,
+/* pciWriteLong */ linuxPciCfgWrite,
+/* pciSetBitsLong */ linuxPciCfgSetBits,
+#if defined(__powerpc__)
+/* pciAddrHostToBus */ linuxPpcHostAddrToBusAddr,
+/* pciAddrBusToHost */ linuxPpcBusAddrToHostAddr,
+#else
+/* pciAddrHostToBus */ pciAddrNOOP,
+/* pciAddrBusToHost */ linuxTransAddrBusToHost,
+#endif
+
+/* pciControlBridge */ NULL,
+/* pciGetBridgeBuses */ NULL,
+/* pciGetBridgeResources */ NULL,
+
+/* pciReadByte */ linuxPciCfgReadByte,
+/* pciWriteByte */ linuxPciCfgWriteByte,
+
+/* pciReadWord */ linuxPciCfgReadWord,
+/* pciWriteWord */ linuxPciCfgWriteWord,
+};
+
+static pciBusInfo_t linuxPci0 = {
+/* configMech */ PCI_CFG_MECH_OTHER,
+/* numDevices */ 32,
+/* secondary */ FALSE,
+/* primary_bus */ 0,
+#ifdef PowerMAX_OS
+/* ppc_io_base */ 0,
+/* ppc_io_size */ 0,
+#endif
+/* funcs */ &linuxFuncs0,
+/* pciBusPriv */ NULL,
+/* bridge */ NULL
+};
+
+void
+linuxPciInit()
+{
+ struct stat st;
+ if ((xf86Info.pciFlags == PCIForceNone) ||
+ (-1 == stat("/proc/bus/pci", &st))) {
+ /* when using this as default for all linux architectures,
+ we'll need a fallback for 2.0 kernels here */
+ return;
+ }
+ pciNumBuses = 1;
+ pciBusInfo[0] = &linuxPci0;
+ pciFindFirstFP = pciGenFindFirst;
+ pciFindNextFP = pciGenFindNext;
+}
+
+static int
+linuxPciOpenFile(PCITAG tag, Bool write)
+{
+ static int lbus,ldev,lfunc,fd = -1,is_write = 0;
+ int bus, dev, func;
+ char file[32];
+ struct stat ignored;
+
+ bus = PCI_BUS_FROM_TAG(tag);
+ dev = PCI_DEV_FROM_TAG(tag);
+ func = PCI_FUNC_FROM_TAG(tag);
+ if (fd == -1 || (write && (!is_write))
+ || bus != lbus || dev != ldev || func != lfunc) {
+ if (fd != -1)
+ close(fd);
+ if (bus < 256) {
+ sprintf(file,"/proc/bus/pci/%02x",bus);
+ if (stat(file, &ignored) < 0)
+ sprintf(file, "/proc/bus/pci/0000:%02x/%02x.%1x",
+ bus, dev, func);
+ else
+ sprintf(file, "/proc/bus/pci/%02x/%02x.%1x",
+ bus, dev, func);
+ } else {
+ sprintf(file,"/proc/bus/pci/%04x",bus);
+ if (stat(file, &ignored) < 0)
+ sprintf(file, "/proc/bus/pci/0000:%04x/%02x.%1x",
+ bus, dev, func);
+ else
+ sprintf(file, "/proc/bus/pci/%04x/%02x.%1x",
+ bus, dev, func);
+ }
+ if (write) {
+ fd = open(file,O_RDWR);
+ if (fd != -1) is_write = TRUE;
+ } else switch (is_write) {
+ case TRUE:
+ fd = open(file,O_RDWR);
+ if (fd > -1)
+ break;
+ default:
+ fd = open(file,O_RDONLY);
+ is_write = FALSE;
+ }
+
+ lbus = bus;
+ ldev = dev;
+ lfunc = func;
+ }
+ return fd;
+}
+
+static CARD32
+linuxPciCfgRead(PCITAG tag, int off)
+{
+ int fd;
+ CARD32 val = 0xffffffff;
+
+ if (-1 != (fd = linuxPciOpenFile(tag,FALSE))) {
+ lseek(fd,off,SEEK_SET);
+ read(fd,&val,4);
+ }
+ return PCI_CPU(val);
+}
+
+static void
+linuxPciCfgWrite(PCITAG tag, int off, CARD32 val)
+{
+ int fd;
+
+ if (-1 != (fd = linuxPciOpenFile(tag,TRUE))) {
+ lseek(fd,off,SEEK_SET);
+ val = PCI_CPU(val);
+ write(fd,&val,4);
+ }
+}
+
+static void
+linuxPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits)
+{
+ int fd;
+ CARD32 val = 0xffffffff;
+
+ if (-1 != (fd = linuxPciOpenFile(tag,TRUE))) {
+ lseek(fd,off,SEEK_SET);
+ read(fd,&val,4);
+ val = PCI_CPU(val);
+ val = (val & ~mask) | (bits & mask);
+ val = PCI_CPU(val);
+ lseek(fd,off,SEEK_SET);
+ write(fd,&val,4);
+ }
+}
+
+/*
+ * This function will convert a BAR address into a host address
+ * suitable for passing into the mmap function of a /proc/bus
+ * device.
+ */
+ADDRESS linuxTransAddrBusToHost(PCITAG tag, PciAddrType type, ADDRESS addr)
+{
+ ADDRESS ret = xf86GetOSOffsetFromPCI(tag, PCI_MEM|PCI_IO, addr);
+
+ if (ret)
+ return ret;
+
+ /*
+ * if it is not a BAR address, it must be legacy, (or wrong)
+ * return it as is..
+ */
+ return addr;
+}
+
+
+#if defined(__powerpc__)
+
+#ifndef __NR_pciconfig_iobase
+#define __NR_pciconfig_iobase 200
+#endif
+
+static ADDRESS
+linuxPpcBusAddrToHostAddr(PCITAG tag, PciAddrType type, ADDRESS addr)
+{
+ if (type == PCI_MEM)
+ {
+ ADDRESS membase = syscall(__NR_pciconfig_iobase, 1,
+ PCI_BUS_FROM_TAG(tag), PCI_DFN_FROM_TAG(tag));
+ return (addr + membase);
+ }
+ else if (type == PCI_IO)
+ {
+ ADDRESS iobase = syscall(__NR_pciconfig_iobase, 2,
+ PCI_BUS_FROM_TAG(tag), PCI_DFN_FROM_TAG(tag));
+ return (addr + iobase);
+ }
+ else return addr;
+}
+
+static ADDRESS
+linuxPpcHostAddrToBusAddr(PCITAG tag, PciAddrType type, ADDRESS addr)
+{
+ if (type == PCI_MEM)
+ {
+ ADDRESS membase = syscall(__NR_pciconfig_iobase, 1,
+ PCI_BUS_FROM_TAG(tag), PCI_DFN_FROM_TAG(tag));
+ return (addr - membase);
+ }
+ else if (type == PCI_IO)
+ {
+ ADDRESS iobase = syscall(__NR_pciconfig_iobase, 2,
+ PCI_BUS_FROM_TAG(tag), PCI_DFN_FROM_TAG(tag));
+ return (addr - iobase);
+ }
+ else return addr;
+}
+
+#endif /* __powerpc__ */
+
+static CARD8
+linuxPciCfgReadByte(PCITAG tag, int off)
+{
+ int fd;
+ CARD8 val = 0xff;
+
+ if (-1 != (fd = linuxPciOpenFile(tag,FALSE))) {
+ lseek(fd,off,SEEK_SET);
+ read(fd,&val,1);
+ }
+
+ return val;
+}
+
+static void
+linuxPciCfgWriteByte(PCITAG tag, int off, CARD8 val)
+{
+ int fd;
+
+ if (-1 != (fd = linuxPciOpenFile(tag,TRUE))) {
+ lseek(fd,off,SEEK_SET);
+ write(fd, &val, 1);
+ }
+}
+
+static CARD16
+linuxPciCfgReadWord(PCITAG tag, int off)
+{
+ int fd;
+ CARD16 val = 0xff;
+
+ if (-1 != (fd = linuxPciOpenFile(tag,FALSE))) {
+ lseek(fd, off, SEEK_SET);
+ read(fd, &val, 2);
+ }
+
+ return PCI_CPU16(val);
+}
+
+static void
+linuxPciCfgWriteWord(PCITAG tag, int off, CARD16 val)
+{
+ int fd;
+
+ if (-1 != (fd = linuxPciOpenFile(tag,TRUE))) {
+ lseek(fd, off, SEEK_SET);
+ val = PCI_CPU16(val);
+ write(fd, &val, 2);
+ }
+}
+
+#ifndef INCLUDE_XF86_NO_DOMAIN
+
+/*
+ * Compiling the following simply requires the presence of <linux/pci.c>.
+ * Actually running this is another matter altogether...
+ *
+ * This scheme requires that the kernel allow mmap()'ing of a host bridge's I/O
+ * and memory spaces through its /proc/bus/pci/BUS/DFN entry. Which one is
+ * determined by a prior ioctl().
+ *
+ * For the sparc64 port, this means 2.4.12 or later. For ppc, this
+ * functionality is almost, but not quite there yet. Alpha and other kernel
+ * ports to multi-domain architectures still need to implement this.
+ *
+ * This scheme is also predicated on the use of an IOADDRESS compatible type to
+ * designate I/O addresses. Although IOADDRESS is defined as an unsigned
+ * integral type, it is actually the virtual address of, i.e. a pointer to, the
+ * I/O port to access. And so, the inX/outX macros in "compiler.h" need to be
+ * #define'd appropriately (as is done on SPARC's).
+ *
+ * Another requirement to port this scheme to another multi-domain architecture
+ * is to add the appropriate entries in the pciControllerSizes array below.
+ *
+ * TO DO: Address the deleterious reaction some host bridges have to master
+ * aborts. This is already done for secondary PCI buses, but not yet
+ * for accesses to primary buses (except for the SPARC port, where
+ * master aborts are avoided during PCI scans).
+ */
+
+#include <linux/pci.h>
+
+#ifndef PCIIOC_BASE /* Ioctls for /proc/bus/pci/X/Y nodes. */
+#define PCIIOC_BASE ('P' << 24 | 'C' << 16 | 'I' << 8)
+
+/* Get controller for PCI device. */
+#define PCIIOC_CONTROLLER (PCIIOC_BASE | 0x00)
+/* Set mmap state to I/O space. */
+#define PCIIOC_MMAP_IS_IO (PCIIOC_BASE | 0x01)
+/* Set mmap state to MEM space. */
+#define PCIIOC_MMAP_IS_MEM (PCIIOC_BASE | 0x02)
+/* Enable/disable write-combining. */
+#define PCIIOC_WRITE_COMBINE (PCIIOC_BASE | 0x03)
+
+#endif
+
+/* This probably shouldn't be Linux-specific */
+static pciConfigPtr
+xf86GetPciHostConfigFromTag(PCITAG Tag)
+{
+ int bus = PCI_BUS_FROM_TAG(Tag);
+ pciBusInfo_t *pBusInfo;
+
+ while ((bus < pciNumBuses) && (pBusInfo = pciBusInfo[bus])) {
+ if (bus == pBusInfo->primary_bus)
+ return pBusInfo->bridge;
+ bus = pBusInfo->primary_bus;
+ }
+
+ return NULL; /* Bad data */
+}
+
+/*
+ * This is ugly, but until I can extract this information from the kernel,
+ * it'll have to do. The default I/O space size is 64K, and 4G for memory.
+ * Anything else needs to go in this table. (PowerPC folk take note.)
+ *
+ * Note that Linux/SPARC userland is 32-bit, so 4G overflows to zero here.
+ *
+ * Please keep this table in ascending vendor/device order.
+ */
+static struct pciSizes {
+ unsigned short vendor, device;
+ unsigned long io_size, mem_size;
+} pciControllerSizes[] = {
+ {
+ PCI_VENDOR_SUN, PCI_CHIP_PSYCHO,
+ 1U << 16, 1U << 31
+ },
+ {
+ PCI_VENDOR_SUN, PCI_CHIP_SCHIZO,
+ 1U << 24, 1U << 31 /* ??? */
+ },
+ {
+ PCI_VENDOR_SUN, PCI_CHIP_SABRE,
+ 1U << 24, (unsigned long)(1ULL << 32)
+ },
+ {
+ PCI_VENDOR_SUN, PCI_CHIP_HUMMINGBIRD,
+ 1U << 24, (unsigned long)(1ULL << 32)
+ }
+};
+#define NUM_SIZES (sizeof(pciControllerSizes) / sizeof(pciControllerSizes[0]))
+
+static unsigned long
+linuxGetIOSize(PCITAG Tag)
+{
+ pciConfigPtr pPCI;
+ int i;
+
+ /* Find host bridge */
+ if ((pPCI = xf86GetPciHostConfigFromTag(Tag))) {
+ /* Look up vendor/device */
+ for (i = 0; i < NUM_SIZES; i++) {
+ if (pPCI->pci_vendor > pciControllerSizes[i].vendor)
+ continue;
+ if (pPCI->pci_vendor < pciControllerSizes[i].vendor)
+ break;
+ if (pPCI->pci_device > pciControllerSizes[i].device)
+ continue;
+ if (pPCI->pci_device < pciControllerSizes[i].device)
+ break;
+ return pciControllerSizes[i].io_size;
+ }
+ }
+
+ return 1U << 16; /* Default to 64K */
+}
+
+static void
+linuxGetSizes(PCITAG Tag, unsigned long *io_size, unsigned long *mem_size)
+{
+ pciConfigPtr pPCI;
+ int i;
+
+ *io_size = (1U << 16); /* Default to 64K */
+ *mem_size = (unsigned long)(1ULL << 32); /* Default to 4G */
+
+ /* Find host bridge */
+ if ((pPCI = xf86GetPciHostConfigFromTag(Tag))) {
+ /* Look up vendor/device */
+ for (i = 0; i < NUM_SIZES; i++) {
+ if (pPCI->pci_vendor > pciControllerSizes[i].vendor)
+ continue;
+ if (pPCI->pci_vendor < pciControllerSizes[i].vendor)
+ break;
+ if (pPCI->pci_device > pciControllerSizes[i].device)
+ continue;
+ if (pPCI->pci_device < pciControllerSizes[i].device)
+ break;
+ *io_size = pciControllerSizes[i].io_size;
+ *mem_size = pciControllerSizes[i].mem_size;
+ break;
+ }
+ }
+}
+
+int
+xf86GetPciDomain(PCITAG Tag)
+{
+ pciConfigPtr pPCI;
+ int fd, result;
+
+ pPCI = xf86GetPciHostConfigFromTag(Tag);
+
+ if (pPCI && (result = PCI_DOM_FROM_BUS(pPCI->busnum)))
+ return result;
+
+ if (!pPCI || pPCI->fakeDevice)
+ return 1; /* Domain 0 is reserved */
+
+ if ((fd = linuxPciOpenFile(pPCI ? pPCI->tag : 0,FALSE)) < 0)
+ return 0;
+
+ if ((result = ioctl(fd, PCIIOC_CONTROLLER, 0)) < 0)
+ return 0;
+
+ return result + 1; /* Domain 0 is reserved */
+}
+
+static pointer
+linuxMapPci(int ScreenNum, int Flags, PCITAG Tag,
+ ADDRESS Base, unsigned long Size, int mmap_ioctl)
+{
+ do {
+ pciConfigPtr pPCI;
+ unsigned char *result;
+ ADDRESS realBase, Offset;
+ int fd, mmapflags, prot;
+
+ xf86InitVidMem();
+
+ pPCI = xf86GetPciHostConfigFromTag(Tag);
+
+ if (((fd = linuxPciOpenFile(pPCI ? pPCI->tag : 0,FALSE)) < 0) ||
+ (ioctl(fd, mmap_ioctl, 0) < 0))
+ break;
+
+/* Note: IA-64 doesn't compile this and doesn't need to */
+#ifdef __ia64__
+
+# ifndef MAP_WRITECOMBINED
+# define MAP_WRITECOMBINED 0x00010000
+# endif
+# ifndef MAP_NONCACHED
+# define MAP_NONCACHED 0x00020000
+# endif
+
+ if (Flags & VIDMEM_FRAMEBUFFER)
+ mmapflags = MAP_SHARED | MAP_WRITECOMBINED;
+ else
+ mmapflags = MAP_SHARED | MAP_NONCACHED;
+
+#else /* !__ia64__ */
+
+ mmapflags = (Flags & VIDMEM_FRAMEBUFFER) / VIDMEM_FRAMEBUFFER;
+
+ if (ioctl(fd, PCIIOC_WRITE_COMBINE, mmapflags) < 0)
+ break;
+
+ mmapflags = MAP_SHARED;
+
+#endif /* ?__ia64__ */
+
+ /* Align to page boundary */
+ realBase = Base & ~(getpagesize() - 1);
+ Offset = Base - realBase;
+
+ if (Flags & VIDMEM_READONLY)
+ prot = PROT_READ;
+ else
+ prot = PROT_READ | PROT_WRITE;
+
+ result = mmap(NULL, Size + Offset, prot, mmapflags, fd, realBase);
+
+ if (!result || ((pointer)result == MAP_FAILED))
+ return NULL;
+
+ xf86MakeNewMapping(ScreenNum, Flags, realBase, Size + Offset, result);
+
+ return result + Offset;
+ } while (0);
+
+ if (mmap_ioctl == PCIIOC_MMAP_IS_MEM)
+ return xf86MapVidMem(ScreenNum, Flags, Base, Size);
+
+ return NULL;
+}
+
+#define MAX_DOMAINS 257
+static pointer DomainMmappedIO[MAX_DOMAINS];
+static pointer DomainMmappedMem[MAX_DOMAINS];
+
+static int
+linuxOpenLegacy(PCITAG Tag, char *name)
+{
+#define PREFIX "/sys/class/pci_bus/%04x:%02x/%s"
+ char *path;
+ int domain, bus;
+ pciBusInfo_t *pBusInfo;
+ pciConfigPtr bridge = NULL;
+ int fd;
+
+ path = xalloc(strlen(PREFIX) + strlen(name));
+ if (!path)
+ return -1;
+
+ for (;;) {
+ domain = xf86GetPciDomain(Tag);
+ bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(Tag));
+
+ /* Domain 0 is reserved -- see xf86GetPciDomain() */
+ if ((domain <= 0) || (domain >= MAX_DOMAINS))
+ FatalError("linuxOpenLegacy(): domain out of range\n");
+
+ sprintf(path, PREFIX, domain - 1, bus, name);
+ fd = open(path, O_RDWR);
+ if (fd >= 0) {
+ xfree(path);
+ return fd;
+ }
+
+ pBusInfo = pciBusInfo[bus];
+ if (!pBusInfo || (bridge == pBusInfo->bridge) ||
+ !(bridge = pBusInfo->bridge)) {
+ xfree(path);
+ return -1;
+ }
+
+ Tag = bridge->tag;
+ }
+
+ xfree(path);
+ return fd;
+}
+
+/*
+ * xf86MapDomainMemory - memory map PCI domain memory
+ *
+ * This routine maps the memory region in the domain specified by Tag and
+ * returns a pointer to it. The pointer is saved for future use if it's in
+ * the legacy ISA memory space (memory in a domain between 0 and 1MB).
+ */
+pointer
+xf86MapDomainMemory(int ScreenNum, int Flags, PCITAG Tag,
+ ADDRESS Base, unsigned long Size)
+{
+ int domain = xf86GetPciDomain(Tag);
+ int fd;
+
+ /*
+ * We use /proc/bus/pci on non-legacy addresses or if the Linux sysfs
+ * legacy_mem interface is unavailable.
+ */
+ if (Base > 1024*1024)
+ return linuxMapPci(ScreenNum, Flags, Tag, Base, Size,
+ PCIIOC_MMAP_IS_MEM);
+
+ if ((fd = linuxOpenLegacy(Tag, "legacy_mem")) < 0)
+ return linuxMapPci(ScreenNum, Flags, Tag, Base, Size,
+ PCIIOC_MMAP_IS_MEM);
+
+
+ /* If we haven't already mapped this legacy space, try to. */
+ if (!DomainMmappedMem[domain]) {
+ DomainMmappedMem[domain] = mmap(NULL, 1024*1024, PROT_READ|PROT_WRITE,
+ MAP_SHARED, fd, 0);
+ if (DomainMmappedMem[domain] == MAP_FAILED) {
+ close(fd);
+ perror("mmap failure");
+ FatalError("xf86MapDomainMem(): mmap() failure\n");
+ }
+ }
+
+ close(fd);
+ return (pointer)((char *)DomainMmappedMem[domain] + Base);
+}
+
+/*
+ * xf86MapDomainIO - map I/O space in this domain
+ *
+ * Each domain has a legacy ISA I/O space. This routine will try to
+ * map it using the Linux sysfs legacy_io interface. If that fails,
+ * it'll fall back to using /proc/bus/pci.
+ *
+ * If the legacy_io interface *does* exist, the file descriptor (fd below)
+ * will be saved in the DomainMmappedIO array in the upper bits of the
+ * pointer. Callers will do I/O with small port numbers (<64k values), so
+ * the platform I/O code can extract the port number and the fd, lseek to
+ * the port number in the legacy_io file, and issue the read or write.
+ *
+ * This has no means of returning failure, so all errors are fatal
+ */
+IOADDRESS
+xf86MapDomainIO(int ScreenNum, int Flags, PCITAG Tag,
+ IOADDRESS Base, unsigned long Size)
+{
+ int domain = xf86GetPciDomain(Tag);
+ int fd;
+
+ if ((domain <= 0) || (domain >= MAX_DOMAINS))
+ FatalError("xf86MapDomainIO(): domain out of range\n");
+
+ if (DomainMmappedIO[domain])
+ return (IOADDRESS)DomainMmappedIO[domain] + Base;
+
+ /* Permanently map all of I/O space */
+ if ((fd = linuxOpenLegacy(Tag, "legacy_io")) < 0) {
+ DomainMmappedIO[domain] = linuxMapPci(ScreenNum, Flags, Tag,
+ 0, linuxGetIOSize(Tag),
+ PCIIOC_MMAP_IS_IO);
+ /* ia64 can't mmap legacy IO port space */
+ if (!DomainMmappedIO[domain])
+ return Base;
+ }
+ else { /* legacy_io file exists, encode fd */
+ DomainMmappedIO[domain] = (pointer)(fd << 24);
+ }
+
+ return (IOADDRESS)DomainMmappedIO[domain] + Base;
+}
+
+/*
+ * xf86ReadDomainMemory - copy from domain memory into a caller supplied buffer
+ */
+int
+xf86ReadDomainMemory(PCITAG Tag, ADDRESS Base, int Len, unsigned char *Buf)
+{
+ unsigned char *ptr, *src;
+ ADDRESS offset;
+ unsigned long size;
+ int len, pagemask = getpagesize() - 1;
+
+ unsigned int i, dom, bus, dev, func;
+ unsigned int fd;
+ char file[256];
+ struct stat st;
+
+ dom = PCI_DOM_FROM_TAG(Tag);
+ bus = PCI_BUS_FROM_TAG(Tag);
+ dev = PCI_DEV_FROM_TAG(Tag);
+ func = PCI_FUNC_FROM_TAG(Tag);
+ sprintf(file, "/sys/devices/pci%04x:%02x/%04x:%02x:%02x.%1x/rom",
+ dom, bus, dom, bus, dev, func);
+
+ /*
+ * If the caller wants the ROM and the sysfs rom interface exists,
+ * try to use it instead of reading it from /proc/bus/pci.
+ */
+ if (((Base & 0xfffff) == 0xC0000) && (stat(file, &st) == 0)) {
+ if ((fd = open(file, O_RDWR)))
+ Base = 0x0;
+
+ /* enable the ROM first */
+ write(fd, "1", 2);
+ lseek(fd, 0, SEEK_SET);
+
+ /* copy the ROM until we hit Len, EOF or read error */
+ for (i = 0; i < Len && read(fd, Buf, 1) > 0; Buf++, i++)
+ ;
+
+ write(fd, "0", 2);
+ close(fd);
+
+ return Len;
+ }
+
+ /* Ensure page boundaries */
+ offset = Base & ~pagemask;
+ size = ((Base + Len + pagemask) & ~pagemask) - offset;
+
+ ptr = xf86MapDomainMemory(-1, VIDMEM_READONLY, Tag, offset, size);
+
+ if (!ptr)
+ return -1;
+
+ /* Using memcpy() here can hang the system */
+ src = ptr + (Base - offset);
+ for (len = Len; len-- > 0;)
+ *Buf++ = *src++;
+
+ xf86UnMapVidMem(-1, ptr, size);
+
+ return Len;
+}
+
+resPtr
+xf86BusAccWindowsFromOS(void)
+{
+ pciConfigPtr *ppPCI, pPCI;
+ resPtr pRes = NULL;
+ resRange range;
+ unsigned long io_size, mem_size;
+ int domain;
+
+ if ((ppPCI = xf86scanpci(0))) {
+ for (; (pPCI = *ppPCI); ppPCI++) {
+ if ((pPCI->pci_base_class != PCI_CLASS_BRIDGE) ||
+ (pPCI->pci_sub_class != PCI_SUBCLASS_BRIDGE_HOST))
+ continue;
+
+ domain = xf86GetPciDomain(pPCI->tag);
+ linuxGetSizes(pPCI->tag, &io_size, &mem_size);
+
+ RANGE(range, 0, (ADDRESS)(mem_size - 1),
+ RANGE_TYPE(ResExcMemBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+
+ RANGE(range, 0, (IOADDRESS)(io_size - 1),
+ RANGE_TYPE(ResExcIoBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+
+ if (domain <= 0)
+ break;
+ }
+ }
+
+ return pRes;
+}
+
+resPtr
+xf86PciBusAccWindowsFromOS(void)
+{
+ pciConfigPtr *ppPCI, pPCI;
+ resPtr pRes = NULL;
+ resRange range;
+ unsigned long io_size, mem_size;
+ int domain;
+
+ if ((ppPCI = xf86scanpci(0))) {
+ for (; (pPCI = *ppPCI); ppPCI++) {
+ if ((pPCI->pci_base_class != PCI_CLASS_BRIDGE) ||
+ (pPCI->pci_sub_class != PCI_SUBCLASS_BRIDGE_HOST))
+ continue;
+
+ domain = xf86GetPciDomain(pPCI->tag);
+ linuxGetSizes(pPCI->tag, &io_size, &mem_size);
+
+ RANGE(range, 0, (ADDRESS)(mem_size - 1),
+ RANGE_TYPE(ResExcMemBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+
+ RANGE(range, 0, (IOADDRESS)(io_size - 1),
+ RANGE_TYPE(ResExcIoBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+
+ if (domain <= 0)
+ break;
+ }
+ }
+
+ return pRes;
+}
+
+
+resPtr
+xf86AccResFromOS(resPtr pRes)
+{
+ pciConfigPtr *ppPCI, pPCI;
+ resRange range;
+ unsigned long io_size, mem_size;
+ int domain;
+
+ if ((ppPCI = xf86scanpci(0))) {
+ for (; (pPCI = *ppPCI); ppPCI++) {
+ if ((pPCI->pci_base_class != PCI_CLASS_BRIDGE) ||
+ (pPCI->pci_sub_class != PCI_SUBCLASS_BRIDGE_HOST))
+ continue;
+
+ domain = xf86GetPciDomain(pPCI->tag);
+ linuxGetSizes(pPCI->tag, &io_size, &mem_size);
+
+ /*
+ * At minimum, the top and bottom resources must be claimed, so
+ * that resources that are (or appear to be) unallocated can be
+ * relocated.
+ */
+ RANGE(range, 0x00000000u, 0x0009ffffu,
+ RANGE_TYPE(ResExcMemBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+ RANGE(range, 0x000c0000u, 0x000effffu,
+ RANGE_TYPE(ResExcMemBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+ RANGE(range, 0x000f0000u, 0x000fffffu,
+ RANGE_TYPE(ResExcMemBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+
+ RANGE(range, (ADDRESS)(mem_size - 1), (ADDRESS)(mem_size - 1),
+ RANGE_TYPE(ResExcMemBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+
+ RANGE(range, 0x00000000u, 0x00000000u,
+ RANGE_TYPE(ResExcIoBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+ RANGE(range, (IOADDRESS)(io_size - 1), (IOADDRESS)(io_size - 1),
+ RANGE_TYPE(ResExcIoBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+
+ if (domain <= 0)
+ break;
+ }
+ }
+
+ return pRes;
+}
+
+#endif /* !INCLUDE_XF86_NO_DOMAIN */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/netbsdPci.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/netbsdPci.c
new file mode 100644
index 000000000..7dbbfdec7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/netbsdPci.c
@@ -0,0 +1,132 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/netbsdPci.c,v 1.4 2003/08/24 17:37:04 dawes Exp $ */
+/*
+ * Copyright (C) 1994-2003 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE
+ * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written
+ * authorization from the XFree86 Project.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <dev/pci/pciio.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86OSpriv.h"
+
+#include "Pci.h"
+
+static CARD32 netbsdPciConfRead(PCITAG, int);
+static void netbsdPciConfWrite(PCITAG, int, CARD32);
+static void netbsdPciSetBits(PCITAG, int, CARD32, CARD32);
+
+static int devpci = -1;
+
+static pciBusFuncs_t netbsdFuncs0 = {
+/* pciReadLong */ netbsdPciConfRead,
+/* pciWriteLong */ netbsdPciConfWrite,
+/* pciSetBitsLong */ netbsdPciSetBits,
+/* pciAddrHostToBus */ pciAddrNOOP,
+/* pciAddrBusToHost */ pciAddrNOOP
+};
+
+static pciBusInfo_t netbsdPci0 = {
+/* configMech */ PCI_CFG_MECH_OTHER,
+/* numDevices */ 32,
+/* secondary */ FALSE,
+/* primary_bus */ 0,
+/* funcs */ &netbsdFuncs0,
+/* pciBusPriv */ NULL,
+/* bridge */ NULL
+};
+
+void
+netbsdPciInit()
+{
+ struct pciio_businfo pci_businfo;
+
+ devpci = open("/dev/pci0", O_RDWR);
+ if (devpci == -1)
+ FatalError("netbsdPciInit: can't open /dev/pci0\n");
+
+ pciNumBuses = 1;
+ pciBusInfo[0] = &netbsdPci0;
+ pciFindFirstFP = pciGenFindFirst;
+ pciFindNextFP = pciGenFindNext;
+ /* use businfo to get the number of devs */
+ if (ioctl(devpci, PCI_IOC_BUSINFO, &pci_businfo) != 0)
+ FatalError("netbsdPciInit: not a PCI bus device");
+ netbsdPci0.numDevices = pci_businfo.maxdevs;
+}
+
+static CARD32
+netbsdPciConfRead(PCITAG tag, int reg)
+{
+ struct pciio_bdf_cfgreg bdfr;
+
+ bdfr.bus = PCI_BUS_FROM_TAG(tag);
+ bdfr.device = PCI_DEV_FROM_TAG(tag);
+ bdfr.function = PCI_FUNC_FROM_TAG(tag);
+ bdfr.cfgreg.reg = reg;
+
+ if (ioctl(devpci, PCI_IOC_BDF_CFGREAD, &bdfr) == -1)
+ FatalError("netbsdPciConfRead: failed on %d/%d/%d\n",
+ bdfr.bus, bdfr.device, bdfr.function);
+
+ return (bdfr.cfgreg.val);
+}
+
+static void
+netbsdPciConfWrite(PCITAG tag, int reg, CARD32 val)
+{
+ struct pciio_bdf_cfgreg bdfr;
+
+ bdfr.bus = PCI_BUS_FROM_TAG(tag);
+ bdfr.device = PCI_DEV_FROM_TAG(tag);
+ bdfr.function = PCI_FUNC_FROM_TAG(tag);
+ bdfr.cfgreg.reg = reg;
+ bdfr.cfgreg.val = val;
+
+ if (ioctl(devpci, PCI_IOC_BDF_CFGWRITE, &bdfr) == -1)
+ FatalError("netbsdPciConfWrite: failed on %d/%d/%d\n",
+ bdfr.bus, bdfr.device, bdfr.function);
+}
+
+static void
+netbsdPciSetBits(PCITAG tag, int reg, CARD32 mask, CARD32 bits)
+{
+ CARD32 val;
+
+ val = netbsdPciConfRead(tag, reg);
+ val = (val & ~mask) | (bits & mask);
+ netbsdPciConfWrite(tag, reg, val);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/ppcPci.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/ppcPci.c
new file mode 100644
index 000000000..7a438af67
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/ppcPci.c
@@ -0,0 +1,311 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/ppcPci.c,v 1.8 2002/07/24 19:06:52 tsi Exp $ */
+/*
+ * ppcPci.c - PowerPC PCI access functions
+ *
+ * PCI driver functions supporting Motorola PowerPC platforms
+ * including Powerstack(RiscPC/RiscPC+), PowerStackII, MTX, and
+ * MVME 160x/260x/360x/460x VME boards
+ *
+ * Gary Barton
+ * Concurrent Computer Corporation
+ * garyb@gate.net
+ *
+ */
+
+/*
+ * Copyright 1998 by Concurrent Computer Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Concurrent Computer
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Concurrent Computer Corporation makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Copyright 1998 by Metro Link Incorporated
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include "compiler.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "Pci.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED (pointer)(-1)
+#endif
+
+void
+ppcPciInit()
+{
+#if defined(PowerMAX_OS)
+ extern void pmaxPciInit(void);
+
+ pmaxPciInit();
+
+#else
+
+ static void motoppcPciInit(void);
+ motoppcPciInit();
+
+#endif
+}
+
+#if defined(PowerMAX_OS)
+
+/*
+ * Motorola PowerPC platform support
+ *
+ * The following code should support the MVME 1600 & 2600 VME boards
+ * as well as the various PowerStack and RiscPC models. All of these
+ * machines support PCI config mechanism #1 and use the std config
+ * address and data regs locations:
+ * cfg address reg = 0xcf8 (PCI I/O)
+ * cfg data reg = 0xcfc (PCI I/O)
+ *
+ * The moto machines do have different address maps on either side
+ * of the PCI-host bridge though.
+ */
+static ADDRESS motoppcBusAddrToHostAddr(PCITAG, PciAddrType, ADDRESS);
+static ADDRESS motoppcHostAddrToBusAddr(PCITAG, PciAddrType, ADDRESS);
+static CARD32 pciCfgMech1Read(PCITAG tag, int offset);
+static void pciCfgMech1Write(PCITAG tag, int offset, CARD32 val);
+static void pciCfgMech1SetBits(PCITAG tag, int offset,
+ CARD32 mask, CARD32 val);
+
+
+static pciBusFuncs_t motoppcFuncs0 = {
+/* pciReadLong */ pciCfgMech1Read,
+/* pciWriteLong */ pciCfgMech1Write,
+/* pciSetBitsLong */ pciCfgMech1SetBits,
+/* pciAddrHostToBus */ motoppcHostAddrToBusAddr,
+/* pciAddrBusToHost */ motoppcBusAddrToHostAddr
+};
+
+static pciBusInfo_t motoppcPci0 = {
+/* configMech */ PCI_CFG_MECH_1,
+/* numDevices */ 32,
+/* secondary */ FALSE,
+/* primary_bus */ 0,
+#ifdef PowerMAX_OS
+/* ppc_io_base */ 0x80000000,
+/* ppc_io_size */ 64 * 1024,
+#endif
+/* funcs */ &motoppcFuncs0,
+/* pciBusPriv */ NULL,
+/* bridge */ NULL
+};
+
+extern volatile unsigned char *ioBase;
+
+static void
+motoppcPciInit()
+{
+ pciNumBuses = 1;
+ pciBusInfo[0] = &motoppcPci0;
+ pciFindFirstFP = pciGenFindFirst;
+ pciFindNextFP = pciGenFindNext;
+
+ if (!xf86EnableIO())
+ FatalError("motoppcPciInit: EnableIO failed\n");
+
+ if (ioBase == MAP_FAILED) {
+ ppcPciIoMap(0); /* Make inb/outb et al work for pci0 and its secondaries */
+
+ if (ioBase == MAP_FAILED) {
+ FatalError("motoppcPciInit: Cannot map pci0 I/O segment!!!\n");
+ /*NOTREACHED*/
+ }
+ }
+}
+
+extern unsigned long motoPciMemBase = 0;
+
+#if defined(Lynx) && defined(__powerpc__)
+extern unsigned long motoPciMemLen = 0x40000000;
+#else
+extern unsigned long motoPciMemLen = 0x3f000000;
+#endif
+
+extern unsigned long motoPciMemBaseCPU = 0xc0000000;
+
+static ADDRESS
+motoppcBusAddrToHostAddr(PCITAG tag, PciAddrType type, ADDRESS addr)
+{
+ unsigned long addr_l = (unsigned long)addr;
+
+ if (type == PCI_MEM) {
+ if (addr_l >= motoPciMemBase && addr_l < motoPciMemLen)
+ /*
+ * PCI memory space addresses [0-0x3effffff] are
+ * are seen at [0xc0000000,0xfeffffff] on moto host
+ */
+ return((ADDRESS)((motoPciMemBaseCPU - motoPciMemBase) + addr_l));
+
+ else if (addr_l >= 0x80000000)
+ /*
+ * Moto host memory [0,0x7fffffff] is seen at
+ * [0x80000000,0xffffffff] on PCI bus
+ */
+ return((ADDRESS)(addr_l & 0x7fffffff));
+ else
+ FatalError("motoppcBusAddrToHostAddr: PCI addr 0x%x is not accessible to host!!!\n",
+ addr_l);
+ } else
+ return addr;
+
+ /*NOTREACHED*/
+}
+
+static ADDRESS
+motoppcHostAddrToBusAddr(PCITAG tag, PciAddrType type, ADDRESS addr)
+{
+ unsigned long addr_l = (unsigned long)addr;
+
+ if (type == PCI_MEM) {
+ if (addr_l < 0x80000000)
+ /*
+ * Moto host memory [0,0x7fffffff] is seen at
+ * [0x80000000,0xffffffff] on PCI bus
+ */
+ return((ADDRESS)(0x80000000 | addr_l));
+
+ else if (addr_l >= motoPciMemBaseCPU && addr_l < motoPciMemBaseCPU + motoPciMemLen)
+ /*
+ * PCI memory space addresses [0-0x3effffff] are
+ * are seen at [0xc0000000,0xfeffffff] on moto host
+ */
+ return((ADDRESS)(addr_l - (motoPciMemBaseCPU - motoPciMemBase)));
+
+ else
+ FatalError("motoppcHostAddrToBusAddr: Host addr 0x%x is not accessible to PCI!!!\n",
+ addr_l);
+ } else
+ return addr;
+
+ /*NOTREACHED*/
+}
+
+#if defined (__powerpc__)
+static int buserr_detected;
+
+static
+void buserr(int sig)
+{
+ buserr_detected = 1;
+}
+#endif
+
+static CARD32
+pciCfgMech1Read(PCITAG tag, int offset)
+{
+ unsigned long rv = 0xffffffff;
+#ifdef DEBUGPCI
+ ErrorF("pciCfgMech1Read(tag=%08x,offset=%08x)\n", tag, offset);
+#endif
+
+#if defined(__powerpc__)
+ signal(SIGBUS, buserr);
+ buserr_detected = 0;
+#endif
+
+ outl(0xCF8, PCI_EN | tag | (offset & 0xfc));
+ rv = inl(0xCFC);
+
+#if defined(__powerpc__)
+ signal(SIGBUS, SIG_DFL);
+ if (buserr_detected)
+ {
+#ifdef DEBUGPCI
+ ErrorF("pciCfgMech1Read() BUS ERROR\n");
+#endif
+ return(0xffffffff);
+ }
+ else
+#endif
+ return(rv);
+}
+
+static void
+pciCfgMech1Write(PCITAG tag, int offset, CARD32 val)
+{
+#ifdef DEBUGPCI
+ ErrorF("pciCfgMech1Write(tag=%08x,offset=%08x,val=%08x)\n",
+ tag, offset,val);
+#endif
+
+#if defined(__powerpc__)
+ signal(SIGBUS, SIG_IGN);
+#endif
+
+ outl(0xCF8, PCI_EN | tag | (offset & 0xfc));
+#if defined(Lynx) && defined(__powerpc__)
+ outb(0x80, 0x00); /* without this the next access fails
+ * on my Powerstack system when we use
+ * assembler inlines for outl */
+#endif
+ outl(0xCFC, val);
+
+#if defined(__powerpc__)
+ signal(SIGBUS, SIG_DFL);
+#endif
+}
+
+static void
+pciCfgMech1SetBits(PCITAG tag, int offset, CARD32 mask, CARD32 val)
+{
+ unsigned long rv = 0xffffffff;
+
+#if defined(__powerpc__)
+ signal(SIGBUS, buserr);
+#endif
+
+ outl(0xCF8, PCI_EN | tag | (offset & 0xfc));
+ rv = inl(0xCFC);
+ rv = (rv & ~mask) | val;
+ outl(0xCFC, rv);
+
+#if defined(__powerpc__)
+ signal(SIGBUS, SIG_DFL);
+#endif
+}
+
+#endif /* PowerMAX_OS */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c
new file mode 100644
index 000000000..48e10ede4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c
@@ -0,0 +1,1052 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c,v 1.14 2003/08/24 17:37:04 dawes Exp $ */
+/*
+ * Copyright (C) 2001-2003 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "Pci.h"
+#include "xf86sbusBus.h"
+
+#if defined(sun)
+
+extern char *apertureDevName;
+static int apertureFd = -1;
+
+/*
+ * A version of xf86MapVidMem() that allows for 64-bit displacements (but not
+ * sizes). Areas thus mapped can be unmapped by xf86UnMapVidMem().
+ */
+static pointer
+sparcMapAperture(int iScreen, int Flags,
+ unsigned long long Base, unsigned long Size)
+{
+ pointer result;
+ static int lastFlags = 0;
+
+ /* Assume both Base & Size are multiples of the page size */
+
+ if ((apertureFd < 0) || (Flags != lastFlags)) {
+ if (apertureFd >= 0)
+ close(apertureFd);
+ lastFlags = Flags;
+ apertureFd = open(apertureDevName,
+ (Flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
+ if (apertureFd < 0)
+ FatalError("sparcMapAperture: open failure: %s\n",
+ strerror(errno));
+ }
+
+ result = mmap(NULL, Size,
+ (Flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_SHARED, apertureFd, (off_t)Base);
+
+ if (result == MAP_FAILED)
+ FatalError("sparcMapAperture: mmap failure: %s\n", strerror(errno));
+
+ return result;
+}
+
+/*
+ * Platform-specific bus privates.
+ */
+typedef struct _sparcDomainRec {
+ unsigned long long io_addr, io_size;
+ unsigned long long mem_addr, mem_size;
+ pointer pci, io;
+ int bus_min, bus_max;
+ unsigned char dfn_mask[256 / 8];
+} sparcDomainRec, *sparcDomainPtr;
+
+#define SetBitInMap(bit, map) \
+ do { \
+ int _bit = (bit); \
+ (map)[_bit >> 3] |= 1 << (_bit & 7); \
+ } while (0)
+
+#define IsBitSetInMap(bit, map) \
+ ((map)[(bit) >> 3] & (1 << ((bit) & 7)))
+
+/*
+ * Domain 0 is reserved for the one that represents the system as a whole, i.e.
+ * the one without any resource relocations.
+ */
+#define MAX_DOMAINS (MAX_PCI_BUSES / 256)
+static sparcDomainPtr xf86DomainInfo[MAX_DOMAINS];
+static int pciNumDomains = 1;
+
+/* Variables that are assigned this must be declared volatile */
+#define PciReg(base, tag, off, type) \
+ *(volatile type *)(pointer)((char *)(base) + \
+ (PCI_TAG_NO_DOMAIN(tag) | (off)))
+
+/* Generic SPARC PCI access functions */
+static CARD32
+sparcPciCfgRead32(PCITAG tag, int off)
+{
+ pciBusInfo_t *pBusInfo;
+ sparcDomainPtr pDomain;
+ volatile CARD32 result = (CARD32)(-1); /* Must be volatile */
+ int bus;
+
+ if ((off >= 0) && (off <= 252) && !(off & 3) &&
+ ((bus = PCI_BUS_FROM_TAG(tag)) < pciNumBuses) &&
+ (pBusInfo = pciBusInfo[bus]) && (pDomain = pBusInfo->pciBusPriv) &&
+ (bus >= pDomain->bus_min) && (bus < pDomain->bus_max) &&
+ ((bus > pDomain->bus_min) ||
+ IsBitSetInMap(PCI_DFN_FROM_TAG(tag), pDomain->dfn_mask))) {
+ result = PciReg(pDomain->pci, tag, off, CARD32);
+
+ result = PCI_CPU(result);
+ }
+
+ return result;
+}
+
+static void
+sparcPciCfgWrite32(PCITAG tag, int off, CARD32 val)
+{
+ pciBusInfo_t *pBusInfo;
+ sparcDomainPtr pDomain;
+ int bus;
+
+ if ((off < 0) || (off > 252) || (off & 3) ||
+ ((bus = PCI_BUS_FROM_TAG(tag)) >= pciNumBuses) ||
+ !(pBusInfo = pciBusInfo[bus]) || !(pDomain = pBusInfo->pciBusPriv) ||
+ (bus < pDomain->bus_min) || (bus >= pDomain->bus_max) ||
+ ((bus == pDomain->bus_min) &&
+ !IsBitSetInMap(PCI_DFN_FROM_TAG(tag), pDomain->dfn_mask)))
+ return;
+
+ val = PCI_CPU(val);
+ PciReg(pDomain->pci, tag, off, CARD32) = val;
+}
+
+static void
+sparcPciCfgSetBits32(PCITAG tag, int off, CARD32 mask, CARD32 bits)
+{
+ CARD32 PciVal;
+
+ PciVal = sparcPciCfgRead32(tag, off);
+ PciVal &= ~mask;
+ PciVal |= bits;
+ sparcPciCfgWrite32(tag, off, PciVal);
+}
+
+static pciBusFuncs_t sparcPCIFunctions =
+{
+ sparcPciCfgRead32,
+ sparcPciCfgWrite32,
+ sparcPciCfgSetBits32,
+ pciAddrNOOP,
+ pciAddrNOOP
+};
+
+/*
+ * Sabre-specific versions of the above because of its peculiar access size
+ * requirements.
+ */
+static CARD32
+sabrePciCfgRead32(PCITAG tag, int off)
+{
+ pciBusInfo_t *pBusInfo;
+ sparcDomainPtr pDomain;
+ volatile CARD32 result; /* Must be volatile */
+ int bus;
+
+ if (PCI_BDEV_FROM_TAG(tag))
+ return sparcPciCfgRead32(tag, off);
+
+ if (PCI_FUNC_FROM_TAG(tag) || (off < 0) || (off > 252) || (off & 3) ||
+ ((bus = PCI_BUS_FROM_TAG(tag)) >= pciNumBuses) ||
+ !(pBusInfo = pciBusInfo[bus]) || !(pDomain = pBusInfo->pciBusPriv) ||
+ (bus != pDomain->bus_min))
+ return (CARD32)(-1);
+
+ if (off < 8) {
+ result = (PciReg(pDomain->pci, tag, off, CARD16) << 16) |
+ PciReg(pDomain->pci, tag, off + 2, CARD16);
+ return PCI_CPU(result);
+ }
+
+ result = (PciReg(pDomain->pci, tag, off + 3, CARD8) << 24) |
+ (PciReg(pDomain->pci, tag, off + 2, CARD8) << 16) |
+ (PciReg(pDomain->pci, tag, off + 1, CARD8) << 8) |
+ (PciReg(pDomain->pci, tag, off , CARD8) );
+ return result;
+}
+
+static void
+sabrePciCfgWrite32(PCITAG tag, int off, CARD32 val)
+{
+ pciBusInfo_t *pBusInfo;
+ sparcDomainPtr pDomain;
+ int bus;
+
+ if (PCI_BDEV_FROM_TAG(tag))
+ sparcPciCfgWrite32(tag, off, val);
+ else if (!PCI_FUNC_FROM_TAG(tag) &&
+ (off >= 0) && (off <= 252) && !(off & 3) &&
+ ((bus = PCI_BUS_FROM_TAG(tag)) < pciNumBuses) &&
+ (pBusInfo = pciBusInfo[bus]) &&
+ (pDomain = pBusInfo->pciBusPriv) &&
+ (bus == pDomain->bus_min)) {
+ if (off < 8) {
+ val = PCI_CPU(val);
+ PciReg(pDomain->pci, tag, off , CARD16) = val >> 16;
+ PciReg(pDomain->pci, tag, off + 2, CARD16) = val;
+ } else {
+ PciReg(pDomain->pci, tag, off , CARD8) = val;
+ PciReg(pDomain->pci, tag, off + 1, CARD8) = val >> 8;
+ PciReg(pDomain->pci, tag, off + 2, CARD8) = val >> 16;
+ PciReg(pDomain->pci, tag, off + 3, CARD8) = val >> 24;
+ }
+ }
+}
+
+static void
+sabrePciCfgSetBits32(PCITAG tag, int off, CARD32 mask, CARD32 bits)
+{
+ CARD32 PciVal;
+
+ PciVal = sabrePciCfgRead32(tag, off);
+ PciVal &= ~mask;
+ PciVal |= bits;
+ sabrePciCfgWrite32(tag, off, PciVal);
+}
+
+static pciBusFuncs_t sabrePCIFunctions =
+{
+ sabrePciCfgRead32,
+ sabrePciCfgWrite32,
+ sabrePciCfgSetBits32,
+ pciAddrNOOP,
+ pciAddrNOOP
+};
+
+static int pagemask;
+
+/* Scan PROM for all PCI host bridges in the system */
+void
+sparcPciInit(void)
+{
+ int node, node2;
+
+ if (!xf86LinearVidMem())
+ return;
+
+ apertureFd = open(apertureDevName, O_RDWR);
+ if (apertureFd < 0) {
+ xf86Msg(X_ERROR,
+ "sparcPciInit: open failure: %s\n", strerror(errno));
+ return;
+ }
+
+ sparcPromInit();
+ pagemask = xf86getpagesize() - 1;
+
+ for (node = promGetChild(promRootNode);
+ node;
+ node = promGetSibling(node)) {
+ unsigned long long pci_addr;
+ sparcDomainRec domain;
+ sparcDomainPtr pDomain;
+ pciBusFuncs_p pFunctions;
+ char *prop_val;
+ int prop_len, bus;
+
+ prop_val = promGetProperty("name", &prop_len);
+ /* Some PROMs include the trailing null; some don't */
+ if (!prop_val || (prop_len < 3) || (prop_len > 4) ||
+ strcmp(prop_val, "pci"))
+ continue;
+
+ prop_val = promGetProperty("model", &prop_len);
+ if (!prop_val || (prop_len <= 0)) {
+ prop_val = promGetProperty("compatible", &prop_len);
+ if (!prop_val || (prop_len <= 0))
+ continue;
+ }
+
+ pFunctions = &sparcPCIFunctions;
+ (void)memset(&domain, 0, sizeof(domain));
+
+ if (!strncmp("SUNW,sabre", prop_val, prop_len) ||
+ !strncmp("pci108e,a000", prop_val, prop_len) ||
+ !strncmp("pci108e,a001", prop_val, prop_len)) {
+ /*
+ * There can only be one "Sabre" bridge in a system. It provides
+ * PCI configuration space, a 24-bit I/O space and a 32-bit memory
+ * space, all three of which are at fixed physical CPU addresses.
+ */
+ static Bool sabre_seen = FALSE;
+
+ xf86Msg(X_INFO,
+ "Sabre or Hummingbird PCI host bridge found (\"%s\")\n",
+ prop_val);
+
+ /* There can only be one Sabre */
+ if (sabre_seen)
+ continue;
+ sabre_seen = TRUE;
+
+ /* Get "bus-range" property */
+ prop_val = promGetProperty("bus-range", &prop_len);
+ if (!prop_val || (prop_len != 8) ||
+ (((unsigned int *)prop_val)[0]) ||
+ (((unsigned int *)prop_val)[1] >= 256))
+ continue;
+
+ pci_addr = 0x01fe01000000ull;
+ domain.io_addr = 0x01fe02000000ull;
+ domain.io_size = 0x000001000000ull;
+ domain.mem_addr = 0x01ff00000000ull;
+ domain.mem_size = 0x000100000000ull;
+ domain.bus_min = 0; /* Always */
+ domain.bus_max = ((int *)prop_val)[1];
+
+ pFunctions = &sabrePCIFunctions;
+ } else
+ if (!strncmp("SUNW,psycho", prop_val, prop_len) ||
+ !strncmp("pci108e,8000", prop_val, prop_len)) {
+ /*
+ * A "Psycho" host bridge provides two PCI interfaces, each with
+ * its own 16-bit I/O and 31-bit memory spaces. Both share the
+ * same PCI configuration space. Here, they are assigned separate
+ * domain numbers to prevent unintentional I/O and/or memory
+ * resource conflicts.
+ */
+ xf86Msg(X_INFO,
+ "Psycho PCI host bridge found (\"%s\")\n", prop_val);
+
+ /* Get "bus-range" property */
+ prop_val = promGetProperty("bus-range", &prop_len);
+ if (!prop_val || (prop_len != 8) ||
+ (((unsigned int *)prop_val)[1] >= 256) ||
+ (((unsigned int *)prop_val)[0] > ((unsigned int *)prop_val)[1]))
+ continue;
+
+ domain.bus_min = ((int *)prop_val)[0];
+ domain.bus_max = ((int *)prop_val)[1];
+
+ /* Get "ranges" property */
+ prop_val = promGetProperty("ranges", &prop_len);
+ if (!prop_val || (prop_len != 112) ||
+ prop_val[0] || (prop_val[28] != 0x01u) ||
+ (prop_val[56] != 0x02u) || (prop_val[84] != 0x03u) ||
+ (((unsigned int *)prop_val)[4] != 0x01000000u) ||
+ ((unsigned int *)prop_val)[5] ||
+ ((unsigned int *)prop_val)[12] ||
+ (((unsigned int *)prop_val)[13] != 0x00010000u) ||
+ ((unsigned int *)prop_val)[19] ||
+ (((unsigned int *)prop_val)[20] != 0x80000000u) ||
+ ((((unsigned int *)prop_val)[11] & ~0x00010000u) !=
+ 0x02000000u) ||
+ (((unsigned int *)prop_val)[18] & ~0x80000000u) ||
+ (((unsigned int *)prop_val)[3] !=
+ ((unsigned int *)prop_val)[10]) ||
+ (((unsigned int *)prop_val)[17] !=
+ ((unsigned int *)prop_val)[24]) ||
+ (((unsigned int *)prop_val)[18] !=
+ ((unsigned int *)prop_val)[25]) ||
+ (((unsigned int *)prop_val)[19] !=
+ ((unsigned int *)prop_val)[26]) ||
+ (((unsigned int *)prop_val)[20] !=
+ ((unsigned int *)prop_val)[27]))
+ continue;
+
+ /* Use memcpy() to avoid alignment issues */
+ (void)memcpy(&pci_addr, prop_val + 12,
+ sizeof(pci_addr));
+ (void)memcpy(&domain.io_addr, prop_val + 40,
+ sizeof(domain.io_addr));
+ (void)memcpy(&domain.mem_addr, prop_val + 68,
+ sizeof(domain.mem_addr));
+
+ domain.io_size = 0x000000010000ull;
+ domain.mem_size = 0x000080000000ull;
+ } else
+ if (!strncmp("SUNW,schizo", prop_val, prop_len) ||
+ !strncmp("pci108e,8001", prop_val, prop_len)) {
+ /*
+ * I have no docs on the "Schizo", but judging from the Linux
+ * kernel, it also provides two PCI domains. Each PCI
+ * configuration space is the usual 16M in size, followed by a
+ * variable-length I/O space. Each domain also provides a
+ * variable-length memory space. The kernel seems to think the I/O
+ * spaces are 16M long, and the memory spaces, 2G, but these
+ * assumptions are actually only present in source code comments.
+ * Sun has, however, confirmed to me the validity of these
+ * assumptions.
+ */
+ volatile unsigned long long mem_match, mem_mask, io_match, io_mask;
+ unsigned long Offset;
+ pointer pSchizo;
+
+ xf86Msg(X_INFO,
+ "Schizo PCI host bridge found (\"%s\")\n", prop_val);
+
+ /* Get "bus-range" property */
+ prop_val = promGetProperty("bus-range", &prop_len);
+ if (!prop_val || (prop_len != 8) ||
+ (((unsigned int *)prop_val)[1] >= 256) ||
+ (((unsigned int *)prop_val)[0] > ((unsigned int *)prop_val)[1]))
+ continue;
+
+ domain.bus_min = ((int *)prop_val)[0];
+ domain.bus_max = ((int *)prop_val)[1];
+
+ /* Get "reg" property */
+ prop_val = promGetProperty("reg", &prop_len);
+ if (!prop_val || (prop_len != 48))
+ continue;
+
+ /* Temporarily map some of Schizo's registers */
+ pSchizo = sparcMapAperture(-1, VIDMEM_MMIO,
+ ((unsigned long long *)prop_val)[2] - 0x000000010000ull,
+ 0x00010000ul);
+
+ /* Determine where PCI config, I/O and memory spaces reside */
+ if ((((unsigned long long *)prop_val)[0] & 0x000000700000ull) ==
+ 0x000000600000ull)
+ Offset = 0x0040;
+ else
+ Offset = 0x0060;
+
+ mem_match = PciReg(pSchizo, 0, Offset, unsigned long long);
+ mem_mask = PciReg(pSchizo, 0, Offset + 8, unsigned long long);
+ io_match = PciReg(pSchizo, 0, Offset + 16, unsigned long long);
+ io_mask = PciReg(pSchizo, 0, Offset + 24, unsigned long long);
+
+ /* Unmap Schizo registers */
+ xf86UnMapVidMem(-1, pSchizo, 0x00010000ul);
+
+ /* Calculate sizes */
+ mem_mask = (((mem_mask - 1) ^ mem_mask) >> 1) + 1;
+ io_mask = (((io_mask - 1) ^ io_mask ) >> 1) + 1;
+
+ if (io_mask <= 0x000001000000ull) /* Nothing left for I/O */
+ continue;
+
+ domain.mem_addr = mem_match & ~0x8000000000000000ull;
+ domain.mem_size = mem_mask;
+ pci_addr = io_match & ~0x8000000000000000ull;
+ domain.io_addr = pci_addr + 0x0000000001000000ull;
+ domain.io_size = io_mask - 0x0000000001000000ull;
+ } else {
+ xf86Msg(X_WARNING, "Unknown PCI host bridge: \"%s\"\n", prop_val);
+ continue;
+ }
+
+ /* Only map as much PCI configuration as we need */
+ domain.pci = (char *)sparcMapAperture(-1, VIDMEM_MMIO,
+ pci_addr + PCI_MAKE_TAG(domain.bus_min, 0, 0),
+ PCI_MAKE_TAG(domain.bus_max - domain.bus_min + 1, 0, 0)) -
+ PCI_MAKE_TAG(domain.bus_min, 0, 0);
+
+ /* Allocate a domain record */
+ pDomain = xnfalloc(sizeof(sparcDomainRec));
+ *pDomain = domain;
+
+ /*
+ * Allocate and prime pciBusInfo records. These are allocated one at a
+ * time because those for empty buses are eventually released.
+ */
+ bus = pDomain->bus_min =
+ PCI_MAKE_BUS(pciNumDomains, domain.bus_min);
+ pciNumBuses = pDomain->bus_max =
+ PCI_MAKE_BUS(pciNumDomains, domain.bus_max) + 1;
+
+ pciBusInfo[bus] = xnfcalloc(1, sizeof(pciBusInfo_t));
+ pciBusInfo[bus]->configMech = PCI_CFG_MECH_OTHER;
+ pciBusInfo[bus]->numDevices = 32;
+ pciBusInfo[bus]->funcs = pFunctions;
+ pciBusInfo[bus]->pciBusPriv = pDomain;
+ while (++bus < pciNumBuses) {
+ pciBusInfo[bus] = xnfalloc(sizeof(pciBusInfo_t));
+ *(pciBusInfo[bus]) = *(pciBusInfo[bus - 1]);
+ pciBusInfo[bus]->funcs = &sparcPCIFunctions;
+ }
+
+ /* Next domain, please... */
+ xf86DomainInfo[pciNumDomains++] = pDomain;
+
+ /*
+ * OK, enough of the straight-forward stuff. Time to deal with some
+ * brokenness...
+ *
+ * The PCI specs require that when a bus transaction remains unclaimed
+ * for too long, the master entity on that bus is to cancel the
+ * transaction it issued or passed on with a master abort. Two
+ * outcomes are possible:
+ *
+ * - the master abort can be treated as an error that is propogated
+ * back through the bus tree to the entity that ultimately originated
+ * the transaction; or
+ * - the transaction can be allowed to complete normally, which means
+ * that writes are ignored and reads return all ones.
+ *
+ * In the first case, if the CPU happens to be at the tail end of the
+ * tree path through one of its host bridges, it will be told there is
+ * a hardware mal-function, despite being generated by software.
+ *
+ * For a software function (be it firmware, OS or userland application)
+ * to determine how a PCI bus tree is populated, it must be able to
+ * detect when master aborts occur. Obviously, PCI discovery is much
+ * simpler when master aborts are allowed to complete normally.
+ *
+ * Unfortunately, a number of non-Intel PCI implementations have chosen
+ * to treat master aborts as severe errors. The net effect is to
+ * cripple PCI discovery algorithms in userland.
+ *
+ * On SPARCs, master aborts cause a number of different behaviours,
+ * including delivering a signal to the userland application, rebooting
+ * the system, "dropping down" to firmware, or, worst of all, bus
+ * lockouts. Even in the first case, the SIGBUS signal that is
+ * eventually generated isn't delivered in a timely enough fashion to
+ * allow an application to reliably detect the master abort that
+ * ultimately caused it.
+ *
+ * This can be somewhat mitigated. On all architectures, master aborts
+ * that occur on secondary buses can be forced to complete normally
+ * because the PCI-to-PCI bridges that serve them are governed by an
+ * industry-wide specification. (This is just another way of saying
+ * that whatever justification there might be for erroring out master
+ * aborts is deemed by the industry as insufficient to generate more
+ * PCI non-compliance than there already is...)
+ *
+ * This leaves us with master aborts that occur on primary buses.
+ * There is no specification for host-to-PCI bridges. Bridges used in
+ * SPARCs can be told to ignore all PCI errors, but not specifically
+ * master aborts. Not only is this too coarse-grained, but
+ * master-aborted read transactions on the primary bus end up returning
+ * garbage rather than all ones.
+ *
+ * I have elected to work around this the only way I can think of doing
+ * so right now. The following scans an additional PROM level and
+ * builds a device/function map for the primary bus. I can only hope
+ * this PROM information represents all devices on the primary bus,
+ * rather than only a subset of them.
+ *
+ * Master aborts are useful in other ways too, that are not addressed
+ * here. These include determining whether or not a domain provides
+ * VGA, or if a PCI device actually implements PCI disablement.
+ *
+ * --- TSI @ UQV 2001.09.19
+ */
+ for (node2 = promGetChild(node);
+ node2;
+ node2 = promGetSibling(node2)) {
+ /* Get "reg" property */
+ prop_val = promGetProperty("reg", &prop_len);
+ if (!prop_val || (prop_len % 20))
+ continue;
+
+ /*
+ * It's unnecessary to scan the entire "reg" property, but I'll do
+ * so anyway.
+ */
+ prop_len /= 20;
+ for (; prop_len--; prop_val += 20)
+ SetBitInMap(PCI_DFN_FROM_TAG(*(PCITAG *)prop_val),
+ pDomain->dfn_mask);
+ }
+
+ /* Assume the host bridge is device 0, function 0 on its bus */
+ SetBitInMap(0, pDomain->dfn_mask);
+ }
+
+ sparcPromClose();
+
+ close(apertureFd);
+ apertureFd = -1;
+}
+
+#ifndef INCLUDE_XF86_NO_DOMAIN
+
+int
+xf86GetPciDomain(PCITAG Tag)
+{
+ return PCI_DOM_FROM_TAG(Tag);
+}
+
+pointer
+xf86MapDomainMemory(int ScreenNum, int Flags, PCITAG Tag,
+ ADDRESS Base, unsigned long Size)
+{
+ sparcDomainPtr pDomain;
+ pointer result;
+ int domain = PCI_DOM_FROM_TAG(Tag);
+
+ if ((domain <= 0) || (domain >= pciNumDomains) ||
+ !(pDomain = xf86DomainInfo[domain]) ||
+ (((unsigned long long)Base + (unsigned long long)Size) >
+ pDomain->mem_size))
+ FatalError("xf86MapDomainMemory() called with invalid parameters.\n");
+
+ result = sparcMapAperture(ScreenNum, Flags, pDomain->mem_addr + Base, Size);
+
+ if (apertureFd >= 0) {
+ close(apertureFd);
+ apertureFd = -1;
+ }
+
+ return result;
+}
+
+IOADDRESS
+xf86MapDomainIO(int ScreenNum, int Flags, PCITAG Tag,
+ IOADDRESS Base, unsigned long Size)
+{
+ sparcDomainPtr pDomain;
+ int domain = PCI_DOM_FROM_TAG(Tag);
+
+ if ((domain <= 0) || (domain >= pciNumDomains) ||
+ !(pDomain = xf86DomainInfo[domain]) ||
+ (((unsigned long long)Base + (unsigned long long)Size) >
+ pDomain->io_size))
+ FatalError("xf86MapDomainIO() called with invalid parameters.\n");
+
+ /* Permanently map all of I/O space */
+ if (!pDomain->io) {
+ pDomain->io = sparcMapAperture(ScreenNum, Flags,
+ pDomain->io_addr, pDomain->io_size);
+
+ if (apertureFd >= 0) {
+ close(apertureFd);
+ apertureFd = -1;
+ }
+ }
+
+ return (IOADDRESS)pDomain->io + Base;
+}
+
+int
+xf86ReadDomainMemory(PCITAG Tag, ADDRESS Base, int Len, unsigned char *Buf)
+{
+ unsigned char *ptr, *src;
+ ADDRESS offset;
+ unsigned long size;
+ int len;
+
+ /* Ensure page boundaries */
+ offset = Base & ~pagemask;
+ size = ((Base + Len + pagemask) & ~pagemask) - offset;
+
+ ptr = xf86MapDomainMemory(-1, VIDMEM_READONLY, Tag, offset, size);
+
+ /* Using memcpy() here hangs the system */
+ src = ptr + (Base - offset);
+ for (len = Len; len-- > 0;)
+ *Buf++ = *src++;
+
+ xf86UnMapVidMem(-1, ptr, size);
+
+ return Len;
+}
+
+resPtr
+xf86BusAccWindowsFromOS(void)
+{
+ sparcDomainPtr pDomain;
+ resPtr pRes = NULL;
+ resRange range;
+ int domain;
+
+ for (domain = 1; domain < pciNumDomains; domain++) {
+ if (!(pDomain = xf86DomainInfo[domain]))
+ continue;
+
+ RANGE(range, 0, pDomain->mem_size - 1,
+ RANGE_TYPE(ResExcMemBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+
+ RANGE(range, 0, pDomain->io_size - 1,
+ RANGE_TYPE(ResExcIoBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+ }
+
+ return pRes;
+}
+
+resPtr
+xf86PciBusAccWindowsFromOS(void)
+{
+ sparcDomainPtr pDomain;
+ resPtr pRes = NULL;
+ resRange range;
+ int domain;
+
+ for (domain = 1; domain < pciNumDomains; domain++) {
+ if (!(pDomain = xf86DomainInfo[domain]))
+ continue;
+
+ RANGE(range, 0, pDomain->mem_size - 1,
+ RANGE_TYPE(ResExcMemBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+
+ RANGE(range, 0, pDomain->io_size - 1,
+ RANGE_TYPE(ResExcIoBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+ }
+
+ return pRes;
+}
+
+resPtr
+xf86AccResFromOS(resPtr pRes)
+{
+ sparcDomainPtr pDomain;
+ resRange range;
+ int domain;
+
+ for (domain = 1; domain < pciNumDomains; domain++) {
+ if (!(pDomain = xf86DomainInfo[domain]))
+ continue;
+
+ /*
+ * At minimum, the top and bottom resources must be claimed, so that
+ * resources that are (or appear to be) unallocated can be relocated.
+ */
+ RANGE(range, 0x00000000u, 0x0009ffffu,
+ RANGE_TYPE(ResExcMemBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+ RANGE(range, 0x000c0000u, 0x000effffu,
+ RANGE_TYPE(ResExcMemBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+ RANGE(range, 0x000f0000u, 0x000fffffu,
+ RANGE_TYPE(ResExcMemBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+
+ RANGE(range, pDomain->mem_size - 1, pDomain->mem_size - 1,
+ RANGE_TYPE(ResExcMemBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+
+ RANGE(range, 0x00000000u, 0x00000000u,
+ RANGE_TYPE(ResExcIoBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+ RANGE(range, pDomain->io_size - 1, pDomain->io_size - 1,
+ RANGE_TYPE(ResExcIoBlock, domain));
+ pRes = xf86AddResToList(pRes, &range, -1);
+ }
+
+ return pRes;
+}
+
+#endif /* !INCLUDE_XF86_NO_DOMAIN */
+
+#endif /* defined(sun) */
+
+#if defined(ARCH_PCI_PCI_BRIDGE)
+
+/* Definitions specific to Sun's APB P2P bridge (a.k.a. Simba) */
+#define APB_IO_ADDRESS_MAP 0xDE
+#define APB_MEM_ADDRESS_MAP 0xDF
+
+/*
+ * Simba's can only occur on bus 0. Furthermore, Simba's must have a non-zero
+ * device/function number because the Sabre interface they must connect to
+ * occupies the 0:0:0 slot. Also, there can be only one Sabre interface in the
+ * system, and therefore, only one Simba function can route any particular
+ * resource. Thus, it is appropriate to use a single set of static variables
+ * to hold the tag of the Simba function routing a VGA resource range at any
+ * one time, and to test these variables for non-zero to determine whether or
+ * not the Sabre would master-abort a VGA access (and kill the system).
+ *
+ * The trick is to determine when it is safe to re-route VGA, because doing so
+ * re-routes much more.
+ */
+static PCITAG simbavgaIOTag = 0, simbavgaMemTag = 0;
+static Bool simbavgaRoutingAllow = TRUE;
+
+/*
+ * Scan the bus subtree rooted at 'bus' for a non-display device that might be
+ * decoding the bottom 2 MB of I/O space and/or the bottom 512 MB of memory
+ * space. Reset simbavgaRoutingAllow if such a device is found.
+ *
+ * XXX For now, this is very conservative and should be made less so as the
+ * need arises.
+ */
+static void
+simbaCheckBus(CARD16 pcicommand, int bus)
+{
+ pciConfigPtr pPCI, *ppPCI = xf86scanpci(0);
+
+ while ((pPCI = *ppPCI++)) {
+ if (pPCI->busnum < bus)
+ continue;
+ if (pPCI->busnum > bus)
+ break;
+
+ /* XXX Assume all devices respect PCI disablement */
+ if (!(pcicommand & pPCI->pci_command))
+ continue;
+
+ /* XXX This doesn't deal with mis-advertised classes */
+ switch (pPCI->pci_base_class) {
+ case PCI_CLASS_PREHISTORIC:
+ if (pPCI->pci_sub_class == PCI_SUBCLASS_PREHISTORIC_VGA)
+ continue; /* Ignore VGA */
+ break;
+
+ case PCI_CLASS_DISPLAY:
+ continue;
+
+ case PCI_CLASS_BRIDGE:
+ switch (pPCI->pci_sub_class) {
+ case PCI_SUBCLASS_BRIDGE_PCI:
+ case PCI_SUBCLASS_BRIDGE_CARDBUS:
+ /* Scan secondary bus */
+ /* XXX First check bridge routing? */
+ simbaCheckBus(pcicommand & pPCI->pci_command,
+ PCI_SECONDARY_BUS_EXTRACT(pPCI->pci_pp_bus_register,
+ pPCI->tag));
+ if (!simbavgaRoutingAllow)
+ return;
+
+ default:
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ /*
+ * XXX We could check the device's bases here, but PCI doesn't limit
+ * the device's decoding to them.
+ */
+
+ simbavgaRoutingAllow = FALSE;
+ break;
+ }
+}
+
+static pciConfigPtr
+simbaVerifyBus(int bus)
+{
+ pciConfigPtr pPCI;
+ if ((bus < 0) || (bus >= pciNumBuses) ||
+ !pciBusInfo[bus] || !(pPCI = pciBusInfo[bus]->bridge) ||
+ (pPCI->pci_device_vendor != DEVID(VENDOR_SUN, CHIP_SIMBA)))
+ return NULL;
+
+ return pPCI;
+}
+
+static CARD16
+simbaControlBridge(int bus, CARD16 mask, CARD16 value)
+{
+ pciConfigPtr pPCI;
+ CARD16 current = 0, tmp;
+ CARD8 iomap, memmap;
+
+ if ((pPCI = simbaVerifyBus(bus))) {
+ /*
+ * The Simba does not implement VGA enablement as described in the P2P
+ * spec. It does however route I/O and memory in large enough chunks
+ * so that we can determine were VGA resources would be routed
+ * (including ISA VGA I/O aliases). We can allow changes to that
+ * routing only under certain circumstances.
+ */
+ iomap = pciReadByte(pPCI->tag, APB_IO_ADDRESS_MAP);
+ memmap = pciReadByte(pPCI->tag, APB_MEM_ADDRESS_MAP);
+ if (iomap & memmap & 0x01) {
+ current |= PCI_PCI_BRIDGE_VGA_EN;
+ if ((mask & PCI_PCI_BRIDGE_VGA_EN) &&
+ !(value & PCI_PCI_BRIDGE_VGA_EN)) {
+ if (!simbavgaRoutingAllow) {
+ xf86MsgVerb(X_WARNING, 3, "Attempt to disable VGA routing"
+ " through Simba at %x:%x:%x disallowed.\n",
+ pPCI->busnum, pPCI->devnum, pPCI->funcnum);
+ value |= PCI_PCI_BRIDGE_VGA_EN;
+ } else {
+ pciWriteByte(pPCI->tag, APB_IO_ADDRESS_MAP,
+ iomap & ~0x01);
+ pciWriteByte(pPCI->tag, APB_MEM_ADDRESS_MAP,
+ memmap & ~0x01);
+ simbavgaIOTag = simbavgaMemTag = 0;
+ }
+ }
+ } else {
+ if (mask & value & PCI_PCI_BRIDGE_VGA_EN) {
+ if (!simbavgaRoutingAllow) {
+ xf86MsgVerb(X_WARNING, 3, "Attempt to enable VGA routing"
+ " through Simba at %x:%x:%x disallowed.\n",
+ pPCI->busnum, pPCI->devnum, pPCI->funcnum);
+ value &= ~PCI_PCI_BRIDGE_VGA_EN;
+ } else {
+ if (pPCI->tag != simbavgaIOTag) {
+ if (simbavgaIOTag) {
+ tmp = pciReadByte(simbavgaIOTag,
+ APB_IO_ADDRESS_MAP);
+ pciWriteByte(simbavgaIOTag, APB_IO_ADDRESS_MAP,
+ tmp & ~0x01);
+ }
+
+ pciWriteByte(pPCI->tag, APB_IO_ADDRESS_MAP,
+ iomap | 0x01);
+ simbavgaIOTag = pPCI->tag;
+ }
+
+ if (pPCI->tag != simbavgaMemTag) {
+ if (simbavgaMemTag) {
+ tmp = pciReadByte(simbavgaMemTag,
+ APB_MEM_ADDRESS_MAP);
+ pciWriteByte(simbavgaMemTag, APB_MEM_ADDRESS_MAP,
+ tmp & ~0x01);
+ }
+
+ pciWriteByte(pPCI->tag, APB_MEM_ADDRESS_MAP,
+ memmap | 0x01);
+ simbavgaMemTag = pPCI->tag;
+ }
+ }
+ }
+ }
+
+ /* Move on to master abort failure enablement (as per P2P spec) */
+ tmp = pciReadWord(pPCI->tag, PCI_PCI_BRIDGE_CONTROL_REG);
+ current |= tmp;
+ if (tmp & PCI_PCI_BRIDGE_MASTER_ABORT_EN) {
+ if ((mask & PCI_PCI_BRIDGE_MASTER_ABORT_EN) &&
+ !(value & PCI_PCI_BRIDGE_MASTER_ABORT_EN))
+ pciWriteWord(pPCI->tag, PCI_PCI_BRIDGE_CONTROL_REG,
+ tmp & ~PCI_PCI_BRIDGE_MASTER_ABORT_EN);
+ } else {
+ if (mask & value & PCI_PCI_BRIDGE_MASTER_ABORT_EN)
+ pciWriteWord(pPCI->tag, PCI_PCI_BRIDGE_CONTROL_REG,
+ tmp | PCI_PCI_BRIDGE_MASTER_ABORT_EN);
+ }
+
+ /* Insert emulation of other P2P controls here */
+ }
+
+ return (current & ~mask) | (value & mask);
+}
+
+static void
+simbaGetBridgeResources(int bus,
+ pointer *ppIoRes,
+ pointer *ppMemRes,
+ pointer *ppPmemRes)
+{
+ pciConfigPtr pPCI = simbaVerifyBus(bus);
+ resRange range;
+ int i;
+
+ if (!pPCI)
+ return;
+
+ if (ppIoRes) {
+ xf86FreeResList(*ppIoRes);
+ *ppIoRes = NULL;
+
+ if (pPCI->pci_command & PCI_CMD_IO_ENABLE) {
+ unsigned char iomap = pciReadByte(pPCI->tag, APB_IO_ADDRESS_MAP);
+ if (simbavgaRoutingAllow)
+ iomap |= 0x01;
+ for (i = 0; i < 8; i++) {
+ if (iomap & (1 << i)) {
+ RANGE(range, i << 21, ((i + 1) << 21) - 1,
+ RANGE_TYPE(ResExcIoBlock,
+ xf86GetPciDomain(pPCI->tag)));
+ *ppIoRes = xf86AddResToList(*ppIoRes, &range, -1);
+ }
+ }
+ }
+ }
+
+ if (ppMemRes) {
+ xf86FreeResList(*ppMemRes);
+ *ppMemRes = NULL;
+
+ if (pPCI->pci_command & PCI_CMD_MEM_ENABLE) {
+ unsigned char memmap = pciReadByte(pPCI->tag, APB_MEM_ADDRESS_MAP);
+ if (simbavgaRoutingAllow)
+ memmap |= 0x01;
+ for (i = 0; i < 8; i++) {
+ if (memmap & (1 << i)) {
+ RANGE(range, i << 29, ((i + 1) << 29) - 1,
+ RANGE_TYPE(ResExcMemBlock,
+ xf86GetPciDomain(pPCI->tag)));
+ *ppMemRes = xf86AddResToList(*ppMemRes, &range, -1);
+ }
+ }
+ }
+ }
+
+ if (ppPmemRes) {
+ xf86FreeResList(*ppPmemRes);
+ *ppPmemRes = NULL;
+ }
+}
+
+void ARCH_PCI_PCI_BRIDGE(pciConfigPtr pPCI)
+{
+ static pciBusFuncs_t simbaBusFuncs;
+ pciBusInfo_t *pBusInfo;
+ CARD16 pcicommand;
+
+ if (pPCI->pci_device_vendor != DEVID(VENDOR_SUN, CHIP_SIMBA))
+ return;
+
+ pBusInfo = pPCI->businfo;
+
+ simbaBusFuncs = *(pBusInfo->funcs);
+ simbaBusFuncs.pciControlBridge = simbaControlBridge;
+ simbaBusFuncs.pciGetBridgeResources = simbaGetBridgeResources;
+
+ pBusInfo->funcs = &simbaBusFuncs;
+
+ if (!simbavgaRoutingAllow)
+ return;
+
+ pcicommand = 0;
+
+ if (pciReadByte(pPCI->tag, APB_IO_ADDRESS_MAP) & 0x01) {
+ pcicommand |= PCI_CMD_IO_ENABLE;
+ simbavgaIOTag = pPCI->tag;
+ }
+
+ if (pciReadByte(pPCI->tag, APB_MEM_ADDRESS_MAP) & 0x01) {
+ pcicommand |= PCI_CMD_MEM_ENABLE;
+ simbavgaMemTag = pPCI->tag;
+ }
+
+ if (!pcicommand)
+ return;
+
+ simbaCheckBus(pcicommand,
+ PCI_SECONDARY_BUS_EXTRACT(pPCI->pci_pp_bus_register, pPCI->tag));
+}
+
+#endif /* defined(ARCH_PCI_PCI_BRIDGE) */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h
new file mode 100644
index 000000000..a8b7ef492
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h
@@ -0,0 +1,807 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h,v 1.39 2003/08/24 17:37:05 dawes Exp $ */
+/*
+ * Copyright 1998 by Concurrent Computer Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Concurrent Computer
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Concurrent Computer Corporation makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Copyright 1998 by Metro Link Incorporated
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * This file is derived in part from the original xf86_PCI.h that included
+ * following copyright message:
+ *
+ * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the above listed copyright holder(s)
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. The above listed
+ * copyright holder(s) make(s) no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*
+ * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/*
+ * This file contains just the public interface to the PCI code.
+ * Drivers should use this file rather than Pci.h.
+ */
+
+#ifndef _XF86PCI_H
+#define _XF86PCI_H 1
+#include <X11/Xarch.h>
+#include <X11/Xfuncproto.h>
+#include "misc.h"
+
+#define PCI_NOT_FOUND 0xFFFFFFFFU
+
+/*
+ * PCI cfg space definitions (e.g. stuff right out of the PCI spec)
+ */
+
+/* Device identification register */
+#define PCI_ID_REG 0x00
+
+/* Command and status register */
+#define PCI_CMD_STAT_REG 0x04
+#define PCI_CMD_BASE_REG 0x10
+#define PCI_CMD_BIOS_REG 0x30
+#define PCI_CMD_MASK 0xffff
+#define PCI_CMD_IO_ENABLE 0x01
+#define PCI_CMD_MEM_ENABLE 0x02
+#define PCI_CMD_MASTER_ENABLE 0x04
+#define PCI_CMD_SPECIAL_ENABLE 0x08
+#define PCI_CMD_INVALIDATE_ENABLE 0x10
+#define PCI_CMD_PALETTE_ENABLE 0x20
+#define PCI_CMD_PARITY_ENABLE 0x40
+#define PCI_CMD_STEPPING_ENABLE 0x80
+#define PCI_CMD_SERR_ENABLE 0x100
+#define PCI_CMD_BACKTOBACK_ENABLE 0x200
+#define PCI_CMD_BIOS_ENABLE 0x01
+
+/* base class */
+#define PCI_CLASS_REG 0x08
+#define PCI_CLASS_MASK 0xff000000
+#define PCI_CLASS_SHIFT 24
+#define PCI_CLASS_EXTRACT(x) \
+ (((x) & PCI_CLASS_MASK) >> PCI_CLASS_SHIFT)
+
+/* base class values */
+#define PCI_CLASS_PREHISTORIC 0x00
+#define PCI_CLASS_MASS_STORAGE 0x01
+#define PCI_CLASS_NETWORK 0x02
+#define PCI_CLASS_DISPLAY 0x03
+#define PCI_CLASS_MULTIMEDIA 0x04
+#define PCI_CLASS_MEMORY 0x05
+#define PCI_CLASS_BRIDGE 0x06
+#define PCI_CLASS_COMMUNICATIONS 0x07
+#define PCI_CLASS_SYSPERIPH 0x08
+#define PCI_CLASS_INPUT 0x09
+#define PCI_CLASS_DOCKING 0x0a
+#define PCI_CLASS_PROCESSOR 0x0b
+#define PCI_CLASS_SERIALBUS 0x0c
+#define PCI_CLASS_WIRELESS 0x0d
+#define PCI_CLASS_I2O 0x0e
+#define PCI_CLASS_SATELLITE 0x0f
+#define PCI_CLASS_CRYPT 0x10
+#define PCI_CLASS_DATA_ACQUISTION 0x11
+#define PCI_CLASS_UNDEFINED 0xff
+
+/* sub class */
+#define PCI_SUBCLASS_MASK 0x00ff0000
+#define PCI_SUBCLASS_SHIFT 16
+#define PCI_SUBCLASS_EXTRACT(x) \
+ (((x) & PCI_SUBCLASS_MASK) >> PCI_SUBCLASS_SHIFT)
+
+/* Sub class values */
+/* 0x00 prehistoric subclasses */
+#define PCI_SUBCLASS_PREHISTORIC_MISC 0x00
+#define PCI_SUBCLASS_PREHISTORIC_VGA 0x01
+
+/* 0x01 mass storage subclasses */
+#define PCI_SUBCLASS_MASS_STORAGE_SCSI 0x00
+#define PCI_SUBCLASS_MASS_STORAGE_IDE 0x01
+#define PCI_SUBCLASS_MASS_STORAGE_FLOPPY 0x02
+#define PCI_SUBCLASS_MASS_STORAGE_IPI 0x03
+#define PCI_SUBCLASS_MASS_STORAGE_MISC 0x80
+
+/* 0x02 network subclasses */
+#define PCI_SUBCLASS_NETWORK_ETHERNET 0x00
+#define PCI_SUBCLASS_NETWORK_TOKENRING 0x01
+#define PCI_SUBCLASS_NETWORK_FDDI 0x02
+#define PCI_SUBCLASS_NETWORK_MISC 0x80
+
+/* 0x03 display subclasses */
+#define PCI_SUBCLASS_DISPLAY_VGA 0x00
+#define PCI_SUBCLASS_DISPLAY_XGA 0x01
+#define PCI_SUBCLASS_DISPLAY_MISC 0x80
+
+/* 0x04 multimedia subclasses */
+#define PCI_SUBCLASS_MULTIMEDIA_VIDEO 0x00
+#define PCI_SUBCLASS_MULTIMEDIA_AUDIO 0x01
+#define PCI_SUBCLASS_MULTIMEDIA_MISC 0x80
+
+/* 0x05 memory subclasses */
+#define PCI_SUBCLASS_MEMORY_RAM 0x00
+#define PCI_SUBCLASS_MEMORY_FLASH 0x01
+#define PCI_SUBCLASS_MEMORY_MISC 0x80
+
+/* 0x06 bridge subclasses */
+#define PCI_SUBCLASS_BRIDGE_HOST 0x00
+#define PCI_SUBCLASS_BRIDGE_ISA 0x01
+#define PCI_SUBCLASS_BRIDGE_EISA 0x02
+#define PCI_SUBCLASS_BRIDGE_MC 0x03
+#define PCI_SUBCLASS_BRIDGE_PCI 0x04
+#define PCI_SUBCLASS_BRIDGE_PCMCIA 0x05
+#define PCI_SUBCLASS_BRIDGE_NUBUS 0x06
+#define PCI_SUBCLASS_BRIDGE_CARDBUS 0x07
+#define PCI_SUBCLASS_BRIDGE_RACEWAY 0x08
+#define PCI_SUBCLASS_BRIDGE_MISC 0x80
+#define PCI_IF_BRIDGE_PCI_SUBTRACTIVE 0x01
+
+/* 0x07 communications controller subclasses */
+#define PCI_SUBCLASS_COMMUNICATIONS_SERIAL 0x00
+#define PCI_SUBCLASS_COMMUNICATIONS_PARALLEL 0x01
+#define PCI_SUBCLASS_COMMUNICATIONS_MULTISERIAL 0x02
+#define PCI_SUBCLASS_COMMUNICATIONS_MODEM 0x03
+#define PCI_SUBCLASS_COMMUNICATIONS_MISC 0x80
+
+/* 0x08 generic system peripherals subclasses */
+#define PCI_SUBCLASS_SYSPERIPH_PIC 0x00
+#define PCI_SUBCLASS_SYSPERIPH_DMA 0x01
+#define PCI_SUBCLASS_SYSPERIPH_TIMER 0x02
+#define PCI_SUBCLASS_SYSPERIPH_RTC 0x03
+#define PCI_SUBCLASS_SYSPERIPH_HOTPCI 0x04
+#define PCI_SUBCLASS_SYSPERIPH_MISC 0x80
+
+/* 0x09 input device subclasses */
+#define PCI_SUBCLASS_INPUT_KEYBOARD 0x00
+#define PCI_SUBCLASS_INPUT_DIGITIZER 0x01
+#define PCI_SUBCLASS_INPUT_MOUSE 0x02
+#define PCI_SUBCLASS_INPUT_SCANNER 0x03
+#define PCI_SUBCLASS_INPUT_GAMEPORT 0x04
+#define PCI_SUBCLASS_INPUT_MISC 0x80
+
+/* 0x0a docking station subclasses */
+#define PCI_SUBCLASS_DOCKING_GENERIC 0x00
+#define PCI_SUBCLASS_DOCKING_MISC 0x80
+
+/* 0x0b processor subclasses */
+#define PCI_SUBCLASS_PROCESSOR_386 0x00
+#define PCI_SUBCLASS_PROCESSOR_486 0x01
+#define PCI_SUBCLASS_PROCESSOR_PENTIUM 0x02
+#define PCI_SUBCLASS_PROCESSOR_ALPHA 0x10
+#define PCI_SUBCLASS_PROCESSOR_POWERPC 0x20
+#define PCI_SUBCLASS_PROCESSOR_MIPS 0x30
+#define PCI_SUBCLASS_PROCESSOR_COPROC 0x40
+
+/* 0x0c serial bus controller subclasses */
+#define PCI_SUBCLASS_SERIAL_FIREWIRE 0x00
+#define PCI_SUBCLASS_SERIAL_ACCESS 0x01
+#define PCI_SUBCLASS_SERIAL_SSA 0x02
+#define PCI_SUBCLASS_SERIAL_USB 0x03
+#define PCI_SUBCLASS_SERIAL_FIBRECHANNEL 0x04
+#define PCI_SUBCLASS_SERIAL_SMBUS 0x05
+
+/* 0x0d wireless controller subclasses */
+#define PCI_SUBCLASS_WIRELESS_IRDA 0x00
+#define PCI_SUBCLASS_WIRELESS_CONSUMER_IR 0x01
+#define PCI_SUBCLASS_WIRELESS_RF 0x02
+#define PCI_SUBCLASS_WIRELESS_MISC 0x80
+
+/* 0x0e intelligent I/O controller subclasses */
+#define PCI_SUBCLASS_I2O_I2O 0x00
+
+/* 0x0f satellite communications controller subclasses */
+#define PCI_SUBCLASS_SATELLITE_TV 0x01
+#define PCI_SUBCLASS_SATELLITE_AUDIO 0x02
+#define PCI_SUBCLASS_SATELLITE_VOICE 0x03
+#define PCI_SUBCLASS_SATELLITE_DATA 0x04
+
+/* 0x10 encryption/decryption controller subclasses */
+#define PCI_SUBCLASS_CRYPT_NET_COMPUTING 0x00
+#define PCI_SUBCLASS_CRYPT_ENTERTAINMENT 0x10
+#define PCI_SUBCLASS_CRYPT_MISC 0x80
+
+/* 0x11 data acquisition and signal processing controller subclasses */
+#define PCI_SUBCLASS_DATAACQ_DPIO 0x00
+#define PCI_SUBCLASS_DATAACQ_MISC 0x80
+
+
+/* Header */
+#define PCI_HEADER_MISC 0x0c
+#define PCI_HEADER_MULTIFUNCTION 0x00800000
+
+/* Interrupt configration register */
+#define PCI_INTERRUPT_REG 0x3c
+#define PCI_INTERRUPT_PIN_MASK 0x0000ff00
+#define PCI_INTERRUPT_PIN_EXTRACT(x) \
+ ((((x) & PCI_INTERRUPT_PIN_MASK) >> 8) & 0xff)
+#define PCI_INTERRUPT_PIN_NONE 0x00
+#define PCI_INTERRUPT_PIN_A 0x01
+#define PCI_INTERRUPT_PIN_B 0x02
+#define PCI_INTERRUPT_PIN_C 0x03
+#define PCI_INTERRUPT_PIN_D 0x04
+
+#define PCI_INTERRUPT_LINE_MASK 0x000000ff
+#define PCI_INTERRUPT_LINE_EXTRACT(x) \
+ ((((x) & PCI_INTERRUPT_LINE_MASK) >> 0) & 0xff)
+#define PCI_INTERRUPT_LINE_INSERT(x,v) \
+ (((x) & ~PCI_INTERRUPT_LINE_MASK) | ((v) << 0))
+
+/* Base registers */
+#define PCI_MAP_REG_START 0x10
+#define PCI_MAP_REG_END 0x28
+#define PCI_MAP_ROM_REG 0x30
+
+#define PCI_MAP_MEMORY 0x00000000
+#define PCI_MAP_IO 0x00000001
+
+#define PCI_MAP_MEMORY_TYPE 0x00000007
+#define PCI_MAP_IO_TYPE 0x00000003
+
+#define PCI_MAP_MEMORY_TYPE_32BIT 0x00000000
+#define PCI_MAP_MEMORY_TYPE_32BIT_1M 0x00000002
+#define PCI_MAP_MEMORY_TYPE_64BIT 0x00000004
+#define PCI_MAP_MEMORY_TYPE_MASK 0x00000006
+#define PCI_MAP_MEMORY_CACHABLE 0x00000008
+#define PCI_MAP_MEMORY_ATTR_MASK 0x0000000e
+#define PCI_MAP_MEMORY_ADDRESS_MASK 0xfffffff0
+
+#define PCI_MAP_IO_ATTR_MASK 0x00000003
+
+#define PCI_MAP_IS_IO(b) ((b) & PCI_MAP_IO)
+#define PCI_MAP_IS_MEM(b) (!PCI_MAP_IS_IO(b))
+
+#define PCI_MAP_IS64BITMEM(b) \
+ (((b) & PCI_MAP_MEMORY_TYPE) == PCI_MAP_MEMORY_TYPE_64BIT)
+
+#define PCIGETMEMORY(b) ((b) & PCI_MAP_MEMORY_ADDRESS_MASK)
+#define PCIGETMEMORY64HIGH(b) (*((CARD32*)&(b) + 1))
+#define PCIGETMEMORY64(b) \
+ (PCIGETMEMORY(b) | ((CARD64)PCIGETMEMORY64HIGH(b) << 32))
+
+#define PCI_MAP_IO_ADDRESS_MASK 0xfffffffc
+
+#define PCIGETIO(b) ((b) & PCI_MAP_IO_ADDRESS_MASK)
+
+#define PCI_MAP_ROM_DECODE_ENABLE 0x00000001
+#define PCI_MAP_ROM_ADDRESS_MASK 0xfffff800
+
+#define PCIGETROM(b) ((b) & PCI_MAP_ROM_ADDRESS_MASK)
+
+/* PCI-PCI bridge mapping registers */
+#define PCI_PCI_BRIDGE_BUS_REG 0x18
+#define PCI_SUBORDINATE_BUS_MASK 0x00ff0000
+#define PCI_SECONDARY_BUS_MASK 0x0000ff00
+#define PCI_PRIMARY_BUS_MASK 0x000000ff
+
+#define PCI_PCI_BRIDGE_IO_REG 0x1c
+#define PCI_PCI_BRIDGE_MEM_REG 0x20
+#define PCI_PCI_BRIDGE_PMEM_REG 0x24
+
+#define PCI_PPB_IOBASE_EXTRACT(x) (((x) << 8) & 0xFF00)
+#define PCI_PPB_IOLIMIT_EXTRACT(x) (((x) << 0) & 0xFF00)
+
+#define PCI_PPB_MEMBASE_EXTRACT(x) (((x) << 16) & 0xFFFF0000)
+#define PCI_PPB_MEMLIMIT_EXTRACT(x) (((x) << 0) & 0xFFFF0000)
+
+#define PCI_PCI_BRIDGE_CONTROL_REG 0x3E
+#define PCI_PCI_BRIDGE_PARITY_EN 0x01
+#define PCI_PCI_BRIDGE_SERR_EN 0x02
+#define PCI_PCI_BRIDGE_ISA_EN 0x04
+#define PCI_PCI_BRIDGE_VGA_EN 0x08
+#define PCI_PCI_BRIDGE_MASTER_ABORT_EN 0x20
+#define PCI_PCI_BRIDGE_SECONDARY_RESET 0x40
+#define PCI_PCI_BRIDGE_FAST_B2B_EN 0x80
+/* header type 2 extensions */
+#define PCI_CB_BRIDGE_CTL_CB_RESET 0x40 /* CardBus reset */
+#define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */
+#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100
+#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200
+#define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400
+
+#define PCI_CB_SEC_STATUS_REG 0x16 /* Secondary status */
+#define PCI_CB_PRIMARY_BUS_REG 0x18 /* PCI bus number */
+#define PCI_CB_CARD_BUS_REG 0x19 /* CardBus bus number */
+#define PCI_CB_SUBORDINATE_BUS_REG 0x1a /* Subordinate bus number */
+#define PCI_CB_LATENCY_TIMER_REG 0x1b /* CardBus latency timer */
+#define PCI_CB_MEM_BASE_0_REG 0x1c
+#define PCI_CB_MEM_LIMIT_0_REG 0x20
+#define PCI_CB_MEM_BASE_1_REG 0x24
+#define PCI_CB_MEM_LIMIT_1_REG 0x28
+#define PCI_CB_IO_BASE_0_REG 0x2c
+#define PCI_CB_IO_LIMIT_0_REG 0x30
+#define PCI_CB_IO_BASE_1_REG 0x34
+#define PCI_CB_IO_LIMIT_1_REG 0x38
+#define PCI_CB_BRIDGE_CONTROL_REG 0x3E
+
+#define PCI_CB_IO_RANGE_MASK ~0x03
+#define PCI_CB_IOBASE(x) (x & PCI_CB_IO_RANGE_MASK)
+#define PCI_CB_IOLIMIT(x) ((x & PCI_CB_IO_RANGE_MASK) + 3)
+
+/* Subsystem identification register */
+#define PCI_SUBSYSTEM_ID_REG 0x2c
+
+/* User defined cfg space regs */
+#define PCI_REG_USERCONFIG 0x40
+#define PCI_OPTION_REG 0x40
+
+/*
+ * Typedefs, etc...
+ */
+
+/* Primitive Types */
+typedef unsigned long ADDRESS; /* Memory/PCI address */
+typedef unsigned long IOADDRESS; /* Must be large enough for a pointer */
+typedef unsigned long PCITAG;
+
+/*
+ * PCI configuration space
+ */
+typedef struct pci_cfg_regs {
+ /* start of official PCI config space header */
+ union { /* Offset 0x0 - 0x3 */
+ CARD32 device_vendor;
+ struct {
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ CARD16 device;
+ CARD16 vendor;
+#else
+ CARD16 vendor;
+ CARD16 device;
+#endif
+ } dv;
+ } dv_id;
+
+ union { /* Offset 0x4 - 0x8 */
+ CARD32 status_command;
+ struct {
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ CARD16 status;
+ CARD16 command;
+#else
+ CARD16 command;
+ CARD16 status;
+#endif
+ } sc;
+ } stat_cmd;
+
+ union { /* Offset 0x8 - 0xb */
+ CARD32 class_revision;
+ struct {
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ CARD8 base_class;
+ CARD8 sub_class;
+ CARD8 prog_if;
+ CARD8 rev_id;
+#else
+ CARD8 rev_id;
+ CARD8 prog_if;
+ CARD8 sub_class;
+ CARD8 base_class;
+#endif
+ } cr;
+ } class_rev;
+
+ union { /* Offset 0xc - 0xf */
+ CARD32 bist_header_latency_cache;
+ struct {
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ CARD8 bist;
+ CARD8 header_type;
+ CARD8 latency_timer;
+ CARD8 cache_line_size;
+#else
+ CARD8 cache_line_size;
+ CARD8 latency_timer;
+ CARD8 header_type;
+ CARD8 bist;
+#endif
+ } bhlc;
+ } bhlc;
+ union { /* Offset 0x10 - 0x3b */
+ struct { /* header type 2 */
+ CARD32 cg_rsrvd1; /* 0x10 */
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ CARD16 secondary_status; /* 0x16 */
+ CARD16 cg_rsrvd2; /* 0x14 */
+
+ union {
+ CARD32 cg_bus_reg;
+ struct {
+ CARD8 latency_timer; /* 0x1b */
+ CARD8 subordinate_bus_number; /* 0x1a */
+ CARD8 cardbus_bus_number; /* 0x19 */
+ CARD8 primary_bus_number; /* 0x18 */
+ } cgbr;
+ } cgbr;
+#else
+ CARD16 cg_rsrvd2; /* 0x14 */
+ CARD16 secondary_status; /* 0x16 */
+
+ union {
+ CARD32 cg_bus_reg;
+ struct {
+ CARD8 primary_bus_number; /* 0x18 */
+ CARD8 cardbus_bus_number; /* 0x19 */
+ CARD8 subordinate_bus_number; /* 0x1a */
+ CARD8 latency_timer; /* 0x1b */
+ } cgbr;
+ } cgbr;
+#endif
+ CARD32 mem_base0; /* 0x1c */
+ CARD32 mem_limit0; /* 0x20 */
+ CARD32 mem_base1; /* 0x24 */
+ CARD32 mem_limit1; /* 0x28 */
+ CARD32 io_base0; /* 0x2c */
+ CARD32 io_limit0; /* 0x30 */
+ CARD32 io_base1; /* 0x34 */
+ CARD32 io_limit1; /* 0x38 */
+ } cg;
+ struct {
+ union { /* Offset 0x10 - 0x27 */
+ struct { /* header type 0 */
+ CARD32 dv_base0;
+ CARD32 dv_base1;
+ CARD32 dv_base2;
+ CARD32 dv_base3;
+ CARD32 dv_base4;
+ CARD32 dv_base5;
+ } dv;
+ struct { /* header type 1 */
+ CARD32 bg_rsrvd[2];
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ union {
+ CARD32 pp_bus_reg;
+ struct {
+ CARD8 secondary_latency_timer;
+ CARD8 subordinate_bus_number;
+ CARD8 secondary_bus_number;
+ CARD8 primary_bus_number;
+ } ppbr;
+ } ppbr;
+
+ CARD16 secondary_status;
+ CARD8 io_limit;
+ CARD8 io_base;
+
+ CARD16 mem_limit;
+ CARD16 mem_base;
+
+ CARD16 prefetch_mem_limit;
+ CARD16 prefetch_mem_base;
+#else
+ union {
+ CARD32 pp_bus_reg;
+ struct {
+ CARD8 primary_bus_number;
+ CARD8 secondary_bus_number;
+ CARD8 subordinate_bus_number;
+ CARD8 secondary_latency_timer;
+ } ppbr;
+ } ppbr;
+
+ CARD8 io_base;
+ CARD8 io_limit;
+ CARD16 secondary_status;
+
+ CARD16 mem_base;
+ CARD16 mem_limit;
+
+ CARD16 prefetch_mem_base;
+ CARD16 prefetch_mem_limit;
+#endif
+ } bg;
+ } bc;
+ union { /* Offset 0x28 - 0x2b */
+ CARD32 rsvd1;
+ CARD32 pftch_umem_base;
+ CARD32 cardbus_cis_ptr;
+ } um_c_cis;
+ union { /* Offset 0x2c - 0x2f */
+ CARD32 subsys_card_vendor;
+ CARD32 pftch_umem_limit;
+ CARD32 rsvd2;
+ struct {
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ CARD16 subsys_card;
+ CARD16 subsys_vendor;
+#else
+ CARD16 subsys_vendor;
+ CARD16 subsys_card;
+#endif
+ } ssys;
+ } um_ssys_id;
+ union { /* Offset 0x30 - 0x33 */
+ CARD32 baserom;
+ struct {
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ CARD16 io_ulimit;
+ CARD16 io_ubase;
+#else
+ CARD16 io_ubase;
+ CARD16 io_ulimit;
+#endif
+ } b_u_io;
+ } uio_rom;
+ struct {
+ CARD32 rsvd3; /* Offset 0x34 - 0x37 */
+ CARD32 rsvd4; /* Offset 0x38 - 0x3b */
+ } rsvd;
+ } cd;
+ } cx;
+ union { /* Offset 0x3c - 0x3f */
+ union { /* header type 0 */
+ CARD32 max_min_ipin_iline;
+ struct {
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ CARD8 max_lat;
+ CARD8 min_gnt;
+ CARD8 int_pin;
+ CARD8 int_line;
+#else
+ CARD8 int_line;
+ CARD8 int_pin;
+ CARD8 min_gnt;
+ CARD8 max_lat;
+#endif
+ } mmii;
+ } mmii;
+ struct { /* header type 1 */
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ CARD16 bridge_control; /* upper 8 bits reserved */
+ CARD8 rsvd2;
+ CARD8 rsvd1;
+#else
+ CARD8 rsvd1;
+ CARD8 rsvd2;
+ CARD16 bridge_control; /* upper 8 bits reserved */
+#endif
+ } bctrl;
+ } bm;
+ union { /* Offset 0x40 - 0xff */
+ CARD32 dwords[48];
+ CARD8 bytes[192];
+ } devspf;
+} pciCfgRegs;
+
+typedef union pci_cfg_spc {
+ pciCfgRegs regs;
+ CARD32 dwords[256/sizeof(CARD32)];
+ CARD8 bytes[256/sizeof(CARD8)];
+} pciCfgSpc;
+
+/*
+ * Data structure returned by xf86scanpci including contents of
+ * PCI config space header
+ */
+typedef struct pci_device {
+ PCITAG tag;
+ int busnum;
+ int devnum;
+ int funcnum;
+ pciCfgSpc cfgspc;
+ int basesize[7]; /* number of bits in base addr allocations */
+ Bool minBasesize;
+ CARD32 listed_class;
+ pointer businfo; /* pointer to secondary's bus info structure */
+ Bool fakeDevice; /* Device added by system chipset support */
+} pciDevice, *pciConfigPtr;
+
+typedef enum {
+ PCI_MEM,
+ PCI_MEM_SIZE,
+ PCI_MEM_SPARSE_BASE,
+ PCI_MEM_SPARSE_MASK,
+ PCI_IO,
+ PCI_IO_SIZE,
+ PCI_IO_SPARSE_BASE,
+ PCI_IO_SPARSE_MASK
+} PciAddrType;
+
+#define pci_device_vendor cfgspc.regs.dv_id.device_vendor
+#define pci_vendor cfgspc.regs.dv_id.dv.vendor
+#define pci_device cfgspc.regs.dv_id.dv.device
+#define pci_status_command cfgspc.regs.stat_cmd.status_command
+#define pci_command cfgspc.regs.stat_cmd.sc.command
+#define pci_status cfgspc.regs.stat_cmd.sc.status
+#define pci_class_revision cfgspc.regs.class_rev.class_revision
+#define pci_rev_id cfgspc.regs.class_rev.cr.rev_id
+#define pci_prog_if cfgspc.regs.class_rev.cr.prog_if
+#define pci_sub_class cfgspc.regs.class_rev.cr.sub_class
+#define pci_base_class cfgspc.regs.class_rev.cr.base_class
+#define pci_bist_header_latency_cache cfgspc.regs.bhlc.bist_header_latency_cache
+#define pci_cache_line_size cfgspc.regs.bhlc.bhlc.cache_line_size
+#define pci_latency_timer cfgspc.regs.bhlc.bhlc.latency_timer
+#define pci_header_type cfgspc.regs.bhlc.bhlc.header_type
+#define pci_bist cfgspc.regs.bhlc.bhlc.bist
+#define pci_cb_secondary_status cfgspc.regs.cx.cg.secondary_status
+#define pci_cb_bus_register cfgspc.regs.cx.cg.cgbr.cg_bus_reg
+#define pci_cb_primary_bus_number cfgspc.regs.cx.cg.cgbr.cgbr.primary_bus_number
+#define pci_cb_cardbus_bus_number cfgspc.regs.cx.cg.cgbr.cgbr.cardbus_bus_number
+#define pci_cb_subordinate_bus_number cfgspc.regs.cx.cg.cgbr.cgbr.subordinate_bus_number
+#define pci_cb_latency_timer cfgspc.regs.cx.cg.cgbr.cgbr.latency_timer
+#define pci_cb_membase0 cfgspc.regs.cx.cg.mem_base0
+#define pci_cb_memlimit0 cfgspc.regs.cx.cg.mem_limit0
+#define pci_cb_membase1 cfgspc.regs.cx.cg.mem_base1
+#define pci_cb_memlimit1 cfgspc.regs.cx.cg.mem_limit1
+#define pci_cb_iobase0 cfgspc.regs.cx.cg.io_base0
+#define pci_cb_iolimit0 cfgspc.regs.cx.cg.io_limit0
+#define pci_cb_iobase1 cfgspc.regs.cx.cg.io_base1
+#define pci_cb_iolimit1 cfgspc.regs.cx.cg.io_limit1
+#define pci_base0 cfgspc.regs.cx.cd.bc.dv.dv_base0
+#define pci_base1 cfgspc.regs.cx.cd.bc.dv.dv_base1
+#define pci_base2 cfgspc.regs.cx.cd.bc.dv.dv_base2
+#define pci_base3 cfgspc.regs.cx.cd.bc.dv.dv_base3
+#define pci_base4 cfgspc.regs.cx.cd.bc.dv.dv_base4
+#define pci_base5 cfgspc.regs.cx.cd.bc.dv.dv_base5
+#define pci_cardbus_cis_ptr cfgspc.regs.cx.cd.umem_c_cis.cardbus_cis_ptr
+#define pci_subsys_card_vendor cfgspc.regs.cx.cd.um_ssys_id.subsys_card_vendor
+#define pci_subsys_vendor cfgspc.regs.cx.cd.um_ssys_id.ssys.subsys_vendor
+#define pci_subsys_card cfgspc.regs.cx.cd.um_ssys_id.ssys.subsys_card
+#define pci_baserom cfgspc.regs.cx.cd.uio_rom.baserom
+#define pci_pp_bus_register cfgspc.regs.cx.cd.bc.bg.ppbr.pp_bus_reg
+#define pci_primary_bus_number cfgspc.regs.cx.cd.bc.bg.ppbr.ppbr.primary_bus_number
+#define pci_secondary_bus_number cfgspc.regs.cx.cd.bc.bg.ppbr.ppbr.secondary_bus_number
+#define pci_subordinate_bus_number cfgspc.regs.cx.cd.bc.bg.ppbr.ppbr.subordinate_bus_number
+#define pci_secondary_latency_timer cfgspc.regs.cx.cd.bc.bg.ppbr.ppbr.secondary_latency_timer
+#define pci_io_base cfgspc.regs.cx.cd.bc.bg.io_base
+#define pci_io_limit cfgspc.regs.cx.cd.bc.bg.io_limit
+#define pci_secondary_status cfgspc.regs.cx.cd.bc.bg.secondary_status
+#define pci_mem_base cfgspc.regs.cx.cd.bc.bg.mem_base
+#define pci_mem_limit cfgspc.regs.cx.cd.bc.bg.mem_limit
+#define pci_prefetch_mem_base cfgspc.regs.cx.cd.bc.bg.prefetch_mem_base
+#define pci_prefetch_mem_limit cfgspc.regs.cx.cd.bc.bg.prefetch_mem_limit
+#define pci_rsvd1 cfgspc.regs.cx.cd.um_c_cis.rsvd1
+#define pci_rsvd2 cfgspc.regs.cx.cd.um_ssys_id.rsvd2
+#define pci_prefetch_upper_mem_base cfgspc.regs.cx.cd.um_c_cis.pftch_umem_base
+#define pci_prefetch_upper_mem_limit cfgspc.regs.cx.cd.um_ssys_id.pftch_umem_limit
+#define pci_upper_io_base cfgspc.regs.cx.cd.uio_rom.b_u_io.io_ubase
+#define pci_upper_io_limit cfgspc.regs.cx.cd.uio_rom.b_u_io.io_ulimit
+#define pci_int_line cfgspc.regs.bm.mmii.mmii.int_line
+#define pci_int_pin cfgspc.regs.bm.mmii.mmii.int_pin
+#define pci_min_gnt cfgspc.regs.bm.mmii.mmii.min_gnt
+#define pci_max_lat cfgspc.regs.bm.mmii.mmii.max_lat
+#define pci_max_min_ipin_iline cfgspc.regs.bm.mmii.max_min_ipin_iline
+#define pci_bridge_control cfgspc.regs.bm.bctrl.bridge_control
+#define pci_user_config cfgspc.regs.devspf.dwords[0]
+#define pci_user_config_0 cfgspc.regs.devspf.bytes[0]
+#define pci_user_config_1 cfgspc.regs.devspf.bytes[1]
+#define pci_user_config_2 cfgspc.regs.devspf.bytes[2]
+#define pci_user_config_3 cfgspc.regs.devspf.bytes[3]
+
+typedef enum {
+ PCI_BIOS_PC = 0,
+ PCI_BIOS_OPEN_FIRMARE,
+ PCI_BIOS_HP_PA_RISC,
+ PCI_BIOS_OTHER
+} PciBiosType;
+
+/* Public PCI access functions */
+void pciInit(void);
+PCITAG pciFindFirst(CARD32 id, CARD32 mask);
+PCITAG pciFindNext(void);
+CARD32 pciReadLong(PCITAG tag, int offset);
+CARD16 pciReadWord(PCITAG tag, int offset);
+CARD8 pciReadByte(PCITAG tag, int offset);
+void pciWriteLong(PCITAG tag, int offset, CARD32 val);
+void pciWriteWord(PCITAG tag, int offset, CARD16 val);
+void pciWriteByte(PCITAG tag, int offset, CARD8 val);
+void pciSetBitsLong(PCITAG tag, int offset, CARD32 mask, CARD32 val);
+void pciSetBitsByte(PCITAG tag, int offset, CARD8 mask, CARD8 val);
+ADDRESS pciBusAddrToHostAddr(PCITAG tag, PciAddrType type, ADDRESS addr);
+ADDRESS pciHostAddrToBusAddr(PCITAG tag, PciAddrType type, ADDRESS addr);
+PCITAG pciTag(int busnum, int devnum, int funcnum);
+int pciGetBaseSize(PCITAG tag, int indx, Bool destructive, Bool *min);
+CARD32 pciCheckForBrokenBase(PCITAG tag,int basereg);
+pointer xf86MapPciMem(int ScreenNum, int Flags, PCITAG Tag,
+ ADDRESS Base, unsigned long Size);
+int xf86ReadPciBIOS(unsigned long Offset, PCITAG Tag, int basereg,
+ unsigned char *Buf, int Len);
+int xf86ReadPciBIOSByType(unsigned long Offset, PCITAG Tag,
+ int basereg, unsigned char *Buf,
+ int Len, PciBiosType Type);
+int xf86GetAvailablePciBIOSTypes(PCITAG Tag, int basereg,
+ PciBiosType *Buf);
+pciConfigPtr *xf86scanpci(int flags);
+
+extern int pciNumBuses;
+
+/* Domain access functions. Some of these probably shouldn't be public */
+int xf86GetPciDomain(PCITAG tag);
+pointer xf86MapDomainMemory(int ScreenNum, int Flags, PCITAG Tag,
+ ADDRESS Base, unsigned long Size);
+IOADDRESS xf86MapDomainIO(int ScreenNum, int Flags, PCITAG Tag,
+ IOADDRESS Base, unsigned long Size);
+int xf86ReadDomainMemory(PCITAG Tag, ADDRESS Base, int Len,
+ unsigned char *Buf);
+
+typedef enum {
+ ROM_BASE_PRESET = -2,
+ ROM_BASE_BIOS,
+ ROM_BASE_MEM0 = 0,
+ ROM_BASE_MEM1,
+ ROM_BASE_MEM2,
+ ROM_BASE_MEM3,
+ ROM_BASE_MEM4,
+ ROM_BASE_MEM5,
+ ROM_BASE_FIND
+} romBaseSource;
+
+#endif /* _XF86PCI_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/xf86Sbus.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/xf86Sbus.h
new file mode 100644
index 000000000..21b05cba4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/xf86Sbus.h
@@ -0,0 +1,70 @@
+/*
+ * Platform specific SBUS and OpenPROM access declarations.
+ *
+ * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Sbus.h,v 1.3 2001/04/20 17:02:43 tsi Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _XF86_SBUS_H
+#define _XF86_SBUS_H
+
+#if defined(linux)
+#include <asm/types.h>
+#include <linux/fb.h>
+#include <asm/fbio.h>
+#include <asm/openpromio.h>
+#elif defined(SVR4)
+#include <sys/fbio.h>
+#include <sys/openpromio.h>
+#elif defined(__OpenBSD__) && defined(__sparc64__)
+/* XXX */
+#elif defined(CSRG_BASED)
+#if defined(__FreeBSD__)
+#include <sys/types.h>
+#include <sys/fbio.h>
+#include <dev/ofw/openpromio.h>
+#else
+#include <machine/fbio.h>
+#endif
+#else
+#include <sun/fbio.h>
+#endif
+
+#ifndef FBTYPE_SUNGP3
+#define FBTYPE_SUNGP3 -1
+#endif
+#ifndef FBTYPE_MDICOLOR
+#define FBTYPE_MDICOLOR -1
+#endif
+#ifndef FBTYPE_SUNLEO
+#define FBTYPE_SUNLEO -1
+#endif
+#ifndef FBTYPE_TCXCOLOR
+#define FBTYPE_TCXCOLOR -1
+#endif
+#ifndef FBTYPE_CREATOR
+#define FBTYPE_CREATOR -1
+#endif
+
+#endif /* _XF86_SBUS_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/zx1PCI.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/zx1PCI.c
new file mode 100644
index 000000000..3d219c86f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/zx1PCI.c
@@ -0,0 +1,1133 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/zx1PCI.c,v 1.8 2004/01/16 15:39:38 tsi Exp $ */
+/*
+ * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+/*
+ * This file contains the glue necessary for support of HP's ZX1 chipset.
+ * Keep in mind that this chipset is used in both Itanium2 and PA-RISC
+ * architectures.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "zx1PCI.h"
+#include "xf86.h"
+#include "xf86_OSlib.h"
+#include "Pci.h"
+
+#define MIO_BASE 0xFED00000UL /* mio register base */
+#define MIO_SIZE 0x00002000UL /* 8k, minimum */
+
+/* ZX1 mio register definitions */
+#define MIO_FUNCTION0 0x0000U
+
+#define MODULE_INFO 0x0100U
+#define STATUS_CONTROL 0x0108U
+#define DILLON_PRESENT 0x02UL
+
+#define LMMIO_DIR_BASE0 0x0300U
+#define LMMIO_DIR_MASK0 0x0308U
+#define LMMIO_DIR_ROUTE0 0x0310U
+#define LMMIO_DIR_BASE1 0x0318U
+#define LMMIO_DIR_MASK1 0x0320U
+#define LMMIO_DIR_ROUTE1 0x0328U
+#define LMMIO_DIR_BASE2 0x0330U
+#define LMMIO_DIR_MASK2 0x0338U
+#define LMMIO_DIR_ROUTE2 0x0340U
+#define LMMIO_DIR_BASE3 0x0348U
+#define LMMIO_DIR_MASK3 0x0350U
+#define LMMIO_DIR_ROUTE3 0x0358U
+#define LMMIO_DIST_BASE 0x0360U
+#define LMMIO_DIST_MASK 0x0368U
+#define LMMIO_DIST_ROUTE 0x0370U
+#define GMMIO_DIST_BASE 0x0378U
+#define PORT_DISABLE 0x02UL
+#define MAP_TO_LMMIO 0x04UL
+#define GMMIO_DIST_MASK 0x0380U
+#define GMMIO_DIST_ROUTE 0x0388U
+#define IOS_DIST_BASE 0x0390U
+#define IOS_DIST_MASK 0x0398U
+#define IOS_DIST_ROUTE 0x03A0U
+#define ROPE_CONFIG_BASE 0x03A8U
+#define VGA_ROUTE 0x03B0U
+#define VGA_ENABLE 0x8000000000000000UL
+#define VGA_LIGHT 0x4000000000000000UL
+
+#define IOS_DIR_BASE 0x03C0U
+#define IOS_DIR_MASK 0x03C8U
+#define IOS_DIR_ROUTE 0x03D0U
+#define IOS_BASE 0x03D8U
+
+#define MIO_FUNCTION1 0x1000U
+
+#define ROPE_CONFIG 0x1040U
+#define ROPE_D0 0x0100UL
+#define ROPE_D2 0x0200UL
+#define ROPE_D4 0x0400UL
+#define ROPE_D6 0x0800UL
+#define ROPE_Q0 0x1000UL
+#define ROPE_Q4 0x2000UL
+
+#define LBA_PORT0_CNTRL 0x1200U
+#define LBA_PORT1_CNTRL 0x1208U
+#define LBA_PORT2_CNTRL 0x1210U
+#define LBA_PORT3_CNTRL 0x1218U
+#define LBA_PORT4_CNTRL 0x1220U
+#define LBA_PORT5_CNTRL 0x1228U
+#define LBA_PORT6_CNTRL 0x1230U
+#define LBA_PORT7_CNTRL 0x1238U
+#define LBA_RESET_FUNCTION 0x0000000001UL
+#define LBA_CLEAR_ERROR 0x0000000010UL
+#define LBA_HARD_FAIL 0x0000000040UL
+#define LBA_RESET_COMPLETE 0x0100000000UL
+
+#define ROPE_PAGE_CONTROL 0x1418U
+
+/*
+ * Total ioa configuration space size is actually 128k, but we only need the
+ * first 64k.
+ */
+#define IOA_SIZE 0x00010000UL
+
+/* ZX1 ioa register definitions */
+#define IOA_CONFIG_ADDR 0x0040U
+#define IOA_CONFIG_DATA 0x0048U
+
+#define IOA_SECONDARY_BUS 0x0058U
+#define IOA_SUBORDINATE_BUS 0x0059U
+
+#define IOA_CONTROL 0x0108U
+#define IOA_RESET_FUNCTION 0x0000000001UL
+#define IOA_FORWARD_VGA 0x0000000008UL
+#define IOA_CLEAR_ERROR 0x0000000010UL
+#define IOA_HARD_FAIL 0x0000000040UL
+#define IOA_RESET_COMPLETE 0x0100000000UL
+
+#define IOA_LMMIO_BASE 0x0200U
+#define IOA_LMMIO_MASK 0x0208U
+#define IOA_GMMIO_BASE 0x0210U
+#define IOA_GMMIO_MASK 0x0218U
+#define IOA_WLMMIO_BASE 0x0220U
+#define IOA_WLMMIO_MASK 0x0228U
+#define IOA_WGMMIO_BASE 0x0230U
+#define IOA_WGMMIO_MASK 0x0238U
+#define IOA_IOS_BASE 0x0240U
+#define IOA_IOS_MASK 0x0248U
+#define IOA_ELMMIO_BASE 0x0250U
+#define IOA_ELMMIO_MASK 0x0258U
+#define IOA_EIOS_BASE 0x0260U
+#define IOA_EIOS_MASK 0x0268U
+#define IOA_GLOBAL_MASK 0x0270U
+#define IOA_SLAVE_CONTROL 0x0278U
+#define IOA_VGA_PEER_ENABLE 0x2000UL
+#define IOA_MSI_BASE 0x0280U
+#define IOA_MSI_MASK 0x0288U
+
+#define IOA_DMA_BASE 0x02B0U
+#define IOA_DMA_MASK 0x02B8U
+
+#define IOA_ERROR_CONFIG 0x0680U
+#define IOA_ERROR_PIOWRITE 0x0001UL
+#define IOA_ERROR_PIOREAD 0x0002UL
+#define IOA_ERROR_DMAWRITE 0x0004UL
+#define IOA_ERROR_DMAREAD 0x0008UL
+#define IOA_ERROR_CONFIG_MASTER 0x0010UL
+#define IOA_ERROR_SMART 0x0020UL
+#define IOA_ERROR_FATAL_SERR 0x0040UL
+#define IOA_ERROR_ASSERT_SERR 0x0080UL
+/* ? 0x0100UL */
+#define IOA_ERROR_LOOPBACK 0x0200UL
+#define IOA_ERROR_CONFIG_TARGET 0x0400UL
+#define IOA_ERROR_IO_MASTER 0x0800UL
+#define IOA_ERROR_IO_TARGET 0x1000UL
+#define IOA_ERROR_MEM_MASTER 0x2000UL
+#define IOA_ERROR_MEM_TARGET 0x4000UL
+#define IOA_ERROR_HF_IO_FATAL 0x8000UL
+
+#define RANGE_ENABLE 0x01UL /* In various base registers */
+
+#define IO_MASK ((1UL << 16) - 1UL)
+#define LMMIO_MASK ((1UL << 32) - 1UL)
+#ifdef __ia64__
+#define GMMIO_MASK ((1UL << 44) - 1UL)
+#else /* PA-RISC */
+#define GMMIO_MASK ((1UL << 40) - 1UL)
+#endif
+
+#define PDH_START 0xFF000000UL
+#define PDH_LAST 0xFFFFFFFFUL
+
+static CARD8 *pZX1mio = NULL,
+ *pZX1ioa = NULL;
+
+/* Per-rope data */
+static INT8 zx1_ropemap[8];
+static CARD32 zx1_pciids[8];
+static CARD64 zx1_lbacntl[8];
+static int zx1_busno[8], zx1_subno[8];
+
+/* Array of Booleans for non-empty buses */
+static INT8 zx1_busnmpt[MAX_PCI_BUSES];
+
+static pciBusFuncs_t zx1BusFuncs;
+static int zx1_fakebus = -1;
+static Bool zx1_hasvga = FALSE;
+
+static pointer pZX1IoRes[8], pZX1MemRes[8]; /* Rope resources */
+
+/* Non-PCI configuration space access macros */
+#define MIO_BYTE(offset) \
+ (*(volatile CARD8 *)(pointer)(pZX1mio + (offset)))
+#define MIO_WORD(offset) \
+ (*(volatile CARD16 *)(pointer)(pZX1mio + (offset)))
+#define MIO_LONG(offset) \
+ (*(volatile CARD32 *)(pointer)(pZX1mio + (offset)))
+#define MIO_QUAD(offset) \
+ (*(volatile CARD64 *)(pointer)(pZX1mio + (offset)))
+#define IOA_BYTE(ioa, offset) \
+ (*(volatile CARD8 *)(pointer)(pZX1ioa + ((offset) + ((ioa) << 13))))
+#define IOA_WORD(ioa, offset) \
+ (*(volatile CARD16 *)(pointer)(pZX1ioa + ((offset) + ((ioa) << 13))))
+#define IOA_LONG(ioa, offset) \
+ (*(volatile CARD32 *)(pointer)(pZX1ioa + ((offset) + ((ioa) << 13))))
+#define IOA_QUAD(ioa, offset) \
+ (*(volatile CARD64 *)(pointer)(pZX1ioa + ((offset) + ((ioa) << 13))))
+
+/* Range definitions */
+#define MAX_RANGE 16
+static CARD64 bot[MAX_RANGE], top[MAX_RANGE], msk[MAX_RANGE], siz[MAX_RANGE];
+static INT8 *pDecode[MAX_RANGE];
+static int nRange = 0;
+
+/* Track a resource range and assign a granularity to it */
+static void
+SetRange(CARD64 base, CARD64 last, CARD8 width)
+{
+ int i;
+
+ bot[nRange] = base;
+ top[nRange] = last;
+ msk[nRange] = (CARD64)(-1L);
+ if (base)
+ msk[nRange] &= (base ^ (base - 1UL)) >> 1;
+ if (last + 1UL)
+ msk[nRange] &= (last ^ (last + 1UL)) >> 1;
+ if (width < 64)
+ msk[nRange] &= (1UL << width) - 1UL;
+
+ /* Look for overlapping ranges */
+ for (i = 0; i < nRange; i++) {
+ if ((bot[i] > top[i]) ||
+ (top[nRange] < bot[i]) ||
+ (top[i] < bot[nRange]))
+ continue;
+
+ /* Merge in overlapping range */
+ if (bot[nRange] > bot[i])
+ bot[nRange] = bot[i];
+ if (top[nRange] < top[i])
+ top[nRange] = top[i];
+
+ /* Assign finer granularity */
+ msk[nRange] &= msk[i];
+ bot[i] = 1UL;
+ top[i] = 0;
+ }
+
+ nRange++;
+}
+
+/* Lookup granularity associated with the range containing 'base' */
+static int
+GetRange(CARD64 base)
+{
+ int i;
+
+ for (i = 0; i < nRange; i++) {
+ if ((bot[i] > top[i]) ||
+ (base < bot[i]) ||
+ (base > top[i]))
+ continue;
+
+ if (pDecode[i])
+ break;
+
+ /* Allocate decoding array */
+ msk[i]++;
+ siz[i] = ((top[i] - bot[i] + 1UL) / msk[i]) + 1UL;
+ pDecode[i] = xnfalloc(siz[i]);
+ (void)memset(pDecode[i], -1, siz[i]);
+ break;
+ }
+
+ return i;
+}
+
+/*
+ * Verify that 'bus' is a rope's secondary bus and return the pciConfigPtr of
+ * the associated fake PCI-to-PCI bridge.
+ */
+static pciConfigPtr
+VerifyZX1Bus(int bus)
+{
+ pciConfigPtr pPCI;
+
+ if ((bus < 0) || (bus >= pciNumBuses) ||
+ !pciBusInfo[bus] || !(pPCI = pciBusInfo[bus]->bridge) ||
+ (pPCI->busnum != zx1_fakebus) || (pPCI->funcnum != 0) ||
+ (pPCI->devnum < 0x10) || (pPCI->devnum > 0x17))
+ return NULL;
+
+ return pPCI;
+}
+
+/*
+ * This function is called to emulate the various settings in a P2P or CardBus
+ * bridge's control register on a ZX1-based system.
+ */
+static CARD16
+ControlZX1Bridge(int bus, CARD16 mask, CARD16 value)
+{
+ pciConfigPtr pPCI;
+ CARD64 tmp1, tmp2, tmp3, ropenum;
+ CARD16 current = 0;
+
+ if ((pPCI = VerifyZX1Bus(bus))) {
+ ropenum = pPCI->devnum & 0x07;
+
+ /*
+ * Start with VGA enablement. This preserves the "VGA-lite" bit
+ * in mio's VGA_ROUTE register, and the VPE bit in each ioa's
+ * SLAVE_CONTROL register.
+ */
+ tmp1 = MIO_QUAD(VGA_ROUTE);
+ tmp2 = IOA_QUAD(ropenum, IOA_CONTROL) &
+ ~(IOA_RESET_FUNCTION | IOA_CLEAR_ERROR);
+ if ((tmp1 & VGA_ENABLE) && ((tmp1 & 0x07UL) == ropenum)) {
+ current |= PCI_PCI_BRIDGE_VGA_EN;
+ if ((mask & PCI_PCI_BRIDGE_VGA_EN) &&
+ !(value & PCI_PCI_BRIDGE_VGA_EN)) {
+ MIO_QUAD(VGA_ROUTE) = tmp1 & ~VGA_ENABLE;
+ tmp2 &= ~IOA_FORWARD_VGA;
+ IOA_QUAD(ropenum, IOA_CONTROL) = tmp2;
+ }
+ } else if (mask & value & PCI_PCI_BRIDGE_VGA_EN) {
+ if (!zx1_hasvga) {
+ xf86MsgVerb(X_WARNING, 3,
+ "HP ZX1: Attempt to enable VGA routing to bus %d"
+ " through rope %ld disallowed\n", bus, ropenum);
+ value &= ~PCI_PCI_BRIDGE_VGA_EN;
+ } else {
+ if (tmp1 & VGA_ENABLE) {
+ /*
+ * VGA is routed somewhere else. Disable it.
+ */
+ MIO_QUAD(VGA_ROUTE) = 0UL;
+ tmp3 = IOA_QUAD(tmp1 & 0x07UL, IOA_CONTROL);
+ if (tmp3 & IOA_FORWARD_VGA)
+ IOA_QUAD(tmp1 & 0x07UL, IOA_CONTROL) = tmp3 &
+ ~(IOA_RESET_FUNCTION | IOA_FORWARD_VGA |
+ IOA_CLEAR_ERROR);
+ }
+ if (!(tmp2 & IOA_FORWARD_VGA)) {
+ tmp2 |= IOA_FORWARD_VGA;
+ IOA_QUAD(ropenum, IOA_CONTROL) = tmp2;
+ }
+ tmp1 = (tmp1 & ~0x07UL) | ropenum | VGA_ENABLE;
+ MIO_QUAD(VGA_ROUTE) = tmp1;
+ }
+ }
+
+ /* Move on to master abort failure enablement */
+ tmp1 = MIO_QUAD((ropenum << 3) + LBA_PORT0_CNTRL) &
+ ~(LBA_RESET_FUNCTION | LBA_CLEAR_ERROR);
+ if ((tmp1 & LBA_HARD_FAIL) || (tmp2 & IOA_HARD_FAIL)) {
+ current |= PCI_PCI_BRIDGE_MASTER_ABORT_EN;
+ if ((mask & PCI_PCI_BRIDGE_MASTER_ABORT_EN) &&
+ !(value & PCI_PCI_BRIDGE_MASTER_ABORT_EN)) {
+ if (tmp1 & LBA_HARD_FAIL)
+ MIO_QUAD((ropenum << 3) + LBA_PORT0_CNTRL) =
+ tmp1 & ~LBA_HARD_FAIL;
+ if (tmp2 & IOA_HARD_FAIL) {
+ tmp2 &= ~IOA_HARD_FAIL;
+ IOA_QUAD(ropenum, IOA_CONTROL) = tmp2;
+ }
+ }
+ } else {
+ if (mask & value & PCI_PCI_BRIDGE_MASTER_ABORT_EN) {
+ if (!(tmp1 & LBA_HARD_FAIL))
+ MIO_QUAD((ropenum << 3) + LBA_PORT0_CNTRL) =
+ tmp1 | LBA_HARD_FAIL;
+ if (!(tmp2 & IOA_HARD_FAIL)) {
+ tmp2 |= IOA_HARD_FAIL;
+ IOA_QUAD(ropenum, IOA_CONTROL) = tmp2;
+ }
+ }
+ }
+
+ /* Put emulation of any other P2P bridge control here */
+ }
+
+ return (current & ~mask) | (value & mask);
+}
+
+/* Retrieves a list of the resources routed to a rope's secondary bus */
+static void
+GetZX1BridgeResources(int bus,
+ pointer *ppIoRes,
+ pointer *ppMemRes,
+ pointer *ppPmemRes)
+{
+ pciConfigPtr pPCI = VerifyZX1Bus(bus);
+
+ if (ppIoRes) {
+ xf86FreeResList(*ppIoRes);
+ *ppIoRes =
+ pPCI ? xf86DupResList(pZX1IoRes[pPCI->devnum & 0x07]) : NULL;
+ }
+
+ if (ppMemRes) {
+ xf86FreeResList(*ppMemRes);
+ *ppMemRes =
+ pPCI ? xf86DupResList(pZX1MemRes[pPCI->devnum & 0x07]) : NULL;
+ }
+
+ if (ppPmemRes) {
+ xf86FreeResList(*ppPmemRes);
+ *ppPmemRes = NULL;
+ }
+}
+
+/* The fake bus */
+static CARD32
+zx1FakeReadLong(PCITAG tag, int offset)
+{
+ FatalError("zx1FakeReadLong(0x%lX, 0x%X) called\n",
+ (unsigned long)tag, offset);
+}
+
+static void
+zx1FakeWriteLong(PCITAG tag, int offset, CARD32 val)
+{
+ FatalError("zx1FakeWriteLong(0x%lX, 0x%X, 0x%08X) called\n",
+ (unsigned long)tag, offset, val);
+}
+
+static void
+zx1FakeSetBits(PCITAG tag, int offset, CARD32 mask, CARD32 bits)
+{
+ CARD32 val;
+
+ val = zx1FakeReadLong(tag, offset);
+ val &= ~mask;
+ val |= bits;
+ zx1FakeWriteLong(tag, offset, val);
+}
+
+static pciBusFuncs_t zx1FakeBusFuncs = {
+ zx1FakeReadLong,
+ zx1FakeWriteLong,
+ zx1FakeSetBits
+};
+
+static pciBusInfo_t zx1FakeBus = {
+ 0, /* configMech -- copied from bus 0 */
+ 0, /* numDevices -- copied from bus 0 */
+ FALSE, /* secondary */
+ 0, /* primary_bus -- dynamically set */
+#ifdef PowerMAX_OS
+ 0, /* ppc_io_base -- ignored */
+ 0, /* ppc_io_size -- ignored */
+#endif
+ &zx1FakeBusFuncs, /* funcs */
+ NULL, /* pciBusPriv -- none */
+ NULL, /* bridge -- dynamically set */
+};
+
+void
+xf86PreScanZX1(void)
+{
+ resRange range;
+ unsigned long mapSize = xf86getpagesize();
+ unsigned long tmp, base, ioaaddr;
+ unsigned long flagsd, based, lastd, maskd, routed;
+ unsigned long flags0, base0, last0, mask0, route0;
+ unsigned long flags1, base1, last1, mask1, route1;
+ unsigned long flags2, base2, last2, mask2, route2;
+ unsigned long flags3, base3, last3, mask3, route3;
+ unsigned long flagsg, baseg, lastg, maskg, routeg;
+ unsigned long flagsl, basel, lastl;
+ int i, rope;
+
+ /* Map mio registers (minimum 8k) */
+ if (mapSize < MIO_SIZE)
+ mapSize = MIO_SIZE;
+
+ if (!(pZX1mio = xf86MapVidMem(-1, VIDMEM_MMIO, MIO_BASE, mapSize)))
+ return;
+
+ /* Look for ZX1's SBA and IOC */
+ if (((MIO_LONG(MIO_FUNCTION0 + PCI_ID_REG) !=
+ DEVID(VENDOR_HP, CHIP_ZX1_SBA)) ||
+ (MIO_LONG(MIO_FUNCTION1 + PCI_ID_REG) !=
+ DEVID(VENDOR_HP, CHIP_ZX1_IOC))) &&
+ ((MIO_LONG(MIO_FUNCTION0 + PCI_ID_REG) !=
+ DEVID(VENDOR_HP, CHIP_ZX2_SBA)) ||
+ (MIO_LONG(MIO_FUNCTION1 + PCI_ID_REG) !=
+ DEVID(VENDOR_HP, CHIP_ZX2_IOC)))) {
+ xf86UnMapVidMem(-1, pZX1mio, mapSize);
+ pZX1mio = NULL;
+ return;
+ }
+
+ /* Map rope configuration space */
+ ioaaddr = MIO_QUAD(ROPE_CONFIG_BASE);
+ if (!(ioaaddr & RANGE_ENABLE) || /* No ropes */
+ ((ioaaddr = ioaaddr & ~RANGE_ENABLE) & 0x01FFFFUL) || /* Not aligned */
+ !(pZX1ioa = xf86MapVidMem(-1, VIDMEM_MMIO, ioaaddr, IOA_SIZE))) {
+ xf86UnMapVidMem(-1, pZX1mio, mapSize);
+ pZX1mio = NULL;
+ return;
+ }
+
+ for (i = 0; i < 8; i++) {
+ zx1_ropemap[i] = i;
+ zx1_lbacntl[i] = 0;
+ xf86FreeResList(pZX1IoRes[i]);
+ xf86FreeResList(pZX1MemRes[i]);
+ pZX1IoRes[i] = pZX1MemRes[i] = NULL;
+ }
+
+ /*
+ * Determine which of 8 possible ropes exist in the system. This is done
+ * by looking at their "coupling" to generate a list of candidates,
+ * whittling this list down by factoring in ROPE_PAGE_CONTROL register
+ * contents, then poking each candidate's configuration space to determine
+ * its existence.
+ */
+ tmp = MIO_QUAD(ROPE_CONFIG);
+ if (tmp & ROPE_D0)
+ zx1_ropemap[1] = 0;
+ if (tmp & ROPE_D2)
+ zx1_ropemap[3] = 2;
+ if (tmp & ROPE_D4)
+ zx1_ropemap[5] = 4;
+ if (tmp & ROPE_D6)
+ zx1_ropemap[7] = 6;
+ if (tmp & ROPE_Q0)
+ zx1_ropemap[1] = zx1_ropemap[2] = zx1_ropemap[3] = 0;
+ if (tmp & ROPE_Q4)
+ zx1_ropemap[5] = zx1_ropemap[6] = zx1_ropemap[7] = 4;
+
+ /*
+ * zx2 should allow better probing support via hard-fails, so no need to
+ * use the ROPE_PAGE_CONTROL register. Also, zx2 always has ropes 3 & 7
+ * active regardless of bundling.
+ */
+ if (MIO_LONG(MIO_FUNCTION0 + PCI_ID_REG) !=
+ DEVID(VENDOR_HP, CHIP_ZX2_SBA)) {
+
+ tmp = MIO_QUAD(ROPE_PAGE_CONTROL);
+ for (i = 0; i < 8; i++, tmp >>= 8)
+ if (!(CARD8)tmp)
+ zx1_ropemap[i] = -1;
+ } else {
+ zx1_ropemap[3] = 3;
+ zx1_ropemap[7] = 7;
+ }
+
+ for (i = 0; i < 8; ) {
+ if (zx1_ropemap[i] == i) {
+
+ /* Prevent hard-fails */
+ zx1_lbacntl[i] = MIO_QUAD((i << 3) + LBA_PORT0_CNTRL) &
+ ~(LBA_RESET_FUNCTION | LBA_CLEAR_ERROR);
+ if (zx1_lbacntl[i] & LBA_HARD_FAIL)
+ MIO_QUAD((i << 3) + LBA_PORT0_CNTRL) =
+ zx1_lbacntl[i] & ~LBA_HARD_FAIL;
+
+ /* Poke for an ioa */
+ zx1_pciids[i] = IOA_LONG(i, PCI_ID_REG);
+ switch (zx1_pciids[i]) {
+ case DEVID(VENDOR_HP, CHIP_ELROY):
+ case DEVID(VENDOR_HP, CHIP_ZX1_LBA): /* Mercury */
+ case DEVID(VENDOR_HP, CHIP_ZX1_AGP8): /* QuickSilver */
+ case DEVID(VENDOR_HP, CHIP_ZX2_LBA):
+ /* Expected vendor/device IDs */
+ zx1_busno[i] =
+ (unsigned int)IOA_BYTE(i, IOA_SECONDARY_BUS);
+ zx1_subno[i] =
+ (unsigned int)IOA_BYTE(i, IOA_SUBORDINATE_BUS);
+ break;
+
+ default:
+ if ((CARD16)(zx1_pciids[i] + 1U) > (CARD16)1U)
+ xf86MsgVerb(X_NOTICE, 0,
+ "HP ZX1: Unexpected vendor/device id 0x%08X"
+ " on rope %d\n", zx1_pciids[i], i);
+ /* Nobody home, or not the "right" kind of rope guest */
+
+ /*
+ * Restore hard-fail setting. For "active" ropes, this is done
+ * later.
+ */
+ if (zx1_lbacntl[i] & LBA_HARD_FAIL) {
+ MIO_QUAD((i << 3) + LBA_PORT0_CNTRL) = zx1_lbacntl[i];
+ zx1_lbacntl[i] = 0;
+ }
+
+ /* Ignore this rope and its couplings */
+ do {
+ zx1_ropemap[i++] = -1;
+ } while ((i < 8) && (zx1_ropemap[i] < i));
+ continue; /* Avoid over-incrementing 'i' */
+ }
+ }
+ i++;
+ }
+
+ /* Determine if VGA is currently routed */
+ tmp = MIO_QUAD(VGA_ROUTE);
+ if (tmp & VGA_ENABLE)
+ zx1_hasvga = TRUE;
+
+ /*
+ * Decode mio resource "coarse" routing (i.e. ignoring VGA). Due to the
+ * rather unusual flexibility of this chipset, this is done in a number of
+ * stages. For each of I/O and memory, first decode the relevant registers
+ * to generate ranges with an associated granularity. Overlapping ranges
+ * are merged into a larger range with the finer granularity. Each
+ * original range is then more thoroughly decoded using the granularity
+ * associated with the merged range that contains it. The result is then
+ * converted into resource lists for the common layer.
+ *
+ * Note that this doesn't care whether or not read-only bits are actually
+ * set as documented, nor that mask bits are contiguous. This does,
+ * however, factor in upper limits on I/O, LMMIO anf GMMIO addresses, and
+ * thus assumes high-order address bits are ignored rather than decoded.
+ * For example, an I/O address of 0x76543210 will be treated as 0x3210
+ * rather than considered out-of-range. In part, this handling is a
+ * consequence of the fact that high-order mask bits are zeroes instead of
+ * ones.
+ */
+
+ flagsd = 0; based = 0; lastd = 0; maskd = 0; routed = 0;
+ flags0 = 0; base0 = 0; last0 = 0; mask0 = 0; route0 = 0;
+ flags1 = 0; base1 = 0; last1 = 0; mask1 = 0; route1 = 0;
+ flags2 = 0; base2 = 0; last2 = 0; mask2 = 0; route2 = 0;
+ flags3 = 0; base3 = 0; last3 = 0; mask3 = 0; route3 = 0;
+ flagsg = 0; baseg = 0; lastg = 0; maskg = 0; routeg = 0;
+ flagsl = 0; basel = 0; lastl = 0;
+
+ if ((tmp = MIO_QUAD(IOS_DIST_BASE)) & RANGE_ENABLE) {
+ flagsd = RANGE_ENABLE;
+ maskd = MIO_QUAD(IOS_DIST_MASK);
+ based = tmp & maskd & (~RANGE_ENABLE & IO_MASK);
+ lastd = based | (~maskd & IO_MASK);
+ routed = MIO_QUAD(IOS_DIST_ROUTE) >> 58;
+ SetRange(based, lastd, routed);
+ }
+
+ if ((tmp = MIO_QUAD(IOS_DIR_BASE)) & RANGE_ENABLE) {
+ flags0 = RANGE_ENABLE;
+ mask0 = MIO_QUAD(IOS_DIR_MASK);
+ base0 = tmp & mask0 & (~RANGE_ENABLE & IO_MASK);
+ last0 = base0 | (~mask0 & IO_MASK);
+ route0 = MIO_QUAD(IOS_DIR_ROUTE) & 0x07U;
+ SetRange(base0, last0, 64);
+ }
+
+ if (flagsd) {
+ i = GetRange(based);
+ for (tmp = based; tmp <= lastd; tmp += msk[i]) {
+ if ((tmp & maskd) == based) {
+ base = (tmp - bot[i]) / msk[i];
+ pDecode[i][base] = zx1_ropemap[(tmp >> routed) & 0x07U];
+ }
+ }
+
+ flagsd = 0;
+ }
+
+ if (flags0) {
+ i = GetRange(base0);
+ for (tmp = base0; tmp <= last0; tmp += msk[i]) {
+ if ((tmp & mask0) == base0) {
+ base = (tmp - bot[i]) / msk[i];
+ pDecode[i][base] = zx1_ropemap[route0];
+ }
+ }
+
+ flags0 = 0;
+ }
+
+ for (i = 0; i < nRange; i++) {
+ if (!pDecode[i])
+ continue;
+
+ rope = pDecode[i][0];
+ for (base = tmp = 0; ++tmp < siz[i]; ) {
+ if (rope == pDecode[i][tmp])
+ continue;
+
+ if (rope >= 0) {
+ RANGE(range, (base * msk[i]) + bot[i],
+ (tmp * msk[i]) + bot[i] - 1UL,
+ RANGE_TYPE(ResExcIoBlock, 0));
+ pZX1IoRes[rope] =
+ xf86AddResToList(pZX1IoRes[rope], &range, -1);
+ }
+
+ base = tmp;
+ rope = pDecode[i][base];
+ }
+
+ xfree(pDecode[i]);
+ pDecode[i] = NULL;
+ }
+
+ nRange = 0;
+
+ /*
+ * Move on to CPU memory access decoding. For now, don't tell the common
+ * layer about CPU memory ranges that are either relocated to 0 or
+ * translated into PCI I/O.
+ */
+
+ SetRange(MIO_BASE, MIO_BASE + MIO_SIZE - 1UL, 64); /* mio */
+ SetRange(ioaaddr, ioaaddr + ((IOA_SIZE << 1) - 1UL), 64); /* ioa */
+ SetRange(PDH_START, PDH_LAST, 64); /* PDH */
+
+ SetRange(MIO_BASE, LMMIO_MASK, 64); /* Completeness */
+
+ if ((tmp = MIO_QUAD(LMMIO_DIST_BASE)) & RANGE_ENABLE) {
+ flagsd = RANGE_ENABLE;
+ maskd = MIO_QUAD(LMMIO_DIST_MASK);
+ based = tmp & maskd & (~RANGE_ENABLE & LMMIO_MASK);
+ lastd = based | (~maskd & LMMIO_MASK);
+ routed = MIO_QUAD(LMMIO_DIST_ROUTE) >> 58;
+ SetRange(based, lastd, routed);
+ }
+
+ if ((tmp = MIO_QUAD(LMMIO_DIR_BASE0)) & RANGE_ENABLE) {
+ flags0 = RANGE_ENABLE;
+ mask0 = MIO_QUAD(LMMIO_DIR_MASK0);
+ base0 = tmp & mask0 & (~RANGE_ENABLE & LMMIO_MASK);
+ last0 = base0 | (~mask0 & LMMIO_MASK);
+ route0 = MIO_QUAD(LMMIO_DIR_ROUTE0) & 0x07U;
+ SetRange(base0, last0, 64);
+ }
+
+ if ((tmp = MIO_QUAD(LMMIO_DIR_BASE1)) & RANGE_ENABLE) {
+ flags1 = RANGE_ENABLE;
+ mask1 = MIO_QUAD(LMMIO_DIR_MASK1);
+ base1 = tmp & mask1 & (~RANGE_ENABLE & LMMIO_MASK);
+ last1 = base1 | (~mask1 & LMMIO_MASK);
+ route1 = MIO_QUAD(LMMIO_DIR_ROUTE1) & 0x07U;
+ SetRange(base1, last1, 64);
+ }
+
+ if ((tmp = MIO_QUAD(LMMIO_DIR_BASE2)) & RANGE_ENABLE) {
+ flags2 = RANGE_ENABLE;
+ mask2 = MIO_QUAD(LMMIO_DIR_MASK2);
+ base2 = tmp & mask2 & (~RANGE_ENABLE & LMMIO_MASK);
+ last2 = base2 | (~mask2 & LMMIO_MASK);
+ route2 = MIO_QUAD(LMMIO_DIR_ROUTE2) & 0x07U;
+ SetRange(base2, last2, 64);
+ }
+
+ if ((tmp = MIO_QUAD(LMMIO_DIR_BASE3)) & RANGE_ENABLE) {
+ flags3 = RANGE_ENABLE;
+ mask3 = MIO_QUAD(LMMIO_DIR_MASK3);
+ base3 = tmp & mask3 & (~RANGE_ENABLE & LMMIO_MASK);
+ last3 = base3 | (~mask3 & LMMIO_MASK);
+ route3 = MIO_QUAD(LMMIO_DIR_ROUTE3) & 0x07U;
+ SetRange(base3, last3, 64);
+ }
+
+ if ((tmp = MIO_QUAD(GMMIO_DIST_BASE)) & RANGE_ENABLE) {
+ flagsg = tmp & (RANGE_ENABLE | PORT_DISABLE | MAP_TO_LMMIO);
+ maskg = MIO_QUAD(GMMIO_DIST_MASK);
+ baseg = tmp & maskg &
+ (~(RANGE_ENABLE | PORT_DISABLE | MAP_TO_LMMIO) & GMMIO_MASK);
+ lastg = baseg | (~maskg & GMMIO_MASK);
+ tmp = routeg = MIO_QUAD(GMMIO_DIST_ROUTE) >> 58;
+ if (!(flagsg & (PORT_DISABLE & MAP_TO_LMMIO)) && (tmp > 26))
+ tmp = 26;
+ SetRange(baseg, lastg, tmp);
+ }
+
+ if ((tmp = MIO_QUAD(IOS_BASE)) & RANGE_ENABLE) {
+ flagsl = RANGE_ENABLE;
+ basel = tmp & (~RANGE_ENABLE & GMMIO_MASK);
+ lastl = basel | 0x001FFFFFUL;
+ SetRange(basel, lastl, 64);
+ }
+
+ if (flagsd) {
+ i = GetRange(based);
+ for (tmp = based; tmp <= lastd; tmp += msk[i]) {
+ if ((tmp & maskd) == based) {
+ base = (tmp - bot[i]) / msk[i];
+ pDecode[i][base] = zx1_ropemap[(tmp >> routed) & 0x07U];
+ }
+ }
+
+ flagsd = 0;
+ }
+
+ /* LMMIO distributed range does not address anything beyond 0xFED00000 */
+ i = GetRange(MIO_BASE);
+ for (tmp = MIO_BASE; tmp <= LMMIO_MASK; tmp += msk[i]) {
+ base = (tmp - bot[i]) / msk[i];
+ pDecode[i][base] = -1;
+ }
+
+ /* Dillon space can sometimes be redirected to rope 0 */
+ tmp = MIO_QUAD(STATUS_CONTROL);
+ if (!(tmp & DILLON_PRESENT)) {
+ i = GetRange(PDH_START);
+ for (tmp = PDH_START; tmp <= PDH_LAST; tmp += msk[i]) {
+ base = (tmp - bot[i]) / msk[i];
+ pDecode[i][base] = zx1_ropemap[0];
+ }
+ }
+
+ if (flagsg) {
+ unsigned long mask = (0x07UL << routeg) | maskg;
+
+ i = GetRange(baseg);
+ for (tmp = baseg; tmp <= lastg; tmp += msk[i]) {
+ if ((tmp & maskg) == baseg) {
+ base = (tmp - bot[i]) / msk[i];
+
+ if ((flagsg & MAP_TO_LMMIO) ||
+ (!(flagsg & PORT_DISABLE) &&
+ (tmp <= ((tmp & mask) | 0x03FFFFFFUL)))) {
+ pDecode[i][base] = -1;
+ } else {
+ pDecode[i][base] = zx1_ropemap[(tmp >> routeg) & 0x07U];
+ }
+ }
+ }
+
+ flagsg = 0;
+ }
+
+ if (flagsl) {
+ i = GetRange(basel);
+ for (tmp = basel; tmp <= lastl; tmp += msk[i]) {
+ base = (tmp - bot[i]) / msk[i];
+ pDecode[i][base] = -1;
+ }
+
+ flagsl = 0;
+ }
+
+ /* For now, assume directed LMMIO ranges don't overlap with each other */
+ if (flags0) {
+ i = GetRange(base0);
+ for (tmp = base0; tmp <= last0; tmp += msk[i]) {
+ if ((tmp & mask0) == base0) {
+ base = (tmp - bot[i]) / msk[i];
+ pDecode[i][base] = zx1_ropemap[route0];
+ }
+ }
+
+ flags0 = 0;
+ }
+
+ if (flags1) {
+ i = GetRange(base1);
+ for (tmp = base1; tmp <= last1; tmp += msk[i]) {
+ if ((tmp & mask1) == base1) {
+ base = (tmp - bot[i]) / msk[i];
+ pDecode[i][base] = zx1_ropemap[route1];
+ }
+ }
+
+ flags1 = 0;
+ }
+
+ if (flags2) {
+ i = GetRange(base2);
+ for (tmp = base2; tmp <= last2; tmp += msk[i]) {
+ if ((tmp & mask2) == base2) {
+ base = (tmp - bot[i]) / msk[i];
+ pDecode[i][base] = zx1_ropemap[route2];
+ }
+ }
+
+ flags2 = 0;
+ }
+
+ if (flags3) {
+ i = GetRange(base3);
+ for (tmp = base3; tmp <= last3; tmp += msk[i]) {
+ if ((tmp & mask3) == base3) {
+ base = (tmp - bot[i]) / msk[i];
+ pDecode[i][base] = zx1_ropemap[route3];
+ }
+ }
+
+ flags3 = 0;
+ }
+
+ /* Claim iao config area */
+ i = GetRange(ioaaddr);
+ for (tmp = ioaaddr; tmp < ioaaddr + (IOA_SIZE << 1); tmp += msk[i]) {
+ base = (tmp - bot[i]) / msk[i];
+ pDecode[i][base] = -1;
+ }
+
+ /* Claim mio config area */
+ i = GetRange(MIO_BASE);
+ for (tmp = MIO_BASE; tmp < (MIO_BASE + MIO_SIZE); tmp += msk[i]) {
+ base = (tmp - bot[i]) / msk[i];
+ pDecode[i][base] = -1;
+ }
+
+ for (i = 0; i < nRange; i++) {
+ if (!pDecode[i])
+ continue;
+
+ rope = pDecode[i][0];
+ for (base = tmp = 0; ++tmp < siz[i]; ) {
+ if (rope == pDecode[i][tmp])
+ continue;
+
+ if (rope >= 0) {
+ RANGE(range, (base * msk[i]) + bot[i],
+ (tmp * msk[i]) + bot[i] - 1UL,
+ RANGE_TYPE(ResExcMemBlock, 0));
+ pZX1MemRes[rope] =
+ xf86AddResToList(pZX1MemRes[rope], &range, -1);
+ }
+
+ base = tmp;
+ rope = pDecode[i][base];
+ }
+
+ xfree(pDecode[i]);
+ pDecode[i] = NULL;
+ }
+
+ nRange = 0;
+
+ return;
+}
+
+/* This is called to finalise the results of a PCI bus scan */
+void
+xf86PostScanZX1(void)
+{
+ pciConfigPtr pPCI, *ppPCI, *ppPCI2;
+ pciBusInfo_t *pBusInfo;
+ int i, idx;
+
+ if (!pZX1mio)
+ return;
+
+ (void)memset(zx1_busnmpt, FALSE, sizeof(zx1_busnmpt));
+ pBusInfo = pciBusInfo[0];
+
+ /*
+ * Certain 2.4 & 2.5 Linux kernels add fake PCI devices. Remove them to
+ * prevent any possible interference with our PCI validation.
+ *
+ * Also, if VGA isn't routed on server entry, determine if VGA routing
+ * needs to be enabled while the server is running.
+ */
+ idx = 0;
+ ppPCI = ppPCI2 = xf86scanpci(0); /* Recursion is only apparent */
+ while ((pPCI = *ppPCI2++)) {
+ switch (pPCI->pci_device_vendor) {
+ case DEVID(VENDOR_HP, CHIP_ELROY):
+ case DEVID(VENDOR_HP, CHIP_ZX1_SBA): /* Pluto function 0 */
+ case DEVID(VENDOR_HP, CHIP_ZX1_IOC): /* Pluto function 1 */
+ case DEVID(VENDOR_HP, CHIP_ZX1_LBA): /* Mercury */
+ case DEVID(VENDOR_HP, CHIP_ZX1_AGP8): /* QuickSilver */
+ case DEVID(VENDOR_HP, CHIP_ZX2_SBA):
+ case DEVID(VENDOR_HP, CHIP_ZX2_IOC):
+ case DEVID(VENDOR_HP, CHIP_ZX2_LBA):
+ xfree(pPCI); /* Remove it */
+ continue;
+
+ default:
+ *ppPCI++ = pPCI;
+ idx++;
+
+ zx1_busnmpt[pPCI->busnum] = TRUE;
+
+ if (zx1_hasvga)
+ continue;
+
+ switch (pPCI->pci_base_class) {
+ case PCI_CLASS_PREHISTORIC:
+ if (pPCI->pci_sub_class == PCI_SUBCLASS_PREHISTORIC_VGA)
+ break;
+ continue;
+
+ case PCI_CLASS_DISPLAY:
+ if (pPCI->pci_sub_class == PCI_SUBCLASS_DISPLAY_VGA)
+ break;
+ continue;
+
+ default:
+ continue;
+ }
+
+ zx1_hasvga = TRUE;
+ continue;
+ }
+ }
+
+ /*
+ * Restore hard-fail settings and figure out the actual secondary and
+ * subordinate bus numbers.
+ */
+ for (i = 0; i < 8; i++) {
+ if (zx1_ropemap[i] != i)
+ continue;
+
+ if (zx1_lbacntl[i] & LBA_HARD_FAIL)
+ MIO_QUAD((i << 3) + LBA_PORT0_CNTRL) = zx1_lbacntl[i];
+
+ while ((zx1_busno[i] < zx1_subno[i]) && !pciBusInfo[zx1_subno[i]])
+ zx1_subno[i]--;
+
+ if (zx1_fakebus <= zx1_subno[i])
+ zx1_fakebus = zx1_subno[i] + 1;
+
+ while (!zx1_busnmpt[zx1_busno[i]]) {
+ if (zx1_busno[i]) /* Info for bus zero is in static storage */
+ xfree(pciBusInfo[zx1_busno[i]]);
+ pciBusInfo[zx1_busno[i]++] = NULL;
+ if (zx1_busno[i] > zx1_subno[i])
+ break;
+ }
+ }
+
+ if (zx1_fakebus >= pciNumBuses) {
+ if (zx1_fakebus >= pciMaxBusNum)
+ FatalError("HP ZX1: No room for fake PCI bus\n");
+ pciNumBuses = zx1_fakebus + 1;
+ }
+
+ /* Set up our extra bus functions */
+ zx1BusFuncs = *(pBusInfo->funcs);
+ zx1BusFuncs.pciControlBridge = ControlZX1Bridge;
+ zx1BusFuncs.pciGetBridgeResources = GetZX1BridgeResources;
+
+ /* Set up our own fake bus to act as the root segment */
+ zx1FakeBus.configMech = pBusInfo->configMech;
+ zx1FakeBus.numDevices = pBusInfo->numDevices;
+ zx1FakeBus.primary_bus = zx1_fakebus;
+ pciBusInfo[zx1_fakebus] = &zx1FakeBus;
+
+ /* Add the fake bus' host bridge */
+ if (++idx >= MAX_PCI_DEVICES)
+ FatalError("HP ZX1: No room for fake Host-to-PCI bridge\n");
+ *ppPCI++ = zx1FakeBus.bridge = pPCI = xnfcalloc(1, sizeof(pciDevice));
+ pPCI->tag = PCI_MAKE_TAG(zx1_fakebus, 0, 0);
+ pPCI->busnum = zx1_fakebus;
+ /* pPCI->devnum = pPCI->funcnum = 0; */
+ pPCI->pci_device_vendor = DEVID(VENDOR_HP, CHIP_ZX1_SBA);
+ pPCI->pci_base_class = PCI_CLASS_BRIDGE;
+ /* pPCI->pci_sub_class = PCI_SUBCLASS_BRIDGE_HOST; */
+ pPCI->fakeDevice = TRUE;
+
+#ifdef OLD_FORMAT
+ xf86MsgVerb(X_INFO, 2, "PCI: BusID 0x%.2x,0x%02x,0x%1x "
+ "ID 0x%04x,0x%04x Rev 0x%02x Class 0x%02x,0x%02x\n",
+ pPCI->busnum, pPCI->devnum, pPCI->funcnum,
+ pPCI->pci_vendor, pPCI->pci_device, pPCI->pci_rev_id,
+ pPCI->pci_base_class, pPCI->pci_sub_class);
+#else
+ xf86MsgVerb(X_INFO, 2, "PCI: %.2x:%02x:%1x: chip %04x,%04x"
+ " card %04x,%04x rev %02x class %02x,%02x,%02x hdr %02x\n",
+ pPCI->busnum, pPCI->devnum, pPCI->funcnum,
+ pPCI->pci_vendor, pPCI->pci_device,
+ pPCI->pci_subsys_vendor, pPCI->pci_subsys_card,
+ pPCI->pci_rev_id, pPCI->pci_base_class,
+ pPCI->pci_sub_class, pPCI->pci_prog_if,
+ pPCI->pci_header_type);
+#endif
+
+ /* Add a fake PCI-to-PCI bridge to represent each active rope */
+ for (i = 0; i < 8; i++) {
+ if ((zx1_ropemap[i] != i) || (zx1_busno[i] > zx1_subno[i]) ||
+ !(pBusInfo = pciBusInfo[zx1_busno[i]]))
+ continue;
+
+ if (++idx >= MAX_PCI_DEVICES)
+ FatalError("HP ZX1: No room for fake PCI-to-PCI bridge\n");
+ *ppPCI++ = pPCI = xnfcalloc(1, sizeof(pciDevice));
+ pPCI->busnum = zx1_fakebus;
+ pPCI->devnum = i | 0x10;
+ /* pPCI->funcnum = 0; */
+ pPCI->tag = PCI_MAKE_TAG(zx1_fakebus, pPCI->devnum, 0);
+ pPCI->pci_device_vendor = zx1_pciids[i];
+ pPCI->pci_base_class = PCI_CLASS_BRIDGE;
+ pPCI->pci_sub_class = PCI_SUBCLASS_BRIDGE_PCI;
+ pPCI->pci_header_type = 1;
+ pPCI->pci_primary_bus_number = zx1_fakebus;
+ pPCI->pci_secondary_bus_number = zx1_busno[i];
+ pPCI->pci_subordinate_bus_number = zx1_subno[i];
+ pPCI->fakeDevice = TRUE;
+
+ pBusInfo->bridge = pPCI;
+ pBusInfo->secondary = TRUE;
+ pBusInfo->primary_bus = zx1_fakebus;
+
+ /* Plug in chipset routines */
+ pBusInfo->funcs = &zx1BusFuncs;
+
+ /* Set bridge control register for scanpci utility */
+ pPCI->pci_bridge_control = ControlZX1Bridge(zx1_busno[i], 0, 0);
+
+#ifdef OLD_FORMAT
+ xf86MsgVerb(X_INFO, 2, "PCI: BusID 0x%.2x,0x%02x,0x%1x "
+ "ID 0x%04x,0x%04x Rev 0x%02x Class 0x%02x,0x%02x\n",
+ pPCI->busnum, pPCI->devnum, pPCI->funcnum,
+ pPCI->pci_vendor, pPCI->pci_device, pPCI->pci_rev_id,
+ pPCI->pci_base_class, pPCI->pci_sub_class);
+#else
+ xf86MsgVerb(X_INFO, 2, "PCI: %.2x:%02x:%1x: chip %04x,%04x"
+ " card %04x,%04x rev %02x class %02x,%02x,%02x hdr %02x\n",
+ pPCI->busnum, pPCI->devnum, pPCI->funcnum,
+ pPCI->pci_vendor, pPCI->pci_device,
+ pPCI->pci_subsys_vendor, pPCI->pci_subsys_card,
+ pPCI->pci_rev_id, pPCI->pci_base_class,
+ pPCI->pci_sub_class, pPCI->pci_prog_if,
+ pPCI->pci_header_type);
+#endif
+ }
+
+ *ppPCI = NULL; /* Terminate array */
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/zx1PCI.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/zx1PCI.h
new file mode 100644
index 000000000..2795b4459
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bus/zx1PCI.h
@@ -0,0 +1,40 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/zx1PCI.h,v 1.1 2003/02/23 20:26:49 tsi Exp $ */
+/*
+ * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef PCI_ZX1_H
+#define PCI_ZX1_H 1
+
+#include <X11/Xdefs.h>
+
+void xf86PreScanZX1(void);
+void xf86PostScanZX1(void);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile
new file mode 100644
index 000000000..261bd6bab
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile
@@ -0,0 +1,35 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile,v 1.8 2002/10/11 01:46:59 dawes Exp $
+#include <Server.tmpl>
+
+BIOS_MOD = bios_DGmmap
+
+SRCS = dgux_init.c dgux_video.c IO_utils.c dgux_io.c $(BIOS_MOD).c VTsw_noop.c \
+ dgux_kbd.c dgux_kbdEv.c dgux_tty.c std_mouse.c std_mseEv.c \
+ stdResource.c stdPci.c sigiostubs.c pm_noop.c kmod_noop.c agp_noop.c
+
+OBJS = dgux_init.o dgux_video.o IO_utils.o dgux_io.o $(BIOS_MOD).o VTsw_noop.o \
+ dgux_kbd.o dgux_kbdEv.o dgux_tty.o std_mouse.o std_mseEv.o \
+ stdResource.o stdPci.o sigiostubs.o pm_noop.o kmod_noop.o agp_noop.o
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+RESDEFINES = -DUSESTDRES
+
+DEFINES = $(RESDEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+LinkSourceFile(VTsw_noop,../shared)
+LinkSourceFile(IO_utils,../shared)
+LinkSourceFile(std_mouse,../shared)
+LinkSourceFile(std_mseEv,../shared)
+LinkSourceFile(stdResource.c,../shared)
+LinkSourceFile(stdPci.c,../shared)
+LinkSourceFile(sigiostubs.c,../shared)
+LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
+LinkSourceFile(agp_noop.c,../shared)
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/bios_DGmmap.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/bios_DGmmap.c
new file mode 100644
index 000000000..95aad7a12
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/bios_DGmmap.c
@@ -0,0 +1,70 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/bios_DGmmap.c,v 1.3 2000/02/11 22:36:02 dawes Exp $ */
+/*
+ * INTEL DG/UX RELEASE 4.20 MU03
+ * Copyright 1997 Takis Psarogiannakopoulos Cambridge,UK
+ * <takis@dpmms.cam.ac.uk>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ * XCONSORTIUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FITNESS, IN NO EVENT SHALL XCONSORTIUM BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+/*
+ * Read the BIOS via mmap() to the device /dev/mem.
+ */
+int xf86ReadBIOS(Base, Offset, Buf, Len)
+unsigned long Base;
+unsigned long Offset;
+unsigned char *Buf;
+int Len;
+{
+ int fd;
+ unsigned char *ptr;
+ int psize;
+ int mlen;
+
+ if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
+ {
+ ErrorF("xf86ReadBios: Failed to open %s (%s)\n", DEV_MEM,
+ strerror(errno));
+ return(-1);
+ }
+ psize = xf86getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, MAP_SHARED,
+ fd, (off_t)Base);
+ if ((int)ptr == -1)
+ {
+ ErrorF("xf86ReadBios: %s mmap failed\n", DEV_MEM);
+ close(fd);
+ return(-1);
+ }
+ (void)memcpy(Buf, (void *)(ptr + Offset), Len);
+ (void)munmap((caddr_t)ptr, mlen);
+ (void)close(fd);
+ return(Len);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_init.c
new file mode 100644
index 000000000..b7282a004
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_init.c
@@ -0,0 +1,182 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_init.c,v 1.1 1998/12/13 07:37:46 dawes Exp $ */
+/*
+ * INTEL DG/UX RELEASE 4.20 MU03
+ * Copyright 1997 Takis Psarogiannakopoulos Cambridge,UK
+ * <takis@dpmms.cam.ac.uk>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ * XCONSORTIUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FITNESS, IN NO EVENT SHALL XCONSORTIUM BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+
+static Bool KeepTty = FALSE;
+static Bool Protect0 = FALSE;
+static int VTnum = -1;
+
+extern void xf86VTRequest(
+ int
+);
+
+void xf86OpenConsole()
+{
+ int i;
+ int fd;
+ char vtname[14];
+
+ if (serverGeneration == 1)
+ {
+ /* check if we're run with euid==0 */
+ if (geteuid() != 0)
+ {
+ FatalError("xf86OpenConsole: Server must be suid root\n");
+ }
+ if (Protect0)
+ {
+ int fd = -1;
+
+ if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0)
+ {
+ ErrorF("xf86OpenConsole: cannot open /dev/zero (%s)\n",
+ strerror(errno));
+ }
+ else
+ {
+ if ((int)mmap(0, 0x1000, PROT_NONE,
+ MAP_FIXED | MAP_SHARED, fd, 0) == -1)
+ {
+ ErrorF("xf86OpenConsole: failed to protect page 0 (%s)\n",
+ strerror(errno));
+ }
+ close(fd);
+ }
+ }
+ if (VTnum != -1)
+ {
+ xf86Info.vtno = VTnum;
+ }
+ else
+ {
+ if ((fd = open("/dev/console",O_WRONLY,0)) < 0)
+ {
+ FatalError(
+ "xf86OpenConsole: Cannot open system tty (/dev/console), (%s)\n",
+ strerror(errno));
+ }
+ close(fd);
+ }
+ xf86Info.vtno=0;
+ ErrorF(" (Intel DG/ux: using VT number: systty%d)\n\n", xf86Info.vtno);
+
+ sprintf(vtname,"/dev/console");
+
+ xf86Config(FALSE); /* Read XF86Config */
+
+ if (!KeepTty)
+ {
+ setpgrp();
+ }
+
+ if ((xf86Info.consoleFd = open("/dev/console", O_RDWR|O_NDELAY, 0)) < 0)
+ {
+ FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
+ vtname, strerror(errno));
+ }
+
+
+
+ if ((xf86Info.kbdFd = open("/dev/keybd", O_RDONLY|O_NDELAY, 0)) < 0)
+ {
+ FatalError("xf86OpenConsole: Cannot open keyboard (/dev/keybd), (%s)\n", strerror(errno));
+ }
+ /* change ownerships and Grab all other system consoles */
+ chown(vtname, getuid(), getgid());
+ chown("/dev/syscon", getuid(), getgid());
+ chown("/dev/systty", getuid(), getgid());
+ if (!KeepTty)
+ {
+ /*
+ * Detach from the controlling tty to avoid char loss
+ */
+ if ((i = open("/dev/tty",O_RDWR)) >= 0)
+ {
+ ioctl(i, TIOCNOTTY, 0);
+ close(i);
+ }
+ }
+ }
+ else
+ {
+ /* serverGeneration != 1 */
+ if (!xf86VTSema)
+ sleep(5);
+ }
+ return;
+}
+
+void xf86CloseConsole()
+{
+ close(xf86Info.kbdFd); /* Close the keyboard */
+ close(xf86Info.consoleFd); /* Close the system console */
+ return;
+}
+
+int xf86ProcessArgument(argc, argv, i)
+int argc;
+char *argv[];
+int i;
+{
+ if (!strcmp(argv[i], "-keeptty"))
+ {
+ KeepTty = TRUE;
+ return(1);
+ }
+ if (!strcmp(argv[i], "-protect0"))
+ {
+ Protect0 = TRUE;
+ return(1);
+ }
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+ {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
+ {
+ UseMsg();
+ VTnum = -1;
+ return(0);
+ }
+ return(1);
+ }
+ return(0);
+}
+
+void xf86UseMsg()
+{
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_io.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_io.c
new file mode 100644
index 000000000..b66051f63
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_io.c
@@ -0,0 +1,96 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_io.c,v 1.3 2002/10/11 01:40:34 dawes Exp $ */
+/*
+ * INTEL DG/UX RELEASE 4.20 MU03
+ * Copyright 1997 Takis Psarogiannakopoulos Cambridge,UK
+ * <takis@dpmms.cam.ac.uk>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ * XCONSORTIUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FITNESS, IN NO EVENT SHALL XCONSORTIUM BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+
+
+
+void xf86SoundKbdBell(loudness, pitch, duration)
+int loudness;
+int pitch;
+int duration;
+{
+ if (loudness && pitch)
+ {
+
+ /*
+ * We use KBD_TONE_HIGH to avoid putting the server
+ * to sleep
+ */
+ ioctl(xf86Info.kbdFd, KBD_TONE_HIGH,
+ ((1193190 / pitch) & 0xffff) |
+ (((unsigned long)duration *
+ loudness / 50) << 16));
+
+ }
+}
+
+
+
+void xf86MouseInit(mouse)
+MouseDevPtr mouse;
+{
+ return;
+}
+
+
+
+/* Added for DG/ux: only RDONLY will not crash the Xserver */
+int xf86MouseOn(mouse)
+MouseDevPtr mouse;
+{
+ if ((mouse->mseFd = open(mouse->mseDevice, O_RDONLY|O_NDELAY)) < 0)
+ {
+ if (xf86Info.allowMouseOpenFail) {
+ ErrorF("Cannot open mouse (%s) - Continuing...\n",
+ strerror(errno));
+ return(-2);
+ }
+ FatalError("Cannot open mouse (%s)\n", strerror(errno));
+ }
+
+ xf86SetupMouse(mouse);
+
+ /* Flush any pending input */
+ ioctl(mouse->mseFd, TCFLSH, 0);
+ return(mouse->mseFd);
+}
+
+#include "xf86OSKbd.h"
+
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+ return FALSE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_kbd.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_kbd.c
new file mode 100644
index 000000000..7c25fb390
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_kbd.c
@@ -0,0 +1,120 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_kbd.c,v 1.1 1998/12/13 07:37:46 dawes Exp $ */
+/*
+ * INTEL DG/UX RELEASE 4.20 MU03
+ * Copyright 1997 Takis Psarogiannakopoulos Cambridge,UK
+ * <takis@dpmms.cam.ac.uk>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ * XCONSORTIUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FITNESS, IN NO EVENT SHALL XCONSORTIUM BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/* *Contents*
+
+ 1 xf86KbdSetLeds
+ 2 xf86KbdGetLeds
+ 3 xf86SetKbdRepeat
+ 4 xf86KbdInit()
+ 5 xf86KbdOn()
+ 6 xf86KbdOff()
+
+*/
+
+
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+
+
+static struct termios kbdtty;
+
+
+/* ADDED FOR INTEL DGUX */
+void xf86SetKbdLeds(leds)
+int leds;
+{
+ ioctl(xf86Info.kbdFd, KBD_SET_LED, leds);
+}
+
+
+
+/* ADDED FOR INTEL DGUX */
+int xf86GetKbdLeds()
+{
+ int leds;
+
+ ioctl(xf86Info.kbdFd, KBD_GET_STATE, &leds);
+ return(leds);
+}
+
+/* ADDED FOR INTEL DGUX */
+void xf86SetKbdRepeat(char rad)
+{
+ return;
+}
+
+
+
+
+/* ADDED FOR INTEL DGUX */
+
+void xf86KbdInit()
+{
+ tcgetattr(xf86Info.kbdFd, &kbdtty);
+}
+
+
+
+
+
+/* ADDED FOR INTEL DGUX */
+
+int xf86KbdOn()
+{
+ struct termios nTty;
+
+ nTty = kbdtty;
+ nTty.c_iflag = IGNPAR | IGNBRK;
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME] = 0;
+ nTty.c_cc[VMIN] = 1;
+ cfsetispeed(&nTty, 9600);
+ cfsetospeed(&nTty, 9600);
+ tcsetattr(xf86Info.kbdFd, TCSANOW, &nTty);
+ return(xf86Info.kbdFd);
+}
+
+
+
+
+
+/* Intel DG/ux */
+int xf86KbdOff()
+{
+ tcsetattr(xf86Info.kbdFd, TCSANOW, &kbdtty);
+ return(xf86Info.kbdFd);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_kbdEv.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_kbdEv.c
new file mode 100644
index 000000000..1651f20d8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_kbdEv.c
@@ -0,0 +1,47 @@
+/* $XFree86$ */
+/*
+ * INTEL DG/UX RELEASE 4.20 MU02
+ * Copyright 1997 Takis Psarogiannakopoulos Cambridge,UK
+ * <takis@dpmms.cam.ac.uk>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ * XCONSORTIUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FITNESS, IN NO EVENT SHALL XCONSORTIUM BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+
+void xf86KbdEvents()
+{
+ unsigned char rBuf[64];
+ int nBytes, i;
+
+ if ((nBytes = read( xf86Info.kbdFd, (char *)rBuf, sizeof(rBuf))) > 0)
+ {
+ for (i = 0; i < nBytes; i++)
+ xf86PostKbdEvent(rBuf[i]);
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_tty.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_tty.c
new file mode 100644
index 000000000..b6dee0421
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_tty.c
@@ -0,0 +1,175 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_tty.c,v 1.1 1998/12/13 07:37:47 dawes Exp $ */
+/*
+ * INTEL DG/UX RELEASE 4.20 MU03
+ * Copyright 1997 Takis Psarogiannakopoulos Cambridge,UK
+ * <takis@dpmms.cam.ac.uk>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ * XCONSORTIUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FITNESS, IN NO EVENT SHALL XCONSORTIUM BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* BSD (POSIX) Flavor tty for ix86 DG/ux R4.20MU03 */
+
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+#include "xf86_Config.h"
+
+static Bool not_a_tty = FALSE;
+
+void xf86SetMouseSpeed(mouse, old, new, cflag)
+MouseDevPtr mouse;
+int old;
+int new;
+unsigned cflag;
+{
+ struct termios tty;
+ char *c;
+
+ if (not_a_tty)
+ return;
+
+ if (tcgetattr(mouse->mseFd, &tty) < 0)
+ {
+ not_a_tty = TRUE;
+ ErrorF("Warning: %s unable to get status of mouse fd (%s)\n",
+ mouse->mseDevice, strerror(errno));
+ return;
+ }
+
+ /* this will query the initial baudrate only once */
+ if (mouse->oldBaudRate < 0) {
+ switch (cfgetispeed(&tty))
+ {
+ case B9600:
+ mouse->oldBaudRate = 9600;
+ break;
+ case B4800:
+ mouse->oldBaudRate = 4800;
+ break;
+ case B2400:
+ mouse->oldBaudRate = 2400;
+ break;
+ case B1200:
+ default:
+ mouse->oldBaudRate = 1200;
+ break;
+ }
+ }
+
+ tty.c_iflag = IGNBRK | IGNPAR;
+ tty.c_oflag = 0;
+ tty.c_lflag = 0;
+ tty.c_cflag = (tcflag_t)cflag;
+ tty.c_cc[VTIME] = 0;
+ tty.c_cc[VMIN] = 1;
+
+ switch (old)
+ {
+ case 9600:
+ cfsetispeed(&tty, B9600);
+ cfsetospeed(&tty, B9600);
+ break;
+ case 4800:
+ cfsetispeed(&tty, B4800);
+ cfsetospeed(&tty, B4800);
+ break;
+ case 2400:
+ cfsetispeed(&tty, B2400);
+ cfsetospeed(&tty, B2400);
+ break;
+ case 1200:
+ default:
+ cfsetispeed(&tty, B1200);
+ cfsetospeed(&tty, B1200);
+ }
+
+ if (tcsetattr(mouse->mseFd, TCSADRAIN, &tty) < 0)
+ {
+ if (xf86Info.allowMouseOpenFail) {
+ ErrorF("Unable to set status of mouse fd (%s) - Continuing...\n",
+ strerror(errno));
+ return;
+ }
+ xf86FatalError("Unable to set status of mouse fd (%s)\n",
+ strerror(errno));
+ }
+
+ switch (new)
+ {
+ case 9600:
+ c = "*q";
+ cfsetispeed(&tty, B9600);
+ cfsetospeed(&tty, B9600);
+ break;
+ case 4800:
+ c = "*p";
+ cfsetispeed(&tty, B4800);
+ cfsetospeed(&tty, B4800);
+ break;
+ case 2400:
+ c = "*o";
+ cfsetispeed(&tty, B2400);
+ cfsetospeed(&tty, B2400);
+ break;
+ case 1200:
+ default:
+ c = "*n";
+ cfsetispeed(&tty, B1200);
+ cfsetospeed(&tty, B1200);
+ }
+
+ if (mouse->mseType == P_LOGIMAN || mouse->mseType == P_LOGI)
+ {
+ if (write(mouse->mseFd, c, 2) != 2)
+ {
+ if (xf86AllowMouseOpenFail) {
+ ErrorF("Unable to write to mouse fd (%s) - Continuing...\n",
+ strerror(errno));
+ return;
+ }
+ xf86FatalError("Unable to write to mouse fd (%s)\n",
+ strerror(errno));
+ }
+ }
+ usleep(100000);
+
+ if (tcsetattr(mouse->mseFd, TCSADRAIN, &tty) < 0)
+ {
+ if (xf86AllowMouseOpenFail) {
+ ErrorF("Unable to set status of mouse fd (%s) - Continuing...\n",
+ strerror(errno));
+ return;
+ }
+ xf86FatalError("Unable to set status of mouse fd (%s)\n",
+ strerror(errno));
+ }
+}
+
+/* ADDED FOR X 3.3.2.3 */
+int
+xf86FlushInput(fd)
+int fd;
+{
+ return tcflush(fd, TCIFLUSH);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c
new file mode 100644
index 000000000..25336d68a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c
@@ -0,0 +1,441 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c,v 1.6tsi Exp $ */
+/*
+ * INTEL DG/UX RELEASE 4.20 MU03
+ * Copyright 1997 Takis Psarogiannakopoulos Cambridge,UK
+ * <takis@dpmms.cam.ac.uk>
+ *
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ * XFREE86 PROJECT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FITNESS, IN NO EVENT SHALL XCONSORTIUM BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+/* Stuff for the SET_IOPL() ,RESET_IOPL() */
+/* #include <fcntl.h> */
+static int io_takis;
+int set_takis;
+
+
+/***************************************************************************/
+/* SET_IOPL() and RESET_IOPL() section for ix86 DG/ux 4.20MU03 */
+/***************************************************************************/
+
+
+int SET_IOPL()
+{
+ io_takis=open("/dev/console", O_RDWR,0);
+ if ((io_takis) < 0)
+ {
+ return(-1);
+ }
+ set_takis = ioctl(io_takis,KDENABIO,0);
+
+ if (set_takis < 0)
+ {
+ return(-1);
+ }
+ return(1);
+}
+
+
+
+
+void RESET_IOPL()
+{
+
+ ioctl(io_takis,KDDISABIO,0);
+ close(io_takis);
+ return;
+
+}
+
+/***************************************************************************/
+/* DG/ux Video Memory Mapping part */
+/***************************************************************************/
+
+#undef HAS_SVR3_MMAPDRV /* ix86 DG/ux is a typical SVR4 without SVR3_MMAPDRV */
+
+Bool xf86LinearVidMem()
+{
+ return(TRUE);
+}
+
+pointer
+xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size)
+{
+ pointer base;
+ int fd;
+
+ fd = open(DEV_MEM, (Flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
+ if (fd < 0)
+ {
+ FatalError("xf86MapVidMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ base = mmap((caddr_t)0, Size,
+ (Flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_SHARED, fd, (off_t)Base);
+ close(fd);
+ if (base == MAP_FAILED)
+ {
+ FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
+ "xf86MapVidMem", Size, Base, strerror(errno));
+ }
+
+ return(base);
+}
+
+void xf86UnMapVidMem(ScreenNum, Region, Base, Size)
+int ScreenNum;
+int Region;
+pointer Base;
+unsigned long Size;
+{
+ munmap(Base, Size);
+}
+
+/***************************************************************************/
+/* I/O Permissions section */
+/***************************************************************************/
+
+#define ALWAYS_USE_EXTENDED
+#ifdef ALWAYS_USE_EXTENDED
+
+static Bool ScreenEnabled[MAXSCREENS];
+static Bool ExtendedEnabled = FALSE;
+static Bool InitDone = FALSE;
+
+void
+xf86ClearIOPortList(ScreenNum)
+int ScreenNum;
+{
+ if (!InitDone)
+ {
+ int i;
+ for (i = 0; i < MAXSCREENS; i++)
+ ScreenEnabled[i] = FALSE;
+ InitDone = TRUE;
+ }
+ return;
+}
+
+void
+xf86AddIOPorts(ScreenNum, NumPorts, Ports)
+int ScreenNum;
+int NumPorts;
+unsigned *Ports;
+{
+ return;
+}
+
+void
+xf86EnableIOPorts(ScreenNum)
+int ScreenNum;
+{
+ int i;
+
+ ScreenEnabled[ScreenNum] = TRUE;
+
+ if (ExtendedEnabled)
+ return;
+
+ if (SET_IOPL() < 0)
+ {
+ FatalError("%s: Failed to set IOPL for extended I/O\n",
+ "xf86EnableIOPorts");
+ }
+ ExtendedEnabled = TRUE;
+
+ return;
+}
+
+void
+xf86DisableIOPorts(ScreenNum)
+int ScreenNum;
+{
+ int i;
+
+ ScreenEnabled[ScreenNum] = FALSE;
+
+ if (!ExtendedEnabled)
+ return;
+
+ for (i = 0; i < MAXSCREENS; i++)
+ if (ScreenEnabled[i])
+ return;
+
+ RESET_IOPL();
+ ExtendedEnabled = FALSE;
+
+ return;
+}
+
+#else /* !ALWAYS_USE_EXTENDED */
+
+#define DISABLED 0
+#define NON_EXTENDED 1
+#define EXTENDED 2
+
+static unsigned *EnabledPorts[MAXSCREENS];
+static int NumEnabledPorts[MAXSCREENS];
+static Bool ScreenEnabled[MAXSCREENS];
+static Bool ExtendedPorts[MAXSCREENS];
+static Bool ExtendedEnabled = FALSE;
+static Bool InitDone = FALSE;
+static struct kd_disparam OrigParams;
+
+void xf86ClearIOPortList(ScreenNum)
+int ScreenNum;
+{
+ if (!InitDone)
+ {
+ xf86InitPortLists(EnabledPorts, NumEnabledPorts, ScreenEnabled,
+ ExtendedPorts, MAXSCREENS);
+ if (ioctl(xf86Info.consoleFd, KDDISPTYPE, &OrigParams) < 0)
+ {
+ FatalError("%s: Could not get display parameters\n",
+ "xf86ClearIOPortList");
+ }
+ InitDone = TRUE;
+ return;
+ }
+ ExtendedPorts[ScreenNum] = FALSE;
+ if (EnabledPorts[ScreenNum] != (unsigned *)NULL)
+ xfree(EnabledPorts[ScreenNum]);
+ EnabledPorts[ScreenNum] = (unsigned *)NULL;
+ NumEnabledPorts[ScreenNum] = 0;
+}
+
+void xf86AddIOPorts(ScreenNum, NumPorts, Ports)
+int ScreenNum;
+int NumPorts;
+unsigned *Ports;
+{
+ int i;
+
+ if (!InitDone)
+ {
+ FatalError("xf86AddIOPorts: I/O control lists not initialised\n");
+ }
+ EnabledPorts[ScreenNum] = xrealloc(EnabledPorts[ScreenNum],
+ (NumEnabledPorts[ScreenNum]+NumPorts)*sizeof(unsigned));
+ for (i = 0; i < NumPorts; i++)
+ {
+ EnabledPorts[ScreenNum][NumEnabledPorts[ScreenNum] + i] =
+ Ports[i];
+ if (Ports[i] > 0x3FF)
+ ExtendedPorts[ScreenNum] = TRUE;
+ }
+ NumEnabledPorts[ScreenNum] += NumPorts;
+}
+
+void xf86EnableIOPorts(ScreenNum)
+int ScreenNum;
+{
+ struct kd_disparam param;
+ int i, j;
+
+ if (ScreenEnabled[ScreenNum])
+ return;
+
+ for (i = 0; i < MAXSCREENS; i++)
+ {
+ if (ExtendedPorts[i] && (ScreenEnabled[i] || i == ScreenNum))
+ {
+ if (SET_IOPL() < 0)
+ {
+ FatalError("%s: Failed to set IOPL for extended I/O\n",
+ "xf86EnableIOPorts");
+ }
+ ExtendedEnabled = TRUE;
+ break;
+ }
+ }
+ if (ExtendedEnabled && i == MAXSCREENS)
+ {
+ RESET_IOPL();
+ ExtendedEnabled = FALSE;
+ }
+ if (ioctl(xf86Info.consoleFd, KDDISPTYPE, &param) < 0)
+ {
+ FatalError("%s: Could not get display parameters\n",
+ "xf86EnableIOPorts");
+ }
+ for (i = 0; i < NumEnabledPorts[ScreenNum]; i++)
+ {
+ unsigned port = EnabledPorts[ScreenNum][i];
+
+ if (port > 0x3FF)
+ continue;
+
+ if (!xf86CheckPorts(port, EnabledPorts, NumEnabledPorts,
+ ScreenEnabled, MAXSCREENS))
+ {
+ continue;
+ }
+ for (j=0; j < MKDIOADDR; j++)
+ {
+ if (param.ioaddr[j] == port)
+ {
+ break;
+ }
+ }
+ if (j == MKDIOADDR)
+ {
+ if (ioctl(xf86Info.consoleFd, KDADDIO, port) < 0)
+ {
+ FatalError("%s: Failed to enable port 0x%x\n",
+ "xf86EnableIOPorts", port);
+ }
+ }
+ }
+ if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
+ {
+ FatalError("xf86EnableIOPorts: I/O port enable failed (%s)\n",
+ strerror(errno));
+ }
+ ScreenEnabled[ScreenNum] = TRUE;
+ return;
+}
+
+void xf86DisableIOPorts(ScreenNum)
+int ScreenNum;
+{
+ struct kd_disparam param;
+ int i, j;
+
+ if (!ScreenEnabled[ScreenNum])
+ return;
+
+ ScreenEnabled[ScreenNum] = FALSE;
+ for (i = 0; i < MAXSCREENS; i++)
+ {
+ if (ScreenEnabled[i] && ExtendedPorts[i])
+ break;
+ }
+ if (ExtendedEnabled && i == MAXSCREENS)
+ {
+ RESET_IOPL();
+ ExtendedEnabled = FALSE;
+ }
+ /* Turn off I/O before changing the access list */
+ ioctl(xf86Info.consoleFd, KDDISABIO, 0);
+ if (ioctl(xf86Info.consoleFd, KDDISPTYPE, &param) < 0)
+ {
+ ErrorF("%s: Could not get display parameters\n",
+ "xf86DisableIOPorts");
+ return;
+ }
+
+ for (i=0; i < MKDIOADDR; i++)
+ {
+ if (param.ioaddr[i] == 0)
+ {
+ break;
+ }
+ if (!xf86CheckPorts(param.ioaddr[i], EnabledPorts,
+ NumEnabledPorts, ScreenEnabled, MAXSCREENS))
+ {
+ continue;
+ }
+ for (j=0; j < MKDIOADDR; j++)
+ {
+ if (param.ioaddr[i] == OrigParams.ioaddr[j])
+ {
+ /*
+ * Port was one of the original ones; don't
+ * touch it.
+ */
+ break;
+ }
+ }
+ if (j == MKDIOADDR)
+ {
+ /*
+ * We added this port, so remove it.
+ */
+ ioctl(xf86Info.consoleFd, KDDELIO, param.ioaddr[i]);
+ }
+ }
+ for (i = 0; i < MAXSCREENS; i++)
+ {
+ if (ScreenEnabled[i])
+ {
+ ioctl(xf86Info.consoleFd, KDENABIO, 0);
+ break;
+ }
+ }
+ return;
+}
+#endif
+
+void xf86DisableIOPrivs()
+{
+ if (ExtendedEnabled)
+ RESET_IOPL();
+ return;
+}
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+
+Bool xf86DisableInterrupts()
+{
+
+#ifdef __GNUC__
+ __asm__ __volatile__("cli");
+#else
+ asm("cli");
+#endif /* __GNUC__ */
+
+ return(TRUE);
+}
+
+void xf86EnableInterrupts()
+{
+
+#ifdef __GNUC__
+ __asm__ __volatile__("sti");
+#else
+ asm("sti");
+#endif /* __GNUC__ */
+
+ return;
+}
+
+
+void
+xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base,
+ unsigned long Size)
+{
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile
new file mode 100644
index 000000000..7716ed348
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile
@@ -0,0 +1,40 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile,v 1.14 2002/10/11 01:46:59 dawes Exp $
+
+#include <Server.tmpl>
+
+BIOS_MOD = bios_mmap
+
+MOUSESRC = hurd_mouse.c
+MOUSEOBJ = hurd_mouse.o
+
+SRCS = hurd_init.c hurd_video.c hurd_io.c libc_wrapper.c $(BIOS_MOD).c \
+ VTsw_noop.c posix_tty.c $(MOUSESRC) \
+ stdResource.c stdPci.c sigiostubs.c pm_noop.c kmod_noop.c agp_noop.c
+
+OBJS = hurd_init.o hurd_video.o hurd_io.o libc_wrapper.o $(BIOS_MOD).o \
+ VTsw_noop.o posix_tty.o $(MOUSEOBJ) \
+ stdResource.o stdPci.o sigiostubs.o pm_noop.o kmod_noop.o agp_noop.o
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/mi
+
+RESDEFINES = -DUSESTDRES
+
+DEFINES = $(RESDEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+
+LinkSourceFile(VTsw_noop.c,../shared)
+LinkSourceFile(posix_tty.c,../shared)
+LinkSourceFile(libc_wrapper.c,../shared)
+LinkSourceFile(stdResource.c,../shared)
+LinkSourceFile(stdPci.c,../shared)
+LinkSourceFile(sigiostubs.c,../shared)
+LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
+LinkSourceFile(agp_noop.c,../shared)
+
+DependTarget()
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/bios_mmap.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/bios_mmap.c
new file mode 100644
index 000000000..132e755e2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/bios_mmap.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright 1997 by UCHIYAMA Yasushi
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of UCHIYAMA Yasushi not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. UCHIYAMA Yasushi makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86$ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include<mach.h>
+#include<device/device.h>
+
+#include <X11/X.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#define BIOS_SIZE 0x20000
+
+int
+xf86ReadBIOS(unsigned long Base,unsigned long Offset,unsigned char *Buf,int Len)
+{
+ mach_port_t device,iopl_dev;
+ memory_object_t iopl_mem;
+ vm_address_t addr = (vm_address_t)0; /* serach starting address */
+ kern_return_t err;
+
+
+ err = get_privileged_ports (NULL, &device);
+ if( err )
+ {
+ errno = err;
+ FatalError("xf86ReadBIOS() can't get_privileged_ports. (%s)\n",strerror(errno));
+ }
+ err = device_open(device,D_READ|D_WRITE,"iopl",&iopl_dev);
+ mach_port_deallocate (mach_task_self (), device);
+ if( err )
+ {
+ errno = err;
+ FatalError("xf86ReadBIOS() can't device_open. (%s)\n",strerror(errno));
+ }
+ err = device_map(iopl_dev,VM_PROT_READ|VM_PROT_WRITE, Base , BIOS_SIZE ,&iopl_mem,0);
+ if( err )
+ {
+ errno = err;
+ FatalError("xf86ReadBIOS() can't device_map. (%s)\n",strerror(errno));
+ }
+ err = vm_map(mach_task_self(),
+ &addr,
+ BIOS_SIZE,
+ 0,
+ TRUE,
+ iopl_mem,
+ Base,
+ FALSE,
+ VM_PROT_READ|VM_PROT_WRITE,
+ VM_PROT_READ|VM_PROT_WRITE,
+ VM_INHERIT_SHARE);
+ mach_port_deallocate(mach_task_self(),iopl_mem);
+ if( err )
+ {
+ errno = err;
+ FatalError("xf86ReadBIOS() can't vm_map. (%s)\n",strerror(errno));
+ }
+
+ memcpy(Buf,(void*)((int)addr + Offset), Len);
+
+ err = vm_deallocate(mach_task_self(), addr, BIOS_SIZE);
+ if( err )
+ {
+ errno = err;
+ FatalError("xf86ReadBIOS() can't vm_deallocate. (%s)\n",strerror(errno));
+ }
+
+ return Len;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_init.c
new file mode 100644
index 000000000..aec5b3d46
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_init.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright 1997,1998 by UCHIYAMA Yasushi
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of UCHIYAMA Yasushi not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. UCHIYAMA Yasushi makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_init.c,v 1.1 1998/08/16 10:25:48 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include <stdio.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <sys/file.h>
+#include <assert.h>
+#include <mach.h>
+
+int
+xf86ProcessArgument( int argc,char **argv, int i )
+{
+ return 0;
+}
+void
+xf86UseMsg()
+{
+ return;
+}
+
+
+void
+xf86OpenConsole()
+{
+ if( serverGeneration == 1 )
+ {
+ kern_return_t err;
+ mach_port_t device;
+ int fd;
+ err = get_privileged_ports( NULL, &device );
+ if( err )
+ {
+ errno = err;
+ FatalError( "xf86KbdInit can't get_privileged_ports. (%s)\n" , strerror(errno) );
+ }
+ mach_port_deallocate (mach_task_self (), device);
+
+ if( ( fd = open( "/dev/kbd" , O_RDONLY|O_NONBLOCK ) ) < 0 )
+ {
+ fprintf( stderr , "Cannot open keyboard (%s)\n",strerror(errno) );
+ exit(1);
+ }
+ xf86Info.consoleFd = fd;
+ }
+ return;
+}
+
+void
+xf86CloseConsole()
+{
+ close( xf86Info.consoleFd );
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_io.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_io.c
new file mode 100644
index 000000000..32b4bc71d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_io.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright 1997,1998 by UCHIYAMA Yasushi
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of UCHIYAMA Yasushi not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. UCHIYAMA Yasushi makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_io.c,v 1.8 2002/10/11 01:40:35 dawes Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "mipointer.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include <stdio.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <sys/file.h>
+#include <assert.h>
+#include <mach.h>
+#include <sys/ioctl.h>
+
+typedef unsigned short kev_type; /* kd event type */
+typedef unsigned char Scancode;
+
+struct mouse_motion {
+ short mm_deltaX; /* units? */
+ short mm_deltaY;
+};
+
+typedef struct {
+ kev_type type; /* see below */
+ struct timeval time; /* timestamp */
+ union { /* value associated with event */
+ boolean_t up; /* MOUSE_LEFT .. MOUSE_RIGHT */
+ Scancode sc; /* KEYBD_EVENT */
+ struct mouse_motion mmotion; /* MOUSE_MOTION */
+ } value;
+} kd_event;
+
+/*
+ * kd_event ID's.
+ */
+#define MOUSE_LEFT 1 /* mouse left button up/down */
+#define MOUSE_MIDDLE 2
+#define MOUSE_RIGHT 3
+#define MOUSE_MOTION 4 /* mouse motion */
+#define KEYBD_EVENT 5 /* key up/down */
+
+/***********************************************************************
+ * Keyboard
+ **********************************************************************/
+void
+xf86SoundKbdBell(int loudness,int pitch,int duration)
+{
+ return;
+}
+
+void
+xf86SetKbdLeds(int leds)
+{
+ return;
+}
+
+int
+xf86GetKbdLeds()
+{
+ return 0;
+}
+
+void
+xf86SetKbdRepeat(char rad)
+{
+ return;
+}
+
+void
+xf86KbdInit()
+{
+ return;
+}
+int
+xf86KbdOn()
+{
+ int data = 1;
+ if( ioctl( xf86Info.consoleFd, _IOW('k', 1, int),&data) < 0)
+ FatalError("Cannot set event mode on keyboard (%s)\n",strerror(errno));
+ return xf86Info.consoleFd;
+}
+int
+xf86KbdOff()
+{
+ int data = 2;
+ if( ioctl( xf86Info.consoleFd, _IOW('k', 1, int),&data) < 0)
+ FatalError("can't reset keyboard mode (%s)\n",strerror(errno));
+}
+
+void
+xf86KbdEvents()
+{
+ kd_event ke;
+ while( read(xf86Info.consoleFd, &ke, sizeof(ke)) == sizeof(ke) )
+ xf86PostKbdEvent(ke.value.sc);
+}
+
+#include "xf86OSKbd.h"
+
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+ return FALSE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_mouse.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_mouse.c
new file mode 100644
index 000000000..84a5c46da
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_mouse.c
@@ -0,0 +1,300 @@
+/*
+ * Copyright 1997,1998 by UCHIYAMA Yasushi
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of UCHIYAMA Yasushi not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. UCHIYAMA Yasushi makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_mouse.c,v 1.7 2000/02/10 22:33:44 dawes Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "mipointer.h"
+
+#include "xf86.h"
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+#include "xf86_OSlib.h"
+
+#include <stdio.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <sys/file.h>
+#include <assert.h>
+#include <mach.h>
+#include <sys/ioctl.h>
+
+typedef unsigned short kev_type; /* kd event type */
+typedef unsigned char Scancode;
+
+struct mouse_motion {
+ short mm_deltaX; /* units? */
+ short mm_deltaY;
+};
+
+typedef struct {
+ kev_type type; /* see below */
+ struct timeval time; /* timestamp */
+ union { /* value associated with event */
+ boolean_t up; /* MOUSE_LEFT .. MOUSE_RIGHT */
+ Scancode sc; /* KEYBD_EVENT */
+ struct mouse_motion mmotion; /* MOUSE_MOTION */
+ } value;
+} kd_event;
+
+/*
+ * kd_event ID's.
+ */
+#define MOUSE_LEFT 1 /* mouse left button up/down */
+#define MOUSE_MIDDLE 2
+#define MOUSE_RIGHT 3
+#define MOUSE_MOTION 4 /* mouse motion */
+#define KEYBD_EVENT 5 /* key up/down */
+
+#define NUMEVENTS 64
+
+/*
+ * OsMouseProc --
+ * Handle the initialization, etc. of a mouse
+ */
+static int
+OsMouseProc(DeviceIntPtr pPointer, int what)
+{
+ InputInfoPtr pInfo;
+ MouseDevPtr pMse;
+ unsigned char map[MSE_MAXBUTTONS + 1];
+ int nbuttons;
+
+ pInfo = pPointer->public.devicePrivate;
+ pMse = pInfo->private;
+ pMse->device = pPointer;
+
+ switch (what) {
+ case DEVICE_INIT:
+ pPointer->public.on = FALSE;
+
+ for (nbuttons = 0; nbuttons < MSE_MAXBUTTONS; ++nbuttons)
+ map[nbuttons + 1] = nbuttons + 1;
+
+ InitPointerDeviceStruct((DevicePtr)pPointer,
+ map,
+ min(pMse->buttons, MSE_MAXBUTTONS),
+ miPointerGetMotionEvents,
+ pMse->Ctrl,
+ miPointerGetMotionBufferSize());
+
+ /* X valuator */
+ xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 0);
+ /* Y valuator */
+ xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 1);
+ xf86MotionHistoryAllocate(pInfo);
+ break;
+
+ case DEVICE_ON:
+ pInfo->fd = xf86OpenSerial(pInfo->options);
+ if (pInfo->fd == -1)
+ xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
+ else {
+ pMse->buffer = XisbNew(pInfo->fd,
+ NUMEVENTS * sizeof(kd_event));
+ if (!pMse->buffer) {
+ xfree(pMse);
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ } else {
+ xf86FlushInput(pInfo->fd);
+ AddEnabledDevice(pInfo->fd);
+ }
+ }
+ pMse->lastButtons = 0;
+ pMse->lastMappedButtons = 0;
+ pMse->emulateState = 0;
+ pPointer->public.on = TRUE;
+ break;
+
+ case DEVICE_OFF:
+ case DEVICE_CLOSE:
+ if (pInfo->fd != -1) {
+ RemoveEnabledDevice(pInfo->fd);
+ if (pMse->buffer) {
+ XisbFree(pMse->buffer);
+ pMse->buffer = NULL;
+ }
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ }
+ pPointer->public.on = FALSE;
+ usleep(300000);
+ break;
+ }
+ return Success;
+}
+
+/*
+ * OsMouseReadInput --
+ * Get some events from our queue. Process all outstanding events now.
+ */
+static void
+OsMouseReadInput(InputInfoPtr pInfo)
+{
+ MouseDevPtr pMse;
+ static kd_event eventList[NUMEVENTS];
+ int n, c;
+ kd_event *event = eventList;
+ unsigned char *pBuf;
+
+ pMse = pInfo->private;
+
+ XisbBlockDuration(pMse->buffer, -1);
+ pBuf = (unsigned char *)eventList;
+ n = 0;
+ while ((c = XisbRead(pMse->buffer)) >= 0 && n < sizeof(eventList))
+ pBuf[n++] = (unsigned char)c;
+
+ if (n == 0)
+ return;
+
+ n /= sizeof(kd_event);
+ while( n-- ) {
+ int buttons = pMse->lastButtons;
+ int dx = 0, dy = 0;
+ switch (event->type) {
+ case MOUSE_RIGHT:
+ buttons = buttons & 6 |(event->value.up ? 0 : 1);
+ break;
+ case MOUSE_MIDDLE:
+ buttons = buttons & 5 |(event->value.up ? 0 : 2);
+ break;
+ case MOUSE_LEFT:
+ buttons = buttons & 3 |(event->value.up ? 0 : 4) ;
+ break;
+ case MOUSE_MOTION:
+ dx = event->value.mmotion.mm_deltaX;
+ dy = - event->value.mmotion.mm_deltaY;
+ break;
+ default:
+ ErrorF("Bad mouse event (%d)\n",event->type);
+ continue;
+ }
+ pMse->PostEvent(pInfo, buttons, dx, dy, 0, 0);
+ ++event;
+ }
+ return;
+}
+
+static Bool
+OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ MouseDevPtr pMse;
+
+ /* This is called when the protocol is "OSMouse". */
+
+ pMse = pInfo->private;
+ pMse->protocol = protocol;
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
+
+ /* Collect the options, and process the common options. */
+ xf86CollectInputOptions(pInfo, NULL, NULL);
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
+
+ /* Check if the device can be opened. */
+ pInfo->fd = xf86OpenSerial(pInfo->options);
+ if (pInfo->fd == -1) {
+ if (xf86GetAllowMouseOpenFail())
+ xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
+ else {
+ xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
+ xfree(pMse);
+ return FALSE;
+ }
+ }
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+
+ /* Process common mouse options (like Emulate3Buttons, etc). */
+ pMse->CommonOptions(pInfo);
+
+ /* Setup the local procs. */
+ pInfo->device_control = OsMouseProc;
+ pInfo->read_input = OsMouseReadInput;
+
+ pInfo->flags |= XI86_CONFIGURED;
+ return TRUE;
+}
+
+static int
+SupportedInterfaces(void)
+{
+ /* XXX Need to check this. */
+ return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_AUTO;
+}
+
+static const char *internalNames[] = {
+ "OSMouse",
+ NULL
+};
+
+static const char **
+BuiltinNames(void)
+{
+ return internalNames;
+}
+
+static Bool
+CheckProtocol(const char *protocol)
+{
+ int i;
+
+ for (i = 0; internalNames[i]; i++)
+ if (xf86NameCmp(protocol, internalNames[i]) == 0)
+ return TRUE;
+ return FALSE;
+}
+
+/* XXX Is this appropriate? If not, this function should be removed. */
+static const char *
+DefaultProtocol(void)
+{
+ return "OSMouse";
+}
+
+OSMouseInfoPtr
+xf86OSMouseInit(int flags)
+{
+ OSMouseInfoPtr p;
+
+ p = xcalloc(sizeof(OSMouseInfoRec), 1);
+ if (!p)
+ return NULL;
+ p->SupportedInterfaces = SupportedInterfaces;
+ p->BuiltinNames = BuiltinNames;
+ p->DefaultProtocol = DefaultProtocol;
+ p->CheckProtocol = CheckProtocol;
+ p->PreInit = OsMousePreInit;
+ return p;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_video.c
new file mode 100644
index 000000000..ecb8df1db
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_video.c
@@ -0,0 +1,181 @@
+/*
+ * Copyright 1997, 1998 by UCHIYAMA Yasushi
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of UCHIYAMA Yasushi not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. UCHIYAMA Yasushi makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_video.c,v 1.3 1999/04/29 12:24:52 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <mach.h>
+#include <device/device.h>
+
+#include <X11/X.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+/**************************************************************************
+ * Video Memory Mapping section
+ ***************************************************************************/
+pointer
+xf86MapVidMem(int ScreenNum,int Flags, unsigned long Base, unsigned long Size)
+{
+ mach_port_t device,iopl_dev;
+ memory_object_t iopl_mem;
+ kern_return_t err;
+ vm_address_t addr=(vm_address_t)0;
+
+ err = get_privileged_ports (NULL, &device);
+ if( err )
+ {
+ errno = err;
+ FatalError("xf86MapVidMem() can't get_privileged_ports. (%s)\n",strerror(errno));
+ }
+ err = device_open(device,D_READ|D_WRITE,"iopl",&iopl_dev);
+ mach_port_deallocate (mach_task_self(), device);
+ if( err )
+ {
+ errno = err;
+ FatalError("xf86MapVidMem() can't device_open. (%s)\n",strerror(errno));
+ }
+
+ err = device_map(iopl_dev,VM_PROT_READ|VM_PROT_WRITE, Base , Size ,&iopl_mem,0);
+ if( err )
+ {
+ errno = err;
+ FatalError("xf86MapVidMem() can't device_map. (%s)\n",strerror(errno));
+ }
+ err = vm_map(mach_task_self(),
+ &addr,
+ Size,
+ 0, /* mask */
+ TRUE, /* anywhere */
+ iopl_mem,
+ (vm_offset_t)Base,
+ FALSE, /* copy on write */
+ VM_PROT_READ|VM_PROT_WRITE,
+ VM_PROT_READ|VM_PROT_WRITE,
+ VM_INHERIT_SHARE);
+ mach_port_deallocate(mach_task_self(),iopl_mem);
+ if( err )
+ {
+ errno = err;
+ FatalError("xf86MapVidMem() can't vm_map.(iopl_mem) (%s)\n",strerror(errno));
+ }
+ mach_port_deallocate(mach_task_self(),iopl_dev);
+ if( err )
+ {
+ errno = err;
+ FatalError("xf86MapVidMem() can't mach_port_deallocate.(iopl_dev) (%s)\n",strerror(errno));
+ }
+ return (pointer)addr;
+}
+
+void
+xf86UnMapVidMem(int ScreenNum,pointer Base,unsigned long Size)
+{
+ kern_return_t err = vm_deallocate(mach_task_self(), (int)Base, Size);
+ if( err )
+ {
+ errno = err;
+ ErrorF("xf86UnMapVidMem: can't dealloc framebuffer space (%s)\n",strerror(errno));
+ }
+ return;
+}
+
+Bool
+xf86LinearVidMem()
+{
+ return(TRUE);
+}
+
+/**************************************************************************
+ * I/O Permissions section
+ ***************************************************************************/
+Bool
+xf86EnableIO()
+{
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ return;
+}
+
+void
+xf86ClearIOPortList(int ScreenNum)
+{
+ return;
+}
+void
+xf86AddIOPorts(int ScreenNum,int NumPorts,unsigned int *Ports)
+{
+ return;
+}
+void
+xf86EnableIOPorts(int ScreenNum)
+{
+ return;
+}
+
+void
+xf86DisableIOPorts(int ScreenNum)
+{
+ return;
+}
+void
+xf86DisableIOPrivs()
+{
+ return;
+}
+/**************************************************************************
+ * Interrupt Handling section
+ **************************************************************************/
+Bool
+xf86DisableInterrupts()
+{
+ return TRUE;
+}
+void
+xf86EnableInterrupts()
+{
+ return;
+}
+
+void
+xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base,
+ unsigned long Size)
+{
+}
+
+Bool
+xf86CheckMTRR(int s)
+{
+ return FALSE;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/int10Defines.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/int10Defines.h
new file mode 100644
index 000000000..56e10cf67
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/int10Defines.h
@@ -0,0 +1,90 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/int10Defines.h,v 1.4 2003/08/24 17:37:03 dawes Exp $ */
+/*
+ * Copyright (c) 2000-2001 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _INT10DEFINES_H_
+#define _INT10DEFINES_H_ 1
+
+#ifdef _VM86_LINUX
+
+#include <asm/vm86.h>
+
+#define CPU_R(type,name,num) \
+ (((type *)&(((struct vm86_struct *)REG->cpuRegs)->regs.name))[num])
+#define CPU_RD(name,num) CPU_R(CARD32,name,num)
+#define CPU_RW(name,num) CPU_R(CARD16,name,num)
+#define CPU_RB(name,num) CPU_R(CARD8,name,num)
+
+#define X86_EAX CPU_RD(eax,0)
+#define X86_EBX CPU_RD(ebx,0)
+#define X86_ECX CPU_RD(ecx,0)
+#define X86_EDX CPU_RD(edx,0)
+#define X86_ESI CPU_RD(esi,0)
+#define X86_EDI CPU_RD(edi,0)
+#define X86_EBP CPU_RD(ebp,0)
+#define X86_EIP CPU_RD(eip,0)
+#define X86_ESP CPU_RD(esp,0)
+#define X86_EFLAGS CPU_RD(eflags,0)
+
+#define X86_FLAGS CPU_RW(eflags,0)
+#define X86_AX CPU_RW(eax,0)
+#define X86_BX CPU_RW(ebx,0)
+#define X86_CX CPU_RW(ecx,0)
+#define X86_DX CPU_RW(edx,0)
+#define X86_SI CPU_RW(esi,0)
+#define X86_DI CPU_RW(edi,0)
+#define X86_BP CPU_RW(ebp,0)
+#define X86_IP CPU_RW(eip,0)
+#define X86_SP CPU_RW(esp,0)
+#define X86_CS CPU_RW(cs,0)
+#define X86_DS CPU_RW(ds,0)
+#define X86_ES CPU_RW(es,0)
+#define X86_SS CPU_RW(ss,0)
+#define X86_FS CPU_RW(fs,0)
+#define X86_GS CPU_RW(gs,0)
+
+#define X86_AL CPU_RB(eax,0)
+#define X86_BL CPU_RB(ebx,0)
+#define X86_CL CPU_RB(ecx,0)
+#define X86_DL CPU_RB(edx,0)
+
+#define X86_AH CPU_RB(eax,1)
+#define X86_BH CPU_RB(ebx,1)
+#define X86_CH CPU_RB(ecx,1)
+#define X86_DH CPU_RB(edx,1)
+
+#elif defined(_X86EMU)
+
+#include "xf86x86emu.h"
+
+#endif
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/Imakefile
new file mode 100644
index 000000000..8ef246842
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/Imakefile
@@ -0,0 +1,142 @@
+XCOMM $XConsortium: Imakefile /main/10 1996/10/19 18:06:19 kaleb $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/Imakefile,v 3.45 2002/09/16 18:06:13 eich Exp $
+
+#include <Server.tmpl>
+
+#if BuildXInputExt
+# if JoystickSupport
+ JOYSTICK_SRC = lnx_jstk.c
+# endif
+# if DoLoadableServer
+SHARED_CFLAGS = PositionIndependentCFlags
+# else
+# if JoystickSupport
+ JOYSTICK_OBJ = lnx_jstk.o
+# endif
+# endif
+#endif
+
+#if HasMTRRSupport
+MTRRDEFINES = -DHAS_MTRR_SUPPORT
+#endif
+
+DRI_SRC = sigio.c
+DRI_OBJ = sigio.o
+
+MOUSESRC = lnx_mouse.c
+MOUSEOBJ = lnx_mouse.o
+
+KBDSRC = lnx_kbd.c lnx_KbdMap.c at_scancode.c
+KBDOBJ = lnx_kbd.o lnx_KbdMap.o at_scancode.o
+
+#if defined(i386Architecture) || defined(ia64Architecture) || defined(AMD64Architecture)
+RES_SRCS=stdResource.c
+RES_OBJS=stdResource.o
+#else
+RES_SRCS=lnxResource.c
+RES_OBJS=lnxResource.o
+#endif
+
+#if defined(AlphaArchitecture)
+PLATFORM_SRC=lnx_ev56.c xf86Axp.c lnx_axp.c
+PLATFORM_OBJ=lnx_ev56.o xf86Axp.o lnx_axp.o
+#endif
+#if defined (ia64Architecture)
+PLATFORM_SRC=ia64Pci.c lnx_ia64.c
+PLATFORM_OBJ=ia64Pci.o lnx_ia64.o
+PLATFORM_DEFINES=-DOS_PROBE_PCI_CHIPSET=lnxProbePciChipset
+#endif
+
+#if DoOSFontRestore
+FONTSRC=lnx_font.c
+FONTOBJ=lnx_font.o
+# ifndef FontRestoreCheckOsVersion
+# define FontRestoreCheckOsVersion YES
+# endif
+FONT_DEFINES=-DDO_OS_FONTRESTORE -DCHECK_OS_VERSION=FontRestoreCheckOsVersion
+#endif
+
+SRCS = lnx_init.c lnx_video.c lnx_io.c libc_wrapper.c bios_mmap.c \
+ VTsw_usl.c std_kbdEv.c posix_tty.c lnx_acpi.c $(MOUSESRC) \
+ lnx_pci.c vidmem.c lnx_apm.c $(JOYSTICK_SRC) $(DRI_SRC) $(RES_SRCS) \
+ $(PLATFORM_SRC) lnx_kmod.c lnx_agp.c $(FONTSRC) $(KBDSRC) /*wcHelper.c*/
+
+OBJS = lnx_init.o lnx_video.o lnx_io.o libc_wrapper.o bios_mmap.o \
+ VTsw_usl.o std_kbdEv.o posix_tty.o lnx_acpi.o $(MOUSEOBJ) \
+ lnx_pci.o vidmem.o lnx_apm.o $(JOYSTICK_OBJ) $(DRI_OBJ) $(RES_OBJS) \
+ $(PLATFORM_OBJ) lnx_kmod.o lnx_agp.o $(FONTOBJ) $(KBDOBJ) /*wcHelper.o*/
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(XF86OSSRC)/shared \
+ -I$(XF86OSSRC)/bus -I$(DRMSRCDIR)/shared-core
+
+RESDEFINES = -DUSESTDRES
+
+DEFINES = $(MTRRDEFINES) $(RESDEFINES) $(PLATFORM_DEFINES) $(FONT_DEFINES) -DHAVE_SYSV_IPC
+
+#if defined(AlphaArchitecture)
+SpecialObjectRule(lnx_ev56.o, lnx_ev56.c, -mcpu=ev56)
+#endif
+
+#if DoOSFontRestore
+SpecialObjectRule(VTsw_usl.o, VTsw_usl.c, -DOSHEADER=\"lnx.h\" -DOSSWITCHAWAY="lnx_switchaway()")
+#endif
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+#if BuildXF86DRI
+DRISUBDIR = drm
+#endif
+TESTVAR = XF86INT10_BUILD
+
+#if XF86INT10_BUILD > X86EMU_GENERIC
+INT10SUBDIR = int10
+#endif
+
+#if BuildXF86DRI || (XF86INT10_BUILD > X86EMU_GENERIC)
+#define IHaveSubdirs
+SUBDIRS = $(DRISUBDIR) $(INT10SUBDIR)
+#endif
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+#if BuildXInputExt
+# if DoLoadableServer
+# if JoystickSupport
+AllTarget(lnx_jstk.o)
+#if 0
+InstallDynamicModule(lnx_jstk.o,$(MODULEDIR),input)
+#endif
+# endif
+# endif
+#endif
+
+LinkSourceFile(bios_mmap.c,../shared)
+LinkSourceFile(std_kbdEv.c,../shared)
+LinkSourceFile(at_scancode.c,../shared)
+LinkSourceFile(posix_tty.c,../shared)
+LinkSourceFile(libc_wrapper.c,../shared)
+LinkSourceFile(vidmem.c,../shared)
+LinkSourceFile(VTsw_usl.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
+
+LinkSourceFile($(DRI_SRC),../shared)
+
+#if defined(i386Architecture) || defined(ia64Architecture) || defined (AMD64Architecture)
+LinkSourceFile(stdResource.c,../shared)
+#endif
+#if defined(AlphaArchitecture)
+LinkSourceFile(xf86Axp.c,../shared)
+#endif
+#if defined(ia64Architecture)
+LinkSourceFile(ia64Pci.c,../shared)
+#endif
+DependTarget()
+
+#if 0
+InstallDriverSDKDynamicModule(lnx_jstk.o,$(DRIVERSDKMODULEDIR))
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile
new file mode 100644
index 000000000..54511fbe0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile
@@ -0,0 +1,64 @@
+XCOMM $XFree86: Imakefile,v 1.13 2002/10/30 12:52:32 alanh Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#if DoLoadableServer
+MSRC = drmmodule.c
+MOBJ = drmmodule.o
+#endif
+
+#if BuildXF86DRI
+#if HasMTRRSupport
+MTRR_DEFINES = -DHAS_MTRR_SUPPORT
+#endif
+
+ SRCS = xf86drm.c \
+ xf86drmHash.c \
+ xf86drmRandom.c \
+ xf86drmSL.c \
+ $(MSRC)
+
+ OBJS = xf86drm.o \
+ xf86drmHash.o \
+ xf86drmRandom.o \
+ xf86drmSL.o \
+ $(MOBJ)
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(EXTINCSRC) -I../.. -I$(DRMSRCDIR)/linux-core \
+ -I$(DRMSRCDIR)/shared-core
+
+DEFINES = $(MTRR_DEFINES) $(GLX_DEFINES)
+
+LIBDRM_DIR = ../../../../../../../extras/drm/libdrm
+
+LinkSourceFile(xf86drm.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmHash.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmRandom.c,$(LIBDRM_DIR))
+LinkSourceFile(xf86drmSL.c,$(LIBDRM_DIR))
+
+#if DoLoadableServer
+
+ModuleObjectRule()
+LibraryModuleTarget(drm,$(OBJS))
+NormalLintTarget($(SRCS))
+
+#ifdef LinuxArchitecture
+InstallLibraryModule(drm,$(MODULEDIR),linux)
+#endif
+
+#else
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+#endif
+
+
+DependTarget()
+#endif
+
+
+
+InstallDriverSDKLibraryModule(drm,$(DRIVERSDKMODULEDIR),linux)
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/drm/drmmodule.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/drm/drmmodule.c
new file mode 100644
index 000000000..fd751e756
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/drm/drmmodule.c
@@ -0,0 +1,60 @@
+/* drmmodule.c -- Module initialization
+ * Created: Fri Jun 4 09:05:48 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/drmmodule.c,v 1.2 2000/02/23 04:47:22 martin Exp $
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Module.h"
+
+static MODULESETUPPROTO(drmSetup);
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "drm",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_EXTENSION,
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_NONE,
+ {0,0,0,0}
+};
+
+XF86ModuleData drmModuleData = { &VersRec, drmSetup, NULL };
+
+static pointer
+drmSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ return (void *)1;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile
new file mode 100644
index 000000000..6a23e75e5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile
@@ -0,0 +1,77 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile,v 1.15 2003/06/12 14:12:36 eich Exp $
+
+#define IHaveModules
+
+#include <Server.tmpl>
+
+#define IHaveSubdirs
+
+
+#if defined(XF86INT10_BUILD) && \
+ ( !defined(DoLoadableServer) || !defined(Int10SubLibs))
+#define DoSingleLib
+# if XF86INT10_BUILD == X86VM
+EXPOBJS = vm86/helper_exec.o vm86/linux_vm86.o vm86/xf86int10.o
+SUBDIRS = vm86
+# elif XF86INT10_BUILD == X86EMU_OS
+EXPOBJS = x86emu/x86emu.o x86emu/xf86int10.o x86emu/helper_exec.o \
+ x86emu/xf86x86emu.o
+SUBDIRS = x86emu
+# endif
+#else
+SUBDIRS = vm86 x86emu
+LNXDEF = -DDoSubModules
+#endif
+
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+SRCS = pci.c xf86int10module.c helper_mem.c linux.c
+OBJS = pci.o xf86int10module.o helper_mem.o linux.o
+
+
+LinkSourceFile(helper_mem.c,$(XF86SRC)/int10)
+LinkSourceFile(pci.c,$(XF86SRC)/int10)
+LinkSourceFile(xf86int10module.c,$(XF86SRC)/int10)
+
+
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86SRC)/int10 \
+ -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(X86EMUINCLUDES)
+
+DEFINES=-DHAVE_SYSV_IPC $(X86EMUDEFINES) $(EXTRADEFINES)
+
+#if defined(i386Architecture) || defined (AMD64Architecture)
+EXTRADEFINES=-D_PC
+#endif
+
+
+SpecialObjectRule(linux.o, linux.c, -DHAVE_SYSV_IPC $(LNXDEF))
+
+
+#if defined(XF86INT10_BUILD) && XF86INT10_BUILD > X86EMU_GENERIC
+
+ModuleObjectRule()
+
+#if HasParallelMake && defined (DoSingleLib)
+MakeMutex($(SUBDIRS) $(EXPOBJS) $(DONES))
+#endif
+
+LibraryModuleTarget(int10, $(OBJS) $(EXPOBJS))
+
+InstallLibraryModule(int10,$(MODULEDIR),linux)
+
+all::
+ @(set -x; cd ../..; \
+ RemoveFile(LibraryTargetName(int10)); \
+ $(LN) linux/int10/LibraryTargetName(int10) . )
+
+InstallDriverSDKLibraryModule(int10,$(DRIVERSDKMODULEDIR),.)
+
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c
new file mode 100644
index 000000000..b8e821cd1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c
@@ -0,0 +1,649 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c,v 1.32 2004/02/05 18:24:59 eich Exp $ */
+/*
+ * linux specific part of the int10 module
+ * Copyright 1999, 2000, 2001, 2002, 2003, 2004 Egbert Eich
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Pci.h"
+#include "compiler.h"
+#define _INT10_PRIVATE
+#include "xf86int10.h"
+#ifdef __sparc__
+#define DEV_MEM "/dev/fb"
+#else
+#define DEV_MEM "/dev/mem"
+#endif
+#ifndef XFree86LOADER
+#include <sys/mman.h>
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+#endif
+#define ALLOC_ENTRIES(x) ((V_RAM / x) - 1)
+#define SHMERRORPTR (pointer)(-1)
+
+static int counter = 0;
+static unsigned long int10Generation = 0;
+
+static CARD8 read_b(xf86Int10InfoPtr pInt, int addr);
+static CARD16 read_w(xf86Int10InfoPtr pInt, int addr);
+static CARD32 read_l(xf86Int10InfoPtr pInt, int addr);
+static void write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val);
+static void write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val);
+static void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val);
+
+int10MemRec linuxMem = {
+ read_b,
+ read_w,
+ read_l,
+ write_b,
+ write_w,
+ write_l
+};
+
+typedef struct {
+ int lowMem;
+ int highMem;
+ char* base;
+ char* base_high;
+ int screen;
+ char* alloc;
+} linuxInt10Priv;
+
+#if defined DoSubModules
+
+typedef enum {
+ INT10_NOT_LOADED,
+ INT10_LOADED_VM86,
+ INT10_LOADED_X86EMU,
+ INT10_LOAD_FAILED
+} Int10LinuxSubModuleState;
+
+static Int10LinuxSubModuleState loadedSubModule = INT10_NOT_LOADED;
+
+static Int10LinuxSubModuleState int10LinuxLoadSubModule(ScrnInfoPtr pScrn);
+
+#endif /* DoSubModules */
+
+xf86Int10InfoPtr
+xf86InitInt10(int entityIndex)
+{
+ return xf86ExtendedInitInt10(entityIndex, 0);
+}
+
+xf86Int10InfoPtr
+xf86ExtendedInitInt10(int entityIndex, int Flags)
+{
+ xf86Int10InfoPtr pInt = NULL;
+ CARD8 *bios_base;
+ int screen;
+ int fd;
+ static void* vidMem = NULL;
+ static void* sysMem = NULL;
+ void* vMem = NULL;
+ void *options = NULL;
+ int low_mem;
+ int high_mem = -1;
+ char *base = SHMERRORPTR;
+ char *base_high = SHMERRORPTR;
+ int pagesize;
+ memType cs;
+ legacyVGARec vga;
+ xf86int10BiosLocation bios;
+ Bool videoBiosMapped = FALSE;
+
+ if (int10Generation != serverGeneration) {
+ counter = 0;
+ int10Generation = serverGeneration;
+ }
+
+ screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex;
+
+ options = xf86HandleInt10Options(xf86Screens[screen],entityIndex);
+
+ if (int10skip(options)) {
+ xfree(options);
+ return NULL;
+ }
+
+#if defined DoSubModules
+ if (loadedSubModule == INT10_NOT_LOADED)
+ loadedSubModule = int10LinuxLoadSubModule(xf86Screens[screen]);
+
+ if (loadedSubModule == INT10_LOAD_FAILED)
+ return NULL;
+#endif
+
+ if ((!vidMem) || (!sysMem)) {
+ if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
+ if (!sysMem) {
+#ifdef DEBUG
+ ErrorF("Mapping sys bios area\n");
+#endif
+ if ((sysMem = mmap((void *)(SYS_BIOS), BIOS_SIZE,
+ PROT_READ | PROT_EXEC,
+ MAP_SHARED | MAP_FIXED, fd, SYS_BIOS))
+ == MAP_FAILED) {
+ xf86DrvMsg(screen, X_ERROR, "Cannot map SYS BIOS\n");
+ close(fd);
+ goto error0;
+ }
+ }
+ if (!vidMem) {
+#ifdef DEBUG
+ ErrorF("Mapping VRAM area\n");
+#endif
+ if ((vidMem = mmap((void *)(V_RAM), VRAM_SIZE,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_SHARED | MAP_FIXED, fd, V_RAM))
+ == MAP_FAILED) {
+ xf86DrvMsg(screen, X_ERROR, "Cannot map V_RAM\n");
+ close(fd);
+ goto error0;
+ }
+ }
+ close(fd);
+ } else {
+ xf86DrvMsg(screen, X_ERROR, "Cannot open %s\n", DEV_MEM);
+ goto error0;
+ }
+ }
+
+ pInt = (xf86Int10InfoPtr)xnfcalloc(1, sizeof(xf86Int10InfoRec));
+ pInt->scrnIndex = screen;
+ pInt->entityIndex = entityIndex;
+ if (!xf86Int10ExecSetup(pInt))
+ goto error0;
+ pInt->mem = &linuxMem;
+ pagesize = getpagesize();
+ pInt->private = (pointer)xnfcalloc(1, sizeof(linuxInt10Priv));
+ ((linuxInt10Priv*)pInt->private)->screen = screen;
+ ((linuxInt10Priv*)pInt->private)->alloc =
+ (pointer)xnfcalloc(1, ALLOC_ENTRIES(pagesize));
+
+ if (!xf86IsEntityPrimary(entityIndex)) {
+#ifdef DEBUG
+ ErrorF("Mapping high memory area\n");
+#endif
+ if ((high_mem = shmget(counter++, HIGH_MEM_SIZE,
+ IPC_CREAT | SHM_R | SHM_W)) == -1) {
+ if (errno == ENOSYS)
+ xf86DrvMsg(screen, X_ERROR, "shmget error\n Please reconfigure"
+ " your kernel to include System V IPC support\n");
+ else
+ xf86DrvMsg(screen, X_ERROR,
+ "shmget(highmem) error: %s\n",strerror(errno));
+ goto error1;
+ }
+ } else {
+#ifdef DEBUG
+ ErrorF("Mapping Video BIOS\n");
+#endif
+ videoBiosMapped = TRUE;
+ if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
+ if ((vMem = mmap((void *)(V_BIOS), SYS_BIOS - V_BIOS,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_SHARED | MAP_FIXED, fd, V_BIOS))
+ == MAP_FAILED) {
+ xf86DrvMsg(screen, X_ERROR, "Cannot map V_BIOS\n");
+ close(fd);
+ goto error1;
+ }
+ close (fd);
+ } else
+ goto error1;
+ }
+ ((linuxInt10Priv*)pInt->private)->highMem = high_mem;
+
+#ifdef DEBUG
+ ErrorF("Mapping 640kB area\n");
+#endif
+ if ((low_mem = shmget(counter++, V_RAM,
+ IPC_CREAT | SHM_R | SHM_W)) == -1) {
+ xf86DrvMsg(screen, X_ERROR,
+ "shmget(lowmem) error: %s\n",strerror(errno));
+ goto error2;
+ }
+
+ ((linuxInt10Priv*)pInt->private)->lowMem = low_mem;
+ base = shmat(low_mem, 0, 0);
+ if (base == SHMERRORPTR) {
+ xf86DrvMsg(screen, X_ERROR,
+ "shmat(low_mem) error: %s\n",strerror(errno));
+ goto error3;
+ }
+ ((linuxInt10Priv *)pInt->private)->base = base;
+ if (high_mem > -1) {
+ base_high = shmat(high_mem, 0, 0);
+ if (base_high == SHMERRORPTR) {
+ xf86DrvMsg(screen, X_ERROR,
+ "shmat(high_mem) error: %s\n",strerror(errno));
+ goto error3;
+ }
+ ((linuxInt10Priv*)pInt->private)->base_high = base_high;
+ } else
+ ((linuxInt10Priv*)pInt->private)->base_high = NULL;
+
+ if (!MapCurrentInt10(pInt))
+ goto error3;
+
+ Int10Current = pInt;
+
+#ifdef DEBUG
+ ErrorF("Mapping int area\n");
+#endif
+ if (xf86ReadBIOS(0, 0, (unsigned char *)0, LOW_PAGE_SIZE) < 0) {
+ xf86DrvMsg(screen, X_ERROR, "Cannot read int vect\n");
+ goto error3;
+ }
+#ifdef DEBUG
+ ErrorF("done\n");
+#endif
+ /*
+ * Read in everything between V_BIOS and SYS_BIOS as some system BIOSes
+ * have executable code there. Note that xf86ReadBIOS() can only bring in
+ * 64K bytes at a time.
+ */
+ if (!videoBiosMapped) {
+ (void)memset((pointer)V_BIOS, 0, SYS_BIOS - V_BIOS);
+#ifdef DEBUG
+ ErrorF("Reading BIOS\n");
+#endif
+ for (cs = V_BIOS; cs < SYS_BIOS; cs += V_BIOS_SIZE)
+ if (xf86ReadBIOS(cs, 0, (pointer)cs, V_BIOS_SIZE) < V_BIOS_SIZE)
+ xf86DrvMsg(screen, X_WARNING,
+ "Unable to retrieve all of segment 0x%06lX.\n", cs);
+#ifdef DEBUG
+ ErrorF("done\n");
+#endif
+ }
+
+ xf86int10ParseBiosLocation(options,&bios);
+
+ if (xf86IsEntityPrimary(entityIndex)
+ && !(initPrimary(options))) {
+ if (bios.bus == BUS_ISA && bios.location.legacy) {
+ xf86DrvMsg(screen, X_CONFIG,
+ "Overriding BIOS location: 0x%x\n",
+ bios.location.legacy);
+ cs = bios.location.legacy >> 4;
+ bios_base = (unsigned char *)(cs << 4);
+ if (!int10_check_bios(screen, cs, bios_base)) {
+ xf86DrvMsg(screen, X_ERROR,
+ "No V_BIOS at specified address 0x%lx\n",cs << 4);
+ goto error3;
+ }
+ } else {
+ if (bios.bus == BUS_PCI) {
+ xf86DrvMsg(screen, X_WARNING,
+ "Option BiosLocation for primary device ignored: "
+ "It points to PCI.\n");
+ xf86DrvMsg(screen, X_WARNING,
+ "You must set Option InitPrimary also\n");
+ }
+
+ cs = ((CARD16*)0)[(0x10<<1) + 1];
+
+ bios_base = (unsigned char *)(cs << 4);
+
+ if (!int10_check_bios(screen, cs, bios_base)) {
+ cs = ((CARD16*)0)[(0x42 << 1) + 1];
+ bios_base = (unsigned char *)(cs << 4);
+ if (!int10_check_bios(screen, cs, bios_base)) {
+ cs = V_BIOS >> 4;
+ bios_base = (unsigned char *)(cs << 4);
+ if (!int10_check_bios(screen, cs, bios_base)) {
+ xf86DrvMsg(screen, X_ERROR, "No V_BIOS found\n");
+ goto error3;
+ }
+ }
+ }
+ }
+
+ xf86DrvMsg(screen, X_INFO, "Primary V_BIOS segment is: 0x%lx\n", cs);
+
+ pInt->BIOSseg = cs;
+ set_return_trap(pInt);
+#ifdef _PC
+ pInt->Flags = Flags & (SET_BIOS_SCRATCH | RESTORE_BIOS_SCRATCH);
+ if (! (pInt->Flags & SET_BIOS_SCRATCH))
+ pInt->Flags &= ~RESTORE_BIOS_SCRATCH;
+ xf86Int10SaveRestoreBIOSVars(pInt, TRUE);
+#endif
+ } else {
+ EntityInfoPtr pEnt = xf86GetEntityInfo(pInt->entityIndex);
+ BusType location_type;
+
+ if (bios.bus != BUS_NONE) {
+ switch (location_type = bios.bus) {
+ case BUS_PCI:
+ xf86DrvMsg(screen,X_CONFIG,"Overriding bios location: "
+ "PCI:%i:%i%i\n",bios.location.pci.bus,
+ bios.location.pci.dev,bios.location.pci.func);
+ break;
+ case BUS_ISA:
+ if (bios.location.legacy)
+ xf86DrvMsg(screen,X_CONFIG,"Overriding bios location: "
+ "Legacy:0x%x\n",bios.location.legacy);
+ else
+ xf86DrvMsg(screen,X_CONFIG,"Overriding bios location: "
+ "Legacy\n");
+ break;
+ default:
+ break;
+ }
+ } else
+ location_type = pEnt->location.type;
+
+ switch (location_type) {
+ case BUS_PCI:
+ {
+ int pci_entity;
+
+ if (bios.bus == BUS_PCI)
+ pci_entity = xf86GetPciEntity(bios.location.pci.bus,
+ bios.location.pci.dev,
+ bios.location.pci.func);
+ else
+ pci_entity = pInt->entityIndex;
+ if (!mapPciRom(pci_entity, (unsigned char *)(V_BIOS))) {
+ xf86DrvMsg(screen, X_ERROR, "Cannot read V_BIOS\n");
+ goto error3;
+ }
+ pInt->BIOSseg = V_BIOS >> 4;
+ break;
+ }
+ case BUS_ISA:
+ if (bios.bus == BUS_ISA && bios.location.legacy) {
+ cs = bios.location.legacy >> 4;
+ bios_base = (unsigned char *)(cs << 4);
+ if (!int10_check_bios(screen, cs, bios_base)) {
+ xf86DrvMsg(screen,X_ERROR,"No V_BIOS found "
+ "on override address %p\n",bios_base);
+ goto error3;
+ }
+ } else {
+ cs = ((CARD16*)0)[(0x10<<1)+1];
+ bios_base = (unsigned char *)(cs << 4);
+
+ if (!int10_check_bios(screen, cs, bios_base)) {
+ cs = ((CARD16*)0)[(0x42<<1)+1];
+ bios_base = (unsigned char *)(cs << 4);
+ if (!int10_check_bios(screen, cs, bios_base)) {
+ cs = V_BIOS >> 4;
+ bios_base = (unsigned char *)(cs << 4);
+ if (!int10_check_bios(screen, cs, bios_base)) {
+ xf86DrvMsg(screen,X_ERROR,"No V_BIOS found\n");
+ goto error3;
+ }
+ }
+ }
+ }
+ xf86DrvMsg(screen,X_INFO,"Primary V_BIOS segment is: 0x%lx\n",cs);
+ pInt->BIOSseg = cs;
+ break;
+ default:
+ goto error3;
+ }
+ xfree(pEnt);
+ pInt->num = 0xe6;
+ reset_int_vect(pInt);
+ set_return_trap(pInt);
+ LockLegacyVGA(pInt, &vga);
+ xf86ExecX86int10(pInt);
+ UnlockLegacyVGA(pInt, &vga);
+ }
+#ifdef DEBUG
+ dprint(0xc0000, 0x20);
+#endif
+
+ xfree(options);
+ return pInt;
+
+error3:
+ if (base_high)
+ shmdt(base_high);
+ shmdt(base);
+ shmdt(0);
+ if (base_high)
+ shmdt((char*)HIGH_MEM);
+ shmctl(low_mem, IPC_RMID, NULL);
+ Int10Current = NULL;
+error2:
+ if (high_mem > -1)
+ shmctl(high_mem, IPC_RMID,NULL);
+error1:
+ if (vMem)
+ munmap(vMem, SYS_BIOS - V_BIOS);
+ xfree(((linuxInt10Priv*)pInt->private)->alloc);
+ xfree(pInt->private);
+error0:
+ xfree(options);
+ xfree(pInt);
+ return NULL;
+}
+
+Bool
+MapCurrentInt10(xf86Int10InfoPtr pInt)
+{
+ pointer addr;
+ int fd = -1;
+
+ if (Int10Current) {
+ shmdt(0);
+ if (((linuxInt10Priv*)Int10Current->private)->highMem >= 0)
+ shmdt((char*)HIGH_MEM);
+ else
+ munmap((pointer)V_BIOS, (SYS_BIOS - V_BIOS));
+ }
+ addr = shmat(((linuxInt10Priv*)pInt->private)->lowMem, (char*)1, SHM_RND);
+ if (addr == SHMERRORPTR) {
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot shmat() low memory\n");
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "shmat(low_mem) error: %s\n",strerror(errno));
+ return FALSE;
+ }
+
+ if (((linuxInt10Priv*)pInt->private)->highMem >= 0) {
+ addr = shmat(((linuxInt10Priv*)pInt->private)->highMem,
+ (char*)HIGH_MEM, 0);
+ if (addr == SHMERRORPTR) {
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "Cannot shmat() high memory\n");
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "shmget error: %s\n",strerror(errno));
+ return FALSE;
+ }
+ } else {
+ if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
+ if (mmap((void *)(V_BIOS), SYS_BIOS - V_BIOS,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_SHARED | MAP_FIXED, fd, V_BIOS)
+ == MAP_FAILED) {
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot map V_BIOS\n");
+ close (fd);
+ return FALSE;
+ }
+ } else {
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot open %s\n",DEV_MEM);
+ return FALSE;
+ }
+ close (fd);
+ }
+
+ return TRUE;
+}
+
+void
+xf86FreeInt10(xf86Int10InfoPtr pInt)
+{
+ if (!pInt)
+ return;
+
+#ifdef _PC
+ xf86Int10SaveRestoreBIOSVars(pInt, FALSE);
+#endif
+ if (Int10Current == pInt) {
+ shmdt(0);
+ if (((linuxInt10Priv*)pInt->private)->highMem >= 0)
+ shmdt((char*)HIGH_MEM);
+ else
+ munmap((pointer)V_BIOS, (SYS_BIOS - V_BIOS));
+ Int10Current = NULL;
+ }
+
+ if (((linuxInt10Priv*)pInt->private)->base_high)
+ shmdt(((linuxInt10Priv*)pInt->private)->base_high);
+ shmdt(((linuxInt10Priv*)pInt->private)->base);
+ shmctl(((linuxInt10Priv*)pInt->private)->lowMem, IPC_RMID, NULL);
+ if (((linuxInt10Priv*)pInt->private)->highMem >= 0)
+ shmctl(((linuxInt10Priv*)pInt->private)->highMem, IPC_RMID, NULL);
+ xfree(((linuxInt10Priv*)pInt->private)->alloc);
+ xfree(pInt->private);
+ xfree(pInt);
+}
+
+void *
+xf86Int10AllocPages(xf86Int10InfoPtr pInt, int num, int *off)
+{
+ int pagesize = getpagesize();
+ int num_pages = ALLOC_ENTRIES(pagesize);
+ int i, j;
+
+ for (i = 0; i < (num_pages - num); i++) {
+ if (((linuxInt10Priv*)pInt->private)->alloc[i] == 0) {
+ for (j = i; j < (num + i); j++)
+ if ((((linuxInt10Priv*)pInt->private)->alloc[j] != 0))
+ break;
+ if (j == (num + i))
+ break;
+ else
+ i = i + num;
+ }
+ }
+ if (i == (num_pages - num))
+ return NULL;
+
+ for (j = i; j < (i + num); j++)
+ ((linuxInt10Priv*)pInt->private)->alloc[j] = 1;
+
+ *off = (i + 1) * pagesize;
+
+ return ((linuxInt10Priv*)pInt->private)->base + ((i + 1) * pagesize);
+}
+
+void
+xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num)
+{
+ int pagesize = getpagesize();
+ int first = (((unsigned long)pbase
+ - (unsigned long)((linuxInt10Priv*)pInt->private)->base)
+ / pagesize) - 1;
+ int i;
+
+ for (i = first; i < (first + num); i++)
+ ((linuxInt10Priv*)pInt->private)->alloc[i] = 0;
+}
+
+static CARD8
+read_b(xf86Int10InfoPtr pInt, int addr)
+{
+ return *((CARD8 *)(memType)addr);
+}
+
+static CARD16
+read_w(xf86Int10InfoPtr pInt, int addr)
+{
+ return *((CARD16 *)(memType)addr);
+}
+
+static CARD32
+read_l(xf86Int10InfoPtr pInt, int addr)
+{
+ return *((CARD32 *)(memType)addr);
+}
+
+static void
+write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val)
+{
+ *((CARD8 *)(memType)addr) = val;
+}
+
+static void
+write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val)
+{
+ *((CARD16 *)(memType)addr) = val;
+}
+
+static
+void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val)
+{
+ *((CARD32 *)(memType) addr) = val;
+}
+
+pointer
+xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr)
+{
+ if (addr < V_RAM)
+ return ((linuxInt10Priv*)pInt->private)->base + addr;
+ else if (addr < V_BIOS)
+ return (pointer)(memType)addr;
+ else if (addr < SYS_BIOS) {
+ if (((linuxInt10Priv*)pInt->private)->base_high)
+ return (pointer)(((linuxInt10Priv*)pInt->private)->base_high
+ - V_BIOS + addr);
+ else
+ return (pointer) (memType)addr;
+ } else
+ return (pointer) (memType)addr;
+}
+
+#if defined DoSubModules
+
+static Bool
+vm86_tst(void)
+{
+ int __res;
+
+#ifdef __PIC__
+ /* When compiling with -fPIC, we can't use asm constraint "b" because
+ %ebx is already taken by gcc. */
+ __asm__ __volatile__("pushl %%ebx\n\t"
+ "movl %2,%%ebx\n\t"
+ "movl %1,%%eax\n\t"
+ "int $0x80\n\t"
+ "popl %%ebx"
+ :"=a" (__res)
+ :"n" ((int)113), "r" (NULL));
+#else
+ __asm__ __volatile__("int $0x80\n\t"
+ :"=a" (__res):"a" ((int)113),
+ "b" ((struct vm86_struct *)NULL));
+#endif
+
+ if (__res < 0 && __res == -ENOSYS)
+ return FALSE;
+
+ return TRUE;
+}
+
+static Int10LinuxSubModuleState
+int10LinuxLoadSubModule(ScrnInfoPtr pScrn)
+{
+ if (vm86_tst()) {
+ if (xf86LoadSubModule(pScrn,"vm86"))
+ return INT10_LOADED_VM86;
+ }
+ if (xf86LoadSubModule(pScrn,"x86emu"))
+ return INT10_LOADED_X86EMU;
+
+ return INT10_LOAD_FAILED;
+}
+
+#endif /* DoSubModules */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/vm86/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/vm86/Imakefile
new file mode 100644
index 000000000..522369894
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/vm86/Imakefile
@@ -0,0 +1,55 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/vm86/Imakefile,v 1.2 2003/06/12 14:12:37 eich Exp $
+
+#define IHaveModules
+
+#include <Server.tmpl>
+
+SRCS1 = linux_vm86.c helper_exec.c xf86int10.c
+OBJS1 = linux_vm86.o helper_exec.o xf86int10.o
+
+#if defined(DoLoadableServer) && defined(Int10SubLibs)
+SUBMODSRCS = xf86vm86module.c
+SUBMODOBJS = xf86vm86module.o
+#endif
+
+OBJS = $(SUBMODOBJS) $(OBJS1)
+SRCS = $(SUBMODSRCS) $(SRCS1)
+
+LinkSourceFile(helper_exec.c,$(XF86SRC)/int10)
+LinkSourceFile(xf86int10.c,$(XF86SRC)/int10)
+LinkFile(xf86vm86module.c,$(XF86SRC)/int10/xf86int10module.c)
+
+
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86SRC)/int10 \
+ -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(X86EMUINCLUDES)
+
+DEFINES=-DHAVE_SYSV_IPC $(X86EMUDEFINES) $(EXTRADEFINES)
+
+#if defined(i386Architecture) || defined (AMD64Architecture)
+EXTRADEFINES=-D_PC
+#endif
+
+SpecialObjectRule(xf86vm86module.o, xf86vm86module.c, -DMOD_NAME=vm86)
+SpecialObjectRule(helper_exec.o, helper_exec.c, -D_VM86_LINUX)
+SpecialObjectRule(xf86int10.o, xf86int10.c, -D_VM86_LINUX -DSHOW_ALL_DEVICES)
+SpecialObjectRule(linux_vm86.o, linux_vm86.c, -D_VM86_LINUX)
+
+ModuleObjectRule()
+
+#if defined(DoLoadableServer) && defined(Int10SubLibs)
+LibraryModuleTarget(vm86, $(OBJS))
+InstallLibraryModule(vm86,$(MODULEDIR),linux)
+
+all::
+ @(set -x; cd ../..; \
+ RemoveFile(LibraryTargetName(vm86)); \
+ $(LN) linux/int10/vm86/LibraryTargetName(vm86) . )
+
+InstallDriverSDKLibraryModule(vm86,$(DRIVERSDKMODULEDIR),.)
+#else
+SubdirLibraryRule($(OBJS))
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c
new file mode 100644
index 000000000..e99cde8da
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c
@@ -0,0 +1,302 @@
+/* $XFree86$ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Pci.h"
+#include "compiler.h"
+#define _INT10_PRIVATE
+#include "xf86int10.h"
+
+#define REG pInt
+
+#ifdef _VM86_LINUX
+#include "int10Defines.h"
+
+static int vm86_rep(struct vm86_struct *ptr);
+static struct vm86_struct vm86_s;
+
+Bool
+xf86Int10ExecSetup(xf86Int10InfoPtr pInt)
+{
+#define VM86S ((struct vm86_struct *)pInt->cpuRegs)
+
+ pInt->cpuRegs = &vm86_s;
+ VM86S->flags = 0;
+ VM86S->screen_bitmap = 0;
+ VM86S->cpu_type = CPU_586;
+ memset(&VM86S->int_revectored, 0xff, sizeof(VM86S->int_revectored));
+ memset(&VM86S->int21_revectored, 0xff, sizeof(VM86S->int21_revectored));
+ return TRUE;
+}
+
+/* get the linear address */
+#define LIN_PREF_SI ((pref_seg << 4) + X86_SI)
+#define LWECX ((prefix66 ^ prefix67) ? X86_ECX : X86_CX)
+#define LWECX_ZERO {if (prefix66 ^ prefix67) X86_ECX = 0; else X86_CX = 0;}
+#define DF (1 << 10)
+
+/* vm86 fault handling */
+static Bool
+vm86_GP_fault(xf86Int10InfoPtr pInt)
+{
+ unsigned char *csp, *lina;
+ CARD32 org_eip;
+ int pref_seg;
+ int done, is_rep, prefix66, prefix67;
+
+ csp = lina = SEG_ADR((unsigned char *), X86_CS, IP);
+
+ is_rep = 0;
+ prefix66 = prefix67 = 0;
+ pref_seg = -1;
+
+ /* eat up prefixes */
+ done = 0;
+ do {
+ switch (MEM_RB(pInt, (int)csp++)) {
+ case 0x66: /* operand prefix */ prefix66=1; break;
+ case 0x67: /* address prefix */ prefix67=1; break;
+ case 0x2e: /* CS */ pref_seg=X86_CS; break;
+ case 0x3e: /* DS */ pref_seg=X86_DS; break;
+ case 0x26: /* ES */ pref_seg=X86_ES; break;
+ case 0x36: /* SS */ pref_seg=X86_SS; break;
+ case 0x65: /* GS */ pref_seg=X86_GS; break;
+ case 0x64: /* FS */ pref_seg=X86_FS; break;
+ case 0xf0: /* lock */ break;
+ case 0xf2: /* repnz */
+ case 0xf3: /* rep */ is_rep=1; break;
+ default: done=1;
+ }
+ } while (!done);
+ csp--; /* oops one too many */
+ org_eip = X86_EIP;
+ X86_IP += (csp - lina);
+
+ switch (MEM_RB(pInt, (int)csp)) {
+ case 0x6c: /* insb */
+ /* NOTE: ES can't be overwritten; prefixes 66,67 should use esi,edi,ecx
+ * but is anyone using extended regs in real mode? */
+ /* WARNING: no test for DI wrapping! */
+ X86_EDI += port_rep_inb(pInt, X86_DX, SEG_EADR((CARD32), X86_ES, DI),
+ X86_FLAGS & DF, is_rep ? LWECX : 1);
+ if (is_rep) LWECX_ZERO;
+ X86_IP++;
+ break;
+
+ case 0x6d: /* (rep) insw / insd */
+ /* NOTE: ES can't be overwritten */
+ /* WARNING: no test for _DI wrapping! */
+ if (prefix66) {
+ X86_DI += port_rep_inl(pInt, X86_DX, SEG_ADR((CARD32), X86_ES, DI),
+ X86_EFLAGS & DF, is_rep ? LWECX : 1);
+ }
+ else {
+ X86_DI += port_rep_inw(pInt, X86_DX, SEG_ADR((CARD32), X86_ES, DI),
+ X86_FLAGS & DF, is_rep ? LWECX : 1);
+ }
+ if (is_rep) LWECX_ZERO;
+ X86_IP++;
+ break;
+
+ case 0x6e: /* (rep) outsb */
+ if (pref_seg < 0) pref_seg = X86_DS;
+ /* WARNING: no test for _SI wrapping! */
+ X86_SI += port_rep_outb(pInt, X86_DX, (CARD32)LIN_PREF_SI,
+ X86_FLAGS & DF, is_rep ? LWECX : 1);
+ if (is_rep) LWECX_ZERO;
+ X86_IP++;
+ break;
+
+ case 0x6f: /* (rep) outsw / outsd */
+ if (pref_seg < 0) pref_seg = X86_DS;
+ /* WARNING: no test for _SI wrapping! */
+ if (prefix66) {
+ X86_SI += port_rep_outl(pInt, X86_DX, (CARD32)LIN_PREF_SI,
+ X86_EFLAGS & DF, is_rep ? LWECX : 1);
+ }
+ else {
+ X86_SI += port_rep_outw(pInt, X86_DX, (CARD32)LIN_PREF_SI,
+ X86_FLAGS & DF, is_rep ? LWECX : 1);
+ }
+ if (is_rep) LWECX_ZERO;
+ X86_IP++;
+ break;
+
+ case 0xe5: /* inw xx, inl xx */
+ if (prefix66) X86_EAX = x_inl(csp[1]);
+ else X86_AX = x_inw(csp[1]);
+ X86_IP += 2;
+ break;
+
+ case 0xe4: /* inb xx */
+ X86_AL = x_inb(csp[1]);
+ X86_IP += 2;
+ break;
+
+ case 0xed: /* inw dx, inl dx */
+ if (prefix66) X86_EAX = x_inl(X86_DX);
+ else X86_AX = x_inw(X86_DX);
+ X86_IP += 1;
+ break;
+
+ case 0xec: /* inb dx */
+ X86_AL = x_inb(X86_DX);
+ X86_IP += 1;
+ break;
+
+ case 0xe7: /* outw xx */
+ if (prefix66) x_outl(csp[1], X86_EAX);
+ else x_outw(csp[1], X86_AX);
+ X86_IP += 2;
+ break;
+
+ case 0xe6: /* outb xx */
+ x_outb(csp[1], X86_AL);
+ X86_IP += 2;
+ break;
+
+ case 0xef: /* outw dx */
+ if (prefix66) x_outl(X86_DX, X86_EAX);
+ else x_outw(X86_DX, X86_AX);
+ X86_IP += 1;
+ break;
+
+ case 0xee: /* outb dx */
+ x_outb(X86_DX, X86_AL);
+ X86_IP += 1;
+ break;
+
+ case 0xf4:
+#ifdef DEBUG
+ ErrorF("hlt at %p\n", lina);
+#endif
+ return FALSE;
+
+ case 0x0f:
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "CPU 0x0f Trap at CS:EIP=0x%4.4x:0x%8.8lx\n", X86_CS, X86_EIP);
+ goto op0ferr;
+
+ default:
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "unknown reason for exception\n");
+
+ op0ferr:
+ dump_registers(pInt);
+ stack_trace(pInt);
+ dump_code(pInt);
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "cannot continue\n");
+ return FALSE;
+ } /* end of switch() */
+ return TRUE;
+}
+
+static int
+do_vm86(xf86Int10InfoPtr pInt)
+{
+ int retval, signo;
+
+ xf86InterceptSignals(&signo);
+ retval = vm86_rep(VM86S);
+ xf86InterceptSignals(NULL);
+
+ if (signo >= 0) {
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "vm86() syscall generated signal %d.\n", signo);
+ dump_registers(pInt);
+ dump_code(pInt);
+ stack_trace(pInt);
+ return 0;
+ }
+
+ switch (VM86_TYPE(retval)) {
+ case VM86_UNKNOWN:
+ if (!vm86_GP_fault(pInt)) return 0;
+ break;
+ case VM86_STI:
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "vm86_sti :-((\n");
+ dump_registers(pInt);
+ dump_code(pInt);
+ stack_trace(pInt);
+ return 0;
+ case VM86_INTx:
+ pInt->num = VM86_ARG(retval);
+ if (!int_handler(pInt)) {
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "Unknown vm86_int: 0x%X\n\n", VM86_ARG(retval));
+ dump_registers(pInt);
+ dump_code(pInt);
+ stack_trace(pInt);
+ return 0;
+ }
+ /* I'm not sure yet what to do if we can handle ints */
+ break;
+ case VM86_SIGNAL:
+ return 1;
+ /*
+ * we used to warn here and bail out - but now the sigio stuff
+ * always fires signals at us. So we just ignore them for now.
+ */
+ xf86DrvMsg(pInt->scrnIndex, X_WARNING, "received signal\n");
+ return 0;
+ default:
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR, "unknown type(0x%x)=0x%x\n",
+ VM86_ARG(retval), VM86_TYPE(retval));
+ dump_registers(pInt);
+ dump_code(pInt);
+ stack_trace(pInt);
+ return 0;
+ }
+
+ return 1;
+}
+
+void
+xf86ExecX86int10(xf86Int10InfoPtr pInt)
+{
+ int sig = setup_int(pInt);
+
+ if (int_handler(pInt))
+ while(do_vm86(pInt)) {};
+
+ finish_int(pInt, sig);
+}
+
+static int
+vm86_rep(struct vm86_struct *ptr)
+{
+ int __res;
+
+#ifdef __PIC__
+ /* When compiling with -fPIC, we can't use asm constraint "b" because
+ %ebx is already taken by gcc. */
+ __asm__ __volatile__("pushl %%ebx\n\t"
+ "push %%gs\n\t"
+ "movl %2,%%ebx\n\t"
+ "movl %1,%%eax\n\t"
+ "int $0x80\n\t"
+ "pop %%gs\n\t"
+ "popl %%ebx"
+ :"=a" (__res)
+ :"n" ((int)113), "r" ((struct vm86_struct *)ptr));
+#else
+ __asm__ __volatile__("push %%gs\n\t"
+ "int $0x80\n\t"
+ "pop %%gs"
+ :"=a" (__res):"a" ((int)113),
+ "b" ((struct vm86_struct *)ptr));
+#endif
+
+ if (__res < 0) {
+ errno = -__res;
+ __res = -1;
+ }
+ else errno = 0;
+ return __res;
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/x86emu/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/x86emu/Imakefile
new file mode 100644
index 000000000..8a0dc4463
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/x86emu/Imakefile
@@ -0,0 +1,86 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/x86emu/Imakefile,v 1.2 2003/06/12 14:12:37 eich Exp $
+
+#define IHaveModules
+
+#include <Server.tmpl>
+
+SRCS1 = xf86x86emu.c helper_exec.c xf86int10.c
+OBJS1 = xf86x86emu.o helper_exec.o xf86int10.o
+
+#if defined(DoLoadableServer) && defined(Int10SubLibs)
+SUBMODSRCS = xf86x86emumodule.c
+SUBMODOBJS = xf86x86emumodule.o
+#endif
+
+SRCS2 = $(SUBMODSRCS) $(SRCS1)
+OBJS2 = $(SUBMODOBJS) $(OBJS1)
+
+LinkSourceFile(helper_exec.c,$(XF86SRC)/int10)
+LinkSourceFile(xf86int10.c,$(XF86SRC)/int10)
+LinkSourceFile(xf86x86emu.c,$(XF86SRC)/int10)
+LinkFile(xf86x86emumodule.c,$(XF86SRC)/int10/xf86int10module.c)
+
+
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86SRC)/int10 \
+ -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(X86EMUINCLUDES)
+
+DEFINES=-DHAVE_SYSV_IPC $(X86EMUDEFINES) $(EXTRADEFINES)
+
+#if defined(i386Architecture) || defined (AMD64Architecture)
+EXTRADEFINES=-D_PC
+#endif
+
+SpecialObjectRule(xf86x86emumodule.o, xf86x86emumodule.c, -DMOD_NAME=x86emu)
+SpecialObjectRule(helper_exec.o, helper_exec.c, -D_X86EMU)
+SpecialObjectRule(xf86int10.o, xf86int10.c, -D_X86EMU -DSHOW_ALL_DEVICES)
+SpecialObjectRule(linux.o, linux.c, -D_X86EMU -DHAVE_SYSV_IPC)
+
+X86TOPDIR = $(TOP)/extras/x86emu
+X86SRCDIR = $(X86TOPDIR)/src/x86emu
+X86EMUINCLUDES = $(X86TOPDIR)/include -I$(X86SRCDIR)
+# if DoLoadableServer
+X86EMUMODDEFS = -DNO_SYS_HEADERS
+# endif
+
+X86EMUDEFINES = -D__DRIVER__ -DFORCE_POST -D_CEXPORT= -DNO_LONG_LONG $(X86EMUMODDEFS)
+
+#if !defined(X86EMU_LIBPATH)
+X86EMUSRCS = x86emu.c
+X86EMUOBJS = x86emu.o
+
+LinkSourceFile(x86emu.c,$(XF86SRC)/int10)
+LinkSourceFile(debug.c,$(X86SRCDIR))
+LinkSourceFile(decode.c,$(X86SRCDIR))
+LinkSourceFile(fpu.c,$(X86SRCDIR))
+LinkSourceFile(ops.c,$(X86SRCDIR))
+LinkSourceFile(ops2.c,$(X86SRCDIR))
+LinkSourceFile(prim_ops.c,$(X86SRCDIR))
+LinkSourceFile(sys.c,$(X86SRCDIR))
+#else
+BuildObjectFromLibraryWithPath(X86EMU_LIBPATH,x86emu,x86emu)
+X86EMUOBJS = x86emu.o
+#endif
+
+SRCS = $(SRCS2) $(X86EMUSRCS)
+OBJS = $(OBJS2) $(X86EMUOBJS)
+
+ModuleObjectRule()
+
+#if defined(DoLoadableServer) && defined(Int10SubLibs)
+LibraryModuleTarget(x86emu, $(OBJS))
+
+InstallLibraryModule(x86emu,$(MODULEDIR),linux)
+
+all::
+ @(set -x; cd ../..; \
+ RemoveFile(LibraryTargetName(x86emu)); \
+ $(LN) linux/int10/x86emu/LibraryTargetName(x86emu) . )
+
+InstallDriverSDKLibraryModule(x86emu,$(DRIVERSDKMODULEDIR),.)
+#else
+SubdirLibraryRule($(OBJS))
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx.h
new file mode 100644
index 000000000..68ad34011
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx.h
@@ -0,0 +1,55 @@
+/* $XFree86: Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef LNX_H_
+# ifdef __alpha__
+extern unsigned long _bus_base __P ((void)) __attribute__ ((const));
+extern unsigned long _bus_base_sparse __P ((void)) __attribute__ ((const));
+extern int iopl __P ((int __level));
+
+/* new pciconfig_iobase syscall added in 2.2.15 and 2.3.99 */
+# include <linux/unistd.h>
+# include <asm/pci.h>
+extern long (*_iobase)(unsigned, int, int, int);
+
+/*
+ * _iobase deals with the case the __NR_pciconfig_iobase is either undefined
+ * or unsupported by the kernel, but we need to make sure that the `which'
+ * argument symbols are defined.
+ */
+# ifndef IOBASE_HOSE
+# define IOBASE_HOSE 0
+# endif
+# ifndef IOBASE_SPARSE_MEM
+# define IOBASE_SPARSE_MEM 1
+# endif
+# ifndef IOBASE_DENSE_MEM
+# define IOBASE_DENSE_MEM 2
+# endif
+# ifndef IOBASE_SPARSE_IO
+# define IOBASE_SPARSE_IO 3
+# endif
+# ifndef IOBASE_DENSE_IO
+# define IOBASE_DENSE_IO 4
+# endif
+# ifndef IOBASE_ROOT_BUS
+# define IOBASE_ROOT_BUS 5
+# endif
+# ifndef IOBASE_FROM_HOSE
+# define IOBASE_FROM_HOSE 0x10000
+# endif
+# endif /* __alpha__ */
+
+# if defined(DO_OS_FONTRESTORE)
+Bool lnx_savefont(void);
+Bool lnx_restorefont(void);
+Bool lnx_switchaway(void);
+void lnx_freefontdata(void);
+# endif
+
+#define LNX_H_
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c
new file mode 100644
index 000000000..690d3bc8f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c
@@ -0,0 +1,291 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c,v 3.18 2002/01/25 21:56:19 tsi Exp $ */
+
+/* Resource information code */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Privstr.h"
+#include "xf86Pci.h"
+#include "xf86Resources.h"
+#define NEED_OS_RAC_PROTOS
+#include "xf86_OSlib.h"
+#include "lnx.h"
+
+/* Avoid Imakefile changes */
+#include "bus/Pci.h"
+
+resRange PciAvoid[] =
+{
+#if !defined(__sparc__) || !defined(INCLUDE_XF86_NO_DOMAIN)
+ _PCI_AVOID_PC_STYLE,
+#endif
+ _END
+};
+
+#ifdef INCLUDE_XF86_NO_DOMAIN
+
+#ifdef __alpha__
+
+resPtr
+xf86BusAccWindowsFromOS(void)
+{
+ resPtr ret = NULL;
+ resRange range;
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ return ret;
+}
+
+resPtr
+xf86PciBusAccWindowsFromOS(void)
+{
+ resPtr ret = NULL;
+ resRange range;
+ /*
+ * On the Alpha the first 16MB of every 128 Mb segment in
+ * sparse address space are an image of the ISA bus range
+ */
+ if (_bus_base_sparse()) {
+ RANGE(range, 0x00000000, 0x07ffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x09000000, 0x0fffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x11000000, 0x17ffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x19000000, 0x1fffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x21000000, 0x27ffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x29000000, 0x2fffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x31000000, 0x37ffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x39000000, 0x3fffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x41000000, 0x47ffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x49000000, 0x4fffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x51000000, 0x57ffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x59000000, 0x5fffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x61000000, 0x67ffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x69000000, 0x6fffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x71000000, 0x77ffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x79000000, 0x7fffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x81000000, 0x87ffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x89000000, 0x8fffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x91000000, 0x97ffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x99000000, 0x9fffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xa1000000, 0xa7ffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xa9000000, 0xafffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xb1000000, 0xb7ffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xb9000000, 0xbfffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xc1000000, 0xc7ffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xc9000000, 0xcfffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xd1000000, 0xd7ffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xd9000000, 0xdfffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xe1000000, 0xe7ffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xe9000000, 0xefffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xf1000000, 0xf7ffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xf9000000, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ } else {
+ RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ }
+ RANGE(range, 0x00000000, 0xffffffff, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ return ret;
+}
+
+#ifdef INCLUDE_UNUSED
+
+resPtr
+xf86IsaBusAccWindowsFromOS(void)
+{
+ resPtr ret = NULL;
+ resRange range;
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ return ret;
+}
+
+#endif /* INCLUDE_UNUSED */
+
+resPtr
+xf86AccResFromOS(resPtr ret)
+{
+ resRange range;
+
+ /*
+ * Fallback is to claim the following areas:
+ *
+ * 0x000c0000 - 0x000effff location of VGA and other extensions ROMS
+ */
+
+ RANGE(range, 0x000c0000, 0x000effff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ /*
+ * Fallback would be to claim well known ports in the 0x0 - 0x3ff range
+ * along with their sparse I/O aliases, but that's too imprecise. Instead
+ * claim a bare minimum here.
+ */
+ RANGE(range, 0x00000000, 0x000000ff, ResExcIoBlock); /* For mainboard */
+ ret = xf86AddResToList(ret, &range, -1);
+
+ /*
+ * At minimum, the top and bottom resources must be claimed, so that
+ * resources that are (or appear to be) unallocated can be relocated.
+ */
+ RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+/* RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1); */
+ RANGE(range, 0xffffffff, 0xffffffff, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ /* XXX add others */
+ return ret;
+}
+
+#elif defined(__powerpc__) || \
+ defined(__sparc__) || \
+ defined(__mips__) || \
+ defined(__sh__) || \
+ defined(__mc68000__) || \
+ defined(__arm__) || \
+ defined(__s390__) || \
+ defined(__hppa__)
+
+ /*
+ * XXX this isn't exactly correct but it will get the server working
+ * for now until we get something better.
+ */
+
+resPtr
+xf86BusAccWindowsFromOS(void)
+{
+ resPtr ret = NULL;
+ resRange range;
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+#if defined(__sparc__) || defined(__powerpc__)
+ RANGE(range, 0x00000000, 0x00ffffff, ResExcIoBlock);
+#else
+ RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
+#endif
+ ret = xf86AddResToList(ret, &range, -1);
+ return ret;
+}
+
+resPtr
+xf86PciBusAccWindowsFromOS(void)
+{
+ resPtr ret = NULL;
+ resRange range;
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+#if defined(__sparc__) || defined(__powerpc__)
+ RANGE(range, 0x00000000, 0x00ffffff, ResExcIoBlock);
+#else
+ RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
+#endif
+ ret = xf86AddResToList(ret, &range, -1);
+ return ret;
+}
+
+#ifdef INCLUDE_UNUSED
+
+resPtr
+xf86IsaBusAccWindowsFromOS(void)
+{
+ resPtr ret = NULL;
+ resRange range;
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+#if defined(__sparc__) || defined(__powerpc__)
+ RANGE(range, 0x00000000, 0x00ffffff, ResExcIoBlock);
+#else
+ RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
+#endif
+ ret = xf86AddResToList(ret, &range, -1);
+ return ret;
+}
+
+#endif /* INCLUDE_UNUSED */
+
+resPtr
+xf86AccResFromOS(resPtr ret)
+{
+ resRange range;
+
+ /*
+ * At minimum, the top and bottom resources must be claimed, so that
+ * resources that are (or appear to be) unallocated can be relocated.
+ */
+ RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+#if defined(__sparc__) || defined(__powerpc__)
+ RANGE(range, 0x00ffffff, 0x00ffffff, ResExcIoBlock);
+#else
+ RANGE(range, 0x0000ffff, 0x0000ffff, ResExcIoBlock);
+#endif
+ ret = xf86AddResToList(ret, &range, -1);
+
+ return ret;
+}
+
+#else
+
+#error : Put your platform dependent code here!!
+
+#endif
+
+#endif /* INCLUDE_XF86_NO_DOMAIN */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_KbdMap.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_KbdMap.c
new file mode 100644
index 000000000..3a5a57b8c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_KbdMap.c
@@ -0,0 +1,606 @@
+/* $XFree86$ */
+
+/*
+ * Slightly modified xf86KbdLnx.c which is
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86Xinput.h"
+#include "xf86OSKbd.h"
+#include "atKeynames.h"
+
+#include "xf86Keymap.h"
+
+#include "lnx_kbd.h"
+
+/*ARGSUSED*/
+
+/*
+ * KbdGetMapping --
+ * Get the national keyboard mapping. The keyboard type is set, a new map
+ * and the modifiermap is computed.
+ */
+
+static void readKernelMapping(InputInfoPtr pInfo,
+ KeySymsPtr pKeySyms, CARD8 *pModMap);
+void
+KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ KeySym *k;
+ char type;
+ int i;
+
+ readKernelMapping(pInfo, pKeySyms, pModMap);
+
+ /*
+ * compute the modifier map
+ */
+ for (i = 0; i < MAP_LENGTH; i++)
+ pModMap[i] = NoSymbol; /* make sure it is restored */
+
+ for (k = map, i = MIN_KEYCODE;
+ i < (NUM_KEYCODES + MIN_KEYCODE);
+ i++, k += 4)
+
+ switch(*k) {
+
+ case XK_Shift_L:
+ case XK_Shift_R:
+ pModMap[i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ case XK_Control_R:
+ pModMap[i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ pModMap[i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ case XK_Alt_R:
+ pModMap[i] = AltMask;
+ break;
+
+ case XK_Num_Lock:
+ pModMap[i] = NumLockMask;
+ break;
+
+ case XK_Scroll_Lock:
+ pModMap[i] = ScrollLockMask;
+ break;
+
+ /* kana support */
+ case XK_Kana_Lock:
+ case XK_Kana_Shift:
+ pModMap[i] = KanaMask;
+ break;
+
+ /* alternate toggle for multinational support */
+ case XK_Mode_switch:
+ pModMap[i] = AltLangMask;
+ break;
+
+ }
+
+ pKbd->kbdType = ioctl(pInfo->fd, KDGKBTYPE, &type) != -1 ? type : KB_101;
+
+ pKeySyms->map = map;
+ pKeySyms->mapWidth = GLYPHS_PER_KEY;
+ pKeySyms->minKeyCode = MIN_KEYCODE;
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
+}
+
+#include <linux/keyboard.h>
+
+static KeySym linux_to_x[256] = {
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Escape,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
+ XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
+ XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
+ XK_comma, XK_minus, XK_period, XK_slash,
+ XK_0, XK_1, XK_2, XK_3,
+ XK_4, XK_5, XK_6, XK_7,
+ XK_8, XK_9, XK_colon, XK_semicolon,
+ XK_less, XK_equal, XK_greater, XK_question,
+ XK_at, XK_A, XK_B, XK_C,
+ XK_D, XK_E, XK_F, XK_G,
+ XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O,
+ XK_P, XK_Q, XK_R, XK_S,
+ XK_T, XK_U, XK_V, XK_W,
+ XK_X, XK_Y, XK_Z, XK_bracketleft,
+ XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
+ XK_grave, XK_a, XK_b, XK_c,
+ XK_d, XK_e, XK_f, XK_g,
+ XK_h, XK_i, XK_j, XK_k,
+ XK_l, XK_m, XK_n, XK_o,
+ XK_p, XK_q, XK_r, XK_s,
+ XK_t, XK_u, XK_v, XK_w,
+ XK_x, XK_y, XK_z, XK_braceleft,
+ XK_bar, XK_braceright, XK_asciitilde, XK_BackSpace,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_nobreakspace,XK_exclamdown, XK_cent, XK_sterling,
+ XK_currency, XK_yen, XK_brokenbar, XK_section,
+ XK_diaeresis, XK_copyright, XK_ordfeminine, XK_guillemotleft,
+ XK_notsign, XK_hyphen, XK_registered, XK_macron,
+ XK_degree, XK_plusminus, XK_twosuperior, XK_threesuperior,
+ XK_acute, XK_mu, XK_paragraph, XK_periodcentered,
+ XK_cedilla, XK_onesuperior, XK_masculine, XK_guillemotright,
+ XK_onequarter, XK_onehalf, XK_threequarters,XK_questiondown,
+ XK_Agrave, XK_Aacute, XK_Acircumflex, XK_Atilde,
+ XK_Adiaeresis, XK_Aring, XK_AE, XK_Ccedilla,
+ XK_Egrave, XK_Eacute, XK_Ecircumflex, XK_Ediaeresis,
+ XK_Igrave, XK_Iacute, XK_Icircumflex, XK_Idiaeresis,
+ XK_ETH, XK_Ntilde, XK_Ograve, XK_Oacute,
+ XK_Ocircumflex, XK_Otilde, XK_Odiaeresis, XK_multiply,
+ XK_Ooblique, XK_Ugrave, XK_Uacute, XK_Ucircumflex,
+ XK_Udiaeresis, XK_Yacute, XK_THORN, XK_ssharp,
+ XK_agrave, XK_aacute, XK_acircumflex, XK_atilde,
+ XK_adiaeresis, XK_aring, XK_ae, XK_ccedilla,
+ XK_egrave, XK_eacute, XK_ecircumflex, XK_ediaeresis,
+ XK_igrave, XK_iacute, XK_icircumflex, XK_idiaeresis,
+ XK_eth, XK_ntilde, XK_ograve, XK_oacute,
+ XK_ocircumflex, XK_otilde, XK_odiaeresis, XK_division,
+ XK_oslash, XK_ugrave, XK_uacute, XK_ucircumflex,
+ XK_udiaeresis, XK_yacute, XK_thorn, XK_ydiaeresis
+};
+
+/*
+ * Maps the AT keycodes to Linux keycodes
+ */
+static unsigned char at2lnx[NUM_KEYCODES] =
+{
+ 0x01, /* KEY_Escape */ 0x02, /* KEY_1 */
+ 0x03, /* KEY_2 */ 0x04, /* KEY_3 */
+ 0x05, /* KEY_4 */ 0x06, /* KEY_5 */
+ 0x07, /* KEY_6 */ 0x08, /* KEY_7 */
+ 0x09, /* KEY_8 */ 0x0a, /* KEY_9 */
+ 0x0b, /* KEY_0 */ 0x0c, /* KEY_Minus */
+ 0x0d, /* KEY_Equal */ 0x0e, /* KEY_BackSpace */
+ 0x0f, /* KEY_Tab */ 0x10, /* KEY_Q */
+ 0x11, /* KEY_W */ 0x12, /* KEY_E */
+ 0x13, /* KEY_R */ 0x14, /* KEY_T */
+ 0x15, /* KEY_Y */ 0x16, /* KEY_U */
+ 0x17, /* KEY_I */ 0x18, /* KEY_O */
+ 0x19, /* KEY_P */ 0x1a, /* KEY_LBrace */
+ 0x1b, /* KEY_RBrace */ 0x1c, /* KEY_Enter */
+ 0x1d, /* KEY_LCtrl */ 0x1e, /* KEY_A */
+ 0x1f, /* KEY_S */ 0x20, /* KEY_D */
+ 0x21, /* KEY_F */ 0x22, /* KEY_G */
+ 0x23, /* KEY_H */ 0x24, /* KEY_J */
+ 0x25, /* KEY_K */ 0x26, /* KEY_L */
+ 0x27, /* KEY_SemiColon */ 0x28, /* KEY_Quote */
+ 0x29, /* KEY_Tilde */ 0x2a, /* KEY_ShiftL */
+ 0x2b, /* KEY_BSlash */ 0x2c, /* KEY_Z */
+ 0x2d, /* KEY_X */ 0x2e, /* KEY_C */
+ 0x2f, /* KEY_V */ 0x30, /* KEY_B */
+ 0x31, /* KEY_N */ 0x32, /* KEY_M */
+ 0x33, /* KEY_Comma */ 0x34, /* KEY_Period */
+ 0x35, /* KEY_Slash */ 0x36, /* KEY_ShiftR */
+ 0x37, /* KEY_KP_Multiply */ 0x38, /* KEY_Alt */
+ 0x39, /* KEY_Space */ 0x3a, /* KEY_CapsLock */
+ 0x3b, /* KEY_F1 */ 0x3c, /* KEY_F2 */
+ 0x3d, /* KEY_F3 */ 0x3e, /* KEY_F4 */
+ 0x3f, /* KEY_F5 */ 0x40, /* KEY_F6 */
+ 0x41, /* KEY_F7 */ 0x42, /* KEY_F8 */
+ 0x43, /* KEY_F9 */ 0x44, /* KEY_F10 */
+ 0x45, /* KEY_NumLock */ 0x46, /* KEY_ScrollLock */
+ 0x47, /* KEY_KP_7 */ 0x48, /* KEY_KP_8 */
+ 0x49, /* KEY_KP_9 */ 0x4a, /* KEY_KP_Minus */
+ 0x4b, /* KEY_KP_4 */ 0x4c, /* KEY_KP_5 */
+ 0x4d, /* KEY_KP_6 */ 0x4e, /* KEY_KP_Plus */
+ 0x4f, /* KEY_KP_1 */ 0x50, /* KEY_KP_2 */
+ 0x51, /* KEY_KP_3 */ 0x52, /* KEY_KP_0 */
+ 0x53, /* KEY_KP_Decimal */ 0x54, /* KEY_SysReqest */
+ 0x00, /* 0x55 */ 0x56, /* KEY_Less */
+ 0x57, /* KEY_F11 */ 0x58, /* KEY_F12 */
+ 0x66, /* KEY_Home */ 0x67, /* KEY_Up */
+ 0x68, /* KEY_PgUp */ 0x69, /* KEY_Left */
+ 0x5d, /* KEY_Begin */ 0x6a, /* KEY_Right */
+ 0x6b, /* KEY_End */ 0x6c, /* KEY_Down */
+ 0x6d, /* KEY_PgDown */ 0x6e, /* KEY_Insert */
+ 0x6f, /* KEY_Delete */ 0x60, /* KEY_KP_Enter */
+ 0x61, /* KEY_RCtrl */ 0x77, /* KEY_Pause */
+ 0x63, /* KEY_Print */ 0x62, /* KEY_KP_Divide */
+ 0x64, /* KEY_AltLang */ 0x65, /* KEY_Break */
+ 0x00, /* KEY_LMeta */ 0x00, /* KEY_RMeta */
+ 0x7A, /* KEY_Menu/FOCUS_PF11*/0x00, /* 0x6e */
+ 0x7B, /* FOCUS_PF12 */ 0x00, /* 0x70 */
+ 0x00, /* 0x71 */ 0x00, /* 0x72 */
+ 0x59, /* FOCUS_PF2 */ 0x78, /* FOCUS_PF9 */
+ 0x00, /* 0x75 */ 0x00, /* 0x76 */
+ 0x5A, /* FOCUS_PF3 */ 0x5B, /* FOCUS_PF4 */
+ 0x5C, /* FOCUS_PF5 */ 0x5D, /* FOCUS_PF6 */
+ 0x5E, /* FOCUS_PF7 */ 0x5F, /* FOCUS_PF8 */
+ 0x7C, /* JAP_86 */ 0x79, /* FOCUS_PF10 */
+ 0x00, /* 0x7f */
+};
+#define NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0]))
+
+#define NUM_CUSTOMKEYS NR_KEYS
+
+static void
+readKernelMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ KeySym *k;
+ int i;
+ int maxkey;
+ static unsigned char tbl[GLYPHS_PER_KEY] =
+ {
+ 0, /* unshifted */
+ 1, /* shifted */
+ 0, /* modeswitch unshifted */
+ 0 /* modeswitch shifted */
+ };
+
+ /*
+ * Read the mapping from the kernel.
+ * Since we're still using the XFree86 scancode->AT keycode mapping
+ * routines, we need to convert the AT keycodes to Linux keycodes,
+ * then translate the Linux keysyms into X keysyms.
+ *
+ * First, figure out which tables to use for the modeswitch columns
+ * above, from the XF86Config fields.
+ */
+ tbl[2] = 8; /* alt */
+ tbl[3] = tbl[2] | 1;
+
+ if (pKbd->CustomKeycodes) {
+ k = map;
+ maxkey = NUM_CUSTOMKEYS;
+ }
+ else {
+ k = map+GLYPHS_PER_KEY;
+ maxkey = NUM_AT2LNX;
+ }
+
+ for (i = 0; i < maxkey; ++i)
+ {
+ struct kbentry kbe;
+ int j;
+
+ if (pKbd->CustomKeycodes)
+ kbe.kb_index = i;
+ else
+ kbe.kb_index = at2lnx[i];
+
+ for (j = 0; j < GLYPHS_PER_KEY; ++j, ++k)
+ {
+ unsigned short kval;
+
+ *k = NoSymbol;
+
+ kbe.kb_table = tbl[j];
+ if (
+ (!pKbd->CustomKeycodes && kbe.kb_index == 0) ||
+ ioctl(pInfo->fd, KDGKBENT, &kbe))
+ continue;
+
+ kval = KVAL(kbe.kb_value);
+ switch (KTYP(kbe.kb_value))
+ {
+ case KT_LATIN:
+ case KT_LETTER:
+ *k = linux_to_x[kval];
+ break;
+
+ case KT_FN:
+ if (kval <= 19)
+ *k = XK_F1 + kval;
+ else switch (kbe.kb_value)
+ {
+ case K_FIND:
+ *k = XK_Home; /* or XK_Find */
+ break;
+ case K_INSERT:
+ *k = XK_Insert;
+ break;
+ case K_REMOVE:
+ *k = XK_Delete;
+ break;
+ case K_SELECT:
+ *k = XK_End; /* or XK_Select */
+ break;
+ case K_PGUP:
+ *k = XK_Prior;
+ break;
+ case K_PGDN:
+ *k = XK_Next;
+ break;
+ case K_HELP:
+ *k = XK_Help;
+ break;
+ case K_DO:
+ *k = XK_Execute;
+ break;
+ case K_PAUSE:
+ *k = XK_Pause;
+ break;
+ case K_MACRO:
+ *k = XK_Menu;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case KT_SPEC:
+ switch (kbe.kb_value)
+ {
+ case K_ENTER:
+ *k = XK_Return;
+ break;
+ case K_BREAK:
+ *k = XK_Break;
+ break;
+ case K_CAPS:
+ *k = XK_Caps_Lock;
+ break;
+ case K_NUM:
+ *k = XK_Num_Lock;
+ break;
+ case K_HOLD:
+ *k = XK_Scroll_Lock;
+ break;
+ case K_COMPOSE:
+ *k = XK_Multi_key;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case KT_PAD:
+ switch (kbe.kb_value)
+ {
+ case K_PPLUS:
+ *k = XK_KP_Add;
+ break;
+ case K_PMINUS:
+ *k = XK_KP_Subtract;
+ break;
+ case K_PSTAR:
+ *k = XK_KP_Multiply;
+ break;
+ case K_PSLASH:
+ *k = XK_KP_Divide;
+ break;
+ case K_PENTER:
+ *k = XK_KP_Enter;
+ break;
+ case K_PCOMMA:
+ *k = XK_KP_Separator;
+ break;
+ case K_PDOT:
+ *k = XK_KP_Decimal;
+ break;
+ case K_PPLUSMINUS:
+ *k = XK_KP_Subtract;
+ break;
+ default:
+ if (kval <= 9)
+ *k = XK_KP_0 + kval;
+ break;
+ }
+ break;
+
+ /*
+ * KT_DEAD keys are for accelerated diacritical creation.
+ */
+ case KT_DEAD:
+ switch (kbe.kb_value)
+ {
+ case K_DGRAVE:
+ *k = XK_dead_grave;
+ break;
+ case K_DACUTE:
+ *k = XK_dead_acute;
+ break;
+ case K_DCIRCM:
+ *k = XK_dead_circumflex;
+ break;
+ case K_DTILDE:
+ *k = XK_dead_tilde;
+ break;
+ case K_DDIERE:
+ *k = XK_dead_diaeresis;
+ break;
+ }
+ break;
+
+ case KT_CUR:
+ switch (kbe.kb_value)
+ {
+ case K_DOWN:
+ *k = XK_Down;
+ break;
+ case K_LEFT:
+ *k = XK_Left;
+ break;
+ case K_RIGHT:
+ *k = XK_Right;
+ break;
+ case K_UP:
+ *k = XK_Up;
+ break;
+ }
+ break;
+
+ case KT_SHIFT:
+ switch (kbe.kb_value)
+ {
+ case K_ALTGR:
+ *k = XK_Alt_R;
+ break;
+ case K_ALT:
+ *k = (kbe.kb_index == 0x64 ?
+ XK_Alt_R : XK_Alt_L);
+ break;
+ case K_CTRL:
+ *k = (kbe.kb_index == 0x61 ?
+ XK_Control_R : XK_Control_L);
+ break;
+ case K_CTRLL:
+ *k = XK_Control_L;
+ break;
+ case K_CTRLR:
+ *k = XK_Control_R;
+ break;
+ case K_SHIFT:
+ *k = (kbe.kb_index == 0x36 ?
+ XK_Shift_R : XK_Shift_L);
+ break;
+ case K_SHIFTL:
+ *k = XK_Shift_L;
+ break;
+ case K_SHIFTR:
+ *k = XK_Shift_R;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ /*
+ * KT_ASCII keys accumulate a 3 digit decimal number that gets
+ * emitted when the shift state changes. We can't emulate that.
+ */
+ case KT_ASCII:
+ break;
+
+ case KT_LOCK:
+ if (kbe.kb_value == K_SHIFTLOCK)
+ *k = XK_Shift_Lock;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if (k[-1] == k[-2]) k[-1] = NoSymbol;
+ if (k[-2] == k[-3]) k[-2] = NoSymbol;
+ if (k[-3] == k[-4]) k[-3] = NoSymbol;
+ if (k[-4] == k[-2] && k[-3] == k[-1]) k[-2] = k[-1] = NoSymbol;
+ if (k[-1] == k[-4] && k[-2] == k[-3] && k[-2] == NoSymbol) k[-1] =NoSymbol;
+ }
+
+ if (!pKbd->CustomKeycodes)
+ return;
+
+ /*
+ * Find the Mapping for the special server functions
+ */
+ pKbd->specialMap = (TransMapPtr) xcalloc(NUM_CUSTOMKEYS, 1);
+ if (pKbd->specialMap != NULL) {
+ pKbd->specialMap->end = NUM_CUSTOMKEYS;
+ pKbd->specialMap->map = (unsigned char*) xcalloc(NUM_CUSTOMKEYS, 1);
+ if (pKbd->specialMap == NULL) {
+ xfree(pKbd->specialMap);
+ pKbd->specialMap = NULL;
+ }
+ }
+ if (pKbd->specialMap == NULL) {
+ xf86Msg(X_ERROR, "%s can't allocate \"special map\"\n", pInfo->name);
+ return;
+ }
+
+ for (i = 0; i < NUM_CUSTOMKEYS; ++i) {
+ struct kbentry kbe;
+ int special = 0;
+
+ kbe.kb_index = i;
+ kbe.kb_table = 0; /* Plain map */
+ if (!ioctl(pInfo->fd, KDGKBENT, &kbe))
+ switch (kbe.kb_value) {
+ case K(KT_LATIN,0x7f): /* This catches DEL too... But who cares? */
+ special = KEY_BackSpace;
+ break;
+ case K_PMINUS:
+ special = KEY_KP_Minus;
+ break;
+ case K_PPLUS:
+ special = KEY_KP_Plus;
+ break;
+ case K_F1:
+ special = KEY_F1;
+ break;
+ case K_F2:
+ special = KEY_F2;
+ break;
+ case K_F3:
+ special = KEY_F3;
+ break;
+ case K_F4:
+ special = KEY_F4;
+ break;
+ case K_F5:
+ special = KEY_F5;
+ break;
+ case K_F6:
+ special = KEY_F6;
+ break;
+ case K_F7:
+ special = KEY_F7;
+ break;
+ case K_F8:
+ special = KEY_F8;
+ break;
+ case K_F9:
+ special = KEY_F9;
+ break;
+ case K_F10:
+ special = KEY_F10;
+ break;
+ case K_F11:
+ special = KEY_F11;
+ break;
+ case K_F12:
+ special = KEY_F12;
+ break;
+ case K_ALT:
+ special = KEY_Alt;
+ break;
+ case K_ALTGR:
+ special = KEY_AltLang;
+ break;
+ case K_CONS:
+ special = KEY_SysReqest;
+ break;
+ }
+ pKbd->specialMap->map[i] = special;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_acpi.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_acpi.c
new file mode 100644
index 000000000..9d1dea77d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_acpi.c
@@ -0,0 +1,170 @@
+#include "X.h"
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
+#include "xf86_OSproc.h"
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#define ACPI_SOCKET "/var/run/acpid.socket"
+#define ACPI_EVENTS "/proc/acpi/event"
+
+#define ACPI_VIDEO_NOTIFY_SWITCH 0x80
+#define ACPI_VIDEO_NOTIFY_PROBE 0x81
+#define ACPI_VIDEO_NOTIFY_CYCLE 0x82
+#define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83
+#define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84
+
+#define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x82
+#define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x83
+#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x84
+#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x85
+#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x86
+
+#define ACPI_VIDEO_HEAD_INVALID (~0u - 1)
+#define ACPI_VIDEO_HEAD_END (~0u)
+
+static void lnxCloseACPI(void);
+static pointer ACPIihPtr = NULL;
+PMClose lnxACPIOpen(void);
+
+#define LINE_LENGTH 80
+
+static int
+lnxACPIGetEventFromOs(int fd, pmEvent *events, int num)
+{
+ char ev[LINE_LENGTH];
+ int n;
+
+ memset(ev, 0, LINE_LENGTH);
+
+ n = read( fd, ev, LINE_LENGTH );
+
+ /* Check that we have a video event */
+ if (strstr(ev, "video") == ev) {
+ char *video = NULL;
+ char *GFX = NULL;
+ char *notify = NULL;
+ char *data = NULL; /* doesn't appear to be used in the kernel */
+ unsigned long int notify_l, data_l;
+
+ video = strtok(ev, "video");
+
+ GFX = strtok(NULL, " ");
+#if 0
+ ErrorF("GFX: %s\n",GFX);
+#endif
+
+ notify = strtok(NULL, " ");
+ notify_l = strtoul(notify, NULL, 16);
+#if 0
+ ErrorF("notify: 0x%lx\n",notify_l);
+#endif
+
+ data = strtok(NULL, " ");
+ data_l = strtoul(data, NULL, 16);
+#if 0
+ ErrorF("data: 0x%lx\n",data_l);
+#endif
+
+ /* We currently don't differentiate between any event */
+ switch (notify_l) {
+ case ACPI_VIDEO_NOTIFY_SWITCH:
+ break;
+ case ACPI_VIDEO_NOTIFY_PROBE:
+ break;
+ case ACPI_VIDEO_NOTIFY_CYCLE:
+ break;
+ case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT:
+ break;
+ case ACPI_VIDEO_NOTIFY_PREV_OUTPUT:
+ break;
+ default:
+ break;
+ }
+
+ /* Deal with all ACPI events as a capability change */
+ events[0] = XF86_APM_CAPABILITY_CHANGED;
+
+ return 1;
+ }
+
+ return 0;
+}
+
+static pmWait
+lnxACPIConfirmEventToOs(int fd, pmEvent event)
+{
+ /* No ability to send back to the kernel in ACPI */
+ switch (event) {
+ default:
+ return PM_NONE;
+ }
+}
+
+PMClose
+lnxACPIOpen(void)
+{
+ int fd;
+ struct sockaddr_un addr;
+ int r = -1;
+
+#ifdef DEBUG
+ ErrorF("ACPI: OSPMOpen called\n");
+#endif
+ if (ACPIihPtr || !xf86Info.pmFlag)
+ return NULL;
+
+#ifdef DEBUG
+ ErrorF("ACPI: Opening device\n");
+#endif
+ if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) > -1) {
+ memset(&addr, 0, sizeof(addr));
+ addr.sun_family = AF_UNIX;
+ strcpy(addr.sun_path, ACPI_SOCKET);
+ if ((r = connect(fd, (struct sockaddr*)&addr, sizeof(addr))) == -1) {
+ shutdown(fd, 2);
+ close(fd);
+ fd = -1;
+ }
+ }
+
+ /* acpid's socket isn't available, so try going direct */
+ if (fd == -1) {
+ if ((fd = open(ACPI_EVENTS, O_RDONLY)) < 0) {
+ xf86MsgVerb(X_WARNING,3,"Open ACPI failed (%s) (%s)\n", ACPI_EVENTS,
+ strerror(errno));
+ return NULL;
+ }
+ }
+
+ xf86PMGetEventFromOs = lnxACPIGetEventFromOs;
+ xf86PMConfirmEventToOs = lnxACPIConfirmEventToOs;
+ ACPIihPtr = xf86AddInputHandler(fd,xf86HandlePMEvents,NULL);
+ xf86MsgVerb(X_INFO,3,"Open ACPI successful (%s)\n", (r != -1) ? ACPI_SOCKET : ACPI_EVENTS);
+
+ return lnxCloseACPI;
+}
+
+static void
+lnxCloseACPI(void)
+{
+ int fd;
+
+#ifdef DEBUG
+ ErrorF("ACPI: Closing device\n");
+#endif
+ if (ACPIihPtr) {
+ fd = xf86RemoveInputHandler(ACPIihPtr);
+ shutdown(fd, 2);
+ close(fd);
+ ACPIihPtr = NULL;
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c
new file mode 100644
index 000000000..6a5c83db2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c
@@ -0,0 +1,371 @@
+/*
+ * Abstraction of the AGP GART interface.
+ *
+ * This version is for both Linux and FreeBSD.
+ *
+ * Copyright © 2000 VA Linux Systems, Inc.
+ * Copyright © 2001 The XFree86 Project, Inc.
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c,v 3.11 2003/04/03 22:47:42 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#if defined(linux)
+#include <asm/ioctl.h>
+#include <linux/agpgart.h>
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+#include <sys/ioctl.h>
+#include <sys/agpio.h>
+#endif
+
+#ifndef AGP_DEVICE
+#define AGP_DEVICE "/dev/agpgart"
+#endif
+/* AGP page size is independent of the host page size. */
+#ifndef AGP_PAGE_SIZE
+#define AGP_PAGE_SIZE 4096
+#endif
+#define AGPGART_MAJOR_VERSION 0
+#define AGPGART_MINOR_VERSION 99
+
+static int gartFd = -1;
+static int acquiredScreen = -1;
+static Bool initDone = FALSE;
+/*
+ * Close /dev/agpgart. This frees all associated memory allocated during
+ * this server generation.
+ */
+Bool
+xf86GARTCloseScreen(int screenNum)
+{
+ if(gartFd != -1) {
+ close(gartFd);
+ acquiredScreen = -1;
+ gartFd = -1;
+ initDone = FALSE;
+ }
+ return TRUE;
+}
+
+/*
+ * Open /dev/agpgart. Keep it open until xf86GARTCloseScreen is called.
+ */
+static Bool
+GARTInit(int screenNum)
+{
+ struct _agp_info agpinf;
+
+ if (initDone)
+ return (gartFd != -1);
+
+ initDone = TRUE;
+
+ if (gartFd == -1)
+ gartFd = open(AGP_DEVICE, O_RDWR, 0);
+ else
+ return FALSE;
+
+ if (gartFd == -1) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "GARTInit: Unable to open " AGP_DEVICE " (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+
+ xf86AcquireGART(-1);
+ /* Check the kernel driver version. */
+ if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "GARTInit: AGPIOC_INFO failed (%s)\n", strerror(errno));
+ close(gartFd);
+ gartFd = -1;
+ return FALSE;
+ }
+ xf86ReleaseGART(-1);
+
+#if defined(linux)
+ /* Per Dave Jones, every effort will be made to keep the
+ * agpgart interface backwards compatible, so allow all
+ * future versions.
+ */
+ if (
+#if (AGPGART_MAJOR_VERSION > 0) /* quiet compiler */
+ agpinf.version.major < AGPGART_MAJOR_VERSION ||
+#endif
+ (agpinf.version.major == AGPGART_MAJOR_VERSION &&
+ agpinf.version.minor < AGPGART_MINOR_VERSION)) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "GARTInit: Kernel agpgart driver version is not current"
+ " (%d.%d vs %d.%d)\n",
+ agpinf.version.major, agpinf.version.minor,
+ AGPGART_MAJOR_VERSION, AGPGART_MINOR_VERSION);
+ close(gartFd);
+ gartFd = -1;
+ return FALSE;
+ }
+#endif
+
+ return TRUE;
+}
+
+Bool
+xf86AgpGARTSupported()
+{
+ return GARTInit(-1);
+}
+
+AgpInfoPtr
+xf86GetAGPInfo(int screenNum)
+{
+ struct _agp_info agpinf;
+ AgpInfoPtr info;
+
+ if (!GARTInit(screenNum))
+ return NULL;
+
+
+ if ((info = xcalloc(sizeof(AgpInfo), 1)) == NULL) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86GetAGPInfo: Failed to allocate AgpInfo\n");
+ return NULL;
+ }
+
+ memset((char*)&agpinf, 0, sizeof(agpinf));
+
+ if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
+ strerror(errno));
+ return NULL;
+ }
+
+ info->bridgeId = agpinf.bridge_id;
+ info->agpMode = agpinf.agp_mode;
+ info->base = agpinf.aper_base;
+ info->size = agpinf.aper_size;
+ info->totalPages = agpinf.pg_total;
+ info->systemPages = agpinf.pg_system;
+ info->usedPages = agpinf.pg_used;
+
+ xf86DrvMsg(screenNum, X_INFO, "Kernel reported %d total, %d used\n", agpinf.pg_total, agpinf.pg_used);
+
+ return info;
+}
+
+/*
+ * XXX If multiple screens can acquire the GART, should we have a reference
+ * count instead of using acquiredScreen?
+ */
+
+Bool
+xf86AcquireGART(int screenNum)
+{
+ if (screenNum != -1 && !GARTInit(screenNum))
+ return FALSE;
+
+ if (screenNum == -1 || acquiredScreen != screenNum) {
+ if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "xf86AcquireGART: AGPIOC_ACQUIRE failed (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+ acquiredScreen = screenNum;
+ }
+ return TRUE;
+}
+
+Bool
+xf86ReleaseGART(int screenNum)
+{
+ if (screenNum != -1 && !GARTInit(screenNum))
+ return FALSE;
+
+ if (acquiredScreen == screenNum) {
+ /*
+ * The FreeBSD agp driver removes allocations on release.
+ * The Linux driver doesn't. xf86ReleaseGART() is expected
+ * to give up access to the GART, but not to remove any
+ * allocations.
+ */
+#if !defined(linux)
+ if (screenNum == -1)
+#endif
+ {
+ if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "xf86ReleaseGART: AGPIOC_RELEASE failed (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+ acquiredScreen = -1;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+int
+xf86AllocateGARTMemory(int screenNum, unsigned long size, int type,
+ unsigned long *physical)
+{
+ struct _agp_allocate alloc;
+ int pages;
+
+ /*
+ * Allocates "size" bytes of GART memory (rounds up to the next
+ * page multiple) or type "type". A handle (key) for the allocated
+ * memory is returned. On error, the return value is -1.
+ */
+
+ if (!GARTInit(screenNum) || acquiredScreen != screenNum)
+ return -1;
+
+ pages = (size / AGP_PAGE_SIZE);
+ if (size % AGP_PAGE_SIZE != 0)
+ pages++;
+
+ /* XXX check for pages == 0? */
+
+ alloc.pg_count = pages;
+ alloc.type = type;
+
+ if (ioctl(gartFd, AGPIOC_ALLOCATE, &alloc) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86AllocateGARTMemory: "
+ "allocation of %d pages failed\n\t(%s)\n", pages,
+ strerror(errno));
+ return -1;
+ }
+
+ if (physical)
+ *physical = alloc.physical;
+
+ return alloc.key;
+}
+
+Bool
+xf86DeallocateGARTMemory(int screenNum, int key)
+{
+ if (!GARTInit(screenNum) || acquiredScreen != screenNum)
+ return FALSE;
+
+ if (acquiredScreen != screenNum) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86UnbindGARTMemory: AGP not acquired by this screen\n");
+ return FALSE;
+ }
+
+ if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *)key) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING,"xf86DeAllocateGARTMemory: "
+ "deallocation gart memory with key %d failed\n\t(%s)\n",
+ key, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Bind GART memory with "key" at "offset" */
+Bool
+xf86BindGARTMemory(int screenNum, int key, unsigned long offset)
+{
+ struct _agp_bind bind;
+ int pageOffset;
+
+ if (!GARTInit(screenNum) || acquiredScreen != screenNum)
+ return FALSE;
+
+ if (acquiredScreen != screenNum) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86BindGARTMemory: AGP not acquired by this screen\n");
+ return FALSE;
+ }
+
+ if (offset % AGP_PAGE_SIZE != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: "
+ "offset (0x%lx) is not page-aligned (%d)\n",
+ offset, AGP_PAGE_SIZE);
+ return FALSE;
+ }
+ pageOffset = offset / AGP_PAGE_SIZE;
+
+ xf86DrvMsgVerb(screenNum, X_INFO, 3,
+ "xf86BindGARTMemory: bind key %d at 0x%08lx "
+ "(pgoffset %d)\n", key, offset, pageOffset);
+
+ bind.pg_start = pageOffset;
+ bind.key = key;
+
+ if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: "
+ "binding of gart memory with key %d\n"
+ "\tat offset 0x%lx failed (%s)\n",
+ key, offset, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/* Unbind GART memory with "key" */
+Bool
+xf86UnbindGARTMemory(int screenNum, int key)
+{
+ struct _agp_unbind unbind;
+
+ if (!GARTInit(screenNum) || acquiredScreen != screenNum)
+ return FALSE;
+
+ if (acquiredScreen != screenNum) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86UnbindGARTMemory: AGP not acquired by this screen\n");
+ return FALSE;
+ }
+
+ unbind.priority = 0;
+ unbind.key = key;
+
+ if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86UnbindGARTMemory: "
+ "unbinding of gart memory with key %d "
+ "failed (%s)\n", key, strerror(errno));
+ return FALSE;
+ }
+
+ xf86DrvMsgVerb(screenNum, X_INFO, 3,
+ "xf86UnbindGARTMemory: unbind key %d\n", key);
+
+ return TRUE;
+}
+
+
+/* XXX Interface may change. */
+Bool
+xf86EnableAGP(int screenNum, CARD32 mode)
+{
+ agp_setup setup;
+
+ if (!GARTInit(screenNum) || acquiredScreen != screenNum)
+ return FALSE;
+
+ setup.agp_mode = mode;
+ if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86EnableAGP: "
+ "AGPIOC_SETUP with mode %ld failed (%s)\n",
+ (unsigned long)mode, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c
new file mode 100644
index 000000000..bd78d877f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c
@@ -0,0 +1,192 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c,v 3.12 2001/12/24 22:54:31 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
+#include "xf86_OSproc.h"
+#include "lnx.h"
+#include <linux/apm_bios.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#define APM_PROC "/proc/apm"
+#define APM_DEVICE "/dev/apm_bios"
+
+#ifndef APM_STANDBY_FAILED
+# define APM_STANDBY_FAILED 0xf000
+#endif
+#ifndef APM_SUSPEND_FAILED
+# define APM_SUSPEND_FAILED 0xf001
+#endif
+
+static PMClose lnxAPMOpen(void);
+extern PMClose lnxACPIOpen(void);
+static void lnxCloseAPM(void);
+static pointer APMihPtr = NULL;
+
+static struct {
+ apm_event_t apmLinux;
+ pmEvent xf86;
+} LinuxToXF86[] = {
+ { APM_SYS_STANDBY, XF86_APM_SYS_STANDBY },
+ { APM_SYS_SUSPEND, XF86_APM_SYS_SUSPEND },
+ { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME },
+ { APM_CRITICAL_RESUME, XF86_APM_CRITICAL_RESUME },
+ { APM_LOW_BATTERY, XF86_APM_LOW_BATTERY },
+ { APM_POWER_STATUS_CHANGE, XF86_APM_POWER_STATUS_CHANGE },
+ { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME },
+ { APM_CRITICAL_SUSPEND, XF86_APM_CRITICAL_SUSPEND },
+ { APM_USER_STANDBY, XF86_APM_USER_STANDBY },
+ { APM_USER_SUSPEND, XF86_APM_USER_SUSPEND },
+ { APM_STANDBY_RESUME, XF86_APM_STANDBY_RESUME },
+#if defined(APM_CAPABILITY_CHANGED)
+ { APM_CAPABILITY_CHANGED, XF86_CAPABILITY_CHANGED },
+#endif
+#if 0
+ { APM_STANDBY_FAILED, XF86_APM_STANDBY_FAILED },
+ { APM_SUSPEND_FAILED, XF86_APM_SUSPEND_FAILED }
+#endif
+};
+
+#define numApmEvents (sizeof(LinuxToXF86) / sizeof(LinuxToXF86[0]))
+
+/*
+ * APM is still under construction.
+ * I'm not sure if the places where I initialize/deinitialize
+ * apm is correct. Also I don't know what to do in SETUP state.
+ * This depends if wakeup gets called in this situation, too.
+ * Also we need to check if the action that is taken on an
+ * event is reasonable.
+ */
+static int
+lnxPMGetEventFromOs(int fd, pmEvent *events, int num)
+{
+ int i,j,n;
+ apm_event_t linuxEvents[8];
+
+ if ((n = read( fd, linuxEvents, num * sizeof(apm_event_t) )) == -1)
+ return 0;
+ n /= sizeof(apm_event_t);
+ if (n > num)
+ n = num;
+ for (i = 0; i < n; i++) {
+ for (j = 0; j < numApmEvents; j++)
+ if (LinuxToXF86[j].apmLinux == linuxEvents[i]) {
+ events[i] = LinuxToXF86[j].xf86;
+ break;
+ }
+ if (j == numApmEvents)
+ events[i] = XF86_APM_UNKNOWN;
+ }
+ return n;
+}
+
+static pmWait
+lnxPMConfirmEventToOs(int fd, pmEvent event)
+{
+ switch (event) {
+ case XF86_APM_SYS_STANDBY:
+ case XF86_APM_USER_STANDBY:
+ if (ioctl( fd, APM_IOC_STANDBY, NULL ))
+ return PM_FAILED;
+ return PM_CONTINUE;
+ case XF86_APM_SYS_SUSPEND:
+ case XF86_APM_CRITICAL_SUSPEND:
+ case XF86_APM_USER_SUSPEND:
+ if (ioctl( fd, APM_IOC_SUSPEND, NULL )) {
+ /* I believe this is wrong (EE)
+ EBUSY is sent when a device refuses to be suspended.
+ In this case we still need to undo everything we have
+ done to suspend ourselves or we will stay in suspended
+ state forever. */
+ if (errno == EBUSY)
+ return PM_CONTINUE;
+ else
+ return PM_FAILED;
+ }
+ return PM_CONTINUE;
+ case XF86_APM_STANDBY_RESUME:
+ case XF86_APM_NORMAL_RESUME:
+ case XF86_APM_CRITICAL_RESUME:
+ case XF86_APM_STANDBY_FAILED:
+ case XF86_APM_SUSPEND_FAILED:
+ return PM_CONTINUE;
+ default:
+ return PM_NONE;
+ }
+}
+
+PMClose
+xf86OSPMOpen(void)
+{
+ PMClose ret = NULL;
+
+ /* Favour ACPI over APM, but only when enabled */
+
+ if (!xf86acpiDisableFlag)
+ ret = lnxACPIOpen();
+
+ if (!ret)
+ ret = lnxAPMOpen();
+
+ return ret;
+}
+
+static PMClose
+lnxAPMOpen(void)
+{
+ int fd, pfd;
+
+#ifdef DEBUG
+ ErrorF("APM: OSPMOpen called\n");
+#endif
+ if (APMihPtr || !xf86Info.pmFlag)
+ return NULL;
+
+#ifdef DEBUG
+ ErrorF("APM: Opening device\n");
+#endif
+ if ((fd = open( APM_DEVICE, O_RDWR )) > -1) {
+ if (access( APM_PROC, R_OK ) ||
+ ((pfd = open( APM_PROC, O_RDONLY)) == -1)) {
+ xf86MsgVerb(X_WARNING,3,"Cannot open APM (%s) (%s)\n",
+ APM_PROC, strerror(errno));
+ close(fd);
+ return NULL;
+ } else
+ close(pfd);
+ xf86PMGetEventFromOs = lnxPMGetEventFromOs;
+ xf86PMConfirmEventToOs = lnxPMConfirmEventToOs;
+ APMihPtr = xf86AddInputHandler(fd,xf86HandlePMEvents,NULL);
+ xf86MsgVerb(X_INFO,3,"Open APM successful\n");
+ return lnxCloseAPM;
+ }
+ xf86MsgVerb(X_INFO,3,"No APM support in BIOS or kernel\n");
+ return NULL;
+}
+
+static void
+lnxCloseAPM(void)
+{
+ int fd;
+
+#ifdef DEBUG
+ ErrorF("APM: Closing device\n");
+#endif
+ if (APMihPtr) {
+ fd = xf86RemoveInputHandler(APMihPtr);
+ close(fd);
+ APMihPtr = NULL;
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_axp.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_axp.c
new file mode 100644
index 000000000..fd47a5559
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_axp.c
@@ -0,0 +1,200 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_axp.c,v 1.3 2001/02/15 11:03:56 alanh Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "shared/xf86Axp.h"
+
+axpDevice lnxGetAXP(void);
+
+typedef struct
+ { char* sysName;
+ char* sysVari;
+ char* cpu;
+ axpDevice sys; }
+AXP;
+
+static AXP axpList[] = {
+ { "Tsunami", NULL, NULL, TSUNAMI },
+ { "Eiger", NULL, NULL, TSUNAMI },
+ {"Noname", NULL, NULL, LCA },
+ { "AlphaBook1", NULL, NULL, LCA },
+ {"EB66", NULL, NULL, LCA},
+ {"EB64+",NULL,NULL, APECS},
+ {"Noritake",NULL,"EV5",CIA},
+ {"Noritake",NULL,"EV56",CIA},
+ {"Noritake",NULL,NULL,APECS},
+ {"XL",NULL,NULL,APECS},
+ {"Avanti",NULL,NULL,APECS},
+ {"Mikasa",NULL,"EV5",CIA},
+ {"Mikasa",NULL,"EV56",CIA},
+ {"Mikasa",NULL,NULL,APECS},
+ {"EB164","EB164",NULL,CIA},
+ {"EB164","PC164", NULL,CIA},
+ {"EB164","LX164",NULL, PYXIS},
+ {"EB164","SX164",NULL, PYXIS},
+ {"EB164","RX164",NULL, POLARIS},
+ {"Alcor",NULL,NULL,CIA},
+ {"Takara",NULL,NULL,CIA},
+ {"Sable",NULL, "EV5",T2_GAMMA},
+ {"Sable",NULL,"EV56",T2_GAMMA},
+ {"Sable",NULL,NULL,T2},
+ {"Rawhide",NULL,NULL,MCPCIA},
+ {"Jensen",NULL,NULL,JENSEN},
+ {"Miata",NULL,NULL,PYXIS_CIA},
+ {"Ruffian",NULL,NULL,PYXIS_CIA},
+ {"Nautilus",NULL,NULL,IRONGATE},
+ {NULL,NULL,NULL,NONE}
+};
+
+
+axpDevice
+lnxGetAXP(void)
+{
+ FILE *file;
+ int count = 0;
+ char res[256];
+ char cpu[255];
+ char systype[255];
+ char sysvari[255];
+ if (!(file = fopen("/proc/cpuinfo","r")))
+ return SYS_NONE;
+ do {
+ if (!fgets(res,0xff,file)) return SYS_NONE;
+ switch (count) {
+ case 1:
+ sscanf(res, "cpu model : %s",cpu);
+#ifdef DEBUG
+ ErrorF("CPU %s\n",cpu);
+#endif
+ break;
+ case 5:
+ sscanf(res, "system type : %s",systype);
+#ifdef DEBUG
+ ErrorF("system type : %s\n",systype);
+#endif
+ break;
+ case 6:
+ sscanf(res, "system variation : %s",sysvari);
+#ifdef DEBUG
+ ErrorF("system variation: %s\n",sysvari);
+#endif
+ break;
+ }
+ count++;
+ } while (count < 8);
+
+ fclose(file);
+
+ count = 0;
+
+ do {
+ if (!axpList[count].sysName || !strcmp(axpList[count].sysName,systype)) {
+ if (axpList[count].sysVari && strcmp(axpList[count].sysVari,sysvari)) {
+ count++;
+ continue;
+ };
+ if (axpList[count].cpu && strcmp(axpList[count].cpu,cpu)) {
+ count++;
+ continue;
+ }
+ return axpList[count].sys;
+ }
+ count++;
+ } while (1);
+}
+
+/*
+ * pciconfig_iobase wrappers and dynamic i/o selection
+ */
+#include <linux/unistd.h>
+#include <asm/pci.h>
+#include <errno.h>
+
+/* glibc versions (single hose only) */
+extern void _outb(char val, unsigned long port);
+extern void _outw(short val, unsigned long port);
+extern void _outl(int val, unsigned long port);
+extern unsigned int _inb(unsigned long port);
+extern unsigned int _inw(unsigned long port);
+extern unsigned int _inl(unsigned long port);
+
+extern void _dense_outb(char, unsigned long);
+extern void _dense_outw(short, unsigned long);
+extern void _dense_outl(int, unsigned long);
+extern unsigned int _dense_inb(unsigned long);
+extern unsigned int _dense_inw(unsigned long);
+extern unsigned int _dense_inl(unsigned long);
+
+void (*_alpha_outb)(char, unsigned long) = _outb;
+void (*_alpha_outw)(short, unsigned long) = _outw;
+void (*_alpha_outl)(int, unsigned long) = _outl;
+unsigned int (*_alpha_inb)(unsigned long) = _inb;
+unsigned int (*_alpha_inw)(unsigned long) = _inw;
+unsigned int (*_alpha_inl)(unsigned long) = _inl;
+
+static long _alpha_iobase_query(unsigned, int, int, int);
+long (*_iobase)(unsigned, int, int, int) = _alpha_iobase_query;
+
+static long
+_alpha_iobase(unsigned flags, int hose, int bus, int devfn)
+{
+#ifdef __NR_pciconfig_iobase
+ if (bus < 0) {
+ bus = hose;
+ flags |= IOBASE_FROM_HOSE;
+ }
+
+ return syscall(__NR_pciconfig_iobase, flags, bus, devfn);
+#else
+ return -ENOSYS
+#endif
+}
+
+static long
+_alpha_iobase_legacy(unsigned flags, int hose, int bus, int devfn)
+{
+ if (hose > 0) return -ENODEV;
+ if (flags & IOBASE_DENSE_MEM) return _bus_base();
+ if (flags & IOBASE_SPARSE_MEM) return _bus_base_sparse();
+ return 0;
+}
+
+static long
+_alpha_iobase_query(unsigned flags, int hose, int bus, int devfn)
+{
+ /*
+ * Only use iobase if the syscall is supported *and* it's
+ * a dense io system
+ */
+ if (_alpha_iobase(IOBASE_DENSE_IO, 0, 0, 0) > 0) {
+ /*
+ * The syscall worked and it's a dense io system - take over the
+ * io subsystem
+ */
+ _iobase = _alpha_iobase;
+
+#ifndef INCLUDE_XF86_NO_DOMAIN
+ /*
+ * Only take over the inx/outx functions if this is a dense I/O
+ * system *and* addressing domains are being used. The dense I/O
+ * routines expect I/O to be mapped (as done in xf86MapDomainIO)
+ */
+ _alpha_outb = _dense_outb;
+ _alpha_outw = _dense_outw;
+ _alpha_outl = _dense_outl;
+ _alpha_inb = _dense_inb;
+ _alpha_inw = _dense_inw;
+ _alpha_inl = _dense_inl;
+#endif /* !INCLUDE_XF86_NO_DOMAIN */
+ } else _iobase = _alpha_iobase_legacy;
+
+ return _iobase(flags, hose, bus, devfn);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_ev56.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_ev56.c
new file mode 100644
index 000000000..63077e907
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_ev56.c
@@ -0,0 +1,151 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_ev56.c,v 3.5 2000/02/17 13:45:49 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "input.h"
+#include "scrnintstr.h"
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+int readDense8(pointer Base, register unsigned long Offset);
+int readDense16(pointer Base, register unsigned long Offset);
+int readDense32(pointer Base, register unsigned long Offset);
+void
+writeDenseNB8(int Value, pointer Base, register unsigned long Offset);
+void
+writeDenseNB16(int Value, pointer Base, register unsigned long Offset);
+void
+writeDenseNB32(int Value, pointer Base, register unsigned long Offset);
+void
+writeDense8(int Value, pointer Base, register unsigned long Offset);
+void
+writeDense16(int Value, pointer Base, register unsigned long Offset);
+void
+writeDense32(int Value, pointer Base, register unsigned long Offset);
+
+int
+readDense8(pointer Base, register unsigned long Offset)
+{
+ mem_barrier();
+ return *(volatile CARD8*) ((unsigned long)Base+(Offset));
+}
+
+int
+readDense16(pointer Base, register unsigned long Offset)
+{
+ mem_barrier();
+ return *(volatile CARD16*) ((unsigned long)Base+(Offset));
+}
+
+int
+readDense32(pointer Base, register unsigned long Offset)
+{
+ mem_barrier();
+ return *(volatile CARD32*)((unsigned long)Base+(Offset));
+}
+
+void
+writeDenseNB8(int Value, pointer Base, register unsigned long Offset)
+{
+ *(volatile CARD8*)((unsigned long)Base+(Offset)) = Value;
+}
+
+void
+writeDenseNB16(int Value, pointer Base, register unsigned long Offset)
+{
+ *(volatile CARD16*)((unsigned long)Base + (Offset)) = Value;
+}
+
+void
+writeDenseNB32(int Value, pointer Base, register unsigned long Offset)
+{
+ *(volatile CARD32*)((unsigned long)Base+(Offset)) = Value;
+}
+
+void
+writeDense8(int Value, pointer Base, register unsigned long Offset)
+{
+ write_mem_barrier();
+ *(volatile CARD8 *)((unsigned long)Base+(Offset)) = Value;
+}
+
+void
+writeDense16(int Value, pointer Base, register unsigned long Offset)
+{
+ write_mem_barrier();
+ *(volatile CARD16 *)((unsigned long)Base+(Offset)) = Value;
+}
+
+void
+writeDense32(int Value, pointer Base, register unsigned long Offset)
+{
+ write_mem_barrier();
+ *(volatile CARD32 *)((unsigned long)Base+(Offset)) = Value;
+}
+
+
+#ifndef INCLUDE_XF86_NO_DOMAIN
+
+void
+_dense_outb(char val, unsigned long port)
+{
+ if ((port & ~0xffff) == 0) return _outb(val, port);
+
+ write_mem_barrier();
+ *(volatile CARD8 *)port = val;
+}
+
+void
+_dense_outw(short val, unsigned long port)
+{
+ if ((port & ~0xffff) == 0) return _outw(val, port);
+
+ write_mem_barrier();
+ *(volatile CARD16 *)port = val;
+}
+
+void
+_dense_outl(int val, unsigned long port)
+{
+ if ((port & ~0xffff) == 0) return _outl(val, port);
+
+ write_mem_barrier();
+ *(volatile CARD32 *)port = val;
+}
+
+unsigned int
+_dense_inb(unsigned long port)
+{
+ if ((port & ~0xffff) == 0) return _inb(port);
+
+ mem_barrier();
+ return *(volatile CARD8 *)port;
+}
+
+unsigned int
+_dense_inw(unsigned long port)
+{
+ if ((port & ~0xffff) == 0) return _inw(port);
+
+ mem_barrier();
+ return *(volatile CARD16 *)port;
+}
+
+unsigned int
+_dense_inl(unsigned long port)
+{
+ if ((port & ~0xffff) == 0) return _inl(port);
+
+ mem_barrier();
+ return *(volatile CARD32 *)port;
+}
+
+#endif /* !INCLUDE_XF86_NO_DOMAIN */
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_font.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_font.c
new file mode 100644
index 000000000..e9a5b6aef
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_font.c
@@ -0,0 +1,291 @@
+/*
+ * Copyright 2004, Egbert Eich
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * EGBERT EICH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+ * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Egbert Eich shall not
+ * be used in advertising or otherwise to promote the sale, use or other deal-
+ *ings in this Software without prior written authorization from Egbert Eich.
+ *
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "lnx.h"
+
+#include <sys/stat.h>
+#include <string.h>
+#include <errno.h>
+
+struct {
+ int width;
+ int height;
+ int charcount;
+ unsigned char *data;
+} lnxfont = { 0, 0, 0, NULL };
+
+
+static Bool
+getfont(int *width, int *height,
+ int *charcount, unsigned char *data)
+{
+ struct console_font_op op;
+ struct consolefontdesc ds;
+ int result;
+
+ op.op = KD_FONT_OP_GET;
+ op.width = *width;
+ op.height = *height;
+ op.charcount = *charcount;
+ op.data = data;
+ op.flags = 0;
+
+ SYSCALL(result = ioctl(xf86Info.consoleFd, KDFONTOP, &op));
+#ifdef DEBUG
+ ErrorF("Console font read: h: %i count: %i\n",op.height,op.charcount);
+#endif
+
+ if (!result) {
+
+ *width = op.width;
+ *height = op.height;
+ *charcount = op.charcount;
+
+ return TRUE;
+ }
+
+ if (errno != ENOSYS && errno != EINVAL)
+ return FALSE;
+
+ /* GIO_FONTX fallback */
+ ds.charcount = *charcount;
+ ds.charheight = *height;
+ ds.chardata = (char *)data;
+ *width = 8;
+
+ SYSCALL(result = ioctl(xf86Info.consoleFd, GIO_FONTX, &ds));
+
+ if (!result) {
+
+ *charcount = ds.charcount;
+ *height = ds.charheight;
+
+ return TRUE;
+ }
+
+ if (errno != ENOSYS && errno != EINVAL)
+ return FALSE;
+
+ /* GIO_FONT fallback */
+ if (*charcount < 256)
+ return FALSE;
+
+ SYSCALL(result = ioctl(xf86Info.consoleFd, GIO_FONT, data));
+
+ if (!result) {
+ *height = 0;
+ *charcount = 512;
+ return TRUE;
+ }
+
+ return FALSE;
+
+}
+
+#define VERSION_LEN 31
+
+Bool
+lnx_savefont(void)
+{
+ unsigned char *fontdata;
+#if CHECK_OS_VERSION
+ char kernel_version[VERSION_LEN + 1];
+ int k_major, k_minor, k_release;
+#endif
+ int size;
+ int fd;
+ int width = 32, height = 32, charcount = 2048;
+
+#ifdef DEBUG
+ ErrorF("SAVE font\n");
+#endif
+
+#if CHECK_OS_VERSION
+ /* Check if the kernel has full support for this */
+ if ((fd = open ("/proc/sys/kernel/osrelease",O_RDONLY)) == -1) {
+ close (fd);
+ return TRUE;
+ }
+ size = read(fd, kernel_version, VERSION_LEN);
+ close (fd);
+
+ if (size < 0)
+ return TRUE;
+
+ size = sscanf(kernel_version, "%d.%d.%d",&k_major,&k_minor,&k_release);
+ if (size < 3
+ || (k_major < 2)
+ || ((k_major == 2)
+ && ((k_minor < 6)
+ || ( k_minor == 6
+ && k_release < 11))))
+ return TRUE;
+#endif
+
+ /* if we are in fbdev mode we don't bother saving fonts */
+ if ((fd = open ("/dev/fb0",O_RDWR)) != -1) {
+ close (fd);
+ return TRUE;
+ }
+
+ if (!getfont(&width, &height, &charcount, NULL)) {
+ xf86Msg(X_WARNING,
+ "lnx_savefont: cannot obtain font info\n");
+ goto error;
+ } else if (charcount == 2048) {
+ xf86Msg(X_WARNING, "lnx_savefont: "
+ "kernel bug: kernel doesn't report font info\n");
+ return FALSE;
+ }
+
+ size = (width + 7)/8 * 32 * charcount;
+ fontdata = (unsigned char *)xnfalloc(size);
+ if (!fontdata) {
+ xf86Msg(X_WARNING,
+ "lnx_savefont: cannot allocate memory to save font\n");
+ goto error;
+ }
+
+ if (!getfont(&width, &height, &charcount, fontdata)) {
+ xf86Msg(X_WARNING,"lnx_savefont: cannot read font data\n");
+ goto error;
+ }
+ lnxfont.width = width;
+ lnxfont.height = height;
+ lnxfont.charcount = charcount;
+ lnxfont.data = fontdata;
+
+ return TRUE;
+
+ error:
+ return FALSE;
+}
+
+static Bool
+setfont(int width, int height,
+ int charcount, unsigned char *data)
+{
+ struct console_font_op op;
+ struct consolefontdesc ds;
+ int result;
+
+ op.op = KD_FONT_OP_SET;
+ op.flags = 0;
+ op.charcount = charcount;
+ op.width = width;
+ op.height = height;
+ op.data = data;
+
+ SYSCALL(result = ioctl(xf86Info.consoleFd, KDFONTOP, &op));
+
+ if (!result)
+ return TRUE;
+
+ if (errno != ENOSYS && errno != EINVAL)
+ return FALSE;
+
+ /* PIO_FONTX fallback */
+ if (width != 8)
+ return FALSE;
+
+ ds.charcount = charcount;
+ ds.chardata = (char *)data;
+ ds.charheight = height;
+ SYSCALL(result = ioctl(xf86Info.consoleFd, PIO_FONTX, &ds));
+
+ if (!result)
+ return TRUE;
+
+ if (errno != ENOSYS && errno != EINVAL)
+ return FALSE;
+
+ /* PIO_FONT fallback */
+ SYSCALL(result = ioctl(xf86Info.consoleFd, PIO_FONT, data));
+
+ if (!result)
+ return TRUE;
+
+ return FALSE;
+}
+
+Bool
+lnx_restorefont(void)
+{
+ if (lnxfont.data == NULL)
+ return FALSE;
+#ifdef DEBUG
+ ErrorF("RESTORE font\n");
+#endif
+#if 0
+ /* must wack the height to make the kernel reprogram the VGA registers */
+ if (!setfont(lnxfont.width, lnxfont.height + 1, lnxfont.charcount,
+ lnxfont.data)) {
+ xf86Msg(X_WARNING,"lnx_fontretore: cannot write font data\n");
+ return FALSE;
+ }
+#endif
+ if (!setfont(lnxfont.width, lnxfont.height, lnxfont.charcount,
+ lnxfont.data)) {
+ xf86Msg(X_WARNING,"lnx_restorefont: cannot write font data\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool
+lnx_switchaway(void)
+{
+ Bool ret;
+
+ /* temporarily switch to text mode */
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT);
+ ret = lnx_restorefont();
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS);
+ return ret;
+}
+
+void
+lnx_freefontdata(void)
+{
+ if (lnxfont.data == NULL)
+ return;
+
+ xfree(lnxfont.data);
+ lnxfont.data = NULL;
+ lnxfont.width = lnxfont.height = lnxfont.charcount = 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_ia64.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_ia64.c
new file mode 100644
index 000000000..5f742d01f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_ia64.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2004, Egbert Eich
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * EGBERT EICH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+ * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Egbert Eich shall not
+ * be used in advertising or otherwise to promote the sale, use or other deal-
+ *ings in this Software without prior written authorization from Egbert Eich.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/utsname.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include "ia64Pci.h"
+#include "Pci.h"
+
+#if defined OS_PROBE_PCI_CHIPSET
+IA64Chipset OS_PROBE_PCI_CHIPSET(scanpciWrapperOpt flags)
+{
+ struct stat unused;
+ struct utsname utsName;
+
+ if (!stat("/proc/bus/mckinley/zx1",&unused)
+ || !stat("/proc/bus/mckinley/zx2",&unused))
+ return ZX1_CHIPSET;
+
+ if (!stat("/proc/sgi_sn/licenseID", &unused)) {
+ int major, minor, patch;
+ char *c;
+
+ /* We need a 2.6.11 or better kernel for Altix support */
+ uname(&utsName);
+ c = utsName.release;
+
+ major = atoi(c);
+ c = strstr(c, ".") + 1;
+ minor = atoi(c);
+ c = strstr(c, ".") + 1;
+ patch = atoi(c);
+
+ if (major < 2 || (major == 2 && minor < 6) ||
+ (major == 2 && minor == 6 && patch < 11)) {
+ ErrorF("Kernel 2.6.11 or better needed for Altix support\n");
+ return NONE_CHIPSET;
+ }
+ return ALTIX_CHIPSET;
+ }
+
+ return NONE_CHIPSET;
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c
new file mode 100644
index 000000000..1eb0f33fe
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c
@@ -0,0 +1,415 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 1.9 2005/08/26 07:35:55 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 3.14 2001/10/31 22:50:30 tsi Exp $ */
+/*
+ * Copyright 1992 by Orest Zborowski <obz@Kodak.com>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Orest Zborowski and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Orest Zborowski
+ * and David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT BE LIABLE
+ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: lnx_init.c /main/7 1996/10/23 18:46:30 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "lnx.h"
+
+#include <sys/stat.h>
+
+#ifdef USE_DEV_FB
+extern char *getenv(const char *);
+#include <linux/fb.h>
+char *fb_dev_name;
+#endif
+
+static Bool KeepTty = FALSE;
+static int VTnum = -1;
+static Bool VTSwitch = TRUE;
+static Bool ShareVTs = FALSE;
+static int activeVT = -1;
+
+static int vtPermSave[4];
+static char vtname[11];
+
+static int
+saveVtPerms(void)
+{
+ /* We need to use stat to get permissions. */
+ struct stat svtp;
+
+ /* Do them numerically ordered, hard coded tty0 first. */
+ if (stat("/dev/tty0", &svtp) != 0)
+ return 0;
+ vtPermSave[0] = (int)svtp.st_uid;
+ vtPermSave[1] = (int)svtp.st_gid;
+
+ /* Now check the console we are dealing with. */
+ if (stat(vtname, &svtp) != 0)
+ return 0;
+ vtPermSave[2] = (int)svtp.st_uid;
+ vtPermSave[3] = (int)svtp.st_gid;
+
+ return 1;
+}
+
+static void
+restoreVtPerms(void)
+{
+ /* Set the terminal permissions back to before we started. */
+ chown("/dev/tty0", vtPermSave[0], vtPermSave[1]);
+ chown(vtname, vtPermSave[2], vtPermSave[3]);
+}
+
+void
+xf86OpenConsole(void)
+{
+ int i, fd = -1;
+ struct vt_mode VT;
+ struct vt_stat vts;
+ MessageType from = X_PROBED;
+#ifdef USE_DEV_FB
+ struct fb_var_screeninfo var;
+ int fbfd;
+#endif
+ char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
+ char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
+
+ if (serverGeneration == 1) {
+
+ /* when KeepTty check if we're run with euid==0 */
+ if (KeepTty && geteuid() != 0)
+ FatalError("xf86OpenConsole:"
+ " Server must be suid root for option \"KeepTTY\"\n");
+
+ /*
+ * setup the virtual terminal manager
+ */
+ if (VTnum != -1) {
+ xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
+ } else {
+
+ i=0;
+ while (tty0[i] != NULL) {
+ if ((fd = open(tty0[i],O_WRONLY,0)) >= 0)
+ break;
+ i++;
+ }
+
+ if (fd < 0)
+ FatalError(
+ "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
+ strerror(errno));
+
+ if (ShareVTs)
+ {
+ if (ioctl(fd, VT_GETSTATE, &vts) == 0)
+ xf86Info.vtno = vts.v_active;
+ else
+ FatalError("xf86OpenConsole: Cannot find the current"
+ " VT (%s)\n", strerror(errno));
+ } else {
+ if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
+ (xf86Info.vtno == -1))
+ FatalError("xf86OpenConsole: Cannot find a free VT: %s\n",
+ strerror(errno));
+ }
+ close(fd);
+ }
+
+#ifdef USE_DEV_FB
+ if (!ShareVTs)
+ {
+ fb_dev_name=getenv("FRAMEBUFFER");
+ if (!fb_dev_name)
+ fb_dev_name="/dev/fb0current";
+
+ if ((fbfd = open(fb_dev_name, O_RDONLY)) < 0)
+ FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
+ fb_dev_name, strerror(errno));
+
+ if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var) < 0)
+ FatalError("xf86OpenConsole: Unable to get screen info %s\n",
+ strerror(errno));
+ }
+#endif
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+
+ if (!KeepTty) {
+ pid_t ppid = getppid();
+ pid_t ppgid;
+ ppgid = getpgid(ppid);
+
+ /*
+ * change to parent process group that pgid != pid so
+ * that setsid() doesn't fail and we become process
+ * group leader
+ */
+ if (setpgid(0,ppgid) < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: setpgid failed: %s\n",
+ strerror(errno));
+
+ /* become process group leader */
+ if ((setsid() < 0))
+ xf86Msg(X_WARNING, "xf86OpenConsole: setsid failed: %s\n",
+ strerror(errno));
+ }
+
+ i=0;
+ while (vcs[i] != NULL) {
+ sprintf(vtname, vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
+ if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >= 0)
+ break;
+ i++;
+ }
+
+ if (xf86Info.consoleFd < 0)
+ FatalError("xf86OpenConsole: Cannot open virtual console"
+ " %d (%s)\n", xf86Info.vtno, strerror(errno));
+
+ if (!ShareVTs)
+ {
+ /*
+ * Grab the vt ownership before we overwrite it.
+ * Hard coded /dev/tty0 into this function as well for below.
+ */
+ if (!saveVtPerms())
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: Could not save ownership of VT\n");
+
+ /* change ownership of the vt */
+ if (chown(vtname, getuid(), getgid()) < 0)
+ xf86Msg(X_WARNING,"xf86OpenConsole: chown %s failed: %s\n",
+ vtname, strerror(errno));
+
+ /*
+ * the current VT device we're running on is not "console", we want
+ * to grab all consoles too
+ *
+ * Why is this needed??
+ */
+ if (chown("/dev/tty0", getuid(), getgid()) < 0)
+ xf86Msg(X_WARNING,"xf86OpenConsole: chown /dev/tty0 failed: %s\n",
+ strerror(errno));
+ }
+
+ /*
+ * Linux doesn't switch to an active vt after the last close of a vt,
+ * so we do this ourselves by remembering which is active now.
+ */
+ if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0)
+ xf86Msg(X_WARNING,"xf86OpenConsole: VT_GETSTATE failed: %s\n",
+ strerror(errno));
+ else
+ activeVT = vts.v_active;
+
+#if 0
+ if (!KeepTty) {
+ /*
+ * Detach from the controlling tty to avoid char loss
+ */
+ if ((i = open("/dev/tty",O_RDWR)) >= 0) {
+ ioctl(i, TIOCNOTTY, 0);
+ close(i);
+ }
+ }
+#endif
+
+ if (!ShareVTs)
+ {
+#if defined(DO_OS_FONTRESTORE)
+ lnx_savefont();
+#endif
+ /*
+ * now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed: %s\n",
+ strerror(errno));
+
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed: %s\n",
+ strerror(errno));
+
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
+ FatalError("xf86OpenConsole: VT_GETMODE failed %s\n",
+ strerror(errno));
+
+ signal(SIGUSR1, xf86VTRequest);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n",
+ strerror(errno));
+
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n",
+ strerror(errno));
+
+ /* we really should have a InitOSInputDevices() function instead
+ * of Init?$#*&Device(). So I just place it here */
+
+#ifdef USE_DEV_FB
+ /* copy info to new console */
+ var.yoffset=0;
+ var.xoffset=0;
+ if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &var))
+ FatalError("Unable to set screen info\n");
+ close(fbfd);
+#endif
+ } else { /* ShareVTs */
+ close(xf86Info.consoleFd);
+ }
+ signal(SIGUSR2, xf86ReloadInputDevs);
+ } else { /* serverGeneration != 1 */
+ if (!ShareVTs && VTSwitch)
+ {
+ /*
+ * now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed %s\n",
+ strerror(errno));
+ }
+
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed %s\n",
+ strerror(errno));
+ }
+ return;
+}
+
+void
+xf86CloseConsole()
+{
+ struct vt_mode VT;
+#if defined(DO_OS_FONTRESTORE)
+ struct vt_stat vts;
+ int vtno = -1;
+#endif
+
+ if (ShareVTs) return;
+
+#if defined(DO_OS_FONTRESTORE)
+ if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETSTATE failed: %s\n",
+ strerror(errno));
+ else
+ vtno = vts.v_active;
+#endif
+
+ /* Back to text mode ... */
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT) < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n",
+ strerror(errno));
+
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n",
+ strerror(errno));
+ else {
+ /* set dflt vt handling */
+ VT.mode = VT_AUTO;
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n",
+ strerror(errno));
+ }
+
+ if (VTSwitch)
+ {
+ /*
+ * Perform a switch back to the active VT when we were started
+ */
+ if (activeVT >= 0) {
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT) < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: VT_ACTIVATE failed: %s\n",
+ strerror(errno));
+ activeVT = -1;
+ }
+
+#if defined(DO_OS_FONTRESTORE)
+ if (xf86Info.vtno == vtno) /* check if we are active */
+ lnx_restorefont();
+ lnx_freefontdata();
+#endif
+ }
+ close(xf86Info.consoleFd); /* make the vt-manager happy */
+
+ restoreVtPerms(); /* restore the permissions */
+
+ return;
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty"))
+ {
+ KeepTty = TRUE;
+ return(1);
+ }
+ if (!strcmp(argv[i], "-novtswitch"))
+ {
+ VTSwitch = FALSE;
+ return(1);
+ }
+ if (!strcmp(argv[i], "-sharevts"))
+ {
+ ShareVTs = TRUE;
+ return(1);
+ }
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+ {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
+ {
+ UseMsg();
+ VTnum = -1;
+ return(0);
+ }
+ return(1);
+ }
+ return(0);
+}
+
+void
+xf86UseMsg()
+{
+ ErrorF("vtXX use the specified VT number\n");
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+ ErrorF("-novtswitch don't immediately switch to new VT\n");
+ ErrorF("-sharevts share VTs with another X server\n");
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c
new file mode 100644
index 000000000..47df0dfb6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c
@@ -0,0 +1,275 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c,v 3.25 2003/08/19 17:32:34 tsi Exp $ */
+/*
+ * Copyright 1992 by Orest Zborowski <obz@Kodak.com>
+ * Copyright 1993 by David Dawes <dawes@xfree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Orest Zborowski and David Dawes
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Orest Zborowski
+ * and David Dawes make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OREST ZBOROWSKI AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID DAWES BE LIABLE
+ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: lnx_io.c /main/8 1996/10/19 18:06:28 kaleb $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#define KBC_TIMEOUT 250 /* Timeout in ms for sending to keyboard controller */
+
+void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
+{
+ if (loudness && pitch)
+ {
+ ioctl(xf86Info.consoleFd, KDMKTONE,
+ ((1193190 / pitch) & 0xffff) |
+ (((unsigned long)duration *
+ loudness / 50) << 16));
+ }
+}
+
+void
+xf86SetKbdLeds(int leds)
+{
+ ioctl(xf86Info.consoleFd, KDSETLED, leds);
+}
+
+int
+xf86GetKbdLeds()
+{
+ int leds = 0;
+
+ ioctl(xf86Info.consoleFd, KDGETLED, &leds);
+ return(leds);
+}
+
+/* kbd rate stuff based on kbdrate.c from Rik Faith <faith@cs.unc.edu> et.al.
+ * from util-linux-2.9t package */
+
+#include <linux/kd.h>
+#include <linux/version.h>
+#ifdef __sparc__
+#include <asm/param.h>
+#include <asm/kbio.h>
+#endif
+
+/* Deal with spurious kernel header change in struct kbd_repeat.
+ We undo this define after the routine using that struct is over,
+ so as not to interfere with other 'rate' elements. */
+#if defined(LINUX_VERSION_CODE) && defined(KERNEL_VERSION)
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,42)
+# define rate period
+# endif
+#endif
+
+static int
+KDKBDREP_ioctl_ok(int rate, int delay) {
+#if defined(KDKBDREP) && !defined(__sparc__)
+ /* This ioctl is defined in <linux/kd.h> but is not
+ implemented anywhere - must be in some m68k patches. */
+ struct kbd_repeat kbdrep_s;
+
+ /* don't change, just test */
+ kbdrep_s.rate = -1;
+ kbdrep_s.delay = -1;
+ if (ioctl( xf86Info.consoleFd, KDKBDREP, &kbdrep_s )) {
+ return 0;
+ }
+ /* do the change */
+ if (rate == 0) /* switch repeat off */
+ kbdrep_s.rate = 0;
+ else
+ kbdrep_s.rate = 10000 / rate; /* convert cps to msec */
+ if (kbdrep_s.rate < 1)
+ kbdrep_s.rate = 1;
+ kbdrep_s.delay = delay;
+ if (kbdrep_s.delay < 1)
+ kbdrep_s.delay = 1;
+
+ if (ioctl( xf86Info.consoleFd, KDKBDREP, &kbdrep_s )) {
+ return 0;
+ }
+
+ return 1; /* success! */
+#else /* no KDKBDREP */
+ return 0;
+#endif /* KDKBDREP */
+}
+
+#undef rate
+
+/* Undo the earlier define for the struct kbd_repeat problem. */
+#if defined(LINUX_VERSION_CODE) && defined(KERNEL_VERSION)
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,42)
+# undef rate
+# endif
+#endif
+
+static int
+KIOCSRATE_ioctl_ok(int rate, int delay) {
+#ifdef KIOCSRATE
+ struct kbd_rate kbdrate_s;
+ int fd;
+
+ fd = open("/dev/kbd", O_RDONLY);
+ if (fd == -1)
+ return 0;
+
+ kbdrate_s.rate = (rate + 5) / 10; /* must be integer, so round up */
+ kbdrate_s.delay = delay * HZ / 1000; /* convert ms to Hz */
+ if (kbdrate_s.rate > 50)
+ kbdrate_s.rate = 50;
+
+ if (ioctl( fd, KIOCSRATE, &kbdrate_s )) {
+ return 0;
+ }
+
+ close( fd );
+
+ return 1;
+#else /* no KIOCSRATE */
+ return 0;
+#endif /* KIOCSRATE */
+}
+
+void xf86SetKbdRepeat(char rad)
+{
+#ifdef __sparc__
+ int rate = 500; /* Default rate */
+ int delay = 200; /* Default delay */
+#else
+ int rate = 300; /* Default rate */
+ int delay = 250; /* Default delay */
+#endif
+
+#if defined(__alpha__) || defined (__i386__) || defined(__ia64__)
+ int i;
+ int timeout;
+ int value = 0x7f; /* Maximum delay with slowest rate */
+
+ static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
+ 133, 120, 109, 100, 92, 86, 80, 75, 67,
+ 60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
+ 25, 23, 21, 20 };
+#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
+
+ static int valid_delays[] = { 250, 500, 750, 1000 };
+#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
+#endif
+
+ if (xf86Info.kbdRate >= 0)
+ rate = xf86Info.kbdRate * 10;
+ if (xf86Info.kbdDelay >= 0)
+ delay = xf86Info.kbdDelay;
+
+ if(KDKBDREP_ioctl_ok(rate, delay)) /* m68k? */
+ return;
+
+ if(KIOCSRATE_ioctl_ok(rate, delay)) /* sparc? */
+ return;
+
+ if (xf86IsPc98())
+ return;
+
+#if defined(__alpha__) || defined (__i386__) || defined(__ia64__)
+
+ /* The ioport way */
+
+ for (i = 0; i < RATE_COUNT; i++)
+ if (rate >= valid_rates[i]) {
+ value &= 0x60;
+ value |= i;
+ break;
+ }
+
+ for (i = 0; i < DELAY_COUNT; i++)
+ if (delay <= valid_delays[i]) {
+ value &= 0x1f;
+ value |= i << 5;
+ break;
+ }
+
+ timeout = KBC_TIMEOUT;
+ while (((inb(0x64) & 2) == 2) && --timeout)
+ usleep(1000); /* wait */
+
+ if (timeout == 0)
+ return;
+
+ outb(0x60, 0xf3); /* set typematic rate */
+ while (((inb(0x64) & 2) == 2) && --timeout)
+ usleep(1000); /* wait */
+
+ usleep(10000);
+ outb(0x60, value);
+
+#endif /* __alpha__ || __i386__ || __ia64__ */
+}
+
+static int kbdtrans;
+static struct termios kbdtty;
+
+void
+xf86KbdInit()
+{
+ ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans);
+ tcgetattr (xf86Info.consoleFd, &kbdtty);
+}
+
+int
+xf86KbdOn()
+{
+ struct termios nTty;
+
+#ifdef __powerpc__
+ if (xf86Info.kbdCustomKeycodes)
+ ioctl(xf86Info.consoleFd, KDSKBMODE, K_MEDIUMRAW);
+ else
+#endif
+ ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW);
+
+ nTty = kbdtty;
+ nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME]=0;
+ nTty.c_cc[VMIN]=1;
+ cfsetispeed(&nTty, 9600);
+ cfsetospeed(&nTty, 9600);
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
+ return(xf86Info.consoleFd);
+}
+
+int
+xf86KbdOff()
+{
+ ioctl(xf86Info.consoleFd, KDSKBMODE, kbdtrans);
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty);
+ return(xf86Info.consoleFd);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_jstk.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_jstk.c
new file mode 100644
index 000000000..dafdc0594
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_jstk.c
@@ -0,0 +1,188 @@
+/* $XConsortium: lnx_jstk.c /main/7 1996/02/21 17:51:36 kaleb $ */
+/* Id: lnx_jstk.c,v 1.1 1995/12/20 14:06:09 lepied Exp */
+/*
+ * Copyright 1995 by Frederic Lepied, France. <fred@sugix.frmug.fr.net>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Frederic Lepied not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Frederic Lepied makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_jstk.c,v 3.8.2.1 1998/06/05 16:23:12 dawes Exp $ */
+
+static const char rcs_id[] = "Id: lnx_jstk.c,v 1.1 1995/12/20 14:06:09 lepied Exp";
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#define inline __inline__
+#include <linux/joystick.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+#ifdef XFree86LOADER
+#include "xf86.h"
+#include "xf86_ansic.h"
+#endif
+
+#if !defined(JSIOCGTIMELIMIT)
+/* make 2.1.x joystick.h backward compatable */
+#define JSIOCGTIMELIMIT JS_GET_TIMELIMIT
+#define JSIOCSTIMELIMIT JS_SET_TIMELIMIT
+#define js_status JS_DATA_TYPE
+#endif
+
+
+/***********************************************************************
+ *
+ * xf86JoystickOn --
+ *
+ * open the device and init timeout according to the device value.
+ *
+ ***********************************************************************
+ */
+
+int
+xf86JoystickOn(char *name, int *timeout, int *centerX, int *centerY)
+{
+ int fd;
+ struct js_status js;
+
+#ifdef DEBUG
+ ErrorF("xf86JoystickOn %s\n", name);
+#endif
+
+ if ((fd = open(name, O_RDWR | O_NDELAY, 0)) < 0)
+ {
+ xf86Msg(X_WARNING, "Cannot open joystick '%s' (%s)\n", name,
+ strerror(errno));
+ return -1;
+ }
+
+ if (*timeout == 0) {
+ if (ioctl (fd, JSIOCGTIMELIMIT, timeout) == -1) {
+ Error("joystick JSIOCGTIMELIMIT ioctl");
+ }
+ else {
+ xf86Msg(X_CONFIG, "Joystick: timeout value = %d\n", *timeout);
+ }
+ }
+ else {
+ if (ioctl(fd, JSIOCSTIMELIMIT, timeout) == -1) {
+ Error("joystick JSIOCSTIMELIMIT ioctl");
+ }
+ }
+
+ /* Assume the joystick is centred when this is called */
+ read(fd, &js, JS_RETURN);
+ if (*centerX < 0) {
+ *centerX = js.x;
+ xf86Msg(X_CONFIG, "Joystick: CenterX set to %d\n", *centerX);
+ }
+ if (*centerY < 0) {
+ *centerY = js.y;
+ xf86Msg(X_CONFIG, "Joystick: CenterY set to %d\n", *centerY);
+ }
+
+ return fd;
+}
+
+/***********************************************************************
+ *
+ * xf86JoystickInit --
+ *
+ * called when X device is initialized.
+ *
+ ***********************************************************************
+ */
+
+void
+xf86JoystickInit()
+{
+ return;
+}
+
+/***********************************************************************
+ *
+ * xf86JoystickOff --
+ *
+ * close the handle.
+ *
+ ***********************************************************************
+ */
+
+int
+xf86JoystickOff(int *fd, int doclose)
+{
+ int oldfd;
+
+ if (((oldfd = *fd) >= 0) && doclose) {
+ close(*fd);
+ *fd = -1;
+ }
+ return oldfd;
+}
+
+/***********************************************************************
+ *
+ * xf86JoystickGetState --
+ *
+ * return the state of buttons and the position of the joystick.
+ *
+ ***********************************************************************
+ */
+
+int
+xf86JoystickGetState(int fd, int *x, int *y, int *buttons)
+{
+ struct js_status js;
+ int status;
+
+ status = read(fd, &js, JS_RETURN);
+
+ if (status != JS_RETURN)
+ {
+ Error("Joystick read");
+ return 0;
+ }
+
+ *x = js.x;
+ *y = js.y;
+ *buttons = js.buttons;
+
+ return 1;
+}
+
+#ifdef XFree86LOADER
+/*
+ * Entry point for XFree86 Loader
+ */
+void
+linux_jstkModuleInit(pointer *data, INT32 *magic)
+{
+ *magic = MAGIC_DONE;
+ *data = NULL;
+}
+#endif
+
+/* end of lnx_jstk.c */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c
new file mode 100644
index 000000000..b1fc95b56
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c
@@ -0,0 +1,559 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c,v 1.4 2003/11/03 05:11:52 tsi Exp $ */
+
+/*
+ * Copyright (c) 2002 by The XFree86 Project, Inc.
+ * Author: Ivan Pascal.
+ *
+ * Based on the code from lnx_io.c which is
+ * Copyright 1992 by Orest Zborowski <obz@Kodak.com>
+ * Copyright 1993 by David Dawes <dawes@xfree86.org>
+ */
+
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include "xf86Xinput.h"
+#include "xf86OSKbd.h"
+#include "atKeynames.h"
+#if defined(DO_OS_FONTRESTORE)
+#include "lnx.h"
+#endif
+#include "lnx_kbd.h"
+
+#define KBC_TIMEOUT 250 /* Timeout in ms for sending to keyboard controller */
+
+static KbdProtocolRec protocols[] = {
+ {"standard", PROT_STD },
+ { NULL, PROT_UNKNOWN_KBD }
+};
+
+extern Bool VTSwitchEnabled;
+#ifdef USE_VT_SYSREQ
+extern Bool VTSysreqToggle;
+#endif
+
+static void
+SoundBell(InputInfoPtr pInfo, int loudness, int pitch, int duration)
+{
+ if (loudness && pitch)
+ {
+ ioctl(pInfo->fd, KDMKTONE,
+ ((1193190 / pitch) & 0xffff) |
+ (((unsigned long)duration *
+ loudness / 50) << 16));
+ }
+}
+
+static void
+SetKbdLeds(InputInfoPtr pInfo, int leds)
+{
+ int real_leds = 0;
+
+#if defined (__sparc__)
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ if (pKbd->sunKbd) {
+ if (leds & 0x08) real_leds |= XLED1;
+ if (leds & 0x04) real_leds |= XLED3;
+ if (leds & 0x02) real_leds |= XLED4;
+ if (leds & 0x01) real_leds |= XLED2;
+ leds = real_leds;
+ real_leds = 0;
+ }
+#endif /* defined (__sparc__) */
+#ifdef LED_CAP
+ if (leds & XLED1) real_leds |= LED_CAP;
+ if (leds & XLED2) real_leds |= LED_NUM;
+ if (leds & XLED3) real_leds |= LED_SCR;
+#ifdef LED_COMP
+ if (leds & XLED4) real_leds |= LED_COMP;
+#else
+ if (leds & XLED4) real_leds |= LED_SCR;
+#endif
+#endif
+ ioctl(pInfo->fd, KDSETLED, real_leds);
+}
+
+static int
+GetKbdLeds(InputInfoPtr pInfo)
+{
+ int real_leds, leds = 0;
+
+ ioctl(pInfo->fd, KDGETLED, &real_leds);
+
+ if (real_leds & LED_CAP) leds |= XLED1;
+ if (real_leds & LED_NUM) leds |= XLED2;
+ if (real_leds & LED_SCR) leds |= XLED3;
+
+ return(leds);
+}
+
+/* kbd rate stuff based on kbdrate.c from Rik Faith <faith@cs.unc.edu> et.al.
+ * from util-linux-2.9t package */
+
+#include <linux/kd.h>
+#include <linux/version.h>
+#ifdef __sparc__
+#include <asm/param.h>
+#include <asm/kbio.h>
+#endif
+
+/* Deal with spurious kernel header change in struct kbd_repeat.
+ We undo this define after the routine using that struct is over,
+ so as not to interfere with other 'rate' elements. */
+#if defined(LINUX_VERSION_CODE) && defined(KERNEL_VERSION)
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,42)
+# define rate period
+# endif
+#endif
+
+static int
+KDKBDREP_ioctl_ok(int rate, int delay) {
+#if defined(KDKBDREP) && !defined(__sparc__)
+ /* This ioctl is defined in <linux/kd.h> but is not
+ implemented anywhere - must be in some m68k patches. */
+ struct kbd_repeat kbdrep_s;
+
+ /* don't change, just test */
+ kbdrep_s.rate = -1;
+ kbdrep_s.delay = -1;
+ if (ioctl( xf86Info.consoleFd, KDKBDREP, &kbdrep_s )) {
+ return 0;
+ }
+
+ /* do the change */
+ if (rate == 0) /* switch repeat off */
+ kbdrep_s.rate = 0;
+ else
+ kbdrep_s.rate = 10000 / rate; /* convert cps to msec */
+ if (kbdrep_s.rate < 1)
+ kbdrep_s.rate = 1;
+ kbdrep_s.delay = delay;
+ if (kbdrep_s.delay < 1)
+ kbdrep_s.delay = 1;
+
+ if (ioctl( xf86Info.consoleFd, KDKBDREP, &kbdrep_s )) {
+ return 0;
+ }
+
+ return 1; /* success! */
+#else /* no KDKBDREP */
+ return 0;
+#endif /* KDKBDREP */
+}
+
+#undef rate
+
+/* Undo the earlier define for the struct kbd_repeat problem. */
+#if defined(LINUX_VERSION_CODE) && defined(KERNEL_VERSION)
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,42)
+# undef rate
+# endif
+#endif
+
+static int
+KIOCSRATE_ioctl_ok(int rate, int delay) {
+#ifdef KIOCSRATE
+ struct kbd_rate kbdrate_s;
+ int fd;
+
+ fd = open("/dev/kbd", O_RDONLY);
+ if (fd == -1)
+ return 0;
+
+ kbdrate_s.rate = (rate + 5) / 10; /* must be integer, so round up */
+ kbdrate_s.delay = delay * HZ / 1000; /* convert ms to Hz */
+ if (kbdrate_s.rate > 50)
+ kbdrate_s.rate = 50;
+
+ if (ioctl( fd, KIOCSRATE, &kbdrate_s )) {
+ return 0;
+ }
+
+ close( fd );
+
+ return 1;
+#else /* no KIOCSRATE */
+ return 0;
+#endif /* KIOCSRATE */
+}
+
+#undef rate
+
+static void
+SetKbdRepeat(InputInfoPtr pInfo, char rad)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ int i;
+ int timeout;
+ int value = 0x7f; /* Maximum delay with slowest rate */
+
+#ifdef __sparc__
+ int rate = 500; /* Default rate */
+ int delay = 200; /* Default delay */
+#else
+ int rate = 300; /* Default rate */
+ int delay = 250; /* Default delay */
+#endif
+
+ static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
+ 133, 120, 109, 100, 92, 86, 80, 75, 67,
+ 60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
+ 25, 23, 21, 20 };
+#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
+
+ static int valid_delays[] = { 250, 500, 750, 1000 };
+#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
+
+ if (pKbd->rate >= 0)
+ rate = pKbd->rate * 10;
+ if (pKbd->delay >= 0)
+ delay = pKbd->delay;
+
+ if(KDKBDREP_ioctl_ok(rate, delay)) /* m68k? */
+ return;
+
+ if(KIOCSRATE_ioctl_ok(rate, delay)) /* sparc? */
+ return;
+
+ if (xf86IsPc98())
+ return;
+
+#if defined(__alpha__) || defined (__i386__) || defined(__ia64__)
+
+ if (!xorgHWAccess) {
+ if (xf86EnableIO())
+ xorgHWAccess = TRUE;
+ else
+ return;
+ }
+
+ /* The ioport way */
+
+ for (i = 0; i < RATE_COUNT; i++)
+ if (rate >= valid_rates[i]) {
+ value &= 0x60;
+ value |= i;
+ break;
+ }
+
+ for (i = 0; i < DELAY_COUNT; i++)
+ if (delay <= valid_delays[i]) {
+ value &= 0x1f;
+ value |= i << 5;
+ break;
+ }
+
+ timeout = KBC_TIMEOUT;
+ while (((inb(0x64) & 2) == 2) && --timeout)
+ usleep(1000); /* wait */
+
+ if (timeout == 0)
+ return;
+
+ outb(0x60, 0xf3); /* set typematic rate */
+ while (((inb(0x64) & 2) == 2) && --timeout)
+ usleep(1000); /* wait */
+
+ usleep(10000);
+ outb(0x60, value);
+
+#endif /* __alpha__ || __i386__ || __ia64__ */
+}
+
+typedef struct {
+ int kbdtrans;
+ struct termios kbdtty;
+} LnxKbdPrivRec, *LnxKbdPrivPtr;
+
+static int
+KbdInit(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ LnxKbdPrivPtr priv = (LnxKbdPrivPtr) pKbd->private;
+
+ if (pKbd->isConsole) {
+ ioctl (pInfo->fd, KDGKBMODE, &(priv->kbdtrans));
+ tcgetattr (pInfo->fd, &(priv->kbdtty));
+ }
+ if (!pKbd->CustomKeycodes) {
+ pKbd->RemapScanCode = ATScancode;
+ }
+
+ return Success;
+}
+
+static int
+KbdOn(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ LnxKbdPrivPtr priv = (LnxKbdPrivPtr) pKbd->private;
+ struct termios nTty;
+
+ if (pKbd->isConsole) {
+ if (pKbd->CustomKeycodes)
+ ioctl(pInfo->fd, KDSKBMODE, K_MEDIUMRAW);
+ else
+ ioctl(pInfo->fd, KDSKBMODE, K_RAW);
+
+ nTty = priv->kbdtty;
+ nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME]=0;
+ nTty.c_cc[VMIN]=1;
+ cfsetispeed(&nTty, 9600);
+ cfsetospeed(&nTty, 9600);
+ tcsetattr(pInfo->fd, TCSANOW, &nTty);
+ }
+ return Success;
+}
+
+static int
+KbdOff(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ LnxKbdPrivPtr priv = (LnxKbdPrivPtr) pKbd->private;
+
+ if (pKbd->isConsole) {
+ ioctl(pInfo->fd, KDSKBMODE, priv->kbdtrans);
+ tcsetattr(pInfo->fd, TCSANOW, &(priv->kbdtty));
+ }
+ return Success;
+}
+
+static int
+GetSpecialKey(InputInfoPtr pInfo, int scanCode)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ int specialkey = scanCode;
+
+#if defined (__sparc__)
+ if (pKbd->sunKbd) {
+ switch (scanCode) {
+ case 0x2b: specialkey = KEY_BackSpace; break;
+ case 0x47: specialkey = KEY_KP_Minus; break;
+ case 0x7d: specialkey = KEY_KP_Plus; break;
+ /* XXX needs cases for KEY_KP_Divide and KEY_KP_Multiply */
+ case 0x05: specialkey = KEY_F1; break;
+ case 0x06: specialkey = KEY_F2; break;
+ case 0x08: specialkey = KEY_F3; break;
+ case 0x0a: specialkey = KEY_F4; break;
+ case 0x0c: specialkey = KEY_F5; break;
+ case 0x0e: specialkey = KEY_F6; break;
+ case 0x10: specialkey = KEY_F7; break;
+ case 0x11: specialkey = KEY_F8; break;
+ case 0x12: specialkey = KEY_F9; break;
+ case 0x07: specialkey = KEY_F10; break;
+ case 0x09: specialkey = KEY_F11; break;
+ case 0x0b: specialkey = KEY_F12; break;
+ default: specialkey = 0; break;
+ }
+ return specialkey;
+ }
+#endif
+
+ if (pKbd->CustomKeycodes) {
+ specialkey = pKbd->specialMap->map[scanCode];
+ }
+ return specialkey;
+}
+
+#define ModifierSet(k) ((modifiers & (k)) == (k))
+
+static
+Bool SpecialKey(InputInfoPtr pInfo, int key, Bool down, int modifiers)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+
+ if(!pKbd->vtSwitchSupported)
+ return FALSE;
+
+ if ((ModifierSet(ControlMask | AltMask)) ||
+ (ModifierSet(ControlMask | AltLangMask))) {
+ if (VTSwitchEnabled && !xf86Info.vtSysreq && !xf86Info.dontVTSwitch) {
+ switch (key) {
+ case KEY_F1:
+ case KEY_F2:
+ case KEY_F3:
+ case KEY_F4:
+ case KEY_F5:
+ case KEY_F6:
+ case KEY_F7:
+ case KEY_F8:
+ case KEY_F9:
+ case KEY_F10:
+ if (down) {
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F1 + 1);
+ return TRUE;
+ }
+ case KEY_F11:
+ case KEY_F12:
+ if (down) {
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F11 + 11);
+ return TRUE;
+ }
+ }
+ }
+ }
+#ifdef USE_VT_SYSREQ
+ if (VTSwitchEnabled && xf86Info.vtSysreq && !xf86Info.dontVTSwitch) {
+ switch (key) {
+ case KEY_F1:
+ case KEY_F2:
+ case KEY_F3:
+ case KEY_F4:
+ case KEY_F5:
+ case KEY_F6:
+ case KEY_F7:
+ case KEY_F8:
+ case KEY_F9:
+ case KEY_F10:
+ if (VTSysreqToggle && down) {
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F1 + 1);
+ VTSysreqToggle = FALSE;
+ return TRUE;
+ }
+ break;
+ case KEY_F11:
+ case KEY_F12:
+ if (VTSysreqToggle && down) {
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F11 + 11);
+ VTSysreqToggle = FALSE;
+ return TRUE;
+ }
+ break;
+ /* Ignore these keys -- ie don't let them cancel an alt-sysreq */
+ case KEY_Alt:
+ case KEY_AltLang:
+ break;
+ case KEY_SysReqest:
+ if ((ModifierSet(AltMask) || ModifierSet(AltLangMask)) && down)
+ VTSysreqToggle = TRUE;
+ break;
+ default:
+ /*
+ * We only land here when Alt-SysReq is followed by a
+ * non-switching key.
+ */
+ if (VTSysreqToggle)
+ VTSysreqToggle = FALSE;
+ }
+ }
+#endif /* USE_VT_SYSREQ */
+ return FALSE;
+}
+
+static void
+stdReadInput(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ unsigned char rBuf[64];
+ int nBytes, i;
+ if ((nBytes = read( pInfo->fd, (char *)rBuf, sizeof(rBuf))) > 0) {
+ for (i = 0; i < nBytes; i++)
+ pKbd->PostEvent(pInfo, rBuf[i] & 0x7f,
+ rBuf[i] & 0x80 ? FALSE : TRUE);
+ }
+}
+
+static Bool
+OpenKeyboard(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ int i;
+ KbdProtocolId prot = PROT_UNKNOWN_KBD;
+ char *s;
+
+ s = xf86SetStrOption(pInfo->options, "Protocol", NULL);
+ for (i = 0; protocols[i].name; i++) {
+ if (xf86NameCmp(s, protocols[i].name) == 0) {
+ prot = protocols[i].id;
+ break;
+ }
+ }
+
+ switch (prot) {
+ case PROT_STD:
+ pInfo->read_input = stdReadInput;
+ break;
+ default:
+ xf86Msg(X_ERROR,"\"%s\" is not a valid keyboard protocol name\n", s);
+ xfree(s);
+ return FALSE;
+ }
+
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, s);
+ xfree(s);
+
+ s = xf86SetStrOption(pInfo->options, "Device", NULL);
+ if (s == NULL) {
+ pInfo->fd = xf86Info.consoleFd;
+ pKbd->isConsole = TRUE;
+ } else {
+ pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL);
+ if (pInfo->fd == -1) {
+ xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s);
+ xfree(s);
+ return FALSE;
+ }
+ pKbd->isConsole = FALSE;
+ xfree(s);
+ }
+
+ if (pKbd->isConsole)
+ pKbd->vtSwitchSupported = TRUE;
+
+ return TRUE;
+}
+
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = pInfo->private;
+
+ pKbd->KbdInit = KbdInit;
+ pKbd->KbdOn = KbdOn;
+ pKbd->KbdOff = KbdOff;
+ pKbd->Bell = SoundBell;
+ pKbd->SetLeds = SetKbdLeds;
+ pKbd->GetLeds = GetKbdLeds;
+ pKbd->SetKbdRepeat = SetKbdRepeat;
+ pKbd->KbdGetMapping = KbdGetMapping;
+ pKbd->SpecialKey = SpecialKey;
+
+ pKbd->RemapScanCode = NULL;
+ pKbd->GetSpecialKey = GetSpecialKey;
+
+ pKbd->OpenKeyboard = OpenKeyboard;
+ pKbd->vtSwitchSupported = FALSE;
+
+ pKbd->private = xcalloc(sizeof(LnxKbdPrivRec), 1);
+ if (pKbd->private == NULL) {
+ xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
+ return FALSE;
+ }
+
+#if defined(__powerpc__)
+ {
+ FILE *f;
+ f = fopen("/proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes","r");
+ if (f) {
+ if (fgetc(f) == '0')
+ pKbd->CustomKeycodes = TRUE;
+ fclose(f);
+ }
+ }
+#endif
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.h
new file mode 100644
index 000000000..7b9cd434e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.h
@@ -0,0 +1,5 @@
+/* $XFree86$ */
+
+extern void KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms,
+ CARD8 *pModMap);
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_kmod.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_kmod.c
new file mode 100644
index 000000000..c211d115a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_kmod.c
@@ -0,0 +1,113 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kmod.c,v 3.5 2001/10/01 13:44:14 eich Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <signal.h>
+#include "xf86_OSlib.h"
+#include "xf86.h"
+
+
+#define MODPROBE_PATH_FILE "/proc/sys/kernel/modprobe"
+#define MAX_PATH 1024
+
+
+#if 0
+/* XFree86 #defines execl to be the xf86execl() function which does
+ * a fork AND exec. We don't want that. We want the regular,
+ * standard execl().
+ */
+#ifdef execl
+#undef execl
+#endif
+#endif
+
+
+/*
+ * Load a Linux kernel module.
+ * This is used by the DRI/DRM to load a DRM kernel module when
+ * the X server starts. It could be used for other purposes in the future.
+ * Input:
+ * modName - name of the kernel module (Ex: "tdfx")
+ * Return:
+ * 0 for failure, 1 for success
+ */
+int
+xf86LoadKernelModule(const char *modName)
+{
+ char mpPath[MAX_PATH] = "";
+ int fd = -1, status, n;
+ pid_t pid;
+
+ /* get the path to the modprobe program */
+ fd = open(MODPROBE_PATH_FILE, O_RDONLY);
+ if (fd >= 0) {
+ int count = read(fd, mpPath, MAX_PATH - 1);
+ if (count <= 0) {
+ mpPath[0] = 0;
+ }
+ else if (mpPath[count - 1] == '\n') {
+ mpPath[count - 1] = 0; /* replaces \n with \0 */
+ }
+ close(fd);
+ /* if this worked, mpPath will be "/sbin/modprobe" or similar. */
+ }
+
+ if (mpPath[0] == 0) {
+ /* we failed to get the path from the system, use a default */
+ strcpy(mpPath, "/sbin/modprobe");
+ }
+
+ /* now fork/exec the modprobe command */
+ /*
+ * It would be good to capture stdout/stderr so that it can be directed
+ * to the log file. modprobe errors currently are missing from the log
+ * file.
+ */
+ switch (pid = fork()) {
+ case 0: /* child */
+ /* change real/effective user ID to 0/0 as we need to
+ * preinstall agpgart module for some DRM modules
+ */
+ if (setreuid(0,0)) {
+ xf86Msg(X_WARNING,"LoadKernelModule: "
+ "Setting of real/effective user Id to 0/0 failed");
+ }
+ setenv("PATH","/sbin",1);
+ n = execl(mpPath, "modprobe", modName, NULL);
+ xf86Msg(X_WARNING,"LoadKernelModule %s\n",strerror(errno));
+ exit(EXIT_FAILURE); /* if we get here the child's exec failed */
+ break;
+ case -1: /* fork failed */
+ return 0;
+ default: /* fork worked */
+ {
+ /* XXX we loop over waitpid() because it sometimes fails on
+ * the first attempt. Don't know why!
+ */
+ int count = 0, p;
+ do {
+ p = waitpid(pid, &status, 0);
+ } while (p == -1 && count++ < 4);
+
+ if (p == -1) {
+ return 0;
+ }
+
+ if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
+ return 1; /* success! */
+ }
+ else {
+ return 0;
+ }
+ }
+ }
+
+ /* never get here */
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_mouse.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_mouse.c
new file mode 100644
index 000000000..d73c69853
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_mouse.c
@@ -0,0 +1,206 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_mouse.c,v 1.2 2003/10/08 14:58:30 dawes Exp $ */
+
+/*
+ * Copyright 1999 by The XFree86 Project, Inc.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+#include "xf86_OSlib.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+static int
+SupportedInterfaces(void)
+{
+ return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_AUTO;
+}
+
+static const char *
+DefaultProtocol(void)
+{
+ return "Auto";
+}
+
+#define DEFAULT_MOUSE_DEV "/dev/mouse"
+#define DEFAULT_PS2_DEV "/dev/psaux"
+#define DEFAULT_GPM_DATA_DEV "/dev/gpmdata"
+#define DEFAULT_GPM_CTL_DEV "/dev/gpmdata"
+
+static const char *mouseDevs[] = {
+ DEFAULT_MOUSE_DEV,
+ DEFAULT_PS2_DEV,
+ DEFAULT_GPM_DATA_DEV,
+ NULL
+};
+
+typedef enum {
+ MOUSE_PROTO_UNKNOWN = 0,
+ MOUSE_PROTO_SERIAL,
+ MOUSE_PROTO_PS2,
+ MOUSE_PROTO_MSC,
+ MOUSE_PROTO_GPM
+} protocolTypes;
+
+static struct {
+ protocolTypes proto;
+ const char *name;
+} devproto[] = {
+ { MOUSE_PROTO_UNKNOWN, NULL },
+ { MOUSE_PROTO_PS2, "PS/2" },
+ { MOUSE_PROTO_MSC, "MouseSystems" },
+ { MOUSE_PROTO_GPM, "GPM" }
+};
+
+static const char *
+FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ int fd = -1;
+ const char **pdev;
+
+ for (pdev = mouseDevs; *pdev; pdev++) {
+ SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK | O_EXCL));
+ if (fd == -1) {
+#ifdef DEBUG
+ ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno));
+#endif
+ } else
+ break;
+ }
+
+ if (*pdev) {
+ close(fd);
+ /* Set the Device option. */
+ pInfo->conf_idev->commonOptions =
+ xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", *pdev);
+ xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
+ pInfo->name, *pdev);
+ }
+
+ return *pdev;
+}
+
+static const char *
+GuessProtocol(InputInfoPtr pInfo, int flags)
+{
+ int fd = -1;
+ const char *dev;
+ char *realdev;
+ struct stat sbuf;
+ int i;
+ int proto = MOUSE_PROTO_UNKNOWN;
+
+ dev = xf86SetStrOption(pInfo->conf_idev->commonOptions, "Device", NULL);
+ if (!dev) {
+#ifdef DEBUG
+ ErrorF("xf86SetStrOption failed to return the device name\n");
+#endif
+ return NULL;
+ }
+ /* Look at the device name to guess the protocol. */
+ realdev = NULL;
+ if (strcmp(dev, DEFAULT_MOUSE_DEV) == 0) {
+ if (lstat(dev, &sbuf) != 0) {
+#ifdef DEBUG
+ ErrorF("lstat failed for %s (%s)\n", dev, strerror(errno));
+#endif
+ return NULL;
+ }
+ if (S_ISLNK(sbuf.st_mode)) {
+ realdev = xnfalloc(PATH_MAX + 1);
+ i = readlink(dev, realdev, PATH_MAX);
+ if (i <= 0) {
+#ifdef DEBUG
+ ErrorF("readlink failed for %s (%s)\n", dev, strerror(errno));
+#endif
+ xfree(realdev);
+ return NULL;
+ }
+ realdev[i] = '\0';
+ }
+ }
+ if (!realdev)
+ realdev = xnfstrdup(dev);
+ else {
+ /* If realdev doesn't contain a '/' then prepend "/dev/" */
+ if (!strchr(realdev, '/')) {
+ char *tmp = xnfalloc(strlen(realdev) + 5 + 1);
+ sprintf(tmp, "/dev/%s", realdev);
+ xfree(realdev);
+ realdev = tmp;
+ }
+ }
+
+ if (strcmp(realdev, DEFAULT_PS2_DEV) == 0)
+ proto = MOUSE_PROTO_PS2;
+ else if (strcmp(realdev, DEFAULT_GPM_DATA_DEV) == 0)
+ proto = MOUSE_PROTO_MSC;
+ else if (strcmp(realdev, DEFAULT_GPM_CTL_DEV) == 0)
+ proto = MOUSE_PROTO_GPM;
+ xfree(realdev);
+ /*
+ * If the protocol can't be guessed from the device name,
+ * try to characterise it.
+ */
+ if (proto == MOUSE_PROTO_UNKNOWN) {
+ SYSCALL (fd = open(dev, O_RDWR | O_NONBLOCK | O_EXCL));
+ if (isatty(fd)) {
+ /* Serial PnP has already failed, so give up. */
+ } else {
+ if (fstat(fd, &sbuf) != 0) {
+#ifdef DEBUG
+ ErrorF("fstat failed for %s (%s)\n", dev, strerror(errno));
+#endif
+ close(fd);
+ return NULL;
+ }
+ if (S_ISFIFO(sbuf.st_mode)) {
+ /* Assume GPM data in MSC format. */
+ proto = MOUSE_PROTO_MSC;
+ } else {
+ /* Default to PS/2 */
+ proto = MOUSE_PROTO_PS2;
+ }
+ }
+ close(fd);
+ }
+ if (proto == MOUSE_PROTO_UNKNOWN) {
+ xf86Msg(X_ERROR, "%s: GuessProtocol: Cannot find mouse protocol.\n",
+ pInfo->name);
+ return NULL;
+ } else {
+ for (i = 0; i < sizeof(devproto)/sizeof(devproto[0]); i++) {
+ if (devproto[i].proto == proto) {
+ xf86Msg(X_INFO,
+ "%s: GuessProtocol: "
+ "setting mouse protocol to \"%s\"\n",
+ pInfo->name, devproto[i].name);
+ return devproto[i].name;
+ }
+ }
+ }
+ return NULL;
+}
+
+OSMouseInfoPtr
+xf86OSMouseInit(int flags)
+{
+ OSMouseInfoPtr p;
+
+ p = xcalloc(sizeof(OSMouseInfoRec), 1);
+ if (!p)
+ return NULL;
+ p->SupportedInterfaces = SupportedInterfaces;
+ p->DefaultProtocol = DefaultProtocol;
+ p->FindDevice = FindDevice;
+ p->GuessProtocol = GuessProtocol;
+ return p;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_pci.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_pci.c
new file mode 100644
index 000000000..cec9226c8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_pci.c
@@ -0,0 +1,230 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_pci.c,v 3.8 2002/04/09 15:59:37 tsi Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
+#include "xf86_OSproc.h"
+#include "xf86Pci.h"
+
+#ifdef __sparc__
+#define PCIADDR_TYPE long long
+#define PCIADDR_IGNORE_FMT "%*x"
+#define PCIADDR_FMT "%llx"
+#else
+#define PCIADDR_TYPE long
+#define PCIADDR_IGNORE_FMT "%*x"
+#define PCIADDR_FMT "%lx"
+#endif
+
+FILE *xf86OSLinuxPCIFile = NULL;
+
+Bool
+xf86GetPciSizeFromOS(PCITAG tag, int index, int* bits)
+{
+ char c[0x200];
+ char *res;
+ unsigned int bus, devfn, dev, fn;
+ unsigned PCIADDR_TYPE size[7];
+ unsigned int num;
+ signed PCIADDR_TYPE Size;
+
+ if (index > 7)
+ return FALSE;
+
+ if (!xf86OSLinuxPCIFile && \
+ !(xf86OSLinuxPCIFile = fopen("/proc/bus/pci/devices","r")))
+ return FALSE;
+ do {
+ res = fgets(c,0x1ff,xf86OSLinuxPCIFile);
+ if (res) {
+ num = sscanf(res,
+ /*bus+dev vendorid deviceid irq */
+ "%02x%02x\t%*04x%*04x\t%*x"
+ /* 7 PCI resource base addresses */
+ "\t" PCIADDR_IGNORE_FMT
+ "\t" PCIADDR_IGNORE_FMT
+ "\t" PCIADDR_IGNORE_FMT
+ "\t" PCIADDR_IGNORE_FMT
+ "\t" PCIADDR_IGNORE_FMT
+ "\t" PCIADDR_IGNORE_FMT
+ "\t" PCIADDR_IGNORE_FMT
+ /* 7 PCI resource sizes, and then optionally a driver name */
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT,
+ &bus,&devfn,&size[0],&size[1],&size[2],&size[3],
+ &size[4],&size[5],&size[6]);
+ if (num != 9) { /* apparantly not 2.3 style */
+ fseek(xf86OSLinuxPCIFile, 0L, SEEK_SET);
+ return FALSE;
+ }
+ dev = devfn >> 3;
+ fn = devfn & 0x7;
+ if (tag == pciTag(bus,dev,fn)) {
+ *bits = 0;
+ if (size[index] != 0) {
+ Size = size[index] - ((PCIADDR_TYPE) 1);
+ while (Size & ((PCIADDR_TYPE) 0x01)) {
+ Size = Size >> ((PCIADDR_TYPE) 1);
+ (*bits)++;
+ }
+ }
+ fseek(xf86OSLinuxPCIFile, 0L, SEEK_SET);
+ return TRUE;
+ }
+ }
+ } while (res);
+
+ fseek(xf86OSLinuxPCIFile, 0L, SEEK_SET);
+ return FALSE;
+}
+
+
+
+/* Query the kvirt address (64bit) of a BAR range from TAG */
+Bool
+xf86GetPciOffsetFromOS(PCITAG tag, int index, unsigned long* bases)
+{
+ FILE *file;
+ char c[0x200];
+ char *res;
+ unsigned int bus, devfn, dev, fn;
+ unsigned PCIADDR_TYPE offset[7];
+ unsigned int num;
+
+ if (index > 7)
+ return FALSE;
+
+ if (!(file = fopen("/proc/bus/pci/devices","r")))
+ return FALSE;
+ do {
+ res = fgets(c,0x1ff,file);
+ if (res) {
+ num = sscanf(res,
+ /*bus+dev vendorid deviceid irq */
+ "%02x%02x\t%*04x%*04x\t%*x"
+ /* 7 PCI resource base addresses */
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ /* 7 PCI resource sizes, and then optionally a driver name */
+ "\t" PCIADDR_IGNORE_FMT
+ "\t" PCIADDR_IGNORE_FMT
+ "\t" PCIADDR_IGNORE_FMT
+ "\t" PCIADDR_IGNORE_FMT
+ "\t" PCIADDR_IGNORE_FMT
+ "\t" PCIADDR_IGNORE_FMT
+ "\t" PCIADDR_IGNORE_FMT,
+ &bus,&devfn,&offset[0],&offset[1],&offset[2],&offset[3],
+ &offset[4],&offset[5],&offset[6]);
+ if (num != 9) { /* apparantly not 2.3 style */
+ fclose(file);
+ return FALSE;
+ }
+
+ dev = devfn >> 3;
+ fn = devfn & 0x7;
+ if (tag == pciTag(bus,dev,fn)) {
+ /* return the offset for the index requested */
+ *bases = offset[index];
+ fclose(file);
+ return TRUE;
+ }
+ }
+ } while (res);
+
+ fclose(file);
+ return FALSE;
+}
+
+/* Query the kvirt address (64bit) of a BAR range from size for a given TAG */
+unsigned long
+xf86GetOSOffsetFromPCI(PCITAG tag, int space, unsigned long base)
+{
+ FILE *file;
+ char c[0x200];
+ char *res;
+ unsigned int bus, devfn, dev, fn;
+ unsigned PCIADDR_TYPE offset[7];
+ unsigned PCIADDR_TYPE size[7];
+ unsigned int num;
+ unsigned int ndx;
+
+ if (!(file = fopen("/proc/bus/pci/devices","r")))
+ return 0;
+ do {
+ res = fgets(c,0x1ff,file);
+ if (res) {
+ num = sscanf(res,
+ /*bus+dev vendorid deviceid irq */
+ "%02x%02x\t%*04x%*04x\t%*x"
+ /* 7 PCI resource base addresses */
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ /* 7 PCI resource sizes, and then optionally a driver name */
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT
+ "\t" PCIADDR_FMT,
+ &bus,&devfn,&offset[0],&offset[1],&offset[2],&offset[3],
+ &offset[4],&offset[5],&offset[6], &size[0], &size[1], &size[2],
+ &size[3], &size[4], &size[5], &size[6]);
+ if (num != 16) { /* apparantly not 2.3 style */
+ fclose(file);
+ return 0;
+ }
+
+ dev = devfn >> 3;
+ fn = devfn & 0x7;
+ if (tag == pciTag(bus,dev,fn)) {
+ /* ok now look through all the BAR values of this device */
+ for (ndx=0; ndx<7; ndx++) {
+ unsigned long savePtr;
+ /*
+ * remember to lop of the last 4bits of the BAR values as they are
+ * memory attributes
+ */
+ if (ndx == 6)
+ savePtr = (0xFFFFFFF0) &
+ pciReadLong(tag, PCI_CMD_BIOS_REG);
+ else /* this the ROM bar */
+ savePtr = (0xFFFFFFF0) &
+ pciReadLong(tag, PCI_CMD_BASE_REG + (0x4 * ndx));
+
+ /* find the index of the incoming base */
+ if (base >= savePtr && base <= (savePtr + size[ndx])) {
+ fclose(file);
+ return (offset[ndx] & ~(0xFUL)) + (base - savePtr);
+ }
+ }
+ }
+ }
+ } while (res);
+
+ fclose(file);
+ return 0;
+
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c
new file mode 100644
index 000000000..577439c54
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c
@@ -0,0 +1,1169 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c,v 1.10 2005/09/19 18:38:26 alanc Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c,v 3.67 2003/06/25 18:27:07 eich Exp $ */
+/*
+ * Copyright 1992 by Orest Zborowski <obz@Kodak.com>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Orest Zborowski and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Orest Zborowski
+ * and David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT BE LIABLE
+ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: lnx_video.c /main/9 1996/10/19 18:06:34 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <errno.h>
+#include <string.h>
+
+#include <X11/X.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+#include "lnx.h"
+#ifdef __alpha__
+#include "shared/xf86Axp.h"
+#endif
+
+#ifdef HAS_MTRR_SUPPORT
+#include <asm/mtrr.h>
+#endif
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+static Bool ExtendedEnabled = FALSE;
+
+#ifdef __ia64__
+
+#include "compiler.h"
+#include <sys/io.h>
+
+#elif !defined(__powerpc__) && \
+ !defined(__mc68000__) && \
+ !defined(__sparc__) && \
+ !defined(__mips__)
+
+/*
+ * Due to conflicts with "compiler.h", don't rely on <sys/io.h> to declare
+ * these.
+ */
+extern int ioperm(unsigned long __from, unsigned long __num, int __turn_on);
+extern int iopl(int __level);
+
+#endif
+
+#ifdef __alpha__
+
+# ifdef LIBC_IS_FIXED
+extern void sethae(unsigned long hae);
+# else
+# include <unistd.h>
+# define sethae(x) syscall(301,x);
+# endif
+
+/* define to test the Sparse addressing on a non-Jensen */
+# ifdef TEST_JENSEN_CODE
+# define isJensen (1)
+# else
+# define isJensen (axpSystem == JENSEN)
+# endif
+
+# define BUS_BASE bus_base
+
+#else
+
+#define BUS_BASE (0)
+
+#endif /* __alpha__ */
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+static pointer mapVidMem(int, unsigned long, unsigned long, int);
+static void unmapVidMem(int, pointer, unsigned long);
+#if defined (__alpha__)
+static pointer mapVidMemSparse(int, unsigned long, unsigned long, int);
+extern axpDevice lnxGetAXP(void);
+static void unmapVidMemSparse(int, pointer, unsigned long);
+# if defined(JENSEN_SUPPORT)
+static pointer mapVidMemJensen(int, unsigned long, unsigned long, int);
+static void unmapVidMemJensen(int, pointer, unsigned long);
+# endif
+static axpDevice axpSystem = -1;
+static Bool needSparse;
+static unsigned long hae_thresh;
+static unsigned long hae_mask;
+static unsigned long bus_base;
+static unsigned long sparse_size;
+#endif
+
+#ifdef HAS_MTRR_SUPPORT
+
+#define SPLIT_WC_REGIONS 1
+
+static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType);
+static void undoWC(int, pointer);
+
+/* The file desc for /proc/mtrr. Once opened, left opened, and the mtrr
+ driver will clean up when we exit. */
+#define MTRR_FD_UNOPENED (-1) /* We have yet to open /proc/mtrr */
+#define MTRR_FD_PROBLEM (-2) /* We tried to open /proc/mtrr, but had
+ a problem. */
+static int mtrr_fd = MTRR_FD_UNOPENED;
+
+/* Open /proc/mtrr. FALSE on failure. Will always fail on Linux 2.0,
+ and will fail on Linux 2.2 with MTRR support configured out,
+ so verbosity should be chosen appropriately. */
+static Bool
+mtrr_open(int verbosity)
+{
+ /* Only report absence of /proc/mtrr once. */
+ static Bool warned = FALSE;
+
+ char **fn;
+ static char *mtrr_files[] = {
+ "/dev/cpu/mtrr", /* Possible future name */
+ "/proc/mtrr", /* Current name */
+ NULL
+ };
+
+ if (mtrr_fd == MTRR_FD_UNOPENED) {
+ /* So open it. */
+ for (fn = mtrr_files; mtrr_fd < 0 && *fn; fn++)
+ mtrr_fd = open(*fn, O_WRONLY);
+
+ if (mtrr_fd < 0)
+ mtrr_fd = MTRR_FD_PROBLEM;
+ }
+
+ if (mtrr_fd == MTRR_FD_PROBLEM) {
+ /* To make sure we only ever warn once, need to check
+ verbosity outside xf86MsgVerb */
+ if (!warned && verbosity <= xf86GetVerbosity()) {
+ xf86MsgVerb(X_WARNING, verbosity,
+ "System lacks support for changing MTRRs\n");
+ warned = TRUE;
+ }
+
+ return FALSE;
+ }
+ else
+ return TRUE;
+}
+
+/*
+ * We maintain a list of WC regions for each physical mapping so they can
+ * be undone when unmapping.
+ */
+
+struct mtrr_wc_region {
+ struct mtrr_sentry sentry;
+ Bool added; /* added WC or removed it */
+ struct mtrr_wc_region * next;
+};
+
+
+static struct mtrr_wc_region *
+mtrr_cull_wc_region(int screenNum, unsigned long base, unsigned long size,
+ MessageType from)
+{
+ /* Some BIOS writers thought that setting wc over the mmio
+ region of a graphics devices was a good idea. Try to fix
+ it. */
+
+ struct mtrr_gentry gent;
+ struct mtrr_wc_region *wcreturn = NULL, *wcr;
+ int count, ret=0;
+
+ /* Linux 2.0 users should not get a warning without -verbose */
+ if (!mtrr_open(2))
+ return NULL;
+
+ for (gent.regnum = 0;
+ ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0;
+ gent.regnum++) {
+ if (gent.type != MTRR_TYPE_WRCOMB
+ || gent.base + gent.size <= base
+ || base + size <= gent.base)
+ continue;
+
+ /* Found an overlapping region. Delete it. */
+
+ wcr = xalloc(sizeof(*wcr));
+ if (!wcr)
+ return NULL;
+ wcr->sentry.base = gent.base;
+ wcr->sentry.size = gent.size;
+ wcr->sentry.type = MTRR_TYPE_WRCOMB;
+ wcr->added = FALSE;
+
+ count = 3;
+ while (count-- &&
+ (ret = ioctl(mtrr_fd, MTRRIOC_KILL_ENTRY, &(wcr->sentry))) < 0);
+
+ if (ret >= 0) {
+ xf86DrvMsg(screenNum, from,
+ "Removed MMIO write-combining range "
+ "(0x%lx,0x%lx)\n",
+ (unsigned long) gent.base, (unsigned long) gent.size);
+ wcr->next = wcreturn;
+ wcreturn = wcr;
+ gent.regnum--;
+ } else {
+ xfree(wcr);
+ xf86DrvMsgVerb(screenNum, X_WARNING, 0,
+ "Failed to remove MMIO "
+ "write-combining range (0x%lx,0x%lx)\n",
+ gent.base, (unsigned long) gent.size);
+ }
+ }
+ return wcreturn;
+}
+
+
+static struct mtrr_wc_region *
+mtrr_remove_offending(int screenNum, unsigned long base, unsigned long size,
+ MessageType from)
+{
+ struct mtrr_gentry gent;
+ struct mtrr_wc_region *wcreturn = NULL, **wcr;
+
+ if (!mtrr_open(2))
+ return NULL;
+
+ wcr = &wcreturn;
+ for (gent.regnum = 0;
+ ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0; gent.regnum++ ) {
+ if (gent.type == MTRR_TYPE_WRCOMB
+ && ((gent.base >= base && gent.base + gent.size < base + size) ||
+ (gent.base > base && gent.base + gent.size <= base + size))) {
+ *wcr = mtrr_cull_wc_region(screenNum, gent.base, gent.size, from);
+ if (*wcr) gent.regnum--;
+ while(*wcr) {
+ wcr = &((*wcr)->next);
+ }
+ }
+ }
+ return wcreturn;
+}
+
+
+static struct mtrr_wc_region *
+mtrr_add_wc_region(int screenNum, unsigned long base, unsigned long size,
+ MessageType from)
+{
+ struct mtrr_wc_region **wcr, *wcreturn, *curwcr;
+
+ /*
+ * There can be only one....
+ */
+
+ wcreturn = mtrr_remove_offending(screenNum, base, size, from);
+ wcr = &wcreturn;
+ while (*wcr) {
+ wcr = &((*wcr)->next);
+ }
+
+ /* Linux 2.0 should not warn, unless the user explicitly asks for
+ WC. */
+
+ if (!mtrr_open(from == X_CONFIG ? 0 : 2))
+ return wcreturn;
+
+ *wcr = curwcr = xalloc(sizeof(**wcr));
+ if (!curwcr)
+ return wcreturn;
+
+ curwcr->sentry.base = base;
+ curwcr->sentry.size = size;
+ curwcr->sentry.type = MTRR_TYPE_WRCOMB;
+ curwcr->added = TRUE;
+ curwcr->next = NULL;
+
+#if SPLIT_WC_REGIONS
+ /*
+ * Splits up the write-combining region if it is not aligned on a
+ * size boundary.
+ */
+
+ {
+ unsigned long lbase, d_size = 1;
+ unsigned long n_size = size;
+ unsigned long n_base = base;
+
+ for (lbase = n_base, d_size = 1; !(lbase & 1);
+ lbase = lbase >> 1, d_size <<= 1);
+ while (d_size > n_size)
+ d_size = d_size >> 1;
+#ifdef DEBUG
+ ErrorF("WC_BASE: 0x%lx WC_END: 0x%lx\n",base,base+d_size-1);
+#endif
+ n_base += d_size;
+ n_size -= d_size;
+ if (n_size) {
+ xf86DrvMsgVerb(screenNum,X_INFO,3,"Splitting WC range: "
+ "base: 0x%lx, size: 0x%lx\n",base,size);
+ curwcr->next = mtrr_add_wc_region(screenNum, n_base, n_size,from);
+ }
+ curwcr->sentry.size = d_size;
+ }
+
+ /*****************************************************************/
+#endif /* SPLIT_WC_REGIONS */
+
+ if (ioctl(mtrr_fd, MTRRIOC_ADD_ENTRY, &curwcr->sentry) >= 0) {
+ /* Avoid printing on every VT switch */
+ if (xf86ServerIsInitialising()) {
+ xf86DrvMsg(screenNum, from,
+ "Write-combining range (0x%lx,0x%lx)\n",
+ base, size);
+ }
+ return wcreturn;
+ }
+ else {
+ *wcr = curwcr->next;
+ xfree(curwcr);
+
+ /* Don't complain about the VGA region: MTRR fixed
+ regions aren't currently supported, but might be in
+ the future. */
+ if ((unsigned long)base >= 0x100000) {
+ xf86DrvMsgVerb(screenNum, X_WARNING, 0,
+ "Failed to set up write-combining range "
+ "(0x%lx,0x%lx)\n", base, size);
+ }
+ return wcreturn;
+ }
+}
+
+static void
+mtrr_undo_wc_region(int screenNum, struct mtrr_wc_region *wcr)
+{
+ struct mtrr_wc_region *p, *prev;
+
+ if (mtrr_fd > 0) {
+ p = wcr;
+ while (p) {
+ if (p->added)
+ ioctl(mtrr_fd, MTRRIOC_DEL_ENTRY, &p->sentry);
+ prev = p;
+ p = p->next;
+ xfree(prev);
+ }
+ }
+}
+
+static pointer
+setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
+ MessageType from)
+{
+ if (enable)
+ return mtrr_add_wc_region(screenNum, base, size, from);
+ else
+ return mtrr_cull_wc_region(screenNum, base, size, from);
+}
+
+static void
+undoWC(int screenNum, pointer regioninfo)
+{
+ mtrr_undo_wc_region(screenNum, regioninfo);
+}
+
+#endif /* HAS_MTRR_SUPPORT */
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->linearSupported = TRUE;
+#ifdef __alpha__
+ if (axpSystem == -1) {
+ axpSystem = lnxGetAXP();
+ if ((needSparse = (_bus_base_sparse() > 0))) {
+ hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
+ hae_mask = xf86AXPParams[axpSystem].hae_mask;
+ sparse_size = xf86AXPParams[axpSystem].size;
+ }
+ bus_base = _bus_base();
+ }
+ if (isJensen) {
+# ifndef JENSEN_SUPPORT
+ FatalError("Jensen is not supported any more\n"
+ "If you are intereseted in fixing Jensen support\n"
+ "please contact xfree86@xfree86.org\n");
+# else
+ xf86Msg(X_INFO,"Machine type is Jensen\n");
+ pVidMem->mapMem = mapVidMemJensen;
+ pVidMem->unmapMem = unmapVidMemJensen;
+# endif /* JENSEN_SUPPORT */
+ } else if (needSparse) {
+ xf86Msg(X_INFO,"Machine needs sparse mapping\n");
+ pVidMem->mapMem = mapVidMemSparse;
+ pVidMem->unmapMem = unmapVidMemSparse;
+ } else {
+ xf86Msg(X_INFO,"Machine type has 8/16 bit access\n");
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+ }
+#else
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+#endif /* __alpha__ */
+
+
+#ifdef HAS_MTRR_SUPPORT
+ pVidMem->setWC = setWC;
+ pVidMem->undoWC = undoWC;
+#endif
+ pVidMem->initialised = TRUE;
+}
+
+#ifdef __sparc__
+/* Basically, you simply cannot do this on Sparc. You have to do something portable
+ * like use /dev/fb* or mmap() on /proc/bus/pci/X/Y nodes. -DaveM
+ */
+static pointer mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ return NULL;
+}
+#else
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ pointer base;
+ int fd;
+ int mapflags = MAP_SHARED;
+ int prot;
+ memType realBase, alignOff;
+
+ realBase = Base & ~(getpagesize() - 1);
+ alignOff = Base - realBase;
+#ifdef DEBUG
+ ErrorF("base: %lx, realBase: %lx, alignOff: %lx \n",
+ Base,realBase,alignOff);
+#endif
+
+#if defined(__ia64__)
+#ifndef MAP_WRITECOMBINED
+#define MAP_WRITECOMBINED 0x00010000
+#endif
+#ifndef MAP_NONCACHED
+#define MAP_NONCACHED 0x00020000
+#endif
+ if(flags & VIDMEM_FRAMEBUFFER)
+ mapflags |= MAP_WRITECOMBINED;
+ else
+ mapflags |= MAP_NONCACHED;
+#endif
+
+#if 0
+ /* this will disappear when people upgrade their kernels */
+ fd = open(DEV_MEM,
+ ((flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR) | O_SYNC);
+#else
+ fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
+#endif
+ if (fd < 0)
+ {
+ FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
+ strerror(errno));
+ }
+
+ if (flags & VIDMEM_READONLY)
+ prot = PROT_READ;
+ else
+ prot = PROT_READ | PROT_WRITE;
+
+ /* This requires linux-0.99.pl10 or above */
+ base = mmap((caddr_t)0, Size + alignOff, prot, mapflags, fd,
+ (off_t)realBase + BUS_BASE);
+ close(fd);
+ if (base == MAP_FAILED) {
+ FatalError("xf86MapVidMem: Could not mmap framebuffer"
+ " (0x%08lx,0x%lx) (%s)\n", Base, Size,
+ strerror(errno));
+ }
+#ifdef DEBUG
+ ErrorF("base: %lx aligned base: %lx\n",base, base + alignOff);
+#endif
+ return (char *)base + alignOff;
+}
+#endif /* !(__sparc__) */
+
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ memType alignOff = (memType)Base
+ - ((memType)Base & ~(getpagesize() - 1));
+
+#ifdef DEBUG
+ ErrorF("alignment offset: %lx\n",alignOff);
+#endif
+ munmap((caddr_t)((memType)Base - alignOff), (Size + alignOff));
+}
+
+
+/***************************************************************************/
+/* I/O Permissions section */
+/***************************************************************************/
+
+#if defined(__powerpc__)
+volatile unsigned char *ioBase = NULL;
+
+#ifndef __NR_pciconfig_iobase
+#define __NR_pciconfig_iobase 200
+#endif
+
+#endif
+
+Bool
+xf86EnableIO(void)
+{
+#if defined(__powerpc__)
+ int fd;
+ unsigned int ioBase_phys;
+#endif
+
+ if (ExtendedEnabled)
+ return TRUE;
+
+#if defined(__powerpc__)
+ ioBase_phys = syscall(__NR_pciconfig_iobase, 2, 0, 0);
+
+ fd = open("/dev/mem", O_RDWR);
+ if (ioBase == NULL) {
+ ioBase = (volatile unsigned char *)mmap(0, 0x20000,
+ PROT_READ | PROT_WRITE, MAP_SHARED, fd,
+ ioBase_phys);
+/* Should this be fatal or just a warning? */
+#if 0
+ if (ioBase == MAP_FAILED) {
+ xf86Msg(X_WARNING,
+ "xf86EnableIOPorts: Failed to map iobase (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+#endif
+ }
+ close(fd);
+#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__)
+ if (ioperm(0, 1024, 1) || iopl(3)) {
+ if (errno == ENODEV)
+ ErrorF("xf86EnableIOPorts: no I/O ports found\n");
+ else
+ FatalError("xf86EnableIOPorts: failed to set IOPL"
+ " for I/O (%s)\n", strerror(errno));
+ return FALSE;
+ }
+# if !defined(__alpha__)
+ ioperm(0x40,4,0); /* trap access to the timer chip */
+ ioperm(0x60,4,0); /* trap access to the keyboard controller */
+# endif
+#endif
+ ExtendedEnabled = TRUE;
+
+ return TRUE;
+}
+
+void
+xf86DisableIO(void)
+{
+ if (!ExtendedEnabled)
+ return;
+#if defined(__powerpc__)
+ munmap(ioBase, 0x20000);
+ ioBase = NULL;
+#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__)
+ iopl(0);
+ ioperm(0, 1024, 0);
+#endif
+ ExtendedEnabled = FALSE;
+
+ return;
+}
+
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+/* XXX The #ifdefs should be made simpler. */
+
+Bool
+xf86DisableInterrupts()
+{
+#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__sh__) && !defined(__hppa__)
+ if (!ExtendedEnabled)
+ if (iopl(3) || ioperm(0, 1024, 1))
+ return (FALSE);
+#endif
+#if defined(__alpha__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__) || defined(__mips__) || defined(__arm__) || defined(__sh__) || defined(__ia64__) || defined(__hppa__)
+#else
+# ifdef __GNUC__
+# if defined(__ia64__)
+# if 0
+ __asm__ __volatile__ (";; rsm psr.i;; srlz.d" ::: "memory");
+# endif
+# else
+ __asm__ __volatile__("cli");
+# endif
+# else
+ asm("cli");
+# endif
+#endif
+#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__ia64__) && !defined(__hppa__)
+ if (!ExtendedEnabled) {
+ iopl(0);
+ ioperm(0, 1024, 0);
+ }
+
+#endif
+ return (TRUE);
+}
+
+void
+xf86EnableInterrupts()
+{
+#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__sh__) && !defined(__hppa__)
+ if (!ExtendedEnabled)
+ if (iopl(3) || ioperm(0, 1024, 1))
+ return;
+#endif
+#if defined(__alpha__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__) || defined(__mips__) || defined(__arm__) || defined(__sh__) || defined(__ia64__) || defined(__hppa__)
+#else
+# ifdef __GNUC__
+# if defined(__ia64__)
+# if 0
+ __asm__ __volatile__ (";; ssm psr.i;; srlz.d" ::: "memory");
+# endif
+# else
+ __asm__ __volatile__("sti");
+# endif
+# else
+ asm("sti");
+# endif
+#endif
+#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__ia64__) && !defined(__hppa__)
+ if (!ExtendedEnabled) {
+ iopl(0);
+ ioperm(0, 1024, 0);
+ }
+#endif
+ return;
+}
+
+#if defined (__alpha__)
+
+#define vuip volatile unsigned int *
+
+extern int readDense8(pointer Base, register unsigned long Offset);
+extern int readDense16(pointer Base, register unsigned long Offset);
+extern int readDense32(pointer Base, register unsigned long Offset);
+extern void
+writeDenseNB8(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDenseNB16(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDenseNB32(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDense8(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDense16(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDense32(int Value, pointer Base, register unsigned long Offset);
+
+static int readSparse8(pointer Base, register unsigned long Offset);
+static int readSparse16(pointer Base, register unsigned long Offset);
+static int readSparse32(pointer Base, register unsigned long Offset);
+static void
+writeSparseNB8(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseNB16(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseNB32(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparse8(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparse16(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparse32(int Value, pointer Base, register unsigned long Offset);
+
+#define DENSE_BASE 0x2ff00000000UL
+#define SPARSE_BASE 0x30000000000UL
+
+static unsigned long msb_set = 0;
+
+static pointer
+mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ int fd, prot;
+ unsigned long ret, rets = 0;
+
+ static Bool was_here = FALSE;
+
+ if (!was_here) {
+ was_here = TRUE;
+
+ xf86WriteMmio8 = writeSparse8;
+ xf86WriteMmio16 = writeSparse16;
+ xf86WriteMmio32 = writeSparse32;
+ xf86WriteMmioNB8 = writeSparseNB8;
+ xf86WriteMmioNB16 = writeSparseNB16;
+ xf86WriteMmioNB32 = writeSparseNB32;
+ xf86ReadMmio8 = readSparse8;
+ xf86ReadMmio16 = readSparse16;
+ xf86ReadMmio32 = readSparse32;
+ }
+
+ fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
+ if (fd < 0) {
+ FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
+ strerror(errno));
+ }
+
+#if 0
+ xf86Msg(X_INFO,"mapVidMemSparse: try Base 0x%lx size 0x%lx flags 0x%x\n",
+ Base, Size, flags);
+#endif
+
+ if (flags & VIDMEM_READONLY)
+ prot = PROT_READ;
+ else
+ prot = PROT_READ | PROT_WRITE;
+
+ /* This requirers linux-0.99.pl10 or above */
+
+ /*
+ * Always do DENSE mmap, since read32/write32 currently require it.
+ */
+ ret = (unsigned long)mmap((caddr_t)(DENSE_BASE + Base), Size,
+ prot, MAP_SHARED, fd,
+ (off_t) (bus_base + Base));
+
+ /*
+ * Do SPARSE mmap only when MMIO and not MMIO_32BIT, or FRAMEBUFFER
+ * and SPARSE (which should require the use of read/write macros).
+ *
+ * By not SPARSE mmapping an 8MB framebuffer, we can save approx. 256K
+ * bytes worth of pagetable (32 pages).
+ */
+ if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) ||
+ ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE)))
+ {
+ rets = (unsigned long)mmap((caddr_t)(SPARSE_BASE + (Base << 5)),
+ Size << 5, prot, MAP_SHARED, fd,
+ (off_t) _bus_base_sparse() + (Base << 5));
+ }
+
+ close(fd);
+
+ if (ret == (unsigned long)MAP_FAILED) {
+ FatalError("xf86MapVidMemSparse: Could not (dense) mmap fb (%s)\n",
+ strerror(errno));
+ }
+
+ if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) ||
+ ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE)))
+ {
+ if (rets == (unsigned long)MAP_FAILED ||
+ rets != (SPARSE_BASE + (Base << 5)))
+ {
+ FatalError("mapVidMemSparse: Could not (sparse) mmap fb (%s)\n",
+ strerror(errno));
+ }
+ }
+
+#if 1
+ if (rets)
+ xf86Msg(X_INFO,"mapVidMemSparse: mapped Base 0x%lx size 0x%lx"
+ " to DENSE at 0x%lx and SPARSE at 0x%lx\n",
+ Base, Size, ret, rets);
+ else
+ xf86Msg(X_INFO,"mapVidMemSparse: mapped Base 0x%lx size 0x%lx"
+ " to DENSE only at 0x%lx\n",
+ Base, Size, ret);
+
+#endif
+ return (pointer) ret;
+}
+
+static void
+unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size)
+{
+ unsigned long Offset = (unsigned long)Base - DENSE_BASE;
+#if 1
+ xf86Msg(X_INFO,"unmapVidMemSparse: unmapping Base 0x%lx Size 0x%lx\n",
+ Base, Size);
+#endif
+ /* Unmap DENSE always. */
+ munmap((caddr_t)Base, Size);
+
+ /* Unmap SPARSE always, and ignore error in case we did not map it. */
+ munmap((caddr_t)(SPARSE_BASE + (Offset << 5)), Size << 5);
+}
+
+static int
+readSparse8(pointer Base, register unsigned long Offset)
+{
+ register unsigned long result, shift;
+ register unsigned long msb;
+
+ mem_barrier();
+ Offset += (unsigned long)Base - DENSE_BASE;
+ shift = (Offset & 0x3) << 3;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
+ }
+
+ mem_barrier();
+ result = *(vuip) (SPARSE_BASE + (Offset << 5));
+ result >>= shift;
+ return 0xffUL & result;
+}
+
+static int
+readSparse16(pointer Base, register unsigned long Offset)
+{
+ register unsigned long result, shift;
+ register unsigned long msb;
+
+ mem_barrier();
+ Offset += (unsigned long)Base - DENSE_BASE;
+ shift = (Offset & 0x2) << 3;
+ if (Offset >= hae_thresh) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
+ }
+
+ mem_barrier();
+ result = *(vuip)(SPARSE_BASE + (Offset<<5) + (1<<(5-2)));
+ result >>= shift;
+ return 0xffffUL & result;
+}
+
+static int
+readSparse32(pointer Base, register unsigned long Offset)
+{
+ /* NOTE: this is really using DENSE. */
+ mem_barrier();
+ return *(vuip)((unsigned long)Base+(Offset));
+}
+
+static void
+writeSparse8(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int b = Value & 0xffU;
+
+ write_mem_barrier();
+ Offset += (unsigned long)Base - DENSE_BASE;
+ if (Offset >= hae_thresh) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
+ }
+
+ write_mem_barrier();
+ *(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101;
+}
+
+static void
+writeSparse16(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int w = Value & 0xffffU;
+
+ write_mem_barrier();
+ Offset += (unsigned long)Base - DENSE_BASE;
+ if (Offset >= hae_thresh) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
+ }
+
+ write_mem_barrier();
+ *(vuip)(SPARSE_BASE + (Offset<<5) + (1<<(5-2))) = w * 0x00010001;
+}
+
+static void
+writeSparse32(int Value, pointer Base, register unsigned long Offset)
+{
+ /* NOTE: this is really using DENSE. */
+ write_mem_barrier();
+ *(vuip)((unsigned long)Base + (Offset)) = Value;
+ return;
+}
+
+static void
+writeSparseNB8(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int b = Value & 0xffU;
+
+ Offset += (unsigned long)Base - DENSE_BASE;
+ if (Offset >= hae_thresh) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
+ }
+ *(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101;
+}
+
+static void
+writeSparseNB16(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int w = Value & 0xffffU;
+
+ Offset += (unsigned long)Base - DENSE_BASE;
+ if (Offset >= hae_thresh) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+ sethae(msb);
+ msb_set = msb;
+ }
+ }
+ *(vuip)(SPARSE_BASE+(Offset<<5)+(1<<(5-2))) = w * 0x00010001;
+}
+
+static void
+writeSparseNB32(int Value, pointer Base, register unsigned long Offset)
+{
+ /* NOTE: this is really using DENSE. */
+ *(vuip)((unsigned long)Base + (Offset)) = Value;
+ return;
+}
+
+void (*xf86WriteMmio8)(int Value, pointer Base, unsigned long Offset)
+ = writeDense8;
+void (*xf86WriteMmio16)(int Value, pointer Base, unsigned long Offset)
+ = writeDense16;
+void (*xf86WriteMmio32)(int Value, pointer Base, unsigned long Offset)
+ = writeDense32;
+void (*xf86WriteMmioNB8)(int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB8;
+void (*xf86WriteMmioNB16)(int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB16;
+void (*xf86WriteMmioNB32)(int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB32;
+int (*xf86ReadMmio8)(pointer Base, unsigned long Offset)
+ = readDense8;
+int (*xf86ReadMmio16)(pointer Base, unsigned long Offset)
+ = readDense16;
+int (*xf86ReadMmio32)(pointer Base, unsigned long Offset)
+ = readDense32;
+
+#ifdef JENSEN_SUPPORT
+
+static int
+readSparseJensen8(pointer Base, register unsigned long Offset);
+static int
+readSparseJensen16(pointer Base, register unsigned long Offset);
+static int
+readSparseJensen32(pointer Base, register unsigned long Offset);
+static void
+writeSparseJensen8(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseJensen16(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseJensen32(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseJensenNB8(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseJensenNB16(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseJensenNB32(int Value, pointer Base, register unsigned long Offset);
+
+/*
+ * The Jensen lacks dense memory, thus we have to address the bus via
+ * the sparse addressing scheme.
+ *
+ * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996
+ */
+
+#ifdef TEST_JENSEN_CODE
+#define SPARSE (5)
+#else
+#define SPARSE (7)
+#endif
+
+#define JENSEN_SHIFT(x) ((long)x<<SPARSE)
+
+static pointer
+mapVidMemJensen(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ pointer base;
+ int fd, prot;
+
+ xf86WriteMmio8 = writeSparseJensen8;
+ xf86WriteMmio16 = writeSparseJensen16;
+ xf86WriteMmio32 = writeSparseJensen32;
+ xf86WriteMmioNB8 = writeSparseJensenNB8;
+ xf86WriteMmioNB16 = writeSparseJensenNB16;
+ xf86WriteMmioNB32 = writeSparseJensenNB32;
+ xf86ReadMmio8 = readSparseJensen8;
+ xf86ReadMmio16 = readSparseJensen16;
+ xf86ReadMmio32 = readSparseJensen32;
+
+ fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
+ if (fd < 0) {
+ FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
+ strerror(errno));
+ }
+
+ if (flags & VIDMEM_READONLY)
+ prot = PROT_READ;
+ else
+ prot = PROT_READ | PROT_WRITE;
+
+ /* This requires linux-0.99.pl10 or above */
+ base = mmap((caddr_t)0, JENSEN_SHIFT(Size),
+ prot, MAP_SHARED, fd,
+ (off_t)(JENSEN_SHIFT((off_t)Base) + _bus_base_sparse()));
+ close(fd);
+ if (base == MAP_FAILED) {
+ FatalError("xf86MapVidMem: Could not mmap framebuffer"
+ " (0x%08x,0x%x) (%s)\n", Base, Size,
+ strerror(errno));
+ }
+ return base;
+}
+
+static void
+unmapVidMemJensen(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap((caddr_t)Base, JENSEN_SHIFT(Size));
+}
+
+static int
+readSparseJensen8(pointer Base, register unsigned long Offset)
+{
+ register unsigned long result, shift;
+
+ mem_barrier();
+ shift = (Offset & 0x3) << 3;
+
+ result = *(vuip) ((unsigned long)Base + (Offset << SPARSE));
+
+ result >>= shift;
+ return 0xffUL & result;
+}
+
+static int
+readSparseJensen16(pointer Base, register unsigned long Offset)
+{
+ register unsigned long result, shift;
+
+ mem_barrier();
+ shift = (Offset & 0x2) << 3;
+
+ result = *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(1<<(SPARSE-2)));
+
+ result >>= shift;
+ return 0xffffUL & result;
+}
+
+static int
+readSparseJensen32(pointer Base, register unsigned long Offset)
+{
+ register unsigned long result;
+
+ mem_barrier();
+ result = *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(3<<(SPARSE-2)));
+
+ return result;
+}
+
+static void
+writeSparseJensen8(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned int b = Value & 0xffU;
+
+ write_mem_barrier();
+ *(vuip) ((unsigned long)Base + (Offset << SPARSE)) = b * 0x01010101;
+}
+
+static void
+writeSparseJensen16(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned int w = Value & 0xffffU;
+
+ write_mem_barrier();
+ *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(1<<(SPARSE-2))) =
+ w * 0x00010001;
+}
+
+static void
+writeSparseJensen32(int Value, pointer Base, register unsigned long Offset)
+{
+ write_mem_barrier();
+ *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(3<<(SPARSE-2))) = Value;
+}
+
+static void
+writeSparseJensenNB8(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned int b = Value & 0xffU;
+
+ *(vuip) ((unsigned long)Base + (Offset << SPARSE)) = b * 0x01010101;
+}
+
+static void
+writeSparseJensenNB16(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned int w = Value & 0xffffU;
+
+ *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(1<<(SPARSE-2))) =
+ w * 0x00010001;
+}
+
+static void
+writeSparseJensenNB32(int Value, pointer Base, register unsigned long Offset)
+{
+ *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(3<<(SPARSE-2))) = Value;
+}
+#endif /* JENSEN_SUPPORT */
+
+#endif /* __alpha__ */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile
new file mode 100644
index 000000000..350856905
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile
@@ -0,0 +1,62 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile,v 3.23 2002/10/17 02:22:46 dawes Exp $
+#include <Server.tmpl>
+
+#if AllowSIGIO
+SIGIO=sigio
+#else
+SIGIO=sigiostubs
+#endif
+
+#if !defined(PpcArchitecture)
+#if HasMTRRSupport
+MTRRDEFINES = -DHAS_MTRR_SUPPORT
+#endif
+IOPERM_SRCS=ioperm_noop.c
+IOPERM_OBJS=ioperm_noop.o
+#endif
+
+#if defined(PpcArchitecture)
+PPC_SRCS=lynx_noinline.c lynx_ppc.c
+PPC_OBJS=lynx_noinline.o lynx_ppc.o
+#endif
+
+MOUSESRC = lynx_mouse.c
+MOUSEOBJ = lynx_mouse.o
+
+SRCS = lynx_init.c lynx_video.c lynx_io.c lynx_mmap.c \
+ VTsw_usl.c std_kbdEv.c posix_tty.c $(MOUSESRC) \
+ $(IOPERM_SRCS) $(PPC_SRCS) libc_wrapper.c stdResource.c stdPci.c \
+ vidmem.c $(SIGIO).c pm_noop.c kmod_noop.c agp_noop.c
+
+OBJS = lynx_init.o lynx_video.o lynx_io.o lynx_mmap.o \
+ VTsw_usl.o std_kbdEv.o posix_tty.o $(MOUSEOBJ) \
+ $(IOPERM_OBJS) $(PPC_OBJS) libc_wrapper.o stdResource.o stdPci.o \
+ vidmem.o $(SIGIO).o pm_noop.o kmod_noop.o agp_noop.o
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(EXTINCSRC) \
+ -I$(ENV_PREFIX)/sys/lynx.os -I$(DRMSRCDIR)/shared-core
+
+RESDEFINES = -DUSESTDRES
+
+DEFINES = $(RESDEFINES) $(MTRRDEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+#if !defined(PpcArchitecture)
+LinkSourceFile(ioperm_noop.c,../shared)
+#endif
+LinkSourceFile(VTsw_usl.c,../shared)
+LinkSourceFile(std_kbdEv.c,../shared)
+LinkSourceFile(posix_tty.c,../shared)
+LinkSourceFile(libc_wrapper.c,../shared)
+LinkSourceFile(stdResource.c,../shared)
+LinkSourceFile(stdPci.c,../shared)
+LinkSourceFile(vidmem.c,../shared)
+LinkSourceFile($(SIGIO).c,../shared)
+LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
+LinkSourceFile(agp_noop.c,../shared)
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_init.c
new file mode 100644
index 000000000..84db50127
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_init.c
@@ -0,0 +1,193 @@
+/*
+ * Copyright 1993 by Thomas Mueller
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_init.c,v 3.2 1998/07/25 16:56:45 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+static int VTnum = -1;
+
+void
+xf86OpenConsole()
+{
+ struct vt_mode VT;
+ char vtname1[11];
+ int fd, pgrp;
+ MessageType from = X_PROBED;
+
+ if (serverGeneration == 1)
+ {
+ /* check if we're run with euid==0 */
+ if (geteuid() != 0)
+ {
+ FatalError("xf86OpenConsole: Server must be suid root\n");
+ }
+
+ /*
+ * setup the virtual terminal manager
+ * NOTE:
+ * We use the out-of-the-box atc terminal driver,
+ * not the GE contributed vdt driver.
+ * Also, we do setup signals for VT switching which
+ * is not really necessary because we don't feed the
+ * VT switch keystrokes to the kernel in xf86Events.c
+ * (it bombs occasionally...)
+ */
+ if (VTnum != -1)
+ {
+ xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
+ }
+ else
+ {
+ /* We could use /dev/con which is usually a symlink
+ * to /dev/atc0 but one could configure the system
+ * to use a serial line as console device, so to
+ * be sure we take /dev/atc0.
+ */
+ if ((fd = open("/dev/atc0",O_WRONLY,0)) < 0)
+ {
+ FatalError(
+ "xf86OpenConsole: Cannot open /dev/atc0 (%s)\n",
+ strerror(errno));
+ }
+ if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
+ (xf86Info.vtno == -1))
+ {
+ FatalError("xf86OpenConsole: Cannot find a free VT\n");
+ }
+ close(fd);
+ }
+ xf86Msg(from, "using VT number %d\n", xf86Info.vtno);
+
+ sprintf(vtname1,"/dev/atc%d",xf86Info.vtno);
+
+ pgrp = getpgrp(); /* POSIX version ! */
+ ioctl(xf86Info.consoleFd, TIOCSPGRP, &pgrp);
+
+ if ((xf86Info.consoleFd = open(vtname1,O_RDWR|O_NDELAY,0)) < 0)
+ {
+ FatalError(
+ "xf86OpenConsole: Cannot open %s (%s)\n",
+ vtname1, strerror(errno));
+ }
+ /* change ownership of the vt */
+ chown(vtname1, getuid(), getgid());
+
+ /*
+ * now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
+ {
+ FatalError("xf86OpenConsole: VT_GETMODE failed\n");
+ }
+
+ /* for future use... */
+ signal(SIGUSR1, xf86VTRequest);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
+ {
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
+ }
+ }
+ else
+ {
+ /* serverGeneration != 1 */
+ /*
+ * now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ /*
+ * If the server doesn't have the VT when the reset occurs,
+ * this is to make sure we don't continue until the activate
+ * signal is received.
+ */
+ if (!xf86Screens[0]->vtSema)
+ sleep(5);
+ }
+ return;
+}
+
+void
+xf86CloseConsole()
+{
+ struct vt_mode VT;
+
+#if 0
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno);
+ ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0);
+#endif
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
+ {
+ VT.mode = VT_AUTO;
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
+ }
+ close(xf86Info.consoleFd); /* make the vt-manager happy */
+ return;
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+ {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
+ {
+ UseMsg();
+ VTnum = -1;
+ return(0);
+ }
+ return(1);
+ }
+ return(0);
+}
+
+void
+xf86UseMsg()
+{
+ ErrorF("vtXX use the specified VT number\n");
+ return;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_io.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_io.c
new file mode 100644
index 000000000..afd3f8962
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_io.c
@@ -0,0 +1,166 @@
+/*
+ * Copyright 1993 by Thomas Mueller
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_io.c,v 3.9 2002/10/11 01:40:35 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#if defined(KDMKTONE) || defined(KIOCSOUND)
+/* Lynx 2.2.1 has sophisticated atc stuff.... */
+void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
+{
+ if (loudness && pitch)
+ {
+#ifdef KDMKTONE
+ /*
+ * If we have KDMKTONE use it to avoid putting the server
+ * to sleep
+ */
+ ioctl(xf86Info.consoleFd, KDMKTONE,
+ (pitch & 0xffff) |
+ (((unsigned long)duration *
+ loudness / 50) << 16));
+#else
+ ioctl(xf86Info.consoleFd, KIOCSOUND, pitch);
+ usleep(xf86Info.bell_duration * loudness * 20);
+ ioctl(xf86Info.consoleFd, KIOCSOUND, 0);
+#endif
+ }
+}
+
+#else
+
+/* this is pulled from /sys/drivers/vt100/atbeep.c */
+
+#define SPEAKER_CONTROL 0x61
+#define TIMER_CONTROL 0x43
+#define TIMER_DATA 0x42
+#define TIMER_LOAD_CMD 0xb6
+
+#define TIMER_CONSTANT 1193280
+#define FREQ_LO(f) ((TIMER_CONSTANT / (f)) % 256)
+#define FREQ_HI(f) ((TIMER_CONSTANT / (f)) / 256)
+
+void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
+{
+ int flo = FREQ_LO(pitch);
+ int fhi = FREQ_HI(pitch);
+
+ outb(TIMER_CONTROL, TIMER_LOAD_CMD);
+ outb(TIMER_DATA, flo);
+ outb(TIMER_DATA, fhi);
+
+ /* speaker on */
+ outb(SPEAKER_CONTROL, inb(SPEAKER_CONTROL) | 3);
+ usleep(xf86Info.bell_duration * loudness * 20);
+ /* speaker off */
+ outb(SPEAKER_CONTROL, inb(SPEAKER_CONTROL) & ~3);
+}
+#endif
+
+void
+xf86SetKbdLeds(int leds)
+{
+#ifdef KBD_SET_LEDS
+ ioctl(xf86Info.consoleFd, KBD_SET_LEDS, &leds);
+#endif
+}
+
+int
+xf86GetKbdLeds()
+{
+#ifdef KBD_SET_LEDS
+ int leds;
+
+ if (ioctl(xf86Info.consoleFd, KBD_SET_LEDS, &leds) < 0)
+ return 0;
+
+ return leds;
+#endif
+ return 0;
+}
+
+void
+xf86SetKbdRepeat(char rad)
+{
+}
+
+static struct termio kbdtty;
+
+void
+xf86KbdInit()
+{
+ ioctl(xf86Info.consoleFd, TCGETA, &kbdtty);
+}
+
+int
+xf86KbdOn()
+{
+ struct termio nTty;
+
+ /* set CAPS_LOCK to behave as CAPS_LOCK not as CTRL */
+ write(xf86Info.consoleFd, "\033<", 2);
+
+ /* enable scan mode */
+ ioctl(xf86Info.consoleFd, TIO_ENSCANMODE, NULL);
+
+ nTty = kbdtty;
+ nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME]=0;
+ nTty.c_cc[VMIN]=1;
+ ioctl(xf86Info.consoleFd, TCSETA, &nTty);
+
+ return(xf86Info.consoleFd);
+}
+
+int
+xf86KbdOff()
+{
+ /* disable scan mode */
+ ioctl(xf86Info.consoleFd, TIO_DISSCANMODE, NULL);
+ ioctl(xf86Info.consoleFd, TCSETA, &kbdtty);
+ return(xf86Info.consoleFd);
+}
+
+#include "xf86OSKbd.h"
+
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+ return FALSE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_mmap.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_mmap.c
new file mode 100644
index 000000000..c00b6700f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_mmap.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright 1993 by Thomas Mueller
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_mmap.c,v 3.5 1998/08/29 05:43:58 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+/*
+ * Read BIOS using smem_create facility
+ */
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+#if defined(__powerpc__)
+ xf86Msg(X_WARNING, "xf86ReadBios: no BIOS-probe on PowerPC\n");
+ return(-1);
+#else
+ char *p;
+ int mlen;
+
+ mlen = (Offset + Len + 4095) & ~4095;
+ p = smem_create("BIOS-probe", (char *)Base, mlen, SM_READ);
+ if (p == NULL)
+ {
+ /* check if there is a stale segment around */
+ if (smem_remove("BIOS-probe") == 0) {
+ xf86Msg(X_INFO,
+ "xf86ReadBios: removed stale smem_ segment\n");
+ p = smem_create("BIOS-probe", (char *)Base, mlen, SM_READ);
+ }
+ if (p == NULL) {
+ xf86Msg(X_WARNING, "xf86ReadBios: Failed to smem_create "
+ "Base %x len %x %s \n",
+ Base, mlen, strerror(errno));
+ return(-1);
+ }
+ }
+ memcpy(Buf, p + Offset, Len);
+ smem_create(NULL, p, 0, SM_DETACH);
+ smem_remove("BIOS-probe");
+ return(Len);
+#endif
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_mouse.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_mouse.c
new file mode 100644
index 000000000..68aca5d38
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_mouse.c
@@ -0,0 +1,34 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_mouse.c,v 1.1 1999/05/22 08:40:14 dawes Exp $ */
+
+/*
+ * Copyright 1999 by The XFree86 Project, Inc.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+
+static int
+SupportedInterfaces(void)
+{
+ /* XXX Need to check this. */
+ return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO;
+}
+
+OSMouseInfoPtr
+xf86OSMouseInit(int flags)
+{
+ OSMouseInfoPtr p;
+
+ p = xcalloc(sizeof(OSMouseInfoRec), 1);
+ if (!p)
+ return NULL;
+ p->SupportedInterfaces = SupportedInterfaces;
+ return p;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_noinline.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_noinline.c
new file mode 100644
index 000000000..1c12f62f9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_noinline.c
@@ -0,0 +1,178 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_noinline.c,v 3.5 2000/07/31 23:25:18 tsi Exp $ */
+/*
+ * Copyright 1998 by Metro Link Incorporated
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#if /* NO_INLINE && */ defined(__powerpc__)
+
+#include "xf86Pci.h"
+
+extern volatile unsigned char *ioBase;
+
+void
+eieio()
+{
+ __asm__ __volatile__ ("eieio");
+}
+
+unsigned long
+ldl_brx(volatile unsigned char *base, int ndx)
+{
+ register unsigned long tmp = *(volatile unsigned long *)(base+ndx);
+ return( ((tmp & 0x000000ff) << 24) |
+ ((tmp & 0x0000ff00) << 8) |
+ ((tmp & 0x00ff0000) >> 8) |
+ ((tmp & 0xff000000) >> 24) );
+}
+
+unsigned short
+ldw_brx(volatile unsigned char *base, int ndx)
+{
+ register unsigned short tmp = *(volatile unsigned short *)(base+ndx);
+ return((tmp << 8) | (tmp >> 8));
+}
+
+void
+stl_brx(unsigned long val, volatile unsigned char *base, int ndx)
+{
+ unsigned char *p = (unsigned char *)&val;
+ unsigned long tmp = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | (p[0] << 0);
+ *(volatile unsigned long *)(base+ndx) = tmp;
+}
+
+void
+stw_brx(unsigned short val, volatile unsigned char *base, int ndx)
+{
+ unsigned char *p = (unsigned char *)&val;
+ unsigned short tmp = (p[1] << 8) | p[0];
+ *(volatile unsigned short *)(base+ndx) = tmp;
+}
+
+void
+outb(IOADDRESS port, unsigned char value)
+{
+ *((volatile unsigned char *)(ioBase + port)) = value; eieio();
+}
+
+void
+outw(IOADDRESS port, unsigned short value)
+{
+ stw_brx(value, ioBase, port); eieio();
+}
+
+void
+outl(IOADDRESS port, unsigned int value)
+{
+ stl_brx(value, ioBase, port); eieio();
+}
+
+unsigned char
+inb(IOADDRESS port)
+{
+ unsigned char val;
+
+ val = *((volatile unsigned char *)(ioBase + port)); eieio();
+ return(val);
+}
+
+unsigned short
+inw(IOADDRESS port)
+{
+ unsigned short val;
+
+ val = ldw_brx(ioBase, port); eieio();
+ return(val);
+}
+
+unsigned int
+inl(IOADDRESS port)
+{
+ unsigned int val;
+
+ val = ldl_brx(ioBase, port); eieio();
+ return(val);
+}
+
+unsigned long
+ldl_u(void *p)
+{
+ return (((*(unsigned char *)(p)) |
+ (*((unsigned char *)(p)+1)<<8) |
+ (*((unsigned char *)(p)+2)<<16) |
+ (*((unsigned char *)(p)+3)<<24)));
+}
+
+unsigned long
+ldq_u(void *p)
+{
+ return ldl_u(p);
+}
+
+unsigned short
+ldw_u(void *p)
+{
+ return(((*(unsigned char *)(p)) |
+ (*((unsigned char *)(p)+1)<<8)));
+}
+
+void
+stl_u(unsigned long v, void *p)
+{
+
+ (*(unsigned char *)(p)) = (v);
+ (*((unsigned char *)(p)+1)) = ((v) >> 8);
+ (*((unsigned char *)(p)+2)) = ((v) >> 16);
+ (*((unsigned char *)(p)+3)) = ((v) >> 24);
+}
+
+void
+stq_u(unsigned long v, void *p)
+{
+ stl_u(v,p);
+}
+
+void
+stw_u(unsigned short v, void *p)
+{
+ (*(unsigned char *)(p)) = (v);
+ (*((unsigned char *)(p)+1)) = ((v) >> 8);
+}
+
+
+void
+mem_barrier(void)
+{
+ __asm__ __volatile__("eieio");
+}
+
+void
+write_mem_barrier(void)
+{
+ __asm__ __volatile__("eieio");
+}
+
+#endif /* NO_INLINE && __powerpc__ */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_ppc.S b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_ppc.S
new file mode 100644
index 000000000..3865850d1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_ppc.S
@@ -0,0 +1,70 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_ppc.S,v 1.1 1999/07/10 07:24:49 dawes Exp $ */
+/*
+ * Copyright 1998 by Metro Link Incorporated
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+ .file "ppc.s"
+.toc
+ .csect .text[PR]
+ .balign 4
+ .globl ppc_flush_icache
+ .globl .ppc_flush_icache
+.csect ppc_flush_icache[DS]
+ppc_flush_icache:
+ .long .ppc_flush_icache, TOC[tc0], 0
+.csect .text[PR]
+.ppc_flush_icache:
+ mflr 0
+ stw 31,-4(1)
+ stw 0,8(1)
+ stwu 1,-64(1)
+ mr 31,1
+ stw 3,88(31)
+ li 6, 0 /* __inst_dcbf (addr, 0); */
+ dcbf 3, 6
+ li 5, 32 /* __inst_dcbf (addr, LINESIZE); */
+ dcbf 3, 5
+ sync /* __inst_sync (); */
+ li 4,0 /* __inst_icbi (addr, 0); */
+ icbi 3,4
+ li 7,32 /* __inst_icbi (addr, LINESIZE); */
+ icbi 3,7
+ sync /* __inst_sync (); */
+ isync /* __inst_isync (); */
+L..1:
+ lwz 1,0(1)
+ lwz 0,8(1)
+ mtlr 0
+ lwz 31,-4(1)
+ blr
+LT..ppc_flush_icache:
+ .long 0
+ .byte 0,0,32,97,128,1,1,1
+ .long 0
+ .long LT..ppc_flush_icache-.ppc_flush_icache
+ .short 16
+ .byte "ppc_flush_icache"
+ .byte 31
+_section_.text:
+ .csect .data[RW]
+ .long _section_.text
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_ppc.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_ppc.c
new file mode 100644
index 000000000..12fa3bcae
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_ppc.c
@@ -0,0 +1,52 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_ppc.S,v 1.1 1999/07/10 07:24:49 dawes Exp $ */
+/*
+ * Copyright 1998 by Metro Link Incorporated
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+void ppc_flush_icache()
+{
+__asm__ __volatile__ (" \
+ mflr 0 ;\
+ stw 31,-4(1) ;\
+ stw 0,8(1) ;\
+ stwu 1,-64(1) ;\
+ mr 31,1 ;\
+ stw 3,88(31) ;\
+ li 6, 0 ;\
+ dcbf 3, 6 ;\
+ li 5, 32 ;\
+ dcbf 3, 5 ;\
+ sync ;\
+ li 4,0 ;\
+ icbi 3,4 ;\
+ li 7,32 ;\
+ icbi 3,7 ;\
+ sync ;\
+ isync ;\
+ lwz 1,0(1) ;\
+ lwz 0,8(1) ;\
+ mtlr 0 ;\
+ lwz 31,-4(1) ;\
+ blr ;\
+");
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c
new file mode 100644
index 000000000..5d0949091
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c
@@ -0,0 +1,711 @@
+/*
+ * Copyright 1993 by Thomas Mueller
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c,v 3.17 2000/10/28 01:42:27 mvojkovi Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#if defined(__powerpc__)
+
+# if defined(USE_MACHINE_ABSOLUTE)
+# include <machine/absolute.h>
+# else
+# define __USER_SPACE_INCLUDE
+# include <hw_absolute.h>
+# endif
+
+void ppcPciIoMap(int bus);
+#endif
+
+#if 0
+#define DEBUG
+#endif
+
+#ifdef HAS_MTRR_SUPPORT
+#include <sys/memrange.h>
+#define X_MTRR_ID "XFree86"
+
+static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType);
+static void undoWC(int, pointer);
+static Bool cleanMTRR(void);
+static int devMemFd = -1;
+#define MTRR_DEVICE "/dev/mtrr"
+#endif
+
+
+#if !defined(NO_MMAP)
+#include <sys/mman.h>
+
+int smem_remove(char *name)
+{
+ return(0);
+}
+
+char *smem_create(char *name, char *arg_addr, long size, int mode)
+{
+ int fd;
+ void *addr = 0;
+ char *retval;
+ size_t len = size;
+ int prot = PROT_READ|PROT_WRITE|PROT_UNCACHE;
+ int flags = MAP_SHARED;
+ off_t off = (off_t)arg_addr;
+
+ if ((fd = open("/dev/mem" , O_RDWR)) < 0)
+ {
+ retval = (char *)-1;
+ }
+ else
+ {
+ if (mode == SM_DETACH)
+ {
+ munmap(arg_addr, len);
+ retval = 0;
+ }
+ else
+ {
+ if ((retval = mmap (addr, len, prot, flags, fd, off) ) == MAP_FAILED)
+ {
+ retval = (char *)-1;
+ }
+ }
+
+ close(fd);
+ }
+
+ return(retval);
+}
+
+#endif
+
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+typedef struct
+{
+ char name[16];
+ unsigned long Base;
+ unsigned long Size;
+ char *ptr;
+ int RefCnt;
+}
+_SMEMS;
+
+#define MAX_SMEMS 16
+
+static _SMEMS smems[MAX_SMEMS];
+
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+static void
+smemCleanup(void)
+{
+ int i;
+
+ for (i = 0; i < MAX_SMEMS; i++) {
+ if (*smems[i].name && smems[i].ptr) {
+ (void)smem_create(NULL, smems[i].ptr, 0, SM_DETACH);
+ (void)smem_remove(smems[i].name);
+ *smems[i].name = '\0';
+ smems[i].ptr = NULL;
+ smems[i].Base = 0;
+ smems[i].Size = 0;
+ smems[i].RefCnt = 0;
+ }
+ }
+}
+
+static pointer
+MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ static int once;
+ int free_slot = -1;
+ int i;
+
+ if (!once)
+ {
+ atexit(smemCleanup);
+ once = 1;
+ }
+ for (i = 0; i < MAX_SMEMS; i++)
+ {
+ if (!*smems[i].name && free_slot == -1)
+ free_slot = i;
+ if (smems[i].Base == Base && smems[i].Size == Size
+ && *smems[i].name) {
+ smems[i].RefCnt++;
+ return smems[i].ptr;
+ }
+ }
+ if (i == MAX_SMEMS && free_slot == -1)
+ {
+ FatalError("MapVidMem: failed to smem_create Base %x Size %x (out of SMEMS entries)\n",
+ Base, Size);
+ }
+
+ i = free_slot;
+ sprintf(smems[i].name, "Video-%d", i);
+ smems[i].Base = Base;
+ smems[i].Size = Size;
+
+ xf86MsgVerb(X_INFO, 3, "MapVidMem: Base=0x%x Size=0x%x\n",
+ Base, Size);
+
+#if defined(__powerpc__)
+ if (((unsigned long)Base & PHYS_IO_MEM_START) != PHYS_IO_MEM_START) {
+ Base = Base | PHYS_IO_MEM_START;
+ }
+#endif
+
+ smems[i].ptr = smem_create(smems[i].name, (char *)Base, Size, SM_READ|SM_WRITE);
+ smems[i].RefCnt = 1;
+ if (smems[i].ptr == NULL)
+ {
+ /* check if there is a stale segment around */
+ if (smem_remove(smems[i].name) == 0) {
+ xf86Msg(X_INFO,
+ "MapVidMem: removed stale smem_ segment %s\n",
+ smems[i].name);
+ smems[i].ptr = smem_create(smems[i].name,
+ (char *)Base, Size, SM_READ|SM_WRITE);
+ }
+ if (smems[i].ptr == NULL) {
+ *smems[i].name = '\0';
+ FatalError("MapVidMem: failed to smem_create Base %x Size %x (%s)\n",
+ Base, Size, strerror(errno));
+ }
+ }
+ xf86MsgVerb(X_INFO, 3, "MapVidMem: Base=0x%x Size=0x%x Ptr=0x%x\n",
+ Base, Size, smems[i].ptr);
+ return smems[i].ptr;
+}
+
+static void
+UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ int i;
+
+ xf86MsgVerb(X_INFO, 3, "UnMapVidMem: Base/Ptr=0x%x Size=0x%x\n",
+ Base, Size);
+ for (i = 0; i < MAX_SMEMS; i++)
+ {
+ if (*smems[i].name && smems[i].ptr == Base
+ && smems[i].Size == Size)
+ {
+ if (--smems[i].RefCnt > 0)
+ return;
+
+ (void)smem_create(NULL, smems[i].ptr, 0, SM_DETACH);
+ xf86MsgVerb(X_INFO, 3,
+ "UnMapVidMem: smem_create(%s, 0x%08x, ... "
+ "SM_DETACH)\n", smems[i].name, smems[i].ptr);
+ (void)smem_remove(smems[i].name);
+ *smems[i].name = '\0';
+ smems[i].RefCnt = 0;
+ return;
+ }
+ }
+ xf86MsgVerb(X_WARNING, 2,
+ "UnMapVidMem: no SMEM found for Base = %lx Size = %lx\n",
+ Base, Size);
+}
+
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->linearSupported = TRUE;
+ pVidMem->mapMem = MapVidMem;
+ pVidMem->unmapMem = UnMapVidMem;
+ pVidMem->setWC = 0;
+ pVidMem->undoWC = 0;
+#ifdef HAS_MTRR_SUPPORT
+ if (cleanMTRR()) {
+ pVidMem->setWC = setWC;
+ pVidMem->undoWC = undoWC;
+ }
+#endif
+ pVidMem->initialised = TRUE;
+}
+
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+Bool
+xf86DisableInterrupts()
+{
+ return(TRUE);
+}
+
+void
+xf86EnableInterrupts()
+{
+ return;
+}
+
+/***************************************************************************/
+/* I/O Permissions section for PowerPC */
+/***************************************************************************/
+
+#if defined(__powerpc__)
+
+volatile unsigned char *ioBase = MAP_FAILED;
+volatile unsigned char *pciConfBase = MAP_FAILED;
+
+static int IOEnabled;
+
+
+static void
+removeIOSmem(void)
+{
+ smem_create(NULL, (char *) ioBase, 0, SM_DETACH);
+ smem_remove("IOBASE");
+ ioBase = MAP_FAILED;
+}
+
+Bool
+xf86EnableIO()
+{
+ if (IOEnabled++ == 0) {
+ ioBase = (unsigned char *) smem_create("IOBASE",
+ (char *)PHYS_ISA_IO_SPACE, 64*1024, SM_READ|SM_WRITE);
+ if (ioBase == MAP_FAILED) {
+ --IOEnabled;
+ xf86Msg(X_WARNING,"xf86EnableIO: Failed to map I/O\n");
+ return FALSE;
+ } else {
+#ifdef DEBUG
+ ErrorF("xf86EnableIO: mapped I/O at vaddr 0x%08x\n",
+ ioBase);
+#endif
+ atexit(removeIOSmem);
+ }
+ }
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ if (!IOEnabled)
+ return;
+
+ if (--IOEnabled == 0)
+ removeIOSmem();
+ return;
+}
+
+#if 0
+void
+xf86DisableIOPrivs(void)
+{
+ return;
+}
+#endif
+void
+ppcPciIoMap(int bus)
+{
+ xf86EnableIO();
+}
+
+#endif
+
+
+#ifdef HAS_MTRR_SUPPORT
+/* memory range (MTRR) support for LynxOS (taken from BSD MTRR support) */
+
+/*
+ * This code is experimental. Some parts may be overkill, and other parts
+ * may be incomplete.
+ */
+
+/*
+ * getAllRanges returns the full list of memory ranges with attributes set.
+ */
+
+static struct mem_range_desc *
+getAllRanges(int *nmr)
+{
+ struct mem_range_desc *mrd;
+ struct mem_range_op mro;
+
+ /*
+ * Find how many ranges there are. If this fails, then the kernel
+ * probably doesn't have MTRR support.
+ */
+ mro.mo_arg[0] = 0;
+ if (ioctl(devMemFd, MEMRANGE_GET, &mro))
+ return NULL;
+ *nmr = mro.mo_arg[0];
+ mrd = xnfalloc(*nmr * sizeof(struct mem_range_desc));
+ mro.mo_arg[0] = *nmr;
+ mro.mo_desc = mrd;
+ if (ioctl(devMemFd, MEMRANGE_GET, &mro)) {
+ xfree(mrd);
+ return NULL;
+ }
+ return mrd;
+}
+
+/*
+ * cleanMTRR removes any memory attribute that may be left by a previous
+ * X server. Normally there won't be any, but this takes care of the
+ * case where a server crashed without being able finish cleaning up.
+ */
+
+static Bool
+cleanMTRR()
+{
+ struct mem_range_desc *mrd;
+ struct mem_range_op mro;
+ int nmr, i;
+
+ /* This shouldn't happen */
+ if (devMemFd < 0) {
+ if ((devMemFd = open(MTRR_DEVICE, O_RDONLY)) < 0) {
+perror("open MTRR");
+ return FALSE;
+ }
+ }
+
+ if (!(mrd = getAllRanges(&nmr)))
+ return FALSE;
+
+ for (i = 0; i < nmr; i++) {
+ if (strcmp(mrd[i].mr_owner, X_MTRR_ID) == 0 &&
+ (mrd[i].mr_flags & MDF_ACTIVE)) {
+#ifdef DEBUG
+ ErrorF("Clean for (0x%lx,0x%lx)\n",
+ (unsigned long)mrd[i].mr_base,
+ (unsigned long)mrd[i].mr_len);
+#endif
+ if (mrd[i].mr_flags & MDF_FIXACTIVE) {
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ mrd[i].mr_flags = MDF_UNCACHEABLE;
+ } else {
+ mro.mo_arg[0] = MEMRANGE_SET_REMOVE;
+ }
+ mro.mo_desc = mrd + i;
+ ioctl(devMemFd, MEMRANGE_SET, &mro);
+ }
+ }
+#ifdef DEBUG
+ sleep(10);
+#endif
+ xfree(mrd);
+ return TRUE;
+}
+
+typedef struct x_RangeRec {
+ struct mem_range_desc mrd;
+ Bool wasWC;
+ struct x_RangeRec * next;
+} RangeRec, *RangePtr;
+
+static void
+freeRangeList(RangePtr range)
+{
+ RangePtr rp;
+
+ while (range) {
+ rp = range;
+ range = rp->next;
+ xfree(rp);
+ }
+}
+
+static RangePtr
+dupRangeList(RangePtr list)
+{
+ RangePtr new = NULL, rp, p;
+
+ rp = list;
+ while (rp) {
+ p = xnfalloc(sizeof(RangeRec));
+ *p = *rp;
+ p->next = new;
+ new = p;
+ rp = rp->next;
+ }
+ return new;
+}
+
+static RangePtr
+sortRangeList(RangePtr list)
+{
+ RangePtr rp1, rp2, copy, sorted = NULL, minp, prev, minprev;
+ unsigned long minBase;
+
+ /* Sort by base address */
+ rp1 = copy = dupRangeList(list);
+ while (rp1) {
+ minBase = rp1->mrd.mr_base;
+ minp = rp1;
+ minprev = NULL;
+ prev = rp1;
+ rp2 = rp1->next;
+ while (rp2) {
+ if (rp2->mrd.mr_base < minBase) {
+ minBase = rp2->mrd.mr_base;
+ minp = rp2;
+ minprev = prev;
+ }
+ prev = rp2;
+ rp2 = rp2->next;
+ }
+ if (minprev) {
+ minprev->next = minp->next;
+ rp1 = copy;
+ } else {
+ rp1 = minp->next;
+ }
+ minp->next = sorted;
+ sorted = minp;
+ }
+ return sorted;
+}
+
+/*
+ * findRanges returns a list of ranges that overlap the specified range.
+ */
+
+static void
+findRanges(unsigned long base, unsigned long size, RangePtr *ucp, RangePtr *wcp)
+{
+ struct mem_range_desc *mrd;
+ int nmr, i;
+ RangePtr rp, *p;
+
+ if (!(mrd = getAllRanges(&nmr)))
+ return;
+
+ for (i = 0; i < nmr; i++) {
+ if ((mrd[i].mr_flags & MDF_ACTIVE) &&
+ mrd[i].mr_base < base + size &&
+ mrd[i].mr_base + mrd[i].mr_len > base) {
+ if (mrd[i].mr_flags & MDF_WRITECOMBINE)
+ p = wcp;
+ else if (mrd[i].mr_flags & MDF_UNCACHEABLE)
+ p = ucp;
+ else
+ continue;
+ rp = xnfalloc(sizeof(RangeRec));
+ rp->mrd = mrd[i];
+ rp->next = *p;
+ *p = rp;
+ }
+ }
+ xfree(mrd);
+}
+
+/*
+ * This checks if the existing overlapping ranges fully cover the requested
+ * range. Is this overkill?
+ */
+
+static Bool
+fullCoverage(unsigned long base, unsigned long size, RangePtr overlap)
+{
+ RangePtr rp1, sorted = NULL;
+ unsigned long end;
+
+ sorted = sortRangeList(overlap);
+ /* Look for gaps */
+ rp1 = sorted;
+ end = base + size;
+ while (rp1) {
+ if (rp1->mrd.mr_base > base) {
+ freeRangeList(sorted);
+ return FALSE;
+ } else {
+ base = rp1->mrd.mr_base + rp1->mrd.mr_len;
+ }
+ if (base >= end) {
+ freeRangeList(sorted);
+ return TRUE;
+ }
+ rp1 = rp1->next;
+ }
+ freeRangeList(sorted);
+ return FALSE;
+}
+
+static pointer
+addWC(int screenNum, unsigned long base, unsigned long size, MessageType from)
+{
+ RangePtr uc = NULL, wc = NULL, retlist = NULL;
+ struct mem_range_desc mrd;
+ struct mem_range_op mro;
+
+ findRanges(base, size, &uc, &wc);
+
+ /* See of the full range is already WC */
+ if (!uc && fullCoverage(base, size, wc)) {
+ xf86DrvMsg(screenNum, from,
+ "Write-combining range (0x%lx,0x%lx) was already set\n",
+ base, size);
+ return NULL;
+ }
+
+ /* Otherwise, try to add the new range */
+ mrd.mr_base = base;
+ mrd.mr_len = size;
+ strcpy(mrd.mr_owner, X_MTRR_ID);
+ mrd.mr_flags = MDF_WRITECOMBINE;
+ mro.mo_desc = &mrd;
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "Failed to set write-combining range "
+ "(0x%lx,0x%lx)\n", base, size);
+ return NULL;
+ } else {
+ xf86DrvMsg(screenNum, from,
+ "Write-combining range (0x%lx,0x%lx)\n", base, size);
+ retlist = xnfalloc(sizeof(RangeRec));
+ retlist->mrd = mrd;
+ retlist->wasWC = FALSE;
+ retlist->next = NULL;
+ return retlist;
+ }
+}
+
+static pointer
+delWC(int screenNum, unsigned long base, unsigned long size, MessageType from)
+{
+ RangePtr uc = NULL, wc = NULL, retlist = NULL;
+ struct mem_range_desc mrd;
+ struct mem_range_op mro;
+
+ findRanges(base, size, &uc, &wc);
+
+ /*
+ * See of the full range is already not WC, or if there is full
+ * coverage from UC ranges.
+ */
+ if (!wc || fullCoverage(base, size, uc)) {
+ xf86DrvMsg(screenNum, from,
+ "Write-combining range (0x%lx,0x%lx) was already clear\n",
+ base, size);
+ return NULL;
+ }
+
+ /* Otherwise, try to add the new range */
+ mrd.mr_base = base;
+ mrd.mr_len = size;
+ strcpy(mrd.mr_owner, X_MTRR_ID);
+ mrd.mr_flags = MDF_UNCACHEABLE;
+ mro.mo_desc = &mrd;
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "Failed to remove write-combining range "
+ "(0x%lx,0x%lx)\n", base, size);
+ /* XXX Should then remove all of the overlapping WC ranges */
+ return NULL;
+ } else {
+ xf86DrvMsg(screenNum, from,
+ "Removed Write-combining range (0x%lx,0x%lx)\n",
+ base, size);
+ retlist = xnfalloc(sizeof(RangeRec));
+ retlist->mrd = mrd;
+ retlist->wasWC = TRUE;
+ retlist->next = NULL;
+ return retlist;
+ }
+}
+
+static pointer
+setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
+ MessageType from)
+{
+ if (enable)
+ return addWC(screenNum, base, size, from);
+ else
+ return delWC(screenNum, base, size, from);
+}
+
+static void
+undoWC(int screenNum, pointer list)
+{
+ RangePtr rp;
+ struct mem_range_op mro;
+ Bool failed;
+
+ rp = list;
+ while (rp) {
+#ifdef DEBUG
+ ErrorF("Undo for (0x%lx,0x%lx), %d\n",
+ (unsigned long)rp->mrd.mr_base,
+ (unsigned long)rp->mrd.mr_len, rp->wasWC);
+#endif
+ failed = FALSE;
+ if (rp->wasWC) {
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ rp->mrd.mr_flags = MDF_WRITECOMBINE;
+ strcpy(rp->mrd.mr_owner, "unknown");
+ } else {
+ mro.mo_arg[0] = MEMRANGE_SET_REMOVE;
+ }
+ mro.mo_desc = &rp->mrd;
+
+ if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
+ if (!rp->wasWC) {
+ mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
+ rp->mrd.mr_flags = MDF_UNCACHEABLE;
+ strcpy(rp->mrd.mr_owner, "unknown");
+ if (ioctl(devMemFd, MEMRANGE_SET, &mro))
+ failed = TRUE;
+ } else
+ failed = TRUE;
+ }
+ if (failed) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "Failed to restore MTRR range (0x%lx,0x%lx)\n",
+ (unsigned long)rp->mrd.mr_base,
+ (unsigned long)rp->mrd.mr_len);
+ }
+ rp = rp->next;
+ }
+}
+
+#endif /* HAS_MTRR_SUPPORT */
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/BUSmemcpy.S b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/BUSmemcpy.S
new file mode 100644
index 000000000..373723c7d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/BUSmemcpy.S
@@ -0,0 +1,153 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/BUSmemcpy.s,v 1.2 1998/07/25 16:56:49 dawes Exp $ */
+/******************************************************************************
+ Copyright 1993 by Glenn G. Lai
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Glenn G. Lai not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+Glenn G. Lai DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+Glenn G. Lai
+P.O. Box 4314
+Austin, Tx 78765
+(glenn@cs.utexas.edu)
+8/9/93
+******************************************************************************/
+/* $XConsortium: BUSmemcpy.s /main/4 1996/02/21 17:39:34 kaleb $ */
+
+/*
+ * Modified to use long-alignment of video memory rather than word-alignment
+ * to improve performance for LocalBus video cards. Function names changed
+ * from ISAToMem and MemToISA to BusToMem and MemToBus.
+ *
+ * David Dawes <dawes@XFree86.org>, 25 August 1993.
+ */
+
+
+#include "assyntax.h"
+
+ FILE("BUSmemcpy.s")
+
+ AS_BEGIN
+
+/* BusToMem copies from video memory to main memory
+ MemToBus copies from main memory to video memory
+
+ void xf86BusToMem(unsigned char *dst, unsigned char *src, int len);
+ void xf86MemToBus(unsigned char *dst, unsigned char *src, int len);
+*/
+
+#define dst REGOFF(4,ESP)
+#define src REGOFF(8,ESP)
+#define len REGOFF(12,ESP)
+
+ GLOBL GLNAME(xf86BusToMem)
+ GLOBL GLNAME(xf86MemToBus)
+
+ SEG_DATA
+copyright:
+ STRING("Copyright 8/9/1993 by Glenn G. Lai")
+
+ SEG_TEXT
+ ALIGNTEXT4
+GLNAME(xf86BusToMem):
+ CLD
+ PUSH_L (ESI)
+ MOV_L (EDI, EDX)
+
+ MOV_L (src, ESI)
+ MOV_L (dst, EDI)
+ MOV_L (len, ECX)
+
+ CMP_L (CONST(7), ECX)
+ JC (quickBM)
+
+ TEST_L (CONST(1), ESI)
+ JZ (BwM)
+
+ MOVS_B
+ DEC_L (ECX)
+
+BwM:
+ TEST_L (CONST(2), ESI)
+ JZ (BlM)
+
+ MOVS_W
+ DEC_L (ECX)
+ DEC_L (ECX)
+
+BlM:
+ MOV_L (ECX, EAX)
+ AND_L (CONST(3), EAX)
+ SHR_L (CONST(2), ECX)
+ REP
+ MOVS_L
+ MOV_L (EAX, ECX)
+quickBM:
+ OR_L (ECX, ECX)
+ JZ (return)
+ REP
+ MOVS_B
+return:
+ POP_L (ESI)
+ MOV_L (EDX, EDI)
+ RET
+/************************/
+
+ ALIGNTEXT4
+GLNAME(xf86MemToBus):
+ CLD
+ PUSH_L (ESI)
+ MOV_L (EDI, EDX)
+
+ MOV_L (src, ESI)
+ MOV_L (dst, EDI)
+ MOV_L (len, ECX)
+
+ CMP_L (CONST(7), ECX)
+ JC (quickMB)
+
+ TEST_L (CONST(1), EDI)
+ JZ (MwB)
+
+ MOVS_B
+ DEC_L (ECX)
+
+MwB:
+ TEST_L (CONST(2), EDI)
+ JZ (MlB)
+
+ MOVS_W
+ DEC_L (ECX)
+ DEC_L (ECX)
+
+MlB:
+ MOV_L (ECX, EAX)
+ AND_L (CONST(3), EAX)
+ SHR_L (CONST(2), ECX)
+ REP
+ MOVS_L
+ MOV_L (EAX, ECX)
+quickMB:
+ OR_L (ECX, ECX)
+ JZ (return)
+ REP
+ MOVS_B
+
+ POP_L (ESI)
+ MOV_L (EDX, EDI)
+ RET
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/BUSmemcpy.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/BUSmemcpy.c
new file mode 100644
index 000000000..9ff14396c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/BUSmemcpy.c
@@ -0,0 +1,413 @@
+
+/****************************************************************************
+
+ For Alpha Linux, BusToMem() and MemToBus() can be simply memcpy(), BUT:
+ we need to prevent unaligned operations when accessing DENSE space on the BUS,
+ as the video memory is mmap'd that way. The below code does this.
+
+NOTE: we could simply use the "memcpy()" from LIBC here, but that, currently, is
+ not as fast.
+
+Thanks to Linus Torvalds for contributing this code.
+
+****************************************************************************/
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/BUSmemcpy.c,v 1.3 1999/12/03 19:17:44 eich Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#ifdef __alpha__
+
+#include "compiler.h"
+
+/*
+ * The Jensen lacks dense memory, thus we have to address the bus via
+ * the sparse addressing scheme. These routines are only used in s3im.c
+ * Non time critical code uses SlowBCopy_{from/to} bus.
+ *
+ * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996
+ */
+
+#ifdef TEST_JENSEN_CODE /* define to test the Sparse addressing on a non-Jensen */
+#define LWORD_CODING (0x18)
+#define SPARSE (5)
+#else
+#define LWORD_CODING (0x60)
+#define SPARSE (7)
+#endif
+
+void
+xf86JensenMemToBus(char *Base, long dst, long src, int count)
+{
+ if( ((long)src^((long)dst)) & 3) {
+ /* src & dst are NOT aligned to each other */
+ unsigned long addr;
+ unsigned long low_word, high_word,last_read;
+ long rm,loop;
+ unsigned long tmp,org,org2,mask,src_org,count_org;
+
+ src_org=src;
+ count_org=count;
+
+ /* add EISA longword coding and round off*/
+ addr = (long)(Base+(dst<<SPARSE) + LWORD_CODING) & ~(3<<SPARSE);
+ rm = (long)dst & 3;
+ count += rm;
+
+ count = count_org + rm;
+ org = *(volatile unsigned int *)addr;
+ __asm__("ldq_u %0,%1"
+ :"=r" (low_word):"m" (*(unsigned long *)(src_org)));
+ src = src_org - rm;
+ if( count > 4 ) {
+ last_read = src_org+count_org - 1;
+ __asm__("ldq_u %0,%1"
+ :"=r" (high_word):"m" (*(unsigned long *)(src+4)));
+ __asm__("extll %1,%2,%0"
+ :"=r" (low_word)
+ :"r" (low_word), "r" ((unsigned long)(src)));
+ __asm__("extlh %1,%2,%0"
+ :"=r" (tmp)
+ :"r" (high_word), "r" ((unsigned long)(src)));
+ tmp |= low_word;
+ src += 4;
+ __asm__("mskqh %1,%2,%0"
+ :"=r" (tmp)
+ :"r" (tmp), "r" (rm));
+ __asm__("mskql %1,%2,%0"
+ :"=r" (org2)
+ :"r" (org), "r" (rm));
+ tmp |= org2;
+
+ loop = (count-4) >> 2; /* loop eqv. count>=4 ; count -= 4 */
+ while (loop) {
+ /* tmp to be stored completly -- need to read next word*/
+ low_word = high_word;
+ *(volatile unsigned int *) (addr) = tmp;
+ __asm__("ldq_u %0,%1"
+ :"=r" (high_word):"m" (*(unsigned long*)(src+4)));
+ loop --;
+ __asm__("extll %1,%2,%0"
+ :"=r" (low_word)
+ :"r" (low_word), "r" ((unsigned long)src));
+ __asm__("extlh %1,%2,%0"
+ :"=r" (tmp)
+ :"r" (high_word), "r" ((unsigned long)src));
+ src += 4;
+ tmp |= low_word;
+ addr += 4<<SPARSE;
+ }
+ if ( count & 3 ) {
+ /* Store tmp completly, and possibly read one more word.*/
+ *(volatile unsigned int *) (addr) = tmp;
+ __asm__("ldq_u %0,%1"
+ :"=r" (tmp):"m" (*((unsigned long *)(last_read)) ));
+ addr += 4<<SPARSE;
+ __asm__("extll %1,%2,%0"
+ :"=r" (low_word)
+ :"r" (high_word), "r" ((unsigned long)src));
+ __asm__("extlh %1,%2,%0"
+ :"=r" (tmp)
+ :"r" (tmp), "r" ((unsigned long)src));
+ tmp |= low_word;
+ org = *(volatile unsigned int *)addr;
+
+ __asm__("mskql %1,%2,%0"
+ :"=r" (tmp)
+ :"r" (tmp), "r" (count&3));
+ __asm__("mskqh %1,%2,%0"
+ :"=r" (org)
+ :"r" (org), "r" (count&3));
+
+ tmp |= org;
+ }
+ *(volatile unsigned int *) (addr) = tmp;
+ return;
+ } else { /* count > 4 */
+ __asm__("ldq_u %0,%1"
+ :"=r" (high_word):"m" (*(unsigned long *)(src+4)));
+ __asm__("extll %1,%2,%0"
+ :"=r" (low_word)
+ :"r" (low_word), "r" ((unsigned long)(src)));
+ __asm__("extlh %1,%2,%0"
+ :"=r" (tmp)
+ :"r" (high_word), "r" ((unsigned long)(src)));
+ tmp |= low_word;
+ if( count < 4 ) {
+
+ mask = -1;
+ __asm__("mskqh %1,%2,%0"
+ :"=r" (mask)
+ :"r" (mask), "r" (rm));
+ __asm__("mskql %1,%2,%0"
+ :"=r" (mask)
+ :"r" (mask), "r" (count));
+ tmp = (tmp & mask) | (org & ~mask);
+ *(volatile unsigned int *) (addr) = tmp;
+ return;
+ } else {
+ __asm__("mskqh %1,%2,%0"
+ :"=r" (tmp)
+ :"r" (tmp), "r" (rm));
+ __asm__("mskql %1,%2,%0"
+ :"=r" (org2)
+ :"r" (org), "r" (rm));
+
+ tmp |= org2;
+ *(volatile unsigned int *) (addr) = tmp;
+ return;
+ }
+ }
+ } else { /* src & dst are aligned to each other */
+ unsigned long addr;
+ unsigned int tmp,org,rm;
+ unsigned int *src_r;
+
+ /* add EISA longword coding and round off*/
+ addr = (long)(Base+(dst<<SPARSE) + LWORD_CODING) & ~(3<<SPARSE);
+
+ src_r = (unsigned int*)((long)src & ~3L);
+ rm=(long)src & 3;
+ count += rm;
+
+ tmp = *src_r;
+ org = *(volatile unsigned int *)addr;
+
+ __asm__("mskqh %1,%2,%0"
+ :"=r" (tmp)
+ :"r" (tmp), "r" (rm));
+ __asm__("mskql %1,%2,%0"
+ :"=r" (org)
+ :"r" (org), "r" (rm));
+
+ tmp |= org;
+
+ while (count > 4) {
+ *(volatile unsigned int *) addr = tmp;
+ addr += 4<<SPARSE;
+ src_r += 1;
+ tmp = *src_r;
+ count -= 4;
+ }
+
+ org = *(volatile unsigned int *)addr;
+ __asm__("mskql %1,%2,%0"
+ :"=r" (tmp)
+ :"r" (tmp), "r" (count));
+ __asm__("mskqh %1,%2,%0"
+ :"=r" (org)
+ :"r" (org), "r" (count));
+ tmp |= org;
+ *(volatile unsigned int *) (addr) = tmp;
+ }
+}
+
+void
+xf86JensenBusToMem(char *Base, char *dst, unsigned long src, int count)
+{
+#if 0
+ /* Optimization of BusToMem() is left as an exercise to the reader ;-)
+ * Consider that ldq_u/extlh/extll won't work because of the bus being
+ * only 4 bytes wide!
+ */
+#else
+ unsigned long addr;
+ long result;
+
+ addr = (unsigned long)(Base+(src<<SPARSE)) ;
+ while( addr & (3<<SPARSE) ){
+ if(count <= 0) return;
+ result = *(volatile int *) addr;
+ result >>= ((addr>>SPARSE) & 3) * 8;
+ *dst++ = (char) result;
+ addr += 1<<SPARSE;
+ count--;
+ }
+ count -=4;
+ while(count >= 0){
+ int i;
+
+ result = *(volatile int *) (addr+LWORD_CODING);
+ for(i=4;i--;) {
+ *dst++ = (char) result;
+ result >>= 8;
+ }
+ addr += 4<<SPARSE;
+ count -= 4;
+ }
+ count +=4;
+
+ while( count ){
+ result = *(volatile int *) addr;
+ result >>= ((addr>>SPARSE) & 3) * 8;
+ *dst++ = (char) result;
+ addr += 1<<SPARSE;
+ count--;
+ }
+#endif
+}
+
+
+static unsigned long __memcpy(unsigned long dest, unsigned long src, int n);
+
+void
+xf86BusToMem(unsigned char *dst, unsigned char *src, int len)
+{
+ __memcpy((unsigned long)dst, (unsigned long)src, len);
+}
+void
+xf86MemToBus(unsigned char *dst, unsigned char *src, int len)
+{
+ if (len == sizeof(int))
+ if (!(((long)src | (long)dst) & 3))
+ *((unsigned int*)dst) = *((unsigned int*)(src));
+ else {
+ int i;
+ if (((long)src) & 3)
+ i = ldl_u((unsigned int*)src);
+ else
+ i = *(unsigned int*)src;
+ if (((long)dst) & 3)
+ stl_u(i,(unsigned int*)dst);
+ else
+ *(unsigned int*)dst = i;
+ }
+ else
+ __memcpy((unsigned long)dst, (unsigned long)src, len);
+}
+
+/*
+ * linux/arch/alpha/lib/memcpy.c
+ *
+ * Copyright (C) 1995 Linus Torvalds, used with his permission.
+ */
+
+/*
+ * This is a reasonably optimized memcpy() routine.
+ */
+
+/*
+ * Note that the C code is written to be optimized into good assembly. However,
+ * at this point gcc is unable to sanely compile "if (n >= 0)", resulting in a
+ * explicit compare against 0 (instead of just using the proper "blt reg, xx" or
+ * "bge reg, xx"). I hope alpha-gcc will be fixed to notice this eventually..
+ */
+
+/*
+ * This should be done in one go with ldq_u*2/mask/stq_u. Do it
+ * with a macro so that we can fix it up later..
+ */
+#define ALIGN_DEST_TO8(d,s,n) \
+ while (d & 7) { \
+ if (n <= 0) return; \
+ n--; \
+ *(char *) d = *(char *) s; \
+ d++; s++; \
+ }
+
+/*
+ * This should similarly be done with ldq_u*2/mask/stq. The destination
+ * is aligned, but we don't fill in a full quad-word
+ */
+#define DO_REST(d,s,n) \
+ while (n > 0) { \
+ n--; \
+ *(char *) d = *(char *) s; \
+ d++; s++; \
+ }
+
+/*
+ * This should be done with ldq/mask/stq. The source and destination are
+ * aligned, but we don't fill in a full quad-word
+ */
+#define DO_REST_ALIGNED(d,s,n) DO_REST(d,s,n)
+
+/*
+ * This does unaligned memory copies. We want to avoid storing to
+ * an unaligned address, as that would do a read-modify-write cycle.
+ * We also want to avoid double-reading the unaligned reads.
+ *
+ * Note the ordering to try to avoid load (and address generation) latencies.
+ */
+static __inline__ void __memcpy_unaligned(unsigned long d, unsigned long s, long n)
+{
+ ALIGN_DEST_TO8(d,s,n);
+ n -= 8; /* to avoid compare against 8 in the loop */
+ if (n >= 0) {
+ unsigned long low_word, high_word;
+ __asm__("ldq_u %0,%1":"=r" (low_word):"m" (*(unsigned long *) s));
+ do {
+ unsigned long tmp;
+ __asm__("ldq_u %0,%1":"=r" (high_word):"m" (*(unsigned long *)(s+8)));
+ n -= 8;
+ __asm__("extql %1,%2,%0"
+ :"=r" (low_word)
+ :"r" (low_word), "r" (s));
+ __asm__("extqh %1,%2,%0"
+ :"=r" (tmp)
+ :"r" (high_word), "r" (s));
+ s += 8;
+ *(unsigned long *) d = low_word | tmp;
+ d += 8;
+ low_word = high_word;
+ } while (n >= 0);
+ }
+ n += 8;
+ DO_REST(d,s,n);
+}
+
+/*
+ * Hmm.. Strange. The __asm__ here is there to make gcc use a integer register
+ * for the load-store. I don't know why, but it would seem that using a floating
+ * point register for the move seems to slow things down (very small difference,
+ * though).
+ *
+ * Note the ordering to try to avoid load (and address generation) latencies.
+ */
+static __inline__ void __memcpy_aligned(unsigned long d, unsigned long s, long n)
+{
+ ALIGN_DEST_TO8(d,s,n);
+ n -= 8;
+ while (n >= 0) {
+ unsigned long tmp;
+ __asm__("ldq %0,%1":"=r" (tmp):"m" (*(unsigned long *) s));
+ n -= 8;
+ s += 8;
+ *(unsigned long *) d = tmp;
+ d += 8;
+ }
+ n += 8;
+ DO_REST_ALIGNED(d,s,n);
+}
+
+static unsigned long __memcpy(unsigned long dest, unsigned long src, int n)
+{
+ if (!((dest ^ src) & 7)) {
+ __memcpy_aligned(dest, src, n);
+ return dest;
+ }
+ __memcpy_unaligned(dest, src, n);
+ return dest;
+}
+
+#else /* __alpha__ */
+
+void
+xf86BusToMem(unsigned char *dst, unsigned char *src, int len)
+{
+ memcpy(dst, src, len);
+}
+void
+xf86MemToBus(unsigned char *dst, unsigned char *src, int len)
+{
+ memcpy(dst, src, len);
+}
+
+#endif /* __alpha__ */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/Delay.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/Delay.c
new file mode 100644
index 000000000..33d0789fd
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/Delay.c
@@ -0,0 +1,44 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/Delay.c,v 3.3 2000/12/08 20:13:38 eich Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define I_NEED_OS2_H
+#endif
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include <time.h>
+
+void
+xf86UDelay(long usec)
+{
+#if 0
+ struct timeval start, interrupt;
+#else
+ int sigio;
+
+ sigio = xf86BlockSIGIO();
+ xf86usleep(usec);
+ xf86UnblockSIGIO(sigio);
+#endif
+
+#if 0
+ gettimeofday(&start,NULL);
+
+ do {
+ usleep(usec);
+ gettimeofday(&interrupt,NULL);
+
+ if ((usec = usec - (interrupt.tv_sec - start.tv_sec) * 1000000
+ - (interrupt.tv_usec - start.tv_usec)) < 0)
+ break;
+ start = interrupt;
+ } while (1);
+#endif
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/IODelay.S b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/IODelay.S
new file mode 100644
index 000000000..685584653
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/IODelay.S
@@ -0,0 +1,53 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/IODelay.s,v 1.2 1998/07/25 16:56:49 dawes Exp $ */
+/*******************************************************************************
+ Copyright 1994 by Glenn G. Lai
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyr notice appear in all copies and that
+both that copyr notice and this permission notice appear in
+supporting documentation, and that the name of Glenn G. Lai not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+Glenn G. Lai DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+Glenn G. Lai
+P.O. Box 4314
+Austin, Tx 78765
+glenn@cs.utexas.edu)
+7/21/94
+*******************************************************************************/
+/* $XConsortium: IODelay.s /main/4 1996/02/21 17:40:21 kaleb $ */
+
+/*
+ * All we really need is a delay of about 40ns for I/O recovery for just
+ * about any occasion, but we'll be more conservative here: On a
+ * 100-MHz CPU, produce at least a delay of 1,000ns.
+ */
+
+#include "assyntax.h"
+
+ FILE("DACDelay.s")
+
+ AS_BEGIN
+
+ GLOBL GLNAME(xf86IODelay)
+
+ SEG_TEXT
+ ALIGNTEXT4
+GLNAME(xf86IODelay):
+ MOV_L (CONST(100), EAX)
+delay_it:
+ DEC_L (EAX)
+ JNE (delay_it)
+ RET
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/IODelay.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/IODelay.c
new file mode 100644
index 000000000..697c07f61
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/IODelay.c
@@ -0,0 +1,28 @@
+
+/* $XConsortium: IODelay.c /main/1 1996/05/07 17:13:43 kaleb $ */
+/*******************************************************************************
+ Stub for Alpha Linux
+*******************************************************************************/
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/IODelay.c,v 1.1.2.1 1998/06/04 17:35:59 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+/*
+ * All we really need is a delay of about 40ns for I/O recovery for just
+ * about any occasion, but we'll be more conservative here: On a
+ * 100-MHz CPU, produce at least a delay of 1,000ns.
+ */
+void
+xf86IODelay()
+{
+ xf86UDelay(1);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/Imakefile
new file mode 100644
index 000000000..d6122f52a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/Imakefile
@@ -0,0 +1,54 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/Imakefile,v 3.13 2003/12/30 15:21:06 herrb Exp $
+XCOMM $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/misc/Imakefile,v 1.2 2004/04/23 19:54:11 eich Exp $
+
+
+
+XCOMM $XConsortium: Imakefile /main/4 1996/09/28 17:24:12 rws $
+
+#include <Server.tmpl>
+
+
+#if defined(i386Architecture) && !defined(cygwinArchitecture) \
+ && !defined(OS2Architecture)
+XSRCS = BUSmemcpy.S IODelay.S SlowBcopy.S
+XOBJS = BUSmemcpy.o IODelay.o SlowBcopy.o
+#else
+XSRCS = BUSmemcpy.c IODelay.c SlowBcopy.c
+XOBJS = BUSmemcpy.o IODelay.o SlowBcopy.o
+#if defined(NetBSDArchitecture)
+BUSmemcpy.o: BUSmemcpy.c
+IODelay.o: IODelay.c
+SlowBcopy.o: SlowBcopy.c
+#endif
+#endif
+
+#if HasGcc || HasGcc2
+ILHACKSRCS = xf86_IlHack.c
+ILHACKOBJS = xf86_IlHack.o
+#elif NeedPortIO
+ILHACKOBJS = PortIO.o
+#endif
+
+SRCS = xf86_Util.c Delay.c $(ILHACKSRCS) $(XSRCS)
+
+OBJS = xf86_Util.o Delay.o $(ILHACKOBJS) $(XOBJS)
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+#if defined(i386Architecture) && !defined(cygwinArchitecture) \
+ && !defined(OS2Architecture)
+ObjectFromAsmSource(BUSmemcpy,NullParameter)
+ObjectFromAsmSource(IODelay,NullParameter)
+ObjectFromAsmSource(SlowBcopy,NullParameter)
+#endif
+
+#ifdef NeedPortIO
+ObjectFromAsmSource(PortIO,NullParameter)
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/PortIO.S b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/PortIO.S
new file mode 100644
index 000000000..75db31156
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/PortIO.S
@@ -0,0 +1,57 @@
+/* $XFree86$ */
+
+/* Port I/O functions for platforms with no inlining. */
+
+#include "assyntax.h"
+
+ FILE("PortIO.s")
+
+ AS_BEGIN
+
+ GLOBL GLNAME(outb)
+ GLOBL GLNAME(outw)
+ GLOBL GLNAME(outl)
+ GLOBL GLNAME(inb)
+ GLOBL GLNAME(inw)
+ GLOBL GLNAME(inl)
+
+ SEG_TEXT
+ ALIGNTEXT4
+GLNAME(outb):
+ MOV_L (REGOFF(4,ESP), EDX)
+ MOV_L (REGOFF(8,ESP), EAX)
+ OUT_B
+ RET
+
+ ALIGNTEXT4
+GLNAME(outw):
+ MOV_L (REGOFF(4,ESP), EDX)
+ MOV_L (REGOFF(8,ESP), EAX)
+ OUT_W
+ RET
+
+ ALIGNTEXT4
+GLNAME(outl):
+ MOV_L (REGOFF(4,ESP), EDX)
+ MOV_L (REGOFF(8,ESP), EAX)
+ OUT_L
+ RET
+
+ ALIGNTEXT4
+GLNAME(inb):
+ MOV_L (REGOFF(4,ESP), EDX)
+ IN_B
+ RET
+
+ ALIGNTEXT4
+GLNAME(inw):
+ MOV_L (REGOFF(4,ESP), EDX)
+ IN_L
+ RET
+
+ ALIGNTEXT4
+GLNAME(inl):
+ MOV_L (REGOFF(4,ESP), EDX)
+ IN_L
+ RET
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/SlowBcopy.S b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/SlowBcopy.S
new file mode 100644
index 000000000..9fd73a0f9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/SlowBcopy.S
@@ -0,0 +1,108 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/SlowBcopy.s,v 1.2 1998/07/25 16:56:50 dawes Exp $ */
+/*******************************************************************************
+ Copyright 1994 by Glenn G. Lai
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyr notice appear in all copies and that
+both that copyr notice and this permission notice appear in
+supporting documentation, and that the name of Glenn G. Lai not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+Glenn G. Lai DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+Glenn G. Lai
+P.O. Box 4314
+Austin, Tx 78765
+glenn@cs.utexas.edu)
+7/21/94
+*******************************************************************************/
+/* $XConsortium: SlowBcopy.s /main/4 1996/02/21 17:40:52 kaleb $ */
+
+/*
+ * Modified from the output generated by GCC
+ *
+ * Create a dependency that should be immune from the effect of register
+ * renaming as is commonly seen in superscalar processors. This should
+ * insert a minimum of 100-ns delays between reads/writes at clock rates
+ * up to 100 MHz---GGL
+ *
+ * Slowbcopy(char *src, char *dst, int count)
+ *
+ */
+
+#include "assyntax.h"
+
+ FILE("SlowBcopy.s")
+
+ AS_BEGIN
+
+gcc2_compiled.:
+___gnu_compiled_c:
+
+ GLOBL GLNAME(xf86SlowBcopy)
+
+ SEG_TEXT
+ ALIGNTEXT4
+GLNAME(xf86SlowBcopy):
+ PUSH_L (EBP)
+ MOV_L (ESP,EBP)
+ PUSH_L (ESI)
+ PUSH_L (EBX)
+ MOV_L (REGOFF(8,EBP),ECX)
+ MOV_L (REGOFF(12,EBP),EDX)
+ MOV_L (REGOFF(16,EBP),ESI)
+ XOR_L (EAX,EAX)
+ CMP_L (ESI,EAX)
+ JGE (L3)
+
+ ALIGNTEXT4
+L5:
+ MOV_B (REGIND(ECX),BL)
+
+ MOV_B (BL, BH)
+ MOV_B (BH, BL)
+ MOV_B (BL, BH)
+ MOV_B (BH, BL)
+ MOV_B (BL, BH)
+ MOV_B (BH, BL)
+ MOV_B (BL, BH)
+ MOV_B (BH, BL)
+ MOV_B (BL, BH)
+ MOV_B (BH, BL)
+
+ MOV_B (BL,REGIND(EDX))
+
+ INC_L (ECX)
+ DEC_L (ECX)
+ INC_L (ECX)
+ DEC_L (ECX)
+ INC_L (ECX)
+ DEC_L (ECX)
+ INC_L (ECX)
+ DEC_L (ECX)
+ INC_L (ECX)
+ DEC_L (ECX)
+
+ INC_L (ECX)
+ INC_L (EDX)
+ INC_L (EAX)
+ CMP_L (ESI,EAX)
+ JL (L5)
+L3:
+ LEA_L (REGOFF(-8,EBP),ESP)
+ POP_L (EBX)
+ POP_L (ESI)
+ MOV_L (EBP,ESP)
+ POP_L (EBP)
+ RET
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/SlowBcopy.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/SlowBcopy.c
new file mode 100644
index 000000000..ec2c67ffa
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/SlowBcopy.c
@@ -0,0 +1,114 @@
+
+/* $XConsortium: SlowBcopy.c /main/1 1996/05/07 17:14:10 kaleb $ */
+/*******************************************************************************
+ for Alpha Linux
+*******************************************************************************/
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/SlowBcopy.c,v 1.6tsi Exp $ */
+
+/*
+ * Create a dependency that should be immune from the effect of register
+ * renaming as is commonly seen in superscalar processors. This should
+ * insert a minimum of 100-ns delays between reads/writes at clock rates
+ * up to 100 MHz---GGL
+ *
+ * Slowbcopy(char *src, char *dst, int count)
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "compiler.h"
+
+/* The outb() isn't needed on my machine, but who knows ... -- ost */
+void
+xf86SlowBcopy(unsigned char *src, unsigned char *dst, int len)
+{
+ while(len--)
+ {
+ *dst++ = *src++;
+#if !defined(__sparc__) && \
+ !defined(__powerpc__) && \
+ !defined(__mips__) && \
+ !defined(__ia64__)
+ outb(0x80, 0x00);
+#endif
+ }
+}
+
+#ifdef __alpha__
+/*
+ * The Jensen lacks dense memory, thus we have to address the bus via
+ * the sparse addressing scheme. Time critical code uses routines from
+ * BUSmemcpy.c
+ *
+ * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996
+ */
+
+#ifdef linux
+
+unsigned long _bus_base(void);
+
+#ifdef TEST_JENSEN_CODE /* define to test the Sparse addressing on a non-Jensen */
+#define SPARSE (5)
+#else
+#define SPARSE (7)
+#endif
+
+#define isJensen() (!_bus_base())
+
+#else
+
+#define isJensen() 0
+#define SPARSE 0
+
+#endif
+
+void
+xf86SlowBCopyFromBus(unsigned char *src, unsigned char *dst, int count)
+{
+ if (isJensen())
+ {
+ unsigned long addr;
+ long result;
+
+ addr = (unsigned long) src;
+ while( count ){
+ result = *(volatile int *) addr;
+ result >>= ((addr>>SPARSE) & 3) * 8;
+ *dst++ = (unsigned char) (0xffUL & result);
+ addr += 1<<SPARSE;
+ count--;
+ outb(0x80, 0x00);
+ }
+ }
+ else
+ xf86SlowBcopy(src,dst,count);
+}
+
+void
+xf86SlowBCopyToBus(unsigned char *src, unsigned char *dst, int count)
+{
+ if (isJensen())
+ {
+ unsigned long addr;
+
+ addr = (unsigned long) dst;
+ while(count) {
+ *(volatile unsigned int *) addr = (unsigned short)(*src) * 0x01010101;
+ src++;
+ addr += 1<<SPARSE;
+ count--;
+ outb(0x80, 0x00);
+ }
+ }
+ else
+ xf86SlowBcopy(src,dst,count);
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/xf86_IlHack.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/xf86_IlHack.c
new file mode 100644
index 000000000..d8053f7d2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/xf86_IlHack.c
@@ -0,0 +1,19 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/xf86_IlHack.c,v 3.4.4.1 1998/06/04 17:36:01 dawes Exp $ */
+/*
+ * This file is an incredible crock to get the normally-inline functions
+ * built into the server so that things can be debugged properly.
+ *
+ * Note: this doesn't work when using a compiler other than GCC.
+ */
+/* $XConsortium: xf86_IlHack.c /main/4 1996/02/21 17:52:26 kaleb $ */
+
+
+#define static /**/
+#define __inline__ /**/
+#undef NO_INLINE
+#define DO_PROTOTYPES
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "compiler.h"
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/xf86_Util.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/xf86_Util.c
new file mode 100644
index 000000000..afcdd5b69
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/misc/xf86_Util.c
@@ -0,0 +1,96 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/xf86_Util.c,v 3.7 1999/01/14 13:05:05 dawes Exp $ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: xf86_Util.c /main/5 1996/10/23 13:13:10 kaleb $ */
+
+/*
+ * This file is for utility functions that will be shared by other pieces
+ * of the system. Putting things here ensure that all the linking order
+ * dependencies are dealt with, as this library will be linked in last.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+
+/* To prevent empty source file warnings */
+int _xf86misc;
+
+#if 0
+/* For use only with gcc */
+#ifdef __GNUC__
+
+#include "os.h"
+
+char *
+debug_alloca(char *file, int line, int size)
+{
+ char *ptr;
+
+ ptr = Xalloc(size);
+ ErrorF("Alloc: %s line %d; ptr = 0x%x, length = %d\n", file, line,
+ ptr, size);
+ return ptr;
+}
+
+void
+debug_dealloca(char *file, int line, char *ptr)
+{
+ ErrorF("Dealloc: %s line %d; ptr = 0x%x\n", file, line, ptr);
+ Xfree(ptr);
+}
+#endif
+#endif
+
+#if defined(ISC) || defined(Lynx)
+
+#include <math.h>
+
+/* Needed for apm_driver.c */
+/* These functions are modeled after the functions inside gnu's libc */
+
+static double
+copysign(double x, double y)
+{
+ x = fabs(x);
+ return y < 0 ? - x : x;
+}
+
+double
+RInt(double x)
+{
+ double s,t;
+ const double one = 1.0;
+ const static double L = 4503599627370496.0E0;
+
+ if (x!=x)
+ return(x);
+ if (copysign(x,one) >= L)
+ return(x);
+ s = copysign(L,x);
+ t = x + s;
+ return (t - s);
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/Imakefile
new file mode 100644
index 000000000..fb7132182
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/Imakefile
@@ -0,0 +1,37 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile,v 1.7 2002/10/11 01:46:59 dawes Exp $
+XCOMM
+
+#include <Server.tmpl>
+
+
+SRCS = nto_io.c nto_init.c nto_kbdEv.c nto_ioperm.c nto_video.c \
+ VTsw_noop.c posix_tty.c kmod_noop.c agp_noop.c stdResource.c \
+ stdPci.c libc_wrapper.c sigiostubs.c pm_noop.c nto_mouse.c
+
+OBJS = nto_io.o nto_init.o nto_kbdEv.o nto_ioperm.o nto_video.o \
+ VTsw_noop.o posix_tty.o kmod_noop.o agp_noop.o stdResource.o \
+ stdPci.o libc_wrapper.o sigiostubs.o pm_noop.o nto_mouse.o
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC)
+
+RESDEFINES = -DUSESTDRES
+
+DEFINES = $(RESDEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+
+LinkSourceFile(libc_wrapper.c,../shared)
+LinkSourceFile(sigiostubs.c,../shared)
+LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(stdResource.c,../shared)
+LinkSourceFile(stdPci.c,../shared)
+
+LinkSourceFile(VTsw_noop.c,../shared)
+LinkSourceFile(posix_tty.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
+LinkSourceFile(agp_noop.c,../shared)
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/README b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/README
new file mode 100644
index 000000000..8d262fe08
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/README
@@ -0,0 +1,29 @@
+XFree86 on NTO
+
+Status:
+Everything builds, and appears to work. Libraries are built as shared.
+
+Building:
+Buiding is done as cross-development from QNX4. What you'll need:
+
+QNX4 4.24+
+Neutrino 2.0 x86 runtime and development packages for QNX4 host.
+Various QNX4 utilities, such as pdksh, cpp etc.
+
+To build:
+
+type (from the xc/ directory)
+BOOTSTRAPCFLAGS="-D__QNXNTO__ -Di386 -D__GNUC__" make World 2>&1 | tee make.log
+
+you can also make PPC or MIPS clients (-DPPC or -DMIPS):
+BOOTSTRAPCFLAGS="-D__QNXNTO__ -DPPC -D__GNUC__" make World 2>&1 | tee make.log
+
+Let the build run, and then examine make.log for any errors.
+
+
+Note that we'll very soon be able to build X natively on NTO...
+
+Sebastien Marineau
+sebastien@qnx.com
+
+$XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/README,v 1.1.2.1 1999/07/29 09:40:14 hohndel Exp $
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_init.c
new file mode 100644
index 000000000..726a8a5ac
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_init.c
@@ -0,0 +1,104 @@
+/*
+ * (c) Copyright 1998 by Sebastien Marineau
+ * <sebastien@qnx.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * SEBASTIEN MARINEAU BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Sebastien Marineau shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Sebastien Marineau.
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/nto_init.c,v 1.2 1999/12/27 00:45:45 robin Exp $
+ */
+
+/* This module contains the NTO-specific functions used at server init.
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/neutrino.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/dcmd_chr.h>
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+extern int NTO_con_fd;
+
+void
+xf86UseMsg()
+{
+ ErrorF("No NTO-specific usage options available at this time\n");
+ return;
+}
+
+int
+xf86ProcessArgument(argc, argv, i)
+int argc;
+char **argv;
+int i;
+{
+
+ return 0;
+
+}
+
+
+/* Right now, OpenConsole() does not do much; later, we may want to handle
+ * console switching and so on....
+ */
+
+void
+xf86OpenConsole()
+{
+ unsigned flags;
+
+
+ ThreadCtl(_NTO_TCTL_IO, 0);
+
+ if((NTO_con_fd = open("/dev/con1", O_RDWR)) == -1) {
+ ErrorF("Unable to open console\n");
+ return;
+ }
+
+ /* Make the console invisible to prevent devc-con from touching hardware */
+ flags = _CONCTL_INVISIBLE | _CONCTL_INVISIBLE_CHG;
+ devctl(NTO_con_fd, DCMD_CHR_SERCTL, &flags, sizeof flags, 0);
+
+ return;
+}
+
+void
+xf86CloseConsole()
+{
+ unsigned flags;
+
+ /* Make console visible again */
+ flags = _CONCTL_INVISIBLE_CHG;
+ devctl(NTO_con_fd, DCMD_CHR_SERCTL, &flags, sizeof flags, 0);
+ close(NTO_con_fd);
+
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_io.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_io.c
new file mode 100644
index 000000000..9c32afd35
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_io.c
@@ -0,0 +1,118 @@
+/*
+ * (c) Copyright 1998 by Sebastien Marineau
+ * <sebastien@qnx.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * SEBASTIEN MARINEAU BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Sebastien Marineau shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Sebastien Marineau.
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/nto_io.c,v 1.4 2002/10/11 01:40:35 dawes Exp $
+ */
+
+/* This module contains the NTO-specific functions to access the keyboard
+ * and the console.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+int NTO_kbd_fd = -1;
+int NTO_con_fd = -1;
+
+void
+xf86SoundKbdBell(loudness, pitch, duration)
+int loudness, pitch, duration;
+{
+
+/* Come back and fix! */
+ErrorF("xf86SoundKbdBell: to implement\n");
+}
+
+void
+xf86SetKbdLeds(leds)
+int leds;
+{
+
+ErrorF("xf86SetKbdLeds: to implement\n");
+}
+
+int
+xf86GetKbdLeds()
+{
+ int leds;
+
+ leds = 0;
+ ErrorF("xf86GetKbdLeds: to implement\n");
+ return(leds);
+}
+
+/* This is a no-op for now */
+void
+xf86SetKbdRepeat(rad)
+char rad;
+{
+ return;
+}
+
+
+/* Need to open keyboard here ? */
+void
+xf86KbdInit()
+{
+
+ ErrorF("xf86KbdInit: to implement\n");
+ return;
+}
+
+
+int xf86KbdOn()
+{
+ /* Here, we need to open /dev/kbd */
+ NTO_kbd_fd = open("/dev/kbd", O_RDWR | O_NONBLOCK);
+ ErrorF("Opened keyboard device, handle %d\n",NTO_kbd_fd);
+ return(NTO_kbd_fd);
+}
+
+int xf86KbdOff()
+{
+ close(NTO_kbd_fd);
+ NTO_kbd_fd = -1;
+ return (-1);
+}
+
+#include "xf86OSKbd.h"
+
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+ return FALSE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_ioperm.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_ioperm.c
new file mode 100644
index 000000000..67a771ff6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_ioperm.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright 1998 by Sebastien Marineau <sebastien@qnx.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Sebastien Marineau makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * SEBASTIEN MARINEAU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/nto_ioperm.c,v 1.2 1999/12/27 00:45:45 robin Exp $
+ */
+
+/* I/O functions to enable access to I/O ports under Neutrino */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/neutrino.h>
+#include <errno.h>
+
+
+Bool xf86EnableIO()
+{
+ ErrorF("xf86EnableIO: enabling I/O access\n");
+ if(ThreadCtl(_NTO_TCTL_IO, 0)) {
+ ErrorF("xf86EnableIO: could not set I/O privilege, errno %d\n",errno);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void xf86DisableIO()
+{
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_kbdEv.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_kbdEv.c
new file mode 100644
index 000000000..a028de6b6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_kbdEv.c
@@ -0,0 +1,53 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/nto_kbdEv.c,v 1.2 1999/12/27 00:45:46 robin Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Dawes <dawes@physics.su.oz.au>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Dawes
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Thomas Roell and
+ * David Dawes makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: std_kbdEv.c /main/4 1996/03/11 10:47:33 kaleb $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+
+#include "xf86_OSlib.h"
+
+extern int NTO_kbd_fd;
+
+void xf86KbdEvents()
+{
+ unsigned char rBuf[64];
+ int nBytes, i;
+
+ if ((nBytes = read( NTO_kbd_fd, (char *)rBuf, sizeof(rBuf))) > 0) {
+ for (i = 0; i < nBytes; i++) {
+ xf86PostKbdEvent(rBuf[i]);
+ }
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_mouse.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_mouse.c
new file mode 100644
index 000000000..2dda8aa32
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_mouse.c
@@ -0,0 +1,210 @@
+/*
+ * Written by Frank Liu Oct 10, 2001
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/nto_mouse.c,v 1.1 2001/11/16 16:47:56 dawes Exp $ */
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+
+/* copied from mipointer.h */
+extern int miPointerGetMotionEvents(
+ DeviceIntPtr /*pPtr*/,
+ xTimecoord * /*coords*/,
+ unsigned long /*start*/,
+ unsigned long /*stop*/,
+ ScreenPtr /*pScreen*/
+);
+
+#include <sys/dcmd_input.h>
+#define NUMEVENTS 64 /* don't want to stuck in the mouse read loop */
+
+/*
+ * OsMouseReadInput --
+ * Get some events from our queue. Process outstanding events now.
+ */
+static void
+OsMouseReadInput(InputInfoPtr pInfo)
+{
+ int n = 0;
+ int buttons, col, row;
+ struct _mouse_packet mp;
+ MouseDevPtr pMse;
+
+ pMse = pInfo->private;
+
+ while ( (read(pInfo->fd, &mp, sizeof(struct _mouse_packet)) > 0 )
+ && (n < NUMEVENTS ) )
+ {
+ col = mp.dx;
+ row = -mp.dy;
+ buttons = mp.hdr.buttons;
+ pMse->PostEvent(pInfo, buttons, col, row, 0, 0);
+ n++;
+ }
+}
+
+/*
+ * OsMouseProc --
+ * Handle the initialization, etc. of a mouse
+ */
+static int
+OsMouseProc(pPointer, what)
+DeviceIntPtr pPointer;
+int what;
+{
+ int nbuttons;
+ unsigned char map[MSE_MAXBUTTONS + 1];
+ MouseDevPtr pMse;
+ InputInfoPtr pInfo;
+
+ pInfo = pPointer->public.devicePrivate;
+ pMse = pInfo->private;
+ pMse->device = pPointer;
+
+ switch (what) {
+ case DEVICE_INIT:
+ pPointer->public.on = FALSE;
+
+ for (nbuttons = 0; nbuttons < MSE_MAXBUTTONS; ++nbuttons)
+ map[nbuttons + 1] = nbuttons + 1;
+
+ InitPointerDeviceStruct((DevicePtr)pPointer,
+ map,
+ min(pMse->buttons, MSE_MAXBUTTONS),
+ miPointerGetMotionEvents,
+ pMse->Ctrl,
+ miPointerGetMotionBufferSize());
+
+ /* X valuator */
+ xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 0);
+ /* Y valuator */
+ xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 1);
+ xf86MotionHistoryAllocate(pInfo);
+ break;
+
+ case DEVICE_ON:
+ pInfo->fd = xf86OpenSerial(pInfo->options);
+ if (pInfo->fd == -1)
+ xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
+ else {
+ AddEnabledDevice(pInfo->fd);
+ }
+ pMse->lastButtons = 0;
+ pMse->lastMappedButtons = 0;
+ pMse->emulateState = 0;
+ pPointer->public.on = TRUE;
+ break;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ if (pInfo->fd != -1) {
+ RemoveEnabledDevice(pInfo->fd);
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ }
+ pPointer->public.on = FALSE;
+ break;
+ }
+ return (Success);
+}
+
+static int
+SupportedInterfaces(void)
+{
+ /* FIXME: Is this correct? Should we just return MSE_MISC? */
+ return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_MISC | MSE_AUTO;
+}
+
+static const char *internalNames[] = {
+ "OSMouse",
+ NULL
+};
+
+static const char **
+BuiltinNames(void)
+{
+ return internalNames;
+}
+
+static Bool
+CheckProtocol(const char *protocol)
+{
+ int i;
+
+ for (i = 0; internalNames[i]; i++)
+ if (xf86NameCmp(protocol, internalNames[i]) == 0)
+ return TRUE;
+ return FALSE;
+}
+
+/* XXX Is this appropriate? If not, this function should be removed. */
+static const char *
+DefaultProtocol(void)
+{
+ return "OSMouse";
+}
+
+static Bool
+OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ MouseDevPtr pMse;
+
+ /* This is called when the protocol is "OSMouse". */
+
+ pMse = pInfo->private;
+ pMse->protocol = protocol;
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
+
+ /* Collect the options, and process the common options. */
+ xf86CollectInputOptions(pInfo, NULL, NULL);
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
+
+ /* Check if the device can be opened. */
+ pInfo->fd = xf86OpenSerial(pInfo->options);
+ if (pInfo->fd == -1) {
+ if (xf86GetAllowMouseOpenFail())
+ xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
+ else {
+ xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
+ xfree(pMse);
+ return FALSE;
+ }
+ }
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+
+ /* Process common mouse options (like Emulate3Buttons, etc). */
+ pMse->CommonOptions(pInfo);
+
+ /* Setup the local procs. */
+ pInfo->device_control = OsMouseProc;
+ pInfo->read_input = OsMouseReadInput;
+
+ pInfo->flags |= XI86_CONFIGURED;
+ return TRUE;
+}
+
+OSMouseInfoPtr
+xf86OSMouseInit(int flags)
+{
+ OSMouseInfoPtr p;
+
+ p = xcalloc(sizeof(OSMouseInfoRec), 1);
+ if (!p)
+ return NULL;
+ p->SupportedInterfaces = SupportedInterfaces;
+ p->BuiltinNames = BuiltinNames;
+ p->DefaultProtocol = DefaultProtocol;
+ p->CheckProtocol = CheckProtocol;
+ p->PreInit = OsMousePreInit;
+ return p;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_video.c
new file mode 100644
index 000000000..f78f6864a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_video.c
@@ -0,0 +1,170 @@
+/* (c) Copyright 1998 by Sebastien Marineau
+ * <sebastien@qnx.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * SEBASTIEN MARINEAU BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Sebastien Marineau shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Sebastien Marineau.
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/nto_video.c,v 1.3tsi Exp $
+ */
+
+/* This module contains the NTO-specific functions to deal with video
+ * framebuffer access and interrupts.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/neutrino.h>
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+
+/* These are the interrupt enabling/disabling functions.
+ */
+
+void xf86EnableInterrupts()
+{
+ InterruptEnable();
+}
+
+Bool xf86DisableInterrupts()
+{
+ InterruptDisable();
+ return 0;
+}
+
+/* These are the routines to map/unmap video memory... */
+
+Bool xf86LinearVidMem()
+{
+ /* Yes we can... */
+ return(TRUE);
+}
+
+/* This is our shmem "Physical" handle */
+int NTO_PhMem_fd = -1;
+
+
+/* Map a chunk of physical video memory, using mmap */
+pointer
+xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size)
+{
+ int fd;
+ pointer base;
+
+ if(NTO_PhMem_fd < 0) {
+ if ((fd = open("/dev/mem", O_RDWR, 0777)) < 0) {
+ FatalError("xf86MapVidMem: Failed to open /dev/mem\n");
+ }
+ NTO_PhMem_fd = fd;
+ }
+
+ base = mmap((caddr_t)0, Size,
+ (Flags & VIDMEM_READONLY) ? PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_SHARED, NTO_PhMem_fd, (off_t)Base);
+
+ ErrorF("MapVidMem: addr %08x size %08x addr %08x\n", Base, Size, base);
+ if ((long)base == -1) {
+ FatalError("xf86MapVidMem: Failed to mmap video memory\n");
+ }
+
+ return base;
+}
+
+/* ARGSUSED */
+void
+xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+
+ ErrorF("xf86UnmapVidMem: base %x size %x\n", Base, Size);
+ munmap((caddr_t) Base, Size);
+
+}
+
+/* Finally, this function allows us to read the video BIOS content */
+
+int
+xf86ReadBIOS(Base, Offset, Buf, Len)
+unsigned long Base, Offset;
+unsigned char *Buf;
+int Len;
+{
+ unsigned char * VirtBase;
+
+ ErrorF("xf86ReadBIOS: base %x offset %x len %x\n", Base, Offset, Len);
+
+ if (NTO_PhMem_fd == -1) {
+ if ((NTO_PhMem_fd = open("/dev/mem", O_RDWR, 0777)) < 0) {
+ FatalError("xf86ReadBIOS: cannot open Physical memory\n");
+ }
+ }
+
+ /* Use mmap to map BIOS region. Note the restrictions on
+ * mmap alignement of offset variable (which must be on a page
+ * boundary).
+ */
+ VirtBase = (unsigned char *) mmap(0, (size_t)((Offset & 0x7fff) + Len), PROT_READ,
+ MAP_SHARED, NTO_PhMem_fd, (off_t) (Base + (Offset & 0xffff8000)));
+ if((long)VirtBase == -1) {
+ FatalError( "xf86ReadBIOS: Could not mmap BIOS memory space, errno=%i\n", errno);
+ }
+
+ /* So now we have our mapping to the BIOS region */
+
+ /* Do a sanity check on what we have just mapped */
+ if (((off_t)((off_t)Offset & 0x7FFF) != (off_t)0) &&
+ (VirtBase[0] != 0x55) &&
+ (VirtBase[1] != 0xaa)) {
+ ErrorF( "xf86ReadBIOS: BIOS sanity check failed, addr=%x\n",
+ (int)Base + Offset);
+ munmap(VirtBase, (Offset & 0x7fff) + Len);
+ return -1;
+ }
+
+ /* Things look good: copy BIOS data */
+ memcpy(Buf, VirtBase + (Offset & 0x7fff), Len);
+ munmap(VirtBase, (Offset & 0x7fff) + Len);
+
+ return Len;
+}
+
+void
+xf86MapReadSideEffects(int ScreenNum, int Flags, pointer base,
+ unsigned long Size)
+{
+ return;
+}
+
+Bool
+xf86CheckMTRR(int s)
+{
+ return FALSE;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/Imakefile
new file mode 100644
index 000000000..6659da9be
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/Imakefile
@@ -0,0 +1,45 @@
+XCOMM $XConsortium: Imakefile /main/7 1996/09/28 17:24:18 rws $
+
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/Imakefile,v 3.20 2002/10/17 02:22:48 dawes Exp $
+#include <Server.tmpl>
+
+BIOS_MOD = os2_bios
+
+SRCS = os2_init.c os2_video.c os2_io.c $(BIOS_MOD).c \
+ os2_ioperm.c os2_VTsw.c os2_mouse.c os2_KbdEv.c os2_stubs.c \
+ os2_select.c os2_diag.c libc_wrapper.c stdResource.c stdPci.c \
+ vidmem.c sigiostubs.c pm_noop.c kmod_noop.c agp_noop.c os2_serial.c \
+ os2_kbd.c
+
+OBJS = os2_init.o os2_video.o os2_io.o $(BIOS_MOD).o \
+ os2_ioperm.o os2_VTsw.o os2_mouse.o os2_kbdEv.o os2_stubs.o \
+ os2_select.o os2_diag.o libc_wrapper.o stdResource.o stdPci.o \
+ vidmem.o sigiostubs.o pm_noop.o kmod_noop.o agp_noop.o os2_serial.o \
+ os2_kbd.o
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+ -I$(SERVERSRC)/mi -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+RESDEFINES = -DUSESTDRES
+
+DEFINES = $(RESDEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+NormalAsmObjectRule()
+
+LinkSourceFile(VTsw_noop.c,../shared)
+LinkSourceFile(libc_wrapper.c,../shared)
+LinkSourceFile(stdResource.c,../shared)
+LinkSourceFile(stdPci.c,../shared)
+LinkSourceFile(vidmem.c,../shared)
+LinkSourceFile(sigiostubs.c,../shared)
+LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
+LinkSourceFile(agp_noop.c,../shared)
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/README b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/README
new file mode 100644
index 000000000..d07059eed
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/README
@@ -0,0 +1,78 @@
+Information on files in this directory
+--------------------------------------
+\xc\programs\xserver\hw\xfree86\os-support\os2
+
+The files in this directory form the OS-dependent porting layer of
+XFree86 for OS/2. They are the work of:
+
+ Holger Veit <Holger.Veit@gmd.de>
+ Sebastien Marineau <marineau@genie.uottawa.ca>
+
+Some functions which were absent from OS/2,
+such as direct access to IO ports and the mapping of physical memory,
+are implemented in a device-driver written for this purpose by Holger Veit
+<Holger.Veit@gmd.de>. The driver also implements several functions
+necessary for xterm.
+The driver should be installed in the config.sys with a line:
+
+DEVICE=path\XF86SUP.SYS
+
+The following gives a brief overview of the implementation of the
+porting layer, and lists some of the "gotchas" when modifying the source.
+
+BIOS and physical memory mapping: This is handled by the functions in XF86SUP.SYS driver.
+
+IO permission: Handled by a function in the XF86SUP.SYS driver. Essentially, IO permissions
+are granted for the whole Xserver at server initialisation. The device-driver sets the IOPL
+level to ring 3 for the Xserver, which in essence gives it the same IO privileges that a
+device-driver has. Note the danger here: the Xserver can write to any IO port it wishes,
+and can disable interrupts (something which it does), thus can potentially hang the system.
+
+VT switching (switching back and forth to the WPS): This is handled by the keyboard driver,
+i.e. the stardard keyboard sequences (CTRL-ESC etc.) trigger the switch back to PM. The
+Xserver is notified of switches by the VIO function VIOSavRedrawWait(), which is run in
+a separate thread. When a switch to/from PM is requested, this function call unblocks, and
+the Xserver either saves or restores the video buffer and video mode. Note that semaphores
+are used to communicate with the main Xserver thread, and handle cases such as server
+reset while the server has lost focus etc.
+A similar mechanism is used to handle hard-error popups. A thread is run which blocks
+on the VIOModeWait() function. When a hard-error notification occurs, the Xserver attempts
+to recover by resetting the screen. Note that, due to some (probable) bugs in the OS/2
+video drivers, this does not always work as expected. According to the specs, the OS/2
+video drivers are supposed to restore the palette when returning from a hard-error. This
+does not seem to be always the case..... so the palette in X may be screwed up after the
+hard-error.
+
+Keyboard input: because X needs all keyboard event to function (both keypresses, key
+releases, for all keys), the keyboard input was implemented by registering a keyboard
+monitor for the Xserver. The keyboard monitor is run in a separate thread, and sends
+the keystrokes back to the Xserver main thread through a queue. Another thread is
+also started, whose purpose is to "eat" the keystrokes returned by KbdCharIn(). Note that
+the monitor was necessary because the OS/2 keyboard driver does not pass all keystrokes
+to the application calling KbdCharIn().
+
+Mouse input: This was implemented similarly to the keyboard input: mouse events are
+read in a thread, which then passes them to the main Xserver thread through a queue.
+
+Select: this unix and emx function has been reimplemented and optimized for the xserver.
+Because of the need to handle input from pipes, sockets, the mouse and keyboard (which
+select() in unix does but the EMX select does not), it was decided to rewrite it in
+order to minimize CPU usage and maximize responsiveness. Essentially, select() blocks on
+a MuxWait semaphore, and unblocks when input is available from pipes, the mouse and the
+keyboard. The MuxWait semaphore times out every timeslice, so that sockets can be checked
+for activity (unfortunately, sockets are not well-handled in the OS/2 TCPIP and one cannot
+attach a semaphore to a socket). There is also the possibility of using the high-resolution
+timer (found in Merlin) to check sockets more often than every timeslice.
+*** Important: in order to maximize speed, certain shortcuts are utilized in this
+implementation of select(), which makes it unsuitable as a general-purpose function. Also,
+it is imperative that the EMX select() never be called from the Xserver! ***
+
+
+If you wish to modify the source, be aware that there may be very good reasons as
+to why certain things were done this way. Usually, if certain function implementations
+appear unnecessarily complicated, it is probably because there were subtle problems
+with the simpler solutions. Due to the complexity of the Xserver code, and the
+differences between OS/2 and unix, there are many potential pitfalls.
+
+$XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/README,v 3.1 1996/01/30 15:26:27 dawes Exp $
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/int10/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/int10/Imakefile
new file mode 100644
index 000000000..a323229bf
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/int10/Imakefile
@@ -0,0 +1,110 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/int10/Imakefile,v 1.1 2000/04/05 18:13:55 dawes Exp $
+
+#define IHaveModules
+
+#include <Server.tmpl>
+
+SRCS1 = pci.c xf86int10module.c helper_exec.c helper_mem.c xf86int10.c
+OBJS1 = pci.o xf86int10module.o helper_exec.o helper_mem.o xf86int10.o
+
+LinkSourceFile(helper_mem.c,$(XF86SRC)/int10)
+LinkSourceFile(helper_exec.c,$(XF86SRC)/int10)
+LinkSourceFile(xf86int10.c,$(XF86SRC)/int10)
+LinkSourceFile(pci.c,$(XF86SRC)/int10)
+LinkSourceFile(xf86int10module.c,$(XF86SRC)/int10)
+LinkSourceFile(xf86x86emu.c,$(XF86SRC)/int10)
+LinkSourceFile(generic.c,$(XF86SRC)/int10)
+
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86SRC)/int10 \
+ -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC)
+
+DEFINES=-DHAVE_SYSV_IPC
+
+#if 0
+/* debugging stuff */
+#DEFINES =-D_PC
+#undef XF86INT10_BUILD
+#define XF86INT10_BUILD X86EMU_GENERIC
+#define X86EMU_LIBPATH /usr/local/lib
+#endif
+
+#if defined(i386Architecture)
+DEFINES =-D_PC
+#endif
+
+/* XXX keep this temporarily for reference */
+#if 0
+#if (XF86INT10_BUILD == X86EMU_GENERIC)
+
+SRCS = $(SRCS1) xf86x86emu.c generic.c
+OBJS = $(OBJS1) xf86x86emu.o generic.o x86emu.o
+SpecialObjectRule(pci.o, pci.c, -D_X86EMU)
+SpecialObjectRule(helper_exec.o, helper_exec.c, -D_X86EMU)
+SpecialObjectRule(xf86int10.o, xf86int10.c, -D_X86EMU -DSHOW_ALL_DEVICES)
+SpecialObjectRule(generic.o, generic.c, -D_X86EMU)
+SpecialObjectRule(xf86x86emu.o, xf86x86emu.c, -D_X86EMU)
+BuildObjectFromLibraryWithPath(X86EMU_LIBPATH,x86emu,x86emu)
+#endif
+#endif
+
+#if defined(XF86INT10_BUILD) && (XF86INT10_BUILD == X86VM)
+
+SRCS = $(SRCS1) linux.c
+OBJS = $(OBJS1) linux.o
+SpecialObjectRule(pci.o, pci.c, -D_VM86_LINUX)
+SpecialObjectRule(helper_exec.o, helper_exec.c, -D_VM86_LINUX)
+SpecialObjectRule(xf86int10.o, xf86int10.c, -D_VM86_LINUX -DSHOW_ALL_DEVICES)
+SpecialObjectRule(linux.o, linux.c, -D_VM86_LINUX -DHAVE_SYSV_IPC)
+
+#elif (XF86INT10_BUILD == X86EMU_OS)
+
+SpecialObjectRule(pci.o, pci.c, -D_X86EMU)
+SpecialObjectRule(helper_exec.o, helper_exec.c, -D_X86EMU)
+SpecialObjectRule(xf86int10.o, xf86int10.c, -D_X86EMU -DSHOW_ALL_DEVICES)
+SpecialObjectRule(linux.o, linux.c, -D_X86EMU -DHAVE_SYSV_IPC)
+
+X86TOPDIR = $(TOP)/extras/x86emu
+X86SRCDIR = $(X86TOPDIR)/src/x86emu
+X86EMUINCLUDES = -I$(X86TOPDIR)/include -I$(X86SRCDIR)
+
+# if !defined(X86EMU_LIBPATH)
+X86EMUSRCS = debug.c decode.c fpu.c ops.c ops2.c prim_ops.c sys.c
+X86EMUOBJS = debug.o decode.o fpu.o ops.o ops2.o prim_ops.o sys.o
+
+LinkSourceFile(debug.c,$(X86SRCDIR))
+LinkSourceFile(decode.c,$(X86SRCDIR))
+LinkSourceFile(fpu.c,$(X86SRCDIR))
+LinkSourceFile(ops.c,$(X86SRCDIR))
+LinkSourceFile(ops2.c,$(X86SRCDIR))
+LinkSourceFile(prim_ops.c,$(X86SRCDIR))
+LinkSourceFile(sys.c,$(X86SRCDIR))
+# else
+BuildObjectFromLibraryWithPath(X86EMU_LIBPATH,x86emu,x86emu)
+X86EMUOBJS = x86emu.o
+# endif
+
+SRCS = $(SRCS1) xf86x86emu.c linux.c $(X86EMUSRCS)
+OBJS = $(OBJS1) xf86x86emu.o linux.o $(X86EMUOBJS)
+
+#endif
+
+#if defined(XF86INT10_BUILD) && XF86INT10_BUILD > X86EMU_GENERIC
+
+LibraryModuleTarget(int10, $(OBJS))
+
+InstallLibraryModule(int10,$(MODULEDIR),linux)
+
+all::
+ @(set -x; cd ../..; \
+ RemoveFile(LibraryTargetName(int10)); \
+ $(LN) linux/int10/LibraryTargetName(int10) . )
+
+InstallDriverSDKLibraryModule(int10,$(DRIVERSDKMODULEDIR),.)
+
+InstallDriverSDKNonExecFile(../../int10/xf86int10.h,$(DRIVERSDKINCLUDEDIR))
+
+#endif
+
+DependTarget()
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c
new file mode 100644
index 000000000..d01cfb373
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c
@@ -0,0 +1,452 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c,v 1.3 2001/04/30 14:34:58 tsi Exp $ */
+/*
+ * XFree86 int10 module
+ * execute BIOS int 10h calls in x86 real mode environment
+ * Copyright 1999 Egbert Eich
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86str.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Pci.h"
+#include "compiler.h"
+#define _INT10_PRIVATE
+#include "xf86int10.h"
+#include "int10Defines.h"
+
+static CARD8 read_b(xf86Int10InfoPtr pInt,int addr);
+static CARD16 read_w(xf86Int10InfoPtr pInt,int addr);
+static CARD32 read_l(xf86Int10InfoPtr pInt,int addr);
+static void write_b(xf86Int10InfoPtr pInt,int addr, CARD8 val);
+static void write_w(xf86Int10InfoPtr pInt,int addr, CARD16 val);
+static void write_l(xf86Int10InfoPtr pInt,int addr, CARD32 val);
+
+/*
+ * the emulator cannot pass a pointer to the current xf86Int10InfoRec
+ * to the memory access functions therefore store it here.
+ */
+
+typedef struct {
+ int shift;
+ int pagesize_1;
+ int entries;
+ void* vRam;
+ memType *alloc_rec;
+} genericInt10Priv;
+
+#define INTPriv(x) ((genericInt10Priv*)x->private)
+
+int10MemRec genericMem = {
+ read_b,
+ read_w,
+ read_l,
+ write_b,
+ write_w,
+ write_l
+};
+
+static void MapVRam(xf86Int10InfoPtr pInt);
+static void UnmapVRam(xf86Int10InfoPtr pInt);
+static void setupTable(xf86Int10InfoPtr pInt, memType address,
+ int loc,int size);
+
+static void *sysMem = NULL;
+
+xf86Int10InfoPtr
+xf86InitInt10(int entityIndex)
+{
+ xf86Int10InfoPtr pInt;
+ int screen;
+ void* intMem;
+ void* vbiosMem;
+ int pagesize;
+ int entries;
+ int shift;
+ legacyVGARec vga;
+
+ screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex;
+
+ if (int10skip(xf86Screens[screen],entityIndex))
+ return NULL;
+
+ pInt = (xf86Int10InfoPtr)xnfcalloc(1,sizeof(xf86Int10InfoRec));
+ pInt->entityIndex = entityIndex;
+ if (!xf86Int10ExecSetup(pInt))
+ goto error0;
+ pInt->mem = &genericMem;
+ pagesize = xf86getpagesize();
+ pInt->private = (pointer)xnfcalloc(1,sizeof(genericInt10Priv));
+ entries = SYS_SIZE / pagesize;
+
+ pInt->scrnIndex = screen;
+ INTPriv(pInt)->pagesize_1 = pagesize - 1;
+ INTPriv(pInt)->entries = entries;
+ INTPriv(pInt)->alloc_rec =
+ xnfcalloc(1,sizeof(memType) * entries);
+ for (shift = 0 ; (pagesize >> shift) ; shift++) {};
+ shift -= 1;
+ INTPriv(pInt)->shift = shift;
+
+ /*
+ * we need to map video RAM MMIO as some chipsets map mmio
+ * registers into this range.
+ */
+
+ MapVRam(pInt);
+ intMem = xnfalloc(pagesize);
+ setupTable(pInt,(memType)intMem,0,pagesize);
+ vbiosMem = xnfalloc(V_BIOS_SIZE);
+
+#ifdef _PC
+ if (!sysMem)
+ sysMem = xf86MapVidMem(screen,VIDMEM_FRAMEBUFFER,SYS_BIOS,BIOS_SIZE);
+ setupTable(pInt,(memType)sysMem,SYS_BIOS,BIOS_SIZE);
+ if (xf86ReadBIOS(0,0,(unsigned char *)intMem,LOW_PAGE_SIZE) < 0) {
+ xf86DrvMsg(screen,X_ERROR,"Cannot read int vect\n");
+ goto error1;
+ }
+ if (xf86IsEntityPrimary(entityIndex)) {
+ int size;
+ int cs = MEM_RW(pInt,((0x10<<2)+2));
+
+int i,k,m;
+char buf[100], hx[10];
+for (i=0; i<0x100; i+=16) {
+sprintf(buf,"%04x: ",i);
+for (k=0; k<16; k++) {
+ m = MEM_RB(pInt,i+k);
+ sprintf(hx,"%02x ",((unsigned)m)&0xff);
+ strcat(buf,hx);
+}
+xf86DrvMsg(screen,X_INFO,"%s\n",buf);
+}
+
+
+
+ xf86DrvMsg(screen,X_INFO,"Primary V_BIOS segmant is: 0x%x\n",cs);
+ if (xf86ReadBIOS(cs << 4,0,(unsigned char *)vbiosMem,
+ 0x10) < 0) {
+ xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (1)\n");
+ goto error1;
+ }
+ if (!((*(CARD8*)vbiosMem == 0x55)
+ && (*((CARD8*)vbiosMem + 1) == 0xAA))) {
+ xf86DrvMsg(screen,X_ERROR,"No V_BIOS found\n");
+ goto error1;
+ }
+
+ size = *((CARD8*)vbiosMem + 2) * 512;
+ if (xf86ReadBIOS(cs << 4,0,vbiosMem, size) < 0) {
+ xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (2)\n");
+ goto error1;
+ }
+
+ setupTable(pInt,(memType)vbiosMem,cs<<4,size);
+ set_return_trap(pInt);
+ pInt->BIOSseg = cs;
+ } else {
+ reset_int_vect(pInt);
+ set_return_trap(pInt);
+ if (!mapPciRom(pInt,(unsigned char *)(vbiosMem))) {
+ xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (3)\n");
+ goto error1;
+ }
+ setupTable(pInt,(memType)vbiosMem,V_BIOS,V_BIOS_SIZE);
+ pInt->BIOSseg = V_BIOS >> 4;
+ pInt->num = 0xe6;
+ LockLegacyVGA(pInt, &vga);
+ xf86ExecX86int10(pInt);
+ UnlockLegacyVGA(pInt, &vga);
+ }
+#else
+ if (!sysMem) {
+ sysMem = xnfalloc(BIOS_SIZE);
+ setup_system_bios((memType)sysMem);
+ }
+ setupTable(pInt,(memType)sysMem,SYS_BIOS,BIOS_SIZE);
+ setup_int_vect(pInt);
+ set_return_trap(pInt);
+ if (!mapPciRom(pInt,(unsigned char *)(vbiosMem))) {
+ xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (4)\n");
+ goto error1;
+ }
+ setupTable(pInt,(memType)vbiosMem,V_BIOS,V_BIOS_SIZE);
+ pInt->BIOSseg = V_BIOS >> 4;
+ pInt->num = 0xe6;
+ LockLegacyVGA(pInt, &vga);
+ xf86ExecX86int10(pInt);
+ UnlockLegacyVGA(pInt, &vga);
+#endif
+ return pInt;
+
+ error1:
+ xfree(vbiosMem);
+ xfree(intMem);
+ UnmapVRam(pInt);
+ xfree(INTPriv(pInt)->alloc_rec);
+ xfree(pInt->private);
+ error0:
+ xfree(pInt);
+
+ return NULL;
+}
+
+static void
+MapVRam(xf86Int10InfoPtr pInt)
+{
+ int screen = pInt->scrnIndex;
+ int pagesize = INTPriv(pInt)->pagesize_1 + 1;
+ int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize;
+ INTPriv(pInt)->vRam = xf86MapVidMem(screen,VIDMEM_MMIO,V_RAM,size);
+}
+
+static void
+UnmapVRam(xf86Int10InfoPtr pInt)
+{
+ int screen = pInt->scrnIndex;
+ int pagesize = INTPriv(pInt)->pagesize_1 + 1;
+ int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize;
+
+ xf86UnMapVidMem(screen,INTPriv(pInt)->vRam,size);
+}
+
+Bool
+MapCurrentInt10(xf86Int10InfoPtr pInt)
+{
+ /* nothing to do here */
+ return TRUE;
+}
+
+void
+xf86FreeInt10(xf86Int10InfoPtr pInt)
+{
+ int pagesize;
+
+ if (!pInt)
+ return;
+ pagesize = INTPriv(pInt)->pagesize_1 + 1;
+ if (Int10Current == pInt)
+ Int10Current = NULL;
+ xfree(INTPriv(pInt)->alloc_rec[V_BIOS/pagesize]);
+ xfree(INTPriv(pInt)->alloc_rec[0]);
+ UnmapVRam(pInt);
+ xfree(INTPriv(pInt)->alloc_rec);
+ xfree(pInt->private);
+ xfree(pInt);
+}
+
+void *
+xf86Int10AllocPages(xf86Int10InfoPtr pInt,int num, int *off)
+{
+ void* addr;
+ int pagesize = INTPriv(pInt)->pagesize_1 + 1;
+ int num_pages = INTPriv(pInt)->entries;
+ int i,j;
+
+ for (i=0;i<num_pages - num;i++) {
+ if (INTPriv(pInt)->alloc_rec[i] == 0) {
+ for (j=i;j < num + i;j++)
+ if ((INTPriv(pInt)->alloc_rec[j] != 0))
+ break;
+ if (j == num + i)
+ break;
+ else
+ i = i + num;
+ }
+ }
+ if (i == num_pages - num)
+ return NULL;
+
+ *off = i * pagesize;
+ addr = xnfalloc(pagesize * num);
+ setupTable(pInt,(memType)addr,*off,pagesize * num);
+
+ return addr;
+}
+
+void
+xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num)
+{
+ int num_pages = INTPriv(pInt)->entries;
+ int i,j;
+ for (i = 0;i<num_pages - num; i++)
+ if (INTPriv(pInt)->alloc_rec[i]==(memType)pbase) {
+ for (j = 0; j < num; j++)
+ INTPriv(pInt)->alloc_rec[i] = 0;
+ break;
+ }
+ xfree(pbase);
+ return;
+}
+
+static void
+setupTable(xf86Int10InfoPtr pInt, memType address,int loc,int size)
+{
+ int pagesize = INTPriv(pInt)->pagesize_1 + 1;
+ int i,j,num;
+
+ i = loc / pagesize;
+ num = (size + pagesize - 1)/ pagesize; /* round up to the nearest page */
+ /* boudary if size is not */
+ /* multiple of pagesize */
+ for (j = 0; j<num; j++) {
+ INTPriv(pInt)->alloc_rec[i+j] = address;
+ address += pagesize;
+ }
+}
+
+#define OFF(addr) \
+ ((addr) & (INTPriv(pInt)->pagesize_1))
+#define SHIFT \
+ (INTPriv(pInt)->shift)
+#define BASE(addr,shift) \
+ (INTPriv(pInt)->alloc_rec[addr >> shift])
+#define V_ADDR(addr,shift,off) \
+ (BASE(addr,shift) + (off))
+#define VRAM_ADDR(addr) (addr - 0xA0000)
+#define VRAM_BASE (INTPriv(pInt)->vRam)
+
+#define VRAM(addr) ((addr >= 0xA0000) && (addr <= 0xBFFFF))
+#define V_ADDR_RB(addr,shift,off) \
+ (VRAM(addr)) ? MMIO_IN8((CARD8*)VRAM_BASE,VRAM_ADDR(addr)) \
+ : *(CARD8*) V_ADDR(addr,shift,off)
+#define V_ADDR_RW(addr,shift,off) \
+ (VRAM(addr)) ? MMIO_IN16((CARD16*)VRAM_BASE,VRAM_ADDR(addr)) \
+ : ldw_u((pointer)V_ADDR(addr,shift,off))
+#define V_ADDR_RL(addr,shift,off) \
+ (VRAM(addr)) ? MMIO_IN32((CARD32*)VRAM_BASE,VRAM_ADDR(addr)) \
+ : ldl_u((pointer)V_ADDR(addr,shift,off))
+
+#define V_ADDR_WB(addr,shift,off,val) \
+ if(VRAM(addr)) \
+ MMIO_OUT8((CARD8*)VRAM_BASE,VRAM_ADDR(addr),val); \
+ else \
+ *(CARD8*) V_ADDR(addr,shift,off) = val;
+#define V_ADDR_WW(addr,shift,off,val) \
+ if(VRAM(addr)) \
+ MMIO_OUT16((CARD16*)VRAM_BASE,VRAM_ADDR(addr),val); \
+ else \
+ stw_u((val),(pointer)(V_ADDR(addr,shift,off)));
+
+#define V_ADDR_WL(addr,shift,off,val) \
+ if (VRAM(addr)) \
+ MMIO_OUT32((CARD32*)VRAM_BASE,VRAM_ADDR(addr),val); \
+ else \
+ stl_u(val,(pointer)(V_ADDR(addr,shift,off)));
+
+static CARD8
+read_b(xf86Int10InfoPtr pInt, int addr)
+{
+ if (!BASE(addr,SHIFT)) return 0xff;
+
+ return V_ADDR_RB(addr,SHIFT,OFF(addr));
+}
+
+static CARD16
+read_w(xf86Int10InfoPtr pInt, int addr)
+{
+ int shift = SHIFT;
+ int off = OFF(addr);
+
+ if (!BASE(addr,shift)) return 0xffff;
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ return ((V_ADDR_RB(addr,shift,off))
+ || ((V_ADDR_RB(addr,shift,off + 1)) << 8));
+#else
+ if (OFF(addr + 1) > 0) {
+ return V_ADDR_RW(addr,SHIFT,OFF(addr));
+ } else {
+ return ((V_ADDR_RB(addr,shift,off + 1))
+ || ((V_ADDR_RB(addr,shift,off)) << 8));
+ }
+#endif
+}
+
+static CARD32
+read_l(xf86Int10InfoPtr pInt, int addr)
+{
+ int shift = SHIFT;
+ int off = OFF(addr);
+
+ if (!BASE(addr,shift)) return 0xffffffff;
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ return ((V_ADDR_RB(addr,shift,off))
+ || ((V_ADDR_RB(addr,shift,off + 1)) << 8)
+ || ((V_ADDR_RB(addr,shift,off + 2)) << 16)
+ || ((V_ADDR_RB(addr,shift,off + 3)) << 24));
+#else
+ if (OFF(addr + 3) > 2) {
+ return V_ADDR_RL(addr,SHIFT,OFF(addr));
+ } else {
+ return ((V_ADDR_RB(addr,shift,off + 3))
+ || ((V_ADDR_RB(addr,shift,off + 2)) << 8)
+ || ((V_ADDR_RB(addr,shift,off + 1)) << 16)
+ || ((V_ADDR_RB(addr,shift,off)) << 24));
+ }
+#endif
+}
+
+static void
+write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val)
+{
+ if (!BASE(addr,SHIFT)) return;
+
+ V_ADDR_WB(addr,SHIFT,OFF(addr),val);
+}
+
+static void
+write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val)
+{
+ int shift = SHIFT;
+ int off = OFF(addr);
+
+ if (!BASE(addr,shift)) return;
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ V_ADDR_WB(addr,shift,off,val);
+ V_ADDR_WB(addr,shift,off + 1,val >> 8);
+#else
+ if (OFF(addr + 1) > 0) {
+ V_ADDR_WW(addr,shift,OFF(addr),val);
+ } else {
+ V_ADDR_WB(addr,shift,off + 1,val);
+ V_ADDR_WB(addr,shift,off,val >> 8);
+ }
+#endif
+}
+
+static void
+write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val)
+{
+ int shift = SHIFT;
+ int off = OFF(addr);
+ if (!BASE(addr,shift)) return;
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ V_ADDR_WB(addr,shift,off,val);
+ V_ADDR_WB(addr,shift,off + 1, val >> 8);
+ V_ADDR_WB(addr,shift,off + 2, val >> 16);
+ V_ADDR_WB(addr,shift,off + 3, val >> 24);
+#else
+ if (OFF(addr + 3) > 2) {
+ V_ADDR_WL(addr,shift,OFF(addr),val);
+ } else {
+ V_ADDR_WB(addr,shift,off + 3, val);
+ V_ADDR_WB(addr,shift,off + 2, val >> 8);
+ V_ADDR_WB(addr,shift,off + 1, val >> 16);
+ V_ADDR_WB(addr,shift,off, val >> 24);
+ }
+#endif
+}
+
+pointer
+xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr)
+{
+ return (pointer) V_ADDR(addr,SHIFT,OFF(addr));
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_VTsw.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_VTsw.c
new file mode 100644
index 000000000..e050a62cb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_VTsw.c
@@ -0,0 +1,340 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_VTsw.c,v 3.13 2003/06/10 17:03:54 dawes Exp $ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ * Modified 1996 by Sebastien Marineau <marineau@genie.uottawa.ca>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: os2_VTsw.c /main/7 1996/05/13 16:37:55 kaleb $ */
+
+#define I_NEED_OS2_H
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#define INCL_WINSWITCHLIST
+#define INCL_VIO
+#define INCL_KBD
+#define INCL_DOSPROCESS
+#define INCL_DOSSEMAPHORES
+#define INCL_DOSERRORS
+#undef RT_FONT
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "atKeynames.h"
+
+BOOL SwitchedToWPS=FALSE;
+BOOL WaitingForAccess=FALSE;
+void os2PostKbdEvent();
+HEV hevServerHasFocus;
+HEV hevSwitchRequested;
+HEV hevErrorPopupDetected;
+extern HEV hevPopupPending;
+extern HEV hSwitchToSem;
+BOOL os2PopupErrorPending=FALSE;
+
+/*
+ * Added OS/2 code to handle switching back to WPS
+ */
+
+
+Bool xf86VTSwitchPending()
+{
+ return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+}
+
+Bool xf86VTSwitchAway()
+{
+ APIRET rc;
+ ULONG drive;
+
+ xf86Info.vtRequestsPending=FALSE;
+ SwitchedToWPS=TRUE;
+
+ rc = DosQuerySysInfo(5,5,&drive,sizeof(drive));
+ rc = DosSuppressPopUps(0x0000L,drive+96); /* Disable popups */
+ DosPostEventSem(hevSwitchRequested);
+ usleep(30000);
+ return(TRUE);
+}
+
+Bool xf86VTSwitchTo()
+{
+ APIRET rc;
+ ULONG drive,postCount;
+
+ xf86Info.vtRequestsPending=FALSE;
+ SwitchedToWPS=FALSE;
+ rc = DosResetEventSem(hSwitchToSem,&postCount);
+ DosPostEventSem(hevSwitchRequested);
+ rc = DosQuerySysInfo(5,5,&drive,sizeof(drive));
+ rc = DosSuppressPopUps(0x0001L,drive+96); /* Disable popups */
+
+ /* We reset the state of the control key */
+ os2PostKbdEvent(KEY_LCtrl,1);
+ os2PostKbdEvent(KEY_LCtrl,0);
+ os2PostKbdEvent(KEY_RCtrl,1);
+ os2PostKbdEvent(KEY_RCtrl,0);
+ os2PostKbdEvent(KEY_Alt,1);
+ os2PostKbdEvent(KEY_Alt,0);
+ return(TRUE);
+}
+
+
+/* This function is run as a thread and will notify of switch-to/switch-away events */
+void os2VideoNotify(arg)
+void * arg;
+{
+ USHORT Indic;
+ USHORT NotifyType;
+ APIRET rc;
+ ULONG postCount;
+ Bool FirstTime=TRUE;
+ int timeout_count;
+
+ rc=DosCreateEventSem(NULL,&hevServerHasFocus,0L,FALSE);
+ rc=DosPostEventSem(hevServerHasFocus);
+ rc=DosCreateEventSem(NULL,&hevSwitchRequested,0L,FALSE);
+ rc=DosPostEventSem(hevSwitchRequested);
+
+
+ while(1) {
+ Indic=0;
+ rc=VioSavRedrawWait(Indic,&NotifyType,(HVIO)0);
+
+/* Here we handle the semaphore used to indicate wether we have screen access */
+ if(NotifyType==0) rc=DosResetEventSem(hevServerHasFocus,&postCount);
+ if(FirstTime){
+ FirstTime=FALSE;
+ if(NotifyType==1) NotifyType=65535; /* In case a redraw is requested on first call */
+ }
+
+ if(NotifyType==1){
+/* Notify os2PseudoSelect() that we are back */
+ rc=DosPostEventSem(hSwitchToSem);
+ if (rc) xf86Msg(X_ERROR,"Post SwitchToSem returned %d\n");
+/* Sanity check */
+ if (!SwitchedToWPS) {
+ xf86Msg(X_ERROR,
+ "Abnormal switching back to server detected\n");
+ }
+ }
+
+/* Here we set the semaphore used to indicate switching request */
+
+ if((NotifyType!=65535)&&(!WaitingForAccess)) {
+ rc=DosResetEventSem(hevSwitchRequested,&postCount);
+ xf86Info.vtRequestsPending=TRUE;
+/* Then wait for semaphore to be posted once switch is complete. Wait 20 secs, then kill server */
+ timeout_count=0;
+ rc=DosSetPriority(2,3,0,1);
+ do {
+ rc=DosWaitEventSem(hevSwitchRequested,1000L);
+ if(rc==ERROR_TIMEOUT){
+ timeout_count++;
+ if(timeout_count>25){
+ xf86Msg(X_ERROR,
+ "Server timeout on VT switch request. Server was killed\n");
+ DosExit(1L,0);
+ }
+ if(WaitingForAccess) { /* The server is resetting */
+ DosPostEventSem(hevSwitchRequested);
+ xf86Info.vtRequestsPending=FALSE;
+ }
+ }
+ } while (rc==ERROR_TIMEOUT);
+ rc=DosSetPriority(2,2,0,1);
+ }
+ if(NotifyType==1) rc=DosPostEventSem(hevServerHasFocus);
+ if((NotifyType==0)&&(!SwitchedToWPS))
+ xf86Msg(X_ERROR,
+ "Abnormal switching away from server!\n");
+ } /* endwhile */
+
+/* End of thread */
+}
+
+/* This function is run as a thread and will notify of hard-error events */
+void os2HardErrorNotify(arg)
+void * arg;
+{
+ USHORT Indic;
+ USHORT NotifyType;
+ APIRET rc;
+ ULONG postCount;
+
+ rc=DosCreateEventSem(NULL,&hevErrorPopupDetected,0L,FALSE);
+ rc=DosPostEventSem(hevErrorPopupDetected);
+ os2PopupErrorPending=FALSE;
+
+ while(1) {
+ Indic=0;
+ rc=VioModeWait(Indic,&NotifyType,(HVIO)0);
+ if(NotifyType==0){
+ os2PopupErrorPending=TRUE;
+ rc=DosPostEventSem(hSwitchToSem);
+ rc=DosResetEventSem(hevErrorPopupDetected,&postCount);
+ rc=DosWaitEventSem(hevErrorPopupDetected,20000L);
+ if(rc==ERROR_TIMEOUT) GiveUp(0); /* Shutdown on timeout of semaphore */
+ }
+ } /* endwhile */
+
+/* End of thread */
+}
+
+static BOOL is_redirected = FALSE;
+
+static void
+redirect_output(void)
+{
+ /* hv300996 create redirect file on boot drive, instead
+ * anywhere you are just standing
+ */
+ char buf[20],dr[3];
+ ULONG drive;
+ APIRET rc;
+
+ if (is_redirected) return;
+
+ if ((rc = DosQuerySysInfo(5,5,&drive,sizeof(drive))) != 0)
+ dr[0] = 0;
+ else {
+ dr[0] = drive+96;
+ dr[1] = ':';
+ dr[2] = 0;
+ }
+ sprintf(buf,"%s\\xf86log.os2",dr);
+
+ ErrorF("\nThis is the XFree86/OS2-4.0 server\n");
+ ErrorF("\nAll output from now on will be redirected to %s\n",buf);
+ freopen(buf,"w",stderr);
+
+ is_redirected = TRUE;
+}
+
+void
+os2ServerVideoAccess()
+{
+ APIRET rc;
+ ULONG fgSession;
+ ULONG length=4;
+ CHAR Status;
+
+ /* Redirect output as early as possible */
+ /* redirect_output(); */
+ /* too many logfiles, server will log to /usr/adm */
+
+/* Wait for screen access. This is called at server reset or at server startup */
+/* Here we do some waiting until this session comes in the foreground before *
+ * going any further. This is because we may have been started in the bg */
+
+ if(serverGeneration==1){
+ rc=VioScrLock(0, &Status, (HVIO)0);
+ while(Status != 0){
+ rc=VioScrLock(0, &Status, (HVIO)0);
+ DosSleep(1000);
+ }
+ VioScrUnLock((HVIO)0);
+ return;
+ }
+ WaitingForAccess=TRUE;
+ rc=DosWaitEventSem(hevServerHasFocus,SEM_INDEFINITE_WAIT);
+ WaitingForAccess=FALSE;
+ SwitchedToWPS=FALSE; /* In case server has reset while we were switched to WPS */
+}
+
+/* This next function will attempt to recover from a hard error popup
+ * with an EnterLeave call
+ */
+
+void os2RecoverFromPopup()
+{
+ int j;
+ ULONG postCount;
+
+ if (os2PopupErrorPending) {
+#if 0
+ for (j = 0; j < screenInfo.numScreens; j++)
+ (XF86SCRNINFO(screenInfo.screens[j])->EnterLeaveVT)(LEAVE, j);
+ for (j = 0; j < screenInfo.numScreens; j++)
+ (XF86SCRNINFO(screenInfo.screens[j])->EnterLeaveVT)(ENTER, j);
+#endif
+ DosResetEventSem(hSwitchToSem,&postCount);
+
+ for (j = 0; j < xf86NumScreens; j++) {
+ if (xf86Screens[j]->EnableDisableFBAccess)
+ (*xf86Screens[j]->EnableDisableFBAccess)(j, FALSE);
+ }
+ xf86EnterServerState(SETUP);
+ for (j = 0; j < xf86NumScreens; j++)
+ xf86Screens[j]->LeaveVT(j, 0);
+ for (j = 0; j < xf86NumScreens; j++) {
+ xf86Screens[j]->EnterVT(j, 0);
+ }
+ xf86EnterServerState(OPERATING);
+ for (j = 0; j < xf86NumScreens; j++) {
+ if (xf86Screens[j]->EnableDisableFBAccess)
+ (*xf86Screens[j]->EnableDisableFBAccess)(j, TRUE);
+ }
+
+ /* We reset the state of the control key */
+ os2PostKbdEvent(KEY_LCtrl,1);
+ os2PostKbdEvent(KEY_LCtrl,0);
+ os2PostKbdEvent(KEY_RCtrl,1);
+ os2PostKbdEvent(KEY_RCtrl,0);
+ os2PostKbdEvent(KEY_Alt,1);
+ os2PostKbdEvent(KEY_Alt,0);
+
+ /* Turn screen saver off when switching back */
+ SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset);
+ os2PopupErrorPending=FALSE;
+ DosPostEventSem(hevErrorPopupDetected);
+ }
+}
+
+/* This checks wether a popup event is waiting. The semaphore would be reset
+ * by the XF86VIO.DLL function
+ */
+
+void os2CheckPopupPending()
+{
+ int j;
+ ULONG postCount;
+
+ return; /* For now this is a no-op */
+
+#if 0
+ DosQueryEventSem(hevPopupPending,&postCount);
+ if (postCount==0) { /* We have a popup pending */
+#if 0
+ for (j = 0; j < screenInfo.numScreens; j++)
+ (XF86SCRNINFO(screenInfo.screens[j])->EnterLeaveVT)(LEAVE, j);
+#endif
+ DosPostEventSem(hevPopupPending);
+ }
+#endif
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_bios.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_bios.c
new file mode 100644
index 000000000..4069ad745
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_bios.c
@@ -0,0 +1,143 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_bios.c,v 3.10 2000/04/05 18:13:52 dawes Exp $ */
+/*
+ * (c) Copyright 1994 by Holger Veit
+ * <Holger.Veit@gmd.de>
+ * Modified 1996 by Sebastien Marineau <marineau@genie.uottawa.ca>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Holger Veit shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Holger Veit.
+ *
+ */
+/* $XConsortium: os2_bios.c /main/5 1996/10/27 11:48:45 kaleb $ */
+
+#define I_NEED_OS2_H
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#define INCL_32
+#define INCL_DOS
+#define INCL_DOSFILEMGR
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+/*
+ * Read BIOS via xf86sup.SYS device driver
+ */
+
+static APIRET doioctl(HFILE fd,ULONG addr,ULONG len,unsigned char* dbuf)
+{
+ UCHAR *dta;
+ ULONG plen,dlen;
+ APIRET rc;
+
+ struct {
+ ULONG command;
+ ULONG physaddr;
+ USHORT numbytes;
+ } par;
+
+ /* prepare parameter and data packets for ioctl */
+ par.command = 0;
+ par.physaddr = addr;
+ par.numbytes = dlen = len;
+ plen = sizeof(par);
+
+ /* issue call to get a readonly copy of BIOS ROM */
+ rc = DosDevIOCtl(fd, (ULONG)0x76, (ULONG)0x64,
+ (PVOID)&par, (ULONG)plen, (PULONG)&plen,
+ (PVOID)dbuf, (ULONG)dlen, (PULONG)&dlen);
+
+ return rc;
+}
+
+int xf86ReadBIOS(Base, Offset, Buf, Len)
+unsigned long Base;
+unsigned long Offset;
+unsigned char *Buf;
+int Len;
+{
+ HFILE fd;
+ int i;
+ ULONG action;
+ APIRET rc;
+ ULONG Phys_address;
+ UCHAR* dta;
+ int off, chunksz,lensave;
+
+ /* allocate dta */
+ dta = (UCHAR*)xalloc(Len);
+
+ Phys_address=Base+Offset;
+
+ /* open the special device pmap$ (default with OS/2) */
+ if (DosOpen((PSZ)"PMAP$", (PHFILE)&fd, (PULONG)&action,
+ (ULONG)0, FILE_SYSTEM, FILE_OPEN,
+ OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT|OPEN_ACCESS_READONLY,
+ (ULONG)0) != 0) {
+ FatalError("xf86ReadBIOS: install DEVICE=path\\xf86sup.SYS!");
+ return -1;
+ }
+
+ /* copy 32K at a time */
+ off = 0;
+ lensave = Len;
+ while (Len > 0) {
+ chunksz = (Len > 32768) ? 32768 : Len;
+ Len -= chunksz;
+ rc = doioctl(fd,(ULONG)Phys_address,chunksz,dta+off);
+ if (rc != 0) {
+ FatalError("xf86ReadBIOS: BIOS map failed, addr=%lx, rc=%d\n",
+ Phys_address,rc);
+ xfree(dta);
+ DosClose(fd);
+ return -1;
+ }
+ off += chunksz;
+ }
+
+ /*
+ * Sanity check... No longer fatal, as some PS/1 and PS/2 fail here but still work.
+ * S. Marineau, 10/10/96
+ */
+#if 0
+ if ((Phys_address & 0x7fff) != 0 &&
+ (dta[0] != 0x55 || dta[1] != 0xaa)) {
+ FatalError("BIOS sanity check failed, addr=%x\nPlease report if you encounter problems\n",
+ Phys_address);
+ }
+#endif
+
+ /* copy data to buffer */
+ memcpy(Buf, dta, lensave);
+ xfree(dta);
+
+ /* close device */
+ DosClose(fd);
+
+ return(lensave);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_diag.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_diag.c
new file mode 100644
index 000000000..f321df5c2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_diag.c
@@ -0,0 +1,263 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_diag.c,v 3.7 2000/04/05 18:13:52 dawes Exp $ */
+/*
+ * (c) Copyright 1997 by Holger Veit
+ * <Holger.Veit@gmd.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Holger Veit shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Holger Veit.
+ *
+ */
+/* $XConsortium$ */
+
+/* This file checks whether the user has installed the system correctly,
+ * to avoid the numerous questions why this or that does not work
+ */
+
+#define I_NEED_OS2_H
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#define INCL_DOSFILEMGR
+#define INCL_KBD
+#define INCL_VIO
+#define INCL_DOSMISC
+#define INCL_DOSPROCESS
+#define INCL_DOSSEMAPHORES
+#define INCL_DOSMODULEMGR
+#define INCL_DOSFILEMGR
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include <netdb.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+static BOOL diag_checks = FALSE;
+
+/* from Eberhard to check for the right EMX version */
+static void
+check_emx (void)
+{
+ ULONG rc;
+ HMODULE hmod;
+ char name[CCHMAXPATH];
+ char fail[9];
+
+ if (_emx_rev < 50) {
+ xf86Msg(X_ERROR,"This program requires emx.dll revision 50 (0.9c fix 2) "
+ "or later.\n");
+ rc = DosLoadModule (fail, sizeof (fail), "emx", &hmod);
+ if (rc == 0) {
+ rc = DosQueryModuleName (hmod, sizeof (name), name);
+ if (rc == 0)
+ xf86Msg(X_ERROR,"Please delete or update `%s'.\n", name);
+ DosFreeModule (hmod);
+ }
+ exit (2);
+ }
+}
+
+static void
+check_bsl(const char *var)
+{
+ char *t1 = strrchr(var,'\\');
+ if (strchr(var,'/')) {
+ xf86Msg(X_WARNING,
+ "\"%s\" must exclusively use backward slashes \"\\\"\n",
+ var);
+ }
+ if (t1 && *(t1+1)=='\0') {
+ xf86Msg(X_WARNING,
+ "\"%s\" mustn't end with \"\\\"\n",var);
+ *t1 = '\0';
+ }
+}
+
+
+static void
+check_fsl(const char *var)
+{
+ char *t1 = strrchr(var,'/');
+ if (strchr(var,'\\')) {
+ xf86Msg(X_WARNING,
+ "\"%s\" must exclusively use forward slashes \"/\"\n",
+ var);
+ }
+}
+
+
+static void
+check_long(const char* path)
+{
+ FILE *f;
+ char n[300];
+
+ sprintf(n,"%s\\xf86_test_for_very_long_filename",path);
+ f = fopen(n,"w");
+ if (f==NULL) {
+ xf86Msg(X_WARNING,
+ "\"%s\" does not accept long filenames\nmust reside on HPFS or similar\n",
+ path);
+ } else {
+ fclose(f);
+ unlink(n);
+ }
+}
+
+static char *
+check_env_present(const char *env)
+{
+ char *e = getenv(env);
+ if (!e) {
+ xf86Msg(X_WARNING,
+ "You have no \"%s\" environment variable, but need one\n",
+ env);
+ return 0;
+ }
+ return e;
+}
+
+void os2_checkinstallation(void)
+{
+ char *emxopt, *tmp, *home, *logname, *termcap;
+ char hostname[256], *display, *hostvar, *s, *h;
+ struct hostent *hent;
+ struct in_addr *in;
+ int i;
+
+ if (diag_checks) return;
+ diag_checks = TRUE;
+
+ /* test whether the EMX version is okay */
+ check_emx();
+
+ /* Check a number of environment variables */
+ emxopt = getenv("EMXOPT");
+ if (emxopt) {
+ for (i=0; i<strlen(emxopt); i++) {
+ if (emxopt[i]=='-') {
+ switch (emxopt[++i]) {
+ case 't':
+ xf86Msg(X_ERROR,
+ "Remove -t option from EMXOPT variable!\n");
+ break;
+ case 'r':
+ xf86Msg(X_ERROR,
+ "Remove -r option from EMXOPT variable!\n");
+ }
+ }
+ }
+ }
+
+ tmp = check_env_present("TMP");
+ if (tmp) {
+ check_bsl(tmp);
+ check_long(tmp);
+ }
+
+ home = check_env_present("HOME");
+ if (home) {
+ check_bsl(home);
+ check_long(home);
+ }
+
+ logname = check_env_present("LOGNAME");
+ termcap = check_env_present("TERMCAP");
+ if (termcap)
+ check_fsl(termcap);
+
+ if (gethostname(hostname,sizeof(hostname)) != 0) {
+ xf86Msg(X_ERROR,
+ "gethostname() failed: Check TCP/IP setup!\n");
+ } else {
+ xf86Msg(X_INFO,
+ "gethostname() returns: \"%s\"\n",hostname);
+ }
+
+ display = check_env_present("DISPLAY");
+ if (display)
+ xf86Msg(X_INFO,
+ "DISPLAY to listen is set to: \"%s\"\n",
+ display);
+
+ hostvar = check_env_present("HOSTNAME");
+
+ strcpy(hostname,display);
+ h = strchr(hostname,':');
+ if (!h)
+ xf86Msg(X_WARNING,
+ "Invalid DISPLAY name: expected something like XXX:0.0\n");
+ else
+ *h = 0;
+ h = strchr(hostname,'/');
+ if (h)
+ h++;
+ else
+ h = hostname;
+
+ if (stricmp(h,hostvar)) {
+ xf86Msg(X_WARNING,
+ "HOSTNAME does not match DISPLAY: Do you really mean this?\n");
+ xf86Msg(X_WARNING,
+ " This means that xinit/startx and client access may not work\n");
+ xf86Msg(X_WARNING,
+ " which is intentional usually only when connection to a XDM server\n");
+ }
+
+ hent = gethostbyname(h);
+ if (!hent)
+ xf86Msg(X_ERROR,
+ "gethostbyname() failed: Check TCP/IP setup\n");
+ else {
+ xf86Msg(X_INFO,
+ "gethostbyname() returns the following data:\n");
+ xf86Msg(X_INFO," official host name: \"%s\"\n",hent->h_name);
+ while ((s= *(hent->h_aliases)) != NULL) {
+ xf86Msg(X_INFO,
+ " alias: \"%s\"\n",s);
+ hent->h_aliases++;
+ }
+ xf86Msg(X_INFO,
+ " addr type = %d, addr length = %d\n",
+ hent->h_addrtype, hent->h_length);
+ if (hent->h_addrtype == AF_INET) {
+ while ((in= (struct in_addr*)*(hent->h_addr_list++)) != NULL) {
+ xf86Msg(X_INFO,
+ " IP address: \"%s\"\n",
+ inet_ntoa(*in));
+ }
+ } else {
+ xf86Msg(X_INFO,
+ "Addrtype should be %d: Check network setup and install TCP/IP support correctly\n",
+ AF_INET);
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_init.c
new file mode 100644
index 000000000..81b2689b8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_init.c
@@ -0,0 +1,244 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_init.c,v 3.18 2003/11/29 01:48:31 dawes Exp $ */
+/*
+ * (c) Copyright 1994 by Holger Veit
+ * <Holger.Veit@gmd.de>
+ * Modified 1996 Sebastien Marineau <marineau@genie.uottawa.ca>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Holger Veit shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Holger Veit.
+ *
+ */
+/* $XConsortium: os2_init.c /main/9 1996/10/19 18:07:13 kaleb $ */
+
+#define I_NEED_OS2_H
+#define INCL_DOSFILEMGR
+#define INCL_KBD
+#define INCL_VIO
+#define INCL_DOSMISC
+#define INCL_DOSPROCESS
+#define INCL_DOSSEMAPHORES
+#define INCL_DOSMODULEMGR
+#define INCL_DOSFILEMGR
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <float.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+VIOMODEINFO OriginalVideoMode;
+void os2VideoNotify();
+void os2HardErrorNotify();
+void os2KbdMonitorThread();
+void os2KbdBitBucketThread();
+HEV hevPopupPending;
+extern HEV hKbdSem;
+extern BOOL os2HRTimerFlag;
+static unsigned short cw;
+extern void os2_checkinstallation(); /* os2_diag.c */
+
+void xf86OpenConsole()
+{
+ /* try to catch problems before they become obvious */
+ os2_checkinstallation();
+
+ if (serverGeneration == 1) {
+ HKBD fd;
+ ULONG drive;
+ ULONG dummy;
+ KBDHWID hwid;
+ APIRET rc;
+ int VioTid;
+ ULONG actual_handles;
+ LONG new_handles;
+
+ /* hv 250197 workaround for xkb-Problem: switch to X11ROOT drive */
+ char *x11r = getenv("X11ROOT");
+ /* Make sure X11ROOT is set before we go further sm280297 */
+ if (x11r == NULL){
+ xf86Msg(X_ERROR,
+ "Environment variable X11ROOT is not set! Aborting...\n");
+ exit(1);
+ }
+ if (_chdir2(x11r) < 0) {
+ xf86Msg(X_ERROR,"Cannot change to X11ROOT directory!\n");
+ }
+
+ xf86Msg(X_INFO,"Console opened\n");
+ OriginalVideoMode.cb=sizeof(VIOMODEINFO);
+ rc=VioGetMode(&OriginalVideoMode,(HVIO)0);
+ if(rc!=0)
+ xf86Msg(X_ERROR,
+ "Could not get original video mode. RC=%d\n",rc);
+ xf86Info.consoleFd = -1;
+
+ /* Set the number of handles to higher than the default 20. Set to 80 which should be plenty */
+ new_handles = 0;
+ rc = DosSetRelMaxFH(&new_handles,&actual_handles);
+ if (actual_handles < 80) {
+ new_handles = 80 - actual_handles;
+ rc = DosSetRelMaxFH(&new_handles,&actual_handles);
+ xf86Msg(X_INFO,"Increased number of available handles to %d\n",
+ actual_handles);
+ }
+
+ /* grab the keyboard */
+ rc = KbdGetFocus(0,0);
+ if (rc != 0)
+ FatalError("xf86OpenConsole: cannot grab kbd focus, rc=%d\n",rc);
+
+ /* open the keyboard */
+ rc = KbdOpen(&fd);
+ if (rc != 0)
+ FatalError("xf86OpenConsole: cannot open keyboard, rc=%d\n",rc);
+ xf86Info.consoleFd = fd;
+
+ xf86Msg(X_INFO,"Keyboard opened\n");
+
+ /* assign logical keyboard */
+ KbdFreeFocus(0);
+ rc = KbdGetFocus(0,fd);
+ if (rc != 0)
+ FatalError("xf86OpenConsole: cannot set local kbd focus, rc=%d\n",rc);
+
+/* Create kbd queue semaphore */
+
+ rc = DosCreateEventSem(NULL,&hKbdSem,DC_SEM_SHARED,TRUE);
+ if (rc != 0)
+ FatalError("xf86OpenConsole: cannot create keyboard queue semaphore, rc=%d\n",rc);
+
+/* Create popup semaphore */
+
+ rc = DosCreateEventSem("\\SEM32\\XF86PUP",&hevPopupPending,DC_SEM_SHARED,1);
+ if (rc)
+ xf86Msg(X_ERROR,
+ "Could not create popup semaphore! RC=%d\n",rc);
+#if 0
+ rc=VioRegister("xf86vio","XF86POPUP_SUBCLASS",0x20002004L,0L);
+ if (rc) {
+ FatalError("Could not register XF86VIO.DLL module. Please install in LIBPATH! RC=%d\n",
+ rc);
+ }
+#endif
+
+/* Start up the VIO monitor thread */
+ VioTid=_beginthread(os2VideoNotify,NULL,0x4000,(void *)NULL);
+ xf86Msg(X_INFO,"Started Vio thread, Tid=%d\n",VioTid);
+ rc=DosSetPriority(2,3,0,VioTid);
+
+/* Start up the hard-error VIO monitor thread */
+ VioTid=_beginthread(os2HardErrorNotify,NULL,0x4000,(void *)NULL);
+ xf86Msg(X_INFO,"Started hard error Vio mode monitor thread, Tid=%d\n",
+ VioTid);
+ rc=DosSetPriority(2,3,0,VioTid);
+
+/* We have to set the codepage before the keyboard monitor is registered */
+ rc = KbdSetCp(0,0,fd);
+ if(rc != 0)
+ FatalError("xf86OpenConsole: cannot set keyboard codepage, rc=%d\n",rc);
+
+/* Start up the kbd monitor thread */
+ VioTid=_beginthread(os2KbdMonitorThread,NULL,0x4000,(void *)NULL);
+ xf86Msg(X_INFO,"Started Kbd monitor thread, Tid=%d\n",VioTid);
+ rc=DosSetPriority(2,3,0,VioTid);
+
+/* Disable hard-errors through DosError */
+ rc = DosQuerySysInfo(5,5,&drive,sizeof(drive));
+ rc = DosSuppressPopUps(0x0001L,drive+96); /* Disable popups */
+
+ hwid.cb = sizeof(hwid); /* fix crash on P9000 */
+ rc = KbdGetHWID(&hwid, fd);
+ if (rc == 0) {
+ switch (hwid.idKbd) {
+ default:
+ case 0xab54: /* 88/89 key */
+ case 0: /*unknown*/
+ case 1: /*real AT 84 key*/
+ xf86Info.kbdType = KB_84; break;
+ case 0xab85: /* 122 key */
+ FatalError("Unsupported extended 122key keyboard found!\n",0);
+ case 0xab41: /* 101/102 key */
+ xf86Info.kbdType = KB_101; break;
+ }
+ } else
+ xf86Info.kbdType = KB_84; /*defensive*/
+
+/* Start up the Kbd bit-bucket thread. We don't want to leave the kbd events in the driver queue */
+ VioTid=_beginthread(os2KbdBitBucketThread,NULL,0x2000,(void *)NULL);
+ xf86Msg(X_INFO,"Started Kbd bit-bucket thread, Tid=%d\n",VioTid);
+
+/* fg271103: set control word of FPU to default value to prevent SIGFPE in GLX (and elsewhere?) */
+
+#define DEFAULT_X86_FPU 0x037f
+
+ cw = _control87(DEFAULT_X86_FPU, 0xFFFF);
+ xf86Msg(X_INFO,"Checking FPCW: %#x\n",cw);
+
+ if (cw != DEFAULT_X86_FPU) {
+ cw = _control87(0,0);
+ xf86Msg(X_INFO,"Set FPCW to %#x\n",cw);
+ }
+
+ }
+ return;
+}
+
+void xf86CloseConsole()
+{
+ APIRET rc;
+ ULONG drive;
+
+ if (xf86Info.consoleFd != -1) {
+ KbdClose(xf86Info.consoleFd);
+ }
+ VioSetMode(&OriginalVideoMode,(HVIO)0);
+ rc = DosQuerySysInfo(5,5,&drive,sizeof(drive));
+ rc = DosSuppressPopUps(0x0000L,drive+96); /* Reenable popups */
+ rc = DosCloseEventSem(hevPopupPending);
+ rc = VioDeRegister();
+ return;
+}
+
+/* ARGSUSED */
+
+int xf86ProcessArgument (argc, argv, i)
+int argc;
+char *argv[];
+int i;
+{
+ return 0;
+}
+
+void xf86UseMsg()
+{
+ return;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_io.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_io.c
new file mode 100644
index 000000000..e6570aeb9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_io.c
@@ -0,0 +1,257 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_io.c,v 3.19 2003/11/17 22:20:41 dawes Exp $ */
+/*
+ * (c) Copyright 1994,1999 by Holger Veit
+ * <Holger.Veit@gmd.de>
+ * Modified 1996 by Sebastien Marineau <marineau@genie.uottawa.ca>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Holger Veit shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Holger Veit.
+ *
+ */
+/* $XConsortium: os2_io.c /main/9 1996/05/13 16:38:07 kaleb $ */
+
+#define I_NEED_OS2_H
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xpoll.h>
+#include "compiler.h"
+#include <time.h>
+
+#define INCL_DOSPROCESS
+#define INCL_KBD
+#define INCL_MOU
+#define INCL_DOSDEVIOCTL
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+int os2MouseQueueQuery();
+int os2KbdQueueQuery();
+void os2RecoverFromPopup();
+void os2CheckPopupPending();
+extern BOOL os2PopupErrorPending;
+int _select2 (int, fd_set *, fd_set *,fd_set *, struct timeval *);
+
+
+/***************************************************************************/
+
+void xf86SoundKbdBell(loudness, pitch, duration)
+int loudness;
+int pitch;
+int duration;
+{
+ DosBeep((ULONG)pitch, (ULONG)duration);
+}
+
+void xf86SetKbdLeds(leds)
+int leds;
+{
+ KBDINFO kinfo;
+ APIRET rc;
+
+ rc = KbdGetStatus(&kinfo,(HKBD)xf86Info.consoleFd);
+ if (!rc) {
+ kinfo.fsMask = 0x10;
+ kinfo.fsState &= ~0x70;
+ kinfo.fsState |= (leds&0x70);
+ KbdSetStatus(&kinfo,(HKBD)xf86Info.consoleFd);
+ }
+}
+
+int xf86GetKbdLeds()
+{
+ KBDINFO kinfo;
+ APIRET rc;
+
+ rc = KbdGetStatus(&kinfo,(HKBD)xf86Info.consoleFd);
+ return rc ? 0 : kinfo.fsState & 0x70;
+}
+
+void xf86SetKbdRepeat(char rad)
+{
+ int rc;
+ int delay = 250; /* Default delay */
+ int rate = 30; /* Default repeat rate */
+
+ struct {
+ USHORT Delay;
+ USHORT Rate;
+ } rateDelay;
+
+ ULONG rateDelaySize = sizeof(rateDelay);
+
+ /*notyet*/
+ return;
+
+ if (xf86Info.kbdRate >= 0)
+ rate = xf86Info.kbdRate;
+ if (xf86Info.kbdDelay >= 0)
+ delay = xf86Info.kbdDelay;
+
+ rateDelay.Delay = delay;
+ rateDelay.Rate = rate;
+
+ xf86Msg(X_INFO,"Setting typematic rate: Delay=%d, Rate=%d\n",delay,rate);
+
+ rc = DosDevIOCtl( (HFILE) xf86Info.consoleFd,
+ IOCTL_KEYBOARD,
+ KBD_SETTYPAMATICRATE,
+ &rateDelay,
+ rateDelaySize,
+ &rateDelaySize,
+ NULL,
+ 0,
+ NULL);
+ if (rc!=0) {
+ xf86Msg(X_ERROR,"xf86SetKbdRepeat: DosDevIOCtl returned %d\n",rc);
+ }
+}
+
+void xf86KbdInit()
+{
+ /*none required*/
+}
+
+
+USHORT OrigKbdState;
+USHORT OrigKbdInterim;
+
+typedef struct {
+ USHORT state;
+ UCHAR makeCode;
+ UCHAR breakCode;
+ USHORT keyID;
+} HOTKEYPARAM;
+
+
+int xf86KbdOn()
+{
+ KBDINFO info;
+ APIRET rc;
+ int i,k;
+ ULONG len;
+
+
+ KbdGetStatus(&info,(HKBD)xf86Info.consoleFd);
+ OrigKbdState=info.fsMask;
+ OrigKbdInterim=info.fsInterim;
+ info.fsMask &= ~0x09;
+ info.fsMask |= 0x136;
+ info.fsInterim &= ~0x20;
+ KbdSetStatus(&info,(HKBD)xf86Info.consoleFd);
+ return -1;
+}
+
+int xf86KbdOff()
+{
+ ULONG len;
+ APIRET rc;
+ KBDINFO info;
+
+ info.fsMask=OrigKbdState;
+ info.fsInterim=OrigKbdInterim;
+ KbdSetStatus(&info,(HKBD)xf86Info.consoleFd);
+ return -1;
+}
+
+#if 0 /*OBSOLETE*/
+void xf86MouseInit(mouse)
+MouseDevPtr mouse;
+{
+ HMOU fd;
+ APIRET rc;
+ USHORT nbut;
+
+ if (serverGeneration == 1) {
+ rc = MouOpen((PSZ)NULL,(PHMOU)&fd);
+ if (rc != 0)
+ FatalError("Cannot open mouse, rc=%d\n", rc);
+ mouse->mseFd = fd;
+ }
+
+ /* flush mouse queue */
+ MouFlushQue(fd);
+
+ /* check buttons */
+ rc = MouGetNumButtons(&nbut,fd);
+ if (rc == 0)
+ xf86Msg(X_INFO,"OsMouse has %d button(s).\n",nbut);
+}
+#endif
+
+#if 0 /*OBSOLETE*/
+int xf86MouseOn(mouse)
+MouseDevPtr mouse;
+{
+#if 0
+ HMOU fd;
+ APIRET rc;
+ USHORT nbut;
+#endif
+ xf86Msg (X_ERROR,
+ "Calling MouseOn, a bad thing.... Must be some bug in the code!\n");
+
+#if 0
+ if (serverGeneration == 1) {
+ rc = MouOpen((PSZ)NULL,(PHMOU)&fd);
+ if (rc != 0)
+ FatalError("Cannot open mouse, rc=%d\n", rc);
+ mouse->mseFd = fd;
+ }
+
+ /* flush mouse queue */
+ MouFlushQue(fd);
+
+ /* check buttons */
+ rc = MouGetNumButtons(&nbut,fd);
+ if (rc == 0)
+ xf86Msg(X_INFO,"OsMouse has %d button(s).\n",nbut);
+
+ return (mouse->mseFd);
+#endif
+}
+#endif
+
+#if 0 /*OBSOLETE*/
+/* This table is a bit irritating, because these mouse types are infact
+ * defined in the OS/2 kernel, but I want to force the user to put
+ * "OsMouse" in the config file, and not worry about the particular mouse
+ * type that is connected.
+ */
+Bool xf86SupportedMouseTypes[] =
+{
+ FALSE, /* Microsoft */
+ FALSE, /* MouseSystems */
+ FALSE, /* MMSeries */
+ FALSE, /* Logitech */
+ FALSE, /* BusMouse */
+ FALSE, /* MouseMan */
+ FALSE, /* PS/2 */
+ FALSE, /* Hitachi Tablet */
+};
+
+int xf86NumMouseTypes = sizeof(xf86SupportedMouseTypes) /
+ sizeof(xf86SupportedMouseTypes[0]);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_ioperm.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_ioperm.c
new file mode 100644
index 000000000..c03bb96af
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_ioperm.c
@@ -0,0 +1,140 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_ioperm.c,v 3.5 1997/08/26 10:01:38 hohndel Exp $ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ * Modified 1996 by Sebastien Marineau <marineau@genie.uottawa.ca>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: os2_ioperm.c /main/4 1996/04/18 16:50:01 kaleb $ */
+
+
+
+#define I_NEED_OS2_H
+#define INCL_32
+#define INCL_DOS
+#define INCL_DOSFILEMGR
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+/*
+ * To access I/O ports under OS/2, we use the xf86sup.sys driver.
+ * For the moment, we use a function which basically grants IO priviledge
+ * to the whole server. NOTE: Once the server is running, we should
+ * change this to use inline IO functions through the callgate returned by
+ * the fastio$ driver.
+ */
+
+int ioEnabled=FALSE;
+ULONG action;
+char *ioDrvPath = "/dev/fastio$";
+USHORT callgate[3]={0,0,0};
+
+
+Bool xf86EnableIO()
+{
+
+HFILE hfd;
+ ULONG dlen;
+ APIRET rc;
+
+ /* no need to call multiple times */
+ if (ioEnabled) return TRUE;
+
+ if (DosOpen((PSZ)ioDrvPath, (PHFILE)&hfd, (PULONG)&action,
+ (ULONG)0, FILE_SYSTEM, FILE_OPEN,
+ OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT|OPEN_ACCESS_READONLY,
+ (ULONG)0) != 0) {
+ xf86Msg(X_ERROR,"Error opening fastio$ driver...\n");
+ xf86Msg(X_ERROR,"Please install xf86sup.sys in config.sys!\n");
+ return FALSE;
+ }
+ callgate[0] = callgate[1] = 0;
+
+/* Get callgate from driver for fast io to ports and other stuff */
+
+ rc = DosDevIOCtl(hfd, (ULONG)0x76, (ULONG)0x64,
+ NULL, 0, NULL,
+ (ULONG*)&callgate[2], sizeof(USHORT), &dlen);
+ if (rc) {
+ xf86Msg(X_ERROR,
+ "EnableIOPorts failed, rc=%d, dlen=%d; emergency exit\n",
+ rc,dlen);
+ DosClose(hfd);
+ return FALSE;
+ }
+
+/* Calling callgate with function 13 sets IOPL for the program */
+
+ asm volatile ("movl $13,%%ebx;.byte 0xff,0x1d;.long _callgate"
+ : /*no outputs */
+ : /*no inputs */
+ : "eax","ebx","ecx","edx","cc");
+
+ ioEnabled = TRUE;
+ DosClose(hfd);
+ return TRUE;
+}
+
+void xf86DisableIO()
+{
+HFILE hfd;
+ ULONG dlen;
+ APIRET rc;
+
+ /* no need to call multiple times */
+ if (!ioEnabled) return;
+
+ if (DosOpen((PSZ)ioDrvPath, (PHFILE)&hfd, (PULONG)&action,
+ (ULONG)0, FILE_SYSTEM, FILE_OPEN,
+ OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT|OPEN_ACCESS_READONLY,
+ (ULONG)0) != 0) {
+ xf86Msg(X_ERROR,"Error opening fastio$ driver...\n");
+ xf86Msg(X_ERROR,"Please install xf86sup.sys in config.sys!\n");
+ return;
+ }
+ callgate[0] = callgate[1] = 0;
+
+ rc = DosDevIOCtl(hfd, (ULONG)0x76, (ULONG)0x64,
+ NULL, 0, NULL,
+ (ULONG*)&callgate[2], sizeof(USHORT), &dlen);
+ if (rc) {
+ xf86Msg(X_ERROR,"DisableIOPorts failed, rc=%d, dlen=%d\n",
+ rc,dlen);
+ DosClose(hfd);
+ return;
+ }
+
+/* Function 14 of callgate brings program back to ring 3 */
+
+ asm volatile ("movl $14,%%ebx;.byte 0xff,0x1d;.long _callgate"
+ : /*no outputs */
+ : /*no inputs */
+ : "eax","ebx","ecx","edx","cc");
+ ioEnabled=FALSE;
+ DosClose(hfd);
+ return;
+
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_kbd.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_kbd.c
new file mode 100644
index 000000000..f99f12c0f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_kbd.c
@@ -0,0 +1,158 @@
+/*
+ * Copied from os2_io.c which is
+ *
+ * (c) Copyright 1994,1999 by Holger Veit
+ * <Holger.Veit@gmd.de>
+ * Modified 1996 by Sebastien Marineau <marineau@genie.uottawa.ca>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Holger Veit shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Holger Veit.
+ *
+ */
+/* $XFree86$ */
+
+#define I_NEED_OS2_H
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xpoll.h>
+#include "compiler.h"
+#include <time.h>
+
+#define INCL_DOSPROCESS
+#define INCL_KBD
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86Xinput.h"
+#include "xf86OSKbd.h"
+
+
+
+/***************************************************************************/
+
+static void SoundKbdBell(loudness, pitch, duration)
+int loudness;
+int pitch;
+int duration;
+{
+ DosBeep((ULONG)pitch, (ULONG)duration);
+}
+
+static void SetKbdLeds(pInfo, leds)
+InputInfoPtr pInfo;
+int leds;
+{
+ KBDINFO kinfo;
+ APIRET rc;
+
+ rc = KbdGetStatus(&kinfo,(HKBD)xf86Info.consoleFd);
+ if (!rc) {
+ kinfo.fsMask = 0x10;
+ kinfo.fsState &= ~0x70;
+ kinfo.fsState |= (leds&0x70);
+ KbdSetStatus(&kinfo,(HKBD)xf86Info.consoleFd);
+ }
+}
+
+static int GetKbdLeds(pInfo)
+InputInfoPtr pInfo;
+{
+ KBDINFO kinfo;
+ APIRET rc;
+
+ rc = KbdGetStatus(&kinfo,(HKBD)xf86Info.consoleFd);
+ return rc ? 0 : kinfo.fsState & 0x70;
+}
+
+static void SetKbdRepeat(pInfo, rad)
+InputInfoPtr pInfo;
+char rad;
+{
+ /*notyet*/
+}
+
+static void KbdInit(pInfo)
+InputInfoPtr pInfo;
+{
+ /*none required*/
+ xf86Msg(X_INFO,"XKB module: Keyboard initialized\n");
+}
+
+
+static USHORT OrigKbdState;
+static USHORT OrigKbdInterim;
+
+typedef struct {
+ USHORT state;
+ UCHAR makeCode;
+ UCHAR breakCode;
+ USHORT keyID;
+} HOTKEYPARAM;
+
+
+static int KbdOn(pInfo)
+InputInfoPtr pInfo;
+{
+ KBDINFO info;
+
+ KbdGetStatus(&info,(HKBD)xf86Info.consoleFd);
+ OrigKbdState=info.fsMask;
+ OrigKbdInterim=info.fsInterim;
+ info.fsMask &= ~0x09;
+ info.fsMask |= 0x136;
+ info.fsInterim &= ~0x20;
+ KbdSetStatus(&info,(HKBD)xf86Info.consoleFd);
+ return -1;
+}
+
+static int KbdOff(pInfo)
+InputInfoPtr pInfo;
+{
+ KBDINFO info;
+
+ info.fsMask=OrigKbdState;
+ info.fsInterim=OrigKbdInterim;
+ KbdSetStatus(&info,(HKBD)xf86Info.consoleFd);
+ return -1;
+}
+
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = pInfo->private;
+
+ pKbd->KbdInit = KbdInit;
+ pKbd->KbdOn = KbdOn;
+ pKbd->KbdOff = KbdOff;
+ pKbd->Bell = SoundKbdBell;
+ pKbd->SetLeds = SetKbdLeds;
+ pKbd->GetLeds = GetKbdLeds;
+ pKbd->SetKbdRepeat = SetKbdRepeat;
+
+ pKbd->vtSwitchSupported = FALSE;
+
+ /* not yet */
+ return FALSE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_kbdEv.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_kbdEv.c
new file mode 100644
index 000000000..861fbf089
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_kbdEv.c
@@ -0,0 +1,511 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_kbdEv.c,v 3.16 2002/05/31 18:46:01 dawes Exp $ */
+/*
+ * (c) Copyright 1994,1996,1999 by Holger Veit
+ * <Holger.Veit@gmd.de>
+ * Modified 1996 Sebastien Marineau <marineau@genie.uottawa.ca>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Holger Veit shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Holger Veit.
+ *
+ */
+/* $XConsortium: os2_kbdEv.c /main/10 1996/10/27 11:48:48 kaleb $ */
+
+#define I_NEED_OS2_H
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+
+#define INCL_KBD
+#define INCL_DOSMONITORS
+#define INCL_WINSWITCHLIST
+#define INCL_DOSQUEUES
+#undef RT_FONT /* must discard this */
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "atKeynames.h"
+
+/* Attention! these lines copied from ../../common/xf86Events.c */
+#define XE_POINTER 1
+#define XE_KEYBOARD 2
+
+#ifdef XKB
+extern Bool noXkbExtension;
+#endif
+
+#ifdef XTESTEXT1
+
+#define XTestSERVER_SIDE
+#include <X11/extensions/xtestext1.h>
+extern short xtest_mousex;
+extern short xtest_mousey;
+extern int on_steal_input;
+extern Bool XTestStealKeyData();
+extern void XTestStealMotionData();
+
+#ifdef XINPUT
+#define ENQUEUE(ev, code, direction, dev_type) \
+ (ev)->u.u.detail = (code); \
+ (ev)->u.u.type = (direction); \
+ if (!on_steal_input || \
+ XTestStealKeyData((ev)->u.u.detail, (ev)->u.u.type, dev_type, \
+ xtest_mousex, xtest_mousey)) \
+ xf86eqEnqueue((ev))
+#else
+#define ENQUEUE(ev, code, direction, dev_type) \
+ (ev)->u.u.detail = (code); \
+ (ev)->u.u.type = (direction); \
+ if (!on_steal_input || \
+ XTestStealKeyData((ev)->u.u.detail, (ev)->u.u.type, dev_type, \
+ xtest_mousex, xtest_mousey)) \
+ mieqEnqueue((ev))
+#endif
+
+#define MOVEPOINTER(dx, dy, time) \
+ if (on_steal_input) \
+ XTestStealMotionData(dx, dy, XE_POINTER, xtest_mousex, xtest_mousey); \
+ miPointerDeltaCursor (dx, dy, time)
+
+#else /* ! XTESTEXT1 */
+
+#ifdef XINPUT
+#define ENQUEUE(ev, code, direction, dev_type) \
+ (ev)->u.u.detail = (code); \
+ (ev)->u.u.type = (direction); \
+ xf86eqEnqueue((ev))
+#else
+#define ENQUEUE(ev, code, direction, dev_type) \
+ (ev)->u.u.detail = (code); \
+ (ev)->u.u.type = (direction); \
+ mieqEnqueue((ev))
+#endif
+#define MOVEPOINTER(dx, dy, time) \
+ miPointerDeltaCursor (dx, dy, time)
+
+#endif
+/* end of include */
+
+HQUEUE hKbdQueue;
+HEV hKbdSem;
+int last_status;
+int lastStatus;
+int lastShiftState;
+extern BOOL SwitchedToWPS;
+
+void os2PostKbdEvent();
+
+int os2KbdQueueQuery()
+{
+ ULONG numElements,postCount;
+
+ (void)DosQueryQueue(hKbdQueue,&numElements);
+ if (numElements!=0) return 0; /* We have something in queue */
+
+ DosResetEventSem(hKbdSem,&postCount);
+ return 1;
+}
+
+
+void xf86KbdEvents()
+{
+ KBDKEYINFO keybuf;
+ ULONG numElements;
+ REQUESTDATA requestData;
+ ULONG dataLength, postCount;
+ PVOID dummy;
+ BYTE elemPriority;
+ int scan, down;
+ static int last;
+ USHORT ModState;
+ int i;
+
+ while(DosReadQueue(hKbdQueue,
+ &requestData,&dataLength,&dummy,
+ 0L,1L,&elemPriority,hKbdSem) == 0) {
+
+ /* xf86Msg(X_INFO,
+ "Got queue element. data=%d, scancode =%d,up=%d, ddflag %d\n",
+ requestData.ulData,
+ (requestData.ulData&0x7F00)>>8,
+ requestData.ulData&0x8000,
+ requestData.ulData>>16);*/
+
+ scan=(requestData.ulData&0x7F00)>>8;
+
+ /* the separate cursor keys return 0xe0/scan */
+ if ((requestData.ulData & 0x3F0000)==0x20000) scan=0;
+ if (requestData.ulData & 0x800000) {
+ switch (scan) {
+
+/* BUG ALERT: IBM has in its keyboard driver a 122 key keyboard, which
+ * uses the "server generated scancodes" from atKeynames.h as real scan codes.
+ * We wait until some poor guy with such a keyboard will break the whole
+ * card house though...
+ */
+ case KEY_KP_7: scan = KEY_Home; break;
+ case KEY_KP_8: scan = KEY_Up; break;
+ case KEY_KP_9: scan = KEY_PgUp; break;
+ case KEY_KP_4: scan = KEY_Left; break;
+ case KEY_KP_5: scan = KEY_Begin; break;
+ case KEY_KP_6: scan = KEY_Right; break;
+ case KEY_KP_1: scan = KEY_End; break;
+ case KEY_KP_2: scan = KEY_Down; break;
+ case KEY_KP_3: scan = KEY_PgDown; break;
+ case KEY_KP_0: scan = KEY_Insert; break;
+ case KEY_KP_Decimal: scan = KEY_Delete; break;
+ case KEY_Enter: scan = KEY_KP_Enter; break;
+ case KEY_LCtrl: scan = KEY_RCtrl; break;
+ case KEY_KP_Multiply: scan = KEY_Print; break;
+ case KEY_Slash: scan = KEY_KP_Divide; break;
+ case KEY_Alt: scan = KEY_AltLang; break;
+ case KEY_ScrollLock: scan = KEY_Break; break;
+ case 0x5b: scan = KEY_LMeta; break;
+ case 0x5c: scan = KEY_RMeta; break;
+ case 0x5d: scan = KEY_Menu; break;
+ default:
+ /* virtual shifts: ignore */
+ scan = 0; break;
+ }
+ }
+
+ down = (requestData.ulData&0x8000) ? FALSE : TRUE;
+ if (scan!=0) os2PostKbdEvent(scan, down);
+ }
+ (void)DosResetEventSem(hKbdSem,&postCount);
+}
+
+/*
+ * xf86PostKbdEvent --
+ * Translate the raw hardware KbdEvent into an XEvent, and tell DIX
+ * about it. Scancode preprocessing and so on is done ...
+ *
+ * OS/2 specific xf86PostKbdEvent(key) has been moved from common/xf86Events.c
+ * as some things differ, and I didn't want to scatter this routine with
+ * ifdefs further (hv).
+ */
+
+void os2PostKbdEvent(unsigned scanCode, Bool down)
+{
+ KeyClassRec *keyc = ((DeviceIntPtr)xf86Info.pKeyboard)->key;
+ Bool updateLeds = FALSE;
+ Bool UsePrefix = FALSE;
+ Bool Direction = FALSE;
+ xEvent kevent;
+ KeySym *keysym;
+ int keycode;
+ static int lockkeys = 0;
+
+ /*
+ * and now get some special keysequences
+ */
+ if ((ModifierDown(ControlMask | AltMask)) ||
+ (ModifierDown(ControlMask | AltLangMask))) {
+ switch (scanCode) {
+ case KEY_BackSpace:
+ if (!xf86Info.dontZap) GiveUp(0);
+ return;
+ case KEY_KP_Minus: /* Keypad - */
+ if (!xf86Info.dontZoom) {
+ if (down)
+ xf86ZoomViewport(xf86Info.currentScreen, -1);
+ return;
+ }
+ break;
+ case KEY_KP_Plus: /* Keypad + */
+ if (!xf86Info.dontZoom) {
+ if (down)
+ xf86ZoomViewport(xf86Info.currentScreen, 1);
+ return;
+ }
+ break;
+ }
+ }
+
+ /* CTRL-ESC is std OS/2 hotkey for going back to PM and popping up
+ * window list... handled by keyboard driverand PM if you tell it. This is
+ * what we have done, and thus should never detect this key combo */
+ if (ModifierDown(ControlMask) && scanCode==KEY_Escape) {
+ /* eat it */
+ return;
+ } else if (ModifierDown(AltLangMask|AltMask) && scanCode==KEY_Escape) {
+ /* same here */
+ return;
+ }
+
+ /*
+ * Now map the scancodes to real X-keycodes ...
+ */
+ keycode = scanCode + MIN_KEYCODE;
+ keysym = (keyc->curKeySyms.map +
+ keyc->curKeySyms.mapWidth *
+ (keycode - keyc->curKeySyms.minKeyCode));
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ /* Filter autorepeated caps/num/scroll lock keycodes. */
+
+#define CAPSFLAG 0x01
+#define NUMFLAG 0x02
+#define SCROLLFLAG 0x04
+#define MODEFLAG 0x08
+ if (down) {
+ switch (keysym[0]) {
+ case XK_Caps_Lock:
+ if (lockkeys & CAPSFLAG)
+ return;
+ else
+ lockkeys |= CAPSFLAG;
+ break;
+ case XK_Num_Lock:
+ if (lockkeys & NUMFLAG)
+ return;
+ else
+ lockkeys |= NUMFLAG;
+ break;
+ case XK_Scroll_Lock:
+ if (lockkeys & SCROLLFLAG)
+ return;
+ else
+ lockkeys |= SCROLLFLAG;
+ break;
+ }
+
+ if (keysym[1] == XF86XK_ModeLock) {
+ if (lockkeys & MODEFLAG)
+ return;
+ else
+ lockkeys |= MODEFLAG;
+ }
+ } else {
+ switch (keysym[0]) {
+ case XK_Caps_Lock:
+ lockkeys &= ~CAPSFLAG;
+ break;
+ case XK_Num_Lock:
+ lockkeys &= ~NUMFLAG;
+ break;
+ case XK_Scroll_Lock:
+ lockkeys &= ~SCROLLFLAG;
+ break;
+ }
+
+ if (keysym[1] == XF86XK_ModeLock)
+ lockkeys &= ~MODEFLAG;
+ }
+
+ /*
+ * LockKey special handling:
+ * ignore releases, toggle on & off on presses.
+ * Don't deal with the Caps_Lock keysym directly,
+ * but check the lock modifier
+ */
+#ifndef PC98
+ if (keyc->modifierMap[keycode] & LockMask ||
+ keysym[0] == XK_Scroll_Lock ||
+ keysym[1] == XF86XK_ModeLock ||
+ keysym[0] == XK_Num_Lock) {
+ Bool flag;
+
+ if (!down) return;
+ flag = !KeyPressed(keycode);
+ if (!flag) down = !down;
+
+ if (keyc->modifierMap[keycode] & LockMask)
+ xf86Info.capsLock = flag;
+ if (keysym[0] == XK_Num_Lock)
+ xf86Info.numLock = flag;
+ if (keysym[0] == XK_Scroll_Lock)
+ xf86Info.scrollLock = flag;
+ if (keysym[1] == XF86XK_ModeLock)
+ xf86Info.modeSwitchLock = flag;
+ updateLeds = TRUE;
+ }
+#endif /* not PC98 */
+
+ /* normal, non-keypad keys */
+ if (scanCode < KEY_KP_7 || scanCode > KEY_KP_Decimal) {
+ /* magic ALT_L key on AT84 keyboards for multilingual support */
+ if (xf86Info.kbdType == KB_84 &&
+ ModifierDown(AltMask) &&
+ keysym[2] != NoSymbol) {
+ UsePrefix = TRUE;
+ Direction = TRUE;
+ }
+ }
+
+#ifdef XKB /* Warning: got position wrong first time */
+ }
+#endif
+
+ /* check for an autorepeat-event */
+ if ((down && KeyPressed(keycode)) &&
+ (xf86Info.autoRepeat != AutoRepeatModeOn || keyc->modifierMap[keycode]))
+ return;
+
+ xf86Info.lastEventTime =
+ kevent.u.keyButtonPointer.time =
+ GetTimeInMillis();
+
+ /*
+ * And now send these prefixes ...
+ * NOTE: There cannot be multiple Mode_Switch keys !!!!
+ */
+ if (UsePrefix) {
+ ENQUEUE(&kevent,
+ keyc->modifierKeyMap[keyc->maxKeysPerModifier*7],
+ Direction ? KeyPress : KeyRelease,
+ XE_KEYBOARD);
+ ENQUEUE(&kevent,
+ keycode,
+ down ? KeyPress : KeyRelease,
+ XE_KEYBOARD);
+ ENQUEUE(&kevent,
+ keyc->modifierKeyMap[keyc->maxKeysPerModifier*7],
+ Direction ? KeyRelease : KeyPress,
+ XE_KEYBOARD);
+ } else {
+#ifdef XFreeDGA
+ if (((ScrnInfoPtr)(xf86Info.currentScreen->devPrivates[xf86ScreenIndex].ptr))->directMode&XF86DGADirectKeyb) {
+ XF86DirectVideoKeyEvent(&kevent,
+ keycode,
+ down ? KeyPress : KeyRelease);
+ } else
+#endif
+ {
+ ENQUEUE(&kevent,
+ keycode,
+ down ? KeyPress : KeyRelease,
+ XE_KEYBOARD);
+ }
+ }
+
+ if (updateLeds) xf86KbdLeds();
+}
+
+#pragma pack(1)
+struct KeyPacket {
+ unsigned short mnflags;
+ KBDKEYINFO cp;
+ unsigned short ddflags;
+};
+#pragma pack()
+
+/* The next function runs as a thread. It registers a monitor on the kbd
+ * driver, and uses that to get keystrokes. This is because the standard
+ * OS/2 keyboard driver does not send keyboard release events. A queue
+ * is used to communicate with the main thread to send keystrokes */
+
+void os2KbdMonitorThread(void* arg)
+{
+ struct KeyPacket packet;
+ APIRET rc;
+ USHORT length,print_flag;
+ ULONG queueParam;
+ HMONITOR hKbdMonitor;
+ MONIN monInbuf;
+ MONOUT monOutbuf;
+ char queueName[128];
+
+#if 0
+ monInbuf=(MONIN *)_tmalloc(2*sizeof(MONIN));
+ if (monInbuf==NULL) {
+ xf86Msg(X_ERROR,
+ "Could not allocate memory in kbd monitor thread!\n");
+ exit(1);
+ }
+ monOutbuf=(MONOUT *) &monInbuf[1];
+#endif
+
+ monInbuf.cb=sizeof(MONIN);
+ monOutbuf.cb=sizeof(MONOUT);
+
+ rc = DosMonOpen("KBD$",&hKbdMonitor);
+ xf86Msg(X_INFO,"Opened kbd monitor, rc=%d\n",rc);
+ rc = DosMonReg(hKbdMonitor,
+ (PBYTE)&monInbuf,(PBYTE)&monOutbuf,(USHORT)2,(USHORT)-1);
+ xf86Msg(X_INFO,"Kbd monitor registered, rc=%d\n",rc);
+ if (rc) {
+ DosMonClose(hKbdMonitor);
+ exit(1);
+ }
+
+ /* create a queue */
+ sprintf(queueName,"\\QUEUES\\XF86KBD\\%d",getpid());
+ rc = DosCreateQueue(&hKbdQueue,0L,queueName);
+ xf86Msg(X_INFO,"Kbd Queue created, rc=%d\n",rc);
+ (void)DosPurgeQueue(hKbdQueue);
+
+ while (1) {
+ length = sizeof(packet);
+ rc = DosMonRead((PBYTE)&monInbuf,0,(PBYTE)&packet,&length);
+ if (rc) {
+ xf86Msg(X_ERROR,
+ "DosMonRead returned bad RC! rc=%d\n",rc);
+ DosMonClose(hKbdMonitor);
+ exit(1);
+ }
+ queueParam = packet.mnflags+(packet.ddflags<<16);
+ if (packet.mnflags&0x7F00)
+ DosWriteQueue(hKbdQueue,queueParam,0L,NULL,0L);
+ /*xf86Msg(X_INFO,"Wrote a char to queue, rc=%d\n",rc); */
+ print_flag = packet.ddflags & 0x1F;
+
+ /*xf86Msg(X_INFO,"Kbd Monitor: Key press %d, scan code %d, ddflags %d\n",
+ packet.mnflags&0x8000,(packet.mnflags&0x7F00)>>8,packet.ddflags);
+ */
+
+ /* This line will swallow print-screen keypresses */
+ if (print_flag == 0x13 || print_flag == 0x14 ||
+ print_flag == 0x15 || print_flag == 0x16)
+ rc = 0;
+ else
+ rc = DosMonWrite((PBYTE)&monOutbuf,(PBYTE)&packet,length);
+ if (rc) {
+ xf86Msg(X_ERROR,
+ "DosMonWrite returned bad RC! rc=%d\n",rc);
+ DosMonClose(hKbdMonitor);
+ exit(1);
+ }
+ }
+
+ DosCloseQueue(hKbdQueue);
+ DosMonClose(hKbdMonitor);
+}
+
+void os2KbdBitBucketThread(void* arg)
+{
+ KBDKEYINFO key;
+ while (1) {
+ if (xf86Info.consoleFd != -1) {
+ KbdCharIn(&key,1,xf86Info.consoleFd);
+ usleep(100000);
+ } else
+ usleep(500000);
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_mouse.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_mouse.c
new file mode 100644
index 000000000..e1fd52c2e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_mouse.c
@@ -0,0 +1,653 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_mouse.c,v 3.17 2002/05/31 18:46:02 dawes Exp $ */
+/*
+ * (c) Copyright 1994,1999,2000 by Holger Veit
+ * <Holger.Veit@gmd.de>
+ * Modified (c) 1996 Sebastien Marineau <marineau@genie.uottawa.ca>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Holger Veit shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Holger Veit.
+ *
+ */
+/* $XConsortium: os2_mouse.c /main/10 1996/10/27 11:48:51 kaleb $ */
+
+#define I_NEED_OS2_H
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#define INCL_DOSFILEMGR
+#define INCL_DOSQUEUES
+#define INCL_MOU
+#undef RT_FONT
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86Config.h"
+
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+#include "mipointer.h"
+
+/* The following support code was copied from mouse.c */
+
+/**********************************************************************
+ *
+ * Emulate3Button support code
+ *
+ **********************************************************************/
+
+
+/*
+ * Lets create a simple finite-state machine for 3 button emulation:
+ *
+ * We track buttons 1 and 3 (left and right). There are 11 states:
+ * 0 ground - initial state
+ * 1 delayed left - left pressed, waiting for right
+ * 2 delayed right - right pressed, waiting for left
+ * 3 pressed middle - right and left pressed, emulated middle sent
+ * 4 pressed left - left pressed and sent
+ * 5 pressed right - right pressed and sent
+ * 6 released left - left released after emulated middle
+ * 7 released right - right released after emulated middle
+ * 8 repressed left - left pressed after released left
+ * 9 repressed right - right pressed after released right
+ * 10 pressed both - both pressed, not emulating middle
+ *
+ * At each state, we need handlers for the following events
+ * 0: no buttons down
+ * 1: left button down
+ * 2: right button down
+ * 3: both buttons down
+ * 4: emulate3Timeout passed without a button change
+ * Note that button events are not deltas, they are the set of buttons being
+ * pressed now. It's possible (ie, mouse hardware does it) to go from (eg)
+ * left down to right down without anything in between, so all cases must be
+ * handled.
+ *
+ * a handler consists of three values:
+ * 0: action1
+ * 1: action2
+ * 2: new emulation state
+ *
+ * action > 0: ButtonPress
+ * action = 0: nothing
+ * action < 0: ButtonRelease
+ *
+ * The comment preceeding each section is the current emulation state.
+ * The comments to the right are of the form
+ * <button state> (<events>) -> <new emulation state>
+ * which should be read as
+ * If the buttons are in <button state>, generate <events> then go to
+ * <new emulation state>.
+ */
+static signed char stateTab[11][5][3] = {
+/* 0 ground */
+ {
+ { 0, 0, 0 }, /* nothing -> ground (no change) */
+ { 0, 0, 1 }, /* left -> delayed left */
+ { 0, 0, 2 }, /* right -> delayed right */
+ { 2, 0, 3 }, /* left & right (middle press) -> pressed middle */
+ { 0, 0, -1 } /* timeout N/A */
+ },
+/* 1 delayed left */
+ {
+ { 1, -1, 0 }, /* nothing (left event) -> ground */
+ { 0, 0, 1 }, /* left -> delayed left (no change) */
+ { 1, -1, 2 }, /* right (left event) -> delayed right */
+ { 2, 0, 3 }, /* left & right (middle press) -> pressed middle */
+ { 1, 0, 4 }, /* timeout (left press) -> pressed left */
+ },
+/* 2 delayed right */
+ {
+ { 3, -3, 0 }, /* nothing (right event) -> ground */
+ { 3, -3, 1 }, /* left (right event) -> delayed left (no change) */
+ { 0, 0, 2 }, /* right -> delayed right (no change) */
+ { 2, 0, 3 }, /* left & right (middle press) -> pressed middle */
+ { 3, 0, 5 }, /* timeout (right press) -> pressed right */
+ },
+/* 3 pressed middle */
+ {
+ { -2, 0, 0 }, /* nothing (middle release) -> ground */
+ { 0, 0, 7 }, /* left -> released right */
+ { 0, 0, 6 }, /* right -> released left */
+ { 0, 0, 3 }, /* left & right -> pressed middle (no change) */
+ { 0, 0, -1 }, /* timeout N/A */
+ },
+/* 4 pressed left */
+ {
+ { -1, 0, 0 }, /* nothing (left release) -> ground */
+ { 0, 0, 4 }, /* left -> pressed left (no change) */
+ { -1, 0, 2 }, /* right (left release) -> delayed right */
+ { 3, 0, 10 }, /* left & right (right press) -> pressed both */
+ { 0, 0, -1 }, /* timeout N/A */
+ },
+/* 5 pressed right */
+ {
+ { -3, 0, 0 }, /* nothing (right release) -> ground */
+ { -3, 0, 1 }, /* left (right release) -> delayed left */
+ { 0, 0, 5 }, /* right -> pressed right (no change) */
+ { 1, 0, 10 }, /* left & right (left press) -> pressed both */
+ { 0, 0, -1 }, /* timeout N/A */
+ },
+/* 6 released left */
+ {
+ { -2, 0, 0 }, /* nothing (middle release) -> ground */
+ { -2, 0, 1 }, /* left (middle release) -> delayed left */
+ { 0, 0, 6 }, /* right -> released left (no change) */
+ { 1, 0, 8 }, /* left & right (left press) -> repressed left */
+ { 0, 0, -1 }, /* timeout N/A */
+ },
+/* 7 released right */
+ {
+ { -2, 0, 0 }, /* nothing (middle release) -> ground */
+ { 0, 0, 7 }, /* left -> released right (no change) */
+ { -2, 0, 2 }, /* right (middle release) -> delayed right */
+ { 3, 0, 9 }, /* left & right (right press) -> repressed right */
+ { 0, 0, -1 }, /* timeout N/A */
+ },
+/* 8 repressed left */
+ {
+ { -2, -1, 0 }, /* nothing (middle release, left release) -> ground */
+ { -2, 0, 4 }, /* left (middle release) -> pressed left */
+ { -1, 0, 6 }, /* right (left release) -> released left */
+ { 0, 0, 8 }, /* left & right -> repressed left (no change) */
+ { 0, 0, -1 }, /* timeout N/A */
+ },
+/* 9 repressed right */
+ {
+ { -2, -3, 0 }, /* nothing (middle release, right release) -> ground */
+ { -3, 0, 7 }, /* left (right release) -> released right */
+ { -2, 0, 5 }, /* right (middle release) -> pressed right */
+ { 0, 0, 9 }, /* left & right -> repressed right (no change) */
+ { 0, 0, -1 }, /* timeout N/A */
+ },
+/* 10 pressed both */
+ {
+ { -1, -3, 0 }, /* nothing (left release, right release) -> ground */
+ { -3, 0, 4 }, /* left (right release) -> pressed left */
+ { -1, 0, 5 }, /* right (left release) -> pressed right */
+ { 0, 0, 10 }, /* left & right -> pressed both (no change) */
+ { 0, 0, -1 }, /* timeout N/A */
+ },
+};
+
+/*
+ * Table to allow quick reversal of natural button mapping to correct mapping
+ */
+
+/*
+ * [JCH-96/01/21] The ALPS GlidePoint pad extends the MS protocol
+ * with a fourth button activated by tapping the PAD.
+ * The 2nd line corresponds to 4th button on; the drv sends
+ * the buttons in the following map (MSBit described first) :
+ * 0 | 4th | 1st | 2nd | 3rd
+ * And we remap them (MSBit described first) :
+ * 0 | 4th | 3rd | 2nd | 1st
+ */
+static char reverseMap[32] = { 0, 4, 2, 6, 1, 5, 3, 7,
+ 8, 12, 10, 14, 9, 13, 11, 15,
+ 16, 20, 18, 22, 17, 21, 19, 23,
+ 24, 28, 26, 30, 25, 29, 27, 31};
+
+
+static char hitachMap[16] = { 0, 2, 1, 3,
+ 8, 10, 9, 11,
+ 4, 6, 5, 7,
+ 12, 14, 13, 15 };
+
+#define reverseBits(map, b) (((b) & ~0x0f) | map[(b) & 0x0f])
+
+static CARD32
+buttonTimer(InputInfoPtr pInfo)
+{
+ MouseDevPtr pMse;
+ int sigstate;
+ int id;
+
+ pMse = pInfo->private;
+
+ sigstate = xf86BlockSIGIO ();
+
+ pMse->emulate3Pending = FALSE;
+ if ((id = stateTab[pMse->emulateState][4][0]) != 0) {
+ xf86PostButtonEvent(pInfo->dev, 0, abs(id), (id >= 0), 0, 0);
+ pMse->emulateState = stateTab[pMse->emulateState][4][2];
+ } else {
+ ErrorF("Got unexpected buttonTimer in state %d\n", pMse->emulateState);
+ }
+
+ xf86UnblockSIGIO (sigstate);
+ return 0;
+}
+
+static Bool
+Emulate3ButtonsSoft(InputInfoPtr pInfo)
+{
+ MouseDevPtr pMse = pInfo->private;
+
+ if (!pMse->emulate3ButtonsSoft)
+ return TRUE;
+
+ pMse->emulate3Buttons = FALSE;
+
+ if (pMse->emulate3Pending)
+ buttonTimer(pInfo);
+
+ xf86Msg(X_INFO,"3rd Button detected: disabling emulate3Button\n");
+
+ return FALSE;
+}
+
+static void MouseBlockHandler(pointer data,
+ struct timeval **waitTime,
+ pointer LastSelectMask)
+{
+ InputInfoPtr pInfo = (InputInfoPtr) data;
+ MouseDevPtr pMse = (MouseDevPtr) pInfo->private;
+ int ms;
+
+ if (pMse->emulate3Pending)
+ {
+ ms = pMse->emulate3Expires - GetTimeInMillis ();
+ if (ms <= 0)
+ ms = 0;
+ AdjustWaitForDelay (waitTime, ms);
+ }
+}
+
+static void MouseWakeupHandler(pointer data,
+ int i,
+ pointer LastSelectMask)
+{
+ InputInfoPtr pInfo = (InputInfoPtr) data;
+ MouseDevPtr pMse = (MouseDevPtr) pInfo->private;
+ int ms;
+
+ if (pMse->emulate3Pending)
+ {
+ ms = pMse->emulate3Expires - GetTimeInMillis ();
+ if (ms <= 0)
+ buttonTimer (pInfo);
+ }
+}
+
+static int
+SupportedInterfaces(void)
+{
+ return MSE_MISC;
+}
+
+static const char* internalNames[] = {
+ "OS2Mouse",
+ NULL
+};
+
+static const char**
+BuiltinNames(void)
+{
+ return internalNames;
+}
+
+static Bool
+CheckProtocol(const char *protocol)
+{
+ int i;
+
+ for (i = 0; internalNames[i]; i++)
+ if (xf86NameCmp(protocol, internalNames[i]) == 0)
+ return TRUE;
+ return FALSE;
+}
+
+static const char *
+DefaultProtocol(void)
+{
+ return "OS2Mouse";
+}
+
+static const char *
+SetupAuto(InputInfoPtr pInfo, int *protoPara)
+{
+ return "OS2Mouse";
+}
+
+HMOU hMouse=65535;
+HEV hMouseSem;
+HQUEUE hMouseQueue;
+InputInfoPtr iinfoPtr;
+int MouseTid;
+BOOL HandleValid=FALSE;
+extern BOOL SwitchedToWPS;
+extern CARD32 LastSwitchTime;
+void os2MouseEventThread(void* arg);
+
+static void
+os2MouseReadInput(InputInfoPtr pInfo)
+{
+ APIRET rc;
+ ULONG postCount,dataLength;
+ PVOID dummy;
+ int buttons;
+ int state;
+ int i, dx,dy;
+ BYTE elemPriority;
+ REQUESTDATA requestData;
+
+ MouseDevPtr pMse = pInfo->private;
+
+ if (!HandleValid) return;
+ while((rc = DosReadQueue(hMouseQueue,
+ &requestData,&dataLength,&dummy,
+ 0L,1L,&elemPriority,hMouseSem)) == 0) {
+ dx = requestData.ulData;
+ (void)DosReadQueue(hMouseQueue,
+ &requestData,&dataLength,&dummy,
+ 0L,1L,&elemPriority,hMouseSem);
+ dy = requestData.ulData;
+ (void)DosReadQueue(hMouseQueue,
+ &requestData,&dataLength,&dummy,
+ 0L,1L,&elemPriority,hMouseSem);
+ state = requestData.ulData;
+ (void)DosReadQueue(hMouseQueue,
+ &requestData,&dataLength,&dummy,
+ 0L,1L,&elemPriority,hMouseSem);
+ if (requestData.ulData != 0xFFFFFFFF)
+ xf86Msg(X_ERROR,
+ "Unexpected mouse event tag, %d\n",
+ requestData.ulData);
+
+ /* Contrary to other systems, OS/2 has mouse buttons *
+ * in the proper order, so we reverse them before *
+ * sending the event. */
+
+ buttons = ((state & 0x06) ? 4 : 0) |
+ ((state & 0x18) ? 1 : 0) |
+ ((state & 0x60) ? 2 : 0);
+ pMse->PostEvent(pInfo, buttons, dx, dy, 0, 0);
+ }
+ DosResetEventSem(hMouseSem,&postCount);
+}
+
+int os2MouseProc(DeviceIntPtr pPointer, int what)
+{
+ APIRET rc = 0;
+ USHORT nbuttons, state;
+ unsigned char map[MSE_MAXBUTTONS + 1];
+ int i;
+
+ InputInfoPtr pInfo = pPointer->public.devicePrivate;
+ MouseDevPtr pMse = pInfo->private;
+ pMse->device = pPointer;
+
+ switch (what) {
+ case DEVICE_INIT:
+ pPointer->public.on = FALSE;
+ if (hMouse == 65535)
+ rc = MouOpen((PSZ)0, &hMouse);
+ if (rc != 0)
+ xf86Msg(X_WARNING,"%s: cannot open mouse, rc=%d\n",
+ pInfo->name,rc);
+ else {
+ pInfo->fd = hMouse;
+
+ /* flush mouse queue */
+ MouFlushQue(hMouse);
+
+ /* check buttons */
+ rc = MouGetNumButtons(&nbuttons, hMouse);
+ if (rc == 0)
+ xf86Msg(X_INFO,"%s: Mouse has %d button(s).\n",
+ pInfo->name,nbuttons);
+ if (nbuttons==2) nbuttons++;
+
+ for (i = 1; i<=nbuttons; i++)
+ map[i] = i;
+
+ InitPointerDeviceStruct((DevicePtr)pPointer, map, nbuttons,
+ miPointerGetMotionEvents, pMse->Ctrl,
+ miPointerGetMotionBufferSize());
+
+ /* X valuator */
+ xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 0);
+ /* y Valuator */
+ InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 1);
+ xf86MotionHistoryAllocate(pInfo);
+
+ /* OK, we are ready to start up the mouse thread ! */
+ if (!HandleValid) {
+ rc = DosCreateEventSem(NULL,&hMouseSem,DC_SEM_SHARED,TRUE);
+ if (rc != 0)
+ xf86Msg(X_ERROR,"%s: could not create mouse queue semaphore, rc=%d\n",
+ pInfo->name,rc);
+ MouseTid = _beginthread(os2MouseEventThread,NULL,0x4000,(void *)pInfo);
+ xf86Msg(X_INFO,
+ "%s: Started Mouse event thread, Tid=%d\n",
+ pInfo->name, MouseTid);
+ DosSetPriority(2,3,0,MouseTid);
+ }
+ HandleValid=TRUE;
+ }
+ break;
+
+ case DEVICE_ON:
+ if (!HandleValid) return -1;
+ pMse->lastButtons = 0;
+ pMse->lastMappedButtons = 0;
+ pMse->emulateState = 0;
+ pPointer->public.on = TRUE;
+ state = 0x300;
+ rc = MouSetDevStatus(&state,hMouse);
+ state = 0x7f;
+ rc = MouSetEventMask(&state,hMouse);
+ MouFlushQue(hMouse);
+ if (pMse->emulate3Buttons || pMse->emulate3ButtonsSoft)
+ {
+ RegisterBlockAndWakeupHandlers (MouseBlockHandler, MouseWakeupHandler,
+ (pointer) pInfo);
+ }
+ break;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ if (!HandleValid) return -1;
+ if (pMse->emulate3Buttons || pMse->emulate3ButtonsSoft)
+ {
+ RemoveBlockAndWakeupHandlers (MouseBlockHandler, MouseWakeupHandler,
+ (pointer) pInfo);
+ }
+ pPointer->public.on = FALSE;
+ state = 0x300;
+ MouSetDevStatus(&state,hMouse);
+ state = 0;
+ MouSetEventMask(&state,hMouse);
+ if (what == DEVICE_CLOSE) {
+/* Comment out for now as this seems to break server */
+#if 0
+ MouClose(hMouse);
+ hMouse = 65535;
+ pInfo->fd = -1;
+ HandleValid = FALSE;
+#endif
+ }
+ break;
+ }
+ return Success;
+}
+
+int os2MouseQueueQuery()
+{
+ /* Now we check for activity on mouse handles */
+ ULONG numElements,postCount;
+
+ if (!HandleValid) return(1);
+ DosResetEventSem(hMouseSem,&postCount);
+ (void)DosQueryQueue(hMouseQueue,&numElements);
+ if (numElements>0) { /* Something in mouse queue! */
+ return 0; /* Will this work? */
+ }
+ return 1;
+}
+
+void os2MouseEventThread(void *arg)
+{
+ APIRET rc;
+ MOUEVENTINFO mev;
+ ULONG queueParam;
+ USHORT waitflg;
+ char queueName[128];
+ MouseDevPtr pMse;
+
+ iinfoPtr = (InputInfoPtr)arg;
+ pMse = iinfoPtr->private;
+
+ sprintf(queueName,"\\QUEUES\\XF86MOU\\%d",getpid());
+ rc = DosCreateQueue(&hMouseQueue,0L,queueName);
+ xf86Msg(X_INFO,"Mouse Queue created, rc=%d\n",rc);
+ (void)DosPurgeQueue(hMouseQueue);
+
+ while(1) {
+ waitflg = 1;
+ rc = MouReadEventQue(&mev,&waitflg,hMouse);
+ if (rc) {
+ xf86Msg(X_ERROR,
+ "Bad return code from mouse driver, rc=%d\n",
+ rc);
+ xf86Msg(X_ERROR,"Mouse aborting!\n");
+ break;
+ }
+
+ queueParam = mev.col;
+ if ((rc = DosWriteQueue(hMouseQueue,queueParam,0L,NULL,0L)))
+ break;
+ queueParam = mev.row;
+ if ((rc = DosWriteQueue(hMouseQueue,queueParam,0L,NULL,0L)))
+ break;
+ queueParam = mev.fs;
+ if ((rc = DosWriteQueue(hMouseQueue,queueParam,0L,NULL,0L)))
+ break;
+ queueParam = 0xFFFFFFFF;
+ if ((rc = DosWriteQueue(hMouseQueue,queueParam,0L,NULL,0L)))
+ break;
+ }
+ xf86Msg(X_ERROR,
+ "An unrecoverable error in mouse queue has occured, rc=%d. Mouse is shutting down.\n",
+ rc);
+ DosCloseQueue(hMouseQueue);
+}
+
+
+static Bool
+os2MousePreInit(InputInfoPtr pInfo, const char* protocol, int flags)
+{
+ MouseDevPtr pMse = pInfo->private;
+
+ pMse->protocol = protocol;
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
+
+ /* Collect the options, and process the common options. */
+ xf86CollectInputOptions(pInfo, NULL, NULL);
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
+
+ /* Process common mouse options (like Emulate3Buttons, etc). */
+ pMse->CommonOptions(pInfo);
+
+ /* Setup the local procs. */
+ pInfo->device_control = os2MouseProc;
+ pInfo->read_input = os2MouseReadInput;
+
+ pInfo->flags |= XI86_CONFIGURED;
+ return TRUE;
+}
+
+OSMouseInfoPtr
+xf86OSMouseInit(int flags)
+{
+ OSMouseInfoPtr p;
+
+ p = xcalloc(sizeof(OSMouseInfoRec), 1);
+ if (!p)
+ return NULL;
+ p->SupportedInterfaces = SupportedInterfaces;
+ p->BuiltinNames = BuiltinNames;
+ p->DefaultProtocol = DefaultProtocol;
+ p->CheckProtocol = CheckProtocol;
+ p->PreInit = os2MousePreInit;
+ p->SetupAuto = SetupAuto;
+ return p;
+}
+
+void xf86OsMouseEvents()
+{
+ APIRET rc;
+ ULONG postCount,dataLength;
+ PVOID dummy;
+ int buttons;
+ int state;
+ int i, dx,dy;
+ BYTE elemPriority;
+ REQUESTDATA requestData;
+
+ MouseDevPtr pMse = iinfoPtr->private;
+
+ if (!HandleValid) return;
+ while((rc = DosReadQueue(hMouseQueue,
+ &requestData,&dataLength,&dummy,
+ 0L,1L,&elemPriority,hMouseSem)) == 0) {
+ dx = requestData.ulData;
+ (void)DosReadQueue(hMouseQueue,
+ &requestData,&dataLength,&dummy,
+ 0L,1L,&elemPriority,hMouseSem);
+ dy = requestData.ulData;
+ (void)DosReadQueue(hMouseQueue,
+ &requestData,&dataLength,&dummy,
+ 0L,1L,&elemPriority,hMouseSem);
+ state = requestData.ulData;
+ (void)DosReadQueue(hMouseQueue,
+ &requestData,&dataLength,&dummy,
+ 0L,1L,&elemPriority,hMouseSem);
+ if (requestData.ulData != 0xFFFFFFFF)
+ xf86Msg(X_ERROR,
+ "Unexpected mouse event tag, %d\n",
+ requestData.ulData);
+
+ /* Contrary to other systems, OS/2 has mouse buttons *
+ * in the proper order, so we reverse them before *
+ * sending the event. */
+
+ buttons = ((state & 0x06) ? 4 : 0) |
+ ((state & 0x18) ? 1 : 0) |
+ ((state & 0x60) ? 2 : 0);
+ pMse->PostEvent(iinfoPtr, buttons, dx, dy, 0, 0);
+ }
+ DosResetEventSem(hMouseSem,&postCount);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_select.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_select.c
new file mode 100644
index 000000000..395104242
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_select.c
@@ -0,0 +1,497 @@
+/* $XConsortium: os2_select.c /main/6 1996/10/27 11:48:55 kaleb $ */
+
+
+
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_select.c,v 3.9 2003/03/25 04:18:24 dawes Exp $ */
+
+/*
+ * (c) Copyright 1996 by Sebastien Marineau
+ * <marineau@genie.uottawa.ca>
+ * Modified 1999 by Holger.Veit@gmd.de
+ * Modified 2004 by Frank Giessler
+ * <giessler@biomag.uni-jena.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Sebastien Marineau shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Sebastien Marineau.
+ *
+ */
+
+/* os2_select.c: reimplementation of the xserver select(), optimized for speed */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <memory.h>
+#include <io.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/errno.h>
+#include <emx/io.h>
+
+#define I_NEED_OS2_H
+#define INCL_DOSSEMAPHORES
+#define INCL_DOSPROFILE
+#define INCL_DOSPROCESS
+#define INCL_DOSFILEMGR
+#define INCL_DOSMISC
+#define INCL_DOSMODULEMGR
+
+
+#include <X11/Xpoll.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include "os2_select.h"
+
+int os2MouseQueueQuery();
+int os2KbdQueueQuery();
+void os2RecoverFromPopup();
+void os2CheckPopupPending();
+void os2SocketMonitorThread();
+extern BOOL os2PopupErrorPending;
+
+extern HEV hKbdSem;
+extern HEV hMouseSem;
+extern HEV hevServerHasFocus;
+HEV hPipeSem;
+HEV hSocketSem;
+HEV hActivateSocketSem;
+HEV hSwitchToSem;
+static HMUX hSelectWait;
+SEMRECORD SelectMuxRecord[5];
+HMODULE hmod_so32dll;
+static struct select_data sd;
+
+static int (*os2_tcp_select)(int *,int,int,int,long);
+static int (*os2_so_cancel)(int);
+static int (*os2_sock_errno)();
+int os2_set_error(ULONG);
+extern int _files[];
+
+
+
+/* This is a new implementation of select, for improved efficiency */
+/* This function performs select() on sockets */
+/* but uses OS/2 internal fncts to check mouse */
+/* and keyboard. S. Marineau, 27/4/96 */
+
+/* This is still VERY messy */
+
+/* A few note on optimizations: this select has been tuned for maximum
+* performance, and thus has a different approach than a general-purpose
+* select. It should not be used in another app without modifications. Further,
+* it may need modifications if the Xserver os code is modified
+* Assumptions: this is never called with anything in exceptfds. This is
+* silently ignored. Further, if any pipes are specified in the write mask, it is
+* because they have just been stuffed full by the xserver. There is not much
+* in immediately returning with those bits set. Instead, we block on the
+* semaphore for at least one tick, which will let the client at least start
+* to flush the pipe. */
+
+int os2PseudoSelect(nfds,readfds,writefds,exceptfds,timeout)
+ int nfds;
+ fd_set *readfds,*writefds,*exceptfds;
+ struct timeval *timeout;
+{
+
+ static BOOL FirstTime=TRUE;
+
+ int n,ns,np;
+ int ready_handles;
+ ULONG timeout_ms;
+ BOOL any_ready;
+ ULONG semKey,postCount;
+ APIRET rc;
+ char faildata[16];
+ static int Socket_Tid;
+
+ sd.have_read=FALSE; sd.have_write=FALSE;
+ sd.socket_nread=0; sd.socket_nwrite=0; sd.socket_ntotal=0;
+ sd.max_fds=31; ready_handles=0; any_ready=FALSE;
+ sd.pipe_ntotal=0; sd.pipe_have_write=FALSE;
+
+ /* Stuff we have to do the first time this is called to set up various parameters */
+
+ if (FirstTime) {
+ /* First load the so32dll.dll module and get a pointer to the SELECT fn */
+
+ if ((rc=DosLoadModule(faildata,sizeof(faildata),"SO32DLL",&hmod_so32dll))!=0) {
+ FatalError("Could not load module so32dll.dll, rc = %d. Error note %s\n",rc,faildata);
+ }
+ if ((rc = DosQueryProcAddr(hmod_so32dll, 0, "SELECT", (PPFN)&os2_tcp_select))!=0) {
+ FatalError("Could not query address of SELECT, rc = %d.\n",rc);
+ }
+ if ((rc = DosQueryProcAddr(hmod_so32dll, 0, "SO_CANCEL", (PPFN)&os2_so_cancel))!=0) {
+ FatalError("Could not query address of SO_CANCEL, rc = %d.\n",rc);
+ }
+ if ((rc = DosQueryProcAddr(hmod_so32dll, 0, "SOCK_ERRNO", (PPFN)&os2_sock_errno))!=0) {
+ FatalError("Could not query address of SOCK_ERRNO, rc = %d.\n",rc);
+ }
+
+ /* Call these a first time to set the semaphore */
+ xf86OsMouseEvents();
+ xf86KbdEvents();
+
+ DosCreateEventSem(NULL, &hSocketSem,DC_SEM_SHARED,FALSE);
+ DosResetEventSem(hSocketSem,&postCount);
+
+ DosCreateEventSem(NULL, &hActivateSocketSem, DC_SEM_SHARED, FALSE);
+ DosResetEventSem(hActivateSocketSem, &postCount);
+
+ DosCreateEventSem(NULL, &hSwitchToSem, DC_SEM_SHARED, FALSE);
+ DosResetEventSem(hSwitchToSem, &postCount);
+
+ Socket_Tid = _beginthread(os2SocketMonitorThread, NULL, 0x2000,(void *) NULL);
+ xf86Msg(X_INFO,
+ "Started Socket monitor thread, TID=%d\n",Socket_Tid);
+
+ SelectMuxRecord[0].hsemCur = (HSEM)hMouseSem;
+ SelectMuxRecord[0].ulUser = MOUSE_SEM_KEY;
+ SelectMuxRecord[1].hsemCur = (HSEM)hKbdSem;
+ SelectMuxRecord[1].ulUser = KBD_SEM_KEY;
+ SelectMuxRecord[2].hsemCur = (HSEM)hPipeSem;
+ SelectMuxRecord[2].ulUser = PIPE_SEM_KEY;
+ SelectMuxRecord[3].hsemCur = (HSEM)hSocketSem;
+ SelectMuxRecord[3].ulUser = SOCKET_SEM_KEY;
+ SelectMuxRecord[4].hsemCur = (HSEM)hSwitchToSem;
+ SelectMuxRecord[4].ulUser = SWITCHTO_SEM_KEY;
+
+ rc = DosCreateMuxWaitSem(NULL, &hSelectWait, 5, SelectMuxRecord,
+ DC_SEM_SHARED | DCMW_WAIT_ANY);
+ if (rc) {
+ xf86Msg(X_ERROR,"Could not create MuxWait semaphore, rc=%d\n",rc);
+ }
+ FirstTime = FALSE;
+ }
+
+ rc = DosResetEventSem(hActivateSocketSem, &postCount);
+ /* Set up the time delay structs */
+
+ if (timeout!=NULL) {
+ timeout_ms=timeout->tv_sec*1000+timeout->tv_usec/1000;
+ } else {
+ timeout_ms=1000000; /* This should be large enough... */
+ }
+
+ /* Zero our local fd_masks */
+ {FD_ZERO(&sd.read_copy);}
+ {FD_ZERO(&sd.write_copy);}
+
+ /* Copy the masks for later use */
+ if (readfds!=NULL) { XFD_COPYSET(readfds,&sd.read_copy); sd.have_read=TRUE; }
+ if (writefds!=NULL) {XFD_COPYSET(writefds,&sd.write_copy); sd.have_write=TRUE; }
+
+ /* And zero the original masks */
+ if (sd.have_read){ FD_ZERO(readfds); }
+ if (sd.have_write) {FD_ZERO(writefds); }
+ if (exceptfds != NULL) {FD_ZERO(exceptfds); }
+
+ /* Now we parse the fd_sets passed to select and separate pipe/sockets */
+ n = os2_parse_select(&sd,nfds);
+
+ /* Now check if we have sockets ready! */
+
+ if (sd.socket_ntotal > 0) {
+ ns = os2_poll_sockets(&sd,readfds,writefds);
+ if (ns>0) {
+ ready_handles+=ns;
+ any_ready = TRUE;
+ } else if (ns == -1) {
+ return(-1);
+ }
+ }
+
+ /* And pipes */
+
+ if (sd.pipe_ntotal > 0) {
+ np = os2_check_pipes(&sd,readfds,writefds);
+ if (np > 0) {
+ ready_handles+=np;
+ any_ready = TRUE;
+ } else if (np == -1) {
+ return(-1);
+ }
+ }
+
+ /* And finally poll input devices */
+ if(!os2MouseQueueQuery() || !os2KbdQueueQuery() ) any_ready = TRUE;
+
+ if (xf86Info.vtRequestsPending) any_ready=TRUE;
+
+ if (os2PopupErrorPending)
+ os2RecoverFromPopup();
+
+ if (!any_ready && timeout_ms) {
+ DosResetEventSem(hSocketSem,&postCount);
+
+ /* Activate the socket thread */
+ if (sd.socket_ntotal>0) {
+ rc = DosPostEventSem(hActivateSocketSem);
+ }
+
+ rc = DosWaitMuxWaitSem(hSelectWait, timeout_ms, &semKey);
+
+ /* If our socket monitor thread is still blocked in os2_tcp_select()
+ * we have to wake it up by calling os2_so_cancel().
+ * After that, call os2_tcp_select() once more to get rid of
+ * error SOCEINTR (10004)
+ */
+ if (sd.socket_ntotal>0) {
+ rc = DosQueryEventSem(hSocketSem, &postCount);
+
+ if (postCount == 0) { /* os2_select still blocked */
+ int i,f,g;
+ struct select_data *sd_ptr=&sd;
+
+ if (sd.socket_nread > 0) {
+ for (i=0; i<sd.socket_nread; i++) {
+ f = g = sd_ptr->tcp_select_mask[i];
+ os2_so_cancel(f);
+ os2_tcp_select(&g, 1, 0, 0, 0); /* get rid of error 10004 */
+ }
+ }
+ if (sd.socket_nwrite > 0) {
+ for (i=sd.socket_nread;
+ i<sd.socket_nread+sd.socket_nwrite;
+ i++) {
+ f = g = sd_ptr->tcp_select_mask[i];
+ os2_so_cancel(f);
+ os2_tcp_select(&g, 0, 1, 0, 0); /* get rid of error 10004 */
+ }
+ }
+ } else { /* not blocked, something must be ready -> get it */
+ ns = os2_poll_sockets(&sd,readfds,writefds);
+ if (ns>0) {
+ ready_handles+=ns;
+ } else if (ns == -1) {
+ return(-1);
+ }
+ }
+ }
+ if (sd.pipe_ntotal > 0) {
+ rc = DosQueryEventSem(hPipeSem,&postCount);
+ if (postCount > 0) {
+ np = os2_check_pipes(&sd,readfds,writefds);
+ if (np > 0) {
+ ready_handles+=np;
+ } else if (np == -1) {
+ return(-1);
+ }
+ }
+ }
+ }
+ /* The polling of sockets/pipe automatically set the proper bits */
+ return (ready_handles);
+}
+
+
+int os2_parse_select(sd,nfds)
+ struct select_data *sd;
+ int nfds;
+{
+ int i;
+ /* First we determine up to which descriptor we need to check. */
+ /* No need to check up to 256 if we don't have to (and usually we dont...)*/
+ /* Note: stuff here is hardcoded for fd_sets which are int[8] as in EMX!!! */
+
+ if (nfds > sd->max_fds) {
+ for (i=0;i<((FD_SETSIZE+31)/32);i++) {
+ if (sd->read_copy.fds_bits[i] ||
+ sd->write_copy.fds_bits[i])
+ sd->max_fds=(i*32) +32;
+ }
+ } else { sd->max_fds = nfds; }
+
+ /* Check if this is greater than specified in select() call */
+ if(sd->max_fds > nfds) sd->max_fds = nfds;
+
+ if (sd->have_read) {
+ for (i = 0; i < sd->max_fds; ++i) {
+ if (FD_ISSET (i, &sd->read_copy)) {
+ if(_files[i] & F_SOCKET) {
+ sd->tcp_select_mask[sd->socket_ntotal]=_getsockhandle(i);
+ sd->tcp_emx_handles[sd->socket_ntotal]=i;
+ sd->socket_ntotal++; sd->socket_nread++;
+ } else if (_files[i] & F_PIPE) {
+ sd -> pipe_ntotal++;
+ }
+ }
+ }
+ }
+ if (sd->have_write) {
+ for (i = 0; i < sd->max_fds; ++i) {
+ if (FD_ISSET (i, &sd->write_copy)) {
+ if (_files[i] & F_SOCKET) {
+ sd->tcp_select_mask[sd->socket_ntotal]=_getsockhandle(i);
+ sd->tcp_emx_handles[sd->socket_ntotal]=i;
+ sd->socket_ntotal++; sd->socket_nwrite++;
+ } else if (_files[i] & F_PIPE) {
+ sd -> pipe_ntotal++;
+ sd -> pipe_have_write=TRUE;
+ }
+ }
+ }
+ }
+ return(sd->socket_ntotal);
+}
+
+
+int os2_poll_sockets(sd,readfds,writefds)
+ struct select_data *sd;
+ fd_set *readfds,*writefds;
+{
+ int e,i;
+ int j,n;
+
+ memcpy(sd->tcp_select_copy,sd->tcp_select_mask,
+ sd->socket_ntotal*sizeof(int));
+
+ e = os2_tcp_select(sd->tcp_select_copy,sd->socket_nread,
+ sd->socket_nwrite, 0, 0);
+
+ if (e == 0) return(e);
+
+ /* We have something ready? */
+ if (e>0) {
+ j = 0; n = 0;
+ for (i = 0; i < sd->socket_nread; ++i, ++j)
+ if (sd->tcp_select_copy[j] != -1) {
+ FD_SET (sd->tcp_emx_handles[j], readfds);
+ n ++;
+ }
+ for (i = 0; i < sd->socket_nwrite; ++i, ++j)
+ if (sd->tcp_select_copy[j] != -1) {
+ FD_SET (sd->tcp_emx_handles[j], writefds);
+ n ++;
+ }
+ errno = 0;
+
+ return n;
+ }
+ if (e<0) {
+ /*Error -- TODO */
+ xf86Msg(X_ERROR,"Error in server select! sock_errno = %d\n",os2_sock_errno());
+ errno = EBADF;
+ return (-1);
+ }
+}
+
+/* Check to see if anything is ready on pipes */
+
+int os2_check_pipes(sd,readfds,writefds)
+ struct select_data *sd;
+ fd_set *readfds,*writefds;
+{
+ int i,e;
+ ULONG ulPostCount;
+ PIPESEMSTATE pipeSemState[128];
+ APIRET rc;
+
+ e = 0;
+ rc = DosResetEventSem(hPipeSem,&ulPostCount);
+ rc = DosQueryNPipeSemState((HSEM) hPipeSem, (PPIPESEMSTATE)&pipeSemState,
+ sizeof(pipeSemState));
+ if(rc) xf86Msg(X_ERROR,"SELECT: rc from QueryNPipeSem: %d\n",rc);
+ i=0;
+ while (pipeSemState[i].fStatus != 0) {
+/* xf86Msg(X_INFO,"SELECT: sem entry, stat=%d, flag=%d, key=%d,avail=%d\n",
+ pipeSemState[i].fStatus,pipeSemState[i].fFlag,pipeSemState[i].usKey,
+ pipeSemState[i].usAvail); */
+ if ((pipeSemState[i].fStatus == 1) &&
+ (FD_ISSET(pipeSemState[i].usKey,&sd->read_copy))) {
+ FD_SET(pipeSemState[i].usKey,readfds);
+ e++;
+ } else if ((pipeSemState[i].fStatus == 2) &&
+ (FD_ISSET(pipeSemState[i].usKey,&sd->write_copy))) {
+ FD_SET(pipeSemState[i].usKey,writefds);
+ e++;
+ } else if ((pipeSemState[i].fStatus == 3) &&
+ ((FD_ISSET(pipeSemState[i].usKey,&sd->read_copy)) ||
+ (FD_ISSET(pipeSemState[i].usKey,&sd->write_copy)) )) {
+ errno = EBADF;
+ /* xf86Msg(X_ERROR,"Pipe has closed down, fd=%d\n",pipeSemState[i].usKey); */
+ return (-1);
+ }
+ i++;
+ } /* endwhile */
+
+ errno = 0;
+ return(e);
+}
+
+
+void os2SocketMonitorThread(void *arg)
+{
+ struct select_data *sd_ptr = &sd;
+ ULONG ulPostCount;
+ int e,rc;
+
+ /* Make thread time critical */
+ DosSetPriority(2L,3L,0L,0L);
+
+ while (1) {
+ rc = DosWaitEventSem(hActivateSocketSem, SEM_INDEFINITE_WAIT);
+ if (rc != 0 )
+ xf86Msg(X_ERROR,"Socket monitor: DosWaitEventSem(hActivateSocketSem..) returned %d\n",rc);
+
+ rc = DosResetEventSem(hActivateSocketSem,&ulPostCount);
+ if (rc != 0 )
+ xf86Msg(X_ERROR,"Socket monitor: DosResetEventSem(&hActivateSocketSem..) returned %d\n",rc);
+
+ /* fg300104:
+ * The next line shouldn't be here, but the DosPostEventSem()
+ * below will return 299 from time to time under heavy load
+ */
+/* DosResetEventSem(hSocketSem,&ulPostCount);*/
+
+ memcpy(sd_ptr->tcp_select_monitor,sd_ptr->tcp_select_mask,
+ sd_ptr->socket_ntotal*sizeof(int));
+
+ /* call os2_select(), return only if either something is ready or
+ * os2_so_cancel() was called
+ */
+ e = os2_tcp_select(sd_ptr->tcp_select_monitor, sd_ptr->socket_nread,
+ sd_ptr->socket_nwrite, 0, -1);
+
+ if (e>0) {
+ rc = DosPostEventSem(hSocketSem);
+ if (rc != 0 )
+ xf86Msg(X_ERROR,"Socket monitor: DosPostEventSem(hSocketSem..) returned %d\n",rc);
+ } else if (e<0) {
+ rc = os2_sock_errno();
+ if (rc != 10004)
+ xf86Msg(X_ERROR,"Socket monitor: os2_select: sock_errno = %d\n",rc);
+ }
+
+ rc = DosQueryEventSem(hevServerHasFocus, &ulPostCount);
+
+ /* no need to rush while switched away */
+ if ((rc==0) && (ulPostCount==0))
+ rc == DosWaitEventSem(hevServerHasFocus,31L);
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_select.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_select.h
new file mode 100644
index 000000000..cb2291e09
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_select.h
@@ -0,0 +1,62 @@
+/* $XConsortium: os2_select.h /main/1 1996/05/13 16:38:30 kaleb $ */
+/*
+ * (c) Copyright 1996 by Sebastien Marineau
+ * <marineau@genie.uottawa.ca>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Sebastien Marineau shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Sebastien Marineau.
+ *
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_select.h,v 3.1 1996/12/27 07:04:31 dawes Exp $ */
+
+/* Header file for os2_select.c */
+
+#define MAX_TCP 256
+
+#define MOUSE_SEM_KEY 0x0F01
+#define KBD_SEM_KEY 0x0F02
+#define PIPE_SEM_KEY 0x0F03
+#define SOCKET_SEM_KEY 0x0F04
+#define SWITCHTO_SEM_KEY 0x0F05
+
+
+struct select_data
+{
+ fd_set read_copy;
+ fd_set write_copy;
+ BOOL have_read;
+ BOOL have_write;
+ int tcp_select_mask[MAX_TCP];
+ int tcp_emx_handles[MAX_TCP];
+ int tcp_select_copy[MAX_TCP];
+ int tcp_select_monitor[MAX_TCP];
+ int socket_nread;
+ int socket_nwrite;
+ int socket_ntotal;
+ int pipe_ntotal;
+ int pipe_have_write;
+ int max_fds;
+};
+
+
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_serial.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_serial.c
new file mode 100644
index 000000000..6587b1bda
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_serial.c
@@ -0,0 +1,517 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_serial.c,v 1.3 2000/04/05 18:13:53 dawes Exp $ */
+/*
+ * (c) Copyright 1999 by Holger Veit
+ * <Holger.Veit@gmd.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Holger Veit shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Holger Veit.
+ *
+ */
+/* $XConsortium$ */
+
+#define I_NEED_OS2_H
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#define INCL_DOSDEVIOCTL
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+static int _set_baudrate(HFILE fd,int baud)
+{
+ USHORT br = baud;
+ ULONG plen;
+ return DosDevIOCtl(fd,IOCTL_ASYNC,ASYNC_SETBAUDRATE,
+ (PULONG)&br,sizeof(br),&plen,NULL,0,NULL);
+}
+
+#pragma pack(1)
+typedef struct _glinectl {
+ UCHAR databits;
+ UCHAR parity;
+ UCHAR stopbits;
+ UCHAR sendbrk;
+} GLINECTL;
+typedef struct _slinectl {
+ UCHAR databits;
+ UCHAR parity;
+ UCHAR stopbits;
+} SLINECTL;
+
+#pragma pack()
+
+static int _get_linectrl(HFILE fd,GLINECTL* linectrl)
+{
+ ULONG dlen;
+ return DosDevIOCtl(fd,IOCTL_ASYNC,ASYNC_GETLINECTRL,
+ NULL,0,NULL,linectrl,sizeof(GLINECTL),&dlen);
+}
+
+static int _set_linectl(HFILE fd,GLINECTL* linectl)
+{
+ ULONG plen;
+ return DosDevIOCtl(fd,IOCTL_ASYNC,ASYNC_SETLINECTRL,
+ (PULONG)&linectl,sizeof(SLINECTL),&plen,NULL,0,NULL);
+}
+
+static int _get_dcb(HFILE fd,DCBINFO* dcb) {
+
+ ULONG dlen;
+ return DosDevIOCtl(fd,IOCTL_ASYNC,ASYNC_GETDCBINFO,
+ NULL,0,NULL,(PULONG)dcb,sizeof(DCBINFO),&dlen);
+}
+
+static int _set_dcb(HFILE fd,DCBINFO* dcb)
+{
+ ULONG plen;
+ return DosDevIOCtl(fd,IOCTL_ASYNC, ASYNC_SETDCBINFO,
+ (PULONG)dcb,sizeof(DCBINFO),&plen,NULL,0,NULL);
+}
+
+#pragma pack(1)
+typedef struct comsize {
+ USHORT nqueued;
+ USHORT qsize;
+} COMSIZE;
+#pragma pack()
+
+static int _get_nread(HFILE fd,ULONG* nread)
+{
+ ULONG dlen;
+ COMSIZE sz;
+ APIRET rc = DosDevIOCtl(fd,IOCTL_ASYNC,ASYNC_GETINQUECOUNT,
+ NULL, 0, NULL, sz,sizeof(COMSIZE),&dlen);
+ *nread = sz.nqueued;
+ return rc ? -1 : 0;
+}
+
+int xf86OpenSerial (pointer options)
+{
+ APIRET rc;
+ HFILE fd, i;
+ ULONG action;
+ GLINECTL linectl;
+
+ char* dev = xf86FindOptionValue (options, "Device");
+ xf86MarkOptionUsedByName (options, "Device");
+ if (!dev) {
+ xf86Msg (X_ERROR, "xf86OpenSerial: No Device specified.\n");
+ return -1;
+ }
+
+ rc = DosOpen(dev, &fd, &action, 0, FILE_NORMAL, FILE_OPEN,
+ OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, NULL);
+ if (rc) {
+ xf86Msg (X_ERROR,
+ "xf86OpenSerial: Cannot open device %s, rc=%d.\n",
+ dev, rc);
+ return -1;
+ }
+
+ /* check whether it is an async device */
+ if (_get_linectrl(fd,&linectl)) {
+ xf86Msg (X_WARNING,
+ "xf86OpenSerial: Specified device %s is not a tty\n",
+ dev);
+ DosClose(fd);
+ return -1;
+ }
+
+ /* set up default port parameters */
+ _set_baudrate(fd, 9600);
+
+ linectl.databits = 8;
+ linectl.parity = 0;
+ linectl.stopbits = 0;
+ _set_linectl(fd, &linectl);
+
+ if (xf86SetSerial (fd, options) == -1) {
+ DosClose(fd);
+ return -1;
+ }
+
+ return fd;
+}
+
+int xf86SetSerial (int fd, pointer options)
+{
+ APIRET rc;
+ USHORT baud;
+ ULONG plen,dlen;
+ char *s;
+
+ GLINECTL linectl;
+ DCBINFO dcb;
+
+ if ((s = xf86FindOptionValue (options, "BaudRate"))) {
+ xf86MarkOptionUsedByName (options, "BaudRate");
+ if ((rc = _set_baudrate(fd, atoi(s)))) {
+ xf86Msg (X_ERROR,"Set Baudrate: %s, rc=%d\n", s, rc);
+ return -1;
+ }
+ }
+
+ /* get line parameters */
+ if (DosDevIOCtl((HFILE)fd,IOCTL_ASYNC, ASYNC_GETLINECTRL,
+ NULL,0,NULL,
+ (PULONG)&linectl,sizeof(GLINECTL),&dlen)) return -1;
+
+ if ((s = xf86FindOptionValue (options, "StopBits"))) {
+ xf86MarkOptionUsedByName (options, "StopBits");
+ switch (atoi (s)) {
+ case 1: linectl.stopbits = 0;
+ break;
+ case 2: linectl.stopbits = 2;
+ break;
+ default: xf86Msg (X_ERROR,
+ "Invalid Option StopBits value: %s\n", s);
+ return -1;
+ }
+ }
+
+ if ((s = xf86FindOptionValue (options, "DataBits"))) {
+ int db;
+ xf86MarkOptionUsedByName (options, "DataBits");
+ switch (db = atoi (s)) {
+ case 5: case 6: case 7: case 8:
+ linectl.databits = db;
+ break;
+ default: xf86Msg (X_ERROR,
+ "Invalid Option DataBits value: %s\n", s);
+ return -1;
+ }
+ }
+
+ if ((s = xf86FindOptionValue (options, "Parity"))) {
+ xf86MarkOptionUsedByName (options, "Parity");
+ if (xf86NameCmp (s, "Odd") == 0)
+ linectl.parity = 1; /* odd */
+ else if (xf86NameCmp (s, "Even") == 0)
+ linectl.parity = 2; /* even */
+ else if (xf86NameCmp (s, "None") == 0)
+ linectl.parity = 0; /* none */
+ else {
+ xf86Msg (X_ERROR,
+ "Invalid Option Parity value: %s\n", s);
+ return -1;
+ }
+ }
+
+ /* set line parameters */
+ if (_set_linectl(fd,&linectl)) return -1;
+
+ if (xf86FindOptionValue (options, "Vmin"))
+ xf86Msg (X_ERROR, "Vmin unsupported on this OS\n");
+
+ if (xf86FindOptionValue (options, "Vtime"))
+ xf86Msg (X_ERROR, "Vtime unsupported on this OS\n");
+
+ /* get device parameters */
+ if (_get_dcb(fd,&dcb)) return -1;
+
+ if ((s = xf86FindOptionValue (options, "FlowControl"))) {
+ xf86MarkOptionUsedByName (options, "FlowControl");
+ if (xf86NameCmp (s, "XonXoff") == 0)
+ dcb.fbFlowReplace |= 0x03;
+ else if (xf86NameCmp (s, "None") == 0)
+ dcb.fbFlowReplace &= ~0x03;
+ else {
+ xf86Msg (X_ERROR,
+ "Invalid Option FlowControl value: %s\n", s);
+ return -1;
+ }
+ }
+
+ if ((s = xf86FindOptionValue (options, "ClearDTR"))) {
+ dcb.fbCtlHndShake &= ~0x03; /* DTR=0 */
+ xf86MarkOptionUsedByName (options, "ClearDTR");
+ }
+
+ if ((s = xf86FindOptionValue (options, "ClearRTS"))) {
+ dcb.fbFlowReplace &= ~0xc0; /* RTS=0 */
+ xf86MarkOptionUsedByName (options, "ClearRTS");
+ }
+
+ /* set device parameters */
+ return _set_dcb(fd,&dcb) ? -1 : 0;
+}
+
+int xf86ReadSerial (int fd, void *buf, int count)
+{
+ ULONG nread,nq;
+ APIRET rc;
+
+ /* emulate non-blocking read */
+ if (_get_nread((HFILE)fd,&nq)) return -1;
+ if (nq==0) return 0;
+ if (nq < count) count = nq;
+
+ rc = DosRead((HFILE)fd,(PVOID)buf,(ULONG)count,&nread);
+ return rc ? -1 : (int)nread;
+}
+
+int xf86WriteSerial (int fd, const void *buf, int count)
+{
+ ULONG nwrite;
+ APIRET rc = DosWrite((HFILE)fd,(PVOID)buf,(ULONG)count,&nwrite);
+ return rc ? -1 : (int)nwrite;
+}
+
+int xf86CloseSerial (int fd)
+{
+ APIRET rc = DosClose((HFILE)fd);
+ return rc ? -1 : 0;
+}
+
+int xf86WaitForInput (int fd, int timeout)
+{
+ APIRET rc;
+ ULONG dlen,nq;
+
+ do {
+ if (_get_nread((HFILE)fd,&nq)) return -1;
+ if (nq) return 1;
+
+ DosSleep(10);
+ timeout -= 10000; /* 10000 usec */
+ } while (timeout > 0);
+
+ return 0;
+}
+
+int xf86SerialSendBreak (int fd, int duration)
+{
+ USHORT data;
+ ULONG dlen;
+ APIRET rc;
+ rc = DosDevIOCtl((HFILE)fd,IOCTL_ASYNC,ASYNC_SETBREAKON,
+ NULL, 0, NULL,
+ &data, sizeof(data), &dlen);
+ if (rc)
+ return -1;
+ DosSleep(500);
+
+ rc = DosDevIOCtl((HFILE)fd,IOCTL_ASYNC,ASYNC_SETBREAKOFF,
+ NULL, 0, NULL,
+ &data, sizeof(data), &dlen);
+ return rc ? -1 : 0;
+}
+
+int xf86FlushInput(int fd)
+{
+ APIRET rc;
+ UCHAR buf;
+ ULONG nread,nq;
+
+ if (_get_nread((HFILE)fd,&nq)) return -1;
+
+ /* eat all chars in queue */
+ while (nq) {
+ rc = DosRead((HFILE)fd,&buf,1,&nread);
+ if (rc) return -1;
+ nq--;
+ }
+ return 0;
+}
+
+static struct states {
+ int xf;
+ int os;
+} modemStates[] = {
+ { XF86_M_DTR, 0x01 },
+ { XF86_M_RTS, 0x02 },
+ { XF86_M_CTS, 0x10 },
+ { XF86_M_DSR, 0x20 },
+ { XF86_M_RNG, 0x40 },
+ { XF86_M_CAR, 0x80 },
+};
+
+static int numStates = sizeof(modemStates) / sizeof(modemStates[0]);
+
+static int
+xf2osState(int state)
+{
+ int i;
+ int ret = 0;
+
+ for (i = 0; i < numStates; i++)
+ if (state & modemStates[i].xf)
+ ret |= modemStates[i].os;
+ return ret;
+}
+
+static int
+os2xfState(int state)
+{
+ int i;
+ int ret = 0;
+
+ for (i = 0; i < numStates; i++)
+ if (state & modemStates[i].os)
+ ret |= modemStates[i].xf;
+ return ret;
+}
+
+static int
+getOsStateMask(void)
+{
+ int i;
+ int ret = 0;
+ for (i = 0; i < numStates; i++)
+ ret |= modemStates[i].os;
+ return ret;
+}
+
+static int osStateMask = 0;
+
+static
+int _get_modem_state(int fd,ULONG* state)
+{
+ ULONG state1,len;
+
+ if (DosDevIOCtl((HFILE)fd,IOCTL_ASYNC,ASYNC_GETMODEMOUTPUT,
+ NULL,0,NULL, state, sizeof(BYTE), &len) != 0 ||
+ DosDevIOCtl((HFILE)fd,IOCTL_ASYNC,ASYNC_GETMODEMINPUT,
+ NULL,0,NULL, &state1, sizeof(BYTE), &len) != 0)
+ return -1;
+ *state |= state1;
+ *state &= 0xff;
+ return 0;
+}
+
+static
+int _set_modem_state(int fd,ULONG state,ULONG mask)
+{
+ int len;
+ struct {
+ BYTE onmask;
+ BYTE offmask;
+ } modemctrl;
+ modemctrl.onmask = state;
+ modemctrl.offmask = mask;
+
+ if (DosDevIOCtl((HFILE)fd,IOCTL_ASYNC,ASYNC_SETMODEMCTRL,
+ NULL,0,NULL, (PULONG)&modemctrl, sizeof(modemctrl), &len) != 0)
+ return -1;
+ else
+ return 0;
+}
+
+int
+xf86SetSerialModemState(int fd, int state)
+{
+ ULONG s;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+ if (!osStateMask)
+ osStateMask = getOsStateMask();
+
+ state = xf2osState(state);
+
+ if (_get_modem_state(fd,&s) != 0)
+ return -1;
+
+ s &= ~osStateMask;
+ s |= state;
+
+ return _set_modem_state(fd,s,0x03);
+}
+
+int
+xf86GetSerialModemState(int fd)
+{
+ ULONG s;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+ if (_get_modem_state(fd,&s) != 0)
+ return -1;
+
+ return os2xfState(s);
+}
+
+int
+xf86SerialModemSetBits(int fd, int bits)
+{
+ int ret;
+ int s;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+ s = xf2osState(bits);
+ return _set_modem_state(fd,s,0x03);
+}
+
+int
+xf86SerialModemClearBits(int fd, int bits)
+{
+ int ret;
+ int s;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+ s = xf2osState(bits);
+ return _set_modem_state(fd, 0, ~s & 0xff);
+}
+
+int
+xf86SetSerialSpeed (int fd, int speed)
+{
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+ return _set_baudrate(fd,speed);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_stubs.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_stubs.c
new file mode 100644
index 000000000..727a605d1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_stubs.c
@@ -0,0 +1,403 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_stubs.c,v 3.4 2002/05/31 18:46:02 dawes Exp $ */
+/*
+ * (c) Copyright 1996 by Holger Veit
+ * <Holger.Veit@gmd.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Holger Veit shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Holger Veit.
+ *
+ */
+/* $XConsortium: os2_stubs.c /main/3 1996/10/27 11:48:58 kaleb $ */
+
+#define I_NEED_OS2_H
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xpoll.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/time.h>
+
+/* This is there to resolve a symbol in Xvfb
+ * this version is somewhat crippled compared to the one in os2_io.c
+ */
+#ifdef OS2NULLSELECT
+
+/* This below implements select() for calls in xnest. It has been */
+/* somewhat optimized for improved performance, but assumes a few */
+/* things so it cannot be used as a general select. */
+
+#include <sys/select.h>
+#include <sys/errno.h>
+#define INCL_DOSSEMAPHORES
+#define INCL_DOSNPIPES
+#define INCL_DOSMISC
+#define INCL_DOSMODULEMGR
+#undef BOOL
+#undef BYTE
+#include <os2.h>
+
+HEV hPipeSem;
+HMODULE hmod_so32dll;
+static int (*os2_tcp_select)(int*,int,int,int,long);
+ULONG os2_get_sys_millis();
+extern int _files[];
+
+#define MAX_TCP 256
+/* These lifted from sys/emx.h. Change if that changes there! */
+#define F_SOCKET 0x10000000
+#define F_PIPE 0x20000000
+
+struct select_data
+{
+ fd_set read_copy;
+ fd_set write_copy;
+ BOOL have_read;
+ BOOL have_write;
+ int tcp_select_mask[MAX_TCP];
+ int tcp_emx_handles[MAX_TCP];
+ int tcp_select_copy[MAX_TCP];
+ int socket_nread;
+ int socket_nwrite;
+ int socket_ntotal;
+ int pipe_ntotal;
+ int pipe_have_write;
+ int max_fds;
+};
+
+int os2PseudoSelect(int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout)
+{
+static BOOL FirstTime=TRUE;
+static haveTCPIP=TRUE;
+ULONG timeout_ms;
+ULONG postCount, start_millis,now_millis;
+char faildata[16];
+struct select_data sd;
+BOOL any_ready;
+int np,ns, i,ready_handles,n;
+APIRET rc;
+
+sd.have_read=FALSE; sd.have_write=FALSE;
+sd.socket_nread=0; sd.socket_nwrite=0; sd.socket_ntotal=0;
+sd.max_fds=31; ready_handles=0; any_ready=FALSE;
+sd.pipe_ntotal=0; sd.pipe_have_write=FALSE;
+
+if(FirstTime){
+ /* First load the so32dll.dll module and get a pointer to the SELECT function */
+
+ if((rc=DosLoadModule(faildata,sizeof(faildata),"SO32DLL",&hmod_so32dll))!=0){
+ fprintf(stderr, "Could not load module so32dll.dll, rc = %d. Error note %s\n",rc,faildata);
+ haveTCPIP=FALSE;
+ }
+ if((rc = DosQueryProcAddr(hmod_so32dll, 0, "SELECT", (PPFN)&os2_tcp_select))!=0){
+ fprintf(stderr, "Could not query address of SELECT, rc = %d.\n",rc);
+ haveTCPIP=FALSE;
+ }
+ /* Call these a first time to set the semaphore */
+ /* rc = DosCreateEventSem(NULL, &hPipeSem, DC_SEM_SHARED, FALSE);
+ if(rc) {
+ fprintf(stderr, "Could not create event semaphore, rc=%d\n",rc);
+ return(-1);
+ }
+ rc = DosResetEventSem(hPipeSem, &postCount); */ /* Done in xtrans code for servers*/
+
+ /*fprintf(stderr, "Client select() done first-time stuff, sem handle %d.\n",hPipeSem);*/
+
+ FirstTime = FALSE;
+}
+
+/* Set up the time delay structs */
+
+ if(timeout!=NULL) {
+ timeout_ms=timeout->tv_sec*1000+timeout->tv_usec/1000;
+ }
+ else { timeout_ms=1000000; } /* This should be large enough... */
+ if(timeout_ms>0) start_millis=os2_get_sys_millis();
+
+/* Copy the masks */
+ {FD_ZERO(&sd.read_copy);}
+ {FD_ZERO(&sd.write_copy);}
+ if(readfds!=NULL){ XFD_COPYSET(readfds,&sd.read_copy); sd.have_read=TRUE;}
+ if(writefds!=NULL) {XFD_COPYSET(writefds,&sd.write_copy);sd.have_write=TRUE;}
+
+/* And zero the original masks */
+ if(sd.have_read){ FD_ZERO(readfds);}
+ if(sd.have_write) {FD_ZERO(writefds);}
+ if(exceptfds != NULL) {FD_ZERO(exceptfds);}
+
+/* Now we parse the fd_sets passed to select and separate pipe/sockets */
+ n = os2_parse_select(&sd,nfds);
+ if(n == -1) {
+ errno = EBADF;
+ return (-1);
+ }
+
+/* Now we have three cases: either we have sockets, pipes, or both */
+/* We handle all three cases differently to optimize things */
+
+/* Case 1: only pipes! */
+ if((sd.pipe_ntotal >0) && (!sd.socket_ntotal)){
+ np = os2_check_pipes(&sd,readfds,writefds);
+ if(np > 0){
+ return (np);
+ }
+ else if (np == -1) { return(-1); }
+ while(!any_ready){
+ rc = DosWaitEventSem(hPipeSem, 1L);
+ /* if(rc) fprintf(stderr,"Sem-wait timeout, rc = %d\n",rc); */
+ if(rc == 640) {
+ return(0);
+ }
+ if((rc != 0) && (rc != 95)) {errno= EBADF; return(-1);}
+ np = os2_check_pipes(&sd,readfds,writefds);
+ if (np > 0){
+ return(np);
+ }
+ else if (np < 0){ return(-1); }
+ }
+ }
+
+/* Case 2: only sockets. Just let the os/2 tcp select do the work */
+ if((sd.socket_ntotal > 0) && (!sd.pipe_ntotal)){
+ ns = os2_check_sockets(&sd, readfds, writefds, timeout_ms);
+ return (ns);
+ }
+
+/* Case 3: combination of both */
+ if((sd.socket_ntotal > 0) && (sd.pipe_ntotal)){
+ np = os2_check_pipes(&sd,readfds,writefds);
+ if(np > 0){
+ any_ready=TRUE;
+ ready_handles += np;
+ }
+ else if (np == -1) { return(-1); }
+
+ ns = os2_check_sockets(&sd,readfds,writefds, 0);
+ if(ns>0){
+ ready_handles+=ns;
+ any_ready = TRUE;
+ }
+ else if (ns == -1) {return(-1);}
+
+ while (!any_ready && timeout_ms){
+
+ rc = DosWaitEventSem(hPipeSem, 1L);
+ if (rc=640) return(0);
+ if(rc == 0){
+ np = os2_check_pipes(&sd,readfds,writefds);
+ if(np > 0){
+ ready_handles+=np;
+ any_ready = TRUE;
+ }
+ else if (np == -1) {
+ return(-1); }
+ }
+
+ ns = os2_check_sockets(&sd,readfds,writefds,exceptfds, 0);
+ if(ns>0){
+ ready_handles+=ns;
+ any_ready = TRUE;
+ }
+ else if (ns == -1) {return(-1);}
+
+ if (i%8 == 0) {
+ now_millis = os2_get_sys_millis();
+ if((now_millis-start_millis) > timeout_ms) timeout_ms = 0;
+ }
+ i++;
+ }
+ }
+
+return(ready_handles);
+}
+
+
+ULONG os2_get_sys_millis()
+{
+ APIRET rc;
+ ULONG milli;
+
+ rc = DosQuerySysInfo(14, 14, &milli, sizeof(milli));
+ if(rc) {
+ fprintf(stderr,"Bad return code querying the millisecond counter! rc=%d\n",rc);
+ return(0);
+ }
+ return(milli);
+}
+
+int os2_parse_select(sd,nfds)
+struct select_data *sd;
+int nfds;
+{
+ int i;
+ APIRET rc;
+/* First we determine up to which descriptor we need to check. */
+/* No need to check up to 256 if we don't have to (and usually we dont...)*/
+/* Note: stuff here is hardcoded for fd_sets which are int[8] as in EMX! */
+
+ if(nfds > sd->max_fds){
+ for(i=0;i<((FD_SETSIZE+31)/32);i++){
+ if(sd->read_copy.fds_bits[i] ||
+ sd->write_copy.fds_bits[i])
+ sd->max_fds=(i*32) +32;
+ }
+ }
+ else { sd->max_fds = nfds; }
+/* Check if result is greater than specified in select() call */
+ if(sd->max_fds > nfds) sd->max_fds = nfds;
+
+ if (sd->have_read)
+ {
+ for (i = 0; i < sd->max_fds; ++i) {
+ if (FD_ISSET (i, &sd->read_copy)){
+ if(_files[i] & F_SOCKET)
+ {
+ sd->tcp_select_mask[sd->socket_ntotal]=_getsockhandle(i);
+ sd->tcp_emx_handles[sd->socket_ntotal]=i;
+ sd->socket_ntotal++; sd->socket_nread++;
+ }
+ else if (_files[i] & F_PIPE)
+ {
+ sd -> pipe_ntotal++;
+ /* rc = DosSetNPipeSem((HPIPE)i, (HSEM) hPipeSem, i);
+ if(rc) { fprintf(stderr,"Error SETNPIPE rc = %d\n",rc); return -1;} */
+ }
+ }
+ }
+ }
+
+ if (sd->have_write)
+ {
+ for (i = 0; i < sd->max_fds; ++i) {
+ if (FD_ISSET (i, &sd->write_copy)){
+ if(_files[i] & F_SOCKET)
+ {
+ sd->tcp_select_mask[sd->socket_ntotal]=_getsockhandle(i);
+ sd->tcp_emx_handles[sd->socket_ntotal]=i;
+ sd->socket_ntotal++; sd->socket_nwrite++;
+ }
+ else if (_files[i] & F_PIPE)
+ {
+ sd -> pipe_ntotal++;
+ /* rc = DosSetNPipeSem((HPIPE)i, (HSEM) hPipeSem, i);
+ if(rc) { fprintf(stderr,"Error SETNPIPE rc = %d\n",rc); return -1;} */
+ sd -> pipe_have_write=TRUE;
+ }
+ }
+ }
+ }
+
+
+return(sd->socket_ntotal);
+}
+
+
+int os2_check_sockets(sd,readfds,writefds)
+struct select_data *sd;
+fd_set *readfds,*writefds;
+{
+ int e,i;
+ int j,n;
+ memcpy(sd->tcp_select_copy,sd->tcp_select_mask,
+ sd->socket_ntotal*sizeof(int));
+
+ e = os2_tcp_select(sd->tcp_select_copy,sd->socket_nread,
+ sd->socket_nwrite, 0, 0);
+
+ if(e == 0) return(e);
+/* We have something ready? */
+ if(e>0){
+ j = 0; n = 0;
+ for (i = 0; i < sd->socket_nread; ++i, ++j)
+ if (sd->tcp_select_copy[j] != -1)
+ {
+ FD_SET (sd->tcp_emx_handles[j], readfds);
+ n ++;
+ }
+ for (i = 0; i < sd->socket_nwrite; ++i, ++j)
+ if (sd->tcp_select_copy[j] != -1)
+ {
+ FD_SET (sd->tcp_emx_handles[j], writefds);
+ n ++;
+ }
+ errno = 0;
+
+ return n;
+ }
+ if(e<0){
+ /*Error -- TODO. EBADF is a good choice for now. */
+ fprintf(stderr,"Error in server select! e=%d\n",e);
+ errno = EBADF;
+ return (-1);
+ }
+ }
+
+/* Check to see if anything is ready on pipes */
+
+int os2_check_pipes(sd,readfds,writefds)
+struct select_data *sd;
+fd_set *readfds,*writefds;
+{
+int i,e;
+ULONG ulPostCount;
+PIPESEMSTATE pipeSemState[128];
+APIRET rc;
+ e = 0;
+ rc = DosResetEventSem(hPipeSem,&ulPostCount);
+ rc = DosQueryNPipeSemState((HSEM) hPipeSem, (PPIPESEMSTATE)&pipeSemState,
+ sizeof(pipeSemState));
+ if(rc) fprintf(stderr,"SELECT: rc from QueryNPipeSem: %d\n",rc);
+ i=0;
+ while (pipeSemState[i].fStatus != 0) {
+ /*fprintf(stderr,"SELECT: sem entry, stat=%d, flag=%d, key=%d,avail=%d\n",
+ pipeSemState[i].fStatus,pipeSemState[i].fFlag,pipeSemState[i].usKey,
+ pipeSemState[i].usAvail); */
+ if((pipeSemState[i].fStatus == 1) &&
+ (FD_ISSET(pipeSemState[i].usKey,&sd->read_copy))){
+ FD_SET(pipeSemState[i].usKey,readfds);
+ e++;
+ }
+ else if((pipeSemState[i].fStatus == 2) &&
+ (FD_ISSET(pipeSemState[i].usKey,&sd->write_copy))){
+ FD_SET(pipeSemState[i].usKey,writefds);
+ e++;
+ }
+ else if( (pipeSemState[i].fStatus == 3) &&
+ ( (FD_ISSET(pipeSemState[i].usKey,&sd->read_copy)) ||
+ (FD_ISSET(pipeSemState[i].usKey,&sd->write_copy)) )){
+ errno = EBADF;
+ /* fprintf(stderr,"Pipe has closed down, fd=%d\n",pipeSemState[i].usKey); */
+ return (-1);
+ }
+ i++;
+ } /* endwhile */
+ /*fprintf(stderr,"Done listing pipe sem entries, total %d entries, total ready entries %d\n",i,e);*/
+errno = 0;
+return(e);
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c
new file mode 100644
index 000000000..c45b3165e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c
@@ -0,0 +1,241 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c,v 3.15 2002/05/31 18:46:02 dawes Exp $ */
+/*
+ * (c) Copyright 1994,1999 by Holger Veit
+ * <Holger.Veit@gmd.de>
+ * Modified 1996 by Sebastien Marineau <marineau@genie.uottawa.ca>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Holger Veit shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Holger Veit.
+ *
+ */
+/* $XConsortium: os2_video.c /main/8 1996/10/27 11:49:02 kaleb $ */
+
+#define I_NEED_OS2_H
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#define INCL_DOSFILEMGR
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#include "compiler.h"
+
+/***************************************************************************/
+/* Video Memory Mapping helper functions */
+/***************************************************************************/
+
+/* This section uses the xf86sup.sys driver developed for xfree86.
+ * The driver allows mapping of physical memory
+ * You must install it with a line DEVICE=path\xf86sup.sys in config.sys.
+ */
+
+#define LOWORD(X) ((X) & 0xffff)
+#define HIWORD(X) ((X) >> 16)
+
+static HFILE mapdev = -1;
+static ULONG stored_virt_addr;
+static char* mappath = "\\DEV\\PMAP$";
+static HFILE open_mmap()
+{
+ APIRET rc;
+ ULONG action;
+
+ if (mapdev != -1)
+ return mapdev;
+
+ rc = DosOpen((PSZ)mappath, (PHFILE)&mapdev, (PULONG)&action,
+ (ULONG)0, FILE_SYSTEM, FILE_OPEN,
+ OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT|OPEN_ACCESS_READONLY,
+ (ULONG)0);
+ if (rc!=0) {
+ mapdev = -1; }
+ else {
+ /* fg030203: ask for driver version of xf86sup.sys;
+ no output prior to version 1.539 */
+ struct {
+ ULONG magic;
+ ULONG drvtype;
+ ULONG version;
+ } drvid;
+ ULONG dlen = sizeof(drvid);
+ if ((rc=DosDevIOCtl(mapdev, (ULONG)0x76, (ULONG)0x61,
+ (PVOID)NULL, (ULONG)0, (PULONG)NULL,
+ (PVOID)&drvid, (ULONG)dlen, (PULONG)&dlen))==0) {
+ xf86Msg(X_INFO,"PMAP$: driver version = %x.%x\n",
+ HIWORD(drvid.version),
+ LOWORD(drvid.version));
+ }
+ }
+ return mapdev;
+}
+
+static void close_mmap()
+{
+ if (mapdev != -1)
+ DosClose(mapdev);
+ mapdev = -1;
+}
+
+/* this structure is used as a parameter packet for the direct access
+ * ioctl of pmap$
+ */
+
+/* Changed here for structure of driver PMAP$ */
+
+typedef struct{
+ ULONG addr;
+ ULONG size;
+} DIOParPkt;
+
+/* This is the data packet for the mapping function */
+
+typedef struct {
+ ULONG addr;
+ USHORT sel;
+} DIODtaPkt;
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+/* ARGSUSED */
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ DIOParPkt par;
+ ULONG plen;
+ DIODtaPkt dta;
+ ULONG dlen;
+ static BOOL ErrRedir = FALSE;
+ APIRET rc;
+
+ par.addr = (ULONG)Base;
+ par.size = (ULONG)Size;
+ plen = sizeof(par);
+ dlen = sizeof(dta);
+
+ open_mmap();
+ if (mapdev == -1)
+ FatalError("mapVidMem: install DEVICE=path\\XF86SUP.SYS!");
+
+ if ((rc=DosDevIOCtl(mapdev, (ULONG)0x76, (ULONG)0x44,
+ (PVOID)&par, (ULONG)plen, (PULONG)&plen,
+ (PVOID)&dta, (ULONG)dlen, (PULONG)&dlen)) == 0) {
+ xf86Msg(X_INFO,"mapVidMem succeeded: (ScreenNum=%d, Base=0x%x, Size=0x%x, vaddr=0x%x)\n",
+ ScreenNum, Base, Size, dta.addr);
+
+ if (dlen==sizeof(dta)) {
+ return (pointer)dta.addr;
+ }
+ /*else fail*/
+ }
+
+ /* fail */
+ FatalError("mapVidMem FAILED!!: rc = %d (ScreenNum=%d, Base=0x%x, Size=0x%x, return len=%d, vaddr=0x%x, sel=0x%x)\n",
+ rc, ScreenNum, Base, Size, dlen, dta.addr, dta.sel);
+ return (pointer)0;
+}
+
+/* ARGSUSED */
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ DIOParPkt par;
+ ULONG plen,vmaddr;
+ APIRET rc;
+/* We need here the VIRTADDR for unmapping, not the physical address */
+/* This should be taken care of either here by keeping track of allocated */
+/* pointers, but this is also already done in the driver... Thus it would */
+/* be a waste to do this tracking twice. Can this be changed when the fn. */
+/* is called? This would require tracking this function in all servers, */
+/* and changing it appropriately to call this with the virtual adress */
+/* If the above mapping function is only called once, then we can store */
+/* the virtual adress and use it here.... */
+
+ par.addr = (ULONG)Base;
+ par.size = 0xffffffff; /* This is the virtual address parameter. Set this to ignore */
+ plen = sizeof(par);
+
+ if (mapdev != -1)
+ rc = DosDevIOCtl(mapdev, (ULONG)0x76, (ULONG)0x45,
+ (PVOID)&par, (ULONG)plen, (PULONG)&plen,
+ &vmaddr, sizeof(ULONG), &plen);
+ if (!rc) {
+ xf86Msg(X_INFO,"unmapVidMem: Unmap phys memory at virtual address 0x%x\n",
+ vmaddr);
+ }
+ else {
+ xf86Msg(X_ERROR,"unmapVidMem: Unmap phys memory at base 0x%x, virtual address 0x%x, rc=%d\n",
+ Base,vmaddr,rc);
+ }
+/* Now if more than one region has been allocated and we close the driver,
+ * the other pointers will immediately become invalid. We avoid closing
+ * driver for now, but this should be fixed for server exit
+ */
+
+ /* close_mmap(); */
+}
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+Bool xf86DisableInterrupts()
+{
+ /* allow interrupt disabling but check for side-effects.
+ * Not a good policy on OS/2...
+ */
+ asm ("cli");
+ return TRUE;
+}
+
+void xf86EnableInterrupts()
+{
+ /*Reenable*/
+ asm ("sti");
+}
+
+/***************************************************************************/
+/* Initialize video memory */
+/***************************************************************************/
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->linearSupported = TRUE;
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+#if 0
+ pVidMem->mapMemSparse = 0;
+ pVidMem->unmapMemSparse = 0;
+#endif
+ pVidMem->setWC = 0; /* no MTRR support */
+ pVidMem->undoWC = 0;
+ pVidMem->initialised = TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile
new file mode 100644
index 000000000..37cc186c4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile
@@ -0,0 +1,48 @@
+
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile,v 1.11 2002/10/11 01:47:00 dawes Exp $
+
+#include <Server.tmpl>
+
+MOUSESRC = pmax_mouse.c
+MOUSEOBJ = pmax_mouse.o
+
+SRCS = pmax_devs.c pmax_init.c pmax_map.c pmax_pci.c pmax_ppc.c \
+ bios_V4mmap.c VTsw_usl.c sysv_kbd.c std_kbdEv.c \
+ posix_tty.c $(MOUSESRC) xqueue.c ioperm_noop.c \
+ libc_wrapper.c stdResource.c stdPci.o sigiostubs.c pm_noop.c \
+ kmod_noop.c agp_noop.c
+
+OBJS = pmax_devs.o pmax_init.o pmax_map.o pmax_pci.o pmax_ppc.o \
+ bios_V4mmap.o VTsw_usl.o sysv_kbd.o std_kbdEv.o \
+ posix_tty.o $(MOUSESRC) xqueue.o ioperm_noop.o \
+ libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o \
+ kmod_noop.o agp_noop.o
+
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(XF86OSSRC)/bus -I. \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(EXTINCSRC) -I../sysv
+
+RESDEFINES = -DUSESTDRES
+
+DEFINES = $(RESDEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+LinkSourceFile(VTsw_usl.c,../shared)
+LinkSourceFile(ioperm_noop.c,../shared)
+LinkSourceFile(sysv_kbd.c,../shared)
+LinkSourceFile(std_kbdEv.c,../shared)
+LinkSourceFile(posix_tty.c,../shared)
+LinkSourceFile(libc_wrapper.c,../shared)
+LinkSourceFile(stdResource.c,../shared)
+LinkSourceFile(stdPci.c,../shared)
+LinkSourceFile(sigiostubs.c,../shared)
+LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
+LinkSourceFile(agp_noop.c,../shared)
+
+LinkSourceFile(bios_V4mmap.c,../sysv)
+LinkSourceFile(xqueue.c,../sysv)
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_devs.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_devs.c
new file mode 100644
index 000000000..f221e0755
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_devs.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright 1998 by Concurrent Computer Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Concurrent Computer
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Concurrent Computer Corporation makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Copyright 1998 by Metro Link Incorporated
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * This module was derived in part from the original XFree86
+ * sysv/sysv_io.c which contains the following copyright notice:
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Dawes <dawes@xfree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Dawes
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Thomas Roell and
+ * David Dawes makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_devs.c,v 1.7 2002/10/11 01:40:36 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
+{
+ if (loudness && pitch)
+ {
+#ifdef KDMKTONE
+ /*
+ * If we have KDMKTONE use it to avoid putting the server
+ * to sleep
+ */
+ ioctl(xf86Info.consoleFd, KDMKTONE,
+ ((1193190 / pitch) & 0xffff) |
+ (((unsigned long)duration *
+ loudness / 50) << 16));
+#else
+ ioctl(xf86Info.consoleFd, KIOCSOUND, 1193180 / pitch);
+ usleep(xf86Info.bell_duration * loudness * 20);
+ ioctl(xf86Info.consoleFd, KIOCSOUND, 0);
+#endif
+ }
+}
+
+void
+xf86SetKbdLeds(int leds)
+{
+#if 0 /* used to be KBIO_SETMODE */
+ ioctl(xf86Info.consoleFd, KBIO_SETMODE, KBM_AT);
+ ioctl(xf86Info.consoleFd, KDSETLED, leds);
+ ioctl(xf86Info.consoleFd, KBIO_SETMODE, KBM_XT);
+#endif
+
+ ioctl(xf86Info.consoleFd, KDSETLED, leds);
+}
+
+#include "xf86OSKbd.h"
+
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+ return FALSE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_init.c
new file mode 100644
index 000000000..7da733d22
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_init.c
@@ -0,0 +1,473 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_init.c,v 1.2.2.2 1998/07/18 17:53:54 dawes Exp $ */
+/*
+ * Copyright 1998 by Concurrent Computer Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Concurrent Computer
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Concurrent Computer Corporation makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Copyright 1998 by Metro Link Incorporated
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * This file was derived in part from the original XFree86 sysv OS
+ * support which contains the following copyright notice:
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Thomas Roell and
+ * David Wexelblat makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/types.h>
+#include <time.h>
+#include <errno.h>
+
+#include <sys/prosrfs.h>
+#include <sys/cpu.h>
+#include <sys/ipl.h>
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+static Bool KeepTty = FALSE;
+static Bool Protect0 = FALSE;
+static Bool pmaxInitialized = FALSE;
+
+#define VT_DEFAULT -2
+#define VT_NONE -1
+
+static int VTnum = VT_DEFAULT;
+
+extern void pmax_init_splmap(void);
+
+int pmax_sys_type; /* Also used by pmax_pci.c */
+
+/*
+ * PowerMAXOS_sys_type()
+ *
+ * Determine type of PowerHawk, PowerStack, PowerMaxion, or NightHawk
+ */
+int
+PowerMAXOS_sys_type(void)
+{
+ int fd;
+ procfile_t procfile;
+
+ fd = open("/system/processor/0",O_RDONLY);
+ if (fd<0) {
+ FatalError("Cannot open '%s'\n", "/system/processor/0");
+ }
+
+ if (read(fd, &procfile, sizeof(procfile)) < 0) {
+ FatalError("Cannot read '%s'\n", "/system/processor/0");
+ }
+ close(fd);
+
+ return(procfile.cpu_model);
+}
+
+void
+pmaxInit(void)
+{
+ char *mach;
+
+ if (pmaxInitialized)
+ return;
+
+ pmaxInitialized = TRUE;
+
+ /*
+ * Determine type of machine
+ */
+ pmax_sys_type = PowerMAXOS_sys_type();
+ switch(pmax_sys_type) {
+
+ case MODEL_NH6400:
+ mach ="PowerMAXION (NH6400)";
+ break;
+
+ case MODEL_NH6408:
+ mach = "PowerMAXION (NH6408)";
+ break;
+
+ case MODEL_NH6800T:
+ mach = "TurboHawk";
+ break;
+
+ case MODEL_MPWR:
+ mach = "PowerStack";
+ break;
+
+ case MODEL_PH610:
+ mach = "PowerHawk 610";
+ break;
+
+ case MODEL_MPWR2:
+ mach = "PowerStack II (utah)";
+ break;
+
+ case MODEL_PH620:
+ mach = "PowerHawk 620";
+ break;
+
+ case MODEL_PH640:
+ mach = "PowerHawk 640";
+ break;
+
+ case MODEL_MMTX:
+ mach = "PowerStack II (MTX)";
+ break;
+
+ default:
+ FatalError("pmaxInit: Unknown/unsupported machine type 0x%x\n",
+ pmax_sys_type);
+ /*NOTREACHED*/
+ }
+
+ xf86Msg(X_INFO, "pmaxInit: Machine type: %s\n", mach);
+
+ /*
+ * Map IPL hardware so that interrupts can be (temporarily) disabled
+ * (see pmax_video.c)
+ */
+ pmax_init_splmap();
+
+ /*
+ * Now that we know the system type, initialize the
+ * pci access routines
+ */
+ pciInit();
+}
+
+void
+xf86OpenConsole()
+{
+ struct vt_mode VT;
+ char vtname[10];
+ MessageType from = X_DEFAULT;
+
+ if (serverGeneration == 1)
+ {
+
+ /* check if we're run with euid==0 */
+ if (geteuid() != 0)
+ {
+ FatalError("xf86OpenConsole: Server must be suid root\n");
+ }
+
+ /* Protect page 0 to help find NULL dereferencing */
+ /* mprotect() doesn't seem to work */
+ if (Protect0)
+ {
+ int fd = -1;
+
+ if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: cannot open /dev/zero (%s)\n",
+ strerror(errno));
+ }
+ else
+ {
+ if ((int)mmap(0, 0x1000, PROT_NONE,
+ MAP_FIXED | MAP_SHARED, fd, 0) == -1)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: failed to protect page 0 (%s)\n",
+ strerror(errno));
+ }
+ close(fd);
+ }
+ }
+
+ pmaxInit(); /* Initialize OS specific functions */
+
+ /*
+ * setup the virtual terminal manager
+ */
+ if (VTnum == VT_DEFAULT) {
+ int fd;
+
+ /*
+ * No specific VT specified, so ask the vtl term mgr
+ * for the next available VT
+ */
+ if ((fd = open("/dev/vt00",O_WRONLY,0)) < 0) {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: Could not open /dev/vt00 (%s)\n",
+ strerror(errno));
+ VTnum = VT_NONE;
+ }
+ else {
+ if (ioctl(fd, VT_OPENQRY, &VTnum) < 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: Cannot find a free VT\n");
+ VTnum = VT_NONE;
+ }
+ close(fd);
+ }
+ } else {
+ from = X_CMDLINE;
+ }
+
+ xf86Info.vtno = VTnum;
+
+ if (xf86Info.vtno == VT_NONE)
+ strcpy(vtname, "/dev/null");
+ else
+ sprintf(vtname,"/dev/vt%02d",xf86Info.vtno);
+
+ xf86Msg(from, "using VT \"%s\"\n\n", vtname);
+
+ if (!KeepTty)
+ {
+ setpgrp();
+ }
+
+ if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) < 0)
+ {
+ FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
+ vtname, strerror(errno));
+ }
+
+ if (xf86Info.vtno != VT_NONE)
+ {
+ /* change ownership of the vt */
+ (void) chown(vtname, getuid(), getgid());
+
+ /*
+ * now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
+ {
+ FatalError("xf86OpenConsole: VT_GETMODE failed\n");
+ }
+
+ signal(SIGUSR1, xf86VTRequest);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
+ {
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ {
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
+ }
+ }
+ }
+ else
+ {
+ /* serverGeneration != 1 */
+ /*
+ * now get the VT
+ */
+ if (xf86Info.vtno != VT_NONE)
+ {
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+ }
+ /*
+ * If the server doesn't have the VT when the reset occurs,
+ * this is to make sure we don't continue until the activate
+ * signal is received.
+ */
+ if (!xf86Screens[0]->vtSema)
+ sleep(5);
+ }
+ }
+ return;
+}
+
+void xf86CloseConsole()
+{
+ struct vt_mode VT;
+
+ if (xf86Info.vtno != VT_NONE)
+ {
+
+#if 0
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno);
+ ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0);
+#endif
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
+ {
+ VT.mode = VT_AUTO;
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
+ }
+ }
+
+ close(xf86Info.consoleFd); /* make the vt-manager happy */
+ return;
+}
+
+int xf86ProcessArgument(argc, argv, i)
+int argc;
+char *argv[];
+int i;
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty"))
+ {
+ KeepTty = TRUE;
+ return(1);
+ }
+
+ /*
+ * Prevent server from attemping to open a new VT in the "-novt"
+ * flag was specified.
+ */
+ if (!strcmp(argv[i], "-novt"))
+ {
+ VTnum = VT_NONE;
+ return(1);
+ }
+
+ /*
+ * Undocumented flag to protect page 0 from read/write to help
+ * catch NULL pointer dereferences. This is purely a debugging
+ * flag.
+ */
+ if (!strcmp(argv[i], "-protect0"))
+ {
+ Protect0 = TRUE;
+ return(1);
+ }
+
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+ {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
+ {
+ UseMsg();
+ VTnum = VT_DEFAULT;
+ return(0);
+ }
+ return(1);
+ }
+ return(0);
+}
+
+void xf86UseMsg()
+{
+ ErrorF("vtXX use the specified VT number\n");
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+ ErrorF("-novt ");
+ ErrorF("don't allocate and open a new virtual terminal\n");
+ return;
+}
+
+
+void
+xf86_pmax_usleep(unsigned long n)
+{
+ struct timespec requested,remaining;
+ int rv;
+
+ requested.tv_sec = n/1000000;
+ requested.tv_nsec = (n % 1000000) * 1000;
+
+ while ((rv = nanosleep(&requested,&remaining)) < 0) {
+ if (errno != EINTR)
+ break;
+
+ remaining = requested; /* structure assignment */
+ }
+
+ if (rv) {
+ ErrorF("xf86_pmax_usleep: nanosleep() failed: rv=%d, errno=%d\n", rv, errno);
+ }
+}
+
+#ifndef usleep
+
+void
+usleep(unsigned long n)
+{
+ xf86_pmax_usleep(n);
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c
new file mode 100644
index 000000000..36d3366a2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c
@@ -0,0 +1,239 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c,v 1.7 2000/06/27 14:27:31 tsi Exp $ */
+/*
+ * Copyright 1998 by Concurrent Computer Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Concurrent Computer
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Concurrent Computer Corporation makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Copyright 1998 by Metro Link Incorporated
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * This file was derived in part from the original XFree86 sysv OS
+ * support which contains the following copyright notice:
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Thomas Roell and
+ * David Wexelblat makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include "Pci.h"
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+/*
+ * Map an I/O region given its address (host POV)
+ */
+void *
+pmax_iomap(unsigned long base, unsigned long len)
+{
+ int fd;
+ void *rv;
+
+ if ((fd = open("/dev/iomem", O_RDWR)) < 0)
+ {
+ ErrorF("pmax_iomap: failed to open /dev/iomem (%s)\n",
+ strerror(errno));
+ return(MAP_FAILED);
+ }
+
+ rv = (void *)mmap((caddr_t)0, len, PROT_READ|PROT_WRITE,
+ MAP_SHARED, fd, (off_t)base);
+
+ close(fd);
+ return(rv);
+}
+
+Bool
+xf86LinearVidMem()
+{
+ return TRUE;
+}
+
+extern void * pmax_iomap(unsigned long, unsigned long);
+
+pointer
+xf86MapVidMem(int ScreenNum, int Region, pointer Base, unsigned long Size)
+{
+ ErrorF("%s: Not supported on this OS. Drivers should use xf86MapPciMem() instead\n",
+ "xf86MapVidMem");
+ FatalError("%s: Cannot map [s=%x,a=%x]\n", "xf86MapVidMem", Size, Base);
+}
+
+
+pointer
+xf86MapPciMem(int ScreenNum, int Flags, PCITAG Tag, pointer Base,
+ unsigned long Size)
+{
+ pointer hostbase = pciBusAddrToHostAddr(Tag, Base);
+ pointer base;
+
+ base = (pointer) pmax_iomap((unsigned long)hostbase, Size);
+ if (base == MAP_FAILED) {
+ xf86Msg(X_WARNING,
+ "xf86MapPciMem: Could not mmap PCI memory "
+ "[base=0x%x,hostbase=0x%x,size=%x] (%s)\n",
+ Base, hostbase, Size, strerror(errno));
+ }
+ return((pointer)base);
+}
+
+
+/* ARGSUSED */
+void
+xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap(Base, Size);
+}
+
+/*
+ * Read BIOS via mmap()ing /dev/iomem.
+ */
+/*ARGSUSED*/
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, int Len)
+{
+ ErrorF("%s: Not supported on this OS. Drivers should use xf86ReadPciBIOS() instead\n",
+ "xf86ReadBIOS");
+ FatalError("%s: Cannot read BIOS [base=0x%x,offset=0x%x,size=%d]\n", "xf86ReadBIOS", Base, Offset, Len);
+}
+
+int
+xf86ReadPciBIOS(unsigned long Base, unsigned long Offset, PCITAG Tag,
+ unsigned char *Buf, int Len)
+{
+ pointer hostbase = pciBusAddrToHostAddr(Tag, (void *)Base);
+ char *base;
+ int psize;
+ int mlen;
+
+ psize = xf86getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ base = pmax_iomap((unsigned long)hostbase, mlen);
+ if (base == MAP_FAILED) {
+ xf86Msg(X_WARNING, "xf86ReadPciBIOS: Could not mmap PCI memory"
+ " [base=0x%x,hostbase=0x%x,size=%x] (%s)\n",
+ Base, hostbase, mlen, strerror(errno));
+ return(0);
+ }
+
+ (void)memcpy(Buf, base + Offset, Len);
+ (void)munmap(base, mlen);
+ return(Len);
+}
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+#include <sys/ipl.h>
+
+#ifndef PL_HI
+#define PL_HI PL8
+#endif
+
+#ifndef PL_0
+#define PL_0 PL0
+#endif
+
+static void *spl_map_addr = NULL;
+
+void
+pmax_init_splmap(void)
+{
+ spl_map_addr = spl_map(0);
+ if (!spl_map_addr) {
+ xf86Msg(X_WARNING,
+ "pmax_init_splmap: spl_map() failed. "
+ "Cannot bind to IPL register\n");
+ xf86ErrorF("\tInterrupts cannot be disabled/enabled !!!\n");
+ }
+}
+
+
+Bool
+xf86DisableInterrupts()
+{
+ if (spl_map_addr) {
+ (void)spl_request(PL_HI,spl_map_addr);
+ return(TRUE);
+ }
+
+ return(FALSE);
+}
+
+void xf86EnableInterrupts()
+{
+ if (spl_map_addr) {
+ (void)spl_request(PL_0, spl_map_addr);
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_mouse.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_mouse.c
new file mode 100644
index 000000000..1568598c4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_mouse.c
@@ -0,0 +1,60 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_mouse.c,v 1.2 1999/09/04 13:04:46 dawes Exp $ */
+
+/*
+ * Copyright 1999 by The XFree86 Project, Inc.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+#include "xqueue.h"
+
+static int
+SupportedInterfaces(void)
+{
+ /* XXX Need to check this. */
+ return MSE_SERIAL | MSE_AUTO;
+}
+
+static const char *internalNames[] = {
+ "Xqueue",
+ NULL
+};
+
+static const char **
+BuiltinNames(void)
+{
+ return internalNames;
+}
+
+static Bool
+CheckProtocol(const char *protocol)
+{
+ int i;
+
+ for (i = 0; internalNames[i]; i++)
+ if (xf86NameCmp(protocol, internalNames[i]) == 0)
+ return TRUE;
+ return FALSE;
+}
+
+OSMouseInfoPtr
+xf86OSMouseInit(int flags)
+{
+ OSMouseInfoPtr p;
+
+ p = xcalloc(sizeof(OSMouseInfoRec), 1);
+ if (!p)
+ return NULL;
+ p->SupportedInterfaces = SupportedInterfaces;
+ p->BuiltinNames = BuiltinNames;
+ p->CheckProtocol = CheckProtocol;
+ p->PreInit = XqueueMousePreInit;
+ return p;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_pci.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_pci.c
new file mode 100644
index 000000000..21f20dff8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_pci.c
@@ -0,0 +1,1072 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_pci.c,v 1.6 2002/07/24 19:06:53 tsi Exp $ */
+/*
+ * Copyright 1998 by Concurrent Computer Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Concurrent Computer
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Concurrent Computer Corporation makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Copyright 1998 by Metro Link Incorporated
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include "os.h"
+#include "compiler.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "Pci.h"
+
+#include <sys/prosrfs.h>
+#include <sys/cpu.h>
+
+/*
+ * Night Hawk 6400/6408 platform support
+ */
+#undef NH640X_PCI_MFDEV_SUPPORT
+#undef NH640X_PCI_BRIDGE_SUPPORT
+
+static void nh640xPciInit(void);
+static PCITAG nh640xPciFindNext(void);
+static PCITAG nh640xPciFindFirst(void);
+static CARD32 nh6400PciReadLong(PCITAG tag, int offset);
+static void nh6400PciWriteLong(PCITAG tag, int offset, CARD32 val);
+static ADDRESS nh6400BusToHostAddr(PCITAG tag, ADDRESS addr);
+static ADDRESS nh6400HostToBusAddr(PCITAG tag, ADDRESS addr);
+static CARD32 nh6408PciReadLong(PCITAG tag, int offset);
+static void nh6408PciWriteLong(PCITAG tag, int offset, CARD32 val);
+static ADDRESS nh6408BusToHostAddr(PCITAG tag, ADDRESS addr);
+static ADDRESS nh6408HostToBusAddr(PCITAG tag, ADDRESS addr);
+
+static pciBusFuncs_t nh6400_pci_funcs = {
+ nh6400PciReadLong,
+ nh6400PciWriteLong,
+ nh6400HostToBusAddr,
+ nh6400BusToHostAddr
+};
+
+static pciBusFuncs_t nh6408_pci_funcs = {
+ nh6408PciReadLong,
+ nh6408PciWriteLong,
+ nh6408HostToBusAddr,
+ nh6408BusToHostAddr
+};
+
+/*
+ * NH640x CFG address and data register offsets from base
+ */
+#define NH6400_PCI_CFG_ADDR_REG_OFF 0
+#define NH6400_PCI_CFG_TYPE0_DATA_REG_OFF 0x40
+#define NH6400_PCI_CFG_TYPE1_DATA_REG_OFF 0x80
+
+#define NH6408_PCI_CFG_ADDR_REG_OFF 0
+#define NH6408_PCI_CFG_DATA_REG_OFF 0x10000
+
+/*
+ * Possible cfg addr values for NH640x GMEM PMC ports
+ */
+static unsigned long nh6400_pmc_cfgaddrs[] = {
+ PCI_CFGMECH1_TYPE0_CFGADDR(0,0,0)
+};
+
+/*
+ * Possible cfg addr values for devices on a secondary bus
+ * (e.g. behind DEC 21152 PCI-to-PCI bridge)
+ */
+static unsigned long dec_cfgaddrs[] = {
+ PCI_CFGMECH1_TYPE1_CFGADDR(1,0,0,0),
+ PCI_CFGMECH1_TYPE1_CFGADDR(1,1,0,0),
+ PCI_CFGMECH1_TYPE1_CFGADDR(1,2,0,0),
+ PCI_CFGMECH1_TYPE1_CFGADDR(1,3,0,0),
+ PCI_CFGMECH1_TYPE1_CFGADDR(1,4,0,0),
+ PCI_CFGMECH1_TYPE1_CFGADDR(1,5,0,0),
+ PCI_CFGMECH1_TYPE1_CFGADDR(1,6,0,0),
+ PCI_CFGMECH1_TYPE1_CFGADDR(1,7,0,0),
+ PCI_CFGMECH1_TYPE1_CFGADDR(1,8,0,0),
+ PCI_CFGMECH1_TYPE1_CFGADDR(1,9,0,0),
+ PCI_CFGMECH1_TYPE1_CFGADDR(1,10,0,0),
+ PCI_CFGMECH1_TYPE1_CFGADDR(1,11,0,0),
+ PCI_CFGMECH1_TYPE1_CFGADDR(1,12,0,0),
+ PCI_CFGMECH1_TYPE1_CFGADDR(1,13,0,0),
+ PCI_CFGMECH1_TYPE1_CFGADDR(1,14,0,0),
+ PCI_CFGMECH1_TYPE1_CFGADDR(1,15,0,0)
+};
+
+/*
+ * Data structure holding information about various nh640x PCI buses
+ */
+struct nh640x_pci_info {
+ int busnum;
+ int type;
+ unsigned long num_cfg_addrs;
+ unsigned long *cfg_addrs;
+ int primary_bus;
+ unsigned long cfgPhysBase;
+ unsigned long memBase;
+ unsigned long ioBase;
+ unsigned long ioSize;
+ unsigned char *cfgAddrReg; /* After mapping */
+};
+
+/* Type */
+#define PRIMARY_PCI 0
+#define SECONDARY_PCI 1
+
+static struct nh640x_pci_info nh6400_pci_info[] = {
+/* pci4 */ { 4, PRIMARY_PCI, 1, nh6400_pmc_cfgaddrs, 0, 0xa0000000, 0xa1000000, 0, 0xa2000000 },
+/* pci12 */ { 12, SECONDARY_PCI, 16, dec_cfgaddrs, 4 },
+#if 0
+/* pci5 */ { 5, PRIMARY_PCI, 1, nh6400_pmc_cfgaddrs, 0, 0xb0000000, 0xb1000000, 0, 0xb2000000 },
+/* pci13 */ { 13, SECONDARY_PCI, 16, dec_cfgaddrs, 5 },
+#endif
+};
+
+#define NH6400_NUM_PCI_EXPANSION_BUSES (sizeof(nh6400_pci_info)/sizeof(struct nh640x_pci_info))
+
+static struct nh640x_pci_info nh6408_pci_info[] = {
+/* pci8 */ { 8, PRIMARY_PCI, 1, nh6400_pmc_cfgaddrs, 0, 0x98040000, 0x9a800000, 65536, 0xa0000000 },
+/* pci12 */ { 12, SECONDARY_PCI, 16, dec_cfgaddrs, 8, },
+#if 0
+/* pci9 */ { 9, PRIMARY_PCI, 1, nh6400_pmc_cfgaddrs, 0, 0x99040000, 0x9b800000, 65536, 0xb0000000 },
+/* pci13 */ { 13, SECONDARY_PCI, 16, dec_cfgaddrs, 9, },
+#endif
+};
+
+#define NH6408_NUM_PCI_EXPANSION_BUSES (sizeof(nh6408_pci_info)/sizeof(struct nh640x_pci_info))
+
+extern unsigned long pmax_sys_type;
+
+#define MOTOPPC_IO_BASE 0x80000000L /* Start of PCI/ISA I/O region */
+
+extern void * pmax_iomap(unsigned long, unsigned long);
+extern unsigned long ioSize;
+extern volatile unsigned char *ioBase;
+
+void
+pmaxPciInit(void)
+{
+ extern void motoppcPciInit(void);
+ extern void nh640xPciInit(void);
+ extern void nh6800tPciInit(void);
+
+ extern unsigned long motoPciMemBase;
+ extern unsigned long motoPciMemLen;
+ extern unsigned long motoPciMemBaseCPU;
+
+ /*
+ * Determine type of machine
+ */
+ switch(pmax_sys_type) {
+ case MODEL_NH6400:
+ case MODEL_NH6408:
+ nh640xPciInit();
+ break;
+
+ case MODEL_NH6800T:
+ nh6800tPciInit();
+ break;
+
+ case MODEL_PH620:
+ case MODEL_PH640:
+ case MODEL_MMTX:
+ motoPciMemBase = 0;
+ motoPciMemLen = 0x20000000;
+ motoPciMemBaseCPU = 0xa0000000;
+ /*FALLTHROUGH*/
+
+ case MODEL_MPWR:
+ case MODEL_PH610:
+ case MODEL_MPWR2:
+ motoppcPciInit();
+ break;
+
+ default:
+ FatalError("pmaxPciInit: Unsupported machine type\n");
+ break;
+ }
+}
+
+void
+ppcPciIoMap(int pcibus)
+{
+ int primary_bus;
+
+ if (ioBase != MAP_FAILED)
+ munmap((void*)ioBase,ioSize);
+
+ if (!pciBusInfo[pcibus])
+ return;
+
+ primary_bus = pciBusInfo[pcibus]->primary_bus;
+
+ if (!pciBusInfo[primary_bus])
+ return;
+
+ ioSize = min(pciBusInfo[primary_bus]->ppc_io_size, 64 * 1024);
+ if (ioSize) {
+ ioBase = (unsigned char *)pmax_iomap(pciBusInfo[primary_bus]->ppc_io_base, ioSize);
+ if (ioBase == MAP_FAILED)
+ ioSize = 0;
+ }
+}
+
+static void
+nh640xPciInit(void)
+{
+ int i,n;
+ struct nh640x_pci_info *infop;
+ pciBusFuncs_p functions;
+
+ switch (pmax_sys_type) {
+ case MODEL_NH6400:
+ n = NH6400_NUM_PCI_EXPANSION_BUSES;
+ infop = nh6400_pci_info;
+ functions = &nh6400_pci_funcs;
+ break;
+ case MODEL_NH6408:
+ n = NH6408_NUM_PCI_EXPANSION_BUSES;
+ infop = nh6408_pci_info;
+ functions = &nh6408_pci_funcs;
+ break;
+ default:
+ FatalError("Unknown Power MAXION system type\n");
+ /*NOTREACHED*/
+ }
+
+ /*
+ * Initialize entries in pciBusInfo[] table for each defined PCI bus.
+ * This table is actually sparse because undefined or inaccessible
+ * pci buses are left as NULL entries. Of course, pciFindNext() is
+ * aware of this convention, and will skip the undefined buses.
+ */
+ for (i=0; i<n; infop++,i++) {
+ int bus = infop->busnum;
+ pciBusInfo_t *busp;
+
+ if (pciBusInfo[bus])
+ busp = pciBusInfo[bus];
+ else
+ busp = xalloc(sizeof(pciBusInfo_t));
+
+ if (!busp)
+ FatalError("nh640xPciInit: xalloc failed\n");
+
+ /* Initialize pci bus info */
+ busp->configMech = PCI_CFG_MECH_OTHER;
+ busp->numDevices = infop->num_cfg_addrs;
+ busp->secondary = (infop->type == SECONDARY_PCI ? TRUE : FALSE);
+ busp->primary_bus = infop->primary_bus;
+ busp->funcs = functions;
+ busp->pciBusPriv = infop;
+
+ /* Initialize I/O base/size info */
+ if (busp->secondary) {
+ pciBusInfo_t *pri_busp = pciBusInfo[busp->primary_bus];
+ if (pri_busp) {
+ busp->ppc_io_base = pri_busp->ppc_io_base;
+ busp->ppc_io_size = pri_busp->ppc_io_size;
+ }
+ }
+ else if (infop->ioSize) {
+ busp->ppc_io_size = infop->ioSize;
+ busp->ppc_io_base = infop->ioBase;
+ }
+
+ pciBusInfo[bus] = busp;
+
+ /*
+ * Adjust pciNumBuses to reflect the highest defined entry in pciBusInfo
+ */
+ if (pciNumBuses < bus)
+ pciNumBuses = bus + 1;
+ }
+
+ pciFindFirstFP = nh640xPciFindFirst;
+ pciFindNextFP = nh640xPciFindNext;
+}
+
+static PCITAG
+nh640xPciFindNext(void)
+{
+ unsigned long devid, tmp;
+ unsigned char base_class, sub_class, sec_bus, pri_bus;
+
+ for (;;) {
+
+ if (pciBusNum == -1) {
+ /*
+ * Start at top of the order
+ */
+ pciBusNum = 0;
+ pciFuncNum = 0;
+ pciDevNum = 0;
+ }
+ else {
+#ifdef NH640X_PCI_MFDEV_SUPPORT
+ /*
+ * Somewhere in middle of order. Determine who's
+ * next up
+ */
+ if (pciFuncNum == 0) {
+ /*
+ * Is current dev a multifunction device?
+ */
+ if (pciMfDev(pciBusNum, pciDevNum))
+ /* Probe for other functions */
+ pciFuncNum = 1;
+ else
+ /* No more functions this device. Next device please */
+ pciDevNum ++;
+ }
+ else if (++pciFuncNum >= 8) {
+ /* No more functions for this device. Next device please */
+ pciFuncNum = 0;
+ pciDevNum ++;
+ }
+#else /* NH640X_PCI_MFDEV_SUPPORT */
+ pciDevNum++;
+#endif /* NH640X_PCI_MFDEV_SUPPORT */
+
+ if (!pciBusInfo[pciBusNum] || pciDevNum >= pciBusInfo[pciBusNum]->numDevices) {
+ /*
+ * No more devices for this bus. Next bus please
+ */
+ if (++pciBusNum >= pciNumBuses)
+ /* No more buses. All done for now */
+ return(PCI_NOT_FOUND);
+
+ pciDevNum = 0;
+ }
+ }
+
+ if (!pciBusInfo[pciBusNum])
+ continue; /* Undefined bus, next bus/device please */
+
+ /*
+ * At this point, pciBusNum, pciDevNum, and pciFuncNum have been
+ * advanced to the next device. Compute the tag, and read the
+ * device/vendor ID field.
+ */
+ pciDeviceTag = PCI_MAKE_TAG(pciBusNum, pciDevNum, pciFuncNum);
+ devid = pciReadLong(pciDeviceTag, 0);
+ if (devid == 0xffffffff)
+ continue; /* Nobody home. Next device please */
+
+#ifdef NH640X_PCI_BRIDGE_SUPPORT
+ /*
+ * Before checking for a specific devid, look for enabled
+ * PCI to PCI bridge devices. If one is found, create and
+ * initialize a bus info record (if one does not already exist).
+ */
+ tmp = pciReadLong(pciDeviceTag, PCI_CLASS_CODE_REG);
+ base_class = PCI_EXTRACT_BASE_CLASS(tmp);
+ sub_class = PCI_EXTRACT_SUBCLASS(tmp);
+ if (base_class == PCI_CLASS_BRIDGE && sub_class == PCI_SUBCLASS_BRIDGE_PCI) {
+ tmp = pciReadLong(pciDeviceTag, PCI_BRIDGE_BUS_REG);
+ sec_bus = PCI_SECONDARY_BUS_EXTRACT(tmp);
+ pri_bus = PCI_PRIMARY_BUS_EXTRACT(tmp);
+ if (sec_bus > 0 && sec_bus < PCI_MAX_BUSES && pcibusInfo[pri_bus]) {
+ /*
+ * Found a secondary PCI bus
+ */
+ if (!pciBusInfo[sec_bus]) {
+ pciBusInfo[sec_bus] = xalloc(sizeof(pciBusInfo_t));
+
+ if (!pciBusInfo[sec_bus])
+ FatalError("nh640xPciFindNext: alloc failed\n!!!");
+ }
+
+ /* Copy parents settings... */
+ *pciBusInfo[sec_bus] = *pcibusInfo[pri_bus];
+
+ /* ...but not everything same as parent */
+ pciBusInfo[sec_bus]->primary_bus = pri_bus;
+ pciBusInfo[sec_bus]->secondary = TRUE;
+ pciBusInfo[sec_bus]->numDevices = 32;
+
+ if (pciNumBuses < sec_num)
+ pciNumBuses = sec_num+1;
+ }
+ }
+#endif /* NH640X_PCI_BRIDGE_SUPPORT */
+
+ /*
+ * Does this device match the requested devid after
+ * applying mask?
+ */
+ if ((devid & pciDevidMask) == pciDevid) {
+ /* Yes - Return it. Otherwise, next device */
+
+ /* However, before returning it, try to map */
+ /* I/O region for this PCI bus */
+ ppcPciIoMap(PCI_BUS_FROM_TAG(pciDeviceTag));
+
+ return(pciDeviceTag); /* got a match */
+ }
+
+ } /* for */
+
+ /*NOTREACHED*/
+}
+
+static PCITAG
+nh640xPciFindFirst(void)
+{
+ pciBusNum = -1;
+ return(nh640xPciFindNext());
+}
+
+static unsigned long
+nh6400PciReadLong(PCITAG tag, int offset)
+{
+ unsigned long tmp;
+ char *base;
+ int devnum, bus, func, data_reg_offset, ndevs;
+ unsigned long cfgaddr;
+ pciBusInfo_t *busp, *pri_busp;
+ struct nh640x_pci_info *infop, *pri_infop;
+
+ bus = PCI_BUS_FROM_TAG(tag);
+ devnum = PCI_DEV_FROM_TAG(tag);
+ func = PCI_FUNC_FROM_TAG(tag);
+
+ xf86MsgVerb(3, X_INFO,
+ "nh6400PciReadLong: bus=%d, devnum=%d, func=%d, offset=0x%x\n",
+ bus, devnum, func, offset);
+
+ if (bus >= pciNumBuses || !pciBusInfo[bus]) {
+ xf86Msg(X_WARNING, "nh6400PciReadLong: bus pci%d not defined!!!\n",
+ bus);
+ return(0xffffffff);
+ }
+
+ busp = pciBusInfo[bus];
+ infop = (struct nh640x_pci_info *)busp->pciBusPriv;
+
+ if (busp->secondary) {
+ /*
+ * Secondary PCI bus behind a pci-to-pci bridge
+ */
+ pri_busp = pciBusInfo[busp->primary_bus];
+ pri_infop = (struct nh640x_pci_info *)pri_busp->pciBusPriv;
+ ndevs = 16;
+ data_reg_offset = NH6400_PCI_CFG_TYPE1_DATA_REG_OFF; /* For Type 1 cfg cycles */
+
+ if (!pri_busp) {
+ xf86Msg(X_WARNING,
+ "nh6400PciReadLong: pci%d's primary parent [pci%d] "
+ "is not defined!!!\n", bus, busp->primary_bus);
+ return(0xffffffff);
+ }
+ }
+ else {
+ pri_busp = busp;
+ pri_infop = infop;
+ ndevs = infop->num_cfg_addrs;
+ data_reg_offset = NH6400_PCI_CFG_TYPE0_DATA_REG_OFF; /* For Type 0 cfg cycles */
+ }
+
+ if (devnum >= ndevs) {
+ xf86Msg(X_WARNING,
+ "nh6400PciReadLong: devnum %d out of range for bus pci%d\n",
+ devnum, bus);
+ return(0xffffffff);
+ }
+
+ /*
+ * Make sure the cfg address and data registers for this bus are mapped
+ * Secondary buses just use the primary parents addreses
+ */
+ if (!infop->cfgAddrReg) {
+ if (!pri_infop->cfgAddrReg) {
+ pri_infop->cfgAddrReg = pmax_iomap(pri_infop->cfgPhysBase, 0x1000);
+ if (pri_infop->cfgAddrReg == MAP_FAILED) {
+ FatalError("nh6400PciReadLong: Cannot map PCI cfg regs @ 0x%08x\n",
+ pri_infop->cfgPhysBase);
+ /*NOTREACHED*/
+ }
+ }
+ infop->cfgAddrReg = pri_infop->cfgAddrReg;
+ infop->cfgPhysBase = pri_infop->cfgPhysBase;
+ }
+ base = infop->cfgAddrReg;
+
+ if (busp->secondary) {
+ /* cfgaddr = PCI_CFGMECH1_TYPE1_CFGADDR(bus,devnum,func,offset); */
+ cfgaddr = PCI_CFGMECH1_TYPE1_CFGADDR(1,devnum,func,offset); /* Must use bus=1 for now - glb */
+ }
+ else {
+ cfgaddr = infop->cfg_addrs[devnum] + offset;
+ }
+
+ xf86MsgVerb(X_INFO, 3,
+ "nh6400PciReadLong: Writing cfgaddr=0x%x to 0x%x (phys=0x%x)\n",
+ cfgaddr, base, infop->cfgPhysBase);
+
+ /* There may not be any OS interaction while interrupts are disabled */
+ xf86DisableInterrupts();
+
+ *((unsigned long *)(base)) = pciByteSwap(cfgaddr); /* Set cfg address */
+ eieio();
+
+ if (!badaddr(base + data_reg_offset, 4, 0)) {
+ tmp = *((unsigned long *)(base + data_reg_offset));
+ eieio();
+ }
+
+ xf86EnableInterrupts();
+
+ xf86MsgVerb(X_INFO, 3, "nh6400PciReadLong: Read value=0x%x from 0x%x (phys=0x%x)\n",
+ pciByteSwap(tmp), base + data_reg_offset, infop->cfgPhysBase + data_reg_offset);
+
+ return(pciByteSwap(tmp));
+}
+
+static void
+nh6400PciWriteLong(PCITAG tag, int offset, unsigned long val)
+{
+ char *base;
+ int devnum, bus, func, data_reg_offset, ndevs;
+ unsigned long cfgaddr;
+ pciBusInfo_t *busp, *pri_busp;
+ struct nh640x_pci_info *infop, *pri_infop;
+
+ bus = PCI_BUS_FROM_TAG(tag);
+ devnum = PCI_DEV_FROM_TAG(tag);
+ func = PCI_FUNC_FROM_TAG(tag);
+
+ xf86MsgVerb(X_INFO, 3,
+ "nh6400PciWriteLong: bus=%d, devnum=%d, func=%d, offset=0x%x, "
+ val=0x%x\n", bus, devnum, func, offset, val);
+
+ if (bus >= pciNumBuses || !pciBusInfo[bus]) {
+ xf86Msg(X_WARNING, "nh6400PciWriteLong: bus pci%d not defined!!!\n",
+ bus);
+ return;
+ }
+ busp = pciBusInfo[bus];
+ infop = (struct nh640x_pci_info *)busp->pciBusPriv;
+
+ if (busp->secondary) {
+ /*
+ * Secondary PCI bus behind a pci-to-pci bridge
+ */
+ pri_busp = pciBusInfo[busp->primary_bus];
+ pri_infop = (struct nh640x_pci_info *)pri_busp->pciBusPriv;
+ ndevs = 16;
+ data_reg_offset = NH6400_PCI_CFG_TYPE1_DATA_REG_OFF; /* For Type 1 cfg cycles */
+
+ if (!pri_busp) {
+ xf86Msg(X_WARNING,
+ "nh6400PciWriteLong: pci%d's primary parent [pci%d]"
+ " is not defined!!!\n", bus, busp->primary_bus);
+ return;
+ }
+ }
+ else {
+ pri_busp = busp;
+ pri_infop = infop;
+ ndevs = infop->num_cfg_addrs;
+ data_reg_offset = NH6400_PCI_CFG_TYPE0_DATA_REG_OFF; /* For Type 0 cfg cycles */
+ }
+
+ if (devnum >= ndevs) {
+ xf86Msg(X_WARNING,
+ "nh6400PciWriteLong: devnum %d out of range for bus pci%d\n",
+ devnum, bus);
+ return;
+ }
+
+ /*
+ * Make sure the cfg address and data registers for this bus are mapped
+ * Secondary buses just use the primary parents addreses
+ */
+ if (!infop->cfgAddrReg) {
+ if (!pri_infop->cfgAddrReg) {
+ pri_infop->cfgAddrReg = pmax_iomap(pri_infop->cfgPhysBase, 0x1000);
+ if (pri_infop->cfgAddrReg == MAP_FAILED) {
+ FatalError("nh6400PciWriteLong: Cannot map PCI cfg regs @ 0x%08x\n",
+ pri_infop->cfgPhysBase);
+ /*NOTREACHED*/
+ }
+ }
+ infop->cfgAddrReg = pri_infop->cfgAddrReg;
+ infop->cfgPhysBase = pri_infop->cfgPhysBase;
+ }
+ base = infop->cfgAddrReg;
+
+ if (busp->secondary) {
+ /* cfgaddr = PCI_CFGMECH1_TYPE1_CFGADDR(bus,devnum,func,offset); */
+ cfgaddr = PCI_CFGMECH1_TYPE1_CFGADDR(1,devnum,func,offset); /* Must use bus=1 for now - glb */
+ }
+ else {
+ cfgaddr = infop->cfg_addrs[devnum] + offset;
+ }
+
+ xf86MsgVerb(X_INFO, 3,
+ "nh6400PciWriteLong: Writing cfgaddr=0x%x to 0x%x (phys=0x%x)\n",
+ cfgaddr, base, infop->cfgPhysBase);
+
+ /* There may not be any OS interaction while interrupts are disabled */
+ xf86DisableInterrupts();
+
+ *((unsigned long *)(base)) = pciByteSwap(cfgaddr); /* Set cfg address */
+ eieio();
+
+ *((unsigned long *)(base + data_reg_offset)) = pciByteSwap(val);
+ eieio();
+
+ xf86EnableInterrupts();
+
+ xf86MsgVerb(X_INFO, 3,
+ "nh6400PciWriteLong: Wrote value=0x%x to 0x%x (phys=0x%x)\n",
+ val, base + data_reg_offset,
+ infop->cfgPhysBase + data_reg_offset);
+}
+
+/*
+ * These next two functions are for debugging purposes only because
+ * the nh6400 does not translate passed to/from a PCI domain. However,
+ * we do do some bounds checking to make sure things are where they
+ * should be.
+ */
+static ADDRESS
+nh6400BusToHostAddr(PCITAG tag, ADDRESS addr)
+{
+ unsigned long addr_l = (unsigned long)addr;
+ int bus = PCI_BUS_FROM_TAG(tag);
+ struct nh640x_pci_info *infop;
+ int pri_bus;
+ unsigned long membase;
+
+ if (!pciBusInfo[bus])
+ FatalError("nh6400BusToHostAddr: pci%d not defined!!\n", bus);
+
+ if (pciBusInfo[bus]->secondary) {
+ pri_bus = pciBusInfo[bus]->primary_bus;
+
+ if (!pciBusInfo[pri_bus])
+ FatalError("nh6400BusToHostAddr: Primary bus pci%d not defined!!\n", pri_bus);
+ }
+ else
+ pri_bus = bus;
+
+ infop = (struct nh640x_pci_info *)pciBusInfo[pri_bus]->pciBusPriv;
+ membase = infop->memBase;
+
+ if (addr_l < 0x80000000)
+ /*
+ * NH6400 host memory addresses are 0-0x7fffffff
+ */
+ return(addr);
+
+ else if (addr_l >= membase && addr_l < membase + 0x0e000000)
+ /*
+ * NH6400 host can access PCI memory space addresses
+ * [memBase, memBase+0x0dffffff]
+ */
+ return(addr);
+ else
+ /* Other addresses are not valid */
+ FatalError("nh6400BusToHostAddr: Bus address 0x%x not visible to NH6400 host\n",
+ addr_l);
+
+ /*NOTREACHED*/
+}
+
+static ADDRESS
+nh6400HostToBusAddr(PCITAG tag, ADDRESS addr)
+{
+ unsigned long addr_l = (unsigned long) addr;
+ int bus = PCI_BUS_FROM_TAG(tag);
+ struct nh640x_pci_info *infop;
+ int pri_bus;
+ unsigned long membase;
+
+ if (!pciBusInfo[bus])
+ FatalError("nh6400HostToBusAddr: pci%d not defined!!\n", bus);
+
+ if (pciBusInfo[bus]->secondary) {
+ pri_bus = pciBusInfo[bus]->primary_bus;
+
+ if (!pciBusInfo[pri_bus])
+ FatalError("nh6400HostToBusAddr: Primary bus pci%d not defined!!\n", pri_bus);
+ }
+ else
+ pri_bus = bus;
+
+ infop = (struct nh640x_pci_info *)pciBusInfo[pri_bus]->pciBusPriv;
+ membase = infop->memBase;
+
+ if (addr_l < 0x80000000)
+ /*
+ * NH6400 host memory addresses are 0-0x7fffffff
+ */
+ return(addr);
+
+ else if (addr_l >= membase && addr_l < membase + 0x0e000000)
+ /*
+ * NH6400 host can access PCI memory space addresses
+ * [memBase, memBase+0x0dffffff]
+ */
+ return(addr);
+ else
+ /* Other addresses are not valid */
+ FatalError("nh6400HostToBusAddr: Bus address 0x%x not visible to NH6400 host\n",
+ addr_l);
+
+ /*NOTREACHED*/
+}
+
+
+/*
+ * NH6408 platform support
+ */
+static unsigned long
+nh6408PciReadLong(PCITAG tag, int offset)
+{
+ unsigned long tmp;
+ char *base;
+ int devnum, bus, func, ndevs;
+ unsigned long cfgaddr;
+ pciBusInfo_t *busp, *pri_busp;
+ struct nh640x_pci_info *infop, *pri_infop;
+
+ bus = PCI_BUS_FROM_TAG(tag);
+ devnum = PCI_DEV_FROM_TAG(tag);
+ func = PCI_FUNC_FROM_TAG(tag);
+
+ xf86MsgVerb(X_INFO,
+ "nh6408PciReadLong: bus=%d, devnum=%d, func=%d, offset=0x%x\n",
+ bus, devnum, func, offset);
+
+ if (bus >= pciNumBuses || !pciBusInfo[bus]) {
+ xf86Msg(X_WARNING, "nh6408PciReadLong: bus pci%d not defined!!!\n",
+ bus);
+ return(0xffffffff);
+ }
+
+ busp = pciBusInfo[bus];
+ infop = (struct nh640x_pci_info *)busp->pciBusPriv;
+
+ if (busp->secondary) {
+ /*
+ * Secondary PCI bus behind a pci-to-pci bridge
+ */
+ pri_busp = pciBusInfo[busp->primary_bus];
+ pri_infop = (struct nh640x_pci_info *)pri_busp->pciBusPriv;
+ ndevs = 16;
+
+ if (!pri_busp) {
+ xf86Msg(X_WARNING,
+ "nh6408PciReadLong: pci%d's primary parent [pci%d] "
+ "is not defined!!!\n", bus, busp->primary_bus);
+ return(0xffffffff);
+ }
+ }
+ else {
+ pri_busp = busp;
+ pri_infop = infop;
+ ndevs = infop->num_cfg_addrs;
+ }
+
+ if (devnum >= ndevs) {
+ xf86Msg(X_WARNING
+ "nh6408PciReadLong: devnum %d out of range for bus pci%d\n",
+ devnum, bus);
+ return(0xffffffff);
+ }
+
+ /*
+ * Make sure the cfg address and data registers for this bus are mapped
+ * Secondary buses just use the primary parents addreses
+ */
+ if (!infop->cfgAddrReg) {
+ if (!pri_infop->cfgAddrReg) {
+ pri_infop->cfgAddrReg = pmax_iomap(pri_infop->cfgPhysBase, 0x11000);
+ if (pri_infop->cfgAddrReg == MAP_FAILED) {
+ FatalError("nh6408PciReadLong: Cannot map PCI cfg regs @ 0x%08x\n",
+ pri_infop->cfgPhysBase);
+ /*NOTREACHED*/
+ }
+ }
+ infop->cfgAddrReg = pri_infop->cfgAddrReg;
+ infop->cfgPhysBase = pri_infop->cfgPhysBase;
+ }
+ base = infop->cfgAddrReg;
+
+ if (busp->secondary) {
+ /* cfgaddr = PCI_CFGMECH1_TYPE1_CFGADDR(bus,devnum,func,offset); */
+ cfgaddr = PCI_CFGMECH1_TYPE1_CFGADDR(1,devnum,func,offset); /* Must use bus=1 for now - glb */
+ }
+ else {
+ cfgaddr = infop->cfg_addrs[devnum] + offset;
+ }
+
+ xf86MsgVerb(X_INFO, 3,
+ "nh6408PciReadLong: Writing cfgaddr=0x%x to 0x%x (phys=0x%x)\n",
+ cfgaddr, base, infop->cfgPhysBase);
+
+ /* There may not be any OS interaction while interrupts are disabled */
+ xf86DisableInterrupts();
+
+ *((unsigned long *)(base)) = pciByteSwap(cfgaddr); /* Set cfg address */
+ eieio();
+
+ if (!badaddr(base + NH6408_PCI_CFG_DATA_REG_OFF, 4, 0)) {
+ tmp = *((unsigned long *)(base + NH6408_PCI_CFG_DATA_REG_OFF));
+ eieio();
+ }
+
+ xf86EnableInterrupts();
+
+ xf86MsgVerb(X_INFO, 3, "nh6408PciReadLong: Read value=0x%x from 0x%x (phys=0x%x)\n",
+ pciByteSwap(tmp),
+ base + NH6408_PCI_CFG_DATA_REG_OFF,
+ infop->cfgPhysBase + NH6408_PCI_CFG_DATA_REG_OFF);
+
+ return(pciByteSwap(tmp));
+}
+
+static void
+nh6408PciWriteLong(PCITAG tag, int offset, unsigned long val)
+{
+ char *base;
+ int devnum, bus, func, ndevs;
+ unsigned long cfgaddr;
+ pciBusInfo_t *busp, *pri_busp;
+ struct nh640x_pci_info *infop, *pri_infop;
+
+ bus = PCI_BUS_FROM_TAG(tag);
+ devnum = PCI_DEV_FROM_TAG(tag);
+ func = PCI_FUNC_FROM_TAG(tag);
+
+ xf86MsgVerb(X_INFO,
+ "nh6408PciWriteLong: bus=%d, devnum=%d, func=%d, offset=0x%x, "
+ "val=0x%x\n", bus, devnum, func, offset, val);
+
+ if (bus >= pciNumBuses || !pciBusInfo[bus]) {
+ xf86Msg(X_WARNING, "nh6408PciWriteLong: bus pci%d not defined!!!\n",
+ bus);
+ return;
+ }
+
+ busp = pciBusInfo[bus];
+ infop = (struct nh640x_pci_info *)busp->pciBusPriv;
+
+ if (busp->secondary) {
+ /*
+ * Secondary PCI bus behind a pci-to-pci bridge
+ */
+ pri_busp = pciBusInfo[busp->primary_bus];
+ pri_infop = (struct nh640x_pci_info *)pri_busp->pciBusPriv;
+ ndevs = 16;
+
+ if (!pri_busp) {
+ xf86Msg(X_WARNING,
+ "nh6408PciWriteLong: pci%d's primary parent [pci%d] "
+ is not defined!!!\n", bus, busp->primary_bus);
+ return;
+ }
+ }
+ else {
+ pri_busp = busp;
+ pri_infop = infop;
+ ndevs = infop->num_cfg_addrs;
+ }
+
+ if (devnum >= ndevs) {
+ xf86Msg(X_WARNING,
+ "nh6408PciWriteLong: devnum %d out of range for bus pci%d\n",
+ devnum, bus);
+ return;
+ }
+
+ /*
+ * Make sure the cfg address and data registers for this bus are mapped
+ * Secondary buses just use the primary parents addreses
+ */
+ if (!infop->cfgAddrReg) {
+ if (!pri_infop->cfgAddrReg) {
+ pri_infop->cfgAddrReg = pmax_iomap(pri_infop->cfgPhysBase, 0x11000);
+ if (pri_infop->cfgAddrReg == MAP_FAILED) {
+ FatalError("nh6408PciWriteLong: Cannot map PCI cfg regs @ 0x%08x\n",
+ pri_infop->cfgPhysBase);
+ /*NOTREACHED*/
+ }
+ }
+ infop->cfgAddrReg = pri_infop->cfgAddrReg;
+ infop->cfgPhysBase = pri_infop->cfgPhysBase;
+ }
+ base = infop->cfgAddrReg;
+
+ if (busp->secondary) {
+ /* cfgaddr = PCI_CFGMECH1_TYPE1_CFGADDR(bus,devnum,0,offset); */
+ cfgaddr = PCI_CFGMECH1_TYPE1_CFGADDR(1,devnum,0,offset);
+ }
+ else {
+ cfgaddr = infop->cfg_addrs[devnum] + offset;
+ }
+
+ xf86MsgVerb(X_INFO, 3,
+ "nh6408PciWriteLong: Writing cfgaddr=0x%x to 0x%x (phys=0x%x)\n",
+ cfgaddr, base, infop->cfgPhysBase);
+
+ /* There may not be any OS interaction while interrupts are disabled */
+ xf86DisableInterrupts();
+
+ *((unsigned long *)(base)) = pciByteSwap(cfgaddr); /* Set cfg address */
+ eieio();
+
+ *((unsigned long *)(base + NH6408_PCI_CFG_DATA_REG_OFF)) = pciByteSwap(val);
+ eieio();
+
+ xf86EnableInterrupts();
+
+ xf86MsgVerb(X_INFO, 3,
+ "nh6408PciWriteLong: Wrote value=0x%x to 0x%x (phys=0x%x)\n",
+ val, base + NH6408_PCI_CFG_DATA_REG_OFF,
+ infop->cfgPhysBase + NH6408_PCI_CFG_DATA_REG_OFF);
+}
+
+
+static ADDRESS
+nh6408BusToHostAddr(PCITAG tag, ADDRESS addr)
+{
+ unsigned long addr_l = (unsigned long)addr;
+ int bus = PCI_BUS_FROM_TAG(tag);
+ int pri_bus;
+ struct nh640x_pci_info *infop;
+ unsigned long membase;
+
+ if (!pciBusInfo[bus])
+ FatalError("nh6408BusToHostAddr: pci%d not defined!!\n", bus);
+
+ if (pciBusInfo[bus]->secondary) {
+ pri_bus = pciBusInfo[bus]->primary_bus;
+
+ if (!pciBusInfo[pri_bus])
+ FatalError("nh6408BusToHostAddr: Primary bus pci%d not defined!!\n", pri_bus);
+ }
+ else
+ pri_bus = bus;
+
+ infop = (struct nh640x_pci_info *)pciBusInfo[pri_bus]->pciBusPriv;
+ membase = infop->memBase;
+
+ if (addr_l < 0x10000000)
+ /*
+ * NH6408 host sees PCI memory space addresses 0-0x0fffffff
+ * at the primary PCI buses "memBase" [memBase, memBase+0x0fffffff]
+ */
+ return((ADDRESS)(membase + addr_l));
+
+ else if (addr_l >= 0x80000000)
+ /*
+ * NH6408 host memory addresses 0-0x7fffffff are seen at
+ * 0x80000000-0xffffffff on PCI
+ */
+ return((ADDRESS)(addr_l & 0x7fffffff));
+
+ else
+ /* Other addresses are not valid */
+ FatalError("nh6408BusToHostAddr: Bus address 0x%x not visible to NH6408 host\n",
+ addr_l);
+
+ /*NOTREACHED*/
+}
+
+static ADDRESS
+nh6408HostToBusAddr(PCITAG tag, ADDRESS addr)
+{
+ unsigned long addr_l = (unsigned long)addr;
+ int bus = PCI_BUS_FROM_TAG(tag);
+ int pri_bus;
+ struct nh640x_pci_info *infop;
+ unsigned long membase;
+
+ if (!pciBusInfo[bus])
+ FatalError("nh6408HostToBusAddr: pci%d not defined!!\n", bus);
+
+ if (pciBusInfo[bus]->secondary) {
+ pri_bus = pciBusInfo[bus]->primary_bus;
+
+ if (!pciBusInfo[pri_bus])
+ FatalError("nh6408HostToBusAddr: Primary bus pci%d not defined!!\n", pri_bus);
+ }
+ else
+ pri_bus = bus;
+
+ infop = (struct nh640x_pci_info *)pciBusInfo[pri_bus]->pciBusPriv;
+ membase = infop->memBase;
+
+ if (addr_l < 0x80000000)
+ /*
+ * NH6408 host memory addresses 0-0x7fffffff are seen at
+ * 0x80000000-0xffffffff on PCI
+ */
+ return((ADDRESS)(addr_l | 0x80000000));
+
+ else if (addr_l >= membase && addr_l < (membase + 0x10000000))
+ /*
+ * NH6408 host sees PCI memory space addresses 0-0x0fffffff
+ * at the primary PCI buses "memBase" [memBase, memBase+0x0fffffff]
+ */
+ return((ADDRESS)(addr_l - membase));
+
+ else
+ /* Other addresses are not valid */
+ FatalError("nh6408HostToBusAddr: Host address 0x%x not visible to pci%d\n",
+ addr_l, bus);
+
+ /*NOTREACHED*/
+}
+
+/*
+ * NH6800 (Turbo) support
+ */
+static void
+nh6800tPciInit(void)
+{
+ FatalError("nh6800tPciInit: NH6800TURBO not supported (yet)!!!\n");
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_ppc.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_ppc.c
new file mode 100644
index 000000000..aa286d4ac
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_ppc.c
@@ -0,0 +1,251 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_ppc.c,v 1.3 1998/07/25 16:56:56 dawes Exp $ */
+/*
+ * Copyright 1998 by Concurrent Computer Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Concurrent Computer
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Concurrent Computer Corporation makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Copyright 1998 by Metro Link Incorporated
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Metro Link
+ * Incorporated not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Metro Link Incorporated makes no representations
+ * about the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/types.h>
+#include <errno.h>
+
+#include <sys/prosrfs.h>
+#include <sys/cpu.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+volatile unsigned char *ioBase = MAP_FAILED; /* Also referenced by compiler.h */
+unsigned long ioSize = 0;
+
+#undef outb
+#undef outw
+#undef outl
+#undef inb
+#undef inw
+#undef inl
+
+void
+outb(unsigned int a, unsigned char b)
+{
+ if (ioBase == MAP_FAILED) {
+ ErrorF("outb(0x%04X, 0x%02X) fails. Uninitialized ioBase\n", a, b);
+ return;
+ }
+
+ *((volatile unsigned char *)(ioBase + a)) = b; eieio();
+}
+
+void
+outw(unsigned int a, unsigned short w)
+{
+ if (ioBase == MAP_FAILED) {
+ ErrorF("outw(0x%04X, 0x%04X) fails. Unitialized ioBase\n", a, w);
+ return;
+ }
+
+ stw_brx(w,ioBase,a); eieio();
+}
+
+void
+outl(unsigned int a, unsigned int l)
+{
+ if (ioBase == MAP_FAILED) {
+ ErrorF("outl(0x%04X, 0x%08X) fails. Unitialized ioBase\n", a, l);
+ return;
+ }
+
+ stl_brx(l,ioBase,a); eieio();
+}
+
+unsigned char
+inb(unsigned int a)
+{
+ unsigned char b;
+
+ if (ioBase == MAP_FAILED) {
+ FatalError("%s(0x%04X) fails. Unitialized ioBase\n", "inb", a);
+ /*NOTREACHED*/
+ }
+
+ b = *((volatile unsigned char *)(ioBase + a));
+
+ return(b);
+}
+
+unsigned short
+inw(unsigned int a)
+{
+ unsigned short w;
+
+ if (ioBase == MAP_FAILED) {
+ FatalError("%s(0x%04X) fails. Unitialized ioBase\n", "inw", a);
+ /*NOTREACHED*/
+ }
+
+ w = ldw_brx(ioBase,a);
+ return(w);
+}
+
+unsigned int
+inl(unsigned int a)
+{
+ unsigned int l;
+
+ if (ioBase == MAP_FAILED) {
+ FatalError("%s(0x%04X) fails. Unitialized ioBase\n", "inl", a);
+ /*NOTREACHED*/
+ }
+
+ l = ldl_brx(ioBase, a);
+ return(l);
+}
+
+#ifdef PPCIO_DEBUG
+
+void
+debug_outb(unsigned int a, unsigned char b, int line, char *file)
+{
+ if (xf86Verbose > 3)
+ ErrorF("outb(0x%04X, 0x%02X) at line %d, file \"%s\"\n", a, b, line, file);
+
+ outb(a,b);
+}
+
+void
+debug_outw(unsigned int a, unsigned short w, int line, char *file)
+{
+ if (xf86Verbose > 3)
+ ErrorF("outw(0x%04X, 0x%04X) at line %d, file \"%s\"\n", a, w, line, file);
+
+ outw(a,w);
+}
+
+void
+debug_outl(unsigned int a, unsigned int l, int line, char *file)
+{
+ if (xf86Verbose > 3)
+ ErrorF("outl(0x%04X, 0x%08X) at line %d, file \"%s\"\n", a, l, line, file);
+
+ outl(a,l);
+}
+
+
+unsigned char
+debug_inb(unsigned int a, int line, char *file)
+{
+ unsigned char b;
+
+ if (xf86Verbose > 4)
+ ErrorF("Calling %s(0x%04x) at line %d, file \"%s\" ...\n", "inb", a, line, file);
+
+ b = inb(a);
+
+ if (xf86Verbose > 3)
+ ErrorF("... %s(0x%04X) returns 0x%02X\n", "inb", a, b);
+
+ return(b);
+}
+
+unsigned short
+debug_inw(unsigned int a, int line, char *file)
+{
+ unsigned short w;
+
+ if (xf86Verbose > 4)
+ ErrorF("Calling %s(0x%04x) at line %d, file \"%s\" ...\n", "inw", a, line, file);
+
+ w = inw(a);
+
+ if (xf86Verbose > 3)
+ ErrorF("... %s(0x%04X) returns 0x%04X\n", "inw", a, w);
+
+ return(w);
+}
+
+unsigned int
+debug_inl(unsigned int a, int line, char *file)
+{
+ unsigned int l;
+
+ if (xf86Verbose > 4)
+ ErrorF("Calling %s(0x%04x) at line %d, file \"%s\" ...\n", "inl", a, line, file);
+
+ l = inl(a);
+
+ if (xf86Verbose > 3)
+ ErrorF("... %s(0x%04X) returns 0x%08X\n", "inl", a, l);
+
+ return(l);
+}
+
+#endif /* PPCIO_DEBUG */
+
+/*
+ * This is neccessary on the PPC 604 (and 604e) because they have
+ * separate I and D caches and the caches must be manually synchronized
+ * when applying relocation to the instruction portion of loaded modules.
+ */
+#define LINESIZE 32
+#define CACHE_LINE(a) (((unsigned long)a) & ~(LINESIZE-1))
+
+void
+ppc_flush_icache(char *addr)
+{
+ /* Flush D-cache to memory */
+ __inst_dcbf (addr, 0);
+ __inst_dcbf (addr, LINESIZE);
+ __inst_sync ();
+
+ /* Invalidate I-cache */
+ __inst_icbi (addr, 0);
+ __inst_icbi (addr, LINESIZE);
+ __inst_sync ();
+ __inst_isync ();
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile
new file mode 100644
index 000000000..0c8e07b37
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile
@@ -0,0 +1,37 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile,v 1.7 2002/10/11 01:47:00 dawes Exp $
+
+#include <Server.tmpl>
+
+
+SRCS = qnx_io.c qnx_init.c qnx_utils.c ioperm_noop.c qnx_video.c \
+ qnx_VTsw.c qnx_kbd.c posix_tty.c qnx_mouse.c qnx_select.c \
+ libc_wrapper.c stdResource.c stdPci.c sigiostubs.c pm_noop.c \
+ kmod_noop.c agp_noop.c
+
+OBJS = qnx_io.o qnx_init.o qnx_utils.o ioperm_noop.o qnx_video.o \
+ qnx_VTsw.o qnx_kbd.o posix_tty.o qnx_mouse.o qnx_select.o \
+ libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o \
+ kmod_noop.o agp_noop.o
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC)
+
+RESDEFINES = -DUSESTDRES
+
+DEFINES = $(RESDEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+
+LinkSourceFile(libc_wrapper.c,../shared)
+LinkSourceFile(posix_tty.c,../shared)
+LinkSourceFile(ioperm_noop.c,../shared)
+LinkSourceFile(stdResource.c,../shared)
+LinkSourceFile(stdPci.c,../shared)
+LinkSourceFile(sigiostubs.c,../shared)
+LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
+LinkSourceFile(agp_noop.c,../shared)
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_VTsw.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_VTsw.c
new file mode 100644
index 000000000..7902b5597
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_VTsw.c
@@ -0,0 +1,116 @@
+/*
+ * (c) Copyright 1998 by Sebastien Marineau
+ * <sebastien@qnx.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Sebastien Marineau shall not
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Sebastien Marineau.
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/qnx/qnx_VTsw.c,v 1.1.2.2 1999/07/23 13:42:32 hohndel Exp $
+ */
+
+/* This module contains the code to use _select_receive to handle
+ * messages from the Mouse and Input driver. These cannot be select'ed on.
+ */
+
+/* This module contains the functions which are used to do
+ * VT switching to a text console and back... Experimental.
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include <sys/console.h>
+
+int QNX_console_exist[10];
+Bool QNX_vtswitch_pending = FALSE;
+int QNX_con_toactivate = -1;
+extern struct _console_ctrl *QNX_con_ctrl;
+extern unsigned QNX_con_mask, QNX_con_bits;
+extern pid_t QNX_console_proxy;
+extern int QNX_our_console;
+
+/* This gets called to determine if a VT switch has been requested */
+Bool xf86VTSwitchPending()
+{
+ return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+}
+
+/* This is called to do OS-specific stuff when we switch away from
+ * our console.
+ */
+Bool xf86VTSwitchAway()
+{
+ int ret;
+ unsigned event, bits;
+
+ ErrorF("Called VT switch away!\n");
+
+ /* First check wether we are trying to switch to our console... */
+ if (xf86Info.vtRequestsPending == QNX_our_console) {
+ xf86Info.vtRequestsPending = FALSE;
+ return (FALSE);
+ }
+
+ /* Reenable console switching */
+ QNX_con_bits &= ~QNX_con_mask;
+ bits = console_ctrl(QNX_con_ctrl, -1, QNX_con_bits, QNX_con_mask);
+ QNX_con_mask = 0;
+
+ /* And activate the new console. Check if it is valid first... */
+ ret = console_active(QNX_con_ctrl, xf86Info.vtRequestsPending);
+ ErrorF("xf86VTSwitchAway: Made console %d active, ret %d\n",
+ xf86Info.vtRequestsPending, ret);
+ xf86Info.vtRequestsPending = FALSE;
+
+ if (ret == -1) {
+ QNX_con_mask = CONSOLE_INVISIBLE | CONSOLE_NOSWITCH;
+ QNX_con_bits = console_ctrl (QNX_con_ctrl,
+ QNX_our_console, QNX_con_mask, QNX_con_mask);
+ return (FALSE);
+ }
+ /* Arm the console with the proxy so we know when we come back */
+ console_state(QNX_con_ctrl, QNX_our_console, 0L, _CON_EVENT_ACTIVE);
+ event = _CON_EVENT_ACTIVE;
+ console_arm (QNX_con_ctrl, QNX_our_console, QNX_console_proxy, event);
+
+ return(TRUE);
+}
+
+/* And this is called when we are switching back to the server */
+Bool xf86VTSwitchTo()
+{
+ unsigned bits, mask;
+
+ ErrorF("Called VT switch to the server!\n");
+ QNX_con_mask = CONSOLE_INVISIBLE | CONSOLE_NOSWITCH;
+ QNX_con_bits = console_ctrl (QNX_con_ctrl, QNX_our_console, QNX_con_mask, QNX_con_mask);
+ xf86Info.vtRequestsPending = FALSE;
+ return(TRUE);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_init.c
new file mode 100644
index 000000000..b96cc4d30
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_init.c
@@ -0,0 +1,175 @@
+/*
+ * (c) Copyright 1998 by Sebastien Marineau
+ * <sebastien@qnx.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * SEBASTIEN MARINEAU BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Sebastien Marineau shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Sebastien Marineau.
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/qnx/qnx_init.c,v 1.1.2.2 1999/07/23 13:42:33 hohndel Exp $
+ */
+
+/* This module contains the qnx-specific functions used at server init.
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <i86.h>
+#include <sys/mman.h>
+#include <sys/console.h>
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+struct _console_ctrl *QNX_con_ctrl = NULL;
+unsigned long QNX_con_mask = 0;
+unsigned long QNX_con_bits = 0;
+pid_t QNX_console_proxy = -1;
+int QNX_our_console = -1;
+
+void
+xf86UseMsg()
+{
+ ErrorF("No QNX-specific usage options available at this time\n");
+ return;
+}
+
+int
+xf86ProcessArgument(argc, argv, i)
+int argc;
+char **argv;
+int i;
+{
+
+ return 0;
+
+}
+
+
+void
+xf86OpenConsole()
+{
+struct _console_info info;
+unsigned event;
+int default_console = FALSE;
+char con_name[32];
+int active;
+
+ ErrorF("xf86OpenConsole\n");
+
+ if(QNX_con_ctrl == NULL) {
+ /* First open a channel to default stdout */
+ xf86Info.consoleFd = fileno(stdout);
+ if((QNX_con_ctrl = console_open (fileno(stdout), O_RDWR)) == NULL){
+ /* Hmmm. Didn't work. Try to open con1 as default */
+
+ if (( xf86Info.consoleFd = open("/dev/con1", O_RDWR)) < 0){
+ FatalError("xf86OpenConsole: could not open console driver\n");
+ return;
+ }
+ if((QNX_con_ctrl =
+ console_open (xf86Info.consoleFd, O_RDWR)) == NULL){
+ FatalError("xf86OpenConsole: could not open console\n");
+ }
+ default_console = TRUE;
+ }
+ if(QNX_con_ctrl && console_info(QNX_con_ctrl, 0, &info) == 0 ) {
+ if( info.type != _CON_TYPE_STANDARD ) {
+ FatalError("xf86OpenConsole: console is not a standard text console\n");
+ return;
+ }
+ }
+ else {
+ FatalError("xf86OpenConsole: Error querying console\n");
+ return;
+ }
+ }
+
+ /* We have a console, and it is text. Keep going */
+ /* Next, check if Photon has got the screen */
+ if(qnx_name_locate(0, "/qnx/crt", 0, NULL) != -1) {
+ FatalError("xf86OpenConsole: Photon has already grabbed the display\n");
+ return;
+ }
+ fclose (stdout);
+ /* We have two cases here: either this is the first time through,
+ * and QNX_our_console is not set yet, or we're coming here from
+ * a reset. In that case, make sure our console is now active
+ * before we go further...
+ */
+ if (QNX_our_console < 0) {
+ QNX_our_console = console_active(QNX_con_ctrl, -1);
+ }
+ else {
+ console_arm(QNX_con_ctrl, QNX_our_console, -1, _CON_EVENT_ACTIVE);
+ while ((active = console_active(QNX_con_ctrl, -1)) !=
+ QNX_our_console) {
+ sleep(2);
+ ErrorF("Waiting for our console to become active!\n");
+ }
+ }
+ QNX_con_mask = CONSOLE_INVISIBLE | CONSOLE_NOSWITCH;
+ QNX_con_bits = console_ctrl (QNX_con_ctrl, QNX_our_console,
+ QNX_con_mask, QNX_con_mask);
+ ErrorF("xf86OpenConsole: Locked console %d\n", QNX_our_console);
+
+ /* If we had the wrong console opened in the first place, reopen */
+ if(default_console) {
+ close(xf86Info.consoleFd);
+ sprintf(con_name, "/dev/con%d", QNX_our_console);
+ xf86Info.consoleFd = open(con_name, O_RDWR);
+ ErrorF("xf86OpenConsole: reopened console %d\n", QNX_our_console);
+ }
+
+ /* Next create the proxy used to notify us of console events */
+ if(QNX_console_proxy == -1){
+ if((QNX_console_proxy = qnx_proxy_attach(0, 0, 0, -1)) == -1){
+ ErrorF("xf86OpenConsole: Could not create proxy for VT switching\n");
+ }
+ }
+
+ return;
+}
+
+void
+xf86CloseConsole()
+{
+ unsigned bits;
+ int font;
+
+ ErrorF("xf86CloseConsole\n");
+ if(QNX_con_ctrl == NULL) return;
+ QNX_con_bits &= ~QNX_con_mask; /* To make sure */
+ bits = console_ctrl(QNX_con_ctrl, 0, QNX_con_bits, QNX_con_mask);
+
+ ErrorF("xf86CloseConsole: unlocked console\n");
+ /* For now, dump malloc info as well */
+#if 0
+ malloc_dump(2);
+#endif
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_io.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_io.c
new file mode 100644
index 000000000..d1cf5c4bf
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_io.c
@@ -0,0 +1,110 @@
+/*
+ * (c) Copyright 1998 by Sebastien Marineau
+ * <sebastien@qnx.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * SEBASTIEN MARINEAU BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Sebastien Marineau shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Sebastien Marineau.
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_io.c,v 1.2 2002/10/11 01:40:36 dawes Exp $
+ */
+
+/* This module contains the qnx-specific functions to access the keyboard
+ * and the console.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <i86.h>
+#include <sys/mman.h>
+#include <sys/qioctl.h>
+#include <errno.h>
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+
+void
+xf86SoundKbdBell(loudness, pitch, duration)
+int loudness, pitch, duration;
+{
+
+/* Come back and fix! */
+ErrorF("xf86SoundKbdBell: to implement\n");
+}
+
+void
+xf86SetKbdLeds(leds)
+int leds;
+{
+unsigned long bits[2], oldbits;
+
+ bits[0] = leds;
+ bits[1] = LED_CAP | LED_NUM | LED_SCR;
+
+ if (qnx_ioctl (xf86Info.consoleFd, QCTL_DEV_CTL, &bits, 8, &oldbits, 4) == -1)
+ ErrorF("xf86SetKbdLeds: error setting kbd leds, errno %d\n", errno);
+
+}
+
+int
+xf86GetKbdLeds()
+{
+unsigned long bits[2], oldbits = 0;
+
+ bits[0] = bits[1] = 0;
+ if (qnx_ioctl(xf86Info.consoleFd, QCTL_DEV_CTL, &bits, 8, &oldbits, 4) == -1)
+ ErrorF("xf86SetKbdLeds: error getting kbd leds, errno %d\n", errno);
+
+ return(oldbits);
+}
+
+/* This is a no-op for now */
+void
+xf86SetKbdRepeat(rad)
+char rad;
+{
+ return;
+}
+
+
+/* This is a no-op for now */
+void
+xf86KbdInit()
+{
+
+ return;
+}
+
+#include "xf86OSKbd.h"
+
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+ return FALSE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_kbd.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_kbd.c
new file mode 100644
index 000000000..88a7209cd
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_kbd.c
@@ -0,0 +1,104 @@
+/*
+ * (c) Copyright 1998 by Sebastien Marineau
+ * <sebastien@qnx.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * SEBASTIEN MARINEAU BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Sebastien Marineau shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Sebastien Marineau.
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/qnx/qnx_kbd.c,v 1.1.2.2 1999/07/23 13:42:35 hohndel Exp $
+ */
+
+/* This module contains the qnx-specific functions to access the keyboard
+ * and the console.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <i86.h>
+#include <sys/mman.h>
+#include <sys/dev.h>
+#include <errno.h>
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+
+int QNX_kbd_fd = -1;
+pid_t QNX_kbd_proxy = -1;
+
+int
+xf86KbdOn()
+{
+
+ if(QNX_kbd_fd == -1)
+ QNX_kbd_fd = open("/dev/kbd", O_RDWR);
+ if(QNX_kbd_proxy == -1)
+ QNX_kbd_proxy = qnx_proxy_attach(0, 0, 0, -1);
+ if (QNX_kbd_fd == -1) {
+ FatalError("xf86KbdOn: Could not open keyboard, errno = %d\n", errno);
+ }
+ if (QNX_kbd_proxy == -1) {
+ FatalError("xf86KbdOn: Could not create kbd proxy, errno = %d\n", errno);
+ }
+ if(xf86Verbose)
+ ErrorF("xf86KbdOn: fd = %d, proxy = %d\n", QNX_kbd_fd, QNX_kbd_proxy);
+ if (dev_arm(QNX_kbd_fd, QNX_kbd_proxy, _DEV_EVENT_RXRDY) == -1)
+ FatalError("xf86KbdOn: could not arm kbd proxy, errno %d\n", errno);
+ return(-1); /* We don't want to select on kbd handle... */
+
+
+}
+
+int
+xf86KbdOff()
+{
+ int fd;
+
+ ErrorF("xf86KbdOff:\n ");
+ fd = QNX_kbd_fd;
+ close(QNX_kbd_fd);
+ QNX_kbd_fd = -1;
+ return(-1);
+}
+
+void xf86KbdEvents()
+{
+ unsigned char rBuf[64];
+ int nBytes, i;
+
+ if ((nBytes = dev_read( QNX_kbd_fd, (char *)rBuf, sizeof(rBuf),
+ 0, 0, 0, 0, NULL)) > 0) {
+ for (i = 0; i < nBytes; i++)
+ xf86PostKbdEvent(rBuf[i]);
+ /* Re-arm proxy */
+ dev_arm(QNX_kbd_fd, QNX_kbd_proxy, _DEV_EVENT_RXRDY);
+
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_mouse.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_mouse.c
new file mode 100644
index 000000000..ec45a30be
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_mouse.c
@@ -0,0 +1,267 @@
+/*
+ * (c) Copyright 1998 by Sebastien Marineau
+ * <sebastien@qnx.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * SEBASTIEN MARINEAU BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Sebastien Marineau shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Sebastien Marineau.
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_mouse.c,v 1.4 2002/01/07 20:38:29 dawes Exp $
+ */
+
+/* This module contains the qnx-specific functions to access the keyboard
+ * and the console.
+ */
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <i86.h>
+#include <sys/mman.h>
+#include <sys/dev.h>
+#include <sys/mouse.h>
+#include <sys/proxy.h>
+#include <errno.h>
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+
+extern int miPointerGetMotionEvents(
+ DeviceIntPtr /*pPtr*/,
+ xTimecoord * /*coords*/,
+ unsigned long /*start*/,
+ unsigned long /*stop*/,
+ ScreenPtr /*pScreen*/
+);
+
+struct _mouse_ctrl *QNX_mouse = NULL;
+pid_t QNX_mouse_proxy = -1;
+Bool QNX_mouse_event = FALSE;
+
+/* the following function is converted from old void xf86OsMouseEvents() */
+static void
+OsMouseReadInput(InputInfoPtr pInfo)
+{
+ struct mouse_event events[16];
+ int i, nEvents;
+ int buttons, col, row;
+ int armed = 0;
+ MouseDevPtr pMse;
+
+ pMse = pInfo->private;
+
+ while ((nEvents = mouse_read(QNX_mouse, &events,
+ 16, QNX_mouse_proxy, &armed) ) > 0) {
+ /* ErrorF("Got mouse event, #%d!\n", nEvents);*/
+
+ for (i = 0; i < nEvents; i ++){
+ col = events[i].dx;
+ row = -events[i].dy;
+ buttons = events[i].buttons;
+ pMse->PostEvent(pInfo, buttons, col, row, 0, 0);
+ }
+ }
+ if (!armed) ErrorF("Drained mouse queue, armed = 0??\n");
+ QNX_mouse_event = FALSE;
+}
+
+/* The main mouse setup proc */
+static int
+OsMouseProc(pPointer, what)
+DeviceIntPtr pPointer;
+int what;
+{
+ int i, ret, armed;
+ int nbuttons;
+ unsigned char *map;
+ struct mouse_event mevent;
+ MouseDevPtr pMse;
+ InputInfoPtr pInfo;
+
+ pInfo = pPointer->public.devicePrivate;
+ pMse = pInfo->private;
+ pMse->device = pPointer;
+
+ switch (what) {
+ case DEVICE_INIT:
+ pPointer->public.on = FALSE;
+ if (QNX_mouse_proxy == -1) {
+ if((QNX_mouse_proxy =
+ qnx_proxy_attach(0, 0, 0, -1)) == -1){
+ FatalError("xf86MouseOn: Could not create mouse proxy; %s\n",
+ strerror(errno));
+ }
+ }
+ if (QNX_mouse == NULL) QNX_mouse =
+ mouse_open(0, NULL, xf86Info.consoleFd);
+ if (QNX_mouse == NULL) {
+ if (xf86AllowMouseOpenFail) {
+ ErrorF("Cannot open mouse (%s) - Continuing...\n",
+ strerror(errno));
+ return(-1);
+ }
+ FatalError("Cannot open mouse (%s)\n", strerror(errno));
+ }
+ /* Ok, so we have opened the channel to the mouse driver */
+ ErrorF("Opened mouse: handle %d buttons\n", QNX_mouse->handle,
+ QNX_mouse->buttons);
+ pInfo->fd = QNX_mouse->fd;
+ mouse_flush(QNX_mouse);
+ QNX_mouse_event = FALSE;
+ /* How de we determine how many buttons we have?? */
+ nbuttons = 3;
+ map = (unsigned char *) xalloc(nbuttons + 1);
+ if (map == (unsigned char *) NULL)
+ FatalError("Failed to allocate memory for mouse structures\n");
+ for(i=0;i <= nbuttons; i++)
+ map[i] = i;
+ InitPointerDeviceStruct ((DevicePtr) pPointer, map, nbuttons,
+ miPointerGetMotionEvents, pMse->Ctrl,
+ miPointerGetMotionBufferSize());
+
+ /* X valuator */
+ xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 0);
+ /* Y valuator */
+ xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 1);
+ xf86MotionHistoryAllocate(pInfo);
+
+ xfree(map);
+ break;
+
+ case DEVICE_ON:
+ if(QNX_mouse == NULL) return(-1);
+ pMse->lastButtons = 0;
+ pMse->lastMappedButtons = 0;
+ pMse->emulateState = 0;
+ pPointer->public.on = TRUE;
+ mouse_flush(QNX_mouse);
+ /* AddEnabledDevice(pInfo->fd); */
+ ret = mouse_read(QNX_mouse, &mevent, 0,
+ QNX_mouse_proxy, NULL);
+ ErrorF("MouseOn: armed proxy, %d, proxy pid %d\n", ret,
+ QNX_mouse_proxy);
+ if (ret < 0) {
+ FatalError("xf86MouseOn: could not arm proxy; %s\n",
+ strerror(errno));
+ }
+ break;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ if(QNX_mouse == NULL) return(-1);
+ pPointer->public.on = FALSE;
+ if (what == DEVICE_CLOSE){
+ mouse_close (QNX_mouse);
+ QNX_mouse = NULL;
+ }
+ pPointer->public.on = FALSE;
+ break;
+ }
+ return (Success);
+}
+
+static int
+SupportedInterfaces(void)
+{
+ /* XXX Need to check this. */
+ return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_MISC | MSE_AUTO;
+}
+
+static const char *internalNames[] = {
+ "OSMouse",
+ NULL
+};
+
+static const char **
+BuiltinNames(void)
+{
+ return internalNames;
+}
+
+static Bool
+CheckProtocol(const char *protocol)
+{
+ int i;
+
+ for (i = 0; internalNames[i]; i++)
+ if (xf86NameCmp(protocol, internalNames[i]) == 0)
+ return TRUE;
+ return FALSE;
+}
+
+/* XXX Is this appropriate? If not, this function should be removed. */
+static const char *
+DefaultProtocol(void)
+{
+ return "OSMouse";
+}
+
+static Bool
+OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ MouseDevPtr pMse;
+
+ /* This is called when the protocol is "OSMouse". */
+
+ pMse = pInfo->private;
+ pMse->protocol = protocol;
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
+
+ /* Collect the options, and process the common options. */
+ xf86CollectInputOptions(pInfo, NULL, NULL);
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
+
+ /* Process common mouse options (like Emulate3Buttons, etc). */
+ pMse->CommonOptions(pInfo);
+
+ /* Setup the local procs. */
+ pInfo->device_control = OsMouseProc;
+ pInfo->read_input = OsMouseReadInput;
+
+ pInfo->flags |= XI86_CONFIGURED;
+ return TRUE;
+}
+
+OSMouseInfoPtr
+xf86OSMouseInit(int flags)
+{
+ OSMouseInfoPtr p;
+
+ p = xcalloc(sizeof(OSMouseInfoRec), 1);
+ if (!p)
+ return NULL;
+ p->SupportedInterfaces = SupportedInterfaces;
+ p->BuiltinNames = BuiltinNames;
+ p->DefaultProtocol = DefaultProtocol;
+ p->CheckProtocol = CheckProtocol;
+ p->PreInit = OsMousePreInit;
+ return p;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_select.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_select.c
new file mode 100644
index 000000000..82359fe40
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_select.c
@@ -0,0 +1,75 @@
+/*
+ * (c) Copyright 1998 by Sebastien Marineau
+ * <sebastien@qnx.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Sebastien Marineau shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Sebastien Marineau.
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/qnx/qnx_select.c,v 1.1.2.2 1999/07/23 13:42:37 hohndel Exp $
+ */
+
+/* This module contains the code to use _select_receive to handle
+ * messages from the Mouse and Input driver. These cannot be select'ed on.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#define FD_SETSIZE 256
+#include <sys/select.h>
+#include <sys/kernel.h>
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+extern pid_t QNX_mouse_proxy;
+extern Bool QNX_mouse_event;
+extern pid_t QNX_console_proxy;
+
+pid_t _select_receive ( pid_t proxy)
+{
+
+ pid_t pid;
+ char msg[16];
+
+ pid = Receive(0, msg, sizeof(msg));
+/* ErrorF("Received message from pid %d %d. Mouse pid %d\n", pid, proxy,
+ QNX_mouse_proxy);
+*/
+ if (pid == QNX_mouse_proxy) return (-1);
+ if (pid == QNX_console_proxy) {
+ ErrorF("VT swicth requested by proxy to select()\n");
+ xf86Info.vtRequestsPending = TRUE;
+ return(-1);
+ }
+
+ /* For now; check exact semantics */
+ return (proxy);
+}
+
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_utils.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_utils.c
new file mode 100644
index 000000000..f78c0453e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_utils.c
@@ -0,0 +1,30 @@
+/* This includes various utility functions which are missing otherwise
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/qnx/qnx_utils.c,v 1.1.2.2 1999/07/23 13:42:39 hohndel Exp $
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <limits.h>
+#include <string.h>
+#include <i86.h>
+#include <conio.h>
+#include <time.h>
+
+#include <X11/X.h>
+#include <xf86.h>
+
+void usleep (unsigned long interval) { delay( interval/1000 ); }
+
+/* We have our own version of GetTimeInMillis, because the normal
+ * version calls gettimeofday(), which seems to thrash ES...
+ */
+CARD32
+GetTimeInMillis()
+{
+struct timespec tp;
+
+ qnx_getclock(0, CLOCK_REALTIME, &tp);
+ return((tp.tv_sec * 1000) + (tp.tv_nsec / 1000000));
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_video.c
new file mode 100644
index 000000000..578d33ea0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_video.c
@@ -0,0 +1,183 @@
+/*
+ * (c) Copyright 1998 by Sebastien Marineau
+ * <sebastien@qnx.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * SEBASTIEN MARINEAU BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Sebastien Marineau shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Sebastien Marineau.
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_video.c,v 1.3tsi Exp $
+ */
+
+/* This module contains the qnx-specific functions to deal with video
+ * framebuffer access and interrupts.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <i86.h>
+#include <sys/mman.h>
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+
+/* These are the interrupt enabling/disabling functions. Simply call
+ * the Watcom equivalents.
+ */
+
+void xf86EnableInterrupts()
+{
+ _enable();
+}
+
+void xf86DisableInterrupts()
+{
+ xf86ErrorF("Disable interrupts: not yet...\n");
+ /* _disable(); */
+}
+
+/* These are the routines to map/unmap video memory... */
+
+Bool xf86LinearVidMem()
+{
+ /* Yes we can... */
+ xf86ErrorF("xf86LinearMem: called\n");
+ return(TRUE);
+}
+
+/* This is our shmem "Physical" handle */
+int QNX_PhMem_fd = -1;
+
+
+/* Map a chunk of physical video memory, using mmap */
+
+pointer xf86MapVidMem(ScreenNum, Flags, Base, Size)
+int ScreenNum;
+int Flags;
+unsigned long Base;
+unsigned long Size;
+{
+int fd;
+void *base;
+ xf86ErrorF("xf86MapVidMem called\n");
+ if(QNX_PhMem_fd < 0) {
+ if ((fd = shm_open("Physical", O_RDWR, 0777)) < 0) {
+ FatalError("xf86MapVidMem: Failed to open /dev/shmem\n");
+ }
+ QNX_PhMem_fd = fd;
+ }
+ base = mmap((caddr_t)0, Size,
+ (Flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_SHARED, QNX_PhMem_fd, (off_t)Base);
+ xf86ErrorF("MapVidMem: addr %08x size %08x addr %08x\n", Base,
+ Size, base);
+ if ((long)base == -1)
+ {
+ FatalError("xf86MapVidMem: Failed to mmap video memory\n");
+ }
+ return(base);
+
+}
+
+void xf86UnMapVidMem(ScreenNum, Base, Size)
+int ScreenNum;
+pointer Base;
+unsigned long Size;
+{
+
+ xf86ErrorF("xf86UnmapVidMem called\n");
+ munmap((caddr_t) Base, Size);
+
+}
+
+/* Finally, this function allows us to read the video BIOS content */
+
+int
+xf86ReadBIOS(Base, Offset, Buf, Len)
+unsigned long Base, Offset;
+unsigned char *Buf;
+int Len;
+{
+ unsigned char * VirtBase;
+
+ xf86ErrorF("xf86ReadBIOS called\n");
+ if (QNX_PhMem_fd == -1)
+ {
+ if ((QNX_PhMem_fd = shm_open("Physical", O_RDWR, 0777)) < 0)
+ {
+ FatalError("xf86ReadBIOS: cannot open Physical memory\n");
+ }
+ }
+
+ /* Use mmap to map BIOS region. Note the restrictions on
+ * mmap alignement of offset variable (which must be on a page
+ * boundary).
+ */
+ VirtBase = (unsigned char *) mmap(0, (size_t)((Offset & 0x7fff) + Len), PROT_READ,
+ MAP_SHARED, QNX_PhMem_fd,
+ (off_t) (Base + (Offset & 0xffff8000)));
+ if((long)VirtBase == -1) {
+ FatalError(
+ "xf86ReadBIOS: Could not mmap BIOS memory space, errno=%i\n",
+ errno);
+ }
+
+ /* So now we have our mapping to the BIOS region */
+ /* Do a sanity check on what we have just mapped */
+ if (((off_t)((off_t)Offset & 0x7FFF) != (off_t)0) &&
+ (VirtBase[0] != 0x55) &&
+ (VirtBase[1] != 0xaa)) {
+ xf86ErrorF(
+ "xf86ReadBIOS: BIOS sanity check failed, addr=%x\n",
+ (int)Base + Offset);
+ munmap(VirtBase, (Offset & 0x7fff) + Len);
+ return(-1);
+ }
+
+ /* Things look good: copy BIOS data */
+ memcpy(Buf, VirtBase + (Offset & 0x7fff), Len);
+ munmap(VirtBase, (Offset & 0x7fff) + Len);
+ return(Len);
+
+}
+
+void
+xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base,
+ unsigned long Size)
+{
+ return;
+}
+
+Bool
+xf86CheckMTRR(int s)
+{
+ return FALSE;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/Imakefile
new file mode 100644
index 000000000..35502389a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/Imakefile
@@ -0,0 +1,56 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/Imakefile,v 3.15 2002/10/17 02:22:49 dawes Exp $
+
+
+
+
+XCOMM $XConsortium: Imakefile /main/4 1996/09/28 17:24:25 rws $
+
+#include <Server.tmpl>
+
+SRCS = sco_init.c sco_video.c sco_io.c sco_iop.c sco_mouse.c VTsw_sco.c \
+ std_kbdEv.c posix_tty.c bios_mmap.c vidmem.c \
+ libc_wrapper.c stdResource.c stdPci.c sigiostubs.c pm_noop.c \
+ kmod_noop.c agp_noop.c sco_kbd.c at_scancode.c sco_KbdMap.c
+
+OBJS = sco_init.o sco_video.o sco_io.o sco_iop.o sco_mouse.o VTsw_sco.o \
+ std_kbdEv.o posix_tty.o bios_mmap.o vidmem.o \
+ libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o \
+ kmod_noop.o agp_noop.o sco_kbd.o at_scancode.o sco_KbdMap.o \
+ sco_event.o
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+ -I$(SERVERSRC)/mi -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+RESDEFINES = -DUSESTDRES
+
+DEFINES = $(RESDEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+XCOMM Hack for SCO platforms to get around a bug in GNU ld. The server needs
+XCOMM to link with -levent for the event driver interface. However, that is
+XCOMM a COFF-only library, and GCC/GNU ld only deal with ELF. Theoretically,
+XCOMM GNU ld will convert COFF to ELF on the fly, but it gets it wrong. The
+XCOMM SCO link editor gets it right. So we create an object here that the
+XCOMM server can link against.
+sco_event.o:
+ @ar x /usr/lib/libevent.a mouse.o
+ @/usr/ccs/bin/elf/ld -r -o sco_event.o mouse.o
+ @rm -f mouse.o
+
+LinkSourceFile(bios_mmap.c,../shared)
+LinkSourceFile(std_kbdEv.c,../shared)
+LinkSourceFile(at_scancode.c,../shared)
+LinkSourceFile(posix_tty.c,../shared)
+LinkSourceFile(libc_wrapper.c,../shared)
+LinkSourceFile(stdResource.c,../shared)
+LinkSourceFile(stdPci.c,../shared)
+LinkSourceFile(sigiostubs.c,../shared)
+LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
+LinkSourceFile(agp_noop.c,../shared)
+LinkSourceFile(vidmem.c,../shared)
+
+DependTarget()
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/VTsw_sco.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/VTsw_sco.c
new file mode 100644
index 000000000..beb86ccad
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/VTsw_sco.c
@@ -0,0 +1,119 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/VTsw_sco.c,v 1.2 1998/07/25 16:56:57 dawes Exp $ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ * Copyright 1993 by David McCullough <davidm@stallion.oz.au>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: VTsw_sco.c /main/2 1995/11/13 06:08:36 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+/* For the event driver prototypes */
+#include <sys/event.h>
+#include <mouse.h>
+
+/*
+ * Handle the VT-switching interface for SCO
+ */
+
+/*
+ * This function is the signal handler for the VT-switching signal. It
+ * is only referenced inside the OS-support layer. NOTE: we do NOT need
+ * to re-arm the signal here, since we used sigaction() to set the signal
+ * disposition in sco_init.c. If we had used signal(), we would need to
+ * re-arm the signal here. All we need to do now is record the fact that
+ * we got the signal. XFree86 handles the rest.
+ */
+void
+xf86VTRequest(int sig)
+{
+ xf86Info.vtRequestsPending = TRUE;
+ return;
+}
+
+Bool
+xf86VTSwitchPending(void)
+{
+ return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+}
+
+/*
+ * When we switch away, we need to flush and suspend the event driver
+ * before the VT_RELDISP. We also need to get the current LED status
+ * and preserve it, so that we can restore it when we come back.
+ */
+static int sco_ledstatus = -1;
+static unsigned int sco_ledstate = 0;
+
+Bool
+xf86VTSwitchAway(void)
+{
+ ev_flush();
+ ev_suspend();
+
+ sco_ledstatus = ioctl(xf86Info.consoleFd, KDGETLED, &sco_ledstate);
+
+ xf86Info.vtRequestsPending = FALSE;
+ if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_TRUE) < 0) {
+ return(FALSE);
+ } else {
+ return(TRUE);
+ }
+}
+
+/*
+ * When we come back to the X server, we need to resume the event driver,
+ * and we need to restore the LED settings to what they were when we
+ * switched away.
+ */
+Bool
+xf86VTSwitchTo(void)
+{
+ ev_resume();
+
+ xf86Info.vtRequestsPending = FALSE;
+ if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) {
+ return(FALSE);
+ } else {
+ if (sco_ledstatus >= 0) {
+ ioctl (xf86Info.consoleFd, KDSETLED, sco_ledstate);
+ }
+ sco_ledstatus = -1;
+
+ /*
+ * Convince the console driver this screen is in graphics mode,
+ * otherwise it assumes it can do more to the screen than it should.
+ */
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
+ ErrorF("Failed to set graphics mode (%s)\n", strerror(errno));
+ }
+
+ return TRUE;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_KbdMap.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_KbdMap.c
new file mode 100644
index 000000000..6a0e9de04
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_KbdMap.c
@@ -0,0 +1,304 @@
+/* $XFree86$ */
+/*
+ * Copyright 2005 by J. Kean Johnston <jkj@sco.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name J. Kean Johnston not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. J. Kean Johnston makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * Based on xf86KbdMap.c, which is
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ * Copyright (c) 1992-2003 by The XFree86 Project, Inc.
+ */
+
+#include "X.h"
+#include "Xmd.h"
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86Xinput.h"
+#include "xf86OSKbd.h"
+#include "atKeynames.h"
+#include "xf86Keymap.h"
+
+#include "sco_kbd.h"
+
+#define KD_GET_ENTRY(i,n) \
+ eascii_to_x[((priv->keymap.key[i].spcl << (n+1)) & 0x100) + priv->keymap.key[i].map[n]]
+
+/*
+ * NOTE: Not all possible remappable symbols are remapped. There are two main
+ * reasons:
+ * a) The mapping between scancode and SYSV/386 - symboltable
+ * is inconsistent between different versions and has some
+ * BIG mistakes.
+ * b) In X-Windows there is a difference between numpad-keys
+ * and normal keys. SYSV/386 uses for both kinds of keys
+ * the same symbol.
+ *
+ * Thus only the alpha keypad and the function keys are translated.
+ * Also CapsLock, NumLock, ScrollLock, Shift, Control & Alt.
+ */
+
+static unsigned char remap[128] = {
+ 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0, /* 0x30 - 0x37 */
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38 - 0x3f */
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0, /* 0x40 - 0x47 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */
+ 0, 0, 0, 0, 0, 0, 0x56, 0x57, /* 0x50 - 0x57 */
+ 0x58, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x67 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68 - 0x6f */
+ 0, 0, 0x69, 0x65, 0, 0, 0, 0, /* 0x70 - 0x77 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */
+};
+
+static KeySym eascii_to_x[512] = {
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, XK_Return, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Escape,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
+ XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
+ XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
+ XK_comma, XK_minus, XK_period, XK_slash,
+ XK_0, XK_1, XK_2, XK_3,
+ XK_4, XK_5, XK_6, XK_7,
+ XK_8, XK_9, XK_colon, XK_semicolon,
+ XK_less, XK_equal, XK_greater, XK_question,
+ XK_at, XK_A, XK_B, XK_C,
+ XK_D, XK_E, XK_F, XK_G,
+ XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O,
+ XK_P, XK_Q, XK_R, XK_S,
+ XK_T, XK_U, XK_V, XK_W,
+ XK_X, XK_Y, XK_Z, XK_bracketleft,
+ XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
+ XK_grave, XK_a, XK_b, XK_c,
+ XK_d, XK_e, XK_f, XK_g,
+ XK_h, XK_i, XK_j, XK_k,
+ XK_l, XK_m, XK_n, XK_o,
+ XK_p, XK_q, XK_r, XK_s,
+ XK_t, XK_u, XK_v, XK_w,
+ XK_x, XK_y, XK_z, XK_braceleft,
+ XK_bar, XK_braceright, XK_asciitilde, XK_Delete,
+ XK_Ccedilla, XK_udiaeresis, XK_eacute, XK_acircumflex,
+ XK_adiaeresis, XK_agrave, XK_aring, XK_ccedilla,
+ XK_ecircumflex, XK_ediaeresis, XK_egrave, XK_idiaeresis,
+ XK_icircumflex, XK_igrave, XK_Adiaeresis, XK_Aring,
+ XK_Eacute, XK_ae, XK_AE, XK_ocircumflex,
+ XK_odiaeresis, XK_ograve, XK_ucircumflex, XK_ugrave,
+ XK_ydiaeresis, XK_Odiaeresis, XK_Udiaeresis, XK_cent,
+ XK_sterling, XK_yen, XK_paragraph, XK_section,
+ XK_aacute, XK_iacute, XK_oacute, XK_uacute,
+ XK_ntilde, XK_Ntilde, XK_ordfeminine, XK_masculine,
+ XK_questiondown,XK_hyphen, XK_notsign, XK_onehalf,
+ XK_onequarter, XK_exclamdown, XK_guillemotleft,XK_guillemotright,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_Greek_alpha, XK_ssharp, XK_Greek_GAMMA, XK_Greek_pi,
+ XK_Greek_SIGMA, XK_Greek_sigma, XK_mu, XK_Greek_tau,
+ XK_Greek_PHI, XK_Greek_THETA, XK_Greek_OMEGA, XK_Greek_delta,
+ XK_infinity, XK_Ooblique, XK_Greek_epsilon, XK_intersection,
+ XK_identical, XK_plusminus, XK_greaterthanequal, XK_lessthanequal,
+ XK_topintegral, XK_botintegral, XK_division, XK_similarequal,
+ XK_degree, NoSymbol, NoSymbol, XK_radical,
+ XK_Greek_eta, XK_twosuperior, XK_periodcentered, NoSymbol,
+
+ /*
+ * special marked entries (256 + x)
+ */
+
+ NoSymbol, NoSymbol, XK_Shift_L, XK_Shift_R,
+ XK_Caps_Lock, XK_Num_Lock, XK_Scroll_Lock, XK_Alt_L,
+ NoSymbol, XK_Control_L, XK_Alt_L, XK_Alt_R,
+ XK_Control_L, XK_Control_R, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_F1,
+ XK_F2, XK_F3, XK_F4, XK_F5,
+ XK_F6, XK_F7, XK_F8, XK_F9,
+ XK_F10, XK_F11, XK_F12, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ };
+
+/*
+ * KbdGetMapping --
+ * Get the national keyboard mapping. The keyboard type is set, a new map
+ * and the modifiermap is computed.
+ */
+
+void
+KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ ScoKbdPrivPtr priv = (ScoKbdPrivPtr) pKbd->private;
+ KeySym *k;
+ int i;
+ KeySym *pMap = map;
+
+ for (i = 0; i < priv->keymap.n_keys && i < NUM_KEYCODES; i++) {
+ if (remap[i]) {
+ k = pMap + (remap[i] << 2);
+
+ k[0] = KD_GET_ENTRY(i,0); /* non-shifed */
+ k[1] = KD_GET_ENTRY(i,1); /* shifted */
+ k[2] = KD_GET_ENTRY(i,4); /* alt */
+ k[3] = KD_GET_ENTRY(i,5); /* alt - shifted */
+
+ if (k[3] == k[2]) k[3] = NoSymbol;
+ if (k[2] == k[1]) k[2] = NoSymbol;
+ if (k[1] == k[0]) k[1] = NoSymbol;
+ if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
+ }
+ }
+
+ /*
+ * compute the modifier map
+ */
+ for (i = 0; i < MAP_LENGTH; i++)
+ pModMap[i] = NoSymbol; /* make sure it is restored */
+
+ for (k = pMap, i = MIN_KEYCODE;
+ i < (NUM_KEYCODES + MIN_KEYCODE);
+ i++, k += GLYPHS_PER_KEY) {
+
+ switch(*k) {
+ case XK_Shift_L:
+ case XK_Shift_R:
+ pModMap[i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ case XK_Control_R:
+ pModMap[i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ pModMap[i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ case XK_Alt_R:
+ pModMap[i] = AltMask;
+ break;
+
+ case XK_Num_Lock:
+ pModMap[i] = NumLockMask;
+ break;
+
+ case XK_Scroll_Lock:
+ pModMap[i] = ScrollLockMask;
+ break;
+
+ /* kana support */
+ case XK_Kana_Lock:
+ case XK_Kana_Shift:
+ pModMap[i] = KanaMask;
+ break;
+
+ /* alternate toggle for multinational support */
+ case XK_Mode_switch:
+ pModMap[i] = AltLangMask;
+ break;
+ }
+ }
+
+ pKeySyms->map = pMap;
+ pKeySyms->mapWidth = GLYPHS_PER_KEY;
+ pKeySyms->minKeyCode = MIN_KEYCODE;
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_init.c
new file mode 100644
index 000000000..bc1f3b56d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_init.c
@@ -0,0 +1,296 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_init.c,v 3.13 2002/06/03 21:22:10 dawes Exp $ */
+/*
+ * Copyright 2001-2005 by J. Kean Johnston <jkj@sco.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name J. Kean Johnston not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. J. Kean Johnston makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XConsortium$ */
+
+/* Re-written May 2001 to represent the current state of reality */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+static Bool KeepTty = FALSE;
+static int VTnum = -1;
+static char vtdevice[48];
+static int sco_console_mode = -1;
+
+extern Bool mpxLock;
+
+void
+xf86OpenConsole(void)
+{
+ int i, ioctl_ret;
+ struct vt_mode VT;
+ struct vid_info vidinf;
+ struct sigaction sigvtsw;
+ char *ttn;
+
+ if (serverGeneration == 1) {
+ /* check if we're run with euid==0 */
+ if (geteuid() != 0) {
+ FatalError("xf86OpenConsole: Server must be setuid root\n");
+ }
+
+ /* If we are run in the background we will get SIGTTOU. Ignore it. */
+ OsSignal (SIGTTOU, SIG_IGN);
+
+ /*
+ * Set up the virtual terminal (multiscreen in SCO parlance).
+ * For the actual console itself, screens are numbered from
+ * 1 to (usually) 16. However, it is possible to have a nested
+ * server, and it is also possible to be on a multi-console
+ * system such as MaxSpeed or SunRiver. Therefore, we should
+ * not make any assumptions about the TTY name we are on, and
+ * instead we rely on ttyname() to give us the real TTY name.
+ * Previously, we tried to determine the TTY name manually.
+ * This is wrong. The only time we need to futz with the TTY name
+ * is if we were given the name of a TTY to run on explicity on
+ * the command line.
+ */
+
+ if (VTnum == -1) {
+ /*
+ * No device was specified. We need to query the kernel to see which
+ * console device we are on (and in fact if we are on a console at all).
+ */
+ ttn = ttyname (1);
+
+ if (ttn == (char *)0) {
+ FatalError ("xf86OpenConsole: Could not determine TTY name: %s\n",
+ strerror(errno));
+ }
+ strlcpy (vtdevice, ttn, sizeof(vtdevice));
+ } else if (VTnum >= 0) {
+ snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum);
+ }
+
+ /*
+ * Now we can dispose of stdin/stdout
+ */
+ fclose (stdin);
+ fclose (stdout);
+
+ if ((xf86Info.consoleFd = open(vtdevice, O_RDWR | O_NDELAY, 0)) < 0) {
+ FatalError("xf86OpenConsole: Cannot open %s: %s\n", vtdevice,
+ strerror(errno));
+ }
+
+ /*
+ * We make 100% sure we use the correct VT number. This can get ugly
+ * where there are multi-consoles in use, so we make sure we query
+ * the kernel for the correct VT number. It knows best, we don't.
+ */
+ vidinf.size = sizeof(vidinf);
+ if (ioctl (xf86Info.consoleFd, CONS_GETINFO, &vidinf) < 0) {
+ FatalError ("xf86OpenConsole: %s not a console device "
+ "or error querying device: %s\n", vtdevice, strerror (errno));
+ }
+ xf86Info.vtno = vidinf.m_num;
+ VTnum = vidinf.m_num + 1; /* 0-based */
+
+ ErrorF("(using VT%02d device %s)\n\n", VTnum, vtdevice);
+
+ /* We activate the console just in case its not the one we are on */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
+ ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno));
+ }
+
+ /* Disassociate from controling TTY */
+ if (!KeepTty) {
+ setpgrp();
+ }
+
+ /*
+ * Now we get the current mode that the console device is in. We will
+ * use this later when we close the console device to restore it to
+ * that same mode.
+ */
+ if ((sco_console_mode = ioctl(xf86Info.consoleFd, CONS_GET, 0L)) < 0) {
+ FatalError("xf86OpenConsole: CONS_GET failed on console (%s)\n",
+ strerror(errno));
+ }
+
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) {
+ FatalError("xf86OpenConsole: VT_GETMODE failed (%s)\n", strerror(errno));
+ }
+
+ sigvtsw.sa_handler = xf86VTRequest;
+ sigfillset(&sigvtsw.sa_mask);
+ sigvtsw.sa_flags = 0;
+
+ /* NOTE: Using sigaction means we dont have to re-arm the signal */
+ sigaction(SIGUSR1, &sigvtsw, NULL);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+ VT.frsig = SIGINT; /* Not implemented */
+ VT.waitv = 0;
+
+ /*
+ * The SCO X server tries the following call 5 times. Lets do the same
+ * thing. It shouldn't really be required but sometimes things take a
+ * while to settle down when switching screens. *helpless shrug* I know
+ * its sucks but ...
+ */
+
+ ioctl_ret = 0;
+ for (i = 0; i < 5; i++) {
+ ioctl_ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT);
+ if (ioctl_ret >= 0)
+ break;
+ usleep(999999); /* Dont use nap() - it forces linking with -lx */
+ }
+
+ if (ioctl_ret < 0) {
+ FatalError("xf86OpenConsole: VT_SETMODE failed (%s)\n", strerror(errno));
+ }
+
+ /*
+ * Convince the console driver we are in graphics mode.
+ */
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
+ ErrorF("Failed to set graphics mode (%s)\n", strerror(errno));
+ }
+ } else { /* serverGeneration != 1 */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
+ ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno));
+ }
+ }
+}
+
+/*
+ * Restore the console to its previous state. This may cause flicker if
+ * the screen was previous in a graphics mode, because we first set it
+ * to text mode. This has the advantage of getting the console driver
+ * to do a soft reset on the card, which really does help settle the
+ * video card down again after coming out of Xfree86.
+ */
+void
+xf86CloseConsole(void)
+{
+ struct vt_mode VT;
+ struct sigaction sigvtsw;
+
+ /* Set text mode (possibly briefly) */
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT0);
+
+ /* Restore the original mode */
+ if (sco_console_mode != -1) {
+ ioctl(xf86Info.consoleFd, MODESWITCH | sco_console_mode, 0L);
+ }
+
+ ioctl(xf86Info.consoleFd, VT_RELDISP, 1); /* Release the display */
+
+ sigvtsw.sa_handler = SIG_DFL;
+ sigfillset(&sigvtsw.sa_mask);
+ sigvtsw.sa_flags = 0;
+
+ sigaction(SIGUSR1, &sigvtsw, NULL);
+
+ VT.mode = VT_AUTO;
+ VT.waitv = 0;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+ VT.frsig = SIGINT;
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* Revert to auto handling */
+
+ close(xf86Info.consoleFd); /* We're done with the device */
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals).
+ */
+ if (!strcmp(argv[i], "-keeptty")) {
+ KeepTty = TRUE;
+ return(1);
+ }
+
+ /*
+ * By default, the X server wants to bind itself to CPU 0. This makes
+ * sure that the server has full access to the I/O ports at IOPL 3.
+ * Some SMP systems have trouble with I/O on CPU's other than 0. If,
+ * however, you have a system that is well behaved, you can specify
+ * this argument and let the scheduler decide which CPU the server
+ * should run on.
+ */
+ if (!strcmp(argv[i], "-nompxlock")) {
+ mpxLock = FALSE;
+ return (1);
+ }
+
+ /*
+ * Specify the VT number to run on (NOT the device).
+ */
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't')) {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0) {
+ UseMsg();
+ VTnum = -1;
+ return(0);
+ }
+ if (VTnum <= 0) {
+ UseMsg();
+ VTnum = -1;
+ return(0);
+ }
+ return(1);
+ }
+
+ /*
+ * Use a device the user specifies.
+ */
+ if (!strcmp(argv[i], "-crt")) {
+ if (++i > argc) {
+ UseMsg();
+ VTnum = -1;
+ return(0);
+ } else {
+ VTnum = -2;
+ strlcpy (vtdevice, argv[i], sizeof(vtdevice));
+ return(2);
+ }
+ }
+ return(0);
+}
+
+void
+xf86UseMsg(void)
+{
+ ErrorF("vtXX use the specified VT number\n");
+ ErrorF("-crt DEVICE use the specified VT device\n");
+ ErrorF("-nompxlock dont bind X server to CPU 0\n");
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_io.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_io.c
new file mode 100644
index 000000000..c97916cf5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_io.c
@@ -0,0 +1,269 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_io.c,v 3.9 2002/10/11 01:40:36 dawes Exp $ */
+/*
+ * Copyright 2001 by J. Kean Johnston <jkj@sco.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name J. Kean Johnston not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. J. Kean Johnston makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XConsortium$ */
+
+/* Re-written May 2001 to represent the current state of reality */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "compiler.h"
+
+#define _NEED_SYSI86
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86OSpriv.h"
+#include "xf86_OSlib.h"
+
+#include <sys/param.h>
+#include <sys/emap.h>
+#include <sys/nmap.h>
+
+void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
+{
+ if (loudness && pitch) {
+ ioctl(xf86Info.consoleFd, KIOCSOUND, 1193180 / pitch);
+ usleep(duration * loudness * 20);
+ ioctl(xf86Info.consoleFd, KIOCSOUND, 0);
+ }
+}
+
+void
+xf86SetKbdLeds(int leds)
+{
+ /*
+ * sleep the first time through under SCO. There appears to be a
+ * timing problem in the driver which causes the keyboard to be lost.
+ * This usleep stops it from occurring. NOTE: this was in the old code.
+ * I am not convinced it is true any longer, but it doesn't hurt to
+ * leave this in here.
+ */
+ static int once = 1;
+
+ if (once) {
+ usleep(100);
+ once = 0;
+ }
+
+ ioctl(xf86Info.consoleFd, KDSETLED, leds );
+}
+
+int
+xf86GetKbdLeds(void)
+{
+ int leds;
+
+ ioctl (xf86Info.consoleFd, KDGETLED, &leds);
+ return leds;
+}
+
+/*
+ * Much of the code in this function is duplicated from the Linux code
+ * by Orest Zborowski <obz@Kodak.com> and David Dawes <dawes@xfree86.org>.
+ * Please see the file ../linux/lnx_io.c for full copyright information.
+ *
+ * NOTE: Only OpenServer Release 5.0.6 with Release Supplement 5.0.6A
+ * and later have the required ioctl. 5.0.6A or higher is HIGHLY
+ * recommended. The console driver is quite a different beast on that OS.
+ */
+void
+xf86SetKbdRepeat(char rad)
+{
+#if defined(KBIO_SETRATE)
+ int i;
+ int value = 0x7f; /* Maximum delay with slowest rate */
+ int delay = 250; /* Default delay */
+ int rate = 300; /* Default repeat rate */
+
+ static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
+ 133, 120, 109, 100, 92, 86, 80, 75, 67,
+ 60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
+ 25, 23, 21, 20 };
+#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
+
+ static int valid_delays[] = { 250, 500, 750, 1000 };
+#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
+
+ if (xf86Info.kbdRate >= 0)
+ rate = xf86Info.kbdRate * 10;
+ if (xf86Info.kbdDelay >= 0)
+ delay = xf86Info.kbdDelay;
+
+ for (i = 0; i < RATE_COUNT; i++)
+ if (rate >= valid_rates[i]) {
+ value &= 0x60;
+ value |= i;
+ break;
+ }
+
+ for (i = 0; i < DELAY_COUNT; i++)
+ if (delay <= valid_delays[i]) {
+ value &= 0x1f;
+ value |= i << 5;
+ break;
+ }
+
+ ioctl (xf86Info.consoleFd, KBIO_SETRATE, value);
+#endif /* defined(KBIO_SETRATE) */
+}
+
+static Bool use_tcs = TRUE, use_kd = TRUE;
+static Bool no_nmap = TRUE, no_emap = TRUE;
+static int orig_getsc, orig_kbm;
+static struct termios orig_termios;
+static keymap_t keymap, noledmap;
+static uchar_t *sc_mapbuf;
+static uchar_t *sc_mapbuf2;
+
+void
+xf86KbdInit(void)
+{
+ orig_getsc = 0;
+ if (ioctl (xf86Info.consoleFd, TCGETSC, &orig_getsc) < 0)
+ use_tcs = FALSE;
+ if (ioctl (xf86Info.consoleFd, KDGKBMODE, &orig_kbm) < 0)
+ use_kd = FALSE;
+
+ if (!use_tcs && !use_kd)
+ FatalError ("xf86KbdInit: Could not determine keyboard mode\n");
+
+ /*
+ * One day this should be fixed to translate normal ASCII characters
+ * back into scancodes or into events that XFree86 wants, but not
+ * now. For the time being, we only support scancode mode screens.
+ */
+ if (use_tcs && !(orig_getsc & KB_ISSCANCODE))
+ FatalError ("xf86KbdInit: Keyboard can not send scancodes\n");
+
+ /*
+ * We need to get the original keyboard map and NUL out the lock
+ * modifiers. This prevents the scancode API from messing with
+ * the keyboard LED's. We restore the original map when we exit.
+ */
+ if (ioctl (xf86Info.consoleFd, GIO_KEYMAP, &keymap) < 0) {
+ FatalError ("xf86KbdInit: Failed to get keyboard map (%s)\n",
+ strerror(errno));
+ }
+ if (ioctl (xf86Info.consoleFd, GIO_KEYMAP, &noledmap) < 0) {
+ FatalError ("xf86KbdInit: Failed to get keyboard map (%s)\n",
+ strerror(errno));
+ } else {
+ int i, j;
+
+ for (i = 0; i < noledmap.n_keys; i++) {
+ for (j = 0; j < NUM_STATES; j++) {
+ if (IS_SPECIAL(noledmap, i, j) &&
+ ((noledmap.key[i].map[j] == K_CLK) ||
+ (noledmap.key[i].map[j] == K_NLK) ||
+ (noledmap.key[i].map[j] == K_SLK))) {
+ noledmap.key[i].map[j] = K_NOP;
+ }
+ }
+ }
+ }
+
+ if (ioctl (xf86Info.consoleFd, XCGETA, &orig_termios) < 0) {
+ FatalError ("xf86KbdInit: Failed to get terminal modes (%s)\n",
+ strerror(errno));
+ }
+
+ sc_mapbuf = xalloc (10*BSIZE);
+ sc_mapbuf2 = xalloc(10*BSIZE);
+
+ /* Get the emap */
+ if (ioctl (xf86Info.consoleFd, LDGMAP, sc_mapbuf) < 0) {
+ if (errno != ENAVAIL) {
+ FatalError ("xf86KbdInit: Failed to retrieve e-map (%s)\n",
+ strerror (errno));
+ }
+ no_emap = FALSE;
+ }
+
+ /* Get the nmap */
+ if (ioctl (xf86Info.consoleFd, NMGMAP, sc_mapbuf2) < 0) {
+ if (errno != ENAVAIL) {
+ FatalError ("xf86KbdInit: Failed to retrieve n-map (%s)\n",
+ strerror (errno));
+ }
+ no_nmap = FALSE;
+ }
+}
+
+int
+xf86KbdOn(void)
+{
+ struct termios newtio;
+
+ ioctl (xf86Info.consoleFd, LDNMAP); /* Turn e-mapping off */
+ ioctl (xf86Info.consoleFd, NMNMAP); /* Turn n-mapping off */
+
+ newtio = orig_termios; /* structure copy */
+ newtio.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ newtio.c_oflag = 0;
+ newtio.c_cflag = CREAD | CS8 | B9600;
+ newtio.c_lflag = 0;
+ newtio.c_cc[VTIME]=0;
+ newtio.c_cc[VMIN]=1;
+ cfsetispeed(&newtio, 9600);
+ cfsetospeed(&newtio, 9600);
+ ioctl(xf86Info.consoleFd, XCSETA, &newtio);
+
+ /* Now tell the keyboard driver to send us raw scancodes */
+ if (use_tcs) {
+ int nm = orig_getsc;
+ nm &= ~KB_XSCANCODE;
+ ioctl (xf86Info.consoleFd, TCSETSC, &nm);
+ }
+
+ if (use_kd)
+ ioctl (xf86Info.consoleFd, KDSKBMODE, K_RAW);
+
+ ioctl (xf86Info.consoleFd, PIO_KEYMAP, &noledmap);
+
+ return(xf86Info.consoleFd);
+}
+
+int
+xf86KbdOff(void)
+{
+ /* Revert back to original translate scancode mode */
+ if (use_tcs)
+ ioctl (xf86Info.consoleFd, TCSETSC, &orig_getsc);
+ if (use_kd)
+ ioctl (xf86Info.consoleFd, KDSKBMODE, orig_kbm);
+
+ ioctl (xf86Info.consoleFd, PIO_KEYMAP, &keymap);
+
+ if (no_emap)
+ ioctl (xf86Info.consoleFd, LDSMAP, sc_mapbuf);
+ if (no_nmap)
+ ioctl (xf86Info.consoleFd, NMSMAP, sc_mapbuf2);
+
+ ioctl(xf86Info.consoleFd, XCSETA, &orig_termios);
+
+ return(xf86Info.consoleFd);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_iop.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_iop.c
new file mode 100644
index 000000000..35d48e04a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_iop.c
@@ -0,0 +1,136 @@
+/* $XFree86$ */
+/*
+ * Copyright 2001 by J. Kean Johnston <jkj@caldera.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name J. Kean Johnston not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. J. Kean Johnston makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XConsortium$ */
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "compiler.h"
+
+#define _NEED_SYSI86
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86OSpriv.h"
+#include "xf86_OSlib.h"
+
+
+/***************************************************************************/
+/* I/O Permissions section */
+/***************************************************************************/
+
+/*
+ * There is a right way and a wrong way of doing this. Unfortunately, we
+ * are forced to do it the wrong way. The right way is to be told the range
+ * or ranges of I/O ports the driver(s) need access to, in order to use the
+ * CONS_IOPERM ioctl() to grant access only to those ports we care about.
+ * This way we can guarantee some small level of stability because a driver
+ * does not have access to all ports (which would mean it could play with
+ * the PIT and thus affect scheduling times, or a whole slew of other
+ * nasty things). However, because XFree86 currently only enables or disables
+ * ALL port access, we need to run at IOPL 3, which basically means the
+ * X Server runs at the same level as the kernel. You can image why this is
+ * unsafe. Oh, and this is not a problem unique to OSR5, other OSes are
+ * affected by this as well.
+ *
+ * So, for the time being, we change our IOPL until such time as the XFree86
+ * architecture is changed to allow for tighter control of I/O ports. If and
+ * when it is, then the CONS_ADDIOP/DELIOP ioctl() should be used to enable
+ * or disable access to the desired ports.
+ */
+
+extern long sysi86 (int cmd, ...);
+
+static Bool IOEnabled = FALSE;
+
+Bool
+xf86EnableIO(void)
+{
+ if (IOEnabled)
+ return TRUE;
+
+ if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) {
+ xf86Msg(X_WARNING,"Failed to set IOPL for extended I/O\n");
+ return FALSE;
+ }
+
+ IOEnabled = TRUE;
+ return TRUE;
+}
+
+void
+xf86DisableIO(void)
+{
+ if (!IOEnabled)
+ return;
+
+ sysi86(SI86V86, V86SC_IOPL, 0);
+ IOEnabled = FALSE;
+}
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+Bool
+xf86DisableInterrupts(void)
+{
+ if (!IOEnabled) {
+ if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)
+ return FALSE;
+ }
+
+#ifdef __GNUC__
+ __asm__ __volatile__("cli");
+#else
+ asm("cli");
+#endif /* __GNUC__ */
+
+ if (!IOEnabled) {
+ sysi86(SI86V86, V86SC_IOPL, PS_IOPL);
+ }
+
+ return(TRUE);
+}
+
+void
+xf86EnableInterrupts(void)
+{
+ if (!IOEnabled) {
+ if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)
+ return;
+ }
+
+#ifdef __GNUC__
+ __asm__ __volatile__("sti");
+#else
+ asm("sti");
+#endif /* __GNUC__ */
+
+ if (!IOEnabled) {
+ sysi86(SI86V86, V86SC_IOPL, PS_IOPL);
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_kbd.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_kbd.c
new file mode 100644
index 000000000..a26b7e96b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_kbd.c
@@ -0,0 +1,530 @@
+/* $XFree86$ */
+/*
+ * Copyright 2005 by J. Kean Johnston <jkj@sco.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name J. Kean Johnston not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. J. Kean Johnston makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XConsortium$ */
+
+/*
+ * Based on sco_io.c which is
+ * (C) Copyright 2003 J. Kean Johnston <jkj@sco.com>
+ *
+ * Based on lnx_kbd.c which is
+ * Copyright (c) 2002 by The XFree86 Project, Inc.
+ *
+ * Based on the code from lnx_io.c which is
+ * Copyright 1992 by Orest Zborowski <obz@Kodak.com>
+ * Copyright 1993 by David Dawes <dawes@xfree86.org>
+ */
+
+#define NEED_EVENTS
+#include "X.h"
+
+#include "compiler.h"
+
+#define _NEED_SYSI86
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86OSpriv.h"
+#include "xf86_OSlib.h"
+
+#include "xf86Xinput.h"
+#include "xf86OSKbd.h"
+#include "atKeynames.h"
+#include "sco_kbd.h"
+
+#include <sys/param.h>
+#include <sys/emap.h>
+#include <sys/nmap.h>
+
+static KbdProtocolRec protocols[] = {
+ { "standard", PROT_STD },
+ { NULL, PROT_UNKNOWN_KBD }
+};
+
+extern Bool VTSwitchEnabled;
+#ifdef USE_VT_SYSREQ
+extern Bool VTSysreqToggle;
+#endif
+
+static void
+SoundBell(InputInfoPtr pInfo, int loudness, int pitch, int duration)
+{
+ if (loudness && pitch) {
+ ioctl(pInfo->fd, KIOCSOUND, 1193180 / pitch);
+ usleep(duration * loudness * 20);
+ ioctl(pInfo->fd, KIOCSOUND, 0);
+ }
+}
+
+static void
+SetKbdLeds(InputInfoPtr pInfo, int leds)
+{
+ int real_leds = 0;
+ static int once = 1;
+
+ /*
+ * sleep the first time through under SCO. There appears to be a
+ * timing problem in the driver which causes the keyboard to be lost.
+ * This usleep stops it from occurring. NOTE: this was in the old code.
+ * I am not convinced it is true any longer, but it doesn't hurt to
+ * leave this in here.
+ */
+ if (once) {
+ usleep(100);
+ once = 0;
+ }
+
+#ifdef LED_CAP
+ if (leds & XLED1)
+ real_leds |= LED_CAP;
+ if (leds & XLED2)
+ real_leds |= LED_NUM;
+ if (leds & XLED3)
+ real_leds |= LED_SCR;
+#ifdef LED_COMP
+ if (leds & XLED4)
+ real_leds |= LED_COMP;
+#else
+ if (leds & XLED4)
+ real_leds |= LED_SCR;
+#endif
+#endif
+ ioctl(pInfo->fd, KDSETLED, real_leds);
+}
+
+static int
+GetKbdLeds(InputInfoPtr pInfo)
+{
+ int real_leds, leds = 0;
+
+ ioctl(pInfo->fd, KDGETLED, &real_leds);
+
+ if (real_leds & LED_CAP) leds |= XLED1;
+ if (real_leds & LED_NUM) leds |= XLED2;
+ if (real_leds & LED_SCR) leds |= XLED3;
+
+ return(leds);
+}
+
+/*
+ * NOTE: Only OpenServer Release 5.0.6 with Release Supplement 5.0.6A
+ * and later have the required ioctl. 5.0.6A or higher is HIGHLY
+ * recommended. The console driver is quite a different beast on that OS.
+ */
+#undef rate
+
+static void
+SetKbdRepeat(InputInfoPtr pInfo, char rad)
+{
+#if defined(KBIO_SETRATE)
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ int i;
+ int value = 0x7f; /* Maximum delay with slowest rate */
+ int delay = 250; /* Default delay */
+ int rate = 300; /* Default repeat rate */
+
+ static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
+ 133, 120, 109, 100, 92, 86, 80, 75, 67,
+ 60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
+ 25, 23, 21, 20 };
+#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
+
+ static int valid_delays[] = { 250, 500, 750, 1000 };
+#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
+
+ if (pKbd->rate >= 0)
+ rate = pKbd->rate * 10;
+ if (pKbd->delay >= 0)
+ delay = pKbd->delay;
+
+ for (i = 0; i < RATE_COUNT; i++)
+ if (rate >= valid_rates[i]) {
+ value &= 0x60;
+ value |= i;
+ break;
+ }
+
+ for (i = 0; i < DELAY_COUNT; i++)
+ if (delay <= valid_delays[i]) {
+ value &= 0x1f;
+ value |= i << 5;
+ break;
+ }
+
+ ioctl (pInfo->fd, KBIO_SETRATE, value);
+#endif /* defined(KBIO_SETRATE) */
+}
+
+static int
+KbdInit(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ ScoKbdPrivPtr priv = (ScoKbdPrivPtr) pKbd->private;
+
+ if (pKbd->isConsole) {
+ priv->use_tcs = 1;
+ priv->use_kd = 1;
+ priv->no_nmap = 1;
+ priv->no_emap = 1;
+ priv->orig_getsc = 0;
+
+ if (ioctl (pInfo->fd, TCGETSC, &priv->orig_getsc) < 0)
+ priv->use_tcs = 0;
+ if (ioctl (pInfo->fd, KDGKBMODE, &priv->orig_kbm) < 0)
+ priv->use_kd = 0;
+
+ if (!priv->use_tcs && !priv->use_kd) {
+ xf86Msg (X_ERROR, "KbdInit: Could not determine keyboard mode\n");
+ return !Success;
+ }
+
+ /*
+ * One day this should be fixed to translate normal ASCII characters
+ * back into scancodes or into events that XFree86 wants, but not
+ * now. For the time being, we only support scancode mode screens.
+ */
+ if (priv->use_tcs && !(priv->orig_getsc & KB_ISSCANCODE)) {
+ xf86Msg (X_ERROR, "KbdInit: Keyboard can not send scancodes\n");
+ return !Success;
+ }
+
+ /*
+ * We need to get the original keyboard map and NUL out the lock
+ * modifiers. This prevents the scancode API from messing with
+ * the keyboard LED's. We restore the original map when we exit.
+ */
+ if (ioctl (pInfo->fd, GIO_KEYMAP, &priv->keymap) < 0) {
+ xf86Msg (X_ERROR, "KbdInit: Failed to get keyboard map (%s)\n",
+ strerror(errno));
+ return !Success;
+ }
+ if (ioctl (pInfo->fd, GIO_KEYMAP, &priv->noledmap) < 0) {
+ xf86Msg (X_ERROR, "KbdInit: Failed to get keyboard map (%s)\n",
+ strerror(errno));
+ return !Success;
+ } else {
+ int i, j;
+
+ for (i = 0; i < priv->noledmap.n_keys; i++) {
+ for (j = 0; j < NUM_STATES; j++) {
+ if (IS_SPECIAL(priv->noledmap, i, j) &&
+ ((priv->noledmap.key[i].map[j] == K_CLK) ||
+ (priv->noledmap.key[i].map[j] == K_NLK) ||
+ (priv->noledmap.key[i].map[j] == K_SLK))) {
+ priv->noledmap.key[i].map[j] = K_NOP;
+ }
+ }
+ }
+ }
+
+ if (ioctl (pInfo->fd, XCGETA, &priv->kbdtty) < 0) {
+ xf86Msg (X_ERROR, "KbdInit: Failed to get terminal modes (%s)\n",
+ strerror(errno));
+ return !Success;
+ }
+
+ priv->sc_mapbuf = xalloc (10*BSIZE);
+ priv->sc_mapbuf2 = xalloc(10*BSIZE);
+
+ /* Get the emap */
+ if (ioctl (pInfo->fd, LDGMAP, priv->sc_mapbuf) < 0) {
+ if (errno != ENAVAIL) {
+ xf86Msg (X_ERROR, "KbdInit: Failed to retrieve e-map (%s)\n",
+ strerror (errno));
+ return !Success;
+ }
+ priv->no_emap = 0;
+ }
+
+ /* Get the nmap */
+ if (ioctl (pInfo->fd, NMGMAP, priv->sc_mapbuf2) < 0) {
+ if (errno != ENAVAIL) {
+ xf86Msg (X_ERROR, "KbdInit: Failed to retrieve n-map (%s)\n",
+ strerror (errno));
+ return !Success;
+ }
+ priv->no_nmap = 0;
+ }
+ } /* End of if we are on a console */
+
+ return Success;
+}
+
+static int
+KbdOn(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ ScoKbdPrivPtr priv = (ScoKbdPrivPtr) pKbd->private;
+ struct termios newtio;
+
+ if (pKbd->isConsole) {
+ ioctl (pInfo->fd, LDNMAP); /* Turn e-mapping off */
+ ioctl (pInfo->fd, NMNMAP); /* Turn n-mapping off */
+
+ newtio = priv->kbdtty; /* structure copy */
+ newtio.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ newtio.c_oflag = 0;
+ newtio.c_cflag = CREAD | CS8 | B9600;
+ newtio.c_lflag = 0;
+ newtio.c_cc[VTIME]=0;
+ newtio.c_cc[VMIN]=1;
+ cfsetispeed(&newtio, 9600);
+ cfsetospeed(&newtio, 9600);
+ ioctl(pInfo->fd, XCSETA, &newtio);
+
+ /* Now tell the keyboard driver to send us raw scancodes */
+ if (priv->use_tcs) {
+ int nm = priv->orig_getsc;
+ nm &= ~KB_XSCANCODE;
+ ioctl (pInfo->fd, TCSETSC, &nm);
+ }
+
+ if (priv->use_kd)
+ ioctl (pInfo->fd, KDSKBMODE, K_RAW);
+
+ ioctl (pInfo->fd, PIO_KEYMAP, &priv->noledmap);
+ }
+
+ return Success;
+}
+
+static int
+KbdOff(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ ScoKbdPrivPtr priv = (ScoKbdPrivPtr) pKbd->private;
+
+ if (pKbd->isConsole) {
+ /* Revert back to original translate scancode mode */
+ if (priv->use_tcs)
+ ioctl (pInfo->fd, TCSETSC, &priv->orig_getsc);
+ if (priv->use_kd)
+ ioctl (pInfo->fd, KDSKBMODE, priv->orig_kbm);
+
+ ioctl (pInfo->fd, PIO_KEYMAP, &priv->keymap);
+
+ if (priv->no_emap)
+ ioctl (pInfo->fd, LDSMAP, priv->sc_mapbuf);
+ if (priv->no_nmap)
+ ioctl (pInfo->fd, NMSMAP, priv->sc_mapbuf2);
+
+ ioctl(pInfo->fd, XCSETA, &priv->kbdtty);
+ }
+
+ return Success;
+}
+
+static int
+GetSpecialKey(InputInfoPtr pInfo, int scanCode)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ int specialkey = scanCode;
+
+ if (pKbd->CustomKeycodes) {
+ specialkey = pKbd->specialMap->map[scanCode];
+ }
+ return specialkey;
+}
+
+#define ModifierSet(k) ((modifiers & (k)) == (k))
+
+static Bool
+SpecialKey(InputInfoPtr pInfo, int key, Bool down, int modifiers)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+
+ if(!pKbd->vtSwitchSupported)
+ return FALSE;
+
+ if ((!ModifierSet(ShiftMask)) && ((ModifierSet(ControlMask | AltMask)) ||
+ (ModifierSet(ControlMask | AltLangMask)))) {
+ if (VTSwitchEnabled && !xf86Info.vtSysreq) {
+ switch (key) {
+ case KEY_F1:
+ case KEY_F2:
+ case KEY_F3:
+ case KEY_F4:
+ case KEY_F5:
+ case KEY_F6:
+ case KEY_F7:
+ case KEY_F8:
+ case KEY_F9:
+ case KEY_F10:
+ if (down) {
+ int sts = key - KEY_F1;
+ if (sts != xf86Info.vtno) {
+ ioctl(pInfo->fd, VT_ACTIVATE, sts);
+ }
+ return TRUE;
+ }
+ case KEY_F11:
+ case KEY_F12:
+ if (down) {
+ int sts = key - KEY_F11 + 10;
+ if (sts != xf86Info.vtno) {
+ ioctl(pInfo->fd, VT_ACTIVATE, sts);
+ }
+ return TRUE;
+ }
+ }
+ }
+ }
+#ifdef USE_VT_SYSREQ
+ if (VTSwitchEnabled && xf86Info.vtSysreq) {
+ switch (key) {
+ case KEY_F1:
+ case KEY_F2:
+ case KEY_F3:
+ case KEY_F4:
+ case KEY_F5:
+ case KEY_F6:
+ case KEY_F7:
+ case KEY_F8:
+ case KEY_F9:
+ case KEY_F10:
+ if (VTSysreqToggle && down) {
+ ioctl(pInfo->fd, VT_ACTIVATE, key - KEY_F1);
+ VTSysreqToggle = FALSE;
+ return TRUE;
+ }
+ break;
+ case KEY_F11:
+ case KEY_F12:
+ if (VTSysreqToggle && down) {
+ ioctl(pInfo->fd, VT_ACTIVATE, key - KEY_F11 + 10);
+ VTSysreqToggle = FALSE;
+ return TRUE;
+ }
+ break;
+ /* Ignore these keys -- ie don't let them cancel an alt-sysreq */
+ case KEY_Alt:
+ case KEY_AltLang:
+ break;
+ case KEY_SysReqest:
+ if (!(ModifierSet(ShiftMask) || ModifierSet(ControlMask))) {
+ if ((ModifierSet(AltMask) || ModifierSet(AltLangMask)) && down)
+ VTSysreqToggle = TRUE;
+ }
+ break;
+ default:
+ /*
+ * We only land here when Alt-SysReq is followed by a
+ * non-switching key.
+ */
+ if (VTSysreqToggle)
+ VTSysreqToggle = FALSE;
+ }
+ }
+#endif /* USE_VT_SYSREQ */
+ return FALSE;
+}
+
+static void
+stdReadInput(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ unsigned char rBuf[64];
+ int nBytes, i;
+
+ if ((nBytes = read( pInfo->fd, (char *)rBuf, sizeof(rBuf))) > 0) {
+ for (i = 0; i < nBytes; i++) {
+ pKbd->PostEvent(pInfo, rBuf[i] & 0x7f, rBuf[i] & 0x80 ? FALSE : TRUE);
+ }
+ }
+}
+
+static Bool
+OpenKeyboard(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ int i;
+ KbdProtocolId prot = PROT_UNKNOWN_KBD;
+ char *s;
+
+ s = xf86SetStrOption(pInfo->options, "Protocol", NULL);
+ for (i = 0; protocols[i].name; i++) {
+ if (xf86NameCmp(s, protocols[i].name) == 0) {
+ prot = protocols[i].id;
+ break;
+ }
+ }
+
+ switch (prot) {
+ case PROT_STD:
+ pInfo->read_input = stdReadInput;
+ break;
+ default:
+ xf86Msg(X_ERROR,"\"%s\" is not a valid keyboard protocol name\n", s);
+ xfree(s);
+ return FALSE;
+ }
+
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, s);
+ xfree(s);
+
+ s = xf86SetStrOption(pInfo->options, "Device", NULL);
+ if (s == NULL) {
+ pInfo->fd = xf86Info.consoleFd;
+ pKbd->isConsole = TRUE;
+ } else {
+ pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL);
+ if (pInfo->fd == -1) {
+ xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s);
+ xfree(s);
+ return FALSE;
+ }
+ pKbd->isConsole = FALSE;
+ xfree(s);
+ }
+
+ if (pKbd->isConsole)
+ pKbd->vtSwitchSupported = TRUE;
+
+ return TRUE;
+}
+
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = pInfo->private;
+
+ pKbd->KbdInit = KbdInit;
+ pKbd->KbdOn = KbdOn;
+ pKbd->KbdOff = KbdOff;
+ pKbd->Bell = SoundBell;
+ pKbd->SetLeds = SetKbdLeds;
+ pKbd->GetLeds = GetKbdLeds;
+ pKbd->SetKbdRepeat = SetKbdRepeat;
+ pKbd->KbdGetMapping = KbdGetMapping;
+ pKbd->SpecialKey = SpecialKey;
+ pKbd->GetSpecialKey = GetSpecialKey;
+ pKbd->OpenKeyboard = OpenKeyboard;
+ pKbd->RemapScanCode = ATScancode;
+ pKbd->vtSwitchSupported = FALSE;
+
+ pKbd->private = xcalloc(sizeof(ScoKbdPrivRec), 1);
+ if (pKbd->private == NULL) {
+ xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_kbd.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_kbd.h
new file mode 100644
index 000000000..a79cd7bb9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_kbd.h
@@ -0,0 +1,20 @@
+/* $XFree86$ */
+#ifndef SCO_KBD_HDR
+#define SCO_KBD_HDR
+
+typedef struct {
+ int use_tcs;
+ int use_kd;
+ int no_nmap;
+ int no_emap;
+ int orig_getsc;
+ int orig_kbm;
+ struct termios kbdtty;
+ keymap_t keymap, noledmap;
+ uchar_t *sc_mapbuf;
+ uchar_t *sc_mapbuf2;
+} ScoKbdPrivRec, *ScoKbdPrivPtr;
+
+extern void KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms,
+ CARD8 *pModMap);
+#endif /* SCO_KBD_HDR */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_mouse.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_mouse.c
new file mode 100644
index 000000000..ea81c947d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_mouse.c
@@ -0,0 +1,261 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_mouse.c,v 3.12 2001/06/30 22:41:49 tsi Exp $ */
+/*
+ * Copyright 2001 by J. Kean Johnston <jkj@sco.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name J. Kean Johnston not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. J. Kean Johnston makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* $XConsortium$ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+#include "mipointer.h"
+#include <sys/event.h>
+#include <mouse.h>
+
+static int
+SupportedInterfaces (void)
+{
+ return MSE_MISC;
+}
+
+static const char *internalNames[] = {
+ "OSMouse",
+ NULL
+};
+
+static const char **
+BuiltinNames (void)
+{
+ return internalNames;
+}
+
+static Bool
+CheckProtocol (const char *protocol)
+{
+ int i;
+
+ for (i = 0; internalNames[i]; i++) {
+ if (xf86NameCmp (protocol, internalNames[i]) == 0)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static const char *
+DefaultProtocol (void)
+{
+ return "OSMouse";
+}
+
+static const char *
+evtErrStr (int evterr)
+{
+ switch (evterr) {
+ case -1: return "error in config files";
+ case -2: return "no mouse devices to attach";
+ case -3: return "unable to open device";
+ case -4: return "unable to open event queue";
+ case -999: return "unable to initialize event driver";
+ default: return "unknown event driver error";
+ }
+}
+
+static int
+OsMouseProc (DeviceIntPtr pPointer, int what)
+{
+ InputInfoPtr pInfo;
+ MouseDevPtr pMse;
+ unsigned char map[9];
+ dmask_t dmask;
+ MessageType from = X_CONFIG;
+ int evi;
+
+ pInfo = pPointer->public.devicePrivate;
+ pMse = pInfo->private;
+ pMse->device = pPointer;
+
+ switch (what) {
+ case DEVICE_INIT:
+ pPointer->public.on = FALSE;
+
+ dmask = D_ABS | D_REL | D_BUTTON;
+ if ((evi = ev_initf(xf86Info.consoleFd)) < 0) {
+ FatalError ("OsMouseProc: Event driver initialization failed (%s)\n",
+ evtErrStr(evi));
+ }
+ pInfo->fd = ev_open (&dmask);
+ if (pInfo->fd < 0) {
+ FatalError ("OsMouseProc: DEVICE_INIT failed (%s)\n", evtErrStr(pInfo->fd));
+ }
+
+ pMse->buttons = xf86SetIntOption (pInfo->options, "Buttons", 0);
+ if (pMse->buttons == 0) {
+ pMse->buttons = 8;
+ from = X_DEFAULT;
+ }
+ xf86Msg (from, "%s: Buttons: %d\n", pInfo->name, pMse->buttons);
+
+ for (evi = 0; evi <= 8; evi++)
+ map[evi] = evi;
+
+ InitPointerDeviceStruct((DevicePtr)pPointer, map, 8,
+ miPointerGetMotionEvents, pMse->Ctrl,
+ miPointerGetMotionBufferSize());
+
+ /* X valuator */
+ xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 0);
+
+ /* Y valuator */
+ xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 1);
+
+ xf86MotionHistoryAllocate(pInfo);
+
+ ev_flush();
+ ev_suspend();
+ break;
+
+ case DEVICE_ON:
+ pMse->lastButtons = 0;
+ pMse->lastMappedButtons = 0;
+ pMse->emulateState = 0;
+ pPointer->public.on = TRUE;
+ ev_resume();
+ AddEnabledDevice (pInfo->fd);
+ break;
+
+ case DEVICE_OFF:
+ case DEVICE_CLOSE:
+ pPointer->public.on = FALSE;
+ RemoveEnabledDevice (pInfo->fd);
+ if (what == DEVICE_CLOSE) {
+ ev_close();
+ pInfo->fd = -1;
+ } else {
+ ev_suspend();
+ }
+ break;
+ }
+
+ return Success;
+}
+
+static void
+OsMouseReadInput (InputInfoPtr pInfo)
+{
+ MouseDevPtr pMse;
+ EVENT *evp;
+
+ pMse = pInfo->private;
+
+ while ((evp = ev_read()) != (EVENT *)0) {
+ int buttons = EV_BUTTONS(*evp);
+ int dx = EV_DX(*evp), dy = -(EV_DY(*evp)), dz = 0;
+
+ if (buttons & WHEEL_FWD)
+ dz = -1;
+ else if (buttons & WHEEL_BACK)
+ dz = 1;
+
+ buttons &= ~(WHEEL_FWD | WHEEL_BACK);
+
+ pMse->PostEvent (pInfo, buttons, dx, dy, dz, 0);
+ ev_pop();
+ }
+}
+
+static Bool
+OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ MouseDevPtr pMse;
+
+ /* This is called when the protocol is "OSMouse". */
+
+ pMse = pInfo->private;
+ pMse->protocol = protocol;
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
+
+ /* Collect the options, and process the common options. */
+ xf86CollectInputOptions(pInfo, NULL, NULL);
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
+
+ /* Check if the device can be opened. */
+ pInfo->fd = ev_initf(xf86Info.consoleFd);
+ if (pInfo->fd != -1) {
+ dmask_t dmask = (D_ABS | D_REL | D_BUTTON);
+ pInfo->fd = ev_open(&dmask);
+ } else {
+ pInfo->fd = -999;
+ }
+
+ if (pInfo->fd < 0) {
+ if (xf86GetAllowMouseOpenFail())
+ xf86Msg(X_WARNING, "%s: cannot open event manager (%s)\n",
+ pInfo->name, evtErrStr(pInfo->fd));
+ else {
+ xf86Msg(X_ERROR, "%s: cannot open event manager (%s)\n",
+ pInfo->name, evtErrStr(pInfo->fd));
+ xfree(pMse);
+ return FALSE;
+ }
+ }
+ ev_close();
+ pInfo->fd = -1;
+
+ /* Process common mouse options (like Emulate3Buttons, etc). */
+ pMse->CommonOptions(pInfo);
+
+ /* Setup the local procs. */
+ pInfo->device_control = OsMouseProc;
+ pInfo->read_input = OsMouseReadInput;
+
+ pInfo->flags |= XI86_CONFIGURED;
+ return TRUE;
+}
+
+OSMouseInfoPtr
+xf86OSMouseInit (int flags)
+{
+ OSMouseInfoPtr p;
+
+ p = xcalloc(sizeof(OSMouseInfoRec), 1);
+ if (!p)
+ return NULL;
+
+ p->SupportedInterfaces = SupportedInterfaces;
+ p->BuiltinNames = BuiltinNames;
+ p->DefaultProtocol = DefaultProtocol;
+ p->CheckProtocol = CheckProtocol;
+ p->PreInit = OsMousePreInit;
+
+ return p;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_video.c
new file mode 100644
index 000000000..dd81786bb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_video.c
@@ -0,0 +1,296 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_video.c,v 3.8tsi Exp $ */
+/*
+ * Copyright 2001 by J. Kean Johnston <jkj@sco.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name J. Kean Johnston not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. J. Kean Johnston makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XConsortium$ */
+
+/* Re-written May 2001 to represent the current state of reality */
+
+/*
+ * This file contains the completely re-written SCO OpenServer video
+ * routines for XFree86 4.x. Much of this is based on the SCO X server
+ * code (which is an X11R5 server) and will probably only work on
+ * OpenServer versions 5.0.5, 5.0.6 and later. Please send me (jkj@sco.com)
+ * email if you have any questions.
+ *
+ * Ideally, you should use OSR5.0.6A or later, with the updated console
+ * driver for 5.0.6A (its the default driver in 5.0.7 and later).
+ * However, if you are running on an older system, this code will detect
+ * that and adjust accordingly.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#define _NEED_SYSI86
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86OSpriv.h"
+#include "xf86_OSlib.h"
+
+#include <sys/ci/ciioctl.h>
+#define MPXNAME "/dev/atp1"
+#define BASECPU 1
+
+Bool mpxLock = TRUE;
+
+#define USE_VASMETHOD 1
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+static int sco_mcdone = 0, sco_ismc = 0;
+
+/***************************************************************************/
+/*
+ * To map the video memory, we first need to see if we are on a multi-console
+ * system. If we are, we need to try to use an existing video class in the
+ * kernel. We do this by retrieving the list of currently defined classes
+ * (via the new CONS_GETCLASS ioctl()) to see if we have a class that will
+ * match the range of memory we desire. If we can't find one, we have an
+ * error and we abort.
+ *
+ * If we are not using a multi-console, we can simply use mmap() to map in
+ * the frame buffer, using the classs-access method as a fall-back only if
+ * the mmap() fails (it shouldn't). We always set the appropriate pointers
+ * in the config structure to point ot the right function to map and unmap
+ * the video memory. An alternative to using mmap() is to use the new
+ * CONS_ADDVAS call, which will use vasmalloc() and vasbind() in the kernel
+ * to map the physical address to a virtual one, which it then returns.
+ * I am not 100% sure if this is faster or not, but it may prove easier to
+ * debug things. Just to be on the safe side, I have included both methods
+ * here, and the mmap() method can be used by setting USE_VASMETHOD to 0
+ * above.
+ */
+
+#if !defined(CONS_ADDVAS)
+# undef USE_VASMETHOD
+# define USE_VASMETHOD 0
+#endif
+
+static int
+scoIsMultiConsole (void)
+{
+ int x;
+
+ if (sco_mcdone)
+ return sco_ismc;
+ x = access ("/usr/lib/vidconf/.multiconsole", F_OK);
+ if (x == 0)
+ sco_ismc = 1;
+ sco_mcdone = 1;
+ return sco_ismc;
+}
+
+/*
+ * This maps memory using mmap()
+ */
+static pointer
+mapVidMemMMAP(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ int fd;
+ unsigned long realBase, alignOff;
+ pointer base;
+
+ fd = open (DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
+ if (fd < 0) {
+ FatalError("xf86MapVidMem: failed to open %s (%s)\n", DEV_MEM,
+ strerror(errno));
+ return 0; /* NOTREACHED */
+ }
+
+ realBase = Base & ~(getpagesize() - 1);
+ alignOff = Base - realBase;
+
+#ifdef DEBUG
+ ErrorF("base: %lx, realBase: %lx, alignOff: %lx\n", Base,realBase,alignOff);
+#endif
+
+ base = mmap((caddr_t)0, Size + alignOff,
+ (flags & VIDMEM_READONLY) ? PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_SHARED, fd, (off_t)realBase);
+ close(fd);
+ if (base == MAP_FAILED) {
+ FatalError("xf86MapVidMem: Could not mmap framebuffer (0x%08x,0x%x) (%s)\n",
+ Base, Size, strerror(errno));
+ return 0; /* NOTREACHED */
+ }
+
+#ifdef DEBUG
+ ErrorF("base: %lx aligned base: %lx\n",base, base + alignOff);
+#endif
+ return (pointer)((char *)base + alignOff);
+}
+
+#if (USE_VASMETHOD)
+/*
+ * This maps memory using the virtual address space (VAS) console calls.
+ */
+static pointer
+mapVidMemVAS(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ struct vidvasmem vas;
+ pointer base;
+
+ vas.base = (long)Base;
+ vas.size = (long)Size;
+
+ base = (pointer)ioctl (xf86Info.consoleFd, CONS_ADDVAS, &vas);
+ if (base == (pointer)-1) {
+ return mapVidMemMMAP(ScreenNum, Base, Size, flags);
+ }
+ return base;
+}
+#endif /* USE_VASMETHOD */
+
+struct vidclass vidclasslist[] = {
+ { "VBE", "", 0xf0000000, 0x2000000, 0 },
+ { "P9000", "", 0xc0000000, 0x400000, 0 },
+ { "TULIP", "", 0x80000000, 0x400000, 0 },
+ { "VIPER", "", 0xa0000000, 0x400000, 0 },
+ { "S3T", "", 0xa0000000, 0x200000, 0 },
+ { "S3DT", "", 0x4000000, 0x400000, 0 },
+ { "MGA", "", 0x2200000, 0x4000, 0 },
+ { "CLVGA", "", 0xa0000, 0x20000, 0 },
+ { "OLIVE", "", 0xd8000000, 0x400000, 0 },
+ { "S3C", "", 0xa0000, 0x10000, 0 },
+ { "MGAVLB", "", 0xac000, 0x34000, 0 },
+ { "ATI8514", "", 0xFF000, 0x1000, 0 },
+ { "GXREGS", "", 0xb0000, 0x10000, 0 },
+ { "GX", "", 0xa0000, 0x10000, 0 },
+ { "CT64300", "", 0xa0000000, 0x400000, 0 },
+ { "SVGA", "", 0xa0000, 0x20000, 0 },
+ { "S3V", "", 0xa0000000, 0x400000, 0 },
+ { "8514A", "", 0xFF000, 0x1000, 0 },
+ { "VGA", "", 0xa0000, 0x10000, 0 },
+ { 0 }
+};
+
+static pointer
+mapVidMemVC(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ struct vidclass *vcp;
+ char *class = NULL;
+ pointer base;
+
+ for (vcp = vidclasslist; vcp->name; vcp++) {
+ if ((vcp->base == Base) && (vcp->size == Size)) {
+ class = vcp->name;
+ break;
+ }
+ }
+
+ if (class == NULL) {
+ /*
+ * As a fall-back, we will try and use the mmap() approach. This may
+ * prove to be the wrong thing to do, but time and testing will tell.
+ */
+ ErrorF("xf86MapVidMem: No class map defined for (0x%08x,0x%08x)\n", Base, Size);
+#if USE_VASMETHOD
+ return mapVidMemVAS(ScreenNum, Base, Size, flags);
+#else /* !USE_VASMETHOD */
+ return mapVidMemMMAP(ScreenNum, Base, Size, flags);
+#endif
+ }
+
+ /*
+ * We found a suitable class. Try and use it.
+ */
+ base = (pointer)ioctl(xf86Info.consoleFd, MAP_CLASS, class);
+ if ((int)base == -1) {
+ FatalError("xf86MapVidMem: Failed to map video memory class `%s'\n", class);
+ return 0; /* NOTREACHED */
+ }
+
+ return base;
+}
+
+/*
+ * Unmapping the video memory is easy. We always call munmap(), as it is
+ * safe to do so even if we haven't actually mapped in any pages via mmap().
+ * In the case where we used the video class, we don't need to do anything
+ * as the kernel will clean up the TSS when we exit, and will undo the
+ * vasbind() that was done when the class was originally mapped. If we used
+ * vasmap, we simply undo the map. Again, it is benign to call vasunmap
+ * even if we got the frame buffer via some other mechanism (like mmap).
+ */
+
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+#if USE_VASMETHOD
+ struct vidvasmem vas;
+ int x;
+
+ vas.base = (long)Base;
+ vas.size = (long)Size;
+
+ x = ioctl (xf86Info.consoleFd, CONS_DELVAS, &vas);
+ if (x == 0)
+ return;
+#endif /* USE_VASMETHOD */
+
+ munmap(Base, Size);
+}
+
+/*
+ * Set things up to point to our local functions. When the kernel gets
+ * MTRR support, we will need to add the required functions for that
+ * here too. MTRR support will most likely appear in 5.0.8 or 5.1.0.
+ *
+ * We also want to lock the X server process to the base CPU in an MPX
+ * system, since we will be going to IOPL 3. Most engine drivers can cope
+ * with I/O access on any CPU but there are a few (AST Manhattan I believe)
+ * that can't, so the server needs to be locked to CPU0.
+ */
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ int mpx_fd;
+
+ if (scoIsMultiConsole ()) {
+ pVidMem->mapMem = mapVidMemVC;
+ } else {
+#if USE_VASMETHOD
+ pVidMem->mapMem = mapVidMemVAS;
+#else
+ pVidMem->mapMem = mapVidMemMMAP;
+#endif
+ }
+
+ pVidMem->unmapMem = unmapVidMem;
+ pVidMem->linearSupported = TRUE;
+ pVidMem->initialised = TRUE;
+
+ if (mpxLock && (mpx_fd = open (MPXNAME, O_RDONLY)) > 0) {
+ if (ioctl (mpx_fd, ACPU_XLOCK, BASECPU) < 0)
+ ErrorF ("xf86OSInitVidMem: Can not bind to CPU 0 (%s)\n",
+ strerror(errno));
+ close (mpx_fd);
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/VTsw_noop.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/VTsw_noop.c
new file mode 100644
index 000000000..ac8ae3b0a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/VTsw_noop.c
@@ -0,0 +1,56 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_noop.c,v 3.1.4.1 1998/06/05 16:23:20 dawes Exp $ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@XFree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: VTsw_noop.c /main/3 1996/02/21 17:53:25 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+/*
+ * No-op functions for OSs without VTs
+ */
+
+Bool
+xf86VTSwitchPending()
+{
+ return(FALSE);
+}
+
+Bool
+xf86VTSwitchAway()
+{
+ return(FALSE);
+}
+
+Bool
+xf86VTSwitchTo()
+{
+ return(TRUE);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c
new file mode 100644
index 000000000..b38470aea
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c
@@ -0,0 +1,92 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c,v 3.1.4.1 1998/06/05 16:23:21 dawes Exp $ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@XFree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: VTsw_usl.c /main/3 1996/02/21 17:53:28 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#ifdef OSHEADER
+# include OSHEADER
+#endif
+
+/*
+ * Handle the VT-switching interface for OSs that use USL-style ioctl()s
+ * (the sysv, sco, and linux subdirs).
+ */
+
+/*
+ * This function is the signal handler for the VT-switching signal. It
+ * is only referenced inside the OS-support layer.
+ */
+void
+xf86VTRequest(int sig)
+{
+ signal(sig, (void(*)(int))xf86VTRequest);
+ xf86Info.vtRequestsPending = TRUE;
+ return;
+}
+
+Bool
+xf86VTSwitchPending()
+{
+ return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+}
+
+Bool
+xf86VTSwitchAway()
+{
+ xf86Info.vtRequestsPending = FALSE;
+ if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0)
+ {
+ return(FALSE);
+ }
+ else
+ {
+#ifdef OSSWITCHAWAY
+ OSSWITCHAWAY;
+#endif
+ return(TRUE);
+ }
+}
+
+Bool
+xf86VTSwitchTo()
+{
+ xf86Info.vtRequestsPending = FALSE;
+ if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
+ {
+ return(FALSE);
+ }
+ else
+ {
+ return(TRUE);
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/agp_noop.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/agp_noop.c
new file mode 100644
index 000000000..c13b29c38
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/agp_noop.c
@@ -0,0 +1,107 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/agp_noop.c,v 1.5 2003/08/24 17:37:05 dawes Exp $ */
+/*
+ * Copyright (c) 2000-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * Abstraction of the AGP GART interface. Stubs for platforms without
+ * AGP GART support.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef __UNIXOS2__
+# define I_NEED_OS2_H
+#endif
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+Bool
+xf86GARTCloseScreen(int screenNum)
+{
+ return FALSE;
+}
+
+Bool
+xf86AgpGARTSupported()
+{
+ return FALSE;
+}
+
+AgpInfoPtr
+xf86GetAGPInfo(int screenNum)
+{
+ return NULL;
+}
+
+Bool
+xf86AcquireGART(int screenNum)
+{
+ return FALSE;
+}
+
+Bool
+xf86ReleaseGART(int screenNum)
+{
+ return FALSE;
+}
+
+int
+xf86AllocateGARTMemory(int screenNum, unsigned long size, int type,
+ unsigned long *physical)
+{
+ return -1;
+}
+
+Bool
+xf86DeallocateGARTMemory(int screenNum, int key)
+{
+ return FALSE;
+}
+
+Bool
+xf86BindGARTMemory(int screenNum, int key, unsigned long offset)
+{
+ return FALSE;
+}
+
+
+Bool
+xf86UnbindGARTMemory(int screenNum, int key)
+{
+ return FALSE;
+}
+
+Bool
+xf86EnableAGP(int screenNum, CARD32 mode)
+{
+ return FALSE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/at_scancode.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/at_scancode.c
new file mode 100644
index 000000000..8947254bc
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/at_scancode.c
@@ -0,0 +1,132 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/at_scancode.c,v 1.4 2003/08/24 17:37:05 dawes Exp $ */
+/*
+ * Copyright (c) 2002-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Xinput.h"
+#include "xf86OSKbd.h"
+#include "atKeynames.h"
+
+Bool
+ATScancode(InputInfoPtr pInfo, int *scanCode)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+
+ switch (pKbd->scanPrefix) {
+ case 0:
+ switch (*scanCode) {
+ case KEY_Prefix0:
+ case KEY_Prefix1:
+ pKbd->scanPrefix = *scanCode; /* special prefixes */
+ return TRUE;
+ }
+ if (!xf86IsPc98()) {
+ switch (*scanCode) {
+ case 0x59: *scanCode = KEY_0x59; break;
+ case 0x5a: *scanCode = KEY_0x5A; break;
+ case 0x5b: *scanCode = KEY_0x5B; break;
+ case 0x5c: *scanCode = KEY_KP_Equal; break; /* Keypad Equal */
+ case 0x5d: *scanCode = KEY_0x5D; break;
+ case 0x5e: *scanCode = KEY_0x5E; break;
+ case 0x5f: *scanCode = KEY_0x5F; break;
+ case 0x62: *scanCode = KEY_0x62; break;
+ case 0x63: *scanCode = KEY_0x63; break;
+ case 0x64: *scanCode = KEY_0x64; break;
+ case 0x65: *scanCode = KEY_0x65; break;
+ case 0x66: *scanCode = KEY_0x66; break;
+ case 0x67: *scanCode = KEY_0x67; break;
+ case 0x68: *scanCode = KEY_0x68; break;
+ case 0x69: *scanCode = KEY_0x69; break;
+ case 0x6a: *scanCode = KEY_0x6A; break;
+ case 0x6b: *scanCode = KEY_0x6B; break;
+ case 0x6c: *scanCode = KEY_0x6C; break;
+ case 0x6d: *scanCode = KEY_0x6D; break;
+ case 0x6e: *scanCode = KEY_0x6E; break;
+ case 0x6f: *scanCode = KEY_0x6F; break;
+ case 0x70: *scanCode = KEY_0x70; break;
+ case 0x71: *scanCode = KEY_0x71; break;
+ case 0x72: *scanCode = KEY_0x72; break;
+ case 0x73: *scanCode = KEY_0x73; break;
+ case 0x74: *scanCode = KEY_0x74; break;
+ case 0x75: *scanCode = KEY_0x75; break;
+ case 0x76: *scanCode = KEY_0x76; break;
+ }
+ }
+ break;
+ case KEY_Prefix0:
+ pKbd->scanPrefix = 0;
+ switch (*scanCode) {
+ case KEY_KP_7: *scanCode = KEY_Home; break; /* curs home */
+ case KEY_KP_8: *scanCode = KEY_Up; break; /* curs up */
+ case KEY_KP_9: *scanCode = KEY_PgUp; break; /* curs pgup */
+ case KEY_KP_4: *scanCode = KEY_Left; break; /* curs left */
+ case KEY_KP_5: *scanCode = KEY_Begin; break; /* curs begin */
+ case KEY_KP_6: *scanCode = KEY_Right; break; /* curs right */
+ case KEY_KP_1: *scanCode = KEY_End; break; /* curs end */
+ case KEY_KP_2: *scanCode = KEY_Down; break; /* curs down */
+ case KEY_KP_3: *scanCode = KEY_PgDown; break; /* curs pgdown */
+ case KEY_KP_0: *scanCode = KEY_Insert; break; /* curs insert */
+ case KEY_KP_Decimal: *scanCode = KEY_Delete; break; /* curs delete */
+ case KEY_Enter: *scanCode = KEY_KP_Enter; break; /* keypad enter */
+ case KEY_LCtrl: *scanCode = KEY_RCtrl; break; /* right ctrl */
+ case KEY_KP_Multiply: *scanCode = KEY_Print; break; /* print */
+ case KEY_Slash: *scanCode = KEY_KP_Divide; break; /* keyp divide */
+ case KEY_Alt: *scanCode = KEY_AltLang; break; /* right alt */
+ case KEY_ScrollLock: *scanCode = KEY_Break; break; /* curs break */
+ case 0x5b: *scanCode = KEY_LMeta; break;
+ case 0x5c: *scanCode = KEY_RMeta; break;
+ case 0x5d: *scanCode = KEY_Menu; break;
+ case KEY_F3: *scanCode = KEY_F13; break;
+ case KEY_F4: *scanCode = KEY_F14; break;
+ case KEY_F5: *scanCode = KEY_F15; break;
+ case KEY_F6: *scanCode = KEY_F16; break;
+ case KEY_F7: *scanCode = KEY_F17; break;
+ case KEY_KP_Plus: *scanCode = KEY_KP_DEC; break;
+ case 0x2A:
+ case 0x36:
+ return TRUE;
+ default:
+ xf86MsgVerb(X_INFO, 4, "Unreported Prefix0 scancode: 0x%02x\n",
+ *scanCode);
+ *scanCode += 0x78;
+ }
+ break;
+ case KEY_Prefix1:
+ pKbd->scanPrefix = (*scanCode == KEY_LCtrl) ? KEY_LCtrl : 0;
+ return TRUE;
+ case KEY_LCtrl:
+ pKbd->scanPrefix = 0;
+ if (*scanCode != KEY_NumLock)
+ return TRUE;
+ *scanCode = KEY_Pause; /* pause */
+ }
+ return FALSE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c
new file mode 100644
index 000000000..8bd6d3f3e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c
@@ -0,0 +1,77 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c,v 3.5 1998/09/13 00:51:32 dawes Exp $ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: bios_devmem.c /main/5 1996/10/19 18:07:41 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include <string.h>
+
+/*
+ * Read BIOS via /dev/mem.
+ */
+
+#ifndef DEV_MEM
+# define DEV_MEM "/dev/mem"
+#endif
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ int fd;
+
+#ifdef __ia64__
+ if ((fd = open(DEV_MEM, O_RDONLY | O_SYNC)) < 0)
+#else
+ if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
+#endif
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ return(-1);
+ }
+
+ if (lseek(fd, (Base+Offset), SEEK_SET) < 0)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: %s seek failed (%s)\n",
+ DEV_MEM, strerror(errno));
+ close(fd);
+ return(-1);
+ }
+ if (read(fd, Buf, Len) != Len)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: %s read failed (%s)\n",
+ DEV_MEM, strerror(errno));
+ close(fd);
+ return(-1);
+ }
+ close(fd);
+ return(Len);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/bios_mmap.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/bios_mmap.c
new file mode 100644
index 000000000..b4ff8c31f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/bios_mmap.c
@@ -0,0 +1,164 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/bios_mmap.c,v 1.8 2000/11/19 16:38:06 tsi Exp $ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: bios_V4mmap.c /main/4 1996/02/21 17:54:27 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+/*
+ * Read BIOS via mmap()ing DEV_MEM
+ */
+
+#ifndef __alpha__
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ int fd;
+ unsigned char *ptr;
+ int psize;
+ int mlen;
+
+ if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ return(-1);
+ }
+ psize = xf86getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
+ MAP_SHARED, fd, (off_t)Base);
+ if (ptr == MAP_FAILED)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed (%s)\n",
+ DEV_MEM, strerror(errno));
+ close(fd);
+ return(-1);
+ }
+#ifdef DEBUG
+ ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
+ Base, ptr[0] | (ptr[1] << 8));
+#endif
+ (void)memcpy(Buf, (void *)(ptr + Offset), Len);
+ (void)munmap((caddr_t)ptr, mlen);
+ (void)close(fd);
+ return(Len);
+}
+
+#else /* __alpha__ */
+
+ /*
+ * We trick "mmap" into mapping BUS memory for us via BUS_BASE,
+ * which is the KSEG address of the start of the DENSE memory
+ * area.
+ */
+
+ /*
+ * NOTE: there prolly ought to be more validity checks and all
+ * re: boundaries and sizes and such...
+ */
+
+/*
+ * The Jensen lacks dense memory, thus we have to address the bus via
+ * the sparse addressing scheme.
+ *
+ * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996
+ */
+
+#ifdef linux
+
+#ifdef TEST_JENSEN_CODE /* define to test the Sparse addressing on a non-Jensen */
+#define SPARSE (5)
+#define isJensen (1)
+#else
+#define isJensen (!_bus_base())
+#define SPARSE (7)
+#endif
+
+extern unsigned long _bus_base(void);
+extern unsigned long _bus_base_sparse(void);
+#define BUS_BASE (isJensen ? _bus_base_sparse() : _bus_base())
+#define JENSEN_SHIFT(x) (isJensen ? ((long)x<<SPARSE) : (long)x)
+
+#else
+
+extern u_int64_t dense_base(void);
+#define BUS_BASE dense_base()
+#define JENSEN_SHIFT(x) ((long) x)
+
+#endif
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ caddr_t base;
+ int fd;
+ int psize;
+ int mlen;
+
+ if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ return(-1);
+ }
+
+ psize = xf86getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ base = mmap((caddr_t)0, JENSEN_SHIFT(mlen), PROT_READ,
+ MAP_SHARED, fd, (off_t)(JENSEN_SHIFT(Base) + BUS_BASE));
+
+ if (base == MAP_FAILED)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ return(-1);
+ }
+
+ xf86SlowBCopyFromBus((unsigned char *)(base+JENSEN_SHIFT(Offset)),
+ Buf, Len);
+
+ munmap((caddr_t)JENSEN_SHIFT(base), JENSEN_SHIFT(mlen));
+ close(fd);
+ return(Len);
+}
+
+#endif /* __alpha__ */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/ia64Pci.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/ia64Pci.c
new file mode 100644
index 000000000..ff4312bf5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/ia64Pci.c
@@ -0,0 +1,244 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/ia64Pci.c,v 1.3 2003/02/23 20:26:49 tsi Exp $ */
+/*
+ * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+/*
+ * This file contains the glue needed to support various IA-64 chipsets.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <signal.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <linux/pci.h>
+
+#include "compiler.h"
+#include "460gxPCI.h"
+#include "e8870PCI.h"
+#include "zx1PCI.h"
+#include "altixPCI.h"
+#include "Pci.h"
+#include "ia64Pci.h"
+
+/*
+ * We use special in/out routines here since Altix platforms require the
+ * use of the sysfs legacy_io interface. The legacy_io file maps to the I/O
+ * space of a given PCI domain; reads and writes are used to do port I/O.
+ * The file descriptor for the file is stored in the upper bits of the
+ * value passed in by the caller, and is created and populated by
+ * xf86MapDomainIO.
+ *
+ * If the legacy_io interface doesn't exist, we fall back to the glibc in/out
+ * routines, which are prefixed by an underscore (e.g. _outb).
+ */
+static int ia64_port_to_fd(unsigned long port)
+{
+ return (port >> 24) & 0xffffffff;
+}
+
+void outb(unsigned long port, unsigned char val)
+{
+ int fd = ia64_port_to_fd(port);
+
+ if (!fd) {
+ _outb(val, port & 0xffff);
+ goto out;
+ }
+ if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
+ ErrorF("I/O lseek failed\n");
+ goto out;
+ }
+ if (write(fd, &val, 1) != 1) {
+ ErrorF("I/O write failed\n");
+ goto out;
+ }
+ out:
+ return;
+}
+
+void outw(unsigned long port, unsigned short val)
+{
+ int fd = ia64_port_to_fd(port);
+
+ if (!fd) {
+ _outw(val, port & 0xffff);
+ goto out;
+ }
+ if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
+ ErrorF("I/O lseek failed\n");
+ goto out;
+ }
+ if (write(fd, &val, 2) != 2) {
+ ErrorF("I/O write failed\n");
+ goto out;
+ }
+ out:
+ return;
+}
+
+void outl(unsigned long port, unsigned int val)
+{
+ int fd = ia64_port_to_fd(port);
+
+ if (!fd) {
+ _outl(val, port & 0xffff);
+ goto out;
+ }
+ if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
+ ErrorF("I/O lseek failed\n");
+ goto out;
+ }
+ if (write(fd, &val, 4) != 4) {
+ ErrorF("I/O write failed\n");
+ goto out;
+ }
+ out:
+ return;
+}
+
+unsigned int inb(unsigned long port)
+{
+ int fd = ia64_port_to_fd(port);
+ unsigned char val;
+
+ if (!fd)
+ return _inb(port & 0xffff);
+
+ if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
+ ErrorF("I/O lseek failed\n");
+ val = -1;
+ goto out;
+ }
+ if (read(fd, &val, 1) != 1) {
+ ErrorF("I/O read failed\n");
+ val = -1;
+ goto out;
+ }
+ out:
+ return val;
+}
+
+unsigned int inw(unsigned long port)
+{
+ int fd = ia64_port_to_fd(port);
+ unsigned short val;
+
+ if (!fd)
+ return _inw(port & 0xffff);
+
+ if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
+ ErrorF("I/O lseek failed\n");
+ val = -1;
+ goto out;
+ }
+ if (read(fd, &val, 2) != 2) {
+ ErrorF("I/O read failed\n");
+ val = -1;
+ goto out;
+ }
+ out:
+ return val;
+}
+
+unsigned int inl(unsigned long port)
+{
+ int fd = ia64_port_to_fd(port);
+ unsigned int val;
+
+ if (!fd)
+ return _inl(port & 0xffff);
+
+ if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
+ ErrorF("I/O lseek failed\n");
+ val = -1;
+ goto out;
+ }
+ if (read(fd, &val, 4) != 4) {
+ ErrorF("I/O read failed\n");
+ val = -1;
+ goto out;
+ }
+ out:
+ return val;
+}
+
+void
+ia64ScanPCIWrapper(scanpciWrapperOpt flags)
+{
+ static IA64Chipset chipset = NONE_CHIPSET;
+
+ if (flags == SCANPCI_INIT) {
+
+ /* PCI configuration space probes should be done first */
+ if (xorgProbe460GX(flags)) {
+ chipset = I460GX_CHIPSET;
+ xf86PreScan460GX();
+ return;
+ } else if (xorgProbeE8870(flags)) {
+ chipset = E8870_CHIPSET;
+ xf86PreScanE8870();
+ return;
+ }
+#ifdef OS_PROBE_PCI_CHIPSET
+ chipset = OS_PROBE_PCI_CHIPSET(flags);
+ switch (chipset) {
+ case ZX1_CHIPSET:
+ xf86PreScanZX1();
+ return;
+ case ALTIX_CHIPSET:
+ xf86PreScanAltix();
+ return;
+ default:
+ return;
+ }
+#endif
+ } else /* if (flags == SCANPCI_TERM) */ {
+
+ switch (chipset) {
+ case I460GX_CHIPSET:
+ xf86PostScan460GX();
+ return;
+ case E8870_CHIPSET:
+ xf86PostScanE8870();
+ return;
+ case ZX1_CHIPSET:
+ xf86PostScanZX1();
+ return;
+ case ALTIX_CHIPSET:
+ xf86PostScanAltix();
+ return;
+ default:
+ return;
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/ia64Pci.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/ia64Pci.h
new file mode 100644
index 000000000..978c9ff0e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/ia64Pci.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2004, Egbert Eich
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * EGBERT EICH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+ * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Egbert Eich shall not
+ * be used in advertising or otherwise to promote the sale, use or other deal-
+ *ings in this Software without prior written authorization from Egbert Eich.
+ *
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _IA64_PCI_H
+# define _IA64_PCI_H
+
+#include "Pci.h"
+
+typedef enum {
+ NONE_CHIPSET,
+ I460GX_CHIPSET,
+ E8870_CHIPSET,
+ ZX1_CHIPSET,
+ ALTIX_CHIPSET
+} IA64Chipset;
+
+# ifdef OS_PROBE_PCI_CHIPSET
+extern IA64Chipset OS_PROBE_PCI_CHIPSET(scanpciWrapperOpt flags);
+# endif
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/inout.S b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/inout.S
new file mode 100644
index 000000000..73a2cbbb6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/inout.S
@@ -0,0 +1,111 @@
+/* $XConsortium: inout.s /main/6 1996/02/21 17:53:35 kaleb $ */
+
+
+
+
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/inout.s,v 3.5 1996/12/23 06:50:58 dawes Exp $ */
+
+#include "assyntax.h"
+
+/*
+ * Make i80386 io primitives available at C-level.
+ */
+
+ FILE("inout.s")
+ AS_BEGIN
+ SEG_TEXT
+
+/*
+ *-----------------------------------------------------------------------
+ * inb ---
+ * Input one byte.
+ *
+ * Results:
+ * Byte in al.
+ *-----------------------------------------------------------------------
+ */
+ GLOBL GLNAME(inb)
+GLNAME(inb):
+ MOV_L (REGOFF(4,ESP),EDX)
+ SUB_L (EAX,EAX)
+ IN_B
+ RET
+
+/*
+ *-----------------------------------------------------------------------
+ * outb ---
+ * Output one byte.
+ *
+ * Results:
+ * None.
+ *-----------------------------------------------------------------------
+ */
+ GLOBL GLNAME(outb)
+GLNAME(outb):
+ MOV_L (REGOFF(4,sp),EDX)
+ MOV_L (REGOFF(8,sp),EAX)
+ OUT_B
+ RET
+/*
+ *-----------------------------------------------------------------------
+ * inw ---
+ * Input one 16-bit word.
+ *
+ * Results:
+ * Word in ax.
+ *-----------------------------------------------------------------------
+ */
+ GLOBL GLNAME(inw)
+GLNAME(inw):
+ MOV_L (REGOFF(4,ESP),EDX)
+ IN_W
+ RET
+
+/*
+ *-----------------------------------------------------------------------
+ * outw ---
+ * Output one 16-bit word.
+ *
+ * Results:
+ * None.
+ *-----------------------------------------------------------------------
+ */
+ GLOBL GLNAME(outw)
+GLNAME(outw):
+ MOV_L (REGOFF(4,ESP),EDX)
+ MOV_L (REGOFF(8,ESP),EAX)
+ OUT_W
+ RET
+
+/*
+ *-----------------------------------------------------------------------
+ * inl ---
+ * Input one 32-bit longword.
+ *
+ * Results:
+ * Word in eax.
+ *-----------------------------------------------------------------------
+ */
+ GLOBL GLNAME(inl)
+GLNAME(inl):
+ MOV_L (REGOFF(4,ESP),EDX)
+ IN_L
+ RET
+
+/*
+ *-----------------------------------------------------------------------
+ * outl ---
+ * Output one 32-bit longword.
+ *
+ * Results:
+ * None.
+ *-----------------------------------------------------------------------
+ */
+ GLOBL GLNAME(outl)
+GLNAME(outl):
+ MOV_L (REGOFF(4,ESP),EDX)
+ MOV_L (REGOFF(8,ESP),EAX)
+ OUT_L
+ RET
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/ioperm_noop.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/ioperm_noop.c
new file mode 100644
index 000000000..b3ea044f9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/ioperm_noop.c
@@ -0,0 +1,51 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/ioperm_noop.c,v 3.3 1998/07/25 16:57:00 dawes Exp $ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@XFree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: ioperm_noop.c /main/3 1996/02/21 17:53:39 kaleb $ */
+
+/*
+ * Some platforms don't bother with I/O permissions,
+ * or the permissions are implicit with opening/enabling the console.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+Bool
+xf86EnableIO()
+{
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ return;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/kbd.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/kbd.c
new file mode 100644
index 000000000..822c8fe52
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/kbd.c
@@ -0,0 +1,39 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/kbd.c,v 1.3 2003/08/24 17:37:05 dawes Exp $ */
+/*
+ * Copyright (c) 2001-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86OSKbd.h"
+
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+ return FALSE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/kmod_noop.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/kmod_noop.c
new file mode 100644
index 000000000..620e9bf35
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/kmod_noop.c
@@ -0,0 +1,39 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/kmod_noop.c,v 1.2 2003/08/24 17:37:05 dawes Exp $ */
+/*
+ * Copyright (c) 2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86_OSproc.h"
+
+int xf86LoadKernelModule(const char *pathname)
+{
+ (void) pathname;
+ return 0; /* failure */
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c
new file mode 100644
index 000000000..aba445945
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c
@@ -0,0 +1,2153 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c,v 1.102 2003/11/19 03:52:58 dawes Exp $ */
+/*
+ * Copyright 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Orest Zborowski and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Orest Zborowski
+ * and David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THE XFREE86 PROJECT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT BE LIABLE
+ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#if defined(linux) && !defined(__GLIBC__)
+#undef __STRICT_ANSI__
+#endif
+#include <X11/X.h>
+#ifdef __UNIXOS2__
+#define I_NEED_OS2_H
+#endif
+#include <X11/Xmd.h>
+#include <X11/Xos.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#if defined(__bsdi__)
+#undef _POSIX_SOURCE
+#undef _ANSI_SOURCE
+#endif
+#include <sys/time.h>
+#include <math.h>
+#ifdef sun
+#include <ieeefp.h>
+#endif
+#include <stdarg.h>
+#include <fcntl.h>
+#include <X11/Xfuncproto.h>
+#include "os.h"
+#include <ctype.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+#include <sys/ioctl.h>
+#ifdef __UNIXOS2__
+#define NO_MMAP
+#include <sys/param.h>
+#endif
+#ifdef HAS_SVR3_MMAPDRV
+#define NO_MMAP
+#ifdef SELF_CONTAINED_WRAPPER
+#include <sys/at_ansi.h>
+#include <sys/kd.h>
+#include <sys/sysmacros.h>
+#if !defined(_NEED_SYSI86)
+# include <sys/immu.h>
+# include <sys/region.h>
+#endif
+#include <sys/mmap.h>
+struct kd_memloc MapDSC;
+int mmapFd = -2;
+#else
+extern struct kd_memloc MapDSC;
+extern int mmapFd;
+#endif
+#endif
+#ifndef NO_MMAP
+#include <sys/mman.h>
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)-1)
+#endif
+#endif
+#if !defined(ISC)
+#include <stdlib.h>
+#endif
+
+#define NEED_XF86_TYPES
+#define NEED_XF86_PROTOTYPES
+#define DONT_DEFINE_WRAPPERS
+#include "xf86_ansic.h"
+
+#ifndef SELF_CONTAINED_WRAPPER
+#include "xf86.h"
+#include "xf86Priv.h"
+#define NO_OSLIB_PROTOTYPES
+#define XF86_OS_PRIVS
+#define HAVE_WRAPPER_DECLS
+#include "xf86_OSlib.h"
+#else
+void xf86WrapperInit(void);
+#endif
+
+
+#ifndef X_NOT_POSIX
+#include <dirent.h>
+#else
+#ifdef SYSV
+#include <dirent.h>
+#else
+#ifdef USG
+#include <dirent.h>
+#else
+#include <sys/dir.h>
+#ifndef dirent
+#define dirent direct
+#endif
+#endif
+#endif
+#endif
+typedef struct dirent DIRENTRY;
+
+#ifdef __UNIXOS2__
+#define _POSIX_SOURCE
+#endif
+#ifdef ISC202
+#include <sys/types.h>
+#define WIFEXITED(a) ((a & 0x00ff) == 0) /* LSB will be 0 */
+#define WEXITSTATUS(a) ((a & 0xff00) >> 8)
+#define WIFSIGNALED(a) ((a & 0xff00) == 0) /* MSB will be 0 */
+#define WTERMSIG(a) (a & 0x00ff)
+#else
+#if defined(ISC) && !defined(_POSIX_SOURCE)
+#define _POSIX_SOURCE
+#include <sys/types.h>
+#include <sys/wait.h>
+#undef _POSIX_SOURCE
+#else
+#if (defined(ISC) && defined(_POSIX_SOURCE)) || defined(Lynx) || (defined (__alpha__) && defined(linux))
+#include <sys/types.h>
+#endif
+#include <sys/wait.h>
+#endif
+#endif
+#ifdef Lynx
+#if !defined(S_IFIFO) && defined(S_IFFIFO)
+#define S_IFIFO S_IFFIFO
+#endif
+#endif
+
+/* For xf86getpagesize() */
+#if defined(linux)
+#define HAS_SC_PAGESIZE
+#define HAS_GETPAGESIZE
+#elif defined(CSRG_BASED)
+#define HAS_GETPAGESIZE
+#elif defined(DGUX)
+#define HAS_GETPAGESIZE
+#elif defined(sun) && !defined(SVR4)
+#define HAS_GETPAGESIZE
+#endif
+#ifdef XNO_SYSCONF
+#undef _SC_PAGESIZE
+#endif
+#ifdef HAVE_SYSV_IPC
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#endif
+#include <setjmp.h>
+
+#if defined(setjmp) && defined(__GNU_LIBRARY__) && \
+ (!defined(__GLIBC__) || (__GLIBC__ < 2) || \
+ ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 3)))
+#define HAS_GLIBC_SIGSETJMP 1
+#endif
+
+#if 0
+#define SETBUF_RETURNS_INT
+#endif
+
+double xf86HUGE_VAL;
+
+#ifndef SELF_CONTAINED_WRAPPERS
+extern void xf86DisableIO(void);
+#endif
+
+/*
+ * This file contains the XFree86 wrappers for libc functions that can be
+ * called by loadable modules
+ */
+
+double
+xf86hypot(double x, double y)
+{
+ return(hypot(x,y));
+}
+
+void
+xf86qsort(void *base, xf86size_t nmemb, xf86size_t size,
+ int (*comp)(const void *, const void *))
+{
+ qsort(base, nmemb, size, comp);
+}
+
+/* string functions */
+
+char*
+xf86strcat(char* dest, const char* src)
+{
+ return(strcat(dest,src));
+}
+
+char*
+xf86strchr(const char* s, int c)
+{
+ return strchr(s,c);
+}
+
+int
+xf86strcmp(const char* s1, const char* s2)
+{
+ return strcmp(s1,s2);
+}
+
+/* Just like the BSD version. It assumes that tolower() is ANSI-compliant */
+int
+xf86strcasecmp(const char* s1, const char* s2)
+{
+ const unsigned char *us1 = (const unsigned char *)s1;
+ const unsigned char *us2 = (const unsigned char *)s2;
+
+ while (tolower(*us1) == tolower(*us2++))
+ if (*us1++ == '\0')
+ return 0;
+
+ return tolower(*us1) - tolower(*--us2);
+}
+
+char*
+xf86strcpy(char* dest, const char* src)
+{
+ return strcpy(dest,src);
+}
+
+xf86size_t
+xf86strcspn(const char* s1, const char* s2)
+{
+ return (xf86size_t)strcspn(s1,s2);
+}
+
+xf86size_t
+xf86strlen(const char* s)
+{
+ return (xf86size_t)strlen(s);
+}
+
+xf86size_t
+xf86strlcat(char *dest, const char *src, xf86size_t size)
+{
+ return(strlcat(dest, src, size));
+}
+
+xf86size_t
+xf86strlcpy(char *dest, const char *src, xf86size_t size)
+{
+ return strlcpy(dest, src, size);
+}
+
+char*
+xf86strncat(char* dest, const char* src, xf86size_t n)
+{
+ return strncat(dest,src,(size_t)n);
+}
+
+int
+xf86strncmp(const char* s1, const char* s2, xf86size_t n)
+{
+ return strncmp(s1,s2,(size_t)n);
+}
+
+/* Just like the BSD version. It assumes that tolower() is ANSI-compliant */
+int
+xf86strncasecmp(const char* s1, const char* s2, xf86size_t n)
+{
+ if (n != 0) {
+ const unsigned char *us1 = (const unsigned char *)s1;
+ const unsigned char *us2 = (const unsigned char *)s2;
+
+ do {
+ if (tolower(*us1) != tolower(*us2++))
+ return tolower(*us1) - tolower(*--us2);
+ if (*us1++ == '\0')
+ break;
+ } while (--n != 0);
+ }
+ return 0;
+}
+
+char*
+xf86strncpy(char* dest, const char* src, xf86size_t n)
+{
+ return strncpy(dest,src,(size_t)n);
+}
+
+char*
+xf86strpbrk(const char* s1, const char* s2)
+{
+ return strpbrk(s1,s2);
+}
+
+char*
+xf86strrchr(const char* s, int c)
+{
+ return strrchr(s,c);
+}
+
+xf86size_t
+xf86strspn(const char* s1, const char* s2)
+{
+ return strspn(s1,s2);
+}
+
+char*
+xf86strstr(const char* s1, const char* s2)
+{
+ return strstr(s1,s2);
+}
+
+char*
+xf86strtok(char* s1, const char* s2)
+{
+ return strtok(s1,s2);
+}
+
+char*
+xf86strdup(const char* s)
+{
+ return xstrdup(s);
+}
+
+int
+xf86sprintf(char *s, const char *format, ...)
+{
+ int ret;
+ va_list args;
+ va_start(args, format);
+ ret = vsprintf(s, format, args);
+ va_end(args);
+ return ret;
+}
+
+int
+xf86snprintf(char *s, xf86size_t len, const char *format, ...)
+{
+ int ret;
+ va_list args;
+ va_start(args, format);
+ ret = vsnprintf(s, (size_t)len, format, args);
+ va_end(args);
+ return ret;
+}
+
+void
+xf86bzero(void* s, unsigned int n)
+{
+ memset(s, 0, n);
+}
+
+#ifdef HAVE_VSSCANF
+int
+xf86sscanf(char *s, const char *format, ...)
+#else
+int
+xf86sscanf(char *s, const char *format, char *a0, char *a1, char *a2,
+ char *a3, char *a4, char *a5, char *a6, char *a7, char *a8,
+ char *a9) /* limit of ten args */
+#endif
+{
+#ifdef HAVE_VSSCANF
+ int ret;
+ va_list args;
+ va_start(args, format);
+
+ ret = vsscanf(s,format,args);
+ va_end(args);
+ return ret;
+#else
+ return sscanf(s, format, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
+#endif
+}
+
+/* Basic I/O */
+
+int xf86errno;
+
+/* XXX This is not complete */
+
+static int
+xfToOsOpenFlags(int xfflags)
+{
+ int flags = 0;
+
+ /* XXX This assumes O_RDONLY is 0 */
+ if (xfflags & XF86_O_WRONLY)
+ flags |= O_WRONLY;
+ if (xfflags & XF86_O_RDWR)
+ flags |= O_RDWR;
+ if (xfflags & XF86_O_CREAT)
+ flags |= O_CREAT;
+
+ return flags;
+}
+
+int
+xf86open(const char *path, int flags, ...)
+{
+ int fd;
+ va_list ap;
+
+ va_start(ap, flags);
+ flags = xfToOsOpenFlags(flags);
+ if (flags & O_CREAT) {
+ /* can't request a mode_t directly on systems where mode_t
+ is an unsigned short */
+ mode_t mode = (mode_t)va_arg(ap, unsigned int);
+ fd = open(path, flags, mode);
+ } else {
+ fd = open(path, flags);
+ }
+ va_end(ap);
+ xf86errno = xf86GetErrno();
+
+ return fd;
+}
+
+int
+xf86close(int fd)
+{
+ int status = close(fd);
+
+ xf86errno = xf86GetErrno();
+ return status;
+}
+
+long
+xf86lseek(int fd, long offset, int whence)
+{
+ switch (whence) {
+ case XF86_SEEK_SET:
+ whence = SEEK_SET;
+ break;
+ case XF86_SEEK_CUR:
+ whence = SEEK_CUR;
+ break;
+ case XF86_SEEK_END:
+ whence = SEEK_END;
+ break;
+ }
+ return (long)lseek(fd, (off_t)offset, whence);
+}
+
+int
+xf86ioctl(int fd, unsigned long request, pointer argp)
+{
+ int status = ioctl(fd, request, argp);
+
+ xf86errno = xf86GetErrno();
+ return status;
+}
+
+xf86ssize_t
+xf86read(int fd, void *buf, xf86size_t nbytes)
+{
+ xf86ssize_t n = read(fd, buf, (size_t)nbytes);
+
+ xf86errno = xf86GetErrno();
+ return n;
+}
+
+xf86ssize_t
+xf86write(int fd, const void *buf, xf86size_t nbytes)
+{
+ xf86ssize_t n = write(fd, buf, (size_t)nbytes);
+
+ xf86errno = xf86GetErrno();
+ return n;
+}
+
+void*
+xf86mmap(void *start, xf86size_t length, int prot,
+ int flags, int fd, xf86size_t /* off_t */ offset)
+{
+#ifndef NO_MMAP
+ int p=0, f=0;
+ void *rc;
+
+ if (flags & XF86_MAP_FIXED) f |= MAP_FIXED;
+ if (flags & XF86_MAP_SHARED) f |= MAP_SHARED;
+ if (flags & XF86_MAP_PRIVATE) f |= MAP_PRIVATE;
+#if defined(__amd64__) && defined(linux)
+ if (flags & XF86_MAP_32BIT) f |= MAP_32BIT;
+#endif
+ if (prot & XF86_PROT_EXEC) p |= PROT_EXEC;
+ if (prot & XF86_PROT_READ) p |= PROT_READ;
+ if (prot & XF86_PROT_WRITE) p |= PROT_WRITE;
+ if (prot & XF86_PROT_NONE) p |= PROT_NONE;
+
+ rc = mmap(start,(size_t)length,p,f,fd,(off_t)offset);
+
+ xf86errno = xf86GetErrno();
+ if (rc == MAP_FAILED)
+ return XF86_MAP_FAILED;
+ else
+ return rc;
+#else
+#ifdef HAS_SVR3_MMAPDRV
+ void *rc;
+#ifdef SELF_CONTAINED_WRAPPER
+ if(mmapFd < 0) {
+ if ((mmapFd = open("/dev/mmap", O_RDWR)) == -1) {
+ ErrorF("Warning: failed to open /dev/mmap \n");
+ xf86errno = xf86_ENOSYS;
+ return XF86_MAP_FAILED;
+ }
+ }
+#endif
+ MapDSC.vaddr = (char *)start;
+ MapDSC.physaddr = (char *)offset;
+ MapDSC.length = length;
+ MapDSC.ioflg = 1;
+
+ rc = (pointer)ioctl(mmapFd, MAP, &MapDSC);
+ xf86errno = xf86GetErrno();
+ if (rc == NULL)
+ return XF86_MAP_FAILED;
+ else
+ return rc;
+#else
+ ErrorF("Warning: mmap() is not supported on this platform\n");
+ xf86errno = xf86_ENOSYS;
+ return XF86_MAP_FAILED;
+#endif
+#endif
+}
+
+int
+xf86munmap(void *start, xf86size_t length)
+{
+#ifndef NO_MMAP
+ int rc = munmap(start,(size_t)length);
+
+ xf86errno = xf86GetErrno();
+ return rc;
+#else
+#ifdef HAS_SVR3_MMAPDRV
+ int rc = ioctl(mmapFd, UNMAPRM , start);
+
+ xf86errno = xf86GetErrno();
+ return rc;
+#else
+ ErrorF("Warning: munmap() is not supported on this platform\n");
+ xf86errno = xf86_ENOSYS;
+ return -1;
+#endif
+#endif
+}
+
+int
+xf86stat(const char *file_name, struct xf86stat *xfst)
+{
+ int rc;
+ struct stat st;
+
+ rc = stat(file_name, &st);
+ xf86errno = xf86GetErrno();
+ xfst->st_rdev = st.st_rdev; /* Not much is currently supported */
+ return rc;
+}
+
+int
+xf86fstat(int fd, struct xf86stat *xfst)
+{
+ int rc;
+ struct stat st;
+
+ rc = fstat(fd, &st);
+ xf86errno = xf86GetErrno();
+ xfst->st_rdev = st.st_rdev; /* Not much is currently supported */
+ return rc;
+}
+
+static int
+xfToOsAccessMode(int xfmode)
+{
+ switch(xfmode) {
+ case XF86_R_OK: return R_OK;
+ case XF86_W_OK: return W_OK;
+ case XF86_X_OK: return X_OK;
+ case XF86_F_OK: return F_OK;
+ }
+ return 0;
+}
+
+int
+xf86access(const char *pathname, int mode)
+{
+ int rc;
+
+ mode = xfToOsAccessMode(mode);
+ rc = access(pathname, mode);
+ xf86errno = xf86GetErrno();
+ return rc;
+}
+
+
+
+/* limited stdio support */
+
+#define XF86FILE_magic 0x58464856 /* "XFHV" */
+
+typedef struct _xf86_file_ {
+ INT32 fileno;
+ INT32 magic;
+ FILE* filehnd;
+ char* fname;
+} XF86FILE_priv;
+
+XF86FILE_priv stdhnd[3] = {
+ { 0, XF86FILE_magic, NULL, "$stdinp$" },
+ { 0, XF86FILE_magic, NULL, "$stdout$" },
+ { 0, XF86FILE_magic, NULL, "$stderr$" }
+};
+
+XF86FILE* xf86stdin = (XF86FILE*)&stdhnd[0];
+XF86FILE* xf86stdout = (XF86FILE*)&stdhnd[1];
+XF86FILE* xf86stderr = (XF86FILE*)&stdhnd[2];
+
+void
+xf86WrapperInit()
+{
+ if (stdhnd[0].filehnd == NULL)
+ stdhnd[0].filehnd = stdin;
+ if (stdhnd[1].filehnd == NULL)
+ stdhnd[1].filehnd = stdout;
+ if (stdhnd[2].filehnd == NULL)
+ stdhnd[2].filehnd = stderr;
+ xf86HUGE_VAL = HUGE_VAL;
+}
+
+XF86FILE*
+xf86fopen(const char* fn, const char* mode)
+{
+ XF86FILE_priv* fp;
+ FILE *f = fopen(fn,mode);
+ xf86errno = xf86GetErrno();
+ if (!f) return 0;
+
+ fp = xalloc(sizeof(XF86FILE_priv));
+ fp->magic = XF86FILE_magic;
+ fp->filehnd = f;
+ fp->fileno = fileno(f);
+ fp->fname = xf86strdup(fn);
+#ifdef DEBUG
+ ErrorF("xf86fopen(%s,%s) yields FILE %p XF86FILE %p\n",
+ fn,mode,f,fp);
+#endif
+ return (XF86FILE*)fp;
+}
+
+static void _xf86checkhndl(XF86FILE_priv* f,const char *func)
+{
+ if (!f || f->magic != XF86FILE_magic ||
+ !f->filehnd || !f->fname) {
+ FatalError("libc_wrapper error: passed invalid FILE handle to %s",
+ func);
+ exit(42);
+ }
+}
+
+int
+xf86fclose(XF86FILE* f)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+ int ret;
+
+ _xf86checkhndl(fp,"xf86fclose");
+
+ /* somewhat bad check */
+ if (fp->fileno < 3 && fp->fname[0]=='$') {
+ /* assume this is stdin/out/err, don't dispose */
+ ret = fclose(fp->filehnd);
+ } else {
+ ret = fclose(fp->filehnd);
+ fp->magic = 0; /* invalidate */
+ xfree(fp->fname);
+ xfree(fp);
+ }
+ return ret ? -1 : 0;
+}
+
+int
+xf86printf(const char *format, ...)
+{
+ int ret;
+ va_list args;
+ va_start(args, format);
+
+ ret = printf(format,args);
+ va_end(args);
+ return ret;
+}
+
+int
+xf86fprintf(XF86FILE* f, const char *format, ...)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+ int ret;
+ va_list args;
+ va_start(args, format);
+
+#ifdef DEBUG
+ ErrorF("xf86fprintf for XF86FILE %p\n", fp);
+#endif
+ _xf86checkhndl(fp,"xf86fprintf");
+
+ ret = vfprintf(fp->filehnd,format,args);
+ va_end(args);
+ return ret;
+}
+
+int
+xf86vfprintf(XF86FILE* f, const char *format, va_list ap)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+#ifdef DEBUG
+ ErrorF("xf86vfprintf for XF86FILE %p\n", fp);
+#endif
+ _xf86checkhndl(fp,"xf86vfprintf");
+
+ return vfprintf(fp->filehnd,format,ap);
+}
+
+int
+xf86vsprintf(char *s, const char *format, va_list ap)
+{
+ return vsprintf(s, format, ap);
+}
+
+int
+xf86vsnprintf(char *s, xf86size_t len, const char *format, va_list ap)
+{
+ return vsnprintf(s, (size_t)len, format, ap);
+}
+
+#ifdef HAVE_VFSCANF
+int
+xf86fscanf(XF86FILE* f, const char *format, ...)
+#else
+int
+xf86fscanf(XF86FILE* f, const char *format, char *a0, char *a1, char *a2,
+ char *a3, char *a4, char *a5, char *a6, char *a7, char *a8,
+ char *a9) /* limit of ten args */
+#endif
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+#ifdef HAVE_VFSCANF
+ int ret;
+ va_list args;
+ va_start(args, format);
+
+ _xf86checkhndl(fp,"xf86fscanf");
+
+ ret = vfscanf(fp->filehnd,format,args);
+ va_end(args);
+ return ret;
+#else
+ _xf86checkhndl(fp,"xf86fscanf");
+ return fscanf(fp->filehnd, format, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
+#endif
+}
+
+char *
+xf86fgets(char *buf, INT32 n, XF86FILE* f)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+ _xf86checkhndl(fp,"xf86fgets");
+ return fgets(buf,(int)n,fp->filehnd);
+}
+
+int
+xf86fputs(const char *buf, XF86FILE* f)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+ _xf86checkhndl(fp,"xf86fputs");
+ return fputs(buf,fp->filehnd);
+}
+
+int
+xf86getc(XF86FILE* f)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+ _xf86checkhndl(fp,"xf86getc");
+ return getc(fp->filehnd);
+}
+
+int
+xf86fgetc(XF86FILE* f)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+ _xf86checkhndl(fp,"xf86fgetc");
+ return fgetc(fp->filehnd);
+}
+
+int
+xf86fputc(int c,XF86FILE* f)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+ _xf86checkhndl(fp,"xf86fputc");
+ return fputc(c,fp->filehnd);
+}
+
+int
+xf86fflush(XF86FILE* f)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+ _xf86checkhndl(fp,"xf86fflush");
+ return fflush(fp->filehnd);
+}
+
+xf86size_t
+xf86fread(void* buf, xf86size_t sz, xf86size_t cnt, XF86FILE* f)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+#ifdef DEBUG
+ ErrorF("xf86fread for XF86FILE %p\n", fp);
+#endif
+ _xf86checkhndl(fp,"xf86fread");
+ return fread(buf,(size_t)sz,(size_t)cnt,fp->filehnd);
+}
+
+xf86size_t
+xf86fwrite(const void* buf, xf86size_t sz, xf86size_t cnt, XF86FILE* f)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+ _xf86checkhndl(fp,"xf86fwrite");
+ return fwrite(buf,(size_t)sz,(size_t)cnt,fp->filehnd);
+}
+
+int
+xf86fseek(XF86FILE* f, long offset, int whence)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+ _xf86checkhndl(fp,"xf86fseek");
+ switch (whence) {
+ case XF86_SEEK_SET:
+ whence = SEEK_SET;
+ break;
+ case XF86_SEEK_CUR:
+ whence = SEEK_CUR;
+ break;
+ case XF86_SEEK_END:
+ whence = SEEK_END;
+ break;
+ }
+ return fseek(fp->filehnd,offset,whence);
+}
+
+long
+xf86ftell(XF86FILE* f)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+ _xf86checkhndl(fp,"xf86ftell");
+ return ftell(fp->filehnd);
+}
+
+#define mapnum(e) case (xf86_##e): err = e; break;
+
+char*
+xf86strerror(int n)
+{
+ int err;
+
+ switch (n)
+ {
+ case 0: err = 0; break;
+ mapnum (EACCES);
+ mapnum (EAGAIN);
+ mapnum (EBADF);
+ mapnum (EEXIST);
+ mapnum (EFAULT);
+ mapnum (EINTR);
+ mapnum (EINVAL);
+ mapnum (EISDIR);
+ mapnum (ELOOP); /* not POSIX 1 */
+ mapnum (EMFILE);
+ mapnum (ENAMETOOLONG);
+ mapnum (ENFILE);
+ mapnum (ENOENT);
+ mapnum (ENOMEM);
+ mapnum (ENOSPC);
+ mapnum (ENOTDIR);
+ mapnum (EPIPE);
+ mapnum (EROFS);
+#ifndef __UNIXOS2__
+ mapnum (ETXTBSY); /* not POSIX 1 */
+#endif
+ mapnum (ENOTTY);
+#ifdef ENOSYS
+ mapnum (ENOSYS);
+#endif
+ mapnum (EBUSY);
+ mapnum (ENODEV);
+ mapnum (EIO);
+#ifdef ESRCH
+ mapnum (ESRCH);
+#endif
+#ifdef ENXIO
+ mapnum (ENXIO);
+#endif
+#ifdef E2BIG
+ mapnum (E2BIG);
+#endif
+#ifdef ENOEXEC
+ mapnum (ENOEXEC);
+#endif
+#ifdef ECHILD
+ mapnum (ECHILD);
+#endif
+#ifdef ENOTBLK
+ mapnum (ENOTBLK);
+#endif
+#ifdef EXDEV
+ mapnum (EXDEV);
+#endif
+#ifdef EFBIG
+ mapnum (EFBIG);
+#endif
+#ifdef ESPIPE
+ mapnum (ESPIPE);
+#endif
+#ifdef EMLINK
+ mapnum (EMLINK);
+#endif
+#ifdef EDOM
+ mapnum (EDOM);
+#endif
+#ifdef ERANGE
+ mapnum (ERANGE);
+#endif
+
+ default:
+ err = 999;
+ }
+ return strerror(err);
+}
+
+#undef mapnum
+
+
+/* required for portable fgetpos/fsetpos,
+ * use as
+ * XF86fpos_t* pos = xalloc(xf86fpossize());
+ */
+long
+xf86fpossize()
+{
+ return sizeof(fpos_t);
+}
+
+int
+xf86fgetpos(XF86FILE* f,XF86fpos_t* pos)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+ fpos_t *ppos = (fpos_t*)pos;
+
+ _xf86checkhndl(fp,"xf86fgetpos");
+#ifndef ISC
+ return fgetpos(fp->filehnd,ppos);
+#else
+ *ppos = ftell(fp->filehnd);
+ if (*ppos < 0L)
+ return(-1);
+ return(0);
+#endif
+}
+
+int
+xf86fsetpos(XF86FILE* f,const XF86fpos_t* pos)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+ fpos_t *ppos = (fpos_t*)pos;
+
+ /* XXX need to handle xf86errno here */
+ _xf86checkhndl(fp,"xf86fsetpos");
+#ifndef ISC
+ return fsetpos(fp->filehnd,ppos);
+#else
+ if (ppos == NULL)
+ {
+ errno = EINVAL;
+ return EOF;
+ }
+ return fseek(fp->filehnd, *ppos, SEEK_SET);
+#endif
+}
+
+void
+xf86perror(const char *s)
+{
+ perror(s);
+}
+
+int
+xf86remove(const char *s)
+{
+#ifdef _POSIX_SOURCE
+ return remove(s);
+#else
+ return unlink(s);
+#endif
+}
+
+int
+xf86rename(const char *old, const char *new)
+{
+#ifdef _POSIX_SOURCE
+ return rename(old,new);
+#else
+ int ret = link(old,new);
+ if (!ret) {
+ ret = unlink(old);
+ if (ret) unlink(new);
+ } else
+ ret = unlink(new);
+ return ret;
+#endif
+}
+
+void
+xf86rewind(XF86FILE* f)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+ _xf86checkhndl(fp,"xf86fsetpos");
+ rewind(fp->filehnd);
+}
+
+void
+xf86clearerr(XF86FILE* f)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+ _xf86checkhndl(fp,"xf86clearerr");
+ clearerr(fp->filehnd);
+}
+
+int
+xf86feof(XF86FILE* f)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+ _xf86checkhndl(fp,"xf86feof");
+ return feof(fp->filehnd);
+}
+
+int
+xf86ferror(XF86FILE* f)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+ _xf86checkhndl(fp,"xf86ferror");
+ return ferror(fp->filehnd);
+}
+
+XF86FILE*
+xf86freopen(const char* fname,const char* mode,XF86FILE* fold)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)fold;
+ FILE *fnew;
+
+ _xf86checkhndl(fp,"xf86freopen");
+ fnew = freopen(fname,mode,fp->filehnd);
+ xf86errno = xf86GetErrno();
+ if (!fnew) {
+ xf86fclose(fold); /* discard old XF86FILE structure */
+ return 0;
+ }
+ /* recycle the old XF86FILE structure */
+ fp->magic = XF86FILE_magic;
+ fp->filehnd = fnew;
+ fp->fileno = fileno(fnew);
+ fp->fname = xf86strdup(fname);
+#ifdef DEBUG
+ ErrorF("xf86freopen(%s,%s,%p) yields FILE %p XF86FILE %p\n",
+ fname,mode,fold,fnew,fp);
+#endif
+ return (XF86FILE*)fp;
+}
+
+int
+xf86setbuf(XF86FILE* f, char *buf)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+ _xf86checkhndl(fp,"xf86fsetbuf");
+#ifdef SETBUF_RETURNS_INT
+ return setbuf(fp->filehnd, buf);
+#else
+ setbuf(fp->filehnd, buf);
+ return 0;
+#endif
+}
+
+int
+xf86setvbuf(XF86FILE* f, char *buf, int mode, xf86size_t size)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+ int vbufmode;
+
+ _xf86checkhndl(fp,"xf86fsetvbuf");
+
+ switch (mode) {
+ case XF86_IONBF:
+ vbufmode = _IONBF;
+ break;
+ case XF86_IOLBF:
+ vbufmode = _IOFBF;
+ break;
+ case XF86_IOFBF:
+ vbufmode = _IOLBF;
+ break;
+ default:
+ FatalError("libc_wrapper error: mode in setvbuf incorrect");
+ exit(42);
+ }
+
+ return setvbuf(fp->filehnd,buf,vbufmode,(size_t)size);
+}
+
+XF86FILE*
+xf86tmpfile(void)
+{
+#ifdef NEED_TMPFILE
+ return xf86fopen(tmpnam((char*)0),"w+");
+#else
+ XF86FILE_priv* fp;
+ FILE *f = tmpfile();
+ xf86errno = xf86GetErrno();
+ if (!f) return 0;
+
+ fp = xalloc(sizeof(XF86FILE_priv));
+ fp->magic = XF86FILE_magic;
+ fp->filehnd = f;
+ fp->fileno = fileno(f);
+ fp->fname = xf86strdup("*tmpfile*"); /* so that it can be xfree()'d */
+#ifdef DEBUG
+ ErrorF("xf86tmpfile() yields FILE %p XF86FILE %p\n",f,fp);
+#endif
+ return (XF86FILE*)fp;
+}
+#endif /* HAS_TMPFILE */
+
+
+int
+xf86ungetc(int c,XF86FILE* f)
+{
+ XF86FILE_priv* fp = (XF86FILE_priv*)f;
+
+ _xf86checkhndl(fp,"xf86ungetc");
+ return ungetc(c,fp->filehnd);
+}
+
+/* Misc functions. Some are ANSI C, some are not. */
+
+void
+xf86usleep(usec)
+ unsigned long usec;
+{
+#if (defined(SYSV) || defined(SVR4)) && !defined(sun)
+ syscall(3112, (usec) / 1000 + 1);
+#else
+ usleep(usec);
+#endif
+}
+
+void
+xf86getsecs(long * secs, long * usecs)
+{
+ struct timeval tv;
+
+ X_GETTIMEOFDAY(&tv);
+ if (secs)
+ *secs = tv.tv_sec;
+ if (usecs)
+ *usecs= tv.tv_usec;
+
+ return;
+}
+
+int
+xf86ffs(int mask)
+{
+ int n;
+ if (mask == 0) return 0;
+ for (n = 1; (mask & 1)==0; n++)
+ mask >>= 1;
+ return n;
+}
+
+char *
+xf86getenv(const char * a)
+{
+ /* Only allow this when the real and effective uids are the same */
+ if (getuid() != geteuid())
+ return NULL;
+ else
+ return(getenv(a));
+}
+
+void *
+xf86bsearch(const void *key, const void *base, xf86size_t nmemb,
+ xf86size_t size, int (*compar)(const void *, const void *))
+{
+ return bsearch(key, base, (size_t)nmemb, (size_t)size, compar);
+}
+
+int
+xf86execl(const char *pathname, const char *arg, ...)
+{
+#ifndef __UNIXOS2__
+ int i;
+ pid_t pid;
+ int exit_status;
+ char *arglist[5];
+ va_list args;
+ va_start(args, arg);
+ arglist[0] = (char*)&args;
+ i = 1;
+ while (i < 5 && (arglist[i++] = va_arg(args, char *)) != NULL)
+ ;
+ va_end(args);
+
+ if ((pid = fork()) < 0) {
+ ErrorF("Fork failed (%s)\n", strerror(errno));
+ return -1;
+ } else if (pid == 0) { /* child */
+ /*
+ * Make sure that the child doesn't inherit any I/O permissions it
+ * shouldn't have. It's better to put constraints on the development
+ * of a clock program than to give I/O permissions to a bogus program
+ * in someone's XF86Config file
+ */
+#ifndef SELF_CONTAINED_WRAPPER
+ xf86DisableIO();
+#endif
+ if (setuid(getuid()) == -1) {
+ ErrorF("xf86Execl: setuid() failed: %s\n", strerror(errno));
+ exit(255);
+ }
+#if !defined(SELF_CONTAINED_WRAPPER)
+ /* set stdin, stdout to the consoleFD, and leave stderr alone */
+ for (i = 0; i < 2; i++)
+ {
+ if (xf86Info.consoleFd != i)
+ {
+ close(i);
+ dup(xf86Info.consoleFd);
+ }
+ }
+#endif
+
+ execv(pathname, arglist);
+ ErrorF("Exec failed for command \"%s\" (%s)\n",
+ pathname, strerror(errno));
+ exit(255);
+ }
+
+ /* parent */
+ wait(&exit_status);
+ if (WIFEXITED(exit_status))
+ {
+ switch (WEXITSTATUS(exit_status))
+ {
+ case 0: /* OK */
+ return 0;
+ case 255: /* exec() failed */
+ return(255);
+ default: /* bad exit status */
+ ErrorF("Program \"%s\" had bad exit status %d\n",
+ pathname, WEXITSTATUS(exit_status));
+ return(WEXITSTATUS(exit_status));
+ }
+ }
+ else if (WIFSIGNALED(exit_status))
+ {
+ ErrorF("Program \"%s\" died on signal %d\n",
+ pathname, WTERMSIG(exit_status));
+ return(WTERMSIG(exit_status));
+ }
+#ifdef WIFSTOPPED
+ else if (WIFSTOPPED(exit_status))
+ {
+ ErrorF("Program \"%s\" stopped by signal %d\n",
+ pathname, WSTOPSIG(exit_status));
+ return(WSTOPSIG(exit_status));
+ }
+#endif
+ else /* should never get to this point */
+ {
+ ErrorF("Program \"%s\" has unknown exit condition\n",
+ pathname);
+ return(1);
+ }
+#else
+ return(1);
+#endif /* __UNIXOS2__ Disable this crazy business for now */
+}
+
+void
+xf86abort(void)
+{
+ ErrorF("Module called abort() function\n");
+ abort();
+}
+
+void
+xf86exit(int ex)
+{
+ ErrorF("Module called exit() function with value=%d\n",ex);
+ exit(ex);
+}
+
+/* directory handling functions */
+#define XF86DIR_magic 0x78666876 /* "xfhv" */
+
+typedef struct _xf86_dir_ {
+ DIR *dir;
+ INT32 magic;
+ XF86DIRENT *dirent;
+} XF86DIR_priv;
+
+static void
+_xf86checkdirhndl(XF86DIR_priv* f,const char *func)
+{
+ if (!f || f->magic != XF86DIR_magic || !f->dir || !f->dirent) {
+ FatalError("libc_wrapper error: passed invalid DIR handle to %s",
+ func);
+ exit(42);
+ }
+}
+
+XF86DIR *
+xf86opendir(const char *name)
+{
+ XF86DIR_priv *dp;
+ DIR *dirp;
+
+ dirp = opendir(name);
+ if (!dirp)
+ return (XF86DIR*)0;
+
+ dp = xalloc(sizeof(XF86DIR_priv));
+ dp->magic = XF86DIR_magic; /* This time I have this, Dirk! :-) */
+ dp->dir = dirp;
+ dp->dirent = xalloc(sizeof(struct _xf86dirent));
+
+ return (XF86DIR*)dp;
+}
+
+XF86DIRENT*
+xf86readdir(XF86DIR* dirp)
+{
+ XF86DIR_priv* dp = (XF86DIR_priv*)dirp;
+ DIRENTRY *de;
+ XF86DIRENT* xde;
+ int sz;
+
+ _xf86checkdirhndl(dp,"xf86readdir");
+
+ de = readdir(dp->dir);
+ if (!de)
+ return (XF86DIRENT*)0;
+ xde = dp->dirent;
+ sz = strlen(de->d_name);
+ strncpy(xde->d_name,de->d_name, sz>_XF86NAMELEN ? (_XF86NAMELEN+1) : (sz+1));
+ xde->d_name[_XF86NAMELEN] = '\0'; /* be sure to have a 0 byte */
+ return xde;
+}
+
+void
+xf86rewinddir(XF86DIR* dirp)
+{
+ XF86DIR_priv* dp = (XF86DIR_priv*)dirp;
+
+ _xf86checkdirhndl(dp,"xf86readdir");
+ rewinddir(dp->dir);
+}
+
+int
+xf86closedir(XF86DIR* dir)
+{
+ XF86DIR_priv* dp = (XF86DIR_priv*)dir;
+ int n;
+
+ _xf86checkdirhndl(dp,"xf86readdir");
+
+ n = closedir(dp->dir);
+ dp->magic = 0;
+ xfree(dp->dirent);
+ xfree(dp);
+
+ return n;
+}
+
+static mode_t
+xfToOsChmodMode(xf86mode_t xfmode)
+{
+ mode_t mode = 0;
+
+ if (xfmode & XF86_S_ISUID) mode |= S_ISUID;
+ if (xfmode & XF86_S_ISGID) mode |= S_ISGID;
+#ifndef __UNIXOS2__
+ if (xfmode & XF86_S_ISVTX) mode |= S_ISVTX;
+#endif
+ if (xfmode & XF86_S_IRUSR) mode |= S_IRUSR;
+ if (xfmode & XF86_S_IWUSR) mode |= S_IWUSR;
+ if (xfmode & XF86_S_IXUSR) mode |= S_IXUSR;
+ if (xfmode & XF86_S_IRGRP) mode |= S_IRGRP;
+ if (xfmode & XF86_S_IWGRP) mode |= S_IWGRP;
+ if (xfmode & XF86_S_IXGRP) mode |= S_IXGRP;
+ if (xfmode & XF86_S_IROTH) mode |= S_IROTH;
+ if (xfmode & XF86_S_IWOTH) mode |= S_IWOTH;
+ if (xfmode & XF86_S_IXOTH) mode |= S_IXOTH;
+
+ return mode;
+}
+
+int
+xf86chmod(const char *path, xf86mode_t xfmode)
+{
+ mode_t mode = xfToOsChmodMode(xfmode);
+ int rc = chmod(path, mode);
+
+ xf86errno = xf86GetErrno();
+ return rc;
+}
+
+int
+xf86chown(const char *path, xf86uid_t owner, xf86gid_t group)
+{
+#ifndef __UNIXOS2__
+ int rc = chown(path, owner, group);
+#else
+ int rc = 0;
+#endif
+ xf86errno = xf86GetErrno();
+ return rc;
+}
+
+xf86uid_t
+xf86geteuid(void)
+{
+ return geteuid();
+}
+
+xf86gid_t
+xf86getegid(void)
+{
+ return getegid();
+}
+
+int
+xf86getpid(void)
+{
+ return getpid();
+}
+
+static mode_t
+xfToOsMknodMode(xf86mode_t xfmode)
+{
+ mode_t mode = xfToOsChmodMode(xfmode);
+
+ if (xfmode & XF86_S_IFREG) mode |= S_IFREG;
+ if (xfmode & XF86_S_IFCHR) mode |= S_IFCHR;
+#ifndef __UNIXOS2__
+ if (xfmode & XF86_S_IFBLK) mode |= S_IFBLK;
+#endif
+ if (xfmode & XF86_S_IFIFO) mode |= S_IFIFO;
+
+ return mode;
+}
+
+int xf86mknod(const char *pathname, xf86mode_t xfmode, xf86dev_t dev)
+{
+ mode_t mode = xfToOsMknodMode(xfmode);
+#ifndef __UNIXOS2__
+ int rc = mknod(pathname, mode, dev);
+#else
+ int rc = 0;
+#endif
+ xf86errno = xf86GetErrno();
+ return rc;
+}
+
+unsigned int xf86sleep(unsigned int seconds)
+{
+ return sleep(seconds);
+}
+
+int xf86mkdir(const char *pathname, xf86mode_t xfmode)
+{
+ mode_t mode = xfToOsChmodMode(xfmode);
+ int rc = mkdir(pathname, mode);
+
+ xf86errno = xf86GetErrno();
+ return rc;
+}
+
+
+/* Several math functions */
+
+int
+xf86abs(int x)
+{
+ return abs(x);
+}
+
+double
+xf86acos(double x)
+{
+ return acos(x);
+}
+
+double
+xf86asin(double x)
+{
+ return asin(x);
+}
+
+double
+xf86atan(double x)
+{
+ return atan(x);
+}
+
+double
+xf86atan2(double x,double y)
+{
+ return atan2(x,y);
+}
+
+double
+xf86atof(const char* s)
+{
+ return atof(s);
+}
+
+int
+xf86atoi(const char* s)
+{
+ return atoi(s);
+}
+
+long
+xf86atol(const char* s)
+{
+ return atol(s);
+}
+
+double
+xf86ceil(double x)
+{
+ return ceil(x);
+}
+
+double
+xf86cos(double x)
+{
+ return(cos(x));
+}
+
+double
+xf86exp(double x)
+{
+ return(exp(x));
+}
+
+double
+xf86fabs(double x)
+{
+ return(fabs(x));
+}
+
+int
+xf86finite(double x)
+{
+#ifndef QNX4
+#ifndef __UNIXOS2__
+ return(finite(x));
+#else
+ return(isfinite(x));
+#endif /* __UNIXOS2__ */
+#else
+ /* XXX Replace this with something that really works. */
+ return 1;
+#endif
+}
+
+double
+xf86floor(double x)
+{
+ return floor(x);
+}
+
+double
+xf86fmod(double x,double y)
+{
+ return fmod(x,y);
+}
+
+long
+xf86labs(long x)
+{
+ return labs(x);
+}
+
+double
+xf86ldexp(double x, int exp)
+{
+ return ldexp(x, exp);
+}
+
+double
+xf86log(double x)
+{
+ return(log(x));
+}
+
+double
+xf86log10(double x)
+{
+ return(log10(x));
+}
+
+double
+xf86modf(double x,double* y)
+{
+ return modf(x,y);
+}
+
+double
+xf86pow(double x, double y)
+{
+ return(pow(x,y));
+}
+
+double
+xf86sin(double x)
+{
+ return sin(x);
+}
+
+double
+xf86sqrt(double x)
+{
+ return(sqrt(x));
+}
+
+double
+xf86strtod(const char *s, char **end)
+{
+ return strtod(s,end);
+}
+
+long
+xf86strtol(const char *s, char **end, int radix)
+{
+ return strtol(s,end,radix);
+}
+
+unsigned long
+xf86strtoul(const char *s, char **end,int radix)
+{
+ return strtoul(s,end,radix);
+}
+
+double
+xf86tan(double x)
+{
+ return tan(x);
+}
+
+/* memory functions */
+void*
+xf86memchr(const void* s, int c, xf86size_t n)
+{
+ return memchr(s,c,(size_t)n);
+}
+
+int
+xf86memcmp(const void* s1, const void* s2, xf86size_t n)
+{
+ return(memcmp(s1,s2,(size_t)n));
+}
+
+void*
+xf86memcpy(void* dest, const void* src, xf86size_t n)
+{
+ return(memcpy(dest,src,(size_t)n));
+}
+
+void*
+xf86memmove(void* dest, const void* src, xf86size_t n)
+{
+ return(memmove(dest,src,(size_t)n));
+}
+
+void*
+xf86memset(void* s, int c, xf86size_t n)
+{
+ return(memset(s,c,(size_t)n));
+}
+
+/* ctype functions */
+
+int
+xf86isalnum(int c)
+{
+ return isalnum(c) ? 1 : 0;
+}
+
+int
+xf86isalpha(int c)
+{
+ return isalpha(c) ? 1 : 0;
+}
+
+int
+xf86iscntrl(int c)
+{
+ return iscntrl(c) ? 1 : 0;
+}
+
+int
+xf86isdigit(int c)
+{
+ return isdigit(c) ? 1 : 0;
+}
+
+int
+xf86isgraph(int c)
+{
+ return isgraph(c) ? 1 : 0;
+}
+
+int
+xf86islower(int c)
+{
+ return islower(c) ? 1 : 0;
+}
+
+int
+xf86isprint(int c)
+{
+ return isprint(c) ? 1 : 0;
+}
+
+int
+xf86ispunct(int c)
+{
+ return ispunct(c) ? 1 : 0;
+}
+
+int
+xf86isspace(int c)
+{
+ return isspace(c) ? 1 : 0;
+}
+
+int
+xf86isupper(int c)
+{
+ return isupper(c) ? 1 : 0;
+}
+
+int
+xf86isxdigit(int c)
+{
+ return isxdigit(c) ? 1 : 0;
+}
+
+int
+xf86tolower(int c)
+{
+ return tolower(c);
+}
+
+int
+xf86toupper(int c)
+{
+ return toupper(c);
+}
+
+/* memory allocation functions */
+void*
+xf86calloc(xf86size_t sz,xf86size_t n)
+{
+ return xcalloc(sz, n);
+}
+
+void
+xf86free(void* p)
+{
+ xfree(p);
+}
+
+double
+xf86frexp(double x, int *exp)
+{
+ return frexp(x, exp);
+}
+
+void*
+xf86malloc(xf86size_t n)
+{
+ return xalloc(n);
+}
+
+void*
+xf86realloc(void* p, xf86size_t n)
+{
+ return xrealloc(p,n);
+}
+
+/*
+ * XXX This probably doesn't belong here.
+ */
+int
+xf86getpagesize()
+{
+ static int pagesize = -1;
+
+ if (pagesize != -1)
+ return pagesize;
+
+#if defined(_SC_PAGESIZE) || defined(HAS_SC_PAGESIZE)
+ pagesize = sysconf(_SC_PAGESIZE);
+#endif
+#ifdef _SC_PAGE_SIZE
+ if (pagesize == -1)
+ pagesize = sysconf(_SC_PAGE_SIZE);
+#endif
+#ifdef HAS_GETPAGESIZE
+ if (pagesize == -1)
+ pagesize = getpagesize();
+#endif
+#ifdef PAGE_SIZE
+ if (pagesize == -1)
+ pagesize = PAGE_SIZE;
+#endif
+ if (pagesize == -1)
+ FatalError("xf86getpagesize: Cannot determine page size");
+
+ return pagesize;
+}
+
+
+#define mapnum(e) case (e): return (xf86_##e)
+
+int
+xf86GetErrno ()
+{
+ switch (errno)
+ {
+ case 0: return 0;
+ mapnum (EACCES);
+ mapnum (EAGAIN);
+ mapnum (EBADF);
+ mapnum (EEXIST);
+ mapnum (EFAULT);
+ mapnum (EINTR);
+ mapnum (EINVAL);
+ mapnum (EISDIR);
+ mapnum (ELOOP); /* not POSIX 1 */
+ mapnum (EMFILE);
+ mapnum (ENAMETOOLONG);
+ mapnum (ENFILE);
+ mapnum (ENOENT);
+ mapnum (ENOMEM);
+ mapnum (ENOSPC);
+ mapnum (ENOTDIR);
+ mapnum (EPIPE);
+ mapnum (EROFS);
+#ifndef __UNIXOS2__
+ mapnum (ETXTBSY); /* not POSIX 1 */
+#endif
+ mapnum (ENOTTY);
+#ifdef ENOSYS
+ mapnum (ENOSYS);
+#endif
+ mapnum (EBUSY);
+ mapnum (ENODEV);
+ mapnum (EIO);
+#ifdef ESRCH
+ mapnum (ESRCH);
+#endif
+#ifdef ENXIO
+ mapnum (ENXIO);
+#endif
+#ifdef E2BIG
+ mapnum (E2BIG);
+#endif
+#ifdef ENOEXEC
+ mapnum (ENOEXEC);
+#endif
+#ifdef ECHILD
+ mapnum (ECHILD);
+#endif
+#ifdef ENOTBLK
+ mapnum (ENOTBLK);
+#endif
+#ifdef EXDEV
+ mapnum (EXDEV);
+#endif
+#ifdef EFBIG
+ mapnum (EFBIG);
+#endif
+#ifdef ESPIPE
+ mapnum (ESPIPE);
+#endif
+#ifdef EMLINK
+ mapnum (EMLINK);
+#endif
+#ifdef EDOM
+ mapnum (EDOM);
+#endif
+#ifdef ERANGE
+ mapnum (ERANGE);
+#endif
+ default:
+ return (xf86_UNKNOWN);
+ }
+}
+
+#undef mapnum
+
+
+
+#ifdef HAVE_SYSV_IPC
+
+int
+xf86shmget(xf86key_t key, int size, int xf86shmflg)
+{
+ int shmflg;
+ int ret;
+
+ /* This copies the permissions (SHM_R, SHM_W for u, g, o). */
+ shmflg = xf86shmflg & 0777;
+
+ if (key == XF86IPC_PRIVATE) key = IPC_PRIVATE;
+
+ if (xf86shmflg & XF86IPC_CREAT) shmflg |= IPC_CREAT;
+ if (xf86shmflg & XF86IPC_EXCL) shmflg |= IPC_EXCL;
+ if (xf86shmflg & XF86IPC_NOWAIT) shmflg |= IPC_NOWAIT;
+ ret = shmget((key_t) key, size, shmflg);
+
+ if (ret == -1)
+ xf86errno = xf86GetErrno();
+
+ return ret;
+}
+
+char *
+xf86shmat(int id, char *addr, int xf86shmflg)
+{
+ int shmflg = 0;
+ pointer ret;
+
+#ifdef SHM_RDONLY
+ if (xf86shmflg & XF86SHM_RDONLY) shmflg |= SHM_RDONLY;
+#endif
+#ifdef SHM_RND
+ if (xf86shmflg & XF86SHM_RND) shmflg |= SHM_RND;
+#endif
+#ifdef SHM_REMAP
+ if (xf86shmflg & XF86SHM_REMAP) shmflg |= SHM_REMAP;
+#endif
+
+ ret = shmat(id,addr,shmflg);
+
+ if (ret == (pointer) -1)
+ xf86errno = xf86GetErrno();
+
+ return ret;
+}
+
+int
+xf86shmdt(char *addr)
+{
+ int ret;
+
+ ret = shmdt(addr);
+
+ if (ret == -1)
+ xf86errno = xf86GetErrno();
+
+ return ret;
+}
+
+/*
+ * for now only implement the rmid command.
+ */
+int
+xf86shmctl(int id, int xf86cmd, pointer buf)
+{
+ int cmd;
+ int ret;
+
+ switch (xf86cmd) {
+ case XF86IPC_RMID:
+ cmd = IPC_RMID;
+ break;
+ default:
+ return 0;
+ }
+
+ ret = shmctl(id, cmd, buf);
+
+ if (ret == -1)
+ xf86errno = xf86GetErrno();
+
+ return ret;
+}
+#else
+
+int
+xf86shmget(xf86key_t key, int size, int xf86shmflg)
+{
+ xf86errno = ENOSYS;
+
+ return -1;
+}
+
+char *
+xf86shmat(int id, char *addr, int xf86shmflg)
+{
+ xf86errno = ENOSYS;
+
+ return (char *)-1;
+}
+
+int
+xf86shmctl(int id, int xf86cmd, pointer buf)
+{
+ xf86errno = ENOSYS;
+
+ return -1;
+}
+
+int
+xf86shmdt(char *addr)
+{
+ xf86errno = ENOSYS;
+
+ return -1;
+}
+#endif /* HAVE_SYSV_IPC */
+
+int
+xf86getjmptype()
+{
+#ifdef HAS_GLIBC_SIGSETJMP
+ return 1;
+#else
+ return 0;
+#endif
+}
+
+#ifdef HAS_GLIBC_SIGSETJMP
+
+int
+xf86setjmp(xf86jmp_buf env)
+{
+#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ return __sigsetjmp((void *)env, xf86setjmp1_arg2());
+#else
+ return xf86setjmp1(env, xf86setjmp1_arg2());
+#endif
+}
+
+int
+xf86setjmp0(xf86jmp_buf env)
+{
+ FatalError("setjmp: type 0 called instead of type %d", xf86getjmptype());
+}
+
+#if !defined(__GLIBC__) || (__GLIBC__ < 2) /* libc5 */
+
+int
+xf86setjmp1(xf86jmp_buf env, int arg2)
+{
+ __sigjmp_save((void *)env, arg2);
+ return __setjmp((void *)env);
+}
+
+#endif
+
+#else /* HAS_GLIBC_SIGSETJMP */
+
+int
+xf86setjmp1(xf86jmp_buf env, int arg2)
+{
+ FatalError("setjmp: type 1 called instead of type %d", xf86getjmptype());
+}
+
+int
+xf86setjmp0(xf86jmp_buf env)
+{
+ return setjmp((void *)env);
+}
+
+#endif /* HAS_GLIBC_SIGSETJMP */
+
+int
+xf86setjmp1_arg2()
+{
+ return 1;
+}
+
+int
+xf86setjmperror(xf86jmp_buf env)
+{
+ FatalError("setjmp: don't know how to handle setjmp() type %d",
+ xf86getjmptype());
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/pm_noop.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/pm_noop.c
new file mode 100644
index 000000000..6e24653ba
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/pm_noop.c
@@ -0,0 +1,48 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/pm_noop.c,v 1.2 2003/08/24 17:37:06 dawes Exp $ */
+/*
+ * Copyright (c) 2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* Stubs for the OS-support layer power-management functions. */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
+#include "xf86_OSproc.h"
+
+PMClose
+xf86OSPMOpen(void)
+{
+ return NULL;
+}
+
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c
new file mode 100644
index 000000000..be3703944
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c
@@ -0,0 +1,689 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c,v 3.30 2003/08/24 17:37:06 dawes Exp $ */
+/*
+ * Copyright 1993-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+
+/* $XConsortium: posix_tty.c /main/7 1996/10/19 18:07:47 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+static int
+GetBaud (int baudrate)
+{
+#ifdef B300
+ if (baudrate == 300)
+ return B300;
+#endif
+#ifdef B1200
+ if (baudrate == 1200)
+ return B1200;
+#endif
+#ifdef B2400
+ if (baudrate == 2400)
+ return B2400;
+#endif
+#ifdef B4800
+ if (baudrate == 4800)
+ return B4800;
+#endif
+#ifdef B9600
+ if (baudrate == 9600)
+ return B9600;
+#endif
+#ifdef B19200
+ if (baudrate == 19200)
+ return B19200;
+#endif
+#ifdef B38400
+ if (baudrate == 38400)
+ return B38400;
+#endif
+#ifdef B57600
+ if (baudrate == 57600)
+ return B57600;
+#endif
+#ifdef B115200
+ if (baudrate == 115200)
+ return B115200;
+#endif
+#ifdef B230400
+ if (baudrate == 230400)
+ return B230400;
+#endif
+#ifdef B460800
+ if (baudrate == 460800)
+ return B460800;
+#endif
+ return (0);
+}
+
+int
+xf86OpenSerial (pointer options)
+{
+#ifdef Lynx
+ struct sgttyb ms_sgtty;
+#endif
+ struct termios t;
+ int fd, i;
+ char *dev;
+
+ dev = xf86SetStrOption (options, "Device", NULL);
+ if (!dev)
+ {
+ xf86Msg (X_ERROR, "xf86OpenSerial: No Device specified.\n");
+ return (-1);
+ }
+
+ SYSCALL (fd = open (dev, O_RDWR | O_NONBLOCK));
+ if (fd == -1)
+ {
+ xf86Msg (X_ERROR,
+ "xf86OpenSerial: Cannot open device %s\n\t%s.\n",
+ dev, strerror (errno));
+ xfree(dev);
+ return (-1);
+ }
+
+ if (!isatty (fd))
+ {
+#if 1
+ /* Allow non-tty devices to be opened. */
+ xfree(dev);
+ return (fd);
+#else
+ xf86Msg (X_WARNING,
+ "xf86OpenSerial: Specified device %s is not a tty\n",
+ dev);
+ SYSCALL (close (fd));
+ errno = EINVAL;
+ xfree(dev);
+ return (-1);
+#endif
+ }
+
+#ifdef Lynx
+ /* LynxOS does not assert DTR without this */
+ ioctl (fd, TIOCGETP, (char *) &ms_sgtty);
+ ioctl (fd, TIOCSDTR, (char *) &ms_sgtty);
+#endif
+
+ /* set up default port parameters */
+ SYSCALL (tcgetattr (fd, &t));
+ t.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR\
+ |IGNCR|ICRNL|IXON);
+ t.c_oflag &= ~OPOST;
+ t.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
+ t.c_cflag &= ~(CSIZE|PARENB);
+ t.c_cflag |= CS8|CLOCAL;
+
+ cfsetispeed (&t, B9600);
+ cfsetospeed (&t, B9600);
+ t.c_cc[VMIN] = 1;
+ t.c_cc[VTIME] = 0;
+
+ SYSCALL (tcsetattr (fd, TCSANOW, &t));
+
+ if (xf86SetSerial (fd, options) == -1)
+ {
+ SYSCALL (close (fd));
+ xfree(dev);
+ return (-1);
+ }
+
+ SYSCALL (i = fcntl (fd, F_GETFL, 0));
+ if (i == -1)
+ {
+ SYSCALL (close (fd));
+ xfree(dev);
+ return (-1);
+ }
+ i &= ~O_NONBLOCK;
+ SYSCALL (i = fcntl (fd, F_SETFL, i));
+ if (i == -1)
+ {
+ SYSCALL (close (fd));
+ xfree(dev);
+ return (-1);
+ }
+ xfree(dev);
+ return (fd);
+}
+
+int
+xf86SetSerial (int fd, pointer options)
+{
+ struct termios t;
+ int val;
+ const char *s;
+ int baud, r;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+ SYSCALL (tcgetattr (fd, &t));
+
+ if ((val = xf86SetIntOption (options, "BaudRate", 0)))
+ {
+ if ((baud = GetBaud (val)))
+ {
+ cfsetispeed (&t, baud);
+ cfsetospeed (&t, baud);
+ }
+ else
+ {
+ xf86Msg (X_ERROR,
+ "Invalid Option BaudRate value: %d\n", val);
+ return (-1);
+ }
+ }
+
+ if ((val = xf86SetIntOption (options, "StopBits", 0)))
+ {
+ switch (val)
+ {
+ case 1:
+ t.c_cflag &= ~(CSTOPB);
+ break;
+ case 2:
+ t.c_cflag |= CSTOPB;
+ break;
+ default:
+ xf86Msg (X_ERROR,
+ "Invalid Option StopBits value: %d\n", val);
+ return (-1);
+ break;
+ }
+ }
+
+ if ((val = xf86SetIntOption (options, "DataBits", 0)))
+ {
+ switch (val)
+ {
+ case 5:
+ t.c_cflag &= ~(CSIZE);
+ t.c_cflag |= CS5;
+ break;
+ case 6:
+ t.c_cflag &= ~(CSIZE);
+ t.c_cflag |= CS6;
+ break;
+ case 7:
+ t.c_cflag &= ~(CSIZE);
+ t.c_cflag |= CS7;
+ break;
+ case 8:
+ t.c_cflag &= ~(CSIZE);
+ t.c_cflag |= CS8;
+ break;
+ default:
+ xf86Msg (X_ERROR,
+ "Invalid Option DataBits value: %d\n", val);
+ return (-1);
+ break;
+ }
+ }
+
+ if ((s = xf86SetStrOption (options, "Parity", NULL)))
+ {
+ if (xf86NameCmp (s, "Odd") == 0)
+ {
+ t.c_cflag |= PARENB | PARODD;
+ }
+ else if (xf86NameCmp (s, "Even") == 0)
+ {
+ t.c_cflag |= PARENB;
+ t.c_cflag &= ~(PARODD);
+ }
+ else if (xf86NameCmp (s, "None") == 0)
+ {
+ t.c_cflag &= ~(PARENB);
+ }
+ else
+ {
+ xf86Msg (X_ERROR, "Invalid Option Parity value: %s\n",
+ s);
+ return (-1);
+ }
+ }
+
+ if ((val = xf86SetIntOption (options, "Vmin", -1)) != -1)
+ {
+ t.c_cc[VMIN] = val;
+ }
+ if ((val = xf86SetIntOption (options, "Vtime", -1)) != -1)
+ {
+ t.c_cc[VTIME] = val;
+ }
+
+ if ((s = xf86SetStrOption (options, "FlowControl", NULL)))
+ {
+ xf86MarkOptionUsedByName (options, "FlowControl");
+ if (xf86NameCmp (s, "Xoff") == 0)
+ {
+ t.c_iflag |= IXOFF;
+ }
+ else if (xf86NameCmp (s, "Xon") == 0)
+ {
+ t.c_iflag |= IXON;
+ }
+ else if (xf86NameCmp (s, "XonXoff") == 0)
+ {
+ t.c_iflag |= IXON|IXOFF;
+ }
+ else if (xf86NameCmp (s, "None") == 0)
+ {
+ t.c_iflag &= ~(IXON | IXOFF);
+ }
+ else
+ {
+ xf86Msg (X_ERROR,
+ "Invalid Option FlowControl value: %s\n", s);
+ return (-1);
+ }
+ }
+
+ if ((xf86SetBoolOption (options, "ClearDTR", FALSE)))
+ {
+#ifdef CLEARDTR_SUPPORT
+# if !defined(Lynx) || defined(TIOCMBIC)
+ val = TIOCM_DTR;
+ SYSCALL (ioctl(fd, TIOCMBIC, &val));
+# else
+ SYSCALL (ioctl(fd, TIOCCDTR, NULL));
+# endif
+#else
+ xf86Msg (X_WARNING,
+ "Option ClearDTR not supported on this OS\n");
+ return (-1);
+#endif
+ xf86MarkOptionUsedByName (options, "ClearDTR");
+ }
+
+ if ((xf86SetBoolOption (options, "ClearRTS", FALSE)))
+ {
+#ifdef CLEARRTS_SUPPORT
+ val = TIOCM_RTS;
+ SYSCALL (ioctl(fd, TIOCMBIC, &val));
+#else
+ xf86Msg (X_WARNING,
+ "Option ClearRTS not supported on this OS\n");
+ return (-1);
+#endif
+ xf86MarkOptionUsedByName (options, "ClearRTS");
+ }
+
+ SYSCALL (r = tcsetattr (fd, TCSANOW, &t));
+ return (r);
+}
+
+int
+xf86SetSerialSpeed (int fd, int speed)
+{
+ struct termios t;
+ int baud, r;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+ SYSCALL (tcgetattr (fd, &t));
+
+ if ((baud = GetBaud (speed)))
+ {
+ cfsetispeed (&t, baud);
+ cfsetospeed (&t, baud);
+ }
+ else
+ {
+ xf86Msg (X_ERROR,
+ "Invalid Option BaudRate value: %d\n", speed);
+ return (-1);
+ }
+
+ SYSCALL (r = tcsetattr (fd, TCSANOW, &t));
+ return (r);
+}
+
+int
+xf86ReadSerial (int fd, void *buf, int count)
+{
+ int r;
+#ifdef DEBUG
+ int i;
+#endif
+ SYSCALL (r = read (fd, buf, count));
+#ifdef DEBUG
+ ErrorF("ReadingSerial: 0x%x",
+ (unsigned char)*(((unsigned char *)buf)));
+ for (i = 1; i < r; i++)
+ ErrorF(", 0x%x",(unsigned char)*(((unsigned char *)buf) + i));
+ ErrorF("\n");
+#endif
+ return (r);
+}
+
+int
+xf86WriteSerial (int fd, const void *buf, int count)
+{
+ int r;
+#ifdef DEBUG
+ int i;
+
+ ErrorF("WritingSerial: 0x%x",(unsigned char)*(((unsigned char *)buf)));
+ for (i = 1; i < count; i++)
+ ErrorF(", 0x%x",(unsigned char)*(((unsigned char *)buf) + i));
+ ErrorF("\n");
+#endif
+ SYSCALL (r = write (fd, buf, count));
+ return (r);
+}
+
+int
+xf86CloseSerial (int fd)
+{
+ int r;
+
+ SYSCALL (r = close (fd));
+ return (r);
+}
+
+int
+xf86WaitForInput (int fd, int timeout)
+{
+ fd_set readfds;
+ struct timeval to;
+ int r;
+
+ FD_ZERO(&readfds);
+
+ if (fd >= 0) {
+ FD_SET(fd, &readfds);
+ }
+
+ to.tv_sec = timeout / 1000000;
+ to.tv_usec = timeout % 1000000;
+
+ if (fd >= 0) {
+ SYSCALL (r = select (FD_SETSIZE, &readfds, NULL, NULL, &to));
+ }
+ else {
+ SYSCALL (r = select (FD_SETSIZE, NULL, NULL, NULL, &to));
+ }
+ xf86ErrorFVerb (9,"select returned %d\n", r);
+ return (r);
+}
+
+int
+xf86SerialSendBreak (int fd, int duration)
+{
+ int r;
+
+ SYSCALL (r = tcsendbreak (fd, duration));
+ return (r);
+
+}
+
+int
+xf86FlushInput(int fd)
+{
+ fd_set fds;
+ struct timeval timeout;
+ char c[4];
+
+#ifdef DEBUG
+ ErrorF("FlushingSerial\n");
+#endif
+ if (tcflush(fd, TCIFLUSH) == 0)
+ return 0;
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+ while (select(FD_SETSIZE, &fds, NULL, NULL, &timeout) > 0) {
+ if (read(fd, &c, sizeof(c)) < 1)
+ return 0;
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+ }
+ return 0;
+}
+
+static struct states {
+ int xf;
+ int os;
+} modemStates[] = {
+#ifdef TIOCM_LE
+ { XF86_M_LE, TIOCM_LE },
+#endif
+#ifdef TIOCM_DTR
+ { XF86_M_DTR, TIOCM_DTR },
+#endif
+#ifdef TIOCM_RTS
+ { XF86_M_RTS, TIOCM_RTS },
+#endif
+#ifdef TIOCM_ST
+ { XF86_M_ST, TIOCM_ST },
+#endif
+#ifdef TIOCM_SR
+ { XF86_M_SR, TIOCM_SR },
+#endif
+#ifdef TIOCM_CTS
+ { XF86_M_CTS, TIOCM_CTS },
+#endif
+#ifdef TIOCM_CAR
+ { XF86_M_CAR, TIOCM_CAR },
+#elif defined(TIOCM_CD)
+ { XF86_M_CAR, TIOCM_CD },
+#endif
+#ifdef TIOCM_RNG
+ { XF86_M_RNG, TIOCM_RNG },
+#elif defined(TIOCM_RI)
+ { XF86_M_CAR, TIOCM_RI },
+#endif
+#ifdef TIOCM_DSR
+ { XF86_M_DSR, TIOCM_DSR },
+#endif
+};
+
+static int numStates = sizeof(modemStates) / sizeof(modemStates[0]);
+
+static int
+xf2osState(int state)
+{
+ int i;
+ int ret = 0;
+
+ for (i = 0; i < numStates; i++)
+ if (state & modemStates[i].xf)
+ ret |= modemStates[i].os;
+ return ret;
+}
+
+static int
+os2xfState(int state)
+{
+ int i;
+ int ret = 0;
+
+ for (i = 0; i < numStates; i++)
+ if (state & modemStates[i].os)
+ ret |= modemStates[i].xf;
+ return ret;
+}
+
+static int
+getOsStateMask(void)
+{
+ int i;
+ int ret = 0;
+ for (i = 0; i < numStates; i++)
+ ret |= modemStates[i].os;
+ return ret;
+}
+
+static int osStateMask = 0;
+
+int
+xf86SetSerialModemState(int fd, int state)
+{
+ int ret;
+ int s;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+#ifndef TIOCMGET
+ return -1;
+#else
+ if (!osStateMask)
+ osStateMask = getOsStateMask();
+
+ state = xf2osState(state);
+ SYSCALL((ret = ioctl(fd, TIOCMGET, &s)));
+ if (ret < 0)
+ return -1;
+ s &= ~osStateMask;
+ s |= state;
+ SYSCALL((ret = ioctl(fd, TIOCMSET, &s)));
+ if (ret < 0)
+ return -1;
+ else
+ return 0;
+#endif
+}
+
+int
+xf86GetSerialModemState(int fd)
+{
+ int ret;
+ int s;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+#ifndef TIOCMGET
+ return -1;
+#else
+ SYSCALL((ret = ioctl(fd, TIOCMGET, &s)));
+ if (ret < 0)
+ return -1;
+ return os2xfState(s);
+#endif
+}
+
+int
+xf86SerialModemSetBits(int fd, int bits)
+{
+ int ret;
+ int s;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+#ifndef TIOCMGET
+ return -1;
+#else
+ s = xf2osState(bits);
+ SYSCALL((ret = ioctl(fd, TIOCMBIS, &s)));
+ return ret;
+#endif
+}
+
+int
+xf86SerialModemClearBits(int fd, int bits)
+{
+ int ret;
+ int s;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+#ifndef TIOCMGET
+ return -1;
+#else
+ s = xf2osState(bits);
+ SYSCALL((ret = ioctl(fd, TIOCMBIC, &s)));
+ return ret;
+#endif
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/sigio.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/sigio.c
new file mode 100644
index 000000000..e6da3940f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/sigio.c
@@ -0,0 +1,312 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/sigio.c,v 1.16 2003/09/04 00:21:17 dawes Exp $ */
+
+/* sigio.c -- Support for SIGIO handler installation and removal
+ * Created: Thu Jun 3 15:39:18 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ */
+/*
+ * Copyright (c) 2002 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef XFree86Server
+# include <X11/X.h>
+# include "xf86.h"
+# include "xf86Priv.h"
+# include "xf86_OSlib.h"
+# include "inputstr.h"
+#else
+# include <unistd.h>
+# include <signal.h>
+# include <fcntl.h>
+# include <sys/time.h>
+# include <errno.h>
+# include <stdio.h>
+# include <string.h>
+# define SYSCALL(call) while(((call) == -1) && (errno == EINTR))
+#endif
+
+/*
+ * Linux libc5 defines FASYNC, but not O_ASYNC. Don't know if it is
+ * functional or not.
+ */
+#if defined(FASYNC) && !defined(O_ASYNC)
+# define O_ASYNC FASYNC
+#endif
+
+#ifdef MAX_DEVICES
+/* MAX_DEVICES represents the maximimum number of input devices usable
+ * at the same time plus one entry for DRM support.
+ */
+# define MAX_FUNCS (MAX_DEVICES + 1)
+#else
+# define MAX_FUNCS 16
+#endif
+
+typedef struct _xf86SigIOFunc {
+ void (*f) (int, void *);
+ int fd;
+ void *closure;
+} Xf86SigIOFunc;
+
+static Xf86SigIOFunc xf86SigIOFuncs[MAX_FUNCS];
+static int xf86SigIOMax;
+static int xf86SigIOMaxFd;
+static fd_set xf86SigIOMask;
+
+/*
+ * SIGIO gives no way of discovering which fd signalled, select
+ * to discover
+ */
+static void
+xf86SIGIO (int sig)
+{
+ int i;
+ fd_set ready;
+ struct timeval to;
+ int r;
+
+ ready = xf86SigIOMask;
+ to.tv_sec = 0;
+ to.tv_usec = 0;
+ SYSCALL (r = select (xf86SigIOMaxFd, &ready, 0, 0, &to));
+ for (i = 0; r > 0 && i < xf86SigIOMax; i++)
+ if (xf86SigIOFuncs[i].f && FD_ISSET (xf86SigIOFuncs[i].fd, &ready))
+ {
+ (*xf86SigIOFuncs[i].f)(xf86SigIOFuncs[i].fd,
+ xf86SigIOFuncs[i].closure);
+ r--;
+ }
+#ifdef XFree86Server
+ if (r > 0) {
+ xf86Msg(X_ERROR, "SIGIO %d descriptors not handled\n", r);
+ }
+#endif
+}
+
+static int
+xf86IsPipe (int fd)
+{
+ struct stat buf;
+
+ if (fstat (fd, &buf) < 0)
+ return 0;
+ return S_ISFIFO(buf.st_mode);
+}
+
+int
+xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *closure)
+{
+ struct sigaction sa;
+ struct sigaction osa;
+ int i;
+ int blocked;
+
+ for (i = 0; i < MAX_FUNCS; i++)
+ {
+ if (!xf86SigIOFuncs[i].f)
+ {
+ if (xf86IsPipe (fd))
+ return 0;
+ blocked = xf86BlockSIGIO();
+ if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_ASYNC) == -1) {
+#ifdef XFree86Server
+ xf86Msg(X_WARNING, "fcntl(%d, O_ASYNC): %s\n",
+ fd, strerror(errno));
+#else
+ fprintf(stderr,"fcntl(%d, O_ASYNC): %s\n",
+ fd, strerror(errno));
+#endif
+ xf86UnblockSIGIO(blocked);
+ return 0;
+ }
+ if (fcntl(fd, F_SETOWN, getpid()) == -1) {
+#ifdef XFree86Server
+ xf86Msg(X_WARNING, "fcntl(%d, F_SETOWN): %s\n",
+ fd, strerror(errno));
+#else
+ fprintf(stderr,"fcntl(%d, F_SETOWN): %s\n",
+ fd, strerror(errno));
+#endif
+ xf86UnblockSIGIO(blocked);
+ return 0;
+ }
+ sigemptyset(&sa.sa_mask);
+ sigaddset(&sa.sa_mask, SIGIO);
+ sa.sa_flags = 0;
+ sa.sa_handler = xf86SIGIO;
+ sigaction(SIGIO, &sa, &osa);
+ xf86SigIOFuncs[i].fd = fd;
+ xf86SigIOFuncs[i].closure = closure;
+ xf86SigIOFuncs[i].f = f;
+ if (i >= xf86SigIOMax)
+ xf86SigIOMax = i+1;
+ if (fd >= xf86SigIOMaxFd)
+ xf86SigIOMaxFd = fd + 1;
+ FD_SET (fd, &xf86SigIOMask);
+ xf86UnblockSIGIO(blocked);
+ return 1;
+ }
+ /* Allow overwriting of the closure and callback */
+ else if (xf86SigIOFuncs[i].fd == fd)
+ {
+ xf86SigIOFuncs[i].closure = closure;
+ xf86SigIOFuncs[i].f = f;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int
+xf86RemoveSIGIOHandler(int fd)
+{
+ struct sigaction sa;
+ struct sigaction osa;
+ int i;
+ int max;
+ int maxfd;
+ int ret;
+
+ max = 0;
+ maxfd = -1;
+ ret = 0;
+ for (i = 0; i < MAX_FUNCS; i++)
+ {
+ if (xf86SigIOFuncs[i].f)
+ {
+ if (xf86SigIOFuncs[i].fd == fd)
+ {
+ xf86SigIOFuncs[i].f = 0;
+ xf86SigIOFuncs[i].fd = 0;
+ xf86SigIOFuncs[i].closure = 0;
+ FD_CLR (fd, &xf86SigIOMask);
+ ret = 1;
+ }
+ else
+ {
+ max = i + 1;
+ if (xf86SigIOFuncs[i].fd >= maxfd)
+ maxfd = xf86SigIOFuncs[i].fd + 1;
+ }
+ }
+ }
+ if (ret)
+ {
+ fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_ASYNC);
+ xf86SigIOMax = max;
+ xf86SigIOMaxFd = maxfd;
+ if (!max)
+ {
+ sigemptyset(&sa.sa_mask);
+ sigaddset(&sa.sa_mask, SIGIO);
+ sa.sa_flags = 0;
+ sa.sa_handler = SIG_DFL;
+ sigaction(SIGIO, &sa, &osa);
+ }
+ }
+ return ret;
+}
+
+int
+xf86BlockSIGIO (void)
+{
+ sigset_t set, old;
+ int ret;
+
+ sigemptyset (&set);
+ sigaddset (&set, SIGIO);
+ sigprocmask (SIG_BLOCK, &set, &old);
+ ret = sigismember (&old, SIGIO);
+#ifdef DEBUG
+ ErrorF("%i = xf86BlockSIGIO()\n",ret);
+#endif
+ return ret;
+}
+
+void
+xf86UnblockSIGIO (int wasset)
+{
+ sigset_t set;
+#ifdef DEBUG
+ ErrorF("xf86UnblockSIGIO(%i)\n",wasset);
+#endif
+
+ if (!wasset)
+ {
+ sigemptyset (&set);
+ sigaddset (&set, SIGIO);
+ sigprocmask (SIG_UNBLOCK, &set, NULL);
+ }
+}
+
+#ifdef XFree86Server
+void
+xf86AssertBlockedSIGIO (char *where)
+{
+ sigset_t set, old;
+
+ sigemptyset (&set);
+ sigprocmask (SIG_BLOCK, &set, &old);
+ if (!sigismember (&old, SIGIO))
+ xf86Msg (X_ERROR, "SIGIO not blocked at %s\n", where);
+}
+
+/* XXX This is a quick hack for the benefit of xf86SetSilkenMouse() */
+
+int
+xf86SIGIOSupported (void)
+{
+ return 1;
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/sigiostubs.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/sigiostubs.c
new file mode 100644
index 000000000..2173bb991
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/sigiostubs.c
@@ -0,0 +1,86 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/sigiostubs.c,v 1.4 2003/08/24 17:37:06 dawes Exp $ */
+/*
+ * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/shared/sigiostubs.c,v 1.5 2005/07/03 07:01:35 daniels Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef XFree86Server
+#ifdef __UNIXOS2__
+# define I_NEED_OS2_H
+#endif
+# include <X11/X.h>
+# include "xf86.h"
+# include "xf86Priv.h"
+# include "xf86_OSlib.h"
+#else
+# include <unistd.h>
+# include <signal.h>
+# include <fcntl.h>
+# include <sys/time.h>
+# include <errno.h>
+#endif
+
+int
+xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *closure)
+{
+ return 0;
+}
+
+int
+xf86RemoveSIGIOHandler(int fd)
+{
+ return 0;
+}
+
+int
+xf86BlockSIGIO (void)
+{
+ return 0;
+}
+
+void
+xf86UnblockSIGIO (int wasset)
+{
+}
+
+#ifdef XFree86Server
+void
+xf86AssertBlockedSIGIO (char *where)
+{
+}
+#endif
+
+/* XXX This is a quick hack for the benefit of xf86SetSilkenMouse() */
+Bool
+xf86SIGIOSupported ()
+{
+ return FALSE;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/stdPci.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/stdPci.c
new file mode 100644
index 000000000..491406f92
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/stdPci.c
@@ -0,0 +1,52 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/stdPci.c,v 3.4 2003/08/24 17:37:06 dawes Exp $ */
+/*
+ * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef __UNIXOS2__
+# define I_NEED_OS2_H
+#endif
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Privstr.h"
+#include "xf86Pci.h"
+#define NEED_OS_RAC_PROTOS
+#include "xf86_OSlib.h"
+
+#ifndef HAVE_PCI_SIZE_FUNC
+#define xf86StdGetPciSizeFromOS xf86GetPciSizeFromOS
+#endif
+
+Bool
+xf86StdGetPciSizeFromOS(PCITAG tag, int index, int* bits)
+{
+ return FALSE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/stdResource.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/stdResource.c
new file mode 100644
index 000000000..4704d8194
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/stdResource.c
@@ -0,0 +1,182 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/stdResource.c,v 1.22 2003/08/24 17:37:06 dawes Exp $ */
+/*
+ * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* Standard resource information code */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef __UNIXOS2__
+# define I_NEED_OS2_H
+#endif
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Privstr.h"
+#include "xf86Pci.h"
+#define NEED_OS_RAC_PROTOS
+#include "xf86_OSlib.h"
+#include "xf86Resources.h"
+
+#ifdef __UNIXOS2__
+# undef ADDRESS
+#endif
+/* Avoid Imakefile changes */
+#include "bus/Pci.h"
+
+#ifdef USESTDRES
+#define xf86StdBusAccWindowsFromOS xf86BusAccWindowsFromOS
+#define xf86StdAccResFromOS xf86AccResFromOS
+#define xf86StdPciBusAccWindowsFromOS xf86PciBusAccWindowsFromOS
+#define xf86StdIsaBusAccWindowsFromOS xf86IsaBusAccWindowsFromOS
+
+resRange PciAvoid[] = {_PCI_AVOID_PC_STYLE, _END};
+#endif
+
+#ifdef INCLUDE_XF86_NO_DOMAIN
+
+resPtr
+xf86StdBusAccWindowsFromOS(void)
+{
+ /* Fallback is to allow addressing of all memory space */
+ resPtr ret = NULL;
+ resRange range;
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ /* Fallback is to allow addressing of all I/O space */
+ RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ return ret;
+}
+
+resPtr
+xf86StdPciBusAccWindowsFromOS(void)
+{
+ /* Fallback is to allow addressing of all memory space */
+ resPtr ret = NULL;
+ resRange range;
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ /* Fallback is to allow addressing of all I/O space */
+ RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ return ret;
+}
+
+#ifdef INCLUDE_UNUSED
+
+resPtr
+xf86StdIsaBusAccWindowsFromOS(void)
+{
+ /* Fallback is to allow addressing of all memory space */
+ resPtr ret = NULL;
+ resRange range;
+
+ RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ /* Fallback is to allow addressing of all I/O space */
+ RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ return ret;
+}
+
+#endif /* INCLUDE_UNUSED */
+
+resPtr
+xf86StdAccResFromOS(resPtr ret)
+{
+ resRange range;
+
+ /*
+ * Fallback is to claim the following areas:
+ *
+ * 0x00000000 - 0x0009ffff low 640k host memory
+ * 0x000c0000 - 0x000effff location of VGA and other extensions ROMS
+ * 0x000f0000 - 0x000fffff system BIOS
+ * 0x00100000 - 0x3fffffff low 1G - 1MB host memory
+ * 0xfec00000 - 0xfecfffff default I/O APIC config space
+ * 0xfee00000 - 0xfeefffff default Local APIC config space
+ * 0xffe00000 - 0xffffffff high BIOS area (should this be included?)
+ *
+ * reference: Intel 440BX AGP specs
+ *
+ * The two APIC spaces appear to be BX-specific and should be dealt with
+ * elsewhere.
+ */
+
+ /* Fallback is to claim 0x0 - 0x9ffff and 0x100000 - 0x7fffffff */
+ RANGE(range, 0x00000000, 0x0009ffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x000c0000, 0x000effff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x000f0000, 0x000fffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x00100000, 0x3fffffff,
+ ResExcMemBlock | ResBios | ResEstimated);
+ ret = xf86AddResToList(ret, &range, -1);
+#if 0
+ RANGE(range, 0xfec00000, 0xfecfffff, ResExcMemBlock | ResBios);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xfee00000, 0xfeefffff, ResExcMemBlock | ResBios);
+ ret = xf86AddResToList(ret, &range, -1);
+#endif
+ RANGE(range, 0xffe00000, 0xffffffff, ResExcMemBlock | ResBios);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ /*
+ * Fallback would be to claim well known ports in the 0x0 - 0x3ff range
+ * along with their sparse I/O aliases, but that's too imprecise. Instead
+ * claim a bare minimum here.
+ */
+ RANGE(range, 0x00000000, 0x000000ff, ResExcIoBlock); /* For mainboard */
+ ret = xf86AddResToList(ret, &range, -1);
+
+ /*
+ * At minimum, the top and bottom resources must be claimed, so that
+ * resources that are (or appear to be) unallocated can be relocated.
+ */
+/* RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+ RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1); */
+ RANGE(range, 0x0000ffff, 0x0000ffff, ResExcIoBlock);
+ ret = xf86AddResToList(ret, &range, -1);
+
+ /* XXX add others */
+ return ret;
+}
+
+#endif /* INCLUDE_XF86_NO_DOMAIN */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c
new file mode 100644
index 000000000..c678162c2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c
@@ -0,0 +1,50 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c,v 3.2 1998/07/25 16:57:01 dawes Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Dawes <dawes@xfree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Dawes
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Thomas Roell and
+ * David Dawes makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: std_kbdEv.c /main/4 1996/03/11 10:47:33 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+void
+xf86KbdEvents()
+{
+ unsigned char rBuf[64];
+ int nBytes, i;
+
+ if ((nBytes = read( xf86Info.consoleFd, (char *)rBuf, sizeof(rBuf)))
+ > 0)
+ {
+ for (i = 0; i < nBytes; i++)
+ xf86PostKbdEvent(rBuf[i]);
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/sysv_kbd.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/sysv_kbd.c
new file mode 100644
index 000000000..3a3544e8c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/sysv_kbd.c
@@ -0,0 +1,106 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/sysv_kbd.c,v 3.3 1998/07/25 16:57:02 dawes Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Dawes <dawes@XFree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Dawes
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Thomas Roell and
+ * David Dawes makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: sysv_kbd.c /main/3 1996/02/21 17:53:59 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+int
+xf86GetKbdLeds()
+{
+ int leds;
+
+ ioctl(xf86Info.consoleFd, KDGETLED, &leds);
+ return(leds);
+}
+
+void
+xf86SetKbdRepeat(char rad)
+{
+#ifdef KDSETRAD
+ ioctl(xf86Info.consoleFd, KDSETRAD, rad);
+#endif
+}
+
+static int kbdtrans;
+static struct termio kbdtty;
+static char *kbdemap = NULL;
+
+void
+xf86KbdInit()
+{
+#ifdef KDGKBMODE
+ ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans);
+#endif
+ ioctl (xf86Info.consoleFd, TCGETA, &kbdtty);
+#if defined(E_TABSZ)
+ kbdemap = xalloc(E_TABSZ);
+ if (ioctl(xf86Info.consoleFd, LDGMAP, kbdemap) < 0)
+ {
+ xfree(kbdemap);
+ kbdemap = NULL;
+ }
+#endif
+}
+
+int
+xf86KbdOn()
+{
+ struct termio nTty;
+
+ ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW);
+ ioctl(xf86Info.consoleFd, LDNMAP, 0); /* disable mapping completely */
+ nTty = kbdtty;
+ nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8 | B9600;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME]=0;
+ nTty.c_cc[VMIN]=1;
+ ioctl(xf86Info.consoleFd, TCSETA, &nTty);
+ return(xf86Info.consoleFd);
+}
+
+int
+xf86KbdOff()
+{
+ if (kbdemap)
+ {
+ ioctl(xf86Info.consoleFd, LDSMAP, kbdemap);
+ }
+ ioctl(xf86Info.consoleFd, KDSKBMODE, kbdtrans);
+ ioctl(xf86Info.consoleFd, TCSETA, &kbdtty);
+ return(xf86Info.consoleFd);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c
new file mode 100644
index 000000000..237d47a4d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c
@@ -0,0 +1,300 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c,v 1.17 2003/08/24 17:37:06 dawes Exp $ */
+/*
+ * Copyright (c) 1993-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef __UNIXOS2__
+# define I_NEED_OS2_H
+#endif
+#include <X11/X.h>
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+/*
+ * This file contains the common part of the video memory mapping functions
+ */
+
+/*
+ * Get a piece of the ScrnInfoRec. At the moment, this is only used to hold
+ * the MTRR option information, but it is likely to be expanded if we do
+ * auto unmapping of memory at VT switch.
+ *
+ */
+
+typedef struct {
+ unsigned long physBase;
+ unsigned long size;
+ pointer virtBase;
+ pointer mtrrInfo;
+ int flags;
+} MappingRec, *MappingPtr;
+
+typedef struct {
+ int numMappings;
+ MappingPtr * mappings;
+ Bool mtrrEnabled;
+ MessageType mtrrFrom;
+ Bool mtrrOptChecked;
+ ScrnInfoPtr pScrn;
+} VidMapRec, *VidMapPtr;
+
+static int vidMapIndex = -1;
+
+#define VIDMAPPTR(p) ((VidMapPtr)((p)->privates[vidMapIndex].ptr))
+
+static VidMemInfo vidMemInfo = {FALSE, };
+static VidMapRec vidMapRec = {0, NULL, TRUE, X_DEFAULT, FALSE, NULL};
+
+static VidMapPtr
+getVidMapRec(int scrnIndex)
+{
+ VidMapPtr vp;
+ ScrnInfoPtr pScrn;
+
+ if ((scrnIndex < 0) ||
+ !(pScrn = xf86Screens[scrnIndex]))
+ return &vidMapRec;
+
+ if (vidMapIndex < 0)
+ vidMapIndex = xf86AllocateScrnInfoPrivateIndex();
+
+ if (VIDMAPPTR(pScrn) != NULL)
+ return VIDMAPPTR(pScrn);
+
+ vp = pScrn->privates[vidMapIndex].ptr = xnfcalloc(sizeof(VidMapRec), 1);
+ vp->mtrrEnabled = TRUE; /* default to enabled */
+ vp->mtrrFrom = X_DEFAULT;
+ vp->mtrrOptChecked = FALSE;
+ vp->pScrn = pScrn;
+ return vp;
+}
+
+static MappingPtr
+newMapping(VidMapPtr vp)
+{
+ vp->mappings = xnfrealloc(vp->mappings, sizeof(MappingPtr) *
+ (vp->numMappings + 1));
+ vp->mappings[vp->numMappings] = xnfcalloc(sizeof(MappingRec), 1);
+ return vp->mappings[vp->numMappings++];
+}
+
+static MappingPtr
+findMapping(VidMapPtr vp, pointer vbase, unsigned long size)
+{
+ int i;
+
+ for (i = 0; i < vp->numMappings; i++) {
+ if (vp->mappings[i]->virtBase == vbase &&
+ vp->mappings[i]->size == size)
+ return vp->mappings[i];
+ }
+ return NULL;
+}
+
+static void
+removeMapping(VidMapPtr vp, MappingPtr mp)
+{
+ int i, found = 0;
+
+ for (i = 0; i < vp->numMappings; i++) {
+ if (vp->mappings[i] == mp) {
+ found = 1;
+ xfree(vp->mappings[i]);
+ } else if (found) {
+ vp->mappings[i - 1] = vp->mappings[i];
+ }
+ }
+ vp->numMappings--;
+ vp->mappings[vp->numMappings] = NULL;
+}
+
+enum { OPTION_MTRR };
+static const OptionInfoRec opts[] =
+{
+ { OPTION_MTRR, "mtrr", OPTV_BOOLEAN, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+
+static void
+checkMtrrOption(VidMapPtr vp)
+{
+ if (!vp->mtrrOptChecked && vp->pScrn && vp->pScrn->options != NULL) {
+ OptionInfoPtr options;
+
+ options = xnfalloc(sizeof(opts));
+ (void)memcpy(options, opts, sizeof(opts));
+ xf86ProcessOptions(vp->pScrn->scrnIndex, vp->pScrn->options,
+ options);
+ if (xf86GetOptValBool(options, OPTION_MTRR, &vp->mtrrEnabled))
+ vp->mtrrFrom = X_CONFIG;
+ xfree(options);
+ vp->mtrrOptChecked = TRUE;
+ }
+}
+
+void
+xf86MakeNewMapping(int ScreenNum, int Flags, unsigned long Base, unsigned long Size, pointer Vbase)
+{
+ VidMapPtr vp;
+ MappingPtr mp;
+
+ vp = getVidMapRec(ScreenNum);
+ mp = newMapping(vp);
+ mp->physBase = Base;
+ mp->size = Size;
+ mp->virtBase = Vbase;
+ mp->flags = Flags;
+}
+
+void
+xf86InitVidMem(void)
+{
+ if (!vidMemInfo.initialised) {
+ memset(&vidMemInfo, 0, sizeof(VidMemInfo));
+ xf86OSInitVidMem(&vidMemInfo);
+ }
+}
+
+pointer
+xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size)
+{
+ pointer vbase = NULL;
+ VidMapPtr vp;
+ MappingPtr mp;
+
+ if (((Flags & VIDMEM_FRAMEBUFFER) &&
+ (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))))
+ FatalError("Mapping memory with more than one type\n");
+
+ xf86InitVidMem();
+ if (!vidMemInfo.initialised || !vidMemInfo.mapMem)
+ return NULL;
+
+ vbase = vidMemInfo.mapMem(ScreenNum, Base, Size, Flags);
+
+ if (!vbase || vbase == (pointer)-1)
+ return NULL;
+
+ vp = getVidMapRec(ScreenNum);
+ mp = newMapping(vp);
+ mp->physBase = Base;
+ mp->size = Size;
+ mp->virtBase = vbase;
+ mp->flags = Flags;
+
+ /*
+ * Check the "mtrr" option even when MTRR isn't supported to avoid
+ * warnings about unrecognised options.
+ */
+ checkMtrrOption(vp);
+
+ if (vp->mtrrEnabled && vidMemInfo.setWC) {
+ if (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))
+ mp->mtrrInfo =
+ vidMemInfo.setWC(ScreenNum, Base, Size, FALSE,
+ vp->mtrrFrom);
+ else if (Flags & VIDMEM_FRAMEBUFFER)
+ mp->mtrrInfo =
+ vidMemInfo.setWC(ScreenNum, Base, Size, TRUE,
+ vp->mtrrFrom);
+ }
+ return vbase;
+}
+
+void
+xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ VidMapPtr vp;
+ MappingPtr mp;
+
+ if (!vidMemInfo.initialised || !vidMemInfo.unmapMem) {
+ xf86DrvMsg(ScreenNum, X_WARNING,
+ "xf86UnMapVidMem() called before xf86MapVidMem()\n");
+ return;
+ }
+
+ vp = getVidMapRec(ScreenNum);
+ mp = findMapping(vp, Base, Size);
+ if (!mp) {
+ xf86DrvMsg(ScreenNum, X_WARNING,
+ "xf86UnMapVidMem: cannot find region for [%p,0x%lx]\n",
+ Base, Size);
+ return;
+ }
+ if (vp->mtrrEnabled && vidMemInfo.undoWC && mp)
+ vidMemInfo.undoWC(ScreenNum, mp->mtrrInfo);
+
+ vidMemInfo.unmapMem(ScreenNum, Base, Size);
+ removeMapping(vp, mp);
+}
+
+Bool
+xf86CheckMTRR(int ScreenNum)
+{
+ VidMapPtr vp = getVidMapRec(ScreenNum);
+
+ /*
+ * Check the "mtrr" option even when MTRR isn't supported to avoid
+ * warnings about unrecognised options.
+ */
+ checkMtrrOption(vp);
+
+ if (vp->mtrrEnabled && vidMemInfo.setWC)
+ return TRUE;
+
+ return FALSE;
+}
+
+Bool
+xf86LinearVidMem()
+{
+ xf86InitVidMem();
+ return vidMemInfo.linearSupported;
+}
+
+void
+xf86MapReadSideEffects(int ScreenNum, int Flags, pointer base,
+ unsigned long Size)
+{
+ if (!(Flags & VIDMEM_READSIDEEFFECT))
+ return;
+
+ if (!vidMemInfo.initialised || !vidMemInfo.readSideEffects)
+ return;
+
+ vidMemInfo.readSideEffects(ScreenNum, base, Size);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.c
new file mode 100644
index 000000000..b8953f119
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.c
@@ -0,0 +1,50 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.c,v 1.3 2003/08/24 17:37:06 dawes Exp $ */
+/*
+ * Copyright (c) 2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Axp.h"
+
+axpParams xf86AXPParams[] = {
+ {SYS_NONE, 0, 0, 0},
+ {TSUNAMI, 0, 0, 0},
+ {LCA, 1<<24,0xf8000000, 1UL << 32},
+ {APECS, 1<<24,0xf8000000, 1UL << 32},
+ {T2, 0,0xFC000000, 1UL << 31},
+ {T2_GAMMA, 0,0xFC000000, 1UL << 31},
+ {CIA, 0,0xE0000000, 1UL << 34},
+ {MCPCIA, 0,0xf8000000, 1UL << 31},
+ {JENSEN, 0, 0xE000000, 1UL << 32},
+ {POLARIS, 0, 0, 0},
+ {PYXIS, 0, 0, 0},
+ {PYXIS_CIA, 0,0xE0000000, 1UL << 34},
+ {IRONGATE, 0, 0, 0}
+};
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.h
new file mode 100644
index 000000000..4b8b08370
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.h
@@ -0,0 +1,36 @@
+/* $XFree86$ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _XF86_AXP_H_
+#define _XF86_AXP_H_
+
+typedef enum {
+ SYS_NONE,
+ TSUNAMI,
+ LCA,
+ APECS,
+ T2,
+ T2_GAMMA,
+ CIA,
+ MCPCIA,
+ JENSEN,
+ POLARIS,
+ PYXIS,
+ PYXIS_CIA,
+ IRONGATE
+} axpDevice;
+
+typedef struct {
+ axpDevice id;
+ unsigned long hae_thresh;
+ unsigned long hae_mask;
+ unsigned long size;
+} axpParams;
+
+extern axpParams xf86AXPParams[];
+
+#endif
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile
new file mode 100644
index 000000000..2ef24f5e4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile
@@ -0,0 +1,119 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile,v 1.4 2002/10/17 02:22:49 dawes Exp $
+XCOMM $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile,v 1.8 2005/11/06 03:49:22 alanc Exp $
+XCOMM
+XCOMM Copyright 2001 The XFree86 Project, Inc. All Rights Reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, sublicense, and/or sell copies of the Software, and to permit
+XCOMM persons to whom the Software is furnished to do so, subject to the
+XCOMM following conditions:
+XCOMM
+XCOMM The above copyright notice and this permission notice shall be included
+XCOMM in all copies or substantial portions of the Software.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+XCOMM IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR
+XCOMM OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+XCOMM ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+XCOMM OTHER DEALINGS IN THE SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of the XFree86 Project shall
+XCOMM not be used in advertising or otherwise to promote the sale, use or other
+XCOMM dealings in this Software without prior written authorization from the
+XCOMM XFree86 Project.
+XCOMM
+
+/* This is a combined Imakefile intended for all SunOS variants */
+
+#include <Server.tmpl>
+
+#if !HasGcc
+# if HasSunC
+# if !defined(AsmArch) || !defined(AsmFlags)
+# error "Unsupported Architecture for building Xorg server with Sun compilers."
+# error "Need to use gcc or add AsmArch & AsmFlag settings in xc/config/cf/sun.cf"
+# endif
+PROWORKS_ASM_ARCH = AsmArch
+PROWORKS_ASM_FLAGS = AsmFlags
+PROWORKS_INOUT_SRC = solaris-$(PROWORKS_ASM_ARCH).S
+PROWORKS_INOUT_OBJ = solaris-$(PROWORKS_ASM_ARCH).o
+
+all:: $(PROWORKS_ASM_ARCH).il
+includes:: $(PROWORKS_ASM_ARCH).il
+
+CppFileTarget($(PROWORKS_ASM_ARCH).il,solaris-$(PROWORKS_ASM_ARCH).S,-DINLINE_ASM,NullParameter)
+
+$(PROWORKS_INOUT_OBJ): $(PROWORKS_INOUT_SRC)
+ $(AS) -P -o $@ $(PROWORKS_ASM_FLAGS) $(PROWORKS_INOUT_SRC)
+
+# elif defined(i386Architecture)
+PROWORKS_INOUT_SRC = sun_inout.s
+PROWORKS_INOUT_OBJ = sun_inout.o
+# endif
+#endif
+
+#if defined(i386Architecture) && (OSMinorVersion < 8)
+IO_SRC = sysv_io.c
+IO_OBJ = sysv_io.o
+KBD_SRCS = sysv_kbd.c std_kbdEv.c
+KBD_OBJS = sysv_kbd.o std_kbdEv.o
+VTSW_SRC = VTsw_usl.c
+VTSW_OBJ = VTsw_usl.o
+#else
+IO_SRC = sun_io.c
+IO_OBJ = sun_io.o
+KBD_SRCS = sun_kbd.c sun_kbdEv.c
+KBD_OBJS = sun_kbd.o sun_kbdEv.o
+VTSW_SRC = VTsw_noop.c
+VTSW_OBJ = VTsw_noop.o
+#endif
+
+#if defined(i386Architecture) || defined(AMD64Architecture)
+AGP_SRC = sun_agp.c
+AGP_OBJ = sun_agp.o
+#else
+AGP_SRC = agp_noop.c
+AGP_OBJ = agp_noop.o
+#endif
+
+#ifdef SVR4Architecture
+SYSVIPCDEFINES = -DHAVE_SYSV_IPC
+#endif
+
+SRCS = sun_bios.c sun_init.c $(IO_SRC) $(KBD_SRCS) $(PROWORKS_INOUT_SRC) \
+ sun_mouse.c sun_vid.c $(AGP_SRC) libc_wrapper.c kmod_noop.c pm_noop.c \
+ posix_tty.c sigiostubs.c stdPci.c stdResource.c $(VTSW_SRC)
+OBJS = sun_bios.o sun_init.o $(IO_OBJ) $(KBD_OBJS) $(PROWORKS_INOUT_OBJ) \
+ sun_mouse.o sun_vid.o $(AGP_OBJ) libc_wrapper.o kmod_noop.o pm_noop.o \
+ posix_tty.o sigiostubs.o stdPci.o stdResource.o $(VTSW_OBJ)
+
+INCLUDES = -I. -I$(XF86OSSRC) -I$(XF86COMSRC) \
+ -I$(SERVERSRC)/mi -I$(SERVERSRC)/include -I$(SERVERSRC)/Xext \
+ -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+DEFINES = -DUSESTDRES $(VENDOR_DEFINES) $(SYSVIPCDEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+NormalAsmObjectRule()
+
+LinkSourceFile($(VTSW_SRC),../shared)
+LinkSourceFile(agp_noop.c,../shared)
+LinkSourceFile(libc_wrapper.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
+LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(posix_tty.c,../shared)
+LinkSourceFile(sigiostubs.c,../shared)
+LinkSourceFile(stdPci.c,../shared)
+LinkSourceFile(stdResource.c,../shared)
+LinkSourceFile(std_kbdEv.c,../shared)
+LinkSourceFile(sysv_io.c,../sysv)
+LinkSourceFile(sysv_kbd.c,../shared)
+
+DependTarget()
+LintTarget()
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/agpgart.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/agpgart.h
new file mode 100644
index 000000000..637087527
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/agpgart.h
@@ -0,0 +1,109 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/agpgart.h,v 1.2 2005/07/01 22:43:25 daniels Exp $ */
+/*
+ * AGPGART module version 0.99
+ * Copyright (C) 1999 Jeff Hartmann
+ * Copyright (C) 1999 Precision Insight, Inc.
+ * Copyright (C) 1999 Xi Graphics, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#ifndef _AGPGART_H
+#define _AGPGART_H
+
+#pragma ident "@(#)agpgart.h 1.1 05/04/04 SMI"
+
+typedef struct _agp_version {
+ uint16_t agpv_major;
+ uint16_t agpv_minor;
+} agp_version_t;
+
+typedef struct _agp_info {
+ agp_version_t agpi_version;
+ uint32_t agpi_devid; /* bridge vendor + device */
+ uint32_t agpi_mode; /* mode of bridge */
+ ulong_t agpi_aperbase; /* base of aperture */
+ size_t agpi_apersize; /* aperture range size */
+ uint32_t agpi_pgtotal; /* max number of pages in aperture */
+ uint32_t agpi_pgsystem; /* same as pg_total */
+ uint32_t agpi_pgused; /* NUMBER of currently used pages */
+} agp_info_t;
+
+typedef struct _agp_setup {
+ uint32_t agps_mode;
+} agp_setup_t;
+
+typedef struct _agp_allocate {
+ int32_t agpa_key;
+ uint32_t agpa_pgcount;
+ uint32_t agpa_type;
+ uint32_t agpa_physical; /* for i810/830 driver */
+} agp_allocate_t;
+
+typedef struct _agp_bind {
+ int32_t agpb_key;
+ uint32_t agpb_pgstart;
+} agp_bind_t;
+
+typedef struct _agp_unbind {
+ int32_t agpu_key;
+ uint32_t agpu_pri; /* no use in solaris */
+} agp_unbind_t;
+
+#define AGPIOC_BASE 'G'
+#define AGPIOC_INFO _IOR(AGPIOC_BASE, 0, 100)
+#define AGPIOC_ACQUIRE _IO(AGPIOC_BASE, 1)
+#define AGPIOC_RELEASE _IO(AGPIOC_BASE, 2)
+#define AGPIOC_SETUP _IOW(AGPIOC_BASE, 3, agp_setup_t)
+#define AGPIOC_ALLOCATE _IOWR(AGPIOC_BASE, 4, agp_allocate_t)
+#define AGPIOC_DEALLOCATE _IOW(AGPIOC_BASE, 5, int)
+#define AGPIOC_BIND _IOW(AGPIOC_BASE, 6, agp_bind_t)
+#define AGPIOC_UNBIND _IOW(AGPIOC_BASE, 7, agp_unbind_t)
+
+#define AGP_DEVICE "/dev/agpgart"
+
+#endif /* _AGPGART_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/find_deps.pl b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/find_deps.pl
new file mode 100755
index 000000000..2eac14f47
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/find_deps.pl
@@ -0,0 +1,150 @@
+#!/usr/bin/perl -w
+#
+# $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/find_deps.pl,v 1.2 2004/09/22 17:20:56 alanc Exp $
+#
+# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, and/or sell copies of the Software, and to permit persons
+# to whom the Software is furnished to do so, provided that the above
+# copyright notice(s) and this permission notice appear in all copies of
+# the Software and that both the above copyright notice(s) and this
+# permission notice appear in supporting documentation.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+# Except as contained in this notice, the name of a copyright holder
+# shall not be used in advertising or otherwise to promote the sale, use
+# or other dealings in this Software without prior written authorization
+# of the copyright holder.
+#
+#------------------------------------------------------------------------------
+#
+# This script scans the X server, it's libraries, and shared object drivers
+# and generates the linker flags necessary to allow the shared object modules
+# to load via dlopen().
+#
+# WARNING: Do not try this at home boys and girls! Only trained professionals
+# should try this stunt. This script is not intended to serve as an example of
+# proper use of the linker or associated tools, but merely as an unfortunately
+# necessary bit of hackery to get Xserver modules to load via Solaris dlopen
+# instead of the XFree86 custom loader/runtime linker.
+#
+# No guarantee of usability or suitablity is made - in fact it's almost
+# guaranteed this is not suitable for any other use, and maybe not even
+# for the one it was intended.
+#
+# Usage: find_deps.pl [-R ProjectRoot] <paths_to_scan>
+# Expects to be called while cwd is a directory containing Xorg or XFree86
+# server binary.
+
+use strict;
+use File::Find;
+use Getopt::Std;
+
+my @objlist = ();
+my %symtable = ();
+
+my $servername;
+
+my $ProjectRoot = "/usr/X11R6";
+
+my %opts;
+getopts('R:', \%opts);
+if (exists($opts{"R"})) {
+ $ProjectRoot = $opts{"R"};
+}
+
+if (-f "Xorg") {
+ $servername = "Xorg";
+} elsif (-f "XFree86") {
+ $servername = "XFree86";
+} else {
+ die "Cannot find X server";
+}
+
+$File::Find::name = $servername;
+$_ = $servername;
+&scanobjs;
+
+find({wanted => \&scanobjs, preprocess => \&filterobjs}, @ARGV);
+
+for my $f (@objlist) {
+ open(ELFDUMP, "/usr/ccs/bin/elfdump -r $f|") || die "Cannot open file";
+ my $edline;
+ my %deps = ();
+ while ($edline = <ELFDUMP>) {
+ next unless $edline =~ /(GLOB_DAT|R_386_32|R_SPARC_32)/;
+ my @edpart = split /\s+/, $edline;
+ if (exists $symtable{$edpart[$#edpart]}) {
+# print "$f : $edpart[$#edpart] - $symtable{$edpart[$#edpart]}\n";
+ $deps{$symtable{$edpart[$#edpart]}} += 1;
+ } else {
+ print "$f : $edpart[$#edpart] - not found\n";
+ }
+ }
+ close(ELFDUMP);
+
+ my $depslist = "";
+
+ for my $d (sort keys %deps) {
+ next if ($f =~ /$d/ || $d !~ /\.so$/);
+ $depslist .= " -Wl,-N,$d";
+ }
+ print "$f : $depslist\n";
+ my $depsfile = $f ."_deps";
+ if ($depslist ne "") {
+ my $dirlist = "-R $ProjectRoot/lib/modules";
+ if ($f =~ /drivers/) {
+ $dirlist .= " -R $ProjectRoot/lib/modules/drivers";
+ }
+ if ($depslist =~ /libfbdevhw.so/) {
+ $dirlist .= " -R $ProjectRoot/lib/modules/linux/";
+ }
+ if ($depslist =~ /libGLcore.so/) {
+ $dirlist .= " -R $ProjectRoot/lib/modules/extensions/";
+ }
+
+ open(MODDEPSFILE, '>', $depsfile) || die "Cannot write to $depsfile";
+ print MODDEPSFILE $dirlist, $depslist, "\n";
+ close(MODDEPSFILE);
+ } elsif (! -z $depsfile) {
+ unlink($depsfile);
+ system("touch $depsfile");
+ }
+}
+
+
+sub filterobjs {
+ return (grep( ($_ =~ /\.so$/) || (-d $_) , @_));
+}
+
+sub scanobjs {
+ return if /libXfont.so/;
+ return if (-d $_);
+ print "Scanning $File::Find::name ...\n";
+ push @objlist, $File::Find::name;
+ open(NMOUT, "/usr/ccs/bin/nm $_|") || die "Cannot nm file $_";
+ my $nmline;
+ while ($nmline = <NMOUT>) {
+ next unless $nmline =~ /\|/;
+ my @nmpart = split(/\s*\|\s*/, $nmline);
+ next unless ($nmpart[4] eq "GLOB") && ($nmpart[6] ne "UNDEF");
+ chomp($nmpart[7]);
+ if (! exists $symtable{$nmpart[7]}) {
+ $symtable{$nmpart[7]} = $_;
+ }
+ }
+ close(NMOUT);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-amd64.S b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-amd64.S
new file mode 100644
index 000000000..9f5e58cb0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-amd64.S
@@ -0,0 +1,73 @@
+/ Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+/
+/ Permission is hereby granted, free of charge, to any person obtaining a
+/ copy of this software and associated documentation files (the
+/ "Software"), to deal in the Software without restriction, including
+/ without limitation the rights to use, copy, modify, merge, publish,
+/ distribute, and/or sell copies of the Software, and to permit persons
+/ to whom the Software is furnished to do so, provided that the above
+/ copyright notice(s) and this permission notice appear in all copies of
+/ the Software and that both the above copyright notice(s) and this
+/ permission notice appear in supporting documentation.
+/
+/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+/ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+/ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+/ OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+/ HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+/ INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+/ FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+/ NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+/ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+/
+/ Except as contained in this notice, the name of a copyright holder
+/ shall not be used in advertising or otherwise to promote the sale, use
+/ or other dealings in this Software without prior written authorization
+/ of the copyright holder.
+
+#ifdef INLINE_ASM
+#define FUNCTION_START(f,n) .inline f,n
+#define FUNCTION_END(f) .end
+#else
+#define _ASM
+#include <sys/asm_linkage.h>
+#define FUNCTION_START(f,n) ENTRY(f)
+#define FUNCTION_END(f) SET_SIZE(f)
+#endif
+
+ FUNCTION_START(inb,4)
+ movq %rdi, %rdx
+ xorq %rax, %rax
+ inb (%dx)
+ FUNCTION_END(inb)
+
+ FUNCTION_START(inw,4)
+ movq %rdi, %rdx
+ xorq %rax, %rax
+ inw (%dx)
+ FUNCTION_END(inw)
+
+ FUNCTION_START(inl,4)
+ movq %rdi, %rdx
+ xorq %rax, %rax
+ inl (%dx)
+ FUNCTION_END(inl)
+
+ FUNCTION_START(outb,8)
+ movq %rdi, %rdx
+ movq %rsi, %rax
+ outb (%dx)
+ FUNCTION_END(outb)
+
+ FUNCTION_START(outw,8)
+ movq %rdi, %rdx
+ movq %rsi, %rax
+ outw (%dx)
+ FUNCTION_END(outw)
+
+ FUNCTION_START(outl,8)
+ movq %rdi, %rdx
+ movq %rsi, %rax
+ outl (%dx)
+ FUNCTION_END(outl)
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-ia32.S b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-ia32.S
new file mode 100644
index 000000000..e2d9cf60a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-ia32.S
@@ -0,0 +1,73 @@
+/ Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+/
+/ Permission is hereby granted, free of charge, to any person obtaining a
+/ copy of this software and associated documentation files (the
+/ "Software"), to deal in the Software without restriction, including
+/ without limitation the rights to use, copy, modify, merge, publish,
+/ distribute, and/or sell copies of the Software, and to permit persons
+/ to whom the Software is furnished to do so, provided that the above
+/ copyright notice(s) and this permission notice appear in all copies of
+/ the Software and that both the above copyright notice(s) and this
+/ permission notice appear in supporting documentation.
+/
+/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+/ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+/ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+/ OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+/ HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+/ INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+/ FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+/ NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+/ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+/
+/ Except as contained in this notice, the name of a copyright holder
+/ shall not be used in advertising or otherwise to promote the sale, use
+/ or other dealings in this Software without prior written authorization
+/ of the copyright holder.
+
+#ifdef INLINE_ASM
+#define FUNCTION_START(f,n) .inline f,n
+#define FUNCTION_END(f) .end
+#else
+#define _ASM
+#include <sys/asm_linkage.h>
+#define FUNCTION_START(f,n) ENTRY(f)
+#define FUNCTION_END(f) SET_SIZE(f)
+#endif
+
+ FUNCTION_START(inb,4)
+ movl (%esp), %edx
+ xorl %eax, %eax
+ inb (%dx)
+ FUNCTION_END(inb)
+
+ FUNCTION_START(inw,4)
+ movl (%esp), %edx
+ xorl %eax, %eax
+ inw (%dx)
+ FUNCTION_END(inw)
+
+ FUNCTION_START(inl,4)
+ movl (%esp), %edx
+ xorl %eax, %eax
+ inl (%dx)
+ FUNCTION_END(inl)
+
+ FUNCTION_START(outb,8)
+ movl (%esp), %edx
+ movl 4(%esp), %eax
+ outb (%dx)
+ FUNCTION_END(outb)
+
+ FUNCTION_START(outw,8)
+ movl (%esp), %edx
+ movl 4(%esp), %eax
+ outw (%dx)
+ FUNCTION_END(outw)
+
+ FUNCTION_START(outl,8)
+ movl (%esp), %edx
+ movl 4(%esp), %eax
+ outl (%dx)
+ FUNCTION_END(outl)
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-sparcv8plus.S b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-sparcv8plus.S
new file mode 100644
index 000000000..fb23942ef
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-sparcv8plus.S
@@ -0,0 +1,144 @@
+/* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#ifdef INLINE_ASM
+#define FUNCTION_START(f,n) .inline f,n
+#define FUNCTION_END(f) .end
+#else
+#define _ASM
+#include <sys/asm_linkage.h>
+#define FUNCTION_START(f,n) ENTRY(f)
+#define FUNCTION_END(f) SET_SIZE(f)
+#endif
+
+/* Converted from common/compiler.h gcc inline format to Sun cc inline
+ * format by Kenjiro Tsuji
+ *
+ * The value 0x88 means ASI_PRIMARY_LITTLE.
+ * The store or load to/from the address space will be done
+ * as little-endian. In the original xrog code, the value
+ * is defined as the macro ASI_PL.
+ *
+ * In the original xorg code, "membar #StoreStore|#StoreLoad"
+ * is directly implemented as an instruction "0x8143e00a".
+ *
+ */
+
+ FUNCTION_START(outb, 0)
+ stba %o1, [%o0] 0x88
+ membar #StoreStore|#StoreLoad
+ FUNCTION_END(outb)
+
+ FUNCTION_START(outw, 0)
+ stha %o1, [%o0] 0x88
+ membar #StoreStore|#StoreLoad
+ FUNCTION_END(outw)
+
+ FUNCTION_START(outl, 0)
+ sta %o1, [%o0] 0x88
+ membar #StoreStore|#StoreLoad
+ FUNCTION_END(outl)
+
+ FUNCTION_START(inb, 0)
+ lduba [%o0] 0x88, %o0
+ FUNCTION_END(inb)
+
+ FUNCTION_START(inw, 0)
+ lduha [%o0] 0x88, %o0
+ FUNCTION_END(inw)
+
+ FUNCTION_START(inl, 0)
+ lda [%o0] 0x88, %o0
+ FUNCTION_END(inl)
+
+ FUNCTION_START(xf86ReadMmio8, 0)
+ lduba [%o0 + %o1] 0x88, %o0
+ FUNCTION_END(xf86ReadMmio8)
+
+ FUNCTION_START(xf86ReadMmio16Be, 0)
+ lduh [%o0 + %o1], %o0
+ FUNCTION_END(xf86ReadMmio16Be)
+
+ FUNCTION_START(xf86ReadMmio16Le, 0)
+ lduha [%o0 + %o1] 0x88, %o0
+ FUNCTION_END(xf86ReadMmio16Le)
+
+ FUNCTION_START(xf86ReadMmio32Be, 0)
+ ld [%o0 + %o1], %o0
+ FUNCTION_END(xf86ReadMmio32Be)
+
+ FUNCTION_START(xf86ReadMmio32Le, 0)
+ lda [%o0 + %o1] 0x88, %o0
+ FUNCTION_END(xf86ReadMmio32Le)
+
+ FUNCTION_START(xf86WriteMmio8, 0)
+ stba %o2, [%o0 + %o1] 0x88
+ membar #StoreStore|#StoreLoad
+ FUNCTION_END(xf86WriteMmio8)
+
+ FUNCTION_START(xf86WriteMmio16Be, 0)
+ sth %o2, [%o0 + %o1]
+ membar #StoreStore|#StoreLoad
+ FUNCTION_END(xf86WriteMmio16Be)
+
+ FUNCTION_START(xf86WriteMmio16Le, 0)
+ stha %o2, [%o0 + %o1] 0x88
+ membar #StoreStore|#StoreLoad
+ FUNCTION_END(xf86WriteMmio16Le)
+
+ FUNCTION_START(xf86WriteMmio32Be, 0)
+ st %o2, [%o0 + %o1]
+ membar #StoreStore|#StoreLoad
+ FUNCTION_END(xf86WriteMmio32Be)
+
+ FUNCTION_START(xf86WriteMmio32Le, 0)
+ sta %o2, [%o0 + %o1] 0x88
+ membar #StoreStore|#StoreLoad
+ FUNCTION_END(xf86WriteMmio32Le)
+
+ FUNCTION_START(xf86WriteMmio8NB, 0)
+ add %o0, %o1, %o0
+ stba %o2, [%o0] 0x88
+ FUNCTION_END(xf86WriteMmio8NB)
+
+ FUNCTION_START(xf86WriteMmio16BeNB, 0)
+ sth %o2, [%o0 + %o1]
+ FUNCTION_END(xf86WriteMmio16BeNB)
+
+ FUNCTION_START(xf86WriteMmio16LeNB, 0)
+ stha %o2, [%o0 + %o1] 0x88
+ FUNCTION_END(xf86WriteMmio16LeNB)
+
+ FUNCTION_START(xf86WriteMmio32BeNB, 0)
+ st %o2, [%o0 + %o1]
+ FUNCTION_END(xf86WriteMmio32BeNB)
+
+ FUNCTION_START(xf86WriteMmio32LeNB, 0)
+ sta %o2, [%o0 + %o1] 0x88
+ FUNCTION_END(xf86WriteMmio32LeNB)
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_agp.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_agp.c
new file mode 100644
index 000000000..0460f1299
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_agp.c
@@ -0,0 +1,339 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_agp.c,v 1.5 2005/08/24 22:37:15 alanc Exp $ */
+/*
+ * Abstraction of the AGP GART interface.
+ *
+ * This version is for Solaris.
+ *
+ * Copyright © 2000 VA Linux Systems, Inc.
+ * Copyright © 2001 The XFree86 Project, Inc.
+ */
+/* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#pragma ident "@(#)sun_agp.c 1.1 05/04/04 SMI"
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86_OSproc.h"
+#include <unistd.h>
+#include <sys/ioccom.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include "agpgart.h"
+
+#ifndef AGP_DEVICE
+#define AGP_DEVICE "/dev/agpgart"
+#endif
+/* AGP page size is independent of the host page size. */
+#ifndef AGP_PAGE_SIZE
+#define AGP_PAGE_SIZE 4096
+#endif
+
+static int gartFd = -1;
+static int acquiredScreen = -1;
+static Bool initDone = FALSE;
+/*
+ * Close /dev/agpgart. This frees all associated memory allocated during
+ * this server generation.
+ */
+Bool
+xf86GARTCloseScreen(int screenNum)
+{
+ if (gartFd != -1) {
+ close(gartFd);
+ acquiredScreen = -1;
+ gartFd = -1;
+ initDone = FALSE;
+
+ xf86DrvMsg(screenNum, X_INFO,
+ "xf86GARTCloseScreen: device closed successfully\n");
+
+ }
+ return TRUE;
+}
+
+/*
+ * Open /dev/agpgart. Keep it open until xf86GARTCloseScreen is called.
+ */
+static Bool
+GARTInit(int screenNum)
+{
+ if (initDone)
+ return (gartFd != -1);
+
+ if (gartFd == -1)
+ gartFd = open(AGP_DEVICE, O_RDWR);
+ else
+ return FALSE;
+
+ if (gartFd == -1) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "GARTInit: Unable to open " AGP_DEVICE " (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+
+ initDone = TRUE;
+ xf86DrvMsg(screenNum, X_INFO,
+ "GARTInit: " AGP_DEVICE " opened successfully\n");
+
+ return TRUE;
+}
+
+Bool
+xf86AgpGARTSupported(void)
+{
+ return (GARTInit(-1));
+
+}
+
+AgpInfoPtr
+xf86GetAGPInfo(int screenNum)
+{
+ agp_info_t agpinf;
+ AgpInfoPtr info;
+
+ if (!GARTInit(screenNum))
+ return NULL;
+
+ if ((info = xcalloc(sizeof(AgpInfo), 1)) == NULL) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86GetAGPInfo: Failed to allocate AgpInfo\n");
+ return NULL;
+ }
+
+ if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
+ strerror(errno));
+ return NULL;
+ }
+
+ info->bridgeId = agpinf.agpi_devid;
+ info->agpMode = agpinf.agpi_mode;
+ info->base = agpinf.agpi_aperbase;
+ info->size = agpinf.agpi_apersize;
+ info->totalPages = (unsigned long)agpinf.agpi_pgtotal;
+ info->systemPages = (unsigned long)agpinf.agpi_pgsystem;
+ info->usedPages = (unsigned long)agpinf.agpi_pgused;
+
+ return info;
+}
+
+Bool
+xf86AcquireGART(int screenNum)
+{
+
+ if (!GARTInit(screenNum))
+ return FALSE;
+
+ if (acquiredScreen != screenNum) {
+ if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "xf86AcquireGART: AGPIOC_ACQUIRE failed (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+ acquiredScreen = screenNum;
+ xf86DrvMsg(screenNum, X_INFO,
+ "xf86AcquireGART: AGPIOC_ACQUIRE succeeded\n");
+ }
+ return TRUE;
+}
+
+Bool
+xf86ReleaseGART(int screenNum)
+{
+
+ if (!GARTInit(screenNum))
+ return FALSE;
+
+ if (acquiredScreen == screenNum) {
+ /*
+ * The FreeBSD agp driver removes allocations on release.
+ * The Solaris driver doesn't. xf86ReleaseGART() is expected
+ * to give up access to the GART, but not to remove any
+ * allocations.
+ */
+
+ if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "xf86ReleaseGART: AGPIOC_RELEASE failed (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+ acquiredScreen = -1;
+ xf86DrvMsg(screenNum, X_INFO,
+ "xf86ReleaseGART: AGPIOC_RELEASE succeeded\n");
+ return TRUE;
+ }
+ return FALSE;
+}
+
+int
+xf86AllocateGARTMemory(int screenNum, unsigned long size, int type,
+ unsigned long *physical)
+{
+ agp_allocate_t alloc;
+ int pages;
+
+ /*
+ * Allocates "size" bytes of GART memory (rounds up to the next
+ * page multiple) or type "type". A handle (key) for the allocated
+ * memory is returned. On error, the return value is -1.
+ * "size" should be larger than 0, or AGPIOC_ALLOCATE ioctl will
+ * return error.
+ */
+
+ if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
+ return -1;
+
+ pages = (size / AGP_PAGE_SIZE);
+ if (size % AGP_PAGE_SIZE != 0)
+ pages++;
+
+ alloc.agpa_pgcount = pages;
+ alloc.agpa_type = type;
+
+ if (ioctl(gartFd, AGPIOC_ALLOCATE, &alloc) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86AllocateGARTMemory: "
+ "allocation of %d pages failed\n\t(%s)\n", pages,
+ strerror(errno));
+ return -1;
+ }
+
+ if (physical)
+ *physical = (unsigned long)alloc.agpa_physical;
+
+ return alloc.agpa_key;
+}
+
+Bool
+xf86DeallocateGARTMemory(int screenNum, int key)
+{
+ if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
+ return FALSE;
+
+ if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *)key) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86DeAllocateGARTMemory: "
+ "deallocation of gart memory with key %d failed\n"
+ "\t(%s)\n", key, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Bind GART memory with "key" at "offset" */
+Bool
+xf86BindGARTMemory(int screenNum, int key, unsigned long offset)
+{
+ agp_bind_t bind;
+ int pageOffset;
+
+ if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
+ return FALSE;
+
+ if (offset % AGP_PAGE_SIZE != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: "
+ "offset (0x%lx) is not page-aligned (%d)\n",
+ offset, AGP_PAGE_SIZE);
+ return FALSE;
+ }
+ pageOffset = offset / AGP_PAGE_SIZE;
+
+ xf86DrvMsgVerb(screenNum, X_INFO, 3,
+ "xf86BindGARTMemory: bind key %d at 0x%08lx "
+ "(pgoffset %d)\n", key, offset, pageOffset);
+
+ bind.agpb_pgstart = pageOffset;
+ bind.agpb_key = key;
+
+ if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: "
+ "binding of gart memory with key %d\n"
+ "\tat offset 0x%lx failed (%s)\n",
+ key, offset, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Unbind GART memory with "key" */
+Bool
+xf86UnbindGARTMemory(int screenNum, int key)
+{
+ agp_unbind_t unbind;
+
+ if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
+ return FALSE;
+
+ unbind.agpu_pri = 0;
+ unbind.agpu_key = key;
+
+ if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86UnbindGARTMemory: "
+ "unbinding of gart memory with key %d "
+ "failed (%s)\n", key, strerror(errno));
+ return FALSE;
+ }
+
+ xf86DrvMsgVerb(screenNum, X_INFO, 3,
+ "xf86UnbindGARTMemory: unbind key %d\n", key);
+
+ return TRUE;
+}
+
+
+/* XXX Interface may change. */
+Bool
+xf86EnableAGP(int screenNum, CARD32 mode)
+{
+ agp_setup_t setup;
+
+ if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
+ return FALSE;
+
+ setup.agps_mode = mode;
+ if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86EnableAGP: "
+ "AGPIOC_SETUP with mode %x failed (%s)\n",
+ mode, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_bios.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_bios.c
new file mode 100644
index 000000000..8319de04e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_bios.c
@@ -0,0 +1,104 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_bios.c,v 1.2tsi Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ * Copyright 1999 by David Holland <davidh@iquest.net>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the names of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
+ * SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef i386
+#define _NEED_SYSI86
+#endif
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+extern char *apertureDevName;
+
+/*
+ * Read BIOS via mmap()ing physical memory.
+ */
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ int fd;
+ unsigned char *ptr;
+ char solx86_vtname[20];
+ int psize;
+ int mlen;
+
+ /*
+ * Solaris 2.1 x86 SVR4 (10/27/93)
+ * The server must treat the virtual terminal device file
+ * as the standard SVR4 /dev/pmem. By default, then used VT
+ * is considered the "default" file to open.
+ *
+ * Solaris 2.8 x86 (7/26/99) - DWH
+ *
+ * Use /dev/xsvc for everything.
+ */
+ psize = xf86getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+#if defined(i386) && !defined(__SOL8__)
+ if (Base >= 0xA0000 && Base + mlen < 0xFFFFF && xf86Info.vtno >= 0)
+ sprintf(solx86_vtname, "/dev/vt%02d", xf86Info.vtno);
+ else
+#endif
+ {
+ if (!xf86LinearVidMem())
+ FatalError("xf86ReadBIOS: Could not mmap BIOS"
+ " [a=%lx]\n", Base);
+ sprintf(solx86_vtname, apertureDevName);
+ }
+
+ if ((fd = open(solx86_vtname, O_RDONLY)) < 0)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
+ solx86_vtname, strerror(errno));
+ return(-1);
+ }
+ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
+ MAP_SHARED, fd, (off_t)Base);
+ if (ptr == MAP_FAILED)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed "
+ "[0x%08lx, 0x%04x]\n",
+ solx86_vtname, Base, mlen);
+ close(fd);
+ return -1;
+ }
+
+ (void)memcpy(Buf, (void *)(ptr + Offset), Len);
+ (void)munmap((caddr_t)ptr, mlen);
+ (void)close(fd);
+
+ return Len;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c
new file mode 100644
index 000000000..b2fc3a41e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c
@@ -0,0 +1,393 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c,v 1.5 2001/11/25 13:51:24 tsi Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ * Copyright 1999 by David Holland <davidh@iquest.net>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the names of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c,v 1.5 2005/07/03 07:01:36 daniels Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#if defined(__i386) || defined(__x86)
+# include <sys/kd.h>
+#endif
+
+static Bool KeepTty = FALSE;
+static Bool Protect0 = FALSE;
+#ifdef HAS_USL_VTS
+static int VTnum = -1;
+static int xf86StartVT = -1;
+#endif
+
+#if defined(__SOL8__) || !defined(__i386)
+static char fb_dev[PATH_MAX] = "/dev/fb";
+#else
+static char fb_dev[PATH_MAX] = "/dev/console";
+#endif
+
+void
+xf86OpenConsole(void)
+{
+#ifdef HAS_USL_VTS
+ int fd, i;
+ struct vt_mode VT;
+ struct vt_stat vtinfo;
+ int FreeVTslot;
+ MessageType from = X_PROBED;
+#endif
+
+ if (serverGeneration == 1)
+ {
+ /* Check if we're run with euid==0 */
+ if (geteuid() != 0)
+ FatalError("xf86OpenConsole: Server must be suid root\n");
+
+ /* Protect page 0 to help find NULL dereferencing */
+ /* mprotect() doesn't seem to work */
+ if (Protect0)
+ {
+ int fd = -1;
+
+ if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: cannot open /dev/zero (%s)\n",
+ strerror(errno));
+ }
+ else
+ {
+ if ((int)mmap(0, 0x1000, PROT_NONE,
+ MAP_FIXED | MAP_SHARED, fd, 0) == -1)
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: failed to protect page 0 (%s)\n",
+ strerror(errno));
+
+ close(fd);
+ }
+ }
+
+#ifdef HAS_USL_VTS
+
+ /*
+ * Setup the virtual terminal manager
+ */
+ if (VTnum != -1)
+ {
+ xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
+ }
+ else
+ {
+ if ((fd = open("/dev/vt00",O_RDWR,0)) < 0)
+ FatalError("xf86OpenConsole: Cannot open /dev/vt00 (%s)\n",
+ strerror(errno));
+
+ if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
+ FatalError("xf86OpenConsole: Cannot determine current VT\n");
+
+ xf86StartVT = vtinfo.v_active;
+
+ /*
+ * There is a SEVERE problem with x86's VT's. The VT_OPENQRY
+ * ioctl() will panic the entire system if all 8 (7 VT's+Console)
+ * terminals are used. The only other way I've found to determine
+ * if there is a free VT is to try activating all the the available
+ * VT's and see if they all succeed - if they do, there there is no
+ * free VT, and the Xserver cannot continue without panic'ing the
+ * system. (It's ugly, but it seems to work.) Note there is a
+ * possible race condition here.
+ *
+ * David Holland 2/23/94
+ */
+
+ FreeVTslot = 0;
+ for (i = 7; (i >= 0) && !FreeVTslot; i--)
+ if (ioctl(fd, VT_ACTIVATE, i) != 0)
+ FreeVTslot = 1;
+
+ if (!FreeVTslot ||
+ (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
+ (xf86Info.vtno == -1))
+ FatalError("xf86OpenConsole: Cannot find a free VT\n");
+
+ close(fd);
+ }
+
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+
+ sprintf(fb_dev, "/dev/vt%02d", xf86Info.vtno); /* Solaris 2.1 x86 */
+
+#endif /* HAS_USL_VTS */
+
+ if (!KeepTty)
+ setpgrp();
+
+ if (((xf86Info.consoleFd = open(fb_dev, O_RDWR | O_NDELAY, 0)) < 0))
+ FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
+ fb_dev, strerror(errno));
+
+#ifdef HAS_USL_VTS
+
+ /* Change ownership of the vt */
+ chown(fb_dev, getuid(), getgid());
+
+ /*
+ * Now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
+ FatalError("xf86OpenConsole: VT_GETMODE failed\n");
+
+ signal(SIGUSR1, xf86VTRequest);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
+#endif
+#ifdef KDSETMODE
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
+#endif
+ }
+ else /* serverGeneration != 1 */
+ {
+#ifdef HAS_USL_VTS
+ /*
+ * Now re-get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+
+ /*
+ * If the server doesn't have the VT when the reset occurs,
+ * this is to make sure we don't continue until the activate
+ * signal is received.
+ */
+ if (!xf86Screens[0]->vtSema)
+ sleep(5);
+
+#endif /* HAS_USL_VTS */
+
+ }
+}
+
+void
+xf86CloseConsole(void)
+{
+#ifdef HAS_USL_VTS
+ struct vt_mode VT;
+#endif
+#if defined(__SOL8__) || !defined(i386)
+ int tmp;
+#endif
+
+#if !defined(i386) && !defined(__x86)
+
+ if (!xf86DoProbe && !xf86DoConfigure) {
+ int fd;
+
+ /*
+ * Wipe out framebuffer just like the non-SI Xsun server does. This
+ * could be improved by saving framebuffer contents in
+ * xf86OpenConsole() above and restoring them here. Also, it's unclear
+ * at this point whether this should be done for all framebuffers in
+ * the system, rather than only the console.
+ */
+ if ((fd = open("/dev/fb", O_RDWR, 0)) < 0) {
+ xf86Msg(X_WARNING,
+ "xf86CloseConsole(): unable to open framebuffer (%s)\n",
+ strerror(errno));
+ } else {
+ struct fbgattr fbattr;
+
+ if ((ioctl(fd, FBIOGATTR, &fbattr) < 0) &&
+ (ioctl(fd, FBIOGTYPE, &fbattr.fbtype) < 0)) {
+ xf86Msg(X_WARNING,
+ "xf86CloseConsole(): unable to retrieve framebuffer"
+ " attributes (%s)\n", strerror(errno));
+ } else {
+ pointer fbdata;
+
+ fbdata = mmap(NULL, fbattr.fbtype.fb_size,
+ PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (fbdata == MAP_FAILED) {
+ xf86Msg(X_WARNING,
+ "xf86CloseConsole(): unable to mmap framebuffer"
+ " (%s)\n", strerror(errno));
+ } else {
+ (void)memset(fbdata, 0, fbattr.fbtype.fb_size);
+ (void)munmap(fbdata, fbattr.fbtype.fb_size);
+ }
+ }
+
+ close(fd);
+ }
+ }
+
+#endif
+
+#ifdef KDSETMODE
+ /* Reset the display back to text mode */
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT);
+#endif
+
+#ifdef HAS_USL_VTS
+
+ /*
+ * Solaris 2.1 x86 doesn't seem to "switch" back to the console when the VT
+ * is relinquished and its mode is reset to auto. Also, Solaris 2.1 seems
+ * to associate vt00 with the console so I've opened the "console" back up
+ * and made it the active vt again in text mode and then closed it. There
+ * must be a better hack for this but I'm not aware of one at this time.
+ *
+ * Doug Anson 11/6/93
+ * danson@lgc.com
+ *
+ * Fixed - 12/5/93 - David Holland - davidh@dorite.use.com
+ * Did the whole thing similarly to the way linux does it
+ */
+
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
+ {
+ VT.mode = VT_AUTO; /* Set default vt handling */
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT);
+ }
+
+ /* Activate the VT that X was started on */
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86StartVT);
+
+#endif /* HAS_USL_VTS */
+
+ close(xf86Info.consoleFd);
+
+#if defined(__SOL8__) || !defined(i386)
+
+ /*
+ * This probably shouldn't be here. However, there is no corresponding
+ * xf86CloseKbd() routine - DWH
+ */
+
+ /* Set the keyboard into "indirect" mode and turn off even translation */
+ tmp = 0;
+ (void) ioctl(xf86Info.kbdFd, KIOCSDIRECT, &tmp);
+ tmp = TR_ASCII;
+ (void) ioctl(xf86Info.kbdFd, KIOCTRANS, &tmp);
+
+ close(xf86Info.kbdFd);
+
+#endif
+}
+
+int
+xf86ProcessArgument(int argc, char **argv, int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful when
+ * debugging, so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty"))
+ {
+ KeepTty = TRUE;
+ return 1;
+ }
+
+ /*
+ * Undocumented flag to protect page 0 from read/write to help catch NULL
+ * pointer dereferences. This is purely a debugging flag.
+ */
+ if (!strcmp(argv[i], "-protect0"))
+ {
+ Protect0 = TRUE;
+ return 1;
+ }
+
+#ifdef HAS_USL_VTS
+
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+ {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
+ {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ }
+
+ return 1;
+ }
+
+#endif /* HAS_USL_VTS */
+
+#if defined(__SOL8__) || !defined(i386)
+
+ if ((i + 1) < argc) {
+ if (!strcmp(argv[i], "-dev")) {
+ strncpy(fb_dev, argv[i+1], PATH_MAX);
+ fb_dev[PATH_MAX - 1] = '\0';
+ return 2;
+ }
+
+ if (!strcmp(argv[i], "-ar1")) {
+ xf86Info.kbdDelay = atoi(argv[i + 1]) * 1000;
+ return 2;
+ }
+
+ if (!strcmp(argv[i], "-ar2")) {
+ xf86Info.kbdRate = atoi(argv[i + 1]) * 1000;
+ return 2;
+ }
+ }
+
+#endif
+
+ return 0;
+}
+
+void xf86UseMsg()
+{
+#ifdef HAS_USL_VTS
+ ErrorF("vtXX Use the specified VT number\n");
+#endif
+#if defined(__SOL8__) || !defined(i386)
+ ErrorF("-dev <fb> Framebuffer device\n");
+ ErrorF("-ar1 <float> Set autorepeat initiate time (sec)\n");
+ ErrorF(" (if not using XKB)\n");
+ ErrorF("-ar2 <float> Set autorepeat interval time (sec)\n");
+ ErrorF(" (if not using XKB)\n");
+#endif
+ ErrorF("-keeptty Don't detach controlling tty\n");
+ ErrorF(" (for debugging only)\n");
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_inout.s b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_inout.s
new file mode 100644
index 000000000..5c0b23ef6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_inout.s
@@ -0,0 +1,124 @@
+/ $XFree86$
+/
+/ Copyright 1994-2001 The XFree86 Project, Inc. All Rights Reserved.
+/
+/ Permission is hereby granted, free of charge, to any person obtaining a copy
+/ of this software and associated documentation files (the "Software"), to deal
+/ in the Software without restriction, including without limitation the rights
+/ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+/ copies of the Software, and to permit persons to whom the Software is
+/ furnished to do so, subject to the following conditions:
+/
+/ The above copyright notice and this permission notice shall be included in
+/ all copies or substantial portions of the Software.
+/
+/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+/ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+/ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+/ XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+/ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+/ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+/
+/ Except as contained in this notice, the name of the XFree86 Project shall not
+/ be used in advertising or otherwise to promote the sale, use or other
+/ dealings in this Software without prior written authorization from the
+/ XFree86 Project.
+/
+/
+/ File: sun_inout.s
+/
+/ Purpose: Provide inb(), inw(), inl(), outb(), outw(), outl() functions
+/ for Solaris x86 using the ProWorks compiler by SunPro
+/
+/ Author: Installed into XFree86 SuperProbe by Doug Anson (danson@lgc.com)
+/ Portions donated to XFree86 by Steve Dever (Steve.Dever@Eng.Sun.Com)
+/
+/ Synopsis: (c callable external declarations)
+/ extern unsigned char inb(int port);
+/ extern unsigned short inw(int port);
+/ extern unsigned long inl(int port);
+/ extern void outb(int port, unsigned char value);
+/ extern void outw(int port, unsigned short value);
+/ extern void outl(int port, unsigned long value);
+/
+
+.file "sunos_inout.s"
+.text
+
+.globl inb
+.globl inw
+.globl inl
+.globl outb
+.globl outw
+.globl outl
+
+/
+/ unsigned char inb(int port);
+/
+.align 4
+inb:
+ movl 4(%esp),%edx
+ subl %eax,%eax
+ inb (%dx)
+ ret
+.type inb,@function
+.size inb,.-inb
+
+/
+/ unsigned short inw(int port);
+/
+.align 4
+inw:
+ movl 4(%esp),%edx
+ subl %eax,%eax
+ inw (%dx)
+ ret
+.type inw,@function
+.size inw,.-inw
+
+/
+/ unsigned long inl(int port);
+/
+.align 4
+inl:
+ movl 4(%esp),%edx
+ inl (%dx)
+ ret
+.type inl,@function
+.size inl,.-inl
+
+/
+/ void outb(int port, unsigned char value);
+/
+.align 4
+outb:
+ movl 4(%esp),%edx
+ movl 8(%esp),%eax
+ outb (%dx)
+ ret
+.type outb,@function
+.size outb,.-outb
+
+/
+/ void outw(int port, unsigned short value);
+/
+.align 4
+outw:
+ movl 4(%esp),%edx
+ movl 8(%esp),%eax
+ outw (%dx)
+ ret
+.type outw,@function
+.size outw,.-outw
+
+/
+/ void outl(int port, unsigned long value);
+/
+.align 4
+outl:
+ movl 4(%esp),%edx
+ movl 8(%esp),%eax
+ outl (%dx)
+ ret
+.type outl,@function
+.size outl,.-outl
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c
new file mode 100644
index 000000000..2269ef3c9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c
@@ -0,0 +1,160 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c,v 1.2 2002/10/11 01:40:37 dawes Exp $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c,v 1.4 2005/08/13 00:11:28 alanc Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Dawes <dawes@xfree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Dawes
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Thomas Roell and
+ * David Dawes makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+/* Solaris support routines for builtin "keyboard" driver */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "sun_kbd.h"
+
+static sunKbdPrivRec sunKeyboardPriv;
+
+_X_HIDDEN void
+xf86KbdInit(void)
+{
+ const char *kbdName = "keyboard";
+ pointer *kbdOptions = NULL;
+ IDevPtr pDev;
+
+ /* There should be a better way to find the keyboard device name, but
+ this seems to work for now. */
+ for (pDev = xf86ConfigLayout.inputs; pDev && pDev->identifier; pDev++) {
+ if (!xf86NameCmp(pDev->driver, "keyboard")) {
+ kbdName = pDev->identifier;
+ kbdOptions = pDev->commonOptions;
+ break;
+ }
+ }
+
+ if (xf86Info.kbdFd < 0) {
+ xf86Info.kbdFd = sunKbdOpen(kbdName, kbdOptions);
+ if (xf86Info.kbdFd < 0) {
+ FatalError("Unable to open keyboard: /dev/kbd\n");
+ }
+ }
+
+ memset(&sunKeyboardPriv, 0, sizeof(sunKbdPrivRec));
+ if (sunKbdInit(&sunKeyboardPriv, xf86Info.kbdFd,
+ kbdName, kbdOptions) != Success) {
+ FatalError("Unable to initialize keyboard driver\n");
+ }
+}
+
+_X_HIDDEN int
+xf86KbdOn(void)
+{
+ if (sunKbdOn(&sunKeyboardPriv) != Success) {
+ FatalError("Enabling keyboard");
+ }
+
+ return xf86Info.kbdFd;
+}
+
+_X_HIDDEN int
+xf86KbdOff(void)
+{
+ if (sunKbdOff(&sunKeyboardPriv) != Success) {
+ FatalError("Disabling keyboard");
+ }
+
+ return xf86Info.kbdFd;
+}
+
+_X_EXPORT void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
+{
+ sunKbdSoundBell(&sunKeyboardPriv, loudness, pitch, duration);
+}
+
+_X_HIDDEN void
+xf86SetKbdLeds(int leds)
+{
+ sunKbdSetLeds(&sunKeyboardPriv, leds);
+}
+
+_X_HIDDEN int
+xf86GetKbdLeds(void)
+{
+ return sunKbdGetLeds(&sunKeyboardPriv);
+}
+
+_X_HIDDEN void
+xf86SetKbdRepeat(char rad)
+{
+ sunKbdSetRepeat(&sunKeyboardPriv, rad);
+}
+
+/*
+ * Lets try reading more than one keyboard event at a time in the hopes that
+ * this will be slightly more efficient. Or we could just try the MicroSoft
+ * method, and forget about efficiency. :-)
+ */
+_X_HIDDEN void
+xf86KbdEvents(void)
+{
+ Firm_event event[64];
+ int nBytes, i;
+
+ /* I certainly hope its not possible to read partial events */
+
+ if ((nBytes = read(xf86Info.kbdFd, (char *)event, sizeof(event))) > 0)
+ {
+ for (i = 0; i < (nBytes / sizeof(Firm_event)); i++)
+ sunPostKbdEvent(sunKeyboardPriv.ktype, &event[i]);
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c
new file mode 100644
index 000000000..0a39155f4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c
@@ -0,0 +1,662 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c,v 1.1 2001/05/28 02:42:31 tsi Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Dawes <dawes@XFree86.org>
+ * Copyright 1999 by David Holland <davidh@iquest.net)
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the names of Thomas Roell, David Dawes, and David Holland not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. Thomas Roell, David Dawes, and
+ * David Holland make no representations about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THOMAS ROELL, DAVID DAWES, AND DAVID HOLLAND DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL THOMAS ROELL, DAVID DAWES, OR DAVID HOLLAND
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/* Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c,v 1.7 2005/08/30 22:34:14 alanc Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSKbd.h"
+#include "sun_kbd.h"
+
+/* Define to provide support for using /dev/audio to ring the bell instead of
+ the keyboard beeper */
+#define AUDIO_BELL
+
+#ifdef AUDIO_BELL
+#include <sys/audio.h>
+#include <sys/uio.h>
+#include <limits.h>
+#include <math.h>
+#include <poll.h>
+#endif
+
+/***************************************************************************
+ * Common implementation of routines shared by "keyboard" driver in sun_io.c
+ * and "kbd" driver (later on in this file)
+ */
+
+#include <sys/stropts.h>
+#include <sys/vuid_event.h>
+#include <sys/kbd.h>
+
+_X_HIDDEN int
+sunKbdOpen(const char *devName, pointer options)
+{
+ int kbdFD;
+ const char *kbdPath = NULL;
+ const char *defaultKbd = "/dev/kbd";
+
+ if (options != NULL) {
+ kbdPath = xf86SetStrOption(options, "Device", NULL);
+ }
+ if (kbdPath == NULL) {
+ kbdPath = defaultKbd;
+ }
+
+ kbdFD = open(kbdPath, O_RDONLY | O_NONBLOCK);
+
+ if (kbdFD == -1) {
+ xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", devName, kbdPath);
+ } else {
+ xf86MsgVerb(X_INFO, 3, "%s: Opened device \"%s\"\n", devName, kbdPath);
+ }
+
+ if ((kbdPath != NULL) && (kbdPath != defaultKbd)) {
+ xfree(kbdPath);
+ }
+ return kbdFD;
+}
+
+
+/*
+ * Save initial keyboard state. This is called at the start of each server
+ * generation.
+ */
+
+_X_HIDDEN int
+sunKbdInit(sunKbdPrivPtr priv, int kbdFD, const char *devName, pointer options)
+{
+ int ktype, klayout, i;
+ const char *ktype_name;
+
+ priv->kbdFD = kbdFD;
+ priv->devName = devName;
+ priv->otranslation = -1;
+ priv->odirect = -1;
+
+ if (options != NULL) {
+ priv->strmod = xf86SetStrOption(options, "StreamsModule", NULL);
+ priv->audioDevName = xf86SetStrOption(options, "BellDevice", NULL);
+
+ if (priv->audioDevName && (priv->audioDevName[0] == '\0')) {
+ xfree(priv->audioDevName);
+ priv->audioDevName = NULL;
+ }
+ } else {
+ priv->strmod = NULL;
+ priv->audioDevName = NULL;
+ }
+
+ if (priv->strmod) {
+ SYSCALL(i = ioctl(priv->kbdFD, I_PUSH, priv->strmod));
+ if (i < 0) {
+ xf86Msg(X_ERROR,
+ "%s: cannot push module '%s' onto keyboard device: %s\n",
+ priv->devName, priv->strmod, strerror(errno));
+ }
+ }
+
+ SYSCALL(i = ioctl(kbdFD, KIOCTYPE, &ktype));
+ if (i < 0) {
+ xf86Msg(X_ERROR, "%s: Unable to determine keyboard type: %s\n",
+ devName, strerror(errno));
+ return BadImplementation;
+ }
+
+ SYSCALL(i = ioctl(kbdFD, KIOCLAYOUT, &klayout));
+ if (i < 0) {
+ xf86Msg(X_ERROR, "%s: Unable to determine keyboard layout: %s\n",
+ devName, strerror(errno));
+ return BadImplementation;
+ }
+
+ switch (ktype) {
+ case KB_SUN3:
+ ktype_name = "Sun Type 3"; break;
+ case KB_SUN4:
+ ktype_name = "Sun Type 4/5/6"; break;
+ case KB_USB:
+ ktype_name = "USB"; break;
+ case KB_PC:
+ ktype_name = "PC"; break;
+ default:
+ ktype_name = "Unknown"; break;
+ }
+
+ xf86Msg(X_PROBED, "%s: Keyboard type: %s (%d)\n",
+ devName, ktype_name, ktype);
+ xf86Msg(X_PROBED, "%s: Keyboard layout: %d\n", devName, klayout);
+
+ priv->ktype = ktype;
+ priv->keyMap = sunGetKbdMapping(ktype);
+ priv->audioState = AB_INITIALIZING;
+ priv->oleds = sunKbdGetLeds(priv);
+
+ return Success;
+}
+
+_X_HIDDEN int
+sunKbdOn(sunKbdPrivPtr priv)
+{
+ int ktrans, kdirect, i;
+
+ SYSCALL(i = ioctl(priv->kbdFD, KIOCGDIRECT, &kdirect));
+ if (i < 0) {
+ xf86Msg(X_ERROR,
+ "%s: Unable to determine keyboard direct setting: %s\n",
+ priv->devName, strerror(errno));
+ return BadImplementation;
+ }
+
+ priv->odirect = kdirect;
+ kdirect = 1;
+
+ SYSCALL(i = ioctl(priv->kbdFD, KIOCSDIRECT, &kdirect));
+ if (i < 0) {
+ xf86Msg(X_ERROR, "%s: Failed turning keyboard direct mode on: %s\n",
+ priv->devName, strerror(errno));
+ return BadImplementation;
+ }
+
+ /* Setup translation */
+
+ SYSCALL(i = ioctl(priv->kbdFD, KIOCGTRANS, &ktrans));
+ if (i < 0) {
+ xf86Msg(X_ERROR,
+ "%s: Unable to determine keyboard translation mode: %s\n",
+ priv->devName, strerror(errno));
+ return BadImplementation;
+ }
+
+ priv->otranslation = ktrans;
+ ktrans = TR_UNTRANS_EVENT;
+
+ SYSCALL(i = ioctl(priv->kbdFD, KIOCTRANS, &ktrans));
+ if (i < 0) {
+ xf86Msg(X_ERROR, "%s: Failed setting keyboard translation mode: %s\n",
+ priv->devName, strerror(errno));
+ return BadImplementation;
+ }
+
+ return Success;
+}
+
+_X_HIDDEN int
+sunKbdOff(sunKbdPrivPtr priv)
+{
+ int i;
+
+ /* restore original state */
+
+ sunKbdSetLeds(priv, priv->oleds);
+
+ if (priv->otranslation != -1) {
+ SYSCALL(i = ioctl(priv->kbdFD, KIOCTRANS, &priv->otranslation));
+ if (i < 0) {
+ xf86Msg(X_ERROR,
+ "%s: Unable to restore keyboard translation mode: %s\n",
+ priv->devName, strerror(errno));
+ return BadImplementation;
+ }
+ priv->otranslation = -1;
+ }
+
+ if (priv->odirect != -1) {
+ SYSCALL(i = ioctl(priv->kbdFD, KIOCSDIRECT, &priv->odirect));
+ if (i < 0) {
+ xf86Msg(X_ERROR,
+ "%s: Unable to restore keyboard direct setting: %s\n",
+ priv->devName, strerror(errno));
+ return BadImplementation;
+ }
+ priv->odirect = -1;
+ }
+
+ if (priv->strmod) {
+ SYSCALL(i = ioctl(priv->kbdFD, I_POP, priv->strmod));
+ if (i < 0) {
+ xf86Msg(X_WARNING,
+ "%s: cannot pop module '%s' off keyboard device: %s\n",
+ priv->devName, priv->strmod, strerror(errno));
+ }
+ }
+
+ return Success;
+}
+
+#ifdef AUDIO_BELL
+
+/* Helper function to ring bell via audio device instead of keyboard beeper */
+
+#define BELL_RATE 48000 /* Samples per second */
+#define BELL_HZ 50 /* Fraction of a second i.e. 1/x */
+#define BELL_MS (1000/BELL_HZ) /* MS */
+#define BELL_SAMPLES (BELL_RATE / BELL_HZ)
+#define BELL_MIN 3 /* Min # of repeats */
+
+static int
+sunKbdAudioBell(sunKbdPrivPtr priv, int loudness, int pitch, int duration)
+{
+ static short samples[BELL_SAMPLES];
+ static short silence[BELL_SAMPLES]; /* "The Sound of Silence" */
+ static int lastFreq;
+ int cnt;
+ int i;
+ int written;
+ int repeats;
+ int freq;
+ audio_info_t audioInfo;
+ struct iovec iov[IOV_MAX];
+ int iovcnt;
+ double ampl, cyclen, phase;
+ int audioFD;
+
+ if ((loudness <= 0) || (pitch <= 0) || (duration <= 0)) {
+ return 0;
+ }
+
+ if ((priv == NULL) || (priv->audioDevName == NULL)) {
+ return -1;
+ }
+
+ if (priv->audioState == AB_INITIALIZING) {
+ priv->audioState = AB_NORMAL;
+ lastFreq = 0;
+ bzero(silence, sizeof(silence));
+ }
+
+ audioFD = open(priv->audioDevName, O_WRONLY | O_NONBLOCK);
+ if (audioFD == -1) {
+ xf86Msg(X_ERROR, "%s: cannot open audio device \"%s\": %s\n",
+ priv->devName, priv->audioDevName, strerror(errno));
+ return -1;
+ }
+
+ freq = pitch;
+ freq = min(freq, (BELL_RATE / 2) - 1);
+ freq = max(freq, 2 * BELL_HZ);
+
+ /*
+ * Ensure full waves per buffer
+ */
+ freq -= freq % BELL_HZ;
+
+ if (freq != lastFreq) {
+ lastFreq = freq;
+ ampl = 16384.0;
+
+ cyclen = (double) freq / (double) BELL_RATE;
+ phase = 0.0;
+
+ for (i = 0; i < BELL_SAMPLES; i++) {
+ samples[i] = (short) (ampl * sin(2.0 * M_PI * phase));
+ phase += cyclen;
+ if (phase >= 1.0)
+ phase -= 1.0;
+ }
+ }
+
+ repeats = (duration + (BELL_MS / 2)) / BELL_MS;
+ repeats = max(repeats, BELL_MIN);
+
+ loudness = max(0, loudness);
+ loudness = min(loudness, 100);
+
+#ifdef DEBUG
+ ErrorF("BELL : freq %d volume %d duration %d repeats %d\n",
+ freq, loudness, duration, repeats);
+#endif
+
+ AUDIO_INITINFO(&audioInfo);
+ audioInfo.play.encoding = AUDIO_ENCODING_LINEAR;
+ audioInfo.play.sample_rate = BELL_RATE;
+ audioInfo.play.channels = 2;
+ audioInfo.play.precision = 16;
+ audioInfo.play.gain = min(AUDIO_MAX_GAIN, AUDIO_MAX_GAIN * loudness / 100);
+
+ if (ioctl(audioFD, AUDIO_SETINFO, &audioInfo) < 0){
+ xf86Msg(X_ERROR,
+ "%s: AUDIO_SETINFO failed on audio device \"%s\": %s\n",
+ priv->devName, priv->audioDevName, strerror(errno));
+ close(audioFD);
+ return -1;
+ }
+
+ iovcnt = 0;
+
+ for (cnt = 0; cnt <= repeats; cnt++) {
+ iov[iovcnt].iov_base = (char *) samples;
+ iov[iovcnt++].iov_len = sizeof(samples);
+ if (cnt == repeats) {
+ /* Insert a bit of silence so that multiple beeps are distinct and
+ * not compressed into a single tone.
+ */
+ iov[iovcnt].iov_base = (char *) silence;
+ iov[iovcnt++].iov_len = sizeof(silence);
+ }
+ if ((iovcnt >= IOV_MAX) || (cnt == repeats)) {
+ written = writev(audioFD, iov, iovcnt);
+
+ if ((written < ((int)(sizeof(samples) * iovcnt)))) {
+ /* audio buffer was full! */
+
+ int naptime;
+
+ if (written == -1) {
+ if (errno != EAGAIN) {
+ xf86Msg(X_ERROR,
+ "%s: writev failed on audio device \"%s\": %s\n",
+ priv->devName, priv->audioDevName,
+ strerror(errno));
+ close(audioFD);
+ return -1;
+ }
+ i = iovcnt;
+ } else {
+ i = ((sizeof(samples) * iovcnt) - written)
+ / sizeof(samples);
+ }
+ cnt -= i;
+
+ /* sleep a little to allow audio buffer to drain */
+ naptime = BELL_MS * i;
+ poll(NULL, 0, naptime);
+
+ i = ((sizeof(samples) * iovcnt) - written) % sizeof(samples);
+ iovcnt = 0;
+ if ((written != -1) && (i > 0)) {
+ iov[iovcnt].iov_base = ((char *) samples) + i;
+ iov[iovcnt++].iov_len = sizeof(samples) - i;
+ }
+ } else {
+ iovcnt = 0;
+ }
+ }
+ }
+
+ close(audioFD);
+ return 0;
+}
+
+#endif /* AUDIO_BELL */
+
+_X_HIDDEN void
+sunKbdSoundBell(sunKbdPrivPtr priv, int loudness, int pitch, int duration)
+{
+ int kbdCmd, i;
+
+ if (loudness && pitch)
+ {
+#ifdef AUDIO_BELL
+ if (priv->audioDevName != NULL) {
+ if (sunKbdAudioBell(priv, loudness, pitch, duration) == 0) {
+ return;
+ }
+ }
+#endif
+
+ kbdCmd = KBD_CMD_BELL;
+
+ SYSCALL(i = ioctl (priv->kbdFD, KIOCCMD, &kbdCmd));
+ if (i < 0) {
+ xf86Msg(X_ERROR, "%s: Failed to activate bell: %s\n",
+ priv->devName, strerror(errno));
+ }
+
+ usleep(duration * loudness * 20);
+
+ kbdCmd = KBD_CMD_NOBELL;
+ SYSCALL(i = ioctl (priv->kbdFD, KIOCCMD, &kbdCmd));
+ if (i < 0) {
+ xf86Msg(X_ERROR, "%s: Failed to deactivate bell: %s\n",
+ priv->devName, strerror(errno));
+ }
+ }
+}
+
+_X_HIDDEN void
+sunKbdSetLeds(sunKbdPrivPtr priv, int leds)
+{
+ int i;
+
+ SYSCALL(i = ioctl(priv->kbdFD, KIOCSLED, &leds));
+ if (i < 0) {
+ xf86Msg(X_ERROR, "%s: Failed to set keyboard LED's: %s\n",
+ priv->devName, strerror(errno));
+ }
+}
+
+_X_HIDDEN int
+sunKbdGetLeds(sunKbdPrivPtr priv)
+{
+ int i, leds = 0;
+
+ SYSCALL(i = ioctl(priv->kbdFD, KIOCGLED, &leds));
+ if (i < 0) {
+ xf86Msg(X_ERROR, "%s: Failed to get keyboard LED's: %s\n",
+ priv->devName, strerror(errno));
+ }
+ return leds;
+}
+
+/* ARGSUSED0 */
+_X_HIDDEN void
+sunKbdSetRepeat(sunKbdPrivPtr priv, char rad)
+{
+ /* Nothing to do */
+}
+
+/***************************************************************************
+ * Routines called from "kbd" driver via proc vectors filled in by
+ * xf86OSKbdPreInit().
+ */
+
+
+static int
+KbdInit(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+
+ return sunKbdInit(priv, pInfo->fd, pInfo->name, pInfo->options);
+}
+
+
+static int
+KbdOn(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+
+ return sunKbdOn(priv);
+}
+
+static int
+KbdOff(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+
+ return sunKbdOff(priv);
+}
+
+
+static void
+SoundKbdBell(InputInfoPtr pInfo, int loudness, int pitch, int duration)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+
+ sunKbdSoundBell(priv, loudness, pitch, duration);
+}
+
+static void
+SetKbdLeds(InputInfoPtr pInfo, int leds)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+ int real_leds = sunKbdGetLeds(priv);
+
+ real_leds &= ~(LED_CAPS_LOCK | LED_NUM_LOCK | LED_SCROLL_LOCK | LED_COMPOSE);
+
+ if (leds & XLED1) real_leds |= LED_CAPS_LOCK;
+ if (leds & XLED2) real_leds |= LED_NUM_LOCK;
+ if (leds & XLED3) real_leds |= LED_SCROLL_LOCK;
+ if (leds & XLED4) real_leds |= LED_COMPOSE;
+
+ sunKbdSetLeds(priv, real_leds);
+}
+
+static int
+GetKbdLeds(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+ int leds = 0;
+ int real_leds = sunKbdGetLeds(priv);
+
+ if (real_leds & LED_CAPS_LOCK) leds |= XLED1;
+ if (real_leds & LED_NUM_LOCK) leds |= XLED2;
+ if (real_leds & LED_SCROLL_LOCK) leds |= XLED3;
+ if (real_leds & LED_COMPOSE) leds |= XLED4;
+
+ return leds;
+}
+
+static void
+SetKbdRepeat(InputInfoPtr pInfo, char rad)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+
+ sunKbdSetRepeat(priv, rad);
+}
+
+static void
+KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ /* Should probably do something better here */
+ xf86KbdGetMapping(pKeySyms, pModMap);
+}
+
+static void
+ReadInput(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+ Firm_event event[64];
+ int nBytes, i;
+
+ /* I certainly hope its not possible to read partial events */
+
+ if ((nBytes = read(pInfo->fd, (char *)event, sizeof(event))) > 0)
+ {
+ for (i = 0; i < (nBytes / sizeof(Firm_event)); i++) {
+ pKbd->PostEvent(pInfo, priv->keyMap[event[i].id],
+ event[i].value == VKEY_DOWN ? TRUE : FALSE);
+ }
+ }
+}
+
+static Bool
+OpenKeyboard(InputInfoPtr pInfo)
+{
+ pInfo->fd = sunKbdOpen(pInfo->name, pInfo->options);
+
+ if (pInfo->fd >= 0) {
+ pInfo->read_input = ReadInput;
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+_X_EXPORT Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = pInfo->private;
+
+ pKbd->KbdInit = KbdInit;
+ pKbd->KbdOn = KbdOn;
+ pKbd->KbdOff = KbdOff;
+ pKbd->Bell = SoundKbdBell;
+ pKbd->SetLeds = SetKbdLeds;
+ pKbd->GetLeds = GetKbdLeds;
+ pKbd->SetKbdRepeat = SetKbdRepeat;
+ pKbd->KbdGetMapping = KbdGetMapping;
+
+ pKbd->RemapScanCode = NULL;
+ pKbd->GetSpecialKey = NULL;
+ pKbd->SpecialKey = NULL;
+
+ pKbd->OpenKeyboard = OpenKeyboard;
+
+ pKbd->vtSwitchSupported = FALSE;
+ pKbd->CustomKeycodes = FALSE;
+
+ pKbd->private = xcalloc(sizeof(sunKbdPrivRec), 1);
+ if (pKbd->private == NULL) {
+ xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
+ return FALSE;
+ } else {
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+ priv->otranslation = -1;
+ priv->odirect = -1;
+ }
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.h
new file mode 100644
index 000000000..ed2824b1f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.h
@@ -0,0 +1,72 @@
+/* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#ifndef _XORG_SUN_KBD_H_
+#define _XORG_SUN_KBD_H_
+
+/*
+ * Keyboard common implementation routines shared by "keyboard" driver
+ * in sun_io.c and "kbd" driver in sun_kbd.c
+ */
+
+typedef struct {
+ int kbdFD;
+ const char * devName;
+ int ktype; /* Keyboard type from KIOCTYPE */
+ Bool kbdActive; /* Have we set kbd modes for X? */
+ int otranslation; /* Original translation mode */
+ int odirect; /* Original "direct" mode setting */
+ unsigned char oleds; /* Original LED state */
+ const char * strmod; /* Streams module pushed on kbd device */
+ const char * audioDevName; /* Audio device path to use for bell
+ or NULL to use keyboard beeper */
+ enum {AB_INITIALIZING, AB_NORMAL} audioState;
+ const unsigned char *keyMap;
+} sunKbdPrivRec, *sunKbdPrivPtr;
+
+/* sun_kbd.c */
+extern int sunKbdOpen (const char *devName, pointer options);
+extern int sunKbdInit (sunKbdPrivPtr priv, int kbdFD,
+ const char *devName, pointer options);
+extern int sunKbdOn (sunKbdPrivPtr priv);
+extern int sunKbdOff (sunKbdPrivPtr priv);
+
+extern void sunKbdSoundBell (sunKbdPrivPtr priv,
+ int loudness, int pitch, int duration);
+
+extern void sunKbdSetLeds (sunKbdPrivPtr priv, int leds);
+extern int sunKbdGetLeds (sunKbdPrivPtr priv);
+extern void sunKbdSetRepeat (sunKbdPrivPtr priv, char rad);
+
+/* sun_kbdEv.c */
+#include <sys/vuid_event.h>
+extern void sunPostKbdEvent (int ktype, Firm_event *event);
+
+extern const unsigned char *sunGetKbdMapping(int ktype);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c
new file mode 100644
index 000000000..dbae7c775
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c
@@ -0,0 +1,892 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c,v 1.5 2003/08/26 19:00:36 tsi Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ * Copyright 1993 by David Dawes <dawes@xfree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the names of Thomas Roell and David Dawes not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. Thomas Roell and David Dawes make no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+ * IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* [JCH-96/01/21] Extended std reverse map to four buttons. */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c,v 1.9 2005/08/16 00:40:25 alanc Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "sun_kbd.h"
+
+#ifdef XINPUT
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "xf86Xinput.h"
+#else
+#include "inputstr.h"
+#endif
+
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+
+#include <sys/kbd.h>
+#include "atKeynames.h"
+
+#ifdef XKB
+extern Bool noXkbExtension;
+#endif
+
+#define XE_POINTER 1
+#define XE_KEYBOARD 2
+
+#ifdef XTESTEXT1
+
+#define XTestSERVER_SIDE
+#include <X11/extensions/xtestext1.h>
+extern short xtest_mousex;
+extern short xtest_mousey;
+extern int on_steal_input;
+extern Bool XTestStealKeyData();
+extern void XTestStealMotionData();
+
+#ifdef XINPUT
+#define ENQUEUE(ev, code, direction, dev_type) \
+ (ev)->u.u.detail = (code); \
+ (ev)->u.u.type = (direction); \
+ if (!on_steal_input || \
+ XTestStealKeyData((ev)->u.u.detail, (ev)->u.u.type, dev_type, \
+ xtest_mousex, xtest_mousey)) \
+ xf86eqEnqueue((ev))
+#else
+#define ENQUEUE(ev, code, direction, dev_type) \
+ (ev)->u.u.detail = (code); \
+ (ev)->u.u.type = (direction); \
+ if (!on_steal_input || \
+ XTestStealKeyData((ev)->u.u.detail, (ev)->u.u.type, dev_type, \
+ xtest_mousex, xtest_mousey)) \
+ mieqEnqueue((ev))
+#endif
+
+#else /* ! XTESTEXT1 */
+
+#ifdef XINPUT
+#define ENQUEUE(ev, code, direction, dev_type) \
+ (ev)->u.u.detail = (code); \
+ (ev)->u.u.type = (direction); \
+ xf86eqEnqueue((ev))
+#else
+#define ENQUEUE(ev, code, direction, dev_type) \
+ (ev)->u.u.detail = (code); \
+ (ev)->u.u.type = (direction); \
+ mieqEnqueue((ev))
+#endif
+
+#endif
+
+static void startautorepeat(long keycode);
+static CARD32 processautorepeat(OsTimerPtr timer, CARD32 now, pointer arg);
+
+static OsTimerPtr sunTimer = NULL;
+
+/* Map the Solaris keycodes to the "XFree86" keycodes. */
+/*
+ * This doesn't seem right. It probably needs to be dependent on a keyboard
+ * type.
+ */
+
+/* Additional Sun Japanese Keyboard Keys not defined in common/atKeynames.h */
+#define KEY_Kanji 0x82
+#define KEY_Execute 0x83
+
+static unsigned char map[256] = {
+#if defined(i386) || defined(__i386) || defined(__i386__) || defined(__x86)
+ KEY_NOTUSED, /* 0 */
+ KEY_Tilde, /* 1 */
+ KEY_1, /* 2 */
+ KEY_2, /* 3 */
+ KEY_3, /* 4 */
+ KEY_4, /* 5 */
+ KEY_5, /* 6 */
+ KEY_6, /* 7 */
+ KEY_7, /* 8 */
+ KEY_8, /* 9 */
+ KEY_9, /* 10 */
+ KEY_0, /* 11 */
+ KEY_Minus, /* 12 */
+ KEY_Equal, /* 13 */
+ 0x7D, /*KEY_P_YEN*/ /* 14 */
+ KEY_BackSpace, /* 15 */
+ KEY_Tab, /* 16 */
+ KEY_Q, /* 17 */
+ KEY_W, /* 18 */
+ KEY_E, /* 19 */
+ KEY_R, /* 20 */
+ KEY_T, /* 21 */
+ KEY_Y, /* 22 */
+ KEY_U, /* 23 */
+ KEY_I, /* 24 */
+ KEY_O, /* 25 */
+ KEY_P, /* 26 */
+ KEY_LBrace, /* 27 */
+ KEY_RBrace, /* 28 */
+ KEY_BSlash, /* 29 */
+ KEY_CapsLock, /* 30 */
+ KEY_A, /* 31 */
+ KEY_S, /* 32 */
+ KEY_D, /* 33 */
+ KEY_F, /* 34 */
+ KEY_G, /* 35 */
+ KEY_H, /* 36 */
+ KEY_J, /* 37 */
+ KEY_K, /* 38 */
+ KEY_L, /* 39 */
+ KEY_SemiColon, /* 40 */
+ KEY_Quote, /* 41 */
+ KEY_UNKNOWN, /* 42 */
+ KEY_Enter, /* 43 */
+ KEY_ShiftL, /* 44 */
+ KEY_Less, /* 45 */
+ KEY_Z, /* 46 */
+ KEY_X, /* 47 */
+ KEY_C, /* 48 */
+ KEY_V, /* 49 */
+ KEY_B, /* 50 */
+ KEY_N, /* 51 */
+ KEY_M, /* 52 */
+ KEY_Comma, /* 53 */
+ KEY_Period, /* 54 */
+ KEY_Slash, /* 55 */
+ KEY_BSlash2, /* 56 */
+ KEY_ShiftR, /* 57 */
+ KEY_LCtrl, /* 58 */
+ KEY_LMeta, /* 59 */
+ KEY_Alt, /* 60 */
+ KEY_Space, /* 61 */
+ KEY_AltLang, /* 62 */
+ KEY_RMeta, /* 63 */
+ KEY_RCtrl, /* 64 */
+ KEY_Menu, /* 65 */
+ KEY_UNKNOWN, /* 66 */
+ KEY_UNKNOWN, /* 67 */
+ KEY_UNKNOWN, /* 68 */
+ KEY_UNKNOWN, /* 69 */
+ KEY_UNKNOWN, /* 70 */
+ KEY_UNKNOWN, /* 71 */
+ KEY_UNKNOWN, /* 72 */
+ KEY_UNKNOWN, /* 73 */
+ KEY_UNKNOWN, /* 74 */
+ KEY_Insert, /* 75 */
+ KEY_Delete, /* 76 */
+ KEY_UNKNOWN, /* 77 */
+ KEY_UNKNOWN, /* 78 */
+ KEY_Left, /* 79 */
+ KEY_Home, /* 80 */
+ KEY_End, /* 81 */
+ KEY_UNKNOWN, /* 82 */
+ KEY_Up, /* 83 */
+ KEY_Down, /* 84 */
+ KEY_PgUp, /* 85 */
+ KEY_PgDown, /* 86 */
+ KEY_UNKNOWN, /* 87 */
+ KEY_UNKNOWN, /* 88 */
+ KEY_Right, /* 89 */
+ KEY_NumLock, /* 90 */
+ KEY_KP_7, /* 91 */
+ KEY_KP_4, /* 92 */
+ KEY_KP_1, /* 93 */
+ KEY_UNKNOWN, /* 94 */
+ KEY_KP_Divide, /* 95 */
+ KEY_KP_8, /* 96 */
+ KEY_KP_5, /* 97 */
+ KEY_KP_2, /* 98 */
+ KEY_KP_0, /* 99 */
+ KEY_KP_Multiply, /* 100 */
+ KEY_KP_9, /* 101 */
+ KEY_KP_6, /* 102 */
+ KEY_KP_3, /* 103 */
+ KEY_KP_Decimal, /* 104 */
+ KEY_KP_Minus, /* 105 */
+ KEY_KP_Plus, /* 106 */
+ KEY_UNKNOWN, /* 107 */
+ KEY_KP_Enter, /* 108 */
+ KEY_UNKNOWN, /* 109 */
+ KEY_Escape, /* 110 */
+ KEY_UNKNOWN, /* 111 */
+ KEY_F1, /* 112 */
+ KEY_F2, /* 113 */
+ KEY_F3, /* 114 */
+ KEY_F4, /* 115 */
+ KEY_F5, /* 116 */
+ KEY_F6, /* 117 */
+ KEY_F7, /* 118 */
+ KEY_F8, /* 119 */
+ KEY_F9, /* 120 */
+ KEY_F10, /* 121 */
+ KEY_F11, /* 122 */
+ KEY_F12, /* 123 */
+ KEY_Print, /* 124 */
+ KEY_ScrollLock, /* 125 */
+ KEY_Pause, /* 126 */
+ KEY_UNKNOWN, /* 127 */
+ KEY_UNKNOWN, /* 128 */
+ KEY_UNKNOWN, /* 129 */
+ KEY_UNKNOWN, /* 130 */
+ KEY_NFER, /* 131 */
+ KEY_XFER, /* 132 */
+ KEY_HKTG, /* 133 */
+ KEY_UNKNOWN, /* 134 */
+#elif defined(sparc) || defined(__sparc__)
+ KEY_UNKNOWN, /* 0x00 */
+ KEY_UNKNOWN, /* 0x01 */
+ KEY_UNKNOWN, /* 0x02 */
+ KEY_UNKNOWN, /* 0x03 */
+ KEY_UNKNOWN, /* 0x04 */
+ KEY_F1, /* 0x05 */
+ KEY_F2, /* 0x06 */
+ KEY_F10, /* 0x07 */
+ KEY_F3, /* 0x08 */
+ KEY_F11, /* 0x09 */
+ KEY_F4, /* 0x0A */
+ KEY_F12, /* 0x0B */
+ KEY_F5, /* 0x0C */
+ KEY_UNKNOWN, /* 0x0D */
+ KEY_F6, /* 0x0E */
+ KEY_UNKNOWN, /* 0x0F */
+ KEY_F7, /* 0x10 */
+ KEY_F8, /* 0x11 */
+ KEY_F9, /* 0x12 */
+ KEY_Alt, /* 0x13 */
+ KEY_Up, /* 0x14 */
+ KEY_Pause, /* 0x15 */
+ KEY_SysReqest, /* 0x16 */
+ KEY_ScrollLock, /* 0x17 */
+ KEY_Left, /* 0x18 */
+ KEY_UNKNOWN, /* 0x19 */
+ KEY_UNKNOWN, /* 0x1A */
+ KEY_Down, /* 0x1B */
+ KEY_Right, /* 0x1C */
+ KEY_Escape, /* 0x1D */
+ KEY_1, /* 0x1E */
+ KEY_2, /* 0x1F */
+ KEY_3, /* 0x20 */
+ KEY_4, /* 0x21 */
+ KEY_5, /* 0x22 */
+ KEY_6, /* 0x23 */
+ KEY_7, /* 0x24 */
+ KEY_8, /* 0x25 */
+ KEY_9, /* 0x26 */
+ KEY_0, /* 0x27 */
+ KEY_Minus, /* 0x28 */
+ KEY_Equal, /* 0x29 */
+ KEY_Tilde, /* 0x2A */
+ KEY_BackSpace, /* 0x2B */
+ KEY_Insert, /* 0x2C */
+ KEY_UNKNOWN, /* 0x2D */
+ KEY_KP_Divide, /* 0x2E */
+ KEY_KP_Multiply, /* 0x2F */
+ KEY_UNKNOWN, /* 0x30 */
+ KEY_UNKNOWN, /* 0x31 */
+ KEY_KP_Decimal, /* 0x32 */
+ KEY_UNKNOWN, /* 0x33 */
+ KEY_Home, /* 0x34 */
+ KEY_Tab, /* 0x35 */
+ KEY_Q, /* 0x36 */
+ KEY_W, /* 0x37 */
+ KEY_E, /* 0x38 */
+ KEY_R, /* 0x39 */
+ KEY_T, /* 0x3A */
+ KEY_Y, /* 0x3B */
+ KEY_U, /* 0x3C */
+ KEY_I, /* 0x3D */
+ KEY_O, /* 0x3E */
+ KEY_P, /* 0x3F */
+ KEY_LBrace, /* 0x40 */
+ KEY_RBrace, /* 0x41 */
+ KEY_Delete, /* 0x42 */
+ KEY_UNKNOWN, /* 0x43 */
+ KEY_KP_7, /* 0x44 */
+ KEY_KP_8, /* 0x45 */
+ KEY_KP_9, /* 0x46 */
+ KEY_KP_Minus, /* 0x47 */
+ KEY_UNKNOWN, /* 0x48 */
+ KEY_UNKNOWN, /* 0x49 */
+ KEY_End, /* 0x4A */
+ KEY_UNKNOWN, /* 0x4B */
+ KEY_LCtrl, /* 0x4C */
+ KEY_A, /* 0x4D */
+ KEY_S, /* 0x4E */
+ KEY_D, /* 0x4F */
+ KEY_F, /* 0x50 */
+ KEY_G, /* 0x51 */
+ KEY_H, /* 0x52 */
+ KEY_J, /* 0x53 */
+ KEY_K, /* 0x54 */
+ KEY_L, /* 0x55 */
+ KEY_SemiColon, /* 0x56 */
+ KEY_Quote, /* 0x57 */
+ KEY_BSlash, /* 0x58 */
+ KEY_Enter, /* 0x59 */
+ KEY_KP_Enter, /* 0x5A */
+ KEY_KP_4, /* 0x5B */
+ KEY_KP_5, /* 0x5C */
+ KEY_KP_6, /* 0x5D */
+ KEY_KP_0, /* 0x5E */
+ KEY_UNKNOWN, /* 0x5F */
+ KEY_PgUp, /* 0x60 */
+ KEY_UNKNOWN, /* 0x61 */
+ KEY_NumLock, /* 0x62 */
+ KEY_ShiftL, /* 0x63 */
+ KEY_Z, /* 0x64 */
+ KEY_X, /* 0x65 */
+ KEY_C, /* 0x66 */
+ KEY_V, /* 0x67 */
+ KEY_B, /* 0x68 */
+ KEY_N, /* 0x69 */
+ KEY_M, /* 0x6A */
+ KEY_Comma, /* 0x6B */
+ KEY_Period, /* 0x6C */
+ KEY_Slash, /* 0x6D */
+ KEY_ShiftR, /* 0x6E */
+ KEY_UNKNOWN, /* 0x6F */
+ KEY_KP_1, /* 0x70 */
+ KEY_KP_2, /* 0x71 */
+ KEY_KP_3, /* 0x72 */
+ KEY_UNKNOWN, /* 0x73 */
+ KEY_UNKNOWN, /* 0x74 */
+ KEY_UNKNOWN, /* 0x75 */
+ KEY_UNKNOWN, /* 0x76 */
+ KEY_CapsLock, /* 0x77 */
+ KEY_LMeta, /* 0x78 */
+ KEY_Space, /* 0x79 */
+ KEY_RMeta, /* 0x7A */
+ KEY_PgDown, /* 0x7B */
+ KEY_UNKNOWN, /* 0x7C */
+ KEY_KP_Plus, /* 0x7D */
+ KEY_UNKNOWN, /* 0x7E */
+ KEY_UNKNOWN, /* 0x7F */
+#endif
+ /* The rest default to KEY_UNKNOWN */
+};
+
+#if defined(KB_USB)
+static unsigned char usbmap[256] = {
+/*
+ * partially taken from ../bsd/bsd_KbdMap.c
+ *
+ * added keycodes for Sun special keys (left function keys, audio control)
+ */
+ /* 0 */ KEY_NOTUSED,
+ /* 1 */ KEY_NOTUSED,
+ /* 2 */ KEY_NOTUSED,
+ /* 3 */ KEY_NOTUSED,
+ /* 4 */ KEY_A,
+ /* 5 */ KEY_B,
+ /* 6 */ KEY_C,
+ /* 7 */ KEY_D,
+ /* 8 */ KEY_E,
+ /* 9 */ KEY_F,
+ /* 10 */ KEY_G,
+ /* 11 */ KEY_H,
+ /* 12 */ KEY_I,
+ /* 13 */ KEY_J,
+ /* 14 */ KEY_K,
+ /* 15 */ KEY_L,
+ /* 16 */ KEY_M,
+ /* 17 */ KEY_N,
+ /* 18 */ KEY_O,
+ /* 19 */ KEY_P,
+ /* 20 */ KEY_Q,
+ /* 21 */ KEY_R,
+ /* 22 */ KEY_S,
+ /* 23 */ KEY_T,
+ /* 24 */ KEY_U,
+ /* 25 */ KEY_V,
+ /* 26 */ KEY_W,
+ /* 27 */ KEY_X,
+ /* 28 */ KEY_Y,
+ /* 29 */ KEY_Z,
+ /* 30 */ KEY_1, /* 1 !*/
+ /* 31 */ KEY_2, /* 2 @ */
+ /* 32 */ KEY_3, /* 3 # */
+ /* 33 */ KEY_4, /* 4 $ */
+ /* 34 */ KEY_5, /* 5 % */
+ /* 35 */ KEY_6, /* 6 ^ */
+ /* 36 */ KEY_7, /* 7 & */
+ /* 37 */ KEY_8, /* 8 * */
+ /* 38 */ KEY_9, /* 9 ( */
+ /* 39 */ KEY_0, /* 0 ) */
+ /* 40 */ KEY_Enter, /* Return */
+ /* 41 */ KEY_Escape, /* Escape */
+ /* 42 */ KEY_BackSpace, /* Backspace Delete */
+ /* 43 */ KEY_Tab, /* Tab */
+ /* 44 */ KEY_Space, /* Space */
+ /* 45 */ KEY_Minus, /* - _ */
+ /* 46 */ KEY_Equal, /* = + */
+ /* 47 */ KEY_LBrace, /* [ { */
+ /* 48 */ KEY_RBrace, /* ] } */
+ /* 49 */ KEY_BSlash, /* \ | */
+ /* 50 */ KEY_BSlash, /* \ _ # ~ on some keyboards */
+ /* 51 */ KEY_SemiColon, /* ; : */
+ /* 52 */ KEY_Quote, /* ' " */
+ /* 53 */ KEY_Tilde, /* ` ~ */
+ /* 54 */ KEY_Comma, /* , < */
+ /* 55 */ KEY_Period, /* . > */
+ /* 56 */ KEY_Slash, /* / ? */
+ /* 57 */ KEY_CapsLock, /* Caps Lock */
+ /* 58 */ KEY_F1, /* F1 */
+ /* 59 */ KEY_F2, /* F2 */
+ /* 60 */ KEY_F3, /* F3 */
+ /* 61 */ KEY_F4, /* F4 */
+ /* 62 */ KEY_F5, /* F5 */
+ /* 63 */ KEY_F6, /* F6 */
+ /* 64 */ KEY_F7, /* F7 */
+ /* 65 */ KEY_F8, /* F8 */
+ /* 66 */ KEY_F9, /* F9 */
+ /* 67 */ KEY_F10, /* F10 */
+ /* 68 */ KEY_F11, /* F11 */
+ /* 69 */ KEY_F12, /* F12 */
+ /* 70 */ KEY_Print, /* PrintScrn SysReq */
+ /* 71 */ KEY_ScrollLock, /* Scroll Lock */
+ /* 72 */ KEY_Pause, /* Pause Break */
+ /* 73 */ KEY_Insert, /* Insert XXX Help on some Mac Keyboards */
+ /* 74 */ KEY_Home, /* Home */
+ /* 75 */ KEY_PgUp, /* Page Up */
+ /* 76 */ KEY_Delete, /* Delete */
+ /* 77 */ KEY_End, /* End */
+ /* 78 */ KEY_PgDown, /* Page Down */
+ /* 79 */ KEY_Right, /* Right Arrow */
+ /* 80 */ KEY_Left, /* Left Arrow */
+ /* 81 */ KEY_Down, /* Down Arrow */
+ /* 82 */ KEY_Up, /* Up Arrow */
+ /* 83 */ KEY_NumLock, /* Num Lock */
+ /* 84 */ KEY_KP_Divide, /* Keypad / */
+ /* 85 */ KEY_KP_Multiply, /* Keypad * */
+ /* 86 */ KEY_KP_Minus, /* Keypad - */
+ /* 87 */ KEY_KP_Plus, /* Keypad + */
+ /* 88 */ KEY_KP_Enter, /* Keypad Enter */
+ /* 89 */ KEY_KP_1, /* Keypad 1 End */
+ /* 90 */ KEY_KP_2, /* Keypad 2 Down */
+ /* 91 */ KEY_KP_3, /* Keypad 3 Pg Down */
+ /* 92 */ KEY_KP_4, /* Keypad 4 Left */
+ /* 93 */ KEY_KP_5, /* Keypad 5 */
+ /* 94 */ KEY_KP_6, /* Keypad 6 */
+ /* 95 */ KEY_KP_7, /* Keypad 7 Home */
+ /* 96 */ KEY_KP_8, /* Keypad 8 Up */
+ /* 97 */ KEY_KP_9, /* KEypad 9 Pg Up */
+ /* 98 */ KEY_KP_0, /* Keypad 0 Ins */
+ /* 99 */ KEY_KP_Decimal, /* Keypad . Del */
+ /* 100 */ KEY_Less, /* < > on some keyboards */
+ /* 101 */ KEY_Menu, /* Menu */
+ /* 102 */ KEY_Power, /* Sun: Power */
+ /* 103 */ KEY_KP_Equal, /* Keypad = on Mac keyboards */
+ /* 104 */ KEY_NOTUSED,
+ /* 105 */ KEY_NOTUSED,
+ /* 106 */ KEY_NOTUSED,
+ /* 107 */ KEY_NOTUSED,
+ /* 108 */ KEY_NOTUSED,
+ /* 109 */ KEY_NOTUSED,
+ /* 110 */ KEY_NOTUSED,
+ /* 111 */ KEY_NOTUSED,
+ /* 112 */ KEY_NOTUSED,
+ /* 113 */ KEY_NOTUSED,
+ /* 114 */ KEY_NOTUSED,
+ /* 115 */ KEY_NOTUSED,
+ /* 116 */ KEY_L7, /* Sun: Open */
+ /* 117 */ KEY_Help, /* Sun: Help */
+ /* 118 */ KEY_L3, /* Sun: Props */
+ /* 119 */ KEY_L5, /* Sun: Front */
+ /* 120 */ KEY_L1, /* Sun: Stop */
+ /* 121 */ KEY_L2, /* Sun: Again */
+ /* 122 */ KEY_L4, /* Sun: Undo */
+ /* 123 */ KEY_L10, /* Sun: Cut */
+ /* 124 */ KEY_L6, /* Sun: Copy */
+ /* 125 */ KEY_L8, /* Sun: Paste */
+ /* 126 */ KEY_L9, /* Sun: Find */
+ /* 127 */ KEY_Mute, /* Sun: AudioMute */
+ /* 128 */ KEY_AudioRaise, /* Sun: AudioRaise */
+ /* 129 */ KEY_AudioLower, /* Sun: AudioLower */
+ /* 130 */ KEY_NOTUSED,
+ /* 131 */ KEY_NOTUSED,
+ /* 132 */ KEY_NOTUSED,
+ /* 133 */ KEY_NOTUSED,
+ /* 134 */ KEY_NOTUSED,
+ /* 135 */ KEY_BSlash2, /* Sun Japanese Kbd: Backslash / Underscore */
+ /* 136 */ KEY_XFER, /* Sun Japanese Kbd: Henkan Mode */
+ /* 137 */ KEY_Yen, /* Sun Japanese Kbd: Yen / Brokenbar */
+ /* 138 */ KEY_Kanji, /* Sun Japanese Kbd: Kanji */
+ /* 139 */ KEY_Execute, /* Sun Japanese Kbd: Execute */
+ /* 140 */ KEY_NOTUSED,
+ /* 141 */ KEY_NOTUSED,
+ /* 142 */ KEY_NOTUSED,
+ /* 143 */ KEY_NOTUSED,
+ /* 144 */ KEY_NOTUSED,
+ /* 145 */ KEY_NOTUSED,
+ /* 146 */ KEY_NOTUSED,
+ /* 147 */ KEY_NOTUSED,
+ /* 148 */ KEY_NOTUSED,
+ /* 149 */ KEY_NOTUSED,
+ /* 150 */ KEY_NOTUSED,
+ /* 151 */ KEY_NOTUSED,
+ /* 152 */ KEY_NOTUSED,
+ /* 153 */ KEY_NOTUSED,
+ /* 154 */ KEY_NOTUSED,
+ /* 155 */ KEY_NOTUSED,
+ /* 156 */ KEY_NOTUSED,
+ /* 157 */ KEY_NOTUSED,
+ /* 158 */ KEY_NOTUSED,
+ /* 159 */ KEY_NOTUSED,
+ /* 160 */ KEY_NOTUSED,
+ /* 161 */ KEY_NOTUSED,
+ /* 162 */ KEY_NOTUSED,
+ /* 163 */ KEY_NOTUSED,
+ /* 164 */ KEY_NOTUSED,
+ /* 165 */ KEY_NOTUSED,
+ /* 166 */ KEY_NOTUSED,
+ /* 167 */ KEY_NOTUSED,
+ /* 168 */ KEY_NOTUSED,
+ /* 169 */ KEY_NOTUSED,
+ /* 170 */ KEY_NOTUSED,
+ /* 171 */ KEY_NOTUSED,
+ /* 172 */ KEY_NOTUSED,
+ /* 173 */ KEY_NOTUSED,
+ /* 174 */ KEY_NOTUSED,
+ /* 175 */ KEY_NOTUSED,
+ /* 176 */ KEY_NOTUSED,
+ /* 177 */ KEY_NOTUSED,
+ /* 178 */ KEY_NOTUSED,
+ /* 179 */ KEY_NOTUSED,
+ /* 180 */ KEY_NOTUSED,
+ /* 181 */ KEY_NOTUSED,
+ /* 182 */ KEY_NOTUSED,
+ /* 183 */ KEY_NOTUSED,
+ /* 184 */ KEY_NOTUSED,
+ /* 185 */ KEY_NOTUSED,
+ /* 186 */ KEY_NOTUSED,
+ /* 187 */ KEY_NOTUSED,
+ /* 188 */ KEY_NOTUSED,
+ /* 189 */ KEY_NOTUSED,
+ /* 190 */ KEY_NOTUSED,
+ /* 191 */ KEY_NOTUSED,
+ /* 192 */ KEY_NOTUSED,
+ /* 193 */ KEY_NOTUSED,
+ /* 194 */ KEY_NOTUSED,
+ /* 195 */ KEY_NOTUSED,
+ /* 196 */ KEY_NOTUSED,
+ /* 197 */ KEY_NOTUSED,
+ /* 198 */ KEY_NOTUSED,
+ /* 199 */ KEY_NOTUSED,
+ /* 200 */ KEY_NOTUSED,
+ /* 201 */ KEY_NOTUSED,
+ /* 202 */ KEY_NOTUSED,
+ /* 203 */ KEY_NOTUSED,
+ /* 204 */ KEY_NOTUSED,
+ /* 205 */ KEY_NOTUSED,
+ /* 206 */ KEY_NOTUSED,
+ /* 207 */ KEY_NOTUSED,
+ /* 208 */ KEY_NOTUSED,
+ /* 209 */ KEY_NOTUSED,
+ /* 210 */ KEY_NOTUSED,
+ /* 211 */ KEY_NOTUSED,
+ /* 212 */ KEY_NOTUSED,
+ /* 213 */ KEY_NOTUSED,
+ /* 214 */ KEY_NOTUSED,
+ /* 215 */ KEY_NOTUSED,
+ /* 216 */ KEY_NOTUSED,
+ /* 217 */ KEY_NOTUSED,
+ /* 218 */ KEY_NOTUSED,
+ /* 219 */ KEY_NOTUSED,
+ /* 220 */ KEY_NOTUSED,
+ /* 221 */ KEY_NOTUSED,
+ /* 222 */ KEY_NOTUSED,
+ /* 223 */ KEY_NOTUSED,
+ /* 224 */ KEY_LCtrl, /* Left Control */
+ /* 225 */ KEY_ShiftL, /* Left Shift */
+ /* 226 */ KEY_Alt, /* Left Alt */
+ /* 227 */ KEY_LMeta, /* Left Meta */
+ /* 228 */ KEY_RCtrl, /* Right Control */
+ /* 229 */ KEY_ShiftR, /* Right Shift */
+ /* 230 */ KEY_AltLang, /* Right Alt, AKA AltGr */
+ /* 231 */ KEY_RMeta, /* Right Meta */
+};
+
+#endif /* KB_USB */
+
+_X_HIDDEN const unsigned char *
+sunGetKbdMapping(int ktype) {
+#if defined(KB_USB)
+ if (ktype == KB_USB)
+ return usbmap;
+ else
+#endif
+ return map;
+}
+
+
+/*
+ * sunPostKbdEvent --
+ * Translate the raw hardware Firm_event into an XEvent, and tell DIX
+ * about it. KeyCode preprocessing and so on is done ...
+ *
+ * Most of the Solaris stuff has whacked Panix/PC98 support in the
+ * interests of simplicity - DWH 8/30/99
+ */
+
+_X_HIDDEN void
+sunPostKbdEvent(int sun_ktype, Firm_event *event)
+{
+ Bool down;
+ KeyClassRec *keyc = ((DeviceIntPtr)xf86Info.pKeyboard)->key;
+ Bool updateLeds = FALSE;
+ xEvent kevent;
+ KeySym *keysym;
+ int keycode;
+ static int lockkeys = 0;
+
+ /* Give down a value */
+ if (event->value == VKEY_DOWN)
+ down = TRUE;
+ else
+ down = FALSE;
+
+
+#if defined(KB_USB)
+ if(sun_ktype == KB_USB)
+ keycode = usbmap[event->id];
+ else
+#endif
+ keycode = map[event->id];
+
+ /*
+ * and now get some special keysequences
+ */
+
+#ifdef XKB
+ if (((xf86Info.ddxSpecialKeys == SKWhenNeeded) &&
+ (!xf86Info.ActionKeyBindingsSet)) ||
+ noXkbExtension || (xf86Info.ddxSpecialKeys == SKAlways))
+#endif
+ {
+ if (!(ModifierDown(ShiftMask)) &&
+ ((ModifierDown(ControlMask | AltMask)) ||
+ (ModifierDown(ControlMask | AltLangMask))))
+ {
+ switch (keycode) {
+ /*
+ * The idea here is to pass the scancode down to a list of
+ * registered routines. There should be some standard conventions
+ * for processing certain keys.
+ */
+ case KEY_BackSpace:
+ xf86ProcessActionEvent(ACTION_TERMINATE, NULL);
+ break;
+
+ /*
+ * Check grabs
+ */
+ case KEY_KP_Divide:
+ xf86ProcessActionEvent(ACTION_DISABLEGRAB, NULL);
+ break;
+ case KEY_KP_Multiply:
+ xf86ProcessActionEvent(ACTION_CLOSECLIENT, NULL);
+ break;
+
+ /*
+ * Video mode switches
+ */
+ case KEY_KP_Minus: /* Keypad - */
+ if (down) xf86ProcessActionEvent(ACTION_PREV_MODE, NULL);
+ if (!xf86Info.dontZoom) return;
+ break;
+
+ case KEY_KP_Plus: /* Keypad + */
+ if (down) xf86ProcessActionEvent(ACTION_NEXT_MODE, NULL);
+ if (!xf86Info.dontZoom) return;
+ break;
+ }
+ }
+ }
+
+ /*
+ * Now map the scancodes to real X-keycodes ...
+ */
+ if (keycode == KEY_NOTUSED) {
+ xf86MsgVerb(X_INFO, 0,
+ "raw code %d mapped to KEY_NOTUSED -- please report\n", event->id);
+ return;
+ }
+ if (keycode == KEY_UNKNOWN) {
+ xf86MsgVerb(X_INFO, 0,
+ "raw code %d mapped to KEY_UNKNOWN -- please report\n", event->id);
+ return;
+ }
+ keycode += MIN_KEYCODE;
+ keysym = keyc->curKeySyms.map +
+ (keyc->curKeySyms.mapWidth *
+ (keycode - keyc->curKeySyms.minKeyCode));
+
+#ifdef XKB
+ if (noXkbExtension)
+#endif
+ {
+ /*
+ * Toggle lock keys.
+ */
+#define CAPSFLAG 0x01
+#define NUMFLAG 0x02
+#define SCROLLFLAG 0x04
+#define MODEFLAG 0x08
+
+ if (down) {
+ /*
+ * Handle the KeyPresses of the lock keys.
+ */
+
+ switch (keysym[0]) {
+
+ case XK_Caps_Lock:
+ if (lockkeys & CAPSFLAG) {
+ lockkeys &= ~CAPSFLAG;
+ return;
+ }
+ lockkeys |= CAPSFLAG;
+ updateLeds = TRUE;
+ xf86Info.capsLock = down;
+ break;
+
+ case XK_Num_Lock:
+ if (lockkeys & NUMFLAG) {
+ lockkeys &= ~NUMFLAG;
+ return;
+ }
+ lockkeys |= NUMFLAG;
+ updateLeds = TRUE;
+ xf86Info.numLock = down;
+ break;
+
+ case XK_Scroll_Lock:
+ if (lockkeys & SCROLLFLAG) {
+ lockkeys &= ~SCROLLFLAG;
+ return;
+ }
+ lockkeys |= SCROLLFLAG;
+ updateLeds = TRUE;
+ xf86Info.scrollLock = down;
+ break;
+ }
+ } else {
+ /*
+ * Handle the releases of the lock keys.
+ */
+
+ switch (keysym[0]) {
+
+ case XK_Caps_Lock:
+ if (lockkeys & CAPSFLAG)
+ return;
+ updateLeds = TRUE;
+ xf86Info.capsLock = down;
+ break;
+
+ case XK_Num_Lock:
+ if (lockkeys & NUMFLAG)
+ return;
+ updateLeds = TRUE;
+ xf86Info.numLock = down;
+ break;
+
+ case XK_Scroll_Lock:
+ if (lockkeys & SCROLLFLAG)
+ return;
+ updateLeds = TRUE;
+ xf86Info.scrollLock = down;
+ break;
+ }
+ }
+
+ if (updateLeds)
+ xf86KbdLeds();
+
+ /*
+ * If this keycode is not a modifier key, and its down initiate the
+ * autorepeate sequence. (Only necessary if not using XKB).
+ *
+ * If its not down, then reset the timer.
+ */
+ if (!keyc->modifierMap[keycode]) {
+ if (down) {
+ startautorepeat(keycode);
+ } else {
+ TimerFree(sunTimer);
+ sunTimer = NULL;
+ }
+ }
+ }
+
+ xf86Info.lastEventTime =
+ kevent.u.keyButtonPointer.time =
+ GetTimeInMillis();
+
+ /*
+ * And now send these prefixes ...
+ * NOTE: There cannot be multiple Mode_Switch keys !!!!
+ */
+
+ ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD);
+}
+
+
+
+/*
+ * Autorepeat stuff
+ */
+
+void
+startautorepeat(long keycode)
+{
+ sunTimer = TimerSet(sunTimer, /* Timer */
+ 0, /* Flags */
+ xf86Info.kbdDelay, /* millis */
+ processautorepeat, /* callback */
+ (pointer) keycode); /* arg for timer */
+}
+
+CARD32
+processautorepeat(OsTimerPtr timer, CARD32 now, pointer arg)
+{
+ xEvent kevent;
+ int keycode;
+
+ keycode = (long)arg;
+
+ xf86Info.lastEventTime =
+ kevent.u.keyButtonPointer.time =
+ GetTimeInMillis();
+
+ /*
+ * Repeat a key by faking a KeyRelease, and a KeyPress event in rapid
+ * succession
+ */
+
+ ENQUEUE(&kevent, keycode, KeyRelease, XE_KEYBOARD);
+ ENQUEUE(&kevent, keycode, KeyPress, XE_KEYBOARD);
+
+ /* And return the appropriate value so we get rescheduled */
+ return xf86Info.kbdRate;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c
new file mode 100644
index 000000000..928609f0e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c
@@ -0,0 +1,719 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c,v 1.4 2002/01/25 21:56:21 tsi Exp $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c,v 1.8 2005/07/28 02:38:23 alanc Exp $ */
+/*
+ * Copyright 1999-2001 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+/* Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86_OSlib.h"
+#include "xf86OSmouse.h"
+
+#if defined(__SOL8__) || !defined(__i386)
+
+#include "xisb.h"
+#include "mipointer.h"
+#include <sys/stropts.h>
+#include <sys/vuid_event.h>
+#include <sys/msio.h>
+
+/* Wheel mouse support in VUID drivers in Solaris 9 updates & Solaris 10 */
+#ifdef WHEEL_DEVID /* Defined in vuid_event.h if VUID wheel support present */
+# define HAVE_VUID_WHEEL
+#endif
+#ifdef HAVE_VUID_WHEEL
+# include <sys/vuid_wheel.h>
+#endif
+
+/* Support for scaling absolute coordinates to screen size in
+ * Solaris 10 updates and beyond */
+#if !defined(HAVE_ABSOLUTE_MOUSE_SCALING)
+# ifdef MSIOSRESOLUTION /* Defined in msio.h if scaling support present */
+# define HAVE_ABSOLUTE_MOUSE_SCALING
+# endif
+#endif
+
+/* Names of protocols that are handled internally here. */
+
+static const char *internalNames[] = {
+ "VUID",
+ NULL
+};
+
+static const char *solarisMouseDevs[] = {
+ /* Device file: Protocol: */
+ "/dev/mouse", "VUID", /* USB or SPARC */
+#if defined(__i386) || defined(__x86)
+ "/dev/kdmouse", "PS/2", /* PS/2 */
+#endif
+ NULL
+};
+
+typedef struct _VuidMseRec {
+ struct _VuidMseRec *next;
+ InputInfoPtr pInfo;
+ Firm_event event;
+ unsigned char * buffer;
+ char * strmod;
+ Bool(*wrapped_device_control)(DeviceIntPtr device, int what);
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+ Ms_screen_resolution absres;
+#endif
+} VuidMseRec, *VuidMsePtr;
+
+static VuidMsePtr vuidMouseList = NULL;
+
+static int vuidMouseProc(DeviceIntPtr pPointer, int what);
+static void vuidReadInput(InputInfoPtr pInfo);
+
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse);
+static void vuidMouseAdjustFrame(int index, int x, int y, int flags);
+
+static int vuidMouseGeneration = 0;
+static int vuidMouseScreenIndex;
+#define vuidMouseScreenPrivate(s) ((s)->devPrivates[vuidMouseScreenIndex].ptr)
+#endif /* HAVE_ABSOLUTE_MOUSE_SCALING */
+
+static inline
+VuidMsePtr getVuidMsePriv(InputInfoPtr pInfo)
+{
+ VuidMsePtr m = vuidMouseList;
+
+ while ((m != NULL) && (m->pInfo != pInfo)) {
+ m = m->next;
+ }
+
+ return m;
+}
+
+
+/*
+ * Initialize and enable the mouse wheel, if present.
+ *
+ * Returns 1 if mouse wheel was successfully enabled.
+ * Returns 0 if an error occurred or if there is no mouse wheel.
+ */
+static int
+vuidMouseWheelInit(InputInfoPtr pInfo)
+{
+#ifdef HAVE_VUID_WHEEL
+ wheel_state wstate;
+ int nwheel = -1;
+ int i;
+
+ wstate.vers = VUID_WHEEL_STATE_VERS;
+ wstate.id = 0;
+ wstate.stateflags = -1;
+
+ SYSCALL(i = ioctl(pInfo->fd, VUIDGWHEELCOUNT, &nwheel));
+ if (i != 0)
+ return (0);
+
+ SYSCALL(i = ioctl(pInfo->fd, VUIDGWHEELSTATE, &wstate));
+ if (i != 0) {
+ xf86Msg(X_WARNING, "%s: couldn't get wheel state\n", pInfo->name);
+ return (0);
+ }
+
+ wstate.stateflags |= VUID_WHEEL_STATE_ENABLED;
+
+ SYSCALL(i = ioctl(pInfo->fd, VUIDSWHEELSTATE, &wstate));
+ if (i != 0) {
+ xf86Msg(X_WARNING, "%s: couldn't enable wheel\n", pInfo->name);
+ return (0);
+ }
+
+ return (1);
+#else
+ return (0);
+#endif
+}
+
+
+/* This function is called when the protocol is "VUID". */
+static Bool
+vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ MouseDevPtr pMse = pInfo->private;
+ VuidMsePtr pVuidMse;
+ int buttons, i;
+
+ pVuidMse = xcalloc(sizeof(VuidMseRec), 1);
+ if (pVuidMse == NULL) {
+ xf86Msg(X_ERROR, "%s: cannot allocate VuidMouseRec\n", pInfo->name);
+ xfree(pMse);
+ return FALSE;
+ }
+
+ pMse->protocol = protocol;
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
+
+ /* Collect the options, and process the common options. */
+ xf86CollectInputOptions(pInfo, NULL, NULL);
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
+
+ /* Check if the device can be opened. */
+ pInfo->fd = xf86OpenSerial(pInfo->options);
+ if (pInfo->fd == -1) {
+ if (xf86GetAllowMouseOpenFail())
+ xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
+ else {
+ xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
+ xfree(pVuidMse);
+ xfree(pMse);
+ return FALSE;
+ }
+ }
+
+ pVuidMse->buffer = (unsigned char *)&pVuidMse->event;
+
+ pVuidMse->strmod = xf86SetStrOption(pInfo->options, "StreamsModule", NULL);
+ if (pVuidMse->strmod) {
+ SYSCALL(i = ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod));
+ if (i < 0) {
+ xf86Msg(X_ERROR,
+ "%s: cannot push module '%s' onto mouse device: %s\n",
+ pInfo->name, pVuidMse->strmod, strerror(errno));
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ xfree(pVuidMse->strmod);
+ xfree(pVuidMse);
+ xfree(pMse);
+ return FALSE;
+ }
+ }
+
+ buttons = xf86SetIntOption(pInfo->options, "Buttons", 0);
+ if (buttons == 0) {
+ SYSCALL(i = ioctl(pInfo->fd, MSIOBUTTONS, &buttons));
+ if (i == 0) {
+ pInfo->conf_idev->commonOptions =
+ xf86ReplaceIntOption(pInfo->conf_idev->commonOptions,
+ "Buttons", buttons);
+ xf86Msg(X_INFO, "%s: Setting Buttons option to \"%d\"\n",
+ pInfo->name, buttons);
+ }
+ }
+
+ if (pVuidMse->strmod) {
+ SYSCALL(i = ioctl(pInfo->fd, I_POP, pVuidMse->strmod));
+ if (i == -1) {
+ xf86Msg(X_WARNING,
+ "%s: cannot pop module '%s' off mouse device: %s\n",
+ pInfo->name, pVuidMse->strmod, strerror(errno));
+ }
+ }
+
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+
+ /* Process common mouse options (like Emulate3Buttons, etc). */
+ pMse->CommonOptions(pInfo);
+
+ /* Setup the local procs. */
+ pVuidMse->wrapped_device_control = pInfo->device_control;
+ pInfo->device_control = vuidMouseProc;
+ pInfo->read_input = vuidReadInput;
+
+ pMse->xisbscale = sizeof(Firm_event);
+
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+ pVuidMse->absres.height = pVuidMse->absres.width = 0;
+#endif
+ pVuidMse->pInfo = pInfo;
+ pVuidMse->next = vuidMouseList;
+ vuidMouseList = pVuidMse;
+
+ pInfo->flags |= XI86_CONFIGURED;
+ return TRUE;
+}
+
+static void
+vuidFlushAbsEvents(InputInfoPtr pInfo, int absX, int absY,
+ Bool *absXset, Bool *absYset)
+{
+#ifdef DEBUG
+ ErrorF("vuidFlushAbsEvents: %d,%d (set: %d, %d)\n", absX, absY,
+ *absXset, *absYset);
+#endif
+ if ((*absXset) && (*absYset)) {
+ xf86PostMotionEvent(pInfo->dev,
+ /* is_absolute: */ TRUE,
+ /* first_valuator: */ 0,
+ /* num_valuators: */ 2,
+ absX, absY);
+ } else if (*absXset) {
+ xf86PostMotionEvent(pInfo->dev,
+ /* is_absolute: */ TRUE,
+ /* first_valuator: */ 0,
+ /* num_valuators: */ 1,
+ absX);
+ } else if (*absYset) {
+ xf86PostMotionEvent(pInfo->dev,
+ /* is_absolute: */ TRUE,
+ /* first_valuator: */ 1,
+ /* num_valuators: */ 1,
+ absY);
+ }
+
+ *absXset = FALSE;
+ *absYset = FALSE;
+}
+
+static void
+vuidReadInput(InputInfoPtr pInfo)
+{
+ MouseDevPtr pMse;
+ VuidMsePtr pVuidMse;
+ int buttons;
+ int dx = 0, dy = 0, dz = 0, dw = 0;
+ unsigned int n;
+ int c;
+ unsigned char *pBuf;
+ int wmask;
+ int absX, absY;
+ Bool absXset = FALSE, absYset = FALSE;
+
+ pMse = pInfo->private;
+ pVuidMse = getVuidMsePriv(pInfo);
+ buttons = pMse->lastButtons;
+ XisbBlockDuration(pMse->buffer, -1);
+ pBuf = pVuidMse->buffer;
+ n = 0;
+
+ do {
+ while (n < sizeof(Firm_event) && (c = XisbRead(pMse->buffer)) >= 0) {
+ pBuf[n++] = (unsigned char)c;
+ }
+
+ if (n == 0)
+ return;
+
+ if (n != sizeof(Firm_event)) {
+ xf86Msg(X_WARNING, "%s: incomplete packet, size %d\n",
+ pInfo->name, n);
+ }
+
+#ifdef DEBUG
+ ErrorF("vuidReadInput: event type: %3d value: %5d\n",
+ pVuidMse->event.id, pVuidMse->event.value);
+#endif
+
+ if (pVuidMse->event.id >= BUT_FIRST && pVuidMse->event.id <= BUT_LAST) {
+ /* button */
+ int butnum = pVuidMse->event.id - BUT_FIRST;
+
+ if (butnum < 3)
+ butnum = 2 - butnum;
+ if (!pVuidMse->event.value)
+ buttons &= ~(1 << butnum);
+ else
+ buttons |= (1 << butnum);
+ } else if (pVuidMse->event.id >= VLOC_FIRST &&
+ pVuidMse->event.id <= VLOC_LAST) {
+ /* axis */
+ int delta = pVuidMse->event.value;
+ switch(pVuidMse->event.id) {
+ case LOC_X_DELTA:
+ dx += delta;
+ break;
+ case LOC_Y_DELTA:
+ dy -= delta;
+ break;
+ case LOC_X_ABSOLUTE:
+ if (absXset) {
+ vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
+ }
+ absX = delta;
+ absXset = TRUE;
+ break;
+ case LOC_Y_ABSOLUTE:
+ if (absYset) {
+ vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
+ }
+ absY = delta;
+ absYset = TRUE;
+ break;
+ }
+ }
+#ifdef HAVE_VUID_WHEEL
+ else if (vuid_in_range(VUID_WHEEL, pVuidMse->event.id)) {
+ if (vuid_id_offset(pVuidMse->event.id) == 0)
+ dz -= VUID_WHEEL_GETDELTA(pVuidMse->event.value);
+ else
+ dw -= VUID_WHEEL_GETDELTA(pVuidMse->event.value);
+ }
+#endif
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+ else if (pVuidMse->event.id == MOUSE_TYPE_ABSOLUTE) {
+ /* force sending absolute resolution scaling ioctl */
+ pVuidMse->absres.height = pVuidMse->absres.width = 0;
+ vuidMouseSendScreenSize(miPointerCurrentScreen(), pVuidMse);
+ }
+#endif
+
+ n = 0;
+ if ((c = XisbRead(pMse->buffer)) >= 0) {
+ /* Another packet. Handle it right away. */
+ pBuf[n++] = c;
+ }
+ } while (n != 0);
+
+ if (absXset || absYset) {
+ vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
+ }
+
+ pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw);
+ return;
+}
+
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse)
+{
+ InputInfoPtr pInfo = pVuidMse->pInfo;
+ ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+ int result;
+
+ if ((pVuidMse->absres.width != pScr->currentMode->HDisplay) ||
+ (pVuidMse->absres.height != pScr->currentMode->VDisplay))
+ {
+ pVuidMse->absres.width = pScr->currentMode->HDisplay;
+ pVuidMse->absres.height = pScr->currentMode->VDisplay;
+
+ do {
+ result = ioctl(pInfo->fd, MSIOSRESOLUTION, &(pVuidMse->absres));
+ } while ( (result != 0) && (errno == EINTR) );
+
+ if (result != 0) {
+ xf86Msg(X_WARNING,
+ "%s: couldn't set absolute mouse scaling resolution: %s\n",
+ pInfo->name, strerror(errno));
+#ifdef DEBUG
+ } else {
+ xf86Msg(X_INFO,
+ "%s: absolute mouse scaling resolution set to %d x %d\n",
+ pInfo->name,
+ pVuidMse->absres.width, pVuidMse->absres.height);
+#endif
+ }
+ }
+}
+
+static void vuidMouseAdjustFrame(int index, int x, int y, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ ScreenPtr pScreen = pScrn->pScreen;
+ xf86AdjustFrameProc *wrappedAdjustFrame
+ = (xf86AdjustFrameProc *) vuidMouseScreenPrivate(pScreen);
+ VuidMsePtr m;
+
+ if(wrappedAdjustFrame) {
+ pScrn->AdjustFrame = wrappedAdjustFrame;
+ (*pScrn->AdjustFrame)(index, x, y, flags);
+ pScrn->AdjustFrame = vuidMouseAdjustFrame;
+ }
+
+ if (miPointerCurrentScreen() == pScreen) {
+ for (m = vuidMouseList; m != NULL ; m = m->next) {
+ vuidMouseSendScreenSize(pScreen, m);
+ }
+ }
+}
+#endif /* HAVE_ABSOLUTE_MOUSE_SCALING */
+
+
+static int
+vuidMouseProc(DeviceIntPtr pPointer, int what)
+{
+ InputInfoPtr pInfo;
+ MouseDevPtr pMse;
+ VuidMsePtr pVuidMse;
+ int ret = Success;
+ int i;
+
+ pInfo = pPointer->public.devicePrivate;
+ pMse = pInfo->private;
+ pMse->device = pPointer;
+
+ pVuidMse = getVuidMsePriv(pInfo);
+ if (pVuidMse == NULL) {
+ return BadImplementation;
+ }
+
+ switch (what) {
+
+ case DEVICE_INIT:
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+ if (vuidMouseGeneration != serverGeneration) {
+ if ((vuidMouseScreenIndex = AllocateScreenPrivateIndex()) >= 0) {
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
+ vuidMouseScreenPrivate(pScreen)
+ = (pointer) pScrn->AdjustFrame;
+ pScrn->AdjustFrame = vuidMouseAdjustFrame;
+ }
+ }
+ vuidMouseGeneration = serverGeneration;
+ }
+#endif
+ ret = pVuidMse->wrapped_device_control(pPointer, what);
+ break;
+
+ case DEVICE_ON:
+ ret = pVuidMse->wrapped_device_control(pPointer, DEVICE_ON);
+
+ if ((ret == Success) && (pInfo->fd != -1)) {
+ int fmt = VUID_FIRM_EVENT;
+
+ if (pVuidMse->strmod) {
+ SYSCALL(i = ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod));
+ if (i < 0) {
+ xf86Msg(X_WARNING,
+ "%s: cannot push module '%s' onto mouse device: %s\n",
+ pInfo->name, pVuidMse->strmod, strerror(errno));
+ xfree(pVuidMse->strmod);
+ pVuidMse->strmod = NULL;
+ }
+ }
+ SYSCALL(i = ioctl(pInfo->fd, VUIDSFORMAT, &fmt));
+ if (i < 0) {
+ xf86Msg(X_WARNING,
+ "%s: cannot set mouse device to VUID mode: %s\n",
+ pInfo->name, strerror(errno));
+ }
+ vuidMouseWheelInit(pInfo);
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+ vuidMouseSendScreenSize(screenInfo.screens[0], pVuidMse);
+#endif
+ xf86FlushInput(pInfo->fd);
+ }
+ break;
+
+ case DEVICE_OFF:
+ case DEVICE_CLOSE:
+ if (pInfo->fd != -1) {
+ if (pVuidMse->strmod) {
+ SYSCALL(i = ioctl(pInfo->fd, I_POP, pVuidMse->strmod));
+ if (i == -1) {
+ xf86Msg(X_WARNING,
+ "%s: cannot pop module '%s' off mouse device: %s\n",
+ pInfo->name, pVuidMse->strmod, strerror(errno));
+ }
+ }
+ }
+ ret = pVuidMse->wrapped_device_control(pPointer, what);
+ break;
+
+ default: /* Should never be called, but just in case */
+ ret = pVuidMse->wrapped_device_control(pPointer, what);
+ break;
+ }
+ return ret;
+}
+
+static Bool
+sunMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ /* The protocol is guaranteed to be one of the internalNames[] */
+ if (xf86NameCmp(protocol, "VUID") == 0) {
+ return vuidPreInit(pInfo, protocol, flags);
+ }
+ return TRUE;
+}
+
+static const char **
+BuiltinNames(void)
+{
+ return internalNames;
+}
+
+static Bool
+CheckProtocol(const char *protocol)
+{
+ int i;
+
+ for (i = 0; internalNames[i]; i++)
+ if (xf86NameCmp(protocol, internalNames[i]) == 0)
+ return TRUE;
+
+ return FALSE;
+}
+
+static const char *
+DefaultProtocol(void)
+{
+ return "Auto";
+}
+
+static Bool
+solarisMouseAutoProbe(InputInfoPtr pInfo, const char **protocol,
+ const char **device)
+{
+ const char **pdev, **pproto, *dev = NULL;
+ int fd = -1;
+ Bool found;
+
+ for (pdev = solarisMouseDevs; *pdev; pdev += 2) {
+ pproto = pdev + 1;
+ if ((*protocol != NULL) && (strcmp(*protocol, "Auto") != 0) &&
+ (*pproto != NULL) && (strcmp(*pproto, *protocol) != 0)) {
+ continue;
+ }
+ if ((*device != NULL) && (strcmp(*device, *pdev) != 0)) {
+ continue;
+ }
+ SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK));
+ if (fd == -1) {
+#ifdef DEBUG
+ ErrorF("Cannot open %s (%s)\n", pdev, strerror(errno));
+#endif
+ } else {
+ found = TRUE;
+ if ((*pproto != NULL) && (strcmp(*pproto, "VUID") == 0)) {
+ int i, r;
+ SYSCALL(r = ioctl(fd, VUIDGFORMAT, &i));
+ if (r < 0) {
+ found = FALSE;
+ }
+ }
+ close(fd);
+ if (found == TRUE) {
+ if (*pproto != NULL) {
+ *protocol = *pproto;
+ }
+ *device = *pdev;
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+static const char *
+SetupAuto(InputInfoPtr pInfo, int *protoPara)
+{
+ const char *pdev = NULL;
+ const char *pproto = NULL;
+ MouseDevPtr pMse = pInfo->private;
+
+ if (pInfo->fd == -1) {
+ /* probe to find device/protocol to use */
+ if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) {
+ /* Set the Device option. */
+ pInfo->conf_idev->commonOptions =
+ xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", pdev);
+ xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
+ pInfo->name, pdev);
+ }
+ } else if (pMse->protocolID == PROT_AUTO) {
+ pdev = xf86CheckStrOption(pInfo->conf_idev->commonOptions,
+ "Device", NULL);
+ solarisMouseAutoProbe(pInfo, &pproto, &pdev);
+ }
+ return pproto;
+}
+
+static const char *
+FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ const char *pdev = NULL;
+ const char *pproto = protocol;
+
+ if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) {
+ /* Set the Device option. */
+ pInfo->conf_idev->commonOptions =
+ xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", pdev);
+ xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
+ pInfo->name, pdev);
+ }
+ return pdev;
+}
+
+#else /* __SOL8__ || !__i386 */
+
+#undef MSE_MISC
+#define MSE_MISC 0
+
+#endif /* !__SOL8__ && __i386 */
+
+static int
+SupportedInterfaces(void)
+{
+ /* XXX This needs to be checked. */
+ return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO | MSE_XPS2 | MSE_MISC;
+}
+
+OSMouseInfoPtr
+xf86OSMouseInit(int flags)
+{
+ OSMouseInfoPtr p;
+
+ p = xcalloc(sizeof(OSMouseInfoRec), 1);
+ if (!p)
+ return NULL;
+ p->SupportedInterfaces = SupportedInterfaces;
+#if defined(__SOL8__) || !defined(__i386)
+ p->BuiltinNames = BuiltinNames;
+ p->CheckProtocol = CheckProtocol;
+ p->PreInit = sunMousePreInit;
+ p->DefaultProtocol = DefaultProtocol;
+ p->SetupAuto = SetupAuto;
+ p->FindDevice = FindDevice;
+#endif
+ return p;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c
new file mode 100644
index 000000000..82cd1ae7b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c
@@ -0,0 +1,237 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c,v 1.2 2001/10/28 03:34:03 tsi Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the names of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
+ * SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/types.h> /* get __x86 definition if not set by compiler */
+
+#if defined(i386) || defined(__x86)
+#define _NEED_SYSI86
+#endif
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+char *apertureDevName = NULL;
+
+Bool
+xf86LinearVidMem(void)
+{
+ int mmapFd;
+
+ if (apertureDevName)
+ return TRUE;
+
+ apertureDevName = "/dev/xsvc";
+ if ((mmapFd = open(apertureDevName, O_RDWR)) < 0)
+ {
+ apertureDevName = "/dev/fbs/aperture";
+ if((mmapFd = open(apertureDevName, O_RDWR)) < 0)
+ {
+ xf86MsgVerb(X_WARNING, 0,
+ "xf86LinearVidMem: failed to open %s (%s)\n",
+ apertureDevName, strerror(errno));
+ xf86MsgVerb(X_WARNING, 0,
+ "xf86LinearVidMem: either /dev/fbs/aperture or /dev/xsvc"
+ " device driver required\n");
+ xf86MsgVerb(X_WARNING, 0,
+ "xf86LinearVidMem: linear memory access disabled\n");
+ apertureDevName = NULL;
+ return FALSE;
+ }
+ }
+ close(mmapFd);
+ return TRUE;
+}
+
+pointer
+xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size)
+{
+ pointer base;
+ int fd;
+ char vtname[20];
+
+ /*
+ * Solaris 2.1 x86 SVR4 (10/27/93)
+ * The server must treat the virtual terminal device file as the
+ * standard SVR4 /dev/pmem.
+ *
+ * Using the /dev/vtXX device as /dev/pmem only works for the
+ * A0000-FFFFF region - If we wish you mmap the linear aperture
+ * it requires a device driver.
+ *
+ * So what we'll do is use /dev/vtXX for the A0000-FFFFF stuff, and
+ * try to use the /dev/fbs/aperture or /dev/xsvc driver if the server
+ * tries to mmap anything > FFFFF. Its very very unlikely that the
+ * server will try to mmap anything below FFFFF that can't be handled
+ * by /dev/vtXX.
+ *
+ * DWH - 2/23/94
+ * DWH - 1/31/99 (Gee has it really been 5 years?)
+ *
+ * Solaris 2.8 7/26/99
+ * Use /dev/xsvc for everything
+ *
+ * DWH - 7/26/99 - Solaris8/dev/xsvc changes
+ *
+ * TSI - 2001.09 - SPARC changes
+ */
+
+#if defined(i386) && !defined(__SOL8__)
+ if(Base < 0xFFFFF)
+ sprintf(vtname, "/dev/vt%02d", xf86Info.vtno);
+ else
+#endif
+ {
+ if (!xf86LinearVidMem())
+ FatalError("xf86MapVidMem: no aperture device\n");
+
+ strcpy(vtname, apertureDevName);
+ }
+
+ fd = open(vtname, (Flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
+ if (fd < 0)
+ FatalError("xf86MapVidMem: failed to open %s (%s)\n",
+ vtname, strerror(errno));
+
+ base = mmap(NULL, Size,
+ (Flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_SHARED, fd, (off_t)Base);
+ close(fd);
+ if (base == MAP_FAILED)
+ FatalError("xf86MapVidMem: mmap failure: %s\n",
+ strerror(errno));
+
+ return(base);
+}
+
+/* ARGSUSED */
+void
+xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap(Base, Size);
+}
+
+/***************************************************************************/
+/* I/O Permissions section */
+/***************************************************************************/
+
+#if defined(i386) || defined(__x86)
+static Bool ExtendedEnabled = FALSE;
+#endif
+
+Bool
+xf86EnableIO(void)
+{
+#if defined(i386) || defined(__x86)
+ if (ExtendedEnabled)
+ return TRUE;
+
+ if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) {
+ xf86Msg(X_WARNING,"xf86EnableIOPorts: Failed to set IOPL for I/O\n");
+ return FALSE;
+ }
+ ExtendedEnabled = TRUE;
+#endif /* i386 */
+ return TRUE;
+}
+
+void
+xf86DisableIO(void)
+{
+#if defined(i386) || defined(__x86)
+ if(!ExtendedEnabled)
+ return;
+
+ sysi86(SI86V86, V86SC_IOPL, 0);
+
+ ExtendedEnabled = FALSE;
+#endif /* i386 */
+}
+
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+Bool xf86DisableInterrupts(void)
+{
+#if defined(i386) || defined(__x86)
+ if (!ExtendedEnabled && (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0))
+ return FALSE;
+
+#ifdef __GNUC__
+ __asm__ __volatile__("cli");
+#else
+ asm("cli");
+#endif /* __GNUC__ */
+
+ if (!ExtendedEnabled)
+ sysi86(SI86V86, V86SC_IOPL, 0);
+#endif /* i386 */
+
+ return TRUE;
+}
+
+void xf86EnableInterrupts(void)
+{
+#if defined(i386) || defined(__x86)
+ if (!ExtendedEnabled && (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0))
+ return;
+
+#ifdef __GNUC__
+ __asm__ __volatile__("sti");
+#else
+ asm("sti");
+#endif /* __GNUC__ */
+
+ if (!ExtendedEnabled)
+ sysi86(SI86V86, V86SC_IOPL, 0);
+#endif /* i386 */
+}
+
+void
+xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base,
+ unsigned long Size)
+{
+}
+
+Bool
+xf86CheckMTRR(int ScreenNum)
+{
+ return FALSE;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile
new file mode 100644
index 000000000..2ba9baf92
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile
@@ -0,0 +1,58 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile,v 3.24 2002/10/11 01:47:00 dawes Exp $
+
+
+
+
+
+XCOMM $XConsortium: Imakefile /main/10 1996/10/25 11:38:05 kaleb $
+
+#include <Server.tmpl>
+
+#if defined(SVR4Architecture) || defined(i386Sco325Architecture)
+BIOS_MOD = bios_mmap
+#else
+BIOS_MOD = bios_devmem
+#endif
+
+MOUSESRC = sysv_mouse.c
+MOUSEOBJ = sysv_mouse.o
+
+SRCS = sysv_init.c sysv_video.c sysv_io.c $(BIOS_MOD).c VTsw_usl.c \
+ sysv_kbd.c std_kbdEv.c posix_tty.c $(MOUSESRC) xqueue.c \
+ libc_wrapper.c stdResource.c stdPci.c vidmem.c sigiostubs.c pm_noop.c \
+ kmod_noop.c agp_noop.c
+
+OBJS = sysv_init.o sysv_video.o sysv_io.o $(BIOS_MOD).o VTsw_usl.o \
+ sysv_kbd.o std_kbdEv.o posix_tty.o $(MOUSEOBJ) xqueue.o \
+ libc_wrapper.o stdResource.o stdPci.o vidmem.o sigiostubs.o pm_noop.o \
+ kmod_noop.o agp_noop.o
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/mi
+
+RESDEFINES = -DUSESTDRES
+
+DEFINES = $(RESDEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+#if !defined(SVR4Architecture)
+LinkSourceFile(bios_devmem.c,../shared)
+#else
+LinkSourceFile(bios_mmap.c,../shared)
+#endif
+LinkSourceFile(VTsw_usl.c,../shared)
+LinkSourceFile(sysv_kbd.c,../shared)
+LinkSourceFile(std_kbdEv.c,../shared)
+LinkSourceFile(posix_tty.c,../shared)
+LinkSourceFile(libc_wrapper.c,../shared)
+LinkSourceFile(stdResource.c,../shared)
+LinkSourceFile(stdPci.c,../shared)
+LinkSourceFile(vidmem.c,../shared)
+LinkSourceFile(sigiostubs.c,../shared)
+LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
+LinkSourceFile(agp_noop.c,../shared)
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_init.c
new file mode 100644
index 000000000..3edffd446
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_init.c
@@ -0,0 +1,254 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_init.c,v 3.4.4.3 1998/07/18 17:53:57 dawes Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Thomas Roell and
+ * David Wexelblat makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: sysv_init.c /main/4 1996/02/21 17:54:31 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+static Bool KeepTty = FALSE;
+#ifdef SVR4
+static Bool Protect0 = FALSE;
+#endif
+static int VTnum = -1;
+
+
+void
+xf86OpenConsole()
+{
+ int fd;
+ struct vt_mode VT;
+ char vtname1[10],vtname2[10];
+ MessageType from = X_PROBED;
+
+ if (serverGeneration == 1)
+ {
+ /* check if we're run with euid==0 */
+ if (geteuid() != 0)
+ {
+ FatalError("xf86OpenConsole: Server must be suid root\n");
+ }
+
+#ifdef SVR4
+ /* Protect page 0 to help find NULL dereferencing */
+ /* mprotect() doesn't seem to work */
+ if (Protect0)
+ {
+ int fd = -1;
+
+ if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: cannot open /dev/zero (%s)\n",
+ strerror(errno));
+ }
+ else
+ {
+ if ((int)mmap(0, 0x1000, PROT_NONE,
+ MAP_FIXED | MAP_SHARED, fd, 0) == -1)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: failed to protect page 0 (%s)\n",
+ strerror(errno));
+ }
+ close(fd);
+ }
+ }
+#endif
+ /*
+ * setup the virtual terminal manager
+ */
+ if (VTnum != -1)
+ {
+ xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
+ }
+ else
+ {
+ if ((fd = open("/dev/console",O_WRONLY,0)) < 0)
+ {
+ FatalError(
+ "xf86OpenConsole: Cannot open /dev/console (%s)\n",
+ strerror(errno));
+ }
+ if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
+ (xf86Info.vtno == -1))
+ {
+ FatalError("xf86OpenConsole: Cannot find a free VT\n");
+ }
+ close(fd);
+ }
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+
+ sprintf(vtname1,"/dev/vc%02d",xf86Info.vtno); /* ESIX */
+ sprintf(vtname2,"/dev/vt%02d",xf86Info.vtno); /* rest of the world */
+
+ if (!KeepTty)
+ {
+ setpgrp();
+ }
+
+ if (((xf86Info.consoleFd = open(vtname1, O_RDWR|O_NDELAY, 0)) < 0) &&
+ ((xf86Info.consoleFd = open(vtname2, O_RDWR|O_NDELAY, 0)) < 0))
+ {
+ FatalError("xf86OpenConsole: Cannot open %s (%s) (%s)\n",
+ vtname2, vtname1, strerror(errno));
+ }
+
+ /* change ownership of the vt */
+ if (chown(vtname1, getuid(), getgid()) < 0)
+ {
+ chown(vtname2, getuid(), getgid());
+ }
+
+ /*
+ * now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
+ {
+ FatalError("xf86OpenConsole: VT_GETMODE failed\n");
+ }
+
+ signal(SIGUSR1, xf86VTRequest);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
+ {
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ {
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
+ }
+ }
+ else
+ {
+ /* serverGeneration != 1 */
+ /*
+ * now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+ }
+ /*
+ * If the server doesn't have the VT when the reset occurs,
+ * this is to make sure we don't continue until the activate
+ * signal is received.
+ */
+ if (!xf86Screens[0]->vtSema)
+ sleep(5);
+ }
+ return;
+}
+
+void
+xf86CloseConsole()
+{
+ struct vt_mode VT;
+
+#if 0
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno);
+ ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0);
+#endif
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
+ {
+ VT.mode = VT_AUTO;
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
+ }
+ close(xf86Info.consoleFd); /* make the vt-manager happy */
+ return;
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty"))
+ {
+ KeepTty = TRUE;
+ return(1);
+ }
+#ifdef SVR4
+ /*
+ * Undocumented flag to protect page 0 from read/write to help
+ * catch NULL pointer dereferences. This is purely a debugging
+ * flag.
+ */
+ if (!strcmp(argv[i], "-protect0"))
+ {
+ Protect0 = TRUE;
+ return(1);
+ }
+#endif
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+ {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
+ {
+ UseMsg();
+ VTnum = -1;
+ return(0);
+ }
+ return(1);
+ }
+ return(0);
+}
+
+void
+xf86UseMsg()
+{
+ ErrorF("vtXX use the specified VT number\n");
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_io.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_io.c
new file mode 100644
index 000000000..6fb642bce
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_io.c
@@ -0,0 +1,78 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_io.c,v 3.10 2002/10/11 01:40:37 dawes Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Dawes <dawes@xfree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Dawes
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Thomas Roell and
+ * David Dawes makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: sysv_io.c /main/8 1996/10/19 18:08:06 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
+{
+ if (loudness && pitch)
+ {
+#ifdef KDMKTONE
+ /*
+ * If we have KDMKTONE use it to avoid putting the server
+ * to sleep
+ */
+ ioctl(xf86Info.consoleFd, KDMKTONE,
+ ((1193190 / pitch) & 0xffff) |
+ (((unsigned long)duration *
+ loudness / 50) << 16));
+#else
+ ioctl(xf86Info.consoleFd, KIOCSOUND, 1193180 / pitch);
+ usleep(xf86Info.bell_duration * loudness * 20);
+ ioctl(xf86Info.consoleFd, KIOCSOUND, 0);
+#endif
+ }
+}
+
+void
+xf86SetKbdLeds(int leds)
+{
+#ifdef KBIO_SETMODE
+ ioctl(xf86Info.consoleFd, KBIO_SETMODE, KBM_AT);
+ ioctl(xf86Info.consoleFd, KDSETLED, leds);
+ ioctl(xf86Info.consoleFd, KBIO_SETMODE, KBM_XT);
+#endif
+}
+
+#include "xf86OSKbd.h"
+
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+ return FALSE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_mouse.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_mouse.c
new file mode 100644
index 000000000..f839362fc
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_mouse.c
@@ -0,0 +1,64 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_mouse.c,v 1.3 1999/09/04 13:04:49 dawes Exp $ */
+
+/*
+ * Copyright 1999 by The XFree86 Project, Inc.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+#include "xqueue.h"
+
+static int
+SupportedInterfaces(void)
+{
+ /* XXX Need to check this. */
+ return MSE_SERIAL | MSE_AUTO;
+}
+
+#ifndef ISC
+static const char *internalNames[] = {
+ "Xqueue",
+ NULL
+};
+
+static const char **
+BuiltinNames(void)
+{
+ return internalNames;
+}
+
+static Bool
+CheckProtocol(const char *protocol)
+{
+ int i;
+
+ for (i = 0; internalNames[i]; i++)
+ if (xf86NameCmp(protocol, internalNames[i]) == 0)
+ return TRUE;
+ return FALSE;
+}
+#endif
+
+OSMouseInfoPtr
+xf86OSMouseInit(int flags)
+{
+ OSMouseInfoPtr p;
+
+ p = xcalloc(sizeof(OSMouseInfoRec), 1);
+ if (!p)
+ return NULL;
+ p->SupportedInterfaces = SupportedInterfaces;
+#ifndef ISC
+ p->BuiltinNames = BuiltinNames;
+ p->CheckProtocol = CheckProtocol;
+ p->PreInit = XqueueMousePreInit;
+#endif
+ return p;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c
new file mode 100644
index 000000000..e8c26dada
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c
@@ -0,0 +1,369 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c,v 3.20tsi Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Thomas Roell and
+ * David Wexelblat makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: sysv_video.c /main/8 1996/10/25 11:38:09 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#define _NEED_SYSI86
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+#ifndef SI86IOPL
+#define SET_IOPL() sysi86(SI86V86,V86SC_IOPL,PS_IOPL)
+#define RESET_IOPL() sysi86(SI86V86,V86SC_IOPL,0)
+#else
+#define SET_IOPL() sysi86(SI86IOPL,3)
+#define RESET_IOPL() sysi86(SI86IOPL,0)
+#endif
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+/*
+ * XXX Support for SVR3 will need to be reworked if needed. In particular
+ * the Region parameter is no longer passed, and will need to be dealt
+ * with internally if required.
+ * OK, i'll rework that thing ... (clean it up a lot)
+ * SVR3 Support only with SVR3_MMAPDRV (mr)
+ *
+ */
+
+#ifdef HAS_SVR3_MMAPDRV
+#ifndef MMAP_DEBUG
+#define MMAP_DEBUG 3
+#endif
+
+struct kd_memloc MapDSC;
+int mmapFd = -2;
+
+static int
+mmapStat(pointer Base, unsigned long Size) {
+
+ int nmmreg,i=0,region=-1;
+ mmapinfo_t *ibuf;
+
+ nmmreg = ioctl(mmapFd, GETNMMREG);
+
+ if(nmmreg <= 0)
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "\nNo physical memory mapped currently.\n\n");
+ else {
+ if((ibuf = (mmapinfo_t *)malloc(nmmreg*sizeof(mmapinfo_t))) == NULL)
+ xf86Msg(X_WARNING,
+ "Couldn't allocate memory 4 mmapinfo_t\n");
+ else {
+ if(ioctl(mmapFd, GETMMREG, ibuf) != -1)
+ {
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# mmapStat: [Size=%x,Base=%x]\n", Size, Base);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# Physical Address Size Reference Count\n");
+ for(i = 0; i < nmmreg; i++) {
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "%-4d 0x%08X %5dk %5d ",
+ i, ibuf[i].physaddr, ibuf[i].length/1024, ibuf[i].refcnt);
+ if (ibuf[i].physaddr == Base || ibuf[i].length == Size ) {
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,"MATCH !!!");
+ if (region==-1) region=i;
+ }
+ xf86ErrorFVerb(MMAP_DEBUG, "\n");
+ }
+ xf86ErrorFVerb(MMAP_DEBUG, "\n");
+ }
+ free(ibuf);
+ }
+ }
+ if (region == -1 && nmmreg > 0) region=region * i;
+ return(region);
+}
+#endif
+
+
+static Bool
+linearVidMem()
+{
+#ifdef SVR4
+ return TRUE;
+#elif defined(HAS_SVR3_MMAPDRV)
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# xf86LinearVidMem: MMAP 2.2.2 called\n");
+
+ if(mmapFd >= 0) return TRUE;
+
+ if ((mmapFd = open("/dev/mmap", O_RDWR)) != -1)
+ {
+ if(ioctl(mmapFd, GETVERSION) < 0x0222) {
+ xf86Msg(X_WARNING,
+ "xf86LinearVidMem: MMAP 2.2.2 or above required\n");
+ xf86ErrorF("\tlinear memory access disabled\n");
+ return FALSE;
+ }
+ return TRUE;
+ }
+ xf86Msg(X_WARNING, "xf86LinearVidMem: failed to open /dev/mmap (%s)\n",
+ strerror(errno));
+ xf86ErrorF("\tlinear memory access disabled\n");
+ return FALSE;
+#endif
+}
+
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ pointer base;
+ int fd;
+
+#if defined(SVR4)
+ fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
+ if (fd < 0)
+ {
+ FatalError("xf86MapVidMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ base = mmap((caddr_t)0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_SHARED, fd, (off_t)Base);
+ close(fd);
+ if (base == MAP_FAILED)
+ {
+ FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
+ "xf86MapVidMem", Size, Base, strerror(errno));
+ }
+#else /* SVR4 */
+#ifdef HAS_SVR3_MMAPDRV
+
+ xf86MsgVerb(X_INFO, MMAP_DEBUG, "# xf86MapVidMem: MMAP 2.2.2 called\n");
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION));
+ if (ioctl(mmapFd, GETVERSION) == -1)
+ {
+ xf86LinearVidMem();
+ }
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION));
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "xf86MapVidMem: Screen: %d\n", ScreenNum);
+ mmapStat(Base,Size);
+ /* To force the MMAP driver to provide the address */
+ base = (pointer)0;
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "xf86MapVidMem: [s=%x,a=%x]\n", Size, Base);
+ MapDSC.vaddr = (char *)base;
+ MapDSC.physaddr = (char *)Base;
+ MapDSC.length = Size;
+ MapDSC.ioflg = 1;
+ if(mmapFd >= 0)
+ {
+ if((base = (pointer)ioctl(mmapFd, MAP, &MapDSC)) == (pointer)-1)
+ {
+ FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
+ "xf86MapVidMem", Size, Base, strerror(errno));
+ /* NOTREACHED */
+ }
+
+ /* Next time we want the same address! */
+ MapDSC.vaddr = (char *)base;
+ }
+
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MapDSC.vaddr : 0x%x\n", MapDSC.vaddr);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MapDSC.physaddr: 0x%x\n", MapDSC.physaddr);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MapDSC.length : %d\n", MapDSC.length);
+ mmapStat(Base,Size);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "xf86MapVidMem: [s=%x,a=%x,b=%x]\n", Size, Base, base);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "xf86MapVidMem: SUCCEED Mapping FrameBuffer \n");
+#endif /* HAS_SVR3_MMAPDRV */
+#endif /* SVR4 */
+ return(base);
+}
+
+/* ARGSUSED */
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+#if defined (SVR4)
+ munmap(Base, Size);
+#else /* SVR4 */
+#ifdef HAS_SVR3_MMAPDRV
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# xf86UnMapVidMem: UNMapping FrameBuffer\n");
+ mmapStat(Base,Size);
+ ioctl(mmapFd, UNMAPRM , Base);
+ mmapStat(Base,Size);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# xf86UnMapVidMem: Screen: %d [v=%x]\n", ScreenNum, Base);
+#endif /* HAS_SVR3_MMAPDRV */
+#endif /* SVR4 */
+ return;
+}
+
+#if defined(SVR4) && defined(i386) && !defined(sun)
+/*
+ * For some SVR4 versions, a 32-bit read is done for the first location
+ * in each page when the page is first mapped. If this is done while
+ * memory access is enabled for regions that have read side-effects,
+ * this can cause unexpected results, including lockups on some hardware.
+ * This function is called to make sure each page is mapped while it is
+ * safe to do so.
+ */
+
+/*
+ * XXX Should get this the correct way (see os/xalloc.c), but since this is
+ * for one platform I'll be lazy.
+ */
+#define X_PAGE_SIZE 4096
+
+static void
+readSideEffects(int ScreenNum, pointer Base, unsigned long Size)
+{
+ unsigned long base, end, addr;
+ CARD32 val;
+
+ base = (unsigned long)Base;
+ end = base + Size;
+
+ for (addr = base; addr < end; addr += X_PAGE_SIZE)
+ val = *(volatile CARD32 *)addr;
+}
+#endif
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->linearSupported = linearVidMem();
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+#if defined(SVR4) && defined(i386) && !defined(sun)
+ pVidMem->readSideEffects = readSideEffects;
+#endif
+ pVidMem->initialised = TRUE;
+}
+
+/***************************************************************************/
+/* I/O Permissions section */
+/***************************************************************************/
+
+static Bool ExtendedEnabled = FALSE;
+static Bool InitDone = FALSE;
+
+Bool
+xf86EnableIO()
+{
+ int i;
+
+ if (ExtendedEnabled)
+ return TRUE;
+
+ if (SET_IOPL() < 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86EnableIO: Failed to set IOPL for extended I/O\n");
+ return FALSE;
+ }
+ ExtendedEnabled = TRUE;
+
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ if (!ExtendedEnabled)
+ return;
+
+ RESET_IOPL();
+ ExtendedEnabled = FALSE;
+
+ return;
+}
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+Bool
+xf86DisableInterrupts()
+{
+ if (!ExtendedEnabled)
+ {
+ if (SET_IOPL() < 0)
+ {
+ return(FALSE);
+ }
+ }
+
+#ifdef __GNUC__
+ __asm__ __volatile__("cli");
+#else
+ asm("cli");
+#endif /* __GNUC__ */
+
+ if (!ExtendedEnabled)
+ {
+ RESET_IOPL();
+ }
+ return(TRUE);
+}
+
+void
+xf86EnableInterrupts()
+{
+ if (!ExtendedEnabled)
+ {
+ if (SET_IOPL() < 0)
+ {
+ return;
+ }
+ }
+
+#ifdef __GNUC__
+ __asm__ __volatile__("sti");
+#else
+ asm("sti");
+#endif /* __GNUC__ */
+
+ if (!ExtendedEnabled)
+ {
+ RESET_IOPL();
+ }
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/xqueue.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/xqueue.c
new file mode 100644
index 000000000..6c2132cef
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/xqueue.c
@@ -0,0 +1,543 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/xqueue.c,v 3.19 2000/02/10 22:33:45 dawes Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993-1999 by The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: xqueue.c /main/8 1996/10/19 18:08:11 kaleb $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+#include "xqueue.h"
+
+#ifdef XQUEUE
+
+static xqEventQueue *XqueQaddr;
+static int xqueFd = -1;
+#ifndef XQUEUE_ASYNC
+static int xquePipe[2];
+#endif
+
+#ifdef XKB
+#include "inputstr.h"
+#include <X11/extensions/XKB.h>
+#include <X11/extensions/XKBstr.h>
+#include <X11/extensions/XKBsrv.h>
+extern Bool noXkbExtension;
+#endif
+
+#include "xf86Xinput.h"
+#include "mipointer.h"
+
+typedef struct {
+ int xquePending;
+ int xqueSema;
+} XqInfoRec, *XqInfoPtr;
+
+InputInfoPtr XqMouse = NULL;
+InputInfoPtr XqKeyboard = NULL;
+
+#ifndef XQUEUE_ASYNC
+/*
+ * xf86XqueSignal --
+ * Trap the signal from xqueue and let it be known that events are
+ * ready for collection
+ */
+
+static void
+xf86XqueSignal(int signum)
+{
+ ((XqInfoPtr)(((MouseDevPtr)(XqMouse->private))->mousePriv))->xquePending = 1;
+ /*
+ * This is a hack, but it is the only reliable way I can find of letting
+ * the main select() loop know that there is more input waiting. Receiving
+ * a signal will interrupt select(), but there is no way I can find of
+ * dealing with events that come in between the end of processing the
+ * last set and when select() gets called.
+ *
+ * Suggestions for better ways of dealing with this without going back to
+ * asynchronous event processing are welcome.
+ */
+#ifdef DEBUG
+ ErrorF("xf86XqueSignal\n");
+#endif
+ write(xquePipe[1], "X", 1);
+ signal(SIGUSR2, xf86XqueSignal);
+}
+#endif
+
+
+/*
+ * xf86XqueKbdProc --
+ * Handle the initialization, etc. of a keyboard.
+ */
+
+int
+xf86XqueKbdProc(DeviceIntPtr pKeyboard, int what)
+{
+ KeySymsRec keySyms;
+ CARD8 modMap[MAP_LENGTH];
+
+ switch (what) {
+
+ case DEVICE_INIT:
+
+ xf86KbdGetMapping(&keySyms, modMap);
+
+ /*
+ * Get also the initial led settings
+ */
+ ioctl(xf86Info.consoleFd, KDGETLED, &xf86Info.leds);
+
+ /*
+ * Perform final initialization of the system private keyboard
+ * structure and fill in various slots in the device record
+ * itself which couldn't be filled in before.
+ */
+ pKeyboard->public.on = FALSE;
+
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ InitKeyboardDeviceStruct((DevicePtr)xf86Info.pKeyboard,
+ &keySyms,
+ modMap,
+ xf86KbdBell,
+ (KbdCtrlProcPtr)xf86KbdCtrl);
+#ifdef XKB
+ } else {
+ XkbComponentNamesRec names;
+ if (XkbInitialMap) {
+ if ((xf86Info.xkbkeymap = strchr(XkbInitialMap, '/')) != NULL)
+ xf86Info.xkbkeymap++;
+ else
+ xf86Info.xkbkeymap = XkbInitialMap;
+ }
+ if (xf86Info.xkbkeymap) {
+ names.keymap = xf86Info.xkbkeymap;
+ names.keycodes = NULL;
+ names.types = NULL;
+ names.compat = NULL;
+ names.symbols = NULL;
+ names.geometry = NULL;
+ } else {
+ names.keymap = NULL;
+ names.keycodes = xf86Info.xkbkeycodes;
+ names.types = xf86Info.xkbtypes;
+ names.compat = xf86Info.xkbcompat;
+ names.symbols = xf86Info.xkbsymbols;
+ names.geometry = xf86Info.xkbgeometry;
+ }
+ if ((xf86Info.xkbkeymap || xf86Info.xkbcomponents_specified)
+ && (xf86Info.xkbmodel == NULL || xf86Info.xkblayout == NULL)) {
+ xf86Info.xkbrules = NULL;
+ }
+ XkbSetRulesDflts(xf86Info.xkbrules, xf86Info.xkbmodel,
+ xf86Info.xkblayout, xf86Info.xkbvariant,
+ xf86Info.xkboptions);
+ XkbInitKeyboardDeviceStruct(pKeyboard,
+ &names,
+ &keySyms,
+ modMap,
+ xf86KbdBell,
+ (KbdCtrlProcPtr)xf86KbdCtrl);
+ }
+#endif
+
+ xf86InitKBD(TRUE);
+ break;
+
+ case DEVICE_ON:
+ pKeyboard->public.on = TRUE;
+ xf86InitKBD(FALSE);
+ break;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ pKeyboard->public.on = FALSE;
+ break;
+ }
+
+ return (Success);
+}
+
+
+/*
+ * xf86XqueEvents --
+ * Get some events from our queue. Nothing to do here ...
+ */
+
+void
+xf86XqueEvents()
+{
+}
+
+
+#ifdef XQUEUE_ASYNC
+static void XqDoInput(int signum);
+#endif
+
+void
+XqReadInput(InputInfoPtr pInfo)
+{
+ MouseDevPtr pMse;
+ XqInfoPtr pXq;
+ xqEvent *XqueEvents;
+ int XqueHead;
+ char buf[100];
+ signed char dx, dy;
+
+ if (xqueFd < 0)
+ return;
+
+ pMse = pInfo->private;
+ pXq = pMse->mousePriv;
+
+ XqueEvents = XqueQaddr->xq_events;
+ XqueHead = XqueQaddr->xq_head;
+
+ while (XqueHead != XqueQaddr->xq_tail) {
+ switch (XqueEvents[XqueHead].xq_type) {
+ case XQ_BUTTON:
+ pMse->PostEvent(pInfo, ~(XqueEvents[XqueHead].xq_code) & 0x07,
+ 0, 0, 0, 0);
+#ifdef DEBUG
+ ErrorF("xqueue: buttons: %d\n", ~(XqueEvents[XqueHead].xq_code) & 0x07);
+#endif
+ break;
+
+ case XQ_MOTION:
+ dx = (signed char)XqueEvents[XqueHead].xq_x;
+ dy = (signed char)XqueEvents[XqueHead].xq_y;
+ pMse->PostEvent(pInfo, ~(XqueEvents[XqueHead].xq_code) & 0x07,
+ (int)dx, (int)dy, 0, 0);
+#ifdef DEBUG
+ ErrorF("xqueue: Motion: (%d, %d) (buttons: %d)\n", dx, dy, ~(XqueEvents[XqueHead].xq_code) & 0x07);
+#endif
+ break;
+
+ case XQ_KEY:
+ /* XXX Need to deal with the keyboard part nicely. */
+#ifdef DEBUG
+ ErrorF("xqueue: key: %d\n", XqueEvents[XqueHead].xq_code);
+#endif
+ xf86PostKbdEvent(XqueEvents[XqueHead].xq_code);
+ break;
+ default:
+ xf86Msg(X_WARNING, "Unknown Xque Event: 0x%02x\n",
+ XqueEvents[XqueHead].xq_type);
+ }
+
+ if ((++XqueHead) == XqueQaddr->xq_size) XqueHead = 0;
+ xf86Info.inputPending = TRUE;
+ }
+
+ /* reenable the signal-processing */
+#ifdef XQUEUE_ASYNC
+ signal(SIGUSR2, XqDoInput);
+#endif
+
+#ifndef XQUEUE_ASYNC
+ {
+ int rval;
+
+ while ((rval = read(xquePipe[0], buf, sizeof(buf))) > 0)
+#ifdef DEBUG
+ ErrorF("Read %d bytes from xquePipe[0]\n", rval);
+#else
+ ;
+#endif
+ }
+#endif
+
+#ifdef DEBUG
+ ErrorF("Leaving XqReadInput()\n");
+#endif
+ pXq->xquePending = 0;
+ XqueQaddr->xq_head = XqueQaddr->xq_tail;
+ XqueQaddr->xq_sigenable = 1; /* UNLOCK */
+}
+
+#ifdef XQUEUE_ASYNC
+static void
+XqDoInput(int signum)
+{
+ if (XqMouse)
+ XqReadInput(XqMouse);
+}
+#endif
+
+static void
+XqBlock(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
+{
+ InputInfoPtr pInfo;
+ MouseDevPtr pMse;
+ XqInfoPtr pXq;
+ /*
+ * On MP SVR4 boxes, a race condition exists because the XQUEUE does
+ * not have anyway to lock it for exclusive access. This results in one
+ * processor putting something on the queue at the same time the other
+ * processor is taking it something off. The count of items in the queue
+ * can get off by 1. This just goes and checks to see if an extra event
+ * was put in the queue a during this period. The signal for this event
+ * was ignored while processing the previous event.
+ */
+
+ pInfo = blockData;
+ pMse = pInfo->private;
+ pXq = pMse-> mousePriv;
+ if (!pXq->xquePending) {
+#ifdef DEBUG
+ ErrorF("XqBlock: calling XqReadInput()\n");
+#endif
+ XqReadInput((InputInfoPtr)blockData);
+ } else {
+#ifdef DEBUG
+ ErrorF("XqBlock: not calling XqReadInput()\n");
+#endif
+ ;
+ }
+ /*
+ * Make sure that any events that come in here are passed on without.
+ * waiting for the next wakeup.
+ */
+ if (xf86Info.inputPending) {
+#ifdef DEBUG
+ ErrorF("XqBlock: calling ProcessInputEvents()\n");
+#endif
+ ProcessInputEvents();
+ } else {
+#ifdef DEBUG
+ ErrorF("XqBlock: not calling ProcessInputEvents()\n");
+#endif
+ ;
+ }
+}
+
+/*
+ * XqEnable --
+ * Enable the handling of the Xque
+ */
+
+static int
+XqEnable(InputInfoPtr pInfo)
+{
+ MouseDevPtr pMse;
+ XqInfoPtr pXq;
+ static struct kd_quemode xqueMode;
+ static Bool was_here = FALSE;
+
+ pMse = pInfo->private;
+ pXq = pMse->mousePriv;
+
+ if (xqueFd < 0) {
+ if ((xqueFd = open("/dev/mouse", O_RDONLY | O_NDELAY)) < 0) {
+ if (xf86GetAllowMouseOpenFail()) {
+ xf86Msg(X_WARNING,
+ "%s: Cannot open /dev/mouse (%s) - Continuing...\n",
+ pInfo->name, strerror(errno));
+ return Success;
+ } else {
+ xf86Msg(X_ERROR, "%s: Cannot open /dev/mouse (%s)\n",
+ pInfo->name, strerror(errno));
+ return !Success;
+ }
+ }
+ }
+#ifndef XQUEUE_ASYNC
+ if (!was_here) {
+ pipe(xquePipe);
+ fcntl(xquePipe[0], F_SETFL, fcntl(xquePipe[0], F_GETFL, 0) | O_NDELAY);
+ fcntl(xquePipe[1], F_SETFL, fcntl(xquePipe[1], F_GETFL, 0) | O_NDELAY);
+ was_here = TRUE;
+ }
+#endif
+
+ if (pXq->xqueSema++ == 0) {
+#ifdef XQUEUE_ASYNC
+ (void) signal(SIGUSR2, XqDoInput);
+#else
+ (void) signal(SIGUSR2, xf86XqueSignal);
+#endif
+ xqueMode.qsize = 64; /* max events */
+ xqueMode.signo = SIGUSR2;
+ ioctl(xf86Info.consoleFd, KDQUEMODE, NULL);
+
+ if (ioctl(xf86Info.consoleFd, KDQUEMODE, &xqueMode) < 0) {
+ xf86Msg(X_ERROR, "%s: Cannot set KDQUEMODE", pInfo->name);
+ return !Success;
+ }
+ XqueQaddr = (xqEventQueue *)xqueMode.qaddr;
+ XqueQaddr->xq_sigenable = 1; /* UNLOCK */
+ }
+
+ return Success;
+}
+
+
+
+/*
+ * xf86XqueDisable --
+ * disable the handling of the Xque
+ */
+
+static int
+XqDisable(InputInfoPtr pInfo)
+{
+ MouseDevPtr pMse;
+ XqInfoPtr pXq;
+
+ pMse = pInfo->private;
+ pXq = pMse->mousePriv;
+
+ if (pXq->xqueSema-- == 1)
+ {
+ XqueQaddr->xq_sigenable = 0; /* LOCK */
+
+ if (ioctl(xf86Info.consoleFd, KDQUEMODE, NULL) < 0) {
+ xf86Msg(X_ERROR, "%s: Cannot unset KDQUEMODE", pInfo->name);
+ return !Success;
+ }
+ }
+
+ if (xqueFd >= 0) {
+ close(xqueFd);
+ xqueFd = -1;
+ }
+
+ return Success;
+}
+
+/*
+ * XqMouseProc --
+ * Handle the initialization, etc. of a mouse
+ */
+
+static int
+XqMouseProc(DeviceIntPtr pPointer, int what)
+{
+ InputInfoPtr pInfo;
+ MouseDevPtr pMse;
+ unchar map[4];
+ int ret;
+
+ pInfo = pPointer->public.devicePrivate;
+ pMse = pInfo->private;
+ pMse->device = pPointer;
+
+ switch (what) {
+ case DEVICE_INIT:
+ pPointer->public.on = FALSE;
+
+ map[1] = 1;
+ map[2] = 2;
+ map[3] = 3;
+
+ InitPointerDeviceStruct((DevicePtr)pPointer,
+ map,
+ 3,
+ miPointerGetMotionEvents,
+ pMse->Ctrl,
+ miPointerGetMotionBufferSize());
+ /* X valuator */
+ xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 0);
+ /* Y valuator */
+ xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 1);
+ xf86MotionHistoryAllocate(pInfo);
+ RegisterBlockAndWakeupHandlers(XqBlock, (WakeupHandlerProcPtr)NoopDDA,
+ pInfo);
+ break;
+
+ case DEVICE_ON:
+ pMse->lastButtons = 0;
+ pMse->lastMappedButtons = 0;
+ pMse->emulateState = 0;
+ pPointer->public.on = TRUE;
+ ret = XqEnable(pInfo);
+#ifndef XQUEUE_ASYNC
+ if (xquePipe[0] != -1) {
+ pInfo->fd = xquePipe[0];
+ AddEnabledDevice(xquePipe[0]);
+ }
+#endif
+ return ret;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ pPointer->public.on = FALSE;
+ ret = XqDisable(pInfo);
+#ifndef XQUEUE_ASYNC
+ if (xquePipe[0] != -1) {
+ RemoveEnabledDevice(xquePipe[0]);
+ pInfo->fd = -1;
+ }
+#endif
+ return ret;
+ }
+ return Success;
+}
+
+Bool
+XqueueMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ MouseDevPtr pMse;
+ XqInfoPtr pXq;
+
+ pMse = pInfo->private;
+ pMse->protocol = protocol;
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
+ pXq = pMse->mousePriv = xnfcalloc(sizeof(XqInfoRec), 1);
+
+ /* Collect the options, and process the common options. */
+ xf86CollectInputOptions(pInfo, NULL, NULL);
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
+
+ /* Process common mouse options (like Emulate3Buttons, etc). */
+ pMse->CommonOptions(pInfo);
+
+ /* Setup the local procs. */
+ pInfo->device_control = XqMouseProc;
+#ifdef XQUEUE_ASYNC
+ pInfo->read_input = NULL;
+#else
+ pInfo->read_input = XqReadInput;
+#endif
+ pInfo->fd = -1;
+
+ XqMouse = pInfo;
+
+ pInfo->flags |= XI86_CONFIGURED;
+ return TRUE;
+}
+
+#endif /* XQUEUE */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/xqueue.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/xqueue.h
new file mode 100644
index 000000000..d693d2b36
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/xqueue.h
@@ -0,0 +1,12 @@
+/* $XFree86$ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _XF86_XQUEUE_H_
+#define _XF86_XQUEUE_H_
+
+Bool XqueueMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/Imakefile
new file mode 100644
index 000000000..034c9c7d6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/Imakefile
@@ -0,0 +1,40 @@
+XCOMM $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/usl/Imakefile,v 1.2 2005/11/08 06:33:29 jkj Exp $
+XCOMM $XConsortium$
+
+#include <Server.tmpl>
+
+SRCS = usl_init.c usl_video.c usl_io.c usl_iop.c usl_mouse.c usl_vtsw.c \
+ usl_xqueue.c std_kbdEv.c posix_tty.c bios_mmap.c vidmem.c \
+ libc_wrapper.c stdResource.c stdPci.c sigiostubs.c pm_noop.c \
+ kmod_noop.c agp_noop.c usl_kbd.c at_scancode.c usl_KbdMap.c
+
+OBJS = usl_init.o usl_video.o usl_io.o usl_iop.o usl_mouse.o usl_vtsw.o \
+ usl_xqueue.o std_kbdEv.o posix_tty.o bios_mmap.o vidmem.o \
+ libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o \
+ kmod_noop.o agp_noop.o usl_kbd.o at_scancode.o usl_KbdMap.o
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+ -I$(SERVERSRC)/mi -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+RESDEFINES = -DUSESTDRES
+
+DEFINES = $(RESDEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+LinkSourceFile(bios_mmap.c,../shared)
+LinkSourceFile(std_kbdEv.c,../shared)
+LinkSourceFile(at_scancode.c,../shared)
+LinkSourceFile(posix_tty.c,../shared)
+LinkSourceFile(libc_wrapper.c,../shared)
+LinkSourceFile(stdResource.c,../shared)
+LinkSourceFile(stdPci.c,../shared)
+LinkSourceFile(sigiostubs.c,../shared)
+LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
+LinkSourceFile(agp_noop.c,../shared)
+LinkSourceFile(vidmem.c,../shared)
+
+DependTarget()
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_KbdMap.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_KbdMap.c
new file mode 100644
index 000000000..57c73f07a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_KbdMap.c
@@ -0,0 +1,304 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/usl/usl_KbdMap.c,v 1.2 2005/11/08 06:33:29 jkj Exp $ */
+/*
+ * Copyright 2005 by J. Kean Johnston <jkj@sco.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name J. Kean Johnston not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. J. Kean Johnston makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * Based on xf86KbdMap.c, which is
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ * Copyright (c) 1992-2003 by The XFree86 Project, Inc.
+ */
+
+#include "X.h"
+#include "Xmd.h"
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86Xinput.h"
+#include "xf86OSKbd.h"
+#include "atKeynames.h"
+#include "xf86Keymap.h"
+
+#include "usl_kbd.h"
+
+#define KD_GET_ENTRY(i,n) \
+ eascii_to_x[((priv->keymap.key[i].spcl << (n+1)) & 0x100) + priv->keymap.key[i].map[n]]
+
+/*
+ * NOTE: Not all possible remappable symbols are remapped. There are two main
+ * reasons:
+ * a) The mapping between scancode and SYSV/386 - symboltable
+ * is inconsistent between different versions and has some
+ * BIG mistakes.
+ * b) In X-Windows there is a difference between numpad-keys
+ * and normal keys. SYSV/386 uses for both kinds of keys
+ * the same symbol.
+ *
+ * Thus only the alpha keypad and the function keys are translated.
+ * Also CapsLock, NumLock, ScrollLock, Shift, Control & Alt.
+ */
+
+static unsigned char remap[128] = {
+ 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0, /* 0x30 - 0x37 */
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38 - 0x3f */
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0, /* 0x40 - 0x47 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */
+ 0, 0, 0, 0, 0, 0, 0x56, 0x57, /* 0x50 - 0x57 */
+ 0x58, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x67 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68 - 0x6f */
+ 0, 0, 0x69, 0x65, 0, 0, 0, 0, /* 0x70 - 0x77 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */
+};
+
+static KeySym eascii_to_x[512] = {
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, XK_Return, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Escape,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
+ XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
+ XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
+ XK_comma, XK_minus, XK_period, XK_slash,
+ XK_0, XK_1, XK_2, XK_3,
+ XK_4, XK_5, XK_6, XK_7,
+ XK_8, XK_9, XK_colon, XK_semicolon,
+ XK_less, XK_equal, XK_greater, XK_question,
+ XK_at, XK_A, XK_B, XK_C,
+ XK_D, XK_E, XK_F, XK_G,
+ XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O,
+ XK_P, XK_Q, XK_R, XK_S,
+ XK_T, XK_U, XK_V, XK_W,
+ XK_X, XK_Y, XK_Z, XK_bracketleft,
+ XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
+ XK_grave, XK_a, XK_b, XK_c,
+ XK_d, XK_e, XK_f, XK_g,
+ XK_h, XK_i, XK_j, XK_k,
+ XK_l, XK_m, XK_n, XK_o,
+ XK_p, XK_q, XK_r, XK_s,
+ XK_t, XK_u, XK_v, XK_w,
+ XK_x, XK_y, XK_z, XK_braceleft,
+ XK_bar, XK_braceright, XK_asciitilde, XK_Delete,
+ XK_Ccedilla, XK_udiaeresis, XK_eacute, XK_acircumflex,
+ XK_adiaeresis, XK_agrave, XK_aring, XK_ccedilla,
+ XK_ecircumflex, XK_ediaeresis, XK_egrave, XK_idiaeresis,
+ XK_icircumflex, XK_igrave, XK_Adiaeresis, XK_Aring,
+ XK_Eacute, XK_ae, XK_AE, XK_ocircumflex,
+ XK_odiaeresis, XK_ograve, XK_ucircumflex, XK_ugrave,
+ XK_ydiaeresis, XK_Odiaeresis, XK_Udiaeresis, XK_cent,
+ XK_sterling, XK_yen, XK_paragraph, XK_section,
+ XK_aacute, XK_iacute, XK_oacute, XK_uacute,
+ XK_ntilde, XK_Ntilde, XK_ordfeminine, XK_masculine,
+ XK_questiondown,XK_hyphen, XK_notsign, XK_onehalf,
+ XK_onequarter, XK_exclamdown, XK_guillemotleft,XK_guillemotright,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_Greek_alpha, XK_ssharp, XK_Greek_GAMMA, XK_Greek_pi,
+ XK_Greek_SIGMA, XK_Greek_sigma, XK_mu, XK_Greek_tau,
+ XK_Greek_PHI, XK_Greek_THETA, XK_Greek_OMEGA, XK_Greek_delta,
+ XK_infinity, XK_Ooblique, XK_Greek_epsilon, XK_intersection,
+ XK_identical, XK_plusminus, XK_greaterthanequal, XK_lessthanequal,
+ XK_topintegral, XK_botintegral, XK_division, XK_similarequal,
+ XK_degree, NoSymbol, NoSymbol, XK_radical,
+ XK_Greek_eta, XK_twosuperior, XK_periodcentered, NoSymbol,
+
+ /*
+ * special marked entries (256 + x)
+ */
+
+ NoSymbol, NoSymbol, XK_Shift_L, XK_Shift_R,
+ XK_Caps_Lock, XK_Num_Lock, XK_Scroll_Lock, XK_Alt_L,
+ NoSymbol, XK_Control_L, XK_Alt_L, XK_Alt_R,
+ XK_Control_L, XK_Control_R, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_F1,
+ XK_F2, XK_F3, XK_F4, XK_F5,
+ XK_F6, XK_F7, XK_F8, XK_F9,
+ XK_F10, XK_F11, XK_F12, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ };
+
+/*
+ * KbdGetMapping --
+ * Get the national keyboard mapping. The keyboard type is set, a new map
+ * and the modifiermap is computed.
+ */
+
+void
+KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ USLKbdPrivPtr priv = (USLKbdPrivPtr) pKbd->private;
+ KeySym *k;
+ int i;
+ KeySym *pMap = map;
+
+ for (i = 0; i < priv->keymap.n_keys && i < NUM_KEYCODES; i++) {
+ if (remap[i]) {
+ k = pMap + (remap[i] << 2);
+
+ k[0] = KD_GET_ENTRY(i,0); /* non-shifed */
+ k[1] = KD_GET_ENTRY(i,1); /* shifted */
+ k[2] = KD_GET_ENTRY(i,4); /* alt */
+ k[3] = KD_GET_ENTRY(i,5); /* alt - shifted */
+
+ if (k[3] == k[2]) k[3] = NoSymbol;
+ if (k[2] == k[1]) k[2] = NoSymbol;
+ if (k[1] == k[0]) k[1] = NoSymbol;
+ if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
+ }
+ }
+
+ /*
+ * compute the modifier map
+ */
+ for (i = 0; i < MAP_LENGTH; i++)
+ pModMap[i] = NoSymbol; /* make sure it is restored */
+
+ for (k = pMap, i = MIN_KEYCODE;
+ i < (NUM_KEYCODES + MIN_KEYCODE);
+ i++, k += 4) {
+
+ switch(*k) {
+ case XK_Shift_L:
+ case XK_Shift_R:
+ pModMap[i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ case XK_Control_R:
+ pModMap[i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ pModMap[i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ case XK_Alt_R:
+ pModMap[i] = AltMask;
+ break;
+
+ case XK_Num_Lock:
+ pModMap[i] = NumLockMask;
+ break;
+
+ case XK_Scroll_Lock:
+ pModMap[i] = ScrollLockMask;
+ break;
+
+ /* kana support */
+ case XK_Kana_Lock:
+ case XK_Kana_Shift:
+ pModMap[i] = KanaMask;
+ break;
+
+ /* alternate toggle for multinational support */
+ case XK_Mode_switch:
+ pModMap[i] = AltLangMask;
+ break;
+ }
+ }
+
+ pKeySyms->map = pMap;
+ pKeySyms->mapWidth = GLYPHS_PER_KEY;
+ pKeySyms->minKeyCode = MIN_KEYCODE;
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_init.c
new file mode 100644
index 000000000..35410b688
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_init.c
@@ -0,0 +1,359 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/usl/usl_init.c,v 1.2 2005/11/08 06:33:29 jkj Exp $ */
+/*
+ * Copyright 2001-2005 by Kean Johnston <jkj@sco.com>
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell, David Wexelblat
+ * and Kean Johnston not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Thomas Roell, David Wexelblat and Kean Johnston make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL, DAVID WEXELBLAT AND KEAN JOHNSTON DISCLAIM ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THOMAS ROELLm DAVID WEXELBLAT
+ * OR KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ *
+ */
+/* $XConsortium$ */
+
+#include "X.h"
+#include "Xmd.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include <sys/utsname.h>
+
+static Bool KeepTty = FALSE;
+static Bool Protect0 = FALSE;
+static Bool CRTSpecified = FALSE;
+static int VTnum = -1;
+static char vtdevice[48];
+
+int usl_is_osr6 = -1;
+
+static Bool
+IsConsoleDevice(const char *dev)
+{
+ if ((!strcmp (dev, "/dev/console")) ||
+ (!strcmp (dev, "/dev/syscon")) ||
+ (!strcmp (dev, "/dev/systty")))
+ return TRUE;
+
+ return FALSE;
+}
+
+static int
+is_osr6 (void)
+{
+ struct utsname uts;
+
+ if (usl_is_osr6 == -1) {
+ if (uname (&uts) < 0) {
+ FatalError ("get_usl_ver: Failed to determine UNIX name (%s)\n",
+ strerror (errno));
+ }
+
+ if (uts.version[0] == '6')
+ usl_is_osr6 = 1;
+ else
+ usl_is_osr6 = 0;
+ }
+
+ return usl_is_osr6;
+}
+
+
+void
+xf86OpenConsole(void)
+{
+ int fd, i, ioctl_ret;
+ struct vt_mode VT;
+ struct vt_stat vts;
+ MessageType from = X_PROBED;
+ struct sigaction sigvtsw;
+ char *ttn;
+
+ if (serverGeneration == 1) {
+ int isconsole = 0, consdev = 0;
+
+ /* check if we're run with euid==0 */
+ if (geteuid() != 0) {
+ FatalError("xf86OpenConsole: Server must be suid root\n");
+ }
+
+ /* If we are run in the background we will get SIGTTOU. Ignore it. */
+ OsSignal (SIGTTOU, SIG_IGN);
+
+ /* Protect page 0 to help find NULL dereferencing */
+ /* mprotect() doesn't seem to work */
+ if (Protect0) {
+ int fd = -1;
+
+ if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0) {
+ xf86Msg(X_WARNING, "xf86OpenConsole: cannot open /dev/zero (%s)\n",
+ strerror(errno));
+ } else {
+ if ((int)mmap(0, 0x1000, PROT_NONE,
+ MAP_FIXED | MAP_SHARED, fd, 0) == -1) {
+ xf86Msg(X_WARNING, "xf86OpenConsole: failed to protect page 0 (%s)\n",
+ strerror(errno));
+ }
+ close(fd);
+ }
+ }
+
+ /*
+ * setup the virtual terminal manager
+ */
+ if (VTnum == -1) {
+ /*
+ * No device was specified. We need to query the kernel to see which
+ * console device we are on (and in fact if we are on a console at all).
+ */
+ if (ioctl (0, VT_GETSTATE, &vts) < 0) {
+ FatalError("xf86OpenConsole: Could not query active VT: %s\n",
+ strerror(errno));
+ }
+ VTnum = vts.v_active;
+ if (is_osr6())
+ snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum + 1);
+ else
+ snprintf (vtdevice, sizeof(vtdevice), "/dev/vt%02d", VTnum);
+ } else {
+ from = X_CMDLINE;
+ if (is_osr6())
+ snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum + 1);
+ else
+ snprintf (vtdevice, sizeof(vtdevice), "/dev/vt%02d", VTnum);
+ }
+
+ if (IsConsoleDevice(vtdevice)) {
+ isconsole = 1;
+ CRTSpecified = FALSE; /* Dont honour -crt /dev/console */
+ }
+
+ if (ioctl (0, KIOCINFO, 0) >= 0)
+ consdev = 1 + isconsole;
+
+ if ((!CRTSpecified) && (isconsole || (!consdev))) {
+ /*
+ * Need to find a free VT
+ */
+ if ((fd = open ("/dev/console", O_WRONLY | O_NOCTTY)) < 0) {
+ FatalError ("xf86OpenConsole: Could not open /dev/console: %s\n",
+ strerror (errno));
+ }
+
+ if (ioctl (fd, VT_OPENQRY, &VTnum) < 0) {
+ FatalError ("xf86OpenConsole: Cannot find a free VT: %s\n",
+ strerror(errno));
+ }
+ close (fd);
+ if (usl_is_osr6)
+ snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum + 1);
+ else
+ snprintf (vtdevice, sizeof(vtdevice), "/dev/vt%02d", VTnum);
+ }
+
+ /*
+ * Now we can dispose of stdin/stdout
+ */
+ fclose (stdin);
+ fclose (stdout);
+
+ if (CRTSpecified || isconsole || consdev != 1) {
+ if (!KeepTty) {
+ setpgrp();
+ }
+ }
+
+ if ((xf86Info.consoleFd = open(vtdevice, O_RDWR | O_NONBLOCK, 0)) < 0) {
+ FatalError("xf86OpenConsole: Cannot open %s: %s\n", vtdevice,
+ strerror(errno));
+ }
+
+ xf86Msg (from, "using VT number %d (%s)\n\n", VTnum, vtdevice);
+ xf86Info.vtno = VTnum;
+
+ /* change ownership of the vt */
+ chown(vtdevice, getuid(), getgid());
+
+ /*
+ * now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
+ FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n",
+ strerror(errno));
+ }
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) {
+ FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %s\n",strerror(errno));
+ }
+
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) {
+ FatalError("xf86OpenConsole: VT_GETMODE failed: %s\n", strerror(errno));
+ }
+
+ sigvtsw.sa_handler = xf86VTRequest;
+ sigfillset(&sigvtsw.sa_mask);
+ sigvtsw.sa_flags = 0;
+ sigaction(SIGUSR1, &sigvtsw, NULL);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+
+ ioctl_ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT);
+ if (ioctl_ret < 0) {
+ FatalError("xf86OpenConsole: VT_SETMODE failed: %s\n", strerror(errno));
+ }
+
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
+ FatalError("xf86OpenConsole: KD_GRAPHICS failed: %s\n", strerror(errno));
+ }
+ } else { /* serverGeneration != 1 */
+ /*
+ * now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
+ FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n", strerror(errno));
+ }
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) {
+ FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %s\n",strerror(errno));
+ }
+ /*
+ * If the server doesn't have the VT when the reset occurs,
+ * this is to make sure we don't continue until the activate
+ * signal is received.
+ */
+ if (!xf86Screens[0]->vtSema)
+ sleep(5);
+ }
+ return;
+}
+
+void
+xf86CloseConsole(void)
+{
+ struct vt_mode VT;
+ struct sigaction sigvtsw;
+
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */
+
+ sigvtsw.sa_handler = SIG_DFL;
+ sigfillset(&sigvtsw.sa_mask);
+ sigvtsw.sa_flags = 0;
+ sigaction(SIGUSR1, &sigvtsw, NULL);
+
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) {
+ VT.mode = VT_AUTO;
+ VT.waitv = 0;
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
+ }
+ close(xf86Info.consoleFd); /* make the vt-manager happy */
+ return;
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty")) {
+ KeepTty = TRUE;
+ return(1);
+ }
+
+ /*
+ * Undocumented flag to protect page 0 from read/write to help
+ * catch NULL pointer dereferences. This is purely a debugging
+ * flag.
+ */
+ if (!strcmp(argv[i], "-protect0")) {
+ Protect0 = TRUE;
+ return(1);
+ }
+
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't')) {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0) {
+ UseMsg();
+ VTnum = -1;
+ return(0);
+ }
+ VTnum -= is_osr6();
+ CRTSpecified = TRUE;
+ return(1);
+ }
+
+ /*
+ * Use a device the user specifies.
+ */
+ if (!strcmp(argv[i], "-crt")) {
+ if (++i > argc) {
+ UseMsg();
+ VTnum = -1;
+ return(0);
+ } else {
+ char *mytty = ttyname(0);
+ char *arg = argv[i];
+
+ if (!mytty)
+ mytty = "\1";
+ if (!arg[0])
+ arg = "\2"; /* Prevent idiots from using -crt "" */
+
+ if (strcmp (mytty, arg) != 0) {
+ char *fmt;
+
+ if (is_osr6())
+ fmt = "/dev/tty%02d";
+ else
+ fmt = "/dev/vt%02d";
+
+ if (sscanf(arg, fmt, &VTnum) == 0) {
+ UseMsg();
+ VTnum = -1;
+ return(0);
+ }
+
+ /* OSR6 devices start names at 1, UW7 starts at 0 */
+ VTnum -= is_osr6();
+ CRTSpecified = TRUE;
+ }
+ return(2);
+ }
+ }
+ return(0);
+}
+
+void
+xf86UseMsg(void)
+{
+ if (is_osr6()) {
+ ErrorF("-crt /dev/ttyXX use the specified VT device\n");
+ ErrorF("vtXX use the specified VT number (01-16)\n");
+ } else {
+ ErrorF("-crt /dev/vtXX use the specified VT device\n");
+ ErrorF("vtXX use the specified VT number (00-15)\n");
+ }
+
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_io.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_io.c
new file mode 100644
index 000000000..c93e8058e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_io.c
@@ -0,0 +1,172 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/usl/usl_io.c,v 1.2 2005/11/08 06:33:30 jkj Exp $ */
+/*
+ * Copyright 2001-2005 by Kean Johnston <jkj@sco.com>
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Dawes <dawes@xfree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell, David Dawes
+ * and Kean Johnston not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Thomas Roell, David Dawes and Kean Johnston make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL, DAVID DAWES AND KEAN JOHNSTON DISCLAIM ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THOMAS ROELLm DAVID WEXELBLAT
+ * OR KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ *
+ */
+/* $XConsortium$ */
+
+#include "X.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
+{
+ if (loudness && pitch) {
+ ioctl(xf86Info.consoleFd, KIOCSOUND, 1193180 / pitch);
+ usleep(xf86Info.bell_duration * loudness * 20);
+ ioctl(xf86Info.consoleFd, KIOCSOUND, 0);
+ }
+}
+
+void
+xf86SetKbdLeds(int leds)
+{
+ ioctl(xf86Info.consoleFd, KDSETLED, leds);
+}
+
+int
+xf86GetKbdLeds(void)
+{
+ int leds;
+
+ ioctl(xf86Info.consoleFd, KDGETLED, &leds);
+ return(leds);
+}
+
+/*
+ * Much of the code in this function is duplicated from the Linux code
+ * by Orest Zborowski <obz@Kodak.com> and David Dawes <dawes@xfree86.org>.
+ * Please see the file ../linux/lnx_io.c for full copyright information.
+ */
+void
+xf86SetKbdRepeat(char rad)
+{
+ int i;
+ int value = 0x7f; /* Maximum delay with slowest rate */
+ int delay = 250; /* Default delay */
+ int rate = 300; /* Default repeat rate */
+
+ static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
+ 133, 120, 109, 100, 92, 86, 80, 75, 67,
+ 60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
+ 25, 23, 21, 20 };
+#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
+
+ static int valid_delays[] = { 250, 500, 750, 1000 };
+#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
+
+ if (xf86Info.kbdRate >= 0)
+ rate = xf86Info.kbdRate * 10;
+ if (xf86Info.kbdDelay >= 0)
+ delay = xf86Info.kbdDelay;
+
+ for (i = 0; i < RATE_COUNT; i++)
+ if (rate >= valid_rates[i]) {
+ value &= 0x60;
+ value |= i;
+ break;
+ }
+
+ for (i = 0; i < DELAY_COUNT; i++)
+ if (delay <= valid_delays[i]) {
+ value &= 0x1f;
+ value |= i << 5;
+ break;
+ }
+
+ ioctl (xf86Info.consoleFd, KDSETTYPEMATICS, value);
+}
+
+static int orig_kbm;
+static struct termio orig_termio;
+static keymap_t keymap, noledmap;
+
+void
+xf86KbdInit(void)
+{
+ ioctl (xf86Info.consoleFd, KDGKBMODE, &orig_kbm);
+ ioctl (xf86Info.consoleFd, TCGETA, &orig_termio);
+ /*
+ * We need to get the original keyboard map and NUL out the lock
+ * modifiers. This prevents the scancode API from messing with
+ * the keyboard LED's. We restore the original map when we exit.
+ */
+ if (ioctl (xf86Info.consoleFd, GIO_KEYMAP, &keymap) < 0) {
+ FatalError ("xf86KbdInit: Failed to get keyboard map (%s)\n",
+ strerror(errno));
+ }
+ if (ioctl (xf86Info.consoleFd, GIO_KEYMAP, &noledmap) < 0) {
+ FatalError ("xf86KbdInit: Failed to get keyboard map (%s)\n",
+ strerror(errno));
+ } else {
+ int i, j;
+
+ for (i = 0; i < noledmap.n_keys; i++) {
+ for (j = 0; j < NUM_STATES; j++) {
+ if (IS_SPECKEY(&noledmap, i, j) &&
+ ((noledmap.key[i].map[j] == K_CLK) ||
+ (noledmap.key[i].map[j] == K_NLK) ||
+ (noledmap.key[i].map[j] == K_SLK))) {
+ noledmap.key[i].map[j] = K_NOP;
+ }
+ }
+ }
+ }
+}
+
+int
+xf86KbdOn(void)
+{
+ struct termio newtio;
+
+ newtio = orig_termio; /* structure copy */
+ newtio.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ newtio.c_oflag = 0;
+ newtio.c_cflag = CREAD | CS8 | B9600;
+ newtio.c_lflag = 0;
+ newtio.c_cc[VTIME]=0;
+ newtio.c_cc[VMIN]=1;
+ ioctl(xf86Info.consoleFd, TCSETA, &newtio);
+
+ ioctl (xf86Info.consoleFd, KDSKBMODE, K_RAW);
+ ioctl (xf86Info.consoleFd, PIO_KEYMAP, &noledmap);
+
+ return(xf86Info.consoleFd);
+}
+
+int
+xf86KbdOff(void)
+{
+ ioctl (xf86Info.consoleFd, KDSKBMODE, orig_kbm);
+ ioctl (xf86Info.consoleFd, PIO_KEYMAP, &keymap);
+ ioctl(xf86Info.consoleFd, TCSETA, &orig_termio);
+
+ return(xf86Info.consoleFd);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_iop.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_iop.c
new file mode 100644
index 000000000..362ac369e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_iop.c
@@ -0,0 +1,108 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/usl/usl_iop.c,v 1.2 2005/11/08 06:33:30 jkj Exp $ */
+/*
+ * Copyright 2001,2005 by Kean Johnston <jkj@sco.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name Kean Johnston not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Kean Johnston makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XConsortium$ */
+
+
+#include "X.h"
+
+#include "compiler.h"
+
+#define _NEED_SYSI86
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86OSpriv.h"
+#include "xf86_OSlib.h"
+
+
+/***************************************************************************/
+/* I/O Permissions section */
+/***************************************************************************/
+
+static Bool IOEnabled = FALSE;
+
+Bool
+xf86EnableIO(void)
+{
+ if (IOEnabled)
+ return TRUE;
+
+ if (sysi86(SI86IOPL, 3) < 0)
+ FatalError("Failed to set IOPL for extended I/O\n");
+ IOEnabled = TRUE;
+ return TRUE;
+}
+
+void
+xf86DisableIO(void)
+{
+ if (!IOEnabled)
+ return;
+
+ sysi86(SI86IOPL, 0);
+ IOEnabled = FALSE;
+}
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+Bool
+xf86DisableInterrupts(void)
+{
+ if (!IOEnabled) {
+ if (sysi86(SI86IOPL, 3) < 0)
+ return FALSE;
+ }
+
+#ifdef __GNUC__
+ __asm__ __volatile__("cli");
+#else
+ asm("cli");
+#endif /* __GNUC__ */
+
+ if (!IOEnabled) {
+ sysi86(SI86IOPL, 0);
+ }
+
+ return(TRUE);
+}
+
+void
+xf86EnableInterrupts(void)
+{
+ if (!IOEnabled) {
+ if (sysi86(SI86IOPL, 3) < 0)
+ return;
+ }
+
+#ifdef __GNUC__
+ __asm__ __volatile__("sti");
+#else
+ asm("sti");
+#endif /* __GNUC__ */
+
+ if (!IOEnabled) {
+ sysi86(SI86IOPL, 0);
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_kbd.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_kbd.c
new file mode 100644
index 000000000..c6e089db8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_kbd.c
@@ -0,0 +1,456 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/usl/usl_kbd.c,v 1.2 2005/11/08 06:33:30 jkj Exp $ */
+/*
+ * Copyright 2005 by Kean Johnston <jkj@sco.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name Kean Johnston not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Kean Johnston makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XConsortium$ */
+
+/*
+ * Based on sco_io.c which is
+ * (C) Copyright 2003 Kean Johnston <jkj@sco.com>
+ *
+ * Based on lnx_kbd.c which is
+ * Copyright (c) 2002 by The XFree86 Project, Inc.
+ *
+ * Based on the code from lnx_io.c which is
+ * Copyright 1992 by Orest Zborowski <obz@Kodak.com>
+ * Copyright 1993 by David Dawes <dawes@xfree86.org>
+ */
+
+#define NEED_EVENTS
+#include "X.h"
+
+#include "compiler.h"
+
+#define _NEED_SYSI86
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86OSpriv.h"
+#include "xf86_OSlib.h"
+
+#include "xf86Xinput.h"
+#include "xf86OSKbd.h"
+#include "atKeynames.h"
+#include "usl_kbd.h"
+#include "usl_xqueue.h"
+
+#include <sys/param.h>
+
+static KbdProtocolRec protocols[] = {
+ { "standard", PROT_STD },
+ { "Xqueue", PROT_XQUEUE },
+ { NULL, PROT_UNKNOWN_KBD }
+};
+
+extern Bool VTSwitchEnabled;
+#ifdef USE_VT_SYSREQ
+extern Bool VTSysreqToggle;
+#endif
+
+static void
+SoundBell(InputInfoPtr pInfo, int loudness, int pitch, int duration)
+{
+ if (loudness && pitch) {
+ ioctl(pInfo->fd, KIOCSOUND, 1193180 / pitch);
+ usleep(duration * loudness * 20);
+ ioctl(pInfo->fd, KIOCSOUND, 0);
+ }
+}
+
+static void
+SetKbdLeds(InputInfoPtr pInfo, int leds)
+{
+ int real_leds = 0;
+
+ if (leds & XLED1)
+ real_leds |= LED_CAP;
+ if (leds & XLED2)
+ real_leds |= LED_NUM;
+ if (leds & XLED3)
+ real_leds |= LED_SCR;
+ ioctl(pInfo->fd, KDSETLED, real_leds);
+}
+
+static int
+GetKbdLeds(InputInfoPtr pInfo)
+{
+ int real_leds, leds = 0;
+
+ ioctl(pInfo->fd, KDGETLED, &real_leds);
+
+ if (real_leds & LED_CAP) leds |= XLED1;
+ if (real_leds & LED_NUM) leds |= XLED2;
+ if (real_leds & LED_SCR) leds |= XLED3;
+
+ return(leds);
+}
+
+static void
+SetKbdRepeat(InputInfoPtr pInfo, char rad)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ int i;
+ int value = 0x7f; /* Maximum delay with slowest rate */
+ int delay = 250; /* Default delay */
+ int rate = 300; /* Default repeat rate */
+
+ static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
+ 133, 120, 109, 100, 92, 86, 80, 75, 67,
+ 60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
+ 25, 23, 21, 20 };
+#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
+
+ static int valid_delays[] = { 250, 500, 750, 1000 };
+#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
+
+ if (pKbd->rate >= 0)
+ rate = pKbd->rate * 10;
+ if (pKbd->delay >= 0)
+ delay = pKbd->delay;
+
+ for (i = 0; i < RATE_COUNT; i++)
+ if (rate >= valid_rates[i]) {
+ value &= 0x60;
+ value |= i;
+ break;
+ }
+
+ for (i = 0; i < DELAY_COUNT; i++)
+ if (delay <= valid_delays[i]) {
+ value &= 0x1f;
+ value |= i << 5;
+ break;
+ }
+
+ ioctl (pInfo->fd, KDSETTYPEMATICS, value);
+}
+
+static int
+KbdInit(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ USLKbdPrivPtr priv = (USLKbdPrivPtr) pKbd->private;
+
+ if (pKbd->isConsole) {
+ if (ioctl (pInfo->fd, KDGKBMODE, &priv->orig_kbm) < 0) {
+ xf86Msg (X_ERROR, "KbdInit: Could not determine keyboard mode\n");
+ return !Success;
+ }
+
+ /*
+ * We need to get the original keyboard map and NUL out the lock
+ * modifiers. This prevents the kernel from messing with
+ * the keyboard LED's. We restore the original map when we exit.
+ * Note that we also have to eliminate screen switch sequences
+ * else the VT manager will switch for us, which we don't want.
+ * For example, lets say you had changed the VT manager to switch
+ * on Alt-Fx instead of Ctrl-Alt-Fx. This means that while inside
+ * X, you cant use, for example, Alt-F4, which is a pain in the
+ * fundamental when you're using CDE-like thingies.
+ */
+ if (ioctl (pInfo->fd, GIO_KEYMAP, &priv->keymap) < 0) {
+ xf86Msg (X_ERROR, "KbdInit: Failed to get keyboard map (%s)\n",
+ strerror(errno));
+ return !Success;
+ }
+ if (ioctl (pInfo->fd, GIO_KEYMAP, &priv->noledmap) < 0) {
+ xf86Msg (X_ERROR, "KbdInit: Failed to get keyboard map (%s)\n",
+ strerror(errno));
+ return !Success;
+ } else {
+ int i, j;
+
+ for (i = 0; i < priv->noledmap.n_keys; i++) {
+ for (j = 0; j < NUM_STATES; j++) {
+ if (IS_SPECKEY(&priv->noledmap, i, j) &&
+ ((priv->noledmap.key[i].map[j] == K_CLK) ||
+ (priv->noledmap.key[i].map[j] == K_NLK) ||
+ (priv->noledmap.key[i].map[j] == K_SLK) ||
+ (priv->noledmap.key[i].map[j] == K_FRCNEXT) ||
+ (priv->noledmap.key[i].map[j] == K_FRCPREV) ||
+ ((priv->noledmap.key[i].map[j] >= K_VTF) &&
+ (priv->noledmap.key[i].map[j] <= K_VTL)) )) {
+ priv->noledmap.key[i].map[j] = K_NOP;
+ }
+ }
+ }
+ }
+
+ if (ioctl (pInfo->fd, TCGETA, &priv->kbdtty) < 0) {
+ xf86Msg (X_ERROR, "KbdInit: Failed to get terminal modes (%s)\n",
+ strerror(errno));
+ return !Success;
+ }
+ } /* End of if we are on a console */
+
+ return Success;
+}
+
+static int
+KbdOn(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ USLKbdPrivPtr priv = (USLKbdPrivPtr) pKbd->private;
+ struct termio newtio;
+
+ if (pKbd->isConsole) {
+ /*
+ * Use the calculated keyboard map that does not have active
+ * LED lock handling (we track LEDs ourselves).
+ */
+ ioctl (pInfo->fd, PIO_KEYMAP, &priv->noledmap);
+
+#ifdef NOTYET
+ newtio = priv->kbdtty; /* structure copy */
+ newtio.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ newtio.c_oflag = 0;
+ newtio.c_cflag = CREAD | CS8 | B9600;
+ newtio.c_lflag = 0;
+ newtio.c_cc[VTIME]=0;
+ newtio.c_cc[VMIN]=1;
+ ioctl(pInfo->fd, TCSETA, &newtio);
+
+ if (priv->xq == 0)
+ ioctl (pInfo->fd, KDSKBMODE, K_RAW);
+ else
+#endif
+ XqKbdOnOff (pInfo, 1);
+ }
+
+ return Success;
+}
+
+static int
+KbdOff(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ USLKbdPrivPtr priv = (USLKbdPrivPtr) pKbd->private;
+
+ if (pKbd->isConsole) {
+ /* Revert back to original translate scancode mode */
+#ifdef NOTYET
+ if (priv->xq == 0)
+ ioctl (pInfo->fd, KDSKBMODE, priv->orig_kbm);
+ else
+#endif
+ XqKbdOnOff (pInfo, 0);
+
+ ioctl (pInfo->fd, PIO_KEYMAP, &priv->keymap);
+ ioctl(pInfo->fd, TCSETA, &priv->kbdtty);
+ }
+
+ return Success;
+}
+
+#define ModifierSet(k) ((modifiers & (k)) == (k))
+
+static Bool
+SpecialKey(InputInfoPtr pInfo, int key, Bool down, int modifiers)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+
+ if(!pKbd->vtSwitchSupported)
+ return FALSE;
+
+ if ((!ModifierSet(ShiftMask)) && ((ModifierSet(ControlMask | AltMask)) ||
+ (ModifierSet(ControlMask | AltLangMask)))) {
+ if (VTSwitchEnabled && !xf86Info.vtSysreq) {
+ switch (key) {
+ case KEY_F1:
+ case KEY_F2:
+ case KEY_F3:
+ case KEY_F4:
+ case KEY_F5:
+ case KEY_F6:
+ case KEY_F7:
+ case KEY_F8:
+ case KEY_F9:
+ case KEY_F10:
+ if (down) {
+ int sts = key - KEY_F1;
+ if (sts != xf86Info.vtno) {
+ ioctl(pInfo->fd, VT_SWITCH, sts);
+ }
+ return TRUE;
+ }
+ case KEY_F11:
+ case KEY_F12:
+ if (down) {
+ int sts = key - KEY_F11 + 10;
+ if (sts != xf86Info.vtno) {
+ ioctl(pInfo->fd, VT_SWITCH, sts);
+ }
+ return TRUE;
+ }
+ }
+ }
+ }
+#ifdef USE_VT_SYSREQ
+ if (VTSwitchEnabled && xf86Info.vtSysreq) {
+ switch (key) {
+ case KEY_F1:
+ case KEY_F2:
+ case KEY_F3:
+ case KEY_F4:
+ case KEY_F5:
+ case KEY_F6:
+ case KEY_F7:
+ case KEY_F8:
+ case KEY_F9:
+ case KEY_F10:
+ if (VTSysreqToggle && down) {
+ ioctl(pInfo->fd, VT_ACTIVATE, key - KEY_F1);
+ VTSysreqToggle = FALSE;
+ return TRUE;
+ }
+ break;
+ case KEY_F11:
+ case KEY_F12:
+ if (VTSysreqToggle && down) {
+ ioctl(pInfo->fd, VT_ACTIVATE, key - KEY_F11 + 10);
+ VTSysreqToggle = FALSE;
+ return TRUE;
+ }
+ break;
+ /* Ignore these keys -- ie don't let them cancel an alt-sysreq */
+ case KEY_Alt:
+ case KEY_AltLang:
+ break;
+ case KEY_SysReqest:
+ if (!(ModifierSet(ShiftMask) || ModifierSet(ControlMask))) {
+ if ((ModifierSet(AltMask) || ModifierSet(AltLangMask)) && down)
+ VTSysreqToggle = TRUE;
+ }
+ break;
+ default:
+ /*
+ * We only land here when Alt-SysReq is followed by a
+ * non-switching key.
+ */
+ if (VTSysreqToggle)
+ VTSysreqToggle = FALSE;
+ }
+ }
+#endif /* USE_VT_SYSREQ */
+ return FALSE;
+}
+
+#ifdef NOTYET
+static void
+stdReadInput(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ unsigned char rBuf[64];
+ int nBytes, i;
+
+ if ((nBytes = read( pInfo->fd, (char *)rBuf, sizeof(rBuf))) > 0) {
+ for (i = 0; i < nBytes; i++) {
+ pKbd->PostEvent(pInfo, rBuf[i] & 0x7f, rBuf[i] & 0x80 ? FALSE : TRUE);
+ }
+ }
+}
+#endif
+
+static Bool
+OpenKeyboard(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ USLKbdPrivPtr priv = (USLKbdPrivPtr) pKbd->private;
+ int i;
+ KbdProtocolId prot = PROT_UNKNOWN_KBD;
+ char *s;
+
+ s = xf86SetStrOption(pInfo->options, "Protocol", NULL);
+ for (i = 0; protocols[i].name; i++) {
+ if (xf86NameCmp(s, protocols[i].name) == 0) {
+ prot = protocols[i].id;
+ break;
+ }
+ }
+
+ switch (prot) {
+ case PROT_STD:
+#ifdef NOTYET
+ pInfo->read_input = stdReadInput;
+ priv->xq = 0;
+ break;
+#endif
+ case PROT_XQUEUE:
+ pInfo->read_input = NULL; /* Handled by the XQUEUE signal handler */
+ priv->xq = 1;
+ break;
+ default:
+ xf86Msg(X_ERROR,"\"%s\" is not a valid keyboard protocol name\n", s);
+ xfree(s);
+ return FALSE;
+ }
+
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, s);
+ xfree(s);
+
+ s = xf86SetStrOption(pInfo->options, "Device", NULL);
+ if (s == NULL) {
+ pInfo->fd = xf86Info.consoleFd;
+ pKbd->isConsole = TRUE;
+ } else {
+ pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL);
+ if (pInfo->fd == -1) {
+ xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s);
+ xfree(s);
+ return FALSE;
+ }
+ pKbd->isConsole = FALSE;
+ xfree(s);
+ }
+
+ if (pKbd->isConsole)
+ pKbd->vtSwitchSupported = TRUE;
+
+ return TRUE;
+}
+
+Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = pInfo->private;
+
+ pKbd->KbdInit = KbdInit;
+ pKbd->KbdOn = KbdOn;
+ pKbd->KbdOff = KbdOff;
+ pKbd->Bell = SoundBell;
+ pKbd->SetLeds = SetKbdLeds;
+ pKbd->GetLeds = GetKbdLeds;
+ pKbd->SetKbdRepeat = SetKbdRepeat;
+ pKbd->KbdGetMapping = KbdGetMapping;
+ pKbd->SpecialKey = SpecialKey;
+ pKbd->OpenKeyboard = OpenKeyboard;
+
+ pKbd->GetSpecialKey = NULL;
+ pKbd->RemapScanCode = ATScancode;
+ pKbd->vtSwitchSupported = FALSE;
+
+ pKbd->private = xcalloc(sizeof(USLKbdPrivRec), 1);
+ if (pKbd->private == NULL) {
+ xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_kbd.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_kbd.h
new file mode 100644
index 000000000..a65986fe5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_kbd.h
@@ -0,0 +1,14 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/usl/usl_kbd.h,v 1.2 2005/11/08 06:33:30 jkj Exp $ */
+#ifndef SCO_KBD_HDR
+#define SCO_KBD_HDR
+
+typedef struct {
+ int orig_kbm;
+ struct termio kbdtty;
+ keymap_t keymap, noledmap;
+ int xq;
+} USLKbdPrivRec, *USLKbdPrivPtr;
+
+extern void KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms,
+ CARD8 *pModMap);
+#endif /* SCO_KBD_HDR */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_mouse.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_mouse.c
new file mode 100644
index 000000000..708a08e11
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_mouse.c
@@ -0,0 +1,181 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/usl/usl_mouse.c,v 1.3 2005/11/10 02:41:20 jkj Exp $ */
+
+/*
+ * Copyright 2005 Kean Johnston
+ * Copyright 1999 by The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of The XFree86 Project, Inc
+ * and Kean Johnston not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * The XFree86 Project, Inc and Kean Johnston make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THE XFREE86 PROJECT, INC AND KEAN JOHNSTON DISCLAIM ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THOMAS ROELLm DAVID WEXELBLAT
+ * OR KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ *
+ */
+
+#include "X.h"
+#include "compiler.h"
+#include "xf86.h"
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "mipointer.h"
+#include "usl_xqueue.h"
+
+static int
+SupportedInterfaces(void)
+{
+ return MSE_MISC;
+}
+
+static const char *internalNames[] = {
+ "Xqueue",
+ NULL
+};
+
+static const char **
+BuiltinNames(void)
+{
+ return internalNames;
+}
+
+static const char *
+DefaultProtocol (void)
+{
+ return "Xqueue";
+}
+
+static Bool
+CheckProtocol(const char *protocol)
+{
+ int i;
+
+ for (i = 0; internalNames[i]; i++)
+ if (xf86NameCmp(protocol, internalNames[i]) == 0)
+ return TRUE;
+ return FALSE;
+}
+
+static int
+OsMouseProc(DeviceIntPtr pPointer, int what)
+{
+ InputInfoPtr pInfo;
+ MouseDevPtr pMse;
+ unsigned char map[9];
+ int ret;
+
+ pInfo = pPointer->public.devicePrivate;
+ pMse = pInfo->private;
+ pMse->device = pPointer;
+
+ switch (what) {
+ case DEVICE_INIT:
+ pPointer->public.on = FALSE;
+
+ for (ret = 0; ret <= 8; ret++)
+ map[ret] = ret;
+
+ InitPointerDeviceStruct((DevicePtr)pPointer, map, 8,
+ miPointerGetMotionEvents, pMse->Ctrl,
+ miPointerGetMotionBufferSize());
+ /* X valuator */
+ xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 0);
+
+ /* Y valuator */
+ xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 1);
+
+ xf86MotionHistoryAllocate(pInfo);
+ break;
+
+ case DEVICE_ON:
+ pMse->lastButtons = 0;
+ pMse->emulateState = 0;
+ pPointer->public.on = TRUE;
+ XqMseOnOff (pInfo, 1);
+ break;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ pPointer->public.on = FALSE;
+ XqMseOnOff (pInfo, 0);
+ break;
+ }
+ return Success;
+}
+
+static Bool
+OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ /* This is called when the protocol is "Xqueue" */
+ MouseDevPtr pMse;
+
+ pMse = pInfo->private;
+ pMse->protocol = protocol;
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
+
+ /* Collect the options, and process the common options. */
+ xf86CollectInputOptions(pInfo, NULL, NULL);
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
+
+ pInfo->fd = -1;
+#if 0
+ /* Make sure we can open the mouse */
+ pInfo->fd = open ("/dev/mouse", O_RDONLY | O_NONBLOCK);
+
+ if (pInfo->fd < 0) {
+ if (xf86GetAllowMouseOpenFail()) {
+ xf86Msg(X_WARNING, "%s: cannot open /dev/mouse (%s)\n",
+ pInfo->name, strerror(errno));
+ } else {
+ xf86Msg(X_ERROR, "%s: cannot open /dev/mouse (%s)\n",
+ pInfo->name, strerror(errno));
+ xfree(pMse);
+ return FALSE;
+ }
+ }
+#endif
+
+ /* Process common mouse options (like Emulate3Buttons, etc). */
+ pMse->CommonOptions(pInfo);
+
+ /* Setup the local procs. */
+ pInfo->device_control = OsMouseProc;
+ pInfo->read_input = NULL; /* Handled by the XQUEUE signal handler */
+
+ pInfo->flags |= XI86_CONFIGURED;
+ return TRUE;
+}
+
+OSMouseInfoPtr
+xf86OSMouseInit(int flags)
+{
+ OSMouseInfoPtr p;
+
+ p = xcalloc(sizeof(OSMouseInfoRec), 1);
+ if (!p)
+ return NULL;
+
+ p->SupportedInterfaces = SupportedInterfaces;
+ p->BuiltinNames = BuiltinNames;
+ p->DefaultProtocol = DefaultProtocol;
+ p->CheckProtocol = CheckProtocol;
+ p->PreInit = OsMousePreInit;
+ return p;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_video.c
new file mode 100644
index 000000000..2c85ea92c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_video.c
@@ -0,0 +1,111 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/usl/usl_video.c,v 1.2 2005/11/08 06:33:30 jkj Exp $ */
+/*
+ * Copyrught 2005 Kean Johnston <jkj@sco.com>
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell, David Dawes
+ * and Kean Johnston not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Thomas Roell, David Dawes and Kean Johnston make no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL, DAVID DAWES AND KEAN JOHNSTON DISCLAIM ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THOMAS ROELLm DAVID WEXELBLAT
+ * OR KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ *
+ */
+/* $XConsortium$ */
+
+#include "X.h"
+
+#define _NEED_SYSI86
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+static Bool
+linearVidMem(void)
+{
+ return TRUE;
+}
+
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ pointer base;
+ int fd;
+
+ fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
+ if (fd < 0) {
+ FatalError("xf86MapVidMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ base = mmap((caddr_t)0, Size, (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_SHARED, fd, (off_t)Base);
+ close(fd);
+
+ if (base == MAP_FAILED) {
+ FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
+ "xf86MapVidMem", Size, Base, strerror(errno));
+ }
+ return(base);
+}
+
+/* ARGSUSED */
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap(Base, Size);
+}
+
+/*
+ * For some SVR4 versions, a 32-bit read is done for the first location
+ * in each page when the page is first mapped. If this is done while
+ * memory access is enabled for regions that have read side-effects,
+ * this can cause unexpected results, including lockups on some hardware.
+ * This function is called to make sure each page is mapped while it is
+ * safe to do so.
+ */
+
+#define X_PAGE_SIZE 4096
+
+static void
+readSideEffects(int ScreenNum, pointer Base, unsigned long Size)
+{
+ unsigned long base, end, addr;
+ CARD32 val;
+
+ base = (unsigned long)Base;
+ end = base + Size;
+
+ for (addr = base; addr < end; addr += X_PAGE_SIZE)
+ val = *(volatile CARD32 *)addr;
+}
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->linearSupported = linearVidMem();
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+ pVidMem->readSideEffects = readSideEffects;
+ pVidMem->initialised = TRUE;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_vtsw.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_vtsw.c
new file mode 100644
index 000000000..d15a24149
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_vtsw.c
@@ -0,0 +1,97 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/usl/usl_vtsw.c,v 1.2 2005/11/08 06:33:30 jkj Exp $ */
+/*
+ * Copyright 2005 by Kean Johnston <jkj@sco.com>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ * Copyright 1993 by David McCullough <davidm@stallion.oz.au>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium$ */
+
+#include "X.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+/*
+ * Handle the VT-switching interface for SCO UnixWare / OpenServer 6
+ */
+
+/*
+ * This function is the signal handler for the VT-switching signal. It
+ * is only referenced inside the OS-support layer. NOTE: we do NOT need
+ * to re-arm the signal here, since we used sigaction() to set the signal
+ * disposition in usl_init.c. If we had used signal(), we would need to
+ * re-arm the signal here. All we need to do now is record the fact that
+ * we got the signal. XFree86 handles the rest.
+ */
+void
+xf86VTRequest(int sig)
+{
+ xf86Info.vtRequestsPending = TRUE;
+ return;
+}
+
+Bool
+xf86VTSwitchPending(void)
+{
+ return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+}
+
+static int usl_ledstatus = -1;
+static unsigned int usl_ledstate = 0;
+
+Bool
+xf86VTSwitchAway(void)
+{
+ usl_ledstatus = ioctl(xf86Info.consoleFd, KDGETLED, &usl_ledstate);
+
+ xf86Info.vtRequestsPending = FALSE;
+ if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0) {
+ return(FALSE);
+ } else {
+ return(TRUE);
+ }
+}
+
+Bool
+xf86VTSwitchTo(void)
+{
+ xf86Info.vtRequestsPending = FALSE;
+ if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) {
+ return(FALSE);
+ } else {
+ if (usl_ledstatus >= 0) {
+ ioctl (xf86Info.consoleFd, KDSETLED, usl_ledstate);
+ }
+ usl_ledstatus = -1;
+
+ /*
+ * Convince the console driver this screen is in graphics mode,
+ * otherwise it assumes it can do more to the screen than it should.
+ */
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
+ ErrorF("Failed to set graphics mode (%s)\n", strerror(errno));
+ }
+
+ return TRUE;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_xqueue.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_xqueue.c
new file mode 100644
index 000000000..8b66ee1f8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_xqueue.c
@@ -0,0 +1,360 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/usl/usl_xqueue.c,v 1.3 2005/11/10 02:41:20 jkj Exp $ */
+/*
+ * Copyright 2005 by Kean Johnston <jkj@sco.com>
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993-1999 by The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium$ */
+
+#include "X.h"
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+#include "xf86OSKbd.h"
+#include "usl_xqueue.h"
+
+#ifdef XKB
+#include "inputstr.h"
+#include <X11/extensions/XKB.h>
+#include <X11/extensions/XKBstr.h>
+#include <X11/extensions/XKBsrv.h>
+extern Bool noXkbExtension;
+#endif
+
+#include "xf86Xinput.h"
+#include "mipointer.h"
+
+#if !defined(XQ_WHEEL)
+# define XQ_WHEEL 4
+#endif
+
+/*
+ * Implementation notes
+ *
+ * This code is based on a mixture of the original XFree86 sysv/xqueue.c
+ * and information gathered from the SCO X server code (no actual code
+ * was used, just the principles).
+ *
+ * The XFree86 XQUEUE code went to some considerable lengths to implement
+ * what it calls "asynchronous XQUEUE". This involved creating a pipe,
+ * and writing to that pipe each time an XQUEUE signal is received. The
+ * one end of that pipe was then added to the list of selectable file
+ * descriptors with AddEnabledDevice(). I completely fail to see the need
+ * for this, and this code does not implement that mechanism. The server
+ * will be interrupted anyway by the XQUEUE driver, so whether we pull the
+ * events off the queue at the time we receive the signal or whether we
+ * write to a pipe and then have the main select() loop stop and call us,
+ * it makes no difference I can fathom.
+ *
+ * The code also differs from the original XFree86 code in that it maintains
+ * local variables for the number of devices initialized. The original code
+ * stored that information in the private data pointer of the mouse structure,
+ * but this same code is used for both the keyboard and the mouse, so that
+ * was changed.
+ *
+ * Part of the difficulty in dealing with XQUEUE is that it is a single
+ * interface to two devices. The recent changes in XFree86/Xorg try to
+ * treat the mouse and keyboard as discrete devices, and the code is
+ * structured in such a way that they should be able to be independently
+ * opened and closed. But we can't do that with XQUEUE, so we have to
+ * centralize XQUEUE access here in this module.
+ */
+
+static xqEventQueue *xqQaddr = NULL;
+static int xqSigEnable = 1;
+static int xqEnableCount = 0;
+static struct kd_quemode xqMode;
+
+/*
+ * These two pointers are set when the keyboard/mouse handler procs
+ * are called to turn them on or off. This is so that we can call the
+ * correct PostEvent for the device.
+ */
+static InputInfoPtr xqMouse = NULL;
+static InputInfoPtr xqKeyboard = NULL;
+
+static void XqSignalHandler (int signo);
+
+/*
+ * Private functions
+ */
+static void
+XqReset (void)
+{
+ if (xqEnableCount > 0) {
+ xqQaddr->xq_head = xqQaddr->xq_tail;
+ xqQaddr->xq_sigenable = xqSigEnable;
+ }
+}
+
+#ifdef NOTNEEDED
+static void
+XqLock (void)
+{
+ xqSigEnable = 0;
+ if (xqEnableCount > 0) {
+ xqQaddr->xq_sigenable = xqSigEnable;
+ }
+}
+
+static void
+XqUnlock (void)
+{
+ xqSigEnable = 1;
+ if (xqEnableCount > 0) {
+ xqQaddr->xq_sigenable = xqSigEnable;
+ }
+}
+#endif /* NOTNEEDED */
+
+/*
+ * Since this code is shared between two devices, we need to keep track
+ * of how many times we've been enabled or disabled. For example, if the
+ * keyboard has been turned off, but the mouse hasn't, then we do not
+ * want the whole queue off. Only when both devices are turned off do we
+ * actually disable Xqueue mode. When either device is turned on, we
+ * enable it.
+ */
+static int
+XqEnable (InputInfoPtr pInfo)
+{
+ struct sigaction xqsig;
+ static int msefd = -1;
+
+ if (msefd == -1) {
+ msefd = open ("/dev/mouse", O_RDONLY | O_NONBLOCK);
+#if 0
+ msefd = open ("/dev/mouse", O_RDONLY | O_NONBLOCK | O_NOCTTY);
+ if (msefd < 0) {
+ /*
+ * Try giving it a controlling tty
+ */
+ msefd = open (ttyname(xf86Info.consoleFd), O_RDWR | O_NONBLOCK);
+ if (msefd >= 0)
+ close (msefd);
+ msefd = open ("/dev/mouse", O_RDONLY | O_NONBLOCK | O_NOCTTY);
+ if (msefd < 0)
+ sleep(2);
+ }
+#endif
+ }
+
+ if (msefd < 0) {
+ if (xf86GetAllowMouseOpenFail()) {
+ ErrorF("%s: cannot open /dev/mouse (%s)\n",
+ ttyname(xf86Info.consoleFd), strerror(errno));
+ } else {
+ sleep(5);
+ FatalError ("%s: cannot open /dev/mouse (%s)\n",
+ ttyname(xf86Info.consoleFd), strerror(errno));
+ }
+ }
+
+ if (xqEnableCount++ == 0) {
+ xqMode.qaddr = 0;
+ ioctl (xf86Info.consoleFd, KDQUEMODE, NULL);
+
+ /*
+ * Note: We need to make sure the signal is armed before we enable
+ * XQUEUE mode, so that if we get events immediately after the ioctl
+ * we dont have an unhandled signal coming to the Xserver.
+ * Also note that we use sigaction, so that we do not have to re-arm
+ * the signal every time it is delivered, which just slows things
+ * down (setting a signal is a fairly expensive operation).
+ */
+
+ xqsig.sa_handler = XqSignalHandler;
+ sigfillset (&xqsig.sa_mask);
+ xqsig.sa_flags = 0;
+ sigaction (SIGUSR2, &xqsig, NULL);
+
+ /*
+ * This is a fairly large queue size. Since we are reacting to events
+ * asynchronously, its best for performance if we deal with as many
+ * events as possible, and high resolution mice generate a lot of
+ * events.
+ */
+ xqMode.qsize = 64;
+ xqMode.signo = SIGUSR2;
+ xqMode.qaddr = 0;
+ if (ioctl (xf86Info.consoleFd, KDQUEMODE, &xqMode) < 0) {
+ xf86Msg (X_ERROR, "%s: could not set XQUEUE mode (%s)", pInfo->name,
+ strerror(errno));
+ xqEnableCount--;
+
+ xqsig.sa_handler = SIG_DFL;
+ sigfillset (&xqsig.sa_mask);
+ xqsig.sa_flags = 0;
+ sigaction (SIGUSR2, &xqsig, NULL);
+
+ return !Success;
+ }
+
+ /*
+ * We're in business. The workstation is now in XQUEUE mode.
+ */
+ xqQaddr = (xqEventQueue *)xqMode.qaddr;
+ xqQaddr->xq_sigenable = 0; /* LOCK */
+ nap(500);
+ XqReset();
+ }
+ return Success;
+}
+
+static int
+XqDisable (InputInfoPtr pInfo)
+{
+ struct sigaction xqsig;
+
+ if (xqEnableCount-- == 1) {
+ xqQaddr->xq_sigenable = 0; /* LOCK */
+
+ if (ioctl (xf86Info.consoleFd, KDQUEMODE, NULL) < 0) {
+ xf86Msg (X_ERROR, "%s: could not unset XQUEUE mode (%s)", pInfo->name,
+ strerror(errno));
+ xqEnableCount++;
+ return !Success;
+ }
+
+ xqsig.sa_handler = SIG_DFL;
+ sigfillset (&xqsig.sa_mask);
+ xqsig.sa_flags = 0;
+ sigaction (SIGUSR2, &xqsig, NULL);
+ }
+
+ return Success;
+}
+
+/*
+ * XQUEUE signal handler. This is what goes through the list of events
+ * we've already received and dispatches them to either the keyboard or
+ * mouse event poster.
+ */
+static void
+XqSignalHandler (int signo)
+{
+ xqEvent *xqEvents = xqQaddr->xq_events;
+ int xqHead = xqQaddr->xq_head;
+ xEvent xE;
+ MouseDevPtr pMse = NULL;
+ KbdDevPtr pKbd = NULL;
+ signed char dx, dy;
+
+ if (xqMouse)
+ pMse = (MouseDevPtr)xqMouse->private;
+ if (xqKeyboard)
+ pKbd = (KbdDevPtr)xqKeyboard->private;
+
+ while (xqHead != xqQaddr->xq_tail) {
+
+ switch (xqEvents[xqHead].xq_type) {
+ case XQ_MOTION:
+ dx = (signed char)xqEvents[xqHead].xq_x;
+ dy = (signed char)xqEvents[xqHead].xq_y;
+ if (pMse)
+ pMse->PostEvent(xqMouse, ~(xqEvents[xqHead].xq_code) & 0x07,
+ (int)dx, (int)dy, 0, 0);
+ break;
+
+ case XQ_BUTTON:
+ if (pMse)
+ pMse->PostEvent(xqMouse, ~(xqEvents[xqHead].xq_code) & 0x07,
+ 0, 0, 0, 0);
+ break;
+
+ case XQ_WHEEL:
+ if (pMse) {
+ int wbut = pMse->lastButtons, dz;
+ if (xqEvents[xqHead].xq_code == 1)
+ dz = 1;
+ else
+ dz = -1;
+ pMse->PostEvent(xqMouse, wbut, 0, 0, dz, 0);
+ }
+ break;
+
+ case XQ_KEY:
+ if (pKbd)
+ pKbd->PostEvent(xqKeyboard, xqEvents[xqHead].xq_code & 0x7f,
+ xqEvents[xqHead].xq_code & 0x80 ? FALSE : TRUE);
+ break;
+
+ default:
+ xf86Msg(X_WARNING, "XQUEUE: unknown event type %d\n",
+ xqEvents[xqHead].xq_type);
+ break;
+ }
+
+ xqHead++;
+ if (xqHead == xqQaddr->xq_size)
+ xqHead = 0;
+ xf86Info.inputPending = TRUE;
+ }
+
+ XqReset();
+}
+
+/*
+ * Public functions
+ */
+int
+XqMseOnOff (InputInfoPtr pInfo, int on)
+{
+ if (on) {
+ if (xqMouse) {
+ if (xqMouse != pInfo)
+ xf86Msg(X_WARNING, "XqMseOnOff: mouse pointer structure changed!\n");
+ xqMouse = pInfo;
+ } else {
+ xqMouse = pInfo;
+ return XqEnable(pInfo);
+ }
+ } else {
+ xqMouse = NULL;
+ return XqDisable(pInfo);
+ }
+ return Success;
+}
+
+int
+XqKbdOnOff (InputInfoPtr pInfo, int on)
+{
+ if (on) {
+ if (xqKeyboard) {
+ if (xqKeyboard != pInfo)
+ xf86Msg(X_WARNING, "XqKbdOnOff: keyboard pointer structure changed!\n");
+ xqKeyboard = pInfo;
+ } else {
+ xqKeyboard = pInfo;
+ return XqEnable(pInfo);
+ }
+ } else {
+ xqKeyboard = NULL;
+ return XqDisable(pInfo);
+ }
+ return Success;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_xqueue.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_xqueue.h
new file mode 100644
index 000000000..2a777accf
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_xqueue.h
@@ -0,0 +1,9 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/usl/usl_xqueue.h,v 1.2 2005/11/08 06:33:30 jkj Exp $ */
+
+#ifndef _XF86_USL_XQUEUE_H_
+#define _XF86_USL_XQUEUE_H_
+
+extern int XqMseOnOff (InputInfoPtr pInfo, int on);
+extern int XqKbdOnOff (InputInfoPtr pInfo, int on);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86OSKbd.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86OSKbd.h
new file mode 100644
index 000000000..344f7e901
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86OSKbd.h
@@ -0,0 +1,133 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86OSKbd.h,v 1.5tsi Exp $ */
+/*
+ * Copyright (c) 2002-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ *
+ * Author: Ivan Pascal.
+ */
+
+#include "xf86Xinput.h"
+
+Bool ATScancode(InputInfoPtr pInfo, int *scanCode);
+
+/* Public interface to OS-specific keyboard support. */
+
+typedef int (*KbdInitProc)(InputInfoPtr pInfo, int what);
+typedef int (*KbdOnProc)(InputInfoPtr pInfo, int what);
+typedef int (*KbdOffProc)(InputInfoPtr pInfo, int what);
+typedef void (*BellProc)(InputInfoPtr pInfo,
+ int loudness, int pitch, int duration);
+typedef void (*SetLedsProc)(InputInfoPtr pInfo, int leds);
+typedef int (*GetLedsProc)(InputInfoPtr pInfo);
+typedef void (*SetKbdRepeatProc)(InputInfoPtr pInfo, char rad);
+typedef void (*KbdGetMappingProc)(InputInfoPtr pInfo,
+ KeySymsPtr pKeySyms, CARD8* pModMap);
+typedef int (*GetSpecialKeyProc)(InputInfoPtr pInfo, int scanCode);
+typedef Bool (*SpecialKeyProc)(InputInfoPtr pInfo,
+ int key, Bool down, int modifiers);
+typedef int (*RemapScanCodeProc)(InputInfoPtr pInfo, int *scanCode);
+typedef Bool (*OpenKeyboardProc)(InputInfoPtr pInfo);
+typedef void (*PostEventProc)(InputInfoPtr pInfo,
+ unsigned int key, Bool down);
+typedef struct {
+ int begin;
+ int end;
+ unsigned char *map;
+} TransMapRec, *TransMapPtr;
+
+typedef struct {
+ KbdInitProc KbdInit;
+ KbdOnProc KbdOn;
+ KbdOffProc KbdOff;
+ BellProc Bell;
+ SetLedsProc SetLeds;
+ GetLedsProc GetLeds;
+ SetKbdRepeatProc SetKbdRepeat;
+ KbdGetMappingProc KbdGetMapping;
+ RemapScanCodeProc RemapScanCode;
+ GetSpecialKeyProc GetSpecialKey;
+ SpecialKeyProc SpecialKey;
+
+ OpenKeyboardProc OpenKeyboard;
+ PostEventProc PostEvent;
+
+ int rate;
+ int delay;
+ int bell_pitch;
+ int bell_duration;
+ Bool autoRepeat;
+ unsigned long leds;
+ unsigned long xledsMask;
+ unsigned long keyLeds;
+ int scanPrefix;
+ Bool vtSwitchSupported;
+ Bool CustomKeycodes;
+ Bool noXkb;
+ Bool isConsole;
+ TransMapPtr scancodeMap;
+ TransMapPtr specialMap;
+
+ /* os specific */
+ pointer private;
+ int kbdType;
+ int consType;
+ int wsKbdType;
+ Bool sunKbd;
+ Bool Panix106;
+
+} KbdDevRec, *KbdDevPtr;
+
+typedef enum {
+ PROT_STD,
+ PROT_XQUEUE,
+ PROT_WSCONS,
+ PROT_USB,
+ PROT_UNKNOWN_KBD
+} KbdProtocolId;
+
+typedef struct {
+ const char *name;
+ KbdProtocolId id;
+} KbdProtocolRec;
+
+Bool xf86OSKbdPreInit(InputInfoPtr pInfo);
+
+/* Adjust this when the kbd interface changes. */
+
+/*
+ * History:
+ *
+ * 1.0.0 - Initial version.
+ */
+
+#define OS_KBD_VERSION_MAJOR 1
+#define OS_KBD_VERSION_MINOR 0
+#define OS_KBD_VERSION_PATCH 0
+
+#define OS_KBD_VERSION_CURRENT \
+ BUILTIN_INTERFACE_VERSION_NUMERIC(OS_KBD_VERSION_MAJOR, \
+ OS_KBD_VERSION_MINOR, \
+ OS_KBD_VERSION_PATCH)
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h
new file mode 100644
index 000000000..9db1bac19
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h
@@ -0,0 +1,295 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h,v 1.24 2003/11/03 05:11:51 tsi Exp $ */
+/*
+ * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* Public interface to OS-specific mouse support. */
+
+#ifndef _XF86OSMOUSE_H_
+#define _XF86OSMOUSE_H_
+
+#include "xf86Xinput.h"
+
+/* Mouse interface classes */
+#define MSE_NONE 0x00
+#define MSE_SERIAL 0x01 /* serial port */
+#define MSE_BUS 0x02 /* old bus mouse */
+#define MSE_PS2 0x04 /* standard read-only PS/2 */
+#define MSE_XPS2 0x08 /* extended PS/2 */
+#define MSE_AUTO 0x10 /* auto-detect (PnP) */
+#define MSE_MISC 0x20 /* The OS layer will identify the
+ * specific protocol names that are
+ * supported for this class. */
+
+/* Mouse Protocol IDs. */
+typedef enum {
+ PROT_UNKNOWN = -2,
+ PROT_UNSUP = -1, /* protocol is not supported */
+ PROT_MS = 0,
+ PROT_MSC,
+ PROT_MM,
+ PROT_LOGI,
+ PROT_LOGIMAN,
+ PROT_MMHIT,
+ PROT_GLIDE,
+ PROT_IMSERIAL,
+ PROT_THINKING,
+ PROT_ACECAD,
+ PROT_VALUMOUSESCROLL,
+ PROT_PS2,
+ PROT_GENPS2,
+ PROT_IMPS2,
+ PROT_EXPPS2,
+ PROT_THINKPS2,
+ PROT_MMPS2,
+ PROT_GLIDEPS2,
+ PROT_NETPS2,
+ PROT_NETSCPS2,
+ PROT_BM,
+ PROT_AUTO,
+ PROT_SYSMOUSE,
+ PROT_NUMPROTOS /* This must always be last. */
+} MouseProtocolID;
+
+struct _MouseDevRec;
+
+typedef int (*GetInterfaceTypesProc)(void);
+typedef const char **(*BuiltinNamesProc)(void);
+typedef Bool (*CheckProtocolProc)(const char *protocol);
+typedef Bool (*BuiltinPreInitProc)(InputInfoPtr pInfo, const char *protocol,
+ int flags);
+typedef const char *(*DefaultProtocolProc)(void);
+typedef const char *(*SetupAutoProc)(InputInfoPtr pInfo, int *protoPara);
+typedef void (*SetResProc)(InputInfoPtr pInfo, const char* protocol, int rate,
+ int res);
+typedef const char *(*FindDeviceProc)(InputInfoPtr pInfo, const char *protocol,
+ int flags);
+typedef const char *(*GuessProtocolProc)(InputInfoPtr pInfo, int flags);
+
+/*
+ * OSMouseInfoRec is used to pass information from the OSMouse layer to the
+ * OS-independent mouse driver.
+ */
+typedef struct {
+ GetInterfaceTypesProc SupportedInterfaces;
+ BuiltinNamesProc BuiltinNames;
+ CheckProtocolProc CheckProtocol;
+ BuiltinPreInitProc PreInit;
+ DefaultProtocolProc DefaultProtocol;
+ SetupAutoProc SetupAuto;
+ SetResProc SetPS2Res;
+ SetResProc SetBMRes;
+ SetResProc SetMiscRes;
+ FindDeviceProc FindDevice;
+ GuessProtocolProc GuessProtocol;
+} OSMouseInfoRec, *OSMouseInfoPtr;
+
+/*
+ * SupportedInterfaces: Returns the mouse interface types that the OS support.
+ * If MSE_MISC is returned, then the BuiltinNames and
+ * CheckProtocol should be set.
+ *
+ * BuiltinNames: Returns the names of the protocols that are fully handled
+ * in the OS-specific code. These are names that don't appear
+ * directly in the main "mouse" driver.
+ *
+ * CheckProtocol: Checks if the protocol name given is supported by the
+ * OS. It should return TRUE for both "builtin" protocols and
+ * protocols of type MSE_MISC that are supported by the OS.
+ *
+ * PreInit: The PreInit function for protocols that are builtin. This
+ * function is passed the protocol name.
+ *
+ * DefaultProtocol: Returns the name of a default protocol that should be used
+ * for the OS when none has been supplied in the config file.
+ * This should only be set when there is a reasonable default.
+ *
+ * SetupAuto: This function can be used to do OS-specific protocol
+ * auto-detection. It returns the name of the detected protocol,
+ * or NULL when detection fails. It may also adjust one or more
+ * of the "protoPara" values for the detected protocol by setting
+ * then to something other than -1. SetupAuto gets called in two
+ * ways. The first is before any devices have been opened. This
+ * can be used when the protocol "Auto" always maps to a single
+ * protocol type. The second is with the device open, allowing
+ * OS-specific probing to be done.
+ *
+ * SetPS2Res: Set the resolution and sample rate for MSE_PS2 and MSE_XPS2
+ * protocol types.
+ *
+ * SetBMRes: Set the resolution and sample rate for MSE_BM protocol types.
+ *
+ * SetMiscRes: Set the resolution and sample rate for MSE_MISC protocol types.
+ *
+ * FindDevice: This function gets called when no Device has been specified
+ * in the config file. OS-specific methods may be used to guess
+ * which input device to use. This function is called after the
+ * pre-open attempts at protocol discovery are done, but before
+ * the device is open. I.e., after the first SetupAuto() call,
+ * after the DefaultProtocol() call, but before the PreInit()
+ * call. Available protocol information may be used in locating
+ * the default input device.
+ *
+ * GuessProtocol: A last resort attempt at guessing the mouse protocol by
+ * whatever OS-specific means might be available. OS-independent
+ * things should be in the mouse driver. This function gets
+ * called after the mouse driver's OS-independent methods have
+ * failed.
+ */
+
+extern OSMouseInfoPtr xf86OSMouseInit(int flags);
+
+/* Adjust this when the mouse interface changes. */
+
+/*
+ * History:
+ *
+ * 1.0.0 - Everything up to when versioning was started.
+ * 1.1.0 - FindDevice and GuessProtocol added to OSMouseInfoRec
+ * 1.2.0 - xisbscale added to MouseDevRec
+ *
+ */
+
+#define OS_MOUSE_VERSION_MAJOR 1
+#define OS_MOUSE_VERSION_MINOR 2
+#define OS_MOUSE_VERSION_PATCH 0
+
+#define OS_MOUSE_VERSION_CURRENT \
+ BUILTIN_INTERFACE_VERSION_NUMERIC(OS_MOUSE_VERSION_MAJOR, \
+ OS_MOUSE_VERSION_MINOR, \
+ OS_MOUSE_VERSION_PATCH)
+
+#define HAVE_GUESS_PROTOCOL \
+ (xf86GetBuiltinInterfaceVersion(BUILTIN_IF_OSMOUSE, 0) >= \
+ BUILTIN_INTERFACE_VERSION_NUMERIC(1, 1, 0))
+
+#define HAVE_FIND_DEVICE \
+ (xf86GetBuiltinInterfaceVersion(BUILTIN_IF_OSMOUSE, 0) >= \
+ BUILTIN_INTERFACE_VERSION_NUMERIC(1, 1, 0))
+
+/* Z axis mapping */
+#define MSE_NOZMAP 0
+#define MSE_MAPTOX -1
+#define MSE_MAPTOY -2
+#define MSE_MAPTOZ -3
+#define MSE_MAPTOW -4
+
+/* Generalize for other axes. */
+#define MSE_NOAXISMAP MSE_NOZMAP
+
+#define MSE_MAXBUTTONS 24
+#define MSE_DFLTBUTTONS 3
+
+/*
+ * Mouse device record. This is shared by the mouse driver and the OSMouse
+ * layer.
+ */
+
+typedef void (*checkMovementsProc)(InputInfoPtr,int, int);
+typedef void (*autoProbeProc)(InputInfoPtr, Bool, Bool);
+typedef Bool (*collectDataProc)(struct _MouseDevRec *, unsigned char);
+typedef Bool (*dataGoodProc)(struct _MouseDevRec *);
+
+typedef void (*PostMseEventProc)(InputInfoPtr pInfo, int buttons,
+ int dx, int dy, int dz, int dw);
+typedef void (*MouseCommonOptProc)(InputInfoPtr pInfo);
+
+typedef struct _MouseDevRec {
+ PtrCtrlProcPtr Ctrl;
+ PostMseEventProc PostEvent;
+ MouseCommonOptProc CommonOptions;
+ DeviceIntPtr device;
+ const char * mseDevice;
+ const char * protocol;
+ MouseProtocolID protocolID;
+ MouseProtocolID oldProtocolID; /* hack */
+ int class;
+ int mseModel;
+ int baudRate;
+ int oldBaudRate;
+ int sampleRate;
+ int lastButtons;
+ int threshold; /* acceleration */
+ int num;
+ int den;
+ int buttons; /* # of buttons */
+ int emulateState; /* automata state for 2 button mode */
+ Bool emulate3Buttons;
+ Bool emulate3ButtonsSoft;
+ int emulate3Timeout;/* Timeout for 3 button emulation */
+ Bool chordMiddle;
+ Bool flipXY;
+ int invX;
+ int invY;
+ int mouseFlags; /* Flags to Clear after opening
+ * mouse dev */
+ int truebuttons; /* (not used)
+ * Arg to maintain before
+ * emulate3buttons timer callback */
+ int resolution;
+ int negativeZ; /* button mask */
+ int positiveZ; /* button mask */
+ int negativeW; /* button mask */
+ int positiveW; /* button mask */
+ pointer buffer; /* usually an XISBuffer* */
+ int protoBufTail;
+ unsigned char protoBuf[8];
+ unsigned char protoPara[8];
+ unsigned char inSync; /* driver in sync with datastream */
+ pointer mousePriv; /* private area */
+ InputInfoPtr pInfo;
+ int origProtocolID;
+ const char * origProtocol;
+ Bool emulate3Pending;/* timer waiting */
+ CARD32 emulate3Expires;/* time to fire emulation code */
+ Bool emulateWheel;
+ int wheelInertia;
+ int wheelButton;
+ int negativeX; /* Button values. Unlike the Z and */
+ int positiveX; /* W equivalents, these are button */
+ int negativeY; /* values rather than button masks. */
+ int positiveY;
+ int wheelYDistance;
+ int wheelXDistance;
+ Bool autoProbe;
+ checkMovementsProc checkMovements;
+ autoProbeProc autoProbeMouse;
+ collectDataProc collectData;
+ dataGoodProc dataGood;
+ int angleOffset;
+ pointer pDragLock; /* drag lock area */
+ int xisbscale; /* buffer size for 1 event */
+ int wheelButtonTimeout;/* Timeout for the wheel button emulation */
+ CARD32 wheelButtonExpires;
+ int doubleClickSourceButtonMask;
+ int doubleClickTargetButton;
+ int doubleClickTargetButtonMask;
+ int doubleClickOldSourceState;
+ int lastMappedButtons;
+ int buttonMap[MSE_MAXBUTTONS];
+} MouseDevRec, *MouseDevPtr;
+
+#endif /* _XF86OSMOUSE_H_ */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h
new file mode 100644
index 000000000..449e8ddd0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h
@@ -0,0 +1,57 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h,v 1.6 2003/08/24 17:37:03 dawes Exp $ */
+/*
+ * Copyright (c) 1999-2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _XF86OSPRIV_H
+#define _XF86OSPRIV_H
+
+typedef pointer (*MapMemProcPtr)(int, unsigned long, unsigned long, int);
+typedef void (*UnmapMemProcPtr)(int, pointer, unsigned long);
+typedef pointer (*SetWCProcPtr)(int, unsigned long, unsigned long, Bool,
+ MessageType);
+typedef void (*ProtectMemProcPtr)(int, pointer, unsigned long, Bool);
+typedef void (*UndoWCProcPtr)(int, pointer);
+typedef void (*ReadSideEffectsProcPtr)(int, pointer, unsigned long);
+
+typedef struct {
+ Bool initialised;
+ MapMemProcPtr mapMem;
+ UnmapMemProcPtr unmapMem;
+ ProtectMemProcPtr protectMem;
+ SetWCProcPtr setWC;
+ UndoWCProcPtr undoWC;
+ ReadSideEffectsProcPtr readSideEffects;
+ Bool linearSupported;
+} VidMemInfo, *VidMemInfoPtr;
+
+void xf86OSInitVidMem(VidMemInfoPtr);
+
+#endif /* _XF86OSPRIV_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h
new file mode 100644
index 000000000..7e6e60b5b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h
@@ -0,0 +1,759 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h,v 3.94 2003/11/03 05:11:51 tsi Exp $ */
+/*
+ * Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1992 by David Dawes <dawes@XFree86.org>
+ * Copyright 1992 by Jim Tsillas <jtsilla@damon.ccs.northeastern.edu>
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1992 by Robert Baron <Robert.Baron@ernst.mach.cs.cmu.edu>
+ * Copyright 1992 by Orest Zborowski <obz@eskimo.com>
+ * Copyright 1993 by Vrije Universiteit, The Netherlands
+ * Copyright 1993 by David Wexelblat <dwex@XFree86.org>
+ * Copyright 1994, 1996 by Holger Veit <Holger.Veit@gmd.de>
+ * Copyright 1997 by Takis Psarogiannakopoulos <takis@dpmms.cam.ac.uk>
+ * Copyright 1994-2003 by The XFree86 Project, Inc
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the above listed copyright holders
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. The above listed
+ * copyright holders make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/*
+ * The ARM32 code here carries the following copyright:
+ *
+ * Copyright 1997
+ * Digital Equipment Corporation. All rights reserved.
+ * This software is furnished under license and may be used and copied only in
+ * accordance with the following terms and conditions. Subject to these
+ * conditions, you may download, copy, install, use, modify and distribute
+ * this software in source and/or binary form. No title or ownership is
+ * transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce and retain
+ * this copyright notice and list of conditions as they appear in the
+ * source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or logo of Digital
+ * Equipment Corporation. Neither the "Digital Equipment Corporation"
+ * name nor any trademark or logo of Digital Equipment Corporation may be
+ * used to endorse or promote products derived from this software without
+ * the prior written permission of Digital Equipment Corporation.
+ *
+ * 3) This software is provided "AS-IS" and any express or implied warranties,
+ * including but not limited to, any implied warranties of merchantability,
+ * fitness for a particular purpose, or non-infringement are disclaimed.
+ * In no event shall DIGITAL be liable for any damages whatsoever, and in
+ * particular, DIGITAL shall not be liable for special, indirect,
+ * consequential, or incidental damages or damages for lost profits, loss
+ * of revenue or loss of use, whether such damages arise in contract,
+ * negligence, tort, under statute, in equity, at law or otherwise, even
+ * if advised of the possibility of such damage.
+ *
+ */
+
+/* $XConsortium: xf86_OSlib.h /main/22 1996/10/27 11:06:31 kaleb $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h,v 1.13 2005/11/08 06:33:29 jkj Exp $ */
+
+/*
+ * This is private, and should not be included by any drivers. Drivers
+ * may include xf86_OSproc.h to get prototypes for public interfaces.
+ */
+
+#ifndef _XF86_OSLIB_H
+#define _XF86_OSLIB_H
+
+#include <X11/Xos.h>
+#include <X11/Xfuncproto.h>
+
+/*
+ * Define some things from the "ANSI" C wrappers that are needed in the
+ * the core server.
+ */
+#ifndef HAVE_WRAPPER_DECLS
+#define HAVE_WRAPPER_DECLS
+#undef usleep
+#define usleep(a) xf86usleep(a)
+extern void xf86usleep(unsigned long);
+extern int xf86getpagesize(void);
+extern int xf86GetErrno(void);
+typedef unsigned long xf86size_t;
+typedef signed long xf86ssize_t;
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stddef.h>
+
+/**************************************************************************/
+/* SYSV386 (SVR3, SVR4), including Solaris */
+/**************************************************************************/
+#if (defined(SYSV) || defined(SVR4)) && \
+ !defined(DGUX) && !defined(sgi) && \
+ (defined(sun) || defined(i386))
+# ifdef SCO325
+# ifndef _SVID3
+# define _SVID3
+# endif
+# ifndef _NO_STATIC
+# define _NO_STATIC
+# endif
+# endif
+# include <sys/ioctl.h>
+# include <signal.h>
+# include <termio.h>
+# include <sys/stat.h>
+# include <sys/types.h>
+# if defined(__SCO__) || defined(ISC)
+# include <sys/param.h>
+# endif
+
+# ifdef ISC
+# define TIOCMSET (TIOC|26) /* set all modem bits */
+# define TIOCMBIS (TIOC|27) /* bis modem bits */
+# define TIOCMBIC (TIOC|28) /* bic modem bits */
+# define TIOCMGET (TIOC|29) /* get all modem bits */
+# endif
+
+# include <errno.h>
+
+# if defined(PowerMAX_OS)
+# define HAS_USL_VTS
+# include <sys/immu.h>
+# include <sys/sysmacros.h>
+# elif defined(_NEED_SYSI86)
+# include <sys/immu.h>
+# if !(defined (sun) && defined (SVR4))
+# include <sys/region.h>
+# endif
+# include <sys/proc.h>
+# include <sys/tss.h>
+# include <sys/sysi86.h>
+# if defined(SVR4) && !defined(sun)
+# include <sys/seg.h>
+# endif /* SVR4 && !sun */
+/* V86SC_IOPL was moved to <sys/sysi86.h> on Solaris 7 and later */
+# if defined(sun) && defined (SVR4) /* Solaris? */
+# if defined(i386) || defined(__x86) /* on x86 or x64? */
+# if !defined(V86SC_IOPL) /* Solaris 7 or later? */
+# include <sys/v86.h> /* Nope */
+# endif
+# endif /* V86SC_IOPL */
+# else
+# include <sys/v86.h> /* Not solaris */
+# endif /* sun && i386 && SVR4 */
+# if defined(sun) && (defined (i386) || defined(__x86)) && defined (SVR4)
+# include <sys/psw.h>
+# endif
+# endif /* _NEED_SYSI86 */
+
+# if defined(HAS_SVR3_MMAPDRV)
+# include <sys/sysmacros.h>
+# if !defined(_NEED_SYSI86)
+# include <sys/immu.h>
+# include <sys/region.h>
+# endif
+# include <sys/mmap.h> /* MMAP driver header */
+# endif
+
+# if !defined(sun) || (!defined(sparc) && !defined(__SOL8__))
+# define HAS_USL_VTS
+# endif
+# if !defined(sun)
+# include <sys/emap.h>
+# endif
+# if defined(SCO325)
+# include <sys/vtkd.h>
+# include <sys/console.h>
+# include <sys/scankbd.h>
+# include <sys/vid.h>
+# define LED_CAP CLKED
+# define LED_NUM NLKED
+# define LED_SCR SLKED
+# elif defined(HAS_USL_VTS)
+# include <sys/at_ansi.h>
+# include <sys/kd.h>
+# include <sys/vt.h>
+# elif defined(sun)
+# include <sys/fbio.h>
+# include <sys/kbd.h>
+# include <sys/kbio.h>
+
+/* undefine symbols from <sys/kbd.h> we don't need that conflict with enum
+ definitions in parser/xf86tokens.h */
+# undef STRING
+# undef LEFTALT
+# undef RIGHTALT
+
+# define LED_CAP LED_CAPS_LOCK
+# define LED_NUM LED_NUM_LOCK
+# define LED_SCR LED_SCROLL_LOCK
+# define LED_COMP LED_COMPOSE
+# endif /* sun */
+
+# if !defined(VT_ACKACQ)
+# define VT_ACKACQ 2
+# endif /* !VT_ACKACQ */
+
+# if defined(__SCO__)
+# include <sys/sysmacros.h>
+# define POSIX_TTY
+# endif /* __SCO__ */
+
+# if defined(SVR4) || defined(SCO325)
+# include <sys/mman.h>
+# if !(defined(sun) && defined (SVR4))
+# define DEV_MEM "/dev/pmem"
+# elif defined(PowerMAX_OS)
+# define DEV_MEM "/dev/iomem"
+# endif
+# ifdef SCO325
+# undef DEV_MEM
+# define DEV_MEM "/dev/mem"
+# endif
+# define CLEARDTR_SUPPORT
+# define POSIX_TTY
+# endif /* SVR4 */
+
+# ifdef ISC
+# include <termios.h>
+# define POSIX_TTY
+# endif
+
+# if defined(sun) && defined (i386) && defined (SVR4) && !defined(__SOL8__)
+# define USE_VT_SYSREQ
+# define VT_SYSREQ_DEFAULT TRUE
+# endif
+
+# if defined(ATT) && !defined(i386)
+# define i386 /* not defined in ANSI C mode */
+# endif /* ATT && !i386 */
+
+# if (defined(ATT) || defined(SVR4)) && !defined(sun)
+# ifndef __UNIXWARE__
+# ifndef XQUEUE
+# define XQUEUE
+# endif
+# endif
+# include <sys/xque.h>
+# endif /* ATT || SVR4 */
+
+# ifdef SYSV
+# if !defined(ISC) || defined(ISC202) || defined(ISC22)
+# define NEED_STRERROR
+# endif
+# endif
+
+#endif /* (SYSV || SVR4) && !DGUX */
+
+
+
+/**************************************************************************/
+/* DG/ux R4.20MU03 Intel AViion Machines */
+/**************************************************************************/
+#if defined(DGUX) && defined(SVR4)
+#include <sys/ioctl.h>
+#include <signal.h>
+#include <ctype.h>
+#include <termios.h> /* Use termios for BSD Flavor ttys */
+#include <sys/termios.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#include <errno.h>
+#include <sys/sysi86.h>
+#include <unistd.h>
+#include <sys/proc.h>
+#include <sys/map.h>
+#include <sys/sysmacros.h>
+#include <sys/mman.h> /* Memory handling */
+#include <sys/kd.h> /* definitios for KDENABIO KDDISABIO needed for IOPL s */
+#include <sys/kbd.h>
+#include <fcntl.h>
+#include <time.h>
+#include <sys/stream.h>
+#include <sys/ptms.h>
+
+#include <sys/socket.h>
+#include <sys/utsname.h>
+#include <sys/stropts.h>
+#include <sys/sockio.h>
+
+
+#define POSIX_TTY
+
+#undef HAS_USL_VTS
+#undef USE_VT_SYSREQ
+#undef VT_ACKACQ
+
+#define LED_CAP KBD_LED_CAPS_LOCK
+#define LED_NUM KBD_LED_NUM_LOCK
+#define LED_SCR KBD_LED_SCROLL_LOCK
+
+#define KDGKBTYPE KBD_GET_LANGUAGE
+
+
+/* General keyboard types */
+# define KB_84 2
+# define KB_101 1 /* Because ioctl(dgkeybdFd,KBD_GET_LANGUAGE,&type) gives 1=US keyboard */
+# define KB_OTHER 3
+
+#define KDSETLED KBD_SET_LED
+#define KDGETLED KBD_GET_STATE
+#undef KDMKTONE
+#define KDMKTONE KBD_TONE_HIGH
+
+
+#undef DEV_MEM
+#define DEV_MEM "/dev/mem"
+#define CLEARDTR_SUPPORT
+
+#undef VT_SYSREQ_DEFAULT
+#define VT_SYSREQ_DEFAULT FALSE /* Make sure that we dont define any VTs since DG/ux has none */
+
+#endif /* DGUX && SVR4 */
+
+/**************************************************************************/
+/* Linux or Glibc-based system */
+/**************************************************************************/
+#if defined(__linux__) || defined(__GLIBC__)
+# include <sys/ioctl.h>
+# include <signal.h>
+# include <stdlib.h>
+# include <sys/types.h>
+# include <assert.h>
+
+#ifdef __GNU__ /* GNU/Hurd */
+# define USE_OSMOUSE
+#endif
+
+# ifdef __linux__
+# include <termio.h>
+# else /* __GLIBC__ */
+# include <termios.h>
+# endif
+# ifdef __sparc__
+# include <sys/param.h>
+# endif
+
+# include <errno.h>
+
+# include <sys/stat.h>
+
+# include <sys/mman.h>
+# ifdef __linux__
+# define HAS_USL_VTS
+# include <sys/kd.h>
+# include <sys/vt.h>
+# define LDGMAP GIO_SCRNMAP
+# define LDSMAP PIO_SCRNMAP
+# define LDNMAP LDSMAP
+# define CLEARDTR_SUPPORT
+# define USE_VT_SYSREQ
+# endif
+
+# define POSIX_TTY
+
+#endif /* __linux__ || __GLIBC__ */
+
+/**************************************************************************/
+/* LynxOS AT */
+/**************************************************************************/
+#if defined(Lynx)
+
+# include <termio.h>
+# include <sys/ioctl.h>
+# include <param.h>
+# include <signal.h>
+# include <kd.h>
+# include <vt.h>
+# include <sys/stat.h>
+
+# include <errno.h>
+extern int errno;
+
+/* smem_create et.al. to access physical memory */
+# include <smem.h>
+
+/* keyboard types */
+# define KB_84 1
+# define KB_101 2
+# define KB_OTHER 3
+
+/* atc drivers ignores argument to VT_RELDISP ioctl */
+# define VT_ACKACQ 2
+
+# include <termios.h>
+# define POSIX_TTY
+# define CLEARDTR_SUPPORT
+
+/* LynxOS 2.5.1 has these */
+# ifdef LED_NUMLOCK
+# define LED_CAP LED_CAPSLOCK
+# define LED_NUM LED_NUMLOCK
+# define LED_SCR LED_SCROLLOCK
+# endif
+
+#endif /* Lynx */
+
+/**************************************************************************/
+/* 386BSD and derivatives, BSD/386 */
+/**************************************************************************/
+
+#if defined(__386BSD__) && (defined(__FreeBSD__) || defined(__NetBSD__))
+# undef __386BSD__
+#endif
+
+#ifdef CSRG_BASED
+# include <sys/ioctl.h>
+# include <signal.h>
+
+# include <termios.h>
+# define termio termios
+# define POSIX_TTY
+
+# include <errno.h>
+
+# include <sys/types.h>
+# include <sys/mman.h>
+# include <sys/stat.h>
+
+# if defined(__bsdi__)
+# include <sys/param.h>
+# if (_BSDI_VERSION < 199510)
+# include <i386/isa/vgaioctl.h>
+# endif
+# endif /* __bsdi__ */
+
+#endif /* CSRG_BASED */
+
+/**************************************************************************/
+/* Kernel of *BSD */
+/**************************************************************************/
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
+ defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
+
+# include <sys/param.h>
+# if defined(__FreeBSD_version) && !defined(__FreeBSD_kernel_version)
+# define __FreeBSD_kernel_version __FreeBSD_version
+# endif
+
+# if !defined(LINKKIT)
+ /* Don't need this stuff for the Link Kit */
+# if defined(__bsdi__)
+# include <i386/isa/pcconsioctl.h>
+# define CONSOLE_X_MODE_ON PCCONIOCRAW
+# define CONSOLE_X_MODE_OFF PCCONIOCCOOK
+# define CONSOLE_X_BELL PCCONIOCBEEP
+# else /* __bsdi__ */
+# if defined(__OpenBSD__)
+# ifdef PCCONS_SUPPORT
+# include <machine/pccons.h>
+# undef CONSOLE_X_MODE_ON
+# undef CONSOLE_X_MODE_OFF
+# undef CONSOLE_X_BELL
+# endif
+# endif
+# ifdef SYSCONS_SUPPORT
+# define COMPAT_SYSCONS
+# if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+# include <machine/console.h>
+# else
+# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+# if (__FreeBSD_kernel_version >= 410000)
+# include <sys/consio.h>
+# include <sys/kbio.h>
+# else
+# include <machine/console.h>
+# endif /* FreeBSD 4.1 RELEASE or lator */
+# else
+# include <sys/console.h>
+# endif
+# endif
+# endif /* SYSCONS_SUPPORT */
+# if defined(PCVT_SUPPORT)
+# if !defined(SYSCONS_SUPPORT)
+ /* no syscons, so include pcvt specific header file */
+# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+# include <machine/pcvt_ioctl.h>
+# else
+# if defined(__NetBSD__) || defined(__OpenBSD__)
+# if !defined(WSCONS_SUPPORT)
+# include <machine/pcvt_ioctl.h>
+# endif /* WSCONS_SUPPORT */
+# else
+# include <sys/pcvt_ioctl.h>
+# endif /* __NetBSD__ */
+# endif /* __FreeBSD_kernel__ || __OpenBSD__ */
+# else /* pcvt and syscons: hard-code the ID magic */
+# define VGAPCVTID _IOWR('V',113, struct pcvtid)
+ struct pcvtid {
+ char name[16];
+ int rmajor, rminor;
+ };
+# endif /* PCVT_SUPPORT && SYSCONS_SUPPORT */
+# endif /* PCVT_SUPPORT */
+# ifdef WSCONS_SUPPORT
+# include <dev/wscons/wsconsio.h>
+# include <dev/wscons/wsdisplay_usl_io.h>
+# endif /* WSCONS_SUPPORT */
+# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+# if (__FreeBSD_kernel_version >= 500013)
+# include <sys/mouse.h>
+# else
+# undef MOUSE_GETINFO
+# include <machine/mouse.h>
+# endif
+# endif
+ /* Include these definitions in case ioctl_pc.h didn't get included */
+# ifndef CONSOLE_X_MODE_ON
+# define CONSOLE_X_MODE_ON _IO('t',121)
+# endif
+# ifndef CONSOLE_X_MODE_OFF
+# define CONSOLE_X_MODE_OFF _IO('t',122)
+# endif
+# ifndef CONSOLE_X_BELL
+# define CONSOLE_X_BELL _IOW('t',123,int[2])
+# endif
+# ifndef CONSOLE_X_TV_ON
+# define CONSOLE_X_TV_ON _IOW('t',155,int)
+# define XMODE_RGB 0
+# define XMODE_NTSC 1
+# define XMODE_PAL 2
+# define XMODE_SECAM 3
+# endif
+# ifndef CONSOLE_X_TV_OFF
+# define CONSOLE_X_TV_OFF _IO('t',156)
+# endif
+#ifndef CONSOLE_GET_LINEAR_INFO
+# define CONSOLE_GET_LINEAR_INFO _IOR('t',157,struct map_info)
+#endif
+#ifndef CONSOLE_GET_IO_INFO
+# define CONSOLE_GET_IO_INFO _IOR('t',158,struct map_info)
+#endif
+#ifndef CONSOLE_GET_MEM_INFO
+# define CONSOLE_GET_MEM_INFO _IOR('t',159,struct map_info)
+#endif
+# endif /* __bsdi__ */
+# endif /* !LINKKIT */
+
+#if defined(USE_I386_IOPL) || defined(USE_AMD64_IOPL)
+#include <machine/sysarch.h>
+#endif
+
+# define CLEARDTR_SUPPORT
+
+# if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
+# define USE_VT_SYSREQ
+# endif
+
+#endif
+/* __FreeBSD_kernel__ || __NetBSD__ || __OpenBSD__ || __bsdi__ */
+
+/**************************************************************************/
+/* OS/2 */
+/**************************************************************************/
+/* currently OS/2 with a modified EMX/GCC compiler only */
+#if defined(__UNIXOS2__)
+# include <signal.h>
+# include <errno.h>
+# include <sys/stat.h>
+
+/* I would have liked to have this included here always, but
+ * it causes clashes for BYTE and BOOL with Xmd.h, which is too dangerous.
+ * So I'll include it in place where I know it does no harm.
+ */
+#if defined(I_NEED_OS2_H)
+# undef BOOL
+# undef BYTE
+# include <os2.h>
+#endif
+
+ /* keyboard types */
+# define KB_84 1
+# define KB_101 2
+/* could detect more keyboards */
+# define KB_OTHER 3
+
+ /* LEDs */
+# define LED_CAP 0x40
+# define LED_NUM 0x20
+# define LED_SCR 0x10
+
+ /* mouse driver */
+# define OSMOUSE_ONLY
+# define MOUSE_PROTOCOL_IN_KERNEL
+
+extern char* __XOS2RedirRoot(char*);
+
+#endif
+
+/**************************************************************************/
+/* QNX4 */
+/**************************************************************************/
+/* This is the QNX code for Watcom 10.6 and QNX 4.x */
+#if defined(QNX4)
+#include <signal.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <termios.h>
+#include <ioctl.h>
+#include <sys/param.h>
+
+/* Warning: by default, the fd_set size is 32 in QNX! */
+#define FD_SETSIZE 256
+#include <sys/select.h>
+
+ /* keyboard types */
+# define KB_84 1
+# define KB_101 2
+# define KB_OTHER 3
+
+ /* LEDs */
+# define LED_CAP 0x04
+# define LED_NUM 0x02
+# define LED_SCR 0x01
+
+# define POSIX_TTY
+# define OSMOUSE_ONLY
+# define MOUSE_PROTOCOL_IN_KERNEL
+
+#define TIOCM_DTR 0x0001 /* data terminal ready */
+#define TIOCM_RTS 0x0002 /* request to send */
+#define TIOCM_CTS 0x1000 /* clear to send */
+#define TIOCM_DSR 0x2000 /* data set ready */
+#define TIOCM_RI 0x4000 /* ring */
+#define TIOCM_RNG TIOCM_RI
+#define TIOCM_CD 0x8000 /* carrier detect */
+#define TIOCM_CAR TIOCM_CD
+#define TIOCM_LE 0x0100 /* line enable */
+#define TIOCM_ST 0x0200 /* secondary transmit */
+#define TIOCM_SR 0x0400 /* secondary receive */
+
+#endif
+
+/**************************************************************************/
+/* QNX/Neutrino */
+/**************************************************************************/
+/* This is the Neutrino code for for NTO2.0 and GCC */
+#if defined(__QNXNTO__)
+#include <signal.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <termios.h>
+#include <ioctl.h>
+#include <sys/param.h>
+
+/* Warning: by default, the fd_set size is 32 in NTO! */
+#define FD_SETSIZE 256
+#include <sys/select.h>
+
+ /* keyboard types */
+# define KB_84 1
+# define KB_101 2
+# define KB_OTHER 3
+
+# define POSIX_TTY
+
+#endif
+
+/**************************************************************************/
+/* IRIX */
+/**************************************************************************/
+#if defined(sgi)
+
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#endif
+
+/**************************************************************************/
+/* Generic */
+/**************************************************************************/
+
+#include <sys/wait.h> /* May need to adjust this for other OSs */
+
+/*
+ * Hack originally for ISC 2.2 POSIX headers, but may apply elsewhere,
+ * and it's safe, so just do it.
+ */
+#if !defined(O_NDELAY) && defined(O_NONBLOCK)
+# define O_NDELAY O_NONBLOCK
+#endif /* !O_NDELAY && O_NONBLOCK */
+
+#if !defined(MAXHOSTNAMELEN)
+# define MAXHOSTNAMELEN 32
+#endif /* !MAXHOSTNAMELEN */
+
+#if !defined(X_NOT_POSIX)
+# if defined(_POSIX_SOURCE)
+# include <limits.h>
+# else
+# define _POSIX_SOURCE
+# include <limits.h>
+# undef _POSIX_SOURCE
+# endif /* _POSIX_SOURCE */
+#endif /* !X_NOT_POSIX */
+#if !defined(PATH_MAX)
+# if defined(MAXPATHLEN)
+# define PATH_MAX MAXPATHLEN
+# else
+# define PATH_MAX 1024
+# endif /* MAXPATHLEN */
+#endif /* !PATH_MAX */
+
+#ifdef NEED_STRERROR
+# ifndef strerror
+extern char *sys_errlist[];
+extern int sys_nerr;
+# define strerror(n) \
+ ((n) >= 0 && (n) < sys_nerr) ? sys_errlist[n] : "unknown error"
+# endif /* !strerror */
+#endif /* NEED_STRERROR */
+
+#if defined(ISC) || defined(Lynx)
+#define rint(x) RInt(x)
+double RInt(
+ double x
+);
+#endif
+
+#ifndef DEV_MEM
+#define DEV_MEM "/dev/mem"
+#endif
+
+#ifndef VT_SYSREQ_DEFAULT
+#define VT_SYSREQ_DEFAULT FALSE
+#endif
+
+#ifdef OSMOUSE_ONLY
+# ifndef MOUSE_PROTOCOL_IN_KERNEL
+# define MOUSE_PROTOCOL_IN_KERNEL
+# endif
+#endif
+
+#define SYSCALL(call) while(((call) == -1) && (errno == EINTR))
+
+#define XF86_OS_PRIVS
+#include "xf86_OSproc.h"
+
+#ifndef NO_COMPILER_H
+#include "compiler.h"
+#endif
+
+#endif /* _XF86_OSLIB_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h
new file mode 100644
index 000000000..83ce9ed2b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h
@@ -0,0 +1,277 @@
+/*
+ * Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1992 by David Dawes <dawes@XFree86.org>
+ * Copyright 1992 by Jim Tsillas <jtsilla@damon.ccs.northeastern.edu>
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1992 by Robert Baron <Robert.Baron@ernst.mach.cs.cmu.edu>
+ * Copyright 1992 by Orest Zborowski <obz@eskimo.com>
+ * Copyright 1993 by Vrije Universiteit, The Netherlands
+ * Copyright 1993 by David Wexelblat <dwex@XFree86.org>
+ * Copyright 1994, 1996 by Holger Veit <Holger.Veit@gmd.de>
+ * Copyright 1994-2003 by The XFree86 Project, Inc
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the above listed copyright holders
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. The above listed
+ * copyright holders make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/*
+ * The ARM32 code here carries the following copyright:
+ *
+ * Copyright 1997
+ * Digital Equipment Corporation. All rights reserved.
+ * This software is furnished under license and may be used and copied only in
+ * accordance with the following terms and conditions. Subject to these
+ * conditions, you may download, copy, install, use, modify and distribute
+ * this software in source and/or binary form. No title or ownership is
+ * transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce and retain
+ * this copyright notice and list of conditions as they appear in the
+ * source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or logo of Digital
+ * Equipment Corporation. Neither the "Digital Equipment Corporation"
+ * name nor any trademark or logo of Digital Equipment Corporation may be
+ * used to endorse or promote products derived from this software without
+ * the prior written permission of Digital Equipment Corporation.
+ *
+ * 3) This software is provided "AS-IS" and any express or implied warranties,
+ * including but not limited to, any implied warranties of merchantability,
+ * fitness for a particular purpose, or non-infringement are disclaimed.
+ * In no event shall DIGITAL be liable for any damages whatsoever, and in
+ * particular, DIGITAL shall not be liable for special, indirect,
+ * consequential, or incidental damages or damages for lost profits, loss
+ * of revenue or loss of use, whether such damages arise in contract,
+ * negligence, tort, under statute, in equity, at law or otherwise, even
+ * if advised of the possibility of such damage.
+ *
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h,v 3.56 2003/08/24 17:37:03 dawes Exp $ */
+
+#ifndef _XF86_OSPROC_H
+#define _XF86_OSPROC_H
+
+#ifdef XF86_OS_PRIVS
+#include "xf86Pci.h"
+#endif
+
+/*
+ * The actual prototypes have been pulled into this seperate file so
+ * that they can can be used without pulling in all of the OS specific
+ * stuff like sys/stat.h, etc. This casues problem for loadable modules.
+ */
+
+/*
+ * Flags for xf86MapVidMem(). Multiple flags can be or'd together. The
+ * flags may be used as hints. For example it would be permissible to
+ * enable write combining for memory marked only for framebuffer use.
+ */
+
+#define VIDMEM_FRAMEBUFFER 0x01 /* memory for framebuffer use */
+#define VIDMEM_MMIO 0x02 /* memory for I/O use */
+#define VIDMEM_MMIO_32BIT 0x04 /* memory accesses >= 32bit */
+#define VIDMEM_READSIDEEFFECT 0x08 /* reads can have side-effects */
+#define VIDMEM_SPARSE 0x10 /* sparse mapping required
+ * assumed when VIDMEM_MMIO is
+ * set. May be used with
+ * VIDMEM_FRAMEBUFFER) */
+#define VIDMEM_READONLY 0x20 /* read-only mapping
+ * used when reading BIOS images
+ * through xf86MapVidMem() */
+
+/*
+ * OS-independent modem state flags for xf86SetSerialModemState() and
+ * xf86GetSerialModemState().
+ */
+#define XF86_M_LE 0x001 /* line enable */
+#define XF86_M_DTR 0x002 /* data terminal ready */
+#define XF86_M_RTS 0x004 /* request to send */
+#define XF86_M_ST 0x008 /* secondary transmit */
+#define XF86_M_SR 0x010 /* secondary receive */
+#define XF86_M_CTS 0x020 /* clear to send */
+#define XF86_M_CAR 0x040 /* carrier detect */
+#define XF86_M_RNG 0x080 /* ring */
+#define XF86_M_DSR 0x100 /* data set ready */
+
+#ifdef XF86_OS_PRIVS
+extern void xf86WrapperInit(void);
+#endif
+
+#ifndef NO_OSLIB_PROTOTYPES
+/*
+ * This is to prevent re-entrancy to FatalError() when aborting.
+ * Anything that can be called as a result of AbortDDX() should use this
+ * instead of FatalError().
+ */
+
+#define xf86FatalError(a, b) \
+ if (dispatchException & DE_TERMINATE) { \
+ ErrorF(a, b); \
+ ErrorF("\n"); \
+ return; \
+ } else FatalError(a, b)
+
+/***************************************************************************/
+/* Prototypes */
+/***************************************************************************/
+
+#include <X11/Xfuncproto.h>
+#include "opaque.h"
+
+#if defined(XQUEUE)
+#include "input.h" /* for DeviceIntPtr */
+#endif
+
+_XFUNCPROTOBEGIN
+
+/* public functions */
+extern Bool xf86LinearVidMem(void);
+extern Bool xf86CheckMTRR(int);
+extern pointer xf86MapVidMem(int, int, unsigned long, unsigned long);
+extern void xf86UnMapVidMem(int, pointer, unsigned long);
+extern void xf86MapReadSideEffects(int, int, pointer, unsigned long);
+extern int xf86ReadBIOS(unsigned long, unsigned long, unsigned char *, int);
+extern Bool xf86EnableIO(void);
+extern void xf86DisableIO(void);
+extern Bool xf86DisableInterrupts(void);
+extern void xf86EnableInterrupts(void);
+extern void xf86SetTVOut(int);
+extern void xf86SetRGBOut(void);
+extern void xf86SoundKbdBell(int, int, int);
+#if defined(QNX4)
+#pragma aux xf86BusToMem modify [eax ebx ecx edx esi edi];
+#pragma aux xf86MemToBus modify [eax ebx ecx edx esi edi];
+#endif
+extern void xf86BusToMem(unsigned char *, unsigned char *, int);
+extern void xf86MemToBus(unsigned char *, unsigned char *, int);
+extern void xf86IODelay(void);
+extern void xf86UDelay(long usec);
+extern void xf86SlowBcopy(unsigned char *, unsigned char *, int);
+extern int xf86OpenSerial(pointer options);
+extern int xf86SetSerial(int fd, pointer options);
+extern int xf86SetSerialSpeed(int fd, int speed);
+extern int xf86ReadSerial(int fd, void *buf, int count);
+extern int xf86WriteSerial(int fd, const void *buf, int count);
+extern int xf86CloseSerial(int fd);
+extern int xf86FlushInput(int fd);
+extern int xf86WaitForInput(int fd, int timeout);
+extern int xf86SerialSendBreak(int fd, int duration);
+extern int xf86SetSerialModemState(int fd, int state);
+extern int xf86GetSerialModemState(int fd);
+extern int xf86SerialModemSetBits(int fd, int bits);
+extern int xf86SerialModemClearBits(int fd, int bits);
+extern int xf86LoadKernelModule(const char *pathname);
+
+/* AGP GART interface */
+
+typedef struct _AgpInfo {
+ CARD32 bridgeId;
+ CARD32 agpMode;
+ unsigned long base;
+ unsigned long size;
+ unsigned long totalPages;
+ unsigned long systemPages;
+ unsigned long usedPages;
+} AgpInfo, *AgpInfoPtr;
+
+extern Bool xf86AgpGARTSupported(void);
+extern AgpInfoPtr xf86GetAGPInfo(int screenNum);
+extern Bool xf86AcquireGART(int screenNum);
+extern Bool xf86ReleaseGART(int screenNum);
+extern int xf86AllocateGARTMemory(int screenNum, unsigned long size, int type,
+ unsigned long *physical);
+extern Bool xf86DeallocateGARTMemory(int screenNum, int key);
+extern Bool xf86BindGARTMemory(int screenNum, int key, unsigned long offset);
+extern Bool xf86UnbindGARTMemory(int screenNum, int key);
+extern Bool xf86EnableAGP(int screenNum, CARD32 mode);
+extern Bool xf86GARTCloseScreen(int screenNum);
+
+/* These routines are in shared/sigio.c and are not loaded as part of the
+ module. These routines are small, and the code if very POSIX-signal (or
+ OS-signal) specific, so it seemed better to provide more complex
+ wrappers than to wrap each individual function called. */
+extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *);
+extern int xf86RemoveSIGIOHandler(int fd);
+extern int xf86BlockSIGIO (void);
+extern void xf86UnblockSIGIO (int);
+#ifdef XFree86Server
+extern void xf86AssertBlockedSIGIO (char *);
+#endif
+extern Bool xf86SIGIOSupported (void);
+
+#ifdef XF86_OS_PRIVS
+typedef void (*PMClose)(void);
+extern void xf86OpenConsole(void);
+extern void xf86CloseConsole(void);
+extern Bool xf86VTSwitchPending(void);
+extern Bool xf86VTSwitchAway(void);
+extern Bool xf86VTSwitchTo(void);
+extern void xf86VTRequest(int sig);
+extern int xf86ProcessArgument(int, char **, int);
+extern void xf86UseMsg(void);
+extern void xf86SetKbdLeds(int);
+extern int xf86GetKbdLeds(void);
+extern void xf86SetKbdRepeat(char);
+extern void xf86KbdInit(void);
+extern int xf86KbdOn(void);
+extern int xf86KbdOff(void);
+extern void xf86KbdEvents(void);
+#ifdef XQUEUE
+extern int xf86XqueKbdProc(DeviceIntPtr, int);
+extern void xf86XqueEvents(void);
+#endif
+extern void xf86ReloadInputDevs(int sig);
+#ifdef WSCONS_SUPPORT
+extern void xf86WSKbdEvents(void);
+#endif
+extern PMClose xf86OSPMOpen(void);
+
+#ifdef NEED_OS_RAC_PROTOS
+/* RAC-related privs */
+/* internal to os-support layer */
+resPtr xf86StdBusAccWindowsFromOS(void);
+resPtr xf86StdPciAccWindowsFromOS(void);
+resPtr xf86StdIsaAccWindowsFromOS(void);
+resPtr xf86StdAccResFromOS(resPtr ret);
+
+/* available to the common layer */
+resPtr xf86BusAccWindowsFromOS(void);
+resPtr xf86PciBusAccWindowsFromOS(void);
+#ifdef INCLUDE_UNUSED
+resPtr xf86IsaBusAccWindowsFromOS(void);
+#endif
+resPtr xf86AccResFromOS(resPtr ret);
+#endif /* NEED_OS_RAC_PROTOS */
+
+extern Bool xf86GetPciSizeFromOS(PCITAG tag, int indx, int* bits);
+extern Bool xf86GetPciOffsetFromOS(PCITAG tag, int indx, unsigned long* bases);
+extern unsigned long xf86GetOSOffsetFromPCI(PCITAG tag, int space, unsigned long base);
+
+extern void xf86MakeNewMapping(int, int, unsigned long, unsigned long, pointer);
+extern void xf86InitVidMem(void);
+
+#endif /* XF86_OS_PRIVS */
+
+
+_XFUNCPROTOEND
+#endif /* NO_OSLIB_PROTOTYPES */
+
+#endif /* _XF86_OSPROC_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h
new file mode 100644
index 000000000..c4090dc16
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h
@@ -0,0 +1,354 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h,v 3.53 2003/10/28 18:36:37 tsi Exp $ */
+/*
+ * Copyright 1997-2003 by The XFree86 Project, Inc
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the above listed copyright holders
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. The above listed
+ * copyright holders make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifndef _XF86_ANSIC_H
+#define _XF86_ANSIC_H
+
+/* Handle <stdarg.h> */
+
+#ifndef IN_MODULE
+# include <stdarg.h>
+#else /* !IN_MODULE */
+# ifndef __OS2ELF__
+# include <stdarg.h>
+# else /* __OS2ELF__ */
+ /* EMX/gcc_elf under OS/2 does not have native header files */
+# if !defined (_VA_LIST)
+# define _VA_LIST
+ typedef char *va_list;
+# endif
+# define _VA_ROUND(t) ((sizeof (t) + 3) & -4)
+# if !defined (va_start)
+# define va_start(ap,v) ap = (va_list)&v + ((sizeof (v) + 3) & -4)
+# define va_end(ap) (ap = 0, (void)0)
+# define va_arg(ap,t) (ap += _VA_ROUND (t), *(t *)(ap - _VA_ROUND (t)))
+# endif
+# endif /* __OS2ELF__ */
+#endif /* IN_MODULE */
+
+/*
+ * The first set of definitions are required both for modules and
+ * libc_wrapper.c.
+ */
+
+#if defined(XFree86LOADER) || defined(NEED_XF86_TYPES)
+
+#if !defined(SYSV) && !defined(SVR4) && !defined(Lynx) || \
+ defined(__SCO__) || defined(__UNIXWARE__)
+#define HAVE_VSSCANF
+#define HAVE_VFSCANF
+#endif
+
+#ifndef NULL
+#if (defined(SVR4) || defined(SYSV)) && !defined(__GNUC__)
+#define NULL 0
+#else
+#define NULL ((void *)0)
+#endif
+#endif
+#ifndef EOF
+#define EOF (-1)
+#endif
+
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
+/* <limits.h> stuff */
+#define x_BITSPERBYTE 8
+#define x_BITS(type) (x_BITSPERBYTE * (int)sizeof(type))
+#define x_SHORTBITS x_BITS(short)
+#define x_INTBITS x_BITS(int)
+#define x_LONGBITS x_BITS(long)
+#ifndef SHRT_MIN
+#define SHRT_MIN ((short)(1 << (x_SHORTBITS - 1)))
+#endif
+
+#ifndef FONTMODULE
+#include "misc.h"
+#endif
+#include "xf86_libc.h"
+#ifndef SHRT_MAX
+#define SHRT_MAX ((short)~SHRT_MIN)
+#endif
+#ifndef USHRT_MAX
+#define USHRT_MAX ((unsigned short)~0)
+#endif
+#ifndef MINSHORT
+#define MINSHORT SHRT_MIN
+#endif
+#ifndef MAXSHORT
+#define MAXSHORT SHRT_MAX
+#endif
+#ifndef INT_MIN
+#define INT_MIN (1 << (x_INTBITS - 1))
+#endif
+#ifndef INT_MAX
+#define INT_MAX (~INT_MIN)
+#endif
+#ifndef UINT_MAX
+#define UINT_MAX (~0)
+#endif
+#ifndef MININT
+#define MININT INT_MIN
+#endif
+#ifndef MAXINT
+#define MAXINT INT_MAX
+#endif
+#ifndef LONG_MIN
+#define LONG_MIN ((long)(1 << (x_LONGBITS - 1)))
+#endif
+#ifndef LONG_MAX
+#define LONG_MAX ((long)~LONG_MIN)
+#endif
+#ifndef ULONG_MAX
+#define ULONG_MAX ((unsigned long)~0UL)
+#endif
+#ifndef MINLONG
+#define MINLONG LONG_MIN
+#endif
+#ifndef MAXLONG
+#define MAXLONG LONG_MAX
+#endif
+
+#endif /* XFree86LOADER || NEED_XF86_TYPES */
+
+#if defined(XFree86LOADER) || defined(NEED_XF86_PROTOTYPES)
+/*
+ * ANSI C compilers only.
+ */
+
+/* ANSI C emulation library */
+
+extern void xf86abort(void);
+extern int xf86abs(int);
+extern double xf86acos(double);
+extern double xf86asin(double);
+extern double xf86atan(double);
+extern double xf86atan2(double,double);
+extern double xf86atof(const char*);
+extern int xf86atoi(const char*);
+extern long xf86atol(const char*);
+extern void *xf86bsearch(const void *, const void *, xf86size_t, xf86size_t,
+ int (*)(const void *, const void *));
+extern double xf86ceil(double);
+extern void* xf86calloc(xf86size_t,xf86size_t);
+extern void xf86clearerr(XF86FILE*);
+extern double xf86cos(double);
+extern void xf86exit(int);
+extern double xf86exp(double);
+extern double xf86fabs(double);
+extern int xf86fclose(XF86FILE*);
+extern int xf86feof(XF86FILE*);
+extern int xf86ferror(XF86FILE*);
+extern int xf86fflush(XF86FILE*);
+extern int xf86fgetc(XF86FILE*);
+extern int xf86getc(XF86FILE*);
+extern int xf86fgetpos(XF86FILE*,XF86fpos_t*);
+extern char* xf86fgets(char*,INT32,XF86FILE*);
+extern int xf86finite(double);
+extern double xf86floor(double);
+extern double xf86fmod(double,double);
+extern XF86FILE* xf86fopen(const char*,const char*);
+extern double xf86frexp(double, int*);
+extern int xf86printf(const char*,...);
+extern int xf86fprintf(XF86FILE*,const char*,...);
+extern int xf86fputc(int,XF86FILE*);
+extern int xf86fputs(const char*,XF86FILE*);
+extern xf86size_t xf86fread(void*,xf86size_t,xf86size_t,XF86FILE*);
+extern void xf86free(void*);
+extern XF86FILE* xf86freopen(const char*,const char*,XF86FILE*);
+#if defined(HAVE_VFSCANF) || !defined(NEED_XF86_PROTOTYPES)
+extern int xf86fscanf(XF86FILE*,const char*,...);
+#else
+extern int xf86fscanf(/*XF86FILE*,const char*,char *,char *,char *,char *,
+ char *,char *,char *,char *,char *,char * */);
+#endif
+extern int xf86fseek(XF86FILE*,long,int);
+extern int xf86fsetpos(XF86FILE*,const XF86fpos_t*);
+extern long xf86ftell(XF86FILE*);
+extern xf86size_t xf86fwrite(const void*,xf86size_t,xf86size_t,XF86FILE*);
+extern char* xf86getenv(const char*);
+extern int xf86isalnum(int);
+extern int xf86isalpha(int);
+extern int xf86iscntrl(int);
+extern int xf86isdigit(int);
+extern int xf86isgraph(int);
+extern int xf86islower(int);
+extern int xf86isprint(int);
+extern int xf86ispunct(int);
+extern int xf86isspace(int);
+extern int xf86isupper(int);
+extern int xf86isxdigit(int);
+extern long xf86labs(long);
+extern double xf86ldexp(double,int);
+extern double xf86log(double);
+extern double xf86log10(double);
+extern void* xf86malloc(xf86size_t);
+extern void* xf86memchr(const void*,int,xf86size_t);
+extern int xf86memcmp(const void*,const void*,xf86size_t);
+extern void* xf86memcpy(void*,const void*,xf86size_t);
+extern void* xf86memmove(void*,const void*,xf86size_t);
+extern void* xf86memset(void*,int,xf86size_t);
+extern double xf86modf(double,double*);
+extern void xf86perror(const char*);
+extern double xf86pow(double,double);
+extern void xf86qsort(void*, xf86size_t, xf86size_t,
+ int(*)(const void*, const void*));
+extern void* xf86realloc(void*,xf86size_t);
+extern int xf86remove(const char*);
+extern int xf86rename(const char*,const char*);
+extern void xf86rewind(XF86FILE*);
+extern int xf86setbuf(XF86FILE*,char*);
+extern int xf86setvbuf(XF86FILE*,char*,int,xf86size_t);
+extern double xf86sin(double);
+extern int xf86sprintf(char*,const char*,...);
+extern int xf86snprintf(char*,xf86size_t,const char*,...);
+extern double xf86sqrt(double);
+#if defined(HAVE_VSSCANF) || !defined(NEED_XF86_PROTOTYPES)
+extern int xf86sscanf(char*,const char*,...);
+#else
+extern int xf86sscanf(/*char*,const char*,char *,char *,char *,char *,
+ char *,char *,char *,char *,char *,char * */);
+#endif
+extern char* xf86strcat(char*,const char*);
+extern char* xf86strchr(const char*, int c);
+extern int xf86strcmp(const char*,const char*);
+extern int xf86strcasecmp(const char*,const char*);
+extern char* xf86strcpy(char*,const char*);
+extern xf86size_t xf86strcspn(const char*,const char*);
+extern char* xf86strerror(int);
+extern xf86size_t xf86strlcat(char*,const char*,xf86size_t);
+extern xf86size_t xf86strlcpy(char*,const char*,xf86size_t);
+extern xf86size_t xf86strlen(const char*);
+extern char* xf86strncat(char *, const char *, xf86size_t);
+extern int xf86strncmp(const char*,const char*,xf86size_t);
+extern int xf86strncasecmp(const char*,const char*,xf86size_t);
+extern char* xf86strncpy(char*,const char*,xf86size_t);
+extern char* xf86strpbrk(const char*,const char*);
+extern char* xf86strrchr(const char*,int);
+extern xf86size_t xf86strspn(const char*,const char*);
+extern char* xf86strstr(const char*,const char*);
+extern double xf86strtod(const char*,char**);
+extern char* xf86strtok(char*,const char*);
+extern long xf86strtol(const char*,char**,int);
+extern unsigned long xf86strtoul(const char*,char**,int);
+extern double xf86tan(double);
+extern XF86FILE* xf86tmpfile(void);
+extern char* xf86tmpnam(char*);
+extern int xf86tolower(int);
+extern int xf86toupper(int);
+extern int xf86ungetc(int,XF86FILE*);
+extern int xf86vfprintf(XF86FILE*,const char*,va_list);
+extern int xf86vsprintf(char*,const char*,va_list);
+extern int xf86vsnprintf(char*,xf86size_t,const char*,va_list);
+
+extern int xf86open(const char*, int,...);
+extern int xf86close(int);
+extern long xf86lseek(int, long, int);
+extern int xf86ioctl(int, unsigned long, pointer);
+extern xf86ssize_t xf86read(int, void *, xf86size_t);
+extern xf86ssize_t xf86write(int, const void *, xf86size_t);
+extern void* xf86mmap(void*, xf86size_t, int, int, int, xf86size_t /* off_t */);
+extern int xf86munmap(void*, xf86size_t);
+extern int xf86stat(const char *, struct xf86stat *);
+extern int xf86fstat(int, struct xf86stat *);
+extern int xf86access(const char *, int);
+extern int xf86errno;
+extern int xf86GetErrno(void);
+
+extern double xf86HUGE_VAL;
+
+extern double xf86hypot(double,double);
+
+/* non-ANSI C functions */
+extern XF86DIR* xf86opendir(const char*);
+extern int xf86closedir(XF86DIR*);
+extern XF86DIRENT* xf86readdir(XF86DIR*);
+extern void xf86rewinddir(XF86DIR*);
+extern void xf86bcopy(const void*,void*,xf86size_t);
+extern int xf86ffs(int);
+extern char* xf86strdup(const char*);
+extern void xf86bzero(void*,unsigned int);
+extern int xf86execl(const char *, const char *, ...);
+extern long xf86fpossize(void);
+extern int xf86chmod(const char *, xf86mode_t);
+extern int xf86chown(const char *, xf86uid_t, xf86gid_t);
+extern xf86uid_t xf86geteuid(void);
+extern xf86gid_t xf86getegid(void);
+extern int xf86getpid(void);
+extern int xf86mknod(const char *, xf86mode_t, xf86dev_t);
+extern int xf86mkdir(const char *, xf86mode_t);
+unsigned int xf86sleep(unsigned int seconds);
+/* sysv IPC */
+extern int xf86shmget(xf86key_t key, int size, int xf86shmflg);
+extern char * xf86shmat(int id, char *addr, int xf86shmflg);
+extern int xf86shmdt(char *addr);
+extern int xf86shmctl(int id, int xf86cmd, pointer buf);
+
+extern int xf86setjmp(xf86jmp_buf env);
+extern int xf86setjmp0(xf86jmp_buf env);
+extern int xf86setjmp1(xf86jmp_buf env, int);
+extern int xf86setjmp1_arg2(void);
+extern int xf86setjmperror(xf86jmp_buf env);
+extern int xf86getjmptype(void);
+extern void xf86longjmp(xf86jmp_buf env, int val);
+#define xf86setjmp_macro(env) \
+ (xf86getjmptype() == 0 ? xf86setjmp0((env)) : \
+ (xf86getjmptype() == 1 ? xf86setjmp1((env), xf86setjmp1_arg2()) : \
+ xf86setjmperror((env))))
+
+#else /* XFree86LOADER || NEED_XF86_PROTOTYPES */
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <ctype.h>
+#ifdef HAVE_SYSV_IPC
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#endif
+#include <sys/stat.h>
+#define stat_t struct stat
+#endif /* XFree86LOADER || NEED_XF86_PROTOTYPES */
+
+/*
+ * These things are always required by drivers (but not by libc_wrapper.c),
+ * even for a static server because some OSs don't provide them.
+ */
+
+extern int xf86getpagesize(void);
+extern void xf86usleep(unsigned long);
+extern void xf86getsecs(long *, long *);
+#ifndef DONT_DEFINE_WRAPPERS
+#undef getpagesize
+#define getpagesize() xf86getpagesize()
+#undef usleep
+#define usleep(ul) xf86usleep(ul)
+#undef getsecs
+#define getsecs(a, b) xf86getsecs(a, b)
+#endif
+#endif /* _XF86_ANSIC_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_libc.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_libc.h
new file mode 100644
index 000000000..c51e0ee14
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_libc.h
@@ -0,0 +1,726 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h,v 1.9 2005/08/24 11:18:31 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h,v 3.63 2003/12/08 21:46:55 alanh Exp $ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file is an attempt to make developing code for the new loadable module
+ * architecure simpler. It tries to use macros to hide all libc wrappers so
+ * that all that is needed to "port" a module to this architecture is to
+ * include this one header file
+ *
+ * Revision history:
+ *
+ *
+ * 0.4 Apr 12 1997 add the ANSI defines
+ * 0.3 Feb 24 1997 handle getenv
+ * 0.2 Feb 24 1997 hide few FILE functions
+ * 0.1 Feb 24 1997 hide the trivial functions mem* str*
+ */
+
+#ifndef XF86_LIBC_H
+#define XF86_LIBC_H 1
+
+#include <X11/Xfuncs.h>
+#include <stddef.h>
+
+/*
+ * The first set of definitions are required both for modules and
+ * libc_wrapper.c.
+ */
+
+#if defined(XFree86LOADER) || defined(NEED_XF86_TYPES)
+
+/*
+ * First, the new data types
+ *
+ * note: if some pointer is declared "opaque" here, pass it between
+ * xf86* functions only, and don't rely on it having a whatever internal
+ * structure, even if some source file might reveal the existence of
+ * such a structure.
+ */
+typedef void XF86FILE; /* opaque FILE replacement */
+extern XF86FILE* xf86stdin;
+extern XF86FILE* xf86stdout;
+extern XF86FILE* xf86stderr;
+
+typedef void XF86fpos_t; /* opaque fpos_t replacement */
+
+#define _XF86NAMELEN 263 /* enough for a larger filename */
+ /* (divisble by 8) */
+typedef void XF86DIR; /* opaque DIR replacement */
+
+/* Note: the following is POSIX! POSIX only requires the d_name member.
+ * Normal Unix has often a number of other members, but don't rely on that
+ */
+struct _xf86dirent { /* types in struct dirent/direct: */
+ char d_name[_XF86NAMELEN+1]; /* char [MAXNAMLEN]; might be smaller or unaligned */
+};
+typedef struct _xf86dirent XF86DIRENT;
+
+typedef unsigned long xf86size_t;
+typedef signed long xf86ssize_t;
+typedef unsigned long xf86dev_t;
+typedef unsigned int xf86mode_t;
+typedef unsigned int xf86uid_t;
+typedef unsigned int xf86gid_t;
+
+struct xf86stat {
+ xf86dev_t st_rdev; /* This is incomplete, and makes assumptions */
+};
+
+/* sysv IPC */
+typedef int xf86key_t;
+
+/* setjmp/longjmp */
+#if defined(__ia64__)
+typedef int xf86jmp_buf[1024] __attribute__ ((aligned (16))); /* guarantees 128-bit alignment! */
+#else
+typedef int xf86jmp_buf[1024];
+#endif
+
+/* for setvbuf */
+#define XF86_IONBF 1
+#define XF86_IOFBF 2
+#define XF86_IOLBF 3
+
+/* for open (XXX not complete) */
+#define XF86_O_RDONLY 0x0000
+#define XF86_O_WRONLY 0x0001
+#define XF86_O_RDWR 0x0002
+#define XF86_O_CREAT 0x0200
+
+/* for mmap */
+#define XF86_PROT_EXEC 0x0001
+#define XF86_PROT_READ 0x0002
+#define XF86_PROT_WRITE 0x0004
+#define XF86_PROT_NONE 0x0008
+#define XF86_MAP_FIXED 0x0001
+#define XF86_MAP_SHARED 0x0002
+#define XF86_MAP_PRIVATE 0x0004
+#define XF86_MAP_32BIT 0x0040
+#define XF86_MAP_FAILED ((void *)-1)
+
+/* for fseek */
+#define XF86_SEEK_SET 0
+#define XF86_SEEK_CUR 1
+#define XF86_SEEK_END 2
+
+/* for access */
+#define XF86_R_OK 0
+#define XF86_W_OK 1
+#define XF86_X_OK 2
+#define XF86_F_OK 3
+
+/* for chmod */
+#define XF86_S_ISUID 04000 /* set user ID on execution */
+#define XF86_S_ISGID 02000 /* set group ID on execution */
+#define XF86_S_ISVTX 01000 /* sticky bit */
+#define XF86_S_IRUSR 00400 /* read by owner */
+#define XF86_S_IWUSR 00200 /* write by owner */
+#define XF86_S_IXUSR 00100 /* execute/search by owner */
+#define XF86_S_IRGRP 00040 /* read by group */
+#define XF86_S_IWGRP 00020 /* write by group */
+#define XF86_S_IXGRP 00010 /* execute/search by group */
+#define XF86_S_IROTH 00004 /* read by others */
+#define XF86_S_IWOTH 00002 /* write by others */
+#define XF86_S_IXOTH 00001 /* execute/search by others */
+
+/* for mknod */
+#define XF86_S_IFREG 0010000
+#define XF86_S_IFCHR 0020000
+#define XF86_S_IFBLK 0040000
+#define XF86_S_IFIFO 0100000
+
+/*
+ * errno values
+ * They start at 1000 just so they don't match real errnos at all
+ */
+#define xf86_UNKNOWN 1000
+#define xf86_EACCES 1001
+#define xf86_EAGAIN 1002
+#define xf86_EBADF 1003
+#define xf86_EEXIST 1004
+#define xf86_EFAULT 1005
+#define xf86_EINTR 1006
+#define xf86_EINVAL 1007
+#define xf86_EISDIR 1008
+#define xf86_ELOOP 1009
+#define xf86_EMFILE 1010
+#define xf86_ENAMETOOLONG 1011
+#define xf86_ENFILE 1012
+#define xf86_ENOENT 1013
+#define xf86_ENOMEM 1014
+#define xf86_ENOSPC 1015
+#define xf86_ENOTDIR 1016
+#define xf86_EPIPE 1017
+#define xf86_EROFS 1018
+#define xf86_ETXTBSY 1019
+#define xf86_ENOTTY 1020
+#define xf86_ENOSYS 1021
+#define xf86_EBUSY 1022
+#define xf86_ENODEV 1023
+#define xf86_EIO 1024
+
+#define xf86_ESRCH 1025
+#define xf86_ENXIO 1026
+#define xf86_E2BIG 1027
+#define xf86_ENOEXEC 1028
+#define xf86_ECHILD 1029
+#define xf86_ENOTBLK 1030
+#define xf86_EXDEV 1031
+#define xf86_EFBIG 1032
+#define xf86_ESPIPE 1033
+#define xf86_EMLINK 1034
+#define xf86_EDOM 1035
+#define xf86_ERANGE 1036
+
+
+/* sysv IPV */
+/* xf86shmget() */
+#define XF86IPC_CREAT 01000
+#define XF86IPC_EXCL 02000
+#define XF86IPC_NOWAIT 04000
+#define XF86SHM_R 0400
+#define XF86SHM_W 0200
+#define XF86IPC_PRIVATE ((xf86key_t)0)
+/* xf86shmat() */
+#define XF86SHM_RDONLY 010000 /* attach read-only else read-write */
+#define XF86SHM_RND 020000 /* round attach address to SHMLBA */
+#define XF86SHM_REMAP 040000 /* take-over region on attach */
+/* xf86shmclt() */
+#define XF86IPC_RMID 0
+
+#endif /* defined(XFree86LOADER) || defined(NEED_XF86_TYPES) */
+
+/*
+ * the rest of this file should only be included for code that is supposed
+ * to go into modules
+ */
+
+#if defined(XFree86LOADER) && !defined(DONT_DEFINE_WRAPPERS)
+
+#undef abort
+#define abort() xf86abort()
+#undef abs
+#define abs(i) xf86abs(i)
+#undef acos
+#define acos(d) xf86acos(d)
+#undef asin
+#define asin(d) xf86asin(d)
+#undef atan
+#define atan(d) xf86atan(d)
+#undef atan2
+#define atan2(d1,d2) xf86atan2(d1,d2)
+#undef atof
+#define atof(ccp) xf86atof(ccp)
+#undef atoi
+#define atoi(ccp) xf86atoi(ccp)
+#undef atol
+#define atol(ccp) xf86atol(ccp)
+#undef bsearch
+#define bsearch(a,b,c,d,e) xf86bsearch(a,b,c,d,e)
+#undef ceil
+#define ceil(d) xf86ceil(d)
+#undef calloc
+#define calloc(I1,I2) xf86calloc(I1,I2)
+#undef clearerr
+#define clearerr(FP) xf86clearerr(FP)
+#undef cos
+#define cos(d) xf86cos(d)
+#undef exit
+#define exit(i) xf86exit(i)
+#undef exp
+#define exp(d) xf86exp(d)
+#undef fabs
+#define fabs(d) xf86fabs(d)
+#undef fclose
+#define fclose(FP) xf86fclose(FP)
+#undef feof
+#define feof(FP) xf86feof(FP)
+#undef ferror
+#define ferror(FP) xf86ferror(FP)
+#undef fflush
+#define fflush(FP) xf86fflush(FP)
+#undef fgetc
+#define fgetc(FP) xf86fgetc(FP)
+#undef getc
+#define getc(FP) xf86getc(FP)
+#undef fgetpos
+#define fgetpos(FP,fpp) xf86fgetpos(FP,fpp)
+#undef fgets
+#define fgets(cp,i,FP) xf86fgets(cp,i,FP)
+#undef finite
+#define finite(d) xf86finite(d)
+#undef floor
+#define floor(d) xf86floor(d)
+#undef fmod
+#define fmod(d1,d2) xf86fmod(d1,d2)
+#undef fopen
+#define fopen(ccp1,ccp2) xf86fopen(ccp1,ccp2)
+#undef printf
+#define printf xf86printf
+#undef fprintf
+#define fprintf xf86fprintf
+#undef fputc
+#define fputc(i,FP) xf86fputc(i,FP)
+#undef fputs
+#define fputs(ccp,FP) xf86fputs(ccp,FP)
+#undef fread
+#define fread(vp,I1,I2,FP) xf86fread(vp,I1,I2,FP)
+#undef free
+#define free(vp) xf86free(vp)
+#undef freopen
+#define freopen(ccp1,ccp2,FP) xf86freopen(ccp1,ccp2,FP)
+#undef frexp
+#define frexp(x,exp) xf86frexp(x,exp)
+#undef fscanf
+#define fscanf xf86fscanf
+#undef fseek
+#define fseek(FP,l,i) xf86fseek(FP,l,i)
+#undef fsetpos
+#define fsetpos(FP,cfpp) xf86fsetpos(FP,cfpp)
+#undef ftell
+#define ftell(FP) xf86ftell(FP)
+#undef fwrite
+#define fwrite(cvp,I1,I2,FP) xf86fwrite(cvp,I1,I2,FP)
+#undef getenv
+#define getenv(ccp) xf86getenv(ccp)
+#undef isalnum
+#define isalnum(i) xf86isalnum(i)
+#undef isalpha
+#define isalpha(i) xf86isalpha(i)
+#undef iscntrl
+#define iscntrl(i) xf86iscntrl(i)
+#undef isdigit
+#define isdigit(i) xf86isdigit(i)
+#undef isgraph
+#define isgraph(i) xf86isgraph(i)
+#undef islower
+#define islower(i) xf86islower(i)
+#undef isprint
+#define isprint(i) xf86isprint(i)
+#undef ispunct
+#define ispunct(i) xf86ispunct(i)
+#undef isspace
+#define isspace(i) xf86isspace(i)
+#undef isupper
+#define isupper(i) xf86isupper(i)
+#undef isxdigit
+#define isxdigit(i) xf86isxdigit(i)
+#undef labs
+#define labs(l) xf86labs(l)
+#undef ldexp
+#define ldexp(x, exp) xf86ldexp(x, exp)
+#undef log
+#define log(d) xf86log(d)
+#undef log10
+#define log10(d) xf86log10(d)
+#undef malloc
+#define malloc(I) xf86malloc(I)
+#undef memchr
+#define memchr(cvp,i,I) xf86memchr(cvp,i,I)
+#undef memcmp
+#define memcmp(cvp1,cvp2,I) xf86memcmp(cvp1,cvp2,I)
+#undef memcpy
+#define memcpy(vp,cvp,I) xf86memcpy(vp,cvp,I)
+#undef memmove
+#define memmove(vp,cvp,I) xf86memmove(vp,cvp,I)
+#undef memset
+#define memset(vp,int,I) xf86memset(vp,int,I)
+#undef modf
+#define modf(d,dp) xf86modf(d,dp)
+#undef perror
+#define perror(ccp) xf86perror(ccp)
+#undef pow
+#define pow(d1,d2) xf86pow(d1,d2)
+#undef realloc
+#define realloc(vp,I) xf86realloc(vp,I)
+#undef remove
+#define remove(ccp) xf86remove(ccp)
+#undef rename
+#define rename(ccp1,ccp2) xf86rename(ccp1,ccp2)
+#undef rewind
+#define rewind(FP) xf86rewind(FP)
+#undef setbuf
+#define setbuf(FP,cp) xf86setbuf(FP,cp)
+#undef setvbuf
+#define setvbuf(FP,cp,i,I) xf86setvbuf(FP,cp,i,I)
+#undef sin
+#define sin(d) xf86sin(d)
+#undef snprintf
+#define snprintf xf86snprintf
+#undef sprintf
+#define sprintf xf86sprintf
+#undef sqrt
+#define sqrt(d) xf86sqrt(d)
+#undef sscanf
+#define sscanf xf86sscanf
+#undef strcat
+#define strcat(cp,ccp) xf86strcat(cp,ccp)
+#undef strcmp
+#define strcmp(ccp1,ccp2) xf86strcmp(ccp1,ccp2)
+#undef strcasecmp
+#define strcasecmp(ccp1,ccp2) xf86strcasecmp(ccp1,ccp2)
+#undef strcpy
+#define strcpy(cp,ccp) xf86strcpy(cp,ccp)
+#undef strcspn
+#define strcspn(ccp1,ccp2) xf86strcspn(ccp1,ccp2)
+#undef strerror
+#define strerror(i) xf86strerror(i)
+#undef strlcat
+#define strlcat(cp,ccp,I) xf86strlcat(cp,ccp,I)
+#undef strlcpy
+#define strlcpy(cp,ccp,I) xf86strlcpy(cp,ccp,I)
+#undef strlen
+#define strlen(ccp) xf86strlen(ccp)
+#undef strncmp
+#define strncmp(ccp1,ccp2,I) xf86strncmp(ccp1,ccp2,I)
+#undef strncasecmp
+#define strncasecmp(ccp1,ccp2,I) xf86strncasecmp(ccp1,ccp2,I)
+#undef strncpy
+#define strncpy(cp,ccp,I) xf86strncpy(cp,ccp,I)
+#undef strpbrk
+#define strpbrk(ccp1,ccp2) xf86strpbrk(ccp1,ccp2)
+#undef strchr
+#define strchr(ccp,i) xf86strchr(ccp,i)
+#undef strrchr
+#define strrchr(ccp,i) xf86strrchr(ccp,i)
+#undef strspn
+#define strspn(ccp1,ccp2) xf86strspn(ccp1,ccp2)
+#undef strstr
+#define strstr(ccp1,ccp2) xf86strstr(ccp1,ccp2)
+#undef srttod
+#define strtod(ccp,cpp) xf86strtod(ccp,cpp)
+#undef strtok
+#define strtok(cp,ccp) xf86strtok(cp,ccp)
+#undef strtol
+#define strtol(ccp,cpp,i) xf86strtol(ccp,cpp,i)
+#undef strtoul
+#define strtoul(ccp,cpp,i) xf86strtoul(ccp,cpp,i)
+#undef tan
+#define tan(d) xf86tan(d)
+#undef tmpfile
+#define tmpfile() xf86tmpfile()
+#undef tolower
+#define tolower(i) xf86tolower(i)
+#undef toupper
+#define toupper(i) xf86toupper(i)
+#undef ungetc
+#define ungetc(i,FP) xf86ungetc(i,FP)
+#undef vfprinf
+#define vfprintf(p,f,a) xf86vfprintf(p,f,a)
+#undef vsnprintf
+#define vsnprintf(s,n,f,a) xf86vsnprintf(s,n,f,a)
+#undef vsprintf
+#define vsprintf(s,f,a) xf86vsprintf(s,f,a)
+/* XXX Disable assert as if NDEBUG was defined */
+/* Some X headers defined this away too */
+#undef assert
+#define assert(a) ((void)0)
+#undef HUGE_VAL
+#define HUGE_VAL xf86HUGE_VAL
+
+#undef hypot
+#define hypot(x,y) xf86hypot(x,y)
+
+#undef qsort
+#define qsort(b, n, s, f) xf86qsort(b, n, s, f)
+
+/* non-ANSI C functions */
+#undef opendir
+#define opendir(cp) xf86opendir(cp)
+#undef closedir
+#define closedir(DP) xf86closedir(DP)
+#undef readdir
+#define readdir(DP) xf86readdir(DP)
+#undef rewinddir
+#define rewinddir(DP) xf86rewinddir(DP)
+#undef bcopy
+#define bcopy(vp,cvp,I) xf86memmove(cvp,vp,I)
+#undef ffs
+#define ffs(i) xf86ffs(i)
+#undef strdup
+#define strdup(ccp) xf86strdup(ccp)
+#undef bzero
+#define bzero(vp,ui) xf86bzero(vp,ui)
+#undef execl
+#define execl xf86execl
+#undef chmod
+#define chmod(a,b) xf86chmod(a,b)
+#undef chown
+#define chown(a,b,c) xf86chown(a,b,c)
+#undef geteuid
+#define geteuid xf86geteuid
+#undef getegid
+#define getegid xf86getegid
+#undef getpid
+#define getpid xf86getpid
+#undef mknod
+#define mknod(a,b,c) xf86mknod(a,b,c)
+#undef sleep
+#define sleep(a) xf86sleep(a)
+#undef mkdir
+#define mkdir(a,b) xf86mkdir(a,b)
+#undef getpagesize
+#define getpagesize xf86getpagesize
+#undef shmget
+#define shmget(a,b,c) xf86shmget(a,b,c)
+#undef shmat
+#define shmat(a,b,c) xf86shmat(a,b,c)
+#undef shmdt
+#define shmdt(a) xf86shmdt(a)
+#undef shmctl
+#define shmctl(a,b,c) xf86shmctl(a,b,c)
+
+#undef S_ISUID
+#define S_ISUID XF86_S_ISUID
+#undef S_ISGID
+#define S_ISGID XF86_S_ISGID
+#undef S_ISVTX
+#define S_ISVTX XF86_S_ISVTX
+#undef S_IRUSR
+#define S_IRUSR XF86_S_IRUSR
+#undef S_IWUSR
+#define S_IWUSR XF86_S_IWUSR
+#undef S_IXUSR
+#define S_IXUSR XF86_S_IXUSR
+#undef S_IRGRP
+#define S_IRGRP XF86_S_IRGRP
+#undef S_IWGRP
+#define S_IWGRP XF86_S_IWGRP
+#undef S_IXGRP
+#define S_IXGRP XF86_S_IXGRP
+#undef S_IROTH
+#define S_IROTH XF86_S_IROTH
+#undef S_IWOTH
+#define S_IWOTH XF86_S_IWOTH
+#undef S_IXOTH
+#define S_IXOTH XF86_S_IXOTH
+#undef S_IFREG
+#define S_IFREG XF86_S_IFREG
+#undef S_IFCHR
+#define S_IFCHR XF86_S_IFCHR
+#undef S_IFBLK
+#define S_IFBLK XF86_S_IFBLK
+#undef S_IFIFO
+#define S_IFIFO XF86_S_IFIFO
+
+/* some types */
+#undef FILE
+#define FILE XF86FILE
+#undef fpos_t
+#define fpos_t XF86fpos_t
+#undef DIR
+#define DIR XF86DIR
+#undef DIRENT
+#define DIRENT XF86DIRENT
+#undef size_t
+#define size_t xf86size_t
+#undef ssize_t
+#define ssize_t xf86ssize_t
+#undef dev_t
+#define dev_t xf86dev_t
+#undef mode_t
+#define mode_t xf86mode_t
+#undef uid_t
+#define uid_t xf86uid_t
+#undef gid_t
+#define gid_t xf86gid_t
+#undef stat_t
+#define stat_t struct xf86stat
+
+#undef ulong
+#define ulong unsigned long
+
+/*
+ * There should be no need to #undef any of these. If they are already
+ * defined it is because some illegal header has been included.
+ */
+
+/* some vars */
+#undef stdin
+#define stdin xf86stdin
+#undef stdout
+#define stdout xf86stdout
+#undef stderr
+#define stderr xf86stderr
+
+#undef SEEK_SET
+#define SEEK_SET XF86_SEEK_SET
+#undef SEEK_CUR
+#define SEEK_CUR XF86_SEEK_CUR
+#undef SEEK_END
+#define SEEK_END XF86_SEEK_END
+
+/*
+ * XXX Basic I/O functions BAD,BAD,BAD!
+ */
+#define open xf86open
+#define close(a) xf86close(a)
+#define lseek(a,b,c) xf86lseek(a,b,c)
+#if !defined(__DragonFly__)
+#define ioctl(a,b,c) xf86ioctl(a,b,c)
+#endif
+#define read(a,b,c) xf86read(a,b,c)
+#define write(a,b,c) xf86write(a,b,c)
+#define mmap(a,b,c,d,e,f) xf86mmap(a,b,c,d,e,f)
+#define munmap(a,b) xf86munmap(a,b)
+#define stat(a,b) xf86stat(a,b)
+#define fstat(a,b) xf86fstat(a,b)
+#define access(a,b) xf86access(a,b)
+#undef O_RDONLY
+#define O_RDONLY XF86_O_RDONLY
+#undef O_WRONLY
+#define O_WRONLY XF86_O_WRONLY
+#undef O_RDWR
+#define O_RDWR XF86_O_RDWR
+#undef O_CREAT
+#define O_CREAT XF86_O_CREAT
+#undef PROT_EXEC
+#define PROT_EXEC XF86_PROT_EXEC
+#undef PROT_READ
+#define PROT_READ XF86_PROT_READ
+#undef PROT_WRITE
+#define PROT_WRITE XF86_PROT_WRITE
+#undef PROT_NONE
+#define PROT_NONE XF86_PROT_NONE
+#undef MAP_FIXED
+#define MAP_FIXED XF86_MAP_FIXED
+#undef MAP_SHARED
+#define MAP_SHARED XF86_MAP_SHARED
+#undef MAP_PRIVATE
+#define MAP_PRIVATE XF86_MAP_PRIVATE
+#undef MAP_FAILED
+#define MAP_FAILED XF86_MAP_FAILED
+#undef R_OK
+#define R_OK XF86_R_OK
+#undef W_OK
+#define W_OK XF86_W_OK
+#undef X_OK
+#define X_OK XF86_X_OK
+#undef F_OK
+#define F_OK XF86_F_OK
+#undef errno
+#define errno xf86errno
+#undef putchar
+#define putchar(i) xf86fputc(i, xf86stdout)
+#undef puts
+#define puts(s) xf86fputs(s, xf86stdout)
+
+#undef EACCES
+#define EACCES xf86_EACCES
+#undef EAGAIN
+#define EAGAIN xf86_EAGAIN
+#undef EBADF
+#define EBADF xf86_EBADF
+#undef EEXIST
+#define EEXIST xf86_EEXIST
+#undef EFAULT
+#define EFAULT xf86_EFAULT
+#undef EINTR
+#define EINTR xf86_EINTR
+#undef EINVAL
+#define EINVAL xf86_EINVAL
+#undef EISDIR
+#define EISDIR xf86_EISDIR
+#undef ELOOP
+#define ELOOP xf86_ELOOP
+#undef EMFILE
+#define EMFILE xf86_EMFILE
+#undef ENAMETOOLONG
+#define ENAMETOOLONG xf86_ENAMETOOLONG
+#undef ENFILE
+#define ENFILE xf86_ENFILE
+#undef ENOENT
+#define ENOENT xf86_ENOENT
+#undef ENOMEM
+#define ENOMEM xf86_ENOMEM
+#undef ENOSPC
+#define ENOSPC xf86_ENOSPC
+#undef ENOTDIR
+#define ENOTDIR xf86_ENOTDIR
+#undef EPIPE
+#define EPIPE xf86_EPIPE
+#undef EROFS
+#define EROFS xf86_EROFS
+#undef ETXTBSY
+#define ETXTBSY xf86_ETXTBSY
+#undef ENOTTY
+#define ENOTTY xf86_ENOTTY
+#undef ENOSYS
+#define ENOSYS xf86_ENOSYS
+#undef EBUSY
+#define EBUSY xf86_EBUSY
+#undef ENODEV
+#define ENODEV xf86_ENODEV
+#undef EIO
+#define EIO xf86_EIO
+
+/* IPC stuff */
+#undef SHM_RDONLY
+#define SHM_RDONLY XF86SHM_RDONLY
+#undef SHM_RND
+#define SHM_RND XF86SHM_RND
+#undef SHM_REMAP
+#define SHM_REMAP XF86SHM_REMAP
+#undef IPC_RMID
+#define IPC_RMID XF86IPC_RMID
+#undef IPC_CREAT
+#define IPC_CREAT XF86IPC_CREAT
+#undef IPC_EXCL
+#define IPC_EXCL XF86IPC_EXCL
+#undef PC_NOWAIT
+#define IPC_NOWAIT XF86IPC_NOWAIT
+#undef SHM_R
+#define SHM_R XF86SHM_R
+#undef SHM_W
+#define SHM_W XF86SHM_W
+#undef IPC_PRIVATE
+#define IPC_PRIVATE XF86IPC_PRIVATE
+
+/* Some ANSI macros */
+#undef FILENAME_MAX
+#define FILENAME_MAX 1024
+
+#if (defined(sun) && defined(__SVR4))
+# define _FILEDEFED /* Already have FILE defined, don't redefine it */
+#endif
+
+#endif /* XFree86LOADER && !DONT_DEFINE_WRAPPERS */
+
+#if defined(XFree86LOADER) && \
+ (!defined(DONT_DEFINE_WRAPPERS) || defined(DEFINE_SETJMP_WRAPPERS))
+#undef setjmp
+#define setjmp(a) xf86setjmp_macro(a)
+#undef longjmp
+#define longjmp(a,b) xf86longjmp(a,b)
+#undef jmp_buf
+#define jmp_buf xf86jmp_buf
+#endif
+
+#endif /* XF86_LIBC_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Configint.h b/nx-X11/programs/Xserver/hw/xfree86/parser/Configint.h
new file mode 100644
index 000000000..a51116b55
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Configint.h
@@ -0,0 +1,226 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Configint.h,v 1.21 2003/08/24 17:37:07 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2002 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/*
+ * These definitions are used through out the configuration file parser, but
+ * they should not be visible outside of the parser.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _Configint_h_
+#define _Configint_h_
+
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include "xf86Parser.h"
+
+typedef struct
+{
+ int num; /* returned number */
+ char *str; /* private copy of the return-string */
+ double realnum; /* returned number as a real */
+}
+LexRec, *LexPtr;
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#include "configProcs.h"
+#include <stdlib.h>
+#define xf86confmalloc malloc
+#define xf86confrealloc realloc
+#define xf86confcalloc calloc
+#define xf86conffree free
+
+#define TestFree(a) if (a) { xf86conffree (a); a = NULL; }
+
+#define parsePrologue(typeptr,typerec) typeptr ptr; \
+if( (ptr=(typeptr)xf86confcalloc(1,sizeof(typerec))) == NULL ) { return NULL; } \
+memset(ptr,0,sizeof(typerec));
+
+#define parsePrologueVoid(typeptr,typerec) int token; typeptr ptr; \
+if( (ptr=(typeptr)xf86confcalloc(1,sizeof(typerec))) == NULL ) { return; } \
+memset(ptr,0,sizeof(typerec));
+
+#define HANDLE_RETURN(f,func)\
+if ((ptr->f=func) == NULL)\
+{\
+ CLEANUP (ptr);\
+ return (NULL);\
+}
+
+#define HANDLE_LIST(field,func,type)\
+{\
+type p = func ();\
+if (p == NULL)\
+{\
+ CLEANUP (ptr);\
+ return (NULL);\
+}\
+else\
+{\
+ ptr->field = (type) xf86addListItem ((glp) ptr->field, (glp) p);\
+}\
+}
+
+#define Error(a,b) do { \
+ xf86parseError (a, b); CLEANUP (ptr); return NULL; \
+ } while (0)
+
+/*
+ * These are defines for error messages to promote consistency.
+ * error messages are preceded by the line number, section and file name,
+ * so these messages should be about the specific keyword and syntax in error.
+ * To help limit namespace polution, end each with _MSG.
+ * limit messages to 70 characters if possible.
+ */
+
+#define BAD_OPTION_MSG \
+"The Option keyword requires 1 or 2 quoted strings to follow it."
+#define INVALID_KEYWORD_MSG \
+"\"%s\" is not a valid keyword in this section."
+#define INVALID_SECTION_MSG \
+"\"%s\" is not a valid section name."
+#define UNEXPECTED_EOF_MSG \
+"Unexpected EOF. Missing EndSection keyword?"
+#define QUOTE_MSG \
+"The %s keyword requires a quoted string to follow it."
+#define NUMBER_MSG \
+"The %s keyword requires a number to follow it."
+#define POSITIVE_INT_MSG \
+"The %s keyword requires a positive integer to follow it."
+#define ZAXISMAPPING_MSG \
+"The ZAxisMapping keyword requires 2 positive numbers or X or Y to follow it."
+#define AUTOREPEAT_MSG \
+"The AutoRepeat keyword requires 2 numbers (delay and rate) to follow it."
+#define XLEDS_MSG \
+"The XLeds keyword requries one or more numbers to follow it."
+#define DACSPEED_MSG \
+"The DacSpeed keyword must be followed by a list of up to %d numbers."
+#define DISPLAYSIZE_MSG \
+"The DisplaySize keyword must be followed by the width and height in mm."
+#define HORIZSYNC_MSG \
+"The HorizSync keyword must be followed by a list of numbers or ranges."
+#define VERTREFRESH_MSG \
+"The VertRefresh keyword must be followed by a list of numbers or ranges."
+#define VIEWPORT_MSG \
+"The Viewport keyword must be followed by an X and Y value."
+#define VIRTUAL_MSG \
+"The Virtual keyword must be followed by a width and height value."
+#define WEIGHT_MSG \
+"The Weight keyword must be followed by red, green and blue values."
+#define BLACK_MSG \
+"The Black keyword must be followed by red, green and blue values."
+#define WHITE_MSG \
+"The White keyword must be followed by red, green and blue values."
+#define SCREEN_MSG \
+"The Screen keyword must be followed by an optional number, a screen name\n" \
+"\tin quotes, and optional position/layout information."
+#define INVALID_SCR_MSG \
+"Invalid Screen line."
+#define INPUTDEV_MSG \
+"The InputDevice keyword must be followed by an input device name in quotes."
+#define INACTIVE_MSG \
+"The Inactive keyword must be followed by a Device name in quotes."
+#define UNDEFINED_SCREEN_MSG \
+"Undefined Screen \"%s\" referenced by ServerLayout \"%s\"."
+#define UNDEFINED_MONITOR_MSG \
+"Undefined Monitor \"%s\" referenced by Screen \"%s\"."
+#define UNDEFINED_MODES_MSG \
+"Undefined Modes Section \"%s\" referenced by Monitor \"%s\"."
+#define UNDEFINED_DEVICE_MSG \
+"Undefined Device \"%s\" referenced by Screen \"%s\"."
+#define UNDEFINED_ADAPTOR_MSG \
+"Undefined VideoAdaptor \"%s\" referenced by Screen \"%s\"."
+#define ADAPTOR_REF_TWICE_MSG \
+"VideoAdaptor \"%s\" already referenced by Screen \"%s\"."
+#define UNDEFINED_DEVICE_LAY_MSG \
+"Undefined Device \"%s\" referenced by ServerLayout \"%s\"."
+#define UNDEFINED_INPUT_MSG \
+"Undefined InputDevice \"%s\" referenced by ServerLayout \"%s\"."
+#define NO_IDENT_MSG \
+"This section must have an Identifier line."
+#define ONLY_ONE_MSG \
+"This section must have only one of either %s line."
+#define UNDEFINED_DRIVER_MSG \
+"Device section \"%s\" must have a Driver line."
+#define UNDEFINED_INPUTDRIVER_MSG \
+"InputDevice section \"%s\" must have a Driver line."
+#define INVALID_GAMMA_MSG \
+"gamma correction value(s) expected\n either one value or three r/g/b values."
+#define GROUP_MSG \
+"The Group keyword must be followed by either a group name in quotes or\n" \
+"\ta numerical group id."
+#define MULTIPLE_MSG \
+"Multiple \"%s\" lines."
+
+/* Warning messages */
+#define OBSOLETE_MSG \
+"Ignoring obsolete keyword \"%s\"."
+#define MOVED_TO_FLAGS_MSG \
+"Keyword \"%s\" is now an Option flag in the ServerFlags section."
+
+#endif /* _Configint_h_ */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/DRI.c b/nx-X11/programs/Xserver/hw/xfree86/parser/DRI.c
new file mode 100644
index 000000000..93d0d4b52
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/DRI.c
@@ -0,0 +1,187 @@
+/* DRI.c -- DRI Section in XF86Config file
+ * Created: Fri Mar 19 08:40:22 1999 by faith@precisioninsight.com
+ * Revised: Thu Jun 17 16:08:05 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/parser/DRI.c,v 1.13 2003/01/01 19:22:20 paulo Exp $
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec DRITab[] =
+{
+ {ENDSECTION, "endsection"},
+ {GROUP, "group"},
+ {BUFFERS, "buffers"},
+ {MODE, "mode"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeBuffersList
+
+XF86ConfBuffersPtr
+xf86parseBuffers (void)
+{
+ int token;
+ parsePrologue (XF86ConfBuffersPtr, XF86ConfBuffersRec)
+
+ if (xf86getSubToken (&(ptr->buf_comment)) != NUMBER)
+ Error ("Buffers count expected", NULL);
+ ptr->buf_count = val.num;
+
+ if (xf86getSubToken (&(ptr->buf_comment)) != NUMBER)
+ Error ("Buffers size expected", NULL);
+ ptr->buf_size = val.num;
+
+ if ((token = xf86getSubToken (&(ptr->buf_comment))) == STRING) {
+ ptr->buf_flags = val.str;
+ if ((token = xf86getToken (NULL)) == COMMENT)
+ ptr->buf_comment = xf86addComment(ptr->buf_comment, val.str);
+ else
+ xf86unGetToken(token);
+ }
+
+#ifdef DEBUG
+ printf ("Buffers parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+#define CLEANUP xf86freeDRI
+
+XF86ConfDRIPtr
+xf86parseDRISection (void)
+{
+ int token;
+ parsePrologue (XF86ConfDRIPtr, XF86ConfDRIRec);
+
+ /* Zero is a valid value for this. */
+ ptr->dri_group = -1;
+ while ((token = xf86getToken (DRITab)) != ENDSECTION) {
+ switch (token)
+ {
+ case GROUP:
+ if ((token = xf86getSubToken (&(ptr->dri_comment))) == STRING)
+ ptr->dri_group_name = val.str;
+ else if (token == NUMBER)
+ ptr->dri_group = val.num;
+ else
+ Error (GROUP_MSG, NULL);
+ break;
+ case MODE:
+ if (xf86getSubToken (&(ptr->dri_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Mode");
+ ptr->dri_mode = val.num;
+ break;
+ case BUFFERS:
+ HANDLE_LIST (dri_buffers_lst, xf86parseBuffers,
+ XF86ConfBuffersPtr);
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ case COMMENT:
+ ptr->dri_comment = xf86addComment(ptr->dri_comment, val.str);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ ErrorF("DRI section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printDRISection (FILE * cf, XF86ConfDRIPtr ptr)
+{
+ XF86ConfBuffersPtr bufs;
+
+ if (ptr == NULL)
+ return;
+
+ fprintf (cf, "Section \"DRI\"\n");
+ if (ptr->dri_comment)
+ fprintf (cf, "%s", ptr->dri_comment);
+ if (ptr->dri_group_name)
+ fprintf (cf, "\tGroup \"%s\"\n", ptr->dri_group_name);
+ else if (ptr->dri_group >= 0)
+ fprintf (cf, "\tGroup %d\n", ptr->dri_group);
+ if (ptr->dri_mode)
+ fprintf (cf, "\tMode 0%o\n", ptr->dri_mode);
+ for (bufs = ptr->dri_buffers_lst; bufs; bufs = bufs->list.next) {
+ fprintf (cf, "\tBuffers %d %d",
+ bufs->buf_count, bufs->buf_size);
+ if (bufs->buf_flags) fprintf (cf, " \"%s\"", bufs->buf_flags);
+ if (bufs->buf_comment)
+ fprintf(cf, "%s", bufs->buf_comment);
+ else
+ fprintf (cf, "\n");
+ }
+ fprintf (cf, "EndSection\n\n");
+}
+
+void
+xf86freeDRI (XF86ConfDRIPtr ptr)
+{
+ if (ptr == NULL)
+ return;
+
+ xf86freeBuffersList (ptr->dri_buffers_lst);
+ TestFree (ptr->dri_comment);
+ xf86conffree (ptr);
+}
+
+void
+xf86freeBuffersList (XF86ConfBuffersPtr ptr)
+{
+ XF86ConfBuffersPtr prev;
+
+ while (ptr) {
+ TestFree (ptr->buf_flags);
+ TestFree (ptr->buf_comment);
+ prev = ptr;
+ ptr = ptr->list.next;
+ xf86conffree (prev);
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Device.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Device.c
new file mode 100644
index 000000000..6eb2857f0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Device.c
@@ -0,0 +1,403 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Device.c,v 1.27 2003/08/24 17:37:07 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static
+xf86ConfigSymTabRec DeviceTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {VENDOR, "vendorname"},
+ {BOARD, "boardname"},
+ {CHIPSET, "chipset"},
+ {RAMDAC, "ramdac"},
+ {DACSPEED, "dacspeed"},
+ {CLOCKS, "clocks"},
+ {OPTION, "option"},
+ {VIDEORAM, "videoram"},
+ {BIOSBASE, "biosbase"},
+ {MEMBASE, "membase"},
+ {IOBASE, "iobase"},
+ {CLOCKCHIP, "clockchip"},
+ {CHIPID, "chipid"},
+ {CHIPREV, "chiprev"},
+ {CARD, "card"},
+ {DRIVER, "driver"},
+ {BUSID, "busid"},
+ {TEXTCLOCKFRQ, "textclockfreq"},
+ {IRQ, "irq"},
+ {SCREEN, "screen"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeDeviceList
+
+XF86ConfDevicePtr
+xf86parseDeviceSection (void)
+{
+ int i;
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
+
+ /* Zero is a valid value for these */
+ ptr->dev_chipid = -1;
+ ptr->dev_chiprev = -1;
+ ptr->dev_irq = -1;
+ while ((token = xf86getToken (DeviceTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->dev_comment = xf86addComment(ptr->dev_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->dev_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case VENDOR:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Vendor");
+ ptr->dev_vendor = val.str;
+ break;
+ case BOARD:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Board");
+ ptr->dev_board = val.str;
+ break;
+ case CHIPSET:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Chipset");
+ ptr->dev_chipset = val.str;
+ break;
+ case CARD:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Card");
+ ptr->dev_card = val.str;
+ break;
+ case DRIVER:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Driver");
+ ptr->dev_driver = val.str;
+ break;
+ case RAMDAC:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Ramdac");
+ ptr->dev_ramdac = val.str;
+ break;
+ case DACSPEED:
+ for (i = 0; i < CONF_MAXDACSPEEDS; i++)
+ ptr->dev_dacSpeeds[i] = 0;
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ {
+ Error (DACSPEED_MSG, CONF_MAXDACSPEEDS);
+ }
+ else
+ {
+ ptr->dev_dacSpeeds[0] = (int) (val.realnum * 1000.0 + 0.5);
+ for (i = 1; i < CONF_MAXDACSPEEDS; i++)
+ {
+ if (xf86getSubToken (&(ptr->dev_comment)) == NUMBER)
+ ptr->dev_dacSpeeds[i] = (int)
+ (val.realnum * 1000.0 + 0.5);
+ else
+ {
+ xf86unGetToken (token);
+ break;
+ }
+ }
+ }
+ break;
+ case VIDEORAM:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "VideoRam");
+ ptr->dev_videoram = val.num;
+ break;
+ case BIOSBASE:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "BIOSBase");
+ ptr->dev_bios_base = val.num;
+ break;
+ case MEMBASE:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "MemBase");
+ ptr->dev_mem_base = val.num;
+ break;
+ case IOBASE:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "IOBase");
+ ptr->dev_io_base = val.num;
+ break;
+ case CLOCKCHIP:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "ClockChip");
+ ptr->dev_clockchip = val.str;
+ break;
+ case CHIPID:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "ChipID");
+ ptr->dev_chipid = val.num;
+ break;
+ case CHIPREV:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "ChipRev");
+ ptr->dev_chiprev = val.num;
+ break;
+
+ case CLOCKS:
+ token = xf86getSubToken(&(ptr->dev_comment));
+ for( i = ptr->dev_clocks;
+ token == NUMBER && i < CONF_MAXCLOCKS; i++ ) {
+ ptr->dev_clock[i] = (int)(val.realnum * 1000.0 + 0.5);
+ token = xf86getSubToken(&(ptr->dev_comment));
+ }
+ ptr->dev_clocks = i;
+ xf86unGetToken (token);
+ break;
+ case TEXTCLOCKFRQ:
+ if ((token = xf86getSubToken(&(ptr->dev_comment))) != NUMBER)
+ Error (NUMBER_MSG, "TextClockFreq");
+ ptr->dev_textclockfreq = (int)(val.realnum * 1000.0 + 0.5);
+ break;
+ case OPTION:
+ ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst);
+ break;
+ case BUSID:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "BusID");
+ ptr->dev_busid = val.str;
+ break;
+ case IRQ:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (QUOTE_MSG, "IRQ");
+ ptr->dev_irq = val.num;
+ break;
+ case SCREEN:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Screen");
+ ptr->dev_screen = val.num;
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Device section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printDeviceSection (FILE * cf, XF86ConfDevicePtr ptr)
+{
+ int i;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"Device\"\n");
+ if (ptr->dev_comment)
+ fprintf (cf, "%s", ptr->dev_comment);
+ if (ptr->dev_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->dev_identifier);
+ if (ptr->dev_driver)
+ fprintf (cf, "\tDriver \"%s\"\n", ptr->dev_driver);
+ if (ptr->dev_vendor)
+ fprintf (cf, "\tVendorName \"%s\"\n", ptr->dev_vendor);
+ if (ptr->dev_board)
+ fprintf (cf, "\tBoardName \"%s\"\n", ptr->dev_board);
+ if (ptr->dev_chipset)
+ fprintf (cf, "\tChipSet \"%s\"\n", ptr->dev_chipset);
+ if (ptr->dev_card)
+ fprintf (cf, "\tCard \"%s\"\n", ptr->dev_card);
+ if (ptr->dev_ramdac)
+ fprintf (cf, "\tRamDac \"%s\"\n", ptr->dev_ramdac);
+ if (ptr->dev_dacSpeeds[0] > 0 ) {
+ fprintf (cf, "\tDacSpeed ");
+ for (i = 0; i < CONF_MAXDACSPEEDS
+ && ptr->dev_dacSpeeds[i] > 0; i++ )
+ fprintf (cf, "%g ", (double) (ptr->dev_dacSpeeds[i])/ 1000.0 );
+ fprintf (cf, "\n");
+ }
+ if (ptr->dev_videoram)
+ fprintf (cf, "\tVideoRam %d\n", ptr->dev_videoram);
+ if (ptr->dev_bios_base)
+ fprintf (cf, "\tBiosBase 0x%lx\n", ptr->dev_bios_base);
+ if (ptr->dev_mem_base)
+ fprintf (cf, "\tMemBase 0x%lx\n", ptr->dev_mem_base);
+ if (ptr->dev_io_base)
+ fprintf (cf, "\tIOBase 0x%lx\n", ptr->dev_io_base);
+ if (ptr->dev_clockchip)
+ fprintf (cf, "\tClockChip \"%s\"\n", ptr->dev_clockchip);
+ if (ptr->dev_chipid != -1)
+ fprintf (cf, "\tChipId 0x%x\n", ptr->dev_chipid);
+ if (ptr->dev_chiprev != -1)
+ fprintf (cf, "\tChipRev 0x%x\n", ptr->dev_chiprev);
+
+ xf86printOptionList(cf, ptr->dev_option_lst, 1);
+ if (ptr->dev_clocks > 0 ) {
+ fprintf (cf, "\tClocks ");
+ for (i = 0; i < ptr->dev_clocks; i++ )
+ fprintf (cf, "%.1f ", (double)ptr->dev_clock[i] / 1000.0 );
+ fprintf (cf, "\n");
+ }
+ if (ptr->dev_textclockfreq) {
+ fprintf (cf, "\tTextClockFreq %.1f\n",
+ (double)ptr->dev_textclockfreq / 1000.0);
+ }
+ if (ptr->dev_busid)
+ fprintf (cf, "\tBusID \"%s\"\n", ptr->dev_busid);
+ if (ptr->dev_screen > 0)
+ fprintf (cf, "\tScreen %d\n", ptr->dev_screen);
+ if (ptr->dev_irq >= 0)
+ fprintf (cf, "\tIRQ %d\n", ptr->dev_irq);
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86freeDeviceList (XF86ConfDevicePtr ptr)
+{
+ XF86ConfDevicePtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->dev_identifier);
+ TestFree (ptr->dev_vendor);
+ TestFree (ptr->dev_board);
+ TestFree (ptr->dev_chipset);
+ TestFree (ptr->dev_card);
+ TestFree (ptr->dev_driver);
+ TestFree (ptr->dev_ramdac);
+ TestFree (ptr->dev_clockchip);
+ TestFree (ptr->dev_comment);
+ xf86optionListFree (ptr->dev_option_lst);
+
+ prev = ptr;
+ ptr = ptr->list.next;
+ xf86conffree (prev);
+ }
+}
+
+int
+xf86validateDevice (XF86ConfigPtr p)
+{
+ XF86ConfDevicePtr device = p->conf_device_lst;
+
+ if (!device) {
+ xf86validationError ("At least one Device section is required.");
+ return (FALSE);
+ }
+
+ while (device) {
+ if (!device->dev_driver) {
+ xf86validationError (UNDEFINED_DRIVER_MSG, device->dev_identifier);
+ return (FALSE);
+ }
+ device = device->list.next;
+ }
+ return (TRUE);
+}
+
+XF86ConfDevicePtr
+xf86findDevice (const char *ident, XF86ConfDevicePtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->dev_identifier) == 0)
+ return (p);
+
+ p = p->list.next;
+ }
+ return (NULL);
+}
+
+char *
+xf86configStrdup (const char *s)
+{
+ char *tmp;
+ if (!s) return NULL;
+ tmp = xf86confmalloc (sizeof (char) * (strlen (s) + 1));
+ if (tmp)
+ strcpy (tmp, s);
+ return (tmp);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Extensions.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Extensions.c
new file mode 100644
index 000000000..b64f08111
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Extensions.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2004 Red Hat Inc., Raleigh, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec ExtensionsTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeExtensions
+
+XF86ConfExtensionsPtr
+xf86parseExtensionsSection (void)
+{
+ int token;
+ parsePrologue (XF86ConfExtensionsPtr, XF86ConfExtensionsRec);
+
+ while ((token = xf86getToken (ExtensionsTab)) != ENDSECTION) {
+ switch (token) {
+ case OPTION:
+ ptr->ext_option_lst = xf86parseOption(ptr->ext_option_lst);
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ case COMMENT:
+ ptr->extensions_comment =
+ xf86addComment(ptr->extensions_comment, val.str);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ ErrorF("Extensions section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printExtensionsSection (FILE * cf, XF86ConfExtensionsPtr ptr)
+{
+ XF86OptionPtr p;
+
+ if (ptr == NULL || ptr->ext_option_lst == NULL)
+ return;
+
+ p = ptr->ext_option_lst;
+ fprintf (cf, "Section \"Extensions\"\n");
+ if (ptr->extensions_comment)
+ fprintf (cf, "%s", ptr->extensions_comment);
+ xf86printOptionList(cf, p, 1);
+ fprintf (cf, "EndSection\n\n");
+}
+
+void
+xf86freeExtensions (XF86ConfExtensionsPtr ptr)
+{
+ if (ptr == NULL)
+ return;
+
+ xf86optionListFree (ptr->ext_option_lst);
+ TestFree (ptr->extensions_comment);
+ xf86conffree (ptr);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Files.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Files.c
new file mode 100644
index 000000000..cbbcc74c8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Files.c
@@ -0,0 +1,295 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Files.c,v 1.16 2003/08/24 17:37:07 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/Xos.h>
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec FilesTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {FONTPATH, "fontpath"},
+ {RGBPATH, "rgbpath"},
+ {MODULEPATH, "modulepath"},
+ {INPUTDEVICES, "inputdevices"},
+ {LOGFILEPATH, "logfile"},
+ {-1, ""},
+};
+
+static char *
+prependRoot (char *pathname)
+{
+#ifndef __EMX__
+ return pathname;
+#else
+ /* XXXX caveat: multiple path components in line */
+ return (char *) __XOS2RedirRoot (pathname);
+#endif
+}
+
+#define CLEANUP xf86freeFiles
+
+XF86ConfFilesPtr
+xf86parseFilesSection (void)
+{
+ int i, j;
+ int k, l;
+ char *str;
+ int token;
+ parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec)
+
+ while ((token = xf86getToken (FilesTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->file_comment = xf86addComment(ptr->file_comment, val.str);
+ break;
+ case FONTPATH:
+ if (xf86getSubToken (&(ptr->file_comment)) != STRING)
+ Error (QUOTE_MSG, "FontPath");
+ j = FALSE;
+ str = prependRoot (val.str);
+ if (ptr->file_fontpath == NULL)
+ {
+ ptr->file_fontpath = xf86confmalloc (1);
+ ptr->file_fontpath[0] = '\0';
+ i = strlen (str) + 1;
+ }
+ else
+ {
+ i = strlen (ptr->file_fontpath) + strlen (str) + 1;
+ if (ptr->file_fontpath[strlen (ptr->file_fontpath) - 1] != ',')
+ {
+ i++;
+ j = TRUE;
+ }
+ }
+ ptr->file_fontpath =
+ xf86confrealloc (ptr->file_fontpath, i);
+ if (j)
+ strcat (ptr->file_fontpath, ",");
+
+ strcat (ptr->file_fontpath, str);
+ xf86conffree (val.str);
+ break;
+ case RGBPATH:
+ if (xf86getSubToken (&(ptr->file_comment)) != STRING)
+ Error (QUOTE_MSG, "RGBPath");
+ ptr->file_rgbpath = val.str;
+ break;
+ case MODULEPATH:
+ if (xf86getSubToken (&(ptr->file_comment)) != STRING)
+ Error (QUOTE_MSG, "ModulePath");
+ l = FALSE;
+ str = prependRoot (val.str);
+ if (ptr->file_modulepath == NULL)
+ {
+ ptr->file_modulepath = xf86confmalloc (1);
+ ptr->file_modulepath[0] = '\0';
+ k = strlen (str) + 1;
+ }
+ else
+ {
+ k = strlen (ptr->file_modulepath) + strlen (str) + 1;
+ if (ptr->file_modulepath[strlen (ptr->file_modulepath) - 1] != ',')
+ {
+ k++;
+ l = TRUE;
+ }
+ }
+ ptr->file_modulepath = xf86confrealloc (ptr->file_modulepath, k);
+ if (l)
+ strcat (ptr->file_modulepath, ",");
+
+ strcat (ptr->file_modulepath, str);
+ xf86conffree (val.str);
+ break;
+ case INPUTDEVICES:
+ if (xf86getSubToken (&(ptr->file_comment)) != STRING)
+ Error (QUOTE_MSG, "InputDevices");
+ l = FALSE;
+ str = prependRoot (val.str);
+ if (ptr->file_inputdevs == NULL)
+ {
+ ptr->file_inputdevs = xf86confmalloc (1);
+ ptr->file_inputdevs[0] = '\0';
+ k = strlen (str) + 1;
+ }
+ else
+ {
+ k = strlen (ptr->file_inputdevs) + strlen (str) + 1;
+ if (ptr->file_inputdevs[strlen (ptr->file_inputdevs) - 1] != ',')
+ {
+ k++;
+ l = TRUE;
+ }
+ }
+ ptr->file_inputdevs = xf86confrealloc (ptr->file_inputdevs, k);
+ if (l)
+ strcat (ptr->file_inputdevs, ",");
+
+ strcat (ptr->file_inputdevs, str);
+ xf86conffree (val.str);
+ break;
+ case LOGFILEPATH:
+ if (xf86getSubToken (&(ptr->file_comment)) != STRING)
+ Error (QUOTE_MSG, "LogFile");
+ ptr->file_logfile = val.str;
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ printf ("File section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printFileSection (FILE * cf, XF86ConfFilesPtr ptr)
+{
+ char *p, *s;
+
+ if (ptr == NULL)
+ return;
+
+ if (ptr->file_comment)
+ fprintf (cf, "%s", ptr->file_comment);
+ if (ptr->file_logfile)
+ fprintf (cf, "\tLogFile \"%s\"\n", ptr->file_logfile);
+ if (ptr->file_rgbpath)
+ fprintf (cf, "\tRgbPath \"%s\"\n", ptr->file_rgbpath);
+ if (ptr->file_modulepath)
+ {
+ s = ptr->file_modulepath;
+ p = index (s, ',');
+ while (p)
+ {
+ *p = '\000';
+ fprintf (cf, "\tModulePath \"%s\"\n", s);
+ *p = ',';
+ s = p;
+ s++;
+ p = index (s, ',');
+ }
+ fprintf (cf, "\tModulePath \"%s\"\n", s);
+ }
+ if (ptr->file_inputdevs)
+ {
+ s = ptr->file_inputdevs;
+ p = index (s, ',');
+ while (p)
+ {
+ *p = '\000';
+ fprintf (cf, "\tInputDevices \"%s\"\n", s);
+ *p = ',';
+ s = p;
+ s++;
+ p = index (s, ',');
+ }
+ fprintf (cf, "\tInputdevs \"%s\"\n", s);
+ }
+ if (ptr->file_fontpath)
+ {
+ s = ptr->file_fontpath;
+ p = index (s, ',');
+ while (p)
+ {
+ *p = '\000';
+ fprintf (cf, "\tFontPath \"%s\"\n", s);
+ *p = ',';
+ s = p;
+ s++;
+ p = index (s, ',');
+ }
+ fprintf (cf, "\tFontPath \"%s\"\n", s);
+ }
+}
+
+void
+xf86freeFiles (XF86ConfFilesPtr p)
+{
+ if (p == NULL)
+ return;
+
+ TestFree (p->file_logfile);
+ TestFree (p->file_rgbpath);
+ TestFree (p->file_modulepath);
+ TestFree (p->file_inputdevs);
+ TestFree (p->file_fontpath);
+ TestFree (p->file_comment);
+
+ xf86conffree (p);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Flags.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Flags.c
new file mode 100644
index 000000000..bda24df1b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Flags.c
@@ -0,0 +1,525 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Flags.c,v 1.23 2003/08/24 17:37:07 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+#include <math.h>
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec ServerFlagsTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {NOTRAPSIGNALS, "notrapsignals"},
+ {DONTZAP, "dontzap"},
+ {DONTZOOM, "dontzoom"},
+ {DISABLEVIDMODE, "disablevidmodeextension"},
+ {ALLOWNONLOCAL, "allownonlocalxvidtune"},
+ {DISABLEMODINDEV, "disablemodindev"},
+ {MODINDEVALLOWNONLOCAL, "allownonlocalmodindev"},
+ {ALLOWMOUSEOPENFAIL, "allowmouseopenfail"},
+ {OPTION, "option"},
+ {BLANKTIME, "blanktime"},
+ {STANDBYTIME, "standbytime"},
+ {SUSPENDTIME, "suspendtime"},
+ {OFFTIME, "offtime"},
+ {DEFAULTLAYOUT, "defaultserverlayout"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeFlags
+
+XF86ConfFlagsPtr
+xf86parseFlagsSection (void)
+{
+ int token;
+ parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
+
+ while ((token = xf86getToken (ServerFlagsTab)) != ENDSECTION)
+ {
+ int hasvalue = FALSE;
+ int strvalue = FALSE;
+ int tokentype;
+ switch (token)
+ {
+ case COMMENT:
+ ptr->flg_comment = xf86addComment(ptr->flg_comment, val.str);
+ break;
+ /*
+ * these old keywords are turned into standard generic options.
+ * we fall through here on purpose
+ */
+ case DEFAULTLAYOUT:
+ strvalue = TRUE;
+ case BLANKTIME:
+ case STANDBYTIME:
+ case SUSPENDTIME:
+ case OFFTIME:
+ hasvalue = TRUE;
+ case NOTRAPSIGNALS:
+ case DONTZAP:
+ case DONTZOOM:
+ case DISABLEVIDMODE:
+ case ALLOWNONLOCAL:
+ case DISABLEMODINDEV:
+ case MODINDEVALLOWNONLOCAL:
+ case ALLOWMOUSEOPENFAIL:
+ {
+ int i = 0;
+ while (ServerFlagsTab[i].token != -1)
+ {
+ char *tmp;
+
+ if (ServerFlagsTab[i].token == token)
+ {
+ char *valstr = NULL;
+ /* can't use strdup because it calls malloc */
+ tmp = xf86configStrdup (ServerFlagsTab[i].name);
+ if (hasvalue)
+ {
+ tokentype = xf86getSubToken(&(ptr->flg_comment));
+ if (strvalue) {
+ if (tokentype != STRING)
+ Error (QUOTE_MSG, tmp);
+ valstr = val.str;
+ } else {
+ if (tokentype != NUMBER)
+ Error (NUMBER_MSG, tmp);
+ valstr = xf86confmalloc(16);
+ if (valstr)
+ sprintf(valstr, "%d", val.num);
+ }
+ }
+ ptr->flg_option_lst = xf86addNewOption
+ (ptr->flg_option_lst, tmp, valstr);
+ }
+ i++;
+ }
+ }
+ break;
+ case OPTION:
+ ptr->flg_option_lst = xf86parseOption(ptr->flg_option_lst);
+ break;
+
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ printf ("Flags section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printServerFlagsSection (FILE * f, XF86ConfFlagsPtr flags)
+{
+ XF86OptionPtr p;
+
+ if ((!flags) || (!flags->flg_option_lst))
+ return;
+ p = flags->flg_option_lst;
+ fprintf (f, "Section \"ServerFlags\"\n");
+ if (flags->flg_comment)
+ fprintf (f, "%s", flags->flg_comment);
+ xf86printOptionList(f, p, 1);
+ fprintf (f, "EndSection\n\n");
+}
+
+static XF86OptionPtr
+addNewOption2 (XF86OptionPtr head, char *name, char *val, int used)
+{
+ XF86OptionPtr new, old = NULL;
+
+ /* Don't allow duplicates */
+ if (head != NULL && (old = xf86findOption(head, name)) != NULL)
+ new = old;
+ else {
+ new = xf86confcalloc (1, sizeof (XF86OptionRec));
+ new->list.next = NULL;
+ }
+ new->opt_name = name;
+ new->opt_val = val;
+ new->opt_used = used;
+
+ if (old == NULL)
+ return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new));
+ else
+ return head;
+}
+
+XF86OptionPtr
+xf86addNewOption (XF86OptionPtr head, char *name, char *val)
+{
+ return addNewOption2(head, name, val, 0);
+}
+
+void
+xf86freeFlags (XF86ConfFlagsPtr flags)
+{
+ if (flags == NULL)
+ return;
+ xf86optionListFree (flags->flg_option_lst);
+ TestFree(flags->flg_comment);
+ xf86conffree (flags);
+}
+
+XF86OptionPtr
+xf86optionListDup (XF86OptionPtr opt)
+{
+ XF86OptionPtr newopt = NULL;
+
+ while (opt)
+ {
+ newopt = xf86addNewOption(newopt, xf86configStrdup(opt->opt_name),
+ xf86configStrdup(opt->opt_val));
+ newopt->opt_used = opt->opt_used;
+ if (opt->opt_comment)
+ newopt->opt_comment = xf86configStrdup(opt->opt_comment);
+ opt = opt->list.next;
+ }
+ return newopt;
+}
+
+void
+xf86optionListFree (XF86OptionPtr opt)
+{
+ XF86OptionPtr prev;
+
+ while (opt)
+ {
+ TestFree (opt->opt_name);
+ TestFree (opt->opt_val);
+ TestFree (opt->opt_comment);
+ prev = opt;
+ opt = opt->list.next;
+ xf86conffree (prev);
+ }
+}
+
+char *
+xf86optionName(XF86OptionPtr opt)
+{
+ if (opt)
+ return opt->opt_name;
+ return 0;
+}
+
+char *
+xf86optionValue(XF86OptionPtr opt)
+{
+ if (opt)
+ return opt->opt_val;
+ return 0;
+}
+
+XF86OptionPtr
+xf86newOption(char *name, char *value)
+{
+ XF86OptionPtr opt;
+
+ opt = xf86confcalloc(1, sizeof (XF86OptionRec));
+ if (!opt)
+ return NULL;
+
+ opt->opt_used = 0;
+ opt->list.next = 0;
+ opt->opt_name = name;
+ opt->opt_val = value;
+
+ return opt;
+}
+
+XF86OptionPtr
+xf86nextOption(XF86OptionPtr list)
+{
+ if (!list)
+ return NULL;
+ return list->list.next;
+}
+
+/*
+ * this function searches the given option list for the named option and
+ * returns a pointer to the option rec if found. If not found, it returns
+ * NULL
+ */
+
+XF86OptionPtr
+xf86findOption (XF86OptionPtr list, const char *name)
+{
+ while (list)
+ {
+ if (xf86nameCompare (list->opt_name, name) == 0)
+ return (list);
+ list = list->list.next;
+ }
+ return (NULL);
+}
+
+/*
+ * this function searches the given option list for the named option. If
+ * found and the option has a parameter, a pointer to the parameter is
+ * returned. If the option does not have a parameter an empty string is
+ * returned. If the option is not found, a NULL is returned.
+ */
+
+char *
+xf86findOptionValue (XF86OptionPtr list, const char *name)
+{
+ XF86OptionPtr p = xf86findOption (list, name);
+
+ if (p)
+ {
+ if (p->opt_val)
+ return (p->opt_val);
+ else
+ return "";
+ }
+ return (NULL);
+}
+
+XF86OptionPtr
+xf86optionListCreate( const char **options, int count, int used )
+{
+ XF86OptionPtr p = NULL;
+ char *t1, *t2;
+ int i;
+
+ if (count == -1)
+ {
+ for (count = 0; options[count]; count++)
+ ;
+ }
+ if( (count % 2) != 0 )
+ {
+ fprintf( stderr, "xf86optionListCreate: count must be an even number.\n" );
+ return (NULL);
+ }
+ for (i = 0; i < count; i += 2)
+ {
+ /* can't use strdup because it calls malloc */
+ t1 = xf86confmalloc (sizeof (char) *
+ (strlen (options[i]) + 1));
+ strcpy (t1, options[i]);
+ t2 = xf86confmalloc (sizeof (char) *
+ (strlen (options[i + 1]) + 1));
+ strcpy (t2, options[i + 1]);
+ p = addNewOption2 (p, t1, t2, used);
+ }
+
+ return (p);
+}
+
+/* the 2 given lists are merged. If an option with the same name is present in
+ * both, the option from the user list - specified in the second argument -
+ * is used. The end result is a single valid list of options. Duplicates
+ * are freed, and the original lists are no longer guaranteed to be complete.
+ */
+XF86OptionPtr
+xf86optionListMerge (XF86OptionPtr head, XF86OptionPtr tail)
+{
+ XF86OptionPtr a, b, ap = NULL, bp = NULL;
+
+ a = tail;
+ b = head;
+ while (tail && b) {
+ if (xf86nameCompare (a->opt_name, b->opt_name) == 0) {
+ if (b == head)
+ head = a;
+ else
+ bp->list.next = a;
+ if (a == tail)
+ tail = a->list.next;
+ else
+ ap->list.next = a->list.next;
+ a->list.next = b->list.next;
+ b->list.next = NULL;
+ xf86optionListFree (b);
+ b = a->list.next;
+ bp = a;
+ a = tail;
+ ap = NULL;
+ } else {
+ ap = a;
+ if (!(a = a->list.next)) {
+ a = tail;
+ bp = b;
+ b = b->list.next;
+ ap = NULL;
+ }
+ }
+ }
+
+ if (head) {
+ for (a = head; a->list.next; a = a->list.next)
+ ;
+ a->list.next = tail;
+ } else
+ head = tail;
+
+ return (head);
+}
+
+char *
+xf86uLongToString(unsigned long i)
+{
+ char *s;
+ int l;
+
+ l = (int)(ceil(log10((double)i) + 2.5));
+ s = xf86confmalloc(l);
+ if (!s)
+ return NULL;
+ sprintf(s, "%lu", i);
+ return s;
+}
+
+void
+xf86debugListOptions(XF86OptionPtr Options)
+{
+ while (Options) {
+ ErrorF("Option: %s Value: %s\n",Options->opt_name,Options->opt_val);
+ Options = Options->list.next;
+ }
+}
+
+XF86OptionPtr
+xf86parseOption(XF86OptionPtr head)
+{
+ XF86OptionPtr option, cnew, old;
+ char *name, *comment = NULL;
+ int token;
+
+ if ((token = xf86getSubToken(&comment)) != STRING) {
+ xf86parseError(BAD_OPTION_MSG, NULL);
+ if (comment)
+ xf86conffree(comment);
+ return (head);
+ }
+
+ name = val.str;
+ if ((token = xf86getSubToken(&comment)) == STRING) {
+ option = xf86newOption(name, val.str);
+ option->opt_comment = comment;
+ if ((token = xf86getToken(NULL)) == COMMENT)
+ option->opt_comment = xf86addComment(option->opt_comment, val.str);
+ else
+ xf86unGetToken(token);
+ }
+ else {
+ option = xf86newOption(name, NULL);
+ option->opt_comment = comment;
+ if (token == COMMENT)
+ option->opt_comment = xf86addComment(option->opt_comment, val.str);
+ else
+ xf86unGetToken(token);
+ }
+
+ old = NULL;
+
+ /* Don't allow duplicates */
+ if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
+ cnew = old;
+ xf86conffree(option->opt_name);
+ TestFree(option->opt_val);
+ TestFree(option->opt_comment);
+ xf86conffree(option);
+ }
+ else
+ cnew = option;
+
+ if (old == NULL)
+ return ((XF86OptionPtr)xf86addListItem((glp)head, (glp)cnew));
+
+ return (head);
+}
+
+void
+xf86printOptionList(FILE *fp, XF86OptionPtr list, int tabs)
+{
+ int i;
+
+ if (!list)
+ return;
+ while (list) {
+ for (i = 0; i < tabs; i++)
+ fputc('\t', fp);
+ if (list->opt_val)
+ fprintf(fp, "Option \"%s\" \"%s\"", list->opt_name, list->opt_val);
+ else
+ fprintf(fp, "Option \"%s\"", list->opt_name);
+ if (list->opt_comment)
+ fprintf(fp, "%s", list->opt_comment);
+ else
+ fputc('\n', fp);
+ list = list->list.next;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/parser/Imakefile
new file mode 100644
index 000000000..29708b64b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Imakefile
@@ -0,0 +1,51 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Imakefile,v 1.12 2001/01/12 19:28:35 dawes Exp $ */
+
+
+
+#define DoNormalLib YES
+#define DoSharedLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#define HasSharedData NO
+#define LibName xf86config
+
+#define UseDBMalloc NO
+
+#if UseDBMalloc
+SYS_LIBRARIES=-ldbmalloc
+DBMALLOCDEFINE=-DDBMALLOC
+#endif
+
+SYS_LIBRARIES = MathLibrary
+
+XCONFIGFILE = XConfigFile
+XCONFIGDIR = XConfigDir
+#if defined XFree86Version
+XVERS = XFree86Version
+#elif defined (XorgVersion)
+XVERS = XorgVersion
+#endif
+
+INCLUDES = -I. -I$(XF86OSSRC)
+
+HEADERS = xf86Parser.h xf86Optrec.h
+
+SRCS = Device.c Files.c Flags.c Input.c Keyboard.c Layout.c Module.c \
+ Video.c Monitor.c Pointer.c Screen.c Vendor.c read.c scan.c write.c \
+ DRI.c Extensions.c
+OBJS = Device.o Files.o Flags.o Input.o Keyboard.o Layout.o Module.o \
+ Video.o Monitor.o Pointer.o Screen.o Vendor.o read.o scan.o write.o \
+ DRI.o Extensions.o
+
+CONFIG_DEFINES = -DXCONFIGDIR=\"$(XCONFIGDIR)\" \
+ -DXCONFIGFILE=\"$(XCONFIGFILE)\" \
+ -DXVERSION="$(XVERS)"
+
+#include <Library.tmpl>
+
+SpecialCObjectRule(scan,NullParameter,$(CONFIG_DEFINES) $(MODULEDEFINES) $(EXT_DEFINES))
+
+NormalProgramTarget(cpconfig,cpconfig.o $(OBJS),NullParameter,$(LOCAL_LIBRARIES),NullParameter)
+
+AllTarget(ProgramTargetName(cpconfig))
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Input.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Input.c
new file mode 100644
index 000000000..9f9323f05
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Input.c
@@ -0,0 +1,215 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Input.c,v 1.14 2003/08/24 17:37:07 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static
+xf86ConfigSymTabRec InputTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {OPTION, "option"},
+ {DRIVER, "driver"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeInputList
+
+XF86ConfInputPtr
+xf86parseInputSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
+
+ while ((token = xf86getToken (InputTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->inp_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case DRIVER:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "Driver");
+ ptr->inp_driver = val.str;
+ break;
+ case OPTION:
+ ptr->inp_option_lst = xf86parseOption(ptr->inp_option_lst);
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("InputDevice section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printInputSection (FILE * cf, XF86ConfInputPtr ptr)
+{
+ while (ptr)
+ {
+ fprintf (cf, "Section \"InputDevice\"\n");
+ if (ptr->inp_comment)
+ fprintf (cf, "%s", ptr->inp_comment);
+ if (ptr->inp_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->inp_identifier);
+ if (ptr->inp_driver)
+ fprintf (cf, "\tDriver \"%s\"\n", ptr->inp_driver);
+ xf86printOptionList(cf, ptr->inp_option_lst, 1);
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86freeInputList (XF86ConfInputPtr ptr)
+{
+ XF86ConfInputPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->inp_identifier);
+ TestFree (ptr->inp_driver);
+ TestFree (ptr->inp_comment);
+ xf86optionListFree (ptr->inp_option_lst);
+
+ prev = ptr;
+ ptr = ptr->list.next;
+ xf86conffree (prev);
+ }
+}
+
+int
+xf86validateInput (XF86ConfigPtr p)
+{
+ XF86ConfInputPtr input = p->conf_input_lst;
+
+#if 0 /* Enable this later */
+ if (!input) {
+ xf86validationError ("At least one InputDevice section is required.");
+ return (FALSE);
+ }
+#endif
+
+ while (input) {
+ if (!input->inp_driver) {
+ xf86validationError (UNDEFINED_INPUTDRIVER_MSG, input->inp_identifier);
+ return (FALSE);
+ }
+ input = input->list.next;
+ }
+ return (TRUE);
+}
+
+XF86ConfInputPtr
+xf86findInput (const char *ident, XF86ConfInputPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->inp_identifier) == 0)
+ return (p);
+
+ p = p->list.next;
+ }
+ return (NULL);
+}
+
+XF86ConfInputPtr
+xf86findInputByDriver (const char *driver, XF86ConfInputPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (driver, p->inp_driver) == 0)
+ return (p);
+
+ p = p->list.next;
+ }
+ return (NULL);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Keyboard.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Keyboard.c
new file mode 100644
index 000000000..4ba893a9d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Keyboard.c
@@ -0,0 +1,306 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Keyboard.c,v 1.17 2003/08/24 17:37:07 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+#include "ctype.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec KeyboardTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {KPROTOCOL, "protocol"},
+ {AUTOREPEAT, "autorepeat"},
+ {XLEDS, "xleds"},
+ {PANIX106, "panix106"},
+ {XKBKEYMAP, "xkbkeymap"},
+ {XKBCOMPAT, "xkbcompat"},
+ {XKBTYPES, "xkbtypes"},
+ {XKBKEYCODES, "xkbkeycodes"},
+ {XKBGEOMETRY, "xkbgeometry"},
+ {XKBSYMBOLS, "xkbsymbols"},
+ {XKBDISABLE, "xkbdisable"},
+ {XKBRULES, "xkbrules"},
+ {XKBMODEL, "xkbmodel"},
+ {XKBLAYOUT, "xkblayout"},
+ {XKBVARIANT, "xkbvariant"},
+ {XKBOPTIONS, "xkboptions"},
+ /* The next two have become ServerFlags options */
+ {VTINIT, "vtinit"},
+ {VTSYSREQ, "vtsysreq"},
+ /* Obsolete keywords */
+ {SERVERNUM, "servernumlock"},
+ {LEFTALT, "leftalt"},
+ {RIGHTALT, "rightalt"},
+ {RIGHTALT, "altgr"},
+ {SCROLLLOCK_TOK, "scrolllock"},
+ {RIGHTCTL, "rightctl"},
+ {-1, ""},
+};
+
+/* Obsolete */
+static xf86ConfigSymTabRec KeyMapTab[] =
+{
+ {CONF_KM_META, "meta"},
+ {CONF_KM_COMPOSE, "compose"},
+ {CONF_KM_MODESHIFT, "modeshift"},
+ {CONF_KM_MODELOCK, "modelock"},
+ {CONF_KM_SCROLLLOCK, "scrolllock"},
+ {CONF_KM_CONTROL, "control"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeInputList
+
+XF86ConfInputPtr
+xf86parseKeyboardSection (void)
+{
+ char *s, *s1, *s2;
+ int l;
+ int token, ntoken;
+ parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
+
+ while ((token = xf86getToken (KeyboardTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
+ break;
+ case KPROTOCOL:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "Protocol");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("Protocol"),
+ val.str);
+ break;
+ case AUTOREPEAT:
+ if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER)
+ Error (AUTOREPEAT_MSG, NULL);
+ s1 = xf86uLongToString(val.num);
+ if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER)
+ Error (AUTOREPEAT_MSG, NULL);
+ s2 = xf86uLongToString(val.num);
+ l = strlen(s1) + 1 + strlen(s2) + 1;
+ s = xf86confmalloc(l);
+ sprintf(s, "%s %s", s1, s2);
+ xf86conffree(s1);
+ xf86conffree(s2);
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("AutoRepeat"), s);
+ break;
+ case XLEDS:
+ if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER)
+ Error (XLEDS_MSG, NULL);
+ s = xf86uLongToString(val.num);
+ l = strlen(s) + 1;
+ while ((token = xf86getSubToken (&(ptr->inp_comment))) == NUMBER)
+ {
+ s1 = xf86uLongToString(val.num);
+ l += (1 + strlen(s1));
+ s = xf86confrealloc(s, l);
+ strcat(s, " ");
+ strcat(s, s1);
+ xf86conffree(s1);
+ }
+ xf86unGetToken (token);
+ break;
+ case SERVERNUM:
+ xf86parseWarning(OBSOLETE_MSG, xf86tokenString());
+ break;
+ case LEFTALT:
+ case RIGHTALT:
+ case SCROLLLOCK_TOK:
+ case RIGHTCTL:
+ xf86parseWarning(OBSOLETE_MSG, xf86tokenString());
+ break;
+ ntoken = xf86getToken (KeyMapTab);
+ switch (ntoken)
+ {
+ case EOF_TOKEN:
+ xf86parseError (UNEXPECTED_EOF_MSG);
+ CLEANUP (ptr);
+ return (NULL);
+ break;
+
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ break;
+ case VTINIT:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "VTInit");
+ xf86parseWarning(MOVED_TO_FLAGS_MSG, "VTInit");
+ break;
+ case VTSYSREQ:
+ xf86parseWarning(MOVED_TO_FLAGS_MSG, "VTSysReq");
+ break;
+ case XKBDISABLE:
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("XkbDisable"),
+ NULL);
+ break;
+ case XKBKEYMAP:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "XKBKeymap");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("XkbKeymap"),
+ val.str);
+ break;
+ case XKBCOMPAT:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "XKBCompat");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("XkbCompat"),
+ val.str);
+ break;
+ case XKBTYPES:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "XKBTypes");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("XkbTypes"),
+ val.str);
+ break;
+ case XKBKEYCODES:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "XKBKeycodes");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("XkbKeycodes"),
+ val.str);
+ break;
+ case XKBGEOMETRY:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "XKBGeometry");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("XkbGeometry"),
+ val.str);
+ break;
+ case XKBSYMBOLS:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "XKBSymbols");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("XkbSymbols"),
+ val.str);
+ break;
+ case XKBRULES:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "XKBRules");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("XkbRules"),
+ val.str);
+ break;
+ case XKBMODEL:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "XKBModel");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("XkbModel"),
+ val.str);
+ break;
+ case XKBLAYOUT:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "XKBLayout");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("XkbLayout"),
+ val.str);
+ break;
+ case XKBVARIANT:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "XKBVariant");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("XkbVariant"),
+ val.str);
+ break;
+ case XKBOPTIONS:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "XKBOptions");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("XkbOptions"),
+ val.str);
+ break;
+ case PANIX106:
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("Panix106"), NULL);
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ ptr->inp_identifier = xf86configStrdup(CONF_IMPLICIT_KEYBOARD);
+ ptr->inp_driver = xf86configStrdup("keyboard");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("CoreKeyboard"), NULL);
+
+#ifdef DEBUG
+ printf ("Keyboard section parsed\n");
+#endif
+
+ return ptr;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Layout.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Layout.c
new file mode 100644
index 000000000..56d92a79c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Layout.c
@@ -0,0 +1,513 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Layout.c,v 1.24 2003/08/24 17:37:07 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+#include <string.h>
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec LayoutTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {SCREEN, "screen"},
+ {IDENTIFIER, "identifier"},
+ {INACTIVE, "inactive"},
+ {INPUTDEVICE, "inputdevice"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+static xf86ConfigSymTabRec AdjTab[] =
+{
+ {RIGHTOF, "rightof"},
+ {LEFTOF, "leftof"},
+ {ABOVE, "above"},
+ {BELOW, "below"},
+ {RELATIVE, "relative"},
+ {ABSOLUTE, "absolute"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeLayoutList
+
+XF86ConfLayoutPtr
+xf86parseLayoutSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
+
+ while ((token = xf86getToken (LayoutTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->lay_comment = xf86addComment(ptr->lay_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->lay_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case INACTIVE:
+ {
+ XF86ConfInactivePtr iptr;
+
+ iptr = xf86confcalloc (1, sizeof (XF86ConfInactiveRec));
+ iptr->list.next = NULL;
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING)
+ Error (INACTIVE_MSG, NULL);
+ iptr->inactive_device_str = val.str;
+ ptr->lay_inactive_lst = (XF86ConfInactivePtr)
+ xf86addListItem ((glp) ptr->lay_inactive_lst, (glp) iptr);
+ }
+ break;
+ case SCREEN:
+ {
+ XF86ConfAdjacencyPtr aptr;
+ int absKeyword = 0;
+
+ aptr = xf86confcalloc (1, sizeof (XF86ConfAdjacencyRec));
+ aptr->list.next = NULL;
+ aptr->adj_scrnum = -1;
+ aptr->adj_where = CONF_ADJ_OBSOLETE;
+ aptr->adj_x = 0;
+ aptr->adj_y = 0;
+ aptr->adj_refscreen = NULL;
+ if ((token = xf86getSubToken (&(ptr->lay_comment))) == NUMBER)
+ aptr->adj_scrnum = val.num;
+ else
+ xf86unGetToken (token);
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != STRING)
+ Error (SCREEN_MSG, NULL);
+ aptr->adj_screen_str = val.str;
+
+ token = xf86getSubTokenWithTab(&(ptr->lay_comment), AdjTab);
+ switch (token)
+ {
+ case RIGHTOF:
+ aptr->adj_where = CONF_ADJ_RIGHTOF;
+ break;
+ case LEFTOF:
+ aptr->adj_where = CONF_ADJ_LEFTOF;
+ break;
+ case ABOVE:
+ aptr->adj_where = CONF_ADJ_ABOVE;
+ break;
+ case BELOW:
+ aptr->adj_where = CONF_ADJ_BELOW;
+ break;
+ case RELATIVE:
+ aptr->adj_where = CONF_ADJ_RELATIVE;
+ break;
+ case ABSOLUTE:
+ aptr->adj_where = CONF_ADJ_ABSOLUTE;
+ absKeyword = 1;
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ xf86unGetToken (token);
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token == STRING)
+ aptr->adj_where = CONF_ADJ_OBSOLETE;
+ else
+ aptr->adj_where = CONF_ADJ_ABSOLUTE;
+ }
+ switch (aptr->adj_where)
+ {
+ case CONF_ADJ_ABSOLUTE:
+ if (absKeyword)
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token == NUMBER)
+ {
+ aptr->adj_x = val.num;
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != NUMBER)
+ Error(INVALID_SCR_MSG, NULL);
+ aptr->adj_y = val.num;
+ } else {
+ if (absKeyword)
+ Error(INVALID_SCR_MSG, NULL);
+ else
+ xf86unGetToken (token);
+ }
+ break;
+ case CONF_ADJ_RIGHTOF:
+ case CONF_ADJ_LEFTOF:
+ case CONF_ADJ_ABOVE:
+ case CONF_ADJ_BELOW:
+ case CONF_ADJ_RELATIVE:
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != STRING)
+ Error(INVALID_SCR_MSG, NULL);
+ aptr->adj_refscreen = val.str;
+ if (aptr->adj_where == CONF_ADJ_RELATIVE)
+ {
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != NUMBER)
+ Error(INVALID_SCR_MSG, NULL);
+ aptr->adj_x = val.num;
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != NUMBER)
+ Error(INVALID_SCR_MSG, NULL);
+ aptr->adj_y = val.num;
+ }
+ break;
+ case CONF_ADJ_OBSOLETE:
+ /* top */
+ aptr->adj_top_str = val.str;
+
+ /* bottom */
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING)
+ Error (SCREEN_MSG, NULL);
+ aptr->adj_bottom_str = val.str;
+
+ /* left */
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING)
+ Error (SCREEN_MSG, NULL);
+ aptr->adj_left_str = val.str;
+
+ /* right */
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING)
+ Error (SCREEN_MSG, NULL);
+ aptr->adj_right_str = val.str;
+
+ }
+ ptr->lay_adjacency_lst = (XF86ConfAdjacencyPtr)
+ xf86addListItem ((glp) ptr->lay_adjacency_lst, (glp) aptr);
+ }
+ break;
+ case INPUTDEVICE:
+ {
+ XF86ConfInputrefPtr iptr;
+
+ iptr = xf86confcalloc (1, sizeof (XF86ConfInputrefRec));
+ iptr->list.next = NULL;
+ iptr->iref_option_lst = NULL;
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING)
+ Error (INPUTDEV_MSG, NULL);
+ iptr->iref_inputdev_str = val.str;
+ while ((token = xf86getSubToken (&(ptr->lay_comment))) == STRING)
+ {
+ iptr->iref_option_lst =
+ xf86addNewOption (iptr->iref_option_lst, val.str, NULL);
+ }
+ xf86unGetToken (token);
+ ptr->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
+ }
+ break;
+ case OPTION:
+ ptr->lay_option_lst = xf86parseOption(ptr->lay_option_lst);
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Layout section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printLayoutSection (FILE * cf, XF86ConfLayoutPtr ptr)
+{
+ XF86ConfAdjacencyPtr aptr;
+ XF86ConfInactivePtr iptr;
+ XF86ConfInputrefPtr inptr;
+ XF86OptionPtr optr;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"ServerLayout\"\n");
+ if (ptr->lay_comment)
+ fprintf (cf, "%s", ptr->lay_comment);
+ if (ptr->lay_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->lay_identifier);
+
+ for (aptr = ptr->lay_adjacency_lst; aptr; aptr = aptr->list.next)
+ {
+ fprintf (cf, "\tScreen ");
+ if (aptr->adj_scrnum >= 0)
+ fprintf (cf, "%2d", aptr->adj_scrnum);
+ else
+ fprintf (cf, " ");
+ fprintf (cf, " \"%s\"", aptr->adj_screen_str);
+ switch(aptr->adj_where)
+ {
+ case CONF_ADJ_OBSOLETE:
+ fprintf (cf, " \"%s\"", aptr->adj_top_str);
+ fprintf (cf, " \"%s\"", aptr->adj_bottom_str);
+ fprintf (cf, " \"%s\"", aptr->adj_right_str);
+ fprintf (cf, " \"%s\"\n", aptr->adj_left_str);
+ break;
+ case CONF_ADJ_ABSOLUTE:
+ if (aptr->adj_x != -1)
+ fprintf (cf, " %d %d\n", aptr->adj_x, aptr->adj_y);
+ else
+ fprintf (cf, "\n");
+ break;
+ case CONF_ADJ_RIGHTOF:
+ fprintf (cf, " RightOf \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_LEFTOF:
+ fprintf (cf, " LeftOf \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_ABOVE:
+ fprintf (cf, " Above \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_BELOW:
+ fprintf (cf, " Below \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_RELATIVE:
+ fprintf (cf, " Relative \"%s\" %d %d\n", aptr->adj_refscreen,
+ aptr->adj_x, aptr->adj_y);
+ break;
+ }
+ }
+ for (iptr = ptr->lay_inactive_lst; iptr; iptr = iptr->list.next)
+ fprintf (cf, "\tInactive \"%s\"\n", iptr->inactive_device_str);
+ for (inptr = ptr->lay_input_lst; inptr; inptr = inptr->list.next)
+ {
+ fprintf (cf, "\tInputDevice \"%s\"", inptr->iref_inputdev_str);
+ for (optr = inptr->iref_option_lst; optr; optr = optr->list.next)
+ {
+ fprintf(cf, " \"%s\"", optr->opt_name);
+ }
+ fprintf(cf, "\n");
+ }
+ xf86printOptionList(cf, ptr->lay_option_lst, 1);
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86freeLayoutList (XF86ConfLayoutPtr ptr)
+{
+ XF86ConfLayoutPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->lay_identifier);
+ TestFree (ptr->lay_comment);
+ xf86freeAdjacencyList (ptr->lay_adjacency_lst);
+ xf86freeInputrefList (ptr->lay_input_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ xf86conffree (prev);
+ }
+}
+
+void
+xf86freeAdjacencyList (XF86ConfAdjacencyPtr ptr)
+{
+ XF86ConfAdjacencyPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->adj_screen_str);
+ TestFree (ptr->adj_top_str);
+ TestFree (ptr->adj_bottom_str);
+ TestFree (ptr->adj_left_str);
+ TestFree (ptr->adj_right_str);
+
+ prev = ptr;
+ ptr = ptr->list.next;
+ xf86conffree (prev);
+ }
+
+}
+
+void
+xf86freeInputrefList (XF86ConfInputrefPtr ptr)
+{
+ XF86ConfInputrefPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->iref_inputdev_str);
+ xf86optionListFree (ptr->iref_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ xf86conffree (prev);
+ }
+
+}
+
+#define CheckScreen(str, ptr)\
+if (str[0] != '\0') \
+{ \
+screen = xf86findScreen (str, p->conf_screen_lst); \
+if (!screen) \
+{ \
+ xf86validationError (UNDEFINED_SCREEN_MSG, \
+ str, layout->lay_identifier); \
+ return (FALSE); \
+} \
+else \
+ ptr = screen; \
+}
+
+int
+xf86validateLayout (XF86ConfigPtr p)
+{
+ XF86ConfLayoutPtr layout = p->conf_layout_lst;
+ XF86ConfAdjacencyPtr adj;
+ XF86ConfInactivePtr iptr;
+ XF86ConfInputrefPtr inptr;
+ XF86ConfScreenPtr screen;
+ XF86ConfDevicePtr device;
+ XF86ConfInputPtr input;
+
+ while (layout)
+ {
+ adj = layout->lay_adjacency_lst;
+ while (adj)
+ {
+ /* the first one can't be "" but all others can */
+ screen = xf86findScreen (adj->adj_screen_str, p->conf_screen_lst);
+ if (!screen)
+ {
+ xf86validationError (UNDEFINED_SCREEN_MSG,
+ adj->adj_screen_str, layout->lay_identifier);
+ return (FALSE);
+ }
+ else
+ adj->adj_screen = screen;
+
+#if 0
+ CheckScreen (adj->adj_top_str, adj->adj_top);
+ CheckScreen (adj->adj_bottom_str, adj->adj_bottom);
+ CheckScreen (adj->adj_left_str, adj->adj_left);
+ CheckScreen (adj->adj_right_str, adj->adj_right);
+#endif
+
+ adj = adj->list.next;
+ }
+ iptr = layout->lay_inactive_lst;
+ while (iptr)
+ {
+ device = xf86findDevice (iptr->inactive_device_str,
+ p->conf_device_lst);
+ if (!device)
+ {
+ xf86validationError (UNDEFINED_DEVICE_LAY_MSG,
+ iptr->inactive_device_str, layout->lay_identifier);
+ return (FALSE);
+ }
+ else
+ iptr->inactive_device = device;
+ iptr = iptr->list.next;
+ }
+ inptr = layout->lay_input_lst;
+ while (inptr)
+ {
+ input = xf86findInput (inptr->iref_inputdev_str,
+ p->conf_input_lst);
+ if (!input)
+ {
+ xf86validationError (UNDEFINED_INPUT_MSG,
+ inptr->iref_inputdev_str, layout->lay_identifier);
+ return (FALSE);
+ }
+ else
+ inptr->iref_inputdev = input;
+ inptr = inptr->list.next;
+ }
+ layout = layout->list.next;
+ }
+ return (TRUE);
+}
+
+XF86ConfLayoutPtr
+xf86findLayout (const char *name, XF86ConfLayoutPtr list)
+{
+ while (list)
+ {
+ if (xf86nameCompare (list->lay_identifier, name) == 0)
+ return (list);
+ list = list->list.next;
+ }
+ return (NULL);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Module.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Module.c
new file mode 100644
index 000000000..7a5a25207
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Module.c
@@ -0,0 +1,261 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Module.c,v 1.12 2003/08/24 17:37:08 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec SubModuleTab[] =
+{
+ {ENDSUBSECTION, "endsubsection"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+static xf86ConfigSymTabRec ModuleTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {LOAD, "load"},
+ {LOAD_DRIVER, "loaddriver"},
+ {SUBSECTION, "subsection"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeModules
+
+XF86LoadPtr
+xf86parseModuleSubSection (XF86LoadPtr head, char *name)
+{
+ int token;
+ parsePrologue (XF86LoadPtr, XF86LoadRec)
+
+ ptr->load_name = name;
+ ptr->load_type = XF86_LOAD_MODULE;
+ ptr->load_opt = NULL;
+ ptr->list.next = NULL;
+
+ while ((token = xf86getToken (SubModuleTab)) != ENDSUBSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->load_comment = xf86addComment(ptr->load_comment, val.str);
+ break;
+ case OPTION:
+ ptr->load_opt = xf86parseOption(ptr->load_opt);
+ break;
+ case EOF_TOKEN:
+ xf86parseError (UNEXPECTED_EOF_MSG, NULL);
+ xf86conffree(ptr);
+ return NULL;
+ default:
+ xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ());
+ xf86conffree(ptr);
+ return NULL;
+ break;
+ }
+
+ }
+
+ return ((XF86LoadPtr) xf86addListItem ((glp) head, (glp) ptr));
+}
+
+XF86ConfModulePtr
+xf86parseModuleSection (void)
+{
+ int token;
+ parsePrologue (XF86ConfModulePtr, XF86ConfModuleRec)
+
+ while ((token = xf86getToken (ModuleTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->mod_comment = xf86addComment(ptr->mod_comment, val.str);
+ break;
+ case LOAD:
+ if (xf86getSubToken (&(ptr->mod_comment)) != STRING)
+ Error (QUOTE_MSG, "Load");
+ ptr->mod_load_lst =
+ xf86addNewLoadDirective (ptr->mod_load_lst, val.str,
+ XF86_LOAD_MODULE, NULL);
+ break;
+ case LOAD_DRIVER:
+ if (xf86getSubToken (&(ptr->mod_comment)) != STRING)
+ Error (QUOTE_MSG, "LoadDriver");
+ ptr->mod_load_lst =
+ xf86addNewLoadDirective (ptr->mod_load_lst, val.str,
+ XF86_LOAD_DRIVER, NULL);
+ break;
+ case SUBSECTION:
+ if (xf86getSubToken (&(ptr->mod_comment)) != STRING)
+ Error (QUOTE_MSG, "SubSection");
+ ptr->mod_load_lst =
+ xf86parseModuleSubSection (ptr->mod_load_lst, val.str);
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ printf ("Module section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printModuleSection (FILE * cf, XF86ConfModulePtr ptr)
+{
+ XF86LoadPtr lptr;
+
+ if (ptr == NULL)
+ return;
+
+ if (ptr->mod_comment)
+ fprintf(cf, "%s", ptr->mod_comment);
+ for (lptr = ptr->mod_load_lst; lptr; lptr = lptr->list.next)
+ {
+ switch (lptr->load_type)
+ {
+ case XF86_LOAD_MODULE:
+ if( lptr->load_opt == NULL ) {
+ fprintf (cf, "\tLoad \"%s\"", lptr->load_name);
+ if (lptr->load_comment)
+ fprintf(cf, "%s", lptr->load_comment);
+ else
+ fputc('\n', cf);
+ }
+ else
+ {
+ fprintf (cf, "\tSubSection \"%s\"\n", lptr->load_name);
+ if (lptr->load_comment)
+ fprintf(cf, "%s", lptr->load_comment);
+ xf86printOptionList(cf, lptr->load_opt, 2);
+ fprintf (cf, "\tEndSubSection\n");
+ }
+ break;
+ case XF86_LOAD_DRIVER:
+ fprintf (cf, "\tLoadDriver \"%s\"", lptr->load_name);
+ if (lptr->load_comment)
+ fprintf(cf, "%s", lptr->load_comment);
+ else
+ fputc('\n', cf);
+ break;
+#if 0
+ default:
+ fprintf (cf, "#\tUnknown type \"%s\"\n", lptr->load_name);
+ break;
+#endif
+ }
+ }
+}
+
+XF86LoadPtr
+xf86addNewLoadDirective (XF86LoadPtr head, char *name, int type, XF86OptionPtr opts)
+{
+ XF86LoadPtr new;
+ int token;
+
+ new = xf86confcalloc (1, sizeof (XF86LoadRec));
+ new->load_name = name;
+ new->load_type = type;
+ new->load_opt = opts;
+ new->list.next = NULL;
+
+ if ((token = xf86getToken(NULL)) == COMMENT)
+ new->load_comment = xf86addComment(new->load_comment, val.str);
+ else
+ xf86unGetToken(token);
+
+ return ((XF86LoadPtr) xf86addListItem ((glp) head, (glp) new));
+}
+
+void
+xf86freeModules (XF86ConfModulePtr ptr)
+{
+ XF86LoadPtr lptr;
+ XF86LoadPtr prev;
+
+ if (ptr == NULL)
+ return;
+ lptr = ptr->mod_load_lst;
+ while (lptr)
+ {
+ TestFree (lptr->load_name);
+ TestFree (lptr->load_comment);
+ prev = lptr;
+ lptr = lptr->list.next;
+ xf86conffree (prev);
+ }
+ TestFree (ptr->mod_comment);
+ xf86conffree (ptr);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Monitor.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Monitor.c
new file mode 100644
index 000000000..52ff5a735
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Monitor.c
@@ -0,0 +1,907 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Monitor.c,v 1.28 2003/08/24 17:37:08 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec MonitorTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {VENDOR, "vendorname"},
+ {MODEL, "modelname"},
+ {USEMODES, "usemodes"},
+ {MODELINE, "modeline"},
+ {DISPLAYSIZE, "displaysize"},
+ {HORIZSYNC, "horizsync"},
+ {VERTREFRESH, "vertrefresh"},
+ {MODE, "mode"},
+ {GAMMA, "gamma"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+static xf86ConfigSymTabRec ModesTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {MODELINE, "modeline"},
+ {MODE, "mode"},
+ {-1, ""},
+};
+
+static xf86ConfigSymTabRec TimingTab[] =
+{
+ {TT_INTERLACE, "interlace"},
+ {TT_PHSYNC, "+hsync"},
+ {TT_NHSYNC, "-hsync"},
+ {TT_PVSYNC, "+vsync"},
+ {TT_NVSYNC, "-vsync"},
+ {TT_CSYNC, "composite"},
+ {TT_PCSYNC, "+csync"},
+ {TT_NCSYNC, "-csync"},
+ {TT_DBLSCAN, "doublescan"},
+ {TT_HSKEW, "hskew"},
+ {TT_BCAST, "bcast"},
+ {TT_VSCAN, "vscan"},
+ {TT_CUSTOM, "CUSTOM"},
+ {-1, ""},
+};
+
+static xf86ConfigSymTabRec ModeTab[] =
+{
+ {DOTCLOCK, "dotclock"},
+ {HTIMINGS, "htimings"},
+ {VTIMINGS, "vtimings"},
+ {FLAGS, "flags"},
+ {HSKEW, "hskew"},
+ {BCAST, "bcast"},
+ {VSCAN, "vscan"},
+ {ENDMODE, "endmode"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeModeLineList
+
+XF86ConfModeLinePtr
+xf86parseModeLine (void)
+{
+ int token;
+ parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec)
+
+ /* Identifier */
+ if (xf86getSubToken (&(ptr->ml_comment)) != STRING)
+ Error ("ModeLine identifier expected", NULL);
+ ptr->ml_identifier = val.str;
+
+ /* DotClock */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine dotclock expected", NULL);
+ ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5);
+
+ /* HDisplay */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine Hdisplay expected", NULL);
+ ptr->ml_hdisplay = val.num;
+
+ /* HSyncStart */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine HSyncStart expected", NULL);
+ ptr->ml_hsyncstart = val.num;
+
+ /* HSyncEnd */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine HSyncEnd expected", NULL);
+ ptr->ml_hsyncend = val.num;
+
+ /* HTotal */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine HTotal expected", NULL);
+ ptr->ml_htotal = val.num;
+
+ /* VDisplay */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine Vdisplay expected", NULL);
+ ptr->ml_vdisplay = val.num;
+
+ /* VSyncStart */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine VSyncStart expected", NULL);
+ ptr->ml_vsyncstart = val.num;
+
+ /* VSyncEnd */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine VSyncEnd expected", NULL);
+ ptr->ml_vsyncend = val.num;
+
+ /* VTotal */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine VTotal expected", NULL);
+ ptr->ml_vtotal = val.num;
+
+ token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab);
+ while ((token == TT_INTERLACE) || (token == TT_PHSYNC) ||
+ (token == TT_NHSYNC) || (token == TT_PVSYNC) ||
+ (token == TT_NVSYNC) || (token == TT_CSYNC) ||
+ (token == TT_PCSYNC) || (token == TT_NCSYNC) ||
+ (token == TT_DBLSCAN) || (token == TT_HSKEW) ||
+ (token == TT_VSCAN) || (token == TT_BCAST))
+ {
+ switch (token)
+ {
+
+ case TT_INTERLACE:
+ ptr->ml_flags |= XF86CONF_INTERLACE;
+ break;
+ case TT_PHSYNC:
+ ptr->ml_flags |= XF86CONF_PHSYNC;
+ break;
+ case TT_NHSYNC:
+ ptr->ml_flags |= XF86CONF_NHSYNC;
+ break;
+ case TT_PVSYNC:
+ ptr->ml_flags |= XF86CONF_PVSYNC;
+ break;
+ case TT_NVSYNC:
+ ptr->ml_flags |= XF86CONF_NVSYNC;
+ break;
+ case TT_CSYNC:
+ ptr->ml_flags |= XF86CONF_CSYNC;
+ break;
+ case TT_PCSYNC:
+ ptr->ml_flags |= XF86CONF_PCSYNC;
+ break;
+ case TT_NCSYNC:
+ ptr->ml_flags |= XF86CONF_NCSYNC;
+ break;
+ case TT_DBLSCAN:
+ ptr->ml_flags |= XF86CONF_DBLSCAN;
+ break;
+ case TT_HSKEW:
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Hskew");
+ ptr->ml_hskew = val.num;
+ ptr->ml_flags |= XF86CONF_HSKEW;
+ break;
+ case TT_BCAST:
+ ptr->ml_flags |= XF86CONF_BCAST;
+ break;
+ case TT_VSCAN:
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Vscan");
+ ptr->ml_vscan = val.num;
+ ptr->ml_flags |= XF86CONF_VSCAN;
+ break;
+ case TT_CUSTOM:
+ ptr->ml_flags |= XF86CONF_CUSTOM;
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab);
+ }
+ xf86unGetToken (token);
+
+#ifdef DEBUG
+ printf ("ModeLine parsed\n");
+#endif
+ return (ptr);
+}
+
+XF86ConfModeLinePtr
+xf86parseVerboseMode (void)
+{
+ int token, token2;
+ int had_dotclock = 0, had_htimings = 0, had_vtimings = 0;
+ parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec)
+
+ if (xf86getSubToken (&(ptr->ml_comment)) != STRING)
+ Error ("Mode name expected", NULL);
+ ptr->ml_identifier = val.str;
+ while ((token = xf86getToken (ModeTab)) != ENDMODE)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->ml_comment = xf86addComment(ptr->ml_comment, val.str);
+ break;
+ case DOTCLOCK:
+ if ((token = xf86getSubToken (&(ptr->ml_comment))) != NUMBER)
+ Error (NUMBER_MSG, "DotClock");
+ ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5);
+ had_dotclock = 1;
+ break;
+ case HTIMINGS:
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_hdisplay = val.num;
+ else
+ Error ("Horizontal display expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_hsyncstart = val.num;
+ else
+ Error ("Horizontal sync start expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_hsyncend = val.num;
+ else
+ Error ("Horizontal sync end expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_htotal = val.num;
+ else
+ Error ("Horizontal total expected", NULL);
+ had_htimings = 1;
+ break;
+ case VTIMINGS:
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_vdisplay = val.num;
+ else
+ Error ("Vertical display expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_vsyncstart = val.num;
+ else
+ Error ("Vertical sync start expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_vsyncend = val.num;
+ else
+ Error ("Vertical sync end expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_vtotal = val.num;
+ else
+ Error ("Vertical total expected", NULL);
+ had_vtimings = 1;
+ break;
+ case FLAGS:
+ token = xf86getSubToken (&(ptr->ml_comment));
+ if (token != STRING)
+ Error (QUOTE_MSG, "Flags");
+ while (token == STRING)
+ {
+ token2 = xf86getStringToken (TimingTab);
+ switch (token2)
+ {
+ case TT_INTERLACE:
+ ptr->ml_flags |= XF86CONF_INTERLACE;
+ break;
+ case TT_PHSYNC:
+ ptr->ml_flags |= XF86CONF_PHSYNC;
+ break;
+ case TT_NHSYNC:
+ ptr->ml_flags |= XF86CONF_NHSYNC;
+ break;
+ case TT_PVSYNC:
+ ptr->ml_flags |= XF86CONF_PVSYNC;
+ break;
+ case TT_NVSYNC:
+ ptr->ml_flags |= XF86CONF_NVSYNC;
+ break;
+ case TT_CSYNC:
+ ptr->ml_flags |= XF86CONF_CSYNC;
+ break;
+ case TT_PCSYNC:
+ ptr->ml_flags |= XF86CONF_PCSYNC;
+ break;
+ case TT_NCSYNC:
+ ptr->ml_flags |= XF86CONF_NCSYNC;
+ break;
+ case TT_DBLSCAN:
+ ptr->ml_flags |= XF86CONF_DBLSCAN;
+ break;
+ case TT_CUSTOM:
+ ptr->ml_flags |= XF86CONF_CUSTOM;
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error ("Unknown flag string", NULL);
+ break;
+ }
+ token = xf86getSubToken (&(ptr->ml_comment));
+ }
+ xf86unGetToken (token);
+ break;
+ case HSKEW:
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("Horizontal skew expected", NULL);
+ ptr->ml_flags |= XF86CONF_HSKEW;
+ ptr->ml_hskew = val.num;
+ break;
+ case VSCAN:
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("Vertical scan count expected", NULL);
+ ptr->ml_flags |= XF86CONF_VSCAN;
+ ptr->ml_vscan = val.num;
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error ("Unexepcted token in verbose \"Mode\" entry\n", NULL);
+ }
+ }
+ if (!had_dotclock)
+ Error ("the dotclock is missing", NULL);
+ if (!had_htimings)
+ Error ("the horizontal timings are missing", NULL);
+ if (!had_vtimings)
+ Error ("the vertical timings are missing", NULL);
+
+#ifdef DEBUG
+ printf ("Verbose Mode parsed\n");
+#endif
+ return (ptr);
+}
+
+#undef CLEANUP
+
+#define CLEANUP xf86freeMonitorList
+
+XF86ConfMonitorPtr
+xf86parseMonitorSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
+
+ while ((token = xf86getToken (MonitorTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->mon_comment = xf86addComment(ptr->mon_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->mon_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case VENDOR:
+ if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
+ Error (QUOTE_MSG, "Vendor");
+ ptr->mon_vendor = val.str;
+ break;
+ case MODEL:
+ if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
+ Error (QUOTE_MSG, "ModelName");
+ ptr->mon_modelname = val.str;
+ break;
+ case MODE:
+ HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode,
+ XF86ConfModeLinePtr);
+ break;
+ case MODELINE:
+ HANDLE_LIST (mon_modeline_lst, xf86parseModeLine,
+ XF86ConfModeLinePtr);
+ break;
+ case DISPLAYSIZE:
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
+ Error (DISPLAYSIZE_MSG, NULL);
+ ptr->mon_width = val.realnum;
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
+ Error (DISPLAYSIZE_MSG, NULL);
+ ptr->mon_height = val.realnum;
+ break;
+
+ case HORIZSYNC:
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
+ Error (HORIZSYNC_MSG, NULL);
+ do {
+ ptr->mon_hsync[ptr->mon_n_hsync].lo = val.realnum;
+ switch (token = xf86getSubToken (&(ptr->mon_comment)))
+ {
+ case COMMA:
+ ptr->mon_hsync[ptr->mon_n_hsync].hi =
+ ptr->mon_hsync[ptr->mon_n_hsync].lo;
+ break;
+ case DASH:
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER ||
+ (float)val.realnum < ptr->mon_hsync[ptr->mon_n_hsync].lo)
+ Error (HORIZSYNC_MSG, NULL);
+ ptr->mon_hsync[ptr->mon_n_hsync].hi = val.realnum;
+ if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA)
+ break;
+ ptr->mon_n_hsync++;
+ goto HorizDone;
+ default:
+ /* We cannot currently know if a '\n' was found,
+ * or this is a real error
+ */
+ ptr->mon_hsync[ptr->mon_n_hsync].hi =
+ ptr->mon_hsync[ptr->mon_n_hsync].lo;
+ ptr->mon_n_hsync++;
+ goto HorizDone;
+ }
+ if (ptr->mon_n_hsync >= CONF_MAX_HSYNC)
+ Error ("Sorry. Too many horizontal sync intervals.", NULL);
+ ptr->mon_n_hsync++;
+ } while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER);
+HorizDone:
+ xf86unGetToken (token);
+ break;
+
+ case VERTREFRESH:
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
+ Error (VERTREFRESH_MSG, NULL);
+ do {
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo = val.realnum;
+ switch (token = xf86getSubToken (&(ptr->mon_comment)))
+ {
+ case COMMA:
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi =
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo;
+ break;
+ case DASH:
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER ||
+ (float)val.realnum < ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo)
+ Error (VERTREFRESH_MSG, NULL);
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = val.realnum;
+ if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA)
+ break;
+ ptr->mon_n_vrefresh++;
+ goto VertDone;
+ default:
+ /* We cannot currently know if a '\n' was found,
+ * or this is a real error
+ */
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi =
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo;
+ ptr->mon_n_vrefresh++;
+ goto VertDone;
+ }
+ if (ptr->mon_n_vrefresh >= CONF_MAX_VREFRESH)
+ Error ("Sorry. Too many vertical refresh intervals.", NULL);
+ ptr->mon_n_vrefresh++;
+ } while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER);
+VertDone:
+ xf86unGetToken (token);
+ break;
+
+ case GAMMA:
+ if( xf86getSubToken (&(ptr->mon_comment)) != NUMBER )
+ {
+ Error (INVALID_GAMMA_MSG, NULL);
+ }
+ else
+ {
+ ptr->mon_gamma_red = ptr->mon_gamma_green =
+ ptr->mon_gamma_blue = val.realnum;
+ if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER )
+ {
+ ptr->mon_gamma_green = val.realnum;
+ if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER )
+ {
+ ptr->mon_gamma_blue = val.realnum;
+ }
+ else
+ {
+ Error (INVALID_GAMMA_MSG, NULL);
+ }
+ }
+ else
+ xf86unGetToken (token);
+ }
+ break;
+ case OPTION:
+ ptr->mon_option_lst = xf86parseOption(ptr->mon_option_lst);
+ break;
+ case USEMODES:
+ {
+ XF86ConfModesLinkPtr mptr;
+
+ if ((token = xf86getSubToken (&(ptr->mon_comment))) != STRING)
+ Error (QUOTE_MSG, "UseModes");
+
+ /* add to the end of the list of modes sections
+ referenced here */
+ mptr = xf86confcalloc (1, sizeof (XF86ConfModesLinkRec));
+ mptr->list.next = NULL;
+ mptr->ml_modes_str = val.str;
+ mptr->ml_modes = NULL;
+ ptr->mon_modes_sect_lst = (XF86ConfModesLinkPtr)
+ xf86addListItem((GenericListPtr)ptr->mon_modes_sect_lst,
+ (GenericListPtr)mptr);
+ }
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ());
+ CLEANUP (ptr);
+ return NULL;
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Monitor section parsed\n");
+#endif
+ return ptr;
+}
+
+#undef CLEANUP
+#define CLEANUP xf86freeModesList
+
+XF86ConfModesPtr
+xf86parseModesSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfModesPtr, XF86ConfModesRec)
+
+ while ((token = xf86getToken (ModesTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->modes_comment = xf86addComment(ptr->modes_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->modes_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->modes_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case MODE:
+ HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode,
+ XF86ConfModeLinePtr);
+ break;
+ case MODELINE:
+ HANDLE_LIST (mon_modeline_lst, xf86parseModeLine,
+ XF86ConfModeLinePtr);
+ break;
+ default:
+ xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ());
+ CLEANUP (ptr);
+ return NULL;
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Modes section parsed\n");
+#endif
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printMonitorSection (FILE * cf, XF86ConfMonitorPtr ptr)
+{
+ int i;
+ XF86ConfModeLinePtr mlptr;
+ XF86ConfModesLinkPtr mptr;
+
+ while (ptr)
+ {
+ mptr = ptr->mon_modes_sect_lst;
+ fprintf (cf, "Section \"Monitor\"\n");
+ if (ptr->mon_comment)
+ fprintf (cf, "%s", ptr->mon_comment);
+ if (ptr->mon_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->mon_identifier);
+ if (ptr->mon_vendor)
+ fprintf (cf, "\tVendorName \"%s\"\n", ptr->mon_vendor);
+ if (ptr->mon_modelname)
+ fprintf (cf, "\tModelName \"%s\"\n", ptr->mon_modelname);
+ while (mptr) {
+ fprintf (cf, "\tUseModes \"%s\"\n", mptr->ml_modes_str);
+ mptr = mptr->list.next;
+ }
+ if (ptr->mon_width)
+ fprintf (cf, "\tDisplaySize %d\t%d\n",
+ ptr->mon_width,
+ ptr->mon_height);
+ if ( ptr->mon_n_hsync || ptr->mon_n_vrefresh )
+ fprintf(cf," ### Comment all HorizSync and VertSync values to use DDC:\n");
+ for (i = 0; i < ptr->mon_n_hsync; i++)
+ {
+ fprintf (cf, "\tHorizSync %2.1f - %2.1f\n",
+ ptr->mon_hsync[i].lo,
+ ptr->mon_hsync[i].hi);
+ }
+ for (i = 0; i < ptr->mon_n_vrefresh; i++)
+ {
+ fprintf (cf, "\tVertRefresh %2.1f - %2.1f\n",
+ ptr->mon_vrefresh[i].lo,
+ ptr->mon_vrefresh[i].hi);
+ }
+ if (ptr->mon_gamma_red) {
+ if (ptr->mon_gamma_red == ptr->mon_gamma_green
+ && ptr->mon_gamma_red == ptr->mon_gamma_blue)
+ {
+ fprintf (cf, "\tGamma %.4g\n",
+ ptr->mon_gamma_red);
+ } else {
+ fprintf (cf, "\tGamma %.4g %.4g %.4g\n",
+ ptr->mon_gamma_red,
+ ptr->mon_gamma_green,
+ ptr->mon_gamma_blue);
+ }
+ }
+ for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next)
+ {
+ fprintf (cf, "\tModeLine \"%s\" %2.1f ",
+ mlptr->ml_identifier, mlptr->ml_clock / 1000.0);
+ fprintf (cf, "%d %d %d %d %d %d %d %d",
+ mlptr->ml_hdisplay, mlptr->ml_hsyncstart,
+ mlptr->ml_hsyncend, mlptr->ml_htotal,
+ mlptr->ml_vdisplay, mlptr->ml_vsyncstart,
+ mlptr->ml_vsyncend, mlptr->ml_vtotal);
+ if (mlptr->ml_flags & XF86CONF_PHSYNC)
+ fprintf (cf, " +hsync");
+ if (mlptr->ml_flags & XF86CONF_NHSYNC)
+ fprintf (cf, " -hsync");
+ if (mlptr->ml_flags & XF86CONF_PVSYNC)
+ fprintf (cf, " +vsync");
+ if (mlptr->ml_flags & XF86CONF_NVSYNC)
+ fprintf (cf, " -vsync");
+ if (mlptr->ml_flags & XF86CONF_INTERLACE)
+ fprintf (cf, " interlace");
+ if (mlptr->ml_flags & XF86CONF_CSYNC)
+ fprintf (cf, " composite");
+ if (mlptr->ml_flags & XF86CONF_PCSYNC)
+ fprintf (cf, " +csync");
+ if (mlptr->ml_flags & XF86CONF_NCSYNC)
+ fprintf (cf, " -csync");
+ if (mlptr->ml_flags & XF86CONF_DBLSCAN)
+ fprintf (cf, " doublescan");
+ if (mlptr->ml_flags & XF86CONF_HSKEW)
+ fprintf (cf, " hskew %d", mlptr->ml_hskew);
+ if (mlptr->ml_flags & XF86CONF_BCAST)
+ fprintf (cf, " bcast");
+ fprintf (cf, "\n");
+ }
+ xf86printOptionList(cf, ptr->mon_option_lst, 1);
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86printModesSection (FILE * cf, XF86ConfModesPtr ptr)
+{
+ XF86ConfModeLinePtr mlptr;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"Modes\"\n");
+ if (ptr->modes_comment)
+ fprintf (cf, "%s", ptr->modes_comment);
+ if (ptr->modes_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->modes_identifier);
+ for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next)
+ {
+ fprintf (cf, "\tModeLine \"%s\" %2.1f ",
+ mlptr->ml_identifier, mlptr->ml_clock / 1000.0);
+ fprintf (cf, "%d %d %d %d %d %d %d %d",
+ mlptr->ml_hdisplay, mlptr->ml_hsyncstart,
+ mlptr->ml_hsyncend, mlptr->ml_htotal,
+ mlptr->ml_vdisplay, mlptr->ml_vsyncstart,
+ mlptr->ml_vsyncend, mlptr->ml_vtotal);
+ if (mlptr->ml_flags & XF86CONF_PHSYNC)
+ fprintf (cf, " +hsync");
+ if (mlptr->ml_flags & XF86CONF_NHSYNC)
+ fprintf (cf, " -hsync");
+ if (mlptr->ml_flags & XF86CONF_PVSYNC)
+ fprintf (cf, " +vsync");
+ if (mlptr->ml_flags & XF86CONF_NVSYNC)
+ fprintf (cf, " -vsync");
+ if (mlptr->ml_flags & XF86CONF_INTERLACE)
+ fprintf (cf, " interlace");
+ if (mlptr->ml_flags & XF86CONF_CSYNC)
+ fprintf (cf, " composite");
+ if (mlptr->ml_flags & XF86CONF_PCSYNC)
+ fprintf (cf, " +csync");
+ if (mlptr->ml_flags & XF86CONF_NCSYNC)
+ fprintf (cf, " -csync");
+ if (mlptr->ml_flags & XF86CONF_DBLSCAN)
+ fprintf (cf, " doublescan");
+ if (mlptr->ml_flags & XF86CONF_HSKEW)
+ fprintf (cf, " hskew %d", mlptr->ml_hskew);
+ if (mlptr->ml_flags & XF86CONF_VSCAN)
+ fprintf (cf, " vscan %d", mlptr->ml_vscan);
+ if (mlptr->ml_flags & XF86CONF_BCAST)
+ fprintf (cf, " bcast");
+ if (mlptr->ml_comment)
+ fprintf (cf, "%s", mlptr->ml_comment);
+ else
+ fprintf (cf, "\n");
+ }
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86freeMonitorList (XF86ConfMonitorPtr ptr)
+{
+ XF86ConfMonitorPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->mon_identifier);
+ TestFree (ptr->mon_vendor);
+ TestFree (ptr->mon_modelname);
+ TestFree (ptr->mon_comment);
+ xf86optionListFree (ptr->mon_option_lst);
+ xf86freeModeLineList (ptr->mon_modeline_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ xf86conffree (prev);
+ }
+}
+
+void
+xf86freeModesList (XF86ConfModesPtr ptr)
+{
+ XF86ConfModesPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->modes_identifier);
+ TestFree (ptr->modes_comment);
+ xf86freeModeLineList (ptr->mon_modeline_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ xf86conffree (prev);
+ }
+}
+
+void
+xf86freeModeLineList (XF86ConfModeLinePtr ptr)
+{
+ XF86ConfModeLinePtr prev;
+ while (ptr)
+ {
+ TestFree (ptr->ml_identifier);
+ TestFree (ptr->ml_comment);
+ prev = ptr;
+ ptr = ptr->list.next;
+ xf86conffree (prev);
+ }
+}
+
+XF86ConfMonitorPtr
+xf86findMonitor (const char *ident, XF86ConfMonitorPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->mon_identifier) == 0)
+ return (p);
+
+ p = p->list.next;
+ }
+ return (NULL);
+}
+
+XF86ConfModesPtr
+xf86findModes (const char *ident, XF86ConfModesPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->modes_identifier) == 0)
+ return (p);
+
+ p = p->list.next;
+ }
+ return (NULL);
+}
+
+XF86ConfModeLinePtr
+xf86findModeLine (const char *ident, XF86ConfModeLinePtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->ml_identifier) == 0)
+ return (p);
+
+ p = p->list.next;
+ }
+ return (NULL);
+}
+
+int
+xf86validateMonitor (XF86ConfigPtr p, XF86ConfScreenPtr screen)
+{
+ XF86ConfMonitorPtr monitor = screen->scrn_monitor;
+ XF86ConfModesLinkPtr modeslnk = monitor->mon_modes_sect_lst;
+ XF86ConfModesPtr modes;
+ while(modeslnk)
+ {
+ modes = xf86findModes (modeslnk->ml_modes_str, p->conf_modes_lst);
+ if (!modes)
+ {
+ xf86validationError (UNDEFINED_MODES_MSG,
+ modeslnk->ml_modes_str,
+ screen->scrn_identifier);
+ return (FALSE);
+ }
+ modeslnk->ml_modes = modes;
+ modeslnk = modeslnk->list.next;
+ }
+ return (TRUE);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Pointer.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Pointer.c
new file mode 100644
index 000000000..81984a3e7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Pointer.c
@@ -0,0 +1,236 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Pointer.c,v 1.13 2003/08/24 17:37:08 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec PointerTab[] =
+{
+ {PROTOCOL, "protocol"},
+ {EMULATE3, "emulate3buttons"},
+ {EM3TIMEOUT, "emulate3timeout"},
+ {ENDSUBSECTION, "endsubsection"},
+ {ENDSECTION, "endsection"},
+ {PDEVICE, "device"},
+ {PDEVICE, "port"},
+ {BAUDRATE, "baudrate"},
+ {SAMPLERATE, "samplerate"},
+ {CLEARDTR, "cleardtr"},
+ {CLEARRTS, "clearrts"},
+ {CHORDMIDDLE, "chordmiddle"},
+ {PRESOLUTION, "resolution"},
+ {DEVICE_NAME, "devicename"},
+ {ALWAYSCORE, "alwayscore"},
+ {PBUTTONS, "buttons"},
+ {ZAXISMAPPING, "zaxismapping"},
+ {-1, ""},
+};
+
+static xf86ConfigSymTabRec ZMapTab[] =
+{
+ {XAXIS, "x"},
+ {YAXIS, "y"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeInputList
+
+XF86ConfInputPtr
+xf86parsePointerSection (void)
+{
+ char *s, *s1, *s2;
+ int l;
+ int token;
+ parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
+
+ while ((token = xf86getToken (PointerTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
+ break;
+ case PROTOCOL:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "Protocol");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("Protocol"),
+ val.str);
+ break;
+ case PDEVICE:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "Device");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("Device"),
+ val.str);
+ break;
+ case EMULATE3:
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("Emulate3Buttons"),
+ NULL);
+ break;
+ case EM3TIMEOUT:
+ if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0)
+ Error (POSITIVE_INT_MSG, "Emulate3Timeout");
+ s = xf86uLongToString(val.num);
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("Emulate3Timeout"),
+ s);
+ break;
+ case CHORDMIDDLE:
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("ChordMiddle"),
+ NULL);
+ break;
+ case PBUTTONS:
+ if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0)
+ Error (POSITIVE_INT_MSG, "Buttons");
+ s = xf86uLongToString(val.num);
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("Buttons"), s);
+ break;
+ case BAUDRATE:
+ if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0)
+ Error (POSITIVE_INT_MSG, "BaudRate");
+ s = xf86uLongToString(val.num);
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("BaudRate"), s);
+ break;
+ case SAMPLERATE:
+ if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0)
+ Error (POSITIVE_INT_MSG, "SampleRate");
+ s = xf86uLongToString(val.num);
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("SampleRate"), s);
+ break;
+ case PRESOLUTION:
+ if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0)
+ Error (POSITIVE_INT_MSG, "Resolution");
+ s = xf86uLongToString(val.num);
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("Resolution"), s);
+ break;
+ case CLEARDTR:
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("ClearDTR"), NULL);
+ break;
+ case CLEARRTS:
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("ClearRTS"), NULL);
+ break;
+ case ZAXISMAPPING:
+ switch (xf86getToken(ZMapTab)) {
+ case NUMBER:
+ if (val.num < 0)
+ Error (ZAXISMAPPING_MSG, NULL);
+ s1 = xf86uLongToString(val.num);
+ if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0)
+ Error (ZAXISMAPPING_MSG, NULL);
+ s2 = xf86uLongToString(val.num);
+ l = strlen(s1) + 1 + strlen(s2) + 1;
+ s = xf86confmalloc(l);
+ sprintf(s, "%s %s", s1, s2);
+ xf86conffree(s1);
+ xf86conffree(s2);
+ break;
+ case XAXIS:
+ s = xf86configStrdup("x");
+ break;
+ case YAXIS:
+ s = xf86configStrdup("y");
+ break;
+ default:
+ Error (ZAXISMAPPING_MSG, NULL);
+ break;
+ }
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("ZAxisMapping"),
+ s);
+ break;
+ case ALWAYSCORE:
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ ptr->inp_identifier = xf86configStrdup(CONF_IMPLICIT_POINTER);
+ ptr->inp_driver = xf86configStrdup("mouse");
+ ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
+ xf86configStrdup("CorePointer"), NULL);
+
+#ifdef DEBUG
+ printf ("Pointer section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Screen.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Screen.c
new file mode 100644
index 000000000..d572af56c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Screen.c
@@ -0,0 +1,578 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Screen.c,v 1.28 2003/11/07 23:41:41 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec DisplayTab[] =
+{
+ {ENDSUBSECTION, "endsubsection"},
+ {MODES, "modes"},
+ {VIEWPORT, "viewport"},
+ {VIRTUAL, "virtual"},
+ {VISUAL, "visual"},
+ {BLACK_TOK, "black"},
+ {WHITE_TOK, "white"},
+ {DEPTH, "depth"},
+ {BPP, "fbbpp"},
+ {WEIGHT, "weight"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeDisplayList
+
+XF86ConfDisplayPtr
+xf86parseDisplaySubSection (void)
+{
+ int token;
+ parsePrologue (XF86ConfDisplayPtr, XF86ConfDisplayRec)
+
+ ptr->disp_black.red = ptr->disp_black.green = ptr->disp_black.blue = -1;
+ ptr->disp_white.red = ptr->disp_white.green = ptr->disp_white.blue = -1;
+ ptr->disp_frameX0 = ptr->disp_frameY0 = -1;
+ while ((token = xf86getToken (DisplayTab)) != ENDSUBSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->disp_comment = xf86addComment(ptr->disp_comment, val.str);
+ break;
+ case VIEWPORT:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (VIEWPORT_MSG, NULL);
+ ptr->disp_frameX0 = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (VIEWPORT_MSG, NULL);
+ ptr->disp_frameY0 = val.num;
+ break;
+ case VIRTUAL:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (VIRTUAL_MSG, NULL);
+ ptr->disp_virtualX = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (VIRTUAL_MSG, NULL);
+ ptr->disp_virtualY = val.num;
+ break;
+ case DEPTH:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Display");
+ ptr->disp_depth = val.num;
+ break;
+ case BPP:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Display");
+ ptr->disp_bpp = val.num;
+ break;
+ case VISUAL:
+ if (xf86getSubToken (&(ptr->disp_comment)) != STRING)
+ Error (QUOTE_MSG, "Display");
+ ptr->disp_visual = val.str;
+ break;
+ case WEIGHT:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WEIGHT_MSG, NULL);
+ ptr->disp_weight.red = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WEIGHT_MSG, NULL);
+ ptr->disp_weight.green = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WEIGHT_MSG, NULL);
+ ptr->disp_weight.blue = val.num;
+ break;
+ case BLACK_TOK:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (BLACK_MSG, NULL);
+ ptr->disp_black.red = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (BLACK_MSG, NULL);
+ ptr->disp_black.green = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (BLACK_MSG, NULL);
+ ptr->disp_black.blue = val.num;
+ break;
+ case WHITE_TOK:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WHITE_MSG, NULL);
+ ptr->disp_white.red = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WHITE_MSG, NULL);
+ ptr->disp_white.green = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WHITE_MSG, NULL);
+ ptr->disp_white.blue = val.num;
+ break;
+ case MODES:
+ {
+ XF86ModePtr mptr;
+
+ while ((token = xf86getSubTokenWithTab (&(ptr->disp_comment), DisplayTab)) == STRING)
+ {
+ mptr = xf86confcalloc (1, sizeof (XF86ModeRec));
+ mptr->mode_name = val.str;
+ mptr->list.next = NULL;
+ ptr->disp_mode_lst = (XF86ModePtr)
+ xf86addListItem ((glp) ptr->disp_mode_lst, (glp) mptr);
+ }
+ xf86unGetToken (token);
+ }
+ break;
+ case OPTION:
+ ptr->disp_option_lst = xf86parseOption(ptr->disp_option_lst);
+ break;
+
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ printf ("Display subsection parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+static xf86ConfigSymTabRec ScreenTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {OBSDRIVER, "driver"},
+ {MDEVICE, "device"},
+ {MONITOR, "monitor"},
+ {VIDEOADAPTOR, "videoadaptor"},
+ {SCREENNO, "screenno"},
+ {SUBSECTION, "subsection"},
+ {DEFAULTDEPTH, "defaultcolordepth"},
+ {DEFAULTDEPTH, "defaultdepth"},
+ {DEFAULTBPP, "defaultbpp"},
+ {DEFAULTFBBPP, "defaultfbbpp"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeScreenList
+XF86ConfScreenPtr
+xf86parseScreenSection (void)
+{
+ int has_ident = FALSE;
+ int has_driver= FALSE;
+ int token;
+
+ parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
+
+ while ((token = xf86getToken (ScreenTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->scrn_comment = xf86addComment(ptr->scrn_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ ptr->scrn_identifier = val.str;
+ if (has_ident || has_driver)
+ Error (ONLY_ONE_MSG,"Identifier or Driver");
+ has_ident = TRUE;
+ break;
+ case OBSDRIVER:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "Driver");
+ ptr->scrn_obso_driver = val.str;
+ if (has_ident || has_driver)
+ Error (ONLY_ONE_MSG,"Identifier or Driver");
+ has_driver = TRUE;
+ break;
+ case DEFAULTDEPTH:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
+ Error (NUMBER_MSG, "DefaultDepth");
+ ptr->scrn_defaultdepth = val.num;
+ break;
+ case DEFAULTBPP:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
+ Error (NUMBER_MSG, "DefaultBPP");
+ ptr->scrn_defaultbpp = val.num;
+ break;
+ case DEFAULTFBBPP:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
+ Error (NUMBER_MSG, "DefaultFbBPP");
+ ptr->scrn_defaultfbbpp = val.num;
+ break;
+ case MDEVICE:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "Device");
+ ptr->scrn_device_str = val.str;
+ break;
+ case MONITOR:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "Monitor");
+ ptr->scrn_monitor_str = val.str;
+ break;
+ case VIDEOADAPTOR:
+ {
+ XF86ConfAdaptorLinkPtr aptr;
+
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "VideoAdaptor");
+
+ /* Don't allow duplicates */
+ for (aptr = ptr->scrn_adaptor_lst; aptr;
+ aptr = (XF86ConfAdaptorLinkPtr) aptr->list.next)
+ if (xf86nameCompare (val.str, aptr->al_adaptor_str) == 0)
+ break;
+
+ if (aptr == NULL)
+ {
+ aptr = xf86confcalloc (1, sizeof (XF86ConfAdaptorLinkRec));
+ aptr->list.next = NULL;
+ aptr->al_adaptor_str = val.str;
+ ptr->scrn_adaptor_lst = (XF86ConfAdaptorLinkPtr)
+ xf86addListItem ((glp) ptr->scrn_adaptor_lst, (glp) aptr);
+ }
+ }
+ break;
+ case OPTION:
+ ptr->scrn_option_lst = xf86parseOption(ptr->scrn_option_lst);
+ break;
+ case SUBSECTION:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "SubSection");
+ {
+ xf86conffree(val.str);
+ HANDLE_LIST (scrn_display_lst, xf86parseDisplaySubSection,
+ XF86ConfDisplayPtr);
+ }
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident && !has_driver)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Screen section parsed\n");
+#endif
+
+ return ptr;
+}
+
+void
+xf86printScreenSection (FILE * cf, XF86ConfScreenPtr ptr)
+{
+ XF86ConfAdaptorLinkPtr aptr;
+ XF86ConfDisplayPtr dptr;
+ XF86ModePtr mptr;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"Screen\"\n");
+ if (ptr->scrn_comment)
+ fprintf (cf, "%s", ptr->scrn_comment);
+ if (ptr->scrn_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->scrn_identifier);
+ if (ptr->scrn_obso_driver)
+ fprintf (cf, "\tDriver \"%s\"\n", ptr->scrn_obso_driver);
+ if (ptr->scrn_device_str)
+ fprintf (cf, "\tDevice \"%s\"\n", ptr->scrn_device_str);
+ if (ptr->scrn_monitor_str)
+ fprintf (cf, "\tMonitor \"%s\"\n", ptr->scrn_monitor_str);
+ if (ptr->scrn_defaultdepth)
+ fprintf (cf, "\tDefaultDepth %d\n",
+ ptr->scrn_defaultdepth);
+ if (ptr->scrn_defaultbpp)
+ fprintf (cf, "\tDefaultBPP %d\n",
+ ptr->scrn_defaultbpp);
+ if (ptr->scrn_defaultfbbpp)
+ fprintf (cf, "\tDefaultFbBPP %d\n",
+ ptr->scrn_defaultfbbpp);
+ xf86printOptionList(cf, ptr->scrn_option_lst, 1);
+ for (aptr = ptr->scrn_adaptor_lst; aptr; aptr = aptr->list.next)
+ {
+ fprintf (cf, "\tVideoAdaptor \"%s\"\n", aptr->al_adaptor_str);
+ }
+ for (dptr = ptr->scrn_display_lst; dptr; dptr = dptr->list.next)
+ {
+ fprintf (cf, "\tSubSection \"Display\"\n");
+ if (dptr->disp_comment)
+ fprintf (cf, "%s", dptr->disp_comment);
+ if (dptr->disp_frameX0 >= 0 || dptr->disp_frameY0 >= 0)
+ {
+ fprintf (cf, "\t\tViewport %d %d\n",
+ dptr->disp_frameX0, dptr->disp_frameY0);
+ }
+ if (dptr->disp_virtualX != 0 || dptr->disp_virtualY != 0)
+ {
+ fprintf (cf, "\t\tVirtual %d %d\n",
+ dptr->disp_virtualX, dptr->disp_virtualY);
+ }
+ if (dptr->disp_depth)
+ {
+ fprintf (cf, "\t\tDepth %d\n", dptr->disp_depth);
+ }
+ if (dptr->disp_bpp)
+ {
+ fprintf (cf, "\t\tFbBPP %d\n", dptr->disp_bpp);
+ }
+ if (dptr->disp_visual)
+ {
+ fprintf (cf, "\t\tVisual \"%s\"\n", dptr->disp_visual);
+ }
+ if (dptr->disp_weight.red != 0)
+ {
+ fprintf (cf, "\t\tWeight %d %d %d\n",
+ dptr->disp_weight.red, dptr->disp_weight.green, dptr->disp_weight.blue);
+ }
+ if (dptr->disp_black.red != -1)
+ {
+ fprintf (cf, "\t\tBlack 0x%04x 0x%04x 0x%04x\n",
+ dptr->disp_black.red, dptr->disp_black.green, dptr->disp_black.blue);
+ }
+ if (dptr->disp_white.red != -1)
+ {
+ fprintf (cf, "\t\tWhite 0x%04x 0x%04x 0x%04x\n",
+ dptr->disp_white.red, dptr->disp_white.green, dptr->disp_white.blue);
+ }
+ if (dptr->disp_mode_lst)
+ {
+ fprintf (cf, "\t\tModes ");
+ }
+ for (mptr = dptr->disp_mode_lst; mptr; mptr = mptr->list.next)
+ {
+ fprintf (cf, " \"%s\"", mptr->mode_name);
+ }
+ if (dptr->disp_mode_lst)
+ {
+ fprintf (cf, "\n");
+ }
+ xf86printOptionList(cf, dptr->disp_option_lst, 2);
+ fprintf (cf, "\tEndSubSection\n");
+ }
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+
+}
+
+void
+xf86freeScreenList (XF86ConfScreenPtr ptr)
+{
+ XF86ConfScreenPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->scrn_identifier);
+ TestFree (ptr->scrn_monitor_str);
+ TestFree (ptr->scrn_device_str);
+ TestFree (ptr->scrn_comment);
+ xf86optionListFree (ptr->scrn_option_lst);
+ xf86freeAdaptorLinkList (ptr->scrn_adaptor_lst);
+ xf86freeDisplayList (ptr->scrn_display_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ xf86conffree (prev);
+ }
+}
+
+void
+xf86freeAdaptorLinkList (XF86ConfAdaptorLinkPtr ptr)
+{
+ XF86ConfAdaptorLinkPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->al_adaptor_str);
+ prev = ptr;
+ ptr = ptr->list.next;
+ xf86conffree (prev);
+ }
+}
+
+void
+xf86freeDisplayList (XF86ConfDisplayPtr ptr)
+{
+ XF86ConfDisplayPtr prev;
+
+ while (ptr)
+ {
+ xf86freeModeList (ptr->disp_mode_lst);
+ xf86optionListFree (ptr->disp_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ xf86conffree (prev);
+ }
+}
+
+void
+xf86freeModeList (XF86ModePtr ptr)
+{
+ XF86ModePtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->mode_name);
+ prev = ptr;
+ ptr = ptr->list.next;
+ xf86conffree (prev);
+ }
+}
+
+int
+xf86validateScreen (XF86ConfigPtr p)
+{
+ XF86ConfScreenPtr screen = p->conf_screen_lst;
+ XF86ConfMonitorPtr monitor;
+ XF86ConfDevicePtr device;
+ XF86ConfAdaptorLinkPtr adaptor;
+
+ if (!screen)
+ {
+ xf86validationError ("At least one Screen section is required.");
+ return (FALSE);
+ }
+
+ while (screen)
+ {
+ if (screen->scrn_obso_driver && !screen->scrn_identifier)
+ screen->scrn_identifier = screen->scrn_obso_driver;
+
+ monitor = xf86findMonitor (screen->scrn_monitor_str, p->conf_monitor_lst);
+ if (screen->scrn_monitor_str)
+ {
+ if (!monitor)
+ {
+ xf86validationError (UNDEFINED_MONITOR_MSG,
+ screen->scrn_monitor_str, screen->scrn_identifier);
+ return (FALSE);
+ }
+ else
+ {
+ screen->scrn_monitor = monitor;
+ if (!xf86validateMonitor(p, screen))
+ return (FALSE);
+ }
+ }
+
+ device = xf86findDevice (screen->scrn_device_str, p->conf_device_lst);
+ if (!device)
+ {
+ xf86validationError (UNDEFINED_DEVICE_MSG,
+ screen->scrn_device_str, screen->scrn_identifier);
+ return (FALSE);
+ }
+ else
+ screen->scrn_device = device;
+
+ adaptor = screen->scrn_adaptor_lst;
+ while (adaptor)
+ {
+ adaptor->al_adaptor = xf86findVideoAdaptor (adaptor->al_adaptor_str, p->conf_videoadaptor_lst);
+ if (!adaptor->al_adaptor)
+ {
+ xf86validationError (UNDEFINED_ADAPTOR_MSG, adaptor->al_adaptor_str, screen->scrn_identifier);
+ return (FALSE);
+ }
+ else if (adaptor->al_adaptor->va_fwdref)
+ {
+ xf86validationError (ADAPTOR_REF_TWICE_MSG, adaptor->al_adaptor_str,
+ adaptor->al_adaptor->va_fwdref);
+ return (FALSE);
+ }
+
+ adaptor->al_adaptor->va_fwdref = xf86configStrdup(screen->scrn_identifier);
+ adaptor = adaptor->list.next;
+ }
+
+ screen = screen->list.next;
+ }
+
+ return (TRUE);
+}
+
+XF86ConfScreenPtr
+xf86findScreen (const char *ident, XF86ConfScreenPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->scrn_identifier) == 0)
+ return (p);
+
+ p = p->list.next;
+ }
+ return (NULL);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Vendor.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Vendor.c
new file mode 100644
index 000000000..9c6469bb8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Vendor.c
@@ -0,0 +1,258 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Vendor.c,v 1.17 2003/08/24 17:37:08 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec VendorSubTab[] =
+{
+ {ENDSUBSECTION, "endsubsection"},
+ {IDENTIFIER, "identifier"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeVendorSubList
+
+XF86ConfVendSubPtr
+xf86parseVendorSubSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfVendSubPtr, XF86ConfVendSubRec)
+
+ while ((token = xf86getToken (VendorSubTab)) != ENDSUBSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->vs_comment = xf86addComment(ptr->vs_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->vs_comment)))
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->vs_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case OPTION:
+ ptr->vs_option_lst = xf86parseOption(ptr->vs_option_lst);
+ break;
+
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ printf ("Vendor subsection parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+static xf86ConfigSymTabRec VendorTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {OPTION, "option"},
+ {SUBSECTION, "subsection"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeVendorList
+
+XF86ConfVendorPtr
+xf86parseVendorSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfVendorPtr, XF86ConfVendorRec)
+
+ while ((token = xf86getToken (VendorTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->vnd_comment = xf86addComment(ptr->vnd_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->vnd_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->vnd_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case OPTION:
+ ptr->vnd_option_lst = xf86parseOption(ptr->vnd_option_lst);
+ break;
+ case SUBSECTION:
+ if (xf86getSubToken (&(ptr->vnd_comment)) != STRING)
+ Error (QUOTE_MSG, "SubSection");
+ {
+ HANDLE_LIST (vnd_sub_lst, xf86parseVendorSubSection,
+ XF86ConfVendSubPtr);
+ }
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Vendor section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printVendorSection (FILE * cf, XF86ConfVendorPtr ptr)
+{
+ XF86ConfVendSubPtr pptr;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"Vendor\"\n");
+ if (ptr->vnd_comment)
+ fprintf (cf, "%s", ptr->vnd_comment);
+ if (ptr->vnd_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->vnd_identifier);
+
+ xf86printOptionList(cf, ptr->vnd_option_lst, 1);
+ for (pptr = ptr->vnd_sub_lst; pptr; pptr = pptr->list.next)
+ {
+ fprintf (cf, "\tSubSection \"Vendor\"\n");
+ if (pptr->vs_comment)
+ fprintf (cf, "%s", pptr->vs_comment);
+ if (pptr->vs_identifier)
+ fprintf (cf, "\t\tIdentifier \"%s\"\n", pptr->vs_identifier);
+ xf86printOptionList(cf, pptr->vs_option_lst, 2);
+ fprintf (cf, "\tEndSubSection\n");
+ }
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86freeVendorList (XF86ConfVendorPtr p)
+{
+ if (p == NULL)
+ return;
+ xf86freeVendorSubList (p->vnd_sub_lst);
+ TestFree (p->vnd_identifier);
+ TestFree (p->vnd_comment);
+ xf86optionListFree (p->vnd_option_lst);
+ xf86conffree (p);
+}
+
+void
+xf86freeVendorSubList (XF86ConfVendSubPtr ptr)
+{
+ XF86ConfVendSubPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->vs_identifier);
+ TestFree (ptr->vs_name);
+ TestFree (ptr->vs_comment);
+ xf86optionListFree (ptr->vs_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ xf86conffree (prev);
+ }
+}
+
+XF86ConfVendorPtr
+xf86findVendor (const char *name, XF86ConfVendorPtr list)
+{
+ while (list)
+ {
+ if (xf86nameCompare (list->vnd_identifier, name) == 0)
+ return (list);
+ list = list->list.next;
+ }
+ return (NULL);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/Video.c b/nx-X11/programs/Xserver/hw/xfree86/parser/Video.c
new file mode 100644
index 000000000..88788aea8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/Video.c
@@ -0,0 +1,297 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Video.c,v 1.13 2003/08/24 17:37:08 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec VideoPortTab[] =
+{
+ {ENDSUBSECTION, "endsubsection"},
+ {IDENTIFIER, "identifier"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeVideoPortList
+
+XF86ConfVideoPortPtr
+xf86parseVideoPortSubSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfVideoPortPtr, XF86ConfVideoPortRec)
+
+ while ((token = xf86getToken (VideoPortTab)) != ENDSUBSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->vp_comment = xf86addComment(ptr->vp_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->vp_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->vp_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case OPTION:
+ ptr->vp_option_lst = xf86parseOption(ptr->vp_option_lst);
+ break;
+
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ printf ("VideoPort subsection parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+static xf86ConfigSymTabRec VideoAdaptorTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {VENDOR, "vendorname"},
+ {BOARD, "boardname"},
+ {BUSID, "busid"},
+ {DRIVER, "driver"},
+ {OPTION, "option"},
+ {SUBSECTION, "subsection"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeVideoAdaptorList
+
+XF86ConfVideoAdaptorPtr
+xf86parseVideoAdaptorSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+
+ parsePrologue (XF86ConfVideoAdaptorPtr, XF86ConfVideoAdaptorRec)
+
+ while ((token = xf86getToken (VideoAdaptorTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->va_comment = xf86addComment(ptr->va_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ ptr->va_identifier = val.str;
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ has_ident = TRUE;
+ break;
+ case VENDOR:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "Vendor");
+ ptr->va_vendor = val.str;
+ break;
+ case BOARD:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "Board");
+ ptr->va_board = val.str;
+ break;
+ case BUSID:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "BusID");
+ ptr->va_busid = val.str;
+ break;
+ case DRIVER:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "Driver");
+ ptr->va_driver = val.str;
+ break;
+ case OPTION:
+ ptr->va_option_lst = xf86parseOption(ptr->va_option_lst);
+ break;
+ case SUBSECTION:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "SubSection");
+ {
+ HANDLE_LIST (va_port_lst, xf86parseVideoPortSubSection,
+ XF86ConfVideoPortPtr);
+ }
+ break;
+
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("VideoAdaptor section parsed\n");
+#endif
+
+ return ptr;
+}
+
+void
+xf86printVideoAdaptorSection (FILE * cf, XF86ConfVideoAdaptorPtr ptr)
+{
+ XF86ConfVideoPortPtr pptr;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"VideoAdaptor\"\n");
+ if (ptr->va_comment)
+ fprintf (cf, "%s", ptr->va_comment);
+ if (ptr->va_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->va_identifier);
+ if (ptr->va_vendor)
+ fprintf (cf, "\tVendorName \"%s\"\n", ptr->va_vendor);
+ if (ptr->va_board)
+ fprintf (cf, "\tBoardName \"%s\"\n", ptr->va_board);
+ if (ptr->va_busid)
+ fprintf (cf, "\tBusID \"%s\"\n", ptr->va_busid);
+ if (ptr->va_driver)
+ fprintf (cf, "\tDriver \"%s\"\n", ptr->va_driver);
+ xf86printOptionList(cf, ptr->va_option_lst, 1);
+ for (pptr = ptr->va_port_lst; pptr; pptr = pptr->list.next)
+ {
+ fprintf (cf, "\tSubSection \"VideoPort\"\n");
+ if (pptr->vp_comment)
+ fprintf (cf, "%s", pptr->vp_comment);
+ if (pptr->vp_identifier)
+ fprintf (cf, "\t\tIdentifier \"%s\"\n", pptr->vp_identifier);
+ xf86printOptionList(cf, pptr->vp_option_lst, 2);
+ fprintf (cf, "\tEndSubSection\n");
+ }
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+
+}
+
+void
+xf86freeVideoAdaptorList (XF86ConfVideoAdaptorPtr ptr)
+{
+ XF86ConfVideoAdaptorPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->va_identifier);
+ TestFree (ptr->va_vendor);
+ TestFree (ptr->va_board);
+ TestFree (ptr->va_busid);
+ TestFree (ptr->va_driver);
+ TestFree (ptr->va_fwdref);
+ TestFree (ptr->va_comment);
+ xf86freeVideoPortList (ptr->va_port_lst);
+ xf86optionListFree (ptr->va_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ xf86conffree (prev);
+ }
+}
+
+void
+xf86freeVideoPortList (XF86ConfVideoPortPtr ptr)
+{
+ XF86ConfVideoPortPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->vp_identifier);
+ TestFree (ptr->vp_comment);
+ xf86optionListFree (ptr->vp_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ xf86conffree (prev);
+ }
+}
+
+XF86ConfVideoAdaptorPtr
+xf86findVideoAdaptor (const char *ident, XF86ConfVideoAdaptorPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->va_identifier) == 0)
+ return (p);
+
+ p = p->list.next;
+ }
+ return (NULL);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/configProcs.h b/nx-X11/programs/Xserver/hw/xfree86/parser/configProcs.h
new file mode 100644
index 000000000..bb5f4e9b2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/configProcs.h
@@ -0,0 +1,132 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/configProcs.h,v 1.17 2003/08/24 17:37:08 dawes Exp $ */
+/*
+ * Copyright (c) 1997-2001 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* Private procs. Public procs are in xf86Parser.h and xf86Optrec.h */
+
+/* Device.c */
+XF86ConfDevicePtr xf86parseDeviceSection(void);
+void xf86printDeviceSection(FILE *cf, XF86ConfDevicePtr ptr);
+void xf86freeDeviceList(XF86ConfDevicePtr ptr);
+int xf86validateDevice(XF86ConfigPtr p);
+/* Files.c */
+XF86ConfFilesPtr xf86parseFilesSection(void);
+void xf86printFileSection(FILE *cf, XF86ConfFilesPtr ptr);
+void xf86freeFiles(XF86ConfFilesPtr p);
+/* Flags.c */
+XF86ConfFlagsPtr xf86parseFlagsSection(void);
+void xf86printServerFlagsSection(FILE *f, XF86ConfFlagsPtr flags);
+void xf86freeFlags(XF86ConfFlagsPtr flags);
+/* Input.c */
+XF86ConfInputPtr xf86parseInputSection(void);
+void xf86printInputSection(FILE *f, XF86ConfInputPtr ptr);
+void xf86freeInputList(XF86ConfInputPtr ptr);
+int xf86validateInput (XF86ConfigPtr p);
+/* Keyboard.c */
+XF86ConfInputPtr xf86parseKeyboardSection(void);
+/* Layout.c */
+XF86ConfLayoutPtr xf86parseLayoutSection(void);
+void xf86printLayoutSection(FILE *cf, XF86ConfLayoutPtr ptr);
+void xf86freeLayoutList(XF86ConfLayoutPtr ptr);
+void xf86freeAdjacencyList(XF86ConfAdjacencyPtr ptr);
+void xf86freeInputrefList(XF86ConfInputrefPtr ptr);
+int xf86validateLayout(XF86ConfigPtr p);
+/* Module.c */
+XF86LoadPtr xf86parseModuleSubSection(XF86LoadPtr head, char *name);
+XF86ConfModulePtr xf86parseModuleSection(void);
+void xf86printModuleSection(FILE *cf, XF86ConfModulePtr ptr);
+XF86LoadPtr xf86addNewLoadDirective(XF86LoadPtr head, char *name, int type, XF86OptionPtr opts);
+void xf86freeModules(XF86ConfModulePtr ptr);
+/* Monitor.c */
+XF86ConfModeLinePtr xf86parseModeLine(void);
+XF86ConfModeLinePtr xf86parseVerboseMode(void);
+XF86ConfMonitorPtr xf86parseMonitorSection(void);
+XF86ConfModesPtr xf86parseModesSection(void);
+void xf86printMonitorSection(FILE *cf, XF86ConfMonitorPtr ptr);
+void xf86printModesSection(FILE *cf, XF86ConfModesPtr ptr);
+void xf86freeMonitorList(XF86ConfMonitorPtr ptr);
+void xf86freeModesList(XF86ConfModesPtr ptr);
+void xf86freeModeLineList(XF86ConfModeLinePtr ptr);
+int xf86validateMonitor(XF86ConfigPtr p, XF86ConfScreenPtr screen);
+/* Pointer.c */
+XF86ConfInputPtr xf86parsePointerSection(void);
+/* Screen.c */
+XF86ConfDisplayPtr xf86parseDisplaySubSection(void);
+XF86ConfScreenPtr xf86parseScreenSection(void);
+void xf86printScreenSection(FILE *cf, XF86ConfScreenPtr ptr);
+void xf86freeScreenList(XF86ConfScreenPtr ptr);
+void xf86freeAdaptorLinkList(XF86ConfAdaptorLinkPtr ptr);
+void xf86freeDisplayList(XF86ConfDisplayPtr ptr);
+void xf86freeModeList(XF86ModePtr ptr);
+int xf86validateScreen(XF86ConfigPtr p);
+/* Vendor.c */
+XF86ConfVendorPtr xf86parseVendorSection(void);
+XF86ConfVendSubPtr xf86parseVendorSubSection (void);
+void xf86freeVendorList(XF86ConfVendorPtr p);
+void xf86printVendorSection(FILE * cf, XF86ConfVendorPtr ptr);
+void xf86freeVendorSubList (XF86ConfVendSubPtr ptr);
+/* Video.c */
+XF86ConfVideoPortPtr xf86parseVideoPortSubSection(void);
+XF86ConfVideoAdaptorPtr xf86parseVideoAdaptorSection(void);
+void xf86printVideoAdaptorSection(FILE *cf, XF86ConfVideoAdaptorPtr ptr);
+void xf86freeVideoAdaptorList(XF86ConfVideoAdaptorPtr ptr);
+void xf86freeVideoPortList(XF86ConfVideoPortPtr ptr);
+/* read.c */
+int xf86validateConfig(XF86ConfigPtr p);
+/* scan.c */
+unsigned int xf86strToUL(char *str);
+int xf86getToken(xf86ConfigSymTabRec *tab);
+int xf86getSubToken(char **comment);
+int xf86getSubTokenWithTab(char **comment, xf86ConfigSymTabRec *tab);
+void xf86unGetToken(int token);
+char *xf86tokenString(void);
+void xf86parseError(char *format, ...);
+void xf86parseWarning(char *format, ...);
+void xf86validationError(char *format, ...);
+void xf86setSection(char *section);
+int xf86getStringToken(xf86ConfigSymTabRec *tab);
+/* write.c */
+/* DRI.c */
+XF86ConfBuffersPtr xf86parseBuffers (void);
+void xf86freeBuffersList (XF86ConfBuffersPtr ptr);
+XF86ConfDRIPtr xf86parseDRISection (void);
+void xf86printDRISection (FILE * cf, XF86ConfDRIPtr ptr);
+void xf86freeDRI (XF86ConfDRIPtr ptr);
+/* Extensions.c */
+XF86ConfExtensionsPtr xf86parseExtensionsSection (void);
+void xf86printExtensionsSection (FILE * cf, XF86ConfExtensionsPtr ptr);
+void xf86freeExtensions (XF86ConfExtensionsPtr ptr);
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef IN_XSERVER
+/* Externally provided functions */
+void ErrorF(const char *f, ...);
+void VErrorF(const char *f, va_list args);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/cpconfig.c b/nx-X11/programs/Xserver/hw/xfree86/parser/cpconfig.c
new file mode 100644
index 000000000..4eb635b30
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/cpconfig.c
@@ -0,0 +1,123 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/cpconfig.c,v 1.6 2000/10/20 14:59:03 alanh Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include "xf86Parser.h"
+#include "configProcs.h"
+
+#ifdef MALLOC_FUNCTIONS
+void
+xfree (void *p)
+{
+ free (p);
+ return;
+}
+
+void *
+xalloc (int size)
+{
+ return malloc (size);
+}
+
+void *
+xrealloc (void *p, int size)
+{
+ return realloc (p, size);
+}
+
+#endif
+
+#define CONFPATH "%A,%R,/etc/X11/%R,%P/etc/X11/%R,%E,%F,/etc/X11/%F," \
+ "%P/etc/X11/%F,%D/%X,/etc/X11/%X,/etc/%X,%P/etc/X11/%X.%H," \
+ "%P/etc/X11/%X,%P/lib/X11/%X.%H,%P/lib/X11/%X"
+
+int
+main (int argc, char *argv[])
+{
+ const char *filename;
+ char *cmdline = NULL;
+ XF86ConfigPtr conf;
+
+ if (argc > 1)
+ {
+ cmdline = argv[1];
+ }
+ if ((filename = xf86openConfigFile (CONFPATH, cmdline, NULL)))
+ {
+ fprintf (stderr, "Opened %s for the config file\n", filename);
+ }
+ else
+ {
+ fprintf (stderr, "Unable to open config file\n");
+ exit (1);
+ }
+
+ if ((conf = xf86readConfigFile ()) == NULL)
+ {
+ fprintf (stderr, "Problem when parsing config file\n");
+ }
+ else
+ {
+ fprintf (stderr, "Config file parsed OK\n");
+ }
+ xf86closeConfigFile ();
+
+ if (argc > 2) {
+ fprintf(stderr, "Writing config file to `%s'\n", argv[2]);
+ xf86writeConfigFile (argv[2], conf);
+ }
+ exit(0);
+}
+
+/* Functions that the parser requires */
+
+void
+VErrorF(const char *f, va_list args)
+{
+ vfprintf(stderr, f, args);
+}
+
+void
+ErrorF(const char *f, ...)
+{
+ va_list args;
+
+ va_start(args, f);
+ vfprintf(stderr, f, args);
+ va_end(args);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/read.c b/nx-X11/programs/Xserver/hw/xfree86/parser/read.c
new file mode 100644
index 000000000..59b0ea6fb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/read.c
@@ -0,0 +1,321 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/read.c,v 1.24 2003/08/24 17:37:08 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec TopLevelTab[] =
+{
+ {SECTION, "section"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeConfig
+
+XF86ConfigPtr
+xf86readConfigFile (void)
+{
+ int token;
+ XF86ConfigPtr ptr = NULL;
+
+ if ((ptr = xf86confcalloc (1, sizeof (XF86ConfigRec))) == NULL)
+ {
+ return NULL;
+ }
+ memset (ptr, 0, sizeof (XF86ConfigRec));
+
+ while ((token = xf86getToken (TopLevelTab)) != EOF_TOKEN)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->conf_comment = xf86addComment(ptr->conf_comment, val.str);
+ break;
+ case SECTION:
+ if (xf86getSubToken (&(ptr->conf_comment)) != STRING)
+ {
+ xf86parseError (QUOTE_MSG, "Section");
+ CLEANUP (ptr);
+ return (NULL);
+ }
+ xf86setSection (val.str);
+ if (xf86nameCompare (val.str, "files") == 0)
+ {
+ xf86conffree(val.str);
+ val.str = NULL;
+ HANDLE_RETURN (conf_files, xf86parseFilesSection ());
+ }
+ else if (xf86nameCompare (val.str, "serverflags") == 0)
+ {
+ xf86conffree(val.str);
+ val.str = NULL;
+ HANDLE_RETURN (conf_flags, xf86parseFlagsSection ());
+ }
+ else if (xf86nameCompare (val.str, "keyboard") == 0)
+ {
+ xf86conffree(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_input_lst, xf86parseKeyboardSection,
+ XF86ConfInputPtr);
+ }
+ else if (xf86nameCompare (val.str, "pointer") == 0)
+ {
+ xf86conffree(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_input_lst, xf86parsePointerSection,
+ XF86ConfInputPtr);
+ }
+ else if (xf86nameCompare (val.str, "videoadaptor") == 0)
+ {
+ xf86conffree(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_videoadaptor_lst, xf86parseVideoAdaptorSection,
+ XF86ConfVideoAdaptorPtr);
+ }
+ else if (xf86nameCompare (val.str, "device") == 0)
+ {
+ xf86conffree(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_device_lst, xf86parseDeviceSection,
+ XF86ConfDevicePtr);
+ }
+ else if (xf86nameCompare (val.str, "monitor") == 0)
+ {
+ xf86conffree(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_monitor_lst, xf86parseMonitorSection,
+ XF86ConfMonitorPtr);
+ }
+ else if (xf86nameCompare (val.str, "modes") == 0)
+ {
+ xf86conffree(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_modes_lst, xf86parseModesSection,
+ XF86ConfModesPtr);
+ }
+ else if (xf86nameCompare (val.str, "screen") == 0)
+ {
+ xf86conffree(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_screen_lst, xf86parseScreenSection,
+ XF86ConfScreenPtr);
+ }
+ else if (xf86nameCompare(val.str, "inputdevice") == 0)
+ {
+ xf86conffree(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_input_lst, xf86parseInputSection,
+ XF86ConfInputPtr);
+ }
+ else if (xf86nameCompare (val.str, "module") == 0)
+ {
+ xf86conffree(val.str);
+ val.str = NULL;
+ HANDLE_RETURN (conf_modules, xf86parseModuleSection ());
+ }
+ else if (xf86nameCompare (val.str, "serverlayout") == 0)
+ {
+ xf86conffree(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_layout_lst, xf86parseLayoutSection,
+ XF86ConfLayoutPtr);
+ }
+ else if (xf86nameCompare (val.str, "vendor") == 0)
+ {
+ xf86conffree(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_vendor_lst, xf86parseVendorSection,
+ XF86ConfVendorPtr);
+ }
+ else if (xf86nameCompare (val.str, "dri") == 0)
+ {
+ xf86conffree(val.str);
+ val.str = NULL;
+ HANDLE_RETURN (conf_dri, xf86parseDRISection ());
+ }
+ else if (xf86nameCompare (val.str, "extensions") == 0)
+ {
+ xf86conffree(val.str);
+ val.str = NULL;
+ HANDLE_RETURN (conf_extensions, xf86parseExtensionsSection ());
+ }
+ else
+ {
+ Error (INVALID_SECTION_MSG, xf86tokenString ());
+ xf86conffree(val.str);
+ val.str = NULL;
+ }
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ xf86conffree(val.str);
+ val.str = NULL;
+ }
+ }
+
+ if (xf86validateConfig (ptr))
+ return (ptr);
+ else
+ {
+ CLEANUP (ptr);
+ return (NULL);
+ }
+}
+
+#undef CLEANUP
+
+/*
+ * This function resolves name references and reports errors if the named
+ * objects cannot be found.
+ */
+int
+xf86validateConfig (XF86ConfigPtr p)
+{
+ if (!xf86validateDevice (p))
+ return FALSE;
+ if (!xf86validateScreen (p))
+ return FALSE;
+ if (!xf86validateInput (p))
+ return FALSE;
+ if (!xf86validateLayout (p))
+ return FALSE;
+
+ return (TRUE);
+}
+
+/*
+ * adds an item to the end of the linked list. Any record whose first field
+ * is a GenericListRec can be cast to this type and used with this function.
+ * A pointer to the head of the list is returned to handle the addition of
+ * the first item.
+ */
+GenericListPtr
+xf86addListItem (GenericListPtr head, GenericListPtr new)
+{
+ GenericListPtr p = head;
+ GenericListPtr last = NULL;
+
+ while (p)
+ {
+ last = p;
+ p = p->next;
+ }
+
+ if (last)
+ {
+ last->next = new;
+ return (head);
+ }
+ else
+ return (new);
+}
+
+/*
+ * Test if one chained list contains the other.
+ * In this case both list have the same endpoint (provided they don't loop)
+ */
+int
+xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2)
+{
+ GenericListPtr p = list_1;
+ GenericListPtr last_1 = NULL, last_2 = NULL;
+
+ while (p) {
+ last_1 = p;
+ p = p->next;
+ }
+
+ p = list_2;
+ while (p) {
+ last_2 = p;
+ p = p->next;
+ }
+
+ return (!(last_1 == last_2));
+}
+
+void
+xf86freeConfig (XF86ConfigPtr p)
+{
+ if (p == NULL)
+ return;
+
+ xf86freeFiles (p->conf_files);
+ xf86freeModules (p->conf_modules);
+ xf86freeFlags (p->conf_flags);
+ xf86freeMonitorList (p->conf_monitor_lst);
+ xf86freeModesList (p->conf_modes_lst);
+ xf86freeVideoAdaptorList (p->conf_videoadaptor_lst);
+ xf86freeDeviceList (p->conf_device_lst);
+ xf86freeScreenList (p->conf_screen_lst);
+ xf86freeLayoutList (p->conf_layout_lst);
+ xf86freeInputList (p->conf_input_lst);
+ xf86freeVendorList (p->conf_vendor_lst);
+ xf86freeDRI (p->conf_dri);
+ xf86freeExtensions (p->conf_extensions);
+ TestFree(p->conf_comment);
+
+ xf86conffree (p);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/scan.c b/nx-X11/programs/Xserver/hw/xfree86/parser/scan.c
new file mode 100644
index 000000000..ce3cda128
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/scan.c
@@ -0,0 +1,949 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/scan.c,v 1.30 2003/11/03 05:11:52 tsi Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+#if !defined(X_NOT_POSIX)
+#if defined(_POSIX_SOURCE)
+#include <limits.h>
+#else
+#define _POSIX_SOURCE
+#include <limits.h>
+#undef _POSIX_SOURCE
+#endif /* _POSIX_SOURCE */
+#endif /* !X_NOT_POSIX */
+#if !defined(PATH_MAX)
+#if defined(MAXPATHLEN)
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif /* MAXPATHLEN */
+#endif /* !PATH_MAX */
+
+#if !defined(MAXHOSTNAMELEN)
+#define MAXHOSTNAMELEN 32
+#endif /* !MAXHOSTNAMELEN */
+
+#include "Configint.h"
+#include "xf86tokens.h"
+
+#define CONFIG_BUF_LEN 1024
+
+static int StringToToken (char *, xf86ConfigSymTabRec *);
+
+static FILE *configFile = NULL;
+static const char **builtinConfig = NULL;
+static int builtinIndex = 0;
+static int configPos = 0; /* current readers position */
+static int configLineNo = 0; /* linenumber */
+static char *configBuf, *configRBuf; /* buffer for lines */
+static char *configPath; /* path to config file */
+static char *configSection = NULL; /* name of current section being parsed */
+static int pushToken = LOCK_TOKEN;
+static int eol_seen = 0; /* private state to handle comments */
+LexRec val;
+
+#ifdef __UNIXOS2__
+extern char *__XOS2RedirRoot(char *path);
+#endif
+
+/*
+ * xf86strToUL --
+ *
+ * A portable, but restricted, version of strtoul(). It only understands
+ * hex, octal, and decimal. But it's good enough for our needs.
+ */
+unsigned int
+xf86strToUL (char *str)
+{
+ int base = 10;
+ char *p = str;
+ unsigned int tot = 0;
+
+ if (*p == '0')
+ {
+ p++;
+ if ((*p == 'x') || (*p == 'X'))
+ {
+ p++;
+ base = 16;
+ }
+ else
+ base = 8;
+ }
+ while (*p)
+ {
+ if ((*p >= '0') && (*p <= ((base == 8) ? '7' : '9')))
+ {
+ tot = tot * base + (*p - '0');
+ }
+ else if ((base == 16) && (*p >= 'a') && (*p <= 'f'))
+ {
+ tot = tot * base + 10 + (*p - 'a');
+ }
+ else if ((base == 16) && (*p >= 'A') && (*p <= 'F'))
+ {
+ tot = tot * base + 10 + (*p - 'A');
+ }
+ else
+ {
+ return (tot);
+ }
+ p++;
+ }
+ return (tot);
+}
+
+/*
+ * xf86getToken --
+ * Read next Token form the config file. Handle the global variable
+ * pushToken.
+ */
+int
+xf86getToken (xf86ConfigSymTabRec * tab)
+{
+ int c, i;
+
+ /*
+ * First check whether pushToken has a different value than LOCK_TOKEN.
+ * In this case rBuf[] contains a valid STRING/TOKEN/NUMBER. But in the
+ * oth * case the next token must be read from the input.
+ */
+ if (pushToken == EOF_TOKEN)
+ return (EOF_TOKEN);
+ else if (pushToken == LOCK_TOKEN)
+ {
+ /*
+ * eol_seen is only set for the first token after a newline.
+ */
+ eol_seen = 0;
+
+ c = configBuf[configPos];
+
+ /*
+ * Get start of next Token. EOF is handled,
+ * whitespaces are skipped.
+ */
+
+again:
+ if (!c)
+ {
+ char *ret;
+ if (configFile)
+ ret = fgets (configBuf, CONFIG_BUF_LEN - 1, configFile);
+ else {
+ if (builtinConfig[builtinIndex] == NULL)
+ ret = NULL;
+ else {
+ ret = strncpy(configBuf, builtinConfig[builtinIndex],
+ CONFIG_BUF_LEN);
+ builtinIndex++;
+ }
+ }
+ if (ret == NULL)
+ {
+ return (pushToken = EOF_TOKEN);
+ }
+ configLineNo++;
+ configPos = 0;
+ eol_seen = 1;
+ }
+
+ i = 0;
+ for (;;) {
+ c = configBuf[configPos++];
+ configRBuf[i++] = c;
+ switch (c) {
+ case ' ':
+ case '\t':
+ case '\r':
+ continue;
+ case '\n':
+ i = 0;
+ continue;
+ }
+ break;
+ }
+ if (c == '\0')
+ goto again;
+
+ if (c == '#')
+ {
+ do
+ {
+ configRBuf[i++] = (c = configBuf[configPos++]);
+ }
+ while ((c != '\n') && (c != '\r') && (c != '\0'));
+ configRBuf[i] = '\0';
+ /* XXX no private copy.
+ * Use xf86addComment when setting a comment.
+ */
+ val.str = configRBuf;
+ return (COMMENT);
+ }
+
+ /* GJA -- handle '-' and ',' * Be careful: "-hsync" is a keyword. */
+ else if ((c == ',') && !isalpha (configBuf[configPos]))
+ {
+ return COMMA;
+ }
+ else if ((c == '-') && !isalpha (configBuf[configPos]))
+ {
+ return DASH;
+ }
+
+ /*
+ * Numbers are returned immediately ...
+ */
+ if (isdigit (c))
+ {
+ int base;
+
+ if (c == '0')
+ if ((configBuf[configPos] == 'x') ||
+ (configBuf[configPos] == 'X'))
+ base = 16;
+ else
+ base = 8;
+ else
+ base = 10;
+
+ configRBuf[0] = c;
+ i = 1;
+ while (isdigit (c = configBuf[configPos++]) ||
+ (c == '.') || (c == 'x') || (c == 'X') ||
+ ((base == 16) && (((c >= 'a') && (c <= 'f')) ||
+ ((c >= 'A') && (c <= 'F')))))
+ configRBuf[i++] = c;
+ configPos--; /* GJA -- one too far */
+ configRBuf[i] = '\0';
+ val.num = xf86strToUL (configRBuf);
+ val.realnum = atof (configRBuf);
+ return (NUMBER);
+ }
+
+ /*
+ * All Strings START with a \" ...
+ */
+ else if (c == '\"')
+ {
+ i = -1;
+ do
+ {
+ configRBuf[++i] = (c = configBuf[configPos++]);
+ }
+ while ((c != '\"') && (c != '\n') && (c != '\r') && (c != '\0'));
+ configRBuf[i] = '\0';
+ val.str = xf86confmalloc (strlen (configRBuf) + 1);
+ strcpy (val.str, configRBuf); /* private copy ! */
+ return (STRING);
+ }
+
+ /*
+ * ... and now we MUST have a valid token. The search is
+ * handled later along with the pushed tokens.
+ */
+ else
+ {
+ configRBuf[0] = c;
+ i = 0;
+ do
+ {
+ configRBuf[++i] = (c = configBuf[configPos++]);;
+ }
+ while ((c != ' ') && (c != '\t') && (c != '\n') && (c != '\r') && (c != '\0') && (c != '#'));
+ --configPos;
+ configRBuf[i] = '\0';
+ i = 0;
+ }
+
+ }
+ else
+ {
+
+ /*
+ * Here we deal with pushed tokens. Reinitialize pushToken again. If
+ * the pushed token was NUMBER || STRING return them again ...
+ */
+ int temp = pushToken;
+ pushToken = LOCK_TOKEN;
+
+ if (temp == COMMA || temp == DASH)
+ return (temp);
+ if (temp == NUMBER || temp == STRING)
+ return (temp);
+ }
+
+ /*
+ * Joop, at last we have to lookup the token ...
+ */
+ if (tab)
+ {
+ i = 0;
+ while (tab[i].token != -1)
+ if (xf86nameCompare (configRBuf, tab[i].name) == 0)
+ return (tab[i].token);
+ else
+ i++;
+ }
+
+ return (ERROR_TOKEN); /* Error catcher */
+}
+
+int
+xf86getSubToken (char **comment)
+{
+ int token;
+
+ for (;;) {
+ token = xf86getToken(NULL);
+ if (token == COMMENT) {
+ if (comment)
+ *comment = xf86addComment(*comment, val.str);
+ }
+ else
+ return (token);
+ }
+ /*NOTREACHED*/
+}
+
+int
+xf86getSubTokenWithTab (char **comment, xf86ConfigSymTabRec *tab)
+{
+ int token;
+
+ for (;;) {
+ token = xf86getToken(tab);
+ if (token == COMMENT) {
+ if (comment)
+ *comment = xf86addComment(*comment, val.str);
+ }
+ else
+ return (token);
+ }
+ /*NOTREACHED*/
+}
+
+void
+xf86unGetToken (int token)
+{
+ pushToken = token;
+}
+
+char *
+xf86tokenString (void)
+{
+ return configRBuf;
+}
+
+int
+xf86pathIsAbsolute(const char *path)
+{
+ if (path && path[0] == '/')
+ return 1;
+#ifdef __UNIXOS2__
+ if (path && (path[0] == '\\' || (path[1] == ':')))
+ return 1;
+#endif
+ return 0;
+}
+
+/* A path is "safe" if it is relative and if it contains no ".." elements. */
+int
+xf86pathIsSafe(const char *path)
+{
+ if (xf86pathIsAbsolute(path))
+ return 0;
+
+ /* Compare with ".." */
+ if (!strcmp(path, ".."))
+ return 0;
+
+ /* Look for leading "../" */
+ if (!strncmp(path, "../", 3))
+ return 0;
+
+ /* Look for trailing "/.." */
+ if ((strlen(path) > 3) && !strcmp(path + strlen(path) - 3, "/.."))
+ return 0;
+
+ /* Look for "/../" */
+ if (strstr(path, "/../"))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * This function substitutes the following escape sequences:
+ *
+ * %A cmdline argument as an absolute path (must be absolute to match)
+ * %R cmdline argument as a relative path
+ * %S cmdline argument as a "safe" path (relative, and no ".." elements)
+ * %X default config file name ("xorg.conf")
+ * %H hostname
+ * %E config file environment ($XORGCONFIG) as an absolute path
+ * %F config file environment ($XORGCONFIG) as a relative path
+ * %G config file environment ($XORGCONFIG) as a safe path
+ * %D $HOME
+ * %P projroot
+ * %M major version number
+ * %% %
+ * %& UNIXOS2 only: prepend X11ROOT env var
+ */
+
+#ifndef XCONFIGFILE
+#define XCONFIGFILE "xorg.conf"
+#endif
+#ifndef PROJECTROOT
+#define PROJECTROOT "/usr/X11R6"
+#endif
+#ifndef XCONFENV
+#define XCONFENV "XORGCONFIG"
+#endif
+#define XFREE86CFGFILE "XF86Config"
+#ifndef XF86_VERSION_MAJOR
+#ifdef XVERSION
+#if XVERSION > 40000000
+#define XF86_VERSION_MAJOR (XVERSION / 10000000)
+#else
+#define XF86_VERSION_MAJOR (XVERSION / 1000)
+#endif
+#else
+#define XF86_VERSION_MAJOR 4
+#endif
+#endif
+
+#define BAIL_OUT do { \
+ xf86conffree(result); \
+ return NULL; \
+ } while (0)
+
+#define CHECK_LENGTH do { \
+ if (l > PATH_MAX) { \
+ BAIL_OUT; \
+ } \
+ } while (0)
+
+#define APPEND_STR(s) do { \
+ if (strlen(s) + l > PATH_MAX) { \
+ BAIL_OUT; \
+ } else { \
+ strcpy(result + l, s); \
+ l += strlen(s); \
+ } \
+ } while (0)
+
+static char *
+DoSubstitution(const char *template, const char *cmdline, const char *projroot,
+ int *cmdlineUsed, int *envUsed, char *XConfigFile)
+{
+ char *result;
+ int i, l;
+ static const char *env = NULL, *home = NULL;
+ static char *hostname = NULL;
+ static char majorvers[3] = "";
+#ifdef __UNIXOS2__
+ static char *x11root = NULL;
+#endif
+
+ if (!template)
+ return NULL;
+
+ if (cmdlineUsed)
+ *cmdlineUsed = 0;
+ if (envUsed)
+ *envUsed = 0;
+
+ result = xf86confmalloc(PATH_MAX + 1);
+ l = 0;
+ for (i = 0; template[i]; i++) {
+ if (template[i] != '%') {
+ result[l++] = template[i];
+ CHECK_LENGTH;
+ } else {
+ switch (template[++i]) {
+ case 'A':
+ if (cmdline && xf86pathIsAbsolute(cmdline)) {
+ APPEND_STR(cmdline);
+ if (cmdlineUsed)
+ *cmdlineUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'R':
+ if (cmdline && !xf86pathIsAbsolute(cmdline)) {
+ APPEND_STR(cmdline);
+ if (cmdlineUsed)
+ *cmdlineUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'S':
+ if (cmdline && xf86pathIsSafe(cmdline)) {
+ APPEND_STR(cmdline);
+ if (cmdlineUsed)
+ *cmdlineUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'X':
+ APPEND_STR(XConfigFile);
+ break;
+ case 'H':
+ if (!hostname) {
+ if ((hostname = xf86confmalloc(MAXHOSTNAMELEN + 1))) {
+ if (gethostname(hostname, MAXHOSTNAMELEN) == 0) {
+ hostname[MAXHOSTNAMELEN] = '\0';
+ } else {
+ xf86conffree(hostname);
+ hostname = NULL;
+ }
+ }
+ }
+ if (hostname)
+ APPEND_STR(hostname);
+ break;
+ case 'E':
+ if (!env)
+ env = getenv(XCONFENV);
+ if (env && xf86pathIsAbsolute(env)) {
+ APPEND_STR(env);
+ if (envUsed)
+ *envUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'F':
+ if (!env)
+ env = getenv(XCONFENV);
+ if (env && !xf86pathIsAbsolute(env)) {
+ APPEND_STR(env);
+ if (envUsed)
+ *envUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'G':
+ if (!env)
+ env = getenv(XCONFENV);
+ if (env && xf86pathIsSafe(env)) {
+ APPEND_STR(env);
+ if (envUsed)
+ *envUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'D':
+ if (!home)
+ home = getenv("HOME");
+ if (home && xf86pathIsAbsolute(home))
+ APPEND_STR(home);
+ else
+ BAIL_OUT;
+ break;
+ case 'P':
+ if (projroot && xf86pathIsAbsolute(projroot))
+ APPEND_STR(projroot);
+ else
+ BAIL_OUT;
+ break;
+ case 'M':
+ if (!majorvers[0]) {
+ if (XF86_VERSION_MAJOR < 0 || XF86_VERSION_MAJOR > 99) {
+ fprintf(stderr, "XF86_VERSION_MAJOR is out of range\n");
+ BAIL_OUT;
+ } else
+ sprintf(majorvers, "%d", XF86_VERSION_MAJOR);
+ }
+ APPEND_STR(majorvers);
+ break;
+ case '%':
+ result[l++] = '%';
+ CHECK_LENGTH;
+ break;
+#ifdef __UNIXOS2__
+ case '&':
+ if (!x11root)
+ x11root = getenv("X11ROOT");
+ if (x11root)
+ APPEND_STR(x11root);
+ else
+ BAIL_OUT;
+ break;
+#endif
+ default:
+ fprintf(stderr, "invalid escape %%%c found in path template\n",
+ template[i]);
+ BAIL_OUT;
+ break;
+ }
+ }
+ }
+#ifdef DEBUG
+ fprintf(stderr, "Converted `%s' to `%s'\n", template, result);
+#endif
+ return result;
+}
+
+/*
+ * xf86openConfigFile --
+ *
+ * This function take a config file search path (optional), a command-line
+ * specified file name (optional) and the ProjectRoot path (optional) and
+ * locates and opens a config file based on that information. If a
+ * command-line file name is specified, then this function fails if none
+ * of the located files.
+ *
+ * The return value is a pointer to the actual name of the file that was
+ * opened. When no file is found, the return value is NULL.
+ *
+ * The escape sequences allowed in the search path are defined above.
+ *
+ */
+
+#ifndef DEFAULT_CONF_PATH
+#define DEFAULT_CONF_PATH "/etc/X11/%S," \
+ "%P/etc/X11/%S," \
+ "/etc/X11/%G," \
+ "%P/etc/X11/%G," \
+ "/etc/X11/%X-%M," \
+ "/etc/X11/%X," \
+ "/etc/%X," \
+ "%P/etc/X11/%X.%H," \
+ "%P/etc/X11/%X-%M," \
+ "%P/etc/X11/%X," \
+ "%P/lib/X11/%X.%H," \
+ "%P/lib/X11/%X-%M," \
+ "%P/lib/X11/%X"
+#endif
+
+const char *
+xf86openConfigFile(const char *path, const char *cmdline, const char *projroot)
+{
+ char *pathcopy;
+ const char *template;
+ int cmdlineUsed = 0;
+
+ configFile = NULL;
+ configPos = 0; /* current readers position */
+ configLineNo = 0; /* linenumber */
+ pushToken = LOCK_TOKEN;
+
+ if (!path || !path[0])
+ path = DEFAULT_CONF_PATH;
+ pathcopy = xf86confmalloc(strlen(path) + 1);
+ strcpy(pathcopy, path);
+ if (!projroot || !projroot[0])
+ projroot = PROJECTROOT;
+
+ template = strtok(pathcopy, ",");
+
+ /* First, search for a config file. */
+ while (template && !configFile) {
+ if ((configPath = DoSubstitution(template, cmdline, projroot,
+ &cmdlineUsed, NULL,
+ XCONFIGFILE))) {
+ if ((configFile = fopen(configPath, "r")) != 0) {
+ if (cmdline && !cmdlineUsed) {
+ fclose(configFile);
+ configFile = NULL;
+ }
+ }
+ }
+ if (configPath && !configFile) {
+ xf86conffree(configPath);
+ configPath = NULL;
+ }
+ template = strtok(NULL, ",");
+ }
+
+ /* Then search for fallback */
+ if (!configFile) {
+ strcpy(pathcopy, path);
+ template = strtok(pathcopy, ",");
+
+ while (template && !configFile) {
+ if ((configPath = DoSubstitution(template, cmdline, projroot,
+ &cmdlineUsed, NULL,
+ XFREE86CFGFILE))) {
+ if ((configFile = fopen(configPath, "r")) != 0) {
+ if (cmdline && !cmdlineUsed) {
+ fclose(configFile);
+ configFile = NULL;
+ }
+ }
+ }
+ if (configPath && !configFile) {
+ xf86conffree(configPath);
+ configPath = NULL;
+ }
+ template = strtok(NULL, ",");
+ }
+ }
+
+ xf86conffree(pathcopy);
+ if (!configFile) {
+
+ return NULL;
+ }
+
+ configBuf = xf86confmalloc (CONFIG_BUF_LEN);
+ configRBuf = xf86confmalloc (CONFIG_BUF_LEN);
+ configBuf[0] = '\0'; /* sanity ... */
+
+ return configPath;
+}
+
+void
+xf86closeConfigFile (void)
+{
+ xf86conffree (configPath);
+ configPath = NULL;
+ xf86conffree (configRBuf);
+ configRBuf = NULL;
+ xf86conffree (configBuf);
+ configBuf = NULL;
+
+ if (configFile) {
+ fclose (configFile);
+ configFile = NULL;
+ } else {
+ builtinConfig = NULL;
+ builtinIndex = 0;
+ }
+}
+
+void
+xf86setBuiltinConfig(const char *config[])
+{
+ builtinConfig = config;
+ configPath = xf86configStrdup("<builtin configuration>");
+ configBuf = xf86confmalloc (CONFIG_BUF_LEN);
+ configRBuf = xf86confmalloc (CONFIG_BUF_LEN);
+ configBuf[0] = '\0'; /* sanity ... */
+
+}
+
+void
+xf86parseError (char *format,...)
+{
+ va_list ap;
+
+ ErrorF ("Parse error on line %d of section %s in file %s\n\t",
+ configLineNo, configSection, configPath);
+ va_start (ap, format);
+ VErrorF (format, ap);
+ va_end (ap);
+
+ ErrorF ("\n");
+}
+
+void
+xf86parseWarning (char *format,...)
+{
+ va_list ap;
+
+ ErrorF ("Parse warning on line %d of section %s in file %s\n\t",
+ configLineNo, configSection, configPath);
+ va_start (ap, format);
+ VErrorF (format, ap);
+ va_end (ap);
+
+ ErrorF ("\n");
+}
+
+void
+xf86validationError (char *format,...)
+{
+ va_list ap;
+
+ ErrorF ("Data incomplete in file %s\n\t", configPath);
+ va_start (ap, format);
+ VErrorF (format, ap);
+ va_end (ap);
+
+ ErrorF ("\n");
+}
+
+void
+xf86setSection (char *section)
+{
+ if (configSection)
+ xf86conffree(configSection);
+ configSection = xf86confmalloc(strlen (section) + 1);
+ strcpy (configSection, section);
+}
+
+/*
+ * xf86getToken --
+ * Lookup a string if it is actually a token in disguise.
+ */
+int
+xf86getStringToken (xf86ConfigSymTabRec * tab)
+{
+ return StringToToken (val.str, tab);
+}
+
+static int
+StringToToken (char *str, xf86ConfigSymTabRec * tab)
+{
+ int i;
+
+ for (i = 0; tab[i].token != -1; i++)
+ {
+ if (!xf86nameCompare (tab[i].name, str))
+ return tab[i].token;
+ }
+ return (ERROR_TOKEN);
+}
+
+
+/*
+ * Compare two names. The characters '_', ' ', and '\t' are ignored
+ * in the comparison.
+ */
+int
+xf86nameCompare (const char *s1, const char *s2)
+{
+ char c1, c2;
+
+ if (!s1 || *s1 == 0) {
+ if (!s2 || *s2 == 0)
+ return (0);
+ else
+ return (1);
+ }
+
+ while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+ s1++;
+ while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+ s2++;
+ c1 = (isupper (*s1) ? tolower (*s1) : *s1);
+ c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+ while (c1 == c2)
+ {
+ if (c1 == '\0')
+ return (0);
+ s1++;
+ s2++;
+ while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+ s1++;
+ while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+ s2++;
+ c1 = (isupper (*s1) ? tolower (*s1) : *s1);
+ c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+ }
+ return (c1 - c2);
+}
+
+char *
+xf86addComment(char *cur, char *add)
+{
+ char *str;
+ int len, curlen, iscomment, hasnewline = 0, endnewline;
+
+ if (add == NULL || add[0] == '\0')
+ return (cur);
+
+ if (cur) {
+ curlen = strlen(cur);
+ if (curlen)
+ hasnewline = cur[curlen - 1] == '\n';
+ eol_seen = 0;
+ }
+ else
+ curlen = 0;
+
+ str = add;
+ iscomment = 0;
+ while (*str) {
+ if (*str != ' ' && *str != '\t')
+ break;
+ ++str;
+ }
+ iscomment = (*str == '#');
+
+ len = strlen(add);
+ endnewline = add[len - 1] == '\n';
+ len += 1 + iscomment + (!hasnewline) + (!endnewline) + eol_seen;
+
+ if ((str = xf86confrealloc(cur, len + curlen)) == NULL)
+ return (cur);
+
+ cur = str;
+
+ if (eol_seen || (curlen && !hasnewline))
+ cur[curlen++] = '\n';
+ if (!iscomment)
+ cur[curlen++] = '#';
+ strcpy(cur + curlen, add);
+ if (!endnewline)
+ strcat(cur, "\n");
+
+ return (cur);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/write.c b/nx-X11/programs/Xserver/hw/xfree86/parser/write.c
new file mode 100644
index 000000000..285080d99
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/write.c
@@ -0,0 +1,220 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/write.c,v 1.18 2003/08/24 17:37:08 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <signal.h>
+#include <errno.h>
+
+#if ((defined(sun) && !defined(SVR4)) || defined(macII)) && !defined(__GLIBC__)
+#ifndef strerror
+extern char *sys_errlist[];
+extern int sys_nerr;
+#define strerror(n) \
+ (((n) >= 0 && (n) < sys_nerr) ? sys_errlist[n] : "unknown error")
+#endif
+#endif
+
+#if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED)
+#define HAS_SAVED_IDS_AND_SETEUID
+#endif
+#if defined(__UNIXOS2__) || defined(WIN32)
+#define HAS_NO_UIDS
+#endif
+
+#ifdef HAS_NO_UIDS
+#define doWriteConfigFile xf86writeConfigFile
+#define Local /**/
+#else
+#define Local static
+#endif
+
+Local int
+doWriteConfigFile (const char *filename, XF86ConfigPtr cptr)
+{
+ FILE *cf;
+
+ if ((cf = fopen (filename, "w")) == NULL)
+ {
+ return 0;
+ }
+
+ if (cptr->conf_comment)
+ fprintf (cf, "%s\n", cptr->conf_comment);
+
+ xf86printLayoutSection (cf, cptr->conf_layout_lst);
+
+ fprintf (cf, "Section \"Files\"\n");
+ xf86printFileSection (cf, cptr->conf_files);
+ fprintf (cf, "EndSection\n\n");
+
+ fprintf (cf, "Section \"Module\"\n");
+ xf86printModuleSection (cf, cptr->conf_modules);
+ fprintf (cf, "EndSection\n\n");
+
+ xf86printVendorSection (cf, cptr->conf_vendor_lst);
+
+ xf86printServerFlagsSection (cf, cptr->conf_flags);
+
+ xf86printInputSection (cf, cptr->conf_input_lst);
+
+ xf86printVideoAdaptorSection (cf, cptr->conf_videoadaptor_lst);
+
+ xf86printModesSection (cf, cptr->conf_modes_lst);
+
+ xf86printMonitorSection (cf, cptr->conf_monitor_lst);
+
+ xf86printDeviceSection (cf, cptr->conf_device_lst);
+
+ xf86printScreenSection (cf, cptr->conf_screen_lst);
+
+ xf86printDRISection (cf, cptr->conf_dri);
+
+ xf86printExtensionsSection (cf, cptr->conf_extensions);
+
+ fclose(cf);
+ return 1;
+}
+
+#ifndef HAS_NO_UIDS
+
+int
+xf86writeConfigFile (const char *filename, XF86ConfigPtr cptr)
+{
+ int ret;
+
+#if !defined(HAS_SAVED_IDS_AND_SETEUID)
+ int pid, p;
+ int status;
+ void (*csig)(int);
+#else
+ int ruid, euid;
+#endif
+
+ if (getuid() != geteuid())
+ {
+
+#if !defined(HAS_SAVED_IDS_AND_SETEUID)
+ /* Need to fork to change ruid without loosing euid */
+#ifdef SIGCHLD
+ csig = signal(SIGCHLD, SIG_DFL);
+#endif
+ switch ((pid = fork()))
+ {
+ case -1:
+ ErrorF("xf86writeConfigFile(): fork failed (%s)\n",
+ strerror(errno));
+ return 0;
+ case 0: /* child */
+ setuid(getuid());
+ ret = doWriteConfigFile(filename, cptr);
+ exit(ret);
+ break;
+ default: /* parent */
+ do
+ {
+ p = waitpid(pid, &status, 0);
+ } while (p == -1 && errno == EINTR);
+ }
+#ifdef SIGCHLD
+ signal(SIGCHLD, csig);
+#endif
+ if (p != -1 && WIFEXITED(status) && WEXITSTATUS(status) == 0)
+ return 1; /* success */
+ else
+ return 0;
+
+#else /* HAS_SAVED_IDS_AND_SETEUID */
+
+ ruid = getuid();
+ euid = geteuid();
+
+ if (seteuid(ruid) == -1)
+ {
+ ErrorF("xf86writeConfigFile(): seteuid(%d) failed (%s)\n",
+ ruid, strerror(errno));
+ return 0;
+ }
+ ret = doWriteConfigFile(filename, cptr);
+
+ if (seteuid(euid) == -1)
+ {
+ ErrorF("xf86writeConfigFile(): seteuid(%d) failed (%s)\n",
+ euid, strerror(errno));
+ }
+ return ret;
+
+#endif /* HAS_SAVED_IDS_AND_SETEUID */
+
+ }
+ else
+ {
+ return doWriteConfigFile(filename, cptr);
+ }
+}
+
+#endif /* !HAS_NO_UIDS */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/xf86Optrec.h b/nx-X11/programs/Xserver/hw/xfree86/parser/xf86Optrec.h
new file mode 100644
index 000000000..c38f2c219
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/xf86Optrec.h
@@ -0,0 +1,113 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86Optrec.h,v 1.11 2003/08/24 17:37:08 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2001 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/*
+ * This file contains the Option Record that is passed between the Parser,
+ * and Module setup procs.
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _xf86Optrec_h_
+#define _xf86Optrec_h_
+#include <stdio.h>
+
+/*
+ * all records that need to be linked lists should contain a GenericList as
+ * their first field.
+ */
+typedef struct generic_list_rec
+{
+ void *next;
+}
+GenericListRec, *GenericListPtr, *glp;
+
+/*
+ * All options are stored using this data type.
+ */
+typedef struct
+{
+ GenericListRec list;
+ char *opt_name;
+ char *opt_val;
+ int opt_used;
+ char *opt_comment;
+}
+XF86OptionRec, *XF86OptionPtr;
+
+
+XF86OptionPtr xf86addNewOption(XF86OptionPtr head, char *name, char *val);
+XF86OptionPtr xf86optionListDup(XF86OptionPtr opt);
+void xf86optionListFree(XF86OptionPtr opt);
+char *xf86optionName(XF86OptionPtr opt);
+char *xf86optionValue(XF86OptionPtr opt);
+XF86OptionPtr xf86newOption(char *name, char *value);
+XF86OptionPtr xf86nextOption(XF86OptionPtr list);
+XF86OptionPtr xf86findOption(XF86OptionPtr list, const char *name);
+char *xf86findOptionValue(XF86OptionPtr list, const char *name);
+int xf86findOptionBoolean (XF86OptionPtr, const char *, int);
+XF86OptionPtr xf86optionListCreate(const char **options, int count, int used);
+XF86OptionPtr xf86optionListMerge(XF86OptionPtr head, XF86OptionPtr tail);
+char *xf86configStrdup (const char *s);
+int xf86nameCompare (const char *s1, const char *s2);
+char *xf86uLongToString(unsigned long i);
+void xf86debugListOptions(XF86OptionPtr);
+XF86OptionPtr xf86parseOption(XF86OptionPtr head);
+void xf86printOptionList(FILE *fp, XF86OptionPtr list, int tabs);
+
+
+#endif /* _xf86Optrec_h_ */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/xf86Parser.h b/nx-X11/programs/Xserver/hw/xfree86/parser/xf86Parser.h
new file mode 100644
index 000000000..71568842d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/xf86Parser.h
@@ -0,0 +1,483 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h,v 1.33 2003/10/08 14:58:30 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/*
+ * This file contains the external interfaces for the XFree86 configuration
+ * file parser.
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _xf86Parser_h_
+#define _xf86Parser_h_
+
+#include "xf86Optrec.h"
+
+#define HAVE_PARSER_DECLS
+
+typedef struct
+{
+ char *file_logfile;
+ char *file_rgbpath;
+ char *file_modulepath;
+ char *file_inputdevs;
+ char *file_fontpath;
+ char *file_comment;
+}
+XF86ConfFilesRec, *XF86ConfFilesPtr;
+
+/* Values for load_type */
+#define XF86_LOAD_MODULE 0
+#define XF86_LOAD_DRIVER 1
+
+typedef struct
+{
+ GenericListRec list;
+ int load_type;
+ char *load_name;
+ XF86OptionPtr load_opt;
+ char *load_comment;
+}
+XF86LoadRec, *XF86LoadPtr;
+
+typedef struct
+{
+ XF86LoadPtr mod_load_lst;
+ char *mod_comment;
+}
+XF86ConfModuleRec, *XF86ConfModulePtr;
+
+#define CONF_IMPLICIT_KEYBOARD "Implicit Core Keyboard"
+
+#define CONF_IMPLICIT_POINTER "Implicit Core Pointer"
+
+#define XF86CONF_PHSYNC 0x0001
+#define XF86CONF_NHSYNC 0x0002
+#define XF86CONF_PVSYNC 0x0004
+#define XF86CONF_NVSYNC 0x0008
+#define XF86CONF_INTERLACE 0x0010
+#define XF86CONF_DBLSCAN 0x0020
+#define XF86CONF_CSYNC 0x0040
+#define XF86CONF_PCSYNC 0x0080
+#define XF86CONF_NCSYNC 0x0100
+#define XF86CONF_HSKEW 0x0200 /* hskew provided */
+#define XF86CONF_BCAST 0x0400
+#define XF86CONF_CUSTOM 0x0800 /* timing numbers customized by editor */
+#define XF86CONF_VSCAN 0x1000
+
+typedef struct
+{
+ GenericListRec list;
+ char *ml_identifier;
+ int ml_clock;
+ int ml_hdisplay;
+ int ml_hsyncstart;
+ int ml_hsyncend;
+ int ml_htotal;
+ int ml_vdisplay;
+ int ml_vsyncstart;
+ int ml_vsyncend;
+ int ml_vtotal;
+ int ml_vscan;
+ int ml_flags;
+ int ml_hskew;
+ char *ml_comment;
+}
+XF86ConfModeLineRec, *XF86ConfModeLinePtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *vp_identifier;
+ XF86OptionPtr vp_option_lst;
+ char *vp_comment;
+}
+XF86ConfVideoPortRec, *XF86ConfVideoPortPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *va_identifier;
+ char *va_vendor;
+ char *va_board;
+ char *va_busid;
+ char *va_driver;
+ XF86OptionPtr va_option_lst;
+ XF86ConfVideoPortPtr va_port_lst;
+ char *va_fwdref;
+ char *va_comment;
+}
+XF86ConfVideoAdaptorRec, *XF86ConfVideoAdaptorPtr;
+
+#define CONF_MAX_HSYNC 8
+#define CONF_MAX_VREFRESH 8
+
+typedef struct
+{
+ float hi, lo;
+}
+parser_range;
+
+typedef struct
+{
+ int red, green, blue;
+}
+parser_rgb;
+
+typedef struct
+{
+ GenericListRec list;
+ char *modes_identifier;
+ XF86ConfModeLinePtr mon_modeline_lst;
+ char *modes_comment;
+}
+XF86ConfModesRec, *XF86ConfModesPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *ml_modes_str;
+ XF86ConfModesPtr ml_modes;
+}
+XF86ConfModesLinkRec, *XF86ConfModesLinkPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *mon_identifier;
+ char *mon_vendor;
+ char *mon_modelname;
+ int mon_width; /* in mm */
+ int mon_height; /* in mm */
+ XF86ConfModeLinePtr mon_modeline_lst;
+ int mon_n_hsync;
+ parser_range mon_hsync[CONF_MAX_HSYNC];
+ int mon_n_vrefresh;
+ parser_range mon_vrefresh[CONF_MAX_VREFRESH];
+ float mon_gamma_red;
+ float mon_gamma_green;
+ float mon_gamma_blue;
+ XF86OptionPtr mon_option_lst;
+ XF86ConfModesLinkPtr mon_modes_sect_lst;
+ char *mon_comment;
+}
+XF86ConfMonitorRec, *XF86ConfMonitorPtr;
+
+#define CONF_MAXDACSPEEDS 4
+#define CONF_MAXCLOCKS 128
+
+typedef struct
+{
+ GenericListRec list;
+ char *dev_identifier;
+ char *dev_vendor;
+ char *dev_board;
+ char *dev_chipset;
+ char *dev_busid;
+ char *dev_card;
+ char *dev_driver;
+ char *dev_ramdac;
+ int dev_dacSpeeds[CONF_MAXDACSPEEDS];
+ int dev_videoram;
+ int dev_textclockfreq;
+ unsigned long dev_bios_base;
+ unsigned long dev_mem_base;
+ unsigned long dev_io_base;
+ char *dev_clockchip;
+ int dev_clocks;
+ int dev_clock[CONF_MAXCLOCKS];
+ int dev_chipid;
+ int dev_chiprev;
+ int dev_irq;
+ int dev_screen;
+ XF86OptionPtr dev_option_lst;
+ char *dev_comment;
+}
+XF86ConfDeviceRec, *XF86ConfDevicePtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *mode_name;
+}
+XF86ModeRec, *XF86ModePtr;
+
+typedef struct
+{
+ GenericListRec list;
+ int disp_frameX0;
+ int disp_frameY0;
+ int disp_virtualX;
+ int disp_virtualY;
+ int disp_depth;
+ int disp_bpp;
+ char *disp_visual;
+ parser_rgb disp_weight;
+ parser_rgb disp_black;
+ parser_rgb disp_white;
+ XF86ModePtr disp_mode_lst;
+ XF86OptionPtr disp_option_lst;
+ char *disp_comment;
+}
+XF86ConfDisplayRec, *XF86ConfDisplayPtr;
+
+typedef struct
+{
+ XF86OptionPtr flg_option_lst;
+ char *flg_comment;
+}
+XF86ConfFlagsRec, *XF86ConfFlagsPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *al_adaptor_str;
+ XF86ConfVideoAdaptorPtr al_adaptor;
+}
+XF86ConfAdaptorLinkRec, *XF86ConfAdaptorLinkPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *scrn_identifier;
+ char *scrn_obso_driver;
+ int scrn_defaultdepth;
+ int scrn_defaultbpp;
+ int scrn_defaultfbbpp;
+ char *scrn_monitor_str;
+ XF86ConfMonitorPtr scrn_monitor;
+ char *scrn_device_str;
+ XF86ConfDevicePtr scrn_device;
+ XF86ConfAdaptorLinkPtr scrn_adaptor_lst;
+ XF86ConfDisplayPtr scrn_display_lst;
+ XF86OptionPtr scrn_option_lst;
+ char *scrn_comment;
+}
+XF86ConfScreenRec, *XF86ConfScreenPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *inp_identifier;
+ char *inp_driver;
+ XF86OptionPtr inp_option_lst;
+ char *inp_comment;
+}
+XF86ConfInputRec, *XF86ConfInputPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ XF86ConfInputPtr iref_inputdev;
+ char *iref_inputdev_str;
+ XF86OptionPtr iref_option_lst;
+}
+XF86ConfInputrefRec, *XF86ConfInputrefPtr;
+
+/* Values for adj_where */
+#define CONF_ADJ_OBSOLETE -1
+#define CONF_ADJ_ABSOLUTE 0
+#define CONF_ADJ_RIGHTOF 1
+#define CONF_ADJ_LEFTOF 2
+#define CONF_ADJ_ABOVE 3
+#define CONF_ADJ_BELOW 4
+#define CONF_ADJ_RELATIVE 5
+
+typedef struct
+{
+ GenericListRec list;
+ int adj_scrnum;
+ XF86ConfScreenPtr adj_screen;
+ char *adj_screen_str;
+ XF86ConfScreenPtr adj_top;
+ char *adj_top_str;
+ XF86ConfScreenPtr adj_bottom;
+ char *adj_bottom_str;
+ XF86ConfScreenPtr adj_left;
+ char *adj_left_str;
+ XF86ConfScreenPtr adj_right;
+ char *adj_right_str;
+ int adj_where;
+ int adj_x;
+ int adj_y;
+ char *adj_refscreen;
+}
+XF86ConfAdjacencyRec, *XF86ConfAdjacencyPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *inactive_device_str;
+ XF86ConfDevicePtr inactive_device;
+}
+XF86ConfInactiveRec, *XF86ConfInactivePtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *lay_identifier;
+ XF86ConfAdjacencyPtr lay_adjacency_lst;
+ XF86ConfInactivePtr lay_inactive_lst;
+ XF86ConfInputrefPtr lay_input_lst;
+ XF86OptionPtr lay_option_lst;
+ char *lay_comment;
+}
+XF86ConfLayoutRec, *XF86ConfLayoutPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *vs_name;
+ char *vs_identifier;
+ XF86OptionPtr vs_option_lst;
+ char *vs_comment;
+}
+XF86ConfVendSubRec, *XF86ConfVendSubPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *vnd_identifier;
+ XF86OptionPtr vnd_option_lst;
+ XF86ConfVendSubPtr vnd_sub_lst;
+ char *vnd_comment;
+}
+XF86ConfVendorRec, *XF86ConfVendorPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ int buf_count;
+ int buf_size;
+ char *buf_flags;
+ char *buf_comment;
+}
+XF86ConfBuffersRec, *XF86ConfBuffersPtr;
+
+typedef struct
+{
+ char *dri_group_name;
+ int dri_group;
+ int dri_mode;
+ XF86ConfBuffersPtr dri_buffers_lst;
+ char *dri_comment;
+}
+XF86ConfDRIRec, *XF86ConfDRIPtr;
+
+typedef struct
+{
+ XF86OptionPtr ext_option_lst;
+ char *extensions_comment;
+}
+XF86ConfExtensionsRec, *XF86ConfExtensionsPtr;
+
+typedef struct
+{
+ XF86ConfFilesPtr conf_files;
+ XF86ConfModulePtr conf_modules;
+ XF86ConfFlagsPtr conf_flags;
+ XF86ConfVideoAdaptorPtr conf_videoadaptor_lst;
+ XF86ConfModesPtr conf_modes_lst;
+ XF86ConfMonitorPtr conf_monitor_lst;
+ XF86ConfDevicePtr conf_device_lst;
+ XF86ConfScreenPtr conf_screen_lst;
+ XF86ConfInputPtr conf_input_lst;
+ XF86ConfLayoutPtr conf_layout_lst;
+ XF86ConfVendorPtr conf_vendor_lst;
+ XF86ConfDRIPtr conf_dri;
+ XF86ConfExtensionsPtr conf_extensions;
+ char *conf_comment;
+}
+XF86ConfigRec, *XF86ConfigPtr;
+
+typedef struct
+{
+ int token; /* id of the token */
+ char *name; /* pointer to the LOWERCASED name */
+}
+xf86ConfigSymTabRec, *xf86ConfigSymTabPtr;
+
+/*
+ * prototypes for public functions
+ */
+extern const char *xf86openConfigFile (const char *, const char *,
+ const char *);
+extern void xf86setBuiltinConfig(const char *config[]);
+extern XF86ConfigPtr xf86readConfigFile (void);
+extern void xf86closeConfigFile (void);
+extern void xf86freeConfig (XF86ConfigPtr p);
+extern int xf86writeConfigFile (const char *, XF86ConfigPtr);
+XF86ConfDevicePtr xf86findDevice(const char *ident, XF86ConfDevicePtr p);
+XF86ConfLayoutPtr xf86findLayout(const char *name, XF86ConfLayoutPtr list);
+XF86ConfMonitorPtr xf86findMonitor(const char *ident, XF86ConfMonitorPtr p);
+XF86ConfModesPtr xf86findModes(const char *ident, XF86ConfModesPtr p);
+XF86ConfModeLinePtr xf86findModeLine(const char *ident, XF86ConfModeLinePtr p);
+XF86ConfScreenPtr xf86findScreen(const char *ident, XF86ConfScreenPtr p);
+XF86ConfInputPtr xf86findInput(const char *ident, XF86ConfInputPtr p);
+XF86ConfInputPtr xf86findInputByDriver(const char *driver, XF86ConfInputPtr p);
+XF86ConfVendorPtr xf86findVendor(const char *name, XF86ConfVendorPtr list);
+XF86ConfVideoAdaptorPtr xf86findVideoAdaptor(const char *ident,
+ XF86ConfVideoAdaptorPtr p);
+
+GenericListPtr xf86addListItem(GenericListPtr head, GenericListPtr c_new);
+int xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2);
+
+int xf86pathIsAbsolute(const char *path);
+int xf86pathIsSafe(const char *path);
+char *xf86addComment(char *cur, char *add);
+
+#endif /* _xf86Parser_h_ */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/parser/xf86tokens.h b/nx-X11/programs/Xserver/hw/xfree86/parser/xf86tokens.h
new file mode 100644
index 000000000..3c7e68ece
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/parser/xf86tokens.h
@@ -0,0 +1,280 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86tokens.h,v 1.20 2003/08/24 17:37:09 dawes Exp $ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _xf86_tokens_h
+#define _xf86_tokens_h
+
+/* Undefine symbols that some OSs might define */
+#undef IOBASE
+
+/*
+ * Each token should have a unique value regardless of the section
+ * it is used in.
+ */
+
+typedef enum {
+ /* errno-style tokens */
+ EOF_TOKEN = -4,
+ LOCK_TOKEN = -3,
+ ERROR_TOKEN = -2,
+
+ /* value type tokens */
+ NUMBER = 1,
+ STRING,
+
+ /* Tokens that can appear in many sections */
+ SECTION,
+ SUBSECTION,
+ ENDSECTION,
+ ENDSUBSECTION,
+ IDENTIFIER,
+ VENDOR,
+ DASH,
+ COMMA,
+ OPTION,
+ COMMENT,
+
+ /* Frequency units */
+ HRZ,
+ KHZ,
+ MHZ,
+
+ /* File tokens */
+ FONTPATH,
+ RGBPATH,
+ MODULEPATH,
+ INPUTDEVICES,
+ LOGFILEPATH,
+
+ /* Server Flag tokens. These are deprecated in favour of generic Options */
+ NOTRAPSIGNALS,
+ DONTZAP,
+ DONTZOOM,
+ DISABLEVIDMODE,
+ ALLOWNONLOCAL,
+ DISABLEMODINDEV,
+ MODINDEVALLOWNONLOCAL,
+ ALLOWMOUSEOPENFAIL,
+ BLANKTIME,
+ STANDBYTIME,
+ SUSPENDTIME,
+ OFFTIME,
+ DEFAULTLAYOUT,
+
+ /* Monitor tokens */
+ MODEL,
+ MODELINE,
+ DISPLAYSIZE,
+ HORIZSYNC,
+ VERTREFRESH,
+ MODE,
+ GAMMA,
+ USEMODES,
+
+ /* Modes tokens */
+ /* no new ones */
+
+ /* Mode tokens */
+ DOTCLOCK,
+ HTIMINGS,
+ VTIMINGS,
+ FLAGS,
+ HSKEW,
+ BCAST,
+ VSCAN,
+ ENDMODE,
+
+ /* Screen tokens */
+ OBSDRIVER,
+ MDEVICE,
+ MONITOR,
+ SCREENNO,
+ DEFAULTDEPTH,
+ DEFAULTBPP,
+ DEFAULTFBBPP,
+
+ /* VideoAdaptor tokens */
+ VIDEOADAPTOR,
+
+ /* Mode timing tokens */
+ TT_INTERLACE,
+ TT_PHSYNC,
+ TT_NHSYNC,
+ TT_PVSYNC,
+ TT_NVSYNC,
+ TT_CSYNC,
+ TT_PCSYNC,
+ TT_NCSYNC,
+ TT_DBLSCAN,
+ TT_HSKEW,
+ TT_BCAST,
+ TT_VSCAN,
+ TT_CUSTOM,
+
+ /* Module tokens */
+ LOAD,
+ LOAD_DRIVER,
+
+ /* Device tokens */
+ DRIVER,
+ CHIPSET,
+ CLOCKS,
+ VIDEORAM,
+ BOARD,
+ IOBASE,
+ RAMDAC,
+ DACSPEED,
+ BIOSBASE,
+ MEMBASE,
+ CLOCKCHIP,
+ CHIPID,
+ CHIPREV,
+ CARD,
+ BUSID,
+ TEXTCLOCKFRQ,
+ IRQ,
+
+ /* Keyboard tokens */
+ AUTOREPEAT,
+ XLEDS,
+ KPROTOCOL,
+ XKBKEYMAP,
+ XKBCOMPAT,
+ XKBTYPES,
+ XKBKEYCODES,
+ XKBGEOMETRY,
+ XKBSYMBOLS,
+ XKBDISABLE,
+ PANIX106,
+ XKBRULES,
+ XKBMODEL,
+ XKBLAYOUT,
+ XKBVARIANT,
+ XKBOPTIONS,
+ /* The next two have become ServerFlags options */
+ VTINIT,
+ VTSYSREQ,
+ /* Obsolete keyboard tokens */
+ SERVERNUM,
+ LEFTALT,
+ RIGHTALT,
+ SCROLLLOCK_TOK,
+ RIGHTCTL,
+ /* arguments for the above obsolete tokens */
+ CONF_KM_META,
+ CONF_KM_COMPOSE,
+ CONF_KM_MODESHIFT,
+ CONF_KM_MODELOCK,
+ CONF_KM_SCROLLLOCK,
+ CONF_KM_CONTROL,
+
+ /* Pointer tokens */
+ EMULATE3,
+ BAUDRATE,
+ SAMPLERATE,
+ PRESOLUTION,
+ CLEARDTR,
+ CLEARRTS,
+ CHORDMIDDLE,
+ PROTOCOL,
+ PDEVICE,
+ EM3TIMEOUT,
+ DEVICE_NAME,
+ ALWAYSCORE,
+ PBUTTONS,
+ ZAXISMAPPING,
+
+ /* Pointer Z axis mapping tokens */
+ XAXIS,
+ YAXIS,
+
+ /* Display tokens */
+ MODES,
+ VIEWPORT,
+ VIRTUAL,
+ VISUAL,
+ BLACK_TOK,
+ WHITE_TOK,
+ DEPTH,
+ BPP,
+ WEIGHT,
+
+ /* Layout Tokens */
+ SCREEN,
+ INACTIVE,
+ INPUTDEVICE,
+
+ /* Adjaceny Tokens */
+ RIGHTOF,
+ LEFTOF,
+ ABOVE,
+ BELOW,
+ RELATIVE,
+ ABSOLUTE,
+
+ /* Vendor Tokens */
+ VENDORNAME,
+
+ /* DRI Tokens */
+ GROUP,
+ BUFFERS
+} ParserTokens;
+
+#endif /* _xf86_tokens_h */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/xf86Date.h b/nx-X11/programs/Xserver/hw/xfree86/xf86Date.h
new file mode 100644
index 000000000..ce2b6ee24
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/xf86Date.h
@@ -0,0 +1,38 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86Date.h,v 1.6 2005/07/03 07:01:24 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86Date.h,v 1.54 2003/12/19 04:52:10 dawes Exp $ */
+/*
+ * Copyright (c) 2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef XF86_DATE
+
+#define XF86_DATE "18 December 2003"
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/xf86Version.h b/nx-X11/programs/Xserver/hw/xfree86/xf86Version.h
new file mode 100644
index 000000000..3996c3581
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/xf86Version.h
@@ -0,0 +1,62 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 1.5 2005/08/24 11:18:35 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 3.566 2003/12/19 04:52:11 dawes Exp $ */
+
+/*
+ * Copyright (c) 1994-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifndef XF86_VERSION_CURRENT
+
+#define XF86_VERSION_MAJOR 4
+#define XF86_VERSION_MINOR 3
+#define XF86_VERSION_PATCH 99
+#define XF86_VERSION_SNAP 902
+
+/* This has five arguments for compatibilty reasons */
+#define XF86_VERSION_NUMERIC(major,minor,patch,snap,dummy) \
+ (((major) * 10000000) + ((minor) * 100000) + ((patch) * 1000) + snap)
+
+#define XF86_GET_MAJOR_VERSION(vers) ((vers) / 10000000)
+#define XF86_GET_MINOR_VERSION(vers) (((vers) % 10000000) / 100000)
+#define XF86_GET_PATCH_VERSION(vers) (((vers) % 100000) / 1000)
+#define XF86_GET_SNAP_VERSION(vers) ((vers) % 1000)
+
+/* Define these for compatibility. They'll be removed at some point. */
+#define XF86_VERSION_SUBMINOR XF86_VERSION_PATCH
+#define XF86_VERSION_BETA 0
+#define XF86_VERSION_ALPHA XF86_VERSION_SNAP
+
+#define XF86_VERSION_CURRENT \
+ XF86_VERSION_NUMERIC(XF86_VERSION_MAJOR, \
+ XF86_VERSION_MINOR, \
+ XF86_VERSION_PATCH, \
+ XF86_VERSION_SNAP, \
+ 0)
+
+#endif
+
+/* $XConsortium: xf86Version.h /main/78 1996/10/28 05:42:10 kaleb $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 1.5 2005/08/24 11:18:35 daniels Exp $ */
diff --git a/nx-X11/programs/Xserver/hw/xnest/Args.c b/nx-X11/programs/Xserver/hw/xnest/Args.c
new file mode 100644
index 000000000..a36677491
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Args.c
@@ -0,0 +1,197 @@
+/* $Xorg: Args.c,v 1.3 2000/08/17 19:53:26 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "screenint.h"
+#include "input.h"
+#include "misc.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Args.h"
+
+char *xnestDisplayName = NULL;
+Bool xnestSynchronize = False;
+Bool xnestFullGeneration = False;
+int xnestDefaultClass;
+Bool xnestUserDefaultClass = False;
+int xnestDefaultDepth;
+Bool xnestUserDefaultDepth = False;
+Bool xnestSoftwareScreenSaver = False;
+int xnestX;
+int xnestY;
+unsigned int xnestWidth;
+unsigned int xnestHeight;
+int xnestUserGeometry = 0;
+int xnestBorderWidth;
+Bool xnestUserBorderWidth = False;
+char *xnestWindowName = NULL;
+int xnestNumScreens = 0;
+Bool xnestDoDirectColormaps = False;
+Window xnestParentWindow = 0;
+
+/* ddxInitGlobals - called by |InitGlobals| from os/util.c */
+void ddxInitGlobals(void)
+{
+}
+
+int
+ddxProcessArgument (int argc, char *argv[], int i)
+{
+ if (!strcmp(argv[i], "-display")) {
+ if (++i < argc) {
+ xnestDisplayName = argv[i];
+ return 2;
+ }
+ return 0;
+ }
+ if (!strcmp(argv[i], "-sync")) {
+ xnestSynchronize = True;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-full")) {
+ xnestFullGeneration = True;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-class")) {
+ if (++i < argc) {
+ if (!strcmp(argv[i], "StaticGray")) {
+ xnestDefaultClass = StaticGray;
+ xnestUserDefaultClass = True;
+ return 2;
+ }
+ else if (!strcmp(argv[i], "GrayScale")) {
+ xnestDefaultClass = GrayScale;
+ xnestUserDefaultClass = True;
+ return 2;
+ }
+ else if (!strcmp(argv[i], "StaticColor")) {
+ xnestDefaultClass = StaticColor;
+ xnestUserDefaultClass = True;
+ return 2;
+ }
+ else if (!strcmp(argv[i], "PseudoColor")) {
+ xnestDefaultClass = PseudoColor;
+ xnestUserDefaultClass = True;
+ return 2;
+ }
+ else if (!strcmp(argv[i], "TrueColor")) {
+ xnestDefaultClass = TrueColor;
+ xnestUserDefaultClass = True;
+ return 2;
+ }
+ else if (!strcmp(argv[i], "DirectColor")) {
+ xnestDefaultClass = DirectColor;
+ xnestUserDefaultClass = True;
+ return 2;
+ }
+ }
+ return 0;
+ }
+ if (!strcmp(argv[i], "-cc")) {
+ if (++i < argc && sscanf(argv[i], "%i", &xnestDefaultClass) == 1) {
+ if (xnestDefaultClass >= 0 && xnestDefaultClass <= 5) {
+ xnestUserDefaultClass = True;
+ /* lex the OS layer process it as well, so return 0 */
+ }
+ }
+ return 0;
+ }
+ if (!strcmp(argv[i], "-depth")) {
+ if (++i < argc && sscanf(argv[i], "%i", &xnestDefaultDepth) == 1) {
+ if (xnestDefaultDepth > 0) {
+ xnestUserDefaultDepth = True;
+ return 2;
+ }
+ }
+ return 0;
+ }
+ if (!strcmp(argv[i], "-sss")) {
+ xnestSoftwareScreenSaver = True;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-geometry")) {
+ if (++i < argc) {
+ xnestUserGeometry = XParseGeometry(argv[i],
+ &xnestX, &xnestY,
+ &xnestWidth, &xnestHeight);
+ if (xnestUserGeometry) return 2;
+ }
+ return 0;
+ }
+ if (!strcmp(argv[i], "-bw")) {
+ if (++i < argc && sscanf(argv[i], "%i", &xnestBorderWidth) == 1) {
+ if (xnestBorderWidth >= 0) {
+ xnestUserBorderWidth = True;
+ return 2;
+ }
+ }
+ return 0;
+ }
+ if (!strcmp(argv[i], "-name")) {
+ if (++i < argc) {
+ xnestWindowName = argv[i];
+ return 2;
+ }
+ return 0;
+ }
+ if (!strcmp(argv[i], "-scrns")) {
+ if (++i < argc && sscanf(argv[i], "%i", &xnestNumScreens) == 1) {
+ if (xnestNumScreens > 0) {
+ if (xnestNumScreens > MAXSCREENS) {
+ ErrorF("Maximum number of screens is %d.\n", MAXSCREENS);
+ xnestNumScreens = MAXSCREENS;
+ }
+ return 2;
+ }
+ }
+ return 0;
+ }
+ if (!strcmp(argv[i], "-install")) {
+ xnestDoDirectColormaps = True;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-parent")) {
+ if (++i < argc) {
+ xnestParentWindow = (XID) strtol (argv[i], (char**)NULL, 0);
+ return 2;
+ }
+ }
+ return 0;
+}
+
+void ddxUseMsg()
+{
+ ErrorF("-display string display name of the real server\n");
+ ErrorF("-sync sinchronize with the real server\n");
+ ErrorF("-full utilize full regeneration\n");
+ ErrorF("-class string default visual class\n");
+ ErrorF("-depth int default depth\n");
+ ErrorF("-sss use software screen saver\n");
+ ErrorF("-geometry WxH+X+Y window size and position\n");
+ ErrorF("-bw int window border width\n");
+ ErrorF("-name string window name\n");
+ ErrorF("-scrns int number of screens to generate\n");
+ ErrorF("-install instal colormaps directly\n");
+}
diff --git a/nx-X11/programs/Xserver/hw/xnest/Args.h b/nx-X11/programs/Xserver/hw/xnest/Args.h
new file mode 100644
index 000000000..a0c586bcb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Args.h
@@ -0,0 +1,40 @@
+/* $Xorg: Args.h,v 1.3 2000/08/17 19:53:27 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+#ifndef XNESTARGC_H
+#define XNESTARGS_H
+
+extern char *xnestDisplayName;
+extern Bool xnestSynchronize;
+extern Bool xnestFullGeneration;
+extern int xnestDefaultClass;
+extern Bool xnestUserDefaultClass;
+extern int xnestDefaultDepth;
+extern Bool xnestUserDefaultDepth;
+extern Bool xnestSoftwareScreenSaver;
+extern int xnestX;
+extern int xnestY;
+extern unsigned int xnestWidth;
+extern unsigned int xnestHeight;
+extern int xnestUserGeometry;
+extern int xnestBorderWidth;
+extern Bool xnestUserBorderWidth;
+extern char *xnestWindowName;
+extern int xnestNumScreens;
+extern Bool xnestDoDirectColormaps;
+extern Window xnestParentWindow;
+
+#endif /* XNESTARGS_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/Color.c b/nx-X11/programs/Xserver/hw/xnest/Color.c
new file mode 100644
index 000000000..779633a96
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Color.c
@@ -0,0 +1,497 @@
+/* $Xorg: Color.c,v 1.3 2000/08/17 19:53:27 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "window.h"
+#include "windowstr.h"
+#include "colormapst.h"
+#include "resource.h"
+
+#include "Xnest.h"
+
+
+#include "Display.h"
+#include "Screen.h"
+#include "Color.h"
+#include "Visual.h"
+#include "XNWindow.h"
+#include "Args.h"
+
+static ColormapPtr InstalledMaps[MAXSCREENS];
+
+Bool
+xnestCreateColormap(ColormapPtr pCmap)
+{
+ VisualPtr pVisual;
+ XColor *colors;
+ int i, ncolors;
+ Pixel red, green, blue;
+ Pixel redInc, greenInc, blueInc;
+
+ pVisual = pCmap->pVisual;
+ ncolors = pVisual->ColormapEntries;
+
+ pCmap->devPriv = (pointer)xalloc(sizeof(xnestPrivColormap));
+
+ xnestColormapPriv(pCmap)->colormap =
+ XCreateColormap(xnestDisplay,
+ xnestDefaultWindows[pCmap->pScreen->myNum],
+ xnestVisual(pVisual),
+ (pVisual->class & DynamicClass) ?
+ AllocAll : AllocNone);
+
+
+ switch (pVisual->class) {
+ case StaticGray: /* read only */
+ colors = (XColor *)xalloc(ncolors * sizeof(XColor));
+ for (i = 0; i < ncolors; i++)
+ colors[i].pixel = i;
+ XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors);
+ for (i = 0; i < ncolors; i++) {
+ pCmap->red[i].co.local.red = colors[i].red;
+ pCmap->red[i].co.local.green = colors[i].red;
+ pCmap->red[i].co.local.blue = colors[i].red;
+ }
+ xfree(colors);
+ break;
+
+ case StaticColor: /* read only */
+ colors = (XColor *)xalloc(ncolors * sizeof(XColor));
+ for (i = 0; i < ncolors; i++)
+ colors[i].pixel = i;
+ XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors);
+ for (i = 0; i < ncolors; i++) {
+ pCmap->red[i].co.local.red = colors[i].red;
+ pCmap->red[i].co.local.green = colors[i].green;
+ pCmap->red[i].co.local.blue = colors[i].blue;
+ }
+ xfree(colors);
+ break;
+
+ case TrueColor: /* read only */
+ colors = (XColor *)xalloc(ncolors * sizeof(XColor));
+ red = green = blue = 0L;
+ redInc = lowbit(pVisual->redMask);
+ greenInc = lowbit(pVisual->greenMask);
+ blueInc = lowbit(pVisual->blueMask);
+ for (i = 0; i < ncolors; i++) {
+ colors[i].pixel = red | green | blue;
+ red += redInc;
+ if (red > pVisual->redMask) red = 0L;
+ green += greenInc;
+ if (green > pVisual->greenMask) green = 0L;
+ blue += blueInc;
+ if (blue > pVisual->blueMask) blue = 0L;
+ }
+ XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors);
+ for (i = 0; i < ncolors; i++) {
+ pCmap->red[i].co.local.red = colors[i].red;
+ pCmap->green[i].co.local.green = colors[i].green;
+ pCmap->blue[i].co.local.blue = colors[i].blue;
+ }
+ xfree(colors);
+ break;
+
+ case GrayScale: /* read and write */
+ break;
+
+ case PseudoColor: /* read and write */
+ break;
+
+ case DirectColor: /* read and write */
+ break;
+ }
+
+ return True;
+}
+
+void
+xnestDestroyColormap(ColormapPtr pCmap)
+{
+ XFreeColormap(xnestDisplay, xnestColormap(pCmap));
+ xfree(pCmap->devPriv);
+}
+
+#define SEARCH_PREDICATE \
+ (xnestWindow(pWin) != None && wColormap(pWin) == icws->cmapIDs[i])
+
+static int
+xnestCountInstalledColormapWindows(WindowPtr pWin, pointer ptr)
+{
+ xnestInstalledColormapWindows *icws = (xnestInstalledColormapWindows *)ptr;
+ int i;
+
+ for (i = 0; i < icws->numCmapIDs; i++)
+ if (SEARCH_PREDICATE) {
+ icws->numWindows++;
+ return WT_DONTWALKCHILDREN;
+ }
+
+ return WT_WALKCHILDREN;
+}
+
+static int
+xnestGetInstalledColormapWindows(WindowPtr pWin, pointer ptr)
+{
+ xnestInstalledColormapWindows *icws = (xnestInstalledColormapWindows *)ptr;
+ int i;
+
+ for (i = 0; i < icws->numCmapIDs; i++)
+ if (SEARCH_PREDICATE) {
+ icws->windows[icws->index++] = xnestWindow(pWin);
+ return WT_DONTWALKCHILDREN;
+ }
+
+ return WT_WALKCHILDREN;
+}
+
+static Window *xnestOldInstalledColormapWindows = NULL;
+static int xnestNumOldInstalledColormapWindows = 0;
+
+static Bool
+xnestSameInstalledColormapWindows(Window *windows, int numWindows)
+{
+ if (xnestNumOldInstalledColormapWindows != numWindows)
+ return False;
+
+ if (xnestOldInstalledColormapWindows == windows)
+ return True;
+
+ if (xnestOldInstalledColormapWindows == NULL || windows == NULL)
+ return False;
+
+ if (memcmp(xnestOldInstalledColormapWindows, windows,
+ numWindows * sizeof(Window)))
+ return False;
+
+ return True;
+}
+
+void
+xnestSetInstalledColormapWindows(ScreenPtr pScreen)
+{
+ xnestInstalledColormapWindows icws;
+ int numWindows;
+
+ icws.cmapIDs = (Colormap *)xalloc(pScreen->maxInstalledCmaps *
+ sizeof(Colormap));
+ icws.numCmapIDs = xnestListInstalledColormaps(pScreen, icws.cmapIDs);
+ icws.numWindows = 0;
+ WalkTree(pScreen, xnestCountInstalledColormapWindows, (pointer)&icws);
+ if (icws.numWindows) {
+ icws.windows = (Window *)xalloc((icws.numWindows + 1) * sizeof(Window));
+ icws.index = 0;
+ WalkTree(pScreen, xnestGetInstalledColormapWindows, (pointer)&icws);
+ icws.windows[icws.numWindows] = xnestDefaultWindows[pScreen->myNum];
+ numWindows = icws.numWindows + 1;
+ }
+ else {
+ icws.windows = NULL;
+ numWindows = 0;
+ }
+
+ xfree(icws.cmapIDs);
+
+ if (!xnestSameInstalledColormapWindows(icws.windows, icws.numWindows)) {
+ if (xnestOldInstalledColormapWindows)
+ xfree(xnestOldInstalledColormapWindows);
+
+#ifdef _XSERVER64
+ {
+ int i;
+ Window64 *windows = (Window64 *)xalloc(numWindows * sizeof(Window64));
+
+ for(i = 0; i < numWindows; ++i)
+ windows[i] = icws.windows[i];
+ XSetWMColormapWindows(xnestDisplay, xnestDefaultWindows[pScreen->myNum],
+ windows, numWindows);
+ xfree(windows);
+ }
+#else
+ XSetWMColormapWindows(xnestDisplay, xnestDefaultWindows[pScreen->myNum],
+ icws.windows, numWindows);
+#endif
+
+ xnestOldInstalledColormapWindows = icws.windows;
+ xnestNumOldInstalledColormapWindows = icws.numWindows;
+
+#ifdef DUMB_WINDOW_MANAGERS
+ /*
+ This code is for dumb window managers.
+ This will only work with default local visual colormaps.
+ */
+ if (icws.numWindows)
+ {
+ WindowPtr pWin;
+ Visual *visual;
+ ColormapPtr pCmap;
+
+ pWin = xnestWindowPtr(icws.windows[0]);
+ visual = xnestVisualFromID(pScreen, wVisual(pWin));
+
+ if (visual == xnestDefaultVisual(pScreen))
+ pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin),
+ RT_COLORMAP);
+ else
+ pCmap = (ColormapPtr)LookupIDByType(pScreen->defColormap,
+ RT_COLORMAP);
+
+ XSetWindowColormap(xnestDisplay,
+ xnestDefaultWindows[pScreen->myNum],
+ xnestColormap(pCmap));
+ }
+#endif /* DUMB_WINDOW_MANAGERS */
+ }
+ else
+ if (icws.windows) xfree(icws.windows);
+}
+
+void
+xnestSetScreenSaverColormapWindow(ScreenPtr pScreen)
+{
+ if (xnestOldInstalledColormapWindows)
+ xfree(xnestOldInstalledColormapWindows);
+
+#ifdef _XSERVER64
+ {
+ Window64 window;
+
+ window = xnestScreenSaverWindows[pScreen->myNum];
+ XSetWMColormapWindows(xnestDisplay, xnestDefaultWindows[pScreen->myNum],
+ &window, 1);
+ xnestScreenSaverWindows[pScreen->myNum] = window;
+ }
+#else
+ XSetWMColormapWindows(xnestDisplay, xnestDefaultWindows[pScreen->myNum],
+ &xnestScreenSaverWindows[pScreen->myNum], 1);
+#endif /* _XSERVER64 */
+
+ xnestOldInstalledColormapWindows = NULL;
+ xnestNumOldInstalledColormapWindows = 0;
+
+ xnestDirectUninstallColormaps(pScreen);
+}
+
+void
+xnestDirectInstallColormaps(ScreenPtr pScreen)
+{
+ int i, n;
+ Colormap pCmapIDs[MAXCMAPS];
+
+ if (!xnestDoDirectColormaps) return;
+
+ n = (*pScreen->ListInstalledColormaps)(pScreen, pCmapIDs);
+
+ for (i = 0; i < n; i++) {
+ ColormapPtr pCmap;
+
+ pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP);
+ if (pCmap)
+ XInstallColormap(xnestDisplay, xnestColormap(pCmap));
+ }
+}
+
+void
+xnestDirectUninstallColormaps(ScreenPtr pScreen)
+{
+ int i, n;
+ Colormap pCmapIDs[MAXCMAPS];
+
+ if (!xnestDoDirectColormaps) return;
+
+ n = (*pScreen->ListInstalledColormaps)(pScreen, pCmapIDs);
+
+ for (i = 0; i < n; i++) {
+ ColormapPtr pCmap;
+
+ pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP);
+ if (pCmap)
+ XUninstallColormap(xnestDisplay, xnestColormap(pCmap));
+ }
+}
+
+void
+xnestInstallColormap(ColormapPtr pCmap)
+{
+ int index;
+ ColormapPtr pOldCmap;
+
+ index = pCmap->pScreen->myNum;
+ pOldCmap = InstalledMaps[index];
+
+ if(pCmap != pOldCmap)
+ {
+ xnestDirectUninstallColormaps(pCmap->pScreen);
+
+ /* Uninstall pInstalledMap. Notify all interested parties. */
+ if(pOldCmap != (ColormapPtr)None)
+ WalkTree(pCmap->pScreen, TellLostMap, (pointer)&pOldCmap->mid);
+
+ InstalledMaps[index] = pCmap;
+ WalkTree(pCmap->pScreen, TellGainedMap, (pointer)&pCmap->mid);
+
+ xnestSetInstalledColormapWindows(pCmap->pScreen);
+ xnestDirectInstallColormaps(pCmap->pScreen);
+ }
+}
+
+void
+xnestUninstallColormap(ColormapPtr pCmap)
+{
+ int index;
+ ColormapPtr pCurCmap;
+
+ index = pCmap->pScreen->myNum;
+ pCurCmap = InstalledMaps[index];
+
+ if(pCmap == pCurCmap)
+ {
+ if (pCmap->mid != pCmap->pScreen->defColormap)
+ {
+ pCurCmap = (ColormapPtr)LookupIDByType(pCmap->pScreen->defColormap,
+ RT_COLORMAP);
+ (*pCmap->pScreen->InstallColormap)(pCurCmap);
+ }
+ }
+}
+
+static Bool xnestInstalledDefaultColormap = False;
+
+int
+xnestListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapIDs)
+{
+ if (xnestInstalledDefaultColormap) {
+ *pCmapIDs = InstalledMaps[pScreen->myNum]->mid;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+void
+xnestStoreColors(ColormapPtr pCmap, int nColors, xColorItem *pColors)
+{
+ if (pCmap->pVisual->class & DynamicClass)
+#ifdef _XSERVER64
+ {
+ int i;
+ XColor *pColors64 = (XColor *)xalloc(nColors * sizeof(XColor) );
+
+ for(i = 0; i < nColors; ++i)
+ {
+ pColors64[i].pixel = pColors[i].pixel;
+ pColors64[i].red = pColors[i].red;
+ pColors64[i].green = pColors[i].green;
+ pColors64[i].blue = pColors[i].blue;
+ pColors64[i].flags = pColors[i].flags;
+ }
+ XStoreColors(xnestDisplay, xnestColormap(pCmap), pColors64, nColors);
+ xfree(pColors64);
+ }
+#else
+ XStoreColors(xnestDisplay, xnestColormap(pCmap),
+ (XColor *)pColors, nColors);
+#endif
+}
+
+void
+xnestResolveColor(unsigned short *pRed, unsigned short *pGreen,
+ unsigned short *pBlue, VisualPtr pVisual)
+{
+ int shift;
+ unsigned int lim;
+
+ shift = 16 - pVisual->bitsPerRGBValue;
+ lim = (1 << pVisual->bitsPerRGBValue) - 1;
+
+ if ((pVisual->class == PseudoColor) || (pVisual->class == DirectColor))
+ {
+ /* rescale to rgb bits */
+ *pRed = ((*pRed >> shift) * 65535) / lim;
+ *pGreen = ((*pGreen >> shift) * 65535) / lim;
+ *pBlue = ((*pBlue >> shift) * 65535) / lim;
+ }
+ else if (pVisual->class == GrayScale)
+ {
+ /* rescale to gray then rgb bits */
+ *pRed = (30L * *pRed + 59L * *pGreen + 11L * *pBlue) / 100;
+ *pBlue = *pGreen = *pRed = ((*pRed >> shift) * 65535) / lim;
+ }
+ else if (pVisual->class == StaticGray)
+ {
+ unsigned int limg;
+
+ limg = pVisual->ColormapEntries - 1;
+ /* rescale to gray then [0..limg] then [0..65535] then rgb bits */
+ *pRed = (30L * *pRed + 59L * *pGreen + 11L * *pBlue) / 100;
+ *pRed = ((((*pRed * (limg + 1))) >> 16) * 65535) / limg;
+ *pBlue = *pGreen = *pRed = ((*pRed >> shift) * 65535) / lim;
+ }
+ else
+ {
+ unsigned limr, limg, limb;
+
+ limr = pVisual->redMask >> pVisual->offsetRed;
+ limg = pVisual->greenMask >> pVisual->offsetGreen;
+ limb = pVisual->blueMask >> pVisual->offsetBlue;
+ /* rescale to [0..limN] then [0..65535] then rgb bits */
+ *pRed = ((((((*pRed * (limr + 1)) >> 16) *
+ 65535) / limr) >> shift) * 65535) / lim;
+ *pGreen = ((((((*pGreen * (limg + 1)) >> 16) *
+ 65535) / limg) >> shift) * 65535) / lim;
+ *pBlue = ((((((*pBlue * (limb + 1)) >> 16) *
+ 65535) / limb) >> shift) * 65535) / lim;
+ }
+}
+
+Bool
+xnestCreateDefaultColormap(ScreenPtr pScreen)
+{
+ VisualPtr pVisual;
+ ColormapPtr pCmap;
+ unsigned short zero = 0, ones = 0xFFFF;
+ Pixel wp, bp;
+
+ for (pVisual = pScreen->visuals;
+ pVisual->vid != pScreen->rootVisual;
+ pVisual++);
+
+ if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &pCmap,
+ (pVisual->class & DynamicClass) ? AllocNone : AllocAll, 0)
+ != Success)
+ return False;
+
+ wp = pScreen->whitePixel;
+ bp = pScreen->blackPixel;
+ if ((AllocColor(pCmap, &ones, &ones, &ones, &wp, 0) !=
+ Success) ||
+ (AllocColor(pCmap, &zero, &zero, &zero, &bp, 0) !=
+ Success))
+ return FALSE;
+ pScreen->whitePixel = wp;
+ pScreen->blackPixel = bp;
+ (*pScreen->InstallColormap)(pCmap);
+
+ xnestInstalledDefaultColormap = True;
+
+ return True;
+}
diff --git a/nx-X11/programs/Xserver/hw/xnest/Color.h b/nx-X11/programs/Xserver/hw/xnest/Color.h
new file mode 100644
index 000000000..9ce72a946
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Color.h
@@ -0,0 +1,58 @@
+/* $Xorg: Color.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+#ifndef XNESTCOLOR_H
+#define XNESTCOLOR_H
+
+#define DUMB_WINDOW_MANAGERS
+
+#define MAXCMAPS 1
+#define MINCMAPS 1
+
+typedef struct {
+ Colormap colormap;
+} xnestPrivColormap;
+
+typedef struct {
+ int numCmapIDs;
+ Colormap *cmapIDs;
+ int numWindows;
+ Window *windows;
+ int index;
+} xnestInstalledColormapWindows;
+
+#define xnestColormapPriv(pCmap) \
+ ((xnestPrivColormap *)((pCmap)->devPriv))
+
+#define xnestColormap(pCmap) (xnestColormapPriv(pCmap)->colormap)
+
+#define xnestPixel(pixel) (pixel)
+
+Bool xnestCreateColormap(ColormapPtr pCmap);
+void xnestDestroyColormap(ColormapPtr pCmap);
+void xnestSetInstalledColormapWindows(ScreenPtr pScreen);
+void xnestSetScreenSaverColormapWindow(ScreenPtr pScreen);
+void xnestDirectInstallColormaps(ScreenPtr pScreen);
+void xnestDirectUninstallColormaps(ScreenPtr pScreen);
+void xnestInstallColormap(ColormapPtr pCmap);
+void xnestUninstallColormap(ColormapPtr pCmap);
+int xnestListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapIDs);
+void xnestStoreColors(ColormapPtr pCmap, int nColors, xColorItem *pColors);
+void xnestResolveColor(unsigned short *pRed, unsigned short *pGreen,
+ unsigned short *pBlue, VisualPtr pVisual);
+Bool xnestCreateDefaultColormap(ScreenPtr pScreen);
+
+#endif /* XNESTCOLOR_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/Cursor.c b/nx-X11/programs/Xserver/hw/xnest/Cursor.c
new file mode 100644
index 000000000..f95860022
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Cursor.c
@@ -0,0 +1,159 @@
+/* $Xorg: Cursor.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Cursor.c,v 1.3 2002/11/23 19:27:50 tsi Exp $ */
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "screenint.h"
+#include "input.h"
+#include "misc.h"
+#include "cursor.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Screen.h"
+#include "XNCursor.h"
+#include "Visual.h"
+#include "Keyboard.h"
+#include "Args.h"
+
+Bool
+xnestRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+ XImage *ximage;
+ Pixmap source, mask;
+ XColor fg_color, bg_color;
+ unsigned long valuemask;
+ XGCValues values;
+
+ valuemask = GCFunction |
+ GCPlaneMask |
+ GCForeground |
+ GCBackground |
+ GCClipMask;
+
+ values.function = GXcopy;
+ values.plane_mask = AllPlanes;
+ values.foreground = 1L;
+ values.background = 0L;
+ values.clip_mask = None;
+
+ XChangeGC(xnestDisplay, xnestBitmapGC, valuemask, &values);
+
+ source = XCreatePixmap(xnestDisplay,
+ xnestDefaultWindows[pScreen->myNum],
+ pCursor->bits->width,
+ pCursor->bits->height,
+ 1);
+
+ mask = XCreatePixmap(xnestDisplay,
+ xnestDefaultWindows[pScreen->myNum],
+ pCursor->bits->width,
+ pCursor->bits->height,
+ 1);
+
+ ximage = XCreateImage(xnestDisplay,
+ xnestDefaultVisual(pScreen),
+ 1, XYBitmap, 0,
+ (char *)pCursor->bits->source,
+ pCursor->bits->width,
+ pCursor->bits->height,
+ BitmapPad(xnestDisplay), 0);
+
+ XPutImage(xnestDisplay, source, xnestBitmapGC, ximage,
+ 0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height);
+
+ XFree(ximage);
+
+ ximage = XCreateImage(xnestDisplay,
+ xnestDefaultVisual(pScreen),
+ 1, XYBitmap, 0,
+ (char *)pCursor->bits->mask,
+ pCursor->bits->width,
+ pCursor->bits->height,
+ BitmapPad(xnestDisplay), 0);
+
+ XPutImage(xnestDisplay, mask, xnestBitmapGC, ximage,
+ 0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height);
+
+ XFree(ximage);
+
+ fg_color.red = pCursor->foreRed;
+ fg_color.green = pCursor->foreGreen;
+ fg_color.blue = pCursor->foreBlue;
+
+ bg_color.red = pCursor->backRed;
+ bg_color.green = pCursor->backGreen;
+ bg_color.blue = pCursor->backBlue;
+
+ pCursor->devPriv[pScreen->myNum] = (pointer)xalloc(sizeof(xnestPrivCursor));
+ xnestCursorPriv(pCursor, pScreen)->cursor =
+ XCreatePixmapCursor(xnestDisplay, source, mask, &fg_color, &bg_color,
+ pCursor->bits->xhot, pCursor->bits->yhot);
+
+ XFreePixmap(xnestDisplay, source);
+ XFreePixmap(xnestDisplay, mask);
+
+ return True;
+}
+
+Bool
+xnestUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+ XFreeCursor(xnestDisplay, xnestCursor(pCursor, pScreen));
+ xfree(xnestCursorPriv(pCursor, pScreen));
+ return True;
+}
+
+void
+xnestRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor, Bool displayed)
+{
+ XColor fg_color, bg_color;
+
+ fg_color.red = pCursor->foreRed;
+ fg_color.green = pCursor->foreGreen;
+ fg_color.blue = pCursor->foreBlue;
+
+ bg_color.red = pCursor->backRed;
+ bg_color.green = pCursor->backGreen;
+ bg_color.blue = pCursor->backBlue;
+
+ XRecolorCursor(xnestDisplay,
+ xnestCursor(pCursor, pScreen),
+ &fg_color, &bg_color);
+}
+
+void xnestSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
+{
+ if (pCursor)
+ {
+ XDefineCursor(xnestDisplay,
+ xnestDefaultWindows[pScreen->myNum],
+ xnestCursor(pCursor, pScreen));
+ }
+}
+
+void
+xnestMoveCursor (ScreenPtr pScreen, int x, int y)
+{
+}
diff --git a/nx-X11/programs/Xserver/hw/xnest/Display.c b/nx-X11/programs/Xserver/hw/xnest/Display.c
new file mode 100644
index 000000000..fa8457651
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Display.c
@@ -0,0 +1,195 @@
+/* $Xorg: Display.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Display.c,v 3.4 2001/10/28 03:34:10 tsi Exp $ */
+
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "screenint.h"
+#include "input.h"
+#include "misc.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Init.h"
+#include "Args.h"
+
+#include "icon"
+#include "screensaver"
+
+Display *xnestDisplay = NULL;
+XVisualInfo *xnestVisuals;
+int xnestNumVisuals;
+int xnestDefaultVisualIndex;
+Colormap *xnestDefaultColormaps;
+int xnestNumDefaultColormaps;
+int *xnestDepths;
+int xnestNumDepths;
+XPixmapFormatValues *xnestPixmapFormats;
+int xnestNumPixmapFormats;
+Pixel xnestBlackPixel;
+Pixel xnestWhitePixel;
+Drawable xnestDefaultDrawables[MAXDEPTH + 1];
+Pixmap xnestIconBitmap;
+Pixmap xnestScreenSaverPixmap;
+XlibGC xnestBitmapGC;
+unsigned long xnestEventMask;
+
+void
+xnestOpenDisplay(int argc, char *argv[])
+{
+ XVisualInfo vi;
+ long mask;
+ int i, j;
+
+ if (!xnestDoFullGeneration) return;
+
+ xnestCloseDisplay();
+
+ xnestDisplay = XOpenDisplay(xnestDisplayName);
+ if (xnestDisplay == NULL)
+ FatalError("Unable to open display \"%s\".\n",
+ XDisplayName(xnestDisplayName));
+
+ if (xnestSynchronize)
+ XSynchronize(xnestDisplay, True);
+
+ mask = VisualScreenMask;
+ vi.screen = DefaultScreen(xnestDisplay);
+ xnestVisuals = XGetVisualInfo(xnestDisplay, mask, &vi, &xnestNumVisuals);
+ if (xnestNumVisuals == 0 || xnestVisuals == NULL)
+ FatalError("Unable to find any visuals.\n");
+
+ if (xnestUserDefaultClass || xnestUserDefaultDepth) {
+ xnestDefaultVisualIndex = UNDEFINED;
+ for (i = 0; i < xnestNumVisuals; i++)
+ if ((!xnestUserDefaultClass ||
+ xnestVisuals[i].class == xnestDefaultClass)
+ &&
+ (!xnestUserDefaultDepth ||
+ xnestVisuals[i].depth == xnestDefaultDepth)) {
+ xnestDefaultVisualIndex = i;
+ break;
+ }
+ if (xnestDefaultVisualIndex == UNDEFINED)
+ FatalError("Unable to find desired default visual.\n");
+ }
+ else {
+ vi.visualid = XVisualIDFromVisual(DefaultVisual(xnestDisplay,
+ DefaultScreen(xnestDisplay)));
+ xnestDefaultVisualIndex = 0;
+ for (i = 0; i < xnestNumVisuals; i++)
+ if (vi.visualid == xnestVisuals[i].visualid)
+ xnestDefaultVisualIndex = i;
+ }
+
+ xnestNumDefaultColormaps = xnestNumVisuals;
+ xnestDefaultColormaps = (Colormap *)xalloc(xnestNumDefaultColormaps *
+ sizeof(Colormap));
+ for (i = 0; i < xnestNumDefaultColormaps; i++)
+ xnestDefaultColormaps[i] = XCreateColormap(xnestDisplay,
+ DefaultRootWindow(xnestDisplay),
+ xnestVisuals[i].visual,
+ AllocNone);
+
+ xnestDepths = XListDepths(xnestDisplay, DefaultScreen(xnestDisplay),
+ &xnestNumDepths);
+
+ xnestPixmapFormats = XListPixmapFormats(xnestDisplay,
+ &xnestNumPixmapFormats);
+
+ xnestBlackPixel = BlackPixel(xnestDisplay, DefaultScreen(xnestDisplay));
+ xnestWhitePixel = WhitePixel(xnestDisplay, DefaultScreen(xnestDisplay));
+
+ if (xnestParentWindow != (Window) 0)
+ xnestEventMask = StructureNotifyMask;
+ else
+ xnestEventMask = 0L;
+
+ for (i = 0; i <= MAXDEPTH; i++)
+ xnestDefaultDrawables[i] = None;
+
+ for (i = 0; i < xnestNumPixmapFormats; i++)
+ for (j = 0; j < xnestNumDepths; j++)
+ if (xnestPixmapFormats[i].depth == 1 ||
+ xnestPixmapFormats[i].depth == xnestDepths[j]) {
+ xnestDefaultDrawables[xnestPixmapFormats[i].depth] =
+ XCreatePixmap(xnestDisplay, DefaultRootWindow(xnestDisplay),
+ 1, 1, xnestPixmapFormats[i].depth);
+ }
+
+ xnestBitmapGC = XCreateGC(xnestDisplay, xnestDefaultDrawables[1], 0L, NULL);
+
+ if (!(xnestUserGeometry & XValue))
+ xnestX = 0;
+
+ if (!(xnestUserGeometry & YValue))
+ xnestY = 0;
+
+ if (xnestParentWindow == 0) {
+ if (!(xnestUserGeometry & WidthValue))
+ xnestWidth = 3 * DisplayWidth(xnestDisplay,
+ DefaultScreen(xnestDisplay)) / 4;
+
+ if (!(xnestUserGeometry & HeightValue))
+ xnestHeight = 3 * DisplayHeight(xnestDisplay,
+ DefaultScreen(xnestDisplay)) / 4;
+ }
+
+ if (!xnestUserBorderWidth)
+ xnestBorderWidth = 1;
+
+ xnestIconBitmap =
+ XCreateBitmapFromData(xnestDisplay,
+ DefaultRootWindow(xnestDisplay),
+ (char *)icon_bits,
+ icon_width,
+ icon_height);
+
+ xnestScreenSaverPixmap =
+ XCreatePixmapFromBitmapData(xnestDisplay,
+ DefaultRootWindow(xnestDisplay),
+ (char *)screensaver_bits,
+ screensaver_width,
+ screensaver_height,
+ xnestWhitePixel,
+ xnestBlackPixel,
+ DefaultDepth(xnestDisplay,
+ DefaultScreen(xnestDisplay)));
+}
+
+void
+xnestCloseDisplay()
+{
+ if (!xnestDoFullGeneration || !xnestDisplay) return;
+
+ /*
+ If xnestDoFullGeneration all x resources will be destroyed upon closing
+ the display connection. There is no need to generate extra protocol.
+ */
+
+ xfree(xnestDefaultColormaps);
+ XFree(xnestVisuals);
+ XFree(xnestDepths);
+ XFree(xnestPixmapFormats);
+ XCloseDisplay(xnestDisplay);
+}
diff --git a/nx-X11/programs/Xserver/hw/xnest/Display.h b/nx-X11/programs/Xserver/hw/xnest/Display.h
new file mode 100644
index 000000000..85aedc583
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Display.h
@@ -0,0 +1,46 @@
+/* $Xorg: Display.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Display.h,v 1.6 2001/01/17 22:36:55 dawes Exp $ */
+
+#ifndef XNESTCOMMON_H
+#define XNESTCOMMON_H
+
+#define UNDEFINED -1
+
+#define MAXDEPTH 32
+#define MAXVISUALSPERDEPTH 256
+
+extern Display *xnestDisplay;
+extern XVisualInfo *xnestVisuals;
+extern int xnestNumVisuals;
+extern int xnestDefaultVisualIndex;
+extern Colormap *xnestDefaultColormaps;
+extern int xnestNumDefaultClormaps;
+extern int *xnestDepths;
+extern int xnestNumDepths;
+extern XPixmapFormatValues *xnestPixmapFormats;
+extern int xnestNumPixmapFormats;
+extern Pixel xnestBlackPixel;
+extern Pixel xnestWhitePixel;
+extern Drawable xnestDefaultDrawables[MAXDEPTH + 1];
+extern Pixmap xnestIconBitmap;
+extern Pixmap xnestScreenSaverPixmap;
+extern XlibGC xnestBitmapGC;
+extern unsigned long xnestEventMask;
+
+void xnestOpenDisplay(int argc, char *argv[]);
+void xnestCloseDisplay(void);
+
+#endif /* XNESTCOMMON_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/Drawable.h b/nx-X11/programs/Xserver/hw/xnest/Drawable.h
new file mode 100644
index 000000000..7b96bdfee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Drawable.h
@@ -0,0 +1,28 @@
+/* $Xorg: Drawable.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+#ifndef XNESTDRAWABLE_H
+#define XNESTDRAWABLE_H
+
+#include "XNWindow.h"
+#include "XNPixmap.h"
+
+#define xnestDrawable(pDrawable) \
+ ((pDrawable)->type == DRAWABLE_WINDOW ? \
+ xnestWindow((WindowPtr)pDrawable) : \
+ xnestPixmap((PixmapPtr)pDrawable))
+
+#endif /* XNESTDRAWABLE_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/Events.c b/nx-X11/programs/Xserver/hw/xnest/Events.c
new file mode 100644
index 000000000..3d520279c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Events.c
@@ -0,0 +1,226 @@
+/* $Xorg: Events.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Events.c,v 1.2 2001/08/01 00:44:57 tsi Exp $ */
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include "screenint.h"
+#include "input.h"
+#include "misc.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+
+#include "mi.h"
+
+#include "Xnest.h"
+
+#include "Args.h"
+#include "Color.h"
+#include "Display.h"
+#include "Screen.h"
+#include "XNWindow.h"
+#include "Events.h"
+#include "Keyboard.h"
+#include "mipointer.h"
+
+CARD32 lastEventTime = 0;
+
+void
+ProcessInputEvents()
+{
+ mieqProcessInputEvents();
+ miPointerUpdate();
+}
+
+int
+TimeSinceLastInputEvent()
+{
+ if (lastEventTime == 0)
+ lastEventTime = GetTimeInMillis();
+ return GetTimeInMillis() - lastEventTime;
+}
+
+void
+SetTimeSinceLastInputEvent()
+{
+ lastEventTime = GetTimeInMillis();
+}
+
+static Bool
+xnestExposurePredicate(Display *display, XEvent *event, char *args)
+{
+ return (event->type == Expose || event->type == ProcessedExpose);
+}
+
+static Bool
+xnestNotExposurePredicate(Display *display, XEvent *event, char *args)
+{
+ return !xnestExposurePredicate(display, event, args);
+}
+
+void
+xnestCollectExposures()
+{
+ XEvent X;
+ WindowPtr pWin;
+ RegionRec Rgn;
+ BoxRec Box;
+
+ while (XCheckIfEvent(xnestDisplay, &X, xnestExposurePredicate, NULL)) {
+ pWin = xnestWindowPtr(X.xexpose.window);
+
+ if (pWin) {
+ Box.x1 = pWin->drawable.x + wBorderWidth(pWin) + X.xexpose.x;
+ Box.y1 = pWin->drawable.y + wBorderWidth(pWin) + X.xexpose.y;
+ Box.x2 = Box.x1 + X.xexpose.width;
+ Box.y2 = Box.y1 + X.xexpose.height;
+
+ REGION_INIT(pWin->drawable.pScreen, &Rgn, &Box, 1);
+
+ miWindowExposures(pWin, &Rgn, NullRegion);
+ }
+ }
+}
+
+void
+xnestQueueKeyEvent(int type, unsigned int keycode)
+{
+ xEvent x;
+ x.u.u.type = type;
+ x.u.u.detail = keycode;
+ x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
+ mieqEnqueue(&x);
+}
+
+void
+xnestCollectEvents()
+{
+ XEvent X;
+ xEvent x;
+ ScreenPtr pScreen;
+
+ while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) {
+ switch (X.type) {
+ case KeyPress:
+ xnestUpdateModifierState(X.xkey.state);
+ xnestQueueKeyEvent(KeyPress, X.xkey.keycode);
+ break;
+
+ case KeyRelease:
+ xnestUpdateModifierState(X.xkey.state);
+ xnestQueueKeyEvent(KeyRelease, X.xkey.keycode);
+ break;
+
+ case ButtonPress:
+ xnestUpdateModifierState(X.xkey.state);
+ x.u.u.type = ButtonPress;
+ x.u.u.detail = X.xbutton.button;
+ x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
+ mieqEnqueue(&x);
+ break;
+
+ case ButtonRelease:
+ xnestUpdateModifierState(X.xkey.state);
+ x.u.u.type = ButtonRelease;
+ x.u.u.detail = X.xbutton.button;
+ x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
+ mieqEnqueue(&x);
+ break;
+
+ case MotionNotify:
+#if 0
+ x.u.u.type = MotionNotify;
+ x.u.keyButtonPointer.rootX = X.xmotion.x;
+ x.u.keyButtonPointer.rootY = X.xmotion.y;
+ x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
+ mieqEnqueue(&x);
+#endif
+ miPointerAbsoluteCursor (X.xmotion.x, X.xmotion.y,
+ lastEventTime = GetTimeInMillis());
+ break;
+
+ case FocusIn:
+ if (X.xfocus.detail != NotifyInferior) {
+ pScreen = xnestScreen(X.xfocus.window);
+ if (pScreen)
+ xnestDirectInstallColormaps(pScreen);
+ }
+ break;
+
+ case FocusOut:
+ if (X.xfocus.detail != NotifyInferior) {
+ pScreen = xnestScreen(X.xfocus.window);
+ if (pScreen)
+ xnestDirectUninstallColormaps(pScreen);
+ }
+ break;
+
+ case KeymapNotify:
+ break;
+
+ case EnterNotify:
+ if (X.xcrossing.detail != NotifyInferior) {
+ pScreen = xnestScreen(X.xcrossing.window);
+ if (pScreen) {
+ NewCurrentScreen(pScreen, X.xcrossing.x, X.xcrossing.y);
+#if 0
+ x.u.u.type = MotionNotify;
+ x.u.keyButtonPointer.rootX = X.xcrossing.x;
+ x.u.keyButtonPointer.rootY = X.xcrossing.y;
+ x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
+ mieqEnqueue(&x);
+#endif
+ miPointerAbsoluteCursor (X.xcrossing.x, X.xcrossing.y,
+ lastEventTime = GetTimeInMillis());
+ xnestDirectInstallColormaps(pScreen);
+ }
+ }
+ break;
+
+ case LeaveNotify:
+ if (X.xcrossing.detail != NotifyInferior) {
+ pScreen = xnestScreen(X.xcrossing.window);
+ if (pScreen) {
+ xnestDirectUninstallColormaps(pScreen);
+ }
+ }
+ break;
+
+ case DestroyNotify:
+ if (xnestParentWindow != (Window) 0 &&
+ X.xdestroywindow.window == xnestParentWindow)
+ exit (0);
+ break;
+
+ case CirculateNotify:
+ case ConfigureNotify:
+ case GravityNotify:
+ case MapNotify:
+ case ReparentNotify:
+ case UnmapNotify:
+ break;
+
+ default:
+ ErrorF("xnest warning: unhandled event\n");
+ break;
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xnest/Events.h b/nx-X11/programs/Xserver/hw/xnest/Events.h
new file mode 100644
index 000000000..c61b26c0d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Events.h
@@ -0,0 +1,31 @@
+/* $Xorg: Events.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+#ifndef XNESTEVENTS_H
+#define XNESTEVENTS_H
+
+#include <X11/Xmd.h>
+
+#define ProcessedExpose (LASTEvent + 1)
+
+extern CARD32 lastEventTime;
+
+void SetTimeSinceLastInputEvent(void);
+void xnestCollectExposures(void);
+void xnestCollectEvents(void);
+void xnestQueueKeyEvent(int type, unsigned int keycode);
+
+#endif /* XNESTEVENTS_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/Font.c b/nx-X11/programs/Xserver/hw/xnest/Font.c
new file mode 100644
index 000000000..d86816e8f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Font.c
@@ -0,0 +1,91 @@
+/* $Xorg: Font.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Font.c,v 3.6 2003/07/16 01:38:51 dawes Exp $ */
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xatom.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "regionstr.h"
+#include <X11/fonts/font.h>
+#include <X11/fonts/fontstruct.h>
+#include "scrnintstr.h"
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "XNFont.h"
+
+int xnestFontPrivateIndex;
+
+Bool
+xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont)
+{
+ pointer priv;
+ Atom name_atom, value_atom;
+ int nprops;
+ FontPropPtr props;
+ int i;
+ char *name;
+
+ FontSetPrivate(pFont, xnestFontPrivateIndex, NULL);
+
+ if (requestingClient && XpClientIsPrintClient(requestingClient, NULL))
+ return True;
+
+ name_atom = MakeAtom("FONT", 4, True);
+ value_atom = 0L;
+
+ nprops = pFont->info.nprops;
+ props = pFont->info.props;
+
+ for (i = 0; i < nprops; i++)
+ if (props[i].name == name_atom) {
+ value_atom = props[i].value;
+ break;
+ }
+
+ if (!value_atom) return False;
+
+ name = (char *)NameForAtom(value_atom);
+
+ if (!name) return False;
+
+ priv = (pointer)xalloc(sizeof(xnestPrivFont));
+ FontSetPrivate(pFont, xnestFontPrivateIndex, priv);
+
+ xnestFontPriv(pFont)->font_struct = XLoadQueryFont(xnestDisplay, name);
+
+ if (!xnestFontStruct(pFont)) return False;
+
+ return True;
+}
+
+
+Bool
+xnestUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
+{
+ if (xnestFontPriv(pFont)) {
+ if (xnestFontStruct(pFont))
+ XFreeFont(xnestDisplay, xnestFontStruct(pFont));
+ xfree(xnestFontPriv(pFont));
+ FontSetPrivate(pFont, xnestFontPrivateIndex, NULL);
+ }
+ return True;
+}
diff --git a/nx-X11/programs/Xserver/hw/xnest/GC.c b/nx-X11/programs/Xserver/hw/xnest/GC.c
new file mode 100644
index 000000000..e46b48f11
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/GC.c
@@ -0,0 +1,340 @@
+/* $Xorg: GC.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/GC.c,v 3.6 2001/10/28 03:34:11 tsi Exp $ */
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mistruct.h"
+#include "region.h"
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "XNGC.h"
+#include "GCOps.h"
+#include "Drawable.h"
+#include "XNFont.h"
+#include "Color.h"
+
+int xnestGCPrivateIndex;
+
+static GCFuncs xnestFuncs = {
+ xnestValidateGC,
+ xnestChangeGC,
+ xnestCopyGC,
+ xnestDestroyGC,
+ xnestChangeClip,
+ xnestDestroyClip,
+ xnestCopyClip,
+};
+
+static GCOps xnestOps = {
+ xnestFillSpans,
+ xnestSetSpans,
+ xnestPutImage,
+ xnestCopyArea,
+ xnestCopyPlane,
+ xnestPolyPoint,
+ xnestPolylines,
+ xnestPolySegment,
+ xnestPolyRectangle,
+ xnestPolyArc,
+ xnestFillPolygon,
+ xnestPolyFillRect,
+ xnestPolyFillArc,
+ xnestPolyText8,
+ xnestPolyText16,
+ xnestImageText8,
+ xnestImageText16,
+ xnestImageGlyphBlt,
+ xnestPolyGlyphBlt,
+ xnestPushPixels
+};
+
+Bool
+xnestCreateGC(GCPtr pGC)
+{
+ pGC->clientClipType = CT_NONE;
+ pGC->clientClip = NULL;
+
+ pGC->funcs = &xnestFuncs;
+ pGC->ops = &xnestOps;
+
+ pGC->miTranslate = 1;
+
+ xnestGCPriv(pGC)->gc = XCreateGC(xnestDisplay,
+ xnestDefaultDrawables[pGC->depth],
+ 0L, NULL);
+ xnestGCPriv(pGC)->nClipRects = 0;
+
+ return True;
+}
+
+void
+xnestValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
+{
+ pGC->lastWinOrg.x = pDrawable->x;
+ pGC->lastWinOrg.y = pDrawable->y;
+}
+
+void
+xnestChangeGC(GCPtr pGC, unsigned long mask)
+{
+ XGCValues values;
+
+ if (mask & GCFunction)
+ values.function = pGC->alu;
+
+ if (mask & GCPlaneMask)
+ values.plane_mask = pGC->planemask;
+
+ if (mask & GCForeground)
+ values.foreground = xnestPixel(pGC->fgPixel);
+
+ if (mask & GCBackground)
+ values.background = xnestPixel(pGC->bgPixel);
+
+ if (mask & GCLineWidth)
+ values.line_width = pGC->lineWidth;
+
+ if (mask & GCLineStyle)
+ values.line_style = pGC->lineStyle;
+
+ if (mask & GCCapStyle)
+ values.cap_style = pGC->capStyle;
+
+ if (mask & GCJoinStyle)
+ values.join_style = pGC->joinStyle;
+
+ if (mask & GCFillStyle)
+ values.fill_style = pGC->fillStyle;
+
+ if (mask & GCFillRule)
+ values.fill_rule = pGC->fillRule;
+
+ if (mask & GCTile) {
+ if (pGC->tileIsPixel)
+ mask &= ~GCTile;
+ else
+ values.tile = xnestPixmap(pGC->tile.pixmap);
+ }
+
+ if (mask & GCStipple)
+ values.stipple = xnestPixmap(pGC->stipple);
+
+ if (mask & GCTileStipXOrigin)
+ values.ts_x_origin = pGC->patOrg.x;
+
+ if (mask & GCTileStipYOrigin)
+ values.ts_y_origin = pGC->patOrg.y;
+
+ if (mask & GCFont)
+ values.font = xnestFont(pGC->font);
+
+ if (mask & GCSubwindowMode)
+ values.subwindow_mode = pGC->subWindowMode;
+
+ if (mask & GCGraphicsExposures)
+ values.graphics_exposures = pGC->graphicsExposures;
+
+ if (mask & GCClipXOrigin)
+ values.clip_x_origin = pGC->clipOrg.x;
+
+ if (mask & GCClipYOrigin)
+ values.clip_y_origin = pGC->clipOrg.y;
+
+ if (mask & GCClipMask) /* this is handled in change clip */
+ mask &= ~GCClipMask;
+
+ if (mask & GCDashOffset)
+ values.dash_offset = pGC->dashOffset;
+
+ if (mask & GCDashList) {
+ mask &= ~GCDashList;
+ XSetDashes(xnestDisplay, xnestGC(pGC),
+ pGC->dashOffset, (char *)pGC->dash, pGC->numInDashList);
+ }
+
+ if (mask & GCArcMode)
+ values.arc_mode = pGC->arcMode;
+
+ if (mask)
+ XChangeGC(xnestDisplay, xnestGC(pGC), mask, &values);
+}
+
+void
+xnestCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
+{
+ XCopyGC(xnestDisplay, xnestGC(pGCSrc), mask, xnestGC(pGCDst));
+}
+
+void
+xnestDestroyGC(GCPtr pGC)
+{
+ XFreeGC(xnestDisplay, xnestGC(pGC));
+}
+
+void
+xnestChangeClip(GCPtr pGC, int type, pointer pValue, int nRects)
+{
+ int i, size;
+ BoxPtr pBox;
+ XRectangle *pRects;
+
+ xnestDestroyClipHelper(pGC);
+
+ switch(type)
+ {
+ case CT_NONE:
+ XSetClipMask(xnestDisplay, xnestGC(pGC), None);
+ break;
+
+ case CT_REGION:
+ nRects = REGION_NUM_RECTS((RegionPtr)pValue);
+ size = nRects * sizeof(*pRects);
+ pRects = (XRectangle *) xalloc(size);
+ pBox = REGION_RECTS((RegionPtr)pValue);
+ for (i = nRects; i-- > 0; ) {
+ pRects[i].x = pBox[i].x1;
+ pRects[i].y = pBox[i].y1;
+ pRects[i].width = pBox[i].x2 - pBox[i].x1;
+ pRects[i].height = pBox[i].y2 - pBox[i].y1;
+ }
+ XSetClipRectangles(xnestDisplay, xnestGC(pGC), 0, 0,
+ pRects, nRects, Unsorted);
+ xfree((char *) pRects);
+ break;
+
+ case CT_PIXMAP:
+ XSetClipMask(xnestDisplay, xnestGC(pGC),
+ xnestPixmap((PixmapPtr)pValue));
+ /*
+ * Need to change into region, so subsequent uses are with
+ * current pixmap contents.
+ */
+ pGC->clientClip = (pointer) (*pGC->pScreen->BitmapToRegion)((PixmapPtr)pValue);
+ (*pGC->pScreen->DestroyPixmap)((PixmapPtr)pValue);
+ pValue = pGC->clientClip;
+ type = CT_REGION;
+ break;
+
+ case CT_UNSORTED:
+ XSetClipRectangles(xnestDisplay, xnestGC(pGC),
+ pGC->clipOrg.x, pGC->clipOrg.y,
+ (XRectangle *)pValue, nRects, Unsorted);
+ break;
+
+ case CT_YSORTED:
+ XSetClipRectangles(xnestDisplay, xnestGC(pGC),
+ pGC->clipOrg.x, pGC->clipOrg.y,
+ (XRectangle *)pValue, nRects, YSorted);
+ break;
+
+ case CT_YXSORTED:
+ XSetClipRectangles(xnestDisplay, xnestGC(pGC),
+ pGC->clipOrg.x, pGC->clipOrg.y,
+ (XRectangle *)pValue, nRects, YXSorted);
+ break;
+
+ case CT_YXBANDED:
+ XSetClipRectangles(xnestDisplay, xnestGC(pGC),
+ pGC->clipOrg.x, pGC->clipOrg.y,
+ (XRectangle *)pValue, nRects, YXBanded);
+ break;
+ }
+
+ switch(type)
+ {
+ default:
+ break;
+
+ case CT_UNSORTED:
+ case CT_YSORTED:
+ case CT_YXSORTED:
+ case CT_YXBANDED:
+
+ /*
+ * other parts of server can only deal with CT_NONE,
+ * CT_PIXMAP and CT_REGION client clips.
+ */
+ pGC->clientClip = (pointer) RECTS_TO_REGION(pGC->pScreen, nRects,
+ (xRectangle *)pValue, type);
+ xfree(pValue);
+ pValue = pGC->clientClip;
+ type = CT_REGION;
+
+ break;
+ }
+
+ pGC->clientClipType = type;
+ pGC->clientClip = pValue;
+ xnestGCPriv(pGC)->nClipRects = nRects;
+}
+
+void
+xnestDestroyClip(GCPtr pGC)
+{
+ xnestDestroyClipHelper(pGC);
+
+ XSetClipMask(xnestDisplay, xnestGC(pGC), None);
+
+ pGC->clientClipType = CT_NONE;
+ pGC->clientClip = NULL;
+ xnestGCPriv(pGC)->nClipRects = 0;
+}
+
+void
+xnestDestroyClipHelper(GCPtr pGC)
+{
+ switch (pGC->clientClipType)
+ {
+ default:
+ case CT_NONE:
+ break;
+
+ case CT_REGION:
+ REGION_DESTROY(pGC->pScreen, pGC->clientClip);
+ break;
+ }
+}
+
+void
+xnestCopyClip(GCPtr pGCDst, GCPtr pGCSrc)
+{
+ RegionPtr pRgn;
+
+ switch (pGCSrc->clientClipType)
+ {
+ default:
+ case CT_NONE:
+ xnestDestroyClip(pGCDst);
+ break;
+
+ case CT_REGION:
+ pRgn = REGION_CREATE(pGCDst->pScreen, NULL, 1);
+ REGION_COPY(pGCDst->pScreen, pRgn, pGCSrc->clientClip);
+ xnestChangeClip(pGCDst, CT_REGION, pRgn, 0);
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xnest/GCOps.c b/nx-X11/programs/Xserver/hw/xnest/GCOps.c
new file mode 100644
index 000000000..233424823
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/GCOps.c
@@ -0,0 +1,329 @@
+/* $Xorg: GCOps.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/GCOps.c,v 3.5 2003/07/16 01:38:51 dawes Exp $ */
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "regionstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "region.h"
+#include "servermd.h"
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Screen.h"
+#include "XNGC.h"
+#include "XNFont.h"
+#include "GCOps.h"
+#include "Drawable.h"
+#include "Visual.h"
+
+void
+xnestFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans, xPoint *pPoints,
+ int *pWidths, int fSorted)
+{
+ ErrorF("xnest warning: function xnestFillSpans not implemented\n");
+}
+
+void
+xnestSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *pSrc,
+ xPoint *pPoints, int *pWidths, int nSpans, int fSorted)
+{
+ ErrorF("xnest warning: function xnestSetSpans not implemented\n");
+}
+
+void
+xnestGetSpans(DrawablePtr pDrawable, int maxWidth, DDXPointPtr pPoints,
+ int *pWidths, int nSpans, char *pBuffer)
+{
+ ErrorF("xnest warning: function xnestGetSpans not implemented\n");
+}
+
+void
+xnestQueryBestSize(int class, unsigned short *pWidth, unsigned short *pHeight,
+ ScreenPtr pScreen)
+{
+ unsigned int width, height;
+
+ width = *pWidth;
+ height = *pHeight;
+
+ XQueryBestSize(xnestDisplay, class,
+ xnestDefaultWindows[pScreen->myNum],
+ width, height, &width, &height);
+
+ *pWidth = width;
+ *pHeight = height;
+}
+
+void
+xnestPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
+ int w, int h, int leftPad, int format, char *pImage)
+{
+ XImage *ximage;
+
+ ximage = XCreateImage(xnestDisplay, xnestDefaultVisual(pDrawable->pScreen),
+ depth, format, leftPad, (char *)pImage,
+ w, h, BitmapPad(xnestDisplay),
+ (format == ZPixmap) ?
+ PixmapBytePad(w, depth) : BitmapBytePad(w+leftPad));
+
+ if (ximage) {
+ XPutImage(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ ximage, 0, 0, x, y, w, h);
+ XFree(ximage);
+ }
+}
+
+void
+xnestGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
+ unsigned int format, unsigned long planeMask,
+ char *pImage)
+{
+ XImage *ximage;
+ int length;
+
+ ximage = XGetImage(xnestDisplay, xnestDrawable(pDrawable),
+ x, y, w, h, planeMask, format);
+
+ if (ximage) {
+ length = ximage->bytes_per_line * ximage->height;
+
+ memmove(pImage, ximage->data, length);
+
+ XDestroyImage(ximage);
+ }
+}
+
+static Bool
+xnestBitBlitPredicate(Display *display, XEvent *event, char *args)
+{
+ return (event->type == GraphicsExpose || event->type == NoExpose);
+}
+
+static RegionPtr
+xnestBitBlitHelper(GCPtr pGC)
+{
+ if (!pGC->graphicsExposures)
+ return NullRegion;
+ else {
+ XEvent event;
+ RegionPtr pReg, pTmpReg;
+ BoxRec Box;
+ Bool pending, overlap;
+
+ pReg = REGION_CREATE(pGC->pScreen, NULL, 1);
+ pTmpReg = REGION_CREATE(pGC->pScreen, NULL, 1);
+ if(!pReg || !pTmpReg) return NullRegion;
+
+ pending = True;
+ while (pending) {
+ XIfEvent(xnestDisplay, &event, xnestBitBlitPredicate, NULL);
+
+ switch (event.type) {
+ case NoExpose:
+ pending = False;
+ break;
+
+ case GraphicsExpose:
+ Box.x1 = event.xgraphicsexpose.x;
+ Box.y1 = event.xgraphicsexpose.y;
+ Box.x2 = event.xgraphicsexpose.x + event.xgraphicsexpose.width;
+ Box.y2 = event.xgraphicsexpose.y + event.xgraphicsexpose.height;
+ REGION_RESET(pGC->pScreen, pTmpReg, &Box);
+ REGION_APPEND(pGC->pScreen, pReg, pTmpReg);
+ pending = event.xgraphicsexpose.count;
+ break;
+ }
+ }
+
+ REGION_DESTROY(pGC->pScreen, pTmpReg);
+ REGION_VALIDATE(pGC->pScreen, pReg, &overlap);
+ return(pReg);
+ }
+}
+
+RegionPtr
+xnestCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
+ GCPtr pGC, int srcx, int srcy, int width, int height,
+ int dstx, int dsty)
+{
+ XCopyArea(xnestDisplay,
+ xnestDrawable(pSrcDrawable), xnestDrawable(pDstDrawable),
+ xnestGC(pGC), srcx, srcy, width, height, dstx, dsty);
+
+ return xnestBitBlitHelper(pGC);
+}
+
+RegionPtr
+xnestCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
+ GCPtr pGC, int srcx, int srcy, int width, int height,
+ int dstx, int dsty, unsigned long plane)
+{
+ XCopyPlane(xnestDisplay,
+ xnestDrawable(pSrcDrawable), xnestDrawable(pDstDrawable),
+ xnestGC(pGC), srcx, srcy, width, height, dstx, dsty, plane);
+
+ return xnestBitBlitHelper(pGC);
+}
+
+void
+xnestPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints,
+ DDXPointPtr pPoints)
+{
+ XDrawPoints(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ (XPoint *)pPoints, nPoints, mode);
+}
+
+void
+xnestPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints,
+ DDXPointPtr pPoints)
+{
+ XDrawLines(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ (XPoint *)pPoints, nPoints, mode);
+}
+
+void
+xnestPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nSegments,
+ xSegment *pSegments)
+{
+ XDrawSegments(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ (XSegment *)pSegments, nSegments);
+}
+
+void
+xnestPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nRectangles,
+ xRectangle *pRectangles)
+{
+ XDrawRectangles(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ (XRectangle *)pRectangles, nRectangles);
+}
+
+void
+xnestPolyArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs)
+{
+ XDrawArcs(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ (XArc *)pArcs, nArcs);
+}
+
+void
+xnestFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, int mode,
+ int nPoints, DDXPointPtr pPoints)
+{
+ XFillPolygon(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ (XPoint *)pPoints, nPoints, shape, mode);
+}
+
+void
+xnestPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nRectangles,
+ xRectangle *pRectangles)
+{
+ XFillRectangles(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ (XRectangle *)pRectangles, nRectangles);
+}
+
+void
+xnestPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs)
+{
+ XFillArcs(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ (XArc *)pArcs, nArcs);
+}
+
+int
+xnestPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
+ char *string)
+{
+ int width;
+
+ XDrawString(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ x, y, string, count);
+
+ width = XTextWidth(xnestFontStruct(pGC->font), string, count);
+
+ return width + x;
+}
+
+int
+xnestPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
+ unsigned short *string)
+{
+ int width;
+
+ XDrawString16(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ x, y, (XChar2b *)string, count);
+
+ width = XTextWidth16(xnestFontStruct(pGC->font), (XChar2b *)string, count);
+
+ return width + x;
+}
+
+void
+xnestImageText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
+ char *string)
+{
+ XDrawImageString(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ x, y, string, count);
+}
+
+void
+xnestImageText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
+ unsigned short *string)
+{
+ XDrawImageString16(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
+ x, y, (XChar2b *)string, count);
+}
+
+void
+xnestImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nGlyphs, CharInfoPtr *pCharInfo,
+ pointer pGlyphBase)
+{
+ ErrorF("xnest warning: function xnestImageGlyphBlt not implemented\n");
+}
+
+void
+xnestPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nGlyphs, CharInfoPtr *pCharInfo,
+ pointer pGlyphBase)
+{
+ ErrorF("xnest warning: function xnestPolyGlyphBlt not implemented\n");
+}
+
+void
+xnestPushPixels(GCPtr pGC, PixmapPtr pBitmap, DrawablePtr pDst,
+ int width, int height, int x, int y)
+{
+ /* only works for solid bitmaps */
+ if (pGC->fillStyle == FillSolid)
+ {
+ XSetStipple (xnestDisplay, xnestGC(pGC), xnestPixmap(pBitmap));
+ XSetTSOrigin (xnestDisplay, xnestGC(pGC), x, y);
+ XSetFillStyle (xnestDisplay, xnestGC(pGC), FillStippled);
+ XFillRectangle (xnestDisplay, xnestDrawable(pDst),
+ xnestGC(pGC), x, y, width, height);
+ XSetFillStyle (xnestDisplay, xnestGC(pGC), FillSolid);
+ }
+ else
+ ErrorF("xnest warning: function xnestPushPixels not implemented\n");
+}
diff --git a/nx-X11/programs/Xserver/hw/xnest/GCOps.h b/nx-X11/programs/Xserver/hw/xnest/GCOps.h
new file mode 100644
index 000000000..ccdc40ebe
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/GCOps.h
@@ -0,0 +1,70 @@
+/* $Xorg: GCOps.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+#ifndef XNESTGCOPS_H
+#define XNESTGCOPS_H
+
+void xnestFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans,
+ xPoint *pPoints, int *pWidths, int fSorted);
+void xnestSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *pSrc,
+ xPoint *pPoints, int *pWidths, int nSpans, int fSorted);
+void xnestGetSpans(DrawablePtr pDrawable, int maxWidth, DDXPointPtr pPoints,
+ int *pWidths, int nSpans, char *pBuffer);
+void xnestQueryBestSize(int class, unsigned short *pWidth,
+ unsigned short *pHeight, ScreenPtr pScreen);
+void xnestPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
+ int w, int h, int leftPad, int format, char *pImage);
+void xnestGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
+ unsigned int format, unsigned long planeMask,
+ char *pImage);
+RegionPtr xnestCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
+ GCPtr pGC, int srcx, int srcy, int width, int height,
+ int dstx, int dsty);
+RegionPtr xnestCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
+ GCPtr pGC, int srcx, int srcy, int width, int height,
+ int dstx, int dsty, unsigned long plane);
+void xnestPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints,
+ DDXPointPtr pPoints);
+void xnestPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints,
+ DDXPointPtr pPoints);
+void xnestPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nSegments,
+ xSegment *pSegments);
+void xnestPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nRectangles,
+ xRectangle *pRectangles);
+void xnestPolyArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs);
+void xnestFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, int mode,
+ int nPoints, DDXPointPtr pPoints);
+void xnestPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nRectangles,
+ xRectangle *pRectangles);
+void xnestPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs);
+int xnestPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
+ char *string);
+int xnestPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
+ unsigned short *string);
+void xnestImageText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
+ char *string);
+void xnestImageText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
+ unsigned short *string);
+void xnestImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nGlyphs, CharInfoPtr *pCharInfo,
+ pointer pGlyphBase);
+void xnestPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nGlyphs, CharInfoPtr *pCharInfo,
+ pointer pGlyphBase);
+void xnestPushPixels(GCPtr pGC, PixmapPtr pBitmap, DrawablePtr pDrawable,
+ int width, int height, int x, int y);
+
+#endif /* XNESTGCOPS_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/GetTime.c b/nx-X11/programs/Xserver/hw/xnest/GetTime.c
new file mode 100644
index 000000000..bdcc6beae
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/GetTime.c
@@ -0,0 +1,51 @@
+/* $Xorg: GetTime.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright (c) 1993 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the X Consortium.
+
+*/
+/* $XFree86$ */
+
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/Xos.h>
+#include "os.h"
+#include <time.h>
+
+#ifdef DDXTIME
+CARD32
+GetTimeInMillis()
+{
+ struct timeval tp;
+
+ X_GETTIMEOFDAY(&tp);
+ return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xnest/Handlers.c b/nx-X11/programs/Xserver/hw/xnest/Handlers.c
new file mode 100644
index 000000000..9915502c4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Handlers.c
@@ -0,0 +1,47 @@
+/* $Xorg: Handlers.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Handlers.c,v 1.2 2001/08/01 00:44:57 tsi Exp $ */
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "screenint.h"
+#include "input.h"
+#include "misc.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Events.h"
+#include "Handlers.h"
+
+void
+xnestBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadMask)
+{
+ xnestCollectExposures();
+ XFlush(xnestDisplay);
+}
+
+void
+xnestWakeupHandler(pointer blockData, int result, pointer pReadMask)
+{
+ xnestCollectEvents();
+}
diff --git a/nx-X11/programs/Xserver/hw/xnest/Handlers.h b/nx-X11/programs/Xserver/hw/xnest/Handlers.h
new file mode 100644
index 000000000..9a1e809cc
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Handlers.h
@@ -0,0 +1,24 @@
+/* $Xorg: Handlers.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+#ifndef XNESTHANDLERS_H
+#define XNESTHANDLERS_H
+
+void xnestBlockHandler(pointer blockData, OSTimePtr pTimeout,
+ pointer pReadMask);
+void xnestWakeupHandler(pointer blockData, int result, pointer pReadMask);
+
+#endif /* XNESTHANDLERS_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/Imakefile b/nx-X11/programs/Xserver/hw/xnest/Imakefile
new file mode 100644
index 000000000..95ebd8d79
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Imakefile
@@ -0,0 +1,90 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:53:28 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/hw/xnest/Imakefile,v 3.28 2003/10/02 13:30:08 eich Exp $
+
+#include <Server.tmpl>
+
+#if BuildDPMS
+DPMSSRC = dpmsstubs.c
+DPMSOBJS = dpmsstubs.o
+#endif
+
+#ifdef OS2Architecture
+SRCS1 = os2Stub.c
+OBJS1 = os2Stub.o
+#endif
+
+SRCS = Args.c \
+ Color.c \
+ Cursor.c \
+ Display.c \
+ Events.c \
+ Font.c \
+ GC.c \
+ GCOps.c \
+ GetTime.c \
+ Handlers.c \
+ Init.c \
+ Keyboard.c \
+ Pixmap.c \
+ Pointer.c \
+ Screen.c \
+ TestExt.c \
+ Visual.c \
+ Window.c \
+ stubs.c \
+ miinitext.c $(SRCS1)
+
+OBJS = Args.o \
+ Color.o \
+ Cursor.o \
+ Display.o \
+ Events.o \
+ Font.o \
+ GC.o \
+ GCOps.o \
+ GetTime.o \
+ Handlers.o \
+ Init.o \
+ Keyboard.o \
+ Pixmap.o \
+ Pointer.o \
+ Screen.o \
+ TestExt.o \
+ Visual.o \
+ Window.o \
+ stubs.o \
+ miinitext.o $(OBJS1)
+
+
+INCLUDES = -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
+ -I../../mi -I../../include -I../../os \
+ -I$(EXTINCSRC) -I$(XINCLUDESRC) -I$(LIBSRC) -I$(SERVERSRC)/Xext
+
+DEFINES = $(OS_DEFINES) $(EXT_DEFINES) -DNO_HW_ONLY_EXTS \
+ -UXFree86LOADER -UMITSHM $(XKBDEFRULESDEFS)
+
+XKB_DEFINES = -DXKB_BASE_DIRECTORY=\"$(LIBDIR)/xkb/\"
+
+all:: $(OBJS) $(DPMSOBJS)
+
+LinkSourceFile(stubs.c,$(SERVERSRC)/Xi)
+SpecialCObjectRule(Init,$(ICONFIGFILES),$(_NOOP_))
+LinkSourceFile(miinitext.c,$(SERVERSRC)/mi)
+SpecialCObjectRule(miinitext,$(ICONFIGFILES),-UDPMSExtension)
+SpecialCObjectRule(Keyboard,$(ICONFIGFILES),$(XKB_DEFINES))
+#if BuildDPMS
+LinkSourceFile(dpmsstubs.c,$(SERVERSRC)/Xext)
+SpecialCObjectRule(dpmsstubs,$(ICONFIGFILES),$(EXT_DEFINES))
+#endif
+
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(xnest,$(OBJS))
+
+InstallManPage(Xnest,$(MANDIR))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/xnest/Init.c b/nx-X11/programs/Xserver/hw/xnest/Init.c
new file mode 100644
index 000000000..f2e7122f3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Init.c
@@ -0,0 +1,164 @@
+/* $Xorg: Init.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Init.c,v 3.24 2003/01/15 02:34:14 torrey Exp $ */
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "screenint.h"
+#include "input.h"
+#include "misc.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#include "mi.h"
+#include <X11/fonts/fontstruct.h>
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Screen.h"
+#include "Pointer.h"
+#include "Keyboard.h"
+#include "Handlers.h"
+#include "Init.h"
+#include "Args.h"
+#include "Drawable.h"
+#include "XNGC.h"
+#include "XNFont.h"
+#ifdef DPMSExtension
+#include "dpmsproc.h"
+#endif
+
+Bool xnestDoFullGeneration = True;
+
+void
+InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
+{
+ int i, j;
+
+ xnestOpenDisplay(argc, argv);
+
+ screenInfo->imageByteOrder = ImageByteOrder(xnestDisplay);
+ screenInfo->bitmapScanlineUnit = BitmapUnit(xnestDisplay);
+ screenInfo->bitmapScanlinePad = BitmapPad(xnestDisplay);
+ screenInfo->bitmapBitOrder = BitmapBitOrder(xnestDisplay);
+
+ screenInfo->numPixmapFormats = 0;
+ for (i = 0; i < xnestNumPixmapFormats; i++)
+ for (j = 0; j < xnestNumDepths; j++)
+ if ((xnestPixmapFormats[i].depth == 1) ||
+ (xnestPixmapFormats[i].depth == xnestDepths[j])) {
+ screenInfo->formats[screenInfo->numPixmapFormats].depth =
+ xnestPixmapFormats[i].depth;
+ screenInfo->formats[screenInfo->numPixmapFormats].bitsPerPixel =
+ xnestPixmapFormats[i].bits_per_pixel;
+ screenInfo->formats[screenInfo->numPixmapFormats].scanlinePad =
+ xnestPixmapFormats[i].scanline_pad;
+ screenInfo->numPixmapFormats++;
+ break;
+ }
+
+ xnestWindowPrivateIndex = AllocateWindowPrivateIndex();
+ xnestGCPrivateIndex = AllocateGCPrivateIndex();
+ xnestFontPrivateIndex = AllocateFontPrivateIndex();
+
+ if (!xnestNumScreens) xnestNumScreens = 1;
+
+ for (i = 0; i < xnestNumScreens; i++)
+ AddScreen(xnestOpenScreen, argc, argv);
+
+ xnestNumScreens = screenInfo->numScreens;
+
+ xnestDoFullGeneration = xnestFullGeneration;
+}
+
+void
+InitInput(int argc, char *argv[])
+{
+ xnestPointerDevice = AddInputDevice(xnestPointerProc, TRUE);
+ xnestKeyboardDevice = AddInputDevice(xnestKeyboardProc, TRUE);
+
+ RegisterPointerDevice(xnestPointerDevice);
+ RegisterKeyboardDevice(xnestKeyboardDevice);
+
+ mieqInit((DevicePtr)xnestKeyboardDevice, (DevicePtr)xnestPointerDevice);
+
+ AddEnabledDevice(XConnectionNumber(xnestDisplay));
+
+ RegisterBlockAndWakeupHandlers(xnestBlockHandler, xnestWakeupHandler, NULL);
+}
+
+/*
+ * DDX - specific abort routine. Called by AbortServer().
+ */
+void AbortDDX()
+{
+ xnestDoFullGeneration = True;
+ xnestCloseDisplay();
+}
+
+/* Called by GiveUp(). */
+void ddxGiveUp()
+{
+ AbortDDX();
+}
+
+#ifdef __DARWIN__
+void
+DarwinHandleGUI(int argc, char *argv[])
+{
+}
+
+void GlxExtensionInit();
+void GlxWrapInitVisuals(void *procPtr);
+
+void
+DarwinGlxExtensionInit()
+{
+ GlxExtensionInit();
+}
+
+void
+DarwinGlxWrapInitVisuals(
+ void *procPtr)
+{
+ GlxWrapInitVisuals(procPtr);
+}
+#endif
+
+void OsVendorInit()
+{
+ return;
+}
+
+void OsVendorFatalError()
+{
+ return;
+}
+
+void ddxBeforeReset(void)
+{
+ return;
+}
+
+/* this is just to get the server to link on AIX */
+#ifdef AIXV3
+int SelectWaitTime = 10000; /* usec */
+#endif
+
diff --git a/nx-X11/programs/Xserver/hw/xnest/Init.h b/nx-X11/programs/Xserver/hw/xnest/Init.h
new file mode 100644
index 000000000..8fb9956eb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Init.h
@@ -0,0 +1,21 @@
+/* $Xorg: Init.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+
+#ifndef XNESTINIT_H
+#define XNESTINIT_H
+
+extern Bool xnestDoFullGeneration;
+
+#endif /* XNESTINIT_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/Keyboard.c b/nx-X11/programs/Xserver/hw/xnest/Keyboard.c
new file mode 100644
index 000000000..8628fd485
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Keyboard.c
@@ -0,0 +1,339 @@
+/* $Xorg: Keyboard.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xnest/Keyboard.c,v 1.8 2005/07/14 03:36:44 kem Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Keyboard.c,v 1.9 2003/09/13 21:33:09 dawes Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "screenint.h"
+#include "inputstr.h"
+#include "misc.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Screen.h"
+#include "Keyboard.h"
+#include "Args.h"
+#include "Events.h"
+
+#ifdef XKB
+#include <X11/extensions/XKB.h>
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XKBconfig.h>
+
+extern Bool
+XkbQueryExtension(
+ Display * /* dpy */,
+ int * /* opcodeReturn */,
+ int * /* eventBaseReturn */,
+ int * /* errorBaseReturn */,
+ int * /* majorRtrn */,
+ int * /* minorRtrn */
+);
+
+extern XkbDescPtr XkbGetKeyboard(
+ Display * /* dpy */,
+ unsigned int /* which */,
+ unsigned int /* deviceSpec */
+);
+
+extern Status XkbGetControls(
+ Display * /* dpy */,
+ unsigned long /* which */,
+ XkbDescPtr /* desc */
+);
+
+#ifndef XKB_BASE_DIRECTORY
+#define XKB_BASE_DIRECTORY "/usr/X11R6/lib/X11/xkb/"
+#endif
+#ifndef XKB_CONFIG_FILE
+#define XKB_CONFIG_FILE "X0-config.keyboard"
+#endif
+#ifndef XKB_DFLT_RULES_FILE
+#define XKB_DFLT_RULES_FILE __XKBDEFRULES__
+#endif
+#ifndef XKB_DFLT_KB_LAYOUT
+#define XKB_DFLT_KB_LAYOUT "us"
+#endif
+#ifndef XKB_DFLT_KB_MODEL
+#define XKB_DFLT_KB_MODEL "pc101"
+#endif
+#ifndef XKB_DFLT_KB_VARIANT
+#define XKB_DFLT_KB_VARIANT NULL
+#endif
+#ifndef XKB_DFLT_KB_OPTIONS
+#define XKB_DFLT_KB_OPTIONS NULL
+#endif
+
+#endif
+
+DeviceIntPtr xnestKeyboardDevice = NULL;
+
+void
+xnestBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls)
+{
+ XBell(xnestDisplay, volume);
+}
+
+void
+xnestChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
+{
+#if 0
+ unsigned long value_mask;
+ XKeyboardControl values;
+ int i;
+
+ value_mask = KBKeyClickPercent |
+ KBBellPercent |
+ KBBellPitch |
+ KBBellDuration |
+ KBAutoRepeatMode;
+
+ values.key_click_percent = ctrl->click;
+ values.bell_percent = ctrl->bell;
+ values.bell_pitch = ctrl->bell_pitch;
+ values.bell_duration = ctrl->bell_duration;
+ values.auto_repeat_mode = ctrl->autoRepeat ?
+ AutoRepeatModeOn : AutoRepeatModeOff;
+
+ XChangeKeyboardControl(xnestDisplay, value_mask, &values);
+
+ /*
+ value_mask = KBKey | KBAutoRepeatMode;
+ At this point, we need to walk through the vector and compare it
+ to the current server vector. If there are differences, report them.
+ */
+
+ value_mask = KBLed | KBLedMode;
+ for (i = 1; i <= 32; i++) {
+ values.led = i;
+ values.led_mode = (ctrl->leds & (1 << (i - 1))) ? LedModeOn : LedModeOff;
+ XChangeKeyboardControl(xnestDisplay, value_mask, &values);
+ }
+#endif
+}
+
+int
+xnestKeyboardProc(DeviceIntPtr pDev, int onoff)
+{
+ XModifierKeymap *modifier_keymap;
+ KeySym *keymap;
+ int mapWidth;
+ int min_keycode, max_keycode;
+ KeySymsRec keySyms;
+ CARD8 modmap[MAP_LENGTH];
+ int i, j;
+ XKeyboardState values;
+
+ switch (onoff)
+ {
+ case DEVICE_INIT:
+ modifier_keymap = XGetModifierMapping(xnestDisplay);
+ XDisplayKeycodes(xnestDisplay, &min_keycode, &max_keycode);
+#ifdef _XSERVER64
+ {
+ KeySym64 *keymap64;
+ int i, len;
+ keymap64 = XGetKeyboardMapping(xnestDisplay,
+ min_keycode,
+ max_keycode - min_keycode + 1,
+ &mapWidth);
+ len = (max_keycode - min_keycode + 1) * mapWidth;
+ keymap = (KeySym *)xalloc(len * sizeof(KeySym));
+ for(i = 0; i < len; ++i)
+ keymap[i] = keymap64[i];
+ XFree(keymap64);
+ }
+#else
+ keymap = XGetKeyboardMapping(xnestDisplay,
+ min_keycode,
+ max_keycode - min_keycode + 1,
+ &mapWidth);
+#endif
+
+ for (i = 0; i < MAP_LENGTH; i++)
+ modmap[i] = 0;
+ for (j = 0; j < 8; j++)
+ for(i = 0; i < modifier_keymap->max_keypermod; i++) {
+ CARD8 keycode;
+ if ((keycode =
+ modifier_keymap->
+ modifiermap[j * modifier_keymap->max_keypermod + i]))
+ modmap[keycode] |= 1<<j;
+ }
+ XFreeModifiermap(modifier_keymap);
+
+ keySyms.minKeyCode = min_keycode;
+ keySyms.maxKeyCode = max_keycode;
+ keySyms.mapWidth = mapWidth;
+ keySyms.map = keymap;
+
+#ifdef XKB
+ if (noXkbExtension) {
+XkbError:
+#endif
+ XGetKeyboardControl(xnestDisplay, &values);
+
+ memmove((char *) defaultKeyboardControl.autoRepeats,
+ (char *) values.auto_repeats, sizeof(values.auto_repeats));
+
+ InitKeyboardDeviceStruct(&pDev->public, &keySyms, modmap,
+ xnestBell, xnestChangeKeyboardControl);
+#ifdef XKB
+ } else {
+ FILE *file;
+ XkbConfigRtrnRec config;
+
+ XkbComponentNamesRec names;
+ char *rules, *model, *layout, *variants, *options;
+
+ XkbDescPtr xkb;
+ int op, event, error, major, minor;
+
+ if (XkbQueryExtension(xnestDisplay, &op, &event, &error, &major, &minor) == 0) {
+ ErrorF("Unable to initialize XKEYBOARD extension.\n");
+ goto XkbError;
+ }
+ xkb = XkbGetKeyboard(xnestDisplay, XkbGBN_AllComponentsMask, XkbUseCoreKbd);
+ if (xkb == NULL || xkb->geom == NULL) {
+ ErrorF("Couldn't get keyboard.\n");
+ goto XkbError;
+ }
+ XkbGetControls(xnestDisplay, XkbAllControlsMask, xkb);
+
+ memset(&names, 0, sizeof(XkbComponentNamesRec));
+ rules = XKB_DFLT_RULES_FILE;
+ model = XKB_DFLT_KB_MODEL;
+ layout = XKB_DFLT_KB_LAYOUT;
+ variants = XKB_DFLT_KB_VARIANT;
+ options = XKB_DFLT_KB_OPTIONS;
+ if (XkbInitialMap) {
+ if ((names.keymap = strchr(XkbInitialMap, '/')) != NULL)
+ ++names.keymap;
+ else
+ names.keymap = XkbInitialMap;
+ }
+
+ if ((file = fopen(XKB_BASE_DIRECTORY XKB_CONFIG_FILE, "r")) != NULL) {
+ if (XkbCFParse(file, XkbCFDflts, xkb, &config) == 0) {
+ ErrorF("Error parsing config file.\n");
+ fclose(file);
+ goto XkbError;
+ }
+ if (config.rules_file)
+ rules = config.rules_file;
+ if (config.model)
+ model = config.model;
+ if (config.layout)
+ layout = config.layout;
+ if (config.variant)
+ variants = config.variant;
+ if (config.options)
+ options = config.options;
+
+ fclose(file);
+ }
+
+ XkbSetRulesDflts(rules, model, layout, variants, options);
+ XkbInitKeyboardDeviceStruct(pDev, &names, &keySyms, modmap,
+ xnestBell, xnestChangeKeyboardControl);
+ XkbDDXChangeControls(pDev, xkb->ctrls, xkb->ctrls);
+ XkbFreeKeyboard(xkb, 0, False);
+ }
+#endif
+#ifdef _XSERVER64
+ xfree(keymap);
+#else
+ XFree(keymap);
+#endif
+ break;
+ case DEVICE_ON:
+ xnestEventMask |= XNEST_KEYBOARD_EVENT_MASK;
+ for (i = 0; i < xnestNumScreens; i++)
+ XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask);
+ break;
+ case DEVICE_OFF:
+ xnestEventMask &= ~XNEST_KEYBOARD_EVENT_MASK;
+ for (i = 0; i < xnestNumScreens; i++)
+ XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask);
+ break;
+ case DEVICE_CLOSE:
+ break;
+ }
+ return Success;
+}
+
+Bool
+LegalModifier(unsigned int key, DevicePtr pDev)
+{
+ return TRUE;
+}
+
+void
+xnestUpdateModifierState(unsigned int state)
+{
+ DeviceIntPtr pDev = xnestKeyboardDevice;
+ KeyClassPtr keyc = pDev->key;
+ int i;
+ CARD8 mask;
+
+ state = state & 0xff;
+
+ if (keyc->state == state)
+ return;
+
+ for (i = 0, mask = 1; i < 8; i++, mask <<= 1) {
+ int key;
+
+ /* Modifier is down, but shouldn't be
+ */
+ if ((keyc->state & mask) && !(state & mask)) {
+ int count = keyc->modifierKeyCount[i];
+
+ for (key = 0; key < MAP_LENGTH; key++)
+ if (keyc->modifierMap[key] & mask) {
+ int bit;
+ BYTE *kptr;
+
+ kptr = &keyc->down[key >> 3];
+ bit = 1 << (key & 7);
+
+ if (*kptr & bit)
+ xnestQueueKeyEvent(KeyRelease, key);
+
+ if (--count == 0)
+ break;
+ }
+ }
+
+ /* Modifier shoud be down, but isn't
+ */
+ if (!(keyc->state & mask) && (state & mask))
+ for (key = 0; key < MAP_LENGTH; key++)
+ if (keyc->modifierMap[key] & mask) {
+ xnestQueueKeyEvent(KeyPress, key);
+ break;
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xnest/Keyboard.h b/nx-X11/programs/Xserver/hw/xnest/Keyboard.h
new file mode 100644
index 000000000..8237dac14
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Keyboard.h
@@ -0,0 +1,30 @@
+/* $Xorg: Keyboard.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+#ifndef XNESTKEYBOARD_H
+#define XNESTKEYBOARD_H
+
+#define XNEST_KEYBOARD_EVENT_MASK \
+ (KeyPressMask | KeyReleaseMask | FocusChangeMask | KeymapStateMask)
+
+extern DeviceIntPtr xnestKeyboardDevice;
+
+void xnestBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls);
+void xnestChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl);
+int xnestKeyboardProc(DeviceIntPtr pDev, int onoff);
+void xnestUpdateModifierState(unsigned int state);
+
+#endif /* XNESTKEYBOARD_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/Pixmap.c b/nx-X11/programs/Xserver/hw/xnest/Pixmap.c
new file mode 100644
index 000000000..30ffbc6e6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Pixmap.c
@@ -0,0 +1,141 @@
+/* $Xorg: Pixmap.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Pixmap.c,v 3.7 2003/07/16 01:38:51 dawes Exp $ */
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "regionstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "regionstr.h"
+#include "gc.h"
+#include "servermd.h"
+#include "mi.h"
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Screen.h"
+#include "XNPixmap.h"
+
+#ifdef PIXPRIV
+int xnestPixmapPrivateIndex;
+#endif
+
+PixmapPtr
+xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth)
+{
+ PixmapPtr pPixmap;
+
+ pPixmap = AllocatePixmap(pScreen, sizeof(xnestPrivPixmap));
+ if (!pPixmap)
+ return NullPixmap;
+ pPixmap->drawable.type = DRAWABLE_PIXMAP;
+ pPixmap->drawable.class = 0;
+ pPixmap->drawable.depth = depth;
+ pPixmap->drawable.bitsPerPixel = depth;
+ pPixmap->drawable.id = 0;
+ pPixmap->drawable.x = 0;
+ pPixmap->drawable.y = 0;
+ pPixmap->drawable.width = width;
+ pPixmap->drawable.height = height;
+ pPixmap->drawable.pScreen = pScreen;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pPixmap->refcnt = 1;
+ pPixmap->devKind = PixmapBytePad(width, depth);
+#ifdef PIXPRIV
+ pPixmap->devPrivates[xnestPixmapPrivateIndex].ptr =
+ (pointer)((char *)pPixmap + pScreen->totalPixmapSize);
+#else
+ pPixmap->devPrivate.ptr = (pointer)(pPixmap + 1);
+#endif
+ if (width && height)
+ xnestPixmapPriv(pPixmap)->pixmap =
+ XCreatePixmap(xnestDisplay,
+ xnestDefaultWindows[pScreen->myNum],
+ width, height, depth);
+ else
+ xnestPixmapPriv(pPixmap)->pixmap = 0;
+
+ return pPixmap;
+}
+
+Bool
+xnestDestroyPixmap(PixmapPtr pPixmap)
+{
+ if(--pPixmap->refcnt)
+ return TRUE;
+ XFreePixmap(xnestDisplay, xnestPixmap(pPixmap));
+ xfree(pPixmap);
+ return TRUE;
+}
+
+RegionPtr
+xnestPixmapToRegion(PixmapPtr pPixmap)
+{
+ XImage *ximage;
+ register RegionPtr pReg, pTmpReg;
+ register int x, y;
+ unsigned long previousPixel, currentPixel;
+ BoxRec Box;
+ Bool overlap;
+
+ ximage = XGetImage(xnestDisplay, xnestPixmap(pPixmap), 0, 0,
+ pPixmap->drawable.width, pPixmap->drawable.height,
+ 1, XYPixmap);
+
+ pReg = REGION_CREATE(pPixmap->drawable.pScreen, NULL, 1);
+ pTmpReg = REGION_CREATE(pPixmap->drawable.pScreen, NULL, 1);
+ if(!pReg || !pTmpReg) return NullRegion;
+
+ for (y = 0; y < pPixmap->drawable.height; y++) {
+ Box.y1 = y;
+ Box.y2 = y + 1;
+ previousPixel = 0L;
+ for (x = 0; x < pPixmap->drawable.width; x++) {
+ currentPixel = XGetPixel(ximage, x, y);
+ if (previousPixel != currentPixel) {
+ if (previousPixel == 0L) {
+ /* left edge */
+ Box.x1 = x;
+ }
+ else if (currentPixel == 0L) {
+ /* right edge */
+ Box.x2 = x;
+ REGION_RESET(pPixmap->drawable.pScreen, pTmpReg, &Box);
+ REGION_APPEND(pPixmap->drawable.pScreen, pReg, pTmpReg);
+ }
+ previousPixel = currentPixel;
+ }
+ }
+ if (previousPixel != 0L) {
+ /* right edge because of the end of pixmap */
+ Box.x2 = pPixmap->drawable.width;
+ REGION_RESET(pPixmap->drawable.pScreen, pTmpReg, &Box);
+ REGION_APPEND(pPixmap->drawable.pScreen, pReg, pTmpReg);
+ }
+ }
+
+ REGION_DESTROY(pPixmap->drawable.pScreen, pTmpReg);
+ XDestroyImage(ximage);
+
+ REGION_VALIDATE(pPixmap->drawable.pScreen, pReg, &overlap);
+
+ return(pReg);
+}
diff --git a/nx-X11/programs/Xserver/hw/xnest/Pointer.c b/nx-X11/programs/Xserver/hw/xnest/Pointer.c
new file mode 100644
index 000000000..1533a06d8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Pointer.c
@@ -0,0 +1,79 @@
+/* $Xorg: Pointer.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "screenint.h"
+#include "inputstr.h"
+#include "input.h"
+#include "misc.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#include "mipointer.h"
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Screen.h"
+#include "Pointer.h"
+#include "Args.h"
+
+DeviceIntPtr xnestPointerDevice = NULL;
+
+void
+xnestChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl)
+{
+ XChangePointerControl(xnestDisplay, True, True,
+ ctrl->num, ctrl->den, ctrl->threshold);
+}
+
+int
+xnestPointerProc(DeviceIntPtr pDev, int onoff)
+{
+ CARD8 map[MAXBUTTONS];
+ int nmap;
+ int i;
+
+ switch (onoff)
+ {
+ case DEVICE_INIT:
+ nmap = XGetPointerMapping(xnestDisplay, map, MAXBUTTONS);
+ for (i = 0; i <= nmap; i++)
+ map[i] = i; /* buttons are already mapped */
+ InitPointerDeviceStruct(&pDev->public, map, nmap,
+ miPointerGetMotionEvents,
+ xnestChangePointerControl,
+ miPointerGetMotionBufferSize());
+ break;
+ case DEVICE_ON:
+ xnestEventMask |= XNEST_POINTER_EVENT_MASK;
+ for (i = 0; i < xnestNumScreens; i++)
+ XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask);
+ break;
+ case DEVICE_OFF:
+ xnestEventMask &= ~XNEST_POINTER_EVENT_MASK;
+ for (i = 0; i < xnestNumScreens; i++)
+ XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask);
+ break;
+ case DEVICE_CLOSE:
+ break;
+ }
+ return Success;
+}
diff --git a/nx-X11/programs/Xserver/hw/xnest/Pointer.h b/nx-X11/programs/Xserver/hw/xnest/Pointer.h
new file mode 100644
index 000000000..872dfb8ee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Pointer.h
@@ -0,0 +1,31 @@
+/* $Xorg: Pointer.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+#ifndef XNESTPOINTER_H
+#define XNESTPOINTER_H
+
+#define MAXBUTTONS 256
+
+#define XNEST_POINTER_EVENT_MASK \
+ (ButtonPressMask | ButtonReleaseMask | PointerMotionMask | \
+ EnterWindowMask | LeaveWindowMask)
+
+extern DeviceIntPtr xnestPointerDevice;
+
+void xnestChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl);
+int xnestPointerProc(DeviceIntPtr pDev, int onoff);
+
+#endif /* XNESTPOINTER_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/Screen.c b/nx-X11/programs/Xserver/hw/xnest/Screen.c
new file mode 100644
index 000000000..660e54fe7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Screen.c
@@ -0,0 +1,458 @@
+/* $Xorg: Screen.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Screen.c,v 3.12 2003/11/14 22:25:59 dawes Exp $ */
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "dix.h"
+#include "mi.h"
+#include "mibstore.h"
+#include "micmap.h"
+#include "colormapst.h"
+#include "resource.h"
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Screen.h"
+#include "XNGC.h"
+#include "GCOps.h"
+#include "Drawable.h"
+#include "XNFont.h"
+#include "Color.h"
+#include "XNCursor.h"
+#include "Visual.h"
+#include "Events.h"
+#include "Init.h"
+#include "mipointer.h"
+#include "Args.h"
+
+Window xnestDefaultWindows[MAXSCREENS];
+Window xnestScreenSaverWindows[MAXSCREENS];
+
+#ifdef GLXEXT
+extern void GlxWrapInitVisuals(miInitVisualsProcPtr *);
+#endif
+
+#ifdef PIXPRIV
+int xnestScreenGeneration = -1;
+#endif
+
+ScreenPtr
+xnestScreen(Window window)
+{
+ int i;
+
+ for (i = 0; i < xnestNumScreens; i++)
+ if (xnestDefaultWindows[i] == window)
+ return screenInfo.screens[i];
+
+ return NULL;
+}
+
+static int
+offset(unsigned long mask)
+{
+ int count;
+
+ for (count = 0; !(mask & 1) && count < 32; count++)
+ mask >>= 1;
+
+ return count;
+}
+
+static Bool
+xnestSaveScreen(ScreenPtr pScreen, int what)
+{
+ if (xnestSoftwareScreenSaver)
+ return False;
+ else {
+ switch (what) {
+ case SCREEN_SAVER_ON:
+ XMapRaised(xnestDisplay, xnestScreenSaverWindows[pScreen->myNum]);
+ xnestSetScreenSaverColormapWindow(pScreen);
+ break;
+
+ case SCREEN_SAVER_OFF:
+ XUnmapWindow(xnestDisplay, xnestScreenSaverWindows[pScreen->myNum]);
+ xnestSetInstalledColormapWindows(pScreen);
+ break;
+
+ case SCREEN_SAVER_FORCER:
+ lastEventTime = GetTimeInMillis();
+ XUnmapWindow(xnestDisplay, xnestScreenSaverWindows[pScreen->myNum]);
+ xnestSetInstalledColormapWindows(pScreen);
+ break;
+
+ case SCREEN_SAVER_CYCLE:
+ XUnmapWindow(xnestDisplay, xnestScreenSaverWindows[pScreen->myNum]);
+ xnestSetInstalledColormapWindows(pScreen);
+ break;
+ }
+ return True;
+ }
+}
+
+static Bool
+xnestCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
+{
+ return FALSE;
+}
+
+static void
+xnestCrossScreen(ScreenPtr pScreen, Bool entering)
+{
+}
+
+static miPointerScreenFuncRec xnestPointerCursorFuncs =
+{
+ xnestCursorOffScreen,
+ xnestCrossScreen,
+ miPointerWarpCursor
+};
+
+static miPointerSpriteFuncRec xnestPointerSpriteFuncs =
+{
+ xnestRealizeCursor,
+ xnestUnrealizeCursor,
+ xnestSetCursor,
+ xnestMoveCursor,
+};
+
+Bool
+xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[])
+{
+ VisualPtr visuals;
+ DepthPtr depths;
+ int numVisuals, numDepths;
+ int i, j, depthIndex;
+ unsigned long valuemask;
+ XSetWindowAttributes attributes;
+ XWindowAttributes gattributes;
+ XSizeHints sizeHints;
+ VisualID defaultVisual;
+ int rootDepth;
+
+ if (!(AllocateWindowPrivate(pScreen, xnestWindowPrivateIndex,
+ sizeof(xnestPrivWin)) &&
+ AllocateGCPrivate(pScreen, xnestGCPrivateIndex,
+ sizeof(xnestPrivGC))))
+ return False;
+
+#ifdef PIXPRIV
+ if (xnestScreenGeneration != serverGeneration) {
+ if ((xnestPixmapPrivateIndex = AllocatePixmapPrivateIndex()) < 0)
+ return False;
+ xnestScreenGeneration = serverGeneration;
+ }
+
+ if (!AllocatePixmapPrivate(pScreen,xnestPixmapPrivateIndex,
+ sizeof (xnestPrivPixmap)))
+ return False;
+#endif
+ visuals = (VisualPtr)xalloc(xnestNumVisuals * sizeof(VisualRec));
+ numVisuals = 0;
+
+ depths = (DepthPtr)xalloc(MAXDEPTH * sizeof(DepthRec));
+ depths[0].depth = 1;
+ depths[0].numVids = 0;
+ depths[0].vids = (VisualID *)xalloc(MAXVISUALSPERDEPTH * sizeof(VisualID));
+ numDepths = 1;
+
+ for (i = 0; i < xnestNumVisuals; i++) {
+ visuals[numVisuals].class = xnestVisuals[i].class;
+ visuals[numVisuals].bitsPerRGBValue = xnestVisuals[i].bits_per_rgb;
+ visuals[numVisuals].ColormapEntries = xnestVisuals[i].colormap_size;
+ visuals[numVisuals].nplanes = xnestVisuals[i].depth;
+ visuals[numVisuals].redMask = xnestVisuals[i].red_mask;
+ visuals[numVisuals].greenMask = xnestVisuals[i].green_mask;
+ visuals[numVisuals].blueMask = xnestVisuals[i].blue_mask;
+ visuals[numVisuals].offsetRed = offset(xnestVisuals[i].red_mask);
+ visuals[numVisuals].offsetGreen = offset(xnestVisuals[i].green_mask);
+ visuals[numVisuals].offsetBlue = offset(xnestVisuals[i].blue_mask);
+
+ /* Check for and remove duplicates. */
+ for (j = 0; j < numVisuals; j++) {
+ if (visuals[numVisuals].class == visuals[j].class &&
+ visuals[numVisuals].bitsPerRGBValue == visuals[j].bitsPerRGBValue &&
+ visuals[numVisuals].ColormapEntries == visuals[j].ColormapEntries &&
+ visuals[numVisuals].nplanes == visuals[j].nplanes &&
+ visuals[numVisuals].redMask == visuals[j].redMask &&
+ visuals[numVisuals].greenMask == visuals[j].greenMask &&
+ visuals[numVisuals].blueMask == visuals[j].blueMask &&
+ visuals[numVisuals].offsetRed == visuals[j].offsetRed &&
+ visuals[numVisuals].offsetGreen == visuals[j].offsetGreen &&
+ visuals[numVisuals].offsetBlue == visuals[j].offsetBlue)
+ break;
+ }
+ if (j < numVisuals)
+ break;
+
+ visuals[numVisuals].vid = FakeClientID(0);
+
+ depthIndex = UNDEFINED;
+ for (j = 0; j < numDepths; j++)
+ if (depths[j].depth == xnestVisuals[i].depth) {
+ depthIndex = j;
+ break;
+ }
+
+ if (depthIndex == UNDEFINED) {
+ depthIndex = numDepths;
+ depths[depthIndex].depth = xnestVisuals[i].depth;
+ depths[depthIndex].numVids = 0;
+ depths[depthIndex].vids =
+ (VisualID *)xalloc(MAXVISUALSPERDEPTH * sizeof(VisualID));
+ numDepths++;
+ }
+ if (depths[depthIndex].numVids >= MAXVISUALSPERDEPTH) {
+ FatalError("Visual table overflow");
+ }
+ depths[depthIndex].vids[depths[depthIndex].numVids] =
+ visuals[numVisuals].vid;
+ depths[depthIndex].numVids++;
+
+ numVisuals++;
+ }
+ visuals = (VisualPtr)xrealloc(visuals, numVisuals * sizeof(VisualRec));
+
+ defaultVisual = visuals[xnestDefaultVisualIndex].vid;
+ rootDepth = visuals[xnestDefaultVisualIndex].nplanes;
+
+#ifdef GLXEXT
+ {
+ miInitVisualsProcPtr proc = NULL;
+
+ GlxWrapInitVisuals(&proc);
+ /* GlxInitVisuals ignores the last three arguments. */
+ proc(&visuals, &depths, &numVisuals, &numDepths,
+ &rootDepth, &defaultVisual, 0, 0, 0);
+ }
+#endif
+
+ if (xnestParentWindow != 0) {
+ XGetWindowAttributes(xnestDisplay, xnestParentWindow, &gattributes);
+ xnestWidth = gattributes.width;
+ xnestHeight = gattributes.height;
+ }
+
+ /* myNum */
+ /* id */
+ miScreenInit(pScreen, NULL, xnestWidth, xnestHeight, 1, 1, xnestWidth,
+ rootDepth,
+ numDepths, depths,
+ defaultVisual, /* root visual */
+ numVisuals, visuals);
+
+/* miInitializeBackingStore(pScreen); */
+
+ pScreen->defColormap = (Colormap) FakeClientID(0);
+ pScreen->minInstalledCmaps = MINCMAPS;
+ pScreen->maxInstalledCmaps = MAXCMAPS;
+ pScreen->backingStoreSupport = NotUseful;
+ pScreen->saveUnderSupport = NotUseful;
+ pScreen->whitePixel = xnestWhitePixel;
+ pScreen->blackPixel = xnestBlackPixel;
+ /* rgf */
+ /* GCperDepth */
+ /* PixmapPerDepth */
+ pScreen->devPrivate = NULL;
+ /* WindowPrivateLen */
+ /* WindowPrivateSizes */
+ /* totalWindowSize */
+ /* GCPrivateLen */
+ /* GCPrivateSizes */
+ /* totalGCSize */
+
+ /* Random screen procedures */
+
+ pScreen->QueryBestSize = xnestQueryBestSize;
+ pScreen->SaveScreen = xnestSaveScreen;
+ pScreen->GetImage = xnestGetImage;
+ pScreen->GetSpans = xnestGetSpans;
+ pScreen->PointerNonInterestBox = NULL;
+ pScreen->SourceValidate = NULL;
+
+ /* Window Procedures */
+
+ pScreen->CreateWindow = xnestCreateWindow;
+ pScreen->DestroyWindow = xnestDestroyWindow;
+ pScreen->PositionWindow = xnestPositionWindow;
+ pScreen->ChangeWindowAttributes = xnestChangeWindowAttributes;
+ pScreen->RealizeWindow = xnestRealizeWindow;
+ pScreen->UnrealizeWindow = xnestUnrealizeWindow;
+ pScreen->PostValidateTree = NULL;
+ pScreen->WindowExposures = xnestWindowExposures;
+ pScreen->PaintWindowBackground = xnestPaintWindowBackground;
+ pScreen->PaintWindowBorder = xnestPaintWindowBorder;
+ pScreen->CopyWindow = xnestCopyWindow;
+ pScreen->ClipNotify = xnestClipNotify;
+
+ /* Pixmap procedures */
+
+ pScreen->CreatePixmap = xnestCreatePixmap;
+ pScreen->DestroyPixmap = xnestDestroyPixmap;
+
+ /* Backing store procedures */
+
+ pScreen->SaveDoomedAreas = NULL;
+ pScreen->RestoreAreas = NULL;
+ pScreen->ExposeCopy = NULL;
+ pScreen->TranslateBackingStore = NULL;
+ pScreen->ClearBackingStore = NULL;
+ pScreen->DrawGuarantee = NULL;
+
+ /* Font procedures */
+
+ pScreen->RealizeFont = xnestRealizeFont;
+ pScreen->UnrealizeFont = xnestUnrealizeFont;
+
+ /* GC procedures */
+
+ pScreen->CreateGC = xnestCreateGC;
+
+ /* Colormap procedures */
+
+ pScreen->CreateColormap = xnestCreateColormap;
+ pScreen->DestroyColormap = xnestDestroyColormap;
+ pScreen->InstallColormap = xnestInstallColormap;
+ pScreen->UninstallColormap = xnestUninstallColormap;
+ pScreen->ListInstalledColormaps = xnestListInstalledColormaps;
+ pScreen->StoreColors = xnestStoreColors;
+ pScreen->ResolveColor = xnestResolveColor;
+
+ pScreen->BitmapToRegion = xnestPixmapToRegion;
+
+ /* OS layer procedures */
+
+ pScreen->BlockHandler = (ScreenBlockHandlerProcPtr)NoopDDA;
+ pScreen->WakeupHandler = (ScreenWakeupHandlerProcPtr)NoopDDA;
+ pScreen->blockData = NULL;
+ pScreen->wakeupData = NULL;
+
+ miPointerInitialize (pScreen, &xnestPointerSpriteFuncs,
+ &xnestPointerCursorFuncs, True);
+
+ pScreen->mmWidth = xnestWidth * DisplayWidthMM(xnestDisplay,
+ DefaultScreen(xnestDisplay)) /
+ DisplayWidth(xnestDisplay,
+ DefaultScreen(xnestDisplay));
+ pScreen->mmHeight = xnestHeight * DisplayHeightMM(xnestDisplay,
+ DefaultScreen(xnestDisplay)) /
+ DisplayHeight(xnestDisplay,
+ DefaultScreen(xnestDisplay));
+
+ /* overwrite miCloseScreen with our own */
+ pScreen->CloseScreen = xnestCloseScreen;
+
+ if (!miScreenDevPrivateInit(pScreen, xnestWidth, NULL))
+ return FALSE;
+
+#ifdef SHAPE
+ /* overwrite miSetShape with our own */
+ pScreen->SetShape = xnestSetShape;
+#endif /* SHAPE */
+
+ /* devPrivates */
+
+#define POSITION_OFFSET (pScreen->myNum * (xnestWidth + xnestHeight) / 32)
+
+ if (xnestDoFullGeneration) {
+
+ valuemask = CWBackPixel | CWEventMask | CWColormap;
+ attributes.background_pixel = xnestWhitePixel;
+ attributes.event_mask = xnestEventMask;
+ attributes.colormap = xnestDefaultVisualColormap(xnestDefaultVisual(pScreen));
+
+ if (xnestParentWindow != 0) {
+ xnestDefaultWindows[pScreen->myNum] = xnestParentWindow;
+ XSelectInput (xnestDisplay, xnestDefaultWindows[pScreen->myNum],
+ xnestEventMask);
+ } else
+ xnestDefaultWindows[pScreen->myNum] =
+ XCreateWindow(xnestDisplay,
+ DefaultRootWindow(xnestDisplay),
+ xnestX + POSITION_OFFSET,
+ xnestY + POSITION_OFFSET,
+ xnestWidth, xnestHeight,
+ xnestBorderWidth,
+ pScreen->rootDepth,
+ InputOutput,
+ xnestDefaultVisual(pScreen),
+ valuemask, &attributes);
+
+ if (!xnestWindowName)
+ xnestWindowName = argv[0];
+
+ sizeHints.flags = PPosition | PSize | PMaxSize;
+ sizeHints.x = xnestX + POSITION_OFFSET;
+ sizeHints.y = xnestY + POSITION_OFFSET;
+ sizeHints.width = sizeHints.max_width = xnestWidth;
+ sizeHints.height = sizeHints.max_height = xnestHeight;
+ if (xnestUserGeometry & XValue || xnestUserGeometry & YValue)
+ sizeHints.flags |= USPosition;
+ if (xnestUserGeometry & WidthValue || xnestUserGeometry & HeightValue)
+ sizeHints.flags |= USSize;
+ XSetStandardProperties(xnestDisplay,
+ xnestDefaultWindows[pScreen->myNum],
+ xnestWindowName,
+ xnestWindowName,
+ xnestIconBitmap,
+ argv, argc, &sizeHints);
+
+ XMapWindow(xnestDisplay, xnestDefaultWindows[pScreen->myNum]);
+
+ valuemask = CWBackPixmap | CWColormap;
+ attributes.background_pixmap = xnestScreenSaverPixmap;
+ attributes.colormap =
+ DefaultColormap(xnestDisplay, DefaultScreen(xnestDisplay));
+ xnestScreenSaverWindows[pScreen->myNum] =
+ XCreateWindow(xnestDisplay,
+ xnestDefaultWindows[pScreen->myNum],
+ 0, 0, xnestWidth, xnestHeight, 0,
+ DefaultDepth(xnestDisplay, DefaultScreen(xnestDisplay)),
+ InputOutput,
+ DefaultVisual(xnestDisplay, DefaultScreen(xnestDisplay)),
+ valuemask, &attributes);
+ }
+
+ if (!xnestCreateDefaultColormap(pScreen)) return False;
+
+ return True;
+}
+
+Bool
+xnestCloseScreen(int index, ScreenPtr pScreen)
+{
+ int i;
+
+ for (i = 0; i < pScreen->numDepths; i++)
+ xfree(pScreen->allowedDepths[i].vids);
+ xfree(pScreen->allowedDepths);
+ xfree(pScreen->visuals);
+ xfree(pScreen->devPrivate);
+
+ /*
+ If xnestDoFullGeneration all x resources will be destroyed upon closing
+ the display connection. There is no need to generate extra protocol.
+ */
+
+ return True;
+}
diff --git a/nx-X11/programs/Xserver/hw/xnest/Screen.h b/nx-X11/programs/Xserver/hw/xnest/Screen.h
new file mode 100644
index 000000000..f35a2872d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Screen.h
@@ -0,0 +1,27 @@
+/* $Xorg: Screen.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+#ifndef XNESTSCREEN_H
+#define XNESTSCREEN_H
+
+extern Window xnestDefaultWindows[MAXSCREENS];
+extern Window xnestScreenSaverWindows[MAXSCREENS];
+
+ScreenPtr xnestScreen(Window window);
+Bool xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[]);
+Bool xnestCloseScreen(int index, ScreenPtr pScreen);
+
+#endif /* XNESTSCREEN_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/TestExt.c b/nx-X11/programs/Xserver/hw/xnest/TestExt.c
new file mode 100644
index 000000000..74446b050
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/TestExt.c
@@ -0,0 +1,69 @@
+/* $Xorg: TestExt.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/TestExt.c,v 3.5 2001/08/27 17:41:00 dawes Exp $ */
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xlib.h>
+#undef Bool
+#include "screenint.h"
+#include "input.h"
+#include "misc.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#include "mipointer.h"
+#define XTestSERVER_SIDE
+#include <X11/extensions/xtestext1.h>
+#include "xtest1dd.h"
+
+extern CARD32 lastEventTime;
+
+void
+XTestGetPointerPos(short *fmousex, short *fmousey)
+{
+ int x,y;
+
+ miPointerPosition(&x, &y);
+ *fmousex = x;
+ *fmousey = y;
+}
+
+void
+XTestJumpPointer(int jx, int jy, int dev_type)
+{
+ miPointerAbsoluteCursor(jx, jy, GetTimeInMillis());
+}
+
+void
+XTestGenerateEvent(int dev_type, int keycode, int keystate, int mousex,
+ int mousey)
+{
+/*
+ xEvent tevent;
+
+ tevent.u.u.type = (dev_type == XE_POINTER) ?
+ (keystate == XTestKEY_UP) ? ButtonRelease : ButtonPress :
+ (keystate == XTestKEY_UP) ? KeyRelease : KeyPress;
+ tevent.u.u.detail = keycode;
+ tevent.u.keyButtonPointer.rootX = mousex;
+ tevent.u.keyButtonPointer.rootY = mousey;
+ tevent.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
+ mieqEnqueue(&tevent);
+*/
+}
diff --git a/nx-X11/programs/Xserver/hw/xnest/Visual.c b/nx-X11/programs/Xserver/hw/xnest/Visual.c
new file mode 100644
index 000000000..bbdb71ec6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Visual.c
@@ -0,0 +1,72 @@
+/* $Xorg: Visual.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "dix.h"
+#include "mi.h"
+#include "mibstore.h"
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Visual.h"
+
+Visual *
+xnestVisual(VisualPtr pVisual)
+{
+ int i;
+
+ for (i = 0; i < xnestNumVisuals; i++)
+ if (pVisual->class == xnestVisuals[i].class &&
+ pVisual->bitsPerRGBValue == xnestVisuals[i].bits_per_rgb &&
+ pVisual->ColormapEntries == xnestVisuals[i].colormap_size &&
+ pVisual->nplanes == xnestVisuals[i].depth &&
+ pVisual->redMask == xnestVisuals[i].red_mask &&
+ pVisual->greenMask == xnestVisuals[i].green_mask &&
+ pVisual->blueMask == xnestVisuals[i].blue_mask)
+ return xnestVisuals[i].visual;
+
+ return NULL;
+}
+
+Visual *
+xnestVisualFromID(ScreenPtr pScreen, VisualID visual)
+{
+ int i;
+
+ for (i = 0; i < pScreen->numVisuals; i++)
+ if (pScreen->visuals[i].vid == visual)
+ return xnestVisual(&pScreen->visuals[i]);
+
+ return NULL;
+}
+
+Colormap
+xnestDefaultVisualColormap(Visual *visual)
+{
+ int i;
+
+ for (i = 0; i < xnestNumVisuals; i++)
+ if (xnestVisuals[i].visual == visual)
+ return xnestDefaultColormaps[i];
+
+ return None;
+}
diff --git a/nx-X11/programs/Xserver/hw/xnest/Visual.h b/nx-X11/programs/Xserver/hw/xnest/Visual.h
new file mode 100644
index 000000000..dfa74dbdc
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Visual.h
@@ -0,0 +1,27 @@
+/* $Xorg: Visual.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+#ifndef XNESTVISUAL_H
+#define XNESTVISUAL_H
+
+Visual *xnestVisual(VisualPtr pVisual);
+Visual *xnestVisualFromID(ScreenPtr pScreen, VisualID visual);
+Colormap xnestDefaultVisualColormap(Visual *visual);
+
+#define xnestDefaultVisual(pScreen) \
+ xnestVisualFromID((pScreen), (pScreen)->rootVisual)
+
+#endif /* XNESTVISUAL_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/Window.c b/nx-X11/programs/Xserver/hw/xnest/Window.c
new file mode 100644
index 000000000..f652c342a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Window.c
@@ -0,0 +1,558 @@
+/* $Xorg: Window.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/Window.c,v 3.7 2001/10/28 03:34:11 tsi Exp $ */
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "gcstruct.h"
+#include "window.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "colormapst.h"
+#include "scrnintstr.h"
+#include "region.h"
+
+#include "mi.h"
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Screen.h"
+#include "XNGC.h"
+#include "Drawable.h"
+#include "Color.h"
+#include "Visual.h"
+#include "Events.h"
+#include "Args.h"
+
+int xnestWindowPrivateIndex;
+
+static int
+xnestFindWindowMatch(WindowPtr pWin, pointer ptr)
+{
+ xnestWindowMatch *wm = (xnestWindowMatch *)ptr;
+ if (wm->window == xnestWindow(pWin)) {
+ wm->pWin = pWin;
+ return WT_STOPWALKING;
+ }
+ else
+ return WT_WALKCHILDREN;
+}
+
+WindowPtr
+xnestWindowPtr(Window window)
+{
+ xnestWindowMatch wm;
+ int i;
+
+ wm.pWin = NullWindow;
+ wm.window = window;
+
+ for (i = 0; i < xnestNumScreens; i++) {
+ WalkTree(screenInfo.screens[i], xnestFindWindowMatch, (pointer) &wm);
+ if (wm.pWin) break;
+ }
+
+ return wm.pWin;
+}
+
+Bool
+xnestCreateWindow(WindowPtr pWin)
+{
+ unsigned long mask;
+ XSetWindowAttributes attributes;
+ Visual *visual;
+ ColormapPtr pCmap;
+
+ if (pWin->drawable.class == InputOnly) {
+ mask = 0L;
+ visual = CopyFromParent;
+ }
+ else {
+ mask = CWEventMask | CWBackingStore;
+ attributes.event_mask = ExposureMask;
+ attributes.backing_store = NotUseful;
+
+ if (pWin->parent) {
+ if (pWin->optional && pWin->optional->visual != wVisual(pWin->parent)) {
+ visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin));
+ mask |= CWColormap;
+ if (pWin->optional->colormap) {
+ pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin), RT_COLORMAP);
+ attributes.colormap = xnestColormap(pCmap);
+ }
+ else
+ attributes.colormap = xnestDefaultVisualColormap(visual);
+ }
+ else
+ visual = CopyFromParent;
+ }
+ else { /* root windows have their own colormaps at creation time */
+ visual = xnestVisualFromID(pWin->drawable.pScreen, wVisual(pWin));
+ pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin), RT_COLORMAP);
+ mask |= CWColormap;
+ attributes.colormap = xnestColormap(pCmap);
+ }
+ }
+
+ xnestWindowPriv(pWin)->window = XCreateWindow(xnestDisplay,
+ xnestWindowParent(pWin),
+ pWin->origin.x -
+ wBorderWidth(pWin),
+ pWin->origin.y -
+ wBorderWidth(pWin),
+ pWin->drawable.width,
+ pWin->drawable.height,
+ pWin->borderWidth,
+ pWin->drawable.depth,
+ pWin->drawable.class,
+ visual,
+ mask, &attributes);
+ xnestWindowPriv(pWin)->parent = xnestWindowParent(pWin);
+ xnestWindowPriv(pWin)->x = pWin->origin.x - wBorderWidth(pWin);
+ xnestWindowPriv(pWin)->y = pWin->origin.y - wBorderWidth(pWin);
+ xnestWindowPriv(pWin)->width = pWin->drawable.width;
+ xnestWindowPriv(pWin)->height = pWin->drawable.height;
+ xnestWindowPriv(pWin)->border_width = pWin->borderWidth;
+ xnestWindowPriv(pWin)->sibling_above = None;
+ if (pWin->nextSib)
+ xnestWindowPriv(pWin->nextSib)->sibling_above = xnestWindow(pWin);
+#ifdef SHAPE
+ xnestWindowPriv(pWin)->bounding_shape =
+ REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
+ xnestWindowPriv(pWin)->clip_shape =
+ REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
+#endif /* SHAPE */
+
+ if (!pWin->parent) /* only the root window will have the right colormap */
+ xnestSetInstalledColormapWindows(pWin->drawable.pScreen);
+
+ return True;
+}
+
+Bool
+xnestDestroyWindow(WindowPtr pWin)
+{
+ if (pWin->nextSib)
+ xnestWindowPriv(pWin->nextSib)->sibling_above =
+ xnestWindowPriv(pWin)->sibling_above;
+#ifdef SHAPE
+ REGION_DESTROY(pWin->drawable.pScreen,
+ xnestWindowPriv(pWin)->bounding_shape);
+ REGION_DESTROY(pWin->drawable.pScreen,
+ xnestWindowPriv(pWin)->clip_shape);
+#endif
+ XDestroyWindow(xnestDisplay, xnestWindow(pWin));
+ xnestWindowPriv(pWin)->window = None;
+
+ if (pWin->optional && pWin->optional->colormap && pWin->parent)
+ xnestSetInstalledColormapWindows(pWin->drawable.pScreen);
+
+ return True;
+}
+
+Bool
+xnestPositionWindow(WindowPtr pWin, int x, int y)
+{
+ xnestConfigureWindow(pWin,
+ CWParent |
+ CWX | CWY |
+ CWWidth | CWHeight |
+ CWBorderWidth);
+
+ return True;
+}
+
+void
+xnestConfigureWindow(WindowPtr pWin, unsigned int mask)
+{
+ unsigned int valuemask;
+ XWindowChanges values;
+
+ if (mask & CWParent &&
+ xnestWindowPriv(pWin)->parent != xnestWindowParent(pWin)) {
+ XReparentWindow(xnestDisplay, xnestWindow(pWin),
+ xnestWindowParent(pWin),
+ pWin->origin.x - wBorderWidth(pWin),
+ pWin->origin.y - wBorderWidth(pWin));
+ xnestWindowPriv(pWin)->parent = xnestWindowParent(pWin);
+ xnestWindowPriv(pWin)->x = pWin->origin.x - wBorderWidth(pWin);
+ xnestWindowPriv(pWin)->y = pWin->origin.y - wBorderWidth(pWin);
+ xnestWindowPriv(pWin)->sibling_above = None;
+ if (pWin->nextSib)
+ xnestWindowPriv(pWin->nextSib)->sibling_above = xnestWindow(pWin);
+ }
+
+ valuemask = 0;
+
+ if (mask & CWX &&
+ xnestWindowPriv(pWin)->x != pWin->origin.x - wBorderWidth(pWin)) {
+ valuemask |= CWX;
+ values.x =
+ xnestWindowPriv(pWin)->x =
+ pWin->origin.x - wBorderWidth(pWin);
+ }
+
+ if (mask & CWY &&
+ xnestWindowPriv(pWin)->y != pWin->origin.y - wBorderWidth(pWin)) {
+ valuemask |= CWY;
+ values.y =
+ xnestWindowPriv(pWin)->y =
+ pWin->origin.y - wBorderWidth(pWin);
+ }
+
+ if (mask & CWWidth &&
+ xnestWindowPriv(pWin)->width != pWin->drawable.width) {
+ valuemask |= CWWidth;
+ values.width =
+ xnestWindowPriv(pWin)->width =
+ pWin->drawable.width;
+ }
+
+ if (mask & CWHeight &&
+ xnestWindowPriv(pWin)->height != pWin->drawable.height) {
+ valuemask |= CWHeight;
+ values.height =
+ xnestWindowPriv(pWin)->height =
+ pWin->drawable.height;
+ }
+
+ if (mask & CWBorderWidth &&
+ xnestWindowPriv(pWin)->border_width != pWin->borderWidth) {
+ valuemask |= CWBorderWidth;
+ values.border_width =
+ xnestWindowPriv(pWin)->border_width =
+ pWin->borderWidth;
+ }
+
+ if (valuemask)
+ XConfigureWindow(xnestDisplay, xnestWindow(pWin), valuemask, &values);
+
+ if (mask & CWStackingOrder &&
+ xnestWindowPriv(pWin)->sibling_above != xnestWindowSiblingAbove(pWin)) {
+ WindowPtr pSib;
+
+ /* find the top sibling */
+ for (pSib = pWin; pSib->prevSib != NullWindow; pSib = pSib->prevSib);
+
+ /* the top sibling */
+ valuemask = CWStackMode;
+ values.stack_mode = Above;
+ XConfigureWindow(xnestDisplay, xnestWindow(pSib), valuemask, &values);
+ xnestWindowPriv(pSib)->sibling_above = None;
+
+ /* the rest of siblings */
+ for (pSib = pSib->nextSib; pSib != NullWindow; pSib = pSib->nextSib) {
+ valuemask = CWSibling | CWStackMode;
+ values.sibling = xnestWindowSiblingAbove(pSib);
+ values.stack_mode = Below;
+ XConfigureWindow(xnestDisplay, xnestWindow(pSib), valuemask, &values);
+ xnestWindowPriv(pSib)->sibling_above = xnestWindowSiblingAbove(pSib);
+ }
+ }
+}
+
+Bool
+xnestChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
+{
+ XSetWindowAttributes attributes;
+
+ if (mask & CWBackPixmap)
+ switch (pWin->backgroundState) {
+ case None:
+ attributes.background_pixmap = None;
+ break;
+
+ case ParentRelative:
+ attributes.background_pixmap = ParentRelative;
+ break;
+
+ case BackgroundPixmap:
+ attributes.background_pixmap = xnestPixmap(pWin->background.pixmap);
+ break;
+
+ case BackgroundPixel:
+ mask &= ~CWBackPixmap;
+ break;
+ }
+
+ if (mask & CWBackPixel) {
+ if (pWin->backgroundState == BackgroundPixel)
+ attributes.background_pixel = xnestPixel(pWin->background.pixel);
+ else
+ mask &= ~CWBackPixel;
+ }
+
+ if (mask & CWBorderPixmap) {
+ if (pWin->borderIsPixel)
+ mask &= ~CWBorderPixmap;
+ else
+ attributes.border_pixmap = xnestPixmap(pWin->border.pixmap);
+ }
+
+ if (mask & CWBorderPixel) {
+ if (pWin->borderIsPixel)
+ attributes.border_pixel = xnestPixel(pWin->border.pixel);
+ else
+ mask &= ~CWBorderPixel;
+ }
+
+ if (mask & CWBitGravity)
+ attributes.bit_gravity = pWin->bitGravity;
+
+ if (mask & CWWinGravity) /* dix does this for us */
+ mask &= ~CWWinGravity;
+
+ if (mask & CWBackingStore) /* this is really not useful */
+ mask &= ~CWBackingStore;
+
+ if (mask & CWBackingPlanes) /* this is really not useful */
+ mask &= ~CWBackingPlanes;
+
+ if (mask & CWBackingPixel) /* this is really not useful */
+ mask &= ~CWBackingPixel;
+
+ if (mask & CWOverrideRedirect)
+ attributes.override_redirect = pWin->overrideRedirect;
+
+ if (mask & CWSaveUnder) /* this is really not useful */
+ mask &= ~CWSaveUnder;
+
+ if (mask & CWEventMask) /* events are handled elsewhere */
+ mask &= ~CWEventMask;
+
+ if (mask & CWDontPropagate) /* events are handled elsewhere */
+ mask &= ~CWDontPropagate;
+
+ if (mask & CWColormap) {
+ ColormapPtr pCmap;
+
+ pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin), RT_COLORMAP);
+
+ attributes.colormap = xnestColormap(pCmap);
+
+ xnestSetInstalledColormapWindows(pWin->drawable.pScreen);
+ }
+
+ if (mask & CWCursor) /* this is handeled in cursor code */
+ mask &= ~CWCursor;
+
+ if (mask)
+ XChangeWindowAttributes(xnestDisplay, xnestWindow(pWin),
+ mask, &attributes);
+
+ return True;
+}
+
+Bool
+xnestRealizeWindow(WindowPtr pWin)
+{
+ xnestConfigureWindow(pWin, CWStackingOrder);
+#ifdef SHAPE
+ xnestShapeWindow(pWin);
+#endif /* SHAPE */
+ XMapWindow(xnestDisplay, xnestWindow(pWin));
+
+ return True;
+}
+
+Bool
+xnestUnrealizeWindow(WindowPtr pWin)
+{
+ XUnmapWindow(xnestDisplay, xnestWindow(pWin));
+
+ return True;
+}
+
+void
+xnestPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ int i;
+ BoxPtr pBox;
+
+ xnestConfigureWindow(pWin, CWWidth | CWHeight);
+
+ pBox = REGION_RECTS(pRegion);
+ for (i = 0; i < REGION_NUM_RECTS(pRegion); i++)
+ XClearArea(xnestDisplay, xnestWindow(pWin),
+ pBox[i].x1 - pWin->drawable.x,
+ pBox[i].y1 - pWin->drawable.y,
+ pBox[i].x2 - pBox[i].x1,
+ pBox[i].y2 - pBox[i].y1,
+ False);
+}
+
+void
+xnestPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ xnestConfigureWindow(pWin, CWBorderWidth);
+}
+
+void
+xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion)
+{
+}
+
+void
+xnestClipNotify(WindowPtr pWin, int dx, int dy)
+{
+ xnestConfigureWindow(pWin, CWStackingOrder);
+#ifdef SHAPE
+ xnestShapeWindow(pWin);
+#endif /* SHAPE */
+}
+
+static Bool
+xnestWindowExposurePredicate(Display *display, XEvent *event, XPointer ptr)
+{
+ return (event->type == Expose && event->xexpose.window == *(Window *)ptr);
+}
+
+void
+xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_exposed)
+{
+ XEvent event;
+ Window window;
+ BoxRec Box;
+
+ XSync(xnestDisplay, False);
+
+ window = xnestWindow(pWin);
+
+ while (XCheckIfEvent(xnestDisplay, &event,
+ xnestWindowExposurePredicate, (char *)&window)) {
+
+ Box.x1 = pWin->drawable.x + wBorderWidth(pWin) + event.xexpose.x;
+ Box.y1 = pWin->drawable.y + wBorderWidth(pWin) + event.xexpose.y;
+ Box.x2 = Box.x1 + event.xexpose.width;
+ Box.y2 = Box.y1 + event.xexpose.height;
+
+ event.xexpose.type = ProcessedExpose;
+
+ if (RECT_IN_REGION(pWin->drawable.pScreen, pRgn, &Box) != rgnIN)
+ XPutBackEvent(xnestDisplay, &event);
+ }
+
+ miWindowExposures(pWin, pRgn, other_exposed);
+}
+
+#ifdef SHAPE
+void
+xnestSetShape(WindowPtr pWin)
+{
+ xnestShapeWindow(pWin);
+ miSetShape(pWin);
+}
+
+static Bool
+xnestRegionEqual(RegionPtr pReg1, RegionPtr pReg2)
+{
+ BoxPtr pBox1, pBox2;
+ unsigned int n1, n2;
+
+ if (pReg1 == pReg2) return True;
+
+ if (pReg1 == NullRegion || pReg2 == NullRegion) return False;
+
+ pBox1 = REGION_RECTS(pReg1);
+ n1 = REGION_NUM_RECTS(pReg1);
+
+ pBox2 = REGION_RECTS(pReg2);
+ n2 = REGION_NUM_RECTS(pReg2);
+
+ if (n1 != n2) return False;
+
+ if (pBox1 == pBox2) return True;
+
+ if (memcmp(pBox1, pBox2, n1 * sizeof(BoxRec))) return False;
+
+ return True;
+}
+
+void
+xnestShapeWindow(WindowPtr pWin)
+{
+ Region reg;
+ BoxPtr pBox;
+ XRectangle rect;
+ int i;
+
+ if (!xnestRegionEqual(xnestWindowPriv(pWin)->bounding_shape,
+ wBoundingShape(pWin))) {
+
+ if (wBoundingShape(pWin)) {
+ REGION_COPY(pWin->drawable.pScreen,
+ xnestWindowPriv(pWin)->bounding_shape, wBoundingShape(pWin));
+
+ reg = XCreateRegion();
+ pBox = REGION_RECTS(xnestWindowPriv(pWin)->bounding_shape);
+ for (i = 0;
+ i < REGION_NUM_RECTS(xnestWindowPriv(pWin)->bounding_shape);
+ i++) {
+ rect.x = pBox[i].x1;
+ rect.y = pBox[i].y1;
+ rect.width = pBox[i].x2 - pBox[i].x1;
+ rect.height = pBox[i].y2 - pBox[i].y1;
+ XUnionRectWithRegion(&rect, reg, reg);
+ }
+ XShapeCombineRegion(xnestDisplay, xnestWindow(pWin),
+ ShapeBounding, 0, 0, reg, ShapeSet);
+ XDestroyRegion(reg);
+ }
+ else {
+ REGION_EMPTY(pWin->drawable.pScreen,
+ xnestWindowPriv(pWin)->bounding_shape);
+
+ XShapeCombineMask(xnestDisplay, xnestWindow(pWin),
+ ShapeBounding, 0, 0, None, ShapeSet);
+ }
+ }
+
+ if (!xnestRegionEqual(xnestWindowPriv(pWin)->clip_shape,
+ wClipShape(pWin))) {
+
+ if (wClipShape(pWin)) {
+ REGION_COPY(pWin->drawable.pScreen,
+ xnestWindowPriv(pWin)->clip_shape, wClipShape(pWin));
+
+ reg = XCreateRegion();
+ pBox = REGION_RECTS(xnestWindowPriv(pWin)->clip_shape);
+ for (i = 0;
+ i < REGION_NUM_RECTS(xnestWindowPriv(pWin)->clip_shape);
+ i++) {
+ rect.x = pBox[i].x1;
+ rect.y = pBox[i].y1;
+ rect.width = pBox[i].x2 - pBox[i].x1;
+ rect.height = pBox[i].y2 - pBox[i].y1;
+ XUnionRectWithRegion(&rect, reg, reg);
+ }
+ XShapeCombineRegion(xnestDisplay, xnestWindow(pWin),
+ ShapeClip, 0, 0, reg, ShapeSet);
+ XDestroyRegion(reg);
+ }
+ else {
+ REGION_EMPTY(pWin->drawable.pScreen,
+ xnestWindowPriv(pWin)->clip_shape);
+
+ XShapeCombineMask(xnestDisplay, xnestWindow(pWin),
+ ShapeClip, 0, 0, None, ShapeSet);
+ }
+ }
+}
+#endif /* SHAPE */
diff --git a/nx-X11/programs/Xserver/hw/xnest/XNCursor.h b/nx-X11/programs/Xserver/hw/xnest/XNCursor.h
new file mode 100644
index 000000000..8684a5e7f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/XNCursor.h
@@ -0,0 +1,35 @@
+/* $Xorg: Cursor.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/XNCursor.h,v 1.2 2002/11/23 19:27:50 tsi Exp $ */
+
+#ifndef XNESTCURSOR_H
+#define XNESTCURSOR_H
+
+typedef struct {
+ Cursor cursor;
+} xnestPrivCursor;
+
+#define xnestCursorPriv(pCursor, pScreen) \
+ ((xnestPrivCursor *)((pCursor)->devPriv[pScreen->myNum]))
+
+#define xnestCursor(pCursor, pScreen) \
+ (xnestCursorPriv(pCursor, pScreen)->cursor)
+
+Bool xnestRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
+Bool xnestUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
+void xnestSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y);
+void xnestMoveCursor (ScreenPtr pScreen, int x, int y);
+
+#endif /* XNESTCURSOR_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/XNFont.h b/nx-X11/programs/Xserver/hw/xnest/XNFont.h
new file mode 100644
index 000000000..7fb4017bd
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/XNFont.h
@@ -0,0 +1,37 @@
+/* $Xorg: XNFont.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+
+#ifndef XNESTFONT_H
+#define XNESTFONT_H
+
+typedef struct {
+ XFontStruct *font_struct;
+} xnestPrivFont;
+
+extern int xnestFontPrivateIndex;
+
+#define xnestFontPriv(pFont) \
+ ((xnestPrivFont *)FontGetPrivate(pFont, xnestFontPrivateIndex))
+
+#define xnestFontStruct(pFont) (xnestFontPriv(pFont)->font_struct)
+
+#define xnestFont(pFont) (xnestFontStruct(pFont)->fid)
+
+Bool xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont);
+Bool xnestUnrealizeFont(ScreenPtr pScreen, FontPtr pFont);
+
+#endif /* XNESTFONT_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/XNGC.h b/nx-X11/programs/Xserver/hw/xnest/XNGC.h
new file mode 100644
index 000000000..56939cceb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/XNGC.h
@@ -0,0 +1,44 @@
+/* $Xorg: XNGC.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+#ifndef XNESTGC_H
+#define XNESTGC_H
+
+/* This file uses the GC definition form Xlib.h as XlibGC. */
+
+typedef struct {
+ XlibGC gc;
+ int nClipRects;
+} xnestPrivGC;
+
+extern int xnestGCPrivateIndex;
+
+#define xnestGCPriv(pGC) \
+ ((xnestPrivGC *)((pGC)->devPrivates[xnestGCPrivateIndex].ptr))
+
+#define xnestGC(pGC) (xnestGCPriv(pGC)->gc)
+
+Bool xnestCreateGC(GCPtr pGC);
+void xnestValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable);
+void xnestChangeGC(GCPtr pGC, unsigned long mask);
+void xnestCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
+void xnestDestroyGC(GCPtr pGC);
+void xnestChangeClip(GCPtr pGC, int type, pointer pValue, int nRects);
+void xnestDestroyClip(GCPtr pGC);
+void xnestDestroyClipHelper(GCPtr pGC);
+void xnestCopyClip(GCPtr pGCDst, GCPtr pGCSrc);
+
+#endif /* XNESTGC_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/XNPixmap.h b/nx-X11/programs/Xserver/hw/xnest/XNPixmap.h
new file mode 100644
index 000000000..fab1843d1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/XNPixmap.h
@@ -0,0 +1,45 @@
+/* $Xorg: Pixmap.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/XNPixmap.h,v 1.3 2003/01/10 13:29:40 eich Exp $ */
+
+#ifndef XNESTPIXMAP_H
+#define XNESTPIXMAP_H
+
+#ifdef PIXPRIV
+extern int xnestPixmapPrivateIndex;
+#endif
+
+typedef struct {
+ Pixmap pixmap;
+} xnestPrivPixmap;
+
+#ifdef PIXPRIV
+#define xnestPixmapPriv(pPixmap) \
+ ((xnestPrivPixmap *)((pPixmap)->devPrivates[xnestPixmapPrivateIndex].ptr))
+#else
+#define xnestPixmapPriv(pPixmap) \
+ ((xnestPrivPixmap *)((pPixmap)->devPrivate.ptr))
+#endif
+
+#define xnestPixmap(pPixmap) (xnestPixmapPriv(pPixmap)->pixmap)
+
+#define xnestSharePixmap(pPixmap) ((pPixmap)->refcnt++)
+
+PixmapPtr xnestCreatePixmap(ScreenPtr pScreen, int width, int height,
+ int depth);
+Bool xnestDestroyPixmap(PixmapPtr pPixmap);
+RegionPtr xnestPixmapToRegion(PixmapPtr pPixmap);
+
+#endif /* XNESTPIXMAP_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/XNWindow.h b/nx-X11/programs/Xserver/hw/xnest/XNWindow.h
new file mode 100644
index 000000000..3a57646a7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/XNWindow.h
@@ -0,0 +1,80 @@
+/* $Xorg: XNWindow.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright 1993 by Davor Matic
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xnest/XNWindow.h,v 1.3 2003/11/03 05:36:34 tsi Exp $ */
+
+#ifndef XNESTWINDOW_H
+#define XNESTWINDOW_H
+
+typedef struct {
+ Window window;
+ Window parent;
+ int x;
+ int y;
+ unsigned int width;
+ unsigned int height;
+ unsigned int border_width;
+ Window sibling_above;
+#ifdef SHAPE
+ RegionPtr bounding_shape;
+ RegionPtr clip_shape;
+#endif /* SHAPE */
+} xnestPrivWin;
+
+typedef struct {
+ WindowPtr pWin;
+ Window window;
+} xnestWindowMatch;
+
+extern int xnestWindowPrivateIndex;
+
+#define xnestWindowPriv(pWin) \
+ ((xnestPrivWin *)((pWin)->devPrivates[xnestWindowPrivateIndex].ptr))
+
+#define xnestWindow(pWin) (xnestWindowPriv(pWin)->window)
+
+#define xnestWindowParent(pWin) \
+ ((pWin)->parent ? \
+ xnestWindow((pWin)->parent) : \
+ xnestDefaultWindows[pWin->drawable.pScreen->myNum])
+
+#define xnestWindowSiblingAbove(pWin) \
+ ((pWin)->prevSib ? xnestWindow((pWin)->prevSib) : None)
+
+#define xnestWindowSiblingBelow(pWin) \
+ ((pWin)->nextSib ? xnestWindow((pWin)->nextSib) : None)
+
+#define CWParent CWSibling
+#define CWStackingOrder CWStackMode
+
+WindowPtr xnestWindowPtr(Window window);
+Bool xnestCreateWindow(WindowPtr pWin);
+Bool xnestDestroyWindow(WindowPtr pWin);
+Bool xnestPositionWindow(WindowPtr pWin, int x, int y);
+void xnestConfigureWindow(WindowPtr pWin, unsigned int mask);
+Bool xnestChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
+Bool xnestRealizeWindow(WindowPtr pWin);
+Bool xnestUnrealizeWindow(WindowPtr pWin);
+void xnestPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what);
+void xnestPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion, int what);
+void xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion);
+void xnestClipNotify(WindowPtr pWin, int dx, int dy);
+void xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn,
+ RegionPtr other_exposed);
+#ifdef SHAPE
+void xnestSetShape(WindowPtr pWin);
+void xnestShapeWindow(WindowPtr pWin);
+#endif /* SHAPE */
+
+#endif /* XNESTWINDOW_H */
diff --git a/nx-X11/programs/Xserver/hw/xnest/Xnest.h b/nx-X11/programs/Xserver/hw/xnest/Xnest.h
new file mode 100644
index 000000000..ade73833f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Xnest.h
@@ -0,0 +1,96 @@
+/* $Xorg: Xnest.h,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+Copyright (c) 1995 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the X Consortium.
+
+*/
+/* $XFree86$ */
+
+/*
+** Machines with a 64 bit library interface and a 32 bit server require
+** name changes to protect the guilty.
+*/
+#ifdef _XSERVER64
+#define _XSERVER64_tmp
+#undef _XSERVER64
+typedef unsigned long XID64;
+typedef unsigned long Mask64;
+typedef unsigned long Atom64;
+typedef unsigned long VisualID64;
+typedef unsigned long Time64;
+#define XID XID64
+#define Mask Mask64
+#define Atom Atom64
+#define VisualID VisualID64
+#define Time Time64
+typedef XID Window64;
+typedef XID Drawable64;
+typedef XID Font64;
+typedef XID Pixmap64;
+typedef XID Cursor64;
+typedef XID Colormap64;
+typedef XID GContext64;
+typedef XID KeySym64;
+#define Window Window64
+#define Drawable Drawable64
+#define Font Font64
+#define Pixmap Pixmap64
+#define Cursor Cursor64
+#define Colormap Colormap64
+#define GContext GContext64
+#define KeySym KeySym64
+#endif /*_XSERVER64*/
+
+#define GC XlibGC
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/shape.h>
+#undef GC
+
+#ifdef _XSERVER64_tmp
+#define _XSERVER64
+#undef _XSERVER64_tmp
+#undef XID
+#undef Mask
+#undef Atom
+#undef VisualID
+#undef Time
+#undef Window
+#undef Drawable
+#undef Font
+#undef Pixmap
+#undef Cursor
+#undef Colormap
+#undef GContext
+#undef KeySym
+#endif /*_XSERVER64_tmp*/
+
+
+
+
+
+
diff --git a/nx-X11/programs/Xserver/hw/xnest/Xnest.man b/nx-X11/programs/Xserver/hw/xnest/Xnest.man
new file mode 100644
index 000000000..131c224f2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/Xnest.man
@@ -0,0 +1,264 @@
+.\" $Xorg: Xnest.man,v 1.3 2000/08/17 19:53:28 cpqbld Exp $
+.\" Copyright (c) 1993, 1994 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" $XFree86: xc/programs/Xserver/hw/xnest/Xnest.man,v 1.6 2001/01/27 18:21:00 dawes Exp $
+.\"
+.TH XNEST 1 __xorgversion__
+.SH NAME
+Xnest \- a nested X server
+.SH SYNOPSIS
+.B Xnest
+[-options]
+.SH DESCRIPTION
+\fIXnest\fP is a client and a server. \fIXnest\fP is a client of the
+real server which manages windows and graphics requests on its behalf.
+\fIXnest\fP is a server to its own clients. \fIXnest\fP manages
+windows and graphics requests on their behalf. To these clients
+\fIXnest\fP appears to be a conventional server.
+.SH OPTIONS
+\fIXnest\fP supports all standard options of the sample server
+implementation. For more details, please see the manual page on your
+system for \fIXserver\fP. The following additional arguments are
+supported as well.
+.TP 4
+.B \-display \fIstring\fP
+This option specifies the display name of the real server that
+\fIXnest\fP should try to connect with. If it is not provided on the
+command line \fIXnest\fP will read the \fIDISPLAY\fP environment
+variable in order to find out the same information.
+.TP 4
+.B \-sync
+This option tells \fIXnest\fP to synchronize its window and graphics
+operations with the real server. This is a useful option for
+debugging, but it will slow down the performance considerably. It
+should not be used unless absolutely necessary.
+.TP 4
+.B \-full
+This option tells \fIXnest\fP to utilize full regeneration of real
+server objects and reopen a new connection to the real server each
+time the nested server regenerates. The sample server implementation
+regenerates all objects in the server when the last client of this
+server terminates. When this happens, \fIXnest\fP by default
+maintains the same top level window and the same real server
+connection in each new generation. If the user selects full
+regeneration, even the top level window and the connection to the real
+server will be regenerated for each server generation.
+.TP 4
+.B \-class \fIstring\fP
+This option specifies the default visual class of the nested server.
+It is similar to the \fI-cc\fP option from the set of standard options
+except that it will accept a string rather than a number for the
+visual class specification. The string must be one of the following
+six values: \fIStaticGray\fP, \fIGrayScale\fP, \fIStaticColor\fP,
+\fIPseudoColor\fP, \fITrueColor\fP, or \fIDirectColor\fP. If both,
+\fI-class\fP and \fI-cc\fP options are specified, the last instance of
+either option assumes precedence. The class of the default visual of
+the nested server need not be the same as the class of the default
+visual of the real server; although, it has to be supported by the
+real server. See \fIxdpyinfo\fP for a list of supported visual
+classes on the real server before starting \fIXnest\fP. If the user
+chooses a static class, all the colors in the default colormap will be
+preallocated. If the user chooses a dynamic class, colors in the
+default colormap will be available to individual clients for
+allocation.
+.TP 4
+.B \-depth \fIint\fP
+This option specifies the default visual depth of the nested server.
+The depth of the default visual of the nested server need not be the
+same as the depth of the default visual of the real server; although,
+it has to be supported by the real server. See \fIxdpyinfo\fP for a
+list of supported visual depths on the real server before starting
+\fIXnest\fP.
+.TP 4
+.B \-sss
+This option tells \fIXnest\fP to use the software screen saver. By
+default \fIXnest\fP will use the screen saver that corresponds to the
+hardware screen saver in the real server. Of course, even this screen
+saver is software generated since \fIXnest\fP does not control any
+actual hardware. However, it is treated as a hardware screen saver
+within the sample server code.
+.TP 4
+.B \-geometry \fIWxH+X+Y\fP
+This option specifies geometry parameters for the top level
+\fIXnest\fP windows. These windows corresponds to the root windows of
+the nested server. The width and height specified with this option
+will be the maximum width and height of each top level \fIXnest\fP
+window. \fIXnest\fP will allow the user to make any top level window
+smaller, but it will not actually change the size of the nested server
+root window. As of yet, there is no mechanism within the sample
+server implementation to change the size of the root window after
+screen initialization. In order to do so, one would probably need to
+extend the X protocol. Therefore, it is not likely that this will be
+available any time soon. If this option is not specified \fIXnest\fP
+will choose width and height to be 3/4 of the dimensions of the root
+window of the real server.
+.TP 4
+.B \-bw \fIint\fP
+This option specifies the border width of the top level \fIXnest\fP
+window. The integer parameter must be a positive number. The default
+border width is 1.
+.TP 4
+.B \-name \fIstring\fP
+This option specifies the name of the top level \fIXnest\fP window.
+The default value is the program name.
+.TP 4
+.B \-scrns \fIint\fP
+This option specifies the number of screens to create in the nested
+server. For each screen, \fIXnest\fP will create a separate top level
+window. Each screen is referenced by the number after the dot in the
+client display name specification. For example, \fIxterm -display
+:1.1\fP will open an \fIxterm\fP client in the nested server with the
+display number \fI:1\fP on the second screen. The number of screens
+is limited by the hard coded constant in the server sample code which
+is usually 3.
+.TP 4
+.B \-install
+This option tells \fIXnest\fP to do its own colormap installation by
+bypassing the real window manager. For it to work properly the user
+will probably have to temporarily quit the real window manager. By
+default \fIXnest\fP will keep the nested client window whose colormap
+should be installed in the real server in the
+\fIWM\_COLORMAP\_WINDOWS\fP property of the top level \fIXnest\fP
+window. If this colormap is of the same visual type as the root
+window of the nested server, \fIXnest\fP will associate this colormap
+with the top level \fIXnest\fP window as well. Since this does not
+have to be the case, window managers should look primarily at the
+\fIWM\_COLORMAP\_WINDOWS\fP property rather than the colormap
+associated with the top level \fIXnest\fP window. Unfortunately,
+window managers are not very good at doing that yet so this option
+might come in handy.
+.TP 4
+.B \-parent \fIwindow_id\fP
+This option tells \fIXnest\fP to use the \fIwindow_id\fP as the
+root window instead of creating a window. This option is used
+by the xrx xnestplugin.
+.SH USAGE
+Starting up \fIXnest\fP is as simple as starting up \fIxclock\fP from
+a terminal emulator. If a user wishes to run \fIXnest\fP on the same
+workstation as the real server, it is important that the nested server
+is given its own listening socket address. Therefore, if there is a
+server already running on the user's workstation, \fIXnest\fP will
+have to be started up with a new display number. Since there is
+usually no more than one server running on a workstation, specifying
+\fIXnest :1\fP on the command line will be sufficient for most users.
+For each server running on the workstation the display number needs to
+be incremented by one. Thus, if you wish to start another
+\fIXnest\fP, you will need to type \fIXnest :2\fP on the command line.
+.PP
+To run clients in the nested server each client needs to be given the
+same display number as the nested server. For example, \fIxterm
+-display :1\fP will start up an \fIxterm\fP in the first nested server
+and \fIxterm -display :2\fP will start an \fIxterm\fP in the second
+nested server from the example above. Additional clients can be
+started from these \fIxterm\fPs in each nested server.
+.SH XNEST AS A CLIENT
+\fIXnest\fP behaves and looks to the real server and other real
+clients as another real client. It is a rather demanding client,
+however, since almost any window or graphics request from a nested
+client will result in a window or graphics request from \fIXnest\fP to
+the real server. Therefore, it is desirable that \fIXnest\fP and the
+real server are on a local network, or even better, on the same
+machine. As of now, \fIXnest\fP assumes that the real server supports
+the shape extension. There is no way to turn off this assumption
+dynamically. \fIXnest\fP can be compiled without the shape extension
+built in, and in that case the real server need not support it. The
+dynamic shape extension selection support should be considered in
+further development of \fIXnest\fP.
+.PP
+Since \fIXnest\fP need not use the same default visual as the the real
+server, the top level window of the \fIXnest\fP client always has its
+own colormap. This implies that other windows' colors will not be
+displayed properly while the keyboard or pointer focus is in the
+\fIXnest\fP window, unless the real server has support for more than
+one installed colormap at any time. The colormap associated with the
+top window of the \fIXnest\fP client need not be the appropriate
+colormap that the nested server wants installed in the real server.
+In the case that a nested client attempts to install a colormap of a
+different visual from the default visual of the nested server,
+\fIXnest\fP will put the top window of this nested client and all
+other top windows of the nested clients that use the same colormap
+into the \fIWM\_COLORMAP\_WINDOWS\fP property of the top level
+\fIXnest\fP window on the real server. Thus, it is important that the
+real window manager that manages the \fIXnest\fP top level window
+looks at the \fIWM\_COLORMAP\_WINDOWS\fP property rather than the
+colormap associated with the top level \fIXnest\fP window. Since most
+window managers appear to not implement this convention properly as of
+yet, \fIXnest\fP can optionally do direct installation of colormaps
+into the real server bypassing the real window manager. If the user
+chooses this option, it is usually necessary to temporarily disable
+the real window manager since it will interfere with the \fIXnest\fP
+scheme of colormap installation.
+.PP
+Keyboard and pointer control procedures of the nested server change
+the keyboard and pointer control parameters of the real server.
+Therefore, after \fIXnest\fP is started up, it will change the
+keyboard and pointer controls of the real server to its own internal
+defaults. Perhaps there should be a command line option to tell
+\fIXnest\fP to inherit the keyboard and pointer control parameters
+from the real server rather than imposing its own. This is a future
+consideration.
+.SH XNEST AS A SERVER
+\fIXnest\fP as a server looks exactly like a real server to its own
+clients. For the clients there is no way of telling if they are
+running on a real or a nested server.
+.PP
+As already mentioned, \fIXnest\fP is a very user friendly server when
+it comes to customization. \fIXnest\fP will pick up a number of
+command line arguments that can configure its default visual class and
+depth, number of screens, etc. In the future, \fIXnest\fP should read
+a customization input file to provide even greater freedom and
+simplicity in selecting the desired layout. Unfortunately, there is
+no support for backing store and save under as of yet, but this should
+also be considered in the future development of \fIXnest\fP.
+.PP
+The only apparent intricacy from the users' perspective about using
+\fIXnest\fP as a server is the selection of fonts. \fIXnest\fP
+manages fonts by loading them locally and then passing the font name
+to the real server and asking it to load that font remotely. This
+approach avoids the overload of sending the glyph bits across the
+network for every text operation, although it is really a bug. The
+proper implementation of fonts should be moved into the \fIos\fP
+layer. The consequence of this approach is that the user will have to
+worry about two different font paths - a local one for the nested
+server and a remote one for the real server - since \fIXnest\fP does
+not propagate its font path to the real server. The reason for this
+is because real and nested servers need not run on the same file
+system which makes the two font paths mutually incompatible. Thus, if
+there is a font in the local font path of the nested server, there is
+no guarantee that this font exists in the remote font path of the real
+server. \fIXlsfonts\fP client, if run on the nested server will list
+fonts in the local font path and if run on the real server will list
+fonts in the remote font path. Before a font can be successfully
+opened by the nested server it has to exist in local and remote font
+paths. It is the users' responsibility to make sure that this is the
+case.
+.SH BUGS
+Won't run well on servers supporting different visual depths.
+Still crashes randomly. Probably has some memory leaks.
+.SH AUTHOR
+Davor Matic, MIT X Consortium
+
diff --git a/nx-X11/programs/Xserver/hw/xnest/icon b/nx-X11/programs/Xserver/hw/xnest/icon
new file mode 100644
index 000000000..725f1131a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/icon
@@ -0,0 +1,14 @@
+#define icon_width 32
+#define icon_height 32
+static unsigned char icon_bits[] = {
+ 0xff, 0x00, 0x00, 0xc0, 0xfe, 0x01, 0x00, 0xc0, 0xfc, 0x03, 0x00, 0x60,
+ 0xf8, 0x07, 0x00, 0x30, 0xf8, 0x07, 0x00, 0x18, 0xf0, 0x0f, 0x00, 0x0c,
+ 0xe0, 0x1f, 0x00, 0x06, 0xc0, 0x3f, 0x00, 0x06, 0xc0, 0x3f, 0x00, 0x03,
+ 0x80, 0x7f, 0x80, 0x01, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfe, 0x61, 0x00,
+ 0x00, 0xfe, 0x31, 0x00, 0x00, 0xfc, 0x33, 0x00, 0x00, 0xf8, 0x1b, 0x00,
+ 0x00, 0xf0, 0x0d, 0x00, 0x00, 0xf0, 0x0e, 0x00, 0x00, 0x60, 0x1f, 0x00,
+ 0x00, 0xb0, 0x3f, 0x00, 0x00, 0x98, 0x7f, 0x00, 0x00, 0x98, 0x7f, 0x00,
+ 0x00, 0x0c, 0xff, 0x00, 0x00, 0x06, 0xfe, 0x01, 0x00, 0x03, 0xfc, 0x03,
+ 0x80, 0x01, 0xfc, 0x03, 0xc0, 0x00, 0xf8, 0x07, 0xc0, 0x00, 0xf0, 0x0f,
+ 0x60, 0x00, 0xe0, 0x1f, 0x30, 0x00, 0xe0, 0x1f, 0x18, 0x00, 0xc0, 0x3f,
+ 0x0c, 0x00, 0x80, 0x7f, 0x06, 0x00, 0x00, 0xff};
diff --git a/nx-X11/programs/Xserver/hw/xnest/os2Stub.c b/nx-X11/programs/Xserver/hw/xnest/os2Stub.c
new file mode 100644
index 000000000..0868b4480
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/os2Stub.c
@@ -0,0 +1,388 @@
+/*
+ * (c) Copyright 1996 by Sebastien Marineau
+ * <marineau@genie.uottawa.ca>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HOLGER VEIT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Sebastien Marineau shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Sebastien Marineau.
+ *
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xnest/os2Stub.c,v 3.1 2002/05/31 18:46:04 dawes Exp $ */
+
+/* This below implements select() for calls in xnest. It has been */
+/* somewhat optimized for improved performance, but assumes a few */
+/* things so it cannot be used as a general select. */
+
+#define I_NEED_OS2_H
+#include <X11/Xpoll.h>
+#include <stdio.h>
+#include <sys/select.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#define INCL_DOSSEMAPHORES
+#define INCL_DOSNPIPES
+#define INCL_DOSMISC
+#define INCL_DOSMODULEMGR
+#undef BOOL
+#undef BYTE
+#include <os2.h>
+
+HEV hPipeSem;
+HMODULE hmod_so32dll;
+static int (*os2_tcp_select)(int*,int,int,int,long);
+ULONG os2_get_sys_millis();
+extern int _files[];
+
+#define MAX_TCP 256
+/* These lifted from sys/emx.h. Change if that changes there! */
+#define F_SOCKET 0x10000000
+#define F_PIPE 0x20000000
+
+struct select_data
+{
+ fd_set read_copy;
+ fd_set write_copy;
+ BOOL have_read;
+ BOOL have_write;
+ int tcp_select_mask[MAX_TCP];
+ int tcp_emx_handles[MAX_TCP];
+ int tcp_select_copy[MAX_TCP];
+ int socket_nread;
+ int socket_nwrite;
+ int socket_ntotal;
+ int pipe_ntotal;
+ int pipe_have_write;
+ int max_fds;
+};
+
+int os2PseudoSelect(int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout)
+{
+static BOOL FirstTime=TRUE;
+static haveTCPIP=TRUE;
+ULONG timeout_ms;
+ULONG postCount, start_millis,now_millis;
+char faildata[16];
+struct select_data sd;
+BOOL any_ready;
+int np,ns, i,ready_handles,n;
+APIRET rc;
+
+sd.have_read=FALSE; sd.have_write=FALSE;
+sd.socket_nread=0; sd.socket_nwrite=0; sd.socket_ntotal=0;
+sd.max_fds=31; ready_handles=0; any_ready=FALSE;
+sd.pipe_ntotal=0; sd.pipe_have_write=FALSE;
+
+if(FirstTime){
+ /* First load the so32dll.dll module and get a pointer to the SELECT function */
+
+ if((rc=DosLoadModule(faildata,sizeof(faildata),"SO32DLL",&hmod_so32dll))!=0){
+ fprintf(stderr, "Could not load module so32dll.dll, rc = %d. Error note %s\n",rc,faildata);
+ haveTCPIP=FALSE;
+ }
+ if((rc = DosQueryProcAddr(hmod_so32dll, 0, "SELECT", (PPFN)&os2_tcp_select))!=0){
+ fprintf(stderr, "Could not query address of SELECT, rc = %d.\n",rc);
+ haveTCPIP=FALSE;
+ }
+ /* Call these a first time to set the semaphore */
+ /* rc = DosCreateEventSem(NULL, &hPipeSem, DC_SEM_SHARED, FALSE);
+ if(rc) {
+ fprintf(stderr, "Could not create event semaphore, rc=%d\n",rc);
+ return(-1);
+ }
+ rc = DosResetEventSem(hPipeSem, &postCount); */ /* Done in xtrans code for servers*/
+
+ /*fprintf(stderr, "Client select() done first-time stuff, sem handle %d.\n",hPipeSem);*/
+
+ FirstTime = FALSE;
+}
+
+/* Set up the time delay structs */
+
+ if(timeout!=NULL) {
+ timeout_ms=timeout->tv_sec*1000+timeout->tv_usec/1000;
+ }
+ else { timeout_ms=1000000; } /* This should be large enough... */
+ if(timeout_ms>0) start_millis=os2_get_sys_millis();
+
+/* Copy the masks */
+ {FD_ZERO(&sd.read_copy);}
+ {FD_ZERO(&sd.write_copy);}
+ if(readfds!=NULL){ XFD_COPYSET(readfds,&sd.read_copy); sd.have_read=TRUE;}
+ if(writefds!=NULL) {XFD_COPYSET(writefds,&sd.write_copy);sd.have_write=TRUE;}
+
+/* And zero the original masks */
+ if(sd.have_read){ FD_ZERO(readfds);}
+ if(sd.have_write) {FD_ZERO(writefds);}
+ if(exceptfds != NULL) {FD_ZERO(exceptfds);}
+
+/* Now we parse the fd_sets passed to select and separate pipe/sockets */
+ n = os2_parse_select(&sd,nfds);
+ if(n == -1) {
+ errno = EBADF;
+ return (-1);
+ }
+
+/* Now we have three cases: either we have sockets, pipes, or both */
+/* We handle all three cases differently to optimize things */
+
+/* Case 1: only pipes! */
+ if((sd.pipe_ntotal >0) && (!sd.socket_ntotal)){
+ np = os2_check_pipes(&sd,readfds,writefds);
+ if(np > 0){
+ return (np);
+ }
+ else if (np == -1) { return(-1); }
+ while(!any_ready){
+ rc = DosWaitEventSem(hPipeSem, 1L);
+ /* if(rc) fprintf(stderr,"Sem-wait timeout, rc = %d\n",rc); */
+ if(rc == 640) {
+ return(0);
+ }
+ if((rc != 0) && (rc != 95)) {errno= EBADF; return(-1);}
+ np = os2_check_pipes(&sd,readfds,writefds);
+ if (np > 0){
+ return(np);
+ }
+ else if (np < 0){ return(-1); }
+ }
+ }
+
+/* Case 2: only sockets. Just let the os/2 tcp select do the work */
+ if((sd.socket_ntotal > 0) && (!sd.pipe_ntotal)){
+ ns = os2_check_sockets(&sd, readfds, writefds, timeout_ms);
+ return (ns);
+ }
+
+/* Case 3: combination of both */
+ if((sd.socket_ntotal > 0) && (sd.pipe_ntotal)){
+ np = os2_check_pipes(&sd,readfds,writefds);
+ if(np > 0){
+ any_ready=TRUE;
+ ready_handles += np;
+ }
+ else if (np == -1) { return(-1); }
+
+ ns = os2_check_sockets(&sd,readfds,writefds, 0);
+ if(ns>0){
+ ready_handles+=ns;
+ any_ready = TRUE;
+ }
+ else if (ns == -1) {return(-1);}
+
+ while (!any_ready && timeout_ms){
+
+ rc = DosWaitEventSem(hPipeSem, 1L);
+ if (rc==640) return(0);
+ if(rc == 0){
+ np = os2_check_pipes(&sd,readfds,writefds);
+ if(np > 0){
+ ready_handles+=np;
+ any_ready = TRUE;
+ }
+ else if (np == -1) {
+ return(-1); }
+ }
+
+ ns = os2_check_sockets(&sd,readfds,writefds,exceptfds, 0);
+ if(ns>0){
+ ready_handles+=ns;
+ any_ready = TRUE;
+ }
+ else if (ns == -1) {return(-1);}
+
+ if (i%8 == 0) {
+ now_millis = os2_get_sys_millis();
+ if((now_millis-start_millis) > timeout_ms) timeout_ms = 0;
+ }
+ i++;
+ }
+ }
+
+return(ready_handles);
+}
+
+
+ULONG os2_get_sys_millis()
+{
+ APIRET rc;
+ ULONG milli;
+
+ rc = DosQuerySysInfo(14, 14, &milli, sizeof(milli));
+ if(rc) {
+ fprintf(stderr,"Bad return code querying the millisecond counter! rc=%d\n",rc);
+ return(0);
+ }
+ return(milli);
+}
+
+int os2_parse_select(sd,nfds)
+struct select_data *sd;
+int nfds;
+{
+ int i;
+ APIRET rc;
+/* First we determine up to which descriptor we need to check. */
+/* No need to check up to 256 if we don't have to (and usually we dont...)*/
+/* Note: stuff here is hardcoded for fd_sets which are int[8] as in EMX! */
+
+ if(nfds > sd->max_fds){
+ for(i=0;i<((FD_SETSIZE+31)/32);i++){
+ if(sd->read_copy.fds_bits[i] ||
+ sd->write_copy.fds_bits[i])
+ sd->max_fds=(i*32) +32;
+ }
+ }
+ else { sd->max_fds = nfds; }
+/* Check if result is greater than specified in select() call */
+ if(sd->max_fds > nfds) sd->max_fds = nfds;
+
+ if (sd->have_read)
+ {
+ for (i = 0; i < sd->max_fds; ++i) {
+ if (FD_ISSET (i, &sd->read_copy)){
+ if(_files[i] & F_SOCKET)
+ {
+ sd->tcp_select_mask[sd->socket_ntotal]=_getsockhandle(i);
+ sd->tcp_emx_handles[sd->socket_ntotal]=i;
+ sd->socket_ntotal++; sd->socket_nread++;
+ }
+ else if (_files[i] & F_PIPE)
+ {
+ sd -> pipe_ntotal++;
+ /* rc = DosSetNPipeSem((HPIPE)i, (HSEM) hPipeSem, i);
+ if(rc) { fprintf(stderr,"Error SETNPIPE rc = %d\n",rc); return -1;} */
+ }
+ }
+ }
+ }
+
+ if (sd->have_write)
+ {
+ for (i = 0; i < sd->max_fds; ++i) {
+ if (FD_ISSET (i, &sd->write_copy)){
+ if(_files[i] & F_SOCKET)
+ {
+ sd->tcp_select_mask[sd->socket_ntotal]=_getsockhandle(i);
+ sd->tcp_emx_handles[sd->socket_ntotal]=i;
+ sd->socket_ntotal++; sd->socket_nwrite++;
+ }
+ else if (_files[i] & F_PIPE)
+ {
+ sd -> pipe_ntotal++;
+ /* rc = DosSetNPipeSem((HPIPE)i, (HSEM) hPipeSem, i);
+ if(rc) { fprintf(stderr,"Error SETNPIPE rc = %d\n",rc); return -1;} */
+ sd -> pipe_have_write=TRUE;
+ }
+ }
+ }
+ }
+
+
+return(sd->socket_ntotal);
+}
+
+
+int os2_check_sockets(sd,readfds,writefds)
+struct select_data *sd;
+fd_set *readfds,*writefds;
+{
+ int e,i;
+ int j,n;
+ memcpy(sd->tcp_select_copy,sd->tcp_select_mask,
+ sd->socket_ntotal*sizeof(int));
+
+ e = os2_tcp_select(sd->tcp_select_copy,sd->socket_nread,
+ sd->socket_nwrite, 0, 0);
+
+ if(e == 0) return(e);
+/* We have something ready? */
+ if(e>0){
+ j = 0; n = 0;
+ for (i = 0; i < sd->socket_nread; ++i, ++j)
+ if (sd->tcp_select_copy[j] != -1)
+ {
+ FD_SET (sd->tcp_emx_handles[j], readfds);
+ n ++;
+ }
+ for (i = 0; i < sd->socket_nwrite; ++i, ++j)
+ if (sd->tcp_select_copy[j] != -1)
+ {
+ FD_SET (sd->tcp_emx_handles[j], writefds);
+ n ++;
+ }
+ errno = 0;
+
+ return n;
+ }
+ if(e<0){
+ /*Error -- TODO. EBADF is a good choice for now. */
+ fprintf(stderr,"Error in server select! e=%d\n",e);
+ errno = EBADF;
+ return (-1);
+ }
+ }
+
+/* Check to see if anything is ready on pipes */
+
+int os2_check_pipes(sd,readfds,writefds)
+struct select_data *sd;
+fd_set *readfds,*writefds;
+{
+int i,e;
+ULONG ulPostCount;
+PIPESEMSTATE pipeSemState[128];
+APIRET rc;
+ e = 0;
+ rc = DosResetEventSem(hPipeSem,&ulPostCount);
+ rc = DosQueryNPipeSemState((HSEM) hPipeSem, (PPIPESEMSTATE)&pipeSemState,
+ sizeof(pipeSemState));
+ if(rc) fprintf(stderr,"SELECT: rc from QueryNPipeSem: %d\n",rc);
+ i=0;
+ while (pipeSemState[i].fStatus != 0) {
+ /*fprintf(stderr,"SELECT: sem entry, stat=%d, flag=%d, key=%d,avail=%d\n",
+ pipeSemState[i].fStatus,pipeSemState[i].fFlag,pipeSemState[i].usKey,
+ pipeSemState[i].usAvail); */
+ if((pipeSemState[i].fStatus == 1) &&
+ (FD_ISSET(pipeSemState[i].usKey,&sd->read_copy))){
+ FD_SET(pipeSemState[i].usKey,readfds);
+ e++;
+ }
+ else if((pipeSemState[i].fStatus == 2) &&
+ (FD_ISSET(pipeSemState[i].usKey,&sd->write_copy))){
+ FD_SET(pipeSemState[i].usKey,writefds);
+ e++;
+ }
+ else if( (pipeSemState[i].fStatus == 3) &&
+ ( (FD_ISSET(pipeSemState[i].usKey,&sd->read_copy)) ||
+ (FD_ISSET(pipeSemState[i].usKey,&sd->write_copy)) )){
+ errno = EBADF;
+ /* fprintf(stderr,"Pipe has closed down, fd=%d\n",pipeSemState[i].usKey); */
+ return (-1);
+ }
+ i++;
+ } /* endwhile */
+ /*fprintf(stderr,"Done listing pipe sem entries, total %d entries, total ready entries %d\n",i,e);*/
+errno = 0;
+return(e);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xnest/screensaver b/nx-X11/programs/Xserver/hw/xnest/screensaver
new file mode 100644
index 000000000..4940f2650
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xnest/screensaver
@@ -0,0 +1,686 @@
+#define screensaver_width 256
+#define screensaver_height 256
+static unsigned char screensaver_bits[] = {
+ 0xa8, 0x00, 0xa0, 0xaa, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0xa8, 0xaa, 0x02, 0x00, 0x80, 0x0a, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x00, 0x40, 0x55,
+ 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x50,
+ 0x55, 0x05, 0x00, 0x40, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x80, 0xaa, 0x2a, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x02, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xaa, 0x02, 0x00, 0xa0,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x15, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00,
+ 0x00, 0x00, 0x00, 0x50, 0x55, 0x05, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0xaa,
+ 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x00, 0xa0,
+ 0xaa, 0x0a, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x54, 0x55, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x40, 0x55, 0x15, 0x00, 0x50,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xaa, 0x2a, 0x80, 0x02, 0x80, 0xaa, 0xaa, 0x82, 0x0a, 0xa8, 0x28, 0x80,
+ 0x8a, 0x80, 0x2a, 0x80, 0x80, 0x8a, 0xa2, 0x82, 0x0a, 0xaa, 0x0a, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x2a, 0x02, 0x80, 0x82, 0x41, 0x40, 0x00, 0x50,
+ 0x55, 0x41, 0x00, 0x00, 0x04, 0x00, 0x54, 0x40, 0x10, 0x00, 0x40, 0x00,
+ 0x51, 0x55, 0x00, 0x15, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x41, 0x00, 0x10, 0x14, 0x00, 0x00, 0x00, 0xa8, 0x8a, 0x02, 0x00, 0x02,
+ 0x00, 0x20, 0xa2, 0x00, 0x80, 0x00, 0x08, 0x00, 0xaa, 0x2a, 0x00, 0x2a,
+ 0x08, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x80,
+ 0x01, 0x00, 0x01, 0x50, 0x45, 0x05, 0x00, 0x01, 0x10, 0x10, 0x40, 0x11,
+ 0x40, 0x00, 0x44, 0x00, 0x50, 0x15, 0x01, 0x15, 0x04, 0x00, 0x40, 0x00,
+ 0x05, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00, 0x50, 0x20, 0x00, 0x00, 0xa2,
+ 0xaa, 0x2a, 0x00, 0x00, 0x02, 0x00, 0xa0, 0x08, 0x00, 0x00, 0x00, 0x00,
+ 0xa2, 0xaa, 0x00, 0x0a, 0x00, 0x08, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x20,
+ 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x01, 0x40, 0x44, 0x15, 0x10, 0x01,
+ 0x10, 0x10, 0x40, 0x01, 0x40, 0x00, 0x00, 0x00, 0x54, 0x55, 0x41, 0x45,
+ 0x04, 0x00, 0x40, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x54,
+ 0x20, 0x80, 0x00, 0x82, 0xaa, 0x0a, 0x00, 0x00, 0x22, 0x00, 0x80, 0x0a,
+ 0x00, 0x00, 0x82, 0x00, 0xa0, 0x8a, 0x22, 0x02, 0x00, 0x08, 0x20, 0x00,
+ 0xa8, 0x00, 0x00, 0x20, 0x00, 0x80, 0x00, 0x2a, 0x10, 0x40, 0x00, 0x01,
+ 0x54, 0x45, 0x10, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x00, 0x01, 0x00,
+ 0x50, 0x45, 0x05, 0x41, 0x00, 0x04, 0x10, 0x00, 0x50, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x15, 0x00, 0x28, 0x00, 0xaa, 0xaa, 0x0a, 0x0a, 0x00,
+ 0x20, 0x08, 0x00, 0x20, 0x00, 0x00, 0x80, 0x00, 0xa8, 0xa2, 0x22, 0x2a,
+ 0x00, 0x00, 0x0a, 0x00, 0xa8, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x0a,
+ 0x50, 0x05, 0x00, 0x01, 0x55, 0x45, 0x00, 0x00, 0x01, 0x00, 0x00, 0x40,
+ 0x01, 0x00, 0x00, 0x00, 0x40, 0x55, 0x11, 0x00, 0x00, 0x54, 0x01, 0x00,
+ 0x44, 0x01, 0x00, 0x00, 0x05, 0x40, 0x00, 0x05, 0x00, 0x08, 0x00, 0x80,
+ 0xaa, 0xaa, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x0a, 0x00, 0x80, 0x00,
+ 0x80, 0xaa, 0x28, 0x20, 0x00, 0x00, 0x02, 0x00, 0x80, 0x02, 0x00, 0x00,
+ 0x28, 0x00, 0x80, 0x02, 0x10, 0x10, 0x00, 0x01, 0x54, 0x45, 0x01, 0x00,
+ 0x41, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x10, 0x55, 0x14, 0x00,
+ 0x00, 0x04, 0x04, 0x00, 0x40, 0x01, 0x00, 0x00, 0x40, 0x40, 0x40, 0x01,
+ 0x08, 0x00, 0x80, 0x00, 0xa8, 0xa2, 0x02, 0x80, 0x00, 0x00, 0x00, 0x00,
+ 0x20, 0xa0, 0xaa, 0x00, 0x80, 0x28, 0x0a, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x80, 0x02, 0x00, 0x00, 0x80, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x10, 0x14, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
+ 0x00, 0x40, 0x00, 0x00, 0x08, 0x20, 0x80, 0x00, 0x08, 0x08, 0x80, 0x80,
+ 0x80, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x8a, 0x8a, 0x00,
+ 0x02, 0x02, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01,
+ 0x10, 0x10, 0x00, 0x01, 0x10, 0x45, 0x55, 0x01, 0x00, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x02, 0x00, 0x08, 0x00, 0x00,
+ 0x20, 0xa2, 0xaa, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
+ 0x00, 0x80, 0x00, 0x02, 0x04, 0x00, 0x40, 0x00, 0x04, 0x04, 0x40, 0x40,
+ 0x00, 0x01, 0x00, 0x04, 0x04, 0x00, 0x00, 0x01, 0x00, 0x51, 0x45, 0x05,
+ 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x45, 0x01,
+ 0x2a, 0x80, 0xaa, 0xaa, 0x82, 0xaa, 0x2a, 0xa0, 0x02, 0x02, 0x80, 0xa8,
+ 0x00, 0x2a, 0xa0, 0x02, 0x80, 0xa2, 0x00, 0xa0, 0xa0, 0x0a, 0xa0, 0x00,
+ 0x00, 0x00, 0x80, 0x88, 0x02, 0x00, 0x08, 0x80, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x50, 0x41, 0x55, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
+ 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xa0, 0xaa, 0x0a,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x54, 0x40, 0x55, 0x15, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x54, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x2a, 0x80, 0xaa, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8,
+ 0x02, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x55, 0x55,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x05, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x00, 0x54, 0x55, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
+ 0x15, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0xa8, 0xaa,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x0a, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x50, 0x55, 0x05, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x40, 0x15, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0,
+ 0x00, 0x00, 0xa8, 0xaa, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0x2a, 0x20, 0x00, 0x00, 0x41, 0x05, 0x55, 0x54, 0x11, 0x04, 0x00, 0x14,
+ 0x40, 0x10, 0x44, 0x15, 0x15, 0x00, 0x00, 0x50, 0x01, 0x00, 0x50, 0x55,
+ 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x10, 0x50, 0x40,
+ 0x82, 0x08, 0x02, 0x08, 0x20, 0x08, 0x00, 0x22, 0xa0, 0x20, 0x88, 0x00,
+ 0x22, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0xa0, 0xaa, 0x0a, 0x00, 0x80, 0x02,
+ 0x00, 0x00, 0x00, 0x00, 0xaa, 0x08, 0x88, 0x20, 0x44, 0x10, 0x01, 0x04,
+ 0x50, 0x04, 0x00, 0x41, 0x10, 0x11, 0x44, 0x00, 0x41, 0x00, 0x00, 0x54,
+ 0x41, 0x00, 0x40, 0x55, 0x15, 0x00, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00,
+ 0x54, 0x11, 0x04, 0x11, 0x80, 0x20, 0x02, 0x08, 0xa0, 0x08, 0x00, 0x02,
+ 0x88, 0x20, 0x88, 0x00, 0x82, 0x00, 0x00, 0x2a, 0x22, 0x00, 0x80, 0xaa,
+ 0x2a, 0x00, 0x20, 0x08, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x08, 0x08, 0x20,
+ 0x40, 0x10, 0x01, 0x04, 0x50, 0x04, 0x00, 0x01, 0x04, 0x41, 0x44, 0x00,
+ 0x41, 0x00, 0x00, 0x15, 0x05, 0x14, 0x15, 0x50, 0x10, 0x05, 0x40, 0x41,
+ 0x41, 0x10, 0x45, 0x05, 0x50, 0x04, 0x04, 0x10, 0x80, 0x20, 0x02, 0x08,
+ 0xa0, 0x08, 0x00, 0x02, 0x08, 0x22, 0x82, 0x00, 0x82, 0x00, 0x00, 0x0a,
+ 0x2a, 0x22, 0x8a, 0x22, 0x22, 0x08, 0x80, 0x22, 0x22, 0x88, 0x88, 0x02,
+ 0x28, 0x02, 0x08, 0x20, 0x40, 0x10, 0x15, 0x54, 0x10, 0x05, 0x00, 0x14,
+ 0x04, 0x41, 0x44, 0x05, 0x41, 0x00, 0x00, 0x05, 0x50, 0x01, 0x41, 0x04,
+ 0x05, 0x11, 0x00, 0x05, 0x44, 0x44, 0x50, 0x00, 0x10, 0x05, 0x50, 0x10,
+ 0x80, 0x0a, 0x02, 0x08, 0x20, 0x0a, 0x00, 0x20, 0xa8, 0x82, 0x82, 0x00,
+ 0x2a, 0x00, 0x80, 0x02, 0x22, 0x02, 0x82, 0x20, 0x20, 0x08, 0x20, 0x88,
+ 0x82, 0x88, 0x8a, 0x00, 0x88, 0x0a, 0x80, 0x20, 0x40, 0x04, 0x01, 0x04,
+ 0x10, 0x05, 0x00, 0x40, 0x04, 0x41, 0x41, 0x00, 0x11, 0x00, 0x40, 0x01,
+ 0x41, 0x41, 0x41, 0x14, 0x15, 0x11, 0x40, 0x44, 0x04, 0x44, 0x40, 0x00,
+ 0x44, 0x15, 0x00, 0x11, 0x80, 0x08, 0x02, 0x08, 0x20, 0x0a, 0x00, 0x80,
+ 0x08, 0x82, 0x82, 0x00, 0x22, 0x00, 0xa0, 0x00, 0x22, 0x22, 0x82, 0x20,
+ 0x22, 0x0a, 0x20, 0x28, 0x82, 0x82, 0x88, 0x00, 0x88, 0x2a, 0x00, 0x22,
+ 0x44, 0x10, 0x01, 0x04, 0x10, 0x04, 0x00, 0x41, 0x04, 0x01, 0x41, 0x00,
+ 0x41, 0x00, 0x50, 0x01, 0x14, 0x14, 0x01, 0x55, 0x10, 0x15, 0x40, 0x45,
+ 0x05, 0x01, 0x45, 0x00, 0x04, 0x55, 0x04, 0x11, 0x82, 0x20, 0x02, 0x08,
+ 0x20, 0x08, 0x00, 0x22, 0x08, 0x82, 0x80, 0x00, 0x82, 0x00, 0xa8, 0x00,
+ 0x00, 0x00, 0x00, 0xa0, 0xaa, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0xaa, 0x88, 0x20, 0x41, 0x10, 0x55, 0x54, 0x11, 0x04, 0x00, 0x14,
+ 0x04, 0x01, 0x41, 0x15, 0x41, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x40,
+ 0x55, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x54, 0x51, 0x40,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x80, 0xaa, 0x2a, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x00, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x54, 0x55, 0x01, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x15, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
+ 0x00, 0x54, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xaa, 0x02,
+ 0x00, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0xa8, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x55, 0x05, 0x00, 0x00, 0x00, 0x00,
+ 0x50, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x10, 0x00, 0x50, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xa0, 0xaa, 0x0a, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
+ 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x55, 0x15,
+ 0x00, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x40, 0x15, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xaa, 0x2a, 0x00, 0x00, 0x00, 0x00,
+ 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x02, 0x00, 0x80, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa,
+ 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x14, 0x40, 0x01, 0x41, 0x40, 0x01, 0x14, 0x10, 0x01, 0x00, 0x40,
+ 0x01, 0x04, 0x14, 0x14, 0x14, 0x10, 0x04, 0x00, 0xa0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0a, 0xaa, 0x00, 0x00, 0x00, 0x80, 0x82, 0xa0, 0x20, 0x82,
+ 0xa2, 0x20, 0x02, 0x22, 0x28, 0x02, 0x00, 0x08, 0x8a, 0x22, 0x08, 0x08,
+ 0x22, 0x28, 0x0a, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x44, 0x54,
+ 0x01, 0x00, 0x00, 0x40, 0x41, 0x40, 0x10, 0x04, 0x11, 0x11, 0x04, 0x41,
+ 0x10, 0x04, 0x00, 0x04, 0x04, 0x40, 0x10, 0x00, 0x41, 0x10, 0x11, 0x00,
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0xaa, 0x02, 0x00, 0x00, 0xa0,
+ 0x82, 0x80, 0x08, 0x08, 0x02, 0x08, 0x88, 0x80, 0x08, 0x08, 0x00, 0x08,
+ 0x08, 0x20, 0x20, 0x80, 0x80, 0x20, 0x00, 0x00, 0x10, 0x50, 0x14, 0x14,
+ 0x45, 0x05, 0x40, 0x05, 0x41, 0x14, 0x15, 0x50, 0x41, 0x01, 0x04, 0x00,
+ 0x01, 0x04, 0x50, 0x00, 0x11, 0x04, 0x00, 0x14, 0x00, 0x40, 0x10, 0x44,
+ 0x00, 0x11, 0x00, 0x00, 0xa0, 0x88, 0x22, 0xa2, 0x88, 0x08, 0x00, 0x2a,
+ 0x82, 0x22, 0x22, 0xa8, 0x80, 0x0a, 0x08, 0x00, 0x02, 0xa8, 0x8a, 0xaa,
+ 0x08, 0x08, 0x00, 0xa8, 0x00, 0x2a, 0x20, 0x80, 0xaa, 0x20, 0x00, 0x00,
+ 0x00, 0x05, 0x04, 0x15, 0x55, 0x04, 0x40, 0x04, 0x50, 0x54, 0x01, 0x54,
+ 0x00, 0x54, 0x04, 0x00, 0x01, 0x04, 0x40, 0x00, 0x10, 0x04, 0x00, 0x40,
+ 0x05, 0x41, 0x40, 0x40, 0x00, 0x10, 0x00, 0x00, 0x80, 0x08, 0x02, 0x82,
+ 0x80, 0x08, 0x80, 0x20, 0x02, 0x02, 0x02, 0x2a, 0x00, 0xa0, 0x08, 0x00,
+ 0x02, 0x08, 0x80, 0x00, 0x08, 0x08, 0x00, 0x00, 0x8a, 0x20, 0x20, 0x82,
+ 0x00, 0x20, 0x00, 0x00, 0x10, 0x45, 0x04, 0x11, 0x51, 0x04, 0x50, 0x44,
+ 0x44, 0x44, 0x01, 0x15, 0x00, 0x40, 0x05, 0x00, 0x01, 0x04, 0x40, 0x00,
+ 0x10, 0x04, 0x00, 0x00, 0x54, 0x40, 0x40, 0x41, 0x00, 0x10, 0x00, 0x00,
+ 0xa0, 0x28, 0x02, 0x0a, 0x8a, 0x08, 0x20, 0x0a, 0x0a, 0x28, 0x02, 0x0a,
+ 0x00, 0x80, 0x08, 0x00, 0x02, 0x08, 0x80, 0x00, 0x08, 0x08, 0x00, 0x00,
+ 0x88, 0x20, 0x80, 0x80, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x05, 0x40, 0x00, 0x11, 0x00,
+ 0x01, 0x10, 0x10, 0x01, 0x11, 0x04, 0x00, 0x04, 0x50, 0x40, 0x41, 0x01,
+ 0x01, 0x11, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa,
+ 0xaa, 0x00, 0x80, 0x02, 0x80, 0x80, 0x20, 0x02, 0x02, 0x20, 0x08, 0x82,
+ 0x08, 0x08, 0x00, 0x08, 0x88, 0x20, 0x80, 0x00, 0x82, 0x20, 0x00, 0x00,
+ 0x00, 0x40, 0x01, 0x10, 0x00, 0x00, 0x00, 0x54, 0x55, 0x01, 0x40, 0x01,
+ 0x40, 0x14, 0x40, 0x41, 0x05, 0x40, 0x01, 0x14, 0x14, 0x14, 0x00, 0x44,
+ 0x01, 0x45, 0x00, 0x00, 0x14, 0x54, 0x00, 0x00, 0x00, 0x80, 0x02, 0x08,
+ 0x00, 0x00, 0x00, 0xa8, 0xaa, 0x02, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x04, 0x00, 0x00, 0x00, 0x50,
+ 0x55, 0x05, 0x50, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0a, 0x02, 0x00, 0x00, 0x00, 0xa0, 0xaa, 0x0a, 0xa8, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x01,
+ 0x00, 0x00, 0x00, 0x50, 0x55, 0x05, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0xa0,
+ 0xaa, 0x0a, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x55, 0x15, 0x15, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0xaa, 0x2a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x55, 0x15, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0x8a, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x54, 0x45, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x02, 0x00, 0x00, 0x00, 0x00,
+ 0xa8, 0xa2, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x05, 0x50, 0x00, 0x50, 0x40, 0x45, 0x11, 0x00, 0x50,
+ 0x40, 0x41, 0x01, 0x00, 0x14, 0x00, 0x51, 0x40, 0x40, 0x00, 0x05, 0x14,
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x0a,
+ 0x88, 0x02, 0xaa, 0xa8, 0x80, 0x00, 0x00, 0xaa, 0xa8, 0xa2, 0x02, 0x00,
+ 0xa2, 0xa0, 0x22, 0xa8, 0xa0, 0xa0, 0x8a, 0x2a, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x14, 0x04, 0x01, 0x45, 0x51,
+ 0x04, 0x40, 0x00, 0x45, 0x41, 0x51, 0x01, 0x00, 0x41, 0x50, 0x54, 0x50,
+ 0x50, 0x50, 0x14, 0x14, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0a, 0x82, 0xa2, 0xa0, 0x02, 0xa0, 0x88, 0x82,
+ 0xa0, 0x88, 0x02, 0x80, 0x82, 0x28, 0x28, 0xa0, 0x20, 0x28, 0x08, 0x8a,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x45, 0x54, 0x00,
+ 0x14, 0x40, 0x41, 0x50, 0x05, 0x51, 0x10, 0x41, 0x41, 0x41, 0x01, 0x00,
+ 0x05, 0x14, 0x10, 0x50, 0x40, 0x10, 0x14, 0x54, 0x04, 0x00, 0x41, 0x55,
+ 0x04, 0x45, 0x01, 0x04, 0x20, 0x02, 0x08, 0x00, 0x2a, 0xa0, 0x00, 0xa0,
+ 0x8a, 0x20, 0xa8, 0xa2, 0xa0, 0xa0, 0x00, 0x80, 0x0a, 0x28, 0x28, 0xa0,
+ 0x20, 0x28, 0x0a, 0x2a, 0x00, 0x00, 0x22, 0x0a, 0x80, 0x88, 0x02, 0x88,
+ 0x04, 0x50, 0x01, 0x00, 0x54, 0x40, 0x01, 0x50, 0x15, 0x10, 0x14, 0x51,
+ 0x40, 0x41, 0x01, 0x00, 0x15, 0x14, 0x14, 0x40, 0x11, 0x14, 0x05, 0x14,
+ 0x00, 0x40, 0x10, 0x00, 0x15, 0x45, 0x04, 0x01, 0x00, 0x00, 0x08, 0x00,
+ 0xa8, 0xa0, 0x00, 0x28, 0x8a, 0x08, 0x0a, 0x28, 0xa0, 0xa0, 0x00, 0x00,
+ 0x2a, 0x0a, 0x28, 0xa0, 0x08, 0x8a, 0x02, 0x0a, 0x00, 0x80, 0x00, 0x08,
+ 0x80, 0x00, 0x00, 0x82, 0x44, 0x11, 0x00, 0x00, 0x50, 0x50, 0x00, 0x10,
+ 0x05, 0x40, 0x15, 0x05, 0x50, 0x50, 0x00, 0x00, 0x14, 0x14, 0x14, 0x40,
+ 0x11, 0x54, 0x00, 0x05, 0x00, 0x00, 0x11, 0x00, 0x01, 0x40, 0x04, 0x44,
+ 0x80, 0x20, 0x0a, 0x00, 0xa0, 0xa0, 0x00, 0x88, 0x82, 0xa8, 0x0a, 0x00,
+ 0xa0, 0xa0, 0x00, 0x00, 0x28, 0x0a, 0x0a, 0xa0, 0x08, 0x0a, 0x00, 0x0a,
+ 0x00, 0x00, 0x22, 0x0a, 0xa2, 0x00, 0x00, 0x88, 0x01, 0x40, 0x15, 0x00,
+ 0x50, 0x51, 0x40, 0x00, 0x01, 0x51, 0x15, 0x00, 0x50, 0x50, 0x00, 0x00,
+ 0x54, 0x14, 0x54, 0x40, 0x05, 0x14, 0x00, 0x05, 0x00, 0x40, 0x41, 0x15,
+ 0x14, 0x45, 0x04, 0x05, 0x00, 0x00, 0x00, 0x80, 0xa0, 0xa0, 0x20, 0x88,
+ 0x80, 0xaa, 0x08, 0x82, 0x28, 0x28, 0x02, 0x20, 0x28, 0x0a, 0x2a, 0xa0,
+ 0x02, 0x0a, 0x88, 0xa2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x41, 0x40, 0x11, 0x44, 0x00, 0x55, 0x14, 0x44,
+ 0x50, 0x50, 0x01, 0x40, 0x10, 0x54, 0x15, 0x40, 0x01, 0x14, 0x04, 0x45,
+ 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0x22, 0xa0, 0x0a, 0x00, 0x00, 0x0a, 0x2a, 0x20, 0x28, 0xa8, 0x00, 0xa0,
+ 0x08, 0xa8, 0x08, 0xa0, 0x00, 0xa8, 0x82, 0x82, 0x02, 0x08, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x05, 0x00,
+ 0x00, 0x54, 0x55, 0x10, 0x50, 0x50, 0x00, 0x00, 0x05, 0x50, 0x04, 0x40,
+ 0x00, 0x50, 0x40, 0x05, 0x05, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x80, 0xaa, 0x2a,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0a, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x05, 0x00, 0x40, 0x55, 0x15, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0a,
+ 0x00, 0x80, 0xaa, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x00, 0x00, 0x55, 0x55,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xa0, 0x02, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x01,
+ 0x00, 0x00, 0x54, 0x55, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0xa8, 0xaa,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x50, 0x55, 0x05, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00,
+ 0x00, 0x00, 0xa0, 0xaa, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x82, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x50, 0x55,
+ 0x05, 0x00, 0x00, 0x14, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa0, 0xaa, 0x0a, 0x00, 0x00, 0x28,
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x0a, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00,
+ 0x00, 0x00, 0x40, 0x55, 0x15, 0x00, 0x00, 0x50, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x40, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0a, 0x00, 0x00, 0x00, 0x80, 0xaa,
+ 0x2a, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x55, 0x50, 0x15,
+ 0x55, 0x11, 0x55, 0x00, 0x15, 0x00, 0x54, 0x01, 0x00, 0x54, 0x01, 0x40,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x50, 0x00, 0x20, 0x82, 0x20, 0x08, 0x82, 0x00, 0x22, 0x80,
+ 0x08, 0x08, 0x28, 0xa2, 0x28, 0x20, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xa2,
+ 0x00, 0x04, 0x41, 0x10, 0x04, 0x11, 0x00, 0x40, 0x10, 0x14, 0x10, 0x54,
+ 0x54, 0x11, 0x10, 0x00, 0x01, 0x00, 0x50, 0x14, 0x15, 0x05, 0x45, 0x01,
+ 0x50, 0x50, 0x44, 0x14, 0x05, 0x00, 0x04, 0x40, 0x20, 0x02, 0x22, 0x02,
+ 0x22, 0x08, 0x20, 0x20, 0x00, 0x08, 0x20, 0xa8, 0x28, 0x22, 0x08, 0x80,
+ 0x02, 0x00, 0x88, 0x22, 0xa2, 0x88, 0x28, 0x02, 0x88, 0x80, 0x22, 0xa2,
+ 0x08, 0x00, 0x08, 0x22, 0x00, 0x04, 0x41, 0x00, 0x04, 0x00, 0x01, 0x40,
+ 0x00, 0x10, 0x40, 0x04, 0x11, 0x10, 0x04, 0x10, 0x05, 0x00, 0x10, 0x04,
+ 0x01, 0x55, 0x45, 0x04, 0x10, 0x50, 0x44, 0x15, 0x01, 0x00, 0x14, 0x10,
+ 0x00, 0x2a, 0xa0, 0x02, 0x2a, 0x20, 0x22, 0x80, 0x02, 0x22, 0x20, 0x02,
+ 0x0a, 0xa0, 0x02, 0x08, 0x0a, 0x00, 0x20, 0x02, 0x82, 0x80, 0x20, 0x02,
+ 0x80, 0x88, 0x28, 0x82, 0x00, 0x00, 0xa8, 0x20, 0x00, 0x44, 0x40, 0x01,
+ 0x14, 0x00, 0x04, 0x00, 0x05, 0x10, 0x40, 0x00, 0x11, 0x10, 0x05, 0x04,
+ 0x14, 0x00, 0x44, 0x44, 0x01, 0x51, 0x44, 0x04, 0x10, 0x45, 0x14, 0x11,
+ 0x01, 0x00, 0x50, 0x11, 0x00, 0x82, 0x20, 0x02, 0x22, 0x20, 0x28, 0x20,
+ 0x08, 0x2a, 0x80, 0x02, 0x02, 0x20, 0x08, 0x00, 0x00, 0x00, 0x28, 0x28,
+ 0x02, 0x8a, 0x22, 0x02, 0xa0, 0xa8, 0x08, 0x8a, 0x00, 0x00, 0x80, 0x22,
+ 0x00, 0x04, 0x41, 0x10, 0x04, 0x01, 0x10, 0x00, 0x10, 0x41, 0x40, 0x01,
+ 0x11, 0x10, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x51, 0x20, 0x82, 0x20, 0x00,
+ 0x02, 0x20, 0x28, 0x20, 0x88, 0x20, 0x80, 0x00, 0x82, 0x20, 0x28, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x22, 0x10, 0x04, 0x45, 0x10, 0x04, 0x01, 0x10, 0x40,
+ 0x04, 0x40, 0x00, 0x00, 0x41, 0x10, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x41,
+ 0x8a, 0x0a, 0xaa, 0x8a, 0xaa, 0xa8, 0x20, 0xa0, 0x82, 0xa2, 0x80, 0x80,
+ 0xaa, 0xa8, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x80, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x55, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x15, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0xaa, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x55, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54,
+ 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xa0, 0xa2, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x2a, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x10, 0x50,
+ 0x41, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x15, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0xa0, 0x80, 0x02, 0xa8, 0x28,
+ 0x0a, 0xa0, 0x02, 0xa8, 0x00, 0x8a, 0x02, 0x28, 0x00, 0x00, 0x00, 0x0a,
+ 0x28, 0x80, 0x2a, 0x80, 0x22, 0x80, 0x0a, 0x00, 0xa8, 0x00, 0x28, 0x2a,
+ 0x00, 0x05, 0x00, 0x50, 0x00, 0x00, 0x55, 0x51, 0x14, 0x14, 0x54, 0x54,
+ 0x01, 0x54, 0x01, 0x50, 0x50, 0x05, 0x00, 0x05, 0x00, 0x50, 0x55, 0x40,
+ 0x51, 0x50, 0x15, 0x00, 0x54, 0x05, 0x14, 0x55, 0x00, 0x0a, 0x00, 0xa0,
+ 0x00, 0x80, 0xaa, 0x2a, 0x2a, 0x08, 0x2a, 0xa8, 0x02, 0xaa, 0x02, 0xa0,
+ 0xa0, 0x02, 0x00, 0x0a, 0x00, 0xa8, 0xaa, 0x80, 0x2a, 0xa8, 0x2a, 0x80,
+ 0xaa, 0x0a, 0xa8, 0xaa, 0x01, 0x05, 0x00, 0x50, 0x05, 0x40, 0x55, 0x55,
+ 0x14, 0x00, 0x14, 0x50, 0x05, 0x54, 0x01, 0x40, 0x51, 0x01, 0x00, 0x55,
+ 0x00, 0x54, 0x55, 0x41, 0x15, 0x54, 0x55, 0x40, 0x55, 0x15, 0x54, 0x55,
+ 0x02, 0x0a, 0x00, 0xa0, 0x0a, 0xa0, 0x02, 0x2a, 0x2a, 0x00, 0x0a, 0x88,
+ 0x0a, 0x2a, 0x00, 0x80, 0xaa, 0x00, 0x00, 0xaa, 0x00, 0xaa, 0xa0, 0xa2,
+ 0x0a, 0x2a, 0xa8, 0xa0, 0x0a, 0x0a, 0xaa, 0xa0, 0x01, 0x14, 0x01, 0x40,
+ 0x55, 0x50, 0x01, 0x14, 0x14, 0x00, 0x05, 0x04, 0x15, 0x15, 0x00, 0x00,
+ 0x51, 0x00, 0x00, 0x54, 0x05, 0x14, 0x40, 0x45, 0x05, 0x15, 0x50, 0x41,
+ 0x01, 0x14, 0x54, 0x40, 0x02, 0xa8, 0x00, 0x80, 0xaa, 0xa8, 0x00, 0x2a,
+ 0x28, 0x88, 0x02, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8,
+ 0x0a, 0x0a, 0xa0, 0xa2, 0x82, 0x0a, 0xa0, 0xa0, 0x00, 0x28, 0x2a, 0xa0,
+ 0x01, 0x50, 0x00, 0x00, 0x55, 0x50, 0x00, 0x14, 0x54, 0x54, 0x05, 0x15,
+ 0x14, 0x15, 0x00, 0x00, 0x11, 0x00, 0x00, 0x50, 0x05, 0x15, 0x00, 0x40,
+ 0x01, 0x05, 0x40, 0x51, 0x00, 0x14, 0x14, 0x40, 0x00, 0xa8, 0x00, 0x00,
+ 0xa8, 0x28, 0x00, 0x28, 0x28, 0xa8, 0x02, 0x80, 0x0a, 0x0a, 0x00, 0x80,
+ 0x08, 0x00, 0x00, 0x80, 0x8a, 0x0a, 0x00, 0xa0, 0x80, 0xaa, 0xaa, 0xa8,
+ 0xaa, 0x2a, 0x0a, 0xa0, 0x01, 0x44, 0x01, 0x00, 0x50, 0x55, 0x00, 0x14,
+ 0x50, 0x14, 0x01, 0x00, 0x15, 0x05, 0x00, 0x40, 0x15, 0x00, 0x00, 0x00,
+ 0x15, 0x05, 0x00, 0x50, 0x41, 0x55, 0x55, 0x51, 0x55, 0x15, 0x15, 0x40,
+ 0x00, 0x80, 0x02, 0x00, 0xa0, 0x28, 0x00, 0x0a, 0x28, 0x0a, 0x02, 0x00,
+ 0x8a, 0x0a, 0x00, 0xa0, 0x2a, 0x00, 0x00, 0x00, 0x8a, 0x0a, 0x00, 0xa0,
+ 0x80, 0xaa, 0xaa, 0xa8, 0xaa, 0x2a, 0x0a, 0xa0, 0x01, 0x40, 0x01, 0x00,
+ 0x50, 0x55, 0x00, 0x14, 0x50, 0x05, 0x00, 0x00, 0x14, 0x05, 0x00, 0x50,
+ 0x50, 0x00, 0x00, 0x00, 0x15, 0x05, 0x00, 0x50, 0x40, 0x55, 0x55, 0x51,
+ 0x55, 0x15, 0x05, 0x50, 0x00, 0x80, 0x02, 0x2a, 0xa8, 0x28, 0x00, 0x0a,
+ 0xa8, 0x0a, 0x80, 0xaa, 0x82, 0x02, 0x00, 0x20, 0xa0, 0x00, 0xa0, 0x82,
+ 0x8a, 0x0a, 0x00, 0xa0, 0x80, 0x02, 0x00, 0x28, 0x00, 0x00, 0x0a, 0xa0,
+ 0x00, 0x00, 0x05, 0x14, 0x50, 0x54, 0x00, 0x15, 0x50, 0x05, 0x40, 0x55,
+ 0x01, 0x05, 0x00, 0x10, 0x40, 0x01, 0x40, 0x01, 0x05, 0x15, 0x50, 0x51,
+ 0x40, 0x01, 0x00, 0x50, 0x00, 0x00, 0x05, 0x50, 0x00, 0x00, 0x0a, 0x2a,
+ 0xa8, 0xa8, 0x80, 0x0a, 0xa0, 0x02, 0x80, 0x0a, 0x80, 0x02, 0x00, 0x08,
+ 0x80, 0x02, 0xa0, 0x82, 0x0a, 0x2a, 0xa8, 0xa0, 0x80, 0x02, 0x2a, 0xa8,
+ 0x80, 0x8a, 0x0a, 0xa0, 0x00, 0x00, 0x00, 0x54, 0x55, 0x50, 0x55, 0x05,
+ 0x50, 0x01, 0x00, 0x00, 0x44, 0x05, 0x00, 0x04, 0x00, 0x05, 0x40, 0x55,
+ 0x05, 0x54, 0x55, 0x50, 0x00, 0x55, 0x15, 0x50, 0x55, 0x05, 0x05, 0x50,
+ 0x00, 0x00, 0x00, 0xa8, 0x2a, 0xa0, 0xaa, 0x0a, 0xa0, 0x00, 0x08, 0x00,
+ 0x8a, 0x02, 0x00, 0x0a, 0x00, 0x00, 0x80, 0xaa, 0x02, 0xaa, 0x2a, 0x28,
+ 0x80, 0xaa, 0x0a, 0xa0, 0xaa, 0x82, 0x02, 0x28, 0x00, 0x00, 0x00, 0x50,
+ 0x15, 0x40, 0x55, 0x05, 0x40, 0x01, 0x10, 0x00, 0x55, 0x01, 0x00, 0x05,
+ 0x00, 0x00, 0x00, 0x55, 0x01, 0x54, 0x15, 0x50, 0x00, 0x55, 0x05, 0x40,
+ 0x55, 0x01, 0x05, 0x50, 0x00, 0x00, 0x00, 0xa0, 0x02, 0x80, 0x0a, 0x0a,
+ 0xa0, 0x00, 0x00, 0xa0, 0xaa, 0x02, 0x80, 0x0a, 0x00, 0x00, 0x00, 0x2a,
+ 0x00, 0xa0, 0x0a, 0x28, 0x00, 0xa8, 0x00, 0x80, 0x2a, 0x80, 0x02, 0x28,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
+ 0x55, 0x00, 0x40, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0xa0, 0x02,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x50, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa,
+ 0xaa, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x55, 0x01, 0x50, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xa8, 0xaa, 0x02, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50,
+ 0x55, 0x05, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0xaa, 0x0a, 0x0a, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x40, 0x55, 0x15, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0xaa, 0x8a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x55, 0x45, 0x05, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x22, 0xa0, 0x22, 0xa8, 0x0a, 0xa8, 0x00,
+ 0xa8, 0xa0, 0x28, 0x80, 0xaa, 0x22, 0x28, 0xa0, 0x02, 0x2a, 0x2a, 0xa0,
+ 0x02, 0x8a, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x15, 0x50, 0x15, 0x54, 0x15, 0x54, 0x01, 0x55, 0x41, 0x55, 0x00,
+ 0x55, 0x11, 0x54, 0x50, 0x05, 0x54, 0x54, 0x54, 0x05, 0x54, 0x05, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x08, 0x08,
+ 0x20, 0x08, 0x02, 0x82, 0x82, 0x82, 0x82, 0x00, 0xaa, 0x08, 0x20, 0x20,
+ 0x08, 0x08, 0x08, 0x0a, 0x0a, 0x28, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x50, 0x10, 0x04, 0x10, 0x10, 0x00, 0x01, 0x04,
+ 0x01, 0x01, 0x01, 0x01, 0x54, 0x14, 0x11, 0x00, 0x10, 0x10, 0x04, 0x04,
+ 0x04, 0x10, 0x00, 0x14, 0x51, 0x10, 0x44, 0x01, 0x50, 0x44, 0x44, 0x14,
+ 0xa0, 0x00, 0x02, 0x08, 0x08, 0x80, 0x00, 0x82, 0x00, 0x82, 0x80, 0x00,
+ 0xa8, 0x28, 0x00, 0xa0, 0x0a, 0x20, 0x08, 0x02, 0x08, 0x08, 0x00, 0x00,
+ 0x20, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x05, 0x04, 0x00,
+ 0x10, 0x00, 0x55, 0x45, 0x55, 0x41, 0x40, 0x00, 0x54, 0x54, 0x00, 0x50,
+ 0x05, 0x10, 0x04, 0x55, 0x05, 0x04, 0x00, 0x44, 0x10, 0x14, 0x45, 0x04,
+ 0x10, 0x54, 0x54, 0x04, 0x00, 0x0a, 0x02, 0x00, 0x08, 0x80, 0xaa, 0x82,
+ 0xaa, 0x82, 0x80, 0x00, 0x2a, 0xaa, 0x00, 0x08, 0x08, 0x20, 0x02, 0xaa,
+ 0x0a, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00,
+ 0x10, 0x14, 0x04, 0x00, 0x04, 0x00, 0x01, 0x40, 0x00, 0x40, 0x40, 0x00,
+ 0x15, 0x45, 0x15, 0x04, 0x04, 0x10, 0x01, 0x01, 0x00, 0x04, 0x00, 0x05,
+ 0x15, 0x10, 0x44, 0x04, 0x14, 0x14, 0x41, 0x04, 0x08, 0x08, 0x0a, 0x08,
+ 0x08, 0x80, 0x02, 0x82, 0x80, 0x20, 0x20, 0x80, 0x8a, 0x8a, 0x22, 0x02,
+ 0x02, 0xa0, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x54, 0x05, 0x54, 0x15, 0x55, 0x01, 0x55, 0x01,
+ 0x55, 0x51, 0x51, 0x01, 0x45, 0x05, 0x00, 0x54, 0x15, 0x40, 0x00, 0x54,
+ 0x45, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xa8, 0x02, 0xa8, 0x82, 0xaa, 0x00, 0xaa, 0x00, 0x2a, 0xa8, 0xa8, 0x80,
+ 0x82, 0x22, 0x20, 0xa8, 0x0a, 0x20, 0x00, 0xa8, 0x80, 0xaa, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x55, 0x55, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50,
+ 0x05, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xa0, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x08,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50,
+ 0x00, 0x54, 0x55, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x40, 0x15, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x00, 0xa8, 0xaa, 0x02,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0x2a, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x54, 0x00, 0x54, 0x55, 0x01, 0x00, 0x40, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a,
+ 0x00, 0xa8, 0xaa, 0x02, 0x00, 0x80, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x50, 0x55, 0x05,
+ 0x00, 0x00, 0x05, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x54, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0x0a, 0x00, 0xa0, 0xaa, 0x0a, 0x00, 0x00, 0x0a, 0x08,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x02, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05,
+ 0x00, 0x40, 0x55, 0x15, 0x00, 0x00, 0x14, 0x04, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x54, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x80, 0xaa, 0x2a,
+ 0x00, 0x00, 0x28, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xa8, 0x02, 0x08, 0x00, 0x10, 0x50, 0x50, 0x50, 0x40, 0x10, 0x00, 0x00,
+ 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x50, 0x00,
+ 0x50, 0x00, 0x05, 0x04, 0x01, 0x05, 0x50, 0x40, 0x54, 0x05, 0x04, 0x05,
+ 0x8a, 0x20, 0x20, 0x88, 0xa0, 0x28, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00,
+ 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x20, 0x00, 0x82, 0x82, 0x08, 0x8a,
+ 0x82, 0x08, 0x88, 0xa0, 0xa8, 0x0a, 0x22, 0x28, 0x00, 0x41, 0x00, 0x04,
+ 0x41, 0x44, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x55, 0x55,
+ 0x00, 0x00, 0x10, 0x00, 0x01, 0x41, 0x10, 0x44, 0x44, 0x10, 0x04, 0x41,
+ 0x50, 0x15, 0x11, 0x10, 0x80, 0x80, 0x00, 0x02, 0x82, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x80, 0x00,
+ 0x02, 0x22, 0x20, 0x08, 0x20, 0x20, 0x02, 0x22, 0xa0, 0x2a, 0x22, 0x20,
+ 0x00, 0x41, 0x10, 0x01, 0x44, 0x00, 0x00, 0x40, 0x41, 0x51, 0x04, 0x14,
+ 0x15, 0x00, 0x11, 0x44, 0x50, 0x54, 0x40, 0x01, 0x05, 0x10, 0x00, 0x04,
+ 0x10, 0x40, 0x01, 0x44, 0x10, 0x15, 0x51, 0x00, 0xa8, 0x80, 0x00, 0xaa,
+ 0x82, 0x00, 0x00, 0x20, 0x22, 0x8a, 0xa2, 0x22, 0x22, 0x80, 0xa0, 0x88,
+ 0x88, 0x88, 0x88, 0x02, 0x2a, 0x20, 0x00, 0x08, 0xa0, 0x2a, 0xaa, 0x22,
+ 0x20, 0x8a, 0xa0, 0x02, 0x04, 0x01, 0x01, 0x01, 0x40, 0x00, 0x00, 0x40,
+ 0x10, 0x10, 0x41, 0x54, 0x11, 0x00, 0x11, 0x40, 0x54, 0x05, 0x04, 0x05,
+ 0x50, 0x11, 0x00, 0x04, 0x10, 0x00, 0x01, 0x40, 0x10, 0x45, 0x00, 0x15,
+ 0x82, 0x80, 0x08, 0x02, 0x80, 0x00, 0x00, 0x00, 0x22, 0x88, 0x02, 0x02,
+ 0x22, 0x00, 0x82, 0x08, 0x02, 0x08, 0x02, 0x0a, 0x80, 0x22, 0x00, 0x08,
+ 0x20, 0x00, 0x02, 0x20, 0x20, 0xa2, 0x00, 0x28, 0x01, 0x01, 0x05, 0x01,
+ 0x40, 0x00, 0x00, 0x40, 0x14, 0x51, 0x41, 0x44, 0x11, 0x40, 0x04, 0x11,
+ 0x04, 0x05, 0x01, 0x14, 0x00, 0x15, 0x00, 0x04, 0x10, 0x00, 0x01, 0x40,
+ 0x10, 0x51, 0x01, 0x50, 0x82, 0x00, 0x02, 0x02, 0x80, 0x00, 0x00, 0x80,
+ 0xa2, 0x88, 0x2a, 0x28, 0x22, 0x80, 0x02, 0x28, 0x8a, 0x88, 0x00, 0x28,
+ 0x00, 0x22, 0x00, 0x08, 0x20, 0x00, 0x02, 0x20, 0xa0, 0xa8, 0x02, 0x20,
+ 0x01, 0x05, 0x05, 0x04, 0x44, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00,
+ 0x00, 0x00, 0x40, 0x55, 0x15, 0x00, 0x00, 0x00, 0x01, 0x44, 0x00, 0x04,
+ 0x40, 0x40, 0x04, 0x44, 0x10, 0x51, 0x15, 0x40, 0x82, 0x00, 0x02, 0x08,
+ 0x82, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x80, 0xaa,
+ 0x2a, 0x00, 0x00, 0x00, 0x02, 0x82, 0x08, 0x08, 0x80, 0x20, 0x08, 0x22,
+ 0xa0, 0xa0, 0x2a, 0x20, 0x14, 0x01, 0x00, 0x50, 0x50, 0x01, 0x00, 0x00,
+ 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x00,
+ 0x51, 0x00, 0x05, 0x15, 0x00, 0x05, 0x50, 0x50, 0x50, 0x40, 0x15, 0x05,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0x80, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x10, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x10, 0x40, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x28, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x80, 0x2a, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50,
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x54, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0xa8, 0x02, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
+ 0x00, 0x00, 0x50, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xa0, 0x0a,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
+ 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0a, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x04, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x00, 0x40, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x50, 0x55, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00,
+ 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0xaa,
+ 0x15, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x10, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x05, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x55, 0x2a, 0x00, 0x00, 0x00,
+ 0x00, 0xa0, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0xaa, 0x15, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00,
+ 0x00, 0x10, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x55,
+ 0xa2, 0x00, 0x80, 0x02, 0x0a, 0xa2, 0x82, 0x02, 0x0a, 0x08, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0a, 0xa8, 0xa0, 0x80, 0x82, 0xa0, 0x11, 0x01, 0x00, 0x04,
+ 0x11, 0x50, 0x41, 0x04, 0x11, 0x10, 0x00, 0x14, 0x44, 0x40, 0x00, 0x41,
+ 0x11, 0x00, 0x14, 0x00, 0x44, 0x05, 0x05, 0x04, 0x45, 0x00, 0x10, 0x44,
+ 0x11, 0x11, 0x04, 0x44, 0xa2, 0x02, 0x20, 0x80, 0x20, 0x28, 0x20, 0x08,
+ 0x02, 0x20, 0x80, 0x22, 0xa8, 0xa8, 0xa0, 0x82, 0x28, 0x00, 0x28, 0x80,
+ 0x22, 0x08, 0x82, 0x0a, 0x22, 0x80, 0x00, 0x82, 0x20, 0x00, 0x88, 0x8a,
+ 0x51, 0x05, 0x50, 0x00, 0x10, 0x11, 0x11, 0x10, 0x01, 0x50, 0x40, 0x10,
+ 0x54, 0x04, 0x11, 0x04, 0x41, 0x00, 0x50, 0x40, 0x10, 0x04, 0x44, 0x10,
+ 0x44, 0x40, 0x01, 0x01, 0x10, 0x10, 0x44, 0x14, 0xa2, 0x00, 0xa0, 0x00,
+ 0xa8, 0x02, 0xa0, 0x0a, 0x02, 0xa0, 0xa0, 0x00, 0x0a, 0x82, 0x08, 0x82,
+ 0x20, 0x00, 0xa0, 0x20, 0x20, 0x08, 0x22, 0x08, 0x02, 0x80, 0x02, 0x02,
+ 0x20, 0xa8, 0x8a, 0x82, 0x51, 0x01, 0x40, 0x01, 0x55, 0x01, 0x10, 0x00,
+ 0x01, 0x40, 0x41, 0x00, 0x04, 0x54, 0x50, 0x41, 0x40, 0x00, 0x40, 0x10,
+ 0x10, 0x04, 0x41, 0x05, 0x01, 0x00, 0x05, 0x01, 0x10, 0x10, 0x40, 0x50,
+ 0xa2, 0x08, 0x80, 0x82, 0xa0, 0x8a, 0x20, 0x00, 0x02, 0x80, 0x22, 0x00,
+ 0x02, 0x0a, 0x28, 0x80, 0x20, 0x00, 0x80, 0x20, 0x08, 0x88, 0xa0, 0x00,
+ 0x02, 0x00, 0x0a, 0x02, 0x20, 0x08, 0x80, 0xa0, 0x51, 0x01, 0x00, 0x44,
+ 0x50, 0x11, 0x10, 0x00, 0x01, 0x00, 0x11, 0x00, 0x01, 0x01, 0x04, 0x40,
+ 0x10, 0x00, 0x40, 0x11, 0x10, 0x10, 0x11, 0x00, 0x01, 0x00, 0x10, 0x01,
+ 0x10, 0x10, 0x40, 0x50, 0xa2, 0x08, 0x00, 0x88, 0x80, 0x08, 0x20, 0x00,
+ 0x02, 0x02, 0x22, 0x00, 0x02, 0x02, 0x08, 0x20, 0x20, 0x00, 0x80, 0x08,
+ 0x08, 0x88, 0x20, 0x80, 0x00, 0x00, 0x20, 0x02, 0x20, 0x28, 0x80, 0xa0,
+ 0x51, 0x11, 0x10, 0x44, 0x40, 0x50, 0x40, 0x10, 0x01, 0x00, 0x11, 0x00,
+ 0x01, 0x01, 0x04, 0x40, 0x10, 0x00, 0x01, 0x11, 0x04, 0x50, 0x10, 0x00,
+ 0x01, 0x40, 0x10, 0x04, 0x11, 0x50, 0x00, 0x01, 0xa2, 0x28, 0x20, 0x82,
+ 0x0a, 0x20, 0xa0, 0x0a, 0x02, 0x02, 0x22, 0x88, 0x00, 0x82, 0x08, 0x22,
+ 0x08, 0x80, 0x80, 0x28, 0x08, 0x28, 0x20, 0x88, 0x00, 0x80, 0x08, 0xaa,
+ 0x20, 0xa0, 0x82, 0xaa, 0x41, 0x50, 0x50, 0x01, 0x55, 0x00, 0x00, 0x05,
+ 0x05, 0x05, 0x51, 0x04, 0x01, 0x45, 0x14, 0x11, 0x50, 0x00, 0x41, 0x50,
+ 0x04, 0x10, 0x50, 0x44, 0x00, 0x40, 0x05, 0x50, 0x50, 0x40, 0x01, 0x14,
+ 0xaa, 0xaa, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xa0, 0x82,
+ 0x00, 0x2a, 0xa8, 0x20, 0x28, 0x80, 0x2a, 0x20, 0x08, 0x08, 0xa0, 0x82,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x55, 0x01, 0x00,
+ 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xa8, 0xaa, 0x02, 0x80, 0x0a, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x54, 0x55, 0x01, 0x40, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xaa, 0x02, 0xa0,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x50, 0x55, 0x05, 0x40, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xa0, 0xaa, 0x0a, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x55, 0x15, 0x50,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0xaa, 0x2a, 0x28, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x55, 0x55, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x40, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0x2a, 0x2a,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x15, 0x15, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xaa, 0x8a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x45, 0x45,
+ 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x88, 0xa2, 0x22, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x88, 0x00, 0x00, 0x80, 0xaa, 0x2a, 0x0a, 0x00, 0x0a, 0x08,
+ 0x02, 0x22, 0xa0, 0x80, 0x08, 0x00, 0xa0, 0x00, 0x20, 0xa0, 0xa0, 0xa0,
+ 0x41, 0x01, 0x51, 0x45, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01,
+ 0x00, 0x00, 0x55, 0x55, 0x14, 0x00, 0x11, 0x14, 0x05, 0x45, 0x10, 0x41,
+ 0x11, 0x00, 0x40, 0x01, 0x14, 0x41, 0x40, 0x10, 0x82, 0x28, 0xa2, 0xaa,
+ 0x80, 0xa2, 0xa2, 0xa0, 0xa8, 0x00, 0x28, 0x28, 0x08, 0xa2, 0x02, 0xaa,
+ 0xa8, 0x80, 0x20, 0x88, 0x88, 0x0a, 0x08, 0x82, 0x20, 0x00, 0x80, 0x0a,
+ 0x00, 0x82, 0x00, 0x08, 0x04, 0x51, 0x51, 0x55, 0x45, 0x44, 0x11, 0x11,
+ 0x11, 0x01, 0x50, 0x44, 0x04, 0x11, 0x05, 0x55, 0x41, 0x41, 0x40, 0x10,
+ 0x40, 0x55, 0x04, 0x44, 0x40, 0x00, 0x00, 0x14, 0x00, 0x01, 0x01, 0x04,
+ 0x88, 0xa8, 0xa8, 0x2a, 0x2a, 0x20, 0x08, 0x0a, 0x0a, 0x02, 0xa0, 0x80,
+ 0x88, 0x08, 0xa2, 0xaa, 0x02, 0x22, 0x00, 0x08, 0xa0, 0x8a, 0x02, 0x88,
+ 0x20, 0x00, 0x00, 0x20, 0x00, 0x82, 0x20, 0x02, 0x05, 0x55, 0x54, 0x55,
+ 0x44, 0x40, 0x50, 0x51, 0x11, 0x01, 0x04, 0x51, 0x10, 0x51, 0x41, 0x55,
+ 0x05, 0x44, 0x00, 0x10, 0x00, 0x50, 0x54, 0x45, 0x40, 0x00, 0x00, 0x40,
+ 0x50, 0x01, 0x01, 0x54, 0x80, 0x2a, 0xaa, 0x0a, 0x28, 0x28, 0x08, 0x08,
+ 0x08, 0x02, 0x88, 0x88, 0x80, 0x08, 0xa8, 0xaa, 0x0a, 0x28, 0x00, 0x08,
+ 0xa0, 0x02, 0x02, 0x80, 0x20, 0x00, 0x00, 0x80, 0x08, 0x02, 0x02, 0x02,
+ 0x00, 0x15, 0x55, 0x15, 0x44, 0x44, 0x10, 0x11, 0x11, 0x01, 0x04, 0x45,
+ 0x50, 0x10, 0x51, 0x55, 0x15, 0x44, 0x00, 0x10, 0x00, 0x01, 0x04, 0x40,
+ 0x40, 0x00, 0x00, 0x40, 0x04, 0x01, 0x11, 0x04, 0x80, 0x0a, 0xaa, 0x2a,
+ 0x82, 0x22, 0xa0, 0xa0, 0x08, 0x02, 0xa8, 0xa8, 0x20, 0xa0, 0xa8, 0xaa,
+ 0x0a, 0x28, 0x00, 0x08, 0x80, 0x00, 0x02, 0x80, 0x20, 0x00, 0x00, 0x80,
+ 0x02, 0x02, 0x0a, 0x02, 0x00, 0x04, 0x54, 0x55, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x55, 0x15, 0x44, 0x00, 0x10,
+ 0x10, 0x00, 0x04, 0x40, 0x40, 0x00, 0x00, 0x40, 0x04, 0x01, 0x04, 0x04,
+ 0x08, 0x02, 0xa8, 0xaa, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0xaa, 0x28, 0x82, 0x00, 0x08, 0xa8, 0x80, 0x08, 0x88,
+ 0x20, 0x00, 0x20, 0x20, 0x02, 0x0a, 0x0a, 0x08, 0x44, 0x00, 0x50, 0x55,
+ 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
+ 0x51, 0x01, 0x11, 0x10, 0x54, 0x41, 0x10, 0x44, 0x40, 0x00, 0x40, 0x10,
+ 0x04, 0x01, 0x04, 0x10, 0x00, 0x00, 0xa0, 0xaa, 0x0a, 0x00, 0x00, 0x00,
+ 0x00, 0xa0, 0x00, 0x08, 0x00, 0x00, 0x00, 0xaa, 0x08, 0x00, 0x0a, 0x2a,
+ 0x2a, 0x0a, 0xa0, 0xa0, 0xa0, 0x00, 0x20, 0x0a, 0x28, 0x02, 0x00, 0xa0,
+ 0x50, 0x01, 0x50, 0x55, 0x05, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x54, 0x55, 0x01, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/nx-X11/programs/Xserver/hw/xwin/ChangeLog b/nx-X11/programs/Xserver/hw/xwin/ChangeLog
new file mode 100644
index 000000000..93da0323a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/ChangeLog
@@ -0,0 +1,663 @@
+2005-07-05 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowwm.c:
+ Fix crash on server shutdown
+
+2005-07-05 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winkeybd.c:
+ * winkeybd.h:
+ * winwndproc.c:
+ Fix simultanious presses of Left and Right Control and Shift keys.
+ https://bugs.freedesktop.org/show_bug.cgi?id=3677
+
+2005-07-05 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowwm.c:
+ Fix typo which broke window titles
+
+2005-07-05 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowwndproc.c:
+ * winkeybd.c:
+ Fix problem with fake Control press on Alt-Gr
+ https://bugs.freedesktop.org/show_bug.cgi?id=3680
+ https://bugs.freedesktop.org/show_bug.cgi?id=3497
+
+ * InitOutput.c:
+ Fix static declaration of winGetBaseDir
+
+2005-07-05 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winwindow.h:
+ * winmultiwindowwm.c:
+ * winscrinit.c:
+ External windowmanagers could connect in multiwindow mode which lead
+ to strange results with the internal windowmanager.
+
+2005-07-05 Alexander Gottwald <ago at freedesktop dot org>
+
+ * *.c:
+ Include xwin-config.h if HAVE_XWIN_CONFIG is defined
+ Cleanup X11 includes handling
+ Warning fixes
+
+2005-06-30 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowwndproc.c:
+ Pass serverClient instead of NULL to ConfigureWindow.
+ This should fix a crash reported by Øyvind Harboe
+
+2005-06-08 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winlayouts.h:
+ Merge from CYGWIN
+ Added layout "French (Canada)" as ca_enhanced
+ Added Czech (QWERTY) layout
+ * winshaddnl.c:
+ Merge from CYGWIN
+ Print error code if winStoreColorsShadowDDNL fails
+
+2005-06-08 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowwindow.c:
+ Fix crash reported by Øyvind Harboe
+
+2005-06-03 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowwndproc.c:
+ * winblock.c:
+ Backout last winRaiseWindow patch which caused stacking problems
+
+2005-05-25 Alexander Gottwald <ago at freedesktop dot org>
+
+ * win.h:
+ * winmultiwindowwm.c:
+ Workaround bug in pthread.h
+
+2005-05-08 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowwndproc.c:
+ * winblock.c:
+ Only call ConfigureWindow from winRaiseWindow if the windows
+ message dispatch loop is running.
+
+2005-05-02 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winerror.c:
+ Print correct logfile in FatalError message
+
+2005-04-19 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowwndproc.c:
+ Prevent recursive calls to winRaiseWindow.
+
+2005-03-10 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowwndproc.c:
+ Force rebuilding of window stack if a window changes it's state from
+ minimized.
+
+2005-03-07 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowwndproc.c:
+ * winmultiwindowwindow.c:
+ Prevent winRaiseWindow from calling ConfigureWindow if the message
+ was sent from within winDestroyWindowsWindow
+
+ DestroyWindow send a WM_WINDOWPOSCHANGED to another window causing
+ a restacking of all windows, even of the window which is just about
+ to destroyed and whose structures may not be intact anymore.
+
+2005-02-24 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowwndproc.c:
+ on WM_WINDOWPOSCHANGED raise window directly and in sync without
+ utilizing the async windowmanager thread. Fixes some restacking
+ problems occuring which were timing dependent
+ Do not raise the window on WM_ACTIVATE
+ Removed unused code for WM_WINDOWPOSCHANGING
+ ESC is debug key. Print status but do not abort processing the message
+
+2005-02-12 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowwindow.c
+ * winmultiwindowwndproc.c
+ * winwin32rootlesswndproc.c:
+ Cleanup some message debugging
+
+2005-02-12 Alexander Gottwald <ago at freedesktop dot org>
+
+ * win.h
+ * winfont.c
+ * winmultiwindowshape.c
+ * winmultiwindowwindow.c
+ * winpfbdd.c
+ * winshaddd.c
+ * winshadddnl.c
+ * winshadgdi.c
+ * winwindow.c:
+ Fix incorrect wrapping of functions. Ensure the pointers from pScreen
+ point to the called function even if wrapped functions changed it
+
+ * winmultiwindowwindow.c:
+ Set the window properties to NULL to avoid referencing freed memory
+ because of timing problems after deleting a window
+
+ * winscrinit.c:
+ Do not wrap ChangeWindowAttributes. All functions are noops currently
+
+2005-02-12 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmsg.h:
+ * winmsg.c:
+ print window handle in message output
+
+2005-02-08 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winkeybd.c:
+ * winkeynames.h:
+ Updated fix for ABNT2 and HK_Toggle keys.
+
+2005-02-08 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winkeybd.h:
+ * winkeynames.h:
+ Backout ABNT2 and HK_Toggle fix since it broke keys F1 and F4.
+
+2005-02-07 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winlayouts.h:
+ * winconfig.c:
+ Moved keyboard layout table to external file.
+
+2005-02-02 Alexander Gottwald <ago at freedesktop dot org>
+
+ * wincreatewnd.c:
+ Force ShowWindow if XWin was started via run.exe. Fixes mainwindow
+ not showing bug
+
+2005-01-31 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowwindow.c
+ * winmultiwindowwndproc.c:
+ Create windows with SWP_NOACTIVATE flag (updated) (Kensuke Matsuzaki)
+
+2005-01-31 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowwndproc.c:
+ Fixes for window ordering problem (updated) (Kensuke Matsuzaki)
+
+2005-01-31 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winconfig.c:
+ Added hungarian keyboard layout.
+
+2005-01-31 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmessages.h
+ * winmsg.h
+ * winmsg.c
+ * winmultiwindowwndproc.c
+ * winwin32rootlesswndproc.c
+ * winwndproc.c:
+ Make logging of messages configurable with environment variables
+
+2005-01-31 Alexander Gottwald <ago at freedesktop dot org>
+
+ * InitOutput.c:
+ resolve SHGetFolderPath dynamicly since it is not available on all Windows
+ systems.
+
+2005-01-12 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmsg.c
+ * winmsg.h:
+ Introduce function winTrace which prints log message with verbosity 10
+ * winmultiwindowwindow.c:
+ Use winTrace for 3 heavily called functions
+
+2005-01-11 Alexander Gottwald <ago at freedesktop dot org>
+
+ * XWin.man:
+ Document the -silent-dup-error switch
+
+2005-01-11 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winkeyhook.c:
+ Do not grab ALT-TAB when window is in multiwindow mode
+
+2005-01-11 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winprefs.h:
+ Fix crash with not matching definitions of PATH_MAX
+
+2005-01-10 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winkeybd.h
+ * winkeynames.h:
+ Adjust keysyms for Hiragana_Katakana toggle and backslash/underscore
+ on Japanese and ABNT2 keyboards
+
+2005-01-10 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winkeybd.h
+ * winkeyhook.c
+ * winwndproc.c:
+ Make keyhook feature work in multiwindowmode too
+ Hook windows keys
+
+2005-01-08 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winblock.c:
+ Fix a possible null-pointer dereference (Keishi Suenaga)
+
+2005-01-06 Alexander Gottwald <ago at freedesktop dot org>
+
+ * Imakefile
+ * InitOutput.c
+ * XWin.rc
+ * winerror.c
+ * wintrayicon.c
+ * winvideo.c
+ * winshaddd.c
+ * winwindow.h:
+ Set PROJECT_NAME in Imakefile to create alternative window titles
+ for Cygwin/X and Xming
+
+2005-01-06 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowclass.c:
+ * winmultiwindowwm.c:
+ Fix crash with non-nullterminated strings (reported by Øyvind Harboe)
+
+2004-12-14 Alexander Gottwald <ago at freedesktop dot org>
+
+ * InitOutput.c:
+ * winprocarg.c:
+ EnumDisplayMonitors is not available on Window NT4 and 95. Resolve
+ the function dynamicly
+
+2004-12-08 Alexander Gottwald <ago at freedesktop dot org>
+
+ * InitOutput.c:
+ * winprocarg.c:
+ Added support for placing the main window with the @<monitor#>.
+ Patch by Mark Fisher, small changes by Alexander Gottwald
+
+2004-12-06 Alexander Gottwald <ago at freedesktop dot org>
+
+ * XWin.rc:
+ include windows.h
+
+2004-12-05 Alexander Gottwald <ago at freedesktop dot org>
+
+ * ddraw.h:
+ redone ddraw.h to be able to mix it with w32api style COM header
+ files.
+
+ * winmultiwindowwm.c:
+ * obj_base.h:
+ * ddraw.h:
+ obj_base.h is not needed anymore. Using <objbase.h> instead.
+
+ * winms.h:
+ Use Xwindows.h instead of windows.h
+
+ * winresource.h:
+ do not include win_ms.h
+
+ * win.h:
+ remove extra definition of sleep()
+
+ * InitOutput.c:
+ Set HOME to Documents and Settings/username if not set
+
+ * winprefs.c:
+ Use Xming basedir instead of ProjectRoot for system.XWinrc
+
+ * windialogs.c:
+ * winshadgdi.c:
+ * winprefs.c:
+ Fix callback functions to use wBOOL instead of BOOL
+
+ * winmultiwindowwindow.c:
+ * winwin32rootless.c:
+ * winwin32rootlesswindow.c:
+ * winerror.c:
+ Fix compiler warnings. Added debug output.
+
+ * winconfig.c:
+ Fix warning about undefined macro max
+
+2004-12-04 Earle Philhower
+
+ * InitOutput.c:
+ * win.h:
+ * wincreatewnd.c:
+ * winprocarg.c:
+ Optional position -screen parameter (-screen n WxH+X+Y or
+ -screen n W H X Y)
+
+2004-12-03 Alexander Gottwald <ago at freedesktop dot org>
+
+ * windialogs.c:
+ * win.h:
+ * Imakefile:
+ * winerror.c:
+ Removed scprintf, aprintf and snprintf stuff and use newXprintf
+
+2004-12-02 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winwin32rootless.c:
+ Adjust the width of the rootless backbuffer to match 32 bit alignment
+
+ * winprocarg.c:
+ Make multiplemonitors default for -internalwm
+
+2004-12-01 Alexander Gottwald <ago at freedesktop dot org>
+
+ * InitOutput.c:
+ Set XERRORDB environment variable to relocate the XErrorDB file
+
+2004-11-29 Kensuke Matsuzaki <zakki@peppermint.jp>
+
+ * winmultiwindowwm.c:
+ Fixed windows.h include for cygwin.
+
+ * winmultiwindowwindow.c:
+ Bugzilla #1945: Stop unnecessary reordering.
+
+2004-11-24 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowwm.c:
+ Finally the multiwindow mode defines a default cursor
+
+2004-11-22 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowwm.c:
+ Fixes for building multiwindow and internalwm on mingw
+ * winwin32rootless.c:
+ Changed some debugging output
+
+2004-11-22 Alexander Gottwald <ago at freedesktop dot org>
+
+ * InitOutput.c, winglobals.c, winprocarg.c:
+ Xming: Place logfile in users tempdir
+
+2004-11-15 Alexander Gottwald <ago at freedesktop dot org>
+
+ * Imakefile:
+ Remove override of HasSnprintf
+
+2004-11-15 Alexander Gottwald <ago at freedesktop dot org>
+
+ * Imakefile:
+ * InitInput.c: (InitInput):
+ * InitOutput.c: (winClipboardShutdown), (ddxGiveUp),
+ (winCheckMount), (winGetBaseDir), (winFixupPaths), (OsVendorInit),
+ (winCheckDisplayNumber):
+ * win.h:
+ * winblock.c: (winBlockHandler):
+ * winclipboard.h:
+ * winclipboardthread.c: (winClipboardProc):
+ * winclipboardwndproc.c: (winClipboardWindowProc):
+ * winconfig.c: (winConfigKeyboard), (winConfigFiles):
+ * wincreatewnd.c: (winCreateBoundingWindowWindowed):
+ * windialogs.c: (winDisplayExitDialog), (winExitDlgProc),
+ (winAboutDlgProc):
+ * winengine.c: (winSetEngine):
+ * winerror.c: (OsVendorVErrorF), (winMessageBoxF), (scprintf):
+ * winglobals.c: (winInitializeGlobals):
+ * winkeybd.c: (winKeybdReleaseKeys):
+ * winmultiwindowicons.c:
+ * winmultiwindowwindow.c: (winCreateWindowsWindow):
+ * winmultiwindowwm.c:
+ * winprefs.c: (ReloadPrefs), (HandleCustomWM_COMMAND):
+ * winprocarg.c: (ddxProcessArgument):
+ * winscrinit.c: (winFinishScreenInitFB):
+ * winshadddnl.c:
+ * wintrayicon.c: (winHandleIconMessage):
+ * winwakeup.c: (winWakeupHandler):
+ * winwin32rootless.c: (winMWExtWMCreateFrame):
+ * winwindow.c: (winReshapeRootless):
+ * winwindow.h:
+ * winwndproc.c: (winWindowProc):
+ Bufzilla #1802, http://freedesktop.org/bugzilla/show_bug.cgi?id=1802
+ Added mingw (Win32) port
+
+2004-11-11 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winconfig.c:
+ added keyboard layout "French (Switzerland)"
+
+2004-11-06 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winwndproc.c, wintrayicon.c, winscrinit.c:
+ * winmultiwindowwindow.c:
+ Wrap all mwextwm and internalwm code with XWIN_MULTIWINDOWEXTWM
+
+2004-11-04 Kensuke Matsuzaki <zakki@peppermint.jp>
+
+ * InitOutput.c: (winUseMsg):
+ * win.h:
+ * winmultiwindowwindow.c: (winMinimizeWindow):
+ * winmultiwindowwm.c: (PushMessage), (UpdateName),
+ (PreserveWin32Stack), (winMultiWindowWMProc),
+ (winMultiWindowXMsgProc), (winInitWM), (winInitMultiWindowWM),
+ (CheckAnotherWindowManager):
+ * winprocarg.c: (winInitializeDefaultScreens),
+ (ddxProcessArgument):
+ * winscrinit.c: (winFinishScreenInitFB):
+ * wintrayicon.c: (winHandleIconMessage):
+ * winwin32rootless.c: (InitWin32RootlessEngine),
+ (winMWExtWMResizeFrame), (winMWExtWMRestackFrame),
+ (winMWExtWMStartDrawing), (winMWExtWMRootlessSwitchWindow),
+ (winMWExtWMSetNativeProperty):
+ * winwin32rootlesswindow.c: (winMWExtWMReorderWindows),
+ (winMWExtWMDecorateWindow), (winMWExtWMUpdateWindowDecoration),
+ (winIsInternalWMRunning), (winMWExtWMRestackWindows):
+ * winwin32rootlesswndproc.c: (winMWExtWMWindowProc):
+ * winwindow.h:
+ * winwndproc.c: (winWindowProc):
+ Add internalwm mode.
+
+2004-10-28 Alexander Gottwald <ago at freedesktop dot org>
+
+ * win.h:
+ add fRetryCreateSurface
+ * winshaddnl.c (winBltExposedRegionsShadowDDNL):
+ try to recreate the primary surface if it was lost
+ * winshaddnl.c (winCreatePrimarySurfaceShadowDDNL):
+ mark screen to retry creating the primary surface if it failed
+
+2004-10-23 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winconfig (winConfigFiles):
+ Simplify /etc/X11/font-dirs parsing
+
+2004-10-20 Alexander Gottwald <ago at freedesktop dot org>
+
+ * XWin.rc, winresource.h, winwndproc.c:
+ Add ShowCursor entry to tray menu
+
+2004-10-20 Alexander Gottwald <ago at freedesktop dot org>
+
+ * Imakefile:
+ Add ETCX11DIR to DEFINES
+ * InitOutput.c (InitOutput):
+ * winconfig.c (winConfigFiles) :
+ Add entries from /etc/X11/font-dirs to default fontpath
+
+2004-10-16 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winprocarg.c (winInitializeDefaultScreens, ddxProcessArgument):
+ * win.h:
+ Make multiple monitors default for -multiwindow and -mwextwm.
+ Added a flag to indicate if the user has overridden the multimonitor
+ settings. (Øyvind Harboe, Alexander Gottwald)
+
+2004-10-07 Torrey Lyons <torrey at freedesktop dot org>
+
+ * winscrinit.c:
+ Add compatibility with the generic rootless layer's new
+ DoReorderWindow function.
+
+2004-10-05 Alexander Gottwald <ago at freedesktop dot org>
+
+ * XWin.rc:
+ Set the dialogstyle to DS_CENTERMOUSE. Dialogs will now popup on the
+ monitor where the mouse is and not on the center of the whole desktop.
+
+2004-10-02 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmouse.c (winMouseProc):
+ Make sure buttons 1-3 are mouse buttons and wheel events are 4-5
+ Document code
+ Replace ErrorF with appropriate winMsg
+ use a symbolic name for the wheel event offset
+
+2004-10-01 Alexander Gottwald <ago at freedesktop dot org>
+
+ * wincreatewnd.c (winCreateBoundingWindowWindowed):
+ Do not adjust workarea if native windowmanager is used
+
+2004-09-22 Kensuke Matsuzaki
+
+ * winclipboardthread.c (winClipboardErrorHandler):
+ * winclipboardwndproc.c (winClipboardWindowProc):
+ * winclipboardxevents.c (winClipboardFlushXEvents):
+ Fix clipboard bug with unicode applications.
+
+2004-09-17 Torrey Lyons <torrey at freedesktop dot org>
+
+ * winscrinit.c: (winFinishScreenInitFB):
+ Bugzilla #1032: Make rootless acceleration functions compatible with
+ Damage.
+
+2004-09-16 Alexander Gottwald <ago at freedesktop dot org>
+
+ * wincreatewnd.c (winCreateBoundingWindowWindowed):
+ Remove code which prevented the use from specifying the window
+ size in nodecoration mode.
+
+2004-08-26 Chris B <news at sempermax dot com>
+
+ * win.h, winmessages.h:
+ Add defines for WM_XBUTTON
+ * winmouse.c (winMouseProc):
+ Query number of mouse buttons from windows.
+ * winmultiwindowwndproc.c (winTopLevelWindowProc):
+ * winwin32rootlesswndproc.c (winMWExtWMWindowProc):
+ * winwndproc.c (winWindowProc):
+ Handle WM_XBUTTON messages.
+
+2004-08-02 Kensuke Matsuzaki
+
+ * winclipboardthread.c winclipboardwndproc.c:
+ * winclipboardxevents.c winwin32rootlesswndproc.c:
+ Fix the bug that we can't copy & paste multi-byte string to
+ Unicode-base Windows application. Rename fUnicodeSupport to
+ fUseUnicode, because it don't mean wheather Windows support
+ Unicode or not.
+
+2004-07-31 Alexander Gottwald <ago at freedesktop dot org>
+
+ * win.h:
+ adjust prototype for winInitCmapPrivates to match Egberts change.
+
+2004-07-30 Egbert Eich <eich at freedesktop dot org>
+
+ * winallpriv.c: (winInitCmapPrivates):
+ test if colormap with index really exists in the list of
+ installed maps before using it.
+
+2004-07-09 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winconfig.c: Add entry for irish layout (ie)
+ * InitOutput.c, winerror.c, winglobals.c: rename g_fUseMsg to
+ g_fSilentFatalError
+ * InitOutput.c, winglobals.c, winprocarg.c: added commandline option
+ -silent-dup-error to allow silent termination if another instance of
+ XWin was found running
+
+2004-06-27 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winconfig.c: Add entry for us layout. This changes not much but
+ removes a strange error message about the unknown us layout.
+
+2004-06-24 Alexander Gottwald <ago at freedesktop dot org>
+
+ * InitOutput.c: Check for textmode mounted /tmp and print a warning
+
+2004-06-15 Harold Hunt <huntharo at msu dot edu>
+
+ * windialogs.c: Fix path to locally installed changelog for the About
+ dialog box.
+
+2004-05-27 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winpriv.c: Create win32 window if not already created
+ * winmultiwindowwindow.c: Export winCreateWindowWindow
+
+2004-05-27 Alexander Gottwald <ago at freedesktop dot org>
+
+ * win.h: Allow CYGDEBUG to defined in the Makefile
+ * winwindow.h: Allow CYGWINDOWING_DEBUG to defined in the Makefile
+
+2004-05-19 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmultiwindowicons.c (winInitGlobalIcons): Load the small default
+ icon too
+ * winprefs.h, winprefs.c (winOverrideDefaultIcon): Takes the iconsize
+ as parameter
+
+2004-05-19 Alexander Gottwald <ago at freedesktop dot org>
+
+ * win.h, winmultiwindowicons.c (winXIconToHICON): Takes iconsize
+ as parameter
+ * winglobals.c, winmultiwindowicons.c: Rename g_hiconX to g_hIconX.
+ Added new variable g_hSmallIconX for 16x16 icon.
+ * winwindow.h, winmultiwindowicons.c (winInitGlobalIcons): Inits the
+ global g_hIconX handles.
+ * winwindow.h, winmultiwindowicons.c (winDestroyIcon): Free the icon
+ without messing with the global icon handle.
+ * winmultiwindowicons.c (winSelectIcons): Generate a custom icon from
+ window settigns or set them to globals.
+ * winmultiwindowshape.c, winmultiwindowwindow.c, winwin32rootless.c,
+ winwin32rootlesswindow.c, winwin32rootlesswndproc.c: Remove
+ declaration of g_hiconX;
+ * winmultiwindowwindow.c (winCreateWindowsWindow),
+ winwin32rootless.c (winMWExtWMCreateFrame): Use winSelectIcons
+ to get the window icons. Set the small icon too.
+ * winmultiwindowwindow.c (winDestroyWindowsWindow),
+ winmultiwindowicons.c (winUpdateIcon),
+ winprefs.c (ReloadEnumWindowsProc),
+ winwin32rootlesswindow.c (winMWExtWMUpdateIcon),
+ winwin32rootless.c (winMWExtWMDestroyFrame): Use winDestroyIcon
+ to free the icon without destroying the global icon.
+
+2004-05-17 Alexander Gottwald <ago at freedesktop dot org>
+
+ * windialogs.c (winExitDlgProc, winAboutDlgProc),
+ winmultiwindowwndproc.c (winTopLevelWindowProc),
+ winwndproc.c (winWindowProc): Check if g_fSoftwareCursor is set
+ before calling ShowCursor.
+
+2004-05-09 Dan Wilks <Dan_Wilks at intuit dot com>
+
+ * winclipboard.h: Add extern prototypes for winDebug, winErrorFVerb
+ copied from winmsg.h.
+ * winclipboardinit.c (winFixClipboardChain): Post rather than send the
+ reinit message to the clipboard window. Sending the message caused,
+ or possibly just exacerbated an existing, race condition that would
+ cause the X server to hang when coming back from a remote desktop
+ session.
+ * winclipboardwndproc.c (winProcessXEventsTimeout): switch to new
+ logging api's.
+ * winclipboardwindproc.c (winClipboardWindowProc): switch to new
+ logging api's. Add some additional debug logging. Make best effort
+ to prevent our window appearing twice in the clipboard chain. Also
+ detect loops when they occur and try to behave in a reasonable way.
+
+# vim:ts=8:noexpandtab:encoding=utf8
diff --git a/nx-X11/programs/Xserver/hw/xwin/Imakefile b/nx-X11/programs/Xserver/hw/xwin/Imakefile
new file mode 100644
index 000000000..fe99f0853
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/Imakefile
@@ -0,0 +1,310 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xwin/Imakefile,v 1.18 2003/10/02 13:30:09 eich Exp $
+
+#include <Server.tmpl>
+
+EXTRADEFINES =
+
+#if HasShm
+SHMDEF = -DHAS_SHM
+#endif
+
+#ifdef cygwinArchitecture
+MMAPDEF = -DHAS_MMAP
+#endif
+
+#if defined(HasDevWindow) && HasDevWindows
+EXTRADEFINES += -DHAS_DEVWINDOWS
+#endif
+
+#if defined(RelocateProjectRoot) && RelocateProjectRoot
+EXTRADEFINES += -DRELOCATE_PROJECTROOT
+#endif
+
+#ifdef cygwinArchitecture
+EXTRADEFINES += -DREAD_FONTDIRS
+#endif
+
+#if defined(mingwArchitecture)
+PROJECT_NAME = Xming
+#elif defined(cygwinArchitecture)
+PROJECT_NAME = Cygwin/X
+#else
+PROJECT_NAME = Xorg
+#endif
+PROJECT_DEFINES = -DPROJECT_NAME="\"$(PROJECT_NAME)\""
+RC_PROJECT_DEFINES = -DPROJECT_NAME="\\\"$(PROJECT_NAME)\\\""
+EXTRA_DEFINES = $(PROJECT_DEFINES)
+
+#if BuildXWinClipboard
+SRCS_CLIPBOARD = \
+ winclipboardinit.c \
+ winclipboardtextconv.c \
+ winclipboardthread.c \
+ winclipboardunicode.c \
+ winclipboardwndproc.c \
+ winclipboardwrappers.c \
+ winclipboardxevents.c
+#endif
+
+#if GlxUseWindows
+SRCS_GLX_WINDOWS = \
+ winpriv.c
+#endif
+
+#if BuildXWinMultiWindow
+SRCS_MULTIWINDOW = \
+ winmultiwindowshape.c \
+ winmultiwindowwindow.c \
+ winmultiwindowwm.c \
+ winmultiwindowwndproc.c
+#endif
+
+#if BuildXWinMultiWindowExtWM
+SRCS_MULTIWINDOWEXTWM = \
+ winwin32rootless.c \
+ winwin32rootlesswindow.c \
+ winwin32rootlesswndproc.c \
+ winwindowswm.c
+#endif
+
+#if BuildXWinNativeGDI
+SRCS_NATIVEGDI = \
+ winclip.c \
+ winfillsp.c \
+ winfont.c \
+ wingc.c \
+ wingetsp.c \
+ winnativegdi.c \
+ winpixmap.c \
+ winpntwin.c \
+ winpolyline.c \
+ winpushpxl.c \
+ winrop.c \
+ winsetsp.c
+#endif
+
+#if BuildXWinPrimaryFB
+SRCS_PRIMARYFB = \
+ winpfbdd.c
+#endif
+
+#if BuildRandR
+SRCS_RANDR = \
+ winrandr.c
+#endif
+
+#if BuildXvExt
+SRCS_XV = \
+ winvideo.c
+#endif
+
+SRCS = InitInput.c \
+ InitOutput.c \
+ stubs.c \
+ winallpriv.c \
+ winauth.c \
+ winblock.c \
+ wincmap.c \
+ winconfig.c \
+ wincreatewnd.c \
+ wincursor.c \
+ windialogs.c \
+ winengine.c \
+ winerror.c \
+ winglobals.c \
+ winkeybd.c \
+ winkeyhook.c \
+ winmisc.c \
+ winmouse.c \
+ winmsg.c \
+ winmultiwindowclass.c \
+ winmultiwindowicons.c \
+ winprefs.c \
+ winprefslex.l \
+ winprefsyacc.y \
+ winprocarg.c \
+ winregistry.c \
+ winscrinit.c \
+ winshaddd.c \
+ winshadddnl.c \
+ winshadgdi.c \
+ wintrayicon.c \
+ winvalargs.c \
+ winwakeup.c \
+ winwindow.c \
+ winwndproc.c \
+ $(SRCS_CLIPBOARD) \
+ $(SRCS_GLX_WINDOWS) \
+ $(SRCS_MULTIWINDOW) \
+ $(SRCS_MULTIWINDOWEXTWM) \
+ $(SRCS_NATIVEGDI) \
+ $(SRCS_PRIMARYFB) \
+ $(SRCS_RANDR) \
+ $(SRCS_XV)
+
+winprefsyacc.c: winprefsyacc.y
+ bison -d -o winprefsyacc.c winprefsyacc.y
+
+winprefsyacc.h: winprefsyacc.c
+
+winprefslex.c: winprefsyacc.y winprefslex.l winprefsyacc.h
+ flex -i -owinprefslex.c winprefslex.l
+
+clean::
+ $(RM) winprefslex.c winprefsyacc.h winprefsyacc.c
+
+depend:: winprefslex.c winprefsyacc.h winprefsyacc.c
+
+#if BuildXWinClipboard
+OBJS_CLIPBOARD = \
+ winclipboardinit.o \
+ winclipboardtextconv.o \
+ winclipboardthread.o \
+ winclipboardunicode.o \
+ winclipboardwndproc.o \
+ winclipboardwrappers.o \
+ winclipboardxevents.o
+#endif
+
+#if GlxUseWindows
+OBJS_GLX_WINDOWS = \
+ winpriv.o
+#endif
+
+#if BuildXWinMultiWindow
+OBJS_MULTIWINDOW = \
+ winmultiwindowshape.o \
+ winmultiwindowwindow.o \
+ winmultiwindowwm.o \
+ winmultiwindowwndproc.o
+#endif
+
+#if BuildXWinMultiWindowExtWM
+OBJS_MULTIWINDOWEXTWM = \
+ winwin32rootless.o \
+ winwin32rootlesswindow.o \
+ winwin32rootlesswndproc.o \
+ winwindowswm.o
+#endif
+
+#if BuildXWinNativeGDI
+OBJS_NATIVEGDI = \
+ winclip.o \
+ winfillsp.o \
+ winfont.o \
+ wingc.o \
+ wingetsp.o \
+ winnativegdi.o \
+ winpixmap.o \
+ winpntwin.o \
+ winpolyline.o \
+ winpushpxl.o \
+ winrop.o \
+ winsetsp.o
+#endif
+
+#if BuildXWinPrimaryFB
+OBJS_PRIMARYFB = \
+ winpfbdd.o
+#endif
+
+#if BuildRandR
+OBJS_RANDR = \
+ winrandr.o
+#endif
+
+#if BuildXvExt
+OBJS_XV = \
+ winvideo.o
+#endif
+
+OBJS = InitInput.o \
+ InitOutput.o \
+ stubs.o \
+ winallpriv.o \
+ winauth.o \
+ winblock.o \
+ wincmap.o \
+ winconfig.o \
+ wincreatewnd.o \
+ wincursor.o \
+ windialogs.o \
+ winengine.o \
+ winerror.o \
+ winglobals.o \
+ winkeybd.o \
+ winkeyhook.o \
+ winmisc.o \
+ winmouse.o \
+ winmsg.o \
+ winmultiwindowclass.o \
+ winmultiwindowicons.o \
+ winprefs.o \
+ winprefslex.o \
+ winprefsyacc.o \
+ winprocarg.o \
+ winregistry.o \
+ winscrinit.o \
+ winshaddd.o \
+ winshadddnl.o \
+ winshadgdi.o \
+ wintrayicon.o \
+ winvalargs.o \
+ winwakeup.o \
+ winwindow.o \
+ winwndproc.o \
+ $(OBJS_CLIPBOARD) \
+ $(OBJS_GLX_WINDOWS) \
+ $(OBJS_MULTIWINDOW) \
+ $(OBJS_MULTIWINDOWEXTWM) \
+ $(OBJS_NATIVEGDI) \
+ $(OBJS_PRIMARYFB) \
+ $(OBJS_RANDR) \
+ $(OBJS_XV)
+
+INCLUDES = -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
+ -I$(SERVERSRC)/fb -I$(SERVERSRC)/mi \
+ -I$(SERVERSRC)/miext/shadow \
+ -I$(SERVERSRC)/miext/rootless \
+ -I$(SERVERSRC)/miext/rootless/safeAlpha \
+ -I$(SERVERSRC)/include -I$(SERVERSRC)/os \
+ -I$(EXTINCSRC) -I$(XINCLUDESRC) \
+ -I$(SERVERSRC)/render -I$(SERVERSRC)/randr \
+ -I$(WINDOWSWMLIBSRC)
+
+#ifdef XVendorString
+VENDORSTRING = XVendorString
+ VENDOR_STRING = -DVENDOR_STRING=\"$(VENDORSTRING)\"
+#endif
+
+#ifdef XVendorContact
+VENDORCONTACT = XVendorContact
+ VENDOR_CONTACT = -DVENDOR_CONTACT=\"$(VENDORCONTACT)\"
+#endif
+
+#ifdef CygxVersionString
+CYGXVERSIONSTRING = CygxVersionString
+ VERSION_STRING = -DVERSION_STRING=\"$(CYGXVERSIONSTRING)\"
+#endif
+
+VENDOR_DEFINES = $(VENDOR_STRING) $(VENDOR_CONTACT) $(VERSION_STRING)
+
+DEFINES = $(OS_DEFINES) $(SHMDEF) $(MMAPDEF) $(EXTRADEFINES) \
+ -DPROJECTROOT="\"$(PROJECTROOT)\"" -DETCX11DIR="\"$(ETCX11DIR)\""
+
+LinkSourceFile(stubs.c,$(SERVERSRC)/Xi)
+SpecialCObjectRule(stubs,$(ICONFIGFILES),$(EXT_DEFINES))
+
+SpecialCObjectRule(winerror,$(ICONFIGFILES),$(DEFINES) $(VENDOR_DEFINES))
+SpecialCObjectRule(winprocarg,$(ICONFIGFILES),$(DEFINES) $(VENDOR_DEFINES))
+
+/* Build the Windows resource file (contains the program icon, etc.) */
+ResourceObjectRule(XWin,X.ico X-boxed.ico,$(RC_PROJECT_DEFINES))
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(XWin,$(OBJS))
+
+InstallManPage(XWin,$(MANDIR))
+InstallManPage(XWinrc,$(MANDIR))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/hw/xwin/InitInput.c b/nx-X11/programs/Xserver/hw/xwin/InitInput.c
new file mode 100644
index 000000000..8b72416ab
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/InitInput.c
@@ -0,0 +1,204 @@
+/* $TOG: InitInput.c /main/12 1998/02/10 13:23:52 kaleb $ */
+/*
+
+ Copyright 1993, 1998 The Open Group
+
+ Permission to use, copy, modify, distribute, and sell this software and its
+ documentation for any purpose is hereby granted without fee, provided that
+ the above copyright notice appear in all copies and that both that
+ copyright notice and this permission notice appear in supporting
+ documentation.
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name of The Open Group shall
+ not be used in advertising or otherwise to promote the sale, use or
+ other dealings in this Software without prior written authorization
+ from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xwin/InitInput.c,v 1.11 2002/07/05 09:19:25 alanh Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#ifdef XWIN_CLIPBOARD
+# include "../../Xext/xf86miscproc.h"
+#endif
+#include "dixstruct.h"
+
+
+/*
+ * Local function prototypes
+ */
+
+#ifdef XWIN_CLIPBOARD
+DISPATCH_PROC(winProcEstablishConnection);
+DISPATCH_PROC(winProcQueryTree);
+DISPATCH_PROC(winProcSetSelectionOwner);
+#endif
+
+
+/*
+ * Local global declarations
+ */
+
+CARD32 g_c32LastInputEventTime = 0;
+
+
+/*
+ * References to external symbols
+ */
+
+#ifdef HAS_DEVWINDOWS
+extern int g_fdMessageQueue;
+#endif
+extern Bool g_fXdmcpEnabled;
+#ifdef XWIN_CLIPBOARD
+extern winDispatchProcPtr winProcEstablishConnectionOrig;
+extern winDispatchProcPtr winProcQueryTreeOrig;
+#endif
+
+
+/* Called from dix/devices.c */
+/*
+ * All of our keys generate up and down transition notifications,
+ * so all of our keys can be used as modifiers.
+ *
+ * An example of a modifier is mapping the A key to the Control key.
+ * A has to be a legal modifier. I think.
+ */
+
+Bool
+LegalModifier (unsigned int uiKey, DevicePtr pDevice)
+{
+ return TRUE;
+}
+
+
+/* Called from dix/dispatch.c */
+/*
+ * Run through the Windows message queue(s) one more time.
+ * Tell mi to dequeue the events that we have sent it.
+ */
+void
+ProcessInputEvents (void)
+{
+#if 0
+ ErrorF ("ProcessInputEvents\n");
+#endif
+
+ mieqProcessInputEvents ();
+ miPointerUpdate ();
+
+#if 0
+ ErrorF ("ProcessInputEvents - returning\n");
+#endif
+}
+
+
+int
+TimeSinceLastInputEvent ()
+{
+ if (g_c32LastInputEventTime == 0)
+ g_c32LastInputEventTime = GetTickCount ();
+ return GetTickCount () - g_c32LastInputEventTime;
+}
+
+
+/* See Porting Layer Definition - p. 17 */
+void
+InitInput (int argc, char *argv[])
+{
+ DeviceIntPtr pMouse, pKeyboard;
+
+#if CYGDEBUG
+ winDebug ("InitInput\n");
+#endif
+
+#ifdef XWIN_CLIPBOARD
+ /*
+ * Wrap some functions at every generation of the server.
+ */
+ if (InitialVector[2] != winProcEstablishConnection)
+ {
+ winProcEstablishConnectionOrig = InitialVector[2];
+ InitialVector[2] = winProcEstablishConnection;
+ }
+ if (g_fXdmcpEnabled
+ && ProcVector[X_QueryTree] != winProcQueryTree)
+ {
+ winProcQueryTreeOrig = ProcVector[X_QueryTree];
+ ProcVector[X_QueryTree] = winProcQueryTree;
+ }
+#endif
+
+ pMouse = AddInputDevice (winMouseProc, TRUE);
+ pKeyboard = AddInputDevice (winKeybdProc, TRUE);
+
+ RegisterPointerDevice (pMouse);
+ RegisterKeyboardDevice (pKeyboard);
+
+ miRegisterPointerDevice (screenInfo.screens[0], pMouse);
+ mieqInit ((DevicePtr)pKeyboard, (DevicePtr)pMouse);
+
+ /* Initialize the mode key states */
+ winInitializeModeKeyStates ();
+
+#ifdef HAS_DEVWINDOWS
+ /* Only open the windows message queue device once */
+ if (g_fdMessageQueue == WIN_FD_INVALID)
+ {
+ /* Open a file descriptor for the Windows message queue */
+ g_fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, O_RDONLY);
+
+ if (g_fdMessageQueue == -1)
+ {
+ FatalError ("InitInput - Failed opening %s\n",
+ WIN_MSG_QUEUE_FNAME);
+ }
+
+ /* Add the message queue as a device to wait for in WaitForSomething */
+ AddEnabledDevice (g_fdMessageQueue);
+ }
+#endif
+
+#if CYGDEBUG
+ winDebug ("InitInput - returning\n");
+#endif
+}
+
+
+#ifdef XTESTEXT1
+void
+XTestGenerateEvent (int dev_type, int keycode, int keystate,
+ int mousex, int mousey)
+{
+ ErrorF ("XTestGenerateEvent\n");
+}
+
+
+void
+XTestGetPointerPos (short *fmousex, short *fmousey)
+{
+ ErrorF ("XTestGetPointerPos\n");
+}
+
+
+void
+XTestJumpPointer (int jx, int jy, int dev_type)
+{
+ ErrorF ("XTestJumpPointer\n");
+}
+#endif
+
diff --git a/nx-X11/programs/Xserver/hw/xwin/InitOutput.c b/nx-X11/programs/Xserver/hw/xwin/InitOutput.c
new file mode 100644
index 000000000..c5242cc6f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/InitOutput.c
@@ -0,0 +1,1172 @@
+/* $TOG: InitOutput.c /main/20 1998/02/10 13:23:56 kaleb $ */
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xwin/InitOutput.c,v 1.34 2003/10/02 13:30:09 eich Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winmsg.h"
+#include "winconfig.h"
+#include "winprefs.h"
+#ifdef XWIN_CLIPBOARD
+#include "X11/Xlocale.h"
+#endif
+#ifdef DPMSExtension
+#include "dpmsproc.h"
+#endif
+#ifdef __CYGWIN__
+#include <mntent.h>
+#endif
+#if defined(XKB) && defined(WIN32)
+#include <X11/extensions/XKBsrv.h>
+#endif
+#ifdef RELOCATE_PROJECTROOT
+#include <shlobj.h>
+typedef HRESULT (*SHGETFOLDERPATHPROC)(
+ HWND hwndOwner,
+ int nFolder,
+ HANDLE hToken,
+ DWORD dwFlags,
+ LPTSTR pszPath
+);
+#endif
+
+
+/*
+ * References to external symbols
+ */
+
+extern int g_iNumScreens;
+extern winScreenInfo g_ScreenInfo[];
+extern int g_iLastScreen;
+extern char * g_pszCommandLine;
+extern Bool g_fSilentFatalError;
+
+extern char * g_pszLogFile;
+extern Bool g_fLogFileChanged;
+extern int g_iLogVerbose;
+Bool g_fLogInited;
+
+extern Bool g_fXdmcpEnabled;
+#ifdef HAS_DEVWINDOWS
+extern int g_fdMessageQueue;
+#endif
+extern const char * g_pszQueryHost;
+extern HINSTANCE g_hInstance;
+
+#ifdef XWIN_CLIPBOARD
+extern Bool g_fUnicodeClipboard;
+extern Bool g_fClipboardLaunched;
+extern Bool g_fClipboardStarted;
+extern pthread_t g_ptClipboardProc;
+extern HWND g_hwndClipboard;
+extern Bool g_fClipboard;
+#endif
+
+extern HMODULE g_hmodDirectDraw;
+extern FARPROC g_fpDirectDrawCreate;
+extern FARPROC g_fpDirectDrawCreateClipper;
+
+extern HMODULE g_hmodCommonControls;
+extern FARPROC g_fpTrackMouseEvent;
+extern Bool g_fNoHelpMessageBox;
+extern Bool g_fSilentDupError;
+
+
+/*
+ * Function prototypes
+ */
+
+#ifdef XWIN_CLIPBOARD
+static void
+winClipboardShutdown (void);
+#endif
+
+#if defined(DDXOSVERRORF)
+void
+OsVendorVErrorF (const char *pszFormat, va_list va_args);
+#endif
+
+void
+winInitializeDefaultScreens (void);
+
+static Bool
+winCheckDisplayNumber (void);
+
+void
+winLogCommandLine (int argc, char *argv[]);
+
+void
+winLogVersionInfo (void);
+
+Bool
+winValidateArgs (void);
+
+#ifdef RELOCATE_PROJECTROOT
+const char *
+winGetBaseDir(void);
+#endif
+
+/*
+ * For the depth 24 pixmap we default to 32 bits per pixel, but
+ * we change this pixmap format later if we detect that the display
+ * is going to be running at 24 bits per pixel.
+ *
+ * FIXME: On second thought, don't DIBs only support 32 bits per pixel?
+ * DIBs are the underlying bitmap used for DirectDraw surfaces, so it
+ * seems that all pixmap formats with depth 24 would be 32 bits per pixel.
+ * Confirm whether depth 24 DIBs can have 24 bits per pixel, then remove/keep
+ * the bits per pixel adjustment and update this comment to reflect the
+ * situation. Harold Hunt - 2002/07/02
+ */
+
+static PixmapFormatRec g_PixmapFormats[] = {
+ { 1, 1, BITMAP_SCANLINE_PAD },
+ { 4, 8, BITMAP_SCANLINE_PAD },
+ { 8, 8, BITMAP_SCANLINE_PAD },
+ { 15, 16, BITMAP_SCANLINE_PAD },
+ { 16, 16, BITMAP_SCANLINE_PAD },
+ { 24, 32, BITMAP_SCANLINE_PAD },
+#ifdef RENDER
+ { 32, 32, BITMAP_SCANLINE_PAD }
+#endif
+};
+
+const int NUMFORMATS = sizeof (g_PixmapFormats) / sizeof (g_PixmapFormats[0]);
+
+#ifdef XWIN_CLIPBOARD
+static void
+winClipboardShutdown (void)
+{
+ /* Close down clipboard resources */
+ if (g_fClipboard && g_fClipboardLaunched && g_fClipboardStarted)
+ {
+ /* Synchronously destroy the clipboard window */
+ if (g_hwndClipboard != NULL)
+ {
+ SendMessage (g_hwndClipboard, WM_DESTROY, 0, 0);
+ /* NOTE: g_hwndClipboard is set to NULL in winclipboardthread.c */
+ }
+ else
+ return;
+
+ /* Wait for the clipboard thread to exit */
+ pthread_join (g_ptClipboardProc, NULL);
+
+ g_fClipboardLaunched = FALSE;
+ g_fClipboardStarted = FALSE;
+
+ winDebug ("winClipboardShutdown - Clipboard thread has exited.\n");
+ }
+}
+#endif
+
+
+#if defined(DDXBEFORERESET)
+/*
+ * Called right before KillAllClients when the server is going to reset,
+ * allows us to shutdown our seperate threads cleanly.
+ */
+
+void
+ddxBeforeReset (void)
+{
+ winDebug ("ddxBeforeReset - Hello\n");
+
+#ifdef XWIN_CLIPBOARD
+ winClipboardShutdown ();
+#endif
+}
+#endif
+
+
+/* See Porting Layer Definition - p. 57 */
+void
+ddxGiveUp (void)
+{
+ int i;
+
+#if CYGDEBUG
+ winDebug ("ddxGiveUp\n");
+#endif
+
+ /* Perform per-screen deinitialization */
+ for (i = 0; i < g_iNumScreens; ++i)
+ {
+ /* Delete the tray icon */
+ if (!g_ScreenInfo[i].fNoTrayIcon && g_ScreenInfo[i].pScreen)
+ winDeleteNotifyIcon (winGetScreenPriv (g_ScreenInfo[i].pScreen));
+ }
+
+#ifdef XWIN_MULTIWINDOW
+ /* Notify the worker threads we're exiting */
+ winDeinitMultiWindowWM ();
+#endif
+
+#ifdef HAS_DEVWINDOWS
+ /* Close our handle to our message queue */
+ if (g_fdMessageQueue != WIN_FD_INVALID)
+ {
+ /* Close /dev/windows */
+ close (g_fdMessageQueue);
+
+ /* Set the file handle to invalid */
+ g_fdMessageQueue = WIN_FD_INVALID;
+ }
+#endif
+
+ if (!g_fLogInited) {
+ LogInit (g_pszLogFile, NULL);
+ g_fLogInited = TRUE;
+ }
+ LogClose ();
+
+ /*
+ * At this point we aren't creating any new screens, so
+ * we are guaranteed to not need the DirectDraw functions.
+ */
+ if (g_hmodDirectDraw != NULL)
+ {
+ FreeLibrary (g_hmodDirectDraw);
+ g_hmodDirectDraw = NULL;
+ g_fpDirectDrawCreate = NULL;
+ g_fpDirectDrawCreateClipper = NULL;
+ }
+
+ /* Unload our TrackMouseEvent funtion pointer */
+ if (g_hmodCommonControls != NULL)
+ {
+ FreeLibrary (g_hmodCommonControls);
+ g_hmodCommonControls = NULL;
+ g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
+ }
+
+ /* Free concatenated command line */
+ if (g_pszCommandLine)
+ {
+ free (g_pszCommandLine);
+ g_pszCommandLine = NULL;
+ }
+
+ /* Remove our keyboard hook if it is installed */
+ winRemoveKeyboardHookLL ();
+
+ /* Tell Windows that we want to end the app */
+ PostQuitMessage (0);
+}
+
+
+/* See Porting Layer Definition - p. 57 */
+void
+AbortDDX (void)
+{
+#if CYGDEBUG
+ winDebug ("AbortDDX\n");
+#endif
+ ddxGiveUp ();
+}
+
+#ifdef __CYGWIN__
+/* hasmntopt is currently not implemented for cygwin */
+static const char *winCheckMntOpt(const struct mntent *mnt, const char *opt)
+{
+ const char *s;
+ size_t len;
+ if (mnt == NULL)
+ return NULL;
+ if (opt == NULL)
+ return NULL;
+ if (mnt->mnt_opts == NULL)
+ return NULL;
+
+ len = strlen(opt);
+ s = strstr(mnt->mnt_opts, opt);
+ if (s == NULL)
+ return NULL;
+ if ((s == mnt->mnt_opts || *(s-1) == ',') && (s[len] == 0 || s[len] == ','))
+ return (char *)opt;
+ return NULL;
+}
+
+static void
+winCheckMount(void)
+{
+ FILE *mnt;
+ struct mntent *ent;
+
+ enum { none = 0, sys_root, user_root, sys_tmp, user_tmp }
+ level = none, curlevel;
+ BOOL binary = TRUE;
+
+ mnt = setmntent("/etc/mtab", "r");
+ if (mnt == NULL)
+ {
+ ErrorF("setmntent failed");
+ return;
+ }
+
+ while ((ent = getmntent(mnt)) != NULL)
+ {
+ BOOL system = (strcmp(ent->mnt_type, "system") == 0);
+ BOOL root = (strcmp(ent->mnt_dir, "/") == 0);
+ BOOL tmp = (strcmp(ent->mnt_dir, "/tmp") == 0);
+
+ if (system)
+ {
+ if (root)
+ curlevel = sys_root;
+ else if (tmp)
+ curlevel = sys_tmp;
+ else
+ continue;
+ }
+ else
+ {
+ if (root)
+ curlevel = user_root;
+ else if (tmp)
+ curlevel = user_tmp;
+ else
+ continue;
+ }
+
+ if (curlevel <= level)
+ continue;
+ level = curlevel;
+
+ if (winCheckMntOpt(ent, "binmode") == NULL)
+ binary = 0;
+ else
+ binary = 1;
+ }
+
+ if (endmntent(mnt) != 1)
+ {
+ ErrorF("endmntent failed");
+ return;
+ }
+
+ if (!binary)
+ winMsg(X_WARNING, "/tmp mounted int textmode\n");
+}
+#else
+static void
+winCheckMount(void)
+{
+}
+#endif
+
+#ifdef RELOCATE_PROJECTROOT
+const char *
+winGetBaseDir(void)
+{
+ static BOOL inited = FALSE;
+ static char buffer[MAX_PATH];
+ if (!inited)
+ {
+ char *fendptr;
+ HMODULE module = GetModuleHandle(NULL);
+ DWORD size = GetModuleFileName(module, buffer, sizeof(buffer));
+ if (sizeof(buffer) > 0)
+ buffer[sizeof(buffer)-1] = 0;
+
+ fendptr = buffer + size;
+ while (fendptr > buffer)
+ {
+ if (*fendptr == '\\' || *fendptr == '/')
+ {
+ *fendptr = 0;
+ break;
+ }
+ fendptr--;
+ }
+ inited = TRUE;
+ }
+ return buffer;
+}
+#endif
+
+static void
+winFixupPaths (void)
+{
+ BOOL changed_fontpath = FALSE;
+ MessageType font_from = X_DEFAULT;
+#ifdef RELOCATE_PROJECTROOT
+ const char *basedir = winGetBaseDir();
+ size_t basedirlen = strlen(basedir);
+#endif
+
+#ifdef READ_FONTDIRS
+ {
+ /* Open fontpath configuration file */
+ FILE *fontdirs = fopen(ETCX11DIR "/font-dirs", "rt");
+ if (fontdirs != NULL)
+ {
+ char buffer[256];
+ int needs_sep = TRUE;
+ int comment_block = FALSE;
+
+ /* get defautl fontpath */
+ char *fontpath = xstrdup(defaultFontPath);
+ size_t size = strlen(fontpath);
+
+ /* read all lines */
+ while (!feof(fontdirs))
+ {
+ size_t blen;
+ char *hashchar;
+ char *str;
+ int has_eol = FALSE;
+
+ /* read one line */
+ str = fgets(buffer, sizeof(buffer), fontdirs);
+ if (str == NULL) /* stop on error or eof */
+ break;
+
+ if (strchr(str, '\n') != NULL)
+ has_eol = TRUE;
+
+ /* check if block is continued comment */
+ if (comment_block)
+ {
+ /* ignore all input */
+ *str = 0;
+ blen = 0;
+ if (has_eol) /* check if line ended in this block */
+ comment_block = FALSE;
+ }
+ else
+ {
+ /* find comment character. ignore all trailing input */
+ hashchar = strchr(str, '#');
+ if (hashchar != NULL)
+ {
+ *hashchar = 0;
+ if (!has_eol) /* mark next block as continued comment */
+ comment_block = TRUE;
+ }
+ }
+
+ /* strip whitespaces from beginning */
+ while (*str == ' ' || *str == '\t')
+ str++;
+
+ /* get size, strip whitespaces from end */
+ blen = strlen(str);
+ while (blen > 0 && (str[blen-1] == ' ' ||
+ str[blen-1] == '\t' || str[blen-1] == '\n'))
+ {
+ str[--blen] = 0;
+ }
+
+ /* still something left to add? */
+ if (blen > 0)
+ {
+ size_t newsize = size + blen;
+ /* reserve one character more for ',' */
+ if (needs_sep)
+ newsize++;
+
+ /* allocate memory */
+ if (fontpath == NULL)
+ fontpath = malloc(newsize+1);
+ else
+ fontpath = realloc(fontpath, newsize+1);
+
+ /* add separator */
+ if (needs_sep)
+ {
+ fontpath[size] = ',';
+ size++;
+ needs_sep = FALSE;
+ }
+
+ /* mark next line as new entry */
+ if (has_eol)
+ needs_sep = TRUE;
+
+ /* add block */
+ strncpy(fontpath + size, str, blen);
+ fontpath[newsize] = 0;
+ size = newsize;
+ }
+ }
+
+ /* cleanup */
+ fclose(fontdirs);
+ defaultFontPath = xstrdup(fontpath);
+ free(fontpath);
+ changed_fontpath = TRUE;
+ font_from = X_CONFIG;
+ }
+ }
+#endif /* READ_FONTDIRS */
+#ifdef RELOCATE_PROJECTROOT
+ {
+ const char *libx11dir = PROJECTROOT "/lib/X11";
+ size_t libx11dir_len = strlen(libx11dir);
+ char *newfp = NULL;
+ size_t newfp_len = 0;
+ const char *endptr, *ptr, *oldptr = defaultFontPath;
+
+ endptr = oldptr + strlen(oldptr);
+ ptr = strchr(oldptr, ',');
+ if (ptr == NULL)
+ ptr = endptr;
+ while (ptr != NULL)
+ {
+ size_t oldfp_len = (ptr - oldptr);
+ size_t newsize = oldfp_len;
+ char *newpath = malloc(newsize + 1);
+ strncpy(newpath, oldptr, newsize);
+ newpath[newsize] = 0;
+
+
+ if (strncmp(libx11dir, newpath, libx11dir_len) == 0)
+ {
+ char *compose;
+ newsize = newsize - libx11dir_len + basedirlen;
+ compose = malloc(newsize + 1);
+ strcpy(compose, basedir);
+ strncat(compose, newpath + libx11dir_len, newsize - basedirlen);
+ compose[newsize] = 0;
+ free(newpath);
+ newpath = compose;
+ }
+
+ oldfp_len = newfp_len;
+ if (oldfp_len > 0)
+ newfp_len ++; /* space for separator */
+ newfp_len += newsize;
+
+ if (newfp == NULL)
+ newfp = malloc(newfp_len + 1);
+ else
+ newfp = realloc(newfp, newfp_len + 1);
+
+ if (oldfp_len > 0)
+ {
+ strcpy(newfp + oldfp_len, ",");
+ oldfp_len++;
+ }
+ strcpy(newfp + oldfp_len, newpath);
+
+ free(newpath);
+
+ if (*ptr == 0)
+ {
+ oldptr = ptr;
+ ptr = NULL;
+ } else
+ {
+ oldptr = ptr + 1;
+ ptr = strchr(oldptr, ',');
+ if (ptr == NULL)
+ ptr = endptr;
+ }
+ }
+
+ defaultFontPath = xstrdup(newfp);
+ free(newfp);
+ changed_fontpath = TRUE;
+ }
+#endif /* RELOCATE_PROJECTROOT */
+ if (changed_fontpath)
+ winMsg (font_from, "FontPath set to \"%s\"\n", defaultFontPath);
+
+#ifdef RELOCATE_PROJECTROOT
+ if (1) {
+ const char *libx11dir = "/usr/X11R6/lib/X11";
+ size_t libx11dir_len = strlen(libx11dir);
+
+ if (strncmp(libx11dir, rgbPath, libx11dir_len) == 0)
+ {
+ size_t newsize = strlen(rgbPath) - libx11dir_len + basedirlen;
+ char *compose = malloc(newsize + 1);
+ strcpy(compose, basedir);
+ strcat(compose, rgbPath + libx11dir_len);
+ compose[newsize] = 0;
+ rgbPath = xstrdup (compose);
+ free (compose);
+
+ winMsg (X_DEFAULT, "RgbPath set to \"%s\"\n", rgbPath);
+ }
+ }
+
+ if (getenv("XKEYSYMDB") == NULL)
+ {
+ char buffer[MAX_PATH];
+ snprintf(buffer, sizeof(buffer), "XKEYSYMDB=%s\\XKeysymDB",
+ basedir);
+ buffer[sizeof(buffer)-1] = 0;
+ putenv(buffer);
+ }
+ if (getenv("XERRORDB") == NULL)
+ {
+ char buffer[MAX_PATH];
+ snprintf(buffer, sizeof(buffer), "XERRORDB=%s\\XErrorDB",
+ basedir);
+ buffer[sizeof(buffer)-1] = 0;
+ putenv(buffer);
+ }
+ if (getenv("XLOCALEDIR") == NULL)
+ {
+ char buffer[MAX_PATH];
+ snprintf(buffer, sizeof(buffer), "XLOCALEDIR=%s\\locale",
+ basedir);
+ buffer[sizeof(buffer)-1] = 0;
+ putenv(buffer);
+ }
+ if (getenv("HOME") == NULL)
+ {
+ HMODULE shfolder;
+ SHGETFOLDERPATHPROC shgetfolderpath = NULL;
+ char buffer[MAX_PATH + 5];
+ strncpy(buffer, "HOME=", 5);
+
+ /* Try to load SHGetFolderPath from shfolder.dll and shell32.dll */
+
+ shfolder = LoadLibrary("shfolder.dll");
+ /* fallback to shell32.dll */
+ if (shfolder == NULL)
+ shfolder = LoadLibrary("shell32.dll");
+
+ /* resolve SHGetFolderPath */
+ if (shfolder != NULL)
+ shgetfolderpath = (SHGETFOLDERPATHPROC)GetProcAddress(shfolder, "SHGetFolderPathA");
+
+ /* query appdata directory */
+ if (shgetfolderpath &&
+ shgetfolderpath(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0,
+ buffer + 5) == 0)
+ {
+ putenv(buffer);
+ } else
+ {
+ winMsg (X_ERROR, "Can not determine HOME directory\n");
+ }
+ if (shfolder != NULL)
+ FreeLibrary(shfolder);
+ }
+ if (!g_fLogFileChanged) {
+ static char buffer[MAX_PATH];
+ DWORD size = GetTempPath(sizeof(buffer), buffer);
+ if (size && size < sizeof(buffer))
+ {
+ snprintf(buffer + size, sizeof(buffer) - size,
+ "XWin.%s.log", display);
+ buffer[sizeof(buffer)-1] = 0;
+ g_pszLogFile = buffer;
+ winMsg (X_DEFAULT, "Logfile set to \"%s\"\n", g_pszLogFile);
+ }
+ }
+#ifdef XKB
+ {
+ static char xkbbasedir[MAX_PATH];
+
+ snprintf(xkbbasedir, sizeof(xkbbasedir), "%s\\xkb", basedir);
+ if (sizeof(xkbbasedir) > 0)
+ xkbbasedir[sizeof(xkbbasedir)-1] = 0;
+ XkbBaseDirectory = xkbbasedir;
+ }
+#endif /* XKB */
+#endif /* RELOCATE_PROJECTROOT */
+}
+
+void
+OsVendorInit (void)
+{
+ /* Re-initialize global variables on server reset */
+ winInitializeGlobals ();
+
+ LogInit (NULL, NULL);
+ LogSetParameter (XLOG_VERBOSITY, g_iLogVerbose);
+
+ winFixupPaths();
+
+#ifdef DDXOSVERRORF
+ if (!OsVendorVErrorFProc)
+ OsVendorVErrorFProc = OsVendorVErrorF;
+#endif
+
+ if (!g_fLogInited) {
+ /* keep this order. If LogInit fails it calls Abort which then calls
+ * ddxGiveUp where LogInit is called again and creates an infinite
+ * recursion. If we set g_fLogInited to TRUE before the init we
+ * avoid the second call
+ */
+ g_fLogInited = TRUE;
+ LogInit (g_pszLogFile, NULL);
+ }
+ LogSetParameter (XLOG_FLUSH, 1);
+ LogSetParameter (XLOG_VERBOSITY, g_iLogVerbose);
+ LogSetParameter (XLOG_FILE_VERBOSITY, 1);
+
+ /* Log the version information */
+ if (serverGeneration == 1)
+ winLogVersionInfo ();
+
+ winCheckMount();
+
+ /* Add a default screen if no screens were specified */
+ if (g_iNumScreens == 0)
+ {
+ winDebug ("OsVendorInit - Creating bogus screen 0\n");
+
+ /*
+ * We need to initialize default screens if no arguments
+ * were processed. Otherwise, the default screens would
+ * already have been initialized by ddxProcessArgument ().
+ */
+ winInitializeDefaultScreens ();
+
+ /*
+ * Add a screen 0 using the defaults set by
+ * winInitializeDefaultScreens () and any additional parameters
+ * processed by ddxProcessArgument ().
+ */
+ g_iNumScreens = 1;
+ g_iLastScreen = 0;
+
+ /* We have to flag this as an explicit screen, even though it isn't */
+ g_ScreenInfo[0].fExplicitScreen = TRUE;
+ }
+}
+
+
+static void
+winUseMsg (void)
+{
+ ErrorF ("-depth bits_per_pixel\n"
+ "\tSpecify an optional bitdepth to use in fullscreen mode\n"
+ "\twith a DirectDraw engine.\n");
+
+ ErrorF ("-emulate3buttons [timeout]\n"
+ "\tEmulate 3 button mouse with an optional timeout in\n"
+ "\tmilliseconds.\n");
+
+ ErrorF ("-engine engine_type_id\n"
+ "\tOverride the server's automatically selected engine type:\n"
+ "\t\t1 - Shadow GDI\n"
+ "\t\t2 - Shadow DirectDraw\n"
+ "\t\t4 - Shadow DirectDraw4 Non-Locking\n"
+#ifdef XWIN_NATIVEGDI
+ "\t\t16 - Native GDI - experimental\n"
+#endif
+ );
+
+ ErrorF ("-fullscreen\n"
+ "\tRun the server in fullscreen mode.\n");
+
+ ErrorF ("-refresh rate_in_Hz\n"
+ "\tSpecify an optional refresh rate to use in fullscreen mode\n"
+ "\twith a DirectDraw engine.\n");
+
+ ErrorF ("-screen scr_num [width height [x y] | [[WxH[+X+Y]][@m]] ]\n"
+ "\tEnable screen scr_num and optionally specify a width and\n"
+ "\theight and initial position for that screen. Additionally\n"
+ "\ta monitor number can be specified to start the server on,\n"
+ "\tat which point, all coordinates become relative to that\n"
+ "\tmonitor (Not for Windows NT4 and 95). Examples:\n"
+ "\t -screen 0 800x600+100+100@2 ; 2nd monitor offset 100,100 size 800x600\n"
+ "\t -screen 0 1024x768@3 ; 3rd monitor size 1024x768\n"
+ "\t -screen 0 @1 ; on 1st monitor using its full resolution (the default)\n");
+
+ ErrorF ("-lesspointer\n"
+ "\tHide the windows mouse pointer when it is over an inactive\n"
+ "\t" PROJECT_NAME " window. This prevents ghost cursors appearing where\n"
+ "\tthe Windows cursor is drawn overtop of the X cursor\n");
+
+ ErrorF ("-nodecoration\n"
+ "\tDo not draw a window border, title bar, etc. Windowed\n"
+ "\tmode only.\n");
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ ErrorF ("-mwextwm\n"
+ "\tRun the server in multi-window external window manager mode.\n");
+
+ ErrorF ("-internalwm\n"
+ "\tRun the internal window manager.\n");
+#endif
+
+ ErrorF ("-rootless\n"
+ "\tRun the server in rootless mode.\n");
+
+#ifdef XWIN_MULTIWINDOW
+ ErrorF ("-multiwindow\n"
+ "\tRun the server in multi-window mode.\n");
+#endif
+
+ ErrorF ("-multiplemonitors\n"
+ "\tEXPERIMENTAL: Use the entire virtual screen if multiple\n"
+ "\tmonitors are present.\n");
+
+#ifdef XWIN_CLIPBOARD
+ ErrorF ("-clipboard\n"
+ "\tRun the clipboard integration module.\n"
+ "\tDo not use at the same time as 'xwinclip'.\n");
+
+ ErrorF ("-nounicodeclipboard\n"
+ "\tDo not use Unicode clipboard even if NT-based platform.\n");
+#endif
+
+ ErrorF ("-scrollbars\n"
+ "\tIn windowed mode, allow screens bigger than the Windows desktop.\n"
+ "\tMoreover, if the window has decorations, one can now resize\n"
+ "\tit.\n");
+
+ ErrorF ("-[no]trayicon\n"
+ "\tDo not create a tray icon. Default is to create one\n"
+ "\ticon per screen. You can globally disable tray icons with\n"
+ "\t-notrayicon, then enable it for specific screens with\n"
+ "\t-trayicon for those screens.\n");
+
+ ErrorF ("-clipupdates num_boxes\n"
+ "\tUse a clipping region to constrain shadow update blits to\n"
+ "\tthe updated region when num_boxes, or more, are in the\n"
+ "\tupdated region. Currently supported only by `-engine 1'.\n");
+
+#ifdef XWIN_EMULATEPSEUDO
+ ErrorF ("-emulatepseudo\n"
+ "\tCreate a depth 8 PseudoColor visual when running in\n"
+ "\tdepths 15, 16, 24, or 32, collectively known as TrueColor\n"
+ "\tdepths. The PseudoColor visual does not have correct colors,\n"
+ "\tand it may crash, but it at least allows you to run your\n"
+ "\tapplication in TrueColor modes.\n");
+#endif
+
+ ErrorF ("-[no]unixkill\n"
+ "\tCtrl+Alt+Backspace exits the X Server.\n");
+
+ ErrorF ("-[no]winkill\n"
+ "\tAlt+F4 exits the X Server.\n");
+
+#ifdef XWIN_XF86CONFIG
+ ErrorF ("-config\n"
+ "\tSpecify a configuration file.\n");
+
+ ErrorF ("-keyboard\n"
+ "\tSpecify a keyboard device from the configuration file.\n");
+#endif
+
+#ifdef XKB
+ ErrorF ("-xkbrules XKBRules\n"
+ "\tEquivalent to XKBRules in XF86Config files.\n");
+
+ ErrorF ("-xkbmodel XKBModel\n"
+ "\tEquivalent to XKBModel in XF86Config files.\n");
+
+ ErrorF ("-xkblayout XKBLayout\n"
+ "\tEquivalent to XKBLayout in XF86Config files.\n"
+ "\tFor example: -xkblayout de\n");
+
+ ErrorF ("-xkbvariant XKBVariant\n"
+ "\tEquivalent to XKBVariant in XF86Config files.\n"
+ "\tFor example: -xkbvariant nodeadkeys\n");
+
+ ErrorF ("-xkboptions XKBOptions\n"
+ "\tEquivalent to XKBOptions in XF86Config files.\n");
+#endif
+
+ ErrorF ("-logfile filename\n"
+ "\tWrite logmessages to <filename> instead of /tmp/Xwin.log.\n");
+
+ ErrorF ("-logverbose verbosity\n"
+ "\tSet the verbosity of logmessages. [NOTE: Only a few messages\n"
+ "\trespect the settings yet]\n"
+ "\t\t0 - only print fatal error.\n"
+ "\t\t1 - print additional configuration information.\n"
+ "\t\t2 - print additional runtime information [default].\n"
+ "\t\t3 - print debugging and tracing information.\n");
+
+ ErrorF ("-[no]keyhook\n"
+ "\tGrab special windows key combinations like Alt-Tab or the Menu "
+ "key.\n These keys are discarded by default.\n");
+
+ ErrorF ("-swcursor\n"
+ "\tDisable the usage of the windows cursor and use the X11 software "
+ "cursor instead\n");
+}
+
+/* See Porting Layer Definition - p. 57 */
+void
+ddxUseMsg(void)
+{
+ /* Set a flag so that FatalError won't give duplicate warning message */
+ g_fSilentFatalError = TRUE;
+
+ winUseMsg();
+
+ /* Log file will not be opened for UseMsg unless we open it now */
+ if (!g_fLogInited) {
+ LogInit (g_pszLogFile, NULL);
+ g_fLogInited = TRUE;
+ }
+ LogClose ();
+
+ /* Notify user where UseMsg text can be found.*/
+ if (!g_fNoHelpMessageBox)
+ winMessageBoxF ("The " PROJECT_NAME " help text has been printed to "
+ "/tmp/XWin.log.\n"
+ "Please open /tmp/XWin.log to read the help text.\n",
+ MB_ICONINFORMATION);
+}
+
+/* ddxInitGlobals - called by |InitGlobals| from os/util.c */
+void ddxInitGlobals(void)
+{
+}
+
+#ifdef DDXTIME /* from ServerOSDefines */
+CARD32
+GetTimeInMillis (void)
+{
+ return GetTickCount ();
+}
+#endif /* DDXTIME */
+
+
+/* See Porting Layer Definition - p. 20 */
+/*
+ * Do any global initialization, then initialize each screen.
+ *
+ * NOTE: We use ddxProcessArgument, so we don't need to touch argc and argv
+ */
+
+void
+InitOutput (ScreenInfo *screenInfo, int argc, char *argv[])
+{
+ int i;
+
+ /* Log the command line */
+ winLogCommandLine (argc, argv);
+
+#if CYGDEBUG
+ winDebug ("InitOutput\n");
+#endif
+
+ /* Validate command-line arguments */
+ if (serverGeneration == 1 && !winValidateArgs ())
+ {
+ FatalError ("InitOutput - Invalid command-line arguments found. "
+ "Exiting.\n");
+ }
+
+ /* Check for duplicate invocation on same display number.*/
+ if (serverGeneration == 1 && !winCheckDisplayNumber ())
+ {
+ if (g_fSilentDupError)
+ g_fSilentFatalError = TRUE;
+ FatalError ("InitOutput - Duplicate invocation on display "
+ "number: %s. Exiting.\n", display);
+ }
+
+#ifdef XWIN_XF86CONFIG
+ /* Try to read the xorg.conf-style configuration file */
+ if (!winReadConfigfile ())
+ winErrorFVerb (1, "InitOutput - Error reading config file\n");
+#else
+ winMsg(X_INFO, "XF86Config is not supported\n");
+ winMsg(X_INFO, "See http://x.cygwin.com/docs/faq/cygwin-x-faq.html "
+ "for more information\n");
+ winConfigFiles ();
+#endif
+
+ /* Load preferences from XWinrc file */
+ LoadPreferences();
+
+ /* Setup global screen info parameters */
+ screenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+ screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+ screenInfo->numPixmapFormats = NUMFORMATS;
+
+ /* Describe how we want common pixmap formats padded */
+ for (i = 0; i < NUMFORMATS; i++)
+ {
+ screenInfo->formats[i] = g_PixmapFormats[i];
+ }
+
+ /* Load pointers to DirectDraw functions */
+ winGetDDProcAddresses ();
+
+ /* Detect supported engines */
+ winDetectSupportedEngines ();
+
+ /* Load common controls library */
+ g_hmodCommonControls = LoadLibraryEx ("comctl32.dll", NULL, 0);
+
+ /* Load TrackMouseEvent function pointer */
+ g_fpTrackMouseEvent = GetProcAddress (g_hmodCommonControls,
+ "_TrackMouseEvent");
+ if (g_fpTrackMouseEvent == NULL)
+ {
+ winErrorFVerb (1, "InitOutput - Could not get pointer to function\n"
+ "\t_TrackMouseEvent in comctl32.dll. Try installing\n"
+ "\tInternet Explorer 3.0 or greater if you have not\n"
+ "\talready.\n");
+
+ /* Free the library since we won't need it */
+ FreeLibrary (g_hmodCommonControls);
+ g_hmodCommonControls = NULL;
+
+ /* Set function pointer to point to no operation function */
+ g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
+ }
+
+ /* Store the instance handle */
+ g_hInstance = GetModuleHandle (NULL);
+
+ /* Initialize each screen */
+ for (i = 0; i < g_iNumScreens; ++i)
+ {
+ /* Initialize the screen */
+ if (-1 == AddScreen (winScreenInit, argc, argv))
+ {
+ FatalError ("InitOutput - Couldn't add screen %d", i);
+ }
+ }
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+
+#if defined(XCSECURITY)
+ /* Generate a cookie used by internal clients for authorization */
+ if (g_fXdmcpEnabled)
+ winGenerateAuthorization ();
+#endif
+
+ /* Perform some one time initialization */
+ if (1 == serverGeneration)
+ {
+ /*
+ * setlocale applies to all threads in the current process.
+ * Apply locale specified in LANG environment variable.
+ */
+ setlocale (LC_ALL, "");
+ }
+#endif
+
+#if CYGDEBUG || YES
+ winDebug ("InitOutput - Returning.\n");
+#endif
+}
+
+
+/*
+ * winCheckDisplayNumber - Check if another instance of Cygwin/X is
+ * already running on the same display number. If no one exists,
+ * make a mutex to prevent new instances from running on the same display.
+ *
+ * return FALSE if the display number is already used.
+ */
+
+static Bool
+winCheckDisplayNumber ()
+{
+ int nDisp;
+ HANDLE mutex;
+ char name[MAX_PATH];
+ char * pszPrefix = '\0';
+ OSVERSIONINFO osvi = {0};
+
+ /* Check display range */
+ nDisp = atoi (display);
+ if (nDisp < 0 || nDisp > 65535)
+ {
+ ErrorF ("winCheckDisplayNumber - Bad display number: %d\n", nDisp);
+ return FALSE;
+ }
+
+ /* Set first character of mutex name to null */
+ name[0] = '\0';
+
+ /* Get operating system version information */
+ osvi.dwOSVersionInfoSize = sizeof (osvi);
+ GetVersionEx (&osvi);
+
+ /* Want a mutex shared among all terminals on NT > 4.0 */
+ if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT
+ && osvi.dwMajorVersion >= 5)
+ {
+ pszPrefix = "Global\\";
+ }
+
+ /* Setup Cygwin/X specific part of name */
+ snprintf (name, sizeof(name), "%sCYGWINX_DISPLAY:%d", pszPrefix, nDisp);
+
+ /* Windows automatically releases the mutex when this process exits */
+ mutex = CreateMutex (NULL, FALSE, name);
+ if (!mutex)
+ {
+ LPVOID lpMsgBuf;
+
+ /* Display a fancy error message */
+ FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError (),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &lpMsgBuf,
+ 0, NULL);
+ ErrorF ("winCheckDisplayNumber - CreateMutex failed: %s\n",
+ (LPSTR)lpMsgBuf);
+ LocalFree (lpMsgBuf);
+
+ return FALSE;
+ }
+ if (GetLastError () == ERROR_ALREADY_EXISTS)
+ {
+ ErrorF ("winCheckDisplayNumber - "
+ PROJECT_NAME " is already running on display %d\n",
+ nDisp);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+#ifdef DPMSExtension
+Bool DPMSSupported(void)
+{
+ return FALSE;
+}
+
+void DPMSSet(int level)
+{
+ return;
+}
+
+int DPMSGet(int *plevel)
+{
+ return 0;
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/README b/nx-X11/programs/Xserver/hw/xwin/README
new file mode 100644
index 000000000..219fd1337
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/README
@@ -0,0 +1,141 @@
+Cygwin/X Release Notes
+======================
+
+Release X11R6.7
+===============
+
+Cygwin/X has continued its rapid pace of development that it has sustained
+since Spring 2001 and this release shows it, we now have: a stable and fast
+multi-window mode, seamless clipboard integration, a configurable tray menu
+icon, popups on error messages pointing users to the log file and our mailing
+list, the beginnings of indirect 3D acceleration for OpenGL applications,
+improved non-US keyboard and clipboard support, and only a handful of bugs
+that continue to be reported.
+
+Between the XFree86 4.3.0 release and the X.Org X11R6.7 release the Cyg-
+win/XFree86 project broke away from The XFree86 Project, Inc. due to a lack
+of support from the XFree86 project. As such, the Cygwin/XFree86 project was
+renamed to the Cygwin/X project and the upstream source code tree that Cyg-
+win/X pulls from and pushes to is now the tree managed by the X.Org Founda-
+tion. The Cygwin/X project has seen a rush of development and interest in
+the project since the split; one metric showing this is that the number of
+CVS committers we have has gone from zero to six.
+
+The most outstanding features of this release are
+
+ o Major multi-window mode improvements. (Takuma Murakami, Earle F.
+ Philhower III)
+
+ o Initial work of accelerated OpenGL using the windows OpenGL drivers.
+ (Alexander Gottwald)
+
+ o Massive rework of clipboard integration with windows. (Harold L Hunt II,
+ Kensuke Matsuzaki)
+
+ o Improved Japanese clipboard and keyboard support. (Kensuke Matsuzaki,
+ Takuma Murakami, Alexander Gottwald)
+
+ o Customizable tray menu icon allowing shortcuts to start programs,
+ etc.(Earle F. Philhower III)
+
+ o New icons. (Jehan Bing, Michael Bax, Benjamin Rienfenstahl)
+
+ o Fix some multi-monitor problems.(Takuma Murakami)
+
+ o Fix repeated key strokes. (Ivan Pascal)
+
+ o Automatic keyboard layouts for the most frequently used keyboard lay-
+ outs. (Alexander Gottwald)
+
+ o Built in SHM support with detection of the SHM engine (cygserver).
+ (Ralf Habacker, Harold L Hunt II)
+
+ o Merged in work on the NativeGDI engine. (Alan Hourihane)
+
+OpenGL with Cygwin/X
+====================
+
+Cygwin/X has supported GLX only with software rendering provided by the Mesa
+library. Starting with X11R6.7 we add support for hardware accelerated OpenGL.
+
+This support is still under development and still has some bigger problems.
+To provide both versions (the stable software rendering and the new hardware
+accelerated) we ship to binaries. XWin.exe contains the software rendering
+and XWin_GL.exe uses the hardware acceleration provided by the windows drivers.
+
+The known problems with hardware accelerated OpenGL are:
+
+ o Only multiwindow mode is useful. In the other modes the OpenGL output
+ does not align with the X11 windows.
+
+ o Using two programs which require different visuals will fail. For example
+ glxgears and glxinfo will not work without restarting XWin_GL.exe.
+
+ o OpenGL extensions and functions from OpenGL 1.2 and later should work
+ but are not completely tested.
+
+ o The standard Windows OpenGL driver will produce no output. Use the one
+ from your video adapter vendor.
+
+If you notice problems with some programs please send a message with the
+logfile /tmp/XWin.log and a short error description to <cygwin-xfree@cygwin.com>
+
+The hardware accelerated OpenGL was tested using:
+
+ o glxgears
+ o glxinfo
+ o blender
+ o tuxkart
+ o GLUT demos (some did fail)
+ o tuxracer (currently not working)
+
+
+Release X11R6.8
+===============
+
+Having reached a quite mature state in release X11R6.7 the development
+has slowed down a little bit. Some of the former active developers have
+retired or cut their work for the Cygwin/X project due to conflicts with
+job, study and family.
+
+The X11R6.8 release now includes major improvements from the xserver project.
+This includes the XFixes, Damage, Composite and XEVIE extension which is a
+major step towards allowing Cygwin/X to have real transparency.
+
+But at the current state Composite is not working with Cygwin/X. Not all code
+in the Cygwin/X Server has been updated to support the Composite feature and
+using it will even crash the xserver. But as a second problem nearly all
+functions required for compositing are lacking acceleration in Cygwin/X so
+the feature would not be very useful if it would work. So it is disabled by
+default.
+
+OpenGL with Cygwin/X
+====================
+
+The OpenGL support has lost some of it's limitations from the last release
+and should be much more stable. But due to missing wide spread testing in
+the community it is still available in a separate program. XWin still uses
+the old software OpenGL which is known to be stable.
+
+The known problems with hardware accelerated OpenGL are:
+
+ o Only multiwindow mode is useful. In the other modes the OpenGL output
+ does not align with the X11 windows.
+
+ o OpenGL extensions and functions from OpenGL 1.2 and later should work
+ but are not completely tested.
+
+ o The standard Windows OpenGL driver will produce no output. Use the one
+ from your video adapter vendor.
+
+If you notice problems with some programs please send a message with the
+logfile /tmp/XWin.log and a short error description to <cygwin-xfree@cygwin.com>
+
+The hardware accelerated OpenGL was tested using:
+
+ o glxgears
+ o glxinfo
+ o blender
+ o tuxkart
+ o GLUT demos (some did fail)
+
diff --git a/nx-X11/programs/Xserver/hw/xwin/X-boxed.ico b/nx-X11/programs/Xserver/hw/xwin/X-boxed.ico
new file mode 100755
index 000000000..072704253
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/X-boxed.ico
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/xwin/X.ico b/nx-X11/programs/Xserver/hw/xwin/X.ico
new file mode 100644
index 000000000..d47168fca
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/X.ico
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/xwin/XWin.man b/nx-X11/programs/Xserver/hw/xwin/XWin.man
new file mode 100644
index 000000000..4e70c19f5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/XWin.man
@@ -0,0 +1,287 @@
+.TH XWIN 1 __vendorversion__
+.SH NAME
+XWin \- X Server for the Cygwin environment on Microsoft Windows
+
+
+.SH SYNOPSIS
+.B XWin
+[ options ] ...
+
+
+.SH DESCRIPTION
+.I XWin is an X Server for the X Window System on the Cygwin environment
+running on Microsoft Windows.
+
+
+.SH MODES
+\fIXWin\fP can operate in five different and incompatible modes:
+.br
+* \fISingle Window\fP: This is the default option. The X server
+appears as a single Windows window and all X windows are contained
+within this window. This mode requires an external window manager.
+.br
+* \fINo Decoration\fP: This mode is like single window mode except
+that the X server window does not have a title bar or border, thus
+maximizing the amount of space available for X windows within the X
+server window. This mode requires an external window manager.
+.br
+* \fIFull Screen\fP: This mode is like single window mode except that
+the X server window takes the full screen, covering completely the
+Windows desktop. This mode requires an external window manager.
+.br
+* \fIRootless\fP: The X server works on a window covering the whole
+screen but the root window (traditionally covered with an X hatch
+pattern) is hidden from view. This mode requires an external window
+manager.
+.br
+* \fIMulti-Window\fP: In this mode \fIXWin\fP uses its own integrated
+window manager in order to handle the top-level X windows, in such a
+way that they appear as normal Windows windows.
+.PP
+NOTE: \fIMulti-Window\fP mode will crash if an external window manager
+such as \fItwm\fP or \fIfvwm\fP is launched since \fIMulti-Window\fP
+uses its own internal window manager; all other modes require an
+external window manager in order to move, resize, and perform other
+operations on the individual X windows.
+
+
+.SH LOG
+As it runs \fIXWin\fP writes messages indicating the most relevant events
+to the console
+from which it was called and to a log file that by default is located at
+\fI/tmp/XWin.log\fP. This file is mainly for debugging purposes.
+
+
+.SH PREFERENCES FILE
+On startup \fIXWin\fP looks for the file \fI$HOME/.XWinrc\fP or, if
+the previous file does not exist,
+\fI/usr/X11R6/lib/X11/system.XWinrc\fP. \fI.XWinrc\fP allows setting
+preferences for the following:
+.br
+1- To include items into the menu associated with the \fIXWin\fP icon
+which is in the \fIWindows\fP system tray. This functions in all
+modes that have a tray icon.
+.br
+2- To include items in the menu which is associated with the Windows
+window that \fIXWin -multiwindow\fP produces for each top-level X
+window. That can be done both for the generic case and for particular
+programs.
+.br
+3- To change the icon that is associated to the Windows window that
+\fIXWin -multiwindow\fP produces for each top-level X-window. Again,
+that can be done both for the generic case and for particular
+programs.
+.PP
+The format of the \fI.XWinrc\fP file is given in the man page XWinrc(5).
+
+
+.SH OPTIONS
+In addition to the normal server options described in the \fIXserver(1)\fP
+manual page, \fIXWin\fP accepts the following command line switches,
+\fIall\fP of which are optional:
+.TP 8
+.B \-clipboard
+Enables the integration
+between the Cygwin/X clipboard and Windows clipboard. Do not use in
+conjunction with the \fIxwinclip\fP program.
+.TP 8
+.B "\-clipupdates \fInum_boxes\fP"
+Specify an optional threshold, above which the boxes in a shadow
+update operation will be collected into a GDI clipping region. The
+clipping region is then used to do a single bit block transfer that is
+constrained to the updated area by the clipping region. There is some
+overhead involved in creating, installing, destroying, and removing
+the clipping region, thus there may not be much benefit for a small
+number of boxes (less than 10). It is even possible that this
+functionality does not provide a benefit at any number of boxes; we
+can only determine the usefulness of this feature through testing.
+This parameter works in conjunction with engines 1, 2, and 4 (Shadow
+GDI, Shadow DirectDraw, and Shadow DirectDraw Non-Locking,
+respectively).
+.TP 8
+.B "\-emulate3buttons \fItimeout\fP"
+Emulate a three button mouse; pressing both buttons within
+.I timeout
+milliseconds causes an emulated middle button press. The default
+.I timeout
+is 50 milliseconds. Note that most mice with scroll wheel have middle
+button functionality, usually you will need this option only if you have
+a two button mouse without scroll wheel.
+.TP 8
+.B \-emulatepseudo
+Create a depth 8 PseudoColor visual when running in depths 15, 16, 24,
+or 32, collectively known as TrueColor depths.
+ At this date (April 2004) this option is not still operative.
+.TP 8
+.B "\-engine \fIengine_type_id\fP"
+This option, which is intended for Cygwin/X developers,
+overrides the server's automatically supported engine type. This
+parameter will be ignored if the specified engine type is not
+supported on the current system. The supported engine type ids are 1
+- Shadow GDI, 2 - Shadow DirectDraw, and 4 - Shadow DirectDraw4.
+Additionally, there is a barely functional experimental engine type id
+16 - Native GDI.
+.TP 8
+.B "\-fullscreen [-depth \fIdepth\fP] [-refresh \fIrate_in_Hz\fP]"
+Run the server in fullscreen mode, as opposed to the default windowed
+mode.
+.TP 8
+.B "\-depth \fIdepth\fP"
+Specify the color depth, in bits per pixel, to use when running in
+fullscreen with a DirectDraw engine. This parameter is ignored if
+\fB\-fullscreen\fP is not specified.
+.TP 8
+.B "\-refresh \fIrate_in_Hz\fP"
+Specify an optional refresh rate to use when running in
+fullscreen with a DirectDraw engine. This parameter is ignored if
+\fB\-fullscreen\fP is not specified.
+.TP 8
+.B \-help
+Write a help text to the console and to the log file.
+.TP 8
+.B \-ignoreinput
+Ignore keyboard and mouse input. This is usually only used for testing
+and debugging purposes.
+.TP 8
+.B \-[no]keyhook
+Enable [disable] a low-level keyboard hook for catching
+special key combinations like Alt+Tab and passing them to the X
+Server instead of letting \fIWindows\fP handle them.
+.TP 8
+.B \-lesspointer
+Hide the Windows mouse cursor when the mouse is over any Cygwin/X
+window (regardless of whether that window is active or inactive). This
+prevents the Windows mouse cursor from being placed overtop of the X
+cursor.
+.TP 8
+.B "\-logfile \fIFile_Name\fP"
+Change the log file from the default located at \fI/tmp/XWin.log\fP to
+the one indicated by \fIFile_Name\fP.
+.TP 8
+.B "\-logverbose \fIlevel\fP"
+Control the degree of verbosity of the log messages with the integer
+parameter \fIlevel\fP. For \fIlevel\fP=0 only fatal errors are
+reported, for \fIlevel\fP=1 (default) simple information about
+configuration is also given, for \fIlevel\fP=2 a detailed log
+information (including trace and debug output) is produced. Bigger
+values will yield a still more detailed debug output. At this date
+(April 2004) the option is still not fully operative; the default
+value is 2 and the output is insensitive to the level value.
+.TP 8
+.B \-multimonitors
+Create a root window that covers all monitors on a system with
+multiple monitors.
+.TP 8
+.B \-multiwindow
+Start the integrated \fIWindowsi\fP-based window manager, which launches each
+top-level X window in its own \fIWindows\fP window. Not to be used together
+with \fB\-rootless\fP nor \fB\-fullscreen\fP.
+.TP 8
+.B \-nodecoration
+Do not give the Cygwin/X window a Windows window border, title bar,
+etc. This parameter only applies to windowed mode screens, i.e., this
+parameter is ignored when the \fB\-fullscreen\fP parameter is specified.
+.TP 8
+.B \-nounicodeclipboard
+Do not use Unicode clipboard even if NT-based platform.
+.TP 8
+.B \-rootless
+Run the server in rootless mode. Not to be used with \fB\-multiwindow\fP
+nor with \fB\-fullscreen\fP.
+.TP 8
+.B "\-screen \fIscreen_number\fP \fIwidth\fP \fIheight\fP"
+This parameter may be used to specify the
+.I screen_number,
+.I height,
+and
+.I width
+of one or several Cygwin/X screens; each Cygwin/X screen will be
+opened in its own window. When using multiple screens, be sure not to
+duplicate any screen numbers.
+.I XWin
+default behavior is to create a single screen that is roughly
+the size of the current Windows display area.
+Screen specific parameters, such as \fB\-fullscreen\fP, can be applied as a
+default to all screens by placing those screen specific parameters
+before any \fB\-screen\fP parameter. Screen specific parameters placed after
+the first \fB\-screen\fP parameter will apply only to the immediately
+preceeding \fB\-screen\fP parameter.
+.TP 8
+.B \-scrollbars
+In windowed mode, allow screens bigger than the Windows desktop.
+Moreover, if the window has decorations, one can now resize it.
+.TP 8
+.B \-[no]trayicon
+Do not create a tray icon. Default is to create one
+icon per screen. You can globally disable tray icons with
+\fB\-notrayicon\fP, then enable it for specific screens with
+\fB\-trayicon\fP for those screens.
+.TP 8
+.B \-[no]unixkill
+Enable or disable the \fICtrl-Alt-Backspace\fP key combination as a
+signal to exit the X Server. The \fICtrl-Alt-Backspace\fP key combination
+is disabled by default.
+.TP 8
+.B \-[no]winkill
+Enable or disable the \fIAlt-F4\fP key combination as a signal to exit the
+X Server.
+The \fIAlt-F4\fP key combination is enabled by default.
+.TP 8
+.B \-swcursor
+Disable the usage of the windows cursor and use the X11 software cursor instead.
+.B \-silent-dup-error
+If another instance of XWin is found running, exit silently and don't display
+the error messge.
+.TP 8
+.B "\-xkblayout \fIlayout\fP"
+.TP 8
+.B "\-xkbmodel \fImodel\fP"
+.TP 8
+.B "\-xkboptions \fIoption\fP"
+.TP 8
+.B "\-xkbrules \fIrule\fP"
+.TP 8
+.B "\-xkbvariant \fIvariant\fp"
+These options implement the xkeyboard extension for loading
+a particular keyboard map as the X server starts. The behavior is similar
+to the \fIsetxkbmap\fP program. The layout data is located at
+\fI/usr/X11R6/lib/X11/xkb/\fP. Additional information is found in the
+README files therein and in the man page of \fIsetxkbmap\fP. For example
+in order to load a German layout for a pc105 keyboard one uses
+the options:
+.br
+.I " \-xkblayout de \-xkbmodel pc105"
+.PP
+Alternatively one may use the \fIsetxkbmap\fP program after XWin is
+running or even the \fIxmodmap\fP program for loading the old-style
+keyboard maps.
+
+
+.SH "SEE ALSO"
+X(__miscmansuffix__), Xserver(1), xdm(1), xinit(1), XWinrc(1), setxkbmap(1)
+
+
+.SH BUGS
+.I XWin
+and this man page still have many limitations. Some of the more obvious
+ones are:
+.br
+- The display mode can not be changed once the X server has started.
+.br
+- The XWin software is developing rapidly; it is therefore likely that
+this man page is not up to date. It is always prudent to
+look also at the output of \fIXWin -help\fP and to the Cygwin/X User Guide
+at /usr/share/doc/cygwin-x-doc-x.x.x/ug/cygwin-x-ug.xxx in order to
+check the options that are operative.
+
+
+.SH AUTHORS
+This list is by no means complete, but direct contributors to the
+Cygwin/X project include (in alphabetical order by last name): Stuart
+Adamson, Michael Bax, Jehan Bing, Lev Bishop, Dr. Peter Busch, Biju G
+C, Robert Collins, Nick Crabtree, Early Ehlinger, Christopher Faylor,
+John Fortin, Brian Genisio, Fabrizio Gennari, Alexander Gottwald, Ralf
+Habacker, Colin Harrison, Matthieu Herrb, Alan Hourihane, Pierre A
+Humblet, Harold L Hunt II, Dakshinamurthy Karra, Kensuke Matsuzaki,
+Takuma Murakami, Earle F. Philhower III, Benjamin Riefenstahl, Suhaib
+Siddiqi, Jack Tanner, and Nicholas Wourms.
diff --git a/nx-X11/programs/Xserver/hw/xwin/XWin.rc b/nx-X11/programs/Xserver/hw/xwin/XWin.rc
new file mode 100644
index 000000000..6ff23ca47
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/XWin.rc
@@ -0,0 +1,110 @@
+/*
+ *Copyright (C) 2002-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#include "windows.h"
+#include "winresource.h"
+
+/*
+ * Dialogs
+ */
+
+/* About */
+ABOUT_BOX DIALOG DISCARDABLE 32, 32, 240, 105
+STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_TABSTOP | DS_CENTERMOUSE
+CAPTION "About " PROJECT_NAME
+FONT 8, "MS Sans Serif"
+BEGIN
+ CONTROL PROJECT_NAME " Website", ID_ABOUT_WEBSITE, "Button",
+ BS_OWNERDRAW | WS_TABSTOP, 30, 45, 75, 15
+ CONTROL "Change Log", ID_ABOUT_CHANGELOG, "Button",
+ BS_OWNERDRAW | WS_TABSTOP, 135, 45, 75, 15
+ CONTROL "User's Guide", ID_ABOUT_UG, "Button",
+ BS_OWNERDRAW | WS_TABSTOP, 30, 65, 75, 15
+ CONTROL "FAQ", ID_ABOUT_FAQ, "Button",
+ BS_OWNERDRAW | WS_TABSTOP, 135, 65, 75, 15
+
+ DEFPUSHBUTTON "Dismiss", IDOK, 95, 85, 50, 15
+
+ CTEXT "Welcome to the preliminary About box for the " PROJECT_NAME " X Server. This dialog was created on 2004/03/25 and will eventually be filled with more useful information. For now, use the links below to learn more about the " PROJECT_NAME " project.", IDC_STATIC, 5, 5, 230, 35
+END
+
+
+/* Depth change */
+
+DEPTH_CHANGE_BOX DIALOG DISCARDABLE 32, 32, 180, 100
+STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | DS_CENTERMOUSE
+FONT 8, "MS Sans Serif"
+CAPTION PROJECT_NAME
+BEGIN
+ DEFPUSHBUTTON "Dismiss", IDOK, 66, 80, 50, 14
+ CTEXT PROJECT_NAME, IDC_STATIC, 40, 12, 100, 8
+ CTEXT "Disruptive screen configuration change.", IDC_STATIC, 7, 40, 166, 8
+ CTEXT "Restore previous resolution to use " PROJECT_NAME ".", IDC_STATIC, 7, 52, 166, 8
+END
+
+
+/* Exit */
+
+EXIT_DIALOG DIALOG DISCARDABLE 32, 32, 180, 78
+STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_TABSTOP | DS_CENTERMOUSE
+FONT 8, "MS Sans Serif"
+CAPTION PROJECT_NAME " - Exit?"
+BEGIN
+ PUSHBUTTON "E&xit", IDOK, 55, 56, 30, 14
+ DEFPUSHBUTTON "&Cancel", IDCANCEL, 95, 56, 30, 14
+ CTEXT "Exiting will close all screens running on this display.", IDC_STATIC, 7, 12, 166, 8
+ CTEXT "No information about connected clients available.", IDC_CLIENTS_CONNECTED, 7, 24, 166, 8
+ CTEXT "Proceed with shutdown of this display/server?", IDC_STATIC, 7, 36, 166, 8
+END
+
+
+/*
+ * Menus
+ */
+
+IDM_TRAYICON_MENU MENU DISCARDABLE
+BEGIN
+ POPUP "TRAYICON_MENU"
+ BEGIN
+ MENUITEM "&Hide Root Window", ID_APP_HIDE_ROOT
+ MENUITEM "Show Cursor", ID_APP_SHOWCURSOR
+ MENUITEM "&About...", ID_APP_ABOUT
+ MENUITEM SEPARATOR
+ MENUITEM "E&xit", ID_APP_EXIT
+ END
+END
+
+
+/*
+ * Icons
+ */
+
+IDI_XWIN ICON DISCARDABLE "X.ico"
+IDI_XWIN_BOXED ICON DISCARDABLE "X-boxed.ico"
diff --git a/nx-X11/programs/Xserver/hw/xwin/XWinrc.man b/nx-X11/programs/Xserver/hw/xwin/XWinrc.man
new file mode 100755
index 000000000..eba3fb603
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/XWinrc.man
@@ -0,0 +1,180 @@
+.TH XWIN 5 __vendorversion__
+
+
+.SH NAME
+XWinrc\- XWin Server Resource Configuration File.
+
+
+.SH DESCRIPTION
+The X Server for the X Window System on the Cygwin/X environment
+running on Microsoft Windows, \fIXWin\fP can be optionally configured
+with the \fIXWinrc\fP file. A system-wide configuration file should
+be placed in \fI/usr/X11R6/lib/X11/system.XWinrc\fP, a per-user file
+should be put at \fI$HOME/.XWinrc\fP. The \fIsystem.XWinrc\fP file is
+read only if no \fI$HOME/.XWinrc\fP exist.
+.PP
+With the \fI.XWinrc\fP configuration file it is possible to do the
+following:
+.PP
+1- To include items into the menu associated with the \fIXWin\fP icon
+which is in the \fIWindows\fP system tray. This feature functions in
+all XWin modes that have such tray icon.
+.PP
+2- To include items into the menu which is associated with the
+\fIWindows\fP window that \fIXWin -multiwindow\fP produces for each
+top-level X-window. That can be done both for the generic case and
+for particular programs.
+.PP
+3- To change the icon that is associated to the \fIWindows\fP window
+that \fIXWin -multiwindow\fP produces for each top-level X-window.
+Again, that can be done both for the generic case and for particular
+programs. The new icons associated should be \fIWindows\fP format
+icons \fI.ico\fP.
+
+
+.SH FILE FORMAT
+.B Keywords
+are case insensitive, but in this document they will be written
+completely capitalized.
+.PP
+.B Comments
+are legal pretty much anywhere you can have an end-of-line; they
+begin with "#" or "//" and go to the end-of-line.
+.PP
+Quote marks in strings are optional unless the string has included spaces.
+.PP
+There are three kinds of instructions: miscellaneous, menu, and icon.
+
+
+.SH Miscellaneous instruction
+.TP 8
+.B DEBUG \fIString\fP
+The \fIString\fP is printed to the XWin.log file.
+
+.TP 8
+.B TRAYICON \fIicon-specifier\fB
+The \fBTRAYICON\fP keyword changes the icon \fIXWin\fP displays in the
+system tray area.
+
+.TP 8
+.B SILENTEXIT
+The \fBSILENTEXIT\fP keyword, which takes no parameters, disables the
+exit confirmation dialog.
+
+
+.SH Menu instructions
+.TP 8
+.B MENU \fIMenu_Name\fP {
+.br
+.B \fIMenu_Item_Line\fP
+.br
+.B \fIMenu_Item_Line\fP
+.br
+.B \fI...\fP
+.br
+.B }
+.br
+This instruction defines a menu and asigns a \fIMenu_Name\fP to it.
+\fIMenu_Item_Line\fP are lines of any of the following types:
+.TP 8
+.B \t SEPARATOR
+.TP 8
+.B \t \fIItem_Label\fP EXEC \fICommand\fP
+.TP 8
+.B \t \fIItem_Label\fP MENU \fIpreviously-defined-menu-name\fP
+.TP 8
+.B \t \fIItem_Label\fP ALWAYSONTOP
+.TP 8
+.B \t \fIItem_Label\fP RELOAD
+.br
+The \fIItem_Label\fP is the string that is written in the menu item.
+.br
+\fICommand\fP is a string with the command that will be executed by /bin/sh.
+Here paths should be \fICYGWIN\fP style (e.g. /usr/local/bin/myprogram).
+A string "%display%" appearing in the \fICommand\fP will be replaced
+with the proper display variable (i.e. 127.0.0.1:<display>.0).
+.br
+\fBALWAYSONTOP\fP sets the window to which the menu is associated to
+display above all others.
+.br
+\fBRELOAD\fP causes the XWinrc file to be reloaded and icons and menus
+regenerated.
+.TP 8
+.B ROOTMENU \fIpreviously-defined-menu-name\fP
+Includes the items in the indicated menu into the menu associated with
+\fIXWin\fP that appears in the system tray.
+.TP 8
+.B DEFAULTSYSMENU \fIpreviously-defined-menu-name\fP ATSTART|ATEND
+Includes the items in the indicated menu into the menu associated with
+generic top-level X-Windows in the \fIXWin\fP \fImultiwindow\fP mode. The
+keywords \fBATSTART\fP and \fBATEND\fP indicate if such items should be
+included at the start or at the end of the menu.
+.TP 8
+.B SYSMENU {
+ \fIclass-or-name-of-window\fP \fIdefined-menu-name\fP \fBATSTART|ATEND\fP
+.br
+ \fI...\fP
+.br
+ \fB}\fP
+.br
+Associates a specific menu to a specific WM_CLASS or WM_NAME.
+
+
+.SH Icon Instructions
+When specifying an \fIicon-file\fP in the following commands several different formats are allowed:
+.br
+\fB"NAME.ICO"\fP\fI of an .ico format file\fP
+.br
+\t \t ("cygwin.ico", "apple.ico")
+.br
+\fB"NAME.DLL,nn"\fP\fI of a .DLL and icon index\fP
+.br
+\t \t ("c:\\windows\\system32\\shell32.dll,4" is the default folder icon)
+.br
+\fB",nn"\fP\fI index into XWin.EXE internal ICON resources\fP
+.br
+\t \t (",101" is the 1st icon inside \fIXWin.EXE\fP)
+.TP 8
+.B ICONDIRECTORY \fIWindows-path-to-icon-directory\fP
+Defines the default directory to search for \ficon-file\fP files.
+It should be a \fIWindows\fP style path (e.g. C:\\cygwin\\usr\\local\\icons).
+.TP 8
+.B DEFAULTICON \fIicon-file\fP
+Defines a replacement for the standard X icon for applications without
+specified icons.
+.TP 8
+.B ICONS {
+.br
+ \fIclass-or-name-of-window\fP \fIicon-file\fP
+.br
+ \fI...\fP
+.br
+ \fB}\fP
+.br
+Defines icon replacements windows matching the specified window class or names.
+If multiple name or class matches occur for a window, only the first one
+will be used.
+
+
+.SH EXAMPLE
+.TP 8
+This example adds an Xterm menu item to the system tray icon
+\fBMENU systray {
+.br
+\t xterm EXEC "xterm -display %display% -sb -sl 999"
+.br
+\t SEPARATOR
+.br
+}
+.br
+ROOTMENU systray
+\fP
+
+
+.SH "SEE ALSO"
+ XWin(1)
+
+
+.SH AUTHOR
+The XWinrc feature of XWin was written primarily by Earle F. Philhower
+III.
diff --git a/nx-X11/programs/Xserver/hw/xwin/_usr_X11R6_lib_X11_system.XWinrc b/nx-X11/programs/Xserver/hw/xwin/_usr_X11R6_lib_X11_system.XWinrc
new file mode 100644
index 000000000..d9c2d4210
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/_usr_X11R6_lib_X11_system.XWinrc
@@ -0,0 +1,125 @@
+# XWin Server Resource File - EXAMPLE
+# Earle F. Philhower, III
+
+# Place in ~/.XWinrc or in /usr/X11R6/lib/X11/system.XWinrc
+
+# Keywords are case insensitive, comments legal pretty much anywhere
+# you can have an end-of-line
+
+# Comments begin with "#" or "//" and go to the end-of-line
+
+# Paths to commands are **cygwin** based (i.e. /usr/local/bin/xcalc)
+
+# Paths to icons are **WINDOWS** based (i.e. c:\windows\icons)
+
+# Menus are defined as...
+# MENU <name> {
+# <Menu Text> EXEC <command>
+# ^^ This command will have any "%display%"
+# string replaced with the proper display
+# variable (i.e. 127.0.0.1:<display>.0)
+# or <Menu Text> MENU <name-of-some-prior-defined-menu>
+# or <Menu Text> ALWAYSONTOP
+# ^^ Sets the window to display above all others
+# or <Menu Text> RELOAD
+# ^^ Causes ~/.XWinrc or the system.XWinrc file
+# to be reloaded and icons and menus regenerated
+# or SEPARATOR
+# ...
+# }
+
+# Set the taskmar menu with
+# ROOTMENU <name-of-some-prior-defined-menu>
+
+# If you want a menu to be applied to all popup window's system menu
+# DEFAULTSYSMENU <name-of-some-prior-defined-menu> <atstart|atend>
+
+# To choose a specific menu for a specific WM_CLASS or WM_NAME use ...
+# SYSMENU {
+# <class-or-name-of-window> <name-of-prior-defined-menu> <atstart|atend>
+# ...
+# }
+
+# When specifying an ICONFILE in the following commands several different
+# formats are allowed:
+# 1. Name of a regular Windows .ico format file
+# (ex: "cygwin.ico", "apple.ico")
+# 2. Name and index into a Windows .DLL
+# (ex: "c:\windows\system32\shell32.dll,4" gives the default folder icon
+# "c:\windows\system32\shell32.dll,5" gives the floppy drive icon)
+# 3. Index into XWin.EXE internal ICON resource
+# (ex: ",101" is the 1st icon inside XWin.exe)
+
+# To define where ICO files live (** Windows path**)
+# ICONDIRECTORY <windows-path i.e. c:\cygwin\usr\icons>
+# NOTE: If you specify a fully qualified path to an ICON below
+# (i.e. "c:\xxx" or "d:\xxxx")
+# this ICONDIRECTORY will not be prepended
+
+# To change the taskbar icon use...
+# TRAYICON <name-of-windows-ico-file-in-icondirectory>
+
+# To define a replacement for the standard X icon for apps w/o specified icons
+# DEFAULTICON <name-of-windows-ico-file-in-icondirectory>
+
+# To define substitute icons on a per-window basis use...
+# ICONS {
+# <class-or-name-of-window> <icon-file-name.ico>
+# ...
+# }
+# In the case where multiple matches occur, the first listed in the ICONS
+# section will be chosen.
+
+# To disable exit confirmation dialog add the line containing SilentExit
+
+# DEBUG <string> prints out the string to the XWin.log file
+
+// Below are just some silly menus to demonstrate writing your
+// own configuration file.
+
+// Make some menus...
+menu apps {
+ xterm exec "xterm"
+ "Emacs" exec "emacs"
+ notepad exec notepad
+ xload exec "xload -display %display%" # Comment
+}
+
+menu root {
+// Comments fit here, too...
+ "Reload .XWinrc" RELOAD
+ "Applications" menu apps
+ SEParATOR
+}
+
+menu aot {
+ Separator
+ "Always on Top" alwaysontop
+}
+
+menu xtermspecial {
+ "Emacs" exec "emacs"
+ "Always on Top" alwaysontop
+ SepArAtor
+}
+
+RootMenu root
+
+DefaultSysMenu aot atend
+
+SysMenu {
+ "xterm" xtermspecial atstart
+}
+
+# IconDirectory "c:\winnt\"
+
+# DefaultIcon "reinstall.ico"
+
+# Icons {
+# "xterm" "uninstall.ico"
+# }
+
+# SilentExit
+
+DEBUG "Done parsing the configuration file..."
+
diff --git a/nx-X11/programs/Xserver/hw/xwin/ddraw.h b/nx-X11/programs/Xserver/hw/xwin/ddraw.h
new file mode 100644
index 000000000..6fbe88213
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/ddraw.h
@@ -0,0 +1,2108 @@
+/* $Id: ddraw.h,v 1.5 2005/07/01 22:43:39 daniels Exp $ */
+
+#ifndef __XWIN_DDRAW_H
+#define __XWIN_DDRAW_H
+
+#include <winnt.h>
+#include <wingdi.h>
+#include <objbase.h>
+
+#if defined(NONAMELESSUNION) && !defined(DUMMYUNIONNAME1)
+#define DUMMYUNIONNAME1 u1
+#endif
+
+#define ICOM_CALL_( xfn, p, args) (p)->lpVtbl->xfn args
+
+# ifdef UNICODE
+# define WINELIB_NAME_AW(func) func##W
+# else
+# define WINELIB_NAME_AW(func) func##A
+# endif /* UNICODE */
+#define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* defined(__cplusplus) */
+
+#ifndef DIRECTDRAW_VERSION
+#define DIRECTDRAW_VERSION 0x0700
+#endif /* DIRECTDRAW_VERSION */
+
+/*****************************************************************************
+ * Predeclare the interfaces
+ */
+DEFINE_GUID( CLSID_DirectDraw, 0xD7B70EE0,0x4340,0x11CF,0xB0,0x63,0x00,0x20,0xAF,0xC2,0xCD,0x35 );
+DEFINE_GUID( CLSID_DirectDraw7, 0x3C305196,0x50DB,0x11D3,0x9C,0xFE,0x00,0xC0,0x4F,0xD9,0x30,0xC5 );
+DEFINE_GUID( CLSID_DirectDrawClipper, 0x593817A0,0x7DB3,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xb9,0x33,0x56 );
+DEFINE_GUID( IID_IDirectDraw, 0x6C14DB80,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
+DEFINE_GUID( IID_IDirectDraw2, 0xB3A6F3E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56 );
+DEFINE_GUID( IID_IDirectDraw4, 0x9c59509a,0x39bd,0x11d1,0x8c,0x4a,0x00,0xc0,0x4f,0xd9,0x30,0xc5 );
+DEFINE_GUID( IID_IDirectDraw7, 0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b );
+DEFINE_GUID( IID_IDirectDrawSurface, 0x6C14DB81,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
+DEFINE_GUID( IID_IDirectDrawSurface2, 0x57805885,0x6eec,0x11cf,0x94,0x41,0xa8,0x23,0x03,0xc1,0x0e,0x27 );
+DEFINE_GUID( IID_IDirectDrawSurface3, 0xDA044E00,0x69B2,0x11D0,0xA1,0xD5,0x00,0xAA,0x00,0xB8,0xDF,0xBB );
+DEFINE_GUID( IID_IDirectDrawSurface4, 0x0B2B8630,0xAD35,0x11D0,0x8E,0xA6,0x00,0x60,0x97,0x97,0xEA,0x5B );
+DEFINE_GUID( IID_IDirectDrawSurface7, 0x06675a80,0x3b9b,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b );
+DEFINE_GUID( IID_IDirectDrawPalette, 0x6C14DB84,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
+DEFINE_GUID( IID_IDirectDrawClipper, 0x6C14DB85,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
+DEFINE_GUID( IID_IDirectDrawColorControl,0x4B9F0EE0,0x0D7E,0x11D0,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8 );
+DEFINE_GUID( IID_IDirectDrawGammaControl,0x69C11C3E,0xB46B,0x11D1,0xAD,0x7A,0x00,0xC0,0x4F,0xC2,0x9B,0x4E );
+
+typedef struct IDirectDraw *LPDIRECTDRAW;
+typedef struct IDirectDraw2 *LPDIRECTDRAW2;
+typedef struct IDirectDraw4 *LPDIRECTDRAW4;
+typedef struct IDirectDraw7 *LPDIRECTDRAW7;
+typedef struct IDirectDrawClipper *LPDIRECTDRAWCLIPPER;
+typedef struct IDirectDrawPalette *LPDIRECTDRAWPALETTE;
+typedef struct IDirectDrawSurface *LPDIRECTDRAWSURFACE;
+typedef struct IDirectDrawSurface2 *LPDIRECTDRAWSURFACE2;
+typedef struct IDirectDrawSurface3 *LPDIRECTDRAWSURFACE3;
+typedef struct IDirectDrawSurface4 *LPDIRECTDRAWSURFACE4;
+typedef struct IDirectDrawSurface7 *LPDIRECTDRAWSURFACE7;
+typedef struct IDirectDrawColorControl *LPDIRECTDRAWCOLORCONTROL;
+typedef struct IDirectDrawGammaControl *LPDIRECTDRAWGAMMACONTROL;
+
+
+#define DDENUMRET_CANCEL 0
+#define DDENUMRET_OK 1
+
+#define DD_OK 0
+
+
+#define _FACDD 0x876
+#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code )
+
+#define DDERR_ALREADYINITIALIZED MAKE_DDHRESULT( 5 )
+#define DDERR_CANNOTATTACHSURFACE MAKE_DDHRESULT( 10 )
+#define DDERR_CANNOTDETACHSURFACE MAKE_DDHRESULT( 20 )
+#define DDERR_CURRENTLYNOTAVAIL MAKE_DDHRESULT( 40 )
+#define DDERR_EXCEPTION MAKE_DDHRESULT( 55 )
+#define DDERR_GENERIC E_FAIL
+#define DDERR_HEIGHTALIGN MAKE_DDHRESULT( 90 )
+#define DDERR_INCOMPATIBLEPRIMARY MAKE_DDHRESULT( 95 )
+#define DDERR_INVALIDCAPS MAKE_DDHRESULT( 100 )
+#define DDERR_INVALIDCLIPLIST MAKE_DDHRESULT( 110 )
+#define DDERR_INVALIDMODE MAKE_DDHRESULT( 120 )
+#define DDERR_INVALIDOBJECT MAKE_DDHRESULT( 130 )
+#define DDERR_INVALIDPARAMS E_INVALIDARG
+#define DDERR_INVALIDPIXELFORMAT MAKE_DDHRESULT( 145 )
+#define DDERR_INVALIDRECT MAKE_DDHRESULT( 150 )
+#define DDERR_LOCKEDSURFACES MAKE_DDHRESULT( 160 )
+#define DDERR_NO3D MAKE_DDHRESULT( 170 )
+#define DDERR_NOALPHAHW MAKE_DDHRESULT( 180 )
+#define DDERR_NOSTEREOHARDWARE MAKE_DDHRESULT( 181 )
+#define DDERR_NOSURFACELEFT MAKE_DDHRESULT( 182 )
+#define DDERR_NOCLIPLIST MAKE_DDHRESULT( 205 )
+#define DDERR_NOCOLORCONVHW MAKE_DDHRESULT( 210 )
+#define DDERR_NOCOOPERATIVELEVELSET MAKE_DDHRESULT( 212 )
+#define DDERR_NOCOLORKEY MAKE_DDHRESULT( 215 )
+#define DDERR_NOCOLORKEYHW MAKE_DDHRESULT( 220 )
+#define DDERR_NODIRECTDRAWSUPPORT MAKE_DDHRESULT( 222 )
+#define DDERR_NOEXCLUSIVEMODE MAKE_DDHRESULT( 225 )
+#define DDERR_NOFLIPHW MAKE_DDHRESULT( 230 )
+#define DDERR_NOGDI MAKE_DDHRESULT( 240 )
+#define DDERR_NOMIRRORHW MAKE_DDHRESULT( 250 )
+#define DDERR_NOTFOUND MAKE_DDHRESULT( 255 )
+#define DDERR_NOOVERLAYHW MAKE_DDHRESULT( 260 )
+#define DDERR_OVERLAPPINGRECTS MAKE_DDHRESULT( 270 )
+#define DDERR_NORASTEROPHW MAKE_DDHRESULT( 280 )
+#define DDERR_NOROTATIONHW MAKE_DDHRESULT( 290 )
+#define DDERR_NOSTRETCHHW MAKE_DDHRESULT( 310 )
+#define DDERR_NOT4BITCOLOR MAKE_DDHRESULT( 316 )
+#define DDERR_NOT4BITCOLORINDEX MAKE_DDHRESULT( 317 )
+#define DDERR_NOT8BITCOLOR MAKE_DDHRESULT( 320 )
+#define DDERR_NOTEXTUREHW MAKE_DDHRESULT( 330 )
+#define DDERR_NOVSYNCHW MAKE_DDHRESULT( 335 )
+#define DDERR_NOZBUFFERHW MAKE_DDHRESULT( 340 )
+#define DDERR_NOZOVERLAYHW MAKE_DDHRESULT( 350 )
+#define DDERR_OUTOFCAPS MAKE_DDHRESULT( 360 )
+#define DDERR_OUTOFMEMORY E_OUTOFMEMORY
+#define DDERR_OUTOFVIDEOMEMORY MAKE_DDHRESULT( 380 )
+#define DDERR_OVERLAYCANTCLIP MAKE_DDHRESULT( 382 )
+#define DDERR_OVERLAYCOLORKEYONLYONEACTIVE MAKE_DDHRESULT( 384 )
+#define DDERR_PALETTEBUSY MAKE_DDHRESULT( 387 )
+#define DDERR_COLORKEYNOTSET MAKE_DDHRESULT( 400 )
+#define DDERR_SURFACEALREADYATTACHED MAKE_DDHRESULT( 410 )
+#define DDERR_SURFACEALREADYDEPENDENT MAKE_DDHRESULT( 420 )
+#define DDERR_SURFACEBUSY MAKE_DDHRESULT( 430 )
+#define DDERR_CANTLOCKSURFACE MAKE_DDHRESULT( 435 )
+#define DDERR_SURFACEISOBSCURED MAKE_DDHRESULT( 440 )
+#define DDERR_SURFACELOST MAKE_DDHRESULT( 450 )
+#define DDERR_SURFACENOTATTACHED MAKE_DDHRESULT( 460 )
+#define DDERR_TOOBIGHEIGHT MAKE_DDHRESULT( 470 )
+#define DDERR_TOOBIGSIZE MAKE_DDHRESULT( 480 )
+#define DDERR_TOOBIGWIDTH MAKE_DDHRESULT( 490 )
+#define DDERR_UNSUPPORTED E_NOTIMPL
+#define DDERR_UNSUPPORTEDFORMAT MAKE_DDHRESULT( 510 )
+#define DDERR_UNSUPPORTEDMASK MAKE_DDHRESULT( 520 )
+#define DDERR_INVALIDSTREAM MAKE_DDHRESULT( 521 )
+#define DDERR_VERTICALBLANKINPROGRESS MAKE_DDHRESULT( 537 )
+#define DDERR_WASSTILLDRAWING MAKE_DDHRESULT( 540 )
+#define DDERR_DDSCAPSCOMPLEXREQUIRED MAKE_DDHRESULT( 542 )
+#define DDERR_XALIGN MAKE_DDHRESULT( 560 )
+#define DDERR_INVALIDDIRECTDRAWGUID MAKE_DDHRESULT( 561 )
+#define DDERR_DIRECTDRAWALREADYCREATED MAKE_DDHRESULT( 562 )
+#define DDERR_NODIRECTDRAWHW MAKE_DDHRESULT( 563 )
+#define DDERR_PRIMARYSURFACEALREADYEXISTS MAKE_DDHRESULT( 564 )
+#define DDERR_NOEMULATION MAKE_DDHRESULT( 565 )
+#define DDERR_REGIONTOOSMALL MAKE_DDHRESULT( 566 )
+#define DDERR_CLIPPERISUSINGHWND MAKE_DDHRESULT( 567 )
+#define DDERR_NOCLIPPERATTACHED MAKE_DDHRESULT( 568 )
+#define DDERR_NOHWND MAKE_DDHRESULT( 569 )
+#define DDERR_HWNDSUBCLASSED MAKE_DDHRESULT( 570 )
+#define DDERR_HWNDALREADYSET MAKE_DDHRESULT( 571 )
+#define DDERR_NOPALETTEATTACHED MAKE_DDHRESULT( 572 )
+#define DDERR_NOPALETTEHW MAKE_DDHRESULT( 573 )
+#define DDERR_BLTFASTCANTCLIP MAKE_DDHRESULT( 574 )
+#define DDERR_NOBLTHW MAKE_DDHRESULT( 575 )
+#define DDERR_NODDROPSHW MAKE_DDHRESULT( 576 )
+#define DDERR_OVERLAYNOTVISIBLE MAKE_DDHRESULT( 577 )
+#define DDERR_NOOVERLAYDEST MAKE_DDHRESULT( 578 )
+#define DDERR_INVALIDPOSITION MAKE_DDHRESULT( 579 )
+#define DDERR_NOTAOVERLAYSURFACE MAKE_DDHRESULT( 580 )
+#define DDERR_EXCLUSIVEMODEALREADYSET MAKE_DDHRESULT( 581 )
+#define DDERR_NOTFLIPPABLE MAKE_DDHRESULT( 582 )
+#define DDERR_CANTDUPLICATE MAKE_DDHRESULT( 583 )
+#define DDERR_NOTLOCKED MAKE_DDHRESULT( 584 )
+#define DDERR_CANTCREATEDC MAKE_DDHRESULT( 585 )
+#define DDERR_NODC MAKE_DDHRESULT( 586 )
+#define DDERR_WRONGMODE MAKE_DDHRESULT( 587 )
+#define DDERR_IMPLICITLYCREATED MAKE_DDHRESULT( 588 )
+#define DDERR_NOTPALETTIZED MAKE_DDHRESULT( 589 )
+#define DDERR_UNSUPPORTEDMODE MAKE_DDHRESULT( 590 )
+#define DDERR_NOMIPMAPHW MAKE_DDHRESULT( 591 )
+#define DDERR_INVALIDSURFACETYPE MAKE_DDHRESULT( 592 )
+#define DDERR_NOOPTIMIZEHW MAKE_DDHRESULT( 600 )
+#define DDERR_NOTLOADED MAKE_DDHRESULT( 601 )
+#define DDERR_NOFOCUSWINDOW MAKE_DDHRESULT( 602 )
+#define DDERR_NOTONMIPMAPSUBLEVEL MAKE_DDHRESULT( 603 )
+#define DDERR_DCALREADYCREATED MAKE_DDHRESULT( 620 )
+#define DDERR_NONONLOCALVIDMEM MAKE_DDHRESULT( 630 )
+#define DDERR_CANTPAGELOCK MAKE_DDHRESULT( 640 )
+#define DDERR_CANTPAGEUNLOCK MAKE_DDHRESULT( 660 )
+#define DDERR_NOTPAGELOCKED MAKE_DDHRESULT( 680 )
+#define DDERR_MOREDATA MAKE_DDHRESULT( 690 )
+#define DDERR_EXPIRED MAKE_DDHRESULT( 691 )
+#define DDERR_TESTFINISHED MAKE_DDHRESULT( 692 )
+#define DDERR_NEWMODE MAKE_DDHRESULT( 693 )
+#define DDERR_D3DNOTINITIALIZED MAKE_DDHRESULT( 694 )
+#define DDERR_VIDEONOTACTIVE MAKE_DDHRESULT( 695 )
+#define DDERR_NOMONITORINFORMATION MAKE_DDHRESULT( 696 )
+#define DDERR_NODRIVERSUPPORT MAKE_DDHRESULT( 697 )
+#define DDERR_DEVICEDOESNTOWNSURFACE MAKE_DDHRESULT( 699 )
+#define DDERR_NOTINITIALIZED CO_E_NOTINITIALIZED
+
+/* dwFlags for Blt* */
+#define DDBLT_ALPHADEST 0x00000001
+#define DDBLT_ALPHADESTCONSTOVERRIDE 0x00000002
+#define DDBLT_ALPHADESTNEG 0x00000004
+#define DDBLT_ALPHADESTSURFACEOVERRIDE 0x00000008
+#define DDBLT_ALPHAEDGEBLEND 0x00000010
+#define DDBLT_ALPHASRC 0x00000020
+#define DDBLT_ALPHASRCCONSTOVERRIDE 0x00000040
+#define DDBLT_ALPHASRCNEG 0x00000080
+#define DDBLT_ALPHASRCSURFACEOVERRIDE 0x00000100
+#define DDBLT_ASYNC 0x00000200
+#define DDBLT_COLORFILL 0x00000400
+#define DDBLT_DDFX 0x00000800
+#define DDBLT_DDROPS 0x00001000
+#define DDBLT_KEYDEST 0x00002000
+#define DDBLT_KEYDESTOVERRIDE 0x00004000
+#define DDBLT_KEYSRC 0x00008000
+#define DDBLT_KEYSRCOVERRIDE 0x00010000
+#define DDBLT_ROP 0x00020000
+#define DDBLT_ROTATIONANGLE 0x00040000
+#define DDBLT_ZBUFFER 0x00080000
+#define DDBLT_ZBUFFERDESTCONSTOVERRIDE 0x00100000
+#define DDBLT_ZBUFFERDESTOVERRIDE 0x00200000
+#define DDBLT_ZBUFFERSRCCONSTOVERRIDE 0x00400000
+#define DDBLT_ZBUFFERSRCOVERRIDE 0x00800000
+#define DDBLT_WAIT 0x01000000
+#define DDBLT_DEPTHFILL 0x02000000
+#define DDBLT_DONOTWAIT 0x08000000
+
+/* dwTrans for BltFast */
+#define DDBLTFAST_NOCOLORKEY 0x00000000
+#define DDBLTFAST_SRCCOLORKEY 0x00000001
+#define DDBLTFAST_DESTCOLORKEY 0x00000002
+#define DDBLTFAST_WAIT 0x00000010
+#define DDBLTFAST_DONOTWAIT 0x00000020
+
+/* dwFlags for Flip */
+#define DDFLIP_WAIT 0x00000001
+#define DDFLIP_EVEN 0x00000002 /* only valid for overlay */
+#define DDFLIP_ODD 0x00000004 /* only valid for overlay */
+#define DDFLIP_NOVSYNC 0x00000008
+#define DDFLIP_STEREO 0x00000010
+#define DDFLIP_DONOTWAIT 0x00000020
+
+/* dwFlags for GetBltStatus */
+#define DDGBS_CANBLT 0x00000001
+#define DDGBS_ISBLTDONE 0x00000002
+
+/* dwFlags for IDirectDrawSurface7::GetFlipStatus */
+#define DDGFS_CANFLIP 1L
+#define DDGFS_ISFLIPDONE 2L
+
+/* dwFlags for IDirectDrawSurface7::SetPrivateData */
+#define DDSPD_IUNKNOWNPTR 1L
+#define DDSPD_VOLATILE 2L
+
+/* DDSCAPS.dwCaps */
+/* reserved1, was 3d capable */
+#define DDSCAPS_RESERVED1 0x00000001
+/* surface contains alpha information */
+#define DDSCAPS_ALPHA 0x00000002
+/* this surface is a backbuffer */
+#define DDSCAPS_BACKBUFFER 0x00000004
+/* complex surface structure */
+#define DDSCAPS_COMPLEX 0x00000008
+/* part of surface flipping structure */
+#define DDSCAPS_FLIP 0x00000010
+/* this surface is the frontbuffer surface */
+#define DDSCAPS_FRONTBUFFER 0x00000020
+/* this is a plain offscreen surface */
+#define DDSCAPS_OFFSCREENPLAIN 0x00000040
+/* overlay */
+#define DDSCAPS_OVERLAY 0x00000080
+/* palette objects can be created and attached to us */
+#define DDSCAPS_PALETTE 0x00000100
+/* primary surface (the one the user looks at currently)(right eye)*/
+#define DDSCAPS_PRIMARYSURFACE 0x00000200
+/* primary surface for left eye */
+#define DDSCAPS_PRIMARYSURFACELEFT 0x00000400
+/* surface exists in systemmemory */
+#define DDSCAPS_SYSTEMMEMORY 0x00000800
+/* surface can be used as a texture */
+#define DDSCAPS_TEXTURE 0x00001000
+/* surface may be destination for 3d rendering */
+#define DDSCAPS_3DDEVICE 0x00002000
+/* surface exists in videomemory */
+#define DDSCAPS_VIDEOMEMORY 0x00004000
+/* surface changes immediately visible */
+#define DDSCAPS_VISIBLE 0x00008000
+/* write only surface */
+#define DDSCAPS_WRITEONLY 0x00010000
+/* zbuffer surface */
+#define DDSCAPS_ZBUFFER 0x00020000
+/* has its own DC */
+#define DDSCAPS_OWNDC 0x00040000
+/* surface should be able to receive live video */
+#define DDSCAPS_LIVEVIDEO 0x00080000
+/* should be able to have a hw codec decompress stuff into it */
+#define DDSCAPS_HWCODEC 0x00100000
+/* mode X (320x200 or 320x240) surface */
+#define DDSCAPS_MODEX 0x00200000
+/* one mipmap surface (1 level) */
+#define DDSCAPS_MIPMAP 0x00400000
+#define DDSCAPS_RESERVED2 0x00800000
+/* memory allocation delayed until Load() */
+#define DDSCAPS_ALLOCONLOAD 0x04000000
+/* Indicates that the surface will receive data from a video port */
+#define DDSCAPS_VIDEOPORT 0x08000000
+/* surface is in local videomemory */
+#define DDSCAPS_LOCALVIDMEM 0x10000000
+/* surface is in nonlocal videomemory */
+#define DDSCAPS_NONLOCALVIDMEM 0x20000000
+/* surface is a standard VGA mode surface (NOT ModeX) */
+#define DDSCAPS_STANDARDVGAMODE 0x40000000
+/* optimized? surface */
+#define DDSCAPS_OPTIMIZED 0x80000000
+
+typedef struct _DDSCAPS {
+ DWORD dwCaps; /* capabilities of surface wanted */
+} DDSCAPS,*LPDDSCAPS;
+
+/* DDSCAPS2.dwCaps2 */
+/* indicates the surface will receive data from a video port using
+ deinterlacing hardware. */
+#define DDSCAPS2_HARDWAREDEINTERLACE 0x00000002
+/* indicates the surface will be locked very frequently. */
+#define DDSCAPS2_HINTDYNAMIC 0x00000004
+/* indicates surface can be re-ordered or retiled on load() */
+#define DDSCAPS2_HINTSTATIC 0x00000008
+/* indicates surface to be managed by directdraw/direct3D */
+#define DDSCAPS2_TEXTUREMANAGE 0x00000010
+/* reserved bits */
+#define DDSCAPS2_RESERVED1 0x00000020
+#define DDSCAPS2_RESERVED2 0x00000040
+/* indicates surface will never be locked again */
+#define DDSCAPS2_OPAQUE 0x00000080
+/* set at CreateSurface() time to indicate antialising will be used */
+#define DDSCAPS2_HINTANTIALIASING 0x00000100
+/* set at CreateSurface() time to indicate cubic environment map */
+#define DDSCAPS2_CUBEMAP 0x00000200
+/* face flags for cube maps */
+#define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400
+#define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800
+#define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000
+#define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000
+#define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000
+#define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000
+/* specifies all faces of a cube for CreateSurface() */
+#define DDSCAPS2_CUBEMAP_ALLFACES ( DDSCAPS2_CUBEMAP_POSITIVEX |\
+ DDSCAPS2_CUBEMAP_NEGATIVEX |\
+ DDSCAPS2_CUBEMAP_POSITIVEY |\
+ DDSCAPS2_CUBEMAP_NEGATIVEY |\
+ DDSCAPS2_CUBEMAP_POSITIVEZ |\
+ DDSCAPS2_CUBEMAP_NEGATIVEZ )
+/* set for mipmap sublevels on DirectX7 and later. ignored by CreateSurface() */
+#define DDSCAPS2_MIPMAPSUBLEVEL 0x00010000
+/* indicates texture surface to be managed by Direct3D *only* */
+#define DDSCAPS2_D3DTEXTUREMANAGE 0x00020000
+/* indicates managed surface that can safely be lost */
+#define DDSCAPS2_DONOTPERSIST 0x00040000
+/* indicates surface is part of a stereo flipping chain */
+#define DDSCAPS2_STEREOSURFACELEFT 0x00080000
+
+typedef struct _DDSCAPS2 {
+ DWORD dwCaps; /* capabilities of surface wanted */
+ DWORD dwCaps2; /* additional capabilities */
+ DWORD dwCaps3; /* reserved capabilities */
+ DWORD dwCaps4; /* more reserved capabilities */
+} DDSCAPS2,*LPDDSCAPS2;
+
+#define DD_ROP_SPACE (256/32) /* space required to store ROP array */
+
+typedef struct _DDCAPS_DX7 /* DirectX 7 version of caps struct */
+{
+ DWORD dwSize; /* size of the DDDRIVERCAPS structure */
+ DWORD dwCaps; /* driver specific capabilities */
+ DWORD dwCaps2; /* more driver specific capabilites */
+ DWORD dwCKeyCaps; /* color key capabilities of the surface */
+ DWORD dwFXCaps; /* driver specific stretching and effects capabilites */
+ DWORD dwFXAlphaCaps; /* alpha driver specific capabilities */
+ DWORD dwPalCaps; /* palette capabilities */
+ DWORD dwSVCaps; /* stereo vision capabilities */
+ DWORD dwAlphaBltConstBitDepths; /* DDBD_2,4,8 */
+ DWORD dwAlphaBltPixelBitDepths; /* DDBD_1,2,4,8 */
+ DWORD dwAlphaBltSurfaceBitDepths; /* DDBD_1,2,4,8 */
+ DWORD dwAlphaOverlayConstBitDepths; /* DDBD_2,4,8 */
+ DWORD dwAlphaOverlayPixelBitDepths; /* DDBD_1,2,4,8 */
+ DWORD dwAlphaOverlaySurfaceBitDepths; /* DDBD_1,2,4,8 */
+ DWORD dwZBufferBitDepths; /* DDBD_8,16,24,32 */
+ DWORD dwVidMemTotal; /* total amount of video memory */
+ DWORD dwVidMemFree; /* amount of free video memory */
+ DWORD dwMaxVisibleOverlays; /* maximum number of visible overlays */
+ DWORD dwCurrVisibleOverlays; /* current number of visible overlays */
+ DWORD dwNumFourCCCodes; /* number of four cc codes */
+ DWORD dwAlignBoundarySrc; /* source rectangle alignment */
+ DWORD dwAlignSizeSrc; /* source rectangle byte size */
+ DWORD dwAlignBoundaryDest; /* dest rectangle alignment */
+ DWORD dwAlignSizeDest; /* dest rectangle byte size */
+ DWORD dwAlignStrideAlign; /* stride alignment */
+ DWORD dwRops[DD_ROP_SPACE]; /* ROPS supported */
+ DDSCAPS ddsOldCaps; /* old DDSCAPS - superceded for DirectX6+ */
+ DWORD dwMinOverlayStretch; /* minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMaxOverlayStretch; /* maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMinLiveVideoStretch; /* minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMaxLiveVideoStretch; /* maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMinHwCodecStretch; /* minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMaxHwCodecStretch; /* maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwReserved1;
+ DWORD dwReserved2;
+ DWORD dwReserved3;
+ DWORD dwSVBCaps; /* driver specific capabilities for System->Vmem blts */
+ DWORD dwSVBCKeyCaps; /* driver color key capabilities for System->Vmem blts */
+ DWORD dwSVBFXCaps; /* driver FX capabilities for System->Vmem blts */
+ DWORD dwSVBRops[DD_ROP_SPACE];/* ROPS supported for System->Vmem blts */
+ DWORD dwVSBCaps; /* driver specific capabilities for Vmem->System blts */
+ DWORD dwVSBCKeyCaps; /* driver color key capabilities for Vmem->System blts */
+ DWORD dwVSBFXCaps; /* driver FX capabilities for Vmem->System blts */
+ DWORD dwVSBRops[DD_ROP_SPACE];/* ROPS supported for Vmem->System blts */
+ DWORD dwSSBCaps; /* driver specific capabilities for System->System blts */
+ DWORD dwSSBCKeyCaps; /* driver color key capabilities for System->System blts */
+ DWORD dwSSBFXCaps; /* driver FX capabilities for System->System blts */
+ DWORD dwSSBRops[DD_ROP_SPACE];/* ROPS supported for System->System blts */
+ DWORD dwMaxVideoPorts; /* maximum number of usable video ports */
+ DWORD dwCurrVideoPorts; /* current number of video ports used */
+ DWORD dwSVBCaps2; /* more driver specific capabilities for System->Vmem blts */
+ DWORD dwNLVBCaps; /* driver specific capabilities for non-local->local vidmem blts */
+ DWORD dwNLVBCaps2; /* more driver specific capabilities non-local->local vidmem blts */
+ DWORD dwNLVBCKeyCaps; /* driver color key capabilities for non-local->local vidmem blts */
+ DWORD dwNLVBFXCaps; /* driver FX capabilities for non-local->local blts */
+ DWORD dwNLVBRops[DD_ROP_SPACE]; /* ROPS supported for non-local->local blts */
+ DDSCAPS2 ddsCaps; /* surface capabilities */
+} DDCAPS_DX7,*LPDDCAPS_DX7;
+
+typedef struct _DDCAPS_DX6 /* DirectX 6 version of caps struct */
+{
+ DWORD dwSize; /* size of the DDDRIVERCAPS structure */
+ DWORD dwCaps; /* driver specific capabilities */
+ DWORD dwCaps2; /* more driver specific capabilites */
+ DWORD dwCKeyCaps; /* color key capabilities of the surface */
+ DWORD dwFXCaps; /* driver specific stretching and effects capabilites */
+ DWORD dwFXAlphaCaps; /* alpha driver specific capabilities */
+ DWORD dwPalCaps; /* palette capabilities */
+ DWORD dwSVCaps; /* stereo vision capabilities */
+ DWORD dwAlphaBltConstBitDepths; /* DDBD_2,4,8 */
+ DWORD dwAlphaBltPixelBitDepths; /* DDBD_1,2,4,8 */
+ DWORD dwAlphaBltSurfaceBitDepths; /* DDBD_1,2,4,8 */
+ DWORD dwAlphaOverlayConstBitDepths; /* DDBD_2,4,8 */
+ DWORD dwAlphaOverlayPixelBitDepths; /* DDBD_1,2,4,8 */
+ DWORD dwAlphaOverlaySurfaceBitDepths; /* DDBD_1,2,4,8 */
+ DWORD dwZBufferBitDepths; /* DDBD_8,16,24,32 */
+ DWORD dwVidMemTotal; /* total amount of video memory */
+ DWORD dwVidMemFree; /* amount of free video memory */
+ DWORD dwMaxVisibleOverlays; /* maximum number of visible overlays */
+ DWORD dwCurrVisibleOverlays; /* current number of visible overlays */
+ DWORD dwNumFourCCCodes; /* number of four cc codes */
+ DWORD dwAlignBoundarySrc; /* source rectangle alignment */
+ DWORD dwAlignSizeSrc; /* source rectangle byte size */
+ DWORD dwAlignBoundaryDest; /* dest rectangle alignment */
+ DWORD dwAlignSizeDest; /* dest rectangle byte size */
+ DWORD dwAlignStrideAlign; /* stride alignment */
+ DWORD dwRops[DD_ROP_SPACE]; /* ROPS supported */
+ DDSCAPS ddsOldCaps; /* old DDSCAPS - superceded for DirectX6+ */
+ DWORD dwMinOverlayStretch; /* minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMaxOverlayStretch; /* maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMinLiveVideoStretch; /* minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMaxLiveVideoStretch; /* maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMinHwCodecStretch; /* minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMaxHwCodecStretch; /* maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwReserved1;
+ DWORD dwReserved2;
+ DWORD dwReserved3;
+ DWORD dwSVBCaps; /* driver specific capabilities for System->Vmem blts */
+ DWORD dwSVBCKeyCaps; /* driver color key capabilities for System->Vmem blts */
+ DWORD dwSVBFXCaps; /* driver FX capabilities for System->Vmem blts */
+ DWORD dwSVBRops[DD_ROP_SPACE];/* ROPS supported for System->Vmem blts */
+ DWORD dwVSBCaps; /* driver specific capabilities for Vmem->System blts */
+ DWORD dwVSBCKeyCaps; /* driver color key capabilities for Vmem->System blts */
+ DWORD dwVSBFXCaps; /* driver FX capabilities for Vmem->System blts */
+ DWORD dwVSBRops[DD_ROP_SPACE];/* ROPS supported for Vmem->System blts */
+ DWORD dwSSBCaps; /* driver specific capabilities for System->System blts */
+ DWORD dwSSBCKeyCaps; /* driver color key capabilities for System->System blts */
+ DWORD dwSSBFXCaps; /* driver FX capabilities for System->System blts */
+ DWORD dwSSBRops[DD_ROP_SPACE];/* ROPS supported for System->System blts */
+ DWORD dwMaxVideoPorts; /* maximum number of usable video ports */
+ DWORD dwCurrVideoPorts; /* current number of video ports used */
+ DWORD dwSVBCaps2; /* more driver specific capabilities for System->Vmem blts */
+ DWORD dwNLVBCaps; /* driver specific capabilities for non-local->local vidmem blts */
+ DWORD dwNLVBCaps2; /* more driver specific capabilities non-local->local vidmem blts */
+ DWORD dwNLVBCKeyCaps; /* driver color key capabilities for non-local->local vidmem blts */
+ DWORD dwNLVBFXCaps; /* driver FX capabilities for non-local->local blts */
+ DWORD dwNLVBRops[DD_ROP_SPACE]; /* ROPS supported for non-local->local blts */
+ /* and one new member for DirectX 6 */
+ DDSCAPS2 ddsCaps; /* surface capabilities */
+} DDCAPS_DX6,*LPDDCAPS_DX6;
+
+typedef struct _DDCAPS_DX5 /* DirectX5 version of caps struct */
+{
+ DWORD dwSize; /* size of the DDDRIVERCAPS structure */
+ DWORD dwCaps; /* driver specific capabilities */
+ DWORD dwCaps2; /* more driver specific capabilites */
+ DWORD dwCKeyCaps; /* color key capabilities of the surface */
+ DWORD dwFXCaps; /* driver specific stretching and effects capabilites */
+ DWORD dwFXAlphaCaps; /* alpha driver specific capabilities */
+ DWORD dwPalCaps; /* palette capabilities */
+ DWORD dwSVCaps; /* stereo vision capabilities */
+ DWORD dwAlphaBltConstBitDepths; /* DDBD_2,4,8 */
+ DWORD dwAlphaBltPixelBitDepths; /* DDBD_1,2,4,8 */
+ DWORD dwAlphaBltSurfaceBitDepths; /* DDBD_1,2,4,8 */
+ DWORD dwAlphaOverlayConstBitDepths; /* DDBD_2,4,8 */
+ DWORD dwAlphaOverlayPixelBitDepths; /* DDBD_1,2,4,8 */
+ DWORD dwAlphaOverlaySurfaceBitDepths; /* DDBD_1,2,4,8 */
+ DWORD dwZBufferBitDepths; /* DDBD_8,16,24,32 */
+ DWORD dwVidMemTotal; /* total amount of video memory */
+ DWORD dwVidMemFree; /* amount of free video memory */
+ DWORD dwMaxVisibleOverlays; /* maximum number of visible overlays */
+ DWORD dwCurrVisibleOverlays; /* current number of visible overlays */
+ DWORD dwNumFourCCCodes; /* number of four cc codes */
+ DWORD dwAlignBoundarySrc; /* source rectangle alignment */
+ DWORD dwAlignSizeSrc; /* source rectangle byte size */
+ DWORD dwAlignBoundaryDest; /* dest rectangle alignment */
+ DWORD dwAlignSizeDest; /* dest rectangle byte size */
+ DWORD dwAlignStrideAlign; /* stride alignment */
+ DWORD dwRops[DD_ROP_SPACE]; /* ROPS supported */
+ DDSCAPS ddsCaps; /* DDSCAPS structure has all the general capabilities */
+ DWORD dwMinOverlayStretch; /* minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMaxOverlayStretch; /* maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMinLiveVideoStretch; /* minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMaxLiveVideoStretch; /* maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMinHwCodecStretch; /* minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMaxHwCodecStretch; /* maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwReserved1;
+ DWORD dwReserved2;
+ DWORD dwReserved3;
+ DWORD dwSVBCaps; /* driver specific capabilities for System->Vmem blts */
+ DWORD dwSVBCKeyCaps; /* driver color key capabilities for System->Vmem blts */
+ DWORD dwSVBFXCaps; /* driver FX capabilities for System->Vmem blts */
+ DWORD dwSVBRops[DD_ROP_SPACE];/* ROPS supported for System->Vmem blts */
+ DWORD dwVSBCaps; /* driver specific capabilities for Vmem->System blts */
+ DWORD dwVSBCKeyCaps; /* driver color key capabilities for Vmem->System blts */
+ DWORD dwVSBFXCaps; /* driver FX capabilities for Vmem->System blts */
+ DWORD dwVSBRops[DD_ROP_SPACE];/* ROPS supported for Vmem->System blts */
+ DWORD dwSSBCaps; /* driver specific capabilities for System->System blts */
+ DWORD dwSSBCKeyCaps; /* driver color key capabilities for System->System blts */
+ DWORD dwSSBFXCaps; /* driver FX capabilities for System->System blts */
+ DWORD dwSSBRops[DD_ROP_SPACE];/* ROPS supported for System->System blts */
+ /* the following are the new DirectX 5 members */
+ DWORD dwMaxVideoPorts; /* maximum number of usable video ports */
+ DWORD dwCurrVideoPorts; /* current number of video ports used */
+ DWORD dwSVBCaps2; /* more driver specific capabilities for System->Vmem blts */
+ DWORD dwNLVBCaps; /* driver specific capabilities for non-local->local vidmem blts */
+ DWORD dwNLVBCaps2; /* more driver specific capabilities non-local->local vidmem blts */
+ DWORD dwNLVBCKeyCaps; /* driver color key capabilities for non-local->local vidmem blts */
+ DWORD dwNLVBFXCaps; /* driver FX capabilities for non-local->local blts */
+ DWORD dwNLVBRops[DD_ROP_SPACE]; /* ROPS supported for non-local->local blts */
+} DDCAPS_DX5,*LPDDCAPS_DX5;
+
+typedef struct _DDCAPS_DX3 /* DirectX3 version of caps struct */
+{
+ DWORD dwSize; /* size of the DDDRIVERCAPS structure */
+ DWORD dwCaps; /* driver specific capabilities */
+ DWORD dwCaps2; /* more driver specific capabilites */
+ DWORD dwCKeyCaps; /* color key capabilities of the surface */
+ DWORD dwFXCaps; /* driver specific stretching and effects capabilites */
+ DWORD dwFXAlphaCaps; /* alpha driver specific capabilities */
+ DWORD dwPalCaps; /* palette capabilities */
+ DWORD dwSVCaps; /* stereo vision capabilities */
+ DWORD dwAlphaBltConstBitDepths; /* DDBD_2,4,8 */
+ DWORD dwAlphaBltPixelBitDepths; /* DDBD_1,2,4,8 */
+ DWORD dwAlphaBltSurfaceBitDepths; /* DDBD_1,2,4,8 */
+ DWORD dwAlphaOverlayConstBitDepths; /* DDBD_2,4,8 */
+ DWORD dwAlphaOverlayPixelBitDepths; /* DDBD_1,2,4,8 */
+ DWORD dwAlphaOverlaySurfaceBitDepths; /* DDBD_1,2,4,8 */
+ DWORD dwZBufferBitDepths; /* DDBD_8,16,24,32 */
+ DWORD dwVidMemTotal; /* total amount of video memory */
+ DWORD dwVidMemFree; /* amount of free video memory */
+ DWORD dwMaxVisibleOverlays; /* maximum number of visible overlays */
+ DWORD dwCurrVisibleOverlays; /* current number of visible overlays */
+ DWORD dwNumFourCCCodes; /* number of four cc codes */
+ DWORD dwAlignBoundarySrc; /* source rectangle alignment */
+ DWORD dwAlignSizeSrc; /* source rectangle byte size */
+ DWORD dwAlignBoundaryDest; /* dest rectangle alignment */
+ DWORD dwAlignSizeDest; /* dest rectangle byte size */
+ DWORD dwAlignStrideAlign; /* stride alignment */
+ DWORD dwRops[DD_ROP_SPACE]; /* ROPS supported */
+ DDSCAPS ddsCaps; /* DDSCAPS structure has all the general capabilities */
+ DWORD dwMinOverlayStretch; /* minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMaxOverlayStretch; /* maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMinLiveVideoStretch; /* minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMaxLiveVideoStretch; /* maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMinHwCodecStretch; /* minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwMaxHwCodecStretch; /* maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+ DWORD dwReserved1;
+ DWORD dwReserved2;
+ DWORD dwReserved3;
+ DWORD dwSVBCaps; /* driver specific capabilities for System->Vmem blts */
+ DWORD dwSVBCKeyCaps; /* driver color key capabilities for System->Vmem blts */
+ DWORD dwSVBFXCaps; /* driver FX capabilities for System->Vmem blts */
+ DWORD dwSVBRops[DD_ROP_SPACE];/* ROPS supported for System->Vmem blts */
+ DWORD dwVSBCaps; /* driver specific capabilities for Vmem->System blts */
+ DWORD dwVSBCKeyCaps; /* driver color key capabilities for Vmem->System blts */
+ DWORD dwVSBFXCaps; /* driver FX capabilities for Vmem->System blts */
+ DWORD dwVSBRops[DD_ROP_SPACE];/* ROPS supported for Vmem->System blts */
+ DWORD dwSSBCaps; /* driver specific capabilities for System->System blts */
+ DWORD dwSSBCKeyCaps; /* driver color key capabilities for System->System blts */
+ DWORD dwSSBFXCaps; /* driver FX capabilities for System->System blts */
+ DWORD dwSSBRops[DD_ROP_SPACE];/* ROPS supported for System->System blts */
+ DWORD dwReserved4;
+ DWORD dwReserved5;
+ DWORD dwReserved6;
+} DDCAPS_DX3,*LPDDCAPS_DX3;
+
+/* set caps struct according to DIRECTDRAW_VERSION */
+
+#if DIRECTDRAW_VERSION <= 0x300
+typedef DDCAPS_DX3 DDCAPS;
+#elif DIRECTDRAW_VERSION <= 0x500
+typedef DDCAPS_DX5 DDCAPS;
+#elif DIRECTDRAW_VERSION <= 0x600
+typedef DDCAPS_DX6 DDCAPS;
+#else
+typedef DDCAPS_DX7 DDCAPS;
+#endif
+
+typedef DDCAPS *LPDDCAPS;
+
+/* DDCAPS.dwCaps */
+#define DDCAPS_3D 0x00000001
+#define DDCAPS_ALIGNBOUNDARYDEST 0x00000002
+#define DDCAPS_ALIGNSIZEDEST 0x00000004
+#define DDCAPS_ALIGNBOUNDARYSRC 0x00000008
+#define DDCAPS_ALIGNSIZESRC 0x00000010
+#define DDCAPS_ALIGNSTRIDE 0x00000020
+#define DDCAPS_BLT 0x00000040
+#define DDCAPS_BLTQUEUE 0x00000080
+#define DDCAPS_BLTFOURCC 0x00000100
+#define DDCAPS_BLTSTRETCH 0x00000200
+#define DDCAPS_GDI 0x00000400
+#define DDCAPS_OVERLAY 0x00000800
+#define DDCAPS_OVERLAYCANTCLIP 0x00001000
+#define DDCAPS_OVERLAYFOURCC 0x00002000
+#define DDCAPS_OVERLAYSTRETCH 0x00004000
+#define DDCAPS_PALETTE 0x00008000
+#define DDCAPS_PALETTEVSYNC 0x00010000
+#define DDCAPS_READSCANLINE 0x00020000
+#define DDCAPS_STEREOVIEW 0x00040000
+#define DDCAPS_VBI 0x00080000
+#define DDCAPS_ZBLTS 0x00100000
+#define DDCAPS_ZOVERLAYS 0x00200000
+#define DDCAPS_COLORKEY 0x00400000
+#define DDCAPS_ALPHA 0x00800000
+#define DDCAPS_COLORKEYHWASSIST 0x01000000
+#define DDCAPS_NOHARDWARE 0x02000000
+#define DDCAPS_BLTCOLORFILL 0x04000000
+#define DDCAPS_BANKSWITCHED 0x08000000
+#define DDCAPS_BLTDEPTHFILL 0x10000000
+#define DDCAPS_CANCLIP 0x20000000
+#define DDCAPS_CANCLIPSTRETCHED 0x40000000
+#define DDCAPS_CANBLTSYSMEM 0x80000000
+
+/* DDCAPS.dwCaps2 */
+#define DDCAPS2_CERTIFIED 0x00000001
+#define DDCAPS2_NO2DDURING3DSCENE 0x00000002
+#define DDCAPS2_VIDEOPORT 0x00000004
+#define DDCAPS2_AUTOFLIPOVERLAY 0x00000008
+#define DDCAPS2_CANBOBINTERLEAVED 0x00000010
+#define DDCAPS2_CANBOBNONINTERLEAVED 0x00000020
+#define DDCAPS2_COLORCONTROLOVERLAY 0x00000040
+#define DDCAPS2_COLORCONTROLPRIMARY 0x00000080
+#define DDCAPS2_CANDROPZ16BIT 0x00000100
+#define DDCAPS2_NONLOCALVIDMEM 0x00000200
+#define DDCAPS2_NONLOCALVIDMEMCAPS 0x00000400
+#define DDCAPS2_NOPAGELOCKREQUIRED 0x00000800
+#define DDCAPS2_WIDESURFACES 0x00001000
+#define DDCAPS2_CANFLIPODDEVEN 0x00002000
+#define DDCAPS2_CANBOBHARDWARE 0x00004000
+#define DDCAPS2_COPYFOURCC 0x00008000
+#define DDCAPS2_PRIMARYGAMMA 0x00020000
+#define DDCAPS2_CANRENDERWINDOWED 0x00080000
+#define DDCAPS2_CANCALIBRATEGAMMA 0x00100000
+#define DDCAPS2_FLIPINTERVAL 0x00200000
+#define DDCAPS2_FLIPNOVSYNC 0x00400000
+#define DDCAPS2_CANMANAGETEXTURE 0x00800000
+#define DDCAPS2_TEXMANINNONLOCALVIDMEM 0x01000000
+#define DDCAPS2_STEREO 0x02000000
+#define DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL 0x04000000
+
+
+/* Set/Get Colour Key Flags */
+#define DDCKEY_COLORSPACE 0x00000001 /* Struct is single colour space */
+#define DDCKEY_DESTBLT 0x00000002 /* To be used as dest for blt */
+#define DDCKEY_DESTOVERLAY 0x00000004 /* To be used as dest for CK overlays */
+#define DDCKEY_SRCBLT 0x00000008 /* To be used as src for blt */
+#define DDCKEY_SRCOVERLAY 0x00000010 /* To be used as src for CK overlays */
+
+typedef struct _DDCOLORKEY
+{
+ DWORD dwColorSpaceLowValue;/* low boundary of color space that is to
+ * be treated as Color Key, inclusive
+ */
+ DWORD dwColorSpaceHighValue;/* high boundary of color space that is
+ * to be treated as Color Key, inclusive
+ */
+} DDCOLORKEY,*LPDDCOLORKEY;
+
+/* ddCKEYCAPS bits */
+#define DDCKEYCAPS_DESTBLT 0x00000001
+#define DDCKEYCAPS_DESTBLTCLRSPACE 0x00000002
+#define DDCKEYCAPS_DESTBLTCLRSPACEYUV 0x00000004
+#define DDCKEYCAPS_DESTBLTYUV 0x00000008
+#define DDCKEYCAPS_DESTOVERLAY 0x00000010
+#define DDCKEYCAPS_DESTOVERLAYCLRSPACE 0x00000020
+#define DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV 0x00000040
+#define DDCKEYCAPS_DESTOVERLAYONEACTIVE 0x00000080
+#define DDCKEYCAPS_DESTOVERLAYYUV 0x00000100
+#define DDCKEYCAPS_SRCBLT 0x00000200
+#define DDCKEYCAPS_SRCBLTCLRSPACE 0x00000400
+#define DDCKEYCAPS_SRCBLTCLRSPACEYUV 0x00000800
+#define DDCKEYCAPS_SRCBLTYUV 0x00001000
+#define DDCKEYCAPS_SRCOVERLAY 0x00002000
+#define DDCKEYCAPS_SRCOVERLAYCLRSPACE 0x00004000
+#define DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV 0x00008000
+#define DDCKEYCAPS_SRCOVERLAYONEACTIVE 0x00010000
+#define DDCKEYCAPS_SRCOVERLAYYUV 0x00020000
+#define DDCKEYCAPS_NOCOSTOVERLAY 0x00040000
+
+typedef struct _DDPIXELFORMAT {
+ DWORD dwSize; /* 0: size of structure */
+ DWORD dwFlags; /* 4: pixel format flags */
+ DWORD dwFourCC; /* 8: (FOURCC code) */
+ union {
+ DWORD dwRGBBitCount; /* C: how many bits per pixel */
+ DWORD dwYUVBitCount; /* C: how many bits per pixel */
+ DWORD dwZBufferBitDepth; /* C: how many bits for z buffers */
+ DWORD dwAlphaBitDepth; /* C: how many bits for alpha channels*/
+ DWORD dwLuminanceBitCount;
+ DWORD dwBumpBitCount;
+ } DUMMYUNIONNAME1;
+ union {
+ DWORD dwRBitMask; /* 10: mask for red bit*/
+ DWORD dwYBitMask; /* 10: mask for Y bits*/
+ DWORD dwStencilBitDepth;
+ DWORD dwLuminanceBitMask;
+ DWORD dwBumpDuBitMask;
+ } DUMMYUNIONNAME2;
+ union {
+ DWORD dwGBitMask; /* 14: mask for green bits*/
+ DWORD dwUBitMask; /* 14: mask for U bits*/
+ DWORD dwZBitMask;
+ DWORD dwBumpDvBitMask;
+ } DUMMYUNIONNAME3;
+ union {
+ DWORD dwBBitMask; /* 18: mask for blue bits*/
+ DWORD dwVBitMask; /* 18: mask for V bits*/
+ DWORD dwStencilBitMask;
+ DWORD dwBumpLuminanceBitMask;
+ } DUMMYUNIONNAME4;
+ union {
+ DWORD dwRGBAlphaBitMask; /* 1C: mask for alpha channel */
+ DWORD dwYUVAlphaBitMask; /* 1C: mask for alpha channel */
+ DWORD dwLuminanceAlphaBitMask;
+ DWORD dwRGBZBitMask; /* 1C: mask for Z channel */
+ DWORD dwYUVZBitMask; /* 1C: mask for Z channel */
+ } DUMMYUNIONNAME5;
+ /* 20: next structure */
+} DDPIXELFORMAT,*LPDDPIXELFORMAT;
+
+/* DDCAPS.dwFXCaps */
+#define DDFXCAPS_BLTALPHA 0x00000001
+#define DDFXCAPS_OVERLAYALPHA 0x00000004
+#define DDFXCAPS_BLTARITHSTRETCHYN 0x00000010
+#define DDFXCAPS_BLTARITHSTRETCHY 0x00000020
+#define DDFXCAPS_BLTMIRRORLEFTRIGHT 0x00000040
+#define DDFXCAPS_BLTMIRRORUPDOWN 0x00000080
+#define DDFXCAPS_BLTROTATION 0x00000100
+#define DDFXCAPS_BLTROTATION90 0x00000200
+#define DDFXCAPS_BLTSHRINKX 0x00000400
+#define DDFXCAPS_BLTSHRINKXN 0x00000800
+#define DDFXCAPS_BLTSHRINKY 0x00001000
+#define DDFXCAPS_BLTSHRINKYN 0x00002000
+#define DDFXCAPS_BLTSTRETCHX 0x00004000
+#define DDFXCAPS_BLTSTRETCHXN 0x00008000
+#define DDFXCAPS_BLTSTRETCHY 0x00010000
+#define DDFXCAPS_BLTSTRETCHYN 0x00020000
+#define DDFXCAPS_OVERLAYARITHSTRETCHY 0x00040000
+#define DDFXCAPS_OVERLAYARITHSTRETCHYN 0x00000008
+#define DDFXCAPS_OVERLAYSHRINKX 0x00080000
+#define DDFXCAPS_OVERLAYSHRINKXN 0x00100000
+#define DDFXCAPS_OVERLAYSHRINKY 0x00200000
+#define DDFXCAPS_OVERLAYSHRINKYN 0x00400000
+#define DDFXCAPS_OVERLAYSTRETCHX 0x00800000
+#define DDFXCAPS_OVERLAYSTRETCHXN 0x01000000
+#define DDFXCAPS_OVERLAYSTRETCHY 0x02000000
+#define DDFXCAPS_OVERLAYSTRETCHYN 0x04000000
+#define DDFXCAPS_OVERLAYMIRRORLEFTRIGHT 0x08000000
+#define DDFXCAPS_OVERLAYMIRRORUPDOWN 0x10000000
+
+#define DDFXCAPS_OVERLAYFILTER DDFXCAPS_OVERLAYARITHSTRETCHY
+
+/* DDCAPS.dwFXAlphaCaps */
+#define DDFXALPHACAPS_BLTALPHAEDGEBLEND 0x00000001
+#define DDFXALPHACAPS_BLTALPHAPIXELS 0x00000002
+#define DDFXALPHACAPS_BLTALPHAPIXELSNEG 0x00000004
+#define DDFXALPHACAPS_BLTALPHASURFACES 0x00000008
+#define DDFXALPHACAPS_BLTALPHASURFACESNEG 0x00000010
+#define DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND 0x00000020
+#define DDFXALPHACAPS_OVERLAYALPHAPIXELS 0x00000040
+#define DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG 0x00000080
+#define DDFXALPHACAPS_OVERLAYALPHASURFACES 0x00000100
+#define DDFXALPHACAPS_OVERLAYALPHASURFACESNEG 0x00000200
+
+/* DDCAPS.dwPalCaps */
+#define DDPCAPS_4BIT 0x00000001
+#define DDPCAPS_8BITENTRIES 0x00000002
+#define DDPCAPS_8BIT 0x00000004
+#define DDPCAPS_INITIALIZE 0x00000008
+#define DDPCAPS_PRIMARYSURFACE 0x00000010
+#define DDPCAPS_PRIMARYSURFACELEFT 0x00000020
+#define DDPCAPS_ALLOW256 0x00000040
+#define DDPCAPS_VSYNC 0x00000080
+#define DDPCAPS_1BIT 0x00000100
+#define DDPCAPS_2BIT 0x00000200
+#define DDPCAPS_ALPHA 0x00000400
+
+/* DDCAPS.dwSVCaps */
+/* the first 4 of these are now obsolete */
+#if DIRECTDRAW_VERSION >= 0x700 /* FIXME: I'm not sure when this switch occured */
+#define DDSVCAPS_RESERVED1 0x00000001
+#define DDSVCAPS_RESERVED2 0x00000002
+#define DDSVCAPS_RESERVED3 0x00000004
+#define DDSVCAPS_RESERVED4 0x00000008
+#else
+#define DDSVCAPS_ENIGMA 0x00000001
+#define DDSVCAPS_FLICKER 0x00000002
+#define DDSVCAPS_REDBLUE 0x00000004
+#define DDSVCAPS_SPLIT 0x00000008
+#endif
+#define DDSVCAPS_STEREOSEQUENTIAL 0x00000010
+
+/* BitDepths */
+#define DDBD_1 0x00004000
+#define DDBD_2 0x00002000
+#define DDBD_4 0x00001000
+#define DDBD_8 0x00000800
+#define DDBD_16 0x00000400
+#define DDBD_24 0x00000200
+#define DDBD_32 0x00000100
+
+/* DDOVERLAYFX.dwDDFX */
+#define DDOVERFX_ARITHSTRETCHY 0x00000001
+#define DDOVERFX_MIRRORLEFTRIGHT 0x00000002
+#define DDOVERFX_MIRRORUPDOWN 0x00000004
+
+/* UpdateOverlay flags */
+#define DDOVER_ALPHADEST 0x00000001
+#define DDOVER_ALPHADESTCONSTOVERRIDE 0x00000002
+#define DDOVER_ALPHADESTNEG 0x00000004
+#define DDOVER_ALPHADESTSURFACEOVERRIDE 0x00000008
+#define DDOVER_ALPHAEDGEBLEND 0x00000010
+#define DDOVER_ALPHASRC 0x00000020
+#define DDOVER_ALPHASRCCONSTOVERRIDE 0x00000040
+#define DDOVER_ALPHASRCNEG 0x00000080
+#define DDOVER_ALPHASRCSURFACEOVERRIDE 0x00000100
+#define DDOVER_HIDE 0x00000200
+#define DDOVER_KEYDEST 0x00000400
+#define DDOVER_KEYDESTOVERRIDE 0x00000800
+#define DDOVER_KEYSRC 0x00001000
+#define DDOVER_KEYSRCOVERRIDE 0x00002000
+#define DDOVER_SHOW 0x00004000
+#define DDOVER_ADDDIRTYRECT 0x00008000
+#define DDOVER_REFRESHDIRTYRECTS 0x00010000
+#define DDOVER_REFRESHALL 0x00020000
+#define DDOVER_DDFX 0x00080000
+#define DDOVER_AUTOFLIP 0x00100000
+#define DDOVER_BOB 0x00200000
+#define DDOVER_OVERRIDEBOBWEAVE 0x00400000
+#define DDOVER_INTERLEAVED 0x00800000
+
+/* DDCOLORKEY.dwFlags */
+#define DDPF_ALPHAPIXELS 0x00000001
+#define DDPF_ALPHA 0x00000002
+#define DDPF_FOURCC 0x00000004
+#define DDPF_PALETTEINDEXED4 0x00000008
+#define DDPF_PALETTEINDEXEDTO8 0x00000010
+#define DDPF_PALETTEINDEXED8 0x00000020
+#define DDPF_RGB 0x00000040
+#define DDPF_COMPRESSED 0x00000080
+#define DDPF_RGBTOYUV 0x00000100
+#define DDPF_YUV 0x00000200
+#define DDPF_ZBUFFER 0x00000400
+#define DDPF_PALETTEINDEXED1 0x00000800
+#define DDPF_PALETTEINDEXED2 0x00001000
+#define DDPF_ZPIXELS 0x00002000
+#define DDPF_STENCILBUFFER 0x00004000
+#define DDPF_ALPHAPREMULT 0x00008000
+#define DDPF_LUMINANCE 0x00020000
+#define DDPF_BUMPLUMINANCE 0x00040000
+#define DDPF_BUMPDUDV 0x00080000
+
+/* SetCooperativeLevel dwFlags */
+#define DDSCL_FULLSCREEN 0x00000001
+#define DDSCL_ALLOWREBOOT 0x00000002
+#define DDSCL_NOWINDOWCHANGES 0x00000004
+#define DDSCL_NORMAL 0x00000008
+#define DDSCL_EXCLUSIVE 0x00000010
+#define DDSCL_ALLOWMODEX 0x00000040
+#define DDSCL_SETFOCUSWINDOW 0x00000080
+#define DDSCL_SETDEVICEWINDOW 0x00000100
+#define DDSCL_CREATEDEVICEWINDOW 0x00000200
+#define DDSCL_MULTITHREADED 0x00000400
+#define DDSCL_FPUSETUP 0x00000800
+#define DDSCL_FPUPRESERVE 0x00001000
+
+
+/* DDSURFACEDESC.dwFlags */
+#define DDSD_CAPS 0x00000001
+#define DDSD_HEIGHT 0x00000002
+#define DDSD_WIDTH 0x00000004
+#define DDSD_PITCH 0x00000008
+#define DDSD_BACKBUFFERCOUNT 0x00000020
+#define DDSD_ZBUFFERBITDEPTH 0x00000040
+#define DDSD_ALPHABITDEPTH 0x00000080
+#define DDSD_LPSURFACE 0x00000800
+#define DDSD_PIXELFORMAT 0x00001000
+#define DDSD_CKDESTOVERLAY 0x00002000
+#define DDSD_CKDESTBLT 0x00004000
+#define DDSD_CKSRCOVERLAY 0x00008000
+#define DDSD_CKSRCBLT 0x00010000
+#define DDSD_MIPMAPCOUNT 0x00020000
+#define DDSD_REFRESHRATE 0x00040000
+#define DDSD_LINEARSIZE 0x00080000
+#define DDSD_TEXTURESTAGE 0x00100000
+#define DDSD_FVF 0x00200000
+#define DDSD_SRCVBHANDLE 0x00400000
+#define DDSD_ALL 0x007ff9ee
+
+/* EnumSurfaces flags */
+#define DDENUMSURFACES_ALL 0x00000001
+#define DDENUMSURFACES_MATCH 0x00000002
+#define DDENUMSURFACES_NOMATCH 0x00000004
+#define DDENUMSURFACES_CANBECREATED 0x00000008
+#define DDENUMSURFACES_DOESEXIST 0x00000010
+
+/* SetDisplayMode flags */
+#define DDSDM_STANDARDVGAMODE 0x00000001
+
+/* EnumDisplayModes flags */
+#define DDEDM_REFRESHRATES 0x00000001
+#define DDEDM_STANDARDVGAMODES 0x00000002
+
+/* WaitForVerticalDisplay flags */
+
+#define DDWAITVB_BLOCKBEGIN 0x00000001
+#define DDWAITVB_BLOCKBEGINEVENT 0x00000002
+#define DDWAITVB_BLOCKEND 0x00000004
+
+typedef struct _DDSURFACEDESC
+{
+ DWORD dwSize; /* 0: size of the DDSURFACEDESC structure*/
+ DWORD dwFlags; /* 4: determines what fields are valid*/
+ DWORD dwHeight; /* 8: height of surface to be created*/
+ DWORD dwWidth; /* C: width of input surface*/
+ union {
+ LONG lPitch; /* 10: distance to start of next line (return value only)*/
+ DWORD dwLinearSize;
+ } DUMMYUNIONNAME1;
+ DWORD dwBackBufferCount;/* 14: number of back buffers requested*/
+ union {
+ DWORD dwMipMapCount;/* 18:number of mip-map levels requested*/
+ DWORD dwZBufferBitDepth;/*18: depth of Z buffer requested*/
+ DWORD dwRefreshRate;/* 18:refresh rate (used when display mode is described)*/
+ } DUMMYUNIONNAME2;
+ DWORD dwAlphaBitDepth;/* 1C:depth of alpha buffer requested*/
+ DWORD dwReserved; /* 20:reserved*/
+ LPVOID lpSurface; /* 24:pointer to the associated surface memory*/
+ DDCOLORKEY ddckCKDestOverlay;/* 28: CK for dest overlay use*/
+ DDCOLORKEY ddckCKDestBlt; /* 30: CK for destination blt use*/
+ DDCOLORKEY ddckCKSrcOverlay;/* 38: CK for source overlay use*/
+ DDCOLORKEY ddckCKSrcBlt; /* 40: CK for source blt use*/
+ DDPIXELFORMAT ddpfPixelFormat;/* 48: pixel format description of the surface*/
+ DDSCAPS ddsCaps; /* 68: direct draw surface caps */
+} DDSURFACEDESC,*LPDDSURFACEDESC;
+
+typedef struct _DDSURFACEDESC2
+{
+ DWORD dwSize; /* 0: size of the DDSURFACEDESC structure*/
+ DWORD dwFlags; /* 4: determines what fields are valid*/
+ DWORD dwHeight; /* 8: height of surface to be created*/
+ DWORD dwWidth; /* C: width of input surface*/
+ union {
+ LONG lPitch; /*10: distance to start of next line (return value only)*/
+ DWORD dwLinearSize; /*10: formless late-allocated optimized surface size */
+ } DUMMYUNIONNAME1;
+ DWORD dwBackBufferCount;/* 14: number of back buffers requested*/
+ union {
+ DWORD dwMipMapCount;/* 18:number of mip-map levels requested*/
+ DWORD dwRefreshRate;/* 18:refresh rate (used when display mode is described)*/
+ DWORD dwSrcVBHandle;/* 18:source used in VB::Optimize */
+ } DUMMYUNIONNAME2;
+ DWORD dwAlphaBitDepth;/* 1C:depth of alpha buffer requested*/
+ DWORD dwReserved; /* 20:reserved*/
+ LPVOID lpSurface; /* 24:pointer to the associated surface memory*/
+ union {
+ DDCOLORKEY ddckCKDestOverlay; /* 28: CK for dest overlay use*/
+ DWORD dwEmptyFaceColor; /* 28: color for empty cubemap faces */
+ } DUMMYUNIONNAME3;
+ DDCOLORKEY ddckCKDestBlt; /* 30: CK for destination blt use*/
+ DDCOLORKEY ddckCKSrcOverlay;/* 38: CK for source overlay use*/
+ DDCOLORKEY ddckCKSrcBlt; /* 40: CK for source blt use*/
+
+ union {
+ DDPIXELFORMAT ddpfPixelFormat;/* 48: pixel format description of the surface*/
+ DWORD dwFVF; /* 48: vertex format description of vertex buffers */
+ } DUMMYUNIONNAME4;
+ DDSCAPS2 ddsCaps; /* 68: DDraw surface caps */
+ DWORD dwTextureStage; /* 78: stage in multitexture cascade */
+} DDSURFACEDESC2,*LPDDSURFACEDESC2;
+
+/* DDCOLORCONTROL.dwFlags */
+#define DDCOLOR_BRIGHTNESS 0x00000001
+#define DDCOLOR_CONTRAST 0x00000002
+#define DDCOLOR_HUE 0x00000004
+#define DDCOLOR_SATURATION 0x00000008
+#define DDCOLOR_SHARPNESS 0x00000010
+#define DDCOLOR_GAMMA 0x00000020
+#define DDCOLOR_COLORENABLE 0x00000040
+
+typedef struct {
+ DWORD dwSize;
+ DWORD dwFlags;
+ LONG lBrightness;
+ LONG lContrast;
+ LONG lHue;
+ LONG lSaturation;
+ LONG lSharpness;
+ LONG lGamma;
+ LONG lColorEnable;
+ DWORD dwReserved1;
+} DDCOLORCONTROL,*LPDDCOLORCONTROL;
+
+typedef struct {
+ WORD red[256];
+ WORD green[256];
+ WORD blue[256];
+} DDGAMMARAMP,*LPDDGAMMARAMP;
+
+typedef BOOL CALLBACK (*LPDDENUMCALLBACKA)(GUID *, LPSTR, LPSTR, LPVOID);
+typedef BOOL CALLBACK (*LPDDENUMCALLBACKW)(GUID *, LPWSTR, LPWSTR, LPVOID);
+DECL_WINELIB_TYPE_AW(LPDDENUMCALLBACK)
+
+typedef HRESULT CALLBACK (*LPDDENUMMODESCALLBACK)(LPDDSURFACEDESC, LPVOID);
+typedef HRESULT CALLBACK (*LPDDENUMMODESCALLBACK2)(LPDDSURFACEDESC2, LPVOID);
+typedef HRESULT CALLBACK (*LPDDENUMSURFACESCALLBACK)(LPDIRECTDRAWSURFACE, LPDDSURFACEDESC, LPVOID);
+typedef HRESULT CALLBACK (*LPDDENUMSURFACESCALLBACK2)(LPDIRECTDRAWSURFACE4, LPDDSURFACEDESC2, LPVOID);
+typedef HRESULT CALLBACK (*LPDDENUMSURFACESCALLBACK7)(LPDIRECTDRAWSURFACE7, LPDDSURFACEDESC2, LPVOID);
+
+typedef BOOL CALLBACK (*LPDDENUMCALLBACKEXA)(GUID *, LPSTR, LPSTR, LPVOID, HMONITOR);
+typedef BOOL CALLBACK (*LPDDENUMCALLBACKEXW)(GUID *, LPWSTR, LPWSTR, LPVOID, HMONITOR);
+DECL_WINELIB_TYPE_AW(LPDDENUMCALLBACKEX)
+
+HRESULT WINAPI DirectDrawEnumerateExA( LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags);
+HRESULT WINAPI DirectDrawEnumerateExW( LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags);
+#define DirectDrawEnumerateEx WINELIB_NAME_AW(DirectDrawEnumerateEx)
+
+/* flags for DirectDrawEnumerateEx */
+#define DDENUM_ATTACHEDSECONDARYDEVICES 0x00000001
+#define DDENUM_DETACHEDSECONDARYDEVICES 0x00000002
+#define DDENUM_NONDISPLAYDEVICES 0x00000004
+
+/* flags for DirectDrawCreate or IDirectDraw::Initialize */
+#define DDCREATE_HARDWAREONLY 1L
+#define DDCREATE_EMULATIONONLY 2L
+
+typedef struct _DDBLTFX
+{
+ DWORD dwSize; /* size of structure */
+ DWORD dwDDFX; /* FX operations */
+ DWORD dwROP; /* Win32 raster operations */
+ DWORD dwDDROP; /* Raster operations new for DirectDraw */
+ DWORD dwRotationAngle; /* Rotation angle for blt */
+ DWORD dwZBufferOpCode; /* ZBuffer compares */
+ DWORD dwZBufferLow; /* Low limit of Z buffer */
+ DWORD dwZBufferHigh; /* High limit of Z buffer */
+ DWORD dwZBufferBaseDest; /* Destination base value */
+ DWORD dwZDestConstBitDepth; /* Bit depth used to specify Z constant for destination */
+ union
+ {
+ DWORD dwZDestConst; /* Constant to use as Z buffer for dest */
+ LPDIRECTDRAWSURFACE lpDDSZBufferDest; /* Surface to use as Z buffer for dest */
+ } DUMMYUNIONNAME1;
+ DWORD dwZSrcConstBitDepth; /* Bit depth used to specify Z constant for source */
+ union
+ {
+ DWORD dwZSrcConst; /* Constant to use as Z buffer for src */
+ LPDIRECTDRAWSURFACE lpDDSZBufferSrc; /* Surface to use as Z buffer for src */
+ } DUMMYUNIONNAME2;
+ DWORD dwAlphaEdgeBlendBitDepth; /* Bit depth used to specify constant for alpha edge blend */
+ DWORD dwAlphaEdgeBlend; /* Alpha for edge blending */
+ DWORD dwReserved;
+ DWORD dwAlphaDestConstBitDepth; /* Bit depth used to specify alpha constant for destination */
+ union
+ {
+ DWORD dwAlphaDestConst; /* Constant to use as Alpha Channel */
+ LPDIRECTDRAWSURFACE lpDDSAlphaDest; /* Surface to use as Alpha Channel */
+ } DUMMYUNIONNAME3;
+ DWORD dwAlphaSrcConstBitDepth; /* Bit depth used to specify alpha constant for source */
+ union
+ {
+ DWORD dwAlphaSrcConst; /* Constant to use as Alpha Channel */
+ LPDIRECTDRAWSURFACE lpDDSAlphaSrc; /* Surface to use as Alpha Channel */
+ } DUMMYUNIONNAME4;
+ union
+ {
+ DWORD dwFillColor; /* color in RGB or Palettized */
+ DWORD dwFillDepth; /* depth value for z-buffer */
+ DWORD dwFillPixel; /* pixel val for RGBA or RGBZ */
+ LPDIRECTDRAWSURFACE lpDDSPattern; /* Surface to use as pattern */
+ } DUMMYUNIONNAME5;
+ DDCOLORKEY ddckDestColorkey; /* DestColorkey override */
+ DDCOLORKEY ddckSrcColorkey; /* SrcColorkey override */
+} DDBLTFX,*LPDDBLTFX;
+
+/* dwDDFX */
+/* arithmetic stretching along y axis */
+#define DDBLTFX_ARITHSTRETCHY 0x00000001
+/* mirror on y axis */
+#define DDBLTFX_MIRRORLEFTRIGHT 0x00000002
+/* mirror on x axis */
+#define DDBLTFX_MIRRORUPDOWN 0x00000004
+/* do not tear */
+#define DDBLTFX_NOTEARING 0x00000008
+/* 180 degrees clockwise rotation */
+#define DDBLTFX_ROTATE180 0x00000010
+/* 270 degrees clockwise rotation */
+#define DDBLTFX_ROTATE270 0x00000020
+/* 90 degrees clockwise rotation */
+#define DDBLTFX_ROTATE90 0x00000040
+/* dwZBufferLow and dwZBufferHigh specify limits to the copied Z values */
+#define DDBLTFX_ZBUFFERRANGE 0x00000080
+/* add dwZBufferBaseDest to every source z value before compare */
+#define DDBLTFX_ZBUFFERBASEDEST 0x00000100
+
+typedef struct _DDOVERLAYFX
+{
+ DWORD dwSize; /* size of structure */
+ DWORD dwAlphaEdgeBlendBitDepth; /* Bit depth used to specify constant for alpha edge blend */
+ DWORD dwAlphaEdgeBlend; /* Constant to use as alpha for edge blend */
+ DWORD dwReserved;
+ DWORD dwAlphaDestConstBitDepth; /* Bit depth used to specify alpha constant for destination */
+ union
+ {
+ DWORD dwAlphaDestConst; /* Constant to use as alpha channel for dest */
+ LPDIRECTDRAWSURFACE lpDDSAlphaDest; /* Surface to use as alpha channel for dest */
+ } DUMMYUNIONNAME1;
+ DWORD dwAlphaSrcConstBitDepth; /* Bit depth used to specify alpha constant for source */
+ union
+ {
+ DWORD dwAlphaSrcConst; /* Constant to use as alpha channel for src */
+ LPDIRECTDRAWSURFACE lpDDSAlphaSrc; /* Surface to use as alpha channel for src */
+ } DUMMYUNIONNAME2;
+ DDCOLORKEY dckDestColorkey; /* DestColorkey override */
+ DDCOLORKEY dckSrcColorkey; /* DestColorkey override */
+ DWORD dwDDFX; /* Overlay FX */
+ DWORD dwFlags; /* flags */
+} DDOVERLAYFX,*LPDDOVERLAYFX;
+
+typedef struct _DDBLTBATCH
+{
+ LPRECT lprDest;
+ LPDIRECTDRAWSURFACE lpDDSSrc;
+ LPRECT lprSrc;
+ DWORD dwFlags;
+ LPDDBLTFX lpDDBltFx;
+} DDBLTBATCH,*LPDDBLTBATCH;
+
+#define MAX_DDDEVICEID_STRING 512
+
+typedef struct tagDDDEVICEIDENTIFIER {
+ char szDriver[MAX_DDDEVICEID_STRING];
+ char szDescription[MAX_DDDEVICEID_STRING];
+ LARGE_INTEGER liDriverVersion;
+ DWORD dwVendorId;
+ DWORD dwDeviceId;
+ DWORD dwSubSysId;
+ DWORD dwRevision;
+ GUID guidDeviceIdentifier;
+} DDDEVICEIDENTIFIER, * LPDDDEVICEIDENTIFIER;
+
+typedef struct tagDDDEVICEIDENTIFIER2 {
+ char szDriver[MAX_DDDEVICEID_STRING]; /* user readable driver name */
+ char szDescription[MAX_DDDEVICEID_STRING]; /* user readable description */
+ LARGE_INTEGER liDriverVersion; /* driver version */
+ DWORD dwVendorId; /* vendor ID, zero if unknown */
+ DWORD dwDeviceId; /* chipset ID, zero if unknown */
+ DWORD dwSubSysId; /* board ID, zero if unknown */
+ DWORD dwRevision; /* chipset version, zero if unknown */
+ GUID guidDeviceIdentifier; /* unique ID for this driver/chipset combination */
+ DWORD dwWHQLLevel; /* Windows Hardware Quality Lab certification level */
+} DDDEVICEIDENTIFIER2, * LPDDDEVICEIDENTIFIER2;
+
+/*****************************************************************************
+ * IDirectDrawPalette interface
+ */
+#undef INTERFACE
+#define INTERFACE IDirectDrawPalette
+DECLARE_INTERFACE_(IDirectDrawPalette,IUnknown)
+{
+ STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ STDMETHOD(GetCaps)(THIS_ LPDWORD lpdwCaps) PURE;
+ STDMETHOD(GetEntries)(THIS_ DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries) PURE;
+ STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpDDColorTable) PURE;
+ STDMETHOD(SetEntries)(THIS_ DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries) PURE;
+};
+
+ /*** IUnknown methods ***/
+#define IDirectDrawPalette_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
+#define IDirectDrawPalette_AddRef(p) ICOM_CALL_(AddRef,p,(p))
+#define IDirectDrawPalette_Release(p) ICOM_CALL_(Release,p,(p))
+ /*** IDirectDrawPalette methods ***/
+#define IDirectDrawPalette_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a))
+#define IDirectDrawPalette_GetEntries(p,a,b,c,d) ICOM_CALL_(GetEntries,p,(p,a,b,c,d))
+#define IDirectDrawPalette_Initialize(p,a,b,c) ICOM_CALL_(Initialize,p,(p,a,b,c))
+#define IDirectDrawPalette_SetEntries(p,a,b,c,d) ICOM_CALL_(SetEntries,p,(p,a,b,c,d))
+
+
+/*****************************************************************************
+ * IDirectDrawClipper interface
+ */
+#undef INTERFACE
+#define INTERFACE IDirectDrawClipper
+DECLARE_INTERFACE_(IDirectDrawClipper,IUnknown)
+{
+ STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ STDMETHOD(GetClipList)(THIS_ LPRECT lpRect, LPRGNDATA lpClipList, LPDWORD lpdwSize) PURE;
+ STDMETHOD(GetHWnd)(THIS_ HWND* lphWnd) PURE;
+ STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW lpDD, DWORD dwFlags) PURE;
+ STDMETHOD(IsClipListChanged)(THIS_ BOOL* lpbChanged) PURE;
+ STDMETHOD(SetClipList)(THIS_ LPRGNDATA lpClipList, DWORD dwFlags) PURE;
+ STDMETHOD(SetHWnd)(THIS_ DWORD dwFlags, HWND hWnd) PURE;
+};
+
+ /*** IUnknown methods ***/
+#define IDirectDrawClipper_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
+#define IDirectDrawClipper_AddRef(p) ICOM_CALL_(AddRef,p,(p))
+#define IDirectDrawClipper_Release(p) ICOM_CALL_(Release,p,(p))
+ /*** IDirectDrawClipper methods ***/
+#define IDirectDrawClipper_GetClipList(p,a,b,c) ICOM_CALL_(GetClipList,p,(p,a,b,c))
+#define IDirectDrawClipper_GetHWnd(p,a) ICOM_CALL_(GetHWnd,p,(p,a))
+#define IDirectDrawClipper_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b))
+#define IDirectDrawClipper_IsClipListChanged(p,a) ICOM_CALL_(IsClipListChanged,p,(p,a))
+#define IDirectDrawClipper_SetClipList(p,a,b) ICOM_CALL_(SetClipList,p,(p,a,b))
+#define IDirectDrawClipper_SetHWnd(p,a,b) ICOM_CALL_(SetHWnd,p,(p,a,b))
+
+
+/*****************************************************************************
+ * IDirectDraw interface
+ */
+#undef INTERFACE
+#define INTERFACE IDirectDraw
+DECLARE_INTERFACE_(IDirectDraw,IUnknown)
+{
+ STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ STDMETHOD(Compact)(THIS) PURE;
+ STDMETHOD(CreateClipper)(THIS_ DWORD dwFlags, LPDIRECTDRAWCLIPPER* lplpDDClipper, IUnknown* pUnkOuter) PURE;
+ STDMETHOD(CreatePalette)(THIS_ DWORD dwFlags, LPPALETTEENTRY lpColorTable, LPDIRECTDRAWPALETTE* lplpDDPalette, IUnknown* pUnkOuter) PURE;
+ STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE* lplpDDSurface, IUnknown* pUnkOuter) PURE;
+ STDMETHOD(DuplicateSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDSurface, LPDIRECTDRAWSURFACE* lplpDupDDSurface) PURE;
+ STDMETHOD(EnumDisplayModes)(THIS_ DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK lpEnumModesCallback) PURE;
+ STDMETHOD(EnumSurfaces)(THIS_ DWORD dwFlags, LPDDSURFACEDESC lpDDSD, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback) PURE;
+ STDMETHOD(FlipToGDISurface)(THIS) PURE;
+ STDMETHOD(GetCaps)(THIS_ LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps) PURE;
+ STDMETHOD(GetDisplayMode)(THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
+ STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD lpNumCodes, LPDWORD lpCodes) PURE;
+ STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE* lplpGDIDDSurface) PURE;
+ STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD lpdwFrequency) PURE;
+ STDMETHOD(GetScanLine)(THIS_ LPDWORD lpdwScanLine) PURE;
+ STDMETHOD(GetVerticalBlankStatus)(THIS_ BOOL* lpbIsInVB) PURE;
+ STDMETHOD(Initialize)(THIS_ GUID* lpGUID) PURE;
+ STDMETHOD(RestoreDisplayMode)(THIS) PURE;
+ STDMETHOD(SetCooperativeLevel)(THIS_ HWND hWnd, DWORD dwFlags) PURE;
+ STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD, DWORD) PURE;
+ STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD dwFlags, HANDLE hEvent) PURE;
+};
+
+ /*** IUnknown methods ***/
+#define IDirectDraw_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
+#define IDirectDraw_AddRef(p) ICOM_CALL_(AddRef,p,(p))
+#define IDirectDraw_Release(p) ICOM_CALL_(Release,p,(p))
+ /*** IDirectDraw methods ***/
+#define IDirectDraw_Compact(p) ICOM_CALL_(Compact,p,(p))
+#define IDirectDraw_CreateClipper(p,a,b,c) ICOM_CALL_(CreateClipper,p,(p,a,b,c))
+#define IDirectDraw_CreatePalette(p,a,b,c,d) ICOM_CALL_(CreatePalette,p,(p,a,b,c,d))
+#define IDirectDraw_CreateSurface(p,a,b,c) ICOM_CALL_(CreateSurface,p,(p,a,b,c))
+#define IDirectDraw_DuplicateSurface(p,a,b) ICOM_CALL_(DuplicateSurface,p,(p,a,b))
+#define IDirectDraw_EnumDisplayModes(p,a,b,c,d) ICOM_CALL_(EnumDisplayModes,p,(p,a,b,c,d))
+#define IDirectDraw_EnumSurfaces(p,a,b,c,d) ICOM_CALL_(EnumSurfaces,p,(p,a,b,c,d))
+#define IDirectDraw_FlipToGDISurface(p) ICOM_CALL_(FlipToGDISurface,p,(p))
+#define IDirectDraw_GetCaps(p,a,b) ICOM_CALL_(GetCaps,p,(p,a,b))
+#define IDirectDraw_GetDisplayMode(p,a) ICOM_CALL_(GetDisplayMode,p,(p,a))
+#define IDirectDraw_GetFourCCCodes(p,a,b) ICOM_CALL_(GetFourCCCodes,p,(p,a,b))
+#define IDirectDraw_GetGDISurface(p,a) ICOM_CALL_(GetGDISurface,p,(p,a))
+#define IDirectDraw_GetMonitorFrequency(p,a) ICOM_CALL_(GetMonitorFrequency,p,(p,a))
+#define IDirectDraw_GetScanLine(p,a) ICOM_CALL_(GetScanLine,p,(p,a))
+#define IDirectDraw_GetVerticalBlankStatus(p,a) ICOM_CALL_(GetVerticalBlankStatus,p,(p,a))
+#define IDirectDraw_Initialize(p,a) ICOM_CALL_(Initialize,p,(p,a))
+#define IDirectDraw_RestoreDisplayMode(p) ICOM_CALL_(RestoreDisplayMode,p,(p))
+#define IDirectDraw_SetCooperativeLevel(p,a,b) ICOM_CALL_(SetCooperativeLevel,p,(p,a,b))
+#define IDirectDraw_SetDisplayMode(p,a,b,c) ICOM_CALL_(SetDisplayMode,p,(p,a,b,c))
+#define IDirectDraw_WaitForVerticalBlank(p,a,b) ICOM_CALL_(WaitForVerticalBlank,p,(p,a,b))
+
+
+/* flags for Lock() */
+#define DDLOCK_SURFACEMEMORYPTR 0x00000000
+#define DDLOCK_WAIT 0x00000001
+#define DDLOCK_EVENT 0x00000002
+#define DDLOCK_READONLY 0x00000010
+#define DDLOCK_WRITEONLY 0x00000020
+#define DDLOCK_NOSYSLOCK 0x00000800
+
+
+/*****************************************************************************
+ * IDirectDraw2 interface
+ */
+/* Note: IDirectDraw2 cannot derive from IDirectDraw because the number of
+ * arguments of SetDisplayMode has changed !
+ */
+#undef INTERFACE
+#define INTERFACE IDirectDraw2
+DECLARE_INTERFACE_(IDirectDraw2,IUnknown)
+{
+ STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ STDMETHOD(Compact)(THIS) PURE;
+ STDMETHOD(CreateClipper)(THIS_ DWORD dwFlags, LPDIRECTDRAWCLIPPER* lplpDDClipper, IUnknown* pUnkOuter) PURE;
+ STDMETHOD(CreatePalette)(THIS_ DWORD dwFlags, LPPALETTEENTRY lpColorTable, LPDIRECTDRAWPALETTE* lplpDDPalette, IUnknown* pUnkOuter) PURE;
+ STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE2* lplpDDSurface, IUnknown* pUnkOuter) PURE;
+ STDMETHOD(DuplicateSurface)(THIS_ LPDIRECTDRAWSURFACE2 lpDDSurface, LPDIRECTDRAWSURFACE2* lplpDupDDSurface) PURE;
+ STDMETHOD(EnumDisplayModes)(THIS_ DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK lpEnumModesCallback) PURE;
+ STDMETHOD(EnumSurfaces)(THIS_ DWORD dwFlags, LPDDSURFACEDESC lpDDSD, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback) PURE;
+ STDMETHOD(FlipToGDISurface)(THIS) PURE;
+ STDMETHOD(GetCaps)(THIS_ LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps) PURE;
+ STDMETHOD(GetDisplayMode)(THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
+ STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD lpNumCodes, LPDWORD lpCodes) PURE;
+ STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE2* lplpGDIDDSurface) PURE;
+ STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD lpdwFrequency) PURE;
+ STDMETHOD(GetScanLine)(THIS_ LPDWORD lpdwScanLine) PURE;
+ STDMETHOD(GetVerticalBlankStatus)(THIS_ BOOL* lpbIsInVB) PURE;
+ STDMETHOD(Initialize)(THIS_ GUID* lpGUID) PURE;
+ STDMETHOD(RestoreDisplayMode)(THIS) PURE;
+ STDMETHOD(SetCooperativeLevel)(THIS_ HWND hWnd, DWORD dwFlags) PURE;
+ STDMETHOD(SetDisplayMode)(THIS_ DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags) PURE;
+ STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD dwFlags, HANDLE hEvent) PURE;
+
+ STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS lpDDCaps, LPDWORD lpdwTotal, LPDWORD lpdwFree) PURE;
+};
+
+ /*** IUnknown methods ***/
+#define IDirectDraw2_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
+#define IDirectDraw2_AddRef(p) ICOM_CALL_(AddRef,p,(p))
+#define IDirectDraw2_Release(p) ICOM_CALL_(Release,p,(p))
+ /*** IDirectDraw methods ***/
+#define IDirectDraw2_Compact(p) ICOM_CALL_(Compact,p,(p))
+#define IDirectDraw2_CreateClipper(p,a,b,c) ICOM_CALL_(CreateClipper,p,(p,a,b,c))
+#define IDirectDraw2_CreatePalette(p,a,b,c,d) ICOM_CALL_(CreatePalette,p,(p,a,b,c,d))
+#define IDirectDraw2_CreateSurface(p,a,b,c) ICOM_CALL_(CreateSurface,p,(p,a,b,c))
+#define IDirectDraw2_DuplicateSurface(p,a,b) ICOM_CALL_(DuplicateSurface,p,(p,a,b))
+#define IDirectDraw2_EnumDisplayModes(p,a,b,c,d) ICOM_CALL_(EnumDisplayModes,p,(p,a,b,c,d))
+#define IDirectDraw2_EnumSurfaces(p,a,b,c,d) ICOM_CALL_(EnumSurfaces,p,(p,a,b,c,d))
+#define IDirectDraw2_FlipToGDISurface(p) ICOM_CALL_(FlipToGDISurface,p,(p))
+#define IDirectDraw2_GetCaps(p,a,b) ICOM_CALL_(GetCaps,p,(p,a,b))
+#define IDirectDraw2_GetDisplayMode(p,a) ICOM_CALL_(GetDisplayMode,p,(p,a))
+#define IDirectDraw2_GetFourCCCodes(p,a,b) ICOM_CALL_(GetFourCCCodes,p,(p,a,b))
+#define IDirectDraw2_GetGDISurface(p,a) ICOM_CALL_(GetGDISurface,p,(p,a))
+#define IDirectDraw2_GetMonitorFrequency(p,a) ICOM_CALL_(GetMonitorFrequency,p,(p,a))
+#define IDirectDraw2_GetScanLine(p,a) ICOM_CALL_(GetScanLine,p,(p,a))
+#define IDirectDraw2_GetVerticalBlankStatus(p,a) ICOM_CALL_(GetVerticalBlankStatus,p,(p,a))
+#define IDirectDraw2_Initialize(p,a) ICOM_CALL_(Initialize,p,(p,a))
+#define IDirectDraw2_RestoreDisplayMode(p) ICOM_CALL_(RestoreDisplayMode,p,(p))
+#define IDirectDraw2_SetCooperativeLevel(p,a,b) ICOM_CALL_(SetCooperativeLevel,p,(p,a,b))
+#define IDirectDraw2_SetDisplayMode(p,a,b,c,d,e) ICOM_CALL_(SetDisplayMode,p,(p,a,b,c,d,e))
+#define IDirectDraw2_WaitForVerticalBlank(p,a,b) ICOM_CALL_(WaitForVerticalBlank,p,(p,a,b))
+/*** IDirectDraw2 methods ***/
+#define IDirectDraw2_GetAvailableVidMem(p,a,b,c) ICOM_CALL_(GetAvailableVidMem,p,(p,a,b,c))
+
+
+/*****************************************************************************
+ * IDirectDraw4 interface
+ */
+#undef INTERFACE
+#define INTERFACE IDirectDraw4
+DECLARE_INTERFACE_(IDirectDraw4,IUnknown)
+{
+ STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ STDMETHOD(Compact)(THIS) PURE;
+ STDMETHOD(CreateClipper)(THIS_ DWORD dwFlags, LPDIRECTDRAWCLIPPER* lplpDDClipper, IUnknown* pUnkOuter) PURE;
+ STDMETHOD(CreatePalette)(THIS_ DWORD dwFlags, LPPALETTEENTRY lpColorTable, LPDIRECTDRAWPALETTE* lplpDDPalette, IUnknown* pUnkOuter) PURE;
+ STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC2 lpDDSurfaceDesc, LPDIRECTDRAWSURFACE4* lplpDDSurface, IUnknown* pUnkOuter) PURE;
+ STDMETHOD(DuplicateSurface)(THIS_ LPDIRECTDRAWSURFACE4 lpDDSurface, LPDIRECTDRAWSURFACE4* lplpDupDDSurface) PURE;
+ STDMETHOD(EnumDisplayModes)(THIS_ DWORD dwFlags, LPDDSURFACEDESC2 lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK2 lpEnumModesCallback) PURE;
+ STDMETHOD(EnumSurfaces)(THIS_ DWORD dwFlags, LPDDSURFACEDESC2 lpDDSD, LPVOID lpContext, LPDDENUMSURFACESCALLBACK2 lpEnumSurfacesCallback) PURE;
+ STDMETHOD(FlipToGDISurface)(THIS) PURE;
+ STDMETHOD(GetCaps)(THIS_ LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps) PURE;
+ STDMETHOD(GetDisplayMode)(THIS_ LPDDSURFACEDESC2 lpDDSurfaceDesc) PURE;
+ STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD lpNumCodes, LPDWORD lpCodes) PURE;
+ STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE4* lplpGDIDDSurface) PURE;
+ STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD lpdwFrequency) PURE;
+ STDMETHOD(GetScanLine)(THIS_ LPDWORD lpdwScanLine) PURE;
+ STDMETHOD(GetVerticalBlankStatus)(THIS_ BOOL* lpbIsInVB) PURE;
+ STDMETHOD(Initialize)(THIS_ GUID* lpGUID) PURE;
+ STDMETHOD(RestoreDisplayMode)(THIS) PURE;
+ STDMETHOD(SetCooperativeLevel)(THIS_ HWND hWnd, DWORD dwFlags) PURE;
+ STDMETHOD(SetDisplayMode)(THIS_ DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags) PURE;
+ STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD dwFlags, HANDLE hEvent) PURE;
+
+ STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS2 lpDDCaps, LPDWORD lpdwTotal, LPDWORD lpdwFree) PURE;
+
+ STDMETHOD(GetSurfaceFromDC)(THIS_ HDC , LPDIRECTDRAWSURFACE4* ) PURE;
+ STDMETHOD(RestoreAllSurfaces)(THIS) PURE;
+ STDMETHOD(TestCooperativeLevel)(THIS) PURE;
+ STDMETHOD(GetDeviceIdentifier)(THIS_ LPDDDEVICEIDENTIFIER , DWORD ) PURE;
+};
+
+ /*** IUnknown methods ***/
+#define IDirectDraw4_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
+#define IDirectDraw4_AddRef(p) ICOM_CALL_(AddRef,p,(p))
+#define IDirectDraw4_Release(p) ICOM_CALL_(Release,p,(p))
+ /*** IDirectDraw methods ***/
+#define IDirectDraw4_Compact(p) ICOM_CALL_(Compact,p,(p))
+#define IDirectDraw4_CreateClipper(p,a,b,c) ICOM_CALL_(CreateClipper,p,(p,a,b,c))
+#define IDirectDraw4_CreatePalette(p,a,b,c,d) ICOM_CALL_(CreatePalette,p,(p,a,b,c,d))
+#define IDirectDraw4_CreateSurface(p,a,b,c) ICOM_CALL_(CreateSurface,p,(p,a,b,c))
+#define IDirectDraw4_DuplicateSurface(p,a,b) ICOM_CALL_(DuplicateSurface,p,(p,a,b))
+#define IDirectDraw4_EnumDisplayModes(p,a,b,c,d) ICOM_CALL_(EnumDisplayModes,p,(p,a,b,c,d))
+#define IDirectDraw4_EnumSurfaces(p,a,b,c,d) ICOM_CALL_(EnumSurfaces,p,(p,a,b,c,d))
+#define IDirectDraw4_FlipToGDISurface(p) ICOM_CALL_(FlipToGDISurface,p,(p))
+#define IDirectDraw4_GetCaps(p,a,b) ICOM_CALL_(GetCaps,p,(p,a,b))
+#define IDirectDraw4_GetDisplayMode(p,a) ICOM_CALL_(GetDisplayMode,p,(p,a))
+#define IDirectDraw4_GetFourCCCodes(p,a,b) ICOM_CALL_(GetFourCCCodes,p,(p,a,b))
+#define IDirectDraw4_GetGDISurface(p,a) ICOM_CALL_(GetGDISurface,p,(p,a))
+#define IDirectDraw4_GetMonitorFrequency(p,a) ICOM_CALL_(GetMonitorFrequency,p,(p,a))
+#define IDirectDraw4_GetScanLine(p,a) ICOM_CALL_(GetScanLine,p,(p,a))
+#define IDirectDraw4_GetVerticalBlankStatus(p,a) ICOM_CALL_(GetVerticalBlankStatus,p,(p,a))
+#define IDirectDraw4_Initialize(p,a) ICOM_CALL_(Initialize,p,(p,a))
+#define IDirectDraw4_RestoreDisplayMode(p) ICOM_CALL_(RestoreDisplayMode,p,(p))
+#define IDirectDraw4_SetCooperativeLevel(p,a,b) ICOM_CALL_(SetCooperativeLevel,p,(p,a,b))
+#define IDirectDraw4_SetDisplayMode(p,a,b,c,d,e) ICOM_CALL_(SetDisplayMode,p,(p,a,b,c,d,e))
+#define IDirectDraw4_WaitForVerticalBlank(p,a,b) ICOM_CALL_(WaitForVerticalBlank,p,(p,a,b))
+/*** IDirectDraw2 methods ***/
+#define IDirectDraw4_GetAvailableVidMem(p,a,b,c) ICOM_CALL_(GetAvailableVidMem,p,(p,a,b,c))
+/*** IDirectDraw4 methods ***/
+#define IDirectDraw4_GetSurfaceFromDC(p,a,b) ICOM_CALL_(GetSurfaceFromDC,p,(p,a,b))
+#define IDirectDraw4_RestoreAllSurfaces(pc) ICOM_CALL_(RestoreAllSurfaces,p,(p))
+#define IDirectDraw4_TestCooperativeLevel(p) ICOM_CALL_(TestCooperativeLevel,p,(p))
+#define IDirectDraw4_GetDeviceIdentifier(p,a,b) ICOM_CALL_(GetDeviceIdentifier,p,(p,a,b))
+
+
+/*****************************************************************************
+ * IDirectDraw7 interface
+ */
+/* Note: IDirectDraw7 cannot derive from IDirectDraw4; it is even documented
+ * as not interchangeable with earlier DirectDraw interfaces.
+ */
+#undef INTERFACE
+#define INTERFACE IDirectDraw7
+DECLARE_INTERFACE_(IDirectDraw7,IUnknown)
+{
+ STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ STDMETHOD(Compact)(THIS) PURE;
+ STDMETHOD(CreateClipper)(THIS_ DWORD dwFlags, LPDIRECTDRAWCLIPPER* lplpDDClipper, IUnknown* pUnkOuter) PURE;
+ STDMETHOD(CreatePalette)(THIS_ DWORD dwFlags, LPPALETTEENTRY lpColorTable, LPDIRECTDRAWPALETTE* lplpDDPalette, IUnknown* pUnkOuter) PURE;
+ STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC2 lpDDSurfaceDesc, LPDIRECTDRAWSURFACE7* lplpDDSurface, IUnknown* pUnkOuter) PURE;
+ STDMETHOD(DuplicateSurface)(THIS_ LPDIRECTDRAWSURFACE7 lpDDSurface, LPDIRECTDRAWSURFACE7* lplpDupDDSurface) PURE;
+ STDMETHOD(EnumDisplayModes)(THIS_ DWORD dwFlags, LPDDSURFACEDESC2 lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK2 lpEnumModesCallback) PURE;
+ STDMETHOD(EnumSurfaces)(THIS_ DWORD dwFlags, LPDDSURFACEDESC2 lpDDSD, LPVOID lpContext, LPDDENUMSURFACESCALLBACK7 lpEnumSurfacesCallback) PURE;
+ STDMETHOD(FlipToGDISurface)(THIS) PURE;
+ STDMETHOD(GetCaps)(THIS_ LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps) PURE;
+ STDMETHOD(GetDisplayMode)(THIS_ LPDDSURFACEDESC2 lpDDSurfaceDesc) PURE;
+ STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD lpNumCodes, LPDWORD lpCodes) PURE;
+ STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE7* lplpGDIDDSurface) PURE;
+ STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD lpdwFrequency) PURE;
+ STDMETHOD(GetScanLine)(THIS_ LPDWORD lpdwScanLine) PURE;
+ STDMETHOD(GetVerticalBlankStatus)(THIS_ BOOL* lpbIsInVB) PURE;
+ STDMETHOD(Initialize)(THIS_ GUID* lpGUID) PURE;
+ STDMETHOD(RestoreDisplayMode)(THIS) PURE;
+ STDMETHOD(SetCooperativeLevel)(THIS_ HWND hWnd, DWORD dwFlags) PURE;
+ STDMETHOD(SetDisplayMode)(THIS_ DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags) PURE;
+ STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD dwFlags, HANDLE hEvent) PURE;
+
+ STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS2 lpDDCaps, LPDWORD lpdwTotal, LPDWORD lpdwFree) PURE;
+
+ STDMETHOD(GetSurfaceFromDC)(THIS_ HDC , LPDIRECTDRAWSURFACE7* ) PURE;
+ STDMETHOD(RestoreAllSurfaces)(THIS) PURE;
+ STDMETHOD(TestCooperativeLevel)(THIS) PURE;
+ STDMETHOD(GetDeviceIdentifier)(THIS_ LPDDDEVICEIDENTIFIER2 , DWORD ) PURE;
+
+ STDMETHOD(StartModeTest)(THIS_ LPSIZE , DWORD , DWORD ) PURE;
+ STDMETHOD(EvaluateMode)(THIS_ DWORD , DWORD * ) PURE;
+};
+
+ /*** IUnknown methods ***/
+#define IDirectDraw7_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
+#define IDirectDraw7_AddRef(p) ICOM_CALL_(AddRef,p,(p))
+#define IDirectDraw7_Release(p) ICOM_CALL_(Release,p,(p))
+ /*** IDirectDraw methods ***/
+#define IDirectDraw7_Compact(p) ICOM_CALL_(Compact,p,(p))
+#define IDirectDraw7_CreateClipper(p,a,b,c) ICOM_CALL_(CreateClipper,p,(p,a,b,c))
+#define IDirectDraw7_CreatePalette(p,a,b,c,d) ICOM_CALL_(CreatePalette,p,(p,a,b,c,d))
+#define IDirectDraw7_CreateSurface(p,a,b,c) ICOM_CALL_(CreateSurface,p,(p,a,b,c))
+#define IDirectDraw7_DuplicateSurface(p,a,b) ICOM_CALL_(DuplicateSurface,p,(p,a,b))
+#define IDirectDraw7_EnumDisplayModes(p,a,b,c,d) ICOM_CALL_(EnumDisplayModes,p,(p,a,b,c,d))
+#define IDirectDraw7_EnumSurfaces(p,a,b,c,d) ICOM_CALL_(EnumSurfaces,p,(p,a,b,c,d))
+#define IDirectDraw7_FlipToGDISurface(p) ICOM_CALL_(FlipToGDISurface,p,(p))
+#define IDirectDraw7_GetCaps(p,a,b) ICOM_CALL_(GetCaps,p,(p,a,b))
+#define IDirectDraw7_GetDisplayMode(p,a) ICOM_CALL_(GetDisplayMode,p,(p,a))
+#define IDirectDraw7_GetFourCCCodes(p,a,b) ICOM_CALL_(GetFourCCCodes,p,(p,a,b))
+#define IDirectDraw7_GetGDISurface(p,a) ICOM_CALL_(GetGDISurface,p,(p,a))
+#define IDirectDraw7_GetMonitorFrequency(p,a) ICOM_CALL_(GetMonitorFrequency,p,(p,a))
+#define IDirectDraw7_GetScanLine(p,a) ICOM_CALL_(GetScanLine,p,(p,a))
+#define IDirectDraw7_GetVerticalBlankStatus(p,a) ICOM_CALL_(GetVerticalBlankStatus,p,(p,a))
+#define IDirectDraw7_Initialize(p,a) ICOM_CALL_(Initialize,p,(p,a))
+#define IDirectDraw7_RestoreDisplayMode(p) ICOM_CALL_(RestoreDisplayMode,p,(p))
+#define IDirectDraw7_SetCooperativeLevel(p,a,b) ICOM_CALL_(SetCooperativeLevel,p,(p,a,b))
+#define IDirectDraw7_SetDisplayMode(p,a,b,c,d,e) ICOM_CALL_(SetDisplayMode,p,(p,a,b,c,d,e))
+#define IDirectDraw7_WaitForVerticalBlank(p,a,b) ICOM_CALL_(WaitForVerticalBlank,p,(p,a,b))
+/*** added in IDirectDraw2 ***/
+#define IDirectDraw7_GetAvailableVidMem(p,a,b,c) ICOM_CALL_(GetAvailableVidMem,p,(p,a,b,c))
+/*** added in IDirectDraw4 ***/
+#define IDirectDraw7_GetSurfaceFromDC(p,a,b) ICOM_CALL_(GetSurfaceFromDC,p,(p,a,b))
+#define IDirectDraw7_RestoreAllSurfaces(p) ICOM_CALL_(RestoreAllSurfaces,p,(p))
+#define IDirectDraw7_TestCooperativeLevel(p) ICOM_CALL_(TestCooperativeLevel,p,(p))
+#define IDirectDraw7_GetDeviceIdentifier(p,a,b) ICOM_CALL_(GetDeviceIdentifier,p,(p,a,b))
+/*** added in IDirectDraw 7 ***/
+#define IDirectDraw7_StartModeTest(p,a,b,c) ICOM_CALL_(StartModeTest,p,(p,a,b,c))
+#define IDirectDraw7_EvaluateMode(p,a,b) ICOM_CALL_(EvaluateMode,p,(p,a,b))
+
+
+/*****************************************************************************
+ * IDirectDrawSurface interface
+ */
+#undef INTERFACE
+#define INTERFACE IDirectDrawSurface
+DECLARE_INTERFACE_(IDirectDrawSurface,IUnknown)
+{
+ STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDSAttachedSurface) PURE;
+ STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT lpRect) PURE;
+ STDMETHOD(Blt)(THIS_ LPRECT lpDestRect, LPDIRECTDRAWSURFACE lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx) PURE;
+ STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags) PURE;
+ STDMETHOD(BltFast)(THIS_ DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans) PURE;
+ STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSAttachedSurface) PURE;
+ STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback) PURE;
+ STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfnCallback) PURE;
+ STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride, DWORD dwFlags) PURE;
+ STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS lpDDSCaps, LPDIRECTDRAWSURFACE* lplpDDAttachedSurface) PURE;
+ STDMETHOD(GetBltStatus)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(GetCaps)(THIS_ LPDDSCAPS lpDDSCaps) PURE;
+ STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER* lplpDDClipper) PURE;
+ STDMETHOD(GetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
+ STDMETHOD(GetDC)(THIS_ HDC* lphDC) PURE;
+ STDMETHOD(GetFlipStatus)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(GetOverlayPosition)(THIS_ LPLONG lplX, LPLONG lplY) PURE;
+ STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE* lplpDDPalette) PURE;
+ STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT lpDDPixelFormat) PURE;
+ STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
+ STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
+ STDMETHOD(IsLost)(THIS) PURE;
+ STDMETHOD(Lock)(THIS_ LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent) PURE;
+ STDMETHOD(ReleaseDC)(THIS_ HDC hDC) PURE;
+ STDMETHOD(Restore)(THIS) PURE;
+ STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper) PURE;
+ STDMETHOD(SetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
+ STDMETHOD(SetOverlayPosition)(THIS_ LONG lX, LONG lY) PURE;
+ STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE lpDDPalette) PURE;
+ STDMETHOD(Unlock)(THIS_ LPVOID lpSurfaceData) PURE;
+ STDMETHOD(UpdateOverlay)(THIS_ LPRECT lpSrcRect, LPDIRECTDRAWSURFACE lpDDDestSurface, LPRECT lpDestRect, DWORD dwFlags, LPDDOVERLAYFX lpDDOverlayFx) PURE;
+ STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSReference) PURE;
+};
+
+ /*** IUnknown methods ***/
+#define IDirectDrawSurface_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
+#define IDirectDrawSurface_AddRef(p) ICOM_CALL_(AddRef,p,(p))
+#define IDirectDrawSurface_Release(p) ICOM_CALL_(Release,p,(p))
+ /*** IDirectDrawSurface methods ***/
+#define IDirectDrawSurface_AddAttachedSurface(p,a) ICOM_CALL_(AddAttachedSurface,p,(p,a))
+#define IDirectDrawSurface_AddOverlayDirtyRect(p,a) ICOM_CALL_(AddOverlayDirtyRect,p,(p,a))
+#define IDirectDrawSurface_Blt(p,a,b,c,d,e) ICOM_CALL_(Blt,p,(p,a,b,c,d,e))
+#define IDirectDrawSurface_BltBatch(p,a,b,c) ICOM_CALL_(BltBatch,p,(p,a,b,c))
+#define IDirectDrawSurface_BltFast(p,a,b,c,d,e) ICOM_CALL_(BltFast,p,(p,a,b,c,d,e))
+#define IDirectDrawSurface_DeleteAttachedSurface(p,a,b) ICOM_CALL_(DeleteAttachedSurface,p,(p,a,b))
+#define IDirectDrawSurface_EnumAttachedSurfaces(p,a,b) ICOM_CALL_(EnumAttachedSurfaces,p,(p,a,b))
+#define IDirectDrawSurface_EnumOverlayZOrders(p,a,b,c) ICOM_CALL_(EnumOverlayZOrders,p,(p,a,b,c))
+#define IDirectDrawSurface_Flip(p,a,b) ICOM_CALL_(Flip,p,(p,a,b))
+#define IDirectDrawSurface_GetAttachedSurface(p,a,b) ICOM_CALL_(GetAttachedSurface,p,(p,a,b))
+#define IDirectDrawSurface_GetBltStatus(p,a) ICOM_CALL_(GetBltStatus,p,(p,a))
+#define IDirectDrawSurface_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a))
+#define IDirectDrawSurface_GetClipper(p,a) ICOM_CALL_(GetClipper,p,(p,a))
+#define IDirectDrawSurface_GetColorKey(p,a,b) ICOM_CALL_(GetColorKey,p,(p,a,b))
+#define IDirectDrawSurface_GetDC(p,a) ICOM_CALL_(GetDC,p,(p,a))
+#define IDirectDrawSurface_GetFlipStatus(p,a) ICOM_CALL_(GetFlipStatus,p,(p,a))
+#define IDirectDrawSurface_GetOverlayPosition(p,a,b) ICOM_CALL_(GetOverlayPosition,p,(p,a,b))
+#define IDirectDrawSurface_GetPalette(p,a) ICOM_CALL_(GetPalette,p,(p,a))
+#define IDirectDrawSurface_GetPixelFormat(p,a) ICOM_CALL_(GetPixelFormat,p,(p,a))
+#define IDirectDrawSurface_GetSurfaceDesc(p,a) ICOM_CALL_(GetSurfaceDesc,p,(p,a))
+#define IDirectDrawSurface_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b))
+#define IDirectDrawSurface_IsLost(p) ICOM_CALL_(IsLost,p,(p))
+#define IDirectDrawSurface_Lock(p,a,b,c,d) ICOM_CALL_(Lock,p,(p,a,b,c,d))
+#define IDirectDrawSurface_ReleaseDC(p,a) ICOM_CALL_(ReleaseDC,p,(p,a))
+#define IDirectDrawSurface_Restore(p) ICOM_CALL_(Restore,p,(p))
+#define IDirectDrawSurface_SetClipper(p,a) ICOM_CALL_(SetClipper,p,(p,a))
+#define IDirectDrawSurface_SetColorKey(p,a,b) ICOM_CALL_(SetColorKey,p,(p,a,b))
+#define IDirectDrawSurface_SetOverlayPosition(p,a,b) ICOM_CALL_(SetOverlayPosition,p,(p,a,b))
+#define IDirectDrawSurface_SetPalette(p,a) ICOM_CALL_(SetPalette,p,(p,a))
+#define IDirectDrawSurface_Unlock(p,a) ICOM_CALL_(Unlock,p,(p,a))
+#define IDirectDrawSurface_UpdateOverlay(p,a,b,c,d,e) ICOM_CALL_(UpdateOverlay,p,(p,a,b,c,d,e))
+#define IDirectDrawSurface_UpdateOverlayDisplay(p,a) ICOM_CALL_(UpdateOverlayDisplay,p,(p,a))
+#define IDirectDrawSurface_UpdateOverlayZOrder(p,a,b) ICOM_CALL_(UpdateOverlayZOrder,p,(p,a,b))
+
+
+/*****************************************************************************
+ * IDirectDrawSurface2 interface
+ */
+/* Cannot inherit from IDirectDrawSurface because the LPDIRECTDRAWSURFACE parameters
+ * have been converted to LPDIRECTDRAWSURFACE2.
+ */
+#undef INTERFACE
+#define INTERFACE IDirectDrawSurface2
+DECLARE_INTERFACE_(IDirectDrawSurface2,IUnknown)
+{
+ STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE2 lpDDSAttachedSurface) PURE;
+ STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT lpRect) PURE;
+ STDMETHOD(Blt)(THIS_ LPRECT lpDestRect, LPDIRECTDRAWSURFACE2 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx) PURE;
+ STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags) PURE;
+ STDMETHOD(BltFast)(THIS_ DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE2 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans) PURE;
+ STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE2 lpDDSAttachedSurface) PURE;
+ STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback) PURE;
+ STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfnCallback) PURE;
+ STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE2 lpDDSurfaceTargetOverride, DWORD dwFlags) PURE;
+ STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS lpDDSCaps, LPDIRECTDRAWSURFACE2* lplpDDAttachedSurface) PURE;
+ STDMETHOD(GetBltStatus)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(GetCaps)(THIS_ LPDDSCAPS lpDDSCaps) PURE;
+ STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER* lplpDDClipper) PURE;
+ STDMETHOD(GetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
+ STDMETHOD(GetDC)(THIS_ HDC* lphDC) PURE;
+ STDMETHOD(GetFlipStatus)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(GetOverlayPosition)(THIS_ LPLONG lplX, LPLONG lplY) PURE;
+ STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE* lplpDDPalette) PURE;
+ STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT lpDDPixelFormat) PURE;
+ STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
+ STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
+ STDMETHOD(IsLost)(THIS) PURE;
+ STDMETHOD(Lock)(THIS_ LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent) PURE;
+ STDMETHOD(ReleaseDC)(THIS_ HDC hDC) PURE;
+ STDMETHOD(Restore)(THIS) PURE;
+ STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper) PURE;
+ STDMETHOD(SetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
+ STDMETHOD(SetOverlayPosition)(THIS_ LONG lX, LONG lY) PURE;
+ STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE lpDDPalette) PURE;
+ STDMETHOD(Unlock)(THIS_ LPVOID lpSurfaceData) PURE;
+ STDMETHOD(UpdateOverlay)(THIS_ LPRECT lpSrcRect, LPDIRECTDRAWSURFACE2 lpDDDestSurface, LPRECT lpDestRect, DWORD dwFlags, LPDDOVERLAYFX lpDDOverlayFx) PURE;
+ STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE2 lpDDSReference) PURE;
+ /* added in v2 */
+ STDMETHOD(GetDDInterface)(THIS_ LPVOID* lplpDD) PURE;
+ STDMETHOD(PageLock)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(PageUnlock)(THIS_ DWORD dwFlags) PURE;
+};
+
+ /*** IUnknown methods ***/
+#define IDirectDrawSurface2_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
+#define IDirectDrawSurface2_AddRef(p) ICOM_CALL_(AddRef,p,(p))
+#define IDirectDrawSurface2_Release(p) ICOM_CALL_(Release,p,(p))
+/*** IDirectDrawSurface methods (almost) ***/
+#define IDirectDrawSurface2_AddAttachedSurface(p,a) ICOM_CALL_(AddAttachedSurface,p,(p,a))
+#define IDirectDrawSurface2_AddOverlayDirtyRect(p,a) ICOM_CALL_(AddOverlayDirtyRect,p,(p,a))
+#define IDirectDrawSurface2_Blt(p,a,b,c,d,e) ICOM_CALL_(Blt,p,(p,a,b,c,d,e))
+#define IDirectDrawSurface2_BltBatch(p,a,b,c) ICOM_CALL_(BltBatch,p,(p,a,b,c))
+#define IDirectDrawSurface2_BltFast(p,a,b,c,d,e) ICOM_CALL_(BltFast,p,(p,a,b,c,d,e))
+#define IDirectDrawSurface2_DeleteAttachedSurface(p,a,b) ICOM_CALL_(DeleteAttachedSurface,p,(p,a,b))
+#define IDirectDrawSurface2_EnumAttachedSurfaces(p,a,b) ICOM_CALL_(EnumAttachedSurfaces,p,(p,a,b))
+#define IDirectDrawSurface2_EnumOverlayZOrders(p,a,b,c) ICOM_CALL_(EnumOverlayZOrders,p,(p,a,b,c))
+#define IDirectDrawSurface2_Flip(p,a,b) ICOM_CALL_(Flip,p,(p,a,b))
+#define IDirectDrawSurface2_GetAttachedSurface(p,a,b) ICOM_CALL_(GetAttachedSurface,p,(p,a,b))
+#define IDirectDrawSurface2_GetBltStatus(p,a) ICOM_CALL_(GetBltStatus,p,(p,a))
+#define IDirectDrawSurface2_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a))
+#define IDirectDrawSurface2_GetClipper(p,a) ICOM_CALL_(GetClipper,p,(p,a))
+#define IDirectDrawSurface2_GetColorKey(p,a,b) ICOM_CALL_(GetColorKey,p,(p,a,b))
+#define IDirectDrawSurface2_GetDC(p,a) ICOM_CALL_(GetDC,p,(p,a))
+#define IDirectDrawSurface2_GetFlipStatus(p,a) ICOM_CALL_(GetFlipStatus,p,(p,a))
+#define IDirectDrawSurface2_GetOverlayPosition(p,a,b) ICOM_CALL_(GetOverlayPosition,p,(p,a,b))
+#define IDirectDrawSurface2_GetPalette(p,a) ICOM_CALL_(GetPalette,p,(p,a))
+#define IDirectDrawSurface2_GetPixelFormat(p,a) ICOM_CALL_(GetPixelFormat,p,(p,a))
+#define IDirectDrawSurface2_GetSurfaceDesc(p,a) ICOM_CALL_(GetSurfaceDesc,p,(p,a))
+#define IDirectDrawSurface2_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b))
+#define IDirectDrawSurface2_IsLost(p) ICOM_CALL_(IsLost,p,(p))
+#define IDirectDrawSurface2_Lock(p,a,b,c,d) ICOM_CALL_(Lock,p,(p,a,b,c,d))
+#define IDirectDrawSurface2_ReleaseDC(p,a) ICOM_CALL_(ReleaseDC,p,(p,a))
+#define IDirectDrawSurface2_Restore(p) ICOM_CALL_(Restore,p,(p))
+#define IDirectDrawSurface2_SetClipper(p,a) ICOM_CALL_(SetClipper,p,(p,a))
+#define IDirectDrawSurface2_SetColorKey(p,a,b) ICOM_CALL_(SetColorKey,p,(p,a,b))
+#define IDirectDrawSurface2_SetOverlayPosition(p,a,b) ICOM_CALL_(SetOverlayPosition,p,(p,a,b))
+#define IDirectDrawSurface2_SetPalette(p,a) ICOM_CALL_(SetPalette,p,(p,a))
+#define IDirectDrawSurface2_Unlock(p,a) ICOM_CALL_(Unlock,p,(p,a))
+#define IDirectDrawSurface2_UpdateOverlay(p,a,b,c,d,e) ICOM_CALL_(UpdateOverlay,p,(p,a,b,c,d,e))
+#define IDirectDrawSurface2_UpdateOverlayDisplay(p,a) ICOM_CALL_(UpdateOverlayDisplay,p,(p,a))
+#define IDirectDrawSurface2_UpdateOverlayZOrder(p,a,b) ICOM_CALL_(UpdateOverlayZOrder,p,(p,a,b))
+/*** IDirectDrawSurface2 methods ***/
+#define IDirectDrawSurface2_GetDDInterface(p,a) ICOM_CALL_(GetDDInterface,p,(p,a))
+#define IDirectDrawSurface2_PageLock(p,a) ICOM_CALL_(PageLock,p,(p,a))
+#define IDirectDrawSurface2_PageUnlock(p,a) ICOM_CALL_(PageUnlock,p,(p,a))
+
+
+/*****************************************************************************
+ * IDirectDrawSurface3 interface
+ */
+/* Cannot inherit from IDirectDrawSurface2 because the LPDIRECTDRAWSURFACE2 parameters
+ * have been converted to LPDIRECTDRAWSURFACE3.
+ */
+#undef INTERFACE
+#define INTERFACE IDirectDrawSurface3
+DECLARE_INTERFACE_(IDirectDrawSurface3,IUnknown)
+{
+ STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE3 lpDDSAttachedSurface) PURE;
+ STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT lpRect) PURE;
+ STDMETHOD(Blt)(THIS_ LPRECT lpDestRect, LPDIRECTDRAWSURFACE3 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx) PURE;
+ STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags) PURE;
+ STDMETHOD(BltFast)(THIS_ DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE3 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans) PURE;
+ STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE3 lpDDSAttachedSurface) PURE;
+ STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback) PURE;
+ STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfnCallback) PURE;
+ STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE3 lpDDSurfaceTargetOverride, DWORD dwFlags) PURE;
+ STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS lpDDSCaps, LPDIRECTDRAWSURFACE3* lplpDDAttachedSurface) PURE;
+ STDMETHOD(GetBltStatus)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(GetCaps)(THIS_ LPDDSCAPS lpDDSCaps) PURE;
+ STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER* lplpDDClipper) PURE;
+ STDMETHOD(GetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
+ STDMETHOD(GetDC)(THIS_ HDC* lphDC) PURE;
+ STDMETHOD(GetFlipStatus)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(GetOverlayPosition)(THIS_ LPLONG lplX, LPLONG lplY) PURE;
+ STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE* lplpDDPalette) PURE;
+ STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT lpDDPixelFormat) PURE;
+ STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
+ STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
+ STDMETHOD(IsLost)(THIS) PURE;
+ STDMETHOD(Lock)(THIS_ LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent) PURE;
+ STDMETHOD(ReleaseDC)(THIS_ HDC hDC) PURE;
+ STDMETHOD(Restore)(THIS) PURE;
+ STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper) PURE;
+ STDMETHOD(SetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
+ STDMETHOD(SetOverlayPosition)(THIS_ LONG lX, LONG lY) PURE;
+ STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE lpDDPalette) PURE;
+ STDMETHOD(Unlock)(THIS_ LPVOID lpSurfaceData) PURE;
+ STDMETHOD(UpdateOverlay)(THIS_ LPRECT lpSrcRect, LPDIRECTDRAWSURFACE3 lpDDDestSurface, LPRECT lpDestRect, DWORD dwFlags, LPDDOVERLAYFX lpDDOverlayFx) PURE;
+ STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE3 lpDDSReference) PURE;
+ /* added in v2 */
+ STDMETHOD(GetDDInterface)(THIS_ LPVOID* lplpDD) PURE;
+ STDMETHOD(PageLock)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(PageUnlock)(THIS_ DWORD dwFlags) PURE;
+ /* added in v3 */
+ STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC lpDDSD, DWORD dwFlags) PURE;
+};
+
+ /*** IUnknown methods ***/
+#define IDirectDrawSurface3_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
+#define IDirectDrawSurface3_AddRef(p) ICOM_CALL_(AddRef,p,(p))
+#define IDirectDrawSurface3_Release(p) ICOM_CALL_(Release,p,(p))
+/*** IDirectDrawSurface methods (almost) ***/
+#define IDirectDrawSurface3_AddAttachedSurface(p,a) ICOM_CALL_(AddAttachedSurface,p,(p,a))
+#define IDirectDrawSurface3_AddOverlayDirtyRect(p,a) ICOM_CALL_(AddOverlayDirtyRect,p,(p,a))
+#define IDirectDrawSurface3_Blt(p,a,b,c,d,e) ICOM_CALL_(Blt,p,(p,a,b,c,d,e))
+#define IDirectDrawSurface3_BltBatch(p,a,b,c) ICOM_CALL_(BltBatch,p,(p,a,b,c))
+#define IDirectDrawSurface3_BltFast(p,a,b,c,d,e) ICOM_CALL_(BltFast,p,(p,a,b,c,d,e))
+#define IDirectDrawSurface3_DeleteAttachedSurface(p,a,b) ICOM_CALL_(DeleteAttachedSurface,p,(p,a,b))
+#define IDirectDrawSurface3_EnumAttachedSurfaces(p,a,b) ICOM_CALL_(EnumAttachedSurfaces,p,(p,a,b))
+#define IDirectDrawSurface3_EnumOverlayZOrders(p,a,b,c) ICOM_CALL_(EnumOverlayZOrders,p,(p,a,b,c))
+#define IDirectDrawSurface3_Flip(p,a,b) ICOM_CALL_(Flip,p,(p,a,b))
+#define IDirectDrawSurface3_GetAttachedSurface(p,a,b) ICOM_CALL_(GetAttachedSurface,p,(p,a,b))
+#define IDirectDrawSurface3_GetBltStatus(p,a) ICOM_CALL_(GetBltStatus,p,(p,a))
+#define IDirectDrawSurface3_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a))
+#define IDirectDrawSurface3_GetClipper(p,a) ICOM_CALL_(GetClipper,p,(p,a))
+#define IDirectDrawSurface3_GetColorKey(p,a,b) ICOM_CALL_(GetColorKey,p,(p,a,b))
+#define IDirectDrawSurface3_GetDC(p,a) ICOM_CALL_(GetDC,p,(p,a))
+#define IDirectDrawSurface3_GetFlipStatus(p,a) ICOM_CALL_(GetFlipStatus,p,(p,a))
+#define IDirectDrawSurface3_GetOverlayPosition(p,a,b) ICOM_CALL_(GetOverlayPosition,p,(p,a,b))
+#define IDirectDrawSurface3_GetPalette(p,a) ICOM_CALL_(GetPalette,p,(p,a))
+#define IDirectDrawSurface3_GetPixelFormat(p,a) ICOM_CALL_(GetPixelFormat,p,(p,a))
+#define IDirectDrawSurface3_GetSurfaceDesc(p,a) ICOM_CALL_(GetSurfaceDesc,p,(p,a))
+#define IDirectDrawSurface3_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b))
+#define IDirectDrawSurface3_IsLost(p) ICOM_CALL_(IsLost,p,(p))
+#define IDirectDrawSurface3_Lock(p,a,b,c,d) ICOM_CALL_(Lock,p,(p,a,b,c,d))
+#define IDirectDrawSurface3_ReleaseDC(p,a) ICOM_CALL_(ReleaseDC,p,(p,a))
+#define IDirectDrawSurface3_Restore(p) ICOM_CALL_(Restore,p,(p))
+#define IDirectDrawSurface3_SetClipper(p,a) ICOM_CALL_(SetClipper,p,(p,a))
+#define IDirectDrawSurface3_SetColorKey(p,a,b) ICOM_CALL_(SetColorKey,p,(p,a,b))
+#define IDirectDrawSurface3_SetOverlayPosition(p,a,b) ICOM_CALL_(SetOverlayPosition,p,(p,a,b))
+#define IDirectDrawSurface3_SetPalette(p,a) ICOM_CALL_(SetPalette,p,(p,a))
+#define IDirectDrawSurface3_Unlock(p,a) ICOM_CALL_(Unlock,p,(p,a))
+#define IDirectDrawSurface3_UpdateOverlay(p,a,b,c,d,e) ICOM_CALL_(UpdateOverlay,p,(p,a,b,c,d,e))
+#define IDirectDrawSurface3_UpdateOverlayDisplay(p,a) ICOM_CALL_(UpdateOverlayDisplay,p,(p,a))
+#define IDirectDrawSurface3_UpdateOverlayZOrder(p,a,b) ICOM_CALL_(UpdateOverlayZOrder,p,(p,a,b))
+/*** IDirectDrawSurface2 methods ***/
+#define IDirectDrawSurface3_GetDDInterface(p,a) ICOM_CALL_(GetDDInterface,p,(p,a))
+#define IDirectDrawSurface3_PageLock(p,a) ICOM_CALL_(PageLock,p,(p,a))
+#define IDirectDrawSurface3_PageUnlock(p,a) ICOM_CALL_(PageUnlock,p,(p,a))
+/*** IDirectDrawSurface3 methods ***/
+#define IDirectDrawSurface3_SetSurfaceDesc(p,a,b) ICOM_CALL_(SetSurfaceDesc,p,(p,a,b))
+
+
+/*****************************************************************************
+ * IDirectDrawSurface4 interface
+ */
+/* Cannot inherit from IDirectDrawSurface2 because DDSCAPS changed to DDSCAPS2.
+ */
+#undef INTERFACE
+#define INTERFACE IDirectDrawSurface4
+DECLARE_INTERFACE_(IDirectDrawSurface4,IUnknown)
+{
+ STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE4 lpDDSAttachedSurface) PURE;
+ STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT lpRect) PURE;
+ STDMETHOD(Blt)(THIS_ LPRECT lpDestRect, LPDIRECTDRAWSURFACE4 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx) PURE;
+ STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags) PURE;
+ STDMETHOD(BltFast)(THIS_ DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE4 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans) PURE;
+ STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE4 lpDDSAttachedSurface) PURE;
+ STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback) PURE;
+ STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfnCallback) PURE;
+ STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE4 lpDDSurfaceTargetOverride, DWORD dwFlags) PURE;
+ STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS2 lpDDSCaps, LPDIRECTDRAWSURFACE4* lplpDDAttachedSurface) PURE;
+ STDMETHOD(GetBltStatus)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(GetCaps)(THIS_ LPDDSCAPS2 lpDDSCaps) PURE;
+ STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER* lplpDDClipper) PURE;
+ STDMETHOD(GetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
+ STDMETHOD(GetDC)(THIS_ HDC* lphDC) PURE;
+ STDMETHOD(GetFlipStatus)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(GetOverlayPosition)(THIS_ LPLONG lplX, LPLONG lplY) PURE;
+ STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE* lplpDDPalette) PURE;
+ STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT lpDDPixelFormat) PURE;
+ STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
+ STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW lpDD, LPDDSURFACEDESC lpDDSurfaceDesc) PURE;
+ STDMETHOD(IsLost)(THIS) PURE;
+ STDMETHOD(Lock)(THIS_ LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent) PURE;
+ STDMETHOD(ReleaseDC)(THIS_ HDC hDC) PURE;
+ STDMETHOD(Restore)(THIS) PURE;
+ STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper) PURE;
+ STDMETHOD(SetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
+ STDMETHOD(SetOverlayPosition)(THIS_ LONG lX, LONG lY) PURE;
+ STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE lpDDPalette) PURE;
+ STDMETHOD(Unlock)(THIS_ LPRECT lpSurfaceData) PURE;
+ STDMETHOD(UpdateOverlay)(THIS_ LPRECT lpSrcRect, LPDIRECTDRAWSURFACE4 lpDDDestSurface, LPRECT lpDestRect, DWORD dwFlags, LPDDOVERLAYFX lpDDOverlayFx) PURE;
+ STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE4 lpDDSReference) PURE;
+ /* added in v2 */
+ STDMETHOD(GetDDInterface)(THIS_ LPVOID* lplpDD) PURE;
+ STDMETHOD(PageLock)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(PageUnlock)(THIS_ DWORD dwFlags) PURE;
+ /* added in v3 */
+ STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC lpDDSD, DWORD dwFlags) PURE;
+ /* added in v4 */
+ STDMETHOD(SetPrivateData)(THIS_ REFGUID , LPVOID , DWORD , DWORD ) PURE;
+ STDMETHOD(GetPrivateData)(THIS_ REFGUID , LPVOID , LPDWORD ) PURE;
+ STDMETHOD(FreePrivateData)(THIS_ REFGUID ) PURE;
+ STDMETHOD(GetUniquenessValue)(THIS_ LPDWORD ) PURE;
+ STDMETHOD(ChangeUniquenessValue)(THIS) PURE;
+};
+
+ /*** IUnknown methods ***/
+#define IDirectDrawSurface4_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
+#define IDirectDrawSurface4_AddRef(p) ICOM_CALL_(AddRef,p,(p))
+#define IDirectDrawSurface4_Release(p) ICOM_CALL_(Release,p,(p))
+/*** IDirectDrawSurface (almost) methods ***/
+#define IDirectDrawSurface4_AddAttachedSurface(p,a) ICOM_CALL_(AddAttachedSurface,p,(p,a))
+#define IDirectDrawSurface4_AddOverlayDirtyRect(p,a) ICOM_CALL_(AddOverlayDirtyRect,p,(p,a))
+#define IDirectDrawSurface4_Blt(p,a,b,c,d,e) ICOM_CALL_(Blt,p,(p,a,b,c,d,e))
+#define IDirectDrawSurface4_BltBatch(p,a,b,c) ICOM_CALL_(BltBatch,p,(p,a,b,c))
+#define IDirectDrawSurface4_BltFast(p,a,b,c,d,e) ICOM_CALL_(BltFast,p,(p,a,b,c,d,e))
+#define IDirectDrawSurface4_DeleteAttachedSurface(p,a,b) ICOM_CALL_(DeleteAttachedSurface,p,(p,a,b))
+#define IDirectDrawSurface4_EnumAttachedSurfaces(p,a,b) ICOM_CALL_(EnumAttachedSurfaces,p,(p,a,b))
+#define IDirectDrawSurface4_EnumOverlayZOrders(p,a,b,c) ICOM_CALL_(EnumOverlayZOrders,p,(p,a,b,c))
+#define IDirectDrawSurface4_Flip(p,a,b) ICOM_CALL_(Flip,p,(p,a,b))
+#define IDirectDrawSurface4_GetAttachedSurface(p,a,b) ICOM_CALL_(GetAttachedSurface,p,(p,a,b))
+#define IDirectDrawSurface4_GetBltStatus(p,a) ICOM_CALL_(GetBltStatus,p,(p,a))
+#define IDirectDrawSurface4_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a))
+#define IDirectDrawSurface4_GetClipper(p,a) ICOM_CALL_(GetClipper,p,(p,a))
+#define IDirectDrawSurface4_GetColorKey(p,a,b) ICOM_CALL_(GetColorKey,p,(p,a,b))
+#define IDirectDrawSurface4_GetDC(p,a) ICOM_CALL_(GetDC,p,(p,a))
+#define IDirectDrawSurface4_GetFlipStatus(p,a) ICOM_CALL_(GetFlipStatus,p,(p,a))
+#define IDirectDrawSurface4_GetOverlayPosition(p,a,b) ICOM_CALL_(GetOverlayPosition,p,(p,a,b))
+#define IDirectDrawSurface4_GetPalette(p,a) ICOM_CALL_(GetPalette,p,(p,a))
+#define IDirectDrawSurface4_GetPixelFormat(p,a) ICOM_CALL_(GetPixelFormat,p,(p,a))
+#define IDirectDrawSurface4_GetSurfaceDesc(p,a) ICOM_CALL_(GetSurfaceDesc,p,(p,a))
+#define IDirectDrawSurface4_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b))
+#define IDirectDrawSurface4_IsLost(p) ICOM_CALL_(IsLost,p,(p))
+#define IDirectDrawSurface4_Lock(p,a,b,c,d) ICOM_CALL_(Lock,p,(p,a,b,c,d))
+#define IDirectDrawSurface4_ReleaseDC(p,a) ICOM_CALL_(ReleaseDC,p,(p,a))
+#define IDirectDrawSurface4_Restore(p) ICOM_CALL_(Restore,p,(p))
+#define IDirectDrawSurface4_SetClipper(p,a) ICOM_CALL_(SetClipper,p,(p,a))
+#define IDirectDrawSurface4_SetColorKey(p,a,b) ICOM_CALL_(SetColorKey,p,(p,a,b))
+#define IDirectDrawSurface4_SetOverlayPosition(p,a,b) ICOM_CALL_(SetOverlayPosition,p,(p,a,b))
+#define IDirectDrawSurface4_SetPalette(p,a) ICOM_CALL_(SetPalette,p,(p,a))
+#define IDirectDrawSurface4_Unlock(p,a) ICOM_CALL_(Unlock,p,(p,a))
+#define IDirectDrawSurface4_UpdateOverlay(p,a,b,c,d,e) ICOM_CALL_(UpdateOverlay,p,(p,a,b,c,d,e))
+#define IDirectDrawSurface4_UpdateOverlayDisplay(p,a) ICOM_CALL_(UpdateOverlayDisplay,p,(p,a))
+#define IDirectDrawSurface4_UpdateOverlayZOrder(p,a,b) ICOM_CALL_(UpdateOverlayZOrder,p,(p,a,b))
+/*** IDirectDrawSurface2 methods ***/
+#define IDirectDrawSurface4_GetDDInterface(p,a) ICOM_CALL_(GetDDInterface,p,(p,a))
+#define IDirectDrawSurface4_PageLock(p,a) ICOM_CALL_(PageLock,p,(p,a))
+#define IDirectDrawSurface4_PageUnlock(p,a) ICOM_CALL_(PageUnlock,p,(p,a))
+/*** IDirectDrawSurface3 methods ***/
+#define IDirectDrawSurface4_SetSurfaceDesc(p,a,b) ICOM_CALL_(SetSurfaceDesc,p,(p,a,b))
+/*** IDirectDrawSurface4 methods ***/
+#define IDirectDrawSurface4_SetPrivateData(p,a,b,c,d) ICOM_CALL_(SetPrivateData,p,(p,a,b,c,d))
+#define IDirectDrawSurface4_GetPrivateData(p,a,b,c) ICOM_CALL_(GetPrivateData,p,(p,a,b,c))
+#define IDirectDrawSurface4_FreePrivateData(p,a) ICOM_CALL_(FreePrivateData,p,(p,a))
+#define IDirectDrawSurface4_GetUniquenessValue(p,a) ICOM_CALL_(GetUniquenessValue,p,(p,a))
+#define IDirectDrawSurface4_ChangeUniquenessValue(p) ICOM_CALL_(ChangeUniquenessValue,p,(p))
+
+
+/*****************************************************************************
+ * IDirectDrawSurface7 interface
+ */
+#undef INTERFACE
+#define INTERFACE IDirectDrawSurface7
+DECLARE_INTERFACE_(IDirectDrawSurface7,IUnknown)
+{
+ STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE7 lpDDSAttachedSurface) PURE;
+ STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT lpRect) PURE;
+ STDMETHOD(Blt)(THIS_ LPRECT lpDestRect, LPDIRECTDRAWSURFACE7 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx) PURE;
+ STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags) PURE;
+ STDMETHOD(BltFast)(THIS_ DWORD dwX, DWORD dwY, LPDIRECTDRAWSURFACE7 lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans) PURE;
+ STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE7 lpDDSAttachedSurface) PURE;
+ STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID lpContext, LPDDENUMSURFACESCALLBACK7 lpEnumSurfacesCallback) PURE;
+ STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK7 lpfnCallback) PURE;
+ STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverride, DWORD dwFlags) PURE;
+ STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS2 lpDDSCaps, LPDIRECTDRAWSURFACE7* lplpDDAttachedSurface) PURE;
+ STDMETHOD(GetBltStatus)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(GetCaps)(THIS_ LPDDSCAPS2 lpDDSCaps) PURE;
+ STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER* lplpDDClipper) PURE;
+ STDMETHOD(GetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
+ STDMETHOD(GetDC)(THIS_ HDC* lphDC) PURE;
+ STDMETHOD(GetFlipStatus)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(GetOverlayPosition)(THIS_ LPLONG lplX, LPLONG lplY) PURE;
+ STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE* lplpDDPalette) PURE;
+ STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT lpDDPixelFormat) PURE;
+ STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC2 lpDDSurfaceDesc) PURE;
+ STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW lpDD, LPDDSURFACEDESC2 lpDDSurfaceDesc) PURE;
+ STDMETHOD(IsLost)(THIS) PURE;
+ STDMETHOD(Lock)(THIS_ LPRECT lpDestRect, LPDDSURFACEDESC2 lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent) PURE;
+ STDMETHOD(ReleaseDC)(THIS_ HDC hDC) PURE;
+ STDMETHOD(Restore)(THIS) PURE;
+ STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper) PURE;
+ STDMETHOD(SetColorKey)(THIS_ DWORD dwFlags, LPDDCOLORKEY lpDDColorKey) PURE;
+ STDMETHOD(SetOverlayPosition)(THIS_ LONG lX, LONG lY) PURE;
+ STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE lpDDPalette) PURE;
+ STDMETHOD(Unlock)(THIS_ LPRECT lpSurfaceData) PURE;
+ STDMETHOD(UpdateOverlay)(THIS_ LPRECT lpSrcRect, LPDIRECTDRAWSURFACE7 lpDDDestSurface, LPRECT lpDestRect, DWORD dwFlags, LPDDOVERLAYFX lpDDOverlayFx) PURE;
+ STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD dwFlags, LPDIRECTDRAWSURFACE7 lpDDSReference) PURE;
+ /* added in v2 */
+ STDMETHOD(GetDDInterface)(THIS_ LPVOID* lplpDD) PURE;
+ STDMETHOD(PageLock)(THIS_ DWORD dwFlags) PURE;
+ STDMETHOD(PageUnlock)(THIS_ DWORD dwFlags) PURE;
+ /* added in v3 */
+ STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC2 lpDDSD, DWORD dwFlags) PURE;
+ /* added in v4 */
+ STDMETHOD(SetPrivateData)(THIS_ REFGUID , LPVOID , DWORD , DWORD ) PURE;
+ STDMETHOD(GetPrivateData)(THIS_ REFGUID , LPVOID , LPDWORD ) PURE;
+ STDMETHOD(FreePrivateData)(THIS_ REFGUID ) PURE;
+ STDMETHOD(GetUniquenessValue)(THIS_ LPDWORD ) PURE;
+ STDMETHOD(ChangeUniquenessValue)(THIS) PURE;
+ /* added in v7 */
+ STDMETHOD(SetPriority)(THIS_ DWORD prio) PURE;
+ STDMETHOD(GetPriority)(THIS_ LPDWORD prio) PURE;
+ STDMETHOD(SetLOD)(THIS_ DWORD lod) PURE;
+ STDMETHOD(GetLOD)(THIS_ LPDWORD lod) PURE;
+};
+
+ /*** IUnknown methods ***/
+#define IDirectDrawSurface7_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
+#define IDirectDrawSurface7_AddRef(p) ICOM_CALL_(AddRef,p,(p))
+#define IDirectDrawSurface7_Release(p) ICOM_CALL_(Release,p,(p))
+/*** IDirectDrawSurface (almost) methods ***/
+#define IDirectDrawSurface7_AddAttachedSurface(p,a) ICOM_CALL_(AddAttachedSurface,p,(p,a))
+#define IDirectDrawSurface7_AddOverlayDirtyRect(p,a) ICOM_CALL_(AddOverlayDirtyRect,p,(p,a))
+#define IDirectDrawSurface7_Blt(p,a,b,c,d,e) ICOM_CALL_(Blt,p,(p,a,b,c,d,e))
+#define IDirectDrawSurface7_BltBatch(p,a,b,c) ICOM_CALL_(BltBatch,p,(p,a,b,c))
+#define IDirectDrawSurface7_BltFast(p,a,b,c,d,e) ICOM_CALL_(BltFast,p,(p,a,b,c,d,e))
+#define IDirectDrawSurface7_DeleteAttachedSurface(p,a,b) ICOM_CALL_(DeleteAttachedSurface,p,(p,a,b))
+#define IDirectDrawSurface7_EnumAttachedSurfaces(p,a,b) ICOM_CALL_(EnumAttachedSurfaces,p,(p,a,b))
+#define IDirectDrawSurface7_EnumOverlayZOrders(p,a,b,c) ICOM_CALL_(EnumOverlayZOrders,p,(p,a,b,c))
+#define IDirectDrawSurface7_Flip(p,a,b) ICOM_CALL_(Flip,p,(p,a,b))
+#define IDirectDrawSurface7_GetAttachedSurface(p,a,b) ICOM_CALL_(GetAttachedSurface,p,(p,a,b))
+#define IDirectDrawSurface7_GetBltStatus(p,a) ICOM_CALL_(GetBltStatus,p,(p,a))
+#define IDirectDrawSurface7_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a))
+#define IDirectDrawSurface7_GetClipper(p,a) ICOM_CALL_(GetClipper,p,(p,a))
+#define IDirectDrawSurface7_GetColorKey(p,a,b) ICOM_CALL_(GetColorKey,p,(p,a,b))
+#define IDirectDrawSurface7_GetDC(p,a) ICOM_CALL_(GetDC,p,(p,a))
+#define IDirectDrawSurface7_GetFlipStatus(p,a) ICOM_CALL_(GetFlipStatus,p,(p,a))
+#define IDirectDrawSurface7_GetOverlayPosition(p,a,b) ICOM_CALL_(GetOverlayPosition,p,(p,a,b))
+#define IDirectDrawSurface7_GetPalette(p,a) ICOM_CALL_(GetPalette,p,(p,a))
+#define IDirectDrawSurface7_GetPixelFormat(p,a) ICOM_CALL_(GetPixelFormat,p,(p,a))
+#define IDirectDrawSurface7_GetSurfaceDesc(p,a) ICOM_CALL_(GetSurfaceDesc,p,(p,a))
+#define IDirectDrawSurface7_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b))
+#define IDirectDrawSurface7_IsLost(p) ICOM_CALL_(IsLost,p,(p))
+#define IDirectDrawSurface7_Lock(p,a,b,c,d) ICOM_CALL_(Lock,p,(p,a,b,c,d))
+#define IDirectDrawSurface7_ReleaseDC(p,a) ICOM_CALL_(ReleaseDC,p,(p,a))
+#define IDirectDrawSurface7_Restore(p) ICOM_CALL_(Restore,p,(p))
+#define IDirectDrawSurface7_SetClipper(p,a) ICOM_CALL_(SetClipper,p,(p,a))
+#define IDirectDrawSurface7_SetColorKey(p,a,b) ICOM_CALL_(SetColorKey,p,(p,a,b))
+#define IDirectDrawSurface7_SetOverlayPosition(p,a,b) ICOM_CALL_(SetOverlayPosition,p,(p,a,b))
+#define IDirectDrawSurface7_SetPalette(p,a) ICOM_CALL_(SetPalette,p,(p,a))
+#define IDirectDrawSurface7_Unlock(p,a) ICOM_CALL_(Unlock,p,(p,a))
+#define IDirectDrawSurface7_UpdateOverlay(p,a,b,c,d,e) ICOM_CALL_(UpdateOverlay,p,(p,a,b,c,d,e))
+#define IDirectDrawSurface7_UpdateOverlayDisplay(p,a) ICOM_CALL_(UpdateOverlayDisplay,p,(p,a))
+#define IDirectDrawSurface7_UpdateOverlayZOrder(p,a,b) ICOM_CALL_(UpdateOverlayZOrder,p,(p,a,b))
+/*** IDirectDrawSurface2 methods ***/
+#define IDirectDrawSurface7_GetDDInterface(p,a) ICOM_CALL_(GetDDInterface,p,(p,a))
+#define IDirectDrawSurface7_PageLock(p,a) ICOM_CALL_(PageLock,p,(p,a))
+#define IDirectDrawSurface7_PageUnlock(p,a) ICOM_CALL_(PageUnlock,p,(p,a))
+/*** IDirectDrawSurface3 methods ***/
+#define IDirectDrawSurface7_SetSurfaceDesc(p,a,b) ICOM_CALL_(SetSurfaceDesc,p,(p,a,b))
+/*** IDirectDrawSurface4 methods ***/
+#define IDirectDrawSurface7_SetPrivateData(p,a,b,c,d) ICOM_CALL_(SetPrivateData,p,(p,a,b,c,d))
+#define IDirectDrawSurface7_GetPrivateData(p,a,b,c) ICOM_CALL_(GetPrivateData,p,(p,a,b,c))
+#define IDirectDrawSurface7_FreePrivateData(p,a) ICOM_CALL_(FreePrivateData,p,(p,a))
+#define IDirectDrawSurface7_GetUniquenessValue(p,a) ICOM_CALL_(GetUniquenessValue,p,(p,a))
+#define IDirectDrawSurface7_ChangeUniquenessValue(p) ICOM_CALL_(ChangeUniquenessValue,p,(p))
+/*** IDirectDrawSurface7 methods ***/
+#define IDirectDrawSurface7_SetPriority(p,a) ICOM_CALL_(SetPriority,p,(p,a))
+#define IDirectDrawSurface7_GetPriority(p,a) ICOM_CALL_(GetPriority,p,(p,a))
+#define IDirectDrawSurface7_SetLOD(p,a) ICOM_CALL_(SetLOD,p,(p,a))
+#define IDirectDrawSurface7_GetLOD(p,a) ICOM_CALL_(GetLOD,p,(p,a))
+
+/*****************************************************************************
+ * IDirectDrawColorControl interface
+ */
+#undef INTERFACE
+#define INTERFACE IDirectDrawColorControl
+DECLARE_INTERFACE_(IDirectDrawColorControl,IUnknown)
+{
+ STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ STDMETHOD(GetColorControls)(THIS_ LPDDCOLORCONTROL lpColorControl) PURE;
+ STDMETHOD(SetColorControls)(THIS_ LPDDCOLORCONTROL lpColorControl) PURE;
+};
+
+ /*** IUnknown methods ***/
+#define IDirectDrawColorControl_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
+#define IDirectDrawColorControl_AddRef(p) ICOM_CALL_(AddRef,p,(p))
+#define IDirectDrawColorControl_Release(p) ICOM_CALL_(Release,p,(p))
+ /*** IDirectDrawColorControl methods ***/
+#define IDirectDrawColorControl_GetColorControls(p,a) ICOM_CALL_(GetColorControls,p,(p,a))
+#define IDirectDrawColorControl_SetColorControls(p,a) ICOM_CALL_(SetColorControls,p,(p,a))
+
+/*****************************************************************************
+ * IDirectDrawGammaControl interface
+ */
+#undef INTERFACE
+#define INTERFACE IDirectDrawGammaControl
+DECLARE_INTERFACE_(IDirectDrawGammaControl,IUnknown)
+{
+ STDMETHOD(QueryInterface)(THIS_ REFIID,LPVOID*) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+ STDMETHOD(GetGammaRamp)(THIS_ DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp) PURE;
+ STDMETHOD(SetGammaRamp)(THIS_ DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp) PURE;
+};
+
+ /*** IUnknown methods ***/
+#define IDirectDrawGammaControl_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b))
+#define IDirectDrawGammaControl_AddRef(p) ICOM_CALL_(AddRef,p,(p))
+#define IDirectDrawGammaControl_Release(p) ICOM_CALL_(Release,p,(p))
+ /*** IDirectDrawGammaControl methods ***/
+#define IDirectDrawGammaControl_GetGammaRamp(p,a,b) ICOM_CALL_(GetGammaRamp,p,(p,a,b))
+#define IDirectDrawGammaControl_SetGammaRamp(p,a,b) ICOM_CALL_(SetGammaRamp,p,(p,a,b))
+
+
+HRESULT WINAPI DirectDrawCreate(LPGUID,LPDIRECTDRAW*,LPUNKNOWN);
+HRESULT WINAPI DirectDrawCreateEx(LPGUID,LPVOID*,REFIID,LPUNKNOWN);
+HRESULT WINAPI DirectDrawEnumerateA(LPDDENUMCALLBACKA,LPVOID);
+HRESULT WINAPI DirectDrawEnumerateW(LPDDENUMCALLBACKW,LPVOID);
+#define DirectDrawEnumerate WINELIB_NAME_AW(DirectDrawEnumerate)
+HRESULT WINAPI DirectDrawCreateClipper(DWORD,LPDIRECTDRAWCLIPPER*,LPUNKNOWN);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif /* defined(__cplusplus) */
+
+#endif /* __XWIN_DDRAW_H */
diff --git a/nx-X11/programs/Xserver/hw/xwin/win.h b/nx-X11/programs/Xserver/hw/xwin/win.h
new file mode 100644
index 000000000..9baee9b05
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/win.h
@@ -0,0 +1,1466 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ * Kensuke Matsuzaki
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/win.h,v 1.37 2003/10/02 13:30:09 eich Exp $ */
+
+#ifndef _WIN_H_
+#define _WIN_H_
+
+#ifndef NO
+#define NO 0
+#endif
+#ifndef YES
+#define YES 1
+#endif
+
+/* Turn debug messages on or off */
+#ifndef CYGDEBUG
+#define CYGDEBUG NO
+#endif
+
+/* WM_XBUTTON Messages. They should go into w32api. */
+#ifndef WM_XBUTTONDOWN
+# define WM_XBUTTONDOWN 523
+#endif
+#ifndef WM_XBUTTONUP
+# define WM_XBUTTONUP 524
+#endif
+#ifndef WM_XBUTTONDBLCLK
+# define WM_XBUTTONDBLCLK 525
+#endif
+
+#define NEED_EVENTS
+
+#define WIN_DEFAULT_BPP 0
+#define WIN_DEFAULT_WHITEPIXEL 255
+#define WIN_DEFAULT_BLACKPIXEL 0
+#define WIN_DEFAULT_LINEBIAS 0
+#define WIN_DEFAULT_E3B_TIME 50 /* milliseconds */
+#define WIN_DEFAULT_DPI 75
+#define WIN_DEFAULT_REFRESH 0
+#define WIN_DEFAULT_WIN_KILL TRUE
+#define WIN_DEFAULT_UNIX_KILL FALSE
+#define WIN_DEFAULT_CLIP_UPDATES_NBOXES 0
+#ifdef XWIN_EMULATEPSEUDO
+#define WIN_DEFAULT_EMULATE_PSEUDO FALSE
+#endif
+#define WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH FALSE
+
+#define WIN_DIB_MAXIMUM_SIZE 0x08000000 /* 16 MB on Windows 95, 98, Me */
+#define WIN_DIB_MAXIMUM_SIZE_MB (WIN_DIB_MAXIMUM_SIZE / 8 / 1024 / 1024)
+
+/*
+ * Windows only supports 256 color palettes
+ */
+#define WIN_NUM_PALETTE_ENTRIES 256
+
+/*
+ * Number of times to call Restore in an attempt to restore the primary surface
+ */
+#define WIN_REGAIN_SURFACE_RETRIES 1
+
+/*
+ * Build a supported display depths mask by shifting one to the left
+ * by the number of bits in the supported depth.
+ */
+#define WIN_SUPPORTED_BPPS ( (1 << (32 - 1)) | (1 << (24 - 1)) \
+ | (1 << (16 - 1)) | (1 << (15 - 1)) \
+ | (1 << ( 8 - 1)))
+#define WIN_CHECK_DEPTH YES
+
+/*
+ * Timer IDs for WM_TIMER
+ */
+#define WIN_E3B_TIMER_ID 1
+#define WIN_POLLING_MOUSE_TIMER_ID 2
+
+
+#define WIN_E3B_OFF -1
+#define WIN_FD_INVALID -1
+
+#define WIN_SERVER_NONE 0x0L /* 0 */
+#define WIN_SERVER_SHADOW_GDI 0x1L /* 1 */
+#define WIN_SERVER_SHADOW_DD 0x2L /* 2 */
+#define WIN_SERVER_SHADOW_DDNL 0x4L /* 4 */
+#ifdef XWIN_PRIMARYFB
+#define WIN_SERVER_PRIMARY_DD 0x8L /* 8 */
+#endif
+#ifdef XWIN_NATIVEGDI
+# define WIN_SERVER_NATIVE_GDI 0x10L /* 16 */
+#endif
+
+#define AltMapIndex Mod1MapIndex
+#define NumLockMapIndex Mod2MapIndex
+#define AltLangMapIndex Mod3MapIndex
+#define KanaMapIndex Mod4MapIndex
+#define ScrollLockMapIndex Mod5MapIndex
+
+#define WIN_MOD_LALT 0x00000001
+#define WIN_MOD_RALT 0x00000002
+#define WIN_MOD_LCONTROL 0x00000004
+#define WIN_MOD_RCONTROL 0x00000008
+
+#define WIN_24BPP_MASK_RED 0x00FF0000
+#define WIN_24BPP_MASK_GREEN 0x0000FF00
+#define WIN_24BPP_MASK_BLUE 0x000000FF
+
+#define WIN_MAX_KEYS_PER_KEY 4
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+
+#include <errno.h>
+#if defined(XWIN_MULTIWINDOWEXTWM) || defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+#define HANDLE void *
+#include <pthread.h>
+#undef HANDLE
+#endif
+
+#ifdef HAS_MMAP
+#include <sys/mman.h>
+#ifndef MAP_FILE
+#define MAP_FILE 0
+#endif /* MAP_FILE */
+#endif /* HAS_MMAP */
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xos.h>
+#include <X11/Xprotostr.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "pixmap.h"
+#include "region.h"
+#include "gcstruct.h"
+#include "colormap.h"
+#include "colormapst.h"
+#include "miscstruct.h"
+#include "servermd.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "micmap.h"
+#include "mifillarc.h"
+#include "mifpoly.h"
+#include "mibstore.h"
+#include "input.h"
+#include "mipointer.h"
+#include "X11/keysym.h"
+#include "mibstore.h"
+#include "micoord.h"
+#include "dix.h"
+#include "miline.h"
+#include "shadow.h"
+#include "fb.h"
+#include "rootless.h"
+
+#ifdef RENDER
+#include "mipict.h"
+#include "picturestr.h"
+#endif
+
+#ifdef RANDR
+#include "randrstr.h"
+#endif
+
+/*
+ * Windows headers
+ */
+#include "winms.h"
+#include "./winresource.h"
+
+
+/*
+ * Define Windows constants
+ */
+
+#define WM_TRAYICON (WM_USER + 1000)
+#define WM_INIT_SYS_MENU (WM_USER + 1001)
+#define WM_GIVEUP (WM_USER + 1002)
+
+
+/* Local includes */
+#include "winwindow.h"
+#include "winmsg.h"
+
+
+/*
+ * Debugging macros
+ */
+
+#if CYGDEBUG
+#define DEBUG_MSG(str,...) \
+if (fDebugProcMsg) \
+{ \
+ char *pszTemp; \
+ int iLength; \
+ pszTemp = Xprintf (str, ##__VA_ARGS__); \
+ MessageBox (NULL, pszTemp, szFunctionName, MB_OK); \
+ xfree (pszTemp); \
+}
+#else
+#define DEBUG_MSG(str,...)
+#endif
+
+#if CYGDEBUG
+#define DEBUG_FN_NAME(str) PTSTR szFunctionName = str
+#else
+#define DEBUG_FN_NAME(str)
+#endif
+
+#if CYGDEBUG || YES
+#define DEBUGVARS BOOL fDebugProcMsg = FALSE
+#else
+#define DEBUGVARS
+#endif
+
+#if CYGDEBUG || YES
+#define DEBUGPROC_MSG fDebugProcMsg = TRUE
+#else
+#define DEBUGPROC_MSG
+#endif
+
+#define PROFILEPOINT(point,thresh)\
+{\
+static unsigned int PROFPT##point = 0;\
+if (++PROFPT##point % thresh == 0)\
+ErrorF (#point ": PROFILEPOINT hit %u times\n", PROFPT##point);\
+}
+
+
+/* We use xor this macro for detecting toggle key state changes */
+#define WIN_XOR(a,b) ((!(a) && (b)) || ((a) && !(b)))
+
+#define DEFINE_ATOM_HELPER(func,atom_name) \
+static Atom func (void) { \
+ static int generation; \
+ static Atom atom; \
+ if (generation != serverGeneration) { \
+ generation = serverGeneration; \
+ atom = MakeAtom (atom_name, strlen (atom_name), TRUE); \
+ } \
+ return atom; \
+}
+
+/*
+ * Typedefs for engine dependent function pointers
+ */
+
+typedef Bool (*winAllocateFBProcPtr)(ScreenPtr);
+
+typedef void (*winShadowUpdateProcPtr)(ScreenPtr, shadowBufPtr);
+
+typedef Bool (*winCloseScreenProcPtr)(int, ScreenPtr);
+
+typedef Bool (*winInitVisualsProcPtr)(ScreenPtr);
+
+typedef Bool (*winAdjustVideoModeProcPtr)(ScreenPtr);
+
+typedef Bool (*winCreateBoundingWindowProcPtr)(ScreenPtr);
+
+typedef Bool (*winFinishScreenInitProcPtr)(int, ScreenPtr, int, char **);
+
+typedef Bool (*winBltExposedRegionsProcPtr)(ScreenPtr);
+
+typedef Bool (*winActivateAppProcPtr)(ScreenPtr);
+
+typedef Bool (*winRedrawScreenProcPtr)(ScreenPtr pScreen);
+
+typedef Bool (*winRealizeInstalledPaletteProcPtr)(ScreenPtr pScreen);
+
+typedef Bool (*winInstallColormapProcPtr)(ColormapPtr pColormap);
+
+typedef Bool (*winStoreColorsProcPtr)(ColormapPtr pmap,
+ int ndef, xColorItem *pdefs);
+
+typedef Bool (*winCreateColormapProcPtr)(ColormapPtr pColormap);
+
+typedef Bool (*winDestroyColormapProcPtr)(ColormapPtr pColormap);
+
+typedef Bool (*winHotKeyAltTabProcPtr)(ScreenPtr);
+
+typedef Bool (*winCreatePrimarySurfaceProcPtr)(ScreenPtr);
+
+typedef Bool (*winReleasePrimarySurfaceProcPtr)(ScreenPtr);
+
+typedef Bool (*winFinishCreateWindowsWindowProcPtr)(WindowPtr pWin);
+
+
+/* Typedef for DIX wrapper functions */
+typedef int (*winDispatchProcPtr) (ClientPtr);
+
+
+/*
+ * GC (graphics context) privates
+ */
+
+typedef struct
+{
+ HDC hdc;
+ HDC hdcMem;
+} winPrivGCRec, *winPrivGCPtr;
+
+
+/*
+ * Pixmap privates
+ */
+
+typedef struct
+{
+ HDC hdcSelected;
+ HBITMAP hBitmap;
+ BYTE *pbBits;
+ DWORD dwScanlineBytes;
+ BITMAPINFOHEADER *pbmih;
+} winPrivPixmapRec, *winPrivPixmapPtr;
+
+
+/*
+ * Colormap privates
+ */
+
+typedef struct
+{
+ HPALETTE hPalette;
+ LPDIRECTDRAWPALETTE lpDDPalette;
+ RGBQUAD rgbColors[WIN_NUM_PALETTE_ENTRIES];
+ PALETTEENTRY peColors[WIN_NUM_PALETTE_ENTRIES];
+} winPrivCmapRec, *winPrivCmapPtr;
+
+/*
+ * Windows Cursor handling.
+ */
+
+typedef struct {
+ /* from GetSystemMetrics */
+ int sm_cx;
+ int sm_cy;
+
+ BOOL visible;
+ HCURSOR handle;
+ QueryBestSizeProcPtr QueryBestSize;
+ miPointerSpriteFuncPtr spriteFuncs;
+} winCursorRec;
+
+/*
+ * Screen information structure that we need before privates are available
+ * in the server startup sequence.
+ */
+
+typedef struct
+{
+ ScreenPtr pScreen;
+
+ /* Did the user specify a height and width? */
+ Bool fUserGaveHeightAndWidth;
+
+ DWORD dwScreen;
+ DWORD dwUserWidth;
+ DWORD dwUserHeight;
+ DWORD dwWidth;
+ DWORD dwHeight;
+ DWORD dwWidth_mm;
+ DWORD dwHeight_mm;
+ DWORD dwPaddedWidth;
+
+ /* Did the user specify a screen position? */
+ Bool fUserGavePosition;
+ DWORD dwInitialX;
+ DWORD dwInitialY;
+
+ /*
+ * dwStride is the number of whole pixels that occupy a scanline,
+ * including those pixels that are not displayed. This is basically
+ * a rounding up of the width.
+ */
+ DWORD dwStride;
+
+ /* Offset of the screen in the window when using scrollbars */
+ DWORD dwXOffset;
+ DWORD dwYOffset;
+
+ DWORD dwBPP;
+ DWORD dwDepth;
+ DWORD dwRefreshRate;
+ char *pfb;
+ DWORD dwEngine;
+ DWORD dwEnginePreferred;
+ DWORD dwClipUpdatesNBoxes;
+#ifdef XWIN_EMULATEPSEUDO
+ Bool fEmulatePseudo;
+#endif
+ Bool fFullScreen;
+ Bool fDecoration;
+#ifdef XWIN_MULTIWINDOWEXTWM
+ Bool fMWExtWM;
+ Bool fInternalWM;
+ Bool fAnotherWMRunning;
+#endif
+ Bool fRootless;
+#ifdef XWIN_MULTIWINDOW
+ Bool fMultiWindow;
+#endif
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ Bool fMultiMonitorOverride;
+#endif
+ Bool fMultipleMonitors;
+ Bool fLessPointer;
+ Bool fScrollbars;
+ Bool fNoTrayIcon;
+ int iE3BTimeout;
+ /* Windows (Alt+F4) and Unix (Ctrl+Alt+Backspace) Killkey */
+ Bool fUseWinKillKey;
+ Bool fUseUnixKillKey;
+ Bool fIgnoreInput;
+
+ /* Did the user explicitly set this screen? */
+ Bool fExplicitScreen;
+} winScreenInfo, *winScreenInfoPtr;
+
+
+/*
+ * Screen privates
+ */
+
+typedef struct _winPrivScreenRec
+{
+ winScreenInfoPtr pScreenInfo;
+
+ Bool fEnabled;
+ Bool fClosed;
+ Bool fActive;
+ Bool fBadDepth;
+
+ int iDeltaZ;
+
+ int iConnectedClients;
+
+ CloseScreenProcPtr CloseScreen;
+
+ DWORD dwRedMask;
+ DWORD dwGreenMask;
+ DWORD dwBlueMask;
+ DWORD dwBitsPerRGB;
+
+ DWORD dwModeKeyStates;
+
+ /* Handle to icons that must be freed */
+ HICON hiconNotifyIcon;
+
+ /* Last width, height, and depth of the Windows display */
+ DWORD dwLastWindowsWidth;
+ DWORD dwLastWindowsHeight;
+ DWORD dwLastWindowsBitsPixel;
+
+ /* Palette management */
+ ColormapPtr pcmapInstalled;
+
+ /* Pointer to the root visual so we only have to look it up once */
+ VisualPtr pRootVisual;
+
+ /* 3 button emulation variables */
+ int iE3BCachedPress;
+ Bool fE3BFakeButton2Sent;
+
+ /* Privates used by shadow fb GDI server */
+ HBITMAP hbmpShadow;
+ HDC hdcScreen;
+ HDC hdcShadow;
+ HWND hwndScreen;
+
+ /* Privates used by shadow fb and primary fb DirectDraw servers */
+ LPDIRECTDRAW pdd;
+ LPDIRECTDRAWSURFACE2 pddsPrimary;
+ LPDIRECTDRAW2 pdd2;
+
+ /* Privates used by shadow fb DirectDraw server */
+ LPDIRECTDRAWSURFACE2 pddsShadow;
+ LPDDSURFACEDESC pddsdShadow;
+
+ /* Privates used by primary fb DirectDraw server */
+ LPDIRECTDRAWSURFACE2 pddsOffscreen;
+ LPDDSURFACEDESC pddsdOffscreen;
+ LPDDSURFACEDESC pddsdPrimary;
+
+ /* Privates used by shadow fb DirectDraw Nonlocking server */
+ LPDIRECTDRAW4 pdd4;
+ LPDIRECTDRAWSURFACE4 pddsShadow4;
+ LPDIRECTDRAWSURFACE4 pddsPrimary4;
+ BOOL fRetryCreateSurface;
+
+ /* Privates used by both shadow fb DirectDraw servers */
+ LPDIRECTDRAWCLIPPER pddcPrimary;
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ /* Privates used by multi-window external window manager */
+ RootlessFrameID widTop;
+ Bool fRestacking;
+#endif
+
+#ifdef XWIN_MULTIWINDOW
+ /* Privates used by multi-window */
+ pthread_t ptWMProc;
+ pthread_t ptXMsgProc;
+ void *pWMInfo;
+#endif
+
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ /* Privates used by both multi-window and rootless */
+ Bool fRootWindowShown;
+#endif
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ /* Privates used for any module running in a seperate thread */
+ pthread_mutex_t pmServerStarted;
+ Bool fServerStarted;
+#endif
+
+ /* Engine specific functions */
+ winAllocateFBProcPtr pwinAllocateFB;
+ winShadowUpdateProcPtr pwinShadowUpdate;
+ winCloseScreenProcPtr pwinCloseScreen;
+ winInitVisualsProcPtr pwinInitVisuals;
+ winAdjustVideoModeProcPtr pwinAdjustVideoMode;
+ winCreateBoundingWindowProcPtr pwinCreateBoundingWindow;
+ winFinishScreenInitProcPtr pwinFinishScreenInit;
+ winBltExposedRegionsProcPtr pwinBltExposedRegions;
+ winActivateAppProcPtr pwinActivateApp;
+ winRedrawScreenProcPtr pwinRedrawScreen;
+ winRealizeInstalledPaletteProcPtr pwinRealizeInstalledPalette;
+ winInstallColormapProcPtr pwinInstallColormap;
+ winStoreColorsProcPtr pwinStoreColors;
+ winCreateColormapProcPtr pwinCreateColormap;
+ winDestroyColormapProcPtr pwinDestroyColormap;
+ winHotKeyAltTabProcPtr pwinHotKeyAltTab;
+ winCreatePrimarySurfaceProcPtr pwinCreatePrimarySurface;
+ winReleasePrimarySurfaceProcPtr pwinReleasePrimarySurface;
+
+#ifdef XWIN_MULTIWINDOW
+ /* Window Procedures for MultiWindow mode */
+ winFinishCreateWindowsWindowProcPtr pwinFinishCreateWindowsWindow;
+#endif
+
+ /* Window Procedures for Rootless mode */
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ PositionWindowProcPtr PositionWindow;
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ ValidateTreeProcPtr ValidateTree;
+ PostValidateTreeProcPtr PostValidateTree;
+ WindowExposuresProcPtr WindowExposures;
+ PaintWindowBackgroundProcPtr PaintWindowBackground;
+ PaintWindowBorderProcPtr PaintWindowBorder;
+ CopyWindowProcPtr CopyWindow;
+ ClearToBackgroundProcPtr ClearToBackground;
+ ClipNotifyProcPtr ClipNotify;
+ RestackWindowProcPtr RestackWindow;
+ ReparentWindowProcPtr ReparentWindow;
+ ResizeWindowProcPtr ResizeWindow;
+ MoveWindowProcPtr MoveWindow;
+#ifdef SHAPE
+ SetShapeProcPtr SetShape;
+#endif
+
+ winCursorRec cursor;
+} winPrivScreenRec;
+
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+typedef struct {
+ RootlessWindowPtr pFrame;
+ HWND hWnd;
+ int dwWidthBytes;
+ BITMAPINFOHEADER *pbmihShadow;
+ HBITMAP hbmpShadow;
+ HDC hdcShadow;
+ HDC hdcScreen;
+ BOOL fResized;
+ BOOL fRestackingNow;
+ BOOL fClose;
+ BOOL fMovingOrSizing;
+ BOOL fDestroyed;//for debug
+ char *pfb;
+} win32RootlessWindowRec, *win32RootlessWindowPtr;
+#endif
+
+
+typedef struct {
+ pointer value;
+ XID id;
+} WindowIDPairRec, *WindowIDPairPtr;
+
+
+/*
+ * Extern declares for general global variables
+ */
+
+extern winScreenInfo g_ScreenInfo[];
+extern miPointerScreenFuncRec g_winPointerCursorFuncs;
+extern DWORD g_dwEvents;
+#ifdef HAS_DEVWINDOWS
+extern int g_fdMessageQueue;
+#endif
+extern int g_iScreenPrivateIndex;
+extern int g_iCmapPrivateIndex;
+extern int g_iGCPrivateIndex;
+extern int g_iPixmapPrivateIndex;
+extern int g_iWindowPrivateIndex;
+extern unsigned long g_ulServerGeneration;
+extern CARD32 g_c32LastInputEventTime;
+extern DWORD g_dwEnginesSupported;
+extern HINSTANCE g_hInstance;
+extern int g_copyROP[];
+extern int g_patternROP[];
+extern const char * g_pszQueryHost;
+
+
+/*
+ * Extern declares for dynamically loaded libraries and function pointers
+ */
+
+extern HMODULE g_hmodDirectDraw;
+extern FARPROC g_fpDirectDrawCreate;
+extern FARPROC g_fpDirectDrawCreateClipper;
+
+extern HMODULE g_hmodCommonControls;
+extern FARPROC g_fpTrackMouseEvent;
+
+
+/*
+ * Screen privates macros
+ */
+
+#define winGetScreenPriv(pScreen) \
+ ((winPrivScreenPtr) (pScreen)->devPrivates[g_iScreenPrivateIndex].ptr)
+
+#define winSetScreenPriv(pScreen,v) \
+ ((pScreen)->devPrivates[g_iScreenPrivateIndex].ptr = (pointer) v)
+
+#define winScreenPriv(pScreen) \
+ winPrivScreenPtr pScreenPriv = winGetScreenPriv(pScreen)
+
+
+/*
+ * Colormap privates macros
+ */
+
+#define winGetCmapPriv(pCmap) \
+ ((winPrivCmapPtr) (pCmap)->devPrivates[g_iCmapPrivateIndex].ptr)
+
+#define winSetCmapPriv(pCmap,v) \
+ ((pCmap)->devPrivates[g_iCmapPrivateIndex].ptr = (pointer) v)
+
+#define winCmapPriv(pCmap) \
+ winPrivCmapPtr pCmapPriv = winGetCmapPriv(pCmap)
+
+
+/*
+ * GC privates macros
+ */
+
+#define winGetGCPriv(pGC) \
+ ((winPrivGCPtr) (pGC)->devPrivates[g_iGCPrivateIndex].ptr)
+
+#define winSetGCPriv(pGC,v) \
+ ((pGC)->devPrivates[g_iGCPrivateIndex].ptr = (pointer) v)
+
+#define winGCPriv(pGC) \
+ winPrivGCPtr pGCPriv = winGetGCPriv(pGC)
+
+
+/*
+ * Pixmap privates macros
+ */
+
+#define winGetPixmapPriv(pPixmap) \
+ ((winPrivPixmapPtr) (pPixmap)->devPrivates[g_iPixmapPrivateIndex].ptr)
+
+#define winSetPixmapPriv(pPixmap,v) \
+ ((pPixmap)->devPrivates[g_iPixmapPrivateIndex].ptr = (pointer) v)
+
+#define winPixmapPriv(pPixmap) \
+ winPrivPixmapPtr pPixmapPriv = winGetPixmapPriv(pPixmap)
+
+
+/*
+ * Window privates macros
+ */
+
+#define winGetWindowPriv(pWin) \
+ ((winPrivWinPtr) (pWin)->devPrivates[g_iWindowPrivateIndex].ptr)
+
+#define winSetWindowPriv(pWin,v) \
+ ((pWin)->devPrivates[g_iWindowPrivateIndex].ptr = (pointer) v)
+
+#define winWindowPriv(pWin) \
+ winPrivWinPtr pWinPriv = winGetWindowPriv(pWin)
+
+/*
+ * wrapper macros
+ */
+#define _WIN_WRAP(priv, real, mem, func) {\
+ priv->mem = real->mem; \
+ real->mem = func; \
+}
+
+#define _WIN_UNWRAP(priv, real, mem) {\
+ real->mem = priv->mem; \
+}
+
+#define WIN_WRAP(mem, func) _WIN_WRAP(pScreenPriv, pScreen, mem, func)
+
+#define WIN_UNWRAP(mem) _WIN_UNWRAP(pScreenPriv, pScreen, mem)
+
+/*
+ * BEGIN DDX and DIX Function Prototypes
+ */
+
+
+/*
+ * winallpriv.c
+ */
+
+Bool
+winAllocatePrivates (ScreenPtr pScreen);
+
+Bool
+winInitCmapPrivates (ColormapPtr pCmap, int index);
+
+Bool
+winAllocateCmapPrivates (ColormapPtr pCmap);
+
+
+/*
+ * winauth.c
+ */
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+# if defined(XCSECURITY)
+Bool
+winGenerateAuthorization (void);
+# endif
+#endif
+
+
+/*
+ * winblock.c
+ */
+
+void
+winBlockHandler (int nScreen,
+ pointer pBlockData,
+ pointer pTimeout,
+ pointer pReadMask);
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winclip.c
+ */
+
+RegionPtr
+winPixmapToRegionNativeGDI (PixmapPtr pPix);
+#endif
+
+
+#ifdef XWIN_CLIPBOARD
+/*
+ * winclipboardinit.c
+ */
+
+Bool
+winInitClipboard (void);
+
+void
+winFixClipboardChain (void);
+#endif
+
+
+/*
+ * wincmap.c
+ */
+
+void
+winSetColormapFunctions (ScreenPtr pScreen);
+
+Bool
+winCreateDefColormap (ScreenPtr pScreen);
+
+
+/*
+ * wincreatewnd.c
+ */
+
+Bool
+winCreateBoundingWindowFullScreen (ScreenPtr pScreen);
+
+Bool
+winCreateBoundingWindowWindowed (ScreenPtr pScreen);
+
+
+/*
+ * windialogs.c
+ */
+
+void
+winDisplayExitDialog (winPrivScreenPtr pScreenPriv);
+
+void
+winDisplayDepthChangeDialog (winPrivScreenPtr pScreenPriv);
+
+void
+winDisplayAboutDialog (winPrivScreenPtr pScreenPriv);
+
+
+/*
+ * winengine.c
+ */
+
+void
+winDetectSupportedEngines (void);
+
+Bool
+winSetEngine (ScreenPtr pScreen);
+
+Bool
+winGetDDProcAddresses (void);
+
+
+/*
+ * winerror.c
+ */
+
+#ifdef DDXOSVERRORF
+void
+OSVenderVErrorF (const char *pszFormat, va_list va_args);
+#endif
+
+void
+winMessageBoxF (const char *pszError, UINT uType, ...);
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winfillsp.c
+ */
+
+void
+winFillSpansNativeGDI (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nSpans,
+ DDXPointPtr pPoints,
+ int *pWidths,
+ int fSorted);
+#endif
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winfont.c
+ */
+
+Bool
+winRealizeFontNativeGDI (ScreenPtr pScreen, FontPtr pFont);
+
+Bool
+winUnrealizeFontNativeGDI (ScreenPtr pScreen, FontPtr pFont);
+#endif
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * wingc.c
+ */
+
+Bool
+winCreateGCNativeGDI (GCPtr pGC);
+#endif
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * wingetsp.c
+ */
+
+void
+winGetSpansNativeGDI (DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr pPoints,
+ int *pWidths,
+ int nSpans,
+ char *pDst);
+#endif
+
+
+/*
+ * winglobals.c
+ */
+
+void
+winInitializeGlobals (void);
+
+
+/*
+ * winkeybd.c
+ */
+
+void
+winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode);
+
+int
+winKeybdProc (DeviceIntPtr pDeviceInt, int iState);
+
+void
+winInitializeModeKeyStates (void);
+
+void
+winRestoreModeKeyStates (void);
+
+Bool
+winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam);
+
+void
+winKeybdReleaseKeys (void);
+
+void
+winSendKeyEvent (DWORD dwKey, Bool fDown);
+
+
+/*
+ * winkeyhook.c
+ */
+
+Bool
+winInstallKeyboardHookLL (void);
+
+void
+winRemoveKeyboardHookLL (void);
+
+
+/*
+ * winmisc.c
+ */
+
+#ifdef XWIN_NATIVEGDI
+void
+winQueryBestSizeNativeGDI (int class, unsigned short *pWidth,
+ unsigned short *pHeight, ScreenPtr pScreen);
+#endif
+
+CARD8
+winCountBits (DWORD dw);
+
+Bool
+winUpdateFBPointer (ScreenPtr pScreen, void *pbits);
+
+#ifdef XWIN_NATIVEGDI
+BOOL
+winPaintBackground (HWND hwnd, COLORREF colorref);
+#endif
+
+
+/*
+ * winmouse.c
+ */
+
+int
+winMouseProc (DeviceIntPtr pDeviceInt, int iState);
+
+int
+winMouseWheel (ScreenPtr pScreen, int iDeltaZ);
+
+void
+winMouseButtonsSendEvent (int iEventType, int iButton);
+
+int
+winMouseButtonsHandle (ScreenPtr pScreen,
+ int iEventType, int iButton,
+ WPARAM wParam);
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winnativegdi.c
+ */
+
+HBITMAP
+winCreateDIBNativeGDI (int iWidth, int iHeight, int iDepth,
+ BYTE **ppbBits, BITMAPINFO **ppbmi);
+
+Bool
+winSetEngineFunctionsNativeGDI (ScreenPtr pScreen);
+#endif
+
+
+#ifdef XWIN_PRIMARYFB
+/*
+ * winpfbddd.c
+ */
+
+Bool
+winSetEngineFunctionsPrimaryDD (ScreenPtr pScreen);
+#endif
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winpixmap.c
+ */
+
+PixmapPtr
+winCreatePixmapNativeGDI (ScreenPtr pScreen, int width, int height, int depth);
+
+Bool
+winDestroyPixmapNativeGDI (PixmapPtr pPixmap);
+
+Bool
+winModifyPixmapHeaderNativeGDI (PixmapPtr pPixmap,
+ int iWidth, int iHeight,
+ int iDepth,
+ int iBitsPerPixel,
+ int devKind,
+ pointer pPixData);
+#endif
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winpntwin.c
+ */
+
+void
+winPaintWindowNativeGDI (WindowPtr pWin, RegionPtr pRegion, int what);
+#endif
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winpolyline.c
+ */
+
+void
+winPolyLineNativeGDI (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ppt);
+#endif
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winpushpxl.c
+ */
+
+void
+winPushPixels (GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable,
+ int dx, int dy, int xOrg, int yOrg);
+#endif
+
+
+/*
+ * winscrinit.c
+ */
+
+Bool
+winScreenInit (int index,
+ ScreenPtr pScreen,
+ int argc, char **argv);
+
+Bool
+winFinishScreenInitFB (int index,
+ ScreenPtr pScreen,
+ int argc, char **argv);
+
+#if defined(XWIN_NATIVEGDI)
+Bool
+winFinishScreenInitNativeGDI (int index,
+ ScreenPtr pScreen,
+ int argc, char **argv);
+#endif
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * winsetsp.c
+ */
+
+void
+winSetSpansNativeGDI (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *pSrc,
+ DDXPointPtr pPoints,
+ int *pWidth,
+ int nSpans,
+ int fSorted);
+#endif
+
+
+/*
+ * winshaddd.c
+ */
+
+Bool
+winSetEngineFunctionsShadowDD (ScreenPtr pScreen);
+
+
+/*
+ * winshadddnl.c
+ */
+
+Bool
+winSetEngineFunctionsShadowDDNL (ScreenPtr pScreen);
+
+
+/*
+ * winshadgdi.c
+ */
+
+Bool
+winSetEngineFunctionsShadowGDI (ScreenPtr pScreen);
+
+
+/*
+ * winwakeup.c
+ */
+
+void
+winWakeupHandler (int nScreen,
+ pointer pWakeupData,
+ unsigned long ulResult,
+ pointer pReadmask);
+
+
+/*
+ * winwindow.c
+ */
+
+#ifdef XWIN_NATIVEGDI
+Bool
+winCreateWindowNativeGDI (WindowPtr pWin);
+
+Bool
+winDestroyWindowNativeGDI (WindowPtr pWin);
+
+Bool
+winPositionWindowNativeGDI (WindowPtr pWin, int x, int y);
+
+void
+winCopyWindowNativeGDI (WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc);
+
+Bool
+winChangeWindowAttributesNativeGDI (WindowPtr pWin, unsigned long mask);
+
+Bool
+winUnmapWindowNativeGDI (WindowPtr pWindow);
+
+Bool
+winMapWindowNativeGDI (WindowPtr pWindow);
+#endif
+
+Bool
+winCreateWindowRootless (WindowPtr pWindow);
+
+Bool
+winDestroyWindowRootless (WindowPtr pWindow);
+
+Bool
+winPositionWindowRootless (WindowPtr pWindow, int x, int y);
+
+Bool
+winChangeWindowAttributesRootless (WindowPtr pWindow, unsigned long mask);
+
+Bool
+winUnmapWindowRootless (WindowPtr pWindow);
+
+Bool
+winMapWindowRootless (WindowPtr pWindow);
+
+#ifdef SHAPE
+void
+winSetShapeRootless (WindowPtr pWindow);
+#endif
+
+
+/*
+ * winmultiwindowicons.c - Used by both multi-window and Win32Rootless
+ */
+
+HICON
+winXIconToHICON (WindowPtr pWin, int iconSize);
+
+
+#ifdef XWIN_MULTIWINDOW
+/*
+ * winmultiwindowshape.c
+ */
+
+# ifdef SHAPE
+void
+winReshapeMultiWindow (WindowPtr pWin);
+
+void
+winSetShapeMultiWindow (WindowPtr pWindow);
+
+void
+winUpdateRgnMultiWindow (WindowPtr pWindow);
+# endif
+#endif
+
+
+#ifdef XWIN_MULTIWINDOW
+/*
+ * winmultiwindowwindow.c
+ */
+
+Bool
+winCreateWindowMultiWindow (WindowPtr pWindow);
+
+Bool
+winDestroyWindowMultiWindow (WindowPtr pWindow);
+
+Bool
+winPositionWindowMultiWindow (WindowPtr pWindow, int x, int y);
+
+Bool
+winChangeWindowAttributesMultiWindow (WindowPtr pWindow, unsigned long mask);
+
+Bool
+winUnmapWindowMultiWindow (WindowPtr pWindow);
+
+Bool
+winMapWindowMultiWindow (WindowPtr pWindow);
+
+void
+winReparentWindowMultiWindow (WindowPtr pWin, WindowPtr pPriorParent);
+
+void
+winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib);
+
+void
+winReorderWindowsMultiWindow (void);
+
+void
+winResizeWindowMultiWindow (WindowPtr pWin, int x, int y, unsigned int w,
+ unsigned int h, WindowPtr pSib);
+void
+winMoveWindowMultiWindow (WindowPtr pWin, int x, int y,
+ WindowPtr pSib, VTKind kind);
+
+void
+winCopyWindowMultiWindow (WindowPtr pWin, DDXPointRec oldpt,
+ RegionPtr oldRegion);
+
+XID
+winGetWindowID (WindowPtr pWin);
+
+int
+winAdjustXWindow (WindowPtr pWin, HWND hwnd);
+#endif
+
+
+#ifdef XWIN_MULTIWINDOW
+/*
+ * winmultiwindowwndproc.c
+ */
+
+LRESULT CALLBACK
+winTopLevelWindowProc (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam);
+#endif
+
+
+/*
+ * wintrayicon.c
+ */
+
+void
+winInitNotifyIcon (winPrivScreenPtr pScreenPriv);
+
+void
+winDeleteNotifyIcon (winPrivScreenPtr pScreenPriv);
+
+LRESULT
+winHandleIconMessage (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam,
+ winPrivScreenPtr pScreenPriv);
+
+
+/*
+ * winwndproc.c
+ */
+
+LRESULT CALLBACK
+winWindowProc (HWND hWnd, UINT message,
+ WPARAM wParam, LPARAM lParam);
+
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+/*
+ * winwin32rootless.c
+ */
+
+Bool
+winMWExtWMCreateFrame (RootlessWindowPtr pFrame, ScreenPtr pScreen,
+ int newX, int newY, RegionPtr pShape);
+
+void
+winMWExtWMDestroyFrame (RootlessFrameID wid);
+
+void
+winMWExtWMMoveFrame (RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY);
+
+void
+winMWExtWMResizeFrame (RootlessFrameID wid, ScreenPtr pScreen,
+ int newX, int newY, unsigned int newW, unsigned int newH,
+ unsigned int gravity);
+
+void
+winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid);
+
+void
+winMWExtWMReshapeFrame (RootlessFrameID wid, RegionPtr pShape);
+
+void
+winMWExtWMUnmapFrame (RootlessFrameID wid);
+
+void
+winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow);
+
+void
+winMWExtWMStopDrawing (RootlessFrameID wid, Bool flush);
+
+void
+winMWExtWMUpdateRegion (RootlessFrameID wid, RegionPtr pDamage);
+
+void
+winMWExtWMDamageRects (RootlessFrameID wid, int count, const BoxRec *rects,
+ int shift_x, int shift_y);
+
+void
+winMWExtWMRootlessSwitchWindow (RootlessWindowPtr pFrame, WindowPtr oldWin);
+
+void
+winMWExtWMCopyBytes (unsigned int width, unsigned int height,
+ const void *src, unsigned int srcRowBytes,
+ void *dst, unsigned int dstRowBytes);
+
+void
+winMWExtWMFillBytes (unsigned int width, unsigned int height, unsigned int value,
+ void *dst, unsigned int dstRowBytes);
+
+int
+winMWExtWMCompositePixels (unsigned int width, unsigned int height, unsigned int function,
+ void *src[2], unsigned int srcRowBytes[2],
+ void *mask, unsigned int maskRowBytes,
+ void *dst[2], unsigned int dstRowBytes[2]);
+
+void
+winMWExtWMCopyWindow (RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
+ int dx, int dy);
+#endif
+
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+/*
+ * winwin32rootlesswindow.c
+ */
+
+void
+winMWExtWMReorderWindows (ScreenPtr pScreen);
+
+void
+winMWExtWMMoveXWindow (WindowPtr pWin, int x, int y);
+
+void
+winMWExtWMResizeXWindow (WindowPtr pWin, int w, int h);
+
+void
+winMWExtWMMoveResizeXWindow (WindowPtr pWin, int x, int y, int w, int h);
+
+void
+winMWExtWMUpdateIcon (Window id);
+
+void
+winMWExtWMUpdateWindowDecoration (win32RootlessWindowPtr pRLWinPriv,
+ winScreenInfoPtr pScreenInfo);
+
+wBOOL CALLBACK
+winMWExtWMDecorateWindow (HWND hwnd, LPARAM lParam);
+
+Bool
+winIsInternalWMRunning (winScreenInfoPtr pScreenInfo);
+
+void
+winMWExtWMRestackWindows (ScreenPtr pScreen);
+#endif
+
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+/*
+ * winwin32rootlesswndproc.c
+ */
+
+LRESULT CALLBACK
+winMWExtWMWindowProc (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam);
+#endif
+
+
+/*
+ * winwindowswm.c
+ */
+
+void
+winWindowsWMSendEvent (int type, unsigned int mask, int which, int arg,
+ Window window, int x, int y, int w, int h);
+
+void
+winWindowsWMExtensionInit (void);
+
+/*
+ * wincursor.c
+ */
+
+Bool
+winInitCursor (ScreenPtr pScreen);
+
+/*
+ * END DDX and DIX Function Prototypes
+ */
+
+#endif /* _WIN_H_ */
+
diff --git a/nx-X11/programs/Xserver/hw/xwin/winallpriv.c b/nx-X11/programs/Xserver/hw/xwin/winallpriv.c
new file mode 100644
index 000000000..7b4814b9b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winallpriv.c
@@ -0,0 +1,185 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Keith Packard, MIT X Consortium
+ * Harold L Hunt II
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winallpriv.c,v 1.11 2002/10/17 08:18:21 alanh Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/* See Porting Layer Definition - p. 58 */
+/*
+ * Allocate indexes for the privates that we use.
+ * Allocate memory directly for the screen privates.
+ * Reserve space in GCs and Pixmaps for our privates.
+ * Colormap privates are handled in winAllocateCmapPrivates ()
+ */
+
+Bool
+winAllocatePrivates (ScreenPtr pScreen)
+{
+ winPrivScreenPtr pScreenPriv;
+
+#if CYGDEBUG
+ winDebug ("winAllocateScreenPrivates - g_ulServerGeneration: %d "
+ "serverGeneration: %d\n",
+ g_ulServerGeneration, serverGeneration);
+#endif
+
+ /* We need a new slot for our privates if the screen gen has changed */
+ if (g_ulServerGeneration != serverGeneration)
+ {
+ /* Get an index that we can store our privates at */
+ g_iScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ g_iGCPrivateIndex = AllocateGCPrivateIndex ();
+ g_iPixmapPrivateIndex = AllocatePixmapPrivateIndex ();
+ g_iWindowPrivateIndex = AllocateWindowPrivateIndex ();
+
+ g_ulServerGeneration = serverGeneration;
+ }
+
+ /* Allocate memory for the screen private structure */
+ pScreenPriv = (winPrivScreenPtr) malloc (sizeof (winPrivScreenRec));
+ if (!pScreenPriv)
+ {
+ ErrorF ("winAllocateScreenPrivates - malloc () failed\n");
+ return FALSE;
+ }
+
+ /* Initialize the memory of the private structure */
+ ZeroMemory (pScreenPriv, sizeof (winPrivScreenRec));
+
+ /* Intialize private structure members */
+ pScreenPriv->fActive = TRUE;
+
+ /* Save the screen private pointer */
+ winSetScreenPriv (pScreen, pScreenPriv);
+
+ /* Reserve GC memory for our privates */
+ if (!AllocateGCPrivate (pScreen, g_iGCPrivateIndex,
+ sizeof (winPrivGCRec)))
+ {
+ ErrorF ("winAllocatePrivates - AllocateGCPrivate () failed\n");
+ return FALSE;
+ }
+
+ /* Reserve Pixmap memory for our privates */
+ if (!AllocatePixmapPrivate (pScreen, g_iPixmapPrivateIndex,
+ sizeof (winPrivPixmapRec)))
+ {
+ ErrorF ("winAllocatePrivates - AllocatePixmapPrivates () failed\n");
+ return FALSE;
+ }
+
+ /* Reserve Window memory for our privates */
+ if (!AllocateWindowPrivate (pScreen, g_iWindowPrivateIndex,
+ sizeof (winPrivWinRec)))
+ {
+ ErrorF ("winAllocatePrivates () - AllocateWindowPrivates () failed\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap privates may be allocated after the default colormap has
+ * already been created for some screens. This initialization procedure
+ * is called for each default colormap that is found.
+ */
+
+Bool
+winInitCmapPrivates (ColormapPtr pcmap, int index)
+{
+#if CYGDEBUG
+ winDebug ("winInitCmapPrivates\n");
+#endif
+
+ /*
+ * I see no way that this function can do anything useful
+ * with only a ColormapPtr. We don't have the index for
+ * our dev privates yet, so we can't really initialize
+ * anything. Perhaps I am misunderstanding the purpose
+ * of this function.
+ */
+ /* That's definitely true.
+ * I therefore changed the API and added the index as argument.
+ */
+ return TRUE;
+}
+
+
+/*
+ * Allocate memory for our colormap privates
+ */
+
+Bool
+winAllocateCmapPrivates (ColormapPtr pCmap)
+{
+ winPrivCmapPtr pCmapPriv;
+ static unsigned long s_ulPrivateGeneration = 0;
+
+#if CYGDEBUG
+ winDebug ("winAllocateCmapPrivates\n");
+#endif
+
+ /* Get a new privates index when the server generation changes */
+ if (s_ulPrivateGeneration != serverGeneration)
+ {
+ /* Get an index that we can store our privates at */
+ g_iCmapPrivateIndex = AllocateColormapPrivateIndex (winInitCmapPrivates);
+
+ /* Save the new server generation */
+ s_ulPrivateGeneration = serverGeneration;
+ }
+
+ /* Allocate memory for our private structure */
+ pCmapPriv = (winPrivCmapPtr) malloc (sizeof (winPrivCmapRec));
+ if (!pCmapPriv)
+ {
+ ErrorF ("winAllocateCmapPrivates - malloc () failed\n");
+ return FALSE;
+ }
+
+ /* Initialize the memory of the private structure */
+ ZeroMemory (pCmapPriv, sizeof (winPrivCmapRec));
+
+ /* Save the cmap private pointer */
+ winSetCmapPriv (pCmap, pCmapPriv);
+
+#if CYGDEBUG
+ winDebug ("winAllocateCmapPrivates - Returning\n");
+#endif
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winauth.c b/nx-X11/programs/Xserver/hw/xwin/winauth.c
new file mode 100644
index 000000000..3d24ef426
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winauth.c
@@ -0,0 +1,132 @@
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#if defined(XCSECURITY)
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#include "win.h"
+
+/* Includes for authorization */
+#include "X11/Xauth.h"
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#include <X11/extensions/securstr.h>
+
+
+/*
+ * Constants
+ */
+
+#define AUTH_NAME "MIT-MAGIC-COOKIE-1"
+
+
+/*
+ * Globals
+ */
+
+XID g_authId = 0;
+unsigned int g_uiAuthDataLen = 0;
+char *g_pAuthData = NULL;
+
+
+/*
+ * Generate authorization cookie for internal server clients
+ */
+
+Bool
+winGenerateAuthorization ()
+{
+ Bool fFreeAuth = FALSE;
+ SecurityAuthorizationPtr pAuth = NULL;
+
+ /* Call OS layer to generate authorization key */
+ g_authId = GenerateAuthorization (strlen (AUTH_NAME),
+ AUTH_NAME,
+ 0,
+ NULL,
+ &g_uiAuthDataLen,
+ &g_pAuthData);
+ if ((XID) ~0L == g_authId)
+ {
+ ErrorF ("winGenerateAuthorization - GenerateAuthorization failed\n");
+ goto auth_bailout;
+ }
+#if 0
+ else
+ {
+ ErrorF ("winGenerateAuthorization - GenerateAuthorization success!\n"
+ "AuthDataLen: %d AuthData: %s\n",
+ g_uiAuthDataLen, g_pAuthData);
+ }
+#endif
+
+ /* Allocate structure for additional auth information */
+ pAuth = (SecurityAuthorizationPtr)
+ xalloc (sizeof (SecurityAuthorizationRec));
+ if (!(pAuth))
+ {
+ ErrorF ("winGenerateAuthorization - Failed allocating "
+ "SecurityAuthorizationPtr.\n");
+ goto auth_bailout;
+ }
+
+ /* Fill in the auth fields */
+ pAuth->id = g_authId;
+ pAuth->timeout = 0; /* live for x seconds after refcnt == 0 */
+ pAuth->group = None;
+ pAuth->trustLevel = XSecurityClientTrusted;
+ pAuth->refcnt = 1; /* this auth must stick around */
+ pAuth->secondsRemaining = 0;
+ pAuth->timer = NULL;
+ pAuth->eventClients = NULL;
+
+ /* Add the authorization to the server's auth list */
+ if (!AddResource (g_authId,
+ SecurityAuthorizationResType,
+ pAuth))
+ {
+ ErrorF ("winGenerateAuthorization - AddResource failed for auth.\n");
+ fFreeAuth = TRUE;
+ goto auth_bailout;
+ }
+
+ /* Don't free the auth data, since it is still used internally */
+ pAuth = NULL;
+
+ return TRUE;
+
+ auth_bailout:
+ if (fFreeAuth)
+ xfree (pAuth);
+
+ return FALSE;
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/winblock.c b/nx-X11/programs/Xserver/hw/xwin/winblock.c
new file mode 100644
index 000000000..abea60e0f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winblock.c
@@ -0,0 +1,106 @@
+/*
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winmsg.h"
+
+
+/*
+ * References to external symbols
+ */
+
+extern HWND g_hDlgDepthChange;
+extern HWND g_hDlgExit;
+extern HWND g_hDlgAbout;
+
+
+/* See Porting Layer Definition - p. 6 */
+void
+winBlockHandler (int nScreen,
+ pointer pBlockData,
+ pointer pTimeout,
+ pointer pReadMask)
+{
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ winScreenPriv((ScreenPtr)pBlockData);
+#endif
+ MSG msg;
+#ifndef HAS_DEVWINDOWS
+ struct timeval **tvp = pTimeout;
+ if (*tvp != NULL)
+ {
+ (*tvp)->tv_sec = 0;
+ (*tvp)->tv_usec = 100;
+ }
+#endif
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ /* Signal threaded modules to begin */
+ if (pScreenPriv != NULL && !pScreenPriv->fServerStarted)
+ {
+ int iReturn;
+
+ winDebug ("winBlockHandler - Releasing pmServerStarted\n");
+
+ /* Flag that modules are to be started */
+ pScreenPriv->fServerStarted = TRUE;
+
+ /* Unlock the mutex for threaded modules */
+ iReturn = pthread_mutex_unlock (&pScreenPriv->pmServerStarted);
+ if (iReturn != 0)
+ {
+ ErrorF ("winBlockHandler - pthread_mutex_unlock () failed: %d\n",
+ iReturn);
+ goto winBlockHandler_ProcessMessages;
+ }
+
+ winDebug ("winBlockHandler - pthread_mutex_unlock () returned\n");
+ }
+
+winBlockHandler_ProcessMessages:
+#endif
+
+ /* Process all messages on our queue */
+ while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ if ((g_hDlgDepthChange == 0
+ || !IsDialogMessage (g_hDlgDepthChange, &msg))
+ && (g_hDlgExit == 0
+ || !IsDialogMessage (g_hDlgExit, &msg))
+ && (g_hDlgAbout == 0
+ || !IsDialogMessage (g_hDlgAbout, &msg)))
+ {
+ DispatchMessage (&msg);
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winclip.c b/nx-X11/programs/Xserver/hw/xwin/winclip.c
new file mode 100644
index 000000000..aab7d632d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winclip.c
@@ -0,0 +1,42 @@
+/*
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+/* Look at mfb/mfbclip.c for sample implementation */
+RegionPtr
+winPixmapToRegionNativeGDI (PixmapPtr pPix)
+{
+ ErrorF ("winPixmapToRegion()\n");
+ return NULL;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winclipboard.h b/nx-X11/programs/Xserver/hw/xwin/winclipboard.h
new file mode 100644
index 000000000..445c01b27
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winclipboard.h
@@ -0,0 +1,164 @@
+#ifndef _WINCLIPBOARD_H_
+#define _WINCLIPBOARD_H_
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+/* Standard library headers */
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#ifdef __CYGWIN__
+#include <sys/select.h>
+#else
+#include "Xwinsock.h"
+#define HAS_WINSOCK
+#endif
+#include <fcntl.h>
+#include <setjmp.h>
+#include <pthread.h>
+
+/* X headers */
+#include <X11/X.h>
+#include <X11/Xatom.h>
+/* NOTE: For some unknown reason, including Xproto.h solves
+ * tons of problems with including windows.h. Unknowns reasons
+ * are usually bad, so someone should investigate this.
+ */
+#include <X11/Xproto.h>
+#include "X11/Xutil.h"
+#include "X11/Xlocale.h"
+
+/* Fixups to prevent collisions between Windows and X headers */
+#define ATOM DWORD
+
+#ifndef __CYGWIN__
+#define sleep(x) Sleep (1000 * (x))
+#endif
+
+/* Windows headers */
+#ifndef XFree86Server
+#define XFree86Server
+#endif
+#include <windows.h>
+#undef XFree86Server
+
+
+/* Clipboard module constants */
+#define WIN_CLIPBOARD_WINDOW_CLASS "xwinclip"
+#define WIN_CLIPBOARD_WINDOW_TITLE "xwinclip"
+#ifdef HAS_DEVWINDOWS
+# define WIN_MSG_QUEUE_FNAME "/dev/windows"
+#endif
+#define WIN_CONNECT_RETRIES 40
+#define WIN_CONNECT_DELAY 4
+#define WIN_JMP_OKAY 0
+#define WIN_JMP_ERROR_IO 2
+#define WIN_LOCAL_PROPERTY "CYGX_CUT_BUFFER"
+#define WIN_XEVENTS_SUCCESS 0
+#define WIN_XEVENTS_SHUTDOWN 1
+#define WIN_XEVENTS_CONVERT 2
+#define WIN_XEVENTS_NOTIFY 3
+
+#define WM_WM_REINIT (WM_USER + 1)
+
+/*
+ * References to external symbols
+ */
+
+extern char *display;
+extern void ErrorF (const char* /*f*/, ...);
+extern void winDebug (const char *format, ...);
+extern void winErrorFVerb (int verb, const char *format, ...);
+
+
+/*
+ * winclipboardinit.c
+ */
+
+Bool
+winInitClipboard (void);
+
+HWND
+winClipboardCreateMessagingWindow (void);
+
+
+/*
+ * winclipboardtextconv.c
+ */
+
+void
+winClipboardDOStoUNIX (char *pszData, int iLength);
+
+void
+winClipboardUNIXtoDOS (unsigned char **ppszData, int iLength);
+
+
+/*
+ * winclipboardthread.c
+ */
+
+void *
+winClipboardProc (void *);
+
+void
+winDeinitClipboard (void);
+
+
+/*
+ * winclipboardunicode.c
+ */
+
+Bool
+winClipboardDetectUnicodeSupport (void);
+
+
+/*
+ * winclipboardwndproc.c
+ */
+
+BOOL
+winClipboardFlushWindowsMessageQueue (HWND hwnd);
+
+LRESULT CALLBACK
+winClipboardWindowProc (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam);
+
+
+/*
+ * winclipboardxevents.c
+ */
+
+int
+winClipboardFlushXEvents (HWND hwnd,
+ int iWindow,
+ Display *pDisplay,
+ Bool fUnicodeSupport);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/winclipboardinit.c b/nx-X11/programs/Xserver/hw/xwin/winclipboardinit.c
new file mode 100644
index 000000000..6a0cbaf2c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winclipboardinit.c
@@ -0,0 +1,143 @@
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "dixstruct.h"
+#include "winclipboard.h"
+
+
+/*
+ * Local typedefs
+ */
+
+typedef int (*winDispatchProcPtr) (ClientPtr);
+
+DISPATCH_PROC(winProcSetSelectionOwner);
+
+
+/*
+ * References to external symbols
+ */
+
+extern pthread_t g_ptClipboardProc;
+extern winDispatchProcPtr winProcSetSelectionOwnerOrig;
+extern Bool g_fClipboard;
+extern HWND g_hwndClipboard;
+
+
+/*
+ * Intialize the Clipboard module
+ */
+
+Bool
+winInitClipboard ()
+{
+ ErrorF ("winInitClipboard ()\n");
+
+ /* Wrap some internal server functions */
+ if (ProcVector[X_SetSelectionOwner] != winProcSetSelectionOwner)
+ {
+ winProcSetSelectionOwnerOrig = ProcVector[X_SetSelectionOwner];
+ ProcVector[X_SetSelectionOwner] = winProcSetSelectionOwner;
+ }
+
+ /* Spawn a thread for the Clipboard module */
+ if (pthread_create (&g_ptClipboardProc,
+ NULL,
+ winClipboardProc,
+ NULL))
+ {
+ /* Bail if thread creation failed */
+ ErrorF ("winInitClipboard - pthread_create failed.\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Create the Windows window that we use to recieve Windows messages
+ */
+
+HWND
+winClipboardCreateMessagingWindow ()
+{
+ WNDCLASS wc;
+ HWND hwnd;
+
+ /* Setup our window class */
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = winClipboardWindowProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = GetModuleHandle (NULL);
+ wc.hIcon = 0;
+ wc.hCursor = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = WIN_CLIPBOARD_WINDOW_CLASS;
+ RegisterClass (&wc);
+
+ /* Create the window */
+ hwnd = CreateWindowExA (0, /* Extended styles */
+ WIN_CLIPBOARD_WINDOW_CLASS,/* Class name */
+ WIN_CLIPBOARD_WINDOW_TITLE,/* Window name */
+ WS_OVERLAPPED, /* Not visible anyway */
+ CW_USEDEFAULT, /* Horizontal position */
+ CW_USEDEFAULT, /* Vertical position */
+ CW_USEDEFAULT, /* Right edge */
+ CW_USEDEFAULT, /* Bottom edge */
+ (HWND) NULL, /* No parent or owner window */
+ (HMENU) NULL, /* No menu */
+ GetModuleHandle (NULL),/* Instance handle */
+ NULL); /* Creation data */
+ assert (hwnd != NULL);
+
+ /* I'm not sure, but we may need to call this to start message processing */
+ ShowWindow (hwnd, SW_HIDE);
+
+ /* Similarly, we may need a call to this even though we don't paint */
+ UpdateWindow (hwnd);
+
+ return hwnd;
+}
+
+void
+winFixClipboardChain (void)
+{
+ if (g_fClipboard
+ && g_hwndClipboard)
+ {
+ PostMessage (g_hwndClipboard, WM_WM_REINIT, 0, 0);
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winclipboardtextconv.c b/nx-X11/programs/Xserver/hw/xwin/winclipboardtextconv.c
new file mode 100644
index 000000000..fd2e696c3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winclipboardtextconv.c
@@ -0,0 +1,159 @@
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+void
+winClipboardDOStoUNIX (char *pszSrc, int iLength);
+void
+winClipboardUNIXtoDOS (unsigned char **ppszData, int iLength);
+
+/*
+ * Convert \r\n to \n
+ *
+ * NOTE: This was heavily inspired by, Cygwin's
+ * winsup/cygwin/fhandler.cc/fhandler_base::read ()
+ */
+
+void
+winClipboardDOStoUNIX (char *pszSrc, int iLength)
+{
+ char *pszDest = pszSrc;
+ char *pszEnd = pszSrc + iLength;
+
+ /* Loop until the last character */
+ while (pszSrc < pszEnd)
+ {
+ /* Copy the current source character to current destination character */
+ *pszDest = *pszSrc;
+
+ /* Advance to the next source character */
+ pszSrc++;
+
+ /* Don't advance the destination character if we need to drop an \r */
+ if (*pszDest != '\r' || *pszSrc != '\n')
+ pszDest++;
+ }
+
+ /* Move the terminating null */
+ *pszDest = '\0';
+}
+
+
+/*
+ * Convert \n to \r\n
+ */
+
+void
+winClipboardUNIXtoDOS (unsigned char **ppszData, int iLength)
+{
+ int iNewlineCount = 0;
+ unsigned char *pszSrc = *ppszData;
+ unsigned char *pszEnd = pszSrc + iLength;
+ unsigned char *pszDest = NULL, *pszDestBegin = NULL;
+
+#if 0
+ ErrorF ("UNIXtoDOS () - Original data:\n%s\n", *ppszData);
+#endif
+
+ /* Count \n characters without leading \r */
+ while (pszSrc < pszEnd)
+ {
+ /* Skip ahead two character if found set of \r\n */
+ if (*pszSrc == '\r' && pszSrc + 1 < pszEnd && *(pszSrc + 1) == '\n')
+ {
+ pszSrc += 2;
+ continue;
+ }
+
+ /* Increment the count if found naked \n */
+ if (*pszSrc == '\n')
+ {
+ iNewlineCount++;
+ }
+
+ pszSrc++;
+ }
+
+ /* Return if no naked \n's */
+ if (iNewlineCount == 0)
+ return;
+
+ /* Allocate a new string */
+ pszDestBegin = pszDest = malloc (iLength + iNewlineCount + 1);
+
+ /* Set source pointer to beginning of data string */
+ pszSrc = *ppszData;
+
+ /* Loop through all characters in source string */
+ while (pszSrc < pszEnd)
+ {
+ /* Copy line endings that are already valid */
+ if (*pszSrc == '\r' && pszSrc + 1 < pszEnd && *(pszSrc + 1) == '\n')
+ {
+ *pszDest = *pszSrc;
+ *(pszDest + 1) = *(pszSrc + 1);
+ pszDest += 2;
+ pszSrc += 2;
+ continue;
+ }
+
+ /* Add \r to naked \n's */
+ if (*pszSrc == '\n')
+ {
+ *pszDest = '\r';
+ *(pszDest + 1) = *pszSrc;
+ pszDest += 2;
+ pszSrc += 1;
+ continue;
+ }
+
+ /* Copy normal characters */
+ *pszDest = *pszSrc;
+ pszSrc++;
+ pszDest++;
+ }
+
+ /* Put terminating null at end of new string */
+ *pszDest = '\0';
+
+ /* Swap string pointers */
+ free (*ppszData);
+ *ppszData = pszDestBegin;
+
+#if 0
+ ErrorF ("UNIXtoDOS () - Final string:\n%s\n", pszDestBegin);
+#endif
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winclipboardthread.c b/nx-X11/programs/Xserver/hw/xwin/winclipboardthread.c
new file mode 100644
index 000000000..081abd5e7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winclipboardthread.c
@@ -0,0 +1,477 @@
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include <sys/types.h>
+#include "winclipboard.h"
+#ifdef __CYGWIN__
+#include <errno.h>
+#endif
+#include "X11/Xauth.h"
+
+
+/*
+ * Constants
+ */
+
+#define AUTH_NAME "MIT-MAGIC-COOKIE-1"
+
+
+/*
+ * References to external symbols
+ */
+
+extern Bool g_fUnicodeClipboard;
+extern unsigned long serverGeneration;
+#if defined(XCSECURITY)
+extern unsigned int g_uiAuthDataLen;
+extern char *g_pAuthData;
+#endif
+extern Bool g_fClipboardStarted;
+extern HWND g_hwndClipboard;
+extern void *g_pClipboardDisplay;
+extern Window g_iClipboardWindow;
+
+
+/*
+ * Global variables
+ */
+
+static jmp_buf g_jmpEntry;
+Bool g_fUnicodeSupport = FALSE;
+Bool g_fUseUnicode = FALSE;
+
+
+/*
+ * Local function prototypes
+ */
+
+static int
+winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr);
+
+static int
+winClipboardIOErrorHandler (Display *pDisplay);
+
+
+/*
+ * Main thread function
+ */
+
+void *
+winClipboardProc (void *pvNotUsed)
+{
+ Atom atomClipboard, atomClipboardManager;
+ int iReturn;
+ HWND hwnd = NULL;
+ int iConnectionNumber = 0;
+#ifdef HAS_DEVWINDOWS
+ int fdMessageQueue = 0;
+#else
+ struct timeval tvTimeout;
+#endif
+ fd_set fdsRead;
+ int iMaxDescriptor;
+ Display *pDisplay = NULL;
+ Window iWindow = None;
+ int iRetries;
+ Bool fUseUnicode;
+ char szDisplay[512];
+ int iSelectError;
+
+ ErrorF ("winClipboardProc - Hello\n");
+
+ /* Do we have Unicode support? */
+ g_fUnicodeSupport = winClipboardDetectUnicodeSupport ();
+
+ /* Do we use Unicode clipboard? */
+ fUseUnicode = g_fUnicodeClipboard && g_fUnicodeSupport;
+
+ /* Save the Unicode support flag in a global */
+ g_fUseUnicode = fUseUnicode;
+
+ /* Allow multiple threads to access Xlib */
+ if (XInitThreads () == 0)
+ {
+ ErrorF ("winClipboardProc - XInitThreads failed.\n");
+ pthread_exit (NULL);
+ }
+
+ /* See if X supports the current locale */
+ if (XSupportsLocale () == False)
+ {
+ ErrorF ("winClipboardProc - Locale not supported by X. Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ /* Set jump point for Error exits */
+ iReturn = setjmp (g_jmpEntry);
+
+ /* Check if we should continue operations */
+ if (iReturn != WIN_JMP_ERROR_IO
+ && iReturn != WIN_JMP_OKAY)
+ {
+ /* setjmp returned an unknown value, exit */
+ ErrorF ("winClipboardProc - setjmp returned: %d exiting\n",
+ iReturn);
+ pthread_exit (NULL);
+ }
+ else if (iReturn == WIN_JMP_ERROR_IO)
+ {
+ /* TODO: Cleanup the Win32 window and free any allocated memory */
+ ErrorF ("winClipboardProc - setjmp returned for IO Error Handler.\n");
+ pthread_exit (NULL);
+ }
+
+#if defined(XCSECURITY)
+ /* Use our generated cookie for authentication */
+ XSetAuthorization (AUTH_NAME,
+ strlen (AUTH_NAME),
+ g_pAuthData,
+ g_uiAuthDataLen);
+#endif
+
+ /* Set error handler */
+ XSetErrorHandler (winClipboardErrorHandler);
+ XSetIOErrorHandler (winClipboardIOErrorHandler);
+
+ /* Initialize retry count */
+ iRetries = 0;
+
+ /* Setup the display connection string x */
+ /*
+ * NOTE: Always connect to screen 0 since we require that screen
+ * numbers start at 0 and increase without gaps. We only need
+ * to connect to one screen on the display to get events
+ * for all screens on the display. That is why there is only
+ * one clipboard client thread.
+ */
+ snprintf (szDisplay,
+ 512,
+ "127.0.0.1:%s.0",
+ display);
+
+ /* Print the display connection string */
+ ErrorF ("winClipboardProc - DISPLAY=%s\n", szDisplay);
+
+ /* Open the X display */
+ do
+ {
+ pDisplay = XOpenDisplay (szDisplay);
+ if (pDisplay == NULL)
+ {
+ ErrorF ("winClipboardProc - Could not open display, "
+ "try: %d, sleeping: %d\n",
+ iRetries + 1, WIN_CONNECT_DELAY);
+ ++iRetries;
+ sleep (WIN_CONNECT_DELAY);
+ continue;
+ }
+ else
+ break;
+ }
+ while (pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES);
+
+ /* Make sure that the display opened */
+ if (pDisplay == NULL)
+ {
+ ErrorF ("winClipboardProc - Failed opening the display, giving up\n");
+ pthread_exit (NULL);
+ }
+
+ /* Save the display in the screen privates */
+ g_pClipboardDisplay = pDisplay;
+
+ ErrorF ("winClipboardProc - XOpenDisplay () returned and "
+ "successfully opened the display.\n");
+
+ /* Get our connection number */
+ iConnectionNumber = ConnectionNumber (pDisplay);
+
+#ifdef HAS_DEVWINDOWS
+ /* Open a file descriptor for the windows message queue */
+ fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, O_RDONLY);
+ if (fdMessageQueue == -1)
+ {
+ ErrorF ("winClipboardProc - Failed opening %s\n", WIN_MSG_QUEUE_FNAME);
+ pthread_exit (NULL);
+ }
+
+ /* Find max of our file descriptors */
+ iMaxDescriptor = max (fdMessageQueue, iConnectionNumber) + 1;
+#else
+ iMaxDescriptor = iConnectionNumber + 1;
+#endif
+
+ /* Select event types to watch */
+ if (XSelectInput (pDisplay,
+ DefaultRootWindow (pDisplay),
+ SubstructureNotifyMask |
+ StructureNotifyMask |
+ PropertyChangeMask) == BadWindow)
+ ErrorF ("winClipboardProc - XSelectInput generated BadWindow "
+ "on RootWindow\n\n");
+
+ /* Create atoms */
+ atomClipboard = XInternAtom (pDisplay, "CLIPBOARD", False);
+ atomClipboardManager = XInternAtom (pDisplay, "CLIPBOARD_MANAGER", False);
+
+ /* Create a messaging window */
+ iWindow = XCreateSimpleWindow (pDisplay,
+ DefaultRootWindow (pDisplay),
+ 1, 1,
+ 500, 500,
+ 0,
+ BlackPixel (pDisplay, 0),
+ BlackPixel (pDisplay, 0));
+ if (iWindow == 0)
+ {
+ ErrorF ("winClipboardProc - Could not create an X window.\n");
+ pthread_exit (NULL);
+ }
+
+ /* Save the window in the screen privates */
+ g_iClipboardWindow = iWindow;
+
+ /* Create Windows messaging window */
+ hwnd = winClipboardCreateMessagingWindow ();
+
+ /* Save copy of HWND in screen privates */
+ g_hwndClipboard = hwnd;
+
+ /* Assert ownership of selections if Win32 clipboard is owned */
+ if (NULL != GetClipboardOwner ())
+ {
+ /* PRIMARY */
+ iReturn = XSetSelectionOwner (pDisplay, XA_PRIMARY,
+ iWindow, CurrentTime);
+ if (iReturn == BadAtom || iReturn == BadWindow)
+ {
+ ErrorF ("winClipboardProc - Could not set PRIMARY owner\n");
+ pthread_exit (NULL);
+ }
+
+ /* CLIPBOARD */
+ iReturn = XSetSelectionOwner (pDisplay, atomClipboard,
+ iWindow, CurrentTime);
+ if (iReturn == BadAtom || iReturn == BadWindow)
+ {
+ ErrorF ("winClipboardProc - Could not set CLIPBOARD owner\n");
+ pthread_exit (NULL);
+ }
+ }
+
+ /* Pre-flush X events */
+ /*
+ * NOTE: Apparently you'll freeze if you don't do this,
+ * because there may be events in local data structures
+ * already.
+ */
+ winClipboardFlushXEvents (hwnd,
+ iWindow,
+ pDisplay,
+ fUseUnicode);
+
+ /* Pre-flush Windows messages */
+ if (!winClipboardFlushWindowsMessageQueue (hwnd))
+ return 0;
+
+ /* Signal that the clipboard client has started */
+ g_fClipboardStarted = TRUE;
+
+ /* Loop for X events */
+ while (1)
+ {
+ /* Setup the file descriptor set */
+ /*
+ * NOTE: You have to do this before every call to select
+ * because select modifies the mask to indicate
+ * which descriptors are ready.
+ */
+ FD_ZERO (&fdsRead);
+ FD_SET (iConnectionNumber, &fdsRead);
+#ifdef HAS_DEVWINDOWS
+ FD_SET (fdMessageQueue, &fdsRead);
+#else
+ tvTimeout.tv_sec = 0;
+ tvTimeout.tv_usec = 100;
+#endif
+
+ /* Wait for a Windows event or an X event */
+ iReturn = select (iMaxDescriptor, /* Highest fds number */
+ &fdsRead, /* Read mask */
+ NULL, /* No write mask */
+ NULL, /* No exception mask */
+#ifdef HAS_DEVWINDOWS
+ NULL /* No timeout */
+#else
+ &tvTimeout /* Set timeout */
+#endif
+ );
+
+#ifndef HAS_WINSOCK
+ iSelectError = errno;
+#else
+ iSelectError = WSAGetLastError();
+#endif
+
+ if (iReturn < 0)
+ {
+#ifndef HAS_WINSOCK
+ if (iSelectError == EINTR)
+#else
+ if (iSelectError == WSAEINTR)
+#endif
+ continue;
+
+ ErrorF ("winClipboardProc - Call to select () failed: %d. "
+ "Bailing.\n", iReturn);
+ break;
+ }
+
+ /* Branch on which descriptor became active */
+ if (FD_ISSET (iConnectionNumber, &fdsRead))
+ {
+ /* Process X events */
+ /* Exit when we see that server is shutting down */
+ iReturn = winClipboardFlushXEvents (hwnd,
+ iWindow,
+ pDisplay,
+ fUseUnicode);
+ if (WIN_XEVENTS_SHUTDOWN == iReturn)
+ {
+ ErrorF ("winClipboardProc - winClipboardFlushXEvents "
+ "trapped shutdown event, exiting main loop.\n");
+ break;
+ }
+ }
+
+#ifdef HAS_DEVWINDOWS
+ /* Check for Windows event ready */
+ if (FD_ISSET (fdMessageQueue, &fdsRead))
+#else
+ if (1)
+#endif
+ {
+ /* Process Windows messages */
+ if (!winClipboardFlushWindowsMessageQueue (hwnd))
+ {
+ ErrorF ("winClipboardProc - "
+ "winClipboardFlushWindowsMessageQueue trapped "
+ "WM_QUIT message, exiting main loop.\n");
+ break;
+ }
+ }
+ }
+
+ /* Close our X window */
+ if (pDisplay && iWindow)
+ {
+ iReturn = XDestroyWindow (pDisplay, iWindow);
+ if (iReturn == BadWindow)
+ ErrorF ("winClipboardProc - XDestroyWindow returned BadWindow.\n");
+ else
+ ErrorF ("winClipboardProc - XDestroyWindow succeeded.\n");
+ }
+
+
+#ifdef HAS_DEVWINDOWS
+ /* Close our Win32 message handle */
+ if (fdMessageQueue)
+ close (fdMessageQueue);
+#endif
+
+#if 0
+ /*
+ * FIXME: XCloseDisplay hangs if we call it, as of 2004/03/26. The
+ * XSync and XSelectInput calls did not help.
+ */
+
+ /* Discard any remaining events */
+ XSync (pDisplay, TRUE);
+
+ /* Select event types to watch */
+ XSelectInput (pDisplay,
+ DefaultRootWindow (pDisplay),
+ None);
+
+ /* Close our X display */
+ if (pDisplay)
+ {
+ XCloseDisplay (pDisplay);
+ }
+#endif
+
+ g_iClipboardWindow = None;
+ g_pClipboardDisplay = NULL;
+ g_hwndClipboard = NULL;
+
+ return NULL;
+}
+
+
+/*
+ * winClipboardErrorHandler - Our application specific error handler
+ */
+
+static int
+winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr)
+{
+ char pszErrorMsg[100];
+
+ XGetErrorText (pDisplay,
+ pErr->error_code,
+ pszErrorMsg,
+ sizeof (pszErrorMsg));
+ ErrorF ("winClipboardErrorHandler - ERROR: \n\t%s\n"
+ "\tSerial: %d, Request Code: %d, Minor Code: %d\n",
+ pszErrorMsg,
+ pErr->serial,
+ pErr->request_code,
+ pErr->minor_code);
+ return 0;
+}
+
+
+/*
+ * winClipboardIOErrorHandler - Our application specific IO error handler
+ */
+
+static int
+winClipboardIOErrorHandler (Display *pDisplay)
+{
+ ErrorF ("\nwinClipboardIOErrorHandler!\n\n");
+
+ /* Restart at the main entry point */
+ longjmp (g_jmpEntry, WIN_JMP_ERROR_IO);
+
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winclipboardunicode.c b/nx-X11/programs/Xserver/hw/xwin/winclipboardunicode.c
new file mode 100644
index 000000000..ba86915a4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winclipboardunicode.c
@@ -0,0 +1,69 @@
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "winclipboard.h"
+
+
+/*
+ * Determine whether we suport Unicode or not.
+ * NOTE: Currently, just check if we are on an NT-based platform or not.
+ */
+
+Bool
+winClipboardDetectUnicodeSupport (void)
+{
+ Bool fReturn = FALSE;
+ OSVERSIONINFO osvi = {0};
+
+ /* Get operating system version information */
+ osvi.dwOSVersionInfoSize = sizeof (osvi);
+ GetVersionEx (&osvi);
+
+ /* Branch on platform ID */
+ switch (osvi.dwPlatformId)
+ {
+ case VER_PLATFORM_WIN32_NT:
+ /* Unicode supported on NT only */
+ ErrorF ("DetectUnicodeSupport - Windows NT/2000/XP\n");
+ fReturn = TRUE;
+ break;
+
+ case VER_PLATFORM_WIN32_WINDOWS:
+ /* Unicode is not supported on non-NT */
+ ErrorF ("DetectUnicodeSupport - Windows 95/98/Me\n");
+ fReturn = FALSE;
+ break;
+ }
+
+ return fReturn;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winclipboardwndproc.c b/nx-X11/programs/Xserver/hw/xwin/winclipboardwndproc.c
new file mode 100644
index 000000000..a006b46d3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winclipboardwndproc.c
@@ -0,0 +1,585 @@
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include <sys/types.h>
+#include <sys/time.h>
+#include "winclipboard.h"
+
+
+/*
+ * Constants
+ */
+
+#define WIN_CLIPBOARD_PROP "cyg_clipboard_prop"
+#define WIN_POLL_TIMEOUT 1
+
+
+/*
+ * References to external symbols
+ */
+
+extern Bool g_fUseUnicode;
+extern Bool g_fUnicodeSupport;
+extern void *g_pClipboardDisplay;
+extern Window g_iClipboardWindow;
+extern Atom g_atomLastOwnedSelection;
+
+
+/*
+ * Local function prototypes
+ */
+
+static Bool
+winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
+ Bool fUseUnicode, int iTimeoutSec);
+
+
+/*
+ * Process X events up to specified timeout
+ */
+
+static int
+winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
+ Bool fUseUnicode, int iTimeoutSec)
+{
+ int iConnNumber;
+ struct timeval tv;
+ int iReturn;
+ DWORD dwStopTime = (GetTickCount () / 1000) + iTimeoutSec;
+
+ /* We need to ensure that all pending events are processed */
+ XSync (pDisplay, FALSE);
+
+ /* Get our connection number */
+ iConnNumber = ConnectionNumber (pDisplay);
+
+ /* Loop for X events */
+ while (1)
+ {
+ fd_set fdsRead;
+
+ /* Setup the file descriptor set */
+ FD_ZERO (&fdsRead);
+ FD_SET (iConnNumber, &fdsRead);
+
+ /* Adjust timeout */
+ tv.tv_sec = dwStopTime - (GetTickCount () / 1000);
+ tv.tv_usec = 0;
+
+ /* Break out if no time left */
+ if (tv.tv_sec < 0)
+ return WIN_XEVENTS_SUCCESS;
+
+ /* Wait for a Windows event or an X event */
+ iReturn = select (iConnNumber + 1,/* Highest fds number */
+ &fdsRead, /* Read mask */
+ NULL, /* No write mask */
+ NULL, /* No exception mask */
+ &tv); /* No timeout */
+ if (iReturn <= 0)
+ {
+ ErrorF ("winProcessXEventsTimeout - Call to select () failed: %d. "
+ "Bailing.\n", iReturn);
+ break;
+ }
+
+ /* Branch on which descriptor became active */
+ if (FD_ISSET (iConnNumber, &fdsRead))
+ {
+ /* Process X events */
+ /* Exit when we see that server is shutting down */
+ iReturn = winClipboardFlushXEvents (hwnd,
+ iWindow,
+ pDisplay,
+ fUseUnicode);
+ if (WIN_XEVENTS_NOTIFY == iReturn
+ || WIN_XEVENTS_CONVERT == iReturn)
+ {
+ /* Bail out if convert or notify processed */
+ return iReturn;
+ }
+ }
+ }
+
+ return WIN_XEVENTS_SUCCESS;
+}
+
+
+/*
+ * Process a given Windows message
+ */
+
+LRESULT CALLBACK
+winClipboardWindowProc (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ static HWND s_hwndNextViewer;
+ static Bool s_fCBCInitialized;
+
+ /* Branch on message type */
+ switch (message)
+ {
+ case WM_DESTROY:
+ {
+ winDebug ("winClipboardWindowProc - WM_DESTROY\n");
+
+ /* Remove ourselves from the clipboard chain */
+ ChangeClipboardChain (hwnd, s_hwndNextViewer);
+
+ s_hwndNextViewer = NULL;
+
+ PostQuitMessage (0);
+ }
+ return 0;
+
+
+ case WM_CREATE:
+ {
+ winDebug ("winClipboardWindowProc - WM_CREATE\n");
+
+ /* Add ourselves to the clipboard viewer chain */
+ s_hwndNextViewer = SetClipboardViewer (hwnd);
+ if (s_hwndNextViewer == hwnd)
+ {
+ s_hwndNextViewer = NULL;
+ winErrorFVerb (1, "winClipboardWindowProc - WM_CREATE: "
+ "attempted to set next window to ourselves.");
+ }
+ }
+ return 0;
+
+
+ case WM_CHANGECBCHAIN:
+ {
+ static Bool s_fProcessingChangeCBChain = FALSE;
+ winDebug ("winClipboardWindowProc - WM_CHANGECBCHAIN: wParam(%x) "
+ "lParam(%x) s_hwndNextViewer(%x)\n",
+ wParam, lParam, s_hwndNextViewer);
+
+
+ /*
+ * We've occasionally seen a loop in the clipboard chain. Break
+ * it on the first hint of recursion.
+ */
+ if (! s_fProcessingChangeCBChain)
+ {
+ s_fProcessingChangeCBChain = TRUE;
+ }
+ else
+ {
+ winErrorFVerb (1, "winClipboardWindowProc - WM_CHANGECBCHAIN - "
+ "Nested calls detected. Bailing.\n");
+ winDebug ("winClipboardWindowProc - WM_CHANGECBCHAIN: Exit\n");
+ return 0;
+ }
+
+ if ((HWND) wParam == s_hwndNextViewer)
+ {
+ s_hwndNextViewer = (HWND) lParam;
+ if (s_hwndNextViewer == hwnd)
+ {
+ s_hwndNextViewer = NULL;
+ winErrorFVerb (1, "winClipboardWindowProc - WM_CHANGECBCHAIN: "
+ "attempted to set next window to ourselves.");
+ }
+ }
+ else if (s_hwndNextViewer)
+ SendMessage (s_hwndNextViewer, message,
+ wParam, lParam);
+
+ s_fProcessingChangeCBChain = FALSE;
+ }
+ winDebug ("winClipboardWindowProc - WM_CHANGECBCHAIN: Exit\n");
+ return 0;
+
+ case WM_WM_REINIT:
+ {
+ /* Ensure that we're in the clipboard chain. Some apps,
+ * WinXP's remote desktop for one, don't play nice with the
+ * chain. This message is called whenever we receive a
+ * WM_ACTIVATEAPP message to ensure that we continue to
+ * receive clipboard messages.
+ *
+ * It might be possible to detect if we're still in the chain
+ * by calling SendMessage (GetClipboardViewer(),
+ * WM_DRAWCLIPBOARD, 0, 0); and then seeing if we get the
+ * WM_DRAWCLIPBOARD message. That, however, might be more
+ * expensive than just putting ourselves back into the chain.
+ */
+
+ winDebug ("winClipboardWindowProc - WM_WM_REINIT: Enter\n");
+ if (hwnd != GetClipboardViewer ())
+ {
+ winDebug (" WM_WM_REINIT: Replacing us(%x) with %x at head "
+ "of chain\n", hwnd, s_hwndNextViewer);
+ s_fCBCInitialized = FALSE;
+ ChangeClipboardChain (hwnd, s_hwndNextViewer);
+ s_hwndNextViewer = NULL;
+ s_fCBCInitialized = FALSE;
+ winDebug (" WM_WM_REINIT: Putting us back at head of chain.\n");
+ s_hwndNextViewer = SetClipboardViewer (hwnd);
+ if (s_hwndNextViewer == hwnd)
+ {
+ s_hwndNextViewer = NULL;
+ winErrorFVerb (1, "winClipboardWindowProc - WM_WM_REINIT: "
+ "attempted to set next window to ourselves.\n");
+ }
+ }
+ else
+ {
+ winDebug (" WM_WM_REINIT: already at head of viewer chain.\n");
+ }
+ }
+ winDebug ("winClipboardWindowProc - WM_WM_REINIT: Exit\n");
+ return 0;
+
+
+ case WM_DRAWCLIPBOARD:
+ {
+ static Bool s_fProcessingDrawClipboard = FALSE;
+ Display *pDisplay = g_pClipboardDisplay;
+ Window iWindow = g_iClipboardWindow;
+ int iReturn;
+
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Enter\n");
+
+ /*
+ * We've occasionally seen a loop in the clipboard chain. Break
+ * it on the first hint of recursion.
+ */
+ if (! s_fProcessingDrawClipboard)
+ {
+ s_fProcessingDrawClipboard = TRUE;
+ }
+ else
+ {
+ winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Nested calls detected. Bailing.\n");
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
+ return 0;
+ }
+
+ /* Pass the message on the next window in the clipboard viewer chain */
+ if (s_hwndNextViewer)
+ SendMessage (s_hwndNextViewer, message, 0, 0);
+
+ /* Bail on first message */
+ if (!s_fCBCInitialized)
+ {
+ s_fCBCInitialized = TRUE;
+ s_fProcessingDrawClipboard = FALSE;
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
+ return 0;
+ }
+
+ /*
+ * NOTE: We cannot bail out when NULL == GetClipboardOwner ()
+ * because some applications deal with the clipboard in a manner
+ * that causes the clipboard owner to be NULL when they are in
+ * fact taking ownership. One example of this is the Win32
+ * native compile of emacs.
+ */
+
+ /* Bail when we still own the clipboard */
+ if (hwnd == GetClipboardOwner ())
+ {
+
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "We own the clipboard, returning.\n");
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
+ s_fProcessingDrawClipboard = FALSE;
+ return 0;
+ }
+
+ /*
+ * Do not take ownership of the X11 selections when something
+ * other than CF_TEXT or CF_UNICODETEXT has been copied
+ * into the Win32 clipboard.
+ */
+ if (!IsClipboardFormatAvailable (CF_TEXT)
+ && !IsClipboardFormatAvailable (CF_UNICODETEXT))
+ {
+
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Clipboard does not contain CF_TEXT nor "
+ "CF_UNICODETEXT.\n");
+
+ /*
+ * We need to make sure that the X Server has processed
+ * previous XSetSelectionOwner messages.
+ */
+ XSync (pDisplay, FALSE);
+
+ winDebug("winClipboardWindowProc - XSync done.\n");
+
+ /* Release PRIMARY selection if owned */
+ iReturn = XGetSelectionOwner (pDisplay, XA_PRIMARY);
+ if (iReturn == g_iClipboardWindow)
+ {
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "PRIMARY selection is owned by us.\n");
+ XSetSelectionOwner (pDisplay,
+ XA_PRIMARY,
+ None,
+ CurrentTime);
+ }
+ else if (BadWindow == iReturn || BadAtom == iReturn)
+ winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "XGetSelection failed for PRIMARY: %d\n", iReturn);
+
+ /* Release CLIPBOARD selection if owned */
+ iReturn = XGetSelectionOwner (pDisplay,
+ XInternAtom (pDisplay,
+ "CLIPBOARD",
+ False));
+ if (iReturn == g_iClipboardWindow)
+ {
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "CLIPBOARD selection is owned by us.\n");
+ XSetSelectionOwner (pDisplay,
+ XInternAtom (pDisplay,
+ "CLIPBOARD",
+ False),
+ None,
+ CurrentTime);
+ }
+ else if (BadWindow == iReturn || BadAtom == iReturn)
+ winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "XGetSelection failed for CLIPBOARD: %d\n", iReturn);
+
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
+ s_fProcessingDrawClipboard = FALSE;
+ return 0;
+ }
+
+ /* Reassert ownership of PRIMARY */
+ iReturn = XSetSelectionOwner (pDisplay,
+ XA_PRIMARY,
+ iWindow,
+ CurrentTime);
+ if (iReturn == BadAtom || iReturn == BadWindow)
+ {
+ winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Could not reassert ownership of PRIMARY\n");
+ }
+ else
+ {
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Reasserted ownership of PRIMARY\n");
+ }
+
+ /* Reassert ownership of the CLIPBOARD */
+ iReturn = XSetSelectionOwner (pDisplay,
+ XInternAtom (pDisplay,
+ "CLIPBOARD",
+ False),
+ iWindow,
+ CurrentTime);
+ if (iReturn == BadAtom || iReturn == BadWindow)
+ {
+ winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Could not reassert ownership of CLIPBOARD\n");
+ }
+ else
+ {
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Reasserted ownership of CLIPBOARD\n");
+ }
+
+ /* Flush the pending SetSelectionOwner event now */
+ XFlush (pDisplay);
+
+ s_fProcessingDrawClipboard = FALSE;
+ }
+ winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
+ return 0;
+
+
+ case WM_DESTROYCLIPBOARD:
+ /*
+ * NOTE: Intentionally do nothing.
+ * Changes in the Win32 clipboard are handled by WM_DRAWCLIPBOARD
+ * above. We only process this message to conform to the specs
+ * for delayed clipboard rendering in Win32. You might think
+ * that we need to release ownership of the X11 selections, but
+ * we do not, because a WM_DRAWCLIPBOARD message will closely
+ * follow this message and reassert ownership of the X11
+ * selections, handling the issue for us.
+ */
+ return 0;
+
+
+ case WM_RENDERFORMAT:
+ case WM_RENDERALLFORMATS:
+ {
+ int iReturn;
+ Display *pDisplay = g_pClipboardDisplay;
+ Window iWindow = g_iClipboardWindow;
+ Bool fConvertToUnicode;
+
+ winDebug ("winClipboardWindowProc - WM_RENDER*FORMAT - Hello.\n");
+
+ /* Flag whether to convert to Unicode or not */
+ if (message == WM_RENDERALLFORMATS)
+ fConvertToUnicode = FALSE;
+ else
+ fConvertToUnicode = g_fUnicodeSupport && (CF_UNICODETEXT == wParam);
+
+ /* Request the selection contents */
+ iReturn = XConvertSelection (pDisplay,
+ g_atomLastOwnedSelection,
+ XInternAtom (pDisplay,
+ "COMPOUND_TEXT", False),
+ XInternAtom (pDisplay,
+ "CYGX_CUT_BUFFER", False),
+ iWindow,
+ CurrentTime);
+ if (iReturn == BadAtom || iReturn == BadWindow)
+ {
+ winErrorFVerb (1, "winClipboardWindowProc - WM_RENDER*FORMAT - "
+ "XConvertSelection () failed\n");
+ break;
+ }
+
+ /* Special handling for WM_RENDERALLFORMATS */
+ if (message == WM_RENDERALLFORMATS)
+ {
+ /* We must open and empty the clipboard */
+
+ /* Close clipboard if we have it open already */
+ if (GetOpenClipboardWindow () == hwnd)
+ {
+ CloseClipboard ();
+ }
+
+ if (!OpenClipboard (hwnd))
+ {
+ winErrorFVerb (1, "winClipboardWindowProc - WM_RENDER*FORMATS - "
+ "OpenClipboard () failed: %08x\n",
+ GetLastError ());
+ break;
+ }
+
+ if (!EmptyClipboard ())
+ {
+ winErrorFVerb (1, "winClipboardWindowProc - WM_RENDER*FORMATS - "
+ "EmptyClipboard () failed: %08x\n",
+ GetLastError ());
+ break;
+ }
+ }
+
+ /* Process the SelectionNotify event */
+ iReturn = winProcessXEventsTimeout (hwnd,
+ iWindow,
+ pDisplay,
+ fConvertToUnicode,
+ WIN_POLL_TIMEOUT);
+ if (WIN_XEVENTS_CONVERT == iReturn)
+ {
+ /*
+ * The selection was offered for conversion first, so we have
+ * to process a second SelectionNotify event to get the actual
+ * data in the selection.
+ */
+ iReturn = winProcessXEventsTimeout (hwnd,
+ iWindow,
+ pDisplay,
+ fConvertToUnicode,
+ WIN_POLL_TIMEOUT);
+ }
+
+ /*
+ * The last of the up-to two calls to winProcessXEventsTimeout
+ * from above had better have seen a notify event, or else we
+ * are dealing with a buggy or old X11 app. In these cases we
+ * have to paste some fake data to the Win32 clipboard to
+ * satisfy the requirement that we write something to it.
+ */
+ if (WIN_XEVENTS_NOTIFY != iReturn)
+ {
+ /* Paste no data, to satisfy required call to SetClipboardData */
+ if (g_fUnicodeSupport)
+ SetClipboardData (CF_UNICODETEXT, NULL);
+ SetClipboardData (CF_TEXT, NULL);
+ }
+
+ /* Special handling for WM_RENDERALLFORMATS */
+ if (message == WM_RENDERALLFORMATS)
+ {
+ /* We must close the clipboard */
+
+ if (!CloseClipboard ())
+ {
+ winErrorFVerb (1, "winClipboardWindowProc - WM_RENDERALLFORMATS - "
+ "CloseClipboard () failed: %08x\n",
+ GetLastError ());
+ break;
+ }
+ }
+
+ winDebug ("winClipboardWindowProc - WM_RENDER*FORMAT - Returning.\n");
+ return 0;
+ }
+ }
+
+ /* Let Windows perform default processing for unhandled messages */
+ return DefWindowProc (hwnd, message, wParam, lParam);
+}
+
+
+/*
+ * Process any pending Windows messages
+ */
+
+BOOL
+winClipboardFlushWindowsMessageQueue (HWND hwnd)
+{
+ MSG msg;
+
+ /* Flush the messaging window queue */
+ /* NOTE: Do not pass the hwnd of our messaging window to PeekMessage,
+ * as this will filter out many non-window-specific messages that
+ * are sent to our thread, such as WM_QUIT.
+ */
+ while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ /* Dispatch the message if not WM_QUIT */
+ if (msg.message == WM_QUIT)
+ return FALSE;
+ else
+ DispatchMessage (&msg);
+ }
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winclipboardwrappers.c b/nx-X11/programs/Xserver/hw/xwin/winclipboardwrappers.c
new file mode 100755
index 000000000..8801f6c42
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winclipboardwrappers.c
@@ -0,0 +1,544 @@
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "dixstruct.h"
+#include <X11/Xatom.h>
+
+
+/*
+ * Constants
+ */
+
+#define CLIP_NUM_SELECTIONS 2
+#define CLIP_OWN_PRIMARY 0
+#define CLIP_OWN_CLIPBOARD 1
+
+
+/*
+ * Local function prototypes
+ */
+
+DISPATCH_PROC(winProcEstablishConnection);
+DISPATCH_PROC(winProcQueryTree);
+DISPATCH_PROC(winProcSetSelectionOwner);
+
+
+/*
+ * References to external symbols
+ */
+
+extern Bool g_fUnicodeSupport;
+extern int g_iNumScreens;
+extern unsigned int g_uiAuthDataLen;
+extern char *g_pAuthData;
+extern Bool g_fXdmcpEnabled;
+extern Bool g_fClipboardLaunched;
+extern Bool g_fClipboardStarted;
+extern Bool g_fClipboard;
+extern Window g_iClipboardWindow;
+extern Atom g_atomLastOwnedSelection;
+extern HWND g_hwndClipboard;
+
+extern winDispatchProcPtr winProcEstablishConnectionOrig;
+extern winDispatchProcPtr winProcQueryTreeOrig;
+extern winDispatchProcPtr winProcSetSelectionOwnerOrig;
+
+
+/*
+ * Wrapper for internal QueryTree function.
+ * Hides the clipboard client when it is the only client remaining.
+ */
+
+int
+winProcQueryTree (ClientPtr client)
+{
+ int iReturn;
+
+ /*
+ * This procedure is only used for initialization.
+ * We can unwrap the original procedure at this point
+ * so that this function is no longer called until the
+ * server resets and the function is wrapped again.
+ */
+ ProcVector[X_QueryTree] = winProcQueryTreeOrig;
+
+ /*
+ * Call original function and bail if it fails.
+ * NOTE: We must do this first, since we need XdmcpOpenDisplay
+ * to be called before we initialize our clipboard client.
+ */
+ iReturn = (*winProcQueryTreeOrig) (client);
+ if (iReturn != 0)
+ {
+ ErrorF ("winProcQueryTree - ProcQueryTree failed, bailing.\n");
+ return iReturn;
+ }
+
+ /* Make errors more obvious */
+ winProcQueryTreeOrig = NULL;
+
+ /* Do nothing if clipboard is not enabled */
+ if (!g_fClipboard)
+ {
+ ErrorF ("winProcQueryTree - Clipboard is not enabled, "
+ "returning.\n");
+ return iReturn;
+ }
+
+ /* If the clipboard client has already been started, abort */
+ if (g_fClipboardLaunched)
+ {
+ ErrorF ("winProcQueryTree - Clipboard client already "
+ "launched, returning.\n");
+ return iReturn;
+ }
+
+ /* Startup the clipboard client if clipboard mode is being used */
+ if (g_fXdmcpEnabled && g_fClipboard)
+ {
+ /*
+ * NOTE: The clipboard client is started here for a reason:
+ * 1) Assume you are using XDMCP (e.g. XWin -query %hostname%)
+ * 2) If the clipboard client attaches during X Server startup,
+ * then it becomes the "magic client" that causes the X Server
+ * to reset if it exits.
+ * 3) XDMCP calls KillAllClients when it starts up.
+ * 4) The clipboard client is a client, so it is killed.
+ * 5) The clipboard client is the "magic client", so the X Server
+ * resets itself.
+ * 6) This repeats ad infinitum.
+ * 7) We avoid this by waiting until at least one client (could
+ * be XDM, could be another client) connects, which makes it
+ * almost certain that the clipboard client will not connect
+ * until after XDM when using XDMCP.
+ * 8) Unfortunately, there is another problem.
+ * 9) XDM walks the list of windows with XQueryTree,
+ * killing any client it finds with a window.
+ * 10)Thus, when using XDMCP we wait until the first call
+ * to ProcQueryTree before we startup the clipboard client.
+ * This should prevent XDM from finding the clipboard client,
+ * since it has not yet created a window.
+ * 11)Startup when not using XDMCP is handled in
+ * winProcEstablishConnection.
+ */
+
+ /* Create the clipboard client thread */
+ if (!winInitClipboard ())
+ {
+ ErrorF ("winProcQueryTree - winClipboardInit "
+ "failed.\n");
+ return iReturn;
+ }
+
+ ErrorF ("winProcQueryTree - winInitClipboard returned.\n");
+ }
+
+ /* Flag that clipboard client has been launched */
+ g_fClipboardLaunched = TRUE;
+
+ return iReturn;
+}
+
+
+/*
+ * Wrapper for internal EstablishConnection function.
+ * Initializes internal clients that must not be started until
+ * an external client has connected.
+ */
+
+int
+winProcEstablishConnection (ClientPtr client)
+{
+ int iReturn;
+ static int s_iCallCount = 0;
+ static unsigned long s_ulServerGeneration = 0;
+
+ ErrorF ("winProcEstablishConnection - Hello\n");
+
+ /* Do nothing if clipboard is not enabled */
+ if (!g_fClipboard)
+ {
+ ErrorF ("winProcEstablishConnection - Clipboard is not enabled, "
+ "returning.\n");
+
+ /* Unwrap the original function, call it, and return */
+ InitialVector[2] = winProcEstablishConnectionOrig;
+ iReturn = (*winProcEstablishConnectionOrig) (client);
+ winProcEstablishConnectionOrig = NULL;
+ return iReturn;
+ }
+
+ /* Watch for server reset */
+ if (s_ulServerGeneration != serverGeneration)
+ {
+ /* Save new generation number */
+ s_ulServerGeneration = serverGeneration;
+
+ /* Reset call count */
+ s_iCallCount = 0;
+ }
+
+ /* Increment call count */
+ ++s_iCallCount;
+
+ /* Wait for second call when Xdmcp is enabled */
+ if (g_fXdmcpEnabled
+ && !g_fClipboardLaunched
+ && s_iCallCount < 4)
+ {
+ ErrorF ("winProcEstablishConnection - Xdmcp enabled, waiting to "
+ "start clipboard client until fourth call.\n");
+ return (*winProcEstablishConnectionOrig) (client);
+ }
+
+ /*
+ * This procedure is only used for initialization.
+ * We can unwrap the original procedure at this point
+ * so that this function is no longer called until the
+ * server resets and the function is wrapped again.
+ */
+ InitialVector[2] = winProcEstablishConnectionOrig;
+
+ /*
+ * Call original function and bail if it fails.
+ * NOTE: We must do this first, since we need XdmcpOpenDisplay
+ * to be called before we initialize our clipboard client.
+ */
+ iReturn = (*winProcEstablishConnectionOrig) (client);
+ if (iReturn != 0)
+ {
+ ErrorF ("winProcEstablishConnection - ProcEstablishConnection "
+ "failed, bailing.\n");
+ return iReturn;
+ }
+
+ /* Clear original function pointer */
+ winProcEstablishConnectionOrig = NULL;
+
+ /* If the clipboard client has already been started, abort */
+ if (g_fClipboardLaunched)
+ {
+ ErrorF ("winProcEstablishConnection - Clipboard client already "
+ "launched, returning.\n");
+ return iReturn;
+ }
+
+ /* Startup the clipboard client if clipboard mode is being used */
+ if (g_fClipboard)
+ {
+ /*
+ * NOTE: The clipboard client is started here for a reason:
+ * 1) Assume you are using XDMCP (e.g. XWin -query %hostname%)
+ * 2) If the clipboard client attaches during X Server startup,
+ * then it becomes the "magic client" that causes the X Server
+ * to reset if it exits.
+ * 3) XDMCP calls KillAllClients when it starts up.
+ * 4) The clipboard client is a client, so it is killed.
+ * 5) The clipboard client is the "magic client", so the X Server
+ * resets itself.
+ * 6) This repeats ad infinitum.
+ * 7) We avoid this by waiting until at least one client (could
+ * be XDM, could be another client) connects, which makes it
+ * almost certain that the clipboard client will not connect
+ * until after XDM when using XDMCP.
+ * 8) Unfortunately, there is another problem.
+ * 9) XDM walks the list of windows with XQueryTree,
+ * killing any client it finds with a window.
+ * 10)Thus, when using XDMCP we wait until the second call
+ * to ProcEstablishCeonnection before we startup the clipboard
+ * client. This should prevent XDM from finding the clipboard
+ * client, since it has not yet created a window.
+ */
+
+ /* Create the clipboard client thread */
+ if (!winInitClipboard ())
+ {
+ ErrorF ("winProcEstablishConnection - winClipboardInit "
+ "failed.\n");
+ return iReturn;
+ }
+
+ ErrorF ("winProcEstablishConnection - winInitClipboard returned.\n");
+ }
+
+ /* Flag that clipboard client has been launched */
+ g_fClipboardLaunched = TRUE;
+
+ return iReturn;
+}
+
+
+/*
+ * Wrapper for internal SetSelectionOwner function.
+ * Grabs ownership of Windows clipboard when X11 clipboard owner changes.
+ */
+
+int
+winProcSetSelectionOwner (ClientPtr client)
+{
+ int i;
+ DrawablePtr pDrawable;
+ WindowPtr pWindow = None;
+ Bool fOwnedToNotOwned = FALSE;
+ static Window s_iOwners[CLIP_NUM_SELECTIONS] = {None};
+ static unsigned long s_ulServerGeneration = 0;
+ REQUEST(xSetSelectionOwnerReq);
+
+ REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
+
+#if 0
+ ErrorF ("winProcSetSelectionOwner - Hello.\n");
+#endif
+
+ /* Watch for server reset */
+ if (s_ulServerGeneration != serverGeneration)
+ {
+ /* Save new generation number */
+ s_ulServerGeneration = serverGeneration;
+
+ /* Initialize static variables */
+ for (i = 0; i < CLIP_NUM_SELECTIONS; ++i)
+ s_iOwners[i] = None;
+ }
+
+ /* Abort if clipboard not completely initialized yet */
+ if (!g_fClipboardStarted)
+ {
+ ErrorF ("winProcSetSelectionOwner - Clipboard not yet started, "
+ "aborting.\n");
+ goto winProcSetSelectionOwner_Done;
+ }
+
+ /* Grab window if we have one */
+ if (None != stuff->window)
+ {
+ /* Grab the Window from the request */
+ pWindow = (WindowPtr) SecurityLookupWindow (stuff->window, client,
+ SecurityReadAccess);
+ if (!pWindow)
+ {
+ ErrorF ("winProcSetSelectionOwner - Found BadWindow, aborting.\n");
+ goto winProcSetSelectionOwner_Done;
+ }
+ }
+
+ /* Now we either have a valid window or None */
+
+ /* Save selection owners for monitored selections, ignore other selections */
+ if (XA_PRIMARY == stuff->selection)
+ {
+ /* Look for owned -> not owned transition */
+ if (None == stuff->window
+ && None != s_iOwners[CLIP_OWN_PRIMARY])
+ {
+ fOwnedToNotOwned = TRUE;
+
+#if 0
+ ErrorF ("winProcSetSelectionOwner - PRIMARY - Going from "
+ "owned to not owned.\n");
+#endif
+
+ /* Adjust last owned selection */
+ if (None != s_iOwners[CLIP_OWN_CLIPBOARD])
+ g_atomLastOwnedSelection = MakeAtom ("CLIPBOARD", 9, TRUE);
+ else
+ g_atomLastOwnedSelection = None;
+ }
+
+ /* Save new selection owner or None */
+ s_iOwners[CLIP_OWN_PRIMARY] = stuff->window;
+
+#if 0
+ ErrorF ("winProcSetSelectionOwner - PRIMARY - Now owned by: %d\n",
+ stuff->window);
+#endif
+ }
+ else if (MakeAtom ("CLIPBOARD", 9, TRUE) == stuff->selection)
+ {
+ /* Look for owned -> not owned transition */
+ if (None == stuff->window
+ && None != s_iOwners[CLIP_OWN_CLIPBOARD])
+ {
+ fOwnedToNotOwned = TRUE;
+
+#if 0
+ ErrorF ("winProcSetSelectionOwner - CLIPBOARD - Going from "
+ "owned to not owned.\n");
+#endif
+
+ /* Adjust last owned selection */
+ if (None != s_iOwners[CLIP_OWN_PRIMARY])
+ g_atomLastOwnedSelection = XA_PRIMARY;
+ else
+ g_atomLastOwnedSelection = None;
+ }
+
+ /* Save new selection owner or None */
+ s_iOwners[CLIP_OWN_CLIPBOARD] = stuff->window;
+
+#if 0
+ ErrorF ("winProcSetSelectionOwner - CLIPBOARD - Now owned by: %d\n",
+ stuff->window);
+#endif
+ }
+ else
+ goto winProcSetSelectionOwner_Done;
+
+ /*
+ * At this point, if one of the selections is still owned by the
+ * clipboard manager then it should be marked as unowned since
+ * we will be taking ownership of the Win32 clipboard.
+ */
+ if (g_iClipboardWindow == s_iOwners[CLIP_OWN_PRIMARY])
+ s_iOwners[CLIP_OWN_PRIMARY] = None;
+ if (g_iClipboardWindow == s_iOwners[CLIP_OWN_CLIPBOARD])
+ s_iOwners[CLIP_OWN_CLIPBOARD] = None;
+
+ /*
+ * Handle case when selection is being disowned,
+ * WM_DRAWCLIPBOARD did not do the disowning,
+ * both monitored selections are no longer owned,
+ * an owned to not owned transition was detected,
+ * and we currently own the Win32 clipboard.
+ */
+ if (None == stuff->window
+ && g_iClipboardWindow != client->lastDrawableID
+ && (None == s_iOwners[CLIP_OWN_PRIMARY]
+ || g_iClipboardWindow == s_iOwners[CLIP_OWN_PRIMARY])
+ && (None == s_iOwners[CLIP_OWN_CLIPBOARD]
+ || g_iClipboardWindow == s_iOwners[CLIP_OWN_CLIPBOARD])
+ && fOwnedToNotOwned
+ && g_hwndClipboard != NULL
+ && g_hwndClipboard == GetClipboardOwner ())
+ {
+#if 0
+ ErrorF ("winProcSetSelectionOwner - We currently own the "
+ "clipboard and neither the PRIMARY nor the CLIPBOARD "
+ "selections are owned, releasing ownership of Win32 "
+ "clipboard.\n");
+#endif
+
+ /* Release ownership of the Windows clipboard */
+ OpenClipboard (NULL);
+ EmptyClipboard ();
+ CloseClipboard ();
+
+ /* Clear X selection ownership (might still be marked as us owning) */
+ s_iOwners[CLIP_OWN_PRIMARY] = None;
+ s_iOwners[CLIP_OWN_CLIPBOARD] = None;
+
+ goto winProcSetSelectionOwner_Done;
+ }
+
+ /* Abort if no window at this point */
+ if (None == stuff->window)
+ {
+#if 0
+ ErrorF ("winProcSetSelectionOwner - No window, returning.\n");
+#endif
+ goto winProcSetSelectionOwner_Done;
+ }
+
+ /* Abort if invalid selection */
+ if (!ValidAtom (stuff->selection))
+ {
+ ErrorF ("winProcSetSelectionOwner - Found BadAtom, aborting.\n");
+ goto winProcSetSelectionOwner_Done;
+ }
+
+ /* Cast Window to Drawable */
+ pDrawable = (DrawablePtr) pWindow;
+
+ /* Abort if clipboard manager is owning the selection */
+ if (pDrawable->id == g_iClipboardWindow)
+ {
+#if 0
+ ErrorF ("winProcSetSelectionOwner - We changed ownership, "
+ "aborting.\n");
+#endif
+ goto winProcSetSelectionOwner_Done;
+ }
+
+ /* Abort if root window is taking ownership */
+ if (pDrawable->id == 0)
+ {
+ ErrorF ("winProcSetSelectionOwner - Root window taking ownership, "
+ "aborting\n");
+ goto winProcSetSelectionOwner_Done;
+ }
+
+ /* Close clipboard if we have it open already */
+ if (GetOpenClipboardWindow () == g_hwndClipboard)
+ {
+ CloseClipboard ();
+ }
+
+ /* Access the Windows clipboard */
+ if (!OpenClipboard (g_hwndClipboard))
+ {
+ ErrorF ("winProcSetSelectionOwner - OpenClipboard () failed: %08x\n",
+ (int) GetLastError ());
+ goto winProcSetSelectionOwner_Done;
+ }
+
+ /* Take ownership of the Windows clipboard */
+ if (!EmptyClipboard ())
+ {
+ ErrorF ("winProcSetSelectionOwner - EmptyClipboard () failed: %08x\n",
+ (int) GetLastError ());
+ goto winProcSetSelectionOwner_Done;
+ }
+
+ /* Advertise Unicode if we support it */
+ if (g_fUnicodeSupport)
+ SetClipboardData (CF_UNICODETEXT, NULL);
+
+ /* Always advertise regular text */
+ SetClipboardData (CF_TEXT, NULL);
+
+ /* Save handle to last owned selection */
+ g_atomLastOwnedSelection = stuff->selection;
+
+ /* Release the clipboard */
+ if (!CloseClipboard ())
+ {
+ ErrorF ("winProcSetSelectionOwner - CloseClipboard () failed: "
+ "%08x\n",
+ (int) GetLastError ());
+ goto winProcSetSelectionOwner_Done;
+ }
+
+ winProcSetSelectionOwner_Done:
+ return (*winProcSetSelectionOwnerOrig) (client);
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winclipboardxevents.c b/nx-X11/programs/Xserver/hw/xwin/winclipboardxevents.c
new file mode 100644
index 000000000..d4c617bec
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winclipboardxevents.c
@@ -0,0 +1,796 @@
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "winclipboard.h"
+
+
+/*
+ * References to external symbols
+ */
+
+extern Bool g_fUnicodeSupport;
+
+
+/*
+ * Process any pending X events
+ */
+
+int
+winClipboardFlushXEvents (HWND hwnd,
+ int iWindow,
+ Display *pDisplay,
+ Bool fUseUnicode)
+{
+ Atom atomLocalProperty = XInternAtom (pDisplay,
+ WIN_LOCAL_PROPERTY,
+ False);
+ Atom atomUTF8String = XInternAtom (pDisplay,
+ "UTF8_STRING",
+ False);
+ Atom atomCompoundText = XInternAtom (pDisplay,
+ "COMPOUND_TEXT",
+ False);
+ Atom atomTargets = XInternAtom (pDisplay,
+ "TARGETS",
+ False);
+
+ /* Process all pending events */
+ while (XPending (pDisplay))
+ {
+ XTextProperty xtpText = {0};
+ XEvent event;
+ XSelectionEvent eventSelection;
+ unsigned long ulReturnBytesLeft;
+ unsigned char *pszReturnData = NULL;
+ char *pszGlobalData = NULL;
+ int iReturn;
+ HGLOBAL hGlobal = NULL;
+ XICCEncodingStyle xiccesStyle;
+ int iConvertDataLen = 0;
+ char *pszConvertData = NULL;
+ char *pszTextList[2] = {NULL};
+ int iCount;
+ char **ppszTextList = NULL;
+ wchar_t *pwszUnicodeStr = NULL;
+ int iUnicodeLen = 0;
+ int iReturnDataLen = 0;
+ int i;
+ Bool fAbort = FALSE;
+ Bool fCloseClipboard = FALSE;
+ Bool fSetClipboardData = TRUE;
+
+ /* Get the next event - will not block because one is ready */
+ XNextEvent (pDisplay, &event);
+
+ /* Branch on the event type */
+ switch (event.type)
+ {
+ /*
+ * SelectionRequest
+ */
+
+ case SelectionRequest:
+#if 0
+ {
+ char *pszAtomName = NULL;
+
+ ErrorF ("SelectionRequest - target %d\n",
+ event.xselectionrequest.target);
+
+ pszAtomName = XGetAtomName (pDisplay,
+ event.xselectionrequest.target);
+ ErrorF ("SelectionRequest - Target atom name %s\n", pszAtomName);
+ XFree (pszAtomName);
+ pszAtomName = NULL;
+ }
+#endif
+
+ /* Abort if invalid target type */
+ if (event.xselectionrequest.target != XA_STRING
+ && event.xselectionrequest.target != atomUTF8String
+ && event.xselectionrequest.target != atomCompoundText
+ && event.xselectionrequest.target != atomTargets)
+ {
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ /* Handle targets type of request */
+ if (event.xselectionrequest.target == atomTargets)
+ {
+ Atom atomTargetArr[] = {atomTargets,
+ atomCompoundText,
+ atomUTF8String,
+ XA_STRING};
+
+ /* Try to change the property */
+ iReturn = XChangeProperty (pDisplay,
+ event.xselectionrequest.requestor,
+ event.xselectionrequest.property,
+ XA_ATOM,
+ 32,
+ PropModeReplace,
+ (unsigned char *) atomTargetArr,
+ (sizeof (atomTargetArr)
+ / sizeof (atomTargetArr[0])));
+ if (iReturn == BadAlloc
+ || iReturn == BadAtom
+ || iReturn == BadMatch
+ || iReturn == BadValue
+ || iReturn == BadWindow)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "XChangeProperty failed: %d\n",
+ iReturn);
+ }
+
+ /* Setup selection notify xevent */
+ eventSelection.type = SelectionNotify;
+ eventSelection.send_event = True;
+ eventSelection.display = pDisplay;
+ eventSelection.requestor = event.xselectionrequest.requestor;
+ eventSelection.selection = event.xselectionrequest.selection;
+ eventSelection.target = event.xselectionrequest.target;
+ eventSelection.property = event.xselectionrequest.property;
+ eventSelection.time = event.xselectionrequest.time;
+
+ /*
+ * Notify the requesting window that
+ * the operation has completed
+ */
+ iReturn = XSendEvent (pDisplay,
+ eventSelection.requestor,
+ False,
+ 0L,
+ (XEvent *) &eventSelection);
+ if (iReturn == BadValue || iReturn == BadWindow)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "XSendEvent () failed\n");
+ }
+ break;
+ }
+
+ /* Check that clipboard format is available */
+ if (fUseUnicode
+ && !IsClipboardFormatAvailable (CF_UNICODETEXT))
+ {
+ ErrorF ("winClipboardFlushXEvents - CF_UNICODETEXT is not "
+ "available from Win32 clipboard. Aborting.\n");
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+ else if (!fUseUnicode
+ && !IsClipboardFormatAvailable (CF_TEXT))
+ {
+ ErrorF ("winClipboardFlushXEvents - CF_TEXT is not "
+ "available from Win32 clipboard. Aborting.\n");
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ /* Close clipboard if we have it open already */
+ if (GetOpenClipboardWindow () == hwnd)
+ {
+ CloseClipboard ();
+ }
+
+ /* Access the clipboard */
+ if (!OpenClipboard (hwnd))
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "OpenClipboard () failed: %08x\n",
+ GetLastError ());
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ /* Indicate that clipboard was opened */
+ fCloseClipboard = TRUE;
+
+ /* Setup the string style */
+ if (event.xselectionrequest.target == XA_STRING)
+ xiccesStyle = XStringStyle;
+#ifdef X_HAVE_UTF8_STRING
+ else if (event.xselectionrequest.target == atomUTF8String)
+ xiccesStyle = XUTF8StringStyle;
+#endif
+ else if (event.xselectionrequest.target == atomCompoundText)
+ xiccesStyle = XCompoundTextStyle;
+ else
+ xiccesStyle = XStringStyle;
+
+ /*
+ * FIXME: Can't pass CF_UNICODETEXT on Windows 95/98/Me
+ */
+
+ /* Get a pointer to the clipboard text, in desired format */
+ if (fUseUnicode)
+ {
+ /* Retrieve clipboard data */
+ hGlobal = GetClipboardData (CF_UNICODETEXT);
+ }
+ else
+ {
+ /* Retrieve clipboard data */
+ hGlobal = GetClipboardData (CF_TEXT);
+ }
+ if (!hGlobal)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "GetClipboardData () failed: %08x\n",
+ GetLastError ());
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+ pszGlobalData = (char *) GlobalLock (hGlobal);
+
+ /* Convert the Unicode string to UTF8 (MBCS) */
+ if (fUseUnicode)
+ {
+ iConvertDataLen = WideCharToMultiByte (CP_UTF8,
+ 0,
+ (LPCWSTR)pszGlobalData,
+ -1,
+ NULL,
+ 0,
+ NULL,
+ NULL);
+ /* NOTE: iConvertDataLen includes space for null terminator */
+ pszConvertData = (char *) malloc (iConvertDataLen);
+ WideCharToMultiByte (CP_UTF8,
+ 0,
+ (LPCWSTR)pszGlobalData,
+ -1,
+ pszConvertData,
+ iConvertDataLen,
+ NULL,
+ NULL);
+ }
+ else
+ {
+ pszConvertData = strdup (pszGlobalData);
+ iConvertDataLen = strlen (pszConvertData) + 1;
+ }
+
+ /* Convert DOS string to UNIX string */
+ winClipboardDOStoUNIX (pszConvertData, strlen (pszConvertData));
+
+ /* Setup our text list */
+ pszTextList[0] = pszConvertData;
+ pszTextList[1] = NULL;
+
+ /* Initialize the text property */
+ xtpText.value = NULL;
+
+ /* Create the text property from the text list */
+ if (fUseUnicode)
+ {
+#ifdef X_HAVE_UTF8_STRING
+ iReturn = Xutf8TextListToTextProperty (pDisplay,
+ pszTextList,
+ 1,
+ xiccesStyle,
+ &xtpText);
+#endif
+ }
+ else
+ {
+ iReturn = XmbTextListToTextProperty (pDisplay,
+ pszTextList,
+ 1,
+ xiccesStyle,
+ &xtpText);
+ }
+ if (iReturn == XNoMemory || iReturn == XLocaleNotSupported)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "X*TextListToTextProperty failed: %d\n",
+ iReturn);
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ /* Free the converted string */
+ free (pszConvertData);
+ pszConvertData = NULL;
+
+ /* Copy the clipboard text to the requesting window */
+ iReturn = XChangeProperty (pDisplay,
+ event.xselectionrequest.requestor,
+ event.xselectionrequest.property,
+ event.xselectionrequest.target,
+ 8,
+ PropModeReplace,
+ xtpText.value,
+ xtpText.nitems);
+ if (iReturn == BadAlloc || iReturn == BadAtom
+ || iReturn == BadMatch || iReturn == BadValue
+ || iReturn == BadWindow)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "XChangeProperty failed: %d\n",
+ iReturn);
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ /* Release the clipboard data */
+ GlobalUnlock (hGlobal);
+ pszGlobalData = NULL;
+
+ /* Clean up */
+ XFree (xtpText.value);
+ xtpText.value = NULL;
+
+ /* Setup selection notify event */
+ eventSelection.type = SelectionNotify;
+ eventSelection.send_event = True;
+ eventSelection.display = pDisplay;
+ eventSelection.requestor = event.xselectionrequest.requestor;
+ eventSelection.selection = event.xselectionrequest.selection;
+ eventSelection.target = event.xselectionrequest.target;
+ eventSelection.property = event.xselectionrequest.property;
+ eventSelection.time = event.xselectionrequest.time;
+
+ /* Notify the requesting window that the operation has completed */
+ iReturn = XSendEvent (pDisplay,
+ eventSelection.requestor,
+ False,
+ 0L,
+ (XEvent *) &eventSelection);
+ if (iReturn == BadValue || iReturn == BadWindow)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "XSendEvent () failed\n");
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ winClipboardFlushXEvents_SelectionRequest_Done:
+ /* Free allocated resources */
+ if (xtpText.value)
+ XFree (xtpText.value);
+ if (pszConvertData)
+ free (pszConvertData);
+ if (hGlobal && pszGlobalData)
+ GlobalUnlock (hGlobal);
+
+ /*
+ * Send a SelectionNotify event to the requesting
+ * client when we abort.
+ */
+ if (fAbort)
+ {
+ /* Setup selection notify event */
+ eventSelection.type = SelectionNotify;
+ eventSelection.send_event = True;
+ eventSelection.display = pDisplay;
+ eventSelection.requestor = event.xselectionrequest.requestor;
+ eventSelection.selection = event.xselectionrequest.selection;
+ eventSelection.target = event.xselectionrequest.target;
+ eventSelection.property = None;
+ eventSelection.time = event.xselectionrequest.time;
+
+ /* Notify the requesting window that the operation is complete */
+ iReturn = XSendEvent (pDisplay,
+ eventSelection.requestor,
+ False,
+ 0L,
+ (XEvent *) &eventSelection);
+ if (iReturn == BadValue || iReturn == BadWindow)
+ {
+ /*
+ * Should not be a problem if XSendEvent fails because
+ * the client may simply have exited.
+ */
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "XSendEvent () failed for abort event.\n");
+ }
+ }
+
+ /* Close clipboard if it was opened */
+ if (fCloseClipboard)
+ CloseClipboard ();
+ break;
+
+
+ /*
+ * SelectionNotify
+ */
+
+ case SelectionNotify:
+#if 0
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify\n");
+ {
+ char *pszAtomName;
+
+ pszAtomName = XGetAtomName (pDisplay,
+ event.xselection.selection);
+
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - ATOM: %s\n",
+ pszAtomName);
+
+ XFree (pszAtomName);
+ }
+#endif
+
+
+ /*
+ * Request conversion of UTF8 and CompoundText targets.
+ */
+ if (event.xselection.property == None)
+ {
+ if (event.xselection.target == XA_STRING)
+ {
+#if 0
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+ "XA_STRING\n");
+#endif
+ return WIN_XEVENTS_CONVERT;
+ }
+ else if (event.xselection.target == atomUTF8String)
+ {
+#if 0
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+ "Requesting conversion of UTF8 target.\n");
+#endif
+ iReturn = XConvertSelection (pDisplay,
+ event.xselection.selection,
+ XA_STRING,
+ atomLocalProperty,
+ iWindow,
+ CurrentTime);
+ if (iReturn != Success)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+ "XConvertSelection () failed for UTF8String, "
+ "aborting: %d\n",
+ iReturn);
+ break;
+ }
+
+ /* Process the ConvertSelection event */
+ XFlush (pDisplay);
+ return WIN_XEVENTS_CONVERT;
+ }
+#ifdef X_HAVE_UTF8_STRING
+ else if (event.xselection.target == atomCompoundText)
+ {
+#if 0
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+ "Requesting conversion of CompoundText target.\n");
+#endif
+ iReturn = XConvertSelection (pDisplay,
+ event.xselection.selection,
+ atomUTF8String,
+ atomLocalProperty,
+ iWindow,
+ CurrentTime);
+ if (iReturn != Success)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+ "XConvertSelection () failed for CompoundText, "
+ "aborting: %d\n",
+ iReturn);
+ break;
+ }
+
+ /* Process the ConvertSelection event */
+ XFlush (pDisplay);
+ return WIN_XEVENTS_CONVERT;
+ }
+#endif
+ else
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+ "Unknown format. Cannot request conversion, "
+ "aborting.\n");
+ break;
+ }
+ }
+
+ /* Retrieve the size of the stored data */
+ iReturn = XGetWindowProperty (pDisplay,
+ iWindow,
+ atomLocalProperty,
+ 0,
+ 0, /* Don't get data, just size */
+ False,
+ AnyPropertyType,
+ &xtpText.encoding,
+ &xtpText.format,
+ &xtpText.nitems,
+ &ulReturnBytesLeft,
+ &xtpText.value);
+ if (iReturn != Success)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+ "XGetWindowProperty () failed, aborting: %d\n",
+ iReturn);
+ break;
+ }
+
+#if 0
+ ErrorF ("SelectionNotify - returned data %d left %d\n",
+ xtpText.nitems, ulReturnBytesLeft);
+#endif
+
+ /* Request the selection data */
+ iReturn = XGetWindowProperty (pDisplay,
+ iWindow,
+ atomLocalProperty,
+ 0,
+ ulReturnBytesLeft,
+ False,
+ AnyPropertyType,
+ &xtpText.encoding,
+ &xtpText.format,
+ &xtpText.nitems,
+ &ulReturnBytesLeft,
+ &xtpText.value);
+ if (iReturn != Success)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+ "XGetWindowProperty () failed, aborting: %d\n",
+ iReturn);
+ break;
+ }
+
+#if 0
+ {
+ char *pszAtomName = NULL;
+
+ ErrorF ("SelectionNotify - returned data %d left %d\n",
+ xtpText.nitems, ulReturnBytesLeft);
+
+ pszAtomName = XGetAtomName(pDisplay, xtpText.encoding);
+ ErrorF ("Notify atom name %s\n", pszAtomName);
+ XFree (pszAtomName);
+ pszAtomName = NULL;
+ }
+#endif
+
+ if (fUseUnicode)
+ {
+#ifdef X_HAVE_UTF8_STRING
+ /* Convert the text property to a text list */
+ iReturn = Xutf8TextPropertyToTextList (pDisplay,
+ &xtpText,
+ &ppszTextList,
+ &iCount);
+#endif
+ }
+ else
+ {
+ iReturn = XmbTextPropertyToTextList (pDisplay,
+ &xtpText,
+ &ppszTextList,
+ &iCount);
+ }
+ if (iReturn == Success || iReturn > 0)
+ {
+ /* Conversion succeeded or some unconvertible characters */
+ if (ppszTextList != NULL)
+ {
+ for (i = 0; i < iCount; i++)
+ {
+ iReturnDataLen += strlen(ppszTextList[i]);
+ }
+ pszReturnData = malloc (iReturnDataLen + 1);
+ pszReturnData[0] = '\0';
+ for (i = 0; i < iCount; i++)
+ {
+ strcat (pszReturnData, ppszTextList[i]);
+ }
+ }
+ else
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+ "X*TextPropertyToTextList list_return is NULL.\n");
+ pszReturnData = malloc (1);
+ pszReturnData[0] = '\0';
+ }
+ }
+ else
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+ "X*TextPropertyToTextList returned: ");
+ switch (iReturn)
+ {
+ case XNoMemory:
+ ErrorF ("XNoMemory\n");
+ break;
+ case XConverterNotFound:
+ ErrorF ("XConverterNotFound\n");
+ break;
+ default:
+ ErrorF ("%d", iReturn);
+ break;
+ }
+ pszReturnData = malloc (1);
+ pszReturnData[0] = '\0';
+ }
+
+ /* Free the data returned from XGetWindowProperty */
+ if (ppszTextList)
+ XFreeStringList (ppszTextList);
+ ppszTextList = NULL;
+ XFree (xtpText.value);
+ xtpText.value = NULL;
+
+ /* Convert the X clipboard string to DOS format */
+ winClipboardUNIXtoDOS (&pszReturnData, strlen (pszReturnData));
+
+ if (fUseUnicode)
+ {
+ /* Find out how much space needed to convert MBCS to Unicode */
+ iUnicodeLen = MultiByteToWideChar (CP_UTF8,
+ 0,
+ pszReturnData,
+ -1,
+ NULL,
+ 0);
+
+ /* Allocate memory for the Unicode string */
+ pwszUnicodeStr
+ = (wchar_t*) malloc (sizeof (wchar_t) * (iUnicodeLen + 1));
+ if (!pwszUnicodeStr)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify "
+ "malloc failed for pwszUnicodeStr, aborting.\n");
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionNotify_Done;
+ }
+
+ /* Do the actual conversion */
+ MultiByteToWideChar (CP_UTF8,
+ 0,
+ pszReturnData,
+ -1,
+ pwszUnicodeStr,
+ iUnicodeLen);
+
+ /* Allocate global memory for the X clipboard data */
+ hGlobal = GlobalAlloc (GMEM_MOVEABLE,
+ sizeof (wchar_t) * (iUnicodeLen + 1));
+ }
+ else
+ {
+ pszConvertData = strdup (pszReturnData);
+ iConvertDataLen = strlen (pszConvertData) + 1;
+
+ /* Allocate global memory for the X clipboard data */
+ hGlobal = GlobalAlloc (GMEM_MOVEABLE, iConvertDataLen);
+ }
+
+ /* Check that global memory was allocated */
+ if (!hGlobal)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify "
+ "GlobalAlloc failed, aborting: %ld\n",
+ GetLastError ());
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionNotify_Done;
+ }
+
+ /* Obtain a pointer to the global memory */
+ pszGlobalData = GlobalLock (hGlobal);
+ if (pszGlobalData == NULL)
+ {
+ ErrorF ("winClipboardFlushXEvents - Could not lock global "
+ "memory for clipboard transfer\n");
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionNotify_Done;
+ }
+
+ /* Copy the returned string into the global memory */
+ if (fUseUnicode)
+ {
+ memcpy (pszGlobalData,
+ pwszUnicodeStr,
+ sizeof (wchar_t) * (iUnicodeLen + 1));
+ free (pwszUnicodeStr);
+ pwszUnicodeStr = NULL;
+ }
+ else
+ {
+ strcpy (pszGlobalData, pszConvertData);
+ free (pszConvertData);
+ pszConvertData = NULL;
+ }
+
+ /* Release the pointer to the global memory */
+ GlobalUnlock (hGlobal);
+ pszGlobalData = NULL;
+
+ /* Push the selection data to the Windows clipboard */
+ if (fUseUnicode)
+ SetClipboardData (CF_UNICODETEXT, hGlobal);
+ else
+ SetClipboardData (CF_TEXT, hGlobal);
+
+ /* Flag that SetClipboardData has been called */
+ fSetClipboardData = FALSE;
+
+ /*
+ * NOTE: Do not try to free pszGlobalData, it is owned by
+ * Windows after the call to SetClipboardData ().
+ */
+
+ winClipboardFlushXEvents_SelectionNotify_Done:
+ /* Free allocated resources */
+ if (ppszTextList)
+ XFreeStringList (ppszTextList);
+ if (xtpText.value)
+ XFree (xtpText.value);
+ if (pszConvertData)
+ free (pszConvertData);
+ if (pwszUnicodeStr)
+ free (pwszUnicodeStr);
+ if (hGlobal && pszGlobalData)
+ GlobalUnlock (hGlobal);
+ if (fSetClipboardData && g_fUnicodeSupport)
+ SetClipboardData (CF_UNICODETEXT, NULL);
+ if (fSetClipboardData)
+ SetClipboardData (CF_TEXT, NULL);
+ return WIN_XEVENTS_NOTIFY;
+
+ default:
+ break;
+ }
+ }
+
+ return WIN_XEVENTS_SUCCESS;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/wincmap.c b/nx-X11/programs/Xserver/hw/xwin/wincmap.c
new file mode 100644
index 000000000..b3b99b1b5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/wincmap.c
@@ -0,0 +1,675 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/wincmap.c,v 1.9 2002/07/05 09:19:26 alanh Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * Local prototypes
+ */
+
+static int
+winListInstalledColormaps (ScreenPtr pScreen, Colormap *pmaps);
+
+static void
+winStoreColors (ColormapPtr pmap, int ndef, xColorItem *pdefs);
+
+static void
+winInstallColormap (ColormapPtr pmap);
+
+static void
+winUninstallColormap (ColormapPtr pmap);
+
+static void
+winResolveColor (unsigned short *pred,
+ unsigned short *pgreen,
+ unsigned short *pblue,
+ VisualPtr pVisual);
+
+static Bool
+winCreateColormap (ColormapPtr pmap);
+
+static void
+winDestroyColormap (ColormapPtr pmap);
+
+static Bool
+winGetPaletteDIB (ScreenPtr pScreen, ColormapPtr pcmap);
+
+static Bool
+winGetPaletteDD (ScreenPtr pScreen, ColormapPtr pcmap);
+
+
+/*
+ * Set screen functions for colormaps
+ */
+
+void
+winSetColormapFunctions (ScreenPtr pScreen)
+{
+ pScreen->CreateColormap = winCreateColormap;
+ pScreen->DestroyColormap = winDestroyColormap;
+ pScreen->InstallColormap = winInstallColormap;
+ pScreen->UninstallColormap = winUninstallColormap;
+ pScreen->ListInstalledColormaps = winListInstalledColormaps;
+ pScreen->StoreColors = winStoreColors;
+ pScreen->ResolveColor = winResolveColor;
+}
+
+
+/* See Porting Layer Definition - p. 30 */
+/*
+ * Walk the list of installed colormaps, filling the pmaps list
+ * with the resource ids of the installed maps, and return
+ * a count of the total number of installed maps.
+ */
+static int
+winListInstalledColormaps (ScreenPtr pScreen, Colormap *pmaps)
+{
+ winScreenPriv(pScreen);
+
+ /*
+ * There will only be one installed colormap, so we only need
+ * to return one id, and the count of installed maps will always
+ * be one.
+ */
+ *pmaps = pScreenPriv->pcmapInstalled->mid;
+ return 1;
+}
+
+
+/* See Porting Layer Definition - p. 30 */
+/* See Programming Windows - p. 663 */
+static void
+winInstallColormap (ColormapPtr pColormap)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ ColormapPtr oldpmap = pScreenPriv->pcmapInstalled;
+
+#if CYGDEBUG
+ winDebug ("winInstallColormap\n");
+#endif
+
+ /* Did the colormap actually change? */
+ if (pColormap != oldpmap)
+ {
+#if CYGDEBUG
+ winDebug ("winInstallColormap - Colormap has changed, attempt "
+ "to install.\n");
+#endif
+
+ /* Was there a previous colormap? */
+ if (oldpmap != (ColormapPtr) None)
+ {
+ /* There was a previous colormap; tell clients it is gone */
+ WalkTree (pColormap->pScreen, TellLostMap, (char *)&oldpmap->mid);
+ }
+
+ /* Install new colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+ WalkTree (pColormap->pScreen, TellGainedMap, (char *)&pColormap->mid);
+
+ /* Call the engine specific colormap install procedure */
+ if (!((*pScreenPriv->pwinInstallColormap) (pColormap)))
+ {
+ winErrorFVerb (2, "winInstallColormap - Screen specific colormap install "
+ "procedure failed. Continuing, but colors may be "
+ "messed up from now on.\n");
+ }
+ }
+
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+}
+
+
+/* See Porting Layer Definition - p. 30 */
+static void
+winUninstallColormap (ColormapPtr pmap)
+{
+ winScreenPriv(pmap->pScreen);
+ ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
+
+#if CYGDEBUG
+ winDebug ("winUninstallColormap\n");
+#endif
+
+ /* Is the colormap currently installed? */
+ if (pmap != curpmap)
+ {
+ /* Colormap not installed, nothing to do */
+ return;
+ }
+
+ /* Clear the installed colormap flag */
+ pScreenPriv->pcmapInstalled = NULL;
+
+ /*
+ * NOTE: The default colormap does not get "uninstalled" before
+ * it is destroyed.
+ */
+
+ /* Install the default cmap in place of the cmap to be uninstalled */
+ if (pmap->mid != pmap->pScreen->defColormap)
+ {
+ curpmap = (ColormapPtr) LookupIDByType(pmap->pScreen->defColormap,
+ RT_COLORMAP);
+ (*pmap->pScreen->InstallColormap) (curpmap);
+ }
+}
+
+
+/* See Porting Layer Definition - p. 30 */
+static void
+winStoreColors (ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pmap);
+ int i;
+ unsigned short nRed, nGreen, nBlue;
+
+#if CYGDEBUG
+ if (ndef != 1)
+ winDebug ("winStoreColors - ndef: %d\n",
+ ndef);
+#endif
+
+ /* Save the new colors in the colormap privates */
+ for (i = 0; i < ndef; ++i)
+ {
+ /* Adjust the colors from the X color spec to the Windows color spec */
+ nRed = pdefs[i].red >> 8;
+ nGreen = pdefs[i].green >> 8;
+ nBlue = pdefs[i].blue >> 8;
+
+ /* Copy the colors to a palette entry table */
+ pCmapPriv->peColors[pdefs[0].pixel + i].peRed = nRed;
+ pCmapPriv->peColors[pdefs[0].pixel + i].peGreen = nGreen;
+ pCmapPriv->peColors[pdefs[0].pixel + i].peBlue = nBlue;
+
+ /* Copy the colors to a RGBQUAD table */
+ pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbRed = nRed;
+ pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbGreen = nGreen;
+ pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbBlue = nBlue;
+
+#if CYGDEBUG
+ winDebug ("winStoreColors - nRed %d nGreen %d nBlue %d\n",
+ nRed, nGreen, nBlue);
+#endif
+ }
+
+ /* Call the engine specific store colors procedure */
+ if (!((pScreenPriv->pwinStoreColors) (pmap, ndef, pdefs)))
+ {
+ winErrorFVerb (2, "winStoreColors - Engine cpecific color storage procedure "
+ "failed. Continuing, but colors may be messed up from now "
+ "on.\n");
+ }
+}
+
+
+/* See Porting Layer Definition - p. 30 */
+static void
+winResolveColor (unsigned short *pred,
+ unsigned short *pgreen,
+ unsigned short *pblue,
+ VisualPtr pVisual)
+{
+#if CYGDEBUG
+ winDebug ("winResolveColor ()\n");
+#endif
+
+ miResolveColor (pred, pgreen, pblue, pVisual);
+}
+
+
+/* See Porting Layer Definition - p. 29 */
+static Bool
+winCreateColormap (ColormapPtr pmap)
+{
+ winPrivCmapPtr pCmapPriv = NULL;
+ ScreenPtr pScreen = pmap->pScreen;
+ winScreenPriv(pScreen);
+
+#if CYGDEBUG
+ winDebug ("winCreateColormap\n");
+#endif
+
+ /* Allocate colormap privates */
+ if (!winAllocateCmapPrivates (pmap))
+ {
+ ErrorF ("winCreateColorma - Couldn't allocate cmap privates\n");
+ return FALSE;
+ }
+
+ /* Get a pointer to the newly allocated privates */
+ pCmapPriv = winGetCmapPriv (pmap);
+
+ /*
+ * FIXME: This is some evil hackery to help in handling some X clients
+ * that expect the top pixel to be white. This "help" only lasts until
+ * some client overwrites the top colormap entry.
+ *
+ * We don't want to actually allocate the top entry, as that causes
+ * problems with X clients that need 7 planes (128 colors) in the default
+ * colormap, such as Magic 7.1.
+ */
+ pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbRed = 255;
+ pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbGreen = 255;
+ pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbBlue = 255;
+ pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peRed = 255;
+ pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peGreen = 255;
+ pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peBlue = 255;
+
+ /* Call the engine specific colormap initialization procedure */
+ if (!((*pScreenPriv->pwinCreateColormap) (pmap)))
+ {
+ ErrorF ("winCreateColormap - Engine specific colormap creation "
+ "procedure failed. Aborting.\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/* See Porting Layer Definition - p. 29, 30 */
+static void
+winDestroyColormap (ColormapPtr pColormap)
+{
+ winScreenPriv(pColormap->pScreen);
+ winCmapPriv(pColormap);
+
+ /* Call the engine specific colormap destruction procedure */
+ if (!((*pScreenPriv->pwinDestroyColormap) (pColormap)))
+ {
+ winErrorFVerb (2, "winDestroyColormap - Engine specific colormap destruction "
+ "procedure failed. Continuing, but it is possible that memory "
+ "was leaked, or that colors will be messed up from now on.\n");
+ }
+
+ /* Free the colormap privates */
+ free (pCmapPriv);
+ winSetCmapPriv (pColormap, NULL);
+
+#if CYGDEBUG
+ winDebug ("winDestroyColormap - Returning\n");
+#endif
+}
+
+
+/*
+ * Internal function to load the palette used by the Shadow DIB
+ */
+
+static Bool
+winGetPaletteDIB (ScreenPtr pScreen, ColormapPtr pcmap)
+{
+ winScreenPriv(pScreen);
+ int i;
+ Pixel pixel; /* Pixel == CARD32 */
+ CARD16 nRed, nGreen, nBlue; /* CARD16 == unsigned short */
+ UINT uiColorsRetrieved = 0;
+ RGBQUAD rgbColors[WIN_NUM_PALETTE_ENTRIES];
+
+ /* Get the color table for the screen */
+ uiColorsRetrieved = GetDIBColorTable (pScreenPriv->hdcScreen,
+ 0,
+ WIN_NUM_PALETTE_ENTRIES,
+ rgbColors);
+ if (uiColorsRetrieved == 0)
+ {
+ ErrorF ("winGetPaletteDIB - Could not retrieve screen color table\n");
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winGetPaletteDIB - Retrieved %d colors from DIB\n",
+ uiColorsRetrieved);
+#endif
+
+ /* Set the DIB color table to the default screen palette */
+ if (SetDIBColorTable (pScreenPriv->hdcShadow,
+ 0,
+ uiColorsRetrieved,
+ rgbColors) == 0)
+ {
+ ErrorF ("winGetPaletteDIB - SetDIBColorTable () failed\n");
+ return FALSE;
+ }
+
+ /* Alloc each color in the DIB color table */
+ for (i = 0; i < uiColorsRetrieved; ++i)
+ {
+ pixel = i;
+
+ /* Extract the color values for current palette entry */
+ nRed = rgbColors[i].rgbRed << 8;
+ nGreen = rgbColors[i].rgbGreen << 8;
+ nBlue = rgbColors[i].rgbBlue << 8;
+
+#if CYGDEBUG
+ winDebug ("winGetPaletteDIB - Allocating a color: %d; "
+ "%d %d %d\n",
+ pixel, nRed, nGreen, nBlue);
+#endif
+
+ /* Allocate a entry in the X colormap */
+ if (AllocColor (pcmap,
+ &nRed,
+ &nGreen,
+ &nBlue,
+ &pixel,
+ 0) != Success)
+ {
+ ErrorF ("winGetPaletteDIB - AllocColor () failed, pixel %d\n",
+ i);
+ return FALSE;
+ }
+
+ if (i != pixel
+ || nRed != rgbColors[i].rgbRed
+ || nGreen != rgbColors[i].rgbGreen
+ || nBlue != rgbColors[i].rgbBlue)
+ {
+ winDebug ("winGetPaletteDIB - Got: %d; "
+ "%d %d %d\n",
+ (int) pixel, nRed, nGreen, nBlue);
+ }
+
+ /* FIXME: Not sure that this bit is needed at all */
+ pcmap->red[i].co.local.red = nRed;
+ pcmap->red[i].co.local.green = nGreen;
+ pcmap->red[i].co.local.blue = nBlue;
+ }
+
+ /* System is using a colormap */
+ /* Set the black and white pixel indices */
+ pScreen->whitePixel = uiColorsRetrieved - 1;
+ pScreen->blackPixel = 0;
+
+ return TRUE;
+}
+
+
+/*
+ * Internal function to load the standard system palette being used by DD
+ */
+
+static Bool
+winGetPaletteDD (ScreenPtr pScreen, ColormapPtr pcmap)
+{
+ int i;
+ Pixel pixel; /* Pixel == CARD32 */
+ CARD16 nRed, nGreen, nBlue; /* CARD16 == unsigned short */
+ UINT uiSystemPaletteEntries;
+ LPPALETTEENTRY ppeColors = NULL;
+ HDC hdc = NULL;
+
+ /* Get a DC to obtain the default palette */
+ hdc = GetDC (NULL);
+ if (hdc == NULL)
+ {
+ ErrorF ("winGetPaletteDD - Couldn't get a DC\n");
+ return FALSE;
+ }
+
+ /* Get the number of entries in the system palette */
+ uiSystemPaletteEntries = GetSystemPaletteEntries (hdc,
+ 0, 0, NULL);
+ if (uiSystemPaletteEntries == 0)
+ {
+ ErrorF ("winGetPaletteDD - Unable to determine number of "
+ "system palette entries\n");
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winGetPaletteDD - uiSystemPaletteEntries %d\n",
+ uiSystemPaletteEntries);
+#endif
+
+ /* Allocate palette entries structure */
+ ppeColors = malloc (uiSystemPaletteEntries * sizeof (PALETTEENTRY));
+ if (ppeColors == NULL)
+ {
+ ErrorF ("winGetPaletteDD - malloc () for colormap failed\n");
+ return FALSE;
+ }
+
+ /* Get system palette entries */
+ GetSystemPaletteEntries (hdc,
+ 0, uiSystemPaletteEntries, ppeColors);
+
+ /* Allocate an X colormap entry for every system palette entry */
+ for (i = 0; i < uiSystemPaletteEntries; ++i)
+ {
+ pixel = i;
+
+ /* Extract the color values for current palette entry */
+ nRed = ppeColors[i].peRed << 8;
+ nGreen = ppeColors[i].peGreen << 8;
+ nBlue = ppeColors[i].peBlue << 8;
+#if CYGDEBUG
+ winDebug ("winGetPaletteDD - Allocating a color: %d; "
+ "%d %d %d\n",
+ pixel, nRed, nGreen, nBlue);
+#endif
+ if (AllocColor (pcmap,
+ &nRed,
+ &nGreen,
+ &nBlue,
+ &pixel,
+ 0) != Success)
+ {
+ ErrorF ("winGetPaletteDD - AllocColor () failed, pixel %d\n",
+ i);
+ free (ppeColors);
+ ppeColors = NULL;
+ return FALSE;
+ }
+
+ pcmap->red[i].co.local.red = nRed;
+ pcmap->red[i].co.local.green = nGreen;
+ pcmap->red[i].co.local.blue = nBlue;
+ }
+
+ /* System is using a colormap */
+ /* Set the black and white pixel indices */
+ pScreen->whitePixel = uiSystemPaletteEntries - 1;
+ pScreen->blackPixel = 0;
+
+ /* Free colormap */
+ if (ppeColors != NULL)
+ {
+ free (ppeColors);
+ ppeColors = NULL;
+ }
+
+ /* Free the DC */
+ if (hdc != NULL)
+ {
+ ReleaseDC (NULL, hdc);
+ hdc = NULL;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Install the standard fb colormap, or the GDI colormap,
+ * depending on the current screen depth.
+ */
+
+Bool
+winCreateDefColormap (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ unsigned short zero = 0, ones = 0xFFFF;
+ VisualPtr pVisual = pScreenPriv->pRootVisual;
+ ColormapPtr pcmap = NULL;
+ Pixel wp, bp;
+
+#if CYGDEBUG
+ winDebug ("winCreateDefColormap\n");
+#endif
+
+ /* Use standard fb colormaps for non palettized color modes */
+ if (pScreenInfo->dwBPP > 8)
+ {
+ winDebug ("winCreateDefColormap - Deferring to " \
+ "fbCreateDefColormap ()\n");
+ return fbCreateDefColormap (pScreen);
+ }
+
+ /*
+ * AllocAll for non-Dynamic visual classes,
+ * AllocNone for Dynamic visual classes.
+ */
+
+ /*
+ * Dynamic visual classes allow the colors of the color map
+ * to be changed by clients.
+ */
+
+#if CYGDEBUG
+ winDebug ("winCreateDefColormap - defColormap: %d\n",
+ pScreen->defColormap);
+#endif
+
+ /* Allocate an X colormap, owned by client 0 */
+ if (CreateColormap (pScreen->defColormap,
+ pScreen,
+ pVisual,
+ &pcmap,
+ (pVisual->class & DynamicClass) ? AllocNone : AllocAll,
+ 0) != Success)
+ {
+ ErrorF ("winCreateDefColormap - CreateColormap failed\n");
+ return FALSE;
+ }
+ if (pcmap == NULL)
+ {
+ ErrorF ("winCreateDefColormap - Colormap could not be created\n");
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winCreateDefColormap - Created a colormap\n");
+#endif
+
+ /* Branch on the visual class */
+ if (!(pVisual->class & DynamicClass))
+ {
+ /* Branch on engine type */
+ if (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI)
+ {
+ /* Load the colors being used by the Shadow DIB */
+ if (!winGetPaletteDIB (pScreen, pcmap))
+ {
+ ErrorF ("winCreateDefColormap - Couldn't get DIB colors\n");
+ return FALSE;
+ }
+ }
+ else
+ {
+ /* Load the colors from the default system palette */
+ if (!winGetPaletteDD (pScreen, pcmap))
+ {
+ ErrorF ("winCreateDefColormap - Couldn't get colors "
+ "for DD\n");
+ return FALSE;
+ }
+ }
+ }
+ else
+ {
+ wp = pScreen->whitePixel;
+ bp = pScreen->blackPixel;
+
+ /* Allocate a black and white pixel */
+ if ((AllocColor (pcmap, &ones, &ones, &ones, &wp, 0) !=
+ Success)
+ ||
+ (AllocColor (pcmap, &zero, &zero, &zero, &bp, 0) !=
+ Success))
+ {
+ ErrorF ("winCreateDefColormap - Couldn't allocate bp or wp\n");
+ return FALSE;
+ }
+
+ pScreen->whitePixel = wp;
+ pScreen->blackPixel = bp;
+
+#if 0
+ /* Have to reserve first 10 and last ten pixels in DirectDraw windowed */
+ if (pScreenInfo->dwEngine != WIN_SERVER_SHADOW_GDI)
+ {
+ int k;
+ Pixel p;
+
+ for (k = 1; k < 10; ++k)
+ {
+ p = k;
+ if (AllocColor (pcmap, &ones, &ones, &ones, &p, 0) != Success)
+ FatalError ("Foo!\n");
+ }
+
+ for (k = 245; k < 255; ++k)
+ {
+ p = k;
+ if (AllocColor (pcmap, &zero, &zero, &zero, &p, 0) != Success)
+ FatalError ("Baz!\n");
+ }
+ }
+#endif
+ }
+
+ /* Install the created colormap */
+ (*pScreen->InstallColormap)(pcmap);
+
+#if CYGDEBUG
+ winDebug ("winCreateDefColormap - Returning\n");
+#endif
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winconfig.c b/nx-X11/programs/Xserver/hw/xwin/winconfig.c
new file mode 100644
index 000000000..917ce08c0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winconfig.c
@@ -0,0 +1,1185 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Alexander Gottwald
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winconfig.c,v 1.3 2003/10/02 13:30:10 eich Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winconfig.h"
+#include "winmsg.h"
+#include "globals.h"
+
+#ifdef XKB
+#ifndef XKB_IN_SERVER
+#define XKB_IN_SERVER
+#endif
+#include <X11/extensions/XKBsrv.h>
+#endif
+
+#ifdef XWIN_XF86CONFIG
+#ifndef CONFIGPATH
+#define CONFIGPATH "%A," "%R," \
+ "/etc/X11/%R," "%P/etc/X11/%R," \
+ "%E," "%F," \
+ "/etc/X11/%F," "%P/etc/X11/%F," \
+ "%D/%X," \
+ "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
+ "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+ "%P/etc/X11/%X," \
+ "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+ "%P/lib/X11/%X"
+#endif
+
+XF86ConfigPtr g_xf86configptr = NULL;
+#endif
+
+WinCmdlineRec g_cmdline = {
+#ifdef XWIN_XF86CONFIG
+ NULL, /* configFile */
+#endif
+ NULL, /* fontPath */
+ NULL, /* rgbPath */
+#ifdef XWIN_XF86CONFIG
+ NULL, /* keyboard */
+#endif
+#ifdef XKB
+ FALSE, /* noXkbExtension */
+ NULL, /* xkbMap */
+ NULL, /* xkbRules */
+ NULL, /* xkbModel */
+ NULL, /* xkbLayout */
+ NULL, /* xkbVariant */
+ NULL, /* xkbOptions */
+#endif
+ NULL, /* screenname */
+ NULL, /* mousename */
+ FALSE, /* emulate3Buttons */
+ 0 /* emulate3Timeout */
+};
+
+winInfoRec g_winInfo = {
+ { /* keyboard */
+ 0, /* leds */
+ 500, /* delay */
+ 30 /* rate */
+#ifdef XKB
+ }
+ ,
+ { /* xkb */
+ FALSE, /* disable */
+ NULL, /* rules */
+ NULL, /* model */
+ NULL, /* layout */
+ NULL, /* variant */
+ NULL, /* options */
+ NULL, /* initialMap */
+ NULL, /* keymap */
+ NULL, /* types */
+ NULL, /* compat */
+ NULL, /* keycodes */
+ NULL, /* symbols */
+ NULL /* geometry */
+#endif
+ }
+ ,
+ {
+ FALSE,
+ 50}
+};
+
+#define NULL_IF_EMPTY(x) (winNameCompare(x,"")?x:NULL)
+
+#ifdef XWIN_XF86CONFIG
+serverLayoutRec g_winConfigLayout;
+
+static Bool ParseOptionValue (int scrnIndex, pointer options,
+ OptionInfoPtr p);
+static Bool configLayout (serverLayoutPtr, XF86ConfLayoutPtr, char *);
+static Bool configImpliedLayout (serverLayoutPtr, XF86ConfScreenPtr);
+static Bool GetBoolValue (OptionInfoPtr p, const char *s);
+
+
+Bool
+winReadConfigfile ()
+{
+ Bool retval = TRUE;
+ const char *filename;
+ MessageType from = X_DEFAULT;
+ char *xf86ConfigFile = NULL;
+
+ if (g_cmdline.configFile)
+ {
+ from = X_CMDLINE;
+ xf86ConfigFile = g_cmdline.configFile;
+ }
+
+ /* Parse config file into data structure */
+
+ filename = xf86openConfigFile (CONFIGPATH, xf86ConfigFile, PROJECTROOT);
+
+ /* Hack for backward compatibility */
+ if (!filename && from == X_DEFAULT)
+ filename = xf86openConfigFile (CONFIGPATH, "XF86Config", PROJECTROOT);
+
+ if (filename)
+ {
+ winMsg (from, "Using config file: \"%s\"\n", filename);
+ }
+ else
+ {
+ winMsg (X_ERROR, "Unable to locate/open config file");
+ if (xf86ConfigFile)
+ ErrorF (": \"%s\"", xf86ConfigFile);
+ ErrorF ("\n");
+ return FALSE;
+ }
+ if ((g_xf86configptr = xf86readConfigFile ()) == NULL)
+ {
+ winMsg (X_ERROR, "Problem parsing the config file\n");
+ return FALSE;
+ }
+ xf86closeConfigFile ();
+
+ LogPrintMarkers();
+
+ /* set options from data structure */
+
+ if (g_xf86configptr->conf_layout_lst == NULL || g_cmdline.screenname != NULL)
+ {
+ if (g_cmdline.screenname == NULL)
+ {
+ winMsg (X_WARNING,
+ "No Layout section. Using the first Screen section.\n");
+ }
+ if (!configImpliedLayout (&g_winConfigLayout,
+ g_xf86configptr->conf_screen_lst))
+ {
+ winMsg (X_ERROR, "Unable to determine the screen layout\n");
+ return FALSE;
+ }
+ }
+ else
+ {
+ /* Check if layout is given in the config file */
+ if (g_xf86configptr->conf_flags != NULL)
+ {
+ char *dfltlayout = NULL;
+ pointer optlist = g_xf86configptr->conf_flags->flg_option_lst;
+
+ if (optlist && winFindOption (optlist, "defaultserverlayout"))
+ dfltlayout =
+ winSetStrOption (optlist, "defaultserverlayout", NULL);
+
+ if (!configLayout (&g_winConfigLayout,
+ g_xf86configptr->conf_layout_lst,
+ dfltlayout))
+ {
+ winMsg (X_ERROR, "Unable to determine the screen layout\n");
+ return FALSE;
+ }
+ }
+ else
+ {
+ if (!configLayout (&g_winConfigLayout,
+ g_xf86configptr->conf_layout_lst,
+ NULL))
+ {
+ winMsg (X_ERROR, "Unable to determine the screen layout\n");
+ return FALSE;
+ }
+ }
+ }
+
+ /* setup special config files */
+ winConfigFiles ();
+ return retval;
+}
+#endif
+
+/* load layout definitions */
+#include "winlayouts.h"
+
+/* Set the keyboard configuration */
+Bool
+winConfigKeyboard (DeviceIntPtr pDevice)
+{
+#ifdef XKB
+ char layoutName[KL_NAMELENGTH];
+ static unsigned int layoutNum = 0;
+ int keyboardType;
+#endif
+#ifdef XWIN_XF86CONFIG
+ XF86ConfInputPtr kbd = NULL;
+ XF86ConfInputPtr input_list = NULL;
+ MessageType kbdfrom = X_CONFIG;
+#endif
+ MessageType from = X_DEFAULT;
+ char *s = NULL;
+
+ /* Setup defaults */
+#ifdef XKB
+ g_winInfo.xkb.disable = FALSE;
+# ifdef PC98 /* japanese */ /* not implemented */
+ g_winInfo.xkb.rules = "xfree98";
+ g_winInfo.xkb.model = "pc98";
+ g_winInfo.xkb.layout = "nex/jp";
+ g_winInfo.xkb.variant = NULL;
+ g_winInfo.xkb.options = NULL;
+# else
+ g_winInfo.xkb.rules = "xorg";
+ g_winInfo.xkb.model = "pc101";
+ g_winInfo.xkb.layout = "us";
+ g_winInfo.xkb.variant = NULL;
+ g_winInfo.xkb.options = NULL;
+# endif /* PC98 */
+
+ /*
+ * Query the windows autorepeat settings and change the xserver defaults.
+ * If XKB is disabled then windows handles the autorepeat and the special
+ * treatment is not needed
+ */
+ {
+ int kbd_delay;
+ DWORD kbd_speed;
+ if (SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &kbd_delay, 0) &&
+ SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &kbd_speed, 0))
+ {
+ switch (kbd_delay)
+ {
+ case 0: g_winInfo.keyboard.delay = 250; break;
+ case 1: g_winInfo.keyboard.delay = 500; break;
+ case 2: g_winInfo.keyboard.delay = 750; break;
+ default:
+ case 3: g_winInfo.keyboard.delay = 1000; break;
+ }
+ g_winInfo.keyboard.rate = (kbd_speed>0)?kbd_speed:1;
+ winMsgVerb(X_PROBED, 1, "Setting autorepeat to delay=%d, rate=%d\n",
+ g_winInfo.keyboard.delay, g_winInfo.keyboard.rate);
+ }
+ }
+
+
+ keyboardType = GetKeyboardType (0);
+ if (keyboardType > 0 && GetKeyboardLayoutName (layoutName))
+ {
+ WinKBLayoutPtr pLayout;
+ Bool bfound = FALSE;
+
+ if (! layoutNum)
+ layoutNum = strtoul (layoutName, (char **)NULL, 16);
+ if ((layoutNum & 0xffff) == 0x411) {
+ /* The japanese layouts know a lot of different IMEs which all have
+ different layout numbers set. Map them to a single entry.
+ Same might apply for chinese, korean and other symbol languages
+ too */
+ layoutNum = (layoutNum & 0xffff);
+ if (keyboardType == 7)
+ {
+ /* Japanese layouts have problems with key event messages
+ such as the lack of WM_KEYUP for Caps Lock key.
+ Loading US layout fixes this problem. */
+ if (LoadKeyboardLayout("00000409", KLF_ACTIVATE) != NULL)
+ winMsg (X_INFO, "Loading US keyboard layout.\n");
+ else
+ winMsg (X_ERROR, "LoadKeyboardLaout failed.\n");
+ }
+ }
+ winMsg (X_PROBED, "winConfigKeyboard - Layout: \"%s\" (%08x) \n",
+ layoutName, layoutNum);
+
+ for (pLayout = winKBLayouts; pLayout->winlayout != -1; pLayout++)
+ {
+ if (pLayout->winlayout != layoutNum)
+ continue;
+ if (pLayout->winkbtype > 0 && pLayout->winkbtype != keyboardType)
+ continue;
+
+ bfound = TRUE;
+ winMsg (X_PROBED,
+ "Using preset keyboard for \"%s\" (%x), type \"%d\"\n",
+ pLayout->layoutname, pLayout->winlayout, keyboardType);
+
+ g_winInfo.xkb.model = pLayout->xkbmodel;
+ g_winInfo.xkb.layout = pLayout->xkblayout;
+ g_winInfo.xkb.variant = pLayout->xkbvariant;
+ g_winInfo.xkb.options = pLayout->xkboptions;
+ break;
+ }
+
+ if (!bfound)
+ {
+ HKEY regkey = NULL;
+ const char regtempl[] =
+ "SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\";
+ char *regpath;
+ char lname[256];
+ DWORD namesize = sizeof(lname);
+
+ regpath = malloc(sizeof(regtempl) + KL_NAMELENGTH + 1);
+ strcpy(regpath, regtempl);
+ strcat(regpath, layoutName);
+
+ if (!RegOpenKey(HKEY_LOCAL_MACHINE, regpath, &regkey) &&
+ !RegQueryValueEx(regkey, "Layout Text", 0, NULL, lname, &namesize))
+ {
+ winMsg (X_ERROR,
+ "Keyboardlayout \"%s\" (%s) is unknown\n", lname, layoutName);
+ }
+
+ /* Close registry key */
+ if (regkey)
+ RegCloseKey (regkey);
+ free(regpath);
+ }
+ }
+
+ g_winInfo.xkb.initialMap = NULL;
+ g_winInfo.xkb.keymap = NULL;
+ g_winInfo.xkb.types = NULL;
+ g_winInfo.xkb.compat = NULL;
+ g_winInfo.xkb.keycodes = NULL;
+ g_winInfo.xkb.symbols = NULL;
+ g_winInfo.xkb.geometry = NULL;
+#endif /* XKB */
+
+ /* parse the configuration */
+#ifdef XWIN_XF86CONFIG
+ if (g_cmdline.keyboard)
+ kbdfrom = X_CMDLINE;
+
+ /*
+ * Until the layout code is finished, I search for the keyboard
+ * device and configure the server with it.
+ */
+
+ if (g_xf86configptr != NULL)
+ input_list = g_xf86configptr->conf_input_lst;
+
+ while (input_list != NULL)
+ {
+ if (winNameCompare (input_list->inp_driver, "keyboard") == 0)
+ {
+ /* Check if device name matches requested name */
+ if (g_cmdline.keyboard && winNameCompare (input_list->inp_identifier,
+ g_cmdline.keyboard))
+ continue;
+ kbd = input_list;
+ }
+ input_list = input_list->list.next;
+ }
+
+ if (kbd != NULL)
+ {
+
+ if (kbd->inp_identifier)
+ winMsg (kbdfrom, "Using keyboard \"%s\" as primary keyboard\n",
+ kbd->inp_identifier);
+
+ if ((s = winSetStrOption(kbd->inp_option_lst, "AutoRepeat", NULL)))
+ {
+ if ((sscanf(s, "%ld %ld", &g_winInfo.keyboard.delay,
+ &g_winInfo.keyboard.rate) != 2) ||
+ (g_winInfo.keyboard.delay < 1) ||
+ (g_winInfo.keyboard.rate == 0) ||
+ (1000 / g_winInfo.keyboard.rate) < 1)
+ {
+ winErrorFVerb (2, "\"%s\" is not a valid AutoRepeat value", s);
+ xfree(s);
+ return FALSE;
+ }
+ xfree(s);
+ winMsg (X_CONFIG, "AutoRepeat: %ld %ld\n",
+ g_winInfo.keyboard.delay, g_winInfo.keyboard.rate);
+ }
+#endif
+
+#ifdef XKB
+ from = X_DEFAULT;
+ if (g_cmdline.noXkbExtension)
+ {
+ from = X_CMDLINE;
+ g_winInfo.xkb.disable = TRUE;
+ }
+#ifdef XWIN_XF86CONFIG
+ else if (kbd->inp_option_lst)
+ {
+ int b = winSetBoolOption (kbd->inp_option_lst, "XkbDisable", FALSE);
+ if (b)
+ {
+ from = X_CONFIG;
+ g_winInfo.xkb.disable = TRUE;
+ }
+ }
+#endif
+ if (g_winInfo.xkb.disable)
+ {
+ winMsg (from, "XkbExtension disabled\n");
+ }
+ else
+ {
+ s = NULL;
+ if (g_cmdline.xkbRules)
+ {
+ s = g_cmdline.xkbRules;
+ from = X_CMDLINE;
+ }
+#ifdef XWIN_XF86CONFIG
+ else
+ {
+ s = winSetStrOption (kbd->inp_option_lst, "XkbRules", NULL);
+ from = X_CONFIG;
+ }
+#endif
+ if (s)
+ {
+ g_winInfo.xkb.rules = NULL_IF_EMPTY (s);
+ winMsg (from, "XKB: rules: \"%s\"\n", s);
+ }
+
+ s = NULL;
+ if (g_cmdline.xkbModel)
+ {
+ s = g_cmdline.xkbModel;
+ from = X_CMDLINE;
+ }
+#ifdef XWIN_XF86CONFIG
+ else
+ {
+ s = winSetStrOption (kbd->inp_option_lst, "XkbModel", NULL);
+ from = X_CONFIG;
+ }
+#endif
+ if (s)
+ {
+ g_winInfo.xkb.model = NULL_IF_EMPTY (s);
+ winMsg (from, "XKB: model: \"%s\"\n", s);
+ }
+
+ s = NULL;
+ if (g_cmdline.xkbLayout)
+ {
+ s = g_cmdline.xkbLayout;
+ from = X_CMDLINE;
+ }
+#ifdef XWIN_XF86CONFIG
+ else
+ {
+ s = winSetStrOption (kbd->inp_option_lst, "XkbLayout", NULL);
+ from = X_CONFIG;
+ }
+#endif
+ if (s)
+ {
+ g_winInfo.xkb.layout = NULL_IF_EMPTY (s);
+ winMsg (from, "XKB: layout: \"%s\"\n", s);
+ }
+
+ s = NULL;
+ if (g_cmdline.xkbVariant)
+ {
+ s = g_cmdline.xkbVariant;
+ from = X_CMDLINE;
+ }
+#ifdef XWIN_XF86CONFIG
+ else
+ {
+ s = winSetStrOption (kbd->inp_option_lst, "XkbVariant", NULL);
+ from = X_CONFIG;
+ }
+#endif
+ if (s)
+ {
+ g_winInfo.xkb.variant = NULL_IF_EMPTY (s);
+ winMsg (from, "XKB: variant: \"%s\"\n", s);
+ }
+
+ s = NULL;
+ if (g_cmdline.xkbOptions)
+ {
+ s = g_cmdline.xkbOptions;
+ from = X_CMDLINE;
+ }
+#ifdef XWIN_XF86CONFIG
+ else
+ {
+ s = winSetStrOption (kbd->inp_option_lst, "XkbOptions", NULL);
+ from = X_CONFIG;
+ }
+#endif
+ if (s)
+ {
+ g_winInfo.xkb.options = NULL_IF_EMPTY (s);
+ winMsg (from, "XKB: options: \"%s\"\n", s);
+ }
+
+#ifdef XWIN_XF86CONFIG
+ from = X_CMDLINE;
+ if (!XkbInitialMap)
+ {
+ s =
+ winSetStrOption (kbd->inp_option_lst, "XkbInitialMap", NULL);
+ if (s)
+ {
+ XkbInitialMap = NULL_IF_EMPTY (s);
+ from = X_CONFIG;
+ }
+ }
+
+ if ((s = winSetStrOption (kbd->inp_option_lst, "XkbKeymap", NULL)))
+ {
+ g_winInfo.xkb.keymap = NULL_IF_EMPTY (s);
+ winMsg (X_CONFIG, "XKB: keymap: \"%s\" "
+ " (overrides other XKB settings)\n", s);
+ }
+
+ if ((s = winSetStrOption (kbd->inp_option_lst, "XkbCompat", NULL)))
+ {
+ g_winInfo.xkb.compat = NULL_IF_EMPTY (s);
+ winMsg (X_CONFIG, "XKB: compat: \"%s\"\n", s);
+ }
+
+ if ((s = winSetStrOption (kbd->inp_option_lst, "XkbTypes", NULL)))
+ {
+ g_winInfo.xkb.types = NULL_IF_EMPTY (s);
+ winMsg (X_CONFIG, "XKB: types: \"%s\"\n", s);
+ }
+
+ if ((s =
+ winSetStrOption (kbd->inp_option_lst, "XkbKeycodes", NULL)))
+ {
+ g_winInfo.xkb.keycodes = NULL_IF_EMPTY (s);
+ winMsg (X_CONFIG, "XKB: keycodes: \"%s\"\n", s);
+ }
+
+ if ((s =
+ winSetStrOption (kbd->inp_option_lst, "XkbGeometry", NULL)))
+ {
+ g_winInfo.xkb.geometry = NULL_IF_EMPTY (s);
+ winMsg (X_CONFIG, "XKB: geometry: \"%s\"\n", s);
+ }
+
+ if ((s = winSetStrOption (kbd->inp_option_lst, "XkbSymbols", NULL)))
+ {
+ g_winInfo.xkb.symbols = NULL_IF_EMPTY (s);
+ winMsg (X_CONFIG, "XKB: symbols: \"%s\"\n", s);
+ }
+#endif
+#endif
+ }
+#ifdef XWIN_XF86CONFIG
+ }
+#endif
+
+ return TRUE;
+}
+
+
+#ifdef XWIN_XF86CONFIG
+Bool
+winConfigMouse (DeviceIntPtr pDevice)
+{
+ MessageType mousefrom = X_CONFIG;
+
+ XF86ConfInputPtr mouse = NULL;
+ XF86ConfInputPtr input_list = NULL;
+
+ if (g_cmdline.mouse)
+ mousefrom = X_CMDLINE;
+
+ if (g_xf86configptr != NULL)
+ input_list = g_xf86configptr->conf_input_lst;
+
+ while (input_list != NULL)
+ {
+ if (winNameCompare (input_list->inp_driver, "mouse") == 0)
+ {
+ /* Check if device name matches requested name */
+ if (g_cmdline.mouse && winNameCompare (input_list->inp_identifier,
+ g_cmdline.mouse))
+ continue;
+ mouse = input_list;
+ }
+ input_list = input_list->list.next;
+ }
+
+ if (mouse != NULL)
+ {
+ if (mouse->inp_identifier)
+ winMsg (mousefrom, "Using pointer \"%s\" as primary pointer\n",
+ mouse->inp_identifier);
+
+ g_winInfo.pointer.emulate3Buttons =
+ winSetBoolOption (mouse->inp_option_lst, "Emulate3Buttons", FALSE);
+ if (g_cmdline.emulate3buttons)
+ g_winInfo.pointer.emulate3Buttons = g_cmdline.emulate3buttons;
+
+ g_winInfo.pointer.emulate3Timeout =
+ winSetIntOption (mouse->inp_option_lst, "Emulate3Timeout", 50);
+ if (g_cmdline.emulate3timeout)
+ g_winInfo.pointer.emulate3Timeout = g_cmdline.emulate3timeout;
+ }
+ else
+ {
+ winMsg (X_ERROR, "No primary pointer configured\n");
+ winMsg (X_DEFAULT, "Using compiletime defaults for pointer\n");
+ }
+
+ return TRUE;
+}
+
+
+Bool
+winConfigFiles ()
+{
+ MessageType from;
+ XF86ConfFilesPtr filesptr = NULL;
+
+ /* set some shortcuts */
+ if (g_xf86configptr != NULL)
+ {
+ filesptr = g_xf86configptr->conf_files;
+ }
+
+
+ /* Fontpath */
+ from = X_DEFAULT;
+
+ if (g_cmdline.fontPath)
+ {
+ from = X_CMDLINE;
+ defaultFontPath = g_cmdline.fontPath;
+ }
+ else if (filesptr != NULL && filesptr->file_fontpath)
+ {
+ from = X_CONFIG;
+ defaultFontPath = xstrdup (filesptr->file_fontpath);
+ }
+ winMsg (from, "FontPath set to \"%s\"\n", defaultFontPath);
+
+ /* RGBPath */
+ from = X_DEFAULT;
+ if (g_cmdline.rgbPath)
+ {
+ from = X_CMDLINE;
+ rgbPath = g_cmdline.rgbPath;
+ }
+ else if (filesptr != NULL && filesptr->file_rgbpath)
+ {
+ from = X_CONFIG;
+ rgbPath = xstrdup (filesptr->file_rgbpath);
+ }
+ winMsg (from, "RgbPath set to \"%s\"\n", rgbPath);
+
+ return TRUE;
+}
+#else
+Bool
+winConfigFiles ()
+{
+ MessageType from;
+
+ /* Fontpath */
+ if (g_cmdline.fontPath)
+ {
+ defaultFontPath = g_cmdline.fontPath;
+ winMsg (X_CMDLINE, "FontPath set to \"%s\"\n", defaultFontPath);
+ }
+
+ /* RGBPath */
+ if (g_cmdline.rgbPath)
+ {
+ from = X_CMDLINE;
+ rgbPath = g_cmdline.rgbPath;
+ winMsg (X_CMDLINE, "RgbPath set to \"%s\"\n", rgbPath);
+ }
+
+ return TRUE;
+}
+#endif
+
+
+Bool
+winConfigOptions ()
+{
+ return TRUE;
+}
+
+
+Bool
+winConfigScreens ()
+{
+ return TRUE;
+}
+
+
+#ifdef XWIN_XF86CONFIG
+char *
+winSetStrOption (pointer optlist, const char *name, char *deflt)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_STRING;
+ if (ParseOptionValue (-1, optlist, &o))
+ deflt = o.value.str;
+ if (deflt)
+ return xstrdup (deflt);
+ else
+ return NULL;
+}
+
+
+int
+winSetBoolOption (pointer optlist, const char *name, int deflt)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_BOOLEAN;
+ if (ParseOptionValue (-1, optlist, &o))
+ deflt = o.value.bool;
+ return deflt;
+}
+
+
+int
+winSetIntOption (pointer optlist, const char *name, int deflt)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_INTEGER;
+ if (ParseOptionValue (-1, optlist, &o))
+ deflt = o.value.num;
+ return deflt;
+}
+
+
+double
+winSetRealOption (pointer optlist, const char *name, double deflt)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_REAL;
+ if (ParseOptionValue (-1, optlist, &o))
+ deflt = o.value.realnum;
+ return deflt;
+}
+#endif
+
+
+/*
+ * Compare two strings for equality. This is caseinsensitive and
+ * The characters '_', ' ' (space) and '\t' (tab) are treated as
+ * not existing.
+ */
+
+int
+winNameCompare (const char *s1, const char *s2)
+{
+ char c1, c2;
+
+ if (!s1 || *s1 == 0)
+ {
+ if (!s2 || *s2 == 0)
+ return 0;
+ else
+ return 1;
+ }
+
+ while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+ s1++;
+ while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+ s2++;
+
+ c1 = (isupper (*s1) ? tolower (*s1) : *s1);
+ c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+
+ while (c1 == c2)
+ {
+ if (c1 == 0)
+ return 0;
+ s1++;
+ s2++;
+
+ while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+ s1++;
+ while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+ s2++;
+
+ c1 = (isupper (*s1) ? tolower (*s1) : *s1);
+ c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+ }
+ return (c1 - c2);
+}
+
+
+#ifdef XWIN_XF86CONFIG
+/*
+ * Find the named option in the list.
+ * @return the pointer to the option record, or NULL if not found.
+ */
+
+XF86OptionPtr
+winFindOption (XF86OptionPtr list, const char *name)
+{
+ while (list)
+ {
+ if (winNameCompare (list->opt_name, name) == 0)
+ return list;
+ list = list->list.next;
+ }
+ return NULL;
+}
+
+
+/*
+ * Find the Value of an named option.
+ * @return The option value or NULL if not found.
+ */
+
+char *
+winFindOptionValue (XF86OptionPtr list, const char *name)
+{
+ list = winFindOption (list, name);
+ if (list)
+ {
+ if (list->opt_val)
+ return (list->opt_val);
+ else
+ return "";
+ }
+ return (NULL);
+}
+
+
+/*
+ * Parse the option.
+ */
+
+static Bool
+ParseOptionValue (int scrnIndex, pointer options, OptionInfoPtr p)
+{
+ char *s, *end;
+
+ if ((s = winFindOptionValue (options, p->name)) != NULL)
+ {
+ switch (p->type)
+ {
+ case OPTV_INTEGER:
+ if (*s == '\0')
+ {
+ winDrvMsg (scrnIndex, X_WARNING,
+ "Option \"%s\" requires an integer value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ else
+ {
+ p->value.num = strtoul (s, &end, 0);
+ if (*end == '\0')
+ {
+ p->found = TRUE;
+ }
+ else
+ {
+ winDrvMsg (scrnIndex, X_WARNING,
+ "Option \"%s\" requires an integer value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ }
+ break;
+ case OPTV_STRING:
+ if (*s == '\0')
+ {
+ winDrvMsg (scrnIndex, X_WARNING,
+ "Option \"%s\" requires an string value\n", p->name);
+ p->found = FALSE;
+ }
+ else
+ {
+ p->value.str = s;
+ p->found = TRUE;
+ }
+ break;
+ case OPTV_ANYSTR:
+ p->value.str = s;
+ p->found = TRUE;
+ break;
+ case OPTV_REAL:
+ if (*s == '\0')
+ {
+ winDrvMsg (scrnIndex, X_WARNING,
+ "Option \"%s\" requires a floating point value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ else
+ {
+ p->value.realnum = strtod (s, &end);
+ if (*end == '\0')
+ {
+ p->found = TRUE;
+ }
+ else
+ {
+ winDrvMsg (scrnIndex, X_WARNING,
+ "Option \"%s\" requires a floating point value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ }
+ break;
+ case OPTV_BOOLEAN:
+ if (GetBoolValue (p, s))
+ {
+ p->found = TRUE;
+ }
+ else
+ {
+ winDrvMsg (scrnIndex, X_WARNING,
+ "Option \"%s\" requires a boolean value\n", p->name);
+ p->found = FALSE;
+ }
+ break;
+ case OPTV_FREQ:
+ if (*s == '\0')
+ {
+ winDrvMsg (scrnIndex, X_WARNING,
+ "Option \"%s\" requires a frequency value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ else
+ {
+ double freq = strtod (s, &end);
+ int units = 0;
+
+ if (end != s)
+ {
+ p->found = TRUE;
+ if (!winNameCompare (end, "Hz"))
+ units = 1;
+ else if (!winNameCompare (end, "kHz") ||
+ !winNameCompare (end, "k"))
+ units = 1000;
+ else if (!winNameCompare (end, "MHz") ||
+ !winNameCompare (end, "M"))
+ units = 1000000;
+ else
+ {
+ winDrvMsg (scrnIndex, X_WARNING,
+ "Option \"%s\" requires a frequency value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ if (p->found)
+ freq *= (double) units;
+ }
+ else
+ {
+ winDrvMsg (scrnIndex, X_WARNING,
+ "Option \"%s\" requires a frequency value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ if (p->found)
+ {
+ p->value.freq.freq = freq;
+ p->value.freq.units = units;
+ }
+ }
+ break;
+ case OPTV_NONE:
+ /* Should never get here */
+ p->found = FALSE;
+ break;
+ }
+ if (p->found)
+ {
+ winDrvMsgVerb (scrnIndex, X_CONFIG, 2, "Option \"%s\"", p->name);
+ if (!(p->type == OPTV_BOOLEAN && *s == 0))
+ {
+ winErrorFVerb (2, " \"%s\"", s);
+ }
+ winErrorFVerb (2, "\n");
+ }
+ }
+ else if (p->type == OPTV_BOOLEAN)
+ {
+ /* Look for matches with options with or without a "No" prefix. */
+ char *n, *newn;
+ OptionInfoRec opt;
+
+ n = winNormalizeName (p->name);
+ if (!n)
+ {
+ p->found = FALSE;
+ return FALSE;
+ }
+ if (strncmp (n, "no", 2) == 0)
+ {
+ newn = n + 2;
+ }
+ else
+ {
+ free (n);
+ n = malloc (strlen (p->name) + 2 + 1);
+ if (!n)
+ {
+ p->found = FALSE;
+ return FALSE;
+ }
+ strcpy (n, "No");
+ strcat (n, p->name);
+ newn = n;
+ }
+ if ((s = winFindOptionValue (options, newn)) != NULL)
+ {
+ if (GetBoolValue (&opt, s))
+ {
+ p->value.bool = !opt.value.bool;
+ p->found = TRUE;
+ }
+ else
+ {
+ winDrvMsg (scrnIndex, X_WARNING,
+ "Option \"%s\" requires a boolean value\n", newn);
+ p->found = FALSE;
+ }
+ }
+ else
+ {
+ p->found = FALSE;
+ }
+ if (p->found)
+ {
+ winDrvMsgVerb (scrnIndex, X_CONFIG, 2, "Option \"%s\"", newn);
+ if (*s != 0)
+ {
+ winErrorFVerb (2, " \"%s\"", s);
+ }
+ winErrorFVerb (2, "\n");
+ }
+ free (n);
+ }
+ else
+ {
+ p->found = FALSE;
+ }
+ return p->found;
+}
+
+
+static Bool
+configLayout (serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
+ char *default_layout)
+{
+#if 0
+#pragma warn UNIMPLEMENTED
+#endif
+ return TRUE;
+}
+
+
+static Bool
+configImpliedLayout (serverLayoutPtr servlayoutp,
+ XF86ConfScreenPtr conf_screen)
+{
+#if 0
+#pragma warn UNIMPLEMENTED
+#endif
+ return TRUE;
+}
+
+
+static Bool
+GetBoolValue (OptionInfoPtr p, const char *s)
+{
+ if (*s == 0)
+ {
+ p->value.bool = TRUE;
+ }
+ else
+ {
+ if (winNameCompare (s, "1") == 0)
+ p->value.bool = TRUE;
+ else if (winNameCompare (s, "on") == 0)
+ p->value.bool = TRUE;
+ else if (winNameCompare (s, "true") == 0)
+ p->value.bool = TRUE;
+ else if (winNameCompare (s, "yes") == 0)
+ p->value.bool = TRUE;
+ else if (winNameCompare (s, "0") == 0)
+ p->value.bool = FALSE;
+ else if (winNameCompare (s, "off") == 0)
+ p->value.bool = FALSE;
+ else if (winNameCompare (s, "false") == 0)
+ p->value.bool = FALSE;
+ else if (winNameCompare (s, "no") == 0)
+ p->value.bool = FALSE;
+ }
+ return TRUE;
+}
+#endif
+
+
+char *
+winNormalizeName (const char *s)
+{
+ char *ret, *q;
+ const char *p;
+
+ if (s == NULL)
+ return NULL;
+
+ ret = malloc (strlen (s) + 1);
+ for (p = s, q = ret; *p != 0; p++)
+ {
+ switch (*p)
+ {
+ case '_':
+ case ' ':
+ case '\t':
+ continue;
+ default:
+ if (isupper (*p))
+ *q++ = tolower (*p);
+ else
+ *q++ = *p;
+ }
+ }
+ *q = '\0';
+ return ret;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xwin/winconfig.h b/nx-X11/programs/Xserver/hw/xwin/winconfig.h
new file mode 100644
index 000000000..46990ba09
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winconfig.h
@@ -0,0 +1,345 @@
+#ifndef __WIN_CONFIG_H__
+#define __WIN_CONFIG_H__
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Alexander Gottwald
+ */
+/* $Id: winconfig.h,v 1.4 2005/07/01 22:43:40 daniels Exp $ */
+
+#include "win.h"
+#ifdef XWIN_XF86CONFIG
+#include "../xfree86/parser/xf86Parser.h"
+#endif
+
+
+/* These are taken from hw/xfree86/common/xf86str.h */
+
+typedef struct
+{
+ CARD32 red, green, blue;
+}
+rgb;
+
+
+typedef struct
+{
+ float red, green, blue;
+}
+Gamma;
+
+
+typedef struct
+{
+ char *identifier;
+ char *vendor;
+ char *board;
+ char *chipset;
+ char *ramdac;
+ char *driver;
+ struct _confscreenrec *myScreenSection;
+ Bool claimed;
+ Bool active;
+ Bool inUse;
+ int videoRam;
+ int textClockFreq;
+ pointer options;
+ int screen; /* For multi-CRTC cards */
+}
+GDevRec, *GDevPtr;
+
+
+typedef struct
+{
+ char *identifier;
+ char *driver;
+ pointer commonOptions;
+ pointer extraOptions;
+}
+IDevRec, *IDevPtr;
+
+
+typedef struct
+{
+ int frameX0;
+ int frameY0;
+ int virtualX;
+ int virtualY;
+ int depth;
+ int fbbpp;
+ rgb weight;
+ rgb blackColour;
+ rgb whiteColour;
+ int defaultVisual;
+ char **modes;
+ pointer options;
+}
+DispRec, *DispPtr;
+
+
+typedef struct _confxvportrec
+{
+ char *identifier;
+ pointer options;
+}
+confXvPortRec, *confXvPortPtr;
+
+
+typedef struct _confxvadaptrec
+{
+ char *identifier;
+ int numports;
+ confXvPortPtr ports;
+ pointer options;
+}
+confXvAdaptorRec, *confXvAdaptorPtr;
+
+
+typedef struct _confscreenrec
+{
+ char *id;
+ int screennum;
+ int defaultdepth;
+ int defaultbpp;
+ int defaultfbbpp;
+ GDevPtr device;
+ int numdisplays;
+ DispPtr displays;
+ int numxvadaptors;
+ confXvAdaptorPtr xvadaptors;
+ pointer options;
+}
+confScreenRec, *confScreenPtr;
+
+
+typedef enum
+{
+ PosObsolete = -1,
+ PosAbsolute = 0,
+ PosRightOf,
+ PosLeftOf,
+ PosAbove,
+ PosBelow,
+ PosRelative
+}
+PositionType;
+
+
+typedef struct _screenlayoutrec
+{
+ confScreenPtr screen;
+ char *topname;
+ confScreenPtr top;
+ char *bottomname;
+ confScreenPtr bottom;
+ char *leftname;
+ confScreenPtr left;
+ char *rightname;
+ confScreenPtr right;
+ PositionType where;
+ int x;
+ int y;
+ char *refname;
+ confScreenPtr refscreen;
+}
+screenLayoutRec, *screenLayoutPtr;
+
+
+typedef struct _serverlayoutrec
+{
+ char *id;
+ screenLayoutPtr screens;
+ GDevPtr inactives;
+ IDevPtr inputs;
+ pointer options;
+}
+serverLayoutRec, *serverLayoutPtr;
+
+
+/*
+ * winconfig.c
+ */
+
+typedef struct
+{
+ /* Files */
+#ifdef XWIN_XF86CONFIG
+ char *configFile;
+#endif
+ char *fontPath;
+ char *rgbPath;
+ /* input devices - keyboard */
+#ifdef XWIN_XF86CONFIG
+ char *keyboard;
+#endif
+#ifdef XKB
+ Bool noXkbExtension;
+ char *xkbMap;
+ char *xkbRules;
+ char *xkbModel;
+ char *xkbLayout;
+ char *xkbVariant;
+ char *xkbOptions;
+#endif
+ /* layout */
+ char *screenname;
+ /* mouse settings */
+ char *mouse;
+ Bool emulate3buttons;
+ long emulate3timeout;
+}
+WinCmdlineRec, *WinCmdlinePtr;
+
+
+extern WinCmdlineRec g_cmdline;
+#ifdef XWIN_XF86CONFIG
+extern XF86ConfigPtr g_xf86configptr;
+#endif
+extern serverLayoutRec g_winConfigLayout;
+
+
+/*
+ * Function prototypes
+ */
+
+Bool winReadConfigfile (void);
+Bool winConfigFiles (void);
+Bool winConfigOptions (void);
+Bool winConfigScreens (void);
+Bool winConfigKeyboard (DeviceIntPtr pDevice);
+Bool winConfigMouse (DeviceIntPtr pDevice);
+
+
+typedef struct
+{
+ double freq;
+ int units;
+}
+OptFrequency;
+
+
+typedef union
+{
+ unsigned long num;
+ char *str;
+ double realnum;
+ Bool bool;
+ OptFrequency freq;
+}
+ValueUnion;
+
+
+typedef enum
+{
+ OPTV_NONE = 0,
+ OPTV_INTEGER,
+ OPTV_STRING, /* a non-empty string */
+ OPTV_ANYSTR, /* Any string, including an empty one */
+ OPTV_REAL,
+ OPTV_BOOLEAN,
+ OPTV_FREQ
+}
+OptionValueType;
+
+
+typedef enum
+{
+ OPTUNITS_HZ = 1,
+ OPTUNITS_KHZ,
+ OPTUNITS_MHZ
+}
+OptFreqUnits;
+
+
+typedef struct
+{
+ int token;
+ const char *name;
+ OptionValueType type;
+ ValueUnion value;
+ Bool found;
+}
+OptionInfoRec, *OptionInfoPtr;
+
+
+/*
+ * Function prototypes
+ */
+
+char *winSetStrOption (pointer optlist, const char *name, char *deflt);
+int winSetBoolOption (pointer optlist, const char *name, int deflt);
+int winSetIntOption (pointer optlist, const char *name, int deflt);
+double winSetRealOption (pointer optlist, const char *name, double deflt);
+#ifdef XWIN_XF86CONFIG
+XF86OptionPtr winFindOption (XF86OptionPtr list, const char *name);
+char *winFindOptionValue (XF86OptionPtr list, const char *name);
+#endif
+int winNameCompare (const char *s1, const char *s2);
+char *winNormalizeName (const char *s);
+
+
+typedef struct
+{
+ struct
+ {
+ long leds;
+ long delay;
+ long rate;
+ }
+ keyboard;
+#ifdef XKB
+ struct
+ {
+ Bool disable;
+ char *rules;
+ char *model;
+ char *layout;
+ char *variant;
+ char *options;
+ char *initialMap;
+ char *keymap;
+ char *types;
+ char *compat;
+ char *keycodes;
+ char *symbols;
+ char *geometry;
+ }
+ xkb;
+#endif
+ struct
+ {
+ Bool emulate3Buttons;
+ long emulate3Timeout;
+ }
+ pointer;
+}
+winInfoRec, *winInfoPtr;
+
+
+extern winInfoRec g_winInfo;
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/wincreatewnd.c b/nx-X11/programs/Xserver/hw/xwin/wincreatewnd.c
new file mode 100644
index 000000000..7c93e4063
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/wincreatewnd.c
@@ -0,0 +1,642 @@
+/*
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "shellapi.h"
+
+#ifndef ABS_AUTOHIDE
+#define ABS_AUTOHIDE 1
+#endif
+
+/*
+ * Local function prototypes
+ */
+
+static Bool
+winGetWorkArea (RECT *prcWorkArea, winScreenInfo *pScreenInfo);
+
+static Bool
+winAdjustForAutoHide (RECT *prcWorkArea);
+
+
+/*
+ * Create a full screen window
+ */
+
+Bool
+winCreateBoundingWindowFullScreen (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ int iWidth = pScreenInfo->dwWidth;
+ int iHeight = pScreenInfo->dwHeight;
+ HWND *phwnd = &pScreenPriv->hwndScreen;
+ WNDCLASS wc;
+ char szTitle[256];
+
+#if CYGDEBUG
+ winDebug ("winCreateBoundingWindowFullScreen\n");
+#endif
+
+ /* Setup our window class */
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = winWindowProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = g_hInstance;
+ wc.hIcon = LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN));
+ wc.hCursor = 0;
+ wc.hbrBackground = 0;
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = WINDOW_CLASS;
+ RegisterClass (&wc);
+
+ /* Set display and screen-specific tooltip text */
+ if (g_pszQueryHost != NULL)
+ snprintf (szTitle,
+ sizeof (szTitle),
+ WINDOW_TITLE_XDMCP,
+ g_pszQueryHost);
+ else
+ snprintf (szTitle,
+ sizeof (szTitle),
+ WINDOW_TITLE,
+ display,
+ (int) pScreenInfo->dwScreen);
+
+ /* Create the window */
+ *phwnd = CreateWindowExA (0, /* Extended styles */
+ WINDOW_CLASS, /* Class name */
+ szTitle, /* Window name */
+ WS_POPUP,
+ 0, /* Horizontal position */
+ 0, /* Vertical position */
+ iWidth, /* Right edge */
+ iHeight, /* Bottom edge */
+ (HWND) NULL, /* No parent or owner window */
+ (HMENU) NULL, /* No menu */
+ GetModuleHandle (NULL),/* Instance handle */
+ pScreenPriv); /* ScreenPrivates */
+
+ /* Branch on the server engine */
+ switch (pScreenInfo->dwEngine)
+ {
+#ifdef XWIN_NATIVEGDI
+ case WIN_SERVER_SHADOW_GDI:
+ /* Show the window */
+ ShowWindow (*phwnd, SW_SHOWMAXIMIZED);
+ break;
+#endif
+
+ default:
+ /* Hide the window */
+ ShowWindow (*phwnd, SW_SHOWNORMAL);
+ break;
+ }
+
+ /* Send first paint message */
+ UpdateWindow (*phwnd);
+
+ /* Attempt to bring our window to the top of the display */
+ BringWindowToTop (*phwnd);
+
+ return TRUE;
+}
+
+
+/*
+ * Create our primary Windows display window
+ */
+
+Bool
+winCreateBoundingWindowWindowed (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ int iWidth = pScreenInfo->dwUserWidth;
+ int iHeight = pScreenInfo->dwUserHeight;
+ int iPosX;
+ int iPosY;
+ HWND *phwnd = &pScreenPriv->hwndScreen;
+ WNDCLASS wc;
+ RECT rcClient, rcWorkArea;
+ DWORD dwWindowStyle;
+ BOOL fForceShowWindow = FALSE;
+ char szTitle[256];
+
+ winDebug ("winCreateBoundingWindowWindowed - User w: %d h: %d\n",
+ (int) pScreenInfo->dwUserWidth, (int) pScreenInfo->dwUserHeight);
+ winDebug ("winCreateBoundingWindowWindowed - Current w: %d h: %d\n",
+ (int) pScreenInfo->dwWidth, (int) pScreenInfo->dwHeight);
+
+ /* Set the common window style flags */
+ dwWindowStyle = WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX;
+
+ /* Decorated or undecorated window */
+ if (pScreenInfo->fDecoration
+#ifdef XWIN_MULTIWINDOWEXTWM
+ && !pScreenInfo->fMWExtWM
+#endif
+ && !pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOW
+ && !pScreenInfo->fMultiWindow
+#endif
+ )
+ {
+ /* Try to handle startup via run.exe. run.exe instructs Windows to
+ * hide all created windows. Detect this case and make sure the
+ * window is shown nevertheless */
+ STARTUPINFO startupInfo;
+ GetStartupInfo(&startupInfo);
+ if (startupInfo.dwFlags & STARTF_USESHOWWINDOW &&
+ startupInfo.wShowWindow == SW_HIDE)
+ {
+ fForceShowWindow = TRUE;
+ }
+ dwWindowStyle |= WS_CAPTION;
+ if (pScreenInfo->fScrollbars)
+ dwWindowStyle |= WS_THICKFRAME | WS_MAXIMIZEBOX;
+ }
+ else
+ dwWindowStyle |= WS_POPUP;
+
+ /* Setup our window class */
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = winWindowProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = g_hInstance;
+ wc.hIcon = LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN));
+ wc.hCursor = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = WINDOW_CLASS;
+ RegisterClass (&wc);
+
+ /* Get size of work area */
+ winGetWorkArea (&rcWorkArea, pScreenInfo);
+
+ /* Adjust for auto-hide taskbars */
+ winAdjustForAutoHide (&rcWorkArea);
+
+ /* Did the user specify a position? */
+ if (pScreenInfo->fUserGavePosition)
+ {
+ iPosX = pScreenInfo->dwInitialX;
+ iPosY = pScreenInfo->dwInitialY;
+ }
+ else
+ {
+ iPosX = rcWorkArea.left;
+ iPosY = rcWorkArea.top;
+ }
+
+ /* Did the user specify a height and width? */
+ if (pScreenInfo->fUserGaveHeightAndWidth)
+ {
+ /* User gave a desired height and width, try to accomodate */
+#if CYGDEBUG
+ winDebug ("winCreateBoundingWindowWindowed - User gave height "
+ "and width\n");
+#endif
+
+ /* Adjust the window width and height for borders and title bar */
+ if (pScreenInfo->fDecoration
+#ifdef XWIN_MULTIWINDOWEXTWM
+ && !pScreenInfo->fMWExtWM
+#endif
+ && !pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOW
+ && !pScreenInfo->fMultiWindow
+#endif
+ )
+ {
+#if CYGDEBUG
+ winDebug ("winCreateBoundingWindowWindowed - Window has decoration\n");
+#endif
+ /* Are we using scrollbars? */
+ if (pScreenInfo->fScrollbars)
+ {
+#if CYGDEBUG
+ winDebug ("winCreateBoundingWindowWindowed - Window has "
+ "scrollbars\n");
+#endif
+
+ iWidth += 2 * GetSystemMetrics (SM_CXSIZEFRAME);
+ iHeight += 2 * GetSystemMetrics (SM_CYSIZEFRAME)
+ + GetSystemMetrics (SM_CYCAPTION);
+ }
+ else
+ {
+#if CYGDEBUG
+ winDebug ("winCreateBoundingWindowWindowed - Window does not have "
+ "scrollbars\n");
+#endif
+
+ iWidth += 2 * GetSystemMetrics (SM_CXFIXEDFRAME);
+ iHeight += 2 * GetSystemMetrics (SM_CYFIXEDFRAME)
+ + GetSystemMetrics (SM_CYCAPTION);
+ }
+ }
+ }
+ else
+ {
+ /* By default, we are creating a window that is as large as possible */
+#if CYGDEBUG
+ winDebug ("winCreateBoundingWindowWindowed - User did not give "
+ "height and width\n");
+#endif
+ /* Defaults are wrong if we have multiple monitors */
+ if (pScreenInfo->fMultipleMonitors)
+ {
+ iWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
+ iHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
+ }
+ }
+
+ /* Clean up the scrollbars flag, if necessary */
+ if ((!pScreenInfo->fDecoration
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || pScreenInfo->fMWExtWM
+#endif
+ || pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOW
+ || pScreenInfo->fMultiWindow
+#endif
+ )
+ && pScreenInfo->fScrollbars)
+ {
+ /* We cannot have scrollbars if we do not have a window border */
+ pScreenInfo->fScrollbars = FALSE;
+ }
+
+ if (TRUE
+#ifdef XWIN_MULTIWINDOWEXTWM
+ && !pScreenInfo->fMWExtWM
+#endif
+#ifdef XWIN_MULTIWINDOW
+ && !pScreenInfo->fMultiWindow
+#endif
+ )
+ {
+ /* Trim window width to fit work area */
+ if (iWidth > (rcWorkArea.right - rcWorkArea.left))
+ iWidth = rcWorkArea.right - rcWorkArea.left;
+
+ /* Trim window height to fit work area */
+ if (iHeight >= (rcWorkArea.bottom - rcWorkArea.top))
+ iHeight = rcWorkArea.bottom - rcWorkArea.top;
+
+#if CYGDEBUG
+ winDebug ("winCreateBoundingWindowWindowed - Adjusted width: %d "\
+ "height: %d\n",
+ iWidth, iHeight);
+#endif
+ }
+
+ /* Set display and screen-specific tooltip text */
+ if (g_pszQueryHost != NULL)
+ snprintf (szTitle,
+ sizeof (szTitle),
+ WINDOW_TITLE_XDMCP,
+ g_pszQueryHost);
+ else
+ snprintf (szTitle,
+ sizeof (szTitle),
+ WINDOW_TITLE,
+ display,
+ (int) pScreenInfo->dwScreen);
+
+ /* Create the window */
+ *phwnd = CreateWindowExA (0, /* Extended styles */
+ WINDOW_CLASS, /* Class name */
+ szTitle, /* Window name */
+ dwWindowStyle,
+ iPosX, /* Horizontal position */
+ iPosY, /* Vertical position */
+ iWidth, /* Right edge */
+ iHeight, /* Bottom edge */
+ (HWND) NULL, /* No parent or owner window */
+ (HMENU) NULL, /* No menu */
+ GetModuleHandle (NULL),/* Instance handle */
+ pScreenPriv); /* ScreenPrivates */
+ if (*phwnd == NULL)
+ {
+ ErrorF ("winCreateBoundingWindowWindowed - CreateWindowEx () failed\n");
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winCreateBoundingWindowWindowed - CreateWindowEx () returned\n");
+#endif
+
+ if (fForceShowWindow)
+ {
+ ErrorF("winCreateBoundingWindowWindowed - Setting normal windowstyle\n");
+ ShowWindow(*phwnd, SW_SHOW);
+ }
+
+ /* Get the client area coordinates */
+ if (!GetClientRect (*phwnd, &rcClient))
+ {
+ ErrorF ("winCreateBoundingWindowWindowed - GetClientRect () "
+ "failed\n");
+ return FALSE;
+ }
+
+ winDebug ("winCreateBoundingWindowWindowed - WindowClient "
+ "w %ld h %ld r %ld l %ld b %ld t %ld\n",
+ rcClient.right - rcClient.left,
+ rcClient.bottom - rcClient.top,
+ rcClient.right, rcClient.left,
+ rcClient.bottom, rcClient.top);
+
+ /* We adjust the visual size if the user did not specify it */
+ if (!(pScreenInfo->fScrollbars && pScreenInfo->fUserGaveHeightAndWidth))
+ {
+ /*
+ * User did not give a height and width with scrollbars enabled,
+ * so we will resize the underlying visual to be as large as
+ * the initial view port (page size). This way scrollbars will
+ * not appear until the user shrinks the window, if they ever do.
+ *
+ * NOTE: We have to store the viewport size here because
+ * the user may have an autohide taskbar, which would
+ * cause the viewport size to be one less in one dimension
+ * than the viewport size that we calculated by subtracting
+ * the size of the borders and caption.
+ */
+ pScreenInfo->dwWidth = rcClient.right - rcClient.left;
+ pScreenInfo->dwHeight = rcClient.bottom - rcClient.top;
+ }
+
+#if 0
+ /*
+ * NOTE: For the uninitiated, the page size is the number of pixels
+ * that we can display in the x or y direction at a time and the
+ * range is the total number of pixels in the x or y direction that we
+ * have available to display. In other words, the page size is the
+ * size of the window area minus the space the caption, borders, and
+ * scrollbars (if any) occupy, and the range is the size of the
+ * underlying X visual. Notice that, contrary to what some of the
+ * MSDN Library arcticles lead you to believe, the windows
+ * ``client area'' size does not include the scrollbars. In other words,
+ * the whole client area size that is reported to you is drawable by
+ * you; you do not have to subtract the size of the scrollbars from
+ * the client area size, and if you did it would result in the size
+ * of the scrollbars being double counted.
+ */
+
+ /* Setup scrollbar page and range, if scrollbars are enabled */
+ if (pScreenInfo->fScrollbars)
+ {
+ SCROLLINFO si;
+
+ /* Initialize the scrollbar info structure */
+ si.cbSize = sizeof (si);
+ si.fMask = SIF_RANGE | SIF_PAGE;
+ si.nMin = 0;
+
+ /* Setup the width range and page size */
+ si.nMax = pScreenInfo->dwWidth - 1;
+ si.nPage = rcClient.right - rcClient.left;
+ winDebug ("winCreateBoundingWindowWindowed - HORZ nMax: %d nPage :%d\n",
+ si.nMax, si.nPage);
+ SetScrollInfo (*phwnd, SB_HORZ, &si, TRUE);
+
+ /* Setup the height range and page size */
+ si.nMax = pScreenInfo->dwHeight - 1;
+ si.nPage = rcClient.bottom - rcClient.top;
+ winDebug ("winCreateBoundingWindowWindowed - VERT nMax: %d nPage :%d\n",
+ si.nMax, si.nPage);
+ SetScrollInfo (*phwnd, SB_VERT, &si, TRUE);
+ }
+#endif
+
+ /* Show the window */
+ if (FALSE
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || pScreenInfo->fMWExtWM
+#endif
+#ifdef XWIN_MULTIWINDOW
+ || pScreenInfo->fMultiWindow
+#endif
+ )
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ pScreenPriv->fRootWindowShown = FALSE;
+#endif
+ ShowWindow (*phwnd, SW_HIDE);
+ }
+ else
+ ShowWindow (*phwnd, SW_SHOWNORMAL);
+ if (!UpdateWindow (*phwnd))
+ {
+ ErrorF ("winCreateBoundingWindowWindowed - UpdateWindow () failed\n");
+ return FALSE;
+ }
+
+ /* Attempt to bring our window to the top of the display */
+ if (TRUE
+#ifdef XWIN_MULTIWINDOWEXTWM
+ && !pScreenInfo->fMWExtWM
+#endif
+ && !pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOW
+ && !pScreenInfo->fMultiWindow
+#endif
+ )
+ {
+ if (!BringWindowToTop (*phwnd))
+ {
+ ErrorF ("winCreateBoundingWindowWindowed - BringWindowToTop () "
+ "failed\n");
+ return FALSE;
+ }
+ }
+
+#ifdef XWIN_NATIVEGDI
+ /* Paint window background blue */
+ if (pScreenInfo->dwEngine == WIN_SERVER_NATIVE_GDI)
+ winPaintBackground (*phwnd, RGB (0x00, 0x00, 0xFF));
+#endif
+
+ winDebug ("winCreateBoundingWindowWindowed - Returning\n");
+
+ return TRUE;
+}
+
+
+/*
+ * Find the work area of all attached monitors
+ */
+
+static Bool
+winGetWorkArea (RECT *prcWorkArea, winScreenInfo *pScreenInfo)
+{
+ int iPrimaryWidth, iPrimaryHeight;
+ int iWidth, iHeight;
+ int iLeft, iTop;
+ int iPrimaryNonWorkAreaWidth, iPrimaryNonWorkAreaHeight;
+
+ /* SPI_GETWORKAREA only gets the work area of the primary screen. */
+ SystemParametersInfo (SPI_GETWORKAREA, 0, prcWorkArea, 0);
+
+ /* Bail out here if we aren't using multiple monitors */
+ if (!pScreenInfo->fMultipleMonitors)
+ return TRUE;
+
+ winDebug ("winGetWorkArea - Original WorkArea: %d %d %d %d\n",
+ (int) prcWorkArea->top, (int) prcWorkArea->left,
+ (int) prcWorkArea->bottom, (int) prcWorkArea->right);
+
+ /* Get size of full virtual screen */
+ iWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
+ iHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
+
+ winDebug ("winGetWorkArea - Virtual screen is %d x %d\n", iWidth, iHeight);
+
+ /* Get origin of full virtual screen */
+ iLeft = GetSystemMetrics (SM_XVIRTUALSCREEN);
+ iTop = GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ winDebug ("winGetWorkArea - Virtual screen origin is %d, %d\n", iLeft, iTop);
+
+ /* Get size of primary screen */
+ iPrimaryWidth = GetSystemMetrics (SM_CXSCREEN);
+ iPrimaryHeight = GetSystemMetrics (SM_CYSCREEN);
+
+ winDebug ("winGetWorkArea - Primary screen is %d x %d\n",
+ iPrimaryWidth, iPrimaryHeight);
+
+ /* Work out how much of the primary screen we aren't using */
+ iPrimaryNonWorkAreaWidth = iPrimaryWidth - (prcWorkArea->right -
+ prcWorkArea->left);
+ iPrimaryNonWorkAreaHeight = iPrimaryHeight - (prcWorkArea->bottom
+ - prcWorkArea->top);
+
+ /* Update the rectangle to include all monitors */
+ if (iLeft < 0)
+ {
+ prcWorkArea->left = iLeft;
+ }
+ if (iTop < 0)
+ {
+ prcWorkArea->top = iTop;
+ }
+ prcWorkArea->right = prcWorkArea->left + iWidth -
+ iPrimaryNonWorkAreaWidth;
+ prcWorkArea->bottom = prcWorkArea->top + iHeight -
+ iPrimaryNonWorkAreaHeight;
+
+ winDebug ("winGetWorkArea - Adjusted WorkArea for multiple "
+ "monitors: %d %d %d %d\n",
+ (int) prcWorkArea->top, (int) prcWorkArea->left,
+ (int) prcWorkArea->bottom, (int) prcWorkArea->right);
+
+ return TRUE;
+}
+
+
+/*
+ * Adjust the client area so that any auto-hide toolbars
+ * will work correctly.
+ */
+
+static Bool
+winAdjustForAutoHide (RECT *prcWorkArea)
+{
+ APPBARDATA abd;
+ HWND hwndAutoHide;
+
+ winDebug ("winAdjustForAutoHide - Original WorkArea: %d %d %d %d\n",
+ (int) prcWorkArea->top, (int) prcWorkArea->left,
+ (int) prcWorkArea->bottom, (int) prcWorkArea->right);
+
+ /* Find out if the Windows taskbar is set to auto-hide */
+ ZeroMemory (&abd, sizeof (abd));
+ abd.cbSize = sizeof (abd);
+ if (SHAppBarMessage (ABM_GETSTATE, &abd) & ABS_AUTOHIDE)
+ winDebug ("winAdjustForAutoHide - Taskbar is auto hide\n");
+
+ /* Look for a TOP auto-hide taskbar */
+ abd.uEdge = ABE_TOP;
+ hwndAutoHide = (HWND) SHAppBarMessage (ABM_GETAUTOHIDEBAR, &abd);
+ if (hwndAutoHide != NULL)
+ {
+ winDebug ("winAdjustForAutoHide - Found TOP auto-hide taskbar\n");
+ prcWorkArea->top += 1;
+ }
+
+ /* Look for a LEFT auto-hide taskbar */
+ abd.uEdge = ABE_LEFT;
+ hwndAutoHide = (HWND) SHAppBarMessage (ABM_GETAUTOHIDEBAR, &abd);
+ if (hwndAutoHide != NULL)
+ {
+ winDebug ("winAdjustForAutoHide - Found LEFT auto-hide taskbar\n");
+ prcWorkArea->left += 1;
+ }
+
+ /* Look for a BOTTOM auto-hide taskbar */
+ abd.uEdge = ABE_BOTTOM;
+ hwndAutoHide = (HWND) SHAppBarMessage (ABM_GETAUTOHIDEBAR, &abd);
+ if (hwndAutoHide != NULL)
+ {
+ winDebug ("winAdjustForAutoHide - Found BOTTOM auto-hide taskbar\n");
+ prcWorkArea->bottom -= 1;
+ }
+
+ /* Look for a RIGHT auto-hide taskbar */
+ abd.uEdge = ABE_RIGHT;
+ hwndAutoHide = (HWND) SHAppBarMessage (ABM_GETAUTOHIDEBAR, &abd);
+ if (hwndAutoHide != NULL)
+ {
+ winDebug ("winAdjustForAutoHide - Found RIGHT auto-hide taskbar\n");
+ prcWorkArea->right -= 1;
+ }
+
+ winDebug ("winAdjustForAutoHide - Adjusted WorkArea: %d %d %d %d\n",
+ (int) prcWorkArea->top, (int) prcWorkArea->left,
+ (int) prcWorkArea->bottom, (int) prcWorkArea->right);
+
+#if 0
+ /* Obtain the task bar window dimensions */
+ abd.hWnd = hwndAutoHide;
+ hwndAutoHide = (HWND) SHAppBarMessage (ABM_GETTASKBARPOS, &abd);
+ winDebug ("hwndAutoHide %08x abd.hWnd %08x %d %d %d %d\n",
+ hwndAutoHide, abd.hWnd,
+ abd.rc.top, abd.rc.left, abd.rc.bottom, abd.rc.right);
+#endif
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/wincursor.c b/nx-X11/programs/Xserver/hw/xwin/wincursor.c
new file mode 100644
index 000000000..5a619922a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/wincursor.c
@@ -0,0 +1,615 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/wincursor.c,v 1.5 2002/07/05 09:19:26 alanh Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winmsg.h"
+#include <cursorstr.h>
+#include <mipointrst.h>
+#include <servermd.h>
+
+
+#ifndef MIN
+#define MIN(x,y) ((x)<(y)?(x):(y))
+#endif
+
+#define BYTE_COUNT(x) (((x) + 7) / 8)
+
+#define BRIGHTNESS(x) (x##Red * 0.299 + x##Green * 0.587 + x##Blue * 0.114)
+
+#if 0
+# define WIN_DEBUG_MSG winDebug
+#else
+# define WIN_DEBUG_MSG(...)
+#endif
+
+/*
+ * Local function prototypes
+ */
+
+static void
+winPointerWarpCursor (ScreenPtr pScreen, int x, int y);
+
+static Bool
+winCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y);
+
+static void
+winCrossScreen (ScreenPtr pScreen, Bool fEntering);
+
+miPointerScreenFuncRec g_winPointerCursorFuncs =
+{
+ winCursorOffScreen,
+ winCrossScreen,
+ winPointerWarpCursor
+};
+
+
+static void
+winPointerWarpCursor (ScreenPtr pScreen, int x, int y)
+{
+ winScreenPriv(pScreen);
+ RECT rcClient;
+ static Bool s_fInitialWarp = TRUE;
+
+ /* Discard first warp call */
+ if (s_fInitialWarp)
+ {
+ /* First warp moves mouse to center of window, just ignore it */
+
+ /* Don't ignore subsequent warps */
+ s_fInitialWarp = FALSE;
+
+ winErrorFVerb (2, "winPointerWarpCursor - Discarding first warp: %d %d\n",
+ x, y);
+
+ return;
+ }
+
+ /* Only update the Windows cursor position if we are active */
+ if (pScreenPriv->hwndScreen == GetForegroundWindow ())
+ {
+ /* Get the client area coordinates */
+ GetClientRect (pScreenPriv->hwndScreen, &rcClient);
+
+ /* Translate the client area coords to screen coords */
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&rcClient,
+ 2);
+
+ /*
+ * Update the Windows cursor position so that we don't
+ * immediately warp back to the current position.
+ */
+ SetCursorPos (rcClient.left + x, rcClient.top + y);
+ }
+
+ /* Call the mi warp procedure to do the actual warping in X. */
+ miPointerWarpCursor (pScreen, x, y);
+}
+
+static Bool
+winCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y)
+{
+ return FALSE;
+}
+
+static void
+winCrossScreen (ScreenPtr pScreen, Bool fEntering)
+{
+}
+
+static unsigned char
+reverse(unsigned char c)
+{
+ int i;
+ unsigned char ret = 0;
+ for (i = 0; i < 8; ++i)
+ {
+ ret |= ((c >> i)&1) << (7 - i);
+ }
+ return ret;
+}
+
+/*
+ * Convert X cursor to Windows cursor
+ * FIXME: Perhaps there are more smart code
+ */
+static HCURSOR
+winLoadCursor (ScreenPtr pScreen, CursorPtr pCursor, int screen)
+{
+ winScreenPriv(pScreen);
+ HCURSOR hCursor = NULL;
+ unsigned char *pAnd;
+ unsigned char *pXor;
+ int nCX, nCY;
+ int nBytes;
+ double dForeY, dBackY;
+ BOOL fReverse;
+ HBITMAP hAnd, hXor;
+ ICONINFO ii;
+ unsigned char *pCur;
+ int x, y;
+ unsigned char bit;
+ HDC hDC;
+ BITMAPV4HEADER bi;
+ BITMAPINFO *pbmi;
+ unsigned long *lpBits;
+
+ WIN_DEBUG_MSG("winLoadCursor: Win32: %dx%d X11: %dx%d hotspot: %d,%d\n",
+ pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
+ pCursor->bits->width, pCursor->bits->height,
+ pCursor->bits->xhot, pCursor->bits->yhot
+ );
+
+ /* We can use only White and Black, so calc brightness of color
+ * Also check if the cursor is inverted */
+ dForeY = BRIGHTNESS(pCursor->fore);
+ dBackY = BRIGHTNESS(pCursor->back);
+ fReverse = dForeY < dBackY;
+
+ /* Check wether the X11 cursor is bigger than the win32 cursor */
+ if (pScreenPriv->cursor.sm_cx < pCursor->bits->width ||
+ pScreenPriv->cursor.sm_cy < pCursor->bits->height)
+ {
+ winErrorFVerb (2, "winLoadCursor - Windows requires %dx%d cursor\n"
+ "\tbut X requires %dx%d\n",
+ pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
+ pCursor->bits->width, pCursor->bits->height);
+ }
+
+ /* Get the number of bytes required to store the whole cursor image
+ * This is roughly (sm_cx * sm_cy) / 8
+ * round up to 8 pixel boundary so we can convert whole bytes */
+ nBytes = BYTE_COUNT(pScreenPriv->cursor.sm_cx) * pScreenPriv->cursor.sm_cy;
+
+ /* Get the effective width and height */
+ nCX = MIN(pScreenPriv->cursor.sm_cx, pCursor->bits->width);
+ nCY = MIN(pScreenPriv->cursor.sm_cy, pCursor->bits->height);
+
+ /* Allocate memory for the bitmaps */
+ pAnd = malloc (nBytes);
+ memset (pAnd, 0xFF, nBytes);
+ pXor = malloc (nBytes);
+ memset (pXor, 0x00, nBytes);
+
+ /* Convert the X11 bitmap to a win32 bitmap
+ * The first is for an empty mask */
+ if (pCursor->bits->emptyMask)
+ {
+ int x, y, xmax = BYTE_COUNT(nCX);
+ for (y = 0; y < nCY; ++y)
+ for (x = 0; x < xmax; ++x)
+ {
+ int nWinPix = BYTE_COUNT(pScreenPriv->cursor.sm_cx) * y + x;
+ int nXPix = BitmapBytePad(pCursor->bits->width) * y + x;
+
+ pAnd[nWinPix] = 0;
+ if (fReverse)
+ pXor[nWinPix] = reverse (~pCursor->bits->source[nXPix]);
+ else
+ pXor[nWinPix] = reverse (pCursor->bits->source[nXPix]);
+ }
+ }
+ else
+ {
+ int x, y, xmax = BYTE_COUNT(nCX);
+ for (y = 0; y < nCY; ++y)
+ for (x = 0; x < xmax; ++x)
+ {
+ int nWinPix = BYTE_COUNT(pScreenPriv->cursor.sm_cx) * y + x;
+ int nXPix = BitmapBytePad(pCursor->bits->width) * y + x;
+
+ unsigned char mask = pCursor->bits->mask[nXPix];
+ pAnd[nWinPix] = reverse (~mask);
+ if (fReverse)
+ pXor[nWinPix] = reverse (~pCursor->bits->source[nXPix] & mask);
+ else
+ pXor[nWinPix] = reverse (pCursor->bits->source[nXPix] & mask);
+ }
+ }
+
+ /* prepare the pointers */
+ hCursor = NULL;
+ lpBits = NULL;
+
+ /* We have a truecolor alpha-blended cursor and can use it! */
+ if (pCursor->bits->argb)
+ {
+ WIN_DEBUG_MSG("winLoadCursor: Trying truecolor alphablended cursor\n");
+ memset (&bi, 0, sizeof (BITMAPV4HEADER));
+ bi.bV4Size = sizeof(BITMAPV4HEADER);
+ bi.bV4Width = pScreenPriv->cursor.sm_cx;
+ bi.bV4Height = -(pScreenPriv->cursor.sm_cy); /* right-side up */
+ bi.bV4Planes = 1;
+ bi.bV4BitCount = 32;
+ bi.bV4V4Compression = BI_BITFIELDS;
+ bi.bV4RedMask = 0x00FF0000;
+ bi.bV4GreenMask = 0x0000FF00;
+ bi.bV4BlueMask = 0x000000FF;
+ bi.bV4AlphaMask = 0xFF000000;
+
+ lpBits = (unsigned long *) calloc (pScreenPriv->cursor.sm_cx*pScreenPriv->cursor.sm_cy,
+ sizeof (unsigned long));
+
+ if (lpBits)
+ {
+ for (y=0; y<nCY; y++)
+ {
+ unsigned long *src, *dst;
+ src = &(pCursor->bits->argb[y * pCursor->bits->width]);
+ dst = &(lpBits[y * pScreenPriv->cursor.sm_cx]);
+ memcpy (dst, src, 4*nCX);
+ }
+ }
+ } /* End if-truecolor-icon */
+
+ if (!lpBits)
+ {
+ /* Bicolor, use a palettized DIB */
+ WIN_DEBUG_MSG("winLoadCursor: Trying two color cursor\n");
+ pbmi = (BITMAPINFO*)&bi;
+ memset (pbmi, 0, sizeof (BITMAPINFOHEADER));
+ pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ pbmi->bmiHeader.biWidth = pScreenPriv->cursor.sm_cx;
+ pbmi->bmiHeader.biHeight = -abs(pScreenPriv->cursor.sm_cy); /* right-side up */
+ pbmi->bmiHeader.biPlanes = 1;
+ pbmi->bmiHeader.biBitCount = 8;
+ pbmi->bmiHeader.biCompression = BI_RGB;
+ pbmi->bmiHeader.biSizeImage = 0;
+ pbmi->bmiHeader.biClrUsed = 3;
+ pbmi->bmiHeader.biClrImportant = 3;
+ pbmi->bmiColors[0].rgbRed = 0; /* Empty */
+ pbmi->bmiColors[0].rgbGreen = 0;
+ pbmi->bmiColors[0].rgbBlue = 0;
+ pbmi->bmiColors[0].rgbReserved = 0;
+ pbmi->bmiColors[1].rgbRed = pCursor->backRed>>8; /* Background */
+ pbmi->bmiColors[1].rgbGreen = pCursor->backGreen>>8;
+ pbmi->bmiColors[1].rgbBlue = pCursor->backBlue>>8;
+ pbmi->bmiColors[1].rgbReserved = 0;
+ pbmi->bmiColors[2].rgbRed = pCursor->foreRed>>8; /* Foreground */
+ pbmi->bmiColors[2].rgbGreen = pCursor->foreGreen>>8;
+ pbmi->bmiColors[2].rgbBlue = pCursor->foreBlue>>8;
+ pbmi->bmiColors[2].rgbReserved = 0;
+
+ lpBits = (unsigned long *) calloc (pScreenPriv->cursor.sm_cx*pScreenPriv->cursor.sm_cy,
+ sizeof (char));
+
+ pCur = (unsigned char *)lpBits;
+ if (lpBits)
+ {
+ for (y=0; y<pScreenPriv->cursor.sm_cy; y++)
+ {
+ for (x=0; x<pScreenPriv->cursor.sm_cx; x++)
+ {
+ if (x>=nCX || y>=nCY) /* Outside of X11 icon bounds */
+ (*pCur++) = 0;
+ else /* Within X11 icon bounds */
+ {
+ int nWinPix = BYTE_COUNT(pScreenPriv->cursor.sm_cx) * y + (x/8);
+
+ bit = pAnd[nWinPix];
+ bit = bit & (1<<(7-(x&7)));
+ if (!bit) /* Within the cursor mask? */
+ {
+ int nXPix = BitmapBytePad(pCursor->bits->width) * y + (x/8);
+ bit = ~reverse(~pCursor->bits->source[nXPix] & pCursor->bits->mask[nXPix]);
+ bit = bit & (1<<(7-(x&7)));
+ if (bit) /* Draw foreground */
+ (*pCur++) = 2;
+ else /* Draw background */
+ (*pCur++) = 1;
+ }
+ else /* Outside the cursor mask */
+ (*pCur++) = 0;
+ }
+ } /* end for (x) */
+ } /* end for (y) */
+ } /* end if (lpbits) */
+ }
+
+ /* If one of the previous two methods gave us the bitmap we need, make a cursor */
+ if (lpBits)
+ {
+ WIN_DEBUG_MSG("winLoadCursor: Creating bitmap cursor: hotspot %d,%d\n",
+ pCursor->bits->xhot, pCursor->bits->yhot);
+
+ hAnd = NULL;
+ hXor = NULL;
+
+ hAnd = CreateBitmap (pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy, 1, 1, pAnd);
+
+ hDC = GetDC (NULL);
+ if (hDC)
+ {
+ hXor = CreateCompatibleBitmap (hDC, pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy);
+ SetDIBits (hDC, hXor, 0, pScreenPriv->cursor.sm_cy, lpBits, (BITMAPINFO*)&bi, DIB_RGB_COLORS);
+ ReleaseDC (NULL, hDC);
+ }
+ free (lpBits);
+
+
+ if (hAnd && hXor)
+ {
+ ii.fIcon = FALSE;
+ ii.xHotspot = pCursor->bits->xhot;
+ ii.yHotspot = pCursor->bits->yhot;
+ ii.hbmMask = hAnd;
+ ii.hbmColor = hXor;
+ hCursor = (HCURSOR) CreateIconIndirect( &ii );
+
+ if (hCursor == NULL)
+ winW32Error(2, "winLoadCursor - CreateIconIndirect failed:");
+ else
+ {
+ if (GetIconInfo(hCursor, &ii))
+ {
+ if (ii.fIcon)
+ {
+ WIN_DEBUG_MSG("winLoadCursor: CreateIconIndirect returned no cursor. Trying again.\n");
+
+ DestroyCursor(hCursor);
+
+ ii.fIcon = FALSE;
+ ii.xHotspot = pCursor->bits->xhot;
+ ii.yHotspot = pCursor->bits->yhot;
+ hCursor = (HCURSOR) CreateIconIndirect( &ii );
+
+ if (hCursor == NULL)
+ winW32Error(2, "winLoadCursor - CreateIconIndirect failed:");
+ }
+ /* GetIconInfo creates new bitmaps. Destroy them again */
+ if (ii.hbmMask)
+ DeleteObject(ii.hbmMask);
+ if (ii.hbmColor)
+ DeleteObject(ii.hbmColor);
+ }
+ }
+ }
+
+ if (hAnd)
+ DeleteObject (hAnd);
+ if (hXor)
+ DeleteObject (hXor);
+ }
+
+ if (!hCursor)
+ {
+ /* We couldn't make a color cursor for this screen, use
+ black and white instead */
+ hCursor = CreateCursor (g_hInstance,
+ pCursor->bits->xhot, pCursor->bits->yhot,
+ pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
+ pAnd, pXor);
+ if (hCursor == NULL)
+ winW32Error(2, "winLoadCursor - CreateCursor failed:");
+ }
+ free (pAnd);
+ free (pXor);
+
+ return hCursor;
+}
+
+/*
+===========================================================================
+
+ Pointer sprite functions
+
+===========================================================================
+*/
+
+/*
+ * winRealizeCursor
+ * Convert the X cursor representation to native format if possible.
+ */
+static Bool
+winRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
+{
+ WIN_DEBUG_MSG("winRealizeCursor: cursor=%p\n", pCursor);
+
+ if(pCursor == NULL || pCursor->bits == NULL)
+ return FALSE;
+
+ /* FIXME: cache ARGB8888 representation? */
+
+ return TRUE;
+}
+
+
+/*
+ * winUnrealizeCursor
+ * Free the storage space associated with a realized cursor.
+ */
+static Bool
+winUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+ WIN_DEBUG_MSG("winUnrealizeCursor: cursor=%p\n", pCursor);
+ return TRUE;
+}
+
+
+/*
+ * winSetCursor
+ * Set the cursor sprite and position.
+ */
+static void
+winSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
+{
+ POINT ptCurPos, ptTemp;
+ HWND hwnd;
+ RECT rcClient;
+ BOOL bInhibit;
+ winScreenPriv(pScreen);
+ WIN_DEBUG_MSG("winSetCursor: cursor=%p\n", pCursor);
+
+ /* Inhibit changing the cursor if the mouse is not in a client area */
+ bInhibit = FALSE;
+ if (GetCursorPos (&ptCurPos))
+ {
+ hwnd = WindowFromPoint (ptCurPos);
+ if (hwnd)
+ {
+ if (GetClientRect (hwnd, &rcClient))
+ {
+ ptTemp.x = rcClient.left;
+ ptTemp.y = rcClient.top;
+ if (ClientToScreen (hwnd, &ptTemp))
+ {
+ rcClient.left = ptTemp.x;
+ rcClient.top = ptTemp.y;
+ ptTemp.x = rcClient.right;
+ ptTemp.y = rcClient.bottom;
+ if (ClientToScreen (hwnd, &ptTemp))
+ {
+ rcClient.right = ptTemp.x;
+ rcClient.bottom = ptTemp.y;
+ if (!PtInRect (&rcClient, ptCurPos))
+ bInhibit = TRUE;
+ }
+ }
+ }
+ }
+ }
+
+ if (pCursor == NULL)
+ {
+ if (pScreenPriv->cursor.visible)
+ {
+ if (!bInhibit)
+ ShowCursor (FALSE);
+ pScreenPriv->cursor.visible = FALSE;
+ }
+ }
+ else
+ {
+ if (pScreenPriv->cursor.handle)
+ {
+ if (!bInhibit)
+ SetCursor (NULL);
+ DestroyCursor (pScreenPriv->cursor.handle);
+ pScreenPriv->cursor.handle = NULL;
+ }
+ pScreenPriv->cursor.handle =
+ winLoadCursor (pScreen, pCursor, pScreen->myNum);
+ WIN_DEBUG_MSG("winSetCursor: handle=%p\n", pScreenPriv->cursor.handle);
+
+ if (!bInhibit)
+ SetCursor (pScreenPriv->cursor.handle);
+
+ if (!pScreenPriv->cursor.visible)
+ {
+ if (!bInhibit)
+ ShowCursor (TRUE);
+ pScreenPriv->cursor.visible = TRUE;
+ }
+ }
+}
+
+
+/*
+ * QuartzMoveCursor
+ * Move the cursor. This is a noop for us.
+ */
+static void
+winMoveCursor (ScreenPtr pScreen, int x, int y)
+{
+}
+
+
+static miPointerSpriteFuncRec winSpriteFuncsRec = {
+ winRealizeCursor,
+ winUnrealizeCursor,
+ winSetCursor,
+ winMoveCursor
+};
+
+
+/*
+===========================================================================
+
+ Other screen functions
+
+===========================================================================
+*/
+
+/*
+ * winCursorQueryBestSize
+ * Handle queries for best cursor size
+ */
+static void
+winCursorQueryBestSize (int class, unsigned short *width,
+ unsigned short *height, ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ if (class == CursorShape)
+ {
+ *width = pScreenPriv->cursor.sm_cx;
+ *height = pScreenPriv->cursor.sm_cy;
+ }
+ else
+ {
+ if (pScreenPriv->cursor.QueryBestSize)
+ (*pScreenPriv->cursor.QueryBestSize)(class, width, height, pScreen);
+ }
+}
+
+/*
+ * winInitCursor
+ * Initialize cursor support
+ */
+Bool
+winInitCursor (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ miPointerScreenPtr pPointPriv;
+ /* override some screen procedures */
+ pScreenPriv->cursor.QueryBestSize = pScreen->QueryBestSize;
+ pScreen->QueryBestSize = winCursorQueryBestSize;
+
+ pPointPriv = (miPointerScreenPtr) pScreen->devPrivates[miPointerScreenIndex].ptr;
+
+ pScreenPriv->cursor.spriteFuncs = pPointPriv->spriteFuncs;
+ pPointPriv->spriteFuncs = &winSpriteFuncsRec;
+
+ pScreenPriv->cursor.handle = NULL;
+ pScreenPriv->cursor.visible = FALSE;
+
+ pScreenPriv->cursor.sm_cx = GetSystemMetrics (SM_CXCURSOR);
+ pScreenPriv->cursor.sm_cy = GetSystemMetrics (SM_CYCURSOR);
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/windialogs.c b/nx-X11/programs/Xserver/hw/xwin/windialogs.c
new file mode 100755
index 000000000..ab06b0d00
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/windialogs.c
@@ -0,0 +1,788 @@
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ * Earle F. Philhower III
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#ifdef __CYGWIN__
+#include <sys/cygwin.h>
+#endif
+#include <shellapi.h>
+#include "winprefs.h"
+
+
+/*
+ * References to external globals
+ */
+
+extern Bool g_fCursor;
+extern HWND g_hDlgDepthChange;
+extern HWND g_hDlgExit;
+extern HWND g_hDlgAbout;
+extern WINPREFS pref;
+#ifdef XWIN_CLIPBOARD
+extern Bool g_fClipboardStarted;
+#endif
+extern Bool g_fSoftwareCursor;
+
+
+/*
+ * Local function prototypes
+ */
+
+static wBOOL CALLBACK
+winExitDlgProc (HWND hDialog, UINT message,
+ WPARAM wParam, LPARAM lParam);
+
+static wBOOL CALLBACK
+winChangeDepthDlgProc (HWND hDialog, UINT message,
+ WPARAM wParam, LPARAM lParam);
+
+static wBOOL CALLBACK
+winAboutDlgProc (HWND hDialog, UINT message,
+ WPARAM wParam, LPARAM lParam);
+
+
+static void
+winDrawURLWindow (LPARAM lParam);
+
+static LRESULT CALLBACK
+winURLWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+static void
+winOverrideURLButton (HWND hdlg, int id);
+
+static void
+winUnoverrideURLButton (HWND hdlg, int id);
+
+
+/*
+ * Owner-draw a button as a URL
+ */
+
+static void
+winDrawURLWindow (LPARAM lParam)
+{
+ DRAWITEMSTRUCT *draw;
+ char str[256];
+ RECT rect;
+ HFONT font;
+ COLORREF crText;
+
+ draw = (DRAWITEMSTRUCT *) lParam;
+ GetWindowText (draw->hwndItem, str, sizeof(str));
+ str[255] = 0;
+ GetClientRect (draw->hwndItem, &rect);
+
+ /* Color the button depending upon its state */
+ if (draw->itemState & ODS_SELECTED)
+ crText = RGB(128+64,0,0);
+ else if (draw->itemState & ODS_FOCUS)
+ crText = RGB(0,128+64,0);
+ else
+ crText = RGB(0,0,128+64);
+ SetTextColor (draw->hDC, crText);
+
+ /* Create underlined font 14 high, standard dialog font */
+ font = CreateFont (-14, 0, 0, 0, FW_NORMAL, FALSE, TRUE, FALSE,
+ 0, 0, 0, 0, 0, "MS Sans Serif");
+ if (!font)
+ {
+ ErrorF ("winDrawURLWindow: Unable to create URL font, bailing.\n");
+ return;
+ }
+ /* Draw it */
+ SetBkMode (draw->hDC, OPAQUE);
+ SelectObject (draw->hDC, font);
+ DrawText (draw->hDC, str, strlen (str),&rect,DT_CENTER | DT_VCENTER);
+ /* Delete the created font, replace it with stock font */
+ DeleteObject (SelectObject (draw->hDC, GetStockObject (ANSI_VAR_FONT)));
+}
+
+
+/*
+ * WndProc for overridden buttons
+ */
+
+static LRESULT CALLBACK
+winURLWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ WNDPROC origCB = NULL;
+ HCURSOR cursor;
+
+ /* If it's a SetCursor message, tell it to the hand */
+ if (msg==WM_SETCURSOR) {
+ cursor = LoadCursor (NULL, IDC_HAND);
+ if (cursor)
+ SetCursor (cursor);
+ return TRUE;
+ }
+ origCB = (WNDPROC)GetWindowLong (hwnd, GWL_USERDATA);
+ /* Otherwise fall through to original WndProc */
+ if (origCB)
+ return CallWindowProc (origCB, hwnd, msg, wParam, lParam);
+ else
+ return FALSE;
+}
+
+
+/*
+ * Register and unregister the custom WndProc
+ */
+
+static void
+winOverrideURLButton (HWND hwnd, int id)
+{
+ WNDPROC origCB;
+ origCB = (WNDPROC)SetWindowLong (GetDlgItem (hwnd, id),
+ GWL_WNDPROC, (LONG)winURLWndProc);
+ SetWindowLong (GetDlgItem (hwnd, id), GWL_USERDATA, (LONG)origCB);
+}
+
+static void
+winUnoverrideURLButton (HWND hwnd, int id)
+{
+ WNDPROC origCB;
+ origCB = (WNDPROC)SetWindowLong (GetDlgItem (hwnd, id),
+ GWL_USERDATA, 0);
+ if (origCB)
+ SetWindowLong (GetDlgItem (hwnd, id), GWL_WNDPROC, (LONG)origCB);
+}
+
+
+/*
+ * Center a dialog window in the desktop window
+ */
+
+static void
+winCenterDialog (HWND hwndDlg)
+{
+ HWND hwndDesk;
+ RECT rc, rcDlg, rcDesk;
+
+ hwndDesk = GetParent (hwndDlg);
+ if (!hwndDesk || IsIconic (hwndDesk))
+ hwndDesk = GetDesktopWindow ();
+
+ GetWindowRect (hwndDesk, &rcDesk);
+ GetWindowRect (hwndDlg, &rcDlg);
+ CopyRect (&rc, &rcDesk);
+
+ OffsetRect (&rcDlg, -rcDlg.left, -rcDlg.top);
+ OffsetRect (&rc, -rc.left, -rc.top);
+ OffsetRect (&rc, -rcDlg.right, -rcDlg.bottom);
+
+ SetWindowPos (hwndDlg,
+ HWND_TOP,
+ rcDesk.left + (rc.right / 2),
+ rcDesk.top + (rc.bottom / 2),
+ 0, 0,
+ SWP_NOSIZE | SWP_NOZORDER);
+}
+
+
+/*
+ * Display the Exit dialog box
+ */
+
+void
+winDisplayExitDialog (winPrivScreenPtr pScreenPriv)
+{
+ int i;
+ int liveClients = 0;
+
+ /* Count up running clinets (clients[0] is serverClient) */
+ for (i = 1; i < currentMaxClients; i++)
+ if (clients[i] != NullClient)
+ liveClients++;
+#if defined(XWIN_MULTIWINDOW)
+ /* Count down server internal clients */
+ if (pScreenPriv->pScreenInfo->fMultiWindow)
+ liveClients -= 2; /* multiwindow window manager & XMsgProc */
+#endif
+#if defined(XWIN_CLIPBOARD)
+ if (g_fClipboardStarted)
+ liveClients--; /* clipboard manager */
+#endif
+
+ /* A user reported that this sometimes drops below zero. just eye-candy. */
+ if (liveClients < 0)
+ liveClients = 0;
+
+ /* Don't show the exit confirmation dialog if SilentExit is enabled */
+ if (pref.fSilentExit && liveClients <= 0)
+ {
+ if (g_hDlgExit != NULL)
+ {
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+ }
+ PostMessage (pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
+ return;
+ }
+
+ pScreenPriv->iConnectedClients = liveClients;
+
+ /* Check if dialog already exists */
+ if (g_hDlgExit != NULL)
+ {
+ /* Dialog box already exists, display it */
+ ShowWindow (g_hDlgExit, SW_SHOWDEFAULT);
+
+ /* User has lost the dialog. Show them where it is. */
+ SetForegroundWindow (g_hDlgExit);
+
+ return;
+ }
+
+ /* Create dialog box */
+ g_hDlgExit = CreateDialogParam (g_hInstance,
+ "EXIT_DIALOG",
+ pScreenPriv->hwndScreen,
+ winExitDlgProc,
+ (int) pScreenPriv);
+
+ /* Drop minimize and maximize buttons */
+ SetWindowLong (g_hDlgExit, GWL_STYLE,
+ GetWindowLong (g_hDlgExit, GWL_STYLE)
+ & ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
+ SetWindowLong (g_hDlgExit, GWL_EXSTYLE,
+ GetWindowLong (g_hDlgExit, GWL_EXSTYLE) & ~WS_EX_APPWINDOW );
+ SetWindowPos (g_hDlgExit, HWND_TOPMOST, 0, 0, 0, 0,
+ SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE);
+
+ /* Show the dialog box */
+ ShowWindow (g_hDlgExit, SW_SHOW);
+
+ /* Needed to get keyboard controls (tab, arrows, enter, esc) to work */
+ SetForegroundWindow (g_hDlgExit);
+
+ /* Set focus to the Cancel button */
+ PostMessage (g_hDlgExit, WM_NEXTDLGCTL,
+ (int) GetDlgItem (g_hDlgExit, IDCANCEL), TRUE);
+}
+
+#define CONNECTED_CLIENTS_FORMAT "There are currently %d clients connected."
+
+
+/*
+ * Exit dialog window procedure
+ */
+
+static wBOOL CALLBACK
+winExitDlgProc (HWND hDialog, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ static winPrivScreenPtr s_pScreenPriv = NULL;
+
+ /* Branch on message type */
+ switch (message)
+ {
+ case WM_INITDIALOG:
+ {
+ char *pszConnectedClients;
+
+ /* Store pointers to private structures for future use */
+ s_pScreenPriv = (winPrivScreenPtr) lParam;
+
+ winCenterDialog (hDialog);
+
+ /* Set icon to standard app icon */
+ PostMessage (hDialog,
+ WM_SETICON,
+ ICON_SMALL,
+ (LPARAM) LoadIcon (g_hInstance,
+ MAKEINTRESOURCE(IDI_XWIN)));
+
+ /* Format the connected clients string */
+ pszConnectedClients = Xprintf (CONNECTED_CLIENTS_FORMAT,
+ s_pScreenPriv->iConnectedClients);
+ if (!pszConnectedClients)
+ return TRUE;
+
+
+
+ /* Set the number of connected clients */
+ SetWindowText (GetDlgItem (hDialog, IDC_CLIENTS_CONNECTED),
+ pszConnectedClients);
+ xfree (pszConnectedClients);
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD (wParam))
+ {
+ case IDOK:
+ /* Send message to call the GiveUp function */
+ PostMessage (s_pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+ return TRUE;
+
+ case IDCANCEL:
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+ return TRUE;
+ }
+ break;
+
+ case WM_MOUSEMOVE:
+ case WM_NCMOUSEMOVE:
+ /* Show the cursor if it is hidden */
+ if (g_fSoftwareCursor && !g_fCursor)
+ {
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+ return TRUE;
+
+ case WM_CLOSE:
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+/*
+ * Display the Depth Change dialog box
+ */
+
+void
+winDisplayDepthChangeDialog (winPrivScreenPtr pScreenPriv)
+{
+ /* Check if dialog already exists */
+ if (g_hDlgDepthChange != NULL)
+ {
+ /* Dialog box already exists, display it */
+ ShowWindow (g_hDlgDepthChange, SW_SHOWDEFAULT);
+
+ /* User has lost the dialog. Show them where it is. */
+ SetForegroundWindow (g_hDlgDepthChange);
+
+ return;
+ }
+
+ /*
+ * Display a notification to the user that the visual
+ * will not be displayed until the Windows display depth
+ * is restored to the original value.
+ */
+ g_hDlgDepthChange = CreateDialogParam (g_hInstance,
+ "DEPTH_CHANGE_BOX",
+ pScreenPriv->hwndScreen,
+ winChangeDepthDlgProc,
+ (int) pScreenPriv);
+
+ /* Drop minimize and maximize buttons */
+ SetWindowLong (g_hDlgDepthChange, GWL_STYLE,
+ GetWindowLong (g_hDlgDepthChange, GWL_STYLE)
+ & ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
+ SetWindowLong (g_hDlgDepthChange, GWL_EXSTYLE,
+ GetWindowLong (g_hDlgDepthChange, GWL_EXSTYLE)
+ & ~WS_EX_APPWINDOW );
+ SetWindowPos (g_hDlgDepthChange, 0, 0, 0, 0, 0,
+ SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | SWP_NOSIZE);
+
+ /* Show the dialog box */
+ ShowWindow (g_hDlgDepthChange, SW_SHOW);
+
+ ErrorF ("winDisplayDepthChangeDialog - DialogBox returned: %d\n",
+ (int) g_hDlgDepthChange);
+ ErrorF ("winDisplayDepthChangeDialog - GetLastError: %d\n",
+ (int) GetLastError ());
+
+ /* Minimize the display window */
+ ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
+}
+
+
+/*
+ * Process messages for the dialog that is displayed for
+ * disruptive screen depth changes.
+ */
+
+static wBOOL CALLBACK
+winChangeDepthDlgProc (HWND hwndDialog, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ static winPrivScreenPtr s_pScreenPriv = NULL;
+ static winScreenInfo *s_pScreenInfo = NULL;
+ static ScreenPtr s_pScreen = NULL;
+
+#if CYGDEBUG
+ winDebug ("winChangeDepthDlgProc\n");
+#endif
+
+ /* Branch on message type */
+ switch (message)
+ {
+ case WM_INITDIALOG:
+#if CYGDEBUG
+ winDebug ("winChangeDepthDlgProc - WM_INITDIALOG\n");
+#endif
+
+ /* Store pointers to private structures for future use */
+ s_pScreenPriv = (winPrivScreenPtr) lParam;
+ s_pScreenInfo = s_pScreenPriv->pScreenInfo;
+ s_pScreen = s_pScreenInfo->pScreen;
+
+#if CYGDEBUG
+ winDebug ("winChangeDepthDlgProc - WM_INITDIALOG - s_pScreenPriv: %08x, "
+ "s_pScreenInfo: %08x, s_pScreen: %08x\n",
+ s_pScreenPriv, s_pScreenInfo, s_pScreen);
+#endif
+
+#if CYGDEBUG
+ winDebug ("winChangeDepthDlgProc - WM_INITDIALOG - orig bpp: %d, "
+ "last bpp: %d\n",
+ s_pScreenInfo->dwBPP,
+ s_pScreenPriv->dwLastWindowsBitsPixel);
+#endif
+
+ winCenterDialog( hwndDialog );
+
+ /* Set icon to standard app icon */
+ PostMessage (hwndDialog,
+ WM_SETICON,
+ ICON_SMALL,
+ (LPARAM) LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN)));
+
+ return TRUE;
+
+ case WM_DISPLAYCHANGE:
+#if CYGDEBUG
+ winDebug ("winChangeDepthDlgProc - WM_DISPLAYCHANGE - orig bpp: %d, "
+ "last bpp: %d, new bpp: %d\n",
+ s_pScreenInfo->dwBPP,
+ s_pScreenPriv->dwLastWindowsBitsPixel,
+ wParam);
+#endif
+
+ /* Dismiss the dialog if the display returns to the original depth */
+ if (wParam == s_pScreenInfo->dwBPP)
+ {
+ ErrorF ("winChangeDelthDlgProc - wParam == s_pScreenInfo->dwBPP\n");
+
+ /* Depth has been restored, dismiss dialog */
+ DestroyWindow (g_hDlgDepthChange);
+ g_hDlgDepthChange = NULL;
+
+ /* Flag that we have a valid screen depth */
+ s_pScreenPriv->fBadDepth = FALSE;
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD (wParam))
+ {
+ case IDOK:
+ case IDCANCEL:
+ ErrorF ("winChangeDepthDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
+
+ /*
+ * User dismissed the dialog, hide it until the
+ * display mode is restored.
+ */
+ ShowWindow (g_hDlgDepthChange, SW_HIDE);
+ return TRUE;
+ }
+ break;
+
+ case WM_CLOSE:
+ ErrorF ("winChangeDepthDlgProc - WM_CLOSE\n");
+
+ DestroyWindow (g_hDlgAbout);
+ g_hDlgAbout = NULL;
+
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+/*
+ * Display the About dialog box
+ */
+
+void
+winDisplayAboutDialog (winPrivScreenPtr pScreenPriv)
+{
+ /* Check if dialog already exists */
+ if (g_hDlgAbout != NULL)
+ {
+ /* Dialog box already exists, display it */
+ ShowWindow (g_hDlgAbout, SW_SHOWDEFAULT);
+
+ /* User has lost the dialog. Show them where it is. */
+ SetForegroundWindow (g_hDlgAbout);
+
+ return;
+ }
+
+ /*
+ * Display the about box
+ */
+ g_hDlgAbout = CreateDialogParam (g_hInstance,
+ "ABOUT_BOX",
+ pScreenPriv->hwndScreen,
+ winAboutDlgProc,
+ (int) pScreenPriv);
+
+ /* Drop minimize and maximize buttons */
+ SetWindowLong (g_hDlgAbout, GWL_STYLE,
+ GetWindowLong (g_hDlgAbout, GWL_STYLE)
+ & ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
+ SetWindowLong (g_hDlgAbout, GWL_EXSTYLE,
+ GetWindowLong (g_hDlgAbout, GWL_EXSTYLE) & ~WS_EX_APPWINDOW);
+ SetWindowPos (g_hDlgAbout, 0, 0, 0, 0, 0,
+ SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE);
+
+ /* Show the dialog box */
+ ShowWindow (g_hDlgAbout, SW_SHOW);
+
+ /* Needed to get keyboard controls (tab, arrows, enter, esc) to work */
+ SetForegroundWindow (g_hDlgAbout);
+
+ /* Set focus to the OK button */
+ PostMessage (g_hDlgAbout, WM_NEXTDLGCTL,
+ (int) GetDlgItem (g_hDlgAbout, IDOK), TRUE);
+}
+
+
+/*
+ * Process messages for the about dialog.
+ */
+
+static wBOOL CALLBACK
+winAboutDlgProc (HWND hwndDialog, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ static winPrivScreenPtr s_pScreenPriv = NULL;
+ static winScreenInfo *s_pScreenInfo = NULL;
+ static ScreenPtr s_pScreen = NULL;
+
+#if CYGDEBUG
+ winDebug ("winAboutDlgProc\n");
+#endif
+
+ /* Branch on message type */
+ switch (message)
+ {
+ case WM_INITDIALOG:
+#if CYGDEBUG
+ winDebug ("winAboutDlgProc - WM_INITDIALOG\n");
+#endif
+
+ /* Store pointers to private structures for future use */
+ s_pScreenPriv = (winPrivScreenPtr) lParam;
+ s_pScreenInfo = s_pScreenPriv->pScreenInfo;
+ s_pScreen = s_pScreenInfo->pScreen;
+
+ winCenterDialog (hwndDialog);
+
+ /* Set icon to standard app icon */
+ PostMessage (hwndDialog,
+ WM_SETICON,
+ ICON_SMALL,
+ (LPARAM) LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN)));
+
+ /* Override the URL buttons */
+ winOverrideURLButton (hwndDialog, ID_ABOUT_CHANGELOG);
+ winOverrideURLButton (hwndDialog, ID_ABOUT_WEBSITE);
+ winOverrideURLButton (hwndDialog, ID_ABOUT_UG);
+ winOverrideURLButton (hwndDialog, ID_ABOUT_FAQ);
+
+ return TRUE;
+
+ case WM_DRAWITEM:
+ /* Draw the URL buttons as needed */
+ winDrawURLWindow (lParam);
+ return TRUE;
+
+ case WM_MOUSEMOVE:
+ case WM_NCMOUSEMOVE:
+ /* Show the cursor if it is hidden */
+ if (g_fSoftwareCursor && !g_fCursor)
+ {
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD (wParam))
+ {
+ case IDOK:
+ case IDCANCEL:
+ ErrorF ("winAboutDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
+
+ DestroyWindow (g_hDlgAbout);
+ g_hDlgAbout = NULL;
+
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+
+ /* Restore window procedures for URL buttons */
+ winUnoverrideURLButton (hwndDialog, ID_ABOUT_CHANGELOG);
+ winUnoverrideURLButton (hwndDialog, ID_ABOUT_WEBSITE);
+ winUnoverrideURLButton (hwndDialog, ID_ABOUT_UG);
+ winUnoverrideURLButton (hwndDialog, ID_ABOUT_FAQ);
+
+ return TRUE;
+
+ case ID_ABOUT_CHANGELOG:
+ {
+ int iReturn;
+#ifdef __CYGWIN__
+ const char * pszCygPath = "/usr/X11R6/share/doc/"
+ "xorg-x11-xwin/changelog.html";
+ char pszWinPath[MAX_PATH + 1];
+
+ /* Convert the POSIX path to a Win32 path */
+ cygwin_conv_to_win32_path (pszCygPath, pszWinPath);
+#else
+ const char * pszWinPath = "http://x.cygwin.com/"
+ "devel/server/changelog.html";
+#endif
+
+ iReturn = (int) ShellExecute (NULL,
+ "open",
+ pszWinPath,
+ NULL,
+ NULL,
+ SW_MAXIMIZE);
+ if (iReturn < 32)
+ {
+ ErrorF ("winAboutDlgProc - WM_COMMAND - ID_ABOUT_CHANGELOG - "
+ "ShellExecute failed: %d\n",
+ iReturn);
+ }
+ }
+ return TRUE;
+
+ case ID_ABOUT_WEBSITE:
+ {
+ const char * pszPath = "http://x.cygwin.com/";
+ int iReturn;
+
+ iReturn = (int) ShellExecute (NULL,
+ "open",
+ pszPath,
+ NULL,
+ NULL,
+ SW_MAXIMIZE);
+ if (iReturn < 32)
+ {
+ ErrorF ("winAboutDlgProc - WM_COMMAND - ID_ABOUT_WEBSITE - "
+ "ShellExecute failed: %d\n",
+ iReturn);
+ }
+ }
+ return TRUE;
+
+ case ID_ABOUT_UG:
+ {
+ const char * pszPath = "http://x.cygwin.com/docs/ug/";
+ int iReturn;
+
+ iReturn = (int) ShellExecute (NULL,
+ "open",
+ pszPath,
+ NULL,
+ NULL,
+ SW_MAXIMIZE);
+ if (iReturn < 32)
+ {
+ ErrorF ("winAboutDlgProc - WM_COMMAND - ID_ABOUT_UG - "
+ "ShellExecute failed: %d\n",
+ iReturn);
+ }
+ }
+ return TRUE;
+
+ case ID_ABOUT_FAQ:
+ {
+ const char * pszPath = "http://x.cygwin.com/docs/faq/";
+ int iReturn;
+
+ iReturn = (int) ShellExecute (NULL,
+ "open",
+ pszPath,
+ NULL,
+ NULL,
+ SW_MAXIMIZE);
+ if (iReturn < 32)
+ {
+ ErrorF ("winAboutDlgProc - WM_COMMAND - ID_ABOUT_FAQ - "
+ "ShellExecute failed: %d\n",
+ iReturn);
+ }
+ }
+ return TRUE;
+ }
+ break;
+
+ case WM_CLOSE:
+ ErrorF ("winAboutDlgProc - WM_CLOSE\n");
+
+ DestroyWindow (g_hDlgAbout);
+ g_hDlgAbout = NULL;
+
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+
+ /* Restore window procedures for URL buttons */
+ winUnoverrideURLButton (hwndDialog, ID_ABOUT_CHANGELOG);
+ winUnoverrideURLButton (hwndDialog, ID_ABOUT_WEBSITE);
+ winUnoverrideURLButton (hwndDialog, ID_ABOUT_UG);
+ winUnoverrideURLButton (hwndDialog, ID_ABOUT_FAQ);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winengine.c b/nx-X11/programs/Xserver/hw/xwin/winengine.c
new file mode 100644
index 000000000..f0bc671e2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winengine.c
@@ -0,0 +1,336 @@
+/*
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winmsg.h"
+
+
+/*
+ * External global variables
+ */
+
+extern const GUID _IID_IDirectDraw4;
+
+
+/*
+ * Detect engines supported by current Windows version
+ * DirectDraw version and hardware
+ */
+
+void
+winDetectSupportedEngines ()
+{
+ OSVERSIONINFO osvi;
+
+ /* Initialize the engine support flags */
+ g_dwEnginesSupported = WIN_SERVER_SHADOW_GDI;
+
+#ifdef XWIN_NATIVEGDI
+ g_dwEnginesSupported |= WIN_SERVER_NATIVE_GDI;
+#endif
+
+ /* Get operating system version information */
+ ZeroMemory (&osvi, sizeof (osvi));
+ osvi.dwOSVersionInfoSize = sizeof (osvi);
+ GetVersionEx (&osvi);
+
+ /* Branch on platform ID */
+ switch (osvi.dwPlatformId)
+ {
+ case VER_PLATFORM_WIN32_NT:
+ /* Engine 4 is supported on NT only */
+ winErrorFVerb (2, "winDetectSupportedEngines - Windows NT/2000/XP\n");
+ break;
+
+ case VER_PLATFORM_WIN32_WINDOWS:
+ /* Engine 4 is supported on NT only */
+ winErrorFVerb (2, "winDetectSupportedEngines - Windows 95/98/Me\n");
+ break;
+ }
+
+ /* Do we have DirectDraw? */
+ if (g_hmodDirectDraw != NULL)
+ {
+ LPDIRECTDRAW lpdd = NULL;
+ LPDIRECTDRAW4 lpdd4 = NULL;
+ HRESULT ddrval;
+
+ /* Was the DirectDrawCreate function found? */
+ if (g_fpDirectDrawCreate == NULL)
+ {
+ /* No DirectDraw support */
+ return;
+ }
+
+ /* DirectDrawCreate exists, try to call it */
+ /* Create a DirectDraw object, store the address at lpdd */
+ ddrval = (*g_fpDirectDrawCreate) (NULL,
+ (void**) &lpdd,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ /* No DirectDraw support */
+ winErrorFVerb (2, "winDetectSupportedEngines - DirectDraw not installed\n");
+ return;
+ }
+ else
+ {
+ /* We have DirectDraw */
+ winErrorFVerb (2, "winDetectSupportedEngines - DirectDraw installed\n");
+ g_dwEnginesSupported |= WIN_SERVER_SHADOW_DD;
+
+#ifdef XWIN_PRIMARYFB
+ /* Allow PrimaryDD engine if NT */
+ if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
+ {
+ g_dwEnginesSupported |= WIN_SERVER_PRIMARY_DD;
+ winErrorFVerb (2, "winDetectSupportedEngines - Allowing PrimaryDD\n");
+ }
+#endif
+ }
+
+ /* Try to query for DirectDraw4 interface */
+ ddrval = IDirectDraw_QueryInterface (lpdd,
+ &IID_IDirectDraw4,
+ (LPVOID*) &lpdd4);
+ if (SUCCEEDED (ddrval))
+ {
+ /* We have DirectDraw4 */
+ winErrorFVerb (2, "winDetectSupportedEngines - DirectDraw4 installed\n");
+ g_dwEnginesSupported |= WIN_SERVER_SHADOW_DDNL;
+ }
+
+ /* Cleanup DirectDraw interfaces */
+ if (lpdd4 != NULL)
+ IDirectDraw_Release (lpdd4);
+ if (lpdd != NULL)
+ IDirectDraw_Release (lpdd);
+ }
+
+ winErrorFVerb (2, "winDetectSupportedEngines - Returning, supported engines %08x\n",
+ (unsigned int) g_dwEnginesSupported);
+}
+
+
+/*
+ * Set the engine type, depending on the engines
+ * supported for this screen, and whether the user
+ * suggested an engine type
+ */
+
+Bool
+winSetEngine (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc;
+ DWORD dwBPP;
+
+ /* Get a DC */
+ hdc = GetDC (NULL);
+ if (hdc == NULL)
+ {
+ ErrorF ("winSetEngine - Couldn't get an HDC\n");
+ return FALSE;
+ }
+
+ /*
+ * pScreenInfo->dwBPP may be 0 to indicate that the current screen
+ * depth is to be used. Thus, we must query for the current display
+ * depth here.
+ */
+ dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+
+ /* Release the DC */
+ ReleaseDC (NULL, hdc);
+ hdc = NULL;
+
+ /* ShadowGDI is the only engine that supports windowed PseudoColor */
+ if (dwBPP == 8 && !pScreenInfo->fFullScreen)
+ {
+ winErrorFVerb (2, "winSetEngine - Windowed && PseudoColor => ShadowGDI\n");
+ pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
+
+ /* Set engine function pointers */
+ winSetEngineFunctionsShadowGDI (pScreen);
+ return TRUE;
+ }
+
+ /* ShadowGDI is the only engine that supports Multi Window Mode */
+ if (
+#ifdef XWIN_MULTIWINDOWEXTWM
+ pScreenInfo->fMWExtWM
+#else
+ FALSE
+#endif
+#ifdef XWIN_MULTIWINDOW
+ || pScreenInfo->fMultiWindow
+#else
+ || FALSE
+#endif
+ )
+ {
+ winErrorFVerb (2, "winSetEngine - Multi Window or Rootless => ShadowGDI\n");
+ pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
+
+ /* Set engine function pointers */
+ winSetEngineFunctionsShadowGDI (pScreen);
+ return TRUE;
+ }
+
+ /* If the user's choice is supported, we'll use that */
+ if (g_dwEnginesSupported & pScreenInfo->dwEnginePreferred)
+ {
+ winErrorFVerb (2, "winSetEngine - Using user's preference: %d\n",
+ (int) pScreenInfo->dwEnginePreferred);
+ pScreenInfo->dwEngine = pScreenInfo->dwEnginePreferred;
+
+ /* Setup engine function pointers */
+ switch (pScreenInfo->dwEngine)
+ {
+ case WIN_SERVER_SHADOW_GDI:
+ winSetEngineFunctionsShadowGDI (pScreen);
+ break;
+ case WIN_SERVER_SHADOW_DD:
+ winSetEngineFunctionsShadowDD (pScreen);
+ break;
+ case WIN_SERVER_SHADOW_DDNL:
+ winSetEngineFunctionsShadowDDNL (pScreen);
+ break;
+#ifdef XWIN_PRIMARYFB
+ case WIN_SERVER_PRIMARY_DD:
+ winSetEngineFunctionsPrimaryDD (pScreen);
+ break;
+#endif
+#ifdef XWIN_NATIVEGDI
+ case WIN_SERVER_NATIVE_GDI:
+ winSetEngineFunctionsNativeGDI (pScreen);
+ break;
+#endif
+ default:
+ FatalError ("winSetEngine - Invalid engine type\n");
+ }
+ return TRUE;
+ }
+
+ /* ShadowDDNL has good performance, so why not */
+ if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DDNL)
+ {
+ winErrorFVerb (2, "winSetEngine - Using Shadow DirectDraw NonLocking\n");
+ pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DDNL;
+
+ /* Set engine function pointers */
+ winSetEngineFunctionsShadowDDNL (pScreen);
+ return TRUE;
+ }
+
+ /* ShadowDD is next in line */
+ if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DD)
+ {
+ winErrorFVerb (2, "winSetEngine - Using Shadow DirectDraw\n");
+ pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DD;
+
+ /* Set engine function pointers */
+ winSetEngineFunctionsShadowDD (pScreen);
+ return TRUE;
+ }
+
+ /* ShadowGDI is next in line */
+ if (g_dwEnginesSupported & WIN_SERVER_SHADOW_GDI)
+ {
+ winErrorFVerb (2, "winSetEngine - Using Shadow GDI DIB\n");
+ pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
+
+ /* Set engine function pointers */
+ winSetEngineFunctionsShadowGDI (pScreen);
+ return TRUE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Get procedure addresses for DirectDrawCreate and DirectDrawCreateClipper
+ */
+
+Bool
+winGetDDProcAddresses ()
+{
+ Bool fReturn = TRUE;
+
+ /* Load the DirectDraw library */
+ g_hmodDirectDraw = LoadLibraryEx ("ddraw.dll", NULL, 0);
+ if (g_hmodDirectDraw == NULL)
+ {
+ ErrorF ("winGetDDProcAddresses - Could not load ddraw.dll\n");
+ fReturn = TRUE;
+ goto winGetDDProcAddresses_Exit;
+ }
+
+ /* Try to get the DirectDrawCreate address */
+ g_fpDirectDrawCreate = GetProcAddress (g_hmodDirectDraw,
+ "DirectDrawCreate");
+ if (g_fpDirectDrawCreate == NULL)
+ {
+ ErrorF ("winGetDDProcAddresses - Could not get DirectDrawCreate "
+ "address\n");
+ fReturn = TRUE;
+ goto winGetDDProcAddresses_Exit;
+ }
+
+ /* Try to get the DirectDrawCreateClipper address */
+ g_fpDirectDrawCreateClipper = GetProcAddress (g_hmodDirectDraw,
+ "DirectDrawCreateClipper");
+ if (g_fpDirectDrawCreateClipper == NULL)
+ {
+ ErrorF ("winGetDDProcAddresses - Could not get "
+ "DirectDrawCreateClipper address\n");
+ fReturn = FALSE;
+ goto winGetDDProcAddresses_Exit;
+ }
+
+ /*
+ * Note: Do not unload ddraw.dll here. Do it in GiveUp
+ */
+
+ winGetDDProcAddresses_Exit:
+ /* Unload the DirectDraw library if we failed to initialize */
+ if (!fReturn && g_hmodDirectDraw != NULL)
+ {
+ FreeLibrary (g_hmodDirectDraw);
+ g_hmodDirectDraw = NULL;
+ }
+
+ return fReturn;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winerror.c b/nx-X11/programs/Xserver/hw/xwin/winerror.c
new file mode 100644
index 000000000..7d292134f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winerror.c
@@ -0,0 +1,143 @@
+/*
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#ifdef XVENDORNAME
+#define VENDOR_STRING XVENDORNAME
+#define VERSION_STRING XORG_RELEASE
+#define VENDOR_CONTACT BUILDERADDR
+#endif
+
+#include "win.h"
+
+/* References to external symbols */
+extern char * g_pszCommandLine;
+extern char * g_pszLogFile;
+extern Bool g_fSilentFatalError;
+
+
+#ifdef DDXOSVERRORF
+/* Prototype */
+void
+OsVendorVErrorF (const char *pszFormat, va_list va_args);
+
+void
+OsVendorVErrorF (const char *pszFormat, va_list va_args)
+{
+#if defined(XWIN_CLIPBOARD) || defined (XWIN_MULTIWINDOW)
+ /* make sure the clipboard and multiwindow threads do not interfere the
+ * main thread */
+ static pthread_mutex_t s_pmPrinting = PTHREAD_MUTEX_INITIALIZER;
+
+ /* Lock the printing mutex */
+ pthread_mutex_lock (&s_pmPrinting);
+#endif
+
+ /* Print the error message to a log file, could be stderr */
+ LogVWrite (0, pszFormat, va_args);
+
+#if defined(XWIN_CLIPBOARD) || defined (XWIN_MULTIWINDOW)
+ /* Unlock the printing mutex */
+ pthread_mutex_unlock (&s_pmPrinting);
+#endif
+}
+#endif
+
+
+/*
+ * os/util.c/FatalError () calls our vendor ErrorF, so the message
+ * from a FatalError will be logged. Thus, the message for the
+ * fatal error is not passed to this function.
+ *
+ * Attempt to do last-ditch, safe, important cleanup here.
+ */
+#ifdef DDXOSFATALERROR
+void
+OsVendorFatalError (void)
+{
+ /* Don't give duplicate warning if UseMsg was called */
+ if (g_fSilentFatalError)
+ return;
+
+ winMessageBoxF (
+ "A fatal error has occurred and " PROJECT_NAME " will now exit.\n" \
+ "Please open %s for more information.\n",
+ MB_ICONERROR, (g_pszLogFile?g_pszLogFile:"the logfile"));
+}
+#endif
+
+
+/*
+ * winMessageBoxF - Print a formatted error message in a useful
+ * message box.
+ */
+
+void
+winMessageBoxF (const char *pszError, UINT uType, ...)
+{
+ char * pszErrorF = NULL;
+ char * pszMsgBox = NULL;
+ va_list args;
+
+ va_start(args, uType);
+ pszErrorF = Xvprintf(pszError, args);
+ va_end(args);
+ if (!pszErrorF)
+ goto winMessageBoxF_Cleanup;
+
+#define MESSAGEBOXF \
+ "%s\n" \
+ "Vendor: %s\n" \
+ "Release: %s\n" \
+ "Contact: %s\n" \
+ "XWin was started with the following command-line:\n\n" \
+ "%s\n"
+
+ pszMsgBox = Xprintf (MESSAGEBOXF,
+ pszErrorF, VENDOR_STRING, VERSION_STRING, VENDOR_CONTACT,
+ g_pszCommandLine);
+ if (!pszMsgBox)
+ goto winMessageBoxF_Cleanup;
+
+ /* Display the message box string */
+ MessageBox (NULL,
+ pszMsgBox,
+ PROJECT_NAME,
+ MB_OK | uType);
+
+ winMessageBoxF_Cleanup:
+ if (pszErrorF)
+ xfree (pszErrorF);
+ if (pszMsgBox)
+ xfree (pszMsgBox);
+#undef MESSAGEBOXF
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winfillsp.c b/nx-X11/programs/Xserver/hw/xwin/winfillsp.c
new file mode 100644
index 000000000..43ccde67c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winfillsp.c
@@ -0,0 +1,876 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Harold L Hunt II
+ * Alan Hourihane <alanh@fairlite.demon.co.uk>
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winfillsp.c,v 1.9 2001/11/01 12:19:40 alanh Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * References to external symbols
+ */
+
+extern int g_iPixmapPrivateIndex;
+extern int g_iGCPrivateIndex;
+extern int g_copyROP[];
+
+
+extern void ROP16(HDC hdc, int rop);
+
+#define TRANSLATE_COLOR(color) \
+{ \
+ if (pDrawable->depth == 15) \
+ color = ((color & 0x1F) << 19) | ((color & 0x03E0) << 6) | \
+ ((color & 0xF800) >> 8); \
+ else if (pDrawable->depth == 16) \
+ color = ((color & 0x1F) << 19) | ((color & 0x07E0) << 5) | \
+ ((color & 0xF800) >> 8); \
+ else if (pDrawable->depth == 24 || pDrawable->depth == 32) \
+ color = ((color & 0xFF) << 16) | (color & 0xFF00) | \
+ ((color & 0xFF0000) >> 16); \
+}
+
+/* See Porting Layer Definition - p. 54 */
+void
+winFillSpansNativeGDI (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int iSpans,
+ DDXPointPtr pPoints,
+ int *piWidths,
+ int fSorted)
+{
+ winGCPriv(pGC);
+ HBITMAP hbmpOrig = NULL, hbmpOrigStipple = NULL;
+ HBITMAP hPenOrig = NULL;
+ HBITMAP hBitmap = NULL;
+ PixmapPtr pPixmap = NULL;
+ winPrivPixmapPtr pPixmapPriv = NULL;
+ PixmapPtr pStipple = NULL;
+ winPrivPixmapPtr pStipplePriv = NULL;
+ PixmapPtr pTile = NULL;
+ winPrivPixmapPtr pTilePriv = NULL;
+ HDC hdcStipple = NULL, hdcTile = NULL;
+ HPEN hPen = NULL;
+ int iX;
+ int fg, bg;
+ RegionPtr pClip = pGC->pCompositeClip;
+ BoxPtr pextent, pbox;
+ int nbox;
+ int extentX1, extentX2, extentY1, extentY2;
+ int fullX1, fullX2, fullY1;
+ HRGN hrgn = NULL, combined = NULL;
+
+ nbox = REGION_NUM_RECTS (pClip);
+ pbox = REGION_RECTS (pClip);
+
+ if (!nbox) return;
+
+ combined = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+ nbox--; pbox++;
+
+ while (nbox--)
+ {
+ hrgn = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+ CombineRgn (combined, combined, hrgn, RGN_OR);
+ DeleteObject (hrgn);
+ hrgn = NULL;
+ pbox++;
+ }
+
+ pextent = REGION_EXTENTS (pGC->pScreen, pClip);
+ extentX1 = pextent->x1;
+ extentY1 = pextent->y1;
+ extentX2 = pextent->x2;
+ extentY2 = pextent->y2;
+
+ /* Branch on the type of drawable we have */
+ switch (pDrawable->type)
+ {
+ case DRAWABLE_PIXMAP:
+
+ SelectClipRgn (pGCPriv->hdcMem, combined);
+ DeleteObject (combined);
+ combined = NULL;
+
+ /* Get a pixmap pointer from the drawable pointer, and fetch privates */
+ pPixmap = (PixmapPtr) pDrawable;
+ pPixmapPriv = winGetPixmapPriv (pPixmap);
+
+ /* Select the drawable pixmap into memory hdc */
+ hbmpOrig = SelectObject (pGCPriv->hdcMem, pPixmapPriv->hBitmap);
+ if (hbmpOrig == NULL)
+ FatalError ("winFillSpans - DRAWABLE_PIXMAP - "
+ "SelectObject () failed on\n\tpPixmapPriv->hBitmap: "
+ "%08x\n", (unsigned int) pPixmapPriv->hBitmap);
+
+ /* Branch on the fill type */
+ switch (pGC->fillStyle)
+ {
+ case FillSolid:
+
+ ROP16 (pGCPriv->hdcMem, pGC->alu);
+
+ if (pDrawable->depth == 1)
+ {
+ if (pGC->fgPixel == 0)
+ hPenOrig = SelectObject (pGCPriv->hdcMem,
+ GetStockObject (BLACK_PEN));
+ else
+ hPenOrig = SelectObject (pGCPriv->hdcMem,
+ GetStockObject (WHITE_PEN));
+ }
+ else
+ {
+ fg = pGC->fgPixel;
+ TRANSLATE_COLOR (fg);
+ hPen = CreatePen (PS_SOLID, 0, fg);
+ hPenOrig = SelectObject (pGCPriv->hdcMem, hPen);
+ }
+
+ while (iSpans--)
+ {
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ MoveToEx (pGCPriv->hdcMem, fullX1, fullY1, NULL);
+ LineTo (pGCPriv->hdcMem, fullX2, fullY1);
+ }
+
+ SetROP2 (pGCPriv->hdcMem, R2_COPYPEN);
+
+ /* Give back the Pen */
+ SelectObject (pGCPriv->hdcMem, hPenOrig);
+
+ if (pDrawable->depth != 1)
+ DeleteObject (hPen);
+ break;
+
+ case FillOpaqueStippled:
+
+ pStipple = pGC->stipple;
+ pStipplePriv = winGetPixmapPriv (pStipple);
+
+ /* Create a device-dependent bitmap for the stipple */
+ hBitmap = CreateDIBitmap (pGCPriv->hdcMem,
+ (BITMAPINFOHEADER *)pStipplePriv->pbmih,
+ CBM_INIT,
+ pStipplePriv->pbBits,
+ (BITMAPINFO *)pStipplePriv->pbmih,
+ DIB_RGB_COLORS);
+
+ /* Create a memory DC to hold the stipple */
+ hdcStipple = CreateCompatibleDC (pGCPriv->hdcMem);
+
+ /* Select the stipple bitmap into the stipple DC */
+ hbmpOrigStipple = SelectObject (hdcStipple, hBitmap);
+ if (hbmpOrigStipple == NULL)
+ FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
+ "SelectObject () failed on hbmpOrigStipple\n");
+
+ /* Make a temporary copy of the foreground and background colors */
+ bg = pGC->bgPixel;
+ fg = pGC->fgPixel;
+
+ /* Translate the depth-dependent colors to Win32 COLORREFs */
+ TRANSLATE_COLOR (fg);
+ TRANSLATE_COLOR (bg);
+ SetTextColor (pGCPriv->hdcMem, fg);
+ SetBkColor (pGCPriv->hdcMem, bg);
+
+ while (iSpans--)
+ {
+ int width = pStipple->drawable.width;
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width)
+ {
+ int xoffset;
+
+ if ((iX + pStipple->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pStipple->drawable.width;
+
+ if (iX == fullX1)
+ xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pStipple->drawable.width) - pStipple->drawable.width)) % pStipple->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pStipple->drawable.width)
+ width = pStipple->drawable.width - xoffset;
+
+ BitBlt (pGCPriv->hdcMem,
+ iX, fullY1,
+ width, 1,
+ hdcStipple,
+ xoffset,
+ (fullY1 - (pDrawable->y + (pGC->patOrg.y % pStipple->drawable.height) - pStipple->drawable.height)) % pStipple->drawable.height,
+ g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Clear the stipple HDC */
+ SelectObject (hdcStipple, hbmpOrigStipple);
+ DeleteDC (hdcStipple);
+
+ /* Delete the device dependent stipple bitmap */
+ DeleteObject (hBitmap);
+
+ break;
+ case FillStippled:
+
+ pStipple = pGC->stipple;
+ pStipplePriv = winGetPixmapPriv (pStipple);
+
+ /* Create a device-dependent bitmap for the stipple */
+ hBitmap = CreateDIBitmap (pGCPriv->hdcMem,
+ (BITMAPINFOHEADER *)pStipplePriv->pbmih,
+ CBM_INIT,
+ pStipplePriv->pbBits,
+ (BITMAPINFO *)pStipplePriv->pbmih,
+ DIB_RGB_COLORS);
+
+ /* Create a memory DC to hold the stipple */
+ hdcStipple = CreateCompatibleDC (pGCPriv->hdcMem);
+
+ /* Select the stipple bitmap into the stipple DC */
+ hbmpOrigStipple = SelectObject (hdcStipple, hBitmap);
+ if (hbmpOrigStipple == NULL)
+ FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
+ "SelectObject () failed on hbmpOrigStipple\n");
+
+ /* Make a temporary copy of the foreground and background colors */
+ bg = pGC->bgPixel;
+ fg = pGC->fgPixel;
+
+ /* Translate the depth-dependent colors to Win32 COLORREFs */
+ TRANSLATE_COLOR (fg);
+ TRANSLATE_COLOR (bg);
+
+ /* this is fudgy, we should only invert on the last one
+ * We need to get the black/white pixels right in the
+ * colormap. But yeah ! it's working..
+ */
+ if (pGC->bgPixel != -1 && pGC->fgPixel != -1)
+ {
+ SetTextColor (pGCPriv->hdcMem, fg);
+ SetBkColor (pGCPriv->hdcMem, bg);
+ BitBlt (hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple,
+ 0, 0,
+ 0x330008);
+ }
+ else if (pGC->bgPixel == -1)
+ {
+ SetTextColor (pGCPriv->hdcMem, fg);
+ SetBkMode (pGCPriv->hdcMem, TRANSPARENT);
+ BitBlt (hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple,
+ 0, 0,
+ 0x330008);
+ }
+ else if (pGC->fgPixel == -1)
+ {
+ SetTextColor (pGCPriv->hdcMem, bg);
+ SetBkMode (pGCPriv->hdcMem, TRANSPARENT);
+#if 0
+ BitBlt (hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple,
+ 0, 0,
+ 0x330008);
+#endif
+ }
+
+ while (iSpans--)
+ {
+ int width = pStipple->drawable.width;
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width)
+ {
+ int xoffset;
+
+ if ((iX + pStipple->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pStipple->drawable.width;
+
+ if (iX == fullX1)
+ xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pStipple->drawable.width) - pStipple->drawable.width)) % pStipple->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pStipple->drawable.width)
+ width = pStipple->drawable.width - xoffset;
+
+ BitBlt (pGCPriv->hdcMem,
+ iX, fullY1,
+ width, 1,
+ hdcStipple,
+ xoffset,
+ (fullY1 - (pDrawable->y + (pGC->patOrg.y % pStipple->drawable.height) - pStipple->drawable.height)) % pStipple->drawable.height,
+ g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Clear the stipple HDC */
+ SelectObject (hdcStipple, hbmpOrigStipple);
+ DeleteDC (hdcStipple);
+
+ /* Delete the device dependent stipple bitmap */
+ DeleteObject (hBitmap);
+
+ /* Restore the background mode */
+ SetBkMode (pGCPriv->hdcMem, OPAQUE);
+ break;
+
+ case FillTiled:
+
+ /* Get a pixmap pointer from the tile pointer, and fetch privates */
+ pTile = (PixmapPtr) pGC->tile.pixmap;
+ pTilePriv = winGetPixmapPriv (pTile);
+
+ /* Create a memory DC to hold the tile */
+ hdcTile = CreateCompatibleDC (pGCPriv->hdcMem);
+
+ /* Select the tile into a DC */
+ hbmpOrig = SelectObject (hdcTile, pTilePriv->hBitmap);
+ if (hbmpOrig == NULL)
+ FatalError ("winFillSpans - DRAWABLE_PIXMAP - FillTiled - "
+ "SelectObject () failed on pTilePriv->hBitmap\n");
+
+ while (iSpans--)
+ {
+ int width = pTile->drawable.width;
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width)
+ {
+ int xoffset;
+
+ if ((iX + pTile->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pTile->drawable.width;
+
+ if (iX == fullX1)
+ xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pTile->drawable.width) - pTile->drawable.width)) % pTile->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pTile->drawable.width)
+ width = pTile->drawable.width - xoffset;
+
+ BitBlt (pGCPriv->hdcMem,
+ iX, fullY1,
+ width, 1,
+ hdcTile,
+ xoffset,
+ (fullY1 - (pDrawable->y + (pGC->patOrg.y % pTile->drawable.height) - pTile->drawable.height)) % pTile->drawable.height,
+ g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Push the tile pixmap out of the memory HDC */
+ SelectObject (hdcTile, hbmpOrig);
+
+ /* Delete the tile */
+ DeleteDC (hdcTile);
+ break;
+
+ default:
+ ErrorF ("winFillSpans - DRAWABLE_PIXMAP - Unknown fillStyle\n");
+ break;
+ }
+
+ /* Reset clip region */
+ SelectClipRgn (pGCPriv->hdcMem, NULL);
+
+ /* Push the drawable pixmap out of the GC HDC */
+ SelectObject (pGCPriv->hdcMem, hbmpOrig);
+ break;
+
+ case DRAWABLE_WINDOW:
+
+ SelectClipRgn (pGCPriv->hdc, combined);
+ DeleteObject (combined);
+ combined = NULL;
+
+ /* Branch on fill style */
+ switch (pGC->fillStyle)
+ {
+ case FillSolid:
+
+ ROP16 (pGCPriv->hdc, pGC->alu);
+
+ if (pDrawable->depth == 1)
+ {
+ if (pGC->fgPixel == 0)
+ hPenOrig = SelectObject (pGCPriv->hdc,
+ GetStockObject (BLACK_PEN));
+ else
+ hPenOrig = SelectObject (pGCPriv->hdc,
+ GetStockObject (WHITE_PEN));
+ }
+ else
+ {
+ fg = pGC->fgPixel;
+ TRANSLATE_COLOR (fg);
+ hPen = CreatePen (PS_SOLID, 0, fg);
+ hPenOrig = SelectObject (pGCPriv->hdc, hPen);
+ }
+
+ while (iSpans--)
+ {
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ MoveToEx (pGCPriv->hdc, fullX1, fullY1, NULL);
+ LineTo (pGCPriv->hdc, fullX2, fullY1);
+ }
+
+ SetROP2 (pGCPriv->hdc, R2_COPYPEN);
+
+ /* Give back the Brush */
+ SelectObject (pGCPriv->hdc, hPenOrig);
+
+ if (pDrawable->depth != 1)
+ DeleteObject (hPen);
+ break;
+
+ case FillOpaqueStippled:
+
+ pStipple = pGC->stipple;
+ pStipplePriv = winGetPixmapPriv (pStipple);
+
+ /* Create a device-dependent bitmap for the stipple */
+ hBitmap = CreateDIBitmap (pGCPriv->hdc,
+ (BITMAPINFOHEADER *)pStipplePriv->pbmih,
+ CBM_INIT,
+ pStipplePriv->pbBits,
+ (BITMAPINFO *)pStipplePriv->pbmih,
+ DIB_RGB_COLORS);
+
+ /* Create a memory DC to hold the stipple */
+ hdcStipple = CreateCompatibleDC (pGCPriv->hdc);
+
+ /* Select the stipple bitmap into the stipple DC */
+ hbmpOrigStipple = SelectObject (hdcStipple, hBitmap);
+ if (hbmpOrigStipple == NULL)
+ FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
+ "SelectObject () failed on hbmpOrigStipple\n");
+
+ /* Make a temporary copy of the foreground and background colors */
+ bg = pGC->bgPixel;
+ fg = pGC->fgPixel;
+
+ /* Translate the depth-dependent colors to Win32 COLORREFs */
+ TRANSLATE_COLOR (fg);
+ TRANSLATE_COLOR (bg);
+ SetTextColor (pGCPriv->hdc, fg);
+ SetBkColor (pGCPriv->hdc, bg);
+
+ while (iSpans--)
+ {
+ int width = pStipple->drawable.width;
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width)
+ {
+ int xoffset;
+
+ if ((iX + pStipple->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pStipple->drawable.width;
+
+ if (iX == fullX1)
+ xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pStipple->drawable.width) - pStipple->drawable.width)) % pStipple->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pStipple->drawable.width)
+ width = pStipple->drawable.width - xoffset;
+
+ BitBlt (pGCPriv->hdc,
+ iX, fullY1,
+ width, 1,
+ hdcStipple,
+ xoffset,
+ (fullY1 - (pDrawable->y + (pGC->patOrg.y % pStipple->drawable.height) - pStipple->drawable.height)) % pStipple->drawable.height,
+ g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Clear the stipple HDC */
+ SelectObject (hdcStipple, hbmpOrigStipple);
+ DeleteDC (hdcStipple);
+
+ /* Delete the device dependent stipple bitmap */
+ DeleteObject (hBitmap);
+
+ break;
+
+ case FillStippled:
+ pStipple = pGC->stipple;
+ pStipplePriv = winGetPixmapPriv (pStipple);
+
+ /* Create a device-dependent bitmap for the stipple */
+ hBitmap = CreateDIBitmap (pGCPriv->hdcMem,
+ (BITMAPINFOHEADER *)pStipplePriv->pbmih,
+ CBM_INIT,
+ pStipplePriv->pbBits,
+ (BITMAPINFO *)pStipplePriv->pbmih,
+ DIB_RGB_COLORS);
+
+ /* Create a memory DC to hold the stipple */
+ hdcStipple = CreateCompatibleDC (pGCPriv->hdc);
+
+ /* Select the stipple bitmap into the stipple DC */
+ hbmpOrigStipple = SelectObject (hdcStipple, hBitmap);
+ if (hbmpOrigStipple == NULL)
+ FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
+ "SelectObject () failed on hbmpOrigStipple\n");
+
+ /* Make a temporary copy of the foreground and background colors */
+ bg = pGC->bgPixel;
+ fg = pGC->fgPixel;
+
+ /* Translate the depth-dependent colors to Win32 COLORREFs */
+ TRANSLATE_COLOR (fg);
+ TRANSLATE_COLOR (bg);
+
+ /* this is fudgy, we should only invert on the last one
+ * We need to get the black/white pixels right in the
+ * colormap. But yeah ! it's working..
+ */
+ if (pGC->bgPixel != -1 && pGC->fgPixel != -1)
+ {
+ SetTextColor (pGCPriv->hdc, fg);
+ SetBkColor (pGCPriv->hdc, bg);
+ BitBlt (hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple,
+ 0,0,
+ 0x330008);
+ }
+ else if (pGC->bgPixel == -1)
+ {
+ SetTextColor (pGCPriv->hdc, fg);
+ SetBkMode (pGCPriv->hdc, TRANSPARENT);
+ BitBlt (hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple,
+ 0,0,
+ 0x330008);
+ }
+ else if (pGC->fgPixel == -1)
+ {
+ SetTextColor (pGCPriv->hdc, bg);
+ SetBkMode (pGCPriv->hdc, TRANSPARENT);
+#if 0
+ BitBlt (hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple,
+ 0, 0,
+ 0x330008);
+#endif
+ }
+
+ while (iSpans--)
+ {
+ int width = pStipple->drawable.width;
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width)
+ {
+ int xoffset;
+
+ if ((iX + pStipple->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pStipple->drawable.width;
+
+ if (iX == fullX1)
+ xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pStipple->drawable.width) - pStipple->drawable.width)) % pStipple->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pStipple->drawable.width)
+ width = pStipple->drawable.width - xoffset;
+
+ BitBlt (pGCPriv->hdc,
+ iX, fullY1,
+ width, 1,
+ hdcStipple,
+ xoffset,
+ (fullY1 - (pDrawable->y + (pGC->patOrg.y % pStipple->drawable.height) - pStipple->drawable.height)) % pStipple->drawable.height,
+ g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Clear the stipple HDC */
+ SelectObject (hdcStipple, hbmpOrigStipple);
+ DeleteDC (hdcStipple);
+
+ /* Delete the device dependent stipple bitmap */
+ DeleteObject (hBitmap);
+
+ /* Restore the background mode */
+ SetBkMode (pGCPriv->hdc, OPAQUE);
+ break;
+
+ case FillTiled:
+
+ /* Get a pixmap pointer from the tile pointer, and fetch privates */
+ pTile = (PixmapPtr) pGC->tile.pixmap;
+ pTilePriv = winGetPixmapPriv (pTile);
+
+ /* Select the tile into a DC */
+ hbmpOrig = SelectObject (pGCPriv->hdcMem, pTilePriv->hBitmap);
+ if (hbmpOrig == NULL)
+ FatalError ("winFillSpans - DRAWABLE_WINDOW - FillTiled - "
+ "SelectObject () failed on pTilePriv->hBitmap\n");
+
+ while (iSpans--)
+ {
+ int width = pTile->drawable.width;
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width)
+ {
+ int xoffset;
+
+ if ((iX + pTile->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pTile->drawable.width;
+
+ if (iX == fullX1)
+ xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pTile->drawable.width) - pTile->drawable.width)) % pTile->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pTile->drawable.width)
+ width = pTile->drawable.width - xoffset;
+
+ BitBlt (pGCPriv->hdc,
+ iX, fullY1,
+ width, 1,
+ pGCPriv->hdcMem,
+ xoffset,
+ (fullY1 - (pDrawable->y + (pGC->patOrg.y % pTile->drawable.height) - pTile->drawable.height)) % pTile->drawable.height,
+ g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Push the tile pixmap out of the memory HDC */
+ SelectObject (pGCPriv->hdcMem, hbmpOrig);
+ break;
+
+ default:
+ ErrorF ("winFillSpans - DRAWABLE_WINDOW - Unknown fillStyle\n");
+ break;
+ }
+
+ /* Reset clip region */
+ SelectClipRgn (pGCPriv->hdc, NULL);
+ break;
+
+ case UNDRAWABLE_WINDOW:
+ /* UNDRAWABLE_WINDOW doesn't appear to get called when running xterm */
+ switch (pGC->fillStyle)
+ {
+ case FillSolid:
+ ErrorF ("winFillSpans - UNDRAWABLE_WINDOW - FillSolid - "
+ "Unimplemented\n");
+ break;
+
+ case FillStippled:
+ ErrorF ("winFillSpans - UNDRAWABLE_WINDOW - FillStippled - "
+ "Unimplemented\n");
+ break;
+
+ case FillTiled:
+ ErrorF ("winFillSpans - UNDRAWABLE_WINDOW - FillTiled - "
+ "Unimplemented\n");
+ break;
+
+ case FillOpaqueStippled:
+ ErrorF ("winFillSpans - UNDRAWABLE_WINDOW - OpaqueStippled - "
+ "Unimplemented\n");
+ break;
+
+ default:
+ ErrorF ("winFillSpans - UNDRAWABLE_WINDOW - Unknown fillStyle\n");
+ break;
+ }
+ break;
+
+ case DRAWABLE_BUFFER:
+ /* DRAWABLE_BUFFER seems to be undocumented. */
+ ErrorF ("winFillSpans - DRAWABLE_BUFFER - Unimplemented\n");
+ break;
+
+ default:
+ ErrorF ("winFillSpans - Unknown drawable type\n");
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winfont.c b/nx-X11/programs/Xserver/hw/xwin/winfont.c
new file mode 100644
index 000000000..af3e90da5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winfont.c
@@ -0,0 +1,80 @@
+/*
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+#ifdef XWIN_NATIVEGDI
+/* See Porting Layer Definition - p. 32 */
+/* See mfb/mfbfont.c - mfbRealizeFont() - which is empty :) */
+Bool
+winRealizeFontNativeGDI (ScreenPtr pScreen, FontPtr pFont)
+{
+ BOOL fResult = TRUE;
+ winScreenPriv(pScreen);
+
+#if CYGDEBUG
+ winTrace ("winRealizeFont (%p, %p)\n", pScreen, pFont);
+#endif
+
+ WIN_UNWRAP(RealizeFont);
+ if (pScreen->RealizeFont)
+ fResult = (*pScreen->RealizeFont) (pScreen, pFont);
+ WIN_WRAP(RealizeFont, winRealizeFontNativeGDI);
+
+ return fResult;
+}
+
+/* See Porting Layer Definition - p. 32 */
+/* See mfb/mfbfont.c - mfbUnrealizeFont() - which is empty :) */
+Bool
+winUnrealizeFontNativeGDI (ScreenPtr pScreen, FontPtr pFont)
+{
+ BOOL fResult = TRUE;
+ winScreenPriv(pScreen);
+
+#if CYGDEBUG
+ winTrace ("winUnrealizeFont (%p, %p)\n", pScreen, pFont);
+#endif
+
+ WIN_UNWRAP(UnrealizeFont);
+ if (pScreen->UnrealizeFont)
+ fResult = (*pScreen->UnrealizeFont) (pScreen, pFont);
+ WIN_WRAP(UnrealizeFont, winUnrealizeFontNativeGDI);
+
+ return fResult;
+#if CYGDEBUG
+ winDebug ("winUnrealizeFont()\n");
+#endif
+ return TRUE;
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/wingc.c b/nx-X11/programs/Xserver/hw/xwin/wingc.c
new file mode 100644
index 000000000..3f661d520
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/wingc.c
@@ -0,0 +1,259 @@
+/*
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+void
+winPushPixels (GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable, int dx, int dy, int xOrg, int yOrg);
+
+
+/*
+ * Local prototypes
+ */
+
+#if 0
+static void
+winChangeGCNativeGDI (GCPtr pGC, unsigned long ulChanges);
+#endif
+
+static void
+winValidateGCNativeGDI (GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDrawable);
+
+#if 0
+static void
+winCopyGCNativeGDI (GCPtr pGCsrc, unsigned long ulMask, GCPtr pGCdst);
+#endif
+
+static void
+winDestroyGCNativeGDI (GCPtr pGC);
+
+#if 0
+static void
+winChangeClipNativeGDI (GCPtr pGC, int nType, pointer pValue, int nRects);
+
+static void
+winDestroyClipNativeGDI (GCPtr pGC);
+
+static void
+winCopyClipNativeGDI (GCPtr pGCdst, GCPtr pGCsrc);
+#endif
+
+#if 0
+/* GC Handling Routines */
+const GCFuncs winGCFuncs = {
+ winValidateGCNativeGDI,
+ winChangeGCNativeGDI,
+ winCopyGCNativeGDI,
+ winDestroyGCNativeGDI,
+ winChangeClipNativeGDI,
+ winDestroyClipNativeGDI,
+ winCopyClipNativeGDI,
+};
+#else
+const GCFuncs winGCFuncs = {
+ winValidateGCNativeGDI,
+ miChangeGC,
+ miCopyGC,
+ winDestroyGCNativeGDI,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip,
+};
+#endif
+
+/* Drawing Primitives */
+const GCOps winGCOps = {
+ winFillSpansNativeGDI,
+ winSetSpansNativeGDI,
+ miPutImage,
+ miCopyArea,
+ miCopyPlane,
+ miPolyPoint,
+ winPolyLineNativeGDI,
+ miPolySegment,
+ miPolyRectangle,
+ miPolyArc,
+ miFillPolygon,
+ miPolyFillRect,
+ miPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+#if 0
+ winImageGlyphBltNativeGDI,
+ winPolyGlyphBltNativeGDI,
+#else
+ miImageGlyphBlt,
+ miPolyGlyphBlt,
+#endif
+ winPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+
+/* See Porting Layer Definition - p. 45 */
+/* See mfb/mfbgc.c - mfbCreateGC() */
+/* See Strategies for Porting - pp. 15, 16 */
+Bool
+winCreateGCNativeGDI (GCPtr pGC)
+{
+ winPrivGCPtr pGCPriv = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+
+#if 0
+ ErrorF ("winCreateGCNativeGDI - depth: %d\n",
+ pGC->depth);
+#endif
+
+ pGC->clientClip = NULL;
+ pGC->clientClipType = CT_NONE;
+ pGC->freeCompClip = FALSE;
+ pGC->pCompositeClip = 0;
+
+ pGC->ops = (GCOps *) &winGCOps;
+ pGC->funcs = (GCFuncs *) &winGCFuncs;
+
+ /* We want all coordinates passed to spans functions to be screen relative */
+ pGC->miTranslate = TRUE;
+
+ /* Allocate privates for this GC */
+ pGCPriv = winGetGCPriv (pGC);
+ if (pGCPriv == NULL)
+ {
+ ErrorF ("winCreateGCNativeGDI () - Privates pointer was NULL\n");
+ return FALSE;
+ }
+
+ /* Create a new screen DC for the display window */
+ pScreenPriv = winGetScreenPriv (pGC->pScreen);
+ pGCPriv->hdc = GetDC (pScreenPriv->hwndScreen);
+
+ /* Allocate a memory DC for the GC */
+ pGCPriv->hdcMem = CreateCompatibleDC (pGCPriv->hdc);
+
+ return TRUE;
+}
+
+
+#if 0
+/* See Porting Layer Definition - p. 45 */
+static void
+winChangeGCNativeGDI (GCPtr pGC, unsigned long ulChanges)
+{
+#if 0
+ ErrorF ("winChangeGCNativeGDI () - Doing nothing\n");
+#endif
+}
+#endif
+
+
+static void
+winValidateGCNativeGDI (GCPtr pGC,
+ unsigned long ulChanges,
+ DrawablePtr pDrawable)
+{
+ if ((ulChanges & (GCClipXOrigin | GCClipYOrigin | GCClipMask | GCSubwindowMode))
+ || (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS)))
+ {
+ miComputeCompositeClip (pGC, pDrawable);
+ }
+}
+
+
+#if 0
+/* See Porting Layer Definition - p. 46 */
+static void
+winCopyGCNativeGDI (GCPtr pGCsrc, unsigned long ulMask, GCPtr pGCdst)
+{
+
+}
+#endif
+
+
+/* See Porting Layer Definition - p. 46 */
+static void
+winDestroyGCNativeGDI (GCPtr pGC)
+{
+ winGCPriv(pGC);
+ winScreenPriv(pGC->pScreen);
+
+ if (pGC->freeCompClip)
+ REGION_DESTROY (pGC->pScreen, pGC->pCompositeClip);
+
+ /* Free the memory DC */
+ if (pGCPriv->hdcMem != NULL)
+ {
+ DeleteDC (pGCPriv->hdcMem);
+ pGCPriv->hdcMem = NULL;
+ }
+
+ /* Release the screen DC for the display window */
+ if (pGCPriv->hdc != NULL)
+ {
+ ReleaseDC (pScreenPriv->hwndScreen, pGCPriv->hdc);
+ pGCPriv->hdc = NULL;
+ }
+
+ /* Invalidate the GC privates pointer */
+ winSetGCPriv (pGC, NULL);
+}
+
+#if 0
+/* See Porting Layer Definition - p. 46 */
+static void
+winChangeClipNativeGDI (GCPtr pGC, int nType, pointer pValue, int nRects)
+{
+
+}
+
+
+/* See Porting Layer Definition - p. 47 */
+static void
+winDestroyClipNativeGDI (GCPtr pGC)
+{
+
+}
+
+
+/* See Porting Layer Definition - p. 47 */
+static void
+winCopyClipNativeGDI (GCPtr pGCdst, GCPtr pGCsrc)
+{
+
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/wingetsp.c b/nx-X11/programs/Xserver/hw/xwin/wingetsp.c
new file mode 100644
index 000000000..ec9d51a17
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/wingetsp.c
@@ -0,0 +1,193 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Harold L Hunt II
+ * Alan Hourihane <alanh@fairlite.demon.co.uk>
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/wingetsp.c,v 1.7 2001/11/01 12:19:40 alanh Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+/* See Porting Layer Definition - p. 55 */
+void
+winGetSpansNativeGDI (DrawablePtr pDrawable,
+ int nMax,
+ DDXPointPtr pPoints,
+ int *piWidths,
+ int iSpans,
+ char *pDsts)
+{
+ PixmapPtr pPixmap = NULL;
+ winPrivPixmapPtr pPixmapPriv = NULL;
+ int iSpan;
+ DDXPointPtr pPoint = NULL;
+ int *piWidth = NULL;
+ char *pDst = pDsts;
+ HBITMAP hbmpWindow, hbmpOrig, hbmpOrig1;
+ BYTE *pbWindow = NULL;
+ HDC hdcMem, hdcMem1;
+ ScreenPtr pScreen = pDrawable->pScreen;
+ winScreenPriv(pScreen);
+
+ /* Branch on the drawable type */
+ switch (pDrawable->type)
+ {
+ case DRAWABLE_PIXMAP:
+#if 0
+ ErrorF ("winGetSpans - DRAWABLE_PIXMAP %08x\n",
+ pDrawable);
+#endif
+
+ pPixmap = (PixmapPtr) pDrawable;
+ pPixmapPriv = winGetPixmapPriv (pPixmap);
+
+ /* Open a memory HDC */
+ hdcMem1 = CreateCompatibleDC (NULL);
+ hdcMem = CreateCompatibleDC (NULL);
+
+ /* Select the drawable pixmap into a DC */
+ hbmpOrig1 = SelectObject (hdcMem1, pPixmapPriv->hBitmap);
+
+ if (hbmpOrig1 == NULL)
+ FatalError ("winGetSpans - DRAWABLE_PIXMAP - SelectObject () "
+ "failed on pPixmapPriv->hBitmap\n");
+
+ /* Loop through spans */
+ for (iSpan = 0; iSpan < iSpans; ++iSpan)
+ {
+ pPoint = pPoints + iSpan;
+ piWidth = piWidths + iSpan;
+
+ hbmpWindow = winCreateDIBNativeGDI (*piWidth, 1,
+ pDrawable->depth,
+ &pbWindow,
+ NULL);
+
+ hbmpOrig = SelectObject (hdcMem, hbmpWindow);
+
+ /* Transfer the window bits to the window bitmap */
+ BitBlt (hdcMem,
+ 0, 0,
+ *piWidth, 1,
+ hdcMem1,
+ pPoint->x, pPoint->y,
+ SRCCOPY);
+
+ memcpy (pDst,
+ (char*) pbWindow,
+ PixmapBytePad (*piWidth, pDrawable->depth));
+
+ /* Pop the window bitmap out of the HDC and delete the bitmap */
+ SelectObject (hdcMem, hbmpOrig);
+ DeleteObject (hbmpWindow);
+
+#if 0
+ ErrorF ("(%dx%dx%d) (%d,%d) w: %d\n",
+ pDrawable->width, pDrawable->height, pDrawable->depth,
+ pPoint->x, pPoint->y, *piWidth);
+#endif
+
+ /* Calculate offset of next bit destination */
+ pDst += PixmapBytePad (*piWidth, pDrawable->depth);
+ }
+
+ /* Pop the pixmap's bitmap out of the HDC */
+ SelectObject (hdcMem1, hbmpOrig1);
+
+ /* Delete the HDCs */
+ DeleteDC (hdcMem1);
+ DeleteDC (hdcMem);
+ break;
+
+ case DRAWABLE_WINDOW:
+#if 0
+ ErrorF ("winGetSpans - DRAWABLE_WINDOW\n");
+#endif
+
+ /* Open a memory HDC */
+ hdcMem = CreateCompatibleDC (NULL);
+
+ /* Loop through spans */
+ for (iSpan = 0; iSpan < iSpans; ++iSpan)
+ {
+ pPoint = pPoints + iSpan;
+ piWidth = piWidths + iSpan;
+
+ hbmpWindow = winCreateDIBNativeGDI (*piWidth, 1,
+ pDrawable->depth,
+ &pbWindow,
+ NULL);
+
+ hbmpOrig = SelectObject (hdcMem, hbmpWindow);
+
+ /* Transfer the window bits to the window bitmap */
+ BitBlt (hdcMem,
+ 0, 0,
+ *piWidth, 1,
+ pScreenPriv->hdcScreen,
+ pPoint->x, pPoint->y,
+ SRCCOPY);
+
+ memcpy (pDst,
+ (char*) pbWindow,
+ PixmapBytePad (*piWidth, pDrawable->depth));
+
+ /* Pop the window bitmap out of the HDC */
+ SelectObject (hdcMem, hbmpOrig);
+
+ DeleteObject (hbmpWindow);
+
+#if 0
+ ErrorF ("(%dx%dx%d) (%d,%d) w: %d\n",
+ pDrawable->width, pDrawable->height, pDrawable->depth,
+ pPoint->x, pPoint->y, *piWidth);
+#endif
+
+ /* Calculate offset of next bit destination */
+ pDst += PixmapBytePad (*piWidth, pDrawable->depth);
+ }
+
+ /* Delete the window bitmap */
+ DeleteDC (hdcMem);
+ break;
+
+ case UNDRAWABLE_WINDOW:
+ FatalError ("winGetSpans - UNDRAWABLE_WINDOW\n");
+ break;
+
+ case DRAWABLE_BUFFER:
+ FatalError ("winGetSpans - DRAWABLE_BUFFER\n");
+ break;
+
+ default:
+ FatalError ("winGetSpans - Unknown drawable type\n");
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winglobals.c b/nx-X11/programs/Xserver/hw/xwin/winglobals.c
new file mode 100644
index 000000000..af8190d3f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winglobals.c
@@ -0,0 +1,138 @@
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * General global variables
+ */
+
+int g_iNumScreens = 0;
+winScreenInfo g_ScreenInfo[MAXSCREENS];
+int g_iLastScreen = -1;
+#ifdef HAS_DEVWINDOWS
+int g_fdMessageQueue = WIN_FD_INVALID;
+#endif
+int g_iScreenPrivateIndex = -1;
+int g_iCmapPrivateIndex = -1;
+int g_iGCPrivateIndex = -1;
+int g_iPixmapPrivateIndex = -1;
+int g_iWindowPrivateIndex = -1;
+unsigned long g_ulServerGeneration = 0;
+Bool g_fInitializedDefaultScreens = FALSE;
+DWORD g_dwEnginesSupported = 0;
+HINSTANCE g_hInstance = 0;
+HWND g_hDlgDepthChange = NULL;
+HWND g_hDlgExit = NULL;
+HWND g_hDlgAbout = NULL;
+const char * g_pszQueryHost = NULL;
+Bool g_fXdmcpEnabled = FALSE;
+HICON g_hIconX = NULL;
+HICON g_hSmallIconX = NULL;
+#ifndef RELOCATE_PROJECTROOT
+char * g_pszLogFile = "/tmp/XWin.log";
+#else
+char * g_pszLogFile = "XWin.log";
+Bool g_fLogFileChanged = FALSE;
+#endif
+int g_iLogVerbose = 2;
+Bool g_fLogInited = FALSE;
+char * g_pszCommandLine = NULL;
+Bool g_fSilentFatalError = FALSE;
+DWORD g_dwCurrentThreadID = 0;
+Bool g_fKeyboardHookLL = FALSE;
+HHOOK g_hhookKeyboardLL = NULL;
+HWND g_hwndKeyboardFocus = NULL;
+Bool g_fNoHelpMessageBox = FALSE;
+Bool g_fSoftwareCursor = FALSE;
+Bool g_fSilentDupError = FALSE;
+
+
+/*
+ * Global variables for dynamically loaded libraries and
+ * their function pointers
+ */
+
+HMODULE g_hmodDirectDraw = NULL;
+FARPROC g_fpDirectDrawCreate = NULL;
+FARPROC g_fpDirectDrawCreateClipper = NULL;
+
+HMODULE g_hmodCommonControls = NULL;
+FARPROC g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
+
+
+#ifdef XWIN_CLIPBOARD
+/*
+ * Wrapped DIX functions
+ */
+winDispatchProcPtr winProcEstablishConnectionOrig = NULL;
+winDispatchProcPtr winProcQueryTreeOrig = NULL;
+winDispatchProcPtr winProcSetSelectionOwnerOrig = NULL;
+
+
+/*
+ * Clipboard variables
+ */
+
+Bool g_fUnicodeClipboard = TRUE;
+Bool g_fClipboard = FALSE;
+Bool g_fClipboardLaunched = FALSE;
+Bool g_fClipboardStarted = FALSE;
+pthread_t g_ptClipboardProc;
+HWND g_hwndClipboard = NULL;
+void *g_pClipboardDisplay = NULL;
+Window g_iClipboardWindow = None;
+Atom g_atomLastOwnedSelection = None;
+#endif
+
+
+/*
+ * Re-initialize global variables that are invalidated
+ * by a server reset.
+ */
+
+void
+winInitializeGlobals (void)
+{
+ g_dwCurrentThreadID = GetCurrentThreadId ();
+ g_hwndKeyboardFocus = NULL;
+#ifdef XWIN_CLIPBOARD
+ g_fClipboardLaunched = FALSE;
+ g_fClipboardStarted = FALSE;
+ g_iClipboardWindow = None;
+ g_pClipboardDisplay = NULL;
+ g_atomLastOwnedSelection = None;
+ g_hwndClipboard = NULL;
+#endif
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winkeybd.c b/nx-X11/programs/Xserver/hw/xwin/winkeybd.c
new file mode 100644
index 000000000..3756a4432
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winkeybd.c
@@ -0,0 +1,650 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winkeybd.c,v 1.12 2002/10/17 08:18:22 alanh Exp $ */
+
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winkeybd.h"
+#include "winconfig.h"
+#include "winmsg.h"
+
+#ifdef XKB
+#ifndef XKB_IN_SERVER
+#define XKB_IN_SERVER
+#endif
+#include <X11/extensions/XKBsrv.h>
+#endif
+
+static Bool g_winKeyState[NUM_KEYCODES];
+
+/* Stored to get internal mode key states. Must be read-only. */
+static unsigned short const *g_winInternalModeKeyStatesPtr = NULL;
+
+
+/*
+ * Local prototypes
+ */
+
+static void
+winGetKeyMappings (KeySymsPtr pKeySyms, CARD8 *pModMap);
+
+static void
+winKeybdBell (int iPercent, DeviceIntPtr pDeviceInt,
+ pointer pCtrl, int iClass);
+
+static void
+winKeybdCtrl (DeviceIntPtr pDevice, KeybdCtrl *pCtrl);
+
+
+/*
+ * Translate a Windows WM_[SYS]KEY(UP/DOWN) message
+ * into an ASCII scan code.
+ *
+ * We do this ourselves, rather than letting Windows handle it,
+ * because Windows tends to munge the handling of special keys,
+ * like AltGr on European keyboards.
+ */
+
+void
+winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode)
+{
+ int iKeyFixup = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 1];
+ int iKeyFixupEx = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 2];
+ int iParamScanCode = LOBYTE (HIWORD (lParam));
+
+ /* Branch on special extended, special non-extended, or normal key */
+ if ((HIWORD (lParam) & KF_EXTENDED) && iKeyFixupEx)
+ *piScanCode = iKeyFixupEx;
+ else if (iKeyFixup)
+ *piScanCode = iKeyFixup;
+ else if (wParam == 0 && iParamScanCode == 0x70)
+ *piScanCode = KEY_HKTG;
+ else
+ switch (iParamScanCode)
+ {
+ case 0x70:
+ *piScanCode = KEY_HKTG;
+ break;
+ case 0x73:
+ *piScanCode = KEY_BSlash2;
+ break;
+ default:
+ *piScanCode = iParamScanCode;
+ break;
+ }
+}
+
+
+/*
+ * We call this function from winKeybdProc when we are
+ * initializing the keyboard.
+ */
+
+static void
+winGetKeyMappings (KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ int i;
+ KeySym *pMap = map;
+ KeySym *pKeySym;
+
+ /*
+ * Initialize all key states to up... which may not be true
+ * but it is close enough.
+ */
+ ZeroMemory (g_winKeyState, sizeof (g_winKeyState[0]) * NUM_KEYCODES);
+
+ /* MAP_LENGTH is defined in Xserver/include/input.h to be 256 */
+ for (i = 0; i < MAP_LENGTH; i++)
+ pModMap[i] = NoSymbol; /* make sure it is restored */
+
+ /* Loop through all valid entries in the key symbol table */
+ for (pKeySym = pMap, i = MIN_KEYCODE;
+ i < (MIN_KEYCODE + NUM_KEYCODES);
+ i++, pKeySym += GLYPHS_PER_KEY)
+ {
+ switch (*pKeySym)
+ {
+ case XK_Shift_L:
+ case XK_Shift_R:
+ pModMap[i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ case XK_Control_R:
+ pModMap[i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ pModMap[i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ case XK_Alt_R:
+ pModMap[i] = AltMask;
+ break;
+
+ case XK_Num_Lock:
+ pModMap[i] = NumLockMask;
+ break;
+
+ case XK_Scroll_Lock:
+ pModMap[i] = ScrollLockMask;
+ break;
+
+#if 0
+ case XK_Super_L:
+ case XK_Super_R:
+ pModMap[i] = Mod4Mask;
+ break;
+#else
+ /* Hirigana/Katakana toggle */
+ case XK_Kana_Lock:
+ case XK_Kana_Shift:
+ pModMap[i] = KanaMask;
+ break;
+#endif
+
+ /* alternate toggle for multinational support */
+ case XK_Mode_switch:
+ pModMap[i] = AltLangMask;
+ break;
+ }
+ }
+
+ pKeySyms->map = (KeySym *) pMap;
+ pKeySyms->mapWidth = GLYPHS_PER_KEY;
+ pKeySyms->minKeyCode = MIN_KEYCODE;
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
+}
+
+
+/* Ring the keyboard bell (system speaker on PCs) */
+static void
+winKeybdBell (int iPercent, DeviceIntPtr pDeviceInt,
+ pointer pCtrl, int iClass)
+{
+ /*
+ * We can't use Beep () here because it uses the PC speaker
+ * on NT/2000. MessageBeep (MB_OK) will play the default system
+ * sound on systems with a sound card or it will beep the PC speaker
+ * on systems that do not have a sound card.
+ */
+ MessageBeep (MB_OK);
+}
+
+
+/* Change some keyboard configuration parameters */
+static void
+winKeybdCtrl (DeviceIntPtr pDevice, KeybdCtrl *pCtrl)
+{
+ g_winInternalModeKeyStatesPtr = &(pDevice->key->state);
+}
+
+
+/*
+ * See Porting Layer Definition - p. 18
+ * winKeybdProc is known as a DeviceProc.
+ */
+
+int
+winKeybdProc (DeviceIntPtr pDeviceInt, int iState)
+{
+ KeySymsRec keySyms;
+ CARD8 modMap[MAP_LENGTH];
+ DevicePtr pDevice = (DevicePtr) pDeviceInt;
+#ifdef XKB
+ XkbComponentNamesRec names;
+ XkbSrvInfoPtr xkbi;
+ XkbControlsPtr ctrl;
+#endif
+
+ switch (iState)
+ {
+ case DEVICE_INIT:
+ winConfigKeyboard (pDeviceInt);
+
+ winGetKeyMappings (&keySyms, modMap);
+
+#ifdef XKB
+ /* FIXME: Maybe we should use winGetKbdLeds () here? */
+ defaultKeyboardControl.leds = g_winInfo.keyboard.leds;
+#else
+ defaultKeyboardControl.leds = g_winInfo.keyboard.leds;
+#endif
+
+#ifdef XKB
+ if (g_winInfo.xkb.disable)
+ {
+#endif
+ InitKeyboardDeviceStruct (pDevice,
+ &keySyms,
+ modMap,
+ winKeybdBell,
+ winKeybdCtrl);
+#ifdef XKB
+ }
+ else
+ {
+
+ if (XkbInitialMap)
+ {
+ names.keymap = XkbInitialMap;
+ names.keycodes = NULL;
+ names.types = NULL;
+ names.compat = NULL;
+ names.symbols = NULL;
+ names.geometry = NULL;
+ }
+ else
+ {
+ names.keymap = g_winInfo.xkb.keymap;
+ names.keycodes = g_winInfo.xkb.keycodes;
+ names.types = g_winInfo.xkb.types;
+ names.compat = g_winInfo.xkb.compat;
+ names.symbols = g_winInfo.xkb.symbols;
+ names.geometry = g_winInfo.xkb.geometry;
+ }
+
+ winErrorFVerb(2, "Rules = \"%s\" Model = \"%s\" Layout = \"%s\""
+ " Variant = \"%s\" Options = \"%s\"\n",
+ g_winInfo.xkb.rules, g_winInfo.xkb.model,
+ g_winInfo.xkb.layout, g_winInfo.xkb.variant,
+ g_winInfo.xkb.options);
+
+ XkbSetRulesDflts (g_winInfo.xkb.rules, g_winInfo.xkb.model,
+ g_winInfo.xkb.layout, g_winInfo.xkb.variant,
+ g_winInfo.xkb.options);
+ XkbInitKeyboardDeviceStruct (pDeviceInt, &names, &keySyms,
+ modMap, winKeybdBell, winKeybdCtrl);
+ }
+#endif
+
+#ifdef XKB
+ if (!g_winInfo.xkb.disable)
+ {
+ xkbi = pDeviceInt->key->xkbInfo;
+ if (xkbi != NULL)
+ {
+ ctrl = xkbi->desc->ctrls;
+ ctrl->repeat_delay = g_winInfo.keyboard.delay;
+ ctrl->repeat_interval = 1000/g_winInfo.keyboard.rate;
+ }
+ else
+ {
+ winErrorFVerb (1, "winKeybdProc - Error initializing keyboard AutoRepeat (No XKB)\n");
+ }
+ }
+#endif
+
+ g_winInternalModeKeyStatesPtr = &(pDeviceInt->key->state);
+ break;
+
+ case DEVICE_ON:
+ pDevice->on = TRUE;
+ g_winInternalModeKeyStatesPtr = &(pDeviceInt->key->state);
+ break;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ pDevice->on = FALSE;
+ g_winInternalModeKeyStatesPtr = NULL;
+ break;
+ }
+
+ return Success;
+}
+
+
+/*
+ * Detect current mode key states upon server startup.
+ *
+ * Simulate a press and release of any key that is currently
+ * toggled.
+ */
+
+void
+winInitializeModeKeyStates (void)
+{
+ /* Restore NumLock */
+ if (GetKeyState (VK_NUMLOCK) & 0x0001)
+ {
+ winSendKeyEvent (KEY_NumLock, TRUE);
+ winSendKeyEvent (KEY_NumLock, FALSE);
+ }
+
+ /* Restore CapsLock */
+ if (GetKeyState (VK_CAPITAL) & 0x0001)
+ {
+ winSendKeyEvent (KEY_CapsLock, TRUE);
+ winSendKeyEvent (KEY_CapsLock, FALSE);
+ }
+
+ /* Restore ScrollLock */
+ if (GetKeyState (VK_SCROLL) & 0x0001)
+ {
+ winSendKeyEvent (KEY_ScrollLock, TRUE);
+ winSendKeyEvent (KEY_ScrollLock, FALSE);
+ }
+
+ /* Restore KanaLock */
+ if (GetKeyState (VK_KANA) & 0x0001)
+ {
+ winSendKeyEvent (KEY_HKTG, TRUE);
+ winSendKeyEvent (KEY_HKTG, FALSE);
+ }
+}
+
+
+/*
+ * Upon regaining the keyboard focus we must
+ * resynchronize our internal mode key states
+ * with the actual state of the keys.
+ */
+
+void
+winRestoreModeKeyStates ()
+{
+ DWORD dwKeyState;
+ BOOL processEvents = TRUE;
+ unsigned short internalKeyStates;
+
+ /* X server is being initialized */
+ if (!g_winInternalModeKeyStatesPtr)
+ return;
+
+ /* Only process events if the rootwindow is mapped. The keyboard events
+ * will cause segfaults otherwise */
+ if (WindowTable && WindowTable[0] && WindowTable[0]->mapped == FALSE)
+ processEvents = FALSE;
+
+ /* Force to process all pending events in the mi event queue */
+ if (processEvents)
+ mieqProcessInputEvents ();
+
+ /* Read the mode key states of our X server */
+ internalKeyStates = *g_winInternalModeKeyStatesPtr;
+
+ /*
+ * NOTE: The C XOR operator, ^, will not work here because it is
+ * a bitwise operator, not a logical operator. C does not
+ * have a logical XOR operator, so we use a macro instead.
+ */
+
+ /* Has the key state changed? */
+ dwKeyState = GetKeyState (VK_NUMLOCK) & 0x0001;
+ if (WIN_XOR (internalKeyStates & NumLockMask, dwKeyState))
+ {
+ winSendKeyEvent (KEY_NumLock, TRUE);
+ winSendKeyEvent (KEY_NumLock, FALSE);
+ }
+
+ /* Has the key state changed? */
+ dwKeyState = GetKeyState (VK_CAPITAL) & 0x0001;
+ if (WIN_XOR (internalKeyStates & LockMask, dwKeyState))
+ {
+ winSendKeyEvent (KEY_CapsLock, TRUE);
+ winSendKeyEvent (KEY_CapsLock, FALSE);
+ }
+
+ /* Has the key state changed? */
+ dwKeyState = GetKeyState (VK_SCROLL) & 0x0001;
+ if (WIN_XOR (internalKeyStates & ScrollLockMask, dwKeyState))
+ {
+ winSendKeyEvent (KEY_ScrollLock, TRUE);
+ winSendKeyEvent (KEY_ScrollLock, FALSE);
+ }
+
+ /* Has the key state changed? */
+ dwKeyState = GetKeyState (VK_KANA) & 0x0001;
+ if (WIN_XOR (internalKeyStates & KanaMask, dwKeyState))
+ {
+ winSendKeyEvent (KEY_HKTG, TRUE);
+ winSendKeyEvent (KEY_HKTG, FALSE);
+ }
+}
+
+
+/*
+ * Look for the lovely fake Control_L press/release generated by Windows
+ * when AltGr is pressed/released on a non-U.S. keyboard.
+ */
+
+Bool
+winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam)
+{
+ MSG msgNext;
+ LONG lTime;
+ Bool fReturn;
+
+ /*
+ * Fake Ctrl_L presses will be followed by an Alt_R keypress
+ * with the same timestamp as the Ctrl_L press.
+ */
+ if ((message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
+ && wParam == VK_CONTROL
+ && (HIWORD (lParam) & KF_EXTENDED) == 0)
+ {
+ /* Got a Ctrl_L press */
+
+ /* Get time of current message */
+ lTime = GetMessageTime ();
+
+ /* Look for fake Ctrl_L preceeding an Alt_R press. */
+ fReturn = PeekMessage (&msgNext, NULL,
+ WM_KEYDOWN, WM_SYSKEYDOWN,
+ PM_NOREMOVE);
+
+ /*
+ * Try again if the first call fails.
+ * NOTE: This usually happens when TweakUI is enabled.
+ */
+ if (!fReturn)
+ {
+ /* Voodoo to make sure that the Alt_R message has posted */
+ Sleep (0);
+
+ /* Look for fake Ctrl_L preceeding an Alt_R press. */
+ fReturn = PeekMessage (&msgNext, NULL,
+ WM_KEYDOWN, WM_SYSKEYDOWN,
+ PM_NOREMOVE);
+ }
+ if (msgNext.message != WM_KEYDOWN && msgNext.message != WM_SYSKEYDOWN)
+ fReturn = 0;
+
+ /* Is next press an Alt_R with the same timestamp? */
+ if (fReturn && msgNext.wParam == VK_MENU
+ && msgNext.time == lTime
+ && (HIWORD (msgNext.lParam) & KF_EXTENDED))
+ {
+ /*
+ * Next key press is Alt_R with same timestamp as current
+ * Ctrl_L message. Therefore, this Ctrl_L press is a fake
+ * event, so discard it.
+ */
+ return TRUE;
+ }
+ }
+
+ /*
+ * Fake Ctrl_L releases will be followed by an Alt_R release
+ * with the same timestamp as the Ctrl_L release.
+ */
+ if ((message == WM_KEYUP || message == WM_SYSKEYUP)
+ && wParam == VK_CONTROL
+ && (HIWORD (lParam) & KF_EXTENDED) == 0)
+ {
+ /* Got a Ctrl_L release */
+
+ /* Get time of current message */
+ lTime = GetMessageTime ();
+
+ /* Look for fake Ctrl_L release preceeding an Alt_R release. */
+ fReturn = PeekMessage (&msgNext, NULL,
+ WM_KEYUP, WM_SYSKEYUP,
+ PM_NOREMOVE);
+
+ /*
+ * Try again if the first call fails.
+ * NOTE: This usually happens when TweakUI is enabled.
+ */
+ if (!fReturn)
+ {
+ /* Voodoo to make sure that the Alt_R message has posted */
+ Sleep (0);
+
+ /* Look for fake Ctrl_L release preceeding an Alt_R release. */
+ fReturn = PeekMessage (&msgNext, NULL,
+ WM_KEYUP, WM_SYSKEYUP,
+ PM_NOREMOVE);
+ }
+
+ if (msgNext.message != WM_KEYUP && msgNext.message != WM_SYSKEYUP)
+ fReturn = 0;
+
+ /* Is next press an Alt_R with the same timestamp? */
+ if (fReturn
+ && (msgNext.message == WM_KEYUP
+ || msgNext.message == WM_SYSKEYUP)
+ && msgNext.wParam == VK_MENU
+ && msgNext.time == lTime
+ && (HIWORD (msgNext.lParam) & KF_EXTENDED))
+ {
+ /*
+ * Next key release is Alt_R with same timestamp as current
+ * Ctrl_L message. Therefore, this Ctrl_L release is a fake
+ * event, so discard it.
+ */
+ return TRUE;
+ }
+ }
+
+ /* Not a fake control left press/release */
+ return FALSE;
+}
+
+
+/*
+ * Lift any modifier keys that are pressed
+ */
+
+void
+winKeybdReleaseKeys ()
+{
+ int i;
+
+#ifdef HAS_DEVWINDOWS
+ /* Verify that the mi input system has been initialized */
+ if (g_fdMessageQueue == WIN_FD_INVALID)
+ return;
+#endif
+
+ /* Loop through all keys */
+ for (i = 0; i < NUM_KEYCODES; ++i)
+ {
+ /* Pop key if pressed */
+ if (g_winKeyState[i])
+ winSendKeyEvent (i, FALSE);
+
+ /* Reset pressed flag for keys */
+ g_winKeyState[i] = FALSE;
+ }
+}
+
+
+/*
+ * Take a raw X key code and send an up or down event for it.
+ *
+ * Thanks to VNC for inspiration, though it is a simple function.
+ */
+
+void
+winSendKeyEvent (DWORD dwKey, Bool fDown)
+{
+ xEvent xCurrentEvent;
+
+ /*
+ * When alt-tabing between screens we can get phantom key up messages
+ * Here we only pass them through it we think we should!
+ */
+ if (g_winKeyState[dwKey] == FALSE && fDown == FALSE) return;
+
+ /* Update the keyState map */
+ g_winKeyState[dwKey] = fDown;
+
+ ZeroMemory (&xCurrentEvent, sizeof (xCurrentEvent));
+
+ xCurrentEvent.u.u.type = fDown ? KeyPress : KeyRelease;
+ xCurrentEvent.u.keyButtonPointer.time =
+ g_c32LastInputEventTime = GetTickCount ();
+ xCurrentEvent.u.u.detail = dwKey + MIN_KEYCODE;
+ mieqEnqueue (&xCurrentEvent);
+}
+
+BOOL winCheckKeyPressed(WPARAM wParam, LPARAM lParam)
+{
+ switch (wParam)
+ {
+ case VK_CONTROL:
+ if ((lParam & 0x1ff0000) == 0x11d0000 && g_winKeyState[KEY_RCtrl])
+ return TRUE;
+ if ((lParam & 0x1ff0000) == 0x01d0000 && g_winKeyState[KEY_LCtrl])
+ return TRUE;
+ break;
+ case VK_SHIFT:
+ if ((lParam & 0x1ff0000) == 0x0360000 && g_winKeyState[KEY_ShiftR])
+ return TRUE;
+ if ((lParam & 0x1ff0000) == 0x02a0000 && g_winKeyState[KEY_ShiftL])
+ return TRUE;
+ break;
+ default:
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/* Only on shift release message is sent even if both are pressed.
+ * Fix this here
+ */
+void winFixShiftKeys (int iScanCode)
+{
+ if (GetKeyState (VK_SHIFT) & 0x8000)
+ return;
+
+ if (iScanCode == KEY_ShiftL && g_winKeyState[KEY_ShiftR])
+ winSendKeyEvent (KEY_ShiftR, FALSE);
+ if (iScanCode == KEY_ShiftR && g_winKeyState[KEY_ShiftL])
+ winSendKeyEvent (KEY_ShiftL, FALSE);
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winkeybd.h b/nx-X11/programs/Xserver/hw/xwin/winkeybd.h
new file mode 100644
index 000000000..f42e09fd7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winkeybd.h
@@ -0,0 +1,310 @@
+#if !defined(WINKEYBD_H)
+#define WINKEYBD_H
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Harold L Hunt II
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winkeybd.h,v 1.1 2001/09/26 13:00:34 alanh Exp $ */
+
+/*
+ * We need symbols for the scan codes of keys.
+ */
+#include "winkeynames.h"
+
+
+/*
+ * Include the standard ASCII keymap.
+ *
+ * This header declares a static KeySym array called 'map'.
+ */
+#include "winkeymap.h"
+
+#define WIN_KEYMAP_COLS 3
+
+const int
+g_iKeyMap [] = {
+ /* count Windows VK, ASCII, ASCII when extended VK */
+ /* 0 */ 0, 0, 0,
+ /* 1 */ 0, 0, 0,
+ /* 2 */ 0, 0, 0,
+ /* 3 */ VK_CANCEL, 0, KEY_Break,
+ /* 4 */ 0, 0, 0,
+ /* 5 */ 0, 0, 0,
+ /* 6 */ 0, 0, 0,
+ /* 7 */ 0, 0, 0,
+ /* 8 */ 0, 0, 0,
+ /* 9 */ 0, 0, 0,
+ /* 10 */ 0, 0, 0,
+ /* 11 */ 0, 0, 0,
+ /* 12 */ 0, 0, 0,
+ /* 13 */ VK_RETURN, 0, KEY_KP_Enter,
+ /* 14 */ 0, 0, 0,
+ /* 15 */ 0, 0, 0,
+ /* 16 */ VK_SHIFT, 0, 0,
+ /* 17 */ VK_CONTROL, 0, KEY_RCtrl,
+ /* 18 */ VK_MENU, 0, KEY_AltLang,
+ /* 19 */ VK_PAUSE, KEY_Pause, 0,
+ /* 20 */ 0, 0, 0,
+ /* 21 */ 0, 0, 0,
+ /* 22 */ 0, 0, 0,
+ /* 23 */ 0, 0, 0,
+ /* 24 */ 0, 0, 0,
+ /* 25 */ 0, 0, 0,
+ /* 26 */ 0, 0, 0,
+ /* 27 */ 0, 0, 0,
+ /* 28 */ 0, 0, 0,
+ /* 29 */ 0, 0, 0,
+ /* 30 */ 0, 0, 0,
+ /* 31 */ 0, 0, 0,
+ /* 32 */ 0, 0, 0,
+ /* 33 */ VK_PRIOR, 0, KEY_PgUp,
+ /* 34 */ VK_NEXT, 0, KEY_PgDown,
+ /* 35 */ VK_END, 0, KEY_End,
+ /* 36 */ VK_HOME, 0, KEY_Home,
+ /* 37 */ VK_LEFT, 0, KEY_Left,
+ /* 38 */ VK_UP, 0, KEY_Up,
+ /* 39 */ VK_RIGHT, 0, KEY_Right,
+ /* 40 */ VK_DOWN, 0, KEY_Down,
+ /* 41 */ 0, 0, 0,
+ /* 42 */ 0, 0, 0,
+ /* 43 */ 0, 0, 0,
+ /* 44 */ VK_SNAPSHOT, 0, KEY_Print,
+ /* 45 */ VK_INSERT, 0, KEY_Insert,
+ /* 46 */ VK_DELETE, 0, KEY_Delete,
+ /* 47 */ 0, 0, 0,
+ /* 48 */ 0, 0, 0,
+ /* 49 */ 0, 0, 0,
+ /* 50 */ 0, 0, 0,
+ /* 51 */ 0, 0, 0,
+ /* 52 */ 0, 0, 0,
+ /* 53 */ 0, 0, 0,
+ /* 54 */ 0, 0, 0,
+ /* 55 */ 0, 0, 0,
+ /* 56 */ 0, 0, 0,
+ /* 57 */ 0, 0, 0,
+ /* 58 */ 0, 0, 0,
+ /* 59 */ 0, 0, 0,
+ /* 60 */ 0, 0, 0,
+ /* 61 */ 0, 0, 0,
+ /* 62 */ 0, 0, 0,
+ /* 63 */ 0, 0, 0,
+ /* 64 */ 0, 0, 0,
+ /* 65 */ 0, 0, 0,
+ /* 66 */ 0, 0, 0,
+ /* 67 */ 0, 0, 0,
+ /* 68 */ 0, 0, 0,
+ /* 69 */ 0, 0, 0,
+ /* 70 */ 0, 0, 0,
+ /* 71 */ 0, 0, 0,
+ /* 72 */ 0, 0, 0,
+ /* 73 */ 0, 0, 0,
+ /* 74 */ 0, 0, 0,
+ /* 75 */ 0, 0, 0,
+ /* 76 */ 0, 0, 0,
+ /* 77 */ 0, 0, 0,
+ /* 78 */ 0, 0, 0,
+ /* 79 */ 0, 0, 0,
+ /* 80 */ 0, 0, 0,
+ /* 81 */ 0, 0, 0,
+ /* 82 */ 0, 0, 0,
+ /* 83 */ 0, 0, 0,
+ /* 84 */ 0, 0, 0,
+ /* 85 */ 0, 0, 0,
+ /* 86 */ 0, 0, 0,
+ /* 87 */ 0, 0, 0,
+ /* 88 */ 0, 0, 0,
+ /* 89 */ 0, 0, 0,
+ /* 90 */ 0, 0, 0,
+ /* 91 */ VK_LWIN, KEY_LMeta, 0,
+ /* 92 */ VK_RWIN, KEY_RMeta, 0,
+ /* 93 */ VK_APPS, KEY_Menu, 0,
+ /* 94 */ 0, 0, 0,
+ /* 95 */ 0, 0, 0,
+ /* 96 */ 0, 0, 0,
+ /* 97 */ 0, 0, 0,
+ /* 98 */ 0, 0, 0,
+ /* 99 */ 0, 0, 0,
+ /* 100 */ 0, 0, 0,
+ /* 101 */ 0, 0, 0,
+ /* 102 */ 0, 0, 0,
+ /* 103 */ 0, 0, 0,
+ /* 104 */ 0, 0, 0,
+ /* 105 */ 0, 0, 0,
+ /* 106 */ 0, 0, 0,
+ /* 107 */ 0, 0, 0,
+ /* 108 */ 0, 0, 0,
+ /* 109 */ 0, 0, 0,
+ /* 110 */ 0, 0, 0,
+ /* 111 */ VK_DIVIDE, 0, KEY_KP_Divide,
+ /* 112 */ 0, 0, 0,
+ /* 113 */ 0, 0, 0,
+ /* 114 */ 0, 0, 0,
+ /* 115 */ 0, 0, 0,
+ /* 116 */ 0, 0, 0,
+ /* 117 */ 0, 0, 0,
+ /* 118 */ 0, 0, 0,
+ /* 119 */ 0, 0, 0,
+ /* 120 */ 0, 0, 0,
+ /* 121 */ 0, 0, 0,
+ /* 122 */ 0, 0, 0,
+ /* 123 */ 0, 0, 0,
+ /* 124 */ 0, 0, 0,
+ /* 125 */ 0, 0, 0,
+ /* 126 */ 0, 0, 0,
+ /* 127 */ 0, 0, 0,
+ /* 128 */ 0, 0, 0,
+ /* 129 */ 0, 0, 0,
+ /* 130 */ 0, 0, 0,
+ /* 131 */ 0, 0, 0,
+ /* 132 */ 0, 0, 0,
+ /* 133 */ 0, 0, 0,
+ /* 134 */ 0, 0, 0,
+ /* 135 */ 0, 0, 0,
+ /* 136 */ 0, 0, 0,
+ /* 137 */ 0, 0, 0,
+ /* 138 */ 0, 0, 0,
+ /* 139 */ 0, 0, 0,
+ /* 140 */ 0, 0, 0,
+ /* 141 */ 0, 0, 0,
+ /* 142 */ 0, 0, 0,
+ /* 143 */ 0, 0, 0,
+ /* 144 */ 0, 0, 0,
+ /* 145 */ 0, 0, 0,
+ /* 146 */ 0, 0, 0,
+ /* 147 */ 0, 0, 0,
+ /* 148 */ 0, 0, 0,
+ /* 149 */ 0, 0, 0,
+ /* 150 */ 0, 0, 0,
+ /* 151 */ 0, 0, 0,
+ /* 152 */ 0, 0, 0,
+ /* 153 */ 0, 0, 0,
+ /* 154 */ 0, 0, 0,
+ /* 155 */ 0, 0, 0,
+ /* 156 */ 0, 0, 0,
+ /* 157 */ 0, 0, 0,
+ /* 158 */ 0, 0, 0,
+ /* 159 */ 0, 0, 0,
+ /* 160 */ 0, 0, 0,
+ /* 161 */ 0, 0, 0,
+ /* 162 */ 0, 0, 0,
+ /* 163 */ 0, 0, 0,
+ /* 164 */ 0, 0, 0,
+ /* 165 */ 0, 0, 0,
+ /* 166 */ 0, 0, 0,
+ /* 167 */ 0, 0, 0,
+ /* 168 */ 0, 0, 0,
+ /* 169 */ 0, 0, 0,
+ /* 170 */ 0, 0, 0,
+ /* 171 */ 0, 0, 0,
+ /* 172 */ 0, 0, 0,
+ /* 173 */ 0, 0, 0,
+ /* 174 */ 0, 0, 0,
+ /* 175 */ 0, 0, 0,
+ /* 176 */ 0, 0, 0,
+ /* 177 */ 0, 0, 0,
+ /* 178 */ 0, 0, 0,
+ /* 179 */ 0, 0, 0,
+ /* 180 */ 0, 0, 0,
+ /* 181 */ 0, 0, 0,
+ /* 182 */ 0, 0, 0,
+ /* 183 */ 0, 0, 0,
+ /* 184 */ 0, 0, 0,
+ /* 185 */ 0, 0, 0,
+ /* 186 */ 0, 0, 0,
+ /* 187 */ 0, 0, 0,
+ /* 188 */ 0, 0, 0,
+ /* 189 */ 0, 0, 0,
+ /* 190 */ 0, 0, 0,
+ /* 191 */ 0, 0, 0,
+ /* 192 */ 0, 0, 0,
+ /* 193 */ 0, 0, 0,
+ /* 194 */ 0, 0, 0,
+ /* 195 */ 0, 0, 0,
+ /* 196 */ 0, 0, 0,
+ /* 197 */ 0, 0, 0,
+ /* 198 */ 0, 0, 0,
+ /* 199 */ 0, 0, 0,
+ /* 200 */ 0, 0, 0,
+ /* 201 */ 0, 0, 0,
+ /* 202 */ 0, 0, 0,
+ /* 203 */ 0, 0, 0,
+ /* 204 */ 0, 0, 0,
+ /* 205 */ 0, 0, 0,
+ /* 206 */ 0, 0, 0,
+ /* 207 */ 0, 0, 0,
+ /* 208 */ 0, 0, 0,
+ /* 209 */ 0, 0, 0,
+ /* 210 */ 0, 0, 0,
+ /* 211 */ 0, 0, 0,
+ /* 212 */ 0, 0, 0,
+ /* 213 */ 0, 0, 0,
+ /* 214 */ 0, 0, 0,
+ /* 215 */ 0, 0, 0,
+ /* 216 */ 0, 0, 0,
+ /* 217 */ 0, 0, 0,
+ /* 218 */ 0, 0, 0,
+ /* 219 */ 0, 0, 0,
+ /* 220 */ 0, 0, 0,
+ /* 221 */ 0, 0, 0,
+ /* 222 */ 0, 0, 0,
+ /* 223 */ 0, 0, 0,
+ /* 224 */ 0, 0, 0,
+ /* 225 */ 0, 0, 0,
+ /* 226 */ 0, 0, 0,
+ /* 227 */ 0, 0, 0,
+ /* 228 */ 0, 0, 0,
+ /* 229 */ 0, 0, 0,
+ /* 230 */ 0, 0, 0,
+ /* 231 */ 0, 0, 0,
+ /* 232 */ 0, 0, 0,
+ /* 233 */ 0, 0, 0,
+ /* 234 */ 0, 0, 0,
+ /* 235 */ 0, 0, 0,
+ /* 236 */ 0, 0, 0,
+ /* 237 */ 0, 0, 0,
+ /* 238 */ 0, 0, 0,
+ /* 239 */ 0, 0, 0,
+ /* 240 */ 0, 0, 0,
+ /* 241 */ 0, 0, 0,
+ /* 242 */ 0, 0, 0,
+ /* 243 */ 0, 0, 0,
+ /* 244 */ 0, 0, 0,
+ /* 245 */ 0, 0, 0,
+ /* 246 */ 0, 0, 0,
+ /* 247 */ 0, 0, 0,
+ /* 248 */ 0, 0, 0,
+ /* 249 */ 0, 0, 0,
+ /* 250 */ 0, 0, 0,
+ /* 251 */ 0, 0, 0,
+ /* 252 */ 0, 0, 0,
+ /* 253 */ 0, 0, 0,
+ /* 254 */ 0, 0, 0,
+ /* 255 */ 0, 0, 0
+};
+
+#endif /* WINKEYBD_H */
diff --git a/nx-X11/programs/Xserver/hw/xwin/winkeyhook.c b/nx-X11/programs/Xserver/hw/xwin/winkeyhook.c
new file mode 100755
index 000000000..53d91e6ee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winkeyhook.c
@@ -0,0 +1,194 @@
+/*
+ *Copyright (C) 2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * References to external symbols
+ */
+
+extern HHOOK g_hhookKeyboardLL;
+extern DWORD g_dwCurrentThreadID;
+extern HWND g_hwndKeyboardFocus;
+
+
+/*
+ * Function prototypes
+ */
+
+static LRESULT CALLBACK
+winKeyboardMessageHookLL (int iCode, WPARAM wParam, LPARAM lParam);
+
+
+#ifndef LLKHF_EXTENDED
+# define LLKHF_EXTENDED 0x00000001
+#endif
+#ifndef LLKHF_UP
+# define LLKHF_UP 0x00000080
+#endif
+
+
+/*
+ * KeyboardMessageHook
+ */
+
+static LRESULT CALLBACK
+winKeyboardMessageHookLL (int iCode, WPARAM wParam, LPARAM lParam)
+{
+ BOOL fPassKeystroke = FALSE;
+ BOOL fPassAltTab = TRUE;
+ PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam;
+ HWND hwnd = GetActiveWindow();
+#ifdef XWIN_MULTIWINDOW
+ WindowPtr pWin = NULL;
+ winPrivWinPtr pWinPriv = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pWin = GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
+ {
+ /* Get a pointer to our window privates */
+ pWinPriv = winGetWindowPriv(pWin);
+
+ /* Get pointers to our screen privates and screen info */
+ pScreenPriv = pWinPriv->pScreenPriv;
+ pScreenInfo = pScreenPriv->pScreenInfo;
+
+ if (pScreenInfo->fMultiWindow)
+ fPassAltTab = FALSE;
+ }
+#endif
+
+ /* Pass keystrokes on to our main message loop */
+ if (iCode == HC_ACTION)
+ {
+#if 0
+ ErrorF ("vkCode: %08x\tscanCode: %08x\n", p->vkCode, p->scanCode);
+#endif
+
+ switch (wParam)
+ {
+ case WM_KEYDOWN: case WM_SYSKEYDOWN:
+ case WM_KEYUP: case WM_SYSKEYUP:
+ fPassKeystroke =
+ (fPassAltTab &&
+ (p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0))
+ || (p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)
+ ;
+ break;
+ }
+ }
+
+ /*
+ * Pass message on to our main message loop.
+ * We process this immediately with SendMessage so that the keystroke
+ * appears in, hopefully, the correct order.
+ */
+ if (fPassKeystroke)
+ {
+ LPARAM lParamKey = 0x0;
+
+ /* Construct the lParam from KBDLLHOOKSTRUCT */
+ lParamKey = lParamKey | (0x0000FFFF & 0x00000001); /* Repeat count */
+ lParamKey = lParamKey | (0x00FF0000 & (p->scanCode << 16));
+ lParamKey = lParamKey
+ | (0x01000000 & ((p->flags & LLKHF_EXTENDED) << 23));
+ lParamKey = lParamKey
+ | (0x20000000
+ & ((p->flags & LLKHF_ALTDOWN) << 24));
+ lParamKey = lParamKey | (0x80000000 & ((p->flags & LLKHF_UP) << 24));
+
+ /* Send message to our main window that has the keyboard focus */
+ PostMessage (hwnd,
+ (UINT) wParam,
+ (WPARAM) p->vkCode,
+ lParamKey);
+
+ return 1;
+ }
+
+ /* Call next hook */
+ return CallNextHookEx (NULL, iCode, wParam, lParam);
+}
+
+
+/*
+ * Attempt to install the keyboard hook, return FALSE if it was not installed
+ */
+
+Bool
+winInstallKeyboardHookLL ()
+{
+ OSVERSIONINFO osvi = {0};
+
+ /* Get operating system version information */
+ osvi.dwOSVersionInfoSize = sizeof (osvi);
+ GetVersionEx (&osvi);
+
+ /* Branch on platform ID */
+ switch (osvi.dwPlatformId)
+ {
+ case VER_PLATFORM_WIN32_NT:
+ /* Low-level is supported on NT 4.0 SP3+ only */
+ /* TODO: Return FALSE on NT 4.0 with no SP, SP1, or SP2 */
+ break;
+
+ case VER_PLATFORM_WIN32_WINDOWS:
+ /* Low-level hook is not supported on non-NT */
+ return FALSE;
+ }
+
+ /* Install the hook only once */
+ if (!g_hhookKeyboardLL)
+ g_hhookKeyboardLL = SetWindowsHookEx (WH_KEYBOARD_LL,
+ winKeyboardMessageHookLL,
+ g_hInstance,
+ 0);
+
+ return TRUE;
+}
+
+
+/*
+ * Remove the keyboard hook if it is installed
+ */
+
+void
+winRemoveKeyboardHookLL ()
+{
+ if (g_hhookKeyboardLL)
+ UnhookWindowsHookEx (g_hhookKeyboardLL);
+ g_hhookKeyboardLL = NULL;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winkeymap.h b/nx-X11/programs/Xserver/hw/xwin/winkeymap.h
new file mode 100755
index 000000000..31e6cf21b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winkeymap.h
@@ -0,0 +1,138 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Keymap.h,v 3.19 2002/05/31 18:45:58 dawes Exp $ */
+/*
+ *
+ * For Scancodes see notes in winkeynames.h !!!!
+ *
+ */
+/* $XConsortium: xf86Keymap.h /main/14 1996/02/21 17:38:47 kaleb $ */
+
+static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = {
+ /* 0x00 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x01 */ XK_Escape, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x02 */ XK_1, XK_exclam, NoSymbol, NoSymbol,
+ /* 0x03 */ XK_2, XK_at, NoSymbol, NoSymbol,
+ /* 0x04 */ XK_3, XK_numbersign, NoSymbol, NoSymbol,
+ /* 0x05 */ XK_4, XK_dollar, NoSymbol, NoSymbol,
+ /* 0x06 */ XK_5, XK_percent, NoSymbol, NoSymbol,
+ /* 0x07 */ XK_6, XK_asciicircum, NoSymbol, NoSymbol,
+ /* 0x08 */ XK_7, XK_ampersand, NoSymbol, NoSymbol,
+ /* 0x09 */ XK_8, XK_asterisk, NoSymbol, NoSymbol,
+ /* 0x0a */ XK_9, XK_parenleft, NoSymbol, NoSymbol,
+ /* 0x0b */ XK_0, XK_parenright, NoSymbol, NoSymbol,
+ /* 0x0c */ XK_minus, XK_underscore, NoSymbol, NoSymbol,
+ /* 0x0d */ XK_equal, XK_plus, NoSymbol, NoSymbol,
+ /* 0x0e */ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x0f */ XK_Tab, XK_ISO_Left_Tab,NoSymbol, NoSymbol,
+ /* 0x10 */ XK_Q, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x11 */ XK_W, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x12 */ XK_E, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x13 */ XK_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x14 */ XK_T, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x15 */ XK_Y, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x16 */ XK_U, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x17 */ XK_I, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x18 */ XK_O, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x19 */ XK_P, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1a */ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol,
+ /* 0x1b */ XK_bracketright,XK_braceright, NoSymbol, NoSymbol,
+ /* 0x1c */ XK_Return, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1d */ XK_Control_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1e */ XK_A, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x1f */ XK_S, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x20 */ XK_D, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x21 */ XK_F, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x22 */ XK_G, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x23 */ XK_H, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x24 */ XK_J, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x25 */ XK_K, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x26 */ XK_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x27 */ XK_semicolon, XK_colon, NoSymbol, NoSymbol,
+ /* 0x28 */ XK_quoteright, XK_quotedbl, NoSymbol, NoSymbol,
+ /* 0x29 */ XK_quoteleft, XK_asciitilde, NoSymbol, NoSymbol,
+ /* 0x2a */ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2b */ XK_backslash, XK_bar, NoSymbol, NoSymbol,
+ /* 0x2c */ XK_Z, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2d */ XK_X, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2e */ XK_C, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x2f */ XK_V, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x30 */ XK_B, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x31 */ XK_N, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x32 */ XK_M, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x33 */ XK_comma, XK_less, NoSymbol, NoSymbol,
+ /* 0x34 */ XK_period, XK_greater, NoSymbol, NoSymbol,
+ /* 0x35 */ XK_slash, XK_question, NoSymbol, NoSymbol,
+ /* 0x36 */ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x37 */ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x38 */ XK_Alt_L, XK_Meta_L, NoSymbol, NoSymbol,
+ /* 0x39 */ XK_space, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3a */ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3b */ XK_F1, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3c */ XK_F2, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3d */ XK_F3, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3e */ XK_F4, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x3f */ XK_F5, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x40 */ XK_F6, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x41 */ XK_F7, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x42 */ XK_F8, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x43 */ XK_F9, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x44 */ XK_F10, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x45 */ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x46 */ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x47 */ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol,
+ /* 0x48 */ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol,
+ /* 0x49 */ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol,
+ /* 0x4a */ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4b */ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol,
+ /* 0x4c */ XK_KP_Begin, XK_KP_5, NoSymbol, NoSymbol,
+ /* 0x4d */ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol,
+ /* 0x4e */ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x4f */ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol,
+ /* 0x50 */ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol,
+ /* 0x51 */ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol,
+ /* 0x52 */ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol,
+ /* 0x53 */ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol,
+ /* 0x54 */ XK_Sys_Req, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x55 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x56 */ XK_less, XK_greater, NoSymbol, NoSymbol,
+ /* 0x57 */ XK_F11, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x58 */ XK_F12, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x59 */ XK_Home, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5a */ XK_Up, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5b */ XK_Prior, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5c */ XK_Left, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5d */ XK_Begin, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5e */ XK_Right, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x5f */ XK_End, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x60 */ XK_Down, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x61 */ XK_Next, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x62 */ XK_Insert, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x63 */ XK_Delete, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x64 */ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x65 */ XK_Control_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x66 */ XK_Pause, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x67 */ XK_Print, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x68 */ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x69 */ XK_Alt_R, XK_Meta_R, NoSymbol, NoSymbol,
+ /* 0x6a */ XK_Break, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6b */ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6c */ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6d */ XK_Menu, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6e */ XK_F13, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x6f */ XK_F14, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x70 */ XK_F15, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x71 */ XK_F16, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x72 */ XK_F17, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x73 */ XK_backslash, XK_underscore, NoSymbol, NoSymbol,
+ /* 0x74 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x75 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x76 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x77 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x78 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x79 */ XK_Henkan, XK_Mode_switch, NoSymbol, NoSymbol,
+ /* 0x7a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7b */ XK_Muhenkan, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7d */ XK_backslash, XK_bar, NoSymbol, NoSymbol,
+ /* 0x7e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ /* 0x7f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+};
diff --git a/nx-X11/programs/Xserver/hw/xwin/winkeynames.h b/nx-X11/programs/Xserver/hw/xwin/winkeynames.h
new file mode 100755
index 000000000..f3af1907e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winkeynames.h
@@ -0,0 +1,204 @@
+#ifndef _WINKEYNAMES_H
+#define _WINKEYNAMES_H
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/atKeynames.h,v 3.18 2001/09/29 20:40:30 herrb Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: atKeynames.h /main/11 1996/03/09 11:17:41 kaleb $ */
+
+#define XK_TECHNICAL
+#define XK_KATAKANA
+#include <X11/keysym.h>
+
+#define GLYPHS_PER_KEY 4
+#define NUM_KEYCODES 248
+#define MIN_KEYCODE 8
+#define MAX_KEYCODE (NUM_KEYCODES + MIN_KEYCODE - 1)
+
+#define AltMask Mod1Mask
+#define NumLockMask Mod2Mask
+#define AltLangMask Mod3Mask
+#define KanaMask Mod4Mask
+#define ScrollLockMask Mod5Mask
+
+#define KeyPressed(k) (keyc->down[k >> 3] & (1 << (k & 7)))
+#define ModifierDown(k) ((keyc->state & (k)) == (k))
+
+/*
+ * NOTE: The AT/MF keyboards can generate (via the 8042) two (MF: three)
+ * sets of scancodes. Set3 can only be generated by a MF keyboard.
+ * Set2 sends a makecode for keypress, and the same code prefixed by a
+ * F0 for keyrelease. This is a little bit ugly to handle. Thus we use
+ * here for X386 the PC/XT compatible Set1. This set uses 8bit scancodes.
+ * Bit 7 ist set if the key is released. The code E0 switches to a
+ * different meaning to add the new MF cursorkeys, while not breaking old
+ * applications. E1 is another special prefix. Since I assume that there
+ * will be further versions of PC/XT scancode compatible keyboards, we
+ * may be in trouble one day.
+ *
+ * IDEA: 1) Use Set2 on AT84 keyboards and translate it to MF Set3.
+ * 2) Use the keyboards native set and translate it to common keysyms.
+ */
+
+/*
+ * definition of the AT84/MF101/MF102 Keyboard:
+ * ============================================================
+ * Defined Key Cap Glyphs Pressed value
+ * Key Name Main Also (hex) (dec)
+ * ---------------- ---------- ------- ------ ------
+ */
+
+#define KEY_Escape /* Escape 0x01 */ 1
+#define KEY_1 /* 1 ! 0x02 */ 2
+#define KEY_2 /* 2 @ 0x03 */ 3
+#define KEY_3 /* 3 # 0x04 */ 4
+#define KEY_4 /* 4 $ 0x05 */ 5
+#define KEY_5 /* 5 % 0x06 */ 6
+#define KEY_6 /* 6 ^ 0x07 */ 7
+#define KEY_7 /* 7 & 0x08 */ 8
+#define KEY_8 /* 8 * 0x09 */ 9
+#define KEY_9 /* 9 ( 0x0a */ 10
+#define KEY_0 /* 0 ) 0x0b */ 11
+#define KEY_Minus /* - (Minus) _ (Under) 0x0c */ 12
+#define KEY_Equal /* = (Equal) + 0x0d */ 13
+#define KEY_BackSpace /* Back Space 0x0e */ 14
+#define KEY_Tab /* Tab 0x0f */ 15
+#define KEY_Q /* Q 0x10 */ 16
+#define KEY_W /* W 0x11 */ 17
+#define KEY_E /* E 0x12 */ 18
+#define KEY_R /* R 0x13 */ 19
+#define KEY_T /* T 0x14 */ 20
+#define KEY_Y /* Y 0x15 */ 21
+#define KEY_U /* U 0x16 */ 22
+#define KEY_I /* I 0x17 */ 23
+#define KEY_O /* O 0x18 */ 24
+#define KEY_P /* P 0x19 */ 25
+#define KEY_LBrace /* [ { 0x1a */ 26
+#define KEY_RBrace /* ] } 0x1b */ 27
+#define KEY_Enter /* Enter 0x1c */ 28
+#define KEY_LCtrl /* Ctrl(left) 0x1d */ 29
+#define KEY_A /* A 0x1e */ 30
+#define KEY_S /* S 0x1f */ 31
+#define KEY_D /* D 0x20 */ 32
+#define KEY_F /* F 0x21 */ 33
+#define KEY_G /* G 0x22 */ 34
+#define KEY_H /* H 0x23 */ 35
+#define KEY_J /* J 0x24 */ 36
+#define KEY_K /* K 0x25 */ 37
+#define KEY_L /* L 0x26 */ 38
+#define KEY_SemiColon /* ;(SemiColon) :(Colon) 0x27 */ 39
+#define KEY_Quote /* ' (Apostr) " (Quote) 0x28 */ 40
+#define KEY_Tilde /* ` (Accent) ~ (Tilde) 0x29 */ 41
+#define KEY_ShiftL /* Shift(left) 0x2a */ 42
+#define KEY_BSlash /* \(BckSlash) |(VertBar)0x2b */ 43
+#define KEY_Z /* Z 0x2c */ 44
+#define KEY_X /* X 0x2d */ 45
+#define KEY_C /* C 0x2e */ 46
+#define KEY_V /* V 0x2f */ 47
+#define KEY_B /* B 0x30 */ 48
+#define KEY_N /* N 0x31 */ 49
+#define KEY_M /* M 0x32 */ 50
+#define KEY_Comma /* , (Comma) < (Less) 0x33 */ 51
+#define KEY_Period /* . (Period) >(Greater)0x34 */ 52
+#define KEY_Slash /* / (Slash) ? 0x35 */ 53
+#define KEY_ShiftR /* Shift(right) 0x36 */ 54
+#define KEY_KP_Multiply /* * 0x37 */ 55
+#define KEY_Alt /* Alt(left) 0x38 */ 56
+#define KEY_Space /* (SpaceBar) 0x39 */ 57
+#define KEY_CapsLock /* CapsLock 0x3a */ 58
+#define KEY_F1 /* F1 0x3b */ 59
+#define KEY_F2 /* F2 0x3c */ 60
+#define KEY_F3 /* F3 0x3d */ 61
+#define KEY_F4 /* F4 0x3e */ 62
+#define KEY_F5 /* F5 0x3f */ 63
+#define KEY_F6 /* F6 0x40 */ 64
+#define KEY_F7 /* F7 0x41 */ 65
+#define KEY_F8 /* F8 0x42 */ 66
+#define KEY_F9 /* F9 0x43 */ 67
+#define KEY_F10 /* F10 0x44 */ 68
+#define KEY_NumLock /* NumLock 0x45 */ 69
+#define KEY_ScrollLock /* ScrollLock 0x46 */ 70
+#define KEY_KP_7 /* 7 Home 0x47 */ 71
+#define KEY_KP_8 /* 8 Up 0x48 */ 72
+#define KEY_KP_9 /* 9 PgUp 0x49 */ 73
+#define KEY_KP_Minus /* - (Minus) 0x4a */ 74
+#define KEY_KP_4 /* 4 Left 0x4b */ 75
+#define KEY_KP_5 /* 5 0x4c */ 76
+#define KEY_KP_6 /* 6 Right 0x4d */ 77
+#define KEY_KP_Plus /* + (Plus) 0x4e */ 78
+#define KEY_KP_1 /* 1 End 0x4f */ 79
+#define KEY_KP_2 /* 2 Down 0x50 */ 80
+#define KEY_KP_3 /* 3 PgDown 0x51 */ 81
+#define KEY_KP_0 /* 0 Insert 0x52 */ 82
+#define KEY_KP_Decimal /* . (Decimal) Delete 0x53 */ 83
+#define KEY_SysReqest /* SysReqest 0x54 */ 84
+ /* NOTUSED 0x55 */
+#define KEY_Less /* < (Less) >(Greater) 0x56 */ 86
+#define KEY_F11 /* F11 0x57 */ 87
+#define KEY_F12 /* F12 0x58 */ 88
+
+#define KEY_Prefix0 /* special 0x60 */ 96
+#define KEY_Prefix1 /* specail 0x61 */ 97
+
+/*
+ * The 'scancodes' below are generated by the server, because the MF101/102
+ * keyboard sends them as sequence of other scancodes
+ */
+#define KEY_Home /* Home 0x59 */ 89
+#define KEY_Up /* Up 0x5a */ 90
+#define KEY_PgUp /* PgUp 0x5b */ 91
+#define KEY_Left /* Left 0x5c */ 92
+#define KEY_Begin /* Begin 0x5d */ 93
+#define KEY_Right /* Right 0x5e */ 94
+#define KEY_End /* End 0x5f */ 95
+#define KEY_Down /* Down 0x60 */ 96
+#define KEY_PgDown /* PgDown 0x61 */ 97
+#define KEY_Insert /* Insert 0x62 */ 98
+#define KEY_Delete /* Delete 0x63 */ 99
+#define KEY_KP_Enter /* Enter 0x64 */ 100
+#define KEY_RCtrl /* Ctrl(right) 0x65 */ 101
+#define KEY_Pause /* Pause 0x66 */ 102
+#define KEY_Print /* Print 0x67 */ 103
+#define KEY_KP_Divide /* Divide 0x68 */ 104
+#define KEY_AltLang /* AtlLang(right) 0x69 */ 105
+#define KEY_Break /* Break 0x6a */ 106
+#define KEY_LMeta /* Left Meta 0x6b */ 107
+#define KEY_RMeta /* Right Meta 0x6c */ 108
+#define KEY_Menu /* Menu 0x6d */ 109
+#define KEY_F13 /* F13 0x6e */ 110
+#define KEY_F14 /* F14 0x6f */ 111
+#define KEY_F15 /* F15 0x70 */ 112
+#define KEY_F16 /* F16 0x71 */ 113
+#define KEY_F17 /* F17 0x72 */ 114
+#define KEY_KP_DEC /* KP_DEC 0x73 */ 115
+#define KEY_KP_Equal /* Equal (Keypad) 0x76 */ 118
+#define KEY_XFER /* Kanji Transfer 0x79 */ 121
+#define KEY_NFER /* No Kanji Transfer 0x7b */ 123
+#define KEY_Yen /* Yen 0x7d */ 125
+#define KEY_HKTG /* Hirugana/Katakana tog 0xc8 */ 200
+#define KEY_BSlash2 /* \ _ 0xcb */ 203
+
+/* These are for "notused" and "unknown" entries in translation maps. */
+#define KEY_NOTUSED 0
+#define KEY_UNKNOWN 255
+
+#endif /* _WINKEYNAMES_H */
diff --git a/nx-X11/programs/Xserver/hw/xwin/winlayouts.h b/nx-X11/programs/Xserver/hw/xwin/winlayouts.h
new file mode 100644
index 000000000..cc0752430
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winlayouts.h
@@ -0,0 +1,257 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* Definitions for various keyboard layouts from windows and their
+ * XKB settings.
+ */
+
+typedef struct
+{
+ unsigned int winlayout;
+ int winkbtype;
+ char *xkbmodel;
+ char *xkblayout;
+ char *xkbvariant;
+ char *xkboptions;
+ char *layoutname;
+} WinKBLayoutRec, *WinKBLayoutPtr;
+
+WinKBLayoutRec winKBLayouts[] =
+{
+ { 0x405, -1, "pc105", "cz", NULL, NULL, "Czech"},
+ {0x10405, -1, "pc105", "cz_qwerty", NULL, NULL, "Czech (QWERTY)"},
+ { 0x406, -1, "pc105", "dk", NULL, NULL, "Danish"},
+ { 0x407, -1, "pc105", "de", NULL, NULL, "German (Germany)"},
+ {0x10407, -1, "pc105", "de", NULL, NULL, "German (Germany, IBM)"},
+ { 0x807, -1, "pc105", "de_CH", NULL, NULL, "German (Switzerland)"},
+ { 0x409, -1, "pc105", "us", NULL, NULL, "English (USA)"},
+ {0x10409, -1, "pc105", "dvorak", NULL, NULL, "English (USA, Dvorak)"},
+ {0x20409, -1, "pc105", "us_intl", NULL, NULL, "English (USA, International)"},
+ { 0x809, -1, "pc105", "gb", NULL, NULL, "English (United Kingdom)"},
+ { 0x1809, -1, "pc105", "ie", NULL, NULL, "Irish"},
+ { 0x40a, -1, "pc105", "es", NULL, NULL, "Spanish (Spain, Traditional Sort)"},
+ { 0x40b, -1, "pc105", "fi", NULL, NULL, "Finnish"},
+ { 0x40c, -1, "pc105", "fr", NULL, NULL, "French (Standard)"},
+ { 0x80c, -1, "pc105", "be", NULL, NULL, "French (Belgian)"},
+ { 0xc0c, -1, "pc105", "ca_enhanced", NULL, NULL, "French (Canada)"},
+ { 0x100c, -1, "pc105", "fr_CH", NULL, NULL, "French (Switzerland)"},
+ { 0x40e, -1, "pc105", "hu", NULL, NULL, "Hungarian"},
+ { 0x410, -1, "pc105", "it", NULL, NULL, "Italian"},
+ { 0x411, 7, "jp106", "jp", NULL, NULL, "Japanese"},
+ { 0x813, -1, "pc105", "be", NULL, NULL, "Dutch (Belgian)"},
+ { 0x414, -1, "pc105", "no", NULL, NULL, "Norwegian"},
+ { 0x416, -1, "pc105", "br", NULL, NULL, "Portuguese (Brazil, ABNT)"},
+ {0x10416, -1, "abnt2", "br", NULL, NULL, "Portuguese (Brazil, ABNT2)"},
+ { 0x816, -1, "pc105", "pt", NULL, NULL, "Portuguese (Portugal)"},
+ { 0x41d, -1, "pc105", "se", NULL, NULL, "Swedish (Sweden)"},
+ { -1, -1, NULL, NULL, NULL, NULL, NULL}
+};
+
+/* Listing of language codes from MSDN */
+/*
+Support ID XKB Language
+====================================================================
+ ? 0x0000 Language Neutral
+ ? 0x0400 Process or User Default Language
+ ? 0x0800 System Default Language
+ 0x0401 Arabic (Saudi Arabia)
+ 0x0801 Arabic (Iraq)
+ 0x0c01 Arabic (Egypt)
+ 0x1001 Arabic (Libya)
+ 0x1401 Arabic (Algeria)
+ 0x1801 Arabic (Morocco)
+ 0x1c01 Arabic (Tunisia)
+ 0x2001 Arabic (Oman)
+ 0x2401 Arabic (Yemen)
+ 0x2801 Arabic (Syria)
+ 0x2c01 Arabic (Jordan)
+ 0x3001 Arabic (Lebanon)
+ 0x3401 Arabic (Kuwait)
+ 0x3801 Arabic (U.A.E.)
+ 0x3c01 Arabic (Bahrain)
+ 0x4001 Arabic (Qatar)
+ Arabic (102) AZERTY
+ 0x0402 Bulgarian
+ 0x0403 Catalan
+ 0x0404 Chinese (Taiwan)
+ 0x0804 Chinese (PRC)
+ 0x0c04 Chinese (Hong Kong SAR, PRC)
+ 0x1004 Chinese (Singapore)
+ 0x1404 Chinese (Macao SAR) (98/ME,2K/XP)
+ X 0x0405 cz Czech
+ X cz_qwerty Czech (QWERTY)
+ Czech (Programmers)
+ X 0x0406 dk Danish
+ X 0x0407 de German (Standard)
+ X 0x0807 de_CH German (Switzerland)
+ 0x0c07 German (Austria)
+ 0x1007 German (Luxembourg)
+ 0x1407 German (Liechtenstein)
+ 0x0408 Greek
+ X 0x0409 us English (United States)
+ X 0x0809 gb English (United Kingdom)
+ 0x0c09 English (Australian)
+ 0x1009 English (Canadian)
+ 0x1409 English (New Zealand)
+ X 0x1809 ie English (Ireland)
+ 0x1c09 English (South Africa)
+ 0x2009 English (Jamaica)
+ 0x2409 English (Caribbean)
+ 0x2809 English (Belize)
+ 0x2c09 English (Trinidad)
+ 0x3009 English (Zimbabwe) (98/ME,2K/XP)
+ 0x3409 English (Philippines) (98/ME,2K/XP)
+ X 0x040a es Spanish (Spain, Traditional Sort)
+ 0x080a Spanish (Mexican)
+ 0x0c0a Spanish (Spain, Modern Sort)
+ 0x100a Spanish (Guatemala)
+ 0x140a Spanish (Costa Rica)
+ 0x180a Spanish (Panama)
+ 0x1c0a Spanish (Dominican Republic)
+ 0x200a Spanish (Venezuela)
+ 0x240a Spanish (Colombia)
+ 0x280a Spanish (Peru)
+ 0x2c0a Spanish (Argentina)
+ 0x300a Spanish (Ecuador)
+ 0x340a Spanish (Chile)
+ 0x380a Spanish (Uruguay)
+ 0x3c0a Spanish (Paraguay)
+ 0x400a Spanish (Bolivia)
+ 0x440a Spanish (El Salvador)
+ 0x480a Spanish (Honduras)
+ 0x4c0a Spanish (Nicaragua)
+ 0x500a Spanish (Puerto Rico)
+ X 0x040b fi Finnish
+ Finnish (with Sami)
+ X 0x040c fr French (Standard)
+ X 0x080c be French (Belgian)
+ . 0x0c0c French (Canadian)
+ French (Canadian, Legacy)
+ Canadian (Multilingual)
+ X 0x100c fr_CH French (Switzerland)
+ 0x140c French (Luxembourg)
+ 0x180c French (Monaco) (98/ME,2K/XP)
+ 0x040d Hebrew
+ X 0x040e hu Hungarian
+ . 0x040f Icelandic
+ X 0x0410 it Italian (Standard)
+ 0x0810 Italian (Switzerland)
+ X 0x0411 jp Japanese
+ 0x0412 Korean
+ 0x0812 Korean (Johab) (95,NT)
+ . 0x0413 Dutch (Netherlands)
+ X 0x0813 be Dutch (Belgium)
+ X 0x0414 no Norwegian (Bokmal)
+ 0x0814 Norwegian (Nynorsk)
+ . 0x0415 Polish
+ X 0x0416 br Portuguese (Brazil)
+ X 0x0816 pt Portuguese (Portugal)
+ . 0x0418 Romanian
+ 0x0419 Russian
+ . 0x041a Croatian
+ . 0x081a Serbian (Latin)
+ . 0x0c1a Serbian (Cyrillic)
+ 0x101a Croatian (Bosnia and Herzegovina)
+ 0x141a Bosnian (Bosnia and Herzegovina)
+ 0x181a Serbian (Latin, Bosnia, and Herzegovina)
+ 0x1c1a Serbian (Cyrillic, Bosnia, and Herzegovina)
+ . 0x041b Slovak
+ . 0x041c Albanian
+ X 0x041d se Swedish
+ 0x081d Swedish (Finland)
+ 0x041e Thai
+ 0x041f Turkish
+ 0x0420 Urdu (Pakistan) (98/ME,2K/XP)
+ 0x0820 Urdu (India)
+ 0x0421 Indonesian
+ 0x0422 Ukrainian
+ 0x0423 Belarusian
+ . 0x0424 Slovenian
+ 0x0425 Estonian
+ 0x0426 Latvian
+ 0x0427 Lithuanian
+ 0x0827 Lithuanian (Classic) (98)
+ 0x0429 Farsi
+ 0x042a Vietnamese (98/ME,NT,2K/XP)
+ 0x042b Armenian. This is Unicode only. (2K/XP)
+ Armenian Eastern
+ Armenian Western
+ 0x042c Azeri (Latin)
+ 0x082c Azeri (Cyrillic)
+ 0x042d Basque
+ 0x042f Macedonian (FYROM)
+ 0x0430 Sutu
+ 0x0432 Setswana/Tswana (South Africa)
+ 0x0434 isiXhosa/Xhosa (South Africa)
+ 0x0435 isiZulu/Zulu (South Africa)
+ 0x0436 Afrikaans
+ 0x0437 Georgian. This is Unicode only. (2K/XP)
+ . 0x0438 Faeroese
+ 0x0439 Hindi. This is Unicode only. (2K/XP)
+ 0x043a Maltese (Malta)
+ 0x043b Sami, Northern (Norway)
+ 0x083b Sami, Northern (Sweden)
+ 0x0c3b Sami, Northern (Finland)
+ 0x103b Sami, Lule (Norway)
+ 0x143b Sami, Lule (Sweden)
+ 0x183b Sami, Southern (Norway)
+ 0x1c3b Sami, Southern (Sweden)
+ 0x203b Sami, Skolt (Finland)
+ 0x243b Sami, Inari (Finland)
+ 0x043e Malay (Malaysian)
+ 0x083e Malay (Brunei Darussalam)
+ 0x0440 Kyrgyz. (XP)
+ 0x0441 Swahili (Kenya)
+ 0x0443 Uzbek (Latin)
+ 0x0843 Uzbek (Cyrillic)
+ 0x0444 Tatar (Tatarstan)
+ 0x0445 Bengali (India)
+ Bengali (Inscript)
+ 0x0446 Punjabi. This is Unicode only. (XP)
+ 0x0447 Gujarati. This is Unicode only. (XP)
+ 0x0449 Tamil. This is Unicode only. (2K/XP)
+ 0x044a Telugu. This is Unicode only. (XP)
+ 0x044b Kannada. This is Unicode only. (XP)
+ 0x044c Malayalam (India)
+ 0x044e Marathi. This is Unicode only. (2K/XP)
+ 0x044f Sanskrit. This is Unicode only. (2K/XP)
+ 0x0450 Mongolian (XP)
+ 0x0452 Welsh (United Kingdom)
+ 0x0455 Burmese
+ 0x0456 Galician (XP)
+ 0x0457 Konkani. This is Unicode only. (2K/XP)
+ 0x045a Syriac. This is Unicode only. (XP)
+ 0x0465 Divehi. This is Unicode only. (XP)
+ Divehi (Phonetic)
+ Divehi (Typewriter)
+ 0x046b Quechua (Bolivia)
+ 0x086b Quechua (Ecuador)
+ 0x0c6b Quechua (Peru)
+ 0x046c Sesotho sa Leboa/Northern Sotho (South Africa)
+ 0x007f LOCALE_INVARIANT. See MAKELCID.
+ 0x0481 Maori (New Zealand)
+*/
+
+
diff --git a/nx-X11/programs/Xserver/hw/xwin/winmessages.h b/nx-X11/programs/Xserver/hw/xwin/winmessages.h
new file mode 100755
index 000000000..ae50dc474
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winmessages.h
@@ -0,0 +1,1030 @@
+#ifndef __WINMESSAGES_H__
+#define __WINMESSAGES_H__
+static const unsigned MESSAGE_NAMES_LEN =1024;
+static const char *MESSAGE_NAMES[1024] = {
+ "WM_NULL",
+ "WM_CREATE",
+ "WM_DESTROY",
+ "WM_MOVE",
+ "4",
+ "WM_SIZE",
+ "WM_ACTIVATE",
+ "WM_SETFOCUS",
+ "WM_KILLFOCUS",
+ "9",
+ "WM_ENABLE",
+ "WM_SETREDRAW",
+ "WM_SETTEXT",
+ "WM_GETTEXT",
+ "WM_GETTEXTLENGTH",
+ "WM_PAINT",
+ "WM_CLOSE",
+ "WM_QUERYENDSESSION",
+ "WM_QUIT",
+ "WM_QUERYOPEN",
+ "WM_ERASEBKGND",
+ "WM_SYSCOLORCHANGE",
+ "WM_ENDSESSION",
+ "23",
+ "WM_SHOWWINDOW",
+ "25",
+ "WM_WININICHANGE",
+ "WM_DEVMODECHANGE",
+ "WM_ACTIVATEAPP",
+ "WM_FONTCHANGE",
+ "WM_TIMECHANGE",
+ "WM_CANCELMODE",
+ NULL /* WM_SETCURSOR */,
+ "WM_MOUSEACTIVATE",
+ "WM_CHILDACTIVATE",
+ "WM_QUEUESYNC",
+ "WM_GETMINMAXINFO",
+ "37",
+ "WM_PAINTICON",
+ "WM_ICONERASEBKGND",
+ "WM_NEXTDLGCTL",
+ "41",
+ "WM_SPOOLERSTATUS",
+ "WM_DRAWITEM",
+ "WM_MEASUREITEM",
+ "WM_DELETEITEM",
+ "WM_VKEYTOITEM",
+ "WM_CHARTOITEM",
+ "WM_SETFONT",
+ "WM_GETFONT",
+ "WM_SETHOTKEY",
+ "WM_GETHOTKEY",
+ "52",
+ "53",
+ "54",
+ "WM_QUERYDRAGICON",
+ "56",
+ "WM_COMPAREITEM",
+ "58",
+ "59",
+ "60",
+ "61",
+ "62",
+ "63",
+ "64",
+ "WM_COMPACTING",
+ "66",
+ "67",
+ "WM_COMMNOTIFY",
+ "69",
+ "WM_WINDOWPOSCHANGING",
+ "WM_WINDOWPOSCHANGED",
+ "WM_POWER",
+ "73",
+ "WM_COPYDATA",
+ "WM_CANCELJOURNAL",
+ "76",
+ "77",
+ "WM_NOTIFY",
+ "79",
+ "WM_INPUTLANGCHANGEREQUEST",
+ "WM_INPUTLANGCHANGE",
+ "WM_TCARD",
+ "WM_HELP",
+ "WM_USERCHANGED",
+ "WM_NOTIFYFORMAT",
+ "86",
+ "87",
+ "88",
+ "89",
+ "90",
+ "91",
+ "92",
+ "93",
+ "94",
+ "95",
+ "96",
+ "97",
+ "98",
+ "99",
+ "100",
+ "101",
+ "102",
+ "103",
+ "104",
+ "105",
+ "106",
+ "107",
+ "108",
+ "109",
+ "110",
+ "111",
+ "112",
+ "113",
+ "114",
+ "115",
+ "116",
+ "117",
+ "118",
+ "119",
+ "120",
+ "121",
+ "122",
+ "WM_CONTEXTMENU",
+ "WM_STYLECHANGING",
+ "WM_STYLECHANGED",
+ "WM_DISPLAYCHANGE",
+ "WM_GETICON",
+ "WM_SETICON",
+ "WM_NCCREATE",
+ "WM_NCDESTROY",
+ "WM_NCCALCSIZE",
+ NULL /* WM_NCHITTEST */,
+ "WM_NCPAINT",
+ "WM_NCACTIVATE",
+ "WM_GETDLGCODE",
+ "WM_SYNCPAINT",
+ "137",
+ "138",
+ "139",
+ "140",
+ "141",
+ "142",
+ "143",
+ "144",
+ "145",
+ "146",
+ "147",
+ "148",
+ "149",
+ "150",
+ "151",
+ "152",
+ "153",
+ "154",
+ "155",
+ "156",
+ "157",
+ "158",
+ "159",
+ NULL /* WM_NCMOUSEMOVE */,
+ "WM_NCLBUTTONDOWN",
+ "WM_NCLBUTTONUP",
+ "WM_NCLBUTTONDBLCLK",
+ "WM_NCRBUTTONDOWN",
+ "WM_NCRBUTTONUP",
+ "WM_NCRBUTTONDBLCLK",
+ "WM_NCMBUTTONDOWN",
+ "WM_NCMBUTTONUP",
+ "WM_NCMBUTTONDBLCLK",
+ "170",
+ "171",
+ "172",
+ "173",
+ "174",
+ "175",
+ "176",
+ "177",
+ "178",
+ "179",
+ "180",
+ "181",
+ "182",
+ "183",
+ "184",
+ "185",
+ "186",
+ "187",
+ "188",
+ "189",
+ "190",
+ "191",
+ "192",
+ "193",
+ "194",
+ "195",
+ "196",
+ "197",
+ "198",
+ "199",
+ "200",
+ "201",
+ "202",
+ "203",
+ "204",
+ "205",
+ "206",
+ "207",
+ "208",
+ "209",
+ "210",
+ "211",
+ "212",
+ "213",
+ "214",
+ "215",
+ "216",
+ "217",
+ "218",
+ "219",
+ "220",
+ "221",
+ "222",
+ "223",
+ "224",
+ "225",
+ "226",
+ "227",
+ "228",
+ "229",
+ "230",
+ "231",
+ "232",
+ "233",
+ "234",
+ "235",
+ "236",
+ "237",
+ "238",
+ "239",
+ "240",
+ "241",
+ "242",
+ "243",
+ "244",
+ "245",
+ "246",
+ "247",
+ "248",
+ "249",
+ "250",
+ "251",
+ "252",
+ "253",
+ "254",
+ "255",
+ "WM_KEYDOWN",
+ "WM_KEYUP",
+ "WM_CHAR",
+ "WM_DEADCHAR",
+ "WM_SYSKEYDOWN",
+ "WM_SYSKEYUP",
+ "WM_SYSCHAR",
+ "WM_SYSDEADCHAR",
+ "WM_CONVERTREQUESTEX",
+ "265",
+ "266",
+ "267",
+ "268",
+ "WM_IME_STARTCOMPOSITION",
+ "WM_IME_ENDCOMPOSITION",
+ "WM_IME_KEYLAST",
+ "WM_INITDIALOG",
+ "WM_COMMAND",
+ "WM_SYSCOMMAND",
+ NULL /* WM_TIMER */,
+ "WM_HSCROLL",
+ "WM_VSCROLL",
+ "WM_INITMENU",
+ "WM_INITMENUPOPUP",
+ "280",
+ "281",
+ "282",
+ "283",
+ "284",
+ "285",
+ "286",
+ "WM_MENUSELECT",
+ "WM_MENUCHAR",
+ "WM_ENTERIDLE",
+ "290",
+ "291",
+ "292",
+ "293",
+ "294",
+ "295",
+ "296",
+ "297",
+ "298",
+ "299",
+ "300",
+ "301",
+ "302",
+ "303",
+ "304",
+ "305",
+ "WM_CTLCOLORMSGBOX",
+ "WM_CTLCOLOREDIT",
+ "WM_CTLCOLORLISTBOX",
+ "WM_CTLCOLORBTN",
+ "WM_CTLCOLORDLG",
+ "WM_CTLCOLORSCROLLBAR",
+ "WM_CTLCOLORSTATIC",
+ "313",
+ "314",
+ "315",
+ "316",
+ "317",
+ "318",
+ "319",
+ "320",
+ "321",
+ "322",
+ "323",
+ "324",
+ "325",
+ "326",
+ "327",
+ "328",
+ "329",
+ "330",
+ "331",
+ "332",
+ "333",
+ "334",
+ "335",
+ "336",
+ "337",
+ "338",
+ "339",
+ "340",
+ "341",
+ "342",
+ "343",
+ "344",
+ "345",
+ "346",
+ "347",
+ "348",
+ "349",
+ "350",
+ "351",
+ "352",
+ "353",
+ "354",
+ "355",
+ "356",
+ "357",
+ "358",
+ "359",
+ "360",
+ "361",
+ "362",
+ "363",
+ "364",
+ "365",
+ "366",
+ "367",
+ "368",
+ "369",
+ "370",
+ "371",
+ "372",
+ "373",
+ "374",
+ "375",
+ "376",
+ "377",
+ "378",
+ "379",
+ "380",
+ "381",
+ "382",
+ "383",
+ "384",
+ "385",
+ "386",
+ "387",
+ "388",
+ "389",
+ "390",
+ "391",
+ "392",
+ "393",
+ "394",
+ "395",
+ "396",
+ "397",
+ "398",
+ "399",
+ "400",
+ "401",
+ "402",
+ "403",
+ "404",
+ "405",
+ "406",
+ "407",
+ "408",
+ "409",
+ "410",
+ "411",
+ "412",
+ "413",
+ "414",
+ "415",
+ "416",
+ "417",
+ "418",
+ "419",
+ "420",
+ "421",
+ "422",
+ "423",
+ "424",
+ "425",
+ "426",
+ "427",
+ "428",
+ "429",
+ "430",
+ "431",
+ "432",
+ "433",
+ "434",
+ "435",
+ "436",
+ "437",
+ "438",
+ "439",
+ "440",
+ "441",
+ "442",
+ "443",
+ "444",
+ "445",
+ "446",
+ "447",
+ "448",
+ "449",
+ "450",
+ "451",
+ "452",
+ "453",
+ "454",
+ "455",
+ "456",
+ "457",
+ "458",
+ "459",
+ "460",
+ "461",
+ "462",
+ "463",
+ "464",
+ "465",
+ "466",
+ "467",
+ "468",
+ "469",
+ "470",
+ "471",
+ "472",
+ "473",
+ "474",
+ "475",
+ "476",
+ "477",
+ "478",
+ "479",
+ "480",
+ "481",
+ "482",
+ "483",
+ "484",
+ "485",
+ "486",
+ "487",
+ "488",
+ "489",
+ "490",
+ "491",
+ "492",
+ "493",
+ "494",
+ "495",
+ "496",
+ "497",
+ "498",
+ "499",
+ "500",
+ "501",
+ "502",
+ "503",
+ "504",
+ "505",
+ "506",
+ "507",
+ "508",
+ "509",
+ "510",
+ "511",
+ NULL /* WM_MOUSEMOVE */,
+ "WM_LBUTTONDOWN",
+ "WM_LBUTTONUP",
+ "WM_LBUTTONDBLCLK",
+ "WM_RBUTTONDOWN",
+ "WM_RBUTTONUP",
+ "WM_RBUTTONDBLCLK",
+ "WM_MBUTTONDOWN",
+ "WM_MBUTTONUP",
+ "WM_MBUTTONDBLCLK",
+ "WM_MOUSEWHEEL",
+ "WM_XBUTTONDOWN",
+ "WM_XBUTTONUP",
+ "WM_XBUTTONDBLCLK",
+ "526",
+ "527",
+ "WM_PARENTNOTIFY",
+ "WM_ENTERMENULOOP",
+ "WM_EXITMENULOOP",
+ "WM_NEXTMENU",
+ "WM_SIZING",
+ "WM_CAPTURECHANGED",
+ "WM_MOVING",
+ "535",
+ "WM_POWERBROADCAST",
+ "WM_DEVICECHANGE",
+ "538",
+ "539",
+ "540",
+ "541",
+ "542",
+ "543",
+ "WM_MDICREATE",
+ "WM_MDIDESTROY",
+ "WM_MDIACTIVATE",
+ "WM_MDIRESTORE",
+ "WM_MDINEXT",
+ "WM_MDIMAXIMIZE",
+ "WM_MDITILE",
+ "WM_MDICASCADE",
+ "WM_MDIICONARRANGE",
+ "WM_MDIGETACTIVE",
+ "554",
+ "555",
+ "556",
+ "557",
+ "558",
+ "559",
+ "WM_MDISETMENU",
+ "WM_ENTERSIZEMOVE",
+ "WM_EXITSIZEMOVE",
+ "WM_DROPFILES",
+ "WM_MDIREFRESHMENU",
+ "565",
+ "566",
+ "567",
+ "568",
+ "569",
+ "570",
+ "571",
+ "572",
+ "573",
+ "574",
+ "575",
+ "576",
+ "577",
+ "578",
+ "579",
+ "580",
+ "581",
+ "582",
+ "583",
+ "584",
+ "585",
+ "586",
+ "587",
+ "588",
+ "589",
+ "590",
+ "591",
+ "592",
+ "593",
+ "594",
+ "595",
+ "596",
+ "597",
+ "598",
+ "599",
+ "600",
+ "601",
+ "602",
+ "603",
+ "604",
+ "605",
+ "606",
+ "607",
+ "608",
+ "609",
+ "610",
+ "611",
+ "612",
+ "613",
+ "614",
+ "615",
+ "616",
+ "617",
+ "618",
+ "619",
+ "620",
+ "621",
+ "622",
+ "623",
+ "624",
+ "625",
+ "626",
+ "627",
+ "628",
+ "629",
+ "630",
+ "631",
+ "632",
+ "633",
+ "634",
+ "635",
+ "636",
+ "637",
+ "638",
+ "639",
+ "640",
+ "WM_IME_SETCONTEXT",
+ "WM_IME_NOTIFY",
+ "WM_IME_CONTROL",
+ "WM_IME_COMPOSITIONFULL",
+ "WM_IME_SELECT",
+ "WM_IME_CHAR",
+ "647",
+ "648",
+ "649",
+ "650",
+ "651",
+ "652",
+ "653",
+ "654",
+ "655",
+ "WM_IME_KEYDOWN",
+ "WM_IME_KEYUP",
+ "658",
+ "659",
+ "660",
+ "661",
+ "662",
+ "663",
+ "664",
+ "665",
+ "666",
+ "667",
+ "668",
+ "669",
+ "670",
+ "671",
+ "672",
+ "WM_MOUSEHOVER",
+ "674",
+ "WM_MOUSELEAVE",
+ "676",
+ "677",
+ "678",
+ "679",
+ "680",
+ "681",
+ "682",
+ "683",
+ "684",
+ "685",
+ "686",
+ "687",
+ "688",
+ "689",
+ "690",
+ "691",
+ "692",
+ "693",
+ "694",
+ "695",
+ "696",
+ "697",
+ "698",
+ "699",
+ "700",
+ "701",
+ "702",
+ "703",
+ "704",
+ "705",
+ "706",
+ "707",
+ "708",
+ "709",
+ "710",
+ "711",
+ "712",
+ "713",
+ "714",
+ "715",
+ "716",
+ "717",
+ "718",
+ "719",
+ "720",
+ "721",
+ "722",
+ "723",
+ "724",
+ "725",
+ "726",
+ "727",
+ "728",
+ "729",
+ "730",
+ "731",
+ "732",
+ "733",
+ "734",
+ "735",
+ "736",
+ "737",
+ "738",
+ "739",
+ "740",
+ "741",
+ "742",
+ "743",
+ "744",
+ "745",
+ "746",
+ "747",
+ "748",
+ "749",
+ "750",
+ "751",
+ "752",
+ "753",
+ "754",
+ "755",
+ "756",
+ "757",
+ "758",
+ "759",
+ "760",
+ "761",
+ "762",
+ "763",
+ "764",
+ "765",
+ "766",
+ "767",
+ "WM_CUT",
+ "WM_COPY",
+ "WM_PASTE",
+ "WM_CLEAR",
+ "WM_UNDO",
+ "WM_RENDERFORMAT",
+ "WM_RENDERALLFORMATS",
+ "WM_DESTROYCLIPBOARD",
+ "WM_DRAWCLIPBOARD",
+ "WM_PAINTCLIPBOARD",
+ "WM_VSCROLLCLIPBOARD",
+ "WM_SIZECLIPBOARD",
+ "WM_ASKCBFORMATNAME",
+ "WM_CHANGECBCHAIN",
+ "WM_HSCROLLCLIPBOARD",
+ "WM_QUERYNEWPALETTE",
+ "WM_PALETTEISCHANGING",
+ "WM_PALETTECHANGED",
+ "WM_HOTKEY",
+ "787",
+ "788",
+ "789",
+ "790",
+ "WM_PRINT",
+ "WM_PRINTCLIENT",
+ "793",
+ "794",
+ "795",
+ "796",
+ "797",
+ "798",
+ "799",
+ "800",
+ "801",
+ "802",
+ "803",
+ "804",
+ "805",
+ "806",
+ "807",
+ "808",
+ "809",
+ "810",
+ "811",
+ "812",
+ "813",
+ "814",
+ "815",
+ "816",
+ "817",
+ "818",
+ "819",
+ "820",
+ "821",
+ "822",
+ "823",
+ "824",
+ "825",
+ "826",
+ "827",
+ "828",
+ "829",
+ "830",
+ "831",
+ "832",
+ "833",
+ "834",
+ "835",
+ "836",
+ "837",
+ "838",
+ "839",
+ "840",
+ "841",
+ "842",
+ "843",
+ "844",
+ "845",
+ "846",
+ "847",
+ "848",
+ "849",
+ "850",
+ "851",
+ "852",
+ "853",
+ "854",
+ "855",
+ "856",
+ "857",
+ "858",
+ "859",
+ "860",
+ "861",
+ "862",
+ "863",
+ "864",
+ "865",
+ "866",
+ "867",
+ "868",
+ "869",
+ "870",
+ "871",
+ "872",
+ "873",
+ "874",
+ "875",
+ "876",
+ "877",
+ "878",
+ "879",
+ "880",
+ "881",
+ "882",
+ "883",
+ "884",
+ "885",
+ "886",
+ "887",
+ "888",
+ "889",
+ "890",
+ "891",
+ "892",
+ "893",
+ "894",
+ "895",
+ "896",
+ "897",
+ "898",
+ "899",
+ "900",
+ "901",
+ "902",
+ "903",
+ "904",
+ "905",
+ "906",
+ "907",
+ "908",
+ "909",
+ "910",
+ "911",
+ "912",
+ "913",
+ "914",
+ "915",
+ "916",
+ "917",
+ "918",
+ "919",
+ "920",
+ "921",
+ "922",
+ "923",
+ "924",
+ "925",
+ "926",
+ "927",
+ "928",
+ "929",
+ "930",
+ "931",
+ "932",
+ "933",
+ "934",
+ "935",
+ "936",
+ "937",
+ "938",
+ "939",
+ "940",
+ "941",
+ "942",
+ "943",
+ "944",
+ "945",
+ "946",
+ "947",
+ "948",
+ "949",
+ "950",
+ "951",
+ "952",
+ "953",
+ "954",
+ "955",
+ "956",
+ "957",
+ "958",
+ "959",
+ "960",
+ "961",
+ "962",
+ "963",
+ "964",
+ "965",
+ "966",
+ "967",
+ "968",
+ "969",
+ "970",
+ "971",
+ "972",
+ "973",
+ "974",
+ "975",
+ "976",
+ "977",
+ "978",
+ "979",
+ "980",
+ "981",
+ "982",
+ "983",
+ "984",
+ "985",
+ "986",
+ "987",
+ "988",
+ "989",
+ "990",
+ "991",
+ "992",
+ "993",
+ "994",
+ "995",
+ "996",
+ "997",
+ "998",
+ "999",
+ "1000",
+ "1001",
+ "1002",
+ "1003",
+ "1004",
+ "1005",
+ "1006",
+ "1007",
+ "1008",
+ "1009",
+ "1010",
+ "1011",
+ "1012",
+ "1013",
+ "1014",
+ "1015",
+ "1016",
+ "1017",
+ "1018",
+ "1019",
+ "1020",
+ "1021",
+ "1022",
+ "1023"
+};
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/winmisc.c b/nx-X11/programs/Xserver/hw/xwin/winmisc.c
new file mode 100644
index 000000000..8e6698118
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winmisc.c
@@ -0,0 +1,152 @@
+/*
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+#ifdef XWIN_NATIVEGDI
+/* See Porting Layer Definition - p. 33 */
+/*
+ * Called by clients, returns the best size for a cursor, tile, or
+ * stipple, specified by class (sometimes called kind)
+ */
+
+void
+winQueryBestSizeNativeGDI (int class, unsigned short *pWidth,
+ unsigned short *pHeight, ScreenPtr pScreen)
+{
+ ErrorF ("winQueryBestSizeNativeGDI\n");
+}
+#endif
+
+
+/*
+ * Count the number of one bits in a color mask.
+ */
+
+CARD8
+winCountBits (DWORD dw)
+{
+ DWORD dwBits = 0;
+
+ while (dw)
+ {
+ dwBits += (dw & 1);
+ dw >>= 1;
+ }
+
+ return dwBits;
+}
+
+
+/*
+ * Modify the screen pixmap to point to the new framebuffer address
+ */
+
+Bool
+winUpdateFBPointer (ScreenPtr pScreen, void *pbits)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Location of shadow framebuffer has changed */
+ pScreenInfo->pfb = pbits;
+
+ /* Update the screen pixmap */
+ if (!(*pScreen->ModifyPixmapHeader) (pScreen->devPrivate,
+ pScreen->width,
+ pScreen->height,
+ pScreen->rootDepth,
+ BitsPerPixel (pScreen->rootDepth),
+ PixmapBytePad (pScreenInfo->dwStride,
+ pScreenInfo->dwBPP),
+ pScreenInfo->pfb))
+ {
+ FatalError ("winUpdateFramebufferPointer - Failed modifying "\
+ "screen pixmap\n");
+ }
+
+ return TRUE;
+}
+
+
+#ifdef XWIN_NATIVEGDI
+/*
+ * Paint the window background with the specified color
+ */
+
+BOOL
+winPaintBackground (HWND hwnd, COLORREF colorref)
+{
+ HDC hdc;
+ HBRUSH hbrush;
+ RECT rect;
+
+ /* Create an hdc */
+ hdc = GetDC (hwnd);
+ if (hdc == NULL)
+ {
+ printf ("gdiWindowProc - GetDC failed\n");
+ exit (1);
+ }
+
+ /* Create and select blue brush */
+ hbrush = CreateSolidBrush (colorref);
+ if (hbrush == NULL)
+ {
+ printf ("gdiWindowProc - CreateSolidBrush failed\n");
+ exit (1);
+ }
+
+ /* Get window extents */
+ if (GetClientRect (hwnd, &rect) == FALSE)
+ {
+ printf ("gdiWindowProc - GetClientRect failed\n");
+ exit (1);
+ }
+
+ /* Fill window with blue brush */
+ if (FillRect (hdc, &rect, hbrush) == 0)
+ {
+ printf ("gdiWindowProc - FillRect failed\n");
+ exit (1);
+ }
+
+ /* Delete blue brush */
+ DeleteObject (hbrush);
+
+ /* Release the hdc */
+ ReleaseDC (hwnd, hdc);
+
+ return TRUE;
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/winmouse.c b/nx-X11/programs/Xserver/hw/xwin/winmouse.c
new file mode 100644
index 000000000..818652da6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winmouse.c
@@ -0,0 +1,341 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winmouse.c,v 1.3 2001/05/08 08:14:09 alanh Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+#if defined(XFree86Server) && defined(XINPUT)
+#include "inputstr.h"
+
+/* Peek the internal button mapping */
+static CARD8 const *g_winMouseButtonMap = NULL;
+#endif
+
+
+/*
+ * Local prototypes
+ */
+
+static void
+winMouseCtrl (DeviceIntPtr pDevice, PtrCtrl *pCtrl);
+
+
+static void
+winMouseCtrl (DeviceIntPtr pDevice, PtrCtrl *pCtrl)
+{
+}
+
+
+/*
+ * See Porting Layer Definition - p. 18
+ * This is known as a DeviceProc
+ */
+
+int
+winMouseProc (DeviceIntPtr pDeviceInt, int iState)
+{
+ int lngMouseButtons, i;
+ int lngWheelEvents = 2;
+ CARD8 *map;
+ DevicePtr pDevice = (DevicePtr) pDeviceInt;
+
+ switch (iState)
+ {
+ case DEVICE_INIT:
+ /* Get number of mouse buttons */
+ lngMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
+
+ /* Mapping of windows events to X events:
+ * LEFT:1 MIDDLE:2 RIGHT:3
+ * SCROLL_UP:4 SCROLL_DOWN:5
+ * XBUTTON 1:6 XBUTTON 2:7 ...
+ *
+ * To map scroll wheel correctly we need at least the 3 normal buttons
+ */
+ if (lngMouseButtons < 3)
+ lngMouseButtons = 3;
+ winMsg(X_PROBED, "%d mouse buttons found\n", lngMouseButtons);
+
+ /* allocate memory:
+ * number of buttons + 2x mouse wheel event + 1 extra (offset for map)
+ */
+ map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1));
+
+ /* initalize button map */
+ map[0] = 0;
+ for (i=1; i <= lngMouseButtons + lngWheelEvents; i++)
+ map[i] = i;
+ InitPointerDeviceStruct (pDevice,
+ map,
+ lngMouseButtons + lngWheelEvents,
+ miPointerGetMotionEvents,
+ winMouseCtrl,
+ miPointerGetMotionBufferSize ());
+ free(map);
+
+#if defined(XFree86Server) && defined(XINPUT)
+ g_winMouseButtonMap = pDeviceInt->button->map;
+#endif
+ break;
+
+ case DEVICE_ON:
+ pDevice->on = TRUE;
+ break;
+
+ case DEVICE_CLOSE:
+#if defined(XFree86Server) && defined(XINPUT)
+ g_winMouseButtonMap = NULL;
+#endif
+ case DEVICE_OFF:
+ pDevice->on = FALSE;
+ break;
+ }
+ return Success;
+}
+
+
+/* Handle the mouse wheel */
+int
+winMouseWheel (ScreenPtr pScreen, int iDeltaZ)
+{
+ winScreenPriv(pScreen);
+ int button; /* Button4 or Button5 */
+
+ /* Button4 = WheelUp */
+ /* Button5 = WheelDown */
+
+ /* Do we have any previous delta stored? */
+ if ((pScreenPriv->iDeltaZ > 0
+ && iDeltaZ > 0)
+ || (pScreenPriv->iDeltaZ < 0
+ && iDeltaZ < 0))
+ {
+ /* Previous delta and of same sign as current delta */
+ iDeltaZ += pScreenPriv->iDeltaZ;
+ pScreenPriv->iDeltaZ = 0;
+ }
+ else
+ {
+ /*
+ * Previous delta of different sign, or zero.
+ * We will set it to zero for either case,
+ * as blindly setting takes just as much time
+ * as checking, then setting if necessary :)
+ */
+ pScreenPriv->iDeltaZ = 0;
+ }
+
+ /*
+ * Only process this message if the wheel has moved further than
+ * WHEEL_DELTA
+ */
+ if (iDeltaZ >= WHEEL_DELTA || (-1 * iDeltaZ) >= WHEEL_DELTA)
+ {
+ pScreenPriv->iDeltaZ = 0;
+
+ /* Figure out how many whole deltas of the wheel we have */
+ iDeltaZ /= WHEEL_DELTA;
+ }
+ else
+ {
+ /*
+ * Wheel has not moved past WHEEL_DELTA threshold;
+ * we will store the wheel delta until the threshold
+ * has been reached.
+ */
+ pScreenPriv->iDeltaZ = iDeltaZ;
+ return 0;
+ }
+
+ /* Set the button to indicate up or down wheel delta */
+ if (iDeltaZ > 0)
+ {
+ button = Button4;
+ }
+ else
+ {
+ button = Button5;
+ }
+
+ /*
+ * Flip iDeltaZ to positive, if negative,
+ * because always need to generate a *positive* number of
+ * button clicks for the Z axis.
+ */
+ if (iDeltaZ < 0)
+ {
+ iDeltaZ *= -1;
+ }
+
+ /* Generate X input messages for each wheel delta we have seen */
+ while (iDeltaZ--)
+ {
+ /* Push the wheel button */
+ winMouseButtonsSendEvent (ButtonPress, button);
+
+ /* Release the wheel button */
+ winMouseButtonsSendEvent (ButtonRelease, button);
+ }
+
+ return 0;
+}
+
+
+/*
+ * Enqueue a mouse button event
+ */
+
+void
+winMouseButtonsSendEvent (int iEventType, int iButton)
+{
+ xEvent xCurrentEvent;
+
+ /* Load an xEvent and enqueue the event */
+ xCurrentEvent.u.u.type = iEventType;
+#if defined(XFree86Server) && defined(XINPUT)
+ if (g_winMouseButtonMap)
+ xCurrentEvent.u.u.detail = g_winMouseButtonMap[iButton];
+ else
+#endif
+ xCurrentEvent.u.u.detail = iButton;
+ xCurrentEvent.u.keyButtonPointer.time
+ = g_c32LastInputEventTime = GetTickCount ();
+ mieqEnqueue (&xCurrentEvent);
+}
+
+
+/*
+ * Decide what to do with a Windows mouse message
+ */
+
+int
+winMouseButtonsHandle (ScreenPtr pScreen,
+ int iEventType, int iButton,
+ WPARAM wParam)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Send button events right away if emulate 3 buttons is off */
+ if (pScreenInfo->iE3BTimeout == WIN_E3B_OFF)
+ {
+ /* Emulate 3 buttons is off, send the button event */
+ winMouseButtonsSendEvent (iEventType, iButton);
+ return 0;
+ }
+
+ /* Emulate 3 buttons is on, let the fun begin */
+ if (iEventType == ButtonPress
+ && pScreenPriv->iE3BCachedPress == 0
+ && !pScreenPriv->fE3BFakeButton2Sent)
+ {
+ /*
+ * Button was pressed, no press is cached,
+ * and there is no fake button 2 release pending.
+ */
+
+ /* Store button press type */
+ pScreenPriv->iE3BCachedPress = iButton;
+
+ /*
+ * Set a timer to send this button press if the other button
+ * is not pressed within the timeout time.
+ */
+ SetTimer (pScreenPriv->hwndScreen,
+ WIN_E3B_TIMER_ID,
+ pScreenInfo->iE3BTimeout,
+ NULL);
+ }
+ else if (iEventType == ButtonPress
+ && pScreenPriv->iE3BCachedPress != 0
+ && pScreenPriv->iE3BCachedPress != iButton
+ && !pScreenPriv->fE3BFakeButton2Sent)
+ {
+ /*
+ * Button press is cached, other button was pressed,
+ * and there is no fake button 2 release pending.
+ */
+
+ /* Mouse button was cached and other button was pressed */
+ KillTimer (pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
+ pScreenPriv->iE3BCachedPress = 0;
+
+ /* Send fake middle button */
+ winMouseButtonsSendEvent (ButtonPress, Button2);
+
+ /* Indicate that a fake middle button event was sent */
+ pScreenPriv->fE3BFakeButton2Sent = TRUE;
+ }
+ else if (iEventType == ButtonRelease
+ && pScreenPriv->iE3BCachedPress == iButton)
+ {
+ /*
+ * Cached button was released before timer ran out,
+ * and before the other mouse button was pressed.
+ */
+ KillTimer (pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
+ pScreenPriv->iE3BCachedPress = 0;
+
+ /* Send cached press, then send release */
+ winMouseButtonsSendEvent (ButtonPress, iButton);
+ winMouseButtonsSendEvent (ButtonRelease, iButton);
+ }
+ else if (iEventType == ButtonRelease
+ && pScreenPriv->fE3BFakeButton2Sent
+ && !(wParam & MK_LBUTTON)
+ && !(wParam & MK_RBUTTON))
+ {
+ /*
+ * Fake button 2 was sent and both mouse buttons have now been released
+ */
+ pScreenPriv->fE3BFakeButton2Sent = FALSE;
+
+ /* Send middle mouse button release */
+ winMouseButtonsSendEvent (ButtonRelease, Button2);
+ }
+ else if (iEventType == ButtonRelease
+ && pScreenPriv->iE3BCachedPress == 0
+ && !pScreenPriv->fE3BFakeButton2Sent)
+ {
+ /*
+ * Button was release, no button is cached,
+ * and there is no fake button 2 release is pending.
+ */
+ winMouseButtonsSendEvent (ButtonRelease, iButton);
+ }
+
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winms.h b/nx-X11/programs/Xserver/hw/xwin/winms.h
new file mode 100644
index 000000000..1ad30dc0b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winms.h
@@ -0,0 +1,46 @@
+#ifndef _WINMS_H_
+#define _WINMS_H_
+/*
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#define NONAMELESSUNION
+#define DIRECTDRAW_VERSION 0x0300
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+
+#include <X11/Xwindows.h>
+#include <windowsx.h>
+
+#include "ddraw.h"
+
+#undef CreateWindow
+
+#endif /* _WINMS_H_ */
diff --git a/nx-X11/programs/Xserver/hw/xwin/winmsg.c b/nx-X11/programs/Xserver/hw/xwin/winmsg.c
new file mode 100644
index 000000000..53974101e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winmsg.c
@@ -0,0 +1,180 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Alexander Gottwald
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winmsg.h"
+#if CYGDEBUG
+#include "winmessages.h"
+#endif
+#include <stdarg.h>
+
+void winVMsg (int, MessageType, int verb, const char *, va_list);
+
+void
+winVMsg (int scrnIndex, MessageType type, int verb, const char *format,
+ va_list ap)
+{
+ LogVMessageVerb(type, verb, format, ap);
+}
+
+
+void
+winDrvMsg (int scrnIndex, MessageType type, const char *format, ...)
+{
+ va_list ap;
+ va_start (ap, format);
+ LogVMessageVerb(type, 0, format, ap);
+ va_end (ap);
+}
+
+
+void
+winMsg (MessageType type, const char *format, ...)
+{
+ va_list ap;
+ va_start (ap, format);
+ LogVMessageVerb(type, 1, format, ap);
+ va_end (ap);
+}
+
+
+void
+winDrvMsgVerb (int scrnIndex, MessageType type, int verb, const char *format,
+ ...)
+{
+ va_list ap;
+ va_start (ap, format);
+ LogVMessageVerb(type, verb, format, ap);
+ va_end (ap);
+}
+
+
+void
+winMsgVerb (MessageType type, int verb, const char *format, ...)
+{
+ va_list ap;
+ va_start (ap, format);
+ LogVMessageVerb(type, verb, format, ap);
+ va_end (ap);
+}
+
+
+void
+winErrorFVerb (int verb, const char *format, ...)
+{
+ va_list ap;
+ va_start (ap, format);
+ LogVMessageVerb(X_NONE, verb, format, ap);
+ va_end (ap);
+}
+
+void
+winDebug (const char *format, ...)
+{
+ va_list ap;
+ va_start (ap, format);
+ LogVMessageVerb(X_NONE, 3, format, ap);
+ va_end (ap);
+}
+
+void
+winTrace (const char *format, ...)
+{
+ va_list ap;
+ va_start (ap, format);
+ LogVMessageVerb(X_NONE, 10, format, ap);
+ va_end (ap);
+}
+
+void
+winW32Error(int verb, const char *msg)
+{
+ winW32ErrorEx(verb, msg, GetLastError());
+}
+
+void
+winW32ErrorEx(int verb, const char *msg, DWORD errorcode)
+{
+ LPVOID buffer;
+ if (!FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ errorcode,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &buffer,
+ 0,
+ NULL ))
+ {
+ winErrorFVerb(verb, "Unknown error in FormatMessage!\n");
+ }
+ else
+ {
+ winErrorFVerb(verb, "%s %s", msg, (char *)buffer);
+ LocalFree(buffer);
+ }
+}
+
+#if CYGDEBUG
+void winDebugWin32Message(const char* function, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ static int force = 0;
+
+ if (message >= WM_USER)
+ {
+ if (force || getenv("WIN_DEBUG_MESSAGES") || getenv("WIN_DEBUG_WM_USER"))
+ {
+ winDebug("%s - Message WM_USER + %d\n", function, message - WM_USER);
+ winDebug("\thwnd 0x%x wParam 0x%x lParam 0x%x\n", hwnd, wParam, lParam);
+ }
+ }
+ else if (message < MESSAGE_NAMES_LEN && MESSAGE_NAMES[message])
+ {
+ const char *msgname = MESSAGE_NAMES[message];
+ char buffer[64];
+ snprintf(buffer, sizeof(buffer), "WIN_DEBUG_%s", msgname);
+ buffer[63] = 0;
+ if (force || getenv("WIN_DEBUG_MESSAGES") || getenv(buffer))
+ {
+ winDebug("%s - Message %s\n", function, MESSAGE_NAMES[message]);
+ winDebug("\thwnd 0x%x wParam 0x%x lParam 0x%x\n", hwnd, wParam, lParam);
+ }
+ }
+}
+#else
+void winDebugWin32Message(const char* function, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/winmsg.h b/nx-X11/programs/Xserver/hw/xwin/winmsg.h
new file mode 100644
index 000000000..367086c78
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winmsg.h
@@ -0,0 +1,52 @@
+#ifndef __WIN_MSG_H__
+#define __WIN_MSG_H__
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Alexander Gottwald
+ */
+/* $XFree86$ */
+
+
+/*
+ * Function prototypes
+ */
+
+void winDrvMsgVerb (int scrnIndex,
+ MessageType type, int verb, const char *format, ...);
+void winDrvMsg (int scrnIndex, MessageType type, const char *format, ...);
+void winMsgVerb (MessageType type, int verb, const char *format, ...);
+void winMsg (MessageType type, const char *format, ...);
+void winDebug (const char *format, ...);
+void winTrace (const char *format, ...);
+
+void winErrorFVerb (int verb, const char *format, ...);
+void winW32Error(int verb, const char *message);
+void winW32ErrorEx(int verb, const char *message, DWORD errorcode);
+void winDebugWin32Message(const char* function, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/winmultiwindowclass.c b/nx-X11/programs/Xserver/hw/xwin/winmultiwindowclass.c
new file mode 100755
index 000000000..d8909f0e5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winmultiwindowclass.c
@@ -0,0 +1,326 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Earle F. Philhower, III
+ */
+/* $XFree86$ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include <X11/Xatom.h>
+#include "propertyst.h"
+#include "windowstr.h"
+#include "winmultiwindowclass.h"
+#include "win.h"
+
+/*
+ * Local function
+ */
+
+DEFINE_ATOM_HELPER(AtmWmWindowRole, "WM_WINDOW_ROLE")
+
+
+int
+winMultiWindowGetClassHint (WindowPtr pWin, char **res_name, char **res_class)
+{
+ struct _Window *pwin;
+ struct _Property *prop;
+ int len_name, len_class;
+
+ if (!pWin || !res_name || !res_class)
+ {
+ ErrorF ("winMultiWindowGetClassHint - pWin, res_name, or res_class was "
+ "NULL\n");
+ return 0;
+ }
+
+ pwin = (struct _Window*) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ *res_name = *res_class = NULL;
+
+ while (prop)
+ {
+ if (prop->propertyName == XA_WM_CLASS
+ && prop->type == XA_STRING
+ && prop->format == 8
+ && prop->data)
+ {
+ len_name = strlen ((char *) prop->data);
+
+ (*res_name) = malloc (len_name + 1);
+
+ if (!*res_name)
+ {
+ ErrorF ("winMultiWindowGetClassHint - *res_name was NULL\n");
+ return 0;
+ }
+
+ /* Add one to len_name to allow copying of trailing 0 */
+ strncpy ((*res_name), prop->data, len_name + 1);
+
+ if (len_name == prop->size)
+ len_name--;
+
+ len_class = strlen (((char *)prop->data) + 1 + len_name);
+
+ (*res_class) = malloc (len_class + 1);
+
+ if (!*res_class)
+ {
+ ErrorF ("winMultiWindowGetClassHint - *res_class was NULL\n");
+
+ /* Free the previously allocated res_name */
+ free (*res_name);
+ return 0;
+ }
+
+ strcpy ((*res_class), ((char *)prop->data) + 1 + len_name);
+
+ return 1;
+ }
+ else
+ prop = prop->next;
+ }
+
+ return 0;
+}
+
+
+int
+winMultiWindowGetWMHints (WindowPtr pWin, WinXWMHints *hints)
+{
+ struct _Window *pwin;
+ struct _Property *prop;
+
+ if (!pWin || !hints)
+ {
+ ErrorF ("winMultiWindowGetWMHints - pWin or hints was NULL\n");
+ return 0;
+ }
+
+ pwin = (struct _Window*) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ memset (hints, 0, sizeof (WinXWMHints));
+
+ while (prop)
+ {
+ if (prop->propertyName == XA_WM_HINTS
+ && prop->data)
+ {
+ memcpy (hints, prop->data, sizeof (WinXWMHints));
+ return 1;
+ }
+ else
+ prop = prop->next;
+ }
+
+ return 0;
+}
+
+
+int
+winMultiWindowGetWindowRole (WindowPtr pWin, char **res_role)
+{
+ struct _Window *pwin;
+ struct _Property *prop;
+ int len_role;
+
+ if (!pWin || !res_role)
+ return 0;
+
+ pwin = (struct _Window*) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ *res_role = NULL;
+ while (prop)
+ {
+ if (prop->propertyName == AtmWmWindowRole ()
+ && prop->type == XA_STRING
+ && prop->format == 8
+ && prop->data)
+ {
+ len_role= prop->size;
+
+ (*res_role) = malloc (len_role + 1);
+
+ if (!*res_role)
+ {
+ ErrorF ("winMultiWindowGetWindowRole - *res_role was NULL\n");
+ return 0;
+ }
+
+ strncpy ((*res_role), prop->data, len_role);
+ (*res_role)[len_role] = 0;
+
+ return 1;
+ }
+ else
+ prop = prop->next;
+ }
+
+ return 0;
+}
+
+
+int
+winMultiWindowGetWMNormalHints (WindowPtr pWin, WinXSizeHints *hints)
+{
+ struct _Window *pwin;
+ struct _Property *prop;
+
+ if (!pWin || !hints)
+ {
+ ErrorF ("winMultiWindowGetWMNormalHints - pWin or hints was NULL\n");
+ return 0;
+ }
+
+ pwin = (struct _Window*) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ memset (hints, 0, sizeof (WinXSizeHints));
+
+ while (prop)
+ {
+ if (prop->propertyName == XA_WM_NORMAL_HINTS
+ && prop->data)
+ {
+ memcpy (hints, prop->data, sizeof (WinXSizeHints));
+ return 1;
+ }
+ else
+ prop = prop->next;
+ }
+
+ return 0;
+}
+
+int
+winMultiWindowGetTransientFor (WindowPtr pWin, WindowPtr *ppDaddy)
+{
+ struct _Window *pwin;
+ struct _Property *prop;
+
+ if (!pWin)
+ {
+ ErrorF ("winMultiWindowGetTransientFor - pWin was NULL\n");
+ return 0;
+ }
+
+ pwin = (struct _Window*) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ if (ppDaddy)
+ *ppDaddy = NULL;
+
+ while (prop)
+ {
+ if (prop->propertyName == XA_WM_TRANSIENT_FOR)
+ {
+ if (ppDaddy)
+ memcpy (*ppDaddy, prop->data, sizeof (WindowPtr *));
+ return 1;
+ }
+ else
+ prop = prop->next;
+ }
+
+ return 0;
+}
+
+int
+winMultiWindowGetWMName (WindowPtr pWin, char **wmName)
+{
+ struct _Window *pwin;
+ struct _Property *prop;
+ int len_name;
+
+ if (!pWin || !wmName)
+ {
+ ErrorF ("winMultiWindowGetClassHint - pWin, res_name, or res_class was "
+ "NULL\n");
+ return 0;
+ }
+
+ pwin = (struct _Window*) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ *wmName = NULL;
+
+ while (prop)
+ {
+ if (prop->propertyName == XA_WM_NAME
+ && prop->type == XA_STRING
+ && prop->data)
+ {
+ len_name = prop->size;
+
+ (*wmName) = malloc (len_name + 1);
+
+ if (!*wmName)
+ {
+ ErrorF ("winMultiWindowGetWMName - *wmName was NULL\n");
+ return 0;
+ }
+
+ strncpy ((*wmName), prop->data, len_name);
+ (*wmName)[len_name] = 0;
+
+ return 1;
+ }
+ else
+ prop = prop->next;
+ }
+
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winmultiwindowclass.h b/nx-X11/programs/Xserver/hw/xwin/winmultiwindowclass.h
new file mode 100755
index 000000000..0b430f2f8
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winmultiwindowclass.h
@@ -0,0 +1,116 @@
+#if !defined(WINMULTIWINDOWCLASS_H)
+#define WINMULTIWINDOWCLASS_H
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Earle F. Philhower, III
+ */
+/* $XFree86$ */
+
+
+/*
+ * Structures
+ */
+
+typedef struct {
+ long flags; /* marks which fields in this structure are defined */
+ Bool input; /* does this application rely on the window manager to
+ get keyboard input? */
+ int initial_state; /* see below */
+ Pixmap icon_pixmap; /* pixmap to be used as icon */
+ Window icon_window; /* window to be used as icon */
+ int icon_x, icon_y; /* initial position of icon */
+ Pixmap icon_mask; /* icon mask bitmap */
+ XID window_group; /* id of related window group */
+ /* this structure may be extended in the future */
+} WinXWMHints;
+
+
+/*
+ * new version containing base_width, base_height, and win_gravity fields;
+ * used with WM_NORMAL_HINTS.
+ */
+typedef struct {
+ long flags; /* marks which fields in this structure are defined */
+ int x, y; /* obsolete for new window mgrs, but clients */
+ int width, height; /* should set so old wm's don't mess up */
+ int min_width, min_height;
+ int max_width, max_height;
+ int width_inc, height_inc;
+ struct {
+ int x; /* numerator */
+ int y; /* denominator */
+ } min_aspect, max_aspect;
+ int base_width, base_height; /* added by ICCCM version 1 */
+ int win_gravity; /* added by ICCCM version 1 */
+} WinXSizeHints;
+
+/*
+ * The next block of definitions are for window manager properties that
+ * clients and applications use for communication.
+ */
+
+/* flags argument in size hints */
+#define USPosition (1L << 0) /* user specified x, y */
+#define USSize (1L << 1) /* user specified width, height */
+
+#define PPosition (1L << 2) /* program specified position */
+#define PSize (1L << 3) /* program specified size */
+#define PMinSize (1L << 4) /* program specified minimum size */
+#define PMaxSize (1L << 5) /* program specified maximum size */
+#define PResizeInc (1L << 6) /* program specified resize increments */
+#define PAspect (1L << 7) /* program specified min and max aspect ratios */
+#define PBaseSize (1L << 8) /* program specified base for incrementing */
+#define PWinGravity (1L << 9) /* program specified window gravity */
+
+/* obsolete */
+#define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect)
+
+
+/*
+ * Function prototypes
+ */
+
+int
+winMultiWindowGetWMHints (WindowPtr pWin, WinXWMHints *hints);
+
+int
+winMultiWindowGetClassHint (WindowPtr pWin, char **res_name, char **res_class);
+
+int
+winMultiWindowGetWindowRole (WindowPtr pWin, char **res_role);
+
+int
+winMultiWindowGetWMNormalHints (WindowPtr pWin, WinXSizeHints *hints);
+
+int
+winMultiWindowGetWMName (WindowPtr pWin, char **wmName);
+
+int
+winMultiWindowGetTransientFor (WindowPtr pWin, WindowPtr *ppDaddy);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/winmultiwindowicons.c b/nx-X11/programs/Xserver/hw/xwin/winmultiwindowicons.c
new file mode 100755
index 000000000..2121e998f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winmultiwindowicons.c
@@ -0,0 +1,478 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Earle F. Philhower, III
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winwindow.c,v 1.5 2002/11/07 10:31:32 alanh Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "dixevents.h"
+#include "winmultiwindowclass.h"
+#include "winprefs.h"
+
+
+/*
+ * External global variables
+ */
+
+extern HICON g_hIconX;
+extern HICON g_hSmallIconX;
+
+
+/*
+ * Prototypes for local functions
+ */
+
+static void
+winScaleXBitmapToWindows (int iconSize, int effBPP,
+ PixmapPtr pixmap, unsigned char *image);
+
+
+/*
+ * Scale an X icon bitmap into a Windoze icon bitmap
+ */
+
+static void
+winScaleXBitmapToWindows (int iconSize,
+ int effBPP,
+ PixmapPtr pixmap,
+ unsigned char *image)
+{
+ int row, column, effXBPP, effXDepth;
+ unsigned char *outPtr;
+ unsigned char *iconData = 0;
+ int stride, xStride;
+ float factX, factY;
+ int posX, posY;
+ unsigned char *ptr;
+ unsigned int zero;
+ unsigned int color;
+
+ effXBPP = BitsPerPixel(pixmap->drawable.depth);
+ effXDepth = pixmap->drawable.depth;
+
+ if (pixmap->drawable.bitsPerPixel == 15)
+ effXBPP = 16;
+
+ if (pixmap->drawable.depth == 15)
+ effXDepth = 16;
+
+ /* Need 32-bit aligned rows */
+ stride = ((iconSize * effBPP + 31) & (~31)) / 8;
+ xStride = PixmapBytePad (pixmap->drawable.width, pixmap->drawable.depth);
+ if (stride == 0 || xStride == 0)
+ {
+ ErrorF ("winScaleXBitmapToWindows - stride or xStride is zero. "
+ "Bailing.\n");
+ return;
+ }
+
+ /* Allocate memory for icon data */
+ iconData = malloc (xStride * pixmap->drawable.height);
+ if (!iconData)
+ {
+ ErrorF ("winScaleXBitmapToWindows - malloc failed for iconData. "
+ "Bailing.\n");
+ return;
+ }
+
+ /* Get icon data */
+ miGetImage ((DrawablePtr) &(pixmap->drawable), 0, 0,
+ pixmap->drawable.width, pixmap->drawable.height,
+ ZPixmap, 0xffffffff, iconData);
+
+ /* Keep aspect ratio */
+ factX = ((float)pixmap->drawable.width) / ((float)iconSize);
+ factY = ((float)pixmap->drawable.height) / ((float)iconSize);
+ if (factX > factY)
+ factY = factX;
+ else
+ factX = factY;
+
+ /* Out-of-bounds, fill icon with zero */
+ zero = 0;
+
+ for (row = 0; row < iconSize; row++)
+ {
+ outPtr = image + stride * row;
+ for (column = 0; column < iconSize; column++)
+ {
+ posX = factX * column;
+ posY = factY * row;
+
+ ptr = iconData + posY*xStride;
+ if (effXBPP == 1)
+ {
+ ptr += posX / 8;
+
+ /* Out of X icon bounds, leave space blank */
+ if (posX >= pixmap->drawable.width
+ || posY >= pixmap->drawable.height)
+ ptr = (unsigned char *) &zero;
+
+ if ((*ptr) & (1 << (posX & 7)))
+ switch (effBPP)
+ {
+ case 32:
+ *(outPtr++) = 0;
+ case 24:
+ *(outPtr++) = 0;
+ case 16:
+ *(outPtr++) = 0;
+ case 8:
+ *(outPtr++) = 0;
+ break;
+ case 1:
+ outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
+ break;
+ }
+ else
+ switch (effBPP)
+ {
+ case 32:
+ *(outPtr++) = 255;
+ *(outPtr++) = 255;
+ *(outPtr++) = 255;
+ *(outPtr++) = 0;
+ break;
+ case 24:
+ *(outPtr++) = 255;
+ case 16:
+ *(outPtr++) = 255;
+ case 8:
+ *(outPtr++) = 255;
+ break;
+ case 1:
+ outPtr[column / 8] |= (1 << (7 - (column & 7)));
+ break;
+ }
+ }
+ else if (effXDepth == 24 || effXDepth == 32)
+ {
+ ptr += posX * (effXBPP / 8);
+
+ /* Out of X icon bounds, leave space blank */
+ if (posX >= pixmap->drawable.width
+ || posY >= pixmap->drawable.height)
+ ptr = (unsigned char *) &zero;
+ color = (((*ptr) << 16)
+ + ((*(ptr + 1)) << 8)
+ + ((*(ptr + 2)) << 0));
+ switch (effBPP)
+ {
+ case 32:
+ *(outPtr++) = *(ptr++); // b
+ *(outPtr++) = *(ptr++); // g
+ *(outPtr++) = *(ptr++); // r
+ *(outPtr++) = 0; // resvd
+ break;
+ case 24:
+ *(outPtr++) = *(ptr++);
+ *(outPtr++) = *(ptr++);
+ *(outPtr++) = *(ptr++);
+ break;
+ case 16:
+ color = ((((*ptr) >> 2) << 10)
+ + (((*(ptr + 1)) >> 2) << 5)
+ + (((*(ptr + 2)) >> 2)));
+ *(outPtr++) = (color >> 8);
+ *(outPtr++) = (color & 255);
+ break;
+ case 8:
+ color = (((*ptr))) + (((*(ptr + 1)))) + (((*(ptr + 2))));
+ color /= 3;
+ *(outPtr++) = color;
+ break;
+ case 1:
+ if (color)
+ outPtr[column / 8] |= (1 << (7 - (column & 7)));
+ else
+ outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
+ }
+ }
+ else if (effXDepth == 16)
+ {
+ ptr += posX * (effXBPP / 8);
+
+ /* Out of X icon bounds, leave space blank */
+ if (posX >= pixmap->drawable.width
+ || posY >= pixmap->drawable.height)
+ ptr = (unsigned char *) &zero;
+ color = ((*ptr) << 8) + (*(ptr + 1));
+ switch (effBPP)
+ {
+ case 32:
+ *(outPtr++) = (color & 31) << 2;
+ *(outPtr++) = ((color >> 5) & 31) << 2;
+ *(outPtr++) = ((color >> 10) & 31) << 2;
+ *(outPtr++) = 0; // resvd
+ break;
+ case 24:
+ *(outPtr++) = (color & 31) << 2;
+ *(outPtr++) = ((color >> 5) & 31) << 2;
+ *(outPtr++) = ((color >> 10) & 31) << 2;
+ break;
+ case 16:
+ *(outPtr++) = *(ptr++);
+ *(outPtr++) = *(ptr++);
+ break;
+ case 8:
+ *(outPtr++) = (((color & 31)
+ + ((color >> 5) & 31)
+ + ((color >> 10) & 31)) / 3) << 2;
+ break;
+ case 1:
+ if (color)
+ outPtr[column / 8] |= (1 << (7 - (column & 7)));
+ else
+ outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
+ break;
+ } /* end switch(effbpp) */
+ } /* end if effxbpp==16) */
+ } /* end for column */
+ } /* end for row */
+ free (iconData);
+}
+
+
+/*
+ * Attempt to create a custom icon from the WM_HINTS bitmaps
+ */
+
+HICON
+winXIconToHICON (WindowPtr pWin, int iconSize)
+{
+ unsigned char *mask, *image, *imageMask;
+ unsigned char *dst, *src;
+ PixmapPtr iconPtr;
+ PixmapPtr maskPtr;
+ int planes, bpp, effBPP, stride, maskStride, i;
+ HDC hDC;
+ ICONINFO ii;
+ WinXWMHints hints;
+ HICON hIcon;
+
+ winMultiWindowGetWMHints (pWin, &hints);
+ if (!hints.icon_pixmap) return NULL;
+
+ iconPtr = LookupIDByType (hints.icon_pixmap, RT_PIXMAP);
+
+ if (!iconPtr) return NULL;
+
+ hDC = GetDC (GetDesktopWindow ());
+ planes = GetDeviceCaps (hDC, PLANES);
+ bpp = GetDeviceCaps (hDC, BITSPIXEL);
+ ReleaseDC (GetDesktopWindow (), hDC);
+
+ /* 15 BPP is really 16BPP as far as we care */
+ if (bpp == 15)
+ effBPP = 16;
+ else
+ effBPP = bpp;
+
+ /* Need 32-bit aligned rows */
+ stride = ((iconSize * effBPP + 31) & (~31)) / 8;
+
+ /* Mask is 1-bit deep */
+ maskStride = ((iconSize * 1 + 31) & (~31)) / 8;
+
+ image = (unsigned char * ) malloc (stride * iconSize);
+ imageMask = (unsigned char *) malloc (stride * iconSize);
+ mask = (unsigned char *) malloc (maskStride * iconSize);
+
+ /* Default to a completely black mask */
+ memset (mask, 0, maskStride * iconSize);
+
+ winScaleXBitmapToWindows (iconSize, effBPP, iconPtr, image);
+ maskPtr = LookupIDByType (hints.icon_mask, RT_PIXMAP);
+
+ if (maskPtr)
+ {
+ winScaleXBitmapToWindows (iconSize, 1, maskPtr, mask);
+
+ winScaleXBitmapToWindows (iconSize, effBPP, maskPtr, imageMask);
+
+ /* Now we need to set all bits of the icon which are not masked */
+ /* on to 0 because Color is really an XOR, not an OR function */
+ dst = image;
+ src = imageMask;
+
+ for (i = 0; i < (stride * iconSize); i++)
+ if ((*(src++)))
+ *(dst++) = 0;
+ else
+ dst++;
+ }
+
+ ii.fIcon = TRUE;
+ ii.xHotspot = 0; /* ignored */
+ ii.yHotspot = 0; /* ignored */
+
+ /* Create Win32 mask from pixmap shape */
+ ii.hbmMask = CreateBitmap (iconSize, iconSize, planes, 1, mask);
+
+ /* Create Win32 bitmap from pixmap */
+ ii.hbmColor = CreateBitmap (iconSize, iconSize, planes, bpp, image);
+
+ /* Merge Win32 mask and bitmap into icon */
+ hIcon = CreateIconIndirect (&ii);
+
+ /* Release Win32 mask and bitmap */
+ DeleteObject (ii.hbmMask);
+ DeleteObject (ii.hbmColor);
+
+ /* Free X mask and bitmap */
+ free (mask);
+ free (image);
+ free (imageMask);
+
+ return hIcon;
+}
+
+
+
+/*
+ * Change the Windows window icon
+ */
+
+#ifdef XWIN_MULTIWINDOW
+void
+winUpdateIcon (Window id)
+{
+ WindowPtr pWin;
+ HICON hIcon, hiconOld;
+
+ pWin = LookupIDByType (id, RT_WINDOW);
+ hIcon = (HICON)winOverrideIcon ((unsigned long)pWin);
+
+ if (!hIcon)
+ hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
+
+ if (hIcon)
+ {
+ winWindowPriv(pWin);
+
+ if (pWinPriv->hWnd)
+ {
+ hiconOld = (HICON) SetClassLong (pWinPriv->hWnd,
+ GCL_HICON,
+ (int) hIcon);
+
+ /* Delete the icon if its not the default */
+ winDestroyIcon(hiconOld);
+ }
+ }
+
+ hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXSMICON));
+ if (hIcon)
+ {
+ winWindowPriv(pWin);
+
+ if (pWinPriv->hWnd)
+ {
+ hiconOld = (HICON) SetClassLong (pWinPriv->hWnd,
+ GCL_HICONSM,
+ (int) hIcon);
+ winDestroyIcon (hiconOld);
+ }
+ }
+}
+
+void winInitGlobalIcons (void)
+{
+ int sm_cx = GetSystemMetrics(SM_CXICON);
+ int sm_cxsm = GetSystemMetrics(SM_CXSMICON);
+ /* Load default X icon in case it's not ready yet */
+ if (!g_hIconX)
+ {
+ g_hIconX = (HICON)winOverrideDefaultIcon(sm_cx);
+ g_hSmallIconX = (HICON)winOverrideDefaultIcon(sm_cxsm);
+ }
+
+ if (!g_hIconX)
+ {
+ g_hIconX = (HICON)LoadImage (g_hInstance,
+ MAKEINTRESOURCE(IDI_XWIN),
+ IMAGE_ICON,
+ GetSystemMetrics(SM_CXICON),
+ GetSystemMetrics(SM_CYICON),
+ 0);
+ g_hSmallIconX = (HICON)LoadImage (g_hInstance,
+ MAKEINTRESOURCE(IDI_XWIN),
+ IMAGE_ICON,
+ GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON),
+ LR_DEFAULTSIZE);
+ }
+}
+
+void winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon)
+{
+ HICON hIcon, hSmallIcon;
+
+ winInitGlobalIcons();
+
+ /* Try and get the icon from WM_HINTS */
+ hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
+ hSmallIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXSMICON));
+
+ /* If we got the small, but not the large one swap them */
+ if (!hIcon && hSmallIcon)
+ {
+ hIcon = hSmallIcon;
+ hSmallIcon = NULL;
+ }
+
+ /* Use default X icon if no icon loaded from WM_HINTS */
+ if (!hIcon) {
+ hIcon = g_hIconX;
+ hSmallIcon = g_hSmallIconX;
+ }
+
+ if (pIcon)
+ *pIcon = hIcon;
+ else
+ winDestroyIcon(hIcon);
+ if (pSmallIcon)
+ *pSmallIcon = hSmallIcon;
+ else
+ winDestroyIcon(hSmallIcon);
+}
+
+void winDestroyIcon(HICON hIcon)
+{
+ /* Delete the icon if its not the default */
+ if (hIcon &&
+ hIcon != g_hIconX &&
+ hIcon != g_hSmallIconX &&
+ !winIconIsOverride((unsigned long)hIcon))
+ DestroyIcon (hIcon);
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/winmultiwindowshape.c b/nx-X11/programs/Xserver/hw/xwin/winmultiwindowshape.c
new file mode 100755
index 000000000..0b9650e98
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winmultiwindowshape.c
@@ -0,0 +1,212 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Kensuke Matsuzaki
+ * Harold L Hunt II
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winmultiwindowshape.c,v 1.2 2003/11/10 18:22:44 tsi Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#ifdef SHAPE
+
+#include "win.h"
+
+
+/*
+ * winSetShapeMultiWindow - See Porting Layer Definition - p. 42
+ */
+
+void
+winSetShapeMultiWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winSetShapeMultiWindow - pWin: %08x\n", pWin);
+#endif
+
+ WIN_UNWRAP(SetShape);
+ (*pScreen->SetShape)(pWin);
+ WIN_WRAP(SetShape, winSetShapeMultiWindow);
+
+ /* Update the Windows window's shape */
+ winReshapeMultiWindow (pWin);
+ winUpdateRgnMultiWindow (pWin);
+
+ return;
+}
+
+
+/*
+ * winUpdateRgnMultiWindow - Local function to update a Windows window region
+ */
+
+void
+winUpdateRgnMultiWindow (WindowPtr pWin)
+{
+ SetWindowRgn (winGetWindowPriv(pWin)->hWnd,
+ winGetWindowPriv(pWin)->hRgn, TRUE);
+}
+
+
+/*
+ * winReshapeMultiWindow - Computes the composite clipping region for a window
+ */
+
+void
+winReshapeMultiWindow (WindowPtr pWin)
+{
+ int nRects;
+ RegionRec rrNewShape;
+ BoxPtr pShape, pRects, pEnd;
+ HRGN hRgn, hRgnRect;
+ winWindowPriv(pWin);
+
+#if CYGDEBUG
+ winDebug ("winReshape ()\n");
+#endif
+
+ /* Bail if the window is the root window */
+ if (pWin->parent == NULL)
+ return;
+
+ /* Bail if the window is not top level */
+ if (pWin->parent->parent != NULL)
+ return;
+
+ /* Bail if Windows window handle is invalid */
+ if (pWinPriv->hWnd == NULL)
+ return;
+
+ /* Free any existing window region stored in the window privates */
+ if (pWinPriv->hRgn != NULL)
+ {
+ DeleteObject (pWinPriv->hRgn);
+ pWinPriv->hRgn = NULL;
+ }
+
+ /* Bail if the window has no bounding region defined */
+ if (!wBoundingShape (pWin))
+ return;
+
+ REGION_NULL(pWin->drawable.pScreen, &rrNewShape);
+ REGION_COPY(pWin->drawable.pScreen, &rrNewShape, wBoundingShape(pWin));
+ REGION_TRANSLATE(pWin->drawable.pScreen,
+ &rrNewShape,
+ pWin->borderWidth,
+ pWin->borderWidth);
+
+ nRects = REGION_NUM_RECTS(&rrNewShape);
+ pShape = REGION_RECTS(&rrNewShape);
+
+ /* Don't do anything if there are no rectangles in the region */
+ if (nRects > 0)
+ {
+ RECT rcClient;
+ RECT rcWindow;
+ int iOffsetX, iOffsetY;
+
+ /* Get client rectangle */
+ if (!GetClientRect (pWinPriv->hWnd, &rcClient))
+ {
+ ErrorF ("winReshape - GetClientRect failed, bailing: %d\n",
+ (int) GetLastError ());
+ return;
+ }
+
+ /* Translate client rectangle coords to screen coords */
+ /* NOTE: Only transforms top and left members */
+ ClientToScreen (pWinPriv->hWnd, (LPPOINT) &rcClient);
+
+ /* Get window rectangle */
+ if (!GetWindowRect (pWinPriv->hWnd, &rcWindow))
+ {
+ ErrorF ("winReshape - GetWindowRect failed, bailing: %d\n",
+ (int) GetLastError ());
+ return;
+ }
+
+ /* Calculate offset from window upper-left to client upper-left */
+ iOffsetX = rcClient.left - rcWindow.left;
+ iOffsetY = rcClient.top - rcWindow.top;
+
+ /* Create initial Windows region for title bar */
+ /* FIXME: Mean, nasty, ugly hack!!! */
+ hRgn = CreateRectRgn (0, 0, rcWindow.right, iOffsetY);
+ if (hRgn == NULL)
+ {
+ ErrorF ("winReshape - Initial CreateRectRgn (%d, %d, %d, %d) "
+ "failed: %d\n",
+ 0, 0, (int) rcWindow.right, iOffsetY, (int) GetLastError ());
+ }
+
+ /* Loop through all rectangles in the X region */
+ for (pRects = pShape, pEnd = pShape + nRects; pRects < pEnd; pRects++)
+ {
+ /* Create a Windows region for the X rectangle */
+ hRgnRect = CreateRectRgn (pRects->x1 + iOffsetX,
+ pRects->y1 + iOffsetY,
+ pRects->x2 + iOffsetX,
+ pRects->y2 + iOffsetY);
+ if (hRgnRect == NULL)
+ {
+ ErrorF ("winReshape - Loop CreateRectRgn (%d, %d, %d, %d) "
+ "failed: %d\n"
+ "\tx1: %d x2: %d xOff: %d y1: %d y2: %d yOff: %d\n",
+ pRects->x1 + iOffsetX,
+ pRects->y1 + iOffsetY,
+ pRects->x2 + iOffsetX,
+ pRects->y2 + iOffsetY,
+ (int) GetLastError (),
+ pRects->x1, pRects->x2, iOffsetX,
+ pRects->y1, pRects->y2, iOffsetY);
+ }
+
+ /* Merge the Windows region with the accumulated region */
+ if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR)
+ {
+ ErrorF ("winReshape - CombineRgn () failed: %d\n",
+ (int) GetLastError ());
+ }
+
+ /* Delete the temporary Windows region */
+ DeleteObject (hRgnRect);
+ }
+
+ /* Save a handle to the composite region in the window privates */
+ pWinPriv->hRgn = hRgn;
+ }
+
+ REGION_UNINIT(pWin->drawable.pScreen, &rrNewShape);
+
+ return;
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/winmultiwindowwindow.c b/nx-X11/programs/Xserver/hw/xwin/winmultiwindowwindow.c
new file mode 100644
index 000000000..f1ab55252
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winmultiwindowwindow.c
@@ -0,0 +1,1056 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Kensuke Matsuzaki
+ * Earle F. Philhower, III
+ * Harold L Hunt II
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winwindow.c,v 1.5 2002/11/07 10:31:32 alanh Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "dixevents.h"
+#include "winmultiwindowclass.h"
+#include "winprefs.h"
+
+/*
+ * External global variables
+ */
+
+extern HWND g_hDlgDepthChange;
+
+extern void winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon);
+
+/*
+ * Prototypes for local functions
+ */
+
+void
+winCreateWindowsWindow (WindowPtr pWin);
+
+static void
+winDestroyWindowsWindow (WindowPtr pWin);
+
+static void
+winUpdateWindowsWindow (WindowPtr pWin);
+
+static void
+winFindWindow (pointer value, XID id, pointer cdata);
+
+/*
+ * Constant defines
+ */
+
+#define MOUSE_POLLING_INTERVAL 500
+
+
+/*
+ * Macros
+ */
+
+#define SubSend(pWin) \
+ ((pWin->eventMask|wOtherEventMasks(pWin)) & SubstructureNotifyMask)
+
+#define StrSend(pWin) \
+ ((pWin->eventMask|wOtherEventMasks(pWin)) & StructureNotifyMask)
+
+#define SubStrSend(pWin,pParent) (StrSend(pWin) || SubSend(pParent))
+
+
+/*
+ * CreateWindow - See Porting Layer Definition - p. 37
+ */
+
+Bool
+winCreateWindowMultiWindow (WindowPtr pWin)
+{
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGMULTIWINDOW_DEBUG
+ winTrace ("winCreateWindowMultiWindow - pWin: %p\n", pWin);
+#endif
+
+ WIN_UNWRAP(CreateWindow);
+ fResult = (*pScreen->CreateWindow) (pWin);
+ WIN_WRAP(CreateWindow, winCreateWindowMultiWindow);
+
+ /* Initialize some privates values */
+ pWinPriv->hRgn = NULL;
+ pWinPriv->hWnd = NULL;
+ pWinPriv->pScreenPriv = winGetScreenPriv(pWin->drawable.pScreen);
+ pWinPriv->fXKilled = FALSE;
+
+ return fResult;
+}
+
+
+/*
+ * DestroyWindow - See Porting Layer Definition - p. 37
+ */
+
+Bool
+winDestroyWindowMultiWindow (WindowPtr pWin)
+{
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winDestroyWindowMultiWindow - pWin: %p\n", pWin);
+#endif
+
+ WIN_UNWRAP(DestroyWindow);
+ fResult = (*pScreen->DestroyWindow)(pWin);
+ WIN_WRAP(DestroyWindow, winDestroyWindowMultiWindow);
+
+ /* Flag that the window has been destroyed */
+ pWinPriv->fXKilled = TRUE;
+
+ /* Kill the MS Windows window associated with this window */
+ winDestroyWindowsWindow (pWin);
+
+ return fResult;
+}
+
+
+/*
+ * PositionWindow - See Porting Layer Definition - p. 37
+ *
+ * This function adjusts the position and size of Windows window
+ * with respect to the underlying X window. This is the inverse
+ * of winAdjustXWindow, which adjusts X window to Windows window.
+ */
+
+Bool
+winPositionWindowMultiWindow (WindowPtr pWin, int x, int y)
+{
+ Bool fResult = TRUE;
+ int iX, iY, iWidth, iHeight;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+ HWND hWnd = pWinPriv->hWnd;
+ RECT rcNew;
+ RECT rcOld;
+#if CYGMULTIWINDOW_DEBUG
+ RECT rcClient;
+ RECT *lpRc;
+#endif
+ DWORD dwExStyle;
+ DWORD dwStyle;
+
+#if CYGMULTIWINDOW_DEBUG
+ winTrace ("winPositionWindowMultiWindow - pWin: %p\n", pWin);
+#endif
+
+ WIN_UNWRAP(PositionWindow);
+ fResult = (*pScreen->PositionWindow)(pWin, x, y);
+ WIN_WRAP(PositionWindow, winPositionWindowMultiWindow);
+
+#if CYGWINDOWING_DEBUG
+ ErrorF ("winPositionWindowMultiWindow: (x, y) = (%d, %d)\n",
+ x, y);
+#endif
+
+ /* Bail out if the Windows window handle is bad */
+ if (!hWnd)
+ {
+#if CYGWINDOWING_DEBUG
+ ErrorF ("\timmediately return since hWnd is NULL\n");
+#endif
+ return fResult;
+ }
+
+ /* Get the Windows window style and extended style */
+ dwExStyle = GetWindowLongPtr (hWnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr (hWnd, GWL_STYLE);
+
+ /* Get the X and Y location of the X window */
+ iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
+ iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* Get the height and width of the X window */
+ iWidth = pWin->drawable.width;
+ iHeight = pWin->drawable.height;
+
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight);
+
+#if CYGMULTIWINDOW_DEBUG
+ lpRc = &rcNew;
+ ErrorF ("winPositionWindowMultiWindow - (%d ms)drawable (%d, %d)-(%d, %d)\n",
+ GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
+#endif
+
+ /*
+ * Calculate the required size of the Windows window rectangle,
+ * given the size of the Windows window client area.
+ */
+ AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle);
+
+ /* Get a rectangle describing the old Windows window */
+ GetWindowRect (hWnd, &rcOld);
+
+#if CYGMULTIWINDOW_DEBUG
+ /* Get a rectangle describing the Windows window client area */
+ GetClientRect (hWnd, &rcClient);
+
+ lpRc = &rcNew;
+ ErrorF ("winPositionWindowMultiWindow - (%d ms)rcNew (%d, %d)-(%d, %d)\n",
+ GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
+
+ lpRc = &rcOld;
+ ErrorF ("winPositionWindowMultiWindow - (%d ms)rcOld (%d, %d)-(%d, %d)\n",
+ GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
+
+ lpRc = &rcClient;
+ ErrorF ("(%d ms)rcClient (%d, %d)-(%d, %d)\n",
+ GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
+#endif
+
+ /* Check if the old rectangle and new rectangle are the same */
+ if (!EqualRect (&rcNew, &rcOld))
+ {
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winPositionWindowMultiWindow - Need to move\n");
+#endif
+
+#if CYGWINDOWING_DEBUG
+ ErrorF ("\tMoveWindow to (%ld, %ld) - %ldx%ld\n", rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+#endif
+ /* Change the position and dimensions of the Windows window */
+ MoveWindow (hWnd,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ TRUE);
+ }
+ else
+ {
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winPositionWindowMultiWindow - Not need to move\n");
+#endif
+ }
+
+ return fResult;
+}
+
+
+/*
+ * ChangeWindowAttributes - See Porting Layer Definition - p. 37
+ */
+
+Bool
+winChangeWindowAttributesMultiWindow (WindowPtr pWin, unsigned long mask)
+{
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winChangeWindowAttributesMultiWindow - pWin: %08x\n", pWin);
+#endif
+
+ WIN_UNWRAP(ChangeWindowAttributes);
+ fResult = (*pScreen->ChangeWindowAttributes)(pWin, mask);
+ WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesMultiWindow);
+
+ /*
+ * NOTE: We do not currently need to do anything here.
+ */
+
+ return fResult;
+}
+
+
+/*
+ * UnmapWindow - See Porting Layer Definition - p. 37
+ * Also referred to as UnrealizeWindow
+ */
+
+Bool
+winUnmapWindowMultiWindow (WindowPtr pWin)
+{
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winUnmapWindowMultiWindow - pWin: %08x\n", pWin);
+#endif
+
+ WIN_UNWRAP(UnrealizeWindow);
+ fResult = (*pScreen->UnrealizeWindow)(pWin);
+ WIN_WRAP(UnrealizeWindow, winUnmapWindowMultiWindow);
+
+ /* Flag that the window has been killed */
+ pWinPriv->fXKilled = TRUE;
+
+ /* Destroy the Windows window associated with this X window */
+ winDestroyWindowsWindow (pWin);
+
+ return fResult;
+}
+
+
+/*
+ * MapWindow - See Porting Layer Definition - p. 37
+ * Also referred to as RealizeWindow
+ */
+
+Bool
+winMapWindowMultiWindow (WindowPtr pWin)
+{
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winMapWindowMultiWindow - pWin: %08x\n", pWin);
+#endif
+
+ WIN_UNWRAP(RealizeWindow);
+ fResult = (*pScreen->RealizeWindow)(pWin);
+ WIN_WRAP(RealizeWindow, winMapWindowMultiWindow);
+
+ /* Flag that this window has not been destroyed */
+ pWinPriv->fXKilled = FALSE;
+
+ /* Refresh/redisplay the Windows window associated with this X window */
+ winUpdateWindowsWindow (pWin);
+
+#ifdef SHAPE
+ /* Update the Windows window's shape */
+ winReshapeMultiWindow (pWin);
+ winUpdateRgnMultiWindow (pWin);
+#endif
+
+ return fResult;
+}
+
+
+/*
+ * ReparentWindow - See Porting Layer Definition - p. 42
+ */
+
+void
+winReparentWindowMultiWindow (WindowPtr pWin, WindowPtr pPriorParent)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winReparentMultiWindow - pWin: %08x\n", pWin);
+#endif
+
+ WIN_UNWRAP(ReparentWindow);
+ if (pScreen->ReparentWindow)
+ (*pScreen->ReparentWindow)(pWin, pPriorParent);
+ WIN_WRAP(ReparentWindow, winReparentWindowMultiWindow);
+
+ /* Update the Windows window associated with this X window */
+ winUpdateWindowsWindow (pWin);
+}
+
+
+/*
+ * RestackWindow - Shuffle the z-order of a window
+ */
+
+void
+winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib)
+{
+ WindowPtr pPrevWin;
+ UINT uFlags;
+ HWND hInsertAfter;
+ HWND hWnd = NULL;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG
+ winTrace ("winRestackMultiWindow - %08x\n", pWin);
+#endif
+
+ WIN_UNWRAP(RestackWindow);
+ if (pScreen->RestackWindow)
+ (*pScreen->RestackWindow)(pWin, pOldNextSib);
+ WIN_WRAP(RestackWindow, winRestackWindowMultiWindow);
+
+#if 1
+ /*
+ * Calling winReorderWindowsMultiWindow here means our window manager
+ * (i.e. Windows Explorer) has initiative to determine Z order.
+ */
+ if (pWin->nextSib != pOldNextSib)
+ winReorderWindowsMultiWindow ();
+#else
+ /* Bail out if no window privates or window handle is invalid */
+ if (!pWinPriv || !pWinPriv->hWnd)
+ return;
+
+ /* Get a pointer to our previous sibling window */
+ pPrevWin = pWin->prevSib;
+
+ /*
+ * Look for a sibling window with
+ * valid privates and window handle
+ */
+ while (pPrevWin
+ && !winGetWindowPriv(pPrevWin)
+ && !winGetWindowPriv(pPrevWin)->hWnd)
+ pPrevWin = pPrevWin->prevSib;
+
+ /* Check if we found a valid sibling */
+ if (pPrevWin)
+ {
+ /* Valid sibling - get handle to insert window after */
+ hInsertAfter = winGetWindowPriv(pPrevWin)->hWnd;
+ uFlags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE;
+
+ hWnd = GetNextWindow (pWinPriv->hWnd, GW_HWNDPREV);
+
+ do
+ {
+ if (GetProp (hWnd, WIN_WINDOW_PROP))
+ {
+ if (hWnd == winGetWindowPriv(pPrevWin)->hWnd)
+ {
+ uFlags |= SWP_NOZORDER;
+ }
+ break;
+ }
+ hWnd = GetNextWindow (hWnd, GW_HWNDPREV);
+ }
+ while (hWnd);
+ }
+ else
+ {
+ /* No valid sibling - make this window the top window */
+ hInsertAfter = HWND_TOP;
+ uFlags = SWP_NOMOVE | SWP_NOSIZE;
+ }
+
+ /* Perform the restacking operation in Windows */
+ SetWindowPos (pWinPriv->hWnd,
+ hInsertAfter,
+ 0, 0,
+ 0, 0,
+ uFlags);
+#endif
+}
+
+
+/*
+ * winCreateWindowsWindow - Create a Windows window associated with an X window
+ */
+
+void
+winCreateWindowsWindow (WindowPtr pWin)
+{
+ int iX, iY;
+ int iWidth;
+ int iHeight;
+ HWND hWnd;
+ WNDCLASSEX wc;
+ winWindowPriv(pWin);
+ HICON hIcon;
+ HICON hIconSmall;
+#define CLASS_NAME_LENGTH 512
+ char pszClass[CLASS_NAME_LENGTH], pszWindowID[12];
+ char *res_name, *res_class, *res_role;
+ static int s_iWindowID = 0;
+ winPrivScreenPtr pScreenPriv = pWinPriv->pScreenPriv;
+ WinXSizeHints hints;
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winCreateWindowsWindow - pWin: %08x\n", pWin);
+#endif
+
+ iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
+ iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* Default positions if none specified */
+ if (!winMultiWindowGetWMNormalHints(pWin, &hints))
+ hints.flags = 0;
+ if ( !(hints.flags & (USPosition|PPosition)) &&
+ !winMultiWindowGetTransientFor (pWin, NULL) &&
+ !pWin->overrideRedirect )
+ {
+ iX = CW_USEDEFAULT;
+ iY = CW_USEDEFAULT;
+ }
+
+ iWidth = pWin->drawable.width;
+ iHeight = pWin->drawable.height;
+
+ winSelectIcons(pWin, &hIcon, &hIconSmall);
+
+ /* Set standard class name prefix so we can identify window easily */
+ strncpy (pszClass, WINDOW_CLASS_X, sizeof(pszClass));
+
+ if (winMultiWindowGetClassHint (pWin, &res_name, &res_class))
+ {
+ strncat (pszClass, "-", 1);
+ strncat (pszClass, res_name, CLASS_NAME_LENGTH - strlen (pszClass));
+ strncat (pszClass, "-", 1);
+ strncat (pszClass, res_class, CLASS_NAME_LENGTH - strlen (pszClass));
+
+ /* Check if a window class is provided by the WM_WINDOW_ROLE property,
+ * if not use the WM_CLASS information.
+ * For further information see:
+ * http://tronche.com/gui/x/icccm/sec-5.html
+ */
+ if (winMultiWindowGetWindowRole (pWin, &res_role) )
+ {
+ strcat (pszClass, "-");
+ strcat (pszClass, res_role);
+ free (res_role);
+ }
+
+ free (res_name);
+ free (res_class);
+ }
+
+ /* Add incrementing window ID to make unique class name */
+ snprintf (pszWindowID, sizeof(pszWindowID), "-%x", s_iWindowID++);
+ pszWindowID[sizeof(pszWindowID)-1] = 0;
+ strcat (pszClass, pszWindowID);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winCreateWindowsWindow - Creating class: %s\n", pszClass);
+#endif
+
+ /* Setup our window class */
+ wc.cbSize = sizeof(wc);
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = winTopLevelWindowProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = g_hInstance;
+ wc.hIcon = hIcon;
+ wc.hIconSm = hIconSmall;
+ wc.hCursor = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = pszClass;
+ RegisterClassEx (&wc);
+
+ /* Create the window */
+ /* Make it OVERLAPPED in create call since WS_POPUP doesn't support */
+ /* CW_USEDEFAULT, change back to popup after creation */
+ hWnd = CreateWindowExA (WS_EX_TOOLWINDOW, /* Extended styles */
+ pszClass, /* Class name */
+ WINDOW_TITLE_X, /* Window name */
+ WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
+ iX, /* Horizontal position */
+ iY, /* Vertical position */
+ iWidth, /* Right edge */
+ iHeight, /* Bottom edge */
+ (HWND) NULL, /* No parent or owner window */
+ (HMENU) NULL, /* No menu */
+ GetModuleHandle (NULL), /* Instance handle */
+ pWin); /* ScreenPrivates */
+ if (hWnd == NULL)
+ {
+ ErrorF ("winCreateWindowsWindow - CreateWindowExA () failed: %d\n",
+ (int) GetLastError ());
+ }
+
+ /* Change style back to popup, already placed... */
+ SetWindowLong (hWnd, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
+ SetWindowPos (hWnd, 0, 0, 0, 0, 0,
+ SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ /* Make sure it gets the proper system menu for a WS_POPUP, too */
+ GetSystemMenu (hWnd, TRUE);
+
+ pWinPriv->hWnd = hWnd;
+
+ /* Cause any .XWinrc menus to be added in main WNDPROC */
+ PostMessage (hWnd, WM_INIT_SYS_MENU, 0, 0);
+
+ SetProp (pWinPriv->hWnd, WIN_WID_PROP, (HANDLE) winGetWindowID(pWin));
+
+ /* Flag that this Windows window handles its own activation */
+ SetProp (pWinPriv->hWnd, WIN_NEEDMANAGE_PROP, (HANDLE) 0);
+
+ /* Call engine-specific create window procedure */
+ (*pScreenPriv->pwinFinishCreateWindowsWindow) (pWin);
+}
+
+
+Bool winInDestroyWindowsWindow = FALSE;
+/*
+ * winDestroyWindowsWindow - Destroy a Windows window associated
+ * with an X window
+ */
+static void
+winDestroyWindowsWindow (WindowPtr pWin)
+{
+ MSG msg;
+ winWindowPriv(pWin);
+ HICON hiconClass;
+ HICON hiconSmClass;
+ HMODULE hInstance;
+ int iReturn;
+ char pszClass[512];
+ BOOL oldstate = winInDestroyWindowsWindow;
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winDestroyWindowsWindow\n");
+#endif
+
+ /* Bail out if the Windows window handle is invalid */
+ if (pWinPriv->hWnd == NULL)
+ return;
+
+ winInDestroyWindowsWindow = TRUE;
+
+ /* Store the info we need to destroy after this window is gone */
+ hInstance = (HINSTANCE) GetClassLong (pWinPriv->hWnd, GCL_HMODULE);
+ hiconClass = (HICON) GetClassLong (pWinPriv->hWnd, GCL_HICON);
+ hiconSmClass = (HICON) GetClassLong (pWinPriv->hWnd, GCL_HICONSM);
+ iReturn = GetClassName (pWinPriv->hWnd, pszClass, 512);
+
+ SetProp (pWinPriv->hWnd, WIN_WINDOW_PROP, NULL);
+ /* Destroy the Windows window */
+ DestroyWindow (pWinPriv->hWnd);
+
+ /* Null our handle to the Window so referencing it will cause an error */
+ pWinPriv->hWnd = NULL;
+
+ /* Process all messages on our queue */
+ while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ if (g_hDlgDepthChange == 0 || !IsDialogMessage (g_hDlgDepthChange, &msg))
+ {
+ DispatchMessage (&msg);
+ }
+ }
+
+ /* Only if we were able to get the name */
+ if (iReturn)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winDestroyWindowsWindow - Unregistering %s: ", pszClass);
+#endif
+ iReturn = UnregisterClass (pszClass, hInstance);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winDestroyWindowsWindow - %d Deleting Icon: ", iReturn);
+#endif
+
+ winDestroyIcon(hiconClass);
+ winDestroyIcon(hiconSmClass);
+ }
+
+ winInDestroyWindowsWindow = oldstate;
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("-winDestroyWindowsWindow\n");
+#endif
+}
+
+
+/*
+ * winUpdateWindowsWindow - Redisplay/redraw a Windows window
+ * associated with an X window
+ */
+
+static void
+winUpdateWindowsWindow (WindowPtr pWin)
+{
+ winWindowPriv(pWin);
+ HWND hWnd = pWinPriv->hWnd;
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winUpdateWindowsWindow\n");
+#endif
+
+ /* Check if the Windows window's parents have been destroyed */
+ if (pWin->parent != NULL
+ && pWin->parent->parent == NULL
+ && pWin->mapped)
+ {
+ /* Create the Windows window if it has been destroyed */
+ if (hWnd == NULL)
+ {
+ winCreateWindowsWindow (pWin);
+ assert (pWinPriv->hWnd != NULL);
+ }
+
+ /* Display the window without activating it */
+ ShowWindow (pWinPriv->hWnd, SW_SHOWNOACTIVATE);
+
+ /* Send first paint message */
+ UpdateWindow (pWinPriv->hWnd);
+ }
+ else if (hWnd != NULL)
+ {
+ /* Destroy the Windows window if its parents are destroyed */
+ winDestroyWindowsWindow (pWin);
+ assert (pWinPriv->hWnd == NULL);
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("-winUpdateWindowsWindow\n");
+#endif
+}
+
+
+/*
+ * winGetWindowID -
+ */
+
+XID
+winGetWindowID (WindowPtr pWin)
+{
+ WindowIDPairRec wi = {pWin, 0};
+ ClientPtr c = wClient(pWin);
+
+ /* */
+ FindClientResourcesByType (c, RT_WINDOW, winFindWindow, &wi);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winGetWindowID - Window ID: %d\n", wi.id);
+#endif
+
+ return wi.id;
+}
+
+
+/*
+ * winFindWindow -
+ */
+
+static void
+winFindWindow (pointer value, XID id, pointer cdata)
+{
+ WindowIDPairPtr wi = (WindowIDPairPtr)cdata;
+
+ if (value == wi->value)
+ {
+ wi->id = id;
+ }
+}
+
+
+/*
+ * winReorderWindowsMultiWindow -
+ */
+
+void
+winReorderWindowsMultiWindow (void)
+{
+ HWND hwnd = NULL;
+ WindowPtr pWin = NULL;
+ WindowPtr pWinSib = NULL;
+ XID vlist[2];
+ static Bool fRestacking = FALSE; /* Avoid recusive calls to this function */
+ DWORD dwCurrentProcessID = GetCurrentProcessId ();
+ DWORD dwWindowProcessID = 0;
+
+#if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG
+ winTrace ("winReorderWindowsMultiWindow\n");
+#endif
+
+ if (fRestacking)
+ {
+ /* It is a recusive call so immediately exit */
+#if CYGWINDOWING_DEBUG
+ ErrorF ("winReorderWindowsMultiWindow - "
+ "exit because fRestacking == TRUE\n");
+#endif
+ return;
+ }
+ fRestacking = TRUE;
+
+ /* Loop through top level Window windows, descending in Z order */
+ for ( hwnd = GetTopWindow (NULL);
+ hwnd;
+ hwnd = GetNextWindow (hwnd, GW_HWNDNEXT) )
+ {
+ /* Don't take care of other Cygwin/X process's windows */
+ GetWindowThreadProcessId (hwnd, &dwWindowProcessID);
+
+ if ( GetProp (hwnd, WIN_WINDOW_PROP)
+ && (dwWindowProcessID == dwCurrentProcessID)
+ && !IsIconic (hwnd) ) /* ignore minimized windows */
+ {
+ pWinSib = pWin;
+ pWin = GetProp (hwnd, WIN_WINDOW_PROP);
+
+ if (!pWinSib)
+ { /* 1st window - raise to the top */
+ vlist[0] = Above;
+
+ ConfigureWindow (pWin, CWStackMode, vlist, wClient(pWin));
+ }
+ else
+ { /* 2nd or deeper windows - just below the previous one */
+ vlist[0] = winGetWindowID (pWinSib);
+ vlist[1] = Below;
+
+ ConfigureWindow (pWin, CWSibling | CWStackMode,
+ vlist, wClient(pWin));
+ }
+ }
+ }
+
+ fRestacking = FALSE;
+}
+
+
+/*
+ * winMinimizeWindow - Minimize in response to WM_CHANGE_STATE
+ */
+
+void
+winMinimizeWindow (Window id)
+{
+ WindowPtr pWin;
+ winPrivWinPtr pWinPriv;
+#ifdef XWIN_MULTIWINDOWEXTWM
+ win32RootlessWindowPtr pRLWinPriv;
+#endif
+ HWND hWnd;
+ ScreenPtr pScreen = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+
+#if CYGWINDOWING_DEBUG
+ ErrorF ("winMinimizeWindow\n");
+#endif
+
+ pWin = LookupIDByType (id, RT_WINDOW);
+ if (!pWin)
+ {
+ ErrorF("%s: NULL pWin. Leaving\n", __FUNCTION__);
+ return;
+ }
+
+ pScreen = pWin->drawable.pScreen;
+ if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
+ if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ if (pScreenPriv && pScreenInfo->fInternalWM)
+ {
+ pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
+ hWnd = pRLWinPriv->hWnd;
+ }
+ else
+#else
+ if (pScreenPriv)
+#endif
+ {
+ pWinPriv = winGetWindowPriv (pWin);
+ hWnd = pWinPriv->hWnd;
+ }
+
+ ShowWindow (hWnd, SW_MINIMIZE);
+}
+
+
+/*
+ * CopyWindow - See Porting Layer Definition - p. 39
+ */
+void
+winCopyWindowMultiWindow (WindowPtr pWin, DDXPointRec oldpt,
+ RegionPtr oldRegion)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGWINDOWING_DEBUG
+ ErrorF ("CopyWindowMultiWindow\n");
+#endif
+ WIN_UNWRAP(CopyWindow);
+ (*pScreen->CopyWindow)(pWin, oldpt, oldRegion);
+ WIN_WRAP(CopyWindow, winCopyWindowMultiWindow);
+}
+
+
+/*
+ * MoveWindow - See Porting Layer Definition - p. 42
+ */
+void
+winMoveWindowMultiWindow (WindowPtr pWin, int x, int y,
+ WindowPtr pSib, VTKind kind)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGWINDOWING_DEBUG
+ ErrorF ("MoveWindowMultiWindow to (%d, %d)\n", x, y);
+#endif
+
+ WIN_UNWRAP(MoveWindow);
+ (*pScreen->MoveWindow)(pWin, x, y, pSib, kind);
+ WIN_WRAP(MoveWindow, winMoveWindowMultiWindow);
+}
+
+
+/*
+ * ResizeWindow - See Porting Layer Definition - p. 42
+ */
+void
+winResizeWindowMultiWindow (WindowPtr pWin, int x, int y, unsigned int w,
+ unsigned int h, WindowPtr pSib)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGWINDOWING_DEBUG
+ ErrorF ("ResizeWindowMultiWindow to (%d, %d) - %dx%d\n", x, y, w, h);
+#endif
+ WIN_UNWRAP(ResizeWindow);
+ (*pScreen->ResizeWindow)(pWin, x, y, w, h, pSib);
+ WIN_WRAP(ResizeWindow, winResizeWindowMultiWindow);
+}
+
+
+/*
+ * winAdjustXWindow
+ *
+ * Move and resize X window with respect to corresponding Windows window.
+ * This is called from WM_MOVE/WM_SIZE handlers when the user performs
+ * any windowing operation (move, resize, minimize, maximize, restore).
+ *
+ * The functionality is the inverse of winPositionWindowMultiWindow, which
+ * adjusts Windows window with respect to X window.
+ */
+int
+winAdjustXWindow (WindowPtr pWin, HWND hwnd)
+{
+ RECT rcDraw; /* Rect made from pWin->drawable to be adjusted */
+ RECT rcWin; /* The source: WindowRect from hwnd */
+ DrawablePtr pDraw;
+ XID vlist[4];
+ LONG dX, dY, dW, dH, x, y;
+ DWORD dwStyle, dwExStyle;
+
+#define WIDTH(rc) (rc.right - rc.left)
+#define HEIGHT(rc) (rc.bottom - rc.top)
+
+#if CYGWINDOWING_DEBUG
+ ErrorF ("winAdjustXWindow\n");
+#endif
+
+ if (IsIconic (hwnd))
+ {
+#if CYGWINDOWING_DEBUG
+ ErrorF ("\timmediately return because the window is iconized\n");
+#endif
+ /*
+ * If the Windows window is minimized, its WindowRect has
+ * meaningless values so we don't adjust X window to it.
+ * Instead we put the X window to the bottom in Z order to
+ * be obscured by other windows.
+ */
+ vlist[0] = Below;
+ return ConfigureWindow (pWin, CWStackMode, vlist, wClient(pWin));
+ }
+
+ pDraw = &pWin->drawable;
+
+ /* Calculate the window rect from the drawable */
+ x = pDraw->x + GetSystemMetrics (SM_XVIRTUALSCREEN);
+ y = pDraw->y + GetSystemMetrics (SM_YVIRTUALSCREEN);
+ SetRect (&rcDraw, x, y, x + pDraw->width, y + pDraw->height);
+#ifdef CYGMULTIWINDOW_DEBUG
+ winDebug("\tDrawable extend {%d, %d, %d, %d}, {%d, %d}\n",
+ rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom,
+ rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top);
+#endif
+ dwExStyle = GetWindowLongPtr (hwnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr (hwnd, GWL_STYLE);
+#ifdef CYGMULTIWINDOW_DEBUG
+ winDebug("\tWindowStyle: %08x %08x\n", dwStyle, dwExStyle);
+#endif
+ AdjustWindowRectEx (&rcDraw, dwStyle, FALSE, dwExStyle);
+
+ /* The source of adjust */
+ GetWindowRect (hwnd, &rcWin);
+#ifdef CYGMULTIWINDOW_DEBUG
+ winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n",
+ rcWin.left, rcWin.top, rcWin.right, rcWin.bottom,
+ rcWin.right - rcWin.left, rcWin.bottom - rcWin.top);
+ winDebug("\tDraw extend {%d, %d, %d, %d}, {%d, %d}\n",
+ rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom,
+ rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top);
+#endif
+
+ if (EqualRect (&rcDraw, &rcWin)) {
+ /* Bail if no adjust is needed */
+#if CYGWINDOWING_DEBUG
+ ErrorF ("\treturn because already adjusted\n");
+#endif
+ return 0;
+ }
+
+ /* Calculate delta values */
+ dX = rcWin.left - rcDraw.left;
+ dY = rcWin.top - rcDraw.top;
+ dW = WIDTH(rcWin) - WIDTH(rcDraw);
+ dH = HEIGHT(rcWin) - HEIGHT(rcDraw);
+
+ /*
+ * Adjust.
+ * We may only need to move (vlist[0] and [1]), or only resize
+ * ([2] and [3]) but currently we set all the parameters and leave
+ * the decision to ConfigureWindow. The reason is code simplicity.
+ */
+ vlist[0] = pDraw->x + dX - wBorderWidth(pWin);
+ vlist[1] = pDraw->y + dY - wBorderWidth(pWin);
+ vlist[2] = pDraw->width + dW;
+ vlist[3] = pDraw->height + dH;
+#if CYGWINDOWING_DEBUG
+ ErrorF ("\tConfigureWindow to (%ld, %ld) - %ldx%ld\n", vlist[0], vlist[1],
+ vlist[2], vlist[3]);
+#endif
+ return ConfigureWindow (pWin, CWX | CWY | CWWidth | CWHeight,
+ vlist, wClient(pWin));
+
+#undef WIDTH
+#undef HEIGHT
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xwin/winmultiwindowwm.c b/nx-X11/programs/Xserver/hw/xwin/winmultiwindowwm.c
new file mode 100644
index 000000000..03f179345
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winmultiwindowwm.c
@@ -0,0 +1,1444 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Kensuke Matsuzaki
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winwindow.c,v 1.5 2002/11/07 10:31:32 alanh Exp $ */
+
+/* X headers */
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#ifdef __CYGWIN__
+#include <sys/select.h>
+#endif
+#include <fcntl.h>
+#include <setjmp.h>
+#define HANDLE void *
+#include <pthread.h>
+#undef HANDLE
+#include <X11/X.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <X11/Xlocale.h>
+#include <X11/Xproto.h>
+#include <X11/Xutil.h>
+#include <X11/cursorfont.h>
+
+/* Windows headers */
+#ifdef __CYGWIN__
+/* Fixups to prevent collisions between Windows and X headers */
+#define ATOM DWORD
+
+#include <windows.h>
+#else
+#include <Xwindows.h>
+#endif
+
+/* Local headers */
+#include "objbase.h"
+#include "ddraw.h"
+#include "winwindow.h"
+#ifdef XWIN_MULTIWINDOWEXTWM
+#include "windowswmstr.h"
+#endif
+
+extern void winDebug(const char *format, ...);
+
+#ifndef CYGDEBUG
+#define CYGDEBUG NO
+#endif
+
+/*
+ * Constant defines
+ */
+
+#define WIN_CONNECT_RETRIES 5
+#define WIN_CONNECT_DELAY 5
+#ifdef HAS_DEVWINDOWS
+# define WIN_MSG_QUEUE_FNAME "/dev/windows"
+#endif
+#define WIN_JMP_OKAY 0
+#define WIN_JMP_ERROR_IO 2
+
+
+/*
+ * Local structures
+ */
+
+typedef struct _WMMsgNodeRec {
+ winWMMessageRec msg;
+ struct _WMMsgNodeRec *pNext;
+} WMMsgNodeRec, *WMMsgNodePtr;
+
+typedef struct _WMMsgQueueRec {
+ struct _WMMsgNodeRec *pHead;
+ struct _WMMsgNodeRec *pTail;
+ pthread_mutex_t pmMutex;
+ pthread_cond_t pcNotEmpty;
+ int nQueueSize;
+} WMMsgQueueRec, *WMMsgQueuePtr;
+
+typedef struct _WMInfo {
+ Display *pDisplay;
+ WMMsgQueueRec wmMsgQueue;
+ Atom atmWmProtos;
+ Atom atmWmDelete;
+ Atom atmPrivMap;
+ Bool fAllowOtherWM;
+} WMInfoRec, *WMInfoPtr;
+
+typedef struct _WMProcArgRec {
+ DWORD dwScreen;
+ WMInfoPtr pWMInfo;
+ pthread_mutex_t *ppmServerStarted;
+} WMProcArgRec, *WMProcArgPtr;
+
+typedef struct _XMsgProcArgRec {
+ Display *pDisplay;
+ DWORD dwScreen;
+ WMInfoPtr pWMInfo;
+ pthread_mutex_t *ppmServerStarted;
+ HWND hwndScreen;
+} XMsgProcArgRec, *XMsgProcArgPtr;
+
+
+/*
+ * References to external symbols
+ */
+
+extern char *display;
+extern void ErrorF (const char* /*f*/, ...);
+
+
+/*
+ * Prototypes for local functions
+ */
+
+static void
+PushMessage (WMMsgQueuePtr pQueue, WMMsgNodePtr pNode);
+
+static WMMsgNodePtr
+PopMessage (WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo);
+
+static Bool
+InitQueue (WMMsgQueuePtr pQueue);
+
+static void
+GetWindowName (Display * pDpy, Window iWin, char **ppName);
+
+static int
+SendXMessage (Display *pDisplay, Window iWin, Atom atmType, long nData);
+
+static void
+UpdateName (WMInfoPtr pWMInfo, Window iWindow);
+
+static void*
+winMultiWindowWMProc (void* pArg);
+
+static int
+winMultiWindowWMErrorHandler (Display *pDisplay, XErrorEvent *pErr);
+
+static int
+winMultiWindowWMIOErrorHandler (Display *pDisplay);
+
+static void *
+winMultiWindowXMsgProc (void *pArg);
+
+static int
+winMultiWindowXMsgProcErrorHandler (Display *pDisplay, XErrorEvent *pErr);
+
+static int
+winMultiWindowXMsgProcIOErrorHandler (Display *pDisplay);
+
+static int
+winRedirectErrorHandler (Display *pDisplay, XErrorEvent *pErr);
+
+static void
+winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg);
+
+#if 0
+static void
+PreserveWin32Stack(WMInfoPtr pWMInfo, Window iWindow, UINT direction);
+#endif
+
+static Bool
+CheckAnotherWindowManager (Display *pDisplay, DWORD dwScreen);
+
+
+/*
+ * Local globals
+ */
+
+static jmp_buf g_jmpWMEntry;
+static jmp_buf g_jmpXMsgProcEntry;
+static Bool g_shutdown = FALSE;
+static Bool redirectError = FALSE;
+static Bool g_fAnotherWMRunnig = FALSE;
+
+/*
+ * PushMessage - Push a message onto the queue
+ */
+
+static void
+PushMessage (WMMsgQueuePtr pQueue, WMMsgNodePtr pNode)
+{
+
+ /* Lock the queue mutex */
+ pthread_mutex_lock (&pQueue->pmMutex);
+
+ pNode->pNext = NULL;
+
+ if (pQueue->pTail != NULL)
+ {
+ pQueue->pTail->pNext = pNode;
+ }
+ pQueue->pTail = pNode;
+
+ if (pQueue->pHead == NULL)
+ {
+ pQueue->pHead = pNode;
+ }
+
+
+#if 0
+ switch (pNode->msg.msg)
+ {
+ case WM_WM_MOVE:
+ ErrorF ("\tWM_WM_MOVE\n");
+ break;
+ case WM_WM_SIZE:
+ ErrorF ("\tWM_WM_SIZE\n");
+ break;
+ case WM_WM_RAISE:
+ ErrorF ("\tWM_WM_RAISE\n");
+ break;
+ case WM_WM_LOWER:
+ ErrorF ("\tWM_WM_LOWER\n");
+ break;
+ case WM_WM_MAP:
+ ErrorF ("\tWM_WM_MAP\n");
+ break;
+ case WM_WM_UNMAP:
+ ErrorF ("\tWM_WM_UNMAP\n");
+ break;
+ case WM_WM_KILL:
+ ErrorF ("\tWM_WM_KILL\n");
+ break;
+ case WM_WM_ACTIVATE:
+ ErrorF ("\tWM_WM_ACTIVATE\n");
+ break;
+ default:
+ ErrorF ("\tUnknown Message.\n");
+ break;
+ }
+#endif
+
+ /* Increase the count of elements in the queue by one */
+ ++(pQueue->nQueueSize);
+
+ /* Release the queue mutex */
+ pthread_mutex_unlock (&pQueue->pmMutex);
+
+ /* Signal that the queue is not empty */
+ pthread_cond_signal (&pQueue->pcNotEmpty);
+}
+
+
+#if CYGMULTIWINDOW_DEBUG
+/*
+ * QueueSize - Return the size of the queue
+ */
+
+static int
+QueueSize (WMMsgQueuePtr pQueue)
+{
+ WMMsgNodePtr pNode;
+ int nSize = 0;
+
+ /* Loop through all elements in the queue */
+ for (pNode = pQueue->pHead; pNode != NULL; pNode = pNode->pNext)
+ ++nSize;
+
+ return nSize;
+}
+#endif
+
+
+/*
+ * PopMessage - Pop a message from the queue
+ */
+
+static WMMsgNodePtr
+PopMessage (WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo)
+{
+ WMMsgNodePtr pNode;
+
+ /* Lock the queue mutex */
+ pthread_mutex_lock (&pQueue->pmMutex);
+
+ /* Wait for --- */
+ while (pQueue->pHead == NULL)
+ {
+ pthread_cond_wait (&pQueue->pcNotEmpty, &pQueue->pmMutex);
+ }
+
+ pNode = pQueue->pHead;
+ if (pQueue->pHead != NULL)
+ {
+ pQueue->pHead = pQueue->pHead->pNext;
+ }
+
+ if (pQueue->pTail == pNode)
+ {
+ pQueue->pTail = NULL;
+ }
+
+ /* Drop the number of elements in the queue by one */
+ --(pQueue->nQueueSize);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("Queue Size %d %d\n", pQueue->nQueueSize, QueueSize(pQueue));
+#endif
+
+ /* Release the queue mutex */
+ pthread_mutex_unlock (&pQueue->pmMutex);
+
+ return pNode;
+}
+
+
+#if 0
+/*
+ * HaveMessage -
+ */
+
+static Bool
+HaveMessage (WMMsgQueuePtr pQueue, UINT msg, Window iWindow)
+{
+ WMMsgNodePtr pNode;
+
+ for (pNode = pQueue->pHead; pNode != NULL; pNode = pNode->pNext)
+ {
+ if (pNode->msg.msg==msg && pNode->msg.iWindow==iWindow)
+ return True;
+ }
+
+ return False;
+}
+#endif
+
+
+/*
+ * InitQueue - Initialize the Window Manager message queue
+ */
+
+static
+Bool
+InitQueue (WMMsgQueuePtr pQueue)
+{
+ /* Check if the pQueue pointer is NULL */
+ if (pQueue == NULL)
+ {
+ ErrorF ("InitQueue - pQueue is NULL. Exiting.\n");
+ return FALSE;
+ }
+
+ /* Set the head and tail to NULL */
+ pQueue->pHead = NULL;
+ pQueue->pTail = NULL;
+
+ /* There are no elements initially */
+ pQueue->nQueueSize = 0;
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("InitQueue - Queue Size %d %d\n", pQueue->nQueueSize,
+ QueueSize(pQueue));
+#endif
+
+ ErrorF ("InitQueue - Calling pthread_mutex_init\n");
+
+ /* Create synchronization objects */
+ pthread_mutex_init (&pQueue->pmMutex, NULL);
+
+ ErrorF ("InitQueue - pthread_mutex_init returned\n");
+ ErrorF ("InitQueue - Calling pthread_cond_init\n");
+
+ pthread_cond_init (&pQueue->pcNotEmpty, NULL);
+
+ ErrorF ("InitQueue - pthread_cond_init returned\n");
+
+ return TRUE;
+}
+
+
+/*
+ * GetWindowName - Retrieve the title of an X Window
+ */
+
+static void
+GetWindowName (Display *pDisplay, Window iWin, char **ppName)
+{
+ int nResult, nNum;
+ char **ppList;
+ XTextProperty xtpName;
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("GetWindowName\n");
+#endif
+
+ /* Intialize ppName to NULL */
+ *ppName = NULL;
+
+ /* Try to get --- */
+ nResult = XGetWMName (pDisplay, iWin, &xtpName);
+ if (!nResult || !xtpName.value || !xtpName.nitems)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("GetWindowName - XGetWMName failed. No name.\n");
+#endif
+ return;
+ }
+
+ /* */
+ if (xtpName.encoding == XA_STRING)
+ {
+ /* */
+ if (xtpName.value)
+ {
+ int size = xtpName.nitems * (xtpName.format >> 3);
+ *ppName = malloc(size + 1);
+ strncpy(*ppName, xtpName.value, size);
+ (*ppName)[size] = 0;
+ XFree (xtpName.value);
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("GetWindowName - XA_STRING %s\n", *ppName);
+#endif
+ }
+ else
+ {
+ XmbTextPropertyToTextList (pDisplay, &xtpName, &ppList, &nNum);
+
+ /* */
+ if (nNum && ppList && *ppList)
+ {
+ *ppName = strdup (*ppList);
+ XFreeStringList (ppList);
+ }
+ XFree (xtpName.value);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("GetWindowName - %s %s\n",
+ XGetAtomName (pDisplay, xtpName.encoding), *ppName);
+#endif
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("GetWindowName - Returning\n");
+#endif
+}
+
+
+/*
+ * Send a message to the X server from the WM thread
+ */
+
+static int
+SendXMessage (Display *pDisplay, Window iWin, Atom atmType, long nData)
+{
+ XEvent e;
+
+ /* Prepare the X event structure */
+ e.type = ClientMessage;
+ e.xclient.window = iWin;
+ e.xclient.message_type = atmType;
+ e.xclient.format = 32;
+ e.xclient.data.l[0] = nData;
+ e.xclient.data.l[1] = CurrentTime;
+
+ /* Send the event to X */
+ return XSendEvent (pDisplay, iWin, False, NoEventMask, &e);
+}
+
+
+/*
+ * Updates the name of a HWND according to its X WM_NAME property
+ */
+
+static void
+UpdateName (WMInfoPtr pWMInfo, Window iWindow)
+{
+ char *pszName;
+ Atom atmType;
+ int fmtRet;
+ unsigned long items, remain;
+ HWND *retHwnd, hWnd;
+ XWindowAttributes attr;
+
+ hWnd = 0;
+
+ /* See if we can get the cached HWND for this window... */
+ if (XGetWindowProperty (pWMInfo->pDisplay,
+ iWindow,
+ pWMInfo->atmPrivMap,
+ 0,
+ 1,
+ False,
+ XA_INTEGER,//pWMInfo->atmPrivMap,
+ &atmType,
+ &fmtRet,
+ &items,
+ &remain,
+ (unsigned char **) &retHwnd) == Success)
+ {
+ if (retHwnd)
+ {
+ hWnd = *retHwnd;
+ XFree (retHwnd);
+ }
+ }
+
+ /* Some sanity checks */
+ if (!hWnd) return;
+ if (!IsWindow (hWnd)) return;
+
+ /* Set the Windows window name */
+ GetWindowName (pWMInfo->pDisplay, iWindow, &pszName);
+ if (pszName)
+ {
+ /* Get the window attributes */
+ XGetWindowAttributes (pWMInfo->pDisplay,
+ iWindow,
+ &attr);
+ if (!attr.override_redirect)
+ {
+ SetWindowText (hWnd, pszName);
+ winUpdateIcon (iWindow);
+ }
+
+ free (pszName);
+ }
+}
+
+
+#if 0
+/*
+ * Fix up any differences between the X11 and Win32 window stacks
+ * starting at the window passed in
+ */
+static void
+PreserveWin32Stack(WMInfoPtr pWMInfo, Window iWindow, UINT direction)
+{
+ Atom atmType;
+ int fmtRet;
+ unsigned long items, remain;
+ HWND hWnd, *retHwnd;
+ DWORD myWinProcID, winProcID;
+ Window xWindow;
+ WINDOWPLACEMENT wndPlace;
+
+ hWnd = NULL;
+ /* See if we can get the cached HWND for this window... */
+ if (XGetWindowProperty (pWMInfo->pDisplay,
+ iWindow,
+ pWMInfo->atmPrivMap,
+ 0,
+ 1,
+ False,
+ XA_INTEGER,//pWMInfo->atmPrivMap,
+ &atmType,
+ &fmtRet,
+ &items,
+ &remain,
+ (unsigned char **) &retHwnd) == Success)
+ {
+ if (retHwnd)
+ {
+ hWnd = *retHwnd;
+ XFree (retHwnd);
+ }
+ }
+
+ if (!hWnd) return;
+
+ GetWindowThreadProcessId (hWnd, &myWinProcID);
+ hWnd = GetNextWindow (hWnd, direction);
+
+ while (hWnd) {
+ GetWindowThreadProcessId (hWnd, &winProcID);
+ if (winProcID == myWinProcID)
+ {
+ wndPlace.length = sizeof(WINDOWPLACEMENT);
+ GetWindowPlacement (hWnd, &wndPlace);
+ if ( !(wndPlace.showCmd==SW_HIDE ||
+ wndPlace.showCmd==SW_MINIMIZE) )
+ {
+ xWindow = (Window)GetProp (hWnd, WIN_WID_PROP);
+ if (xWindow)
+ {
+ if (direction==GW_HWNDPREV)
+ XRaiseWindow (pWMInfo->pDisplay, xWindow);
+ else
+ XLowerWindow (pWMInfo->pDisplay, xWindow);
+ }
+ }
+ }
+ hWnd = GetNextWindow(hWnd, direction);
+ }
+}
+#endif /* PreserveWin32Stack */
+
+
+/*
+ * winMultiWindowWMProc
+ */
+
+static void *
+winMultiWindowWMProc (void *pArg)
+{
+ WMProcArgPtr pProcArg = (WMProcArgPtr)pArg;
+ WMInfoPtr pWMInfo = pProcArg->pWMInfo;
+
+ /* Initialize the Window Manager */
+ winInitMultiWindowWM (pWMInfo, pProcArg);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winMultiWindowWMProc ()\n");
+#endif
+
+ /* Loop until we explicity break out */
+ for (;;)
+ {
+ WMMsgNodePtr pNode;
+
+ if(g_fAnotherWMRunnig)/* Another Window manager exists. */
+ {
+ Sleep (1000);
+ continue;
+ }
+
+ /* Pop a message off of our queue */
+ pNode = PopMessage (&pWMInfo->wmMsgQueue, pWMInfo);
+ if (pNode == NULL)
+ {
+ /* Bail if PopMessage returns without a message */
+ /* NOTE: Remember that PopMessage is a blocking function. */
+ ErrorF ("winMultiWindowWMProc - Queue is Empty? Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winMultiWindowWMProc - %d ms MSG: %d ID: %d\n",
+ GetTickCount (), (int)pNode->msg.msg, (int)pNode->msg.dwID);
+#endif
+
+ /* Branch on the message type */
+ switch (pNode->msg.msg)
+ {
+#if 0
+ case WM_WM_MOVE:
+ ErrorF ("\tWM_WM_MOVE\n");
+ break;
+
+ case WM_WM_SIZE:
+ ErrorF ("\tWM_WM_SIZE\n");
+ break;
+#endif
+
+ case WM_WM_RAISE:
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("\tWM_WM_RAISE\n");
+#endif
+ /* Raise the window */
+ XRaiseWindow (pWMInfo->pDisplay, pNode->msg.iWindow);
+#if 0
+ PreserveWin32Stack (pWMInfo, pNode->msg.iWindow, GW_HWNDPREV);
+#endif
+ break;
+
+ case WM_WM_LOWER:
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("\tWM_WM_LOWER\n");
+#endif
+
+ /* Lower the window */
+ XLowerWindow (pWMInfo->pDisplay, pNode->msg.iWindow);
+ break;
+
+ case WM_WM_MAP:
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("\tWM_WM_MAP\n");
+#endif
+ /* Put a note as to the HWND associated with this Window */
+ XChangeProperty (pWMInfo->pDisplay,
+ pNode->msg.iWindow,
+ pWMInfo->atmPrivMap,
+ XA_INTEGER,//pWMInfo->atmPrivMap,
+ 32,
+ PropModeReplace,
+ (unsigned char *) &(pNode->msg.hwndWindow),
+ 1);
+ UpdateName (pWMInfo, pNode->msg.iWindow);
+ winUpdateIcon (pNode->msg.iWindow);
+#if 0
+ /* Handles the case where there are AOT windows above it in W32 */
+ PreserveWin32Stack (pWMInfo, pNode->msg.iWindow, GW_HWNDPREV);
+#endif
+ break;
+
+ case WM_WM_UNMAP:
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("\tWM_WM_UNMAP\n");
+#endif
+
+ /* Unmap the window */
+ XUnmapWindow (pWMInfo->pDisplay, pNode->msg.iWindow);
+ break;
+
+ case WM_WM_KILL:
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("\tWM_WM_KILL\n");
+#endif
+ {
+ int i, n, found = 0;
+ Atom *protocols;
+
+ /* --- */
+ if (XGetWMProtocols (pWMInfo->pDisplay,
+ pNode->msg.iWindow,
+ &protocols,
+ &n))
+ {
+ for (i = 0; i < n; ++i)
+ if (protocols[i] == pWMInfo->atmWmDelete)
+ ++found;
+
+ XFree (protocols);
+ }
+
+ /* --- */
+ if (found)
+ SendXMessage (pWMInfo->pDisplay,
+ pNode->msg.iWindow,
+ pWMInfo->atmWmProtos,
+ pWMInfo->atmWmDelete);
+ else
+ XKillClient (pWMInfo->pDisplay,
+ pNode->msg.iWindow);
+ }
+ break;
+
+ case WM_WM_ACTIVATE:
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("\tWM_WM_ACTIVATE\n");
+#endif
+
+ /* Set the input focus */
+ XSetInputFocus (pWMInfo->pDisplay,
+ pNode->msg.iWindow,
+ RevertToPointerRoot,
+ CurrentTime);
+ break;
+
+ case WM_WM_NAME_EVENT:
+ UpdateName (pWMInfo, pNode->msg.iWindow);
+ break;
+
+ case WM_WM_HINTS_EVENT:
+ winUpdateIcon (pNode->msg.iWindow);
+ break;
+
+ case WM_WM_CHANGE_STATE:
+ /* Minimize the window in Windows */
+ winMinimizeWindow (pNode->msg.iWindow);
+ break;
+
+ default:
+ ErrorF ("winMultiWindowWMProc - Unknown Message. Exiting.\n");
+ pthread_exit (NULL);
+ break;
+ }
+
+ /* Free the retrieved message */
+ free (pNode);
+
+ /* Flush any pending events on our display */
+ XFlush (pWMInfo->pDisplay);
+ }
+
+ /* Free the condition variable */
+ pthread_cond_destroy (&pWMInfo->wmMsgQueue.pcNotEmpty);
+
+ /* Free the mutex variable */
+ pthread_mutex_destroy (&pWMInfo->wmMsgQueue.pmMutex);
+
+ /* Free the passed-in argument */
+ free (pProcArg);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF("-winMultiWindowWMProc ()\n");
+#endif
+}
+
+
+/*
+ * X message procedure
+ */
+
+static void *
+winMultiWindowXMsgProc (void *pArg)
+{
+ winWMMessageRec msg;
+ XMsgProcArgPtr pProcArg = (XMsgProcArgPtr) pArg;
+ char pszDisplay[512];
+ int iRetries;
+ XEvent event;
+ Atom atmWmName;
+ Atom atmWmHints;
+ Atom atmWmChange;
+ int iReturn;
+ XIconSize *xis;
+
+ ErrorF ("winMultiWindowXMsgProc - Hello\n");
+
+ /* Check that argument pointer is not invalid */
+ if (pProcArg == NULL)
+ {
+ ErrorF ("winMultiWindowXMsgProc - pProcArg is NULL. Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ ErrorF ("winMultiWindowXMsgProc - Calling pthread_mutex_lock ()\n");
+
+ /* Grab the server started mutex - pause until we get it */
+ iReturn = pthread_mutex_lock (pProcArg->ppmServerStarted);
+ if (iReturn != 0)
+ {
+ ErrorF ("winMultiWindowXMsgProc - pthread_mutex_lock () failed: %d. "
+ "Exiting.\n",
+ iReturn);
+ pthread_exit (NULL);
+ }
+
+ ErrorF ("winMultiWindowXMsgProc - pthread_mutex_lock () returned.\n");
+
+ /* Allow multiple threads to access Xlib */
+ if (XInitThreads () == 0)
+ {
+ ErrorF ("winMultiWindowXMsgProc - XInitThreads () failed. Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ /* See if X supports the current locale */
+ if (XSupportsLocale () == False)
+ {
+ ErrorF ("winMultiWindowXMsgProc - Locale not supported by X. "
+ "Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ /* Release the server started mutex */
+ pthread_mutex_unlock (pProcArg->ppmServerStarted);
+
+ ErrorF ("winMultiWindowXMsgProc - pthread_mutex_unlock () returned.\n");
+
+ /* Set jump point for IO Error exits */
+ iReturn = setjmp (g_jmpXMsgProcEntry);
+
+ /* Check if we should continue operations */
+ if (iReturn != WIN_JMP_ERROR_IO
+ && iReturn != WIN_JMP_OKAY)
+ {
+ /* setjmp returned an unknown value, exit */
+ ErrorF ("winInitMultiWindowXMsgProc - setjmp returned: %d. Exiting.\n",
+ iReturn);
+ pthread_exit (NULL);
+ }
+ else if (iReturn == WIN_JMP_ERROR_IO)
+ {
+ ErrorF ("winInitMultiWindowXMsgProc - Caught IO Error. Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ /* Install our error handler */
+ XSetErrorHandler (winMultiWindowXMsgProcErrorHandler);
+ XSetIOErrorHandler (winMultiWindowXMsgProcIOErrorHandler);
+
+ /* Setup the display connection string x */
+ snprintf (pszDisplay,
+ 512, "127.0.0.1:%s.%d", display, (int)pProcArg->dwScreen);
+
+ /* Print the display connection string */
+ ErrorF ("winMultiWindowXMsgProc - DISPLAY=%s\n", pszDisplay);
+
+ /* Initialize retry count */
+ iRetries = 0;
+
+ /* Open the X display */
+ do
+ {
+ /* Try to open the display */
+ pProcArg->pDisplay = XOpenDisplay (pszDisplay);
+ if (pProcArg->pDisplay == NULL)
+ {
+ ErrorF ("winMultiWindowXMsgProc - Could not open display, try: %d, "
+ "sleeping: %d\n\f",
+ iRetries + 1, WIN_CONNECT_DELAY);
+ ++iRetries;
+ sleep (WIN_CONNECT_DELAY);
+ continue;
+ }
+ else
+ break;
+ }
+ while (pProcArg->pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES);
+
+ /* Make sure that the display opened */
+ if (pProcArg->pDisplay == NULL)
+ {
+ ErrorF ("winMultiWindowXMsgProc - Failed opening the display. "
+ "Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ ErrorF ("winMultiWindowXMsgProc - XOpenDisplay () returned and "
+ "successfully opened the display.\n");
+
+ /* Check if another window manager is already running */
+ if (pProcArg->pWMInfo->fAllowOtherWM)
+ {
+ g_fAnotherWMRunnig = CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen);
+ } else {
+ redirectError = FALSE;
+ XSetErrorHandler (winRedirectErrorHandler);
+ XSelectInput(pProcArg->pDisplay,
+ RootWindow (pProcArg->pDisplay, pProcArg->dwScreen),
+ SubstructureNotifyMask | ButtonPressMask);
+ XSync (pProcArg->pDisplay, 0);
+ XSetErrorHandler (winMultiWindowXMsgProcErrorHandler);
+ if (redirectError)
+ {
+ ErrorF ("winMultiWindowXMsgProc - "
+ "another window manager is running. Exiting.\n");
+ pthread_exit (NULL);
+ }
+ g_fAnotherWMRunnig = FALSE;
+ }
+
+ /* Set up the supported icon sizes */
+ xis = XAllocIconSize ();
+ if (xis)
+ {
+ xis->min_width = xis->min_height = 16;
+ xis->max_width = xis->max_height = 48;
+ xis->width_inc = xis->height_inc = 16;
+ XSetIconSizes (pProcArg->pDisplay,
+ RootWindow (pProcArg->pDisplay, pProcArg->dwScreen),
+ xis,
+ 1);
+ XFree (xis);
+ }
+
+ atmWmName = XInternAtom (pProcArg->pDisplay,
+ "WM_NAME",
+ False);
+ atmWmHints = XInternAtom (pProcArg->pDisplay,
+ "WM_HINTS",
+ False);
+ atmWmChange = XInternAtom (pProcArg->pDisplay,
+ "WM_CHANGE_STATE",
+ False);
+
+ /* Loop until we explicitly break out */
+ while (1)
+ {
+ if (g_shutdown)
+ break;
+
+ if (pProcArg->pWMInfo->fAllowOtherWM && !XPending (pProcArg->pDisplay))
+ {
+ if (CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen))
+ {
+ if (!g_fAnotherWMRunnig)
+ {
+ g_fAnotherWMRunnig = TRUE;
+ SendMessage(*(HWND*)pProcArg->hwndScreen, WM_UNMANAGE, 0, 0);
+ }
+ }
+ else
+ {
+ if (g_fAnotherWMRunnig)
+ {
+ g_fAnotherWMRunnig = FALSE;
+ SendMessage(*(HWND*)pProcArg->hwndScreen, WM_MANAGE, 0, 0);
+ }
+ }
+ Sleep (500);
+ continue;
+ }
+
+ /* Fetch next event */
+ XNextEvent (pProcArg->pDisplay, &event);
+
+ /* Branch on event type */
+ if (event.type == CreateNotify)
+ {
+ XWindowAttributes attr;
+
+ XSelectInput (pProcArg->pDisplay,
+ event.xcreatewindow.window,
+ PropertyChangeMask);
+
+ /* Get the window attributes */
+ XGetWindowAttributes (pProcArg->pDisplay,
+ event.xcreatewindow.window,
+ &attr);
+
+ if (!attr.override_redirect)
+ XSetWindowBorderWidth(pProcArg->pDisplay,
+ event.xcreatewindow.window,
+ 0);
+ }
+ else if (event.type == PropertyNotify
+ && event.xproperty.atom == atmWmName)
+ {
+ memset (&msg, 0, sizeof (msg));
+
+ msg.msg = WM_WM_NAME_EVENT;
+ msg.iWindow = event.xproperty.window;
+
+ /* Other fields ignored */
+ winSendMessageToWM (pProcArg->pWMInfo, &msg);
+ }
+ else if (event.type == PropertyNotify
+ && event.xproperty.atom == atmWmHints)
+ {
+ memset (&msg, 0, sizeof (msg));
+
+ msg.msg = WM_WM_HINTS_EVENT;
+ msg.iWindow = event.xproperty.window;
+
+ /* Other fields ignored */
+ winSendMessageToWM (pProcArg->pWMInfo, &msg);
+ }
+ else if (event.type == ClientMessage
+ && event.xclient.message_type == atmWmChange
+ && event.xclient.data.l[0] == IconicState)
+ {
+ ErrorF ("winMultiWindowXMsgProc - WM_CHANGE_STATE - IconicState\n");
+
+ memset (&msg, 0, sizeof (msg));
+
+ msg.msg = WM_WM_CHANGE_STATE;
+ msg.iWindow = event.xclient.window;
+
+ winSendMessageToWM (pProcArg->pWMInfo, &msg);
+ }
+ }
+
+ XCloseDisplay (pProcArg->pDisplay);
+ pthread_exit (NULL);
+
+}
+
+
+/*
+ * winInitWM - Entry point for the X server to spawn
+ * the Window Manager thread. Called from
+ * winscrinit.c/winFinishScreenInitFB ().
+ */
+
+Bool
+winInitWM (void **ppWMInfo,
+ pthread_t *ptWMProc,
+ pthread_t *ptXMsgProc,
+ pthread_mutex_t *ppmServerStarted,
+ int dwScreen,
+ HWND hwndScreen,
+ BOOL allowOtherWM)
+{
+ WMProcArgPtr pArg = (WMProcArgPtr) malloc (sizeof(WMProcArgRec));
+ WMInfoPtr pWMInfo = (WMInfoPtr) malloc (sizeof(WMInfoRec));
+ XMsgProcArgPtr pXMsgArg = (XMsgProcArgPtr) malloc (sizeof(XMsgProcArgRec));
+
+ /* Bail if the input parameters are bad */
+ if (pArg == NULL || pWMInfo == NULL)
+ {
+ ErrorF ("winInitWM - malloc failed.\n");
+ return FALSE;
+ }
+
+ /* Zero the allocated memory */
+ ZeroMemory (pArg, sizeof (WMProcArgRec));
+ ZeroMemory (pWMInfo, sizeof (WMInfoRec));
+ ZeroMemory (pXMsgArg, sizeof (XMsgProcArgRec));
+
+ /* Set a return pointer to the Window Manager info structure */
+ *ppWMInfo = pWMInfo;
+ pWMInfo->fAllowOtherWM = allowOtherWM;
+
+ /* Setup the argument structure for the thread function */
+ pArg->dwScreen = dwScreen;
+ pArg->pWMInfo = pWMInfo;
+ pArg->ppmServerStarted = ppmServerStarted;
+
+ /* Intialize the message queue */
+ if (!InitQueue (&pWMInfo->wmMsgQueue))
+ {
+ ErrorF ("winInitWM - InitQueue () failed.\n");
+ return FALSE;
+ }
+
+ /* Spawn a thread for the Window Manager */
+ if (pthread_create (ptWMProc, NULL, winMultiWindowWMProc, pArg))
+ {
+ /* Bail if thread creation failed */
+ ErrorF ("winInitWM - pthread_create failed for Window Manager.\n");
+ return FALSE;
+ }
+
+ /* Spawn the XNextEvent thread, will send messages to WM */
+ pXMsgArg->dwScreen = dwScreen;
+ pXMsgArg->pWMInfo = pWMInfo;
+ pXMsgArg->ppmServerStarted = ppmServerStarted;
+ pXMsgArg->hwndScreen = hwndScreen;
+ if (pthread_create (ptXMsgProc, NULL, winMultiWindowXMsgProc, pXMsgArg))
+ {
+ /* Bail if thread creation failed */
+ ErrorF ("winInitWM - pthread_create failed on XMSG.\n");
+ return FALSE;
+ }
+
+#if CYGDEBUG || YES
+ winDebug ("winInitWM - Returning.\n");
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * Window manager thread - setup
+ */
+
+static void
+winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
+{
+ int iRetries = 0;
+ char pszDisplay[512];
+ int iReturn;
+
+ ErrorF ("winInitMultiWindowWM - Hello\n");
+
+ /* Check that argument pointer is not invalid */
+ if (pProcArg == NULL)
+ {
+ ErrorF ("winInitMultiWindowWM - pProcArg is NULL. Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ ErrorF ("winInitMultiWindowWM - Calling pthread_mutex_lock ()\n");
+
+ /* Grab our garbage mutex to satisfy pthread_cond_wait */
+ iReturn = pthread_mutex_lock (pProcArg->ppmServerStarted);
+ if (iReturn != 0)
+ {
+ ErrorF ("winInitMultiWindowWM - pthread_mutex_lock () failed: %d. "
+ "Exiting.\n",
+ iReturn);
+ pthread_exit (NULL);
+ }
+
+ ErrorF ("winInitMultiWindowWM - pthread_mutex_lock () returned.\n");
+
+ /* Allow multiple threads to access Xlib */
+ if (XInitThreads () == 0)
+ {
+ ErrorF ("winInitMultiWindowWM - XInitThreads () failed. Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ /* See if X supports the current locale */
+ if (XSupportsLocale () == False)
+ {
+ ErrorF ("winInitMultiWindowWM - Locale not supported by X. Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ /* Release the server started mutex */
+ pthread_mutex_unlock (pProcArg->ppmServerStarted);
+
+ ErrorF ("winInitMultiWindowWM - pthread_mutex_unlock () returned.\n");
+
+ /* Set jump point for IO Error exits */
+ iReturn = setjmp (g_jmpWMEntry);
+
+ /* Check if we should continue operations */
+ if (iReturn != WIN_JMP_ERROR_IO
+ && iReturn != WIN_JMP_OKAY)
+ {
+ /* setjmp returned an unknown value, exit */
+ ErrorF ("winInitMultiWindowWM - setjmp returned: %d. Exiting.\n",
+ iReturn);
+ pthread_exit (NULL);
+ }
+ else if (iReturn == WIN_JMP_ERROR_IO)
+ {
+ ErrorF ("winInitMultiWindowWM - Caught IO Error. Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ /* Install our error handler */
+ XSetErrorHandler (winMultiWindowWMErrorHandler);
+ XSetIOErrorHandler (winMultiWindowWMIOErrorHandler);
+
+ /* Setup the display connection string x */
+ snprintf (pszDisplay,
+ 512,
+ "127.0.0.1:%s.%d",
+ display,
+ (int) pProcArg->dwScreen);
+
+ /* Print the display connection string */
+ ErrorF ("winInitMultiWindowWM - DISPLAY=%s\n", pszDisplay);
+
+ /* Open the X display */
+ do
+ {
+ /* Try to open the display */
+ pWMInfo->pDisplay = XOpenDisplay (pszDisplay);
+ if (pWMInfo->pDisplay == NULL)
+ {
+ ErrorF ("winInitMultiWindowWM - Could not open display, try: %d, "
+ "sleeping: %d\n\f",
+ iRetries + 1, WIN_CONNECT_DELAY);
+ ++iRetries;
+ sleep (WIN_CONNECT_DELAY);
+ continue;
+ }
+ else
+ break;
+ }
+ while (pWMInfo->pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES);
+
+ /* Make sure that the display opened */
+ if (pWMInfo->pDisplay == NULL)
+ {
+ ErrorF ("winInitMultiWindowWM - Failed opening the display. "
+ "Exiting.\n");
+ pthread_exit (NULL);
+ }
+
+ ErrorF ("winInitMultiWindowWM - XOpenDisplay () returned and "
+ "successfully opened the display.\n");
+
+
+ /* Create some atoms */
+ pWMInfo->atmWmProtos = XInternAtom (pWMInfo->pDisplay,
+ "WM_PROTOCOLS",
+ False);
+ pWMInfo->atmWmDelete = XInternAtom (pWMInfo->pDisplay,
+ "WM_DELETE_WINDOW",
+ False);
+#ifdef XWIN_MULTIWINDOWEXTWM
+ pWMInfo->atmPrivMap = XInternAtom (pWMInfo->pDisplay,
+ WINDOWSWM_NATIVE_HWND,
+ False);
+#endif
+
+
+ if (1) {
+ Cursor cursor = XCreateFontCursor (pWMInfo->pDisplay, XC_left_ptr);
+ if (cursor)
+ {
+ XDefineCursor (pWMInfo->pDisplay, DefaultRootWindow(pWMInfo->pDisplay), cursor);
+ XFreeCursor (pWMInfo->pDisplay, cursor);
+ }
+ }
+}
+
+
+/*
+ * winSendMessageToWM - Send a message from the X thread to the WM thread
+ */
+
+void
+winSendMessageToWM (void *pWMInfo, winWMMessagePtr pMsg)
+{
+ WMMsgNodePtr pNode;
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winSendMessageToWM ()\n");
+#endif
+
+ pNode = (WMMsgNodePtr)malloc(sizeof(WMMsgNodeRec));
+ if (pNode != NULL)
+ {
+ memcpy (&pNode->msg, pMsg, sizeof(winWMMessageRec));
+ PushMessage (&((WMInfoPtr)pWMInfo)->wmMsgQueue, pNode);
+ }
+}
+
+
+/*
+ * Window manager error handler
+ */
+
+static int
+winMultiWindowWMErrorHandler (Display *pDisplay, XErrorEvent *pErr)
+{
+ char pszErrorMsg[100];
+
+ if (pErr->request_code == X_ChangeWindowAttributes
+ && pErr->error_code == BadAccess)
+ {
+ ErrorF ("winMultiWindowWMErrorHandler - ChangeWindowAttributes "
+ "BadAccess.\n");
+ return 0;
+ }
+
+ XGetErrorText (pDisplay,
+ pErr->error_code,
+ pszErrorMsg,
+ sizeof (pszErrorMsg));
+ ErrorF ("winMultiWindowWMErrorHandler - ERROR: %s\n", pszErrorMsg);
+
+ return 0;
+}
+
+
+/*
+ * Window manager IO error handler
+ */
+
+static int
+winMultiWindowWMIOErrorHandler (Display *pDisplay)
+{
+ ErrorF ("\nwinMultiWindowWMIOErrorHandler!\n\n");
+
+ if (g_shutdown)
+ pthread_exit(NULL);
+
+ /* Restart at the main entry point */
+ longjmp (g_jmpWMEntry, WIN_JMP_ERROR_IO);
+
+ return 0;
+}
+
+
+/*
+ * X message procedure error handler
+ */
+
+static int
+winMultiWindowXMsgProcErrorHandler (Display *pDisplay, XErrorEvent *pErr)
+{
+ char pszErrorMsg[100];
+
+ XGetErrorText (pDisplay,
+ pErr->error_code,
+ pszErrorMsg,
+ sizeof (pszErrorMsg));
+ ErrorF ("winMultiWindowXMsgProcErrorHandler - ERROR: %s\n", pszErrorMsg);
+
+ return 0;
+}
+
+
+/*
+ * X message procedure IO error handler
+ */
+
+static int
+winMultiWindowXMsgProcIOErrorHandler (Display *pDisplay)
+{
+ ErrorF ("\nwinMultiWindowXMsgProcIOErrorHandler!\n\n");
+
+ /* Restart at the main entry point */
+ longjmp (g_jmpXMsgProcEntry, WIN_JMP_ERROR_IO);
+
+ return 0;
+}
+
+
+/*
+ * Catch RedirectError to detect other window manager running
+ */
+
+static int
+winRedirectErrorHandler (Display *pDisplay, XErrorEvent *pErr)
+{
+ redirectError = TRUE;
+ return 0;
+}
+
+
+/*
+ * Check if another window manager is running
+ */
+
+static Bool
+CheckAnotherWindowManager (Display *pDisplay, DWORD dwScreen)
+{
+ redirectError = FALSE;
+ XSetErrorHandler (winRedirectErrorHandler);
+ XSelectInput(pDisplay, RootWindow (pDisplay, dwScreen),
+ // SubstructureNotifyMask | ButtonPressMask
+ ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
+ SubstructureRedirectMask | KeyPressMask |
+ ButtonPressMask | ButtonReleaseMask);
+ XSync (pDisplay, 0);
+ XSetErrorHandler (winMultiWindowXMsgProcErrorHandler);
+ XSelectInput(pDisplay, RootWindow (pDisplay, dwScreen),
+ SubstructureNotifyMask);
+ XSync (pDisplay, 0);
+ if (redirectError)
+ {
+ //ErrorF ("CheckAnotherWindowManager() - another window manager is running. Exiting.\n");
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+/*
+ * Notify the MWM thread we're exiting and not to reconnect
+ */
+
+void
+winDeinitMultiWindowWM ()
+{
+ ErrorF ("winDeinitMultiWindowWM - Noting shutdown in progress\n");
+ g_shutdown = TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winmultiwindowwndproc.c b/nx-X11/programs/Xserver/hw/xwin/winmultiwindowwndproc.c
new file mode 100755
index 000000000..50397d8b0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winmultiwindowwndproc.c
@@ -0,0 +1,1035 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Kensuke Matsuzaki
+ * Earle F. Philhower, III
+ * Harold L Hunt II
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winmultiwindowwndproc.c,v 1.2 2003/10/02 13:30:11 eich Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "dixevents.h"
+#include "winmultiwindowclass.h"
+#include "winprefs.h"
+#include "winmsg.h"
+
+/*
+ * External global variables
+ */
+
+extern Bool g_fCursor;
+extern Bool g_fKeyboardHookLL;
+extern Bool g_fSoftwareCursor;
+
+
+/*
+ * Local globals
+ */
+
+static UINT_PTR g_uipMousePollingTimerID = 0;
+
+
+/*
+ * Constant defines
+ */
+
+#define MOUSE_POLLING_INTERVAL 500
+#define WIN_MULTIWINDOW_SHAPE YES
+
+
+/*
+ * ConstrainSize - Taken from TWM sources - Respects hints for sizing
+ */
+#define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) )
+static void
+ConstrainSize (WinXSizeHints hints, int *widthp, int *heightp)
+{
+ int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta;
+ int baseWidth, baseHeight;
+ int dwidth = *widthp, dheight = *heightp;
+
+ if (hints.flags & PMinSize)
+ {
+ minWidth = hints.min_width;
+ minHeight = hints.min_height;
+ }
+ else if (hints.flags & PBaseSize)
+ {
+ minWidth = hints.base_width;
+ minHeight = hints.base_height;
+ }
+ else
+ minWidth = minHeight = 1;
+
+ if (hints.flags & PBaseSize)
+ {
+ baseWidth = hints.base_width;
+ baseHeight = hints.base_height;
+ }
+ else if (hints.flags & PMinSize)
+ {
+ baseWidth = hints.min_width;
+ baseHeight = hints.min_height;
+ }
+ else
+ baseWidth = baseHeight = 0;
+
+ if (hints.flags & PMaxSize)
+ {
+ maxWidth = hints.max_width;
+ maxHeight = hints.max_height;
+ }
+ else
+ {
+ maxWidth = MAXINT;
+ maxHeight = MAXINT;
+ }
+
+ if (hints.flags & PResizeInc)
+ {
+ xinc = hints.width_inc;
+ yinc = hints.height_inc;
+ }
+ else
+ xinc = yinc = 1;
+
+ /*
+ * First, clamp to min and max values
+ */
+ if (dwidth < minWidth)
+ dwidth = minWidth;
+ if (dheight < minHeight)
+ dheight = minHeight;
+
+ if (dwidth > maxWidth)
+ dwidth = maxWidth;
+ if (dheight > maxHeight)
+ dheight = maxHeight;
+
+ /*
+ * Second, fit to base + N * inc
+ */
+ dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
+ dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
+
+ /*
+ * Third, adjust for aspect ratio
+ */
+
+ /*
+ * The math looks like this:
+ *
+ * minAspectX dwidth maxAspectX
+ * ---------- <= ------- <= ----------
+ * minAspectY dheight maxAspectY
+ *
+ * If that is multiplied out, then the width and height are
+ * invalid in the following situations:
+ *
+ * minAspectX * dheight > minAspectY * dwidth
+ * maxAspectX * dheight < maxAspectY * dwidth
+ *
+ */
+
+ if (hints.flags & PAspect)
+ {
+ if (hints.min_aspect.x * dheight > hints.min_aspect.y * dwidth)
+ {
+ delta = makemult(hints.min_aspect.x * dheight / hints.min_aspect.y - dwidth, xinc);
+ if (dwidth + delta <= maxWidth)
+ dwidth += delta;
+ else
+ {
+ delta = makemult(dheight - dwidth*hints.min_aspect.y/hints.min_aspect.x, yinc);
+ if (dheight - delta >= minHeight)
+ dheight -= delta;
+ }
+ }
+
+ if (hints.max_aspect.x * dheight < hints.max_aspect.y * dwidth)
+ {
+ delta = makemult(dwidth * hints.max_aspect.y / hints.max_aspect.x - dheight, yinc);
+ if (dheight + delta <= maxHeight)
+ dheight += delta;
+ else
+ {
+ delta = makemult(dwidth - hints.max_aspect.x*dheight/hints.max_aspect.y, xinc);
+ if (dwidth - delta >= minWidth)
+ dwidth -= delta;
+ }
+ }
+ }
+
+ /* Return computed values */
+ *widthp = dwidth;
+ *heightp = dheight;
+}
+#undef makemult
+
+
+
+/*
+ * ValidateSizing - Ensures size request respects hints
+ */
+static int
+ValidateSizing (HWND hwnd, WindowPtr pWin,
+ WPARAM wParam, LPARAM lParam)
+{
+ WinXSizeHints sizeHints;
+ RECT *rect;
+ int iWidth, iHeight;
+
+ /* Invalid input checking */
+ if (pWin==NULL || lParam==0)
+ return FALSE;
+
+ /* No size hints, no checking */
+ if (!winMultiWindowGetWMNormalHints (pWin, &sizeHints))
+ return FALSE;
+
+ /* Avoid divide-by-zero */
+ if (sizeHints.flags & PResizeInc)
+ {
+ if (sizeHints.width_inc == 0) sizeHints.width_inc = 1;
+ if (sizeHints.height_inc == 0) sizeHints.height_inc = 1;
+ }
+
+ rect = (RECT*)lParam;
+
+ iWidth = rect->right - rect->left;
+ iHeight = rect->bottom - rect->top;
+
+ /* Now remove size of any borders */
+ iWidth -= 2 * GetSystemMetrics(SM_CXSIZEFRAME);
+ iHeight -= (GetSystemMetrics(SM_CYCAPTION)
+ + 2 * GetSystemMetrics(SM_CYSIZEFRAME));
+
+
+ /* Constrain the size to legal values */
+ ConstrainSize (sizeHints, &iWidth, &iHeight);
+
+ /* Add back the borders */
+ iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
+ iHeight += (GetSystemMetrics(SM_CYCAPTION)
+ + 2 * GetSystemMetrics(SM_CYSIZEFRAME));
+
+ /* Adjust size according to where we're dragging from */
+ switch(wParam) {
+ case WMSZ_TOP:
+ case WMSZ_TOPRIGHT:
+ case WMSZ_BOTTOM:
+ case WMSZ_BOTTOMRIGHT:
+ case WMSZ_RIGHT:
+ rect->right = rect->left + iWidth;
+ break;
+ default:
+ rect->left = rect->right - iWidth;
+ break;
+ }
+ switch(wParam) {
+ case WMSZ_BOTTOM:
+ case WMSZ_BOTTOMRIGHT:
+ case WMSZ_BOTTOMLEFT:
+ case WMSZ_RIGHT:
+ case WMSZ_LEFT:
+ rect->bottom = rect->top + iHeight;
+ break;
+ default:
+ rect->top = rect->bottom - iHeight;
+ break;
+ }
+ return TRUE;
+}
+
+extern Bool winInDestroyWindowsWindow;
+static Bool winInRaiseWindow = FALSE;
+static void winRaiseWindow(WindowPtr pWin)
+{
+ if (!winInDestroyWindowsWindow && !winInRaiseWindow)
+ {
+ BOOL oldstate = winInRaiseWindow;
+ winInRaiseWindow = TRUE;
+ /* Call configure window directly to make sure it gets processed
+ * in time
+ */
+ XID vlist[1] = { 0 };
+ ConfigureWindow(pWin, CWStackMode, vlist, serverClient);
+ winInRaiseWindow = oldstate;
+ }
+}
+
+
+/*
+ * winTopLevelWindowProc - Window procedure for all top-level Windows windows.
+ */
+
+LRESULT CALLBACK
+winTopLevelWindowProc (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ POINT ptMouse;
+ HDC hdcUpdate;
+ PAINTSTRUCT ps;
+ WindowPtr pWin = NULL;
+ winPrivWinPtr pWinPriv = NULL;
+ ScreenPtr s_pScreen = NULL;
+ winPrivScreenPtr s_pScreenPriv = NULL;
+ winScreenInfo *s_pScreenInfo = NULL;
+ HWND hwndScreen = NULL;
+ DrawablePtr pDraw = NULL;
+ int iX, iY, iWidth, iHeight, iBorder;
+ winWMMessageRec wmMsg;
+ Bool fWMMsgInitialized = FALSE;
+ static Bool s_fTracking = FALSE;
+ Bool needRestack = FALSE;
+ LRESULT ret;
+
+#if CYGDEBUG
+ winDebugWin32Message("winTopLevelWindowProc", hwnd, message, wParam, lParam);
+#endif
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pWin = GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
+ {
+ /* Our X window pointer is valid */
+
+ /* Get pointers to the drawable and the screen */
+ pDraw = &pWin->drawable;
+ s_pScreen = pWin->drawable.pScreen;
+
+ /* Get a pointer to our window privates */
+ pWinPriv = winGetWindowPriv(pWin);
+
+ /* Get pointers to our screen privates and screen info */
+ s_pScreenPriv = pWinPriv->pScreenPriv;
+ s_pScreenInfo = s_pScreenPriv->pScreenInfo;
+
+ /* Get the handle for our screen-sized window */
+ hwndScreen = s_pScreenPriv->hwndScreen;
+
+ /* */
+ wmMsg.msg = 0;
+ wmMsg.hwndWindow = hwnd;
+ wmMsg.iWindow = (Window)GetProp (hwnd, WIN_WID_PROP);
+
+ wmMsg.iX = pDraw->x;
+ wmMsg.iY = pDraw->y;
+ wmMsg.iWidth = pDraw->width;
+ wmMsg.iHeight = pDraw->height;
+
+ fWMMsgInitialized = TRUE;
+
+#if 0
+ /*
+ * Print some debugging information
+ */
+
+ ErrorF ("hWnd %08X\n", hwnd);
+ ErrorF ("pWin %08X\n", pWin);
+ ErrorF ("pDraw %08X\n", pDraw);
+ ErrorF ("\ttype %08X\n", pWin->drawable.type);
+ ErrorF ("\tclass %08X\n", pWin->drawable.class);
+ ErrorF ("\tdepth %08X\n", pWin->drawable.depth);
+ ErrorF ("\tbitsPerPixel %08X\n", pWin->drawable.bitsPerPixel);
+ ErrorF ("\tid %08X\n", pWin->drawable.id);
+ ErrorF ("\tx %08X\n", pWin->drawable.x);
+ ErrorF ("\ty %08X\n", pWin->drawable.y);
+ ErrorF ("\twidth %08X\n", pWin->drawable.width);
+ ErrorF ("\thenght %08X\n", pWin->drawable.height);
+ ErrorF ("\tpScreen %08X\n", pWin->drawable.pScreen);
+ ErrorF ("\tserialNumber %08X\n", pWin->drawable.serialNumber);
+ ErrorF ("g_iWindowPrivateIndex %d\n", g_iWindowPrivateIndex);
+ ErrorF ("pWinPriv %08X\n", pWinPriv);
+ ErrorF ("s_pScreenPriv %08X\n", s_pScreenPriv);
+ ErrorF ("s_pScreenInfo %08X\n", s_pScreenInfo);
+ ErrorF ("hwndScreen %08X\n", hwndScreen);
+#endif
+ }
+
+ /* Branch on message type */
+ switch (message)
+ {
+ case WM_CREATE:
+
+ /* */
+ SetProp (hwnd,
+ WIN_WINDOW_PROP,
+ (HANDLE)((LPCREATESTRUCT) lParam)->lpCreateParams);
+
+ /* */
+ SetProp (hwnd,
+ WIN_WID_PROP,
+ (HANDLE)winGetWindowID (((LPCREATESTRUCT) lParam)->lpCreateParams));
+
+ /*
+ * Make X windows' Z orders sync with Windows windows because
+ * there can be AlwaysOnTop windows overlapped on the window
+ * currently being created.
+ */
+ winReorderWindowsMultiWindow ();
+ return 0;
+
+ case WM_INIT_SYS_MENU:
+ /*
+ * Add whatever the setup file wants to for this window
+ */
+ SetupSysMenu ((unsigned long)hwnd);
+ return 0;
+
+ case WM_SYSCOMMAND:
+ /*
+ * Any window menu items go through here
+ */
+ if (HandleCustomWM_COMMAND ((unsigned long)hwnd, LOWORD(wParam)))
+ {
+ /* Don't pass customized menus to DefWindowProc */
+ return 0;
+ }
+ if (wParam == SC_RESTORE || wParam == SC_MAXIMIZE)
+ {
+ WINDOWPLACEMENT wndpl;
+ wndpl.length = sizeof(wndpl);
+ if (GetWindowPlacement(hwnd, &wndpl) && wndpl.showCmd == SW_SHOWMINIMIZED)
+ needRestack = TRUE;
+ }
+ break;
+
+ case WM_INITMENU:
+ /* Checks/Unchecks any menu items before they are displayed */
+ HandleCustomWM_INITMENU ((unsigned long)hwnd, wParam);
+ break;
+
+ case WM_PAINT:
+ /* Only paint if our window handle is valid */
+ if (hwndScreen == NULL)
+ break;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint (hwnd, &ps);
+
+ /* Get the position and dimensions of the window */
+ iBorder = wBorderWidth (pWin);
+ iX = pWin->drawable.x;
+ iY = pWin->drawable.y;
+ iWidth = pWin->drawable.width;
+ iHeight = pWin->drawable.height;
+
+ /* Try to copy from the shadow buffer */
+ if (!BitBlt (hdcUpdate,
+ 0, 0,
+ iWidth, iHeight,
+ s_pScreenPriv->hdcShadow,
+ iX, iY,
+ SRCCOPY))
+ {
+ LPVOID lpMsgBuf;
+
+ /* Display a fancy error message */
+ FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError (),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &lpMsgBuf,
+ 0, NULL);
+
+ ErrorF ("winTopLevelWindowProc - BitBlt failed: %s\n",
+ (LPSTR)lpMsgBuf);
+ LocalFree (lpMsgBuf);
+ }
+
+ /* EndPaint frees the DC */
+ EndPaint (hwndScreen, &ps);
+ return 0;
+
+ case WM_MOUSEMOVE:
+ /* Unpack the client area mouse coordinates */
+ ptMouse.x = GET_X_LPARAM(lParam);
+ ptMouse.y = GET_Y_LPARAM(lParam);
+
+ /* Translate the client area mouse coordinates to screen coordinates */
+ ClientToScreen (hwnd, &ptMouse);
+
+ /* Screen Coords from (-X, -Y) -> Root Window (0, 0) */
+ ptMouse.x -= GetSystemMetrics (SM_XVIRTUALSCREEN);
+ ptMouse.y -= GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* We can't do anything without privates */
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Has the mouse pointer crossed screens? */
+ if (s_pScreen != miPointerCurrentScreen ())
+ miPointerSetNewScreen (s_pScreenInfo->dwScreen,
+ ptMouse.x - s_pScreenInfo->dwXOffset,
+ ptMouse.y - s_pScreenInfo->dwYOffset);
+
+ /* Are we tracking yet? */
+ if (!s_fTracking)
+ {
+ TRACKMOUSEEVENT tme;
+
+ /* Setup data structure */
+ ZeroMemory (&tme, sizeof (tme));
+ tme.cbSize = sizeof (tme);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = hwnd;
+
+ /* Call the tracking function */
+ if (!(*g_fpTrackMouseEvent) (&tme))
+ ErrorF ("winTopLevelWindowProc - _TrackMouseEvent failed\n");
+
+ /* Flag that we are tracking now */
+ s_fTracking = TRUE;
+ }
+
+ /* Hide or show the Windows mouse cursor */
+ if (g_fSoftwareCursor && g_fCursor)
+ {
+ /* Hide Windows cursor */
+ g_fCursor = FALSE;
+ ShowCursor (FALSE);
+ }
+
+ /* Kill the timer used to poll mouse events */
+ if (g_uipMousePollingTimerID != 0)
+ {
+ KillTimer (s_pScreenPriv->hwndScreen, WIN_POLLING_MOUSE_TIMER_ID);
+ g_uipMousePollingTimerID = 0;
+ }
+
+ /* Deliver absolute cursor position to X Server */
+ miPointerAbsoluteCursor (ptMouse.x - s_pScreenInfo->dwXOffset,
+ ptMouse.y - s_pScreenInfo->dwYOffset,
+ g_c32LastInputEventTime = GetTickCount ());
+ return 0;
+
+ case WM_NCMOUSEMOVE:
+ /*
+ * We break instead of returning 0 since we need to call
+ * DefWindowProc to get the mouse cursor changes
+ * and min/max/close button highlighting in Windows XP.
+ * The Platform SDK says that you should return 0 if you
+ * process this message, but it fails to mention that you
+ * will give up any default functionality if you do return 0.
+ */
+
+ /* We can't do anything without privates */
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Non-client mouse movement, show Windows cursor */
+ if (g_fSoftwareCursor && !g_fCursor)
+ {
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+
+ /*
+ * Timer to poll mouse events. This is needed to make
+ * programs like xeyes follow the mouse properly.
+ */
+ if (g_uipMousePollingTimerID == 0)
+ g_uipMousePollingTimerID = SetTimer (s_pScreenPriv->hwndScreen,
+ WIN_POLLING_MOUSE_TIMER_ID,
+ MOUSE_POLLING_INTERVAL,
+ NULL);
+ break;
+
+ case WM_MOUSELEAVE:
+ /* Mouse has left our client area */
+
+ /* Flag that we are no longer tracking */
+ s_fTracking = FALSE;
+
+ /* Show the mouse cursor, if necessary */
+ if (g_fSoftwareCursor && !g_fCursor)
+ {
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+
+ /*
+ * Timer to poll mouse events. This is needed to make
+ * programs like xeyes follow the mouse properly.
+ */
+ if (g_uipMousePollingTimerID == 0)
+ g_uipMousePollingTimerID = SetTimer (s_pScreenPriv->hwndScreen,
+ WIN_POLLING_MOUSE_TIMER_ID,
+ MOUSE_POLLING_INTERVAL,
+ NULL);
+ return 0;
+
+ case WM_LBUTTONDBLCLK:
+ case WM_LBUTTONDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ return winMouseButtonsHandle (s_pScreen, ButtonPress, Button1, wParam);
+
+ case WM_LBUTTONUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button1, wParam);
+
+ case WM_MBUTTONDBLCLK:
+ case WM_MBUTTONDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ return winMouseButtonsHandle (s_pScreen, ButtonPress, Button2, wParam);
+
+ case WM_MBUTTONUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button2, wParam);
+
+ case WM_RBUTTONDBLCLK:
+ case WM_RBUTTONDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ return winMouseButtonsHandle (s_pScreen, ButtonPress, Button3, wParam);
+
+ case WM_RBUTTONUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button3, wParam);
+
+ case WM_XBUTTONDBLCLK:
+ case WM_XBUTTONDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ return winMouseButtonsHandle (s_pScreen, ButtonPress, HIWORD(wParam) + 5, wParam);
+ case WM_XBUTTONUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ return winMouseButtonsHandle (s_pScreen, ButtonRelease, HIWORD(wParam) + 5, wParam);
+
+ case WM_MOUSEWHEEL:
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+ return 0;
+
+ case WM_SETFOCUS:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ winRestoreModeKeyStates ();
+
+ /* Add the keyboard hook if possible */
+ if (g_fKeyboardHookLL)
+ g_fKeyboardHookLL = winInstallKeyboardHookLL ();
+ return 0;
+
+ case WM_KILLFOCUS:
+ /* Pop any pressed keys since we are losing keyboard focus */
+ winKeybdReleaseKeys ();
+
+ /* Remove our keyboard hook if it is installed */
+ winRemoveKeyboardHookLL ();
+ return 0;
+
+ case WM_SYSDEADCHAR:
+ case WM_DEADCHAR:
+ /*
+ * NOTE: We do nothing with WM_*CHAR messages,
+ * nor does the root window, so we can just toss these messages.
+ */
+ return 0;
+
+ case WM_SYSKEYDOWN:
+ case WM_KEYDOWN:
+
+ /*
+ * Don't pass Alt-F4 key combo to root window,
+ * let Windows translate to WM_CLOSE and close this top-level window.
+ *
+ * NOTE: We purposely don't check the fUseWinKillKey setting because
+ * it should only apply to the key handling for the root window,
+ * not for top-level window-manager windows.
+ *
+ * ALSO NOTE: We do pass Ctrl-Alt-Backspace to the root window
+ * because that is a key combo that no X app should be expecting to
+ * receive, since it has historically been used to shutdown the X server.
+ * Passing Ctrl-Alt-Backspace to the root window preserves that
+ * behavior, assuming that -unixkill has been passed as a parameter.
+ */
+ if (wParam == VK_F4 && (GetKeyState (VK_MENU) & 0x8000))
+ break;
+
+#if CYGWINDOWING_DEBUG
+ if (wParam == VK_ESCAPE)
+ {
+ /* Place for debug: put any tests and dumps here */
+ WINDOWPLACEMENT windPlace;
+ RECT rc;
+ LPRECT pRect;
+
+ windPlace.length = sizeof (WINDOWPLACEMENT);
+ GetWindowPlacement (hwnd, &windPlace);
+ pRect = &windPlace.rcNormalPosition;
+ ErrorF ("\nCYGWINDOWING Dump:\n"
+ "\tdrawable: (%hd, %hd) - %hdx%hd\n", pDraw->x,
+ pDraw->y, pDraw->width, pDraw->height);
+ ErrorF ("\twindPlace: (%ld, %ld) - %ldx%ld\n", pRect->left,
+ pRect->top, pRect->right - pRect->left,
+ pRect->bottom - pRect->top);
+ if (GetClientRect (hwnd, &rc))
+ {
+ pRect = &rc;
+ ErrorF ("\tClientRect: (%ld, %ld) - %ldx%ld\n", pRect->left,
+ pRect->top, pRect->right - pRect->left,
+ pRect->bottom - pRect->top);
+ }
+ if (GetWindowRect (hwnd, &rc))
+ {
+ pRect = &rc;
+ ErrorF ("\tWindowRect: (%ld, %ld) - %ldx%ld\n", pRect->left,
+ pRect->top, pRect->right - pRect->left,
+ pRect->bottom - pRect->top);
+ }
+ ErrorF ("\n");
+ }
+#endif
+
+ /* Pass the message to the root window */
+ return winWindowProc(hwndScreen, message, wParam, lParam);
+
+ case WM_SYSKEYUP:
+ case WM_KEYUP:
+
+
+ /* Pass the message to the root window */
+ return winWindowProc(hwndScreen, message, wParam, lParam);
+
+ case WM_HOTKEY:
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+ return 0;
+
+ case WM_ACTIVATE:
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+
+ if (LOWORD(wParam) != WA_INACTIVE)
+ {
+ /* Raise the window to the top in Z order */
+ /* ago: Activate does not mean putting it to front! */
+ /*
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
+ */
+
+ /* Tell our Window Manager thread to activate the window */
+ wmMsg.msg = WM_WM_ACTIVATE;
+ if (fWMMsgInitialized)
+ if (!pWin || !pWin->overrideRedirect) /* for OOo menus */
+ winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
+ }
+ return 0;
+
+ case WM_ACTIVATEAPP:
+ /*
+ * This message is also sent to the root window
+ * so we do nothing for individual multiwindow windows
+ */
+ break;
+
+ case WM_CLOSE:
+ /* Branch on if the window was killed in X already */
+ if (pWinPriv->fXKilled)
+ {
+ /* Window was killed, go ahead and destroy the window */
+ DestroyWindow (hwnd);
+ }
+ else
+ {
+ /* Tell our Window Manager thread to kill the window */
+ wmMsg.msg = WM_WM_KILL;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
+ }
+ return 0;
+
+ case WM_DESTROY:
+
+ /* Branch on if the window was killed in X already */
+ if (pWinPriv && !pWinPriv->fXKilled)
+ {
+ ErrorF ("winTopLevelWindowProc - WM_DESTROY - WM_WM_KILL\n");
+
+ /* Tell our Window Manager thread to kill the window */
+ wmMsg.msg = WM_WM_KILL;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
+ }
+
+ RemoveProp (hwnd, WIN_WINDOW_PROP);
+ RemoveProp (hwnd, WIN_WID_PROP);
+ RemoveProp (hwnd, WIN_NEEDMANAGE_PROP);
+
+ break;
+
+ case WM_MOVE:
+ /* Adjust the X Window to the moved Windows window */
+ winAdjustXWindow (pWin, hwnd);
+ return 0;
+
+ case WM_SHOWWINDOW:
+ /* Bail out if the window is being hidden */
+ if (!wParam)
+ return 0;
+
+ /* Tell X to map the window */
+ MapWindow (pWin, wClient(pWin));
+
+ /* */
+ if (!pWin->overrideRedirect)
+ {
+ DWORD dwExStyle;
+ DWORD dwStyle;
+ RECT rcNew;
+ int iDx, iDy;
+
+ /* Flag that this window needs to be made active when clicked */
+ SetProp (hwnd, WIN_NEEDMANAGE_PROP, (HANDLE) 1);
+
+ /* Get the standard and extended window style information */
+ dwExStyle = GetWindowLongPtr (hwnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr (hwnd, GWL_STYLE);
+
+ /* */
+ if (dwExStyle != WS_EX_APPWINDOW)
+ {
+ /* Setup a rectangle with the X window position and size */
+ SetRect (&rcNew,
+ pDraw->x,
+ pDraw->y,
+ pDraw->x + pDraw->width,
+ pDraw->y + pDraw->height);
+
+#if 0
+ ErrorF ("winTopLevelWindowProc - (%d, %d)-(%d, %d)\n",
+ rcNew.left, rcNew.top,
+ rcNew.right, rcNew.bottom);
+#endif
+
+ /* */
+ AdjustWindowRectEx (&rcNew,
+ WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW,
+ FALSE,
+ WS_EX_APPWINDOW);
+
+ /* Calculate position deltas */
+ iDx = pDraw->x - rcNew.left;
+ iDy = pDraw->y - rcNew.top;
+
+ /* Calculate new rectangle */
+ rcNew.left += iDx;
+ rcNew.right += iDx;
+ rcNew.top += iDy;
+ rcNew.bottom += iDy;
+
+#if 0
+ ErrorF ("winTopLevelWindowProc - (%d, %d)-(%d, %d)\n",
+ rcNew.left, rcNew.top,
+ rcNew.right, rcNew.bottom);
+#endif
+
+ /* Set the window extended style flags */
+ SetWindowLongPtr (hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW);
+
+ /* Set the window standard style flags */
+ SetWindowLongPtr (hwnd, GWL_STYLE,
+ WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW);
+
+ /* Position the Windows window */
+ SetWindowPos (hwnd, HWND_TOP,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ SWP_NOMOVE | SWP_FRAMECHANGED
+ | SWP_SHOWWINDOW | SWP_NOACTIVATE);
+
+ /* Bring the Windows window to the foreground */
+ SetForegroundWindow (hwnd);
+ }
+ }
+ else /* It is an overridden window so make it top of Z stack */
+ {
+#if CYGWINDOWING_DEBUG
+ ErrorF ("overridden window is shown\n");
+#endif
+ SetWindowPos (hwnd, HWND_TOPMOST, 0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ }
+
+ /* Setup the Window Manager message */
+ wmMsg.msg = WM_WM_MAP;
+ wmMsg.iWidth = pDraw->width;
+ wmMsg.iHeight = pDraw->height;
+
+ /* Tell our Window Manager thread to map the window */
+ if (fWMMsgInitialized)
+ winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
+
+ return 0;
+
+ case WM_SIZING:
+ /* Need to legalize the size according to WM_NORMAL_HINTS */
+ /* for applications like xterm */
+ return ValidateSizing (hwnd, pWin, wParam, lParam);
+
+ case WM_WINDOWPOSCHANGED:
+ {
+ LPWINDOWPOS pWinPos = (LPWINDOWPOS) lParam;
+
+ if (!(pWinPos->flags & SWP_NOZORDER))
+ {
+#if CYGWINDOWING_DEBUG
+ winDebug ("\twindow z order was changed\n");
+#endif
+ if (pWinPos->hwndInsertAfter == HWND_TOP
+ ||pWinPos->hwndInsertAfter == HWND_TOPMOST
+ ||pWinPos->hwndInsertAfter == HWND_NOTOPMOST)
+ {
+#if CYGWINDOWING_DEBUG
+ winDebug ("\traise to top\n");
+#endif
+ /* Raise the window to the top in Z order */
+ winRaiseWindow(pWin);
+ }
+ else if (pWinPos->hwndInsertAfter == HWND_BOTTOM)
+ {
+ }
+ else
+ {
+ /* Check if this window is top of X windows. */
+ HWND hWndAbove = NULL;
+ DWORD dwCurrentProcessID = GetCurrentProcessId ();
+ DWORD dwWindowProcessID = 0;
+
+ for (hWndAbove = pWinPos->hwndInsertAfter;
+ hWndAbove != NULL;
+ hWndAbove = GetNextWindow (hWndAbove, GW_HWNDPREV))
+ {
+ /* Ignore other XWin process's window */
+ GetWindowThreadProcessId (hWndAbove, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp (hWndAbove, WIN_WINDOW_PROP)
+ && !IsWindowVisible (hWndAbove)
+ && !IsIconic (hWndAbove) ) /* ignore minimized windows */
+ break;
+ }
+ /* If this is top of X windows in Windows stack,
+ raise it in X stack. */
+ if (hWndAbove == NULL)
+ {
+#if CYGWINDOWING_DEBUG
+ winDebug ("\traise to top\n");
+#endif
+ winRaiseWindow(pWin);
+ }
+ }
+ }
+ }
+ /*
+ * Pass the message to DefWindowProc to let the function
+ * break down WM_WINDOWPOSCHANGED to WM_MOVE and WM_SIZE.
+ */
+ break;
+
+ case WM_SIZE:
+ /* see dix/window.c */
+#if CYGWINDOWING_DEBUG
+ {
+ char buf[64];
+ switch (wParam)
+ {
+ case SIZE_MINIMIZED:
+ strcpy(buf, "SIZE_MINIMIZED");
+ break;
+ case SIZE_MAXIMIZED:
+ strcpy(buf, "SIZE_MAXIMIZED");
+ break;
+ case SIZE_RESTORED:
+ strcpy(buf, "SIZE_RESTORED");
+ break;
+ default:
+ strcpy(buf, "UNKNOWN_FLAG");
+ }
+ ErrorF ("winTopLevelWindowProc - WM_SIZE to %dx%d (%s) - %d ms\n",
+ (int)LOWORD(lParam), (int)HIWORD(lParam), buf,
+ (int)(GetTickCount ()));
+ }
+#endif
+ /* Adjust the X Window to the moved Windows window */
+ winAdjustXWindow (pWin, hwnd);
+ return 0; /* end of WM_SIZE handler */
+
+ case WM_MOUSEACTIVATE:
+
+ /* Check if this window needs to be made active when clicked */
+ if (!GetProp (pWinPriv->hWnd, WIN_NEEDMANAGE_PROP))
+ {
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winTopLevelWindowProc - WM_MOUSEACTIVATE - "
+ "MA_NOACTIVATE\n");
+#endif
+
+ /* */
+ return MA_NOACTIVATE;
+ }
+ break;
+
+ case WM_SETCURSOR:
+ if (LOWORD(lParam) == HTCLIENT)
+ {
+ if (!g_fSoftwareCursor) SetCursor (s_pScreenPriv->cursor.handle);
+ return TRUE;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ ret = DefWindowProc (hwnd, message, wParam, lParam);
+ /*
+ * If the window was minized we get the stack change before the window is restored
+ * and so it gets lost. Ensure there stacking order is correct.
+ */
+ if (needRestack)
+ winReorderWindowsMultiWindow();
+ return ret;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winnativegdi.c b/nx-X11/programs/Xserver/hw/xwin/winnativegdi.c
new file mode 100644
index 000000000..c67f1c7e5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winnativegdi.c
@@ -0,0 +1,547 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Harold L Hunt II
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winnativegdi.c,v 1.14 2003/07/29 21:25:18 dawes Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * External symbols
+ */
+
+extern HWND g_hDlgExit;
+
+
+/*
+ * Local function prototypes
+ */
+
+static Bool
+winAllocateFBNativeGDI (ScreenPtr pScreen);
+
+static void
+winShadowUpdateNativeGDI (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+static Bool
+winCloseScreenNativeGDI (int nIndex, ScreenPtr pScreen);
+
+static Bool
+winInitVisualsNativeGDI (ScreenPtr pScreen);
+
+static Bool
+winAdjustVideoModeNativeGDI (ScreenPtr pScreen);
+
+#if 0
+static Bool
+winBltExposedRegionsNativeGDI (ScreenPtr pScreen);
+#endif
+
+static Bool
+winActivateAppNativeGDI (ScreenPtr pScreen);
+
+static Bool
+winRedrawScreenNativeGDI (ScreenPtr pScreen);
+
+static Bool
+winRealizeInstalledPaletteNativeGDI (ScreenPtr pScreen);
+
+static Bool
+winInstallColormapNativeGDI (ColormapPtr pColormap);
+
+static Bool
+winStoreColorsNativeGDI (ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs);
+
+static Bool
+winCreateColormapNativeGDI (ColormapPtr pColormap);
+
+static Bool
+winDestroyColormapNativeGDI (ColormapPtr pColormap);
+
+
+
+static Bool
+winAllocateFBNativeGDI (ScreenPtr pScreen)
+{
+ FatalError ("winAllocateFBNativeGDI\n");
+
+ return TRUE;
+}
+
+
+/*
+ * We wrap whatever CloseScreen procedure was specified by fb;
+ * a pointer to said procedure is stored in our privates.
+ */
+
+static Bool
+winCloseScreenNativeGDI (int nIndex, ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ ErrorF ("winCloseScreenNativeGDI - Freeing screen resources\n");
+
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
+
+ /*
+ * NOTE: mi doesn't use a CloseScreen procedure, so we do not
+ * need to call a wrapped procedure here.
+ */
+
+ /* Delete the window property */
+ RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
+
+ ErrorF ("winCloseScreenNativeGDI - Destroying window\n");
+
+ /* Delete tray icon, if we have one */
+ if (!pScreenInfo->fNoTrayIcon)
+ winDeleteNotifyIcon (pScreenPriv);
+
+ /* Free the exit confirmation dialog box, if it exists */
+ if (g_hDlgExit != NULL)
+ {
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+ }
+
+ /* Kill our window */
+ if (pScreenPriv->hwndScreen)
+ {
+ DestroyWindow (pScreenPriv->hwndScreen);
+ pScreenPriv->hwndScreen = NULL;
+ }
+
+ /* Invalidate our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
+
+ /* Free the screen privates for this screen */
+ free (pScreenPriv);
+
+ ErrorF ("winCloseScreenNativeGDI - Returning\n");
+
+ return TRUE;
+}
+
+
+static void
+winShadowUpdateNativeGDI (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ FatalError ("winShadowUpdateNativeGDI\n");
+ return;
+}
+
+
+static Bool
+winInitVisualsNativeGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set the bitsPerRGB and bit masks */
+ switch (pScreenInfo->dwDepth)
+ {
+ case 24:
+ pScreenPriv->dwBitsPerRGB = 8;
+ pScreenPriv->dwRedMask = 0x00FF0000;
+ pScreenPriv->dwGreenMask = 0x0000FF00;
+ pScreenPriv->dwBlueMask = 0x000000FF;
+ break;
+
+ case 16:
+ pScreenPriv->dwBitsPerRGB = 6;
+ pScreenPriv->dwRedMask = 0xF800;
+ pScreenPriv->dwGreenMask = 0x07E0;
+ pScreenPriv->dwBlueMask = 0x001F;
+ break;
+
+ case 15:
+ pScreenPriv->dwBitsPerRGB = 5;
+ pScreenPriv->dwRedMask = 0x7C00;
+ pScreenPriv->dwGreenMask = 0x03E0;
+ pScreenPriv->dwBlueMask = 0x001F;
+ break;
+
+ case 8:
+ pScreenPriv->dwBitsPerRGB = 8;
+ pScreenPriv->dwRedMask = 0;
+ pScreenPriv->dwGreenMask = 0;
+ pScreenPriv->dwBlueMask = 0;
+ break;
+
+ default:
+ ErrorF ("winInitVisualsNativeGDI - Unknown screen depth\n");
+ return FALSE;
+ break;
+ }
+
+ /* Tell the user how many bits per RGB we are using */
+ ErrorF ("winInitVisualsNativeGDI - Using dwBitsPerRGB: %d\n",
+ (int) pScreenPriv->dwBitsPerRGB);
+
+ /* Create a single visual according to the Windows screen depth */
+ switch (pScreenInfo->dwDepth)
+ {
+ case 24:
+ case 16:
+ case 15:
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ TrueColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisuals - miSetVisualTypesAndMasks failed\n");
+ return FALSE;
+ }
+ break;
+
+ case 8:
+ ErrorF ("winInitVisuals - Calling miSetVisualTypesAndMasks\n");
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ StaticColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ StaticColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisuals - miSetVisualTypesAndMasks failed\n");
+ return FALSE;
+ }
+ break;
+
+ default:
+ ErrorF ("winInitVisualsNativeGDI - Unknown screen depth\n");
+ return FALSE;
+ }
+
+#if 1
+ ErrorF ("winInitVisualsNativeGDI - Returning\n");
+#endif
+
+ return TRUE;
+}
+
+
+/* Adjust the video mode */
+static Bool
+winAdjustVideoModeNativeGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc = NULL;
+ DWORD dwBPP;
+
+ hdc = GetDC (NULL);
+
+ /* We're in serious trouble if we can't get a DC */
+ if (hdc == NULL)
+ {
+ ErrorF ("winAdjustVideoModeNativeGDI - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+ pScreenInfo->dwDepth = GetDeviceCaps (hdc, PLANES);
+
+ switch (pScreenInfo->dwDepth) {
+ case 24:
+ case 16:
+ case 15:
+ case 8:
+ break;
+ default:
+ if (dwBPP == 32)
+ pScreenInfo->dwDepth = 24;
+ else
+ pScreenInfo->dwDepth = dwBPP;
+ break;
+ }
+
+ /* GDI cannot change the screen depth */
+ if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
+ {
+ /* No -depth parameter passed, let the user know the depth being used */
+ ErrorF ("winAdjustVideoModeNativeGDI - Using Windows display "
+ "depth of %d bits per pixel, %d depth\n",
+ (int) dwBPP, (int) pScreenInfo->dwDepth);
+
+ /* Use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+ else if (dwBPP != pScreenInfo->dwBPP)
+ {
+ /* Warn user if GDI depth is different than -depth parameter */
+ ErrorF ("winAdjustVideoModeNativeGDI - Command line bpp: %d, "\
+ "using bpp: %d\n",
+ (int) pScreenInfo->dwBPP, (int) dwBPP);
+
+ /* We'll use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+
+ return TRUE;
+}
+
+
+static Bool
+winActivateAppNativeGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /*
+ * Are we active?
+ * Are we fullscreen?
+ */
+ if (pScreenPriv != NULL
+ && pScreenPriv->fActive
+ && pScreenInfo->fFullScreen)
+ {
+ /*
+ * Activating, attempt to bring our window
+ * to the top of the display
+ */
+ ShowWindow (pScreenPriv->hwndScreen, SW_RESTORE);
+ }
+
+ /*
+ * Are we inactive?
+ * Are we fullscreen?
+ */
+ if (pScreenPriv != NULL
+ && !pScreenPriv->fActive
+ && pScreenInfo->fFullScreen)
+ {
+ /*
+ * Deactivating, stuff our window onto the
+ * task bar.
+ */
+ ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
+ }
+
+ return TRUE;
+}
+
+
+HBITMAP
+winCreateDIBNativeGDI (int iWidth, int iHeight, int iDepth,
+ BYTE **ppbBits, BITMAPINFO **ppbmi)
+{
+ BITMAPINFOHEADER *pbmih = NULL;
+ HBITMAP hBitmap = NULL;
+ BITMAPINFO *pbmi = NULL;
+
+ /* Don't create an invalid bitmap */
+ if (iWidth == 0
+ || iHeight == 0
+ || iDepth == 0)
+ {
+ ErrorF ("\nwinCreateDIBNativeGDI - Invalid specs w %d h %d d %d\n\n",
+ iWidth, iHeight, iDepth);
+ return NULL;
+ }
+
+ /* Allocate bitmap info header */
+ pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
+ + 256 * sizeof (RGBQUAD));
+ if (pbmih == NULL)
+ {
+ ErrorF ("winCreateDIBNativeGDI - malloc () failed\n");
+ return FALSE;
+ }
+ ZeroMemory (pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
+
+ /* Describe bitmap to be created */
+ pbmih->biSize = sizeof (BITMAPINFOHEADER);
+ pbmih->biWidth = iWidth;
+ pbmih->biHeight = -iHeight;
+ pbmih->biPlanes = 1;
+ pbmih->biBitCount = iDepth;
+ pbmih->biCompression = BI_RGB;
+ pbmih->biSizeImage = 0;
+ pbmih->biXPelsPerMeter = 0;
+ pbmih->biYPelsPerMeter = 0;
+ pbmih->biClrUsed = 0;
+ pbmih->biClrImportant = 0;
+
+ /* Setup color table for mono DIBs */
+ if (iDepth == 1)
+ {
+ pbmi = (BITMAPINFO*) pbmih;
+ pbmi->bmiColors[1].rgbBlue = 255;
+ pbmi->bmiColors[1].rgbGreen = 255;
+ pbmi->bmiColors[1].rgbRed = 255;
+ }
+
+ /* Create a DIB with a bit pointer */
+ hBitmap = CreateDIBSection (NULL,
+ (BITMAPINFO *) pbmih,
+ DIB_RGB_COLORS,
+ (void **) ppbBits,
+ NULL,
+ 0);
+ if (hBitmap == NULL)
+ {
+ ErrorF ("winCreateDIBNativeGDI - CreateDIBSection () failed\n");
+ return NULL;
+ }
+
+ /* Free the bitmap info header memory */
+ if (ppbmi != NULL)
+ {
+ /* Store the address of the BMIH in the ppbmih parameter */
+ *ppbmi = (BITMAPINFO *) pbmih;
+ }
+ else
+ {
+ free (pbmih);
+ pbmih = NULL;
+ }
+
+ return hBitmap;
+}
+
+
+#if 0
+static Bool
+winBltExposedRegionsNativeGDI (ScreenPtr pScreen)
+{
+
+ return TRUE;
+}
+#endif
+
+
+static Bool
+winRedrawScreenNativeGDI (ScreenPtr pScreen)
+{
+ FatalError ("winRedrawScreenNativeGDI\n");
+ return TRUE;
+}
+
+
+static Bool
+winRealizeInstalledPaletteNativeGDI (ScreenPtr pScreen)
+{
+ FatalError ("winRealizeInstalledPaletteNativeGDI\n");
+ return TRUE;
+}
+
+
+static Bool
+winInstallColormapNativeGDI (ColormapPtr pColormap)
+{
+ FatalError ("winInstallColormapNativeGDI\n");
+ return TRUE;
+}
+
+
+static Bool
+winStoreColorsNativeGDI (ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs)
+{
+ FatalError ("winStoreColorsNativeGDI\n");
+ return TRUE;
+}
+
+
+static Bool
+winCreateColormapNativeGDI (ColormapPtr pColormap)
+{
+ FatalError ("winCreateColormapNativeGDI\n");
+ return TRUE;
+}
+
+
+static Bool
+winDestroyColormapNativeGDI (ColormapPtr pColormap)
+{
+ FatalError ("winDestroyColormapNativeGDI\n");
+ return TRUE;
+}
+
+
+/* Set engine specific funtions */
+Bool
+winSetEngineFunctionsNativeGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBNativeGDI;
+ pScreenPriv->pwinShadowUpdate = winShadowUpdateNativeGDI;
+ pScreenPriv->pwinCloseScreen = winCloseScreenNativeGDI;
+ pScreenPriv->pwinInitVisuals = winInitVisualsNativeGDI;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeNativeGDI;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitNativeGDI;
+ /*
+ * WARNING: Do not set the BltExposedRegions procedure pointer to anything
+ * other than NULL until a working painting procedure is in place.
+ * Else, winWindowProc will get stuck in an infinite loop because
+ * Windows expects the BeginPaint and EndPaint functions to be called
+ * before a WM_PAINT message can be removed from the queue. We are
+ * using NULL here as a signal for winWindowProc that it should
+ * not signal that the WM_PAINT message has been processed.
+ */
+ pScreenPriv->pwinBltExposedRegions = NULL;
+ pScreenPriv->pwinActivateApp = winActivateAppNativeGDI;
+ pScreenPriv->pwinRedrawScreen = winRedrawScreenNativeGDI;
+ pScreenPriv->pwinRealizeInstalledPalette =
+ winRealizeInstalledPaletteNativeGDI;
+ pScreenPriv->pwinInstallColormap = winInstallColormapNativeGDI;
+ pScreenPriv->pwinStoreColors = winStoreColorsNativeGDI;
+ pScreenPriv->pwinCreateColormap = winCreateColormapNativeGDI;
+ pScreenPriv->pwinDestroyColormap = winDestroyColormapNativeGDI;
+ pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winpfbdd.c b/nx-X11/programs/Xserver/hw/xwin/winpfbdd.c
new file mode 100644
index 000000000..d9d69039d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winpfbdd.c
@@ -0,0 +1,685 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winpfbdd.c,v 1.17 2002/10/17 08:18:22 alanh Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * External symbols
+ */
+
+extern const GUID _IID_IDirectDraw2;
+extern HWND g_hDlgExit;
+
+
+/*
+ * Local function prototypes
+ */
+
+static Bool
+winAllocateFBPrimaryDD (ScreenPtr pScreen);
+
+static Bool
+winCloseScreenPrimaryDD (int nIndex, ScreenPtr pScreen);
+
+static Bool
+winInitVisualsPrimaryDD (ScreenPtr pScreen);
+
+static Bool
+winAdjustVideoModePrimaryDD (ScreenPtr pScreen);
+
+static Bool
+winActivateAppPrimaryDD (ScreenPtr pScreen);
+
+static Bool
+winHotKeyAltTabPrimaryDD (ScreenPtr pScreen);
+
+
+/*
+ * Create a DirectDraw primary surface
+ */
+
+static Bool
+winAllocateFBPrimaryDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC ddsd;
+ DDSURFACEDESC *pddsdPrimary = NULL;
+ DDSURFACEDESC *pddsdOffscreen = NULL;
+ RECT rcClient;
+
+ ErrorF ("winAllocateFBPrimaryDD\n");
+
+ /* Get client area location in screen coords */
+ GetClientRect (pScreenPriv->hwndScreen, &rcClient);
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&rcClient, 2);
+
+ /* Create a DirectDraw object, store the address at lpdd */
+ ddrval = (*g_fpDirectDrawCreate) (NULL, &pScreenPriv->pdd, NULL);
+ if (ddrval != DD_OK)
+ FatalError ("winAllocateFBPrimaryDD - Could not start DirectDraw\n");
+
+ /* Get a DirectDraw2 interface pointer */
+ ddrval = IDirectDraw_QueryInterface (pScreenPriv->pdd,
+ &IID_IDirectDraw2,
+ (LPVOID*) &pScreenPriv->pdd2);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Failed DD2 query: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+
+ ErrorF ("winAllocateFBPrimaryDD - Created and initialized DD\n");
+
+ /* Are we windowed or fullscreen? */
+ if (pScreenInfo->fFullScreen)
+ {
+ /* Full screen mode */
+ ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
+ pScreenPriv->hwndScreen,
+ DDSCL_FULLSCREEN
+ | DDSCL_EXCLUSIVE);
+ if (FAILED (ddrval))
+ FatalError ("winAllocateFBPrimaryDD - Could not set "
+ "cooperative level\n");
+
+ /* Change the video mode to the mode requested */
+ ddrval = IDirectDraw2_SetDisplayMode (pScreenPriv->pdd2,
+ pScreenInfo->dwWidth,
+ pScreenInfo->dwHeight,
+ pScreenInfo->dwBPP,
+ pScreenInfo->dwRefreshRate,
+ 0);
+ if (FAILED (ddrval))
+ FatalError ("winAllocateFBPrimaryDD - Could not set "
+ "full screen display mode\n");
+ }
+ else
+ {
+ /* Windowed mode */
+ ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
+ pScreenPriv->hwndScreen,
+ DDSCL_NORMAL);
+ if (FAILED (ddrval))
+ FatalError ("winAllocateFBPrimaryDD - Could not set "
+ "cooperative level\n");
+ }
+
+ /* Describe the primary surface */
+ ZeroMemory (&ddsd, sizeof (ddsd));
+ ddsd.dwSize = sizeof (ddsd);
+ ddsd.dwFlags = DDSD_CAPS;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+
+ /* Create the primary surface */
+ ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
+ &ddsd,
+ &pScreenPriv->pddsPrimary,
+ NULL);
+ if (FAILED (ddrval))
+ FatalError ("winAllocateFBPrimaryDD - Could not create primary "
+ "surface %08x\n", (unsigned int) ddrval);
+
+ ErrorF ("winAllocateFBPrimaryDD - Created primary\n");
+
+ /* Allocate a DD surface description for our screen privates */
+ pddsdPrimary = pScreenPriv->pddsdPrimary
+ = malloc (sizeof (DDSURFACEDESC));
+ if (pddsdPrimary == NULL)
+ FatalError ("winAllocateFBPrimaryDD - Could not allocate surface "
+ "description memory\n");
+ ZeroMemory (pddsdPrimary, sizeof (*pddsdPrimary));
+ pddsdPrimary->dwSize = sizeof (*pddsdPrimary);
+
+ /* Describe the offscreen surface to be created */
+ /*
+ * NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
+ * as drawing, locking, and unlocking take forever
+ * with video memory surfaces. In addition,
+ * video memory is a somewhat scarce resource,
+ * so you shouldn't be allocating video memory when
+ * you have the option of using system memory instead.
+ */
+ ZeroMemory (&ddsd, sizeof (ddsd));
+ ddsd.dwSize = sizeof (ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
+ ddsd.dwHeight = pScreenInfo->dwHeight;
+ ddsd.dwWidth = pScreenInfo->dwWidth;
+
+ /* Create the shadow surface */
+ ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
+ &ddsd,
+ &pScreenPriv->pddsOffscreen,
+ NULL);
+ if (ddrval != DD_OK)
+ FatalError ("winAllocateFBPrimaryDD - Could not create shadow "
+ "surface\n");
+
+ ErrorF ("winAllocateFBPrimaryDD - Created offscreen\n");
+
+ /* Allocate a DD surface description for our screen privates */
+ pddsdOffscreen = pScreenPriv->pddsdOffscreen
+ = malloc (sizeof (DDSURFACEDESC));
+ if (pddsdOffscreen == NULL)
+ FatalError ("winAllocateFBPrimaryDD - Could not allocate surface "
+ "description memory\n");
+ ZeroMemory (pddsdOffscreen, sizeof (*pddsdOffscreen));
+ pddsdOffscreen->dwSize = sizeof (*pddsdOffscreen);
+
+ ErrorF ("winAllocateFBPrimaryDD - Locking primary\n");
+
+ /* Lock the primary surface */
+ ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsPrimary,
+ pScreenInfo->fFullScreen ? NULL:&rcClient,
+ pddsdPrimary,
+ DDLOCK_WAIT,
+ NULL);
+ if (ddrval != DD_OK || pddsdPrimary->lpSurface == NULL)
+ FatalError ("winAllocateFBPrimaryDD - Could not lock "
+ "primary surface\n");
+
+ ErrorF ("winAllocateFBPrimaryDD - Locked primary\n");
+
+ /* We don't know how to deal with anything other than RGB */
+ if (!(pddsdPrimary->ddpfPixelFormat.dwFlags & DDPF_RGB))
+ FatalError ("winAllocateFBPrimaryDD - Color format other than RGB\n");
+
+ /* Grab the pitch from the surface desc */
+ pScreenInfo->dwStride = (pddsdPrimary->u1.lPitch * 8)
+ / pScreenInfo->dwBPP;
+
+ /* Save the pointer to our surface memory */
+ pScreenInfo->pfb = pddsdPrimary->lpSurface;
+
+ /* Grab the color depth and masks from the surface description */
+ pScreenPriv->dwRedMask = pddsdPrimary->ddpfPixelFormat.u2.dwRBitMask;
+ pScreenPriv->dwGreenMask = pddsdPrimary->ddpfPixelFormat.u3.dwGBitMask;
+ pScreenPriv->dwBlueMask = pddsdPrimary->ddpfPixelFormat.u4.dwBBitMask;
+
+ ErrorF ("winAllocateFBPrimaryDD - Returning\n");
+
+ return TRUE;
+}
+
+
+/*
+ * Call the wrapped CloseScreen function.
+ *
+ * Free our resources and private structures.
+ */
+
+static Bool
+winCloseScreenPrimaryDD (int nIndex, ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ Bool fReturn;
+
+ ErrorF ("winCloseScreenPrimaryDD - Freeing screen resources\n");
+
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
+
+ /* Call the wrapped CloseScreen procedure */
+ WIN_UNWRAP(CloseScreen);
+ fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
+
+ /* Delete the window property */
+ RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
+
+ /* Free the offscreen surface, if there is one */
+ if (pScreenPriv->pddsOffscreen)
+ {
+ IDirectDrawSurface2_Unlock (pScreenPriv->pddsOffscreen, NULL);
+ IDirectDrawSurface2_Release (pScreenPriv->pddsOffscreen);
+ pScreenPriv->pddsOffscreen = NULL;
+ }
+
+ /* Release the primary surface, if there is one */
+ if (pScreenPriv->pddsPrimary)
+ {
+ IDirectDrawSurface2_Unlock (pScreenPriv->pddsPrimary, NULL);
+ IDirectDrawSurface2_Release (pScreenPriv->pddsPrimary);
+ pScreenPriv->pddsPrimary = NULL;
+ }
+
+ /* Free the DirectDraw object, if there is one */
+ if (pScreenPriv->pdd)
+ {
+ IDirectDraw2_RestoreDisplayMode (pScreenPriv->pdd);
+ IDirectDraw2_Release (pScreenPriv->pdd);
+ pScreenPriv->pdd = NULL;
+ }
+
+ /* Delete tray icon, if we have one */
+ if (!pScreenInfo->fNoTrayIcon)
+ winDeleteNotifyIcon (pScreenPriv);
+
+ /* Free the exit confirmation dialog box, if it exists */
+ if (g_hDlgExit != NULL)
+ {
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+ }
+
+ /* Kill our window */
+ if (pScreenPriv->hwndScreen)
+ {
+ DestroyWindow (pScreenPriv->hwndScreen);
+ pScreenPriv->hwndScreen = NULL;
+ }
+
+ /* Kill our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
+
+ /* Invalidate the ScreenInfo's fb pointer */
+ pScreenInfo->pfb = NULL;
+
+ /* Free the screen privates for this screen */
+ free ((pointer) pScreenPriv);
+
+ return fReturn;
+}
+
+
+/*
+ * Tell mi what sort of visuals we need.
+ *
+ * Generally we only need one visual, as our screen can only
+ * handle one format at a time, I believe. You may want
+ * to verify that last sentence.
+ */
+
+static Bool
+winInitVisualsPrimaryDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ DWORD dwRedBits, dwGreenBits, dwBlueBits;
+
+ /* Count the number of ones in each color mask */
+ dwRedBits = winCountBits (pScreenPriv->dwRedMask);
+ dwGreenBits = winCountBits (pScreenPriv->dwGreenMask);
+ dwBlueBits = winCountBits (pScreenPriv->dwBlueMask);
+
+ /* Store the maximum number of ones in a color mask as the bitsPerRGB */
+ if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwRedBits;
+ else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwGreenBits;
+ else
+ pScreenPriv->dwBitsPerRGB = dwBlueBits;
+
+ ErrorF ("winInitVisualsPrimaryDD - Masks: %08x %08x %08x bpRGB: %d\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask,
+ (int) pScreenPriv->dwBitsPerRGB);
+
+ /* Create a single visual according to the Windows screen depth */
+ switch (pScreenInfo->dwDepth)
+ {
+ case 24:
+ case 16:
+ case 15:
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ TrueColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsPrimaryDD - "
+ "miSetVisualTypesAndMasks failed\n");
+ return FALSE;
+ }
+ break;
+
+ case 8:
+#if CYGDEBUG
+ winDebug ("winInitVisuals - Calling miSetVisualTypesAndMasks\n");
+#endif /* CYGDEBUG */
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ PseudoColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ PseudoColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsPrimaryDD - "
+ "miSetVisualTypesAndMasks failed\n");
+ return FALSE;
+ }
+#if CYGDEBUG
+ winDebug ("winInitVisualsPrimaryDD - Returned from "
+ "miSetVisualTypesAndMasks\n");
+#endif /* CYGDEBUG */
+ break;
+
+ default:
+ ErrorF ("winInitVisualsPrimaryDD - Unknown screen depth\n");
+ return FALSE;
+ }
+
+ ErrorF ("winInitVisualsPrimaryDD - Returning\n");
+
+ return TRUE;
+}
+
+
+static Bool
+winAdjustVideoModePrimaryDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc = NULL;
+ DWORD dwBPP;
+
+ /* We're in serious trouble if we can't get a DC */
+ hdc = GetDC (NULL);
+ if (hdc == NULL)
+ {
+ ErrorF ("winAdjustVideoModePrimaryDD - GetDC failed\n");
+ return FALSE;
+ }
+
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+
+ /* DirectDraw can only change the depth in fullscreen mode */
+ if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
+ {
+ /* No -depth parameter passed, let the user know the depth being used */
+ ErrorF ("winAdjustVideoModePrimaryDD - Using Windows display "
+ "depth of %d bits per pixel\n", (int) dwBPP);
+
+ /* Use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+ else if (pScreenInfo->fFullScreen
+ && pScreenInfo->dwBPP != dwBPP)
+ {
+ /* FullScreen, and GDI depth differs from -depth parameter */
+ ErrorF ("winAdjustVideoModePrimaryDD - FullScreen, using command "
+ "line depth: %d\n", (int) pScreenInfo->dwBPP);
+ }
+ else if (dwBPP != pScreenInfo->dwBPP)
+ {
+ /* Windowed, and GDI depth differs from -depth parameter */
+ ErrorF ("winAdjustVideoModePrimaryDD - Windowed, command line "
+ "depth: %d, using depth: %d\n",
+ (int) pScreenInfo->dwBPP, (int) dwBPP);
+
+ /* We'll use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+
+ return TRUE;
+}
+
+
+/*
+ * We need to blit our offscreen fb to
+ * the screen when we are activated, and we need to point
+ * the fb code back to the primary surface memory.
+ */
+
+static Bool
+winActivateAppPrimaryDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcSrc, rcClient;
+ HRESULT ddrval = DD_OK;
+
+ /* Check for errors */
+ if (pScreenPriv == NULL
+ || pScreenPriv->pddsPrimary == NULL
+ || pScreenPriv->pddsOffscreen == NULL)
+ return FALSE;
+
+ /* Check for do-nothing */
+ if (!pScreenPriv->fActive)
+ return TRUE;
+
+ /* We are activating */
+ ddrval = IDirectDrawSurface2_IsLost (pScreenPriv->pddsOffscreen);
+ if (ddrval == DD_OK)
+ {
+ IDirectDrawSurface2_Unlock (pScreenPriv->pddsOffscreen,
+ NULL);
+ /*
+ * We don't check for an error from Unlock, because it
+ * doesn't matter if the Unlock failed.
+ */
+ }
+
+ /* Restore both surfaces, just cause I like it that way */
+ IDirectDrawSurface2_Restore (pScreenPriv->pddsOffscreen);
+ IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
+
+ /* Get client area in screen coords */
+ GetClientRect (pScreenPriv->hwndScreen, &rcClient);
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&rcClient, 2);
+
+ /* Setup a source rectangle */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
+ &rcClient,
+ pScreenPriv->pddsOffscreen,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+ if (ddrval != DD_OK)
+ FatalError ("winActivateAppPrimaryDD () - Failed blitting offscreen "
+ "surface to primary surface %08x\n", (unsigned int) ddrval);
+
+ /* Lock the primary surface */
+ ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsPrimary,
+ &rcClient,
+ pScreenPriv->pddsdPrimary,
+ DDLOCK_WAIT,
+ NULL);
+ if (ddrval != DD_OK
+ || pScreenPriv->pddsdPrimary->lpSurface == NULL)
+ FatalError ("winActivateAppPrimaryDD () - Could not lock "
+ "primary surface\n");
+
+ /* Notify FB of the new memory pointer */
+ winUpdateFBPointer (pScreen,
+ pScreenPriv->pddsdPrimary->lpSurface);
+
+ /*
+ * Register the Alt-Tab combo as a hotkey so we can copy
+ * the primary framebuffer before the display mode changes
+ */
+ RegisterHotKey (pScreenPriv->hwndScreen, 1, MOD_ALT, 9);
+
+ return TRUE;
+}
+
+
+/*
+ * Handle the Alt+Tab hotkey.
+ *
+ * We need to save the primary fb to an offscreen fb when
+ * we get deactivated, and point the fb code at the offscreen
+ * fb for the duration of the deactivation.
+ */
+
+static Bool
+winHotKeyAltTabPrimaryDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcClient, rcSrc;
+ HRESULT ddrval = DD_OK;
+
+ ErrorF ("\nwinHotKeyAltTabPrimaryDD\n\n");
+
+ /* Alt+Tab was pressed, we will lose focus very soon */
+ pScreenPriv->fActive = FALSE;
+
+ /* Check for error conditions */
+ if (pScreenPriv->pddsPrimary == NULL
+ || pScreenPriv->pddsOffscreen == NULL)
+ return FALSE;
+
+ /* Get client area in screen coords */
+ GetClientRect (pScreenPriv->hwndScreen, &rcClient);
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&rcClient, 2);
+
+ /* Did we loose the primary surface? */
+ ddrval = IDirectDrawSurface2_IsLost (pScreenPriv->pddsPrimary);
+ if (ddrval == DD_OK)
+ {
+ ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsPrimary,
+ NULL);
+ if (FAILED (ddrval))
+ FatalError ("winHotKeyAltTabPrimaryDD - Failed unlocking primary "
+ "surface\n");
+ }
+
+ /* Setup a source rectangle */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Blit the primary surface to the offscreen surface */
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsOffscreen,
+ NULL, /* should be rcDest */
+ pScreenPriv->pddsPrimary,
+ NULL,
+ DDBLT_WAIT,
+ NULL);
+ if (ddrval == DDERR_SURFACELOST)
+ {
+ IDirectDrawSurface2_Restore (pScreenPriv->pddsOffscreen);
+ IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
+
+ /* Blit the primary surface to the offscreen surface */
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsOffscreen,
+ NULL,
+ pScreenPriv->pddsPrimary,
+ NULL,
+ DDBLT_WAIT,
+ NULL);
+ if (FAILED (ddrval))
+ FatalError ("winHotKeyAltTabPrimaryDD - Failed blitting primary "
+ "surface to offscreen surface: %08x\n",
+ (unsigned int) ddrval);
+ }
+ else
+ {
+ FatalError ("winHotKeyAltTabPrimaryDD - Unknown error from "
+ "Blt: %08dx\n", (unsigned int) ddrval);
+ }
+
+ /* Lock the offscreen surface */
+ ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsOffscreen,
+ NULL,
+ pScreenPriv->pddsdOffscreen,
+ DDLOCK_WAIT,
+ NULL);
+ if (ddrval != DD_OK
+ || pScreenPriv->pddsdPrimary->lpSurface == NULL)
+ FatalError ("winHotKeyAltTabPrimaryDD - Could not lock "
+ "offscreen surface\n");
+
+ /* Notify FB of the new memory pointer */
+ winUpdateFBPointer (pScreen,
+ pScreenPriv->pddsdOffscreen->lpSurface);
+
+ /* Unregister our hotkey */
+ UnregisterHotKey (pScreenPriv->hwndScreen, 1);
+
+ return TRUE;
+}
+
+
+/* Set engine specific functions */
+Bool
+winSetEngineFunctionsPrimaryDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBPrimaryDD;
+ pScreenPriv->pwinShadowUpdate
+ = (winShadowUpdateProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinCloseScreen = winCloseScreenPrimaryDD;
+ pScreenPriv->pwinInitVisuals = winInitVisualsPrimaryDD;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModePrimaryDD;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions
+ = (winBltExposedRegionsProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinActivateApp = winActivateAppPrimaryDD;
+ pScreenPriv->pwinHotKeyAltTab = winHotKeyAltTabPrimaryDD;
+#ifdef XWIN_MULTIWINDOW
+ pScreenPriv->pwinFinishCreateWindowsWindow =
+ (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA;
+#endif
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winpixmap.c b/nx-X11/programs/Xserver/hw/xwin/winpixmap.c
new file mode 100644
index 000000000..2780a3921
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winpixmap.c
@@ -0,0 +1,242 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: drewry, september 1986
+ * Harold L Hunt II
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winpixmap.c,v 1.10 2002/10/17 08:18:24 alanh Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * References to external symbols
+ */
+
+extern int g_iPixmapPrivateIndex;
+
+
+/*
+ * Local prototypes
+ */
+
+#if 0
+static void
+winXRotatePixmapNativeGDI (PixmapPtr pPix, int rw);
+
+static void
+winYRotatePixmapNativeGDI (PixmapPtr pPix, int rh);
+
+static void
+winCopyRotatePixmapNativeGDI (PixmapPtr psrcPix, PixmapPtr *ppdstPix,
+ int xrot, int yrot);
+#endif
+
+
+/* See Porting Layer Definition - p. 34 */
+/* See mfb/mfbpixmap.c - mfbCreatePixmap() */
+PixmapPtr
+winCreatePixmapNativeGDI (ScreenPtr pScreen,
+ int iWidth, int iHeight,
+ int iDepth)
+{
+ winPrivPixmapPtr pPixmapPriv = NULL;
+ PixmapPtr pPixmap = NULL;
+
+ /* Allocate pixmap memory */
+ pPixmap = AllocatePixmap (pScreen, 0);
+ if (!pPixmap)
+ {
+ ErrorF ("winCreatePixmapNativeGDI () - Couldn't allocate a pixmap\n");
+ return NullPixmap;
+ }
+
+#if CYGDEBUG
+ winDebug ("winCreatePixmap () - w %d h %d d %d bw %d\n",
+ iWidth, iHeight, iDepth,
+ PixmapBytePad (iWidth, iDepth));
+#endif
+
+ /* Setup pixmap values */
+ pPixmap->drawable.type = DRAWABLE_PIXMAP;
+ pPixmap->drawable.class = 0;
+ pPixmap->drawable.pScreen = pScreen;
+ pPixmap->drawable.depth = iDepth;
+ pPixmap->drawable.bitsPerPixel = BitsPerPixel (iDepth);
+ pPixmap->drawable.id = 0;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pPixmap->drawable.x = 0;
+ pPixmap->drawable.y = 0;
+ pPixmap->drawable.width = iWidth;
+ pPixmap->drawable.height = iHeight;
+ pPixmap->devKind = 0;
+ pPixmap->refcnt = 1;
+ pPixmap->devPrivate.ptr = NULL;
+
+ /* Pixmap privates are allocated by AllocatePixmap */
+ pPixmapPriv = winGetPixmapPriv (pPixmap);
+
+ /* Initialize pixmap privates */
+ pPixmapPriv->hBitmap = NULL;
+ pPixmapPriv->hdcSelected = NULL;
+ pPixmapPriv->pbBits = NULL;
+ pPixmapPriv->dwScanlineBytes = PixmapBytePad (iWidth, iDepth);
+
+ /* Check for zero width or height pixmaps */
+ if (iWidth == 0 || iHeight == 0)
+ {
+ /* Don't allocate a real pixmap, just set fields and return */
+ return pPixmap;
+ }
+
+ /* Create a DIB for the pixmap */
+ pPixmapPriv->hBitmap = winCreateDIBNativeGDI (iWidth, iHeight, iDepth,
+ &pPixmapPriv->pbBits,
+ (BITMAPINFO **) &pPixmapPriv->pbmih);
+
+#if CYGDEBUG
+ winDebug ("winCreatePixmap () - Created a pixmap %08x, %dx%dx%d, for " \
+ "screen: %08x\n",
+ pPixmapPriv->hBitmap, iWidth, iHeight, iDepth, pScreen);
+#endif
+
+ return pPixmap;
+}
+
+
+/*
+ * See Porting Layer Definition - p. 35
+ *
+ * See mfb/mfbpixmap.c - mfbDestroyPixmap()
+ */
+
+Bool
+winDestroyPixmapNativeGDI (PixmapPtr pPixmap)
+{
+ winPrivPixmapPtr pPixmapPriv = NULL;
+
+#if CYGDEBUG
+ winDebug ("winDestroyPixmapNativeGDI ()\n");
+#endif
+
+ /* Bail early if there is not a pixmap to destroy */
+ if (pPixmap == NULL)
+ {
+ ErrorF ("winDestroyPixmapNativeGDI () - No pixmap to destroy\n");
+ return TRUE;
+ }
+
+ /* Get a handle to the pixmap privates */
+ pPixmapPriv = winGetPixmapPriv (pPixmap);
+
+#if CYGDEBUG
+ winDebug ("winDestroyPixmapNativeGDI - pPixmapPriv->hBitmap: %08x\n",
+ pPixmapPriv->hBitmap);
+#endif
+
+ /* Decrement reference count, return if nonzero */
+ --pPixmap->refcnt;
+ if (pPixmap->refcnt != 0)
+ return TRUE;
+
+ /* Free GDI bitmap */
+ if (pPixmapPriv->hBitmap) DeleteObject (pPixmapPriv->hBitmap);
+
+ /* Free the bitmap info header memory */
+ if (pPixmapPriv->pbmih != NULL)
+ {
+ free (pPixmapPriv->pbmih);
+ pPixmapPriv->pbmih = NULL;
+ }
+
+ /* Free the pixmap memory */
+ free (pPixmap);
+ pPixmap = NULL;
+
+ return TRUE;
+}
+
+
+/*
+ * Not used yet
+ */
+
+Bool
+winModifyPixmapHeaderNativeGDI (PixmapPtr pPixmap,
+ int iWidth, int iHeight,
+ int iDepth,
+ int iBitsPerPixel,
+ int devKind,
+ pointer pPixData)
+{
+ FatalError ("winModifyPixmapHeaderNativeGDI ()\n");
+ return TRUE;
+}
+
+
+#if 0
+/*
+ * Not used yet.
+ * See cfb/cfbpixmap.c
+ */
+
+static void
+winXRotatePixmapNativeGDI (PixmapPtr pPix, int rw)
+{
+ ErrorF ("winXRotatePixmap()\n");
+ /* fill in this function, look at CFB */
+}
+
+
+/*
+ * Not used yet.
+ * See cfb/cfbpixmap.c
+ */
+static void
+winYRotatePixmapNativeGDI (PixmapPtr pPix, int rh)
+{
+ ErrorF ("winYRotatePixmap()\n");
+ /* fill in this function, look at CFB */
+}
+
+
+/*
+ * Not used yet.
+ * See cfb/cfbpixmap.c
+ */
+
+static void
+winCopyRotatePixmapNativeGDI (PixmapPtr psrcPix, PixmapPtr *ppdstPix,
+ int xrot, int yrot)
+{
+ ErrorF ("winCopyRotatePixmap()\n");
+ /* fill in this function, look at CFB */
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/winpntwin.c b/nx-X11/programs/Xserver/hw/xwin/winpntwin.c
new file mode 100644
index 000000000..caee712c9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winpntwin.c
@@ -0,0 +1,47 @@
+/*
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+/* See Porting Layer Definition - p. 39
+ * Sometimes implemented as two functions:
+ * PaintWindowBackground (nKind = PW_BACKGROUND)
+ * PaintWindowBorder (nKind = PW_BORDER)
+ */
+void
+winPaintWindowNativeGDI (WindowPtr pWin,
+ RegionPtr pRegion,
+ int nKind)
+{
+ ErrorF ("winPaintWindow()\n");
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winpolyline.c b/nx-X11/programs/Xserver/hw/xwin/winpolyline.c
new file mode 100644
index 000000000..db9dd345b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winpolyline.c
@@ -0,0 +1,57 @@
+/*
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+/* See Porting Layer Definition - p. 50 */
+void
+winPolyLineNativeGDI (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ppt)
+{
+ switch (pGC->lineStyle)
+ {
+ case LineSolid:
+ if (pGC->lineWidth == 0)
+ return miZeroLine (pDrawable, pGC, mode, npt, ppt);
+ else
+ miWideLine (pDrawable, pGC, mode, npt, ppt);
+ break;
+ case LineOnOffDash:
+ case LineDoubleDash:
+ miWideDash (pDrawable, pGC, mode, npt, ppt);
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winprefs.c b/nx-X11/programs/Xserver/hw/xwin/winprefs.c
new file mode 100644
index 000000000..bbe04bd7b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winprefs.c
@@ -0,0 +1,799 @@
+/*
+ * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from the XFree86 Project.
+ *
+ * Authors: Earle F. Philhower, III
+ */
+/* $XFree86: $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef __CYGWIN__
+#include <sys/resource.h>
+#endif
+#include "win.h"
+
+#include <X11/Xwindows.h>
+#include <shellapi.h>
+
+#include "winprefs.h"
+#include "winmultiwindowclass.h"
+
+/* Where will the custom menu commands start counting from? */
+#define STARTMENUID WM_USER
+
+/* External global variables */
+#ifdef XWIN_MULTIWINDOW
+extern DWORD g_dwCurrentThreadID;
+#endif
+
+extern const char *winGetBaseDir(void);
+
+/* From winmultiwindowflex.l, the real parser */
+extern void parse_file (FILE *fp);
+
+/* From winprefyacc.y, the pref structure loaded by the parser */
+extern WINPREFS pref;
+
+/* The global X default icon */
+extern HICON g_hIconX;
+extern HICON g_hSmallIconX;
+
+/* Currently in use command ID, incremented each new menu item created */
+static int g_cmdid = STARTMENUID;
+
+
+/* Defined in DIX */
+extern char *display;
+
+/* Local function to handle comma-ified icon names */
+static HICON
+LoadImageComma (char *fname, int sx, int sy, int flags);
+
+
+/*
+ * Creates or appends a menu from a MENUPARSED structure
+ */
+static HMENU
+MakeMenu (char *name,
+ HMENU editMenu,
+ int editItem)
+{
+ int i;
+ int item;
+ MENUPARSED *m;
+ HMENU hmenu, hsub;
+
+ for (i=0; i<pref.menuItems; i++)
+ {
+ if (!strcmp(name, pref.menu[i].menuName))
+ break;
+ }
+
+ /* Didn't find a match, bummer */
+ if (i==pref.menuItems)
+ {
+ ErrorF("MakeMenu: Can't find menu %s\n", name);
+ return NULL;
+ }
+
+ m = &(pref.menu[i]);
+
+ if (editMenu)
+ {
+ hmenu = editMenu;
+ item = editItem;
+ }
+ else
+ {
+ hmenu = CreatePopupMenu();
+ if (!hmenu)
+ {
+ ErrorF("MakeMenu: Unable to CreatePopupMenu() %s\n", name);
+ return NULL;
+ }
+ item = 0;
+ }
+
+ /* Add the menu items */
+ for (i=0; i<m->menuItems; i++)
+ {
+ /* Only assign IDs one time... */
+ if ( m->menuItem[i].commandID == 0 )
+ m->menuItem[i].commandID = g_cmdid++;
+
+ switch (m->menuItem[i].cmd)
+ {
+ case CMD_EXEC:
+ case CMD_ALWAYSONTOP:
+ case CMD_RELOAD:
+ InsertMenu (hmenu,
+ item,
+ MF_BYPOSITION|MF_ENABLED|MF_STRING,
+ m->menuItem[i].commandID,
+ m->menuItem[i].text);
+ break;
+
+ case CMD_SEPARATOR:
+ InsertMenu (hmenu,
+ item,
+ MF_BYPOSITION|MF_SEPARATOR,
+ 0,
+ NULL);
+ break;
+
+ case CMD_MENU:
+ /* Recursive! */
+ hsub = MakeMenu (m->menuItem[i].param, 0, 0);
+ if (hsub)
+ InsertMenu (hmenu,
+ item,
+ MF_BYPOSITION|MF_POPUP|MF_ENABLED|MF_STRING,
+ (UINT_PTR)hsub,
+ m->menuItem[i].text);
+ break;
+ }
+
+ /* If item==-1 (means to add at end of menu) don't increment) */
+ if (item>=0)
+ item++;
+ }
+
+ return hmenu;
+}
+
+
+#ifdef XWIN_MULTIWINDOW
+/*
+ * Callback routine that is executed once per window class.
+ * Removes or creates custom window settings depending on LPARAM
+ */
+static wBOOL CALLBACK
+ReloadEnumWindowsProc (HWND hwnd, LPARAM lParam)
+{
+ HICON hicon;
+ Window wid;
+
+ if (!hwnd) {
+ ErrorF("ReloadEnumWindowsProc: hwnd==NULL!\n");
+ return FALSE;
+ }
+
+ /* It's our baby, either clean or dirty it */
+ if (lParam==FALSE)
+ {
+ hicon = (HICON)GetClassLong(hwnd, GCL_HICON);
+
+ /* Unselect any icon in the class structure */
+ SetClassLong (hwnd, GCL_HICON, (LONG)LoadIcon (NULL, IDI_APPLICATION));
+
+ /* If it's generated on-the-fly, get rid of it, will regen */
+ winDestroyIcon (hicon);
+
+ hicon = (HICON)GetClassLong(hwnd, GCL_HICONSM);
+
+ /* Unselect any icon in the class structure */
+ SetClassLong (hwnd, GCL_HICONSM, 0);
+
+ /* If it's generated on-the-fly, get rid of it, will regen */
+ winDestroyIcon (hicon);
+
+ /* Remove any menu additions, use bRevert flag */
+ GetSystemMenu (hwnd, TRUE);
+
+ /* This window is now clean of our taint */
+ }
+ else
+ {
+ /* Make the icon default, dynamic, or from xwinrc */
+ SetClassLong (hwnd, GCL_HICON, (LONG)g_hIconX);
+ SetClassLong (hwnd, GCL_HICONSM, (LONG)g_hSmallIconX);
+ wid = (Window)GetProp (hwnd, WIN_WID_PROP);
+ if (wid)
+ winUpdateIcon (wid);
+ /* Update the system menu for this window */
+ SetupSysMenu ((unsigned long)hwnd);
+
+ /* That was easy... */
+ }
+
+ return TRUE;
+}
+#endif
+
+
+/*
+ * Removes any custom icons in classes, custom menus, etc.
+ * Frees all members in pref structure.
+ * Reloads the preferences file.
+ * Set custom icons and menus again.
+ */
+static void
+ReloadPrefs (void)
+{
+ int i;
+
+#ifdef XWIN_MULTIWINDOW
+ /* First, iterate over all windows replacing their icon with system */
+ /* default one and deleting any custom system menus */
+ EnumThreadWindows (g_dwCurrentThreadID, ReloadEnumWindowsProc, FALSE);
+#endif
+
+ /* Now, free/clear all info from our prefs structure */
+ for (i=0; i<pref.menuItems; i++)
+ free (pref.menu[i].menuItem);
+ free (pref.menu);
+ pref.menu = NULL;
+ pref.menuItems = 0;
+
+ pref.rootMenuName[0] = 0;
+
+ free (pref.sysMenu);
+ pref.sysMenuItems = 0;
+
+ pref.defaultSysMenuName[0] = 0;
+ pref.defaultSysMenuPos = 0;
+
+ pref.iconDirectory[0] = 0;
+ pref.defaultIconName[0] = 0;
+ pref.trayIconName[0] = 0;
+
+ for (i=0; i<pref.iconItems; i++)
+ if (pref.icon[i].hicon)
+ DestroyIcon ((HICON)pref.icon[i].hicon);
+ free (pref.icon);
+ pref.icon = NULL;
+ pref.iconItems = 0;
+
+ /* Free global default X icon */
+ if (g_hIconX)
+ DestroyIcon (g_hIconX);
+ if (g_hSmallIconX)
+ DestroyIcon (g_hSmallIconX);
+
+ /* Reset the custom command IDs */
+ g_cmdid = STARTMENUID;
+
+ /* Load the updated resource file */
+ LoadPreferences();
+
+ g_hIconX = NULL;
+ g_hSmallIconX = NULL;
+
+#ifdef XWIN_MULTIWINDOW
+ winInitGlobalIcons();
+#endif
+
+#ifdef XWIN_MULTIWINDOW
+ /* Rebuild the icons and menus */
+ EnumThreadWindows (g_dwCurrentThreadID, ReloadEnumWindowsProc, TRUE);
+#endif
+
+ /* Whew, done */
+}
+
+/*
+ * Check/uncheck the ALWAYSONTOP items in this menu
+ */
+void
+HandleCustomWM_INITMENU(unsigned long hwndIn,
+ unsigned long hmenuIn)
+{
+ HWND hwnd;
+ HMENU hmenu;
+ DWORD dwExStyle;
+ int i, j;
+
+ hwnd = (HWND)hwndIn;
+ hmenu = (HMENU)hmenuIn;
+ if (!hwnd || !hmenu)
+ return;
+
+ if (GetWindowLong (hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
+ dwExStyle = MF_BYCOMMAND | MF_CHECKED;
+ else
+ dwExStyle = MF_BYCOMMAND | MF_UNCHECKED;
+
+ for (i=0; i<pref.menuItems; i++)
+ for (j=0; j<pref.menu[i].menuItems; j++)
+ if (pref.menu[i].menuItem[j].cmd==CMD_ALWAYSONTOP)
+ CheckMenuItem (hmenu, pref.menu[i].menuItem[j].commandID, dwExStyle );
+
+}
+
+/*
+ * Searches for the custom WM_COMMAND command ID and performs action.
+ * Return TRUE if command is proccessed, FALSE otherwise.
+ */
+Bool
+HandleCustomWM_COMMAND (unsigned long hwndIn,
+ int command)
+{
+ HWND hwnd;
+ int i, j;
+ MENUPARSED *m;
+ DWORD dwExStyle;
+
+ hwnd = (HWND)hwndIn;
+
+ if (!command)
+ return FALSE;
+
+ for (i=0; i<pref.menuItems; i++)
+ {
+ m = &(pref.menu[i]);
+ for (j=0; j<m->menuItems; j++)
+ {
+ if (command==m->menuItem[j].commandID)
+ {
+ /* Match! */
+ switch(m->menuItem[j].cmd)
+ {
+#ifdef __CYGWIN__
+ case CMD_EXEC:
+ if (fork()==0)
+ {
+ struct rlimit rl;
+ unsigned long i;
+
+ /* Close any open descriptors except for STD* */
+ getrlimit (RLIMIT_NOFILE, &rl);
+ for (i = STDERR_FILENO+1; i < rl.rlim_cur; i++)
+ close(i);
+
+ /* Disassociate any TTYs */
+ setsid();
+
+ execl ("/bin/sh",
+ "/bin/sh",
+ "-c",
+ m->menuItem[j].param,
+ NULL);
+ exit (0);
+ }
+ else
+ return TRUE;
+ break;
+#endif
+ case CMD_ALWAYSONTOP:
+ if (!hwnd)
+ return FALSE;
+
+ /* Get extended window style */
+ dwExStyle = GetWindowLong (hwnd, GWL_EXSTYLE);
+
+ /* Handle topmost windows */
+ if (dwExStyle & WS_EX_TOPMOST)
+ SetWindowPos (hwnd,
+ HWND_NOTOPMOST,
+ 0, 0,
+ 0, 0,
+ SWP_NOSIZE | SWP_NOMOVE);
+ else
+ SetWindowPos (hwnd,
+ HWND_TOPMOST,
+ 0, 0,
+ 0, 0,
+ SWP_NOSIZE | SWP_NOMOVE);
+#if XWIN_MULTIWINDOW
+ /* Reflect the changed Z order */
+ winReorderWindowsMultiWindow ();
+#endif
+ return TRUE;
+
+ case CMD_RELOAD:
+ ReloadPrefs();
+ return TRUE;
+
+ default:
+ return FALSE;
+ }
+ } /* match */
+ } /* for j */
+ } /* for i */
+
+ return FALSE;
+}
+
+
+#ifdef XWIN_MULTIWINDOW
+/*
+ * Add the default or a custom menu depending on the class match
+ */
+void
+SetupSysMenu (unsigned long hwndIn)
+{
+ HWND hwnd;
+ HMENU sys;
+ int i;
+ WindowPtr pWin;
+ char *res_name, *res_class;
+
+ hwnd = (HWND)hwndIn;
+ if (!hwnd)
+ return;
+
+ pWin = GetProp (hwnd, WIN_WINDOW_PROP);
+
+ sys = GetSystemMenu (hwnd, FALSE);
+ if (!sys)
+ return;
+
+ if (pWin)
+ {
+ /* First see if there's a class match... */
+ if (winMultiWindowGetClassHint (pWin, &res_name, &res_class))
+ {
+ for (i=0; i<pref.sysMenuItems; i++)
+ {
+ if (!strcmp(pref.sysMenu[i].match, res_name) ||
+ !strcmp(pref.sysMenu[i].match, res_class) )
+ {
+ free(res_name);
+ free(res_class);
+
+ MakeMenu (pref.sysMenu[i].menuName, sys,
+ pref.sysMenu[i].menuPos==AT_START?0:-1);
+ return;
+ }
+ }
+
+ /* No match, just free alloc'd strings */
+ free(res_name);
+ free(res_class);
+ } /* Found wm_class */
+ } /* if pwin */
+
+ /* Fallback to system default */
+ if (pref.defaultSysMenuName[0])
+ {
+ if (pref.defaultSysMenuPos==AT_START)
+ MakeMenu (pref.defaultSysMenuName, sys, 0);
+ else
+ MakeMenu (pref.defaultSysMenuName, sys, -1);
+ }
+}
+#endif
+
+
+/*
+ * Possibly add a menu to the toolbar icon
+ */
+void
+SetupRootMenu (unsigned long hmenuRoot)
+{
+ HMENU root;
+
+ root = (HMENU)hmenuRoot;
+ if (!root)
+ return;
+
+ if (pref.rootMenuName[0])
+ {
+ MakeMenu(pref.rootMenuName, root, 0);
+ }
+}
+
+
+/*
+ * Check for and return an overridden default ICON specified in the prefs
+ */
+unsigned long
+winOverrideDefaultIcon(int size)
+{
+ HICON hicon;
+
+ if (pref.defaultIconName[0])
+ {
+ hicon = LoadImageComma (pref.defaultIconName, size, size, 0);
+ if (hicon==NULL)
+ ErrorF ("winOverrideDefaultIcon: LoadImageComma(%s) failed\n",
+ pref.defaultIconName);
+
+ return (unsigned long)hicon;
+ }
+
+ return 0;
+}
+
+
+/*
+ * Return the HICON to use in the taskbar notification area
+ */
+unsigned long
+winTaskbarIcon(void)
+{
+ HICON hicon;
+
+ hicon = 0;
+ /* First try and load an overridden, if success then return it */
+ if (pref.trayIconName[0])
+ {
+ hicon = LoadImageComma (pref.trayIconName,
+ GetSystemMetrics (SM_CXSMICON),
+ GetSystemMetrics (SM_CYSMICON),
+ 0 );
+ }
+
+ /* Otherwise return the default */
+ if (!hicon)
+ hicon = (HICON) LoadImage (g_hInstance,
+ MAKEINTRESOURCE(IDI_XWIN),
+ IMAGE_ICON,
+ GetSystemMetrics (SM_CXSMICON),
+ GetSystemMetrics (SM_CYSMICON),
+ 0);
+
+ return (unsigned long)hicon;
+}
+
+
+/*
+ * Parse a filename to extract an icon:
+ * If fname is exactly ",nnn" then extract icon from our resource
+ * else if it is "file,nnn" then extract icon nnn from that file
+ * else try to load it as an .ico file and if that fails return NULL
+ */
+static HICON
+LoadImageComma (char *fname, int sx, int sy, int flags)
+{
+ HICON hicon;
+ int index;
+ char file[PATH_MAX+NAME_MAX+2];
+
+ /* Some input error checking */
+ if (!fname || !fname[0])
+ return NULL;
+
+ index = 0;
+ hicon = NULL;
+
+ if (fname[0]==',')
+ {
+ /* It's the XWIN.EXE resource they want */
+ index = atoi (fname+1);
+ hicon = LoadImage (g_hInstance,
+ MAKEINTRESOURCE(index),
+ IMAGE_ICON,
+ sx,
+ sy,
+ flags);
+ }
+ else
+ {
+ file[0] = 0;
+ /* Prepend path if not given a "X:\" filename */
+ if ( !(fname[0] && fname[1]==':' && fname[2]=='\\') )
+ {
+ strcpy (file, pref.iconDirectory);
+ if (pref.iconDirectory[0])
+ if (fname[strlen(fname)-1]!='\\')
+ strcat (file, "\\");
+ }
+ strcat (file, fname);
+
+ if (strrchr (file, ','))
+ {
+ /* Specified as <fname>,<index> */
+
+ *(strrchr (file, ',')) = 0; /* End string at comma */
+ index = atoi (strrchr (fname, ',') + 1);
+ hicon = ExtractIcon (g_hInstance, file, index);
+ }
+ else
+ {
+ /* Just an .ico file... */
+
+ hicon = (HICON)LoadImage (NULL,
+ file,
+ IMAGE_ICON,
+ sx,
+ sy,
+ LR_LOADFROMFILE|flags);
+ }
+ }
+ return hicon;
+}
+
+/*
+ * Check for a match of the window class to one specified in the
+ * ICONS{} section in the prefs file, and load the icon from a file
+ */
+unsigned long
+winOverrideIcon (unsigned long longWin)
+{
+ WindowPtr pWin = (WindowPtr) longWin;
+ char *res_name, *res_class;
+ int i;
+ HICON hicon;
+ char *wmName;
+
+ if (pWin==NULL)
+ return 0;
+
+ /* If we can't find the class, we can't override from default! */
+ if (!winMultiWindowGetClassHint (pWin, &res_name, &res_class))
+ return 0;
+
+ winMultiWindowGetWMName (pWin, &wmName);
+
+ for (i=0; i<pref.iconItems; i++) {
+ if (!strcmp(pref.icon[i].match, res_name) ||
+ !strcmp(pref.icon[i].match, res_class) ||
+ (wmName && strstr(wmName, pref.icon[i].match)))
+ {
+ free (res_name);
+ free (res_class);
+ if (wmName)
+ free (wmName);
+
+ if (pref.icon[i].hicon)
+ return pref.icon[i].hicon;
+
+ hicon = LoadImageComma (pref.icon[i].iconFile, 0, 0, LR_DEFAULTSIZE);
+ if (hicon==NULL)
+ ErrorF ("winOverrideIcon: LoadImageComma(%s) failed\n",
+ pref.icon[i].iconFile);
+
+ pref.icon[i].hicon = (unsigned long)hicon;
+ return (unsigned long)hicon;
+ }
+ }
+
+ /* Didn't find the icon, fail gracefully */
+ free (res_name);
+ free (res_class);
+ if (wmName)
+ free (wmName);
+
+ return 0;
+}
+
+
+/*
+ * Should we free this icon or leave it in memory (is it part of our
+ * ICONS{} overrides)?
+ */
+int
+winIconIsOverride(unsigned hiconIn)
+{
+ HICON hicon;
+ int i;
+
+ hicon = (HICON)hiconIn;
+
+ if (!hicon)
+ return 0;
+
+ for (i=0; i<pref.iconItems; i++)
+ if ((HICON)pref.icon[i].hicon == hicon)
+ return 1;
+
+ return 0;
+}
+
+
+
+/*
+ * Try and open ~/.XWinrc and /usr/X11R6/lib/X11/system.XWinrc
+ * Load it into prefs structure for use by other functions
+ */
+void
+LoadPreferences ()
+{
+ char *home;
+ char fname[PATH_MAX+NAME_MAX+2];
+ FILE *prefFile;
+ char szDisplay[512];
+ char *szEnvDisplay;
+ int i, j;
+ char param[PARAM_MAX+1];
+ char *srcParam, *dstParam;
+
+ /* First, clear all preference settings */
+ memset (&pref, 0, sizeof(pref));
+ prefFile = NULL;
+
+ /* Now try and find a ~/.xwinrc file */
+ home = getenv ("HOME");
+ if (home)
+ {
+ strcpy (fname, home);
+ if (fname[strlen(fname)-1]!='/')
+ strcat (fname, "/");
+ strcat (fname, ".XWinrc");
+
+ prefFile = fopen (fname, "r");
+ if (prefFile)
+ ErrorF ("winPrefsLoadPreferences: %s\n", fname);
+ }
+
+ /* No home file found, check system default */
+ if (!prefFile)
+ {
+ char buffer[MAX_PATH];
+#ifdef RELOCATE_PROJECTROOT
+ snprintf(buffer, sizeof(buffer), "%s\\system.XWinrc", winGetBaseDir());
+#else
+ strncpy(buffer, PROJECTROOT"/lib/X11/system.XWinrc", sizeof(buffer));
+#endif
+ buffer[sizeof(buffer)-1] = 0;
+ prefFile = fopen (buffer, "r");
+ if (prefFile)
+ ErrorF ("winPrefsLoadPreferences: %s\n", buffer);
+ }
+
+ /* If we could open it, then read the settings and close it */
+ if (prefFile)
+ {
+ parse_file (prefFile);
+ fclose (prefFile);
+ }
+
+ /* Setup a DISPLAY environment variable, need to allocate on heap */
+ /* because putenv doesn't copy the argument... */
+ snprintf (szDisplay, 512, "DISPLAY=127.0.0.1:%s.0", display);
+ szEnvDisplay = (char *)(malloc (strlen(szDisplay)+1));
+ if (szEnvDisplay)
+ {
+ strcpy (szEnvDisplay, szDisplay);
+ putenv (szEnvDisplay);
+ }
+
+ /* Replace any "%display%" in menu commands with display string */
+ snprintf (szDisplay, 512, "127.0.0.1:%s.0", display);
+ for (i=0; i<pref.menuItems; i++)
+ {
+ for (j=0; j<pref.menu[i].menuItems; j++)
+ {
+ if (pref.menu[i].menuItem[j].cmd==CMD_EXEC)
+ {
+ srcParam = pref.menu[i].menuItem[j].param;
+ dstParam = param;
+ while (*srcParam) {
+ if (!strncmp(srcParam, "%display%", 9))
+ {
+ memcpy (dstParam, szDisplay, strlen(szDisplay));
+ dstParam += strlen(szDisplay);
+ srcParam += 9;
+ }
+ else
+ {
+ *dstParam = *srcParam;
+ dstParam++;
+ srcParam++;
+ }
+ }
+ *dstParam = 0;
+ strcpy (pref.menu[i].menuItem[j].param, param);
+ } /* cmd==cmd_exec */
+ } /* for all menuitems */
+ } /* for all menus */
+
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winprefs.h b/nx-X11/programs/Xserver/hw/xwin/winprefs.h
new file mode 100644
index 000000000..2e58e5e9d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winprefs.h
@@ -0,0 +1,163 @@
+#if !defined(WINPREFS_H)
+#define WINPREFS_H
+/*
+ * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from the XFree86 Project.
+ *
+ * Authors: Earle F. Philhower, III
+ */
+/* $XFree86: $ */
+
+/* Need Bool */
+#include <X11/Xdefs.h>
+/* Need TRUE */
+#include "misc.h"
+
+/* Need to know how long paths can be... */
+#include <limits.h>
+/* Xwindows redefines PATH_MAX to at least 1024 */
+#include <X11/Xwindows.h>
+
+#ifndef NAME_MAX
+#define NAME_MAX PATH_MAX
+#endif
+#define MENU_MAX 128 /* Maximum string length of a menu name or item */
+#define PARAM_MAX (4*PATH_MAX) /* Maximum length of a parameter to a MENU */
+
+
+/* Supported commands in a MENU {} statement */
+typedef enum MENUCOMMANDTYPE
+{
+ CMD_EXEC, /* /bin/sh -c the parameter */
+ CMD_MENU, /* Display a popup menu named param */
+ CMD_SEPARATOR, /* Menu separator */
+ CMD_ALWAYSONTOP, /* Toggle always-on-top mode */
+ CMD_RELOAD /* Reparse the .XWINRC file */
+} MENUCOMMANDTYPE;
+
+/* Where to place a system menu */
+typedef enum MENUPOSITION
+{
+ AT_START, /* Place menu at the top of the system menu */
+ AT_END /* Put it at the bottom of the menu (default) */
+} MENUPOSITION;
+
+/* Menu item definitions */
+typedef struct MENUITEM
+{
+ char text[MENU_MAX+1]; /* To be displayed in menu */
+ MENUCOMMANDTYPE cmd; /* What should it do? */
+ char param[PARAM_MAX+1]; /* Any parameters? */
+ unsigned long commandID; /* Windows WM_COMMAND ID assigned at runtime */
+} MENUITEM;
+
+/* A completely read in menu... */
+typedef struct MENUPARSED
+{
+ char menuName[MENU_MAX+1]; /* What's it called in the text? */
+ MENUITEM *menuItem; /* Array of items */
+ int menuItems; /* How big's the array? */
+} MENUPARSED;
+
+/* To map between a window and a system menu to add for it */
+typedef struct SYSMENUITEM
+{
+ char match[MENU_MAX+1]; /* String to look for to apply this sysmenu */
+ char menuName[MENU_MAX+1]; /* Which menu to show? Used to set *menu */
+ MENUPOSITION menuPos; /* Where to place it (ignored in root) */
+} SYSMENUITEM;
+
+/* To redefine icons for certain window types */
+typedef struct ICONITEM
+{
+ char match[MENU_MAX+1]; /* What string to search for? */
+ char iconFile[PATH_MAX+NAME_MAX+2]; /* Icon location, WIN32 path */
+ unsigned long hicon; /* LoadImage() result */
+} ICONITEM;
+
+typedef struct WINPREFS
+{
+ /* Menu information */
+ MENUPARSED *menu; /* Array of created menus */
+ int menuItems; /* How big? */
+
+ /* Taskbar menu settings */
+ char rootMenuName[MENU_MAX+1]; /* Menu for taskbar icon */
+
+ /* System menu addition menus */
+ SYSMENUITEM *sysMenu;
+ int sysMenuItems;
+
+ /* Which menu to add to unmatched windows? */
+ char defaultSysMenuName[MENU_MAX+1];
+ MENUPOSITION defaultSysMenuPos; /* Where to place it */
+
+ /* Icon information */
+ char iconDirectory[PATH_MAX+1]; /* Where do the .icos lie? (Win32 path) */
+ char defaultIconName[NAME_MAX+1]; /* Replacement for x.ico */
+ char trayIconName[NAME_MAX+1]; /* Replacement for tray icon */
+
+ ICONITEM *icon;
+ int iconItems;
+
+ /* Silent exit flag */
+ Bool fSilentExit;
+
+} WINPREFS;
+
+
+
+
+/* Functions */
+void
+LoadPreferences(void);
+
+void
+SetupRootMenu (unsigned long hmenuRoot);
+
+void
+SetupSysMenu (unsigned long hwndIn);
+
+void
+HandleCustomWM_INITMENU(unsigned long hwndIn,
+ unsigned long hmenuIn);
+
+Bool
+HandleCustomWM_COMMAND (unsigned long hwndIn,
+ int command);
+
+int
+winIconIsOverride (unsigned hiconIn);
+
+unsigned long
+winOverrideIcon (unsigned long longpWin);
+
+unsigned long
+winTaskbarIcon(void);
+
+unsigned long
+winOverrideDefaultIcon(int size);
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/winprefslex.l b/nx-X11/programs/Xserver/hw/xwin/winprefslex.l
new file mode 100644
index 000000000..a4c1abc3d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winprefslex.l
@@ -0,0 +1,116 @@
+%{ # -*- C -*-
+/*
+ * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from the XFree86 Project.
+ *
+ * Authors: Earle F. Philhower, III
+ */
+/* $XFree86: $ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "winprefsyacc.h"
+
+extern YYSTYPE yylval;
+extern char *yytext;
+extern int yyparse(void);
+
+extern void ErrorF (const char* /*f*/, ...);
+
+int yylineno;
+
+/* Copy the parsed string, must be free()d in yacc parser */
+static char *makestr(char *str)
+{
+ char *ptr;
+ ptr = (char*)malloc (strlen(str)+1);
+ if (!ptr)
+ {
+ ErrorF ("winMultiWindowLex:makestr() out of memory\n");
+ exit (-1);
+ }
+ strcpy(ptr, str);
+ return ptr;
+}
+
+%}
+
+%option yylineno
+
+%%
+\#.*[\r\n] { /* comment */ return NEWLINE; }
+\/\/.*[\r\n] { /* comment */ return NEWLINE; }
+[\r\n] { return NEWLINE; }
+[ \t]+ { /* ignore whitespace */ }
+MENU { return MENU; }
+ICONDIRECTORY { return ICONDIRECTORY; }
+DEFAULTICON { return DEFAULTICON; }
+ICONS { return ICONS; }
+ROOTMENU { return ROOTMENU; }
+DEFAULTSYSMENU { return DEFAULTSYSMENU; }
+SYSMENU { return SYSMENU; }
+SEPARATOR { return SEPARATOR; }
+ATSTART { return ATSTART; }
+ATEND { return ATEND; }
+EXEC { return EXEC; }
+ALWAYSONTOP { return ALWAYSONTOP; }
+DEBUG { return DEBUG; }
+RELOAD { return RELOAD; }
+TRAYICON { return TRAYICON; }
+SILENTEXIT { return SILENTEXIT; }
+"{" { return LB; }
+"}" { return RB; }
+"\""[^\"\r\n]+"\"" { yylval.sVal = makestr(yytext+1); \
+ yylval.sVal[strlen(yylval.sVal)-1] = 0; \
+ return STRING; }
+[^ \t\r\n]+ { yylval.sVal = makestr(yytext); \
+ return STRING; }
+%%
+
+/*
+ * Run-of-the mill requirement for yacc
+ */
+int
+yywrap ()
+{
+ return 1;
+}
+
+/*
+ * Run a file through the yacc parser
+ */
+void
+parse_file (FILE *file)
+{
+ if (!file)
+ return;
+
+ yylineno = 1;
+ yyin = file;
+ yyparse ();
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xwin/winprefsyacc.y b/nx-X11/programs/Xserver/hw/xwin/winprefsyacc.y
new file mode 100644
index 000000000..2a54ff28f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winprefsyacc.y
@@ -0,0 +1,353 @@
+%{
+/*
+ * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * from the XFree86 Project.
+ *
+ * Authors: Earle F. Philhower, III
+ */
+/* $XFree86: $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "winprefs.h"
+
+/* The following give better error messages in bison at the cost of a few KB */
+#define YYERROR_VERBOSE 1
+
+/* The global pref settings */
+WINPREFS pref;
+
+/* The working menu */
+static MENUPARSED menu;
+
+/* Functions for parsing the tokens into out structure */
+/* Defined at the end section of this file */
+
+static void SetIconDirectory (char *path);
+static void SetDefaultIcon (char *fname);
+static void SetRootMenu (char *menu);
+static void SetDefaultSysMenu (char *menu, int pos);
+static void SetTrayIcon (char *fname);
+
+static void OpenMenu(char *menuname);
+static void AddMenuLine(char *name, MENUCOMMANDTYPE cmd, char *param);
+static void CloseMenu(void);
+
+static void OpenIcons(void);
+static void AddIconLine(char *matchstr, char *iconfile);
+static void CloseIcons(void);
+
+static void OpenSysMenu(void);
+static void AddSysMenuLine(char *matchstr, char *menuname, int pos);
+static void CloseSysMenu(void);
+
+static int yyerror (char *s);
+
+extern void ErrorF (const char* /*f*/, ...);
+extern char *yytext;
+extern int yylex(void);
+
+%}
+
+%union {
+ char *sVal;
+ int iVal;
+}
+
+%token NEWLINE MENU LB RB ICONDIRECTORY DEFAULTICON ICONS DEFAULTSYSMENU
+%token SYSMENU ROOTMENU SEPARATOR ATSTART ATEND EXEC ALWAYSONTOP DEBUG
+%token RELOAD TRAYICON SILENTEXIT
+
+%token <sVal> STRING
+%type <iVal> atspot
+
+%%
+
+input: /* empty */
+ | input line
+ ;
+
+line: NEWLINE
+ | command
+ ;
+
+
+newline_or_nada:
+ | NEWLINE newline_or_nada
+ ;
+
+command: defaulticon
+ | icondirectory
+ | menu
+ | icons
+ | sysmenu
+ | rootmenu
+ | defaultsysmenu
+ | debug
+ | trayicon
+ | silentexit
+ ;
+
+trayicon: TRAYICON STRING NEWLINE { SetTrayIcon($2); free($2); }
+ ;
+
+rootmenu: ROOTMENU STRING NEWLINE { SetRootMenu($2); free($2); }
+ ;
+
+defaultsysmenu: DEFAULTSYSMENU STRING atspot NEWLINE { SetDefaultSysMenu($2, $3); free($2); }
+ ;
+
+defaulticon: DEFAULTICON STRING NEWLINE { SetDefaultIcon($2); free($2); }
+ ;
+
+icondirectory: ICONDIRECTORY STRING NEWLINE { SetIconDirectory($2); free($2); }
+ ;
+
+menuline: SEPARATOR NEWLINE newline_or_nada { AddMenuLine("-", CMD_SEPARATOR, ""); }
+ | STRING ALWAYSONTOP NEWLINE newline_or_nada { AddMenuLine($1, CMD_ALWAYSONTOP, ""); free($1); }
+ | STRING EXEC STRING NEWLINE newline_or_nada { AddMenuLine($1, CMD_EXEC, $3); free($1); free($3); }
+ | STRING MENU STRING NEWLINE newline_or_nada { AddMenuLine($1, CMD_MENU, $3); free($1); free($3); }
+ | STRING RELOAD NEWLINE newline_or_nada { AddMenuLine($1, CMD_RELOAD, ""); free($1); }
+ ;
+
+menulist: menuline
+ | menuline menulist
+ ;
+
+menu: MENU STRING LB { OpenMenu($2); free($2); } newline_or_nada menulist RB {CloseMenu();}
+ ;
+
+iconline: STRING STRING NEWLINE newline_or_nada { AddIconLine($1, $2); free($1); free($2); }
+ ;
+
+iconlist: iconline
+ | iconline iconlist
+ ;
+
+icons: ICONS LB {OpenIcons();} newline_or_nada iconlist RB {CloseIcons();}
+ ;
+
+atspot: { $$=AT_END; }
+ | ATSTART { $$=AT_START; }
+ | ATEND { $$=AT_END; }
+ ;
+
+sysmenuline: STRING STRING atspot NEWLINE newline_or_nada { AddSysMenuLine($1, $2, $3); free($1); free($2); }
+ ;
+
+sysmenulist: sysmenuline
+ | sysmenuline sysmenulist
+ ;
+
+sysmenu: SYSMENU LB NEWLINE {OpenSysMenu();} newline_or_nada sysmenulist RB {CloseSysMenu();}
+ ;
+
+silentexit: SILENTEXIT NEWLINE { pref.fSilentExit = TRUE; }
+ ;
+
+debug: DEBUG STRING NEWLINE { ErrorF("LoadPreferences: %s\n", $2); free($2); }
+ ;
+
+
+%%
+/*
+ * Errors in parsing abort and print log messages
+ */
+static int
+yyerror (char *s)
+{
+ extern int yylineno; /* Handled by flex internally */
+
+ ErrorF("LoadPreferences: %s line %d\n", s, yylineno);
+ return 1;
+}
+
+/* Miscellaneous functions to store TOKENs into the structure */
+static void
+SetIconDirectory (char *path)
+{
+ strncpy (pref.iconDirectory, path, PATH_MAX);
+ pref.iconDirectory[PATH_MAX] = 0;
+}
+
+static void
+SetDefaultIcon (char *fname)
+{
+ strncpy (pref.defaultIconName, fname, NAME_MAX);
+ pref.defaultIconName[NAME_MAX] = 0;
+}
+
+static void
+SetTrayIcon (char *fname)
+{
+ strncpy (pref.trayIconName, fname, NAME_MAX);
+ pref.trayIconName[NAME_MAX] = 0;
+}
+
+static void
+SetRootMenu (char *menu)
+{
+ strncpy (pref.rootMenuName, menu, MENU_MAX);
+ pref.rootMenuName[MENU_MAX] = 0;
+}
+
+static void
+SetDefaultSysMenu (char *menu, int pos)
+{
+ strncpy (pref.defaultSysMenuName, menu, MENU_MAX);
+ pref.defaultSysMenuName[MENU_MAX] = 0;
+ pref.defaultSysMenuPos = pos;
+}
+
+static void
+OpenMenu (char *menuname)
+{
+ if (menu.menuItem) free(menu.menuItem);
+ menu.menuItem = NULL;
+ strncpy(menu.menuName, menuname, MENU_MAX);
+ menu.menuName[MENU_MAX] = 0;
+ menu.menuItems = 0;
+}
+
+static void
+AddMenuLine (char *text, MENUCOMMANDTYPE cmd, char *param)
+{
+ if (menu.menuItem==NULL)
+ menu.menuItem = (MENUITEM*)malloc(sizeof(MENUITEM));
+ else
+ menu.menuItem = (MENUITEM*)
+ realloc(menu.menuItem, sizeof(MENUITEM)*(menu.menuItems+1));
+
+ strncpy (menu.menuItem[menu.menuItems].text, text, MENU_MAX);
+ menu.menuItem[menu.menuItems].text[MENU_MAX] = 0;
+
+ menu.menuItem[menu.menuItems].cmd = cmd;
+
+ strncpy(menu.menuItem[menu.menuItems].param, param, PARAM_MAX);
+ menu.menuItem[menu.menuItems].param[PARAM_MAX] = 0;
+
+ menu.menuItem[menu.menuItems].commandID = 0;
+
+ menu.menuItems++;
+}
+
+static void
+CloseMenu (void)
+{
+ if (menu.menuItem==NULL || menu.menuItems==0)
+ {
+ ErrorF("LoadPreferences: Empty menu detected\n");
+ return;
+ }
+
+ if (pref.menuItems)
+ pref.menu = (MENUPARSED*)
+ realloc (pref.menu, (pref.menuItems+1)*sizeof(MENUPARSED));
+ else
+ pref.menu = (MENUPARSED*)malloc (sizeof(MENUPARSED));
+
+ memcpy (pref.menu+pref.menuItems, &menu, sizeof(MENUPARSED));
+ pref.menuItems++;
+
+ memset (&menu, 0, sizeof(MENUPARSED));
+}
+
+static void
+OpenIcons (void)
+{
+ if (pref.icon != NULL) {
+ ErrorF("LoadPreferences: Redefining icon mappings\n");
+ free(pref.icon);
+ pref.icon = NULL;
+ }
+ pref.iconItems = 0;
+}
+
+static void
+AddIconLine (char *matchstr, char *iconfile)
+{
+ if (pref.icon==NULL)
+ pref.icon = (ICONITEM*)malloc(sizeof(ICONITEM));
+ else
+ pref.icon = (ICONITEM*)
+ realloc(pref.icon, sizeof(ICONITEM)*(pref.iconItems+1));
+
+ strncpy(pref.icon[pref.iconItems].match, matchstr, MENU_MAX);
+ pref.icon[pref.iconItems].match[MENU_MAX] = 0;
+
+ strncpy(pref.icon[pref.iconItems].iconFile, iconfile, PATH_MAX+NAME_MAX+1);
+ pref.icon[pref.iconItems].iconFile[PATH_MAX+NAME_MAX+1] = 0;
+
+ pref.icon[pref.iconItems].hicon = 0;
+
+ pref.iconItems++;
+}
+
+static void
+CloseIcons (void)
+{
+}
+
+static void
+OpenSysMenu (void)
+{
+ if (pref.sysMenu != NULL) {
+ ErrorF("LoadPreferences: Redefining system menu\n");
+ free(pref.sysMenu);
+ pref.sysMenu = NULL;
+ }
+ pref.sysMenuItems = 0;
+}
+
+static void
+AddSysMenuLine (char *matchstr, char *menuname, int pos)
+{
+ if (pref.sysMenu==NULL)
+ pref.sysMenu = (SYSMENUITEM*)malloc(sizeof(SYSMENUITEM));
+ else
+ pref.sysMenu = (SYSMENUITEM*)
+ realloc(pref.sysMenu, sizeof(SYSMENUITEM)*(pref.sysMenuItems+1));
+
+ strncpy (pref.sysMenu[pref.sysMenuItems].match, matchstr, MENU_MAX);
+ pref.sysMenu[pref.sysMenuItems].match[MENU_MAX] = 0;
+
+ strncpy (pref.sysMenu[pref.sysMenuItems].menuName, menuname, MENU_MAX);
+ pref.sysMenu[pref.sysMenuItems].menuName[MENU_MAX] = 0;
+
+ pref.sysMenu[pref.sysMenuItems].menuPos = pos;
+
+ pref.sysMenuItems++;
+}
+
+static void
+CloseSysMenu (void)
+{
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xwin/winpriv.c b/nx-X11/programs/Xserver/hw/xwin/winpriv.c
new file mode 100644
index 000000000..29221cf2b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winpriv.c
@@ -0,0 +1,134 @@
+/*
+ * Export window information for the Windows-OpenGL GLX implementation.
+ *
+ * Authors: Alexander Gottwald
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winpriv.h"
+#include "winwindow.h"
+
+void
+winCreateWindowsWindow (WindowPtr pWin);
+/**
+ * Return size and handles of a window.
+ * If pWin is NULL, then the information for the root window is requested.
+ */
+extern void winGetWindowInfo(WindowPtr pWin, winWindowInfoPtr pWinInfo)
+{
+ /* Sanity check */
+ if (pWinInfo == NULL)
+ return;
+
+ winDebug("%s:%d pWin=%p\n", __FUNCTION__, __LINE__, pWin);
+
+ /* a real window was requested */
+ if (pWin != NULL)
+ {
+ /* Initialize the size information */
+ RECT rect = {
+ pWin->drawable.x,
+ pWin->drawable.y,
+ pWin->drawable.x + pWin->drawable.width,
+ pWin->drawable.y + pWin->drawable.height
+ }, rect_extends;
+ /* Get the window and screen privates */
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
+ winScreenInfoPtr pScreenInfo = NULL;
+
+ rect_extends = rect;
+ OffsetRect(&rect_extends, -pWin->drawable.x, -pWin->drawable.y);
+
+ if (pWinScreen == NULL)
+ {
+ ErrorF("winGetWindowInfo: screen has no privates\n");
+ return;
+ }
+
+ pWinInfo->hwnd = pWinScreen->hwndScreen;
+ pWinInfo->hrgn = NULL;
+ pWinInfo->rect = rect;
+
+
+ pScreenInfo = pWinScreen->pScreenInfo;
+#ifdef XWIN_MULTIWINDOW
+ /* check for multiwindow mode */
+ if (pScreenInfo->fMultiWindow)
+ {
+ winWindowPriv(pWin);
+
+ if (pWinPriv == NULL)
+ {
+ ErrorF("winGetWindowInfo: window has no privates\n");
+ return;
+ }
+
+ if (pWinPriv->hWnd == NULL)
+ {
+ winCreateWindowsWindow(pWin);
+ }
+ if (pWinPriv->hWnd != NULL) {
+
+ /* copy size and window handle */
+ pWinInfo->rect = rect_extends;
+ pWinInfo->hwnd = pWinPriv->hWnd;
+
+ /* Copy window region */
+ if (pWinInfo->hrgn)
+ DeleteObject(pWinInfo->hrgn);
+ pWinInfo->hrgn = CreateRectRgn(0,0,0,0);
+ CombineRgn(pWinInfo->hrgn, pWinPriv->hRgn, pWinPriv->hRgn,
+ RGN_COPY);
+ }
+
+ return;
+ }
+#endif
+#ifdef XWIN_MULTIWINDOWEXTWM
+ /* check for multiwindow external wm mode */
+ if (pScreenInfo->fMWExtWM)
+ {
+ win32RootlessWindowPtr pRLWinPriv
+ = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
+
+ if (pRLWinPriv == NULL) {
+ ErrorF("winGetWindowInfo: window has no privates\n");
+ return;
+ }
+
+ if (pRLWinPriv->hWnd != NULL)
+ {
+ /* copy size and window handle */
+ pWinInfo->rect = rect_extends;
+ pWinInfo->hwnd = pRLWinPriv->hWnd;
+ }
+ return;
+ }
+#endif
+ }
+ else
+ {
+ RECT rect = {0, 0, 0, 0};
+ ScreenPtr pScreen = g_ScreenInfo[0].pScreen;
+ winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
+
+ pWinInfo->hwnd = NULL;
+ pWinInfo->hrgn = NULL;
+ pWinInfo->rect = rect;
+
+ if (pWinScreen == NULL)
+ {
+ ErrorF("winGetWindowInfo: screen has no privates\n");
+ return;
+ }
+
+ ErrorF("winGetWindowInfo: returning root window\n");
+
+ pWinInfo->hwnd = pWinScreen->hwndScreen;
+ }
+ return;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winpriv.h b/nx-X11/programs/Xserver/hw/xwin/winpriv.h
new file mode 100644
index 000000000..d4505c83e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winpriv.h
@@ -0,0 +1,15 @@
+/*
+ * Export window information for the Windows-OpenGL GLX implementation.
+ *
+ * Authors: Alexander Gottwald
+ */
+#include <windows.h>
+
+typedef struct
+{
+ HWND hwnd;
+ HRGN hrgn;
+ RECT rect;
+} winWindowInfoRec, *winWindowInfoPtr;
+
+extern void winGetWindowInfo(WindowPtr pWin, winWindowInfoPtr pWinInfo);
diff --git a/nx-X11/programs/Xserver/hw/xwin/winprocarg.c b/nx-X11/programs/Xserver/hw/xwin/winprocarg.c
new file mode 100755
index 000000000..bd0b99977
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winprocarg.c
@@ -0,0 +1,1561 @@
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#ifdef XVENDORNAME
+#define VENDOR_STRING XVENDORNAME
+#define VERSION_STRING XORG_RELEASE
+#define VENDOR_CONTACT BUILDERADDR
+#endif
+#include "win.h"
+#include "winconfig.h"
+#include "winprefs.h"
+#include "winmsg.h"
+
+/*
+ * References to external symbols
+ */
+
+extern int g_iNumScreens;
+extern winScreenInfo g_ScreenInfo[];
+extern int g_iLastScreen;
+extern Bool g_fInitializedDefaultScreens;
+#ifdef XWIN_CLIPBOARD
+extern Bool g_fUnicodeClipboard;
+extern Bool g_fClipboard;
+#endif
+extern int g_iLogVerbose;
+extern char * g_pszLogFile;
+#ifdef RELOCATE_PROJECTROOT
+extern Bool g_fLogFileChanged;
+#endif
+extern Bool g_fXdmcpEnabled;
+extern char * g_pszCommandLine;
+extern Bool g_fKeyboardHookLL;
+extern Bool g_fNoHelpMessageBox;
+extern Bool g_fSoftwareCursor;
+extern Bool g_fSilentDupError;
+
+/* globals required by callback function for monitor information */
+struct GetMonitorInfoData {
+ int requestedMonitor;
+ int monitorNum;
+ Bool bUserSpecifiedMonitor;
+ Bool bMonitorSpecifiedExists;
+ int monitorOffsetX;
+ int monitorOffsetY;
+ int monitorHeight;
+ int monitorWidth;
+};
+
+typedef wBOOL (*ENUMDISPLAYMONITORSPROC)(HDC,LPCRECT,MONITORENUMPROC,LPARAM);
+ENUMDISPLAYMONITORSPROC _EnumDisplayMonitors;
+
+wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data);
+
+static Bool QueryMonitor(int index, struct GetMonitorInfoData *data)
+{
+ /* Load EnumDisplayMonitors from DLL */
+ HMODULE user32;
+ FARPROC func;
+ user32 = LoadLibrary("user32.dll");
+ if (user32 == NULL)
+ {
+ winW32Error(2, "Could not open user32.dll");
+ return FALSE;
+ }
+ func = GetProcAddress(user32, "EnumDisplayMonitors");
+ if (func == NULL)
+ {
+ winW32Error(2, "Could not resolve EnumDisplayMonitors: ");
+ return FALSE;
+ }
+ _EnumDisplayMonitors = (ENUMDISPLAYMONITORSPROC)func;
+
+ /* prepare data */
+ if (data == NULL)
+ return FALSE;
+ memset(data, 0, sizeof(*data));
+ data->requestedMonitor = index;
+
+ /* query information */
+ _EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data);
+
+ /* cleanup */
+ FreeLibrary(user32);
+ return TRUE;
+}
+
+/*
+ * Function prototypes
+ */
+
+void
+winLogCommandLine (int argc, char *argv[]);
+
+void
+winLogVersionInfo (void);
+
+#ifdef DDXOSVERRORF
+void OsVendorVErrorF (const char *pszFormat, va_list va_args);
+#endif
+
+void
+winInitializeDefaultScreens (void);
+
+/*
+ * Process arguments on the command line
+ */
+
+void
+winInitializeDefaultScreens (void)
+{
+ int i;
+ DWORD dwWidth, dwHeight;
+
+ /* Bail out early if default screens have already been initialized */
+ if (g_fInitializedDefaultScreens)
+ return;
+
+ /* Zero the memory used for storing the screen info */
+ ZeroMemory (g_ScreenInfo, MAXSCREENS * sizeof (winScreenInfo));
+
+ /* Get default width and height */
+ /*
+ * NOTE: These defaults will cause the window to cover only
+ * the primary monitor in the case that we have multiple monitors.
+ */
+ dwWidth = GetSystemMetrics (SM_CXSCREEN);
+ dwHeight = GetSystemMetrics (SM_CYSCREEN);
+
+ winErrorFVerb (2, "winInitializeDefaultScreens - w %d h %d\n",
+ (int) dwWidth, (int) dwHeight);
+
+ /* Set a default DPI, if no parameter was passed */
+ if (monitorResolution == 0)
+ monitorResolution = WIN_DEFAULT_DPI;
+
+ for (i = 0; i < MAXSCREENS; ++i)
+ {
+ g_ScreenInfo[i].dwScreen = i;
+ g_ScreenInfo[i].dwWidth = dwWidth;
+ g_ScreenInfo[i].dwHeight = dwHeight;
+ g_ScreenInfo[i].dwUserWidth = dwWidth;
+ g_ScreenInfo[i].dwUserHeight = dwHeight;
+ g_ScreenInfo[i].fUserGaveHeightAndWidth
+ = WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH;
+ g_ScreenInfo[i].fUserGavePosition = FALSE;
+ g_ScreenInfo[i].dwBPP = WIN_DEFAULT_BPP;
+ g_ScreenInfo[i].dwClipUpdatesNBoxes = WIN_DEFAULT_CLIP_UPDATES_NBOXES;
+#ifdef XWIN_EMULATEPSEUDO
+ g_ScreenInfo[i].fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO;
+#endif
+ g_ScreenInfo[i].dwRefreshRate = WIN_DEFAULT_REFRESH;
+ g_ScreenInfo[i].pfb = NULL;
+ g_ScreenInfo[i].fFullScreen = FALSE;
+ g_ScreenInfo[i].fDecoration = TRUE;
+#ifdef XWIN_MULTIWINDOWEXTWM
+ g_ScreenInfo[i].fMWExtWM = FALSE;
+ g_ScreenInfo[i].fInternalWM = FALSE;
+#endif
+ g_ScreenInfo[i].fRootless = FALSE;
+#ifdef XWIN_MULTIWINDOW
+ g_ScreenInfo[i].fMultiWindow = FALSE;
+#endif
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ g_ScreenInfo[i].fMultiMonitorOverride = FALSE;
+#endif
+ g_ScreenInfo[i].fMultipleMonitors = FALSE;
+ g_ScreenInfo[i].fLessPointer = FALSE;
+ g_ScreenInfo[i].fScrollbars = FALSE;
+ g_ScreenInfo[i].fNoTrayIcon = FALSE;
+ g_ScreenInfo[i].iE3BTimeout = WIN_E3B_OFF;
+ g_ScreenInfo[i].dwWidth_mm = (dwWidth / WIN_DEFAULT_DPI)
+ * 25.4;
+ g_ScreenInfo[i].dwHeight_mm = (dwHeight / WIN_DEFAULT_DPI)
+ * 25.4;
+ g_ScreenInfo[i].fUseWinKillKey = WIN_DEFAULT_WIN_KILL;
+ g_ScreenInfo[i].fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL;
+ g_ScreenInfo[i].fIgnoreInput = FALSE;
+ g_ScreenInfo[i].fExplicitScreen = FALSE;
+ }
+
+ /* Signal that the default screens have been initialized */
+ g_fInitializedDefaultScreens = TRUE;
+
+ winErrorFVerb (2, "winInitializeDefaultScreens - Returning\n");
+}
+
+/* See Porting Layer Definition - p. 57 */
+/*
+ * INPUT
+ * argv: pointer to an array of null-terminated strings, one for
+ * each token in the X Server command line; the first token
+ * is 'XWin.exe', or similar.
+ * argc: a count of the number of tokens stored in argv.
+ * i: a zero-based index into argv indicating the current token being
+ * processed.
+ *
+ * OUTPUT
+ * return: return the number of tokens processed correctly.
+ *
+ * NOTE
+ * When looking for n tokens, check that i + n is less than argc. Or,
+ * you may check if i is greater than or equal to argc, in which case
+ * you should display the UseMsg () and return 0.
+ */
+
+/* Check if enough arguments are given for the option */
+#define CHECK_ARGS(count) if (i + count >= argc) { UseMsg (); return 0; }
+
+/* Compare the current option with the string. */
+#define IS_OPTION(name) (strcmp (argv[i], name) == 0)
+
+int
+ddxProcessArgument (int argc, char *argv[], int i)
+{
+ static Bool s_fBeenHere = FALSE;
+
+ /* Initialize once */
+ if (!s_fBeenHere)
+ {
+#ifdef DDXOSVERRORF
+ /*
+ * This initialises our hook into VErrorF () for catching log messages
+ * that are generated before OsInit () is called.
+ */
+ OsVendorVErrorFProc = OsVendorVErrorF;
+#endif
+
+ s_fBeenHere = TRUE;
+
+ /* Initialize only if option is not -help */
+ if (!IS_OPTION("-help") && !IS_OPTION("-h") && !IS_OPTION("--help") &&
+ !IS_OPTION("-version") && !IS_OPTION("--version"))
+ {
+
+ /* Log the version information */
+ winLogVersionInfo ();
+
+ /* Log the command line */
+ winLogCommandLine (argc, argv);
+
+ /*
+ * Initialize default screen settings. We have to do this before
+ * OsVendorInit () gets called, otherwise we will overwrite
+ * settings changed by parameters such as -fullscreen, etc.
+ */
+ winErrorFVerb (2, "ddxProcessArgument - Initializing default "
+ "screens\n");
+ winInitializeDefaultScreens ();
+ }
+ }
+
+#if CYGDEBUG
+ winDebug ("ddxProcessArgument - arg: %s\n", argv[i]);
+#endif
+
+ /*
+ * Look for the '-help' and similar options
+ */
+ if (IS_OPTION ("-help") || IS_OPTION("-h") || IS_OPTION("--help"))
+ {
+ /* Reset logfile. We don't need that helpmessage in the logfile */
+ g_pszLogFile = NULL;
+ g_fNoHelpMessageBox = TRUE;
+ UseMsg();
+ exit (0);
+ return 1;
+ }
+
+ if (IS_OPTION ("-version") || IS_OPTION("--version"))
+ {
+ /* Reset logfile. We don't need that versioninfo in the logfile */
+ g_pszLogFile = NULL;
+ winLogVersionInfo ();
+ exit (0);
+ return 1;
+ }
+
+ /*
+ * Look for the '-screen scr_num [width height]' argument
+ */
+ if (IS_OPTION ("-screen"))
+ {
+ int iArgsProcessed = 1;
+ int nScreenNum;
+ int iWidth, iHeight, iX, iY;
+ int iMonitor;
+
+#if CYGDEBUG
+ winDebug ("ddxProcessArgument - screen - argc: %d i: %d\n",
+ argc, i);
+#endif
+
+ /* Display the usage message if the argument is malformed */
+ if (i + 1 >= argc)
+ {
+ return 0;
+ }
+
+ /* Grab screen number */
+ nScreenNum = atoi (argv[i + 1]);
+
+ /* Validate the specified screen number */
+ if (nScreenNum < 0 || nScreenNum >= MAXSCREENS)
+ {
+ ErrorF ("ddxProcessArgument - screen - Invalid screen number %d\n",
+ nScreenNum);
+ UseMsg ();
+ return 0;
+ }
+
+ /* look for @m where m is monitor number */
+ if (i + 2 < argc
+ && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor))
+ {
+ struct GetMonitorInfoData data;
+ if (!QueryMonitor(iMonitor, &data))
+ {
+ ErrorF ("ddxProcessArgument - screen - "
+ "Querying monitors is not supported on NT4 and Win95\n");
+ } else if (data.bMonitorSpecifiedExists == TRUE)
+ {
+ winErrorFVerb(2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
+ iArgsProcessed = 3;
+ g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE;
+ g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
+ g_ScreenInfo[nScreenNum].dwWidth = data.monitorWidth;
+ g_ScreenInfo[nScreenNum].dwHeight = data.monitorHeight;
+ g_ScreenInfo[nScreenNum].dwUserWidth = data.monitorWidth;
+ g_ScreenInfo[nScreenNum].dwUserHeight = data.monitorHeight;
+ g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX;
+ g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY;
+ }
+ else
+ {
+ /* monitor does not exist, error out */
+ ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
+ iMonitor);
+ UseMsg ();
+ exit (0);
+ return 0;
+ }
+ }
+
+ /* Look for 'WxD' or 'W D' */
+ else if (i + 2 < argc
+ && 2 == sscanf (argv[i + 2], "%dx%d",
+ (int *) &iWidth,
+ (int *) &iHeight))
+ {
+ winErrorFVerb (2, "ddxProcessArgument - screen - Found ``WxD'' arg\n");
+ iArgsProcessed = 3;
+ g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE;
+ g_ScreenInfo[nScreenNum].dwWidth = iWidth;
+ g_ScreenInfo[nScreenNum].dwHeight = iHeight;
+ g_ScreenInfo[nScreenNum].dwUserWidth = iWidth;
+ g_ScreenInfo[nScreenNum].dwUserHeight = iHeight;
+ /* Look for WxD+X+Y */
+ if (2 == sscanf (argv[i + 2], "%*dx%*d+%d+%d",
+ (int *) &iX,
+ (int *) &iY))
+ {
+ winErrorFVerb (2, "ddxProcessArgument - screen - Found ``X+Y'' arg\n");
+ g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
+ g_ScreenInfo[nScreenNum].dwInitialX = iX;
+ g_ScreenInfo[nScreenNum].dwInitialY = iY;
+
+ /* look for WxD+X+Y@m where m is monitor number. take X,Y to be offsets from monitor's root position */
+ if (1 == sscanf (argv[i + 2], "%*dx%*d+%*d+%*d@%d",
+ (int *) &iMonitor))
+ {
+ struct GetMonitorInfoData data;
+ if (!QueryMonitor(iMonitor, &data))
+ {
+ ErrorF ("ddxProcessArgument - screen - "
+ "Querying monitors is not supported on NT4 and Win95\n");
+ } else if (data.bMonitorSpecifiedExists == TRUE)
+ {
+ g_ScreenInfo[nScreenNum].dwInitialX += data.monitorOffsetX;
+ g_ScreenInfo[nScreenNum].dwInitialY += data.monitorOffsetY;
+ }
+ else
+ {
+ /* monitor does not exist, error out */
+ ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
+ iMonitor);
+ UseMsg ();
+ exit (0);
+ return 0;
+ }
+
+ }
+ }
+
+ /* look for WxD@m where m is monitor number */
+ else if (1 == sscanf(argv[i + 2], "%*dx%*d@%d",
+ (int *) &iMonitor))
+ {
+ struct GetMonitorInfoData data;
+ if (!QueryMonitor(iMonitor, &data))
+ {
+ ErrorF ("ddxProcessArgument - screen - "
+ "Querying monitors is not supported on NT4 and Win95\n");
+ } else if (data.bMonitorSpecifiedExists == TRUE)
+ {
+ winErrorFVerb (2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
+ g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
+ g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX;
+ g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY;
+ }
+ else
+ {
+ /* monitor does not exist, error out */
+ ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
+ iMonitor);
+ UseMsg ();
+ exit (0);
+ return 0;
+ }
+
+ }
+ }
+ else if (i + 3 < argc
+ && 1 == sscanf (argv[i + 2], "%d",
+ (int *) &iWidth)
+ && 1 == sscanf (argv[i + 3], "%d",
+ (int *) &iHeight))
+ {
+ winErrorFVerb (2, "ddxProcessArgument - screen - Found ``W D'' arg\n");
+ iArgsProcessed = 4;
+ g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE;
+ g_ScreenInfo[nScreenNum].dwWidth = iWidth;
+ g_ScreenInfo[nScreenNum].dwHeight = iHeight;
+ g_ScreenInfo[nScreenNum].dwUserWidth = iWidth;
+ g_ScreenInfo[nScreenNum].dwUserHeight = iHeight;
+ if (i + 5 < argc
+ && 1 == sscanf (argv[i + 4], "%d",
+ (int *) &iX)
+ && 1 == sscanf (argv[i + 5], "%d",
+ (int *) &iY))
+ {
+ winErrorFVerb (2, "ddxProcessArgument - screen - Found ``X Y'' arg\n");
+ iArgsProcessed = 6;
+ g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
+ g_ScreenInfo[nScreenNum].dwInitialX = iX;
+ g_ScreenInfo[nScreenNum].dwInitialY = iY;
+ }
+ }
+ else
+ {
+ winErrorFVerb (2, "ddxProcessArgument - screen - Did not find size arg. "
+ "dwWidth: %d dwHeight: %d\n",
+ (int) g_ScreenInfo[nScreenNum].dwWidth,
+ (int) g_ScreenInfo[nScreenNum].dwHeight);
+ iArgsProcessed = 2;
+ g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE;
+ }
+
+ /* Calculate the screen width and height in millimeters */
+ if (g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth)
+ {
+ g_ScreenInfo[nScreenNum].dwWidth_mm
+ = (g_ScreenInfo[nScreenNum].dwWidth
+ / monitorResolution) * 25.4;
+ g_ScreenInfo[nScreenNum].dwHeight_mm
+ = (g_ScreenInfo[nScreenNum].dwHeight
+ / monitorResolution) * 25.4;
+ }
+
+ /* Flag that this screen was explicity specified by the user */
+ g_ScreenInfo[nScreenNum].fExplicitScreen = TRUE;
+
+ /*
+ * Keep track of the last screen number seen, as parameters seen
+ * before a screen number apply to all screens, whereas parameters
+ * seen after a screen number apply to that screen number only.
+ */
+ g_iLastScreen = nScreenNum;
+
+ /* Keep a count of the number of screens */
+ ++g_iNumScreens;
+
+ return iArgsProcessed;
+ }
+
+ /*
+ * Look for the '-engine n' argument
+ */
+ if (IS_OPTION ("-engine"))
+ {
+ DWORD dwEngine = 0;
+ CARD8 c8OnBits = 0;
+
+ /* Display the usage message if the argument is malformed */
+ if (++i >= argc)
+ {
+ UseMsg ();
+ return 0;
+ }
+
+ /* Grab the argument */
+ dwEngine = atoi (argv[i]);
+
+ /* Count the one bits in the engine argument */
+ c8OnBits = winCountBits (dwEngine);
+
+ /* Argument should only have a single bit on */
+ if (c8OnBits != 1)
+ {
+ UseMsg ();
+ return 0;
+ }
+
+ /* Is this parameter attached to a screen or global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].dwEnginePreferred = dwEngine;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].dwEnginePreferred = dwEngine;
+ }
+
+ /* Indicate that we have processed the argument */
+ return 2;
+ }
+
+ /*
+ * Look for the '-fullscreen' argument
+ */
+ if (IS_OPTION ("-fullscreen"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!g_ScreenInfo[j].fMultiMonitorOverride)
+ g_ScreenInfo[j].fMultipleMonitors = FALSE;
+#endif
+ g_ScreenInfo[j].fFullScreen = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
+ g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE;
+#endif
+ g_ScreenInfo[g_iLastScreen].fFullScreen = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-lesspointer' argument
+ */
+ if (IS_OPTION ("-lesspointer"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fLessPointer = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fLessPointer = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-nodecoration' argument
+ */
+ if (IS_OPTION ("-nodecoration"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!g_ScreenInfo[j].fMultiMonitorOverride)
+ g_ScreenInfo[j].fMultipleMonitors = FALSE;
+#endif
+ g_ScreenInfo[j].fDecoration = FALSE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
+ g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE;
+#endif
+ g_ScreenInfo[g_iLastScreen].fDecoration = FALSE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ /*
+ * Look for the '-mwextwm' argument
+ */
+ if (IS_OPTION ("-mwextwm"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ if (!g_ScreenInfo[j].fMultiMonitorOverride)
+ g_ScreenInfo[j].fMultipleMonitors = TRUE;
+ g_ScreenInfo[j].fMWExtWM = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
+ g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE;
+ g_ScreenInfo[g_iLastScreen].fMWExtWM = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+ /*
+ * Look for the '-internalwm' argument
+ */
+ if (IS_OPTION ("-internalwm"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ if (!g_ScreenInfo[j].fMultiMonitorOverride)
+ g_ScreenInfo[j].fMultipleMonitors = TRUE;
+ g_ScreenInfo[j].fMWExtWM = TRUE;
+ g_ScreenInfo[j].fInternalWM = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
+ g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE;
+ g_ScreenInfo[g_iLastScreen].fMWExtWM = TRUE;
+ g_ScreenInfo[g_iLastScreen].fInternalWM = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+#endif
+
+ /*
+ * Look for the '-rootless' argument
+ */
+ if (IS_OPTION ("-rootless"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!g_ScreenInfo[j].fMultiMonitorOverride)
+ g_ScreenInfo[j].fMultipleMonitors = FALSE;
+#endif
+ g_ScreenInfo[j].fRootless = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
+ g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE;
+#endif
+ g_ScreenInfo[g_iLastScreen].fRootless = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+#ifdef XWIN_MULTIWINDOW
+ /*
+ * Look for the '-multiwindow' argument
+ */
+ if (IS_OPTION ("-multiwindow"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!g_ScreenInfo[j].fMultiMonitorOverride)
+ g_ScreenInfo[j].fMultipleMonitors = TRUE;
+#endif
+ g_ScreenInfo[j].fMultiWindow = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
+ g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE;
+#endif
+ g_ScreenInfo[g_iLastScreen].fMultiWindow = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+#endif
+
+ /*
+ * Look for the '-multiplemonitors' argument
+ */
+ if (IS_OPTION ("-multiplemonitors")
+ || IS_OPTION ("-multimonitors"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ g_ScreenInfo[j].fMultiMonitorOverride = TRUE;
+#endif
+ g_ScreenInfo[j].fMultipleMonitors = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride = TRUE;
+#endif
+ g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-nomultiplemonitors' argument
+ */
+ if (IS_OPTION ("-nomultiplemonitors")
+ || IS_OPTION ("-nomultimonitors"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ g_ScreenInfo[j].fMultiMonitorOverride = TRUE;
+#endif
+ g_ScreenInfo[j].fMultipleMonitors = FALSE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride = TRUE;
+#endif
+ g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+
+ /*
+ * Look for the '-scrollbars' argument
+ */
+ if (IS_OPTION ("-scrollbars"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fScrollbars = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fScrollbars = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+
+#ifdef XWIN_CLIPBOARD
+ /*
+ * Look for the '-clipboard' argument
+ */
+ if (IS_OPTION ("-clipboard"))
+ {
+ g_fClipboard = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+#endif
+
+
+ /*
+ * Look for the '-ignoreinput' argument
+ */
+ if (IS_OPTION ("-ignoreinput"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fIgnoreInput = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fIgnoreInput = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-emulate3buttons' argument
+ */
+ if (IS_OPTION ("-emulate3buttons"))
+ {
+ int iArgsProcessed = 1;
+ int iE3BTimeout = WIN_DEFAULT_E3B_TIME;
+
+ /* Grab the optional timeout value */
+ if (i + 1 < argc
+ && 1 == sscanf (argv[i + 1], "%d",
+ &iE3BTimeout))
+ {
+ /* Indicate that we have processed the next argument */
+ iArgsProcessed++;
+ }
+ else
+ {
+ /*
+ * sscanf () won't modify iE3BTimeout if it doesn't find
+ * the specified format; however, I want to be explicit
+ * about setting the default timeout in such cases to
+ * prevent some programs (me) from getting confused.
+ */
+ iE3BTimeout = WIN_DEFAULT_E3B_TIME;
+ }
+
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].iE3BTimeout = iE3BTimeout;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].iE3BTimeout = iE3BTimeout;
+ }
+
+ /* Indicate that we have processed this argument */
+ return iArgsProcessed;
+ }
+
+ /*
+ * Look for the '-depth n' argument
+ */
+ if (IS_OPTION ("-depth"))
+ {
+ DWORD dwBPP = 0;
+
+ /* Display the usage message if the argument is malformed */
+ if (++i >= argc)
+ {
+ UseMsg ();
+ return 0;
+ }
+
+ /* Grab the argument */
+ dwBPP = atoi (argv[i]);
+
+ /* Is this parameter attached to a screen or global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].dwBPP = dwBPP;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].dwBPP = dwBPP;
+ }
+
+ /* Indicate that we have processed the argument */
+ return 2;
+ }
+
+ /*
+ * Look for the '-refresh n' argument
+ */
+ if (IS_OPTION ("-refresh"))
+ {
+ DWORD dwRefreshRate = 0;
+
+ /* Display the usage message if the argument is malformed */
+ if (++i >= argc)
+ {
+ UseMsg ();
+ return 0;
+ }
+
+ /* Grab the argument */
+ dwRefreshRate = atoi (argv[i]);
+
+ /* Is this parameter attached to a screen or global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].dwRefreshRate = dwRefreshRate;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].dwRefreshRate = dwRefreshRate;
+ }
+
+ /* Indicate that we have processed the argument */
+ return 2;
+ }
+
+ /*
+ * Look for the '-clipupdates num_boxes' argument
+ */
+ if (IS_OPTION ("-clipupdates"))
+ {
+ DWORD dwNumBoxes = 0;
+
+ /* Display the usage message if the argument is malformed */
+ if (++i >= argc)
+ {
+ UseMsg ();
+ return 0;
+ }
+
+ /* Grab the argument */
+ dwNumBoxes = atoi (argv[i]);
+
+ /* Is this parameter attached to a screen or global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].dwClipUpdatesNBoxes = dwNumBoxes;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].dwClipUpdatesNBoxes = dwNumBoxes;
+ }
+
+ /* Indicate that we have processed the argument */
+ return 2;
+ }
+
+#ifdef XWIN_EMULATEPSEUDO
+ /*
+ * Look for the '-emulatepseudo' argument
+ */
+ if (IS_OPTION ("-emulatepseudo"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fEmulatePseudo = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fEmulatePseudo = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+#endif
+
+ /*
+ * Look for the '-nowinkill' argument
+ */
+ if (IS_OPTION ("-nowinkill"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fUseWinKillKey = FALSE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fUseWinKillKey = FALSE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-winkill' argument
+ */
+ if (IS_OPTION ("-winkill"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fUseWinKillKey = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fUseWinKillKey = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-nounixkill' argument
+ */
+ if (IS_OPTION ("-nounixkill"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fUseUnixKillKey = FALSE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fUseUnixKillKey = FALSE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-unixkill' argument
+ */
+ if (IS_OPTION ("-unixkill"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fUseUnixKillKey = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fUseUnixKillKey = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-notrayicon' argument
+ */
+ if (IS_OPTION ("-notrayicon"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fNoTrayIcon = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fNoTrayIcon = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-trayicon' argument
+ */
+ if (IS_OPTION ("-trayicon"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fNoTrayIcon = FALSE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fNoTrayIcon = FALSE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-fp' argument
+ */
+ if (IS_OPTION ("-fp"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.fontPath = argv[++i];
+ return 0; /* Let DIX parse this again */
+ }
+
+ /*
+ * Look for the '-co' argument
+ */
+ if (IS_OPTION ("-co"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.rgbPath = argv[++i];
+ return 0; /* Let DIX parse this again */
+ }
+
+ /*
+ * Look for the '-query' argument
+ */
+ if (IS_OPTION ("-query"))
+ {
+ CHECK_ARGS (1);
+ g_fXdmcpEnabled = TRUE;
+ g_pszQueryHost = argv[++i];
+ return 0; /* Let DIX parse this again */
+ }
+
+ /*
+ * Look for the '-indirect' or '-broadcast' arguments
+ */
+ if (IS_OPTION ("-indirect")
+ || IS_OPTION ("-broadcast"))
+ {
+ g_fXdmcpEnabled = TRUE;
+ return 0; /* Let DIX parse this again */
+ }
+
+ /*
+ * Look for the '-config' argument
+ */
+ if (IS_OPTION ("-config")
+ || IS_OPTION ("-xf86config"))
+ {
+ CHECK_ARGS (1);
+#ifdef XWIN_XF86CONFIG
+ g_cmdline.configFile = argv[++i];
+#else
+ winMessageBoxF ("The %s option is not supported in this "
+ "release.\n"
+ "Ignoring this option and continuing.\n",
+ MB_ICONINFORMATION,
+ argv[i]);
+#endif
+ return 2;
+ }
+
+ /*
+ * Look for the '-keyboard' argument
+ */
+ if (IS_OPTION ("-keyboard"))
+ {
+#ifdef XWIN_XF86CONFIG
+ CHECK_ARGS (1);
+ g_cmdline.keyboard = argv[++i];
+#else
+ winMessageBoxF ("The -keyboard option is not supported in this "
+ "release.\n"
+ "Ignoring this option and continuing.\n",
+ MB_ICONINFORMATION);
+#endif
+ return 2;
+ }
+
+ /*
+ * Look for the '-logfile' argument
+ */
+ if (IS_OPTION ("-logfile"))
+ {
+ CHECK_ARGS (1);
+ g_pszLogFile = argv[++i];
+#ifdef RELOCATE_PROJECTROOT
+ g_fLogFileChanged = TRUE;
+#endif
+ return 2;
+ }
+
+ /*
+ * Look for the '-logverbose' argument
+ */
+ if (IS_OPTION ("-logverbose"))
+ {
+ CHECK_ARGS (1);
+ g_iLogVerbose = atoi(argv[++i]);
+ return 2;
+ }
+
+#ifdef XWIN_CLIPBOARD
+ /*
+ * Look for the '-nounicodeclipboard' argument
+ */
+ if (IS_OPTION ("-nounicodeclipboard"))
+ {
+ g_fUnicodeClipboard = FALSE;
+ /* Indicate that we have processed the argument */
+ return 1;
+ }
+#endif
+
+#ifdef XKB
+ /*
+ * Look for the '-kb' argument
+ */
+ if (IS_OPTION ("-kb"))
+ {
+ g_cmdline.noXkbExtension = TRUE;
+ return 0; /* Let DIX parse this again */
+ }
+
+ if (IS_OPTION ("-xkbrules"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.xkbRules = argv[++i];
+ return 2;
+ }
+ if (IS_OPTION ("-xkbmodel"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.xkbModel = argv[++i];
+ return 2;
+ }
+ if (IS_OPTION ("-xkblayout"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.xkbLayout = argv[++i];
+ return 2;
+ }
+ if (IS_OPTION ("-xkbvariant"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.xkbVariant = argv[++i];
+ return 2;
+ }
+ if (IS_OPTION ("-xkboptions"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.xkbOptions = argv[++i];
+ return 2;
+ }
+#endif
+
+ if (IS_OPTION ("-keyhook"))
+ {
+ g_fKeyboardHookLL = TRUE;
+ return 1;
+ }
+
+ if (IS_OPTION ("-nokeyhook"))
+ {
+ g_fKeyboardHookLL = FALSE;
+ return 1;
+ }
+
+ if (IS_OPTION ("-swcursor"))
+ {
+ g_fSoftwareCursor = TRUE;
+ return 1;
+ }
+
+ if (IS_OPTION ("-silent-dup-error"))
+ {
+ g_fSilentDupError = TRUE;
+ return 1;
+ }
+ return 0;
+}
+
+
+/*
+ * winLogCommandLine - Write entire command line to the log file
+ */
+
+void
+winLogCommandLine (int argc, char *argv[])
+{
+ int i;
+ int iSize = 0;
+ int iCurrLen = 0;
+
+#define CHARS_PER_LINE 60
+
+ /* Bail if command line has already been logged */
+ if (g_pszCommandLine)
+ return;
+
+ /* Count how much memory is needed for concatenated command line */
+ for (i = 0, iCurrLen = 0; i < argc; ++i)
+ if (argv[i])
+ {
+ /* Add a character for lines that overflow */
+ if ((strlen (argv[i]) < CHARS_PER_LINE
+ && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE)
+ || strlen (argv[i]) > CHARS_PER_LINE)
+ {
+ iCurrLen = 0;
+ ++iSize;
+ }
+
+ /* Add space for item and trailing space */
+ iSize += strlen (argv[i]) + 1;
+
+ /* Update current line length */
+ iCurrLen += strlen (argv[i]);
+ }
+
+ /* Allocate memory for concatenated command line */
+ g_pszCommandLine = malloc (iSize + 1);
+ if (!g_pszCommandLine)
+ FatalError ("winLogCommandLine - Could not allocate memory for "
+ "command line string. Exiting.\n");
+
+ /* Set first character to concatenated command line to null */
+ g_pszCommandLine[0] = '\0';
+
+ /* Loop through all args */
+ for (i = 0, iCurrLen = 0; i < argc; ++i)
+ {
+ /* Add a character for lines that overflow */
+ if ((strlen (argv[i]) < CHARS_PER_LINE
+ && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE)
+ || strlen (argv[i]) > CHARS_PER_LINE)
+ {
+ iCurrLen = 0;
+
+ /* Add line break if it fits */
+ strncat (g_pszCommandLine, "\n", iSize - strlen (g_pszCommandLine));
+ }
+
+ strncat (g_pszCommandLine, argv[i], iSize - strlen (g_pszCommandLine));
+ strncat (g_pszCommandLine, " ", iSize - strlen (g_pszCommandLine));
+
+ /* Save new line length */
+ iCurrLen += strlen (argv[i]);
+ }
+
+ ErrorF ("XWin was started with the following command line:\n\n"
+ "%s\n\n", g_pszCommandLine);
+}
+
+
+/*
+ * winLogVersionInfo - Log Cygwin/X version information
+ */
+
+void
+winLogVersionInfo (void)
+{
+ static Bool s_fBeenHere = FALSE;
+
+ if (s_fBeenHere)
+ return;
+ s_fBeenHere = TRUE;
+
+ ErrorF ("Welcome to the XWin X Server\n");
+ ErrorF ("Vendor: %s\n", VENDOR_STRING);
+ ErrorF ("Release: %s\n\n", VERSION_STRING);
+ ErrorF ("Contact: %s\n\n", VENDOR_CONTACT);
+}
+
+/*
+ * getMonitorInfo - callback function used to return information from the enumeration of monitors attached
+ */
+
+wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data)
+{
+ struct GetMonitorInfoData* data = (struct GetMonitorInfoData*)_data;
+ // only get data for monitor number specified in <data>
+ data->monitorNum++;
+ if (data->monitorNum == data->requestedMonitor)
+ {
+ data->bMonitorSpecifiedExists = TRUE;
+ data->monitorOffsetX = rect->left;
+ data->monitorOffsetY = rect->top;
+ data->monitorHeight = rect->bottom - rect->top;
+ data->monitorWidth = rect->right - rect->left;
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winpushpxl.c b/nx-X11/programs/Xserver/hw/xwin/winpushpxl.c
new file mode 100644
index 000000000..594933986
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winpushpxl.c
@@ -0,0 +1,226 @@
+/* $XFree86: xc/programs/Xserver/mi/mipushpxl.c,v 3.11 2001/01/17 22:37:07 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include <X11/X.h>
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "miscstruct.h"
+#include "../mfb/maskbits.h"
+#include "mi.h"
+
+#define NPT 128
+
+/* winPushPixels -- squeegees the fill style of pGC through pBitMap
+ * into pDrawable. pBitMap is a stencil (dx by dy of it is used, it may
+ * be bigger) which is placed on the drawable at xOrg, yOrg. Where a 1 bit
+ * is set in the bitmap, the fill style is put onto the drawable using
+ * the GC's logical function. The drawable is not changed where the bitmap
+ * has a zero bit or outside the area covered by the stencil.
+
+WARNING:
+ this code works if the 1-bit deep pixmap format returned by GetSpans
+is the same as the format defined by the mfb code (i.e. 32-bit padding
+per scanline, scanline unit = 32 bits; later, this might mean
+bitsizeof(int) padding and sacnline unit == bitsizeof(int).)
+
+ */
+
+/*
+ * in order to have both (MSB_FIRST and LSB_FIRST) versions of this
+ * in the server, we need to rename one of them
+ */
+void
+winPushPixels (GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable,
+ int dx, int dy, int xOrg, int yOrg)
+{
+ int h, dxDivPPW, ibEnd;
+ MiBits *pwLineStart;
+ register MiBits *pw, *pwEnd;
+ register MiBits msk;
+ register int ib, w;
+ register int ipt; /* index into above arrays */
+ Bool fInBox;
+ DDXPointRec pt[NPT], ptThisLine;
+ int width[NPT];
+ PixelType startmask;
+
+
+ startmask = (MiBits)(-1) ^
+ LONG2CHARSDIFFORDER((MiBits)(-1) >> 1);
+
+ pwLineStart = (MiBits *)xalloc(BitmapBytePad(dx));
+ if (!pwLineStart)
+ return;
+ ipt = 0;
+ dxDivPPW = dx/PPW;
+
+ for(h = 0, ptThisLine.x = 0, ptThisLine.y = 0;
+ h < dy;
+ h++, ptThisLine.y++)
+ {
+
+ (*pBitMap->drawable.pScreen->GetSpans)((DrawablePtr)pBitMap, dx,
+ &ptThisLine, &dx, 1, (char *)pwLineStart);
+
+ pw = pwLineStart;
+ /* Process all words which are fully in the pixmap */
+
+ fInBox = FALSE;
+ pwEnd = pwLineStart + dxDivPPW;
+ while(pw < pwEnd)
+ {
+ w = *pw;
+#ifdef XFree86Server
+ msk = startmask;
+#else
+ msk = (MiBits)(-1) ^ SCRRIGHT((MiBits)(-1), 1);
+#endif
+ for(ib = 0; ib < PPW; ib++)
+ {
+ if(w & msk)
+ {
+ if(!fInBox)
+ {
+ pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
+ pt[ipt].y = h + yOrg;
+ /* start new box */
+ fInBox = TRUE;
+ }
+ }
+ else
+ {
+ if(fInBox)
+ {
+ width[ipt] = ((pw - pwLineStart) << PWSH) +
+ ib + xOrg - pt[ipt].x;
+ if (++ipt >= NPT)
+ {
+ (*pGC->ops->FillSpans)(pDrawable, pGC,
+ NPT, pt, width, TRUE);
+ ipt = 0;
+ }
+ /* end box */
+ fInBox = FALSE;
+ }
+ }
+#ifdef XFree86Server
+ /* This is not quite right, but it'll do for now */
+ msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) >> 1);
+#else
+ msk = SCRRIGHT(msk, 1);
+#endif
+ }
+ pw++;
+ }
+ ibEnd = dx & PIM;
+ if(ibEnd)
+ {
+ /* Process final partial word on line */
+ w = *pw;
+#ifdef XFree86Server
+ msk = startmask;
+#else
+ msk = (MiBits)(-1) ^ SCRRIGHT((MiBits)(-1), 1);
+#endif
+ for(ib = 0; ib < ibEnd; ib++)
+ {
+ if(w & msk)
+ {
+ if(!fInBox)
+ {
+ /* start new box */
+ pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
+ pt[ipt].y = h + yOrg;
+ fInBox = TRUE;
+ }
+ }
+ else
+ {
+ if(fInBox)
+ {
+ /* end box */
+ width[ipt] = ((pw - pwLineStart) << PWSH) +
+ ib + xOrg - pt[ipt].x;
+ if (++ipt >= NPT)
+ {
+ (*pGC->ops->FillSpans)(pDrawable,
+ pGC, NPT, pt, width, TRUE);
+ ipt = 0;
+ }
+ fInBox = FALSE;
+ }
+ }
+#ifdef XFree86Server
+ /* This is not quite right, but it'll do for now */
+ msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) >> 1);
+#else
+ msk = SCRRIGHT(msk, 1);
+#endif
+ }
+ }
+ /* If scanline ended with last bit set, end the box */
+ if(fInBox)
+ {
+ width[ipt] = dx + xOrg - pt[ipt].x;
+ if (++ipt >= NPT)
+ {
+ (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt, width, TRUE);
+ ipt = 0;
+ }
+ }
+ }
+ xfree(pwLineStart);
+ /* Flush any remaining spans */
+ if (ipt)
+ {
+ (*pGC->ops->FillSpans)(pDrawable, pGC, ipt, pt, width, TRUE);
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winrandr.c b/nx-X11/programs/Xserver/hw/xwin/winrandr.c
new file mode 100755
index 000000000..7b5b1359c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winrandr.c
@@ -0,0 +1,141 @@
+/*
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * Local prototypes
+ */
+
+static Bool
+winRandRGetInfo (ScreenPtr pScreen, Rotation *pRotations);
+
+static Bool
+winRandRSetConfig (ScreenPtr pScreen,
+ Rotation rotateKind,
+ int rate,
+ RRScreenSizePtr pSize);
+
+Bool
+winRandRInit (ScreenPtr pScreen);
+
+
+/*
+ * Answer queries about the RandR features supported.
+ */
+
+static Bool
+winRandRGetInfo (ScreenPtr pScreen, Rotation *pRotations)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ int n;
+ Rotation rotateKind;
+ RRScreenSizePtr pSize;
+
+ winDebug ("winRandRGetInfo ()\n");
+
+ /* Don't support rotations, yet */
+ *pRotations = RR_Rotate_0;
+
+ /* Bail if no depth has a visual associated with it */
+ for (n = 0; n < pScreen->numDepths; n++)
+ if (pScreen->allowedDepths[n].numVids)
+ break;
+ if (n == pScreen->numDepths)
+ return FALSE;
+
+ /* Only one allowed rotation for now */
+ rotateKind = RR_Rotate_0;
+
+ /*
+ * Register supported sizes. This can be called many times, but
+ * we only support one size for now.
+ */
+ pSize = RRRegisterSize (pScreen,
+ pScreenInfo->dwWidth,
+ pScreenInfo->dwHeight,
+ pScreenInfo->dwWidth_mm,
+ pScreenInfo->dwHeight_mm);
+
+ /* Tell RandR what the current config is */
+ RRSetCurrentConfig (pScreen,
+ rotateKind,
+ 0, /* refresh rate, not needed */
+ pSize);
+
+ return TRUE;
+}
+
+
+/*
+ * Respond to resize/rotate request from either X Server or X client app
+ */
+
+static Bool
+winRandRSetConfig (ScreenPtr pScreen,
+ Rotation rotateKind,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ winDebug ("winRandRSetConfig ()\n");
+
+ return TRUE;
+}
+
+
+/*
+ * Initialize the RandR layer.
+ */
+
+Bool
+winRandRInit (ScreenPtr pScreen)
+{
+ rrScrPrivPtr pRRScrPriv;
+
+ winDebug ("winRandRInit ()\n");
+
+ if (!RRScreenInit (pScreen))
+ {
+ ErrorF ("winRandRInit () - RRScreenInit () failed\n");
+ return FALSE;
+ }
+
+ /* Set some RandR function pointers */
+ pRRScrPriv = rrGetScrPriv (pScreen);
+ pRRScrPriv->rrGetInfo = winRandRGetInfo;
+ pRRScrPriv->rrSetConfig = winRandRSetConfig;
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winregistry.c b/nx-X11/programs/Xserver/hw/xwin/winregistry.c
new file mode 100644
index 000000000..3571b14d7
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winregistry.c
@@ -0,0 +1,71 @@
+/*
+ *Copyright (C) 2002-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+/* Prototypes */
+DWORD
+winGetRegistryDWORD (HKEY hkey, char *pszRegistryKey);
+
+DWORD
+winGetRegistryDWORD (HKEY hkey, char *pszRegistryKey)
+{
+ HKEY hkResult;
+ DWORD dwDisposition;
+
+ RegCreateKeyEx (hkey,
+ pszRegistryKey,
+ 0,
+ '\0',
+ REG_OPTION_NON_VOLATILE,
+ KEY_READ,
+ NULL,
+ &hkResult,
+ &dwDisposition);
+
+ if (dwDisposition == REG_CREATED_NEW_KEY)
+ {
+ ErrorF ("winGetRegistryDWORD - Created new key: %s\n", pszRegistryKey);
+ }
+ else if (dwDisposition == REG_OPENED_EXISTING_KEY)
+ {
+ ErrorF ("winGetRegistryDWORD - Opened existing key: %s\n",
+ pszRegistryKey);
+ }
+
+ /* Free the registry key handle */
+ RegCloseKey (hkResult);
+ hkResult = NULL;
+
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winresource.h b/nx-X11/programs/Xserver/hw/xwin/winresource.h
new file mode 100644
index 000000000..c9b23ffc3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winresource.h
@@ -0,0 +1,56 @@
+#if !defined(WINRESOURCE_H)
+#define WINRESOURCE_H
+/*
+ *Copyright (C) 2002-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+
+/*
+ * Local defines
+ */
+
+#define IDC_STATIC -1
+#define IDI_XWIN 101
+#define IDI_XWIN_BOXED 102
+#define IDM_TRAYICON_MENU 103
+#define IDC_CLIENTS_CONNECTED 104
+
+
+#define ID_APP_EXIT 200
+#define ID_APP_HIDE_ROOT 201
+#define ID_APP_ALWAYS_ON_TOP 202
+#define ID_APP_ABOUT 203
+#define ID_APP_SHOWCURSOR 204
+
+#define ID_ABOUT_UG 300
+#define ID_ABOUT_FAQ 301
+#define ID_ABOUT_CHANGELOG 302
+#define ID_ABOUT_WEBSITE 303
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/winrop.c b/nx-X11/programs/Xserver/hw/xwin/winrop.c
new file mode 100644
index 000000000..110292989
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winrop.c
@@ -0,0 +1,145 @@
+/*
+ *Copyright (C) 1994-2002 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Alan Hourihane <alanh@fairlite.demon.co.uk>
+ */
+/* $XFree86$ */
+
+/*
+ * Raster operations used by Windows translated to X's 16 rop codes...
+ */
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+void
+ROP16 (HDC hdc, int rop);
+
+int g_copyROP[16] = { 0xFF0062, /* GXclear - 0 */
+ 0x8800C6, /* GXand - S & D */
+ 0x440328, /* GXandReverse - S & !D */
+ 0xCC0020, /* GXcopy - S */
+ 0x220326, /* GXandInverted - !S & D */
+ 0xAA0029, /* GXnoop - D */
+ 0x660046, /* GXxor - S ^ D */
+ 0xEE0086, /* GXor - S | D */
+ 0x1100A6, /* GXnor - !S & !D */
+ 0x990126, /* GXequiv - !S ^ D */
+ 0x550009, /* GXinvert - !D */
+ 0xDD0228, /* GXorReverse - S | !D */
+ 0x330008, /* GXcopyInverted - !S */
+ 0xBB0226, /* GXorInverted - !S | D */
+ 0x7700C6, /* GXnand - !S | !D */
+ 0x000042 /* GXset - 1 */
+};
+
+int g_patternROP[16] = {0xFF0062, /* GXclear - 0 */
+ 0xA000C9, /* GXand - P & D */
+ 0xF50225, /* GXandReverse - P & !D */
+ 0xF00021, /* GXcopy - P */
+ 0x5F00E9, /* GXandInverted - !P & D */
+ 0xAA0029, /* GXnoop - D */
+ 0xA50065, /* GXxor - P ^ D */
+ 0xA000C9, /* GXor - P | D */
+ 0x5F00E9, /* GXnor - !P & !D */
+ 0x5A0049, /* GXequiv - !P ^ D */
+ 0x550009, /* GXinvert - !D */
+ 0x500325, /* GXorReverse - P | !D */
+ 0x0F0001, /* GXcopyInverted - !P */
+ 0x0A0329, /* GXorInverted - !P | D */
+ 0x0500A9, /* GXnand - !P | !D */
+ 0x000042 /* GXset - 1 */
+};
+
+
+void
+ROP16 (HDC hdc, int rop)
+{
+ switch (rop)
+ {
+ case GXclear:
+ SetROP2 (hdc, R2_BLACK);
+ break;
+
+ case GXand:
+ SetROP2 (hdc, R2_MASKPEN);
+ break;
+
+ case GXandReverse:
+ SetROP2 (hdc, R2_MASKPENNOT);
+ break;
+
+ case GXcopy:
+ SetROP2 (hdc, R2_COPYPEN);
+ break;
+
+ case GXnoop:
+ SetROP2 (hdc, R2_NOP);
+ break;
+
+ case GXxor:
+ SetROP2 (hdc, R2_XORPEN);
+ break;
+
+ case GXor:
+ SetROP2 (hdc, R2_MERGEPEN);
+ break;
+
+ case GXnor:
+ SetROP2 (hdc, R2_NOTMERGEPEN);
+ break;
+
+ case GXequiv:
+ SetROP2 (hdc, R2_NOTXORPEN);
+ break;
+
+ case GXinvert:
+ SetROP2 (hdc, R2_NOT);
+ break;
+
+ case GXorReverse:
+ SetROP2 (hdc, R2_MERGEPENNOT);
+ break;
+
+ case GXcopyInverted:
+ SetROP2 (hdc, R2_NOTCOPYPEN);
+ break;
+
+ case GXorInverted:
+ SetROP2 (hdc, R2_MERGENOTPEN);
+ break;
+
+ case GXnand:
+ SetROP2 (hdc, R2_NOTMASKPEN);
+ break;
+
+ case GXset:
+ SetROP2 (hdc, R2_WHITE);
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winscrinit.c b/nx-X11/programs/Xserver/hw/xwin/winscrinit.c
new file mode 100644
index 000000000..a18139c28
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winscrinit.c
@@ -0,0 +1,794 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ * Kensuke Matsuzaki
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winscrinit.c,v 1.27 2003/07/29 21:25:18 dawes Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winmsg.h"
+#include "safeAlpha.h"
+
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+static RootlessFrameProcsRec
+winMWExtWMProcs = {
+ winMWExtWMCreateFrame,
+ winMWExtWMDestroyFrame,
+
+ winMWExtWMMoveFrame,
+ winMWExtWMResizeFrame,
+ winMWExtWMRestackFrame,
+ winMWExtWMReshapeFrame,
+ winMWExtWMUnmapFrame,
+
+ winMWExtWMStartDrawing,
+ winMWExtWMStopDrawing,
+ winMWExtWMUpdateRegion,
+#ifndef ROOTLESS_TRACK_DAMAGE
+ winMWExtWMDamageRects,
+#endif
+ winMWExtWMRootlessSwitchWindow,
+ NULL,//winWMExtWMDoReorderWindow,
+
+ NULL,//winMWExtWMCopyBytes,
+ NULL,//winMWExtWMFillBytes,
+ NULL,//winMWExtWMCompositePixels,
+ winMWExtWMCopyWindow
+};
+#endif
+
+
+/*
+ * References to external symbols
+ */
+
+extern winScreenInfo g_ScreenInfo[];
+extern miPointerScreenFuncRec g_winPointerCursorFuncs;
+extern int g_iScreenPrivateIndex;
+extern Bool g_fSoftwareCursor;
+
+
+/*
+ * Prototypes
+ */
+
+Bool
+winRandRInit (ScreenPtr pScreen);
+
+
+/*
+ * Local functions
+ */
+
+static Bool
+winSaveScreen (ScreenPtr pScreen, int on);
+
+
+/*
+ * Determine what type of screen we are initializing
+ * and call the appropriate procedure to intiailize
+ * that type of screen.
+ */
+
+Bool
+winScreenInit (int index,
+ ScreenPtr pScreen,
+ int argc, char **argv)
+{
+ winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index];
+ winPrivScreenPtr pScreenPriv;
+ HDC hdc;
+
+#if CYGDEBUG || YES
+ winDebug ("winScreenInit - dwWidth: %ld dwHeight: %ld\n",
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight);
+#endif
+
+ /* Allocate privates for this screen */
+ if (!winAllocatePrivates (pScreen))
+ {
+ ErrorF ("winScreenInit - Couldn't allocate screen privates\n");
+ return FALSE;
+ }
+
+ /* Get a pointer to the privates structure that was allocated */
+ pScreenPriv = winGetScreenPriv (pScreen);
+
+ /* Save a pointer to this screen in the screen info structure */
+ pScreenInfo->pScreen = pScreen;
+
+ /* Save a pointer to the screen info in the screen privates structure */
+ /* This allows us to get back to the screen info from a screen pointer */
+ pScreenPriv->pScreenInfo = pScreenInfo;
+
+ /*
+ * Determine which engine to use.
+ *
+ * NOTE: This is done once per screen because each screen possibly has
+ * a preferred engine specified on the command line.
+ */
+ if (!winSetEngine (pScreen))
+ {
+ ErrorF ("winScreenInit - winSetEngine () failed\n");
+ return FALSE;
+ }
+
+ /* Adjust the video mode for our engine type */
+ if (!(*pScreenPriv->pwinAdjustVideoMode) (pScreen))
+ {
+ ErrorF ("winScreenInit - winAdjustVideoMode () failed\n");
+ return FALSE;
+ }
+
+ /* Check for supported display depth */
+ if (!(WIN_SUPPORTED_BPPS & (1 << (pScreenInfo->dwBPP - 1))))
+ {
+ ErrorF ("winScreenInit - Unsupported display depth: %d\n" \
+ "Change your Windows display depth to 15, 16, 24, or 32 bits "
+ "per pixel.\n",
+ (int) pScreenInfo->dwBPP);
+ ErrorF ("winScreenInit - Supported depths: %08x\n",
+ WIN_SUPPORTED_BPPS);
+#if WIN_CHECK_DEPTH
+ return FALSE;
+#endif
+ }
+
+ /*
+ * Check that all monitors have the same display depth if we are using
+ * multiple monitors
+ */
+ if (pScreenInfo->fMultipleMonitors
+ && !GetSystemMetrics (SM_SAMEDISPLAYFORMAT))
+ {
+ ErrorF ("winScreenInit - Monitors do not all have same pixel format / "
+ "display depth.\n"
+ "Using primary display only.\n");
+ pScreenInfo->fMultipleMonitors = FALSE;
+ }
+
+ /* Create display window */
+ if (!(*pScreenPriv->pwinCreateBoundingWindow) (pScreen))
+ {
+ ErrorF ("winScreenInit - pwinCreateBoundingWindow () "
+ "failed\n");
+ return FALSE;
+ }
+
+ /* Get a device context */
+ hdc = GetDC (pScreenPriv->hwndScreen);
+
+ /* Store the initial height, width, and depth of the display */
+ /* Are we using multiple monitors? */
+ if (pScreenInfo->fMultipleMonitors)
+ {
+ pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
+ pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
+
+ /*
+ * In this case, some of the defaults set in
+ * winInitializeDefaultScreens () are not correct ...
+ */
+ if (!pScreenInfo->fUserGaveHeightAndWidth)
+ {
+ pScreenInfo->dwWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
+ pScreenInfo->dwHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
+ pScreenInfo->dwWidth_mm = (pScreenInfo->dwWidth /
+ WIN_DEFAULT_DPI) * 25.4;
+ pScreenInfo->dwHeight_mm = (pScreenInfo->dwHeight /
+ WIN_DEFAULT_DPI) * 25.4;
+ }
+ }
+ else
+ {
+ pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXSCREEN);
+ pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYSCREEN);
+ }
+
+ /* Save the original bits per pixel */
+ pScreenPriv->dwLastWindowsBitsPixel = GetDeviceCaps (hdc, BITSPIXEL);
+
+ /* Release the device context */
+ ReleaseDC (pScreenPriv->hwndScreen, hdc);
+
+ /* Clear the visuals list */
+ miClearVisualTypes ();
+
+ /* Set the padded screen width */
+ pScreenInfo->dwPaddedWidth = PixmapBytePad (pScreenInfo->dwWidth,
+ pScreenInfo->dwBPP);
+
+ /* Call the engine dependent screen initialization procedure */
+ if (!((*pScreenPriv->pwinFinishScreenInit) (index, pScreen, argc, argv)))
+ {
+ ErrorF ("winScreenInit - winFinishScreenInit () failed\n");
+ return FALSE;
+ }
+
+ if (!g_fSoftwareCursor)
+ winInitCursor(pScreen);
+ else
+ winErrorFVerb(2, "winScreenInit - Using software cursor\n");
+
+#if CYGDEBUG || YES
+ winDebug ("winScreenInit - returning\n");
+#endif
+
+ return TRUE;
+}
+
+
+/* See Porting Layer Definition - p. 20 */
+Bool
+winFinishScreenInitFB (int index,
+ ScreenPtr pScreen,
+ int argc, char **argv)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ VisualPtr pVisual = NULL;
+ char *pbits = NULL;
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ int iReturn;
+#endif
+
+ /* Create framebuffer */
+ if (!(*pScreenPriv->pwinAllocateFB) (pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - Could not allocate framebuffer\n");
+ return FALSE;
+ }
+
+ /*
+ * Grab the number of bits that are used to represent color in each pixel.
+ */
+ if (pScreenInfo->dwBPP == 8)
+ pScreenInfo->dwDepth = 8;
+ else
+ pScreenInfo->dwDepth = winCountBits (pScreenPriv->dwRedMask)
+ + winCountBits (pScreenPriv->dwGreenMask)
+ + winCountBits (pScreenPriv->dwBlueMask);
+
+ winErrorFVerb (2, "winFinishScreenInitFB - Masks: %08x %08x %08x\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask);
+
+ /* Init visuals */
+ if (!(*pScreenPriv->pwinInitVisuals) (pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - winInitVisuals failed\n");
+ return FALSE;
+ }
+
+ /* Setup a local variable to point to the framebuffer */
+ pbits = pScreenInfo->pfb;
+
+ /* Apparently we need this for the render extension */
+ miSetPixmapDepths ();
+
+ /* Start fb initialization */
+ if (!fbSetupScreen (pScreen,
+ pScreenInfo->pfb,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ monitorResolution, monitorResolution,
+ pScreenInfo->dwStride,
+ pScreenInfo->dwBPP))
+ {
+ ErrorF ("winFinishScreenInitFB - fbSetupScreen failed\n");
+ return FALSE;
+ }
+
+ /* Override default colormap routines if visual class is dynamic */
+ if (pScreenInfo->dwDepth == 8
+ && (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
+ || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
+ && pScreenInfo->fFullScreen)
+ || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
+ && pScreenInfo->fFullScreen)))
+ {
+ winSetColormapFunctions (pScreen);
+
+ /*
+ * NOTE: Setting whitePixel to 255 causes Magic 7.1 to allocate its
+ * own colormap, as it cannot allocate 7 planes in the default
+ * colormap. Setting whitePixel to 1 allows Magic to get 7
+ * planes in the default colormap, so it doesn't create its
+ * own colormap. This latter situation is highly desireable,
+ * as it keeps the Magic window viewable when switching to
+ * other X clients that use the default colormap.
+ */
+ pScreen->blackPixel = 0;
+ pScreen->whitePixel = 1;
+ }
+
+ /* Place our save screen function */
+ pScreen->SaveScreen = winSaveScreen;
+
+ /* Backing store functions */
+ /*
+ * FIXME: Backing store support still doesn't seem to be working.
+ */
+ pScreen->BackingStoreFuncs.SaveAreas = fbSaveAreas;
+ pScreen->BackingStoreFuncs.RestoreAreas = fbRestoreAreas;
+
+ /* Finish fb initialization */
+ if (!fbFinishScreenInit (pScreen,
+ pScreenInfo->pfb,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ monitorResolution, monitorResolution,
+ pScreenInfo->dwStride,
+ pScreenInfo->dwBPP))
+ {
+ ErrorF ("winFinishScreenInitFB - fbFinishScreenInit failed\n");
+ return FALSE;
+ }
+
+ /* Save a pointer to the root visual */
+ for (pVisual = pScreen->visuals;
+ pVisual->vid != pScreen->rootVisual;
+ pVisual++);
+ pScreenPriv->pRootVisual = pVisual;
+
+ /*
+ * Setup points to the block and wakeup handlers. Pass a pointer
+ * to the current screen as pWakeupdata.
+ */
+ pScreen->BlockHandler = winBlockHandler;
+ pScreen->WakeupHandler = winWakeupHandler;
+ pScreen->blockData = pScreen;
+ pScreen->wakeupData = pScreen;
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ /*
+ * Setup acceleration for multi-window external window manager mode.
+ * To be compatible with the Damage extension, this must be done
+ * before calling miDCInitialize, which calls DamageSetup.
+ */
+ if (pScreenInfo->fMWExtWM)
+ {
+ if (!RootlessAccelInit (pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - RootlessAccelInit () failed\n");
+ return FALSE;
+ }
+ }
+#endif
+
+#ifdef RENDER
+ /* Render extension initialization, calls miPictureInit */
+ if (!fbPictureInit (pScreen, NULL, 0))
+ {
+ ErrorF ("winFinishScreenInitFB - fbPictureInit () failed\n");
+ return FALSE;
+ }
+#endif
+
+#ifdef RANDR
+ /* Initialize resize and rotate support */
+ if (!winRandRInit (pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - winRandRInit () failed\n");
+ return FALSE;
+ }
+#endif
+
+ /*
+ * Backing store support should reduce network traffic and increase
+ * performance.
+ */
+ miInitializeBackingStore (pScreen);
+
+ /* KDrive does miDCInitialize right after miInitializeBackingStore */
+ /* Setup the cursor routines */
+#if CYGDEBUG
+ winDebug ("winFinishScreenInitFB - Calling miDCInitialize ()\n");
+#endif
+ miDCInitialize (pScreen, &g_winPointerCursorFuncs);
+
+ /* KDrive does winCreateDefColormap right after miDCInitialize */
+ /* Create a default colormap */
+#if CYGDEBUG
+ winDebug ("winFinishScreenInitFB - Calling winCreateDefColormap ()\n");
+#endif
+ if (!winCreateDefColormap (pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - Could not create colormap\n");
+ return FALSE;
+ }
+
+ /* Initialize the shadow framebuffer layer */
+ if ((pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
+ || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
+ || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)
+#ifdef XWIN_MULTIWINDOWEXTWM
+ && !pScreenInfo->fMWExtWM
+#endif
+ )
+ {
+#if CYGDEBUG
+ winDebug ("winFinishScreenInitFB - Calling shadowInit ()\n");
+#endif
+ if (!shadowInit (pScreen,
+ pScreenPriv->pwinShadowUpdate,
+ NULL))
+ {
+ ErrorF ("winFinishScreenInitFB - shadowInit () failed\n");
+ return FALSE;
+ }
+ }
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ /* Handle multi-window external window manager mode */
+ if (pScreenInfo->fMWExtWM)
+ {
+ winDebug ("winScreenInit - MultiWindowExtWM - Calling RootlessInit\n");
+
+ RootlessInit(pScreen, &winMWExtWMProcs);
+
+ winDebug ("winScreenInit - MultiWindowExtWM - RootlessInit returned\n");
+
+ rootless_CopyBytes_threshold = 0;
+ rootless_FillBytes_threshold = 0;
+ rootless_CompositePixels_threshold = 0;
+ /* FIXME: How many? Profiling needed? */
+ rootless_CopyWindow_threshold = 1;
+
+ winWindowsWMExtensionInit ();
+ }
+#endif
+
+ /* Handle rootless mode */
+ if (pScreenInfo->fRootless)
+ {
+ /* Define the WRAP macro temporarily for local use */
+#define WRAP(a) \
+ if (pScreen->a) { \
+ pScreenPriv->a = pScreen->a; \
+ } else { \
+ ErrorF("null screen fn " #a "\n"); \
+ pScreenPriv->a = NULL; \
+ }
+
+ /* Save a pointer to each lower-level window procedure */
+ WRAP(CreateWindow);
+ WRAP(DestroyWindow);
+ WRAP(RealizeWindow);
+ WRAP(UnrealizeWindow);
+ WRAP(PositionWindow);
+ WRAP(ChangeWindowAttributes);
+#ifdef SHAPE
+ WRAP(SetShape);
+#endif
+
+ /* Assign rootless window procedures to be top level procedures */
+ pScreen->CreateWindow = winCreateWindowRootless;
+ pScreen->DestroyWindow = winDestroyWindowRootless;
+ pScreen->PositionWindow = winPositionWindowRootless;
+ /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesRootless;*/
+ pScreen->RealizeWindow = winMapWindowRootless;
+ pScreen->UnrealizeWindow = winUnmapWindowRootless;
+#ifdef SHAPE
+ pScreen->SetShape = winSetShapeRootless;
+#endif
+
+ /* Undefine the WRAP macro, as it is not needed elsewhere */
+#undef WRAP
+ }
+
+
+#ifdef XWIN_MULTIWINDOW
+ /* Handle multi window mode */
+ else if (pScreenInfo->fMultiWindow)
+ {
+ /* Define the WRAP macro temporarily for local use */
+#define WRAP(a) \
+ if (pScreen->a) { \
+ pScreenPriv->a = pScreen->a; \
+ } else { \
+ ErrorF("null screen fn " #a "\n"); \
+ pScreenPriv->a = NULL; \
+ }
+
+ /* Save a pointer to each lower-level window procedure */
+ WRAP(CreateWindow);
+ WRAP(DestroyWindow);
+ WRAP(RealizeWindow);
+ WRAP(UnrealizeWindow);
+ WRAP(PositionWindow);
+ WRAP(ChangeWindowAttributes);
+ WRAP(ReparentWindow);
+ WRAP(RestackWindow);
+ WRAP(ResizeWindow);
+ WRAP(MoveWindow);
+ WRAP(CopyWindow);
+#ifdef SHAPE
+ WRAP(SetShape);
+#endif
+
+ /* Assign multi-window window procedures to be top level procedures */
+ pScreen->CreateWindow = winCreateWindowMultiWindow;
+ pScreen->DestroyWindow = winDestroyWindowMultiWindow;
+ pScreen->PositionWindow = winPositionWindowMultiWindow;
+ /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesMultiWindow;*/
+ pScreen->RealizeWindow = winMapWindowMultiWindow;
+ pScreen->UnrealizeWindow = winUnmapWindowMultiWindow;
+ pScreen->ReparentWindow = winReparentWindowMultiWindow;
+ pScreen->RestackWindow = winRestackWindowMultiWindow;
+ pScreen->ResizeWindow = winResizeWindowMultiWindow;
+ pScreen->MoveWindow = winMoveWindowMultiWindow;
+ pScreen->CopyWindow = winCopyWindowMultiWindow;
+#ifdef SHAPE
+ pScreen->SetShape = winSetShapeMultiWindow;
+#endif
+
+ /* Undefine the WRAP macro, as it is not needed elsewhere */
+#undef WRAP
+ }
+#endif
+
+ /* Wrap either fb's or shadow's CloseScreen with our CloseScreen */
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = pScreenPriv->pwinCloseScreen;
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ /* Create a mutex for modules in separate threads to wait for */
+ iReturn = pthread_mutex_init (&pScreenPriv->pmServerStarted, NULL);
+ if (iReturn != 0)
+ {
+ ErrorF ("winFinishScreenInitFB - pthread_mutex_init () failed: %d\n",
+ iReturn);
+ return FALSE;
+ }
+
+ /* Own the mutex for modules in separate threads */
+ iReturn = pthread_mutex_lock (&pScreenPriv->pmServerStarted);
+ if (iReturn != 0)
+ {
+ ErrorF ("winFinishScreenInitFB - pthread_mutex_lock () failed: %d\n",
+ iReturn);
+ return FALSE;
+ }
+
+ /* Set the ServerStarted flag to false */
+ pScreenPriv->fServerStarted = FALSE;
+#endif
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ pScreenPriv->fRestacking = FALSE;
+#endif
+
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (FALSE
+#ifdef XWIN_MULTIWINDOW
+ || pScreenInfo->fMultiWindow
+#endif
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || pScreenInfo->fInternalWM
+#endif
+ )
+ {
+#if CYGDEBUG || YES
+ winDebug ("winFinishScreenInitFB - Calling winInitWM.\n");
+#endif
+
+ /* Initialize multi window mode */
+ if (!winInitWM (&pScreenPriv->pWMInfo,
+ &pScreenPriv->ptWMProc,
+ &pScreenPriv->ptXMsgProc,
+ &pScreenPriv->pmServerStarted,
+ pScreenInfo->dwScreen,
+ (HWND)&pScreenPriv->hwndScreen,
+#ifdef XWIN_MULTIWINDOWEXTWM
+ pScreenInfo->fInternalWM ||
+#endif
+ FALSE))
+ {
+ ErrorF ("winFinishScreenInitFB - winInitWM () failed.\n");
+ return FALSE;
+ }
+ }
+#endif
+
+ /* Tell the server that we are enabled */
+ pScreenPriv->fEnabled = TRUE;
+
+ /* Tell the server that we have a valid depth */
+ pScreenPriv->fBadDepth = FALSE;
+
+#if CYGDEBUG || YES
+ winDebug ("winFinishScreenInitFB - returning\n");
+#endif
+
+ return TRUE;
+}
+
+#ifdef XWIN_NATIVEGDI
+/* See Porting Layer Definition - p. 20 */
+
+Bool
+winFinishScreenInitNativeGDI (int index,
+ ScreenPtr pScreen,
+ int argc, char **argv)
+{
+ winScreenPriv(pScreen);
+ winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index];
+ VisualPtr pVisuals = NULL;
+ DepthPtr pDepths = NULL;
+ VisualID rootVisual = 0;
+ int nVisuals = 0, nDepths = 0, nRootDepth = 0;
+
+ /* Ignore user input (mouse, keyboard) */
+ pScreenInfo->fIgnoreInput = FALSE;
+
+ /* Get device contexts for the screen and shadow bitmap */
+ pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
+ if (pScreenPriv->hdcScreen == NULL)
+ FatalError ("winFinishScreenInitNativeGDI - Couldn't get a DC\n");
+
+ /* Init visuals */
+ if (!(*pScreenPriv->pwinInitVisuals) (pScreen))
+ {
+ ErrorF ("winFinishScreenInitNativeGDI - pwinInitVisuals failed\n");
+ return FALSE;
+ }
+
+ /* Initialize the mi visuals */
+ if (!miInitVisuals (&pVisuals, &pDepths, &nVisuals, &nDepths, &nRootDepth,
+ &rootVisual,
+ ((unsigned long)1 << (pScreenInfo->dwDepth - 1)), 8,
+ TrueColor))
+ {
+ ErrorF ("winFinishScreenInitNativeGDI - miInitVisuals () failed\n");
+ return FALSE;
+ }
+
+ /* Initialize the CloseScreen procedure pointer */
+ pScreen->CloseScreen = NULL;
+
+ /* Initialize the mi code */
+ if (!miScreenInit (pScreen,
+ NULL, /* No framebuffer */
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ monitorResolution, monitorResolution,
+ pScreenInfo->dwStride,
+ nRootDepth, nDepths, pDepths, rootVisual,
+ nVisuals, pVisuals))
+ {
+ ErrorF ("winFinishScreenInitNativeGDI - miScreenInit failed\n");
+ return FALSE;
+ }
+
+ pScreen->defColormap = FakeClientID(0);
+
+ /*
+ * Register our block and wakeup handlers; these procedures
+ * process messages in our Windows message queue; specifically,
+ * they process mouse and keyboard input.
+ */
+ pScreen->BlockHandler = winBlockHandler;
+ pScreen->WakeupHandler = winWakeupHandler;
+ pScreen->blockData = pScreen;
+ pScreen->wakeupData = pScreen;
+
+ /* Place our save screen function */
+ pScreen->SaveScreen = winSaveScreen;
+
+ /* Pixmaps */
+ pScreen->CreatePixmap = winCreatePixmapNativeGDI;
+ pScreen->DestroyPixmap = winDestroyPixmapNativeGDI;
+
+ /* Other Screen Routines */
+ pScreen->QueryBestSize = winQueryBestSizeNativeGDI;
+ pScreen->SaveScreen = winSaveScreen;
+ pScreen->GetImage = miGetImage;
+ pScreen->GetSpans = winGetSpansNativeGDI;
+
+ /* Window Procedures */
+ pScreen->CreateWindow = winCreateWindowNativeGDI;
+ pScreen->DestroyWindow = winDestroyWindowNativeGDI;
+ pScreen->PositionWindow = winPositionWindowNativeGDI;
+ /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesNativeGDI;*/
+ pScreen->RealizeWindow = winMapWindowNativeGDI;
+ pScreen->UnrealizeWindow = winUnmapWindowNativeGDI;
+
+ /* Paint window */
+ pScreen->PaintWindowBackground = miPaintWindow;
+ pScreen->PaintWindowBorder = miPaintWindow;
+ pScreen->CopyWindow = winCopyWindowNativeGDI;
+
+ /* Fonts */
+ pScreen->RealizeFont = winRealizeFontNativeGDI;
+ pScreen->UnrealizeFont = winUnrealizeFontNativeGDI;
+
+ /* GC */
+ pScreen->CreateGC = winCreateGCNativeGDI;
+
+ /* Colormap Routines */
+ pScreen->CreateColormap = miInitializeColormap;
+ pScreen->DestroyColormap = (DestroyColormapProcPtr) (void (*)(void)) NoopDDA;
+ pScreen->InstallColormap = miInstallColormap;
+ pScreen->UninstallColormap = miUninstallColormap;
+ pScreen->ListInstalledColormaps = miListInstalledColormaps;
+ pScreen->StoreColors = (StoreColorsProcPtr) (void (*)(void)) NoopDDA;
+ pScreen->ResolveColor = miResolveColor;
+
+ /* Bitmap */
+ pScreen->BitmapToRegion = winPixmapToRegionNativeGDI;
+
+ ErrorF ("winFinishScreenInitNativeGDI - calling miDCInitialize\n");
+
+ /* Set the default white and black pixel positions */
+ pScreen->whitePixel = pScreen->blackPixel = (Pixel) 0;
+
+ /* Initialize the cursor */
+ if (!miDCInitialize (pScreen, &g_winPointerCursorFuncs))
+ {
+ ErrorF ("winFinishScreenInitNativeGDI - miDCInitialize failed\n");
+ return FALSE;
+ }
+
+ /* Create a default colormap */
+ if (!miCreateDefColormap (pScreen))
+ {
+ ErrorF ("winFinishScreenInitNativeGDI - miCreateDefColormap () "
+ "failed\n");
+ return FALSE;
+ }
+
+ ErrorF ("winFinishScreenInitNativeGDI - miCreateDefColormap () "
+ "returned\n");
+
+ /* mi doesn't use a CloseScreen procedure, so no need to wrap */
+ pScreen->CloseScreen = pScreenPriv->pwinCloseScreen;
+
+ /* Tell the server that we are enabled */
+ pScreenPriv->fEnabled = TRUE;
+
+ ErrorF ("winFinishScreenInitNativeGDI - Successful addition of "
+ "screen %08x\n",
+ (unsigned int) pScreen);
+
+ return TRUE;
+}
+#endif
+
+
+/* See Porting Layer Definition - p. 33 */
+static Bool
+winSaveScreen (ScreenPtr pScreen, int on)
+{
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winsetsp.c b/nx-X11/programs/Xserver/hw/xwin/winsetsp.c
new file mode 100644
index 000000000..65b90ea39
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winsetsp.c
@@ -0,0 +1,196 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Harold L Hunt II
+ * Alan Hourihane <alanh@fairlite.demon.co.uk>
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winsetsp.c,v 1.7 2001/11/01 12:19:42 alanh Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * References to external symbols
+ */
+
+extern int g_iPixmapPrivateIndex;
+extern int g_iGCPrivateIndex;
+extern int g_copyROP[];
+
+
+/* See Porting Layer Definition - p. 55 */
+void
+winSetSpansNativeGDI (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *pSrcs,
+ DDXPointPtr pPoints,
+ int *piWidths,
+ int iSpans,
+ int fSorted)
+{
+ winGCPriv(pGC);
+ PixmapPtr pPixmap = NULL;
+ winPrivPixmapPtr pPixmapPriv = NULL;
+ HBITMAP hbmpOrig = NULL;
+ BITMAPINFO bmi;
+ HRGN hrgn = NULL, combined = NULL;
+ int nbox;
+ BoxPtr pbox;
+
+ nbox = REGION_NUM_RECTS (pGC->pCompositeClip);
+ pbox = REGION_RECTS (pGC->pCompositeClip);
+
+ if (!nbox) return;
+
+ combined = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+ nbox--; pbox++;
+ while (nbox--)
+ {
+ hrgn = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+ CombineRgn (combined, combined, hrgn, RGN_OR);
+ DeleteObject (hrgn);
+ hrgn = NULL;
+ pbox++;
+ }
+
+ /* Branch on the drawable type */
+ switch (pDrawable->type)
+ {
+ case DRAWABLE_PIXMAP:
+
+ SelectClipRgn (pGCPriv->hdcMem, combined);
+ DeleteObject (combined);
+ combined = NULL;
+
+ pPixmap = (PixmapPtr) pDrawable;
+ pPixmapPriv = winGetPixmapPriv (pPixmap);
+
+ /* Select the drawable pixmap into a DC */
+ hbmpOrig = SelectObject (pGCPriv->hdcMem, pPixmapPriv->hBitmap);
+ if (hbmpOrig == NULL)
+ FatalError ("winSetSpans - DRAWABLE_PIXMAP - SelectObject () "
+ "failed on pPixmapPriv->hBitmap\n");
+
+ while (iSpans--)
+ {
+ ZeroMemory (&bmi, sizeof (BITMAPINFO));
+ bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
+ bmi.bmiHeader.biWidth = *piWidths;
+ bmi.bmiHeader.biHeight = 1;
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = pDrawable->depth;
+ bmi.bmiHeader.biCompression = BI_RGB;
+
+ /* Setup color table for mono DIBs */
+ if (pDrawable->depth == 1)
+ {
+ bmi.bmiColors[1].rgbBlue = 255;
+ bmi.bmiColors[1].rgbGreen = 255;
+ bmi.bmiColors[1].rgbRed = 255;
+ }
+
+ StretchDIBits (pGCPriv->hdcMem,
+ pPoints->x, pPoints->y,
+ *piWidths, 1,
+ 0, 0,
+ *piWidths, 1,
+ pSrcs,
+ (BITMAPINFO *) &bmi,
+ DIB_RGB_COLORS,
+ g_copyROP[pGC->alu]);
+
+ pSrcs += PixmapBytePad (*piWidths, pDrawable->depth);
+ pPoints++;
+ piWidths++;
+ }
+
+ /* Reset the clip region */
+ SelectClipRgn (pGCPriv->hdcMem, NULL);
+
+ /* Push the drawable pixmap out of the GC HDC */
+ SelectObject (pGCPriv->hdcMem, hbmpOrig);
+ break;
+
+ case DRAWABLE_WINDOW:
+
+ SelectClipRgn (pGCPriv->hdc, combined);
+ DeleteObject (combined);
+ combined = NULL;
+
+ while (iSpans--)
+ {
+ ZeroMemory (&bmi, sizeof (BITMAPINFO));
+ bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
+ bmi.bmiHeader.biWidth = *piWidths;
+ bmi.bmiHeader.biHeight = 1;
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = pDrawable->depth;
+ bmi.bmiHeader.biCompression = BI_RGB;
+
+ /* Setup color table for mono DIBs */
+ if (pDrawable->depth == 1)
+ {
+ bmi.bmiColors[1].rgbBlue = 255;
+ bmi.bmiColors[1].rgbGreen = 255;
+ bmi.bmiColors[1].rgbRed = 255;
+ }
+
+ StretchDIBits (pGCPriv->hdc,
+ pPoints->x, pPoints->y,
+ *piWidths, 1,
+ 0, 0,
+ *piWidths, 1,
+ pSrcs,
+ (BITMAPINFO *) &bmi,
+ DIB_RGB_COLORS,
+ g_copyROP[pGC->alu]);
+
+ pSrcs += PixmapBytePad (*piWidths, pDrawable->depth);
+ pPoints++;
+ piWidths++;
+ }
+
+ /* Reset the clip region */
+ SelectClipRgn (pGCPriv->hdc, NULL);
+ break;
+
+ case UNDRAWABLE_WINDOW:
+ FatalError ("\nwinSetSpansNativeGDI - UNDRAWABLE_WINDOW\n\n");
+ break;
+
+ case DRAWABLE_BUFFER:
+ FatalError ("\nwinSetSpansNativeGDI - DRAWABLE_BUFFER\n\n");
+ break;
+
+ default:
+ FatalError ("\nwinSetSpansNativeGDI - Unknown drawable type\n\n");
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winshaddd.c b/nx-X11/programs/Xserver/hw/xwin/winshaddd.c
new file mode 100644
index 000000000..607a0674a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winshaddd.c
@@ -0,0 +1,1443 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winshaddd.c,v 1.22 2002/10/17 08:18:24 alanh Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * External symbols
+ */
+
+extern HWND g_hDlgExit;
+
+
+/*
+ * FIXME: Headers are broken, DEFINE_GUID doesn't work correctly,
+ * so we have to redefine it here.
+ */
+#ifdef DEFINE_GUID
+#undef DEFINE_GUID
+#define DEFINE_GUID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) const GUID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
+#endif /* DEFINE_GUID */
+
+
+/*
+ * FIXME: Headers are broken, IID_IDirectDraw4 has to be defined
+ * here manually. Should be handled by ddraw.h
+ */
+#ifndef IID_IDirectDraw2
+DEFINE_GUID( IID_IDirectDraw2,0xB3A6F3E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56 );
+#endif /* IID_IDirectDraw2 */
+
+
+/*
+ * Local prototypes
+ */
+
+static Bool
+winAllocateFBShadowDD (ScreenPtr pScreen);
+
+static void
+winShadowUpdateDD (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+static Bool
+winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen);
+
+static Bool
+winInitVisualsShadowDD (ScreenPtr pScreen);
+
+static Bool
+winAdjustVideoModeShadowDD (ScreenPtr pScreen);
+
+static Bool
+winBltExposedRegionsShadowDD (ScreenPtr pScreen);
+
+static Bool
+winActivateAppShadowDD (ScreenPtr pScreen);
+
+static Bool
+winRedrawScreenShadowDD (ScreenPtr pScreen);
+
+static Bool
+winRealizeInstalledPaletteShadowDD (ScreenPtr pScreen);
+
+static Bool
+winInstallColormapShadowDD (ColormapPtr pColormap);
+
+static Bool
+winStoreColorsShadowDD (ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs);
+
+static Bool
+winCreateColormapShadowDD (ColormapPtr pColormap);
+
+static Bool
+winDestroyColormapShadowDD (ColormapPtr pColormap);
+
+static Bool
+winCreatePrimarySurfaceShadowDD (ScreenPtr pScreen);
+
+static Bool
+winReleasePrimarySurfaceShadowDD (ScreenPtr pScreen);
+
+
+/*
+ * Create the primary surface and attach the clipper.
+ * Used for both the initial surface creation and during
+ * WM_DISPLAYCHANGE messages.
+ */
+
+static Bool
+winCreatePrimarySurfaceShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC ddsd;
+
+ /* Describe the primary surface */
+ ZeroMemory (&ddsd, sizeof (ddsd));
+ ddsd.dwSize = sizeof (ddsd);
+ ddsd.dwFlags = DDSD_CAPS;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+
+ /* Create the primary surface */
+ ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
+ &ddsd,
+ &pScreenPriv->pddsPrimary,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winCreatePrimarySurfaceShadowDD - Could not create primary "
+ "surface: %08x\n", (unsigned int) ddrval);
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winCreatePrimarySurfaceShadowDD - Created primary surface\n");
+#endif
+
+ /*
+ * Attach a clipper to the primary surface that will clip our blits to our
+ * display window.
+ */
+ ddrval = IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary,
+ pScreenPriv->pddcPrimary);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winCreatePrimarySurfaceShadowDD - Primary attach clipper "
+ "failed: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winCreatePrimarySurfaceShadowDD - Attached clipper to "
+ "primary surface\n");
+#endif
+
+ /* Everything was correct */
+ return TRUE;
+}
+
+
+/*
+ * Detach the clipper and release the primary surface.
+ * Called from WM_DISPLAYCHANGE.
+ */
+
+static Bool
+winReleasePrimarySurfaceShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ ErrorF ("winReleasePrimarySurfaceShadowDD - Hello\n");
+
+ /* Release the primary surface and clipper, if they exist */
+ if (pScreenPriv->pddsPrimary)
+ {
+ /*
+ * Detach the clipper from the primary surface.
+ * NOTE: We do this explicity for clarity. The Clipper is not released.
+ */
+ IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary,
+ NULL);
+
+ ErrorF ("winReleasePrimarySurfaceShadowDD - Detached clipper\n");
+
+ /* Release the primary surface */
+ IDirectDrawSurface2_Release (pScreenPriv->pddsPrimary);
+ pScreenPriv->pddsPrimary = NULL;
+ }
+
+ ErrorF ("winReleasePrimarySurfaceShadowDD - Released primary surface\n");
+
+ return TRUE;
+}
+
+
+/*
+ * Create a DirectDraw surface for the shadow framebuffer; also create
+ * a primary surface object so we can blit to the display.
+ *
+ * Install a DirectDraw clipper on our primary surface object
+ * that clips our blits to the unobscured client area of our display window.
+ */
+
+static Bool
+winAllocateFBShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC ddsd;
+ DDSURFACEDESC *pddsdShadow = NULL;
+
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowDD\n");
+#endif
+
+ /* Create a clipper */
+ ddrval = (*g_fpDirectDrawCreateClipper) (0,
+ &pScreenPriv->pddcPrimary,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not create clipper: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowDD - Created a clipper\n");
+#endif
+
+ /* Get a device context for the screen */
+ pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
+
+ /* Attach the clipper to our display window */
+ ddrval = IDirectDrawClipper_SetHWnd (pScreenPriv->pddcPrimary,
+ 0,
+ pScreenPriv->hwndScreen);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Clipper not attached to "
+ "window: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowDD - Attached clipper to window\n");
+#endif
+
+ /* Create a DirectDraw object, store the address at lpdd */
+ ddrval = (*g_fpDirectDrawCreate) (NULL, &pScreenPriv->pdd, NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not start DirectDraw: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowDD () - Created and initialized DD\n");
+#endif
+
+ /* Get a DirectDraw2 interface pointer */
+ ddrval = IDirectDraw_QueryInterface (pScreenPriv->pdd,
+ &IID_IDirectDraw2,
+ (LPVOID*) &pScreenPriv->pdd2);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Failed DD2 query: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ /* Are we full screen? */
+ if (pScreenInfo->fFullScreen)
+ {
+ DDSURFACEDESC ddsdCurrent;
+ DWORD dwRefreshRateCurrent = 0;
+ HDC hdc = NULL;
+
+ /* Set the cooperative level to full screen */
+ ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
+ pScreenPriv->hwndScreen,
+ DDSCL_EXCLUSIVE
+ | DDSCL_FULLSCREEN);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not set "
+ "cooperative level: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ /*
+ * We only need to get the current refresh rate for comparison
+ * if a refresh rate has been passed on the command line.
+ */
+ if (pScreenInfo->dwRefreshRate != 0)
+ {
+ ZeroMemory (&ddsdCurrent, sizeof (ddsdCurrent));
+ ddsdCurrent.dwSize = sizeof (ddsdCurrent);
+
+ /* Get information about current display settings */
+ ddrval = IDirectDraw2_GetDisplayMode (pScreenPriv->pdd2,
+ &ddsdCurrent);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not get current "
+ "refresh rate: %08x. Continuing.\n",
+ (unsigned int) ddrval);
+ dwRefreshRateCurrent = 0;
+ }
+ else
+ {
+ /* Grab the current refresh rate */
+ dwRefreshRateCurrent = ddsdCurrent.u2.dwRefreshRate;
+ }
+ }
+
+ /* Clean up the refresh rate */
+ if (dwRefreshRateCurrent == pScreenInfo->dwRefreshRate)
+ {
+ /*
+ * Refresh rate is non-specified or equal to current.
+ */
+ pScreenInfo->dwRefreshRate = 0;
+ }
+
+ /* Grab a device context for the screen */
+ hdc = GetDC (NULL);
+ if (hdc == NULL)
+ {
+ ErrorF ("winAllocateFBShadowDD - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Only change the video mode when different than current mode */
+ if (!pScreenInfo->fMultipleMonitors
+ && (pScreenInfo->dwWidth != GetSystemMetrics (SM_CXSCREEN)
+ || pScreenInfo->dwHeight != GetSystemMetrics (SM_CYSCREEN)
+ || pScreenInfo->dwBPP != GetDeviceCaps (hdc, BITSPIXEL)
+ || pScreenInfo->dwRefreshRate != 0))
+ {
+ ErrorF ("winAllocateFBShadowDD - Changing video mode\n");
+
+ /* Change the video mode to the mode requested */
+ ddrval = IDirectDraw2_SetDisplayMode (pScreenPriv->pdd2,
+ pScreenInfo->dwWidth,
+ pScreenInfo->dwHeight,
+ pScreenInfo->dwBPP,
+ pScreenInfo->dwRefreshRate,
+ 0);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not set "\
+ "full screen display mode: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+ }
+ else
+ {
+ ErrorF ("winAllocateFBShadowDD - Not changing video mode\n");
+ }
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+ hdc = NULL;
+ }
+ else
+ {
+ /* Set the cooperative level for windowed mode */
+ ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
+ pScreenPriv->hwndScreen,
+ DDSCL_NORMAL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not set "\
+ "cooperative level: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+ }
+
+ /* Create the primary surface */
+ if (!winCreatePrimarySurfaceShadowDD (pScreen))
+ {
+ ErrorF ("winAllocateFBShadowDD - winCreatePrimarySurfaceShadowDD "
+ "failed\n");
+ return FALSE;
+ }
+
+ /* Describe the shadow surface to be created */
+ /* NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
+ * as drawing, locking, and unlocking take forever
+ * with video memory surfaces. In addition,
+ * video memory is a somewhat scarce resource,
+ * so you shouldn't be allocating video memory when
+ * you have the option of using system memory instead.
+ */
+ ZeroMemory (&ddsd, sizeof (ddsd));
+ ddsd.dwSize = sizeof (ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
+ ddsd.dwHeight = pScreenInfo->dwHeight;
+ ddsd.dwWidth = pScreenInfo->dwWidth;
+
+ /* Create the shadow surface */
+ ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
+ &ddsd,
+ &pScreenPriv->pddsShadow,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not create shadow "\
+ "surface: %08x\n", (unsigned int) ddrval);
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowDD - Created shadow\n");
+#endif
+
+ /* Allocate a DD surface description for our screen privates */
+ pddsdShadow = pScreenPriv->pddsdShadow = malloc (sizeof (DDSURFACEDESC));
+ if (pddsdShadow == NULL)
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not allocate surface "\
+ "description memory\n");
+ return FALSE;
+ }
+ ZeroMemory (pddsdShadow, sizeof (*pddsdShadow));
+ pddsdShadow->dwSize = sizeof (*pddsdShadow);
+
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowDD - Locking shadow\n");
+#endif
+
+ /* Lock the shadow surface */
+ ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
+ NULL,
+ pddsdShadow,
+ DDLOCK_WAIT,
+ NULL);
+ if (FAILED (ddrval) || pddsdShadow->lpSurface == NULL)
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not lock shadow "\
+ "surface: %08x\n", (unsigned int) ddrval);
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowDD - Locked shadow\n");
+#endif
+
+ /* We don't know how to deal with anything other than RGB */
+ if (!(pddsdShadow->ddpfPixelFormat.dwFlags & DDPF_RGB))
+ {
+ ErrorF ("winAllocateFBShadowDD - Color format other than RGB\n");
+ return FALSE;
+ }
+
+ /* Grab the pitch from the surface desc */
+ pScreenInfo->dwStride = (pddsdShadow->u1.lPitch * 8)
+ / pScreenInfo->dwBPP;
+
+ /* Save the pointer to our surface memory */
+ pScreenInfo->pfb = pddsdShadow->lpSurface;
+
+ /* Grab the color depth and masks from the surface description */
+ pScreenPriv->dwRedMask = pddsdShadow->ddpfPixelFormat.u2.dwRBitMask;
+ pScreenPriv->dwGreenMask = pddsdShadow->ddpfPixelFormat.u3.dwGBitMask;
+ pScreenPriv->dwBlueMask = pddsdShadow->ddpfPixelFormat.u4.dwBBitMask;
+
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowDD - Returning\n");
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * Transfer the damaged regions of the shadow framebuffer to the display.
+ */
+
+static void
+winShadowUpdateDD (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RegionPtr damage = &pBuf->damage;
+ HRESULT ddrval = DD_OK;
+ RECT rcDest, rcSrc;
+ POINT ptOrigin;
+ DWORD dwBox = REGION_NUM_RECTS (damage);
+ BoxPtr pBox = REGION_RECTS (damage);
+ HRGN hrgnTemp = NULL, hrgnCombined = NULL;
+
+ /*
+ * Return immediately if the app is not active
+ * and we are fullscreen, or if we have a bad display depth
+ */
+ if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
+ || pScreenPriv->fBadDepth) return;
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&ptOrigin, 1);
+
+ /* Unlock the shadow surface, so we can blit */
+ ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winShadowUpdateProcDD - Unlock failed\n");
+ return;
+ }
+
+ /*
+ * Handle small regions with multiple blits,
+ * handle large regions by creating a clipping region and
+ * doing a single blit constrained to that clipping region.
+ */
+ if (pScreenInfo->dwClipUpdatesNBoxes == 0
+ || dwBox < pScreenInfo->dwClipUpdatesNBoxes)
+ {
+ /* Loop through all boxes in the damaged region */
+ while (dwBox--)
+ {
+ /* Assign damage box to source rectangle */
+ rcSrc.left = pBox->x1;
+ rcSrc.top = pBox->y1;
+ rcSrc.right = pBox->x2;
+ rcSrc.bottom = pBox->y2;
+
+ /* Calculate destination rectange */
+ rcDest.left = ptOrigin.x + rcSrc.left;
+ rcDest.top = ptOrigin.y + rcSrc.top;
+ rcDest.right = ptOrigin.x + rcSrc.right;
+ rcDest.bottom = ptOrigin.y + rcSrc.bottom;
+
+ /* Blit the damaged areas */
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
+ &rcDest,
+ pScreenPriv->pddsShadow,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+
+ /* Get a pointer to the next box */
+ ++pBox;
+ }
+ }
+ else
+ {
+ BoxPtr pBoxExtents = REGION_EXTENTS (pScreen, damage);
+
+ /* Compute a GDI region from the damaged region */
+ hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ dwBox--;
+ pBox++;
+ while (dwBox--)
+ {
+ hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
+ DeleteObject (hrgnTemp);
+ pBox++;
+ }
+
+ /* Install the GDI region as a clipping region */
+ SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined);
+ DeleteObject (hrgnCombined);
+ hrgnCombined = NULL;
+
+ /* Calculating a bounding box for the source is easy */
+ rcSrc.left = pBoxExtents->x1;
+ rcSrc.top = pBoxExtents->y1;
+ rcSrc.right = pBoxExtents->x2;
+ rcSrc.bottom = pBoxExtents->y2;
+
+ /* Calculating a bounding box for the destination is trickier */
+ rcDest.left = ptOrigin.x + rcSrc.left;
+ rcDest.top = ptOrigin.y + rcSrc.top;
+ rcDest.right = ptOrigin.x + rcSrc.right;
+ rcDest.bottom = ptOrigin.y + rcSrc.bottom;
+
+ /* Our Blt should be clipped to the invalidated region */
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
+ &rcDest,
+ pScreenPriv->pddsShadow,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+
+ /* Reset the clip region */
+ SelectClipRgn (pScreenPriv->hdcScreen, NULL);
+ }
+
+ /* Relock the shadow surface */
+ ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
+ NULL,
+ pScreenPriv->pddsdShadow,
+ DDLOCK_WAIT,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winShadowUpdateProcDD - Lock failed\n");
+ return;
+ }
+
+ /* Has our memory pointer changed? */
+ if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
+ {
+ ErrorF ("winShadowUpdateProcDD - Memory location of the shadow "
+ "surface has changed, trying to update the root window "
+ "pixmap header to point to the new address. If you get "
+ "this message and "PROJECT_NAME" freezes or crashes "
+ "after this message then send a problem report and your "
+ "/tmp/XWin.log file to cygwin-xfree@cygwin.com\n");
+
+ /* Location of shadow framebuffer has changed */
+ pScreenInfo->pfb = pScreenPriv->pddsdShadow->lpSurface;
+
+ /* Update the screen pixmap */
+ if (!(*pScreen->ModifyPixmapHeader)(pScreen->devPrivate,
+ pScreen->width,
+ pScreen->height,
+ pScreen->rootDepth,
+ BitsPerPixel (pScreen->rootDepth),
+ PixmapBytePad (pScreenInfo->dwStride,
+ pScreenInfo->dwBPP),
+ pScreenInfo->pfb))
+ {
+ ErrorF ("winShadowUpdateProcDD - Bits changed, could not "
+ "notify fb.\n");
+ return;
+ }
+ }
+}
+
+
+/*
+ * Call the wrapped CloseScreen function.
+ *
+ * Free our resources and private structures.
+ */
+
+static Bool
+winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ Bool fReturn;
+
+#if CYGDEBUG
+ winDebug ("winCloseScreenShadowDD - Freeing screen resources\n");
+#endif
+
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
+
+ /* Call the wrapped CloseScreen procedure */
+ WIN_UNWRAP(CloseScreen);
+ fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
+
+ /* Free the screen DC */
+ ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
+
+ /* Delete the window property */
+ RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
+
+ /* Free the shadow surface, if there is one */
+ if (pScreenPriv->pddsShadow)
+ {
+ IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
+ IDirectDrawSurface2_Release (pScreenPriv->pddsShadow);
+ pScreenPriv->pddsShadow = NULL;
+ }
+
+ /* Detach the clipper from the primary surface and release the clipper. */
+ if (pScreenPriv->pddcPrimary)
+ {
+ /* Detach the clipper */
+ IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary,
+ NULL);
+
+ /* Release the clipper object */
+ IDirectDrawClipper_Release (pScreenPriv->pddcPrimary);
+ pScreenPriv->pddcPrimary = NULL;
+ }
+
+ /* Release the primary surface, if there is one */
+ if (pScreenPriv->pddsPrimary)
+ {
+ IDirectDrawSurface2_Release (pScreenPriv->pddsPrimary);
+ pScreenPriv->pddsPrimary = NULL;
+ }
+
+ /* Free the DirectDraw2 object, if there is one */
+ if (pScreenPriv->pdd2)
+ {
+ IDirectDraw2_RestoreDisplayMode (pScreenPriv->pdd2);
+ IDirectDraw2_Release (pScreenPriv->pdd2);
+ pScreenPriv->pdd2 = NULL;
+ }
+
+ /* Free the DirectDraw object, if there is one */
+ if (pScreenPriv->pdd)
+ {
+ IDirectDraw_Release (pScreenPriv->pdd);
+ pScreenPriv->pdd = NULL;
+ }
+
+ /* Delete tray icon, if we have one */
+ if (!pScreenInfo->fNoTrayIcon)
+ winDeleteNotifyIcon (pScreenPriv);
+
+ /* Free the exit confirmation dialog box, if it exists */
+ if (g_hDlgExit != NULL)
+ {
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+ }
+
+ /* Kill our window */
+ if (pScreenPriv->hwndScreen)
+ {
+ DestroyWindow (pScreenPriv->hwndScreen);
+ pScreenPriv->hwndScreen = NULL;
+ }
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ /* Destroy the thread startup mutex */
+ pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
+#endif
+
+ /* Kill our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
+
+ /* Invalidate the ScreenInfo's fb pointer */
+ pScreenInfo->pfb = NULL;
+
+ /* Free the screen privates for this screen */
+ free ((pointer) pScreenPriv);
+
+ return fReturn;
+}
+
+
+/*
+ * Tell mi what sort of visuals we need.
+ *
+ * Generally we only need one visual, as our screen can only
+ * handle one format at a time, I believe. You may want
+ * to verify that last sentence.
+ */
+
+static Bool
+winInitVisualsShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ DWORD dwRedBits, dwGreenBits, dwBlueBits;
+
+ /* Count the number of ones in each color mask */
+ dwRedBits = winCountBits (pScreenPriv->dwRedMask);
+ dwGreenBits = winCountBits (pScreenPriv->dwGreenMask);
+ dwBlueBits = winCountBits (pScreenPriv->dwBlueMask);
+
+ /* Store the maximum number of ones in a color mask as the bitsPerRGB */
+ if (dwRedBits == 0 || dwGreenBits == 0 || dwBlueBits == 0)
+ pScreenPriv->dwBitsPerRGB = 8;
+ else if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwRedBits;
+ else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwGreenBits;
+ else
+ pScreenPriv->dwBitsPerRGB = dwBlueBits;
+
+ ErrorF ("winInitVisualsShadowDD - Masks %08x %08x %08x BPRGB %d d %d "
+ "bpp %d\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask,
+ (int) pScreenPriv->dwBitsPerRGB,
+ (int) pScreenInfo->dwDepth,
+ (int) pScreenInfo->dwBPP);
+
+ /* Create a single visual according to the Windows screen depth */
+ switch (pScreenInfo->dwDepth)
+ {
+ case 24:
+ case 16:
+ case 15:
+#if defined(XFree86Server)
+ /* Create the real visual */
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ TrueColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
+ "failed for TrueColor\n");
+ return FALSE;
+ }
+
+#ifdef XWIN_EMULATEPSEUDO
+ if (!pScreenInfo->fEmulatePseudo)
+ break;
+
+ /* Setup a pseudocolor visual */
+ if (!miSetVisualTypesAndMasks (8,
+ PseudoColorMask,
+ 8,
+ -1,
+ 0,
+ 0,
+ 0))
+ {
+ ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
+ "failed for PseudoColor\n");
+ return FALSE;
+ }
+#endif
+#else /* XFree86Server */
+ /* Create the real visual */
+ if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowDD - fbSetVisualTypesAndMasks "
+ "failed for TrueColor\n");
+ return FALSE;
+ }
+
+#ifdef XWIN_EMULATEPSEUDO
+ if (!pScreenInfo->fEmulatePseudo)
+ break;
+
+ /* Setup a pseudocolor visual */
+ if (!fbSetVisualTypesAndMasks (8,
+ PseudoColorMask,
+ 8,
+ 0,
+ 0,
+ 0))
+ {
+ ErrorF ("winInitVisualsShadowDD - fbSetVisualTypesAndMasks "
+ "failed for PseudoColor\n");
+ return FALSE;
+ }
+#endif
+#endif /* XFree86Server */
+ break;
+
+ case 8:
+#if defined(XFree86Server)
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ pScreenInfo->fFullScreen
+ ? PseudoColorMask : StaticColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenInfo->fFullScreen
+ ? PseudoColor : StaticColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+#else /* XFree86Server */
+ if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ pScreenInfo->fFullScreen
+ ? PseudoColorMask : StaticColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowDD - fbSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+#endif /* XFree86Server */
+ break;
+
+ default:
+ ErrorF ("winInitVisualsShadowDD - Unknown screen depth\n");
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winInitVisualsShadowDD - Returning\n");
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * Adjust the user proposed video mode
+ */
+
+static Bool
+winAdjustVideoModeShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc = NULL;
+ DWORD dwBPP;
+
+ /* We're in serious trouble if we can't get a DC */
+ hdc = GetDC (NULL);
+ if (hdc == NULL)
+ {
+ ErrorF ("winAdjustVideoModeShadowDD - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+
+ /* DirectDraw can only change the depth in fullscreen mode */
+ if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
+ {
+ /* No -depth parameter passed, let the user know the depth being used */
+ ErrorF ("winAdjustVideoModeShadowDD - Using Windows display "
+ "depth of %d bits per pixel\n", (int) dwBPP);
+
+ /* Use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+ else if (pScreenInfo->fFullScreen
+ && pScreenInfo->dwBPP != dwBPP)
+ {
+ /* FullScreen, and GDI depth differs from -depth parameter */
+ ErrorF ("winAdjustVideoModeShadowDD - FullScreen, using command line "
+ "bpp: %d\n", (int) pScreenInfo->dwBPP);
+ }
+ else if (dwBPP != pScreenInfo->dwBPP)
+ {
+ /* Windowed, and GDI depth differs from -depth parameter */
+ ErrorF ("winAdjustVideoModeShadowDD - Windowed, command line bpp: "
+ "%d, using bpp: %d\n", (int) pScreenInfo->dwBPP, (int) dwBPP);
+
+ /* We'll use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+
+ /* See if the shadow bitmap will be larger than the DIB size limit */
+ if (pScreenInfo->dwWidth * pScreenInfo->dwHeight * pScreenInfo->dwBPP
+ >= WIN_DIB_MAXIMUM_SIZE)
+ {
+ ErrorF ("winAdjustVideoModeShadowDD - Requested DirectDraw surface "
+ "will be larger than %d MB. The surface may fail to be "
+ "allocated on Windows 95, 98, or Me, due to a %d MB limit in "
+ "DIB size. This limit does not apply to Windows NT/2000, and "
+ "this message may be ignored on those platforms.\n",
+ WIN_DIB_MAXIMUM_SIZE_MB, WIN_DIB_MAXIMUM_SIZE_MB);
+ }
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+ return TRUE;
+}
+
+
+/*
+ * Blt exposed regions to the screen
+ */
+
+static Bool
+winBltExposedRegionsShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcSrc, rcDest;
+ POINT ptOrigin;
+ HDC hdcUpdate = NULL;
+ PAINTSTRUCT ps;
+ HRESULT ddrval = DD_OK;
+ Bool fReturn = TRUE;
+ Bool fLocked = TRUE;
+ int i;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
+ if (hdcUpdate == NULL)
+ {
+ ErrorF ("winBltExposedRegionsShadowDD - BeginPaint () returned "
+ "a NULL device context handle. Aborting blit attempt.\n");
+ return FALSE;
+ }
+
+ /* Unlock the shadow surface, so we can blit */
+ ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
+ if (FAILED (ddrval))
+ {
+ fReturn = FALSE;
+ goto winBltExposedRegionsShadowDD_Exit;
+ }
+ else
+ {
+ /* Flag that we have unlocked the shadow surface */
+ fLocked = FALSE;
+ }
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&ptOrigin, 1);
+ rcDest.left = ptOrigin.x;
+ rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
+ rcDest.top = ptOrigin.y;
+ rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
+
+ /* Source can be enter shadow surface, as Blt should clip */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Try to regain the primary surface and blit again if we've lost it */
+ for (i = 0; i <= WIN_REGAIN_SURFACE_RETRIES; ++i)
+ {
+ /* Our Blt should be clipped to the invalidated region */
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
+ &rcDest,
+ pScreenPriv->pddsShadow,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+ if (ddrval == DDERR_SURFACELOST)
+ {
+ /* Surface was lost */
+ ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt "
+ "reported that the primary surface was lost, "
+ "trying to restore, retry: %d\n", i + 1);
+
+ /* Try to restore the surface, once */
+ ddrval = IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
+ ErrorF ("winBltExposedRegionsShadowDD - "
+ "IDirectDrawSurface2_Restore returned: ");
+ if (ddrval == DD_OK)
+ ErrorF ("DD_OK\n");
+ else if (ddrval == DDERR_WRONGMODE)
+ ErrorF ("DDERR_WRONGMODE\n");
+ else if (ddrval == DDERR_INCOMPATIBLEPRIMARY)
+ ErrorF ("DDERR_INCOMPATIBLEPRIMARY\n");
+ else if (ddrval == DDERR_UNSUPPORTED)
+ ErrorF ("DDERR_UNSUPPORTED\n");
+ else if (ddrval == DDERR_INVALIDPARAMS)
+ ErrorF ("DDERR_INVALIDPARAMS\n");
+ else if (ddrval == DDERR_INVALIDOBJECT)
+ ErrorF ("DDERR_INVALIDOBJECT\n");
+ else
+ ErrorF ("unknown error: %08x\n", (unsigned int) ddrval);
+
+ /* Loop around to try the blit one more time */
+ continue;
+ }
+ else if (FAILED (ddrval))
+ {
+ fReturn = FALSE;
+ ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt "
+ "failed, but surface not lost: %08x %d\n",
+ (unsigned int) ddrval, (int) ddrval);
+ goto winBltExposedRegionsShadowDD_Exit;
+ }
+ else
+ {
+ /* Success, stop looping */
+ break;
+ }
+ }
+
+ /* Relock the shadow surface */
+ ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
+ NULL,
+ pScreenPriv->pddsdShadow,
+ DDLOCK_WAIT,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ fReturn = FALSE;
+ ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Lock "
+ "failed\n");
+ goto winBltExposedRegionsShadowDD_Exit;
+ }
+ else
+ {
+ /* Indicate that we have relocked the shadow surface */
+ fLocked = TRUE;
+ }
+
+ /* Has our memory pointer changed? */
+ if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
+ winUpdateFBPointer (pScreen,
+ pScreenPriv->pddsdShadow->lpSurface);
+
+ winBltExposedRegionsShadowDD_Exit:
+ /* EndPaint frees the DC */
+ if (hdcUpdate != NULL)
+ EndPaint (pScreenPriv->hwndScreen, &ps);
+
+ /*
+ * Relock the surface if it is not locked. We don't care if locking fails,
+ * as it will cause the server to shutdown within a few more operations.
+ */
+ if (!fLocked)
+ {
+ IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
+ NULL,
+ pScreenPriv->pddsdShadow,
+ DDLOCK_WAIT,
+ NULL);
+
+ /* Has our memory pointer changed? */
+ if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
+ winUpdateFBPointer (pScreen,
+ pScreenPriv->pddsdShadow->lpSurface);
+
+ fLocked = TRUE;
+ }
+ return fReturn;
+}
+
+
+/*
+ * Do any engine-specific appliation-activation processing
+ */
+
+static Bool
+winActivateAppShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ /*
+ * Do we have a surface?
+ * Are we active?
+ * Are we fullscreen?
+ */
+ if (pScreenPriv != NULL
+ && pScreenPriv->pddsPrimary != NULL
+ && pScreenPriv->fActive)
+ {
+ /* Primary surface was lost, restore it */
+ IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Reblit the shadow framebuffer to the screen.
+ */
+
+static Bool
+winRedrawScreenShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HRESULT ddrval = DD_OK;
+ RECT rcSrc, rcDest;
+ POINT ptOrigin;
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&ptOrigin, 1);
+ rcDest.left = ptOrigin.x;
+ rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
+ rcDest.top = ptOrigin.y;
+ rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
+
+ /* Source can be entire shadow surface, as Blt should clip for us */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Redraw the whole window, to take account for the new colors */
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
+ &rcDest,
+ pScreenPriv->pddsShadow,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winRedrawScreenShadowDD - IDirectDrawSurface_Blt () "
+ "failed: %08x\n",
+ (unsigned int) ddrval);
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Realize the currently installed colormap
+ */
+
+static Bool
+winRealizeInstalledPaletteShadowDD (ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+
+/*
+ * Install the specified colormap
+ */
+
+static Bool
+winInstallColormapShadowDD (ColormapPtr pColormap)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ HRESULT ddrval = DD_OK;
+
+ /* Install the DirectDraw palette on the primary surface */
+ ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary,
+ pCmapPriv->lpDDPalette);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winInstallColormapShadowDD - Failed installing the "
+ "DirectDraw palette.\n");
+ return FALSE;
+ }
+
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+
+ return TRUE;
+}
+
+
+/*
+ * Store the specified colors in the specified colormap
+ */
+
+static Bool
+winStoreColorsShadowDD (ColormapPtr pColormap,
+ int ndef,
+ xColorItem *pdefs)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
+ HRESULT ddrval = DD_OK;
+
+ /* Put the X colormap entries into the Windows logical palette */
+ ddrval = IDirectDrawPalette_SetEntries (pCmapPriv->lpDDPalette,
+ 0,
+ pdefs[0].pixel,
+ ndef,
+ pCmapPriv->peColors
+ + pdefs[0].pixel);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winStoreColorsShadowDD - SetEntries () failed\n");
+ return FALSE;
+ }
+
+ /* Don't install the DirectDraw palette if the colormap is not installed */
+ if (pColormap != curpmap)
+ {
+ return TRUE;
+ }
+
+ if (!winInstallColormapShadowDD (pColormap))
+ {
+ ErrorF ("winStoreColorsShadowDD - Failed installing colormap\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap initialization procedure
+ */
+
+static Bool
+winCreateColormapShadowDD (ColormapPtr pColormap)
+{
+ HRESULT ddrval = DD_OK;
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+
+ /* Create a DirectDraw palette */
+ ddrval = IDirectDraw2_CreatePalette (pScreenPriv->pdd,
+ DDPCAPS_8BIT | DDPCAPS_ALLOW256,
+ pCmapPriv->peColors,
+ &pCmapPriv->lpDDPalette,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winCreateColormapShadowDD - CreatePalette failed\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap destruction procedure
+ */
+
+static Bool
+winDestroyColormapShadowDD (ColormapPtr pColormap)
+{
+ winScreenPriv(pColormap->pScreen);
+ winCmapPriv(pColormap);
+ HRESULT ddrval = DD_OK;
+
+ /*
+ * Is colormap to be destroyed the default?
+ *
+ * Non-default colormaps should have had winUninstallColormap
+ * called on them before we get here. The default colormap
+ * will not have had winUninstallColormap called on it. Thus,
+ * we need to handle the default colormap in a special way.
+ */
+ if (pColormap->flags & IsDefault)
+ {
+#if CYGDEBUG
+ winDebug ("winDestroyColormapShadowDD - Destroying default "
+ "colormap\n");
+#endif
+
+ /*
+ * FIXME: Walk the list of all screens, popping the default
+ * palette out of each screen device context.
+ */
+
+ /* Pop the palette out of the primary surface */
+ ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winDestroyColormapShadowDD - Failed freeing the "
+ "default colormap DirectDraw palette.\n");
+ return FALSE;
+ }
+
+ /* Clear our private installed colormap pointer */
+ pScreenPriv->pcmapInstalled = NULL;
+ }
+
+ /* Release the palette */
+ IDirectDrawPalette_Release (pCmapPriv->lpDDPalette);
+
+ /* Invalidate the colormap privates */
+ pCmapPriv->lpDDPalette = NULL;
+
+ return TRUE;
+}
+
+
+/*
+ * Set engine specific functions
+ */
+
+Bool
+winSetEngineFunctionsShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBShadowDD;
+ pScreenPriv->pwinShadowUpdate = winShadowUpdateDD;
+ pScreenPriv->pwinCloseScreen = winCloseScreenShadowDD;
+ pScreenPriv->pwinInitVisuals = winInitVisualsShadowDD;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowDD;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDD;
+ pScreenPriv->pwinActivateApp = winActivateAppShadowDD;
+ pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowDD;
+ pScreenPriv->pwinRealizeInstalledPalette
+ = winRealizeInstalledPaletteShadowDD;
+ pScreenPriv->pwinInstallColormap = winInstallColormapShadowDD;
+ pScreenPriv->pwinStoreColors = winStoreColorsShadowDD;
+ pScreenPriv->pwinCreateColormap = winCreateColormapShadowDD;
+ pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowDD;
+ pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinCreatePrimarySurface = winCreatePrimarySurfaceShadowDD;
+ pScreenPriv->pwinReleasePrimarySurface = winReleasePrimarySurfaceShadowDD;
+#ifdef XWIN_MULTIWINDOW
+ pScreenPriv->pwinFinishCreateWindowsWindow =
+ (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA;
+#endif
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winshadddnl.c b/nx-X11/programs/Xserver/hw/xwin/winshadddnl.c
new file mode 100644
index 000000000..960cd2d70
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winshadddnl.c
@@ -0,0 +1,1455 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winshadddnl.c,v 1.23 2002/10/17 08:18:25 alanh Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * External symbols
+ */
+
+extern HWND g_hDlgExit;
+
+
+/*
+ * FIXME: Headers are broken, DEFINE_GUID doesn't work correctly,
+ * so we have to redefine it here.
+ */
+#ifdef DEFINE_GUID
+#undef DEFINE_GUID
+#define DEFINE_GUID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) const GUID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
+#endif /* DEFINE_GUID */
+
+/*
+ * FIXME: Headers are broken, IID_IDirectDraw4 has to be defined
+ * here manually. Should be handled by ddraw.h
+ */
+#ifndef IID_IDirectDraw4
+DEFINE_GUID( IID_IDirectDraw4, 0x9c59509a,0x39bd,0x11d1,0x8c,0x4a,0x00,0xc0,0x4f,0xd9,0x30,0xc5 );
+#endif /* IID_IDirectDraw4 */
+
+#define FAIL_MSG_MAX_BLT 10
+
+
+/*
+ * Local prototypes
+ */
+
+static Bool
+winAllocateFBShadowDDNL (ScreenPtr pScreen);
+
+static void
+winShadowUpdateDDNL (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+static Bool
+winCloseScreenShadowDDNL (int nIndex, ScreenPtr pScreen);
+
+static Bool
+winInitVisualsShadowDDNL (ScreenPtr pScreen);
+
+static Bool
+winAdjustVideoModeShadowDDNL (ScreenPtr pScreen);
+
+static Bool
+winBltExposedRegionsShadowDDNL (ScreenPtr pScreen);
+
+static Bool
+winActivateAppShadowDDNL (ScreenPtr pScreen);
+
+static Bool
+winRedrawScreenShadowDDNL (ScreenPtr pScreen);
+
+static Bool
+winRealizeInstalledPaletteShadowDDNL (ScreenPtr pScreen);
+
+static Bool
+winInstallColormapShadowDDNL (ColormapPtr pColormap);
+
+static Bool
+winStoreColorsShadowDDNL (ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs);
+
+static Bool
+winCreateColormapShadowDDNL (ColormapPtr pColormap);
+
+static Bool
+winDestroyColormapShadowDDNL (ColormapPtr pColormap);
+
+static Bool
+winCreatePrimarySurfaceShadowDDNL (ScreenPtr pScreen);
+
+static Bool
+winReleasePrimarySurfaceShadowDDNL (ScreenPtr pScreen);
+
+
+/*
+ * Create the primary surface and attach the clipper.
+ * Used for both the initial surface creation and during
+ * WM_DISPLAYCHANGE messages.
+ */
+
+static Bool
+winCreatePrimarySurfaceShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC2 ddsd;
+
+ winDebug ("winCreatePrimarySurfaceShadowDDNL - Creating primary surface\n");
+
+ /* Describe the primary surface */
+ ZeroMemory (&ddsd, sizeof (ddsd));
+ ddsd.dwSize = sizeof (ddsd);
+ ddsd.dwFlags = DDSD_CAPS;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+
+ /* Create the primary surface */
+ ddrval = IDirectDraw4_CreateSurface (pScreenPriv->pdd4,
+ &ddsd,
+ &pScreenPriv->pddsPrimary4,
+ NULL);
+ pScreenPriv->fRetryCreateSurface = FALSE;
+ if (FAILED (ddrval))
+ {
+ if (ddrval == DDERR_NOEXCLUSIVEMODE)
+ {
+ /* Recreating the surface failed. Mark screen to retry later */
+ pScreenPriv->fRetryCreateSurface = TRUE;
+ winDebug ("winCreatePrimarySurfaceShadowDDNL - Could not create "
+ "primary surface: DDERR_NOEXCLUSIVEMODE\n");
+ }
+ else
+ {
+ ErrorF ("winCreatePrimarySurfaceShadowDDNL - Could not create "
+ "primary surface: %08x\n", (unsigned int) ddrval);
+ }
+ return FALSE;
+ }
+
+#if 1
+ winDebug ("winCreatePrimarySurfaceShadowDDNL - Created primary surface\n");
+#endif
+
+ /* Attach our clipper to our primary surface handle */
+ ddrval = IDirectDrawSurface4_SetClipper (pScreenPriv->pddsPrimary4,
+ pScreenPriv->pddcPrimary);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winCreatePrimarySurfaceShadowDDNL - Primary attach clipper "
+ "failed: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+#if 1
+ winDebug ("winCreatePrimarySurfaceShadowDDNL - Attached clipper to primary "
+ "surface\n");
+#endif
+
+ /* Everything was correct */
+ return TRUE;
+}
+
+
+/*
+ * Detach the clipper and release the primary surface.
+ * Called from WM_DISPLAYCHANGE.
+ */
+
+static Bool
+winReleasePrimarySurfaceShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ winDebug ("winReleasePrimarySurfaceShadowDDNL - Hello\n");
+
+ /* Release the primary surface and clipper, if they exist */
+ if (pScreenPriv->pddsPrimary4)
+ {
+ /*
+ * Detach the clipper from the primary surface.
+ * NOTE: We do this explicity for clarity. The Clipper is not released.
+ */
+ IDirectDrawSurface4_SetClipper (pScreenPriv->pddsPrimary4,
+ NULL);
+
+ winDebug ("winReleasePrimarySurfaceShadowDDNL - Detached clipper\n");
+
+ /* Release the primary surface */
+ IDirectDrawSurface4_Release (pScreenPriv->pddsPrimary4);
+ pScreenPriv->pddsPrimary4 = NULL;
+ }
+
+ winDebug ("winReleasePrimarySurfaceShadowDDNL - Released primary surface\n");
+
+ return TRUE;
+}
+
+
+/*
+ * Create a DirectDraw surface for the shadow framebuffer; also create
+ * a primary surface object so we can blit to the display.
+ *
+ * Install a DirectDraw clipper on our primary surface object
+ * that clips our blits to the unobscured client area of our display window.
+ */
+
+Bool
+winAllocateFBShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC2 ddsdShadow;
+ char *lpSurface = NULL;
+ DDPIXELFORMAT ddpfPrimary;
+
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowDDNL - w %d h %d d %d\n",
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight, pScreenInfo->dwDepth);
+#endif
+
+ /* Allocate memory for our shadow surface */
+ lpSurface = malloc (pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
+ if (lpSurface == NULL)
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not allocate bits\n");
+ return FALSE;
+ }
+
+ /*
+ * Initialize the framebuffer memory so we don't get a
+ * strange display at startup
+ */
+ ZeroMemory (lpSurface, pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
+
+ /* Create a clipper */
+ ddrval = (*g_fpDirectDrawCreateClipper) (0,
+ &pScreenPriv->pddcPrimary,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not attach clipper: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowDDNL - Created a clipper\n");
+#endif
+
+ /* Get a device context for the screen */
+ pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
+
+ /* Attach the clipper to our display window */
+ ddrval = IDirectDrawClipper_SetHWnd (pScreenPriv->pddcPrimary,
+ 0,
+ pScreenPriv->hwndScreen);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Clipper not attached "
+ "to window: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowDDNL - Attached clipper to window\n");
+#endif
+
+ /* Create a DirectDraw object, store the address at lpdd */
+ ddrval = (*g_fpDirectDrawCreate) (NULL,
+ (LPDIRECTDRAW*) &pScreenPriv->pdd,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not start "
+ "DirectDraw: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowDDNL - Created and initialized DD\n");
+#endif
+
+ /* Get a DirectDraw4 interface pointer */
+ ddrval = IDirectDraw_QueryInterface (pScreenPriv->pdd,
+ &IID_IDirectDraw4,
+ (LPVOID*) &pScreenPriv->pdd4);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Failed DD4 query: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ /* Are we full screen? */
+ if (pScreenInfo->fFullScreen)
+ {
+ DDSURFACEDESC2 ddsdCurrent;
+ DWORD dwRefreshRateCurrent = 0;
+ HDC hdc = NULL;
+
+ /* Set the cooperative level to full screen */
+ ddrval = IDirectDraw4_SetCooperativeLevel (pScreenPriv->pdd4,
+ pScreenPriv->hwndScreen,
+ DDSCL_EXCLUSIVE
+ | DDSCL_FULLSCREEN);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not set "
+ "cooperative level: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ /*
+ * We only need to get the current refresh rate for comparison
+ * if a refresh rate has been passed on the command line.
+ */
+ if (pScreenInfo->dwRefreshRate != 0)
+ {
+ ZeroMemory (&ddsdCurrent, sizeof (ddsdCurrent));
+ ddsdCurrent.dwSize = sizeof (ddsdCurrent);
+
+ /* Get information about current display settings */
+ ddrval = IDirectDraw4_GetDisplayMode (pScreenPriv->pdd4,
+ &ddsdCurrent);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not get current "
+ "refresh rate: %08x. Continuing.\n",
+ (unsigned int) ddrval);
+ dwRefreshRateCurrent = 0;
+ }
+ else
+ {
+ /* Grab the current refresh rate */
+ dwRefreshRateCurrent = ddsdCurrent.u2.dwRefreshRate;
+ }
+ }
+
+ /* Clean up the refresh rate */
+ if (dwRefreshRateCurrent == pScreenInfo->dwRefreshRate)
+ {
+ /*
+ * Refresh rate is non-specified or equal to current.
+ */
+ pScreenInfo->dwRefreshRate = 0;
+ }
+
+ /* Grab a device context for the screen */
+ hdc = GetDC (NULL);
+ if (hdc == NULL)
+ {
+ ErrorF ("winAllocateFBShadowDDNL - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Only change the video mode when different than current mode */
+ if (!pScreenInfo->fMultipleMonitors
+ && (pScreenInfo->dwWidth != GetSystemMetrics (SM_CXSCREEN)
+ || pScreenInfo->dwHeight != GetSystemMetrics (SM_CYSCREEN)
+ || pScreenInfo->dwBPP != GetDeviceCaps (hdc, BITSPIXEL)
+ || pScreenInfo->dwRefreshRate != 0))
+ {
+ winDebug ("winAllocateFBShadowDDNL - Changing video mode\n");
+
+ /* Change the video mode to the mode requested */
+ ddrval = IDirectDraw4_SetDisplayMode (pScreenPriv->pdd4,
+ pScreenInfo->dwWidth,
+ pScreenInfo->dwHeight,
+ pScreenInfo->dwBPP,
+ pScreenInfo->dwRefreshRate,
+ 0);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not set "
+ "full screen display mode: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+ }
+ else
+ {
+ winDebug ("winAllocateFBShadowDDNL - Not changing video mode\n");
+ }
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+ hdc = NULL;
+ }
+ else
+ {
+ /* Set the cooperative level for windowed mode */
+ ddrval = IDirectDraw4_SetCooperativeLevel (pScreenPriv->pdd4,
+ pScreenPriv->hwndScreen,
+ DDSCL_NORMAL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not set "
+ "cooperative level: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+ }
+
+ /* Create the primary surface */
+ if (!winCreatePrimarySurfaceShadowDDNL (pScreen))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - winCreatePrimarySurfaceShadowDDNL "
+ "failed\n");
+ return FALSE;
+ }
+
+ /* Get primary surface's pixel format */
+ ZeroMemory (&ddpfPrimary, sizeof (ddpfPrimary));
+ ddpfPrimary.dwSize = sizeof (ddpfPrimary);
+ ddrval = IDirectDrawSurface4_GetPixelFormat (pScreenPriv->pddsPrimary4,
+ &ddpfPrimary);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not get primary "
+ "pixformat: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowDDNL - Primary masks: %08x %08x %08x "
+ "dwRGBBitCount: %d\n",
+ ddpfPrimary.u2.dwRBitMask,
+ ddpfPrimary.u3.dwGBitMask,
+ ddpfPrimary.u4.dwBBitMask,
+ ddpfPrimary.u1.dwRGBBitCount);
+#endif
+
+ /* Describe the shadow surface to be created */
+ /*
+ * NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
+ * as drawing, locking, and unlocking take forever
+ * with video memory surfaces. In addition,
+ * video memory is a somewhat scarce resource,
+ * so you shouldn't be allocating video memory when
+ * you have the option of using system memory instead.
+ */
+ ZeroMemory (&ddsdShadow, sizeof (ddsdShadow));
+ ddsdShadow.dwSize = sizeof (ddsdShadow);
+ ddsdShadow.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH
+ | DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT;
+ ddsdShadow.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
+ ddsdShadow.dwHeight = pScreenInfo->dwHeight;
+ ddsdShadow.dwWidth = pScreenInfo->dwWidth;
+ ddsdShadow.u1.lPitch = pScreenInfo->dwPaddedWidth;
+ ddsdShadow.lpSurface = lpSurface;
+ ddsdShadow.u4.ddpfPixelFormat = ddpfPrimary;
+
+ winDebug ("winAllocateFBShadowDDNL - lPitch: %d\n",
+ (int) pScreenInfo->dwPaddedWidth);
+
+ /* Create the shadow surface */
+ ddrval = IDirectDraw4_CreateSurface (pScreenPriv->pdd4,
+ &ddsdShadow,
+ &pScreenPriv->pddsShadow4,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not create shadow "
+ "surface: %08x\n", (unsigned int) ddrval);
+ return FALSE;
+ }
+
+#if CYGDEBUG || YES
+ winDebug ("winAllocateFBShadowDDNL - Created shadow pitch: %d\n",
+ (int) ddsdShadow.u1.lPitch);
+#endif
+
+ /* Grab the pitch from the surface desc */
+ pScreenInfo->dwStride = (ddsdShadow.u1.lPitch * 8)
+ / pScreenInfo->dwBPP;
+
+#if CYGDEBUG || YES
+ winDebug ("winAllocateFBShadowDDNL - Created shadow stride: %d\n",
+ (int) pScreenInfo->dwStride);
+#endif
+
+ /* Save the pointer to our surface memory */
+ pScreenInfo->pfb = lpSurface;
+
+ /* Grab the masks from the surface description */
+ pScreenPriv->dwRedMask = ddsdShadow.u4.ddpfPixelFormat.u2.dwRBitMask;
+ pScreenPriv->dwGreenMask = ddsdShadow.u4.ddpfPixelFormat.u3.dwGBitMask;
+ pScreenPriv->dwBlueMask = ddsdShadow.u4.ddpfPixelFormat.u4.dwBBitMask;
+
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowDDNL - Returning\n");
+#endif
+
+ return TRUE;
+}
+
+
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+/*
+ * Create a DirectDraw surface for the new multi-window window
+ */
+
+static
+Bool
+winFinishCreateWindowsWindowDDNL (WindowPtr pWin)
+{
+ winWindowPriv(pWin);
+ winPrivScreenPtr pScreenPriv = pWinPriv->pScreenPriv;
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC2 ddsd;
+ int iWidth, iHeight;
+ int iX, iY;
+
+ winDebug ("\nwinFinishCreateWindowsWindowDDNL!\n\n");
+
+ iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
+ iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ iWidth = pWin->drawable.width;
+ iHeight = pWin->drawable.height;
+
+ /* Describe the primary surface */
+ ZeroMemory (&ddsd, sizeof (ddsd));
+ ddsd.dwSize = sizeof (ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+ ddsd.dwHeight = iHeight;
+ ddsd.dwWidth = iWidth;
+
+ /* Create the primary surface */
+ ddrval = IDirectDraw4_CreateSurface (pScreenPriv->pdd4,
+ &ddsd,
+ &pWinPriv->pddsPrimary4,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winFinishCreateWindowsWindowDDNL - Could not create primary "
+ "surface: %08x\n",
+ (unsigned int)ddrval);
+ return FALSE;
+ }
+ return TRUE;
+}
+#endif
+
+
+/*
+ * Transfer the damaged regions of the shadow framebuffer to the display.
+ */
+
+static void
+winShadowUpdateDDNL (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RegionPtr damage = &pBuf->damage;
+ HRESULT ddrval = DD_OK;
+ RECT rcDest, rcSrc;
+ POINT ptOrigin;
+ DWORD dwBox = REGION_NUM_RECTS (damage);
+ BoxPtr pBox = REGION_RECTS (damage);
+ HRGN hrgnTemp = NULL, hrgnCombined = NULL;
+
+ /*
+ * Return immediately if the app is not active
+ * and we are fullscreen, or if we have a bad display depth
+ */
+ if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
+ || pScreenPriv->fBadDepth) return;
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&ptOrigin, 1);
+
+ /*
+ * Handle small regions with multiple blits,
+ * handle large regions by creating a clipping region and
+ * doing a single blit constrained to that clipping region.
+ */
+ if (pScreenInfo->dwClipUpdatesNBoxes == 0
+ || dwBox < pScreenInfo->dwClipUpdatesNBoxes)
+ {
+ /* Loop through all boxes in the damaged region */
+ while (dwBox--)
+ {
+ /* Assign damage box to source rectangle */
+ rcSrc.left = pBox->x1;
+ rcSrc.top = pBox->y1;
+ rcSrc.right = pBox->x2;
+ rcSrc.bottom = pBox->y2;
+
+ /* Calculate destination rectangle */
+ rcDest.left = ptOrigin.x + rcSrc.left;
+ rcDest.top = ptOrigin.y + rcSrc.top;
+ rcDest.right = ptOrigin.x + rcSrc.right;
+ rcDest.bottom = ptOrigin.y + rcSrc.bottom;
+
+ /* Blit the damaged areas */
+ ddrval = IDirectDrawSurface4_Blt (pScreenPriv->pddsPrimary4,
+ &rcDest,
+ pScreenPriv->pddsShadow4,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ static int s_iFailCount = 0;
+
+ if (s_iFailCount < FAIL_MSG_MAX_BLT)
+ {
+ ErrorF ("winShadowUpdateDDNL - IDirectDrawSurface4_Blt () "
+ "failed: %08x\n",
+ (unsigned int) ddrval);
+
+ ++s_iFailCount;
+
+ if (s_iFailCount == FAIL_MSG_MAX_BLT)
+ {
+ ErrorF ("winShadowUpdateDDNL - IDirectDrawSurface4_Blt "
+ "failure message maximum (%d) reached. No "
+ "more failure messages will be printed.\n",
+ FAIL_MSG_MAX_BLT);
+ }
+ }
+ }
+
+ /* Get a pointer to the next box */
+ ++pBox;
+ }
+ }
+ else
+ {
+ BoxPtr pBoxExtents = REGION_EXTENTS (pScreen, damage);
+
+ /* Compute a GDI region from the damaged region */
+ hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ dwBox--;
+ pBox++;
+ while (dwBox--)
+ {
+ hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
+ DeleteObject (hrgnTemp);
+ pBox++;
+ }
+
+ /* Install the GDI region as a clipping region */
+ SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined);
+ DeleteObject (hrgnCombined);
+ hrgnCombined = NULL;
+
+#if CYGDEBUG
+ winDebug ("winShadowUpdateDDNL - be x1 %d y1 %d x2 %d y2 %d\n",
+ pBoxExtents->x1, pBoxExtents->y1,
+ pBoxExtents->x2, pBoxExtents->y2);
+#endif
+
+ /* Calculating a bounding box for the source is easy */
+ rcSrc.left = pBoxExtents->x1;
+ rcSrc.top = pBoxExtents->y1;
+ rcSrc.right = pBoxExtents->x2;
+ rcSrc.bottom = pBoxExtents->y2;
+
+ /* Calculating a bounding box for the destination is trickier */
+ rcDest.left = ptOrigin.x + rcSrc.left;
+ rcDest.top = ptOrigin.y + rcSrc.top;
+ rcDest.right = ptOrigin.x + rcSrc.right;
+ rcDest.bottom = ptOrigin.y + rcSrc.bottom;
+
+ /* Our Blt should be clipped to the invalidated region */
+ ddrval = IDirectDrawSurface4_Blt (pScreenPriv->pddsPrimary4,
+ &rcDest,
+ pScreenPriv->pddsShadow4,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+
+ /* Reset the clip region */
+ SelectClipRgn (pScreenPriv->hdcScreen, NULL);
+ }
+}
+
+
+/*
+ * Call the wrapped CloseScreen function.
+ *
+ * Free our resources and private structures.
+ */
+
+static Bool
+winCloseScreenShadowDDNL (int nIndex, ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ Bool fReturn;
+
+#if CYGDEBUG
+ winDebug ("winCloseScreenShadowDDNL - Freeing screen resources\n");
+#endif
+
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
+
+ /* Call the wrapped CloseScreen procedure */
+ WIN_UNWRAP(CloseScreen);
+ fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
+
+ /* Free the screen DC */
+ ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
+
+ /* Delete the window property */
+ RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
+
+ /* Free the shadow surface, if there is one */
+ if (pScreenPriv->pddsShadow4)
+ {
+ IDirectDrawSurface4_Release (pScreenPriv->pddsShadow4);
+ free (pScreenInfo->pfb);
+ pScreenInfo->pfb = NULL;
+ pScreenPriv->pddsShadow4 = NULL;
+ }
+
+ /* Detach the clipper from the primary surface and release the clipper. */
+ if (pScreenPriv->pddcPrimary)
+ {
+ /* Detach the clipper */
+ IDirectDrawSurface4_SetClipper (pScreenPriv->pddsPrimary4,
+ NULL);
+
+ /* Release the clipper object */
+ IDirectDrawClipper_Release (pScreenPriv->pddcPrimary);
+ pScreenPriv->pddcPrimary = NULL;
+ }
+
+ /* Release the primary surface, if there is one */
+ if (pScreenPriv->pddsPrimary4)
+ {
+ IDirectDrawSurface4_Release (pScreenPriv->pddsPrimary4);
+ pScreenPriv->pddsPrimary4 = NULL;
+ }
+
+ /* Free the DirectDraw4 object, if there is one */
+ if (pScreenPriv->pdd4)
+ {
+ IDirectDraw4_RestoreDisplayMode (pScreenPriv->pdd4);
+ IDirectDraw4_Release (pScreenPriv->pdd4);
+ pScreenPriv->pdd4 = NULL;
+ }
+
+ /* Free the DirectDraw object, if there is one */
+ if (pScreenPriv->pdd)
+ {
+ IDirectDraw_Release (pScreenPriv->pdd);
+ pScreenPriv->pdd = NULL;
+ }
+
+ /* Delete tray icon, if we have one */
+ if (!pScreenInfo->fNoTrayIcon)
+ winDeleteNotifyIcon (pScreenPriv);
+
+ /* Free the exit confirmation dialog box, if it exists */
+ if (g_hDlgExit != NULL)
+ {
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+ }
+
+ /* Kill our window */
+ if (pScreenPriv->hwndScreen)
+ {
+ DestroyWindow (pScreenPriv->hwndScreen);
+ pScreenPriv->hwndScreen = NULL;
+ }
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ /* Destroy the thread startup mutex */
+ pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
+#endif
+
+ /* Kill our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
+
+ /* Invalidate the ScreenInfo's fb pointer */
+ pScreenInfo->pfb = NULL;
+
+ /* Free the screen privates for this screen */
+ free ((pointer) pScreenPriv);
+
+ return fReturn;
+}
+
+
+/*
+ * Tell mi what sort of visuals we need.
+ *
+ * Generally we only need one visual, as our screen can only
+ * handle one format at a time, I believe. You may want
+ * to verify that last sentence.
+ */
+
+static Bool
+winInitVisualsShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ DWORD dwRedBits, dwGreenBits, dwBlueBits;
+
+ /* Count the number of ones in each color mask */
+ dwRedBits = winCountBits (pScreenPriv->dwRedMask);
+ dwGreenBits = winCountBits (pScreenPriv->dwGreenMask);
+ dwBlueBits = winCountBits (pScreenPriv->dwBlueMask);
+
+ /* Store the maximum number of ones in a color mask as the bitsPerRGB */
+ if (dwRedBits == 0 || dwGreenBits == 0 || dwBlueBits == 0)
+ pScreenPriv->dwBitsPerRGB = 8;
+ else if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwRedBits;
+ else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwGreenBits;
+ else
+ pScreenPriv->dwBitsPerRGB = dwBlueBits;
+
+ winDebug ("winInitVisualsShadowDDNL - Masks %08x %08x %08x BPRGB %d d %d "
+ "bpp %d\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask,
+ (int) pScreenPriv->dwBitsPerRGB,
+ (int) pScreenInfo->dwDepth,
+ (int) pScreenInfo->dwBPP);
+
+ /* Create a single visual according to the Windows screen depth */
+ switch (pScreenInfo->dwDepth)
+ {
+ case 24:
+ case 16:
+ case 15:
+#if defined(XFree86Server)
+ /* Setup the real visual */
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ -1,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks "
+ "failed for TrueColor\n");
+ return FALSE;
+ }
+
+#ifdef XWIN_EMULATEPSEUDO
+ if (!pScreenInfo->fEmulatePseudo)
+ break;
+
+ /* Setup a pseudocolor visual */
+ if (!miSetVisualTypesAndMasks (8,
+ PseudoColorMask,
+ 8,
+ -1,
+ 0,
+ 0,
+ 0))
+ {
+ ErrorF ("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks "
+ "failed for PseudoColor\n");
+ return FALSE;
+ }
+#endif
+#else /* XFree86Server */
+ /* Setup the real visual */
+ if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowDDNL - fbSetVisualTypesAndMasks "
+ "failed for TrueColor\n");
+ return FALSE;
+ }
+
+#ifdef XWIN_EMULATEPSEUDO
+ if (!pScreenInfo->fEmulatePseudo)
+ break;
+
+ /* Setup a pseudocolor visual */
+ if (!fbSetVisualTypesAndMasks (8,
+ PseudoColorMask,
+ 8,
+ 0,
+ 0,
+ 0))
+ {
+ ErrorF ("winInitVisualsShadowDDNL - fbSetVisualTypesAndMasks "
+ "failed for PseudoColor\n");
+ return FALSE;
+ }
+#endif
+#endif /* XFree86Server */
+ break;
+
+ case 8:
+#if defined(XFree86Server)
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ pScreenInfo->fFullScreen
+ ? PseudoColorMask : StaticColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenInfo->fFullScreen
+ ? PseudoColor : StaticColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+#else /* XFree86Server */
+ if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ pScreenInfo->fFullScreen
+ ? PseudoColorMask : StaticColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowDDNL - fbSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+#endif /* XFree86Server */
+ break;
+
+ default:
+ ErrorF ("winInitVisualsShadowDDNL - Unknown screen depth\n");
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winInitVisualsShadowDDNL - Returning\n");
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * Adjust the user proposed video mode
+ */
+
+static Bool
+winAdjustVideoModeShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc = NULL;
+ DWORD dwBPP;
+
+ /* We're in serious trouble if we can't get a DC */
+ hdc = GetDC (NULL);
+ if (hdc == NULL)
+ {
+ ErrorF ("winAdjustVideoModeShadowDDNL - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+
+ /* DirectDraw can only change the depth in fullscreen mode */
+ if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
+ {
+ /* No -depth parameter passed, let the user know the depth being used */
+ winErrorFVerb (2, "winAdjustVideoModeShadowDDNL - Using Windows display "
+ "depth of %d bits per pixel\n", (int) dwBPP);
+
+ /* Use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+ else if (pScreenInfo->fFullScreen
+ && pScreenInfo->dwBPP != dwBPP)
+ {
+ /* FullScreen, and GDI depth differs from -depth parameter */
+ winErrorFVerb (2, "winAdjustVideoModeShadowDDNL - FullScreen, using command "
+ "line bpp: %d\n", (int) pScreenInfo->dwBPP);
+ }
+ else if (dwBPP != pScreenInfo->dwBPP)
+ {
+ /* Windowed, and GDI depth differs from -depth parameter */
+ winErrorFVerb (2, "winAdjustVideoModeShadowDDNL - Windowed, command line "
+ "bpp: %d, using bpp: %d\n",
+ (int) pScreenInfo->dwBPP, (int) dwBPP);
+
+ /* We'll use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+
+ /* See if the shadow bitmap will be larger than the DIB size limit */
+ if (pScreenInfo->dwWidth * pScreenInfo->dwHeight * pScreenInfo->dwBPP
+ >= WIN_DIB_MAXIMUM_SIZE)
+ {
+ winErrorFVerb (1, "winAdjustVideoModeShadowDDNL - Requested DirectDraw surface "
+ "will be larger than %d MB. The surface may fail to be "
+ "allocated on Windows 95, 98, or Me, due to a %d MB limit in "
+ "DIB size. This limit does not apply to Windows NT/2000, and "
+ "this message may be ignored on those platforms.\n",
+ WIN_DIB_MAXIMUM_SIZE_MB, WIN_DIB_MAXIMUM_SIZE_MB);
+ }
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+
+ return TRUE;
+}
+
+
+/*
+ * Blt exposed regions to the screen
+ */
+
+static Bool
+winBltExposedRegionsShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcSrc, rcDest;
+ POINT ptOrigin;
+ HDC hdcUpdate;
+ PAINTSTRUCT ps;
+ HRESULT ddrval = DD_OK;
+ Bool fReturn = TRUE;
+ int i;
+
+ /* Quite common case. The primary surface was lost (maybe because of depth
+ * change). Try to create a new primary surface. Bail out if this fails */
+ if (pScreenPriv->pddsPrimary4 == NULL && pScreenPriv->fRetryCreateSurface &&
+ !winCreatePrimarySurfaceShadowDDNL(pScreen))
+ {
+ Sleep(100);
+ return FALSE;
+ }
+ if (pScreenPriv->pddsPrimary4 == NULL)
+ return FALSE;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
+ if (hdcUpdate == NULL)
+ {
+ fReturn = FALSE;
+ ErrorF ("winBltExposedRegionsShadowDDNL - BeginPaint () returned "
+ "a NULL device context handle. Aborting blit attempt.\n");
+ goto winBltExposedRegionsShadowDDNL_Exit;
+ }
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&ptOrigin, 1);
+ rcDest.left = ptOrigin.x;
+ rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
+ rcDest.top = ptOrigin.y;
+ rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
+
+ /* Source can be entire shadow surface, as Blt should clip for us */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Try to regain the primary surface and blit again if we've lost it */
+ for (i = 0; i <= WIN_REGAIN_SURFACE_RETRIES; ++i)
+ {
+ /* Our Blt should be clipped to the invalidated region */
+ ddrval = IDirectDrawSurface4_Blt (pScreenPriv->pddsPrimary4,
+ &rcDest,
+ pScreenPriv->pddsShadow4,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+ if (ddrval == DDERR_SURFACELOST)
+ {
+ /* Surface was lost */
+ winErrorFVerb (1, "winBltExposedRegionsShadowDDNL - "
+ "IDirectDrawSurface4_Blt reported that the primary "
+ "surface was lost, trying to restore, retry: %d\n", i + 1);
+
+ /* Try to restore the surface, once */
+
+ ddrval = IDirectDrawSurface4_Restore (pScreenPriv->pddsPrimary4);
+ winDebug ("winBltExposedRegionsShadowDDNL - "
+ "IDirectDrawSurface4_Restore returned: ");
+ if (ddrval == DD_OK)
+ winDebug ("DD_OK\n");
+ else if (ddrval == DDERR_WRONGMODE)
+ winDebug ("DDERR_WRONGMODE\n");
+ else if (ddrval == DDERR_INCOMPATIBLEPRIMARY)
+ winDebug ("DDERR_INCOMPATIBLEPRIMARY\n");
+ else if (ddrval == DDERR_UNSUPPORTED)
+ winDebug ("DDERR_UNSUPPORTED\n");
+ else if (ddrval == DDERR_INVALIDPARAMS)
+ winDebug ("DDERR_INVALIDPARAMS\n");
+ else if (ddrval == DDERR_INVALIDOBJECT)
+ winDebug ("DDERR_INVALIDOBJECT\n");
+ else
+ winDebug ("unknown error: %08x\n", (unsigned int) ddrval);
+
+ /* Loop around to try the blit one more time */
+ continue;
+ }
+ else if (FAILED (ddrval))
+ {
+ fReturn = FALSE;
+ winErrorFVerb (1, "winBltExposedRegionsShadowDDNL - "
+ "IDirectDrawSurface4_Blt failed, but surface not "
+ "lost: %08x %d\n",
+ (unsigned int) ddrval, (int) ddrval);
+ goto winBltExposedRegionsShadowDDNL_Exit;
+ }
+ else
+ {
+ /* Success, stop looping */
+ break;
+ }
+ }
+
+ winBltExposedRegionsShadowDDNL_Exit:
+ /* EndPaint frees the DC */
+ if (hdcUpdate != NULL)
+ EndPaint (pScreenPriv->hwndScreen, &ps);
+ return fReturn;
+}
+
+
+/*
+ * Do any engine-specific application-activation processing
+ */
+
+static Bool
+winActivateAppShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ /*
+ * Do we have a surface?
+ * Are we active?
+ * Are we full screen?
+ */
+ if (pScreenPriv != NULL
+ && pScreenPriv->pddsPrimary4 != NULL
+ && pScreenPriv->fActive)
+ {
+ /* Primary surface was lost, restore it */
+ IDirectDrawSurface4_Restore (pScreenPriv->pddsPrimary4);
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Reblit the shadow framebuffer to the screen.
+ */
+
+static Bool
+winRedrawScreenShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HRESULT ddrval = DD_OK;
+ RECT rcSrc, rcDest;
+ POINT ptOrigin;
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&ptOrigin, 1);
+ rcDest.left = ptOrigin.x;
+ rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
+ rcDest.top = ptOrigin.y;
+ rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
+
+ /* Source can be entire shadow surface, as Blt should clip for us */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Redraw the whole window, to take account for the new colors */
+ ddrval = IDirectDrawSurface4_Blt (pScreenPriv->pddsPrimary4,
+ &rcDest,
+ pScreenPriv->pddsShadow4,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winRedrawScreenShadowDDNL - IDirectDrawSurface4_Blt () "
+ "failed: %08x\n",
+ (unsigned int) ddrval);
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Realize the currently installed colormap
+ */
+
+static Bool
+winRealizeInstalledPaletteShadowDDNL (ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+
+/*
+ * Install the specified colormap
+ */
+
+static Bool
+winInstallColormapShadowDDNL (ColormapPtr pColormap)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ HRESULT ddrval = DD_OK;
+
+ /* Install the DirectDraw palette on the primary surface */
+ ddrval = IDirectDrawSurface4_SetPalette (pScreenPriv->pddsPrimary4,
+ pCmapPriv->lpDDPalette);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winInstallColormapShadowDDNL - Failed installing the "
+ "DirectDraw palette.\n");
+ return FALSE;
+ }
+
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+
+ return TRUE;
+}
+
+
+/*
+ * Store the specified colors in the specified colormap
+ */
+
+static Bool
+winStoreColorsShadowDDNL (ColormapPtr pColormap,
+ int ndef,
+ xColorItem *pdefs)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
+ HRESULT ddrval = DD_OK;
+
+ /* Put the X colormap entries into the Windows logical palette */
+ ddrval = IDirectDrawPalette_SetEntries (pCmapPriv->lpDDPalette,
+ 0,
+ pdefs[0].pixel,
+ ndef,
+ pCmapPriv->peColors
+ + pdefs[0].pixel);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winStoreColorsShadowDDNL - SetEntries () failed: %08x\n", ddrval);
+ return FALSE;
+ }
+
+ /* Don't install the DirectDraw palette if the colormap is not installed */
+ if (pColormap != curpmap)
+ {
+ return TRUE;
+ }
+
+ if (!winInstallColormapShadowDDNL (pColormap))
+ {
+ ErrorF ("winStoreColorsShadowDDNL - Failed installing colormap\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap initialization procedure
+ */
+
+static Bool
+winCreateColormapShadowDDNL (ColormapPtr pColormap)
+{
+ HRESULT ddrval = DD_OK;
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+
+ /* Create a DirectDraw palette */
+ ddrval = IDirectDraw4_CreatePalette (pScreenPriv->pdd4,
+ DDPCAPS_8BIT | DDPCAPS_ALLOW256,
+ pCmapPriv->peColors,
+ &pCmapPriv->lpDDPalette,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winCreateColormapShadowDDNL - CreatePalette failed\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap destruction procedure
+ */
+
+static Bool
+winDestroyColormapShadowDDNL (ColormapPtr pColormap)
+{
+ winScreenPriv(pColormap->pScreen);
+ winCmapPriv(pColormap);
+ HRESULT ddrval = DD_OK;
+
+ /*
+ * Is colormap to be destroyed the default?
+ *
+ * Non-default colormaps should have had winUninstallColormap
+ * called on them before we get here. The default colormap
+ * will not have had winUninstallColormap called on it. Thus,
+ * we need to handle the default colormap in a special way.
+ */
+ if (pColormap->flags & IsDefault)
+ {
+#if CYGDEBUG
+ winDebug ("winDestroyColormapShadowDDNL - Destroying default colormap\n");
+#endif
+
+ /*
+ * FIXME: Walk the list of all screens, popping the default
+ * palette out of each screen device context.
+ */
+
+ /* Pop the palette out of the primary surface */
+ ddrval = IDirectDrawSurface4_SetPalette (pScreenPriv->pddsPrimary4,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winDestroyColormapShadowDDNL - Failed freeing the "
+ "default colormap DirectDraw palette.\n");
+ return FALSE;
+ }
+
+ /* Clear our private installed colormap pointer */
+ pScreenPriv->pcmapInstalled = NULL;
+ }
+
+ /* Release the palette */
+ IDirectDrawPalette_Release (pCmapPriv->lpDDPalette);
+
+ /* Invalidate the colormap privates */
+ pCmapPriv->lpDDPalette = NULL;
+
+ return TRUE;
+}
+
+
+/*
+ * Set pointers to our engine specific functions
+ */
+
+Bool
+winSetEngineFunctionsShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBShadowDDNL;
+ pScreenPriv->pwinShadowUpdate = winShadowUpdateDDNL;
+ pScreenPriv->pwinCloseScreen = winCloseScreenShadowDDNL;
+ pScreenPriv->pwinInitVisuals = winInitVisualsShadowDDNL;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowDDNL;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDDNL;
+ pScreenPriv->pwinActivateApp = winActivateAppShadowDDNL;
+ pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowDDNL;
+ pScreenPriv->pwinRealizeInstalledPalette
+ = winRealizeInstalledPaletteShadowDDNL;
+ pScreenPriv->pwinInstallColormap = winInstallColormapShadowDDNL;
+ pScreenPriv->pwinStoreColors = winStoreColorsShadowDDNL;
+ pScreenPriv->pwinCreateColormap = winCreateColormapShadowDDNL;
+ pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowDDNL;
+ pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinCreatePrimarySurface = winCreatePrimarySurfaceShadowDDNL;
+ pScreenPriv->pwinReleasePrimarySurface = winReleasePrimarySurfaceShadowDDNL;
+#ifdef XWIN_MULTIWINDOW
+ pScreenPriv->pwinFinishCreateWindowsWindow
+ = winFinishCreateWindowsWindowDDNL;
+#endif
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winshadgdi.c b/nx-X11/programs/Xserver/hw/xwin/winshadgdi.c
new file mode 100644
index 000000000..ba9819298
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winshadgdi.c
@@ -0,0 +1,1323 @@
+/*
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * External symbols
+ */
+
+#ifdef XWIN_MULTIWINDOW
+extern DWORD g_dwCurrentThreadID;
+#endif
+extern HWND g_hDlgExit;
+
+
+/*
+ * Local function prototypes
+ */
+
+#ifdef XWIN_MULTIWINDOW
+static wBOOL CALLBACK
+winRedrawAllProcShadowGDI (HWND hwnd, LPARAM lParam);
+
+static wBOOL CALLBACK
+winRedrawDamagedWindowShadowGDI (HWND hwnd, LPARAM lParam);
+#endif
+
+static Bool
+winAllocateFBShadowGDI (ScreenPtr pScreen);
+
+static void
+winShadowUpdateGDI (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+static Bool
+winCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen);
+
+static Bool
+winInitVisualsShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winAdjustVideoModeShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winBltExposedRegionsShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winActivateAppShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winRedrawScreenShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winInstallColormapShadowGDI (ColormapPtr pColormap);
+
+static Bool
+winStoreColorsShadowGDI (ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs);
+
+static Bool
+winCreateColormapShadowGDI (ColormapPtr pColormap);
+
+static Bool
+winDestroyColormapShadowGDI (ColormapPtr pColormap);
+
+
+/*
+ * Internal function to get the DIB format that is compatible with the screen
+ */
+
+static
+Bool
+winQueryScreenDIBFormat (ScreenPtr pScreen, BITMAPINFOHEADER *pbmih)
+{
+ winScreenPriv(pScreen);
+ HBITMAP hbmp;
+#if CYGDEBUG
+ LPDWORD pdw = NULL;
+#endif
+
+ /* Create a memory bitmap compatible with the screen */
+ hbmp = CreateCompatibleBitmap (pScreenPriv->hdcScreen, 1, 1);
+ if (hbmp == NULL)
+ {
+ ErrorF ("winQueryScreenDIBFormat - CreateCompatibleBitmap failed\n");
+ return FALSE;
+ }
+
+ /* Initialize our bitmap info header */
+ ZeroMemory (pbmih, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
+ pbmih->biSize = sizeof (BITMAPINFOHEADER);
+
+ /* Get the biBitCount */
+ if (!GetDIBits (pScreenPriv->hdcScreen,
+ hbmp,
+ 0, 1,
+ NULL,
+ (BITMAPINFO*) pbmih,
+ DIB_RGB_COLORS))
+ {
+ ErrorF ("winQueryScreenDIBFormat - First call to GetDIBits failed\n");
+ DeleteObject (hbmp);
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ /* Get a pointer to bitfields */
+ pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
+
+ winDebug ("winQueryScreenDIBFormat - First call masks: %08x %08x %08x\n",
+ pdw[0], pdw[1], pdw[2]);
+#endif
+
+ /* Get optimal color table, or the optimal bitfields */
+ if (!GetDIBits (pScreenPriv->hdcScreen,
+ hbmp,
+ 0, 1,
+ NULL,
+ (BITMAPINFO*)pbmih,
+ DIB_RGB_COLORS))
+ {
+ ErrorF ("winQueryScreenDIBFormat - Second call to GetDIBits "
+ "failed\n");
+ DeleteObject (hbmp);
+ return FALSE;
+ }
+
+ /* Free memory */
+ DeleteObject (hbmp);
+
+ return TRUE;
+}
+
+
+/*
+ * Internal function to determine the GDI bits per rgb and bit masks
+ */
+
+static
+Bool
+winQueryRGBBitsAndMasks (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ BITMAPINFOHEADER *pbmih = NULL;
+ Bool fReturn = TRUE;
+ LPDWORD pdw = NULL;
+ DWORD dwRedBits, dwGreenBits, dwBlueBits;
+
+ /* Color masks for 8 bpp are standardized */
+ if (GetDeviceCaps (pScreenPriv->hdcScreen, RASTERCAPS) & RC_PALETTE)
+ {
+ /*
+ * RGB BPP for 8 bit palletes is always 8
+ * and the color masks are always 0.
+ */
+ pScreenPriv->dwBitsPerRGB = 8;
+ pScreenPriv->dwRedMask = 0x0L;
+ pScreenPriv->dwGreenMask = 0x0L;
+ pScreenPriv->dwBlueMask = 0x0L;
+ return TRUE;
+ }
+
+ /* Color masks for 24 bpp are standardized */
+ if (GetDeviceCaps (pScreenPriv->hdcScreen, PLANES)
+ * GetDeviceCaps (pScreenPriv->hdcScreen, BITSPIXEL) == 24)
+ {
+ ErrorF ("winQueryRGBBitsAndMasks - GetDeviceCaps (BITSPIXEL) "
+ "returned 24 for the screen. Using default 24bpp masks.\n");
+
+ /* 8 bits per primary color */
+ pScreenPriv->dwBitsPerRGB = 8;
+
+ /* Set screen privates masks */
+ pScreenPriv->dwRedMask = WIN_24BPP_MASK_RED;
+ pScreenPriv->dwGreenMask = WIN_24BPP_MASK_GREEN;
+ pScreenPriv->dwBlueMask = WIN_24BPP_MASK_BLUE;
+
+ return TRUE;
+ }
+
+ /* Allocate a bitmap header and color table */
+ pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
+ + 256 * sizeof (RGBQUAD));
+ if (pbmih == NULL)
+ {
+ ErrorF ("winQueryRGBBitsAndMasks - malloc failed\n");
+ return FALSE;
+ }
+
+ /* Get screen description */
+ if (winQueryScreenDIBFormat (pScreen, pbmih))
+ {
+ /* Get a pointer to bitfields */
+ pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
+
+#if CYGDEBUG
+ winDebug ("%s - Masks: %08x %08x %08x\n", __FUNCTION__,
+ pdw[0], pdw[1], pdw[2]);
+ winDebug ("%s - Bitmap: %dx%d %d bpp %d planes\n", __FUNCTION__,
+ pbmih->biWidth, pbmih->biHeight, pbmih->biBitCount, pbmih->biPlanes);
+ winDebug ("%s - Compression: %d %s\n", __FUNCTION__,
+ pbmih->biCompression,
+ (pbmih->biCompression == BI_RGB?"(BI_RGB)":
+ (pbmih->biCompression == BI_RLE8?"(BI_RLE8)":
+ (pbmih->biCompression == BI_RLE4?"(BI_RLE4)":
+ (pbmih->biCompression == BI_BITFIELDS?"(BI_BITFIELDS)":""
+ )))));
+#endif
+
+ /* Handle BI_RGB case, which is returned by Wine */
+ if (pbmih->biCompression == BI_RGB)
+ {
+ dwRedBits = 5;
+ dwGreenBits = 5;
+ dwBlueBits = 5;
+
+ pScreenPriv->dwBitsPerRGB = 5;
+
+ /* Set screen privates masks */
+ pScreenPriv->dwRedMask = 0x7c00;
+ pScreenPriv->dwGreenMask = 0x03e0;
+ pScreenPriv->dwBlueMask = 0x001f;
+ }
+ else
+ {
+ /* Count the number of bits in each mask */
+ dwRedBits = winCountBits (pdw[0]);
+ dwGreenBits = winCountBits (pdw[1]);
+ dwBlueBits = winCountBits (pdw[2]);
+
+ /* Find maximum bits per red, green, blue */
+ if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwRedBits;
+ else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwGreenBits;
+ else
+ pScreenPriv->dwBitsPerRGB = dwBlueBits;
+
+ /* Set screen privates masks */
+ pScreenPriv->dwRedMask = pdw[0];
+ pScreenPriv->dwGreenMask = pdw[1];
+ pScreenPriv->dwBlueMask = pdw[2];
+ }
+ }
+ else
+ {
+ ErrorF ("winQueryRGBBitsAndMasks - winQueryScreenDIBFormat failed\n");
+ free (pbmih);
+ fReturn = FALSE;
+ }
+
+ /* Free memory */
+ free (pbmih);
+
+ return fReturn;
+}
+
+
+#ifdef XWIN_MULTIWINDOW
+/*
+ * Redraw all ---?
+ */
+
+static wBOOL CALLBACK
+winRedrawAllProcShadowGDI (HWND hwnd, LPARAM lParam)
+{
+ if (hwnd == (HWND)lParam)
+ return TRUE;
+ InvalidateRect (hwnd, NULL, FALSE);
+ UpdateWindow (hwnd);
+ return TRUE;
+}
+
+static wBOOL CALLBACK
+winRedrawDamagedWindowShadowGDI (HWND hwnd, LPARAM lParam)
+{
+ BoxPtr pDamage = (BoxPtr)lParam;
+ RECT rcClient, rcDamage, rcRedraw;
+ POINT topLeft, bottomRight;
+
+ if (IsIconic (hwnd))
+ return TRUE; /* Don't care minimized windows */
+
+ /* Convert the damaged area from Screen coords to Client coords */
+ topLeft.x = pDamage->x1; topLeft.y = pDamage->y1;
+ bottomRight.x = pDamage->x2; bottomRight.y = pDamage->y2;
+ topLeft.x += GetSystemMetrics (SM_XVIRTUALSCREEN);
+ bottomRight.x += GetSystemMetrics (SM_XVIRTUALSCREEN);
+ topLeft.y += GetSystemMetrics (SM_YVIRTUALSCREEN);
+ bottomRight.y += GetSystemMetrics (SM_YVIRTUALSCREEN);
+ ScreenToClient (hwnd, &topLeft);
+ ScreenToClient (hwnd, &bottomRight);
+ SetRect (&rcDamage, topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
+
+ GetClientRect (hwnd, &rcClient);
+
+ if (IntersectRect (&rcRedraw, &rcClient, &rcDamage))
+ {
+ InvalidateRect (hwnd, &rcRedraw, FALSE);
+ UpdateWindow (hwnd);
+ }
+ return TRUE;
+}
+#endif
+
+
+/*
+ * Allocate a DIB for the shadow framebuffer GDI server
+ */
+
+static Bool
+winAllocateFBShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ BITMAPINFOHEADER *pbmih = NULL;
+ DIBSECTION dibsection;
+ Bool fReturn = TRUE;
+
+ /* Get device contexts for the screen and shadow bitmap */
+ pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
+ pScreenPriv->hdcShadow = CreateCompatibleDC (pScreenPriv->hdcScreen);
+
+ /* Allocate bitmap info header */
+ pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
+ + 256 * sizeof (RGBQUAD));
+ if (pbmih == NULL)
+ {
+ ErrorF ("winAllocateFBShadowGDI - malloc () failed\n");
+ return FALSE;
+ }
+
+ /* Query the screen format */
+ fReturn = winQueryScreenDIBFormat (pScreen, pbmih);
+
+ /* Describe shadow bitmap to be created */
+ pbmih->biWidth = pScreenInfo->dwWidth;
+ pbmih->biHeight = -pScreenInfo->dwHeight;
+
+ ErrorF ("winAllocateFBShadowGDI - Creating DIB with width: %d height: %d "
+ "depth: %d\n",
+ (int) pbmih->biWidth, (int) -pbmih->biHeight, pbmih->biBitCount);
+
+ /* Create a DI shadow bitmap with a bit pointer */
+ pScreenPriv->hbmpShadow = CreateDIBSection (pScreenPriv->hdcScreen,
+ (BITMAPINFO *) pbmih,
+ DIB_RGB_COLORS,
+ (VOID**) &pScreenInfo->pfb,
+ NULL,
+ 0);
+ if (pScreenPriv->hbmpShadow == NULL || pScreenInfo->pfb == NULL)
+ {
+ winW32Error (2, "winAllocateFBShadowGDI - CreateDIBSection failed:");
+ return FALSE;
+ }
+ else
+ {
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowGDI - Shadow buffer allocated\n");
+#endif
+ }
+
+ /* Get information about the bitmap that was allocated */
+ GetObject (pScreenPriv->hbmpShadow,
+ sizeof (dibsection),
+ &dibsection);
+
+#if CYGDEBUG || YES
+ /* Print information about bitmap allocated */
+ winDebug ("winAllocateFBShadowGDI - Dibsection width: %d height: %d "
+ "depth: %d size image: %d\n",
+ (int) dibsection.dsBmih.biWidth, (int) dibsection.dsBmih.biHeight,
+ dibsection.dsBmih.biBitCount,
+ (int) dibsection.dsBmih.biSizeImage);
+#endif
+
+ /* Select the shadow bitmap into the shadow DC */
+ SelectObject (pScreenPriv->hdcShadow,
+ pScreenPriv->hbmpShadow);
+
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowGDI - Attempting a shadow blit\n");
+#endif
+
+ /* Do a test blit from the shadow to the screen, I think */
+ fReturn = BitBlt (pScreenPriv->hdcScreen,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+ if (fReturn)
+ {
+#if CYGDEBUG
+ winDebug ("winAllocateFBShadowGDI - Shadow blit success\n");
+#endif
+ }
+ else
+ {
+ winW32Error (2, "winAllocateFBShadowGDI - Shadow blit failure\n");
+#if 0
+ return FALSE;
+#else
+ /* ago: ignore this error. The blit fails with wine, but does not
+ * cause any problems later. */
+
+ fReturn = TRUE;
+#endif
+ }
+
+ /* Look for height weirdness */
+ if (dibsection.dsBmih.biHeight < 0)
+ {
+ dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight;
+ }
+
+ /* Set screeninfo stride */
+ pScreenInfo->dwStride = ((dibsection.dsBmih.biSizeImage
+ / dibsection.dsBmih.biHeight)
+ * 8) / pScreenInfo->dwBPP;
+
+#if CYGDEBUG || YES
+ winDebug ("winAllocateFBShadowGDI - Created shadow stride: %d\n",
+ (int) pScreenInfo->dwStride);
+#endif
+
+ /* See if the shadow bitmap will be larger than the DIB size limit */
+ if (pScreenInfo->dwWidth * pScreenInfo->dwHeight * pScreenInfo->dwBPP
+ >= WIN_DIB_MAXIMUM_SIZE)
+ {
+ ErrorF ("winAllocateFBShadowGDI - Requested DIB (bitmap) "
+ "will be larger than %d MB. The surface may fail to be "
+ "allocated on Windows 95, 98, or Me, due to a %d MB limit in "
+ "DIB size. This limit does not apply to Windows NT/2000, and "
+ "this message may be ignored on those platforms.\n",
+ WIN_DIB_MAXIMUM_SIZE_MB, WIN_DIB_MAXIMUM_SIZE_MB);
+ }
+
+ /* Determine our color masks */
+ if (!winQueryRGBBitsAndMasks (pScreen))
+ {
+ ErrorF ("winAllocateFBShadowGDI - winQueryRGBBitsAndMasks failed\n");
+ return FALSE;
+ }
+
+#ifdef XWIN_MULTIWINDOW
+ /* Redraw all windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
+#endif
+
+ return fReturn;
+}
+
+
+/*
+ * Blit the damaged regions of the shadow fb to the screen
+ */
+
+static void
+winShadowUpdateGDI (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RegionPtr damage = &pBuf->damage;
+ DWORD dwBox = REGION_NUM_RECTS (damage);
+ BoxPtr pBox = REGION_RECTS (damage);
+ int x, y, w, h;
+ HRGN hrgnTemp = NULL, hrgnCombined = NULL;
+#ifdef XWIN_UPDATESTATS
+ static DWORD s_dwNonUnitRegions = 0;
+ static DWORD s_dwTotalUpdates = 0;
+ static DWORD s_dwTotalBoxes = 0;
+#endif
+ BoxPtr pBoxExtents = REGION_EXTENTS (pScreen, damage);
+
+ /*
+ * Return immediately if the app is not active
+ * and we are fullscreen, or if we have a bad display depth
+ */
+ if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
+ || pScreenPriv->fBadDepth) return;
+
+#ifdef XWIN_UPDATESTATS
+ ++s_dwTotalUpdates;
+ s_dwTotalBoxes += dwBox;
+
+ if (dwBox != 1)
+ {
+ ++s_dwNonUnitRegions;
+ ErrorF ("winShadowUpdatGDI - dwBox: %d\n", dwBox);
+ }
+
+ if ((s_dwTotalUpdates % 100) == 0)
+ ErrorF ("winShadowUpdateGDI - %d%% non-unity regions, avg boxes: %d "
+ "nu: %d tu: %d\n",
+ (s_dwNonUnitRegions * 100) / s_dwTotalUpdates,
+ s_dwTotalBoxes / s_dwTotalUpdates,
+ s_dwNonUnitRegions, s_dwTotalUpdates);
+#endif /* XWIN_UPDATESTATS */
+
+ /*
+ * Handle small regions with multiple blits,
+ * handle large regions by creating a clipping region and
+ * doing a single blit constrained to that clipping region.
+ */
+ if (pScreenInfo->dwClipUpdatesNBoxes == 0
+ || dwBox < pScreenInfo->dwClipUpdatesNBoxes)
+ {
+ /* Loop through all boxes in the damaged region */
+ while (dwBox--)
+ {
+ /*
+ * Calculate x offset, y offset, width, and height for
+ * current damage box
+ */
+ x = pBox->x1;
+ y = pBox->y1;
+ w = pBox->x2 - pBox->x1;
+ h = pBox->y2 - pBox->y1;
+
+ BitBlt (pScreenPriv->hdcScreen,
+ x, y,
+ w, h,
+ pScreenPriv->hdcShadow,
+ x, y,
+ SRCCOPY);
+
+ /* Get a pointer to the next box */
+ ++pBox;
+ }
+ }
+ else
+ {
+ /* Compute a GDI region from the damaged region */
+ hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ dwBox--;
+ pBox++;
+ while (dwBox--)
+ {
+ hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
+ DeleteObject (hrgnTemp);
+ pBox++;
+ }
+
+ /* Install the GDI region as a clipping region */
+ SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined);
+ DeleteObject (hrgnCombined);
+ hrgnCombined = NULL;
+
+ /*
+ * Blit the shadow buffer to the screen,
+ * constrained to the clipping region.
+ */
+ BitBlt (pScreenPriv->hdcScreen,
+ pBoxExtents->x1, pBoxExtents->y1,
+ pBoxExtents->x2 - pBoxExtents->x1,
+ pBoxExtents->y2 - pBoxExtents->y1,
+ pScreenPriv->hdcShadow,
+ pBoxExtents->x1, pBoxExtents->y1,
+ SRCCOPY);
+
+ /* Reset the clip region */
+ SelectClipRgn (pScreenPriv->hdcScreen, NULL);
+ }
+
+#ifdef XWIN_MULTIWINDOW
+ /* Redraw all multiwindow windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows (g_dwCurrentThreadID,
+ winRedrawDamagedWindowShadowGDI,
+ (LPARAM)pBoxExtents);
+#endif
+}
+
+
+/* See Porting Layer Definition - p. 33 */
+/*
+ * We wrap whatever CloseScreen procedure was specified by fb;
+ * a pointer to said procedure is stored in our privates.
+ */
+
+static Bool
+winCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ Bool fReturn;
+
+#if CYGDEBUG
+ winDebug ("winCloseScreenShadowGDI - Freeing screen resources\n");
+#endif
+
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
+
+ /* Call the wrapped CloseScreen procedure */
+ WIN_UNWRAP(CloseScreen);
+ fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
+
+ /* Delete the window property */
+ RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
+
+ /* Free the shadow DC; which allows the bitmap to be freed */
+ DeleteDC (pScreenPriv->hdcShadow);
+
+ /* Free the shadow bitmap */
+ DeleteObject (pScreenPriv->hbmpShadow);
+
+ /* Free the screen DC */
+ ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
+
+ /* Delete tray icon, if we have one */
+ if (!pScreenInfo->fNoTrayIcon)
+ winDeleteNotifyIcon (pScreenPriv);
+
+ /* Free the exit confirmation dialog box, if it exists */
+ if (g_hDlgExit != NULL)
+ {
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+ }
+
+ /* Kill our window */
+ if (pScreenPriv->hwndScreen)
+ {
+ DestroyWindow (pScreenPriv->hwndScreen);
+ pScreenPriv->hwndScreen = NULL;
+ }
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ /* Destroy the thread startup mutex */
+ pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
+#endif
+
+ /* Invalidate our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
+
+ /* Invalidate the ScreenInfo's fb pointer */
+ pScreenInfo->pfb = NULL;
+
+ /* Free the screen privates for this screen */
+ free ((pointer) pScreenPriv);
+
+ return fReturn;
+}
+
+
+/*
+ * Tell mi what sort of visuals we need.
+ *
+ * Generally we only need one visual, as our screen can only
+ * handle one format at a time, I believe. You may want
+ * to verify that last sentence.
+ */
+
+static Bool
+winInitVisualsShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Display debugging information */
+ ErrorF ("winInitVisualsShadowGDI - Masks %08x %08x %08x BPRGB %d d %d "
+ "bpp %d\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask,
+ (int) pScreenPriv->dwBitsPerRGB,
+ (int) pScreenInfo->dwDepth,
+ (int) pScreenInfo->dwBPP);
+
+ /* Create a single visual according to the Windows screen depth */
+ switch (pScreenInfo->dwDepth)
+ {
+ case 24:
+ case 16:
+ case 15:
+#if defined(XFree86Server)
+ /* Setup the real visual */
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ -1,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+
+#ifdef XWIN_EMULATEPSEUDO
+ if (!pScreenInfo->fEmulatePseudo)
+ break;
+
+ /* Setup a pseudocolor visual */
+ if (!miSetVisualTypesAndMasks (8,
+ PseudoColorMask,
+ 8,
+ -1,
+ 0,
+ 0,
+ 0))
+ {
+ ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
+ "failed for PseudoColor\n");
+ return FALSE;
+ }
+#endif
+#else /* XFree86Server */
+ /* Setup the real visual */
+ if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks "
+ "failed for TrueColor\n");
+ return FALSE;
+ }
+
+#ifdef XWIN_EMULATEPSEUDO
+ if (!pScreenInfo->fEmulatePseudo)
+ break;
+
+ /* Setup a pseudocolor visual */
+ if (!fbSetVisualTypesAndMasks (8,
+ PseudoColorMask,
+ 8,
+ 0,
+ 0,
+ 0))
+ {
+ ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks "
+ "failed for PseudoColor\n");
+ return FALSE;
+ }
+#endif
+#endif /* XFree86Server */
+ break;
+
+ case 8:
+#if defined(XFree86Server)
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ PseudoColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ PseudoColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+#else /* XFree86Server */
+ if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ PseudoColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+#endif
+ break;
+
+ default:
+ ErrorF ("winInitVisualsShadowGDI - Unknown screen depth\n");
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ winDebug ("winInitVisualsShadowGDI - Returning\n");
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * Adjust the proposed video mode
+ */
+
+static Bool
+winAdjustVideoModeShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc;
+ DWORD dwBPP;
+
+ hdc = GetDC (NULL);
+
+ /* We're in serious trouble if we can't get a DC */
+ if (hdc == NULL)
+ {
+ ErrorF ("winAdjustVideoModeShadowGDI - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+
+ /* GDI cannot change the screen depth */
+ if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
+ {
+ /* No -depth parameter passed, let the user know the depth being used */
+ ErrorF ("winAdjustVideoModeShadowGDI - Using Windows display "
+ "depth of %d bits per pixel\n", (int) dwBPP);
+
+ /* Use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+ else if (dwBPP != pScreenInfo->dwBPP)
+ {
+ /* Warn user if GDI depth is different than -depth parameter */
+ ErrorF ("winAdjustVideoModeShadowGDI - Command line bpp: %d, "\
+ "using bpp: %d\n", (int) pScreenInfo->dwBPP, (int) dwBPP);
+
+ /* We'll use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+ hdc = NULL;
+
+ return TRUE;
+}
+
+
+/*
+ * Blt exposed regions to the screen
+ */
+
+static Bool
+winBltExposedRegionsShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ winPrivCmapPtr pCmapPriv = NULL;
+ HDC hdcUpdate;
+ PAINTSTRUCT ps;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
+
+ /* Realize the palette, if we have one */
+ if (pScreenPriv->pcmapInstalled != NULL)
+ {
+ pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
+
+ SelectPalette (hdcUpdate, pCmapPriv->hPalette, FALSE);
+ RealizePalette (hdcUpdate);
+ }
+
+ /* Our BitBlt will be clipped to the invalidated region */
+ BitBlt (hdcUpdate,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+
+ /* EndPaint frees the DC */
+ EndPaint (pScreenPriv->hwndScreen, &ps);
+
+#ifdef XWIN_MULTIWINDOW
+ /* Redraw all windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI,
+ (LPARAM)pScreenPriv->hwndScreen);
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * Do any engine-specific appliation-activation processing
+ */
+
+static Bool
+winActivateAppShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /*
+ * 2004/04/12 - Harold - We perform the restoring or minimizing
+ * manually for ShadowGDI in fullscreen modes so that this engine
+ * will perform just like ShadowDD and ShadowDDNL in fullscreen mode;
+ * if we do not do this then our fullscreen window will appear in the
+ * z-order when it is deactivated and it can be uncovered by resizing
+ * or minimizing another window that is on top of it, which is not how
+ * the DirectDraw engines work. Therefore we keep this code here to
+ * make sure that all engines work the same in fullscreen mode.
+ */
+
+ /*
+ * Are we active?
+ * Are we fullscreen?
+ */
+ if (pScreenPriv->fActive
+ && pScreenInfo->fFullScreen)
+ {
+ /*
+ * Activating, attempt to bring our window
+ * to the top of the display
+ */
+ ShowWindow (pScreenPriv->hwndScreen, SW_RESTORE);
+ }
+ else if (!pScreenPriv->fActive
+ && pScreenInfo->fFullScreen)
+ {
+ /*
+ * Deactivating, stuff our window onto the
+ * task bar.
+ */
+ ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Reblit the shadow framebuffer to the screen.
+ */
+
+static Bool
+winRedrawScreenShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Redraw the whole window, to take account for the new colors */
+ BitBlt (pScreenPriv->hdcScreen,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+
+#ifdef XWIN_MULTIWINDOW
+ /* Redraw all windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
+#endif
+
+ return TRUE;
+}
+
+
+
+/*
+ * Realize the currently installed colormap
+ */
+
+static Bool
+winRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winPrivCmapPtr pCmapPriv = NULL;
+
+#if CYGDEBUG
+ winDebug ("winRealizeInstalledPaletteShadowGDI\n");
+#endif
+
+ /* Don't do anything if there is not a colormap */
+ if (pScreenPriv->pcmapInstalled == NULL)
+ {
+#if CYGDEBUG
+ winDebug ("winRealizeInstalledPaletteShadowGDI - No colormap "
+ "installed\n");
+#endif
+ return TRUE;
+ }
+
+ pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
+
+ /* Realize our palette for the screen */
+ if (RealizePalette (pScreenPriv->hdcScreen) == GDI_ERROR)
+ {
+ ErrorF ("winRealizeInstalledPaletteShadowGDI - RealizePalette () "
+ "failed\n");
+ return FALSE;
+ }
+
+ /* Set the DIB color table */
+ if (SetDIBColorTable (pScreenPriv->hdcShadow,
+ 0,
+ WIN_NUM_PALETTE_ENTRIES,
+ pCmapPriv->rgbColors) == 0)
+ {
+ ErrorF ("winRealizeInstalledPaletteShadowGDI - SetDIBColorTable () "
+ "failed\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Install the specified colormap
+ */
+
+static Bool
+winInstallColormapShadowGDI (ColormapPtr pColormap)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ winCmapPriv(pColormap);
+
+ /*
+ * Tell Windows to install the new colormap
+ */
+ if (SelectPalette (pScreenPriv->hdcScreen,
+ pCmapPriv->hPalette,
+ FALSE) == NULL)
+ {
+ ErrorF ("winInstallColormapShadowGDI - SelectPalette () failed\n");
+ return FALSE;
+ }
+
+ /* Realize the palette */
+ if (GDI_ERROR == RealizePalette (pScreenPriv->hdcScreen))
+ {
+ ErrorF ("winInstallColormapShadowGDI - RealizePalette () failed\n");
+ return FALSE;
+ }
+
+ /* Set the DIB color table */
+ if (SetDIBColorTable (pScreenPriv->hdcShadow,
+ 0,
+ WIN_NUM_PALETTE_ENTRIES,
+ pCmapPriv->rgbColors) == 0)
+ {
+ ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
+ return FALSE;
+ }
+
+ /* Redraw the whole window, to take account for the new colors */
+ BitBlt (pScreenPriv->hdcScreen,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+
+#ifdef XWIN_MULTIWINDOW
+ /* Redraw all windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * Store the specified colors in the specified colormap
+ */
+
+static Bool
+winStoreColorsShadowGDI (ColormapPtr pColormap,
+ int ndef,
+ xColorItem *pdefs)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
+
+ /* Put the X colormap entries into the Windows logical palette */
+ if (SetPaletteEntries (pCmapPriv->hPalette,
+ pdefs[0].pixel,
+ ndef,
+ pCmapPriv->peColors + pdefs[0].pixel) == 0)
+ {
+ ErrorF ("winStoreColorsShadowGDI - SetPaletteEntries () failed\n");
+ return FALSE;
+ }
+
+ /* Don't install the Windows palette if the colormap is not installed */
+ if (pColormap != curpmap)
+ {
+ return TRUE;
+ }
+
+ /* Try to install the newly modified colormap */
+ if (!winInstallColormapShadowGDI (pColormap))
+ {
+ ErrorF ("winInstallColormapShadowGDI - winInstallColormapShadowGDI "
+ "failed\n");
+ return FALSE;
+ }
+
+#if 0
+ /* Tell Windows that the palette has changed */
+ RealizePalette (pScreenPriv->hdcScreen);
+
+ /* Set the DIB color table */
+ if (SetDIBColorTable (pScreenPriv->hdcShadow,
+ pdefs[0].pixel,
+ ndef,
+ pCmapPriv->rgbColors + pdefs[0].pixel) == 0)
+ {
+ ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
+ return FALSE;
+ }
+
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap initialization procedure
+ */
+
+static Bool
+winCreateColormapShadowGDI (ColormapPtr pColormap)
+{
+ LPLOGPALETTE lpPaletteNew = NULL;
+ DWORD dwEntriesMax;
+ VisualPtr pVisual;
+ HPALETTE hpalNew = NULL;
+ winCmapPriv(pColormap);
+
+ /* Get a pointer to the visual that the colormap belongs to */
+ pVisual = pColormap->pVisual;
+
+ /* Get the maximum number of palette entries for this visual */
+ dwEntriesMax = pVisual->ColormapEntries;
+
+ /* Allocate a Windows logical color palette with max entries */
+ lpPaletteNew = malloc (sizeof (LOGPALETTE)
+ + (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
+ if (lpPaletteNew == NULL)
+ {
+ ErrorF ("winCreateColormapShadowGDI - Couldn't allocate palette "
+ "with %d entries\n",
+ (int) dwEntriesMax);
+ return FALSE;
+ }
+
+ /* Zero out the colormap */
+ ZeroMemory (lpPaletteNew, sizeof (LOGPALETTE)
+ + (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
+
+ /* Set the logical palette structure */
+ lpPaletteNew->palVersion = 0x0300;
+ lpPaletteNew->palNumEntries = dwEntriesMax;
+
+ /* Tell Windows to create the palette */
+ hpalNew = CreatePalette (lpPaletteNew);
+ if (hpalNew == NULL)
+ {
+ ErrorF ("winCreateColormapShadowGDI - CreatePalette () failed\n");
+ free (lpPaletteNew);
+ return FALSE;
+ }
+
+ /* Save the Windows logical palette handle in the X colormaps' privates */
+ pCmapPriv->hPalette = hpalNew;
+
+ /* Free the palette initialization memory */
+ free (lpPaletteNew);
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap destruction procedure
+ */
+
+static Bool
+winDestroyColormapShadowGDI (ColormapPtr pColormap)
+{
+ winScreenPriv(pColormap->pScreen);
+ winCmapPriv(pColormap);
+
+ /*
+ * Is colormap to be destroyed the default?
+ *
+ * Non-default colormaps should have had winUninstallColormap
+ * called on them before we get here. The default colormap
+ * will not have had winUninstallColormap called on it. Thus,
+ * we need to handle the default colormap in a special way.
+ */
+ if (pColormap->flags & IsDefault)
+ {
+#if CYGDEBUG
+ winDebug ("winDestroyColormapShadowGDI - Destroying default "
+ "colormap\n");
+#endif
+
+ /*
+ * FIXME: Walk the list of all screens, popping the default
+ * palette out of each screen device context.
+ */
+
+ /* Pop the palette out of the device context */
+ SelectPalette (pScreenPriv->hdcScreen,
+ GetStockObject (DEFAULT_PALETTE),
+ FALSE);
+
+ /* Clear our private installed colormap pointer */
+ pScreenPriv->pcmapInstalled = NULL;
+ }
+
+ /* Try to delete the logical palette */
+ if (DeleteObject (pCmapPriv->hPalette) == 0)
+ {
+ ErrorF ("winDestroyColormap - DeleteObject () failed\n");
+ return FALSE;
+ }
+
+ /* Invalidate the colormap privates */
+ pCmapPriv->hPalette = NULL;
+
+ return TRUE;
+}
+
+
+/*
+ * Set engine specific funtions
+ */
+
+Bool
+winSetEngineFunctionsShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBShadowGDI;
+ pScreenPriv->pwinShadowUpdate = winShadowUpdateGDI;
+ pScreenPriv->pwinCloseScreen = winCloseScreenShadowGDI;
+ pScreenPriv->pwinInitVisuals = winInitVisualsShadowGDI;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowGDI;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowGDI;
+ pScreenPriv->pwinActivateApp = winActivateAppShadowGDI;
+ pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowGDI;
+ pScreenPriv->pwinRealizeInstalledPalette =
+ winRealizeInstalledPaletteShadowGDI;
+ pScreenPriv->pwinInstallColormap = winInstallColormapShadowGDI;
+ pScreenPriv->pwinStoreColors = winStoreColorsShadowGDI;
+ pScreenPriv->pwinCreateColormap = winCreateColormapShadowGDI;
+ pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowGDI;
+ pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinCreatePrimarySurface
+ = (winCreatePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinReleasePrimarySurface
+ = (winReleasePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
+#ifdef XWIN_MULTIWINDOW
+ pScreenPriv->pwinFinishCreateWindowsWindow =
+ (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA;
+#endif
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/wintrayicon.c b/nx-X11/programs/Xserver/hw/xwin/wintrayicon.c
new file mode 100755
index 000000000..bf7305c9c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/wintrayicon.c
@@ -0,0 +1,211 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Early Ehlinger
+ * Harold L Hunt II
+ */
+/* $XFree86: $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include <shellapi.h>
+#include "winprefs.h"
+
+/*
+ * Initialize the tray icon
+ */
+
+void
+winInitNotifyIcon (winPrivScreenPtr pScreenPriv)
+{
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ NOTIFYICONDATA nid = {0};
+
+ nid.cbSize = sizeof (NOTIFYICONDATA);
+ nid.hWnd = pScreenPriv->hwndScreen;
+ nid.uID = pScreenInfo->dwScreen;
+ nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
+ nid.uCallbackMessage = WM_TRAYICON;
+ nid.hIcon = (HICON)winTaskbarIcon ();
+
+ /* Save handle to the icon so it can be freed later */
+ pScreenPriv->hiconNotifyIcon = nid.hIcon;
+
+ /* Set display and screen-specific tooltip text */
+ snprintf (nid.szTip,
+ sizeof (nid.szTip),
+ PROJECT_NAME " Server - %s:%d",
+ display,
+ (int) pScreenInfo->dwScreen);
+
+ /* Add the tray icon */
+ if (!Shell_NotifyIcon (NIM_ADD, &nid))
+ ErrorF ("winInitNotifyIcon - Shell_NotifyIcon Failed\n");
+}
+
+
+/*
+ * Delete the tray icon
+ */
+
+void
+winDeleteNotifyIcon (winPrivScreenPtr pScreenPriv)
+{
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ NOTIFYICONDATA nid = {0};
+
+#if 0
+ ErrorF ("winDeleteNotifyIcon\n");
+#endif
+
+ nid.cbSize = sizeof (NOTIFYICONDATA);
+ nid.hWnd = pScreenPriv->hwndScreen;
+ nid.uID = pScreenInfo->dwScreen;
+
+ /* Delete the tray icon */
+ if (!Shell_NotifyIcon (NIM_DELETE, &nid))
+ {
+ ErrorF ("winDeleteNotifyIcon - Shell_NotifyIcon failed\n");
+ return;
+ }
+
+ /* Free the icon that was loaded */
+ if (pScreenPriv->hiconNotifyIcon != NULL
+ && DestroyIcon (pScreenPriv->hiconNotifyIcon) == 0)
+ {
+ ErrorF ("winDeleteNotifyIcon - DestroyIcon failed\n");
+ }
+ pScreenPriv->hiconNotifyIcon = NULL;
+}
+
+
+/*
+ * Process messages intended for the tray icon
+ */
+
+LRESULT
+winHandleIconMessage (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam,
+ winPrivScreenPtr pScreenPriv)
+{
+#if defined(XWIN_MULTIWINDOWEXTWM) || defined(XWIN_MULTIWINDOW)
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+#endif
+
+ switch (lParam)
+ {
+ case WM_LBUTTONUP:
+ /* Restack and bring all windows to top */
+ SetForegroundWindow (hwnd);
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ if (pScreenInfo->fMWExtWM)
+ winMWExtWMRestackWindows (pScreenInfo->pScreen);
+#endif
+ break;
+
+ case WM_LBUTTONDBLCLK:
+ /* Display Exit dialog box */
+ winDisplayExitDialog (pScreenPriv);
+ break;
+
+ case WM_RBUTTONUP:
+ {
+ POINT ptCursor;
+ HMENU hmenuPopup;
+ HMENU hmenuTray;
+
+ /* Get cursor position */
+ GetCursorPos (&ptCursor);
+
+ /* Load tray icon menu resource */
+ hmenuPopup = LoadMenu (g_hInstance,
+ MAKEINTRESOURCE(IDM_TRAYICON_MENU));
+ if (!hmenuPopup)
+ ErrorF ("winHandleIconMessage - LoadMenu failed\n");
+
+ /* Get actual tray icon menu */
+ hmenuTray = GetSubMenu (hmenuPopup, 0);
+
+#ifdef XWIN_MULTIWINDOW
+ /* Check for MultiWindow mode */
+ if (pScreenInfo->fMultiWindow)
+ {
+ MENUITEMINFO mii = {0};
+
+ /* Root is shown, remove the check box */
+
+ /* Setup menu item info structure */
+ mii.cbSize = sizeof (MENUITEMINFO);
+ mii.fMask = MIIM_STATE;
+ mii.fState = MFS_CHECKED;
+
+ /* Unheck box if root is shown */
+ if (pScreenPriv->fRootWindowShown)
+ mii.fState = MFS_UNCHECKED;
+
+ /* Set menu state */
+ SetMenuItemInfo (hmenuTray, ID_APP_HIDE_ROOT, FALSE, &mii);
+ }
+ else
+#endif
+ {
+ /* Remove Hide Root Window button */
+ RemoveMenu (hmenuTray,
+ ID_APP_HIDE_ROOT,
+ MF_BYCOMMAND);
+ }
+
+ SetupRootMenu ((unsigned long)hmenuTray);
+
+ /*
+ * NOTE: This three-step procedure is required for
+ * proper popup menu operation. Without the
+ * call to SetForegroundWindow the
+ * popup menu will often not disappear when you click
+ * outside of it. Without the PostMessage the second
+ * time you display the popup menu it might immediately
+ * disappear.
+ */
+ SetForegroundWindow (hwnd);
+ TrackPopupMenuEx (hmenuTray,
+ TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON,
+ ptCursor.x, ptCursor.y,
+ hwnd,
+ NULL);
+ PostMessage (hwnd, WM_NULL, 0, 0);
+
+ /* Free menu */
+ DestroyMenu (hmenuPopup);
+ }
+ break;
+ }
+
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winvalargs.c b/nx-X11/programs/Xserver/hw/xwin/winvalargs.c
new file mode 100755
index 000000000..038e097a5
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winvalargs.c
@@ -0,0 +1,188 @@
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winmsg.h"
+
+
+/*
+ * References to external symbols
+ */
+
+extern int g_iNumScreens;
+extern winScreenInfo g_ScreenInfo[];
+extern Bool g_fXdmcpEnabled;
+
+
+/*
+ * Prototypes
+ */
+
+Bool
+winValidateArgs (void);
+
+
+/*
+ * winValidateArgs - Look for invalid argument combinations
+ */
+
+Bool
+winValidateArgs (void)
+{
+ int i;
+ int iMaxConsecutiveScreen = 0;
+ BOOL fHasNormalScreen0 = FALSE;
+
+ /*
+ * Check for a malformed set of -screen parameters.
+ * Examples of malformed parameters:
+ * XWin -screen 1
+ * XWin -screen 0 -screen 2
+ * XWin -screen 1 -screen 2
+ */
+ for (i = 0; i < MAXSCREENS; i++)
+ {
+ if (g_ScreenInfo[i].fExplicitScreen)
+ iMaxConsecutiveScreen = i + 1;
+ }
+ winErrorFVerb (2, "winValidateArgs - g_iNumScreens: %d "
+ "iMaxConsecutiveScreen: %d\n",
+ g_iNumScreens, iMaxConsecutiveScreen);
+ if (g_iNumScreens < iMaxConsecutiveScreen)
+ {
+ ErrorF ("winValidateArgs - Malformed set of screen parameter(s). "
+ "Screens must be specified consecutively starting with "
+ "screen 0. That is, you cannot have only a screen 1, nor "
+ "could you have screen 0 and screen 2. You instead must "
+ "have screen 0, or screen 0 and screen 1, respectively. Of "
+ "you can specify as many screens as you want from 0 up to "
+ "%d.\n", MAXSCREENS - 1);
+ return FALSE;
+ }
+
+ /* Loop through all screens */
+ for (i = 0; i < g_iNumScreens; ++i)
+ {
+ /*
+ * Check for any combination of
+ * -multiwindow, -mwextwm, and -rootless.
+ */
+ {
+ int iCount = 0;
+
+ /* Count conflicting options */
+#ifdef XWIN_MULTIWINDOW
+ if (g_ScreenInfo[i].fMultiWindow)
+ ++iCount;
+#endif
+#ifdef XWIN_MULTIWINDOWEXTWM
+ if (g_ScreenInfo[i].fMWExtWM)
+ ++iCount;
+#endif
+ if (g_ScreenInfo[i].fRootless)
+ ++iCount;
+
+ /* Check if the first screen is without rootless and multiwindow */
+ if (iCount == 0 && i == 0)
+ fHasNormalScreen0 = TRUE;
+
+ /* Fail if two or more conflicting options */
+ if (iCount > 1)
+ {
+ ErrorF ("winValidateArgs - Only one of -multiwindow, -mwextwm, "
+ "and -rootless can be specific at a time.\n");
+ return FALSE;
+ }
+ }
+
+ /* Check for -multiwindow or -mwextwm and Xdmcp */
+ /* allow xdmcp if screen 0 is normal. */
+ if (g_fXdmcpEnabled && !fHasNormalScreen0
+ && (FALSE
+#ifdef XWIN_MULTIWINDOW
+ || g_ScreenInfo[i].fMultiWindow
+#endif
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || g_ScreenInfo[i].fMWExtWM
+#endif
+ )
+ )
+ {
+ ErrorF ("winValidateArgs - Xdmcp (-query, -broadcast, or -indirect) "
+ "is invalid with -multiwindow or -mwextwm.\n");
+ return FALSE;
+ }
+
+ /* Check for -multiwindow, -mwextwm, or -rootless and fullscreen */
+ if (g_ScreenInfo[i].fFullScreen
+ && (FALSE
+#ifdef XWIN_MULTIWINDOW
+ || g_ScreenInfo[i].fMultiWindow
+#endif
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || g_ScreenInfo[i].fMWExtWM
+#endif
+ || g_ScreenInfo[i].fRootless)
+ )
+ {
+ ErrorF ("winValidateArgs - -fullscreen is invalid with "
+ "-multiwindow, -mwextwm, or -rootless.\n");
+ return FALSE;
+ }
+
+ /* Check for !fullscreen and any fullscreen-only parameters */
+ if (!g_ScreenInfo[i].fFullScreen
+ && (g_ScreenInfo[i].dwRefreshRate != WIN_DEFAULT_BPP
+ || g_ScreenInfo[i].dwBPP != WIN_DEFAULT_REFRESH))
+ {
+ ErrorF ("winValidateArgs - -refresh and -depth are only valid "
+ "with -fullscreen.\n");
+ return FALSE;
+ }
+
+ /* Check for fullscreen and any non-fullscreen parameters */
+ if (g_ScreenInfo[i].fFullScreen
+ && (g_ScreenInfo[i].fScrollbars
+ || !g_ScreenInfo[i].fDecoration
+ || g_ScreenInfo[i].fLessPointer))
+ {
+ ErrorF ("winValidateArgs - -fullscreen is invalid with "
+ "-scrollbars, -nodecoration, or -lesspointer.\n");
+ return FALSE;
+ }
+ }
+
+ winDebug ("winValidateArgs - Returning.\n");
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winvideo.c b/nx-X11/programs/Xserver/hw/xwin/winvideo.c
new file mode 100755
index 000000000..529ca76d3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winvideo.c
@@ -0,0 +1,210 @@
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/Xvproto.h>
+
+void
+winInitVideo (ScreenPtr pScreen);
+
+/*
+ * winInitVideo - Initialize support for the X Video (Xv) Extension.
+ */
+
+void
+winInitVideo (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ if (pScreenInfo->dwBPP > 8)
+ {
+
+ }
+
+
+}
+
+
+
+
+
+
+
+#if 0
+#include "../xfree86/common/xf86.h"
+#include "../Xext/xvdix.h"
+#include "../xfree86/common/xf86xv.h"
+#include <X11/extensions/Xv.h>
+#endif
+
+#include "win.h"
+
+
+
+#if 0
+/* client libraries expect an encoding */
+static XF86VideoEncodingRec DummyEncoding[1] =
+{
+ {
+ 0,
+ "XV_IMAGE",
+ IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT,
+ {1, 1}
+ }
+};
+
+#define NUM_FORMATS 3
+
+static XF86VideoFormatRec Formats[NUM_FORMATS] =
+{
+ {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
+};
+
+#define NUM_ATTRIBUTES 3
+
+static XF86AttributeRec Attributes[NUM_ATTRIBUTES] =
+{
+ {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"},
+ {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"},
+ {XvSettable | XvGettable, 0, 255, "XV_CONTRAST"}
+};
+
+#define NUM_IMAGES 4
+
+static XF86ImageRec Images[NUM_IMAGES] =
+{
+ XVIMAGE_YUY2,
+ XVIMAGE_YV12,
+ XVIMAGE_I420,
+ XVIMAGE_UYVY
+};
+
+
+
+/*
+ * winInitVideo - Initialize support for the X Video (Xv) Extension.
+ */
+
+void
+winInitVideo (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ XF86VideoAdaptorPtr newAdaptor = NULL;
+
+ if (pScreenInfo->dwBPP > 8)
+ {
+ newAdaptor = I810SetupImageVideo (pScreen);
+ I810InitOffscreenImages (pScreen);
+ }
+
+ xf86XVScreenInit (pScreen, adaptors, 1);
+}
+
+
+static XF86VideoAdaptorPtr
+winSetupImageVideo (ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+#if 0
+ I810Ptr pI810 = I810PTR(pScrn);
+#endif
+ XF86VideoAdaptorPtr adapt;
+
+ if (!(adapt = xcalloc (1, sizeof(XF86VideoAdaptorRec))))
+ return NULL;
+
+ adapt->type = XvWindowMask | XvInputMask | XvImageMask;
+ adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
+ adapt->name = PROJECT_NAME " Video Overlay";
+ adapt->nEncodings = 1;
+ adapt->pEncodings = DummyEncoding;
+ adapt->nFormats = NUM_FORMATS;
+ adapt->pFormats = Formats;
+ adapt->nPorts = 1;
+ adapt->pPortPrivates = NULL;
+
+ adapt->pPortPrivates[0].ptr = NULL;
+ adapt->pAttributes = Attributes;
+ adapt->nImages = NUM_IMAGES;
+ adapt->nAttributes = NUM_ATTRIBUTES;
+ adapt->pImages = Images;
+ adapt->PutVideo = NULL;
+ adapt->PutStill = NULL;
+ adapt->GetVideo = NULL;
+ adapt->GetStill = NULL;
+#if 0
+ adapt->StopVideo = I810StopVideo;
+ adapt->SetPortAttribute = I810SetPortAttribute;
+ adapt->GetPortAttribute = I810GetPortAttribute;
+ adapt->QueryBestSize = I810QueryBestSize;
+ adapt->PutImage = I810PutImage;
+ adapt->QueryImageAttributes = I810QueryImageAttributes;
+#endif
+
+#if 0
+ pPriv->colorKey = pI810->colorKey & ((1 << pScrn->depth) - 1);
+#endif
+ pPriv->videoStatus = 0;
+ pPriv->brightness = 0;
+ pPriv->contrast = 64;
+ pPriv->linear = NULL;
+ pPriv->currentBuf = 0;
+
+#if 0
+ /* gotta uninit this someplace */
+ REGION_NULL(pScreen, &pPriv->clip);
+#endif
+
+#if 0
+ pI810->adaptor = adapt;
+
+ pI810->BlockHandler = pScreen->BlockHandler;
+ pScreen->BlockHandler = I810BlockHandler;
+#endif
+
+#if 0
+ xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
+ xvContrast = MAKE_ATOM("XV_CONTRAST");
+ xvColorKey = MAKE_ATOM("XV_COLORKEY");
+#endif
+
+#if 0
+ I810ResetVideo(pScrn);
+#endif
+
+ return adapt;
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/winwakeup.c b/nx-X11/programs/Xserver/hw/xwin/winwakeup.c
new file mode 100644
index 000000000..c0200ab53
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winwakeup.c
@@ -0,0 +1,72 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winwakeup.c,v 1.6 2002/10/17 08:18:25 alanh Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * References to external symbols
+ */
+
+extern HWND g_hDlgDepthChange;
+extern HWND g_hDlgExit;
+extern HWND g_hDlgAbout;
+
+
+/* See Porting Layer Definition - p. 7 */
+void
+winWakeupHandler (int nScreen,
+ pointer pWakeupData,
+ unsigned long ulResult,
+ pointer pReadmask)
+{
+ MSG msg;
+
+ /* Process all messages on our queue */
+ while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ if ((g_hDlgDepthChange == 0
+ || !IsDialogMessage (g_hDlgDepthChange, &msg))
+ && (g_hDlgExit == 0
+ || !IsDialogMessage (g_hDlgExit, &msg))
+ && (g_hDlgAbout == 0
+ || !IsDialogMessage (g_hDlgAbout, &msg)))
+ {
+ DispatchMessage (&msg);
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winwin32rootless.c b/nx-X11/programs/Xserver/hw/xwin/winwin32rootless.c
new file mode 100755
index 000000000..832e36d44
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winwin32rootless.c
@@ -0,0 +1,1092 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Kensuke Matsuzaki
+ * Earle F. Philhower, III
+ * Harold L Hunt II
+ */
+/*
+ * Look at hw/darwin/quartz/xpr/xprFrame.c and hw/darwin/quartz/cr/crFrame.c
+ */
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include <winuser.h>
+#define _WINDOWSWM_SERVER_
+#include "windowswmstr.h"
+#include "dixevents.h"
+#include "winmultiwindowclass.h"
+#include "winprefs.h"
+#include <X11/Xatom.h>
+
+
+/*
+ * Constant defines
+ */
+
+#define MOUSE_POLLING_INTERVAL 500
+
+#define ULW_COLORKEY 0x00000001
+#define ULW_ALPHA 0x00000002
+#define ULW_OPAQUE 0x00000004
+#define AC_SRC_ALPHA 0x01
+
+/*
+ * Local function
+ */
+
+DEFINE_ATOM_HELPER(AtmWindowsWmNativeHwnd, WINDOWSWM_NATIVE_HWND)
+static void
+winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame);
+
+/*
+ * Global variables
+ */
+
+Bool g_fNoConfigureWindow = FALSE;
+
+
+extern void winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon);
+
+/*
+ * Internal function to get the DIB format that is compatible with the screen
+ * Fixme: Share code with winshadgdi.c
+ */
+
+static
+Bool
+winMWExtWMQueryDIBFormat (win32RootlessWindowPtr pRLWinPriv, BITMAPINFOHEADER *pbmih)
+{
+ HBITMAP hbmp;
+#if CYGMULTIWINDOW_DEBUG
+ LPDWORD pdw = NULL;
+#endif
+
+ /* Create a memory bitmap compatible with the screen */
+ hbmp = CreateCompatibleBitmap (pRLWinPriv->hdcScreen, 1, 1);
+ if (hbmp == NULL)
+ {
+ ErrorF ("winMWExtWMQueryDIBFormat - CreateCompatibleBitmap failed\n");
+ return FALSE;
+ }
+
+ /* Initialize our bitmap info header */
+ ZeroMemory (pbmih, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
+ pbmih->biSize = sizeof (BITMAPINFOHEADER);
+
+ /* Get the biBitCount */
+ if (!GetDIBits (pRLWinPriv->hdcScreen,
+ hbmp,
+ 0, 1,
+ NULL,
+ (BITMAPINFO*) pbmih,
+ DIB_RGB_COLORS))
+ {
+ ErrorF ("winMWExtWMQueryDIBFormat - First call to GetDIBits failed\n");
+ DeleteObject (hbmp);
+ return FALSE;
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ /* Get a pointer to bitfields */
+ pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
+
+ winDebug ("winMWExtWMQueryDIBFormat - First call masks: %08x %08x %08x\n",
+ (unsigned int)pdw[0], (unsigned int)pdw[1], (unsigned int)pdw[2]);
+#endif
+
+ /* Get optimal color table, or the optimal bitfields */
+ if (!GetDIBits (pRLWinPriv->hdcScreen,
+ hbmp,
+ 0, 1,
+ NULL,
+ (BITMAPINFO*)pbmih,
+ DIB_RGB_COLORS))
+ {
+ ErrorF ("winMWExtWMQueryDIBFormat - Second call to GetDIBits "
+ "failed\n");
+ DeleteObject (hbmp);
+ return FALSE;
+ }
+
+ /* Free memory */
+ DeleteObject (hbmp);
+
+ return TRUE;
+}
+
+static HRGN
+winMWExtWMCreateRgnFromRegion (RegionPtr pShape)
+{
+ int nRects;
+ BoxPtr pRects, pEnd;
+ HRGN hRgn, hRgnRect;
+
+ if (pShape == NULL) return NULL;
+
+ nRects = REGION_NUM_RECTS(pShape);
+ pRects = REGION_RECTS(pShape);
+
+ hRgn = CreateRectRgn (0, 0, 0, 0);
+ if (hRgn == NULL)
+ {
+ ErrorF ("winReshape - Initial CreateRectRgn (%d, %d, %d, %d) "
+ "failed: %d\n",
+ 0, 0, 0, 0, (int) GetLastError ());
+ }
+
+ /* Loop through all rectangles in the X region */
+ for (pEnd = pRects + nRects; pRects < pEnd; pRects++)
+ {
+ /* Create a Windows region for the X rectangle */
+ hRgnRect = CreateRectRgn (pRects->x1,
+ pRects->y1,
+ pRects->x2,
+ pRects->y2);
+ if (hRgnRect == NULL)
+ {
+ ErrorF ("winReshape - Loop CreateRectRgn (%d, %d, %d, %d) "
+ "failed: %d\n",
+ pRects->x1,
+ pRects->y1,
+ pRects->x2,
+ pRects->y2,
+ (int) GetLastError ());
+ }
+
+ /* Merge the Windows region with the accumulated region */
+ if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR)
+ {
+ ErrorF ("winReshape - CombineRgn () failed: %d\n",
+ (int) GetLastError ());
+ }
+
+ /* Delete the temporary Windows region */
+ DeleteObject (hRgnRect);
+ }
+
+ return hRgn;
+}
+
+static void
+InitWin32RootlessEngine (win32RootlessWindowPtr pRLWinPriv)
+{
+ pRLWinPriv->hdcScreen = GetDC (pRLWinPriv->hWnd);
+ pRLWinPriv->hdcShadow = CreateCompatibleDC (pRLWinPriv->hdcScreen);
+ pRLWinPriv->hbmpShadow = NULL;
+
+ /* Allocate bitmap info header */
+ pRLWinPriv->pbmihShadow = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
+ + 256 * sizeof (RGBQUAD));
+ if (pRLWinPriv->pbmihShadow == NULL)
+ {
+ ErrorF ("InitWin32RootlessEngine - malloc () failed\n");
+ return;
+ }
+
+ /* Query the screen format */
+ winMWExtWMQueryDIBFormat (pRLWinPriv,
+ pRLWinPriv->pbmihShadow);
+}
+
+Bool
+winMWExtWMCreateFrame (RootlessWindowPtr pFrame, ScreenPtr pScreen,
+ int newX, int newY, RegionPtr pShape)
+{
+#define CLASS_NAME_LENGTH 512
+ Bool fResult = TRUE;
+ win32RootlessWindowPtr pRLWinPriv;
+ WNDCLASSEX wc;
+ char pszClass[CLASS_NAME_LENGTH], pszWindowID[12];
+ HICON hIcon;
+ HICON hIconSmall;
+ char *res_name, *res_class, *res_role;
+ static int s_iWindowID = 0;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMCreateFrame %d %d - %d %d\n",
+ newX, newY, pFrame->width, pFrame->height);
+#endif
+
+ pRLWinPriv = (win32RootlessWindowPtr) malloc (sizeof (win32RootlessWindowRec));
+ pRLWinPriv->pFrame = pFrame;
+ pRLWinPriv->pfb = NULL;
+ pRLWinPriv->hbmpShadow = NULL;
+ pRLWinPriv->hdcShadow = NULL;
+ pRLWinPriv->hdcScreen = NULL;
+ pRLWinPriv->pbmihShadow = NULL;
+ pRLWinPriv->fResized = TRUE;
+ pRLWinPriv->fClose = FALSE;
+ pRLWinPriv->fRestackingNow = FALSE;
+ pRLWinPriv->fDestroyed = FALSE;
+ pRLWinPriv->fMovingOrSizing = FALSE;
+
+ // Store the implementation private frame ID
+ pFrame->wid = (RootlessFrameID) pRLWinPriv;
+
+ winSelectIcons(pFrame->win, &hIcon, &hIconSmall);
+
+ /* Set standard class name prefix so we can identify window easily */
+ strncpy (pszClass, WINDOW_CLASS_X, sizeof(pszClass));
+
+ if (winMultiWindowGetClassHint (pFrame->win, &res_name, &res_class))
+ {
+ strncat (pszClass, "-", 1);
+ strncat (pszClass, res_name, CLASS_NAME_LENGTH - strlen (pszClass));
+ strncat (pszClass, "-", 1);
+ strncat (pszClass, res_class, CLASS_NAME_LENGTH - strlen (pszClass));
+
+ /* Check if a window class is provided by the WM_WINDOW_ROLE property,
+ * if not use the WM_CLASS information.
+ * For further information see:
+ * http://tronche.com/gui/x/icccm/sec-5.html
+ */
+ if (winMultiWindowGetWindowRole (pFrame->win, &res_role) )
+ {
+ strcat (pszClass, "-");
+ strcat (pszClass, res_role);
+ free (res_role);
+ }
+
+ free (res_name);
+ free (res_class);
+ }
+
+ /* Add incrementing window ID to make unique class name */
+ snprintf (pszWindowID, sizeof(pszWindowID), "-%x", s_iWindowID++);
+ pszWindowID[sizeof(pszWindowID)-1] = 0;
+ strcat (pszClass, pszWindowID);
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winCreateWindowsWindow - Creating class: %s\n", pszClass);
+#endif
+
+ /* Setup our window class */
+ wc.cbSize = sizeof(wc);
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = winMWExtWMWindowProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = g_hInstance;
+ wc.hIcon = hIcon;
+ wc.hIconSm = hIconSmall;
+ wc.hCursor = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = pszClass;
+ RegisterClassEx (&wc);
+
+ /* Create the window */
+ g_fNoConfigureWindow = TRUE;
+ pRLWinPriv->hWnd = CreateWindowExA (WS_EX_TOOLWINDOW, /* Extended styles */
+ pszClass, /* Class name */
+ WINDOW_TITLE_X, /* Window name */
+ WS_POPUP | WS_CLIPCHILDREN,
+ newX, /* Horizontal position */
+ newY, /* Vertical position */
+ pFrame->width, /* Right edge */
+ pFrame->height, /* Bottom edge */
+ (HWND) NULL, /* No parent or owner window */
+ (HMENU) NULL, /* No menu */
+ GetModuleHandle (NULL), /* Instance handle */
+ pRLWinPriv); /* ScreenPrivates */
+ if (pRLWinPriv->hWnd == NULL)
+ {
+ ErrorF ("winMWExtWMCreateFrame - CreateWindowExA () failed: %d\n",
+ (int) GetLastError ());
+ fResult = FALSE;
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMCreateFrame - ShowWindow\n");
+#endif
+
+ //ShowWindow (pRLWinPriv->hWnd, SW_SHOWNOACTIVATE);
+ g_fNoConfigureWindow = FALSE;
+
+ if (pShape != NULL)
+ {
+ winMWExtWMReshapeFrame (pFrame->wid, pShape);
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMCreateFrame - (%08x) %08x\n",
+ (int) pFrame->wid, (int) pRLWinPriv->hWnd);
+#if 0
+ {
+ WindowPtr pWin2 = NULL;
+ win32RootlessWindowPtr pRLWinPriv2 = NULL;
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pWin2 = (WindowPtr)GetProp (pRLWinPriv->hWnd, WIN_WINDOW_PROP)) != NULL)
+ {
+ pRLWinPriv2 = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin2, FALSE);
+ }
+ winDebug ("winMWExtWMCreateFrame2 (%08x) %08x\n",
+ pRLWinPriv2, pRLWinPriv2->hWnd);
+ if (pRLWinPriv != pRLWinPriv2 || pRLWinPriv->hWnd != pRLWinPriv2->hWnd)
+ {
+ winDebug ("Error param missmatch\n");
+ }
+ }
+#endif
+#endif
+
+ winMWExtWMSetNativeProperty (pFrame);
+
+ return fResult;
+}
+
+void
+winMWExtWMDestroyFrame (RootlessFrameID wid)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ HICON hiconClass;
+ HICON hiconSmClass;
+ HMODULE hInstance;
+ int iReturn;
+ char pszClass[CLASS_NAME_LENGTH];
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMDestroyFrame (%08x) %08x\n",
+ (int) pRLWinPriv, (int) pRLWinPriv->hWnd);
+#if 0
+ {
+ WindowPtr pWin2 = NULL;
+ win32RootlessWindowPtr pRLWinPriv2 = NULL;
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pWin2 = (WindowPtr)GetProp (pRLWinPriv->hWnd, WIN_WINDOW_PROP)) != NULL)
+ {
+ pRLWinPriv2 = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin2, FALSE);
+ }
+ winDebug ("winMWExtWMDestroyFrame2 (%08x) %08x\n",
+ pRLWinPriv2, pRLWinPriv2->hWnd);
+ if (pRLWinPriv != pRLWinPriv2 || pRLWinPriv->hWnd != pRLWinPriv2->hWnd)
+ {
+ winDebug ("Error param missmatch\n");
+ *(int*)0 = 1;//raise exseption
+ }
+ }
+#endif
+#endif
+
+ /* Store the info we need to destroy after this window is gone */
+ hInstance = (HINSTANCE) GetClassLong (pRLWinPriv->hWnd, GCL_HMODULE);
+ hiconClass = (HICON) GetClassLong (pRLWinPriv->hWnd, GCL_HICON);
+ hiconSmClass = (HICON) GetClassLong (pRLWinPriv->hWnd, GCL_HICONSM);
+ iReturn = GetClassName (pRLWinPriv->hWnd, pszClass, CLASS_NAME_LENGTH);
+
+ pRLWinPriv->fClose = TRUE;
+ pRLWinPriv->fDestroyed = TRUE;
+
+ /* Destroy the Windows window */
+ DestroyWindow (pRLWinPriv->hWnd);
+
+ /* Only if we were able to get the name */
+ if (iReturn)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMDestroyFrame - Unregistering %s: ", pszClass);
+#endif
+ iReturn = UnregisterClass (pszClass, hInstance);
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMDestroyFramew - %d Deleting Icon: ", iReturn);
+#endif
+
+ winDestroyIcon(hiconClass);
+ winDestroyIcon(hiconSmClass);
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMDestroyFrame - done\n");
+#endif
+}
+
+void
+winMWExtWMMoveFrame (RootlessFrameID wid, ScreenPtr pScreen, int iNewX, int iNewY)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ RECT rcNew;
+ DWORD dwExStyle;
+ DWORD dwStyle;
+ int iX, iY, iWidth, iHeight;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMMoveFrame (%08x) (%d %d)\n", (int) pRLWinPriv, iNewX, iNewY);
+#endif
+
+ /* Get the Windows window style and extended style */
+ dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
+
+ /* Get the X and Y location of the X window */
+ iX = iNewX + GetSystemMetrics (SM_XVIRTUALSCREEN);
+ iY = iNewY + GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* Get the height and width of the X window */
+ iWidth = pRLWinPriv->pFrame->width;
+ iHeight = pRLWinPriv->pFrame->height;
+
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight);
+
+#ifdef CYGMULTIWINDOW_DEBUG
+ winDebug("\tWindow {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+#endif
+ /*
+ * Calculate the required size of the Windows window rectangle,
+ * given the size of the Windows window client area.
+ */
+ AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle);
+
+#ifdef CYGMULTIWINDOW_DEBUG
+ winDebug("\tAdjusted {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+#endif
+ g_fNoConfigureWindow = TRUE;
+ SetWindowPos (pRLWinPriv->hWnd, NULL, rcNew.left, rcNew.top, 0, 0,
+ SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
+ g_fNoConfigureWindow = FALSE;
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMMoveFrame (%08x) done\n", (int) pRLWinPriv);
+#endif
+}
+
+void
+winMWExtWMResizeFrame (RootlessFrameID wid, ScreenPtr pScreen,
+ int iNewX, int iNewY,
+ unsigned int uiNewWidth, unsigned int uiNewHeight,
+ unsigned int uiGravity)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ RECT rcNew;
+ RECT rcOld;
+ DWORD dwExStyle;
+ DWORD dwStyle;
+ int iX, iY;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMResizeFrame (%08x) (%d %d)-(%d %d)\n",
+ (int) pRLWinPriv, iNewX, iNewY, uiNewWidth, uiNewHeight);
+#endif
+
+ pRLWinPriv->fResized = TRUE;
+
+ /* Get the Windows window style and extended style */
+ dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
+
+ /* Get the X and Y location of the X window */
+ iX = iNewX + GetSystemMetrics (SM_XVIRTUALSCREEN);
+ iY = iNewY + GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect (&rcNew, iX, iY, iX + uiNewWidth, iY + uiNewHeight);
+
+ /*
+ * Calculate the required size of the Windows window rectangle,
+ * given the size of the Windows window client area.
+ */
+ AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle);
+
+ /* Get a rectangle describing the old Windows window */
+ GetWindowRect (pRLWinPriv->hWnd, &rcOld);
+
+ /* Check if the old rectangle and new rectangle are the same */
+ if (!EqualRect (&rcNew, &rcOld))
+ {
+
+ g_fNoConfigureWindow = TRUE;
+ MoveWindow (pRLWinPriv->hWnd,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ TRUE);
+ g_fNoConfigureWindow = FALSE;
+ }
+}
+
+void
+winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ win32RootlessWindowPtr pRLNextWinPriv = (win32RootlessWindowPtr) nextWid;
+ winScreenPriv(pRLWinPriv->pFrame->win->drawable.pScreen);
+ winScreenInfo *pScreenInfo = NULL;
+ DWORD dwCurrentProcessID = GetCurrentProcessId ();
+ DWORD dwWindowProcessID = 0;
+ HWND hWnd;
+ Bool fFirst = TRUE;
+ Bool fNeedRestack = TRUE;
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMRestackFrame (%08x)\n", (int) pRLWinPriv);
+#endif
+
+ if (pScreenPriv->fRestacking) return;
+
+ if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+
+ pRLWinPriv->fRestackingNow = TRUE;
+
+ /* Show window */
+ if(!IsWindowVisible (pRLWinPriv->hWnd))
+ ShowWindow (pRLWinPriv->hWnd, SW_SHOWNOACTIVATE);
+
+ if (pRLNextWinPriv == NULL)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("Win %08x is top\n", pRLWinPriv);
+#endif
+ pScreenPriv->widTop = wid;
+ SetWindowPos (pRLWinPriv->hWnd, HWND_TOP,
+ 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ }
+ else if (winIsInternalWMRunning(pScreenInfo))
+ {
+ /* using mulwinidow wm */
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("Win %08x is not top\n", pRLWinPriv);
+#endif
+ for (hWnd = GetNextWindow (pRLWinPriv->hWnd, GW_HWNDPREV);
+ fNeedRestack && hWnd != NULL;
+ hWnd = GetNextWindow (hWnd, GW_HWNDPREV))
+ {
+ GetWindowThreadProcessId (hWnd, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp (hWnd, WIN_WINDOW_PROP))
+ {
+ if (hWnd == pRLNextWinPriv->hWnd)
+ {
+ /* Enable interleave X window and Windows window */
+ if (!fFirst)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("raise: Insert after Win %08x\n", pRLNextWinPriv);
+#endif
+ SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
+ 0, 0, 0, 0,
+ SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ }
+ else
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("No change\n");
+#endif
+ }
+ fNeedRestack = FALSE;
+ break;
+ }
+ if (fFirst) fFirst = FALSE;
+ }
+ }
+
+ for (hWnd = GetNextWindow (pRLWinPriv->hWnd, GW_HWNDNEXT);
+ fNeedRestack && hWnd != NULL;
+ hWnd = GetNextWindow (hWnd, GW_HWNDNEXT))
+ {
+ GetWindowThreadProcessId (hWnd, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp (hWnd, WIN_WINDOW_PROP))
+ {
+ if (hWnd == pRLNextWinPriv->hWnd)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("lower: Insert after Win %08x\n", pRLNextWinPriv);
+#endif
+ SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
+ 0, 0, 0, 0,
+ SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ fNeedRestack = FALSE;
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ /* using general wm like twm, wmaker etc.
+ Interleave X window and Windows window will cause problem. */
+ SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
+ 0, 0, 0, 0,
+ SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+#if 0
+#endif
+ }
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMRestackFrame - done (%08x)\n", (int) pRLWinPriv);
+#endif
+
+ pRLWinPriv->fRestackingNow = FALSE;
+}
+
+void
+winMWExtWMReshapeFrame (RootlessFrameID wid, RegionPtr pShape)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ HRGN hRgn, hRgnWindow, hRgnClient;
+ RECT rcWindow, rcClient;
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMReshapeFrame (%08x)\n", (int) pRLWinPriv);
+#endif
+
+ hRgn = winMWExtWMCreateRgnFromRegion (pShape);
+
+ /* Create region for non-client area */
+ GetWindowRect (pRLWinPriv->hWnd, &rcWindow);
+ GetClientRect (pRLWinPriv->hWnd, &rcClient);
+ MapWindowPoints (pRLWinPriv->hWnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
+ OffsetRgn (hRgn, rcClient.left - rcWindow.left, rcClient.top - rcWindow.top);
+ OffsetRect (&rcClient, -rcWindow.left, -rcWindow.top);
+ OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
+ hRgnWindow = CreateRectRgnIndirect (&rcWindow);
+ hRgnClient = CreateRectRgnIndirect (&rcClient);
+ CombineRgn (hRgnWindow, hRgnWindow, hRgnClient, RGN_DIFF);
+ CombineRgn (hRgn, hRgnWindow, hRgn, RGN_OR);
+
+
+ SetWindowRgn (pRLWinPriv->hWnd, hRgn, TRUE);
+
+ DeleteObject (hRgnWindow);
+ DeleteObject (hRgnClient);
+}
+
+void
+winMWExtWMUnmapFrame (RootlessFrameID wid)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMUnmapFrame (%08x)\n", (int) pRLWinPriv);
+#endif
+
+ g_fNoConfigureWindow = TRUE;
+ //ShowWindow (pRLWinPriv->hWnd, SW_MINIMIZE);
+ ShowWindow (pRLWinPriv->hWnd, SW_HIDE);
+ g_fNoConfigureWindow = FALSE;
+}
+
+/*
+ * Fixme: Code sharing with winshadgdi.c and other engine support
+ */
+void
+winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+ ScreenPtr pScreen = NULL;
+ DIBSECTION dibsection;
+ Bool fReturn = TRUE;
+ HDC hdcNew;
+ HBITMAP hbmpNew;
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMStartDrawing (%08x) %08x\n", (int) pRLWinPriv, pRLWinPriv->fDestroyed);
+#endif
+
+ if (!pRLWinPriv->fDestroyed)
+ {
+ pScreen = pRLWinPriv->pFrame->win->drawable.pScreen;
+ if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
+ if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tpScreenPriv %08X\n", (int) pScreenPriv);
+ winDebug ("\tpScreenInfo %08X\n", (int) pScreenInfo);
+ winDebug ("\t(%d, %d)\n", (int)pRLWinPriv->pFrame->width,
+ (int) pRLWinPriv->pFrame->height);
+#endif
+ if (pRLWinPriv->hdcScreen == NULL)
+ {
+ InitWin32RootlessEngine (pRLWinPriv);
+ }
+
+ if (pRLWinPriv->fResized)
+ {
+ /* width * bpp must be multiple of 4 to match 32bit alignment */
+ int stridesize;
+ int misalignment;
+
+ pRLWinPriv->pbmihShadow->biWidth = pRLWinPriv->pFrame->width;
+ pRLWinPriv->pbmihShadow->biHeight = -pRLWinPriv->pFrame->height;
+
+ stridesize = pRLWinPriv->pFrame->width * (pScreenInfo->dwBPP >> 3);
+ misalignment = stridesize & 3;
+ if (misalignment != 0)
+ {
+ stridesize += 4 - misalignment;
+ pRLWinPriv->pbmihShadow->biWidth = stridesize / (pScreenInfo->dwBPP >> 3);
+ winDebug("\tresizing to %d (was %d)\n",
+ pRLWinPriv->pbmihShadow->biWidth, pRLWinPriv->pFrame->width);
+ }
+
+ hdcNew = CreateCompatibleDC (pRLWinPriv->hdcScreen);
+ /* Create a DI shadow bitmap with a bit pointer */
+ hbmpNew = CreateDIBSection (pRLWinPriv->hdcScreen,
+ (BITMAPINFO *) pRLWinPriv->pbmihShadow,
+ DIB_RGB_COLORS,
+ (VOID**) &pRLWinPriv->pfb,
+ NULL,
+ 0);
+ if (hbmpNew == NULL || pRLWinPriv->pfb == NULL)
+ {
+ ErrorF ("winMWExtWMStartDrawing - CreateDIBSection failed\n");
+ //return FALSE;
+ }
+ else
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMStartDrawing - Shadow buffer allocated\n");
+#endif
+ }
+
+ /* Get information about the bitmap that was allocated */
+ GetObject (hbmpNew, sizeof (dibsection), &dibsection);
+
+#if CYGMULTIWINDOW_DEBUG
+ /* Print information about bitmap allocated */
+ winDebug ("winMWExtWMStartDrawing - Dibsection width: %d height: %d "
+ "depth: %d size image: %d\n",
+ (unsigned int)dibsection.dsBmih.biWidth,
+ (unsigned int)dibsection.dsBmih.biHeight,
+ (unsigned int)dibsection.dsBmih.biBitCount,
+ (unsigned int)dibsection.dsBmih.biSizeImage);
+#endif
+
+ /* Select the shadow bitmap into the shadow DC */
+ SelectObject (hdcNew, hbmpNew);
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMStartDrawing - Attempting a shadow blit\n");
+#endif
+
+ /* Blit from the old shadow to the new shadow */
+ fReturn = BitBlt (hdcNew,
+ 0, 0,
+ pRLWinPriv->pFrame->width, pRLWinPriv->pFrame->height,
+ pRLWinPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+ if (fReturn)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMStartDrawing - Shadow blit success\n");
+#endif
+ }
+ else
+ {
+ ErrorF ("winMWExtWMStartDrawing - Shadow blit failure\n");
+ }
+
+ /* Look for height weirdness */
+ if (dibsection.dsBmih.biHeight < 0)
+ {
+ /* FIXME: Figure out why biHeight is sometimes negative */
+ ErrorF ("winMWExtWMStartDrawing - WEIRDNESS - "
+ "biHeight still negative: %d\n",
+ (int) dibsection.dsBmih.biHeight);
+ ErrorF ("winMWExtWMStartDrawing - WEIRDNESS - "
+ "Flipping biHeight sign\n");
+ dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight;
+ }
+
+ pRLWinPriv->dwWidthBytes = dibsection.dsBm.bmWidthBytes;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMStartDrawing - bytesPerRow: %d\n",
+ (unsigned int)dibsection.dsBm.bmWidthBytes);
+#endif
+
+ /* Free the old shadow bitmap */
+ DeleteObject (pRLWinPriv->hdcShadow);
+ DeleteObject (pRLWinPriv->hbmpShadow);
+
+ pRLWinPriv->hdcShadow = hdcNew;
+ pRLWinPriv->hbmpShadow = hbmpNew;
+
+ pRLWinPriv->fResized = FALSE;
+#if CYGMULTIWINDOW_DEBUG && FALSE
+ winDebug ("winMWExtWMStartDrawing - 0x%08x %d\n",
+ (unsigned int)pRLWinPriv->pfb,
+ (unsigned int)dibsection.dsBm.bmWidthBytes);
+#endif
+ }
+ }
+ else
+ {
+ ErrorF ("winMWExtWMStartDrawing - Already window was destroyed \n");
+ }
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMStartDrawing - done (0x%08x) 0x%08x %d\n",
+ (int) pRLWinPriv,
+ (unsigned int)pRLWinPriv->pfb, (unsigned int)pRLWinPriv->dwWidthBytes);
+#endif
+ *pixelData = pRLWinPriv->pfb;
+ *bytesPerRow = pRLWinPriv->dwWidthBytes;
+}
+
+void
+winMWExtWMStopDrawing (RootlessFrameID wid, Bool fFlush)
+{
+#if 0
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ BLENDFUNCTION bfBlend;
+ SIZE szWin;
+ POINT ptSrc;
+#if CYGMULTIWINDOW_DEBUG || TRUE
+ winDebug ("winMWExtWMStopDrawing (%08x)\n", pRLWinPriv);
+#endif
+ szWin.cx = pRLWinPriv->dwWidth;
+ szWin.cy = pRLWinPriv->dwHeight;
+ ptSrc.x = 0;
+ ptSrc.y = 0;
+ bfBlend.BlendOp = AC_SRC_OVER;
+ bfBlend.BlendFlags = 0;
+ bfBlend.SourceConstantAlpha = 255;
+ bfBlend.AlphaFormat = AC_SRC_ALPHA;
+
+ if (!UpdateLayeredWindow (pRLWinPriv->hWnd,
+ NULL, NULL, &szWin,
+ pRLWinPriv->hdcShadow, &ptSrc,
+ 0, &bfBlend, ULW_ALPHA))
+ {
+ ErrorF ("winMWExtWMStopDrawing - UpdateLayeredWindow failed\n");
+ }
+#endif
+}
+
+void
+winMWExtWMUpdateRegion (RootlessFrameID wid, RegionPtr pDamage)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+#if 0
+ BLENDFUNCTION bfBlend;
+ SIZE szWin;
+ POINT ptSrc;
+#endif
+#if CYGMULTIWINDOW_DEBUG && 0
+ winDebug ("winMWExtWMUpdateRegion (%08x)\n", pRLWinPriv);
+#endif
+#if 0
+ szWin.cx = pRLWinPriv->dwWidth;
+ szWin.cy = pRLWinPriv->dwHeight;
+ ptSrc.x = 0;
+ ptSrc.y = 0;
+ bfBlend.BlendOp = AC_SRC_OVER;
+ bfBlend.BlendFlags = 0;
+ bfBlend.SourceConstantAlpha = 255;
+ bfBlend.AlphaFormat = AC_SRC_ALPHA;
+
+ if (!UpdateLayeredWindow (pRLWinPriv->hWnd,
+ NULL, NULL, &szWin,
+ pRLWinPriv->hdcShadow, &ptSrc,
+ 0, &bfBlend, ULW_ALPHA))
+ {
+ LPVOID lpMsgBuf;
+
+ /* Display a fancy error message */
+ FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError (),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &lpMsgBuf,
+ 0, NULL);
+
+ ErrorF ("winMWExtWMUpdateRegion - UpdateLayeredWindow failed: %s\n",
+ (LPSTR)lpMsgBuf);
+ LocalFree (lpMsgBuf);
+ }
+#endif
+ if (!g_fNoConfigureWindow) UpdateWindow (pRLWinPriv->hWnd);
+}
+
+void
+winMWExtWMDamageRects (RootlessFrameID wid, int nCount, const BoxRec *pRects,
+ int shift_x, int shift_y)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ const BoxRec *pEnd;
+#if CYGMULTIWINDOW_DEBUG && 0
+ winDebug ("winMWExtWMDamageRects (%08x, %d, %08x, %d, %d)\n",
+ pRLWinPriv, nCount, pRects, shift_x, shift_y);
+#endif
+
+ for (pEnd = pRects + nCount; pRects < pEnd; pRects++) {
+ RECT rcDmg;
+ rcDmg.left = pRects->x1 + shift_x;
+ rcDmg.top = pRects->y1 + shift_y;
+ rcDmg.right = pRects->x2 + shift_x;
+ rcDmg.bottom = pRects->y2 + shift_y;
+
+ InvalidateRect (pRLWinPriv->hWnd, &rcDmg, FALSE);
+ }
+}
+
+void
+winMWExtWMRootlessSwitchWindow (RootlessWindowPtr pFrame, WindowPtr oldWin)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid;
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMRootlessSwitchWindow (%08x) %08x\n",
+ (int) pRLWinPriv, (int) pRLWinPriv->hWnd);
+#endif
+ pRLWinPriv->pFrame = pFrame;
+ pRLWinPriv->fResized = TRUE;
+
+ /* Set the window extended style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
+
+ /* Set the window standard style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
+ WS_POPUP | WS_CLIPCHILDREN);
+
+ DeleteProperty (oldWin, AtmWindowsWmNativeHwnd ());
+ winMWExtWMSetNativeProperty (pFrame);
+#if CYGMULTIWINDOW_DEBUG
+#if 0
+ {
+ WindowPtr pWin2 = NULL;
+ win32RootlessWindowPtr pRLWinPriv2 = NULL;
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pWin2 = (WindowPtr)GetProp (pRLWinPriv->hWnd, WIN_WINDOW_PROP)) != NULL)
+ {
+ pRLWinPriv2 = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin2, FALSE);
+ }
+ winDebug ("winMWExtWMSwitchFrame2 (%08x) %08x\n",
+ pRLWinPriv2, pRLWinPriv2->hWnd);
+ if (pRLWinPriv != pRLWinPriv2 || pRLWinPriv->hWnd != pRLWinPriv2->hWnd)
+ {
+ winDebug ("Error param missmatch\n");
+ }
+ }
+#endif
+#endif
+}
+
+void
+winMWExtWMCopyBytes (unsigned int width, unsigned int height,
+ const void *src, unsigned int srcRowBytes,
+ void *dst, unsigned int dstRowBytes)
+{
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMCopyBytes - Not implemented\n");
+#endif
+}
+
+void
+winMWExtWMFillBytes (unsigned int width, unsigned int height, unsigned int value,
+ void *dst, unsigned int dstRowBytes)
+{
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMFillBytes - Not implemented\n");
+#endif
+}
+
+int
+winMWExtWMCompositePixels (unsigned int width, unsigned int height, unsigned int function,
+ void *src[2], unsigned int srcRowBytes[2],
+ void *mask, unsigned int maskRowBytes,
+ void *dst[2], unsigned int dstRowBytes[2])
+{
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMCompositePixels - Not implemented\n");
+#endif
+ return 0;
+}
+
+
+void
+winMWExtWMCopyWindow (RootlessFrameID wid, int nDstRects, const BoxRec *pDstRects,
+ int nDx, int nDy)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ const BoxRec *pEnd;
+ RECT rcDmg;
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMCopyWindow (%08x, %d, %08x, %d, %d)\n",
+ (int) pRLWinPriv, nDstRects, (int) pDstRects, nDx, nDy);
+#endif
+
+ for (pEnd = pDstRects + nDstRects; pDstRects < pEnd; pDstRects++)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("BitBlt (%d, %d, %d, %d) (%d, %d)\n",
+ pDstRects->x1, pDstRects->y1,
+ pDstRects->x2 - pDstRects->x1,
+ pDstRects->y2 - pDstRects->y1,
+ pDstRects->x1 + nDx,
+ pDstRects->y1 + nDy);
+#endif
+
+ if (!BitBlt (pRLWinPriv->hdcShadow,
+ pDstRects->x1, pDstRects->y1,
+ pDstRects->x2 - pDstRects->x1,
+ pDstRects->y2 - pDstRects->y1,
+ pRLWinPriv->hdcShadow,
+ pDstRects->x1 + nDx, pDstRects->y1 + nDy,
+ SRCCOPY))
+ {
+ ErrorF ("winMWExtWMCopyWindow - BitBlt failed.\n");
+ }
+
+ rcDmg.left = pDstRects->x1;
+ rcDmg.top = pDstRects->y1;
+ rcDmg.right = pDstRects->x2;
+ rcDmg.bottom = pDstRects->y2;
+
+ InvalidateRect (pRLWinPriv->hWnd, &rcDmg, FALSE);
+ }
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMCopyWindow - done\n");
+#endif
+}
+
+
+/*
+ * winMWExtWMSetNativeProperty
+ */
+
+static void
+winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid;
+ long lData;
+
+ /* FIXME: move this to WindowsWM extension */
+
+ lData = (long) pRLWinPriv->hWnd;
+ ChangeWindowProperty (pFrame->win, AtmWindowsWmNativeHwnd (),
+ XA_INTEGER, 32, PropModeReplace, 1, &lData, TRUE);
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winwin32rootlesswindow.c b/nx-X11/programs/Xserver/hw/xwin/winwin32rootlesswindow.c
new file mode 100755
index 000000000..693d5cd09
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winwin32rootlesswindow.c
@@ -0,0 +1,476 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Kensuke Matsuzaki
+ * Earle F. Philhower, III
+ * Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winprefs.h"
+
+#if 0
+/*
+ * winMWExtWMReorderWindows
+ */
+
+void
+winMWExtWMReorderWindows (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ HWND hwnd = NULL;
+ win32RootlessWindowPtr pRLWin = NULL;
+ win32RootlessWindowPtr pRLWinSib = NULL;
+ DWORD dwCurrentProcessID = GetCurrentProcessId ();
+ DWORD dwWindowProcessID = 0;
+ XID vlist[2];
+
+#if CYGMULTIWINDOW_DEBUG && FALSE
+ winDebug ("winMWExtWMReorderWindows\n");
+#endif
+
+ pScreenPriv->fRestacking = TRUE;
+
+ if (pScreenPriv->fWindowOrderChanged)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMReorderWindows - Need to restack\n");
+#endif
+ hwnd = GetTopWindow (NULL);
+
+ while (hwnd)
+ {
+ GetWindowThreadProcessId (hwnd, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp (hwnd, WIN_WINDOW_PROP))
+ {
+ pRLWinSib = pRLWin;
+ pRLWin = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP);
+
+ if (pRLWinSib)
+ {
+ vlist[0] = pRLWinSib->pFrame->win->drawable.id;
+ vlist[1] = Below;
+
+ ConfigureWindow (pRLWin->pFrame->win, CWSibling | CWStackMode,
+ vlist, wClient(pRLWin->pFrame->win));
+ }
+ else
+ {
+ /* 1st window - raise to the top */
+ vlist[0] = Above;
+
+ ConfigureWindow (pRLWin->pFrame->win, CWStackMode,
+ vlist, wClient(pRLWin->pFrame->win));
+ }
+ }
+ hwnd = GetNextWindow (hwnd, GW_HWNDNEXT);
+ }
+ }
+
+ pScreenPriv->fRestacking = FALSE;
+ pScreenPriv->fWindowOrderChanged = FALSE;
+}
+#endif
+
+
+/*
+ * winMWExtWMMoveXWindow
+ */
+
+void
+winMWExtWMMoveXWindow (WindowPtr pWin, int x, int y)
+{
+ CARD32 *vlist = malloc(sizeof(CARD32)*2);
+
+ vlist[0] = x;
+ vlist[1] = y;
+ ConfigureWindow (pWin, CWX | CWY, vlist, wClient(pWin));
+ free(vlist);
+}
+
+
+/*
+ * winMWExtWMResizeXWindow
+ */
+
+void
+winMWExtWMResizeXWindow (WindowPtr pWin, int w, int h)
+{
+ CARD32 *vlist = malloc(sizeof(CARD32)*2);
+
+ vlist[0] = w;
+ vlist[1] = h;
+ ConfigureWindow (pWin, CWWidth | CWHeight, vlist, wClient(pWin));
+ free(vlist);
+}
+
+
+/*
+ * winMWExtWMMoveResizeXWindow
+ */
+
+void
+winMWExtWMMoveResizeXWindow (WindowPtr pWin, int x, int y, int w, int h)
+{
+ CARD32 *vlist = malloc(sizeof(long)*4);
+
+ vlist[0] = x;
+ vlist[1] = y;
+ vlist[2] = w;
+ vlist[3] = h;
+
+ ConfigureWindow (pWin, CWX | CWY | CWWidth | CWHeight, vlist, wClient(pWin));
+ free(vlist);
+}
+
+
+/*
+ * winMWExtWMUpdateIcon
+ * Change the Windows window icon
+ */
+
+void
+winMWExtWMUpdateIcon (Window id)
+{
+ WindowPtr pWin;
+ HICON hIcon, hiconOld;
+
+ pWin = LookupIDByType (id, RT_WINDOW);
+ hIcon = (HICON)winOverrideIcon ((unsigned long)pWin);
+
+ if (!hIcon)
+ hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
+
+ if (hIcon)
+ {
+ win32RootlessWindowPtr pRLWinPriv
+ = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
+
+ if (pRLWinPriv->hWnd)
+ {
+ hiconOld = (HICON) SetClassLong (pRLWinPriv->hWnd,
+ GCL_HICON,
+ (int) hIcon);
+
+ winDestroyIcon(hiconOld);
+ }
+ }
+}
+
+
+/*
+ * winMWExtWMDecorateWindow - Update window style. Called by EnumWindows.
+ */
+
+wBOOL CALLBACK
+winMWExtWMDecorateWindow (HWND hwnd, LPARAM lParam)
+{
+ win32RootlessWindowPtr pRLWinPriv = NULL;
+ ScreenPtr pScreen = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pRLWinPriv = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
+ {
+ pScreen = pRLWinPriv->pFrame->win->drawable.pScreen;
+ if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
+ if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+ if (pRLWinPriv && pScreenInfo) winMWExtWMUpdateWindowDecoration (pRLWinPriv, pScreenInfo);
+ }
+ return TRUE;
+}
+
+
+/*
+ * winMWExtWMUpdateWindowDecoration - Update window style.
+ */
+
+void
+winMWExtWMUpdateWindowDecoration (win32RootlessWindowPtr pRLWinPriv,
+ winScreenInfoPtr pScreenInfo)
+{
+ Bool fDecorate = FALSE;
+ DWORD dwExStyle = 0;
+ DWORD dwStyle = 0;
+ WINDOWPLACEMENT wndPlace;
+ UINT showCmd = 0;
+
+ wndPlace.length = sizeof (WINDOWPLACEMENT);
+
+ /* Get current window placement */
+ GetWindowPlacement (pRLWinPriv->hWnd, &wndPlace);
+
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ if (!pRLWinPriv->pFrame->win->overrideRedirect)
+ fDecorate = TRUE;
+ }
+#if 0
+ if (wndPlace.showCmd == SW_HIDE)
+ return;//showCmd = SWP_HIDEWINDOW;
+ else
+ showCmd = SWP_SHOWWINDOW;
+#else
+ if (wndPlace.showCmd == SW_HIDE)
+ return;
+
+ if (IsWindowVisible (pRLWinPriv->hWnd))
+ showCmd = SWP_SHOWWINDOW;
+#endif
+
+ showCmd |= SWP_NOMOVE | SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER;
+
+ winDebug ("winMWExtWMUpdateWindowDecoration %08x %s\n",
+ (int)pRLWinPriv, fDecorate?"Decorate":"Bare");
+
+ /* Get the standard and extended window style information */
+ dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
+
+ if (fDecorate)
+ {
+ RECT rcNew;
+ int iDx, iDy;
+ winWMMessageRec wmMsg;
+ winScreenPriv(pScreenInfo->pScreen);
+
+ /* */
+ if (!(dwExStyle & WS_EX_APPWINDOW))
+ {
+ winDebug ("\tBare=>Decorate\n");
+ /* Setup a rectangle with the X window position and size */
+ SetRect (&rcNew,
+ pRLWinPriv->pFrame->x,
+ pRLWinPriv->pFrame->y,
+ pRLWinPriv->pFrame->x + pRLWinPriv->pFrame->width,
+ pRLWinPriv->pFrame->y + pRLWinPriv->pFrame->height);
+
+#ifdef CYGMULTIWINDOW_DEBUG
+ winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+#endif
+ /* */
+ AdjustWindowRectEx (&rcNew,
+ WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW,
+ FALSE,
+ WS_EX_APPWINDOW);
+
+#ifdef CYGMULTIWINDOW_DEBUG
+ winDebug("\tAdjusted {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+#endif
+ /* Calculate position deltas */
+ iDx = pRLWinPriv->pFrame->x - rcNew.left;
+ iDy = pRLWinPriv->pFrame->y - rcNew.top;
+
+ /* Calculate new rectangle */
+ rcNew.left += iDx;
+ rcNew.right += iDx;
+ rcNew.top += iDy;
+ rcNew.bottom += iDy;
+
+ /* Set the window extended style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW);
+
+ /* Set the window standard style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
+ WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW);
+
+#ifdef CYGMULTIWINDOW_DEBUG
+ winDebug("\tWindowStyle: %08x %08x\n",
+ WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW,
+ WS_EX_APPWINDOW);
+#endif
+ /* Position the Windows window */
+#ifdef CYGMULTIWINDOW_DEBUG
+ winDebug("\tMoved {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+#endif
+ SetWindowPos (pRLWinPriv->hWnd, NULL,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ showCmd);
+
+
+ wmMsg.hwndWindow = pRLWinPriv->hWnd;
+ wmMsg.iWindow = (Window)pRLWinPriv->pFrame->win->drawable.id;
+ wmMsg.msg = WM_WM_NAME_EVENT;
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+
+ winMWExtWMReshapeFrame ((RootlessFrameID)pRLWinPriv ,
+ wBoundingShape(pRLWinPriv->pFrame->win));
+ }
+ }
+ else
+ {
+ RECT rcNew;
+
+ /* */
+ if (dwExStyle & WS_EX_APPWINDOW)
+ {
+ winDebug ("\tDecorate=>Bare\n");
+ /* Setup a rectangle with the X window position and size */
+ SetRect (&rcNew,
+ pRLWinPriv->pFrame->x,
+ pRLWinPriv->pFrame->y,
+ pRLWinPriv->pFrame->x + pRLWinPriv->pFrame->width,
+ pRLWinPriv->pFrame->y + pRLWinPriv->pFrame->height);
+#if 0
+ /* */
+ AdjustWindowRectEx (&rcNew,
+ WS_POPUP | WS_CLIPCHILDREN,
+ FALSE,
+ WS_EX_TOOLWINDOW);
+
+ /* Calculate position deltas */
+ iDx = pRLWinPriv->pFrame->x - rcNew.left;
+ iDy = pRLWinPriv->pFrame->y - rcNew.top;
+
+ /* Calculate new rectangle */
+ rcNew.left += iDx;
+ rcNew.right += iDx;
+ rcNew.top += iDy;
+ rcNew.bottom += iDy;
+#endif
+
+ /* Hide window temporary to remove from taskbar. */
+ ShowWindow( pRLWinPriv->hWnd, SW_HIDE );
+
+ /* Set the window extended style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
+
+ /* Set the window standard style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
+ WS_POPUP | WS_CLIPCHILDREN);
+
+ /* Position the Windows window */
+ SetWindowPos (pRLWinPriv->hWnd, NULL,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ showCmd);
+
+ winMWExtWMReshapeFrame ((RootlessFrameID)pRLWinPriv ,
+ wBoundingShape(pRLWinPriv->pFrame->win));
+ }
+ }
+}
+
+
+/*
+ * winIsInternalWMRunning (winScreenInfoPtr pScreenInfo)
+ */
+Bool
+winIsInternalWMRunning (winScreenInfoPtr pScreenInfo)
+{
+ return pScreenInfo->fInternalWM && !pScreenInfo->fAnotherWMRunning;
+}
+
+
+/*
+ * winMWExtWMRestackWindows
+ */
+
+void
+winMWExtWMRestackWindows (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ WindowPtr pRoot = WindowTable[pScreen->myNum];
+ WindowPtr pWin = NULL;
+ WindowPtr pWinPrev = NULL;
+ win32RootlessWindowPtr pRLWin = NULL;
+ win32RootlessWindowPtr pRLWinPrev = NULL;
+ int nWindow = 0;
+ HDWP hWinPosInfo = NULL;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMRestackWindows\n");
+#endif
+
+ pScreenPriv->fRestacking = TRUE;
+
+ if (pRoot != NULL)
+ {
+ for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib)
+ nWindow ++;
+
+ hWinPosInfo = BeginDeferWindowPos(nWindow);
+
+ for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib)
+ {
+ if (pWin->realized)
+ {
+ UINT uFlags;
+
+ pRLWin = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
+ if (pRLWin == NULL) continue;
+
+ if (pWinPrev)
+ pRLWinPrev = (win32RootlessWindowPtr) RootlessFrameForWindow (pWinPrev, FALSE);
+
+ uFlags = SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW;
+ if (pRLWinPrev != NULL) uFlags |= SWP_NOACTIVATE;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMRestackWindows - DeferWindowPos (%08x, %08x)\n",
+ pRLWin->hWnd,
+ pRLWinPrev ? pRLWinPrev->hWnd : HWND_TOP);
+#endif
+ hWinPosInfo = DeferWindowPos (hWinPosInfo, pRLWin->hWnd,
+ pRLWinPrev ? pRLWinPrev->hWnd : HWND_TOP,
+ 0, 0, 0, 0,
+ uFlags);
+ if (hWinPosInfo == NULL)
+ {
+ ErrorF ("winMWExtWMRestackWindows - DeferWindowPos () failed: %d\n",
+ (int) GetLastError ());
+ return;
+ }
+ pWinPrev = pWin;
+ }
+ }
+ if (!EndDeferWindowPos (hWinPosInfo))
+ {
+ ErrorF ("winMWExtWMRestackWindows - EndDeferWindowPos () failed: %d\n",
+ (int) GetLastError ());
+ return;
+ }
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMRestackWindows - done\n");
+#endif
+ pScreenPriv->fRestacking = FALSE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winwin32rootlesswndproc.c b/nx-X11/programs/Xserver/hw/xwin/winwin32rootlesswndproc.c
new file mode 100755
index 000000000..ffa84938f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winwin32rootlesswndproc.c
@@ -0,0 +1,1324 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Kensuke Matsuzaki
+ * Earle F. Philhower, III
+ * Harold L Hunt II
+ */
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include <winuser.h>
+#define _WINDOWSWM_SERVER_
+#include "windowswmstr.h"
+#include "dixevents.h"
+#include "propertyst.h"
+#include <X11/Xatom.h>
+#include "winmultiwindowclass.h"
+#include "winmsg.h"
+
+
+/*
+ * Constant defines
+ */
+
+#define MOUSE_POLLING_INTERVAL 500
+#define MOUSE_ACTIVATE_DEFAULT TRUE
+#define RAISE_ON_CLICK_DEFAULT FALSE
+
+
+/*
+ * Global variables
+ */
+
+extern Bool g_fNoConfigureWindow;
+extern Bool g_fSoftwareCursor;
+
+
+/*
+ * Local globals
+ */
+
+static UINT_PTR g_uipMousePollingTimerID = 0;
+
+
+/*
+ * Local function
+ */
+
+DEFINE_ATOM_HELPER(AtmWindowsWmRaiseOnClick, WINDOWSWM_RAISE_ON_CLICK)
+DEFINE_ATOM_HELPER(AtmWindowsWMMouseActivate, WINDOWSWM_MOUSE_ACTIVATE)
+/* DEFINE_ATOM_HELPER(AtmWindowsWMClientWindow, WINDOWSWM_CLIENT_WINDOW) */
+
+/*
+ * ConstrainSize - Taken from TWM sources - Respects hints for sizing
+ */
+#define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) )
+static void
+ConstrainSize (WinXSizeHints hints, int *widthp, int *heightp)
+{
+ int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta;
+ int baseWidth, baseHeight;
+ int dwidth = *widthp, dheight = *heightp;
+
+ if (hints.flags & PMinSize)
+ {
+ minWidth = hints.min_width;
+ minHeight = hints.min_height;
+ }
+ else if (hints.flags & PBaseSize)
+ {
+ minWidth = hints.base_width;
+ minHeight = hints.base_height;
+ }
+ else
+ minWidth = minHeight = 1;
+
+ if (hints.flags & PBaseSize)
+ {
+ baseWidth = hints.base_width;
+ baseHeight = hints.base_height;
+ }
+ else if (hints.flags & PMinSize)
+ {
+ baseWidth = hints.min_width;
+ baseHeight = hints.min_height;
+ }
+ else
+ baseWidth = baseHeight = 0;
+
+ if (hints.flags & PMaxSize)
+ {
+ maxWidth = hints.max_width;
+ maxHeight = hints.max_height;
+ }
+ else
+ {
+ maxWidth = MAXINT;
+ maxHeight = MAXINT;
+ }
+
+ if (hints.flags & PResizeInc)
+ {
+ xinc = hints.width_inc;
+ yinc = hints.height_inc;
+ }
+ else
+ xinc = yinc = 1;
+
+ /*
+ * First, clamp to min and max values
+ */
+ if (dwidth < minWidth)
+ dwidth = minWidth;
+ if (dheight < minHeight)
+ dheight = minHeight;
+
+ if (dwidth > maxWidth)
+ dwidth = maxWidth;
+ if (dheight > maxHeight)
+ dheight = maxHeight;
+
+ /*
+ * Second, fit to base + N * inc
+ */
+ dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
+ dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
+
+ /*
+ * Third, adjust for aspect ratio
+ */
+
+ /*
+ * The math looks like this:
+ *
+ * minAspectX dwidth maxAspectX
+ * ---------- <= ------- <= ----------
+ * minAspectY dheight maxAspectY
+ *
+ * If that is multiplied out, then the width and height are
+ * invalid in the following situations:
+ *
+ * minAspectX * dheight > minAspectY * dwidth
+ * maxAspectX * dheight < maxAspectY * dwidth
+ *
+ */
+
+ if (hints.flags & PAspect)
+ {
+ if (hints.min_aspect.x * dheight > hints.min_aspect.y * dwidth)
+ {
+ delta = makemult(hints.min_aspect.x * dheight / hints.min_aspect.y - dwidth, xinc);
+ if (dwidth + delta <= maxWidth)
+ dwidth += delta;
+ else
+ {
+ delta = makemult(dheight - dwidth*hints.min_aspect.y/hints.min_aspect.x, yinc);
+ if (dheight - delta >= minHeight)
+ dheight -= delta;
+ }
+ }
+
+ if (hints.max_aspect.x * dheight < hints.max_aspect.y * dwidth)
+ {
+ delta = makemult(dwidth * hints.max_aspect.y / hints.max_aspect.x - dheight, yinc);
+ if (dheight + delta <= maxHeight)
+ dheight += delta;
+ else
+ {
+ delta = makemult(dwidth - hints.max_aspect.x*dheight/hints.max_aspect.y, xinc);
+ if (dwidth - delta >= minWidth)
+ dwidth -= delta;
+ }
+ }
+ }
+
+ /* Return computed values */
+ *widthp = dwidth;
+ *heightp = dheight;
+}
+#undef makemult
+
+
+
+/*
+ * ValidateSizing - Ensures size request respects hints
+ */
+static int
+ValidateSizing (HWND hwnd, WindowPtr pWin,
+ WPARAM wParam, LPARAM lParam)
+{
+ WinXSizeHints sizeHints;
+ RECT *rect;
+ int iWidth, iHeight, iTopBorder;
+ POINT pt;
+
+ /* Invalid input checking */
+ if (pWin==NULL || lParam==0)
+ {
+ ErrorF ("Invalid input checking\n");
+ return FALSE;
+ }
+
+ /* No size hints, no checking */
+ if (!winMultiWindowGetWMNormalHints (pWin, &sizeHints))
+ {
+ ErrorF ("No size hints, no checking\n");
+ return FALSE;
+ }
+
+ /* Avoid divide-by-zero */
+ if (sizeHints.flags & PResizeInc)
+ {
+ if (sizeHints.width_inc == 0) sizeHints.width_inc = 1;
+ if (sizeHints.height_inc == 0) sizeHints.height_inc = 1;
+ }
+
+ rect = (RECT*)lParam;
+
+ iWidth = rect->right - rect->left;
+ iHeight = rect->bottom - rect->top;
+
+ /* Get title bar height, there must be an easier way?! */
+ pt.x = pt.y = 0;
+ ClientToScreen(hwnd, &pt);
+ iTopBorder = pt.y - rect->top;
+
+ /* Now remove size of any borders */
+ iWidth -= 2 * GetSystemMetrics(SM_CXSIZEFRAME);
+ iHeight -= GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
+
+ /* Constrain the size to legal values */
+ ConstrainSize (sizeHints, &iWidth, &iHeight);
+
+ /* Add back the borders */
+ iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
+ iHeight += GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
+
+ /* Adjust size according to where we're dragging from */
+ switch(wParam) {
+ case WMSZ_TOP:
+ case WMSZ_TOPRIGHT:
+ case WMSZ_BOTTOM:
+ case WMSZ_BOTTOMRIGHT:
+ case WMSZ_RIGHT:
+ rect->right = rect->left + iWidth;
+ break;
+ default:
+ rect->left = rect->right - iWidth;
+ break;
+ }
+ switch(wParam) {
+ case WMSZ_BOTTOM:
+ case WMSZ_BOTTOMRIGHT:
+ case WMSZ_BOTTOMLEFT:
+ case WMSZ_RIGHT:
+ case WMSZ_LEFT:
+ rect->bottom = rect->top + iHeight;
+ break;
+ default:
+ rect->top = rect->bottom - iHeight;
+ break;
+ }
+ return TRUE;
+}
+
+
+/*
+ * IsRaiseOnClick
+ */
+
+static Bool
+IsRaiseOnClick (WindowPtr pWin)
+{
+
+ struct _Window *pwin;
+ struct _Property *prop;
+ WindowPtr pRoot = GetCurrentRootWindow ();
+
+ if (!pWin)
+ {
+ ErrorF ("IsRaiseOnClick - no prop use default value:%d\n",
+ RAISE_ON_CLICK_DEFAULT);
+ return RAISE_ON_CLICK_DEFAULT;
+ }
+
+ pwin = (struct _Window*) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ while (prop)
+ {
+ if (prop->propertyName == AtmWindowsWmRaiseOnClick ()
+ && prop->type == XA_INTEGER
+ && prop->format == 32)
+ {
+ return *(int*)prop->data;
+ }
+ else
+ prop = prop->next;
+ }
+
+ if (pWin != pRoot)
+ {
+ return IsRaiseOnClick (pRoot);
+ }
+ else
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("IsRaiseOnClick - no prop use default value:%d\n",
+ RAISE_ON_CLICK_DEFAULT);
+#endif
+ return RAISE_ON_CLICK_DEFAULT;
+ }
+}
+
+
+/*
+ * IsMouseActive
+ */
+
+static Bool
+IsMouseActive (WindowPtr pWin)
+{
+
+ struct _Window *pwin;
+ struct _Property *prop;
+ WindowPtr pRoot = GetCurrentRootWindow ();
+
+ if (!pWin)
+ {
+ ErrorF ("IsMouseActive - pWin was NULL use default value:%d\n",
+ MOUSE_ACTIVATE_DEFAULT);
+ return MOUSE_ACTIVATE_DEFAULT;
+ }
+
+ pwin = (struct _Window*) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ while (prop)
+ {
+ if (prop->propertyName == AtmWindowsWMMouseActivate ()
+ && prop->type == XA_INTEGER
+ && prop->format == 32)
+ {
+ return *(int*)prop->data;
+ }
+ else
+ prop = prop->next;
+ }
+
+ if (pWin != pRoot)
+ {
+ return IsMouseActive (pRoot);
+ }
+ else
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("IsMouseActive - no prop use default value:%d\n",
+ MOUSE_ACTIVATE_DEFAULT);
+#endif
+ return MOUSE_ACTIVATE_DEFAULT;
+ }
+}
+
+
+/*
+ * winMWExtWMWindowProc - Window procedure
+ */
+
+LRESULT CALLBACK
+winMWExtWMWindowProc (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ WindowPtr pWin = NULL;
+ win32RootlessWindowPtr pRLWinPriv = NULL;
+ ScreenPtr pScreen = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+ HWND hwndScreen = NULL;
+ POINT ptMouse;
+ static Bool s_fTracking = FALSE;
+ HDC hdcUpdate;
+ PAINTSTRUCT ps;
+ LPWINDOWPOS pWinPos = NULL;
+ RECT rcClient;
+ winWMMessageRec wmMsg;
+ Bool fWMMsgInitialized = FALSE;
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pRLWinPriv = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
+ {
+ pWin = pRLWinPriv->pFrame->win;
+ pScreen = pWin->drawable.pScreen;
+ if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
+ if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+ if (pScreenPriv) hwndScreen = pScreenPriv->hwndScreen;
+
+ wmMsg.msg = 0;
+ wmMsg.hwndWindow = hwnd;
+ wmMsg.iWindow = (Window)pWin->drawable.id;
+
+ wmMsg.iX = pRLWinPriv->pFrame->x;
+ wmMsg.iY = pRLWinPriv->pFrame->y;
+ wmMsg.iWidth = pRLWinPriv->pFrame->width;
+ wmMsg.iHeight = pRLWinPriv->pFrame->height;
+
+ fWMMsgInitialized = TRUE;
+#if CYGDEBUG
+ winDebugWin32Message("winMWExtWMWindowProc", hwnd, message, wParam, lParam);
+
+ winDebug ("\thWnd %08X\n", hwnd);
+ winDebug ("\tpScreenPriv %08X\n", pScreenPriv);
+ winDebug ("\tpScreenInfo %08X\n", pScreenInfo);
+ winDebug ("\thwndScreen %08X\n", hwndScreen);
+ winDebug ("winMWExtWMWindowProc (%08x) %08x %08x %08x\n",
+ pRLWinPriv, message, wParam, lParam);
+#endif
+ }
+ /* Branch on message type */
+ switch (message)
+ {
+ case WM_CREATE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_CREATE\n");
+#endif
+ /* */
+ SetProp (hwnd,
+ WIN_WINDOW_PROP,
+ (HANDLE)((LPCREATESTRUCT) lParam)->lpCreateParams);
+ return 0;
+
+ case WM_CLOSE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_CLOSE %d\n", pRLWinPriv->fClose);
+#endif
+ /* Tell window-manager to close window */
+ if (pRLWinPriv->fClose)
+ {
+ DestroyWindow (hwnd);
+ }
+ else
+ {
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ /* Tell our Window Manager thread to kill the window */
+ wmMsg.msg = WM_WM_KILL;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMCloseWindow,
+ pWin->drawable.id,
+ 0, 0, 0, 0);
+ }
+ return 0;
+
+ case WM_DESTROY:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_DESTROY\n");
+#endif
+ /* Free the shaodw DC; which allows the bitmap to be freed */
+ DeleteDC (pRLWinPriv->hdcShadow);
+ pRLWinPriv->hdcShadow = NULL;
+
+ /* Free the shadow bitmap */
+ DeleteObject (pRLWinPriv->hbmpShadow);
+ pRLWinPriv->hbmpShadow = NULL;
+
+ /* Free the screen DC */
+ ReleaseDC (pRLWinPriv->hWnd, pRLWinPriv->hdcScreen);
+ pRLWinPriv->hdcScreen = NULL;
+
+ /* Free shadow buffer info header */
+ free (pRLWinPriv->pbmihShadow);
+ pRLWinPriv->pbmihShadow = NULL;
+
+ pRLWinPriv->fResized = FALSE;
+ pRLWinPriv->pfb = NULL;
+ free (pRLWinPriv);
+ RemoveProp (hwnd, WIN_WINDOW_PROP);
+ break;
+
+ case WM_MOUSEMOVE:
+#if CYGMULTIWINDOW_DEBUG && 0
+ winDebug ("winMWExtWMWindowProc - WM_MOUSEMOVE\n");
+#endif
+ /* Unpack the client area mouse coordinates */
+ ptMouse.x = GET_X_LPARAM(lParam);
+ ptMouse.y = GET_Y_LPARAM(lParam);
+
+ /* Translate the client area mouse coordinates to screen coordinates */
+ ClientToScreen (hwnd, &ptMouse);
+
+ /* Screen Coords from (-X, -Y) -> Root Window (0, 0) */
+ ptMouse.x -= GetSystemMetrics (SM_XVIRTUALSCREEN);
+ ptMouse.y -= GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* We can't do anything without privates */
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Has the mouse pointer crossed screens? */
+ if (pScreen != miPointerCurrentScreen ())
+ miPointerSetNewScreen (pScreenInfo->dwScreen,
+ ptMouse.x - pScreenInfo->dwXOffset,
+ ptMouse.y - pScreenInfo->dwYOffset);
+
+ /* Are we tracking yet? */
+ if (!s_fTracking)
+ {
+ TRACKMOUSEEVENT tme;
+
+ /* Setup data structure */
+ ZeroMemory (&tme, sizeof (tme));
+ tme.cbSize = sizeof (tme);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = hwnd;
+
+ /* Call the tracking function */
+ if (!(*g_fpTrackMouseEvent) (&tme))
+ ErrorF ("winMWExtWMWindowProc - _TrackMouseEvent failed\n");
+
+ /* Flag that we are tracking now */
+ s_fTracking = TRUE;
+ }
+
+ /* Kill the timer used to poll mouse events */
+ if (g_uipMousePollingTimerID != 0)
+ {
+ KillTimer (pScreenPriv->hwndScreen, WIN_POLLING_MOUSE_TIMER_ID);
+ g_uipMousePollingTimerID = 0;
+ }
+
+ /* Deliver absolute cursor position to X Server */
+ miPointerAbsoluteCursor (ptMouse.x - pScreenInfo->dwXOffset,
+ ptMouse.y - pScreenInfo->dwYOffset,
+ g_c32LastInputEventTime = GetTickCount ());
+ return 0;
+
+ case WM_NCMOUSEMOVE:
+#if CYGMULTIWINDOW_DEBUG && 0
+ winDebug ("winMWExtWMWindowProc - WM_NCMOUSEMOVE\n");
+#endif
+ /*
+ * We break instead of returning 0 since we need to call
+ * DefWindowProc to get the mouse cursor changes
+ * and min/max/close button highlighting in Windows XP.
+ * The Platform SDK says that you should return 0 if you
+ * process this message, but it fails to mention that you
+ * will give up any default functionality if you do return 0.
+ */
+
+ /* We can't do anything without privates */
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+
+ /*
+ * Timer to poll mouse events. This is needed to make
+ * programs like xeyes follow the mouse properly.
+ */
+ if (g_uipMousePollingTimerID == 0)
+ g_uipMousePollingTimerID = SetTimer (pScreenPriv->hwndScreen,
+ WIN_POLLING_MOUSE_TIMER_ID,
+ MOUSE_POLLING_INTERVAL,
+ NULL);
+ break;
+
+ case WM_MOUSELEAVE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MOUSELEAVE\n");
+#endif
+ /* Mouse has left our client area */
+
+ /* Flag that we are no longer tracking */
+ s_fTracking = FALSE;
+
+ /*
+ * Timer to poll mouse events. This is needed to make
+ * programs like xeyes follow the mouse properly.
+ */
+ if (g_uipMousePollingTimerID == 0)
+ g_uipMousePollingTimerID = SetTimer (pScreenPriv->hwndScreen,
+ WIN_POLLING_MOUSE_TIMER_ID,
+ MOUSE_POLLING_INTERVAL,
+ NULL);
+ return 0;
+
+ case WM_LBUTTONDBLCLK:
+ case WM_LBUTTONDOWN:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_LBUTTONDBLCLK\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (pScreen, ButtonPress, Button1, wParam);
+
+ case WM_LBUTTONUP:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_LBUTTONUP\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture ();
+ return winMouseButtonsHandle (pScreen, ButtonRelease, Button1, wParam);
+
+ case WM_MBUTTONDBLCLK:
+ case WM_MBUTTONDOWN:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MBUTTONDBLCLK\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (pScreen, ButtonPress, Button2, wParam);
+
+ case WM_MBUTTONUP:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MBUTTONUP\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture ();
+ return winMouseButtonsHandle (pScreen, ButtonRelease, Button2, wParam);
+
+ case WM_RBUTTONDBLCLK:
+ case WM_RBUTTONDOWN:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_RBUTTONDBLCLK\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (pScreen, ButtonPress, Button3, wParam);
+
+ case WM_RBUTTONUP:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_RBUTTONUP\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture ();
+ return winMouseButtonsHandle (pScreen, ButtonRelease, Button3, wParam);
+
+ case WM_XBUTTONDBLCLK:
+ case WM_XBUTTONDOWN:
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (pScreen, ButtonPress, HIWORD(wParam) + 5, wParam);
+ case WM_XBUTTONUP:
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture ();
+ return winMouseButtonsHandle (pScreen, ButtonRelease, HIWORD(wParam) + 5, wParam);
+
+ case WM_MOUSEWHEEL:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MOUSEWHEEL\n");
+#endif
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+ return 0;
+
+ case WM_MOUSEACTIVATE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MOUSEACTIVATE\n");
+#endif
+#if 1
+ /* Check if this window needs to be made active when clicked */
+ if (winIsInternalWMRunning(pScreenInfo) && pWin->overrideRedirect)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MOUSEACTIVATE - "
+ "MA_NOACTIVATE\n");
+#endif
+
+ /* */
+ return MA_NOACTIVATE;
+ }
+#endif
+ if (!winIsInternalWMRunning(pScreenInfo) && !IsMouseActive (pWin))
+ return MA_NOACTIVATE;
+
+ break;
+
+ case WM_KILLFOCUS:
+ /* Pop any pressed keys since we are losing keyboard focus */
+ winKeybdReleaseKeys ();
+ return 0;
+
+ case WM_SYSDEADCHAR:
+ case WM_DEADCHAR:
+ /*
+ * NOTE: We do nothing with WM_*CHAR messages,
+ * nor does the root window, so we can just toss these messages.
+ */
+ return 0;
+
+ case WM_SYSKEYDOWN:
+ case WM_KEYDOWN:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_*KEYDOWN\n");
+#endif
+
+ /*
+ * Don't pass Alt-F4 key combo to root window,
+ * let Windows translate to WM_CLOSE and close this top-level window.
+ *
+ * NOTE: We purposely don't check the fUseWinKillKey setting because
+ * it should only apply to the key handling for the root window,
+ * not for top-level window-manager windows.
+ *
+ * ALSO NOTE: We do pass Ctrl-Alt-Backspace to the root window
+ * because that is a key combo that no X app should be expecting to
+ * receive, since it has historically been used to shutdown the X server.
+ * Passing Ctrl-Alt-Backspace to the root window preserves that
+ * behavior, assuming that -unixkill has been passed as a parameter.
+ */
+ if (wParam == VK_F4 && (GetKeyState (VK_MENU) & 0x8000))
+ break;
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+ return 0;
+
+ case WM_SYSKEYUP:
+ case WM_KEYUP:
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_*KEYUP\n");
+#endif
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+ return 0;
+
+ case WM_HOTKEY:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_HOTKEY\n");
+#endif
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+ return 0;
+
+ case WM_PAINT:
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint (hwnd, &ps);
+
+ /* Try to copy from the shadow buffer */
+ if (!BitBlt (hdcUpdate,
+ ps.rcPaint.left, ps.rcPaint.top,
+ ps.rcPaint.right - ps.rcPaint.left,
+ ps.rcPaint.bottom - ps.rcPaint.top,
+ pRLWinPriv->hdcShadow,
+ ps.rcPaint.left, ps.rcPaint.top,
+ SRCCOPY))
+ {
+ LPVOID lpMsgBuf;
+
+ /* Display a fancy error message */
+ FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError (),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &lpMsgBuf,
+ 0, NULL);
+
+ ErrorF ("winMWExtWMWindowProc - BitBlt failed: %s\n",
+ (LPSTR)lpMsgBuf);
+ LocalFree (lpMsgBuf);
+ }
+
+ /* EndPaint frees the DC */
+ EndPaint (hwnd, &ps);
+ break;
+
+ case WM_ACTIVATE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_ACTIVATE\n");
+#endif
+ if (LOWORD(wParam) != WA_INACTIVE)
+ {
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+#if 0
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+#endif
+ /* Tell our Window Manager thread to activate the window */
+ wmMsg.msg = WM_WM_ACTIVATE;
+ if (fWMMsgInitialized)
+ if (!pWin || !pWin->overrideRedirect) /* for OOo menus */
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMActivateWindow,
+ pWin->drawable.id,
+ 0, 0,
+ 0, 0);
+ }
+ return 0;
+
+#if 1
+ case WM_WINDOWPOSCHANGING:
+ pWinPos = (LPWINDOWPOS)lParam;
+ if (!(pWinPos->flags & SWP_NOZORDER))
+ {
+ if (pRLWinPriv->fRestackingNow || pScreenPriv->fRestacking)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("Win %08x is now restacking.\n", (unsigned int)pRLWinPriv);
+#endif
+ break;
+ }
+
+ if (winIsInternalWMRunning(pScreenInfo) || IsRaiseOnClick (pWin))
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("Win %08x has WINDOWSWM_RAISE_ON_CLICK.\n", (unsigned int)pRLWinPriv);
+#endif
+ break;
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("Win %08x forbid to change z order (%08x).\n",
+ (unsigned int)pRLWinPriv, (unsigned int)pWinPos->hwndInsertAfter);
+#endif
+ pWinPos->flags |= SWP_NOZORDER;
+ }
+ break;
+#endif
+
+ case WM_MOVE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MOVE - %d ms\n",
+ (unsigned int)GetTickCount ());
+#endif
+ if (g_fNoConfigureWindow) break;
+#if 0
+ /* Bail if Windows window is not actually moving */
+ if (pRLWinPriv->dwX == (short) LOWORD(lParam)
+ && pRLWinPriv->dwY == (short) HIWORD(lParam))
+ break;
+
+ /* Also bail if we're maximizing, we'll do the whole thing in WM_SIZE */
+ {
+ WINDOWPLACEMENT windPlace;
+ windPlace.length = sizeof (WINDOWPLACEMENT);
+
+ /* Get current window placement */
+ GetWindowPlacement (hwnd, &windPlace);
+
+ /* Bail if maximizing */
+ if (windPlace.showCmd == SW_MAXIMIZE
+ || windPlace.showCmd == SW_SHOWMAXIMIZED)
+ break;
+ }
+#endif
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\t(%d, %d)\n", (short) LOWORD(lParam), (short) HIWORD(lParam));
+#endif
+ if (!pRLWinPriv->fMovingOrSizing)
+ {
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
+ winMWExtWMMoveXWindow (pWin,
+ (LOWORD(lParam) - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN)),
+ (HIWORD(lParam) - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN)));
+ }
+ return 0;
+
+ case WM_SHOWWINDOW:
+#if CYGMULTIWINDOW_DEBUG || TRUE
+ winDebug ("winMWExtWMWindowProc - WM_SHOWWINDOW - %d ms\n",
+ (unsigned int)GetTickCount ());
+#endif
+ /* Bail out if the window is being hidden */
+ if (!wParam)
+ return 0;
+
+ if (!pScreenInfo->fInternalWM)//XXXX
+ return 0;
+
+ winMWExtWMUpdateWindowDecoration (pRLWinPriv, pScreenInfo);
+
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+#if CYGMULTIWINDOW_DEBUG || TRUE
+ winDebug ("\tMapWindow\n");
+#endif
+ /* Tell X to map the window */
+ MapWindow (pWin, wClient(pWin));
+
+ if (!pRLWinPriv->pFrame->win->overrideRedirect)
+ /* Bring the Windows window to the foreground */
+ SetForegroundWindow (hwnd);
+
+ /* Setup the Window Manager message */
+ wmMsg.msg = WM_WM_MAP;
+ wmMsg.iWidth = pRLWinPriv->pFrame->width;
+ wmMsg.iHeight = pRLWinPriv->pFrame->height;
+
+ /* Tell our Window Manager thread to map the window */
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+ break;
+
+ case WM_SIZING:
+ /* Need to legalize the size according to WM_NORMAL_HINTS */
+ /* for applications like xterm */
+ return ValidateSizing (hwnd, pWin, wParam, lParam);
+
+ case WM_WINDOWPOSCHANGED:
+ {
+ pWinPos = (LPWINDOWPOS) lParam;
+#if CYGMULTIWINDOW_DEBUG
+ winDebug("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED\n");
+ winDebug("\tflags: %s%s%s%s%s%s%s%s%s%s%s%s\n",
+ (pWinPos->flags & SWP_DRAWFRAME)?"SWP_DRAWFRAME ":"",
+ (pWinPos->flags & SWP_FRAMECHANGED)?"SWP_FRAMECHANGED ":"",
+ (pWinPos->flags & SWP_HIDEWINDOW)?"SWP_HIDEWINDOW ":"",
+ (pWinPos->flags & SWP_NOACTIVATE)?"SWP_NOACTIVATE ":"",
+ (pWinPos->flags & SWP_NOCOPYBITS)?"SWP_NOCOPYBITS ":"",
+ (pWinPos->flags & SWP_NOMOVE)?"SWP_NOMOVE ":"",
+ (pWinPos->flags & SWP_NOOWNERZORDER)?"SWP_NOOWNERZORDER ":"",
+ (pWinPos->flags & SWP_NOSIZE)?"SWP_NOSIZE ":"",
+ (pWinPos->flags & SWP_NOREDRAW)?"SWP_NOREDRAW ":"",
+ (pWinPos->flags & SWP_NOSENDCHANGING)?"SWP_NOSENDCHANGING ":"",
+ (pWinPos->flags & SWP_NOZORDER)?"SWP_NOZORDER ":"",
+ (pWinPos->flags & SWP_SHOWWINDOW)?"SWP_SHOWWINDOW ":"");
+ winDebug("\tno_configure: %s\n", (g_fNoConfigureWindow?"Yes":"No"));
+ winDebug("\textend: (%d, %d, %d, %d)\n",
+ pWinPos->x, pWinPos->y, pWinPos->cx, pWinPos->cy);
+
+#endif
+ if (pWinPos->flags & SWP_HIDEWINDOW) break;
+
+ /* Reorder if window z order was changed */
+ if ((pScreenPriv != NULL)
+ && !(pWinPos->flags & SWP_NOZORDER)
+ && !(pWinPos->flags & SWP_SHOWWINDOW)
+ && winIsInternalWMRunning(pScreenInfo))
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\twindow z order was changed\n");
+#endif
+ if (pWinPos->hwndInsertAfter == HWND_TOP
+ ||pWinPos->hwndInsertAfter == HWND_TOPMOST
+ ||pWinPos->hwndInsertAfter == HWND_NOTOPMOST)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\traise to top\n");
+#endif
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+#if 1
+ else if (pWinPos->hwndInsertAfter == HWND_BOTTOM)
+ {
+ }
+ else
+ {
+ /* Check if this window is top of X windows. */
+ HWND hWndAbove = NULL;
+ DWORD dwCurrentProcessID = GetCurrentProcessId ();
+ DWORD dwWindowProcessID = 0;
+
+ for (hWndAbove = pWinPos->hwndInsertAfter;
+ hWndAbove != NULL;
+ hWndAbove = GetNextWindow (hWndAbove, GW_HWNDPREV))
+ {
+ /* Ignore other XWin process's window */
+ GetWindowThreadProcessId (hWndAbove, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp (hWndAbove, WIN_WINDOW_PROP)
+ && !IsWindowVisible (hWndAbove)
+ && !IsIconic (hWndAbove) ) /* ignore minimized windows */
+ break;
+ }
+ /* If this is top of X windows in Windows stack,
+ raise it in X stack. */
+ if (hWndAbove == NULL)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\traise to top\n");
+#endif
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+ }
+#endif
+ }
+
+ if (!(pWinPos->flags & SWP_NOSIZE)) {
+ if (IsIconic(hwnd)){
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tIconic -> MINIMIZED\n");
+#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_LOWER;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMMinimizeWindow,
+ pWin->drawable.id,
+ 0, 0, 0, 0);
+ } else if (IsZoomed(hwnd)){
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tZoomed -> MAXIMIZED\n");
+#endif
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMMaximizeWindow,
+ pWin->drawable.id,
+ 0, 0, 0, 0);
+ } else {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tnone -> RESTORED\n");
+#endif
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMRestoreWindow,
+ pWin->drawable.id,
+ 0, 0, 0, 0);
+ }
+ }
+ if (!g_fNoConfigureWindow ) {
+
+ if (!pRLWinPriv->fMovingOrSizing
+ /*&& (pWinPos->flags & SWP_SHOWWINDOW)*/) {
+ GetClientRect (hwnd, &rcClient);
+ MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
+
+ if (!(pWinPos->flags & SWP_NOMOVE)
+ &&!(pWinPos->flags & SWP_NOSIZE)) {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tmove & resize\n");
+#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
+ winMWExtWMMoveResizeXWindow (pWin,
+ rcClient.left - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN),
+ rcClient.right - rcClient.left
+ - wBorderWidth (pWin)*2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth (pWin)*2);
+ } else if (!(pWinPos->flags & SWP_NOMOVE)) {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tmove\n");
+#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
+ winMWExtWMMoveResizeXWindow (pWin,
+ rcClient.left - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN),
+ rcClient.right - rcClient.left
+ - wBorderWidth (pWin)*2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth (pWin)*2);
+ } else if (!(pWinPos->flags & SWP_NOMOVE)) {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tmove\n");
+#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
+ winMWExtWMMoveXWindow (pWin,
+ rcClient.left - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN));
+ } else if (!(pWinPos->flags & SWP_NOSIZE)) {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tresize\n");
+#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
+ winMWExtWMResizeXWindow (pWin,
+ rcClient.right - rcClient.left
+ - wBorderWidth (pWin)*2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth (pWin)*2);
+ }
+ }
+ }
+ }
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED - done.\n");
+#endif
+ return 0;
+
+ case WM_SIZE:
+ /* see dix/window.c */
+ /* FIXME: Maximize/Restore? */
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_SIZE - %d ms\n",
+ (unsigned int)GetTickCount ());
+#endif
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\t(%d, %d) %d\n", (short) LOWORD(lParam), (short) HIWORD(lParam), g_fNoConfigureWindow);
+#endif
+ if (g_fNoConfigureWindow) break;
+
+ /* Branch on type of resizing occurring */
+ switch (wParam)
+ {
+ case SIZE_MINIMIZED:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tSIZE_MINIMIZED\n");
+#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_LOWER;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMMinimizeWindow,
+ pWin->drawable.id,
+ 0, 0,
+ LOWORD(lParam), HIWORD(lParam));
+ break;
+
+ case SIZE_RESTORED:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tSIZE_RESTORED\n");
+#endif
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMRestoreWindow,
+ pWin->drawable.id,
+ 0, 0,
+ LOWORD(lParam), HIWORD(lParam));
+ break;
+
+ case SIZE_MAXIMIZED:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tSIZE_MAXIMIZED\n");
+#endif
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMMaximizeWindow,
+ pWin->drawable.id,
+ 0, 0,
+ LOWORD(lParam), HIWORD(lParam));
+ break;
+ }
+
+ /* Perform the resize and notify the X client */
+ if (!pRLWinPriv->fMovingOrSizing)
+ {
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
+ winMWExtWMResizeXWindow (pWin,
+ (short) LOWORD(lParam)
+ - wBorderWidth (pWin)*2,
+ (short) HIWORD(lParam)
+ - wBorderWidth (pWin)*2);
+ }
+ break;
+
+ case WM_ACTIVATEAPP:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_ACTIVATEAPP - %d ms\n",
+ (unsigned int)GetTickCount ());
+#endif
+ if (wParam)
+ {
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ }
+ else
+ {
+ }
+ winWindowsWMSendEvent(WindowsWMActivationNotify,
+ WindowsWMActivationNotifyMask,
+ 1,
+ WindowsWMIsActive,
+ pWin->drawable.id,
+ 0, 0,
+ 0, 0);
+ }
+ else
+ {
+ winWindowsWMSendEvent(WindowsWMActivationNotify,
+ WindowsWMActivationNotifyMask,
+ 1,
+ WindowsWMIsInactive,
+ pWin->drawable.id,
+ 0, 0,
+ 0, 0);
+ }
+ break;
+
+ case WM_SETCURSOR:
+ if (LOWORD(lParam) == HTCLIENT)
+ {
+ if (!g_fSoftwareCursor) SetCursor (pScreenPriv->cursor.handle);
+ return TRUE;
+ }
+ break;
+
+ case WM_ENTERSIZEMOVE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_ENTERSIZEMOVE - %d ms\n",
+ (unsigned int)GetTickCount ());
+#endif
+ pRLWinPriv->fMovingOrSizing = TRUE;
+ break;
+
+ case WM_EXITSIZEMOVE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_EXITSIZEMOVE - %d ms\n",
+ (unsigned int)GetTickCount ());
+#endif
+ pRLWinPriv->fMovingOrSizing = FALSE;
+
+ GetClientRect (hwnd, &rcClient);
+
+ MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
+
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
+ winMWExtWMMoveResizeXWindow (pWin,
+ rcClient.left - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN),
+ rcClient.right - rcClient.left
+ - wBorderWidth (pWin)*2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth (pWin)*2);
+ break;
+
+ case WM_MANAGE:
+ ErrorF ("winMWExtWMWindowProc - WM_MANAGE\n");
+ break;
+
+ case WM_UNMANAGE:
+ ErrorF ("winMWExtWMWindowProc - WM_UNMANAGE\n");
+ break;
+
+ default:
+ break;
+ }
+
+ return DefWindowProc (hwnd, message, wParam, lParam);
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winwindow.c b/nx-X11/programs/Xserver/hw/xwin/winwindow.c
new file mode 100644
index 000000000..be160196a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winwindow.c
@@ -0,0 +1,650 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Harold L Hunt II
+ * Kensuke Matsuzaki
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winwindow.c,v 1.9 2003/11/10 18:22:44 tsi Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * Prototypes for local functions
+ */
+
+static int
+winAddRgn (WindowPtr pWindow, pointer data);
+
+static
+void
+winUpdateRgnRootless (WindowPtr pWindow);
+
+#ifdef SHAPE
+static
+void
+winReshapeRootless (WindowPtr pWin);
+#endif
+
+
+#ifdef XWIN_NATIVEGDI
+/* See Porting Layer Definition - p. 37 */
+/* See mfb/mfbwindow.c - mfbCreateWindow() */
+
+Bool
+winCreateWindowNativeGDI (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGDEBUG
+ winTrace ("winCreateWindowNativeGDI (%p)\n", pWin);
+#endif
+
+ WIN_UNWRAP(CreateWindow);
+ fResult = (*pScreen->CreateWindow) (pWin);
+ WIN_WRAP(CreateWindow, winCreateWindowNativeGDI);
+
+ return fResult;
+}
+
+
+/* See Porting Layer Definition - p. 37 */
+/* See mfb/mfbwindow.c - mfbDestroyWindow() */
+
+Bool
+winDestroyWindowNativeGDI (WindowPtr pWin)
+{
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGDEBUG
+ winTrace ("winDestroyWindowNativeGDI (%p)\n", pWin);
+#endif
+
+ WIN_UNWRAP(DestroyWindow);
+ fResult = (*pScreen->DestroyWindow)(pWin);
+ WIN_WRAP(DestroyWindow, winDestroyWindowNativeGDI);
+
+ return fResult;
+}
+
+
+/* See Porting Layer Definition - p. 37 */
+/* See mfb/mfbwindow.c - mfbPositionWindow() */
+
+Bool
+winPositionWindowNativeGDI (WindowPtr pWin, int x, int y)
+{
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGDEBUG
+ winTrace ("winPositionWindowNativeGDI (%p)\n", pWin);
+#endif
+
+ WIN_UNWRAP(PositionWindow);
+ fResult = (*pScreen->PositionWindow)(pWin, x, y);
+ WIN_WRAP(PositionWindow, winPositionWindowNativeGDI);
+
+ return fResult;
+}
+
+
+/* See Porting Layer Definition - p. 39 */
+/* See mfb/mfbwindow.c - mfbCopyWindow() */
+
+void
+winCopyWindowNativeGDI (WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc)
+{
+ DDXPointPtr pptSrc;
+ DDXPointPtr ppt;
+ RegionPtr prgnDst;
+ BoxPtr pBox;
+ int dx, dy;
+ int i, nbox;
+ WindowPtr pwinRoot;
+ BoxPtr pBoxDst;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winScreenPriv(pScreen);
+
+#if 0
+ ErrorF ("winCopyWindow\n");
+#endif
+
+ /* Get a pointer to the root window */
+ pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
+
+ /* Create a region for the destination */
+ prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
+
+ /* Calculate the shift from the source to the destination */
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+
+ /* Translate the region from the destination to the source? */
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+ REGION_INTERSECT(pWin->drawable.pScreen, prgnDst, &pWin->borderClip,
+ prgnSrc);
+
+ /* Get a pointer to the first box in the region to be copied */
+ pBox = REGION_RECTS(prgnDst);
+
+ /* Get the number of boxes in the region */
+ nbox = REGION_NUM_RECTS(prgnDst);
+
+ /* Allocate source points for each box */
+ if(!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
+ return;
+
+ /* Set an iterator pointer */
+ ppt = pptSrc;
+
+ /* Calculate the source point of each box? */
+ for (i = nbox; --i >= 0; ppt++, pBox++)
+ {
+ ppt->x = pBox->x1 + dx;
+ ppt->y = pBox->y1 + dy;
+ }
+
+ /* Setup loop pointers again */
+ pBoxDst = REGION_RECTS(prgnDst);
+ ppt = pptSrc;
+
+#if 0
+ ErrorF ("winCopyWindow - x1\tx2\ty1\ty2\tx\ty\n");
+#endif
+
+ /* BitBlt each source to the destination point */
+ for (i = nbox; --i >= 0; pBoxDst++, ppt++)
+ {
+#if 0
+ ErrorF ("winCopyWindow - %d\t%d\t%d\t%d\t%d\t%d\n",
+ pBoxDst->x1, pBoxDst->x2, pBoxDst->y1, pBoxDst->y2,
+ ppt->x, ppt->y);
+#endif
+
+ BitBlt (pScreenPriv->hdcScreen,
+ pBoxDst->x1, pBoxDst->y1,
+ pBoxDst->x2 - pBoxDst->x1, pBoxDst->y2 - pBoxDst->y1,
+ pScreenPriv->hdcScreen,
+ ppt->x, ppt->y,
+ SRCCOPY);
+ }
+
+ /* Cleanup the regions, etc. */
+ DEALLOCATE_LOCAL(pptSrc);
+ REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
+}
+
+
+/* See Porting Layer Definition - p. 37 */
+/* See mfb/mfbwindow.c - mfbChangeWindowAttributes() */
+
+Bool
+winChangeWindowAttributesNativeGDI (WindowPtr pWin, unsigned long mask)
+{
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGDEBUG
+ winTrace ("winChangeWindowAttributesNativeGDI (%p)\n", pWin);
+#endif
+
+ WIN_UNWRAP(ChangeWindowAttributes);
+ fResult = (*pScreen->ChangeWindowAttributes)(pWin, mask);
+ WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesNativeGDI);
+
+ /*
+ * NOTE: We do not currently need to do anything here.
+ */
+
+ return fResult;
+}
+
+
+/* See Porting Layer Definition - p. 37
+ * Also referred to as UnrealizeWindow
+ */
+
+Bool
+winUnmapWindowNativeGDI (WindowPtr pWin)
+{
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGDEBUG
+ winTrace ("winUnmapWindowNativeGDI (%p)\n", pWin);
+#endif
+
+ WIN_UNWRAP(UnrealizeWindow);
+ fResult = (*pScreen->UnrealizeWindow)(pWin);
+ WIN_WRAP(UnrealizeWindow, winUnmapWindowNativeGDI);
+
+ return fResult;
+}
+
+
+/* See Porting Layer Definition - p. 37
+ * Also referred to as RealizeWindow
+ */
+
+Bool
+winMapWindowNativeGDI (WindowPtr pWin)
+{
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGDEBUG
+ winTrace ("winMapWindowNativeGDI (%p)\n", pWin);
+#endif
+
+ WIN_UNWRAP(RealizeWindow);
+ fResult = (*pScreen->RealizeWindow)(pWin);
+ WIN_WRAP(RealizeWindow, winMapWindowMultiWindow);
+
+ return fResult;
+
+}
+#endif
+
+
+/* See Porting Layer Definition - p. 37 */
+/* See mfb/mfbwindow.c - mfbCreateWindow() */
+
+Bool
+winCreateWindowRootless (WindowPtr pWin)
+{
+ Bool fResult = FALSE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGDEBUG
+ winTrace ("winCreateWindowRootless (%p)\n", pWin);
+#endif
+
+ WIN_UNWRAP(CreateWindow);
+ fResult = (*pScreen->CreateWindow) (pWin);
+ WIN_WRAP(CreateWindow, winCreateWindowRootless);
+
+ pWinPriv->hRgn = NULL;
+
+ return fResult;
+}
+
+
+/* See Porting Layer Definition - p. 37 */
+/* See mfb/mfbwindow.c - mfbDestroyWindow() */
+
+Bool
+winDestroyWindowRootless (WindowPtr pWin)
+{
+ Bool fResult = FALSE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGDEBUG
+ winTrace ("winDestroyWindowRootless (%p)\n", pWin);
+#endif
+
+ WIN_UNWRAP(DestroyWindow);
+ fResult = (*pScreen->DestroyWindow)(pWin);
+ WIN_WRAP(DestroyWindow, winDestroyWindowRootless);
+
+ if (pWinPriv->hRgn != NULL)
+ {
+ DeleteObject(pWinPriv->hRgn);
+ pWinPriv->hRgn = NULL;
+ }
+
+ winUpdateRgnRootless (pWin);
+
+ return fResult;
+}
+
+
+/* See Porting Layer Definition - p. 37 */
+/* See mfb/mfbwindow.c - mfbPositionWindow() */
+
+Bool
+winPositionWindowRootless (WindowPtr pWin, int x, int y)
+{
+ Bool fResult = FALSE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+
+#if CYGDEBUG
+ winTrace ("winPositionWindowRootless (%p)\n", pWin);
+#endif
+
+ WIN_UNWRAP(PositionWindow);
+ fResult = (*pScreen->PositionWindow)(pWin, x, y);
+ WIN_WRAP(PositionWindow, winPositionWindowRootless);
+
+ winUpdateRgnRootless (pWin);
+
+ return fResult;
+}
+
+
+/* See Porting Layer Definition - p. 37 */
+/* See mfb/mfbwindow.c - mfbChangeWindowAttributes() */
+
+Bool
+winChangeWindowAttributesRootless (WindowPtr pWin, unsigned long mask)
+{
+ Bool fResult = FALSE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGDEBUG
+ winTrace ("winChangeWindowAttributesRootless (%p)\n", pWin);
+#endif
+
+ WIN_UNWRAP(ChangeWindowAttributes);
+ fResult = (*pScreen->ChangeWindowAttributes)(pWin, mask);
+ WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesRootless);
+
+ winUpdateRgnRootless (pWin);
+
+ return fResult;
+}
+
+
+/* See Porting Layer Definition - p. 37
+ * Also referred to as UnrealizeWindow
+ */
+
+Bool
+winUnmapWindowRootless (WindowPtr pWin)
+{
+ Bool fResult = FALSE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGDEBUG
+ winTrace ("winUnmapWindowRootless (%p)\n", pWin);
+#endif
+
+ WIN_UNWRAP(UnrealizeWindow);
+ fResult = (*pScreen->UnrealizeWindow)(pWin);
+ WIN_WRAP(UnrealizeWindow, winUnmapWindowRootless);
+
+ if (pWinPriv->hRgn != NULL)
+ {
+ DeleteObject(pWinPriv->hRgn);
+ pWinPriv->hRgn = NULL;
+ }
+
+ winUpdateRgnRootless (pWin);
+
+ return fResult;
+}
+
+
+/* See Porting Layer Definition - p. 37
+ * Also referred to as RealizeWindow
+ */
+
+Bool
+winMapWindowRootless (WindowPtr pWin)
+{
+ Bool fResult = FALSE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGDEBUG
+ winTrace ("winMapWindowRootless (%p)\n", pWin);
+#endif
+
+ WIN_UNWRAP(RealizeWindow);
+ fResult = (*pScreen->RealizeWindow)(pWin);
+ WIN_WRAP(RealizeWindow, winMapWindowRootless);
+
+#ifdef SHAPE
+ winReshapeRootless (pWin);
+#endif
+
+ winUpdateRgnRootless (pWin);
+
+ return fResult;
+}
+
+
+#ifdef SHAPE
+void
+winSetShapeRootless (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+#if CYGDEBUG
+ winTrace ("winSetShapeRootless (%p)\n", pWin);
+#endif
+
+ WIN_UNWRAP(SetShape);
+ (*pScreen->SetShape)(pWin);
+ WIN_WRAP(SetShape, winSetShapeRootless);
+
+ winReshapeRootless (pWin);
+ winUpdateRgnRootless (pWin);
+
+ return;
+}
+#endif
+
+
+/*
+ * Local function for adding a region to the Windows window region
+ */
+
+static
+int
+winAddRgn (WindowPtr pWin, pointer data)
+{
+ int iX, iY, iWidth, iHeight, iBorder;
+ HRGN hRgn = *(HRGN*)data;
+ HRGN hRgnWin;
+ winWindowPriv(pWin);
+
+ /* If pWin is not Root */
+ if (pWin->parent != NULL)
+ {
+#if CYGDEBUG
+ winDebug ("winAddRgn ()\n");
+#endif
+ if (pWin->mapped)
+ {
+ iBorder = wBorderWidth (pWin);
+
+ iX = pWin->drawable.x - iBorder;
+ iY = pWin->drawable.y - iBorder;
+
+ iWidth = pWin->drawable.width + iBorder * 2;
+ iHeight = pWin->drawable.height + iBorder * 2;
+
+ hRgnWin = CreateRectRgn (0, 0, iWidth, iHeight);
+
+ if (hRgnWin == NULL)
+ {
+ ErrorF ("winAddRgn - CreateRectRgn () failed\n");
+ ErrorF (" Rect %d %d %d %d\n",
+ iX, iY, iX + iWidth, iY + iHeight);
+ }
+
+ if (pWinPriv->hRgn)
+ {
+ if (CombineRgn (hRgnWin, hRgnWin, pWinPriv->hRgn, RGN_AND)
+ == ERROR)
+ {
+ ErrorF ("winAddRgn - CombineRgn () failed\n");
+ }
+ }
+
+ OffsetRgn (hRgnWin, iX, iY);
+
+ if (CombineRgn (hRgn, hRgn, hRgnWin, RGN_OR) == ERROR)
+ {
+ ErrorF ("winAddRgn - CombineRgn () failed\n");
+ }
+
+ DeleteObject (hRgnWin);
+ }
+ return WT_DONTWALKCHILDREN;
+ }
+ else
+ {
+ return WT_WALKCHILDREN;
+ }
+}
+
+
+/*
+ * Local function to update the Windows window's region
+ */
+
+static
+void
+winUpdateRgnRootless (WindowPtr pWin)
+{
+ HRGN hRgn = CreateRectRgn (0, 0, 0, 0);
+
+ if (hRgn != NULL)
+ {
+ WalkTree (pWin->drawable.pScreen, winAddRgn, &hRgn);
+ SetWindowRgn (winGetScreenPriv(pWin->drawable.pScreen)->hwndScreen,
+ hRgn, TRUE);
+ }
+ else
+ {
+ ErrorF ("winUpdateRgnRootless - CreateRectRgn failed.\n");
+ }
+}
+
+
+#ifdef SHAPE
+static
+void
+winReshapeRootless (WindowPtr pWin)
+{
+ int nRects;
+ /* ScreenPtr pScreen = pWin->drawable.pScreen;*/
+ RegionRec rrNewShape;
+ BoxPtr pShape, pRects, pEnd;
+ HRGN hRgn, hRgnRect;
+ winWindowPriv(pWin);
+
+#if CYGDEBUG
+ winDebug ("winReshapeRootless ()\n");
+#endif
+
+ /* Bail if the window is the root window */
+ if (pWin->parent == NULL)
+ return;
+
+ /* Bail if the window is not top level */
+ if (pWin->parent->parent != NULL)
+ return;
+
+ /* Free any existing window region stored in the window privates */
+ if (pWinPriv->hRgn != NULL)
+ {
+ DeleteObject (pWinPriv->hRgn);
+ pWinPriv->hRgn = NULL;
+ }
+
+ /* Bail if the window has no bounding region defined */
+ if (!wBoundingShape (pWin))
+ return;
+
+ REGION_NULL(pScreen, &rrNewShape);
+ REGION_COPY(pScreen, &rrNewShape, wBoundingShape(pWin));
+ REGION_TRANSLATE(pScreen, &rrNewShape, pWin->borderWidth,
+ pWin->borderWidth);
+
+ nRects = REGION_NUM_RECTS(&rrNewShape);
+ pShape = REGION_RECTS(&rrNewShape);
+
+ if (nRects > 0)
+ {
+ /* Create initial empty Windows region */
+ hRgn = CreateRectRgn (0, 0, 0, 0);
+
+ /* Loop through all rectangles in the X region */
+ for (pRects = pShape, pEnd = pShape + nRects; pRects < pEnd; pRects++)
+ {
+ /* Create a Windows region for the X rectangle */
+ hRgnRect = CreateRectRgn (pRects->x1, pRects->y1,
+ pRects->x2, pRects->y2);
+ if (hRgnRect == NULL)
+ {
+ ErrorF("winReshapeRootless - CreateRectRgn() failed\n");
+ }
+
+ /* Merge the Windows region with the accumulated region */
+ if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR)
+ {
+ ErrorF("winReshapeRootless - CombineRgn() failed\n");
+ }
+
+ /* Delete the temporary Windows region */
+ DeleteObject (hRgnRect);
+ }
+
+ /* Save a handle to the composite region in the window privates */
+ pWinPriv->hRgn = hRgn;
+ }
+
+ REGION_UNINIT(pScreen, &rrNewShape);
+
+ return;
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/winwindow.h b/nx-X11/programs/Xserver/hw/xwin/winwindow.h
new file mode 100644
index 000000000..d0499bcbb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winwindow.h
@@ -0,0 +1,151 @@
+#if !defined(_WINWINDOW_H_)
+#define _WINWINDOW_H_
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Kensuke Matsuzaki
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winwindow.h,v 1.3 2003/10/02 13:30:11 eich Exp $ */
+
+#ifndef NO
+#define NO 0
+#endif
+#ifndef YES
+#define YES 1
+#endif
+
+/* Constant strings */
+#ifndef PROJECT_NAME
+# define PROJECT_NAME "Cygwin/X"
+#endif
+#define WINDOW_CLASS "cygwin/x"
+#define WINDOW_TITLE PROJECT_NAME " - %s:%d"
+#define WINDOW_TITLE_XDMCP PROJECT_NAME " - %s"
+#define WIN_SCR_PROP "cyg_screen_prop rl"
+#define WINDOW_CLASS_X "cygwin/x X rl"
+#define WINDOW_TITLE_X PROJECT_NAME " X"
+#define WIN_WINDOW_PROP "cyg_window_prop_rl"
+#ifdef HAS_DEVWINDOWS
+# define WIN_MSG_QUEUE_FNAME "/dev/windows"
+#endif
+#define WIN_WID_PROP "cyg_wid_prop_rl"
+#define WIN_NEEDMANAGE_PROP "cyg_override_redirect_prop_rl"
+#ifndef CYGMULTIWINDOW_DEBUG
+#define CYGMULTIWINDOW_DEBUG NO
+#endif
+#ifndef CYGWINDOWING_DEBUG
+#define CYGWINDOWING_DEBUG NO
+#endif
+
+typedef struct _winPrivScreenRec *winPrivScreenPtr;
+
+
+/*
+ * Window privates
+ */
+
+typedef struct
+{
+ DWORD dwDummy;
+ HRGN hRgn;
+ HWND hWnd;
+ winPrivScreenPtr pScreenPriv;
+ Bool fXKilled;
+
+ /* Privates used by primary fb DirectDraw server */
+ LPDDSURFACEDESC pddsdPrimary;
+
+ /* Privates used by shadow fb DirectDraw Nonlocking server */
+ LPDIRECTDRAWSURFACE4 pddsPrimary4;
+
+ /* Privates used by both shadow fb DirectDraw servers */
+ LPDIRECTDRAWCLIPPER pddcPrimary;
+} winPrivWinRec, *winPrivWinPtr;
+
+#ifdef XWIN_MULTIWINDOW
+typedef struct _winWMMessageRec{
+ DWORD dwID;
+ DWORD msg;
+ int iWindow;
+ HWND hwndWindow;
+ int iX, iY;
+ int iWidth, iHeight;
+} winWMMessageRec, *winWMMessagePtr;
+
+
+/*
+ * winmultiwindowwm.c
+ */
+
+#define WM_WM_MOVE (WM_USER + 1)
+#define WM_WM_SIZE (WM_USER + 2)
+#define WM_WM_RAISE (WM_USER + 3)
+#define WM_WM_LOWER (WM_USER + 4)
+#define WM_WM_MAP (WM_USER + 5)
+#define WM_WM_UNMAP (WM_USER + 6)
+#define WM_WM_KILL (WM_USER + 7)
+#define WM_WM_ACTIVATE (WM_USER + 8)
+#define WM_WM_NAME_EVENT (WM_USER + 9)
+#define WM_WM_HINTS_EVENT (WM_USER + 10)
+#define WM_WM_CHANGE_STATE (WM_USER + 11)
+#define WM_MANAGE (WM_USER + 100)
+#define WM_UNMANAGE (WM_USER + 102)
+
+void
+winSendMessageToWM (void *pWMInfo, winWMMessagePtr msg);
+
+Bool
+winInitWM (void **ppWMInfo,
+ pthread_t *ptWMProc,
+ pthread_t *ptXMsgProc,
+ pthread_mutex_t *ppmServerStarted,
+ int dwScreen,
+ HWND hwndScreen,
+ BOOL allowOtherWM);
+
+void
+winDeinitMultiWindowWM (void);
+
+void
+winMinimizeWindow (Window id);
+
+
+/*
+ * winmultiwindowicons.c
+ */
+
+void
+winUpdateIcon (Window id);
+
+void
+winInitGlobalIcons (void);
+
+void
+winDestroyIcon(HICON hIcon);
+
+#endif /* XWIN_MULTIWINDOW */
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/winwindowswm.c b/nx-X11/programs/Xserver/hw/xwin/winwindowswm.c
new file mode 100755
index 000000000..81a161041
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winwindowswm.c
@@ -0,0 +1,666 @@
+/* WindowsWM extension is based on AppleWM extension */
+/**************************************************************************
+
+Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
+Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#include "swaprep.h"
+#define _WINDOWSWM_SERVER_
+#include "windowswmstr.h"
+
+static int WMErrorBase;
+
+static DISPATCH_PROC(ProcWindowsWMDispatch);
+static DISPATCH_PROC(SProcWindowsWMDispatch);
+
+static void WindowsWMResetProc(ExtensionEntry* extEntry);
+
+static unsigned char WMReqCode = 0;
+static int WMEventBase = 0;
+
+static RESTYPE ClientType, EventType; /* resource types for event masks */
+static XID eventResource;
+
+/* Currently selected events */
+static unsigned int eventMask = 0;
+
+static int WMFreeClient (pointer data, XID id);
+static int WMFreeEvents (pointer data, XID id);
+static void SNotifyEvent(xWindowsWMNotifyEvent *from, xWindowsWMNotifyEvent *to);
+
+typedef struct _WMEvent *WMEventPtr;
+typedef struct _WMEvent {
+ WMEventPtr next;
+ ClientPtr client;
+ XID clientResource;
+ unsigned int mask;
+} WMEventRec;
+
+static inline BoxRec
+make_box (int x, int y, int w, int h)
+{
+ BoxRec r;
+ r.x1 = x;
+ r.y1 = y;
+ r.x2 = x + w;
+ r.y2 = y + h;
+ return r;
+}
+
+void
+winWindowsWMExtensionInit ()
+{
+ ExtensionEntry* extEntry;
+
+ ClientType = CreateNewResourceType(WMFreeClient);
+ EventType = CreateNewResourceType(WMFreeEvents);
+ eventResource = FakeClientID(0);
+
+ if (ClientType && EventType &&
+ (extEntry = AddExtension(WINDOWSWMNAME,
+ WindowsWMNumberEvents,
+ WindowsWMNumberErrors,
+ ProcWindowsWMDispatch,
+ SProcWindowsWMDispatch,
+ WindowsWMResetProc,
+ StandardMinorOpcode)))
+ {
+ WMReqCode = (unsigned char)extEntry->base;
+ WMErrorBase = extEntry->errorBase;
+ WMEventBase = extEntry->eventBase;
+ EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent;
+ }
+}
+
+/*ARGSUSED*/
+static void
+WindowsWMResetProc (ExtensionEntry* extEntry)
+{
+}
+
+static int
+ProcWindowsWMQueryVersion(register ClientPtr client)
+{
+ xWindowsWMQueryVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xWindowsWMQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = WINDOWS_WM_MAJOR_VERSION;
+ rep.minorVersion = WINDOWS_WM_MINOR_VERSION;
+ rep.patchVersion = WINDOWS_WM_PATCH_VERSION;
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ }
+ WriteToClient(client, sizeof(xWindowsWMQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+
+/* events */
+
+static inline void
+updateEventMask (WMEventPtr *pHead)
+{
+ WMEventPtr pCur;
+
+ eventMask = 0;
+ for (pCur = *pHead; pCur != NULL; pCur = pCur->next)
+ eventMask |= pCur->mask;
+}
+
+/*ARGSUSED*/
+static int
+WMFreeClient (pointer data, XID id)
+{
+ WMEventPtr pEvent;
+ WMEventPtr *pHead, pCur, pPrev;
+
+ pEvent = (WMEventPtr) data;
+ pHead = (WMEventPtr *) LookupIDByType(eventResource, EventType);
+ if (pHead)
+ {
+ pPrev = 0;
+ for (pCur = *pHead; pCur && pCur != pEvent; pCur=pCur->next)
+ pPrev = pCur;
+ if (pCur)
+ {
+ if (pPrev)
+ pPrev->next = pEvent->next;
+ else
+ *pHead = pEvent->next;
+ }
+ updateEventMask (pHead);
+ }
+ xfree ((pointer) pEvent);
+ return 1;
+}
+
+/*ARGSUSED*/
+static int
+WMFreeEvents (pointer data, XID id)
+{
+ WMEventPtr *pHead, pCur, pNext;
+
+ pHead = (WMEventPtr *) data;
+ for (pCur = *pHead; pCur; pCur = pNext)
+ {
+ pNext = pCur->next;
+ FreeResource (pCur->clientResource, ClientType);
+ xfree ((pointer) pCur);
+ }
+ xfree ((pointer) pHead);
+ eventMask = 0;
+ return 1;
+}
+
+static int
+ProcWindowsWMSelectInput (register ClientPtr client)
+{
+ REQUEST(xWindowsWMSelectInputReq);
+ WMEventPtr pEvent, pNewEvent, *pHead;
+ XID clientResource;
+
+ REQUEST_SIZE_MATCH (xWindowsWMSelectInputReq);
+ pHead = (WMEventPtr *)SecurityLookupIDByType(client, eventResource,
+ EventType, SecurityWriteAccess);
+ if (stuff->mask != 0)
+ {
+ if (pHead)
+ {
+ /* check for existing entry. */
+ for (pEvent = *pHead; pEvent; pEvent = pEvent->next)
+ {
+ if (pEvent->client == client)
+ {
+ pEvent->mask = stuff->mask;
+ updateEventMask (pHead);
+ return Success;
+ }
+ }
+ }
+
+ /* build the entry */
+ pNewEvent = (WMEventPtr) xalloc (sizeof (WMEventRec));
+ if (!pNewEvent)
+ return BadAlloc;
+ pNewEvent->next = 0;
+ pNewEvent->client = client;
+ pNewEvent->mask = stuff->mask;
+ /*
+ * add a resource that will be deleted when
+ * the client goes away
+ */
+ clientResource = FakeClientID (client->index);
+ pNewEvent->clientResource = clientResource;
+ if (!AddResource (clientResource, ClientType, (pointer)pNewEvent))
+ return BadAlloc;
+ /*
+ * create a resource to contain a pointer to the list
+ * of clients selecting input. This must be indirect as
+ * the list may be arbitrarily rearranged which cannot be
+ * done through the resource database.
+ */
+ if (!pHead)
+ {
+ pHead = (WMEventPtr *) xalloc (sizeof (WMEventPtr));
+ if (!pHead ||
+ !AddResource (eventResource, EventType, (pointer)pHead))
+ {
+ FreeResource (clientResource, RT_NONE);
+ return BadAlloc;
+ }
+ *pHead = 0;
+ }
+ pNewEvent->next = *pHead;
+ *pHead = pNewEvent;
+ updateEventMask (pHead);
+ }
+ else if (stuff->mask == 0)
+ {
+ /* delete the interest */
+ if (pHead)
+ {
+ pNewEvent = 0;
+ for (pEvent = *pHead; pEvent; pEvent = pEvent->next)
+ {
+ if (pEvent->client == client)
+ break;
+ pNewEvent = pEvent;
+ }
+ if (pEvent)
+ {
+ FreeResource (pEvent->clientResource, ClientType);
+ if (pNewEvent)
+ pNewEvent->next = pEvent->next;
+ else
+ *pHead = pEvent->next;
+ xfree (pEvent);
+ updateEventMask (pHead);
+ }
+ }
+ }
+ else
+ {
+ client->errorValue = stuff->mask;
+ return BadValue;
+ }
+ return Success;
+}
+
+/*
+ * deliver the event
+ */
+
+void
+winWindowsWMSendEvent (int type, unsigned int mask, int which, int arg,
+ Window window, int x, int y, int w, int h)
+{
+ WMEventPtr *pHead, pEvent;
+ ClientPtr client;
+ xWindowsWMNotifyEvent se;
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winWindowsWMSendEvent %d %d %d %d, %d %d - %d %d\n",
+ type, mask, which, arg, x, y, w, h);
+#endif
+ pHead = (WMEventPtr *) LookupIDByType(eventResource, EventType);
+ if (!pHead)
+ return;
+ for (pEvent = *pHead; pEvent; pEvent = pEvent->next)
+ {
+ client = pEvent->client;
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winWindowsWMSendEvent - x%08x\n", (int) client);
+#endif
+ if ((pEvent->mask & mask) == 0
+ || client == serverClient || client->clientGone)
+ {
+ continue;
+ }
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("winWindowsWMSendEvent - send\n");
+#endif
+ se.type = type + WMEventBase;
+ se.kind = which;
+ se.window = window;
+ se.arg = arg;
+ se.x = x;
+ se.y = y;
+ se.w = w;
+ se.h = h;
+ se.sequenceNumber = client->sequence;
+ se.time = currentTime.milliseconds;
+ WriteEventsToClient (client, 1, (xEvent *) &se);
+ }
+}
+
+/* Safe to call from any thread. */
+unsigned int
+WindowsWMSelectedEvents (void)
+{
+ return eventMask;
+}
+
+
+/* general utility functions */
+
+static int
+ProcWindowsWMDisableUpdate (register ClientPtr client)
+{
+ REQUEST_SIZE_MATCH(xWindowsWMDisableUpdateReq);
+
+ //winDisableUpdate();
+
+ return (client->noClientException);
+}
+
+static int
+ProcWindowsWMReenableUpdate (register ClientPtr client)
+{
+ REQUEST_SIZE_MATCH(xWindowsWMReenableUpdateReq);
+
+ //winEnableUpdate();
+
+ return (client->noClientException);
+}
+
+
+/* window functions */
+
+static int
+ProcWindowsWMSetFrontProcess (register ClientPtr client)
+{
+ REQUEST_SIZE_MATCH(xWindowsWMSetFrontProcessReq);
+
+ //QuartzMessageMainThread(kWindowsSetFrontProcess, NULL, 0);
+
+ return (client->noClientException);
+}
+
+
+/* frame functions */
+
+static int
+ProcWindowsWMFrameGetRect (register ClientPtr client)
+{
+ xWindowsWMFrameGetRectReply rep;
+ BoxRec ir;
+ RECT rcNew;
+ REQUEST(xWindowsWMFrameGetRectReq);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("ProcWindowsWMFrameGetRect %d %d\n",
+ (sizeof(xWindowsWMFrameGetRectReq) >> 2), (int) client->req_len);
+#endif
+
+ REQUEST_SIZE_MATCH(xWindowsWMFrameGetRectReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
+
+ if (stuff->frame_rect != 0)
+ {
+ ErrorF ("ProcWindowsWMFrameGetRect - stuff->frame_rect != 0\n");
+ return BadValue;
+ }
+
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect (&rcNew, stuff->ix, stuff->iy,
+ stuff->ix + stuff->iw, stuff->iy + stuff->ih);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("ProcWindowsWMFrameGetRect - %d %d %d %d\n",
+ stuff->ix, stuff->iy, stuff->ix + stuff->iw, stuff->iy + stuff->ih);
+#endif
+
+ /*
+ * Calculate the required size of the Windows window rectangle,
+ * given the size of the Windows window client area.
+ */
+ AdjustWindowRectEx (&rcNew, stuff->frame_style, FALSE, stuff->frame_style_ex);
+ rep.x = rcNew.left;
+ rep.y = rcNew.top;
+ rep.w = rcNew.right - rcNew.left;
+ rep.h = rcNew.bottom - rcNew.top;
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("ProcWindowsWMFrameGetRect - %d %d %d %d\n",
+ rep.x, rep.y, rep.w, rep.h);
+#endif
+
+ WriteToClient(client, sizeof(xWindowsWMFrameGetRectReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+
+static int
+ProcWindowsWMFrameDraw (register ClientPtr client)
+{
+ REQUEST(xWindowsWMFrameDrawReq);
+ WindowPtr pWin;
+ win32RootlessWindowPtr pRLWinPriv;
+ RECT rcNew;
+ int nCmdShow;
+ RegionRec newShape;
+ ScreenPtr pScreen;
+
+ REQUEST_SIZE_MATCH (xWindowsWMFrameDrawReq);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("ProcWindowsWMFrameDraw\n");
+#endif
+ if (!(pWin = SecurityLookupWindow((Drawable)stuff->window,
+ client, SecurityReadAccess)))
+ {
+ return BadValue;
+ }
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("ProcWindowsWMFrameDraw - Window found\n");
+#endif
+
+ pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, TRUE);
+ if (pRLWinPriv == 0) return BadWindow;
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("ProcWindowsWMFrameDraw - HWND 0x%08x 0x%08x 0x%08x\n",
+ (int) pRLWinPriv->hWnd, (int) stuff->frame_style,
+ (int) stuff->frame_style_ex);
+ ErrorF ("ProcWindowsWMFrameDraw - %d %d %d %d\n",
+ stuff->ix, stuff->iy, stuff->iw, stuff->ih);
+#endif
+
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect (&rcNew, stuff->ix, stuff->iy,
+ stuff->ix + stuff->iw, stuff->iy + stuff->ih);
+
+ /*
+ * Calculate the required size of the Windows window rectangle,
+ * given the size of the Windows window client area.
+ */
+ AdjustWindowRectEx (&rcNew, stuff->frame_style, FALSE, stuff->frame_style_ex);
+
+ /* Set the window extended style flags */
+ if (!SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, stuff->frame_style_ex))
+ {
+ return BadValue;
+ }
+
+ /* Set the window standard style flags */
+ if (!SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE, stuff->frame_style))
+ {
+ return BadValue;
+ }
+
+ /* Flush the window style */
+ if (!SetWindowPos (pRLWinPriv->hWnd, NULL,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE))
+ {
+ return BadValue;
+ }
+ if (!IsWindowVisible(pRLWinPriv->hWnd))
+ nCmdShow = SW_HIDE;
+ else
+ nCmdShow = SW_SHOWNA;
+
+ ShowWindow (pRLWinPriv->hWnd, nCmdShow);
+
+ winMWExtWMUpdateIcon (pWin->drawable.id);
+
+ if (wBoundingShape(pWin) != NULL)
+ {
+ pScreen = pWin->drawable.pScreen;
+ /* wBoundingShape is relative to *inner* origin of window.
+ Translate by borderWidth to get the outside-relative position. */
+
+ REGION_NULL(pScreen, &newShape);
+ REGION_COPY(pScreen, &newShape, wBoundingShape(pWin));
+ REGION_TRANSLATE(pScreen, &newShape, pWin->borderWidth, pWin->borderWidth);
+ winMWExtWMReshapeFrame (pRLWinPriv, &newShape);
+ REGION_UNINIT(pScreen, &newShape);
+ }
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("ProcWindowsWMFrameDraw - done\n");
+#endif
+
+ return (client->noClientException);
+}
+
+static int
+ProcWindowsWMFrameSetTitle(
+ register ClientPtr client
+ )
+{
+ unsigned int title_length, title_max;
+ unsigned char *title_bytes;
+ REQUEST(xWindowsWMFrameSetTitleReq);
+ WindowPtr pWin;
+ win32RootlessWindowPtr pRLWinPriv;
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("ProcWindowsWMFrameSetTitle\n");
+#endif
+
+ REQUEST_AT_LEAST_SIZE(xWindowsWMFrameSetTitleReq);
+
+ if (!(pWin = SecurityLookupWindow((Drawable)stuff->window,
+ client, SecurityReadAccess)))
+ {
+ return BadValue;
+ }
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("ProcWindowsWMFrameSetTitle - Window found\n");
+#endif
+
+ title_length = stuff->title_length;
+ title_max = (stuff->length << 2) - sizeof(xWindowsWMFrameSetTitleReq);
+
+ if (title_max < title_length)
+ return BadValue;
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("ProcWindowsWMFrameSetTitle - length is valid\n");
+#endif
+
+ title_bytes = malloc (title_length+1);
+ strncpy (title_bytes, (unsigned char *) &stuff[1], title_length);
+ title_bytes[title_length] = '\0';
+
+ pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
+
+ if (pRLWinPriv == 0)
+ {
+ free (title_bytes);
+ return BadWindow;
+ }
+
+ /* Flush the window style */
+ SetWindowText (pRLWinPriv->hWnd, title_bytes);
+
+ free (title_bytes);
+
+#if CYGMULTIWINDOW_DEBUG
+ ErrorF ("ProcWindowsWMFrameSetTitle - done\n");
+#endif
+
+ return (client->noClientException);
+}
+
+
+/* dispatch */
+
+static int
+ProcWindowsWMDispatch (register ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_WindowsWMQueryVersion:
+ return ProcWindowsWMQueryVersion(client);
+ }
+
+ if (!LocalClient(client))
+ return WMErrorBase + WindowsWMClientNotLocal;
+
+ switch (stuff->data)
+ {
+ case X_WindowsWMSelectInput:
+ return ProcWindowsWMSelectInput(client);
+ case X_WindowsWMDisableUpdate:
+ return ProcWindowsWMDisableUpdate(client);
+ case X_WindowsWMReenableUpdate:
+ return ProcWindowsWMReenableUpdate(client);
+ case X_WindowsWMSetFrontProcess:
+ return ProcWindowsWMSetFrontProcess(client);
+ case X_WindowsWMFrameGetRect:
+ return ProcWindowsWMFrameGetRect(client);
+ case X_WindowsWMFrameDraw:
+ return ProcWindowsWMFrameDraw(client);
+ case X_WindowsWMFrameSetTitle:
+ return ProcWindowsWMFrameSetTitle(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static void
+SNotifyEvent (xWindowsWMNotifyEvent *from, xWindowsWMNotifyEvent *to)
+{
+ to->type = from->type;
+ to->kind = from->kind;
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswapl (from->window, to->window);
+ cpswapl (from->time, to->time);
+ cpswapl (from->arg, to->arg);
+}
+
+static int
+SProcWindowsWMQueryVersion (register ClientPtr client)
+{
+ register int n;
+ REQUEST(xWindowsWMQueryVersionReq);
+ swaps(&stuff->length, n);
+ return ProcWindowsWMQueryVersion(client);
+}
+
+static int
+SProcWindowsWMDispatch (register ClientPtr client)
+{
+ REQUEST(xReq);
+
+ /* It is bound to be non-local when there is byte swapping */
+ if (!LocalClient(client))
+ return WMErrorBase + WindowsWMClientNotLocal;
+
+ /* only local clients are allowed WM access */
+ switch (stuff->data)
+ {
+ case X_WindowsWMQueryVersion:
+ return SProcWindowsWMQueryVersion(client);
+ default:
+ return BadRequest;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/winwndproc.c b/nx-X11/programs/Xserver/hw/xwin/winwndproc.c
new file mode 100644
index 000000000..0864fc638
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/winwndproc.c
@@ -0,0 +1,1273 @@
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ * MATSUZAKI Kensuke
+ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winwndproc.c,v 1.23 2002/10/17 08:18:25 alanh Exp $ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include <commctrl.h>
+#include "winprefs.h"
+#include "winconfig.h"
+#include "winmsg.h"
+
+#ifdef XKB
+extern BOOL winCheckKeyPressed(WPARAM wParam, LPARAM lParam);
+#endif
+extern void winFixShiftKeys (int iScanCode);
+
+
+/*
+ * Global variables
+ */
+
+Bool g_fCursor = TRUE;
+
+
+/*
+ * References to external symbols
+ */
+
+extern Bool g_fClipboard;
+extern HWND g_hDlgDepthChange;
+extern Bool g_fKeyboardHookLL;
+extern HWND g_hwndKeyboardFocus;
+extern Bool g_fSoftwareCursor;
+extern DWORD g_dwCurrentThreadID;
+
+
+/*
+ * Called by winWakeupHandler
+ * Processes current Windows message
+ */
+
+LRESULT CALLBACK
+winWindowProc (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ static winPrivScreenPtr s_pScreenPriv = NULL;
+ static winScreenInfo *s_pScreenInfo = NULL;
+ static ScreenPtr s_pScreen = NULL;
+ static HWND s_hwndLastPrivates = NULL;
+ static HINSTANCE s_hInstance;
+ static Bool s_fTracking = FALSE;
+ static unsigned long s_ulServerGeneration = 0;
+ static UINT s_uTaskbarRestart = 0;
+ int iScanCode;
+ int i;
+
+#if CYGDEBUG
+ winDebugWin32Message("winWindowProc", hwnd, message, wParam, lParam);
+#endif
+
+ /* Watch for server regeneration */
+ if (g_ulServerGeneration != s_ulServerGeneration)
+ {
+ /* Store new server generation */
+ s_ulServerGeneration = g_ulServerGeneration;
+ }
+
+ /* Only retrieve new privates pointers if window handle is null or changed */
+ if ((s_pScreenPriv == NULL || hwnd != s_hwndLastPrivates)
+ && (s_pScreenPriv = GetProp (hwnd, WIN_SCR_PROP)) != NULL)
+ {
+#if CYGDEBUG
+ winDebug ("winWindowProc - Setting privates handle\n");
+#endif
+ s_pScreenInfo = s_pScreenPriv->pScreenInfo;
+ s_pScreen = s_pScreenInfo->pScreen;
+ s_hwndLastPrivates = hwnd;
+ }
+ else if (s_pScreenPriv == NULL)
+ {
+ /* For safety, handle case that should never happen */
+ s_pScreenInfo = NULL;
+ s_pScreen = NULL;
+ s_hwndLastPrivates = NULL;
+ }
+
+ /* Branch on message type */
+ switch (message)
+ {
+ case WM_TRAYICON:
+ return winHandleIconMessage (hwnd, message, wParam, lParam,
+ s_pScreenPriv);
+
+ case WM_CREATE:
+#if CYGDEBUG
+ winDebug ("winWindowProc - WM_CREATE\n");
+#endif
+
+ /*
+ * Add a property to our display window that references
+ * this screens' privates.
+ *
+ * This allows the window procedure to refer to the
+ * appropriate window DC and shadow DC for the window that
+ * it is processing. We use this to repaint exposed
+ * areas of our display window.
+ */
+ s_pScreenPriv = ((LPCREATESTRUCT) lParam)->lpCreateParams;
+ s_hInstance = ((LPCREATESTRUCT) lParam)->hInstance;
+ s_pScreenInfo = s_pScreenPriv->pScreenInfo;
+ s_pScreen = s_pScreenInfo->pScreen;
+ s_hwndLastPrivates = hwnd;
+ s_uTaskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated"));
+ SetProp (hwnd, WIN_SCR_PROP, s_pScreenPriv);
+
+ /* Setup tray icon */
+ if (!s_pScreenInfo->fNoTrayIcon)
+ {
+ /*
+ * NOTE: The WM_CREATE message is processed before CreateWindowEx
+ * returns, so s_pScreenPriv->hwndScreen is invalid at this point.
+ * We go ahead and copy our hwnd parameter over top of the screen
+ * privates hwndScreen so that we have a valid value for
+ * that member. Otherwise, the tray icon will disappear
+ * the first time you move the mouse over top of it.
+ */
+
+ s_pScreenPriv->hwndScreen = hwnd;
+
+ winInitNotifyIcon (s_pScreenPriv);
+ }
+ return 0;
+
+ case WM_DISPLAYCHANGE:
+ /* We cannot handle a display mode change during initialization */
+ if (s_pScreenInfo == NULL)
+ FatalError ("winWindowProc - WM_DISPLAYCHANGE - The display "
+ "mode changed while we were intializing. This is "
+ "very bad and unexpected. Exiting.\n");
+
+ /*
+ * We do not care about display changes with
+ * fullscreen DirectDraw engines, because those engines set
+ * their own mode when they become active.
+ */
+ if (s_pScreenInfo->fFullScreen
+ && (s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
+ || s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
+#ifdef XWIN_PRIMARYFB
+ || s_pScreenInfo->dwEngine == WIN_SERVER_PRIMARY_DD
+#endif
+ ))
+ {
+ /*
+ * Store the new display dimensions and depth.
+ * We do this here for future compatibility in case we
+ * ever allow switching from fullscreen to windowed mode.
+ */
+ s_pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXSCREEN);
+ s_pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYSCREEN);
+ s_pScreenPriv->dwLastWindowsBitsPixel
+ = GetDeviceCaps (s_pScreenPriv->hdcScreen, BITSPIXEL);
+ break;
+ }
+
+ ErrorF ("winWindowProc - WM_DISPLAYCHANGE - orig bpp: %d, last bpp: %d, "
+ "new bpp: %d\n",
+ (int) s_pScreenInfo->dwBPP,
+ (int) s_pScreenPriv->dwLastWindowsBitsPixel,
+ wParam);
+
+ ErrorF ("winWindowProc - WM_DISPLAYCHANGE - new width: %d "
+ "new height: %d\n",
+ LOWORD (lParam), HIWORD (lParam));
+
+ /*
+ * TrueColor --> TrueColor depth changes are disruptive for:
+ * Windowed:
+ * Shadow DirectDraw
+ * Shadow DirectDraw Non-Locking
+ * Primary DirectDraw
+ *
+ * TrueColor --> TrueColor depth changes are non-optimal for:
+ * Windowed:
+ * Shadow GDI
+ *
+ * FullScreen:
+ * Shadow GDI
+ *
+ * TrueColor --> PseudoColor or vice versa are disruptive for:
+ * Windowed:
+ * Shadow DirectDraw
+ * Shadow DirectDraw Non-Locking
+ * Primary DirectDraw
+ * Shadow GDI
+ */
+
+ /*
+ * Check for a disruptive change in depth.
+ * We can only display a message for a disruptive depth change,
+ * we cannot do anything to correct the situation.
+ */
+ if ((s_pScreenInfo->dwBPP != wParam)
+ && (s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
+ || s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
+#ifdef XWIN_PRIMARYFB
+ || s_pScreenInfo->dwEngine == WIN_SERVER_PRIMARY_DD
+#endif
+ ))
+ {
+ /* Cannot display the visual until the depth is restored */
+ ErrorF ("winWindowProc - Disruptive change in depth\n");
+
+ /* Display Exit dialog */
+ winDisplayDepthChangeDialog (s_pScreenPriv);
+
+ /* Flag that we have an invalid screen depth */
+ s_pScreenPriv->fBadDepth = TRUE;
+
+ /* Minimize the display window */
+ ShowWindow (hwnd, SW_MINIMIZE);
+ }
+ else
+ {
+ /* Flag that we have a valid screen depth */
+ s_pScreenPriv->fBadDepth = FALSE;
+ }
+
+ /*
+ * Check for a change in display dimensions.
+ * We can simply recreate the same-sized primary surface when
+ * the display dimensions change.
+ */
+ if (s_pScreenPriv->dwLastWindowsWidth != LOWORD (lParam)
+ || s_pScreenPriv->dwLastWindowsHeight != HIWORD (lParam))
+ {
+ /*
+ * NOTE: The non-DirectDraw engines set the ReleasePrimarySurface
+ * and CreatePrimarySurface function pointers to point
+ * to the no operation function, NoopDDA. This allows us
+ * to blindly call these functions, even if they are not
+ * relevant to the current engine (e.g., Shadow GDI).
+ */
+
+#if CYGDEBUG
+ winDebug ("winWindowProc - WM_DISPLAYCHANGE - Dimensions changed\n");
+#endif
+
+ /* Release the old primary surface */
+ (*s_pScreenPriv->pwinReleasePrimarySurface) (s_pScreen);
+
+#if CYGDEBUG
+ winDebug ("winWindowProc - WM_DISPLAYCHANGE - Released "
+ "primary surface\n");
+#endif
+
+ /* Create the new primary surface */
+ (*s_pScreenPriv->pwinCreatePrimarySurface) (s_pScreen);
+
+#if CYGDEBUG
+ winDebug ("winWindowProc - WM_DISPLAYCHANGE - Recreated "
+ "primary surface\n");
+#endif
+
+#if 0
+ /* Multi-Window mode uses RandR for resizes */
+ if (s_pScreenInfo->fMultiWindow)
+ {
+ RRSetScreenConfig ();
+ }
+#endif
+ }
+ else
+ {
+#if CYGDEBUG
+ winDebug ("winWindowProc - WM_DISPLAYCHANGE - Dimensions did not "
+ "change\n");
+#endif
+ }
+
+ /* Store the new display dimensions and depth */
+ if (s_pScreenInfo->fMultipleMonitors)
+ {
+ s_pScreenPriv->dwLastWindowsWidth
+ = GetSystemMetrics (SM_CXVIRTUALSCREEN);
+ s_pScreenPriv->dwLastWindowsHeight
+ = GetSystemMetrics (SM_CYVIRTUALSCREEN);
+ }
+ else
+ {
+ s_pScreenPriv->dwLastWindowsWidth
+ = GetSystemMetrics (SM_CXSCREEN);
+ s_pScreenPriv->dwLastWindowsHeight
+ = GetSystemMetrics (SM_CYSCREEN);
+ }
+ s_pScreenPriv->dwLastWindowsBitsPixel
+ = GetDeviceCaps (s_pScreenPriv->hdcScreen, BITSPIXEL);
+ break;
+
+ case WM_SIZE:
+ {
+ SCROLLINFO si;
+ RECT rcWindow;
+ int iWidth, iHeight;
+
+#if CYGDEBUG
+ winDebug ("winWindowProc - WM_SIZE\n");
+#endif
+
+ /* Break if we do not use scrollbars */
+ if (!s_pScreenInfo->fScrollbars
+ || !s_pScreenInfo->fDecoration
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ || s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOW
+ || s_pScreenInfo->fMultiWindow
+#endif
+ || s_pScreenInfo->fFullScreen)
+ break;
+
+ /* No need to resize if we get minimized */
+ if (wParam == SIZE_MINIMIZED)
+ return 0;
+
+ /*
+ * Get the size of the whole window, including client area,
+ * scrollbars, and non-client area decorations (caption, borders).
+ * We do this because we need to check if the client area
+ * without scrollbars is large enough to display the whole visual.
+ * The new client area size passed by lParam already subtracts
+ * the size of the scrollbars if they are currently displayed.
+ * So checking is LOWORD(lParam) == visual_width and
+ * HIWORD(lParam) == visual_height will never tell us to hide
+ * the scrollbars because the client area would always be too small.
+ * GetClientRect returns the same sizes given by lParam, so we
+ * cannot use GetClientRect either.
+ */
+ GetWindowRect (hwnd, &rcWindow);
+ iWidth = rcWindow.right - rcWindow.left;
+ iHeight = rcWindow.bottom - rcWindow.top;
+
+ ErrorF ("winWindowProc - WM_SIZE - window w: %d h: %d, "
+ "new client area w: %d h: %d\n",
+ iWidth, iHeight, LOWORD (lParam), HIWORD (lParam));
+
+ /* Subtract the frame size from the window size. */
+ iWidth -= 2 * GetSystemMetrics (SM_CXSIZEFRAME);
+ iHeight -= (2 * GetSystemMetrics (SM_CYSIZEFRAME)
+ + GetSystemMetrics (SM_CYCAPTION));
+
+ /*
+ * Update scrollbar page sizes.
+ * NOTE: If page size == range, then the scrollbar is
+ * automatically hidden.
+ */
+
+ /* Is the naked client area large enough to show the whole visual? */
+ if (iWidth < s_pScreenInfo->dwWidth
+ || iHeight < s_pScreenInfo->dwHeight)
+ {
+ /* Client area too small to display visual, use scrollbars */
+ iWidth -= GetSystemMetrics (SM_CXVSCROLL);
+ iHeight -= GetSystemMetrics (SM_CYHSCROLL);
+ }
+
+ /* Set the horizontal scrollbar page size */
+ si.cbSize = sizeof (si);
+ si.fMask = SIF_PAGE | SIF_RANGE;
+ si.nMin = 0;
+ si.nMax = s_pScreenInfo->dwWidth - 1;
+ si.nPage = iWidth;
+ SetScrollInfo (hwnd, SB_HORZ, &si, TRUE);
+
+ /* Set the vertical scrollbar page size */
+ si.cbSize = sizeof (si);
+ si.fMask = SIF_PAGE | SIF_RANGE;
+ si.nMin = 0;
+ si.nMax = s_pScreenInfo->dwHeight - 1;
+ si.nPage = iHeight;
+ SetScrollInfo (hwnd, SB_VERT, &si, TRUE);
+
+ /*
+ * NOTE: Scrollbars may have moved if they were at the
+ * far right/bottom, so we query their current position.
+ */
+
+ /* Get the horizontal scrollbar position and set the offset */
+ si.cbSize = sizeof (si);
+ si.fMask = SIF_POS;
+ GetScrollInfo (hwnd, SB_HORZ, &si);
+ s_pScreenInfo->dwXOffset = -si.nPos;
+
+ /* Get the vertical scrollbar position and set the offset */
+ si.cbSize = sizeof (si);
+ si.fMask = SIF_POS;
+ GetScrollInfo (hwnd, SB_VERT, &si);
+ s_pScreenInfo->dwYOffset = -si.nPos;
+ }
+ return 0;
+
+ case WM_VSCROLL:
+ {
+ SCROLLINFO si;
+ int iVertPos;
+
+#if CYGDEBUG
+ winDebug ("winWindowProc - WM_VSCROLL\n");
+#endif
+
+ /* Get vertical scroll bar info */
+ si.cbSize = sizeof (si);
+ si.fMask = SIF_ALL;
+ GetScrollInfo (hwnd, SB_VERT, &si);
+
+ /* Save the vertical position for comparison later */
+ iVertPos = si.nPos;
+
+ /*
+ * Don't forget:
+ * moving the scrollbar to the DOWN, scroll the content UP
+ */
+ switch (LOWORD(wParam))
+ {
+ case SB_TOP:
+ si.nPos = si.nMin;
+ break;
+
+ case SB_BOTTOM:
+ si.nPos = si.nMax - si.nPage + 1;
+ break;
+
+ case SB_LINEUP:
+ si.nPos -= 1;
+ break;
+
+ case SB_LINEDOWN:
+ si.nPos += 1;
+ break;
+
+ case SB_PAGEUP:
+ si.nPos -= si.nPage;
+ break;
+
+ case SB_PAGEDOWN:
+ si.nPos += si.nPage;
+ break;
+
+ case SB_THUMBTRACK:
+ si.nPos = si.nTrackPos;
+ break;
+
+ default:
+ break;
+ }
+
+ /*
+ * We retrieve the position after setting it,
+ * because Windows may adjust it.
+ */
+ si.fMask = SIF_POS;
+ SetScrollInfo (hwnd, SB_VERT, &si, TRUE);
+ GetScrollInfo (hwnd, SB_VERT, &si);
+
+ /* Scroll the window if the position has changed */
+ if (si.nPos != iVertPos)
+ {
+ /* Save the new offset for bit block transfers, etc. */
+ s_pScreenInfo->dwYOffset = -si.nPos;
+
+ /* Change displayed region in the window */
+ ScrollWindowEx (hwnd,
+ 0,
+ iVertPos - si.nPos,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ SW_INVALIDATE);
+
+ /* Redraw the window contents */
+ UpdateWindow (hwnd);
+ }
+ }
+ return 0;
+
+ case WM_HSCROLL:
+ {
+ SCROLLINFO si;
+ int iHorzPos;
+
+#if CYGDEBUG
+ winDebug ("winWindowProc - WM_HSCROLL\n");
+#endif
+
+ /* Get horizontal scroll bar info */
+ si.cbSize = sizeof (si);
+ si.fMask = SIF_ALL;
+ GetScrollInfo (hwnd, SB_HORZ, &si);
+
+ /* Save the horizontal position for comparison later */
+ iHorzPos = si.nPos;
+
+ /*
+ * Don't forget:
+ * moving the scrollbar to the RIGHT, scroll the content LEFT
+ */
+ switch (LOWORD(wParam))
+ {
+ case SB_LEFT:
+ si.nPos = si.nMin;
+ break;
+
+ case SB_RIGHT:
+ si.nPos = si.nMax - si.nPage + 1;
+ break;
+
+ case SB_LINELEFT:
+ si.nPos -= 1;
+ break;
+
+ case SB_LINERIGHT:
+ si.nPos += 1;
+ break;
+
+ case SB_PAGELEFT:
+ si.nPos -= si.nPage;
+ break;
+
+ case SB_PAGERIGHT:
+ si.nPos += si.nPage;
+ break;
+
+ case SB_THUMBTRACK:
+ si.nPos = si.nTrackPos;
+ break;
+
+ default:
+ break;
+ }
+
+ /*
+ * We retrieve the position after setting it,
+ * because Windows may adjust it.
+ */
+ si.fMask = SIF_POS;
+ SetScrollInfo (hwnd, SB_HORZ, &si, TRUE);
+ GetScrollInfo (hwnd, SB_HORZ, &si);
+
+ /* Scroll the window if the position has changed */
+ if (si.nPos != iHorzPos)
+ {
+ /* Save the new offset for bit block transfers, etc. */
+ s_pScreenInfo->dwXOffset = -si.nPos;
+
+ /* Change displayed region in the window */
+ ScrollWindowEx (hwnd,
+ iHorzPos - si.nPos,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ SW_INVALIDATE);
+
+ /* Redraw the window contents */
+ UpdateWindow (hwnd);
+ }
+ }
+ return 0;
+
+ case WM_GETMINMAXINFO:
+ {
+ MINMAXINFO *pMinMaxInfo = (MINMAXINFO *) lParam;
+ int iCaptionHeight;
+ int iBorderHeight, iBorderWidth;
+
+#if CYGDEBUG
+ winDebug ("winWindowProc - WM_GETMINMAXINFO - pScreenInfo: %08x\n",
+ s_pScreenInfo);
+#endif
+
+ /* Can't do anything without screen info */
+ if (s_pScreenInfo == NULL
+ || !s_pScreenInfo->fScrollbars
+ || s_pScreenInfo->fFullScreen
+ || !s_pScreenInfo->fDecoration
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ || s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOW
+ || s_pScreenInfo->fMultiWindow
+#endif
+ )
+ break;
+
+ /*
+ * Here we can override the maximum tracking size, which
+ * is the largest size that can be assigned to our window
+ * via the sizing border.
+ */
+
+ /*
+ * FIXME: Do we only need to do this once, since our visual size
+ * does not change? Does Windows store this value statically
+ * once we have set it once?
+ */
+
+ /* Get the border and caption sizes */
+ iCaptionHeight = GetSystemMetrics (SM_CYCAPTION);
+ iBorderWidth = 2 * GetSystemMetrics (SM_CXSIZEFRAME);
+ iBorderHeight = 2 * GetSystemMetrics (SM_CYSIZEFRAME);
+
+ /* Allow the full visual to be displayed */
+ pMinMaxInfo->ptMaxTrackSize.x
+ = s_pScreenInfo->dwWidth + iBorderWidth;
+ pMinMaxInfo->ptMaxTrackSize.y
+ = s_pScreenInfo->dwHeight + iBorderHeight + iCaptionHeight;
+ }
+ return 0;
+
+ case WM_ERASEBKGND:
+#if CYGDEBUG
+ winDebug ("winWindowProc - WM_ERASEBKGND\n");
+#endif
+ /*
+ * Pretend that we did erase the background but we don't care,
+ * the application uses the full window estate. This avoids some
+ * flickering when resizing.
+ */
+ return TRUE;
+
+ case WM_PAINT:
+#if CYGDEBUG
+ winDebug ("winWindowProc - WM_PAINT\n");
+#endif
+ /* Only paint if we have privates and the server is enabled */
+ if (s_pScreenPriv == NULL
+ || !s_pScreenPriv->fEnabled
+ || (s_pScreenInfo->fFullScreen && !s_pScreenPriv->fActive)
+ || s_pScreenPriv->fBadDepth)
+ {
+ /* We don't want to paint */
+ break;
+ }
+
+ /* Break out here if we don't have a valid paint routine */
+ if (s_pScreenPriv->pwinBltExposedRegions == NULL)
+ break;
+
+ /* Call the engine dependent repainter */
+ (*s_pScreenPriv->pwinBltExposedRegions) (s_pScreen);
+ return 0;
+
+ case WM_PALETTECHANGED:
+ {
+#if CYGDEBUG
+ winDebug ("winWindowProc - WM_PALETTECHANGED\n");
+#endif
+ /*
+ * Don't process if we don't have privates or a colormap,
+ * or if we have an invalid depth.
+ */
+ if (s_pScreenPriv == NULL
+ || s_pScreenPriv->pcmapInstalled == NULL
+ || s_pScreenPriv->fBadDepth)
+ break;
+
+ /* Return if we caused the palette to change */
+ if ((HWND) wParam == hwnd)
+ {
+ /* Redraw the screen */
+ (*s_pScreenPriv->pwinRedrawScreen) (s_pScreen);
+ return 0;
+ }
+
+ /* Reinstall the windows palette */
+ (*s_pScreenPriv->pwinRealizeInstalledPalette) (s_pScreen);
+
+ /* Redraw the screen */
+ (*s_pScreenPriv->pwinRedrawScreen) (s_pScreen);
+ return 0;
+ }
+
+ case WM_MOUSEMOVE:
+ /* We can't do anything without privates */
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Has the mouse pointer crossed screens? */
+ if (s_pScreen != miPointerCurrentScreen ())
+ miPointerSetNewScreen (s_pScreenInfo->dwScreen,
+ GET_X_LPARAM(lParam)-s_pScreenInfo->dwXOffset,
+ GET_Y_LPARAM(lParam)-s_pScreenInfo->dwYOffset);
+
+ /* Are we tracking yet? */
+ if (!s_fTracking)
+ {
+ TRACKMOUSEEVENT tme;
+
+ /* Setup data structure */
+ ZeroMemory (&tme, sizeof (tme));
+ tme.cbSize = sizeof (tme);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = hwnd;
+
+ /* Call the tracking function */
+ if (!(*g_fpTrackMouseEvent) (&tme))
+ ErrorF ("winWindowProc - _TrackMouseEvent failed\n");
+
+ /* Flag that we are tracking now */
+ s_fTracking = TRUE;
+ }
+
+ /* Hide or show the Windows mouse cursor */
+ if (g_fSoftwareCursor && g_fCursor && (s_pScreenPriv->fActive || s_pScreenInfo->fLessPointer))
+ {
+ /* Hide Windows cursor */
+ g_fCursor = FALSE;
+ ShowCursor (FALSE);
+ }
+ else if (g_fSoftwareCursor && !g_fCursor && !s_pScreenPriv->fActive
+ && !s_pScreenInfo->fLessPointer)
+ {
+ /* Show Windows cursor */
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+
+ /* Deliver absolute cursor position to X Server */
+ miPointerAbsoluteCursor (GET_X_LPARAM(lParam)-s_pScreenInfo->dwXOffset,
+ GET_Y_LPARAM(lParam)-s_pScreenInfo->dwYOffset,
+ g_c32LastInputEventTime = GetTickCount ());
+ return 0;
+
+ case WM_NCMOUSEMOVE:
+ /*
+ * We break instead of returning 0 since we need to call
+ * DefWindowProc to get the mouse cursor changes
+ * and min/max/close button highlighting in Windows XP.
+ * The Platform SDK says that you should return 0 if you
+ * process this message, but it fails to mention that you
+ * will give up any default functionality if you do return 0.
+ */
+
+ /* We can't do anything without privates */
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Non-client mouse movement, show Windows cursor */
+ if (g_fSoftwareCursor && !g_fCursor)
+ {
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+ break;
+
+ case WM_MOUSELEAVE:
+ /* Mouse has left our client area */
+
+ /* Flag that we are no longer tracking */
+ s_fTracking = FALSE;
+
+ /* Show the mouse cursor, if necessary */
+ if (g_fSoftwareCursor && !g_fCursor)
+ {
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+ return 0;
+
+ case WM_LBUTTONDBLCLK:
+ case WM_LBUTTONDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ )
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (s_pScreen, ButtonPress, Button1, wParam);
+
+ case WM_LBUTTONUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ )
+ ReleaseCapture ();
+ return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button1, wParam);
+
+ case WM_MBUTTONDBLCLK:
+ case WM_MBUTTONDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ )
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (s_pScreen, ButtonPress, Button2, wParam);
+
+ case WM_MBUTTONUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ )
+ ReleaseCapture ();
+ return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button2, wParam);
+
+ case WM_RBUTTONDBLCLK:
+ case WM_RBUTTONDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ )
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (s_pScreen, ButtonPress, Button3, wParam);
+
+ case WM_RBUTTONUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ )
+ ReleaseCapture ();
+ return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button3, wParam);
+
+ case WM_XBUTTONDBLCLK:
+ case WM_XBUTTONDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ )
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (s_pScreen, ButtonPress, HIWORD(wParam) + 5, wParam);
+ case WM_XBUTTONUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ )
+ ReleaseCapture ();
+ return winMouseButtonsHandle (s_pScreen, ButtonRelease, HIWORD(wParam) + 5, wParam);
+
+ case WM_TIMER:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Branch on the timer id */
+ switch (wParam)
+ {
+ case WIN_E3B_TIMER_ID:
+ /* Send delayed button press */
+ winMouseButtonsSendEvent (ButtonPress,
+ s_pScreenPriv->iE3BCachedPress);
+
+ /* Kill this timer */
+ KillTimer (s_pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
+
+ /* Clear screen privates flags */
+ s_pScreenPriv->iE3BCachedPress = 0;
+ break;
+
+ case WIN_POLLING_MOUSE_TIMER_ID:
+ {
+ POINT point;
+
+ /* Get the current position of the mouse cursor */
+ GetCursorPos (&point);
+
+ /* Map from screen (-X, -Y) to root (0, 0) */
+ point.x -= GetSystemMetrics (SM_XVIRTUALSCREEN);
+ point.y -= GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* Deliver absolute cursor position to X Server */
+ miPointerAbsoluteCursor (point.x, point.y,
+ g_c32LastInputEventTime = GetTickCount());
+ }
+ }
+ return 0;
+
+ case WM_CTLCOLORSCROLLBAR:
+ FatalError ("winWindowProc - WM_CTLCOLORSCROLLBAR - We are not "
+ "supposed to get this message. Exiting.\n");
+ return 0;
+
+ case WM_MOUSEWHEEL:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+#if CYGDEBUG
+ winDebug ("winWindowProc - WM_MOUSEWHEEL\n");
+#endif
+ winMouseWheel (s_pScreen, GET_WHEEL_DELTA_WPARAM(wParam));
+ break;
+
+ case WM_SETFOCUS:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Save handle of our main window that last received focus */
+ g_hwndKeyboardFocus = hwnd;
+
+ /* Restore the state of all mode keys */
+ winRestoreModeKeyStates ();
+
+ /* Add the keyboard hook if possible */
+ if (g_fKeyboardHookLL)
+ g_fKeyboardHookLL = winInstallKeyboardHookLL ();
+ return 0;
+
+ case WM_KILLFOCUS:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Clear handle of our main window that last received focus */
+ g_hwndKeyboardFocus = NULL;
+
+ /* Release any pressed keys */
+ winKeybdReleaseKeys ();
+
+ /* Remove our keyboard hook if it is installed */
+ winRemoveKeyboardHookLL ();
+ return 0;
+
+ case WM_SYSKEYDOWN:
+ case WM_KEYDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /*
+ * FIXME: Catching Alt-F4 like this is really terrible. This should
+ * be generalized to handle other Windows keyboard signals. Actually,
+ * the list keys to catch and the actions to perform when caught should
+ * be configurable; that way user's can customize the keys that they
+ * need to have passed through to their window manager or apps, or they
+ * can remap certain actions to new key codes that do not conflict
+ * with the X apps that they are using. Yeah, that'll take awhile.
+ */
+ if ((s_pScreenInfo->fUseWinKillKey && wParam == VK_F4
+ && (GetKeyState (VK_MENU) & 0x8000))
+ || (s_pScreenInfo->fUseUnixKillKey && wParam == VK_BACK
+ && (GetKeyState (VK_MENU) & 0x8000)
+ && (GetKeyState (VK_CONTROL) & 0x8000)))
+ {
+ /*
+ * Better leave this message here, just in case some unsuspecting
+ * user enters Alt + F4 and is surprised when the application
+ * quits.
+ */
+ ErrorF ("winWindowProc - WM_*KEYDOWN - Closekey hit, quitting\n");
+
+ /* Display Exit dialog */
+ winDisplayExitDialog (s_pScreenPriv);
+ return 0;
+ }
+
+ /*
+ * Don't do anything for the Windows keys, as focus will soon
+ * be returned to Windows. We may be able to trap the Windows keys,
+ * but we should determine if that is desirable before doing so.
+ */
+ if ((wParam == VK_LWIN || wParam == VK_RWIN) && !g_fKeyboardHookLL)
+ break;
+
+#ifdef XKB
+ /*
+ * Discard presses generated from Windows auto-repeat
+ * ago: Only discard them if XKB is not disabled
+ */
+ if (!g_winInfo.xkb.disable && (lParam & (1<<30)))
+ {
+ switch (wParam)
+ {
+ /* ago: Pressing LControl while RControl is pressed is
+ * Indicated as repeat. Fix this!
+ */
+ case VK_CONTROL:
+ case VK_SHIFT:
+ if (winCheckKeyPressed(wParam, lParam))
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ }
+#endif
+
+ /* Discard fake Ctrl_L presses that precede AltGR on non-US keyboards */
+ if (winIsFakeCtrl_L (message, wParam, lParam))
+ return 0;
+
+ /* Translate Windows key code to X scan code */
+ winTranslateKey (wParam, lParam, &iScanCode);
+
+ /* Ignore repeats for CapsLock */
+ if (wParam == VK_CAPITAL)
+ lParam = 1;
+
+ /* Send the key event(s) */
+ for (i = 0; i < LOWORD(lParam); ++i)
+ winSendKeyEvent (iScanCode, TRUE);
+ return 0;
+
+ case WM_SYSKEYUP:
+ case WM_KEYUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /*
+ * Don't do anything for the Windows keys, as focus will soon
+ * be returned to Windows. We may be able to trap the Windows keys,
+ * but we should determine if that is desirable before doing so.
+ */
+ if ((wParam == VK_LWIN || wParam == VK_RWIN) && !g_fKeyboardHookLL)
+ break;
+
+ /* Ignore the fake Ctrl_L that follows an AltGr release */
+ if (winIsFakeCtrl_L (message, wParam, lParam))
+ return 0;
+
+ /* Enqueue a keyup event */
+ winTranslateKey (wParam, lParam, &iScanCode);
+ winSendKeyEvent (iScanCode, FALSE);
+
+ /* Release all pressed shift keys */
+ if (wParam == VK_SHIFT)
+ winFixShiftKeys (iScanCode);
+ return 0;
+
+ case WM_HOTKEY:
+ if (s_pScreenPriv == NULL)
+ break;
+
+ /* Call the engine-specific hot key handler */
+ (*s_pScreenPriv->pwinHotKeyAltTab) (s_pScreen);
+ return 0;
+
+ case WM_ACTIVATE:
+ if (s_pScreenPriv == NULL
+ || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* TODO: Override display of window when we have a bad depth */
+ if (LOWORD(wParam) != WA_INACTIVE && s_pScreenPriv->fBadDepth)
+ {
+ ErrorF ("winWindowProc - WM_ACTIVATE - Bad depth, trying "
+ "to override window activation\n");
+
+ /* Minimize the window */
+ ShowWindow (hwnd, SW_MINIMIZE);
+
+ /* Display dialog box */
+ if (g_hDlgDepthChange != NULL)
+ {
+ /* Make the existing dialog box active */
+ SetActiveWindow (g_hDlgDepthChange);
+ }
+ else
+ {
+ /* TODO: Recreate the dialog box and bring to the top */
+ ShowWindow (g_hDlgDepthChange, SW_SHOWDEFAULT);
+ }
+
+ /* Don't do any other processing of this message */
+ return 0;
+ }
+
+#if CYGDEBUG
+ winDebug ("winWindowProc - WM_ACTIVATE\n");
+#endif
+
+ /*
+ * Focus is being changed to another window.
+ * The other window may or may not belong to
+ * our process.
+ */
+
+ /* Clear any lingering wheel delta */
+ s_pScreenPriv->iDeltaZ = 0;
+
+ /* Reshow the Windows mouse cursor if we are being deactivated */
+ if (g_fSoftwareCursor && LOWORD(wParam) == WA_INACTIVE
+ && !g_fCursor)
+ {
+ /* Show Windows cursor */
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+ return 0;
+
+ case WM_ACTIVATEAPP:
+ if (s_pScreenPriv == NULL
+ || s_pScreenInfo->fIgnoreInput)
+ break;
+
+#if CYGDEBUG || TRUE
+ winDebug ("winWindowProc - WM_ACTIVATEAPP\n");
+#endif
+
+ /* Activate or deactivate */
+ s_pScreenPriv->fActive = wParam;
+
+ /* Reshow the Windows mouse cursor if we are being deactivated */
+ if (g_fSoftwareCursor && !s_pScreenPriv->fActive
+ && !g_fCursor)
+ {
+ /* Show Windows cursor */
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+
+#ifdef XWIN_CLIPBOARD
+ /* Make sure the clipboard chain is ok. */
+ winFixClipboardChain ();
+#endif
+
+ /* Call engine specific screen activation/deactivation function */
+ (*s_pScreenPriv->pwinActivateApp) (s_pScreen);
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ if (s_pScreenPriv->fActive)
+ {
+ /* Restack all window unless using built-in wm. */
+ if (s_pScreenInfo->fInternalWM && s_pScreenInfo->fAnotherWMRunning)
+ winMWExtWMRestackWindows (s_pScreen);
+ }
+#endif
+
+ return 0;
+
+ case WM_COMMAND:
+ switch (LOWORD (wParam))
+ {
+ case ID_APP_EXIT:
+ /* Display Exit dialog */
+ winDisplayExitDialog (s_pScreenPriv);
+ return 0;
+ case ID_APP_SHOWCURSOR:
+ winDebug("ShowCursor: %d\n", ShowCursor(TRUE));
+ return 0;
+
+#ifdef XWIN_MULTIWINDOW
+ case ID_APP_HIDE_ROOT:
+ if (s_pScreenPriv->fRootWindowShown)
+ ShowWindow (s_pScreenPriv->hwndScreen, SW_HIDE);
+ else
+ ShowWindow (s_pScreenPriv->hwndScreen, SW_SHOW);
+ s_pScreenPriv->fRootWindowShown = !s_pScreenPriv->fRootWindowShown;
+ return 0;
+#endif
+
+ case ID_APP_ABOUT:
+ /* Display the About box */
+ winDisplayAboutDialog (s_pScreenPriv);
+ return 0;
+
+ default:
+ /* It's probably one of the custom menus... */
+ if (HandleCustomWM_COMMAND (0, LOWORD (wParam)))
+ return 0;
+ }
+ break;
+
+ case WM_ENDSESSION:
+ case WM_GIVEUP:
+ /* Tell X that we are giving up */
+#ifdef XWIN_MULTIWINDOW
+ if (s_pScreenInfo->fMultiWindow)
+ winDeinitMultiWindowWM ();
+#endif
+ GiveUp (0);
+ return 0;
+
+ case WM_CLOSE:
+ /* Display Exit dialog */
+ winDisplayExitDialog (s_pScreenPriv);
+ return 0;
+
+ case WM_SETCURSOR:
+ if (LOWORD(lParam) == HTCLIENT)
+ {
+ if (!g_fSoftwareCursor) SetCursor (s_pScreenPriv->cursor.handle);
+ return TRUE;
+ }
+ break;
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ case WM_MANAGE:
+ ErrorF ("winWindowProc - WM_MANAGE\n");
+ s_pScreenInfo->fAnotherWMRunning = FALSE;
+
+ if (s_pScreenInfo->fInternalWM)
+ {
+ EnumThreadWindows (g_dwCurrentThreadID, winMWExtWMDecorateWindow, 0);
+ //RootlessRepositionWindows (s_pScreen);
+ }
+ break;
+
+ case WM_UNMANAGE:
+ ErrorF ("winWindowProc - WM_UNMANAGE\n");
+ s_pScreenInfo->fAnotherWMRunning = TRUE;
+
+ if (s_pScreenInfo->fInternalWM)
+ {
+ EnumThreadWindows (g_dwCurrentThreadID, winMWExtWMDecorateWindow, 0);
+ winMWExtWMRestackWindows (s_pScreen);
+ }
+ break;
+#endif
+
+ default:
+ if(message == s_uTaskbarRestart)
+ {
+ winInitNotifyIcon (s_pScreenPriv);
+ }
+ break;
+ }
+
+ return DefWindowProc (hwnd, message, wParam, lParam);
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/COPYING b/nx-X11/programs/Xserver/hw/xwin/xlaunch/COPYING
new file mode 100755
index 000000000..c7fa84400
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/COPYING
@@ -0,0 +1,25 @@
+
+ Copyright (c) 2005 Alexander Gottwald
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ Except as contained in this notice, the name(s) of the above copyright
+ holders shall not be used in advertising or otherwise to promote the sale,
+ use or other dealings in this Software without prior written authorization.
+
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/Makefile b/nx-X11/programs/Xserver/hw/xwin/xlaunch/Makefile
new file mode 100755
index 000000000..f7cf923df
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/Makefile
@@ -0,0 +1,79 @@
+#
+# Copyright (c) 2005 Alexander Gottwald
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the sale,
+# use or other dealings in this Software without prior written authorization.
+#
+WINDRES=windres
+
+TARGET=mingw
+#DEBUG_FLAGS=-D_DEBUG
+
+OS_FLAGS_mingw=-mno-cygwin
+OS_FLAGS=$(OS_FLAGS_$(TARGET)) $(DEBUG_FLAGS)
+
+X11_DIR_$(TARGET)=/usr/X11R6
+X11_DIR_mingw=../../../../../exports
+X11_DIR=$(X11_DIR_$(TARGET))
+X11_INCLUDE=-I$(X11_DIR)/include
+X11_LIBDIR=-L$(X11_DIR)/lib
+X11_LIBS_$(TARGET)=-lX11
+X11_LIBS_mingw=-lX11 -lwsock32
+X11_LIBS=$(X11_LIBS_$(TARGET))
+
+PROGRAMFILES:=$(shell cygpath -u $(PROGRAMFILES))
+#MSXML_DIR=$(PROGRAMFILES)/MSXML 4.0
+MSXML_DIR=$(PROGRAMFILES)/Microsoft XML Parser SDK
+MSXML_INCLUDE="-I$(MSXML_DIR)/inc"
+MSXML_LIBDIR="-L$(MSXML_DIR)/lib"
+MSXML_LIBS=
+
+
+CXXFLAGS=-g $(OS_FLAGS) $(X11_INCLUDE) $(MSXML_INCLUDE)
+LDFLAGS=-mwindows $(X11_LIBDIR) $(MSXML_LIBDIR)
+LIBS=-lcomctl32 -lole32 -loleaut32 $(X11_LIBS) $(MSXML_LIBS)
+all:xlaunch.exe
+%.res: %.rc
+ $(WINDRES) -O coff -o $@ $<
+
+WINDOW_PARTS=window util dialog wizard
+WINDOW_OBJECTS=$(foreach file,$(WINDOW_PARTS),window/$(file).o)
+
+RESOURCES_IMAGES=resources/multiwindow.bmp resources/fullscreen.bmp \
+ resources/windowed.bmp resources/nodecoration.bmp
+
+resources/resources.res: resources/resources.rc resources/resources.h \
+ resources/images.rc resources/dialog.rc resources/strings.rc \
+ $(RESOURCES_IMAGES)
+xlaunch.exe: $(WINDOW_OBJECTS) main.o config.o resources/resources.res
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+
+window/dialog.o: window/dialog.cc window/dialog.h window/window.h window/util.h
+window/frame.o: window/frame.cc window/frame.h window/window.h
+window/util.o: window/util.cc window/util.h
+window/window.o: window/window.cc window/window.h window/util.h
+window/wizard.o: window/wizard.cc window/wizard.h window/dialog.h \
+ window/window.h window/util.h
+main.o: main.cc window/util.h window/wizard.h window/dialog.h \
+ window/window.h resources/resources.h config.h
+config.o: config.cc config.h
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/config.cc b/nx-X11/programs/Xserver/hw/xwin/xlaunch/config.cc
new file mode 100644
index 000000000..b6bf65ae3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/config.cc
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+#include "config.h"
+#include "window/util.h"
+#include <msxml2.h>
+#include <stdexcept>
+
+const CLSID CLSID_DOMDocument40 = {0x88d969c0,0xf192,0x11d4,0xa6,0x5f,0x00,0x40,0x96,0x32,0x51,0xe5};
+const CLSID CLSID_DOMDocument30 = {0xf5078f32,0xc551,0x11d3,0x89,0xb9,0x00,0x00,0xf8,0x1f,0xe2,0x21};
+const IID IID_IXMLDOMDocument2 = {0x2933BF95,0x7B36,0x11d2,0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60};
+
+#define HRCALL(x, msg) if (FAILED(x)) { throw std::runtime_error("OLE Error:" msg " failed"); };
+
+char *wcconvert(const wchar_t *wstr)
+{
+ int chars = WideCharToMultiByte(CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL);
+ if (chars == 0)
+ throw win32_error("WideCharToMultiByte");
+ char *mbstr = new char[chars];
+ chars = WideCharToMultiByte(CP_ACP, 0, wstr, -1, mbstr, chars, NULL, NULL);
+ if (chars == 0)
+ throw win32_error("WideCharToMultiByte");
+ return mbstr;
+}
+
+wchar_t *mbconvert(const char *mbstr)
+{
+ int chars = MultiByteToWideChar(CP_ACP, 0, mbstr, -1, NULL, 0);
+ if (chars == 0)
+ throw win32_error("MultiByteToWideChar");
+ wchar_t *wstr = new wchar_t[chars];
+ chars = MultiByteToWideChar(CP_ACP, 0, mbstr, -1, wstr, chars);
+ if (chars == 0)
+ throw win32_error("MultiByteToWideChar");
+ return wstr;
+}
+
+VARIANT VariantString(const char *filename)
+{
+
+ wchar_t *str = mbconvert(filename);
+
+ VARIANT var;
+ VariantInit(&var);
+ V_BSTR(&var) = SysAllocString(str);
+ V_VT(&var) = VT_BSTR;
+
+ delete [] str;
+ return var;
+}
+
+VARIANT VariantString(const wchar_t *str)
+{
+ VARIANT var;
+ VariantInit(&var);
+ V_BSTR(&var) = SysAllocString(str);
+ V_VT(&var) = VT_BSTR;
+ return var;
+}
+
+IXMLDOMDocument2 *CreateDocument()
+{
+ IXMLDOMDocument2 *doc = NULL;
+
+ CoInitialize(NULL);
+
+ HRCALL(CoCreateInstance(CLSID_DOMDocument40, NULL, CLSCTX_INPROC_SERVER,
+ IID_IXMLDOMDocument2, (void**)&doc), "CoCreateInstance");
+
+ try {
+ HRCALL(doc->put_async(VARIANT_FALSE), "put_async");
+ HRCALL(doc->put_validateOnParse(VARIANT_FALSE), "put_validateOnParse");
+ HRCALL(doc->put_resolveExternals(VARIANT_FALSE), "put_resolveExternals");
+
+ IXMLDOMProcessingInstruction *pi = NULL;
+ IXMLDOMElement *root = NULL;
+ BSTR xml = SysAllocString(L"xml");
+ BSTR ver = SysAllocString(L"version='1.0'");
+ HRCALL(doc->createProcessingInstruction(xml,ver, &pi),
+ "createProcessingInstruction");
+ HRCALL(doc->appendChild(pi, NULL),
+ "appendChild");
+ pi->Release();
+ SysFreeString(xml);
+ SysFreeString(ver);
+
+ BSTR elemname = SysAllocString(L"XLaunch");
+ HRCALL(doc->createElement(elemname, &root), "createElement");
+ HRCALL(doc->appendChild(root, NULL), "appendChild");
+ SysFreeString(elemname);
+ } catch (...)
+ {
+ doc->Release();
+ throw;
+ }
+ return doc;
+}
+
+void setAttribute(IXMLDOMElement *elem, const wchar_t *name, const wchar_t *value)
+{
+ BSTR str = SysAllocString(name);
+ VARIANT var = VariantString(value);
+ HRCALL(elem->setAttribute(str, var), "setAttribute");
+ VariantClear(&var);
+ SysFreeString(str);
+}
+
+void setAttribute(IXMLDOMElement *elem, const wchar_t *name, const char *value)
+{
+ wchar_t *wstr = mbconvert(value);
+ setAttribute(elem, name, wstr);
+ delete [] wstr;
+ return;
+}
+
+void CConfig::Save(const char *filename)
+{
+ IXMLDOMDocument2 *doc = CreateDocument();
+ IXMLDOMElement *root = NULL;
+
+ HRCALL(doc->get_documentElement(&root), "get_documentElement");
+
+ switch (window)
+ {
+ case MultiWindow:
+ setAttribute(root, L"WindowMode", L"MultiWindow");
+ break;
+ case Fullscreen:
+ setAttribute(root, L"WindowMode", L"Fullscreen");
+ break;
+ default:
+ case Windowed:
+ setAttribute(root, L"WindowMode", L"Windowed");
+ break;
+ case Nodecoration:
+ setAttribute(root, L"WindowMode", L"Nodecoration");
+ break;
+ }
+ switch (client)
+ {
+ default:
+ case NoClient:
+ setAttribute(root, L"ClientMode", L"NoClient");
+ break;
+ case StartProgram:
+ setAttribute(root, L"ClientMode", L"StartProgram");
+ break;
+ case XDMCP:
+ setAttribute(root, L"ClientMode", L"XDMCP");
+ break;
+ }
+ setAttribute(root, L"LocalClient", local?L"True":L"False");
+ setAttribute(root, L"Display", display.c_str());
+ setAttribute(root, L"Program", program.c_str());
+ setAttribute(root, L"RemoteProtocol", protocol.c_str());
+ setAttribute(root, L"RemoteHost", host.c_str());
+ setAttribute(root, L"RemoteUser", user.c_str());
+ setAttribute(root, L"XDMCPHost", xdmcp_host.c_str());
+ setAttribute(root, L"XDMCPBroadcast", broadcast?L"True":L"False");
+ setAttribute(root, L"XDMCPIndirect", indirect?L"True":L"False");
+ setAttribute(root, L"Clipboard", clipboard?L"True":L"False");
+ setAttribute(root, L"ExtraParams", extra_params.c_str());
+
+ VARIANT var = VariantString(filename);
+ HRCALL(doc->save(var), "save");
+ VariantClear(&var);
+
+
+ root->Release();
+ doc->Release();
+}
+
+BOOL getAttribute(IXMLDOMElement *elem, const wchar_t *name, std::string &ret)
+{
+ VARIANT var;
+ HRCALL(elem->getAttribute((OLECHAR*)name, &var), "getAttribute");
+ if (V_VT(&var) != VT_NULL && V_VT(&var) == VT_BSTR)
+ {
+ char *str = wcconvert(V_BSTR(&var));
+ ret = str;
+ delete [] str;
+ return true;
+ }
+ return false;
+}
+
+BOOL getAttributeBool(IXMLDOMElement *elem, const wchar_t *name, bool &ret)
+{
+ std::string str;
+ if (getAttribute(elem, name, str))
+ {
+ if (str == "True")
+ ret = true;
+ else
+ ret = false;
+ return true;
+ }
+ return false;
+}
+
+
+void CConfig::Load(const char *filename)
+{
+ IXMLDOMDocument2 *doc = CreateDocument();
+ IXMLDOMElement *root = NULL;
+
+ VARIANT var = VariantString(filename);
+ VARIANT_BOOL status;
+ HRCALL(doc->load(var, &status), "load");
+ VariantClear(&var);
+
+ if (status == VARIANT_FALSE)
+ {
+ doc->Release();
+ return;
+ }
+
+ HRCALL(doc->get_documentElement(&root), "get_documentElement");
+
+ std::string windowMode;
+ std::string clientMode;
+
+ if (getAttribute(root, L"WindowMode", windowMode))
+ {
+ if (windowMode == "MultiWindow")
+ window = MultiWindow;
+ else if (windowMode == "Fullscreen")
+ window = Fullscreen;
+ else if (windowMode == "Windowed")
+ window = Windowed;
+ else if (windowMode == "Nodecoration")
+ window = Nodecoration;
+ }
+ if (getAttribute(root, L"ClientMode", clientMode))
+ {
+ if (clientMode == "NoClient")
+ client = NoClient;
+ else if (clientMode == "StartProgram")
+ client = StartProgram;
+ else if (clientMode == "XDMCP")
+ client = XDMCP;
+ }
+
+ getAttributeBool(root, L"LocalClient", local);
+ getAttribute(root, L"Display", display);
+ getAttribute(root, L"Program", program);
+ getAttribute(root, L"RemoteProtocol", protocol);
+ getAttribute(root, L"RemoteHost", host);
+ getAttribute(root, L"RemoteUser", user);
+ getAttribute(root, L"XDMCPHost", xdmcp_host);
+ getAttributeBool(root, L"XDMCPBroadcast", broadcast);
+ getAttributeBool(root, L"XDMCPIndirect", indirect);
+ getAttributeBool(root, L"Clipboard", clipboard);
+ getAttribute(root, L"ExtraParams", extra_params);
+
+
+ doc->Release();
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/config.h b/nx-X11/programs/Xserver/hw/xwin/xlaunch/config.h
new file mode 100644
index 000000000..f0aed3cf1
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/config.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#include <string>
+struct CConfig
+{
+ enum {MultiWindow, Fullscreen, Windowed, Nodecoration} window;
+ enum {NoClient, StartProgram, XDMCP} client;
+ bool local;
+ std::string display;
+ std::string protocol;
+ std::string program;
+ std::string host;
+ std::string user;
+ bool broadcast;
+ bool indirect;
+ std::string xdmcp_host;
+ bool clipboard;
+ std::string extra_params;
+#ifdef _DEBUG
+ CConfig() : window(MultiWindow), client(StartProgram), local(false), display("1"),
+ protocol("Putty"), program("xterm"), host("lupus"), user("ago"),
+ broadcast(false), indirect(false), xdmcp_host("lupus"),
+ clipboard(true), extra_params() {};
+#else
+ CConfig() : window(MultiWindow), client(StartProgram), local(false), display("0"),
+ protocol("Putty"), program("xterm"), host(""), user(""),
+ broadcast(true), indirect(false), xdmcp_host(""),
+ clipboard(true), extra_params() {};
+#endif
+ void Load(const char* filename);
+ void Save(const char* filename);
+};
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/main.cc b/nx-X11/programs/Xserver/hw/xwin/xlaunch/main.cc
new file mode 100755
index 000000000..2247d3aaf
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/main.cc
@@ -0,0 +1,700 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+#include "window/util.h"
+#include "window/wizard.h"
+#include "resources/resources.h"
+#include "config.h"
+#include <prsht.h>
+#include <commctrl.h>
+
+#include <stdexcept>
+
+#include <X11/Xlib.h>
+
+/// @brief Send WM_ENDSESSION to all program windows.
+/// This will shutdown the started xserver
+BOOL CALLBACK KillWindowsProc(HWND hwnd, LPARAM lParam)
+{
+ SendMessage(hwnd, WM_ENDSESSION, 0, 0);
+ return TRUE;
+}
+
+/// @brief Actual wizard implementation.
+/// This is based on generic CWizard but handles the special dialogs
+class CMyWizard : public CWizard
+{
+ public:
+ private:
+ CConfig config; /// Storage for config options.
+ public:
+ /// @brief Constructor.
+ /// Set wizard pages.
+ CMyWizard() : CWizard()
+ {
+ AddPage(IDD_DISPLAY, IDS_DISPLAY_TITLE, IDS_DISPLAY_SUBTITLE);
+ AddPage(IDD_CLIENTS, IDS_CLIENTS_TITLE, IDS_CLIENTS_SUBTITLE);
+ AddPage(IDD_PROGRAM, IDS_PROGRAM_TITLE, IDS_PROGRAM_SUBTITLE);
+ AddPage(IDD_XDMCP, IDS_XDMCP_TITLE, IDS_XDMCP_SUBTITLE);
+ //AddPage(IDD_FONTPATH, IDS_FONTPATH_TITLE, IDS_FONTPATH_SUBTITLE);
+ AddPage(IDD_CLIPBOARD, IDS_CLIPBOARD_TITLE, IDS_CLIPBOARD_SUBTITLE);
+ AddPage(IDD_FINISH, IDS_FINISH_TITLE, IDS_FINISH_SUBTITLE);
+ }
+
+ virtual void LoadConfig(const char *filename)
+ {
+ try {
+ config.Load(filename);
+ } catch (std::runtime_error &e)
+ {
+ printf("Fehler: %s\n", e.what());
+ }
+ }
+
+ /// @brief Handle the PSN_WIZNEXT message.
+ /// @param hwndDlg Handle to active page dialog.
+ /// @param index Index of current page.
+ /// @return TRUE if the message was handled. FALSE otherwise.
+ virtual BOOL WizardNext(HWND hwndDlg, unsigned index)
+ {
+#ifdef _DEBUG
+ printf("%s %d\n", __FUNCTION__, index);
+#endif
+ switch (PageID(index))
+ {
+ case IDD_DISPLAY:
+ // Check for select window mode
+ if (IsDlgButtonChecked(hwndDlg, IDC_MULTIWINDOW))
+ config.window = CConfig::MultiWindow;
+ else if (IsDlgButtonChecked(hwndDlg, IDC_FULLSCREEN))
+ config.window = CConfig::Fullscreen;
+ else if (IsDlgButtonChecked(hwndDlg, IDC_WINDOWED))
+ config.window = CConfig::Windowed;
+ else if (IsDlgButtonChecked(hwndDlg, IDC_NODECORATION))
+ config.window = CConfig::Nodecoration;
+ else
+ {
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
+ return TRUE;
+ }
+ // Get selected display number
+ {
+ char buffer[512];
+ GetDlgItemText(hwndDlg, IDC_DISPLAY, buffer, 512);
+ buffer[511] = 0;
+ config.display = buffer;
+ }
+ // Check for valid input
+ if (config.display.empty())
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
+ else
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_CLIENTS);
+ return TRUE;
+ case IDD_CLIENTS:
+ // Check for select client startup method
+ if (IsDlgButtonChecked(hwndDlg, IDC_CLIENT))
+ {
+ config.client = CConfig::StartProgram;
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_PROGRAM);
+ } else if (IsDlgButtonChecked(hwndDlg, IDC_XDMCP))
+ {
+ config.client = CConfig::XDMCP;
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_XDMCP);
+ } else if (IsDlgButtonChecked(hwndDlg, IDC_CLIENT_NONE))
+ {
+ config.client = CConfig::NoClient;
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_CLIPBOARD);
+ } else
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
+ return TRUE;
+ case IDD_PROGRAM:
+ // Check wether local or remote client should be started
+ if (IsDlgButtonChecked(hwndDlg, IDC_CLIENT_LOCAL))
+ config.local = true;
+ else if (IsDlgButtonChecked(hwndDlg, IDC_CLIENT_REMOTE))
+ config.local = false;
+ else
+ {
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
+ return TRUE;
+ }
+ // Read program, user and host name
+ {
+ char buffer[512];
+ GetDlgItemText(hwndDlg, IDC_CLIENT_USER, buffer, 512);
+ buffer[511] = 0;
+ config.user = buffer;
+ GetDlgItemText(hwndDlg, IDC_CLIENT_HOST, buffer, 512);
+ buffer[511] = 0;
+ config.host = buffer;
+ GetDlgItemText(hwndDlg, IDC_CLIENT_PROGRAM, buffer, 512);
+ buffer[511] = 0;
+ config.program = buffer;
+ }
+ // Check for valid input
+ if (!config.local && (config.host.empty() || config.program.empty()))
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
+ else
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_CLIPBOARD);
+ return TRUE;
+ case IDD_XDMCP:
+ // Check for broadcast
+ if (IsDlgButtonChecked(hwndDlg, IDC_XDMCP_BROADCAST))
+ config.broadcast = true;
+ else if (IsDlgButtonChecked(hwndDlg, IDC_XDMCP_QUERY))
+ config.broadcast = false;
+ else
+ {
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
+ return TRUE;
+ }
+ // Check for indirect mode
+ if (IsDlgButtonChecked(hwndDlg, IDC_XDMCP_INDIRECT))
+ config.indirect = true;
+ else
+ config.indirect = false;
+ // Read hostname
+ {
+ char buffer[512];
+ GetDlgItemText(hwndDlg, IDC_XDMCP_HOST, buffer, 512);
+ buffer[511] = 0;
+ config.xdmcp_host = buffer;
+ }
+ // Check for valid input
+ if (!config.broadcast && config.xdmcp_host.empty())
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, -1);
+ else
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_CLIPBOARD);
+ return TRUE;
+ case IDD_CLIPBOARD:
+ // check for clipboard
+ if (IsDlgButtonChecked(hwndDlg, IDC_CLIPBOARD))
+ config.clipboard = true;
+ else
+ config.clipboard = false;
+ // read parameters
+ {
+ char buffer[512];
+ GetDlgItemText(hwndDlg, IDC_EXTRA_PARAMS, buffer, 512);
+ buffer[511] = 0;
+ config.extra_params = buffer;
+ }
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_FINISH);
+ return TRUE;
+ default:
+ break;
+ }
+ return FALSE;
+ }
+ /// @brief Handle PSN_WIZFINISH message.
+ /// @param hwndDlg Handle to active page dialog.
+ /// @param index Index of current page.
+ /// @return TRUE if the message was handled. FALSE otherwise.
+ virtual BOOL WizardFinish(HWND hwndDlg, unsigned index)
+ {
+#ifdef _DEBUG
+ printf("finish %d\n", index);
+#endif
+ return FALSE;
+ }
+ /// @brief Handle PSN_WIZBACK message.
+ /// Basicly handles switching to proper page (skipping XDMCP or program page
+ /// if required).
+ /// @param hwndDlg Handle to active page dialog.
+ /// @param index Index of current page.
+ /// @return TRUE if the message was handled. FALSE otherwise.
+ virtual BOOL WizardBack(HWND hwndDlg, unsigned index)
+ {
+ switch (PageID(index))
+ {
+ case IDD_PROGRAM:
+ case IDD_XDMCP:
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_CLIENTS);
+ return TRUE;
+ case IDD_FONTPATH:
+ case IDD_CLIPBOARD: // temporary. fontpath is disabled
+ switch (config.client)
+ {
+ case CConfig::NoClient:
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_CLIENTS);
+ return TRUE;
+ case CConfig::StartProgram:
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_PROGRAM);
+ return TRUE;
+ case CConfig::XDMCP:
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_XDMCP);
+ return TRUE;
+ }
+ break;
+ }
+ return FALSE;
+ }
+ /// @brief Handle PSN_SETACTIVE message.
+ /// @param hwndDlg Handle to active page dialog.
+ /// @param index Index of current page.
+ /// @return TRUE if the message was handled. FALSE otherwise.
+ virtual BOOL WizardActivate(HWND hwndDlg, unsigned index)
+ {
+#ifdef _DEBUG
+ printf("%s %d\n", __FUNCTION__, index);
+#endif
+ switch (PageID(index))
+ {
+ case IDD_CLIENTS:
+ // Enable or disable XDMCP radiobutton and text
+ EnableWindow(GetDlgItem(hwndDlg, IDC_XDMCP), config.window != CConfig::MultiWindow);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_XDMCP_DESC), config.window != CConfig::MultiWindow);
+ break;
+ }
+ return FALSE;
+ }
+ protected:
+ /// @brief Enable or disable the control for remote clients.
+ /// @param hwndDlg Handle to active page dialog.
+ /// @param state State of control group.
+ void EnableRemoteProgramGroup(HWND hwndDlg, BOOL state)
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CLIENT_PROTOCOL), state);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CLIENT_HOST), state);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CLIENT_USER), state);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CLIENT_PROTOCOL_DESC), state);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CLIENT_HOST_DESC), state);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CLIENT_USER_DESC), state);
+ }
+ /// @brief Enable or disable the control for XDMCP connection.
+ /// @param hwndDlg Handle to active page dialog.
+ /// @param state State of control group.
+ void EnableXDMCPQueryGroup(HWND hwndDlg, BOOL state)
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_XDMCP_HOST), state);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_XDMCP_INDIRECT), state);
+ }
+ /// @brief Fill program box with default values.
+ /// @param hwndDlg Handle to active page dialog.
+ void FillProgramBox(HWND hwndDlg)
+ {
+ HWND cbwnd = GetDlgItem(hwndDlg, IDC_CLIENT_PROGRAM);
+ if (cbwnd == NULL)
+ return;
+ SendMessage(cbwnd, CB_RESETCONTENT, 0, 0);
+ SendMessage(cbwnd, CB_ADDSTRING, 0, (LPARAM) "xterm");
+ SendMessage(cbwnd, CB_ADDSTRING, 0, (LPARAM) "startkde");
+ SendMessage(cbwnd, CB_ADDSTRING, 0, (LPARAM) "gnome-session");
+ SendMessage(cbwnd, CB_ADDSTRING, 0, (LPARAM) ".xinitrc");
+ SendMessage(cbwnd, CB_ADDSTRING, 0, (LPARAM) "wmaker");
+ SendMessage(cbwnd, CB_SETCURSEL, 0, 0);
+ }
+ /// @brief Fill protocol box with default values.
+ /// @param hwndDlg Handle to active page dialog.
+ void FillProtocolBox(HWND hwndDlg)
+ {
+ HWND cbwnd = GetDlgItem(hwndDlg, IDC_CLIENT_PROTOCOL);
+ if (cbwnd == NULL)
+ return;
+ SendMessage(cbwnd, CB_RESETCONTENT, 0, 0);
+ SendMessage(cbwnd, CB_ADDSTRING, 0, (LPARAM) "Putty");
+ //SendMessage(cbwnd, CB_ADDSTRING, 0, (LPARAM) "OpenSSH");
+ SendMessage(cbwnd, CB_SETCURSEL, 0, 0);
+ }
+ void ShowSaveDialog(HWND parent)
+ {
+ char szTitle[512];
+ char szFilter[512];
+ char szFileTitle[512];
+ char szFile[MAX_PATH];
+ HINSTANCE hInst = GetModuleHandle(NULL);
+
+ LoadString(hInst, IDS_SAVE_TITLE, szTitle, sizeof(szTitle));
+ LoadString(hInst, IDS_SAVE_FILETITLE, szFileTitle, sizeof(szFileTitle));
+ LoadString(hInst, IDS_SAVE_FILTER, szFilter, sizeof(szFilter));
+ for (unsigned i=0; szFilter[i]; i++)
+ if (szFilter[i] == '%')
+ szFilter[i] = '\0';
+
+ strcpy(szFile, "config.xlaunch");
+
+ OPENFILENAME ofn;
+ memset(&ofn, 0, sizeof(OPENFILENAME));
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = parent;
+ ofn.lpstrFilter = szFilter;
+ ofn.lpstrFile= szFile;
+ ofn.nMaxFile = sizeof(szFile)/ sizeof(*szFile);
+ ofn.lpstrFileTitle = szFileTitle;
+ ofn.nMaxFileTitle = sizeof(szFileTitle);
+ ofn.lpstrInitialDir = (LPSTR)NULL;
+ ofn.Flags = OFN_SHOWHELP | OFN_OVERWRITEPROMPT;
+ ofn.lpstrTitle = szTitle;
+
+ if (GetSaveFileName(&ofn))
+ {
+ try {
+ config.Save(ofn.lpstrFile);
+ } catch (std::runtime_error &e)
+ {
+ printf("Fehler: %s\n", e.what());
+ }
+ }
+ }
+ public:
+
+ /// @brief Handle messages fo the dialog pages.
+ /// @param hwndDlg Handle of active dialog.
+ /// @param uMsg Message code.
+ /// @param wParam Message parameter.
+ /// @param lParam Message parameter.
+ /// @param psp Handle to sheet paramters.
+ virtual INT_PTR PageDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, PROPSHEETPAGE *psp)
+ {
+ HWND hwnd;
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ switch (PageID(PageIndex(psp)))
+ {
+ case IDD_DISPLAY:
+ // Init display dialog. Enable correct check buttons
+ switch (config.window)
+ {
+ default:
+ case CConfig::MultiWindow:
+ CheckRadioButton(hwndDlg, IDC_MULTIWINDOW, IDC_NODECORATION, IDC_MULTIWINDOW);
+ break;
+ case CConfig::Fullscreen:
+ CheckRadioButton(hwndDlg, IDC_MULTIWINDOW, IDC_NODECORATION, IDC_FULLSCREEN);
+ break;
+ case CConfig::Windowed:
+ CheckRadioButton(hwndDlg, IDC_MULTIWINDOW, IDC_NODECORATION, IDC_WINDOWED);
+ break;
+ case CConfig::Nodecoration:
+ CheckRadioButton(hwndDlg, IDC_MULTIWINDOW, IDC_NODECORATION, IDC_NODECORATION);
+ break;
+ }
+ // Set display number
+ SetDlgItemText(hwndDlg, IDC_DISPLAY, config.display.c_str());
+ break;
+ case IDD_CLIENTS:
+ // Init client dialog. Enable correct check buttons
+ switch (config.client)
+ {
+ default:
+ case CConfig::NoClient:
+ CheckRadioButton(hwndDlg, IDC_CLIENT_NONE, IDC_CLIENT, IDC_CLIENT_NONE);
+ break;
+ case CConfig::StartProgram:
+ CheckRadioButton(hwndDlg, IDC_CLIENT_NONE, IDC_CLIENT, IDC_CLIENT);
+ break;
+ case CConfig::XDMCP:
+ CheckRadioButton(hwndDlg, IDC_CLIENT_NONE, IDC_CLIENT, IDC_XDMCP);
+ break;
+ }
+ break;
+ case IDD_PROGRAM:
+ // Init program dialog. Check local and remote buttons
+ CheckRadioButton(hwndDlg, IDC_CLIENT_LOCAL, IDC_CLIENT_REMOTE, config.local?IDC_CLIENT_LOCAL:IDC_CLIENT_REMOTE);
+ EnableRemoteProgramGroup(hwndDlg, config.local?FALSE:TRUE);
+ // Fill combo boxes
+ FillProgramBox(hwndDlg);
+ FillProtocolBox(hwndDlg);
+ // Set edit fields
+ if (!config.program.empty())
+ SetDlgItemText(hwndDlg, IDC_CLIENT_PROGRAM, config.program.c_str());
+ SetDlgItemText(hwndDlg, IDC_CLIENT_USER, config.user.c_str());
+ SetDlgItemText(hwndDlg, IDC_CLIENT_HOST, config.host.c_str());
+ break;
+ case IDD_XDMCP:
+ // Init XDMCP dialog. Check broadcast and indirect button
+ CheckRadioButton(hwndDlg, IDC_XDMCP_QUERY, IDC_XDMCP_BROADCAST, config.broadcast?IDC_XDMCP_BROADCAST:IDC_XDMCP_QUERY);
+ CheckDlgButton(hwndDlg, IDC_XDMCP_INDIRECT, config.indirect?BST_CHECKED:BST_UNCHECKED);
+ EnableXDMCPQueryGroup(hwndDlg, config.broadcast?FALSE:TRUE);
+ // Set hostname
+ SetDlgItemText(hwndDlg, IDC_XDMCP_HOST, config.xdmcp_host.c_str());
+ break;
+ case IDD_CLIPBOARD:
+ CheckDlgButton(hwndDlg, IDC_CLIPBOARD, config.clipboard?BST_CHECKED:BST_UNCHECKED);
+ SetDlgItemText(hwndDlg, IDC_EXTRA_PARAMS, config.extra_params.c_str());
+ break;
+
+ }
+ case WM_COMMAND:
+ // Handle control messages
+ switch (LOWORD(wParam))
+ {
+ // Handle clicks on images. Check proper radiobutton
+ case IDC_MULTIWINDOW_IMG:
+ case IDC_FULLSCREEN_IMG:
+ case IDC_WINDOWED_IMG:
+ case IDC_NODECORATION_IMG:
+ CheckRadioButton(hwndDlg, IDC_MULTIWINDOW, IDC_NODECORATION, LOWORD(wParam)-4);
+ SetFocus(GetDlgItem(hwndDlg, LOWORD(wParam)-4));
+ break;
+ // Disable unavailable controls
+ case IDC_CLIENT_REMOTE:
+ case IDC_CLIENT_LOCAL:
+ EnableRemoteProgramGroup(hwndDlg, LOWORD(wParam) == IDC_CLIENT_REMOTE);
+ break;
+ case IDC_XDMCP_QUERY:
+ case IDC_XDMCP_BROADCAST:
+ EnableXDMCPQueryGroup(hwndDlg, LOWORD(wParam) == IDC_XDMCP_QUERY);
+ break;
+ case IDC_FINISH_SAVE:
+ ShowSaveDialog(hwndDlg);
+ break;
+ }
+ }
+ // pass messages to parent
+ return CWizard::PageDispatch(hwndDlg, uMsg, wParam, lParam, psp);
+ }
+
+ /// @brief Try to connect to server.
+ /// Repeat until successful, server died or maximum number of retries
+ /// reached.
+ Display *WaitForServer(HANDLE serverProcess)
+ {
+ int ncycles = 120; /* # of cycles to wait */
+ int cycles; /* Wait cycle count */
+ Display *xd;
+
+ for (cycles = 0; cycles < ncycles; cycles++) {
+ if ((xd = XOpenDisplay(NULL))) {
+ return xd;
+ }
+ else {
+ if (WaitForSingleObject(serverProcess, 1000) == WAIT_TIMEOUT)
+ continue;
+ }
+ }
+ return NULL;
+ }
+
+ /// @brief Do the actual start of Xming and clients
+ void StartUp()
+ {
+ std::string buffer;
+ std::string client;
+
+ // Construct display strings
+ std::string display_id = ":" + config.display;
+ std::string display = "localhost" + display_id + ":0";
+
+#ifdef _DEBUG
+ // Debug only: Switch to Xming installation directory
+ SetCurrentDirectory("C:\\Programme\\Xming");
+#endif
+
+ // Build Xming commandline
+ buffer = "Xming " + display_id + " ";
+ switch (config.window)
+ {
+ case CConfig::MultiWindow:
+ buffer += "-multiwindow ";
+ break;
+ case CConfig::Fullscreen:
+ buffer += "-fullscreen ";
+ break;
+ case CConfig::Nodecoration:
+ buffer += "-nodecoration ";
+ break;
+ default:
+ break;
+ }
+ // Add XDMCP parameter
+ if (config.client == CConfig::XDMCP)
+ {
+ if (config.broadcast)
+ buffer += "-broadcast ";
+ else
+ {
+ if (config.indirect)
+ buffer += "-indirect ";
+ else
+ buffer += "-query ";
+ buffer += config.xdmcp_host;
+ buffer += " ";
+ }
+ }
+ if (config.clipboard)
+ buffer += "-clipboard ";
+ if (!config.extra_params.empty())
+ {
+ buffer += config.extra_params;
+ buffer += " ";
+ }
+
+ // Construct client commandline
+ if (config.client == CConfig::StartProgram)
+ {
+ if (!config.local)
+ {
+ char cmdline[512];
+ std::string host = config.host;
+ if (!config.user.empty())
+ host = config.user + "@" + config.host;
+ if (config.protocol == "Putty")
+ snprintf(cmdline,512,"plink -X %s %s",
+ host.c_str(),config.program.c_str());
+ else
+ snprintf(cmdline,512,"ssh -Y %s %s",
+ host.c_str(),config.program.c_str());
+ client += cmdline;
+ } else
+ client += config.program.c_str();
+ }
+
+ // Prepare program startup
+ STARTUPINFO si, sic;
+ PROCESS_INFORMATION pi, pic;
+ HANDLE handles[2];
+ DWORD hcount = 0;
+ Display *dpy = NULL;
+
+ ZeroMemory( &si, sizeof(si) );
+ si.cb = sizeof(si);
+ ZeroMemory( &pi, sizeof(pi) );
+ ZeroMemory( &sic, sizeof(sic) );
+ sic.cb = sizeof(sic);
+ ZeroMemory( &pic, sizeof(pic) );
+
+ // Start Xming process.
+#ifdef _DEBUG
+ printf("%s\n", buffer.c_str());
+#endif
+ if( !CreateProcess( NULL, (CHAR*)buffer.c_str(), NULL, NULL,
+ FALSE, 0, NULL, NULL, &si, &pi ))
+ throw win32_error("CreateProcess failed");
+ handles[hcount++] = pi.hProcess;
+
+ if (!client.empty())
+ {
+ // Set DISPLAY variable
+ SetEnvironmentVariable("DISPLAY",display.c_str());
+
+ // Wait for server to startup
+ dpy = WaitForServer(pi.hProcess);
+ if (dpy == NULL)
+ {
+ while (hcount--)
+ TerminateProcess(handles[hcount], (DWORD)-1);
+ throw std::runtime_error("Connection to server failed");
+ }
+
+#ifdef _DEBUG
+ printf("%s\n", client.c_str());
+#endif
+
+ // Hide a console window
+ // FIXME: This may make it impossible to enter the password
+ sic.dwFlags = STARTF_USESHOWWINDOW;
+ sic.wShowWindow = SW_HIDE;
+
+ // Start the child process.
+ if( !CreateProcess( NULL, (CHAR*)client.c_str(), NULL, NULL,
+ FALSE, 0, NULL, NULL, &sic, &pic ))
+ {
+ DWORD err = GetLastError();
+ while (hcount--)
+ TerminateProcess(handles[hcount], (DWORD)-1);
+ throw win32_error("CreateProcess failed", err);
+ }
+ handles[hcount++] = pic.hProcess;
+ }
+
+ // Wait until any child process exits.
+ DWORD ret = WaitForMultipleObjects(hcount, handles, FALSE, INFINITE );
+
+#ifdef _DEBUG
+ printf("killing process!\n");
+#endif
+ // Check if Xming is still running
+ DWORD exitcode;
+ GetExitCodeProcess(pi.hProcess, &exitcode);
+ unsigned counter = 0;
+ while (exitcode == STILL_ACTIVE)
+ {
+ if (++counter > 10)
+ TerminateProcess(pi.hProcess, (DWORD)-1);
+ else
+ // Shutdown Xming (the soft way!)
+ EnumThreadWindows(pi.dwThreadId, KillWindowsProc, 0);
+ Sleep(500);
+ GetExitCodeProcess(pi.hProcess, &exitcode);
+ }
+ // Kill the client
+ TerminateProcess(pic.hProcess, (DWORD)-1);
+
+ // Close process and thread handles.
+ CloseHandle( pi.hProcess );
+ CloseHandle( pi.hThread );
+ CloseHandle( pic.hProcess );
+ CloseHandle( pic.hThread );
+ }
+};
+
+int main(int argc, char **argv)
+{
+ try {
+ InitCommonControls();
+ CMyWizard dialog;
+
+ bool skip_wizard = false;
+
+ for (int i = 1; i < argc; i++)
+ {
+ if (argv[i] == NULL)
+ continue;
+
+ std::string arg(argv[i]);
+ if (arg == "-load" && i + 1 < argc)
+ {
+ i++;
+ dialog.LoadConfig(argv[i]);
+ continue;
+ }
+ if (arg == "-run" && i + 1 < argc)
+ {
+ i++;
+ dialog.LoadConfig(argv[i]);
+ skip_wizard = true;
+ continue;
+ }
+ }
+
+ int ret = 0;
+ if (skip_wizard || (ret =dialog.ShowModal()) != 0)
+ dialog.StartUp();
+#ifdef _DEBUG
+ printf("return %d\n", ret);
+#endif
+ return 0;
+ } catch (std::runtime_error &e)
+ {
+ printf("Fehler: %s\n", e.what());
+ return -1;
+ }
+}
+
+
+
+
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/dialog.rc b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/dialog.rc
new file mode 100755
index 000000000..8b00df4ef
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/dialog.rc
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+#include <windows.h>
+#include "resources.h"
+
+#ifndef STR_CAPTION_DISPLAY
+#include "strings.rc"
+#endif
+
+IDD_DISPLAY DIALOGEX 0, 0, 317, 143
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTERMOUSE
+CAPTION STR_CAPTION_DISPLAY
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ AUTORADIOBUTTON STR_MULTIWINDOW,IDC_MULTIWINDOW,7,25,70,24,BS_MULTILINE|BS_TOP
+ AUTORADIOBUTTON STR_FULLSCREEN,IDC_FULLSCREEN,157,25,70,24,BS_MULTILINE|BS_TOP
+ AUTORADIOBUTTON STR_WINDOWED,IDC_WINDOWED,7,75,70,24,BS_MULTILINE|BS_TOP
+ AUTORADIOBUTTON STR_NODECORATION,IDC_NODECORATION,157,75,70,24,BS_MULTILINE|BS_TOP
+
+ CONTROL "IMG_MULTIWINDOW",IDC_MULTIWINDOW_IMG,"Static",SS_BITMAP | SS_NOTIFY,80,10,0,0
+ CONTROL "IMG_FULLSCREEN",IDC_FULLSCREEN_IMG,"Static",SS_BITMAP | SS_NOTIFY,230,10,0,0
+ CONTROL "IMG_WINDOWED",IDC_WINDOWED_IMG,"Static",SS_BITMAP | SS_NOTIFY,80,60,0,0
+ CONTROL "IMG_NODECORATION",IDC_NODECORATION_IMG,"Static",SS_BITMAP | SS_NOTIFY,230,60,0,0
+
+ LTEXT STR_DISPLAY_DESC,IDC_DISPLAY_DESC,7,120,64,12
+ EDITTEXT IDC_DISPLAY,80,118,67,12,ES_NUMBER
+END
+
+IDD_CLIENTS DIALOGEX 0, 0, 317, 143
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTERMOUSE
+CAPTION STR_CAPTION_CLIENTS
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ AUTORADIOBUTTON STR_CLIENT_NONE,IDC_CLIENT_NONE,7,14,300,10
+ AUTORADIOBUTTON STR_CLIENT,IDC_CLIENT,7,56,300,10
+ AUTORADIOBUTTON STR_XDMCP,IDC_XDMCP,7,98,300,10
+
+ LTEXT STR_CLIENT_NONE_DESC,IDC_CLIENT_NONE_DESC,19,28,280,27
+ LTEXT STR_CLIENT_DESC,IDC_CLIENT_DESC,19,70,280,27
+ LTEXT STR_XDMCP_DESC,IDC_XDMCP_DESC,19,112,280,27
+END
+
+IDD_PROGRAM DIALOGEX 0, 0, 317, 143
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTERMOUSE
+CAPTION STR_CAPTION_PROGRAM
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT STR_CLIENT_PROGRAM_DESC,IDC_CLIENT_PROGRAM_DESC,7,14,64,10
+ COMBOBOX IDC_CLIENT_PROGRAM,70,12,64,54,CBS_DROPDOWN | WS_VSCROLL
+
+ AUTORADIOBUTTON STR_CLIENT_LOCAL,IDC_CLIENT_LOCAL,7,28,300,10
+ AUTORADIOBUTTON STR_CLIENT_REMOTE,IDC_CLIENT_REMOTE,7,42,300,10
+
+ LTEXT STR_CLIENT_PROTOCOL_DESC,IDC_CLIENT_PROTOCOL_DESC,19,56,70,10
+ COMBOBOX IDC_CLIENT_PROTOCOL,100,54,64,54,CBS_DROPDOWNLIST | WS_VSCROLL
+
+ LTEXT STR_CLIENT_HOST_DESC,IDC_CLIENT_HOST_DESC,19,70,70,10
+ LTEXT STR_CLIENT_USER_DESC,IDC_CLIENT_USER_DESC,19,84,70,10
+ EDITTEXT IDC_CLIENT_HOST,100,68,64,12
+ EDITTEXT IDC_CLIENT_USER,100,82,64,12
+END
+
+IDD_XDMCP DIALOGEX 0, 0, 317, 143
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTERMOUSE
+CAPTION STR_CAPTION_XDMCP
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ AUTORADIOBUTTON STR_XDMCP_QUERY, IDC_XDMCP_QUERY,7,14,64,10
+ EDITTEXT IDC_XDMCP_HOST,78,12,64,12
+ AUTOCHECKBOX STR_XDMCP_INDIRECT,IDC_XDMCP_INDIRECT,19,28,280,10
+ AUTORADIOBUTTON STR_XDMCP_BROADCAST, IDC_XDMCP_BROADCAST,7,42,300,10
+ LTEXT STR_XDMCP_QUERY_DESC,IDC_XDMCP_QUERY_DESC,7,56,300,42
+END
+
+IDD_CLIPBOARD DIALOGEX 0, 0, 317, 143
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTERMOUSE
+CAPTION STR_CAPTION_CLIPBOARD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ AUTOCHECKBOX STR_CLIPBOARD,IDC_CLIPBOARD,7,14,300,10
+ LTEXT STR_CLIPBOARD_DESC,IDC_CLIPBOARD_DESC,19,28,280,27
+
+ LTEXT STR_EXTRA_PARAMS_DESC,IDC_EXTRA_PARAMS_DESC,7,56,280,10
+ EDITTEXT IDC_EXTRA_PARAMS,7,70,128,12
+END
+
+IDD_FINISH DIALOGEX 0, 0, 317, 143
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTERMOUSE
+CAPTION STR_CAPTION_FINISH
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT STR_FINISH_DESC,IDC_FINISH_DESC,7,14,300,28
+ LTEXT STR_FINISH_SAVE_DESC,IDC_FINISH_SAVE_DESC,7,56,300,12
+ PUSHBUTTON STR_FINISH_SAVE,IDC_FINISH_SAVE,7,68,75,14
+END
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/fullscreen.bmp b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/fullscreen.bmp
new file mode 100755
index 000000000..0d051f0b4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/fullscreen.bmp
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/images.rc b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/images.rc
new file mode 100755
index 000000000..2eac53c93
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/images.rc
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+IMG_MULTIWINDOW BITMAP "resources\\multiwindow.bmp"
+IMG_WINDOWED BITMAP "resources\\windowed.bmp"
+IMG_FULLSCREEN BITMAP "resources\\fullscreen.bmp"
+IMG_NODECORATION BITMAP "resources\\nodecoration.bmp"
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/multiwindow.bmp b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/multiwindow.bmp
new file mode 100755
index 000000000..0755c87b4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/multiwindow.bmp
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/nodecoration.bmp b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/nodecoration.bmp
new file mode 100755
index 000000000..e9e1ce690
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/nodecoration.bmp
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/resources.h b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/resources.h
new file mode 100755
index 000000000..470005192
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/resources.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+
+#define IDC_STATIC -1
+
+#define IDD_WELCOME 100
+#define IDD_FINISH 101
+#define IDD_DISPLAY 102
+#define IDD_CLIENTS 103
+#define IDD_PROGRAM 104
+#define IDD_XDMCP 105
+#define IDD_FONTPATH 106
+#define IDD_CLIPBOARD 107
+
+#define IDS_DISPLAY_TITLE 300
+#define IDS_DISPLAY_SUBTITLE 301
+#define IDS_CLIENTS_TITLE 302
+#define IDS_CLIENTS_SUBTITLE 303
+#define IDS_PROGRAM_TITLE 304
+#define IDS_PROGRAM_SUBTITLE 305
+#define IDS_XDMCP_TITLE 306
+#define IDS_XDMCP_SUBTITLE 307
+#define IDS_FONTPATH_TITLE 308
+#define IDS_FONTPATH_SUBTITLE 309
+#define IDS_FINISH_TITLE 310
+#define IDS_FINISH_SUBTITLE 311
+#define IDS_CLIPBOARD_TITLE 312
+#define IDS_CLIPBOARD_SUBTITLE 313
+#define IDS_SAVE_TITLE 320
+#define IDS_SAVE_FILETITLE 321
+#define IDS_SAVE_FILTER 322
+
+#define IDC_MULTIWINDOW 200
+#define IDC_WINDOWED 201
+#define IDC_FULLSCREEN 202
+#define IDC_NODECORATION 203
+#define IDC_MULTIWINDOW_IMG 204
+#define IDC_WINDOWED_IMG 205
+#define IDC_FULLSCREEN_IMG 206
+#define IDC_NODECORATION_IMG 207
+#define IDC_DISPLAY 208
+#define IDC_DISPLAY_DESC 209
+
+#define IDC_CLIENT_NONE 210
+#define IDC_XDMCP 211
+#define IDC_CLIENT 212
+#define IDC_CLIENT_LOCAL 213
+#define IDC_CLIENT_REMOTE 214
+#define IDC_CLIENT_HOST 215
+#define IDC_CLIENT_USER 216
+#define IDC_CLIENT_PROTOCOL 217
+#define IDC_CLIENT_CONFIGURE 218
+#define IDC_CLIENT_PROGRAM 219
+#define IDC_XDMCP_QUERY 220
+#define IDC_XDMCP_BROADCAST 221
+#define IDC_XDMCP_INDIRECT 222
+#define IDC_XDMCP_HOST 223
+#define IDC_CLIENT_NONE_DESC 224
+#define IDC_XDMCP_DESC 225
+#define IDC_CLIENT_DESC 226
+#define IDC_XDMCP_QUERY_DESC 227
+#define IDC_CLIENT_PROGRAM_DESC 228
+#define IDC_CLIENT_HOST_DESC 229
+#define IDC_CLIENT_USER_DESC 230
+#define IDC_CLIENT_PROTOCOL_DESC 231
+
+#define IDC_FONTPATH_DESC 240
+
+#define IDC_FINISH_DESC 250
+#define IDC_FINISH_SAVE 251
+#define IDC_FINISH_SAVE_DESC 252
+
+#define IDC_CLIPBOARD 260
+#define IDC_CLIPBOARD_DESC 261
+#define IDC_EXTRA_PARAMS 262
+#define IDC_EXTRA_PARAMS_DESC 263
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/resources.rc b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/resources.rc
new file mode 100755
index 000000000..07fd52f32
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/resources.rc
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+#include <windows.h>
+
+#include "resources.h"
+#include "images.rc"
+#include "dialog.rc"
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/strings.rc b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/strings.rc
new file mode 100644
index 000000000..5a9cd281b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/strings.rc
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+
+#define STR_CAPTION_DISPLAY "Display settings"
+#define STR_MULTIWINDOW "Multiple windows"
+#define STR_FULLSCREEN "Fullscreen"
+#define STR_WINDOWED "One large window"
+#define STR_NODECORATION "One window without titlebar"
+#define STR_DISPLAY_DESC "Display number"
+
+#define STR_CAPTION_CLIENTS "Client startup"
+#define STR_CLIENT_NONE "Start no client"
+#define STR_CLIENT_NONE_DESC "This will just start the xserver. You will be able to start local clients later."
+#define STR_CLIENT "Start a program"
+#define STR_CLIENT_DESC "This will start a local or remote program which will connect to the xserver. You will be able to start local clients later too. Remote programs are started using SSH."
+#define STR_XDMCP "Open session via XDMCP"
+#define STR_XDMCP_DESC "This will start a remote XDMCP session. Starting local clients later is limited. This option is not available with the ""Multiple windows"" mode."
+
+#define STR_CAPTION_PROGRAM "Start program"
+#define STR_CLIENT_PROGRAM_DESC "Start program"
+#define STR_CLIENT_LOCAL "Start program on this computer"
+#define STR_CLIENT_REMOTE "Start program on remote computer"
+#define STR_CLIENT_PROTOCOL_DESC "Connect using"
+#define STR_CLIENT_HOST_DESC "Connect to computer"
+#define STR_CLIENT_USER_DESC "Login as user"
+
+
+#define STR_CAPTION_XDMCP "XDMCP settings"
+#define STR_XDMCP_QUERY "Connect to host"
+#define STR_XDMCP_INDIRECT "Use indirect connect"
+#define STR_XDMCP_BROADCAST "Search for hosts (broadcast)"
+#define STR_XDMCP_QUERY_DESC "Some XDMCP servers must be configured to allow remote connections. Please check the documentation about configuring XDMCP servers."
+
+
+#define STR_CAPTION_FONTPATH "Fontpath settings"
+
+#define STR_CAPTION_CLIPBOARD "Clipboard settings"
+#define STR_CLIPBOARD "Clipboard"
+#define STR_CLIPBOARD_DESC "Start the integrated clipboard manager"
+#define STR_EXTRA_PARAMS_DESC "Additional parameters for Xming"
+
+#define STR_CAPTION_FINISH "Finish configuration"
+#define STR_FINISH_DESC "Configuration is complete. Clish Finish to start Xming."
+#define STR_FINISH_SAVE_DESC "You may also save the configuration for later use."
+#define STR_FINISH_SAVE "Save configuration"
+
+#define STR_DISPLAY_TITLE "Select display settings"
+#define STR_DISPLAY_SUBTITLE "Choose how Xming display programs"
+#define STR_CLIENTS_TITLE "Select how to start clients"
+#define STR_CLIENTS_SUBTITLE ""
+#define STR_PROGRAM_TITLE "Specify the program to start"
+#define STR_PROGRAM_SUBTITLE ""
+#define STR_XDMCP_TITLE "Configure a remote XDMCP connection"
+#define STR_XDMCP_SUBTITLE ""
+#define STR_FONTPATH_TITLE "Define font locations"
+#define STR_FONTPATH_SUBTITLE ""
+#define STR_FINISH_TITLE "Configuration complete"
+#define STR_FINISH_SUBTITLE ""
+#define STR_CLIPBOARD_TITLE "Clipboard settings"
+#define STR_CLIPBOARD_SUBTITLE ""
+
+#define STR_SAVE_TITLE "Save configuration"
+#define STR_SAVE_FILETITLE "Filename"
+#define STR_SAVE_FILTER "Xlaunch Files (*.xlaunch)%*.xlaunch%%"
+
+STRINGTABLE
+BEGIN
+ IDS_DISPLAY_TITLE STR_DISPLAY_TITLE
+ IDS_DISPLAY_SUBTITLE STR_DISPLAY_SUBTITLE
+ IDS_CLIENTS_TITLE STR_CLIENTS_TITLE
+ IDS_CLIENTS_SUBTITLE STR_CLIENTS_SUBTITLE
+ IDS_PROGRAM_TITLE STR_PROGRAM_TITLE
+ IDS_PROGRAM_SUBTITLE STR_PROGRAM_SUBTITLE
+ IDS_XDMCP_TITLE STR_XDMCP_TITLE
+ IDS_XDMCP_SUBTITLE STR_XDMCP_SUBTITLE
+ IDS_FONTPATH_TITLE STR_FONTPATH_TITLE
+ IDS_FONTPATH_SUBTITLE STR_FONTPATH_SUBTITLE
+ IDS_FINISH_TITLE STR_FINISH_TITLE
+ IDS_FINISH_SUBTITLE STR_FINISH_SUBTITLE
+ IDS_CLIPBOARD_TITLE STR_CLIPBOARD_TITLE
+ IDS_CLIPBOARD_SUBTITLE STR_CLIPBOARD_SUBTITLE
+ IDS_SAVE_TITLE STR_SAVE_TITLE
+ IDS_SAVE_FILETITLE STR_SAVE_FILETITLE
+ IDS_SAVE_FILTER STR_SAVE_FILTER
+END
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/windowed.bmp b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/windowed.bmp
new file mode 100755
index 000000000..9eff2bff9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/windowed.bmp
Binary files differ
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/dialog.cc b/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/dialog.cc
new file mode 100755
index 000000000..76e5c35ac
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/dialog.cc
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+#include <stdio.h>
+#include "dialog.h"
+#include "util.h"
+
+CBaseDialog::CBaseDialog() : CWindow(""), result(0)
+{
+}
+
+CDialog::CDialog(const char *res) : CBaseDialog(), resourcename(res)
+{
+}
+
+HWND CDialog::CreateWindowHandle()
+{
+ HWND ret = CreateDialog(
+ GetModuleHandle(NULL),
+ resourcename.c_str(),
+ NULL,
+ DialogProc);
+ if (ret == NULL)
+ throw win32_error("CreateDialog failed");
+ return ret;
+}
+
+INT_PTR CALLBACK CBaseDialog::DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ MessageDebug::debug(hwndDlg, uMsg, wParam, lParam, __FUNCTION__);
+ CBaseDialog* dialog = (CDialog*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ if (dialog != NULL)
+ return dialog->DlgDispatch(hwndDlg, uMsg, wParam, lParam);
+ return FALSE;
+}
+
+INT_PTR CBaseDialog::DlgDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch (uMsg)
+ {
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ case IDCANCEL:
+ result = wParam;
+ EndDialog(hwndDlg, wParam);
+ DestroyWindow(hwndDlg);
+ return TRUE;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+INT_PTR CDialog::DlgDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ return CBaseDialog::DlgDispatch(hwndDlg, uMsg, wParam, lParam);
+}
+
+int CBaseDialog::Execute()
+{
+ return CWindow::ShowModal();
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/dialog.h b/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/dialog.h
new file mode 100755
index 000000000..073394bb2
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/dialog.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+#ifndef __DIALOG_H__
+#define __DIALOG_H__
+
+#include "window.h"
+class CBaseDialog : public CWindow
+{
+ private:
+ int result;
+ protected:
+ static INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ virtual INT_PTR DlgDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ public:
+ CBaseDialog();
+ int Execute();
+};
+
+class CDialog : public CBaseDialog
+{
+ private:
+ std::string resourcename;
+ protected:
+ virtual INT_PTR DlgDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ virtual HWND CreateWindowHandle();
+ public:
+ CDialog(const char *res);
+};
+
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/util.cc b/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/util.cc
new file mode 100644
index 000000000..fb7e87297
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/util.cc
@@ -0,0 +1,1112 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+#include "util.h"
+
+std::string win32_error::message(DWORD errorcode)
+{
+ LPVOID lpMsgBuf;
+ if (!FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ errorcode,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL ))
+ {
+ return "Unknown error in FormatMessage";
+ }
+
+ std::string ret((LPCTSTR)lpMsgBuf);
+ LocalFree( lpMsgBuf );
+ return ret;
+}
+
+void MessageDebug::debug(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, const char *prefix)
+{
+#ifdef _DEBUG
+ static const char *psn_notify[] = {
+ "PSN_SETACTIVE",
+ "PSN_KILLACTIVE",
+ "PSN_APPLY",
+ "PSN_RESET",
+ NULL,
+ "PSN_HELP",
+ "PSN_WIZBACK",
+ "PSN_WIZNEXT",
+ "PSN_WIZFINISH",
+ "PSN_QUERYCANCEL" };
+ if (uMsg == WM_NOTIFY)
+ {
+ LPNMHDR pnmh = (LPNMHDR)lParam;
+ int psn_index = -(int)pnmh->code - 200;
+ if (psn_index >= 0 && psn_index < 10 && psn_notify[psn_index])
+ printf("%s: %08x %04x WM_NOTIFY (%s)\n", prefix, hwnd, wParam, psn_notify[psn_index]);
+ else if (pnmh->code < NOTIFY_NAMES_LEN && notify_names[pnmh->code])
+ printf("%s: %08x %04x WM_NOTIFY (%s)\n", prefix, hwnd, wParam, notify_names[pnmh->code]);
+ else
+ printf("%s: %08x %04x WM_NOTIFY (%u)\n", prefix, hwnd, wParam, pnmh->code);
+ }
+ else if (uMsg >= MESSAGE_NAMES_LEN)
+ if (uMsg >= WM_USER)
+ printf("%s: %08x %04x %08x WM_USER + %d\n", prefix, hwnd, wParam, lParam, uMsg - WM_USER);
+ else
+ printf("%s: %08x %04x %08x %d\n", prefix, hwnd, wParam, lParam, uMsg);
+ else if (uMsg >= 0 && uMsg < MESSAGE_NAMES_LEN && message_names[uMsg])
+ printf("%s: %08x %04x %08x %s\n", prefix, hwnd, wParam, lParam, message_names[uMsg]);
+#endif
+}
+
+
+const char * MessageDebug::message_names[MESSAGE_NAMES_LEN] = {
+ "WM_NULL",
+ "WM_CREATE",
+ "WM_DESTROY",
+ "WM_MOVE",
+ "4",
+ "WM_SIZE",
+ "WM_ACTIVATE",
+ "WM_SETFOCUS",
+ "WM_KILLFOCUS",
+ "9",
+ "WM_ENABLE",
+ "WM_SETREDRAW",
+ "WM_SETTEXT",
+ "WM_GETTEXT",
+ "WM_GETTEXTLENGTH",
+ "WM_PAINT",
+ "WM_CLOSE",
+ "WM_QUERYENDSESSION",
+ "WM_QUIT",
+ "WM_QUERYOPEN",
+ "WM_ERASEBKGND",
+ "WM_SYSCOLORCHANGE",
+ "WM_ENDSESSION",
+ "23",
+ "WM_SHOWWINDOW",
+ "25",
+ "WM_WININICHANGE",
+ "WM_DEVMODECHANGE",
+ "WM_ACTIVATEAPP",
+ "WM_FONTCHANGE",
+ "WM_TIMECHANGE",
+ "WM_CANCELMODE",
+ NULL /* WM_SETCURSOR */,
+ "WM_MOUSEACTIVATE",
+ "WM_CHILDACTIVATE",
+ "WM_QUEUESYNC",
+ "WM_GETMINMAXINFO",
+ "37",
+ "WM_PAINTICON",
+ "WM_ICONERASEBKGND",
+ "WM_NEXTDLGCTL",
+ "41",
+ "WM_SPOOLERSTATUS",
+ "WM_DRAWITEM",
+ "WM_MEASUREITEM",
+ "WM_DELETEITEM",
+ "WM_VKEYTOITEM",
+ "WM_CHARTOITEM",
+ "WM_SETFONT",
+ "WM_GETFONT",
+ "WM_SETHOTKEY",
+ "WM_GETHOTKEY",
+ "52",
+ "53",
+ "54",
+ "WM_QUERYDRAGICON",
+ "56",
+ "WM_COMPAREITEM",
+ "58",
+ "59",
+ "60",
+ "61",
+ "62",
+ "63",
+ "64",
+ "WM_COMPACTING",
+ "66",
+ "67",
+ "WM_COMMNOTIFY",
+ "69",
+ "WM_WINDOWPOSCHANGING",
+ "WM_WINDOWPOSCHANGED",
+ "WM_POWER",
+ "73",
+ "WM_COPYDATA",
+ "WM_CANCELJOURNAL",
+ "76",
+ "77",
+ "WM_NOTIFY",
+ "79",
+ "WM_INPUTLANGCHANGEREQUEST",
+ "WM_INPUTLANGCHANGE",
+ "WM_TCARD",
+ "WM_HELP",
+ "WM_USERCHANGED",
+ "WM_NOTIFYFORMAT",
+ "86",
+ "87",
+ "88",
+ "89",
+ "90",
+ "91",
+ "92",
+ "93",
+ "94",
+ "95",
+ "96",
+ "97",
+ "98",
+ "99",
+ "100",
+ "101",
+ "102",
+ "103",
+ "104",
+ "105",
+ "106",
+ "107",
+ "108",
+ "109",
+ "110",
+ "111",
+ "112",
+ "113",
+ "114",
+ "115",
+ "116",
+ "117",
+ "118",
+ "119",
+ "120",
+ "121",
+ "122",
+ "WM_CONTEXTMENU",
+ "WM_STYLECHANGING",
+ "WM_STYLECHANGED",
+ "WM_DISPLAYCHANGE",
+ "WM_GETICON",
+ "WM_SETICON",
+ "WM_NCCREATE",
+ "WM_NCDESTROY",
+ "WM_NCCALCSIZE",
+ NULL /* WM_NCHITTEST */,
+ "WM_NCPAINT",
+ "WM_NCACTIVATE",
+ "WM_GETDLGCODE",
+ "WM_SYNCPAINT",
+ "137",
+ "138",
+ "139",
+ "140",
+ "141",
+ "142",
+ "143",
+ "144",
+ "145",
+ "146",
+ "147",
+ "148",
+ "149",
+ "150",
+ "151",
+ "152",
+ "153",
+ "154",
+ "155",
+ "156",
+ "157",
+ "158",
+ "159",
+ NULL /* WM_NCMOUSEMOVE */,
+ "WM_NCLBUTTONDOWN",
+ "WM_NCLBUTTONUP",
+ "WM_NCLBUTTONDBLCLK",
+ "WM_NCRBUTTONDOWN",
+ "WM_NCRBUTTONUP",
+ "WM_NCRBUTTONDBLCLK",
+ "WM_NCMBUTTONDOWN",
+ "WM_NCMBUTTONUP",
+ "WM_NCMBUTTONDBLCLK",
+ "170",
+ "171",
+ "172",
+ "173",
+ "174",
+ "175",
+ "176",
+ "177",
+ "178",
+ "179",
+ "180",
+ "181",
+ "182",
+ "183",
+ "184",
+ "185",
+ "186",
+ "187",
+ "188",
+ "189",
+ "190",
+ "191",
+ "192",
+ "193",
+ "194",
+ "195",
+ "196",
+ "197",
+ "198",
+ "199",
+ "200",
+ "201",
+ "202",
+ "203",
+ "204",
+ "205",
+ "206",
+ "207",
+ "208",
+ "209",
+ "210",
+ "211",
+ "212",
+ "213",
+ "214",
+ "215",
+ "216",
+ "217",
+ "218",
+ "219",
+ "220",
+ "221",
+ "222",
+ "223",
+ "224",
+ "225",
+ "226",
+ "227",
+ "228",
+ "229",
+ "230",
+ "231",
+ "232",
+ "233",
+ "234",
+ "235",
+ "236",
+ "237",
+ "238",
+ "239",
+ "240",
+ "241",
+ "242",
+ "243",
+ "244",
+ "245",
+ "246",
+ "247",
+ "248",
+ "249",
+ "250",
+ "251",
+ "252",
+ "253",
+ "254",
+ "255",
+ "WM_KEYDOWN",
+ "WM_KEYUP",
+ "WM_CHAR",
+ "WM_DEADCHAR",
+ "WM_SYSKEYDOWN",
+ "WM_SYSKEYUP",
+ "WM_SYSCHAR",
+ "WM_SYSDEADCHAR",
+ "WM_CONVERTREQUESTEX",
+ "265",
+ "266",
+ "267",
+ "268",
+ "WM_IME_STARTCOMPOSITION",
+ "WM_IME_ENDCOMPOSITION",
+ "WM_IME_KEYLAST",
+ "WM_INITDIALOG",
+ "WM_COMMAND",
+ "WM_SYSCOMMAND",
+ NULL /* WM_TIMER */,
+ "WM_HSCROLL",
+ "WM_VSCROLL",
+ "WM_INITMENU",
+ "WM_INITMENUPOPUP",
+ "280",
+ "281",
+ "282",
+ "283",
+ "284",
+ "285",
+ "286",
+ "WM_MENUSELECT",
+ "WM_MENUCHAR",
+ "WM_ENTERIDLE",
+ "290",
+ "291",
+ "292",
+ "293",
+ "294",
+ "295",
+ "296",
+ "297",
+ "298",
+ "299",
+ "300",
+ "301",
+ "302",
+ "303",
+ "304",
+ "305",
+ "WM_CTLCOLORMSGBOX",
+ "WM_CTLCOLOREDIT",
+ "WM_CTLCOLORLISTBOX",
+ "WM_CTLCOLORBTN",
+ "WM_CTLCOLORDLG",
+ "WM_CTLCOLORSCROLLBAR",
+ "WM_CTLCOLORSTATIC",
+ "313",
+ "314",
+ "315",
+ "316",
+ "317",
+ "318",
+ "319",
+ "320",
+ "321",
+ "322",
+ "323",
+ "324",
+ "325",
+ "326",
+ "327",
+ "328",
+ "329",
+ "330",
+ "331",
+ "332",
+ "333",
+ "334",
+ "335",
+ "336",
+ "337",
+ "338",
+ "339",
+ "340",
+ "341",
+ "342",
+ "343",
+ "344",
+ "345",
+ "346",
+ "347",
+ "348",
+ "349",
+ "350",
+ "351",
+ "352",
+ "353",
+ "354",
+ "355",
+ "356",
+ "357",
+ "358",
+ "359",
+ "360",
+ "361",
+ "362",
+ "363",
+ "364",
+ "365",
+ "366",
+ "367",
+ "368",
+ "369",
+ "370",
+ "371",
+ "372",
+ "373",
+ "374",
+ "375",
+ "376",
+ "377",
+ "378",
+ "379",
+ "380",
+ "381",
+ "382",
+ "383",
+ "384",
+ "385",
+ "386",
+ "387",
+ "388",
+ "389",
+ "390",
+ "391",
+ "392",
+ "393",
+ "394",
+ "395",
+ "396",
+ "397",
+ "398",
+ "399",
+ "400",
+ "401",
+ "402",
+ "403",
+ "404",
+ "405",
+ "406",
+ "407",
+ "408",
+ "409",
+ "410",
+ "411",
+ "412",
+ "413",
+ "414",
+ "415",
+ "416",
+ "417",
+ "418",
+ "419",
+ "420",
+ "421",
+ "422",
+ "423",
+ "424",
+ "425",
+ "426",
+ "427",
+ "428",
+ "429",
+ "430",
+ "431",
+ "432",
+ "433",
+ "434",
+ "435",
+ "436",
+ "437",
+ "438",
+ "439",
+ "440",
+ "441",
+ "442",
+ "443",
+ "444",
+ "445",
+ "446",
+ "447",
+ "448",
+ "449",
+ "450",
+ "451",
+ "452",
+ "453",
+ "454",
+ "455",
+ "456",
+ "457",
+ "458",
+ "459",
+ "460",
+ "461",
+ "462",
+ "463",
+ "464",
+ "465",
+ "466",
+ "467",
+ "468",
+ "469",
+ "470",
+ "471",
+ "472",
+ "473",
+ "474",
+ "475",
+ "476",
+ "477",
+ "478",
+ "479",
+ "480",
+ "481",
+ "482",
+ "483",
+ "484",
+ "485",
+ "486",
+ "487",
+ "488",
+ "489",
+ "490",
+ "491",
+ "492",
+ "493",
+ "494",
+ "495",
+ "496",
+ "497",
+ "498",
+ "499",
+ "500",
+ "501",
+ "502",
+ "503",
+ "504",
+ "505",
+ "506",
+ "507",
+ "508",
+ "509",
+ "510",
+ "511",
+ NULL /* WM_MOUSEMOVE */,
+ "WM_LBUTTONDOWN",
+ "WM_LBUTTONUP",
+ "WM_LBUTTONDBLCLK",
+ "WM_RBUTTONDOWN",
+ "WM_RBUTTONUP",
+ "WM_RBUTTONDBLCLK",
+ "WM_MBUTTONDOWN",
+ "WM_MBUTTONUP",
+ "WM_MBUTTONDBLCLK",
+ "WM_MOUSEWHEEL",
+ "WM_XBUTTONDOWN",
+ "WM_XBUTTONUP",
+ "WM_XBUTTONDBLCLK",
+ "526",
+ "527",
+ "WM_PARENTNOTIFY",
+ "WM_ENTERMENULOOP",
+ "WM_EXITMENULOOP",
+ "WM_NEXTMENU",
+ "WM_SIZING",
+ "WM_CAPTURECHANGED",
+ "WM_MOVING",
+ "535",
+ "WM_POWERBROADCAST",
+ "WM_DEVICECHANGE",
+ "538",
+ "539",
+ "540",
+ "541",
+ "542",
+ "543",
+ "WM_MDICREATE",
+ "WM_MDIDESTROY",
+ "WM_MDIACTIVATE",
+ "WM_MDIRESTORE",
+ "WM_MDINEXT",
+ "WM_MDIMAXIMIZE",
+ "WM_MDITILE",
+ "WM_MDICASCADE",
+ "WM_MDIICONARRANGE",
+ "WM_MDIGETACTIVE",
+ "554",
+ "555",
+ "556",
+ "557",
+ "558",
+ "559",
+ "WM_MDISETMENU",
+ "WM_ENTERSIZEMOVE",
+ "WM_EXITSIZEMOVE",
+ "WM_DROPFILES",
+ "WM_MDIREFRESHMENU",
+ "565",
+ "566",
+ "567",
+ "568",
+ "569",
+ "570",
+ "571",
+ "572",
+ "573",
+ "574",
+ "575",
+ "576",
+ "577",
+ "578",
+ "579",
+ "580",
+ "581",
+ "582",
+ "583",
+ "584",
+ "585",
+ "586",
+ "587",
+ "588",
+ "589",
+ "590",
+ "591",
+ "592",
+ "593",
+ "594",
+ "595",
+ "596",
+ "597",
+ "598",
+ "599",
+ "600",
+ "601",
+ "602",
+ "603",
+ "604",
+ "605",
+ "606",
+ "607",
+ "608",
+ "609",
+ "610",
+ "611",
+ "612",
+ "613",
+ "614",
+ "615",
+ "616",
+ "617",
+ "618",
+ "619",
+ "620",
+ "621",
+ "622",
+ "623",
+ "624",
+ "625",
+ "626",
+ "627",
+ "628",
+ "629",
+ "630",
+ "631",
+ "632",
+ "633",
+ "634",
+ "635",
+ "636",
+ "637",
+ "638",
+ "639",
+ "640",
+ "WM_IME_SETCONTEXT",
+ "WM_IME_NOTIFY",
+ "WM_IME_CONTROL",
+ "WM_IME_COMPOSITIONFULL",
+ "WM_IME_SELECT",
+ "WM_IME_CHAR",
+ "647",
+ "648",
+ "649",
+ "650",
+ "651",
+ "652",
+ "653",
+ "654",
+ "655",
+ "WM_IME_KEYDOWN",
+ "WM_IME_KEYUP",
+ "658",
+ "659",
+ "660",
+ "661",
+ "662",
+ "663",
+ "664",
+ "665",
+ "666",
+ "667",
+ "668",
+ "669",
+ "670",
+ "671",
+ "672",
+ "WM_MOUSEHOVER",
+ "674",
+ "WM_MOUSELEAVE",
+ "676",
+ "677",
+ "678",
+ "679",
+ "680",
+ "681",
+ "682",
+ "683",
+ "684",
+ "685",
+ "686",
+ "687",
+ "688",
+ "689",
+ "690",
+ "691",
+ "692",
+ "693",
+ "694",
+ "695",
+ "696",
+ "697",
+ "698",
+ "699",
+ "700",
+ "701",
+ "702",
+ "703",
+ "704",
+ "705",
+ "706",
+ "707",
+ "708",
+ "709",
+ "710",
+ "711",
+ "712",
+ "713",
+ "714",
+ "715",
+ "716",
+ "717",
+ "718",
+ "719",
+ "720",
+ "721",
+ "722",
+ "723",
+ "724",
+ "725",
+ "726",
+ "727",
+ "728",
+ "729",
+ "730",
+ "731",
+ "732",
+ "733",
+ "734",
+ "735",
+ "736",
+ "737",
+ "738",
+ "739",
+ "740",
+ "741",
+ "742",
+ "743",
+ "744",
+ "745",
+ "746",
+ "747",
+ "748",
+ "749",
+ "750",
+ "751",
+ "752",
+ "753",
+ "754",
+ "755",
+ "756",
+ "757",
+ "758",
+ "759",
+ "760",
+ "761",
+ "762",
+ "763",
+ "764",
+ "765",
+ "766",
+ "767",
+ "WM_CUT",
+ "WM_COPY",
+ "WM_PASTE",
+ "WM_CLEAR",
+ "WM_UNDO",
+ "WM_RENDERFORMAT",
+ "WM_RENDERALLFORMATS",
+ "WM_DESTROYCLIPBOARD",
+ "WM_DRAWCLIPBOARD",
+ "WM_PAINTCLIPBOARD",
+ "WM_VSCROLLCLIPBOARD",
+ "WM_SIZECLIPBOARD",
+ "WM_ASKCBFORMATNAME",
+ "WM_CHANGECBCHAIN",
+ "WM_HSCROLLCLIPBOARD",
+ "WM_QUERYNEWPALETTE",
+ "WM_PALETTEISCHANGING",
+ "WM_PALETTECHANGED",
+ "WM_HOTKEY",
+ "787",
+ "788",
+ "789",
+ "790",
+ "WM_PRINT",
+ "WM_PRINTCLIENT",
+ "793",
+ "794",
+ "795",
+ "796",
+ "797",
+ "798",
+ "799",
+ "800",
+ "801",
+ "802",
+ "803",
+ "804",
+ "805",
+ "806",
+ "807",
+ "808",
+ "809",
+ "810",
+ "811",
+ "812",
+ "813",
+ "814",
+ "815",
+ "816",
+ "817",
+ "818",
+ "819",
+ "820",
+ "821",
+ "822",
+ "823",
+ "824",
+ "825",
+ "826",
+ "827",
+ "828",
+ "829",
+ "830",
+ "831",
+ "832",
+ "833",
+ "834",
+ "835",
+ "836",
+ "837",
+ "838",
+ "839",
+ "840",
+ "841",
+ "842",
+ "843",
+ "844",
+ "845",
+ "846",
+ "847",
+ "848",
+ "849",
+ "850",
+ "851",
+ "852",
+ "853",
+ "854",
+ "855",
+ "856",
+ "857",
+ "858",
+ "859",
+ "860",
+ "861",
+ "862",
+ "863",
+ "864",
+ "865",
+ "866",
+ "867",
+ "868",
+ "869",
+ "870",
+ "871",
+ "872",
+ "873",
+ "874",
+ "875",
+ "876",
+ "877",
+ "878",
+ "879",
+ "880",
+ "881",
+ "882",
+ "883",
+ "884",
+ "885",
+ "886",
+ "887",
+ "888",
+ "889",
+ "890",
+ "891",
+ "892",
+ "893",
+ "894",
+ "895",
+ "896",
+ "897",
+ "898",
+ "899",
+ "900",
+ "901",
+ "902",
+ "903",
+ "904",
+ "905",
+ "906",
+ "907",
+ "908",
+ "909",
+ "910",
+ "911",
+ "912",
+ "913",
+ "914",
+ "915",
+ "916",
+ "917",
+ "918",
+ "919",
+ "920",
+ "921",
+ "922",
+ "923",
+ "924",
+ "925",
+ "926",
+ "927",
+ "928",
+ "929",
+ "930",
+ "931",
+ "932",
+ "933",
+ "934",
+ "935",
+ "936",
+ "937",
+ "938",
+ "939",
+ "940",
+ "941",
+ "942",
+ "943",
+ "944",
+ "945",
+ "946",
+ "947",
+ "948",
+ "949",
+ "950",
+ "951",
+ "952",
+ "953",
+ "954",
+ "955",
+ "956",
+ "957",
+ "958",
+ "959",
+ "960",
+ "961",
+ "962",
+ "963",
+ "964",
+ "965",
+ "966",
+ "967",
+ "968",
+ "969",
+ "970",
+ "971",
+ "972",
+ "973",
+ "974",
+ "975",
+ "976",
+ "977",
+ "978",
+ "979",
+ "980",
+ "981",
+ "982",
+ "983",
+ "984",
+ "985",
+ "986",
+ "987",
+ "988",
+ "989",
+ "990",
+ "991",
+ "992",
+ "993",
+ "994",
+ "995",
+ "996",
+ "997",
+ "998",
+ "999",
+ "1000",
+ "1001",
+ "1002",
+ "1003",
+ "1004",
+ "1005",
+ "1006",
+ "1007",
+ "1008",
+ "1009",
+ "1010",
+ "1011",
+ "1012",
+ "1013",
+ "1014",
+ "1015",
+ "1016",
+ "1017",
+ "1018",
+ "1019",
+ "1020",
+ "1021",
+ "1022",
+ "1023"
+};
+
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/util.h b/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/util.h
new file mode 100644
index 000000000..cd21da657
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/util.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+#ifndef __UTIL_H__
+#define __UTIL_H__
+
+#include <windows.h>
+#include <stdexcept>
+
+
+class win32_error : public std::runtime_error
+{
+ public:
+ static std::string message(DWORD code);
+ DWORD errorcode;
+ win32_error(const std::string &msg,DWORD code = GetLastError()) : std::runtime_error(msg + ":" + message(code)), errorcode(code) {};
+};
+
+#define MESSAGE_NAMES_LEN 1024
+#define NOTIFY_NAMES_LEN 0
+class MessageDebug
+{
+ protected:
+ static const char * message_names[MESSAGE_NAMES_LEN];
+ static const char * notify_names[NOTIFY_NAMES_LEN];
+ public:
+ static void debug(HWND handle, UINT uMsg, WPARAM wParam, LPARAM lParam, const char *prefix);
+};
+
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/window.cc b/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/window.cc
new file mode 100755
index 000000000..cca3a485a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/window.cc
@@ -0,0 +1,284 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+
+#include "window.h"
+#include "util.h"
+#include <stdio.h>
+#include <stdexcept>
+
+CWindow::CWindowClass CWindow::windowClass("CWINDOWCLASS", DefWindowProc);
+
+CWindow::CWindowClass::CWindowClass(const char *_name, WNDPROC _wndproc) :
+ wndproc(_wndproc), atom(0), classname(_name)
+{
+ Register();
+}
+
+CWindow::CWindowClass::~CWindowClass()
+{
+ UnregisterClass(classname.c_str(), GetModuleHandle(NULL));
+}
+
+void CWindow::CWindowClass::Register()
+{
+ WNDCLASSEX wndclass;
+ memset(&wndclass, 0, sizeof(wndclass));
+ wndclass.cbSize = sizeof(wndclass);
+ wndclass.style = 0;
+ wndclass.lpfnWndProc = wndproc;
+ wndclass.cbClsExtra = 0;
+ wndclass.cbWndExtra = 0;
+ wndclass.hInstance = GetModuleHandle(NULL);
+ wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
+ wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wndclass.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
+ wndclass.lpszMenuName = NULL;
+ wndclass.lpszClassName = classname.c_str();
+ wndclass.hIconSm = NULL;
+ atom = RegisterClassEx(&wndclass);
+ if (atom == 0)
+ throw win32_error("RegisterClassEx failed");
+}
+
+CWindow::CWindow(const char *_title) : title(_title), hwnd(NULL), parent(NULL), bounds(), owndproc(NULL), showing(FALSE)
+{
+ style = WS_CHILD;
+ exstyle = 0;
+}
+
+HWND CWindow::CreateWindowHandle()
+{
+ HWND ret = CreateWindowEx(
+ exstyle,
+ GetClassName(),
+ title.c_str(),
+ style,
+ bounds.left,
+ bounds.top,
+ bounds.width,
+ bounds.height,
+ parent,
+ NULL,
+ GetModuleHandle(NULL),
+ 0
+ );
+ if (ret == NULL)
+ throw win32_error("CreateWindowEx failed");
+ return ret;
+}
+
+void CWindow::Create()
+{
+ if (hwnd != NULL)
+ return;
+ hwnd = CreateWindowHandle();
+ if (hwnd == NULL)
+ throw win32_error("Could not create window");
+
+ // Reset the error code
+ DWORD err = 0;
+ SetLastError(err);
+
+ // Attach the object reference to the window handle
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)this);
+ err = GetLastError();
+ if (err != 0)
+ throw win32_error("SetWindowLongPtr failed",err);
+
+ // Set the window proc
+ owndproc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)WindowProc);
+ err = GetLastError();
+ if (err != 0)
+ throw win32_error("SetWindowLongPtr failed",err);
+}
+
+const char *CWindow::GetClassName()
+{
+ return windowClass.GetClassName();
+}
+
+LRESULT CALLBACK CWindow::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ MessageDebug::debug(hwnd, uMsg, wParam, lParam, __FUNCTION__);
+ CWindow* window = (CWindow*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ if (window != NULL)
+ return window->Dispatch(hwnd, uMsg, wParam, lParam);
+ return DefWindowProc(hwnd, uMsg, wParam, lParam);
+}
+
+LRESULT CWindow::Dispatch(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch (uMsg)
+ {
+ case WM_SIZE:
+ bounds.width = LOWORD(lParam);
+ bounds.height = LOWORD(lParam);
+ break;
+ case WM_MOVE:
+ bounds.left = LOWORD(lParam);
+ bounds.top = LOWORD(lParam);
+ break;
+ case WM_DESTROY:
+ showing = FALSE;
+ break;
+ }
+ if (owndproc)
+ return CallWindowProc(owndproc, hwnd, uMsg, wParam, lParam);
+ else
+ return DefWindowProc(hwnd, uMsg, wParam, lParam);
+}
+
+void CWindow::Show()
+{
+ if (hwnd == NULL)
+ Create();
+ ShowWindow(hwnd, SW_SHOWNORMAL);
+}
+
+int CWindow::ShowModal()
+{
+ MSG msg;
+ BOOL bRet;
+ showing = TRUE;
+ Show();
+
+ while( showing && (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
+ {
+ if (bRet == -1)
+ {
+ // handle the error and possibly exit
+ }
+ else
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+ return 0;
+}
+
+void CWindow::SetLeft(int left)
+{
+ bounds.left = left;
+ if (hwnd)
+ if (!SetWindowPos(hwnd, NULL,
+ bounds.left, bounds.top,
+ 0, 0,
+ SWP_NOZORDER | SWP_NOSIZE))
+ throw win32_error("SetWindowPos failed");
+}
+
+void CWindow::SetTop(int top)
+{
+ bounds.top = top;
+ if (hwnd)
+ if (!SetWindowPos(hwnd, NULL,
+ bounds.left, bounds.top,
+ 0, 0,
+ SWP_NOZORDER | SWP_NOSIZE))
+ throw win32_error("SetWindowPos failed");
+}
+
+void CWindow::SetWidth(int width)
+{
+ bounds.width = width;
+ if (hwnd)
+ if (!SetWindowPos(hwnd, NULL,
+ 0, 0,
+ bounds.width, bounds.height,
+ SWP_NOZORDER | SWP_NOMOVE))
+ throw win32_error("SetWindowPos failed");
+}
+void CWindow::SetHeight(int height)
+{
+ bounds.height = height;
+ if (hwnd)
+ if (!SetWindowPos(hwnd, NULL,
+ 0, 0,
+ bounds.width, bounds.height,
+ SWP_NOZORDER | SWP_NOMOVE))
+ throw win32_error("SetWindowPos failed");
+}
+
+void CWindow::SetBounds(int left, int top, int width, int height)
+{
+ bounds = CBoundary(left, top, width, height);
+ if (hwnd)
+ if (!SetWindowPos(hwnd, NULL,
+ bounds.left, bounds.top,
+ bounds.width, bounds.height,
+ SWP_NOZORDER))
+ throw win32_error("SetWindowPos failed");
+}
+
+void CWindow::SetBounds(const RECT &rect)
+{
+ bounds = rect;
+ if (hwnd)
+ if (!SetWindowPos(hwnd, NULL,
+ bounds.left, bounds.top,
+ bounds.width, bounds.height,
+ SWP_NOZORDER))
+ throw win32_error("SetWindowPos failed");
+}
+
+HWND CWindow::GetHandle()
+{
+ if (hwnd == NULL)
+ Create();
+ return hwnd;
+}
+
+void CWindow::SetParent(CWindow *window)
+{
+ parent = window->GetHandle();
+ if (hwnd != NULL)
+ if (::SetParent(hwnd, parent) == NULL)
+ throw win32_error("SetParent failed");
+
+}
+
+void CWindow::SetStyle(DWORD style)
+{
+ this->style = style;
+ SetLastError(0);
+ if (hwnd)
+ SetWindowLong(hwnd, GWL_STYLE, style);
+ int err = GetLastError();
+ if (err != 0)
+ throw win32_error("SetWindowLong failed", err);
+}
+
+void CWindow::SetExStyle(DWORD exstyle)
+{
+ this->exstyle = exstyle;
+ SetLastError(0);
+ if (hwnd)
+ SetWindowLong(hwnd, GWL_EXSTYLE, exstyle);
+ int err = GetLastError();
+ if (err != 0)
+ throw win32_error("SetWindowWLong failed", err);
+}
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/window.h b/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/window.h
new file mode 100755
index 000000000..baf401405
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/window.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+#ifndef __WINDOW_H__
+#define __WINDOW_H__
+
+#include <windows.h>
+#include <string>
+
+class CDialog;
+class CWindow
+{
+ friend class CDialog;
+ public:
+ struct CBoundary
+ {
+ int left;
+ int top;
+ int width;
+ int height;
+ CBoundary() :
+ left(0), top(0), width(0), height(0) {};
+ CBoundary(int x, int y, int w, int h) :
+ left(x), top(y), width(w), height(h) {};
+ CBoundary(const RECT &r) :
+ left(r.left), top(r.top), width(r.right-r.left), height(r.bottom-r.top) {};
+ };
+ class CWindowClass
+ {
+ private:
+ WNDPROC wndproc;
+ ATOM atom;
+ std::string classname;
+ protected:
+ void Register();
+ public:
+ CWindowClass(const char *name, WNDPROC wndproc);
+ ~CWindowClass();
+ const char *GetClassName() { return classname.c_str(); };
+ };
+ private:
+ static CWindowClass windowClass;
+
+ std::string title;
+ DWORD exstyle;
+ DWORD style;
+ CBoundary bounds;
+ HWND hwnd;
+ HWND parent;
+ WNDPROC owndproc;
+
+ BOOL showing;
+
+ protected:
+
+ virtual const char *GetClassName();
+ virtual HWND CreateWindowHandle();
+ static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ public:
+ CWindow(const char *title);
+ virtual void Create();
+
+ virtual int ShowModal();
+
+ void Show();
+ void Hide();
+
+ void SetWidth(int width);
+ void SetHeight(int height);
+ void SetLeft(int left);
+ void SetTop(int top);
+ int GetWidth() { return bounds.width; };
+ int GetHeight() { return bounds.height; };
+ int GetLeft() { return bounds.left; };
+ int GetTop() { return bounds.top; };
+
+ void SetBounds(int left, int top, int width, int height);
+ void SetBounds(const RECT &rect);
+
+ void SetStyle(DWORD style);
+ DWORD GetStyle() { return style; };
+
+ void SetExStyle(DWORD exstyle);
+ DWORD GetExStyle() { return exstyle; };
+
+ HWND GetHandle();
+ void SetParent(CWindow *window);
+
+ virtual LRESULT Dispatch(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+};
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/wizard.cc b/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/wizard.cc
new file mode 100755
index 000000000..9d6c71193
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/wizard.cc
@@ -0,0 +1,244 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+#include "wizard.h"
+#include "util.h"
+
+CWizard::CWizard() : pages()
+{
+};
+
+void CWizard::AddPage(const PROPSHEETPAGE &page)
+{
+ pages.push_back(page);
+}
+
+void CWizard::AddPage(const char *page, HINSTANCE instance)
+{
+ PROPSHEETPAGE psp;
+ if (instance == NULL)
+ instance = GetModuleHandle(NULL);
+
+ memset(&psp, 0, sizeof(psp));
+ psp.dwSize = sizeof(PROPSHEETPAGE);
+ psp.dwFlags = PSP_DEFAULT;
+ psp.hInstance = instance;
+ psp.pszTemplate = page;
+ psp.pfnDlgProc = WizardDialogProc;
+ psp.lParam = (LPARAM)this;
+
+ AddPage(psp);
+}
+
+void CWizard::AddPage(DWORD id, DWORD title, DWORD subtitle, HINSTANCE instance)
+{
+ PROPSHEETPAGE psp;
+ if (instance == NULL)
+ instance = GetModuleHandle(NULL);
+
+ memset(&psp, 0, sizeof(psp));
+ psp.dwSize = sizeof(PROPSHEETPAGE);
+ psp.dwFlags = PSP_DEFAULT;
+#if _WIN32_IE >= 0x0500
+ if (title != 0)
+ {
+ psp.dwFlags |= PSP_USEHEADERTITLE;
+ psp.pszHeaderTitle = MAKEINTRESOURCE(title);
+ }
+ if (subtitle != 0)
+ {
+ psp.dwFlags |= PSP_USEHEADERSUBTITLE;
+ psp.pszHeaderSubTitle = MAKEINTRESOURCE(subtitle);
+ }
+#endif
+
+ psp.hInstance = instance;
+ psp.pszTemplate = MAKEINTRESOURCE(id);
+ psp.pfnDlgProc = WizardDialogProc;
+ psp.lParam = (LPARAM)this;
+
+ AddPage(psp);
+}
+
+HWND CWizard::CreateWindowHandle()
+{
+ PROPSHEETHEADER psh;
+ HWND ret;
+
+ PrepareSheetHeader(psh, FALSE);
+ ret = (HWND)PropertySheet(&psh);
+ free(psh.phpage);
+ if (ret == NULL)
+ throw win32_error("PropertySheet failed");
+ return ret;
+}
+
+int CWizard::ShowModal()
+{
+ PROPSHEETHEADER psh;
+ int ret;
+
+ PrepareSheetHeader(psh, TRUE);
+ ret = PropertySheet(&psh);
+ free(psh.phpage);
+ return ret;
+}
+
+void CWizard::PrepareSheetHeader(PROPSHEETHEADER &psh, BOOL modal)
+{
+ HPROPSHEETPAGE *phpage = (HPROPSHEETPAGE*)malloc(pages.size() * sizeof(HPROPSHEETPAGE));
+ DWORD modeflag;
+
+ if (modal)
+ modeflag = 0;
+ else
+ modeflag = PSH_MODELESS;
+
+ for (unsigned i = 0; i < pages.size(); i++)
+ {
+ phpage[i] = CreatePropertySheetPage(&pages[i]);
+ if (phpage[i] == NULL)
+ {
+ DWORD err = GetLastError();
+ free(phpage);
+ throw win32_error("CreatePropertySheetPage failed", err);
+ }
+ }
+
+ memset(&psh, 0, sizeof(psh));
+ psh.dwSize = sizeof(PROPSHEETHEADER);
+#if _WIN32_IE >= 0x0500
+ psh.dwFlags = PSH_WIZARD97 | modeflag;
+#else
+ psh.dwFlags = PSH_WIZARD | modeflag;
+#endif
+ psh.hwndParent = NULL;
+ psh.hInstance = GetModuleHandle(NULL);
+ psh.pszIcon = NULL;
+ psh.pszCaption = (LPSTR) "Cell Properties";
+ psh.nPages = pages.size();
+ psh.nStartPage = 0;
+ psh.phpage = phpage;
+ psh.pfnCallback = NULL;
+}
+
+DWORD CWizard::PageID(unsigned index)
+{
+ if (index < pages.size() && IS_INTRESOURCE(pages[index].pszTemplate))
+ return (DWORD)pages[index].pszTemplate;
+ return (DWORD)-1;
+}
+
+unsigned CWizard::PageIndex(PROPSHEETPAGE *psp)
+{
+ for (unsigned i = 0; i < pages.size(); i++)
+ {
+ if (IS_INTRESOURCE(psp->pszTemplate) || IS_INTRESOURCE(pages[i].pszTemplate ))
+ {
+ if (psp->pszTemplate == pages[i].pszTemplate)
+ return i;
+ }
+ else if (psp->pszTemplate && pages[i].pszTemplate)
+ {
+ if (strcmp(psp->pszTemplate, pages[i].pszTemplate) == 0)
+ return i;
+ }
+ }
+ return (unsigned)-1;
+}
+
+INT_PTR CWizard::DlgDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ return CBaseDialog::DlgDispatch(hwndDlg, uMsg, wParam, lParam);
+}
+
+INT_PTR CWizard::PageDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, PROPSHEETPAGE *psp)
+{
+ LPNMHDR pnmh = (LPNMHDR)lParam;
+ DWORD flags;
+ unsigned pageindex;
+ switch (uMsg)
+ {
+ case WM_NOTIFY:
+ switch (pnmh->code)
+ {
+ case PSN_SETACTIVE:
+#ifdef _DEBUG
+ printf("PSN_SETACTIVE %d\n", PageIndex(psp));
+#endif
+ pageindex = PageIndex(psp);
+ if (pageindex != (unsigned)-1)
+ {
+ flags = 0;
+ if (pageindex > 0)
+ flags |= PSWIZB_BACK;
+ if ((unsigned)pageindex + 1 == pages.size())
+ flags |= PSWIZB_FINISH;
+ if ((unsigned)pageindex + 1 < pages.size())
+ flags |= PSWIZB_NEXT;
+ PropSheet_SetWizButtons(GetParent(hwndDlg), flags);
+ }
+ WizardActivate(hwndDlg, pageindex);
+ break;
+ case PSN_WIZNEXT:
+ if (WizardNext(hwndDlg, PageIndex(psp)))
+ return TRUE;
+ break;
+ case PSN_WIZBACK:
+ if (WizardBack(hwndDlg, PageIndex(psp)))
+ return TRUE;
+ break;
+ case PSN_WIZFINISH:
+ if (WizardFinish(hwndDlg, PageIndex(psp)))
+ return TRUE;
+ DestroyWindow(GetParent(hwndDlg));
+ case PSN_RESET:
+ if (WizardReset(hwndDlg, PageIndex(psp)))
+ return TRUE;
+ DestroyWindow(GetParent(hwndDlg));
+ break;
+ }
+ }
+ return DlgDispatch(hwndDlg, uMsg, wParam, lParam);
+}
+
+
+INT_PTR CALLBACK CWizard::WizardDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ MessageDebug::debug(hwndDlg, uMsg, wParam, lParam, __FUNCTION__);
+ PROPSHEETPAGE *psp = (PROPSHEETPAGE*)lParam;
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)psp);
+ break;
+ }
+ psp = (PROPSHEETPAGE*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ CWizard* wizard = psp?(CWizard*)psp->lParam:NULL;
+ if (wizard != NULL)
+ return wizard->PageDispatch(hwndDlg, uMsg, wParam, lParam, psp);
+ return FALSE;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/wizard.h b/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/wizard.h
new file mode 100755
index 000000000..a2361c51c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xwin/xlaunch/window/wizard.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+#ifndef __WIZARD_H__
+#define __WIZARD_H__
+
+#include "dialog.h"
+#include <vector>
+
+#define _WIN32_IE 0x0500
+#include <prsht.h>
+
+class CWizard : public CBaseDialog
+{
+ private:
+ std::vector<PROPSHEETPAGE> pages;
+ void PrepareSheetHeader(PROPSHEETHEADER &psh, BOOL modal);
+ protected:
+ virtual HWND CreateWindowHandle();
+ static INT_PTR CALLBACK WizardDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ virtual INT_PTR DlgDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ virtual INT_PTR PageDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, PROPSHEETPAGE *psp);
+ virtual unsigned PageIndex(PROPSHEETPAGE *psp);
+ virtual DWORD PageID(unsigned index);
+ virtual BOOL WizardNext(HWND hwndDlg, unsigned index) { return FALSE; }
+ virtual BOOL WizardBack(HWND hwndDlg, unsigned index) { return FALSE; }
+ virtual BOOL WizardFinish(HWND hwndDlg, unsigned index) { return FALSE; }
+ virtual BOOL WizardReset(HWND hwndDlg, unsigned index) { return FALSE; }
+ virtual BOOL WizardActivate(HWND hwndDlg, unsigned index) { return FALSE; }
+ public:
+ CWizard();
+ void AddPage(const PROPSHEETPAGE &page);
+ void AddPage(const char *page, HINSTANCE instance = NULL);
+ void AddPage(DWORD id, DWORD title, DWORD subtitle, HINSTANCE instance = NULL);
+ virtual int ShowModal();
+};
+#endif
diff --git a/nx-X11/programs/Xserver/ilbm/Imakefile b/nx-X11/programs/Xserver/ilbm/Imakefile
new file mode 100644
index 000000000..ed763788f
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/Imakefile
@@ -0,0 +1,63 @@
+XCOMM $XFree86: xc/programs/Xserver/ilbm/Imakefile,v 3.6tsi Exp $
+XCOMM $XConsortium: Imakefile,v 1.38 94/03/11 18:47:47 dpw Exp $
+#define IHaveModules
+#include <Server.tmpl>
+
+SRCS1 = ilbmgc.c ilbmwindow.c ilbmfont.c ilbmfillrct.c ilbmpntwin.c \
+ ilbmpixmap.c ilbmimage.c ilbmline.c ilbmbres.c ilbmhrzvert.c \
+ ilbmbresd.c ilbmpushpxl.c ilbmzerarc.c ilbmfillarc.c ilbmfillsp.c \
+ ilbmsetsp.c ilbmscrinit.c ilbmclip.c ilbmbitblt.c ilbmgetsp.c \
+ ilbmpolypnt.c ilbmbltC.c ilbmbltX.c ilbmbltCI.c ilbmbltO.c \
+ ilbmbltG.c ilbmcmap.c ilbmtileC.c ilbmtileG.c ilbmmisc.c ilbmbstore.c
+
+SRCS = $(SRCS1) ilbmseg.c ilbmbltC.c ilbmbltX.c ilbmbltCI.c ilbmbltO.c \
+ ilbmbltG.c ilbmtileC.c ilbmtileG.c
+
+OBJS = ilbmgc.o ilbmwindow.o ilbmfont.o ilbmpixmap.o ilbmfillsp.o \
+ ilbmsetsp.o ilbmscrinit.o ilbmclip.o ilbmbitblt.o ilbmgetsp.o \
+ ilbmbltC.o ilbmbltX.o ilbmbltCI.o ilbmbltO.o ilbmbltG.o ilbmcmap.o \
+ ilbmimage.o ilbmzerarc.o ilbmfillarc.o ilbmply1rct.o ilbmtileC.o \
+ ilbmtileG.o ilbmfillrct.o ilbmpolypnt.o ilbmmisc.o ilbmbstore.o \
+ ilbmbresd.o ilbmimggblt.o ilbmpushpxl.o ilbmplygblt.o ilbmtegblt.o \
+ ilbmpntwin.o ilbmpntarea.o ilbmbres.o ilbmhrzvert.o ilbmline.o \
+ ilbmseg.o
+
+INCLUDES = -I. -I../cfb -I../mfb -I../mi -I../include -I$(XINCLUDESRC) \
+ -I$(FONTINCSRC) $(EXTRAINCLUDES)
+LINTDEFS = -DMFBPOLYGLYPHBLT=ilbmPolyGlyphBltWhite \
+ -DMFBIMAGEGLYPHBLT=ilbmImageGlyphBltWhite \
+ -DEQWHOLEWORD=MFB_EQWHOLEWORD_WHITE -DOPEQ=MFB_OPEQ_WHITE
+
+LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln \
+ ../mfb/llib-lmfb.ln ../mi/llib-lmi.ln
+
+NormalLibraryObjectRule()
+LibraryModuleTarget(ilbm,$(OBJS))
+LintLibraryTarget(ilbm,$(SRCS1))
+NormalLintTarget($(LINTDEFS) $(SRCS1))
+
+ObjectFromSpecialSource(ilbmseg,ilbmline,-DPOLYSEGMENT)
+
+ObjectFromSpecialSource(ilbmbltC,ilbmblt,-DMROP=Mcopy)
+
+ObjectFromSpecialSource(ilbmbltX,ilbmblt,-DMROP=Mxor)
+
+ObjectFromSpecialSource(ilbmbltCI,ilbmblt,-DMROP=McopyInverted)
+
+ObjectFromSpecialSource(ilbmbltO,ilbmblt,-DMROP=Mor)
+
+ObjectFromSpecialSource(ilbmbltG,ilbmblt,-DMROP=0)
+
+ObjectFromSpecialSource(ilbmtileC,ilbmtile,-DMROP=Mcopy)
+
+ObjectFromSpecialSource(ilbmtileG,ilbmtile,-DMROP=0)
+
+#if DoLoadableServer
+InstallDynamicModule(LibraryTargetName(ilbm),$(MODULEDIR),.)
+#endif
+
+#ifndef OS2Architecture
+DependTarget()
+#endif
+
+InstallDriverSDKDynamicModule(LibraryTargetName(ilbm),$(DRIVERSDKMODULEDIR))
diff --git a/nx-X11/programs/Xserver/ilbm/README b/nx-X11/programs/Xserver/ilbm/README
new file mode 100644
index 000000000..5b43f670c
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/README
@@ -0,0 +1,17 @@
+
+ ilbm -- Interleaved bitplanes for Amiga
+ © Copyright 1995 by Geert Uytterhoeven and Others (read the sources)
+
+All stuff in this directory is based on Xdaniver, which is based on mfb (read
+../afb/Xdaniver.doc).
+
+I made changes to support the interleaved mode of the Linux/68k Amiga Color
+Frame Buffer Device, which uses interleaved bitplanes instead of normal
+bitplanes.
+
+Note: there are still some annoying bugs left in ilbmimage.
+
+--
+Geert Uytterhoeven Geert.Uytterhoeven@cs.kuleuven.ac.be
+Wavelets, Linux/m68k on Amiga http://www.cs.kuleuven.ac.be/~geert/
+Department of Computer Science -- Katholieke Universiteit Leuven -- Belgium
diff --git a/nx-X11/programs/Xserver/ilbm/ilbm.h b/nx-X11/programs/Xserver/ilbm/ilbm.h
new file mode 100644
index 000000000..eba35c200
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbm.h
@@ -0,0 +1,1051 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbm.h,v 3.2 1998/04/05 16:42:23 robin Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbm.h,v 5.31 94/04/17 20:28:15 dpw Exp $ */
+/* Monochrome Frame Buffer definitions
+ written by drewry, september 1986
+*/
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "pixmap.h"
+#include "region.h"
+#include "gc.h"
+#include "colormap.h"
+#include "miscstruct.h"
+#include "mibstore.h"
+
+extern int ilbmInverseAlu[];
+extern int ilbmScreenPrivateIndex;
+/* warning: PixelType definition duplicated in maskbits.h */
+#ifndef PixelType
+#define PixelType unsigned long
+#endif /* PixelType */
+
+#define AFB_MAX_DEPTH 8
+
+/* ilbmbitblt.c */
+
+extern void ilbmDoBitblt(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+
+extern RegionPtr ilbmBitBlt(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ GCPtr /*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ void (*doBitBlt)(),
+ unsigned long /*planemask*/
+);
+
+extern RegionPtr ilbmCopyArea(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr/*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/
+);
+
+extern RegionPtr ilbmCopyPlane(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr/*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ unsigned long /*plane*/
+);
+
+extern void ilbmCopy1ToN(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* ilbmbltC.c */
+
+extern void ilbmDoBitbltCopy(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* ilbmbltCI.c */
+
+extern void ilbmDoBitbltCopyInverted(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* ilbmbltG.c */
+
+extern void ilbmDoBitbltGeneral(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* ilbmbltO.c */
+
+extern void ilbmDoBitbltOr(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* ilbmbltX.c */
+
+extern void ilbmDoBitbltXor(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* ilbmbres.c */
+
+extern void ilbmBresS(
+ PixelType * /*addrl*/,
+ int /*nlwidth*/,
+ int /*sizeDst*/,
+ int /*depthDst*/,
+ int /*signdx*/,
+ int /*signdy*/,
+ int /*axis*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*e*/,
+ int /*e1*/,
+ int /*e2*/,
+ int /*len*/,
+ unsigned char * /*rrops*/
+);
+/* ilbmbresd.c */
+
+extern void ilbmBresD(
+ int * /*pdashIndex*/,
+ unsigned char * /*pDash*/,
+ int /*numInDashList*/,
+ int * /*pdashOffset*/,
+ int /*isDoubleDash*/,
+ PixelType * /*addrl*/,
+ int /*nlwidth*/,
+ int /*sizeDst*/,
+ int /*depthDst*/,
+ int /*signdx*/,
+ int /*signdy*/,
+ int /*axis*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*e*/,
+ int /*e1*/,
+ int /*e2*/,
+ int /*len*/,
+ unsigned char * /*rrops*/,
+ unsigned char * /*bgrrops*/
+);
+/* ilbmbstore.c */
+
+extern void ilbmSaveAreas(
+ PixmapPtr /*pPixmap*/,
+ RegionPtr /*prgnSave*/,
+ int /*xorg*/,
+ int /*yorg*/,
+ WindowPtr /*pWin*/
+);
+
+extern void ilbmRestoreAreas(
+ PixmapPtr /*pPixmap*/,
+ RegionPtr /*prgnRestore*/,
+ int /*xorg*/,
+ int /*yorg*/,
+ WindowPtr /*pWin*/
+);
+/* ilbmclip.c */
+
+extern RegionPtr ilbmPixmapToRegion(
+ PixmapPtr /*pPix*/
+);
+
+/* ilbmcmap.c */
+
+extern Bool ilbmInitializeColormap(
+ ColormapPtr /*pmap*/
+);
+
+extern void ilbmResolveColor(
+ unsigned short * /*pred*/,
+ unsigned short * /*pgreen*/,
+ unsigned short * /*pblue*/,
+ VisualPtr /*pVisual*/
+);
+
+extern Bool ilbmSetVisualTypes(
+ int /*depth*/,
+ int /*visuals*/,
+ int /*bitsPerRGB*/
+);
+
+/* ilbmfillarc.c */
+
+extern void ilbmPolyFillArcSolid(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+/* ilbmfillrct.c */
+
+extern void ilbmPolyFillRect(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nrectFill*/,
+ xRectangle * /*prectInit*/
+);
+
+/* ilbmply1rct.c */
+extern void ilbmFillPolygonSolid(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*shape*/,
+ int /*count*/,
+ DDXPointPtr /*ptsIn*/
+);
+
+/* ilbmfillsp.c */
+
+extern void ilbmSolidFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void ilbmStippleFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void ilbmTileFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void ilbmUnnaturalTileFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void ilbmUnnaturalStippleFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void ilbmOpaqueStippleFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void ilbmUnnaturalOpaqueStippleFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+/* ilbmfont.c */
+
+extern Bool ilbmRealizeFont(
+ ScreenPtr /*pscr*/,
+ FontPtr /*pFont*/
+);
+
+extern Bool ilbmUnrealizeFont(
+ ScreenPtr /*pscr*/,
+ FontPtr /*pFont*/
+);
+/* ilbmgc.c */
+
+extern Bool ilbmCreateGC(
+ GCPtr /*pGC*/
+);
+
+extern void ilbmValidateGC(
+ GCPtr /*pGC*/,
+ unsigned long /*changes*/,
+ DrawablePtr /*pDrawable*/
+);
+
+extern void ilbmDestroyGC(
+ GCPtr /*pGC*/
+);
+
+extern void ilbmReduceRop(
+ int /*alu*/,
+ Pixel /*src*/,
+ unsigned long /*planemask*/,
+ int /*depth*/,
+ unsigned char * /*rrops*/
+);
+
+extern void ilbmReduceOpaqueStipple (
+ Pixel /*fg*/,
+ Pixel /*bg*/,
+ unsigned long /*planemask*/,
+ int /*depth*/,
+ unsigned char * /*rrops*/
+);
+
+extern void ilbmComputeCompositeClip(
+ GCPtr /*pGC*/,
+ DrawablePtr /*pDrawable*/
+);
+
+/* ilbmgetsp.c */
+
+extern void ilbmGetSpans(
+ DrawablePtr /*pDrawable*/,
+ int /*wMax*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ int /*nspans*/,
+ char * /*pdstStart*/
+);
+/* ilbmhrzvert.c */
+
+extern int ilbmHorzS(
+ PixelType * /*addrl*/,
+ int /*nlwidth*/,
+ int /*sizeDst*/,
+ int /*depthDst*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*len*/,
+ unsigned char * /*rrops*/
+);
+
+extern int ilbmVertS(
+ PixelType * /*addrl*/,
+ int /*nlwidth*/,
+ int /*sizeDst*/,
+ int /*depthDst*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*len*/,
+ unsigned char * /*rrops*/
+);
+/* ilbmigbblak.c */
+
+extern void ilbmImageGlyphBlt (
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* ilbmigbwht.c */
+
+/* ilbmimage.c */
+
+extern void ilbmPutImage(
+ DrawablePtr /*dst*/,
+ GCPtr /*pGC*/,
+ int /*depth*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ int /*leftPad*/,
+ int /*format*/,
+ char * /*pImage*/
+);
+
+extern void ilbmGetImage(
+ DrawablePtr /*pDrawable*/,
+ int /*sx*/,
+ int /*sy*/,
+ int /*w*/,
+ int /*h*/,
+ unsigned int /*format*/,
+ unsigned long /*planeMask*/,
+ char * /*pdstLine*/
+);
+/* ilbmline.c */
+
+extern void ilbmLineSS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/
+);
+
+extern void ilbmLineSD(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/
+);
+
+/* ilbmmisc.c */
+
+extern void ilbmQueryBestSize(
+ int /*class*/,
+ unsigned short * /*pwidth*/,
+ unsigned short * /*pheight*/,
+ ScreenPtr /*pScreen*/
+);
+/* ilbmpntarea.c */
+
+extern void ilbmSolidFillArea(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ unsigned char * /*rrops*/
+);
+
+extern void ilbmStippleAreaPPW(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ PixmapPtr /*pstipple*/,
+ unsigned char * /*rrops*/
+);
+extern void ilbmStippleArea(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ PixmapPtr /*pstipple*/,
+ int /*xOff*/,
+ int /*yOff*/,
+ unsigned char * /*rrops*/
+);
+/* ilbmplygblt.c */
+
+extern void ilbmPolyGlyphBlt(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+
+/* ilbmpixmap.c */
+
+extern PixmapPtr ilbmCreatePixmap(
+ ScreenPtr /*pScreen*/,
+ int /*width*/,
+ int /*height*/,
+ int /*depth*/
+);
+
+extern Bool ilbmDestroyPixmap(
+ PixmapPtr /*pPixmap*/
+);
+
+extern PixmapPtr ilbmCopyPixmap(
+ PixmapPtr /*pSrc*/
+);
+
+extern void ilbmPadPixmap(
+ PixmapPtr /*pPixmap*/
+);
+
+extern void ilbmXRotatePixmap(
+ PixmapPtr /*pPix*/,
+ int /*rw*/
+);
+
+extern void ilbmYRotatePixmap(
+ PixmapPtr /*pPix*/,
+ int /*rh*/
+);
+
+extern void ilbmCopyRotatePixmap(
+ PixmapPtr /*psrcPix*/,
+ PixmapPtr * /*ppdstPix*/,
+ int /*xrot*/,
+ int /*yrot*/
+);
+extern void ilbmPaintWindow(
+ WindowPtr /*pWin*/,
+ RegionPtr /*pRegion*/,
+ int /*what*/
+);
+/* ilbmpolypnt.c */
+
+extern void ilbmPolyPoint(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ xPoint * /*pptInit*/
+);
+/* ilbmpushpxl.c */
+
+extern void ilbmPushPixels(
+ GCPtr /*pGC*/,
+ PixmapPtr /*pBitMap*/,
+ DrawablePtr /*pDrawable*/,
+ int /*dx*/,
+ int /*dy*/,
+ int /*xOrg*/,
+ int /*yOrg*/
+);
+/* ilbmscrclse.c */
+
+extern Bool ilbmCloseScreen(
+ int /*index*/,
+ ScreenPtr /*pScreen*/
+);
+/* ilbmscrinit.c */
+
+extern Bool ilbmAllocatePrivates(
+ ScreenPtr /*pScreen*/,
+ int * /*pWinIndex*/,
+ int * /*pGCIndex*/
+);
+
+extern Bool ilbmScreenInit(
+ ScreenPtr /*pScreen*/,
+ pointer /*pbits*/,
+ int /*xsize*/,
+ int /*ysize*/,
+ int /*dpix*/,
+ int /*dpiy*/,
+ int /*width*/
+);
+
+extern PixmapPtr ilbmGetWindowPixmap(
+ WindowPtr /*pWin*/
+);
+
+extern void ilbmSetWindowPixmap(
+ WindowPtr /*pWin*/,
+ PixmapPtr /*pPix*/
+);
+
+/* ilbmseg.c */
+
+extern void ilbmSegmentSS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSeg*/
+);
+
+extern void ilbmSegmentSD(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSeg*/
+);
+/* ilbmsetsp.c */
+
+extern int ilbmSetScanline(
+ int /*y*/,
+ int /*xOrigin*/,
+ int /*xStart*/,
+ int /*xEnd*/,
+ PixelType * /*psrc*/,
+ int /*alu*/,
+ PixelType * /*pdstBase*/,
+ int /*widthDst*/,
+ int /*sizeDst*/,
+ int /*depthDst*/,
+ int /*sizeSrc*/
+);
+
+extern void ilbmSetSpans(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ char * /*psrc*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ int /*nspans*/,
+ int /*fSorted*/
+);
+/* ilbmtegblt.c */
+
+extern void ilbmTEGlyphBlt(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* ilbmtileC.c */
+
+extern void ilbmTileAreaPPWCopy(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/,
+ unsigned long /*planemask*/
+);
+/* ilbmtileG.c */
+
+extern void ilbmTileAreaPPWGeneral(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/,
+ unsigned long /*planemask*/
+);
+
+extern void ilbmTileAreaCopy(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/,
+ int /*xOff*/,
+ int /*yOff*/,
+ unsigned long /*planemask*/
+);
+/* ilbmtileG.c */
+
+extern void ilbmTileAreaGeneral(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/,
+ int /*xOff*/,
+ int /*yOff*/,
+ unsigned long /*planemask*/
+);
+
+extern void ilbmOpaqueStippleAreaPPWCopy(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/,
+ unsigned char */*rropsOS*/,
+ unsigned long /*planemask*/
+);
+/* ilbmtileG.c */
+
+extern void ilbmOpaqueStippleAreaPPWGeneral(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/,
+ unsigned char */*rropsOS*/,
+ unsigned long /*planemask*/
+);
+
+extern void ilbmOpaqueStippleAreaCopy(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/,
+ int /*xOff*/,
+ int /*yOff*/,
+ unsigned char */*rropsOS*/,
+ unsigned long /*planemask*/
+);
+/* ilbmtileG.c */
+
+extern void ilbmOpaqueStippleAreaGeneral(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/,
+ int /*xOff*/,
+ int /*yOff*/,
+ unsigned char */*rropsOS*/,
+ unsigned long /*planemask*/
+);
+
+/* ilbmwindow.c */
+
+extern Bool ilbmCreateWindow(
+ WindowPtr /*pWin*/
+);
+
+extern Bool ilbmDestroyWindow(
+ WindowPtr /*pWin*/
+);
+
+extern Bool ilbmMapWindow(
+ WindowPtr /*pWindow*/
+);
+
+extern Bool ilbmPositionWindow(
+ WindowPtr /*pWin*/,
+ int /*x*/,
+ int /*y*/
+);
+
+extern Bool ilbmUnmapWindow(
+ WindowPtr /*pWindow*/
+);
+
+extern void ilbmCopyWindow(
+ WindowPtr /*pWin*/,
+ DDXPointRec /*ptOldOrg*/,
+ RegionPtr /*prgnSrc*/
+);
+
+extern Bool ilbmChangeWindowAttributes(
+ WindowPtr /*pWin*/,
+ unsigned long /*mask*/
+);
+/* ilbmzerarc.c */
+
+extern void ilbmZeroPolyArcSS(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+
+/*
+ private field of pixmap
+ pixmap.devPrivate = (PixelType *)pointer_to_bits
+ pixmap.devKind = width_of_pixmap_in_bytes
+
+ private field of screen
+ a pixmap, for which we allocate storage. devPrivate is a pointer to
+the bits in the hardware framebuffer. note that devKind can be poked to
+make the code work for framebuffers that are wider than their
+displayable screen (e.g. the early vsII, which displayed 960 pixels
+across, but was 1024 in the hardware.)
+
+ private field of GC
+*/
+
+typedef struct {
+ unsigned char rrops[AFB_MAX_DEPTH]; /* reduction of rasterop to 1 of 3 */
+ unsigned char rropOS[AFB_MAX_DEPTH]; /* rop for opaque stipple */
+} ilbmPrivGC;
+typedef ilbmPrivGC *ilbmPrivGCPtr;
+
+extern int ilbmGCPrivateIndex; /* index into GC private array */
+extern int ilbmWindowPrivateIndex; /* index into Window private array */
+#ifdef PIXMAP_PER_WINDOW
+extern int frameWindowPrivateIndex; /* index into Window private array */
+#endif
+
+#define ilbmGetGCPrivate(pGC) \
+ ((ilbmPrivGC *)((pGC)->devPrivates[ilbmGCPrivateIndex].ptr))
+
+/* private field of window */
+typedef struct {
+ unsigned char fastBorder; /* non-zero if border tile is 32 bits wide */
+ unsigned char fastBackground;
+ unsigned short unused; /* pad for alignment with Sun compiler */
+ DDXPointRec oldRotate;
+ PixmapPtr pRotatedBackground;
+ PixmapPtr pRotatedBorder;
+} ilbmPrivWin;
+
+/* Common macros for extracting drawing information */
+
+#define ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, width, aux, dep, pointer) {\
+ PixmapPtr _pPix; \
+ if ((pDrawable)->type == DRAWABLE_WINDOW) \
+ _pPix = (PixmapPtr)(pDrawable)->pScreen->devPrivates[ilbmScreenPrivateIndex].ptr; \
+ else \
+ _pPix = (PixmapPtr)(pDrawable); \
+ (pointer) = (PixelType *)_pPix->devPrivate.ptr; \
+ (width) = ((int)_pPix->devKind)/sizeof(PixelType); \
+ (dep) = _pPix->drawable.depth; \
+ (aux) = (width)*(dep); \
+}
+
+/* ilbm uses the following macros to calculate addresses in drawables.
+ * To support banked framebuffers, the macros come in four flavors.
+ * All four collapse into the same definition on unbanked devices.
+ *
+ * ilbmScanlineFoo - calculate address and do bank switching
+ * ilbmScanlineFooNoBankSwitch - calculate address, don't bank switch
+ * ilbmScanlineFooSrc - calculate address, switch source bank
+ * ilbmScanlineFooDst - calculate address, switch destination bank
+ */
+
+/* The NoBankSwitch versions are the same for banked and unbanked cases */
+
+#define ilbmScanlineIncNoBankSwitch(_ptr, _off) _ptr += (_off)
+#define ilbmScanlineOffsetNoBankSwitch(_ptr, _off) ((_ptr)+(_off))
+#define ilbmScanlineDeltaNoBankSwitch(_ptr, _y, _w) \
+ ilbmScanlineOffsetNoBankSwitch(_ptr, (_y)*(_w))
+#define ilbmScanlineNoBankSwitch(_ptr, _x, _y, _w) \
+ ilbmScanlineOffsetNoBankSwitch(_ptr, (_y)*(_w)+((_x)>>MFB_PWSH))
+
+#ifdef MFB_LINE_BANK
+
+#include "ilbmlinebank.h" /* get macro definitions from this file */
+
+#else /* !MFB_LINE_BANK - unbanked case */
+
+#define ilbmScanlineInc(_ptr, _off) ilbmScanlineIncNoBankSwitch(_ptr, _off)
+#define ilbmScanlineIncSrc(_ptr, _off) ilbmScanlineInc(_ptr, _off)
+#define ilbmScanlineIncDst(_ptr, _off) ilbmScanlineInc(_ptr, _off)
+
+#define ilbmScanlineOffset(_ptr, _off) ilbmScanlineOffsetNoBankSwitch(_ptr, _off)
+#define ilbmScanlineOffsetSrc(_ptr, _off) ilbmScanlineOffset(_ptr, _off)
+#define ilbmScanlineOffsetDst(_ptr, _off) ilbmScanlineOffset(_ptr, _off)
+
+#define ilbmScanlineSrc(_ptr, _x, _y, _w) ilbmScanline(_ptr, _x, _y, _w)
+#define ilbmScanlineDst(_ptr, _x, _y, _w) ilbmScanline(_ptr, _x, _y, _w)
+
+#define ilbmScanlineDeltaSrc(_ptr, _y, _w) ilbmScanlineDelta(_ptr, _y, _w)
+#define ilbmScanlineDeltaDst(_ptr, _y, _w) ilbmScanlineDelta(_ptr, _y, _w)
+
+#endif /* MFB_LINE_BANK */
+
+#define ilbmScanlineDelta(_ptr, _y, _w) \
+ ilbmScanlineOffset(_ptr, (_y)*(_w))
+
+#define ilbmScanline(_ptr, _x, _y, _w) \
+ ilbmScanlineOffset(_ptr, (_y)*(_w)+((_x)>>MFB_PWSH))
+
+/* precomputed information about each glyph for GlyphBlt code.
+ this saves recalculating the per glyph information for each box.
+*/
+
+typedef struct _ilbmpos{
+ int xpos; /* xposition of glyph's origin */
+ int xchar; /* x position mod 32 */
+ int leftEdge;
+ int rightEdge;
+ int topEdge;
+ int bottomEdge;
+ PixelType *pdstBase; /* longword with character origin */
+ int widthGlyph; /* width in bytes of this glyph */
+} ilbmTEXTPOS;
+
+/* reduced raster ops for ilbm */
+#define RROP_BLACK GXclear
+#define RROP_WHITE GXset
+#define RROP_NOP GXnoop
+#define RROP_INVERT GXinvert
+#define RROP_COPY GXcopy
+
+/* macros for ilbmbitblt.c, ilbmfillsp.c
+ these let the code do one switch on the rop per call, rather
+ than a switch on the rop per item (span or rectangle.)
+*/
+
+#define fnCLEAR(src, dst) (0)
+#define fnAND(src, dst) (src & dst)
+#define fnANDREVERSE(src, dst) (src & ~dst)
+#define fnCOPY(src, dst) (src)
+#define fnANDINVERTED(src, dst) (~src & dst)
+#define fnNOOP(src, dst) (dst)
+#define fnXOR(src, dst) (src ^ dst)
+#define fnOR(src, dst) (src | dst)
+#define fnNOR(src, dst) (~(src | dst))
+#define fnEQUIV(src, dst) (~src ^ dst)
+#define fnINVERT(src, dst) (~dst)
+#define fnORREVERSE(src, dst) (src | ~dst)
+#define fnCOPYINVERTED(src, dst) (~src)
+#define fnORINVERTED(src, dst) (~src | dst)
+#define fnNAND(src, dst) (~(src & dst))
+#define fnSET(src, dst) (~0)
+
+/* Using a "switch" statement is much faster in most cases
+ * since the compiler can do a look-up table or multi-way branch
+ * instruction, depending on the architecture. The result on
+ * A Sun 3/50 is at least 2.5 times faster, assuming a uniform
+ * distribution of RasterOp operation types.
+ *
+ * However, doing some profiling on a running system reveals
+ * GXcopy is the operation over 99.5% of the time and
+ * GXxor is the next most frequent (about .4%), so we make special
+ * checks for those first.
+ *
+ * Note that this requires a change to the "calling sequence"
+ * since we can't engineer a "switch" statement to have an lvalue.
+ */
+#define DoRop(result, alu, src, dst) \
+{ \
+ if (alu == GXcopy) \
+ result = fnCOPY (src, dst); \
+ else if (alu == GXxor) \
+ result = fnXOR (src, dst); \
+ else \
+ switch (alu) { \
+ case GXclear: \
+ result = fnCLEAR (src, dst); \
+ break; \
+ case GXand: \
+ result = fnAND (src, dst); \
+ break; \
+ case GXandReverse: \
+ result = fnANDREVERSE (src, dst); \
+ break; \
+ case GXandInverted: \
+ result = fnANDINVERTED (src, dst); \
+ break; \
+ case GXnoop: \
+ result = fnNOOP (src, dst); \
+ break; \
+ case GXor: \
+ result = fnOR (src, dst); \
+ break; \
+ case GXnor: \
+ result = fnNOR (src, dst); \
+ break; \
+ case GXequiv: \
+ result = fnEQUIV (src, dst); \
+ break; \
+ case GXinvert: \
+ result = fnINVERT (src, dst); \
+ break; \
+ case GXorReverse: \
+ result = fnORREVERSE (src, dst); \
+ break; \
+ case GXcopyInverted: \
+ result = fnCOPYINVERTED (src, dst); \
+ break; \
+ case GXorInverted: \
+ result = fnORINVERTED (src, dst); \
+ break; \
+ case GXnand: \
+ result = fnNAND (src, dst); \
+ break; \
+ case GXset: \
+ result = fnSET (src, dst); \
+ break; \
+ } \
+}
+
+
+/* C expression fragments for various operations. These get passed in
+ * as -D's on the compile command line. See ilbm/Imakefile. This
+ * fixes XBUG 6319.
+ *
+ * This seems like a good place to point out that ilbm's use of the
+ * words black and white is an unfortunate misnomer. In ilbm code, black
+ * means zero, and white means one.
+ */
+#define MFB_OPEQ_WHITE |=
+#define MFB_OPEQ_BLACK &=~
+#define MFB_OPEQ_INVERT ^=
+#define MFB_EQWHOLEWORD_WHITE =~0
+#define MFB_EQWHOLEWORD_BLACK =0
+#define MFB_EQWHOLEWORD_INVERT ^=~0
+#define MFB_OP_WHITE /* nothing */
+#define MFB_OP_BLACK ~
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmbitblt.c b/nx-X11/programs/Xserver/ilbm/ilbmbitblt.c
new file mode 100644
index 000000000..11a0e07fb
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmbitblt.c
@@ -0,0 +1,483 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmbitblt.c,v 3.2tsi Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmbitblt.c,v 5.25 94/04/17 20:28:16 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+
+#include "miscstruct.h"
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "mi.h"
+
+#include "ilbm.h"
+#include "maskbits.h"
+
+
+static unsigned char ilbmRropsOS[AFB_MAX_DEPTH];
+
+/* CopyArea and CopyPlane for a monchrome frame buffer
+
+
+ clip the source rectangle to the source's available bits. (this
+avoids copying unnecessary pieces that will just get exposed anyway.)
+this becomes the new shape of the destination.
+ clip the destination region to the composite clip in the
+GC. this requires translating the destination region to (dstx, dsty).
+ build a list of source points, one for each rectangle in the
+destination. this is a simple translation.
+ go do the multiple rectangle copies
+ do graphics exposures
+*/
+/** Optimized for drawing pixmaps into windows, especially when drawing into
+ ** unobscured windows. Calls to the general-purpose region code were
+ ** replaced with rectangle-to-rectangle clipping comparisions. This is
+ ** possible, since the pixmap is a single rectangle. In an unobscured
+ ** window, the destination clip is also a single rectangle, and region
+ ** code can be avoided entirely. This is a big savings, since the region
+ ** code uses XAlloc() and makes many function calls.
+ **
+ ** In addition, if source is a pixmap, there is no need to call the
+ ** expensive miHandleExposures() routine. Instead, we simply return NULL.
+ **
+ ** Previously, drawing a pixmap into an unobscured window executed at least
+ ** 8 XAlloc()'s, 30 function calls, and hundreds of lines of code.
+ **
+ ** Now, the same operation requires no XAlloc()'s, no region function calls,
+ ** and much less overhead. Nice for drawing lots of small pixmaps.
+ */
+
+void
+ilbmDoBitblt(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
+ DrawablePtr pSrc, pDst;
+ int alu;
+ RegionPtr prgnDst;
+ DDXPointPtr pptSrc;
+ unsigned long planemask;
+{
+ switch (alu) {
+ case GXcopy:
+ ilbmDoBitbltCopy(pSrc, pDst, alu, prgnDst, pptSrc, planemask);
+ break;
+ case GXxor:
+ ilbmDoBitbltXor(pSrc, pDst, alu, prgnDst, pptSrc, planemask);
+ break;
+ case GXcopyInverted:
+ ilbmDoBitbltCopyInverted(pSrc, pDst, alu, prgnDst, pptSrc, planemask);
+ break;
+ case GXor:
+ ilbmDoBitbltOr(pSrc, pDst, alu, prgnDst, pptSrc, planemask);
+ break;
+ default:
+ ilbmDoBitbltGeneral(pSrc, pDst, alu, prgnDst, pptSrc, planemask);
+ break;
+ }
+}
+
+RegionPtr
+ilbmCopyArea(pSrcDrawable, pDstDrawable, pGC, srcx, srcy, width, height,
+ dstx, dsty)
+ DrawablePtr pSrcDrawable;
+ DrawablePtr pDstDrawable;
+ GC *pGC;
+ int srcx, srcy;
+ int width, height;
+ int dstx, dsty;
+{
+ void (*doBitBlt)();
+
+ switch (pGC->alu) {
+ case GXcopy:
+ doBitBlt = ilbmDoBitbltCopy;
+ break;
+ case GXxor:
+ doBitBlt = ilbmDoBitbltXor;
+ break;
+ case GXcopyInverted:
+ doBitBlt = ilbmDoBitbltCopyInverted;
+ break;
+ case GXor:
+ doBitBlt = ilbmDoBitbltOr;
+ break;
+ default:
+ doBitBlt = ilbmDoBitbltGeneral;
+ break;
+ }
+
+ return(ilbmBitBlt(pSrcDrawable, pDstDrawable, pGC, srcx, srcy,
+ width, height, dstx, dsty, doBitBlt, pGC->planemask));
+}
+
+RegionPtr
+ilbmBitBlt(pSrcDrawable, pDstDrawable, pGC, srcx, srcy, width, height,
+ dstx, dsty, doBitBlt, planemask)
+ register DrawablePtr pSrcDrawable;
+ register DrawablePtr pDstDrawable;
+ register GC *pGC;
+ int srcx, srcy;
+ int width, height;
+ int dstx, dsty;
+ void (*doBitBlt)();
+ unsigned long planemask;
+{
+ RegionPtr prgnSrcClip; /* may be a new region, or just a copy */
+ Bool freeSrcClip = FALSE;
+
+ RegionPtr prgnExposed;
+ RegionRec rgnDst;
+ DDXPointPtr pptSrc;
+ register DDXPointPtr ppt;
+ register BoxPtr pbox;
+ int i;
+ register int dx;
+ register int dy;
+ xRectangle origSource;
+ DDXPointRec origDest;
+ int numRects;
+ BoxRec fastBox;
+ int fastClip = 0; /* for fast clipping with pixmap source */
+ int fastExpose = 0; /* for fast exposures with pixmap source */
+ void (*localDoBitBlt)();
+
+ origSource.x = srcx;
+ origSource.y = srcy;
+ origSource.width = width;
+ origSource.height = height;
+ origDest.x = dstx;
+ origDest.y = dsty;
+
+ if ((pSrcDrawable != pDstDrawable) && pSrcDrawable->pScreen->SourceValidate)
+ (*pSrcDrawable->pScreen->SourceValidate)(pSrcDrawable, srcx, srcy, width,
+ height);
+
+ srcx += pSrcDrawable->x;
+ srcy += pSrcDrawable->y;
+
+ /* clip the source */
+
+ if (pSrcDrawable->type == DRAWABLE_PIXMAP)
+ if ((pSrcDrawable == pDstDrawable) && (pGC->clientClipType == CT_NONE))
+ prgnSrcClip = pGC->pCompositeClip;
+ else
+ fastClip = 1;
+ else if (pGC->subWindowMode == IncludeInferiors)
+ if (!((WindowPtr)pSrcDrawable)->parent)
+ /*
+ * special case bitblt from root window in
+ * IncludeInferiors mode; just like from a pixmap
+ */
+ fastClip = 1;
+ else if ((pSrcDrawable == pDstDrawable) &&
+ (pGC->clientClipType == CT_NONE))
+ prgnSrcClip = pGC->pCompositeClip;
+ else {
+ prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable);
+ freeSrcClip = TRUE;
+ }
+ else
+ prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList;
+
+ fastBox.x1 = srcx;
+ fastBox.y1 = srcy;
+ fastBox.x2 = srcx + width;
+ fastBox.y2 = srcy + height;
+
+ /* Don't create a source region if we are doing a fast clip */
+ if (fastClip) {
+ fastExpose = 1;
+ /*
+ * clip the source; if regions extend beyond the source size,
+ * make sure exposure events get sent
+ */
+ if (fastBox.x1 < pSrcDrawable->x) {
+ fastBox.x1 = pSrcDrawable->x;
+ fastExpose = 0;
+ }
+ if (fastBox.y1 < pSrcDrawable->y) {
+ fastBox.y1 = pSrcDrawable->y;
+ fastExpose = 0;
+ }
+ if (fastBox.x2 > pSrcDrawable->x + (int)pSrcDrawable->width) {
+ fastBox.x2 = pSrcDrawable->x + (int)pSrcDrawable->width;
+ fastExpose = 0;
+ }
+ if (fastBox.y2 > pSrcDrawable->y + (int)pSrcDrawable->height) {
+ fastBox.y2 = pSrcDrawable->y + (int)pSrcDrawable->height;
+ fastExpose = 0;
+ }
+ } else {
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip);
+ }
+
+ dstx += pDstDrawable->x;
+ dsty += pDstDrawable->y;
+
+ if (pDstDrawable->type == DRAWABLE_WINDOW)
+ if (!((WindowPtr)pDstDrawable)->realized) {
+ if (!fastClip)
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return NULL;
+ }
+
+ dx = srcx - dstx;
+ dy = srcy - dsty;
+
+ /* Translate and clip the dst to the destination composite clip */
+ if (fastClip) {
+ RegionPtr cclip;
+
+ /* Translate the region directly */
+ fastBox.x1 -= dx;
+ fastBox.x2 -= dx;
+ fastBox.y1 -= dy;
+ fastBox.y2 -= dy;
+
+ /* If the destination composite clip is one rectangle we can
+ do the clip directly. Otherwise we have to create a full
+ blown region and call intersect */
+ cclip = pGC->pCompositeClip;
+ if (REGION_NUM_RECTS(cclip) == 1) {
+ BoxPtr pBox = REGION_RECTS(cclip);
+
+ if (fastBox.x1 < pBox->x1)
+ fastBox.x1 = pBox->x1;
+ if (fastBox.x2 > pBox->x2)
+ fastBox.x2 = pBox->x2;
+ if (fastBox.y1 < pBox->y1)
+ fastBox.y1 = pBox->y1;
+ if (fastBox.y2 > pBox->y2)
+ fastBox.y2 = pBox->y2;
+
+ /* Check to see if the region is empty */
+ if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2) {
+ REGION_NULL(pGC->pScreen, &rgnDst);
+ } else {
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ }
+ } else {
+ /* We must turn off fastClip now, since we must create
+ a full blown region. It is intersected with the
+ composite clip below. */
+ fastClip = 0;
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ }
+ } else
+ REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy);
+
+ if (!fastClip) {
+ REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, pGC->pCompositeClip);
+ }
+
+ /* Do bit blitting */
+ numRects = REGION_NUM_RECTS(&rgnDst);
+ if (numRects && width && height) {
+ if (!(pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(numRects *
+ sizeof(DDXPointRec)))) {
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return NULL;
+ }
+ pbox = REGION_RECTS(&rgnDst);
+ ppt = pptSrc;
+ for (i = numRects; --i >= 0; pbox++, ppt++) {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ (*doBitBlt)(pSrcDrawable, pDstDrawable, pGC->alu, &rgnDst, pptSrc,
+ planemask);
+
+ DEALLOCATE_LOCAL(pptSrc);
+ }
+
+ prgnExposed = NULL;
+ if (pGC->fExpose) {
+ /* Pixmap sources generate a NoExposed (we return NULL to do this) */
+ if (!fastExpose)
+ prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
+ origSource.x, origSource.y,
+ (int)origSource.width,
+ (int)origSource.height, origDest.x,
+ origDest.y, (unsigned long)0);
+ }
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return prgnExposed;
+}
+
+RegionPtr
+ilbmCopyPlane(pSrcDrawable, pDstDrawable, pGC, srcx, srcy, width, height,
+ dstx, dsty, plane)
+DrawablePtr pSrcDrawable, pDstDrawable;
+register GC *pGC;
+int srcx, srcy;
+int width, height;
+int dstx, dsty;
+unsigned long plane;
+{
+ int alu;
+ RegionPtr prgnExposed = NULL;
+ unsigned long old_planemask;
+ PixmapPtr pPixmap = NULL;
+
+ if (pDstDrawable->depth == 1) {
+ old_planemask = pGC->planemask;
+ pGC->planemask = plane;
+ if ((pGC->fgPixel & 1) == 1 && (pGC->bgPixel & 1) == 0) {
+ prgnExposed = (*pGC->ops->CopyArea)(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+ } else if ((pGC->fgPixel & 1) == (pGC->bgPixel & 1)) {
+ unsigned char rop;
+
+ ilbmReduceRop(pGC->alu, pGC->fgPixel, 1, 1, &rop);
+ alu = pGC->alu;
+ pGC->alu = rop;
+ prgnExposed = (*pGC->ops->CopyArea)(pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height, dstx,
+ dsty);
+ pGC->alu = alu;
+ } else { /* need to invert the src */
+ alu = pGC->alu;
+ pGC->alu = ilbmInverseAlu[alu];
+ prgnExposed = (*pGC->ops->CopyArea)(pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height, dstx,
+ dsty);
+ pGC->alu = alu;
+ }
+ pGC->planemask = old_planemask;
+ } else {
+ int free_pixmap = FALSE;
+ PixmapPtr pBitmap = (PixmapPtr)pSrcDrawable;
+ ScreenPtr pScreen = pSrcDrawable->pScreen;
+ GCPtr pGC1;
+
+ if (pSrcDrawable == pDstDrawable ||
+ pSrcDrawable->type == DRAWABLE_WINDOW || pSrcDrawable->depth != 1) {
+ /* Copy a plane from source drawable to a tmp 1-bit deep pixmap */
+ /* XXX: Range check width and height */
+ pBitmap = (*pScreen->CreatePixmap)(pScreen, width, height, 1);
+
+ if (!pBitmap)
+ return(NULL);
+ pGC1 = GetScratchGC(1, pScreen);
+ if (!pGC1) {
+ (*pScreen->DestroyPixmap)(pBitmap);
+ return(NULL);
+ }
+ ValidateGC((DrawablePtr)pBitmap, pGC1);
+ (void)ilbmBitBlt(pSrcDrawable, (DrawablePtr)pBitmap, pGC1, srcx, srcy,
+ width, height, 0, 0, ilbmDoBitbltCopy, plane);
+ free_pixmap = TRUE;
+ }
+#if 0
+ else {
+ /* XXX: could cope with N-deep pixmap source case without using tmp
+ * src bitmap by setting up a scratch pixmap header and fiddle
+ * around with the pbits pointer.
+ */
+ }
+#endif
+ ilbmReduceOpaqueStipple(pGC->fgPixel, pGC->bgPixel, pGC->planemask,
+ pGC->depth, ilbmRropsOS);
+ (void)ilbmBitBlt((DrawablePtr)pBitmap, pDstDrawable, pGC, 0, 0, width,
+ height, dstx, dsty, ilbmCopy1ToN, pGC->planemask);
+ if (free_pixmap) {
+ (*pScreen->DestroyPixmap)(pBitmap);
+ FreeScratchGC(pGC1);
+ }
+
+ if (pGC->fExpose)
+ prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC, srcx,
+ srcy, width, height, dstx, dsty,
+ plane);
+ }
+ return prgnExposed;
+}
+
+void
+ilbmCopy1ToN(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
+ DrawablePtr pSrc, pDst;
+ int alu;
+ RegionPtr prgnDst;
+ DDXPointPtr pptSrc;
+ unsigned long planemask;
+{
+ int numRects = REGION_NUM_RECTS(prgnDst);
+ BoxPtr pbox = REGION_RECTS(prgnDst);
+ int r;
+
+ for (r = 0; r < numRects; r++, pbox++, pptSrc++) {
+ int dx = pptSrc->x;
+ int dy = pptSrc->y;
+
+ if (alu == GXcopy)
+ ilbmOpaqueStippleAreaCopy(pDst, 1, pbox, alu, (PixmapPtr)pSrc, dx, dy,
+ ilbmRropsOS, planemask);
+ else
+ ilbmOpaqueStippleAreaGeneral(pDst, 1, pbox, alu, (PixmapPtr)pSrc, dx,
+ dy, ilbmRropsOS, planemask);
+ }
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmblt.c b/nx-X11/programs/Xserver/ilbm/ilbmblt.c
new file mode 100644
index 000000000..9b11567ca
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmblt.c
@@ -0,0 +1,573 @@
+/* $XFree86$ */
+/*
+ * ilbm copy area
+ */
+
+/*
+
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+Author: Keith Packard
+
+*/
+/* $XConsortium: ilbmblt.c,v 1.11 94/04/17 20:28:16 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "ilbm.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "maskbits.h"
+#include "fastblt.h"
+#include "mergerop.h"
+
+void
+MROP_NAME(ilbmDoBitblt)(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
+ DrawablePtr pSrc, pDst;
+ int alu;
+ RegionPtr prgnDst;
+ DDXPointPtr pptSrc;
+ unsigned long planemask;
+{
+ PixelType *psrcBase, *pdstBase; /* start of src and dst bitmaps */
+ int widthSrc, widthDst; /* add to get to same position in next line */
+ int heightSrc, heightDst;
+ int auxSrc, auxDst;
+
+ BoxPtr pbox;
+ int nbox;
+
+ BoxPtr pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2;
+ /* temporaries for shuffling rectangles */
+ DDXPointPtr pptTmp, pptNew1, pptNew2;
+ /* shuffling boxes entails shuffling the
+ source points too */
+ int w, h;
+ int xdir; /* 1 = left right, -1 = right left/ */
+ int ydir; /* 1 = top down, -1 = bottom up */
+
+ PixelType *psrcLine, *pdstLine;
+ /* pointers to line with current src and dst */
+ register PixelType *psrc; /* pointer to current src longword */
+ register PixelType *pdst; /* pointer to current dst longword */
+
+ MROP_DECLARE_REG()
+
+ /* following used for looping through a line */
+ PixelType startmask, endmask; /* masks for writing ends of dst */
+ int nlMiddle; /* whole longwords in dst */
+ int xoffSrc, xoffDst;
+ register int leftShift, rightShift;
+ register PixelType bits;
+ register PixelType bits1;
+ register int nl; /* temp copy of nlMiddle */
+
+ /* place to store full source word */
+ int nstart; /* number of ragged bits at start of dst */
+ int nend; /* number of ragged bits at end of dst */
+ int srcStartOver; /* pulling nstart bits from src
+ overflows into the next word? */
+ int careful;
+ int tmpSrc;
+ int depthSrc;
+ int depthDst;
+
+ MROP_INITIALIZE(alu,0);
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pSrc, widthSrc, auxSrc, depthSrc,
+ psrcBase);
+ ilbmGetPixelWidthAuxDepthAndPointer(pDst, widthDst, auxDst, depthDst,
+ pdstBase);
+
+ /* Special case where depth of dest pixmap is 1 but source pixmap isn't
+ * Used for GetImage to copy a plane from a source pixmap to a particular
+ * dest pixmap plane.
+ * Note: planemask should have only one bit set or several planes from
+ * the source will be copied to the same dest plane.
+ */
+ if (depthDst == 1 && depthDst != depthSrc)
+ widthDst = 0;
+
+ /* XXX we have to err on the side of safety when both are windows,
+ * because we don't know if IncludeInferiors is being used.
+ */
+ careful = ((pSrc == pDst) ||
+ ((pSrc->type == DRAWABLE_WINDOW) &&
+ (pDst->type == DRAWABLE_WINDOW)));
+
+ pbox = REGION_RECTS(prgnDst);
+ nbox = REGION_NUM_RECTS(prgnDst);
+
+ pboxNew1 = NULL;
+ pptNew1 = NULL;
+ pboxNew2 = NULL;
+ pptNew2 = NULL;
+ if (careful && (pptSrc->y < pbox->y1)) {
+ /* walk source botttom to top */
+ ydir = -1;
+ auxSrc = -auxSrc;
+ auxDst = -auxDst;
+
+ if (nbox > 1) {
+ /* keep ordering in each band, reverse order of bands */
+ pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec)*nbox);
+ if (!pboxNew1)
+ return;
+ pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec)*nbox);
+ if (!pptNew1) {
+ DEALLOCATE_LOCAL(pboxNew1);
+ return;
+ }
+ pboxBase = pboxNext = pbox+nbox-1;
+ while (pboxBase >= pbox) {
+ while ((pboxNext >= pbox) &&
+ (pboxBase->y1 == pboxNext->y1))
+ pboxNext--;
+ pboxTmp = pboxNext+1;
+ pptTmp = pptSrc + (pboxTmp - pbox);
+ while (pboxTmp <= pboxBase) {
+ *pboxNew1++ = *pboxTmp++;
+ *pptNew1++ = *pptTmp++;
+ }
+ pboxBase = pboxNext;
+ }
+ pboxNew1 -= nbox;
+ pbox = pboxNew1;
+ pptNew1 -= nbox;
+ pptSrc = pptNew1;
+ }
+ } else {
+ /* walk source top to bottom */
+ ydir = 1;
+ }
+
+ if (careful && (pptSrc->x < pbox->x1)) {
+ /* walk source right to left */
+ xdir = -1;
+
+ if (nbox > 1) {
+ /* reverse order of rects in each band */
+ pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
+ pptNew2 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox);
+ if (!pboxNew2 || !pptNew2) {
+ if (pptNew2)
+ DEALLOCATE_LOCAL(pptNew2);
+ if (pboxNew2)
+ DEALLOCATE_LOCAL(pboxNew2);
+ if (pboxNew1) {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(pboxNew1);
+ }
+ return;
+ }
+ pboxBase = pboxNext = pbox;
+ while (pboxBase < pbox+nbox) {
+ while ((pboxNext < pbox+nbox) && (pboxNext->y1 == pboxBase->y1))
+ pboxNext++;
+ pboxTmp = pboxNext;
+ pptTmp = pptSrc + (pboxTmp - pbox);
+ while (pboxTmp != pboxBase) {
+ *pboxNew2++ = *--pboxTmp;
+ *pptNew2++ = *--pptTmp;
+ }
+ pboxBase = pboxNext;
+ }
+ pboxNew2 -= nbox;
+ pbox = pboxNew2;
+ pptNew2 -= nbox;
+ pptSrc = pptNew2;
+ }
+ } else {
+ /* walk source left to right */
+ xdir = 1;
+ }
+
+ while (nbox--) {
+ int d;
+ for (d = 0; d < depthSrc; d++) {
+ PixelType *psrcB;
+ PixelType *pdstB;
+
+ if (!(planemask & (1 << d)))
+ continue;
+
+ psrcB = psrcBase + widthSrc * d; /* @@@ NEXT PLANE @@@ */
+ pdstB = pdstBase + widthDst * d; /* @@@ NEXT PLANE @@@ */
+
+ w = pbox->x2 - pbox->x1;
+ h = pbox->y2 - pbox->y1;
+
+ if (ydir == -1) { /* start at last scanline of rectangle */
+ psrcLine = ilbmScanlineDeltaSrc(psrcB, -(pptSrc->y+h-1), auxSrc);
+ pdstLine = ilbmScanlineDeltaDst(pdstB, -(pbox->y2-1), auxDst);
+ } else { /* start at first scanline */
+ psrcLine = ilbmScanlineDeltaSrc(psrcB, pptSrc->y, auxSrc);
+ pdstLine = ilbmScanlineDeltaDst(pdstB, pbox->y1, auxDst);
+ }
+ if ((pbox->x1 & PIM) + w <= PPW) {
+ maskpartialbits (pbox->x1, w, startmask);
+ endmask = 0;
+ nlMiddle = 0;
+ } else {
+ maskbits(pbox->x1, w, startmask, endmask, nlMiddle);
+ }
+ if (xdir == 1) {
+ xoffSrc = pptSrc->x & PIM;
+ xoffDst = pbox->x1 & PIM;
+ pdstLine += (pbox->x1 >> PWSH);
+ psrcLine += (pptSrc->x >> PWSH);
+#ifdef DO_UNALIGNED_BITBLT
+ nl = xoffSrc - xoffDst;
+ psrcLine = (PixelType *)(((unsigned char *) psrcLine) + nl);
+#else
+ if (xoffSrc == xoffDst)
+#endif
+ {
+ while (h--) {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ if (startmask) {
+ *pdst = MROP_MASK(*psrc, *pdst, startmask);
+ psrc++;
+ pdst++;
+ }
+ nl = nlMiddle;
+
+#ifdef LARGE_INSTRUCTION_CACHE
+#ifdef FAST_CONSTANT_OFFSET_MODE
+
+ psrc += nl & (UNROLL-1);
+ pdst += nl & (UNROLL-1);
+
+#define BodyOdd(n) pdst[-n] = MROP_SOLID (psrc[-n], pdst[-n]);
+#define BodyEven(n) pdst[-n] = MROP_SOLID (psrc[-n], pdst[-n]);
+
+#define LoopReset \
+pdst += UNROLL; \
+psrc += UNROLL;
+
+#else
+
+#define BodyOdd(n) *pdst = MROP_SOLID (*psrc, *pdst); pdst++; psrc++;
+#define BodyEven(n) BodyOdd(n)
+
+#define LoopReset ;
+
+#endif
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+#ifdef NOTDEF
+ /* you'd think this would be faster --
+ * a single instruction instead of 6
+ * but measurements show it to be ~15% slower
+ */
+ while ((nl -= 6) >= 0) {
+ asm ("moveml %1+,#0x0c0f;moveml#0x0c0f,%0"
+ : "=m" (*(char *)pdst)
+ : "m" (*(char *)psrc)
+ : "d0", "d1", "d2", "d3",
+ "a2", "a3");
+ pdst += 6;
+ }
+ nl += 6;
+ while (nl--)
+ *pdst++ = *psrc++;
+#endif
+ DuffL(nl, label1,
+ *pdst = MROP_SOLID (*psrc, *pdst);
+ pdst++; psrc++;)
+#endif
+
+ if (endmask)
+ *pdst = MROP_MASK(*psrc, *pdst, endmask);
+ ilbmScanlineIncDst(pdstLine, auxDst);
+ ilbmScanlineIncSrc(psrcLine, auxSrc);
+ }
+ }
+#ifndef DO_UNALIGNED_BITBLT
+ else {
+ if (xoffSrc > xoffDst) {
+ leftShift = (xoffSrc - xoffDst);
+ rightShift = PPW - leftShift;
+ } else {
+ rightShift = (xoffDst - xoffSrc);
+ leftShift = PPW - rightShift;
+ }
+ while (h--) {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ bits = 0;
+ if (xoffSrc > xoffDst)
+ bits = *psrc++;
+ if (startmask) {
+ bits1 = BitLeft(bits,leftShift);
+ bits = *psrc++;
+ bits1 |= BitRight(bits,rightShift);
+ *pdst = MROP_MASK(bits1, *pdst, startmask);
+ pdst++;
+ }
+ nl = nlMiddle;
+
+#ifdef LARGE_INSTRUCTION_CACHE
+ bits1 = bits;
+
+#ifdef FAST_CONSTANT_OFFSET_MODE
+
+ psrc += nl & (UNROLL-1);
+ pdst += nl & (UNROLL-1);
+
+#define BodyOdd(n) \
+bits = psrc[-n]; \
+pdst[-n] = MROP_SOLID(BitLeft(bits1, leftShift) | BitRight(bits, rightShift), pdst[-n]);
+
+#define BodyEven(n) \
+bits1 = psrc[-n]; \
+pdst[-n] = MROP_SOLID(BitLeft(bits, leftShift) | BitRight(bits1, rightShift), pdst[-n]);
+
+#define LoopReset \
+pdst += UNROLL; \
+psrc += UNROLL;
+
+#else
+
+#define BodyOdd(n) \
+bits = *psrc++; \
+*pdst = MROP_SOLID(BitLeft(bits1, leftShift) | BitRight(bits, rightShift), *pdst); \
+pdst++;
+
+#define BodyEven(n) \
+bits1 = *psrc++; \
+*pdst = MROP_SOLID(BitLeft(bits, leftShift) | BitRight(bits1, rightShift), *pdst); \
+pdst++;
+
+#define LoopReset ;
+
+#endif /* !FAST_CONSTANT_OFFSET_MODE */
+
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+ DuffL(nl,label2,
+ bits1 = BitLeft(bits, leftShift);
+ bits = *psrc++;
+ *pdst = MROP_SOLID (bits1 | BitRight(bits, rightShift), *pdst);
+ pdst++;
+ )
+#endif
+
+ if (endmask) {
+ bits1 = BitLeft(bits, leftShift);
+ if (BitLeft(endmask, rightShift)) {
+ bits = *psrc;
+ bits1 |= BitRight(bits, rightShift);
+ }
+ *pdst = MROP_MASK (bits1, *pdst, endmask);
+ }
+ ilbmScanlineIncDst(pdstLine, auxDst);
+ ilbmScanlineIncSrc(psrcLine, auxSrc);
+ }
+ }
+#endif /* DO_UNALIGNED_BITBLT */
+ } else { /* xdir == -1 */
+ xoffSrc = (pptSrc->x + w - 1) & PIM;
+ xoffDst = (pbox->x2 - 1) & PIM;
+ pdstLine += ((pbox->x2-1) >> PWSH) + 1;
+ psrcLine += ((pptSrc->x+w - 1) >> PWSH) + 1;
+#ifdef DO_UNALIGNED_BITBLT
+ nl = xoffSrc - xoffDst;
+ psrcLine = (PixelType *)
+ (((unsigned char *) psrcLine) + nl);
+#else
+ if (xoffSrc == xoffDst)
+#endif
+ {
+ while (h--) {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ if (endmask) {
+ pdst--;
+ psrc--;
+ *pdst = MROP_MASK (*psrc, *pdst, endmask);
+ }
+ nl = nlMiddle;
+
+#ifdef LARGE_INSTRUCTION_CACHE
+#ifdef FAST_CONSTANT_OFFSET_MODE
+ psrc -= nl & (UNROLL - 1);
+ pdst -= nl & (UNROLL - 1);
+
+#define BodyOdd(n) pdst[n-1] = MROP_SOLID (psrc[n-1], pdst[n-1]);
+
+#define BodyEven(n) BodyOdd(n)
+
+#define LoopReset \
+pdst -= UNROLL;\
+psrc -= UNROLL;
+
+#else
+
+#define BodyOdd(n) --pdst; --psrc; *pdst = MROP_SOLID(*psrc, *pdst);
+#define BodyEven(n) BodyOdd(n)
+#define LoopReset ;
+
+#endif
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+ DuffL(nl,label3,
+ --pdst; --psrc; *pdst = MROP_SOLID (*psrc, *pdst);)
+#endif
+
+ if (startmask) {
+ --pdst;
+ --psrc;
+ *pdst = MROP_MASK(*psrc, *pdst, startmask);
+ }
+ ilbmScanlineIncDst(pdstLine, auxDst);
+ ilbmScanlineIncSrc(psrcLine, auxSrc);
+ }
+ }
+#ifndef DO_UNALIGNED_BITBLT
+ else {
+ if (xoffDst > xoffSrc) {
+ rightShift = (xoffDst - xoffSrc);
+ leftShift = PPW - rightShift;
+ } else {
+ leftShift = (xoffSrc - xoffDst);
+ rightShift = PPW - leftShift;
+ }
+ while (h--) {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ bits = 0;
+ if (xoffDst > xoffSrc)
+ bits = *--psrc;
+ if (endmask) {
+ bits1 = BitRight(bits, rightShift);
+ bits = *--psrc;
+ bits1 |= BitLeft(bits, leftShift);
+ pdst--;
+ *pdst = MROP_MASK(bits1, *pdst, endmask);
+ }
+ nl = nlMiddle;
+
+#ifdef LARGE_INSTRUCTION_CACHE
+ bits1 = bits;
+#ifdef FAST_CONSTANT_OFFSET_MODE
+ psrc -= nl & (UNROLL - 1);
+ pdst -= nl & (UNROLL - 1);
+
+#define BodyOdd(n) \
+bits = psrc[n-1]; \
+pdst[n-1] = MROP_SOLID(BitRight(bits1, rightShift) | BitLeft(bits, leftShift),pdst[n-1]);
+
+#define BodyEven(n) \
+bits1 = psrc[n-1]; \
+pdst[n-1] = MROP_SOLID(BitRight(bits, rightShift) | BitLeft(bits1, leftShift),pdst[n-1]);
+
+#define LoopReset \
+pdst -= UNROLL; \
+psrc -= UNROLL;
+
+#else
+
+#define BodyOdd(n) \
+bits = *--psrc; --pdst; \
+*pdst = MROP_SOLID(BitRight(bits1, rightShift) | BitLeft(bits, leftShift),*pdst);
+
+#define BodyEven(n) \
+bits1 = *--psrc; --pdst; \
+*pdst = MROP_SOLID(BitRight(bits, rightShift) | BitLeft(bits1, leftShift),*pdst);
+
+#define LoopReset ;
+
+#endif
+
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+ DuffL(nl, label4,
+ bits1 = BitRight(bits, rightShift);
+ bits = *--psrc;
+ --pdst;
+ *pdst = MROP_SOLID(bits1 | BitLeft(bits, leftShift),*pdst);
+ )
+#endif
+
+ if (startmask) {
+ bits1 = BitRight(bits, rightShift);
+ if (BitRight (startmask, leftShift)) {
+ bits = *--psrc;
+ bits1 |= BitLeft(bits, leftShift);
+ }
+ --pdst;
+ *pdst = MROP_MASK(bits1, *pdst, startmask);
+ }
+ ilbmScanlineIncDst(pdstLine, auxDst);
+ ilbmScanlineIncSrc(psrcLine, auxSrc);
+ }
+ }
+#endif
+ }
+ }
+ pbox++;
+ pptSrc++;
+ }
+ if (pboxNew2) {
+ DEALLOCATE_LOCAL(pptNew2);
+ DEALLOCATE_LOCAL(pboxNew2);
+ }
+ if (pboxNew1) {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(pboxNew1);
+ }
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmbres.c b/nx-X11/programs/Xserver/ilbm/ilbmbres.c
new file mode 100644
index 000000000..49058d446
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmbres.c
@@ -0,0 +1,328 @@
+/* $XFree86$ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmbres.c,v 1.22 94/04/17 20:28:17 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "ilbm.h"
+#include "maskbits.h"
+#include "miline.h"
+
+/* Solid bresenham line */
+/* NOTES
+ e2 is used less often than e1, so it's not in a register
+*/
+
+void
+ilbmBresS(addrlbase, nlwidth, auxDst, depthDst, signdx, signdy, axis, x1, y1,
+ e, e1, e2, len, rrops)
+PixelType *addrlbase; /* pointer to base of bitmap */
+int nlwidth; /* width in longwords of bitmap */
+int auxDst;
+int depthDst;
+int signdx, signdy; /* signs of directions */
+int axis; /* major axis (Y_AXIS or X_AXIS) */
+int x1, y1; /* initial point */
+register int e; /* error accumulator */
+register int e1; /* bresenham increments */
+int e2;
+int len; /* length of line */
+unsigned char *rrops;
+{
+ register int yinc; /* increment to next scanline, in bytes */
+ register PixelType *addrl; /* bitmask long pointer */
+ register PixelType bit; /* current bit being set/cleared/etc. */
+ PixelType leftbit = mask[0]; /* leftmost bit to process in new word */
+ PixelType rightbit = mask[PPW-1]; /* rightmost bit to process in new word */
+
+ register int e3 = e2-e1;
+ PixelType tmp;
+ int saveE;
+ int saveLen;
+ int d;
+
+ /* point to longword containing first point */
+ yinc = signdy * auxDst;
+ e = e-e1; /* to make looping easier */
+
+ if (!len)
+ return;
+
+ saveLen = len;
+ saveE = e;
+
+ for (d = 0; d < depthDst; d++) {
+ addrl = ilbmScanline(addrlbase, x1, y1, auxDst);
+ addrlbase += nlwidth; /* @@@ NEXT PLANE @@@ */
+ len = saveLen;
+ e = saveE;
+ bit = mask[x1 & PIM];
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ if (axis == X_AXIS) {
+ if (signdx > 0) {
+ tmp = *addrl;
+ for (;;) {
+ tmp &= ~bit;
+ if (!--len)
+ break;
+ bit = SCRRIGHT(bit,1);
+ e += e1;
+ if (e >= 0) {
+ *addrl = tmp;
+ ilbmScanlineInc(addrl, yinc);
+ e += e3;
+ if (!bit) {
+ bit = leftbit;
+ addrl ++;
+ }
+ tmp = *addrl;
+ } else if (!bit) {
+ *addrl = tmp;
+ bit = leftbit;
+ addrl ++;
+ tmp = *addrl;
+ }
+ }
+ *addrl = tmp;
+ } else {
+ tmp = *addrl;
+ for (;;) {
+ tmp &= ~bit;
+ if (!--len)
+ break;
+ e += e1;
+ bit = SCRLEFT(bit,1);
+ if (e >= 0) {
+ *addrl = tmp;
+ ilbmScanlineInc(addrl, yinc);
+ e += e3;
+ if (!bit) {
+ bit = rightbit;
+ addrl --;
+ }
+ tmp = *addrl;
+ } else if (!bit) {
+ *addrl = tmp;
+ bit = rightbit;
+ addrl --;
+ tmp = *addrl;
+ }
+ }
+ *addrl = tmp;
+ }
+ } /* if X_AXIS */ else {
+ if (signdx > 0) {
+ while (len--) {
+ *addrl &= ~bit;
+ e += e1;
+ if (e >= 0) {
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ e += e3;
+ }
+ ilbmScanlineInc(addrl, yinc);
+ }
+ } else {
+ while (len--) {
+ *addrl &= ~bit;
+ e += e1;
+ if (e >= 0) {
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit;addrl --; }
+ e += e3;
+ }
+ ilbmScanlineInc(addrl, yinc);
+ }
+ }
+ } /* else Y_AXIS */
+ break;
+
+ case RROP_WHITE:
+ if (axis == X_AXIS) {
+ if (signdx > 0) {
+ tmp = *addrl;
+ for (;;) {
+ tmp |= bit;
+ if (!--len)
+ break;
+ e += e1;
+ bit = SCRRIGHT(bit,1);
+ if (e >= 0) {
+ *addrl = tmp;
+ ilbmScanlineInc(addrl, yinc);
+ e += e3;
+ if (!bit) {
+ bit = leftbit;
+ addrl ++;
+ }
+ tmp = *addrl;
+ } else if (!bit) {
+ *addrl = tmp;
+ bit = leftbit;
+ addrl ++;
+ tmp = *addrl;
+ }
+ }
+ *addrl = tmp;
+ } else {
+ tmp = *addrl;
+ for (;;) {
+ tmp |= bit;
+ if (!--len)
+ break;
+ e += e1;
+ bit = SCRLEFT(bit,1);
+ if (e >= 0) {
+ *addrl = tmp;
+ ilbmScanlineInc(addrl, yinc);
+ e += e3;
+ if (!bit) {
+ bit = rightbit;
+ addrl --;
+ }
+ tmp = *addrl;
+ } else if (!bit) {
+ *addrl = tmp;
+ bit = rightbit;
+ addrl --;
+ tmp = *addrl;
+ }
+ }
+ *addrl = tmp;
+ }
+ } /* if X_AXIS */ else {
+ if (signdx > 0) {
+ while (len--) {
+ *addrl |= bit;
+ e += e1;
+ if (e >= 0) {
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ e += e3;
+ }
+ ilbmScanlineInc(addrl, yinc);
+ }
+ } else {
+ while (len--) {
+ *addrl |= bit;
+ e += e1;
+ if (e >= 0) {
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit;addrl --; }
+ e += e3;
+ }
+ ilbmScanlineInc(addrl, yinc);
+ }
+ }
+ } /* else Y_AXIS */
+ break;
+
+ case RROP_INVERT:
+ if (axis == X_AXIS) {
+ if (signdx > 0) {
+ while (len--) {
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0) {
+ ilbmScanlineInc(addrl, yinc);
+ e += e3;
+ }
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ }
+ } else {
+ while (len--) {
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0) {
+ ilbmScanlineInc(addrl, yinc);
+ e += e3;
+ }
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit;addrl --; }
+ }
+ }
+ } /* if X_AXIS */ else {
+ if (signdx > 0) {
+ while (len--) {
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0) {
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ e += e3;
+ }
+ ilbmScanlineInc(addrl, yinc);
+ }
+ } else {
+ while (len--) {
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0) {
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit; addrl --; }
+ e += e3;
+ }
+ ilbmScanlineInc(addrl, yinc);
+ }
+ }
+ } /* else Y_AXIS */
+ } /* switch */
+ } /* for (d = ... ) */
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmbresd.c b/nx-X11/programs/Xserver/ilbm/ilbmbresd.c
new file mode 100644
index 000000000..78eb392a6
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmbresd.c
@@ -0,0 +1,219 @@
+/* $XFree86$ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmbresd.c,v 1.10 94/04/17 20:28:18 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "ilbm.h"
+#include "maskbits.h"
+#include "miline.h"
+
+/* Dashed bresenham line */
+
+#define StepDash\
+ if (!--dashRemaining) { \
+ if (++ dashIndex == numInDashList) \
+ dashIndex = 0; \
+ dashRemaining = pDash[dashIndex]; \
+ rop = fgrop; \
+ if (dashIndex & 1) \
+ rop = bgrop; \
+ }
+
+void
+ilbmBresD(pdashIndex, pDash, numInDashList, pdashOffset, isDoubleDash,
+ addrlbase, nlwidth, auxDst, depthDst,
+ signdx, signdy, axis, x1, y1, e, e1, e2, len, rrops, bgrrops)
+int *pdashIndex; /* current dash */
+unsigned char *pDash; /* dash list */
+int numInDashList; /* total length of dash list */
+int *pdashOffset; /* offset into current dash */
+int isDoubleDash;
+PixelType *addrlbase; /* pointer to base of bitmap */
+int nlwidth; /* width in longwords of bitmap */
+int auxDst;
+int depthDst;
+int signdx, signdy; /* signs of directions */
+int axis; /* major axis (Y_AXIS or X_AXIS) */
+int x1, y1; /* initial point */
+register int e; /* error accumulator */
+register int e1; /* bresenham increments */
+int e2;
+int len; /* length of line */
+unsigned char *rrops;
+unsigned char *bgrrops;
+{
+ register int yinc; /* increment to next scanline, in bytes */
+ register PixelType *addrl;
+ register int e3 = e2-e1;
+ register unsigned long bit;
+ PixelType leftbit = mask[0]; /* leftmost bit to process in new word */
+ PixelType rightbit = mask[PPW-1]; /* rightmost bit to process in new word */
+ int dashIndex;
+ int dashOffset;
+ int dashRemaining;
+ int rop;
+ int fgrop;
+ int bgrop;
+ int saveE;
+ int saveLen;
+ int d;
+
+ dashOffset = *pdashOffset;
+ dashIndex = *pdashIndex;
+ dashRemaining = pDash[dashIndex] - dashOffset;
+ /* point to longword containing first point */
+
+ yinc = signdy * auxDst;
+ e = e-e1; /* to make looping easier */
+
+ saveE = e;
+ saveLen = len;
+
+ for (d = 0; d < depthDst; d++) {
+ addrl = ilbmScanline(addrlbase, x1, y1, auxDst);
+ addrlbase += nlwidth; /* @@@ NEXT PLANE @@@ */
+
+ fgrop = rrops[d];
+ bgrop = bgrrops[d];
+
+ e = saveE;
+ len = saveLen;
+ bit = mask[x1 & PIM];
+
+ rop = fgrop;
+ if (!isDoubleDash)
+ bgrop = -1;
+ if (dashIndex & 1)
+ rop = bgrop;
+
+ if (axis == X_AXIS) {
+ if (signdx > 0) {
+ while (len--) {
+ if (rop == RROP_BLACK)
+ *addrl &= ~bit;
+ else if (rop == RROP_WHITE)
+ *addrl |= bit;
+ else if (rop == RROP_INVERT)
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0) {
+ ilbmScanlineInc(addrl, yinc);
+ e += e3;
+ }
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ StepDash
+ }
+ } else {
+ while (len--) {
+ if (rop == RROP_BLACK)
+ *addrl &= ~bit;
+ else if (rop == RROP_WHITE)
+ *addrl |= bit;
+ else if (rop == RROP_INVERT)
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0) {
+ ilbmScanlineInc(addrl, yinc);
+ e += e3;
+ }
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit;addrl --; }
+ StepDash
+ }
+ }
+ } /* if X_AXIS */ else {
+ if (signdx > 0) {
+ while (len--) {
+ if (rop == RROP_BLACK)
+ *addrl &= ~bit;
+ else if (rop == RROP_WHITE)
+ *addrl |= bit;
+ else if (rop == RROP_INVERT)
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0) {
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ e += e3;
+ }
+ ilbmScanlineInc(addrl, yinc);
+ StepDash
+ }
+ } else {
+ while (len--) {
+ if (rop == RROP_BLACK)
+ *addrl &= ~bit;
+ else if (rop == RROP_WHITE)
+ *addrl |= bit;
+ else if (rop == RROP_INVERT)
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0) {
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit;addrl --; }
+ e += e3;
+ }
+ ilbmScanlineInc(addrl, yinc);
+ StepDash
+ }
+ }
+ } /* else Y_AXIS */
+ } /* for (d = ...) */
+ *pdashIndex = dashIndex;
+ *pdashOffset = pDash[dashIndex] - dashRemaining;
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmbstore.c b/nx-X11/programs/Xserver/ilbm/ilbmbstore.c
new file mode 100644
index 000000000..56811792f
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmbstore.c
@@ -0,0 +1,159 @@
+/* $XFree86$ */
+/* $XConsortium: ilbmbstore.c,v 5.7 94/04/17 20:28:18 dpw Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/*
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the X Consortium.
+
+*/
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "ilbm.h"
+#include <X11/X.h>
+#include "mibstore.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * ilbmSaveAreas --
+ * Function called by miSaveAreas to actually fetch the areas to be
+ * saved into the backing pixmap. This is very simple to do, since
+ * ilbmDoBitblt is designed for this very thing. The region to save is
+ * already destination-relative and we're given the offset to the
+ * window origin, so we have only to create an array of points of the
+ * u.l. corners of the boxes in the region translated to the screen
+ * coordinate system and fetch the screen pixmap out of its devPrivate
+ * field....
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Data are copied from the screen into the pixmap.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+ilbmSaveAreas(pPixmap, prgnSave, xorg, yorg, pWin)
+ PixmapPtr pPixmap; /* Backing pixmap */
+ RegionPtr prgnSave; /* Region to save (pixmap-relative) */
+ int xorg; /* X origin of region */
+ int yorg; /* Y origin of region */
+ WindowPtr pWin;
+{
+ register DDXPointPtr pPt;
+ DDXPointPtr pPtsInit;
+ register BoxPtr pBox;
+ register int numRects;
+
+ numRects = REGION_NUM_RECTS(prgnSave);
+ pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects * sizeof(DDXPointRec));
+ if (!pPtsInit)
+ return;
+
+ pBox = REGION_RECTS(prgnSave);
+ pPt = pPtsInit;
+ while (numRects--) {
+ pPt->x = pBox->x1 + xorg;
+ pPt->y = pBox->y1 + yorg;
+ pPt++;
+ pBox++;
+ }
+
+ ilbmDoBitblt((DrawablePtr)pPixmap->drawable.pScreen->devPrivates[ilbmScreenPrivateIndex].ptr,
+ (DrawablePtr)pPixmap,
+ GXcopy,
+ prgnSave,
+ pPtsInit, wBackingBitPlanes (pWin));
+
+ DEALLOCATE_LOCAL(pPtsInit);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * ilbmRestoreAreas --
+ * Function called by miRestoreAreas to actually fetch the areas to be
+ * restored from the backing pixmap. This is very simple to do, since
+ * ilbmDoBitblt is designed for this very thing. The region to restore is
+ * already destination-relative and we're given the offset to the
+ * window origin, so we have only to create an array of points of the
+ * u.l. corners of the boxes in the region translated to the pixmap
+ * coordinate system and fetch the screen pixmap out of its devPrivate
+ * field....
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Data are copied from the pixmap into the screen.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+ilbmRestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin)
+ PixmapPtr pPixmap; /* Backing pixmap */
+ RegionPtr prgnRestore; /* Region to restore (screen-relative)*/
+ int xorg; /* X origin of window */
+ int yorg; /* Y origin of window */
+ WindowPtr pWin;
+{
+ register DDXPointPtr pPt;
+ DDXPointPtr pPtsInit;
+ register BoxPtr pBox;
+ register int numRects;
+
+ numRects = REGION_NUM_RECTS(prgnRestore);
+ pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects*sizeof(DDXPointRec));
+ if (!pPtsInit)
+ return;
+
+ pBox = REGION_RECTS(prgnRestore);
+ pPt = pPtsInit;
+ while (numRects--) {
+ pPt->x = pBox->x1 - xorg;
+ pPt->y = pBox->y1 - yorg;
+ pPt++;
+ pBox++;
+ }
+
+ ilbmDoBitblt((DrawablePtr)pPixmap,
+ (DrawablePtr)pPixmap->drawable.pScreen->devPrivates[ilbmScreenPrivateIndex].ptr,
+ GXcopy,
+ prgnRestore,
+ pPtsInit, wBackingBitPlanes (pWin));
+
+ DEALLOCATE_LOCAL(pPtsInit);
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmclip.c b/nx-X11/programs/Xserver/ilbm/ilbmclip.c
new file mode 100644
index 000000000..704b5a9cd
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmclip.c
@@ -0,0 +1,246 @@
+/* $XFree86$ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmclip.c,v 5.6 94/04/17 20:28:19 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "miscstruct.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "regionstr.h"
+#include "gc.h"
+#include "maskbits.h"
+#include "mi.h"
+
+#define ADDRECT(reg,r,fr,rx1,ry1,rx2,ry2) \
+if (((rx1) < (rx2)) && ((ry1) < (ry2)) && \
+ (!((reg)->data->numRects && \
+ ((r-1)->y1 == (ry1)) && \
+ ((r-1)->y2 == (ry2)) && \
+ ((r-1)->x1 <= (rx1)) && \
+ ((r-1)->x2 >= (rx2))))) { \
+ if ((reg)->data->numRects == (reg)->data->size) { \
+ miRectAlloc(reg, 1); \
+ fr = REGION_BOXPTR(reg); \
+ r = fr + (reg)->data->numRects; \
+ } \
+ r->x1 = (rx1); \
+ r->y1 = (ry1); \
+ r->x2 = (rx2); \
+ r->y2 = (ry2); \
+ (reg)->data->numRects++; \
+ if (r->x1 < (reg)->extents.x1) \
+ (reg)->extents.x1 = r->x1; \
+ if (r->x2 > (reg)->extents.x2) \
+ (reg)->extents.x2 = r->x2; \
+ r++; \
+}
+
+/* Convert bitmap clip mask into clipping region.
+ * First, goes through each line and makes boxes by noting the transitions
+ * from 0 to 1 and 1 to 0.
+ * Then it coalesces the current line with the previous if they have boxes
+ * at the same X coordinates.
+ */
+RegionPtr
+ilbmPixmapToRegion(pPix)
+ PixmapPtr pPix;
+{
+ register RegionPtr pReg;
+ register PixelType *pw, w;
+ register int ib;
+ int width, h, base, rx1, crects;
+ PixelType *pwLineEnd;
+ int irectPrevStart, irectLineStart;
+ register BoxPtr prectO, prectN;
+ BoxPtr FirstRect, rects, prectLineStart;
+ Bool fInBox, fSame;
+ register PixelType mask0 = mask[0];
+ PixelType *pwLine;
+ int nWidth;
+
+ pReg = REGION_CREATE(pPix->drawable.pScreen, NULL, 1);
+ if (!pReg)
+ return(NullRegion);
+ FirstRect = REGION_BOXPTR(pReg);
+ rects = FirstRect;
+
+ pwLine = (PixelType *)pPix->devPrivate.ptr;
+ nWidth = pPix->devKind/PGSZB;
+
+ width = pPix->drawable.width;
+ pReg->extents.x1 = width - 1;
+ pReg->extents.x2 = 0;
+ irectPrevStart = -1;
+ for (h = 0; h < pPix->drawable.height; h++) {
+ pw = pwLine;
+ pwLine += nWidth;
+ irectLineStart = rects - FirstRect;
+ /* If the Screen left most bit of the word is set, we're starting in
+ * a box */
+ if (*pw & mask0) {
+ fInBox = TRUE;
+ rx1 = 0;
+ } else
+ fInBox = FALSE;
+ /* Process all words which are fully in the pixmap */
+ pwLineEnd = pw + (width >> PWSH);
+ for (base = 0; pw < pwLineEnd; base += PPW) {
+ w = *pw++;
+ if (fInBox) {
+ if (!~w)
+ continue;
+ } else {
+ if (!w)
+ continue;
+ }
+ for (ib = 0; ib < PPW; ib++) {
+ /* If the Screen left most bit of the word is set, we're
+ * starting a box */
+ if (w & mask0) {
+ if (!fInBox) {
+ rx1 = base + ib;
+ /* start new box */
+ fInBox = TRUE;
+ }
+ } else {
+ if (fInBox) {
+ /* end box */
+ ADDRECT(pReg, rects, FirstRect, rx1, h, base + ib, h + 1);
+ fInBox = FALSE;
+ }
+ }
+ /* Shift the word VISUALLY left one. */
+ w = SCRLEFT(w, 1);
+ }
+ }
+ if (width & PIM) {
+ /* Process final partial word on line */
+ w = *pw++;
+ for (ib = 0; ib < (width & PIM); ib++) {
+ /* If the Screen left most bit of the word is set, we're
+ * starting a box */
+ if (w & mask0) {
+ if (!fInBox) {
+ rx1 = base + ib;
+ /* start new box */
+ fInBox = TRUE;
+ }
+ } else {
+ if (fInBox) {
+ /* end box */
+ ADDRECT(pReg, rects, FirstRect,
+ rx1, h, base + ib, h + 1);
+ fInBox = FALSE;
+ }
+ }
+ /* Shift the word VISUALLY left one. */
+ w = SCRLEFT(w, 1);
+ }
+ }
+ /* If scanline ended with last bit set, end the box */
+ if (fInBox) {
+ ADDRECT(pReg, rects, FirstRect,
+ rx1, h, base + (width & PIM), h + 1);
+ }
+ /* if all rectangles on this line have the same x-coords as
+ * those on the previous line, then add 1 to all the previous y2s and
+ * throw away all the rectangles from this line
+ */
+ fSame = FALSE;
+ if (irectPrevStart != -1) {
+ crects = irectLineStart - irectPrevStart;
+ if (crects == ((rects - FirstRect) - irectLineStart)) {
+ prectO = FirstRect + irectPrevStart;
+ prectN = prectLineStart = FirstRect + irectLineStart;
+ fSame = TRUE;
+ while (prectO < prectLineStart) {
+ if ((prectO->x1 != prectN->x1) || (prectO->x2 != prectN->x2)) {
+ fSame = FALSE;
+ break;
+ }
+ prectO++;
+ prectN++;
+ }
+ if (fSame) {
+ prectO = FirstRect + irectPrevStart;
+ while (prectO < prectLineStart) {
+ prectO->y2 += 1;
+ prectO++;
+ }
+ rects -= crects;
+ pReg->data->numRects -= crects;
+ }
+ }
+ }
+ if (!fSame)
+ irectPrevStart = irectLineStart;
+ }
+ if (!pReg->data->numRects)
+ pReg->extents.x1 = pReg->extents.x2 = 0;
+ else {
+ pReg->extents.y1 = REGION_BOXPTR(pReg)->y1;
+ pReg->extents.y2 = REGION_END(pReg)->y2;
+ if (pReg->data->numRects == 1) {
+ xfree(pReg->data);
+ pReg->data = (RegDataPtr)NULL;
+ }
+ }
+#ifdef DEBUG
+ if (!miValidRegion(pReg))
+ FatalError("Assertion failed file %s, line %d: expr\n", __FILE__, __LINE__);
+#endif
+ return(pReg);
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmcmap.c b/nx-X11/programs/Xserver/ilbm/ilbmcmap.c
new file mode 100644
index 000000000..e485fb6fe
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmcmap.c
@@ -0,0 +1,128 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmcmap.c,v 3.0 1996/08/18 01:53:46 dawes Exp $ */
+/* $XConsortium: ilbmcmap.c,v 4.19 94/04/17 20:28:46 dpw Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "colormapst.h"
+#include "resource.h"
+#include "micmap.h"
+
+int
+ilbmListInstalledColormaps(pScreen, pmaps)
+ ScreenPtr pScreen;
+ Colormap *pmaps;
+{
+ return miListInstalledColormaps(pScreen, pmaps);
+}
+
+
+void
+ilbmInstallColormap(pmap)
+ ColormapPtr pmap;
+{
+ miInstallColormap(pmap);
+}
+
+void
+ilbmUninstallColormap(pmap)
+ ColormapPtr pmap;
+{
+ miUninstallColormap(pmap);
+}
+
+void
+ilbmResolveColor(pred, pgreen, pblue, pVisual)
+ unsigned short *pred, *pgreen, *pblue;
+ register VisualPtr pVisual;
+{
+ miResolveColor(pred, pgreen, pblue, pVisual);
+}
+
+Bool
+ilbmInitializeColormap(pmap)
+ register ColormapPtr pmap;
+{
+ return miInitializeColormap(pmap);
+}
+
+int
+ilbmExpandDirectColors(pmap, ndef, indefs, outdefs)
+ ColormapPtr pmap;
+ int ndef;
+ xColorItem *indefs, *outdefs;
+{
+ return miExpandDirectColors(pmap, ndef, indefs, outdefs);
+}
+
+Bool
+ilbmCreateDefColormap(pScreen)
+ ScreenPtr pScreen;
+{
+ return miCreateDefColormap(pScreen);
+}
+
+Bool
+ilbmSetVisualTypes(depth, visuals, bitsPerRGB)
+ int depth;
+ int visuals;
+ int bitsPerRGB;
+{
+ return miSetVisualTypes(depth, visuals, bitsPerRGB, -1);
+}
+
+/*
+ * Given a list of formats for a screen, create a list
+ * of visuals and depths for the screen which correspond to
+ * the set which can be used with this version of ilbm.
+ */
+
+Bool
+ilbmInitVisuals(visualp, depthp, nvisualp, ndepthp, rootDepthp, defaultVisp,
+ sizes, bitsPerRGB)
+ VisualPtr *visualp;
+ DepthPtr *depthp;
+ int *nvisualp, *ndepthp;
+ int *rootDepthp;
+ VisualID *defaultVisp;
+ unsigned long sizes;
+ int bitsPerRGB;
+{
+ return miInitVisuals(visualp, depthp, nvisualp, ndepthp, rootDepthp,
+ defaultVisp, sizes, bitsPerRGB, -1);
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmfillarc.c b/nx-X11/programs/Xserver/ilbm/ilbmfillarc.c
new file mode 100644
index 000000000..a5ab6c4a2
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmfillarc.c
@@ -0,0 +1,377 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmfillarc.c,v 3.0 1996/08/18 01:53:48 dawes Exp $ */
+/************************************************************
+
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+********************************************************/
+
+/* $XConsortium: ilbmfillarc.c,v 5.14 94/04/17 20:28:20 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "miscstruct.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "ilbm.h"
+#include "maskbits.h"
+#include "mifillarc.h"
+#include "mi.h"
+
+static void
+ilbmFillEllipseSolid(pDraw, arc, rrops)
+ DrawablePtr pDraw;
+ xArc *arc;
+ register unsigned char *rrops;
+{
+ int x, y, e;
+ int yk, xk, ym, xm, dx, dy, xorg, yorg;
+ register int slw;
+ miFillArcRec info;
+ PixelType *addrlt, *addrlb;
+ register PixelType *pdst;
+ PixelType *addrl;
+ register int n;
+ register int d;
+ int nlwidth;
+ register int xpos;
+ PixelType startmask, endmask;
+ int nlmiddle;
+ int depthDst;
+ int auxDst;
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst,
+ addrlt);
+ miFillArcSetup(arc, &info);
+ MIFILLARCSETUP();
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ addrlb = addrlt;
+ addrlt += auxDst * (yorg - y);
+ addrlb += auxDst * (yorg + y + dy);
+ while (y) {
+ addrlt += auxDst;
+ addrlb -= auxDst;
+ MIFILLARCSTEP(slw);
+ if (!slw)
+ continue;
+ xpos = xorg - x;
+ pdst = addrl = ilbmScanlineOffset(addrlt, (xpos >> PWSH));
+ if (((xpos & PIM) + slw) < PPW) {
+ maskpartialbits(xpos, slw, startmask);
+ for (d = 0; d < depthDst; d++, pdst += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ *pdst &= ~startmask;
+ break;
+ case RROP_WHITE:
+ *pdst |= startmask;
+ break;
+ case RROP_INVERT:
+ *pdst ^= startmask;
+ break;
+ case RROP_NOP:
+ break;
+ }
+ }
+ if (miFillArcLower(slw)) {
+ pdst = ilbmScanlineOffset(addrlb, (xpos >> PWSH));
+
+ for (d = 0; d < depthDst; d++, pdst += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ *pdst &= ~startmask;
+ break;
+ case RROP_WHITE:
+ *pdst |= startmask;
+ break;
+ case RROP_INVERT:
+ *pdst ^= startmask;
+ break;
+ case RROP_NOP:
+ break;
+ }
+ }
+ }
+ continue;
+ }
+ maskbits(xpos, slw, startmask, endmask, nlmiddle);
+ for (d = 0; d < depthDst; d++, addrl += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ n = nlmiddle;
+ pdst = addrl;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ if (startmask)
+ *pdst++ &= ~startmask;
+ while (n--)
+ *pdst++ = 0;
+ if (endmask)
+ *pdst &= ~endmask;
+ break;
+
+ case RROP_WHITE:
+ if (startmask)
+ *pdst++ |= startmask;
+ while (n--)
+ *pdst++ = ~0;
+ if (endmask)
+ *pdst |= endmask;
+ break;
+
+ case RROP_INVERT:
+ if (startmask)
+ *pdst++ ^= startmask;
+ while (n--)
+ *pdst++ ^= ~0;
+ if (endmask)
+ *pdst ^= endmask;
+ break;
+
+ case RROP_NOP:
+ break;
+ }
+ }
+ if (!miFillArcLower(slw))
+ continue;
+ addrl = ilbmScanlineOffset(addrlb, (xpos >> PWSH));
+ for (d = 0; d < depthDst; d++, addrl += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ n = nlmiddle;
+ pdst = addrl;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ if (startmask)
+ *pdst++ &= ~startmask;
+ while (n--)
+ *pdst++ = 0;
+ if (endmask)
+ *pdst &= ~endmask;
+ break;
+
+ case RROP_WHITE:
+ if (startmask)
+ *pdst++ |= startmask;
+ while (n--)
+ *pdst++ = ~0;
+ if (endmask)
+ *pdst |= endmask;
+ break;
+
+ case RROP_INVERT:
+ if (startmask)
+ *pdst++ ^= startmask;
+ while (n--)
+ *pdst++ ^= ~0;
+ if (endmask)
+ *pdst ^= endmask;
+ break;
+
+ case RROP_NOP:
+ break;
+ }
+ }
+ }
+}
+
+#define FILLSPAN(xl,xr,addr) \
+ if (xr >= xl) { \
+ width = xr - xl + 1; \
+ addrl = ilbmScanlineOffset(addr, (xl >> PWSH)); \
+ if (((xl & PIM) + width) < PPW) { \
+ maskpartialbits(xl, width, startmask); \
+ for (pdst = addrl, d = 0; d < depthDst; d++, pdst += nlwidth) { /* @@@ NEXT PLANE @@@ */ \
+ switch (rrops[d]) { \
+ case RROP_BLACK: \
+ *pdst &= ~startmask; \
+ break; \
+ case RROP_WHITE: \
+ *pdst |= startmask; \
+ break; \
+ case RROP_INVERT: \
+ *pdst ^= startmask; \
+ break; \
+ case RROP_NOP: \
+ break; \
+ } \
+ } \
+ } else { \
+ maskbits(xl, width, startmask, endmask, nlmiddle); \
+ for (d = 0; d < depthDst; d++, addrl += nlwidth) { /* @@@ NEXT PLANE @@@ */ \
+ n = nlmiddle; \
+ pdst = addrl; \
+ switch (rrops[d]) { \
+ case RROP_BLACK: \
+ if (startmask) \
+ *pdst++ &= ~startmask; \
+ while (n--) \
+ *pdst++ = 0; \
+ if (endmask) \
+ *pdst &= ~endmask; \
+ break; \
+ case RROP_WHITE: \
+ if (startmask) \
+ *pdst++ |= startmask; \
+ while (n--) \
+ *pdst++ = ~0; \
+ if (endmask) \
+ *pdst |= endmask; \
+ break; \
+ case RROP_INVERT: \
+ if (startmask) \
+ *pdst++ ^= startmask; \
+ while (n--) \
+ *pdst++ ^= ~0; \
+ if (endmask) \
+ *pdst ^= endmask; \
+ break; \
+ case RROP_NOP: \
+ break; \
+ } \
+ } \
+ } \
+ }
+
+#define FILLSLICESPANS(flip,addr) \
+ if (!flip) { \
+ FILLSPAN(xl, xr, addr); \
+ } else { \
+ xc = xorg - x; \
+ FILLSPAN(xc, xr, addr); \
+ xc += slw - 1; \
+ FILLSPAN(xl, xc, addr); \
+ }
+
+static void
+ilbmFillArcSliceSolidCopy(pDraw, pGC, arc, rrops)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ xArc *arc;
+ register unsigned char *rrops;
+{
+ PixelType *addrl;
+ register PixelType *pdst;
+ register int n;
+ register int d;
+ int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
+ register int x, y, e;
+ miFillArcRec info;
+ miArcSliceRec slice;
+ int xl, xr, xc;
+ PixelType *addrlt, *addrlb;
+ int nlwidth;
+ int width;
+ PixelType startmask, endmask;
+ int nlmiddle;
+ int auxDst;
+ int depthDst;
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst,
+ addrlt);
+ miFillArcSetup(arc, &info);
+ miFillArcSliceSetup(arc, &slice, pGC);
+ MIFILLARCSETUP();
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ addrlb = addrlt;
+ addrlt = ilbmScanlineDeltaNoBankSwitch(addrlt, yorg - y, auxDst);
+ addrlb = ilbmScanlineDeltaNoBankSwitch(addrlb, yorg + y + dy, auxDst);
+ slice.edge1.x += pDraw->x;
+ slice.edge2.x += pDraw->x;
+ while (y > 0) {
+ ilbmScanlineIncNoBankSwitch(addrlt, auxDst);
+ ilbmScanlineIncNoBankSwitch(addrlb, -auxDst);
+ MIFILLARCSTEP(slw);
+ MIARCSLICESTEP(slice.edge1);
+ MIARCSLICESTEP(slice.edge2);
+ if (miFillSliceUpper(slice)) {
+ MIARCSLICEUPPER(xl, xr, slice, slw);
+ FILLSLICESPANS(slice.flip_top, addrlt);
+ }
+ if (miFillSliceLower(slice)) {
+ MIARCSLICELOWER(xl, xr, slice, slw);
+ FILLSLICESPANS(slice.flip_bot, addrlb);
+ }
+ }
+}
+
+void
+ilbmPolyFillArcSolid(pDraw, pGC, narcs, parcs)
+ register DrawablePtr pDraw;
+ GCPtr pGC;
+ int narcs;
+ xArc *parcs;
+{
+ ilbmPrivGC *priv;
+ register xArc *arc;
+ register int i;
+ int x2, y2;
+ BoxRec box;
+ RegionPtr cclip;
+ unsigned char *rrops;
+
+ priv = (ilbmPrivGC *) pGC->devPrivates[ilbmGCPrivateIndex].ptr;
+ rrops = priv->rrops;
+ cclip = pGC->pCompositeClip;
+ for (arc = parcs, i = narcs; --i >= 0; arc++) {
+ if (miFillArcEmpty(arc))
+ continue;
+ if (miCanFillArc(arc)) {
+ box.x1 = arc->x + pDraw->x;
+ box.y1 = arc->y + pDraw->y;
+ /*
+ * Because box.x2 and box.y2 get truncated to 16 bits, and the
+ * RECT_IN_REGION test treats the resulting number as a signed
+ * integer, the RECT_IN_REGION test alone can go the wrong way.
+ * This can result in a server crash because the rendering
+ * routines in this file deal directly with cpu addresses
+ * of pixels to be stored, and do not clip or otherwise check
+ * that all such addresses are within their respective pixmaps.
+ * So we only allow the RECT_IN_REGION test to be used for
+ * values that can be expressed correctly in a signed short.
+ */
+ x2 = box.x1 + (int)arc->width + 1;
+ box.x2 = x2;
+ y2 = box.y1 + (int)arc->height + 1;
+ box.y2 = y2;
+ if ( (x2 <= MAXSHORT) && (y2 <= MAXSHORT) &&
+ (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) ) {
+ if ((arc->angle2 >= FULLCIRCLE) ||
+ (arc->angle2 <= -FULLCIRCLE))
+ ilbmFillEllipseSolid(pDraw, arc, rrops);
+ else
+ ilbmFillArcSliceSolidCopy(pDraw, pGC, arc, rrops);
+ continue;
+ }
+ }
+ miPolyFillArc(pDraw, pGC, 1, arc);
+ }
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmfillrct.c b/nx-X11/programs/Xserver/ilbm/ilbmfillrct.c
new file mode 100644
index 000000000..604046080
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmfillrct.c
@@ -0,0 +1,299 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmfillrct.c,v 3.0 1996/08/18 01:53:49 dawes Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmfillrct.c,v 5.10 94/04/17 20:28:21 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "pixmapstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "miscstruct.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+
+#include "ilbm.h"
+#include "maskbits.h"
+
+#define MODEQ(a, b) ((a) %= (b))
+void ilbmPaintOddSize();
+
+/*
+ filled rectangles.
+ translate the rectangles, clip them, and call the
+helper function in the GC.
+*/
+
+#define NUM_STACK_RECTS 1024
+
+void
+ilbmPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nrectFill; /* number of rectangles to fill */
+ xRectangle *prectInit; /* Pointer to first rectangle to fill */
+{
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ register BoxPtr pbox;
+ register BoxPtr pboxClipped;
+ BoxPtr pboxClippedBase;
+ BoxPtr pextent;
+ BoxRec stackRects[NUM_STACK_RECTS];
+ int numRects;
+ int n;
+ int xorg, yorg;
+ ilbmPrivGC *priv;
+ PixmapPtr ppix;
+ unsigned char *rrops;
+ unsigned char *rropsOS;
+
+ priv = (ilbmPrivGC *)pGC->devPrivates[ilbmGCPrivateIndex].ptr;
+ ppix = pGC->pRotatedPixmap;
+ prgnClip = pGC->pCompositeClip;
+ rrops = priv->rrops;
+ rropsOS = priv->rropOS;
+
+ prect = prectInit;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ if (xorg || yorg) {
+ prect = prectInit;
+ n = nrectFill;
+ Duff(n, prect->x += xorg; prect->y += yorg; prect++);
+ }
+
+ prect = prectInit;
+
+ numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
+ if (numRects > NUM_STACK_RECTS) {
+ pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(numRects * sizeof(BoxRec));
+ if (!pboxClippedBase)
+ return;
+ }
+ else
+ pboxClippedBase = stackRects;
+
+ pboxClipped = pboxClippedBase;
+
+ if (REGION_NUM_RECTS(prgnClip) == 1) {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_RECTS(prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--) {
+ if ((pboxClipped->x1 = prect->x) < x1)
+ pboxClipped->x1 = x1;
+
+ if ((pboxClipped->y1 = prect->y) < y1)
+ pboxClipped->y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ pboxClipped->x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ pboxClipped->y2 = by2;
+
+ prect++;
+ if ((pboxClipped->x1 < pboxClipped->x2) &&
+ (pboxClipped->y1 < pboxClipped->y2)) {
+ pboxClipped++;
+ }
+ }
+ } else {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--) {
+ BoxRec box;
+
+ if ((box.x1 = prect->x) < x1)
+ box.x1 = x1;
+
+ if ((box.y1 = prect->y) < y1)
+ box.y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ box.x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ box.y2 = by2;
+
+ prect++;
+
+ if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
+ continue;
+
+ n = REGION_NUM_RECTS (prgnClip);
+ pbox = REGION_RECTS(prgnClip);
+
+ /* clip the rectangle to each box in the clip region
+ this is logically equivalent to calling Intersect()
+ */
+ while (n--) {
+ pboxClipped->x1 = max(box.x1, pbox->x1);
+ pboxClipped->y1 = max(box.y1, pbox->y1);
+ pboxClipped->x2 = min(box.x2, pbox->x2);
+ pboxClipped->y2 = min(box.y2, pbox->y2);
+ pbox++;
+
+ /* see if clipping left anything */
+ if (pboxClipped->x1 < pboxClipped->x2 &&
+ pboxClipped->y1 < pboxClipped->y2)
+ pboxClipped++;
+ }
+ }
+ }
+ if (pboxClipped != pboxClippedBase) {
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ ilbmSolidFillArea(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, rrops);
+ break;
+ case FillTiled:
+ switch (pGC->alu) {
+ case GXcopy:
+ if (pGC->pRotatedPixmap)
+ ilbmTileAreaPPWCopy(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, GXcopy,
+ pGC->pRotatedPixmap, pGC->planemask);
+ else
+ ilbmTileAreaCopy(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, GXcopy, pGC->tile.pixmap,
+ pGC->patOrg.x, pGC->patOrg.y,
+ pGC->planemask);
+ break;
+
+ default:
+ if (pGC->pRotatedPixmap)
+ ilbmTileAreaPPWGeneral(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, pGC->alu,
+ pGC->pRotatedPixmap,
+ pGC->planemask);
+ else
+ ilbmTileAreaGeneral(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, pGC->alu,
+ pGC->tile.pixmap, pGC->patOrg.x,
+ pGC->patOrg.y, pGC->planemask);
+ break;
+ } /* switch (alu) */
+ break;
+
+ case FillStippled:
+ if (pGC->pRotatedPixmap)
+ ilbmStippleAreaPPW(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, pGC->pRotatedPixmap, rrops);
+ else
+ ilbmStippleArea(pDrawable, pboxClipped-pboxClippedBase,
+ pboxClippedBase, pGC->stipple, pGC->patOrg.x,
+ pGC->patOrg.y, rrops);
+ break;
+
+ case FillOpaqueStippled:
+ switch (pGC->alu) {
+ case GXcopy:
+ if (pGC->pRotatedPixmap)
+ ilbmOpaqueStippleAreaPPWCopy(pDrawable,
+ pboxClipped-pboxClippedBase,
+ pboxClippedBase, GXcopy,
+ pGC->pRotatedPixmap, rropsOS,
+ pGC->planemask);
+ else
+ ilbmOpaqueStippleAreaCopy(pDrawable,
+ pboxClipped-pboxClippedBase,
+ pboxClippedBase, GXcopy,
+ pGC->stipple, pGC->patOrg.x,
+ pGC->patOrg.y, rropsOS,
+ pGC->planemask);
+ break;
+
+ default:
+ if (pGC->pRotatedPixmap)
+ ilbmOpaqueStippleAreaPPWGeneral(pDrawable,
+ pboxClipped-pboxClippedBase,
+ pboxClippedBase, pGC->alu,
+ pGC->pRotatedPixmap,
+ rropsOS, pGC->planemask);
+ else
+ ilbmOpaqueStippleAreaGeneral(pDrawable,
+ pboxClipped-pboxClippedBase,
+ pboxClippedBase, pGC->alu,
+ pGC->stipple, pGC->patOrg.x,
+ pGC->patOrg.y, rropsOS,
+ pGC->planemask);
+ break;
+ } /* switch (alu) */
+ break;
+ }
+ }
+ if (pboxClippedBase != stackRects)
+ DEALLOCATE_LOCAL(pboxClippedBase);
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmfillsp.c b/nx-X11/programs/Xserver/ilbm/ilbmfillsp.c
new file mode 100644
index 000000000..321154330
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmfillsp.c
@@ -0,0 +1,1149 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmfillsp.c,v 3.0 1996/08/18 01:53:50 dawes Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmfillsp.c,v 5.13 94/04/17 20:28:21 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "ilbm.h"
+#include "maskbits.h"
+
+#include "mergerop.h"
+
+#include "servermd.h"
+#include "mi.h"
+#include "mispans.h"
+
+/* scanline filling for monochrome frame buffer
+ written by drewry, oct 1986
+
+ these routines all clip. they assume that anything that has called
+them has already translated the points (i.e. pGC->miTranslate is
+non-zero, which is howit gets set in ilbmCreateGC().)
+
+ the number of new scnalines created by clipping ==
+MaxRectsPerBand * nSpans.
+
+*/
+
+
+void
+ilbmSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ PixelType *pBase;
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *addrl;/* pointer to current longword in bitmap */
+ register int nlmiddle;
+ register PixelType startmask;
+ register PixelType endmask;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ int depthDst;
+ int auxDst;
+ int d;
+ unsigned char *rrops;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if (!pptFree || !pwidthFree) {
+ if (pptFree)
+ DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree)
+ DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
+ pBase);
+ rrops = ((ilbmPrivGC *)(pGC->devPrivates[ilbmGCPrivateIndex].ptr))->rrops;
+ while (n--) {
+ addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
+
+ for (d = 0; d < depthDst; d++, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ if (*pwidth) {
+ addrl = addrlBase;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ /* all bits inside same longword */
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl &= ~startmask;
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ &= ~startmask;
+ Duff (nlmiddle, *addrl++ = 0x0);
+ if (endmask)
+ *addrl &= ~endmask;
+ }
+ break;
+
+ case RROP_WHITE:
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ /* all bits inside same longword */
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl |= startmask;
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ |= startmask;
+ Duff (nlmiddle, *addrl++ = ~0);
+ if (endmask)
+ *addrl |= endmask;
+ }
+ break;
+ case RROP_INVERT:
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ /* all bits inside same longword */
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl ^= startmask;
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ ^= startmask;
+ Duff (nlmiddle, *addrl++ ^= ~0);
+ if (endmask)
+ *addrl ^= endmask;
+ }
+ break;
+ case RROP_NOP:
+ break;
+ }
+ }
+ }
+ pwidth++;
+ ppt++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+void
+ilbmStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ PixelType *pBase;
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *addrl;/* pointer to current longword in bitmap */
+ register PixelType src;
+ register int nlmiddle;
+ register PixelType startmask;
+ register PixelType endmask;
+ PixmapPtr pStipple;
+ PixelType *psrc;
+ int tileHeight;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ int d;
+ int depthDst;
+ int auxDst;
+ unsigned char *rrops;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if (!pptFree || !pwidthFree) {
+ if (pptFree)
+ DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree)
+ DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
+ pBase);
+
+ pStipple = pGC->pRotatedPixmap;
+ tileHeight = pStipple->drawable.height;
+ psrc = (PixelType *)(pStipple->devPrivate.ptr);
+
+ rrops = ((ilbmPrivGC *)(pGC->devPrivates[ilbmGCPrivateIndex].ptr))->rrops;
+
+ while (n--) {
+ src = psrc[ppt->y % tileHeight];
+ addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
+ for (d = 0; d < depthDst; d++, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ addrl = addrlBase;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ /* all bits inside same longword */
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl &= ~(src & startmask);
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ &= ~(src & startmask);
+ Duff (nlmiddle, *addrl++ &= ~src);
+ if (endmask)
+ *addrl &= ~(src & endmask);
+ }
+ break;
+ case RROP_WHITE:
+ /* all bits inside same longword */
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl |= (src & startmask);
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ |= (src & startmask);
+ Duff (nlmiddle, *addrl++ |= src);
+ if (endmask)
+ *addrl |= (src & endmask);
+ }
+ break;
+ case RROP_INVERT:
+ /* all bits inside same longword */
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl ^= (src & startmask);
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ ^= (src & startmask);
+ Duff (nlmiddle, *addrl++ ^= src);
+ if (endmask)
+ *addrl ^= (src & endmask);
+ }
+ break;
+
+ case RROP_NOP:
+ break;
+ }
+ }
+ pwidth++;
+ ppt++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+void
+ilbmTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ PixelType *pBase;
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *addrl; /* pointer to current longword in bitmap */
+ register PixelType src;
+ register int nlmiddle;
+ register PixelType startmask;
+ register PixelType endmask;
+ PixmapPtr pTile;
+ PixelType *psrc;
+ int tileHeight;
+ int rop;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ int auxDst;
+ int depthDst;
+ int d;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if (!pptFree || !pwidthFree) {
+ if (pptFree)
+ DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree)
+ DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
+ pBase);
+
+ pTile = pGC->pRotatedPixmap;
+ tileHeight = pTile->drawable.height;
+ psrc = (PixelType *)(pTile->devPrivate.ptr);
+ rop = pGC->alu;
+
+ switch (rop) {
+ case GXcopy:
+#define DoMaskCopyRop(src,dst,mask) ((dst) & ~(mask) | (src) & (mask))
+ while (n--) {
+ if (*pwidth) {
+ addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
+
+ for (d = 0; d < depthDst; d++, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ if (!(pGC->planemask & (1 << d)))
+ continue;
+
+ addrl = addrlBase;
+ src = psrc[ppt->y % tileHeight + tileHeight * d];
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl = DoMaskCopyRop (src, *addrl, startmask);
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask) {
+ *addrl = DoMaskCopyRop (src, *addrl, startmask);
+ addrl++;
+ }
+ while (nlmiddle--) {
+ *addrl = src;
+ addrl++;
+ }
+ if (endmask)
+ *addrl = DoMaskCopyRop (src, *addrl, endmask);
+ }
+ }
+ }
+ pwidth++;
+ ppt++;
+ }
+ break;
+
+ default:
+ {
+ register DeclareMergeRop ();
+
+ InitializeMergeRop(rop,~0);
+ while (n--) {
+ if (*pwidth) {
+ addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
+ for (d = 0; d < depthDst; d++, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ if (!(pGC->planemask & (1 << d)))
+ continue;
+
+ addrl = addrlBase;
+
+ src = psrc[ppt->y % tileHeight + tileHeight * d];
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl = DoMaskMergeRop (src, *addrl, startmask);
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask) {
+ *addrl = DoMaskMergeRop (src, *addrl, startmask);
+ addrl++;
+ }
+ while (nlmiddle--) {
+ *addrl = DoMergeRop (src, *addrl);
+ addrl++;
+ }
+ if (endmask)
+ *addrl = DoMaskMergeRop (src, *addrl, endmask);
+ }
+ }
+ }
+ pwidth++;
+ ppt++;
+ }
+ break;
+ }
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+void
+ilbmOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ PixelType *pBase;
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *addrl; /* pointer to current longword in bitmap */
+ register PixelType src;
+ register int nlmiddle;
+ register PixelType startmask;
+ register PixelType endmask;
+ PixmapPtr pTile;
+ PixelType *psrc;
+ int tileHeight;
+ int rop;
+ unsigned char *rropsOS;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ int auxDst;
+ int depthDst;
+ int d;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if (!pptFree || !pwidthFree) {
+ if (pptFree)
+ DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree)
+ DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
+ pBase);
+
+ pTile = pGC->pRotatedPixmap;
+ tileHeight = pTile->drawable.height;
+ psrc = (PixelType *)(pTile->devPrivate.ptr);
+ rop = pGC->alu;
+ rropsOS = ((ilbmPrivGC *)(pGC->devPrivates[ilbmGCPrivateIndex].ptr))->rropOS;
+
+ switch (rop) {
+ case GXcopy:
+#define DoMaskCopyRop(src,dst,mask) ((dst) & ~(mask) | (src) & (mask))
+ while (n--) {
+ addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
+ if (*pwidth) {
+ for (d = 0; d < depthDst; d++, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ src = 0;
+ break;
+ case RROP_WHITE:
+ src = ~0;
+ break;
+ case RROP_INVERT:
+ src = ~psrc[ppt->y % tileHeight];
+ break;
+ case RROP_COPY:
+ src = psrc[ppt->y % tileHeight];
+ break;
+ case RROP_NOP:
+ continue;
+ }
+
+ addrl = addrlBase;
+
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl = DoMaskCopyRop (src, *addrl, startmask);
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask) {
+ *addrl = DoMaskCopyRop (src, *addrl, startmask);
+ addrl++;
+ }
+ while (nlmiddle--) {
+ *addrl = src;
+ addrl++;
+ }
+ if (endmask)
+ *addrl = DoMaskCopyRop (src, *addrl, endmask);
+ }
+ } /* for (d = ...) */
+ }
+
+ pwidth++;
+ ppt++;
+ }
+ break;
+
+ default:
+ {
+ register DeclareMergeRop ();
+
+ InitializeMergeRop(rop,~0);
+ while (n--) {
+ addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
+ if (*pwidth) {
+ for (d = 0; d < depthDst; d++, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ src = 0;
+ break;
+ case RROP_WHITE:
+ src = ~0;
+ break;
+ case RROP_INVERT:
+ src = ~psrc[ppt->y % tileHeight];
+ break;
+ case RROP_COPY:
+ src = psrc[ppt->y % tileHeight];
+ break;
+ case RROP_NOP:
+ continue;
+ }
+
+ addrl = addrlBase;
+
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl = DoMaskMergeRop (src, *addrl, startmask);
+ } else {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask) {
+ *addrl = DoMaskMergeRop (src, *addrl, startmask);
+ addrl++;
+ }
+ while (nlmiddle--) {
+ *addrl = DoMergeRop (src, *addrl);
+ addrl++;
+ }
+ if (endmask)
+ *addrl = DoMaskMergeRop (src, *addrl, endmask);
+ }
+ } /* for (d = ...) */
+ }
+ pwidth++;
+ ppt++;
+ } /* while (n) */
+ break;
+ }
+ } /* switch (rop) */
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+/* Fill spans with tiles that aren't PPW bits wide */
+void
+ilbmUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ int iline; /* first line of tile to use */
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ PixelType *pBase;
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *pdst;/* pointer to current word in bitmap */
+ register PixelType *psrc;/* pointer to current word in tile */
+ register int nlMiddle;
+ register int rop, nstart;
+ PixelType startmask;
+ PixmapPtr pTile; /* pointer to tile we want to fill with */
+ int w, width, x, xSrc, ySrc, srcStartOver, nend;
+ int tlwidth, rem, tileWidth, tileHeight, endinc;
+ PixelType endmask, *psrcT;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ int auxDst;
+ int sizeTile;
+ int depthDst;
+ register int d;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if (!pptFree || !pwidthFree) {
+ if (pptFree)
+ DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree)
+ DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ pTile = pGC->tile.pixmap;
+ tlwidth = pTile->devKind/PGSZB;
+ rop = pGC->alu;
+
+ xSrc = pDrawable->x;
+ ySrc = pDrawable->y;
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
+ pBase);
+
+ tileWidth = pTile->drawable.width;
+ tileHeight = pTile->drawable.height;
+ sizeTile = tlwidth * tileHeight;
+
+ /* this replaces rotating the tile. Instead we just adjust the offset
+ * at which we start grabbing bits from the tile.
+ * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
+ * so that iline and rem always stay within the tile bounds.
+ */
+ xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;
+ ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;
+
+ while (n--) {
+ iline = (ppt->y - ySrc) % tileHeight;
+ psrcT = (PixelType *) pTile->devPrivate.ptr + (iline * tlwidth);
+ addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
+
+ for (d = 0; d < depthDst; d++, psrcT += sizeTile, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ if (!(pGC->planemask & (1 << d)))
+ continue;
+
+ if (*pwidth) {
+ x = ppt->x;
+ pdst = addrlBase;
+ width = *pwidth;
+ while (width > 0) {
+ psrc = psrcT;
+ w = min(tileWidth, width);
+ if ((rem = (x - xSrc) % tileWidth) != 0) {
+ /* if we're in the middle of the tile, get
+ as many bits as will finish the span, or
+ as many as will get to the left edge of the tile,
+ or a longword worth, starting at the appropriate
+ offset in the tile.
+ */
+ w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
+ endinc = rem / BITMAP_SCANLINE_PAD;
+ getandputrop((psrc+endinc), (rem&PIM), (x & PIM), w, pdst, rop);
+ if ((x & PIM) + w >= PPW)
+ pdst++;
+ } else if (((x & PIM) + w) < PPW) {
+ /* doing < PPW bits is easy, and worth special-casing */
+ putbitsrop(*psrc, x & PIM, w, pdst, rop);
+ } else {
+ /* start at the left edge of the tile,
+ and put down as much as we can
+ */
+ maskbits(x, w, startmask, endmask, nlMiddle);
+
+ if (startmask)
+ nstart = PPW - (x & PIM);
+ else
+ nstart = 0;
+ if (endmask)
+ nend = (x + w) & PIM;
+ else
+ nend = 0;
+
+ srcStartOver = nstart > PLST;
+
+ if (startmask) {
+ putbitsrop(*psrc, (x & PIM), nstart, pdst, rop);
+ pdst++;
+ if (srcStartOver)
+ psrc++;
+ }
+
+ while (nlMiddle--) {
+ getandputrop0(psrc, nstart, PPW, pdst, rop);
+ pdst++;
+ psrc++;
+ }
+ if (endmask) {
+ getandputrop0(psrc, nstart, nend, pdst, rop);
+ }
+ }
+ x += w;
+ width -= w;
+ }
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+/* Fill spans with stipples that aren't PPW bits wide */
+void
+ilbmUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ int iline; /* first line of tile to use */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ PixelType *pBase;
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *pdst; /* pointer to current word in bitmap */
+ register PixelType *psrc; /* pointer to current word in tile */
+ register int nlMiddle;
+ register int rop, nstart;
+ PixelType startmask;
+ PixmapPtr pTile; /* pointer to tile we want to fill with */
+ int w, width, x, xSrc, ySrc, srcStartOver, nend;
+ PixelType endmask, *psrcT;
+ int tlwidth, rem, tileWidth, endinc;
+ int tileHeight;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ unsigned char *rrops;
+ register int d;
+ int auxDst;
+ int depthDst;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if (!pptFree || !pwidthFree) {
+ if (pptFree)
+ DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree)
+ DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ pTile = pGC->stipple;
+ tlwidth = pTile->devKind/PGSZB;
+ xSrc = pDrawable->x;
+ ySrc = pDrawable->y;
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
+ pBase);
+
+ tileWidth = pTile->drawable.width;
+ tileHeight = pTile->drawable.height;
+ rrops = ((ilbmPrivGC *)(pGC->devPrivates[ilbmGCPrivateIndex].ptr))->rrops;
+
+ /* this replaces rotating the stipple. Instead, we just adjust the offset
+ * at which we start grabbing bits from the stipple.
+ * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
+ * so that iline and rem always stay within the tile bounds.
+ */
+ xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;
+ ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;
+ while (n--) {
+ iline = (ppt->y - ySrc) % tileHeight;
+ psrcT = (PixelType *) pTile->devPrivate.ptr + (iline * tlwidth);
+ addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
+
+ for (d = 0; d < depthDst; d++, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ rop = rrops[d];
+ if (rop == RROP_NOP)
+ continue;
+
+ pdst = addrlBase;
+ x = ppt->x;
+
+ if (*pwidth) {
+ width = *pwidth;
+ while (width > 0) {
+ psrc = psrcT;
+ w = min(tileWidth, width);
+ if ((rem = (x - xSrc) % tileWidth) != 0) {
+ /* if we're in the middle of the tile, get
+ as many bits as will finish the span, or
+ as many as will get to the left edge of the tile,
+ or a longword worth, starting at the appropriate
+ offset in the tile.
+ */
+ w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
+ endinc = rem / BITMAP_SCANLINE_PAD;
+ getandputrrop((psrc + endinc), (rem & PIM), (x & PIM),
+ w, pdst, rop)
+ if ((x & PIM) + w >= PPW)
+ pdst++;
+ } else if (((x & PIM) + w) < PPW) {
+ /* doing < PPW bits is easy, and worth special-casing */
+ putbitsrrop(*psrc, x & PIM, w, pdst, rop);
+ } else {
+ /* start at the left edge of the tile,
+ and put down as much as we can
+ */
+ maskbits(x, w, startmask, endmask, nlMiddle);
+
+ if (startmask)
+ nstart = PPW - (x & PIM);
+ else
+ nstart = 0;
+ if (endmask)
+ nend = (x + w) & PIM;
+ else
+ nend = 0;
+
+ srcStartOver = nstart > PLST;
+
+ if (startmask) {
+ putbitsrrop(*psrc, (x & PIM), nstart, pdst, rop);
+ pdst++;
+ if (srcStartOver)
+ psrc++;
+ }
+
+ while (nlMiddle--) {
+ getandputrrop0(psrc, nstart, PPW, pdst, rop);
+ pdst++;
+ psrc++;
+ }
+ if (endmask) {
+ getandputrrop0(psrc, nstart, nend, pdst, rop);
+ }
+ }
+ x += w;
+ width -= w;
+ }
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+/* Fill spans with OpaqueStipples that aren't PPW bits wide */
+void
+ilbmUnnaturalOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ int iline; /* first line of tile to use */
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ PixelType *pBase;
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *pdst;/* pointer to current word in bitmap */
+ register PixelType *psrc;/* pointer to current word in tile */
+ register int nlMiddle;
+ register int d;
+ register PixelType tmpsrc;
+ register PixelType tmpdst;
+ register int alu, nstart;
+ register unsigned char *rropsOS;
+ PixelType startmask;
+ PixmapPtr pTile; /* pointer to tile we want to fill with */
+ int w, width, x, xSrc, ySrc, srcStartOver, nend;
+ int tlwidth, rem, tileWidth, tileHeight, endinc;
+ PixelType endmask, *psrcT;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ int auxDst;
+ int sizeTile;
+ int depthDst;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if (!pptFree || !pwidthFree) {
+ if (pptFree)
+ DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree)
+ DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ pTile = pGC->stipple;
+ tlwidth = pTile->devKind/PGSZB;
+ alu = pGC->alu;
+
+ xSrc = pDrawable->x;
+ ySrc = pDrawable->y;
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
+ pBase);
+
+ tileWidth = pTile->drawable.width;
+ tileHeight = pTile->drawable.height;
+ rropsOS = ilbmGetGCPrivate(pGC)->rropOS;
+
+ /* this replaces rotating the tile. Instead we just adjust the offset
+ * at which we start grabbing bits from the tile.
+ * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
+ * so that iline and rem always stay within the tile bounds.
+ */
+ xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;
+ ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;
+
+ while (n--) {
+ iline = (ppt->y - ySrc) % tileHeight;
+ psrcT = (PixelType *) pTile->devPrivate.ptr + (iline * tlwidth);
+ addrlBase = ilbmScanline(pBase, ppt->x, ppt->y, auxDst);
+
+ for (d = 0; d < depthDst; d++, addrlBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ if (!(pGC->planemask & (1 << d)))
+ continue;
+
+ if (*pwidth) {
+ x = ppt->x;
+ pdst = addrlBase;
+ width = *pwidth;
+ while (width > 0) {
+ psrc = psrcT;
+ w = min(tileWidth, width);
+ if ((rem = (x - xSrc) % tileWidth) != 0) {
+ /* if we're in the middle of the tile, get
+ as many bits as will finish the span, or
+ as many as will get to the left edge of the tile,
+ or a longword worth, starting at the appropriate
+ offset in the tile.
+ */
+ w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
+ endinc = rem / BITMAP_SCANLINE_PAD;
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+
+ case RROP_COPY:
+ getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
+ break;
+
+ case RROP_INVERT:
+ getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
+ tmpsrc = ~tmpsrc;
+ break;
+ }
+
+ if (alu != GXcopy) {
+ getbits (pdst, (x & PIM), w, tmpdst);
+ DoRop (tmpsrc, alu, tmpsrc, tmpdst);
+ }
+
+ putbits (tmpsrc, (x & PIM), w, pdst);
+ if ((x & PIM) + w >= PPW)
+ pdst++;
+ } else if (((x & PIM) + w) < PPW) {
+ /* doing < PPW bits is easy, and worth special-casing */
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+ case RROP_COPY:
+ tmpsrc = *psrc;
+ break;
+ case RROP_INVERT:
+ tmpsrc = ~*psrc;
+ break;
+ }
+ if (alu != GXcopy) {
+ getbits (pdst, (x & PIM), w, tmpdst);
+ DoRop (tmpsrc, alu, tmpsrc, tmpdst);
+ }
+ putbits (tmpsrc, (x & PIM), w, pdst);
+ } else {
+ /* start at the left edge of the tile,
+ and put down as much as we can
+ */
+ maskbits(x, w, startmask, endmask, nlMiddle);
+
+ if (startmask)
+ nstart = PPW - (x & PIM);
+ else
+ nstart = 0;
+ if (endmask)
+ nend = (x + w) & PIM;
+ else
+ nend = 0;
+
+ srcStartOver = nstart > PLST;
+
+ if (startmask) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+ case RROP_COPY:
+ tmpsrc = *psrc;
+ break;
+ case RROP_INVERT:
+ tmpsrc = ~*psrc;
+ break;
+ }
+ if (alu != GXcopy) {
+ getbits (pdst, (x & PIM), nstart, tmpdst);
+ DoRop (tmpsrc, alu, tmpsrc, tmpdst);
+ }
+ putbits (tmpsrc, (x & PIM), nstart, pdst);
+ pdst++;
+ if (srcStartOver)
+ psrc++;
+ }
+
+ while (nlMiddle--) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+ case RROP_COPY:
+ getbits (psrc, nstart, PPW, tmpsrc);
+ break;
+ case RROP_INVERT:
+ getbits (psrc, nstart, PPW, tmpsrc);
+ tmpsrc = ~tmpsrc;
+ break;
+ }
+ if (alu != GXcopy) {
+ tmpdst = *pdst;
+ DoRop (tmpsrc, alu, tmpsrc, tmpdst);
+ }
+ *pdst++ = tmpsrc;
+ /*putbits (tmpsrc, 0, PPW, pdst);
+ pdst++;*/
+ psrc++;
+ }
+ if (endmask) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+
+ case RROP_COPY:
+ getbits (psrc, nstart, nend, tmpsrc);
+ break;
+
+ case RROP_INVERT:
+ getbits (psrc, nstart, nend, tmpsrc);
+ tmpsrc = ~tmpsrc;
+ break;
+ }
+ if (alu != GXcopy) {
+ tmpdst = *pdst;
+ DoRop (tmpsrc, alu, tmpsrc, tmpdst);
+ }
+ putbits (tmpsrc, 0, nend, pdst);
+ }
+ }
+ x += w;
+ width -= w;
+ }
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmfont.c b/nx-X11/programs/Xserver/ilbm/ilbmfont.c
new file mode 100644
index 000000000..84ef8e5d1
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmfont.c
@@ -0,0 +1,82 @@
+/* $XFree86$ */
+/*
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*/
+/* $XConsortium: ilbmfont.c,v 1.18 94/04/17 20:28:22 keith Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "ilbm.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "scrnintstr.h"
+
+/*ARGSUSED*/
+Bool
+ilbmRealizeFont( pscr, pFont)
+ ScreenPtr pscr;
+ FontPtr pFont;
+{
+ return (TRUE);
+}
+
+/*ARGSUSED*/
+Bool
+ilbmUnrealizeFont( pscr, pFont)
+ ScreenPtr pscr;
+ FontPtr pFont;
+{
+ return (TRUE);
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmgc.c b/nx-X11/programs/Xserver/ilbm/ilbmgc.c
new file mode 100644
index 000000000..f87f1fc9c
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmgc.c
@@ -0,0 +1,715 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmgc.c,v 3.0 1996/08/18 01:53:52 dawes Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmgc.c,v 5.35 94/04/17 20:28:23 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "ilbm.h"
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "region.h"
+
+#include "mistruct.h"
+#include "migc.h"
+
+#include "maskbits.h"
+
+static GCFuncs ilbmFuncs = {
+ ilbmValidateGC,
+ miChangeGC,
+ miCopyGC,
+ ilbmDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip
+};
+
+static GCOps ilbmGCOps = {
+ ilbmSolidFS,
+ ilbmSetSpans,
+ ilbmPutImage,
+ ilbmCopyArea,
+ miCopyPlane,
+ ilbmPolyPoint,
+ ilbmLineSS,
+ ilbmSegmentSS,
+ miPolyRectangle,
+ ilbmZeroPolyArcSS,
+ ilbmFillPolygonSolid,
+ ilbmPolyFillRect,
+ ilbmPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ ilbmTEGlyphBlt,
+ ilbmPolyGlyphBlt,
+ ilbmPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+
+Bool
+ilbmCreateGC(pGC)
+ register GCPtr pGC;
+{
+ ilbmPrivGC *pPriv;
+
+ pGC->clientClip = NULL;
+ pGC->clientClipType = CT_NONE;
+
+ /* some of the output primitives aren't really necessary, since
+ they will be filled in ValidateGC because of dix/CreateGC()
+ setting all the change bits. Others are necessary because although
+ they depend on being a monochrome frame buffer, they don't change
+ */
+
+ pGC->ops = &ilbmGCOps;
+ pGC->funcs = &ilbmFuncs;
+
+ /* ilbm wants to translate before scan convesion */
+ pGC->miTranslate = 1;
+
+ pPriv = (ilbmPrivGC *)(pGC->devPrivates[ilbmGCPrivateIndex].ptr);
+ ilbmReduceRop(pGC->alu, pGC->fgPixel, pGC->planemask, pGC->depth,
+ pPriv->rrops);
+ ilbmReduceOpaqueStipple(pGC->fgPixel, pGC->bgPixel, pGC->planemask,
+ pGC->depth, pPriv->rropOS);
+
+ pGC->fExpose = TRUE;
+ pGC->pRotatedPixmap = NullPixmap;
+ pGC->freeCompClip = FALSE;
+ return TRUE;
+}
+
+/* Clipping conventions
+ if the drawable is a window
+ CT_REGION ==> pCompositeClip really is the composite
+ CT_other ==> pCompositeClip is the window clip region
+ if the drawable is a pixmap
+ CT_REGION ==> pCompositeClip is the translated client region
+ clipped to the pixmap boundary
+ CT_other ==> pCompositeClip is the pixmap bounding box
+*/
+
+/*ARGSUSED*/
+void
+ilbmValidateGC(pGC, changes, pDrawable)
+ register GCPtr pGC;
+ unsigned long changes;
+ DrawablePtr pDrawable;
+{
+ register ilbmPrivGCPtr devPriv;
+ int mask; /* stateChanges */
+ int index; /* used for stepping through bitfields */
+ int xrot, yrot; /* rotations for tile and stipple pattern */
+ int rrop; /* reduced rasterop */
+ /* flags for changing the proc vector
+ and updating things in devPriv
+ */
+ int new_rotate, new_rrop, new_line, new_text, new_fill;
+ DDXPointRec oldOrg; /* origin of thing GC was last used with */
+
+ oldOrg = pGC->lastWinOrg;
+
+ pGC->lastWinOrg.x = pDrawable->x;
+ pGC->lastWinOrg.y = pDrawable->y;
+
+ /* we need to re-rotate the tile if the previous window/pixmap
+ origin (oldOrg) differs from the new window/pixmap origin
+ (pGC->lastWinOrg)
+ */
+ new_rotate = (oldOrg.x != pGC->lastWinOrg.x) ||
+ (oldOrg.y != pGC->lastWinOrg.y);
+
+
+ devPriv = ((ilbmPrivGCPtr)(pGC->devPrivates[ilbmGCPrivateIndex].ptr));
+
+
+ /*
+ if the client clip is different or moved OR
+ the subwindowMode has changed OR
+ the window's clip has changed since the last validation
+ we need to recompute the composite clip
+ */
+ if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
+ (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS)))
+ ilbmComputeCompositeClip(pGC, pDrawable);
+
+ new_rrop = FALSE;
+ new_line = FALSE;
+ new_text = FALSE;
+ new_fill = FALSE;
+
+ mask = changes;
+ while (mask) {
+ index = lowbit(mask);
+ mask &= ~index;
+
+ /* this switch acculmulates a list of which procedures
+ might have to change due to changes in the GC. in
+ some cases (e.g. changing one 16 bit tile for another)
+ we might not really need a change, but the code is
+ being paranoid.
+ this sort of batching wins if, for example, the alu
+ and the font have been changed, or any other pair
+ of items that both change the same thing.
+ */
+ switch (index) {
+ case GCPlaneMask:
+ case GCFunction:
+ case GCForeground:
+ new_rrop = TRUE;
+ break;
+ case GCBackground:
+ new_rrop = TRUE; /* for opaque stipples */
+ break;
+ case GCLineStyle:
+ case GCLineWidth:
+ case GCJoinStyle:
+ new_line = TRUE;
+ break;
+ case GCCapStyle:
+ break;
+ case GCFillStyle:
+ new_fill = TRUE;
+ break;
+ case GCFillRule:
+ break;
+ case GCTile:
+ if (pGC->tileIsPixel)
+ break;
+ new_rotate = TRUE;
+ new_fill = TRUE;
+ break;
+
+ case GCStipple:
+ if (pGC->stipple == (PixmapPtr)NULL)
+ break;
+ new_rotate = TRUE;
+ new_fill = TRUE;
+ break;
+
+ case GCTileStipXOrigin:
+ new_rotate = TRUE;
+ break;
+
+ case GCTileStipYOrigin:
+ new_rotate = TRUE;
+ break;
+
+ case GCFont:
+ new_text = TRUE;
+ break;
+ case GCSubwindowMode:
+ break;
+ case GCGraphicsExposures:
+ break;
+ case GCClipXOrigin:
+ break;
+ case GCClipYOrigin:
+ break;
+ case GCClipMask:
+ break;
+ case GCDashOffset:
+ break;
+ case GCDashList:
+ break;
+ case GCArcMode:
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* deal with the changes we've collected .
+ new_rrop must be done first because subsequent things
+ depend on it.
+ */
+
+ if (new_rotate || new_fill) {
+ Bool new_pix = FALSE;
+
+ /* figure out how much to rotate */
+ xrot = pGC->patOrg.x;
+ yrot = pGC->patOrg.y;
+ xrot += pDrawable->x;
+ yrot += pDrawable->y;
+
+ switch (pGC->fillStyle) {
+ case FillTiled:
+ /* copy current tile and stipple */
+ if (!pGC->tileIsPixel &&
+ (pGC->tile.pixmap->drawable.width <= PPW) &&
+ !(pGC->tile.pixmap->drawable.width &
+ (pGC->tile.pixmap->drawable.width - 1))) {
+ ilbmCopyRotatePixmap(pGC->tile.pixmap, &pGC->pRotatedPixmap,
+ xrot, yrot);
+ new_pix = TRUE;
+ }
+ break;
+ case FillStippled:
+ case FillOpaqueStippled:
+ if (pGC->stipple && (pGC->stipple->drawable.width <= PPW) &&
+ !(pGC->stipple->drawable.width &
+ (pGC->stipple->drawable.width - 1))) {
+ ilbmCopyRotatePixmap(pGC->stipple, &pGC->pRotatedPixmap,
+ xrot, yrot);
+ new_pix = TRUE;
+ }
+ }
+ /* destroy any previously rotated tile or stipple */
+ if (!new_pix && pGC->pRotatedPixmap) {
+ (*pDrawable->pScreen->DestroyPixmap)(pGC->pRotatedPixmap);
+ pGC->pRotatedPixmap = (PixmapPtr)NULL;
+ }
+ }
+
+ /*
+ * duck out here when the GC is unchanged
+ */
+
+ if (!changes)
+ return;
+
+ if (new_rrop || new_fill) {
+ ilbmReduceRop(pGC->alu, pGC->fgPixel, pGC->planemask, pDrawable->depth,
+ devPriv->rrops);
+ ilbmReduceOpaqueStipple(pGC->fgPixel, pGC->bgPixel, pGC->planemask,
+ pGC->depth, devPriv->rropOS);
+ new_fill = TRUE;
+ }
+
+ if (new_line || new_fill || new_text) {
+ if (!pGC->ops->devPrivate.val) {
+ pGC->ops = miCreateGCOps(pGC->ops);
+ pGC->ops->devPrivate.val = 1;
+ }
+ }
+
+ if (new_line || new_fill) {
+ if (pGC->lineWidth == 0) {
+ if (pGC->lineStyle == LineSolid && pGC->fillStyle == FillSolid)
+ pGC->ops->PolyArc = ilbmZeroPolyArcSS;
+ else
+ pGC->ops->PolyArc = miZeroPolyArc;
+ } else
+ pGC->ops->PolyArc = miPolyArc;
+ if (pGC->lineStyle == LineSolid) {
+ if (pGC->lineWidth == 0) {
+ if (pGC->fillStyle == FillSolid) {
+ pGC->ops->PolySegment = ilbmSegmentSS;
+ pGC->ops->Polylines = ilbmLineSS;
+ } else {
+ pGC->ops->PolySegment = miPolySegment;
+ pGC->ops->Polylines = miZeroLine;
+ }
+ } else {
+ pGC->ops->PolySegment = miPolySegment;
+ pGC->ops->Polylines = miWideLine;
+ }
+ } else {
+ if (pGC->lineWidth == 0 && pGC->fillStyle == FillSolid) {
+ pGC->ops->PolySegment = ilbmSegmentSD;
+ pGC->ops->Polylines = ilbmLineSD;
+ } else {
+ pGC->ops->PolySegment = miPolySegment;
+ pGC->ops->Polylines = miWideDash;
+ }
+ }
+ }
+
+ if (new_text || new_fill) {
+ if ((pGC->font) &&
+ (FONTMAXBOUNDS(pGC->font,rightSideBearing) -
+ FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 ||
+ FONTMINBOUNDS(pGC->font,characterWidth) < 0)) {
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
+ } else {
+ /* special case ImageGlyphBlt for terminal emulator fonts */
+ if ((pGC->font) &&
+ TERMINALFONT(pGC->font)) {
+ pGC->ops->ImageGlyphBlt = ilbmTEGlyphBlt;
+ } else {
+ pGC->ops->ImageGlyphBlt = ilbmImageGlyphBlt;
+ }
+
+ /* now do PolyGlyphBlt */
+ if (pGC->fillStyle == FillSolid) {
+ pGC->ops->PolyGlyphBlt = ilbmPolyGlyphBlt;
+ } else {
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ }
+ }
+ }
+
+ if (new_fill) {
+ /* install a suitable fillspans and pushpixels */
+ pGC->ops->PushPixels = ilbmPushPixels;
+ pGC->ops->FillPolygon = miFillPolygon;
+ pGC->ops->PolyFillArc = miPolyFillArc;
+
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ pGC->ops->FillSpans = ilbmSolidFS;
+ pGC->ops->FillPolygon = ilbmFillPolygonSolid;
+ pGC->ops->PolyFillArc = ilbmPolyFillArcSolid;
+ break;
+ case FillTiled:
+ if (pGC->pRotatedPixmap)
+ pGC->ops->FillSpans = ilbmTileFS;
+ else
+ pGC->ops->FillSpans = ilbmUnnaturalTileFS;
+ break;
+ case FillOpaqueStippled:
+ if (pGC->pRotatedPixmap)
+ pGC->ops->FillSpans = ilbmOpaqueStippleFS;
+ else
+ pGC->ops->FillSpans = ilbmUnnaturalOpaqueStippleFS;
+ break;
+
+ case FillStippled:
+ if (pGC->pRotatedPixmap)
+ pGC->ops->FillSpans = ilbmStippleFS;
+ else
+ pGC->ops->FillSpans = ilbmUnnaturalStippleFS;
+ break;
+ }
+ } /* end of new_fill */
+}
+
+void
+ilbmDestroyGC(pGC)
+ GCPtr pGC;
+{
+ if (pGC->pRotatedPixmap)
+ (*pGC->pScreen->DestroyPixmap)(pGC->pRotatedPixmap);
+ if (pGC->freeCompClip)
+ REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
+ miDestroyGCOps(pGC->ops);
+}
+
+/* table to map alu(src, dst) to alu(~src, dst) */
+int ilbmInverseAlu[16] = {
+ GXclear,
+ GXandInverted,
+ GXnor,
+ GXcopyInverted,
+ GXand,
+ GXnoop,
+ GXequiv,
+ GXorInverted,
+ GXandReverse,
+ GXxor,
+ GXinvert,
+ GXnand,
+ GXcopy,
+ GXor,
+ GXorReverse,
+ GXset
+};
+
+void
+ilbmReduceOpaqueStipple(fg, bg, planemask, depth, rop)
+register PixelType fg;
+register PixelType bg;
+register unsigned long planemask;
+int depth;
+register unsigned char *rop;
+{
+ register int d;
+ register Pixel mask = 1;
+
+ bg ^= fg;
+
+ for (d = 0; d < depth; d++, mask <<= 1) {
+ if (!(planemask & mask))
+ rop[d] = RROP_NOP;
+ else if (!(bg & mask)) {
+ /* Both fg and bg have a 0 or 1 in this plane */
+ if (fg & mask)
+ rop[d] = RROP_WHITE;
+ else
+ rop[d] = RROP_BLACK;
+ } else {
+ /* Both fg and bg have different bits on this plane */
+ if (fg & mask)
+ rop[d] = RROP_COPY;
+ else
+ rop[d] = RROP_INVERT;
+ }
+ }
+}
+
+void
+ilbmReduceRop(alu, src, planemask, depth, rop)
+ register int alu;
+ register Pixel src;
+ register unsigned long planemask;
+ int depth;
+ register unsigned char *rop;
+{
+ register int d;
+ register Pixel mask = 1;
+
+ for (d = 0; d < depth; d++, mask <<= 1) {
+ if (!(planemask & mask))
+ rop[d] = RROP_NOP;
+ else if ((src & mask) == 0) /* src is black */
+ switch (alu) {
+ case GXclear:
+ rop[d] = RROP_BLACK;
+ break;
+ case GXand:
+ rop[d] = RROP_BLACK;
+ break;
+ case GXandReverse:
+ rop[d] = RROP_BLACK;
+ break;
+ case GXcopy:
+ rop[d] = RROP_BLACK;
+ break;
+ case GXandInverted:
+ rop[d] = RROP_NOP;
+ break;
+ case GXnoop:
+ rop[d] = RROP_NOP;
+ break;
+ case GXxor:
+ rop[d] = RROP_NOP;
+ break;
+ case GXor:
+ rop[d] = RROP_NOP;
+ break;
+ case GXnor:
+ rop[d] = RROP_INVERT;
+ break;
+ case GXequiv:
+ rop[d] = RROP_INVERT;
+ break;
+ case GXinvert:
+ rop[d] = RROP_INVERT;
+ break;
+ case GXorReverse:
+ rop[d] = RROP_INVERT;
+ break;
+ case GXcopyInverted:
+ rop[d] = RROP_WHITE;
+ break;
+ case GXorInverted:
+ rop[d] = RROP_WHITE;
+ break;
+ case GXnand:
+ rop[d] = RROP_WHITE;
+ break;
+ case GXset:
+ rop[d] = RROP_WHITE;
+ break;
+ }
+ else /* src is white */
+ switch (alu) {
+ case GXclear:
+ rop[d] = RROP_BLACK;
+ break;
+ case GXand:
+ rop[d] = RROP_NOP;
+ break;
+ case GXandReverse:
+ rop[d] = RROP_INVERT;
+ break;
+ case GXcopy:
+ rop[d] = RROP_WHITE;
+ break;
+ case GXandInverted:
+ rop[d] = RROP_BLACK;
+ break;
+ case GXnoop:
+ rop[d] = RROP_NOP;
+ break;
+ case GXxor:
+ rop[d] = RROP_INVERT;
+ break;
+ case GXor:
+ rop[d] = RROP_WHITE;
+ break;
+ case GXnor:
+ rop[d] = RROP_BLACK;
+ break;
+ case GXequiv:
+ rop[d] = RROP_NOP;
+ break;
+ case GXinvert:
+ rop[d] = RROP_INVERT;
+ break;
+ case GXorReverse:
+ rop[d] = RROP_WHITE;
+ break;
+ case GXcopyInverted:
+ rop[d] = RROP_BLACK;
+ break;
+ case GXorInverted:
+ rop[d] = RROP_NOP;
+ break;
+ case GXnand:
+ rop[d] = RROP_INVERT;
+ break;
+ case GXset:
+ rop[d] = RROP_WHITE;
+ break;
+ }
+ }
+}
+
+void
+ilbmComputeCompositeClip(pGC, pDrawable)
+ GCPtr pGC;
+ DrawablePtr pDrawable;
+{
+ ScreenPtr pScreen = pGC->pScreen;
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ RegionPtr pregWin;
+ Bool freeTmpClip, freeCompClip;
+
+ if (pGC->subWindowMode == IncludeInferiors) {
+ pregWin = NotClippedByChildren(pWin);
+ freeTmpClip = TRUE;
+ } else {
+ pregWin = &pWin->clipList;
+ freeTmpClip = FALSE;
+ }
+ freeCompClip = pGC->freeCompClip;
+
+ /*
+ * if there is no client clip, we can get by with just keeping the
+ * pointer we got, and remembering whether or not should destroy (or
+ * maybe re-use) it later. this way, we avoid unnecessary copying of
+ * regions. (this wins especially if many clients clip by children
+ * and have no client clip.)
+ */
+ if (pGC->clientClipType == CT_NONE) {
+ if (freeCompClip)
+ REGION_DESTROY(pScreen, pGC->pCompositeClip);
+ pGC->pCompositeClip = pregWin;
+ pGC->freeCompClip = freeTmpClip;
+ } else {
+ /*
+ * we need one 'real' region to put into the composite clip. if
+ * pregWin the current composite clip are real, we can get rid of
+ * one. if pregWin is real and the current composite clip isn't,
+ * use pregWin for the composite clip. if the current composite
+ * clip is real and pregWin isn't, use the current composite
+ * clip. if neither is real, create a new region.
+ */
+
+ REGION_TRANSLATE(pScreen, pGC->clientClip,
+ pDrawable->x + pGC->clipOrg.x,
+ pDrawable->y + pGC->clipOrg.y);
+
+ if (freeCompClip) {
+ REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip, pregWin,
+ pGC->clientClip);
+ if (freeTmpClip)
+ REGION_DESTROY(pScreen, pregWin);
+ } else if (freeTmpClip) {
+ REGION_INTERSECT(pScreen, pregWin, pregWin, pGC->clientClip);
+ pGC->pCompositeClip = pregWin;
+ } else {
+ pGC->pCompositeClip = REGION_CREATE(pScreen, NullBox, 0);
+ REGION_INTERSECT(pScreen, pGC->pCompositeClip,
+ pregWin, pGC->clientClip);
+ }
+ pGC->freeCompClip = TRUE;
+ REGION_TRANSLATE(pScreen, pGC->clientClip,
+ -(pDrawable->x + pGC->clipOrg.x),
+ -(pDrawable->y + pGC->clipOrg.y));
+ }
+ } /* end of composite clip for a window */
+ else {
+ BoxRec pixbounds;
+
+ /* XXX should we translate by drawable.x/y here ? */
+ pixbounds.x1 = 0;
+ pixbounds.y1 = 0;
+ pixbounds.x2 = pDrawable->width;
+ pixbounds.y2 = pDrawable->height;
+
+ if (pGC->freeCompClip) {
+ REGION_RESET(pScreen, pGC->pCompositeClip, &pixbounds);
+ } else {
+ pGC->freeCompClip = TRUE;
+ pGC->pCompositeClip = REGION_CREATE(pScreen, &pixbounds, 1);
+ }
+
+ if (pGC->clientClipType == CT_REGION) {
+ REGION_TRANSLATE(pScreen, pGC->pCompositeClip, -pGC->clipOrg.x,
+ -pGC->clipOrg.y);
+ REGION_INTERSECT(pScreen, pGC->pCompositeClip,
+ pGC->pCompositeClip, pGC->clientClip);
+ REGION_TRANSLATE(pScreen, pGC->pCompositeClip, pGC->clipOrg.x,
+ pGC->clipOrg.y);
+ }
+ } /* end of composite clip for pixmap */
+} /* end ilbmComputeCompositeClip */
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmgetsp.c b/nx-X11/programs/Xserver/ilbm/ilbmgetsp.c
new file mode 100644
index 000000000..37b8d8537
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmgetsp.c
@@ -0,0 +1,170 @@
+/* $XFree86$ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmgetsp.c,v 5.10 94/04/17 20:28:24 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "misc.h"
+#include "region.h"
+#include "gc.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "ilbm.h"
+#include "maskbits.h"
+
+#include "servermd.h"
+
+/* GetSpans -- for each span, gets bits from drawable starting at ppt[i]
+ * and continuing for pwidth[i] bits
+ * Each scanline returned will be server scanline padded, i.e., it will come
+ * out to an integral number of words.
+ */
+/*ARGSUSED*/
+void
+ilbmGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pchardstStart)
+ DrawablePtr pDrawable; /* drawable from which to get bits */
+ int wMax; /* largest value of all *pwidths */
+ register DDXPointPtr ppt; /* points to start copying from */
+ int *pwidth; /* list of number of bits to copy */
+ int nspans; /* number of scanlines to copy */
+ char *pchardstStart; /* where to put the bits */
+{
+ PixelType *pdstStart = (PixelType *)pchardstStart;
+ register PixelType *pdst; /* where to put the bits */
+ register PixelType *psrc; /* where to get the bits */
+ register PixelType tmpSrc; /* scratch buffer for bits */
+ PixelType *psrcBase; /* start of src bitmap */
+ int widthSrc; /* width of pixmap in bytes */
+ int auxSrc;
+ int depthSrc;
+ register DDXPointPtr pptLast; /* one past last point to get */
+ int xEnd; /* last pixel to copy from */
+ register int nstart;
+ register int d;
+ int nend;
+ int srcStartOver;
+ PixelType startmask, endmask;
+ unsigned int srcBit;
+ int nlMiddle, nl;
+ int w;
+
+ pptLast = ppt + nspans;
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, widthSrc, auxSrc, depthSrc,
+ psrcBase);
+ pdst = pdstStart;
+
+ while (ppt < pptLast) {
+ /* XXX should this really be << PWSH, or * 8, or * PGSZB? */
+ xEnd = min(ppt->x + *pwidth, widthSrc << PWSH);
+ pwidth++;
+ for (d = 0; d < depthSrc; d++) {
+ psrc = ilbmScanline(psrcBase, ppt->x, ppt->y, auxSrc);
+ psrcBase += widthSrc; /* @@@ NEXT PLANE @@@ */
+ w = xEnd - ppt->x;
+ srcBit = ppt->x & PIM;
+
+ if (srcBit + w <= PPW)
+ {
+ getandputbits0(psrc, srcBit, w, pdst);
+ pdst++;
+ }
+ else
+ {
+
+ maskbits(ppt->x, w, startmask, endmask, nlMiddle);
+ if (startmask)
+ nstart = PPW - srcBit;
+ else
+ nstart = 0;
+ if (endmask)
+ nend = xEnd & PIM;
+ srcStartOver = srcBit + nstart > PLST;
+ if (startmask)
+ {
+ getandputbits0(psrc, srcBit, nstart, pdst);
+ if (srcStartOver)
+ psrc++;
+ }
+ nl = nlMiddle;
+#ifdef FASTPUTBITS
+ Duff(nl, putbits(*psrc, nstart, PPW, pdst); psrc++; pdst++;);
+#else
+ while (nl--)
+ {
+ tmpSrc = *psrc;
+ putbits(tmpSrc, nstart, PPW, pdst);
+ psrc++;
+ pdst++;
+ }
+#endif
+ if (endmask)
+ {
+ putbits(*psrc, nstart, nend, pdst);
+ if (nstart + nend > PPW)
+ pdst++;
+ }
+ if (startmask || endmask)
+ pdst++;
+ }
+ }
+ ppt++;
+ }
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmhrzvert.c b/nx-X11/programs/Xserver/ilbm/ilbmhrzvert.c
new file mode 100644
index 000000000..9612749cf
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmhrzvert.c
@@ -0,0 +1,213 @@
+/* $XFree86$ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmhrzvert.c,v 1.15 94/04/17 20:28:24 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "gc.h"
+#include "window.h"
+#include "pixmap.h"
+#include "region.h"
+
+#include "ilbm.h"
+#include "maskbits.h"
+
+/* horizontal solid line
+ abs(len) > 1
+*/
+ilbmHorzS(pbase, nlwidth, auxDst, depthDst, x1, y1, len, rrops)
+PixelType *pbase; /* pointer to base of bitmap */
+register int nlwidth; /* width in longwords of bitmap */
+int auxDst;
+int depthDst;
+int x1; /* initial point */
+int y1;
+int len; /* length of line */
+register unsigned char *rrops;
+{
+ register PixelType *addrl;
+ register PixelType startmask;
+ register PixelType endmask;
+ register int nlmiddle;
+ register int d;
+ int saveNLmiddle;
+
+ /* force the line to go left to right
+ but don't draw the last point
+ */
+ if (len < 0) {
+ x1 += len;
+ x1 += 1;
+ len = -len;
+ }
+
+ /* all bits inside same longword */
+ if ( ((x1 & PIM) + len) < PPW) {
+ maskpartialbits(x1, len, startmask);
+
+ for (d = 0; d < depthDst; d++) {
+ addrl = ilbmScanline(pbase, x1, y1, auxDst);
+ pbase += nlwidth; /* @@@ NEXT PLANE @@@ */
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ *addrl &= ~startmask;
+ break;
+ case RROP_WHITE:
+ *addrl |= startmask;
+ break;
+ case RROP_INVERT:
+ *addrl ^= startmask;
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ...) */
+ } else {
+ maskbits(x1, len, startmask, endmask, nlmiddle);
+ saveNLmiddle = nlmiddle;
+
+ for (d = 0; d < depthDst; d++) {
+ addrl = ilbmScanline(pbase, x1, y1, auxDst);
+ pbase += nlwidth; /* @@@ NEXT PLANE @@@ */
+ nlmiddle = saveNLmiddle;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ if (startmask)
+ *addrl++ &= ~startmask;
+ Duff (nlmiddle, *addrl++ = 0x0);
+ if (endmask)
+ *addrl &= ~endmask;
+ break;
+
+ case RROP_WHITE:
+ if (startmask)
+ *addrl++ |= startmask;
+ Duff (nlmiddle, *addrl++ = ~0);
+ if (endmask)
+ *addrl |= endmask;
+ break;
+
+ case RROP_INVERT:
+ if (startmask)
+ *addrl++ ^= startmask;
+ Duff (nlmiddle, *addrl++ ^= ~0);
+ if (endmask)
+ *addrl ^= endmask;
+ break;
+
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ... ) */
+ }
+}
+
+/* vertical solid line
+ this uses do loops because pcc (Ultrix 1.2, bsd 4.2) generates
+ better code. sigh. we know that len will never be 0 or 1, so
+ it's OK to use it.
+*/
+
+ilbmVertS(pbase, nlwidth, auxDst, depthDst, x1, y1, len, rrops)
+PixelType *pbase; /* pointer to base of bitmap */
+register int nlwidth; /* width in longwords of bitmap */
+int auxDst;
+int depthDst;
+int x1, y1; /* initial point */
+register int len; /* length of line */
+unsigned char *rrops;
+{
+ register PixelType *addrl;
+ register PixelType bitmask;
+ int saveLen;
+ int d;
+
+ if (len < 0) {
+ auxDst = -auxDst;
+ len = -len;
+ }
+
+ saveLen = len;
+
+ for (d = 0; d < depthDst; d++) {
+ addrl = ilbmScanline(pbase, x1, y1, auxDst);
+ pbase += nlwidth; /* @@@ NEXT PLANE @@@ */
+ len = saveLen;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ bitmask = rmask[x1 & PIM];
+ Duff(len, *addrl &= bitmask; ilbmScanlineInc(addrl, auxDst) );
+ break;
+
+ case RROP_WHITE:
+ bitmask = mask[x1 & PIM];
+ Duff(len, *addrl |= bitmask; ilbmScanlineInc(addrl, auxDst) );
+ break;
+
+ case RROP_INVERT:
+ bitmask = mask[x1 & PIM];
+ Duff(len, *addrl ^= bitmask; ilbmScanlineInc(addrl, auxDst) );
+ break;
+
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ...) */
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmimage.c b/nx-X11/programs/Xserver/ilbm/ilbmimage.c
new file mode 100644
index 000000000..ddb19ac6a
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmimage.c
@@ -0,0 +1,441 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmimage.c,v 3.0 1996/08/18 01:53:56 dawes Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#include <X11/X.h>
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "ilbm.h"
+#include "maskbits.h"
+#include "servermd.h"
+
+void
+ilbmPutImage(pDraw, pGC, depth, x, y, width, height, leftPad, format, pImage)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int depth, x, y, width, height;
+ int leftPad;
+ int format;
+ char *pImage;
+{
+ PixmapPtr pPixmap;
+
+#if 1
+ fprintf(stderr, "ilbmPutImage()\n");
+ fprintf(stderr, "\tdepth = %d, x = %d, y = %d, width = %d, height = %d, "
+ "leftPad = %d\n", depth, x, y, width, height, leftPad);
+ switch (format) {
+ case XYBitmap:
+ fprintf(stderr, "\tformat = XYBitmap\n");
+ break;
+ case XYPixmap:
+ fprintf(stderr, "\tformat = XYPixmap\n");
+ break;
+ case ZPixmap:
+ fprintf(stderr, "\tformat = ZPixmap\n");
+ break;
+ default:
+ fprintf(stderr, "\tformat = %d\n");
+ break;
+ }
+#endif
+
+ if ((width == 0) || (height == 0))
+ return;
+
+ if (format != ZPixmap || depth == 1 || pDraw->depth == 1) {
+ if (format == XYBitmap) {
+ char *ptmp;
+ int realwidth;
+ int size;
+ int aux;
+ int d, yy, xx;
+ char *ss, *dd;
+
+ realwidth = BitmapBytePad(width+leftPad);
+ aux = depth*realwidth;
+ size = height*aux;
+
+#if 1
+ fprintf(stderr, "\trealwidth = %d, aux = %d, size = %d\n", realwidth,
+ aux, size);
+#endif
+
+ if (!(ptmp = (char *)ALLOCATE_LOCAL(size)))
+ return;
+
+ /*
+ * Convert from bitplanes to interleaved bitplanes
+ */
+
+ ss = (char *)pImage;
+ for (d = 0; d < depth; d++) {
+ dd = ptmp+d*realwidth;
+ for (yy = 0; yy < height; yy++) {
+ for (xx = 0; xx < realwidth; xx++)
+#if 1
+ {
+ fprintf(stderr, "*(%d) = *(%d)\n", (&dd[xx])-ptmp,
+ ss-(char *)pImage);
+#endif
+ dd[xx] = *(ss++);
+#if 1
+ }
+#endif
+ dd += aux;
+ }
+ }
+
+ pPixmap = GetScratchPixmapHeader(pDraw->pScreen, width+leftPad, height,
+ depth, depth,
+ BitmapBytePad(width+leftPad),
+ (pointer)ptmp);
+ if (!pPixmap) {
+ DEALLOCATE_LOCAL(ptmp);
+ return;
+ }
+ pGC->fExpose = FALSE;
+ (void)(*pGC->ops->CopyPlane)((DrawablePtr)pPixmap, pDraw, pGC, leftPad,
+ 0, width, height, x, y, 1);
+ DEALLOCATE_LOCAL(ptmp);
+ } else {
+#if 0
+ /* XXX: bit plane order wronge ! */
+ pPixmap->drawable.depth = 1;
+ pPixmap->drawable.bitsPerPixel = 1;
+
+ switch (pGC->alu) {
+ case GXcopy:
+ doBitBlt = ilbmDoBitbltCopy;
+ break;
+ case GXxor:
+ doBitBlt = ilbmDoBitbltXor;
+ break;
+ case GXcopyInverted:
+ doBitBlt = ilbmDoBitbltCopyInverted;
+ break;
+ case GXor:
+ doBitBlt = ilbmDoBitbltOr;
+ break;
+ default:
+ doBitBlt = ilbmDoBitbltGeneral;
+ break;
+ }
+
+ for (plane = (1L << (pPixmap->drawable.depth - 1)); plane;
+ plane >>= 1) {
+ (void)ilbmBitBlt((DrawablePtr)pPixmap, pDraw, pGC, leftPad, 0,
+ width, height, x, y, doBitBlt, plane);
+ /* pDraw->devKind += sizeDst; */
+ }
+#else
+ char *ptmp;
+ int realwidth;
+ int size;
+ int aux;
+ int d, yy, xx;
+ char *ss, *dd;
+
+ realwidth = BitmapBytePad(width+leftPad);
+ aux = depth*realwidth;
+ size = height*aux;
+
+#if 1
+ fprintf(stderr, "\trealwidth = %d, aux = %d, size = %d\n", realwidth,
+ aux, size);
+#endif
+
+ if (!(ptmp = (char *)ALLOCATE_LOCAL(size)))
+ return;
+
+ /*
+ * Convert from bitplanes to interleaved bitplanes
+ */
+
+ ss = (char *)pImage;
+ for (d = 0; d < depth; d++) {
+ dd = ptmp+d*realwidth;
+ for (yy = 0; yy < height; yy++) {
+ for (xx = 0; xx < realwidth; xx++)
+#if 1
+ {
+ fprintf(stderr, "*(%d) = *(%d)\n", (&dd[xx])-ptmp,
+ ss-(char *)pImage);
+#endif
+ dd[xx] = *(ss++);
+#if 1
+ }
+#endif
+ dd += aux;
+ }
+ }
+
+ pPixmap = GetScratchPixmapHeader(pDraw->pScreen, width+leftPad, height,
+ depth, depth,
+ BitmapBytePad(width+leftPad),
+ (pointer)ptmp);
+ if (!pPixmap) {
+ DEALLOCATE_LOCAL(ptmp);
+ return;
+ }
+
+ pGC->fExpose = FALSE;
+ (void)(*pGC->ops->CopyArea)((DrawablePtr)pPixmap, pDraw, pGC, leftPad,
+ 0, width, height, x, y);
+ DEALLOCATE_LOCAL(ptmp);
+#endif
+ }
+
+ pGC->fExpose = TRUE;
+ FreeScratchPixmapHeader(pPixmap);
+ } else {
+ /* Chunky to planar conversion required */
+
+ PixmapPtr pPixmap;
+ ScreenPtr pScreen = pDraw->pScreen;
+ int widthSrc;
+ int start_srcshift;
+ register int b;
+ register int dstshift;
+ register int shift_step;
+ register PixelType dst;
+ register PixelType srcbits;
+ register PixelType *pdst;
+ register PixelType *psrc;
+ int start_bit;
+ register int nl;
+ register int h;
+ register int d;
+ int auxDst;
+ PixelType *pdstBase;
+ int widthDst;
+ int depthDst;
+
+ /* Create a tmp pixmap */
+ pPixmap = (pScreen->CreatePixmap)(pScreen, width, height, depth);
+ if (!pPixmap)
+ return;
+
+ ilbmGetPixelWidthAuxDepthAndPointer((DrawablePtr)pPixmap, widthDst,
+ auxDst, depthDst, pdstBase);
+
+ widthSrc = PixmapWidthInPadUnits(width, depth);
+ /* XXX: if depth == 8, use fast chunky to planar assembly function.*/
+ if (depth > 4) {
+ start_srcshift = 24;
+ shift_step = 8;
+ } else {
+ start_srcshift = 28;
+ shift_step = 4;
+ }
+
+ for (d = 0; d < depth; d++, pdstBase += widthDst) { /* @@@ NEXT PLANE @@@ */
+ register PixelType *pdstLine = pdstBase;
+ start_bit = start_srcshift + d;
+ psrc = (PixelType *)pImage;
+ h = height;
+
+ while (h--) {
+ pdst = pdstLine;
+ pdstLine += auxDst;
+ dstshift = PPW - 1;
+ dst = 0;
+ nl = widthSrc;
+ while (nl--) {
+ srcbits = *psrc++;
+ for (b = start_bit; b >= 0; b -= shift_step) {
+ dst |= ((srcbits >> b) & 1) << dstshift;
+ if (--dstshift < 0) {
+ dstshift = PPW - 1;
+ *pdst++ = dst;
+ dst = 0;
+ }
+ }
+ }
+ if (dstshift != PPW - 1)
+ *pdst++ = dst;
+ }
+ } /* for (d = ...) */
+
+ pGC->fExpose = FALSE;
+ (void)(*pGC->ops->CopyArea)((DrawablePtr)pPixmap, pDraw, pGC, leftPad, 0,
+ width, height, x, y);
+ pGC->fExpose = TRUE;
+ (*pScreen->DestroyPixmap)(pPixmap);
+ }
+}
+
+void
+ilbmGetImage(pDrawable, sx, sy, width, height, format, planemask, pdstLine)
+ DrawablePtr pDrawable;
+ int sx, sy, width, height;
+ unsigned int format;
+ unsigned long planemask;
+ char *pdstLine;
+{
+ BoxRec box;
+ DDXPointRec ptSrc;
+ RegionRec rgnDst;
+ ScreenPtr pScreen;
+ PixmapPtr pPixmap;
+
+#if 1
+ fprintf(stderr, "ilbmGetImage()\n");
+ fprintf(stderr, "\tsx = %d, sy = %d, width = %d, height = %d, "
+ "planemask = 0x%08x\n", sx, sy, width, height, planemask);
+ switch (format) {
+ case XYBitmap:
+ fprintf(stderr, "\tformat = XYBitmap\n");
+ break;
+ case XYPixmap:
+ fprintf(stderr, "\tformat = XYPixmap\n");
+ break;
+ case ZPixmap:
+ fprintf(stderr, "\tformat = ZPixmap\n");
+ break;
+ default:
+ fprintf(stderr, "\tformat = %d\n");
+ break;
+ }
+#endif
+
+ if ((width == 0) || (height == 0))
+ return;
+
+ pScreen = pDrawable->pScreen;
+ sx += pDrawable->x;
+ sy += pDrawable->y;
+
+ if (format == XYPixmap || pDrawable->depth == 1) {
+ pPixmap = GetScratchPixmapHeader(pScreen, width, height, 1, 1,
+ BitmapBytePad(width), (pointer)pdstLine);
+ if (!pPixmap)
+ return;
+
+ ptSrc.x = sx;
+ ptSrc.y = sy;
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = width;
+ box.y2 = height;
+ REGION_INIT(pScreen, &rgnDst, &box, 1);
+
+ pPixmap->drawable.depth = 1;
+ pPixmap->drawable.bitsPerPixel = 1;
+ /* dix layer only ever calls GetImage with 1 bit set in planemask
+ * when format is XYPixmap.
+ */
+ ilbmDoBitblt(pDrawable, (DrawablePtr)pPixmap, GXcopy, &rgnDst, &ptSrc,
+ planemask);
+
+ FreeScratchPixmapHeader(pPixmap);
+ REGION_UNINIT(pScreen, &rgnDst);
+ } else {
+ /* Planar to chunky conversion required */
+
+ PixelType *psrcBits;
+ PixelType *psrcLine;
+ PixelType startmask, endmask;
+ int depthSrc;
+ int widthSrc;
+ int auxSrc;
+ int sizeDst;
+ int widthDst;
+ register PixelType *psrc;
+ register PixelType *pdst;
+ register PixelType dst;
+ register PixelType srcbits;
+ register int d;
+ register int b;
+ register int dstshift;
+ register int shift_step;
+ register int start_endbit;
+ int start_startbit;
+ register int end_endbit;
+ register int start_dstshift;
+ register int nl;
+ register int h;
+ int nlmiddle;
+
+ widthDst = PixmapWidthInPadUnits(width, pDrawable->depth);
+ sizeDst = widthDst * height;
+
+ /* Clear the dest image */
+ bzero(pdstLine, sizeDst << 2);
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, widthSrc, auxSrc,
+ depthSrc, psrcBits);
+
+ psrcBits = ilbmScanline(psrcBits, sx, sy, auxSrc);
+
+ start_startbit = PPW - 1 - (sx & PIM);
+ if ((sx & PIM) + width < PPW) {
+ maskpartialbits(sx, width, startmask);
+ nlmiddle = 0;
+ endmask = 0;
+ start_endbit = PPW - ((sx + width) & PIM);
+ } else {
+ maskbits(sx, width, startmask, endmask, nlmiddle);
+ start_endbit = 0;
+ end_endbit = PPW - ((sx + width) & PIM);
+ }
+ /* ZPixmap images have either 4 or 8 bits per pixel dependent on
+ * depth.
+ */
+ if (depthSrc > 4) {
+ start_dstshift = 24;
+ shift_step = 8;
+ } else {
+ start_dstshift = 28;
+ shift_step = 4;
+ }
+#define SHIFT_BITS(start_bit,end_bit) \
+for (b = (start_bit); b >= (end_bit); b--) { \
+ dst |= ((srcbits >> b) & 1) << dstshift; \
+ if ((dstshift -= shift_step) < 0) { \
+ dstshift = start_dstshift + d; \
+ *pdst++ = dst; \
+ dst = *pdst; \
+ } \
+} \
+
+ for (d = 0; d < depthSrc; d++, psrcBits += widthSrc) { /* @@@ NEXT PLANE @@@ */
+ psrcLine = psrcBits;
+ pdst = (PixelType *)pdstLine;
+ h = height;
+
+ while (h--) {
+ psrc = psrcLine;
+ psrcLine += auxSrc;
+ dst = *pdst;
+ dstshift = start_dstshift + d;
+
+ if (startmask) {
+ srcbits = *psrc++ & startmask;
+ SHIFT_BITS(start_startbit, start_endbit);
+ }
+
+ nl = nlmiddle;
+ while (nl--) {
+ srcbits = *psrc++;
+ SHIFT_BITS(PPW - 1, 0);
+ }
+ if (endmask) {
+ srcbits = *psrc & endmask;
+ SHIFT_BITS(PPW - 1, end_endbit);
+ }
+
+ if (dstshift != start_dstshift + d)
+ *pdst++ = dst;
+ } /* while (h--) */
+ } /* for (d = ...) */
+ }
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmimggblt.c b/nx-X11/programs/Xserver/ilbm/ilbmimggblt.c
new file mode 100644
index 000000000..7fc1f3144
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmimggblt.c
@@ -0,0 +1,474 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmimggblt.c,v 3.0 1996/08/18 01:53:57 dawes Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmimggblt.c,v 5.17 94/04/17 20:28:25 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "ilbm.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "maskbits.h"
+
+/*
+ we should eventually special-case fixed-width fonts for ImageText.
+
+ this works for fonts with glyphs <= 32 bits wide.
+
+ the clipping calculations are done for worst-case fonts.
+we make no assumptions about the heights, widths, or bearings
+of the glyphs. if we knew that the glyphs are all the same height,
+we could clip the tops and bottoms per clipping box, rather
+than per character per clipping box. if we knew that the glyphs'
+left and right bearings were wlle-behaved, we could clip a single
+character at the start, output until the last unclipped
+character, and then clip the last one. this is all straightforward
+to determine based on max-bounds and min-bounds from the font.
+ there is some inefficiency introduced in the per-character
+clipping to make what's going on clearer.
+
+ (it is possible, for example, for a font to be defined in which the
+next-to-last character in a font would be clipped out, but the last
+one wouldn't. the code below deals with this.)
+
+ Image text looks at the bits in the glyph and the fg and bg in the
+GC. it paints a rectangle, as defined in the protocol dcoument,
+and the paints the characters.
+
+ the register allocations for startmask and endmask may not
+be the right thing. are there two other deserving candidates?
+xoff, pdst, pglyph, and tmpSrc seem like the right things, though.
+*/
+
+void
+ilbmImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ ExtentInfoRec info; /* used by QueryGlyphExtents() */
+ BoxRec bbox; /* string's bounding box */
+ xRectangle backrect;/* backing rectangle to paint.
+ in the general case, NOT necessarily
+ the same as the string's bounding box
+ */
+
+ CharInfoPtr pci;
+ int xorg, yorg; /* origin of drawable in bitmap */
+ int widthDst; /* width of dst in longwords */
+
+ /* these keep track of the character origin */
+ PixelType *pdstBase;
+ /* points to longword with character origin */
+ int xchar; /* xorigin of char (mod 32) */
+
+ /* these are used for placing the glyph */
+ register int xoff; /* x offset of left edge of glyph (mod 32) */
+ register PixelType *pdst;
+ /* pointer to current longword in dst */
+
+ register int d;
+ int depthDst;
+ int auxDst;
+ int hSave;
+ int w; /* width of glyph in bits */
+ int h; /* height of glyph */
+ int widthGlyph; /* width of glyph, in bytes */
+ unsigned char rrops[AFB_MAX_DEPTH];
+ register unsigned char *pglyph;
+ /* pointer to current row of glyph */
+ unsigned char *pglyphSave;
+
+ /* used for putting down glyph */
+ register PixelType tmpSrc;
+ /* for getting bits from glyph */
+ register PixelType startmask;
+ register PixelType endmask;
+
+ register int nFirst;/* bits of glyph in current longword */
+ PixelType *pdstSave;
+ int oldFill;
+ ilbmPrivGC *pPriv = (ilbmPrivGC *)(pGC->devPrivates[ilbmGCPrivateIndex].ptr);
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, widthDst, auxDst, depthDst,
+ pdstBase);
+
+ QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info);
+
+ backrect.x = x;
+ backrect.y = y - FONTASCENT(pGC->font);
+ backrect.width = info.overallWidth;
+ backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+
+ x += xorg;
+ y += yorg;
+
+ bbox.x1 = x + info.overallLeft;
+ bbox.x2 = x + info.overallRight;
+ bbox.y1 = y - info.overallAscent;
+ bbox.y2 = y + info.overallDescent;
+
+ oldFill = pGC->fillStyle;
+ pGC->fillStyle = FillSolid;
+ ilbmReduceRop (pGC->alu, pGC->bgPixel, pGC->planemask, pGC->depth,
+ pPriv->rrops);
+ ilbmPolyFillRect(pDrawable, pGC, 1, &backrect);
+ pGC->fillStyle = oldFill;
+ ilbmReduceRop (pGC->alu, pGC->fgPixel, pGC->planemask, pGC->depth,
+ pPriv->rrops);
+ ilbmReduceRop (GXcopy, pGC->fgPixel, pGC->planemask, pGC->depth, rrops);
+
+ /* the faint-hearted can open their eyes now */
+
+ switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox)) {
+ case rgnOUT:
+ break;
+ case rgnIN:
+ pdstBase = ilbmScanlineNoBankSwitch(pdstBase, x, y, auxDst);
+ xchar = x & PIM;
+
+ while (nglyph--) {
+ pci = *ppci;
+ pglyphSave = FONTGLYPHBITS(pglyphBase, pci);
+ w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
+ hSave = pci->metrics.ascent + pci->metrics.descent;
+ widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
+ /* start at top scanline of glyph */
+ pdstSave = ilbmScanlineDelta(pdstBase, -pci->metrics.ascent,
+ auxDst);
+
+ /* find correct word in scanline and x offset within it
+ for left edge of glyph
+ */
+ xoff = xchar + pci->metrics.leftSideBearing;
+ if (xoff > PLST) {
+ pdstSave++;
+ xoff &= PIM;
+ } else if (xoff < 0) {
+ xoff += PPW;
+ pdstSave--;
+ }
+
+ for (d = 0; d < depthDst; d++) {
+ h = hSave;
+ pdst = pdstSave;
+ pdstSave += widthDst; /* @@@ NEXT PLANE @@@ */
+ pglyph = pglyphSave;
+
+ if ((xoff + w) <= PPW) {
+ /* glyph all in one longword */
+ maskpartialbits(xoff, w, startmask);
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst |= SCRRIGHT(tmpSrc, xoff) & startmask;
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ }
+ } else {
+ /* glyph crosses longword boundary */
+ maskPPWbits(xoff, w, startmask, endmask);
+ nFirst = PPW - xoff;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) &= ~(SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst |= SCRRIGHT(tmpSrc, xoff) & startmask;
+ *(pdst+1) |= SCRLEFT(tmpSrc, nFirst) & endmask;
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ }
+ } /* glyph crosses longwords boundary */
+ } /* depth loop */
+ /* update character origin */
+ x += pci->metrics.characterWidth;
+ xchar += pci->metrics.characterWidth;
+ if (xchar > PLST) {
+ xchar -= PPW;
+ pdstBase++;
+ } else if (xchar < 0) {
+ xchar += PPW;
+ pdstBase--;
+ }
+ ppci++;
+ } /* while nglyph-- */
+ break;
+ case rgnPART:
+ {
+ ilbmTEXTPOS *ppos;
+ int nbox;
+ BoxPtr pbox;
+ RegionPtr cclip;
+ int xpos; /* x position of char origin */
+ int i;
+ BoxRec clip;
+ int leftEdge, rightEdge;
+ int topEdge, bottomEdge;
+ int glyphRow; /* first row of glyph not wholly
+ clipped out */
+ int glyphCol; /* leftmost visible column of glyph */
+ int getWidth; /* bits to get from glyph */
+
+ if (!(ppos = (ilbmTEXTPOS *)ALLOCATE_LOCAL(nglyph *
+ sizeof(ilbmTEXTPOS))))
+ return;
+
+ pdstBase = ilbmScanlineNoBankSwitch(pdstBase, x, y, auxDst);
+ xpos = x;
+ xchar = xpos & PIM;
+
+ for (i = 0; i < nglyph; i++) {
+ pci = ppci[i];
+
+ ppos[i].xpos = xpos;
+ ppos[i].xchar = xchar;
+ ppos[i].leftEdge = xpos + pci->metrics.leftSideBearing;
+ ppos[i].rightEdge = xpos + pci->metrics.rightSideBearing;
+ ppos[i].topEdge = y - pci->metrics.ascent;
+ ppos[i].bottomEdge = y + pci->metrics.descent;
+ ppos[i].pdstBase = pdstBase;
+ ppos[i].widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
+
+ xpos += pci->metrics.characterWidth;
+ xchar += pci->metrics.characterWidth;
+ if (xchar > PLST) {
+ xchar &= PIM;
+ pdstBase++;
+ } else if (xchar < 0) {
+ xchar += PPW;
+ pdstBase--;
+ }
+ }
+
+ cclip = pGC->pCompositeClip;
+ pbox = REGION_RECTS(cclip);
+ nbox = REGION_NUM_RECTS(cclip);
+
+ /* HACK ALERT
+ since we continue out of the loop below so often, it
+ is easier to increment pbox at the top than at the end.
+ don't try this at home.
+ */
+ pbox--;
+ while (nbox--) {
+ pbox++;
+ clip.x1 = max(bbox.x1, pbox->x1);
+ clip.y1 = max(bbox.y1, pbox->y1);
+ clip.x2 = min(bbox.x2, pbox->x2);
+ clip.y2 = min(bbox.y2, pbox->y2);
+ if ((clip.x2<=clip.x1) || (clip.y2<=clip.y1))
+ continue;
+
+ for (i = 0; i < nglyph; i++) {
+ pci = ppci[i];
+ xchar = ppos[i].xchar;
+
+ /* clip the left and right edges */
+ if (ppos[i].leftEdge < clip.x1)
+ leftEdge = clip.x1;
+ else
+ leftEdge = ppos[i].leftEdge;
+
+ if (ppos[i].rightEdge > clip.x2)
+ rightEdge = clip.x2;
+ else
+ rightEdge = ppos[i].rightEdge;
+
+ w = rightEdge - leftEdge;
+ if (w <= 0)
+ continue;
+
+ /* clip the top and bottom edges */
+ if (ppos[i].topEdge < clip.y1)
+ topEdge = clip.y1;
+ else
+ topEdge = ppos[i].topEdge;
+
+ if (ppos[i].bottomEdge > clip.y2)
+ bottomEdge = clip.y2;
+ else
+ bottomEdge = ppos[i].bottomEdge;
+
+ hSave = bottomEdge - topEdge;
+ if (hSave <= 0)
+ continue;
+
+ glyphRow = (topEdge - y) + pci->metrics.ascent;
+ widthGlyph = ppos[i].widthGlyph;
+ pglyphSave = FONTGLYPHBITS(pglyphBase, pci);
+ pglyphSave += (glyphRow * widthGlyph);
+
+ glyphCol = (leftEdge - ppos[i].xpos) -
+ (pci->metrics.leftSideBearing);
+ getWidth = w + glyphCol;
+
+ pdstSave = ilbmScanlineDelta(ppos[i].pdstBase, -(y-topEdge),
+ auxDst);
+ xoff = xchar + (leftEdge - ppos[i].xpos);
+ if (xoff > PLST) {
+ xoff &= PIM;
+ pdstSave++;
+ } else if (xoff < 0) {
+ xoff += PPW;
+ pdstSave--;
+ }
+
+ for (d = 0; d < depthDst; d++) {
+ h = hSave;
+ pdst = pdstSave;
+ pdstSave += widthDst; /* @@@ NEXT PLANE @@@ */
+ pglyph = pglyphSave;
+
+ if ((xoff + w) <= PPW) {
+ maskpartialbits(xoff, w, startmask);
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst |= SCRRIGHT(tmpSrc, xoff) & startmask;
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ }
+ } else {
+ maskPPWbits(xoff, w, startmask, endmask);
+ nFirst = PPW - xoff;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) &= ~(SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst |= SCRRIGHT(tmpSrc, xoff) & startmask;
+ *(pdst+1) |= SCRLEFT(tmpSrc, nFirst) & endmask;
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ }
+ }
+ } /* depth */
+ } /* for each glyph */
+ } /* while nbox-- */
+ DEALLOCATE_LOCAL(ppos);
+ break;
+ }
+
+ default:
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmline.c b/nx-X11/programs/Xserver/ilbm/ilbmline.c
new file mode 100644
index 000000000..aa13fc114
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmline.c
@@ -0,0 +1,705 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmline.c,v 3.0 1996/08/18 01:53:58 dawes Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmline.c,v 5.18 94/04/17 20:28:26 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "mistruct.h"
+
+#include "ilbm.h"
+#include "maskbits.h"
+#include "miline.h"
+
+/* single-pixel lines on a color frame buffer
+
+ NON-SLOPED LINES
+ horizontal lines are always drawn left to right; we have to
+move the endpoints right by one after they're swapped.
+ horizontal lines will be confined to a single band of a
+region. the code finds that band (giving up if the lower
+bound of the band is above the line we're drawing); then it
+finds the first box in that band that contains part of the
+line. we clip the line to subsequent boxes in that band.
+ vertical lines are always drawn top to bottom (y-increasing.)
+this requires adding one to the y-coordinate of each endpoint
+after swapping.
+
+ SLOPED LINES
+ when clipping a sloped line, we bring the second point inside
+the clipping box, rather than one beyond it, and then add 1 to
+the length of the line before drawing it. this lets us use
+the same box for finding the outcodes for both endpoints. since
+the equation for clipping the second endpoint to an edge gives us
+1 beyond the edge, we then have to move the point towards the
+first point by one step on the major axis.
+ eventually, there will be a diagram here to explain what's going
+on. the method uses Cohen-Sutherland outcodes to determine
+outsideness, and a method similar to Pike's layers for doing the
+actual clipping.
+
+*/
+
+void
+#ifdef POLYSEGMENT
+ilbmSegmentSS(pDrawable, pGC, nseg, pSeg)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nseg;
+ register xSegment *pSeg;
+#else
+ilbmLineSS(pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt; /* number of points */
+ DDXPointPtr pptInit;
+#endif
+{
+ int nboxInit;
+ register int nbox;
+ BoxPtr pboxInit;
+ register BoxPtr pbox;
+#ifndef POLYSEGMENT
+ register DDXPointPtr ppt; /* pointer to list of translated points */
+#endif
+
+ unsigned int oc1; /* outcode of point 1 */
+ unsigned int oc2; /* outcode of point 2 */
+
+ PixelType *addrlBase; /* pointer to start of drawable */
+ PixelType *addrl; /* address of destination pixmap */
+ int nlwidth; /* width in longwords of destination pixmap */
+ int xorg, yorg; /* origin of window */
+
+ int adx; /* abs values of dx and dy */
+ int ady;
+ int signdx; /* sign of dx and dy */
+ int signdy;
+ int e, e1, e2; /* bresenham error and increments */
+ int len; /* length of segment */
+ int axis; /* major axis */
+ int octant;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ int depthDst;
+ int d;
+ int auxDst;
+ unsigned char *rrops;
+
+ /* a bunch of temporaries */
+ register int y1, y2;
+ register int x1, x2;
+ RegionPtr cclip;
+
+ cclip = pGC->pCompositeClip;
+ rrops = ((ilbmPrivGC *)(pGC->devPrivates[ilbmGCPrivateIndex].ptr))->rrops;
+ pboxInit = REGION_RECTS(cclip);
+ nboxInit = REGION_NUM_RECTS(cclip);
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
+ addrlBase);
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+#ifdef POLYSEGMENT
+ while (nseg--)
+#else
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while (--npt)
+#endif
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+#ifdef POLYSEGMENT
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious) {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+#endif
+
+ if (x1 == x2) /* vertical line */
+ {
+ /* make the line go top to bottom of screen, keeping
+ endpoint semantics
+ */
+ if (y1 > y2) {
+ register int tmp;
+
+ tmp = y2;
+ y2 = y1 + 1;
+ y1 = tmp + 1;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ y1--;
+#endif
+ }
+#ifdef POLYSEGMENT
+ else if (pGC->capStyle != CapNotLast)
+ y2++;
+#endif
+ /* get to first band that might contain part of line */
+ while ((nbox) && (pbox->y2 <= y1)) {
+ pbox++;
+ nbox--;
+ }
+
+ if (nbox) {
+ /* stop when lower edge of box is beyond end of line */
+ while ((nbox) && (y2 >= pbox->y1)) {
+ if ((x1 >= pbox->x1) && (x1 < pbox->x2)) {
+ int y1t, y2t;
+ /* this box has part of the line in it */
+ y1t = max(y1, pbox->y1);
+ y2t = min(y2, pbox->y2);
+ if (y1t != y2t)
+ ilbmVertS(addrlBase, nlwidth, auxDst, depthDst, x1, y1t,
+ y2t-y1t, rrops); /* @@@ NEXT PLANE PASSED @@@ */
+ }
+ nbox--;
+ pbox++;
+ }
+ }
+#ifndef POLYSEGMENT
+ y2 = ppt->y + yorg;
+#endif
+ } else if (y1 == y2) /* horizontal line */ {
+ /* force line from left to right, keeping
+ endpoint semantics
+ */
+ if (x1 > x2) {
+ register int tmp;
+
+ tmp = x2;
+ x2 = x1 + 1;
+ x1 = tmp + 1;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ x1--;
+#endif
+ }
+#ifdef POLYSEGMENT
+ else if (pGC->capStyle != CapNotLast)
+ x2++;
+#endif
+
+ /* find the correct band */
+ while ((nbox) && (pbox->y2 <= y1)) {
+ pbox++;
+ nbox--;
+ }
+
+ /* try to draw the line, if we haven't gone beyond it */
+ if ((nbox) && (pbox->y1 <= y1)) {
+ int tmp;
+
+ /* when we leave this band, we're done */
+ tmp = pbox->y1;
+ while ((nbox) && (pbox->y1 == tmp)) {
+ int x1t, x2t;
+
+ if (pbox->x2 <= x1) {
+ /* skip boxes until one might contain start point */
+ nbox--;
+ pbox++;
+ continue;
+ }
+
+ /* stop if left of box is beyond right of line */
+ if (pbox->x1 >= x2) {
+ nbox = 0;
+ break;
+ }
+
+ x1t = max(x1, pbox->x1);
+ x2t = min(x2, pbox->x2);
+ if (x1t != x2t)
+ ilbmHorzS(addrlBase, nlwidth, auxDst, depthDst, x1t, y1,
+ x2t-x1t, rrops); /* @@@ NEXT PLANE PASSED @@@ */
+ nbox--;
+ pbox++;
+ }
+ }
+#ifndef POLYSEGMENT
+ x2 = ppt->x + xorg;
+#endif
+ }
+ else /* sloped line */
+ {
+ CalcLineDeltas(x1, y1, x2, y2, adx, ady,
+ signdx, signdy, 1, 1, octant);
+
+ if (adx > ady) {
+ axis = X_AXIS;
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+ } else {
+ axis = Y_AXIS;
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ SetYMajorOctant(octant);
+ }
+
+ FIXUP_ERROR(e, octant, bias);
+
+ /* we have bresenham parameters and two points.
+ all we have to do now is clip and draw.
+ */
+
+ while (nbox--) {
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if ((oc1 | oc2) == 0) {
+ if (axis == X_AXIS)
+ len = adx;
+ else
+ len = ady;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ len++;
+#endif
+ ilbmBresS(addrlBase, nlwidth, auxDst, depthDst, signdx, signdy,
+ axis, x1, y1, e, e1, e2, len, rrops); /* @@@ NEXT PLANE PASSED @@@ */
+ break;
+ } else if (oc1 & oc2) {
+ pbox++;
+ } else {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int clipdx, clipdy;
+ int err;
+
+ if (miZeroClipLine(pbox->x1, pbox->y1, pbox->x2-1,
+ pbox->y2-1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1) {
+ pbox++;
+ continue;
+ }
+
+ if (axis == X_AXIS)
+ len = abs(new_x2 - new_x1);
+ else
+ len = abs(new_y2 - new_y1);
+#ifdef POLYSEGMENT
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+#else
+ len += (clip2 != 0);
+#endif
+ if (len) {
+ /* unwind bresenham error term to first point */
+ if (clip1) {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ if (axis == X_AXIS)
+ err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));
+ else
+ err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));
+ }
+ else
+ err = e;
+ ilbmBresS(addrlBase, nlwidth, auxDst, depthDst, signdx,
+ signdy, axis, new_x1, new_y1, err, e1, e2, len,
+ rrops); /* @@@ NEXT PLANE PASSED @@@ */
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+ } /* sloped line */
+ } /* while (nline--) */
+
+#ifndef POLYSEGMENT
+
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1))) {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--) {
+ if ((x2 >= pbox->x1) && (y2 >= pbox->y1) && (x2 < pbox->x2) &&
+ (y2 < pbox->y2)) {
+ for (d = 0; d < depthDst; d++) {
+ addrl = ilbmScanline(addrlBase, x2, y2, auxDst);
+ addrlBase += nlwidth; /* @@@ NEXT PLANE @@@ */
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ *addrl &= rmask[x2 & PIM];
+ break;
+ case RROP_WHITE:
+ *addrl |= mask[x2 & PIM];
+ break;
+ case RROP_INVERT:
+ *addrl ^= mask[x2 & PIM];
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ...) */
+ break;
+ } else
+ pbox++;
+ }
+ }
+#endif
+}
+
+/*
+ * Draw dashed 1-pixel lines.
+ */
+
+void
+#ifdef POLYSEGMENT
+ilbmSegmentSD(pDrawable, pGC, nseg, pSeg)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int nseg;
+ register xSegment *pSeg;
+#else
+ilbmLineSD(pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt; /* number of points */
+ DDXPointPtr pptInit;
+#endif
+{
+ int nboxInit;
+ register int nbox;
+ BoxPtr pboxInit;
+ register BoxPtr pbox;
+#ifndef POLYSEGMENT
+ register DDXPointPtr ppt; /* pointer to list of translated points */
+#endif
+
+ register unsigned int oc1; /* outcode of point 1 */
+ register unsigned int oc2; /* outcode of point 2 */
+
+ PixelType *addrlBase; /* address of destination pixmap */
+ PixelType *addrl;
+ int nlwidth; /* width in longwords of destination pixmap */
+ int auxDst;
+ int depthDst;
+ int xorg, yorg; /* origin of window */
+
+ int adx; /* abs values of dx and dy */
+ int ady;
+ int signdx; /* sign of dx and dy */
+ int signdy;
+ int e, e1, e2; /* bresenham error and increments */
+ int len; /* length of segment */
+ int axis; /* major axis */
+ int octant;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ int x1, x2, y1, y2;
+ RegionPtr cclip;
+ unsigned char *rrops;
+ unsigned char bgrrops[AFB_MAX_DEPTH];
+ unsigned char *pDash;
+ int dashOffset;
+ int numInDashList;
+ int dashIndex;
+ int isDoubleDash;
+ int dashIndexTmp, dashOffsetTmp;
+ int unclippedlen;
+ int d;
+
+ cclip = pGC->pCompositeClip;
+ rrops = ((ilbmPrivGC *)(pGC->devPrivates[ilbmGCPrivateIndex].ptr))->rrops;
+ pboxInit = REGION_RECTS(cclip);
+ nboxInit = REGION_NUM_RECTS(cclip);
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
+ addrlBase);
+
+ /* compute initial dash values */
+
+ pDash = (unsigned char *) pGC->dash;
+ numInDashList = pGC->numInDashList;
+ isDoubleDash = (pGC->lineStyle == LineDoubleDash);
+ dashIndex = 0;
+ dashOffset = 0;
+ miStepDash ((int)pGC->dashOffset, &dashIndex, pDash,
+ numInDashList, &dashOffset);
+
+ if (isDoubleDash)
+ ilbmReduceRop (pGC->alu, pGC->bgPixel, pGC->planemask, pGC->depth,
+ bgrrops);
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+#ifdef POLYSEGMENT
+ while (nseg--)
+#else
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while (--npt)
+#endif
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+#ifdef POLYSEGMENT
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious) {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+#endif
+
+ CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy,
+ 1, 1, octant);
+
+ if (adx > ady) {
+ axis = X_AXIS;
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+ unclippedlen = adx;
+ } else {
+ axis = Y_AXIS;
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ unclippedlen = ady;
+ SetYMajorOctant(octant);
+ }
+
+ FIXUP_ERROR(e, octant, bias);
+
+ /* we have bresenham parameters and two points.
+ all we have to do now is clip and draw.
+ */
+
+ while (nbox--) {
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if ((oc1 | oc2) == 0) {
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ unclippedlen++;
+ dashIndexTmp = dashIndex;
+ dashOffsetTmp = dashOffset;
+ ilbmBresD(&dashIndexTmp, pDash, numInDashList, &dashOffsetTmp,
+ isDoubleDash, addrlBase, nlwidth, auxDst, depthDst,
+ signdx, signdy, axis, x1, y1, e, e1, e2, unclippedlen,
+ rrops, bgrrops); /* @@@ NEXT PLANE PASSED @@@ */
+ break;
+#else
+ ilbmBresD(&dashIndex, pDash, numInDashList, &dashOffset,
+ isDoubleDash, addrlBase, nlwidth, auxDst, depthDst,
+ signdx, signdy, axis, x1, y1, e, e1, e2, unclippedlen,
+ rrops, bgrrops); /* @@@ NEXT PLANE PASSED @@@ */
+ goto dontStep;
+#endif
+ } else if (oc1 & oc2) {
+ pbox++;
+ } else /* have to clip */ {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int clipdx, clipdy;
+ int err;
+
+ if (miZeroClipLine(pbox->x1, pbox->y1, pbox->x2-1, pbox->y2-1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1) {
+ pbox++;
+ continue;
+ }
+ dashIndexTmp = dashIndex;
+ dashOffsetTmp = dashOffset;
+ if (clip1) {
+ int dlen;
+
+ if (axis == X_AXIS)
+ dlen = abs(new_x1 - x1);
+ else
+ dlen = abs(new_y1 - y1);
+ miStepDash (dlen, &dashIndexTmp, pDash,
+ numInDashList, &dashOffsetTmp);
+ }
+ if (axis == X_AXIS)
+ len = abs(new_x2 - new_x1);
+ else
+ len = abs(new_y2 - new_y1);
+#ifdef POLYSEGMENT
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+#else
+ len += (clip2 != 0);
+#endif
+ if (len) {
+ /* unwind bresenham error term to first point */
+ if (clip1) {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ if (axis == X_AXIS)
+ err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));
+ else
+ err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));
+ }
+ else
+ err = e;
+ ilbmBresD(&dashIndexTmp, pDash, numInDashList, &dashOffsetTmp,
+ isDoubleDash, addrlBase, nlwidth, auxDst, depthDst,
+ signdx, signdy, axis, new_x1, new_y1, err, e1, e2,
+ len, rrops, bgrrops); /* @@@ NEXT PLANE PASSED @@@ */
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+#ifndef POLYSEGMENT
+ /*
+ * walk the dash list around to the next line
+ */
+ miStepDash (unclippedlen, &dashIndex, pDash,
+ numInDashList, &dashOffset);
+dontStep: ;
+#endif
+ } /* while (nline--) */
+
+#ifndef POLYSEGMENT
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((dashIndex & 1) == 0 || isDoubleDash) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1))) {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--) {
+ if ((x2 >= pbox->x1) && (y2 >= pbox->y1) && (x2 < pbox->x2) &&
+ (y2 < pbox->y2)) {
+ int rop;
+
+ for (d = 0; d < depthDst; d++) {
+ addrl = ilbmScanline(addrlBase, x2, y2, auxDst);
+ addrlBase += nlwidth; /* @@@ NEXT PLANE @@@ */
+
+ rop = rrops[d];
+ if (dashIndex & 1)
+ rop = bgrrops[d];
+
+ switch (rop) {
+ case RROP_BLACK:
+ *addrl &= rmask[x2 & PIM];
+ break;
+ case RROP_WHITE:
+ *addrl |= mask[x2 & PIM];
+ break;
+
+ case RROP_INVERT:
+ *addrl ^= mask[x2 & PIM];
+ break;
+
+ case RROP_NOP:
+ break;
+ }
+ } /* for (d = ...) */
+ break;
+ } else
+ pbox++;
+ }
+ }
+#endif
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmmisc.c b/nx-X11/programs/Xserver/ilbm/ilbmmisc.c
new file mode 100644
index 000000000..32b1a4b4c
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmmisc.c
@@ -0,0 +1,99 @@
+/* $XFree86$ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmmisc.c,v 5.4 94/04/17 20:28:27 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "cursor.h"
+#include "scrnintstr.h"
+
+#include "ilbm.h"
+
+/*ARGSUSED*/
+void
+ilbmQueryBestSize(class, pwidth, pheight, pScreen)
+int class;
+unsigned short *pwidth;
+unsigned short *pheight;
+ScreenPtr pScreen;
+{
+ unsigned width, test;
+
+ switch (class) {
+ case CursorShape:
+ if (*pwidth > pScreen->width)
+ *pwidth = pScreen->width;
+ if (*pheight > pScreen->height)
+ *pheight = pScreen->height;
+ break;
+ case TileShape:
+ case StippleShape:
+ width = *pwidth;
+ if (!width) break;
+ /* Return the closes power of two not less than what they gave me */
+ test = 0x80000000;
+ /* Find the highest 1 bit in the width given */
+ while (!(test & width))
+ test >>= 1;
+ /* If their number is greater than that, bump up to the next
+ * power of two */
+ if ((test - 1) & width)
+ test <<= 1;
+ *pwidth = test;
+ /* We don't care what height they use */
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmpixmap.c b/nx-X11/programs/Xserver/ilbm/ilbmpixmap.c
new file mode 100644
index 000000000..33c317155
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmpixmap.c
@@ -0,0 +1,295 @@
+/* $XFree86$ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmpixmap.c,v 5.13 94/04/17 20:28:28 dpw Exp $ */
+
+/* pixmap management
+ written by drewry, september 1986
+
+ on a monchrome device, a pixmap is a bitmap.
+*/
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xmd.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "maskbits.h"
+
+#include "ilbm.h"
+#include "mi.h"
+
+#include "servermd.h"
+
+PixmapPtr
+ilbmCreatePixmap(pScreen, width, height, depth)
+ ScreenPtr pScreen;
+ int width;
+ int height;
+ int depth;
+{
+ PixmapPtr pPixmap;
+ size_t datasize;
+ size_t paddedWidth;
+
+ paddedWidth = BitmapBytePad(width);
+ if (paddedWidth > 32767 || height > 32767 || depth > 4)
+ return NullPixmap;
+ datasize = height * paddedWidth * depth;
+ pPixmap = AllocatePixmap(pScreen, datasize);
+ if (!pPixmap)
+ return(NullPixmap);
+ pPixmap->drawable.type = DRAWABLE_PIXMAP;
+ pPixmap->drawable.class = 0;
+ pPixmap->drawable.pScreen = pScreen;
+ pPixmap->drawable.depth = depth;
+ pPixmap->drawable.bitsPerPixel = depth;
+ pPixmap->drawable.id = 0;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pPixmap->drawable.x = 0;
+ pPixmap->drawable.y = 0;
+ pPixmap->drawable.width = width;
+ pPixmap->drawable.height = height;
+ pPixmap->devKind = paddedWidth;
+ pPixmap->refcnt = 1;
+#ifdef PIXPRIV
+ pPixmap->devPrivate.ptr = datasize ?
+ (pointer)((char *)pPixmap + pScreen->totalPixmapSize) : NULL;
+#else
+ pPixmap->devPrivate.ptr = (pointer)(pPixmap + 1);
+#endif
+ return(pPixmap);
+}
+
+Bool
+ilbmDestroyPixmap(pPixmap)
+ PixmapPtr pPixmap;
+{
+ if (--pPixmap->refcnt)
+ return(TRUE);
+ xfree(pPixmap);
+ return(TRUE);
+}
+
+
+PixmapPtr
+ilbmCopyPixmap(pSrc)
+ register PixmapPtr pSrc;
+{
+ register PixmapPtr pDst;
+ int size;
+ ScreenPtr pScreen;
+
+ size = pSrc->drawable.height * pSrc->devKind * pSrc->drawable.depth;
+ pScreen = pSrc->drawable.pScreen;
+ pDst = (*pScreen->CreatePixmap)(pScreen, pSrc->drawable.width,
+ pSrc->drawable.height, pSrc->drawable.depth);
+ if (!pDst)
+ return(NullPixmap);
+ memmove((char *)pDst->devPrivate.ptr, (char *)pSrc->devPrivate.ptr, size);
+ return(pDst);
+}
+
+
+/* replicates a pattern to be a full 32 bits wide.
+ relies on the fact that each scnaline is longword padded.
+ doesn't do anything if pixmap is not a factor of 32 wide.
+ changes width field of pixmap if successful, so that the fast
+ XRotatePixmap code gets used if we rotate the pixmap later.
+
+ calculate number of times to repeat
+ for each scanline of pattern
+ zero out area to be filled with replicate
+ left shift and or in original as many times as needed
+*/
+void
+ilbmPadPixmap(pPixmap)
+ PixmapPtr pPixmap;
+{
+ register int width = pPixmap->drawable.width;
+ register int h;
+ register PixelType mask;
+ register PixelType *p;
+ register PixelType bits; /* real pattern bits */
+ register int i;
+ int d;
+ int rep; /* repeat count for pattern */
+
+ if (width >= PPW)
+ return;
+
+ rep = PPW/width;
+ if (rep*width != PPW)
+ return;
+
+ mask = endtab[width];
+
+ p = (PixelType *)(pPixmap->devPrivate.ptr);
+
+ for (d = 0; d < pPixmap->drawable.depth; d++) {
+ for (h = 0; h < pPixmap->drawable.height; h++) {
+ *p &= mask;
+ bits = *p;
+ for (i = 1; i < rep; i++) {
+ bits = SCRRIGHT(bits, width);
+ *p |= bits;
+ }
+ p++;
+ }
+ }
+ pPixmap->drawable.width = PPW;
+}
+
+/* Rotates pixmap pPix by w pixels to the right on the screen. Assumes that
+ * words are PPW bits wide, and that the least significant bit appears on the
+ * left.
+ */
+void
+ilbmXRotatePixmap(pPix, rw)
+ PixmapPtr pPix;
+ register int rw;
+{
+ register PixelType *pw, *pwFinal;
+ register PixelType t;
+
+ if (pPix == NullPixmap)
+ return;
+
+ pw = (PixelType *)pPix->devPrivate.ptr;
+ rw %= (int)pPix->drawable.width;
+ if (rw < 0)
+ rw += (int)pPix->drawable.width;
+ if (pPix->drawable.width == PPW) {
+ pwFinal = pw + pPix->drawable.height * pPix->drawable.depth;
+ while (pw < pwFinal) {
+ t = *pw;
+ *pw++ = SCRRIGHT(t, rw) | (SCRLEFT(t, (PPW-rw)) & endtab[rw]);
+ }
+ } else {
+ /* We no longer do this. Validate doesn't try to rotate odd-size
+ * tiles or stipples. ilbmUnnatural<tile/stipple>FS works directly off
+ * the unrotate tile/stipple in the GC
+ */
+ ErrorF("X internal error: trying to rotate odd-sized pixmap.\n");
+ }
+
+}
+
+/* Rotates pixmap pPix by h lines. Assumes that h is always less than
+ pPix->height
+ works on any width.
+ */
+void
+ilbmYRotatePixmap(pPix, rh)
+ register PixmapPtr pPix;
+ int rh;
+{
+ int nbyDown; /* bytes to move down to row 0; also offset of
+ row rh */
+ int nbyUp; /* bytes to move up to line rh; also
+ offset of first line moved down to 0 */
+ char *pbase;
+ char *ptmp;
+ int height;
+ int aux;
+
+ if (pPix == NullPixmap)
+ return;
+ height = (int) pPix->drawable.height;
+ rh %= height;
+ if (rh < 0)
+ rh += height;
+
+ aux = pPix->devKind*pPix->drawable.depth;
+ nbyDown = rh*aux;
+ nbyUp = height*aux-nbyDown;
+
+ if (!(ptmp = (char *)ALLOCATE_LOCAL(nbyUp)))
+ return;
+
+ pbase = (char *)pPix->devPrivate.ptr;
+ memmove(ptmp, pbase, nbyUp); /* save the low rows */
+ memmove(pbase, pbase+nbyUp, nbyDown); /* slide the top rows down */
+ memmove(pbase+nbyDown, ptmp, nbyUp); /* move lower rows up to row rh */
+ DEALLOCATE_LOCAL(ptmp);
+}
+
+void
+ilbmCopyRotatePixmap(psrcPix, ppdstPix, xrot, yrot)
+ register PixmapPtr psrcPix, *ppdstPix;
+ int xrot, yrot;
+{
+ register PixmapPtr pdstPix;
+
+ if ((pdstPix = *ppdstPix) && (pdstPix->devKind == psrcPix->devKind) &&
+ (pdstPix->drawable.height == psrcPix->drawable.height) &&
+ (pdstPix->drawable.depth == psrcPix->drawable.depth)) {
+ memmove((char *)pdstPix->devPrivate.ptr, (char *)psrcPix->devPrivate.ptr,
+ psrcPix->drawable.height * psrcPix->devKind *
+ psrcPix->drawable.depth);
+ pdstPix->drawable.width = psrcPix->drawable.width;
+ pdstPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ } else {
+ if (pdstPix)
+ /* FIX XBUG 6168 */
+ (*pdstPix->drawable.pScreen->DestroyPixmap)(pdstPix);
+ *ppdstPix = pdstPix = ilbmCopyPixmap(psrcPix);
+ if (!pdstPix)
+ return;
+ }
+ ilbmPadPixmap(pdstPix);
+ if (xrot)
+ ilbmXRotatePixmap(pdstPix, xrot);
+ if (yrot)
+ ilbmYRotatePixmap(pdstPix, yrot);
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmply1rct.c b/nx-X11/programs/Xserver/ilbm/ilbmply1rct.c
new file mode 100644
index 000000000..490551db7
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmply1rct.c
@@ -0,0 +1,303 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmply1rct.c,v 3.0 1996/08/18 01:54:02 dawes Exp $ */
+/*
+ * $XConsortium: ilbmply1rct.c,v 1.9 94/04/17 20:28:28 dpw Exp $
+ *
+Copyright (c) 1990 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "mistruct.h"
+
+#include "ilbm.h"
+#include "maskbits.h"
+
+#if defined(mips) || defined(sparc)
+#define GetHighWord(x) (((int)(x)) >> 16)
+#else
+#define GetHighWord(x) (((int)(x)) / 65536)
+#endif
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define intToCoord(i,x,y) (((x) = GetHighWord(i)), ((y) = (int)((short) (i))))
+#define coordToInt(x,y) (((x) << 16) | (y))
+#define intToX(i) (GetHighWord(i))
+#define intToY(i) ((int)((short) i))
+#else
+#define intToCoord(i,x,y) (((x) = (int)((short) (i))), ((y) = GetHighWord(i)))
+#define coordToInt(x,y) (((y) << 16) | (x))
+#define intToX(i) ((int)((short) (i)))
+#define intToY(i) (GetHighWord(i))
+#endif
+
+void
+ilbmFillPolygonSolid (pDrawable, pGC, shape, mode, count, ptsIn)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int shape;
+ int mode;
+ int count;
+ DDXPointPtr ptsIn;
+{
+ ilbmPrivGCPtr devPriv;
+ int nlwidth;
+ PixelType *addrl, *addr;
+ int maxy;
+ int origin;
+ register int vertex1, vertex2;
+ int c;
+ BoxPtr extents;
+ int clip;
+ int y;
+ int *vertex1p, *vertex2p;
+ int *endp;
+ int x1, x2;
+ int dx1, dx2;
+ int dy1, dy2;
+ int e1, e2;
+ int step1, step2;
+ int sign1, sign2;
+ int h;
+ int l, r;
+ PixelType mask, bits = ~((PixelType)0);
+ int nmiddle;
+ register unsigned char *rrops;
+ register int n;
+ register int d;
+ int auxDst;
+ int depthDst;
+ register PixelType *pdst;
+
+ devPriv = (ilbmPrivGC *)(pGC->devPrivates[ilbmGCPrivateIndex].ptr);
+
+ if (mode == CoordModePrevious || shape != Convex ||
+ REGION_NUM_RECTS(pGC->pCompositeClip) != 1) {
+ miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+ origin = *((int *) &pDrawable->x);
+ origin -= (origin & 0x8000) << 1;
+ extents = &pGC->pCompositeClip->extents;
+ vertex1 = *((int *) &extents->x1) - origin;
+ vertex2 = *((int *) &extents->x2) - origin - 0x00010001;
+ clip = 0;
+ y = 32767;
+ maxy = 0;
+ vertex2p = (int *) ptsIn;
+ endp = vertex2p + count;
+ while (count--) {
+ c = *vertex2p;
+ clip |= (c - vertex1) | (vertex2 - c);
+ c = intToY(c);
+ if (c < y) {
+ y = c;
+ vertex1p = vertex2p;
+ }
+ vertex2p++;
+ if (c > maxy)
+ maxy = c;
+ }
+ if (y == maxy)
+ return;
+
+ if (clip & 0x80008000) {
+ miFillPolygon (pDrawable, pGC, shape, mode, vertex2p - (int *) ptsIn, ptsIn);
+ return;
+ }
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
+ addrl);
+ rrops = devPriv->rrops;
+ addrl = ilbmScanlineDelta(addrl, y + pDrawable->y, auxDst);
+ origin = intToX(origin);
+ vertex2p = vertex1p;
+ vertex2 = vertex1 = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+#define Setup(c,x,vertex,dx,dy,e,sign,step) {\
+ x = intToX(vertex); \
+ if (dy = intToY(c) - y) { \
+ dx = intToX(c) - x; \
+ step = 0; \
+ if (dx >= 0) { \
+ e = 0; \
+ sign = 1; \
+ if (dx >= dy) {\
+ step = dx / dy; \
+ dx = dx % dy; \
+ } \
+ } else { \
+ e = 1 - dy; \
+ sign = -1; \
+ dx = -dx; \
+ if (dx >= dy) { \
+ step = - (dx / dy); \
+ dx = dx % dy; \
+ } \
+ } \
+ } \
+ x += origin; \
+ vertex = c; \
+}
+
+#define Step(x,dx,dy,e,sign,step) {\
+ x += step; \
+ if ((e += dx) > 0) { \
+ x += sign; \
+ e -= dy; \
+ } \
+}
+ for (;;) {
+ if (y == intToY(vertex1)) {
+ do {
+ if (vertex1p == (int *) ptsIn)
+ vertex1p = endp;
+ c = *--vertex1p;
+ Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1)
+ } while (y >= intToY(vertex1));
+ h = dy1;
+ } else {
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ h = intToY(vertex1) - y;
+ }
+ if (y == intToY(vertex2)) {
+ do {
+ c = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+ Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2)
+ } while (y >= intToY(vertex2));
+ if (dy2 < h)
+ h = dy2;
+ } else {
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ if ((c = (intToY(vertex2) - y)) < h)
+ h = c;
+ }
+ /* fill spans for this segment */
+ y += h;
+ for (;;) {
+ l = x1;
+ r = x2;
+ nmiddle = x2 - x1;
+ if (nmiddle < 0) {
+ nmiddle = -nmiddle;
+ l = x2;
+ r = x1;
+ }
+ c = l & PIM;
+ l -= c;
+ l = l >> PWSH;
+ addr = addrl + l;
+ if (c + nmiddle < PPW) {
+ mask = SCRRIGHT (bits,c) ^ SCRRIGHT (bits,c+nmiddle);
+ for (pdst = addr, d = 0; d < depthDst; d++, pdst += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ *pdst &= ~mask;
+ break;
+ case RROP_WHITE:
+ *pdst |= mask;
+ break;
+ case RROP_INVERT:
+ *pdst ^= mask;
+ break;
+ case RROP_NOP:
+ break;
+ }
+ }
+ } else {
+ if (c) {
+ mask = SCRRIGHT(bits, c);
+ for (pdst = addr, d = 0; d < depthDst; d++, pdst += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ *pdst &= ~mask;
+ break;
+ case RROP_WHITE:
+ *pdst |= mask;
+ break;
+ case RROP_INVERT:
+ *pdst ^= mask;
+ break;
+ case RROP_NOP:
+ break;
+ }
+ }
+ nmiddle += c - PPW;
+ addr++;
+ }
+ nmiddle >>= PWSH;
+ mask = ~SCRRIGHT(bits, r & PIM);
+
+ for (d = 0; d < depthDst; d++, addr += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ n = nmiddle;
+ pdst = addr;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ Duff (n, *pdst++ = 0;)
+ if (mask)
+ *pdst &= ~mask;
+ break;
+ case RROP_WHITE:
+ Duff (n, *pdst++ = ~0;);
+ if (mask)
+ *pdst |= mask;
+ break;
+ case RROP_INVERT:
+ Duff (n, *pdst++ ^= ~0;);
+ if (mask)
+ *pdst ^= mask;
+ break;
+ case RROP_NOP:
+ break;
+ }
+ }
+ }
+ if (!--h)
+ break;
+ ilbmScanlineInc(addrl, auxDst);
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ }
+ if (y == maxy)
+ break;
+ ilbmScanlineInc(addrl, auxDst);
+ }
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmplygblt.c b/nx-X11/programs/Xserver/ilbm/ilbmplygblt.c
new file mode 100644
index 000000000..9b60e1100
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmplygblt.c
@@ -0,0 +1,469 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmplygblt.c,v 3.0 1996/08/18 01:54:03 dawes Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmimggblt.c,v 5.17 94/04/17 20:28:25 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "ilbm.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "maskbits.h"
+
+/*
+ this works for fonts with glyphs <= 32 bits wide.
+
+ the clipping calculations are done for worst-case fonts.
+we make no assumptions about the heights, widths, or bearings
+of the glyphs. if we knew that the glyphs are all the same height,
+we could clip the tops and bottoms per clipping box, rather
+than per character per clipping box. if we knew that the glyphs'
+left and right bearings were wlle-behaved, we could clip a single
+character at the start, output until the last unclipped
+character, and then clip the last one. this is all straightforward
+to determine based on max-bounds and min-bounds from the font.
+ there is some inefficiency introduced in the per-character
+clipping to make what's going on clearer.
+
+ (it is possible, for example, for a font to be defined in which the
+next-to-last character in a font would be clipped out, but the last
+one wouldn't. the code below deals with this.)
+
+*/
+
+void
+ilbmPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ ExtentInfoRec info; /* used by QueryGlyphExtents() */
+ BoxRec bbox; /* string's bounding box */
+ xRectangle backrect; /* backing rectangle to paint.
+ in the general case, NOT necessarily
+ the same as the string's bounding box
+ */
+
+ CharInfoPtr pci;
+ int xorg, yorg; /* origin of drawable in bitmap */
+ int widthDst; /* width of dst in longwords */
+
+ /* these keep track of the character origin */
+ PixelType *pdstBase;
+ /* points to longword with character origin */
+ int xchar; /* xorigin of char (mod 32) */
+
+ /* these are used for placing the glyph */
+ register int xoff; /* x offset of left edge of glyph (mod 32) */
+ register PixelType *pdst; /* pointer to current longword in dst */
+
+ register int d;
+ int depthDst;
+ int auxDst;
+ int hSave;
+ int w; /* width of glyph in bits */
+ int h; /* height of glyph */
+ int widthGlyph; /* width of glyph, in bytes */
+ unsigned char *rrops;
+ register unsigned char *pglyph;
+ /* pointer to current row of glyph */
+ unsigned char *pglyphSave;
+
+ /* used for putting down glyph */
+ register PixelType tmpSrc;
+ /* for getting bits from glyph */
+ register PixelType startmask;
+ register PixelType endmask;
+
+ register int nFirst; /* bits of glyph in current longword */
+ PixelType *pdstSave;
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, widthDst, auxDst, depthDst,
+ pdstBase);
+
+ QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info);
+
+ x += xorg;
+ y += yorg;
+
+ bbox.x1 = x + info.overallLeft;
+ bbox.x2 = x + info.overallRight;
+ bbox.y1 = y - info.overallAscent;
+ bbox.y2 = y + info.overallDescent;
+
+ rrops = ((ilbmPrivGCPtr) pGC->devPrivates[ilbmGCPrivateIndex].ptr)->rrops;
+
+ switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox)) {
+ case rgnOUT:
+ break;
+ case rgnIN:
+ pdstBase = ilbmScanlineNoBankSwitch(pdstBase, x, y, auxDst);
+ xchar = x & PIM;
+
+ while (nglyph--) {
+ pci = *ppci;
+ pglyphSave = FONTGLYPHBITS(pglyphBase, pci);
+ w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
+ hSave = pci->metrics.ascent + pci->metrics.descent;
+ widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
+ /* start at top scanline of glyph */
+ pdstSave = ilbmScanlineDelta(pdstBase, -pci->metrics.ascent,
+ auxDst);
+
+ /* find correct word in scanline and x offset within it
+ for left edge of glyph
+ */
+ xoff = xchar + pci->metrics.leftSideBearing;
+ if (xoff > PLST) {
+ pdstSave++;
+ xoff &= PIM;
+ } else if (xoff < 0) {
+ xoff += PPW;
+ pdstSave--;
+ }
+
+ for (d = 0; d < depthDst; d++) {
+ h = hSave;
+ pdst = pdstSave;
+ pdstSave += widthDst; /* @@@ NEXT PLANE @@@ */
+ pglyph = pglyphSave;
+
+ if ((xoff + w) <= PPW) {
+ /* glyph all in one longword */
+ maskpartialbits(xoff, w, startmask);
+ switch (rrops[d]) {
+ case RROP_WHITE:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst |= (SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ case RROP_BLACK:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst ^= (SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ }
+ } else {
+ /* glyph crosses longword boundary */
+ maskPPWbits(xoff, w, startmask, endmask);
+ nFirst = PPW - xoff;
+ switch (rrops[d]) {
+ case RROP_WHITE:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst |= (SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) |= (SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ case RROP_BLACK:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) &= ~(SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst ^= (SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) ^= (SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ }
+ } /* glyph crosses longwords boundary */
+ } /* depth loop */
+ /* update character origin */
+ x += pci->metrics.characterWidth;
+ xchar += pci->metrics.characterWidth;
+ if (xchar > PLST) {
+ xchar -= PPW;
+ pdstBase++;
+ } else if (xchar < 0) {
+ xchar += PPW;
+ pdstBase--;
+ }
+ ppci++;
+ } /* while nglyph-- */
+ break;
+ case rgnPART:
+ {
+ ilbmTEXTPOS *ppos;
+ int nbox;
+ BoxPtr pbox;
+ RegionPtr cclip;
+ int xpos; /* x position of char origin */
+ int i;
+ BoxRec clip;
+ int leftEdge, rightEdge;
+ int topEdge, bottomEdge;
+ int glyphRow; /* first row of glyph not wholly
+ clipped out */
+ int glyphCol; /* leftmost visible column of glyph */
+ int getWidth; /* bits to get from glyph */
+
+ if (!(ppos = (ilbmTEXTPOS *)ALLOCATE_LOCAL(nglyph *
+ sizeof(ilbmTEXTPOS))))
+ return;
+
+ pdstBase = ilbmScanlineNoBankSwitch(pdstBase, x, y, auxDst);
+ xpos = x;
+ xchar = xpos & PIM;
+
+ for (i = 0; i < nglyph; i++) {
+ pci = ppci[i];
+
+ ppos[i].xpos = xpos;
+ ppos[i].xchar = xchar;
+ ppos[i].leftEdge = xpos + pci->metrics.leftSideBearing;
+ ppos[i].rightEdge = xpos + pci->metrics.rightSideBearing;
+ ppos[i].topEdge = y - pci->metrics.ascent;
+ ppos[i].bottomEdge = y + pci->metrics.descent;
+ ppos[i].pdstBase = pdstBase;
+ ppos[i].widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
+
+ xpos += pci->metrics.characterWidth;
+ xchar += pci->metrics.characterWidth;
+ if (xchar > PLST) {
+ xchar &= PIM;
+ pdstBase++;
+ } else if (xchar < 0) {
+ xchar += PPW;
+ pdstBase--;
+ }
+ }
+
+ cclip = pGC->pCompositeClip;
+ pbox = REGION_RECTS(cclip);
+ nbox = REGION_NUM_RECTS(cclip);
+
+ /* HACK ALERT
+ since we continue out of the loop below so often, it
+ is easier to increment pbox at the top than at the end.
+ don't try this at home.
+ */
+ pbox--;
+ while (nbox--) {
+ pbox++;
+ clip.x1 = max(bbox.x1, pbox->x1);
+ clip.y1 = max(bbox.y1, pbox->y1);
+ clip.x2 = min(bbox.x2, pbox->x2);
+ clip.y2 = min(bbox.y2, pbox->y2);
+ if ((clip.x2<=clip.x1) || (clip.y2<=clip.y1))
+ continue;
+
+ for (i = 0; i<nglyph; i++) {
+ pci = ppci[i];
+ xchar = ppos[i].xchar;
+
+ /* clip the left and right edges */
+ if (ppos[i].leftEdge < clip.x1)
+ leftEdge = clip.x1;
+ else
+ leftEdge = ppos[i].leftEdge;
+
+ if (ppos[i].rightEdge > clip.x2)
+ rightEdge = clip.x2;
+ else
+ rightEdge = ppos[i].rightEdge;
+
+ w = rightEdge - leftEdge;
+ if (w <= 0)
+ continue;
+
+ /* clip the top and bottom edges */
+ if (ppos[i].topEdge < clip.y1)
+ topEdge = clip.y1;
+ else
+ topEdge = ppos[i].topEdge;
+
+ if (ppos[i].bottomEdge > clip.y2)
+ bottomEdge = clip.y2;
+ else
+ bottomEdge = ppos[i].bottomEdge;
+
+ hSave = bottomEdge - topEdge;
+ if (hSave <= 0)
+ continue;
+
+ glyphRow = (topEdge - y) + pci->metrics.ascent;
+ widthGlyph = ppos[i].widthGlyph;
+ pglyphSave = FONTGLYPHBITS(pglyphBase, pci);
+ pglyphSave += (glyphRow * widthGlyph);
+
+ glyphCol = (leftEdge - ppos[i].xpos) -
+ (pci->metrics.leftSideBearing);
+ getWidth = w + glyphCol;
+
+ pdstSave = ilbmScanlineDelta(ppos[i].pdstBase, -(y-topEdge),
+ auxDst);
+ xoff = xchar + (leftEdge - ppos[i].xpos);
+ if (xoff > PLST) {
+ xoff &= PIM;
+ pdstSave++;
+ } else if (xoff < 0) {
+ xoff += PPW;
+ pdstSave--;
+ }
+
+ for (d = 0; d < depthDst; d++) {
+ h = hSave;
+ pdst = pdstSave;
+ pdstSave += widthDst; /* @@@ NEXT PLANE @@@ */
+ pglyph = pglyphSave;
+
+ if ((xoff + w) <= PPW) {
+ maskpartialbits(xoff, w, startmask);
+ switch (rrops[d]) {
+ case RROP_WHITE:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst |= (SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ case RROP_BLACK:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst ^= (SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ }
+ } else {
+ maskPPWbits(xoff, w, startmask, endmask);
+ nFirst = PPW - xoff;
+ switch (rrops[d]) {
+ case RROP_WHITE:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst |= (SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) |= (SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ case RROP_BLACK:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) &= ~(SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst ^= (SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) ^= (SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ ilbmScanlineInc(pdst, auxDst);
+ }
+ break;
+ }
+ }
+ } /* depth */
+ } /* for each glyph */
+ } /* while nbox-- */
+ DEALLOCATE_LOCAL(ppos);
+ break;
+ }
+
+ default:
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmpntarea.c b/nx-X11/programs/Xserver/ilbm/ilbmpntarea.c
new file mode 100644
index 000000000..f61f7fcf9
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmpntarea.c
@@ -0,0 +1,656 @@
+/* $XFree86$ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmpntarea.c,v 5.7 94/04/17 20:28:29 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "windowstr.h"
+#include "regionstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "ilbm.h"
+#include "maskbits.h"
+
+/*
+ the solid fillers are called for rectangles and window backgrounds.
+ the boxes are already translated.
+ maybe this should always take a pixmap instead of a drawable?
+
+ NOTE:
+ iy = ++iy < tileHeight ? iy : 0
+is equivalent to iy%= tileheight, and saves a division.
+*/
+
+/*ARGSUSED*/
+void
+ilbmSolidFillArea(pDraw, nbox, pbox, rrops)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ register unsigned char *rrops;
+{
+ int nlwidth; /* width in longwords of the drawable */
+ int w; /* width of current box */
+ register int h; /* height of current box */
+ register PixelType *p; /* pointer to bits we're writing */
+ register int nlw; /* loop version of nlwMiddle */
+ register PixelType startmask;
+ register PixelType endmask;
+ /* masks for reggedy bits at either end of line */
+ register int nlwExtra; /* to get from right of box to left of next span */
+ int nlwMiddle; /* number of longwords between sides of boxes */
+ PixelType *pbits; /* pointer to start of drawable */
+ PixelType *saveP;
+ int saveH;
+ int depthDst;
+ int auxDst;
+ register int d;
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst, pbits);
+
+ while (nbox--) {
+ w = pbox->x2 - pbox->x1;
+ saveH = pbox->y2 - pbox->y1;
+
+ saveP = ilbmScanline(pbits, pbox->x1, pbox->y1, auxDst);
+
+ if ( ((pbox->x1 & PIM) + w) < PPW) {
+ for (d = 0; d < depthDst; d++) {
+ h = saveH;
+ p = saveP;
+ saveP += nlwidth; /* @@@ NEXT PLANE @@@ */
+ maskpartialbits(pbox->x1, w, startmask);
+ nlwExtra = auxDst;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ Duff(h, *p &= ~startmask; ilbmScanlineInc(p, nlwExtra));
+ break;
+ case RROP_WHITE:
+ Duff(h, *p |= startmask; ilbmScanlineInc(p, nlwExtra));
+ break;
+ case RROP_INVERT:
+ Duff(h, *p ^= startmask; ilbmScanlineInc(p, nlwExtra));
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ..) */
+ } else {
+ maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
+
+ for (d = 0; d < depthDst; d++) {
+ h = saveH;
+ p = saveP;
+ saveP += nlwidth; /* @@@ NEXT PLANE @@@ */
+ nlwExtra = auxDst - nlwMiddle;
+
+ if (startmask && endmask) {
+ nlwExtra -= 1;
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ nlw = nlwMiddle;
+ *p &= ~startmask;
+ p++;
+ Duff(nlw, *p++ = 0);
+ *p &= ~endmask;
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ nlw = nlwMiddle;
+ *p |= startmask;
+ p++;
+ Duff(nlw, *p++ = ~0);
+ *p |= endmask;
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ nlw = nlwMiddle;
+ *p ^= startmask;
+ p++;
+ Duff(nlw, *p++ ^= ~0);
+ *p ^= endmask;
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ }
+ } else if (startmask && !endmask) {
+ nlwExtra -= 1;
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ nlw = nlwMiddle;
+ *p &= ~startmask;
+ p++;
+ Duff(nlw, *p++ = 0);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ nlw = nlwMiddle;
+ *p |= startmask;
+ p++;
+ Duff(nlw, *p++ = ~0);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ nlw = nlwMiddle;
+ *p ^= startmask;
+ p++;
+ Duff(nlw, *p++ ^= ~0);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ }
+ } else if (!startmask && endmask) {
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ = 0);
+ *p &= ~endmask;
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ = ~0);
+ *p |= endmask;
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ ^= ~0);
+ *p ^= endmask;
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ case RROP_NOP:
+ break;
+ }
+ } else { /* no ragged bits at either end */
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ = 0);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ = ~0);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ ^= ~0);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ }
+ } /* for (d = 0 ... ) */
+ }
+ pbox++;
+ }
+}
+
+/* stipple a list of boxes -
+
+you can use the reduced rasterop for stipples. if rrop is
+black, AND the destination with (not stipple pattern). if rrop is
+white OR the destination with the stipple pattern. if rrop is invert,
+XOR the destination with the stipple pattern.
+*/
+
+/*ARGSUSED*/
+void
+ilbmStippleAreaPPW(pDraw, nbox, pbox, pstipple, rrops)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ PixmapPtr pstipple;
+ unsigned char *rrops;
+{
+ register PixelType *psrc; /* pointer to bits in tile, if needed */
+ int tileHeight; /* height of the tile */
+ register PixelType srcpix;
+
+ int nlwidth; /* width in longwords of the drawable */
+ int w; /* width of current box */
+ register int nlw; /* loop version of nlwMiddle */
+ register PixelType *p; /* pointer to bits we're writing */
+ register int h; /* height of current box */
+ PixelType startmask;
+ PixelType endmask; /* masks for reggedy bits at either end of line */
+ int nlwMiddle; /* number of longwords between sides of boxes */
+ int nlwExtra; /* to get from right of box to left of next span */
+ int auxDst;
+ int depthDst;
+ int d;
+ int saveIy;
+ register int iy; /* index of current scanline in tile */
+ PixelType *pbits; /* pointer to start of drawable */
+ PixelType *pBase;
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst, pBase);
+
+ tileHeight = pstipple->drawable.height;
+ psrc = (PixelType *)(pstipple->devPrivate.ptr);
+
+ while (nbox--) {
+ w = pbox->x2 - pbox->x1;
+ saveIy = pbox->y1 % tileHeight;
+ pbits = pBase;
+
+ if ( ((pbox->x1 & PIM) + w) < PPW) {
+ maskpartialbits(pbox->x1, w, startmask);
+ nlwExtra = auxDst;
+ for (d = 0; d < depthDst; d++) {
+ p = ilbmScanline(pbits, pbox->x1, pbox->y1, auxDst);
+ pbits += nlwidth; /* @@@ NEXT PLANE @@@ */
+ iy = saveIy;
+ h = pbox->y2 - pbox->y1;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ *p &= ~(srcpix & startmask);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ *p |= (srcpix & startmask);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ *p ^= (srcpix & startmask);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ...) */
+
+ } else {
+ maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
+
+ for (d = 0; d < depthDst; d++) {
+ nlwExtra = auxDst - nlwMiddle;
+ p = ilbmScanline(pbits, pbox->x1, pbox->y1, auxDst);
+ pbits += nlwidth; /* @@@ NEXT PLANE @@@ */
+ iy = saveIy;
+ h = pbox->y2 - pbox->y1;
+
+ if (startmask && endmask) {
+ nlwExtra -= 1;
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ *p &= ~(srcpix & startmask);
+ p++;
+ Duff (nlw, *p++ &= ~srcpix);
+ *p &= ~(srcpix & endmask);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ *p |= (srcpix & startmask);
+ p++;
+ Duff (nlw, *p++ |= srcpix);
+ *p |= (srcpix & endmask);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ *p ^= (srcpix & startmask);
+ p++;
+ Duff (nlw, *p++ ^= srcpix);
+ *p ^= (srcpix & endmask);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } else if (startmask && !endmask) {
+ nlwExtra -= 1;
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ *p &= ~(srcpix & startmask);
+ p++;
+ Duff(nlw, *p++ &= ~srcpix);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ *p |= (srcpix & startmask);
+ p++;
+ Duff(nlw, *p++ |= srcpix);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ *p ^= (srcpix & startmask);
+ p++;
+ Duff(nlw, *p++ ^= srcpix);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } else if (!startmask && endmask) {
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ &= ~srcpix);
+ *p &= ~(srcpix & endmask);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ |= srcpix);
+ *p |= (srcpix & endmask);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ ^= srcpix);
+ *p ^= (srcpix & endmask);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } else { /* no ragged bits at either end */
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ &= ~srcpix);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_WHITE:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ |= srcpix);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ case RROP_INVERT:
+ while (h--) {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ ^= srcpix);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ break;
+ } /* switch */
+ }
+ } /* for (d = ...) */
+ }
+ pbox++;
+ }
+}
+
+void
+ilbmStippleArea(pDraw, nbox, pbox, pTile, xOff, yOff, rrops)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ PixmapPtr pTile;
+ int xOff;
+ int yOff;
+ unsigned char *rrops;
+{
+ register PixelType *psrc; /* pointer to bits in tile, if needed */
+ int nlwidth; /* width in longwords of the drawable */
+ register int h; /* height of current box */
+ register PixelType *pdst; /* pointer to bits we're writing */
+ int auxDst;
+ int depthDst;
+ int sizeTile;
+ int tileLine;
+ int iline;
+ int w, width, x, xSrc, ySrc, srcStartOver, nend;
+ int tlwidth, rem, tileWidth, tileHeight, endinc;
+ int saveW;
+ register int rop;
+ PixelType *psrcT;
+ int d;
+ int nstart;
+ PixelType startmask;
+ PixelType endmask; /* masks for reggedy bits at either end of line */
+ int nlMiddle; /* number of longwords between sides of boxes */
+ int iy;
+ PixelType *pBase; /* pointer to start of drawable */
+ PixelType *saveP;
+ PixelType *pStartDst;
+ PixelType *pStartTile;
+ int saveH;
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst, pBase);
+
+ tileHeight = pTile->drawable.height;
+ tileWidth = pTile->drawable.width;
+ tlwidth = pTile->devKind/sizeof(PixelType);
+
+ xSrc = pDraw->x + ((xOff % tileWidth) - tileWidth);
+ ySrc = pDraw->y + ((yOff % tileHeight) - tileHeight);
+
+ while (nbox--) {
+ saveW = pbox->x2 - pbox->x1;
+ iline = (pbox->y1 - ySrc) % tileHeight;
+ psrcT = (PixelType *)pTile->devPrivate.ptr;
+ tileLine = iline * tlwidth;
+ saveH = pbox->y2 - pbox->y1;
+ saveP = ilbmScanline(pBase, pbox->x1, pbox->y1, auxDst);
+
+ for (d = 0; d < depthDst; d++, saveP += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ h = saveH;
+ pStartDst = saveP;
+ pStartTile = psrcT + tileLine;
+ iy = iline;
+
+ while (h--) {
+ x = pbox->x1;
+ width = saveW;
+ pdst = pStartDst;
+ rop = rrops[d];
+
+ while (width > 0) {
+ psrc = pStartTile;
+ w = min(tileWidth, width);
+ if ((rem = (x - xSrc) % tileWidth) != 0) {
+ /* if we're in the middle of the tile, get
+ as many bits as will finish the span, or
+ as many as will get to the left edge of the tile,
+ or a longword worth, starting at the appropriate
+ offset in the tile.
+ */
+ w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
+ endinc = rem / BITMAP_SCANLINE_PAD;
+ getandputrrop((psrc + endinc), (rem & PIM), (x & PIM), w,
+ pdst, rop)
+ if ((x & PIM) + w >= PPW)
+ pdst++;
+ } else if (((x & PIM) + w) < PPW) {
+ /* doing < PPW bits is easy, and worth special-casing */
+ putbitsrrop(*psrc, x & PIM, w, pdst, rop);
+ } else {
+ /* start at the left edge of the tile,
+ and put down as much as we can
+ */
+ maskbits(x, w, startmask, endmask, nlMiddle);
+
+ if (startmask)
+ nstart = PPW - (x & PIM);
+ else
+ nstart = 0;
+ if (endmask)
+ nend = (x + w) & PIM;
+ else
+ nend = 0;
+
+ srcStartOver = nstart > PLST;
+
+ if (startmask) {
+ putbitsrrop(*psrc, (x & PIM), nstart, pdst, rop);
+ pdst++;
+ if (srcStartOver)
+ psrc++;
+ }
+
+ while (nlMiddle--) {
+ getandputrrop0(psrc, nstart, PPW, pdst, rop);
+ pdst++;
+ psrc++;
+ }
+
+ if (endmask) {
+ getandputrrop0(psrc, nstart, nend, pdst, rop);
+ }
+ }
+ x += w;
+ width -= w;
+ } /* while (width > 0) */
+
+ pStartDst += auxDst;
+ if (++iy >= tileHeight) {
+ iy = 0;
+ pStartTile = psrcT;
+ } else
+ pStartTile += tlwidth;
+
+ } /* while (h) */
+ } /* for (d = ... ) */
+ pbox++;
+ } /* for each box */
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmpntwin.c b/nx-X11/programs/Xserver/ilbm/ilbmpntwin.c
new file mode 100644
index 000000000..b12a121c8
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmpntwin.c
@@ -0,0 +1,131 @@
+/* $XFree86$ */
+/* $XConsortium: ilbmpntwin.c,v 5.12 94/04/17 20:28:30 dpw Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "windowstr.h"
+#include "regionstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "ilbm.h"
+#include "maskbits.h"
+#include "mi.h"
+
+void
+ilbmPaintWindow(pWin, pRegion, what)
+ WindowPtr pWin;
+ RegionPtr pRegion;
+ int what;
+{
+ register ilbmPrivWin *pPrivWin;
+ unsigned char rrops[AFB_MAX_DEPTH];
+
+ pPrivWin = (ilbmPrivWin *)(pWin->devPrivates[ilbmWindowPrivateIndex].ptr);
+
+ switch (what) {
+ case PW_BACKGROUND:
+ switch (pWin->backgroundState) {
+ case None:
+ return;
+ case ParentRelative:
+ do {
+ pWin = pWin->parent;
+ } while (pWin->backgroundState == ParentRelative);
+ (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
+ what);
+ return;
+ case BackgroundPixmap:
+ if (pPrivWin->fastBackground) {
+ ilbmTileAreaPPWCopy((DrawablePtr)pWin,
+ REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion), GXcopy,
+ pPrivWin->pRotatedBackground, ~0);
+ return;
+ } else {
+ ilbmTileAreaCopy((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion), GXcopy,
+ pWin->background.pixmap, 0, 0, ~0);
+ return;
+ }
+ break;
+ case BackgroundPixel:
+ ilbmReduceRop(GXcopy, pWin->background.pixel, ~0,
+ pWin->drawable.depth, rrops);
+ ilbmSolidFillArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion), rrops);
+ return;
+ }
+ break;
+ case PW_BORDER:
+ if (pWin->borderIsPixel) {
+ ilbmReduceRop(GXcopy, pWin->border.pixel, ~0, pWin->drawable.depth,
+ rrops);
+ ilbmSolidFillArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion), rrops);
+ return;
+ } else if (pPrivWin->fastBorder) {
+ ilbmTileAreaPPWCopy((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion), GXcopy,
+ pPrivWin->pRotatedBorder, ~0);
+ return;
+ }
+ break;
+ }
+ miPaintWindow(pWin, pRegion, what);
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmpolypnt.c b/nx-X11/programs/Xserver/ilbm/ilbmpolypnt.c
new file mode 100644
index 000000000..87666d7b6
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmpolypnt.c
@@ -0,0 +1,152 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmpolypnt.c,v 3.0 1996/08/18 01:54:07 dawes Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmpolypnt.c,v 5.6 94/04/17 20:28:30 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "pixmapstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "miscstruct.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+
+#include "ilbm.h"
+#include "maskbits.h"
+
+void
+ilbmPolyPoint(pDrawable, pGC, mode, npt, pptInit)
+ register DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt;
+ xPoint *pptInit;
+{
+
+ register BoxPtr pbox;
+ register int nbox;
+ register int d;
+
+ register PixelType *addrl;
+ PixelType *pBase;
+ PixelType *pBaseSave;
+ int nlwidth;
+ int auxDst;
+ int depthDst;
+
+ int nptTmp;
+ register xPoint *ppt;
+
+ register int x;
+ register int y;
+ register unsigned char *rrops;
+ ilbmPrivGC *pGCPriv;
+
+ pGCPriv = (ilbmPrivGC *) pGC->devPrivates[ilbmGCPrivateIndex].ptr;
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, nlwidth, auxDst, depthDst,
+ pBaseSave);
+
+ rrops = pGCPriv->rrops;
+ if ((mode == CoordModePrevious) && (npt > 1))
+ for (ppt = pptInit + 1, nptTmp = npt - 1; --nptTmp >= 0; ppt++) {
+ ppt->x += (ppt-1)->x;
+ ppt->y += (ppt-1)->y;
+ }
+
+ nbox = REGION_NUM_RECTS(pGC->pCompositeClip);
+ pbox = REGION_RECTS(pGC->pCompositeClip);
+ for (; --nbox >= 0; pbox++)
+ for (d = 0, pBase = pBaseSave; d < depthDst; d++, pBase += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ addrl = pBase;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ for (ppt = pptInit, nptTmp = npt; --nptTmp >= 0; ppt++) {
+ x = ppt->x + pDrawable->x;
+ y = ppt->y + pDrawable->y;
+ if ((x >= pbox->x1) && (x < pbox->x2) &&
+ (y >= pbox->y1) && (y < pbox->y2))
+ *ilbmScanline(addrl, x, y, auxDst) &= rmask[x & PIM];
+ }
+ break;
+
+ case RROP_WHITE:
+ for (ppt = pptInit, nptTmp = npt; --nptTmp >= 0; ppt++) {
+ x = ppt->x + pDrawable->x;
+ y = ppt->y + pDrawable->y;
+ if ((x >= pbox->x1) && (x < pbox->x2) &&
+ (y >= pbox->y1) && (y < pbox->y2))
+ *ilbmScanline(addrl, x, y, auxDst) |= mask[x & PIM];
+ }
+ break;
+
+ case RROP_INVERT:
+ for (ppt = pptInit, nptTmp = npt; --nptTmp >= 0; ppt++) {
+ x = ppt->x + pDrawable->x;
+ y = ppt->y + pDrawable->y;
+ if ((x >= pbox->x1) && (x < pbox->x2) &&
+ (y >= pbox->y1) && (y < pbox->y2))
+ *ilbmScanline(addrl, x, y, auxDst) ^= mask[x & PIM];
+ }
+ break;
+
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ...) */
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmpushpxl.c b/nx-X11/programs/Xserver/ilbm/ilbmpushpxl.c
new file mode 100644
index 000000000..337172703
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmpushpxl.c
@@ -0,0 +1,263 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmpushpxl.c,v 3.0 1996/08/18 01:54:08 dawes Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmpushpxl.c,v 5.6 94/04/17 20:28:31 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "miscstruct.h"
+#include "maskbits.h"
+#include "regionstr.h"
+#include "ilbm.h"
+
+/* ilbmSolidPP is courtesy of xhacks@csri.toronto.edu
+
+ For fillStyle==FillSolid, a monochrome PushPixels can be reduced to
+ a ROP in the following way: (Note that the ROP is the same as the
+ result of ROP(src=0x3,dst=0x5))
+
+ src=0011 0000 0011
+ dst=0101 0101 0101
+ rop fg=0 fg=1
+ GXclear 0x0 0000 0100 0100 0
+ GXand 0x1 0001 0100 0101 s&d
+ GXandReverse 0x2 0010 0100 0110 s&~d
+ GXcopy 0x3 0011 0100 0111 s
+ GXandInverted 0x4 0100 0101 0100 ~s&d
+ GXnoop 0x5 0101 0101 0101 d
+ GXxor 0x6 0110 0101 0110 s^d
+ GXor 0x7 0111 0101 0111 s|d
+ GXnor 0x8 1000 0110 0100 ~s&~d
+ GXequiv 0x9 1001 0110 0101 ~s^d
+ GXinvert 0xa 1010 0110 0110 ~d
+ GXorReverse 0xb 1011 0110 0111 s|~d
+ GXcopyInverted 0xc 1100 0111 0100 ~s
+ GXorInverted 0xd 1101 0111 0101 ~s|d
+ GXnand 0xe 1110 0111 0110 ~s|~d
+ GXset 0xf 1111 0111 0111 1
+
+For src=0: newRop = 0x4|(rop>>2)
+For src=1: newRop = 0x4|(rop&3)
+*/
+
+/* ilbmSolidPP -- squeegees the forground color of pGC through pBitMap
+ * into pDrawable. pBitMap is a stencil (dx by dy of it is used, it may
+ * be bigger) which is placed on the drawable at xOrg, yOrg. Where a 1 bit
+ * is set in the bitmap, the fill style is put onto the drawable using
+ * the GC's logical function. The drawable is not changed where the bitmap
+ * has a zero bit or outside the area covered by the stencil.
+ */
+void
+ilbmSolidPP(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
+ GCPtr pGC;
+ PixmapPtr pBitMap;
+ DrawablePtr pDrawable;
+ int dx, dy, xOrg, yOrg;
+{
+ unsigned char alu;
+ RegionRec rgnDst;
+ DDXPointPtr pptSrc;
+ BoxRec srcBox;
+ register DDXPointPtr ppt;
+ register BoxPtr pbox;
+ int i;
+
+ if (!pGC->planemask & 1) return;
+
+ /* compute the reduced rop function */
+ alu = pGC->alu;
+ if (!(pGC->fgPixel&1)) alu >>= 2;
+ alu = (alu & 0x3) | 0x4;
+ if (alu == GXnoop) return;
+
+ srcBox.x1 = xOrg;
+ srcBox.y1 = yOrg;
+ srcBox.x2 = xOrg + dx;
+ srcBox.y2 = yOrg + dy;
+ REGION_INIT(pGC->pScreen, &rgnDst, &srcBox, 1);
+
+ /* clip the shape of the dst to the destination composite clip */
+ REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, pGC->pCompositeClip);
+
+ if (!REGION_NIL(&rgnDst)) {
+ i = REGION_NUM_RECTS(&rgnDst);
+ pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec));
+ if (pptSrc) {
+ for (pbox = REGION_RECTS(&rgnDst), ppt = pptSrc; --i >= 0;
+ pbox++, ppt++) {
+ ppt->x = pbox->x1 - xOrg;
+ ppt->y = pbox->y1 - yOrg;
+ }
+ ilbmDoBitblt((DrawablePtr)pBitMap, pDrawable, alu, &rgnDst, pptSrc,
+ pGC->planemask);
+ DEALLOCATE_LOCAL(pptSrc);
+ }
+ }
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+}
+
+#define NPT 128
+
+/* ilbmPushPixels -- squeegees the forground color of pGC through pBitMap
+ * into pDrawable. pBitMap is a stencil (dx by dy of it is used, it may
+ * be bigger) which is placed on the drawable at xOrg, yOrg. Where a 1 bit
+ * is set in the bitmap, the fill style is put onto the drawable using
+ * the GC's logical function. The drawable is not changed where the bitmap
+ * has a zero bit or outside the area covered by the stencil.
+ */
+void
+ilbmPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
+ GCPtr pGC;
+ PixmapPtr pBitMap;
+ DrawablePtr pDrawable;
+ int dx, dy, xOrg, yOrg;
+{
+ int h, dxDivPPW, ibEnd;
+ PixelType *pwLineStart;
+ register PixelType *pw, *pwEnd;
+ register PixelType mask;
+ register int ib;
+ register PixelType w;
+ register int ipt; /* index into above arrays */
+ Bool fInBox;
+ DDXPointRec pt[NPT];
+ int width[NPT];
+
+ /* Now scan convert the pixmap and use the result to call fillspans in
+ * in the drawable with the original GC */
+ ipt = 0;
+ dxDivPPW = dx/PPW;
+ for (h = 0; h < dy; h++) {
+
+ pw = (PixelType *)
+ (((char *)(pBitMap->devPrivate.ptr))+(h * pBitMap->devKind));
+ pwLineStart = pw;
+ /* Process all words which are fully in the pixmap */
+
+ fInBox = FALSE;
+ pwEnd = pwLineStart + dxDivPPW;
+ while (pw < pwEnd) {
+ w = *pw;
+ mask = endtab[1];
+ for (ib = 0; ib < PPW; ib++) {
+ if (w & mask) {
+ if (!fInBox) {
+ pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
+ pt[ipt].y = h + yOrg;
+ /* start new box */
+ fInBox = TRUE;
+ }
+ } else {
+ if (fInBox) {
+ width[ipt] = ((pw - pwLineStart) << PWSH) +
+ ib + xOrg - pt[ipt].x;
+ if (++ipt >= NPT) {
+ (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt,
+ width, TRUE);
+ ipt = 0;
+ }
+ /* end box */
+ fInBox = FALSE;
+ }
+ }
+ mask = SCRRIGHT(mask, 1);
+ }
+ pw++;
+ }
+ ibEnd = dx & PIM;
+ if (ibEnd) {
+ /* Process final partial word on line */
+ w = *pw;
+ mask = endtab[1];
+ for (ib = 0; ib < ibEnd; ib++) {
+ if (w & mask) {
+ if (!fInBox) {
+ /* start new box */
+ pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
+ pt[ipt].y = h + yOrg;
+ fInBox = TRUE;
+ }
+ } else {
+ if (fInBox) {
+ /* end box */
+ width[ipt] = ((pw - pwLineStart) << PWSH) +
+ ib + xOrg - pt[ipt].x;
+ if (++ipt >= NPT) {
+ (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt,
+ width, TRUE);
+ ipt = 0;
+ }
+ fInBox = FALSE;
+ }
+ }
+ mask = SCRRIGHT(mask, 1);
+ }
+ }
+ /* If scanline ended with last bit set, end the box */
+ if (fInBox) {
+ width[ipt] = dx + xOrg - pt[ipt].x;
+ if (++ipt >= NPT) {
+ (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt, width, TRUE);
+ ipt = 0;
+ }
+ }
+ }
+ /* Flush any remaining spans */
+ if (ipt) {
+ (*pGC->ops->FillSpans)(pDrawable, pGC, ipt, pt, width, TRUE);
+ }
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmscrinit.c b/nx-X11/programs/Xserver/ilbm/ilbmscrinit.c
new file mode 100644
index 000000000..37425d0d6
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmscrinit.c
@@ -0,0 +1,251 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmscrinit.c,v 3.4 1998/07/26 01:53:45 dawes Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmscrinit.c,v 5.17 94/04/17 20:28:34 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h> /* for xColorItem */
+#include <X11/Xmd.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "resource.h"
+#include "colormap.h"
+#include "ilbm.h"
+#include "mistruct.h"
+#include "dix.h"
+#include "mi.h"
+#include "mibstore.h"
+#include "migc.h"
+#include "servermd.h"
+
+#ifdef PIXMAP_PER_WINDOW
+int frameWindowPrivateIndex;
+#endif
+int ilbmWindowPrivateIndex;
+int ilbmGCPrivateIndex;
+int ilbmScreenPrivateIndex;
+
+static unsigned long ilbmGeneration = 0;
+
+BSFuncRec ilbmBSFuncRec = {
+ ilbmSaveAreas,
+ ilbmRestoreAreas,
+ (BackingStoreSetClipmaskRgnProcPtr) 0,
+ (BackingStoreGetImagePixmapProcPtr) 0,
+ (BackingStoreGetSpansPixmapProcPtr) 0,
+};
+
+Bool
+ilbmCloseScreen(index, pScreen)
+ int index;
+ ScreenPtr pScreen;
+{
+ int d;
+ DepthPtr depths = pScreen->allowedDepths;
+
+ for (d = 0; d < pScreen->numDepths; d++)
+ xfree(depths[d].vids);
+ xfree(depths);
+ xfree(pScreen->visuals);
+ xfree(pScreen->devPrivates[ilbmScreenPrivateIndex].ptr);
+ return(TRUE);
+}
+
+Bool
+ilbmCreateScreenResources(pScreen)
+ ScreenPtr pScreen;
+{
+ Bool retval;
+
+ pointer oldDevPrivate = pScreen->devPrivate;
+
+ pScreen->devPrivate = pScreen->devPrivates[ilbmScreenPrivateIndex].ptr;
+ retval = miCreateScreenResources(pScreen);
+
+ /* Modify screen's pixmap devKind value stored off devPrivate to
+ * be the width of a single plane in longs rather than the width
+ * of a chunky screen in longs as incorrectly setup by the mi routine.
+ */
+ ((PixmapPtr)pScreen->devPrivate)->devKind = BitmapBytePad(pScreen->width);
+ pScreen->devPrivates[ilbmScreenPrivateIndex].ptr = pScreen->devPrivate;
+ pScreen->devPrivate = oldDevPrivate;
+ return(retval);
+}
+
+Bool
+ilbmAllocatePrivates(pScreen, pWinIndex, pGCIndex)
+ ScreenPtr pScreen;
+ int *pWinIndex, *pGCIndex;
+{
+ if (ilbmGeneration != serverGeneration) {
+#ifdef PIXMAP_PER_WINDOW
+ frameWindowPrivateIndex = AllocateWindowPrivateIndex();
+#endif
+ ilbmWindowPrivateIndex = AllocateWindowPrivateIndex();
+ ilbmGCPrivateIndex = AllocateGCPrivateIndex();
+ ilbmGeneration = serverGeneration;
+ }
+ if (pWinIndex)
+ *pWinIndex = ilbmWindowPrivateIndex;
+ if (pGCIndex)
+ *pGCIndex = ilbmGCPrivateIndex;
+
+ ilbmScreenPrivateIndex = AllocateScreenPrivateIndex();
+ pScreen->GetWindowPixmap = ilbmGetWindowPixmap;
+ pScreen->SetWindowPixmap = ilbmSetWindowPixmap;
+ return(AllocateWindowPrivate(pScreen, ilbmWindowPrivateIndex, sizeof(ilbmPrivWin)) &&
+ AllocateGCPrivate(pScreen, ilbmGCPrivateIndex, sizeof(ilbmPrivGC)));
+}
+
+/* dts * (inch/dot) * (25.4 mm / inch) = mm */
+Bool
+ilbmScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+{
+ VisualPtr visuals;
+ DepthPtr depths;
+ int nvisuals;
+ int ndepths;
+ int rootdepth;
+ VisualID defaultVisual;
+ pointer oldDevPrivate;
+
+ rootdepth = 0;
+ if (!ilbmInitVisuals(&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
+ &defaultVisual, 256, 8)) {
+ ErrorF("ilbmInitVisuals: FALSE\n");
+ return FALSE;
+ }
+ if (!ilbmAllocatePrivates(pScreen,(int *)NULL, (int *)NULL)) {
+ ErrorF("ilbmAllocatePrivates: FALSE\n");
+ return FALSE;
+ }
+
+ pScreen->defColormap = (Colormap)FakeClientID(0);
+ /* whitePixel, blackPixel */
+ pScreen->blackPixel = 0;
+ pScreen->whitePixel = 0;
+ pScreen->QueryBestSize = ilbmQueryBestSize;
+ /* SaveScreen */
+ pScreen->GetImage = ilbmGetImage;
+ pScreen->GetSpans = ilbmGetSpans;
+ pScreen->CreateWindow = ilbmCreateWindow;
+ pScreen->DestroyWindow = ilbmDestroyWindow;
+ pScreen->PositionWindow = ilbmPositionWindow;
+ pScreen->ChangeWindowAttributes = ilbmChangeWindowAttributes;
+ pScreen->RealizeWindow = ilbmMapWindow;
+ pScreen->UnrealizeWindow = ilbmUnmapWindow;
+ pScreen->PaintWindowBackground = ilbmPaintWindow;
+ pScreen->PaintWindowBorder = ilbmPaintWindow;
+ pScreen->CopyWindow = ilbmCopyWindow;
+ pScreen->CreatePixmap = ilbmCreatePixmap;
+ pScreen->DestroyPixmap = ilbmDestroyPixmap;
+ pScreen->RealizeFont = ilbmRealizeFont;
+ pScreen->UnrealizeFont = ilbmUnrealizeFont;
+ pScreen->CreateGC = ilbmCreateGC;
+ pScreen->CreateColormap = ilbmInitializeColormap;
+ pScreen->DestroyColormap = (void (*)())NoopDDA;
+ pScreen->InstallColormap = ilbmInstallColormap;
+ pScreen->UninstallColormap = ilbmUninstallColormap;
+ pScreen->ListInstalledColormaps = ilbmListInstalledColormaps;
+ pScreen->StoreColors = (void (*)())NoopDDA;
+ pScreen->ResolveColor = ilbmResolveColor;
+ pScreen->BitmapToRegion = ilbmPixmapToRegion;
+ oldDevPrivate = pScreen->devPrivate;
+ if (!miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, rootdepth,
+ ndepths, depths, defaultVisual, nvisuals, visuals)) {
+ ErrorF("miScreenInit: FALSE\n");
+ return FALSE;
+ }
+
+ pScreen->CloseScreen = ilbmCloseScreen;
+ pScreen->CreateScreenResources = ilbmCreateScreenResources;
+ pScreen->BackingStoreFuncs = ilbmBSFuncRec;
+
+ pScreen->devPrivates[ilbmScreenPrivateIndex].ptr = pScreen->devPrivate;
+ pScreen->devPrivate = oldDevPrivate;
+
+ return TRUE;
+}
+
+PixmapPtr
+ilbmGetWindowPixmap(pWin)
+ WindowPtr pWin;
+{
+#ifdef PIXMAP_PER_WINDOW
+ return (PixmapPtr)(pWin->devPrivates[frameWindowPrivateIndex].ptr);
+#else
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ return (* pScreen->GetScreenPixmap)(pScreen);
+#endif
+}
+
+void
+ilbmSetWindowPixmap(pWin, pPix)
+ WindowPtr pWin;
+ PixmapPtr pPix;
+{
+#ifdef PIXMAP_PER_WINDOW
+ pWin->devPrivates[frameWindowPrivateIndex].ptr = (pointer)pPix;
+#else
+ (* pWin->drawable.pScreen->SetScreenPixmap)(pPix);
+#endif
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmsetsp.c b/nx-X11/programs/Xserver/ilbm/ilbmsetsp.c
new file mode 100644
index 000000000..0e2df7028
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmsetsp.c
@@ -0,0 +1,269 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmsetsp.c,v 3.0 1996/08/18 01:54:10 dawes Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmsetsp.c,v 5.8 94/04/17 20:28:34 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "misc.h"
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "ilbm.h"
+#include "maskbits.h"
+
+#include "servermd.h"
+
+
+/* ilbmSetScanline -- copies the bits from psrc to the drawable starting at
+ * (xStart, y) and continuing to (xEnd, y). xOrigin tells us where psrc
+ * starts on the scanline. (I.e., if this scanline passes through multiple
+ * boxes, we may not want to start grabbing bits at psrc but at some offset
+ * further on.)
+ */
+ilbmSetScanline(y, xOrigin, xStart, xEnd, psrc, alu, pdstBase, widthDst, auxDst,
+ depthDst, widthSrc)
+ int y;
+ int xOrigin; /* where this scanline starts */
+ int xStart; /* first bit to use from scanline */
+ int xEnd; /* last bit to use from scanline + 1 */
+ register PixelType *psrc;
+ register int alu; /* raster op */
+ PixelType *pdstBase; /* start of the drawable */
+ int widthDst; /* width of drawable in words */
+ int auxDst;
+ int depthDst;
+ int widthSrc; /* width of drawable in words */
+{
+ int w; /* width of scanline in bits */
+ register PixelType *pdst; /* where to put the bits */
+ register PixelType tmpSrc; /* scratch buffer to collect bits in */
+ int dstBit; /* offset in bits from beginning of
+ * word */
+ register int nstart; /* number of bits from first partial */
+ register int nend; /* " " last partial word */
+ int offSrc;
+ PixelType startmask, endmask;
+ PixelType *savePsrc = psrc + ((xStart - xOrigin) >> PWSH);
+ int nlMiddle, nl;
+ int d;
+
+ for (d = 0; d < depthDst; d++) {
+ pdst = ilbmScanline(pdstBase, xStart, y, auxDst) + widthDst * d; /* @@@ NEXT PLANE @@@ */
+ psrc = savePsrc + widthSrc * d; /* @@@ NEXT PLANE @@@ */
+ offSrc = (xStart - xOrigin) & PIM;
+ w = xEnd - xStart;
+ dstBit = xStart & PIM;
+
+ if (dstBit + w <= PPW) {
+ getandputrop(psrc, offSrc, dstBit, w, pdst, alu)
+ } else {
+ maskbits(xStart, w, startmask, endmask, nlMiddle);
+ if (startmask)
+ nstart = PPW - dstBit;
+ else
+ nstart = 0;
+ if (endmask)
+ nend = xEnd & PIM;
+ else
+ nend = 0;
+ if (startmask) {
+ getandputrop(psrc, offSrc, dstBit, nstart, pdst, alu)
+ pdst++;
+ offSrc += nstart;
+ if (offSrc > PLST) {
+ psrc++;
+ offSrc -= PPW;
+ }
+ }
+ nl = nlMiddle;
+ while (nl--) {
+ getbits(psrc, offSrc, PPW, tmpSrc);
+ DoRop(*pdst, alu, tmpSrc, *pdst);
+ pdst++;
+ psrc++;
+ }
+ if (endmask) {
+ getandputrop0(psrc, offSrc, nend, pdst, alu);
+ }
+ }
+ }
+}
+
+/* SetSpans -- for each span copy pwidth[i] bits from psrc to pDrawable at
+ * ppt[i] using the raster op from the GC. If fSorted is TRUE, the scanlines
+ * are in increasing Y order.
+ * Source bit lines are server scanline padded so that they always begin
+ * on a word boundary.
+ */
+void
+ilbmSetSpans(pDrawable, pGC, pcharsrc, ppt, pwidth, nspans, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ char *pcharsrc;
+ register DDXPointPtr ppt;
+ int *pwidth;
+ int nspans;
+ int fSorted;
+{
+ PixelType *psrc = (PixelType *)pcharsrc;
+ PixelType *pdstBase; /* start of dst bitmap */
+ int widthDst; /* width of bitmap in words */
+ int auxDst;
+ int depthDst;
+ int widthSrc;
+ register BoxPtr pbox, pboxLast, pboxTest;
+ register DDXPointPtr pptLast;
+ int alu;
+ RegionPtr prgnDst;
+ int xStart, xEnd;
+ int yMax;
+
+ alu = pGC->alu;
+ prgnDst = pGC->pCompositeClip;
+
+ pptLast = ppt + nspans;
+
+ yMax = pDrawable->y + (int) pDrawable->height;
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, widthDst, auxDst, depthDst,
+ pdstBase);
+
+ pbox = REGION_RECTS(prgnDst);
+ pboxLast = pbox + REGION_NUM_RECTS(prgnDst);
+
+ if (fSorted) {
+ /* scan lines sorted in ascending order. Because they are sorted, we
+ * don't have to check each scanline against each clip box. We can be
+ * sure that this scanline only has to be clipped to boxes at or after the
+ * beginning of this y-band
+ */
+ pboxTest = pbox;
+ while (ppt < pptLast) {
+ pbox = pboxTest;
+ if (ppt->y >= yMax)
+ break;
+ while (pbox < pboxLast) {
+ if (pbox->y1 > ppt->y) {
+ /* scanline is before clip box */
+ break;
+ } else if (pbox->y2 <= ppt->y) {
+ /* clip box is before scanline */
+ pboxTest = ++pbox;
+ continue;
+ } else if (pbox->x1 > ppt->x + *pwidth) {
+ /* clip box is to right of scanline */
+ break;
+ } else if (pbox->x2 <= ppt->x) {
+ /* scanline is to right of clip box */
+ pbox++;
+ continue;
+ }
+
+ /* at least some of the scanline is in the current clip box */
+ xStart = max(pbox->x1, ppt->x);
+ xEnd = min(ppt->x + *pwidth, pbox->x2);
+ widthSrc = PixmapWidthInPadUnits(*pwidth, 1);
+ ilbmSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu, pdstBase,
+ widthDst, auxDst, depthDst, widthSrc);
+ if (ppt->x + *pwidth <= pbox->x2) {
+ /* End of the line, as it were */
+ break;
+ } else
+ pbox++;
+ }
+ /* We've tried this line against every box; it must be outside them
+ * all. move on to the next point */
+ ppt++;
+ psrc += widthSrc * depthDst;
+ pwidth++;
+ }
+ } else {
+ /* scan lines not sorted. We must clip each line against all the boxes */
+ while (ppt < pptLast) {
+ if (ppt->y >= 0 && ppt->y < yMax) {
+ for (pbox = REGION_RECTS(prgnDst); pbox< pboxLast; pbox++) {
+ if (pbox->y1 > ppt->y) {
+ /* rest of clip region is above this scanline,
+ * skip it */
+ break;
+ }
+ if (pbox->y2 <= ppt->y) {
+ /* clip box is below scanline */
+ pbox++;
+ break;
+ }
+ if (pbox->x1 <= ppt->x + *pwidth &&
+ pbox->x2 > ppt->x) {
+ xStart = max(pbox->x1, ppt->x);
+ xEnd = min(pbox->x2, ppt->x + *pwidth);
+ widthSrc = PixmapWidthInPadUnits(*pwidth, 1);
+ ilbmSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu,
+ pdstBase, widthDst, auxDst, depthDst,
+ widthSrc);
+ }
+
+ }
+ }
+ psrc += widthSrc * depthDst;
+ ppt++;
+ pwidth++;
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmtegblt.c b/nx-X11/programs/Xserver/ilbm/ilbmtegblt.c
new file mode 100644
index 000000000..c1c1eac49
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmtegblt.c
@@ -0,0 +1,599 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmtegblt.c,v 3.0 1996/08/18 01:54:11 dawes Exp $ */
+/* $XConsortium: ilbmtegblt.c,v 5.14 94/04/17 20:28:35 dpw Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "ilbm.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "maskbits.h"
+
+/*
+ this works for fonts with glyphs <= PPW bits wide.
+
+ This should be called only with a terminal-emulator font;
+this means that the FIXED_METRICS flag is set, and that
+glyphbounds == charbounds.
+
+ in theory, this goes faster; even if it doesn't, it reduces the
+flicker caused by writing a string over itself with image text (since
+the background gets repainted per character instead of per string.)
+this seems to be important for some converted X10 applications.
+
+ Image text looks at the bits in the glyph and the fg and bg in the
+GC. it paints a rectangle, as defined in the protocol dcoument,
+and the paints the characters.
+
+*/
+
+#if defined(NO_3_60_CG4) && defined(FASTPUTBITS) && defined(FASTGETBITS)
+#define FASTCHARS
+#endif
+
+/*
+ * this macro "knows" that only characters <= 8 bits wide will
+ * fit this case (which is why it is independent of GLYPHPADBYTES)
+ */
+
+#if (BITMAP_BIT_ORDER == MSBFirst) && (GLYPHPADBYTES != 4)
+#if GLYPHPADBYTES == 1
+#define ShiftAmnt 24
+#else
+#define ShiftAmnt 16
+#endif
+
+/*
+ * Note: for BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER, SCRRIGHT() evaluates its
+ * first argument more than once. Thus the imbedded char++ have to be moved.
+ * (DHD)
+ */
+#if BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER
+#if PPW == 32
+#define GetBits4 c = (*char1++ << ShiftAmnt) | \
+ SCRRIGHT (*char2++ << ShiftAmnt, xoff2) | \
+ SCRRIGHT (*char3++ << ShiftAmnt, xoff3) | \
+ SCRRIGHT (*char4++ << ShiftAmnt, xoff4);
+#else /* PPW */
+#define GetBits4 c = ((unsigned long)(*char1++ << ShiftAmnt) << 32 ) | \
+ (SCRRIGHT (*char2++ << ShiftAmnt, xoff2) << 32 ) | \
+ (SCRRIGHT (*char3++ << ShiftAmnt, xoff3) << 32 ) | \
+ (SCRRIGHT (*char4++ << ShiftAmnt, xoff4) << 32 ) | \
+ (*char5++ << ShiftAmnt) | \
+ SCRRIGHT (*char6++ << ShiftAmnt, xoff6) | \
+ SCRRIGHT (*char7++ << ShiftAmnt, xoff7) | \
+ SCRRIGHT (*char8++ << ShiftAmnt, xoff8);
+#endif /* PPW */
+#else /* BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER */
+#if PPW == 32
+#define GetBits4 c = (*char1++ << ShiftAmnt) | \
+ SCRRIGHT (*char2 << ShiftAmnt, xoff2) | \
+ SCRRIGHT (*char3 << ShiftAmnt, xoff3) | \
+ SCRRIGHT (*char4 << ShiftAmnt, xoff4); \
+ char2++; char3++; char4++;
+#else /* PPW == 64 */
+#define GetBits4 c = ((unsigned long)(*char1++ << ShiftAmnt) << 32 ) | \
+ (SCRRIGHT (*char2 << ShiftAmnt, xoff2) << 32 ) | \
+ (SCRRIGHT (*char3 << ShiftAmnt, xoff3) << 32 ) | \
+ (SCRRIGHT (*char4 << ShiftAmnt, xoff4) << 32 ) | \
+ (*char5++ << ShiftAmnt) | \
+ SCRRIGHT (*char6 << ShiftAmnt, xoff6) | \
+ SCRRIGHT (*char7 << ShiftAmnt, xoff7) | \
+ SCRRIGHT (*char8 << ShiftAmnt, xoff8); \
+ char2++; char3++; char4++; char6++; char7++; char8++;
+#endif /* PPW */
+#endif /* BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER */
+
+#else /* (BITMAP_BIT_ORDER != MSBFirst) || (GLYPHPADBYTES == 4) */
+
+#if BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER
+#if PPW == 32
+#define GetBits4 c = *char1++ | \
+ SCRRIGHT (*char2++, xoff2) | \
+ SCRRIGHT (*char3++, xoff3) | \
+ SCRRIGHT (*char4++, xoff4);
+#else /* PPW == 64 */
+#define GetBits4 c = (unsigned long)(((*char1++) << 64 ) | \
+ (SCRRIGHT (*char2++, xoff2) << 64 ) | \
+ (SCRRIGHT (*char3++, xoff3) << 64 ) | \
+ (SCRRIGHT (*char4++, xoff4) << 64 ) | \
+ SCRRIGHT (*char5++, xoff5) | \
+ SCRRIGHT (*char6++, xoff6) | \
+ SCRRIGHT (*char7++, xoff7) | \
+ SCRRIGHT (*char8++, xoff8));
+#endif /* PPW */
+#else /* BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER */
+#if PPW == 32
+#define GetBits4 c = *char1++ | \
+ SCRRIGHT (*char2, xoff2) | \
+ SCRRIGHT (*char3, xoff3) | \
+ SCRRIGHT (*char4, xoff4); \
+ char2++; char3++; char4++;
+#else /* PPW == 64 */
+#define GetBits4 c = (unsigned long)(((*char1++) << 64 ) | \
+ (SCRRIGHT (*char2, xoff2) << 64 ) | \
+ (SCRRIGHT (*char3, xoff3) << 64 ) | \
+ (SCRRIGHT (*char4, xoff4) << 64 ) | \
+ SCRRIGHT (*char5, xoff5) | \
+ SCRRIGHT (*char6, xoff6) | \
+ SCRRIGHT (*char7, xoff7) | \
+ SCRRIGHT (*char8, xoff8)); \
+ char2++; char3++; char4++; \
+ char5++; char6++; char7++; char8++;
+#endif /* PPW */
+#endif /* BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER */
+
+#endif /* BITMAP_BIT_ORDER && GLYPHPADBYTES */
+
+
+#if GLYPHPADBYTES == 1
+typedef unsigned char *glyphPointer;
+#define USE_LEFTBITS
+#endif
+
+#if GLYPHPADBYTES == 2
+typedef unsigned short *glyphPointer;
+#define USE_LEFTBITS
+#endif
+
+#if GLYPHPADBYTES == 4
+typedef unsigned int *glyphPointer;
+#endif
+
+#ifdef USE_LEFTBITS
+#define GetBits1 getleftbits (char1, widthGlyph, c); \
+ c &= glyphMask; \
+ char1 = (glyphPointer) (((char *) char1) + glyphBytes);
+#else
+#define GetBits1 c = *char1++;
+#endif
+
+void
+ilbmTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ FontPtr pfont = pGC->font;
+ int widthDst;
+ PixelType *pdstBase; /* pointer to longword with top row
+ of current glyph */
+
+ int h; /* height of glyph and char */
+ register int xpos; /* current x */
+ int ypos; /* current y */
+ int widthGlyph;
+
+ int hTmp; /* counter for height */
+ register PixelType startmask, endmask;
+ int nfirst; /* used if glyphs spans a longword boundary */
+ BoxRec bbox; /* for clipping */
+ int widthGlyphs;
+ int auxDst;
+ int depthDst;
+ PixelType *saveDst;
+ register PixelType *dst;
+ register PixelType c;
+ register int d;
+ register int xoff1, xoff2, xoff3, xoff4;
+ register glyphPointer char1, char2, char3, char4;
+ glyphPointer schar1, schar2, schar3, schar4;
+#if PPW == 64
+ register int xoff5, xoff6, xoff7, xoff8;
+ register glyphPointer char5, char6, char7, char8;
+ glyphPointer schar5, schar6, schar7, schar8;
+#endif /* PPW */
+
+ unsigned char *rrops;
+#ifdef USE_LEFTBITS
+ register PixelType glyphMask;
+ register PixelType tmpSrc;
+ register int glyphBytes;
+#endif
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDrawable, widthDst, auxDst, depthDst,
+ pdstBase);
+
+ xpos = x + pDrawable->x;
+ ypos = y + pDrawable->y;
+
+ widthGlyph = FONTMAXBOUNDS(pfont,characterWidth);
+ h = FONTASCENT(pfont) + FONTDESCENT(pfont);
+
+ xpos += FONTMAXBOUNDS(pfont,leftSideBearing);
+ ypos -= FONTASCENT(pfont);
+
+ rrops = ((ilbmPrivGCPtr) pGC->devPrivates[ilbmGCPrivateIndex].ptr)->rropOS;
+
+ bbox.x1 = xpos;
+ bbox.x2 = xpos + (widthGlyph * nglyph);
+ bbox.y1 = ypos;
+ bbox.y2 = ypos + h;
+
+ switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox)) {
+ case rgnPART:
+ /* this is the WRONG thing to do, but it works.
+ calling the non-terminal text is easy, but slow, given
+ what we know about the font.
+
+ the right thing to do is something like:
+ for each clip rectangle
+ compute at which row the glyph starts to be in it,
+ and at which row the glyph ceases to be in it
+ compute which is the first glyph inside the left
+ edge, and the last one inside the right edge
+ draw a fractional first glyph, using only
+ the rows we know are in
+ draw all the whole glyphs, using the appropriate rows
+ draw any pieces of the last glyph, using the right rows
+
+ this way, the code would take advantage of knowing that
+ all glyphs are the same height and don't overlap.
+
+ one day...
+ */
+ ilbmImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ case rgnOUT:
+ return;
+ }
+ pdstBase = ilbmScanlineDeltaNoBankSwitch(pdstBase, ypos, auxDst);
+ widthGlyphs = widthGlyph * PGSZB;
+
+#ifdef USE_LEFTBITS
+ glyphMask = endtab[widthGlyph];
+ glyphBytes = GLYPHWIDTHBYTESPADDED(*ppci);
+#endif
+
+ if (nglyph >= PGSZB && widthGlyphs <= PPW) {
+ while (nglyph >= PGSZB) {
+ nglyph -= PGSZB;
+ xoff1 = xpos & PIM;
+ xoff2 = widthGlyph;
+ xoff3 = xoff2 + widthGlyph;
+ xoff4 = xoff3 + widthGlyph;
+#if PPW == 64
+ xoff5 = xoff4 + widthGlyph;
+ xoff6 = xoff5 + widthGlyph;
+ xoff7 = xoff6 + widthGlyph;
+ xoff8 = xoff7 + widthGlyph;
+#endif /* PPW */
+ schar1 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
+ schar2 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
+ schar3 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
+ schar4 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
+#if PPW == 64
+ schar5 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
+ schar6 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
+ schar7 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
+ schar8 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
+#endif /* PPW */
+
+ hTmp = h;
+ saveDst = ilbmScanlineOffset(pdstBase, (xpos >> PWSH)); /* switch now */
+
+#ifndef FASTCHARS
+ if (xoff1 + widthGlyphs <= PPW) {
+ maskpartialbits (xoff1, widthGlyphs, startmask);
+#endif
+ for (d = 0; d < depthDst; d++) {
+ hTmp = h;
+ dst = saveDst;
+ saveDst += widthDst; /* @@@ NEXT PLANE @@@ */
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (hTmp--) {
+#ifdef FASTCHARS
+ FASTPUTBITS(0, xoff1, widthGlyphs, dst);
+#else
+ *(dst) &= ~startmask;
+#endif
+ ilbmScanlineInc(dst, auxDst);
+ }
+ break;
+ case RROP_WHITE:
+ while (hTmp--) {
+#ifdef FASTCHARS
+ FASTPUTBITS(~0, xoff1, widthGlyphs, dst);
+#else
+ *(dst) |= startmask;
+#endif
+ ilbmScanlineInc(dst, auxDst);
+ }
+ break;
+ case RROP_INVERT:
+ char1 = schar1;
+ char2 = schar2;
+ char3 = schar3;
+ char4 = schar4;
+ /* XXX */
+ while (hTmp--) {
+ GetBits4
+#ifdef FASTCHARS
+# if BITMAP_BIT_ORDER == MSBFirst
+ c >>= PPW - widthGlyphs;
+# endif
+ FASTPUTBITS(~c, xoff1, widthGlyphs, dst);
+#else
+ *(dst) = (*dst) & ~startmask | ~SCRRIGHT(c, xoff1) & startmask;
+#endif
+ ilbmScanlineInc(dst, auxDst);
+ }
+ break;
+ case RROP_COPY:
+ char1 = schar1;
+ char2 = schar2;
+ char3 = schar3;
+ char4 = schar4;
+
+ while (hTmp--) {
+ GetBits4
+#ifdef FASTCHARS
+# if BITMAP_BIT_ORDER == MSBFirst
+ c >>= PPW - widthGlyphs;
+#endif
+ FASTPUTBITS(c, xoff1, widthGlyphs, dst);
+#else
+ *(dst) = (*dst) & ~startmask | SCRRIGHT(c, xoff1) & startmask;
+#endif
+ ilbmScanlineInc(dst, auxDst);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch (rrops[d]) */
+ } /* for (d = ... ) */
+#ifndef FASTCHARS
+ } else {
+ maskPPWbits (xoff1, widthGlyphs, startmask, endmask);
+ nfirst = PPW - xoff1;
+ for (d = 0; d < depthDst; d++) {
+ hTmp = h;
+ dst = saveDst;
+ saveDst += widthDst; /* @@@ NEXT PLANE @@@ */
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (hTmp--) {
+ dst[0] &= ~startmask;
+ dst[1] &= ~endmask;
+ ilbmScanlineInc(dst, auxDst);
+ }
+ break;
+ case RROP_WHITE:
+ while (hTmp--) {
+ dst[0] |= startmask;
+ dst[1] |= endmask;
+ ilbmScanlineInc(dst, auxDst);
+ }
+ break;
+ case RROP_INVERT:
+ char1 = schar1;
+ char2 = schar2;
+ char3 = schar3;
+ char4 = schar4;
+
+ while (hTmp--) {
+ GetBits4
+ dst[0] = dst[0] & ~startmask |
+ ~SCRRIGHT(c,xoff1) & startmask;
+ dst[1] = dst[1] & ~endmask |
+ ~SCRLEFT(c,nfirst) & endmask;
+ ilbmScanlineInc(dst, auxDst);
+ }
+ break;
+ case RROP_COPY:
+ char1 = schar1;
+ char2 = schar2;
+ char3 = schar3;
+ char4 = schar4;
+
+ while (hTmp--) {
+ GetBits4
+ dst[0] = dst[0] & ~startmask |
+ SCRRIGHT(c,xoff1) & startmask;
+ dst[1] = dst[1] & ~endmask |
+ SCRLEFT(c,nfirst) & endmask;
+ ilbmScanlineInc(dst, auxDst);
+ }
+ break;
+
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ... ) */
+ }
+#endif
+ xpos += widthGlyphs;
+ }
+ }
+
+ while (nglyph--) {
+ xoff1 = xpos & PIM;
+ schar1 = (glyphPointer) FONTGLYPHBITS(pglyphBase,(*ppci++));
+ hTmp = h;
+ saveDst = ilbmScanlineOffset(pdstBase, (xpos >> PWSH));
+
+ if (xoff1 + widthGlyph <= PPW) {
+ maskpartialbits (xoff1, widthGlyph, startmask);
+
+ for (d = 0; d < depthDst; d++) {
+ hTmp = h;
+ dst = saveDst;
+ saveDst += widthDst; /* @@@ NEXT PLANE @@@ */
+ char1 = schar1;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (hTmp--) {
+ (*dst) &= ~startmask;
+ ilbmScanlineInc(dst, auxDst);
+ }
+ break;
+ case RROP_WHITE:
+ while (hTmp--) {
+ (*dst) |= startmask;
+ ilbmScanlineInc(dst, auxDst);
+ }
+ break;
+ case RROP_INVERT:
+ while (hTmp--) {
+#ifdef FASTCHARS
+#ifdef USE_LEFTBITS
+ FASTGETBITS (char1,0,widthGlyph,c);
+ char1 = (glyphPointer) (((char *) char1) + glyphBytes);
+#else
+ c = *char1++;
+#if BITMAP_BIT_ORDER == MSBFirst
+ c >>= PPW - widthGlyph;
+#endif
+#endif
+ FASTPUTBITS (~c,xoff1,widthGlyph,dst);
+#else
+ GetBits1
+ (*dst) = (*dst) & ~startmask | ~SCRRIGHT(c, xoff1) & startmask;
+#endif
+ ilbmScanlineInc(dst, auxDst);
+ }
+ break;
+ case RROP_COPY:
+ while (hTmp--) {
+#ifdef FASTCHARS
+#ifdef USE_LEFTBITS
+ FASTGETBITS (char1,0,widthGlyph,c);
+ char1 = (glyphPointer) (((char *) char1) + glyphBytes);
+#else
+ c = *char1++;
+#if BITMAP_BIT_ORDER == MSBFirst
+ c >>= PPW - widthGlyph;
+#endif
+#endif
+ FASTPUTBITS (c,xoff1,widthGlyph,dst);
+#else
+ GetBits1
+ (*dst) = (*dst) & ~startmask | SCRRIGHT(c, xoff1) & startmask;
+#endif
+ ilbmScanlineInc(dst, auxDst);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ...) */
+ } else {
+ maskPPWbits (xoff1, widthGlyph, startmask, endmask);
+ nfirst = PPW - xoff1;
+
+ for (d = 0; d < depthDst; d++) {
+ hTmp = h;
+ dst = saveDst;
+ saveDst += widthDst; /* @@@ NEXT PLANE @@@ */
+ char1 = schar1;
+
+ switch (rrops[d]) {
+ case RROP_BLACK:
+ while (hTmp--) {
+ dst[0] &= ~startmask;
+ dst[1] &= ~endmask;
+ ilbmScanlineInc(dst, auxDst);
+ }
+ break;
+ case RROP_WHITE:
+ while (hTmp--) {
+ dst[0] |= startmask;
+ dst[1] |= endmask;
+ ilbmScanlineInc(dst, auxDst);
+ }
+ break;
+ case RROP_INVERT:
+ while (hTmp--) {
+ GetBits1
+ dst[0] = dst[0] & ~startmask |
+ ~SCRRIGHT(c,xoff1) & startmask;
+ dst[1] = dst[1] & ~endmask |
+ ~SCRLEFT(c,nfirst) & endmask;
+ ilbmScanlineInc(dst, auxDst);
+ }
+ break;
+ case RROP_COPY:
+ while (hTmp--) {
+ GetBits1
+ dst[0] = dst[0] & ~startmask |
+ SCRRIGHT(c,xoff1) & startmask;
+ dst[1] = dst[1] & ~endmask |
+ SCRLEFT(c,nfirst) & endmask;
+ ilbmScanlineInc(dst, auxDst);
+ }
+ break;
+ case RROP_NOP:
+ break;
+ } /* switch */
+ } /* for (d = ...) */
+ }
+
+ xpos += widthGlyph;
+ }
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmtile.c b/nx-X11/programs/Xserver/ilbm/ilbmtile.c
new file mode 100644
index 000000000..b35d00028
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmtile.c
@@ -0,0 +1,857 @@
+/* $XFree86$ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: ilbmtile.c,v 5.8 94/04/17 20:28:36 dpw Exp $ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "windowstr.h"
+#include "regionstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "ilbm.h"
+#include "maskbits.h"
+
+#include "mergerop.h"
+/*
+
+ the boxes are already translated.
+
+ NOTE:
+ iy = ++iy < tileHeight ? iy : 0
+is equivalent to iy%= tileheight, and saves a division.
+*/
+
+/*
+ tile area with a PPW bit wide pixmap
+*/
+void
+MROP_NAME(ilbmTileAreaPPW)(pDraw, nbox, pbox, alu, ptile, planemask)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ int alu;
+ PixmapPtr ptile;
+ unsigned long planemask;
+{
+ register PixelType *psrc;
+ /* pointer to bits in tile, if needed */
+ int tileHeight; /* height of the tile */
+ register PixelType srcpix;
+ int nlwidth; /* width in longwords of the drawable */
+ int w; /* width of current box */
+ MROP_DECLARE_REG ()
+ register int h; /* height of current box */
+ register int nlw; /* loop version of nlwMiddle */
+ register PixelType *p; /* pointer to bits we're writing */
+ int auxDst;
+ int depthDst;
+ int tlwidth;
+ register int d;
+ PixelType startmask;
+ PixelType endmask; /* masks for reggedy bits at either end of line */
+ int nlwMiddle; /* number of longwords between sides of boxes */
+ int nlwExtra; /* to get from right of box to left of next span */
+ register int iy; /* index of current scanline in tile */
+ PixelType *pbits; /* pointer to start of drawable */
+ PixelType *saveP;
+ PixelType *pSaveSrc;
+ int saveH;
+ int saveIY;
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst,
+ pbits);
+
+ MROP_INITIALIZE(alu,~0)
+
+ tileHeight = ptile->drawable.height;
+ tlwidth = ptile->devKind/sizeof(PixelType);
+ pSaveSrc = (PixelType *)(ptile->devPrivate.ptr);
+
+ while (nbox--) {
+ w = pbox->x2 - pbox->x1;
+ saveH = pbox->y2 - pbox->y1;
+ saveIY = pbox->y1 % tileHeight;
+ saveP = ilbmScanline(pbits, pbox->x1, pbox->y1, auxDst);
+ psrc = pSaveSrc;
+
+ if (((pbox->x1 & PIM) + w) < PPW) {
+ maskpartialbits(pbox->x1, w, startmask);
+ nlwExtra = auxDst;
+ for (d = 0; d < depthDst; d++, saveP += nlwidth, psrc += tileHeight) { /* @@@ NEXT PLANE @@@ */
+ if (!(planemask & (1 << d)))
+ continue;
+
+ p = saveP;
+ h = saveH;
+ iy = saveIY;
+
+ while (h--) {
+ srcpix = psrc[iy];
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ *p = MROP_MASK(srcpix,*p,startmask);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ }
+ } else {
+ maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
+
+ for (d = 0; d < depthDst; d++, saveP += nlwidth, psrc += tileHeight) { /* @@@ NEXT PLANE @@@ */
+ if (!(planemask & (1 << d)))
+ continue;
+
+ p = saveP;
+ h = saveH;
+ iy = saveIY;
+ nlwExtra = auxDst - nlwMiddle;
+
+ if (startmask && endmask) {
+ nlwExtra -= 1;
+ while (h--) {
+ srcpix = psrc[iy];
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ *p = MROP_MASK (srcpix,*p,startmask);
+ p++;
+ while (nlw--) {
+ *p = MROP_SOLID(srcpix,*p);
+ p++;
+ }
+
+ *p = MROP_MASK(srcpix,*p,endmask);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ } else if (startmask && !endmask) {
+ nlwExtra -= 1;
+ while (h--) {
+ srcpix = psrc[iy];
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ *p = MROP_MASK(srcpix,*p,startmask);
+ p++;
+ while (nlw--) {
+ *p = MROP_SOLID(srcpix,*p);
+ p++;
+ }
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ } else if (!startmask && endmask) {
+ while (h--) {
+ srcpix = psrc[iy];
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ while (nlw--) {
+ *p = MROP_SOLID(srcpix,*p);
+ p++;
+ }
+
+ *p = MROP_MASK(srcpix,*p,endmask);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ } else { /* no ragged bits at either end */
+ while (h--) {
+ srcpix = psrc[iy];
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ while (nlw--) {
+ *p = MROP_SOLID (srcpix,*p);
+ p++;
+ }
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ }
+ } /* for (d = ...) */
+ }
+ pbox++;
+ }
+}
+
+void
+MROP_NAME(ilbmTileArea)(pDraw, nbox, pbox, alu, pTile, xOff, yOff, planemask)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ int alu;
+ PixmapPtr pTile;
+ int xOff;
+ int yOff;
+ unsigned long planemask;
+{
+ register PixelType *psrc;
+ /* pointer to bits in tile, if needed */
+ int nlwidth; /* width in longwords of the drawable */
+ MROP_DECLARE_REG ()
+ register int h; /* height of current box */
+ register PixelType *pdst; /* pointer to bits we're writing */
+ register PixelType tmpsrc, tmpdst;
+ int auxDst;
+ int depthDst;
+ int sizeTile;
+ int tileLine;
+ int iline;
+ int w, width, x, xSrc, ySrc, srcStartOver, nend;
+ int tlwidth, rem, tileWidth, tileHeight, endinc;
+ int saveW;
+ PixelType *psrcT;
+ int d;
+ int nstart;
+ PixelType startmask;
+ PixelType endmask; /* masks for reggedy bits at either end of line */
+ int nlMiddle; /* number of longwords between sides of boxes */
+ int iy;
+ PixelType *pBase; /* pointer to start of drawable */
+ PixelType *saveP;
+ PixelType *pStartDst;
+ PixelType *pStartTile;
+ int saveH;
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst,
+ pBase);
+
+ MROP_INITIALIZE(alu,~0)
+
+ tileHeight = pTile->drawable.height;
+ tileWidth = pTile->drawable.width;
+ tlwidth = pTile->devKind/sizeof(PixelType);
+ sizeTile = tlwidth * tileHeight;
+
+ xSrc = pDraw->x + ((xOff % tileWidth) - tileWidth);
+ ySrc = pDraw->y + ((yOff % tileHeight) - tileHeight);
+
+ while (nbox--) {
+ saveW = pbox->x2 - pbox->x1;
+ iline = (pbox->y1 - ySrc) % tileHeight;
+ psrcT = (PixelType *) pTile->devPrivate.ptr;
+ tileLine = iline * tlwidth;
+ saveH = pbox->y2 - pbox->y1;
+ saveP = ilbmScanline(pBase, pbox->x1, pbox->y1, auxDst);
+
+ for (d = 0; d < depthDst; d++, psrcT += sizeTile, saveP += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ if (!(planemask & (1 << d)))
+ continue;
+
+ h = saveH;
+ pStartDst = saveP;
+ pStartTile = psrcT + tileLine;
+ iy = iline;
+
+ while (h--) {
+ x = pbox->x1;
+ width = saveW;
+ pdst = pStartDst;
+ while (width > 0) {
+ psrc = pStartTile;
+ w = min(tileWidth, width);
+ if ((rem = (x - xSrc) % tileWidth) != 0) {
+ /* if we're in the middle of the tile, get
+ as many bits as will finish the span, or
+ as many as will get to the left edge of the tile,
+ or a longword worth, starting at the appropriate
+ offset in the tile.
+ */
+ w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
+ endinc = rem / BITMAP_SCANLINE_PAD;
+
+ getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
+#if (MROP) != Mcopy
+ getbits (pdst, (x & PIM), w, tmpdst);
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ putbits (tmpsrc, (x & PIM), w, pdst);
+
+ if ((x & PIM) + w >= PPW)
+ pdst++;
+ } else if (((x & PIM) + w) < PPW) {
+ /* doing < PPW bits is easy, and worth special-casing */
+ tmpsrc = *psrc;
+#if (MROP) != Mcopy
+ getbits (pdst, (x & PIM), w, tmpdst);
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ putbits (tmpsrc, (x & PIM), w, pdst);
+ } else {
+ /* start at the left edge of the tile,
+ and put down as much as we can
+ */
+ maskbits(x, w, startmask, endmask, nlMiddle);
+
+ if (startmask)
+ nstart = PPW - (x & PIM);
+ else
+ nstart = 0;
+ if (endmask)
+ nend = (x + w) & PIM;
+ else
+ nend = 0;
+
+ srcStartOver = nstart > PLST;
+
+ if (startmask) {
+ tmpsrc = *psrc;
+#if (MROP) != Mcopy
+ getbits (pdst, (x & PIM), nstart, tmpdst);
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ putbits (tmpsrc, (x & PIM), nstart, pdst);
+ pdst++;
+ if (srcStartOver)
+ psrc++;
+ }
+
+ while (nlMiddle--) {
+ getbits (psrc, nstart, PPW, tmpsrc);
+#if (MROP) != Mcopy
+ tmpdst = *pdst;
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ *pdst++ = tmpsrc;
+ /*putbits (tmpsrc, 0, PPW, pdst);
+ pdst++;*/
+ psrc++;
+ }
+
+ if (endmask) {
+ getbits (psrc, nstart, nend, tmpsrc);
+#if (MROP) != Mcopy
+ tmpdst = *pdst;
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ putbits (tmpsrc, 0, nend, pdst);
+ }
+ }
+ x += w;
+ width -= w;
+ } /* while (width > 0) */
+
+ pStartDst += auxDst;
+ if (++iy >= tileHeight) {
+ iy = 0;
+ pStartTile = psrcT;
+ } else
+ pStartTile += tlwidth;
+
+ } /* while (h) */
+ } /* for (d = ... ) */
+ pbox++;
+ } /* for each box */
+}
+
+void
+MROP_NAME(ilbmOpaqueStippleAreaPPW)(pDraw, nbox, pbox, alu, ptile,
+ rropsOS, planemask)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ int alu;
+ PixmapPtr ptile;
+ register unsigned char *rropsOS;
+ unsigned long planemask;
+{
+ register PixelType *psrc;
+ /* pointer to bits in tile, if needed */
+ int tileHeight; /* height of the tile */
+ register PixelType srcpix;
+ int nlwidth; /* width in longwords of the drawable */
+ int w; /* width of current box */
+ MROP_DECLARE_REG ()
+ register int h; /* height of current box */
+ register int nlw; /* loop version of nlwMiddle */
+ register PixelType *p; /* pointer to bits we're writing */
+ int auxDst;
+ int depthDst;
+ register int d;
+ PixelType startmask;
+ PixelType endmask; /* masks for reggedy bits at either end of line */
+ int nlwMiddle; /* number of longwords between sides of boxes */
+ int nlwExtra; /* to get from right of box to left of next span */
+ register int iy; /* index of current scanline in tile */
+ PixelType *pbits; /* pointer to start of drawable */
+ PixelType *saveP;
+ int saveH;
+ int saveIY;
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst,
+ pbits);
+
+ MROP_INITIALIZE(alu,~0)
+
+ tileHeight = ptile->drawable.height;
+ psrc = (PixelType *)(ptile->devPrivate.ptr);
+
+ while (nbox--) {
+ w = pbox->x2 - pbox->x1;
+ saveH = pbox->y2 - pbox->y1;
+ saveIY = pbox->y1 % tileHeight;
+ saveP = ilbmScanline(pbits, pbox->x1, pbox->y1, auxDst);
+
+ if ( ((pbox->x1 & PIM) + w) < PPW) {
+ maskpartialbits(pbox->x1, w, startmask);
+ nlwExtra = auxDst;
+ for (d = 0; d < depthDst; d++, saveP += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ if (!(planemask & (1 << d)))
+ continue;
+
+ p = saveP;
+ h = saveH;
+ iy = saveIY;
+
+ while (h--) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ srcpix = 0;
+ break;
+ case RROP_WHITE:
+ srcpix = ~0;
+ break;
+ case RROP_COPY:
+ srcpix = psrc[iy];
+ break;
+ case RROP_INVERT:
+ srcpix = ~psrc[iy];
+ break;
+ }
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ *p = MROP_MASK(srcpix,*p,startmask);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ }
+ } else {
+ maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
+
+ for (d = 0; d < depthDst; d++, saveP += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ if (!(planemask & (1 << d)))
+ continue;
+
+ p = saveP;
+ h = saveH;
+ iy = saveIY;
+ nlwExtra = auxDst - nlwMiddle;
+
+ if (startmask && endmask) {
+ nlwExtra -= 1;
+ while (h--) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ srcpix = 0;
+ break;
+ case RROP_WHITE:
+ srcpix = ~0;
+ break;
+ case RROP_COPY:
+ srcpix = psrc[iy];
+ break;
+ case RROP_INVERT:
+ srcpix = ~psrc[iy];
+ break;
+ }
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ *p = MROP_MASK (srcpix,*p,startmask);
+ p++;
+ while (nlw--) {
+ *p = MROP_SOLID(srcpix,*p);
+ p++;
+ }
+
+ *p = MROP_MASK(srcpix,*p,endmask);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ } else if (startmask && !endmask) {
+ nlwExtra -= 1;
+ while (h--) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ srcpix = 0;
+ break;
+ case RROP_WHITE:
+ srcpix = ~0;
+ break;
+ case RROP_COPY:
+ srcpix = psrc[iy];
+ break;
+ case RROP_INVERT:
+ srcpix = ~psrc[iy];
+ break;
+ }
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ *p = MROP_MASK(srcpix,*p,startmask);
+ p++;
+ while (nlw--) {
+ *p = MROP_SOLID(srcpix,*p);
+ p++;
+ }
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ } else if (!startmask && endmask) {
+ while (h--) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ srcpix = 0;
+ break;
+ case RROP_WHITE:
+ srcpix = ~0;
+ break;
+ case RROP_COPY:
+ srcpix = psrc[iy];
+ break;
+ case RROP_INVERT:
+ srcpix = ~psrc[iy];
+ break;
+ }
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ while (nlw--) {
+ *p = MROP_SOLID(srcpix,*p);
+ p++;
+ }
+
+ *p = MROP_MASK(srcpix,*p,endmask);
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ } else { /* no ragged bits at either end */
+ while (h--) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ srcpix = 0;
+ break;
+ case RROP_WHITE:
+ srcpix = ~0;
+ break;
+ case RROP_COPY:
+ srcpix = psrc[iy];
+ break;
+ case RROP_INVERT:
+ srcpix = ~psrc[iy];
+ break;
+ }
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ while (nlw--) {
+ *p = MROP_SOLID (srcpix,*p);
+ p++;
+ }
+ ilbmScanlineInc(p, nlwExtra);
+ }
+ }
+ } /* for (d = ...) */
+ }
+ pbox++;
+ }
+}
+
+void
+MROP_NAME(ilbmOpaqueStippleArea)(pDraw, nbox, pbox, alu, pTile, xOff, yOff,
+ rropsOS, planemask)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ int alu;
+ PixmapPtr pTile;
+ int xOff;
+ int yOff;
+ register unsigned char *rropsOS;
+ unsigned long planemask;
+{
+ register PixelType *psrc;
+ /* pointer to bits in tile, if needed */
+ int nlwidth; /* width in longwords of the drawable */
+ MROP_DECLARE_REG ()
+ register int h; /* height of current box */
+ register PixelType *pdst; /* pointer to bits we're writing */
+ register PixelType tmpsrc, tmpdst;
+ int auxDst;
+ int depthDst;
+ int tileLine;
+ int iline;
+ int w, width, x, xSrc, ySrc, srcStartOver, nend;
+ int tlwidth, rem, tileWidth, tileHeight, endinc;
+ int saveW;
+ PixelType *psrcT;
+ int d;
+ int nstart;
+ PixelType startmask;
+ PixelType endmask; /* masks for reggedy bits at either end of line */
+ int nlMiddle; /* number of longwords between sides of boxes */
+ int iy;
+ PixelType *pBase; /* pointer to start of drawable */
+ PixelType *saveP;
+ PixelType *pStartDst;
+ PixelType *pStartTile;
+ int saveH;
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst,
+ pBase);
+
+ MROP_INITIALIZE(alu,~0)
+
+ tileHeight = pTile->drawable.height;
+ tileWidth = pTile->drawable.width;
+ tlwidth = pTile->devKind/sizeof(PixelType);
+
+ xSrc = pDraw->x + ((xOff % tileWidth) - tileWidth);
+ ySrc = pDraw->y + ((yOff % tileHeight) - tileHeight);
+
+ while (nbox--) {
+ saveW = pbox->x2 - pbox->x1;
+ iline = (pbox->y1 - ySrc) % tileHeight;
+ psrcT = (PixelType *) pTile->devPrivate.ptr;
+ tileLine = iline * tlwidth;
+ saveH = pbox->y2 - pbox->y1;
+ saveP = ilbmScanline(pBase, pbox->x1, pbox->y1, auxDst);
+
+ for (d = 0; d < depthDst; d++, saveP += nlwidth) { /* @@@ NEXT PLANE @@@ */
+ if (!(planemask & (1 << d)))
+ continue;
+
+ h = saveH;
+ pStartDst = saveP;
+ pStartTile = psrcT + tileLine;
+ iy = iline;
+
+ while (h--) {
+ x = pbox->x1;
+ width = saveW;
+ pdst = pStartDst;
+ while (width > 0) {
+ psrc = pStartTile;
+ w = min(tileWidth, width);
+ if ((rem = (x - xSrc) % tileWidth) != 0) {
+ /* if we're in the middle of the tile, get
+ as many bits as will finish the span, or
+ as many as will get to the left edge of the tile,
+ or a longword worth, starting at the appropriate
+ offset in the tile.
+ */
+ w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
+ endinc = rem / BITMAP_SCANLINE_PAD;
+
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+
+ case RROP_COPY:
+ getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
+ break;
+
+ case RROP_INVERT:
+ getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
+ tmpsrc = ~tmpsrc;
+ break;
+ }
+#if (MROP) != Mcopy
+ getbits (pdst, (x & PIM), w, tmpdst);
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ putbits (tmpsrc, (x & PIM), w, pdst);
+
+ if ((x & PIM) + w >= PPW)
+ pdst++;
+ } else if (((x & PIM) + w) < PPW) {
+ /* doing < PPW bits is easy, and worth special-casing */
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+ case RROP_COPY:
+ tmpsrc = *psrc;
+ break;
+ case RROP_INVERT:
+ tmpsrc = ~*psrc;
+ break;
+ }
+#if (MROP) != Mcopy
+ getbits (pdst, (x & PIM), w, tmpdst);
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ putbits (tmpsrc, (x & PIM), w, pdst);
+ } else {
+ /* start at the left edge of the tile,
+ and put down as much as we can
+ */
+ maskbits(x, w, startmask, endmask, nlMiddle);
+
+ if (startmask)
+ nstart = PPW - (x & PIM);
+ else
+ nstart = 0;
+ if (endmask)
+ nend = (x + w) & PIM;
+ else
+ nend = 0;
+
+ srcStartOver = nstart > PLST;
+
+ if (startmask) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+ case RROP_COPY:
+ tmpsrc = *psrc;
+ break;
+ case RROP_INVERT:
+ tmpsrc = ~*psrc;
+ break;
+ }
+#if (MROP) != Mcopy
+ getbits (pdst, (x & PIM), nstart, tmpdst);
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ putbits (tmpsrc, (x & PIM), nstart, pdst);
+ pdst++;
+ if (srcStartOver)
+ psrc++;
+ }
+
+ while (nlMiddle--) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+ case RROP_COPY:
+ getbits (psrc, nstart, PPW, tmpsrc);
+ break;
+ case RROP_INVERT:
+ getbits (psrc, nstart, PPW, tmpsrc);
+ tmpsrc = ~tmpsrc;
+ break;
+ }
+#if (MROP) != Mcopy
+ tmpdst = *pdst;
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ *pdst++ = tmpsrc;
+ /*putbits (tmpsrc, 0, PPW, pdst);
+ pdst++; */
+ psrc++;
+ }
+
+ if (endmask) {
+ switch (rropsOS[d]) {
+ case RROP_BLACK:
+ tmpsrc = 0;
+ break;
+ case RROP_WHITE:
+ tmpsrc = ~0;
+ break;
+
+ case RROP_COPY:
+ getbits (psrc, nstart, nend, tmpsrc);
+ break;
+
+ case RROP_INVERT:
+ getbits (psrc, nstart, nend, tmpsrc);
+ tmpsrc = ~tmpsrc;
+ break;
+ }
+#if (MROP) != Mcopy
+ tmpdst = *pdst;
+ tmpsrc = DoMergeRop (tmpsrc, tmpdst);
+#endif
+ putbits (tmpsrc, 0, nend, pdst);
+ }
+ }
+ x += w;
+ width -= w;
+ } /* while (width > 0) */
+
+ pStartDst += auxDst;
+ if (++iy >= tileHeight) {
+ iy = 0;
+ pStartTile = psrcT;
+ } else
+ pStartTile += tlwidth;
+
+ } /* while (h) */
+ } /* for (d = ... ) */
+ pbox++;
+ } /* for each box */
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmwindow.c b/nx-X11/programs/Xserver/ilbm/ilbmwindow.c
new file mode 100644
index 000000000..be84fcefb
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmwindow.c
@@ -0,0 +1,323 @@
+/* $XFree86$ */
+/* $XConsortium: ilbmwindow.c,v 5.14 94/04/17 20:28:36 dpw Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "ilbm.h"
+#include "mistruct.h"
+#include "regionstr.h"
+#include "maskbits.h"
+
+extern WindowPtr *WindowTable;
+
+Bool
+ilbmCreateWindow(pWin)
+ register WindowPtr pWin;
+{
+ register ilbmPrivWin *pPrivWin;
+
+ pPrivWin = (ilbmPrivWin *)(pWin->devPrivates[ilbmWindowPrivateIndex].ptr);
+ pPrivWin->pRotatedBorder = NullPixmap;
+ pPrivWin->pRotatedBackground = NullPixmap;
+ pPrivWin->fastBackground = FALSE;
+ pPrivWin->fastBorder = FALSE;
+#ifdef PIXMAP_PER_WINDOW
+ pWin->devPrivates[frameWindowPrivateIndex].ptr =
+ pWin->pDrawable.pScreen->devPrivates[ilbmScreenPrivateIndex].ptr;
+#endif
+
+ return (TRUE);
+}
+
+/* This always returns true, because Xfree can't fail. It might be possible
+ * on some devices for Destroy to fail */
+Bool
+ilbmDestroyWindow(pWin)
+ WindowPtr pWin;
+{
+ register ilbmPrivWin *pPrivWin;
+
+ pPrivWin = (ilbmPrivWin *)(pWin->devPrivates[ilbmWindowPrivateIndex].ptr);
+
+ if (pPrivWin->pRotatedBorder)
+ (*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
+ if (pPrivWin->pRotatedBackground)
+ (*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBackground);
+
+ return (TRUE);
+}
+
+/*ARGSUSED*/
+Bool
+ilbmMapWindow(pWindow)
+ WindowPtr pWindow;
+{
+ return (TRUE);
+}
+
+/* (x, y) is the upper left corner of the window on the screen
+ do we really need to pass this? (is it a;ready in pWin->absCorner?)
+ we only do the rotation for pixmaps that are 32 bits wide (padded
+or otherwise.)
+ ilbmChangeWindowAttributes() has already put a copy of the pixmap
+in pPrivWin->pRotated*
+*/
+
+/*ARGSUSED*/
+Bool
+ilbmPositionWindow(pWin, x, y)
+ WindowPtr pWin;
+ int x, y;
+{
+ register ilbmPrivWin *pPrivWin;
+ int reset = 0;
+
+ pPrivWin = (ilbmPrivWin *)(pWin->devPrivates[ilbmWindowPrivateIndex].ptr);
+ if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground) {
+ ilbmXRotatePixmap(pPrivWin->pRotatedBackground,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ ilbmYRotatePixmap(pPrivWin->pRotatedBackground,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ reset = 1;
+ }
+
+ if (!pWin->borderIsPixel && pPrivWin->fastBorder) {
+ while (pWin->backgroundState == ParentRelative)
+ pWin = pWin->parent;
+ ilbmXRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ ilbmYRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ reset = 1;
+ }
+ if (reset) {
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ }
+
+ /* This is the "wrong" fix to the right problem, but it doesn't really
+ * cost very much. When the window is moved, we need to invalidate any
+ * RotatedPixmap that exists in any GC currently validated against this
+ * window.
+ */
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+ /* Again, we have no failure modes indicated by any of the routines
+ * we've called, so we have to assume it worked */
+ return (TRUE);
+}
+
+/*ARGSUSED*/
+Bool
+ilbmUnmapWindow(pWindow)
+ WindowPtr pWindow;
+{
+ return (TRUE);
+}
+
+/* UNCLEAN!
+ this code calls the bitblt helper code directly.
+
+ ilbmCopyWindow copies only the parts of the destination that are
+visible in the source.
+*/
+
+
+void
+ilbmCopyWindow(pWin, ptOldOrg, prgnSrc)
+ WindowPtr pWin;
+ DDXPointRec ptOldOrg;
+ RegionPtr prgnSrc;
+{
+ DDXPointPtr pptSrc;
+ register DDXPointPtr ppt;
+ RegionPtr prgnDst;
+ register BoxPtr pbox;
+ register int dx, dy;
+ register int i, nbox;
+ WindowPtr pwinRoot;
+
+ pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
+
+ prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+ REGION_INTERSECT(pWin->drawable.pScreen, prgnDst, &pWin->borderClip,
+ prgnSrc);
+
+ pbox = REGION_RECTS(prgnDst);
+ nbox = REGION_NUM_RECTS(prgnDst);
+ if (!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
+ return;
+ ppt = pptSrc;
+
+ for (i=nbox; --i >= 0; ppt++, pbox++) {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ ilbmDoBitblt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, GXcopy, prgnDst,
+ pptSrc, ~0);
+ DEALLOCATE_LOCAL(pptSrc);
+ REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
+}
+
+
+
+/* swap in correct PaintWindow* routine. If we can use a fast output
+routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
+of it in devPrivate.
+*/
+Bool
+ilbmChangeWindowAttributes(pWin, mask)
+ register WindowPtr pWin;
+ register unsigned long mask;
+{
+ register unsigned long index;
+ register ilbmPrivWin *pPrivWin;
+ WindowPtr pBgWin;
+
+ pPrivWin = (ilbmPrivWin *)(pWin->devPrivates[ilbmWindowPrivateIndex].ptr);
+ /*
+ * When background state changes from ParentRelative and
+ * we had previously rotated the fast border pixmap to match
+ * the parent relative origin, rerotate to match window
+ */
+ if (mask & (CWBackPixmap | CWBackPixel) &&
+ pWin->backgroundState != ParentRelative && pPrivWin->fastBorder &&
+ (pPrivWin->oldRotate.x != pWin->drawable.x ||
+ pPrivWin->oldRotate.y != pWin->drawable.y)) {
+ ilbmXRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ ilbmYRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ }
+ while (mask) {
+ index = lowbit (mask);
+ mask &= ~index;
+ switch (index) {
+ case CWBackPixmap:
+ if (pWin->backgroundState == None)
+ pPrivWin->fastBackground = FALSE;
+ else if (pWin->backgroundState == ParentRelative) {
+ pPrivWin->fastBackground = FALSE;
+ /* Rotate border to match parent origin */
+ if (pPrivWin->pRotatedBorder) {
+ for (pBgWin = pWin->parent;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+ ilbmXRotatePixmap(pPrivWin->pRotatedBorder,
+ pBgWin->drawable.x - pPrivWin->oldRotate.x);
+ ilbmYRotatePixmap(pPrivWin->pRotatedBorder,
+ pBgWin->drawable.y - pPrivWin->oldRotate.y);
+ pPrivWin->oldRotate.x = pBgWin->drawable.x;
+ pPrivWin->oldRotate.y = pBgWin->drawable.y;
+ }
+ } else if ((pWin->background.pixmap->drawable.width <= PPW) &&
+ !(pWin->background.pixmap->drawable.width &
+ (pWin->background.pixmap->drawable.width - 1))) {
+ ilbmCopyRotatePixmap(pWin->background.pixmap,
+ &pPrivWin->pRotatedBackground,
+ pWin->drawable.x, pWin->drawable.y);
+ if (pPrivWin->pRotatedBackground) {
+ pPrivWin->fastBackground = TRUE;
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ } else
+ pPrivWin->fastBackground = FALSE;
+ } else
+ pPrivWin->fastBackground = FALSE;
+ break;
+
+ case CWBackPixel:
+ pPrivWin->fastBackground = FALSE;
+ break;
+
+ case CWBorderPixmap:
+ if ((pWin->border.pixmap->drawable.width <= PPW) &&
+ !(pWin->border.pixmap->drawable.width &
+ (pWin->border.pixmap->drawable.width - 1))) {
+ for (pBgWin = pWin;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+ ilbmCopyRotatePixmap(pWin->border.pixmap,
+ &pPrivWin->pRotatedBorder,
+ pBgWin->drawable.x, pBgWin->drawable.y);
+ if (pPrivWin->pRotatedBorder) {
+ pPrivWin->fastBorder = TRUE;
+ pPrivWin->oldRotate.x = pBgWin->drawable.x;
+ pPrivWin->oldRotate.y = pBgWin->drawable.y;
+ } else
+ pPrivWin->fastBorder = FALSE;
+ } else
+ pPrivWin->fastBorder = FALSE;
+ break;
+ case CWBorderPixel:
+ pPrivWin->fastBorder = FALSE;
+ break;
+ }
+ }
+ /* Again, we have no failure modes indicated by any of the routines
+ * we've called, so we have to assume it worked */
+ return (TRUE);
+}
diff --git a/nx-X11/programs/Xserver/ilbm/ilbmzerarc.c b/nx-X11/programs/Xserver/ilbm/ilbmzerarc.c
new file mode 100644
index 000000000..ad20d614b
--- /dev/null
+++ b/nx-X11/programs/Xserver/ilbm/ilbmzerarc.c
@@ -0,0 +1,214 @@
+/* $XFree86: xc/programs/Xserver/ilbm/ilbmzerarc.c,v 3.0 1996/08/18 01:54:15 dawes Exp $ */
+/************************************************************
+
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+********************************************************/
+
+/* $XConsortium: ilbmzerarc.c,v 5.19 94/04/17 20:28:37 dpw Exp $ */
+
+/* Derived from:
+ * "Algorithm for drawing ellipses or hyperbolae with a digital plotter"
+ * by M. L. V. Pitteway
+ * The Computer Journal, November 1967, Volume 10, Number 3, pp. 282-289
+ */
+
+/* Modified jun 95 by Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+ to use interleaved bitplanes instead of normal bitplanes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "miscstruct.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "ilbm.h"
+#include "maskbits.h"
+#include "mizerarc.h"
+#include "mi.h"
+
+/*
+ * Note: LEFTMOST must be the bit leftmost in the actual screen
+ * representation. This depends also on the IMAGE_BYTE_ORDER.
+ * LONG2CHARS() takes care of the re-ordering as required. (DHD)
+ */
+#if (BITMAP_BIT_ORDER == MSBFirst)
+#define LEFTMOST ((PixelType) LONG2CHARS((1 << PLST)))
+#else
+#define LEFTMOST ((PixelType) LONG2CHARS(1))
+#endif
+
+#define Pixelate(base,yoff,xoff) \
+{ \
+ paddr = ilbmScanlineOffset(base, (yoff) + ((xoff)>>PWSH)); \
+ pmask = SCRRIGHT(LEFTMOST, (xoff) & PIM); \
+ for (de = 0; de < depthDst; de++, paddr += nlwidth) /* @@@ NEXT PLANE @@@ */ \
+ switch (rrops[de]) { \
+ case RROP_BLACK: \
+ *paddr &= ~pmask; \
+ break; \
+ case RROP_WHITE: \
+ *paddr |= pmask; \
+ break; \
+ case RROP_INVERT: \
+ *paddr ^= pmask; \
+ break; \
+ case RROP_NOP: \
+ break; \
+ } \
+}
+
+#define DoPix(bit,base,yoff,xoff) if (mask & bit) Pixelate(base,yoff,xoff);
+
+static void
+ilbmZeroArcSS(pDraw, pGC, arc)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ xArc *arc;
+{
+ miZeroArcRec info;
+ Bool do360;
+ register int de;
+ register int x, y, a, b, d, mask;
+ register int k1, k3, dx, dy;
+ PixelType *addrl;
+ PixelType *yorgl, *yorgol;
+ PixelType pixel;
+ int nlwidth, yoffset, dyoffset;
+ int auxDst, depthDst;
+ PixelType pmask;
+ register PixelType *paddr;
+ register unsigned char *rrops;
+
+ rrops = ((ilbmPrivGC *)(pGC->devPrivates[ilbmGCPrivateIndex].ptr))->rrops;
+
+ ilbmGetPixelWidthAuxDepthAndPointer(pDraw, nlwidth, auxDst, depthDst,
+ addrl);
+ do360 = miZeroArcSetup(arc, &info, TRUE);
+ yorgl = addrl + ((info.yorg + pDraw->y) * auxDst);
+ yorgol = addrl + ((info.yorgo + pDraw->y) * auxDst);
+ info.xorg += pDraw->x;
+ info.xorgo += pDraw->x;
+ MIARCSETUP();
+ yoffset = y ? auxDst : 0;
+ dyoffset = 0;
+ mask = info.initialMask;
+ if (!(arc->width & 1)) {
+ DoPix(2, yorgl, 0, info.xorgo);
+ DoPix(8, yorgol, 0, info.xorgo);
+ }
+ if (!info.end.x || !info.end.y) {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ if (do360 && (arc->width == arc->height) && !(arc->width & 1)) {
+ int xoffset = auxDst;
+ PixelType *yorghl = ilbmScanlineDeltaNoBankSwitch(yorgl, info.h, auxDst);
+ int xorghp = info.xorg + info.h;
+ int xorghn = info.xorg - info.h;
+
+ while (1) {
+ Pixelate(yorgl, yoffset, info.xorg + x);
+ Pixelate(yorgl, yoffset, info.xorg - x);
+ Pixelate(yorgol, -yoffset, info.xorg - x);
+ Pixelate(yorgol, -yoffset, info.xorg + x);
+ if (a < 0)
+ break;
+ Pixelate(yorghl, -xoffset, xorghp - y);
+ Pixelate(yorghl, -xoffset, xorghn + y);
+ Pixelate(yorghl, xoffset, xorghn + y);
+ Pixelate(yorghl, xoffset, xorghp - y);
+ xoffset += auxDst;
+ MIARCCIRCLESTEP(yoffset += auxDst;);
+ }
+ x = info.w;
+ yoffset = info.h * auxDst;
+ } else if (do360) {
+ while (y < info.h || x < info.w) {
+ MIARCOCTANTSHIFT(dyoffset = auxDst;);
+ Pixelate(yorgl, yoffset, info.xorg + x);
+ Pixelate(yorgl, yoffset, info.xorgo - x);
+ Pixelate(yorgol, -yoffset, info.xorgo - x);
+ Pixelate(yorgol, -yoffset, info.xorg + x);
+ MIARCSTEP(yoffset += dyoffset;, yoffset += auxDst;);
+ }
+ } else {
+ while (y < info.h || x < info.w) {
+ MIARCOCTANTSHIFT(dyoffset = auxDst;);
+ if ((x == info.start.x) || (y == info.start.y)) {
+ mask = info.start.mask;
+ info.start = info.altstart;
+ }
+ DoPix(1, yorgl, yoffset, info.xorg + x);
+ DoPix(2, yorgl, yoffset, info.xorgo - x);
+ DoPix(4, yorgol, -yoffset, info.xorgo - x);
+ DoPix(8, yorgol, -yoffset, info.xorg + x);
+ if ((x == info.end.x) || (y == info.end.y)) {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ MIARCSTEP(yoffset += dyoffset;, yoffset += auxDst;);
+ }
+ }
+ if ((x == info.start.x) || (y == info.start.y))
+ mask = info.start.mask;
+ DoPix(1, yorgl, yoffset, info.xorg + x);
+ DoPix(4, yorgol, -yoffset, info.xorgo - x);
+ if (arc->height & 1) {
+ DoPix(2, yorgl, yoffset, info.xorgo - x);
+ DoPix(8, yorgol, -yoffset, info.xorg + x);
+ }
+}
+
+void
+ilbmZeroPolyArcSS(pDraw, pGC, narcs, parcs)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int narcs;
+ xArc *parcs;
+{
+ register xArc *arc;
+ register int i;
+ BoxRec box;
+ RegionPtr cclip;
+
+ cclip = pGC->pCompositeClip;
+ for (arc = parcs, i = narcs; --i >= 0; arc++) {
+ if (miCanZeroArc(arc)) {
+ box.x1 = arc->x + pDraw->x;
+ box.y1 = arc->y + pDraw->y;
+ box.x2 = box.x1 + (int)arc->width + 1;
+ box.y2 = box.y1 + (int)arc->height + 1;
+ if (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN)
+ ilbmZeroArcSS(pDraw, pGC, arc);
+ else
+ miZeroPolyArc(pDraw, pGC, 1, arc);
+ } else
+ miPolyArc(pDraw, pGC, 1, arc);
+ }
+}
diff --git a/nx-X11/programs/Xserver/include/Imakefile b/nx-X11/programs/Xserver/include/Imakefile
new file mode 100644
index 000000000..210067635
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/Imakefile
@@ -0,0 +1,67 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:53:29 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/include/Imakefile,v 3.21 2001/01/17 22:36:56 dawes Exp $
+
+HEADERS = os.h misc.h
+
+#if defined(XorgVersion) || defined(XFree86Version) \
+ || defined(BSDOSArchitecture)
+#if DoLoadableServer
+LinkSourceFile(xf86Module.h,$(XF86COMSRC))
+LinkSourceFile(xf86Opt.h,$(XF86COMSRC))
+#endif
+LinkSourceFile(xf86_libc.h,$(XF86OSSRC))
+LinkSourceFile(xf86_ansic.h,$(XF86OSSRC))
+LinkSourceFile(xf86Version.h,$(XF86SRC))
+LinkSourceFile(compiler.h,$(XF86COMSRC))
+#endif
+
+LinkSourceFile(osdep.h,../os)
+#ifdef cygwinArchitecture
+LinkFile(xxwindow.h,window.h)
+#endif
+
+all::
+
+depend::
+
+InstallDriverSDKNonExecFile(XIstubs.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(bstore.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(bstorestr.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(colormap.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(colormapst.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(cursor.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(cursorstr.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(dix.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(dixstruct.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(exevents.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(extension.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(extnsionst.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(gc.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(gcstruct.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(globals.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(input.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(inputstr.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(misc.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(miscstruct.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(opaque.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(os.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(pixmap.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(pixmapstr.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(property.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(propertyst.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(region.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(regionstr.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(resource.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(screenint.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(scrnintstr.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(servermd.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(validate.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(window.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(windowstr.h,$(DRIVERSDKINCLUDEDIR))
+
+BuildIncludes($(HEADERS),X11,..)
+InstallMultipleFlags($(HEADERS),$(INCDIR)/X11,$(INSTINCFLAGS))
diff --git a/nx-X11/programs/Xserver/include/XIstubs.h b/nx-X11/programs/Xserver/include/XIstubs.h
new file mode 100644
index 000000000..e005493c4
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/XIstubs.h
@@ -0,0 +1,76 @@
+/* $XFree86: xc/programs/Xserver/include/XIstubs.h,v 3.1 1996/04/15 11:34:22 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifndef XI_STUBS_H
+#define XI_STUBS_H 1
+
+int
+ChangeKeyboardDevice (
+ DeviceIntPtr /* old_dev */,
+ DeviceIntPtr /* new_dev */);
+
+int
+ChangePointerDevice (
+ DeviceIntPtr /* old_dev */,
+ DeviceIntPtr /* new_dev */,
+ unsigned char /* x */,
+ unsigned char /* y */);
+
+void
+CloseInputDevice (
+ DeviceIntPtr /* d */,
+ ClientPtr /* client */);
+
+void
+AddOtherInputDevices (void);
+
+void
+OpenInputDevice (
+ DeviceIntPtr /* dev */,
+ ClientPtr /* client */,
+ int * /* status */);
+
+int
+SetDeviceMode (
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ int /* mode */);
+
+int
+SetDeviceValuators (
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ int * /* valuators */,
+ int /* first_valuator */,
+ int /* num_valuators */);
+
+int
+ChangeDeviceControl (
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ xDeviceCtl * /* control */);
+
+#endif /* XI_STUBS_H */
diff --git a/nx-X11/programs/Xserver/include/bstore.h b/nx-X11/programs/Xserver/include/bstore.h
new file mode 100644
index 000000000..098abcd86
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/bstore.h
@@ -0,0 +1,23 @@
+/* $XFree86: xc/programs/Xserver/include/bstore.h,v 1.1 1998/04/05 16:44:25 robin Exp $*/
+/*
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies. The University of
+ * California makes no representations about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied
+ * warranty.
+ */
+
+/*
+ * Moved here from mi to allow wrapping of lower level backing store functions.
+ * -- 1997.10.27 Marc Aurele La France (tsi@xfree86.org)
+ */
+
+#ifndef _BSTORE_H_
+#define _BSTORE_H_
+
+#include "bstorestr.h"
+
+#endif /* _BSTORE_H_ */
diff --git a/nx-X11/programs/Xserver/include/bstorestr.h b/nx-X11/programs/Xserver/include/bstorestr.h
new file mode 100644
index 000000000..8f21855c4
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/bstorestr.h
@@ -0,0 +1,58 @@
+/* $XFree86: xc/programs/Xserver/include/bstorestr.h,v 1.2 2001/01/06 20:58:12 tsi Exp $*/
+/*
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies. The University of
+ * California makes no representations about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied
+ * warranty.
+ */
+
+/*
+ * Moved here from mi to allow wrapping of lower level backing store functions.
+ * -- 1997.10.27 Marc Aurele La France (tsi@xfree86.org)
+ */
+
+#ifndef _BSTORESTR_H_
+#define _BSTORESTR_H_
+
+#include "gc.h"
+#include "pixmap.h"
+#include "region.h"
+#include "window.h"
+
+typedef void (* BackingStoreSaveAreasProcPtr)(
+ PixmapPtr /*pBackingPixmap*/,
+ RegionPtr /*pObscured*/,
+ int /*x*/,
+ int /*y*/,
+ WindowPtr /*pWin*/);
+
+typedef void (* BackingStoreRestoreAreasProcPtr)(
+ PixmapPtr /*pBackingPixmap*/,
+ RegionPtr /*pExposed*/,
+ int /*x*/,
+ int /*y*/,
+ WindowPtr /*pWin*/);
+
+typedef void (* BackingStoreSetClipmaskRgnProcPtr)(
+ GCPtr /*pBackingGC*/,
+ RegionPtr /*pbackingCompositeClip*/);
+
+typedef PixmapPtr (* BackingStoreGetImagePixmapProcPtr)(void);
+
+typedef PixmapPtr (* BackingStoreGetSpansPixmapProcPtr)(void);
+
+typedef struct _BSFuncs {
+
+ BackingStoreSaveAreasProcPtr SaveAreas;
+ BackingStoreRestoreAreasProcPtr RestoreAreas;
+ BackingStoreSetClipmaskRgnProcPtr SetClipmaskRgn;
+ BackingStoreGetImagePixmapProcPtr GetImagePixmap;
+ BackingStoreGetSpansPixmapProcPtr GetSpansPixmap;
+
+} BSFuncRec, *BSFuncPtr;
+
+#endif /* _BSTORESTR_H_ */
diff --git a/nx-X11/programs/Xserver/include/closestr.h b/nx-X11/programs/Xserver/include/closestr.h
new file mode 100644
index 000000000..d70f754b2
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/closestr.h
@@ -0,0 +1,159 @@
+/* $Xorg: closestr.h,v 1.4 2001/02/09 02:05:14 xorgcvs Exp $ */
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/include/closestr.h,v 3.4 2001/12/14 19:59:53 dawes Exp $ */
+
+
+#ifndef CLOSESTR_H
+#define CLOSESTR_H
+
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#include "closure.h"
+#include "dix.h"
+#include "misc.h"
+#include "gcstruct.h"
+
+/* closure structures */
+
+/* OpenFont */
+
+typedef struct _OFclosure {
+ ClientPtr client;
+ short current_fpe;
+ short num_fpes;
+ FontPathElementPtr *fpe_list;
+ Mask flags;
+ Bool slept;
+
+/* XXX -- get these from request buffer instead? */
+ char *origFontName;
+ int origFontNameLen;
+ XID fontid;
+ char *fontname;
+ int fnamelen;
+ FontPtr non_cachable_font;
+} OFclosureRec;
+
+/* ListFontsWithInfo */
+
+#define XLFDMAXFONTNAMELEN 256
+typedef struct _LFWIstate {
+ char pattern[XLFDMAXFONTNAMELEN];
+ int patlen;
+ int current_fpe;
+ int max_names;
+ Bool list_started;
+ pointer private;
+} LFWIstateRec, *LFWIstatePtr;
+
+typedef struct _LFWIclosure {
+ ClientPtr client;
+ int num_fpes;
+ FontPathElementPtr *fpe_list;
+ xListFontsWithInfoReply *reply;
+ int length;
+ LFWIstateRec current;
+ LFWIstateRec saved;
+ int savedNumFonts;
+ Bool haveSaved;
+ Bool slept;
+ char *savedName;
+} LFWIclosureRec;
+
+/* ListFonts */
+
+typedef struct _LFclosure {
+ ClientPtr client;
+ int num_fpes;
+ FontPathElementPtr *fpe_list;
+ FontNamesPtr names;
+ LFWIstateRec current;
+ LFWIstateRec saved;
+ Bool haveSaved;
+ Bool slept;
+ char *savedName;
+ int savedNameLen;
+} LFclosureRec;
+
+/* PolyText */
+
+typedef
+ int (* PolyTextPtr)(
+ DrawablePtr /* pDraw */,
+ GCPtr /* pGC */,
+ int /* x */,
+ int /* y */,
+ int /* count */,
+ void * /* chars or shorts */
+ );
+
+typedef struct _PTclosure {
+ ClientPtr client;
+ DrawablePtr pDraw;
+ GC *pGC;
+ unsigned char *pElt;
+ unsigned char *endReq;
+ unsigned char *data;
+ int xorg;
+ int yorg;
+ CARD8 reqType;
+ PolyTextPtr polyText;
+ int itemSize;
+ XID did;
+ int err;
+ Bool slept;
+} PTclosureRec;
+
+/* ImageText */
+
+typedef
+ void (* ImageTextPtr)(
+ DrawablePtr /* pDraw */,
+ GCPtr /* pGC */,
+ int /* x */,
+ int /* y */,
+ int /* count */,
+ void * /* chars or shorts */
+ );
+
+typedef struct _ITclosure {
+ ClientPtr client;
+ DrawablePtr pDraw;
+ GC *pGC;
+ BYTE nChars;
+ unsigned char *data;
+ int xorg;
+ int yorg;
+ CARD8 reqType;
+ ImageTextPtr imageText;
+ int itemSize;
+ XID did;
+ Bool slept;
+} ITclosureRec;
+#endif /* CLOSESTR_H */
diff --git a/nx-X11/programs/Xserver/include/closure.h b/nx-X11/programs/Xserver/include/closure.h
new file mode 100644
index 000000000..839303c96
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/closure.h
@@ -0,0 +1,58 @@
+/* $Xorg: closure.h,v 1.4 2001/02/09 02:05:14 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef CLOSURE_H
+#define CLOSURE_H 1
+
+typedef struct _LFclosure *LFclosurePtr;
+typedef struct _LFWIclosure *LFWIclosurePtr;
+typedef struct _OFclosure *OFclosurePtr;
+typedef struct _PTclosure *PTclosurePtr;
+typedef struct _ITclosure *ITclosurePtr;
+
+#endif /* CLOSURE_H */
diff --git a/nx-X11/programs/Xserver/include/colormap.h b/nx-X11/programs/Xserver/include/colormap.h
new file mode 100644
index 000000000..1f2c33075
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/colormap.h
@@ -0,0 +1,184 @@
+/* $XFree86: xc/programs/Xserver/include/colormap.h,v 1.5 2001/12/14 19:59:53 dawes Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*/
+/* $Xorg: colormap.h,v 1.4 2001/02/09 02:05:14 xorgcvs Exp $ */
+
+#ifndef CMAP_H
+#define CMAP_H 1
+
+#include <X11/Xproto.h>
+#include "screenint.h"
+#include "window.h"
+
+/* these follow X.h's AllocNone and AllocAll */
+#define CM_PSCREEN 2
+#define CM_PWIN 3
+/* Passed internally in colormap.c */
+#define REDMAP 0
+#define GREENMAP 1
+#define BLUEMAP 2
+#define PSEUDOMAP 3
+#define AllocPrivate (-1)
+#define AllocTemporary (-2)
+#define DynamicClass 1
+
+/* Values for the flags field of a colormap. These should have 1 bit set
+ * and not overlap */
+#define IsDefault 1
+#define AllAllocated 2
+#define BeingCreated 4
+
+
+typedef CARD32 Pixel;
+typedef struct _CMEntry *EntryPtr;
+/* moved to screenint.h: typedef struct _ColormapRec *ColormapPtr */
+typedef struct _colorResource *colorResourcePtr;
+
+extern int CreateColormap(
+ Colormap /*mid*/,
+ ScreenPtr /*pScreen*/,
+ VisualPtr /*pVisual*/,
+ ColormapPtr* /*ppcmap*/,
+ int /*alloc*/,
+ int /*client*/);
+
+extern int FreeColormap(
+ pointer /*pmap*/,
+ XID /*mid*/);
+
+extern int TellLostMap(
+ WindowPtr /*pwin*/,
+ pointer /* Colormap *pmid */);
+
+extern int TellGainedMap(
+ WindowPtr /*pwin*/,
+ pointer /* Colormap *pmid */);
+
+extern int CopyColormapAndFree(
+ Colormap /*mid*/,
+ ColormapPtr /*pSrc*/,
+ int /*client*/);
+
+extern int AllocColor(
+ ColormapPtr /*pmap*/,
+ unsigned short* /*pred*/,
+ unsigned short* /*pgreen*/,
+ unsigned short* /*pblue*/,
+ Pixel* /*pPix*/,
+ int /*client*/);
+
+extern void FakeAllocColor(
+ ColormapPtr /*pmap*/,
+ xColorItem * /*item*/);
+
+extern void FakeFreeColor(
+ ColormapPtr /*pmap*/,
+ Pixel /*pixel*/);
+
+typedef int (*ColorCompareProcPtr)(
+ EntryPtr /*pent*/,
+ xrgb * /*prgb*/);
+
+extern int FindColor(
+ ColormapPtr /*pmap*/,
+ EntryPtr /*pentFirst*/,
+ int /*size*/,
+ xrgb* /*prgb*/,
+ Pixel* /*pPixel*/,
+ int /*channel*/,
+ int /*client*/,
+ ColorCompareProcPtr /*comp*/);
+
+extern int QueryColors(
+ ColormapPtr /*pmap*/,
+ int /*count*/,
+ Pixel* /*ppixIn*/,
+ xrgb* /*prgbList*/);
+
+extern int FreeClientPixels(
+ pointer /*pcr*/,
+ XID /*fakeid*/);
+
+extern int AllocColorCells(
+ int /*client*/,
+ ColormapPtr /*pmap*/,
+ int /*colors*/,
+ int /*planes*/,
+ Bool /*contig*/,
+ Pixel* /*ppix*/,
+ Pixel* /*masks*/);
+
+extern int AllocColorPlanes(
+ int /*client*/,
+ ColormapPtr /*pmap*/,
+ int /*colors*/,
+ int /*r*/,
+ int /*g*/,
+ int /*b*/,
+ Bool /*contig*/,
+ Pixel* /*pixels*/,
+ Pixel* /*prmask*/,
+ Pixel* /*pgmask*/,
+ Pixel* /*pbmask*/);
+
+extern int FreeColors(
+ ColormapPtr /*pmap*/,
+ int /*client*/,
+ int /*count*/,
+ Pixel* /*pixels*/,
+ Pixel /*mask*/);
+
+extern int StoreColors(
+ ColormapPtr /*pmap*/,
+ int /*count*/,
+ xColorItem* /*defs*/);
+
+extern int IsMapInstalled(
+ Colormap /*map*/,
+ WindowPtr /*pWin*/);
+
+#endif /* CMAP_H */
diff --git a/nx-X11/programs/Xserver/include/colormapst.h b/nx-X11/programs/Xserver/include/colormapst.h
new file mode 100644
index 000000000..5ceee9870
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/colormapst.h
@@ -0,0 +1,121 @@
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*/
+/* $Xorg: colormapst.h,v 1.4 2001/02/09 02:05:14 xorgcvs Exp $ */
+
+#ifndef CMAPSTRUCT_H
+#define CMAPSTRUCT_H 1
+
+#include "colormap.h"
+#include "screenint.h"
+
+/* Shared color -- the color is used by AllocColorPlanes */
+typedef struct
+{
+ unsigned short color;
+ short refcnt;
+} SHAREDCOLOR;
+
+/* LOCO -- a local color for a PseudoColor cell. DirectColor maps always
+ * use the first value (called red) in the structure. What channel they
+ * are really talking about depends on which map they are in. */
+typedef struct
+{
+ unsigned short red, green, blue;
+} LOCO;
+
+/* SHCO -- a shared color for a PseudoColor cell. Used with AllocColorPlanes.
+ * DirectColor maps always use the first value (called red) in the structure.
+ * What channel they are really talking about depends on which map they
+ * are in. */
+typedef struct
+{
+ SHAREDCOLOR *red, *green, *blue;
+} SHCO;
+
+
+/* color map entry */
+typedef struct _CMEntry
+{
+ union
+ {
+ LOCO local;
+ SHCO shco;
+ } co;
+ short refcnt;
+ Bool fShared;
+} Entry;
+
+/* COLORMAPs can be used for either Direct or Pseudo color. PseudoColor
+ * only needs one cell table, we arbitrarily pick red. We keep track
+ * of that table with freeRed, numPixelsRed, and clientPixelsRed */
+
+typedef struct _ColormapRec
+{
+ VisualPtr pVisual;
+ short class; /* PseudoColor or DirectColor */
+ long mid; /* client's name for colormap */
+ ScreenPtr pScreen; /* screen map is associated with */
+ short flags; /* 1 = IsDefault
+ * 2 = AllAllocated */
+ int freeRed;
+ int freeGreen;
+ int freeBlue;
+ int *numPixelsRed;
+ int *numPixelsGreen;
+ int *numPixelsBlue;
+ Pixel **clientPixelsRed;
+ Pixel **clientPixelsGreen;
+ Pixel **clientPixelsBlue;
+ Entry *red;
+ Entry *green;
+ Entry *blue;
+ pointer devPriv;
+ DevUnion *devPrivates; /* dynamic devPrivates added after devPriv
+ already existed - must keep devPriv */
+} ColormapRec;
+
+#endif /* COLORMAP_H */
diff --git a/nx-X11/programs/Xserver/include/cursor.h b/nx-X11/programs/Xserver/include/cursor.h
new file mode 100644
index 000000000..9eb799e1c
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/cursor.h
@@ -0,0 +1,149 @@
+/* $XdotOrg: xc/programs/Xserver/include/cursor.h,v 1.6 2005/08/24 11:18:30 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/include/cursor.h,v 1.6 2002/09/17 01:15:14 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: cursor.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+
+#ifndef CURSOR_H
+#define CURSOR_H
+
+#include "misc.h"
+#include "screenint.h"
+#include "window.h"
+
+#define NullCursor ((CursorPtr)NULL)
+
+/* Provide support for alpha composited cursors */
+#ifdef RENDER
+#define ARGB_CURSOR
+#endif
+
+typedef struct _Cursor *CursorPtr;
+typedef struct _CursorMetric *CursorMetricPtr;
+
+extern CursorPtr rootCursor;
+
+extern int FreeCursor(
+ pointer /*pCurs*/,
+ XID /*cid*/);
+
+/* Quartz support on Mac OS X pulls in the QuickDraw
+ framework whose AllocCursor function conflicts here. */
+#ifdef __DARWIN__
+#define AllocCursor Darwin_X_AllocCursor
+#endif
+extern CursorPtr AllocCursor(
+ unsigned char* /*psrcbits*/,
+ unsigned char* /*pmaskbits*/,
+ CursorMetricPtr /*cm*/,
+ unsigned /*foreRed*/,
+ unsigned /*foreGreen*/,
+ unsigned /*foreBlue*/,
+ unsigned /*backRed*/,
+ unsigned /*backGreen*/,
+ unsigned /*backBlue*/);
+
+extern CursorPtr AllocCursorARGB(
+ unsigned char* /*psrcbits*/,
+ unsigned char* /*pmaskbits*/,
+ CARD32* /*argb*/,
+ CursorMetricPtr /*cm*/,
+ unsigned /*foreRed*/,
+ unsigned /*foreGreen*/,
+ unsigned /*foreBlue*/,
+ unsigned /*backRed*/,
+ unsigned /*backGreen*/,
+ unsigned /*backBlue*/);
+
+extern int AllocGlyphCursor(
+ Font /*source*/,
+ unsigned int /*sourceChar*/,
+ Font /*mask*/,
+ unsigned int /*maskChar*/,
+ unsigned /*foreRed*/,
+ unsigned /*foreGreen*/,
+ unsigned /*foreBlue*/,
+ unsigned /*backRed*/,
+ unsigned /*backGreen*/,
+ unsigned /*backBlue*/,
+ CursorPtr* /*ppCurs*/,
+ ClientPtr /*client*/);
+
+extern CursorPtr CreateRootCursor(
+ char* /*pfilename*/,
+ unsigned int /*glyph*/);
+
+extern int ServerBitsFromGlyph(
+ FontPtr /*pfont*/,
+ unsigned int /*ch*/,
+ register CursorMetricPtr /*cm*/,
+ unsigned char ** /*ppbits*/);
+
+extern Bool CursorMetricsFromGlyph(
+ FontPtr /*pfont*/,
+ unsigned /*ch*/,
+ CursorMetricPtr /*cm*/);
+
+extern void CheckCursorConfinement(
+ WindowPtr /*pWin*/);
+
+extern void NewCurrentScreen(
+ ScreenPtr /*newScreen*/,
+ int /*x*/,
+ int /*y*/);
+
+extern Bool PointerConfinedToScreen(void);
+
+extern void GetSpritePosition(
+ int * /*px*/,
+ int * /*py*/);
+
+#ifdef PANORAMIX
+extern int XineramaGetCursorScreen(void);
+#endif /* PANORAMIX */
+
+#endif /* CURSOR_H */
diff --git a/nx-X11/programs/Xserver/include/cursorstr.h b/nx-X11/programs/Xserver/include/cursorstr.h
new file mode 100644
index 000000000..c877d6cc9
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/cursorstr.h
@@ -0,0 +1,98 @@
+/* $Xorg: cursorstr.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/include/cursorstr.h,v 1.8 2002/11/30 06:21:51 keithp Exp $ */
+
+#ifndef CURSORSTRUCT_H
+#define CURSORSTRUCT_H
+
+#include "cursor.h"
+/*
+ * device-independent cursor storage
+ */
+
+/*
+ * source and mask point directly to the bits, which are in the server-defined
+ * bitmap format.
+ */
+typedef struct _CursorBits {
+ unsigned char *source; /* points to bits */
+ unsigned char *mask; /* points to bits */
+ Bool emptyMask; /* all zeros mask */
+ unsigned short width, height, xhot, yhot; /* metrics */
+ int refcnt; /* can be shared */
+ pointer devPriv[MAXSCREENS]; /* set by pScr->RealizeCursor*/
+#ifdef ARGB_CURSOR
+ CARD32 *argb; /* full-color alpha blended */
+#endif
+} CursorBits, *CursorBitsPtr;
+
+typedef struct _Cursor {
+ CursorBitsPtr bits;
+ unsigned short foreRed, foreGreen, foreBlue; /* device-independent color */
+ unsigned short backRed, backGreen, backBlue; /* device-independent color */
+ int refcnt;
+ pointer devPriv[MAXSCREENS]; /* set by pScr->RealizeCursor*/
+#ifdef XFIXES
+ CARD32 serialNumber;
+ Atom name;
+#endif
+} CursorRec;
+
+typedef struct _CursorMetric {
+ unsigned short width, height, xhot, yhot;
+} CursorMetricRec;
+
+typedef struct {
+ int x, y;
+ ScreenPtr pScreen;
+} HotSpot;
+
+#ifdef XEVIE
+extern HotSpot xeviehot;
+#endif
+#endif /* CURSORSTRUCT_H */
diff --git a/nx-X11/programs/Xserver/include/dix.h b/nx-X11/programs/Xserver/include/dix.h
new file mode 100644
index 000000000..1b8fc4265
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/dix.h
@@ -0,0 +1,817 @@
+/* $XFree86: xc/programs/Xserver/include/dix.h,v 3.26 2003/01/12 02:44:27 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: dix.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+
+#ifndef DIX_H
+#define DIX_H
+
+#include "gc.h"
+#include "window.h"
+#include "input.h"
+
+#define EARLIER -1
+#define SAMETIME 0
+#define LATER 1
+
+#define NullClient ((ClientPtr) 0)
+#define REQUEST(type) \
+ register type *stuff = (type *)client->requestBuffer
+
+
+#define REQUEST_SIZE_MATCH(req)\
+ if ((sizeof(req) >> 2) != client->req_len)\
+ return(BadLength)
+
+#define REQUEST_AT_LEAST_SIZE(req) \
+ if ((sizeof(req) >> 2) > client->req_len )\
+ return(BadLength)
+
+#define REQUEST_FIXED_SIZE(req, n)\
+ if (((sizeof(req) >> 2) > client->req_len) || \
+ (((sizeof(req) + (n) + 3) >> 2) != client->req_len)) \
+ return(BadLength)
+
+#define LEGAL_NEW_RESOURCE(id,client)\
+ if (!LegalNewID(id,client)) \
+ {\
+ client->errorValue = id;\
+ return(BadIDChoice);\
+ }
+
+/* XXX if you are using this macro, you are probably not generating Match
+ * errors where appropriate */
+#define LOOKUP_DRAWABLE(did, client)\
+ ((client->lastDrawableID == did) ? \
+ client->lastDrawable : (DrawablePtr)LookupDrawable(did, client))
+
+#ifdef XCSECURITY
+
+#define SECURITY_VERIFY_DRAWABLE(pDraw, did, client, mode)\
+ if (client->lastDrawableID == did && !client->trustLevel)\
+ pDraw = client->lastDrawable;\
+ else \
+ {\
+ pDraw = (DrawablePtr) SecurityLookupIDByClass(client, did, \
+ RC_DRAWABLE, mode);\
+ if (!pDraw) \
+ {\
+ client->errorValue = did; \
+ return BadDrawable;\
+ }\
+ if (pDraw->type == UNDRAWABLE_WINDOW)\
+ return BadMatch;\
+ }
+
+#define SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, mode)\
+ if (client->lastDrawableID == did && !client->trustLevel)\
+ pDraw = client->lastDrawable;\
+ else \
+ {\
+ pDraw = (DrawablePtr) SecurityLookupIDByClass(client, did, \
+ RC_DRAWABLE, mode);\
+ if (!pDraw) \
+ {\
+ client->errorValue = did; \
+ return BadDrawable;\
+ }\
+ }
+
+#define SECURITY_VERIFY_GC(pGC, rid, client, mode)\
+ if (client->lastGCID == rid && !client->trustLevel)\
+ pGC = client->lastGC;\
+ else\
+ pGC = (GC *) SecurityLookupIDByType(client, rid, RT_GC, mode);\
+ if (!pGC)\
+ {\
+ client->errorValue = rid;\
+ return (BadGC);\
+ }
+
+#define VERIFY_DRAWABLE(pDraw, did, client)\
+ SECURITY_VERIFY_DRAWABLE(pDraw, did, client, SecurityUnknownAccess)
+
+#define VERIFY_GEOMETRABLE(pDraw, did, client)\
+ SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, SecurityUnknownAccess)
+
+#define VERIFY_GC(pGC, rid, client)\
+ SECURITY_VERIFY_GC(pGC, rid, client, SecurityUnknownAccess)
+
+#else /* not XCSECURITY */
+
+#define VERIFY_DRAWABLE(pDraw, did, client)\
+ if (client->lastDrawableID == did)\
+ pDraw = client->lastDrawable;\
+ else \
+ {\
+ pDraw = (DrawablePtr) LookupIDByClass(did, RC_DRAWABLE);\
+ if (!pDraw) \
+ {\
+ client->errorValue = did; \
+ return BadDrawable;\
+ }\
+ if (pDraw->type == UNDRAWABLE_WINDOW)\
+ return BadMatch;\
+ }
+
+#define VERIFY_GEOMETRABLE(pDraw, did, client)\
+ if (client->lastDrawableID == did)\
+ pDraw = client->lastDrawable;\
+ else \
+ {\
+ pDraw = (DrawablePtr) LookupIDByClass(did, RC_DRAWABLE);\
+ if (!pDraw) \
+ {\
+ client->errorValue = did; \
+ return BadDrawable;\
+ }\
+ }
+
+#define VERIFY_GC(pGC, rid, client)\
+ if (client->lastGCID == rid)\
+ pGC = client->lastGC;\
+ else\
+ pGC = (GC *)LookupIDByType(rid, RT_GC);\
+ if (!pGC)\
+ {\
+ client->errorValue = rid;\
+ return (BadGC);\
+ }
+
+#define SECURITY_VERIFY_DRAWABLE(pDraw, did, client, mode)\
+ VERIFY_DRAWABLE(pDraw, did, client)
+
+#define SECURITY_VERIFY_GEOMETRABLE(pDraw, did, client, mode)\
+ VERIFY_GEOMETRABLE(pDraw, did, client)
+
+#define SECURITY_VERIFY_GC(pGC, rid, client, mode)\
+ VERIFY_GC(pGC, rid, client)
+
+#endif /* XCSECURITY */
+
+/*
+ * We think that most hardware implementations of DBE will want
+ * LookupID*(dbe_back_buffer_id) to return the window structure that the
+ * id is a back buffer for. Since both front and back buffers will
+ * return the same structure, you need to be able to distinguish
+ * somewhere what kind of buffer (front/back) was being asked for, so
+ * that ddx can render to the right place. That's the problem that the
+ * following code solves. Note: we couldn't embed this in the LookupID*
+ * functions because the VALIDATE_DRAWABLE_AND_GC macro often circumvents
+ * those functions by checking a one-element cache. That's why we're
+ * mucking with VALIDATE_DRAWABLE_AND_GC.
+ *
+ * If you put -DNEED_DBE_BUF_BITS into PervasiveDBEDefines, the window
+ * structure will have two additional bits defined, srcBuffer and
+ * dstBuffer, and their values will be maintained via the macros
+ * SET_DBE_DSTBUF and SET_DBE_SRCBUF (below). If you also
+ * put -DNEED_DBE_BUF_VALIDATE into PervasiveDBEDefines, the function
+ * DbeValidateBuffer will be called any time the bits change to give you
+ * a chance to do some setup. See the DBE code for more details on this
+ * function. We put in these levels of conditionality so that you can do
+ * just what you need to do, and no more. If neither of these defines
+ * are used, the bits won't be there, and VALIDATE_DRAWABLE_AND_GC will
+ * be unchanged. dpw
+ */
+
+#if defined(NEED_DBE_BUF_BITS)
+#define SET_DBE_DSTBUF(_pDraw, _drawID) \
+ SET_DBE_BUF(_pDraw, _drawID, dstBuffer, TRUE)
+#define SET_DBE_SRCBUF(_pDraw, _drawID) \
+ SET_DBE_BUF(_pDraw, _drawID, srcBuffer, FALSE)
+#if defined (NEED_DBE_BUF_VALIDATE)
+#define SET_DBE_BUF(_pDraw, _drawID, _whichBuffer, _dstbuf) \
+ if (_pDraw->type == DRAWABLE_WINDOW)\
+ {\
+ int thisbuf = (_pDraw->id == _drawID);\
+ if (thisbuf != ((WindowPtr)_pDraw)->_whichBuffer)\
+ {\
+ ((WindowPtr)_pDraw)->_whichBuffer = thisbuf;\
+ DbeValidateBuffer((WindowPtr)_pDraw, _drawID, _dstbuf);\
+ }\
+ }
+#else /* want buffer bits, but don't need to call DbeValidateBuffer */
+#define SET_DBE_BUF(_pDraw, _drawID, _whichBuffer, _dstbuf) \
+ if (_pDraw->type == DRAWABLE_WINDOW)\
+ {\
+ ((WindowPtr)_pDraw)->_whichBuffer = (_pDraw->id == _drawID);\
+ }
+#endif /* NEED_DBE_BUF_VALIDATE */
+#else /* don't want buffer bits in window */
+#define SET_DBE_DSTBUF(_pDraw, _drawID) /**/
+#define SET_DBE_SRCBUF(_pDraw, _drawID) /**/
+#endif /* NEED_DBE_BUF_BITS */
+
+#define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, pGC, client)\
+ if ((stuff->gc == INVALID) || (client->lastGCID != stuff->gc) ||\
+ (client->lastDrawableID != drawID))\
+ {\
+ SECURITY_VERIFY_GEOMETRABLE(pDraw, drawID, client, SecurityWriteAccess);\
+ SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityReadAccess);\
+ if ((pGC->depth != pDraw->depth) ||\
+ (pGC->pScreen != pDraw->pScreen))\
+ return (BadMatch);\
+ client->lastDrawable = pDraw;\
+ client->lastDrawableID = drawID;\
+ client->lastGC = pGC;\
+ client->lastGCID = stuff->gc;\
+ }\
+ else\
+ {\
+ pGC = client->lastGC;\
+ pDraw = client->lastDrawable;\
+ }\
+ SET_DBE_DSTBUF(pDraw, drawID);\
+ if (pGC->serialNumber != pDraw->serialNumber)\
+ ValidateGC(pDraw, pGC);
+
+
+#define WriteReplyToClient(pClient, size, pReply) { \
+ if ((pClient)->swapped) \
+ (*ReplySwapVector[((xReq *)(pClient)->requestBuffer)->reqType]) \
+ (pClient, (int)(size), pReply); \
+ else (void) WriteToClient(pClient, (int)(size), (char *)(pReply)); }
+
+#define WriteSwappedDataToClient(pClient, size, pbuf) \
+ if ((pClient)->swapped) \
+ (*(pClient)->pSwapReplyFunc)(pClient, (int)(size), pbuf); \
+ else (void) WriteToClient (pClient, (int)(size), (char *)(pbuf));
+
+typedef struct _TimeStamp *TimeStampPtr;
+
+#ifndef _XTYPEDEF_CLIENTPTR
+typedef struct _Client *ClientPtr; /* also in misc.h */
+#define _XTYPEDEF_CLIENTPTR
+#endif
+
+typedef struct _WorkQueue *WorkQueuePtr;
+
+extern ClientPtr requestingClient;
+extern ClientPtr *clients;
+extern ClientPtr serverClient;
+extern int currentMaxClients;
+
+typedef int HWEventQueueType;
+typedef HWEventQueueType* HWEventQueuePtr;
+
+extern HWEventQueuePtr checkForInput[2];
+
+typedef struct _TimeStamp {
+ CARD32 months; /* really ~49.7 days */
+ CARD32 milliseconds;
+} TimeStamp;
+
+/* dispatch.c */
+
+extern void SetInputCheck(
+ HWEventQueuePtr /*c0*/,
+ HWEventQueuePtr /*c1*/);
+
+extern void CloseDownClient(
+ ClientPtr /*client*/);
+
+extern void UpdateCurrentTime(void);
+
+extern void UpdateCurrentTimeIf(void);
+
+extern void InitSelections(void);
+
+extern void FlushClientCaches(XID /*id*/);
+
+extern int dixDestroyPixmap(
+ pointer /*value*/,
+ XID /*pid*/);
+
+extern void CloseDownRetainedResources(void);
+
+extern void InitClient(
+ ClientPtr /*client*/,
+ int /*i*/,
+ pointer /*ospriv*/);
+
+extern ClientPtr NextAvailableClient(
+ pointer /*ospriv*/);
+
+extern void SendErrorToClient(
+ ClientPtr /*client*/,
+ unsigned int /*majorCode*/,
+ unsigned int /*minorCode*/,
+ XID /*resId*/,
+ int /*errorCode*/);
+
+extern void DeleteWindowFromAnySelections(
+ WindowPtr /*pWin*/);
+
+extern void MarkClientException(
+ ClientPtr /*client*/);
+
+extern int GetGeometry(
+ ClientPtr /*client*/,
+ xGetGeometryReply* /* wa */);
+
+extern int SendConnSetup(
+ ClientPtr /*client*/,
+ char* /*reason*/);
+
+extern int DoGetImage(
+ ClientPtr /*client*/,
+ int /*format*/,
+ Drawable /*drawable*/,
+ int /*x*/,
+ int /*y*/,
+ int /*width*/,
+ int /*height*/,
+ Mask /*planemask*/,
+ xGetImageReply ** /*im_return*/);
+
+#ifdef LBX
+extern void IncrementClientCount(void);
+#endif /* LBX */
+
+#if defined(DDXBEFORERESET)
+extern void ddxBeforeReset (void);
+#endif
+
+/* dixutils.c */
+
+extern void CopyISOLatin1Lowered(
+ unsigned char * /*dest*/,
+ unsigned char * /*source*/,
+ int /*length*/);
+
+extern int CompareISOLatin1Lowered(
+ unsigned char * /*a*/,
+ int alen,
+ unsigned char * /*b*/,
+ int blen);
+
+#ifdef XCSECURITY
+
+extern WindowPtr SecurityLookupWindow(
+ XID /*rid*/,
+ ClientPtr /*client*/,
+ Mask /*access_mode*/);
+
+extern pointer SecurityLookupDrawable(
+ XID /*rid*/,
+ ClientPtr /*client*/,
+ Mask /*access_mode*/);
+
+extern WindowPtr LookupWindow(
+ XID /*rid*/,
+ ClientPtr /*client*/);
+
+extern pointer LookupDrawable(
+ XID /*rid*/,
+ ClientPtr /*client*/);
+
+#else
+
+extern WindowPtr LookupWindow(
+ XID /*rid*/,
+ ClientPtr /*client*/);
+
+extern pointer LookupDrawable(
+ XID /*rid*/,
+ ClientPtr /*client*/);
+
+#define SecurityLookupWindow(rid, client, access_mode) \
+ LookupWindow(rid, client)
+
+#define SecurityLookupDrawable(rid, client, access_mode) \
+ LookupDrawable(rid, client)
+
+#endif /* XCSECURITY */
+
+extern ClientPtr LookupClient(
+ XID /*rid*/,
+ ClientPtr /*client*/);
+
+extern void NoopDDA(void);
+
+extern int AlterSaveSetForClient(
+ ClientPtr /*client*/,
+ WindowPtr /*pWin*/,
+ unsigned /*mode*/,
+ Bool /*toRoot*/,
+ Bool /*remap*/);
+
+extern void DeleteWindowFromAnySaveSet(
+ WindowPtr /*pWin*/);
+
+extern void BlockHandler(
+ pointer /*pTimeout*/,
+ pointer /*pReadmask*/);
+
+extern void WakeupHandler(
+ int /*result*/,
+ pointer /*pReadmask*/);
+
+typedef void (* WakeupHandlerProcPtr)(
+ pointer /* blockData */,
+ int /* result */,
+ pointer /* pReadmask */);
+
+extern Bool RegisterBlockAndWakeupHandlers(
+ BlockHandlerProcPtr /*blockHandler*/,
+ WakeupHandlerProcPtr /*wakeupHandler*/,
+ pointer /*blockData*/);
+
+extern void RemoveBlockAndWakeupHandlers(
+ BlockHandlerProcPtr /*blockHandler*/,
+ WakeupHandlerProcPtr /*wakeupHandler*/,
+ pointer /*blockData*/);
+
+extern void InitBlockAndWakeupHandlers(void);
+
+extern void ProcessWorkQueue(void);
+
+extern void ProcessWorkQueueZombies(void);
+
+extern Bool QueueWorkProc(
+ Bool (* /*function*/)(
+ ClientPtr /*clientUnused*/,
+ pointer /*closure*/),
+ ClientPtr /*client*/,
+ pointer /*closure*/
+);
+
+typedef Bool (* ClientSleepProcPtr)(
+ ClientPtr /*client*/,
+ pointer /*closure*/);
+
+extern Bool ClientSleep(
+ ClientPtr /*client*/,
+ ClientSleepProcPtr /* function */,
+ pointer /*closure*/);
+
+#ifndef ___CLIENTSIGNAL_DEFINED___
+#define ___CLIENTSIGNAL_DEFINED___
+extern Bool ClientSignal(
+ ClientPtr /*client*/);
+#endif /* ___CLIENTSIGNAL_DEFINED___ */
+
+extern void ClientWakeup(
+ ClientPtr /*client*/);
+
+extern Bool ClientIsAsleep(
+ ClientPtr /*client*/);
+
+/* atom.c */
+
+extern Atom MakeAtom(
+ char * /*string*/,
+ unsigned /*len*/,
+ Bool /*makeit*/);
+
+extern Bool ValidAtom(
+ Atom /*atom*/);
+
+extern char *NameForAtom(
+ Atom /*atom*/);
+
+extern void AtomError(void);
+
+extern void FreeAllAtoms(void);
+
+extern void InitAtoms(void);
+
+/* events.c */
+
+extern void SetMaskForEvent(
+ Mask /* mask */,
+ int /* event */);
+
+
+extern Bool IsParent(
+ WindowPtr /* maybeparent */,
+ WindowPtr /* child */);
+
+extern WindowPtr GetCurrentRootWindow(void);
+
+extern WindowPtr GetSpriteWindow(void);
+
+
+extern void NoticeEventTime(xEventPtr /* xE */);
+
+extern void EnqueueEvent(
+ xEventPtr /* xE */,
+ DeviceIntPtr /* device */,
+ int /* count */);
+
+extern void ComputeFreezes(void);
+
+extern void CheckGrabForSyncs(
+ DeviceIntPtr /* dev */,
+ Bool /* thisMode */,
+ Bool /* otherMode */);
+
+extern void ActivatePointerGrab(
+ DeviceIntPtr /* mouse */,
+ GrabPtr /* grab */,
+ TimeStamp /* time */,
+ Bool /* autoGrab */);
+
+extern void DeactivatePointerGrab(
+ DeviceIntPtr /* mouse */);
+
+extern void ActivateKeyboardGrab(
+ DeviceIntPtr /* keybd */,
+ GrabPtr /* grab */,
+ TimeStamp /* time */,
+ Bool /* passive */);
+
+extern void DeactivateKeyboardGrab(
+ DeviceIntPtr /* keybd */);
+
+extern void AllowSome(
+ ClientPtr /* client */,
+ TimeStamp /* time */,
+ DeviceIntPtr /* thisDev */,
+ int /* newState */);
+
+extern void ReleaseActiveGrabs(
+ ClientPtr client);
+
+extern int DeliverEventsToWindow(
+ WindowPtr /* pWin */,
+ xEventPtr /* pEvents */,
+ int /* count */,
+ Mask /* filter */,
+ GrabPtr /* grab */,
+ int /* mskidx */);
+
+extern int DeliverDeviceEvents(
+ WindowPtr /* pWin */,
+ xEventPtr /* xE */,
+ GrabPtr /* grab */,
+ WindowPtr /* stopAt */,
+ DeviceIntPtr /* dev */,
+ int /* count */);
+
+extern void DefineInitialRootWindow(
+ WindowPtr /* win */);
+
+extern void WindowHasNewCursor(
+ WindowPtr /* pWin */);
+
+extern Bool CheckDeviceGrabs(
+ DeviceIntPtr /* device */,
+ xEventPtr /* xE */,
+ int /* checkFirst */,
+ int /* count */);
+
+extern void DeliverFocusedEvent(
+ DeviceIntPtr /* keybd */,
+ xEventPtr /* xE */,
+ WindowPtr /* window */,
+ int /* count */);
+
+extern void DeliverGrabbedEvent(
+ xEventPtr /* xE */,
+ DeviceIntPtr /* thisDev */,
+ Bool /* deactivateGrab */,
+ int /* count */);
+
+#ifdef XKB
+extern void FixKeyState(
+ xEvent * /* xE */,
+ DeviceIntPtr /* keybd */);
+#endif /* XKB */
+
+extern void RecalculateDeliverableEvents(
+ WindowPtr /* pWin */);
+
+extern int OtherClientGone(
+ pointer /* value */,
+ XID /* id */);
+
+extern void DoFocusEvents(
+ DeviceIntPtr /* dev */,
+ WindowPtr /* fromWin */,
+ WindowPtr /* toWin */,
+ int /* mode */);
+
+extern int SetInputFocus(
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ Window /* focusID */,
+ CARD8 /* revertTo */,
+ Time /* ctime */,
+ Bool /* followOK */);
+
+extern int GrabDevice(
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ unsigned /* this_mode */,
+ unsigned /* other_mode */,
+ Window /* grabWindow */,
+ unsigned /* ownerEvents */,
+ Time /* ctime */,
+ Mask /* mask */,
+ CARD8 * /* status */);
+
+extern void InitEvents(void);
+
+extern void CloseDownEvents(void);
+
+extern void DeleteWindowFromAnyEvents(
+ WindowPtr /* pWin */,
+ Bool /* freeResources */);
+
+
+extern Mask EventMaskForClient(
+ WindowPtr /* pWin */,
+ ClientPtr /* client */);
+
+
+
+extern int DeliverEvents(
+ WindowPtr /*pWin*/,
+ xEventPtr /*xE*/,
+ int /*count*/,
+ WindowPtr /*otherParent*/);
+
+
+extern void WriteEventsToClient(
+ ClientPtr /*pClient*/,
+ int /*count*/,
+ xEventPtr /*events*/);
+
+extern int TryClientEvents(
+ ClientPtr /*client*/,
+ xEventPtr /*pEvents*/,
+ int /*count*/,
+ Mask /*mask*/,
+ Mask /*filter*/,
+ GrabPtr /*grab*/);
+
+extern void WindowsRestructured(void);
+
+
+#ifdef RANDR
+void
+ScreenRestructured (ScreenPtr pScreen);
+#endif
+
+extern void ResetClientPrivates(void);
+
+extern int AllocateClientPrivateIndex(void);
+
+extern Bool AllocateClientPrivate(
+ int /*index*/,
+ unsigned /*amount*/);
+
+/*
+ * callback manager stuff
+ */
+
+#ifndef _XTYPEDEF_CALLBACKLISTPTR
+typedef struct _CallbackList *CallbackListPtr; /* also in misc.h */
+#define _XTYPEDEF_CALLBACKLISTPTR
+#endif
+
+typedef void (*CallbackProcPtr) (
+ CallbackListPtr *, pointer, pointer);
+
+typedef Bool (*AddCallbackProcPtr) (
+ CallbackListPtr *, CallbackProcPtr, pointer);
+
+typedef Bool (*DeleteCallbackProcPtr) (
+ CallbackListPtr *, CallbackProcPtr, pointer);
+
+typedef void (*CallCallbacksProcPtr) (
+ CallbackListPtr *, pointer);
+
+typedef void (*DeleteCallbackListProcPtr) (
+ CallbackListPtr *);
+
+typedef struct _CallbackProcs {
+ AddCallbackProcPtr AddCallback;
+ DeleteCallbackProcPtr DeleteCallback;
+ CallCallbacksProcPtr CallCallbacks;
+ DeleteCallbackListProcPtr DeleteCallbackList;
+} CallbackFuncsRec, *CallbackFuncsPtr;
+
+extern Bool CreateCallbackList(
+ CallbackListPtr * /*pcbl*/,
+ CallbackFuncsPtr /*cbfuncs*/);
+
+extern Bool AddCallback(
+ CallbackListPtr * /*pcbl*/,
+ CallbackProcPtr /*callback*/,
+ pointer /*data*/);
+
+extern Bool DeleteCallback(
+ CallbackListPtr * /*pcbl*/,
+ CallbackProcPtr /*callback*/,
+ pointer /*data*/);
+
+extern void CallCallbacks(
+ CallbackListPtr * /*pcbl*/,
+ pointer /*call_data*/);
+
+extern void DeleteCallbackList(
+ CallbackListPtr * /*pcbl*/);
+
+extern void InitCallbackManager(void);
+
+/*
+ * ServerGrabCallback stuff
+ */
+
+extern CallbackListPtr ServerGrabCallback;
+
+typedef enum {SERVER_GRABBED, SERVER_UNGRABBED,
+ CLIENT_PERVIOUS, CLIENT_IMPERVIOUS } ServerGrabState;
+
+typedef struct {
+ ClientPtr client;
+ ServerGrabState grabstate;
+} ServerGrabInfoRec;
+
+/*
+ * EventCallback stuff
+ */
+
+extern CallbackListPtr EventCallback;
+
+typedef struct {
+ ClientPtr client;
+ xEventPtr events;
+ int count;
+} EventInfoRec;
+
+/*
+ * DeviceEventCallback stuff
+ */
+
+extern CallbackListPtr DeviceEventCallback;
+
+typedef struct {
+ xEventPtr events;
+ int count;
+} DeviceEventInfoRec;
+
+/*
+ * SelectionCallback stuff
+ */
+
+extern CallbackListPtr SelectionCallback;
+
+typedef enum {
+ SelectionSetOwner,
+ SelectionWindowDestroy,
+ SelectionClientClose
+} SelectionCallbackKind;
+
+typedef struct {
+ struct _Selection *selection;
+ SelectionCallbackKind kind;
+} SelectionInfoRec;
+
+#endif /* DIX_H */
diff --git a/nx-X11/programs/Xserver/include/dixevents.h b/nx-X11/programs/Xserver/include/dixevents.h
new file mode 100644
index 000000000..46a5faef0
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/dixevents.h
@@ -0,0 +1,106 @@
+/* $XFree86: xc/programs/Xserver/include/dixevents.h,v 3.4 2001/09/04 14:03:27 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifndef DIXEVENTS_H
+#define DIXEVENTS_H
+
+extern void SetCriticalEvent(int /* event */);
+
+extern CursorPtr GetSpriteCursor(void);
+
+extern int ProcAllowEvents(ClientPtr /* client */);
+
+extern int MaybeDeliverEventsToClient(
+ WindowPtr /* pWin */,
+ xEvent * /* pEvents */,
+ int /* count */,
+ Mask /* filter */,
+ ClientPtr /* dontClient */);
+
+extern int ProcWarpPointer(ClientPtr /* client */);
+
+#if 0
+extern void
+#ifdef XKB
+CoreProcessKeyboardEvent (
+#else
+ProcessKeyboardEvent (
+#endif
+ xEvent * /* xE */,
+ DeviceIntPtr /* keybd */,
+ int /* count */);
+
+extern void
+#ifdef XKB
+CoreProcessPointerEvent (
+#else
+ProcessPointerEvent (
+#endif
+ xEvent * /* xE */,
+ DeviceIntPtr /* mouse */,
+ int /* count */);
+#endif
+
+extern int EventSelectForWindow(
+ WindowPtr /* pWin */,
+ ClientPtr /* client */,
+ Mask /* mask */);
+
+extern int EventSuppressForWindow(
+ WindowPtr /* pWin */,
+ ClientPtr /* client */,
+ Mask /* mask */,
+ Bool * /* checkOptional */);
+
+extern int ProcSetInputFocus(ClientPtr /* client */);
+
+extern int ProcGetInputFocus(ClientPtr /* client */);
+
+extern int ProcGrabPointer(ClientPtr /* client */);
+
+extern int ProcChangeActivePointerGrab(ClientPtr /* client */);
+
+extern int ProcUngrabPointer(ClientPtr /* client */);
+
+extern int ProcGrabKeyboard(ClientPtr /* client */);
+
+extern int ProcUngrabKeyboard(ClientPtr /* client */);
+
+extern int ProcQueryPointer(ClientPtr /* client */);
+
+extern int ProcSendEvent(ClientPtr /* client */);
+
+extern int ProcUngrabKey(ClientPtr /* client */);
+
+extern int ProcGrabKey(ClientPtr /* client */);
+
+extern int ProcGrabButton(ClientPtr /* client */);
+
+extern int ProcUngrabButton(ClientPtr /* client */);
+
+extern int ProcRecolorCursor(ClientPtr /* client */);
+
+#endif /* DIXEVENTS_H */
diff --git a/nx-X11/programs/Xserver/include/dixfont.h b/nx-X11/programs/Xserver/include/dixfont.h
new file mode 100644
index 000000000..c6b8676da
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/dixfont.h
@@ -0,0 +1,155 @@
+/* $Xorg: dixfont.h,v 1.3 2000/08/17 19:53:29 cpqbld Exp $ */
+/***********************************************************
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/include/dixfont.h,v 3.7 2001/02/02 21:39:02 herrb Exp $ */
+
+#ifndef DIXFONT_H
+#define DIXFONT_H 1
+
+#include "dix.h"
+#include <X11/fonts/font.h>
+#include "closure.h"
+#include <X11/fonts/fontstruct.h>
+
+#define NullDIXFontProp ((DIXFontPropPtr)0)
+
+typedef struct _DIXFontProp *DIXFontPropPtr;
+
+extern FPEFunctions *fpe_functions;
+
+extern int FontToXError(int /*err*/);
+
+extern Bool SetDefaultFont(char * /*defaultfontname*/);
+
+extern void QueueFontWakeup(FontPathElementPtr /*fpe*/);
+
+extern void RemoveFontWakeup(FontPathElementPtr /*fpe*/);
+
+extern void FontWakeup(pointer /*data*/,
+ int /*count*/,
+ pointer /*LastSelectMask*/);
+
+extern int OpenFont(ClientPtr /*client*/,
+ XID /*fid*/,
+ Mask /*flags*/,
+ unsigned /*lenfname*/,
+ char * /*pfontname*/);
+
+extern int CloseFont(pointer /*pfont*/,
+ XID /*fid*/);
+
+typedef struct _xQueryFontReply *xQueryFontReplyPtr;
+
+extern void QueryFont(FontPtr /*pFont*/,
+ xQueryFontReplyPtr /*pReply*/,
+ int /*nProtoCCIStructs*/);
+
+extern int ListFonts(ClientPtr /*client*/,
+ unsigned char * /*pattern*/,
+ unsigned int /*length*/,
+ unsigned int /*max_names*/);
+
+int
+doListFontsWithInfo(ClientPtr /*client*/,
+ LFWIclosurePtr /*c*/);
+
+extern int doPolyText(ClientPtr /*client*/,
+ PTclosurePtr /*c*/
+);
+
+extern int PolyText(ClientPtr /*client*/,
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ unsigned char * /*pElt*/,
+ unsigned char * /*endReq*/,
+ int /*xorg*/,
+ int /*yorg*/,
+ int /*reqType*/,
+ XID /*did*/);
+
+extern int doImageText(ClientPtr /*client*/,
+ ITclosurePtr /*c*/);
+
+extern int ImageText(ClientPtr /*client*/,
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*nChars*/,
+ unsigned char * /*data*/,
+ int /*xorg*/,
+ int /*yorg*/,
+ int /*reqType*/,
+ XID /*did*/);
+
+extern int SetFontPath(ClientPtr /*client*/,
+ int /*npaths*/,
+ unsigned char * /*paths*/,
+ int * /*error*/);
+
+extern int SetDefaultFontPath(char * /*path*/);
+
+extern unsigned char *GetFontPath(int * /*count*/,
+ int * /*length*/);
+
+extern int LoadGlyphs(ClientPtr /*client*/,
+ FontPtr /*pfont*/,
+ unsigned /*nchars*/,
+ int /*item_size*/,
+ unsigned char * /*data*/);
+
+extern void DeleteClientFontStuff(ClientPtr /*client*/);
+
+/* Quartz support on Mac OS X pulls in the QuickDraw
+ framework whose InitFonts function conflicts here. */
+#ifdef __DARWIN__
+#define InitFonts Darwin_X_InitFonts
+#endif
+extern void InitFonts(void);
+
+extern void FreeFonts(void);
+
+extern FontPtr find_old_font(XID /*id*/);
+
+extern void GetGlyphs(FontPtr /*font*/,
+ unsigned long /*count*/,
+ unsigned char * /*chars*/,
+ FontEncoding /*fontEncoding*/,
+ unsigned long * /*glyphcount*/,
+ CharInfoPtr * /*glyphs*/);
+
+extern void QueryGlyphExtents(FontPtr /*pFont*/,
+ CharInfoPtr * /*charinfo*/,
+ unsigned long /*count*/,
+ ExtentInfoPtr /*info*/);
+
+extern Bool QueryTextExtents(FontPtr /*pFont*/,
+ unsigned long /*count*/,
+ unsigned char * /*chars*/,
+ ExtentInfoPtr /*info*/);
+
+extern Bool ParseGlyphCachingMode(char * /*str*/);
+
+extern void InitGlyphCaching(void);
+
+extern void SetGlyphCachingMode(int /*newmode*/);
+
+#endif /* DIXFONT_H */
diff --git a/nx-X11/programs/Xserver/include/dixfontstr.h b/nx-X11/programs/Xserver/include/dixfontstr.h
new file mode 100644
index 000000000..948bf1adb
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/dixfontstr.h
@@ -0,0 +1,95 @@
+/* $Xorg: dixfontstr.h,v 1.3 2000/08/17 19:53:29 cpqbld Exp $ */
+/***********************************************************
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef DIXFONTSTRUCT_H
+#define DIXFONTSTRUCT_H
+
+#include "servermd.h"
+#include "dixfont.h"
+#include <X11/fonts/fontstruct.h>
+#include "closure.h"
+#define NEED_REPLIES
+#include <X11/Xproto.h> /* for xQueryFontReply */
+
+#define FONTCHARSET(font) (font)
+#define FONTMAXBOUNDS(font,field) (font)->info.maxbounds.field
+#define FONTMINBOUNDS(font,field) (font)->info.minbounds.field
+#define TERMINALFONT(font) (font)->info.terminalFont
+#define FONTASCENT(font) (font)->info.fontAscent
+#define FONTDESCENT(font) (font)->info.fontDescent
+#define FONTGLYPHS(font) 0
+#define FONTCONSTMETRICS(font) (font)->info.constantMetrics
+#define FONTCONSTWIDTH(font) (font)->info.constantWidth
+#define FONTALLEXIST(font) (font)->info.allExist
+#define FONTFIRSTCOL(font) (font)->info.firstCol
+#define FONTLASTCOL(font) (font)->info.lastCol
+#define FONTFIRSTROW(font) (font)->info.firstRow
+#define FONTLASTROW(font) (font)->info.lastRow
+#define FONTDEFAULTCH(font) (font)->info.defaultCh
+#define FONTINKMIN(font) (&((font)->info.ink_minbounds))
+#define FONTINKMAX(font) (&((font)->info.ink_maxbounds))
+#define FONTPROPS(font) (font)->info.props
+#define FONTGLYPHBITS(base,pci) ((unsigned char *) (pci)->bits)
+#define FONTINFONPROPS(font) (font)->info.nprops
+
+/* some things haven't changed names, but we'll be careful anyway */
+
+#define FONTREFCNT(font) (font)->refcnt
+
+/*
+ * for linear char sets
+ */
+#define N1dChars(pfont) (FONTLASTCOL(pfont) - FONTFIRSTCOL(pfont) + 1)
+
+/*
+ * for 2D char sets
+ */
+#define N2dChars(pfont) (N1dChars(pfont) * \
+ (FONTLASTROW(pfont) - FONTFIRSTROW(pfont) + 1))
+
+#ifndef GLYPHPADBYTES
+#define GLYPHPADBYTES -1
+#endif
+
+#if GLYPHPADBYTES == 0 || GLYPHPADBYTES == 1
+#define GLYPHWIDTHBYTESPADDED(pci) (GLYPHWIDTHBYTES(pci))
+#define PADGLYPHWIDTHBYTES(w) (((w)+7)>>3)
+#endif
+
+#if GLYPHPADBYTES == 2
+#define GLYPHWIDTHBYTESPADDED(pci) ((GLYPHWIDTHBYTES(pci)+1) & ~0x1)
+#define PADGLYPHWIDTHBYTES(w) (((((w)+7)>>3)+1) & ~0x1)
+#endif
+
+#if GLYPHPADBYTES == 4
+#define GLYPHWIDTHBYTESPADDED(pci) ((GLYPHWIDTHBYTES(pci)+3) & ~0x3)
+#define PADGLYPHWIDTHBYTES(w) (((((w)+7)>>3)+3) & ~0x3)
+#endif
+
+#if GLYPHPADBYTES == 8 /* for a cray? */
+#define GLYPHWIDTHBYTESPADDED(pci) ((GLYPHWIDTHBYTES(pci)+7) & ~0x7)
+#define PADGLYPHWIDTHBYTES(w) (((((w)+7)>>3)+7) & ~0x7)
+#endif
+
+#endif /* DIXFONTSTRUCT_H */
diff --git a/nx-X11/programs/Xserver/include/dixgrabs.h b/nx-X11/programs/Xserver/include/dixgrabs.h
new file mode 100644
index 000000000..042e063db
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/dixgrabs.h
@@ -0,0 +1,59 @@
+/* $XFree86: xc/programs/Xserver/include/dixgrabs.h,v 3.0 1996/04/15 11:34:27 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifndef DIXGRABS_H
+#define DIXGRABS_H 1
+
+extern GrabPtr CreateGrab(
+ int /* client */,
+ DeviceIntPtr /* device */,
+ WindowPtr /* window */,
+ Mask /* eventMask */,
+ Bool /* ownerEvents */,
+ Bool /* keyboardMode */,
+ Bool /* pointerMode */,
+ DeviceIntPtr /* modDevice */,
+ unsigned short /* modifiers */,
+ int /* type */,
+ KeyCode /* keybut */,
+ WindowPtr /* confineTo */,
+ CursorPtr /* cursor */);
+
+extern int DeletePassiveGrab(
+ pointer /* value */,
+ XID /* id */);
+
+extern Bool GrabMatchesSecond(
+ GrabPtr /* pFirstGrab */,
+ GrabPtr /* pSecondGrab */);
+
+extern int AddPassiveGrabToList(
+ GrabPtr /* pGrab */);
+
+extern Bool DeletePassiveGrabFromList(
+ GrabPtr /* pMinuendGrab */);
+
+#endif /* DIXGRABS_H */
diff --git a/nx-X11/programs/Xserver/include/dixstruct.h b/nx-X11/programs/Xserver/include/dixstruct.h
new file mode 100644
index 000000000..6266ec9f8
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/dixstruct.h
@@ -0,0 +1,236 @@
+/* $XFree86: xc/programs/Xserver/include/dixstruct.h,v 3.19tsi Exp $ */
+/***********************************************************
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: dixstruct.h,v 1.3 2000/08/17 19:53:29 cpqbld Exp $ */
+
+#ifndef DIXSTRUCT_H
+#define DIXSTRUCT_H
+
+#include "dix.h"
+#include "resource.h"
+#include "cursor.h"
+#include "gc.h"
+#include "pixmap.h"
+#include <X11/Xmd.h>
+
+/*
+ * direct-mapped hash table, used by resource manager to store
+ * translation from client ids to server addresses.
+ */
+
+#ifdef DEBUG
+#define MAX_REQUEST_LOG 100
+#endif
+
+extern CallbackListPtr ClientStateCallback;
+
+typedef struct {
+ ClientPtr client;
+ xConnSetupPrefix *prefix;
+ xConnSetup *setup;
+} NewClientInfoRec;
+
+typedef void (*ReplySwapPtr) (
+ ClientPtr /* pClient */,
+ int /* size */,
+ void * /* pbuf */);
+
+extern void ReplyNotSwappd (
+ ClientPtr /* pClient */,
+ int /* size */,
+ void * /* pbuf */);
+
+typedef enum {ClientStateInitial,
+ ClientStateAuthenticating,
+ ClientStateRunning,
+ ClientStateRetained,
+ ClientStateGone,
+ ClientStateCheckingSecurity,
+ ClientStateCheckedSecurity} ClientState;
+
+#ifdef XFIXES
+typedef struct _saveSet {
+ struct _Window *windowPtr;
+ Bool toRoot;
+ Bool remap;
+} SaveSetElt;
+#define SaveSetWindow(ss) ((ss).windowPtr)
+#define SaveSetToRoot(ss) ((ss).toRoot)
+#define SaveSetRemap(ss) ((ss).remap)
+#define SaveSetAssignWindow(ss,w) ((ss).windowPtr = (w))
+#define SaveSetAssignToRoot(ss,tr) ((ss).toRoot = (tr))
+#define SaveSetAssignRemap(ss,rm) ((ss).remap = (rm))
+#else
+typedef struct _Window *SaveSetElt;
+#define SaveSetWindow(ss) (ss)
+#define SaveSetToRoot(ss) FALSE
+#define SaveSetRemap(ss) TRUE
+#define SaveSetAssignWindow(ss,w) ((ss) = (w))
+#define SaveSetAssignToRoot(ss,tr)
+#define SaveSetAssignRemap(ss,rm)
+#endif
+
+typedef struct _Client {
+ int index;
+ Mask clientAsMask;
+ pointer requestBuffer;
+ pointer osPrivate; /* for OS layer, including scheduler */
+ Bool swapped;
+ ReplySwapPtr pSwapReplyFunc;
+ XID errorValue;
+ int sequence;
+ int closeDownMode;
+ int clientGone;
+ int noClientException; /* this client died or needs to be
+ * killed */
+ DrawablePtr lastDrawable;
+ Drawable lastDrawableID;
+ GCPtr lastGC;
+ GContext lastGCID;
+ SaveSetElt *saveSet;
+ int numSaved;
+ pointer screenPrivate[MAXSCREENS];
+ int (**requestVector) (
+ ClientPtr /* pClient */);
+ CARD32 req_len; /* length of current request */
+ Bool big_requests; /* supports large requests */
+ int priority;
+ ClientState clientState;
+ DevUnion *devPrivates;
+#ifdef XKB
+ unsigned short xkbClientFlags;
+ unsigned short mapNotifyMask;
+ unsigned short newKeyboardNotifyMask;
+ unsigned short vMajor,vMinor;
+ KeyCode minKC,maxKC;
+#endif
+
+#ifdef DEBUG
+ unsigned char requestLog[MAX_REQUEST_LOG];
+ int requestLogIndex;
+#endif
+#ifdef LBX
+ int (*readRequest)(ClientPtr /*client*/);
+#endif
+ unsigned long replyBytesRemaining;
+#ifdef XCSECURITY
+ XID authId;
+ unsigned int trustLevel;
+ pointer (* CheckAccess)(
+ ClientPtr /*pClient*/,
+ XID /*id*/,
+ RESTYPE /*classes*/,
+ Mask /*access_mode*/,
+ pointer /*resourceval*/);
+#endif
+#ifdef XAPPGROUP
+ struct _AppGroupRec* appgroup;
+#endif
+ struct _FontResolution * (*fontResFunc) ( /* no need for font.h */
+ ClientPtr /* pClient */,
+ int * /* num */);
+#ifdef SMART_SCHEDULE
+ int smart_priority;
+ long smart_start_tick;
+ long smart_stop_tick;
+ long smart_check_tick;
+#endif
+} ClientRec;
+
+#ifdef SMART_SCHEDULE
+/*
+ * Scheduling interface
+ */
+extern long SmartScheduleTime;
+extern long SmartScheduleInterval;
+extern long SmartScheduleSlice;
+extern long SmartScheduleMaxSlice;
+extern unsigned long SmartScheduleIdleCount;
+extern Bool SmartScheduleDisable;
+extern Bool SmartScheduleIdle;
+extern Bool SmartScheduleTimerStopped;
+extern Bool SmartScheduleStartTimer(void);
+#ifdef NXAGENT_SERVER
+extern Bool SmartScheduleStopTimer(void);
+#endif
+#define SMART_MAX_PRIORITY (20)
+#define SMART_MIN_PRIORITY (-20)
+
+extern Bool SmartScheduleInit(void);
+
+#endif
+
+/* This prototype is used pervasively in Xext, dix */
+#define DISPATCH_PROC(func) int func(ClientPtr /* client */)
+
+typedef struct _WorkQueue {
+ struct _WorkQueue *next;
+ Bool (*function) (
+ ClientPtr /* pClient */,
+ pointer /* closure */
+);
+ ClientPtr client;
+ pointer closure;
+} WorkQueueRec;
+
+extern TimeStamp currentTime;
+extern TimeStamp lastDeviceEventTime;
+
+extern int CompareTimeStamps(
+ TimeStamp /*a*/,
+ TimeStamp /*b*/);
+
+extern TimeStamp ClientTimeToServerTime(CARD32 /*c*/);
+
+typedef struct _CallbackRec {
+ CallbackProcPtr proc;
+ pointer data;
+ Bool deleted;
+ struct _CallbackRec *next;
+} CallbackRec, *CallbackPtr;
+
+typedef struct _CallbackList {
+ CallbackFuncsRec funcs;
+ int inCallback;
+ Bool deleted;
+ int numDeleted;
+ CallbackPtr list;
+} CallbackListRec;
+
+/* proc vectors */
+
+extern int (* InitialVector[3]) (ClientPtr /*client*/);
+
+extern int (* ProcVector[256]) (ClientPtr /*client*/);
+
+extern int (* SwappedProcVector[256]) (ClientPtr /*client*/);
+
+#ifdef K5AUTH
+extern int (*k5_Vector[256])(ClientPtr /*client*/);
+#endif
+
+extern ReplySwapPtr ReplySwapVector[256];
+
+extern int ProcBadRequest(ClientPtr /*client*/);
+
+#endif /* DIXSTRUCT_H */
diff --git a/nx-X11/programs/Xserver/include/dixstruct.h.NX.original b/nx-X11/programs/Xserver/include/dixstruct.h.NX.original
new file mode 100644
index 000000000..6266ec9f8
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/dixstruct.h.NX.original
@@ -0,0 +1,236 @@
+/* $XFree86: xc/programs/Xserver/include/dixstruct.h,v 3.19tsi Exp $ */
+/***********************************************************
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: dixstruct.h,v 1.3 2000/08/17 19:53:29 cpqbld Exp $ */
+
+#ifndef DIXSTRUCT_H
+#define DIXSTRUCT_H
+
+#include "dix.h"
+#include "resource.h"
+#include "cursor.h"
+#include "gc.h"
+#include "pixmap.h"
+#include <X11/Xmd.h>
+
+/*
+ * direct-mapped hash table, used by resource manager to store
+ * translation from client ids to server addresses.
+ */
+
+#ifdef DEBUG
+#define MAX_REQUEST_LOG 100
+#endif
+
+extern CallbackListPtr ClientStateCallback;
+
+typedef struct {
+ ClientPtr client;
+ xConnSetupPrefix *prefix;
+ xConnSetup *setup;
+} NewClientInfoRec;
+
+typedef void (*ReplySwapPtr) (
+ ClientPtr /* pClient */,
+ int /* size */,
+ void * /* pbuf */);
+
+extern void ReplyNotSwappd (
+ ClientPtr /* pClient */,
+ int /* size */,
+ void * /* pbuf */);
+
+typedef enum {ClientStateInitial,
+ ClientStateAuthenticating,
+ ClientStateRunning,
+ ClientStateRetained,
+ ClientStateGone,
+ ClientStateCheckingSecurity,
+ ClientStateCheckedSecurity} ClientState;
+
+#ifdef XFIXES
+typedef struct _saveSet {
+ struct _Window *windowPtr;
+ Bool toRoot;
+ Bool remap;
+} SaveSetElt;
+#define SaveSetWindow(ss) ((ss).windowPtr)
+#define SaveSetToRoot(ss) ((ss).toRoot)
+#define SaveSetRemap(ss) ((ss).remap)
+#define SaveSetAssignWindow(ss,w) ((ss).windowPtr = (w))
+#define SaveSetAssignToRoot(ss,tr) ((ss).toRoot = (tr))
+#define SaveSetAssignRemap(ss,rm) ((ss).remap = (rm))
+#else
+typedef struct _Window *SaveSetElt;
+#define SaveSetWindow(ss) (ss)
+#define SaveSetToRoot(ss) FALSE
+#define SaveSetRemap(ss) TRUE
+#define SaveSetAssignWindow(ss,w) ((ss) = (w))
+#define SaveSetAssignToRoot(ss,tr)
+#define SaveSetAssignRemap(ss,rm)
+#endif
+
+typedef struct _Client {
+ int index;
+ Mask clientAsMask;
+ pointer requestBuffer;
+ pointer osPrivate; /* for OS layer, including scheduler */
+ Bool swapped;
+ ReplySwapPtr pSwapReplyFunc;
+ XID errorValue;
+ int sequence;
+ int closeDownMode;
+ int clientGone;
+ int noClientException; /* this client died or needs to be
+ * killed */
+ DrawablePtr lastDrawable;
+ Drawable lastDrawableID;
+ GCPtr lastGC;
+ GContext lastGCID;
+ SaveSetElt *saveSet;
+ int numSaved;
+ pointer screenPrivate[MAXSCREENS];
+ int (**requestVector) (
+ ClientPtr /* pClient */);
+ CARD32 req_len; /* length of current request */
+ Bool big_requests; /* supports large requests */
+ int priority;
+ ClientState clientState;
+ DevUnion *devPrivates;
+#ifdef XKB
+ unsigned short xkbClientFlags;
+ unsigned short mapNotifyMask;
+ unsigned short newKeyboardNotifyMask;
+ unsigned short vMajor,vMinor;
+ KeyCode minKC,maxKC;
+#endif
+
+#ifdef DEBUG
+ unsigned char requestLog[MAX_REQUEST_LOG];
+ int requestLogIndex;
+#endif
+#ifdef LBX
+ int (*readRequest)(ClientPtr /*client*/);
+#endif
+ unsigned long replyBytesRemaining;
+#ifdef XCSECURITY
+ XID authId;
+ unsigned int trustLevel;
+ pointer (* CheckAccess)(
+ ClientPtr /*pClient*/,
+ XID /*id*/,
+ RESTYPE /*classes*/,
+ Mask /*access_mode*/,
+ pointer /*resourceval*/);
+#endif
+#ifdef XAPPGROUP
+ struct _AppGroupRec* appgroup;
+#endif
+ struct _FontResolution * (*fontResFunc) ( /* no need for font.h */
+ ClientPtr /* pClient */,
+ int * /* num */);
+#ifdef SMART_SCHEDULE
+ int smart_priority;
+ long smart_start_tick;
+ long smart_stop_tick;
+ long smart_check_tick;
+#endif
+} ClientRec;
+
+#ifdef SMART_SCHEDULE
+/*
+ * Scheduling interface
+ */
+extern long SmartScheduleTime;
+extern long SmartScheduleInterval;
+extern long SmartScheduleSlice;
+extern long SmartScheduleMaxSlice;
+extern unsigned long SmartScheduleIdleCount;
+extern Bool SmartScheduleDisable;
+extern Bool SmartScheduleIdle;
+extern Bool SmartScheduleTimerStopped;
+extern Bool SmartScheduleStartTimer(void);
+#ifdef NXAGENT_SERVER
+extern Bool SmartScheduleStopTimer(void);
+#endif
+#define SMART_MAX_PRIORITY (20)
+#define SMART_MIN_PRIORITY (-20)
+
+extern Bool SmartScheduleInit(void);
+
+#endif
+
+/* This prototype is used pervasively in Xext, dix */
+#define DISPATCH_PROC(func) int func(ClientPtr /* client */)
+
+typedef struct _WorkQueue {
+ struct _WorkQueue *next;
+ Bool (*function) (
+ ClientPtr /* pClient */,
+ pointer /* closure */
+);
+ ClientPtr client;
+ pointer closure;
+} WorkQueueRec;
+
+extern TimeStamp currentTime;
+extern TimeStamp lastDeviceEventTime;
+
+extern int CompareTimeStamps(
+ TimeStamp /*a*/,
+ TimeStamp /*b*/);
+
+extern TimeStamp ClientTimeToServerTime(CARD32 /*c*/);
+
+typedef struct _CallbackRec {
+ CallbackProcPtr proc;
+ pointer data;
+ Bool deleted;
+ struct _CallbackRec *next;
+} CallbackRec, *CallbackPtr;
+
+typedef struct _CallbackList {
+ CallbackFuncsRec funcs;
+ int inCallback;
+ Bool deleted;
+ int numDeleted;
+ CallbackPtr list;
+} CallbackListRec;
+
+/* proc vectors */
+
+extern int (* InitialVector[3]) (ClientPtr /*client*/);
+
+extern int (* ProcVector[256]) (ClientPtr /*client*/);
+
+extern int (* SwappedProcVector[256]) (ClientPtr /*client*/);
+
+#ifdef K5AUTH
+extern int (*k5_Vector[256])(ClientPtr /*client*/);
+#endif
+
+extern ReplySwapPtr ReplySwapVector[256];
+
+extern int ProcBadRequest(ClientPtr /*client*/);
+
+#endif /* DIXSTRUCT_H */
diff --git a/nx-X11/programs/Xserver/include/dixstruct.h.X.original b/nx-X11/programs/Xserver/include/dixstruct.h.X.original
new file mode 100644
index 000000000..d7d810272
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/dixstruct.h.X.original
@@ -0,0 +1,233 @@
+/* $XFree86: xc/programs/Xserver/include/dixstruct.h,v 3.19tsi Exp $ */
+/***********************************************************
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: dixstruct.h,v 1.3 2000/08/17 19:53:29 cpqbld Exp $ */
+
+#ifndef DIXSTRUCT_H
+#define DIXSTRUCT_H
+
+#include "dix.h"
+#include "resource.h"
+#include "cursor.h"
+#include "gc.h"
+#include "pixmap.h"
+#include <X11/Xmd.h>
+
+/*
+ * direct-mapped hash table, used by resource manager to store
+ * translation from client ids to server addresses.
+ */
+
+#ifdef DEBUG
+#define MAX_REQUEST_LOG 100
+#endif
+
+extern CallbackListPtr ClientStateCallback;
+
+typedef struct {
+ ClientPtr client;
+ xConnSetupPrefix *prefix;
+ xConnSetup *setup;
+} NewClientInfoRec;
+
+typedef void (*ReplySwapPtr) (
+ ClientPtr /* pClient */,
+ int /* size */,
+ void * /* pbuf */);
+
+extern void ReplyNotSwappd (
+ ClientPtr /* pClient */,
+ int /* size */,
+ void * /* pbuf */);
+
+typedef enum {ClientStateInitial,
+ ClientStateAuthenticating,
+ ClientStateRunning,
+ ClientStateRetained,
+ ClientStateGone,
+ ClientStateCheckingSecurity,
+ ClientStateCheckedSecurity} ClientState;
+
+#ifdef XFIXES
+typedef struct _saveSet {
+ struct _Window *windowPtr;
+ Bool toRoot;
+ Bool remap;
+} SaveSetElt;
+#define SaveSetWindow(ss) ((ss).windowPtr)
+#define SaveSetToRoot(ss) ((ss).toRoot)
+#define SaveSetRemap(ss) ((ss).remap)
+#define SaveSetAssignWindow(ss,w) ((ss).windowPtr = (w))
+#define SaveSetAssignToRoot(ss,tr) ((ss).toRoot = (tr))
+#define SaveSetAssignRemap(ss,rm) ((ss).remap = (rm))
+#else
+typedef struct _Window *SaveSetElt;
+#define SaveSetWindow(ss) (ss)
+#define SaveSetToRoot(ss) FALSE
+#define SaveSetRemap(ss) TRUE
+#define SaveSetAssignWindow(ss,w) ((ss) = (w))
+#define SaveSetAssignToRoot(ss,tr)
+#define SaveSetAssignRemap(ss,rm)
+#endif
+
+typedef struct _Client {
+ int index;
+ Mask clientAsMask;
+ pointer requestBuffer;
+ pointer osPrivate; /* for OS layer, including scheduler */
+ Bool swapped;
+ ReplySwapPtr pSwapReplyFunc;
+ XID errorValue;
+ int sequence;
+ int closeDownMode;
+ int clientGone;
+ int noClientException; /* this client died or needs to be
+ * killed */
+ DrawablePtr lastDrawable;
+ Drawable lastDrawableID;
+ GCPtr lastGC;
+ GContext lastGCID;
+ SaveSetElt *saveSet;
+ int numSaved;
+ pointer screenPrivate[MAXSCREENS];
+ int (**requestVector) (
+ ClientPtr /* pClient */);
+ CARD32 req_len; /* length of current request */
+ Bool big_requests; /* supports large requests */
+ int priority;
+ ClientState clientState;
+ DevUnion *devPrivates;
+#ifdef XKB
+ unsigned short xkbClientFlags;
+ unsigned short mapNotifyMask;
+ unsigned short newKeyboardNotifyMask;
+ unsigned short vMajor,vMinor;
+ KeyCode minKC,maxKC;
+#endif
+
+#ifdef DEBUG
+ unsigned char requestLog[MAX_REQUEST_LOG];
+ int requestLogIndex;
+#endif
+#ifdef LBX
+ int (*readRequest)(ClientPtr /*client*/);
+#endif
+ unsigned long replyBytesRemaining;
+#ifdef XCSECURITY
+ XID authId;
+ unsigned int trustLevel;
+ pointer (* CheckAccess)(
+ ClientPtr /*pClient*/,
+ XID /*id*/,
+ RESTYPE /*classes*/,
+ Mask /*access_mode*/,
+ pointer /*resourceval*/);
+#endif
+#ifdef XAPPGROUP
+ struct _AppGroupRec* appgroup;
+#endif
+ struct _FontResolution * (*fontResFunc) ( /* no need for font.h */
+ ClientPtr /* pClient */,
+ int * /* num */);
+#ifdef SMART_SCHEDULE
+ int smart_priority;
+ long smart_start_tick;
+ long smart_stop_tick;
+ long smart_check_tick;
+#endif
+} ClientRec;
+
+#ifdef SMART_SCHEDULE
+/*
+ * Scheduling interface
+ */
+extern long SmartScheduleTime;
+extern long SmartScheduleInterval;
+extern long SmartScheduleSlice;
+extern long SmartScheduleMaxSlice;
+extern unsigned long SmartScheduleIdleCount;
+extern Bool SmartScheduleDisable;
+extern Bool SmartScheduleIdle;
+extern Bool SmartScheduleTimerStopped;
+extern Bool SmartScheduleStartTimer(void);
+#define SMART_MAX_PRIORITY (20)
+#define SMART_MIN_PRIORITY (-20)
+
+extern Bool SmartScheduleInit(void);
+
+#endif
+
+/* This prototype is used pervasively in Xext, dix */
+#define DISPATCH_PROC(func) int func(ClientPtr /* client */)
+
+typedef struct _WorkQueue {
+ struct _WorkQueue *next;
+ Bool (*function) (
+ ClientPtr /* pClient */,
+ pointer /* closure */
+);
+ ClientPtr client;
+ pointer closure;
+} WorkQueueRec;
+
+extern TimeStamp currentTime;
+extern TimeStamp lastDeviceEventTime;
+
+extern int CompareTimeStamps(
+ TimeStamp /*a*/,
+ TimeStamp /*b*/);
+
+extern TimeStamp ClientTimeToServerTime(CARD32 /*c*/);
+
+typedef struct _CallbackRec {
+ CallbackProcPtr proc;
+ pointer data;
+ Bool deleted;
+ struct _CallbackRec *next;
+} CallbackRec, *CallbackPtr;
+
+typedef struct _CallbackList {
+ CallbackFuncsRec funcs;
+ int inCallback;
+ Bool deleted;
+ int numDeleted;
+ CallbackPtr list;
+} CallbackListRec;
+
+/* proc vectors */
+
+extern int (* InitialVector[3]) (ClientPtr /*client*/);
+
+extern int (* ProcVector[256]) (ClientPtr /*client*/);
+
+extern int (* SwappedProcVector[256]) (ClientPtr /*client*/);
+
+#ifdef K5AUTH
+extern int (*k5_Vector[256])(ClientPtr /*client*/);
+#endif
+
+extern ReplySwapPtr ReplySwapVector[256];
+
+extern int ProcBadRequest(ClientPtr /*client*/);
+
+#endif /* DIXSTRUCT_H */
diff --git a/nx-X11/programs/Xserver/include/exevents.h b/nx-X11/programs/Xserver/include/exevents.h
new file mode 100644
index 000000000..91c7acb6b
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/exevents.h
@@ -0,0 +1,183 @@
+/* $XFree86: xc/programs/Xserver/include/exevents.h,v 3.1 1996/04/15 11:34:29 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/********************************************************************
+ * Interface of 'exevents.c'
+ */
+
+#ifndef EXEVENTS_H
+#define EXEVENTS_H
+
+extern void RegisterOtherDevice (
+ DeviceIntPtr /* device */);
+
+extern void ProcessOtherEvent (
+ xEventPtr /* FIXME deviceKeyButtonPointer * xE */,
+ DeviceIntPtr /* other */,
+ int /* count */);
+
+extern int InitProximityClassDeviceStruct(
+ DeviceIntPtr /* dev */);
+
+extern void InitValuatorAxisStruct(
+ DeviceIntPtr /* dev */,
+ int /* axnum */,
+ int /* minval */,
+ int /* maxval */,
+ int /* resolution */,
+ int /* min_res */,
+ int /* max_res */);
+
+extern void DeviceFocusEvent(
+ DeviceIntPtr /* dev */,
+ int /* type */,
+ int /* mode */,
+ int /* detail */,
+ WindowPtr /* pWin */);
+
+extern int GrabButton(
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ BYTE /* this_device_mode */,
+ BYTE /* other_devices_mode */,
+ CARD16 /* modifiers */,
+ DeviceIntPtr /* modifier_device */,
+ CARD8 /* button */,
+ Window /* grabWindow */,
+ BOOL /* ownerEvents */,
+ Cursor /* rcursor */,
+ Window /* rconfineTo */,
+ Mask /* eventMask */);
+
+extern int GrabKey(
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ BYTE /* this_device_mode */,
+ BYTE /* other_devices_mode */,
+ CARD16 /* modifiers */,
+ DeviceIntPtr /* modifier_device */,
+ CARD8 /* key */,
+ Window /* grabWindow */,
+ BOOL /* ownerEvents */,
+ Mask /* mask */);
+
+extern int SelectForWindow(
+ DeviceIntPtr /* dev */,
+ WindowPtr /* pWin */,
+ ClientPtr /* client */,
+ Mask /* mask */,
+ Mask /* exclusivemasks */,
+ Mask /* validmasks */);
+
+extern int AddExtensionClient (
+ WindowPtr /* pWin */,
+ ClientPtr /* client */,
+ Mask /* mask */,
+ int /* mskidx */);
+
+extern void RecalculateDeviceDeliverableEvents(
+ WindowPtr /* pWin */);
+
+extern int InputClientGone(
+ WindowPtr /* pWin */,
+ XID /* id */);
+
+extern int SendEvent (
+ ClientPtr /* client */,
+ DeviceIntPtr /* d */,
+ Window /* dest */,
+ Bool /* propagate */,
+ xEvent * /* ev */,
+ Mask /* mask */,
+ int /* count */);
+
+extern int SetButtonMapping (
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ int /* nElts */,
+ BYTE * /* map */);
+
+extern int SetModifierMapping(
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ int /* len */,
+ int /* rlen */,
+ int /* numKeyPerModifier */,
+ KeyCode * /* inputMap */,
+ KeyClassPtr * /* k */);
+
+extern void SendDeviceMappingNotify(
+ CARD8 /* request, */,
+ KeyCode /* firstKeyCode */,
+ CARD8 /* count */,
+ DeviceIntPtr /* dev */);
+
+extern int ChangeKeyMapping(
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ unsigned /* len */,
+ int /* type */,
+ KeyCode /* firstKeyCode */,
+ CARD8 /* keyCodes */,
+ CARD8 /* keySymsPerKeyCode */,
+ KeySym * /* map */);
+
+extern void DeleteWindowFromAnyExtEvents(
+ WindowPtr /* pWin */,
+ Bool /* freeResources */);
+
+extern void DeleteDeviceFromAnyExtEvents(
+ WindowPtr /* pWin */,
+ DeviceIntPtr /* dev */);
+
+extern int MaybeSendDeviceMotionNotifyHint (
+ deviceKeyButtonPointer * /* pEvents */,
+ Mask /* mask */);
+
+extern void CheckDeviceGrabAndHintWindow (
+ WindowPtr /* pWin */,
+ int /* type */,
+ deviceKeyButtonPointer * /* xE */,
+ GrabPtr /* grab */,
+ ClientPtr /* client */,
+ Mask /* deliveryMask */);
+
+extern Mask DeviceEventMaskForClient(
+ DeviceIntPtr /* dev */,
+ WindowPtr /* pWin */,
+ ClientPtr /* client */);
+
+extern void MaybeStopDeviceHint(
+ DeviceIntPtr /* dev */,
+ ClientPtr /* client */);
+
+extern int DeviceEventSuppressForWindow(
+ WindowPtr /* pWin */,
+ ClientPtr /* client */,
+ Mask /* mask */,
+ int /* maskndx */);
+
+#endif /* EXEVENTS_H */
diff --git a/nx-X11/programs/Xserver/include/extension.h b/nx-X11/programs/Xserver/include/extension.h
new file mode 100644
index 000000000..34750173b
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/extension.h
@@ -0,0 +1,67 @@
+/* $Xorg: extension.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/include/extension.h,v 1.5 2001/12/14 19:59:54 dawes Exp $ */
+
+#ifndef EXTENSION_H
+#define EXTENSION_H
+
+_XFUNCPROTOBEGIN
+
+extern unsigned short StandardMinorOpcode(ClientPtr /*client*/);
+
+extern unsigned short MinorOpcodeOfRequest(ClientPtr /*client*/);
+
+extern void InitExtensions(int argc, char **argv);
+
+extern void InitVisualWrap(void);
+
+extern void CloseDownExtensions(void);
+
+_XFUNCPROTOEND
+
+#endif /* EXTENSION_H */
diff --git a/nx-X11/programs/Xserver/include/extinit.h b/nx-X11/programs/Xserver/include/extinit.h
new file mode 100644
index 000000000..37fa9a245
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/extinit.h
@@ -0,0 +1,166 @@
+/* $XFree86: xc/programs/Xserver/include/extinit.h,v 3.2 2001/08/01 00:44:58 tsi Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/********************************************************************
+ * Interface of extinit.c
+ */
+
+#ifndef EXTINIT_H
+#define EXTINIT_H
+
+#include "extnsionst.h"
+
+void
+XInputExtensionInit(
+ void
+ );
+
+
+int
+ProcIDispatch (
+ ClientPtr /* client */
+ );
+
+int
+SProcIDispatch(
+ ClientPtr /* client */
+ );
+
+void
+SReplyIDispatch (
+ ClientPtr /* client */,
+ int /* len */,
+ xGrabDeviceReply * /* rep */
+ );
+
+void
+SEventIDispatch (
+ xEvent * /* from */,
+ xEvent * /* to */
+ );
+
+void
+SEventDeviceValuator (
+ deviceValuator * /* from */,
+ deviceValuator * /* to */
+ );
+
+void
+SEventFocus (
+ deviceFocus * /* from */,
+ deviceFocus * /* to */
+ );
+
+void
+SDeviceStateNotifyEvent (
+ deviceStateNotify * /* from */,
+ deviceStateNotify * /* to */
+ );
+
+void
+SDeviceKeyStateNotifyEvent (
+ deviceKeyStateNotify * /* from */,
+ deviceKeyStateNotify * /* to */
+ );
+
+void
+SDeviceButtonStateNotifyEvent (
+ deviceButtonStateNotify * /* from */,
+ deviceButtonStateNotify * /* to */
+ );
+
+void
+SChangeDeviceNotifyEvent (
+ changeDeviceNotify * /* from */,
+ changeDeviceNotify * /* to */
+ );
+
+void
+SDeviceMappingNotifyEvent (
+ deviceMappingNotify * /* from */,
+ deviceMappingNotify * /* to */
+ );
+
+void
+FixExtensionEvents (
+ ExtensionEntry * /* extEntry */
+ );
+
+void
+RestoreExtensionEvents (
+ void
+ );
+
+void
+IResetProc(
+ ExtensionEntry * /* unused */
+ );
+
+void
+AssignTypeAndName (
+ DeviceIntPtr /* dev */,
+ Atom /* type */,
+ char * /* name */
+ );
+
+void
+MakeDeviceTypeAtoms (
+ void
+);
+
+DeviceIntPtr
+LookupDeviceIntRec (
+ CARD8 /* id */
+ );
+
+void
+SetExclusiveAccess (
+ Mask /* mask */
+ );
+
+void
+AllowPropagateSuppress (
+ Mask /* mask */
+ );
+
+Mask
+GetNextExtEventMask (
+ void
+);
+
+void
+SetMaskForExtEvent(
+ Mask /* mask */,
+ int /* event */
+ );
+
+void
+SetEventInfo(
+ Mask /* mask */,
+ int /* constant */
+ );
+
+#endif /* EXTINIT_H */
diff --git a/nx-X11/programs/Xserver/include/extnsionst.h b/nx-X11/programs/Xserver/include/extnsionst.h
new file mode 100644
index 000000000..daf37bf43
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/extnsionst.h
@@ -0,0 +1,152 @@
+/* $Xorg: extnsionst.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/include/extnsionst.h,v 3.8 2003/04/27 21:31:04 herrb Exp $ */
+
+#ifndef EXTENSIONSTRUCT_H
+#define EXTENSIONSTRUCT_H
+
+#include "misc.h"
+#include "screenint.h"
+#include "extension.h"
+#include "gc.h"
+
+typedef struct _ExtensionEntry {
+ int index;
+ void (* CloseDown)( /* called at server shutdown */
+ struct _ExtensionEntry * /* extension */);
+ char *name; /* extension name */
+ int base; /* base request number */
+ int eventBase;
+ int eventLast;
+ int errorBase;
+ int errorLast;
+ int num_aliases;
+ char **aliases;
+ pointer extPrivate;
+ unsigned short (* MinorOpcode)( /* called for errors */
+ ClientPtr /* client */);
+#ifdef XCSECURITY
+ Bool secure; /* extension visible to untrusted clients? */
+#endif
+} ExtensionEntry;
+
+/*
+ * The arguments may be different for extension event swapping functions.
+ * Deal with this by casting when initializing the event's EventSwapVector[]
+ * entries.
+ */
+typedef void (*EventSwapPtr) (xEvent *, xEvent *);
+
+extern EventSwapPtr EventSwapVector[128];
+
+extern void NotImplemented ( /* FIXME: this may move to another file... */
+ xEvent *,
+ xEvent *);
+
+typedef void (* ExtensionLookupProc)(
+#ifdef EXTENSION_PROC_ARGS
+ EXTENSION_PROC_ARGS
+#else
+ /* args no longer indeterminate */
+ char *name,
+ GCPtr pGC
+#endif
+);
+
+typedef struct _ProcEntry {
+ char *name;
+ ExtensionLookupProc proc;
+} ProcEntryRec, *ProcEntryPtr;
+
+typedef struct _ScreenProcEntry {
+ int num;
+ ProcEntryPtr procList;
+} ScreenProcEntry;
+
+#define SetGCVector(pGC, VectorElement, NewRoutineAddress, Atom) \
+ pGC->VectorElement = NewRoutineAddress;
+
+#define GetGCValue(pGC, GCElement) (pGC->GCElement)
+
+
+extern ExtensionEntry *AddExtension(
+ char* /*name*/,
+ int /*NumEvents*/,
+ int /*NumErrors*/,
+ int (* /*MainProc*/)(ClientPtr /*client*/),
+ int (* /*SwappedMainProc*/)(ClientPtr /*client*/),
+ void (* /*CloseDownProc*/)(ExtensionEntry * /*extension*/),
+ unsigned short (* /*MinorOpcodeProc*/)(ClientPtr /*client*/)
+);
+
+extern Bool AddExtensionAlias(
+ char* /*alias*/,
+ ExtensionEntry * /*extension*/);
+
+extern ExtensionEntry *CheckExtension(const char *extname);
+
+extern ExtensionLookupProc LookupProc(
+ char* /*name*/,
+ GCPtr /*pGC*/);
+
+extern Bool RegisterProc(
+ char* /*name*/,
+ GCPtr /*pGC*/,
+ ExtensionLookupProc /*proc*/);
+
+extern Bool RegisterScreenProc(
+ char* /*name*/,
+ ScreenPtr /*pScreen*/,
+ ExtensionLookupProc /*proc*/);
+
+extern void DeclareExtensionSecurity(
+ char * /*extname*/,
+ Bool /*secure*/);
+
+#endif /* EXTENSIONSTRUCT_H */
+
diff --git a/nx-X11/programs/Xserver/include/gc.h b/nx-X11/programs/Xserver/include/gc.h
new file mode 100644
index 000000000..77c2f20c6
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/gc.h
@@ -0,0 +1,178 @@
+/* $XFree86: xc/programs/Xserver/include/gc.h,v 1.5 2001/12/14 19:59:54 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: gc.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+
+#ifndef GC_H
+#define GC_H
+
+#include <X11/X.h> /* for GContext, Mask */
+#include <X11/Xdefs.h> /* for Bool */
+#include <X11/Xproto.h>
+#include "screenint.h" /* for ScreenPtr */
+#include "pixmap.h" /* for DrawablePtr */
+
+/* clientClipType field in GC */
+#define CT_NONE 0
+#define CT_PIXMAP 1
+#define CT_REGION 2
+#define CT_UNSORTED 6
+#define CT_YSORTED 10
+#define CT_YXSORTED 14
+#define CT_YXBANDED 18
+
+#define GCQREASON_VALIDATE 1
+#define GCQREASON_CHANGE 2
+#define GCQREASON_COPY_SRC 3
+#define GCQREASON_COPY_DST 4
+#define GCQREASON_DESTROY 5
+
+#define GC_CHANGE_SERIAL_BIT (((unsigned long)1)<<31)
+#define GC_CALL_VALIDATE_BIT (1L<<30)
+#define GCExtensionInterest (1L<<29)
+
+#define DRAWABLE_SERIAL_BITS (~(GC_CHANGE_SERIAL_BIT))
+
+#define MAX_SERIAL_NUM (1L<<28)
+
+#define NEXT_SERIAL_NUMBER ((++globalSerialNumber) > MAX_SERIAL_NUM ? \
+ (globalSerialNumber = 1): globalSerialNumber)
+
+typedef struct _GCInterest *GCInterestPtr;
+typedef struct _GC *GCPtr;
+typedef struct _GCOps *GCOpsPtr;
+
+extern void ValidateGC(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/);
+
+extern int ChangeGC(
+ GCPtr/*pGC*/,
+ BITS32 /*mask*/,
+ XID* /*pval*/);
+
+extern int DoChangeGC(
+ GCPtr/*pGC*/,
+ BITS32 /*mask*/,
+ XID* /*pval*/,
+ int /*fPointer*/);
+
+typedef union {
+ CARD32 val;
+ pointer ptr;
+} ChangeGCVal, *ChangeGCValPtr;
+
+extern int dixChangeGC(
+ ClientPtr /*client*/,
+ GCPtr /*pGC*/,
+ BITS32 /*mask*/,
+ CARD32 * /*pval*/,
+ ChangeGCValPtr /*pCGCV*/);
+
+extern GCPtr CreateGC(
+ DrawablePtr /*pDrawable*/,
+ BITS32 /*mask*/,
+ XID* /*pval*/,
+ int* /*pStatus*/);
+
+extern int CopyGC(
+ GCPtr/*pgcSrc*/,
+ GCPtr/*pgcDst*/,
+ BITS32 /*mask*/);
+
+extern int FreeGC(
+ pointer /*pGC*/,
+ XID /*gid*/);
+
+extern void SetGCMask(
+ GCPtr /*pGC*/,
+ Mask /*selectMask*/,
+ Mask /*newDataMask*/);
+
+extern GCPtr CreateScratchGC(
+ ScreenPtr /*pScreen*/,
+ unsigned /*depth*/);
+
+extern void FreeGCperDepth(
+ int /*screenNum*/);
+
+extern Bool CreateGCperDepth(
+ int /*screenNum*/);
+
+extern Bool CreateDefaultStipple(
+ int /*screenNum*/);
+
+extern void FreeDefaultStipple(
+ int /*screenNum*/);
+
+extern int SetDashes(
+ GCPtr /*pGC*/,
+ unsigned /*offset*/,
+ unsigned /*ndash*/,
+ unsigned char* /*pdash*/);
+
+extern int VerifyRectOrder(
+ int /*nrects*/,
+ xRectangle* /*prects*/,
+ int /*ordering*/);
+
+extern int SetClipRects(
+ GCPtr /*pGC*/,
+ int /*xOrigin*/,
+ int /*yOrigin*/,
+ int /*nrects*/,
+ xRectangle* /*prects*/,
+ int /*ordering*/);
+
+extern GCPtr GetScratchGC(
+ unsigned /*depth*/,
+ ScreenPtr /*pScreen*/);
+
+extern void FreeScratchGC(
+ GCPtr /*pGC*/);
+
+#endif /* GC_H */
diff --git a/nx-X11/programs/Xserver/include/gcstruct.h b/nx-X11/programs/Xserver/include/gcstruct.h
new file mode 100644
index 000000000..c2226ba17
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/gcstruct.h
@@ -0,0 +1,328 @@
+/* $Xorg: gcstruct.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+
+/* $XFree86: xc/programs/Xserver/include/gcstruct.h,v 1.7 2003/04/27 21:31:04 herrb Exp $ */
+
+#ifndef GCSTRUCT_H
+#define GCSTRUCT_H
+
+#include "gc.h"
+
+#include "regionstr.h"
+#include "region.h"
+#include "pixmap.h"
+#include "screenint.h"
+#include <X11/Xprotostr.h>
+
+/*
+ * functions which modify the state of the GC
+ */
+
+typedef struct _GCFuncs {
+ void (* ValidateGC)(
+ GCPtr /*pGC*/,
+ unsigned long /*stateChanges*/,
+ DrawablePtr /*pDrawable*/);
+
+ void (* ChangeGC)(
+ GCPtr /*pGC*/,
+ unsigned long /*mask*/);
+
+ void (* CopyGC)(
+ GCPtr /*pGCSrc*/,
+ unsigned long /*mask*/,
+ GCPtr /*pGCDst*/);
+
+ void (* DestroyGC)(
+ GCPtr /*pGC*/);
+
+ void (* ChangeClip)(
+ GCPtr /*pGC*/,
+ int /*type*/,
+ pointer /*pvalue*/,
+ int /*nrects*/);
+
+ void (* DestroyClip)(
+ GCPtr /*pGC*/);
+
+ void (* CopyClip)(
+ GCPtr /*pgcDst*/,
+ GCPtr /*pgcSrc*/);
+ DevUnion devPrivate;
+} GCFuncs;
+
+/*
+ * graphics operations invoked through a GC
+ */
+
+typedef struct _GCOps {
+ void (* FillSpans)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/);
+
+ void (* SetSpans)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ char * /*psrc*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ int /*nspans*/,
+ int /*fSorted*/);
+
+ void (* PutImage)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*depth*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ int /*leftPad*/,
+ int /*format*/,
+ char * /*pBits*/);
+
+ RegionPtr (* CopyArea)(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ GCPtr /*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*w*/,
+ int /*h*/,
+ int /*dstx*/,
+ int /*dsty*/);
+
+ RegionPtr (* CopyPlane)(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr /*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ unsigned long /*bitPlane*/);
+ void (* PolyPoint)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/);
+
+ void (* Polylines)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/);
+
+ void (* PolySegment)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSegs*/);
+
+ void (* PolyRectangle)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nrects*/,
+ xRectangle * /*pRects*/);
+
+ void (* PolyArc)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/);
+
+ void (* FillPolygon)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*shape*/,
+ int /*mode*/,
+ int /*count*/,
+ DDXPointPtr /*pPts*/);
+
+ void (* PolyFillRect)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nrectFill*/,
+ xRectangle * /*prectInit*/);
+
+ void (* PolyFillArc)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/);
+
+ int (* PolyText8)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ char * /*chars*/);
+
+ int (* PolyText16)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ unsigned short * /*chars*/);
+
+ void (* ImageText8)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ char * /*chars*/);
+
+ void (* ImageText16)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ unsigned short * /*chars*/);
+
+ void (* ImageGlyphBlt)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/);
+
+ void (* PolyGlyphBlt)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/);
+
+ void (* PushPixels)(
+ GCPtr /*pGC*/,
+ PixmapPtr /*pBitMap*/,
+ DrawablePtr /*pDst*/,
+ int /*w*/,
+ int /*h*/,
+ int /*x*/,
+ int /*y*/);
+
+#ifdef NEED_LINEHELPER
+ void (* LineHelper)();
+#endif
+
+ DevUnion devPrivate;
+} GCOps;
+
+/* there is padding in the bit fields because the Sun compiler doesn't
+ * force alignment to 32-bit boundaries. losers.
+ */
+typedef struct _GC {
+ ScreenPtr pScreen;
+ unsigned char depth;
+ unsigned char alu;
+ unsigned short lineWidth;
+ unsigned short dashOffset;
+ unsigned short numInDashList;
+ unsigned char *dash;
+ unsigned int lineStyle : 2;
+ unsigned int capStyle : 2;
+ unsigned int joinStyle : 2;
+ unsigned int fillStyle : 2;
+ unsigned int fillRule : 1;
+ unsigned int arcMode : 1;
+ unsigned int subWindowMode : 1;
+ unsigned int graphicsExposures : 1;
+ unsigned int clientClipType : 2; /* CT_<kind> */
+ unsigned int miTranslate:1; /* should mi things translate? */
+ unsigned int tileIsPixel:1; /* tile is solid pixel */
+ unsigned int fExpose:1; /* Call exposure handling */
+ unsigned int freeCompClip:1; /* Free composite clip */
+ unsigned int unused:14; /* see comment above */
+ unsigned long planemask;
+ unsigned long fgPixel;
+ unsigned long bgPixel;
+ /*
+ * alas -- both tile and stipple must be here as they
+ * are independently specifiable
+ */
+ PixUnion tile;
+ PixmapPtr stipple;
+ DDXPointRec patOrg; /* origin for (tile, stipple) */
+ struct _Font *font;
+ DDXPointRec clipOrg;
+ DDXPointRec lastWinOrg; /* position of window last validated */
+ pointer clientClip;
+ unsigned long stateChanges; /* masked with GC_<kind> */
+ unsigned long serialNumber;
+ GCFuncs *funcs;
+ GCOps *ops;
+ DevUnion *devPrivates;
+ /*
+ * The following were moved here from private storage to allow device-
+ * independent access to them from screen wrappers.
+ * --- 1997.11.03 Marc Aurele La France (tsi@xfree86.org)
+ */
+ PixmapPtr pRotatedPixmap; /* tile/stipple rotated for alignment */
+ RegionPtr pCompositeClip;
+ /* fExpose & freeCompClip defined above */
+} GC;
+
+#endif /* GCSTRUCT_H */
diff --git a/nx-X11/programs/Xserver/include/globals.h b/nx-X11/programs/Xserver/include/globals.h
new file mode 100644
index 000000000..0f2864825
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/globals.h
@@ -0,0 +1,192 @@
+/* $XdotOrg: xc/programs/Xserver/include/globals.h,v 1.9 2005/08/24 11:18:31 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/include/globals.h,v 1.3 1999/09/25 14:38:21 dawes Exp $ */
+
+#ifndef _XSERV_GLOBAL_H_
+#define _XSERV_GLOBAL_H_
+
+#include "window.h" /* for WindowPtr */
+
+/* Global X server variables that are visible to mi, dix, os, and ddx */
+
+extern CARD32 defaultScreenSaverTime;
+extern CARD32 defaultScreenSaverInterval;
+extern CARD32 ScreenSaverTime;
+extern CARD32 ScreenSaverInterval;
+
+extern char *defaultFontPath;
+extern char *rgbPath;
+extern int monitorResolution;
+extern Bool loadableFonts;
+extern int defaultColorVisualClass;
+
+extern Bool Must_have_memory;
+extern WindowPtr *WindowTable;
+extern int GrabInProgress;
+extern Bool noTestExtensions;
+
+extern DDXPointRec dixScreenOrigins[MAXSCREENS];
+
+#ifdef DPMSExtension
+extern CARD32 defaultDPMSStandbyTime;
+extern CARD32 defaultDPMSSuspendTime;
+extern CARD32 defaultDPMSOffTime;
+extern CARD32 DPMSStandbyTime;
+extern CARD32 DPMSSuspendTime;
+extern CARD32 DPMSOffTime;
+extern CARD16 DPMSPowerLevel;
+extern Bool defaultDPMSEnabled;
+extern Bool DPMSEnabled;
+extern Bool DPMSEnabledSwitch;
+extern Bool DPMSDisabledSwitch;
+extern Bool DPMSCapableFlag;
+#endif
+
+#ifdef PANORAMIX
+extern Bool PanoramiXMapped;
+extern Bool PanoramiXVisibilityNotifySent;
+extern Bool PanoramiXWindowExposureSent;
+extern Bool PanoramiXOneExposeRequest;
+#endif
+
+#ifdef BIGREQS
+extern Bool noBigReqExtension;
+#endif
+
+#ifdef COMPOSITE
+extern Bool noCompositeExtension;
+#endif
+
+#ifdef DAMAGE
+extern Bool noDamageExtension;
+#endif
+
+#ifdef DBE
+extern Bool noDbeExtension;
+#endif
+
+#ifdef DPSEXT
+extern Bool noDPSExtension;
+#endif
+
+#ifdef DPMSExtension
+extern Bool noDPMSExtension;
+#endif
+
+#ifdef EVI
+extern Bool noEVIExtension;
+#endif
+
+#ifdef FONTCACHE
+extern Bool noFontCacheExtension;
+#endif
+
+#ifdef GLXEXT
+extern Bool noGlxExtension;
+#endif
+
+#ifdef LBX
+extern Bool noLbxExtension;
+#endif
+
+#ifdef SCREENSAVER
+extern Bool noScreenSaverExtension;
+#endif
+
+#ifdef MITSHM
+extern Bool noMITShmExtension;
+#endif
+
+#ifdef MITMISC
+extern Bool noMITMiscExtension;
+#endif
+
+#ifdef MULTIBUFFER
+extern Bool noMultibufferExtension;
+#endif
+
+#ifdef RANDR
+extern Bool noRRExtension;
+#endif
+
+#ifdef RENDER
+extern Bool noRenderExtension;
+#endif
+
+#ifdef SHAPE
+extern Bool noShapeExtension;
+#endif
+
+#ifdef XCSECURITY
+extern Bool noSecurityExtension;
+#endif
+
+#ifdef XSYNC
+extern Bool noSyncExtension;
+#endif
+
+#ifdef TOGCUP
+extern Bool noXcupExtension;
+#endif
+
+#ifdef RES
+extern Bool noResExtension;
+#endif
+
+#ifdef XAPPGROUP
+extern Bool noXagExtension;
+#endif
+
+#ifdef XCMISC
+extern Bool noXCMiscExtension;
+#endif
+
+#ifdef XEVIE
+extern Bool noXevieExtension;
+#endif
+
+#ifdef XF86BIGFONT
+extern Bool noXFree86BigfontExtension;
+#endif
+
+#ifdef XFreeXDGA
+extern Bool noXFree86DGAExtension;
+#endif
+
+#ifdef XF86DRI
+extern Bool noXFree86DRIExtension;
+#endif
+
+#ifdef XF86MISC
+extern Bool noXFree86MiscExtension;
+#endif
+
+#ifdef XF86VIDMODE
+extern Bool noXFree86VidModeExtension;
+#endif
+
+#ifdef XFIXES
+extern Bool noXFixesExtension;
+#endif
+
+#ifdef XKB
+/* |noXkbExtension| is defined in xc/programs/Xserver/xkb/xkbInit.c */
+extern Bool noXkbExtension;
+#endif
+
+#ifdef PANORAMIX
+extern Bool noPanoramiXExtension;
+#endif
+
+#ifdef XINPUT
+extern Bool noXInputExtension;
+#endif
+
+#ifdef XIDLE
+extern Bool noXIdleExtension;
+#endif
+
+#ifdef XV
+extern Bool noXvExtension;
+#endif
+
+#endif /* !_XSERV_GLOBAL_H_ */
diff --git a/nx-X11/programs/Xserver/include/input.h b/nx-X11/programs/Xserver/include/input.h
new file mode 100644
index 000000000..bcaa01e6f
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/input.h
@@ -0,0 +1,391 @@
+/* $Xorg: input.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+/************************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/include/input.h,v 3.8 2003/04/27 21:31:04 herrb Exp $ */
+
+#ifndef INPUT_H
+#define INPUT_H
+
+#include "misc.h"
+#include "screenint.h"
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "window.h" /* for WindowPtr */
+
+#define DEVICE_INIT 0
+#define DEVICE_ON 1
+#define DEVICE_OFF 2
+#define DEVICE_CLOSE 3
+
+#define MAP_LENGTH 256
+#define DOWN_LENGTH 32 /* 256/8 => number of bytes to hold 256 bits */
+#define NullGrab ((GrabPtr)NULL)
+#define PointerRootWin ((WindowPtr)PointerRoot)
+#define NoneWin ((WindowPtr)None)
+#define NullDevice ((DevicePtr)NULL)
+
+#ifndef FollowKeyboard
+#define FollowKeyboard 3
+#endif
+#ifndef FollowKeyboardWin
+#define FollowKeyboardWin ((WindowPtr) FollowKeyboard)
+#endif
+#ifndef RevertToFollowKeyboard
+#define RevertToFollowKeyboard 3
+#endif
+
+typedef unsigned long Leds;
+typedef struct _OtherClients *OtherClientsPtr;
+typedef struct _InputClients *InputClientsPtr;
+typedef struct _DeviceIntRec *DeviceIntPtr;
+
+typedef int (*DeviceProc)(
+ DeviceIntPtr /*device*/,
+ int /*what*/);
+
+typedef void (*ProcessInputProc)(
+ xEventPtr /*events*/,
+ DeviceIntPtr /*device*/,
+ int /*count*/);
+
+typedef Bool (*DeviceHandleProc)(
+ DeviceIntPtr /*device*/,
+ void* /*data*/
+ );
+
+typedef void (*DeviceUnwrapProc)(
+ DeviceIntPtr /*device*/,
+ DeviceHandleProc /*proc*/,
+ void* /*data*/
+ );
+
+typedef struct _DeviceRec {
+ pointer devicePrivate;
+ ProcessInputProc processInputProc; /* current */
+ ProcessInputProc realInputProc; /* deliver */
+ ProcessInputProc enqueueInputProc; /* enqueue */
+ Bool on; /* used by DDX to keep state */
+} DeviceRec, *DevicePtr;
+
+typedef struct {
+ int click, bell, bell_pitch, bell_duration;
+ Bool autoRepeat;
+ unsigned char autoRepeats[32];
+ Leds leds;
+ unsigned char id;
+} KeybdCtrl;
+
+typedef struct {
+ KeySym *map;
+ KeyCode minKeyCode,
+ maxKeyCode;
+ int mapWidth;
+} KeySymsRec, *KeySymsPtr;
+
+typedef struct {
+ int num, den, threshold;
+ unsigned char id;
+} PtrCtrl;
+
+typedef struct {
+ int resolution, min_value, max_value;
+ int integer_displayed;
+ unsigned char id;
+} IntegerCtrl;
+
+typedef struct {
+ int max_symbols, num_symbols_supported;
+ int num_symbols_displayed;
+ KeySym *symbols_supported;
+ KeySym *symbols_displayed;
+ unsigned char id;
+} StringCtrl;
+
+typedef struct {
+ int percent, pitch, duration;
+ unsigned char id;
+} BellCtrl;
+
+typedef struct {
+ Leds led_values;
+ Mask led_mask;
+ unsigned char id;
+} LedCtrl;
+
+extern int AllocateDevicePrivateIndex(void);
+extern Bool AllocateDevicePrivate(DeviceIntPtr device, int index);
+extern void ResetDevicePrivateIndex(void);
+
+extern KeybdCtrl defaultKeyboardControl;
+extern PtrCtrl defaultPointerControl;
+
+#undef AddInputDevice
+extern DevicePtr AddInputDevice(
+ DeviceProc /*deviceProc*/,
+ Bool /*autoStart*/);
+
+#define AddInputDevice(deviceProc, autoStart) \
+ _AddInputDevice(deviceProc, autoStart)
+
+extern DeviceIntPtr _AddInputDevice(
+ DeviceProc /*deviceProc*/,
+ Bool /*autoStart*/);
+
+extern Bool EnableDevice(
+ DeviceIntPtr /*device*/);
+
+extern Bool DisableDevice(
+ DeviceIntPtr /*device*/);
+
+extern int InitAndStartDevices(void);
+
+extern void CloseDownDevices(void);
+
+extern void RemoveDevice(
+ DeviceIntPtr /*dev*/);
+
+extern int NumMotionEvents(void);
+
+#undef RegisterPointerDevice
+extern void RegisterPointerDevice(
+ DevicePtr /*device*/);
+
+#define RegisterPointerDevice(device) \
+ _RegisterPointerDevice(device)
+
+extern void _RegisterPointerDevice(
+ DeviceIntPtr /*device*/);
+
+#undef RegisterKeyboardDevice
+extern void RegisterKeyboardDevice(
+ DevicePtr /*device*/);
+
+#define RegisterKeyboardDevice(device) \
+ _RegisterKeyboardDevice(device)
+
+extern void _RegisterKeyboardDevice(
+ DeviceIntPtr /*device*/);
+
+extern DevicePtr LookupKeyboardDevice(void);
+
+extern DevicePtr LookupPointerDevice(void);
+
+extern DevicePtr LookupDevice(
+ int /* id */);
+
+extern void QueryMinMaxKeyCodes(
+ KeyCode* /*minCode*/,
+ KeyCode* /*maxCode*/);
+
+extern Bool SetKeySymsMap(
+ KeySymsPtr /*dst*/,
+ KeySymsPtr /*src*/);
+
+extern Bool InitKeyClassDeviceStruct(
+ DeviceIntPtr /*device*/,
+ KeySymsPtr /*pKeySyms*/,
+ CARD8 /*pModifiers*/[]);
+
+extern Bool InitButtonClassDeviceStruct(
+ DeviceIntPtr /*device*/,
+ int /*numButtons*/,
+ CARD8* /*map*/);
+
+typedef int (*ValuatorMotionProcPtr)(
+ DeviceIntPtr /*pdevice*/,
+ xTimecoord * /*coords*/,
+ unsigned long /*start*/,
+ unsigned long /*stop*/,
+ ScreenPtr /*pScreen*/);
+
+extern Bool InitValuatorClassDeviceStruct(
+ DeviceIntPtr /*device*/,
+ int /*numAxes*/,
+ ValuatorMotionProcPtr /* motionProc */,
+ int /*numMotionEvents*/,
+ int /*mode*/);
+
+extern Bool InitFocusClassDeviceStruct(
+ DeviceIntPtr /*device*/);
+
+typedef void (*BellProcPtr)(
+ int /*percent*/,
+ DeviceIntPtr /*device*/,
+ pointer /*ctrl*/,
+ int);
+
+typedef void (*KbdCtrlProcPtr)(
+ DeviceIntPtr /*device*/,
+ KeybdCtrl * /*ctrl*/);
+
+extern Bool InitKbdFeedbackClassDeviceStruct(
+ DeviceIntPtr /*device*/,
+ BellProcPtr /*bellProc*/,
+ KbdCtrlProcPtr /*controlProc*/);
+
+typedef void (*PtrCtrlProcPtr)(
+ DeviceIntPtr /*device*/,
+ PtrCtrl * /*ctrl*/);
+
+extern Bool InitPtrFeedbackClassDeviceStruct(
+ DeviceIntPtr /*device*/,
+ PtrCtrlProcPtr /*controlProc*/);
+
+typedef void (*StringCtrlProcPtr)(
+ DeviceIntPtr /*device*/,
+ StringCtrl * /*ctrl*/);
+
+extern Bool InitStringFeedbackClassDeviceStruct(
+ DeviceIntPtr /*device*/,
+ StringCtrlProcPtr /*controlProc*/,
+ int /*max_symbols*/,
+ int /*num_symbols_supported*/,
+ KeySym* /*symbols*/);
+
+typedef void (*BellCtrlProcPtr)(
+ DeviceIntPtr /*device*/,
+ BellCtrl * /*ctrl*/);
+
+extern Bool InitBellFeedbackClassDeviceStruct(
+ DeviceIntPtr /*device*/,
+ BellProcPtr /*bellProc*/,
+ BellCtrlProcPtr /*controlProc*/);
+
+typedef void (*LedCtrlProcPtr)(
+ DeviceIntPtr /*device*/,
+ LedCtrl * /*ctrl*/);
+
+extern Bool InitLedFeedbackClassDeviceStruct(
+ DeviceIntPtr /*device*/,
+ LedCtrlProcPtr /*controlProc*/);
+
+typedef void (*IntegerCtrlProcPtr)(
+ DeviceIntPtr /*device*/,
+ IntegerCtrl * /*ctrl*/);
+
+
+extern Bool InitIntegerFeedbackClassDeviceStruct(
+ DeviceIntPtr /*device*/,
+ IntegerCtrlProcPtr /*controlProc*/);
+
+extern Bool InitPointerDeviceStruct(
+ DevicePtr /*device*/,
+ CARD8* /*map*/,
+ int /*numButtons*/,
+ ValuatorMotionProcPtr /*motionProc*/,
+ PtrCtrlProcPtr /*controlProc*/,
+ int /*numMotionEvents*/);
+
+extern Bool InitKeyboardDeviceStruct(
+ DevicePtr /*device*/,
+ KeySymsPtr /*pKeySyms*/,
+ CARD8 /*pModifiers*/[],
+ BellProcPtr /*bellProc*/,
+ KbdCtrlProcPtr /*controlProc*/);
+
+extern void SendMappingNotify(
+ unsigned int /*request*/,
+ unsigned int /*firstKeyCode*/,
+ unsigned int /*count*/,
+ ClientPtr /* client */);
+
+extern Bool BadDeviceMap(
+ BYTE* /*buff*/,
+ int /*length*/,
+ unsigned /*low*/,
+ unsigned /*high*/,
+ XID* /*errval*/);
+
+extern Bool AllModifierKeysAreUp(
+ DeviceIntPtr /*device*/,
+ CARD8* /*map1*/,
+ int /*per1*/,
+ CARD8* /*map2*/,
+ int /*per2*/);
+
+extern void NoteLedState(
+ DeviceIntPtr /*keybd*/,
+ int /*led*/,
+ Bool /*on*/);
+
+extern void MaybeStopHint(
+ DeviceIntPtr /*device*/,
+ ClientPtr /*client*/);
+
+extern void ProcessPointerEvent(
+ xEventPtr /*xE*/,
+ DeviceIntPtr /*mouse*/,
+ int /*count*/);
+
+extern void ProcessKeyboardEvent(
+ xEventPtr /*xE*/,
+ DeviceIntPtr /*keybd*/,
+ int /*count*/);
+
+#ifdef XKB
+extern void CoreProcessPointerEvent(
+ xEventPtr /*xE*/,
+ DeviceIntPtr /*mouse*/,
+ int /*count*/);
+
+extern void CoreProcessKeyboardEvent(
+ xEventPtr /*xE*/,
+ DeviceIntPtr /*keybd*/,
+ int /*count*/);
+#endif
+
+extern Bool LegalModifier(
+ unsigned int /*key*/,
+ DevicePtr /*pDev*/);
+
+extern void ProcessInputEvents(void);
+
+extern void InitInput(
+ int /*argc*/,
+ char ** /*argv*/);
+
+#endif /* INPUT_H */
diff --git a/nx-X11/programs/Xserver/include/inputstr.h b/nx-X11/programs/Xserver/include/inputstr.h
new file mode 100644
index 000000000..b54e8a1d5
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/inputstr.h
@@ -0,0 +1,314 @@
+/* $XFree86: xc/programs/Xserver/include/inputstr.h,v 1.6 2003/04/27 21:31:04 herrb Exp $ */
+/************************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+
+/* $Xorg: inputstr.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+
+#ifndef INPUTSTRUCT_H
+#define INPUTSTRUCT_H
+
+#include "input.h"
+#include "window.h"
+#include "dixstruct.h"
+
+#define BitIsOn(ptr, bit) (((BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7)))
+
+#define SameClient(obj,client) \
+ (CLIENT_BITS((obj)->resource) == (client)->clientAsMask)
+
+#define MAX_DEVICES 20
+
+#define EMASKSIZE MAX_DEVICES
+
+/* Kludge: OtherClients and InputClients must be compatible, see code */
+
+typedef struct _OtherClients {
+ OtherClientsPtr next;
+ XID resource; /* id for putting into resource manager */
+ Mask mask;
+} OtherClients;
+
+typedef struct _InputClients {
+ InputClientsPtr next;
+ XID resource; /* id for putting into resource manager */
+ Mask mask[EMASKSIZE];
+} InputClients;
+
+typedef struct _OtherInputMasks {
+ Mask deliverableEvents[EMASKSIZE];
+ Mask inputEvents[EMASKSIZE];
+ Mask dontPropagateMask[EMASKSIZE];
+ InputClientsPtr inputClients;
+} OtherInputMasks;
+
+/*
+ * The following structure gets used for both active and passive grabs. For
+ * active grabs some of the fields (e.g. modifiers) are not used. However,
+ * that is not much waste since there aren't many active grabs (one per
+ * keyboard/pointer device) going at once in the server.
+ */
+
+#define MasksPerDetailMask 8 /* 256 keycodes and 256 possible
+ modifier combinations, but only
+ 3 buttons. */
+
+ typedef struct _DetailRec { /* Grab details may be bit masks */
+ unsigned short exact;
+ Mask *pMask;
+ } DetailRec;
+
+ typedef struct _GrabRec {
+ GrabPtr next; /* for chain of passive grabs */
+ XID resource;
+ DeviceIntPtr device;
+ WindowPtr window;
+ unsigned ownerEvents:1;
+ unsigned keyboardMode:1;
+ unsigned pointerMode:1;
+ unsigned coreGrab:1; /* grab is on core device */
+ unsigned coreMods:1; /* modifiers are on core keyboard */
+ CARD8 type; /* event type */
+ DetailRec modifiersDetail;
+ DeviceIntPtr modifierDevice;
+ DetailRec detail; /* key or button */
+ WindowPtr confineTo; /* always NULL for keyboards */
+ CursorPtr cursor; /* always NULL for keyboards */
+ Mask eventMask;
+} GrabRec;
+
+typedef struct _KeyClassRec {
+ CARD8 down[DOWN_LENGTH];
+ KeyCode *modifierKeyMap;
+ KeySymsRec curKeySyms;
+ int modifierKeyCount[8];
+ CARD8 modifierMap[MAP_LENGTH];
+ CARD8 maxKeysPerModifier;
+ unsigned short state;
+ unsigned short prev_state;
+#ifdef XKB
+ struct _XkbSrvInfo *xkbInfo;
+#endif
+} KeyClassRec, *KeyClassPtr;
+
+typedef struct _AxisInfo {
+ int resolution;
+ int min_resolution;
+ int max_resolution;
+ int min_value;
+ int max_value;
+} AxisInfo, *AxisInfoPtr;
+
+typedef struct _ValuatorClassRec {
+ ValuatorMotionProcPtr GetMotionProc;
+ int numMotionEvents;
+ WindowPtr motionHintWindow;
+ AxisInfoPtr axes;
+ unsigned short numAxes;
+ int *axisVal;
+ CARD8 mode;
+} ValuatorClassRec, *ValuatorClassPtr;
+
+typedef struct _ButtonClassRec {
+ CARD8 numButtons;
+ CARD8 buttonsDown; /* number of buttons currently down */
+ unsigned short state;
+ Mask motionMask;
+ CARD8 down[DOWN_LENGTH];
+ CARD8 map[MAP_LENGTH];
+#ifdef XKB
+ union _XkbAction * xkb_acts;
+#endif
+} ButtonClassRec, *ButtonClassPtr;
+
+typedef struct _FocusClassRec {
+ WindowPtr win;
+ int revert;
+ TimeStamp time;
+ WindowPtr *trace;
+ int traceSize;
+ int traceGood;
+} FocusClassRec, *FocusClassPtr;
+
+typedef struct _ProximityClassRec {
+ char pad;
+} ProximityClassRec, *ProximityClassPtr;
+
+typedef struct _KbdFeedbackClassRec *KbdFeedbackPtr;
+typedef struct _PtrFeedbackClassRec *PtrFeedbackPtr;
+typedef struct _IntegerFeedbackClassRec *IntegerFeedbackPtr;
+typedef struct _StringFeedbackClassRec *StringFeedbackPtr;
+typedef struct _BellFeedbackClassRec *BellFeedbackPtr;
+typedef struct _LedFeedbackClassRec *LedFeedbackPtr;
+
+typedef struct _KbdFeedbackClassRec {
+ BellProcPtr BellProc;
+ KbdCtrlProcPtr CtrlProc;
+ KeybdCtrl ctrl;
+ KbdFeedbackPtr next;
+#ifdef XKB
+ struct _XkbSrvLedInfo *xkb_sli;
+#endif
+} KbdFeedbackClassRec;
+
+typedef struct _PtrFeedbackClassRec {
+ PtrCtrlProcPtr CtrlProc;
+ PtrCtrl ctrl;
+ PtrFeedbackPtr next;
+} PtrFeedbackClassRec;
+
+typedef struct _IntegerFeedbackClassRec {
+ IntegerCtrlProcPtr CtrlProc;
+ IntegerCtrl ctrl;
+ IntegerFeedbackPtr next;
+} IntegerFeedbackClassRec;
+
+typedef struct _StringFeedbackClassRec {
+ StringCtrlProcPtr CtrlProc;
+ StringCtrl ctrl;
+ StringFeedbackPtr next;
+} StringFeedbackClassRec;
+
+typedef struct _BellFeedbackClassRec {
+ BellProcPtr BellProc;
+ BellCtrlProcPtr CtrlProc;
+ BellCtrl ctrl;
+ BellFeedbackPtr next;
+} BellFeedbackClassRec;
+
+typedef struct _LedFeedbackClassRec {
+ LedCtrlProcPtr CtrlProc;
+ LedCtrl ctrl;
+ LedFeedbackPtr next;
+#ifdef XKB
+ struct _XkbSrvLedInfo *xkb_sli;
+#endif
+} LedFeedbackClassRec;
+
+/* states for devices */
+
+#define NOT_GRABBED 0
+#define THAWED 1
+#define THAWED_BOTH 2 /* not a real state */
+#define FREEZE_NEXT_EVENT 3
+#define FREEZE_BOTH_NEXT_EVENT 4
+#define FROZEN 5 /* any state >= has device frozen */
+#define FROZEN_NO_EVENT 5
+#define FROZEN_WITH_EVENT 6
+#define THAW_OTHERS 7
+
+typedef struct _DeviceIntRec {
+ DeviceRec public;
+ DeviceIntPtr next;
+ TimeStamp grabTime;
+ Bool startup; /* true if needs to be turned on at
+ server intialization time */
+ DeviceProc deviceProc; /* proc(DevicePtr, DEVICE_xx). It is
+ used to initialize, turn on, or
+ turn off the device */
+ Bool inited; /* TRUE if INIT returns Success */
+ GrabPtr grab; /* the grabber - used by DIX */
+ struct {
+ Bool frozen;
+ int state;
+ GrabPtr other; /* if other grab has this frozen */
+ xEvent *event; /* saved to be replayed */
+ int evcount;
+ } sync;
+ Atom type;
+ char *name;
+ CARD8 id;
+ CARD8 activatingKey;
+ Bool fromPassiveGrab;
+ GrabRec activeGrab;
+ void (*ActivateGrab) (
+ DeviceIntPtr /*device*/,
+ GrabPtr /*grab*/,
+ TimeStamp /*time*/,
+ Bool /*autoGrab*/);
+ void (*DeactivateGrab)(
+ DeviceIntPtr /*device*/);
+ KeyClassPtr key;
+ ValuatorClassPtr valuator;
+ ButtonClassPtr button;
+ FocusClassPtr focus;
+ ProximityClassPtr proximity;
+ KbdFeedbackPtr kbdfeed;
+ PtrFeedbackPtr ptrfeed;
+ IntegerFeedbackPtr intfeed;
+ StringFeedbackPtr stringfeed;
+ BellFeedbackPtr bell;
+ LedFeedbackPtr leds;
+#ifdef XKB
+ struct _XkbInterest * xkb_interest;
+#endif
+ DevUnion *devPrivates;
+ int nPrivates;
+ DeviceUnwrapProc unwrapProc;
+} DeviceIntRec;
+
+typedef struct {
+ int numDevices; /* total number of devices */
+ DeviceIntPtr devices; /* all devices turned on */
+ DeviceIntPtr off_devices; /* all devices turned off */
+ DeviceIntPtr keyboard; /* the main one for the server */
+ DeviceIntPtr pointer;
+} InputInfo;
+
+extern InputInfo inputInfo;
+
+/* for keeping the events for devices grabbed synchronously */
+typedef struct _QdEvent *QdEventPtr;
+typedef struct _QdEvent {
+ QdEventPtr next;
+ DeviceIntPtr device;
+ ScreenPtr pScreen; /* what screen the pointer was on */
+ unsigned long months; /* milliseconds is in the event */
+ xEvent *event;
+ int evcount;
+} QdEventRec;
+
+#endif /* INPUTSTRUCT_H */
diff --git a/nx-X11/programs/Xserver/include/misc.h b/nx-X11/programs/Xserver/include/misc.h
new file mode 100644
index 000000000..5944a427f
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/misc.h
@@ -0,0 +1,269 @@
+/* $XFree86: xc/programs/Xserver/include/misc.h,v 3.28 2001/12/14 19:59:55 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+Copyright 1992, 1993 Data General Corporation;
+Copyright 1992, 1993 OMRON Corporation
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that the
+above copyright notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting documentation, and that
+neither the name OMRON or DATA GENERAL be used in advertising or publicity
+pertaining to distribution of the software without specific, written prior
+permission of the party whose name is to be used. Neither OMRON or
+DATA GENERAL make any representation about the suitability of this software
+for any purpose. It is provided "as is" without express or implied warranty.
+
+OMRON AND DATA GENERAL EACH DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL OMRON OR DATA GENERAL BE LIABLE FOR ANY SPECIAL, INDIRECT
+OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+OF THIS SOFTWARE.
+
+******************************************************************/
+/* $Xorg: misc.h,v 1.5 2001/02/09 02:05:15 xorgcvs Exp $ */
+#ifndef MISC_H
+#define MISC_H 1
+/*
+ * X internal definitions
+ *
+ */
+
+extern unsigned long globalSerialNumber;
+extern unsigned long serverGeneration;
+
+#include <X11/Xosdefs.h>
+#include <X11/Xfuncproto.h>
+#include <X11/Xmd.h>
+#include <X11/X.h>
+#include <X11/Xdefs.h>
+
+#ifndef IN_MODULE
+#ifndef NULL
+#include <stddef.h>
+#endif
+#endif
+
+#ifndef MAXSCREENS
+#define MAXSCREENS 16
+#endif
+#define MAXCLIENTS 256
+#define MAXDITS 1
+#define MAXEXTENSIONS 128
+#define MAXFORMATS 8
+#define MAXVISUALS_PER_SCREEN 50
+
+typedef unsigned long PIXEL;
+typedef unsigned long ATOM;
+
+
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
+#ifndef _XTYPEDEF_CALLBACKLISTPTR
+typedef struct _CallbackList *CallbackListPtr; /* also in dix.h */
+#define _XTYPEDEF_CALLBACKLISTPTR
+#endif
+
+typedef struct _xReq *xReqPtr;
+
+#include "os.h" /* for ALLOCATE_LOCAL and DEALLOCATE_LOCAL */
+#ifndef IN_MODULE
+#include <X11/Xfuncs.h> /* for bcopy, bzero, and bcmp */
+#endif
+
+#define NullBox ((BoxPtr)0)
+#define MILLI_PER_MIN (1000 * 60)
+#define MILLI_PER_SECOND (1000)
+
+ /* this next is used with None and ParentRelative to tell
+ PaintWin() what to use to paint the background. Also used
+ in the macro IS_VALID_PIXMAP */
+
+#define USE_BACKGROUND_PIXEL 3
+#define USE_BORDER_PIXEL 3
+
+
+/* byte swap a 32-bit literal */
+#define lswapl(x) ((((x) & 0xff) << 24) |\
+ (((x) & 0xff00) << 8) |\
+ (((x) & 0xff0000) >> 8) |\
+ (((x) >> 24) & 0xff))
+
+/* byte swap a short literal */
+#define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
+
+#undef min
+#undef max
+
+#define min(a, b) (((a) < (b)) ? (a) : (b))
+#define max(a, b) (((a) > (b)) ? (a) : (b))
+#ifndef IN_MODULE
+/* abs() is a function, not a macro; include the file declaring
+ * it in case we haven't done that yet.
+ */
+#include <stdlib.h>
+#endif /* IN_MODULE */
+#ifndef Fabs
+#define Fabs(a) ((a) > 0.0 ? (a) : -(a)) /* floating absolute value */
+#endif
+#define sign(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))
+/* this assumes b > 0 */
+#define modulus(a, b, d) if (((d) = (a) % (b)) < 0) (d) += (b)
+/*
+ * return the least significant bit in x which is set
+ *
+ * This works on 1's complement and 2's complement machines.
+ * If you care about the extra instruction on 2's complement
+ * machines, change to ((x) & (-(x)))
+ */
+#define lowbit(x) ((x) & (~(x) + 1))
+
+#ifndef IN_MODULE
+/* XXX Not for modules */
+#include <limits.h>
+#if !defined(MAXSHORT) || !defined(MINSHORT) || \
+ !defined(MAXINT) || !defined(MININT)
+/*
+ * Some implementations #define these through <math.h>, so preclude
+ * #include'ing it later.
+ */
+
+#include <math.h>
+#endif
+#undef MAXSHORT
+#define MAXSHORT SHRT_MAX
+#undef MINSHORT
+#define MINSHORT SHRT_MIN
+#undef MAXINT
+#define MAXINT INT_MAX
+#undef MININT
+#define MININT INT_MIN
+
+#include <assert.h>
+#include <ctype.h>
+#include <stdio.h> /* for fopen, etc... */
+
+#endif
+
+/* some macros to help swap requests, replies, and events */
+
+#define LengthRestB(stuff) \
+ ((client->req_len << 2) - sizeof(*stuff))
+
+#define LengthRestS(stuff) \
+ ((client->req_len << 1) - (sizeof(*stuff) >> 1))
+
+#define LengthRestL(stuff) \
+ (client->req_len - (sizeof(*stuff) >> 2))
+
+#define SwapRestS(stuff) \
+ SwapShorts((short *)(stuff + 1), LengthRestS(stuff))
+
+#define SwapRestL(stuff) \
+ SwapLongs((CARD32 *)(stuff + 1), LengthRestL(stuff))
+
+/* byte swap a 32-bit value */
+#define swapl(x, n) { \
+ n = ((char *) (x))[0];\
+ ((char *) (x))[0] = ((char *) (x))[3];\
+ ((char *) (x))[3] = n;\
+ n = ((char *) (x))[1];\
+ ((char *) (x))[1] = ((char *) (x))[2];\
+ ((char *) (x))[2] = n; }
+
+/* byte swap a short */
+#define swaps(x, n) { \
+ n = ((char *) (x))[0];\
+ ((char *) (x))[0] = ((char *) (x))[1];\
+ ((char *) (x))[1] = n; }
+
+/* copy 32-bit value from src to dst byteswapping on the way */
+#define cpswapl(src, dst) { \
+ ((char *)&(dst))[0] = ((char *) &(src))[3];\
+ ((char *)&(dst))[1] = ((char *) &(src))[2];\
+ ((char *)&(dst))[2] = ((char *) &(src))[1];\
+ ((char *)&(dst))[3] = ((char *) &(src))[0]; }
+
+/* copy short from src to dst byteswapping on the way */
+#define cpswaps(src, dst) { \
+ ((char *) &(dst))[0] = ((char *) &(src))[1];\
+ ((char *) &(dst))[1] = ((char *) &(src))[0]; }
+
+extern void SwapLongs(
+ CARD32 *list,
+ unsigned long count);
+
+extern void SwapShorts(
+ short *list,
+ unsigned long count);
+
+extern void MakePredeclaredAtoms(void);
+
+extern int Ones(
+ unsigned long /*mask*/);
+
+typedef struct _xPoint *DDXPointPtr;
+typedef struct _Box *BoxPtr;
+typedef struct _xEvent *xEventPtr;
+typedef struct _xRectangle *xRectanglePtr;
+typedef struct _GrabRec *GrabPtr;
+
+/* typedefs from other places - duplicated here to minimize the amount
+ * of unnecessary junk that one would normally have to include to get
+ * these symbols defined
+ */
+
+#ifndef _XTYPEDEF_CHARINFOPTR
+typedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */
+#define _XTYPEDEF_CHARINFOPTR
+#endif
+
+#endif /* MISC_H */
diff --git a/nx-X11/programs/Xserver/include/miscstruct.h b/nx-X11/programs/Xserver/include/miscstruct.h
new file mode 100644
index 000000000..6a16007b7
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/miscstruct.h
@@ -0,0 +1,80 @@
+/* $Xorg: miscstruct.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/include/miscstruct.h,v 3.4 2003/04/27 21:31:04 herrb Exp $ */
+
+#ifndef MISCSTRUCT_H
+#define MISCSTRUCT_H 1
+
+#include "misc.h"
+#include <X11/Xprotostr.h>
+#include "gc.h"
+
+typedef xPoint DDXPointRec;
+
+typedef struct _Box {
+ short x1, y1, x2, y2;
+} BoxRec;
+
+typedef union _DevUnion {
+ pointer ptr;
+ long val;
+ unsigned long uval;
+ RegionPtr (*fptr)(
+ DrawablePtr /* pSrcDrawable */,
+ DrawablePtr /* pDstDrawable */,
+ GCPtr /* pGC */,
+ int /* srcx */,
+ int /* srcy */,
+ int /* width */,
+ int /* height */,
+ int /* dstx */,
+ int /* dsty */,
+ unsigned long /* bitPlane */);
+} DevUnion;
+
+#endif /* MISCSTRUCT_H */
diff --git a/nx-X11/programs/Xserver/include/opaque.h b/nx-X11/programs/Xserver/include/opaque.h
new file mode 100644
index 000000000..ca29afdc0
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/opaque.h
@@ -0,0 +1,83 @@
+/* $Xorg: opaque.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/include/opaque.h,v 1.13 2003/07/24 13:50:25 eich Exp $ */
+
+#ifndef OPAQUE_H
+#define OPAQUE_H
+
+#include <X11/Xmd.h>
+
+#include "globals.h"
+
+extern char *defaultTextFont;
+extern char *defaultCursorFont;
+extern int MaxClients;
+extern volatile char isItTimeToYield;
+extern volatile char dispatchException;
+
+/* bit values for dispatchException */
+#define DE_RESET 1
+#define DE_TERMINATE 2
+#define DE_PRIORITYCHANGE 4 /* set when a client's priority changes */
+
+extern CARD32 TimeOutValue;
+extern int ScreenSaverBlanking;
+extern int ScreenSaverAllowExposures;
+extern int defaultScreenSaverBlanking;
+extern int defaultScreenSaverAllowExposures;
+extern int argcGlobal;
+extern char **argvGlobal;
+extern char *display;
+
+extern int defaultBackingStore;
+extern Bool disableBackingStore;
+extern Bool enableBackingStore;
+extern Bool disableSaveUnders;
+extern Bool PartialNetwork;
+#ifndef NOLOGOHACK
+extern int logoScreenSaver;
+#endif
+#ifdef RLIMIT_DATA
+extern int limitDataSpace;
+#endif
+#ifdef RLIMIT_STACK
+extern int limitStackSpace;
+#endif
+#ifdef RLIMIT_NOFILE
+extern int limitNoFile;
+#endif
+extern Bool permitOldBugs;
+extern Bool defeatAccessControl;
+extern long maxBigRequestSize;
+extern Bool blackRoot;
+
+extern Bool CoreDump;
+
+
+#endif /* OPAQUE_H */
diff --git a/nx-X11/programs/Xserver/include/os.h b/nx-X11/programs/Xserver/include/os.h
new file mode 100644
index 000000000..0b3354eec
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/os.h
@@ -0,0 +1,546 @@
+/* $XFree86: xc/programs/Xserver/include/os.h,v 3.54 2003/10/30 21:21:06 herrb Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* $Xorg: os.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+
+#ifndef OS_H
+#define OS_H
+
+#include "misc.h"
+#define ALLOCATE_LOCAL_FALLBACK(_size) Xalloc((unsigned long)(_size))
+#define DEALLOCATE_LOCAL_FALLBACK(_ptr) Xfree((pointer)(_ptr))
+#include <X11/Xalloca.h>
+#ifndef IN_MODULE
+#include <stdarg.h>
+#else
+#include "xf86_ansic.h"
+#endif
+
+#define NullFID ((FID) 0)
+
+#define SCREEN_SAVER_ON 0
+#define SCREEN_SAVER_OFF 1
+#define SCREEN_SAVER_FORCER 2
+#define SCREEN_SAVER_CYCLE 3
+
+#ifndef MAX_REQUEST_SIZE
+#define MAX_REQUEST_SIZE 65535
+#endif
+#ifndef MAX_BIG_REQUEST_SIZE
+#define MAX_BIG_REQUEST_SIZE 4194303
+#endif
+
+typedef pointer FID;
+typedef struct _FontPathRec *FontPathPtr;
+typedef struct _NewClientRec *NewClientPtr;
+
+#ifndef xalloc
+#define xnfalloc(size) XNFalloc((unsigned long)(size))
+#define xnfcalloc(_num, _size) XNFcalloc((unsigned long)(_num)*(unsigned long)(_size))
+#define xnfrealloc(ptr, size) XNFrealloc((pointer)(ptr), (unsigned long)(size))
+
+#define xalloc(size) Xalloc((unsigned long)(size))
+#define xcalloc(_num, _size) Xcalloc((unsigned long)(_num)*(unsigned long)(_size))
+#define xrealloc(ptr, size) Xrealloc((pointer)(ptr), (unsigned long)(size))
+#define xfree(ptr) Xfree((pointer)(ptr))
+#define xstrdup(s) Xstrdup(s)
+#define xnfstrdup(s) XNFstrdup(s)
+#endif
+
+#ifndef IN_MODULE
+#ifdef __SCO__
+#include <stdio.h>
+#endif
+#include <string.h>
+#endif
+
+/* have to put $(SIGNAL_DEFINES) in DEFINES in Imakefile to get this right */
+#ifdef SIGNALRETURNSINT
+#define SIGVAL int
+#else
+#define SIGVAL void
+#endif
+
+extern Bool OsDelayInitColors;
+extern void (*OsVendorVErrorFProc)(const char *, va_list args);
+
+extern int WaitForSomething(
+ int* /*pClientsReady*/
+);
+
+#ifdef LBX
+#define ReadRequestFromClient(client) ((client)->readRequest(client))
+extern int StandardReadRequestFromClient(ClientPtr /*client*/);
+
+extern int ClientConnectionNumber(ClientPtr /*client*/);
+#else
+extern int ReadRequestFromClient(ClientPtr /*client*/);
+#endif /* LBX */
+
+extern Bool InsertFakeRequest(
+ ClientPtr /*client*/,
+ char* /*data*/,
+ int /*count*/);
+
+extern void ResetCurrentRequest(ClientPtr /*client*/);
+
+extern void FlushAllOutput(void);
+
+extern void FlushIfCriticalOutputPending(void);
+
+extern void SetCriticalOutputPending(void);
+
+extern int WriteToClient(ClientPtr /*who*/, int /*count*/, char* /*buf*/);
+
+extern void ResetOsBuffers(void);
+
+extern void InitConnectionLimits(void);
+
+extern void CreateWellKnownSockets(void);
+
+extern void ResetWellKnownSockets(void);
+
+extern void CloseWellKnownConnections(void);
+
+extern XID AuthorizationIDOfClient(ClientPtr /*client*/);
+
+extern char *ClientAuthorized(
+ ClientPtr /*client*/,
+ unsigned int /*proto_n*/,
+ char* /*auth_proto*/,
+ unsigned int /*string_n*/,
+ char* /*auth_string*/);
+
+extern Bool EstablishNewConnections(
+ ClientPtr /*clientUnused*/,
+ pointer /*closure*/);
+
+extern void CheckConnections(void);
+
+extern void CloseDownConnection(ClientPtr /*client*/);
+
+extern void AddEnabledDevice(int /*fd*/);
+
+extern void RemoveEnabledDevice(int /*fd*/);
+
+extern void OnlyListenToOneClient(ClientPtr /*client*/);
+
+extern void ListenToAllClients(void);
+
+extern void IgnoreClient(ClientPtr /*client*/);
+
+extern void AttendClient(ClientPtr /*client*/);
+
+extern void MakeClientGrabImpervious(ClientPtr /*client*/);
+
+extern void MakeClientGrabPervious(ClientPtr /*client*/);
+
+#ifdef LBX
+extern void CloseDownFileDescriptor(ClientPtr /* client */);
+#endif
+
+extern void AvailableClientInput(ClientPtr /* client */);
+
+extern CARD32 GetTimeInMillis(void);
+
+extern void AdjustWaitForDelay(
+ pointer /*waitTime*/,
+ unsigned long /*newdelay*/);
+
+typedef struct _OsTimerRec *OsTimerPtr;
+
+typedef CARD32 (*OsTimerCallback)(
+ OsTimerPtr /* timer */,
+ CARD32 /* time */,
+ pointer /* arg */);
+
+extern void TimerInit(void);
+
+extern Bool TimerForce(OsTimerPtr /* timer */);
+
+#define TimerAbsolute (1<<0)
+#define TimerForceOld (1<<1)
+
+extern OsTimerPtr TimerSet(
+ OsTimerPtr /* timer */,
+ int /* flags */,
+ CARD32 /* millis */,
+ OsTimerCallback /* func */,
+ pointer /* arg */);
+
+extern void TimerCheck(void);
+extern void TimerCancel(OsTimerPtr /* pTimer */);
+extern void TimerFree(OsTimerPtr /* pTimer */);
+
+extern void SetScreenSaverTimer(void);
+extern void FreeScreenSaverTimer(void);
+
+#ifdef DPMSExtension
+extern void SetDPMSTimers(void);
+extern void FreeDPMSTimers(void);
+#endif
+
+extern SIGVAL AutoResetServer(int /*sig*/);
+
+extern SIGVAL GiveUp(int /*sig*/);
+
+extern void UseMsg(void);
+
+extern void InitGlobals(void);
+
+extern void ProcessCommandLine(int /*argc*/, char* /*argv*/[]);
+
+extern int set_font_authorizations(
+ char ** /* authorizations */,
+ int * /*authlen */,
+ pointer /* client */);
+
+#ifndef _HAVE_XALLOC_DECLS
+#define _HAVE_XALLOC_DECLS
+extern pointer Xalloc(unsigned long /*amount*/);
+extern pointer Xcalloc(unsigned long /*amount*/);
+extern pointer Xrealloc(pointer /*ptr*/, unsigned long /*amount*/);
+extern void Xfree(pointer /*ptr*/);
+#endif
+
+extern pointer XNFalloc(unsigned long /*amount*/);
+extern pointer XNFcalloc(unsigned long /*amount*/);
+extern pointer XNFrealloc(pointer /*ptr*/, unsigned long /*amount*/);
+
+extern void OsInitAllocator(void);
+
+extern char *Xstrdup(const char *s);
+extern char *XNFstrdup(const char *s);
+extern char *Xprintf(const char *fmt, ...);
+extern char *Xvprintf(const char *fmt, va_list va);
+extern char *XNFprintf(const char *fmt, ...);
+extern char *XNFvprintf(const char *fmt, va_list va);
+
+typedef SIGVAL (*OsSigHandlerPtr)(int /* sig */);
+
+extern OsSigHandlerPtr OsSignal(int /* sig */, OsSigHandlerPtr /* handler */);
+
+extern int auditTrailLevel;
+
+#ifdef SERVER_LOCK
+extern void LockServer(void);
+extern void UnlockServer(void);
+#endif
+
+extern int OsLookupColor(
+ int /*screen*/,
+ char * /*name*/,
+ unsigned /*len*/,
+ unsigned short * /*pred*/,
+ unsigned short * /*pgreen*/,
+ unsigned short * /*pblue*/);
+
+extern void OsInit(void);
+
+extern void OsCleanup(Bool);
+
+extern void OsVendorFatalError(void);
+
+extern void OsVendorInit(void);
+
+extern int OsInitColors(void);
+
+void OsBlockSignals (void);
+
+void OsReleaseSignals (void);
+
+#if !defined(WIN32) && !defined(__UNIXOS2__)
+extern int System(char *);
+extern pointer Popen(char *, char *);
+extern int Pclose(pointer);
+extern pointer Fopen(char *, char *);
+extern int Fclose(pointer);
+#else
+#define System(a) system(a)
+#define Popen(a,b) popen(a,b)
+#define Pclose(a) pclose(a)
+#define Fopen(a,b) fopen(a,b)
+#define Fclose(a) fclose(a)
+#endif
+
+extern void CheckUserParameters(int argc, char **argv, char **envp);
+extern void CheckUserAuthorization(void);
+
+extern int AddHost(
+ ClientPtr /*client*/,
+ int /*family*/,
+ unsigned /*length*/,
+ pointer /*pAddr*/);
+
+extern Bool ForEachHostInFamily (
+ int /*family*/,
+ Bool (* /*func*/ )(
+ unsigned char * /* addr */,
+ short /* len */,
+ pointer /* closure */),
+ pointer /*closure*/);
+
+extern int RemoveHost(
+ ClientPtr /*client*/,
+ int /*family*/,
+ unsigned /*length*/,
+ pointer /*pAddr*/);
+
+extern int GetHosts(
+ pointer * /*data*/,
+ int * /*pnHosts*/,
+ int * /*pLen*/,
+ BOOL * /*pEnabled*/);
+
+typedef struct sockaddr * sockaddrPtr;
+
+extern int InvalidHost(sockaddrPtr /*saddr*/, int /*len*/, ClientPtr client);
+
+extern int LocalClient(ClientPtr /* client */);
+
+extern int LocalClientCred(ClientPtr, int *, int *);
+
+extern int ChangeAccessControl(ClientPtr /*client*/, int /*fEnabled*/);
+
+extern int GetAccessControl(void);
+
+
+extern void AddLocalHosts(void);
+
+extern void ResetHosts(char *display);
+
+extern void EnableLocalHost(void);
+
+extern void DisableLocalHost(void);
+
+extern void AccessUsingXdmcp(void);
+
+extern void DefineSelf(int /*fd*/);
+
+extern void AugmentSelf(pointer /*from*/, int /*len*/);
+
+extern void InitAuthorization(char * /*filename*/);
+
+/* extern int LoadAuthorization(void); */
+
+extern void RegisterAuthorizations(void);
+
+extern XID AuthorizationToID (
+ unsigned short name_length,
+ char *name,
+ unsigned short data_length,
+ char *data);
+
+extern int AuthorizationFromID (
+ XID id,
+ unsigned short *name_lenp,
+ char **namep,
+ unsigned short *data_lenp,
+ char **datap);
+
+extern XID CheckAuthorization(
+ unsigned int /*namelength*/,
+ char * /*name*/,
+ unsigned int /*datalength*/,
+ char * /*data*/,
+ ClientPtr /*client*/,
+ char ** /*reason*/
+);
+
+extern void ResetAuthorization(void);
+
+extern int RemoveAuthorization (
+ unsigned short name_length,
+ char *name,
+ unsigned short data_length,
+ char *data);
+
+extern int AddAuthorization(
+ unsigned int /*name_length*/,
+ char * /*name*/,
+ unsigned int /*data_length*/,
+ char * /*data*/);
+
+extern XID GenerateAuthorization(
+ unsigned int /* name_length */,
+ char * /* name */,
+ unsigned int /* data_length */,
+ char * /* data */,
+ unsigned int * /* data_length_return */,
+ char ** /* data_return */);
+
+#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
+extern void ExpandCommandLine(int * /*pargc*/, char *** /*pargv*/);
+#endif
+
+extern void ddxInitGlobals(void);
+
+extern int ddxProcessArgument(int /*argc*/, char * /*argv*/ [], int /*i*/);
+
+extern void ddxUseMsg(void);
+
+/*
+ * idiom processing stuff
+ */
+
+extern xReqPtr PeekNextRequest(xReqPtr req, ClientPtr client, Bool readmore);
+
+extern void SkipRequests(xReqPtr req, ClientPtr client, int numskipped);
+
+/* int ReqLen(xReq *req, ClientPtr client)
+ * Given a pointer to a *complete* request, return its length in bytes.
+ * Note that if the request is a big request (as defined in the Big
+ * Requests extension), the macro lies by returning 4 less than the
+ * length that it actually occupies in the request buffer. This is so you
+ * can blindly compare the length with the various sz_<request> constants
+ * in Xproto.h without having to know/care about big requests.
+ */
+#define ReqLen(_pxReq, _client) \
+ ((_pxReq->length ? \
+ (_client->swapped ? lswaps(_pxReq->length) : _pxReq->length) \
+ : ((_client->swapped ? \
+ lswapl(((CARD32*)_pxReq)[1]) : ((CARD32*)_pxReq)[1])-1) \
+ ) << 2)
+
+/* otherReqTypePtr CastxReq(xReq *req, otherReqTypePtr)
+ * Cast the given request to one of type otherReqTypePtr to access
+ * fields beyond the length field.
+ */
+#define CastxReq(_pxReq, otherReqTypePtr) \
+ (_pxReq->length ? (otherReqTypePtr)_pxReq \
+ : (otherReqTypePtr)(((CARD32*)_pxReq)+1))
+
+/* stuff for SkippedRequestsCallback */
+extern CallbackListPtr SkippedRequestsCallback;
+typedef struct {
+ xReqPtr req;
+ ClientPtr client;
+ int numskipped;
+} SkippedRequestInfoRec;
+
+/* stuff for ReplyCallback */
+extern CallbackListPtr ReplyCallback;
+typedef struct {
+ ClientPtr client;
+ pointer replyData;
+ unsigned long dataLenBytes;
+ unsigned long bytesRemaining;
+ Bool startOfReply;
+} ReplyInfoRec;
+
+/* stuff for FlushCallback */
+extern CallbackListPtr FlushCallback;
+
+extern void AbortDDX(void);
+extern void ddxGiveUp(void);
+extern int TimeSinceLastInputEvent(void);
+
+/* Logging. */
+typedef enum _LogParameter {
+ XLOG_FLUSH,
+ XLOG_SYNC,
+ XLOG_VERBOSITY,
+ XLOG_FILE_VERBOSITY
+} LogParameter;
+
+/* Flags for log messages. */
+typedef enum {
+ X_PROBED, /* Value was probed */
+ X_CONFIG, /* Value was given in the config file */
+ X_DEFAULT, /* Value is a default */
+ X_CMDLINE, /* Value was given on the command line */
+ X_NOTICE, /* Notice */
+ X_ERROR, /* Error message */
+ X_WARNING, /* Warning message */
+ X_INFO, /* Informational message */
+ X_NONE, /* No prefix */
+ X_NOT_IMPLEMENTED, /* Not implemented */
+ X_UNKNOWN = -1 /* unknown -- this must always be last */
+} MessageType;
+
+/* XXX Need to check which GCC versions have the format(printf) attribute. */
+#if defined(__GNUC__) && \
+ ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ > 4)))
+#define _printf_attribute(a,b) __attribute((format(__printf__,a,b)))
+#else
+#define _printf_attribute(a,b) /**/
+#endif
+
+extern const char *LogInit(const char *fname, const char *backup);
+extern void LogClose(void);
+extern Bool LogSetParameter(LogParameter param, int value);
+extern void LogVWrite(int verb, const char *f, va_list args);
+extern void LogWrite(int verb, const char *f, ...) _printf_attribute(2,3);
+extern void LogVMessageVerb(MessageType type, int verb, const char *format,
+ va_list args);
+extern void LogMessageVerb(MessageType type, int verb, const char *format,
+ ...) _printf_attribute(3,4);
+extern void LogMessage(MessageType type, const char *format, ...)
+ _printf_attribute(2,3);
+extern void FreeAuditTimer(void);
+extern void AuditF(const char *f, ...) _printf_attribute(1,2);
+extern void VAuditF(const char *f, va_list args);
+extern void FatalError(const char *f, ...) _printf_attribute(1,2)
+#if defined(__GNUC__) && \
+ ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ > 4)))
+__attribute((noreturn))
+#endif
+;
+
+extern void VErrorF(const char *f, va_list args);
+extern void ErrorF(const char *f, ...) _printf_attribute(1,2);
+extern void Error(char *str);
+extern void LogPrintMarkers(void);
+
+#if defined(NEED_SNPRINTF) && !defined(IN_MODULE)
+extern int snprintf(char *str, size_t size, const char *format, ...)
+ _printf_attribute(3,4);
+extern int vsnprintf(char *str, size_t size, const char *format, va_list ap);
+#endif
+
+#endif /* OS_H */
diff --git a/nx-X11/programs/Xserver/include/pixmap.h b/nx-X11/programs/Xserver/include/pixmap.h
new file mode 100644
index 000000000..6cea329ec
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/pixmap.h
@@ -0,0 +1,110 @@
+/* $Xorg: pixmap.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86$ */
+
+#ifndef PIXMAP_H
+#define PIXMAP_H
+
+#include "misc.h"
+#include "screenint.h"
+
+/* types for Drawable */
+#define DRAWABLE_WINDOW 0
+#define DRAWABLE_PIXMAP 1
+#define UNDRAWABLE_WINDOW 2
+#define DRAWABLE_BUFFER 3
+
+/* flags to PaintWindow() */
+#define PW_BACKGROUND 0
+#define PW_BORDER 1
+
+#define NullPixmap ((PixmapPtr)0)
+
+typedef struct _Drawable *DrawablePtr;
+typedef struct _Pixmap *PixmapPtr;
+
+typedef union _PixUnion {
+ PixmapPtr pixmap;
+ unsigned long pixel;
+} PixUnion;
+
+#define SamePixUnion(a,b,isPixel)\
+ ((isPixel) ? (a).pixel == (b).pixel : (a).pixmap == (b).pixmap)
+
+#define EqualPixUnion(as, a, bs, b) \
+ ((as) == (bs) && (SamePixUnion (a, b, as)))
+
+#define OnScreenDrawable(type) \
+ ((type == DRAWABLE_WINDOW) || (type == DRAWABLE_BUFFER))
+
+#define WindowDrawable(type) \
+ ((type == DRAWABLE_WINDOW) || (type == UNDRAWABLE_WINDOW))
+
+extern PixmapPtr GetScratchPixmapHeader(
+ ScreenPtr /*pScreen*/,
+ int /*width*/,
+ int /*height*/,
+ int /*depth*/,
+ int /*bitsPerPixel*/,
+ int /*devKind*/,
+ pointer /*pPixData*/);
+
+extern void FreeScratchPixmapHeader(
+ PixmapPtr /*pPixmap*/);
+
+extern Bool CreateScratchPixmapsForScreen(
+ int /*scrnum*/);
+
+extern void FreeScratchPixmapsForScreen(
+ int /*scrnum*/);
+
+extern PixmapPtr AllocatePixmap(
+ ScreenPtr /*pScreen*/,
+ int /*pixDataSize*/);
+
+#endif /* PIXMAP_H */
diff --git a/nx-X11/programs/Xserver/include/pixmapstr.h b/nx-X11/programs/Xserver/include/pixmapstr.h
new file mode 100644
index 000000000..22a1f1025
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/pixmapstr.h
@@ -0,0 +1,88 @@
+/* $Xorg: pixmapstr.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86$ */
+
+#ifndef PIXMAPSTRUCT_H
+#define PIXMAPSTRUCT_H
+#include "pixmap.h"
+#include "screenint.h"
+#include "regionstr.h"
+
+typedef struct _Drawable {
+ unsigned char type; /* DRAWABLE_<type> */
+ unsigned char class; /* specific to type */
+ unsigned char depth;
+ unsigned char bitsPerPixel;
+ unsigned long id; /* resource id */
+ short x; /* window: screen absolute, pixmap: 0 */
+ short y; /* window: screen absolute, pixmap: 0 */
+ unsigned short width;
+ unsigned short height;
+ ScreenPtr pScreen;
+ unsigned long serialNumber;
+} DrawableRec;
+
+/*
+ * PIXMAP -- device dependent
+ */
+
+typedef struct _Pixmap {
+ DrawableRec drawable;
+ int refcnt;
+ int devKind;
+ DevUnion devPrivate;
+#ifdef PIXPRIV
+ DevUnion *devPrivates; /* real devPrivates like gcs & windows */
+#endif
+#ifdef COMPOSITE
+ short screen_x;
+ short screen_y;
+#endif
+} PixmapRec;
+
+#endif /* PIXMAPSTRUCT_H */
diff --git a/nx-X11/programs/Xserver/include/property.h b/nx-X11/programs/Xserver/include/property.h
new file mode 100644
index 000000000..21a38d51c
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/property.h
@@ -0,0 +1,74 @@
+/* $Xorg: property.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/include/property.h,v 1.3 2001/12/14 19:59:55 dawes Exp $ */
+
+#ifndef PROPERTY_H
+#define PROPERTY_H
+
+#include "window.h"
+
+typedef struct _Property *PropertyPtr;
+
+extern int ChangeWindowProperty(
+ WindowPtr /*pWin*/,
+ Atom /*property*/,
+ Atom /*type*/,
+ int /*format*/,
+ int /*mode*/,
+ unsigned long /*len*/,
+ pointer /*value*/,
+ Bool /*sendevent*/);
+
+extern int DeleteProperty(
+ WindowPtr /*pWin*/,
+ Atom /*propName*/);
+
+extern void DeleteAllWindowProperties(
+ WindowPtr /*pWin*/);
+
+#endif /* PROPERTY_H */
diff --git a/nx-X11/programs/Xserver/include/propertyst.h b/nx-X11/programs/Xserver/include/propertyst.h
new file mode 100644
index 000000000..177fca171
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/propertyst.h
@@ -0,0 +1,76 @@
+/* $Xorg: propertyst.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/include/propertyst.h,v 3.2 2001/01/17 22:36:57 dawes Exp $ */
+
+#ifndef PROPERTYSTRUCT_H
+#define PROPERTYSTRUCT_H
+#include "misc.h"
+#include "property.h"
+/*
+ * PROPERTY -- property element
+ */
+
+typedef struct _Property {
+ struct _Property *next;
+ ATOM propertyName;
+ ATOM type; /* ignored by server */
+ short format; /* format of data for swapping - 8,16,32 */
+ long size; /* size of data in (format/8) bytes */
+ pointer data; /* private to client */
+#if defined(LBX) || defined(LBX_COMPAT)
+ /* If space is at a premium and binary compatibility is not
+ * an issue, you may want to put the owner_pid next to format
+ * so that the two shorts pack together without padding.
+ */
+ short owner_pid; /* proxy that has the data */
+ XID tag_id;
+#endif
+} PropertyRec;
+
+#endif /* PROPERTYSTRUCT_H */
+
diff --git a/nx-X11/programs/Xserver/include/region.h b/nx-X11/programs/Xserver/include/region.h
new file mode 100644
index 000000000..0340b0db6
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/region.h
@@ -0,0 +1,54 @@
+/* $Xorg: region.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef REGION_H
+#define REGION_H
+
+#include "regionstr.h"
+
+#endif /* REGION_H */
diff --git a/nx-X11/programs/Xserver/include/regionstr.h b/nx-X11/programs/Xserver/include/regionstr.h
new file mode 100644
index 000000000..000bf3f41
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/regionstr.h
@@ -0,0 +1,412 @@
+/* $XdotOrg: xc/programs/Xserver/include/regionstr.h,v 1.7 2005/08/24 11:18:31 daniels Exp $ */
+/* $Xorg: regionstr.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/include/regionstr.h,v 1.12tsi Exp $ */
+
+#ifndef REGIONSTRUCT_H
+#define REGIONSTRUCT_H
+
+typedef struct _Region RegionRec, *RegionPtr;
+
+#include "miscstruct.h"
+
+/* Return values from RectIn() */
+
+#define rgnOUT 0
+#define rgnIN 1
+#define rgnPART 2
+
+#define NullRegion ((RegionPtr)0)
+
+/*
+ * clip region
+ */
+
+typedef struct _RegData {
+ long size;
+ long numRects;
+/* BoxRec rects[size]; in memory but not explicitly declared */
+} RegDataRec, *RegDataPtr;
+
+struct _Region {
+ BoxRec extents;
+ RegDataPtr data;
+};
+
+extern BoxRec miEmptyBox;
+extern RegDataRec miEmptyData;
+extern RegDataRec miBrokenData;
+
+#define REGION_NIL(reg) ((reg)->data && !(reg)->data->numRects)
+/* not a region */
+#define REGION_NAR(reg) ((reg)->data == &miBrokenData)
+#define REGION_NUM_RECTS(reg) ((reg)->data ? (reg)->data->numRects : 1)
+#define REGION_SIZE(reg) ((reg)->data ? (reg)->data->size : 0)
+#define REGION_RECTS(reg) ((reg)->data ? (BoxPtr)((reg)->data + 1) \
+ : &(reg)->extents)
+#define REGION_BOXPTR(reg) ((BoxPtr)((reg)->data + 1))
+#define REGION_BOX(reg,i) (&REGION_BOXPTR(reg)[i])
+#define REGION_TOP(reg) REGION_BOX(reg, (reg)->data->numRects)
+#define REGION_END(reg) REGION_BOX(reg, (reg)->data->numRects - 1)
+#define REGION_SZOF(n) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)))
+
+/* Keith recommends weaning the region code of pScreen argument */
+#define REG_pScreen screenInfo.screens[0]
+
+#ifdef NEED_SCREEN_REGIONS
+
+#define REGION_CREATE(_pScreen, _rect, _size) \
+ (*(REG_pScreen)->RegionCreate)(_rect, _size)
+
+#define REGION_INIT(_pScreen, _pReg, _rect, _size) \
+ (*(REG_pScreen)->RegionInit)(_pReg, _rect, _size)
+
+#define REGION_COPY(_pScreen, dst, src) \
+ (*(REG_pScreen)->RegionCopy)(dst, src)
+
+#define REGION_DESTROY(_pScreen, _pReg) \
+ (*(REG_pScreen)->RegionDestroy)(_pReg)
+
+#define REGION_UNINIT(_pScreen, _pReg) \
+ (*(REG_pScreen)->RegionUninit)(_pReg)
+
+#define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \
+ (*(REG_pScreen)->Intersect)(newReg, reg1, reg2)
+
+#define REGION_UNION(_pScreen, newReg, reg1, reg2) \
+ (*(REG_pScreen)->Union)(newReg, reg1, reg2)
+
+#define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \
+ (*(REG_pScreen)->Subtract)(newReg, reg1, reg2)
+
+#define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \
+ (*(REG_pScreen)->Inverse)(newReg, reg1, invRect)
+
+#define REGION_RESET(_pScreen, _pReg, _pBox) \
+ (*(REG_pScreen)->RegionReset)(_pReg, _pBox)
+
+#define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \
+ (*(REG_pScreen)->TranslateRegion)(_pReg, _x, _y)
+
+#define RECT_IN_REGION(_pScreen, _pReg, prect) \
+ (*(REG_pScreen)->RectIn)(_pReg, prect)
+
+#define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \
+ (*(REG_pScreen)->PointInRegion)(_pReg, _x, _y, prect)
+
+#define REGION_NOTEMPTY(_pScreen, _pReg) \
+ (*(REG_pScreen)->RegionNotEmpty)(_pReg)
+
+#define REGION_EQUAL(_pScreen, _pReg1, _pReg2) \
+ (*(REG_pScreen)->RegionEqual)(_pReg1, _pReg2)
+
+#define REGION_BROKEN(_pScreen, _pReg) \
+ (*(REG_pScreen)->RegionBroken)(_pReg)
+
+#define REGION_BREAK(_pScreen, _pReg) \
+ (*(REG_pScreen)->RegionBreak)(_pReg)
+
+#define REGION_EMPTY(_pScreen, _pReg) \
+ (*(REG_pScreen)->RegionEmpty)(_pReg)
+
+#define REGION_EXTENTS(_pScreen, _pReg) \
+ (*(REG_pScreen)->RegionExtents)(_pReg)
+
+#define REGION_APPEND(_pScreen, dstrgn, rgn) \
+ (*(REG_pScreen)->RegionAppend)(dstrgn, rgn)
+
+#define REGION_VALIDATE(_pScreen, badreg, pOverlap) \
+ (*(REG_pScreen)->RegionValidate)(badreg, pOverlap)
+
+#define BITMAP_TO_REGION(_pScreen, pPix) \
+ (*(REG_pScreen)->BitmapToRegion)(pPix)
+
+#define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \
+ (*(REG_pScreen)->RectsToRegion)(nrects, prect, ctype)
+
+#else /* !NEED_SCREEN_REGIONS */
+
+/* Reference _pScreen macro argument and check its type */
+#define REGION_SCREEN(_pScreen) (void)((REG_pScreen)->myNum)
+
+#define REGION_CREATE(_pScreen, _rect, _size) \
+ (REGION_SCREEN(_pScreen), miRegionCreate(_rect, _size))
+
+#define REGION_COPY(_pScreen, dst, src) \
+ (REGION_SCREEN(_pScreen), miRegionCopy(dst, src))
+
+#define REGION_DESTROY(_pScreen, _pReg) \
+ (REGION_SCREEN(_pScreen), miRegionDestroy(_pReg))
+
+#define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \
+ (REGION_SCREEN(_pScreen), miIntersect(newReg, reg1, reg2))
+
+#define REGION_UNION(_pScreen, newReg, reg1, reg2) \
+ (REGION_SCREEN(_pScreen), miUnion(newReg, reg1, reg2))
+
+#define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \
+ (REGION_SCREEN(_pScreen), miSubtract(newReg, reg1, reg2))
+
+#define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \
+ (REGION_SCREEN(_pScreen), miInverse(newReg, reg1, invRect))
+
+#define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \
+ (REGION_SCREEN(_pScreen), miTranslateRegion(_pReg, _x, _y))
+
+#define RECT_IN_REGION(_pScreen, _pReg, prect) \
+ (REGION_SCREEN(_pScreen), miRectIn(_pReg, prect))
+
+#define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \
+ (REGION_SCREEN(_pScreen), miPointInRegion(_pReg, _x, _y, prect))
+
+#define REGION_APPEND(_pScreen, dstrgn, rgn) \
+ (REGION_SCREEN(_pScreen), miRegionAppend(dstrgn, rgn))
+
+#define REGION_VALIDATE(_pScreen, badreg, pOverlap) \
+ (REGION_SCREEN(_pScreen), miRegionValidate(badreg, pOverlap))
+
+#define BITMAP_TO_REGION(_pScreen, pPix) \
+ (*(_pScreen)->BitmapToRegion)(pPix) /* no mi version?! */
+
+#define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \
+ (REGION_SCREEN(_pScreen), miRectsToRegion(nrects, prect, ctype))
+
+#define REGION_EQUAL(_pScreen, _pReg1, _pReg2) \
+ (REGION_SCREEN(_pScreen), miRegionEqual(_pReg1, _pReg2))
+
+#define REGION_BREAK(_pScreen, _pReg) \
+ (REGION_SCREEN(_pScreen), miRegionBreak(_pReg))
+
+#ifdef DONT_INLINE_REGION_OPS
+
+#define REGION_INIT(_pScreen, _pReg, _rect, _size) \
+ (REGION_SCREEN(_pScreen), miRegionInit(_pReg, _rect, _size))
+
+#define REGION_UNINIT(_pScreen, _pReg) \
+ (REGION_SCREEN(_pScreen), miRegionUninit(_pReg))
+
+#define REGION_RESET(_pScreen, _pReg, _pBox) \
+ (REGION_SCREEN(_pScreen), miRegionReset(_pReg, _pBox))
+
+#define REGION_NOTEMPTY(_pScreen, _pReg) \
+ (REGION_SCREEN(_pScreen), miRegionNotEmpty(_pReg))
+
+#define REGION_BROKEN(_pScreen, _pReg) \
+ (REGION_SCREEN(_pScreen), miRegionBroken(_pReg))
+
+#define REGION_EMPTY(_pScreen, _pReg) \
+ (REGION_SCREEN(_pScreen), miRegionEmpty(_pReg))
+
+#define REGION_EXTENTS(_pScreen, _pReg) \
+ (REGION_SCREEN(_pScreen), miRegionExtents(_pReg))
+
+#else /* inline certain simple region ops for performance */
+
+#define REGION_INIT(_pScreen, _pReg, _rect, _size) \
+{ \
+ REGION_SCREEN(_pScreen); \
+ if (_rect) \
+ { \
+ (_pReg)->extents = *(_rect); \
+ (_pReg)->data = (RegDataPtr)NULL; \
+ } \
+ else \
+ { \
+ (_pReg)->extents = miEmptyBox; \
+ if (((_size) > 1) && ((_pReg)->data = \
+ (RegDataPtr)xalloc(REGION_SZOF(_size)))) \
+ { \
+ (_pReg)->data->size = (_size); \
+ (_pReg)->data->numRects = 0; \
+ } \
+ else \
+ (_pReg)->data = &miEmptyData; \
+ } \
+ }
+
+
+#define REGION_UNINIT(_pScreen, _pReg) \
+{ \
+ REGION_SCREEN(_pScreen); \
+ if ((_pReg)->data && (_pReg)->data->size) { \
+ xfree((_pReg)->data); \
+ (_pReg)->data = NULL; \
+ } \
+}
+
+#define REGION_RESET(_pScreen, _pReg, _pBox) \
+{ \
+ REGION_SCREEN(_pScreen); \
+ (_pReg)->extents = *(_pBox); \
+ REGION_UNINIT(_pScreen, _pReg); \
+ (_pReg)->data = (RegDataPtr)NULL; \
+}
+
+#define REGION_NOTEMPTY(_pScreen, _pReg) \
+ (REGION_SCREEN(_pScreen), !REGION_NIL(_pReg))
+
+#define REGION_BROKEN(_pScreen, _pReg) \
+ (REGION_SCREEN(_pScreen), REGION_NAR(_pReg))
+
+#define REGION_EMPTY(_pScreen, _pReg) \
+{ \
+ REGION_UNINIT(_pScreen, _pReg); \
+ (_pReg)->extents.x2 = (_pReg)->extents.x1; \
+ (_pReg)->extents.y2 = (_pReg)->extents.y1; \
+ (_pReg)->data = &miEmptyData; \
+}
+
+#define REGION_EXTENTS(_pScreen, _pReg) \
+ (REGION_SCREEN(_pScreen), &(_pReg)->extents)
+
+#define REGION_NULL(_pScreen, _pReg) \
+{ \
+ REGION_SCREEN(_pScreen); \
+ (_pReg)->extents = miEmptyBox; \
+ (_pReg)->data = &miEmptyData; \
+}
+
+#endif /* DONT_INLINE_REGION_OPS */
+
+#endif /* NEED_SCREEN_REGIONS */
+
+#ifndef REGION_NULL
+#define REGION_NULL(_pScreen, _pReg) \
+ REGION_INIT(_pScreen, _pReg, NullBox, 1)
+#endif
+
+/* moved from mi.h */
+
+extern RegionPtr miRegionCreate(
+ BoxPtr /*rect*/,
+ int /*size*/);
+
+extern void miRegionInit(
+ RegionPtr /*pReg*/,
+ BoxPtr /*rect*/,
+ int /*size*/);
+
+extern void miRegionDestroy(
+ RegionPtr /*pReg*/);
+
+extern void miRegionUninit(
+ RegionPtr /*pReg*/);
+
+extern Bool miRegionCopy(
+ RegionPtr /*dst*/,
+ RegionPtr /*src*/);
+
+extern Bool miIntersect(
+ RegionPtr /*newReg*/,
+ RegionPtr /*reg1*/,
+ RegionPtr /*reg2*/);
+
+extern Bool miUnion(
+ RegionPtr /*newReg*/,
+ RegionPtr /*reg1*/,
+ RegionPtr /*reg2*/);
+
+extern Bool miRegionAppend(
+ RegionPtr /*dstrgn*/,
+ RegionPtr /*rgn*/);
+
+extern Bool miRegionValidate(
+ RegionPtr /*badreg*/,
+ Bool * /*pOverlap*/);
+
+extern RegionPtr miRectsToRegion(
+ int /*nrects*/,
+ xRectanglePtr /*prect*/,
+ int /*ctype*/);
+
+extern Bool miSubtract(
+ RegionPtr /*regD*/,
+ RegionPtr /*regM*/,
+ RegionPtr /*regS*/);
+
+extern Bool miInverse(
+ RegionPtr /*newReg*/,
+ RegionPtr /*reg1*/,
+ BoxPtr /*invRect*/);
+
+extern int miRectIn(
+ RegionPtr /*region*/,
+ BoxPtr /*prect*/);
+
+extern void miTranslateRegion(
+ RegionPtr /*pReg*/,
+ int /*x*/,
+ int /*y*/);
+
+extern void miRegionReset(
+ RegionPtr /*pReg*/,
+ BoxPtr /*pBox*/);
+
+extern Bool miRegionBreak(
+ RegionPtr /*pReg*/);
+
+extern Bool miPointInRegion(
+ RegionPtr /*pReg*/,
+ int /*x*/,
+ int /*y*/,
+ BoxPtr /*box*/);
+
+extern Bool miRegionEqual(
+ RegionPtr /*pReg1*/,
+ RegionPtr /*pReg2*/);
+
+extern Bool miRegionNotEmpty(
+ RegionPtr /*pReg*/);
+
+extern void miRegionEmpty(
+ RegionPtr /*pReg*/);
+
+extern BoxPtr miRegionExtents(
+ RegionPtr /*pReg*/);
+
+#endif /* REGIONSTRUCT_H */
diff --git a/nx-X11/programs/Xserver/include/resource.h b/nx-X11/programs/Xserver/include/resource.h
new file mode 100644
index 000000000..49c189869
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/resource.h
@@ -0,0 +1,274 @@
+/* $Xorg: resource.h,v 1.5 2001/02/09 02:05:15 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/include/resource.h,v 1.11 2002/03/06 21:14:04 mvojkovi Exp $ */
+
+#ifndef RESOURCE_H
+#define RESOURCE_H 1
+#include "misc.h"
+
+/*****************************************************************
+ * STUFF FOR RESOURCES
+ *****************************************************************/
+
+/* classes for Resource routines */
+
+typedef unsigned long RESTYPE;
+
+#define RC_VANILLA ((RESTYPE)0)
+#define RC_CACHED ((RESTYPE)1<<31)
+#define RC_DRAWABLE ((RESTYPE)1<<30)
+/* Use class RC_NEVERRETAIN for resources that should not be retained
+ * regardless of the close down mode when the client dies. (A client's
+ * event selections on objects that it doesn't own are good candidates.)
+ * Extensions can use this too!
+ */
+#define RC_NEVERRETAIN ((RESTYPE)1<<29)
+#define RC_LASTPREDEF RC_NEVERRETAIN
+#define RC_ANY (~(RESTYPE)0)
+
+/* types for Resource routines */
+
+#define RT_WINDOW ((RESTYPE)1|RC_CACHED|RC_DRAWABLE)
+#define RT_PIXMAP ((RESTYPE)2|RC_CACHED|RC_DRAWABLE)
+#define RT_GC ((RESTYPE)3|RC_CACHED)
+#undef RT_FONT
+#undef RT_CURSOR
+#define RT_FONT ((RESTYPE)4)
+#define RT_CURSOR ((RESTYPE)5)
+#define RT_COLORMAP ((RESTYPE)6)
+#define RT_CMAPENTRY ((RESTYPE)7)
+#define RT_OTHERCLIENT ((RESTYPE)8|RC_NEVERRETAIN)
+#define RT_PASSIVEGRAB ((RESTYPE)9|RC_NEVERRETAIN)
+#define RT_LASTPREDEF ((RESTYPE)9)
+#define RT_NONE ((RESTYPE)0)
+
+/* bits and fields within a resource id */
+#define RESOURCE_AND_CLIENT_COUNT 29 /* 29 bits for XIDs */
+#if MAXCLIENTS == 64
+#define RESOURCE_CLIENT_BITS 6
+#endif
+#if MAXCLIENTS == 128
+#define RESOURCE_CLIENT_BITS 7
+#endif
+#if MAXCLIENTS == 256
+#define RESOURCE_CLIENT_BITS 8
+#endif
+#if MAXCLIENTS == 512
+#define RESOURCE_CLIENT_BITS 9
+#endif
+/* client field offset */
+#define CLIENTOFFSET (RESOURCE_AND_CLIENT_COUNT - RESOURCE_CLIENT_BITS)
+/* resource field */
+#define RESOURCE_ID_MASK ((1 << CLIENTOFFSET) - 1)
+/* client field */
+#define RESOURCE_CLIENT_MASK (((1 << RESOURCE_CLIENT_BITS) - 1) << CLIENTOFFSET)
+/* extract the client mask from an XID */
+#define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK)
+/* extract the client id from an XID */
+#define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET))
+#define SERVER_BIT (Mask)0x40000000 /* use illegal bit */
+
+#ifdef INVALID
+#undef INVALID /* needed on HP/UX */
+#endif
+
+/* Invalid resource id */
+#define INVALID (0)
+
+#define BAD_RESOURCE 0xe0000000
+
+typedef int (*DeleteType)(
+ pointer /*value*/,
+ XID /*id*/);
+
+typedef void (*FindResType)(
+ pointer /*value*/,
+ XID /*id*/,
+ pointer /*cdata*/);
+
+typedef void (*FindAllRes)(
+ pointer /*value*/,
+ XID /*id*/,
+ RESTYPE /*type*/,
+ pointer /*cdata*/);
+
+typedef Bool (*FindComplexResType)(
+ pointer /*value*/,
+ XID /*id*/,
+ pointer /*cdata*/);
+
+extern RESTYPE CreateNewResourceType(
+ DeleteType /*deleteFunc*/);
+
+extern RESTYPE CreateNewResourceClass(void);
+
+extern Bool InitClientResources(
+ ClientPtr /*client*/);
+
+extern XID FakeClientID(
+ int /*client*/);
+
+/* Quartz support on Mac OS X uses the CarbonCore
+ framework whose AddResource function conflicts here. */
+#ifdef __DARWIN__
+#define AddResource Darwin_X_AddResource
+#endif
+extern Bool AddResource(
+ XID /*id*/,
+ RESTYPE /*type*/,
+ pointer /*value*/);
+
+extern void FreeResource(
+ XID /*id*/,
+ RESTYPE /*skipDeleteFuncType*/);
+
+extern void FreeResourceByType(
+ XID /*id*/,
+ RESTYPE /*type*/,
+ Bool /*skipFree*/);
+
+extern Bool ChangeResourceValue(
+ XID /*id*/,
+ RESTYPE /*rtype*/,
+ pointer /*value*/);
+
+extern void FindClientResourcesByType(
+ ClientPtr /*client*/,
+ RESTYPE /*type*/,
+ FindResType /*func*/,
+ pointer /*cdata*/);
+
+extern void FindAllClientResources(
+ ClientPtr /*client*/,
+ FindAllRes /*func*/,
+ pointer /*cdata*/);
+
+extern void FreeClientNeverRetainResources(
+ ClientPtr /*client*/);
+
+extern void FreeClientResources(
+ ClientPtr /*client*/);
+
+extern void FreeAllResources(void);
+
+extern Bool LegalNewID(
+ XID /*id*/,
+ ClientPtr /*client*/);
+
+extern pointer LookupIDByType(
+ XID /*id*/,
+ RESTYPE /*rtype*/);
+
+extern pointer LookupIDByClass(
+ XID /*id*/,
+ RESTYPE /*classes*/);
+
+extern pointer LookupClientResourceComplex(
+ ClientPtr client,
+ RESTYPE type,
+ FindComplexResType func,
+ pointer cdata);
+
+/* These are the access modes that can be passed in the last parameter
+ * to SecurityLookupIDByType/Class. The Security extension doesn't
+ * currently make much use of these; they're mainly provided as an
+ * example of what you might need for discretionary access control.
+ * You can or these values together to indicate multiple modes
+ * simultaneously.
+ */
+
+#define SecurityUnknownAccess 0 /* don't know intentions */
+#define SecurityReadAccess (1<<0) /* inspecting the object */
+#define SecurityWriteAccess (1<<1) /* changing the object */
+#define SecurityDestroyAccess (1<<2) /* destroying the object */
+
+#ifdef XCSECURITY
+
+extern pointer SecurityLookupIDByType(
+ ClientPtr /*client*/,
+ XID /*id*/,
+ RESTYPE /*rtype*/,
+ Mask /*access_mode*/);
+
+extern pointer SecurityLookupIDByClass(
+ ClientPtr /*client*/,
+ XID /*id*/,
+ RESTYPE /*classes*/,
+ Mask /*access_mode*/);
+
+#else /* not XCSECURITY */
+
+#define SecurityLookupIDByType(client, id, rtype, access_mode) \
+ LookupIDByType(id, rtype)
+
+#define SecurityLookupIDByClass(client, id, classes, access_mode) \
+ LookupIDByClass(id, classes)
+
+#endif /* XCSECURITY */
+
+extern void GetXIDRange(
+ int /*client*/,
+ Bool /*server*/,
+ XID * /*minp*/,
+ XID * /*maxp*/);
+
+extern unsigned int GetXIDList(
+ ClientPtr /*client*/,
+ unsigned int /*count*/,
+ XID * /*pids*/);
+
+extern RESTYPE lastResourceType;
+extern RESTYPE TypeMask;
+
+#ifdef XResExtension
+extern Atom *ResourceNames;
+void RegisterResourceName(RESTYPE type, char* name);
+#endif
+
+#endif /* RESOURCE_H */
+
diff --git a/nx-X11/programs/Xserver/include/rgb.h b/nx-X11/programs/Xserver/include/rgb.h
new file mode 100644
index 000000000..5741a4efa
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/rgb.h
@@ -0,0 +1,54 @@
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: rgb.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+
+#ifndef RGB_H
+#define RGB_H
+typedef struct _RGB {
+ unsigned short red, green, blue;
+ } RGB;
+#endif /* RGB_H */
diff --git a/nx-X11/programs/Xserver/include/screenint.h b/nx-X11/programs/Xserver/include/screenint.h
new file mode 100644
index 000000000..74d5e14a0
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/screenint.h
@@ -0,0 +1,113 @@
+/* $Xorg: screenint.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/include/screenint.h,v 1.5 2001/12/14 19:59:56 dawes Exp $ */
+
+#ifndef SCREENINT_H
+#define SCREENINT_H
+
+#include "misc.h"
+
+typedef struct _PixmapFormat *PixmapFormatPtr;
+typedef struct _Visual *VisualPtr;
+typedef struct _Depth *DepthPtr;
+typedef struct _Screen *ScreenPtr;
+
+extern void ResetScreenPrivates(void);
+
+extern int AllocateScreenPrivateIndex(void);
+
+extern void ResetWindowPrivates(void);
+
+extern int AllocateWindowPrivateIndex(void);
+
+extern Bool AllocateWindowPrivate(
+ ScreenPtr /* pScreen */,
+ int /* index */,
+ unsigned /* amount */);
+
+extern void ResetGCPrivates(void);
+
+extern int AllocateGCPrivateIndex(void);
+
+extern Bool AllocateGCPrivate(
+ ScreenPtr /* pScreen */,
+ int /* index */,
+ unsigned /* amount */);
+
+extern int AddScreen(
+ Bool (* /*pfnInit*/)(
+ int /*index*/,
+ ScreenPtr /*pScreen*/,
+ int /*argc*/,
+ char ** /*argv*/),
+ int /*argc*/,
+ char** /*argv*/);
+
+#ifdef PIXPRIV
+
+extern void ResetPixmapPrivates(void);
+
+extern int AllocatePixmapPrivateIndex(void);
+
+extern Bool AllocatePixmapPrivate(
+ ScreenPtr /* pScreen */,
+ int /* index */,
+ unsigned /* amount */);
+
+#endif /* PIXPRIV */
+
+extern void ResetColormapPrivates(void);
+
+
+typedef struct _ColormapRec *ColormapPtr;
+typedef int (*InitCmapPrivFunc)(ColormapPtr, int);
+
+extern int AllocateColormapPrivateIndex(
+ InitCmapPrivFunc /* initPrivFunc */);
+
+#endif /* SCREENINT_H */
diff --git a/nx-X11/programs/Xserver/include/scrnintstr.h b/nx-X11/programs/Xserver/include/scrnintstr.h
new file mode 100644
index 000000000..ef9358689
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/scrnintstr.h
@@ -0,0 +1,733 @@
+/* $Xorg: scrnintstr.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/include/scrnintstr.h,v 1.12 2003/04/27 21:31:05 herrb Exp $ */
+
+#ifndef SCREENINTSTRUCT_H
+#define SCREENINTSTRUCT_H
+
+#include "screenint.h"
+#include "regionstr.h"
+#include "bstore.h"
+#include "colormap.h"
+#include "cursor.h"
+#include "validate.h"
+#include <X11/Xproto.h>
+#include "dix.h"
+
+typedef struct _PixmapFormat {
+ unsigned char depth;
+ unsigned char bitsPerPixel;
+ unsigned char scanlinePad;
+ } PixmapFormatRec;
+
+typedef struct _Visual {
+ VisualID vid;
+ short class;
+ short bitsPerRGBValue;
+ short ColormapEntries;
+ short nplanes;/* = log2 (ColormapEntries). This does not
+ * imply that the screen has this many planes.
+ * it may have more or fewer */
+ unsigned long redMask, greenMask, blueMask;
+ int offsetRed, offsetGreen, offsetBlue;
+ } VisualRec;
+
+typedef struct _Depth {
+ unsigned char depth;
+ short numVids;
+ VisualID *vids; /* block of visual ids for this depth */
+ } DepthRec;
+
+
+/*
+ * There is a typedef for each screen function pointer so that code that
+ * needs to declare a screen function pointer (e.g. in a screen private
+ * or as a local variable) can easily do so and retain full type checking.
+ */
+
+typedef Bool (* CloseScreenProcPtr)(
+ int /*index*/,
+ ScreenPtr /*pScreen*/);
+
+typedef void (* QueryBestSizeProcPtr)(
+ int /*class*/,
+ unsigned short * /*pwidth*/,
+ unsigned short * /*pheight*/,
+ ScreenPtr /*pScreen*/);
+
+typedef Bool (* SaveScreenProcPtr)(
+ ScreenPtr /*pScreen*/,
+ int /*on*/);
+
+typedef void (* GetImageProcPtr)(
+ DrawablePtr /*pDrawable*/,
+ int /*sx*/,
+ int /*sy*/,
+ int /*w*/,
+ int /*h*/,
+ unsigned int /*format*/,
+ unsigned long /*planeMask*/,
+ char * /*pdstLine*/);
+
+typedef void (* GetSpansProcPtr)(
+ DrawablePtr /*pDrawable*/,
+ int /*wMax*/,
+ DDXPointPtr /*ppt*/,
+ int* /*pwidth*/,
+ int /*nspans*/,
+ char * /*pdstStart*/);
+
+typedef void (* PointerNonInterestBoxProcPtr)(
+ ScreenPtr /*pScreen*/,
+ BoxPtr /*pBox*/);
+
+typedef void (* SourceValidateProcPtr)(
+ DrawablePtr /*pDrawable*/,
+ int /*x*/,
+ int /*y*/,
+ int /*width*/,
+ int /*height*/);
+
+typedef Bool (* CreateWindowProcPtr)(
+ WindowPtr /*pWindow*/);
+
+typedef Bool (* DestroyWindowProcPtr)(
+ WindowPtr /*pWindow*/);
+
+typedef Bool (* PositionWindowProcPtr)(
+ WindowPtr /*pWindow*/,
+ int /*x*/,
+ int /*y*/);
+
+typedef Bool (* ChangeWindowAttributesProcPtr)(
+ WindowPtr /*pWindow*/,
+ unsigned long /*mask*/);
+
+typedef Bool (* RealizeWindowProcPtr)(
+ WindowPtr /*pWindow*/);
+
+typedef Bool (* UnrealizeWindowProcPtr)(
+ WindowPtr /*pWindow*/);
+
+typedef void (* RestackWindowProcPtr)(
+ WindowPtr /*pWindow*/,
+ WindowPtr /*pOldNextSib*/);
+
+typedef int (* ValidateTreeProcPtr)(
+ WindowPtr /*pParent*/,
+ WindowPtr /*pChild*/,
+ VTKind /*kind*/);
+
+typedef void (* PostValidateTreeProcPtr)(
+ WindowPtr /*pParent*/,
+ WindowPtr /*pChild*/,
+ VTKind /*kind*/);
+
+typedef void (* WindowExposuresProcPtr)(
+ WindowPtr /*pWindow*/,
+ RegionPtr /*prgn*/,
+ RegionPtr /*other_exposed*/);
+
+typedef void (* PaintWindowProcPtr)(
+ WindowPtr /*pWindow*/,
+ RegionPtr /*pRegion*/,
+ int /*what*/);
+
+typedef PaintWindowProcPtr PaintWindowBackgroundProcPtr;
+typedef PaintWindowProcPtr PaintWindowBorderProcPtr;
+
+typedef void (* CopyWindowProcPtr)(
+ WindowPtr /*pWindow*/,
+ DDXPointRec /*ptOldOrg*/,
+ RegionPtr /*prgnSrc*/);
+
+typedef void (* ClearToBackgroundProcPtr)(
+ WindowPtr /*pWindow*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ Bool /*generateExposures*/);
+
+typedef void (* ClipNotifyProcPtr)(
+ WindowPtr /*pWindow*/,
+ int /*dx*/,
+ int /*dy*/);
+
+typedef PixmapPtr (* CreatePixmapProcPtr)(
+ ScreenPtr /*pScreen*/,
+ int /*width*/,
+ int /*height*/,
+ int /*depth*/);
+
+typedef Bool (* DestroyPixmapProcPtr)(
+ PixmapPtr /*pPixmap*/);
+
+typedef void (* SaveDoomedAreasProcPtr)(
+ WindowPtr /*pWindow*/,
+ RegionPtr /*prgnSave*/,
+ int /*xorg*/,
+ int /*yorg*/);
+
+typedef RegionPtr (* RestoreAreasProcPtr)(
+ WindowPtr /*pWindow*/,
+ RegionPtr /*prgnRestore*/);
+
+typedef void (* ExposeCopyProcPtr)(
+ WindowPtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ GCPtr /*pGC*/,
+ RegionPtr /*prgnExposed*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ unsigned long /*plane*/);
+
+typedef RegionPtr (* TranslateBackingStoreProcPtr)(
+ WindowPtr /*pWindow*/,
+ int /*windx*/,
+ int /*windy*/,
+ RegionPtr /*oldClip*/,
+ int /*oldx*/,
+ int /*oldy*/);
+
+typedef RegionPtr (* ClearBackingStoreProcPtr)(
+ WindowPtr /*pWindow*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ Bool /*generateExposures*/);
+
+typedef void (* DrawGuaranteeProcPtr)(
+ WindowPtr /*pWindow*/,
+ GCPtr /*pGC*/,
+ int /*guarantee*/);
+
+typedef Bool (* RealizeFontProcPtr)(
+ ScreenPtr /*pScreen*/,
+ FontPtr /*pFont*/);
+
+typedef Bool (* UnrealizeFontProcPtr)(
+ ScreenPtr /*pScreen*/,
+ FontPtr /*pFont*/);
+
+typedef void (* ConstrainCursorProcPtr)(
+ ScreenPtr /*pScreen*/,
+ BoxPtr /*pBox*/);
+
+typedef void (* CursorLimitsProcPtr)(
+ ScreenPtr /*pScreen*/,
+ CursorPtr /*pCursor*/,
+ BoxPtr /*pHotBox*/,
+ BoxPtr /*pTopLeftBox*/);
+
+typedef Bool (* DisplayCursorProcPtr)(
+ ScreenPtr /*pScreen*/,
+ CursorPtr /*pCursor*/);
+
+typedef Bool (* RealizeCursorProcPtr)(
+ ScreenPtr /*pScreen*/,
+ CursorPtr /*pCursor*/);
+
+typedef Bool (* UnrealizeCursorProcPtr)(
+ ScreenPtr /*pScreen*/,
+ CursorPtr /*pCursor*/);
+
+typedef void (* RecolorCursorProcPtr)(
+ ScreenPtr /*pScreen*/,
+ CursorPtr /*pCursor*/,
+ Bool /*displayed*/);
+
+typedef Bool (* SetCursorPositionProcPtr)(
+ ScreenPtr /*pScreen*/,
+ int /*x*/,
+ int /*y*/,
+ Bool /*generateEvent*/);
+
+typedef Bool (* CreateGCProcPtr)(
+ GCPtr /*pGC*/);
+
+typedef Bool (* CreateColormapProcPtr)(
+ ColormapPtr /*pColormap*/);
+
+typedef void (* DestroyColormapProcPtr)(
+ ColormapPtr /*pColormap*/);
+
+typedef void (* InstallColormapProcPtr)(
+ ColormapPtr /*pColormap*/);
+
+typedef void (* UninstallColormapProcPtr)(
+ ColormapPtr /*pColormap*/);
+
+typedef int (* ListInstalledColormapsProcPtr) (
+ ScreenPtr /*pScreen*/,
+ XID* /*pmaps */);
+
+typedef void (* StoreColorsProcPtr)(
+ ColormapPtr /*pColormap*/,
+ int /*ndef*/,
+ xColorItem * /*pdef*/);
+
+typedef void (* ResolveColorProcPtr)(
+ unsigned short* /*pred*/,
+ unsigned short* /*pgreen*/,
+ unsigned short* /*pblue*/,
+ VisualPtr /*pVisual*/);
+
+#ifdef NEED_SCREEN_REGIONS
+
+typedef RegionPtr (* RegionCreateProcPtr)(
+ BoxPtr /*rect*/,
+ int /*size*/);
+
+typedef void (* RegionInitProcPtr)(
+ RegionPtr /*pReg*/,
+ BoxPtr /*rect*/,
+ int /*size*/);
+
+typedef Bool (* RegionCopyProcPtr)(
+ RegionPtr /*dst*/,
+ RegionPtr /*src*/);
+
+typedef void (* RegionDestroyProcPtr)(
+ RegionPtr /*pReg*/);
+
+typedef void (* RegionUninitProcPtr)(
+ RegionPtr /*pReg*/);
+
+typedef Bool (* IntersectProcPtr)(
+ RegionPtr /*newReg*/,
+ RegionPtr /*reg1*/,
+ RegionPtr /*reg2*/);
+
+typedef Bool (* UnionProcPtr)(
+ RegionPtr /*newReg*/,
+ RegionPtr /*reg1*/,
+ RegionPtr /*reg2*/);
+
+typedef Bool (* SubtractProcPtr)(
+ RegionPtr /*regD*/,
+ RegionPtr /*regM*/,
+ RegionPtr /*regS*/);
+
+typedef Bool (* InverseProcPtr)(
+ RegionPtr /*newReg*/,
+ RegionPtr /*reg1*/,
+ BoxPtr /*invRect*/);
+
+typedef void (* RegionResetProcPtr)(
+ RegionPtr /*pReg*/,
+ BoxPtr /*pBox*/);
+
+typedef void (* TranslateRegionProcPtr)(
+ RegionPtr /*pReg*/,
+ int /*x*/,
+ int /*y*/);
+
+typedef int (* RectInProcPtr)(
+ RegionPtr /*region*/,
+ BoxPtr /*prect*/);
+
+typedef Bool (* PointInRegionProcPtr)(
+ RegionPtr /*pReg*/,
+ int /*x*/,
+ int /*y*/,
+ BoxPtr /*box*/);
+
+typedef Bool (* RegionNotEmptyProcPtr)(
+ RegionPtr /*pReg*/);
+
+typedef Bool (* RegionEqualProcPtr)(
+ RegionPtr /*pReg1*/,
+ RegionPtr /*pReg2*/);
+
+typedef Bool (* RegionBrokenProcPtr)(
+ RegionPtr /*pReg*/);
+
+typedef Bool (* RegionBreakProcPtr)(
+ RegionPtr /*pReg*/);
+
+typedef void (* RegionEmptyProcPtr)(
+ RegionPtr /*pReg*/);
+
+typedef BoxPtr (* RegionExtentsProcPtr)(
+ RegionPtr /*pReg*/);
+
+typedef Bool (* RegionAppendProcPtr)(
+ RegionPtr /*dstrgn*/,
+ RegionPtr /*rgn*/);
+
+typedef Bool (* RegionValidateProcPtr)(
+ RegionPtr /*badreg*/,
+ Bool* /*pOverlap*/);
+
+#endif /* NEED_SCREEN_REGIONS */
+
+typedef RegionPtr (* BitmapToRegionProcPtr)(
+ PixmapPtr /*pPix*/);
+
+#ifdef NEED_SCREEN_REGIONS
+
+typedef RegionPtr (* RectsToRegionProcPtr)(
+ int /*nrects*/,
+ xRectangle* /*prect*/,
+ int /*ctype*/);
+
+#endif /* NEED_SCREEN_REGIONS */
+
+typedef void (* SendGraphicsExposeProcPtr)(
+ ClientPtr /*client*/,
+ RegionPtr /*pRgn*/,
+ XID /*drawable*/,
+ int /*major*/,
+ int /*minor*/);
+
+typedef void (* ScreenBlockHandlerProcPtr)(
+ int /*screenNum*/,
+ pointer /*blockData*/,
+ pointer /*pTimeout*/,
+ pointer /*pReadmask*/);
+
+typedef void (* ScreenWakeupHandlerProcPtr)(
+ int /*screenNum*/,
+ pointer /*wakeupData*/,
+ unsigned long /*result*/,
+ pointer /*pReadMask*/);
+
+typedef Bool (* CreateScreenResourcesProcPtr)(
+ ScreenPtr /*pScreen*/);
+
+typedef Bool (* ModifyPixmapHeaderProcPtr)(
+ PixmapPtr /*pPixmap*/,
+ int /*width*/,
+ int /*height*/,
+ int /*depth*/,
+ int /*bitsPerPixel*/,
+ int /*devKind*/,
+ pointer /*pPixData*/);
+
+typedef PixmapPtr (* GetWindowPixmapProcPtr)(
+ WindowPtr /*pWin*/);
+
+typedef void (* SetWindowPixmapProcPtr)(
+ WindowPtr /*pWin*/,
+ PixmapPtr /*pPix*/);
+
+typedef PixmapPtr (* GetScreenPixmapProcPtr)(
+ ScreenPtr /*pScreen*/);
+
+typedef void (* SetScreenPixmapProcPtr)(
+ PixmapPtr /*pPix*/);
+
+typedef void (* MarkWindowProcPtr)(
+ WindowPtr /*pWin*/);
+
+typedef Bool (* MarkOverlappedWindowsProcPtr)(
+ WindowPtr /*parent*/,
+ WindowPtr /*firstChild*/,
+ WindowPtr * /*pLayerWin*/);
+
+typedef Bool (* ChangeSaveUnderProcPtr)(
+ WindowPtr /*pLayerWin*/,
+ WindowPtr /*firstChild*/);
+
+typedef void (* PostChangeSaveUnderProcPtr)(
+ WindowPtr /*pLayerWin*/,
+ WindowPtr /*firstChild*/);
+
+typedef void (* MoveWindowProcPtr)(
+ WindowPtr /*pWin*/,
+ int /*x*/,
+ int /*y*/,
+ WindowPtr /*pSib*/,
+ VTKind /*kind*/);
+
+typedef void (* ResizeWindowProcPtr)(
+ WindowPtr /*pWin*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*w*/,
+ unsigned int /*h*/,
+ WindowPtr /*pSib*/
+);
+
+typedef WindowPtr (* GetLayerWindowProcPtr)(
+ WindowPtr /*pWin*/
+);
+
+typedef void (* HandleExposuresProcPtr)(
+ WindowPtr /*pWin*/);
+
+typedef void (* ReparentWindowProcPtr)(
+ WindowPtr /*pWin*/,
+ WindowPtr /*pPriorParent*/);
+
+#ifdef SHAPE
+typedef void (* SetShapeProcPtr)(
+ WindowPtr /*pWin*/);
+#endif /* SHAPE */
+
+typedef void (* ChangeBorderWidthProcPtr)(
+ WindowPtr /*pWin*/,
+ unsigned int /*width*/);
+
+typedef void (* MarkUnrealizedWindowProcPtr)(
+ WindowPtr /*pChild*/,
+ WindowPtr /*pWin*/,
+ Bool /*fromConfigure*/);
+
+typedef struct _Screen {
+ int myNum; /* index of this instance in Screens[] */
+ ATOM id;
+ short width, height;
+ short mmWidth, mmHeight;
+ short numDepths;
+ unsigned char rootDepth;
+ DepthPtr allowedDepths;
+ unsigned long rootVisual;
+ unsigned long defColormap;
+ short minInstalledCmaps, maxInstalledCmaps;
+ char backingStoreSupport, saveUnderSupport;
+ unsigned long whitePixel, blackPixel;
+ unsigned long rgf; /* array of flags; she's -- HUNGARIAN */
+ GCPtr GCperDepth[MAXFORMATS+1];
+ /* next field is a stipple to use as default in
+ a GC. we don't build default tiles of all depths
+ because they are likely to be of a color
+ different from the default fg pixel, so
+ we don't win anything by building
+ a standard one.
+ */
+ PixmapPtr PixmapPerDepth[1];
+ pointer devPrivate;
+ short numVisuals;
+ VisualPtr visuals;
+ int WindowPrivateLen;
+ unsigned *WindowPrivateSizes;
+ unsigned totalWindowSize;
+ int GCPrivateLen;
+ unsigned *GCPrivateSizes;
+ unsigned totalGCSize;
+
+ /* Random screen procedures */
+
+ CloseScreenProcPtr CloseScreen;
+ QueryBestSizeProcPtr QueryBestSize;
+ SaveScreenProcPtr SaveScreen;
+ GetImageProcPtr GetImage;
+ GetSpansProcPtr GetSpans;
+ PointerNonInterestBoxProcPtr PointerNonInterestBox;
+ SourceValidateProcPtr SourceValidate;
+
+ /* Window Procedures */
+
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ PositionWindowProcPtr PositionWindow;
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ ValidateTreeProcPtr ValidateTree;
+ PostValidateTreeProcPtr PostValidateTree;
+ WindowExposuresProcPtr WindowExposures;
+ PaintWindowBackgroundProcPtr PaintWindowBackground;
+ PaintWindowBorderProcPtr PaintWindowBorder;
+ CopyWindowProcPtr CopyWindow;
+ ClearToBackgroundProcPtr ClearToBackground;
+ ClipNotifyProcPtr ClipNotify;
+ RestackWindowProcPtr RestackWindow;
+
+ /* Pixmap procedures */
+
+ CreatePixmapProcPtr CreatePixmap;
+ DestroyPixmapProcPtr DestroyPixmap;
+
+ /* Backing store procedures */
+
+ SaveDoomedAreasProcPtr SaveDoomedAreas;
+ RestoreAreasProcPtr RestoreAreas;
+ ExposeCopyProcPtr ExposeCopy;
+ TranslateBackingStoreProcPtr TranslateBackingStore;
+ ClearBackingStoreProcPtr ClearBackingStore;
+ DrawGuaranteeProcPtr DrawGuarantee;
+ /*
+ * A read/write copy of the lower level backing store vector is needed now
+ * that the functions can be wrapped.
+ */
+ BSFuncRec BackingStoreFuncs;
+
+ /* Font procedures */
+
+ RealizeFontProcPtr RealizeFont;
+ UnrealizeFontProcPtr UnrealizeFont;
+
+ /* Cursor Procedures */
+
+ ConstrainCursorProcPtr ConstrainCursor;
+ CursorLimitsProcPtr CursorLimits;
+ DisplayCursorProcPtr DisplayCursor;
+ RealizeCursorProcPtr RealizeCursor;
+ UnrealizeCursorProcPtr UnrealizeCursor;
+ RecolorCursorProcPtr RecolorCursor;
+ SetCursorPositionProcPtr SetCursorPosition;
+
+ /* GC procedures */
+
+ CreateGCProcPtr CreateGC;
+
+ /* Colormap procedures */
+
+ CreateColormapProcPtr CreateColormap;
+ DestroyColormapProcPtr DestroyColormap;
+ InstallColormapProcPtr InstallColormap;
+ UninstallColormapProcPtr UninstallColormap;
+ ListInstalledColormapsProcPtr ListInstalledColormaps;
+ StoreColorsProcPtr StoreColors;
+ ResolveColorProcPtr ResolveColor;
+
+ /* Region procedures */
+
+#ifdef NEED_SCREEN_REGIONS
+ RegionCreateProcPtr RegionCreate;
+ RegionInitProcPtr RegionInit;
+ RegionCopyProcPtr RegionCopy;
+ RegionDestroyProcPtr RegionDestroy;
+ RegionUninitProcPtr RegionUninit;
+ IntersectProcPtr Intersect;
+ UnionProcPtr Union;
+ SubtractProcPtr Subtract;
+ InverseProcPtr Inverse;
+ RegionResetProcPtr RegionReset;
+ TranslateRegionProcPtr TranslateRegion;
+ RectInProcPtr RectIn;
+ PointInRegionProcPtr PointInRegion;
+ RegionNotEmptyProcPtr RegionNotEmpty;
+ RegionEqualProcPtr RegionEqual;
+ RegionBrokenProcPtr RegionBroken;
+ RegionBreakProcPtr RegionBreak;
+ RegionEmptyProcPtr RegionEmpty;
+ RegionExtentsProcPtr RegionExtents;
+ RegionAppendProcPtr RegionAppend;
+ RegionValidateProcPtr RegionValidate;
+#endif /* NEED_SCREEN_REGIONS */
+ BitmapToRegionProcPtr BitmapToRegion;
+#ifdef NEED_SCREEN_REGIONS
+ RectsToRegionProcPtr RectsToRegion;
+#endif /* NEED_SCREEN_REGIONS */
+ SendGraphicsExposeProcPtr SendGraphicsExpose;
+
+ /* os layer procedures */
+
+ ScreenBlockHandlerProcPtr BlockHandler;
+ ScreenWakeupHandlerProcPtr WakeupHandler;
+
+ pointer blockData;
+ pointer wakeupData;
+
+ /* anybody can get a piece of this array */
+ DevUnion *devPrivates;
+
+ CreateScreenResourcesProcPtr CreateScreenResources;
+ ModifyPixmapHeaderProcPtr ModifyPixmapHeader;
+
+ GetWindowPixmapProcPtr GetWindowPixmap;
+ SetWindowPixmapProcPtr SetWindowPixmap;
+ GetScreenPixmapProcPtr GetScreenPixmap;
+ SetScreenPixmapProcPtr SetScreenPixmap;
+
+ PixmapPtr pScratchPixmap; /* scratch pixmap "pool" */
+
+#ifdef PIXPRIV
+ int PixmapPrivateLen;
+ unsigned int *PixmapPrivateSizes;
+ unsigned int totalPixmapSize;
+#endif
+
+ MarkWindowProcPtr MarkWindow;
+ MarkOverlappedWindowsProcPtr MarkOverlappedWindows;
+ ChangeSaveUnderProcPtr ChangeSaveUnder;
+ PostChangeSaveUnderProcPtr PostChangeSaveUnder;
+ MoveWindowProcPtr MoveWindow;
+ ResizeWindowProcPtr ResizeWindow;
+ GetLayerWindowProcPtr GetLayerWindow;
+ HandleExposuresProcPtr HandleExposures;
+ ReparentWindowProcPtr ReparentWindow;
+
+#ifdef SHAPE
+ SetShapeProcPtr SetShape;
+#endif /* SHAPE */
+
+ ChangeBorderWidthProcPtr ChangeBorderWidth;
+ MarkUnrealizedWindowProcPtr MarkUnrealizedWindow;
+
+} ScreenRec;
+
+typedef struct _ScreenInfo {
+ int imageByteOrder;
+ int bitmapScanlineUnit;
+ int bitmapScanlinePad;
+ int bitmapBitOrder;
+ int numPixmapFormats;
+ PixmapFormatRec
+ formats[MAXFORMATS];
+ int arraySize;
+ int numScreens;
+ ScreenPtr screens[MAXSCREENS];
+ int numVideoScreens;
+} ScreenInfo;
+
+extern ScreenInfo screenInfo;
+
+extern void InitOutput(
+ ScreenInfo * /*pScreenInfo*/,
+ int /*argc*/,
+ char ** /*argv*/);
+
+#endif /* SCREENINTSTRUCT_H */
diff --git a/nx-X11/programs/Xserver/include/selection.h b/nx-X11/programs/Xserver/include/selection.h
new file mode 100644
index 000000000..9e6edfbd9
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/selection.h
@@ -0,0 +1,69 @@
+/* $Xorg: selection.h,v 1.4 2001/02/09 02:05:16 xorgcvs Exp $ */
+
+#ifndef SELECTION_H
+#define SELECTION_H 1
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#include "dixstruct.h"
+/*
+ *
+ * Selection data structures
+ */
+
+typedef struct _Selection {
+ Atom selection;
+ TimeStamp lastTimeChanged;
+ Window window;
+ WindowPtr pWin;
+ ClientPtr client;
+} Selection;
+
+#endif /* SELECTION_H */
+
+
diff --git a/nx-X11/programs/Xserver/include/servermd.h b/nx-X11/programs/Xserver/include/servermd.h
new file mode 100644
index 000000000..cce6b329c
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/servermd.h
@@ -0,0 +1,583 @@
+/* $XFree86: xc/programs/Xserver/include/servermd.h,v 3.56tsi Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: servermd.h,v 1.3 2000/08/17 19:53:31 cpqbld Exp $ */
+/* $XdotOrg: xc/programs/Xserver/include/servermd.h,v 1.9 2005/11/15 00:29:23 ajax Exp $ */
+
+#ifndef SERVERMD_H
+#define SERVERMD_H 1
+
+/*
+ * Machine dependent values:
+ * GLYPHPADBYTES should be chosen with consideration for the space-time
+ * trade-off. Padding to 0 bytes means that there is no wasted space
+ * in the font bitmaps (both on disk and in memory), but that access of
+ * the bitmaps will cause odd-address memory references. Padding to
+ * 2 bytes would ensure even address memory references and would
+ * be suitable for a 68010-class machine, but at the expense of wasted
+ * space in the font bitmaps. Padding to 4 bytes would be good
+ * for real 32 bit machines, etc. Be sure that you tell the font
+ * compiler what kind of padding you want because its defines are
+ * kept separate from this. See server/include/font.h for how
+ * GLYPHPADBYTES is used.
+ *
+ * Along with this, you should choose an appropriate value for
+ * GETLEFTBITS_ALIGNMENT, which is used in ddx/mfb/maskbits.h. This
+ * constant choses what kind of memory references are guarenteed during
+ * font access; either 1, 2 or 4, for byte, word or longword access,
+ * respectively. For instance, if you have decided to to have
+ * GLYPHPADBYTES == 4, then it is pointless for you to have a
+ * GETLEFTBITS_ALIGNMENT > 1, because the padding of the fonts has already
+ * guarenteed you that your fonts are longword aligned. On the other
+ * hand, even if you have chosen GLYPHPADBYTES == 1 to save space, you may
+ * also decide that the computing involved in aligning the pointer is more
+ * costly than an odd-address access; you choose GETLEFTBITS_ALIGNMENT == 1.
+ *
+ * Next, choose the tuning parameters which are appropriate for your
+ * hardware; these modify the behaviour of the raw frame buffer code
+ * in ddx/mfb and ddx/cfb. Defining these incorrectly will not cause
+ * the server to run incorrectly, but defining these correctly will
+ * cause some noticeable speed improvements:
+ *
+ * AVOID_MEMORY_READ - (8-bit cfb only)
+ * When stippling pixels on the screen (polytext and pushpixels),
+ * don't read long words from the display and mask in the
+ * appropriate values. Rather, perform multiple byte/short/long
+ * writes as appropriate. This option uses many more instructions
+ * but runs much faster when the destination is much slower than
+ * the CPU and at least 1 level of write buffer is availible (2
+ * is much better). Defined currently for SPARC and MIPS.
+ *
+ * FAST_CONSTANT_OFFSET_MODE - (cfb and mfb)
+ * This define is used on machines which have no auto-increment
+ * addressing mode, but do have an effectively free constant-offset
+ * addressing mode. Currently defined for MIPS and SPARC, even though
+ * I remember the cg6 as performing better without it (cg3 definitely
+ * performs better with it).
+ *
+ * LARGE_INSTRUCTION_CACHE -
+ * This define increases the number of times some loops are
+ * unrolled. On 68020 machines (with 256 bytes of i-cache),
+ * this define will slow execution down as instructions miss
+ * the cache frequently. On machines with real i-caches, this
+ * reduces loop overhead, causing a slight performance improvement.
+ * Currently defined for MIPS and SPARC
+ *
+ * FAST_UNALIGNED_READS -
+ * For machines with more memory bandwidth than CPU, this
+ * define uses unaligned reads for 8-bit BitBLT instead of doing
+ * aligned reads and combining the results with shifts and
+ * logical-ors. Currently defined for 68020 and vax.
+ * PLENTIFUL_REGISTERS -
+ * For machines with > 20 registers. Currently used for
+ * unrolling the text painting code a bit more. Currently
+ * defined for MIPS.
+ * SHARED_IDCACHE -
+ * For non-Harvard RISC machines, those which share the same
+ * CPU memory bus for instructions and data. This unrolls some
+ * solid fill loops which are otherwise best left rolled up.
+ * Currently defined for SPARC.
+ */
+
+#ifdef vax
+
+#define IMAGE_BYTE_ORDER LSBFirst /* Values for the VAX only */
+#define BITMAP_BIT_ORDER LSBFirst
+#define GLYPHPADBYTES 1
+#define GETLEFTBITS_ALIGNMENT 4
+#define FAST_UNALIGNED_READS
+
+#endif /* vax */
+
+#ifdef __arm32__
+
+#define IMAGE_BYTE_ORDER LSBFirst
+
+# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
+# define BITMAP_BIT_ORDER MSBFirst
+# else
+# define BITMAP_BIT_ORDER LSBFirst
+# endif
+
+# if defined(XF86MONOVGA) || defined(XF86VGA16)
+# define BITMAP_SCANLINE_UNIT 8
+# endif
+
+#define GLYPHPADBYTES 4
+#define GETLEFTBITS_ALIGNMENT 1
+#define LARGE_INSTRUCTION_CACHE
+#define AVOID_MEMORY_READ
+
+#endif /* __arm32__ */
+
+#if defined (hpux) || defined __hppa__
+
+#define IMAGE_BYTE_ORDER MSBFirst
+#define BITMAP_BIT_ORDER MSBFirst
+#define GLYPHPADBYTES 4 /* to make fb work */
+#define GETLEFTBITS_ALIGNMENT 1 /* PA forces longs to 4 */
+ /* byte boundries */
+#define AVOID_MEMORY_READ
+#define FAST_CONSTANT_OFFSET_MODE
+#define LARGE_INSTRUCTION_CACHE
+#define PLENTIFUL_REGISTERS
+
+#endif /* hpux || __hppa__ */
+
+#if defined(__powerpc__) || defined(__ppc__)
+
+#define IMAGE_BYTE_ORDER MSBFirst
+#define BITMAP_BIT_ORDER MSBFirst
+#define GLYPHPADBYTES 4
+#define GETLEFTBITS_ALIGNMENT 1
+
+/* XXX Should this be for Lynx only? */
+#ifdef Lynx
+#define BITMAP_SCANLINE_UNIT 8
+#endif
+
+#define LARGE_INSTRUCTION_CACHE
+#define FAST_CONSTANT_OFFSET_MODE
+#define PLENTIFUL_REGISTERS
+#define AVOID_MEMORY_READ
+
+#define FAST_MEMCPY
+
+#endif /* PowerPC */
+
+#if defined(__sh__)
+
+#if defined(__BIG_ENDIAN__)
+# define IMAGE_BYTE_ORDER MSBFirst
+# define BITMAP_BIT_ORDER MSBFirst
+# define GLYPHPADBYTES 4
+# define GETLEFTBITS_ALIGNMENT 1
+#else
+# define IMAGE_BYTE_ORDER LSBFirst
+# define BITMAP_BIT_ORDER LSBFirst
+# define GLYPHPADBYTES 4
+# define GETLEFTBITS_ALIGNMENT 1
+#endif
+
+#define AVOID_MEMORY_READ
+#define FAST_CONSTANT_OFFSET_MODE
+#define LARGE_INSTRUCTION_CACHE
+#define PLENTIFUL_REGISTERS
+
+#endif /* SuperH */
+
+
+#if (defined(sun) && (defined(__sparc) || defined(sparc))) || \
+ (defined(__uxp__) && (defined(sparc) || defined(mc68000))) || \
+ defined(__sparc__) || defined(__mc68000__)
+
+#if defined(__sparc) || defined(__sparc__)
+# if !defined(sparc)
+# define sparc 1
+# endif
+#endif
+
+#if defined(sun386) || defined(sun5)
+# define IMAGE_BYTE_ORDER LSBFirst /* Values for the SUN only */
+# define BITMAP_BIT_ORDER LSBFirst
+#else
+# define IMAGE_BYTE_ORDER MSBFirst /* Values for the SUN only */
+# define BITMAP_BIT_ORDER MSBFirst
+#endif
+
+#ifdef sparc
+# define AVOID_MEMORY_READ
+# define LARGE_INSTRUCTION_CACHE
+# define FAST_CONSTANT_OFFSET_MODE
+# define SHARED_IDCACHE
+#endif
+
+#ifdef mc68020
+#define FAST_UNALIGNED_READS
+#endif
+
+#define GLYPHPADBYTES 4
+#define GETLEFTBITS_ALIGNMENT 1
+
+#endif /* sun && !(i386 && SVR4) */
+
+
+#if defined(AIXV3)
+
+#define IMAGE_BYTE_ORDER MSBFirst /* Values for the RISC/6000 */
+#define BITMAP_BIT_ORDER MSBFirst
+#define GLYPHPADBYTES 4
+#define GETLEFTBITS_ALIGNMENT 1
+
+#define LARGE_INSTRUCTION_CACHE
+#define FAST_CONSTANT_OFFSET_MODE
+#define PLENTIFUL_REGISTERS
+#define AVOID_MEMORY_READ
+
+#define FAST_MEMCPY
+#endif /* AIXV3 */
+
+#if defined(ibm032) || defined (ibm)
+
+#ifdef i386
+# define IMAGE_BYTE_ORDER LSBFirst /* Value for PS/2 only */
+#else
+# define IMAGE_BYTE_ORDER MSBFirst /* Values for the RT only*/
+#endif
+#define BITMAP_BIT_ORDER MSBFirst
+#define GLYPHPADBYTES 1
+#define GETLEFTBITS_ALIGNMENT 4
+/* ibm pcc doesn't understand pragmas. */
+
+#ifdef i386
+#define BITMAP_SCANLINE_UNIT 8
+#endif
+
+#endif /* ibm */
+
+#if defined (M4310) || defined(M4315) || defined(M4317) || defined(M4319) || defined(M4330)
+
+#define IMAGE_BYTE_ORDER MSBFirst /* Values for Pegasus only */
+#define BITMAP_BIT_ORDER MSBFirst
+#define GLYPHPADBYTES 4
+#define GETLEFTBITS_ALIGNMENT 1
+
+#define FAST_UNALIGNED_READS
+
+#endif /* tektronix */
+
+#ifdef macII
+
+#define IMAGE_BYTE_ORDER MSBFirst /* Values for the MacII only */
+#define BITMAP_BIT_ORDER MSBFirst
+#define GLYPHPADBYTES 4
+#define GETLEFTBITS_ALIGNMENT 1
+
+/* might want FAST_UNALIGNED_READS for frame buffers with < 1us latency */
+
+#endif /* macII */
+
+#if (defined(mips) || defined(__mips)) && !defined(sgi)
+
+#if defined(MIPSEL) || defined(__MIPSEL__)
+# define IMAGE_BYTE_ORDER LSBFirst /* Values for the PMAX only */
+# define BITMAP_BIT_ORDER LSBFirst
+# define GLYPHPADBYTES 4
+# define GETLEFTBITS_ALIGNMENT 1
+#else
+# define IMAGE_BYTE_ORDER MSBFirst /* Values for the MIPS only */
+# define BITMAP_BIT_ORDER MSBFirst
+# define GLYPHPADBYTES 4
+# define GETLEFTBITS_ALIGNMENT 1
+#endif
+
+#define AVOID_MEMORY_READ
+#define FAST_CONSTANT_OFFSET_MODE
+#define LARGE_INSTRUCTION_CACHE
+#define PLENTIFUL_REGISTERS
+
+#endif /* mips */
+
+#if defined(__alpha) || defined(__alpha__) || defined(__alphaCross)
+# define IMAGE_BYTE_ORDER LSBFirst /* Values for the Alpha only */
+
+# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
+# define BITMAP_BIT_ORDER MSBFirst
+# else
+# define BITMAP_BIT_ORDER LSBFirst
+# endif
+
+# if defined(XF86MONOVGA) || defined(XF86VGA16)
+# define BITMAP_SCANLINE_UNIT 8
+# endif
+
+# define GLYPHPADBYTES 4
+# define GETLEFTBITS_ALIGNMENT 1
+# define FAST_CONSTANT_OFFSET_MODE
+# define LARGE_INSTRUCTION_CACHE
+# define PLENTIFUL_REGISTERS
+
+#endif /* alpha */
+
+#if defined (linux) && defined (__s390__)
+
+#define IMAGE_BYTE_ORDER MSBFirst
+#define BITMAP_BIT_ORDER MSBFirst
+#define GLYPHPADBYTES 4
+#define GETLEFTBITS_ALIGNMENT 1
+
+#define BITMAP_SCANLINE_UNIT 8
+#define LARGE_INSTRUCTION_CACHE
+#define FAST_CONSTANT_OFFSET_MODE
+#define FAST_UNALIGNED_READ
+
+#define FAST_MEMCPY
+
+#endif /* linux/s390 */
+
+#if defined (linux) && defined (__s390x__)
+
+#define IMAGE_BYTE_ORDER MSBFirst
+#define BITMAP_BIT_ORDER MSBFirst
+#define GLYPHPADBYTES 4
+#define GETLEFTBITS_ALIGNMENT 1
+
+#define BITMAP_SCANLINE_UNIT 8
+#define LARGE_INSTRUCTION_CACHE
+#define FAST_CONSTANT_OFFSET_MODE
+#define FAST_UNALIGNED_READ
+
+#define FAST_MEMCPY
+#endif /* linux/s390x */
+
+
+#if defined(__ia64__) || defined(ia64)
+# define IMAGE_BYTE_ORDER LSBFirst
+
+# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
+# define BITMAP_BIT_ORDER MSBFirst
+# else
+# define BITMAP_BIT_ORDER LSBFirst
+# endif
+
+# if defined(XF86MONOVGA) || defined(XF86VGA16)
+# define BITMAP_SCANLINE_UNIT 8
+# endif
+
+# define GLYPHPADBYTES 4
+# define GETLEFTBITS_ALIGNMENT 1
+# define FAST_CONSTANT_OFFSET_MODE
+# define LARGE_INSTRUCTION_CACHE
+# define PLENTIFUL_REGISTERS
+
+#endif /* ia64 */
+
+#if defined(__amd64__) || defined(amd64) || defined(__amd64)
+# define IMAGE_BYTE_ORDER LSBFirst
+
+# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
+# define BITMAP_BIT_ORDER MSBFirst
+# else
+# define BITMAP_BIT_ORDER LSBFirst
+# endif
+
+# if defined(XF86MONOVGA) || defined(XF86VGA16)
+# define BITMAP_SCANLINE_UNIT 8
+# endif
+
+# define GLYPHPADBYTES 4
+# define GETLEFTBITS_ALIGNMENT 1
+# define LARGE_INSTRUCTION_CACHE
+# define FAST_CONSTANT_OFFSET_MODE
+/* ???? */
+# define FAST_UNALIGNED_READS
+#endif /* AMD64 */
+
+#ifdef stellar
+
+#define IMAGE_BYTE_ORDER MSBFirst /* Values for the stellar only*/
+#define BITMAP_BIT_ORDER MSBFirst
+#define GLYPHPADBYTES 4
+#define GETLEFTBITS_ALIGNMENT 4
+#define IMAGE_BUFSIZE (64*1024)
+/*
+ * Use SysV random number generator.
+ */
+#define random rand
+
+#endif /* stellar */
+
+#ifdef luna
+
+#define IMAGE_BYTE_ORDER MSBFirst /* Values for the OMRON only*/
+#define BITMAP_BIT_ORDER MSBFirst
+#define GLYPHPADBYTES 4
+#define GETLEFTBITS_ALIGNMENT 1
+
+#ifndef mc68000
+#define FAST_CONSTANT_OFFSET_MODE
+#define AVOID_MEMORY_READ
+#define LARGE_INSTRUCTION_CACHE
+#define PLENTIFUL_REGISTERS
+#endif
+
+#endif /* luna */
+
+#if (defined(SVR4) && defined(i386)) || \
+ defined(__alpha__) || defined(__alpha) || \
+ defined(__i386__) || defined(__i386) || \
+ defined(__UNIXOS2__) || \
+ defined(__OS2ELF__) || \
+ defined(__QNX__) || \
+ defined(__s390x__) || defined(__s390__)
+
+#ifndef IMAGE_BYTE_ORDER
+#define IMAGE_BYTE_ORDER LSBFirst
+#endif
+
+#ifndef BITMAP_BIT_ORDER
+# if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
+# define BITMAP_BIT_ORDER MSBFirst
+# else
+# define BITMAP_BIT_ORDER LSBFirst
+# endif
+#endif
+
+#ifndef BITMAP_SCANLINE_UNIT
+# if defined(XF86MONOVGA) || defined(XF86VGA16)
+# define BITMAP_SCANLINE_UNIT 8
+# endif
+#endif
+
+#ifndef GLYPHPADBYTES
+#define GLYPHPADBYTES 4
+#endif
+
+#define GETLEFTBITS_ALIGNMENT 1
+#define AVOID_MEMORY_READ
+#ifdef XSVGA
+#define AVOID_GLYPHBLT
+#define FAST_CONSTANT_OFFSET_MODE
+#define FAST_MEMCPY
+#define NO_ONE_RECT
+#endif
+
+#endif /* SVR4 / BSD / i386 */
+
+#if defined (linux) && defined (__mc68000__)
+
+#define IMAGE_BYTE_ORDER MSBFirst
+#define BITMAP_BIT_ORDER MSBFirst
+#define FAST_UNALIGNED_READS
+#define GLYPHPADBYTES 4
+#define GETLEFTBITS_ALIGNMENT 1
+
+#endif /* linux/m68k */
+
+#ifdef sgi
+
+#define IMAGE_BYTE_ORDER MSBFirst
+#define BITMAP_BIT_ORDER MSBFirst
+#define GLYPHPADBYTES 4
+#define GETLEFTBITS_ALIGNMENT 1
+#define AVOID_MEMORY_READ
+#define FAST_CONSTANT_OFFSET_MODE
+#define LARGE_INSTRUCTION_CACHE
+#define PLENTIFUL_REGISTERS
+
+#endif
+
+/* linux on the Compaq Itsy */
+#if defined(linux) && defined(__arm__)
+#define IMAGE_BYTE_ORDER LSBFirst
+#define BITMAP_BIT_ORDER LSBFirst
+#define GLYPHPADBYTES 4
+#define GETLEFTBITS_ALIGNMENT 1
+#endif
+
+/* size of buffer to use with GetImage, measured in bytes. There's obviously
+ * a trade-off between the amount of stack (or whatever ALLOCATE_LOCAL gives
+ * you) used and the number of times the ddx routine has to be called.
+ */
+#ifndef IMAGE_BUFSIZE
+#define IMAGE_BUFSIZE (64*1024)
+#endif
+
+/* pad scanline to a longword */
+#ifndef BITMAP_SCANLINE_UNIT
+#define BITMAP_SCANLINE_UNIT 32
+#endif
+
+#ifndef BITMAP_SCANLINE_PAD
+#define BITMAP_SCANLINE_PAD 32
+#define LOG2_BITMAP_PAD 5
+#define LOG2_BYTES_PER_SCANLINE_PAD 2
+#endif
+
+/*
+ * This returns the number of padding units, for depth d and width w.
+ * For bitmaps this can be calculated with the macros above.
+ * Other depths require either grovelling over the formats field of the
+ * screenInfo or hardwired constants.
+ */
+
+typedef struct _PaddingInfo {
+ int padRoundUp; /* pixels per pad unit - 1 */
+ int padPixelsLog2; /* log 2 (pixels per pad unit) */
+ int padBytesLog2; /* log 2 (bytes per pad unit) */
+ int notPower2; /* bitsPerPixel not a power of 2 */
+ int bytesPerPixel; /* only set when notPower2 is TRUE */
+ int bitsPerPixel; /* bits per pixel */
+} PaddingInfo;
+extern PaddingInfo PixmapWidthPaddingInfo[];
+
+/* The only portable way to get the bpp from the depth is to look it up */
+#define BitsPerPixel(d) (PixmapWidthPaddingInfo[d].bitsPerPixel)
+
+#define PixmapWidthInPadUnits(w, d) \
+ (PixmapWidthPaddingInfo[d].notPower2 ? \
+ (((int)(w) * PixmapWidthPaddingInfo[d].bytesPerPixel + \
+ PixmapWidthPaddingInfo[d].bytesPerPixel) >> \
+ PixmapWidthPaddingInfo[d].padBytesLog2) : \
+ ((int)((w) + PixmapWidthPaddingInfo[d].padRoundUp) >> \
+ PixmapWidthPaddingInfo[d].padPixelsLog2))
+
+/*
+ * Return the number of bytes to which a scanline of the given
+ * depth and width will be padded.
+ */
+#define PixmapBytePad(w, d) \
+ (PixmapWidthInPadUnits(w, d) << PixmapWidthPaddingInfo[d].padBytesLog2)
+
+#define BitmapBytePad(w) \
+ (((int)((w) + BITMAP_SCANLINE_PAD - 1) >> LOG2_BITMAP_PAD) << LOG2_BYTES_PER_SCANLINE_PAD)
+
+#define PixmapWidthInPadUnitsProto(w, d) PixmapWidthInPadUnits(w, d)
+#define PixmapBytePadProto(w, d) PixmapBytePad(w, d)
+#define BitmapBytePadProto(w) BitmapBytePad(w)
+
+#endif /* SERVERMD_H */
diff --git a/nx-X11/programs/Xserver/include/site.h b/nx-X11/programs/Xserver/include/site.h
new file mode 100644
index 000000000..be8c003da
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/site.h
@@ -0,0 +1,139 @@
+/* $Xorg: site.h,v 1.6 2001/02/09 02:05:16 xorgcvs Exp $ */
+/************************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/include/site.h,v 1.8 2001/12/19 21:37:35 dawes Exp $ */
+
+#ifndef SITE_H
+#define SITE_H
+/*
+ * The vendor string identifies the vendor responsible for the
+ * server executable.
+ */
+#ifndef VENDOR_STRING
+#define VENDOR_STRING "The X.Org Group"
+#endif
+
+/*
+ * The vendor release number identifies, for the purpose of submitting
+ * traceable bug reports, the release number of software produced
+ * by the vendor.
+ */
+#ifndef VENDOR_RELEASE
+#define VENDOR_RELEASE 6600
+#endif
+
+/*
+ * The following constants are provided solely as a last line of defense. The
+ * normal build ALWAYS overrides them using a special rule given in
+ * server/dix/Imakefile. If you want to change either of these constants,
+ * you should set the DefaultFontPath or DefaultRGBDatabase configuration
+ * parameters.
+ * DO NOT CHANGE THESE VALUES OR THE DIX IMAKEFILE!
+ */
+#ifndef COMPILEDDEFAULTFONTPATH
+#define COMPILEDDEFAULTFONTPATH "/usr/lib/X11/fonts/misc/"
+#endif
+#ifndef RGB_DB
+#define RGB_DB "/usr/lib/X11/rgb"
+#endif
+
+/*
+ * The following constants contain default values for all of the variables
+ * that can be initialized on the server command line or in the environment.
+ */
+#define COMPILEDDEFAULTFONT "fixed"
+#define COMPILEDCURSORFONT "cursor"
+#ifndef COMPILEDDISPLAYCLASS
+#define COMPILEDDISPLAYCLASS "MIT-unspecified"
+#endif
+#define DEFAULT_TIMEOUT 60 /* seconds */
+#define DEFAULT_KEYBOARD_CLICK 0
+#define DEFAULT_BELL 50
+#define DEFAULT_BELL_PITCH 400
+#define DEFAULT_BELL_DURATION 100
+#ifdef XKB
+#define DEFAULT_AUTOREPEAT TRUE
+#else
+#define DEFAULT_AUTOREPEAT FALSE
+#endif
+#define DEFAULT_AUTOREPEATS {\
+ 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+
+#define DEFAULT_LEDS 0x0 /* all off */
+#define DEFAULT_LEDS_MASK 0xffffffff /* 32 */
+#define DEFAULT_INT_RESOLUTION 1000
+#define DEFAULT_INT_MIN_VALUE 0
+#define DEFAULT_INT_MAX_VALUE 100
+#define DEFAULT_INT_DISPLAYED 0
+
+#define DEFAULT_PTR_NUMERATOR 2
+#define DEFAULT_PTR_DENOMINATOR 1
+#define DEFAULT_PTR_THRESHOLD 4
+
+#define DEFAULT_SCREEN_SAVER_TIME (10 * (60 * 1000))
+#define DEFAULT_SCREEN_SAVER_INTERVAL (10 * (60 * 1000))
+#define DEFAULT_SCREEN_SAVER_BLANKING PreferBlanking
+#define DEFAULT_SCREEN_SAVER_EXPOSURES AllowExposures
+#ifndef NOLOGOHACK
+#define DEFAULT_LOGO_SCREEN_SAVER 1
+#endif
+#ifndef DEFAULT_ACCESS_CONTROL
+#define DEFAULT_ACCESS_CONTROL TRUE
+#endif
+
+/* Default logging parameters. */
+#ifndef DEFAULT_LOG_VERBOSITY
+#define DEFAULT_LOG_VERBOSITY 0
+#endif
+#ifndef DEFAULT_LOG_FILE_VERBOSITY
+#define DEFAULT_LOG_FILE_VERBOSITY 3
+#endif
+
+#endif /* SITE_H */
diff --git a/nx-X11/programs/Xserver/include/swaprep.h b/nx-X11/programs/Xserver/include/swaprep.h
new file mode 100644
index 000000000..2c026c659
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/swaprep.h
@@ -0,0 +1,322 @@
+/* $XFree86: xc/programs/Xserver/include/swaprep.h,v 3.0 1996/04/15 11:34:34 dawes Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifndef SWAPREP_H
+#define SWAPREP_H 1
+
+extern void Swap32Write(
+ ClientPtr /* pClient */,
+ int /* size */,
+ CARD32 * /* pbuf */);
+
+extern void CopySwap32Write(
+ ClientPtr /* pClient */,
+ int /* size */,
+ CARD32 * /* pbuf */);
+
+extern void CopySwap16Write(
+ ClientPtr /* pClient */,
+ int /* size */,
+ short * /* pbuf */);
+
+extern void SGenericReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xGenericReply * /* pRep */);
+
+extern void SGetWindowAttributesReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xGetWindowAttributesReply * /* pRep */);
+
+extern void SGetGeometryReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xGetGeometryReply * /* pRep */);
+
+extern void SQueryTreeReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xQueryTreeReply * /* pRep */);
+
+extern void SInternAtomReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xInternAtomReply * /* pRep */);
+
+extern void SGetAtomNameReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xGetAtomNameReply * /* pRep */);
+
+extern void SGetPropertyReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xGetPropertyReply * /* pRep */);
+
+extern void SListPropertiesReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xListPropertiesReply * /* pRep */);
+
+extern void SGetSelectionOwnerReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xGetSelectionOwnerReply * /* pRep */);
+
+extern void SQueryPointerReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xQueryPointerReply * /* pRep */);
+
+extern void SwapTimecoord(
+ xTimecoord * /* pCoord */);
+
+extern void SwapTimeCoordWrite(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xTimecoord * /* pRep */);
+
+extern void SGetMotionEventsReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xGetMotionEventsReply * /* pRep */);
+
+extern void STranslateCoordsReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xTranslateCoordsReply * /* pRep */);
+
+extern void SGetInputFocusReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xGetInputFocusReply * /* pRep */);
+
+extern void SQueryKeymapReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xQueryKeymapReply * /* pRep */);
+
+#ifdef LBX
+extern void SwapCharInfo(
+ xCharInfo * /* pInfo */);
+#endif
+
+#ifdef LBX
+extern void SwapFont(
+ xQueryFontReply * /* pr */,
+ Bool /* hasGlyphs */);
+#endif
+
+extern void SQueryFontReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xQueryFontReply * /* pRep */);
+
+extern void SQueryTextExtentsReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xQueryTextExtentsReply * /* pRep */);
+
+extern void SListFontsReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xListFontsReply * /* pRep */);
+
+extern void SListFontsWithInfoReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xListFontsWithInfoReply * /* pRep */);
+
+extern void SGetFontPathReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xGetFontPathReply * /* pRep */);
+
+extern void SGetImageReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xGetImageReply * /* pRep */);
+
+extern void SListInstalledColormapsReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xListInstalledColormapsReply * /* pRep */);
+
+extern void SAllocColorReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xAllocColorReply * /* pRep */);
+
+extern void SAllocNamedColorReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xAllocNamedColorReply * /* pRep */);
+
+extern void SAllocColorCellsReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xAllocColorCellsReply * /* pRep */);
+
+extern void SAllocColorPlanesReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xAllocColorPlanesReply * /* pRep */);
+
+extern void SwapRGB(
+ xrgb * /* prgb */);
+
+extern void SQColorsExtend(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xrgb * /* prgb */);
+
+extern void SQueryColorsReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xQueryColorsReply * /* pRep */);
+
+extern void SLookupColorReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xLookupColorReply * /* pRep */);
+
+extern void SQueryBestSizeReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xQueryBestSizeReply * /* pRep */);
+
+extern void SListExtensionsReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xListExtensionsReply * /* pRep */);
+
+extern void SGetKeyboardMappingReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xGetKeyboardMappingReply * /* pRep */);
+
+extern void SGetPointerMappingReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xGetPointerMappingReply * /* pRep */);
+
+extern void SGetModifierMappingReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xGetModifierMappingReply * /* pRep */);
+
+extern void SGetKeyboardControlReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xGetKeyboardControlReply * /* pRep */);
+
+extern void SGetPointerControlReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xGetPointerControlReply * /* pRep */);
+
+extern void SGetScreenSaverReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xGetScreenSaverReply * /* pRep */);
+
+extern void SLHostsExtend(
+ ClientPtr /* pClient */,
+ int /* size */,
+ char * /* buf */);
+
+extern void SListHostsReply(
+ ClientPtr /* pClient */,
+ int /* size */,
+ xListHostsReply * /* pRep */);
+
+extern void SErrorEvent(
+ xError * /* from */,
+ xError * /* to */);
+
+extern void SwapConnSetupInfo(
+ char * /* pInfo */,
+ char * /* pInfoTBase */);
+
+extern void WriteSConnectionInfo(
+ ClientPtr /* pClient */,
+ unsigned long /* size */,
+ char * /* pInfo */);
+
+extern void SwapConnSetup(
+ xConnSetup * /* pConnSetup */,
+ xConnSetup * /* pConnSetupT */);
+
+extern void SwapWinRoot(
+ xWindowRoot * /* pRoot */,
+ xWindowRoot * /* pRootT */);
+
+extern void SwapVisual(
+ xVisualType * /* pVis */,
+ xVisualType * /* pVisT */);
+
+extern void SwapConnSetupPrefix(
+ xConnSetupPrefix * /* pcspFrom */,
+ xConnSetupPrefix * /* pcspTo */);
+
+extern void WriteSConnSetupPrefix(
+ ClientPtr /* pClient */,
+ xConnSetupPrefix * /* pcsp */);
+
+#undef SWAPREP_PROC
+#define SWAPREP_PROC(func) void func(xEvent * /* from */, xEvent * /* to */)
+
+SWAPREP_PROC(SCirculateEvent);
+SWAPREP_PROC(SClientMessageEvent);
+SWAPREP_PROC(SColormapEvent);
+SWAPREP_PROC(SConfigureNotifyEvent);
+SWAPREP_PROC(SConfigureRequestEvent);
+SWAPREP_PROC(SCreateNotifyEvent);
+SWAPREP_PROC(SDestroyNotifyEvent);
+SWAPREP_PROC(SEnterLeaveEvent);
+SWAPREP_PROC(SExposeEvent);
+SWAPREP_PROC(SFocusEvent);
+SWAPREP_PROC(SGraphicsExposureEvent);
+SWAPREP_PROC(SGravityEvent);
+SWAPREP_PROC(SKeyButtonPtrEvent);
+SWAPREP_PROC(SKeymapNotifyEvent);
+SWAPREP_PROC(SMapNotifyEvent);
+SWAPREP_PROC(SMapRequestEvent);
+SWAPREP_PROC(SMappingEvent);
+SWAPREP_PROC(SNoExposureEvent);
+SWAPREP_PROC(SPropertyEvent);
+SWAPREP_PROC(SReparentEvent);
+SWAPREP_PROC(SResizeRequestEvent);
+SWAPREP_PROC(SSelectionClearEvent);
+SWAPREP_PROC(SSelectionNotifyEvent);
+SWAPREP_PROC(SSelectionRequestEvent);
+SWAPREP_PROC(SUnmapNotifyEvent);
+SWAPREP_PROC(SVisibilityEvent);
+
+#undef SWAPREP_PROC
+
+#endif /* SWAPREP_H */
diff --git a/nx-X11/programs/Xserver/include/swapreq.h b/nx-X11/programs/Xserver/include/swapreq.h
new file mode 100644
index 000000000..9c59bbf84
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/swapreq.h
@@ -0,0 +1,120 @@
+/* $XFree86: xc/programs/Xserver/include/swapreq.h,v 1.3 2003/04/27 21:31:05 herrb Exp $ */
+/************************************************************
+
+Copyright 1996 by Thomas E. Dickey <dickey@clark.net>
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifndef SWAPREQ_H
+#define SWAPREQ_H 1
+
+/* The first two are in misc.h */
+#if 0
+extern void SwapLongs (
+ CARD32 * /* list */,
+ unsigned long /* count */);
+
+extern void SwapShorts (
+ short * /* list */,
+ unsigned long /* count */);
+#endif
+
+extern void SwapColorItem(
+ xColorItem * /* pItem */);
+
+extern void SwapConnClientPrefix(
+ xConnClientPrefix * /* pCCP */);
+
+#undef SWAPREQ_PROC
+
+#define SWAPREQ_PROC(func) int func(ClientPtr /* client */)
+
+SWAPREQ_PROC(SProcAllocColor);
+SWAPREQ_PROC(SProcAllocColorCells);
+SWAPREQ_PROC(SProcAllocColorPlanes);
+SWAPREQ_PROC(SProcAllocNamedColor);
+SWAPREQ_PROC(SProcChangeActivePointerGrab);
+SWAPREQ_PROC(SProcChangeGC);
+SWAPREQ_PROC(SProcChangeHosts);
+SWAPREQ_PROC(SProcChangeKeyboardControl);
+SWAPREQ_PROC(SProcChangeKeyboardMapping);
+SWAPREQ_PROC(SProcChangePointerControl);
+SWAPREQ_PROC(SProcChangeProperty);
+SWAPREQ_PROC(SProcChangeWindowAttributes);
+SWAPREQ_PROC(SProcClearToBackground);
+SWAPREQ_PROC(SProcConfigureWindow);
+SWAPREQ_PROC(SProcConvertSelection);
+SWAPREQ_PROC(SProcCopyArea);
+SWAPREQ_PROC(SProcCopyColormapAndFree);
+SWAPREQ_PROC(SProcCopyGC);
+SWAPREQ_PROC(SProcCopyPlane);
+SWAPREQ_PROC(SProcCreateColormap);
+SWAPREQ_PROC(SProcCreateCursor);
+SWAPREQ_PROC(SProcCreateGC);
+SWAPREQ_PROC(SProcCreateGlyphCursor);
+SWAPREQ_PROC(SProcCreatePixmap);
+SWAPREQ_PROC(SProcCreateWindow);
+SWAPREQ_PROC(SProcDeleteProperty);
+SWAPREQ_PROC(SProcFillPoly);
+SWAPREQ_PROC(SProcFreeColors);
+SWAPREQ_PROC(SProcGetImage);
+SWAPREQ_PROC(SProcGetMotionEvents);
+SWAPREQ_PROC(SProcGetProperty);
+SWAPREQ_PROC(SProcGrabButton);
+SWAPREQ_PROC(SProcGrabKey);
+SWAPREQ_PROC(SProcGrabKeyboard);
+SWAPREQ_PROC(SProcGrabPointer);
+SWAPREQ_PROC(SProcImageText);
+SWAPREQ_PROC(SProcInternAtom);
+SWAPREQ_PROC(SProcListFonts);
+SWAPREQ_PROC(SProcListFontsWithInfo);
+SWAPREQ_PROC(SProcLookupColor);
+SWAPREQ_PROC(SProcNoOperation);
+SWAPREQ_PROC(SProcOpenFont);
+SWAPREQ_PROC(SProcPoly);
+SWAPREQ_PROC(SProcPolyText);
+SWAPREQ_PROC(SProcPutImage);
+SWAPREQ_PROC(SProcQueryBestSize);
+SWAPREQ_PROC(SProcQueryColors);
+SWAPREQ_PROC(SProcQueryExtension);
+SWAPREQ_PROC(SProcRecolorCursor);
+SWAPREQ_PROC(SProcReparentWindow);
+SWAPREQ_PROC(SProcResourceReq);
+SWAPREQ_PROC(SProcRotateProperties);
+SWAPREQ_PROC(SProcSendEvent);
+SWAPREQ_PROC(SProcSetClipRectangles);
+SWAPREQ_PROC(SProcSetDashes);
+SWAPREQ_PROC(SProcSetFontPath);
+SWAPREQ_PROC(SProcSetInputFocus);
+SWAPREQ_PROC(SProcSetScreenSaver);
+SWAPREQ_PROC(SProcSetSelectionOwner);
+SWAPREQ_PROC(SProcSimpleReq);
+SWAPREQ_PROC(SProcStoreColors);
+SWAPREQ_PROC(SProcStoreNamedColor);
+SWAPREQ_PROC(SProcTranslateCoords);
+SWAPREQ_PROC(SProcUngrabButton);
+SWAPREQ_PROC(SProcUngrabKey);
+SWAPREQ_PROC(SProcWarpPointer);
+
+#undef SWAPREQ_PROC
+
+#endif /* SWAPREQ_H */
diff --git a/nx-X11/programs/Xserver/include/validate.h b/nx-X11/programs/Xserver/include/validate.h
new file mode 100644
index 000000000..467533d22
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/validate.h
@@ -0,0 +1,42 @@
+/* $Xorg: validate.h,v 1.4 2001/02/09 02:05:16 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+/* $XFree86: xc/programs/Xserver/include/validate.h,v 1.4 2001/01/17 22:36:58 dawes Exp $ */
+
+#ifndef VALIDATE_H
+#define VALIDATE_H
+
+#include "miscstruct.h"
+#include "regionstr.h"
+
+typedef enum { VTOther, VTStack, VTMove, VTUnmap, VTMap, VTBroken } VTKind;
+
+/* union _Validate is now device dependent; see mivalidate.h for an example */
+typedef union _Validate *ValidatePtr;
+
+#define UnmapValData ((ValidatePtr)1)
+
+#endif /* VALIDATE_H */
diff --git a/nx-X11/programs/Xserver/include/window.h b/nx-X11/programs/Xserver/include/window.h
new file mode 100644
index 000000000..7c3fce092
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/window.h
@@ -0,0 +1,265 @@
+/* $Xorg: window.h,v 1.4 2001/02/09 02:05:16 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86$ */
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include "misc.h"
+#include "region.h"
+#include "screenint.h"
+#include <X11/Xproto.h>
+
+#define TOTALLY_OBSCURED 0
+#define UNOBSCURED 1
+#define OBSCURED 2
+
+#define VisibilityNotViewable 3
+
+/* return values for tree-walking callback procedures */
+#define WT_STOPWALKING 0
+#define WT_WALKCHILDREN 1
+#define WT_DONTWALKCHILDREN 2
+#define WT_NOMATCH 3
+#define NullWindow ((WindowPtr) 0)
+
+typedef struct _BackingStore *BackingStorePtr;
+typedef struct _Window *WindowPtr;
+
+typedef int (*VisitWindowProcPtr)(
+ WindowPtr /*pWin*/,
+ pointer /*data*/);
+
+extern int TraverseTree(
+ WindowPtr /*pWin*/,
+ VisitWindowProcPtr /*func*/,
+ pointer /*data*/);
+
+extern int WalkTree(
+ ScreenPtr /*pScreen*/,
+ VisitWindowProcPtr /*func*/,
+ pointer /*data*/);
+
+extern WindowPtr AllocateWindow(
+ ScreenPtr /*pScreen*/);
+
+extern Bool CreateRootWindow(
+ ScreenPtr /*pScreen*/);
+
+extern void InitRootWindow(
+ WindowPtr /*pWin*/);
+
+extern void ClippedRegionFromBox(
+ WindowPtr /*pWin*/,
+ RegionPtr /*Rgn*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/);
+
+extern WindowPtr RealChildHead(
+ WindowPtr /*pWin*/);
+
+extern WindowPtr CreateWindow(
+ Window /*wid*/,
+ WindowPtr /*pParent*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*w*/,
+ unsigned int /*h*/,
+ unsigned int /*bw*/,
+ unsigned int /*class*/,
+ Mask /*vmask*/,
+ XID* /*vlist*/,
+ int /*depth*/,
+ ClientPtr /*client*/,
+ VisualID /*visual*/,
+ int* /*error*/);
+
+extern int DeleteWindow(
+ pointer /*pWin*/,
+ XID /*wid*/);
+
+extern void DestroySubwindows(
+ WindowPtr /*pWin*/,
+ ClientPtr /*client*/);
+
+/* Quartz support on Mac OS X uses the HIToolbox
+ framework whose ChangeWindowAttributes function conflicts here. */
+#ifdef __DARWIN__
+#define ChangeWindowAttributes Darwin_X_ChangeWindowAttributes
+#endif
+extern int ChangeWindowAttributes(
+ WindowPtr /*pWin*/,
+ Mask /*vmask*/,
+ XID* /*vlist*/,
+ ClientPtr /*client*/);
+
+/* Quartz support on Mac OS X uses the HIToolbox
+ framework whose GetWindowAttributes function conflicts here. */
+#ifdef __DARWIN__
+#define GetWindowAttributes(w,c,x) Darwin_X_GetWindowAttributes(w,c,x)
+extern void Darwin_X_GetWindowAttributes(
+#else
+extern void GetWindowAttributes(
+#endif
+ WindowPtr /*pWin*/,
+ ClientPtr /*client*/,
+ xGetWindowAttributesReply* /* wa */);
+
+extern RegionPtr CreateUnclippedWinSize(
+ WindowPtr /*pWin*/);
+
+extern void GravityTranslate(
+ int /*x*/,
+ int /*y*/,
+ int /*oldx*/,
+ int /*oldy*/,
+ int /*dw*/,
+ int /*dh*/,
+ unsigned /*gravity*/,
+ int* /*destx*/,
+ int* /*desty*/);
+
+extern int ConfigureWindow(
+ WindowPtr /*pWin*/,
+ Mask /*mask*/,
+ XID* /*vlist*/,
+ ClientPtr /*client*/);
+
+extern int CirculateWindow(
+ WindowPtr /*pParent*/,
+ int /*direction*/,
+ ClientPtr /*client*/);
+
+extern int ReparentWindow(
+ WindowPtr /*pWin*/,
+ WindowPtr /*pParent*/,
+ int /*x*/,
+ int /*y*/,
+ ClientPtr /*client*/);
+
+extern int MapWindow(
+ WindowPtr /*pWin*/,
+ ClientPtr /*client*/);
+
+extern void MapSubwindows(
+ WindowPtr /*pParent*/,
+ ClientPtr /*client*/);
+
+extern int UnmapWindow(
+ WindowPtr /*pWin*/,
+ Bool /*fromConfigure*/);
+
+extern void UnmapSubwindows(
+ WindowPtr /*pWin*/);
+
+extern void HandleSaveSet(
+ ClientPtr /*client*/);
+
+extern Bool VisibleBoundingBoxFromPoint(
+ WindowPtr /*pWin*/,
+ int /*x*/,
+ int /*y*/,
+ BoxPtr /*box*/);
+
+extern Bool PointInWindowIsVisible(
+ WindowPtr /*pWin*/,
+ int /*x*/,
+ int /*y*/);
+
+extern RegionPtr NotClippedByChildren(
+ WindowPtr /*pWin*/);
+
+extern void SendVisibilityNotify(
+ WindowPtr /*pWin*/);
+
+extern void SaveScreens(
+ int /*on*/,
+ int /*mode*/);
+
+extern WindowPtr FindWindowWithOptional(
+ WindowPtr /*w*/);
+
+extern void CheckWindowOptionalNeed(
+ WindowPtr /*w*/);
+
+extern Bool MakeWindowOptional(
+ WindowPtr /*pWin*/);
+
+extern void DisposeWindowOptional(
+ WindowPtr /*pWin*/);
+
+extern WindowPtr MoveWindowInStack(
+ WindowPtr /*pWin*/,
+ WindowPtr /*pNextSib*/);
+
+void SetWinSize(
+ WindowPtr /*pWin*/);
+
+void SetBorderSize(
+ WindowPtr /*pWin*/);
+
+void ResizeChildrenWinSize(
+ WindowPtr /*pWin*/,
+ int /*dx*/,
+ int /*dy*/,
+ int /*dw*/,
+ int /*dh*/);
+
+extern void SendShapeNotify(
+ WindowPtr /* pWin */,
+ int /* which */ );
+
+extern RegionPtr CreateBoundingShape(
+ WindowPtr /* pWin */ );
+
+extern RegionPtr CreateClipShape(
+ WindowPtr /* pWin */ );
+
+#endif /* WINDOW_H */
diff --git a/nx-X11/programs/Xserver/include/windowstr.h b/nx-X11/programs/Xserver/include/windowstr.h
new file mode 100644
index 000000000..89e3ee10b
--- /dev/null
+++ b/nx-X11/programs/Xserver/include/windowstr.h
@@ -0,0 +1,234 @@
+/* $Xorg: windowstr.h,v 1.4 2001/02/09 02:05:16 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/include/windowstr.h,v 1.6 2001/12/14 19:59:57 dawes Exp $ */
+
+#ifndef WINDOWSTRUCT_H
+#define WINDOWSTRUCT_H
+
+#include "window.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "cursor.h"
+#include "property.h"
+#include "resource.h" /* for ROOT_WINDOW_ID_BASE */
+#include "dix.h"
+#include "miscstruct.h"
+#include <X11/Xprotostr.h>
+#include "opaque.h"
+
+#define GuaranteeNothing 0
+#define GuaranteeVisBack 1
+
+#define SameBackground(as, a, bs, b) \
+ ((as) == (bs) && ((as) == None || \
+ (as) == ParentRelative || \
+ SamePixUnion(a,b,as == BackgroundPixel)))
+
+#define SameBorder(as, a, bs, b) \
+ EqualPixUnion(as, a, bs, b)
+
+typedef struct _WindowOpt {
+ VisualID visual; /* default: same as parent */
+ CursorPtr cursor; /* default: window.cursorNone */
+ Colormap colormap; /* default: same as parent */
+ Mask dontPropagateMask; /* default: window.dontPropagate */
+ Mask otherEventMasks; /* default: 0 */
+ struct _OtherClients *otherClients; /* default: NULL */
+ struct _GrabRec *passiveGrabs; /* default: NULL */
+ PropertyPtr userProps; /* default: NULL */
+ unsigned long backingBitPlanes; /* default: ~0L */
+ unsigned long backingPixel; /* default: 0 */
+#ifdef SHAPE
+ RegionPtr boundingShape; /* default: NULL */
+ RegionPtr clipShape; /* default: NULL */
+ RegionPtr inputShape; /* default: NULL */
+#endif
+#ifdef XINPUT
+ struct _OtherInputMasks *inputMasks; /* default: NULL */
+#endif
+} WindowOptRec, *WindowOptPtr;
+
+#define BackgroundPixel 2L
+#define BackgroundPixmap 3L
+
+typedef struct _Window {
+ DrawableRec drawable;
+ WindowPtr parent; /* ancestor chain */
+ WindowPtr nextSib; /* next lower sibling */
+ WindowPtr prevSib; /* next higher sibling */
+ WindowPtr firstChild; /* top-most child */
+ WindowPtr lastChild; /* bottom-most child */
+ RegionRec clipList; /* clipping rectangle for output */
+ RegionRec borderClip; /* NotClippedByChildren + border */
+ union _Validate *valdata;
+ RegionRec winSize;
+ RegionRec borderSize;
+ DDXPointRec origin; /* position relative to parent */
+ unsigned short borderWidth;
+ unsigned short deliverableEvents;
+ Mask eventMask;
+ PixUnion background;
+ PixUnion border;
+ pointer backStorage; /* null when BS disabled */
+ WindowOptPtr optional;
+ unsigned backgroundState:2; /* None, Relative, Pixel, Pixmap */
+ unsigned borderIsPixel:1;
+ unsigned cursorIsNone:1; /* else real cursor (might inherit) */
+ unsigned backingStore:2;
+ unsigned saveUnder:1;
+ unsigned DIXsaveUnder:1;
+ unsigned bitGravity:4;
+ unsigned winGravity:4;
+ unsigned overrideRedirect:1;
+ unsigned visibility:2;
+ unsigned mapped:1;
+ unsigned realized:1; /* ancestors are all mapped */
+ unsigned viewable:1; /* realized && InputOutput */
+ unsigned dontPropagate:3;/* index into DontPropagateMasks */
+ unsigned forcedBS:1; /* system-supplied backingStore */
+#ifdef NEED_DBE_BUF_BITS
+#define DBE_FRONT_BUFFER 1
+#define DBE_BACK_BUFFER 0
+ unsigned dstBuffer:1; /* destination buffer for rendering */
+ unsigned srcBuffer:1; /* source buffer for rendering */
+#endif
+#ifdef COMPOSITE
+ unsigned redirectDraw:1; /* rendering is redirected from here */
+#endif
+ DevUnion *devPrivates;
+} WindowRec;
+
+/*
+ * Ok, a bunch of macros for accessing the optional record
+ * fields (or filling the appropriate default value)
+ */
+
+extern Mask DontPropagateMasks[];
+
+#define wTrackParent(w,field) ((w)->optional ? \
+ (w)->optional->field \
+ : FindWindowWithOptional(w)->optional->field)
+#define wUseDefault(w,field,def) ((w)->optional ? \
+ (w)->optional->field \
+ : def)
+
+#define wVisual(w) wTrackParent(w, visual)
+#define wCursor(w) ((w)->cursorIsNone ? None : wTrackParent(w, cursor))
+#define wColormap(w) ((w)->drawable.class == InputOnly ? None : wTrackParent(w, colormap))
+#define wDontPropagateMask(w) wUseDefault(w, dontPropagateMask, DontPropagateMasks[(w)->dontPropagate])
+#define wOtherEventMasks(w) wUseDefault(w, otherEventMasks, 0)
+#define wOtherClients(w) wUseDefault(w, otherClients, NULL)
+#ifdef XINPUT
+#define wOtherInputMasks(w) wUseDefault(w, inputMasks, NULL)
+#else
+#define wOtherInputMasks(w) NULL
+#endif
+#define wPassiveGrabs(w) wUseDefault(w, passiveGrabs, NULL)
+#define wUserProps(w) wUseDefault(w, userProps, NULL)
+#define wBackingBitPlanes(w) wUseDefault(w, backingBitPlanes, ~0L)
+#define wBackingPixel(w) wUseDefault(w, backingPixel, 0)
+#ifdef SHAPE
+#define wBoundingShape(w) wUseDefault(w, boundingShape, NULL)
+#define wClipShape(w) wUseDefault(w, clipShape, NULL)
+#define wInputShape(w) wUseDefault(w, inputShape, NULL)
+#endif
+#define wClient(w) (clients[CLIENT_ID((w)->drawable.id)])
+#define wBorderWidth(w) ((int) (w)->borderWidth)
+
+/* true when w needs a border drawn. */
+
+#ifdef SHAPE
+#define HasBorder(w) ((w)->borderWidth || wClipShape(w))
+#else
+#define HasBorder(w) ((w)->borderWidth)
+#endif
+
+typedef struct _ScreenSaverStuff {
+ WindowPtr pWindow;
+ XID wid;
+ char blanked;
+ Bool (*ExternalScreenSaver)(
+ ScreenPtr /*pScreen*/,
+ int /*xstate*/,
+ Bool /*force*/);
+} ScreenSaverStuffRec, *ScreenSaverStuffPtr;
+
+#define SCREEN_IS_BLANKED 0
+#define SCREEN_ISNT_SAVED 1
+#define SCREEN_IS_TILED 2
+#define SCREEN_IS_BLACK 3
+
+#define HasSaverWindow(i) (savedScreenInfo[i].pWindow != NullWindow)
+
+extern int screenIsSaved;
+extern ScreenSaverStuffRec savedScreenInfo[MAXSCREENS];
+
+/*
+ * this is the configuration parameter "NO_BACK_SAVE"
+ * it means that any existant backing store should not
+ * be used to implement save unders.
+ */
+
+#ifndef NO_BACK_SAVE
+#define DO_SAVE_UNDERS(pWin) ((pWin)->drawable.pScreen->saveUnderSupport ==\
+ USE_DIX_SAVE_UNDERS)
+/*
+ * saveUnderSupport is set to this magic value when using DIXsaveUnders
+ */
+
+#define USE_DIX_SAVE_UNDERS 0x40
+#endif
+
+extern int numSaveUndersViewable;
+extern int deltaSaveUndersViewable;
+
+#ifdef XEVIE
+extern WindowPtr xeviewin;
+#endif
+
+#endif /* WINDOWSTRUCT_H */
diff --git a/nx-X11/programs/Xserver/iplan2p2/Imakefile b/nx-X11/programs/Xserver/iplan2p2/Imakefile
new file mode 100644
index 000000000..503bccaca
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p2/Imakefile
@@ -0,0 +1,6 @@
+XCOMM $XFree86$
+XCOMM $XConsortium: Imakefile,v 1.1 91/12/28 13:32:27 rws Exp $
+#define IPlanes 2
+#define LinkDirectory ../iplan2p4
+
+#include "../iplan2p4/Imakefile"
diff --git a/nx-X11/programs/Xserver/iplan2p4/Imakefile b/nx-X11/programs/Xserver/iplan2p4/Imakefile
new file mode 100644
index 000000000..3a3526156
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/Imakefile
@@ -0,0 +1,119 @@
+XCOMM $XFree86: xc/programs/Xserver/iplan2p4/Imakefile,v 3.4 1999/04/17 09:08:48 dawes Exp $
+XCOMM $XConsortium: Imakefile,v 5.41 93/09/06 18:37:23 rws Exp $
+#include <Server.tmpl>
+
+#ifndef IPlanes
+#define IPlanes 4
+#endif
+
+SRCS = iplgc.c iplrrop.c iplwindow.c \
+ iplpntwin.c iplmskbits.c iplpixmap.c iplbitblt.c \
+ iplfillsp.c iplsetsp.c iplscrinit.c iplallpriv.c \
+ iplgetsp.c iplfillrct.c \
+ iplsolidC.c iplsolidX.c iplsolidG.c \
+ ipltileoddC.c ipltileoddG.c ipltile32C.c ipltile32G.c \
+ iplcmap.c \
+ iplfillarcC.c iplfillarcG.c \
+ ipltegblt.c iplbstore.c \
+ iplpolypnt.c \
+ iplbres.c iplline.c iplhrzvert.c iplbresd.c iplimage.c iplseg.c \
+ iplbitblt.c iplbltC.c iplbltX.c iplbltO.c iplbltG.c \
+ iplply1rctC.c iplply1rctG.c iplpack.c
+
+OBJS = iplgc.o iplrrop.o iplwindow.o \
+ iplgetsp.o iplfillrct.o \
+ iplsolidC.o iplsolidX.o iplsolidG.o \
+ ipltileoddC.o ipltileoddG.o ipltile32C.o ipltile32G.o \
+ iplfillsp.o iplsetsp.o iplscrinit.o iplallpriv.o \
+ iplpntwin.o iplmskbits.o iplpixmap.o \
+ iplcmap.o \
+ iplfillarcC.o iplfillarcG.o \
+ ipltegblt.o iplbstore.o \
+ iplpolypnt.o \
+ iplbres.o iplline.o iplhrzvert.o iplbresd.o iplimage.o iplseg.o \
+ iplbitblt.o iplbltC.o iplbltX.o iplbltO.o iplbltG.o \
+ iplply1rctC.o iplply1rctG.o iplpack.o
+
+ INCLUDES = -I. -I../cfb -I../mfb -I../mi -I../include -I$(XINCLUDESRC) \
+ -I$(FONTINCSRC) $(EXTRAINCLUDES)
+ LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln \
+ ../mfb/llib-lmfb.ln ../mi/llib-lmi.ln
+ DEFINES = -DINTER_PLANES=IPlanes
+
+NormalLibraryObjectRule()
+#if IPlanes == 2
+NormalLibraryTarget(ipl2p2,$(OBJS))
+LintLibraryTarget(ipl2p2,$(SRCS))
+#elif IPlanes == 4
+NormalLibraryTarget(ipl2p4,$(OBJS))
+LintLibraryTarget(ipl2p4,$(SRCS))
+#elif IPlanes == 8
+NormalLibraryTarget(ipl2p8,$(OBJS))
+LintLibraryTarget(ipl2p8,$(SRCS))
+#endif
+
+NormalLintTarget($(SRCS))
+
+#ifdef LinkDirectory
+
+LinkSourceFile(ipl.h,LinkDirectory)
+LinkSourceFile(iplallpriv.c,LinkDirectory)
+LinkSourceFile(iplbitblt.c,LinkDirectory)
+LinkSourceFile(iplblt.c,LinkDirectory)
+LinkSourceFile(iplbres.c,LinkDirectory)
+LinkSourceFile(iplbresd.c,LinkDirectory)
+LinkSourceFile(iplbstore.c,LinkDirectory)
+LinkSourceFile(iplcmap.c,LinkDirectory)
+LinkSourceFile(iplfillarc.c,LinkDirectory)
+LinkSourceFile(iplfillrct.c,LinkDirectory)
+LinkSourceFile(iplfillsp.c,LinkDirectory)
+LinkSourceFile(iplgc.c,LinkDirectory)
+LinkSourceFile(iplgetsp.c,LinkDirectory)
+LinkSourceFile(iplhrzvert.c,LinkDirectory)
+LinkSourceFile(iplimage.c,LinkDirectory)
+LinkSourceFile(iplline.c,LinkDirectory)
+LinkSourceFile(iplmap.h,LinkDirectory)
+LinkSourceFile(iplmergerop.h,LinkDirectory)
+LinkSourceFile(iplmskbits.c,LinkDirectory)
+LinkSourceFile(iplmskbits.h,LinkDirectory)
+LinkSourceFile(iplpack.c,LinkDirectory)
+LinkSourceFile(iplpack.h,LinkDirectory)
+LinkSourceFile(iplpixmap.c,LinkDirectory)
+LinkSourceFile(iplply1rct.c,LinkDirectory)
+LinkSourceFile(iplpntwin.c,LinkDirectory)
+LinkSourceFile(iplpolypnt.c,LinkDirectory)
+LinkSourceFile(iplrrop.c,LinkDirectory)
+LinkSourceFile(iplrrop.h,LinkDirectory)
+LinkSourceFile(iplscrinit.c,LinkDirectory)
+LinkSourceFile(iplsetsp.c,LinkDirectory)
+LinkSourceFile(iplsolid.c,LinkDirectory)
+LinkSourceFile(ipltegblt.c,LinkDirectory)
+LinkSourceFile(ipltile32.c,LinkDirectory)
+LinkSourceFile(ipltileodd.c,LinkDirectory)
+LinkSourceFile(iplwindow.c,LinkDirectory)
+#endif
+
+ObjectFromSpecialSource(iplseg,iplline,-DPOLYSEGMENT)
+
+ObjectFromSpecialSource(iplfillarcC,iplfillarc,-DRROP=GXcopy)
+ObjectFromSpecialSource(iplfillarcG,iplfillarc,-DRROP=GXset)
+
+ObjectFromSpecialSource(iplbltC,iplblt,-DMROP=Mcopy)
+ObjectFromSpecialSource(iplbltX,iplblt,-DMROP=Mxor)
+ObjectFromSpecialSource(iplbltO,iplblt,-DMROP=Mor)
+ObjectFromSpecialSource(iplbltG,iplblt,-DMROP=0)
+
+ObjectFromSpecialSource(iplsolidC,iplsolid,-DRROP=GXcopy)
+ObjectFromSpecialSource(iplsolidX,iplsolid,-DRROP=GXxor)
+ObjectFromSpecialSource(iplsolidG,iplsolid,-DRROP=GXset)
+
+ObjectFromSpecialSource(ipltileoddC,ipltileodd,-DMROP=Mcopy)
+ObjectFromSpecialSource(ipltileoddG,ipltileodd,-DMROP=0)
+
+ObjectFromSpecialSource(ipltile32C,ipltile32,-DMROP=Mcopy)
+ObjectFromSpecialSource(ipltile32G,ipltile32,-DMROP=0)
+
+ObjectFromSpecialSource(iplply1rctC,iplply1rct,-DRROP=GXcopy)
+ObjectFromSpecialSource(iplply1rctG,iplply1rct,-DRROP=GXset)
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/iplan2p4/ipl.h b/nx-X11/programs/Xserver/iplan2p4/ipl.h
new file mode 100644
index 000000000..356e43367
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/ipl.h
@@ -0,0 +1,1254 @@
+/* $XFree86: xc/programs/Xserver/iplan2p4/ipl.h,v 3.5 2001/01/30 22:06:21 tsi Exp $ */
+/* $XConsortium: ipl.h,v 5.37 94/04/17 20:28:38 dpw Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "pixmap.h"
+#include "region.h"
+#include "gc.h"
+#include "colormap.h"
+#include "miscstruct.h"
+#include "servermd.h"
+#include "windowstr.h"
+#include "mfb.h"
+#undef PixelType
+
+#include "iplmap.h"
+
+/*
+ private filed of pixmap
+ pixmap.devPrivate = (unsigned int *)pointer_to_bits
+ pixmap.devKind = width_of_pixmap_in_bytes
+*/
+
+extern int iplGCPrivateIndex;
+extern int iplWindowPrivateIndex;
+
+/* private field of GC */
+typedef struct {
+ unsigned char rop; /* special case rop values */
+ /* next two values unused in ipl, included for compatibility with mfb */
+ unsigned char ropOpStip; /* rop for opaque stipple */
+ /* this value is ropFillArea in mfb, usurped for ipl */
+ unsigned char oneRect; /* drawable has one clip rect */
+ unsigned long xor, and; /* reduced rop values */
+ unsigned short xorg[INTER_PLANES],andg[INTER_PLANES];
+ } iplPrivGC;
+
+typedef iplPrivGC *iplPrivGCPtr;
+
+#define iplGetGCPrivate(pGC) ((iplPrivGCPtr)\
+ (pGC)->devPrivates[iplGCPrivateIndex].ptr)
+
+#define iplGetCompositeClip(pGC) ((pGC)->pCompositeClip)
+
+/* way to carry RROP info around */
+typedef struct {
+ unsigned char rop;
+ unsigned long xor, and;
+ unsigned short xorg[INTER_PLANES],andg[INTER_PLANES];
+} iplRRopRec, *iplRRopPtr;
+
+/* private field of window */
+typedef struct {
+ unsigned char fastBorder; /* non-zero if border is 32 bits wide */
+ unsigned char fastBackground;
+ unsigned short unused; /* pad for alignment with Sun compiler */
+ DDXPointRec oldRotate;
+ PixmapPtr pRotatedBackground;
+ PixmapPtr pRotatedBorder;
+ } iplPrivWin;
+
+#define iplGetWindowPrivate(_pWin) ((iplPrivWin *)\
+ (_pWin)->devPrivates[iplWindowPrivateIndex].ptr)
+
+
+/* ipl8bit.c */
+
+extern int iplSetStipple(
+ int /*alu*/,
+ unsigned long /*fg*/,
+ unsigned long /*planemask*/
+);
+
+extern int iplSetOpaqueStipple(
+ int /*alu*/,
+ unsigned long /*fg*/,
+ unsigned long /*bg*/,
+ unsigned long /*planemask*/
+);
+
+extern int iplComputeClipMasks32(
+ BoxPtr /*pBox*/,
+ int /*numRects*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ CARD32 * /*clips*/
+);
+/* ipl8cppl.c */
+
+extern void iplCopyImagePlane(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ int /*rop*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+
+extern void iplCopyPlane8to1(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ int /*rop*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/,
+ unsigned long /*bitPlane*/
+);
+/* ipl8lineCO.c */
+
+extern int ipl8LineSS1RectCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/,
+ DDXPointPtr /*pptInitOrig*/,
+ int * /*x1p*/,
+ int * /*y1p*/,
+ int * /*x2p*/,
+ int * /*y2p*/
+);
+
+extern void ipl8LineSS1Rect(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/
+);
+
+extern void ipl8ClippedLineCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*x2*/,
+ int /*y2*/,
+ BoxPtr /*boxp*/,
+ Bool /*shorten*/
+);
+/* ipl8lineCP.c */
+
+extern int ipl8LineSS1RectPreviousCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/,
+ DDXPointPtr /*pptInitOrig*/,
+ int * /*x1p*/,
+ int * /*y1p*/,
+ int * /*x2p*/,
+ int * /*y2p*/
+);
+/* ipl8lineG.c */
+
+extern int ipl8LineSS1RectGeneral(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/,
+ DDXPointPtr /*pptInitOrig*/,
+ int * /*x1p*/,
+ int * /*y1p*/,
+ int * /*x2p*/,
+ int * /*y2p*/
+);
+
+extern void ipl8ClippedLineGeneral(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*x2*/,
+ int /*y2*/,
+ BoxPtr /*boxp*/,
+ Bool /*shorten*/
+);
+/* ipl8lineX.c */
+
+extern int ipl8LineSS1RectXor(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/,
+ DDXPointPtr /*pptInitOrig*/,
+ int * /*x1p*/,
+ int * /*y1p*/,
+ int * /*x2p*/,
+ int * /*y2p*/
+);
+
+extern void ipl8ClippedLineXor(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*x2*/,
+ int /*y2*/,
+ BoxPtr /*boxp*/,
+ Bool /*shorten*/
+);
+/* ipl8segC.c */
+
+extern int ipl8SegmentSS1RectCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSegInit*/
+);
+/* ipl8segCS.c */
+
+extern int ipl8SegmentSS1RectShiftCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSegInit*/
+);
+
+extern void ipl8SegmentSS1Rect(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSegInit*/
+);
+/* ipl8segG.c */
+
+extern int ipl8SegmentSS1RectGeneral(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSegInit*/
+);
+/* iplsegX.c */
+
+extern int ipl8SegmentSS1RectXor(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSegInit*/
+);
+/* iplallpriv.c */
+
+extern Bool iplAllocatePrivates(
+ ScreenPtr /*pScreen*/,
+ int * /*window_index*/,
+ int * /*gc_index*/
+);
+/* iplbitblt.c */
+
+extern RegionPtr iplBitBlt(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr/*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ void (* /*doBitBlt*/)(),
+ unsigned long /*bitPlane*/
+);
+
+extern void iplDoBitblt(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+
+extern RegionPtr iplCopyArea(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr/*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/
+);
+
+extern void iplCopyPlane1to8(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ int /*rop*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/,
+ unsigned long /*bitPlane*/
+);
+
+extern RegionPtr iplCopyPlane(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr /*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ unsigned long /*bitPlane*/
+);
+/* iplbltC.c */
+
+extern void iplDoBitbltCopy(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* iplbltG.c */
+
+extern void iplDoBitbltGeneral(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* iplbltO.c */
+
+extern void iplDoBitbltOr(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* iplbltX.c */
+
+extern void iplDoBitbltXor(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/,
+ unsigned long /*planemask*/
+);
+/* iplbres.c */
+
+extern void iplBresS(
+ int /*rop*/,
+ unsigned short * /*and*/,
+ unsigned short * /*xor*/,
+ unsigned short * /*addrl*/,
+ int /*nlwidth*/,
+ int /*signdx*/,
+ int /*signdy*/,
+ int /*axis*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*e*/,
+ int /*e1*/,
+ int /*e2*/,
+ int /*len*/
+);
+/* iplbresd.c */
+
+extern void iplBresD(
+ iplRRopPtr /*rrops*/,
+ int * /*pdashIndex*/,
+ unsigned char * /*pDash*/,
+ int /*numInDashList*/,
+ int * /*pdashOffset*/,
+ int /*isDoubleDash*/,
+ unsigned short * /*addrl*/,
+ int /*nlwidth*/,
+ int /*signdx*/,
+ int /*signdy*/,
+ int /*axis*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*e*/,
+ int /*e1*/,
+ int /*e2*/,
+ int /*len*/
+);
+/* iplbstore.c */
+
+extern void iplSaveAreas(
+ PixmapPtr /*pPixmap*/,
+ RegionPtr /*prgnSave*/,
+ int /*xorg*/,
+ int /*yorg*/,
+ WindowPtr /*pWin*/
+);
+
+extern void iplRestoreAreas(
+ PixmapPtr /*pPixmap*/,
+ RegionPtr /*prgnRestore*/,
+ int /*xorg*/,
+ int /*yorg*/,
+ WindowPtr /*pWin*/
+);
+/* iplcmap.c */
+
+extern int iplListInstalledColormaps(
+ ScreenPtr /*pScreen*/,
+ Colormap * /*pmaps*/
+);
+
+extern void iplInstallColormap(
+ ColormapPtr /*pmap*/
+);
+
+extern void iplUninstallColormap(
+ ColormapPtr /*pmap*/
+);
+
+extern void iplResolveColor(
+ unsigned short * /*pred*/,
+ unsigned short * /*pgreen*/,
+ unsigned short * /*pblue*/,
+ VisualPtr /*pVisual*/
+);
+
+extern Bool iplInitializeColormap(
+ ColormapPtr /*pmap*/
+);
+
+extern int iplExpandDirectColors(
+ ColormapPtr /*pmap*/,
+ int /*ndef*/,
+ xColorItem * /*indefs*/,
+ xColorItem * /*outdefs*/
+);
+
+extern Bool iplCreateDefColormap(
+ ScreenPtr /*pScreen*/
+);
+
+extern Bool iplSetVisualTypes(
+ int /*depth*/,
+ int /*visuals*/,
+ int /*bitsPerRGB*/
+);
+
+extern Bool iplInitVisuals(
+ VisualPtr * /*visualp*/,
+ DepthPtr * /*depthp*/,
+ int * /*nvisualp*/,
+ int * /*ndepthp*/,
+ int * /*rootDepthp*/,
+ VisualID * /*defaultVisp*/,
+ unsigned long /*sizes*/,
+ int /*bitsPerRGB*/
+);
+/* iplfillarcC.c */
+
+extern void iplPolyFillArcSolidCopy(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+/* iplfillarcG.c */
+
+extern void iplPolyFillArcSolidGeneral(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+/* iplfillrct.c */
+
+extern void iplFillBoxTileOdd(
+ DrawablePtr /*pDrawable*/,
+ int /*n*/,
+ BoxPtr /*rects*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/
+);
+
+extern void iplFillRectTileOdd(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+
+extern void iplPolyFillRect(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nrectFill*/,
+ xRectangle * /*prectInit*/
+);
+/* iplfillsp.c */
+
+extern void iplUnnaturalTileFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void iplUnnaturalStippleFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void ipl8Stipple32FS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void ipl8OpaqueStipple32FS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+/* iplgc.c */
+
+extern GCOpsPtr iplMatchCommon(
+ GCPtr /*pGC*/,
+ iplPrivGCPtr /*devPriv*/
+);
+
+extern Bool iplCreateGC(
+ GCPtr /*pGC*/
+);
+
+extern void iplValidateGC(
+ GCPtr /*pGC*/,
+ unsigned long /*changes*/,
+ DrawablePtr /*pDrawable*/
+);
+
+/* iplgetsp.c */
+
+extern void iplGetSpans(
+ DrawablePtr /*pDrawable*/,
+ int /*wMax*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ int /*nspans*/,
+ char * /*pdstStart*/
+);
+/* iplglblt8.c */
+
+extern void iplPolyGlyphBlt8(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* iplglrop8.c */
+
+extern void iplPolyGlyphRop8(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* iplhrzvert.c */
+
+extern int iplHorzS(
+ int /*rop*/,
+ unsigned short * /*and*/,
+ unsigned short * /*xor*/,
+ unsigned short * /*addrg*/,
+ int /*nlwidth*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*len*/
+);
+
+extern int iplVertS(
+ int /*rop*/,
+ unsigned short * /*and*/,
+ unsigned short * /*xor*/,
+ unsigned short * /*addrg*/,
+ int /*nlwidth*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*len*/
+);
+/* ipligblt8.c */
+
+extern void iplImageGlyphBlt8(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* iplimage.c */
+
+extern void iplPutImage(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*depth*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ int /*leftPad*/,
+ int /*format*/,
+ char * /*pImage*/
+);
+
+extern void iplGetImage(
+ DrawablePtr /*pDrawable*/,
+ int /*sx*/,
+ int /*sy*/,
+ int /*w*/,
+ int /*h*/,
+ unsigned int /*format*/,
+ unsigned long /*planeMask*/,
+ char * /*pdstLine*/
+);
+/* iplline.c */
+
+extern void iplLineSS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/
+);
+
+extern void iplLineSD(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/
+);
+/* iplmskbits.c */
+/* iplpixmap.c */
+
+extern PixmapPtr iplCreatePixmap(
+ ScreenPtr /*pScreen*/,
+ int /*width*/,
+ int /*height*/,
+ int /*depth*/
+);
+
+extern Bool iplDestroyPixmap(
+ PixmapPtr /*pPixmap*/
+);
+
+extern PixmapPtr iplCopyPixmap(
+ PixmapPtr /*pSrc*/
+);
+
+extern void iplPadPixmap(
+ PixmapPtr /*pPixmap*/
+);
+
+extern void iplXRotatePixmap(
+ PixmapPtr /*pPix*/,
+ int /*rw*/
+);
+
+extern void iplYRotatePixmap(
+ PixmapPtr /*pPix*/,
+ int /*rh*/
+);
+
+extern void iplCopyRotatePixmap(
+ PixmapPtr /*psrcPix*/,
+ PixmapPtr * /*ppdstPix*/,
+ int /*xrot*/,
+ int /*yrot*/
+);
+/* iplply1rctC.c */
+
+extern void iplFillPoly1RectCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*shape*/,
+ int /*mode*/,
+ int /*count*/,
+ DDXPointPtr /*ptsIn*/
+);
+/* iplply1rctG.c */
+
+extern void iplFillPoly1RectGeneral(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*shape*/,
+ int /*mode*/,
+ int /*count*/,
+ DDXPointPtr /*ptsIn*/
+);
+/* iplpntwin.c */
+
+extern void iplPaintWindow(
+ WindowPtr /*pWin*/,
+ RegionPtr /*pRegion*/,
+ int /*what*/
+);
+
+extern void iplFillBoxSolid(
+ DrawablePtr /*pDrawable*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/,
+ unsigned long /*pixel*/
+);
+
+extern void iplFillBoxTile32(
+ DrawablePtr /*pDrawable*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/,
+ PixmapPtr /*tile*/
+);
+/* iplpolypnt.c */
+
+extern void iplPolyPoint(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ xPoint * /*pptInit*/
+);
+/* iplpush8.c */
+
+extern void iplPushPixels8(
+ GCPtr /*pGC*/,
+ PixmapPtr /*pBitmap*/,
+ DrawablePtr /*pDrawable*/,
+ int /*dx*/,
+ int /*dy*/,
+ int /*xOrg*/,
+ int /*yOrg*/
+);
+/* iplrctstp8.c */
+
+extern void ipl8FillRectOpaqueStippled32(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+
+extern void ipl8FillRectTransparentStippled32(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+
+extern void ipl8FillRectStippledUnnatural(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+/* iplrrop.c */
+
+extern int iplReduceRasterOp(
+ int /*rop*/,
+ unsigned long /*fg*/,
+ unsigned long /*pm*/,
+ unsigned short * /*andp*/,
+ unsigned short * /*xorp*/
+);
+/* iplscrinit.c */
+
+extern Bool iplCloseScreen(
+ int /*index*/,
+ ScreenPtr /*pScreen*/
+);
+
+extern Bool iplSetupScreen(
+ ScreenPtr /*pScreen*/,
+ pointer /*pbits*/,
+ int /*xsize*/,
+ int /*ysize*/,
+ int /*dpix*/,
+ int /*dpiy*/,
+ int /*width*/
+);
+
+extern int iplFinishScreenInit(
+ ScreenPtr /*pScreen*/,
+ pointer /*pbits*/,
+ int /*xsize*/,
+ int /*ysize*/,
+ int /*dpix*/,
+ int /*dpiy*/,
+ int /*width*/
+);
+
+extern Bool iplScreenInit(
+ ScreenPtr /*pScreen*/,
+ pointer /*pbits*/,
+ int /*xsize*/,
+ int /*ysize*/,
+ int /*dpix*/,
+ int /*dpiy*/,
+ int /*width*/
+);
+
+extern PixmapPtr iplGetScreenPixmap(
+ ScreenPtr /*pScreen*/
+);
+
+extern void iplSetScreenPixmap(
+ PixmapPtr /*pPix*/
+);
+
+/* iplseg.c */
+
+extern void iplSegmentSS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSeg*/
+);
+
+extern void iplSegmentSD(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSeg*/
+);
+/* iplsetsp.c */
+
+extern int iplSetScanline(
+ int /*y*/,
+ int /*xOrigin*/,
+ int /*xStart*/,
+ int /*xEnd*/,
+ unsigned int * /*psrc*/,
+ int /*alu*/,
+ unsigned short * /*pdstBase*/,
+ int /*widthDst*/,
+ unsigned long /*planemask*/
+);
+
+extern void iplSetSpans(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ char * /*psrc*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ int /*nspans*/,
+ int /*fSorted*/
+);
+/* iplsolidC.c */
+
+extern void iplFillRectSolidCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+
+extern void iplSolidSpansCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+/* iplsolidG.c */
+
+extern void iplFillRectSolidGeneral(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+
+extern void iplSolidSpansGeneral(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+/* iplsolidX.c */
+
+extern void iplFillRectSolidXor(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+
+extern void iplSolidSpansXor(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+/* iplteblt8.c */
+
+extern void iplTEGlyphBlt8(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*xInit*/,
+ int /*yInit*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* ipltegblt.c */
+
+extern void iplTEGlyphBlt(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* ipltile32C.c */
+
+extern void iplFillRectTile32Copy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+
+extern void iplTile32FSCopy(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+/* ipltile32G.c */
+
+extern void iplFillRectTile32General(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/
+);
+
+extern void iplTile32FSGeneral(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+/* ipltileoddC.c */
+
+extern void iplFillBoxTileOddCopy(
+ DrawablePtr /*pDrawable*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/,
+ int /*alu*/,
+ unsigned long /*planemask*/
+);
+
+extern void iplFillSpanTileOddCopy(
+ DrawablePtr /*pDrawable*/,
+ int /*n*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/,
+ int /*alu*/,
+ unsigned long /*planemask*/
+);
+
+extern void iplFillBoxTile32sCopy(
+ DrawablePtr /*pDrawable*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/,
+ int /*alu*/,
+ unsigned long /*planemask*/
+);
+
+extern void iplFillSpanTile32sCopy(
+ DrawablePtr /*pDrawable*/,
+ int /*n*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/,
+ int /*alu*/,
+ unsigned long /*planemask*/
+);
+/* ipltileoddG.c */
+
+extern void iplFillBoxTileOddGeneral(
+ DrawablePtr /*pDrawable*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/,
+ int /*alu*/,
+ unsigned long /*planemask*/
+);
+
+extern void iplFillSpanTileOddGeneral(
+ DrawablePtr /*pDrawable*/,
+ int /*n*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/,
+ int /*alu*/,
+ unsigned long /*planemask*/
+);
+
+extern void iplFillBoxTile32sGeneral(
+ DrawablePtr /*pDrawable*/,
+ int /*nBox*/,
+ BoxPtr /*pBox*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/,
+ int /*alu*/,
+ unsigned long /*planemask*/
+);
+
+extern void iplFillSpanTile32sGeneral(
+ DrawablePtr /*pDrawable*/,
+ int /*n*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ PixmapPtr /*tile*/,
+ int /*xrot*/,
+ int /*yrot*/,
+ int /*alu*/,
+ unsigned long /*planemask*/
+);
+/* iplwindow.c */
+
+extern Bool iplCreateWindow(
+ WindowPtr /*pWin*/
+);
+
+extern Bool iplDestroyWindow(
+ WindowPtr /*pWin*/
+);
+
+extern Bool iplMapWindow(
+ WindowPtr /*pWindow*/
+);
+
+extern Bool iplPositionWindow(
+ WindowPtr /*pWin*/,
+ int /*x*/,
+ int /*y*/
+);
+
+extern Bool iplUnmapWindow(
+ WindowPtr /*pWindow*/
+);
+
+extern void iplCopyWindow(
+ WindowPtr /*pWin*/,
+ DDXPointRec /*ptOldOrg*/,
+ RegionPtr /*prgnSrc*/
+);
+
+extern Bool iplChangeWindowAttributes(
+ WindowPtr /*pWin*/,
+ unsigned long /*mask*/
+);
+/* iplzerarcC.c */
+
+extern void iplZeroPolyArcSS8Copy(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+/* iplzerarcG.c */
+
+extern void iplZeroPolyArcSS8General(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+/* iplzerarcX.c */
+
+extern void iplZeroPolyArcSS8Xor(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+
+/* Common macros for extracting drawing information */
+
+#if (!defined(SINGLEDEPTH) && PSZ != 8) || defined(FORCE_SEPARATE_PRIVATE)
+
+#define CFB_NEED_SCREEN_PRIVATE
+
+extern int iplScreenPrivateIndex;
+#endif
+
+#define iplGetWindowPixmap(d) \
+ ((* ((DrawablePtr)(d))->pScreen->GetWindowPixmap)((WindowPtr)(d)))
+
+#define iplGetTypedWidth(pDrawable,wtype) (\
+ (((pDrawable)->type != DRAWABLE_PIXMAP) ? \
+ (int) (iplGetWindowPixmap(pDrawable)->devKind) : \
+ (int)(((PixmapPtr)pDrawable)->devKind)) / sizeof (wtype))
+
+#define iplGetByteWidth(pDrawable) iplGetTypedWidth(pDrawable, unsigned char)
+
+#define iplGetPixelWidth(pDrawable) iplGetTypedWidth(pDrawable, PixelType)
+
+#define iplGetLongWidth(pDrawable) iplGetTypedWidth(pDrawable, unsigned long)
+
+#define iplGetTypedWidthAndPointer(pDrawable, width, pointer, wtype, ptype) {\
+ PixmapPtr _pPix; \
+ if ((pDrawable)->type != DRAWABLE_PIXMAP) \
+ _pPix = iplGetWindowPixmap(pDrawable); \
+ else \
+ _pPix = (PixmapPtr) (pDrawable); \
+ (pointer) = (ptype *) _pPix->devPrivate.ptr; \
+ (width) = ((int) _pPix->devKind) / sizeof (wtype); \
+}
+
+#define iplGetByteWidthAndPointer(pDrawable, width, pointer) \
+ iplGetTypedWidthAndPointer(pDrawable, width, pointer, unsigned char, unsigned char)
+
+#define iplGetLongWidthAndPointer(pDrawable, width, pointer) \
+ iplGetTypedWidthAndPointer(pDrawable, width, pointer, unsigned long, unsigned long)
+
+#define iplGetPixelWidthAndPointer(pDrawable, width, pointer) \
+ iplGetTypedWidthAndPointer(pDrawable, width, pointer, PixelType, PixelType)
+
+#define iplGetWindowTypedWidthAndPointer(pWin, width, pointer, wtype, ptype) {\
+ PixmapPtr _pPix = iplGetWindowPixmap((DrawablePtr) (pWin)); \
+ (pointer) = (ptype *) _pPix->devPrivate.ptr; \
+ (width) = ((int) _pPix->devKind) / sizeof (wtype); \
+}
+
+#define iplGetWindowLongWidthAndPointer(pWin, width, pointer) \
+ iplGetWindowTypedWidthAndPointer(pWin, width, pointer, unsigned long, unsigned long)
+
+#define iplGetWindowByteWidthAndPointer(pWin, width, pointer) \
+ iplGetWindowTypedWidthAndPointer(pWin, width, pointer, unsigned char, unsigned char)
+
+#define iplGetWindowPixelWidthAndPointer(pDrawable, width, pointer) \
+ iplGetWindowTypedWidthAndPointer(pDrawable, width, pointer, PixelType, PixelType)
+
+/* Macros which handle a coordinate in a single register */
+
+/* Most compilers will convert divide by 65536 into a shift, if signed
+ * shifts exist. If your machine does arithmetic shifts and your compiler
+ * can't get it right, add to this line.
+ */
+
+/* mips compiler - what a joke - it CSEs the 65536 constant into a reg
+ * forcing as to use div instead of shift. Let's be explicit.
+ */
+
+#if defined(mips) || defined(sparc) || defined(__alpha) || defined(__alpha__)
+#define GetHighWord(x) (((int) (x)) >> 16)
+#else
+#define GetHighWord(x) (((int) (x)) / 65536)
+#endif
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define intToCoord(i,x,y) (((x) = GetHighWord(i)), ((y) = (int) ((short) (i))))
+#define coordToInt(x,y) (((x) << 16) | (y))
+#define intToX(i) (GetHighWord(i))
+#define intToY(i) ((int) ((short) i))
+#else
+#define intToCoord(i,x,y) (((x) = (int) ((short) (i))), ((y) = GetHighWord(i)))
+#define coordToInt(x,y) (((y) << 16) | (x))
+#define intToX(i) ((int) ((short) (i)))
+#define intToY(i) (GetHighWord(i))
+#endif
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplallpriv.c b/nx-X11/programs/Xserver/iplan2p4/iplallpriv.c
new file mode 100644
index 000000000..23a13dbd1
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplallpriv.c
@@ -0,0 +1,93 @@
+/* $XFree86$ */
+/*
+ * $XConsortium: iplallpriv.c,v 1.5 94/04/17 20:28:42 dpw Exp $
+ *
+Copyright (c) 1991 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "resource.h"
+#include "colormap.h"
+#include "colormapst.h"
+#include "ipl.h"
+#include "mi.h"
+#include "mistruct.h"
+#include "dix.h"
+#include "mibstore.h"
+
+int iplWindowPrivateIndex;
+int iplGCPrivateIndex;
+#ifdef CFB_NEED_SCREEN_PRIVATE
+int iplScreenPrivateIndex;
+#endif
+
+extern RegionPtr (*iplPuntCopyPlane)();
+
+Bool
+iplAllocatePrivates(pScreen, window_index, gc_index)
+ ScreenPtr pScreen;
+ int *window_index, *gc_index;
+{
+ if (!window_index || !gc_index ||
+ *window_index == -1 && *gc_index == -1)
+ {
+ if (!mfbAllocatePrivates(pScreen,
+ &iplWindowPrivateIndex, &iplGCPrivateIndex))
+ return FALSE;
+ if (window_index)
+ *window_index = iplWindowPrivateIndex;
+ if (gc_index)
+ *gc_index = iplGCPrivateIndex;
+ }
+ else
+ {
+ iplWindowPrivateIndex = *window_index;
+ iplGCPrivateIndex = *gc_index;
+ }
+ if (!AllocateWindowPrivate(pScreen, iplWindowPrivateIndex,
+ sizeof(iplPrivWin)) ||
+ !AllocateGCPrivate(pScreen, iplGCPrivateIndex, sizeof(iplPrivGC)))
+ return FALSE;
+
+ iplPuntCopyPlane = miCopyPlane;
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ iplScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ if (iplScreenPrivateIndex == -1)
+ return FALSE;
+#endif
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplbitblt.c b/nx-X11/programs/Xserver/iplan2p4/iplbitblt.c
new file mode 100644
index 000000000..4bf64437e
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplbitblt.c
@@ -0,0 +1,388 @@
+/* $XFree86: xc/programs/Xserver/iplan2p4/iplbitblt.c,v 3.1tsi Exp $ */
+/*
+ * ipl copy area
+ */
+
+/*
+
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+Author: Keith Packard
+
+*/
+/* $XConsortium: iplbitblt.c,v 5.51 94/05/27 11:00:56 dpw Exp $ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "ipl.h"
+#include "fastblt.h"
+#define MFB_CONSTS_ONLY
+#include "maskbits.h"
+
+#include "iplmskbits.h"
+
+RegionPtr
+iplBitBlt (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, doBitBlt, bitPlane)
+ register DrawablePtr pSrcDrawable;
+ register DrawablePtr pDstDrawable;
+ GC *pGC;
+ int srcx, srcy;
+ int width, height;
+ int dstx, dsty;
+ void (*doBitBlt)();
+ unsigned long bitPlane;
+{
+ RegionPtr prgnSrcClip; /* may be a new region, or just a copy */
+ Bool freeSrcClip = FALSE;
+
+ RegionPtr prgnExposed;
+ RegionRec rgnDst;
+ DDXPointPtr pptSrc;
+ register DDXPointPtr ppt;
+ register BoxPtr pbox;
+ int i;
+ register int dx;
+ register int dy;
+ xRectangle origSource;
+ DDXPointRec origDest;
+ int numRects;
+ BoxRec fastBox;
+ int fastClip = 0; /* for fast clipping with pixmap source */
+ int fastExpose = 0; /* for fast exposures with pixmap source */
+
+ origSource.x = srcx;
+ origSource.y = srcy;
+ origSource.width = width;
+ origSource.height = height;
+ origDest.x = dstx;
+ origDest.y = dsty;
+
+ if ((pSrcDrawable != pDstDrawable) &&
+ pSrcDrawable->pScreen->SourceValidate)
+ {
+ (*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, srcx, srcy, width, height);
+ }
+
+ srcx += pSrcDrawable->x;
+ srcy += pSrcDrawable->y;
+
+ /* clip the source */
+
+ if (pSrcDrawable->type == DRAWABLE_PIXMAP)
+ {
+ if ((pSrcDrawable == pDstDrawable) &&
+ (pGC->clientClipType == CT_NONE))
+ {
+ prgnSrcClip = iplGetCompositeClip(pGC);
+ }
+ else
+ {
+ fastClip = 1;
+ }
+ }
+ else
+ {
+ if (pGC->subWindowMode == IncludeInferiors)
+ {
+ if (!((WindowPtr) pSrcDrawable)->parent)
+ {
+ /*
+ * special case bitblt from root window in
+ * IncludeInferiors mode; just like from a pixmap
+ */
+ fastClip = 1;
+ }
+ else if ((pSrcDrawable == pDstDrawable) &&
+ (pGC->clientClipType == CT_NONE))
+ {
+ prgnSrcClip = iplGetCompositeClip(pGC);
+ }
+ else
+ {
+ prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable);
+ freeSrcClip = TRUE;
+ }
+ }
+ else
+ {
+ prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList;
+ }
+ }
+
+ fastBox.x1 = srcx;
+ fastBox.y1 = srcy;
+ fastBox.x2 = srcx + width;
+ fastBox.y2 = srcy + height;
+
+ /* Don't create a source region if we are doing a fast clip */
+ if (fastClip)
+ {
+ fastExpose = 1;
+ /*
+ * clip the source; if regions extend beyond the source size,
+ * make sure exposure events get sent
+ */
+ if (fastBox.x1 < pSrcDrawable->x)
+ {
+ fastBox.x1 = pSrcDrawable->x;
+ fastExpose = 0;
+ }
+ if (fastBox.y1 < pSrcDrawable->y)
+ {
+ fastBox.y1 = pSrcDrawable->y;
+ fastExpose = 0;
+ }
+ if (fastBox.x2 > pSrcDrawable->x + (int) pSrcDrawable->width)
+ {
+ fastBox.x2 = pSrcDrawable->x + (int) pSrcDrawable->width;
+ fastExpose = 0;
+ }
+ if (fastBox.y2 > pSrcDrawable->y + (int) pSrcDrawable->height)
+ {
+ fastBox.y2 = pSrcDrawable->y + (int) pSrcDrawable->height;
+ fastExpose = 0;
+ }
+ }
+ else
+ {
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip);
+ }
+
+ dstx += pDstDrawable->x;
+ dsty += pDstDrawable->y;
+
+ if (pDstDrawable->type == DRAWABLE_WINDOW)
+ {
+ if (!((WindowPtr)pDstDrawable)->realized)
+ {
+ if (!fastClip)
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return NULL;
+ }
+ }
+
+ dx = srcx - dstx;
+ dy = srcy - dsty;
+
+ /* Translate and clip the dst to the destination composite clip */
+ if (fastClip)
+ {
+ RegionPtr cclip;
+
+ /* Translate the region directly */
+ fastBox.x1 -= dx;
+ fastBox.x2 -= dx;
+ fastBox.y1 -= dy;
+ fastBox.y2 -= dy;
+
+ /* If the destination composite clip is one rectangle we can
+ do the clip directly. Otherwise we have to create a full
+ blown region and call intersect */
+
+ /* XXX because CopyPlane uses this routine for 8-to-1 bit
+ * copies, this next line *must* also correctly fetch the
+ * composite clip from an mfb gc
+ */
+
+ cclip = iplGetCompositeClip(pGC);
+ if (REGION_NUM_RECTS(cclip) == 1)
+ {
+ BoxPtr pBox = REGION_RECTS(cclip);
+
+ if (fastBox.x1 < pBox->x1) fastBox.x1 = pBox->x1;
+ if (fastBox.x2 > pBox->x2) fastBox.x2 = pBox->x2;
+ if (fastBox.y1 < pBox->y1) fastBox.y1 = pBox->y1;
+ if (fastBox.y2 > pBox->y2) fastBox.y2 = pBox->y2;
+
+ /* Check to see if the region is empty */
+ if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2)
+ {
+ REGION_NULL(pGC->pScreen, &rgnDst);
+ }
+ else
+ {
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ }
+ }
+ else
+ {
+ /* We must turn off fastClip now, since we must create
+ a full blown region. It is intersected with the
+ composite clip below. */
+ fastClip = 0;
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ }
+ }
+ else
+ {
+ REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy);
+ }
+
+ if (!fastClip)
+ {
+ REGION_INTERSECT(pGC->pScreen, &rgnDst,
+ &rgnDst,
+ iplGetCompositeClip(pGC));
+ }
+
+ /* Do bit blitting */
+ numRects = REGION_NUM_RECTS(&rgnDst);
+ if (numRects && width && height)
+ {
+ if(!(pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(numRects *
+ sizeof(DDXPointRec))))
+ {
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return NULL;
+ }
+ pbox = REGION_RECTS(&rgnDst);
+ ppt = pptSrc;
+ for (i = numRects; --i >= 0; pbox++, ppt++)
+ {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ (*doBitBlt) (pSrcDrawable, pDstDrawable, pGC->alu, &rgnDst, pptSrc, pGC->planemask, bitPlane);
+ DEALLOCATE_LOCAL(pptSrc);
+ }
+
+ prgnExposed = NULL;
+ if (pGC->fExpose)
+ {
+ extern RegionPtr miHandleExposures();
+
+ /* Pixmap sources generate a NoExposed (we return NULL to do this) */
+ if (!fastExpose)
+ prgnExposed =
+ miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
+ origSource.x, origSource.y,
+ (int)origSource.width,
+ (int)origSource.height,
+ origDest.x, origDest.y, bitPlane);
+ }
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return prgnExposed;
+}
+
+
+void
+iplDoBitblt (pSrc, pDst, alu, prgnDst, pptSrc, planemask)
+ DrawablePtr pSrc, pDst;
+ int alu;
+ RegionPtr prgnDst;
+ DDXPointPtr pptSrc;
+ unsigned long planemask;
+{
+ void (*blt)() = iplDoBitbltGeneral;
+ if ((planemask & INTER_PMSK) == INTER_PMSK) {
+ switch (alu) {
+ case GXcopy:
+ blt = iplDoBitbltCopy;
+ break;
+ case GXxor:
+ blt = iplDoBitbltXor;
+ break;
+ case GXor:
+ blt = iplDoBitbltOr;
+ break;
+ }
+ }
+ (*blt) (pSrc, pDst, alu, prgnDst, pptSrc, planemask);
+}
+
+RegionPtr
+iplCopyArea(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty)
+ register DrawablePtr pSrcDrawable;
+ register DrawablePtr pDstDrawable;
+ GC *pGC;
+ int srcx, srcy;
+ int width, height;
+ int dstx, dsty;
+{
+ void (*doBitBlt) ();
+
+ doBitBlt = iplDoBitbltCopy;
+ if (pGC->alu != GXcopy || (pGC->planemask & INTER_PMSK) != INTER_PMSK)
+ {
+ doBitBlt = iplDoBitbltGeneral;
+ if ((pGC->planemask & INTER_PMSK) == INTER_PMSK)
+ {
+ switch (pGC->alu) {
+ case GXxor:
+ doBitBlt = iplDoBitbltXor;
+ break;
+ case GXor:
+ doBitBlt = iplDoBitbltOr;
+ break;
+ }
+ }
+ }
+ return iplBitBlt (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, doBitBlt, 0L);
+}
+
+/* shared among all different ipl depths through linker magic */
+RegionPtr (*iplPuntCopyPlane)();
+
+RegionPtr iplCopyPlane(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, bitPlane)
+ DrawablePtr pSrcDrawable;
+ DrawablePtr pDstDrawable;
+ GCPtr pGC;
+ int srcx, srcy;
+ int width, height;
+ int dstx, dsty;
+ unsigned long bitPlane;
+{
+ RegionPtr ret;
+ extern RegionPtr miHandleExposures();
+ void (*doBitBlt)();
+
+ ret = (*iplPuntCopyPlane) (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
+ return ret;
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplblt.c b/nx-X11/programs/Xserver/iplan2p4/iplblt.c
new file mode 100644
index 000000000..85bcece13
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplblt.c
@@ -0,0 +1,431 @@
+/* $XFree86$ */
+/*
+ * ipl copy area
+ */
+
+/*
+
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+Author: Keith Packard
+
+*/
+/* $XConsortium: iplblt.c,v 1.13 94/04/17 20:28:44 dpw Exp $ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "ipl.h"
+#include "fastblt.h"
+#include "iplmergerop.h"
+#include "iplmskbits.h"
+
+void
+INTER_MROP_NAME(iplDoBitblt)(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
+ DrawablePtr pSrc, pDst;
+ int alu;
+ RegionPtr prgnDst;
+ DDXPointPtr pptSrc;
+ unsigned long planemask;
+{
+ INTER_DECLAREG(*psrcBase);
+ INTER_DECLAREG(*pdstBase); /* start of src and dst bitmaps */
+ int widthSrc, widthDst; /* add to get to same position in next line */
+
+ BoxPtr pbox;
+ int nbox;
+
+ BoxPtr pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2;
+ /* temporaries for shuffling rectangles */
+ DDXPointPtr pptTmp, pptNew1, pptNew2;
+ /* shuffling boxes entails shuffling the
+ source points too */
+ int w, h;
+ int xdir; /* 1 = left right, -1 = right left/ */
+ int ydir; /* 1 = top down, -1 = bottom up */
+
+ INTER_DECLAREG(*psrcLine);
+ INTER_DECLAREG(*pdstLine); /* pointers to line with current src and dst */
+ INTER_DECLAREG(*psrc); /* pointer to current src group */
+ INTER_DECLAREG(*pdst); /* pointer to current dst group */
+
+ INTER_MROP_DECLARE_REG()
+
+ /* following used for looping through a line */
+ INTER_DECLAREG(startmask);
+ INTER_DECLAREG(endmask); /* masks for writing ends of dst */
+ int ngMiddle; /* whole groups in dst */
+ int xoffSrc, xoffDst;
+ register int leftShift, rightShift;
+ INTER_DECLAREGP(bits);
+ INTER_DECLAREGP(bits1);
+ INTER_DECLAREGP(bits2);
+ register int ng; /* temp copy of ngMiddle */
+
+ /* place to store full source word */
+ int nstart; /* number of ragged bits at start of dst */
+ int nend; /* number of ragged bits at end of dst */
+ int srcStartOver; /* pulling nstart bits from src
+ overflows into the next word? */
+ int careful;
+ int tmpSrc;
+
+ INTER_MROP_INITIALIZE(alu,planemask);
+
+ iplGetGroupWidthAndPointer (pSrc, widthSrc, psrcBase)
+
+ iplGetGroupWidthAndPointer (pDst, widthDst, pdstBase)
+
+ /* XXX we have to err on the side of safety when both are windows,
+ * because we don't know if IncludeInferiors is being used.
+ */
+ careful = ((pSrc == pDst) ||
+ ((pSrc->type == DRAWABLE_WINDOW) &&
+ (pDst->type == DRAWABLE_WINDOW)));
+
+ pbox = REGION_RECTS(prgnDst);
+ nbox = REGION_NUM_RECTS(prgnDst);
+
+ pboxNew1 = NULL;
+ pptNew1 = NULL;
+ pboxNew2 = NULL;
+ pptNew2 = NULL;
+ if (careful && (pptSrc->y < pbox->y1))
+ {
+ /* walk source botttom to top */
+ ydir = -1;
+ widthSrc = -widthSrc;
+ widthDst = -widthDst;
+
+ if (nbox > 1)
+ {
+ /* keep ordering in each band, reverse order of bands */
+ pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
+ if(!pboxNew1)
+ return;
+ pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox);
+ if(!pptNew1)
+ {
+ DEALLOCATE_LOCAL(pboxNew1);
+ return;
+ }
+ pboxBase = pboxNext = pbox+nbox-1;
+ while (pboxBase >= pbox)
+ {
+ while ((pboxNext >= pbox) &&
+ (pboxBase->y1 == pboxNext->y1))
+ pboxNext--;
+ pboxTmp = pboxNext+1;
+ pptTmp = pptSrc + (pboxTmp - pbox);
+ while (pboxTmp <= pboxBase)
+ {
+ *pboxNew1++ = *pboxTmp++;
+ *pptNew1++ = *pptTmp++;
+ }
+ pboxBase = pboxNext;
+ }
+ pboxNew1 -= nbox;
+ pbox = pboxNew1;
+ pptNew1 -= nbox;
+ pptSrc = pptNew1;
+ }
+ }
+ else
+ {
+ /* walk source top to bottom */
+ ydir = 1;
+ }
+
+ if (careful && (pptSrc->x < pbox->x1))
+ {
+ /* walk source right to left */
+ xdir = -1;
+
+ if (nbox > 1)
+ {
+ /* reverse order of rects in each band */
+ pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
+ pptNew2 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox);
+ if(!pboxNew2 || !pptNew2)
+ {
+ if (pptNew2) DEALLOCATE_LOCAL(pptNew2);
+ if (pboxNew2) DEALLOCATE_LOCAL(pboxNew2);
+ if (pboxNew1)
+ {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(pboxNew1);
+ }
+ return;
+ }
+ pboxBase = pboxNext = pbox;
+ while (pboxBase < pbox+nbox)
+ {
+ while ((pboxNext < pbox+nbox) &&
+ (pboxNext->y1 == pboxBase->y1))
+ pboxNext++;
+ pboxTmp = pboxNext;
+ pptTmp = pptSrc + (pboxTmp - pbox);
+ while (pboxTmp != pboxBase)
+ {
+ *pboxNew2++ = *--pboxTmp;
+ *pptNew2++ = *--pptTmp;
+ }
+ pboxBase = pboxNext;
+ }
+ pboxNew2 -= nbox;
+ pbox = pboxNew2;
+ pptNew2 -= nbox;
+ pptSrc = pptNew2;
+ }
+ }
+ else
+ {
+ /* walk source left to right */
+ xdir = 1;
+ }
+
+ while(nbox--)
+ {
+ w = pbox->x2 - pbox->x1;
+ h = pbox->y2 - pbox->y1;
+
+ if (ydir == -1) /* start at last scanline of rectangle */
+ {
+ psrcLine = psrcBase + ((pptSrc->y+h-1) * -widthSrc);
+ pdstLine = pdstBase + ((pbox->y2-1) * -widthDst);
+ }
+ else /* start at first scanline */
+ {
+ psrcLine = psrcBase + (pptSrc->y * widthSrc);
+ pdstLine = pdstBase + (pbox->y1 * widthDst);
+ }
+ if ((pbox->x1 & INTER_PIM) + w <= INTER_PPG)
+ {
+ INTER_maskpartialbits (pbox->x1, w, endmask);
+ startmask = 0;
+ ngMiddle = 0;
+ }
+ else
+ {
+ INTER_maskbits(pbox->x1, w, startmask, endmask, ngMiddle);
+ }
+
+ if (xdir == 1)
+ {
+ xoffSrc = pptSrc->x & INTER_PIM;
+ xoffDst = pbox->x1 & INTER_PIM;
+ pdstLine += (pbox->x1 >> INTER_PGSH) * INTER_PLANES;
+ psrcLine += (pptSrc->x >> INTER_PGSH) * INTER_PLANES;
+ ng = xoffSrc - xoffDst;
+ if (xoffSrc == xoffDst)
+ {
+ while (h--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ pdstLine += widthDst;
+ psrcLine += widthSrc;
+ if (startmask)
+ {
+ INTER_MROP_MASK(psrc, pdst, startmask, pdst);
+ INTER_NEXT_GROUP(psrc);
+ INTER_NEXT_GROUP(pdst);
+ }
+ ng = ngMiddle;
+
+ DuffL(ng, label1,
+ INTER_MROP_SOLID(psrc, pdst, pdst);
+ INTER_NEXT_GROUP(psrc);
+ INTER_NEXT_GROUP(pdst);
+ )
+ if (endmask)
+ INTER_MROP_MASK(psrc, pdst, endmask, pdst);
+ }
+ }
+ else
+ {
+ if (xoffSrc > xoffDst)
+ {
+ leftShift = xoffSrc - xoffDst;
+ rightShift = (INTER_PIM+1) - leftShift;
+ }
+ else
+ {
+ rightShift = xoffDst - xoffSrc;
+ leftShift = (INTER_PIM+1) - rightShift;
+ }
+ while (h--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ pdstLine += widthDst;
+ psrcLine += widthSrc;
+ INTER_CLR(bits);
+ if (xoffSrc > xoffDst) {
+ INTER_COPY(psrc, bits);
+ INTER_NEXT_GROUP(psrc);
+ }
+ if (startmask)
+ {
+ INTER_GETLRC(leftShift, rightShift, psrc, bits, bits1);
+ INTER_MROP_MASK(bits1, pdst, startmask, pdst);
+ INTER_NEXT_GROUP(psrc);
+ INTER_NEXT_GROUP(pdst);
+ }
+ ng = ngMiddle;
+ DuffL (ng,label2,
+ INTER_GETLRC(leftShift, rightShift, psrc, bits, bits1);
+ INTER_MROP_SOLID(bits1, pdst, pdst);
+ INTER_NEXT_GROUP(psrc);
+ INTER_NEXT_GROUP(pdst);
+ )
+ if (endmask)
+ {
+ if ((endmask << rightShift) & 0xffff) {
+ INTER_GETLRC(leftShift, rightShift, psrc, bits,
+ bits1);
+ }
+ else {
+ INTER_SCRLEFT(leftShift, bits, bits1);
+ }
+ INTER_MROP_MASK(bits1, pdst, endmask, pdst);
+ }
+ }
+ }
+ }
+ else /* xdir == -1 */
+ {
+ xoffSrc = (pptSrc->x + w - 1) & INTER_PIM;
+ xoffDst = (pbox->x2 - 1) & INTER_PIM;
+ pdstLine += (((pbox->x2-1) >> INTER_PGSH) + 1) * INTER_PLANES;
+ psrcLine += (((pptSrc->x+w - 1) >> INTER_PGSH) + 1) * INTER_PLANES;
+ if (xoffSrc == xoffDst)
+ {
+ while (h--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ pdstLine += widthDst;
+ psrcLine += widthSrc;
+ if (endmask)
+ {
+ INTER_PREV_GROUP(psrc);
+ INTER_PREV_GROUP(pdst);
+ INTER_MROP_MASK(psrc, pdst, endmask, pdst);
+ }
+ ng = ngMiddle;
+
+ DuffL(ng,label3,
+ INTER_PREV_GROUP(psrc);
+ INTER_PREV_GROUP(pdst);
+ INTER_MROP_SOLID(psrc, pdst, pdst);
+ )
+
+ if (startmask)
+ {
+ INTER_PREV_GROUP(psrc);
+ INTER_PREV_GROUP(pdst);
+ INTER_MROP_MASK(psrc, pdst, startmask, pdst);
+ }
+ }
+ }
+ else
+ {
+ if (xoffDst > xoffSrc)
+ {
+ rightShift = xoffDst - xoffSrc;
+ leftShift = (INTER_PIM + 1) - rightShift;
+ }
+ else
+ {
+ leftShift = xoffSrc - xoffDst;
+ rightShift = (INTER_PIM + 1) - leftShift;
+ }
+ while (h--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ pdstLine += widthDst;
+ psrcLine += widthSrc;
+ INTER_CLR(bits);
+ if (xoffDst > xoffSrc) {
+ INTER_PREV_GROUP(psrc);
+ INTER_COPY(psrc, bits);
+ }
+ if (endmask)
+ {
+ INTER_PREV_GROUP(psrc);
+ INTER_PREV_GROUP(pdst);
+ INTER_GETRLC(rightShift, leftShift, psrc, bits, bits1);
+ INTER_MROP_MASK(bits1, pdst, endmask, pdst);
+ }
+ ng = ngMiddle;
+ DuffL (ng, label4,
+ INTER_PREV_GROUP(psrc);
+ INTER_PREV_GROUP(pdst);
+ INTER_GETRLC(rightShift, leftShift, psrc, bits, bits1);
+ INTER_MROP_SOLID(bits1, pdst, pdst);
+ )
+ if (startmask)
+ {
+ INTER_PREV_GROUP(psrc);
+ INTER_PREV_GROUP(pdst);
+ if ((startmask >> leftShift) & 0xffff) {
+ INTER_GETRLC(rightShift, leftShift, psrc, bits,
+ bits1);
+ }
+ else {
+ INTER_SCRRIGHT(rightShift, bits, bits1);
+ }
+ INTER_MROP_MASK(bits1, pdst, startmask, pdst);
+ }
+ }
+ }
+ }
+ pbox++;
+ pptSrc++;
+ }
+ if (pboxNew2)
+ {
+ DEALLOCATE_LOCAL(pptNew2);
+ DEALLOCATE_LOCAL(pboxNew2);
+ }
+ if (pboxNew1)
+ {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(pboxNew1);
+ }
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplbres.c b/nx-X11/programs/Xserver/iplan2p4/iplbres.c
new file mode 100644
index 000000000..4fa9a3256
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplbres.c
@@ -0,0 +1,186 @@
+/* $XFree86$ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: iplbres.c,v 1.15 94/04/17 20:28:45 dpw Exp $ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "ipl.h"
+#include "servermd.h"
+#include "miline.h"
+
+#include "iplmskbits.h"
+
+/* Solid bresenham line */
+/* NOTES
+ e2 is used less often than e1, so it's not in a register
+*/
+
+void
+iplBresS(rop, andp, xorp, addrg, ngwidth, signdx, signdy, axis, x1, y1, e, e1,
+ e2, len)
+ int rop;
+ INTER_DECLARERRAX(andp);
+ INTER_DECLARERRAX(xorp);
+ INTER_DECLAREG(*addrg); /* pointer to base of bitmap */
+ int ngwidth; /* width in longwords of bitmap */
+ register int signdx;
+ int signdy; /* signs of directions */
+ int axis; /* major axis (Y_AXIS or X_AXIS) */
+ int x1, y1; /* initial point */
+ register int e; /* error accumulator */
+ register int e1; /* bresenham increments */
+ int e2;
+ int len; /* length of line */
+{
+ register int e3 = e2-e1;
+ INTER_DECLAREG(bit);
+ INTER_DECLAREG(leftbit);
+ INTER_DECLAREG(rightbit);
+
+ /* point to longword containing first point */
+ addrg = addrg + y1 * ngwidth + (x1 >> INTER_PGSH) * INTER_PLANES;
+
+ if (signdy < 0)
+ ngwidth = -ngwidth;
+ e = e-e1; /* to make looping easier */
+
+ leftbit = iplmask[0];
+ rightbit = iplmask[INTER_PPG-1];
+ bit = iplmask[x1 & INTER_PIM];
+
+ if (axis == X_AXIS)
+ {
+ if (signdx > 0)
+ {
+ while (len--)
+ {
+ INTER_DoMaskRRop(addrg, andp, xorp, bit, addrg);
+ bit = bit >> 1;
+ e += e1;
+ if (e >= 0)
+ {
+ addrg += ngwidth;
+ e += e3;
+ }
+ if (!bit)
+ {
+ bit = leftbit;
+ addrg += INTER_PLANES;
+ }
+ }
+ }
+ else
+ {
+ while (len--)
+ {
+ INTER_DoMaskRRop(addrg, andp, xorp, bit, addrg);
+ e += e1;
+ bit = bit << 1;
+ if (e >= 0)
+ {
+ addrg += ngwidth;
+ e += e3;
+ }
+ if (!bit)
+ {
+ bit = rightbit;
+ addrg -= INTER_PLANES;
+ }
+ }
+ }
+ } /* if X_AXIS */
+ else
+ {
+ if (signdx > 0)
+ {
+ while(len--)
+ {
+ INTER_DoMaskRRop(addrg, andp, xorp, bit, addrg);
+ e += e1;
+ if (e >= 0)
+ {
+ bit = bit >> 1;
+ if (!bit)
+ {
+ bit = leftbit;
+ addrg += INTER_PLANES;
+ }
+ e += e3;
+ }
+ addrg += ngwidth;
+ }
+ }
+ else
+ {
+ while(len--)
+ {
+ INTER_DoMaskRRop(addrg, andp, xorp, bit, addrg);
+ e += e1;
+ if (e >= 0)
+ {
+ bit = bit << 1;
+ if (!bit)
+ {
+ bit = rightbit;
+ addrg -= INTER_PLANES;
+ }
+ e += e3;
+ }
+ addrg += ngwidth;
+ }
+ }
+ } /* else Y_AXIS */
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplbresd.c b/nx-X11/programs/Xserver/iplan2p4/iplbresd.c
new file mode 100644
index 000000000..61b154135
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplbresd.c
@@ -0,0 +1,212 @@
+/* $XFree86$ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: iplbresd.c,v 1.16 94/04/17 20:28:45 dpw Exp $ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "ipl.h"
+#include "miline.h"
+#include "iplmskbits.h"
+
+/* Dashed bresenham line */
+
+void
+iplBresD(rrops,
+ pdashIndex, pDash, numInDashList, pdashOffset, isDoubleDash,
+ addrg, ngwidth,
+ signdx, signdy, axis, x1, y1, e, e1, e2, len)
+ iplRRopPtr rrops;
+ int *pdashIndex; /* current dash */
+ unsigned char *pDash; /* dash list */
+ int numInDashList; /* total length of dash list */
+ int *pdashOffset; /* offset into current dash */
+ int isDoubleDash;
+ INTER_DECLAREG(*addrg); /* pointer to base of bitmap */
+ int ngwidth; /* width in groups of bitmap */
+ int signdx, signdy; /* signs of directions */
+ int axis; /* major axis (Y_AXIS or X_AXIS) */
+ int x1, y1; /* initial point */
+ register int e; /* error accumulator */
+ register int e1; /* bresenham increments */
+ int e2;
+ int len; /* length of line */
+{
+ register int e3 = e2-e1;
+ int dashIndex;
+ int dashOffset;
+ int dashRemaining;
+ INTER_DECLARERRAX(xorFg);
+ INTER_DECLARERRAX(andFg);
+ INTER_DECLARERRAX(xorBg);
+ INTER_DECLARERRAX(andBg);
+ int thisDash;
+
+ dashOffset = *pdashOffset;
+ dashIndex = *pdashIndex;
+ xorFg = rrops[0].xorg;
+ andFg = rrops[0].andg;
+ xorBg = rrops[1].xorg;
+ andBg = rrops[1].andg;
+ dashRemaining = pDash[dashIndex] - dashOffset;
+ if ((thisDash = dashRemaining) >= len)
+ {
+ thisDash = len;
+ dashRemaining -= len;
+ }
+ e = e-e1; /* to make looping easier */
+
+#define BresStep(minor,major) {if ((e += e1) >= 0) { e += e3; minor; } major;}
+
+#define NextDash {\
+ dashIndex++; \
+ if (dashIndex == numInDashList) \
+ dashIndex = 0; \
+ dashRemaining = pDash[dashIndex]; \
+ if ((thisDash = dashRemaining) >= len) \
+ { \
+ dashRemaining -= len; \
+ thisDash = len; \
+ } \
+}
+
+ {
+ INTER_DECLAREG(startbit);
+ INTER_DECLAREG(bit);
+
+ /* point to longword containing first point */
+ addrg = addrg + (y1 * ngwidth) + (x1 >> INTER_PGSH) * INTER_PLANES;
+ signdy = signdy * ngwidth;
+ signdx = signdx * INTER_PLANES;
+
+ if (signdx > 0)
+ startbit = iplmask[0];
+ else
+ startbit = iplmask[INTER_PPG-1];
+ bit = iplmask[x1 & INTER_PIM];
+
+#define X_Loop(store) while(thisDash--) {\
+ store; \
+ BresStep(addrg += signdy, \
+ if (signdx > 0) \
+ bit >>= 1; \
+ else \
+ bit <<= 1; \
+ if (!bit) \
+ { \
+ bit = startbit; \
+ addrg += signdx; \
+ }) \
+ }
+#define Y_Loop(store) while(thisDash--) {\
+ store; \
+ BresStep(if (signdx > 0) \
+ bit >>= 1; \
+ else \
+ bit <<= 1; \
+ if (!bit) \
+ { \
+ bit = startbit; \
+ addrg += signdx; \
+ }, \
+ addrg += signdy) \
+ }
+
+ if (axis == X_AXIS)
+ {
+ for (;;)
+ {
+ len -= thisDash;
+ if (dashIndex & 1) {
+ if (isDoubleDash) {
+ X_Loop(
+ INTER_DoMaskRRop(addrg, andBg, xorBg, bit, addrg);
+ )
+ } else {
+ X_Loop(;)
+ }
+ } else {
+ X_Loop(INTER_DoMaskRRop(addrg, andFg, xorFg, bit, addrg));
+ }
+ if (!len)
+ break;
+ NextDash
+ }
+ } /* if X_AXIS */
+ else
+ {
+ for (;;)
+ {
+ len -= thisDash;
+ if (dashIndex & 1) {
+ if (isDoubleDash) {
+ Y_Loop(
+ INTER_DoMaskRRop(addrg, andBg, xorBg, bit, addrg);
+ )
+ } else {
+ Y_Loop(;)
+ }
+ } else {
+ Y_Loop(INTER_DoMaskRRop(addrg, andFg, xorFg, bit, addrg));
+ }
+ if (!len)
+ break;
+ NextDash
+ }
+ } /* else Y_AXIS */
+ }
+ *pdashIndex = dashIndex;
+ *pdashOffset = pDash[dashIndex] - dashRemaining;
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplbstore.c b/nx-X11/programs/Xserver/iplan2p4/iplbstore.c
new file mode 100644
index 000000000..d2fc23513
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplbstore.c
@@ -0,0 +1,159 @@
+/* $XFree86$ */
+
+/*-
+ * iplbstore.c --
+ * Functions required by the backing-store implementation in MI.
+ *
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef lint
+static char rcsid[] =
+"$XConsortium: iplbstore.c,v 5.8 93/12/13 17:21:51 dpw Exp $ SPRITE (Berkeley)";
+#endif
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#include "ipl.h"
+#include <X11/X.h>
+#include "mibstore.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * iplSaveAreas --
+ * Function called by miSaveAreas to actually fetch the areas to be
+ * saved into the backing pixmap. This is very simple to do, since
+ * iplDoBitblt is designed for this very thing. The region to save is
+ * already destination-relative and we're given the offset to the
+ * window origin, so we have only to create an array of points of the
+ * u.l. corners of the boxes in the region translated to the screen
+ * coordinate system and fetch the screen pixmap out of its devPrivate
+ * field....
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Data are copied from the screen into the pixmap.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+iplSaveAreas(pPixmap, prgnSave, xorg, yorg, pWin)
+ PixmapPtr pPixmap; /* Backing pixmap */
+ RegionPtr prgnSave; /* Region to save (pixmap-relative) */
+ int xorg; /* X origin of region */
+ int yorg; /* Y origin of region */
+ WindowPtr pWin;
+{
+ register DDXPointPtr pPt;
+ DDXPointPtr pPtsInit;
+ register BoxPtr pBox;
+ register int i;
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ PixmapPtr pScrPix;
+
+ i = REGION_NUM_RECTS(prgnSave);
+ pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec));
+ if (!pPtsInit)
+ return;
+
+ pBox = REGION_RECTS(prgnSave);
+ pPt = pPtsInit;
+ while (--i >= 0) {
+ pPt->x = pBox->x1 + xorg;
+ pPt->y = pBox->y1 + yorg;
+ pPt++;
+ pBox++;
+ }
+
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ pScrPix = (PixmapPtr) pScreen->devPrivates[iplScreenPrivateIndex].ptr;
+#else
+ pScrPix = (PixmapPtr) pScreen->devPrivate;
+#endif
+
+ iplDoBitbltCopy((DrawablePtr) pScrPix, (DrawablePtr)pPixmap,
+ GXcopy, prgnSave, pPtsInit, ~0L);
+
+ DEALLOCATE_LOCAL (pPtsInit);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * iplRestoreAreas --
+ * Function called by miRestoreAreas to actually fetch the areas to be
+ * restored from the backing pixmap. This is very simple to do, since
+ * iplDoBitblt is designed for this very thing. The region to restore is
+ * already destination-relative and we're given the offset to the
+ * window origin, so we have only to create an array of points of the
+ * u.l. corners of the boxes in the region translated to the pixmap
+ * coordinate system and fetch the screen pixmap out of its devPrivate
+ * field....
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Data are copied from the pixmap into the screen.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+iplRestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin)
+ PixmapPtr pPixmap; /* Backing pixmap */
+ RegionPtr prgnRestore; /* Region to restore (screen-relative)*/
+ int xorg; /* X origin of window */
+ int yorg; /* Y origin of window */
+ WindowPtr pWin;
+{
+ register DDXPointPtr pPt;
+ DDXPointPtr pPtsInit;
+ register BoxPtr pBox;
+ register int i;
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ PixmapPtr pScrPix;
+
+ i = REGION_NUM_RECTS(prgnRestore);
+ pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i*sizeof(DDXPointRec));
+ if (!pPtsInit)
+ return;
+
+ pBox = REGION_RECTS(prgnRestore);
+ pPt = pPtsInit;
+ while (--i >= 0) {
+ pPt->x = pBox->x1 - xorg;
+ pPt->y = pBox->y1 - yorg;
+ pPt++;
+ pBox++;
+ }
+
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ pScrPix = (PixmapPtr) pScreen->devPrivates[iplScreenPrivateIndex].ptr;
+#else
+ pScrPix = (PixmapPtr) pScreen->devPrivate;
+#endif
+
+ iplDoBitbltCopy((DrawablePtr)pPixmap, (DrawablePtr) pScrPix,
+ GXcopy, prgnRestore, pPtsInit, ~0L);
+
+ DEALLOCATE_LOCAL (pPtsInit);
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplcmap.c b/nx-X11/programs/Xserver/iplan2p4/iplcmap.c
new file mode 100644
index 000000000..0f3cdca14
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplcmap.c
@@ -0,0 +1,126 @@
+/* $XFree86: xc/programs/Xserver/iplan2p4/iplcmap.c,v 3.0 1996/08/18 01:54:40 dawes Exp $ */
+/* $XConsortium: iplcmap.c,v 4.19 94/04/17 20:28:46 dpw Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "colormapst.h"
+#include "resource.h"
+#include "micmap.h"
+
+int
+iplListInstalledColormaps(pScreen, pmaps)
+ ScreenPtr pScreen;
+ Colormap *pmaps;
+{
+ return miListInstalledColormaps(pScreen, pmaps);
+}
+
+
+void
+iplInstallColormap(pmap)
+ ColormapPtr pmap;
+{
+ miInstallColormap(pmap);
+}
+
+void
+iplUninstallColormap(pmap)
+ ColormapPtr pmap;
+{
+ miUninstallColormap(pmap);
+}
+
+void
+iplResolveColor(pred, pgreen, pblue, pVisual)
+ unsigned short *pred, *pgreen, *pblue;
+ register VisualPtr pVisual;
+{
+ miResolveColor(pred, pgreen, pblue, pVisual);
+}
+
+Bool
+iplInitializeColormap(pmap)
+ register ColormapPtr pmap;
+{
+ return miInitializeColormap(pmap);
+}
+
+int
+iplExpandDirectColors (pmap, ndef, indefs, outdefs)
+ ColormapPtr pmap;
+ int ndef;
+ xColorItem *indefs, *outdefs;
+{
+ return miExpandDirectColors(pmap, ndef, indefs, outdefs);
+}
+
+Bool
+iplCreateDefColormap(pScreen)
+ ScreenPtr pScreen;
+{
+ return miCreateDefColormap(pScreen);
+}
+
+Bool
+iplSetVisualTypes (depth, visuals, bitsPerRGB)
+ int depth;
+ int visuals;
+{
+ return miSetVisualTypes(depth, visuals, bitsPerRGB, -1);
+}
+
+/*
+ * Given a list of formats for a screen, create a list
+ * of visuals and depths for the screen which coorespond to
+ * the set which can be used with this version of ipl.
+ */
+
+Bool
+iplInitVisuals (visualp, depthp, nvisualp, ndepthp, rootDepthp, defaultVisp, sizes, bitsPerRGB)
+ VisualPtr *visualp;
+ DepthPtr *depthp;
+ int *nvisualp, *ndepthp;
+ int *rootDepthp;
+ VisualID *defaultVisp;
+ unsigned long sizes;
+ int bitsPerRGB;
+{
+ return miInitVisuals(visualp, depthp, nvisualp, ndepthp, rootDepthp,
+ defaultVisp, sizes, bitsPerRGB, -1);
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplfillarc.c b/nx-X11/programs/Xserver/iplan2p4/iplfillarc.c
new file mode 100644
index 000000000..f62ff9f9e
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplfillarc.c
@@ -0,0 +1,271 @@
+/* $XFree86$ */
+/************************************************************
+
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+********************************************************/
+
+/* $XConsortium: iplfillarc.c,v 5.15 94/04/17 20:28:47 dpw Exp $ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "miscstruct.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "ipl.h"
+#include "mifillarc.h"
+#include "iplrrop.h"
+#include "mi.h"
+#include "iplmskbits.h"
+
+static void
+INTER_RROP_NAME(iplFillEllipseSolid) (pDraw, pGC, arc)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ xArc *arc;
+{
+ int x, y, e;
+ int yk, xk, ym, xm, dx, dy, xorg, yorg;
+ miFillArcRec info;
+ INTER_DECLAREG(*addrgt);
+ INTER_DECLAREG(*addrgb);
+ INTER_DECLAREG(*addrg);
+ register int n;
+ int ngwidth;
+ INTER_RROP_DECLARE
+ register int xpos;
+ register int slw;
+ INTER_DECLAREG(startmask);
+ INTER_DECLAREG(endmask);
+ int nlmiddle;
+
+ iplGetGroupWidthAndPointer (pDraw, ngwidth, addrgt);
+
+ INTER_RROP_FETCH_GC(pGC);
+ miFillArcSetup(arc, &info);
+ MIFILLARCSETUP();
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ addrgb = addrgt;
+ addrgt += ngwidth * (yorg - y);
+ addrgb += ngwidth * (yorg + y + dy);
+ while (y)
+ {
+ addrgt += ngwidth;
+ addrgb -= ngwidth;
+ MIFILLARCSTEP(slw);
+ if (!slw)
+ continue;
+ xpos = xorg - x;
+ addrg = addrgt + (xpos >> INTER_PGSH) * INTER_PLANES;
+ if (((xpos & INTER_PIM) + slw) <= INTER_PPG)
+ {
+ INTER_maskpartialbits(xpos, slw, startmask);
+ INTER_RROP_SOLID_MASK(addrg,startmask);
+ if (miFillArcLower(slw))
+ {
+ addrg = addrgb + (xpos >> INTER_PGSH) * INTER_PLANES;
+ INTER_RROP_SOLID_MASK(addrg, startmask);
+ }
+ continue;
+ }
+ INTER_maskbits(xpos, slw, startmask, endmask, nlmiddle);
+ if (startmask)
+ {
+ INTER_RROP_SOLID_MASK(addrg, startmask);
+ INTER_NEXT_GROUP(addrg);
+ }
+ n = nlmiddle;
+ INTER_RROP_SPAN(addrg,n)
+
+ if (endmask)
+ INTER_RROP_SOLID_MASK(addrg, endmask);
+ if (!miFillArcLower(slw))
+ continue;
+ addrg = addrgb + (xpos >> INTER_PGSH) * INTER_PLANES;
+ if (startmask)
+ {
+ INTER_RROP_SOLID_MASK(addrg, startmask);
+ INTER_NEXT_GROUP(addrg);
+ }
+ n = nlmiddle;
+ INTER_RROP_SPAN(addrg, n);
+ if (endmask)
+ INTER_RROP_SOLID_MASK(addrg, endmask);
+ }
+}
+
+#define FILLSPAN(xl,xr,addr) \
+ if (xr >= xl) \
+ { \
+ n = xr - xl + 1; \
+ addrg = addr + (xl >> INTER_PGSH) * INTER_PLANES; \
+ if (((xl & INTER_PIM) + n) <= INTER_PPG) \
+ { \
+ INTER_maskpartialbits(xl, n, startmask); \
+ INTER_RROP_SOLID_MASK(addrg, startmask); \
+ } \
+ else \
+ { \
+ INTER_maskbits(xl, n, startmask, endmask, n); \
+ if (startmask) \
+ { \
+ INTER_RROP_SOLID_MASK(addrg, startmask); \
+ INTER_NEXT_GROUP(addrg); \
+ } \
+ while (n--) \
+ { \
+ INTER_RROP_SOLID(addrg); \
+ INTER_NEXT_GROUP(addrg); \
+ } \
+ if (endmask) \
+ INTER_RROP_SOLID_MASK(addrg, endmask); \
+ } \
+ }
+
+#define FILLSLICESPANS(flip,addr) \
+ if (!flip) \
+ { \
+ FILLSPAN(xl, xr, addr); \
+ } \
+ else \
+ { \
+ xc = xorg - x; \
+ FILLSPAN(xc, xr, addr); \
+ xc += slw - 1; \
+ FILLSPAN(xl, xc, addr); \
+ }
+
+static void
+INTER_RROP_NAME(iplFillArcSliceSolid)(pDraw, pGC, arc)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ xArc *arc;
+{
+ int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
+ register int x, y, e;
+ miFillArcRec info;
+ miArcSliceRec slice;
+ int xl, xr, xc;
+ INTER_DECLAREG(*addrgt);
+ INTER_DECLAREG(*addrgb);
+ INTER_DECLAREG(*addrg);
+ register int n;
+ int ngwidth;
+ INTER_RROP_DECLARE
+ INTER_DECLAREG(startmask);
+ INTER_DECLAREG(endmask);
+
+ iplGetGroupWidthAndPointer (pDraw, ngwidth, addrgt);
+
+ INTER_RROP_FETCH_GC(pGC);
+ miFillArcSetup(arc, &info);
+ miFillArcSliceSetup(arc, &slice, pGC);
+ MIFILLARCSETUP();
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ addrgb = addrgt;
+ addrgt += ngwidth * (yorg - y);
+ addrgb += ngwidth * (yorg + y + dy);
+ slice.edge1.x += pDraw->x;
+ slice.edge2.x += pDraw->x;
+ while (y > 0)
+ {
+ addrgt += ngwidth;
+ addrgb -= ngwidth;
+ MIFILLARCSTEP(slw);
+ MIARCSLICESTEP(slice.edge1);
+ MIARCSLICESTEP(slice.edge2);
+ if (miFillSliceUpper(slice))
+ {
+ MIARCSLICEUPPER(xl, xr, slice, slw);
+ FILLSLICESPANS(slice.flip_top, addrgt);
+ }
+ if (miFillSliceLower(slice))
+ {
+ MIARCSLICELOWER(xl, xr, slice, slw);
+ FILLSLICESPANS(slice.flip_bot, addrgb);
+ }
+ }
+}
+
+void
+INTER_RROP_NAME(iplPolyFillArcSolid) (pDraw, pGC, narcs, parcs)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int narcs;
+ xArc *parcs;
+{
+ register xArc *arc;
+ register int i;
+ int x2, y2;
+ BoxRec box;
+ RegionPtr cclip;
+
+ cclip = iplGetCompositeClip(pGC);
+ for (arc = parcs, i = narcs; --i >= 0; arc++)
+ {
+ if (miFillArcEmpty(arc))
+ continue;
+ if (miCanFillArc(arc))
+ {
+ box.x1 = arc->x + pDraw->x;
+ box.y1 = arc->y + pDraw->y;
+ /*
+ * Because box.x2 and box.y2 get truncated to 16 bits, and the
+ * RECT_IN_REGION test treats the resulting number as a signed
+ * integer, the RECT_IN_REGION test alone can go the wrong way.
+ * This can result in a server crash because the rendering
+ * routines in this file deal directly with cpu addresses
+ * of pixels to be stored, and do not clip or otherwise check
+ * that all such addresses are within their respective pixmaps.
+ * So we only allow the RECT_IN_REGION test to be used for
+ * values that can be expressed correctly in a signed short.
+ */
+ x2 = box.x1 + (int)arc->width + 1;
+ box.x2 = x2;
+ y2 = box.y1 + (int)arc->height + 1;
+ box.y2 = y2;
+ if ( (x2 <= MAXSHORT) && (y2 <= MAXSHORT) &&
+ (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) )
+ {
+ if ((arc->angle2 >= FULLCIRCLE) ||
+ (arc->angle2 <= -FULLCIRCLE))
+ INTER_RROP_NAME(iplFillEllipseSolid)(pDraw, pGC, arc);
+ else
+ INTER_RROP_NAME(iplFillArcSliceSolid)(pDraw, pGC, arc);
+ continue;
+ }
+ }
+ miPolyFillArc(pDraw, pGC, 1, arc);
+ }
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplfillrct.c b/nx-X11/programs/Xserver/iplan2p4/iplfillrct.c
new file mode 100644
index 000000000..a3301457b
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplfillrct.c
@@ -0,0 +1,281 @@
+/* $XFree86: xc/programs/Xserver/iplan2p4/iplfillrct.c,v 3.0 1996/08/18 01:54:42 dawes Exp $ */
+/*
+ * Fill rectangles.
+ */
+
+/*
+
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+*/
+
+/* $XConsortium: iplfillrct.c,v 5.18 94/04/17 20:28:47 dpw Exp $ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+#include "ipl.h"
+#include "iplmskbits.h"
+#include "mergerop.h"
+
+
+void
+iplFillBoxTileOdd (pDrawable, n, rects, tile, xrot, yrot)
+ DrawablePtr pDrawable;
+ int n;
+ BoxPtr rects;
+ PixmapPtr tile;
+ int xrot, yrot;
+{
+ if (tile->drawable.width & INTER_PIM)
+ iplFillBoxTileOddCopy (pDrawable, n, rects, tile, xrot, yrot, GXcopy, ~0L);
+ else
+ iplFillBoxTile32sCopy (pDrawable, n, rects, tile, xrot, yrot, GXcopy, ~0L);
+}
+
+void
+iplFillRectTileOdd (pDrawable, pGC, nBox, pBox)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nBox;
+ BoxPtr pBox;
+{
+ int xrot, yrot;
+ void (*fill)();
+
+ xrot = pDrawable->x + pGC->patOrg.x;
+ yrot = pDrawable->y + pGC->patOrg.y;
+ if (pGC->tile.pixmap->drawable.width & INTER_PIM)
+ {
+ fill = iplFillBoxTileOddGeneral;
+ if ((pGC->planemask & INTER_PMSK) == INTER_PMSK)
+ {
+ if (pGC->alu == GXcopy)
+ fill = iplFillBoxTileOddCopy;
+ }
+ }
+ else
+ {
+ fill = iplFillBoxTile32sGeneral;
+ if ((pGC->planemask & INTER_PMSK) == INTER_PMSK)
+ {
+ if (pGC->alu == GXcopy)
+ fill = iplFillBoxTile32sCopy;
+ }
+ }
+ (*fill) (pDrawable, nBox, pBox, pGC->tile.pixmap, xrot, yrot, pGC->alu, pGC->planemask);
+}
+
+#define NUM_STACK_RECTS 1024
+
+void
+iplPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int nrectFill; /* number of rectangles to fill */
+ xRectangle *prectInit; /* Pointer to first rectangle to fill */
+{
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ register BoxPtr pbox;
+ register BoxPtr pboxClipped;
+ BoxPtr pboxClippedBase;
+ BoxPtr pextent;
+ BoxRec stackRects[NUM_STACK_RECTS];
+ iplPrivGC *priv;
+ int numRects;
+ void (*BoxFill)();
+ int n;
+ int xorg, yorg;
+
+ priv = iplGetGCPrivate(pGC);
+ prgnClip = pGC->pCompositeClip;
+
+ BoxFill = 0;
+ switch (pGC->fillStyle)
+ {
+ case FillSolid:
+ switch (priv->rop) {
+ case GXcopy:
+ BoxFill = iplFillRectSolidCopy;
+ break;
+ case GXxor:
+ BoxFill = iplFillRectSolidXor;
+ break;
+ default:
+ BoxFill = iplFillRectSolidGeneral;
+ break;
+ }
+ break;
+ case FillTiled:
+ if (!pGC->pRotatedPixmap)
+ BoxFill = iplFillRectTileOdd;
+ else
+ {
+ if (pGC->alu == GXcopy && (pGC->planemask & INTER_PMSK) == INTER_PMSK)
+ BoxFill = iplFillRectTile32Copy;
+ else
+ BoxFill = iplFillRectTile32General;
+ }
+ break;
+ }
+ prect = prectInit;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ if (xorg || yorg)
+ {
+ prect = prectInit;
+ n = nrectFill;
+ while(n--)
+ {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+ prect = prectInit;
+
+ numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
+ if (numRects > NUM_STACK_RECTS)
+ {
+ pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(numRects * sizeof(BoxRec));
+ if (!pboxClippedBase)
+ return;
+ }
+ else
+ pboxClippedBase = stackRects;
+
+ pboxClipped = pboxClippedBase;
+
+ if (REGION_NUM_RECTS(prgnClip) == 1)
+ {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_RECTS(prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--)
+ {
+ if ((pboxClipped->x1 = prect->x) < x1)
+ pboxClipped->x1 = x1;
+
+ if ((pboxClipped->y1 = prect->y) < y1)
+ pboxClipped->y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ pboxClipped->x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ pboxClipped->y2 = by2;
+
+ prect++;
+ if ((pboxClipped->x1 < pboxClipped->x2) &&
+ (pboxClipped->y1 < pboxClipped->y2))
+ {
+ pboxClipped++;
+ }
+ }
+ }
+ else
+ {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--)
+ {
+ BoxRec box;
+
+ if ((box.x1 = prect->x) < x1)
+ box.x1 = x1;
+
+ if ((box.y1 = prect->y) < y1)
+ box.y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ box.x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ box.y2 = by2;
+
+ prect++;
+
+ if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
+ continue;
+
+ n = REGION_NUM_RECTS (prgnClip);
+ pbox = REGION_RECTS(prgnClip);
+
+ /* clip the rectangle to each box in the clip region
+ this is logically equivalent to calling Intersect()
+ */
+ while(n--)
+ {
+ pboxClipped->x1 = max(box.x1, pbox->x1);
+ pboxClipped->y1 = max(box.y1, pbox->y1);
+ pboxClipped->x2 = min(box.x2, pbox->x2);
+ pboxClipped->y2 = min(box.y2, pbox->y2);
+ pbox++;
+
+ /* see if clipping left anything */
+ if(pboxClipped->x1 < pboxClipped->x2 &&
+ pboxClipped->y1 < pboxClipped->y2)
+ {
+ pboxClipped++;
+ }
+ }
+ }
+ }
+ if (pboxClipped != pboxClippedBase)
+ (*BoxFill) (pDrawable, pGC,
+ pboxClipped-pboxClippedBase, pboxClippedBase);
+ if (pboxClippedBase != stackRects)
+ DEALLOCATE_LOCAL(pboxClippedBase);
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplfillsp.c b/nx-X11/programs/Xserver/iplan2p4/iplfillsp.c
new file mode 100644
index 000000000..863d369af
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplfillsp.c
@@ -0,0 +1,384 @@
+/* $XFree86$ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* $XConsortium: iplfillsp.c,v 5.24 94/04/17 20:28:48 dpw Exp $ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+#include "ipl.h"
+
+#include "mergerop.h"
+
+#define MFB_CONSTS_ONLY
+#include "maskbits.h"
+
+#include "mi.h"
+#include "mispans.h"
+
+#include "iplmskbits.h"
+
+/* scanline filling for color frame buffer
+ written by drewry, oct 1986 modified by smarks
+ changes for compatibility with Little-endian systems Jul 1987; MIT:yba.
+
+ these routines all clip. they assume that anything that has called
+them has already translated the points (i.e. pGC->miTranslate is
+non-zero, which is howit gets set in iplCreateGC().)
+
+ the number of new scnalines created by clipping ==
+MaxRectsPerBand * nSpans.
+
+ FillSolid is overloaded to be used for OpaqueStipple as well,
+if fgPixel == bgPixel.
+Note that for solids, PrivGC.rop == PrivGC.ropOpStip
+
+
+ FillTiled is overloaded to be used for OpaqueStipple, if
+fgPixel != bgPixel. based on the fill style, it uses
+{RotatedTile, gc.alu} or {RotatedStipple, PrivGC.ropOpStip}
+*/
+
+#ifdef notdef
+#include <stdio.h>
+static
+dumpspans(n, ppt, pwidth)
+ int n;
+ DDXPointPtr ppt;
+ int *pwidth;
+{
+ fprintf(stderr,"%d spans\n", n);
+ while (n--) {
+ fprintf(stderr, "[%d,%d] %d\n", ppt->x, ppt->y, *pwidth);
+ ppt++;
+ pwidth++;
+ }
+ fprintf(stderr, "\n");
+}
+#endif
+
+/* Fill spans with tiles that aren't 32 bits wide */
+void
+iplUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+DrawablePtr pDrawable;
+GC *pGC;
+int nInit; /* number of spans to fill */
+DDXPointPtr pptInit; /* pointer to list of start points */
+int *pwidthInit; /* pointer to list of n widths */
+int fSorted;
+{
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ void (*fill)();
+ int xrot, yrot;
+
+ if (!(pGC->planemask))
+ return;
+
+ if (pGC->tile.pixmap->drawable.width & INTER_PIM)
+ {
+ fill = iplFillSpanTileOddGeneral;
+ if ((pGC->planemask & INTER_PMSK) == INTER_PMSK)
+ {
+ if (pGC->alu == GXcopy)
+ fill = iplFillSpanTileOddCopy;
+ }
+ }
+ else
+ {
+ fill = iplFillSpanTile32sGeneral;
+ if ((pGC->planemask & INTER_PMSK) == INTER_PMSK)
+ {
+ if (pGC->alu == GXcopy)
+ fill = iplFillSpanTile32sCopy;
+ }
+ }
+ n = nInit * miFindMaxBand( iplGetCompositeClip(pGC) );
+ if ( n == 0 )
+ return;
+ pwidth = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ ppt = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!ppt || !pwidth)
+ {
+ if (ppt) DEALLOCATE_LOCAL(ppt);
+ if (pwidth) DEALLOCATE_LOCAL(pwidth);
+ return;
+ }
+ n = miClipSpans( iplGetCompositeClip(pGC),
+ pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ xrot = pDrawable->x + pGC->patOrg.x;
+ yrot = pDrawable->y + pGC->patOrg.y;
+
+ (*fill) (pDrawable, n, ppt, pwidth, pGC->tile.pixmap, xrot, yrot, pGC->alu, pGC->planemask);
+
+ DEALLOCATE_LOCAL(ppt);
+ DEALLOCATE_LOCAL(pwidth);
+}
+
+/* Fill spans with stipples that aren't 32 bits wide */
+void
+iplUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+DrawablePtr pDrawable;
+GC *pGC;
+int nInit; /* number of spans to fill */
+DDXPointPtr pptInit; /* pointer to list of start points */
+int *pwidthInit; /* pointer to list of n widths */
+int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ int iline; /* first line of tile to use */
+ INTER_DECLAREG(*addrgBase); /* pointer to start of bitmap */
+ int ngwidth; /* width in groups of bitmap */
+ INTER_DECLAREG(*pdst); /* pointer to current group in bitmap */
+ PixmapPtr pStipple; /* pointer to stipple we want to fill with */
+ register int w;
+ int width, x, xrem, xSrc, ySrc;
+ INTER_DECLAREGP(tmpSrc);
+ INTER_DECLAREGP(tmpDst1);
+ INTER_DECLAREGP(tmpDst2);
+ int stwidth, stippleWidth;
+ unsigned long *psrcS;
+ int rop, stiprop;
+ int stippleHeight;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ INTER_DECLARERRAXP(bgfill);
+ INTER_DECLARERRAXP(fgfill);
+
+ if (!(pGC->planemask))
+ return;
+
+ n = nInit * miFindMaxBand( iplGetCompositeClip(pGC) );
+ if ( n == 0 )
+ return;
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans( iplGetCompositeClip(pGC),
+ pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+ rop = pGC->alu;
+ if (pGC->fillStyle == FillStippled) {
+ switch (rop) {
+ case GXand:
+ case GXcopy:
+ case GXnoop:
+ case GXor:
+ stiprop = rop;
+ break;
+ default:
+ stiprop = rop;
+ rop = GXcopy;
+ }
+ }
+ INTER_PFILL(pGC->fgPixel, fgfill);
+ INTER_PFILL(pGC->bgPixel, bgfill);
+
+ /*
+ * OK, so what's going on here? We have two Drawables:
+ *
+ * The Stipple:
+ * Depth = 1
+ * Width = stippleWidth
+ * Words per scanline = stwidth
+ * Pointer to pixels = pStipple->devPrivate.ptr
+ */
+ pStipple = pGC->stipple;
+
+ stwidth = pStipple->devKind / MFB_PGSZB;
+ stippleWidth = pStipple->drawable.width;
+ stippleHeight = pStipple->drawable.height;
+
+ /*
+ * The Target:
+ * Depth = INTER_PLANES
+ * Width = determined from *pwidth
+ * Groups per scanline = ngwidth
+ * Pointer to pixels = addrgBase
+ */
+
+ iplGetGroupWidthAndPointer (pDrawable, ngwidth, addrgBase)
+
+ /* this replaces rotating the stipple. Instead we just adjust the offset
+ * at which we start grabbing bits from the stipple.
+ * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
+ * so that iline and xrem always stay within the stipple bounds.
+ */
+ modulus (pGC->patOrg.x, stippleWidth, xSrc);
+ xSrc += pDrawable->x - stippleWidth;
+ modulus (pGC->patOrg.y, stippleHeight, ySrc);
+ ySrc += pDrawable->y - stippleHeight;
+
+ while (n--)
+ {
+ iline = (ppt->y - ySrc) % stippleHeight;
+ x = ppt->x;
+ pdst = addrgBase + (ppt->y * ngwidth);
+ psrcS = (unsigned long *) pStipple->devPrivate.ptr + (iline * stwidth);
+
+ if (*pwidth)
+ {
+ width = *pwidth;
+ while(width > 0)
+ {
+ int xtemp, tmpx;
+ register unsigned long *ptemp;
+ INTER_DECLAREG(*pdsttmp);
+ /*
+ * Do a stripe through the stipple & destination w pixels
+ * wide. w is not more than:
+ * - the width of the destination
+ * - the width of the stipple
+ * - the distance between x and the next word
+ * boundary in the destination
+ * - the distance between x and the next word
+ * boundary in the stipple
+ */
+
+ /* width of dest/stipple */
+ xrem = (x - xSrc) % stippleWidth;
+ w = min((stippleWidth - xrem), width);
+ /* dist to word bound in dest */
+ w = min(w, INTER_PPG - (x & INTER_PIM));
+ /* dist to word bound in stip */
+ w = min(w, MFB_PPW - (x & MFB_PIM));
+
+ xtemp = (xrem & MFB_PIM);
+ ptemp = (unsigned long *)(psrcS + (xrem >> MFB_PWSH));
+ tmpx = x & INTER_PIM;
+ pdsttmp = pdst + (x >> INTER_PGSH) * INTER_PLANES;
+ switch ( pGC->fillStyle ) {
+ case FillOpaqueStippled:
+ INTER_getstipplepixelsb(ptemp,xtemp,w,bgfill,fgfill,
+ tmpDst1);
+ INTER_putbitsrop(tmpDst1, tmpx, w, pdsttmp,
+ pGC->planemask, rop);
+ break;
+ case FillStippled:
+ /* Fill tmpSrc with the source pixels */
+ INTER_getbits(pdsttmp, tmpx, w, tmpSrc);
+ INTER_getstipplepixels(ptemp, xtemp, w, 0, tmpSrc,
+ tmpDst1);
+ if (rop != stiprop) {
+ INTER_putbitsrop(fgfill, 0, w, tmpSrc, pGC->planemask, stiprop);
+ } else {
+ INTER_COPY(fgfill, tmpSrc);
+ }
+ INTER_getstipplepixels(ptemp, xtemp, w, 1, tmpSrc, tmpDst2);
+ INTER_OR(tmpDst1,tmpDst2,tmpDst2);
+ INTER_putbitsrop(tmpDst2, tmpx, w, pdsttmp,
+ pGC->planemask, rop);
+ }
+ x += w;
+ width -= w;
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplgc.c b/nx-X11/programs/Xserver/iplan2p4/iplgc.c
new file mode 100644
index 000000000..1cbcb7522
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplgc.c
@@ -0,0 +1,786 @@
+/* $XFree86: xc/programs/Xserver/iplan2p4/iplgc.c,v 3.0 1996/08/18 01:54:45 dawes Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* $XConsortium: iplgc.c,v 5.62 94/04/17 20:28:49 dpw Exp $ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "ipl.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "region.h"
+
+#include "mistruct.h"
+#include "mibstore.h"
+#include "migc.h"
+
+#include "iplmskbits.h"
+
+# ifdef WriteBitGroup
+# define useTEGlyphBlt iplImageGlyphBlt8
+# else
+# define useTEGlyphBlt iplTEGlyphBlt
+# endif
+
+#ifdef WriteBitGroup
+# define useImageGlyphBlt iplImageGlyphBlt8
+# define usePolyGlyphBlt iplPolyGlyphBlt8
+#else
+# define useImageGlyphBlt miImageGlyphBlt
+# define usePolyGlyphBlt miPolyGlyphBlt
+#endif
+
+#ifdef FOUR_BIT_CODE
+# define usePushPixels iplPushPixels8
+#else
+# define usePushPixels mfbPushPixels
+#endif
+
+#ifdef PIXEL_ADDR
+# define ZeroPolyArc iplZeroPolyArcSS8Copy
+#else
+# define ZeroPolyArc miZeroPolyArc
+#endif
+
+GCFuncs iplGCFuncs = {
+ iplValidateGC,
+ miChangeGC,
+ miCopyGC,
+ miDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip,
+};
+
+GCOps iplTEOps1Rect = {
+ iplSolidSpansCopy,
+ iplSetSpans,
+ iplPutImage,
+ iplCopyArea,
+ iplCopyPlane,
+ iplPolyPoint,
+#ifdef PIXEL_ADDR
+ ipl8LineSS1Rect,
+ ipl8SegmentSS1Rect,
+#else
+ iplLineSS,
+ iplSegmentSS,
+#endif
+ miPolyRectangle,
+ ZeroPolyArc,
+ iplFillPoly1RectCopy,
+ iplPolyFillRect,
+ iplPolyFillArcSolidCopy,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ useTEGlyphBlt,
+ usePolyGlyphBlt,
+ usePushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps iplNonTEOps1Rect = {
+ iplSolidSpansCopy,
+ iplSetSpans,
+ iplPutImage,
+ iplCopyArea,
+ iplCopyPlane,
+ iplPolyPoint,
+#ifdef PIXEL_ADDR
+ ipl8LineSS1Rect,
+ ipl8SegmentSS1Rect,
+#else
+ iplLineSS,
+ iplSegmentSS,
+#endif
+ miPolyRectangle,
+ ZeroPolyArc,
+ iplFillPoly1RectCopy,
+ iplPolyFillRect,
+ iplPolyFillArcSolidCopy,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ useImageGlyphBlt,
+ usePolyGlyphBlt,
+ usePushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps iplTEOps = {
+ iplSolidSpansCopy,
+ iplSetSpans,
+ iplPutImage,
+ iplCopyArea,
+ iplCopyPlane,
+ iplPolyPoint,
+ iplLineSS,
+ iplSegmentSS,
+ miPolyRectangle,
+ ZeroPolyArc,
+ miFillPolygon,
+ iplPolyFillRect,
+ iplPolyFillArcSolidCopy,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ useTEGlyphBlt,
+ usePolyGlyphBlt,
+ usePushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps iplNonTEOps = {
+ iplSolidSpansCopy,
+ iplSetSpans,
+ iplPutImage,
+ iplCopyArea,
+ iplCopyPlane,
+ iplPolyPoint,
+ iplLineSS,
+ iplSegmentSS,
+ miPolyRectangle,
+#ifdef PIXEL_ADDR
+ iplZeroPolyArcSS8Copy,
+#else
+ miZeroPolyArc,
+#endif
+ miFillPolygon,
+ iplPolyFillRect,
+ iplPolyFillArcSolidCopy,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ useImageGlyphBlt,
+ usePolyGlyphBlt,
+ usePushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps *
+iplMatchCommon (pGC, devPriv)
+ GCPtr pGC;
+ iplPrivGCPtr devPriv;
+{
+ if (pGC->lineWidth != 0)
+ return 0;
+ if (pGC->lineStyle != LineSolid)
+ return 0;
+ if (pGC->fillStyle != FillSolid)
+ return 0;
+ if (devPriv->rop != GXcopy)
+ return 0;
+ if (pGC->font &&
+ FONTMAXBOUNDS(pGC->font,rightSideBearing) -
+ FONTMINBOUNDS(pGC->font,leftSideBearing) <= 32 &&
+ FONTMINBOUNDS(pGC->font,characterWidth) >= 0)
+ {
+ if (TERMINALFONT(pGC->font)
+#ifdef FOUR_BIT_CODE
+ && FONTMAXBOUNDS(pGC->font,characterWidth) >= PGSZB
+#endif
+ )
+#ifdef NO_ONE_RECT
+ return &iplTEOps1Rect;
+#else
+ if (devPriv->oneRect)
+ return &iplTEOps1Rect;
+ else
+ return &iplTEOps;
+#endif
+ else
+#ifdef NO_ONE_RECT
+ return &iplNonTEOps1Rect;
+#else
+ if (devPriv->oneRect)
+ return &iplNonTEOps1Rect;
+ else
+ return &iplNonTEOps;
+#endif
+ }
+ return 0;
+}
+
+Bool
+iplCreateGC(pGC)
+ register GCPtr pGC;
+{
+ iplPrivGC *pPriv;
+
+ if (PixmapWidthPaddingInfo[pGC->depth].padPixelsLog2 == LOG2_BITMAP_PAD)
+ return (mfbCreateGC(pGC));
+ pGC->clientClip = NULL;
+ pGC->clientClipType = CT_NONE;
+
+ /*
+ * some of the output primitives aren't really necessary, since they
+ * will be filled in ValidateGC because of dix/CreateGC() setting all
+ * the change bits. Others are necessary because although they depend
+ * on being a color frame buffer, they don't change
+ */
+
+ pGC->ops = &iplNonTEOps;
+ pGC->funcs = &iplGCFuncs;
+
+ /* ipl wants to translate before scan conversion */
+ pGC->miTranslate = 1;
+
+ pPriv = iplGetGCPrivate(pGC);
+ pPriv->rop = pGC->alu;
+ pPriv->oneRect = FALSE;
+ pGC->fExpose = TRUE;
+ pGC->freeCompClip = FALSE;
+ pGC->pRotatedPixmap = (PixmapPtr) NULL;
+ return TRUE;
+}
+
+/* Clipping conventions
+ if the drawable is a window
+ CT_REGION ==> pCompositeClip really is the composite
+ CT_other ==> pCompositeClip is the window clip region
+ if the drawable is a pixmap
+ CT_REGION ==> pCompositeClip is the translated client region
+ clipped to the pixmap boundary
+ CT_other ==> pCompositeClip is the pixmap bounding box
+*/
+
+void
+iplValidateGC(pGC, changes, pDrawable)
+ register GCPtr pGC;
+ unsigned long changes;
+ DrawablePtr pDrawable;
+{
+ int mask; /* stateChanges */
+ int index; /* used for stepping through bitfields */
+ int new_rrop;
+ int new_line, new_text, new_fillspans, new_fillarea;
+ int new_rotate;
+ int xrot, yrot;
+ /* flags for changing the proc vector */
+ iplPrivGCPtr devPriv;
+ int oneRect;
+
+ new_rotate = pGC->lastWinOrg.x != pDrawable->x ||
+ pGC->lastWinOrg.y != pDrawable->y;
+
+ pGC->lastWinOrg.x = pDrawable->x;
+ pGC->lastWinOrg.y = pDrawable->y;
+ devPriv = iplGetGCPrivate(pGC);
+
+ new_rrop = FALSE;
+ new_line = FALSE;
+ new_text = FALSE;
+ new_fillspans = FALSE;
+ new_fillarea = FALSE;
+
+ /*
+ * if the client clip is different or moved OR the subwindowMode has
+ * changed OR the window's clip has changed since the last validation
+ * we need to recompute the composite clip
+ */
+
+ if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
+ (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
+ )
+ {
+ miComputeCompositeClip (pGC, pDrawable);
+#ifdef NO_ONE_RECT
+ devPriv->oneRect = FALSE;
+#else
+ oneRect = REGION_NUM_RECTS(pGC->pCompositeClip) == 1;
+ if (oneRect != devPriv->oneRect)
+ new_line = TRUE;
+ devPriv->oneRect = oneRect;
+#endif
+ }
+
+ mask = changes;
+ while (mask) {
+ index = lowbit (mask);
+ mask &= ~index;
+
+ /*
+ * this switch acculmulates a list of which procedures might have
+ * to change due to changes in the GC. in some cases (e.g.
+ * changing one 16 bit tile for another) we might not really need
+ * a change, but the code is being paranoid. this sort of batching
+ * wins if, for example, the alu and the font have been changed,
+ * or any other pair of items that both change the same thing.
+ */
+ switch (index) {
+ case GCFunction:
+ case GCForeground:
+ new_rrop = TRUE;
+ break;
+ case GCPlaneMask:
+ new_rrop = TRUE;
+ new_text = TRUE;
+ break;
+ case GCBackground:
+ break;
+ case GCLineStyle:
+ case GCLineWidth:
+ new_line = TRUE;
+ break;
+ case GCJoinStyle:
+ case GCCapStyle:
+ break;
+ case GCFillStyle:
+ new_text = TRUE;
+ new_fillspans = TRUE;
+ new_line = TRUE;
+ new_fillarea = TRUE;
+ break;
+ case GCFillRule:
+ break;
+ case GCTile:
+ new_fillspans = TRUE;
+ new_fillarea = TRUE;
+ break;
+
+ case GCStipple:
+ if (pGC->stipple)
+ {
+ int width = pGC->stipple->drawable.width;
+ PixmapPtr nstipple;
+
+ if ((width <= INTER_PGSZ) && !(width & (width - 1)) &&
+ (nstipple = iplCopyPixmap(pGC->stipple)))
+ {
+ iplPadPixmap(nstipple);
+ (*pGC->pScreen->DestroyPixmap)(pGC->stipple);
+ pGC->stipple = nstipple;
+ }
+ }
+ new_fillspans = TRUE;
+ new_fillarea = TRUE;
+ break;
+
+ case GCTileStipXOrigin:
+ new_rotate = TRUE;
+ break;
+
+ case GCTileStipYOrigin:
+ new_rotate = TRUE;
+ break;
+
+ case GCFont:
+ new_text = TRUE;
+ break;
+ case GCSubwindowMode:
+ break;
+ case GCGraphicsExposures:
+ break;
+ case GCClipXOrigin:
+ break;
+ case GCClipYOrigin:
+ break;
+ case GCClipMask:
+ break;
+ case GCDashOffset:
+ break;
+ case GCDashList:
+ break;
+ case GCArcMode:
+ break;
+ default:
+ break;
+ }
+ }
+
+ /*
+ * If the drawable has changed, ensure suitable
+ * entries are in the proc vector.
+ */
+ if (pDrawable->serialNumber != (pGC->serialNumber & (DRAWABLE_SERIAL_BITS))) {
+ new_fillspans = TRUE; /* deal with FillSpans later */
+ }
+
+ if (new_rotate || new_fillspans)
+ {
+ Bool new_pix = FALSE;
+
+ xrot = pGC->patOrg.x + pDrawable->x;
+ yrot = pGC->patOrg.y + pDrawable->y;
+
+ switch (pGC->fillStyle)
+ {
+ case FillTiled:
+ if (!pGC->tileIsPixel)
+ {
+ int width = pGC->tile.pixmap->drawable.width;
+
+ if ((width <= INTER_PGSZ) && !(width & (width - 1)))
+ {
+ iplCopyRotatePixmap(pGC->tile.pixmap,
+ &pGC->pRotatedPixmap,
+ xrot, yrot);
+ new_pix = TRUE;
+ }
+ }
+ break;
+#ifdef FOUR_BIT_CODE
+ case FillStippled:
+ case FillOpaqueStippled:
+ {
+ int width = pGC->stipple->drawable.width;
+
+ if ((width <= INTER_PGSZ) && !(width & (width - 1)))
+ {
+ mfbCopyRotatePixmap(pGC->stipple,
+ &pGC->pRotatedPixmap, xrot, yrot);
+ new_pix = TRUE;
+ }
+ }
+ break;
+#endif
+ }
+ if (!new_pix && pGC->pRotatedPixmap)
+ {
+ (*pGC->pScreen->DestroyPixmap)(pGC->pRotatedPixmap);
+ pGC->pRotatedPixmap = (PixmapPtr) NULL;
+ }
+ }
+
+ if (new_rrop)
+ {
+ int old_rrop;
+
+ old_rrop = devPriv->rop;
+ devPriv->rop = iplReduceRasterOp(pGC->alu, pGC->fgPixel,
+ pGC->planemask, devPriv->andg, devPriv->xorg);
+ if (old_rrop == devPriv->rop)
+ new_rrop = FALSE;
+ else
+ {
+#ifdef PIXEL_ADDR
+ new_line = TRUE;
+#endif
+#ifdef WriteBitGroup
+ new_text = TRUE;
+#endif
+ new_fillspans = TRUE;
+ new_fillarea = TRUE;
+ }
+ }
+
+ if (new_rrop || new_fillspans || new_text || new_fillarea || new_line)
+ {
+ GCOps *newops;
+
+ if (newops = iplMatchCommon (pGC, devPriv))
+ {
+ if (pGC->ops->devPrivate.val)
+ miDestroyGCOps (pGC->ops);
+ pGC->ops = newops;
+ new_rrop = new_line = new_fillspans = new_text = new_fillarea = 0;
+ }
+ else
+ {
+ if (!pGC->ops->devPrivate.val)
+ {
+ pGC->ops = miCreateGCOps (pGC->ops);
+ pGC->ops->devPrivate.val = 1;
+ }
+ }
+ }
+
+ /* deal with the changes we've collected */
+ if (new_line)
+ {
+ pGC->ops->FillPolygon = miFillPolygon;
+#ifdef NO_ONE_RECT
+ if (pGC->fillStyle == FillSolid)
+ {
+ switch (devPriv->rop) {
+ case GXcopy:
+ pGC->ops->FillPolygon = iplFillPoly1RectCopy;
+ break;
+ default:
+ pGC->ops->FillPolygon = iplFillPoly1RectGeneral;
+ break;
+ }
+ }
+#else
+ if (devPriv->oneRect && pGC->fillStyle == FillSolid)
+ {
+ switch (devPriv->rop) {
+ case GXcopy:
+ pGC->ops->FillPolygon = iplFillPoly1RectCopy;
+ break;
+ default:
+ pGC->ops->FillPolygon = iplFillPoly1RectGeneral;
+ break;
+ }
+ }
+#endif
+ if (pGC->lineWidth == 0)
+ {
+#ifdef PIXEL_ADDR
+ if ((pGC->lineStyle == LineSolid) && (pGC->fillStyle == FillSolid))
+ {
+ switch (devPriv->rop)
+ {
+ case GXxor:
+ pGC->ops->PolyArc = iplZeroPolyArcSS8Xor;
+ break;
+ case GXcopy:
+ pGC->ops->PolyArc = iplZeroPolyArcSS8Copy;
+ break;
+ default:
+ pGC->ops->PolyArc = iplZeroPolyArcSS8General;
+ break;
+ }
+ }
+ else
+#endif
+ pGC->ops->PolyArc = miZeroPolyArc;
+ }
+ else
+ pGC->ops->PolyArc = miPolyArc;
+ pGC->ops->PolySegment = miPolySegment;
+ switch (pGC->lineStyle)
+ {
+ case LineSolid:
+ if(pGC->lineWidth == 0)
+ {
+ if (pGC->fillStyle == FillSolid)
+ {
+#if defined(PIXEL_ADDR) && !defined(NO_ONE_RECT)
+ if (devPriv->oneRect &&
+ ((pDrawable->x >= pGC->pScreen->width - 32768) &&
+ (pDrawable->y >= pGC->pScreen->height - 32768)))
+ {
+ pGC->ops->Polylines = ipl8LineSS1Rect;
+ pGC->ops->PolySegment = ipl8SegmentSS1Rect;
+ } else
+#endif
+#ifdef NO_ONE_RECT
+ {
+ pGC->ops->Polylines = ipl8LineSS1Rect;
+ pGC->ops->PolySegment = ipl8SegmentSS1Rect;
+ }
+#else
+ {
+ pGC->ops->Polylines = iplLineSS;
+ pGC->ops->PolySegment = iplSegmentSS;
+ }
+#endif
+ }
+ else
+ pGC->ops->Polylines = miZeroLine;
+ }
+ else
+ pGC->ops->Polylines = miWideLine;
+ break;
+ case LineOnOffDash:
+ case LineDoubleDash:
+ if (pGC->lineWidth == 0 && pGC->fillStyle == FillSolid)
+ {
+ pGC->ops->Polylines = iplLineSD;
+ pGC->ops->PolySegment = iplSegmentSD;
+ } else
+ pGC->ops->Polylines = miWideDash;
+ break;
+ }
+ }
+
+ if (new_text && (pGC->font))
+ {
+ if (FONTMAXBOUNDS(pGC->font,rightSideBearing) -
+ FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 ||
+ FONTMINBOUNDS(pGC->font,characterWidth) < 0)
+ {
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
+ }
+ else
+ {
+#ifdef WriteBitGroup
+ if (pGC->fillStyle == FillSolid)
+ {
+ if (devPriv->rop == GXcopy)
+ pGC->ops->PolyGlyphBlt = iplPolyGlyphBlt8;
+ else
+#ifdef FOUR_BIT_CODE
+ pGC->ops->PolyGlyphBlt = iplPolyGlyphRop8;
+#else
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+#endif
+ }
+ else
+#endif
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ /* special case ImageGlyphBlt for terminal emulator fonts */
+#if !defined(WriteBitGroup)
+ if (TERMINALFONT(pGC->font) &&
+ (pGC->planemask & INTER_PMSK) == INTER_PMSK
+#ifdef FOUR_BIT_CODE
+ && FONTMAXBOUNDS(pGC->font,characterWidth) >= PGSZB
+#endif
+ )
+ {
+ pGC->ops->ImageGlyphBlt = useTEGlyphBlt;
+ }
+ else
+#endif
+ {
+#ifdef WriteBitGroup
+ if (devPriv->rop == GXcopy &&
+ pGC->fillStyle == FillSolid &&
+ (pGC->planemask & INTER_PMSK) == INTER_PMSK)
+ pGC->ops->ImageGlyphBlt = iplImageGlyphBlt8;
+ else
+#endif
+ pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
+ }
+ }
+ }
+
+
+ if (new_fillspans) {
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ switch (devPriv->rop) {
+ case GXcopy:
+ pGC->ops->FillSpans = iplSolidSpansCopy;
+ break;
+ case GXxor:
+ pGC->ops->FillSpans = iplSolidSpansXor;
+ break;
+ default:
+ pGC->ops->FillSpans = iplSolidSpansGeneral;
+ break;
+ }
+ break;
+ case FillTiled:
+ if (pGC->pRotatedPixmap)
+ {
+ if (pGC->alu == GXcopy && (pGC->planemask & INTER_PMSK) == INTER_PMSK)
+ pGC->ops->FillSpans = iplTile32FSCopy;
+ else
+ pGC->ops->FillSpans = iplTile32FSGeneral;
+ }
+ else
+ pGC->ops->FillSpans = iplUnnaturalTileFS;
+ break;
+ case FillStippled:
+#ifdef FOUR_BIT_CODE
+ if (pGC->pRotatedPixmap)
+ pGC->ops->FillSpans = ipl8Stipple32FS;
+ else
+#endif
+ pGC->ops->FillSpans = iplUnnaturalStippleFS;
+ break;
+ case FillOpaqueStippled:
+#ifdef FOUR_BIT_CODE
+ if (pGC->pRotatedPixmap)
+ pGC->ops->FillSpans = ipl8OpaqueStipple32FS;
+ else
+#endif
+ pGC->ops->FillSpans = iplUnnaturalStippleFS;
+ break;
+ default:
+ FatalError("iplValidateGC: illegal fillStyle\n");
+ }
+ } /* end of new_fillspans */
+
+ if (new_fillarea) {
+#ifndef FOUR_BIT_CODE
+ pGC->ops->PolyFillRect = miPolyFillRect;
+ if (pGC->fillStyle == FillSolid || pGC->fillStyle == FillTiled)
+ {
+ pGC->ops->PolyFillRect = iplPolyFillRect;
+ }
+#endif
+#ifdef FOUR_BIT_CODE
+ pGC->ops->PushPixels = mfbPushPixels;
+ if (pGC->fillStyle == FillSolid && devPriv->rop == GXcopy)
+ pGC->ops->PushPixels = iplPushPixels8;
+#endif
+ pGC->ops->PolyFillArc = miPolyFillArc;
+ if (pGC->fillStyle == FillSolid)
+ {
+ switch (devPriv->rop)
+ {
+ case GXcopy:
+ pGC->ops->PolyFillArc = iplPolyFillArcSolidCopy;
+ break;
+ default:
+ pGC->ops->PolyFillArc = iplPolyFillArcSolidGeneral;
+ break;
+ }
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplgetsp.c b/nx-X11/programs/Xserver/iplan2p4/iplgetsp.c
new file mode 100644
index 000000000..c325ad1fe
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplgetsp.c
@@ -0,0 +1,166 @@
+/* $XFree86$ */
+/* $XConsortium: iplgetsp.c,v 5.14 94/04/17 20:28:50 dpw Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+
+#include "misc.h"
+#include "region.h"
+#include "gc.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "ipl.h"
+#include "iplmskbits.h"
+#include "iplpack.h"
+
+/* GetSpans -- for each span, gets bits from drawable starting at ppt[i]
+ * and continuing for pwidth[i] bits
+ * Each scanline returned will be server scanline padded, i.e., it will come
+ * out to an integral number of words.
+ */
+void
+iplGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pchardstStart)
+ DrawablePtr pDrawable; /* drawable from which to get bits */
+ int wMax; /* largest value of all *pwidths */
+ register DDXPointPtr ppt; /* points to start copying from */
+ int *pwidth; /* list of number of bits to copy */
+ int nspans; /* number of scanlines to copy */
+ char *pchardstStart; /* where to put the bits */
+{
+ unsigned long *pdst = (unsigned long *)pchardstStart;
+ INTER_DECLAREG(*psrc); /* where to get the bits */
+ INTER_DECLAREGP(tmpSrc); /* scratch buffer for bits */
+ INTER_DECLAREG(*psrcBase); /* start of src bitmap */
+ int widthSrc; /* width of pixmap in bytes */
+ register DDXPointPtr pptLast; /* one past last point to get */
+ int xEnd; /* last pixel to copy from */
+ register int nstart;
+ int nend;
+ INTER_DECLAREG(startmask);
+ INTER_DECLAREG(endmask);
+ int nlMiddle, nl, srcBit;
+ int w,longs;
+ INTER_DECLAREG(*tmppdst);
+ INTER_DECLAREG(*ipdst);
+
+ switch (pDrawable->bitsPerPixel) {
+ case 1:
+ mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pchardstStart);
+ return;
+ case INTER_PLANES:
+ break;
+ default:
+ FatalError("iplGetSpans: invalid depth\n");
+ }
+
+ longs = NUM_LONGS(INTER_PLANES, 0, wMax);
+ tmppdst = (unsigned short *)
+ ALLOCATE_LOCAL(NUM_TEMP_BYTES(INTER_PLANES, longs));
+ iplGetGroupWidthAndPointer (pDrawable, widthSrc, psrcBase)
+
+ pptLast = ppt + nspans;
+ while(ppt < pptLast)
+ {
+ xEnd = min(ppt->x + *pwidth, (widthSrc / INTER_PLANES) << INTER_PGSH);
+ psrc = psrcBase + ppt->y * widthSrc +
+ (ppt->x >> INTER_PGSH) * INTER_PLANES;
+ w = xEnd - ppt->x;
+ srcBit = ppt->x & INTER_PIM;
+ ipdst = tmppdst;
+
+ if (srcBit + w <= INTER_PPG)
+ {
+ INTER_getbits(psrc, srcBit, w, tmpSrc);
+ INTER_putbits(tmpSrc, 0, w, ipdst, ~((unsigned long)0));
+ }
+ else
+ {
+ INTER_maskbits(ppt->x, w, startmask, endmask, nlMiddle);
+ nstart = 0;
+ if (startmask)
+ {
+ nstart = INTER_PPG - srcBit;
+ INTER_getbits(psrc, srcBit, nstart, tmpSrc);
+ INTER_putbits(tmpSrc, 0, nstart, ipdst, ~((unsigned long)0));
+ if(srcBit + nstart >= INTER_PPG)
+ INTER_NEXT_GROUP(psrc);
+ }
+ nl = nlMiddle;
+ while (nl--)
+ {
+ INTER_putbits(psrc, nstart, INTER_PPG, ipdst, ~((unsigned long)0));
+ INTER_NEXT_GROUP(psrc);
+ INTER_NEXT_GROUP(ipdst);
+ }
+ if (endmask)
+ {
+ nend = xEnd & INTER_PIM;
+ INTER_getbits(psrc, 0, nend, tmpSrc);
+ INTER_putbits(tmpSrc, nstart, nend, ipdst, ~((unsigned long)0));
+ }
+ }
+ longs=(w * INTER_PLANES + 31)/32;
+ iplPackLine(INTER_PLANES, longs, tmppdst, pdst);
+ pdst+=longs;
+ ppt++;
+ pwidth++;
+ }
+ DEALLOCATE_LOCAL(tmppdst);
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplhrzvert.c b/nx-X11/programs/Xserver/iplan2p4/iplhrzvert.c
new file mode 100644
index 000000000..45faaa1cb
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplhrzvert.c
@@ -0,0 +1,128 @@
+/* $XFree86$ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: iplhrzvert.c,v 1.8 94/04/17 20:28:51 dpw Exp $ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "gc.h"
+#include "window.h"
+#include "pixmap.h"
+#include "region.h"
+
+#include "ipl.h"
+
+#include "iplmskbits.h"
+
+/* horizontal solid line
+ abs(len) > 1
+*/
+iplHorzS(rop, andp, xorp, addrg, ngwidth, x1, y1, len)
+register int rop;
+INTER_DECLARERRAX(andp);
+INTER_DECLARERRAX(xorp);
+INTER_DECLAREG(*addrg); /* pointer to base of bitmap */
+int ngwidth; /* width in groups of bitmap */
+int x1; /* initial point */
+int y1;
+int len; /* length of line */
+{
+ register int ngmiddle;
+ INTER_DECLAREG(startmask);
+ INTER_DECLAREG(endmask);
+
+ addrg = addrg + y1 * ngwidth + (x1 >> INTER_PGSH) * INTER_PLANES;
+ /* all bits inside same group */
+ if ( ((x1 & INTER_PIM) + len) < INTER_PPG)
+ {
+ INTER_maskpartialbits(x1, len, startmask);
+ INTER_DoMaskRRop(addrg, andp, xorp, startmask, addrg);
+ }
+ else
+ {
+ INTER_maskbits(x1, len, startmask, endmask, ngmiddle);
+ if (startmask)
+ {
+ INTER_DoMaskRRop(addrg, andp, xorp, startmask, addrg);
+ addrg += INTER_PLANES;
+ }
+ while (ngmiddle--)
+ {
+ INTER_DoRRop(addrg, andp, xorp, addrg);
+ addrg += INTER_PLANES;
+ }
+ if (endmask)
+ INTER_DoMaskRRop(addrg, andp, xorp, endmask, addrg);
+ }
+}
+
+/* vertical solid line */
+
+iplVertS(rop, andp, xorp, addrg, ngwidth, x1, y1, len)
+int rop;
+INTER_DECLARERRAX(andp);
+INTER_DECLARERRAX(xorp);
+INTER_DECLAREG(*addrg); /* pointer to base of bitmap */
+register int ngwidth; /* width in groups of bitmap */
+int x1, y1; /* initial point */
+register int len; /* length of line */
+{
+ addrg = addrg + (y1 * ngwidth) + (x1 >> INTER_PGSH) * INTER_PLANES;
+ while (len--)
+ {
+ INTER_DoMaskRRop(addrg, andp, xorp, iplmask[x1 & INTER_PIM], addrg);
+ addrg += ngwidth;
+ }
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplimage.c b/nx-X11/programs/Xserver/iplan2p4/iplimage.c
new file mode 100644
index 000000000..5b72b885f
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplimage.c
@@ -0,0 +1,87 @@
+/* $XFree86$ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: iplimage.c,v 1.18 94/04/17 20:28:52 dpw Exp $ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "ipl.h"
+#include "servermd.h"
+
+void
+iplPutImage(pDraw, pGC, depth, x, y, w, h, leftPad, format, pImage)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int depth, x, y, w, h;
+ int leftPad;
+ int format;
+ char *pImage;
+{
+ miPutImage(pDraw, pGC, depth, x, y, w, h, leftPad, format, pImage);
+}
+
+void
+iplGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine)
+ DrawablePtr pDrawable;
+ int sx, sy, w, h;
+ unsigned int format;
+ unsigned long planeMask;
+ char *pdstLine;
+{
+ miGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplline.c b/nx-X11/programs/Xserver/iplan2p4/iplline.c
new file mode 100644
index 000000000..19d078cb2
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplline.c
@@ -0,0 +1,758 @@
+/* $XFree86: xc/programs/Xserver/iplan2p4/iplline.c,v 3.0 1996/08/18 01:54:50 dawes Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XConsortium: iplline.c,v 1.23 94/04/17 20:28:53 dpw Exp $ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "mistruct.h"
+
+#include "ipl.h"
+#include "miline.h"
+
+#include "iplmskbits.h"
+
+/* single-pixel lines on a color frame buffer
+
+ NON-SLOPED LINES
+ horizontal lines are always drawn left to right; we have to
+move the endpoints right by one after they're swapped.
+ horizontal lines will be confined to a single band of a
+region. the code finds that band (giving up if the lower
+bound of the band is above the line we're drawing); then it
+finds the first box in that band that contains part of the
+line. we clip the line to subsequent boxes in that band.
+ vertical lines are always drawn top to bottom (y-increasing.)
+this requires adding one to the y-coordinate of each endpoint
+after swapping.
+
+ SLOPED LINES
+ when clipping a sloped line, we bring the second point inside
+the clipping box, rather than one beyond it, and then add 1 to
+the length of the line before drawing it. this lets us use
+the same box for finding the outcodes for both endpoints. since
+the equation for clipping the second endpoint to an edge gives us
+1 beyond the edge, we then have to move the point towards the
+first point by one step on the major axis.
+ eventually, there will be a diagram here to explain what's going
+on. the method uses Cohen-Sutherland outcodes to determine
+outsideness, and a method similar to Pike's layers for doing the
+actual clipping.
+
+*/
+
+void
+#ifdef POLYSEGMENT
+iplSegmentSS (pDrawable, pGC, nseg, pSeg)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nseg;
+ register xSegment *pSeg;
+#else
+iplLineSS (pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt; /* number of points */
+ DDXPointPtr pptInit;
+#endif
+{
+ int nboxInit;
+ register int nbox;
+ BoxPtr pboxInit;
+ register BoxPtr pbox;
+#ifndef POLYSEGMENT
+ register DDXPointPtr ppt; /* pointer to list of translated points */
+#endif
+
+ unsigned int oc1; /* outcode of point 1 */
+ unsigned int oc2; /* outcode of point 2 */
+
+ INTER_DECLAREG(*addrg); /* address of destination pixmap */
+ int ngwidth; /* width in groups of destination pixmap */
+ int xorg, yorg; /* origin of window */
+
+ int adx; /* abs values of dx and dy */
+ int ady;
+ int signdx; /* sign of dx and dy */
+ int signdy;
+ int e, e1, e2; /* bresenham error and increments */
+ int len; /* length of segment */
+ int axis; /* major axis */
+ int octant;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+
+ /* a bunch of temporaries */
+ int tmp;
+ register int y1, y2;
+ register int x1, x2;
+ RegionPtr cclip;
+ iplPrivGCPtr devPriv;
+ INTER_DECLARERRAX(xor);
+ INTER_DECLARERRAX(and);
+ int alu;
+
+ devPriv = iplGetGCPrivate(pGC);
+ cclip = pGC->pCompositeClip;
+ pboxInit = REGION_RECTS(cclip);
+ nboxInit = REGION_NUM_RECTS(cclip);
+
+ iplGetGroupWidthAndPointer (pDrawable, ngwidth, addrg)
+
+ alu = devPriv->rop;
+ xor = devPriv->xorg;
+ and = devPriv->andg;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+#ifdef POLYSEGMENT
+ while (nseg--)
+#else
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while(--npt)
+#endif
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+#ifdef POLYSEGMENT
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious)
+ {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+#endif
+
+ if (x1 == x2) /* vertical line */
+ {
+ /* make the line go top to bottom of screen, keeping
+ endpoint semantics
+ */
+ if (y1 > y2)
+ {
+ register int tmp;
+
+ tmp = y2;
+ y2 = y1 + 1;
+ y1 = tmp + 1;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ y1--;
+#endif
+ }
+#ifdef POLYSEGMENT
+ else if (pGC->capStyle != CapNotLast)
+ y2++;
+#endif
+ /* get to first band that might contain part of line */
+ while ((nbox) && (pbox->y2 <= y1))
+ {
+ pbox++;
+ nbox--;
+ }
+
+ if (nbox)
+ {
+ /* stop when lower edge of box is beyond end of line */
+ while((nbox) && (y2 >= pbox->y1))
+ {
+ if ((x1 >= pbox->x1) && (x1 < pbox->x2))
+ {
+ int y1t, y2t;
+ /* this box has part of the line in it */
+ y1t = max(y1, pbox->y1);
+ y2t = min(y2, pbox->y2);
+ if (y1t != y2t)
+ {
+ iplVertS (alu, and, xor,
+ addrg, ngwidth,
+ x1, y1t, y2t-y1t);
+ }
+ }
+ nbox--;
+ pbox++;
+ }
+ }
+#ifndef POLYSEGMENT
+ y2 = ppt->y + yorg;
+#endif
+ }
+ else if (y1 == y2) /* horizontal line */
+ {
+ /* force line from left to right, keeping
+ endpoint semantics
+ */
+ if (x1 > x2)
+ {
+ register int tmp;
+
+ tmp = x2;
+ x2 = x1 + 1;
+ x1 = tmp + 1;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ x1--;
+#endif
+ }
+#ifdef POLYSEGMENT
+ else if (pGC->capStyle != CapNotLast)
+ x2++;
+#endif
+
+ /* find the correct band */
+ while( (nbox) && (pbox->y2 <= y1))
+ {
+ pbox++;
+ nbox--;
+ }
+
+ /* try to draw the line, if we haven't gone beyond it */
+ if ((nbox) && (pbox->y1 <= y1))
+ {
+ /* when we leave this band, we're done */
+ tmp = pbox->y1;
+ while((nbox) && (pbox->y1 == tmp))
+ {
+ int x1t, x2t;
+
+ if (pbox->x2 <= x1)
+ {
+ /* skip boxes until one might contain start point */
+ nbox--;
+ pbox++;
+ continue;
+ }
+
+ /* stop if left of box is beyond right of line */
+ if (pbox->x1 >= x2)
+ {
+ nbox = 0;
+ break;
+ }
+
+ x1t = max(x1, pbox->x1);
+ x2t = min(x2, pbox->x2);
+ if (x1t != x2t)
+ {
+ iplHorzS (alu, and, xor,
+ addrg, ngwidth,
+ x1t, y1, x2t-x1t);
+ }
+ nbox--;
+ pbox++;
+ }
+ }
+#ifndef POLYSEGMENT
+ x2 = ppt->x + xorg;
+#endif
+ }
+ else /* sloped line */
+ {
+ CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy,
+ 1, 1, octant);
+
+ if (adx > ady)
+ {
+ axis = X_AXIS;
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+ }
+ else
+ {
+ axis = Y_AXIS;
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ SetYMajorOctant(octant);
+ }
+
+ FIXUP_ERROR(e, octant, bias);
+
+ /* we have bresenham parameters and two points.
+ all we have to do now is clip and draw.
+ */
+
+ while(nbox--)
+ {
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if ((oc1 | oc2) == 0)
+ {
+ if (axis == X_AXIS)
+ len = adx;
+ else
+ len = ady;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ len++;
+#endif
+ iplBresS (alu, and, xor,
+ addrg, ngwidth,
+ signdx, signdy, axis, x1, y1,
+ e, e1, e2, len);
+ break;
+ }
+ else if (oc1 & oc2)
+ {
+ pbox++;
+ }
+ else
+ {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int clipdx, clipdy;
+ int err;
+
+ if (miZeroClipLine(pbox->x1, pbox->y1, pbox->x2-1,
+ pbox->y2-1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1)
+ {
+ pbox++;
+ continue;
+ }
+
+ if (axis == X_AXIS)
+ len = abs(new_x2 - new_x1);
+ else
+ len = abs(new_y2 - new_y1);
+#ifdef POLYSEGMENT
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+#else
+ len += (clip2 != 0);
+#endif
+ if (len)
+ {
+ /* unwind bresenham error term to first point */
+ if (clip1)
+ {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ if (axis == X_AXIS)
+ err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));
+ else
+ err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));
+ }
+ else
+ err = e;
+ iplBresS(alu, and, xor,
+ addrg, ngwidth,
+ signdx, signdy, axis, new_x1, new_y1,
+ err, e1, e2, len);
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+ } /* sloped line */
+ } /* while (nline--) */
+
+#ifndef POLYSEGMENT
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1)))
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--)
+ {
+ if ((x2 >= pbox->x1) &&
+ (y2 >= pbox->y1) &&
+ (x2 < pbox->x2) &&
+ (y2 < pbox->y2))
+ {
+ INTER_DECLAREG(mask);
+ INTER_DECLAREGP(temp);
+
+ mask = iplmask[x2 & INTER_PIM];
+ addrg += (y2 * ngwidth) + (x2 >> INTER_PGSH) * INTER_PLANES;
+
+ INTER_DoRRop(addrg, and, xor, temp);
+ INTER_COPYM(temp, addrg, mask, addrg);
+ break;
+ }
+ else
+ pbox++;
+ }
+ }
+#endif
+}
+
+/*
+ * Draw dashed 1-pixel lines.
+ */
+
+void
+#ifdef POLYSEGMENT
+iplSegmentSD (pDrawable, pGC, nseg, pSeg)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int nseg;
+ register xSegment *pSeg;
+#else
+iplLineSD( pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt; /* number of points */
+ DDXPointPtr pptInit;
+#endif
+{
+ int nboxInit;
+ register int nbox;
+ BoxPtr pboxInit;
+ register BoxPtr pbox;
+#ifndef POLYSEGMENT
+ register DDXPointPtr ppt; /* pointer to list of translated points */
+#endif
+
+ register unsigned int oc1; /* outcode of point 1 */
+ register unsigned int oc2; /* outcode of point 2 */
+
+ INTER_DECLAREG(*addrg); /* address of destination pixmap */
+ int ngwidth; /* width in groups of destination pixmap */
+ int xorg, yorg; /* origin of window */
+
+ int adx; /* abs values of dx and dy */
+ int ady;
+ int signdx; /* sign of dx and dy */
+ int signdy;
+ int e, e1, e2; /* bresenham error and increments */
+ int len; /* length of segment */
+ int axis; /* major axis */
+ int octant;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ int x1, x2, y1, y2;
+ RegionPtr cclip;
+ iplRRopRec rrops[2];
+ unsigned char *pDash;
+ int dashOffset;
+ int numInDashList;
+ int dashIndex;
+ int isDoubleDash;
+ int dashIndexTmp, dashOffsetTmp;
+ int unclippedlen;
+ iplPrivGCPtr devPriv;
+
+ devPriv = iplGetGCPrivate(pGC);
+ cclip = pGC->pCompositeClip;
+ rrops[0].rop = devPriv->rop;
+ INTER_COPY(devPriv->andg, rrops[0].andg)
+ INTER_COPY(devPriv->xorg, rrops[0].xorg)
+#if 0
+ if (pGC->alu == GXcopy)
+ {
+ rrops[1].rop = GXcopy;
+ rrops[1].and = 0;
+ rrops[1].xor = PFILL (pGC->bgPixel);
+ }
+ else
+#endif
+ {
+ rrops[1].rop = iplReduceRasterOp (pGC->alu,
+ pGC->bgPixel, pGC->planemask,
+ rrops[1].andg, rrops[1].xorg);
+ }
+ pboxInit = REGION_RECTS(cclip);
+ nboxInit = REGION_NUM_RECTS(cclip);
+
+ iplGetGroupWidthAndPointer (pDrawable, ngwidth, addrg)
+
+ /* compute initial dash values */
+
+ pDash = (unsigned char *) pGC->dash;
+ numInDashList = pGC->numInDashList;
+ isDoubleDash = (pGC->lineStyle == LineDoubleDash);
+ dashIndex = 0;
+ dashOffset = 0;
+ miStepDash ((int)pGC->dashOffset, &dashIndex, pDash,
+ numInDashList, &dashOffset);
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+#ifdef POLYSEGMENT
+ while (nseg--)
+#else
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while(--npt)
+#endif
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+#ifdef POLYSEGMENT
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious)
+ {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+#endif
+
+ CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy, 1, 1, octant);
+
+ if (adx > ady)
+ {
+ axis = X_AXIS;
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+ unclippedlen = adx;
+ }
+ else
+ {
+ axis = Y_AXIS;
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ unclippedlen = ady;
+ SetYMajorOctant(octant);
+ }
+
+ FIXUP_ERROR(e, octant, bias);
+
+ /* we have bresenham parameters and two points.
+ all we have to do now is clip and draw.
+ */
+
+ while(nbox--)
+ {
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if ((oc1 | oc2) == 0)
+ {
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ unclippedlen++;
+ dashIndexTmp = dashIndex;
+ dashOffsetTmp = dashOffset;
+ iplBresD (rrops,
+ &dashIndexTmp, pDash, numInDashList,
+ &dashOffsetTmp, isDoubleDash,
+ addrg, ngwidth,
+ signdx, signdy, axis, x1, y1,
+ e, e1, e2, unclippedlen);
+ break;
+#else
+ iplBresD (rrops,
+ &dashIndex, pDash, numInDashList,
+ &dashOffset, isDoubleDash,
+ addrg, ngwidth,
+ signdx, signdy, axis, x1, y1,
+ e, e1, e2, unclippedlen);
+ goto dontStep;
+#endif
+ }
+ else if (oc1 & oc2)
+ {
+ pbox++;
+ }
+ else /* have to clip */
+ {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int clipdx, clipdy;
+ int err;
+ int dashIndexTmp, dashOffsetTmp;
+
+ if (miZeroClipLine(pbox->x1, pbox->y1, pbox->x2-1,
+ pbox->y2-1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1)
+ {
+ pbox++;
+ continue;
+ }
+
+ dashIndexTmp = dashIndex;
+ dashOffsetTmp = dashOffset;
+
+ if (clip1)
+ {
+ int dlen;
+
+ if (axis == X_AXIS)
+ dlen = abs(new_x1 - x1);
+ else
+ dlen = abs(new_y1 - y1);
+ miStepDash (dlen, &dashIndexTmp, pDash,
+ numInDashList, &dashOffsetTmp);
+ }
+
+ if (axis == X_AXIS)
+ len = abs(new_x2 - new_x1);
+ else
+ len = abs(new_y2 - new_y1);
+#ifdef POLYSEGMENT
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+#else
+ len += (clip2 != 0);
+#endif
+ if (len)
+ {
+ /* unwind bresenham error term to first point */
+ if (clip1)
+ {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ if (axis == X_AXIS)
+ err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));
+ else
+ err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));
+ }
+ else
+ err = e;
+ iplBresD (rrops,
+ &dashIndexTmp, pDash, numInDashList,
+ &dashOffsetTmp, isDoubleDash,
+ addrg, ngwidth,
+ signdx, signdy, axis, new_x1, new_y1,
+ err, e1, e2, len);
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+#ifndef POLYSEGMENT
+ /*
+ * walk the dash list around to the next line
+ */
+ miStepDash (unclippedlen, &dashIndex, pDash,
+ numInDashList, &dashOffset);
+dontStep: ;
+#endif
+ } /* while (nline--) */
+
+#ifndef POLYSEGMENT
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((dashIndex & 1) == 0 || isDoubleDash) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1)))
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--)
+ {
+ if ((x2 >= pbox->x1) &&
+ (y2 >= pbox->y1) &&
+ (x2 < pbox->x2) &&
+ (y2 < pbox->y2))
+ {
+ INTER_DECLAREG(mask);
+ int pix;
+
+ pix = 0;
+ if (dashIndex & 1)
+ pix = 1;
+ mask = iplmask[x2 & INTER_PIM];
+ addrg += (y2 * ngwidth) + (x2 >> INTER_PGSH) * INTER_PLANES;
+ INTER_DoMaskRRop(addrg, rrops[pix].andg, rrops[pix].xorg,
+ mask, addrg);
+ break;
+ }
+ else
+ pbox++;
+ }
+ }
+#endif
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplmap.h b/nx-X11/programs/Xserver/iplan2p4/iplmap.h
new file mode 100644
index 000000000..cc065aa82
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplmap.h
@@ -0,0 +1,176 @@
+/* $XFree86: xc/programs/Xserver/iplan2p4/iplmap.h,v 3.1 1998/04/05 16:42:26 robin Exp $ */
+/*
+ * $XConsortium: iplmap.h,v 1.9 94/04/17 20:28:54 dpw Exp $
+ *
+Copyright (c) 1991 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+/*
+ * Map names around so that multiple depths can be supported simultaneously
+ */
+
+/* a losing vendor cpp dumps core if we define NAME in terms of CATNAME */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#if INTER_PLANES == 2
+#define NAME(subname) ipl2p2##subname
+#elif INTER_PLANES == 4
+#define NAME(subname) ipl2p4##subname
+#elif INTER_PLANES == 8
+#define NAME(subname) ipl2p8##subname
+#endif
+
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define CATNAME(prefix,subname) prefix##subname
+#else
+#define CATNAME(prefix,subname) prefix/**/subname
+#endif
+
+#define iplScreenPrivateIndex NAME(ScreenPrivateIndex)
+#define QuartetBitsTable NAME(QuartetBitsTable)
+#define QuartetPixelMaskTable NAME(QuartetPixelMaskTable)
+#define iplAllocatePrivates NAME(AllocatePrivates)
+#define iplBSFuncRec NAME(BSFuncRec)
+#define iplBitBlt NAME(BitBlt)
+#define iplBresD NAME(BresD)
+#define iplBresS NAME(BresS)
+#define iplChangeWindowAttributes NAME(ChangeWindowAttributes)
+#define iplCloseScreen NAME(CloseScreen)
+#define iplCopyArea NAME(CopyArea)
+#define iplCopyImagePlane NAME(CopyImagePlane)
+#define iplCopyPixmap NAME(CopyPixmap)
+#define iplCopyPlane NAME(CopyPlane)
+#define iplCopyRotatePixmap NAME(CopyRotatePixmap)
+#define iplCopyWindow NAME(CopyWindow)
+#define iplCreateGC NAME(CreateGC)
+#define iplCreatePixmap NAME(CreatePixmap)
+#define iplCreateWindow NAME(CreateWindow)
+#define iplCreateScreenResources NAME(CreateScreenResoures)
+#define iplDestroyPixmap NAME(DestroyPixmap)
+#define iplDestroyWindow NAME(DestroyWindow)
+#define iplDoBitblt NAME(DoBitblt)
+#define iplDoBitbltCopy NAME(DoBitbltCopy)
+#define iplDoBitbltGeneral NAME(DoBitbltGeneral)
+#define iplDoBitbltOr NAME(DoBitbltOr)
+#define iplDoBitbltXor NAME(DoBitbltXor)
+#define iplFillBoxSolid NAME(FillBoxSolid)
+#define iplFillBoxTile32 NAME(FillBoxTile32)
+#define iplFillBoxTile32sCopy NAME(FillBoxTile32sCopy)
+#define iplFillBoxTile32sGeneral NAME(FillBoxTile32sGeneral)
+#define iplFillBoxTileOdd NAME(FillBoxTileOdd)
+#define iplFillBoxTileOddCopy NAME(FillBoxTileOddCopy)
+#define iplFillBoxTileOddGeneral NAME(FillBoxTileOddGeneral)
+#define iplFillPoly1RectCopy NAME(FillPoly1RectCopy)
+#define iplFillPoly1RectGeneral NAME(FillPoly1RectGeneral)
+#define iplFillRectSolidCopy NAME(FillRectSolidCopy)
+#define iplFillRectSolidGeneral NAME(FillRectSolidGeneral)
+#define iplFillRectSolidXor NAME(FillRectSolidXor)
+#define iplFillRectTile32Copy NAME(FillRectTile32Copy)
+#define iplFillRectTile32General NAME(FillRectTile32General)
+#define iplFillRectTileOdd NAME(FillRectTileOdd)
+#define iplFillSpanTile32sCopy NAME(FillSpanTile32sCopy)
+#define iplFillSpanTile32sGeneral NAME(FillSpanTile32sGeneral)
+#define iplFillSpanTileOddCopy NAME(FillSpanTileOddCopy)
+#define iplFillSpanTileOddGeneral NAME(FillSpanTileOddGeneral)
+#define iplFinishScreenInit NAME(FinishScreenInit)
+#define iplGCFuncs NAME(GCFuncs)
+#define iplGetImage NAME(GetImage)
+#define iplGetScreenPixmap NAME(GetScreenPixmap)
+#define iplGetSpans NAME(GetSpans)
+#define iplHorzS NAME(HorzS)
+#define iplImageGlyphBlt8 NAME(ImageGlyphBlt8)
+#define iplLineSD NAME(LineSD)
+#define iplLineSS NAME(LineSS)
+#define iplMapWindow NAME(MapWindow)
+#define iplMatchCommon NAME(MatchCommon)
+#define iplNonTEOps NAME(NonTEOps)
+#define iplNonTEOps1Rect NAME(NonTEOps1Rect)
+#define iplPadPixmap NAME(PadPixmap)
+#define iplPaintWindow NAME(PaintWindow)
+#define iplPolyGlyphBlt8 NAME(PolyGlyphBlt8)
+#define iplPolyGlyphRop8 NAME(PolyGlyphRop8)
+#define iplPolyFillArcSolidCopy NAME(PolyFillArcSolidCopy)
+#define iplPolyFillArcSolidGeneral NAME(PolyFillArcSolidGeneral)
+#define iplPolyFillRect NAME(PolyFillRect)
+#define iplPolyPoint NAME(PolyPoint)
+#define iplPositionWindow NAME(PositionWindow)
+#define iplPutImage NAME(PutImage)
+#define iplReduceRasterOp NAME(ReduceRasterOp)
+#define iplRestoreAreas NAME(RestoreAreas)
+#define iplSaveAreas NAME(SaveAreas)
+#define iplScreenInit NAME(ScreenInit)
+#define iplSegmentSD NAME(SegmentSD)
+#define iplSegmentSS NAME(SegmentSS)
+#define iplSetScanline NAME(SetScanline)
+#define iplSetScreenPixmap NAME(SetScreenPixmap)
+#define iplSetSpans NAME(SetSpans)
+#define iplSetupScreen NAME(SetupScreen)
+#define iplSolidSpansCopy NAME(SolidSpansCopy)
+#define iplSolidSpansGeneral NAME(SolidSpansGeneral)
+#define iplSolidSpansXor NAME(SolidSpansXor)
+#define iplStippleStack NAME(StippleStack)
+#define iplStippleStackTE NAME(StippleStackTE)
+#define iplTEGlyphBlt NAME(TEGlyphBlt)
+#define iplTEOps NAME(TEOps)
+#define iplTEOps1Rect NAME(TEOps1Rect)
+#define iplTile32FSCopy NAME(Tile32FSCopy)
+#define iplTile32FSGeneral NAME(Tile32FSGeneral)
+#define iplUnmapWindow NAME(UnmapWindow)
+#define iplUnnaturalStippleFS NAME(UnnaturalStippleFS)
+#define iplUnnaturalTileFS NAME(UnnaturalTileFS)
+#define iplValidateGC NAME(ValidateGC)
+#define iplVertS NAME(VertS)
+#define iplXRotatePixmap NAME(XRotatePixmap)
+#define iplYRotatePixmap NAME(YRotatePixmap)
+#define iplendpartial NAME(endpartial)
+#define iplendtab NAME(endtab)
+#define iplmask NAME(mask)
+#define iplrmask NAME(rmask)
+#define iplstartpartial NAME(startpartial)
+#define iplstarttab NAME(starttab)
+#define ipl8LineSS1Rect NAME(LineSS1Rect)
+#define ipl8SegmentSS1Rect NAME(SegmentSS1Rect)
+#define ipl8ClippedLineCopy NAME(ClippedLineCopy)
+#define ipl8ClippedLineXor NAME(ClippedLineXor)
+#define ipl8ClippedLineGeneral NAME(ClippedLineGeneral )
+#define ipl8SegmentSS1RectCopy NAME(SegmentSS1RectCopy)
+#define ipl8SegmentSS1RectXor NAME(SegmentSS1RectXor)
+#define ipl8SegmentSS1RectGeneral NAME(SegmentSS1RectGeneral )
+#define ipl8SegmentSS1RectShiftCopy NAME(SegmentSS1RectShiftCopy)
+#define ipl8LineSS1RectCopy NAME(LineSS1RectCopy)
+#define ipl8LineSS1RectXor NAME(LineSS1RectXor)
+#define ipl8LineSS1RectGeneral NAME(LineSS1RectGeneral )
+#define ipl8LineSS1RectPreviousCopy NAME(LineSS1RectPreviousCopy)
+#define iplZeroPolyArcSS8Copy NAME(ZeroPolyArcSSCopy)
+#define iplZeroPolyArcSS8Xor NAME(ZeroPolyArcSSXor)
+#define iplZeroPolyArcSS8General NAME(ZeroPolyArcSSGeneral)
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplmergerop.h b/nx-X11/programs/Xserver/iplan2p4/iplmergerop.h
new file mode 100644
index 000000000..09141c983
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplmergerop.h
@@ -0,0 +1,146 @@
+/* $XFree86: xc/programs/Xserver/iplan2p4/iplmergerop.h,v 3.0 1996/08/18 01:54:53 dawes Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _IPLANMERGEROP_H_
+#define _IPLANMERGEROP_H_
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+/* defines:
+ INTER_MROP_NAME
+ INTER_MROP_DECLARE_REG()
+ INTER_MROP_INITIALIZE(alu, pm)
+ INTER_MROP_SOLID(src1, src2, dst)
+ INTER_MROP_MASK(src1, src2, mask, dst)
+ INTER_MROP_PREBUILD(src)
+ INTER_MROP_PREBUILT_DECLARE()
+ INTER_MROP_PREBUILT_SOLID(src,dst)
+ INTER_MROP_PREBUILT_MASK(src,dst,mask)
+*/
+
+#ifndef GXcopy
+#include <X11/X.h>
+#endif
+
+typedef struct _mergeRopBits {
+ unsigned long ca1, cx1, ca2, cx2;
+} mergeRopRec, *mergeRopPtr;
+
+extern mergeRopRec mergeRopBits[16];
+
+#define INTER_DeclareMergeRop() \
+ INTER_DECLAREGP(_ca1); \
+ INTER_DECLAREGP(_cx1); \
+ INTER_DECLAREGP(_ca2); \
+ INTER_DECLAREGP(_cx2);
+
+#define INTER_DeclarePrebuiltMergeRop() \
+ INTER_DECLAREGP(_cca); \
+ INTER_DECLAREGP(_ccx);
+
+#define INTER_InitializeMergeRop(alu,pm) { \
+ INTER_DECLAREGP(_pm); \
+ mergeRopPtr _bits; \
+ INTER_PFILL(pm, _pm); \
+ _bits = &mergeRopBits[alu]; \
+ INTER_ANDMSK(_pm, _bits->ca1, _ca1); \
+ INTER_ANDMSK(_pm, _bits->ca2, _ca2); \
+ INTER_ANDMSK(_pm, _bits->cx2, _cx2); \
+ INTER_NOT(_pm, _pm); \
+ INTER_ORMSK(_pm, _bits->cx1, _cx1); \
+}
+
+#define INTER_DoMergeRop(src1, src2, dst) \
+ INTER_CPLX(src1, src2, _ca1, _cx1, _ca2, _cx2, dst)
+
+#define INTER_DoMaskMergeRop(src1, src2, mask, dst) \
+ INTER_CPLXM(src1, src2, _ca1, _cx1, _ca2, _cx2, mask, dst)
+
+#define INTER_DoPrebuiltMergeRop(src, dst) \
+ INTER_DoRRop(src, _cca, _ccx, dst)
+
+#define INTER_DoMaskPrebuiltMergeRop(src, mask, dst) \
+ INTER_DoMaskRRop(src, _cca, _ccx, mask, dst)
+
+#define INTER_PrebuildMergeRop(src) \
+ INTER_DoRRop(src, _ca1, _cx1, _cca); \
+ INTER_DoRRop(src, _ca2, _cx2, _ccx);
+
+#ifndef MROP
+#define MROP 0
+#endif
+
+#define Mclear (1<<GXclear)
+#define Mand (1<<GXand)
+#define MandReverse (1<<GXandReverse)
+#define Mcopy (1<<GXcopy)
+#define MandInverted (1<<GXandInverted)
+#define Mnoop (1<<GXnoop)
+#define Mxor (1<<GXxor)
+#define Mor (1<<GXor)
+#define Mnor (1<<GXnor)
+#define Mequiv (1<<GXequiv)
+#define Minvert (1<<GXinvert)
+#define MorReverse (1<<GXorReverse)
+#define McopyInverted (1<<GXcopyInverted)
+#define MorInverted (1<<GXorInverted)
+#define Mnand (1<<GXnand)
+#define Mset (1<<GXset)
+
+#if (MROP) == Mcopy
+#define INTER_MROP_NAME(prefix) INTER_MROP_NAME_CAT(prefix,Copy)
+#define INTER_MROP_DECLARE_REG()
+#define INTER_MROP_INITIALIZE(alu,pm)
+#define INTER_MROP_SOLID(src,dst,dst2) INTER_COPY(src, dst2)
+#define INTER_MROP_MASK(src,dst,mask, dst2) INTER_COPYM(src,dst,mask,dst2)
+#endif
+
+#if (MROP) == Mxor
+#define INTER_MROP_NAME(prefix) INTER_MROP_NAME_CAT(prefix,Xor)
+#define INTER_MROP_DECLARE_REG()
+#define INTER_MROP_INITIALIZE(alu,pm)
+#define INTER_MROP_SOLID(src,dst,dst2) INTER_XOR(src,dst,dst2)
+#define INTER_MROP_MASK(src,dst,mask,dst2) INTER_XORM(src,dst,mask,dst2)
+#endif
+
+#if (MROP) == Mor
+#define INTER_MROP_NAME(prefix) INTER_MROP_NAME_CAT(prefix,Or)
+#define INTER_MROP_DECLARE_REG()
+#define INTER_MROP_INITIALIZE(alu,pm)
+#define INTER_MROP_SOLID(src,dst,dst2) INTER_OR(src,dst,dst2)
+#define INTER_MROP_MASK(src,dst,mask,dst2) INTER_ORM(src,dst,mask,dst2)
+#endif
+
+#if (MROP) == 0
+#define INTER_MROP_NAME(prefix) INTER_MROP_NAME_CAT(prefix,General)
+#define INTER_MROP_DECLARE_REG() INTER_DeclareMergeRop()
+#define INTER_MROP_INITIALIZE(alu,pm) INTER_InitializeMergeRop(alu,pm)
+#define INTER_MROP_SOLID(src,dst,dst2) INTER_DoMergeRop(src, dst, dst2)
+#define INTER_MROP_MASK(src,dst,mask,dst2) \
+ INTER_DoMaskMergeRop(src, dst, mask, dst2)
+#define INTER_MROP_PREBUILD(src) INTER_PrebuildMergeRop(src)
+#define INTER_MROP_PREBUILT_DECLARE() INTER_DeclarePrebuiltMergeRop()
+#define INTER_MROP_PREBUILT_SOLID(src,dst, dst2) \
+ INTER_DoPrebuiltMergeRop(dst,dst2)
+#define INTER_MROP_PREBUILT_MASK(src,dst,mask,dst2) \
+ INTER_DoMaskPrebuiltMergeRop(dst,mask, dst2)
+#endif
+
+#ifndef INTER_MROP_PREBUILD
+#define INTER_MROP_PREBUILD(src)
+#define INTER_MROP_PREBUILT_DECLARE()
+#define INTER_MROP_PREBUILT_SOLID(src,dst,dst2) INTER_MROP_SOLID(src,dst,dst2)
+#define INTER_MROP_PREBUILT_MASK(src,dst,mask,dst2) \
+ INTER_MROP_MASK(src,dst,mask,dst2)
+#endif
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define INTER_MROP_NAME_CAT(prefix,suffix) prefix##suffix
+#else
+#define INTER_MROP_NAME_CAT(prefix,suffix) prefix/**/suffix
+#endif
+
+#endif /* _IPLANMERGEROP_H_ */
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplmskbits.c b/nx-X11/programs/Xserver/iplan2p4/iplmskbits.c
new file mode 100644
index 000000000..e611bd293
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplmskbits.c
@@ -0,0 +1,108 @@
+/* $XFree86$ */
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "iplmap.h"
+
+unsigned short iplmask[] =
+ { 0x8000,
+ 0x4000,
+ 0x2000,
+ 0x1000,
+ 0x0800,
+ 0x0400,
+ 0x0200,
+ 0x0100,
+ 0x0080,
+ 0x0040,
+ 0x0020,
+ 0x0010,
+ 0x0008,
+ 0x0004,
+ 0x0002,
+ 0x0001
+ };
+
+unsigned short iplstarttab[] =
+ {
+ 0x0000,
+ 0x7fff,
+ 0x3fff,
+ 0x1fff,
+ 0x0fff,
+ 0x07ff,
+ 0x03ff,
+ 0x01ff,
+ 0x00ff,
+ 0x007f,
+ 0x003f,
+ 0x001f,
+ 0x000f,
+ 0x0007,
+ 0x0003,
+ 0x0001
+ };
+
+unsigned short iplendtab[] =
+ {
+ 0x0000,
+ 0x8000,
+ 0xc000,
+ 0xe000,
+ 0xf000,
+ 0xf800,
+ 0xfc00,
+ 0xfe00,
+ 0xff00,
+ 0xff80,
+ 0xffc0,
+ 0xffe0,
+ 0xfff0,
+ 0xfff8,
+ 0xfffc,
+ 0xfffe
+ };
+
+unsigned short iplstartpartial[] =
+ {
+ 0xffff,
+ 0x7fff,
+ 0x3fff,
+ 0x1fff,
+ 0x0fff,
+ 0x07ff,
+ 0x03ff,
+ 0x01ff,
+ 0x00ff,
+ 0x007f,
+ 0x003f,
+ 0x001f,
+ 0x000f,
+ 0x0007,
+ 0x0003,
+ 0x0001
+ };
+
+unsigned short iplendpartial[] =
+ {
+ 0xffff,
+ 0x8000,
+ 0xc000,
+ 0xe000,
+ 0xf000,
+ 0xf800,
+ 0xfc00,
+ 0xfe00,
+ 0xff00,
+ 0xff80,
+ 0xffc0,
+ 0xffe0,
+ 0xfff0,
+ 0xfff8,
+ 0xfffc,
+ 0xfffe
+ };
+
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplmskbits.h b/nx-X11/programs/Xserver/iplan2p4/iplmskbits.h
new file mode 100644
index 000000000..1efc47d44
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplmskbits.h
@@ -0,0 +1,500 @@
+/* $XFree86$ */
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#define INTER_PIXGRP unsigned short
+
+#define INTER_PGSZ 16
+#define INTER_PGSZB 2
+#define INTER_PPG 16
+#define INTER_PPGMSK 0xffff
+#define INTER_PLST 15
+#define INTER_PIM 15
+#define INTER_PGSH 4
+#define INTER_PMSK ((1 << (INTER_PLANES)) - 1)
+
+extern INTER_PIXGRP iplmask[];
+extern INTER_PIXGRP iplstarttab[];
+extern INTER_PIXGRP iplendtab[];
+extern INTER_PIXGRP iplstartpartial[];
+extern INTER_PIXGRP iplendpartial[];
+
+#define MFB_PSZ 1
+
+#define INTER_NEXT(x) ((x) + INTER_PLANES)
+#define INTER_NEXT_GROUP(x) (x) += INTER_PLANES
+#define INTER_PREV_GROUP(x) (x) -= INTER_PLANES
+
+#define _I(x) (((unsigned long *) (x))[_INDEX])
+#define _IG(x) ((x)[_INDEX])
+
+#define INTER_DECLAREG(x) INTER_PIXGRP x
+#define INTER_DECLAREGP(x) INTER_PIXGRP x[INTER_PLANES]
+
+#define INTER_DECLARERRAX(x) INTER_PIXGRP *(x)
+#define INTER_DECLARERRAXP(x) INTER_PIXGRP x[INTER_PLANES]
+
+/* and |= PLANE_FILL(~fg), or &= PLANE_FILL(fg) */
+#define INTER_ANDXOR_PM(pm, and, xor) \
+ PLANE_TIMESG( \
+ if (!(pm & INTER_PLANE(_INDEX))) { \
+ _IG(and) = INTER_PPGMSK; \
+ _IG(xor) = 0; \
+ })
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#if INTER_PLANES == 2
+
+#define PLANE_TIMESCONDG(x) \
+ ({ int _INDEX; \
+ int _ret; \
+ _ret=(_INDEX=0, (x)) && \
+ (_INDEX=1, (x)) && \
+ _ret; \
+ })
+
+#define PLANE_TIMESCOND(x) \
+ ({ int _INDEX; \
+ (_INDEX=0, x) \
+ })
+
+#define PLANE_TIMESG(x) \
+ { int _INDEX; \
+ _INDEX=0; x; \
+ _INDEX=1; x; \
+ }
+
+#define PLANE_TIMES(x) \
+ { int _INDEX; \
+ _INDEX=0; x; \
+ }
+
+#elif INTER_PLANES == 4
+
+#define PLANE_TIMESCONDG(x) \
+ ({ int _INDEX; \
+ int _ret; \
+ _ret=(_INDEX=0, (x)) && \
+ (_INDEX=1, (x)) && \
+ (_INDEX=2, (x)) && \
+ (_INDEX=3, (x)); \
+ _ret; \
+ })
+
+#define PLANE_TIMESCOND(x) \
+ ({ int _INDEX; \
+ ((_INDEX=0, x) && \
+ (_INDEX=1, x)) \
+ })
+
+#define PLANE_TIMESG(x) \
+ { int _INDEX; \
+ _INDEX=0; x; \
+ _INDEX=1; x; \
+ _INDEX=2; x; \
+ _INDEX=3; x; \
+ }
+
+#define PLANE_TIMES(x) \
+ { int _INDEX; \
+ _INDEX=0; x; \
+ _INDEX=1; x; \
+ }
+
+#elif INTER_PLANES == 8
+
+#define PLANE_TIMESCONDG(x) \
+ ({ int _INDEX; \
+ int _ret; \
+ _ret=((_INDEX=0, (x)) && \
+ (_INDEX=1, (x)) && \
+ (_INDEX=2, (x)) && \
+ (_INDEX=3, (x)) && \
+ (_INDEX=4, (x)) && \
+ (_INDEX=5, (x)) && \
+ (_INDEX=6, (x)) && \
+ (_INDEX=7, (x))); \
+ _ret; \
+ })
+
+#define PLANE_TIMESCOND(x) \
+ ({ int _INDEX; \
+ ((_INDEX=0, x) && \
+ (_INDEX=1, x) && \
+ (_INDEX=2, x) && \
+ (_INDEX=3, x)) \
+ })
+
+#define PLANE_TIMESG(x) \
+ { int _INDEX; \
+ _INDEX=0; x; \
+ _INDEX=1; x; \
+ _INDEX=2; x; \
+ _INDEX=3; x; \
+ _INDEX=4; x; \
+ _INDEX=5; x; \
+ _INDEX=6; x; \
+ _INDEX=7; x; \
+ }
+
+#define PLANE_TIMES(x) \
+ { int _INDEX; \
+ _INDEX=0; x; \
+ _INDEX=1; x; \
+ _INDEX=2; x; \
+ _INDEX=3; x; \
+ }
+
+#endif
+
+/* src = 0 */
+#define INTER_IS_CLR(src) \
+ PLANE_TIMESCONDG(_IG(src) == 0)
+
+/* src = PPGMSK ? */
+#define INTER_IS_SET(src) \
+ PLANE_TIMESCONDG(_IG(src) == INTER_PPGMSK)
+
+/* (src1 ^ scr2) = PPGMSK ? */
+#define INTER_IS_XOR_SET(src1, src2) \
+ PLANE_TIMESCONDG((_IG(src1) ^ _IG(src2)) == INTER_PPGMSK)
+
+/* dst = ~src */
+#define INTER_NOT(src, dst) \
+ PLANE_TIMES(_I(dst) = ~_I(src))
+
+/* dst = 0 */
+#define INTER_CLR(dst) \
+ PLANE_TIMES(_I(dst) = 0)
+
+/* dst = PPGMSK */
+#define INTER_SET(dst) \
+ PLANE_TIMESG(_IG(dst) = INTER_PPGMSK)
+
+/* dst = src */
+#define INTER_COPY(src,dst) \
+ PLANE_TIMES(_I(dst) = _I(src))
+
+/* dst2 = (dst & ~mask) | (src & mask) */
+#define INTER_COPYM(src,dst,mask,dst2) \
+ PLANE_TIMESG( \
+ _IG(dst2) = (_IG(dst) & ~mask) | (_IG(src) & mask) \
+ )
+
+/* dst2 = dst ^ src */
+#define INTER_XOR(src,dst,dst2) \
+ PLANE_TIMES(_I(dst2) = _I(dst) ^ _I(src))
+
+/* dst2 = dst ^ (src & mask) */
+#define INTER_XORM(src,dst,mask,dst2) \
+ PLANE_TIMESG(_IG(dst2) = _IG(dst) ^ (_IG(src) & (mask)))
+
+/* dst2 = dst & src */
+#define INTER_AND(src,dst,dst2) \
+ PLANE_TIMES(_I(dst2) = _I(dst) & _I(src))
+
+/* dst2 = dst & (src | ~mask) */
+#define INTER_ANDM(mask,src,dst,dst2) \
+ PLANE_TIMESG(_IG(dst2) = _IG(dst) & (_IG(src) | ~(mask)))
+
+/* dst2 = dst | src */
+#define INTER_OR(src,dst,dst2) \
+ PLANE_TIMES(_I(dst2) = _I(dst) | _I(src))
+
+/* dst2 = dst | (src & mask) */
+#define INTER_ORM(src,dst,mask,dst2) \
+ PLANE_TIMESG(_IG(dst2) = _IG(dst) | (_IG(src) & (mask)))
+
+/* dst = src | msk */
+#define INTER_ORMSK(src,msk,dst) \
+ PLANE_TIMESG(_IG(dst) = _IG(src) | (msk))
+
+/* dst = src & msk */
+#define INTER_ANDMSK(src,msk,dst) \
+ PLANE_TIMESG(_IG(dst) = _IG(src) & (msk))
+
+/* dst = (src1 & msk1) | (src2 & msk2) */
+#define INTER_ANDMSK2(src1,msk1,src2,msk2,dst) \
+ PLANE_TIMESG(_IG(dst) = (_IG(src1) & (msk1)) | (_IG(src2) & (msk2)))
+
+#define INTER_PLANE(x) (1<<(x))
+
+#define INTER_PFILL(col, fill) \
+ PLANE_TIMESG(_IG(fill) = \
+ ((col) & INTER_PLANE(_INDEX)) ? INTER_PPGMSK : 0)
+
+/* dst = src >> cnt */
+#define INTER_SCRRIGHT(cnt, src, dst) \
+ PLANE_TIMESG(_IG(dst) = _IG(src) >> (cnt))
+
+/* dst = src << cnt */
+#define INTER_SCRLEFT(cnt, src, dst) \
+ PLANE_TIMESG(_IG(dst) = _IG(src) << (cnt))
+
+/* bits1=(bits >> right) | (bits=psrc) << left) */
+#define INTER_GETRLC(right, left, psrc, bits, bits1) \
+ PLANE_TIMESG( _IG(bits1)=(_IG(bits) >> (right)) | \
+ ((_IG(bits) = _IG(psrc)) << (left)))
+
+/* bits1=(bits << left) | (bits=psrc) >> right) */
+#define INTER_GETLRC(left, right, psrc, bits, bits1) \
+ PLANE_TIMESG( _IG(bits1)=(_IG(bits) << (left)) | \
+ ((_IG(bits) = _IG(psrc)) >> (right)))
+
+/* dst=src2 & (src1 & a1 ^ x1) ^ (src1 & a2 ^ x2) */
+#define INTER_CPLX(src1, src2, a1, x1, a2, x2, dst) \
+ PLANE_TIMES( _I(dst) = (_I(src2) \
+ & (_I(src1) & _I(a1) ^ _I(x1)) \
+ ^ (_I(src1) & _I(a2) ^ _I(x2)))) \
+
+/* dst=src2 & ((src1 & a1 ^ x1) | ~mask) ^ ((src1 & a2 ^ x2) & mask) */
+#define INTER_CPLXM(src1, src2, a1, x1, a2, x2, mask, dst) \
+ PLANE_TIMESG( _IG(dst) = (_IG(src2) \
+ & ((_IG(src1) & _IG(a1) ^ _IG(x1)) | ~mask) \
+ ^ ((_IG(src1) & _IG(a2) ^ _IG(x2)) & mask)))
+
+/* dst = (src & ~(bitmask | planemask)) | (insert | (bitmask | planemask)) */
+#define INTER_PMSKINS(bitmask, planemask, insert, src, dst) \
+ PLANE_TIMESG( \
+ if (planemask & INTER_PLANE(_INDEX)) \
+ _IG(dst) = (_IG(src) & ~bitmask) | (_IG(insert) & bitmask) \
+ )
+
+/* dst = (src & ~bitmask) | ((insert >> shift) & bitmask) */
+#define INTER_SCRRMSKINS(bitmask, planemask, insert, shift, src, dst) \
+ PLANE_TIMESG( \
+ if (planemask & INTER_PLANE(_INDEX)) \
+ _IG(dst) = (_IG(src) & ~(bitmask)) | \
+ ((_IG(insert) >> shift) & (bitmask)) \
+ )
+
+/* dst = (src & ~bitmask) | ((insert << shift) & bitmask) */
+#define INTER_SCRLMSKINS(bitmask, planemask, insert, shift, src, dst) \
+ PLANE_TIMESG( \
+ if (planemask & INTER_PLANE(_INDEX)) \
+ _IG(dst) = (_IG(src) & ~bitmask) | \
+ ((_IG(insert) << shift) & bitmask) \
+ )
+
+/* dst = ((src1 << sl1) & bitmask1) | ((src2 >> sr2) & bitmask2) */
+#define INTER_MSKINSM(bitmask1, sl1, src1, bitmask2, sr2, src2, dst) \
+ PLANE_TIMESG( \
+ _IG(dst) = ((_IG(src1) << sl1) & (bitmask1)) | \
+ ((_IG(src2) >> sr2) & (bitmask2)) \
+ )
+
+/* dst = src & and ^ xor */
+#define INTER_DoRRop(src, and, xor, dst) \
+ PLANE_TIMES(_I(dst) = (_I(src) & _I(and) ^ _I(xor))) \
+
+#define INTER_DoMaskRRop(src, and, xor, mask, dst) \
+ PLANE_TIMESG( \
+ _IG(dst) = (_IG(src) & ((_IG(and) | ~(mask))) \
+ ^ (_IG(xor) & mask)))
+
+#define INTER_DoRop(result, alu, src, dst) \
+{ \
+ if (alu == GXcopy) { \
+ PLANE_TIMES( \
+ _I(result) = fnCOPY (_I(src), _I(dst))); \
+ } else if (alu == GXxor) { \
+ PLANE_TIMES( \
+ _I(result) = fnXOR (_I(src), _I(dst))); \
+ } \
+ else { \
+ switch (alu) \
+ { \
+ case GXclear: \
+ PLANE_TIMES( \
+ _I(result) = fnCLEAR (_I(src), _I(dst))); \
+ break; \
+ case GXand: \
+ PLANE_TIMES( \
+ _I(result) = fnAND (_I(src), _I(dst))); \
+ break; \
+ case GXandReverse: \
+ PLANE_TIMES( \
+ _I(result) = fnANDREVERSE (_I(src), _I(dst))); \
+ break; \
+ case GXandInverted: \
+ PLANE_TIMES( \
+ _I(result) = fnANDINVERTED (_I(src), _I(dst))); \
+ break; \
+ case GXnoop: \
+ PLANE_TIMES( \
+ _I(result) = fnNOOP (_I(src), _I(dst))); \
+ break; \
+ case GXor: \
+ PLANE_TIMES( \
+ _I(result) = fnOR (_I(src), _I(dst))); \
+ break; \
+ case GXnor: \
+ PLANE_TIMES( \
+ _I(result) = fnNOR (_I(src), _I(dst))); \
+ break; \
+ case GXequiv: \
+ PLANE_TIMES( \
+ _I(result) = fnEQUIV (_I(src), _I(dst))); \
+ break; \
+ case GXinvert: \
+ PLANE_TIMES( \
+ _I(result) = fnINVERT (_I(src), _I(dst))); \
+ break; \
+ case GXorReverse: \
+ PLANE_TIMES( \
+ _I(result) = fnORREVERSE (_I(src), _I(dst))); \
+ break; \
+ case GXcopyInverted: \
+ PLANE_TIMES( \
+ _I(result) = fnCOPYINVERTED (_I(src), _I(dst))); \
+ break; \
+ case GXorInverted: \
+ PLANE_TIMES( \
+ _I(result) = fnORINVERTED (_I(src), _I(dst))); \
+ break; \
+ case GXnand: \
+ PLANE_TIMES( \
+ _I(result) = fnNAND (_I(src), _I(dst))); \
+ break; \
+ case GXset: \
+ PLANE_TIMES( \
+ _I(result) = fnSET (_I(src), _I(dst))); \
+ break; \
+ } \
+ } \
+}
+
+#define iplGetGroupWidthAndPointer(pDrawable, width, pointer) \
+ iplGetTypedWidthAndPointer(pDrawable, width, pointer, INTER_PIXGRP, INTER_PIXGRP)
+
+#define INTER_getstipplepixels(psrcstip, x, w, ones, psrcpix, pdstpix) \
+{ \
+ unsigned long q; \
+ int m; \
+ if (ones) { \
+ if ((m = ((x) - ((MFB_PPW*MFB_PSZ)-MFB_PPW))) > 0) { \
+ q = (*(psrcstip)) << m; \
+ if ( (x)+(w) > (MFB_PPW*MFB_PSZ) ) \
+ q |= *((psrcstip)+1) >> ((MFB_PPW*MFB_PSZ)-m); \
+ } \
+ else \
+ q = (*(psrcstip)) >> -m; \
+ } \
+ else { \
+ if ((m = ((x) - ((MFB_PPW*MFB_PSZ)-MFB_PPW))) > 0) { \
+ q = (~ *(psrcstip)) << m; \
+ if ( (x)+(w) > (MFB_PPW*MFB_PSZ) ) \
+ q |= (~*((psrcstip)+1)) >> ((MFB_PPW*MFB_PSZ)-m); \
+ } \
+ else \
+ q = (~ *(psrcstip)) >> -m; \
+ } \
+ q >>=16; \
+ INTER_ANDMSK(psrcpix,q,pdstpix); \
+}
+
+#define INTER_getstipplepixelsb(psrcstip, x, w, psrcpix0, psrcpix1, pdstpix) \
+{ \
+ unsigned long q,qn; \
+ int m; \
+ if ((m = ((x) - ((MFB_PPW*MFB_PSZ)-MFB_PPW))) > 0) { \
+ q = (*(psrcstip)) << m; \
+ qn = (~ *(psrcstip)) << m; \
+ if ( (x)+(w) > (MFB_PPW*MFB_PSZ) ) { \
+ q |= *((psrcstip)+1) >> ((MFB_PPW*MFB_PSZ)-m); \
+ qn |= (~ *((psrcstip)+1)) >> ((MFB_PPW*MFB_PSZ)-m); \
+ } \
+ } \
+ else { \
+ q = (*(psrcstip)) >> -m; \
+ qn = (~ *(psrcstip)) >> -m; \
+ } \
+ q >>=16; \
+ qn >>=16; \
+ INTER_ANDMSK2(psrcpix0,qn,psrcpix1,q,pdstpix); \
+}
+
+#define INTER_maskbits(x, w, startmask, endmask, nlg) \
+ startmask = iplstarttab[(x) & INTER_PIM]; \
+ endmask = iplendtab[((x)+(w)) & INTER_PIM]; \
+ if (startmask) \
+ nlg = (((w) - (INTER_PPG - ((x) & INTER_PIM))) >> INTER_PGSH); \
+ else \
+ nlg = (w) >> INTER_PGSH;
+
+#define INTER_maskpartialbits(x, w, mask) \
+ mask = iplstartpartial[(x) & INTER_PIM] & \
+ iplendpartial[((x) + (w)) & INTER_PIM];
+
+#define INTER_mask32bits(x, w, startmask, endmask, nlw) \
+ startmask = iplstarttab[(x) & INTER_PIM]; \
+ endmask = iplendtab[((x)+(w)) & INTER_PIM];
+
+#define INTER_getbits(psrc, x, w, pdst) \
+ if ( ((x) + (w)) <= INTER_PPG) \
+ { \
+ INTER_SCRLEFT((x), psrc, pdst); \
+ } \
+ else \
+ { \
+ int m; \
+ m = INTER_PPG-(x); \
+ INTER_MSKINSM(iplendtab[m], x, psrc, \
+ iplstarttab[m], m, INTER_NEXT(psrc), pdst); \
+ }
+
+#define INTER_putbits(psrc, x, w, pdst, planemask) \
+ if ( ((x)+(w)) <= INTER_PPG) \
+ { \
+ INTER_DECLAREG(tmpmask); \
+ INTER_maskpartialbits((x), (w), tmpmask); \
+ INTER_SCRRMSKINS(tmpmask, planemask, psrc, x, pdst, pdst); \
+ } \
+ else \
+ { \
+ unsigned long m; \
+ unsigned long n; \
+ m = INTER_PPG-(x); \
+ n = (w) - m; \
+ INTER_SCRRMSKINS(iplstarttab[x], planemask, psrc, x, \
+ pdst, pdst); \
+ INTER_SCRLMSKINS(iplendtab[n], planemask, psrc, m, \
+ INTER_NEXT(pdst), INTER_NEXT(pdst)); \
+ }
+
+#define INTER_putbitsrop(psrc, x, w, pdst, planemask, rop) \
+if ( ((x)+(w)) <= INTER_PPG) \
+{ \
+ INTER_DECLAREG(tmpmask); \
+ INTER_DECLAREGP(t1); INTER_DECLAREGP(t2); \
+ INTER_maskpartialbits((x), (w), tmpmask); \
+ INTER_SCRRIGHT((x), (psrc), (t1)); \
+ INTER_DoRop(t2, rop, t1, pdst); \
+ INTER_PMSKINS(tmpmask, planemask, t2, pdst, pdst); \
+} \
+else \
+{ \
+ unsigned long m; \
+ unsigned long n; \
+ INTER_DECLAREGP(t1); INTER_DECLAREGP(t2); \
+ m = INTER_PPG-(x); \
+ n = (w) - m; \
+ INTER_SCRRIGHT((x), (psrc), (t1)); \
+ INTER_DoRop(t2, rop, t1, pdst); \
+ INTER_PMSKINS(iplstarttab[x], planemask, t2, pdst, pdst); \
+ INTER_SCRLEFT(m, (psrc), (t1)); \
+ INTER_DoRop(t2, rop, t1, pdst+1); \
+ INTER_PMSKINS(iplendtab[n], planemask, t2, pdst, pdst); \
+}
+
+#define INTER_putbitsmropshort(src, x, w, pdst) { \
+ INTER_DECLAREG(_tmpmask); \
+ INTER_DECLAREGP(_t1); \
+ INTER_maskpartialbits((x), (w), _tmpmask); \
+ INTER_SCRRIGHT((x), (src), _t1); \
+ INTER_DoMaskMergeRop(_t1, pdst, _tmpmask, pdst); \
+}
+
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplpack.c b/nx-X11/programs/Xserver/iplan2p4/iplpack.c
new file mode 100644
index 000000000..a6ca6f12b
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplpack.c
@@ -0,0 +1,316 @@
+/* $XFree86$ */
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+/* abcd abcd abcd abcd abcd abcd abcd abcd */
+/* aaaa aaaa bbbb bbbb cccc cccc dddd dddd */
+
+unsigned long tabi[256] = {
+ 0x00000000,0x00001000,0x10000000,0x10001000,
+ 0x00002000,0x00003000,0x10002000,0x10003000,
+ 0x20000000,0x20001000,0x30000000,0x30001000,
+ 0x20002000,0x20003000,0x30002000,0x30003000,
+ 0x00004000,0x00005000,0x10004000,0x10005000,
+ 0x00006000,0x00007000,0x10006000,0x10007000,
+ 0x20004000,0x20005000,0x30004000,0x30005000,
+ 0x20006000,0x20007000,0x30006000,0x30007000,
+ 0x40000000,0x40001000,0x50000000,0x50001000,
+ 0x40002000,0x40003000,0x50002000,0x50003000,
+ 0x60000000,0x60001000,0x70000000,0x70001000,
+ 0x60002000,0x60003000,0x70002000,0x70003000,
+ 0x40004000,0x40005000,0x50004000,0x50005000,
+ 0x40006000,0x40007000,0x50006000,0x50007000,
+ 0x60004000,0x60005000,0x70004000,0x70005000,
+ 0x60006000,0x60007000,0x70006000,0x70007000,
+ 0x00008000,0x00009000,0x10008000,0x10009000,
+ 0x0000a000,0x0000b000,0x1000a000,0x1000b000,
+ 0x20008000,0x20009000,0x30008000,0x30009000,
+ 0x2000a000,0x2000b000,0x3000a000,0x3000b000,
+ 0x0000c000,0x0000d000,0x1000c000,0x1000d000,
+ 0x0000e000,0x0000f000,0x1000e000,0x1000f000,
+ 0x2000c000,0x2000d000,0x3000c000,0x3000d000,
+ 0x2000e000,0x2000f000,0x3000e000,0x3000f000,
+ 0x40008000,0x40009000,0x50008000,0x50009000,
+ 0x4000a000,0x4000b000,0x5000a000,0x5000b000,
+ 0x60008000,0x60009000,0x70008000,0x70009000,
+ 0x6000a000,0x6000b000,0x7000a000,0x7000b000,
+ 0x4000c000,0x4000d000,0x5000c000,0x5000d000,
+ 0x4000e000,0x4000f000,0x5000e000,0x5000f000,
+ 0x6000c000,0x6000d000,0x7000c000,0x7000d000,
+ 0x6000e000,0x6000f000,0x7000e000,0x7000f000,
+ 0x80000000,0x80001000,0x90000000,0x90001000,
+ 0x80002000,0x80003000,0x90002000,0x90003000,
+ 0xa0000000,0xa0001000,0xb0000000,0xb0001000,
+ 0xa0002000,0xa0003000,0xb0002000,0xb0003000,
+ 0x80004000,0x80005000,0x90004000,0x90005000,
+ 0x80006000,0x80007000,0x90006000,0x90007000,
+ 0xa0004000,0xa0005000,0xb0004000,0xb0005000,
+ 0xa0006000,0xa0007000,0xb0006000,0xb0007000,
+ 0xc0000000,0xc0001000,0xd0000000,0xd0001000,
+ 0xc0002000,0xc0003000,0xd0002000,0xd0003000,
+ 0xe0000000,0xe0001000,0xf0000000,0xf0001000,
+ 0xe0002000,0xe0003000,0xf0002000,0xf0003000,
+ 0xc0004000,0xc0005000,0xd0004000,0xd0005000,
+ 0xc0006000,0xc0007000,0xd0006000,0xd0007000,
+ 0xe0004000,0xe0005000,0xf0004000,0xf0005000,
+ 0xe0006000,0xe0007000,0xf0006000,0xf0007000,
+ 0x80008000,0x80009000,0x90008000,0x90009000,
+ 0x8000a000,0x8000b000,0x9000a000,0x9000b000,
+ 0xa0008000,0xa0009000,0xb0008000,0xb0009000,
+ 0xa000a000,0xa000b000,0xb000a000,0xb000b000,
+ 0x8000c000,0x8000d000,0x9000c000,0x9000d000,
+ 0x8000e000,0x8000f000,0x9000e000,0x9000f000,
+ 0xa000c000,0xa000d000,0xb000c000,0xb000d000,
+ 0xa000e000,0xa000f000,0xb000e000,0xb000f000,
+ 0xc0008000,0xc0009000,0xd0008000,0xd0009000,
+ 0xc000a000,0xc000b000,0xd000a000,0xd000b000,
+ 0xe0008000,0xe0009000,0xf0008000,0xf0009000,
+ 0xe000a000,0xe000b000,0xf000a000,0xf000b000,
+ 0xc000c000,0xc000d000,0xd000c000,0xd000d000,
+ 0xc000e000,0xc000f000,0xd000e000,0xd000f000,
+ 0xe000c000,0xe000d000,0xf000c000,0xf000d000,
+ 0xe000e000,0xe000f000,0xf000e000,0xf000f000,
+ };
+static unsigned long tabp[256] = {
+ 0x00000000,0x00020000,0x00080000,0x000a0000,
+ 0x00200000,0x00220000,0x00280000,0x002a0000,
+ 0x00800000,0x00820000,0x00880000,0x008a0000,
+ 0x00a00000,0x00a20000,0x00a80000,0x00aa0000,
+ 0x02000000,0x02020000,0x02080000,0x020a0000,
+ 0x02200000,0x02220000,0x02280000,0x022a0000,
+ 0x02800000,0x02820000,0x02880000,0x028a0000,
+ 0x02a00000,0x02a20000,0x02a80000,0x02aa0000,
+ 0x08000000,0x08020000,0x08080000,0x080a0000,
+ 0x08200000,0x08220000,0x08280000,0x082a0000,
+ 0x08800000,0x08820000,0x08880000,0x088a0000,
+ 0x08a00000,0x08a20000,0x08a80000,0x08aa0000,
+ 0x0a000000,0x0a020000,0x0a080000,0x0a0a0000,
+ 0x0a200000,0x0a220000,0x0a280000,0x0a2a0000,
+ 0x0a800000,0x0a820000,0x0a880000,0x0a8a0000,
+ 0x0aa00000,0x0aa20000,0x0aa80000,0x0aaa0000,
+ 0x20000000,0x20020000,0x20080000,0x200a0000,
+ 0x20200000,0x20220000,0x20280000,0x202a0000,
+ 0x20800000,0x20820000,0x20880000,0x208a0000,
+ 0x20a00000,0x20a20000,0x20a80000,0x20aa0000,
+ 0x22000000,0x22020000,0x22080000,0x220a0000,
+ 0x22200000,0x22220000,0x22280000,0x222a0000,
+ 0x22800000,0x22820000,0x22880000,0x228a0000,
+ 0x22a00000,0x22a20000,0x22a80000,0x22aa0000,
+ 0x28000000,0x28020000,0x28080000,0x280a0000,
+ 0x28200000,0x28220000,0x28280000,0x282a0000,
+ 0x28800000,0x28820000,0x28880000,0x288a0000,
+ 0x28a00000,0x28a20000,0x28a80000,0x28aa0000,
+ 0x2a000000,0x2a020000,0x2a080000,0x2a0a0000,
+ 0x2a200000,0x2a220000,0x2a280000,0x2a2a0000,
+ 0x2a800000,0x2a820000,0x2a880000,0x2a8a0000,
+ 0x2aa00000,0x2aa20000,0x2aa80000,0x2aaa0000,
+ 0x80000000,0x80020000,0x80080000,0x800a0000,
+ 0x80200000,0x80220000,0x80280000,0x802a0000,
+ 0x80800000,0x80820000,0x80880000,0x808a0000,
+ 0x80a00000,0x80a20000,0x80a80000,0x80aa0000,
+ 0x82000000,0x82020000,0x82080000,0x820a0000,
+ 0x82200000,0x82220000,0x82280000,0x822a0000,
+ 0x82800000,0x82820000,0x82880000,0x828a0000,
+ 0x82a00000,0x82a20000,0x82a80000,0x82aa0000,
+ 0x88000000,0x88020000,0x88080000,0x880a0000,
+ 0x88200000,0x88220000,0x88280000,0x882a0000,
+ 0x88800000,0x88820000,0x88880000,0x888a0000,
+ 0x88a00000,0x88a20000,0x88a80000,0x88aa0000,
+ 0x8a000000,0x8a020000,0x8a080000,0x8a0a0000,
+ 0x8a200000,0x8a220000,0x8a280000,0x8a2a0000,
+ 0x8a800000,0x8a820000,0x8a880000,0x8a8a0000,
+ 0x8aa00000,0x8aa20000,0x8aa80000,0x8aaa0000,
+ 0xa0000000,0xa0020000,0xa0080000,0xa00a0000,
+ 0xa0200000,0xa0220000,0xa0280000,0xa02a0000,
+ 0xa0800000,0xa0820000,0xa0880000,0xa08a0000,
+ 0xa0a00000,0xa0a20000,0xa0a80000,0xa0aa0000,
+ 0xa2000000,0xa2020000,0xa2080000,0xa20a0000,
+ 0xa2200000,0xa2220000,0xa2280000,0xa22a0000,
+ 0xa2800000,0xa2820000,0xa2880000,0xa28a0000,
+ 0xa2a00000,0xa2a20000,0xa2a80000,0xa2aa0000,
+ 0xa8000000,0xa8020000,0xa8080000,0xa80a0000,
+ 0xa8200000,0xa8220000,0xa8280000,0xa82a0000,
+ 0xa8800000,0xa8820000,0xa8880000,0xa88a0000,
+ 0xa8a00000,0xa8a20000,0xa8a80000,0xa8aa0000,
+ 0xaa000000,0xaa020000,0xaa080000,0xaa0a0000,
+ 0xaa200000,0xaa220000,0xaa280000,0xaa2a0000,
+ 0xaa800000,0xaa820000,0xaa880000,0xaa8a0000,
+ 0xaaa00000,0xaaa20000,0xaaa80000,0xaaaa0000,
+ };
+
+void
+iplUnpackLine(int planes, int longs, unsigned int *psrc, unsigned short *ipsrc)
+{
+ unsigned long temp,m;
+ unsigned char *t=(unsigned char *) &temp;
+ unsigned char *i=(unsigned char *) ipsrc;
+ unsigned char *s=(unsigned char *) psrc;
+ int j,off;
+ switch (planes) {
+ case 2:
+ for (j = 0 ; j < longs ; j++)
+ {
+ *((long *) ipsrc)++=(tabi[s[0]] >> 0) |
+ (tabi[s[1]] >> 4) |
+ (tabi[s[2]] >> 8) |
+ (tabi[s[3]] >> 12);
+ s+=4;
+ }
+ break;
+ case 4:
+ for (j = 0 ; j < longs ; j++)
+ {
+ temp= (tabi[s[0]] >> 0) |
+ (tabi[s[1]] >> 4) |
+ (tabi[s[2]] >> 8) |
+ (tabi[s[3]] >> 12);
+ temp= (tabi[t[0]] >> 0) |
+ (tabi[t[1]] >> 4) |
+ (tabi[t[2]] >> 8) |
+ (tabi[t[3]] >> 12);
+ s+=4;
+ if (j & 1) {
+ i[7]=t[0];
+ i[5]=t[1];
+ i[3]=t[2];
+ i[1]=t[3];
+ i += 8;
+ }
+ else {
+ i[6]=t[0];
+ i[4]=t[1];
+ i[2]=t[2];
+ i[0]=t[3];
+ }
+ }
+ break;
+ case 8:
+ for (j = 0 ; j < longs ; j++)
+ {
+ temp= (tabi[s[0]] >> 0) |
+ (tabi[s[1]] >> 4) |
+ (tabi[s[2]] >> 8) |
+ (tabi[s[3]] >> 12);
+
+ temp= (tabi[t[0]] >> 0) |
+ (tabi[t[1]] >> 4) |
+ (tabi[t[2]] >> 8) |
+ (tabi[t[3]] >> 12);
+
+ temp= (tabi[t[0]] >> 0) |
+ (tabi[t[1]] >> 4) |
+ (tabi[t[2]] >> 8) |
+ (tabi[t[3]] >> 12);
+
+ off=12-(j & 3)*4;
+ m=0xf << off;
+ ipsrc[7]=(ipsrc[7] & ~m) | (((temp >> 28) << off) & m);
+ ipsrc[6]=(ipsrc[6] & ~m) | (((temp >> 24) << off) & m);
+ ipsrc[5]=(ipsrc[5] & ~m) | (((temp >> 20) << off) & m);
+ ipsrc[4]=(ipsrc[4] & ~m) | (((temp >> 16) << off) & m);
+ ipsrc[3]=(ipsrc[3] & ~m) | (((temp >> 12) << off) & m);
+ ipsrc[2]=(ipsrc[2] & ~m) | (((temp >> 8) << off) & m);
+ ipsrc[1]=(ipsrc[1] & ~m) | (((temp >> 4) << off) & m);
+ ipsrc[0]=(ipsrc[0] & ~m) | (((temp >> 0) << off) & m);
+ if (! off)
+ ipsrc +=8;
+ s+=4;
+ }
+ }
+}
+
+void
+iplPackLine(int planes, int longs, unsigned short *ipdst, unsigned int *pdst)
+{
+ unsigned long temp,m;
+ unsigned char *t=(unsigned char *) &temp;
+ unsigned char *i=(unsigned char *) ipdst;
+ int j,off;
+ switch (planes) {
+ case 2:
+ for (j = 0 ; j < longs ; j++)
+ {
+ *pdst++=(tabp[i[2]] >> 0) |
+ (tabp[i[0]] >> 1) |
+ (tabp[i[3]] >> 16) |
+ (tabp[i[1]] >> 17);
+ i+=4;
+ }
+ break;
+ case 4:
+ for (j = 0 ; j < longs ; j++)
+ {
+ if (j & 1) {
+ temp= (tabp[i[7]] >> 0) |
+ (tabp[i[3]] >> 1) |
+ (tabp[i[5]] >> 16) |
+ (tabp[i[1]] >> 17);
+ i += 8;
+ }
+ else {
+ temp= (tabp[i[6]] >> 0) |
+ (tabp[i[2]] >> 1) |
+ (tabp[i[4]] >> 16) |
+ (tabp[i[0]] >> 17);
+ }
+ *pdst++=(tabp[t[0]] >> 0) |
+ (tabp[t[2]] >> 1) |
+ (tabp[t[1]] >> 16) |
+ (tabp[t[3]] >> 17);
+ }
+ break;
+ case 8:
+ for (j = 0 ; j < longs ; j++)
+ {
+ off=12-(j & 3)*4;
+ m=0xf;
+ temp=(((ipdst[7] >> off) & m) << 28) |
+ (((ipdst[6] >> off) & m) << 24) |
+ (((ipdst[5] >> off) & m) << 20) |
+ (((ipdst[4] >> off) & m) << 16) |
+ (((ipdst[3] >> off) & m) << 12) |
+ (((ipdst[2] >> off) & m) << 8) |
+ (((ipdst[1] >> off) & m) << 4) |
+ (((ipdst[0] >> off) & m) << 0);
+
+ if (! off)
+ ipdst +=8;
+
+ temp= (tabp[t[0]] >> 0) |
+ (tabp[t[2]] >> 1) |
+ (tabp[t[1]] >> 16) |
+ (tabp[t[3]] >> 17);
+
+ temp= (tabp[t[0]] >> 0) |
+ (tabp[t[2]] >> 1) |
+ (tabp[t[1]] >> 16) |
+ (tabp[t[3]] >> 17);
+
+ *pdst++=(tabp[t[0]] >> 0) |
+ (tabp[t[2]] >> 1) |
+ (tabp[t[1]] >> 16) |
+ (tabp[t[3]] >> 17);
+ }
+ }
+}
+
+unsigned long
+iplpack(unsigned long ipl)
+{
+ unsigned char *ic=(unsigned char *) &ipl;
+ return (tabp[ic[0]]) | /* a0a0a0a0a0a0a0a00000000000000000 */
+ (tabp[ic[2]] >> 1) | /* abababababababab0000000000000000 */
+ (tabp[ic[1]] >> 16) | /* ababababababababa0a0a0a0a0a0a0a0 */
+ (tabp[ic[3]] >> 17); /* abababababababababababababababab */
+}
+
+unsigned long
+iplunpack(unsigned long pack)
+{
+ unsigned char *ip=(unsigned char *) &pack;
+ return (tabi[ip[0]]) | /* aaaa000000000000bbbb000000000000 */
+ (tabi[ip[1]] >> 4) | /* aaaaaaaa00000000bbbbbbbb00000000 */
+ (tabi[ip[2]] >> 8) | /* aaaaaaaaaaaa0000bbbbbbbbbbbb0000 */
+ (tabi[ip[3]] >> 12); /* aaaaaaaaaaaaaaaabbbbbbbbbbbbbbbb */
+}
+
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplpack.h b/nx-X11/programs/Xserver/iplan2p4/iplpack.h
new file mode 100644
index 000000000..53c2c988f
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplpack.h
@@ -0,0 +1,10 @@
+/* $XFree86$ */
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#define NUM_LONGS(planes, xs, xe) \
+ (((((xe) * (planes) + 31) & ~31) - \
+ (((xs) * (planes)) & ~31))/32)
+
+#define NUM_TEMP_BYTES(planes, longs) \
+ (((2 * (longs) + (planes) - 1) / planes + 1) * planes * 2)
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplpixmap.c b/nx-X11/programs/Xserver/iplan2p4/iplpixmap.c
new file mode 100644
index 000000000..7bfb49551
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplpixmap.c
@@ -0,0 +1,386 @@
+/* $XFree86: xc/programs/Xserver/iplan2p4/iplpixmap.c,v 3.0 1996/08/18 01:54:59 dawes Exp $ */
+/* $XConsortium: iplpixmap.c,v 5.14 94/04/17 20:28:56 dpw Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* pixmap management
+ written by drewry, september 1986
+
+ on a monchrome device, a pixmap is a bitmap.
+*/
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "mi.h"
+#include "ipl.h"
+#include "iplmskbits.h"
+
+extern unsigned long endtab[];
+
+PixmapPtr
+iplCreatePixmap (pScreen, width, height, depth)
+ ScreenPtr pScreen;
+ int width;
+ int height;
+ int depth;
+{
+ PixmapPtr pPixmap;
+ size_t datasize;
+ size_t paddedWidth;
+ int ipad=INTER_PLANES*2 - 1;
+
+ paddedWidth = PixmapBytePad(width, depth);
+ paddedWidth = (paddedWidth + ipad) & ~ipad;
+ if (paddedWidth / 4 > 32767 || height > 32767)
+ return NullPixmap;
+ datasize = height * paddedWidth;
+ pPixmap = AllocatePixmap(pScreen, datasize);
+ if (!pPixmap)
+ return NullPixmap;
+ pPixmap->drawable.type = DRAWABLE_PIXMAP;
+ pPixmap->drawable.class = 0;
+ pPixmap->drawable.pScreen = pScreen;
+ pPixmap->drawable.depth = depth;
+ pPixmap->drawable.bitsPerPixel = BitsPerPixel(depth);
+ pPixmap->drawable.id = 0;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pPixmap->drawable.x = 0;
+ pPixmap->drawable.y = 0;
+ pPixmap->drawable.width = width;
+ pPixmap->drawable.height = height;
+ pPixmap->devKind = paddedWidth;
+ pPixmap->refcnt = 1;
+#ifdef PIXPRIV
+ pPixmap->devPrivate.ptr = datasize ?
+ (pointer)((char *)pPixmap + pScreen->totalPixmapSize) : NULL;
+#else
+ pPixmap->devPrivate.ptr = (pointer)((long)(pPixmap + 1));
+#endif
+ return pPixmap;
+}
+
+Bool
+iplDestroyPixmap(pPixmap)
+ PixmapPtr pPixmap;
+{
+ if(--pPixmap->refcnt)
+ return TRUE;
+ xfree(pPixmap);
+ return TRUE;
+}
+
+PixmapPtr
+iplCopyPixmap(pSrc)
+ register PixmapPtr pSrc;
+{
+ register PixmapPtr pDst;
+ int size;
+ ScreenPtr pScreen;
+
+ size = pSrc->drawable.height * pSrc->devKind;
+ pScreen = pSrc->drawable.pScreen;
+ pDst = (*pScreen->CreatePixmap) (pScreen, pSrc->drawable.width,
+ pSrc->drawable.height, pSrc->drawable.depth);
+ if (!pDst)
+ return NullPixmap;
+ memmove((char *)pDst->devPrivate.ptr, (char *)pSrc->devPrivate.ptr, size);
+ return pDst;
+}
+
+
+/* replicates a pattern to be a full 32 bits wide.
+ relies on the fact that each scnaline is longword padded.
+ doesn't do anything if pixmap is not a factor of 32 wide.
+ changes width field of pixmap if successful, so that the fast
+ iplXRotatePixmap code gets used if we rotate the pixmap later.
+ iplYRotatePixmap code gets used if we rotate the pixmap later.
+
+ calculate number of times to repeat
+ for each scanline of pattern
+ zero out area to be filled with replicate
+ left shift and or in original as many times as needed
+*/
+
+void
+iplPadPixmap(pPixmap)
+ PixmapPtr pPixmap;
+{
+ register int width = pPixmap->drawable.width;
+ register int h;
+ register unsigned short mask;
+ register unsigned short *p;
+ register unsigned short bits; /* real pattern bits */
+ register int i;
+ int rep; /* repeat count for pattern */
+
+ if (width >= INTER_PGSZ)
+ return;
+
+ rep = INTER_PGSZ/width;
+/* if (rep*width != INTER_PGSZ)
+ return; */
+
+ mask = iplendtab[width];
+
+ p = (unsigned short *)(pPixmap->devPrivate.ptr);
+ for (h=0; h < pPixmap->drawable.height * INTER_PLANES; h++)
+ {
+ *p &= mask;
+ bits = *p ;
+ for(i=1; i<rep; i++)
+ {
+#if (BITMAP_BIT_ORDER == MSBFirst)
+ bits >>= width;
+#else
+ bits <<= width;
+#endif
+ *p |= bits;
+ }
+ p++;
+ }
+ pPixmap->drawable.width = rep*width; /* PGSZ/(pPixmap->drawable.bitsPerPixel); */
+}
+
+
+#ifdef notdef
+/*
+ * ipl debugging routine -- assumes pixmap is 1 byte deep
+ */
+static ipldumppixmap(pPix)
+ PixmapPtr pPix;
+{
+ unsigned int *pw;
+ char *psrc, *pdst;
+ int i, j;
+ char line[66];
+
+ ErrorF( "pPixmap: 0x%x\n", pPix);
+ ErrorF( "%d wide %d high\n", pPix->drawable.width, pPix->drawable.height);
+ if (pPix->drawable.width > 64)
+ {
+ ErrorF( "too wide to see\n");
+ return;
+ }
+
+ pw = (unsigned int *) pPix->devPrivate.ptr;
+ psrc = (char *) pw;
+
+/*
+ for ( i=0; i<pPix->drawable.height; ++i )
+ ErrorF( "0x%x\n", pw[i] );
+*/
+
+ for ( i = 0; i < pPix->drawable.height; ++i ) {
+ pdst = line;
+ for(j = 0; j < pPix->drawable.width; j++) {
+ *pdst++ = *psrc++ ? 'X' : ' ' ;
+ }
+ *pdst++ = '\n';
+ *pdst++ = '\0';
+ ErrorF( "%s", line);
+ }
+}
+#endif /* notdef */
+
+/* Rotates pixmap pPix by w pixels to the right on the screen. Assumes that
+ * words are PGSZ bits wide, and that the least significant bit appears on the
+ * left.
+ */
+void
+iplXRotatePixmap(pPix, rw)
+ PixmapPtr pPix;
+ register int rw;
+{
+ INTER_DECLAREG(*pw);
+ INTER_DECLAREG(*pwFinal);
+ INTER_DECLAREGP(t);
+ int rot;
+
+ if (pPix == NullPixmap)
+ return;
+
+ switch (((DrawablePtr) pPix)->bitsPerPixel) {
+ case INTER_PLANES:
+ break;
+ case 1:
+ mfbXRotatePixmap(pPix, rw);
+ return;
+ default:
+ ErrorF("iplXRotatePixmap: unsupported bitsPerPixel %d\n", ((DrawablePtr) pPix)->bitsPerPixel);
+ return;
+ }
+ pw = (unsigned short *)pPix->devPrivate.ptr;
+ modulus (rw, (int) pPix->drawable.width, rot);
+ if(pPix->drawable.width == 16)
+ {
+ pwFinal = pw + pPix->drawable.height * INTER_PLANES;
+ while(pw < pwFinal)
+ {
+ INTER_COPY(pw, t);
+ INTER_MSKINSM(iplendtab[rot], INTER_PPG-rot, t,
+ ~0, rot, t, pw)
+ INTER_NEXT_GROUP(pw);
+ }
+ }
+ else
+ {
+ ErrorF("ipl internal error: trying to rotate odd-sized pixmap.\n");
+#ifdef notdef
+ register unsigned long *pwTmp;
+ int size, tsize;
+
+ tsize = PixmapBytePad(pPix->drawable.width - rot, pPix->drawable.depth);
+ pwTmp = (unsigned long *) ALLOCATE_LOCAL(pPix->drawable.height * tsize);
+ if (!pwTmp)
+ return;
+ /* divide pw (the pixmap) in two vertically at (w - rot) and swap */
+ tsize >>= 2;
+ size = pPix->devKind >> SIZE0F(PixelGroup);
+ iplQuickBlt((long *)pw, (long *)pwTmp,
+ 0, 0, 0, 0,
+ (int)pPix->drawable.width - rot, (int)pPix->drawable.height,
+ size, tsize);
+ iplQuickBlt((long *)pw, (long *)pw,
+ (int)pPix->drawable.width - rot, 0, 0, 0,
+ rot, (int)pPix->drawable.height,
+ size, size);
+ iplQuickBlt((long *)pwTmp, (long *)pw,
+ 0, 0, rot, 0,
+ (int)pPix->drawable.width - rot, (int)pPix->drawable.height,
+ tsize, size);
+ DEALLOCATE_LOCAL(pwTmp);
+#endif
+ }
+}
+
+/* Rotates pixmap pPix by h lines. Assumes that h is always less than
+ pPix->drawable.height
+ works on any width.
+ */
+void
+iplYRotatePixmap(pPix, rh)
+ register PixmapPtr pPix;
+ int rh;
+{
+ int nbyDown; /* bytes to move down to row 0; also offset of
+ row rh */
+ int nbyUp; /* bytes to move up to line rh; also
+ offset of first line moved down to 0 */
+ char *pbase;
+ char *ptmp;
+ int rot;
+
+ if (pPix == NullPixmap)
+ return;
+ switch (((DrawablePtr) pPix)->bitsPerPixel) {
+ case INTER_PLANES:
+ break;
+ case 1:
+ mfbYRotatePixmap(pPix, rh);
+ return;
+ default:
+ ErrorF("iplYRotatePixmap: unsupported bitsPerPixel %d\n", ((DrawablePtr) pPix)->bitsPerPixel);
+ return;
+ }
+
+ modulus (rh, (int) pPix->drawable.height, rot);
+ pbase = (char *)pPix->devPrivate.ptr;
+
+ nbyDown = rot * pPix->devKind;
+ nbyUp = (pPix->devKind * pPix->drawable.height) - nbyDown;
+ if(!(ptmp = (char *)ALLOCATE_LOCAL(nbyUp)))
+ return;
+
+ memmove(ptmp, pbase, nbyUp); /* save the low rows */
+ memmove(pbase, pbase+nbyUp, nbyDown); /* slide the top rows down */
+ memmove(pbase+nbyDown, ptmp, nbyUp); /* move lower rows up to row rot */
+ DEALLOCATE_LOCAL(ptmp);
+}
+
+void
+iplCopyRotatePixmap(psrcPix, ppdstPix, xrot, yrot)
+ register PixmapPtr psrcPix, *ppdstPix;
+ int xrot, yrot;
+{
+ register PixmapPtr pdstPix;
+
+ if ((pdstPix = *ppdstPix) &&
+ (pdstPix->devKind == psrcPix->devKind) &&
+ (pdstPix->drawable.height == psrcPix->drawable.height))
+ {
+ memmove((char *)pdstPix->devPrivate.ptr,
+ (char *)psrcPix->devPrivate.ptr,
+ psrcPix->drawable.height * psrcPix->devKind);
+ pdstPix->drawable.width = psrcPix->drawable.width;
+ pdstPix->drawable.depth = psrcPix->drawable.depth;
+ pdstPix->drawable.bitsPerPixel = psrcPix->drawable.bitsPerPixel;
+ pdstPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ }
+ else
+ {
+ if (pdstPix)
+ /* FIX XBUG 6168 */
+ (*pdstPix->drawable.pScreen->DestroyPixmap)(pdstPix);
+ *ppdstPix = pdstPix = iplCopyPixmap(psrcPix);
+ if (!pdstPix)
+ return;
+ }
+ iplPadPixmap(pdstPix);
+ if (xrot)
+ iplXRotatePixmap(pdstPix, xrot);
+ if (yrot)
+ iplYRotatePixmap(pdstPix, yrot);
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplply1rct.c b/nx-X11/programs/Xserver/iplan2p4/iplply1rct.c
new file mode 100644
index 000000000..bac2be4ed
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplply1rct.c
@@ -0,0 +1,310 @@
+/* $XFree86: xc/programs/Xserver/iplan2p4/iplply1rct.c,v 3.0 1996/08/18 01:55:00 dawes Exp $ */
+/*
+ * $XConsortium: iplply1rct.c,v 1.14 94/04/17 20:28:56 dpw Exp $
+ *
+Copyright (c) 1990 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "mistruct.h"
+
+#include "ipl.h"
+#include "iplrrop.h"
+
+#include "iplmskbits.h"
+
+void
+INTER_RROP_NAME(iplFillPoly1Rect) (pDrawable, pGC, shape, mode, count, ptsIn)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int count;
+ DDXPointPtr ptsIn;
+{
+ iplPrivGCPtr devPriv;
+ int ngwidth;
+ unsigned short *addrl, *addr;
+ int maxy;
+ int origin;
+ register int vertex1, vertex2;
+ int c;
+ BoxPtr extents;
+ int clip;
+ int y;
+ int *vertex1p, *vertex2p;
+ int *endp;
+ int x1, x2;
+ int dx1, dx2;
+ int dy1, dy2;
+ int e1, e2;
+ int step1, step2;
+ int sign1, sign2;
+ int h;
+ int l, r;
+ INTER_DECLAREG(mask);
+ INTER_DECLAREG(bits);
+ int nmiddle;
+ INTER_RROP_DECLARE
+ bits=~0;
+
+ if (mode == CoordModePrevious)
+ {
+ miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ devPriv = iplGetGCPrivate(pGC);
+#ifdef NO_ONE_RECT
+ if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1)
+ {
+ miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+#endif
+ origin = *((int *) &pDrawable->x);
+ origin -= (origin & 0x8000) << 1;
+ extents = &pGC->pCompositeClip->extents;
+ INTER_RROP_FETCH_GCPRIV(devPriv);
+ vertex1 = *((int *) &extents->x1) - origin;
+ vertex2 = *((int *) &extents->x2) - origin - 0x00010001;
+ clip = 0;
+ y = 32767;
+ maxy = 0;
+ vertex2p = (int *) ptsIn;
+ endp = vertex2p + count;
+ if (shape == Convex)
+ {
+ while (count--)
+ {
+ c = *vertex2p;
+ clip |= (c - vertex1) | (vertex2 - c);
+ c = intToY(c);
+ if (c < y)
+ {
+ y = c;
+ vertex1p = vertex2p;
+ }
+ vertex2p++;
+ if (c > maxy)
+ maxy = c;
+ }
+ }
+ else
+ {
+ int yFlip = 0;
+ dx1 = 1;
+ x2 = -1;
+ x1 = -1;
+ while (count--)
+ {
+ c = *vertex2p;
+ clip |= (c - vertex1) | (vertex2 - c);
+ c = intToY(c);
+ if (c < y)
+ {
+ y = c;
+ vertex1p = vertex2p;
+ }
+ vertex2p++;
+ if (c > maxy)
+ maxy = c;
+ if (c == x1)
+ continue;
+ if (dx1 > 0)
+ {
+ if (x2 < 0)
+ x2 = c;
+ else
+ dx2 = dx1 = (c - x1) >> 31;
+ }
+ else
+ if ((c - x1) >> 31 != dx1)
+ {
+ dx1 = ~dx1;
+ yFlip++;
+ }
+ x1 = c;
+ }
+ x1 = (x2 - c) >> 31;
+ if (x1 != dx1)
+ yFlip++;
+ if (x1 != dx2)
+ yFlip++;
+ if (yFlip != 2)
+ clip = 0x8000;
+ }
+ if (y == maxy)
+ return;
+
+ if (clip & 0x80008000)
+ {
+ miFillPolygon (pDrawable, pGC, shape, mode, vertex2p - (int *) ptsIn, ptsIn);
+ return;
+ }
+
+#define AddrYPlus(a,y) ((a) + (y) * ngwidth)
+
+ iplGetGroupWidthAndPointer(pDrawable, ngwidth, addrl);
+ addrl = AddrYPlus(addrl,y + pDrawable->y);
+ origin = intToX(origin);
+ vertex2p = vertex1p;
+ vertex2 = vertex1 = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+#define Setup(c,x,vertex,dx,dy,e,sign,step) {\
+ x = intToX(vertex); \
+ if (dy = intToY(c) - y) { \
+ dx = intToX(c) - x; \
+ step = 0; \
+ if (dx >= 0) \
+ { \
+ e = 0; \
+ sign = 1; \
+ if (dx >= dy) {\
+ step = dx / dy; \
+ dx = dx % dy; \
+ } \
+ } \
+ else \
+ { \
+ e = 1 - dy; \
+ sign = -1; \
+ dx = -dx; \
+ if (dx >= dy) { \
+ step = - (dx / dy); \
+ dx = dx % dy; \
+ } \
+ } \
+ } \
+ x += origin; \
+ vertex = c; \
+}
+
+#define Step(x,dx,dy,e,sign,step) {\
+ x += step; \
+ if ((e += dx) > 0) \
+ { \
+ x += sign; \
+ e -= dy; \
+ } \
+}
+ for (;;)
+ {
+ if (y == intToY(vertex1))
+ {
+ do
+ {
+ if (vertex1p == (int *) ptsIn)
+ vertex1p = endp;
+ c = *--vertex1p;
+ Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1)
+ } while (y >= intToY(vertex1));
+ h = dy1;
+ }
+ else
+ {
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ h = intToY(vertex1) - y;
+ }
+ if (y == intToY(vertex2))
+ {
+ do
+ {
+ c = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+ Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2)
+ } while (y >= intToY(vertex2));
+ if (dy2 < h)
+ h = dy2;
+ }
+ else
+ {
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ if ((c = (intToY(vertex2) - y)) < h)
+ h = c;
+ }
+ /* fill spans for this segment */
+ y += h;
+ for (;;)
+ {
+ l = x1;
+ r = x2;
+ nmiddle = x2 - x1;
+ if (nmiddle < 0)
+ {
+ nmiddle = -nmiddle;
+ l = x2;
+ r = x1;
+ }
+ c = l & INTER_PIM;
+ l -= c;
+
+ addr = addrl + (l >> INTER_PGSH) * INTER_PLANES;
+ if (c + nmiddle < INTER_PPG)
+ {
+ mask = (bits >> c) ^ (bits >> (c+nmiddle));
+ INTER_RROP_SOLID_MASK(addr,mask);
+ }
+ else
+ {
+ if (c)
+ {
+ mask = bits >> c;
+ INTER_RROP_SOLID_MASK(addr,mask);
+ nmiddle += c - INTER_PPG;
+ INTER_NEXT_GROUP(addr);
+ }
+ nmiddle >>= INTER_PGSH;
+ while (--nmiddle >= 0) {
+ INTER_RROP_SOLID(addr); INTER_NEXT_GROUP(addr);
+ }
+ if (mask = ~(bits >> (r & INTER_PIM)))
+ INTER_RROP_SOLID_MASK(addr,mask);
+ }
+ if (!--h)
+ break;
+ addrl = AddrYPlus (addrl, 1);
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ }
+ if (y == maxy)
+ break;
+ addrl = AddrYPlus (addrl, 1);
+ }
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplpntwin.c b/nx-X11/programs/Xserver/iplan2p4/iplpntwin.c
new file mode 100644
index 000000000..8421ba377
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplpntwin.c
@@ -0,0 +1,341 @@
+/* $XFree86$ */
+/* $XConsortium: iplpntwin.c,v 5.18 94/04/17 20:28:57 dpw Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "windowstr.h"
+#include "regionstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "ipl.h"
+#include "mi.h"
+
+void
+iplPaintWindow(pWin, pRegion, what)
+ WindowPtr pWin;
+ RegionPtr pRegion;
+ int what;
+{
+ register iplPrivWin *pPrivWin;
+ WindowPtr pBgWin;
+
+ pPrivWin = iplGetWindowPrivate(pWin);
+
+ switch (what) {
+ case PW_BACKGROUND:
+ switch (pWin->backgroundState) {
+ case None:
+ break;
+ case ParentRelative:
+ do {
+ pWin = pWin->parent;
+ } while (pWin->backgroundState == ParentRelative);
+ (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
+ what);
+ break;
+ case BackgroundPixmap:
+ if (pPrivWin->fastBackground)
+ {
+ iplFillBoxTile32 ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pPrivWin->pRotatedBackground);
+ }
+ else
+ {
+ iplFillBoxTileOdd ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->background.pixmap,
+ (int) pWin->drawable.x, (int) pWin->drawable.y);
+ }
+ break;
+ case BackgroundPixel:
+ iplFillBoxSolid ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->background.pixel);
+ break;
+ }
+ break;
+ case PW_BORDER:
+ if (pWin->borderIsPixel)
+ {
+ iplFillBoxSolid ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->border.pixel);
+ }
+ else if (pPrivWin->fastBorder)
+ {
+ iplFillBoxTile32 ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pPrivWin->pRotatedBorder);
+ }
+ else
+ {
+ for (pBgWin = pWin;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+
+ iplFillBoxTileOdd ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->border.pixmap,
+ (int) pBgWin->drawable.x,
+ (int) pBgWin->drawable.y);
+ }
+ break;
+ }
+}
+
+/*
+ * Use the RROP macros in copy mode
+ */
+
+#define RROP GXcopy
+#include "iplrrop.h"
+#include "iplmskbits.h"
+
+
+# define Expand(left, right, leftAdjust) { \
+ int widthStep; \
+ widthStep = widthDst - (nmiddle + leftAdjust) * INTER_PLANES; \
+ while (h--) { \
+ left \
+ m = nmiddle; \
+ INTER_RROP_SPAN(pdst, m); \
+ right \
+ pdst += widthStep; \
+ } \
+}
+
+void
+iplFillBoxSolid (pDrawable, nBox, pBox, pixel)
+ DrawablePtr pDrawable;
+ int nBox;
+ BoxPtr pBox;
+ unsigned long pixel;
+{
+ INTER_DECLAREG(*pdstBase);
+ int widthDst;
+ register int h;
+ INTER_DECLAREGP(rrop_xor);
+ INTER_DECLAREG(*pdst);
+ INTER_DECLAREG(leftMask);
+ INTER_DECLAREG(rightMask);
+ int nmiddle;
+ register int m;
+ int w;
+
+ iplGetGroupWidthAndPointer(pDrawable, widthDst, pdstBase);
+
+ INTER_PFILL(pixel, rrop_xor);
+ for (; nBox; nBox--, pBox++)
+ {
+ pdst = pdstBase + pBox->y1 * widthDst;
+ h = pBox->y2 - pBox->y1;
+ w = pBox->x2 - pBox->x1;
+ pdst += (pBox->x1 >> INTER_PGSH) * INTER_PLANES;
+ if ((pBox->x1 & INTER_PIM) + w <= INTER_PPG)
+ {
+ INTER_maskpartialbits(pBox->x1, w, leftMask);
+ while (h--) {
+ INTER_COPYM(rrop_xor, pdst, leftMask, pdst);
+ pdst += widthDst;
+ }
+ }
+ else
+ {
+ INTER_maskbits (pBox->x1, w, leftMask, rightMask, nmiddle);
+ if (leftMask)
+ {
+ if (rightMask)
+ {
+ Expand (INTER_RROP_SOLID_MASK (pdst, leftMask);
+ INTER_NEXT_GROUP(pdst);,
+ INTER_RROP_SOLID_MASK (pdst, rightMask); ,
+ 1)
+ }
+ else
+ {
+ Expand (INTER_RROP_SOLID_MASK (pdst, leftMask);
+ INTER_NEXT_GROUP(pdst);,
+ ;,
+ 1)
+ }
+ }
+ else
+ {
+ if (rightMask)
+ {
+ Expand (;,
+ INTER_RROP_SOLID_MASK (pdst, rightMask);,
+ 0)
+ }
+ else
+ {
+ Expand (;,
+ ;,
+ 0)
+ }
+ }
+ }
+ }
+}
+
+void
+iplFillBoxTile32 (pDrawable, nBox, pBox, tile)
+ DrawablePtr pDrawable;
+ int nBox; /* number of boxes to fill */
+ BoxPtr pBox; /* pointer to list of boxes to fill */
+ PixmapPtr tile; /* rotated, expanded tile */
+{
+ INTER_DECLAREGP(rrop_xor);
+ INTER_DECLAREG(*pdst);
+ register int m;
+ INTER_DECLAREG(*psrc);
+ int tileHeight;
+
+ int widthDst;
+ int w;
+ int h;
+ INTER_DECLAREG(leftMask);
+ INTER_DECLAREG(rightMask);
+ int nmiddle;
+ int y;
+ int srcy;
+
+ INTER_DECLAREG(*pdstBase);
+
+ tileHeight = tile->drawable.height;
+ psrc = (unsigned short *)tile->devPrivate.ptr;
+
+
+ iplGetGroupWidthAndPointer (pDrawable, widthDst, pdstBase);
+
+ while (nBox--)
+ {
+ w = pBox->x2 - pBox->x1;
+ h = pBox->y2 - pBox->y1;
+ y = pBox->y1;
+ pdst = pdstBase + (pBox->y1 * widthDst) +
+ (pBox->x1 >> INTER_PGSH) * INTER_PLANES;
+ srcy = y % tileHeight;
+
+#define StepTile INTER_COPY(psrc + srcy * INTER_PLANES, rrop_xor); \
+ ++srcy; \
+ if (srcy == tileHeight) \
+ srcy = 0;
+
+ if ( ((pBox->x1 & INTER_PIM) + w) < INTER_PPG)
+ {
+ INTER_maskpartialbits(pBox->x1, w, leftMask);
+ rightMask = ~leftMask;
+ while (h--)
+ {
+ StepTile
+ INTER_MSKINSM(rightMask, 0, pdst, leftMask, 0, rrop_xor, pdst);
+ pdst += widthDst;
+ }
+ }
+ else
+ {
+ INTER_maskbits(pBox->x1, w, leftMask, rightMask, nmiddle);
+
+ if (leftMask)
+ {
+ if (rightMask)
+ {
+ Expand (StepTile
+ INTER_RROP_SOLID_MASK(pdst, leftMask);
+ INTER_NEXT_GROUP(pdst);,
+ INTER_RROP_SOLID_MASK(pdst, rightMask);,
+ 1)
+ }
+ else
+ {
+ Expand (StepTile
+ INTER_RROP_SOLID_MASK(pdst, leftMask);
+ INTER_NEXT_GROUP(pdst);,
+ ;,
+ 1)
+ }
+ }
+ else
+ {
+ if (rightMask)
+ {
+ Expand (StepTile
+ ,
+ INTER_RROP_SOLID_MASK(pdst, rightMask);,
+ 0)
+ }
+ else
+ {
+ Expand (StepTile
+ ,
+ ;,
+ 0)
+ }
+ }
+ }
+ pBox++;
+ }
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplpolypnt.c b/nx-X11/programs/Xserver/iplan2p4/iplpolypnt.c
new file mode 100644
index 000000000..61aea7ffd
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplpolypnt.c
@@ -0,0 +1,123 @@
+/* $XFree86: xc/programs/Xserver/iplan2p4/iplpolypnt.c,v 3.0 1996/08/18 01:55:02 dawes Exp $ */
+/************************************************************
+
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+********************************************************/
+
+/* $XConsortium: iplpolypnt.c,v 5.17 94/04/17 20:28:57 dpw Exp $ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "ipl.h"
+#include "iplmskbits.h"
+
+#define isClipped(c,ul,lr) ((((c) - (ul)) | ((lr) - (c))) & ClipMask)
+
+/* WARNING: pbox contains two shorts. This code assumes they are packed
+ * and can be referenced together as an INT32.
+ */
+
+#define PointLoop(fill) { \
+ for (nbox = REGION_NUM_RECTS(cclip), pbox = REGION_RECTS(cclip); \
+ --nbox >= 0; \
+ pbox++) \
+ { \
+ c1 = *((INT32 *) &pbox->x1) - off; \
+ c2 = *((INT32 *) &pbox->x2) - off - 0x00010001; \
+ for (ppt = (INT32 *) pptInit, i = npt; --i >= 0;) \
+ { \
+ pt = *ppt++; \
+ if (!isClipped(pt,c1,c2)) { \
+ fill \
+ } \
+ } \
+ } \
+}
+
+void
+iplPolyPoint(pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode;
+ int npt;
+ xPoint *pptInit;
+{
+ register INT32 pt;
+ register INT32 c1, c2;
+ register unsigned long ClipMask = 0x80008000;
+ INTER_DECLAREG(*addrg);
+ register int ngwidth;
+ register int xoffset;
+ INTER_DECLAREG(*addrgt);
+ register INT32 *ppt;
+ RegionPtr cclip;
+ int nbox;
+ register int i;
+ register BoxPtr pbox;
+ INTER_DECLARERRAX(and);
+ INTER_DECLARERRAX(xor);
+ int rop = pGC->alu;
+ int off;
+ iplPrivGCPtr devPriv;
+ xPoint *pptPrev;
+
+ devPriv =iplGetGCPrivate(pGC);
+ rop = devPriv->rop;
+ if (rop == GXnoop)
+ return;
+ cclip = pGC->pCompositeClip;
+ xor = devPriv->xorg;
+ and = devPriv->andg;
+ if ((mode == CoordModePrevious) && (npt > 1))
+ {
+ for (pptPrev = pptInit + 1, i = npt - 1; --i >= 0; pptPrev++)
+ {
+ pptPrev->x += (pptPrev-1)->x;
+ pptPrev->y += (pptPrev-1)->y;
+ }
+ }
+ off = *((int *) &pDrawable->x);
+ off -= (off & 0x8000) << 1;
+ iplGetGroupWidthAndPointer(pDrawable, ngwidth, addrg);
+ addrg = addrg + pDrawable->y * ngwidth +
+ (pDrawable->x >> INTER_PGSH) * INTER_PLANES;
+ xoffset = pDrawable->x & INTER_PIM;
+ PointLoop( addrgt = addrg + intToY(pt) * ngwidth
+ + ((intToX(pt) + xoffset) >> INTER_PGSH) * INTER_PLANES;
+ INTER_DoMaskRRop(addrgt, and, xor,
+ iplmask[(intToX(pt) + xoffset) & INTER_PIM], addrgt);
+ )
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplrrop.c b/nx-X11/programs/Xserver/iplan2p4/iplrrop.c
new file mode 100644
index 000000000..1b65fa9dc
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplrrop.c
@@ -0,0 +1,219 @@
+/* $XFree86$ */
+/*
+ * $XConsortium: iplrrop.c,v 1.8 94/04/17 20:28:59 dpw Exp $
+ *
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+/* ipl reduced rasterop computations */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "ipl.h"
+
+#include "iplmskbits.h"
+
+/* A description:
+ *
+ * There are four possible operations on each bit in the destination word,
+ *
+ * 1 2 3 4
+ *
+ * 0 0 0 1 1
+ * 1 0 1 0 1
+ *
+ * On examination of the reduced rop equation (dst = (dst & and) ^ xor),
+ * these four fall to reduced rops as follows:
+ *
+ * and 0 1 1 0
+ * xor 0 0 1 1
+ *
+ * or, (if 'and' is expensive) (dst = (dst | or) ^ xor)
+ *
+ * or 1 0 0 1
+ * xor 1 0 1 0
+ *
+ * The trouble with using this later equation is that trivial
+ * rasterop reduction is more difficult; some common rasterops
+ * use complicated expressions of xor/and instead of the simple
+ * ones while other common rasterops are not made any simpler:
+ *
+ * GXcopy: *dst = ~xor instead of *dst = xor
+ * GXand: *dst = *dst & ~or instead of *dst = *dst & and
+ * GXor: *dst = *dst | or instead of *dst = *dst | xor
+ * GXxor: *dst = *dst ^ xor instead of *dst = *dst ^ xor
+ *
+ * If you're really set on using this second mechanism, the changes
+ * are pretty simple.
+ *
+ * All that remains is to provide a mechanism for computing and/xor values
+ * based on the raster op and foreground value.
+ *
+ * The 16 rops fall as follows, with the associated reduced
+ * rop and/xor and or/xor values. The values in parenthesis following the
+ * reduced values gives an equation using the source value for
+ * the reduced value, and is one of {0, src, ~src, 1} as appropriate.
+ *
+ * clear and andReverse copy
+ * src 0 1 0 1 0 1 0 1
+ * dst 0 0 0 0 0 0 0 0 1 0 0 1
+ * 1 0 0 1 0 1 1 0 0 1 0 1
+ *
+ * and 0 0 (0) 0 1 (src) 0 1 (src) 0 0 (0)
+ * xor 0 0 (0) 0 0 (0) 0 1 (src) 0 1 (src)
+ *
+ * or 1 1 (1) 1 0 (~src) 1 0 (~src) 1 1 (1)
+ * xor 1 1 (1) 1 0 (~src) 1 1 (1) 1 0 (~src)
+ *
+ * andInverted noop xor or
+ * src 0 1 0 1 0 1 0 1
+ * dst 0 0 0 0 0 0 0 0 1 0 0 1
+ * 1 1 0 1 1 1 1 1 0 1 1 1
+ *
+ * and 1 0 (~src) 1 1 (1) 1 1 (1) 1 0 (~src)
+ * xor 0 0 (0) 0 0 (0) 0 1 (src) 0 1 (src)
+ *
+ * or 0 1 (src) 0 0 (0) 0 0 (0) 0 1 (src)
+ * xor 0 1 (src) 0 0 (0) 0 1 (src) 0 0 (0)
+ *
+ * nor equiv invert orReverse
+ * src 0 1 0 1 0 1 0 1
+ * dst 0 1 0 0 1 0 0 1 1 0 1 1
+ * 1 0 0 1 0 1 1 0 0 1 0 1
+ *
+ * and 1 0 (~src) 1 1 (1) 1 1 (1) 1 0 (~src)
+ * xor 1 0 (~src) 1 0 (~src) 1 1 (1) 1 1 (1)
+ *
+ * or 0 1 (src) 0 0 (0) 0 0 (0) 0 1 (src)
+ * xor 1 1 (1) 1 0 (~src) 1 1 (1) 1 0 (~src)
+ *
+ * copyInverted orInverted nand set
+ * src 0 1 0 1 0 1 0 1
+ * dst 0 1 0 0 1 0 0 1 1 0 1 1
+ * 1 1 0 1 1 1 1 1 0 1 1 1
+ *
+ * and 0 0 (0) 0 1 (src) 0 1 (src) 0 0 (0)
+ * xor 1 0 (~src) 1 0 (~src) 1 1 (1) 1 1 (1)
+ *
+ * or 1 1 (1) 1 0 (~src) 1 0 (~src) 1 1 (1)
+ * xor 0 1 (src) 0 0 (0) 0 1 (src) 0 0 (0)
+ */
+
+iplReduceRasterOp (rop, fg, pm, and, xor)
+ int rop;
+ unsigned long fg, pm;
+ unsigned short *and;
+ unsigned short *xor;
+{
+ int rrop;
+ switch (rop)
+ {
+ case GXclear:
+ INTER_CLR(and);
+ INTER_CLR(xor);
+ break;
+ case GXand:
+ INTER_PFILL(fg, and);
+ INTER_CLR(xor);
+ break;
+ case GXandReverse:
+ INTER_PFILL(fg, and);
+ INTER_PFILL(fg, xor);
+ break;
+ case GXcopy:
+ INTER_CLR(and);
+ INTER_PFILL(fg, xor);
+ break;
+ case GXandInverted:
+ INTER_PFILL(~fg, xor);
+ INTER_CLR(xor);
+ break;
+ case GXnoop:
+ INTER_SET(and);
+ INTER_CLR(xor);
+ break;
+ case GXxor:
+ INTER_SET(and);
+ INTER_PFILL(fg, xor);
+ break;
+ case GXor:
+ INTER_PFILL(~fg, and);
+ INTER_PFILL(fg, xor);
+ break;
+ case GXnor:
+ INTER_PFILL(~fg, and);
+ INTER_PFILL(~fg, xor);
+ break;
+ case GXequiv:
+ INTER_SET(and);
+ INTER_PFILL(~fg, xor);
+ case GXinvert:
+ INTER_SET(and);
+ INTER_SET(xor);
+ break;
+ case GXorReverse:
+ INTER_PFILL(~fg, and);
+ INTER_SET(xor);
+ break;
+ case GXcopyInverted:
+ INTER_CLR(and);
+ INTER_PFILL(~fg, xor);
+ break;
+ case GXorInverted:
+ INTER_PFILL(fg, and);
+ INTER_PFILL(~fg, xor);
+ break;
+ case GXnand:
+ INTER_PFILL(fg, and);
+ INTER_SET(xor);
+ break;
+ case GXset:
+ INTER_CLR(and);
+ INTER_SET(xor);
+ break;
+ }
+ INTER_ANDXOR_PM(pm, and, xor);
+ if (INTER_IS_CLR(and))
+ rrop = GXcopy;
+ else if (INTER_IS_SET(and))
+ rrop = GXxor;
+ else if (INTER_IS_CLR(xor))
+ rrop = GXand;
+ else if (INTER_IS_XOR_SET(and, xor))
+ rrop = GXor;
+ else
+ rrop = GXset;
+ return rrop;
+}
+
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplrrop.h b/nx-X11/programs/Xserver/iplan2p4/iplrrop.h
new file mode 100644
index 000000000..05a88fea4
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplrrop.h
@@ -0,0 +1,80 @@
+/* $XFree86: xc/programs/Xserver/iplan2p4/iplrrop.h,v 3.0 1996/08/18 01:55:04 dawes Exp $ */
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+/* reduced raster ops */
+/* INTER_RROP_DECLARE INTER_RROP_FETCH_GC,
+ INTER_RROP_SOLID_MASK, INTER_RROP_SPAN INTER_RROP_NAME */
+
+#define INTER_RROP_FETCH_GC(gc) \
+INTER_RROP_FETCH_GCPRIV(((iplPrivGCPtr)(gc)->devPrivates[iplGCPrivateIndex].ptr))
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#if RROP == GXcopy
+#define INTER_RROP_DECLARE register unsigned short *rrop_xor;
+#define INTER_RROP_FETCH_GCPRIV(devPriv) rrop_xor = (devPriv)->xorg;
+#define INTER_RROP_SOLID(dst) INTER_COPY(rrop_xor, dst)
+#define INTER_RROP_SOLID_MASK(dst,mask) INTER_COPYM(rrop_xor, dst, mask, dst)
+#define INTER_RROP_NAME(prefix) INTER_RROP_NAME_CAT(prefix,Copy)
+#endif /* GXcopy */
+
+#if RROP == GXxor
+#define INTER_RROP_DECLARE register unsigned short *rrop_xor;
+#define INTER_RROP_FETCH_GCPRIV(devPriv) rrop_xor = (devPriv)->xorg;
+#define INTER_RROP_SOLID(dst) INTER_XOR(rrop_xor, dst, dst)
+#define INTER_RROP_SOLID_MASK(dst,mask) INTER_XORM(rrop_xor, dst, mask, dst)
+#define INTER_RROP_NAME(prefix) INTER_RROP_NAME_CAT(prefix,Xor)
+#endif /* GXxor */
+
+#if RROP == GXand
+#define INTER_RROP_DECLARE register unsigned short *rrop_and;
+#define INTER_RROP_FETCH_GCPRIV(devPriv) rrop_and = (devPriv)->andg;
+#define INTER_RROP_SOLID(dst) INTER_AND(rrop_and, dst, dst)
+#define INTER_RROP_SOLID_MASK(dst,mask) INTER_ANDM(rrop_and, dst, mask, dst)
+#define INTER_RROP_NAME(prefix) INTER_RROP_NAME_CAT(prefix,And)
+#endif /* GXand */
+
+#if RROP == GXor
+#define INTER_RROP_DECLARE register unsigned short *rrop_or;
+#define INTER_RROP_FETCH_GCPRIV(devPriv) rrop_or = (devPriv)->xorg;
+#define INTER_RROP_SOLID(dst) INTER_OR(rrop_or, dst, dst)
+#define INTER_RROP_SOLID_MASK(dst,mask) INTER_ORM(mask, rrop_or, dst, dst)
+#define INTER_RROP_NAME(prefix) INTER_RROP_NAME_CAT(prefix,Or)
+#endif /* GXor */
+
+#if RROP == GXnoop
+#define INTER_RROP_DECLARE
+#define INTER_RROP_FETCH_GCPRIV(devPriv)
+#define INTER_RROP_SOLID(dst)
+#define INTER_RROP_SOLID_MASK(dst,mask)
+#define INTER_RROP_NAME(prefix) INTER_RROP_NAME_CAT(prefix,Noop)
+#endif /* GXnoop */
+
+#if RROP == GXset
+#define INTER_RROP_DECLARE register unsigned short *rrop_and, *rrop_xor;
+#define INTER_RROP_FETCH_GCPRIV(devPriv) rrop_and = (devPriv)->andg; \
+ rrop_xor = (devPriv)->xorg;
+#define INTER_RROP_SOLID(dst) INTER_DoRRop(dst, rrop_and, rrop_xor, dst)
+#define INTER_RROP_SOLID_MASK(dst,mask) \
+ INTER_DoMaskRRop(dst, rrop_and, rrop_xor, mask, dst)
+#define INTER_RROP_NAME(prefix) INTER_RROP_NAME_CAT(prefix,General)
+#endif /* GXset */
+
+#ifndef INTER_RROP_SPAN
+#define INTER_RROP_SPAN(pdst,nmiddle) \
+ while (--(nmiddle) >= 0) { \
+ INTER_RROP_SOLID(pdst); \
+ (pdst) = INTER_NEXT(pdst); \
+ }
+
+#endif
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define INTER_RROP_NAME_CAT(prefix,suffix) prefix##suffix
+#else
+#define INTER_RROP_NAME_CAT(prefix,suffix) prefix/**/suffix
+#endif
+
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplscrinit.c b/nx-X11/programs/Xserver/iplan2p4/iplscrinit.c
new file mode 100644
index 000000000..073e7b9a4
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplscrinit.c
@@ -0,0 +1,233 @@
+/* $XFree86: xc/programs/Xserver/iplan2p4/iplscrinit.c,v 3.2 1998/06/27 12:55:03 hohndel Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XConsortium: iplscrinit.c,v 5.32 94/04/17 20:29:00 dpw Exp $ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "resource.h"
+#include "colormap.h"
+#include "colormapst.h"
+#include "ipl.h"
+#include "mi.h"
+#include "mistruct.h"
+#include "dix.h"
+#include "mibstore.h"
+
+
+BSFuncRec iplBSFuncRec = {
+ iplSaveAreas,
+ iplRestoreAreas,
+ (BackingStoreSetClipmaskRgnProcPtr) 0,
+ (BackingStoreGetImagePixmapProcPtr) 0,
+ (BackingStoreGetSpansPixmapProcPtr) 0,
+};
+
+Bool
+iplCloseScreen (index, pScreen)
+ int index;
+ ScreenPtr pScreen;
+{
+ int d;
+ DepthPtr depths = pScreen->allowedDepths;
+
+ for (d = 0; d < pScreen->numDepths; d++)
+ xfree (depths[d].vids);
+ xfree (depths);
+ xfree (pScreen->visuals);
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ xfree (pScreen->devPrivates[iplScreenPrivateIndex].ptr);
+#else
+ xfree (pScreen->devPrivate);
+#endif
+ return TRUE;
+}
+
+Bool
+iplSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+{
+ int i;
+ extern RegionPtr (*iplPuntCopyPlane)();
+
+ if (!iplAllocatePrivates(pScreen, (int *) 0, (int *) 0))
+ return FALSE;
+ pScreen->defColormap = FakeClientID(0);
+ /* let CreateDefColormap do whatever it wants for pixels */
+ pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
+ pScreen->QueryBestSize = mfbQueryBestSize;
+ /* SaveScreen */
+ pScreen->GetImage = iplGetImage;
+ pScreen->GetSpans = iplGetSpans;
+ pScreen->CreateWindow = iplCreateWindow;
+ pScreen->DestroyWindow = iplDestroyWindow;
+ pScreen->PositionWindow = iplPositionWindow;
+ pScreen->ChangeWindowAttributes = iplChangeWindowAttributes;
+ pScreen->RealizeWindow = iplMapWindow;
+ pScreen->UnrealizeWindow = iplUnmapWindow;
+ pScreen->PaintWindowBackground = iplPaintWindow;
+ pScreen->PaintWindowBorder = iplPaintWindow;
+ pScreen->CopyWindow = iplCopyWindow;
+ pScreen->CreatePixmap = iplCreatePixmap;
+ pScreen->DestroyPixmap = iplDestroyPixmap;
+ pScreen->RealizeFont = mfbRealizeFont;
+ pScreen->UnrealizeFont = mfbUnrealizeFont;
+ pScreen->CreateGC = iplCreateGC;
+ pScreen->CreateColormap = iplInitializeColormap;
+ pScreen->DestroyColormap = (void (*)())NoopDDA;
+ pScreen->InstallColormap = iplInstallColormap;
+ pScreen->UninstallColormap = iplUninstallColormap;
+ pScreen->ListInstalledColormaps = iplListInstalledColormaps;
+ pScreen->StoreColors = (void (*)())NoopDDA;
+ pScreen->ResolveColor = iplResolveColor;
+ pScreen->BitmapToRegion = mfbPixmapToRegion;
+
+ mfbRegisterCopyPlaneProc (pScreen, iplCopyPlane);
+ return TRUE;
+}
+
+#ifdef CFB_NEED_SCREEN_PRIVATE
+Bool
+iplCreateScreenResources(pScreen)
+ ScreenPtr pScreen;
+{
+ Bool retval;
+
+ pointer oldDevPrivate = pScreen->devPrivate;
+ pScreen->devPrivate = pScreen->devPrivates[iplScreenPrivateIndex].ptr;
+ retval = miCreateScreenResources(pScreen);
+ pScreen->devPrivates[iplScreenPrivateIndex].ptr = pScreen->devPrivate;
+ pScreen->devPrivate = oldDevPrivate;
+ return retval;
+}
+#endif
+
+Bool
+iplFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+{
+ int i, j;
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ pointer oldDevPrivate;
+#endif
+ VisualPtr visuals;
+ DepthPtr depths;
+ int nvisuals;
+ int ndepths;
+ int rootdepth;
+ VisualID defaultVisual;
+
+ rootdepth = 0;
+ if (!iplInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
+ &defaultVisual,((unsigned long)1<<(INTER_PLANES-1)), 8))
+ return FALSE;
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ oldDevPrivate = pScreen->devPrivate;
+#endif
+ if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
+ rootdepth, ndepths, depths,
+ defaultVisual, nvisuals, visuals))
+ return FALSE;
+ /* overwrite miCloseScreen with our own */
+ pScreen->CloseScreen = iplCloseScreen;
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ pScreen->CreateScreenResources = iplCreateScreenResources;
+ pScreen->devPrivates[iplScreenPrivateIndex].ptr = pScreen->devPrivate;
+ pScreen->devPrivate = oldDevPrivate;
+#endif
+ pScreen->BackingStoreFuncs = iplBSFuncRec;
+ pScreen->GetScreenPixmap = iplGetScreenPixmap;
+ pScreen->SetScreenPixmap = iplSetScreenPixmap;
+ return TRUE;
+}
+
+/* dts * (inch/dot) * (25.4 mm / inch) = mm */
+Bool
+iplScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+{
+ if (!iplSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width))
+ return FALSE;
+ if (!iplFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width))
+ return FALSE;
+#if INTER_PLANES == 2
+/* This shouldn't be necessary */
+ PixmapWidthPaddingInfo[2].padPixelsLog2 = 4;
+ PixmapWidthPaddingInfo[2].padRoundUp = 15;
+ PixmapWidthPaddingInfo[2].padBytesLog2 = 2;
+#endif
+ return TRUE;
+}
+
+PixmapPtr
+iplGetScreenPixmap(pScreen)
+ ScreenPtr pScreen;
+{
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ return (PixmapPtr)(pScreen->devPrivates[iplScreenPrivateIndex].ptr);
+#else
+ return (PixmapPtr)(pScreen->devPrivate.ptr);
+#endif
+}
+
+void
+iplSetScreenPixmap(pPix)
+ PixmapPtr pPix;
+{
+#ifdef CFB_NEED_SCREEN_PRIVATE
+ if (pPix)
+ pPix->drawable.pScreen->devPrivates[iplScreenPrivateIndex].ptr =
+ (pointer)pPix;
+#else
+ if (pPix)
+ pPix->drawable.pScreen->devPrivate.ptr = (pointer)pPix;
+#endif
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplsetsp.c b/nx-X11/programs/Xserver/iplan2p4/iplsetsp.c
new file mode 100644
index 000000000..9a6c8128d
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplsetsp.c
@@ -0,0 +1,304 @@
+/* $XFree86$ */
+/* $XConsortium: iplsetsp.c,v 5.10 94/04/17 20:29:01 dpw Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+
+#include "misc.h"
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "ipl.h"
+
+#include "iplmskbits.h"
+#include "iplmergerop.h"
+#include "iplpack.h"
+
+/* iplSetScanline -- copies the bits from psrc to the drawable starting at
+ * (xStart, y) and continuing to (xEnd, y). xOrigin tells us where psrc
+ * starts on the scanline. (I.e., if this scanline passes through multiple
+ * boxes, we may not want to start grabbing bits at psrc but at some offset
+ * further on.)
+ */
+iplSetScanline(y, xOrigin, xStart, xEnd, psrc, alu, pdstBase, widthDst, planemask)
+ int y;
+ int xOrigin; /* where this scanline starts */
+ int xStart; /* first bit to use from scanline */
+ int xEnd; /* last bit to use from scanline + 1 */
+ register unsigned int *psrc;
+ register int alu; /* raster op */
+ INTER_DECLAREG(*pdstBase); /* start of the drawable */
+ int widthDst; /* width of drawable in groups */
+ unsigned long planemask;
+{
+ int w; /* width of scanline in bits */
+ INTER_DECLAREG(*pdst); /* where to put the bits */
+ INTER_DECLAREGP(tmpSrc); /* scratch buffer to collect bits in */
+ int dstBit; /* offset in bits from beginning of
+ * word */
+ register int nstart; /* number of bits from first partial */
+ register int nend; /* " " last partial word */
+ int offSrc;
+ INTER_DECLAREG(startmask);
+ INTER_DECLAREG(endmask);
+ int nlMiddle, nl, longs;
+ INTER_DECLAREG(*ipsrc);
+ INTER_DECLAREG(*tmppsrc);
+ INTER_DeclareMergeRop()
+
+ INTER_InitializeMergeRop(alu,planemask);
+
+ longs=NUM_LONGS(INTER_PLANES, xOrigin, xEnd);
+
+ tmppsrc = ipsrc = (unsigned short *)
+ ALLOCATE_LOCAL(NUM_TEMP_BYTES(INTER_PLANES,longs));
+
+ iplUnpackLine(INTER_PLANES, longs, psrc, ipsrc);
+
+ pdst = pdstBase + (y * widthDst) + (xStart >> INTER_PGSH) * INTER_PLANES;
+ offSrc = (xStart - xOrigin) & INTER_PIM;
+ w = xEnd - xStart;
+ dstBit = xStart & INTER_PIM;
+
+ ipsrc += ((xStart - xOrigin) >> INTER_PGSH) * INTER_PLANES;
+ if (dstBit + w <= INTER_PPG)
+ {
+ INTER_maskpartialbits(dstBit, w, startmask);
+ endmask = 0;
+ nlMiddle = 0;
+ }
+ else
+ {
+ INTER_maskbits(xStart, w, startmask, endmask, nlMiddle);
+ }
+ if (startmask)
+ nstart = INTER_PPG - dstBit;
+ else
+ nstart = 0;
+ if (endmask)
+ nend = xEnd & INTER_PIM;
+ else
+ nend = 0;
+ if (startmask)
+ {
+ INTER_getbits(ipsrc, offSrc, nstart, tmpSrc);
+ INTER_putbitsmropshort(tmpSrc, dstBit, nstart, pdst);
+ INTER_NEXT_GROUP(pdst);
+ offSrc += nstart;
+ if (offSrc > INTER_PLST)
+ {
+ INTER_NEXT_GROUP(ipsrc);
+ offSrc -= INTER_PPG;
+ }
+ }
+ nl = nlMiddle;
+ while (nl--)
+ {
+ INTER_getbits(ipsrc, offSrc, INTER_PPG, tmpSrc);
+ INTER_DoMergeRop(tmpSrc, pdst, pdst);
+ INTER_NEXT_GROUP(pdst);
+ INTER_NEXT_GROUP(ipsrc);
+ }
+ if (endmask)
+ {
+ INTER_getbits(ipsrc, offSrc, nend, tmpSrc);
+ INTER_putbitsmropshort(tmpSrc, 0, nend, pdst);
+ }
+ DEALLOCATE_LOCAL(tmppsrc);
+}
+
+
+
+/* SetSpans -- for each span copy pwidth[i] bits from psrc to pDrawable at
+ * ppt[i] using the raster op from the GC. If fSorted is TRUE, the scanlines
+ * are in increasing Y order.
+ * Source bit lines are server scanline padded so that they always begin
+ * on a word boundary.
+ */
+void
+iplSetSpans(pDrawable, pGC, pcharsrc, ppt, pwidth, nspans, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ char *pcharsrc;
+ register DDXPointPtr ppt;
+ int *pwidth;
+ int nspans;
+ int fSorted;
+{
+ unsigned int *psrc = (unsigned int *)pcharsrc;
+ INTER_DECLAREG(*pdstBase); /* start of dst bitmap */
+ int widthDst; /* width of bitmap in words */
+ register BoxPtr pbox, pboxLast, pboxTest;
+ register DDXPointPtr pptLast;
+ int alu;
+ RegionPtr prgnDst;
+ int xStart, xEnd;
+ int yMax;
+
+ alu = pGC->alu;
+ prgnDst = iplGetCompositeClip(pGC);
+ pptLast = ppt + nspans;
+
+ iplGetGroupWidthAndPointer (pDrawable, widthDst, pdstBase)
+
+ yMax = (int) pDrawable->y + (int) pDrawable->height;
+
+ pbox = REGION_RECTS(prgnDst);
+ pboxLast = pbox + REGION_NUM_RECTS(prgnDst);
+
+ if(fSorted)
+ {
+ /* scan lines sorted in ascending order. Because they are sorted, we
+ * don't have to check each scanline against each clip box. We can be
+ * sure that this scanline only has to be clipped to boxes at or after the
+ * beginning of this y-band
+ */
+ pboxTest = pbox;
+ while(ppt < pptLast)
+ {
+ pbox = pboxTest;
+ if(ppt->y >= yMax)
+ break;
+ while(pbox < pboxLast)
+ {
+ if(pbox->y1 > ppt->y)
+ {
+ /* scanline is before clip box */
+ break;
+ }
+ else if(pbox->y2 <= ppt->y)
+ {
+ /* clip box is before scanline */
+ pboxTest = ++pbox;
+ continue;
+ }
+ else if(pbox->x1 > ppt->x + *pwidth)
+ {
+ /* clip box is to right of scanline */
+ break;
+ }
+ else if(pbox->x2 <= ppt->x)
+ {
+ /* scanline is to right of clip box */
+ pbox++;
+ continue;
+ }
+
+ /* at least some of the scanline is in the current clip box */
+ xStart = max(pbox->x1, ppt->x);
+ xEnd = min(ppt->x + *pwidth, pbox->x2);
+ iplSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu,
+ pdstBase, widthDst, pGC->planemask);
+ if(ppt->x + *pwidth <= pbox->x2)
+ {
+ /* End of the line, as it were */
+ break;
+ }
+ else
+ pbox++;
+ }
+ /* We've tried this line against every box; it must be outside them
+ * all. move on to the next point */
+ ppt++;
+ psrc += PixmapWidthInPadUnits(*pwidth, pDrawable->depth);
+ pwidth++;
+ }
+ }
+ else
+ {
+ /* scan lines not sorted. We must clip each line against all the boxes */
+ while(ppt < pptLast)
+ {
+ if(ppt->y >= 0 && ppt->y < yMax)
+ {
+
+ for(pbox = REGION_RECTS(prgnDst); pbox< pboxLast; pbox++)
+ {
+ if(pbox->y1 > ppt->y)
+ {
+ /* rest of clip region is above this scanline,
+ * skip it */
+ break;
+ }
+ if(pbox->y2 <= ppt->y)
+ {
+ /* clip box is below scanline */
+ pbox++;
+ break;
+ }
+ if(pbox->x1 <= ppt->x + *pwidth &&
+ pbox->x2 > ppt->x)
+ {
+ xStart = max(pbox->x1, ppt->x);
+ xEnd = min(pbox->x2, ppt->x + *pwidth);
+ iplSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu,
+ pdstBase, widthDst, pGC->planemask);
+ }
+
+ }
+ }
+ psrc += PixmapWidthInPadUnits(*pwidth, pDrawable->depth);
+ ppt++;
+ pwidth++;
+ }
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplsolid.c b/nx-X11/programs/Xserver/iplan2p4/iplsolid.c
new file mode 100644
index 000000000..768bf0ace
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplsolid.c
@@ -0,0 +1,221 @@
+/* $XFree86: xc/programs/Xserver/iplan2p4/iplsolid.c,v 3.0 1996/08/18 01:55:08 dawes Exp $ */
+/*
+ * $XConsortium: iplsolid.c,v 1.9 94/04/17 20:29:02 dpw Exp $
+ *
+Copyright (c) 1990 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+#include "ipl.h"
+#include "iplrrop.h"
+
+#include "mi.h"
+#include "mispans.h"
+
+#include "iplmskbits.h"
+
+# define Expand(left, right, leftAdjust) { \
+ while (h--) { \
+ pdst = pdstRect; \
+ left \
+ m = nmiddle; \
+ INTER_RROP_SPAN(pdst, m); \
+ right \
+ pdstRect += widthDst; \
+ } \
+}
+
+
+void
+INTER_RROP_NAME(iplFillRectSolid) (pDrawable, pGC, nBox, pBox)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nBox;
+ BoxPtr pBox;
+{
+ register int m;
+ INTER_DECLAREG(*pdst);
+ INTER_RROP_DECLARE
+ INTER_DECLAREG(leftMask);
+ INTER_DECLAREG(rightMask);
+ INTER_DECLAREG(*pdstBase);
+ INTER_DECLAREG(*pdstRect);
+ int nmiddle;
+ int h;
+ int w;
+ int widthDst;
+
+ iplGetGroupWidthAndPointer (pDrawable, widthDst, pdstBase)
+
+ INTER_RROP_FETCH_GC(pGC)
+
+ for (; nBox; nBox--, pBox++)
+ {
+ pdstRect = pdstBase + pBox->y1 * widthDst;
+ h = pBox->y2 - pBox->y1;
+ w = pBox->x2 - pBox->x1;
+ pdstRect += (pBox->x1 >> INTER_PGSH) * INTER_PLANES;
+ if ((pBox->x1 & INTER_PIM) + w <= INTER_PPG)
+ {
+ INTER_maskpartialbits(pBox->x1, w, leftMask);
+ pdst = pdstRect;
+ while (h--) {
+ INTER_RROP_SOLID_MASK (pdst, leftMask);
+ pdst += widthDst;
+ }
+ }
+ else
+ {
+ INTER_maskbits (pBox->x1, w, leftMask, rightMask, nmiddle);
+ if (leftMask)
+ {
+ if (rightMask) /* left mask and right mask */
+ {
+ Expand(INTER_RROP_SOLID_MASK (pdst, leftMask);
+ INTER_NEXT_GROUP(pdst);,
+ INTER_RROP_SOLID_MASK (pdst, rightMask);, 1)
+ }
+ else /* left mask and no right mask */
+ {
+ Expand(INTER_RROP_SOLID_MASK (pdst, leftMask);
+ INTER_NEXT_GROUP(pdst);,
+ ;, 1)
+ }
+ }
+ else
+ {
+ if (rightMask) /* no left mask and right mask */
+ {
+ Expand(;,
+ INTER_RROP_SOLID_MASK (pdst, rightMask);, 0)
+ }
+ else /* no left mask and no right mask */
+ {
+ Expand(;,
+ ;, 0)
+ }
+ }
+ }
+ }
+}
+
+void
+INTER_RROP_NAME(iplSolidSpans) (pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ INTER_DECLAREG(*pdstBase);
+ int widthDst;
+
+ INTER_RROP_DECLARE
+
+ INTER_DECLAREG(*pdst);
+ register int ngmiddle;
+ INTER_DECLAREG(startmask);
+ INTER_DECLAREG(endmask);
+ register int w;
+ int x;
+
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ DDXPointPtr ppt; /* pointer to list of start points */
+ int *pwidthFree;/* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ int *pwidth;
+ iplPrivGCPtr devPriv;
+
+ devPriv = iplGetGCPrivate(pGC);
+ INTER_RROP_FETCH_GCPRIV(devPriv)
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ iplGetGroupWidthAndPointer (pDrawable, widthDst, pdstBase)
+
+ while (n--)
+ {
+ x = ppt->x;
+ pdst = pdstBase + (ppt->y * widthDst);
+ ++ppt;
+ w = *pwidth++;
+ if (!w)
+ continue;
+ if ((x & INTER_PIM) + w <= INTER_PPG)
+ {
+ pdst += (x >> INTER_PGSH) * INTER_PLANES;
+ INTER_maskpartialbits (x, w, startmask);
+ INTER_RROP_SOLID_MASK (pdst, startmask);
+ }
+ else
+ {
+ pdst += (x >> INTER_PGSH) * INTER_PLANES;
+ INTER_maskbits (x, w, startmask, endmask, ngmiddle);
+ if (startmask)
+ {
+ INTER_RROP_SOLID_MASK (pdst, startmask);
+ INTER_NEXT_GROUP(pdst);
+ }
+
+ INTER_RROP_SPAN(pdst,ngmiddle);
+
+ if (endmask)
+ {
+ INTER_RROP_SOLID_MASK (pdst, endmask);
+ }
+ }
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/ipltegblt.c b/nx-X11/programs/Xserver/iplan2p4/ipltegblt.c
new file mode 100644
index 000000000..9a46e31c6
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/ipltegblt.c
@@ -0,0 +1,221 @@
+/* $XFree86$ */
+/* $XConsortium: ipltegblt.c,v 5.9 94/04/17 20:29:03 dpw Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "ipl.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mi.h"
+#define MFB_CONSTS_ONLY
+#include "maskbits.h"
+
+#include "iplmskbits.h"
+
+/*
+ this works for fonts with glyphs <= 32 bits wide, on an
+ arbitrarily deep display. Use iplTEGlyphBlt8 for 8 bit displays.
+
+ This should be called only with a terminal-emulator font;
+this means that the FIXED_METRICS flag is set, and that
+glyphbounds == charbounds.
+
+ in theory, this goes faster; even if it doesn't, it reduces the
+flicker caused by writing a string over itself with image text (since
+the background gets repainted per character instead of per string.)
+this seems to be important for some converted X10 applications.
+
+ Image text looks at the bits in the glyph and the fg and bg in the
+GC. it paints a rectangle, as defined in the protocol dcoument,
+and the paints the characters.
+
+*/
+
+void
+iplTEGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ FontPtr pfont = pGC->font;
+ int widthDst;
+ INTER_DECLAREG(*pdstBase); /* pointer to group with top row
+ of current glyph */
+
+ int w; /* width of glyph and char */
+ int h; /* height of glyph and char */
+ register int xpos=x; /* current x%32 */
+ int ypos=y; /* current y%32 */
+ register unsigned char *pglyph;
+ int widthGlyph;
+
+ INTER_DECLAREG(*pdst); /* pointer to current group in dst */
+ int hTmp; /* counter for height */
+ BoxRec bbox; /* for clipping */
+
+ register int wtmp,xtemp,width;
+ INTER_DECLAREGP(bgfill);
+ INTER_DECLAREGP(fgfill);
+ unsigned long *ptemp;
+ INTER_DECLAREGP(tmpDst1);
+ INTER_DECLAREGP(tmpDst2);
+ INTER_DECLAREG(*pdtmp);
+ int tmpx;
+
+ xpos += pDrawable->x;
+ ypos += pDrawable->y;
+
+ iplGetGroupWidthAndPointer (pDrawable, widthDst, pdstBase)
+
+ wtmp = FONTMAXBOUNDS(pfont,characterWidth);
+ h = FONTASCENT(pfont) + FONTDESCENT(pfont);
+ widthGlyph = GLYPHWIDTHBYTESPADDED(*ppci);
+
+ xpos += FONTMAXBOUNDS(pfont,leftSideBearing);
+ ypos -= FONTASCENT(pfont);
+
+ bbox.x1 = xpos;
+ bbox.x2 = xpos + (wtmp * nglyph);
+ bbox.y1 = ypos;
+ bbox.y2 = ypos + h;
+
+ INTER_PFILL(pGC->fgPixel, fgfill);
+ INTER_PFILL(pGC->bgPixel, bgfill);
+
+ switch (RECT_IN_REGION(pGC->pScreen, iplGetCompositeClip(pGC), &bbox))
+ {
+ case rgnOUT:
+ break;
+ case rgnPART:
+ /* this is the WRONG thing to do, but it works.
+ calling the non-terminal text is easy, but slow, given
+ what we know about the font.
+
+ the right thing to do is something like:
+ for each clip rectangle
+ compute at which row the glyph starts to be in it,
+ and at which row the glyph ceases to be in it
+ compute which is the first glyph inside the left
+ edge, and the last one inside the right edge
+ draw a fractional first glyph, using only
+ the rows we know are in
+ draw all the whole glyphs, using the appropriate rows
+ draw any pieces of the last glyph, using the right rows
+
+ this way, the code would take advantage of knowing that
+ all glyphs are the same height and don't overlap.
+
+ one day...
+ */
+#if 1
+ miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+#endif
+ break;
+ case rgnIN:
+
+ pdtmp = pdstBase + (widthDst * ypos);
+ while(nglyph--)
+ {
+
+ pglyph = FONTGLYPHBITS(pglyphBase, *ppci++);
+ pdst = pdtmp;
+ hTmp = h;
+
+ while (hTmp--)
+ {
+ x = xpos;
+ width = wtmp;
+ xtemp = 0;
+
+ while (width > 0)
+ {
+ tmpx = x & INTER_PIM;
+ w = min(width, INTER_PPG - tmpx);
+ /* w = min(w, (PGSZ - xtemp)); */
+
+ ptemp = (unsigned long *)(pglyph + (xtemp >> MFB_PWSH));
+#if 1
+ INTER_getstipplepixelsb(ptemp,xtemp,w,bgfill,fgfill,tmpDst1);
+#endif
+ {
+ INTER_DECLAREG(*pdsttmp) =
+ pdst + (x >> INTER_PGSH) * INTER_PLANES;
+#if 1
+ INTER_putbits(tmpDst1,tmpx,w,pdsttmp,pGC->planemask);
+#endif
+ }
+ x += w;
+ xtemp += w;
+ width -= w;
+ }
+ pglyph += widthGlyph;
+ pdst += widthDst;
+ }
+ xpos += wtmp;
+ }
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/ipltile32.c b/nx-X11/programs/Xserver/iplan2p4/ipltile32.c
new file mode 100644
index 000000000..06be5a2e8
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/ipltile32.c
@@ -0,0 +1,272 @@
+/* $XFree86: xc/programs/Xserver/iplan2p4/ipltile32.c,v 3.0 1996/08/18 01:55:10 dawes Exp $ */
+/*
+ * Fill 32 bit tiled rectangles. Used by both PolyFillRect and PaintWindow.
+ * no depth dependencies.
+ */
+
+/*
+
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+*/
+
+/* $XConsortium: ipltile32.c,v 1.8 94/04/17 20:29:05 dpw Exp $ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+#include "ipl.h"
+
+#include "mi.h"
+#include "mispans.h"
+
+#include "iplmskbits.h"
+#include "iplmergerop.h"
+
+#define STORE(p) INTER_MROP_PREBUILT_SOLID(srcpix, p, p)
+
+#define Expand(left,right) {\
+ while (h--) { \
+ INTER_COPY(psrc+srcy*INTER_PLANES, srcpix); \
+ INTER_MROP_PREBUILD(srcpix); \
+ ++srcy; \
+ if (srcy == tileHeight) \
+ srcy = 0; \
+ left \
+ ngw = ngwMiddle; \
+ while (ngw--) \
+ { \
+ STORE(p); \
+ INTER_NEXT_GROUP(p); \
+ } \
+ right \
+ p += ngwExtra; \
+ } \
+}
+
+void
+INTER_MROP_NAME(iplFillRectTile32) (pDrawable, pGC, nBox, pBox)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nBox; /* number of boxes to fill */
+ BoxPtr pBox; /* pointer to list of boxes to fill */
+{
+ INTER_DECLAREGP(srcpix);
+ INTER_DECLAREG(*psrc); /* pointer to bits in tile, if needed */
+ int tileHeight; /* height of the tile */
+
+ int ngwDst; /* width in longwords of the dest pixmap */
+ int w; /* width of current box */
+ register int h; /* height of current box */
+ INTER_DECLAREG(startmask);
+ INTER_DECLAREG(endmask); /* masks for reggedy bits at either end of line */
+ int ngwMiddle; /* number of longwords between sides of boxes */
+ int ngwExtra; /* to get from right of box to left of next span */
+ register int ngw; /* loop version of ngwMiddle */
+ INTER_DECLAREG(*p); /* pointer to bits we're writing */
+ int y; /* current scan line */
+ int srcy; /* current tile position */
+
+ INTER_DECLAREG(*pbits); /* pointer to start of pixmap */
+ PixmapPtr tile; /* rotated, expanded tile */
+ INTER_MROP_DECLARE_REG()
+ INTER_MROP_PREBUILT_DECLARE()
+
+ tile = pGC->pRotatedPixmap;
+ tileHeight = tile->drawable.height;
+ psrc = (unsigned short *)tile->devPrivate.ptr;
+
+ INTER_MROP_INITIALIZE(pGC->alu, pGC->planemask);
+
+ iplGetGroupWidthAndPointer (pDrawable, ngwDst, pbits)
+
+ while (nBox--)
+ {
+ w = pBox->x2 - pBox->x1;
+ h = pBox->y2 - pBox->y1;
+ y = pBox->y1;
+ p = pbits + (y * ngwDst) + (pBox->x1 >> INTER_PGSH) * INTER_PLANES;
+ srcy = y % tileHeight;
+
+ if ( ((pBox->x1 & INTER_PIM) + w) <= INTER_PPG)
+ {
+ INTER_maskpartialbits(pBox->x1, w, startmask);
+ ngwExtra = ngwDst;
+ while (h--)
+ {
+ INTER_COPY(psrc+srcy*INTER_PLANES, srcpix);
+ INTER_MROP_PREBUILD(srcpix);
+ ++srcy;
+ if (srcy == tileHeight)
+ srcy = 0;
+ INTER_MROP_PREBUILT_MASK(srcpix, p, startmask, p);
+ p += ngwExtra;
+ }
+ }
+ else
+ {
+ INTER_maskbits(pBox->x1, w, startmask, endmask, ngwMiddle);
+ ngwExtra = ngwDst - ngwMiddle * INTER_PLANES;
+
+ if (startmask)
+ {
+ ngwExtra -= INTER_PLANES;
+ if (endmask)
+ {
+ Expand(
+ INTER_MROP_PREBUILT_MASK(srcpix, p, startmask, p);
+ INTER_NEXT_GROUP(p);,
+ INTER_MROP_PREBUILT_MASK(srcpix, p, endmask, p));
+ }
+ else
+ {
+ Expand(
+ INTER_MROP_PREBUILT_MASK(srcpix, p, startmask, p);
+ INTER_NEXT_GROUP(p);,
+ ;)
+ }
+ }
+ else
+ {
+ if (endmask)
+ {
+ Expand(;,
+ INTER_MROP_PREBUILT_MASK(srcpix, p, endmask, p));
+ }
+ else
+ {
+ Expand(;,
+ ;)
+ }
+ }
+ }
+ pBox++;
+ }
+}
+
+void
+INTER_MROP_NAME(iplTile32FS)(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ DDXPointPtr ppt; /* pointer to list of start points */
+ int *pwidth;/* pointer to list of n widths */
+ INTER_DECLAREG(*pbits); /* pointer to start of bitmap */
+ int ngwDst; /* width in longwords of bitmap */
+ INTER_DECLAREG(*p); /* pointer to current longword in bitmap */
+ register int w; /* current span width */
+ register int ngw;
+ register int x;
+ INTER_DECLAREG(startmask);
+ INTER_DECLAREG(endmask);
+ INTER_DECLAREGP(srcpix);
+ int y;
+ int *pwidthFree;/* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ PixmapPtr tile;
+ INTER_DECLAREG(*psrc); /* pointer to bits in tile */
+ int tileHeight;/* height of the tile */
+ INTER_MROP_DECLARE_REG ()
+ INTER_MROP_PREBUILT_DECLARE()
+
+ n = nInit * miFindMaxBand( iplGetCompositeClip(pGC) );
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans( iplGetCompositeClip(pGC),
+ pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ tile = pGC->pRotatedPixmap;
+ tileHeight = tile->drawable.height;
+ psrc = (unsigned short *)tile->devPrivate.ptr;
+
+ INTER_MROP_INITIALIZE(pGC->alu, pGC->planemask);
+
+ iplGetGroupWidthAndPointer (pDrawable, ngwDst, pbits)
+
+ {
+ while (n--)
+ {
+ x = ppt->x;
+ y = ppt->y;
+ ++ppt;
+ w = *pwidth++;
+ p = pbits + (y * ngwDst) + (x >> INTER_PGSH) * INTER_PLANES;
+ INTER_COPY(psrc +(y % tileHeight)*INTER_PLANES,srcpix);
+ INTER_MROP_PREBUILD(srcpix);
+
+ if ((x & INTER_PIM) + w < INTER_PPG)
+ {
+ INTER_maskpartialbits(x, w, startmask);
+ INTER_MROP_PREBUILT_MASK(srcpix, p, startmask, p);
+ }
+ else
+ {
+ INTER_maskbits(x, w, startmask, endmask, ngw);
+ if (startmask)
+ {
+ INTER_MROP_PREBUILT_MASK(srcpix, p, startmask, p);
+ INTER_NEXT_GROUP(p);
+ }
+ while (ngw--)
+ {
+ STORE(p);
+ INTER_NEXT_GROUP(p);
+ }
+ if (endmask)
+ {
+ INTER_MROP_PREBUILT_MASK(srcpix, p, endmask, p);
+ }
+ }
+ }
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/ipltileodd.c b/nx-X11/programs/Xserver/iplan2p4/ipltileodd.c
new file mode 100644
index 000000000..7230a5621
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/ipltileodd.c
@@ -0,0 +1,869 @@
+/* $XFree86$ */
+/*
+ * Fill odd tiled rectangles and spans.
+ * no depth dependencies.
+ */
+
+/*
+
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+*/
+
+/* $XConsortium: ipltileodd.c,v 1.16 94/04/17 20:29:06 dpw Exp $ */
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+#include "ipl.h"
+
+#include "iplmskbits.h"
+#include "iplmergerop.h"
+
+#define LEFTSHIFT_AMT 0
+
+#define LastTileBits {\
+ INTER_COPY(bits, tmp); \
+ if (tileEndPart) \
+ INTER_MSKINSM(tileEndMask, 0, pSrc, \
+ ~0, tileEndLeftShift, pSrcLine, bits) \
+ else \
+ INTER_COPY(pSrc, bits); \
+}
+
+#define ResetTileBits {\
+ pSrc = pSrcLine; \
+ nlwSrc = widthSrc;\
+ if (tileEndPart) { \
+ if (INTER_PPG - xoff + tileEndPart <= INTER_PPG) {\
+ INTER_COPY(pSrc, bits); INTER_NEXT_GROUP(pSrc); \
+ nlwSrc--; \
+ } else \
+ INTER_MSKINSM(~0, tileEndLeftShift, tmp, \
+ ~0, tileEndRightShift, bits, bits); \
+ xoff = (xoff + xoffStep) & INTER_PIM; \
+ leftShift = xoff << LEFTSHIFT_AMT; \
+ rightShift = INTER_PGSZ - leftShift; \
+ }\
+}
+
+#define NextTileBits {\
+ if (nlwSrc == 1) {\
+ LastTileBits\
+ } else { \
+ if (nlwSrc == 0) {\
+ ResetTileBits\
+ } \
+ if (nlwSrc == 1) {\
+ LastTileBits\
+ } else {\
+ INTER_COPY(bits, tmp); \
+ INTER_COPY(pSrc, bits); INTER_NEXT_GROUP(pSrc); \
+ }\
+ }\
+ nlwSrc--; \
+}
+
+void
+INTER_MROP_NAME(iplFillBoxTileOdd) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, planemask)
+ DrawablePtr pDrawable;
+ int nBox; /* number of boxes to fill */
+ register BoxPtr pBox; /* pointer to list of boxes to fill */
+ PixmapPtr tile; /* tile */
+ int xrot, yrot;
+ int alu;
+ unsigned long planemask;
+{
+ int tileWidth; /* width of tile in pixels */
+ int tileHeight; /* height of the tile */
+ int widthSrc;
+
+ int widthDst; /* width in longwords of the dest pixmap */
+ int w; /* width of current box */
+ int h; /* height of current box */
+ INTER_DECLAREG(startmask);
+ INTER_DECLAREG(endmask);/* masks for reggedy bits at either end of line */
+ int nlwMiddle; /* number of longwords between sides of boxes */
+ int nlwSrc; /* number of whole longwords in source */
+
+ register int nlw; /* loop version of nlwMiddle */
+ int srcy; /* current tile y position */
+ int srcx; /* current tile x position */
+ int xoffDst, xoffSrc;
+ int leftShift, rightShift;
+
+ INTER_MROP_DECLARE_REG()
+
+ INTER_DECLAREG(*pDstBase); /* pointer to start of dest */
+ INTER_DECLAREG(*pDstLine); /* poitner to start of dest box */
+ INTER_DECLAREG(*pSrcBase); /* pointer to start of source */
+ INTER_DECLAREG(*pSrcLine); /* pointer to start of source line */
+ INTER_DECLAREG(*pDst);
+ INTER_DECLAREG(*pSrc);
+ INTER_DECLAREGP(bits);
+ INTER_DECLAREGP(tmp);
+ INTER_DECLAREGP(tmp1);
+ register int nlwPart;
+ int xoffStart, xoff;
+ int leftShiftStart, rightShiftStart, nlwSrcStart;
+ INTER_DECLAREG(tileEndMask);
+ int tileEndLeftShift, tileEndRightShift;
+ int xoffStep;
+ int tileEndPart;
+ int needFirst;
+ unsigned short narrow[2 * INTER_PLANES];
+ INTER_DECLAREG(narrowMask);
+ int narrowShift;
+ Bool narrowTile;
+ int narrowRep;
+
+ INTER_MROP_INITIALIZE (alu, planemask)
+
+ tileHeight = tile->drawable.height;
+ tileWidth = tile->drawable.width;
+ widthSrc = tile->devKind / (INTER_PGSZB * INTER_PLANES);
+ narrowTile = FALSE;
+
+ if (widthSrc == 1)
+ {
+ narrowRep = INTER_PPG / tileWidth;
+ narrowMask = iplendpartial [tileWidth];
+ tileWidth *= narrowRep;
+ narrowShift = tileWidth;
+ tileWidth *= 2;
+ widthSrc = 2;
+ narrowTile = TRUE;
+ }
+ pSrcBase = (unsigned short *)tile->devPrivate.ptr;
+
+ iplGetGroupWidthAndPointer (pDrawable, widthDst, pDstBase)
+
+ tileEndPart = tileWidth & INTER_PIM;
+ tileEndMask = iplendpartial[tileEndPart];
+ tileEndLeftShift = (tileEndPart) << LEFTSHIFT_AMT;
+ tileEndRightShift = INTER_PGSZ - tileEndLeftShift;
+ xoffStep = INTER_PPG - tileEndPart;
+ /*
+ * current assumptions: tile > 32 bits wide.
+ */
+ while (nBox--)
+ {
+ w = pBox->x2 - pBox->x1;
+ h = pBox->y2 - pBox->y1;
+ modulus (pBox->x1 - xrot, tileWidth, srcx);
+ modulus (pBox->y1 - yrot, tileHeight, srcy);
+ xoffDst = pBox->x1 & INTER_PIM;
+ if (xoffDst + w < INTER_PPG)
+ {
+ INTER_maskpartialbits(pBox->x1, w, startmask);
+ endmask = 0;
+ nlwMiddle = 0;
+ }
+ else
+ {
+ INTER_maskbits (pBox->x1, w, startmask, endmask, nlwMiddle)
+ }
+ pDstLine = pDstBase + (pBox->y1 * widthDst) +
+ (pBox->x1 >> INTER_PGSH) * INTER_PLANES;
+ pSrcLine = pSrcBase + (srcy * widthSrc) * INTER_PLANES;
+ xoffSrc = srcx & INTER_PIM;
+ if (xoffSrc >= xoffDst)
+ {
+ xoffStart = xoffSrc - xoffDst;
+ needFirst = 1;
+ }
+ else
+ {
+ xoffStart = INTER_PPG - (xoffDst - xoffSrc);
+ needFirst = 0;
+ }
+ leftShiftStart = (xoffStart) << LEFTSHIFT_AMT;
+ rightShiftStart = INTER_PGSZ - leftShiftStart;
+ nlwSrcStart = (widthSrc - (srcx >> INTER_PGSH));
+ while (h--)
+ {
+ /* XXX only works when narrowShift >= INTER_PPG/2 */
+ if (narrowTile)
+ {
+ int tmpnarrowRep;
+ int shift=narrowShift/narrowRep;
+ INTER_ANDMSK(pSrcBase + srcy * INTER_PLANES, narrowMask, tmp);
+ tmpnarrowRep=narrowRep;
+ /* copy tile until its nearly a whole group wide */
+ while (--tmpnarrowRep)
+ INTER_MSKINSM(~0,0,tmp,~0,shift,tmp,tmp);
+ INTER_MSKINSM(~0, 0, tmp, ~0, narrowShift, tmp, narrow);
+ INTER_MSKINSM(~0, INTER_PPG - narrowShift, tmp,
+ ~0, 2 * narrowShift - INTER_PPG, tmp,
+ narrow + INTER_PLANES);
+ pSrcLine = narrow;
+ }
+ xoff = xoffStart;
+ leftShift = leftShiftStart;
+ rightShift = rightShiftStart;
+ nlwSrc = nlwSrcStart;
+ pSrc = pSrcLine + (srcx >> INTER_PGSH) * INTER_PLANES;
+ pDst = pDstLine;
+ INTER_CLR(bits);
+ if (needFirst)
+ {
+ NextTileBits
+ }
+ if (startmask)
+ {
+ NextTileBits
+ INTER_SCRLEFT(leftShift, tmp, tmp);
+ if (rightShift != INTER_PGSZ)
+ INTER_MSKINSM(~0, 0, tmp, ~0, rightShift, bits, tmp)
+ INTER_MROP_MASK (tmp, pDst, startmask, pDst);
+ INTER_NEXT_GROUP(pDst);
+ }
+ nlw = nlwMiddle;
+ while (nlw)
+ {
+ {
+ NextTileBits
+ if (rightShift != INTER_PGSZ)
+ {
+ INTER_MSKINSM(~0, leftShift, tmp, ~0, rightShift, bits,
+ tmp1);
+ INTER_MROP_SOLID(tmp1, pDst, pDst);
+ }
+ else
+ {
+ INTER_MROP_SOLID (tmp, pDst, pDst);
+ }
+ INTER_NEXT_GROUP(pDst);
+ nlw--;
+ }
+ }
+ if (endmask)
+ {
+ NextTileBits
+ if (rightShift == INTER_PGSZ)
+ INTER_CLR(bits);
+ INTER_MSKINSM(~0, leftShift, tmp, ~0, rightShift, bits, tmp1);
+ INTER_MROP_MASK(tmp1, pDst, endmask, pDst);
+ }
+ pDstLine += widthDst;
+ pSrcLine += widthSrc * INTER_PLANES;
+ if (++srcy == tileHeight)
+ {
+ srcy = 0;
+ pSrcLine = pSrcBase;
+ }
+ }
+ pBox++;
+ }
+}
+
+void
+INTER_MROP_NAME(iplFillSpanTileOdd) (pDrawable, n, ppt, pwidth, tile, xrot, yrot, alu, planemask)
+ DrawablePtr pDrawable;
+ int n;
+ DDXPointPtr ppt;
+ int *pwidth;
+ PixmapPtr tile;
+ int xrot, yrot;
+ int alu;
+ unsigned long planemask;
+{
+ int tileWidth; /* width of tile in pixels */
+ int tileHeight; /* height of the tile */
+ int widthSrc;
+
+ int widthDst; /* width in longwords of the dest pixmap */
+ int w; /* width of current span */
+ INTER_DECLAREG(startmask);
+ INTER_DECLAREG (endmask); /* masks for reggedy bits at either end of line */
+ int nlwSrc; /* number of whole longwords in source */
+
+ register int nlw; /* loop version of nlwMiddle */
+ int srcy; /* current tile y position */
+ int srcx; /* current tile x position */
+ int xoffDst, xoffSrc;
+ int leftShift, rightShift;
+
+ INTER_MROP_DECLARE_REG()
+
+ INTER_DECLAREG(*pDstBase); /* pointer to start of dest */
+ INTER_DECLAREG(*pDstLine); /* poitner to start of dest box */
+ INTER_DECLAREG(*pSrcBase); /* pointer to start of source */
+ INTER_DECLAREG(*pSrcLine); /* pointer to start of source line */
+ INTER_DECLAREG(*pDst);
+ INTER_DECLAREG(*pSrc);
+ INTER_DECLAREGP(bits);
+ INTER_DECLAREGP(tmp);
+ INTER_DECLAREGP(tmp1);
+ register int nlwPart;
+ int xoffStart, xoff;
+ int leftShiftStart, rightShiftStart, nlwSrcStart;
+ INTER_DECLAREG(tileEndMask);
+ int tileEndLeftShift, tileEndRightShift;
+ int xoffStep;
+ int tileEndPart;
+ int needFirst;
+ unsigned short narrow[2 * INTER_PLANES];
+ INTER_DECLAREG(narrowMask);
+ int narrowShift;
+ Bool narrowTile;
+ int narrowRep;
+
+ INTER_MROP_INITIALIZE (alu, planemask)
+
+ tileHeight = tile->drawable.height;
+ tileWidth = tile->drawable.width;
+ widthSrc = tile->devKind / (INTER_PGSZB * INTER_PLANES);
+ narrowTile = FALSE;
+ if (widthSrc == 1)
+ {
+ narrowRep = INTER_PPG / tileWidth;
+ narrowMask = iplendpartial [tileWidth];
+ tileWidth *= narrowRep;
+ narrowShift = tileWidth;
+ tileWidth *= 2;
+ widthSrc = 2;
+ narrowTile = TRUE;
+ }
+ pSrcBase = (unsigned short *)tile->devPrivate.ptr;
+
+ iplGetGroupWidthAndPointer (pDrawable, widthDst, pDstBase)
+
+ tileEndPart = tileWidth & INTER_PIM;
+ tileEndMask = iplendpartial[tileEndPart];
+ tileEndLeftShift = (tileEndPart) << LEFTSHIFT_AMT;
+ tileEndRightShift = INTER_PGSZ - tileEndLeftShift;
+ xoffStep = INTER_PPG - tileEndPart;
+ while (n--)
+ {
+ w = *pwidth++;
+ modulus (ppt->x - xrot, tileWidth, srcx);
+ modulus (ppt->y - yrot, tileHeight, srcy);
+ xoffDst = ppt->x & INTER_PIM;
+ if (xoffDst + w < INTER_PPG)
+ {
+ INTER_maskpartialbits(ppt->x, w, startmask);
+ endmask = 0;
+ nlw = 0;
+ }
+ else
+ {
+ INTER_maskbits (ppt->x, w, startmask, endmask, nlw)
+ }
+ pDstLine = pDstBase + (ppt->y * widthDst) +
+ (ppt->x >> INTER_PGSH) * INTER_PLANES;
+ pSrcLine = pSrcBase + (srcy * widthSrc) * INTER_PLANES;
+ xoffSrc = srcx & INTER_PIM;
+ if (xoffSrc >= xoffDst)
+ {
+ xoffStart = xoffSrc - xoffDst;
+ needFirst = 1;
+ }
+ else
+ {
+ xoffStart = INTER_PPG - (xoffDst - xoffSrc);
+ needFirst = 0;
+ }
+ leftShiftStart = (xoffStart) << LEFTSHIFT_AMT;
+ rightShiftStart = INTER_PGSZ - leftShiftStart;
+ nlwSrcStart = widthSrc - (srcx >> INTER_PGSH);
+ /* XXX only works when narrowShift >= INTER_PPG/2 */
+ if (narrowTile)
+ {
+ int tmpnarrowRep;
+ int shift=narrowShift/narrowRep;
+ INTER_ANDMSK(pSrcBase + srcy * INTER_PLANES, narrowMask, tmp);
+ tmpnarrowRep=narrowRep;
+ /* copy tile until its nearly a whole group wide */
+ while (--tmpnarrowRep)
+ INTER_MSKINSM(~0,0,tmp,~0,shift,tmp,tmp);
+ INTER_MSKINSM(~0, 0, tmp, ~0, narrowShift, tmp, narrow);
+ INTER_MSKINSM(~0, INTER_PPG - narrowShift, tmp,
+ ~0, 2 * narrowShift - INTER_PPG, tmp,
+ narrow + INTER_PLANES);
+ pSrcLine = narrow;
+ }
+ xoff = xoffStart;
+ leftShift = leftShiftStart;
+ rightShift = rightShiftStart;
+ nlwSrc = nlwSrcStart;
+ pSrc = pSrcLine + (srcx >> INTER_PGSH) * INTER_PLANES;
+ pDst = pDstLine;
+ INTER_CLR(bits);
+ if (needFirst)
+ {
+ NextTileBits
+ }
+ if (startmask)
+ {
+ NextTileBits
+ INTER_SCRLEFT(leftShift, tmp, tmp);
+ if (rightShift != INTER_PGSZ)
+ INTER_MSKINSM(~0, 0, tmp, ~0, rightShift, bits, tmp);
+ INTER_MROP_MASK (tmp, pDst, startmask, pDst);
+ INTER_NEXT_GROUP(pDst);
+ }
+ while (nlw)
+ {
+ {
+ NextTileBits
+ if (rightShift != INTER_PGSZ)
+ {
+ INTER_MSKINSM(~0, leftShift, tmp, ~0, rightShift, bits,
+ tmp1);
+ INTER_MROP_SOLID(tmp1, pDst, pDst);
+ INTER_NEXT_GROUP(pDst);
+ }
+ else
+ {
+ INTER_MROP_SOLID (tmp, pDst, pDst);
+ INTER_NEXT_GROUP(pDst);
+ }
+ nlw--;
+ }
+ }
+ if (endmask)
+ {
+ NextTileBits
+ if (rightShift == INTER_PGSZ)
+ INTER_CLR(bits);
+
+ INTER_MSKINSM(~0, leftShift, tmp, ~0, rightShift, bits, tmp1);
+ INTER_MROP_MASK(tmp1, pDst, endmask, pDst);
+ }
+ ppt++;
+ }
+}
+
+# include "fastblt.h"
+
+#define IncSrcPtr INTER_NEXT_GROUP(psrc); if (!--srcRemaining) { srcRemaining = widthSrc; psrc = psrcStart; }
+
+void
+INTER_MROP_NAME(iplFillBoxTile32s) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, planemask)
+ DrawablePtr pDrawable;
+ int nBox; /* number of boxes to fill */
+ register BoxPtr pBox; /* pointer to list of boxes to fill */
+ PixmapPtr tile; /* tile */
+ int xrot, yrot;
+ int alu;
+ unsigned long planemask;
+{
+ int tileWidth; /* width of tile */
+ int tileHeight; /* height of the tile */
+ int widthSrc; /* width in longwords of the source tile */
+
+ int widthDst; /* width in longwords of the dest pixmap */
+ int w; /* width of current box */
+ int h; /* height of current box */
+ INTER_DECLAREG(startmask);
+ INTER_DECLAREG(endmask); /* masks for reggedy bits at either end of line */
+ int nlMiddle; /* number of longwords between sides of boxes */
+
+ register int nl; /* loop version of nlMiddle */
+ int srcy; /* current tile y position */
+ int srcx; /* current tile x position */
+ int srcRemaining; /* number of longwords remaining in source */
+ int xoffDst, xoffSrc;
+ int srcStart; /* number of longwords source offset at left of box */
+ int leftShift, rightShift;
+
+ INTER_MROP_DECLARE_REG()
+
+ INTER_DECLAREG(*pdstBase); /* pointer to start of dest */
+ INTER_DECLAREG(*pdstLine); /* poitner to start of dest box */
+ INTER_DECLAREG(*psrcBase); /* pointer to start of source */
+ INTER_DECLAREG(*psrcLine); /* pointer to fetch point of source */
+ INTER_DECLAREG(*psrcStart); /* pointer to start of source line */
+ INTER_DECLAREG(*pdst);
+ INTER_DECLAREG(*psrc);
+ INTER_DECLAREGP(bits);
+ INTER_DECLAREGP(bits1);
+ register int nlTemp;
+
+ INTER_MROP_INITIALIZE (alu, planemask)
+
+ psrcBase = (unsigned short *)tile->devPrivate.ptr;
+ tileHeight = tile->drawable.height;
+ tileWidth = tile->drawable.width;
+ widthSrc = tile->devKind / (INTER_PGSZB * INTER_PLANES);
+
+ iplGetGroupWidthAndPointer (pDrawable, widthDst, pdstBase)
+
+ while (nBox--)
+ {
+ w = pBox->x2 - pBox->x1;
+ h = pBox->y2 - pBox->y1;
+
+ /* set up source */
+ modulus (pBox->x1 - xrot, tileWidth, srcx);
+ modulus (pBox->y1 - yrot, tileHeight, srcy);
+ xoffSrc = srcx & INTER_PIM;
+ srcStart = srcx >> INTER_PGSH;
+ psrcStart = psrcBase + (srcy * widthSrc) * INTER_PLANES;
+ psrcLine = psrcStart + srcStart * INTER_PLANES;
+
+ /* set up dest */
+ xoffDst = pBox->x1 & INTER_PIM;
+ pdstLine = pdstBase + (pBox->y1 * widthDst) +
+ (pBox->x1 >> INTER_PGSH) * INTER_PLANES;
+ /* set up masks */
+ if (xoffDst + w < INTER_PPG)
+ {
+ INTER_maskpartialbits(pBox->x1, w, startmask);
+ endmask = 0;
+ nlMiddle = 0;
+ }
+ else
+ {
+ INTER_maskbits (pBox->x1, w, startmask, endmask, nlMiddle)
+ }
+ if (xoffSrc == xoffDst)
+ {
+ while (h--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ srcRemaining = widthSrc - srcStart;
+ if (startmask)
+ {
+ INTER_MROP_MASK (psrc, pdst, startmask, pdst);
+ INTER_NEXT_GROUP(pdst);
+ IncSrcPtr
+ }
+ nlTemp = nlMiddle;
+ while (nlTemp)
+ {
+ nl = nlTemp;
+ if (nl > srcRemaining)
+ nl = srcRemaining;
+
+ nlTemp -= nl;
+ srcRemaining -= nl;
+
+ while (nl--) {
+ INTER_MROP_SOLID (psrc, pdst, pdst);
+ INTER_NEXT_GROUP(pdst); INTER_NEXT_GROUP(psrc);
+ }
+
+ if (!srcRemaining)
+ {
+ srcRemaining = widthSrc;
+ psrc = psrcStart;
+ }
+ }
+ if (endmask)
+ {
+ INTER_MROP_MASK (psrc, pdst, endmask, pdst);
+ }
+ pdstLine += widthDst;
+ psrcLine += widthSrc * INTER_PLANES;
+ psrcStart += widthSrc * INTER_PLANES;
+ if (++srcy == tileHeight)
+ {
+ psrcStart = psrcBase;
+ psrcLine = psrcStart + srcStart * INTER_PLANES;
+ srcy = 0;
+ }
+ }
+ }
+ else
+ {
+ if (xoffSrc > xoffDst)
+ {
+ leftShift = (xoffSrc - xoffDst) << LEFTSHIFT_AMT;
+ rightShift = INTER_PGSZ - leftShift;
+ }
+ else
+ {
+ rightShift = (xoffDst - xoffSrc) << LEFTSHIFT_AMT;
+ leftShift = INTER_PGSZ - rightShift;
+ }
+ while (h--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ INTER_CLR(bits);
+ srcRemaining = widthSrc - srcStart;
+ if (xoffSrc > xoffDst)
+ {
+ INTER_COPY(psrc, bits);
+ IncSrcPtr
+ }
+ if (startmask)
+ {
+ INTER_SCRLEFT(leftShift, bits, bits1);
+ INTER_COPY(psrc, bits);
+ IncSrcPtr
+ INTER_MSKINSM(~0, 0, bits1, ~0, rightShift, bits, bits1);
+ INTER_MROP_MASK(bits1, pdst, startmask, pdst);
+ INTER_NEXT_GROUP(pdst);
+ }
+ nlTemp = nlMiddle;
+ while (nlTemp)
+ {
+ nl = nlTemp;
+ if (nl > srcRemaining)
+ nl = srcRemaining;
+
+ nlTemp -= nl;
+ srcRemaining -= nl;
+
+ while (nl--) {
+ INTER_SCRLEFT(leftShift, bits, bits1);
+ INTER_COPY(psrc, bits); INTER_NEXT_GROUP(psrc);
+ INTER_MSKINSM(~0, 0, bits1, ~0, rightShift, bits, bits1);
+ INTER_MROP_SOLID (bits1, pdst, pdst);
+ INTER_NEXT_GROUP(pdst);
+ }
+
+ if (!srcRemaining)
+ {
+ srcRemaining = widthSrc;
+ psrc = psrcStart;
+ }
+ }
+
+ if (endmask)
+ {
+ INTER_SCRLEFT(leftShift, bits, bits1);
+ if (endmask << rightShift)
+ {
+ INTER_COPY(psrc, bits);
+ INTER_MSKINSM(~0, 0, bits1, ~0, rightShift, bits, bits1);
+ }
+ INTER_MROP_MASK (bits1, pdst, endmask, pdst);
+ }
+ pdstLine += widthDst;
+ psrcLine += widthSrc * INTER_PLANES;
+ psrcStart += widthSrc * INTER_PLANES;
+ if (++srcy == tileHeight)
+ {
+ psrcStart = psrcBase;
+ psrcLine = psrcStart + srcStart * INTER_PLANES;
+ srcy = 0;
+ }
+ }
+ }
+ pBox++;
+ }
+}
+
+void
+INTER_MROP_NAME(iplFillSpanTile32s) (pDrawable, n, ppt, pwidth, tile, xrot, yrot, alu, planemask)
+ DrawablePtr pDrawable;
+ int n;
+ DDXPointPtr ppt;
+ int *pwidth;
+ PixmapPtr tile;
+ int xrot, yrot;
+ int alu;
+ unsigned long planemask;
+{
+ int tileWidth; /* width of tile */
+ int tileHeight; /* height of the tile */
+ int widthSrc; /* width in longwords of the source tile */
+
+ int widthDst; /* width in longwords of the dest pixmap */
+ int w; /* width of current box */
+ INTER_DECLAREG(startmask);
+ INTER_DECLAREG(endmask);/* masks for reggedy bits at either end of line */
+ int nlMiddle; /* number of longwords between sides of boxes */
+
+ register int nl; /* loop version of nlMiddle */
+ int srcy; /* current tile y position */
+ int srcx; /* current tile x position */
+ int srcRemaining; /* number of longwords remaining in source */
+ int xoffDst, xoffSrc;
+ int srcStart; /* number of longwords source offset at left of box */
+ int leftShift, rightShift;
+
+ INTER_MROP_DECLARE_REG()
+
+ INTER_DECLAREG(*pdstBase); /* pointer to start of dest */
+ INTER_DECLAREG(*pdstLine); /* poitner to start of dest box */
+ INTER_DECLAREG(*psrcBase); /* pointer to start of source */
+ INTER_DECLAREG(*psrcLine); /* pointer to fetch point of source */
+ INTER_DECLAREG(*psrcStart); /* pointer to start of source line */
+ INTER_DECLAREG(*pdst);
+ INTER_DECLAREG(*psrc);
+ INTER_DECLAREGP(bits);
+ INTER_DECLAREGP(bits1);
+ register int nlTemp;
+
+ INTER_MROP_INITIALIZE (alu, planemask)
+
+ psrcBase = (unsigned short *)tile->devPrivate.ptr;
+ tileHeight = tile->drawable.height;
+ tileWidth = tile->drawable.width;
+ widthSrc = tile->devKind / (INTER_PGSZB * INTER_PLANES);
+
+ iplGetGroupWidthAndPointer (pDrawable, widthDst, pdstBase)
+
+ while (n--)
+ {
+ w = *pwidth++;
+
+ /* set up source */
+ modulus (ppt->x - xrot, tileWidth, srcx);
+ modulus (ppt->y - yrot, tileHeight, srcy);
+ xoffSrc = srcx & INTER_PIM;
+ srcStart = srcx >> INTER_PGSH;
+ psrcStart = psrcBase + (srcy * widthSrc) * INTER_PLANES;
+ psrcLine = psrcStart + srcStart * INTER_PLANES;
+
+ /* set up dest */
+ xoffDst = ppt->x & INTER_PIM;
+ pdstLine = pdstBase + (ppt->y * widthDst) +
+ (ppt->x >> INTER_PGSH) * INTER_PLANES;
+ /* set up masks */
+ if (xoffDst + w < INTER_PPG)
+ {
+ INTER_maskpartialbits(ppt->x, w, startmask);
+ endmask = 0;
+ nlMiddle = 0;
+ }
+ else
+ {
+ INTER_maskbits (ppt->x, w, startmask, endmask, nlMiddle)
+ }
+
+ if (xoffSrc == xoffDst)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ srcRemaining = widthSrc - srcStart;
+ if (startmask)
+ {
+ INTER_MROP_MASK (psrc, pdst, startmask, pdst);
+ INTER_NEXT_GROUP(pdst);
+ IncSrcPtr
+ }
+ nlTemp = nlMiddle;
+ while (nlTemp)
+ {
+ nl = nlTemp;
+ if (nl > srcRemaining)
+ nl = srcRemaining;
+
+ nlTemp -= nl;
+ srcRemaining -= nl;
+
+ while (nl--) {
+ INTER_MROP_SOLID (psrc, pdst, pdst);
+ INTER_NEXT_GROUP(pdst); INTER_NEXT_GROUP(psrc);
+ }
+
+ if (!srcRemaining)
+ {
+ srcRemaining = widthSrc;
+ psrc = psrcStart;
+ }
+ }
+ if (endmask)
+ {
+ INTER_MROP_MASK (psrc, pdst, endmask, pdst);
+ }
+ }
+ else
+ {
+ if (xoffSrc > xoffDst)
+ {
+ leftShift = (xoffSrc - xoffDst) << LEFTSHIFT_AMT;
+ rightShift = INTER_PGSZ - leftShift;
+ }
+ else
+ {
+ rightShift = (xoffDst - xoffSrc) << LEFTSHIFT_AMT;
+ leftShift = INTER_PGSZ - rightShift;
+ }
+ psrc = psrcLine;
+ pdst = pdstLine;
+ INTER_CLR(bits);
+ srcRemaining = widthSrc - srcStart;
+ if (xoffSrc > xoffDst)
+ {
+ INTER_COPY(psrc, bits);
+ IncSrcPtr
+ }
+ if (startmask)
+ {
+ INTER_SCRLEFT(leftShift, bits, bits1);
+ INTER_COPY(psrc, bits);
+ IncSrcPtr
+ INTER_MSKINSM(~0, 0, bits1, ~0, rightShift, bits, bits1);
+ INTER_MROP_MASK(bits1, pdst, startmask, pdst);
+ INTER_NEXT_GROUP(pdst);
+ }
+ nlTemp = nlMiddle;
+ while (nlTemp)
+ {
+ nl = nlTemp;
+ if (nl > srcRemaining)
+ nl = srcRemaining;
+
+ nlTemp -= nl;
+ srcRemaining -= nl;
+
+ while (nl--) {
+ INTER_SCRLEFT(leftShift, bits, bits1);
+ INTER_COPY(psrc, bits); INTER_NEXT_GROUP(psrc);
+ INTER_MSKINSM(~0, 0, bits1, ~0, rightShift, bits, bits1);
+ INTER_MROP_SOLID(bits1, pdst, pdst);
+ INTER_NEXT_GROUP(pdst);
+ }
+
+ if (!srcRemaining)
+ {
+ srcRemaining = widthSrc;
+ psrc = psrcStart;
+ }
+ }
+
+ if (endmask)
+ {
+ INTER_SCRLEFT(leftShift, bits, bits1);
+ if (endmask << rightShift)
+ {
+ INTER_COPY(psrc, bits);
+ INTER_MSKINSM(~0, 0, bits1, ~0, rightShift, bits, bits1);
+ }
+ INTER_MROP_MASK (bits1, pdst, endmask, pdst);
+ }
+ }
+ ppt++;
+ }
+}
diff --git a/nx-X11/programs/Xserver/iplan2p4/iplwindow.c b/nx-X11/programs/Xserver/iplan2p4/iplwindow.c
new file mode 100644
index 000000000..511e753b3
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p4/iplwindow.c
@@ -0,0 +1,343 @@
+/* $XFree86: xc/programs/Xserver/iplan2p4/iplwindow.c,v 3.0tsi Exp $ */
+/* $XConsortium: iplwindow.c,v 5.22 94/04/17 20:29:07 dpw Exp $ */
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
+interleaved planes */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "ipl.h"
+#include "mistruct.h"
+#include "regionstr.h"
+#include "iplmskbits.h"
+
+extern WindowPtr *WindowTable;
+
+Bool
+iplCreateWindow(pWin)
+ WindowPtr pWin;
+{
+ iplPrivWin *pPrivWin;
+
+ pPrivWin = iplGetWindowPrivate(pWin);
+ pPrivWin->pRotatedBorder = NullPixmap;
+ pPrivWin->pRotatedBackground = NullPixmap;
+ pPrivWin->fastBackground = FALSE;
+ pPrivWin->fastBorder = FALSE;
+ pPrivWin->oldRotate.x = 0;
+ pPrivWin->oldRotate.y = 0;
+
+#ifdef PIXMAP_PER_WINDOW
+ /* Setup pointer to Screen pixmap */
+ pWin->devPrivates[frameWindowPrivateIndex].ptr =
+ (pointer) iplGetScreenPixmap(pWin->drawable.pScreen);
+#endif
+
+ return TRUE;
+}
+
+Bool
+iplDestroyWindow(pWin)
+ WindowPtr pWin;
+{
+ iplPrivWin *pPrivWin;
+
+ pPrivWin = iplGetWindowPrivate(pWin);
+
+ if (pPrivWin->pRotatedBorder)
+ (*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
+ if (pPrivWin->pRotatedBackground)
+ (*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBackground);
+ return(TRUE);
+}
+
+/*ARGSUSED*/
+Bool
+iplMapWindow(pWindow)
+ WindowPtr pWindow;
+{
+ return(TRUE);
+}
+
+/* (x, y) is the upper left corner of the window on the screen
+ do we really need to pass this? (is it a;ready in pWin->absCorner?)
+ we only do the rotation for pixmaps that are 32 bits wide (padded
+or otherwise.)
+ iplChangeWindowAttributes() has already put a copy of the pixmap
+in pPrivWin->pRotated*
+*/
+/*ARGSUSED*/
+Bool
+iplPositionWindow(pWin, x, y)
+ WindowPtr pWin;
+ int x, y;
+{
+ iplPrivWin *pPrivWin;
+ int setxy = 0;
+
+ pPrivWin = iplGetWindowPrivate(pWin);
+ if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground)
+ {
+ iplXRotatePixmap(pPrivWin->pRotatedBackground,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ iplYRotatePixmap(pPrivWin->pRotatedBackground,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ setxy = 1;
+ }
+
+ if (!pWin->borderIsPixel && pPrivWin->fastBorder)
+ {
+ while (pWin->backgroundState == ParentRelative)
+ pWin = pWin->parent;
+ iplXRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ iplYRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ setxy = 1;
+ }
+ if (setxy)
+ {
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ }
+ return (TRUE);
+}
+
+/*ARGSUSED*/
+Bool
+iplUnmapWindow(pWindow)
+ WindowPtr pWindow;
+{
+ return (TRUE);
+}
+
+/* UNCLEAN!
+ this code calls the bitblt helper code directly.
+
+ iplCopyWindow copies only the parts of the destination that are
+visible in the source.
+*/
+
+
+void
+iplCopyWindow(pWin, ptOldOrg, prgnSrc)
+ WindowPtr pWin;
+ DDXPointRec ptOldOrg;
+ RegionPtr prgnSrc;
+{
+ DDXPointPtr pptSrc;
+ register DDXPointPtr ppt;
+ RegionRec rgnDst;
+ register BoxPtr pbox;
+ register int dx, dy;
+ register int i, nbox;
+ WindowPtr pwinRoot;
+
+ pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
+
+ REGION_NULL(pWin->drawable.pScreen, &rgnDst);
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+ REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+
+ pbox = REGION_RECTS(&rgnDst);
+ nbox = REGION_NUM_RECTS(&rgnDst);
+ if(!nbox || !(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
+ {
+ REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+ return;
+ }
+ ppt = pptSrc;
+
+ for (i = nbox; --i >= 0; ppt++, pbox++)
+ {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ iplDoBitbltCopy((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
+ GXcopy, &rgnDst, pptSrc, ~0L);
+ DEALLOCATE_LOCAL(pptSrc);
+ REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+}
+
+
+
+/* swap in correct PaintWindow* routine. If we can use a fast output
+routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
+of it in devPrivates[iplWindowPrivateIndex].ptr.
+*/
+Bool
+iplChangeWindowAttributes(pWin, mask)
+ WindowPtr pWin;
+ unsigned long mask;
+{
+ register unsigned long index;
+ register iplPrivWin *pPrivWin;
+ int width;
+ WindowPtr pBgWin;
+
+ pPrivWin = iplGetWindowPrivate(pWin);
+
+ /*
+ * When background state changes from ParentRelative and
+ * we had previously rotated the fast border pixmap to match
+ * the parent relative origin, rerotate to match window
+ */
+ if (mask & (CWBackPixmap | CWBackPixel) &&
+ pWin->backgroundState != ParentRelative &&
+ pPrivWin->fastBorder &&
+ (pPrivWin->oldRotate.x != pWin->drawable.x ||
+ pPrivWin->oldRotate.y != pWin->drawable.y))
+ {
+ iplXRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ iplYRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ }
+ while(mask)
+ {
+ index = lowbit (mask);
+ mask &= ~index;
+ switch(index)
+ {
+ case CWBackPixmap:
+ if (pWin->backgroundState == None)
+ {
+ pPrivWin->fastBackground = FALSE;
+ }
+ else if (pWin->backgroundState == ParentRelative)
+ {
+ pPrivWin->fastBackground = FALSE;
+ /* Rotate border to match parent origin */
+ if (pPrivWin->pRotatedBorder) {
+ for (pBgWin = pWin->parent;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+ iplXRotatePixmap(pPrivWin->pRotatedBorder,
+ pBgWin->drawable.x - pPrivWin->oldRotate.x);
+ iplYRotatePixmap(pPrivWin->pRotatedBorder,
+ pBgWin->drawable.y - pPrivWin->oldRotate.y);
+ pPrivWin->oldRotate.x = pBgWin->drawable.x;
+ pPrivWin->oldRotate.y = pBgWin->drawable.y;
+ }
+ }
+ else if (((width = (pWin->background.pixmap->drawable.width))
+ <= INTER_PGSZ) && !(width & (width - 1)))
+ {
+ iplCopyRotatePixmap(pWin->background.pixmap,
+ &pPrivWin->pRotatedBackground,
+ pWin->drawable.x,
+ pWin->drawable.y);
+ if (pPrivWin->pRotatedBackground)
+ {
+ pPrivWin->fastBackground = TRUE;
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ }
+ else
+ {
+ pPrivWin->fastBackground = FALSE;
+ }
+ }
+ else
+ {
+ pPrivWin->fastBackground = FALSE;
+ }
+ break;
+
+ case CWBackPixel:
+ pPrivWin->fastBackground = FALSE;
+ break;
+
+ case CWBorderPixmap:
+ if (((width = (pWin->border.pixmap->drawable.width)) <= INTER_PGSZ) &&
+ !(width & (width - 1)))
+ {
+ for (pBgWin = pWin;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+ iplCopyRotatePixmap(pWin->border.pixmap,
+ &pPrivWin->pRotatedBorder,
+ pBgWin->drawable.x,
+ pBgWin->drawable.y);
+ if (pPrivWin->pRotatedBorder)
+ {
+ pPrivWin->fastBorder = TRUE;
+ pPrivWin->oldRotate.x = pBgWin->drawable.x;
+ pPrivWin->oldRotate.y = pBgWin->drawable.y;
+ }
+ else
+ {
+ pPrivWin->fastBorder = FALSE;
+ }
+ }
+ else
+ {
+ pPrivWin->fastBorder = FALSE;
+ }
+ break;
+ case CWBorderPixel:
+ pPrivWin->fastBorder = FALSE;
+ break;
+ }
+ }
+ return (TRUE);
+}
+
diff --git a/nx-X11/programs/Xserver/iplan2p8/Imakefile b/nx-X11/programs/Xserver/iplan2p8/Imakefile
new file mode 100644
index 000000000..d7b3bdf54
--- /dev/null
+++ b/nx-X11/programs/Xserver/iplan2p8/Imakefile
@@ -0,0 +1,6 @@
+XCOMM $XFree86$
+XCOMM $XConsortium: Imakefile,v 1.1 91/12/28 13:32:27 rws Exp $
+#define IPlanes 8
+#define LinkDirectory ../iplan2p4
+
+#include "../iplan2p4/Imakefile"
diff --git a/nx-X11/programs/Xserver/lbx/Imakefile b/nx-X11/programs/Xserver/lbx/Imakefile
new file mode 100644
index 000000000..22749d72e
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/Imakefile
@@ -0,0 +1,56 @@
+/* $Xorg: Imakefile,v 1.3 2000/08/17 19:53:31 cpqbld Exp $
+ *
+ * $NCDXorg: @(#)Imakefile,v 1.16 1994/11/18 20:32:34 lemke Exp $
+ *
+ * Copyright 1992 Network Computing Devices
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of NCD. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCD. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, Network Computing Devices
+ */
+/* $XFree86: xc/programs/Xserver/lbx/Imakefile,v 1.4 2001/01/17 22:36:59 dawes Exp $ */
+
+#include <Server.tmpl>
+
+#ifdef NCD
+INCLUDES = \
+ -I$(EXTENSIONSRC)/include/lbx \
+ -I$(EXTENSIONSRC)/include \
+ -I$(EXTENSIONSRC)/lbxcommon/delta \
+ -I$(XINCLUDESRC) \
+ -I$(FONTSRC)/include \
+ -I$(SERVERSRC)/include
+#else
+INCLUDES = -I$(TOP)/include -I$(TOP)/include/fonts -I$(SERVERSRC)/include -I$(EXTINCSRC) -I../../../include/extensions
+#endif
+
+SRCS = \
+ lbxmain.c lbxdix.c lbxtags.c lbxprop.c lbxgfx.c lbxtables.c \
+ lbxswap.c lbxsquish.c lbxexts.c lbxopts.c lbxzerorep.c lbxcmap.c
+
+
+OBJS = \
+ lbxmain.o lbxdix.o lbxtags.o lbxprop.o lbxgfx.o lbxtables.o \
+ lbxswap.o lbxsquish.o lbxexts.o lbxopts.o lbxzerorep.o lbxcmap.o
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(lbx,$(OBJS))
+LintLibraryTarget(lbx,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/lbx/lbxcmap.c b/nx-X11/programs/Xserver/lbx/lbxcmap.c
new file mode 100644
index 000000000..3ae598bc6
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/lbxcmap.c
@@ -0,0 +1,1156 @@
+/* $Xorg: lbxcmap.c,v 1.4 2001/02/09 02:05:16 xorgcvs Exp $ */
+
+/*
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+*/
+/* $XFree86: xc/programs/Xserver/lbx/lbxcmap.c,v 1.9 2001/08/23 14:46:57 alanh Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <sys/types.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xos.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "scrnintstr.h"
+#include "colormapst.h"
+#include "propertyst.h"
+#define _XLBX_SERVER_
+#include <X11/extensions/lbxstr.h>
+#include "lbxserve.h"
+#include <X11/Xfuncproto.h>
+#include <stdio.h>
+
+static int lbxScreenPrivIndex; /* lbx screen private index */
+static int lbxColormapPrivIndex; /* lbx colormap private index */
+
+typedef struct { /* lbx screen private */
+ CreateColormapProcPtr CreateColormap;
+ DestroyColormapProcPtr DestroyColormap;
+ CloseScreenProcPtr CloseScreen;
+} LbxScreenPriv;
+
+typedef struct _LbxStalled {
+ XID id;
+ struct _LbxStalled *next;
+} LbxStalled;
+
+typedef struct _LbxColormapPriv { /* lbx colormap private */
+ char grab_status;
+ char smart_grab;
+ LbxProxyPtr grabber;
+ int last_grabber; /* uid, not pid */
+ LbxStalled *stalled_clients;
+ ColormapPtr next; /* proxy chain */
+} LbxColormapPriv;
+
+#define CMAP_NOT_GRABBED 0
+#define CMAP_GRABBED 1
+#define CMAP_WAITING_FOR_UNGRAB 2
+
+static int LbxUnstallClient(pointer data, XID id);
+
+static RESTYPE StalledResType;
+
+/*
+ * Initialize the fields in the colormap private allocated for LBX.
+ */
+
+static LbxColormapPriv *
+LbxColormapPrivInit (ColormapPtr pmap)
+{
+ LbxColormapPriv *cmapPriv;
+
+ cmapPriv = (LbxColormapPriv *) xalloc (sizeof (LbxColormapPriv));
+ if (!cmapPriv)
+ return cmapPriv;
+
+ pmap->devPrivates[lbxColormapPrivIndex].ptr = (pointer) cmapPriv;
+
+ cmapPriv->grab_status = CMAP_NOT_GRABBED;
+ cmapPriv->grabber = NULL;
+ cmapPriv->last_grabber = 0;
+ cmapPriv->smart_grab = FALSE;
+ cmapPriv->stalled_clients = NULL;
+ cmapPriv->next = NULL;
+
+ return cmapPriv;
+}
+
+
+static int
+LbxDefCmapPrivInit (ColormapPtr pmap, int index)
+{
+#if 0
+ /* BUG: You can't do that. lbxColormapPrivIndex hasn't
+ been initialized yet. */
+ pmap->devPrivates[lbxColormapPrivIndex].ptr = NULL;
+#endif
+ return 1;
+}
+
+static Bool
+LbxCreateColormap (ColormapPtr pmap)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+ Bool ret;
+
+ pScreen->CreateColormap = ((LbxScreenPriv *) (pScreen->devPrivates[
+ lbxScreenPrivIndex].ptr))->CreateColormap;
+
+ pmap->devPrivates[lbxColormapPrivIndex].ptr = NULL;
+ ret = (*pScreen->CreateColormap) (pmap);
+
+ pScreen->CreateColormap = LbxCreateColormap;
+
+ return ret;
+}
+
+static void
+LbxDestroyColormap (ColormapPtr pmap)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+
+ LbxReleaseCmap(pmap, FALSE);
+ pScreen->DestroyColormap = ((LbxScreenPriv *) (pScreen->devPrivates[
+ lbxScreenPrivIndex].ptr))->DestroyColormap;
+ (*pScreen->DestroyColormap) (pmap);
+ if (pmap->devPrivates && pmap->devPrivates[lbxColormapPrivIndex].ptr)
+ xfree(pmap->devPrivates[lbxColormapPrivIndex].ptr);
+ pScreen->DestroyColormap = LbxDestroyColormap;
+}
+
+static Bool
+LbxCloseScreen(int i, ScreenPtr pScreen)
+{
+ LbxScreenPriv* pLbxScrPriv = ((LbxScreenPriv *)
+ (pScreen->devPrivates[lbxScreenPrivIndex].ptr));
+
+ pScreen->CloseScreen = pLbxScrPriv->CloseScreen;
+
+ xfree(pScreen->devPrivates[lbxScreenPrivIndex].ptr);
+ pScreen->devPrivates[lbxScreenPrivIndex].ptr = NULL;
+
+ return pScreen->CloseScreen(i, pScreen);
+}
+
+/*
+ * Initialize LBX colormap private.
+ */
+
+int
+LbxCmapInit (void)
+
+{
+ LbxScreenPriv *pScreenPriv;
+ ColormapPtr defMap;
+ ScreenPtr pScreen;
+ int i;
+
+ StalledResType = CreateNewResourceType(LbxUnstallClient);
+
+ lbxScreenPrivIndex = AllocateScreenPrivateIndex ();
+ if (lbxScreenPrivIndex < 0)
+ return 0;
+
+ lbxColormapPrivIndex = AllocateColormapPrivateIndex (LbxDefCmapPrivInit);
+ if (lbxColormapPrivIndex < 0)
+ return 0;
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ pScreen = screenInfo.screens[i];
+
+ defMap = (ColormapPtr) LookupIDByType(
+ pScreen->defColormap, RT_COLORMAP);
+
+ /* now lbxColormapPrivIndex exists */
+ defMap->devPrivates[lbxColormapPrivIndex].ptr = NULL;
+
+ pScreenPriv = (LbxScreenPriv *) xalloc (sizeof (LbxScreenPriv));
+ if (!pScreenPriv)
+ return 0;
+
+ pScreenPriv->CreateColormap = pScreen->CreateColormap;
+ pScreen->CreateColormap = LbxCreateColormap;
+ pScreenPriv->DestroyColormap = pScreen->DestroyColormap;
+ pScreen->DestroyColormap = LbxDestroyColormap;
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = LbxCloseScreen;
+ pScreen->devPrivates[lbxScreenPrivIndex].ptr = (pointer) pScreenPriv;
+ }
+
+ return 1;
+}
+
+/*
+ * Return the number of allocated cells in the PSEUDO colormap.
+ */
+
+static int
+NumAllocatedCells (EntryPtr pent,
+ int size)
+{
+ Pixel pixel;
+ int count = 0;
+
+ for (pixel = 0; pixel < size; pixel++)
+ {
+ if (pent[pixel].refcnt != 0 && pent[pixel].refcnt != AllocTemporary)
+ count++;
+ }
+
+ return count;
+}
+
+#define NUMRED(vis) ((vis->redMask >> vis->offsetRed) + 1)
+#define NUMGREEN(vis) ((vis->greenMask >> vis->offsetGreen) + 1)
+#define NUMBLUE(vis) ((vis->blueMask >> vis->offsetBlue) + 1)
+
+#define PIX_OUT(ptr,is2,val) \
+ if (is2) *ptr++ = (val) >> 8; \
+ *ptr++ = (val)
+#define RGB_OUT(ptr,is2,shift,val) \
+ *ptr++ = (val) >> shift; \
+ if (is2) *ptr++ = (val)
+
+/*
+ * Return the list of allocated cells in the channel in
+ * the format required by LbxGrabCmapReply.
+ */
+
+static CARD8 *
+OutputChannel(ColormapPtr pmap,
+ EntryPtr chan,
+ int size,
+ CARD8 *ptr,
+ CARD8 flags,
+ CARD8 channels)
+{
+ Bool px2;
+ Bool rgb2;
+ int shift;
+ int rgb_sz;
+ Pixel pixel;
+ EntryPtr pent;
+ CARD8 *pixel_private_range_ptr = NULL;
+ CARD8 *pixel_shared_range_ptr = NULL;
+ int allocpriv;
+
+ px2 = (flags & LBX_2BYTE_PIXELS) != 0;
+ rgb2 = (flags & LBX_RGB_BITS_MASK) > 7;
+ if (rgb2)
+ shift = 8;
+ else
+ shift = 15 - (flags & LBX_RGB_BITS_MASK);
+ rgb_sz = rgb2 + 1;
+ if (channels == (DoRed|DoGreen|DoBlue))
+ rgb_sz *= 3;
+ /* kinda gross, but ddxen use AllocAll on static maps */
+ allocpriv = (pmap->pVisual->class & DynamicClass) ? AllocPrivate : 0;
+ for (pixel = 0; pixel < size; pixel++)
+ {
+ pent = (EntryPtr) &chan[pixel];
+
+ if (pent->refcnt == 0 || pent->refcnt == AllocTemporary)
+ {
+ /*
+ * A free pixel. This disrupts all ranges.
+ */
+
+ pixel_private_range_ptr = pixel_shared_range_ptr = NULL;
+
+ continue;
+ }
+ else if (pent->refcnt == allocpriv)
+ {
+ /*
+ * A private pixel. This disrupts any PIXEL_SHARED_RANGE.
+ */
+
+ pixel_shared_range_ptr = NULL;
+
+ if (!pixel_private_range_ptr)
+ {
+ pixel_private_range_ptr = ptr;
+
+ *ptr++ = LBX_PIXEL_PRIVATE;
+ PIX_OUT(ptr, px2, pixel);
+ }
+ else
+ {
+ CARD8 *pos = pixel_private_range_ptr + 2 + px2;
+ if (*pixel_private_range_ptr == LBX_PIXEL_PRIVATE) {
+ *pixel_private_range_ptr = LBX_PIXEL_RANGE_PRIVATE;
+ ptr += 1 + px2;
+ }
+ PIX_OUT(pos, px2, pixel);
+ }
+ }
+ else
+ {
+ /*
+ * A shared pixel. This disrupts any PIXEL_PRIVATE_RANGE.
+ */
+
+ pixel_private_range_ptr = NULL;
+
+ if (!pixel_shared_range_ptr)
+ {
+ pixel_shared_range_ptr = ptr;
+
+ *ptr++ = LBX_PIXEL_SHARED;
+ PIX_OUT(ptr, px2, pixel);
+ }
+ else
+ {
+ CARD8 *pos = pixel_shared_range_ptr + 2 + px2;
+ if (*pixel_shared_range_ptr == LBX_PIXEL_SHARED)
+ {
+ *pixel_shared_range_ptr = LBX_PIXEL_RANGE_SHARED;
+ memmove (pos + 1 + px2, pos, rgb_sz);
+ ptr += 1 + px2;
+ }
+ PIX_OUT(pos, px2, pixel);
+ }
+
+ if (channels & DoRed) {
+ RGB_OUT(ptr, rgb2, shift, pent->co.local.red);
+ }
+ if (channels & DoGreen) {
+ RGB_OUT(ptr, rgb2, shift, pent->co.local.green);
+ }
+ if (channels & DoBlue) {
+ RGB_OUT(ptr, rgb2, shift, pent->co.local.blue);
+ }
+ }
+ }
+ return ptr;
+}
+
+static void
+GetAllocatedCells (ColormapPtr pmap,
+ CARD8 *flags,
+ CARD8 *buf,
+ int *bytes)
+{
+ CARD8 *ptr;
+
+ *flags = pmap->pVisual->bitsPerRGBValue - 1;
+ if (pmap->pVisual->ColormapEntries > 256)
+ *flags |= LBX_2BYTE_PIXELS;
+ if (!(pmap->pVisual->class & DynamicClass))
+ *flags |= LBX_AUTO_RELEASE;
+ if ((pmap->pVisual->class | DynamicClass) == DirectColor) {
+ *flags |= LBX_3CHANNELS;
+ ptr = OutputChannel(pmap, pmap->red, NUMRED(pmap->pVisual),
+ buf, *flags, DoRed);
+ *ptr++ = LBX_NEXT_CHANNEL;
+ ptr = OutputChannel(pmap, pmap->green, NUMGREEN(pmap->pVisual),
+ ptr, *flags, DoGreen);
+ *ptr++ = LBX_NEXT_CHANNEL;
+ ptr = OutputChannel(pmap, pmap->blue, NUMBLUE(pmap->pVisual),
+ ptr, *flags, DoBlue);
+ } else
+ ptr = OutputChannel(pmap, pmap->red, pmap->pVisual->ColormapEntries,
+ buf, *flags, DoRed|DoGreen|DoBlue);
+ *ptr++ = LBX_LIST_END;
+ *bytes = ptr - buf;
+}
+
+
+/*
+ * Send an LbxReleaseCmapEvent to a proxy.
+ */
+
+static void
+SendReleaseCmapEvent (LbxProxyPtr proxy,
+ Colormap cmap)
+{
+ xLbxReleaseCmapEvent ev;
+ ClientPtr client;
+ LbxClientPtr lbxcp;
+ int n;
+
+ lbxcp = proxy->lbxClients[0];
+
+ if (lbxcp && (client = lbxcp->client))
+ {
+ ev.type = LbxEventCode;
+ ev.lbxType = LbxReleaseCmapEvent;
+ ev.sequenceNumber = client->sequence;
+ ev.colormap = cmap;
+ ev.pad1 = ev.pad2 = ev.pad3 = ev.pad4 = ev.pad5 = ev.pad6 = 0;
+
+ if (client->swapped)
+ {
+ swaps(&ev.sequenceNumber, n);
+ swapl(&ev.colormap, n);
+ }
+
+ WriteToClient(client, sz_xLbxReleaseCmapEvent, (char *) &ev);
+ LbxForceOutput(proxy);
+
+#ifdef COLOR_DEBUG
+ fprintf (stderr,
+ "Sent LbxReleaseCmapEvent to proxy %d, seq = 0x%x, cmap = 0x%x\n",
+ proxy->pid, client->sequence, cmap);
+#endif
+ }
+}
+
+
+/*
+ * WaitForServerCmapControl checks if the colormap is grabbed by a proxy,
+ * and if so, sends an LbxReleaseCmapEvent to the proxy. It then suspends
+ * the current request until the server gets the ReleaseCmap message from
+ * the proxy.
+ */
+
+static Bool
+WaitForServerCmapControl (ClientPtr client,
+ ColormapPtr pmap)
+{
+ LbxColormapPriv *cmapPriv = (LbxColormapPriv *)
+ (pmap->devPrivates[lbxColormapPrivIndex].ptr);
+ LbxStalled *stalled;
+
+ if (cmapPriv->grab_status == CMAP_GRABBED)
+ {
+ /*
+ * Send an LbxReleaseCmapEvent to the proxy that has the grab.
+ */
+
+ SendReleaseCmapEvent (cmapPriv->grabber, pmap->mid);
+ cmapPriv->grab_status = CMAP_WAITING_FOR_UNGRAB;
+ }
+
+ stalled = (LbxStalled *)xalloc(sizeof(LbxStalled));
+ if (!stalled)
+ return FALSE;
+ stalled->id = FakeClientID(client->index);
+ stalled->next = cmapPriv->stalled_clients;
+ cmapPriv->stalled_clients = stalled;
+ return AddResource(stalled->id, StalledResType, (pointer)cmapPriv);
+}
+
+
+/*
+ * When the X server gets any of the requests that allocate color cells,
+ * it calls LbxCheckColorRequest on the request. This function will check
+ * if the colormap is grabbed by a proxy, and if so, will suspend the
+ * current request and wait for the proxy to release the colormap.
+ */
+
+Bool
+LbxCheckColorRequest (ClientPtr client,
+ ColormapPtr pmap,
+ xReq *req)
+{
+ LbxColormapPriv *cmapPriv = (LbxColormapPriv *)
+ (pmap->devPrivates[lbxColormapPrivIndex].ptr);
+
+ if (!cmapPriv)
+ return FALSE;
+
+ if (cmapPriv->grab_status != CMAP_NOT_GRABBED)
+ {
+ /*
+ * The colormap is grabbed by a proxy. Reset this request, and
+ * process it after the server gets back control of the colormap.
+ * Before we reset the request, we must put it back in the
+ * client's byte order.
+ */
+
+ if (!WaitForServerCmapControl (client, pmap))
+ return FALSE;
+
+ if (client->swapped)
+ {
+ register int n;
+
+ switch (req->reqType)
+ {
+ case X_AllocColor:
+ {
+ xAllocColorReq *stuff = (xAllocColorReq *) req;
+ swaps(&stuff->length, n);
+ swapl(&stuff->cmap, n);
+ swaps(&stuff->red, n);
+ swaps(&stuff->green, n);
+ swaps(&stuff->blue, n);
+ break;
+ }
+ case X_AllocNamedColor:
+ {
+ xAllocNamedColorReq *stuff = (xAllocNamedColorReq *) req;
+ swaps(&stuff->length, n);
+ swapl(&stuff->cmap, n);
+ swaps(&stuff->nbytes, n);
+ break;
+ }
+ case X_AllocColorCells:
+ {
+ xAllocColorCellsReq *stuff = (xAllocColorCellsReq *) req;
+ swaps(&stuff->length, n);
+ swapl(&stuff->cmap, n);
+ swaps(&stuff->colors, n);
+ swaps(&stuff->planes, n);
+ break;
+ }
+ case X_AllocColorPlanes:
+ {
+ xAllocColorPlanesReq *stuff = (xAllocColorPlanesReq *) req;
+ swaps(&stuff->length, n);
+ swapl(&stuff->cmap, n);
+ swaps(&stuff->colors, n);
+ swaps(&stuff->red, n);
+ swaps(&stuff->green, n);
+ swaps(&stuff->blue, n);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ ResetCurrentRequest(client);
+ client->sequence--;
+ IgnoreClient(client);
+
+ return TRUE;
+ }
+
+ if (!LbxClient(client) ||
+ LbxProxy(client)->uid != cmapPriv->last_grabber)
+ {
+ /*
+ * Next time the proxy for this client does a colormap grab, it
+ * will have to get the colormap state (a non-smart grab).
+ */
+
+ cmapPriv->smart_grab = FALSE;
+ }
+
+ return FALSE;
+}
+
+static Bool
+LbxGrabbedByClient (ClientPtr client,
+ ColormapPtr pmap)
+{
+ LbxColormapPriv *cmapPriv = (LbxColormapPriv *)
+ (pmap->devPrivates[lbxColormapPrivIndex].ptr);
+ return (cmapPriv &&
+ (cmapPriv->grab_status != CMAP_NOT_GRABBED) &&
+ (cmapPriv->grabber == LbxProxy(client)));
+}
+
+/*
+ * Check if a colormap is grabbed by a proxy.
+ */
+
+int
+LbxCheckCmapGrabbed (ColormapPtr pmap)
+{
+ LbxColormapPriv *cmapPriv = (LbxColormapPriv *)
+ (pmap->devPrivates[lbxColormapPrivIndex].ptr);
+
+ return (cmapPriv && (cmapPriv->grab_status == CMAP_GRABBED));
+}
+
+
+/*
+ * Disable a smart grab on the specified colormap.
+ */
+
+void
+LbxDisableSmartGrab (ColormapPtr pmap)
+{
+ LbxColormapPriv *cmapPriv = (LbxColormapPriv *)
+ (pmap->devPrivates[lbxColormapPrivIndex].ptr);
+
+ if (cmapPriv)
+ cmapPriv->smart_grab = FALSE;
+}
+
+
+/*
+ * Send an LbxFreeCellsEvent to the specified proxy.
+ */
+
+static void
+SendFreeCellsEvent (LbxProxyPtr proxy,
+ Colormap cmap,
+ Pixel pixel_start,
+ Pixel pixel_end)
+{
+ xLbxFreeCellsEvent ev;
+ ClientPtr client;
+ LbxClientPtr lbxcp;
+ int n;
+
+ lbxcp = proxy->lbxClients[0];
+
+ if (lbxcp && (client = lbxcp->client))
+ {
+ ev.type = LbxEventCode;
+ ev.lbxType = LbxFreeCellsEvent;
+ ev.sequenceNumber = client->sequence;
+ ev.colormap = cmap;
+ ev.pixelStart = pixel_start;
+ ev.pixelEnd = pixel_end;
+ ev.pad1 = ev.pad2 = ev.pad3 = ev.pad4 = 0;
+
+ if (client->swapped)
+ {
+ swaps(&ev.sequenceNumber, n);
+ swapl(&ev.colormap, n);
+ swapl(&ev.pixelStart, n);
+ swapl(&ev.pixelEnd, n);
+ }
+
+ WriteToClient(client, sz_xLbxFreeCellsEvent, (char *) &ev);
+ LbxForceOutput(proxy);
+#ifdef COLOR_DEBUG
+ fprintf (stderr, "Sent LbxFreeCellsEvent to proxy %d, seq = 0x%x\n",
+ proxy->pid, client->sequence);
+ fprintf (stderr, " cmap = 0x%x, pixelStart = %d, pixelEnd = %d\n",
+ cmap, pixel_start, pixel_end);
+#endif
+ }
+}
+
+/* XXX use of globals like this is gross */
+static long pixel_start;
+static long pixel_end;
+
+
+/*
+ * LbxFreeCellsEvent generation functions.
+ */
+
+/*ARGSUSED*/
+void
+LbxBeginFreeCellsEvent (ColormapPtr pmap)
+{
+ pixel_start = -1;
+ pixel_end = -1;
+}
+
+
+void
+LbxAddFreeCellToEvent (ColormapPtr pmap,
+ Pixel pixel)
+{
+ /*
+ * We must notify the proxy that has this colormap
+ * grabbed which cells are being freed (their refcount
+ * has reached zero).
+ */
+
+ if (pixel_start == -1)
+ pixel_start = pixel;
+ else
+ {
+ if (pixel_end == -1)
+ pixel_end = pixel;
+ else
+ {
+ if (pixel_end + 1 == pixel)
+ pixel_end = pixel;
+ else if (pixel > pixel_end + 1)
+ {
+ LbxColormapPriv *cmapPriv = (LbxColormapPriv *)
+ (pmap->devPrivates[lbxColormapPrivIndex].ptr);
+
+ SendFreeCellsEvent (cmapPriv->grabber,
+ pmap->mid, pixel_start, pixel_end);
+
+ pixel_start = pixel;
+ pixel_end = -1;
+ }
+ }
+ }
+}
+
+void
+LbxEndFreeCellsEvent (ColormapPtr pmap)
+{
+ /*
+ * Check if there is an LbxFreeCellEvent we need to write.
+ */
+
+ if (pixel_start != -1)
+ {
+ LbxColormapPriv *cmapPriv = (LbxColormapPriv *)
+ (pmap->devPrivates[lbxColormapPrivIndex].ptr);
+
+ SendFreeCellsEvent (cmapPriv->grabber,
+ pmap->mid, pixel_start,
+ pixel_end == -1 ? pixel_start : pixel_end);
+ }
+}
+
+
+/*
+ * Sort the specified pixel list. This optimizes generation
+ * of LbxFreeCellsEvent.
+ */
+
+void
+LbxSortPixelList (Pixel *pixels,
+ int count)
+{
+ int i, j;
+
+ for (i = 0; i <= count - 2; i++)
+ for (j = count - 1; j > i; j--)
+ if (pixels[j - 1] > pixels[j])
+ {
+ Pixel temp = pixels[j - 1];
+ pixels[j - 1] = pixels[j];
+ pixels[j] = temp;
+ }
+}
+
+
+/*
+ * Handle a colormap grab request from a proxy.
+ */
+
+int
+ProcLbxGrabCmap(ClientPtr client)
+{
+ REQUEST(xLbxGrabCmapReq);
+ xLbxGrabCmapReply *reply;
+ Bool smartGrab;
+ LbxColormapPriv *cmapPriv;
+ ColormapPtr pmap;
+ int bytes, n;
+ LbxProxyPtr proxy = LbxProxy(client);
+
+ client->sequence--; /* not a counted request */
+
+ pmap = (ColormapPtr) SecurityLookupIDByType (client, stuff->cmap,
+ RT_COLORMAP,
+ SecurityWriteAccess);
+
+ if (!pmap)
+ {
+ client->errorValue = stuff->cmap;
+ return BadColor;
+ }
+
+ cmapPriv = (LbxColormapPriv *)
+ (pmap->devPrivates[lbxColormapPrivIndex].ptr);
+ if (!cmapPriv)
+ {
+ cmapPriv = LbxColormapPrivInit (pmap);
+ if (!cmapPriv)
+ return BadAlloc;
+ }
+
+
+ /*
+ * We have a SMART GRAB if since this proxy last ungrabbed the
+ * colormap, no color cell was alloc'd by an entity other than
+ * this proxy (this includes other proxies as well as clients
+ * directly connected to the X server without a proxy).
+ *
+ * We want to optimize this special case because a proxy may give
+ * up a grab because it got a request that it could not handle
+ * (e.g. AllocNamedColor or LookupColor). When it asks back for
+ * the grab, there is no need for the server to send the colormap
+ * state, because the proxy is already up to date on the state of
+ * the colormap.
+ *
+ * In order for this to work, the following assumptions are made
+ * about the proxy:
+ *
+ * - the proxy is kept up to date on all cell allocations made on its
+ * behalf resulting from the following requests: AllocNamedColor,
+ * AllocColorCells, AllocColorPlanes
+ * - the proxy is kept up to date on all cells freed by any client
+ * via the LbxFreeCell event.
+ */
+
+ /* if proxy is this confused, give it full info */
+ if (cmapPriv->grab_status == CMAP_GRABBED && cmapPriv->grabber == proxy)
+ LbxReleaseCmap(pmap, FALSE);
+
+ if (proxy->uid != cmapPriv->last_grabber)
+ cmapPriv->smart_grab = FALSE;
+ smartGrab = cmapPriv->smart_grab;
+
+#ifdef COLOR_DEBUG
+ fprintf (stderr, "\nGot colormap grab request, ");
+ fprintf (stderr, "seq = 0x%x, proxy = %d, client = %d, cmap = 0x%x\n",
+ client->sequence, proxy->pid, client->index, stuff->cmap);
+
+ if (cmapPriv->grab_status == CMAP_NOT_GRABBED)
+ {
+ fprintf (stderr, "cmap 0x%x is not grabbed by any proxy\n",
+ stuff->cmap);
+ if (smartGrab)
+ fprintf (stderr, "This is a smart grab\n");
+ }
+ else if (cmapPriv->grab_status == CMAP_GRABBED)
+ {
+ if (cmapPriv->grabber == proxy)
+ {
+ fprintf (stderr, "cmap 0x%x is already grabbed by proxy %d\n",
+ stuff->cmap, proxy->pid);
+ }
+ else
+ {
+ fprintf (stderr, "cmap 0x%x is currently grabbed by proxy %d\n",
+ stuff->cmap, cmapPriv->grabber->pid);
+ }
+ }
+ else if (cmapPriv->grab_status == CMAP_WAITING_FOR_UNGRAB)
+ {
+ fprintf (stderr,
+ "Already waiting for cmap 0x%x to be ungrabbed by proxy %d\n",
+ stuff->cmap, cmapPriv->grabber->pid);
+ }
+#endif
+
+ if (cmapPriv->grab_status != CMAP_NOT_GRABBED &&
+ cmapPriv->grabber != proxy)
+ {
+ /*
+ * The colormap is grabbed by a proxy other than the one that
+ * is requesting this grab. Reset this grab request, and process
+ * it after the server gets back control of the colormap. Before
+ * we reset the request, we must put it back in the client's byte
+ * order.
+ */
+
+ if (!WaitForServerCmapControl (client, pmap))
+ return BadAlloc;
+
+ if (client->swapped)
+ {
+ swaps(&stuff->length, n);
+ swapl(&stuff->cmap, n);
+ }
+
+ ResetCurrentRequest(client);
+ IgnoreClient(client);
+
+ return Success;
+ }
+
+ if (pmap->pVisual->class & DynamicClass) {
+ cmapPriv->grabber = proxy;
+ cmapPriv->grab_status = CMAP_GRABBED;
+ cmapPriv->next = proxy->grabbedCmaps;
+ proxy->grabbedCmaps = pmap;
+ } else
+ smartGrab = FALSE;
+
+ /*
+ * For an smart grab (see comments above), there is no information
+ * sent about the colormap cells because the proxy is all up to date.
+ * Otherwise, the server sends the proxy the state of all allocated
+ * cells in the colormap. All cells not specified are assumed free.
+ */
+
+ bytes = 0;
+ if (!smartGrab) {
+ if ((pmap->pVisual->class | DynamicClass) == DirectColor) {
+ bytes = NumAllocatedCells(pmap->red,
+ NUMRED(pmap->pVisual)) * 9;
+ bytes += NumAllocatedCells(pmap->green,
+ NUMGREEN(pmap->pVisual)) * 9;
+ bytes += NumAllocatedCells(pmap->blue,
+ NUMBLUE(pmap->pVisual)) * 9;
+ bytes += 2;
+ } else
+ bytes = NumAllocatedCells(pmap->red,
+ pmap->pVisual->ColormapEntries) * 9;
+ }
+ bytes += sz_xLbxGrabCmapReply + 1;
+ reply = (xLbxGrabCmapReply *) xalloc (bytes);
+ bzero (reply, sz_xLbxGrabCmapReply);
+
+ if (smartGrab)
+ {
+ reply->flags = LBX_SMART_GRAB;
+ reply->length = 0;
+ }
+ else
+ {
+ GetAllocatedCells (pmap, &reply->flags,
+ (CARD8 *) reply + sz_xLbxGrabCmapReplyHdr, &bytes);
+ if (bytes <= (sz_xLbxGrabCmapReply - sz_xLbxGrabCmapReplyHdr))
+ reply->length = 0;
+ else
+ reply->length = (sz_xLbxGrabCmapReplyHdr +
+ bytes - sz_xLbxGrabCmapReply + 3) >> 2;
+ }
+
+ reply->type = X_Reply;
+ reply->sequenceNumber = client->sequence;
+
+ bytes = sz_xLbxGrabCmapReply + (reply->length << 2);
+
+ if (client->swapped)
+ {
+ register char n;
+
+ swaps (&reply->sequenceNumber, n);
+ swapl (&reply->length, n);
+ }
+
+ WriteToClient (client, bytes, (char *)reply);
+
+ xfree (reply);
+
+ return (client->noClientException);
+}
+
+static int
+LbxUnstallClient(pointer data,
+ XID id)
+{
+ LbxColormapPriv *cmapPriv = (LbxColormapPriv *)data;
+ LbxStalled **prev;
+ ClientPtr client;
+
+ for (prev = &cmapPriv->stalled_clients; *prev && (*prev)->id != id; )
+ prev = &(*prev)->next;
+ *prev = (*prev)->next;
+ client = clients[CLIENT_ID(id)];
+ if (!client->clientGone)
+ AttendClient(client);
+ return 0;
+}
+
+void
+LbxReleaseCmap(ColormapPtr pmap,
+ Bool smart)
+{
+ LbxColormapPriv *cmapPriv;
+ ColormapPtr *prev;
+
+ if (!pmap->devPrivates)
+ return;
+ cmapPriv = (LbxColormapPriv *)
+ (pmap->devPrivates[lbxColormapPrivIndex].ptr);
+ if (!cmapPriv || (cmapPriv->grab_status == CMAP_NOT_GRABBED))
+ return;
+
+ for (prev = &cmapPriv->grabber->grabbedCmaps; *prev && *prev != pmap; )
+ prev = &((LbxColormapPriv *)
+ (*prev)->devPrivates[lbxColormapPrivIndex].ptr)->next;
+ if (*prev == pmap)
+ *prev = cmapPriv->next;
+
+ while (cmapPriv->stalled_clients)
+ FreeResource(cmapPriv->stalled_clients->id, 0);
+
+ cmapPriv->grab_status = CMAP_NOT_GRABBED;
+ cmapPriv->last_grabber = smart ? cmapPriv->grabber->uid : 0;
+ cmapPriv->grabber = NULL;
+ cmapPriv->smart_grab = smart;
+}
+
+/*
+ * Handle a colormap release request from a proxy.
+ */
+
+int
+ProcLbxReleaseCmap(ClientPtr client)
+{
+ REQUEST(xLbxReleaseCmapReq);
+ ColormapPtr pmap;
+
+#ifdef COLOR_DEBUG
+ fprintf (stderr, "Got colormap release request, ");
+ fprintf (stderr, "seq = 0x%x, proxy = %d, client = %d, cmap = 0x%x\n",
+ client->sequence, LbxProxyID(client), client->index, stuff->cmap);
+#endif
+
+ pmap = (ColormapPtr) SecurityLookupIDByType (client, stuff->cmap,
+ RT_COLORMAP,
+ SecurityWriteAccess);
+
+ if (!pmap)
+ {
+ client->errorValue = stuff->cmap;
+ return BadColor;
+ }
+
+ if (LbxGrabbedByClient(client, pmap))
+ LbxReleaseCmap(pmap, TRUE);
+ return Success;
+}
+
+
+/*
+ * Handle an LbxAllocColor request. The proxy did the alloc and
+ * is telling the server what rgb and pixel value to use.
+ */
+
+int
+ProcLbxAllocColor(ClientPtr client)
+{
+ REQUEST(xLbxAllocColorReq);
+ ColormapPtr pmap;
+ CARD32 pixel = stuff->pixel;
+
+ REQUEST_SIZE_MATCH (xLbxAllocColorReq);
+ pmap = (ColormapPtr) SecurityLookupIDByType (client, stuff->cmap,
+ RT_COLORMAP,
+ SecurityWriteAccess);
+
+#ifdef COLOR_DEBUG
+ fprintf (stderr,
+ "Got LBX alloc color: seq = 0x%x, proxy = %d, client = %d\n",
+ client->sequence, LbxProxyID(client), client->index);
+ fprintf (stderr, " cmap = 0x%x, pixel = %d, rgb = (%d,%d,%d)\n",
+ stuff->cmap, stuff->pixel, stuff->red, stuff->green, stuff->blue);
+#endif
+
+ if (pmap)
+ {
+ int status;
+ if (!LbxGrabbedByClient(client, pmap))
+ return BadAccess;
+
+ status = AllocColor (pmap,
+ &stuff->red, &stuff->green, &stuff->blue,
+ &pixel, client->index);
+
+ if (status == Success && pixel != stuff->pixel)
+ {
+ /*
+ * Internal error - Proxy allocated different pixel from server
+ */
+#ifdef COLOR_DEBUG
+ fprintf(stderr, "got pixel %d (%d, %d, %d), expected %d\n",
+ pixel, stuff->red, stuff->green, stuff->blue, stuff->pixel);
+#endif
+ FreeColors (pmap, client->index, 1, &pixel, 0L);
+ return BadAlloc;
+ }
+
+ return status;
+ }
+ else
+ {
+ client->errorValue = stuff->cmap;
+ return (BadColor);
+ }
+}
+
+
+/*
+ * The proxy sends an LbxIncrementPixel request when it short circuits
+ * an AllocColor. The server must bump up the reference count the
+ * specified amount.
+ */
+
+int
+ProcLbxIncrementPixel(ClientPtr client)
+{
+ REQUEST(xLbxIncrementPixelReq);
+ ColormapPtr pmap;
+ EntryPtr pent;
+ Pixel pixel;
+ unsigned short red, green, blue;
+ VisualPtr pVisual;
+ int status;
+
+#ifdef COLOR_DEBUG
+ fprintf (stderr,
+ "Got LBX increment pixel: seq = 0x%x, proxy = %d, client = %d\n",
+ client->sequence, LbxProxyID(client), client->index);
+ fprintf (stderr, " cmap = 0x%x, pixel = %d\n",
+ stuff->cmap, stuff->pixel);
+#endif
+
+ /*
+ * Looks up the color associated with the pixel, and then call
+ * AllocColor() - a bit round-about, but it should work.
+ */
+
+ pmap = (ColormapPtr) SecurityLookupIDByType(client, stuff->cmap,
+ RT_COLORMAP,
+ SecurityWriteAccess);
+ if (!pmap) {
+ client->errorValue = stuff->cmap;
+ return BadColor;
+ }
+
+ pixel = stuff->pixel;
+
+ switch (pmap->class) {
+ case StaticColor:
+ case StaticGray:
+ red = pmap->red[pixel].co.local.red;
+ green = pmap->red[pixel].co.local.green;
+ blue = pmap->red[pixel].co.local.blue;
+ break;
+ case GrayScale:
+ case PseudoColor:
+ pent = pmap->red + pixel;
+ red = pent->co.local.red;
+ green = pent->co.local.green;
+ blue = pent->co.local.blue;
+ break;
+ default:
+ pVisual = pmap->pVisual;
+ red = pmap->red[(pixel & pVisual->redMask) >> pVisual->offsetRed].co.local.red;
+ green = pmap->green[(pixel & pVisual->greenMask) >> pVisual->offsetGreen].co.local.green;
+ blue = pmap->blue[(pixel & pVisual->blueMask) >> pVisual->offsetBlue].co.local.blue;
+ break;
+ }
+
+ status = AllocColor(pmap, &red, &green, &blue, &pixel, client->index);
+
+ if (status == Success && pixel != stuff->pixel)
+ {
+ /*
+ * Internal error - Proxy allocated different pixel from server
+ */
+#ifdef COLOR_DEBUG
+ fprintf(stderr, "got pixel %d, expected %d\n", pixel, stuff->pixel);
+#endif
+ FreeColors (pmap, client->index, 1, &pixel, 0L);
+ return BadAlloc;
+ }
+
+ return status;
+}
diff --git a/nx-X11/programs/Xserver/lbx/lbxdata.h b/nx-X11/programs/Xserver/lbx/lbxdata.h
new file mode 100644
index 000000000..b577f6e50
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/lbxdata.h
@@ -0,0 +1,48 @@
+/* $Xorg: lbxdata.h,v 1.3 2000/08/17 19:53:31 cpqbld Exp $ */
+/*
+ * Copyright 1994 Network Computing Devices, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name Network Computing Devices, Inc. not be
+ * used in advertising or publicity pertaining to distribution of this
+ * software without specific, written prior permission.
+ *
+ * THIS SOFTWARE IS PROVIDED `AS-IS'. NETWORK COMPUTING DEVICES, INC.,
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
+ * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL NETWORK
+ * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
+ * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
+ * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
+ * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _LBXDATA_H_
+#define _LBXDATA_H_
+#define NEED_REPLIES
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#define _XLBX_SERVER_
+#include <X11/extensions/lbxstr.h>
+#include "dixfontstr.h"
+
+extern int lbx_font_private;
+
+typedef struct _fonttaginfo {
+ XID tid;
+ FontPtr pfont;
+ unsigned long size;
+ int compression;
+ xLbxFontInfo *fontinfo;
+} FontTagInfoRec, *FontTagInfoPtr;
+
+#endif /* _LBXDATA_H_ */
diff --git a/nx-X11/programs/Xserver/lbx/lbxdix.c b/nx-X11/programs/Xserver/lbx/lbxdix.c
new file mode 100644
index 000000000..e2a1a7adc
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/lbxdix.c
@@ -0,0 +1,869 @@
+/* $Xorg: lbxdix.c,v 1.4 2001/02/09 02:05:16 xorgcvs Exp $ */
+/*
+
+Copyright 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * Copyright 1993 Network Computing Devices, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name Network Computing Devices, Inc. not be
+ * used in advertising or publicity pertaining to distribution of this
+ * software without specific, written prior permission.
+ *
+ * THIS SOFTWARE IS PROVIDED `AS-IS'. NETWORK COMPUTING DEVICES, INC.,
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
+ * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL NETWORK
+ * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
+ * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
+ * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
+ * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxdix.c,v 1.7 2001/08/23 14:46:57 alanh Exp $ */
+
+/* various bits of DIX-level mangling */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <sys/types.h>
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "inputstr.h"
+#include "servermd.h"
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "propertyst.h"
+#define _XLBX_SERVER_
+#include <X11/extensions/lbxstr.h>
+#include "lbxserve.h"
+#include "lbxtags.h"
+#include "lbxdata.h"
+#include <X11/Xfuncproto.h>
+#ifdef XAPPGROUP
+#include <X11/extensions/Xagsrv.h>
+#endif
+#include "swaprep.h"
+
+int lbx_font_private = -1;
+
+void
+LbxDixInit(void)
+{
+ TagInit();
+ lbx_font_private = AllocateFontPrivateIndex();
+}
+
+/* ARGSUSED */
+void
+LbxAllowMotion(ClientPtr client,
+ int num)
+{
+ LbxProxyPtr proxy = LbxProxy(client);
+ proxy->motion_allowed_events += num;
+}
+
+extern xConnSetupPrefix connSetupPrefix;
+extern char *ConnectionInfo;
+extern int connBlockScreenStart;
+
+int
+LbxSendConnSetup(ClientPtr client,
+ char *reason)
+{
+ int dlength;
+ int i, ndex, lim, wndex;
+ CARD32 dataBuf[16];
+ xLbxConnSetupPrefix csp;
+ NewClientInfoRec nci;
+ LbxProxyPtr proxy = LbxProxy(client);
+
+ if (reason) {
+ SendConnSetup(client, reason);
+ LbxForceOutput(proxy); /* expedient to avoid another state variable */
+ return (client->noClientException);
+ }
+
+ IncrementClientCount();
+
+ client->requestVector = client->swapped ? SwappedProcVector : ProcVector;
+ client->sequence = 0;
+ dataBuf[0] = client->clientAsMask;
+
+ csp.success = TRUE;
+ csp.majorVersion = connSetupPrefix.majorVersion;
+ csp.minorVersion = connSetupPrefix.minorVersion;
+ csp.tag = 0;
+#ifdef XAPPGROUP
+ if (!client->appgroup) {
+#endif
+ csp.changeType = 1; /* LbxNormalDeltas */
+ csp.length = 2 + /* tag + resource-id-base */
+ screenInfo.numScreens; /* input-mask per screen */
+ wndex = 0; ndex = 1; lim = screenInfo.numScreens;
+#ifdef XAPPGROUP
+ } else {
+ csp.changeType = 2; /* LbxAppGroupDeltas */
+ csp.length = 7 + /* tag, res-id-base, root, visual, colormap, b&w-pix */
+ 1 + screenInfo.numScreens - screenInfo.numVideoScreens;
+ XagGetDeltaInfo (client, &dataBuf[1]);
+ for (i = 0; i < MAXSCREENS; i++) {
+ if ((CARD32) WindowTable[i]->drawable.id == dataBuf[1]) {
+ dataBuf[6] = WindowTable[i]->eventMask | wOtherEventMasks(WindowTable[i]);
+ break;
+ }
+ }
+ wndex = screenInfo.numVideoScreens;
+ ndex = 7;
+ lim = screenInfo.numScreens - screenInfo.numVideoScreens;
+ }
+#endif
+ for (i = 0; i < lim; i++, ndex++, wndex++) {
+ dataBuf[ndex] =
+ WindowTable[wndex]->eventMask | wOtherEventMasks(WindowTable[wndex]);
+ }
+ dlength = (csp.length - 1) << 2;
+
+ if (LbxProxyClient(proxy)->swapped) {
+ swaps(&csp.length, i);
+ }
+
+ if (client->swapped) {
+ LbxWriteSConnSetupPrefix(client, &csp);
+ SwapLongs(dataBuf, (1 + screenInfo.numScreens));
+ WriteToClient(client, dlength, (pointer) dataBuf);
+ } else {
+ WriteToClient(client, sizeof(xLbxConnSetupPrefix), (char *) &csp);
+ WriteToClient(client, dlength, (pointer) dataBuf);
+ }
+
+ LbxForceOutput(proxy); /* expedient to avoid another state variable */
+ client->clientState = ClientStateRunning;
+ if (ClientStateCallback) {
+ if (LbxProxyClient(proxy)->swapped != client->swapped) {
+ swaps(&csp.length, i);
+ }
+ nci.client = client;
+ nci.prefix = (xConnSetupPrefix*) &csp;
+ nci.setup = (xConnSetup *) ConnectionInfo;
+ CallCallbacks(&ClientStateCallback, (pointer) &nci);
+ }
+
+ return client->noClientException;
+}
+
+static XID modifier_map_tag;
+
+int
+LbxGetModifierMapping(ClientPtr client)
+{
+ TagData td;
+ pointer tagdata;
+ xLbxGetModifierMappingReply rep;
+ register KeyClassPtr keyc = inputInfo.keyboard->key;
+ int dlength = keyc->maxKeysPerModifier << 3;
+ Bool tag_known = FALSE,
+ send_data;
+ int n;
+
+ if (!modifier_map_tag) {
+ tagdata = (pointer) keyc->modifierKeyMap;
+ TagSaveTag(LbxTagTypeModmap, dlength, tagdata, &modifier_map_tag);
+ } else {
+ td = TagGetTag(modifier_map_tag);
+ tagdata = td->tdata;
+ tag_known = TagProxyMarked(modifier_map_tag, LbxProxyID(client));
+ }
+ if (modifier_map_tag)
+ TagMarkProxy(modifier_map_tag, LbxProxyID(client));
+
+ send_data = (!modifier_map_tag || !tag_known);
+
+ rep.type = X_Reply;
+ rep.keyspermod = keyc->maxKeysPerModifier;
+ rep.sequenceNumber = client->sequence;
+ rep.tag = modifier_map_tag;
+ rep.pad0 = rep.pad1 = rep.pad2 = rep.pad3 = rep.pad4 = 0;
+
+ if (send_data)
+ rep.length = dlength >> 2;
+ else
+ rep.length = 0;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.tag, n);
+ }
+ WriteToClient(client, sizeof(xLbxGetModifierMappingReply), (char *)&rep);
+
+ if (send_data)
+ WriteToClient(client, dlength, (char *) tagdata);
+
+ return client->noClientException;
+}
+
+void
+LbxFlushModifierMapTag(void)
+{
+
+ if (modifier_map_tag)
+ TagDeleteTag(modifier_map_tag);
+}
+
+static XID keyboard_map_tag;
+
+int
+LbxGetKeyboardMapping(ClientPtr client)
+{
+ TagData td;
+ pointer tagdata;
+ xLbxGetKeyboardMappingReply rep;
+
+ REQUEST(xLbxGetKeyboardMappingReq);
+ KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms;
+ int dlength;
+ Bool tag_known = FALSE,
+ send_data;
+ int n;
+
+ REQUEST_SIZE_MATCH(xLbxGetKeyboardMappingReq);
+
+ if ((stuff->firstKeyCode < curKeySyms->minKeyCode) ||
+ (stuff->firstKeyCode > curKeySyms->maxKeyCode)) {
+ client->errorValue = stuff->firstKeyCode;
+ return BadValue;
+ }
+ if (stuff->firstKeyCode + stuff->count > curKeySyms->maxKeyCode + 1) {
+ client->errorValue = stuff->count;
+ return BadValue;
+ }
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.keysperkeycode = curKeySyms->mapWidth;
+ /* length is a count of 4 byte quantities and KeySyms are 4 bytes */
+
+ if (!keyboard_map_tag) {
+ tagdata = (pointer) &curKeySyms->map[(stuff->firstKeyCode -
+ curKeySyms->minKeyCode) * curKeySyms->mapWidth];
+ dlength = (curKeySyms->mapWidth * stuff->count);
+ TagSaveTag(LbxTagTypeKeymap, dlength, tagdata, &keyboard_map_tag);
+ } else {
+ td = TagGetTag(keyboard_map_tag);
+ tagdata = td->tdata;
+ tag_known = TagProxyMarked(keyboard_map_tag, LbxProxyID(client));
+ }
+ if (keyboard_map_tag)
+ TagMarkProxy(keyboard_map_tag, LbxProxyID(client));
+
+ send_data = (!keyboard_map_tag || !tag_known);
+ rep.type = X_Reply;
+ rep.keysperkeycode = curKeySyms->mapWidth;
+ rep.sequenceNumber = client->sequence;
+ rep.tag = keyboard_map_tag;
+ rep.pad0 = rep.pad1 = rep.pad2 = rep.pad3 = rep.pad4 = 0;
+
+ if (send_data)
+ rep.length = (curKeySyms->mapWidth * stuff->count);
+ else
+ rep.length = 0;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.tag, n);
+ }
+ WriteToClient(client, sizeof(xLbxGetKeyboardMappingReply), (char *)&rep);
+
+ if (send_data) {
+ client->pSwapReplyFunc = (ReplySwapPtr)CopySwap32Write;
+ WriteSwappedDataToClient(client,
+ curKeySyms->mapWidth * stuff->count * sizeof(KeySym),
+ &curKeySyms->map[(stuff->firstKeyCode - curKeySyms->minKeyCode) *
+ curKeySyms->mapWidth]);
+ }
+ return client->noClientException;
+}
+
+void
+LbxFlushKeyboardMapTag(void)
+{
+ if (keyboard_map_tag)
+ TagDeleteTag(keyboard_map_tag);
+}
+
+/* counts number of bits needed to hold value */
+static int
+_bitsize(int val)
+{
+ int bits = 1; /* always need one for sign bit */
+
+ if (val == 0)
+ return (bits);
+
+ if (val < 0) {
+ val = -val;
+ }
+ while (val) {
+ bits++;
+ val >>= 1;
+ }
+
+ return bits;
+
+}
+
+/*
+ * squashes the font (if possible), returning the new length and
+ * a pointer to the new data (which has been allocated). if it can't
+ * squish, it just returns a 0 and the data is sent in raw form.
+ */
+int _lbx_fi_junklen = sizeof(BYTE) * 2 + sizeof(CARD16) + sizeof(CARD32);
+
+static int
+squish_font_info(xQueryFontReply *qfr,
+ int rlen,
+ xLbxFontInfo **sqrep)
+{
+ int len,
+ hlen;
+ xLbxFontInfo *new;
+ xCharInfo *minb,
+ *maxb,
+ *ci,
+ bbox;
+ int i;
+ char *t;
+ xLbxCharInfo *chars;
+ int num_chars;
+
+ num_chars = qfr->nCharInfos;
+
+ if (num_chars == 0)
+ return 0;
+
+ minb = &qfr->minBounds;
+ maxb = &qfr->maxBounds;
+ /*
+ * first do the quick check -- if the attribute fields aren't all the
+ * same, punt
+ */
+
+ if (minb->attributes != maxb->attributes)
+ return 0;
+
+#define compute(field) \
+ bbox.field = max(_bitsize(minb->field), _bitsize(maxb->field))
+
+ compute(characterWidth);
+ compute(leftSideBearing);
+ compute(rightSideBearing);
+ compute(ascent);
+ compute(descent);
+
+#undef compute
+
+ /* make sure it fits */
+ if (!((bbox.characterWidth <= LBX_WIDTH_BITS) &&
+ (bbox.leftSideBearing <= LBX_LEFT_BITS) &&
+ (bbox.rightSideBearing <= LBX_RIGHT_BITS) &&
+ (bbox.ascent <= LBX_ASCENT_BITS) &&
+ (bbox.descent <= LBX_DESCENT_BITS))) {
+ return 0;
+ }
+
+ hlen = sizeof(xLbxFontInfo) + qfr->nFontProps * sizeof(xFontProp);
+
+ len = hlen + (num_chars * sizeof(xLbxCharInfo));
+
+ new = (xLbxFontInfo *) xalloc(len);
+ if (!new)
+ return 0;
+
+ /* gross hack to avoid copying all the fields */
+ t = (char *) qfr;
+ t += _lbx_fi_junklen;
+
+ /* copy all but the char infos */
+ memcpy((char *) new, (char *) t, hlen);
+
+ t = (char *) new;
+ t += hlen;
+ chars = (xLbxCharInfo *) t;
+
+ t = (char *) qfr;
+ t += sizeof(xQueryFontReply) + qfr->nFontProps * sizeof(xFontProp);
+ ci = (xCharInfo *) t;
+
+ /* now copy & pack the charinfos */
+ for (i = 0; i < num_chars; i++, chars++, ci++) {
+ chars->metrics = 0;
+ chars->metrics |= (LBX_MASK_BITS(ci->characterWidth, LBX_WIDTH_BITS)
+ << LBX_WIDTH_SHIFT);
+ chars->metrics |= (LBX_MASK_BITS(ci->leftSideBearing, LBX_LEFT_BITS)
+ << LBX_LEFT_SHIFT);
+ chars->metrics |= (LBX_MASK_BITS(ci->rightSideBearing, LBX_RIGHT_BITS)
+ << LBX_RIGHT_SHIFT);
+ chars->metrics |= (LBX_MASK_BITS(ci->ascent, LBX_ASCENT_BITS)
+ << LBX_ASCENT_SHIFT);
+ chars->metrics |= (LBX_MASK_BITS(ci->descent, LBX_DESCENT_BITS)
+ << LBX_DESCENT_SHIFT);
+ }
+
+ *sqrep = new;
+ return len;
+}
+
+int
+LbxQueryFont(ClientPtr client)
+{
+ xQueryFontReply *reply;
+ xLbxQueryFontReply lbxrep;
+ FontPtr pFont;
+ register GC *pGC;
+ Bool send_data = FALSE;
+ Bool free_data = FALSE;
+ int rlength = 0;
+ FontTagInfoPtr ftip;
+ int sqlen = 0;
+ xLbxFontInfo *sqrep,
+ *sreply = NULL;
+
+ REQUEST(xLbxQueryFontReq);
+
+ REQUEST_SIZE_MATCH(xLbxQueryFontReq);
+
+ client->errorValue = stuff->fid; /* EITHER font or gc */
+ pFont = (FontPtr) SecurityLookupIDByType(client, stuff->fid, RT_FONT,
+ SecurityReadAccess);
+ if (!pFont) {
+ /* can't use VERIFY_GC because it might return BadGC */
+ pGC = (GC *) SecurityLookupIDByType(client, stuff->fid, RT_GC,
+ SecurityReadAccess);
+ if (!pGC || !pGC->font) { /* catch a non-existent builtin font */
+ client->errorValue = stuff->fid;
+ return (BadFont); /* procotol spec says only error is BadFont */
+ }
+ pFont = pGC->font;
+ }
+
+ /* get tag (if any) */
+ ftip = (FontTagInfoPtr) FontGetPrivate(pFont, lbx_font_private);
+
+ if (!ftip) {
+ xCharInfo *pmax = FONTINKMAX(pFont);
+ xCharInfo *pmin = FONTINKMIN(pFont);
+ int nprotoxcistructs;
+
+ nprotoxcistructs = (
+ pmax->rightSideBearing == pmin->rightSideBearing &&
+ pmax->leftSideBearing == pmin->leftSideBearing &&
+ pmax->descent == pmin->descent &&
+ pmax->ascent == pmin->ascent &&
+ pmax->characterWidth == pmin->characterWidth) ?
+ 0 : N2dChars(pFont);
+
+ rlength = sizeof(xQueryFontReply) +
+ FONTINFONPROPS(FONTCHARSET(pFont)) * sizeof(xFontProp) +
+ nprotoxcistructs * sizeof(xCharInfo);
+ reply = (xQueryFontReply *) xalloc(rlength);
+ if (!reply) {
+ return (BadAlloc);
+ }
+ free_data = TRUE;
+ send_data = TRUE;
+ QueryFont(pFont, reply, nprotoxcistructs);
+
+ sqlen = squish_font_info(reply, rlength, &sqrep);
+ if (!sqlen) { /* if it failed to squish, send it raw */
+ char *t;
+
+ lbxrep.compression = 0;
+
+ sqlen = rlength - _lbx_fi_junklen;
+ t = (char *) reply;
+ sqrep = (xLbxFontInfo *) (t + _lbx_fi_junklen);
+ } else {
+ lbxrep.compression = 1;
+ xfree(reply); /* no longer needed */
+ }
+ } else { /* just get data from tag */
+ sqrep = ftip->fontinfo;
+ sqlen = ftip->size;
+ lbxrep.compression = ftip->compression;
+ }
+
+ if (!ftip) {
+ /* data allocation is done when font is first queried */
+ ftip = (FontTagInfoPtr) xalloc(sizeof(FontTagInfoRec));
+ if (ftip &&
+ TagSaveTag(LbxTagTypeFont, sqlen, (pointer) ftip, &ftip->tid)) {
+ FontSetPrivate(pFont, lbx_font_private, (pointer) ftip);
+ ftip->pfont = pFont;
+ ftip->size = sqlen;
+ ftip->fontinfo = sqrep;
+ ftip->compression = lbxrep.compression;
+ free_data = FALSE;
+ } else {
+ xfree(ftip);
+ }
+ }
+ if (ftip) {
+ if (!TagProxyMarked(ftip->tid, LbxProxyID(client)))
+ send_data = TRUE;
+ TagMarkProxy(ftip->tid, LbxProxyID(client));
+ lbxrep.tag = ftip->tid;
+ } else {
+ lbxrep.tag = 0;
+ send_data = TRUE;
+ }
+
+ lbxrep.type = X_Reply;
+ lbxrep.sequenceNumber = client->sequence;
+ lbxrep.pad0 = lbxrep.pad1 = lbxrep.pad2 = lbxrep.pad3 = lbxrep.pad4 = 0;
+
+ if (send_data)
+ lbxrep.length = sqlen >> 2;
+ else
+ lbxrep.length = 0;
+
+ if (client->swapped) {
+ int n;
+
+ swaps(&lbxrep.sequenceNumber, n);
+ swapl(&lbxrep.length, n);
+ swapl(&lbxrep.tag, n);
+ sreply = (xLbxFontInfo *) ALLOCATE_LOCAL(sqlen);
+ if (!sreply)
+ return BadAlloc;
+ memcpy((char *) sreply, (char *) sqrep, sqlen);
+ LbxSwapFontInfo(sreply, lbxrep.compression);
+ sqrep = sreply;
+ }
+ WriteToClient(client, sizeof(xLbxQueryFontReply), (char *) &lbxrep);
+ if (send_data)
+ WriteToClient(client, sqlen, (char *)sqrep);
+ if (free_data)
+ xfree(sqrep);
+ if (sreply)
+ DEALLOCATE_LOCAL(sreply);
+ return (client->noClientException);
+}
+
+void
+LbxFreeFontTag(FontPtr pfont)
+{
+ FontTagInfoPtr ftip;
+
+ ftip = (FontTagInfoPtr) FontGetPrivate(pfont, lbx_font_private);
+ if (ftip)
+ TagDeleteTag(ftip->tid);
+}
+
+int
+LbxInvalidateTag(ClientPtr client,
+ XID tag)
+{
+ TagClearProxy(tag, LbxProxyID(client));
+ return client->noClientException;
+}
+
+void
+LbxSendInvalidateTag(ClientPtr client,
+ XID tag,
+ int tagtype)
+{
+ xLbxInvalidateTagEvent ev;
+ int n;
+
+ ev.type = LbxEventCode;
+ ev.lbxType = LbxInvalidateTagEvent;
+ ev.sequenceNumber = client->sequence;
+ ev.tag = tag;
+ ev.tagType = tagtype;
+ ev.pad1 = ev.pad2 = ev.pad3 = ev.pad4 = ev.pad5 = 0;
+
+ if (client->swapped) {
+ swaps(&ev.sequenceNumber, n);
+ swapl(&ev.tag, n);
+ swapl(&ev.tagType, n);
+ }
+ DBG(DBG_CLIENT, (stderr, "Invalidating tag %d\n", tag));
+ WriteToClient(client, sizeof(xLbxInvalidateTagEvent), (char *) &ev);
+ LbxForceOutput(LbxProxy(client));
+}
+
+static void
+LbxSendSendTagData(int pid,
+ XID tag,
+ int tagtype)
+{
+ xLbxSendTagDataEvent ev;
+ int n;
+ LbxProxyPtr proxy;
+ ClientPtr client;
+ LbxClientPtr lbxcp;
+
+ proxy = LbxPidToProxy(pid);
+ lbxcp = (proxy != NULL) ? proxy->lbxClients[0] : NULL;
+ if (lbxcp && (client = lbxcp->client)) {
+ ev.type = LbxEventCode;
+ ev.lbxType = LbxSendTagDataEvent;
+ ev.sequenceNumber = client->sequence;
+ ev.tag = tag;
+ ev.tagType = tagtype;
+ ev.pad1 = ev.pad2 = ev.pad3 = ev.pad4 = ev.pad5 = 0;
+
+ if (client->swapped) {
+ swaps(&ev.sequenceNumber, n);
+ swapl(&ev.tag, n);
+ swapl(&ev.tagType, n);
+ }
+ DBG(DBG_CLIENT, (stderr, "Requesting tag %d\n", tag));
+ WriteToClient(client, sizeof(xLbxSendTagDataEvent), (char *) &ev);
+ LbxForceOutput(proxy);
+ }
+}
+
+/*
+ * keep track of clients stalled waiting for tags to come back from
+ * a proxy. since multiple clinets can be waiting for the same tag,
+ * we have to keep a list of all of them.
+ */
+
+typedef struct _sendtagq {
+ XID tag;
+ int num_stalled;
+ ClientPtr *stalled_clients;
+ struct _sendtagq *next;
+} SendTagQRec, *SendTagQPtr;
+
+static SendTagQPtr queried_tags = NULL;
+
+#define LbxSendTagFailed -1
+#define LbxSendTagSendIt 0
+#define LbxSendTagAlreadySent 1
+
+static Bool
+LbxQueueSendTag(ClientPtr client,
+ XID tag)
+{
+ SendTagQPtr stqp, *prev, new;
+ ClientPtr *newlist;
+
+
+ /* see if we're asking for one already in the pipeline */
+ for (prev = &queried_tags; (stqp = *prev); prev = &stqp->next) {
+ if (stqp->tag == tag) {
+ /* add new client to list */
+ newlist = (ClientPtr *) xrealloc(stqp->stalled_clients,
+ (sizeof(ClientPtr) * (stqp->num_stalled + 1)));
+ if (!newlist)
+ return LbxSendTagFailed;
+ newlist[stqp->num_stalled++] = client;
+ stqp->stalled_clients = newlist;
+ DBG(DBG_CLIENT, (stderr, "Additional client requesting tag %d\n", tag));
+ return LbxSendTagAlreadySent;
+ }
+ }
+
+ /* make new one */
+ new = (SendTagQPtr) xalloc(sizeof(SendTagQRec));
+ newlist = (ClientPtr *) xalloc(sizeof(ClientPtr));
+ if (!new || !newlist) {
+ xfree(new);
+ xfree(newlist);
+ return LbxSendTagFailed;
+ }
+ *newlist = client;
+ new->stalled_clients = newlist;
+ new->num_stalled = 1;
+ new->tag = tag;
+ new->next = NULL;
+
+ /* stick on end of list */
+ *prev = new;
+ return LbxSendTagSendIt;
+}
+
+static SendTagQPtr
+LbxFindQTag(XID tag)
+{
+ SendTagQPtr stqp;
+
+ for (stqp = queried_tags; stqp; stqp = stqp->next) {
+ if (stqp->tag == tag)
+ return stqp;
+ }
+ return NULL;
+}
+
+static void
+LbxFreeQTag(SendTagQPtr stqp)
+{
+ xfree(stqp->stalled_clients);
+ xfree(stqp);
+}
+
+static void
+LbxRemoveQTag(XID tag)
+{
+ SendTagQPtr stqp, *prev;
+
+ for (prev = &queried_tags; (stqp = *prev); prev = &stqp->next) {
+ if (stqp->tag == tag) {
+ *prev = stqp->next;
+ LbxFreeQTag(stqp);
+ return;
+ }
+ }
+}
+
+Bool
+LbxFlushQTag(XID tag)
+{
+ SendTagQPtr stqp;
+ ClientPtr *cp;
+
+ stqp = LbxFindQTag(tag);
+ if (!stqp)
+ return FALSE;
+ for (cp = stqp->stalled_clients; --stqp->num_stalled >= 0; cp++)
+ AttendClient(*cp);
+ LbxRemoveQTag(tag);
+ return TRUE;
+}
+
+void
+ProcessQTagZombies(void)
+{
+ SendTagQPtr stqp;
+ ClientPtr *out, *in;
+ int i;
+
+ for (stqp = queried_tags; stqp; stqp = stqp->next) {
+ out = stqp->stalled_clients;
+ for (in = out, i = stqp->num_stalled; --i >= 0; in++) {
+ if ((*in)->clientGone)
+ --stqp->num_stalled;
+ else
+ *out++ = *in;
+ }
+ }
+}
+
+/*
+ * server sends this
+ */
+
+void
+LbxQueryTagData(ClientPtr client,
+ int owner_pid,
+ XID tag,
+ int tagtype)
+{
+ /* save the info and the client being stalled */
+ if (LbxQueueSendTag(client, tag) == LbxSendTagSendIt)
+ LbxSendSendTagData(owner_pid, tag, tagtype);
+}
+
+/*
+ * server recieves this
+ */
+int
+LbxTagData(ClientPtr client,
+ XID tag,
+ unsigned long len,
+ pointer data)
+{
+ TagData td;
+ PropertyPtr pProp;
+
+ td = TagGetTag(tag);
+ if (!td || td->data_type != LbxTagTypeProperty)
+ return Success;
+ if (!td->global) {
+ /* somebody changed contents while we were querying */
+ TagDeleteTag(tag);
+ return Success;
+ }
+ LbxFlushQTag(tag);
+ pProp = (PropertyPtr) td->tdata;
+ if (pProp->tag_id != tag || pProp->owner_pid != LbxProxyID(client))
+ return Success;
+ pProp->owner_pid = 0;
+ if (len != td->size)
+ pProp->size = len / (pProp->format >> 3);
+ pProp->data = xrealloc(pProp->data, len);
+ if (!pProp->data) {
+ pProp->size = 0;
+ return Success;
+ }
+ if (client->swapped) {
+ switch (pProp->format) {
+ case 32:
+ SwapLongs((CARD32 *) data, len >> 2);
+ break;
+ case 16:
+ SwapShorts((short *) data, len >> 1);
+ break;
+ default:
+ break;
+ }
+ }
+ memmove((char *) pProp->data, (char *) data, len);
+ return Success;
+}
+
+/* when server resets, need to reset global tags */
+void
+LbxResetTags(void)
+{
+ SendTagQPtr stqp;
+
+ modifier_map_tag = 0;
+ keyboard_map_tag = 0;
+
+ /* clean out any pending tag requests */
+ while ((stqp = queried_tags)) {
+ queried_tags = stqp->next;
+ LbxFreeQTag(stqp);
+ }
+}
diff --git a/nx-X11/programs/Xserver/lbx/lbxexts.c b/nx-X11/programs/Xserver/lbx/lbxexts.c
new file mode 100644
index 000000000..1086b4bc5
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/lbxexts.c
@@ -0,0 +1,275 @@
+/* $Xorg: lbxexts.c,v 1.3 2000/08/17 19:53:31 cpqbld Exp $ */
+/*
+ * Copyright 1994 Network Computing Devices, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name Network Computing Devices, Inc. not be
+ * used in advertising or publicity pertaining to distribution of this
+ * software without specific, written prior permission.
+ *
+ * THIS SOFTWARE IS PROVIDED `AS-IS'. NETWORK COMPUTING DEVICES, INC.,
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
+ * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL NETWORK
+ * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
+ * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
+ * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
+ * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxexts.c,v 1.2 2000/05/18 23:46:24 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "colormapst.h"
+#include "propertyst.h"
+#define _XLBX_SERVER_
+#include <X11/extensions/lbxstr.h>
+#include "lbxserve.h"
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+
+typedef struct _lbxext {
+ char *name;
+ char **aliases;
+ int num_aliases;
+ int idx;
+ int opcode;
+ int ev_base;
+ int err_base;
+ int num_reqs;
+ CARD8 *rep_mask;
+ CARD8 *ev_mask;
+#ifdef XCSECURITY
+ Bool secure;
+#endif
+} LbxExtensionEntry;
+
+static LbxExtensionEntry **lbx_extensions = NULL;
+static int num_exts = 0;
+
+
+Bool
+LbxAddExtension(char *name,
+ int opcode,
+ int ev_base,
+ int err_base)
+{
+ int i;
+ LbxExtensionEntry *ext,
+ **newexts;
+
+ ext = (LbxExtensionEntry *) xalloc(sizeof(LbxExtensionEntry));
+ if (!ext)
+ return FALSE;
+ ext->name = (char *) xalloc(strlen(name) + 1);
+ ext->num_aliases = 0;
+ ext->aliases = (char **) NULL;
+ if (!ext->name) {
+ xfree(ext);
+ return FALSE;
+ }
+ strcpy(ext->name, name);
+ i = num_exts;
+ newexts = (LbxExtensionEntry **) xrealloc(lbx_extensions,
+ (i + 1) * sizeof(LbxExtensionEntry *));
+ if (!newexts) {
+ xfree(ext->name);
+ xfree(ext);
+ return FALSE;
+ }
+ num_exts++;
+ lbx_extensions = newexts;
+ lbx_extensions[i] = ext;
+ ext->idx = i;
+
+ ext->opcode = opcode;;
+ ext->ev_base = ev_base;;
+ ext->err_base = err_base;
+ ext->ev_mask = NULL;
+ ext->rep_mask = NULL;
+ ext->num_reqs = 0;
+#ifdef XCSECURITY
+ ext->secure = FALSE;
+#endif
+
+ return TRUE;
+}
+
+Bool
+LbxAddExtensionAlias(int idx,
+ char *alias)
+{
+ char *name;
+ char **aliases;
+ LbxExtensionEntry *ext = lbx_extensions[idx];
+
+ aliases = (char **) xrealloc(ext->aliases,
+ (ext->num_aliases + 1) * sizeof(char *));
+ if (!aliases)
+ return FALSE;
+ ext->aliases = aliases;
+ name = (char *) xalloc(strlen(alias) + 1);
+ if (!name)
+ return FALSE;
+ strcpy(name, alias);
+ ext->aliases[ext->num_aliases] = name;
+ ext->num_aliases++;
+ return TRUE;
+}
+
+static int
+LbxFindExtension(char *extname,
+ int len)
+{
+ int i, j;
+
+ for (i = 0; i < num_exts; i++) {
+ if ((strlen(lbx_extensions[i]->name) == len) &&
+ (strncmp(lbx_extensions[i]->name, extname, len) == 0))
+ return i;
+ for (j = lbx_extensions[i]->num_aliases; --j >= 0;) {
+ if ((strlen(lbx_extensions[i]->aliases[j]) == len) &&
+ (strncmp(lbx_extensions[i]->aliases[j], extname, len) == 0))
+ return i;
+ }
+ }
+ return -1;
+}
+
+void
+LbxDeclareExtensionSecurity(char *extname,
+ Bool secure)
+{
+#ifdef XCSECURITY
+ int i = LbxFindExtension(extname, strlen(extname));
+ if (i >= 0)
+ lbx_extensions[i]->secure = secure;
+#endif
+}
+
+Bool
+LbxRegisterExtensionGenerationMasks(int idx,
+ int num_reqs,
+ char *rep_mask,
+ char *ev_mask)
+{
+ LbxExtensionEntry *ext = lbx_extensions[idx];
+ CARD8 *nrm,
+ *nem;
+ int mlen = mlen = num_reqs / (8 * sizeof(CARD8)) + 1;
+
+ nrm = (CARD8 *) xalloc(sizeof(CARD8) * mlen);
+ nem = (CARD8 *) xalloc(sizeof(CARD8) * mlen);
+
+ if (!nrm || !nem) {
+ xfree(nrm);
+ xfree(nem);
+ return FALSE;
+ }
+ memcpy((char *) nrm, (char *) rep_mask, mlen);
+ memcpy((char *) nem, (char *) ev_mask, mlen);
+ ext->rep_mask = nrm;
+ ext->ev_mask = nem;
+ ext->num_reqs = num_reqs;
+
+ return TRUE;
+}
+
+int
+LbxQueryExtension(ClientPtr client,
+ char *ename,
+ int nlen)
+{
+ xLbxQueryExtensionReply rep;
+ int i;
+ int mlen = 0;
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.major_opcode = 0;
+ rep.present = FALSE;
+ rep.length = 0;
+ rep.pad0 = rep.pad1 = rep.pad2 = rep.pad3 = rep.pad4 = 0;
+
+ i = LbxFindExtension(ename, nlen);
+
+ if (i < 0
+#ifdef XCSECURITY
+ /* don't show insecure extensions to untrusted clients */
+ || (client->trustLevel == XSecurityClientUntrusted &&
+ !lbx_extensions[i]->secure)
+#endif
+ )
+ rep.present = FALSE;
+ else {
+ rep.present = TRUE;
+ rep.major_opcode = lbx_extensions[i]->opcode;
+ rep.first_event = lbx_extensions[i]->ev_base;
+ rep.first_error = lbx_extensions[i]->err_base;
+ rep.numReqs = lbx_extensions[i]->num_reqs;
+ if (lbx_extensions[i]->rep_mask) {
+ mlen = (lbx_extensions[i]->num_reqs + 7) >> 3;
+ rep.length = ((mlen + 3) >> 2) * 2;
+ }
+ }
+ if (client->swapped) {
+ char n;
+
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ }
+ WriteToClient(client, sizeof(xLbxQueryExtensionReply), (char *)&rep);
+ if (mlen) {
+ WriteToClient(client, mlen, (char *)lbx_extensions[i]->rep_mask);
+ WriteToClient(client, mlen, (char *)lbx_extensions[i]->ev_mask);
+ }
+ return Success;
+}
+
+void
+LbxCloseDownExtensions(void)
+{
+ int i,j;
+
+ for (i = 0; i < num_exts; i++) {
+ xfree(lbx_extensions[i]->name);
+ for (j = 0; j < lbx_extensions[i]->num_aliases; j++)
+ xfree(lbx_extensions[i]->aliases[j]);
+ xfree(lbx_extensions[i]->aliases);
+ xfree(lbx_extensions[i]->rep_mask);
+ xfree(lbx_extensions[i]->ev_mask);
+ xfree(lbx_extensions[i]);
+ }
+ xfree(lbx_extensions);
+ lbx_extensions = NULL;
+ num_exts = 0;
+
+}
+
+void
+LbxSetReqMask(CARD8 *mask,
+ int req,
+ Bool on)
+{
+ int mword = req / (8 * sizeof(CARD8));
+
+ req = req % (8 * sizeof(CARD8));
+ if (on) {
+ mask[mword] |= (1 << req);
+ } else {
+ mask[mword] &= ~(1 << req);
+ }
+}
diff --git a/nx-X11/programs/Xserver/lbx/lbxgfx.c b/nx-X11/programs/Xserver/lbx/lbxgfx.c
new file mode 100644
index 000000000..506859a20
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/lbxgfx.c
@@ -0,0 +1,854 @@
+/* $Xorg: lbxgfx.c,v 1.3 2000/08/17 19:53:31 cpqbld Exp $ */
+/*
+ * Copyright 1993 Network Computing Devices, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name Network Computing Devices, Inc. not be
+ * used in advertising or publicity pertaining to distribution of this
+ * software without specific, written prior permission.
+ *
+ * THIS SOFTWARE IS PROVIDED `AS-IS'. NETWORK COMPUTING DEVICES, INC.,
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
+ * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL NETWORK
+ * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
+ * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
+ * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
+ * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxgfx.c,v 1.3 2001/01/17 22:36:59 dawes Exp $ */
+
+/* various bits of DIX-level mangling */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <sys/types.h>
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "servermd.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#define _XLBX_SERVER_
+#include <X11/extensions/lbxstr.h>
+#include "lbxserve.h"
+#include "lbxtags.h"
+#include <X11/Xfuncproto.h>
+#include <X11/extensions/lbximage.h>
+#include "lbxsrvopts.h"
+
+#define DrawableCache(client) (LbxClient(client)->drawableCache)
+#define GContextCache(client) (LbxClient(client)->gcontextCache)
+
+static void
+push (XID cache[GFX_CACHE_SIZE],
+ XID xid)
+{
+ memmove (cache+1, cache, (GFX_CACHE_SIZE - 1) * sizeof (cache[0]));
+ cache[0] = xid;
+}
+
+static XID
+use (XID cache[GFX_CACHE_SIZE],
+ int i)
+{
+ XID tmp;
+
+ tmp = cache[i];
+ if (i != 0)
+ {
+ memmove (cache + 1, cache, i * sizeof (cache[0]));
+ cache[0] = tmp;
+ }
+ return tmp;
+}
+
+extern char *ConnectionInfo;
+
+static int
+LbxDecodeGFXCache(ClientPtr client,
+ CARD8 cacheEnts,
+ char *after,
+ Drawable *drawp,
+ GContext *gcp)
+{
+ int skip;
+ int dcache, gcache;
+
+ dcache = GFXdCacheEnt (cacheEnts);
+ gcache = GFXgCacheEnt (cacheEnts);
+ skip = 0;
+ if (dcache == GFXCacheNone)
+ {
+ memcpy (drawp, after, sizeof (Drawable));
+ push (DrawableCache(client), *drawp);
+ after += sizeof (Drawable);
+ skip += sizeof (Drawable);
+ }
+ else
+ *drawp = use (DrawableCache(client), dcache);
+ if (gcache == GFXCacheNone)
+ {
+ memcpy (gcp, after, sizeof (GContext));
+ push (GContextCache(client), *gcp);
+ skip += sizeof (GContext);
+ }
+ else
+ *gcp = use (GContextCache(client), gcache);
+ return skip;
+}
+
+static int
+LbxDecodeDrawableCache(ClientPtr client,
+ CARD8 cacheEnts,
+ char *after,
+ Drawable *drawp)
+{
+ int skip;
+ int dcache;
+
+ dcache = GFXdCacheEnt (cacheEnts);
+ skip = 0;
+ if (dcache == GFXCacheNone)
+ {
+ memcpy (drawp, after, sizeof (Drawable));
+ push (DrawableCache(client), *drawp);
+ after += sizeof (Drawable);
+ skip += sizeof (Drawable);
+ }
+ else
+ *drawp = use (DrawableCache(client), dcache);
+ return skip;
+}
+
+#ifdef notyet
+static int
+LbxDecodeGCCache(ClientPtr client,
+ CARD8 cacheEnts,
+ char *after,
+ GContext *gcp)
+{
+ int skip;
+ int gcache;
+
+ gcache = GFXgCacheEnt (cacheEnts);
+ skip = 0;
+ if (gcache == GFXCacheNone)
+ {
+ memcpy (gcp, after, sizeof (GContext));
+ push (GContextCache(client), *gcp);
+ after += sizeof (GContext);
+ skip += sizeof (GContext);
+ }
+ else
+ *gcp = use (GContextCache(client), gcache);
+ return skip;
+}
+#endif
+
+#define GFX_GET_DRAWABLE_AND_GC(type,in,len) {\
+ int skip; \
+ len = (client->req_len << 2) - SIZEOF(type); \
+ in = ((char *) stuff) + SIZEOF(type);\
+ skip = LbxDecodeGFXCache(client, stuff->cacheEnts, in, \
+ &drawable, &gc); \
+ in += skip; \
+ len -= skip; \
+}
+
+#define GFX_GET_DST_DRAWABLE_AND_GC(type,in,len) {\
+ int skip; \
+ len = (client->req_len << 2) - SIZEOF(type); \
+ in = ((char *) stuff) + SIZEOF(type);\
+ skip = LbxDecodeGFXCache(client, stuff->cacheEnts, in, \
+ &dstDrawable, &gc); \
+ in += skip; \
+ len -= skip; \
+}
+
+#define GFX_GET_SRC_DST_DRAWABLE_AND_GC(type, in, len) { \
+ int skip; \
+ len = (client->req_len << 2) - SIZEOF(type); \
+ in = ((char *) stuff) + SIZEOF(type); \
+ skip = LbxDecodeDrawableCache(client, stuff->srcCache, in, \
+ &srcDrawable); \
+ in += skip; \
+ len -= skip; \
+ skip = LbxDecodeGFXCache(client, stuff->cacheEnts, in, \
+ &dstDrawable, &gc); \
+ in += skip; \
+ len -= skip; \
+}
+
+#define GFX_GET_GC(type, in, len) { \
+ int skip; \
+ len = (client->req_len << 2) - SIZEOF(type); \
+ in = ((char *) stuff) + SIZEOF(type); \
+ skip = LbxDecodeGCCache(client, stuff->gcCache, in, &gc); \
+ in += skip; \
+ len -= skip; \
+}
+
+int
+LbxDecodePoly(ClientPtr client,
+ CARD8 xreqtype,
+ int (*decode_rtn)(char *, char *, short *))
+{
+ REQUEST(xLbxPolyPointReq);
+ char *in;
+ xPolyPointReq *xreq;
+ int len;
+ int retval;
+ Drawable drawable;
+ GContext gc;
+
+ GFX_GET_DRAWABLE_AND_GC(xLbxPolyPointReq, in, len);
+ if ((xreq = (xPolyPointReq *)
+ xalloc(sizeof(xPolyPointReq) + (len << 1))) == NULL)
+ return BadAlloc;
+ len = (*decode_rtn)(in, in + len - stuff->padBytes, (short *)(&xreq[1]));
+ xreq->reqType = xreqtype;
+ xreq->coordMode = 1;
+ xreq->drawable = drawable;
+ xreq->gc = gc;
+ xreq->length = client->req_len = (sizeof(xPolyPointReq) + len) >> 2;
+ client->requestBuffer = (pointer)xreq;
+
+ retval = (*ProcVector[xreqtype])(client);
+ xfree(xreq);
+ return retval;
+}
+
+int
+LbxDecodeFillPoly(ClientPtr client)
+{
+ REQUEST(xLbxFillPolyReq);
+ char *in;
+ xFillPolyReq *xreq;
+ int len;
+ int retval;
+ Drawable drawable;
+ GContext gc;
+
+ GFX_GET_DRAWABLE_AND_GC(xLbxFillPolyReq, in, len);
+ if ((xreq = (xFillPolyReq *)
+ xalloc(sizeof(xFillPolyReq) + (len << 1))) == NULL)
+ return BadAlloc;
+ len = LbxDecodePoints(in, in + len - stuff->padBytes, (short *) &xreq[1]);
+ xreq->reqType = X_FillPoly;
+ xreq->drawable = drawable;
+ xreq->gc = gc;
+ xreq->shape = stuff->shape;
+ xreq->coordMode = 1;
+ xreq->length = client->req_len = (sizeof(xFillPolyReq) + len) >> 2;
+ client->requestBuffer = (pointer)xreq;
+
+ retval = (*ProcVector[X_FillPoly])(client);
+ xfree(xreq);
+ return retval;
+}
+
+/*
+ * Routines for decoding line drawing requests
+ */
+
+#define DECODE_PSHORT(in, val) \
+ if ((*(in) & 0xf0) != 0xf0) \
+ (val) = *(CARD8 *)(in)++; \
+ else { \
+ (val) = ((*(CARD8 *)(in) & 0x0f) << 8) | *(CARD8 *)((in) + 1); \
+ if ((val) >= 0xe00) \
+ (val) -= 0x1000; \
+ else \
+ (val) += 0xf0; \
+ (in) += 2; \
+ }
+
+#define DECODE_SHORT(in, val) \
+ if ((*(in) & 0xf0) != 0x80) \
+ (val) = *(INT8 *)(in)++; \
+ else { \
+ (val) = ((*(CARD8 *)(in) & 0x0f) << 8) | *(CARD8 *)((in) + 1); \
+ if ((val) & 0x0800) \
+ (val) = ((val) | 0xf000) - 0x70; \
+ else \
+ (val) += 0x80; \
+ (in) += 2; \
+ }
+
+#define DECODE_USHORT(in, val) \
+ if ((*(in) & 0xf0) != 0xf0) \
+ (val) = *(CARD8 *)(in)++; \
+ else { \
+ (val) = (((*(CARD8 *)(in) & 0x0f) << 8) | *(CARD8 *)((in) + 1)) + 0xf0; \
+ (in) += 2; \
+ }
+
+#define DECODE_ANGLE(in, val) \
+ if (*(INT8 *)(in) >= 0x6e) \
+ (val) = (*(INT8 *)(in)++ - 0x67) * (15 << 6); \
+ else if (*(INT8 *)(in) >= 0x5a) \
+ (val) = (*(INT8 *)(in)++ - 0x5a) * (5 << 6); \
+ else if (*(INT8 *)(in) <= (INT8)0x91) \
+ (val) = (*(INT8 *)(in)++ - (INT8)0x98) * (15 << 6); \
+ else if (*(INT8 *)(in) <= (INT8)0xa5) \
+ (val) = (*(INT8 *)(in)++ - (INT8)0xa6) * (5 << 6); \
+ else { \
+ (val) = (*(CARD8 *)(in) << 8) | *(CARD8 *)((in) + 1); \
+ (in) += 2; \
+ }
+
+int
+LbxDecodePoints(char *in,
+ char *inend,
+ short *out)
+{
+ char *start_out = (char *)out;
+
+ while (in < inend) {
+ DECODE_SHORT(in, *out);
+ out++;
+ DECODE_SHORT(in, *out);
+ out++;
+ }
+ return ((char *)out - start_out);
+}
+
+int
+LbxDecodeSegment(char *in,
+ char *inend,
+ short *out)
+{
+ short diff;
+ short last_x = 0;
+ short last_y = 0;
+ char *start_out = (char *)out;
+
+ while (in < inend) {
+ DECODE_SHORT(in, diff);
+ *out = last_x + diff;
+ last_x += diff;
+ out++;
+ DECODE_SHORT(in, diff);
+ *out = last_y + diff;
+ last_y += diff;
+ out++;
+
+ DECODE_SHORT(in, diff);
+ *out = last_x + diff;
+ out++;
+ DECODE_SHORT(in, diff);
+ *out = last_y + diff;
+ out++;
+ }
+ return ((char *)out - start_out);
+}
+
+int
+LbxDecodeRectangle(char *in,
+ char *inend,
+ short *out)
+{
+ short diff;
+ short last_x = 0;
+ short last_y = 0;
+ char *start_out = (char *)out;
+
+ while (in < inend) {
+ DECODE_SHORT(in, diff);
+ *out = last_x + diff;
+ last_x += diff;
+ out++;
+ DECODE_SHORT(in, diff);
+ *out = last_y + diff;
+ last_y += diff;
+ out++;
+
+ DECODE_USHORT(in, *(unsigned short *)out);
+ out++;
+ DECODE_USHORT(in, *(unsigned short *)out);
+ out++;
+ }
+ return ((char *)out - start_out);
+}
+
+int
+LbxDecodeArc(char *in,
+ char *inend,
+ short *out)
+{
+ short diff;
+ short last_x = 0;
+ short last_y = 0;
+ char *start_out = (char *)out;
+
+ while (in < inend) {
+ DECODE_SHORT(in, diff);
+ *out = last_x + diff;
+ last_x += diff;
+ out++;
+ DECODE_SHORT(in, diff);
+ *out = last_y + diff;
+ last_y += diff;
+ out++;
+
+ DECODE_USHORT(in, *(unsigned short *)out);
+ out++;
+ DECODE_USHORT(in, *(unsigned short *)out);
+ out++;
+
+ DECODE_ANGLE(in, *out);
+ out++;
+ DECODE_ANGLE(in, *out);
+ out++;
+ }
+ return ((char *)out - start_out);
+}
+
+int
+LbxDecodeCopyArea (ClientPtr client)
+{
+ REQUEST(xLbxCopyAreaReq);
+ char *in;
+ xCopyAreaReq req;
+ int len;
+ Drawable srcDrawable, dstDrawable;
+ GContext gc;
+
+ GFX_GET_SRC_DST_DRAWABLE_AND_GC(xLbxCopyAreaReq, in, len);
+ req.reqType = X_CopyArea;
+ req.length = client->req_len = SIZEOF(xCopyAreaReq) >> 2;
+ req.srcDrawable = srcDrawable;
+ req.dstDrawable = dstDrawable;
+ req.gc = gc;
+ DECODE_PSHORT (in, req.srcX);
+ DECODE_PSHORT (in, req.srcY);
+ DECODE_PSHORT (in, req.dstX);
+ DECODE_PSHORT (in, req.dstY);
+ DECODE_USHORT (in, req.width);
+ DECODE_USHORT (in, req.height);
+ client->requestBuffer = (pointer) &req;
+ return (*ProcVector[X_CopyArea])(client);
+}
+
+int
+LbxDecodeCopyPlane (ClientPtr client)
+{
+ REQUEST(xLbxCopyPlaneReq);
+ char *in;
+ xCopyPlaneReq req;
+ int len;
+ Drawable srcDrawable, dstDrawable;
+ GContext gc;
+
+ GFX_GET_SRC_DST_DRAWABLE_AND_GC(xLbxCopyPlaneReq, in, len);
+ req.reqType = X_CopyPlane;
+ req.length = client->req_len = SIZEOF(xCopyPlaneReq) >> 2;
+ req.srcDrawable = srcDrawable;
+ req.dstDrawable = dstDrawable;
+ req.gc = gc;
+ DECODE_PSHORT (in, req.srcX);
+ DECODE_PSHORT (in, req.srcY);
+ DECODE_PSHORT (in, req.dstX);
+ DECODE_PSHORT (in, req.dstY);
+ DECODE_USHORT (in, req.width);
+ DECODE_USHORT (in, req.height);
+ req.bitPlane = stuff->bitPlane;
+ client->requestBuffer = (pointer) &req;
+ return (*ProcVector[X_CopyPlane])(client);
+}
+
+static pointer
+get_gfx_buffer(ClientPtr client,
+ int len)
+{
+ LbxClientPtr lbxClient = LbxClient(client);
+ pointer tmp;
+
+ /* XXX should probably shrink this sucker too */
+ if (len > lbxClient->gb_size) {
+ tmp = (pointer) xrealloc(lbxClient->gfx_buffer, len);
+ if (!tmp)
+ return (pointer) NULL;
+ lbxClient->gfx_buffer = tmp;
+ lbxClient->gb_size = len;
+ }
+ return lbxClient->gfx_buffer;
+}
+
+int
+LbxDecodePolyText (ClientPtr client)
+{
+ REQUEST(xLbxPolyTextReq);
+ char *in, *pos;
+ xPolyTextReq *xreq;
+ int len;
+ Drawable drawable;
+ GContext gc;
+
+ GFX_GET_DRAWABLE_AND_GC(xLbxPolyTextReq, in, len);
+ xreq = (xPolyTextReq *) get_gfx_buffer(client, sizeof (xPolyTextReq) + len);
+ if (!xreq)
+ return BadAlloc;
+ xreq->reqType = stuff->lbxReqType == X_LbxPolyText8? X_PolyText8 : X_PolyText16;
+ xreq->drawable = drawable;
+ xreq->gc = gc;
+ pos = in;
+ DECODE_PSHORT(in, xreq->x);
+ DECODE_PSHORT(in, xreq->y);
+ len -= (in - pos);
+ memmove ((char *) (xreq + 1), in, len);
+ xreq->length = client->req_len = (sizeof (xPolyTextReq) + len) >> 2;
+ client->requestBuffer = (pointer) xreq;
+ return (*ProcVector[xreq->reqType])(client);
+}
+
+int
+LbxDecodeImageText (ClientPtr client)
+{
+ REQUEST(xLbxImageTextReq);
+ char *in, *pos;
+ xImageTextReq *xreq;
+ int len;
+ Drawable drawable;
+ GContext gc;
+
+ GFX_GET_DRAWABLE_AND_GC(xLbxImageTextReq, in, len);
+ xreq = (xImageTextReq *) get_gfx_buffer(client, sizeof (xImageTextReq) + len);
+ if (!xreq)
+ return BadAlloc;
+ xreq->reqType = stuff->lbxReqType == X_LbxImageText8? X_ImageText8 : X_ImageText16;
+ xreq->drawable = drawable;
+ xreq->gc = gc;
+ xreq->nChars = stuff->nChars;
+ pos = in;
+ DECODE_PSHORT(in, xreq->x);
+ DECODE_PSHORT(in, xreq->y);
+ len -= (in - pos);
+ memmove ((char *) (xreq + 1), in, len);
+ xreq->length = client->req_len = (sizeof (xImageTextReq) + len) >> 2;
+ client->requestBuffer = (pointer) xreq;
+ return (*ProcVector[xreq->reqType])(client);
+}
+
+int
+LbxDecodePutImage (ClientPtr client)
+{
+ REQUEST (xLbxPutImageReq);
+ char *in, *data;
+ xPutImageReq xreq;
+ int ppl, bpl, nbytes;
+ int retval;
+ int n;
+
+ xreq.reqType = X_PutImage;
+
+ in = (char *) stuff + sz_xLbxPutImageReq;
+
+ if (stuff->bitPacked & 0x80) {
+ xreq.format = (stuff->bitPacked >> 5) & 0x3;
+ xreq.depth = ((stuff->bitPacked >> 2) & 0x7) + 1;
+ xreq.leftPad = 0;
+ } else {
+ xreq.depth = (stuff->bitPacked >> 2) + 1;
+ xreq.format = (*in >> 5) & 0x3;
+ xreq.leftPad = *in++ & 0x1f;
+ }
+ DECODE_USHORT(in, xreq.width);
+ DECODE_USHORT(in, xreq.height);
+ DECODE_PSHORT(in, xreq.dstX);
+ DECODE_PSHORT(in, xreq.dstY);
+ if (client->swapped) {
+ if (GFXdCacheEnt (stuff->cacheEnts) == GFXCacheNone ||
+ GFXgCacheEnt (stuff->cacheEnts) == GFXCacheNone)
+ {
+ swapl (in, n);
+ if (GFXdCacheEnt (stuff->cacheEnts) == GFXCacheNone &&
+ GFXgCacheEnt (stuff->cacheEnts) == GFXCacheNone)
+ swapl (in + 4, n);
+ }
+ }
+ in += LbxDecodeGFXCache(client, stuff->cacheEnts, in,
+ &xreq.drawable, &xreq.gc);
+
+ ppl = xreq.width + xreq.leftPad;
+ if (xreq.format != ZPixmap ||
+ (xreq.depth == 1 && screenInfo.formats->bitsPerPixel == 1)) {
+#ifdef INTERNAL_VS_EXTERNAL_PADDING
+ bpl = BitmapBytePadProto(ppl);
+#else
+ bpl = BitmapBytePad(ppl);
+#endif
+ nbytes = bpl;
+ if (xreq.format == XYPixmap)
+ nbytes *= xreq.depth;
+ } else {
+#ifdef INTERNAL_VS_EXTERNAL_PADDING
+ bpl = PixmapBytePadProto(ppl, xreq.depth);
+#else
+ bpl = PixmapBytePad(ppl, xreq.depth);
+#endif
+ nbytes = bpl;
+ }
+ nbytes *= xreq.height;
+ xreq.length = ((nbytes + 3) >> 2) + (sz_xPutImageReq >> 2);
+ /* +1 is because fillspan in DecodeFaxG42D seems to go 1 byte too far,
+ * and I don't want to mess with that code */
+ if ((data = (char *) xalloc ((xreq.length << 2) + 1)) == NULL)
+ return BadAlloc;
+
+ *((xPutImageReq *)data) = xreq;
+
+ if (!stuff->compressionMethod)
+ {
+ memcpy(data + sz_xPutImageReq, in, nbytes);
+ }
+ else if (xreq.format != ZPixmap ||
+ (xreq.depth == 1 && screenInfo.formats->bitsPerPixel == 1))
+ {
+ LbxBitmapCompMethod *compMethod;
+
+ compMethod = LbxSrvrLookupBitmapCompMethod (LbxProxy(client),
+ stuff->compressionMethod);
+
+ if (!compMethod)
+ {
+ xfree (data);
+ return (BadValue);
+ }
+ else
+ {
+ if (!compMethod->inited)
+ {
+ if (compMethod->compInit)
+ (*compMethod->compInit)();
+ compMethod->inited = 1;
+ }
+
+ (*compMethod->decompFunc) (
+ (unsigned char *) in, (unsigned char *) data + sz_xPutImageReq,
+ nbytes,
+#if BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER
+ (ppl + BITMAP_SCANLINE_UNIT - 1) & ~BITMAP_SCANLINE_UNIT,
+#else
+ ppl,
+#endif
+ bpl,
+ ((xConnSetup *) ConnectionInfo)->bitmapBitOrder == LSBFirst);
+ }
+ }
+ else
+ {
+ LbxPixmapCompMethod *compMethod;
+
+ compMethod = LbxSrvrLookupPixmapCompMethod (LbxProxy(client),
+ stuff->compressionMethod);
+
+ if (!compMethod)
+ {
+ xfree (data);
+ return (BadValue);
+ }
+ else
+ {
+ if (!compMethod->inited)
+ {
+ if (compMethod->compInit)
+ (*compMethod->compInit)();
+ compMethod->inited = 1;
+ }
+
+ (*compMethod->decompFunc) (
+ in, (char *) data + sz_xPutImageReq,
+ (int) xreq.height, bpl);
+ }
+ }
+
+ client->req_len = xreq.length;
+ client->requestBuffer = (pointer) data;
+
+ retval = (*ProcVector[X_PutImage])(client);
+ xfree(data);
+ return retval;
+}
+
+int
+LbxDecodeGetImage (ClientPtr client)
+{
+ REQUEST (xLbxGetImageReq);
+ xLbxGetImageReply *reply = NULL;
+ int lbxLen, xLen, n;
+ int method = 0, bytes, status;
+ xGetImageReply *theImage;
+
+ REQUEST_SIZE_MATCH(xLbxGetImageReq);
+
+ status = DoGetImage(client, stuff->format, stuff->drawable,
+ stuff->x, stuff->y,
+ (int)stuff->width, (int)stuff->height,
+ stuff->planeMask, &theImage);
+
+ if (status != Success)
+ return (status);
+
+ if ((reply = (xLbxGetImageReply *) xalloc (
+ sz_xLbxGetImageReply + theImage->length)) == NULL)
+ {
+ xfree(theImage);
+ return (BadAlloc);
+ }
+
+ if (stuff->format != ZPixmap ||
+ (theImage->depth == 1 && screenInfo.formats->bitsPerPixel == 1))
+ {
+ LbxBitmapCompMethod *compMethod;
+
+ compMethod = LbxSrvrFindPreferredBitmapCompMethod (LbxProxy(client));
+
+ if (!compMethod)
+ status = LBX_IMAGE_COMPRESS_NO_SUPPORT;
+ else
+ {
+ if (!compMethod->inited)
+ {
+ if (compMethod->compInit)
+ (*compMethod->compInit)();
+ compMethod->inited = 1;
+ }
+
+ status = (*compMethod->compFunc) (
+ (unsigned char *) &theImage[1],
+ (unsigned char *) &reply[1],
+ theImage->length,
+ theImage->length,
+#if BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER
+ (int) (stuff->width + BITMAP_SCANLINE_UNIT - 1) &
+ ~BITMAP_SCANLINE_UNIT,
+#else
+ (int) stuff->width,
+#endif
+#ifdef INTERNAL_VS_EXTERNAL_PADDING
+ BitmapBytePadProto(stuff->width),
+#else
+ BitmapBytePad(stuff->width),
+#endif
+ ((xConnSetup *) ConnectionInfo)->bitmapBitOrder == LSBFirst,
+ &bytes);
+
+ method = compMethod->methodOpCode;
+ }
+ }
+ else
+ {
+ LbxPixmapCompMethod *compMethod;
+
+ compMethod = LbxSrvrFindPreferredPixmapCompMethod (
+ LbxProxy(client), (int) stuff->format, theImage->depth);
+
+ if (!compMethod)
+ status = LBX_IMAGE_COMPRESS_NO_SUPPORT;
+ else
+ {
+ if (!compMethod->inited)
+ {
+ if (compMethod->compInit)
+ (*compMethod->compInit)();
+ compMethod->inited = 1;
+ }
+
+ status = (*compMethod->compFunc) (
+ (char *) &theImage[1],
+ (char *) &reply[1],
+ theImage->length,
+ (int) stuff->format,
+ theImage->depth,
+ (int) stuff->height,
+#ifdef INTERNAL_VS_EXTERNAL_PADDING
+ PixmapBytePadProto(stuff->width, theImage->depth),
+#else
+ PixmapBytePad(stuff->width, theImage->depth),
+#endif
+ &bytes);
+
+ method = compMethod->methodOpCode;
+ }
+ }
+
+ reply->type = X_Reply;
+ reply->depth = theImage->depth;
+ reply->sequenceNumber = client->sequence;
+ reply->visual = theImage->visual;
+ reply->pad1 = reply->pad2 = reply->pad3 = reply->pad4 = reply->pad5 = 0;
+
+ if (status != LBX_IMAGE_COMPRESS_SUCCESS)
+ {
+ reply->compressionMethod = LbxImageCompressNone;
+ reply->lbxLength = reply->xLength = (theImage->length + 3) >> 2;
+ }
+ else
+ {
+ reply->compressionMethod = method;
+ reply->lbxLength = (bytes + 3) >> 2;
+ reply->xLength = (theImage->length + 3) >> 2;
+ }
+
+ lbxLen = reply->lbxLength;
+ xLen = reply->xLength;
+
+ if (client->swapped)
+ {
+ swaps (&reply->sequenceNumber, n);
+ swapl (&reply->lbxLength, n);
+ swapl (&reply->xLength, n);
+ swapl (&reply->visual, n);
+ }
+
+ if (reply->compressionMethod != LbxImageCompressNone)
+ {
+ /*
+ * If the compressed image is greater that 25% of the original
+ * image, run the GetImage reply through the regular stream
+ * compressor. Otherwise, just write the compressed image.
+ */
+
+ if (lbxLen > (xLen / 4))
+ {
+ WriteToClient (client,
+ sz_xLbxGetImageReply + (lbxLen << 2), (char *)reply);
+ }
+ else
+ {
+ UncompressedWriteToClient (client,
+ sz_xLbxGetImageReply + (lbxLen << 2), (char *)reply);
+ }
+ }
+ else
+ {
+ /*
+ * Write back the original uncompressed image.
+ */
+
+ WriteToClient (client, sz_xLbxGetImageReply, (char *)reply);
+ WriteToClient (client, lbxLen << 2, (char *)&theImage[1]);
+ }
+
+ xfree (theImage);
+
+ if (reply)
+ xfree ((char *) reply);
+
+ return (Success);
+}
diff --git a/nx-X11/programs/Xserver/lbx/lbxmain.c b/nx-X11/programs/Xserver/lbx/lbxmain.c
new file mode 100644
index 000000000..9139dfbed
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/lbxmain.c
@@ -0,0 +1,1760 @@
+/* $Xorg: lbxmain.c,v 1.4 2001/02/09 02:05:16 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * Copyright 1992 Network Computing Devices
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of NCD. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCD. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxmain.c,v 1.12 2001/10/28 03:34:12 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <sys/types.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xos.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "gcstruct.h"
+#include "extnsionst.h"
+#include "servermd.h"
+#define _XLBX_SERVER_
+#include <X11/extensions/lbxstr.h>
+#include <X11/extensions/lbxdeltastr.h>
+#include "lbxserve.h"
+#include <X11/extensions/lbximage.h>
+#include "lbxsrvopts.h"
+#include "lbxtags.h"
+#include <X11/Xfuncproto.h>
+#include <errno.h>
+#ifndef Lynx
+#include <sys/uio.h>
+#else
+#include <uio.h>
+#endif
+#include <stdio.h>
+
+#ifndef X_NOT_POSIX
+#include <unistd.h>
+#endif
+
+#define CloseLbxClient 0xff
+
+#define MAXBYTESDIFF 8
+
+int LbxWhoAmI = 1; /*
+ * for lbx zlib library to know who we are
+ * server = 1
+ * proxy = 0
+ */
+
+
+static void LbxResetProc ( ExtensionEntry *extEntry );
+static void LbxFreeClient ( ClientPtr client );
+static void LbxShutdownProxy ( LbxProxyPtr proxy );
+static int DecodeLbxDelta ( ClientPtr client );
+
+static LbxProxyPtr proxyList;
+unsigned char LbxReqCode;
+int LbxEventCode;
+static int BadLbxClientCode;
+static int uid_seed;
+
+static int lbxCompressWorkProcCount;
+
+LbxClientPtr lbxClients[MAXCLIENTS];
+
+extern xConnSetupPrefix connSetupPrefix;
+extern char *ConnectionInfo;
+extern int (*LbxInitialVector[3])(ClientPtr);
+
+#ifdef DEBUG
+int lbxDebug = 0;
+#endif
+
+
+void
+LbxExtensionInit(void)
+{
+ ExtensionEntry *extEntry;
+
+ lbxCompressWorkProcCount = 0;
+ proxyList = NULL;
+ uid_seed = 0;
+ if ((extEntry = AddExtension(LBXNAME, LbxNumberEvents, LbxNumberErrors,
+ ProcLbxDispatch, SProcLbxDispatch,
+ LbxResetProc, StandardMinorOpcode)))
+ {
+ LbxReqCode = (unsigned char)extEntry->base;
+ LbxEventCode = extEntry->eventBase;
+ BadLbxClientCode = extEntry->errorBase + BadLbxClient;
+ LbxDixInit();
+
+ LbxCmapInit ();
+ DeclareExtensionSecurity(LBXNAME, TRUE);
+ }
+}
+
+/*ARGSUSED*/
+static void
+LbxResetProc (ExtensionEntry *extEntry)
+{
+ LbxResetTags();
+ uid_seed = 0;
+}
+
+void
+LbxCloseClient (ClientPtr client)
+{
+ xLbxCloseEvent closeEvent;
+ ClientPtr master;
+ LbxProxyPtr proxy;
+ LbxClientPtr lbxClient = LbxClient(client);
+ CARD32 id;
+
+ if (!lbxClient)
+ return;
+ id = lbxClient->id;
+ proxy = lbxClient->proxy;
+
+ DBG (DBG_CLIENT, (stderr, "Close client %d\n", client->index));
+ LbxFreeClient (client);
+ if (!id)
+ {
+ isItTimeToYield = TRUE;
+ CloseDownFileDescriptor (client);
+ LbxShutdownProxy (proxy);
+ }
+ else
+ {
+ master = NULL;
+ if (proxy->lbxClients[0])
+ master = LbxProxyClient(proxy);
+ if (master && !master->clientGone)
+ {
+ closeEvent.type = LbxEventCode;
+ closeEvent.lbxType = LbxCloseEvent;
+ closeEvent.client = id;
+ closeEvent.sequenceNumber = master->sequence;
+ closeEvent.pad1 = closeEvent.pad2 = closeEvent.pad3 =
+ closeEvent.pad4 = closeEvent.pad5 = closeEvent.pad6 = 0;
+ if (master->swapped) {
+ int n;
+
+ swaps(&closeEvent.sequenceNumber, n);
+ swapl(&closeEvent.client, n);
+ }
+ WriteToClient(master, sizeof (closeEvent), (char *)&closeEvent);
+ LbxForceOutput(proxy);
+ }
+ }
+}
+
+static int
+LbxReencodeEvent(ClientPtr client,
+ LbxProxyPtr proxy,
+ char *buf)
+{
+ xEvent *ev = (xEvent *)buf;
+ int n;
+ lbxMotionCache *motionCache = &proxy->motionCache;
+ int motionDelta = 0;
+ Bool swapCache;
+ xEvent tev, *sev;
+
+ if (ev->u.u.type != MotionNotify) {
+ if (proxy->dosquishing)
+ return LbxSquishEvent(buf);
+ return 0;
+ }
+
+ /*
+ * Check if we can generate a motion delta event.
+ *
+ * The motion cache contains the last motion event the server sent.
+ *
+ * The following are always stored in the cache in the server's
+ * byte order:
+ * sequenceNumber, time, rootX, rootY, eventX, eventY
+ * This is because when determining if we can do a delta, all
+ * arithmetic must be done using the server's byte order.
+ *
+ * The following are stored in the byte order of the latest client
+ * receiving a motion event (indicated by motionCache->swapped):
+ * root, event, child, state
+ * These fields do not need to be stored in the server's byte order
+ * because we only use the '==' operator on them.
+ */
+
+ if (!proxy->motion_allowed_events) {
+ DBG(DBG_CLIENT, (stderr, "throttling motion event for client %d\n", client->index));
+ return sz_xEvent;
+ }
+ proxy->motion_allowed_events--;
+
+ motionCache = &proxy->motionCache;
+
+ if (!client->swapped)
+ {
+ swapCache = motionCache->swapped;
+ sev = ev;
+ }
+ else
+ {
+ swapCache = !motionCache->swapped;
+ sev = &tev;
+ cpswaps (ev->u.keyButtonPointer.rootX,
+ sev->u.keyButtonPointer.rootX);
+ cpswaps (ev->u.keyButtonPointer.rootY,
+ sev->u.keyButtonPointer.rootY);
+ cpswaps (ev->u.keyButtonPointer.eventX,
+ sev->u.keyButtonPointer.eventX);
+ cpswaps (ev->u.keyButtonPointer.eventY,
+ sev->u.keyButtonPointer.eventY);
+ cpswaps (ev->u.u.sequenceNumber,
+ sev->u.u.sequenceNumber);
+ cpswapl (ev->u.keyButtonPointer.time,
+ sev->u.keyButtonPointer.time);
+ }
+
+ if (swapCache)
+ {
+ swapl (&motionCache->root, n);
+ swapl (&motionCache->event, n);
+ swapl (&motionCache->child, n);
+ swaps (&motionCache->state, n);
+
+ motionCache->swapped = !motionCache->swapped;
+ }
+
+ motionDelta = 0;
+
+ if (ev->u.u.detail == motionCache->detail &&
+ ev->u.keyButtonPointer.root == motionCache->root &&
+ ev->u.keyButtonPointer.event == motionCache->event &&
+ ev->u.keyButtonPointer.child == motionCache->child &&
+ ev->u.keyButtonPointer.state == motionCache->state &&
+ ev->u.keyButtonPointer.sameScreen == motionCache->sameScreen) {
+
+ int root_delta_x =
+ sev->u.keyButtonPointer.rootX - motionCache->rootX;
+ int root_delta_y =
+ sev->u.keyButtonPointer.rootY - motionCache->rootY;
+ int event_delta_x =
+ sev->u.keyButtonPointer.eventX - motionCache->eventX;
+ int event_delta_y =
+ sev->u.keyButtonPointer.eventY - motionCache->eventY;
+ unsigned long sequence_delta =
+ sev->u.u.sequenceNumber - motionCache->sequenceNumber;
+ unsigned long time_delta =
+ sev->u.keyButtonPointer.time - motionCache->time;
+
+ if (root_delta_x == event_delta_x &&
+ event_delta_x >= -128 && event_delta_x < 128 &&
+ root_delta_y == event_delta_y &&
+ event_delta_y >= -128 && event_delta_y < 128) {
+
+ if (sequence_delta == 0 && time_delta < 256) {
+
+ lbxQuickMotionDeltaEvent *mev =
+ (lbxQuickMotionDeltaEvent *)(buf + sz_xEvent -
+ sz_lbxQuickMotionDeltaEvent);
+
+ mev->type = LbxEventCode + LbxQuickMotionDeltaEvent;
+ mev->deltaTime = time_delta;
+ mev->deltaX = event_delta_x;
+ mev->deltaY = event_delta_y;
+
+ motionDelta = sz_xEvent - sz_lbxQuickMotionDeltaEvent;
+
+ } else if (sequence_delta < 65536 && time_delta < 65536) {
+
+ lbxMotionDeltaEvent *mev =
+ (lbxMotionDeltaEvent *)(buf + sz_xEvent -
+ sz_lbxMotionDeltaEvent);
+
+ mev->type = LbxEventCode;
+ mev->lbxType = LbxMotionDeltaEvent;
+ mev->deltaTime = time_delta;
+ mev->deltaSequence = sequence_delta;
+ mev->deltaX = event_delta_x;
+ mev->deltaY = event_delta_y;
+
+ if (LbxProxyClient(proxy)->swapped)
+ {
+ swaps (&mev->deltaTime, n);
+ swaps (&mev->deltaSequence, n);
+ }
+
+ motionDelta = sz_xEvent - sz_lbxMotionDeltaEvent;
+ }
+ }
+ }
+
+ motionCache->sequenceNumber = sev->u.u.sequenceNumber;
+ motionCache->time = sev->u.keyButtonPointer.time;
+ motionCache->rootX = sev->u.keyButtonPointer.rootX;
+ motionCache->rootY = sev->u.keyButtonPointer.rootY;
+ motionCache->eventX = sev->u.keyButtonPointer.eventX;
+ motionCache->eventY = sev->u.keyButtonPointer.eventY;
+
+ if (motionDelta)
+ return motionDelta;
+
+ ev->u.keyButtonPointer.pad1 = 0;
+ motionCache->detail = ev->u.u.detail;
+ motionCache->root = ev->u.keyButtonPointer.root;
+ motionCache->event = ev->u.keyButtonPointer.event;
+ motionCache->child = ev->u.keyButtonPointer.child;
+ motionCache->state = ev->u.keyButtonPointer.state;
+ motionCache->sameScreen = ev->u.keyButtonPointer.sameScreen;
+ return 0;
+}
+
+static int
+LbxComposeDelta(LbxProxyPtr proxy,
+ char *reply,
+ int len,
+ char *buf)
+{
+ int diffs;
+ int cindex;
+ int n;
+ xLbxDeltaReq *p = (xLbxDeltaReq *)buf;
+
+ diffs = LBXDeltaMinDiffs(&proxy->outdeltas, (unsigned char *)reply, len,
+ min(MAXBYTESDIFF, (len - sz_xLbxDeltaReq) >> 1),
+ &cindex);
+ if (diffs < 0) {
+ LBXAddDeltaOut(&proxy->outdeltas, (unsigned char *)reply, len);
+ return 0;
+ }
+ LBXEncodeDelta(&proxy->outdeltas, (unsigned char *)reply, diffs, cindex,
+ (unsigned char *)(&buf[sz_xLbxDeltaReq]));
+ LBXAddDeltaOut(&proxy->outdeltas, (unsigned char *)reply, len);
+ p->reqType = LbxEventCode;
+ p->lbxReqType = LbxDeltaEvent;
+ p->diffs = diffs;
+ p->cindex = cindex;
+ len = (sz_xLbxDeltaReq + sz_xLbxDiffItem * diffs + 3) & ~3;
+ p->length = len >> 2;
+ if (LbxProxyClient(proxy)->swapped) {
+ swaps(&p->length, n);
+ }
+ return len;
+}
+
+void
+LbxReencodeOutput(ClientPtr client,
+ char *pbuf,
+ int *pcount,
+ char *cbuf,
+ int *ccount)
+{
+ LbxClientPtr lbxClient = LbxClient(client);
+ LbxProxyPtr proxy = lbxClient->proxy;
+ CARD32 len;
+ int n;
+ int count = *ccount;
+ char *obuf = cbuf;
+
+ if (client->clientState != ClientStateRunning) {
+ if (DELTA_CACHEABLE(&proxy->outdeltas, count) &&
+ (n = LbxComposeDelta(proxy, cbuf, count, proxy->oDeltaBuf))) {
+ memcpy(obuf, proxy->oDeltaBuf, n);
+ *ccount -= (count - n);
+ }
+ return;
+ }
+ if (lbxClient->bytes_remaining) {
+ if (count < lbxClient->bytes_remaining) {
+ lbxClient->bytes_remaining -= count;
+ return;
+ }
+ if (DELTA_CACHEABLE(&proxy->outdeltas, lbxClient->bytes_in_reply)) {
+ len = lbxClient->bytes_in_reply - lbxClient->bytes_remaining;
+ pbuf += (*pcount - len);
+ memcpy(proxy->replyBuf, pbuf, len);
+ memcpy(proxy->replyBuf + len, cbuf, lbxClient->bytes_remaining);
+ n = LbxComposeDelta(proxy, proxy->replyBuf,
+ lbxClient->bytes_in_reply, proxy->oDeltaBuf);
+ if (!n)
+ obuf += lbxClient->bytes_remaining;
+ else if (n <= len) {
+ memcpy(pbuf, proxy->oDeltaBuf, n);
+ *pcount -= (len - n);
+ *ccount -= lbxClient->bytes_remaining;
+ } else {
+ memcpy(pbuf, proxy->oDeltaBuf, len);
+ memcpy(obuf, proxy->oDeltaBuf + len, n - len);
+ *ccount -= lbxClient->bytes_remaining - (n - len);
+ obuf += n - len;
+ }
+ } else
+ obuf += lbxClient->bytes_remaining;
+ cbuf += lbxClient->bytes_remaining;
+ count -= lbxClient->bytes_remaining;
+ lbxClient->bytes_remaining = 0;
+ }
+ while (count) {
+ lbxClient->bytes_in_reply = sz_xEvent;
+ if (((xGenericReply *)cbuf)->type == X_Reply) {
+ len = ((xGenericReply *)cbuf)->length;
+ if (client->swapped) {
+ swapl(&len, n);
+ }
+ lbxClient->bytes_in_reply += (len << 2);
+ if (LbxProxyClient(proxy)->swapped != client->swapped) {
+ swapl(&((xGenericReply *)cbuf)->length, n);
+ }
+ if (count < lbxClient->bytes_in_reply) {
+ lbxClient->bytes_remaining = lbxClient->bytes_in_reply - count;
+ if (obuf != cbuf)
+ memmove(obuf, cbuf, count);
+ return;
+ }
+ } else if (((xGenericReply *)cbuf)->type > X_Reply &&
+ ((xGenericReply *)cbuf)->type < LASTEvent &&
+ (n = LbxReencodeEvent(client, proxy, cbuf))) {
+ cbuf += n;
+ *ccount -= n;
+ count -= n;
+ if (n == sz_xEvent)
+ continue;
+ lbxClient->bytes_in_reply -= n;
+ }
+ if (DELTA_CACHEABLE(&proxy->outdeltas, lbxClient->bytes_in_reply) &&
+ (n = LbxComposeDelta(proxy, cbuf, lbxClient->bytes_in_reply,
+ proxy->oDeltaBuf))) {
+ memcpy(obuf, proxy->oDeltaBuf, n);
+ obuf += n;
+ *ccount -= (lbxClient->bytes_in_reply - n);
+ } else {
+ if (obuf != cbuf)
+ memmove(obuf, cbuf, lbxClient->bytes_in_reply);
+ obuf += lbxClient->bytes_in_reply;
+ }
+ cbuf += lbxClient->bytes_in_reply;
+ count -= lbxClient->bytes_in_reply;
+ }
+}
+
+/*ARGSUSED*/
+static void
+LbxReplyCallback(CallbackListPtr *pcbl,
+ pointer nulldata,
+ pointer calldata)
+{
+ ReplyInfoRec *pri = (ReplyInfoRec *)calldata;
+ ClientPtr client = pri->client;
+ LbxClientPtr lbxClient;
+ REQUEST(xReq);
+
+ if (!pri->startOfReply || stuff->reqType > 127)
+ return;
+ lbxClient = LbxClient(client);
+ if (lbxClient)
+ ZeroReplyPadBytes(pri->replyData, stuff->reqType);
+}
+
+/*
+ * XXX If you think this is moronic, you're in good company,
+ * but things definitely hang if we don't have this.
+ */
+/* ARGSUSED */
+static Bool
+LbxCheckCompressInput (ClientPtr dummy1,
+ pointer dummy2)
+{
+ LbxProxyPtr proxy;
+
+ if (!lbxCompressWorkProcCount)
+ return TRUE;
+
+ for (proxy = proxyList; proxy; proxy = proxy->next) {
+ if (proxy->compHandle &&
+ proxy->streamOpts.streamCompInputAvail(proxy->fd))
+ AvailableClientInput (LbxProxyClient(proxy));
+ }
+ return FALSE;
+}
+
+static Bool
+LbxIsClientBlocked (LbxClientPtr lbxClient)
+{
+ LbxProxyPtr proxy = lbxClient->proxy;
+
+ return (lbxClient->ignored ||
+ (GrabInProgress && lbxClient->client->index != GrabInProgress &&
+ lbxClient != proxy->lbxClients[0]));
+}
+
+static void
+LbxSwitchRecv (LbxProxyPtr proxy,
+ LbxClientPtr lbxClient)
+{
+ ClientPtr client;
+
+ proxy->curRecv = lbxClient;
+ if (!lbxClient || lbxClient->client->clientGone)
+ {
+ DBG(DBG_CLIENT, (stderr, "switching to dispose input\n"));
+ lbxClient = proxy->lbxClients[0];
+ if (!lbxClient)
+ return;
+ }
+ client = lbxClient->client;
+ DBG (DBG_SWITCH, (stderr, "switching input to client %d\n", client->index));
+
+ SwitchClientInput (client, FALSE);
+ proxy->curDix = lbxClient;
+}
+
+/* ARGSUSED */
+static Bool
+LbxWaitForUnblocked (ClientPtr client,
+ pointer closure)
+{
+ LbxClientPtr lbxClient;
+ LbxProxyPtr proxy;
+
+ if (client->clientGone)
+ return TRUE;
+ lbxClient = LbxClient(client);
+ if (!lbxClient)
+ return TRUE;
+ proxy = lbxClient->proxy;
+ if (LbxIsClientBlocked (lbxClient) ||
+ ((lbxClient != proxy->curDix) && proxy->curDix->reqs_pending &&
+ !LbxIsClientBlocked(proxy->curDix)))
+ return FALSE;
+ lbxClient->input_blocked = FALSE;
+ DBG (DBG_BLOCK, (stderr, "client %d no longer blocked, switching\n",
+ client->index));
+ SwitchClientInput (client, TRUE);
+ proxy->curDix = lbxClient;
+ return TRUE;
+}
+
+void
+LbxSetForBlock(LbxClientPtr lbxClient)
+{
+ lbxClient->reqs_pending++;
+ if (!lbxClient->input_blocked)
+ {
+ lbxClient->input_blocked = TRUE;
+ QueueWorkProc(LbxWaitForUnblocked, lbxClient->client, NULL);
+ }
+}
+
+/* ARGSUSED */
+static int
+LbxWaitForUngrab (ClientPtr client,
+ pointer closure)
+{
+ LbxClientPtr lbxClient = LbxClient(client);
+ LbxProxyPtr proxy;
+ xLbxListenToAllEvent ungrabEvent;
+
+ if (client->clientGone || !lbxClient)
+ return TRUE;
+ if (GrabInProgress)
+ return FALSE;
+ proxy = lbxClient->proxy;
+ proxy->grabClient = 0;
+ ungrabEvent.type = LbxEventCode;
+ ungrabEvent.lbxType = LbxListenToAll;
+ ungrabEvent.pad1 = ungrabEvent.pad2 = ungrabEvent.pad3 =
+ ungrabEvent.pad4 = ungrabEvent.pad5 = ungrabEvent.pad6 =
+ ungrabEvent.pad7 = 0;
+ WriteToClient (client,
+ sizeof(xLbxListenToAllEvent), (char *)&ungrabEvent);
+ LbxForceOutput(proxy);
+ return TRUE;
+}
+
+static void
+LbxServerGrab(LbxProxyPtr proxy)
+{
+ LbxClientPtr grabbingLbxClient;
+ xLbxListenToOneEvent grabEvent;
+
+ /*
+ * If the current grabbing client has changed, then we need
+ * to send a message to update the proxy.
+ */
+
+ grabEvent.type = LbxEventCode;
+ grabEvent.lbxType = LbxListenToOne;
+ if (!(grabbingLbxClient = lbxClients[GrabInProgress]) ||
+ grabbingLbxClient->proxy != proxy)
+ grabEvent.client = 0xffffffff; /* client other than a proxy client */
+ else
+ grabEvent.client = grabbingLbxClient->id;
+ grabEvent.pad1 = grabEvent.pad2 = grabEvent.pad3 =
+ grabEvent.pad4 = grabEvent.pad5 = grabEvent.pad6 = 0;
+ if (LbxProxyClient(proxy)->swapped) {
+ int n;
+ swapl(&grabEvent.client, n);
+ }
+ WriteToClient(LbxProxyClient(proxy),
+ sizeof(xLbxListenToOneEvent), (char *)&grabEvent);
+ LbxForceOutput(proxy);
+ if (!proxy->grabClient)
+ QueueWorkProc(LbxWaitForUngrab, LbxProxyClient(proxy), NULL);
+ proxy->grabClient = GrabInProgress;
+}
+
+#define MAJOROP(client) ((xReq *)client->requestBuffer)->reqType
+#define MINOROP(client) ((xReq *)client->requestBuffer)->data
+
+static Bool lbxCacheable[] = {
+ FALSE, /* LbxQueryVersion 0 */
+ FALSE, /* LbxStartProxy 1 */
+ TRUE, /* LbxStopProxy 2 */
+ FALSE, /* LbxSwitch 3 */
+ FALSE, /* LbxNewClient 4 */
+ TRUE, /* LbxCloseClient 5 */
+ TRUE, /* LbxModifySequence 6 */
+ FALSE, /* LbxAllowMotion 7 */
+ TRUE, /* LbxIncrementPixel 8 */
+ FALSE, /* LbxDelta 9 */
+ TRUE, /* LbxGetModifierMapping 10 */
+ FALSE, /* nothing 11 */
+ TRUE, /* LbxInvalidateTag 12 */
+ TRUE, /* LbxPolyPoint 13 */
+ TRUE, /* LbxPolyLine 14 */
+ TRUE, /* LbxPolySegment 15 */
+ TRUE, /* LbxPolyRectangle 16 */
+ TRUE, /* LbxPolyArc 17 */
+ TRUE, /* LbxFillPoly 18 */
+ TRUE, /* LbxPolyFillRectangle 19 */
+ TRUE, /* LbxPolyFillArc 20 */
+ TRUE, /* LbxGetKeyboardMapping 21 */
+ TRUE, /* LbxQueryFont 22 */
+ TRUE, /* LbxChangeProperty 23 */
+ TRUE, /* LbxGetProperty 24 */
+ TRUE, /* LbxTagData 25 */
+ TRUE, /* LbxCopyArea 26 */
+ TRUE, /* LbxCopyPlane 27 */
+ TRUE, /* LbxPolyText8 28 */
+ TRUE, /* LbxPolyText16 29 */
+ TRUE, /* LbxImageText8 30 */
+ TRUE, /* LbxImageText16 31 */
+ FALSE, /* LbxQueryExtension 32 */
+ TRUE, /* LbxPutImage 33 */
+ TRUE, /* LbxGetImage 34 */
+ FALSE, /* LbxBeginLargeRequest 35 */
+ FALSE, /* LbxLargeRequestData 36 */
+ FALSE, /* LbxEndLargeRequest 37 */
+ FALSE, /* LbxInternAtoms 38 */
+ TRUE, /* LbxGetWinAttrAndGeom 39 */
+ TRUE, /* LbxGrabCmap 40 */
+ TRUE, /* LbxReleaseCmap 41 */
+ TRUE, /* LbxAllocColor 42 */
+ TRUE, /* LbxSync 43 */
+};
+
+#define NUM(a) (sizeof (a) / sizeof (a[0]))
+
+static int
+LbxReadRequestFromClient (ClientPtr client)
+{
+ int ret;
+ LbxClientPtr lbxClient = LbxClient(client);
+ LbxProxyPtr proxy = lbxClient->proxy;
+ ClientPtr masterClient = LbxProxyClient(proxy);
+ Bool isblocked;
+ Bool cacheable;
+
+ DBG (DBG_READ_REQ, (stderr, "Reading request from client %d\n", client->index));
+
+ if (GrabInProgress && (proxy->grabClient != GrabInProgress))
+ LbxServerGrab(proxy);
+ isblocked = LbxIsClientBlocked(lbxClient);
+
+ if (lbxClient->reqs_pending && !isblocked) {
+ ret = StandardReadRequestFromClient(client);
+ if (ret > 0 && (MAJOROP(client) == LbxReqCode) &&
+ (MINOROP(client) == X_LbxEndLargeRequest))
+ ret = PrepareLargeReqBuffer(client);
+ if (!--lbxClient->reqs_pending && (lbxClient != proxy->curRecv))
+ LbxSwitchRecv (proxy, proxy->curRecv);
+ return ret;
+ }
+ while (1) {
+ ret = StandardReadRequestFromClient(masterClient);
+ if (ret <= 0)
+ return ret;
+ client->requestBuffer = masterClient->requestBuffer;
+ client->req_len = masterClient->req_len;
+ cacheable = client->clientState == ClientStateRunning;
+ if (cacheable && (MAJOROP(client) == LbxReqCode)) {
+ /* Check to see if this request is delta cached */
+ if (MINOROP(client) < NUM(lbxCacheable))
+ cacheable = lbxCacheable[MINOROP(client)];
+ switch (MINOROP(client)) {
+ case X_LbxSwitch:
+ /* Switch is sent by proxy */
+ if (masterClient->swapped)
+ SProcLbxSwitch (client);
+ else
+ ProcLbxSwitch (client);
+ return 0;
+ case X_LbxDelta:
+ ret = DecodeLbxDelta (client);
+ DBG(DBG_DELTA,
+ (stderr,"delta decompressed msg %d, len = %d\n",
+ (unsigned)((unsigned char *)client->requestBuffer)[0],
+ ret));
+ break;
+ case X_LbxEndLargeRequest:
+ if (!isblocked)
+ ret = PrepareLargeReqBuffer(client);
+ break;
+ }
+ }
+ if (cacheable && DELTA_CACHEABLE(&proxy->indeltas, ret)) {
+ DBG(DBG_DELTA,
+ (stderr, "caching msg %d, len = %d, index = %d\n",
+ (unsigned)((unsigned char *)client->requestBuffer)[0],
+ ret, proxy->indeltas.nextDelta));
+ LBXAddDeltaIn(&proxy->indeltas, client->requestBuffer, ret);
+ }
+ if (client->swapped != masterClient->swapped) {
+ char n;
+ /* put length in client order */
+ swaps(&((xReq *)client->requestBuffer)->length, n);
+ }
+ if (!isblocked)
+ return ret;
+ DBG (DBG_BLOCK, (stderr, "Stashing %d bytes for %d\n",
+ ret, client->index));
+ AppendFakeRequest (client, client->requestBuffer, ret);
+ LbxSetForBlock(lbxClient);
+ }
+}
+
+static LbxClientPtr
+LbxInitClient (LbxProxyPtr proxy,
+ ClientPtr client,
+ CARD32 id)
+{
+ LbxClientPtr lbxClient;
+ int i;
+
+ lbxClient = (LbxClientPtr) xalloc (sizeof (LbxClientRec));
+ if (!lbxClient)
+ return NULL;
+ lbxClient->id = id;
+ lbxClient->client = client;
+ lbxClient->proxy = proxy;
+ lbxClient->ignored = FALSE;
+ lbxClient->input_blocked = FALSE;
+ lbxClient->reqs_pending = 0;
+ lbxClient->bytes_in_reply = 0;
+ lbxClient->bytes_remaining = 0;
+ client->readRequest = LbxReadRequestFromClient;
+ bzero (lbxClient->drawableCache, sizeof (lbxClient->drawableCache));
+ bzero (lbxClient->gcontextCache, sizeof (lbxClient->gcontextCache));
+ lbxClients[client->index] = lbxClient;
+ for (i = 0; proxy->lbxClients[i]; i++)
+ ;
+ if (i > proxy->maxIndex)
+ proxy->maxIndex = i;
+ proxy->lbxClients[i] = lbxClient;
+ proxy->numClients++;
+ lbxClient->gfx_buffer = (pointer) NULL;
+ lbxClient->gb_size = 0;
+ return lbxClient;
+}
+
+static void
+LbxFreeClient (ClientPtr client)
+{
+ LbxClientPtr lbxClient = LbxClient(client);
+ LbxProxyPtr proxy = lbxClient->proxy;
+ int i;
+
+ if (lbxClient != proxy->lbxClients[0]) {
+ if (lbxClient == proxy->curRecv)
+ LbxSwitchRecv(proxy, NULL);
+ else if (lbxClient == proxy->curDix)
+ LbxSwitchRecv(proxy, proxy->curRecv);
+ }
+
+ --proxy->numClients;
+ lbxClients[client->index] = NULL;
+ for (i = 0; i <= proxy->maxIndex; i++) {
+ if (proxy->lbxClients[i] == lbxClient) {
+ proxy->lbxClients[i] = NULL;
+ break;
+ }
+ }
+ while (proxy->maxIndex >= 0 && !proxy->lbxClients[proxy->maxIndex])
+ --proxy->maxIndex;
+ xfree(lbxClient->gfx_buffer);
+ client->readRequest = StandardReadRequestFromClient;
+ xfree (lbxClient);
+}
+
+static void
+LbxFreeProxy (LbxProxyPtr proxy)
+{
+ LbxProxyPtr *p;
+
+ LBXFreeDeltaCache(&proxy->indeltas);
+ LBXFreeDeltaCache(&proxy->outdeltas);
+ LbxFreeOsBuffers(proxy);
+ if (proxy->iDeltaBuf)
+ xfree(proxy->iDeltaBuf);
+ if (proxy->replyBuf)
+ xfree(proxy->replyBuf);
+ if (proxy->oDeltaBuf)
+ xfree(proxy->oDeltaBuf);
+ if (proxy->compHandle)
+ proxy->streamOpts.streamCompFreeHandle(proxy->compHandle);
+ if (proxy->bitmapCompMethods)
+ xfree (proxy->bitmapCompMethods);
+ if (proxy->pixmapCompMethods)
+ xfree (proxy->pixmapCompMethods);
+ if (proxy->pixmapCompDepths)
+ {
+ int i;
+ for (i = 0; i < proxy->numPixmapCompMethods; i++)
+ xfree (proxy->pixmapCompDepths[i]);
+ xfree (proxy->pixmapCompDepths);
+ }
+
+ for (p = &proxyList; *p; p = &(*p)->next) {
+ if (*p == proxy) {
+ *p = proxy->next;
+ break;
+ }
+ }
+ if (!proxyList)
+ DeleteCallback(&ReplyCallback, LbxReplyCallback, NULL);
+
+ xfree (proxy);
+}
+
+LbxProxyPtr
+LbxPidToProxy(int pid)
+{
+ LbxProxyPtr proxy;
+
+ for (proxy = proxyList; proxy; proxy = proxy->next) {
+ if (proxy->pid == pid)
+ return proxy;
+ }
+ return NULL;
+}
+
+static void
+LbxShutdownProxy (LbxProxyPtr proxy)
+{
+ int i;
+ ClientPtr client;
+
+ if (proxy->compHandle)
+ --lbxCompressWorkProcCount;
+ while (proxy->grabbedCmaps)
+ LbxReleaseCmap(proxy->grabbedCmaps, FALSE);
+ for (i = 0; i <= proxy->maxIndex; i++)
+ {
+ if (proxy->lbxClients[i])
+ {
+ client = proxy->lbxClients[i]->client;
+ if (!client->clientGone)
+ CloseDownClient (client);
+ }
+ }
+ LbxFlushTags(proxy);
+ LbxFreeProxy(proxy);
+}
+
+
+int
+ProcLbxQueryVersion (ClientPtr client)
+{
+ /* REQUEST(xLbxQueryVersionReq); */
+ xLbxQueryVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xLbxQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = LBX_MAJOR_VERSION;
+ rep.minorVersion = LBX_MINOR_VERSION;
+ rep.pad0 = rep.pad1 = rep.pad2 = rep.pad3 = rep.pad4 = 0;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof(xLbxQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+NextProxyID (void)
+{
+ LbxProxyPtr proxy;
+ int id;
+
+ for (id = 1; id < MAX_NUM_PROXIES; id++) {
+ for (proxy = proxyList; proxy && proxy->pid != id; proxy = proxy->next)
+ ;
+ if (!proxy)
+ return id;
+ }
+ return -1;
+}
+
+int
+ProcLbxStartProxy (ClientPtr client)
+{
+ REQUEST(xLbxStartProxyReq);
+ LbxProxyPtr proxy;
+ LbxClientPtr lbxClient;
+ int reqlen;
+ int replylen;
+ xLbxStartReply *replybuf;
+ LbxNegOptsRec negopt;
+ register int n;
+ pointer compHandle = NULL;
+
+ REQUEST_AT_LEAST_SIZE(xLbxStartProxyReq);
+ if (lbxClients[client->index])
+ return BadLbxClientCode;
+ proxy = (LbxProxyPtr) xalloc (sizeof (LbxProxyRec));
+ if (!proxy)
+ return BadAlloc;
+ bzero(proxy, sizeof (LbxProxyRec));
+ proxy->pid = NextProxyID();
+ if (proxy->pid < 0) { /* too many proxies */
+ xfree(proxy);
+ return BadAlloc;
+ }
+ proxy->uid = ++uid_seed;
+ if (!proxyList)
+ AddCallback(&ReplyCallback, LbxReplyCallback, NULL);
+
+ if(!proxyList)
+ proxyList = proxy;
+ else{
+ proxy->next = proxyList;
+ proxyList = proxy;
+ }
+
+ /*
+ * Don't know exactly how big the reply will be, but it won't be
+ * bigger than the request
+ */
+ reqlen = client->req_len << 2;
+ replybuf = (xLbxStartReply *) xalloc(max(reqlen, sz_xLbxStartReply));
+ if (!replybuf) {
+ LbxFreeProxy(proxy);
+ return BadAlloc;
+ }
+
+ LbxOptionInit(&negopt);
+
+ replylen = LbxOptionParse(&negopt,
+ (unsigned char *)&stuff[1],
+ reqlen - sz_xLbxStartProxyReq,
+ (unsigned char *)&replybuf->optDataStart);
+ if (replylen < 0) {
+ /*
+ * Didn't understand option format, so we'll just end up
+ * using the defaults. Set nopts so that the proxy will
+ * be informed that we rejected the options because of
+ * decoding problems.
+ */
+ LbxOptionInit(&negopt);
+ negopt.nopts = 0xff;
+ replylen = 0;
+ }
+
+ if (LBXInitDeltaCache(&proxy->indeltas, negopt.proxyDeltaN,
+ negopt.proxyDeltaMaxLen) < 0
+ ||
+ LBXInitDeltaCache(&proxy->outdeltas, negopt.serverDeltaN,
+ negopt.serverDeltaMaxLen) < 0) {
+ LbxFreeProxy(proxy);
+ xfree(replybuf);
+ return BadAlloc;
+ }
+
+ n = 0;
+ if (negopt.proxyDeltaN)
+ n = negopt.proxyDeltaMaxLen;
+ if (negopt.serverDeltaN && negopt.serverDeltaMaxLen > n)
+ n = negopt.serverDeltaMaxLen;
+ if (n &&
+ (!(proxy->iDeltaBuf = (char *)xalloc (n)) ||
+ !(proxy->replyBuf = (char *)xalloc (n)) ||
+ !(proxy->oDeltaBuf = (char *)xalloc (n)))) {
+ LbxFreeProxy(proxy);
+ xfree(replybuf);
+ return BadAlloc;
+ }
+
+ MakeClientGrabImpervious(client); /* proxy needs to be grab-proof */
+ proxy->fd = ClientConnectionNumber(client);
+ if (negopt.streamOpts.streamCompInit) {
+ compHandle =
+ (*negopt.streamOpts.streamCompInit)(proxy->fd, negopt.streamOpts.streamCompArg);
+ if (!compHandle) {
+ LbxFreeProxy(proxy);
+ xfree(replybuf);
+ return BadAlloc;
+ }
+ }
+ proxy->ofirst = NULL;
+ proxy->olast = NULL;
+ if (!LbxInitClient (proxy, client, 0))
+ {
+ LbxFreeProxy(proxy);
+ xfree(replybuf);
+ return BadAlloc;
+ }
+ proxy->dosquishing = negopt.squish;
+ proxy->numBitmapCompMethods = negopt.numBitmapCompMethods;
+ proxy->bitmapCompMethods = negopt.bitmapCompMethods;
+ proxy->numPixmapCompMethods = negopt.numPixmapCompMethods;
+ proxy->pixmapCompMethods = negopt.pixmapCompMethods;
+ proxy->pixmapCompDepths = negopt.pixmapCompDepths;
+
+ proxy->streamOpts = negopt.streamOpts;
+ proxy->useTags = negopt.useTags;
+
+ proxy->grabbedCmaps = NULL;
+
+ /* send reply */
+ replybuf->type = X_Reply;
+ replybuf->nOpts = negopt.nopts;
+ replybuf->sequenceNumber = client->sequence;
+
+ replylen += sz_xLbxStartReplyHdr;
+ if (replylen < sz_xLbxStartReply)
+ replylen = sz_xLbxStartReply;
+ replybuf->length = (replylen - sz_xLbxStartReply + 3) >> 2;
+ if (client->swapped) {
+ swaps(&replybuf->sequenceNumber, n);
+ swapl(&replybuf->length, n);
+ }
+ lbxClient = LbxClient(client);
+ WriteToClient(client, replylen, (char *)replybuf);
+
+ LbxProxyConnection(client, proxy);
+ lbxClient = proxy->lbxClients[0];
+ proxy->curDix = lbxClient;
+ proxy->curRecv = lbxClient;
+ proxy->compHandle = compHandle;
+
+ if (proxy->compHandle && !lbxCompressWorkProcCount++)
+ QueueWorkProc(LbxCheckCompressInput, NULL, NULL);
+
+ xfree(replybuf);
+ return Success;
+}
+
+int
+ProcLbxStopProxy(ClientPtr client)
+{
+ /* REQUEST(xLbxStopProxyReq); */
+ LbxProxyPtr proxy;
+ LbxClientPtr lbxClient = LbxClient(client);
+
+ REQUEST_SIZE_MATCH(xLbxStopProxyReq);
+
+ if (!lbxClient)
+ return BadLbxClientCode;
+ if (lbxClient->id)
+ return BadLbxClientCode;
+
+ proxy = lbxClient->proxy;
+ LbxFreeClient (client);
+ LbxShutdownProxy (proxy);
+ return Success;
+}
+
+int
+ProcLbxSwitch(ClientPtr client)
+{
+ REQUEST(xLbxSwitchReq);
+ LbxProxyPtr proxy = LbxMaybeProxy(client);
+ LbxClientPtr lbxClient;
+ int i;
+
+ REQUEST_SIZE_MATCH(xLbxSwitchReq);
+ if (!proxy)
+ return BadLbxClientCode;
+ for (i = 0; i <= proxy->maxIndex; i++) {
+ lbxClient = proxy->lbxClients[i];
+ if (lbxClient && lbxClient->id == stuff->client) {
+ LbxSwitchRecv (proxy, lbxClient);
+ return Success;
+ }
+ }
+ LbxSwitchRecv (proxy, NULL);
+ return BadLbxClientCode;
+}
+
+int
+ProcLbxBeginLargeRequest(ClientPtr client)
+{
+ REQUEST(xLbxBeginLargeRequestReq);
+
+ client->sequence--;
+ REQUEST_SIZE_MATCH(xLbxBeginLargeRequestReq);
+ if (!AllocateLargeReqBuffer(client, stuff->largeReqLength << 2))
+ return BadAlloc;
+ return Success;
+}
+
+
+int
+ProcLbxLargeRequestData(ClientPtr client)
+{
+ REQUEST(xLbxLargeRequestDataReq);
+
+ client->sequence--;
+ REQUEST_AT_LEAST_SIZE(xLbxLargeRequestDataReq);
+ if (!AddToLargeReqBuffer(client, (char *) (stuff + 1),
+ (client->req_len - 1) << 2))
+ return BadAlloc;
+ return Success;
+}
+
+
+int
+ProcLbxEndLargeRequest(ClientPtr client)
+{
+ /* REQUEST(xReq); */
+
+ client->sequence--;
+ REQUEST_SIZE_MATCH(xReq);
+ return BadAlloc;
+}
+
+
+int
+ProcLbxInternAtoms(ClientPtr client)
+{
+ REQUEST(xLbxInternAtomsReq);
+ LbxClientPtr lbxClient = LbxClient(client);
+ xLbxInternAtomsReply *replyRet;
+ char *ptr = (char *) stuff + sz_xLbxInternAtomsReq;
+ Atom *atomsRet;
+ int replyLen, i;
+ char lenbuf[2];
+ CARD16 len;
+ char n;
+
+ REQUEST_AT_LEAST_SIZE(xLbxInternAtomsReq);
+
+ if (!lbxClient)
+ return BadLbxClientCode;
+ if (lbxClient->id)
+ return BadLbxClientCode;
+
+ replyLen = sz_xLbxInternAtomsReplyHdr + stuff->num * sizeof (Atom);
+ if (replyLen < sz_xLbxInternAtomsReply)
+ replyLen = sz_xLbxInternAtomsReply;
+
+ if (!(replyRet = (xLbxInternAtomsReply *) xalloc (replyLen)))
+ return BadAlloc;
+
+ atomsRet = (Atom *) ((char *) replyRet + sz_xLbxInternAtomsReplyHdr);
+
+ for (i = 0; i < stuff->num; i++)
+ {
+ lenbuf[0] = ptr[0];
+ lenbuf[1] = ptr[1];
+ len = *((CARD16 *) lenbuf);
+ ptr += 2;
+
+ if ((atomsRet[i] = MakeAtom (ptr, len, TRUE)) == BAD_RESOURCE)
+ {
+ xfree (replyRet);
+ return BadAlloc;
+ }
+
+ ptr += len;
+ }
+
+ if (client->swapped)
+ for (i = 0; i < stuff->num; i++)
+ swapl (&atomsRet[i], n);
+
+ replyRet->type = X_Reply;
+ replyRet->sequenceNumber = client->sequence;
+ replyRet->length = (replyLen - sz_xLbxInternAtomsReply + 3) >> 2;
+
+ if (client->swapped) {
+ swaps(&replyRet->sequenceNumber, n);
+ swapl(&replyRet->length, n);
+ }
+
+ WriteToClient (client, replyLen, (char *) replyRet);
+
+ xfree (replyRet);
+
+ return Success;
+}
+
+
+int
+ProcLbxGetWinAttrAndGeom(ClientPtr client)
+{
+ REQUEST(xLbxGetWinAttrAndGeomReq);
+ xGetWindowAttributesReply wa;
+ xGetGeometryReply wg;
+ xLbxGetWinAttrAndGeomReply reply;
+ WindowPtr pWin;
+ int status;
+
+ REQUEST_SIZE_MATCH(xLbxGetWinAttrAndGeomReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ GetWindowAttributes(pWin, client, &wa);
+
+ if ((status = GetGeometry(client, &wg)) != Success)
+ return status;
+
+ reply.type = X_Reply;
+ reply.length = (sz_xLbxGetWinAttrAndGeomReply - 32) >> 2;
+ reply.sequenceNumber = client->sequence;
+
+ reply.backingStore = wa.backingStore;
+ reply.visualID = wa.visualID;
+#if defined(__cplusplus) || defined(c_plusplus)
+ reply.c_class = wa.c_class;
+#else
+ reply.class = wa.class;
+#endif
+ reply.bitGravity = wa.bitGravity;
+ reply.winGravity = wa.winGravity;
+ reply.backingBitPlanes = wa.backingBitPlanes;
+ reply.backingPixel = wa.backingPixel;
+ reply.saveUnder = wa.saveUnder;
+ reply.mapInstalled = wa.mapInstalled;
+ reply.mapState = wa.mapState;
+ reply.override = wa.override;
+ reply.colormap = wa.colormap;
+ reply.allEventMasks = wa.allEventMasks;
+ reply.yourEventMask = wa.yourEventMask;
+ reply.doNotPropagateMask = wa.doNotPropagateMask;
+ reply.pad1 = 0;
+ reply.root = wg.root;
+ reply.x = wg.x;
+ reply.y = wg.y;
+ reply.width = wg.width;
+ reply.height = wg.height;
+ reply.borderWidth = wg.borderWidth;
+ reply.depth = wg.depth;
+ reply.pad2 = 0;
+
+ if (client->swapped)
+ {
+ register char n;
+
+ swaps(&reply.sequenceNumber, n);
+ swapl(&reply.length, n);
+ swapl(&reply.visualID, n);
+ swaps(&reply.class, n);
+ swapl(&reply.backingBitPlanes, n);
+ swapl(&reply.backingPixel, n);
+ swapl(&reply.colormap, n);
+ swapl(&reply.allEventMasks, n);
+ swapl(&reply.yourEventMask, n);
+ swaps(&reply.doNotPropagateMask, n);
+ swapl(&reply.root, n);
+ swaps(&reply.x, n);
+ swaps(&reply.y, n);
+ swaps(&reply.width, n);
+ swaps(&reply.height, n);
+ swaps(&reply.borderWidth, n);
+ }
+
+ WriteToClient(client, sizeof(xLbxGetWinAttrAndGeomReply), (char *)&reply);
+ return(client->noClientException);
+}
+
+int
+ProcLbxNewClient(ClientPtr client)
+{
+ REQUEST(xLbxNewClientReq);
+ ClientPtr newClient;
+ LbxProxyPtr proxy = LbxMaybeProxy(client);
+ CARD32 id;
+ int len, i;
+ char *setupbuf;
+ LbxClientPtr lbxClient;
+
+ REQUEST_AT_LEAST_SIZE(xLbxNewClientReq);
+
+ /* save info before our request disappears */
+ id = stuff->client;
+ if (!proxy || !id)
+ return BadLbxClientCode;
+ if (proxy->numClients == MAX_LBX_CLIENTS)
+ return BadAlloc;
+ for (i = 1; i <= proxy->maxIndex; i++) {
+ if (proxy->lbxClients[i] && proxy->lbxClients[i]->id == id)
+ return BadLbxClientCode;
+ }
+ len = (client->req_len << 2) - sizeof(xLbxNewClientReq);
+ setupbuf = (char *)xalloc (len);
+ if (!setupbuf)
+ return BadAlloc;
+ memcpy (setupbuf, (char *)&stuff[1], len);
+
+ newClient = AllocLbxClientConnection (client, proxy);
+ if (!newClient)
+ return BadAlloc;
+ newClient->requestVector = LbxInitialVector;
+ lbxClient = LbxInitClient (proxy, newClient, id);
+ if (!lbxClient)
+ {
+ CloseDownClient (newClient);
+ return BadAlloc;
+ }
+
+ AppendFakeRequest (newClient, setupbuf, len);
+ xfree (setupbuf);
+ LbxSetForBlock(lbxClient);
+
+ DBG (DBG_CLIENT, (stderr, "lbxNewClient X %d\n", newClient->index));
+ return Success;
+}
+
+int
+ProcLbxEstablishConnection(ClientPtr client)
+{
+ char *reason = NULL;
+ char *auth_proto, *auth_string;
+ register xConnClientPrefix *prefix;
+ REQUEST(xReq);
+
+ prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq);
+ auth_proto = (char *)prefix + sz_xConnClientPrefix;
+ auth_string = auth_proto + ((prefix->nbytesAuthProto + 3) & ~3);
+ if ((prefix->majorVersion != X_PROTOCOL) ||
+ (prefix->minorVersion != X_PROTOCOL_REVISION))
+ reason = "Protocol version mismatch";
+ else
+ reason = ClientAuthorized(client,
+ prefix->nbytesAuthProto,
+ auth_proto,
+ prefix->nbytesAuthString,
+ auth_string);
+
+ if (client->clientState == ClientStateCheckingSecurity ||
+ client->clientState == ClientStateAuthenticating)
+ return (client->noClientException = -1); /* XXX some day */
+ return(LbxSendConnSetup(client, reason));
+}
+
+int
+ProcLbxCloseClient (ClientPtr client)
+{
+ REQUEST(xLbxCloseClientReq);
+ LbxClientPtr lbxClient = LbxClient(client);
+
+ REQUEST_SIZE_MATCH(xLbxCloseClientReq);
+ if (!lbxClient || lbxClient->id != stuff->client)
+ return BadLbxClientCode;
+
+ /* this will cause the client to be closed down back in Dispatch() */
+ return(client->noClientException = CloseLbxClient);
+}
+
+int
+ProcLbxModifySequence (ClientPtr client)
+{
+ REQUEST(xLbxModifySequenceReq);
+
+ REQUEST_SIZE_MATCH(xLbxModifySequenceReq);
+ client->sequence += (stuff->adjust - 1); /* Dispatch() adds 1 */
+ return Success;
+}
+
+int
+ProcLbxAllowMotion (ClientPtr client)
+{
+ REQUEST(xLbxAllowMotionReq);
+
+ client->sequence--;
+ REQUEST_SIZE_MATCH(xLbxAllowMotionReq);
+ LbxAllowMotion(client, stuff->num);
+ return Success;
+}
+
+
+static int
+DecodeLbxDelta (ClientPtr client)
+{
+ REQUEST(xLbxDeltaReq);
+ LbxClientPtr lbxClient = LbxClient(client);
+ LbxProxyPtr proxy = lbxClient->proxy;
+ int len;
+ unsigned char *buf;
+
+ /* Note that LBXDecodeDelta decodes and adds current msg to the cache */
+ len = LBXDecodeDelta(&proxy->indeltas,
+ (xLbxDiffItem *)(((char *)stuff) + sz_xLbxDeltaReq),
+ stuff->diffs, stuff->cindex, &buf);
+ /*
+ * Some requests, such as FillPoly, result in the protocol input
+ * buffer being modified. So we need to copy the request
+ * into a temporary buffer where a write would be harmless.
+ * Maybe some day do this copying on a case by case basis,
+ * since not all requests are guilty of this.
+ */
+ memcpy(proxy->iDeltaBuf, buf, len);
+
+ client->requestBuffer = proxy->iDeltaBuf;
+ client->req_len = len >> 2;
+ return len;
+}
+
+int
+ProcLbxGetModifierMapping(ClientPtr client)
+{
+ /* REQUEST(xLbxGetModifierMappingReq); */
+
+ REQUEST_SIZE_MATCH(xLbxGetModifierMappingReq);
+ return LbxGetModifierMapping(client);
+}
+
+int
+ProcLbxGetKeyboardMapping(ClientPtr client)
+{
+ /* REQUEST(xLbxGetKeyboardMappingReq); */
+
+ REQUEST_SIZE_MATCH(xLbxGetKeyboardMappingReq);
+ return LbxGetKeyboardMapping(client);
+}
+
+int
+ProcLbxQueryFont(ClientPtr client)
+{
+ /* REQUEST(xLbxQueryFontReq); */
+
+ REQUEST_SIZE_MATCH(xLbxQueryFontReq);
+ return LbxQueryFont(client);
+}
+
+int
+ProcLbxChangeProperty(ClientPtr client)
+{
+ /* REQUEST(xLbxChangePropertyReq); */
+
+ REQUEST_SIZE_MATCH(xLbxChangePropertyReq);
+ return LbxChangeProperty(client);
+}
+
+int
+ProcLbxGetProperty(ClientPtr client)
+{
+ /* REQUEST(xLbxGetPropertyReq); */
+
+ REQUEST_SIZE_MATCH(xLbxGetPropertyReq);
+ return LbxGetProperty(client);
+}
+
+int
+ProcLbxTagData(ClientPtr client)
+{
+ REQUEST(xLbxTagDataReq);
+
+ client->sequence--; /* not a counted request */
+ REQUEST_AT_LEAST_SIZE(xLbxTagDataReq);
+
+ return LbxTagData(client, stuff->tag, stuff->real_length,
+ (pointer)&stuff[1]); /* better not give any errors */
+}
+
+int
+ProcLbxInvalidateTag(ClientPtr client)
+{
+ REQUEST(xLbxInvalidateTagReq);
+
+ client->sequence--;
+ REQUEST_SIZE_MATCH(xLbxInvalidateTagReq);
+ return LbxInvalidateTag(client, stuff->tag);
+}
+
+int
+ProcLbxPolyPoint(ClientPtr client)
+{
+ return LbxDecodePoly(client, X_PolyPoint, LbxDecodePoints);
+}
+
+int
+ProcLbxPolyLine(ClientPtr client)
+{
+ return LbxDecodePoly(client, X_PolyLine, LbxDecodePoints);
+}
+
+int
+ProcLbxPolySegment(ClientPtr client)
+{
+ return LbxDecodePoly(client, X_PolySegment, LbxDecodeSegment);
+}
+
+int
+ProcLbxPolyRectangle(ClientPtr client)
+{
+ return LbxDecodePoly(client, X_PolyRectangle, LbxDecodeRectangle);
+}
+
+int
+ProcLbxPolyArc(ClientPtr client)
+{
+ return LbxDecodePoly(client, X_PolyArc, LbxDecodeArc);
+}
+
+int
+ProcLbxFillPoly(ClientPtr client)
+{
+ return LbxDecodeFillPoly(client);
+}
+
+int
+ProcLbxPolyFillRectangle(ClientPtr client)
+{
+ return LbxDecodePoly(client, X_PolyFillRectangle, LbxDecodeRectangle);
+}
+
+int
+ProcLbxPolyFillArc(ClientPtr client)
+{
+ return LbxDecodePoly(client, X_PolyFillArc, LbxDecodeArc);
+}
+
+int
+ProcLbxCopyArea(ClientPtr client)
+{
+ return LbxDecodeCopyArea(client);
+}
+
+int
+ProcLbxCopyPlane(ClientPtr client)
+{
+ return LbxDecodeCopyPlane(client);
+}
+
+
+int
+ProcLbxPolyText(ClientPtr client)
+{
+ return LbxDecodePolyText(client);
+}
+
+int
+ProcLbxImageText(ClientPtr client)
+{
+ return LbxDecodeImageText(client);
+}
+
+int
+ProcLbxQueryExtension(ClientPtr client)
+{
+ REQUEST(xLbxQueryExtensionReq);
+ char *ename;
+
+ REQUEST_AT_LEAST_SIZE(xLbxQueryExtensionReq);
+ ename = (char *) &stuff[1];
+ return LbxQueryExtension(client, ename, stuff->nbytes);
+}
+
+int
+ProcLbxPutImage(ClientPtr client)
+{
+ return LbxDecodePutImage(client);
+}
+
+int
+ProcLbxGetImage(ClientPtr client)
+{
+ return LbxDecodeGetImage(client);
+}
+
+
+int
+ProcLbxSync(ClientPtr client)
+{
+ xLbxSyncReply reply;
+
+ client->sequence--; /* not a counted request */
+
+#ifdef COLOR_DEBUG
+ fprintf (stderr, "Got LBX sync, seq = 0x%x\n", client->sequence);
+#endif
+
+ reply.type = X_Reply;
+ reply.length = 0;
+ reply.sequenceNumber = client->sequence;
+ reply.pad0 = reply.pad1 = reply.pad2 = reply.pad3 = reply.pad4 =
+ reply.pad5 = reply.pad6 = 0;
+
+ if (client->swapped)
+ {
+ register char n;
+ swaps (&reply.sequenceNumber, n);
+ }
+
+ WriteToClient (client, sz_xLbxSyncReply, (char *)&reply);
+
+ return (client->noClientException);
+}
+
+
+int
+ProcLbxDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_LbxQueryVersion:
+ return ProcLbxQueryVersion(client);
+ case X_LbxStartProxy:
+ return ProcLbxStartProxy(client);
+ case X_LbxStopProxy:
+ return ProcLbxStopProxy(client);
+ case X_LbxNewClient:
+ return ProcLbxNewClient(client);
+ case X_LbxCloseClient:
+ return ProcLbxCloseClient(client);
+ case X_LbxModifySequence:
+ return ProcLbxModifySequence(client);
+ case X_LbxAllowMotion:
+ return ProcLbxAllowMotion(client);
+ case X_LbxIncrementPixel:
+ return ProcLbxIncrementPixel(client);
+ case X_LbxGrabCmap:
+ return ProcLbxGrabCmap(client);
+ case X_LbxReleaseCmap:
+ return ProcLbxReleaseCmap(client);
+ case X_LbxAllocColor:
+ return ProcLbxAllocColor(client);
+ case X_LbxGetModifierMapping:
+ return ProcLbxGetModifierMapping(client);
+ case X_LbxGetKeyboardMapping:
+ return ProcLbxGetKeyboardMapping(client);
+ case X_LbxInvalidateTag:
+ return ProcLbxInvalidateTag(client);
+ case X_LbxPolyPoint:
+ return ProcLbxPolyPoint (client);
+ case X_LbxPolyLine:
+ return ProcLbxPolyLine (client);
+ case X_LbxPolySegment:
+ return ProcLbxPolySegment (client);
+ case X_LbxPolyRectangle:
+ return ProcLbxPolyRectangle (client);
+ case X_LbxPolyArc:
+ return ProcLbxPolyArc (client);
+ case X_LbxFillPoly:
+ return ProcLbxFillPoly (client);
+ case X_LbxPolyFillRectangle:
+ return ProcLbxPolyFillRectangle (client);
+ case X_LbxPolyFillArc:
+ return ProcLbxPolyFillArc (client);
+ case X_LbxQueryFont:
+ return ProcLbxQueryFont (client);
+ case X_LbxChangeProperty:
+ return ProcLbxChangeProperty (client);
+ case X_LbxGetProperty:
+ return ProcLbxGetProperty (client);
+ case X_LbxTagData:
+ return ProcLbxTagData (client);
+ case X_LbxCopyArea:
+ return ProcLbxCopyArea (client);
+ case X_LbxCopyPlane:
+ return ProcLbxCopyPlane (client);
+ case X_LbxPolyText8:
+ case X_LbxPolyText16:
+ return ProcLbxPolyText (client);
+ case X_LbxImageText8:
+ case X_LbxImageText16:
+ return ProcLbxImageText (client);
+ case X_LbxQueryExtension:
+ return ProcLbxQueryExtension (client);
+ case X_LbxPutImage:
+ return ProcLbxPutImage (client);
+ case X_LbxGetImage:
+ return ProcLbxGetImage (client);
+ case X_LbxInternAtoms:
+ return ProcLbxInternAtoms(client);
+ case X_LbxGetWinAttrAndGeom:
+ return ProcLbxGetWinAttrAndGeom(client);
+ case X_LbxSync:
+ return ProcLbxSync(client);
+ case X_LbxBeginLargeRequest:
+ return ProcLbxBeginLargeRequest(client);
+ case X_LbxLargeRequestData:
+ return ProcLbxLargeRequestData(client);
+ case X_LbxEndLargeRequest:
+ return ProcLbxLargeRequestData(client);
+ default:
+ return BadRequest;
+ }
+}
diff --git a/nx-X11/programs/Xserver/lbx/lbxopts.c b/nx-X11/programs/Xserver/lbx/lbxopts.c
new file mode 100644
index 000000000..eac51bcea
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/lbxopts.c
@@ -0,0 +1,806 @@
+/* $Xorg: lbxopts.c,v 1.3 2000/08/17 19:53:31 cpqbld Exp $ */
+/*
+ * Copyright 1994 Network Computing Devices, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name Network Computing Devices, Inc. not be
+ * used in advertising or publicity pertaining to distribution of this
+ * software without specific, written prior permission.
+ *
+ * THIS SOFTWARE IS PROVIDED `AS-IS'. NETWORK COMPUTING DEVICES, INC.,
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
+ * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL NETWORK
+ * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
+ * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
+ * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
+ * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxopts.c,v 1.5 2001/01/17 22:37:00 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef OPTDEBUG
+#include <stdio.h>
+#endif
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "colormapst.h"
+#include "propertyst.h"
+#include "lbxserve.h"
+#include <X11/extensions/lbxstr.h>
+#include <X11/extensions/lbximage.h>
+#include <X11/extensions/lbxopts.h>
+#include "lbxsrvopts.h"
+#ifndef NO_ZLIB
+#include <X11/extensions/lbxzlib.h>
+#endif /* NO_ZLIB */
+
+static int LbxProxyDeltaOpt ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+static int LbxServerDeltaOpt ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+static int LbxDeltaOpt ( unsigned char *popt, int optlen,
+ unsigned char *preply, short *pn, short *pmaxlen );
+static int LbxStreamCompOpt ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+static int ZlibParse ( LbxNegOptsPtr pno, unsigned char *popt, int optlen,
+ unsigned char *preply );
+static int LbxMessageCompOpt ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+static int LbxUseTagsOpt ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+static int LbxBitmapCompOpt ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+static int LbxPixmapCompOpt ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+static int MergeDepths ( int *depths, LbxPixmapCompMethod *method );
+static int LbxCmapAllOpt ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+
+/*
+ * List of LBX options we recognize and are willing to negotiate
+ */
+static struct _LbxOptionParser {
+ CARD8 optcode;
+ int (*parser)(LbxNegOptsPtr, unsigned char *,
+ int, unsigned char *);
+} LbxOptions[] = {
+ { LBX_OPT_DELTA_PROXY, LbxProxyDeltaOpt },
+ { LBX_OPT_DELTA_SERVER, LbxServerDeltaOpt },
+ { LBX_OPT_STREAM_COMP, LbxStreamCompOpt },
+ { LBX_OPT_BITMAP_COMP, LbxBitmapCompOpt },
+ { LBX_OPT_PIXMAP_COMP, LbxPixmapCompOpt },
+ { LBX_OPT_MSG_COMP, LbxMessageCompOpt },
+ { LBX_OPT_USE_TAGS, LbxUseTagsOpt },
+ { LBX_OPT_CMAP_ALL, LbxCmapAllOpt }
+};
+
+#define LBX_N_OPTS (sizeof(LbxOptions) / sizeof(struct _LbxOptionParser))
+
+/*
+ * Set option defaults
+ */
+void
+LbxOptionInit(LbxNegOptsPtr pno)
+{
+ bzero(pno, sizeof(LbxNegOptsRec));
+ pno->proxyDeltaN = pno->serverDeltaN = LBX_OPT_DELTA_NCACHE_DFLT;
+ pno->proxyDeltaMaxLen = pno->serverDeltaMaxLen = LBX_OPT_DELTA_MSGLEN_DFLT;
+ pno->squish = TRUE;
+ pno->numBitmapCompMethods = 0;
+ pno->bitmapCompMethods = NULL;
+ pno->numPixmapCompMethods = 0;
+ pno->pixmapCompMethods = NULL;
+ pno->pixmapCompDepths = NULL;
+ pno->useTags = TRUE;
+}
+
+int
+LbxOptionParse(LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
+{
+ int i;
+ int nopts = *popt++;
+ unsigned char *pout = preply;
+
+ for (i = 0; i < nopts; i++) {
+ int j;
+ int len;
+ int hdrlen;
+ int replylen;
+
+ LBX_OPT_DECODE_LEN(popt + 1, len, hdrlen);
+ if (len < ++hdrlen || len > optlen) {
+#ifdef OPTDEBUG
+ fprintf(stderr, "bad option length, len = %d, hdrlen = %d, optlen = %d\n", len, hdrlen, optlen);
+#endif
+ return -1;
+ }
+
+ for (j = 0; j < LBX_N_OPTS; j++) {
+ if (popt[0] == LbxOptions[j].optcode) {
+ replylen = (*LbxOptions[j].parser)(pno,
+ popt + hdrlen,
+ len - hdrlen,
+ pout + LBX_OPT_SMALLHDR_LEN);
+ if (replylen < 0)
+ return -1;
+ else if (replylen > 0) {
+ /*
+ * None of the current options require big headers,
+ * so this works for now.
+ */
+ *pout++ = i;
+ *pout++ = LBX_OPT_SMALLHDR_LEN + replylen;
+ pout += replylen;
+ pno->nopts++;
+ }
+ break;
+ }
+ }
+
+ optlen -= len;
+ popt += len;
+ }
+
+ return (pout - preply);
+}
+
+static int
+LbxProxyDeltaOpt(LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
+{
+ return LbxDeltaOpt(popt, optlen, preply,
+ &pno->proxyDeltaN, &pno->proxyDeltaMaxLen);
+}
+
+static int
+LbxServerDeltaOpt(LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
+{
+ return LbxDeltaOpt(popt, optlen, preply,
+ &pno->serverDeltaN, &pno->serverDeltaMaxLen);
+}
+
+static int
+LbxDeltaOpt(unsigned char *popt,
+ int optlen,
+ unsigned char *preply,
+ short *pn,
+ short *pmaxlen)
+{
+ short n;
+ short maxlen;
+
+ /*
+ * If there's more data than we expect, we just ignore it.
+ */
+ if (optlen < LBX_OPT_DELTA_REQLEN) {
+#ifdef OPTDEBUG
+ fprintf(stderr, "bad delta option length = %d\n", optlen);
+#endif
+ return -1;
+ }
+
+ /*
+ * Accept whatever value the proxy prefers, so skip the
+ * min/max offerings. Note that the max message len value is
+ * encoded as the number of 4-byte values.
+ */
+ popt += 2;
+ n = *popt++;
+ popt += 2;
+ maxlen = *popt++;
+ if ((maxlen <<= 2) == 0)
+ n = 0;
+ else if (maxlen < 32) {
+#ifdef OPTDEBUG
+ fprintf(stderr, "bad delta max msg length %d\n", maxlen);
+#endif
+ return -1;
+ }
+
+ /*
+ * Put the response in the reply buffer
+ */
+ *preply++ = n;
+ *preply++ = maxlen >> 2;
+
+ *pn = n;
+ *pmaxlen = maxlen;
+
+ return LBX_OPT_DELTA_REPLYLEN;
+}
+
+
+static struct _LbxStreamCompParser {
+ int typelen;
+ char *type;
+ int (*parser)(LbxNegOptsPtr, unsigned char *,
+ int, unsigned char *);
+} LbxStreamComp[] = {
+#ifndef NO_ZLIB
+ { ZLIB_STRCOMP_OPT_LEN, ZLIB_STRCOMP_OPT, ZlibParse },
+#endif /* NO_ZLIB */
+};
+
+#define LBX_N_STRCOMP \
+ (sizeof(LbxStreamComp) / sizeof(struct _LbxStreamCompParser))
+
+static int
+LbxStreamCompOpt(LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
+{
+ int i;
+ int typelen;
+ int nopts = *popt++;
+
+ for (i = 0; i < nopts; i++) {
+ int j;
+ int len;
+ int lensize;
+ int replylen;
+
+ typelen = popt[0];
+ for (j = 0; j < LBX_N_STRCOMP; j++) {
+ if (typelen == LbxStreamComp[j].typelen &&
+ !strncmp((char *) popt + 1, LbxStreamComp[j].type, typelen))
+ break;
+ }
+
+ popt += 1 + typelen;
+ optlen -= 1 + typelen;
+ LBX_OPT_DECODE_LEN(popt, len, lensize);
+
+ if (j < LBX_N_STRCOMP) {
+ if (len > optlen)
+ return -1;
+ replylen = (*LbxStreamComp[j].parser)(pno,
+ popt + lensize,
+ len - lensize,
+ preply + 1);
+ if (replylen == -1)
+ return -1;
+ else if (replylen >= 0) {
+ *preply = i;
+ return replylen + 1;
+ }
+ }
+
+ optlen -= len;
+ popt += len;
+ }
+
+ return 0;
+}
+
+
+static int
+ZlibParse(LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
+{
+ int level; /* compression level */
+
+ if (*popt++ != 1) /* length should be 1 */
+ return (-1);
+
+ level = *popt;
+ if (level < 1 || level > 9)
+ return (-1);
+
+ pno->streamOpts.streamCompInit =
+ (LbxStreamCompHandle (*)(int, pointer))ZlibInit;
+ pno->streamOpts.streamCompArg = (pointer)(long)level;
+ pno->streamOpts.streamCompStuffInput = ZlibStuffInput;
+ pno->streamOpts.streamCompInputAvail = ZlibInputAvail;
+ pno->streamOpts.streamCompFlush = ZlibFlush;
+ pno->streamOpts.streamCompRead = ZlibRead;
+ pno->streamOpts.streamCompWriteV = ZlibWriteV;
+ pno->streamOpts.streamCompOn = ZlibCompressOn;
+ pno->streamOpts.streamCompOff = ZlibCompressOff;
+ pno->streamOpts.streamCompFreeHandle =
+ (void (*)(LbxStreamCompHandle))ZlibFree;
+
+ return (0);
+}
+
+static int
+LbxMessageCompOpt(LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
+{
+
+ if (optlen == 0) {
+#ifdef OPTDEBUG
+ fprintf(stderr, "bad message-comp option length specified %d\n", optlen);
+#endif
+ return -1;
+ }
+
+ pno->squish = *preply = *popt;
+ return 1;
+}
+
+
+static int
+LbxUseTagsOpt(LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
+{
+
+ if (optlen == 0) {
+#ifdef OPTDEBUG
+ fprintf(stderr, "bad use-tags option length specified %d\n", optlen);
+#endif
+ return -1;
+ }
+
+ pno->useTags = *preply = *popt;
+ return 1;
+}
+
+
+/*
+ * Option negotiation for image compression
+ */
+
+LbxBitmapCompMethod
+LbxBitmapCompMethods [] = {
+ {
+ "XC-FaxG42D", /* compression method name */
+ 0, /* inited */
+ 2, /* method opcode */
+ NULL, /* init function */
+ LbxImageEncodeFaxG42D, /* encode function */
+ LbxImageDecodeFaxG42D /* decode function */
+ }
+};
+
+#define NUM_BITMAP_METHODS \
+ (sizeof (LbxBitmapCompMethods) / sizeof (LbxBitmapCompMethod))
+
+
+#if 1
+/*
+ * Currently, we don't support any pixmap compression algorithms
+ * because regular stream compression does much better than PackBits.
+ * If we want to plug in a better pixmap image compression algorithm,
+ * it would go here.
+ */
+
+#define NUM_PIXMAP_METHODS 0
+LbxPixmapCompMethod LbxPixmapCompMethods [1]; /* dummy */
+
+#else
+
+LbxPixmapCompMethod
+LbxPixmapCompMethods [] = {
+ {
+ "XC-PackBits", /* compression method name */
+ 1 << ZPixmap, /* formats supported */
+ 1, {8}, /* depths supported */
+ 0, /* inited */
+ 1, /* method opcode */
+ NULL, /* init function */
+ LbxImageEncodePackBits, /* encode function */
+ LbxImageDecodePackBits /* decode function */
+ }
+};
+
+#define NUM_PIXMAP_METHODS \
+ (sizeof (LbxPixmapCompMethods) / sizeof (LbxPixmapCompMethod))
+#endif
+
+
+static int
+LbxImageCompOpt (Bool pixmap,
+ LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
+
+{
+ unsigned char *preplyStart = preply;
+ int numMethods = *popt++;
+ unsigned char *myIndices, *hisIndices;
+ unsigned int *retFormats = NULL;
+ int **retDepths = NULL;
+ int replyCount = 0;
+ int status, i, j;
+
+ if (numMethods == 0)
+ {
+ if (pixmap)
+ pno->numPixmapCompMethods = 0;
+ else
+ pno->numBitmapCompMethods = 0;
+
+ *preply++ = 0;
+ return (1);
+ }
+
+ myIndices = (unsigned char *) xalloc (numMethods);
+ hisIndices = (unsigned char *) xalloc (numMethods);
+
+ if (!myIndices || !hisIndices)
+ {
+ if (myIndices)
+ xfree (myIndices);
+ if (hisIndices)
+ xfree (hisIndices);
+ return -1;
+ }
+
+ if (pixmap)
+ {
+ retFormats = (unsigned *) xalloc (numMethods);
+ retDepths = (int **) xalloc (numMethods * sizeof (int *));
+
+ if (!retFormats || !retDepths)
+ {
+ if (retFormats)
+ xfree (retFormats);
+ if (retDepths)
+ xfree (retDepths);
+ xfree (myIndices);
+ xfree (hisIndices);
+ return -1;
+ }
+ }
+
+ /*
+ * For each method in the list sent by the proxy, see if the server
+ * supports this method. If YES, update the following lists:
+ *
+ * myIndices[] is a list of indices into the server's
+ * LbxBit[Pix]mapCompMethods table.
+ *
+ * hisIndices[] is a list of indices into the list of
+ * method names sent by the proxy.
+ *
+ * retFormats[] indicates for each pixmap compression method,
+ * the pixmap formats supported.
+ *
+ * retDepths[] indicates for each pixmap compression method,
+ * the pixmap depths supported.
+ */
+
+ for (i = 0; i < numMethods; i++)
+ {
+ unsigned int formatMask = 0, newFormatMask = 0;
+ int depthCount, *depths = NULL, len;
+ int freeDepths;
+ char *methodName;
+
+ freeDepths = 0;
+ len = *popt++;
+ methodName = (char *) popt;
+ popt += len;
+
+ if (pixmap)
+ {
+ formatMask = *popt++;
+ depthCount = *popt++;
+ depths = (int *) xalloc ((depthCount + 1) * sizeof (int));
+ freeDepths = 1;
+ depths[0] = depthCount;
+ for (j = 1; j <= depthCount; j++)
+ depths[j] = *popt++;
+ }
+
+ for (j = 0;
+ j < (pixmap ? NUM_PIXMAP_METHODS : NUM_BITMAP_METHODS); j++)
+ {
+
+ status = strncmp (methodName,
+ (pixmap ? LbxPixmapCompMethods[j].methodName :
+ LbxBitmapCompMethods[j].methodName),
+ len);
+
+ if (status == 0 && pixmap)
+ {
+ newFormatMask =
+ formatMask & LbxPixmapCompMethods[j].formatMask;
+
+ depthCount = MergeDepths (depths, &LbxPixmapCompMethods[j]);
+
+ if (newFormatMask == 0 || depthCount == 0)
+ status = 1;
+ }
+
+ if (status == 0)
+ {
+ myIndices[replyCount] = j;
+ hisIndices[replyCount] = i;
+
+ if (pixmap)
+ {
+ retFormats[replyCount] = newFormatMask;
+ retDepths[replyCount] = depths;
+ freeDepths = 0;
+ }
+
+ replyCount++;
+ break;
+ }
+ }
+
+ if (freeDepths)
+ xfree (depths);
+ }
+
+ *preply++ = replyCount;
+
+ /*
+ * Sort the lists by LBX server preference (increasing myIndices[] vals)
+ */
+
+ for (i = 0; i <= replyCount - 2; i++)
+ for (j = replyCount - 1; j >= i; j--)
+ if (myIndices[j - 1] > myIndices[j])
+ {
+ char temp1 = myIndices[j - 1];
+ char temp2 = hisIndices[j - 1];
+
+ myIndices[j - 1] = myIndices[j];
+ myIndices[j] = temp1;
+
+ hisIndices[j - 1] = hisIndices[j];
+ hisIndices[j] = temp2;
+
+ if (pixmap)
+ {
+ unsigned temp3 = retFormats[j - 1];
+ int *temp4 = retDepths[j - 1];
+
+ retFormats[j - 1] = retFormats[j];
+ retFormats[j] = temp3;
+
+ retDepths[j - 1] = retDepths[j];
+ retDepths[j] = temp4;
+ }
+ }
+
+ /*
+ * For each method supported, return to the proxy an index into
+ * the list sent by the proxy, the opcode to be used for the method,
+ * the pixmap formats supported, and the list of depths supported.
+ */
+
+ for (i = 0; i < replyCount; i++)
+ {
+ *preply++ = hisIndices[i];
+
+ if (pixmap)
+ {
+ int left;
+ *preply++ = LbxPixmapCompMethods[myIndices[i]].methodOpCode;
+ *preply++ = retFormats[i];
+ *preply++ = left = retDepths[i][0];
+ j = 1;
+ while (left > 0)
+ {
+ *preply++ = retDepths[i][j];
+ left--;
+ }
+ }
+ else
+ {
+ *preply++ = LbxBitmapCompMethods[myIndices[i]].methodOpCode;
+ }
+ }
+
+ if (pixmap)
+ {
+ pno->numPixmapCompMethods = replyCount;
+ pno->pixmapCompMethods = myIndices;
+ pno->pixmapCompDepths = retDepths;
+ }
+ else
+ {
+ pno->numBitmapCompMethods = replyCount;
+ pno->bitmapCompMethods = myIndices;
+ }
+
+ if (hisIndices)
+ xfree (hisIndices);
+
+ if (pixmap)
+ {
+ if (retFormats)
+ xfree (retFormats);
+ }
+
+ return (preply - preplyStart);
+}
+
+
+
+static int
+LbxBitmapCompOpt (LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
+
+{
+ return (LbxImageCompOpt (0 /* bitmap */, pno, popt, optlen, preply));
+}
+
+
+static int
+LbxPixmapCompOpt (LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
+
+{
+ return (LbxImageCompOpt (1 /* Pixmap */, pno, popt, optlen, preply));
+}
+
+
+LbxBitmapCompMethod *
+LbxSrvrLookupBitmapCompMethod (LbxProxyPtr proxy,
+ int methodOpCode)
+
+{
+ int i;
+
+ for (i = 0; i < proxy->numBitmapCompMethods; i++)
+ {
+ LbxBitmapCompMethod *method;
+
+ method = &LbxBitmapCompMethods[proxy->bitmapCompMethods[i]];
+
+ if (method->methodOpCode == methodOpCode)
+ return (method);
+ }
+
+ return (NULL);
+}
+
+
+LbxPixmapCompMethod *
+LbxSrvrLookupPixmapCompMethod (LbxProxyPtr proxy,
+ int methodOpCode)
+
+{
+ int i;
+
+ for (i = 0; i < proxy->numPixmapCompMethods; i++)
+ {
+ LbxPixmapCompMethod *method;
+
+ method = &LbxPixmapCompMethods[proxy->pixmapCompMethods[i]];
+
+ if (method->methodOpCode == methodOpCode)
+ return (method);
+ }
+
+ return (NULL);
+}
+
+
+LbxBitmapCompMethod *
+LbxSrvrFindPreferredBitmapCompMethod (LbxProxyPtr proxy)
+
+{
+ if (proxy->numBitmapCompMethods == 0)
+ return NULL;
+ else
+ return (&LbxBitmapCompMethods[proxy->bitmapCompMethods[0]]);
+}
+
+
+
+LbxPixmapCompMethod *
+LbxSrvrFindPreferredPixmapCompMethod (LbxProxyPtr proxy,
+ int format,
+ int depth)
+
+{
+ if (proxy->numPixmapCompMethods == 0)
+ return NULL;
+ else
+ {
+ LbxPixmapCompMethod *method;
+ int i, j;
+
+ for (i = 0; i < proxy->numPixmapCompMethods; i++)
+ {
+ method = &LbxPixmapCompMethods[proxy->pixmapCompMethods[i]];
+
+ if ((method->formatMask & (1 << format)))
+ {
+ int n = proxy->pixmapCompDepths[i][0];
+ j = 1;
+ while (n > 0)
+ {
+ if (depth == proxy->pixmapCompDepths[i][j])
+ return method;
+ else
+ n--;
+ }
+ }
+ }
+
+ return NULL;
+ }
+}
+
+
+static int
+MergeDepths (int *depths,
+ LbxPixmapCompMethod *method)
+
+{
+ int i, j, count;
+ int temp[LBX_MAX_DEPTHS + 1];
+
+ temp[0] = count = 0;
+
+ for (i = 1; i <= depths[0]; i++)
+ {
+ for (j = 0; j < method->depthCount; j++)
+ if (method->depths[j] == depths[i])
+ {
+ temp[0]++;
+ temp[++count] = depths[i];
+ break;
+ }
+ }
+
+ memcpy (depths, temp, (count + 1) * sizeof (int));
+
+ return (count);
+}
+
+
+#define LbxCmapAllMethod "XC-CMAP"
+
+static int
+LbxCmapAllOpt (LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
+
+{
+ int numMethods = *popt++;
+ int i;
+
+ for (i = 0; i < numMethods; i++)
+ {
+ int len;
+ char *methodName;
+
+ len = *popt++;
+ methodName = (char *) popt;
+ popt += len;
+ if (!strncmp(methodName, LbxCmapAllMethod, len))
+ break;
+ }
+ if (i >= numMethods)
+ i = 0; /* assume first one is proxy's favorite */
+ *preply = i;
+ return 1;
+}
diff --git a/nx-X11/programs/Xserver/lbx/lbxprop.c b/nx-X11/programs/Xserver/lbx/lbxprop.c
new file mode 100644
index 000000000..53c4ef424
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/lbxprop.c
@@ -0,0 +1,549 @@
+/* $Xorg: lbxprop.c,v 1.4 2001/02/09 02:05:17 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * Copyright 1993 Network Computing Devices, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name Network Computing Devices, Inc. not be
+ * used in advertising or publicity pertaining to distribution of this
+ * software without specific, written prior permission.
+ *
+ * THIS SOFTWARE IS PROVIDED `AS-IS'. NETWORK COMPUTING DEVICES, INC.,
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
+ * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL NETWORK
+ * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
+ * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
+ * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
+ * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxprop.c,v 1.4 2001/05/15 10:19:43 eich Exp $ */
+
+/* various bits of DIX-level mangling */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <sys/types.h>
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "servermd.h"
+#include "propertyst.h"
+#include "colormapst.h"
+#include "windowstr.h"
+#define _XLBX_SERVER_
+#include <X11/extensions/lbxstr.h>
+#include "lbxserve.h"
+#include "lbxtags.h"
+#include <X11/Xfuncproto.h>
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+#include "swaprep.h"
+
+void
+LbxStallPropRequest(ClientPtr client,
+ PropertyPtr pProp)
+{
+ xReq *req = (xReq *) client->requestBuffer;
+ register char n;
+
+ LbxQueryTagData(client, pProp->owner_pid,
+ pProp->tag_id, LbxTagTypeProperty);
+
+ /*
+ * Before we reset the request, we must make sure
+ * it is in the client's byte order.
+ */
+
+ if (client->swapped) {
+ if (req->reqType == X_ChangeProperty) {
+ xChangePropertyReq *stuff = (xChangePropertyReq *) req;
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ swapl(&stuff->property, n);
+ swapl(&stuff->type, n);
+ swapl(&stuff->nUnits, n);
+ switch ( stuff->format ) {
+ case 16:
+ SwapRestS(stuff);
+ break;
+ case 32:
+ SwapRestL(stuff);
+ break;
+ }
+ } else if (req->reqType == X_GetProperty) {
+ xGetPropertyReq *stuff = (xGetPropertyReq *) req;
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ swapl(&stuff->property, n);
+ swapl(&stuff->type, n);
+ swapl(&stuff->longOffset, n);
+ swapl(&stuff->longLength, n);
+ } else if (req->data == X_LbxChangeProperty) {
+ xLbxChangePropertyReq *stuff = (xLbxChangePropertyReq *) req;
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ swapl(&stuff->property, n);
+ swapl(&stuff->type, n);
+ swapl(&stuff->nUnits, n);
+ } else if (req->data == X_LbxGetProperty) {
+ xLbxGetPropertyReq *stuff = (xLbxGetPropertyReq *) req;
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ swapl(&stuff->property, n);
+ swapl(&stuff->type, n);
+ swapl(&stuff->longOffset, n);
+ swapl(&stuff->longLength, n);
+ }
+ }
+ ResetCurrentRequest(client);
+ client->sequence--;
+ IgnoreClient(client);
+}
+
+int
+LbxChangeWindowProperty(ClientPtr client,
+ WindowPtr pWin,
+ Atom property,
+ Atom type,
+ int format,
+ int mode,
+ unsigned long len,
+ Bool have_data,
+ pointer value,
+ Bool sendevent,
+ XID *tag)
+{
+ PropertyPtr pProp;
+ xEvent event;
+ int sizeInBytes;
+ int totalSize;
+ pointer data;
+
+ sizeInBytes = format >> 3;
+ totalSize = len * sizeInBytes;
+
+ /* first see if property already exists */
+
+ pProp = wUserProps(pWin);
+ while (pProp) {
+ if (pProp->propertyName == property)
+ break;
+ pProp = pProp->next;
+ }
+ if (!pProp) { /* just add to list */
+ if (!pWin->optional && !MakeWindowOptional(pWin))
+ return (BadAlloc);
+ pProp = (PropertyPtr) xalloc(sizeof(PropertyRec));
+ if (!pProp)
+ return (BadAlloc);
+ data = (pointer) xalloc(totalSize);
+ if (!data && len) {
+ xfree(pProp);
+ return (BadAlloc);
+ }
+ pProp->propertyName = property;
+ pProp->type = type;
+ pProp->format = format;
+ pProp->data = data;
+ if (have_data) {
+ if (len)
+ memmove((char *) data, (char *) value, totalSize);
+ pProp->tag_id = 0;
+ pProp->owner_pid = 0;
+ } else {
+ if (!TagSaveTag(LbxTagTypeProperty, totalSize,
+ (pointer)pProp, &pProp->tag_id)) {
+ xfree(pProp);
+ xfree(pProp->data);
+ return BadAlloc;
+ }
+ pProp->owner_pid = LbxProxyID(client);
+ TagMarkProxy(pProp->tag_id, pProp->owner_pid);
+ }
+ pProp->size = len;
+ pProp->next = pWin->optional->userProps;
+ pWin->optional->userProps = pProp;
+ } else {
+ /*
+ * To append or prepend to a property the request format and type must
+ * match those of the already defined property. The existing format
+ * and type are irrelevant when using the mode "PropModeReplace" since
+ * they will be written over.
+ */
+
+ if ((format != pProp->format) && (mode != PropModeReplace))
+ return (BadMatch);
+ if ((pProp->type != type) && (mode != PropModeReplace))
+ return (BadMatch);
+
+ /*
+ * if its a modify instead of replace, make sure we have the current
+ * value
+ */
+ if ((mode != PropModeReplace) && pProp->tag_id && pProp->owner_pid) {
+ LbxStallPropRequest(client, pProp);
+ return (client->noClientException);
+ }
+ /* make sure any old tag is flushed first */
+ if (pProp->tag_id)
+ TagDeleteTag(pProp->tag_id);
+ if (mode == PropModeReplace) {
+ if (totalSize != pProp->size * (pProp->format >> 3)) {
+ data = (pointer) xrealloc(pProp->data, totalSize);
+ if (!data && len)
+ return (BadAlloc);
+ pProp->data = data;
+ }
+ if (have_data) {
+ if (len)
+ memmove((char *) pProp->data, (char *) value, totalSize);
+ } else {
+ if (!TagSaveTag(LbxTagTypeProperty, totalSize,
+ (pointer)pProp, &pProp->tag_id)) {
+ xfree(pProp);
+ xfree(pProp->data);
+ return BadAlloc;
+ }
+ pProp->owner_pid = LbxProxyID(client);
+ TagMarkProxy(pProp->tag_id, pProp->owner_pid);
+ }
+ pProp->size = len;
+ pProp->type = type;
+ pProp->format = format;
+ } else if (len == 0) {
+ /* do nothing */
+ } else if (mode == PropModeAppend) {
+ data = (pointer) xrealloc(pProp->data,
+ sizeInBytes * (len + pProp->size));
+ if (!data)
+ return (BadAlloc);
+ pProp->data = data;
+ memmove(&((char *) data)[pProp->size * sizeInBytes],
+ (char *) value,
+ totalSize);
+ pProp->size += len;
+ } else if (mode == PropModePrepend) {
+ data = (pointer) xalloc(sizeInBytes * (len + pProp->size));
+ if (!data)
+ return (BadAlloc);
+ memmove(&((char *) data)[totalSize], (char *) pProp->data,
+ (int) (pProp->size * sizeInBytes));
+ memmove((char *) data, (char *) value, totalSize);
+ xfree(pProp->data);
+ pProp->data = data;
+ pProp->size += len;
+ }
+ }
+ if (sendevent) {
+ event.u.u.type = PropertyNotify;
+ event.u.property.window = pWin->drawable.id;
+ event.u.property.state = PropertyNewValue;
+ event.u.property.atom = pProp->propertyName;
+ event.u.property.time = currentTime.milliseconds;
+ DeliverEvents(pWin, &event, 1, (WindowPtr) NULL);
+ }
+ if (pProp->tag_id)
+ *tag = pProp->tag_id;
+ return (Success);
+}
+
+int
+LbxChangeProperty(ClientPtr client)
+{
+ WindowPtr pWin;
+ char format,
+ mode;
+ unsigned long len;
+ int err;
+ int n;
+ XID newtag;
+ xLbxChangePropertyReply rep;
+ REQUEST(xLbxChangePropertyReq);
+
+ REQUEST_SIZE_MATCH(xLbxChangePropertyReq);
+ UpdateCurrentTime();
+ format = stuff->format;
+ mode = stuff->mode;
+ if ((mode != PropModeReplace) && (mode != PropModeAppend) &&
+ (mode != PropModePrepend)) {
+ client->errorValue = mode;
+ return BadValue;
+ }
+ if ((format != 8) && (format != 16) && (format != 32)) {
+ client->errorValue = format;
+ return BadValue;
+ }
+ len = stuff->nUnits;
+ if (len > ((0xffffffff - sizeof(xChangePropertyReq)) >> 2))
+ return BadLength;
+
+ pWin = (WindowPtr) SecurityLookupWindow(stuff->window, client,
+ SecurityWriteAccess);
+ if (!pWin)
+ return (BadWindow);
+ if (!ValidAtom(stuff->property)) {
+ client->errorValue = stuff->property;
+ return (BadAtom);
+ }
+ if (!ValidAtom(stuff->type)) {
+ client->errorValue = stuff->type;
+ return (BadAtom);
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.pad = rep.pad0 = rep.pad1 = rep.pad2 = rep.pad3 = rep.pad4 = 0;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ }
+
+#ifdef XCSECURITY
+ switch (SecurityCheckPropertyAccess(client, pWin, stuff->property,
+ SecurityWriteAccess))
+ {
+ case SecurityErrorOperation:
+ client->errorValue = stuff->property;
+ return BadAtom;
+ case SecurityIgnoreOperation:
+ rep.tag = 0;
+ WriteToClient(client, sizeof(xLbxChangePropertyReply), (char *)&rep);
+ return client->noClientException;
+ }
+#endif
+
+ err = LbxChangeWindowProperty(client, pWin, stuff->property, stuff->type,
+ (int) format, (int) mode, len, FALSE, (pointer) &stuff[1],
+ TRUE, &newtag);
+ if (err)
+ return err;
+
+ rep.tag = newtag;
+
+ if (client->swapped) {
+ swapl(&rep.tag, n);
+ }
+ WriteToClient(client, sizeof(xLbxChangePropertyReply), (char *)&rep);
+
+ return client->noClientException;
+}
+
+static void
+LbxWriteGetpropReply(ClientPtr client,
+ xLbxGetPropertyReply *rep)
+{
+ int n;
+
+ if (client->swapped) {
+ swaps(&rep->sequenceNumber, n);
+ swapl(&rep->length, n);
+ swapl(&rep->propertyType, n);
+ swapl(&rep->bytesAfter, n);
+ swapl(&rep->nItems, n);
+ swapl(&rep->tag, n);
+ }
+ WriteToClient(client, sizeof(xLbxGetPropertyReply), (char *)rep);
+}
+
+int
+LbxGetProperty(ClientPtr client)
+{
+ PropertyPtr pProp,
+ prevProp;
+ unsigned long n,
+ len,
+ ind;
+ WindowPtr pWin;
+ xLbxGetPropertyReply reply;
+ Bool send_data = FALSE;
+
+ REQUEST(xLbxGetPropertyReq);
+
+ REQUEST_SIZE_MATCH(xLbxGetPropertyReq);
+
+ reply.pad1 = 0;
+ reply.pad2 = 0;
+
+ if (stuff->delete)
+ UpdateCurrentTime();
+ pWin = (WindowPtr) SecurityLookupWindow(stuff->window, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return (BadWindow);
+
+ if (!ValidAtom(stuff->property)) {
+ client->errorValue = stuff->property;
+ return (BadAtom);
+ }
+ if ((stuff->delete != xTrue) && (stuff->delete != xFalse)) {
+ client->errorValue = stuff->delete;
+ return (BadValue);
+ }
+ if ((stuff->type != AnyPropertyType) && !ValidAtom(stuff->type))
+ {
+ client->errorValue = stuff->type;
+ return(BadAtom);
+ }
+ pProp = wUserProps(pWin);
+ prevProp = (PropertyPtr) NULL;
+ while (pProp) {
+ if (pProp->propertyName == stuff->property)
+ break;
+ prevProp = pProp;
+ pProp = pProp->next;
+ }
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ if (!pProp) {
+ reply.nItems = 0;
+ reply.length = 0;
+ reply.bytesAfter = 0;
+ reply.propertyType = None;
+ reply.format = 0;
+ reply.tag = 0;
+ LbxWriteGetpropReply(client, &reply);
+ return client->noClientException;
+ }
+ /*
+ * If the request type and actual type don't match. Return the
+ * property information, but not the data.
+ */
+ if ((stuff->type != pProp->type) &&
+ (stuff->type != AnyPropertyType)) {
+ reply.bytesAfter = pProp->size;
+ reply.format = pProp->format;
+ reply.length = 0;
+ reply.nItems = 0;
+ reply.propertyType = pProp->type;
+ reply.tag = 0;
+ LbxWriteGetpropReply(client, &reply);
+ return client->noClientException;
+ }
+ /*
+ * Return type, format, value to client
+ */
+ n = (pProp->format >> 3) * pProp->size; /* size (bytes) of prop */
+ ind = stuff->longOffset << 2;
+
+ /*
+ * If longOffset is invalid such that it causes "len" to be
+ * negative, it's a value error.
+ */
+
+ if (n < ind) {
+ client->errorValue = stuff->longOffset;
+ return BadValue;
+ }
+
+ /* make sure we have the current value */
+ if (pProp->tag_id && pProp->owner_pid) {
+ LbxStallPropRequest(client, pProp);
+ return client->noClientException;
+ }
+
+ len = min(n - ind, stuff->longLength << 2);
+
+ reply.bytesAfter = n - (ind + len);
+ reply.format = pProp->format;
+ reply.propertyType = pProp->type;
+
+ if (!pProp->tag_id) {
+ if (n && (!stuff->delete || reply.bytesAfter)) {
+ TagSaveTag(LbxTagTypeProperty, n, (pointer)pProp, &pProp->tag_id);
+ pProp->owner_pid = 0;
+ }
+ send_data = TRUE;
+ } else
+ send_data = !TagProxyMarked(pProp->tag_id, LbxProxyID(client));
+ if (pProp->tag_id && send_data)
+ TagMarkProxy(pProp->tag_id, LbxProxyID(client));
+ reply.tag = pProp->tag_id;
+
+ if (!send_data)
+ len = 0;
+ else if (reply.tag) {
+ len = n;
+ ind = 0;
+ }
+ reply.nItems = len / (pProp->format >> 3);
+ reply.length = (len + 3) >> 2;
+
+ if (stuff->delete && (reply.bytesAfter == 0)) {
+ xEvent event;
+
+ event.u.u.type = PropertyNotify;
+ event.u.property.window = pWin->drawable.id;
+ event.u.property.state = PropertyDelete;
+ event.u.property.atom = pProp->propertyName;
+ event.u.property.time = currentTime.milliseconds;
+ DeliverEvents(pWin, &event, 1, (WindowPtr) NULL);
+ }
+ LbxWriteGetpropReply(client, &reply);
+ if (len) {
+ switch (reply.format) {
+ case 32:
+ client->pSwapReplyFunc = (ReplySwapPtr)CopySwap32Write;
+ break;
+ case 16:
+ client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write;
+ break;
+ default:
+ client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient;
+ break;
+ }
+ WriteSwappedDataToClient(client, len,
+ (char *) pProp->data + ind);
+ }
+ if (stuff->delete && (reply.bytesAfter == 0)) {
+ if (pProp->tag_id)
+ TagDeleteTag(pProp->tag_id);
+ if (prevProp == (PropertyPtr) NULL) {
+ if (!(pWin->optional->userProps = pProp->next))
+ CheckWindowOptionalNeed(pWin);
+ } else
+ prevProp->next = pProp->next;
+ xfree(pProp->data);
+ xfree(pProp);
+ }
+ return client->noClientException;
+}
diff --git a/nx-X11/programs/Xserver/lbx/lbxserve.h b/nx-X11/programs/Xserver/lbx/lbxserve.h
new file mode 100644
index 000000000..195e985b3
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/lbxserve.h
@@ -0,0 +1,289 @@
+/* $Xorg: lbxserve.h,v 1.4 2001/02/09 02:05:17 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * Copyright 1992 Network Computing Devices
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of NCD. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCD. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxserve.h,v 1.4 2001/08/01 00:44:58 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _LBXSERVE_H_
+
+#include "colormap.h"
+#include "property.h"
+
+#define _LBXSERVE_H_
+#define _XLBX_SERVER_
+#include <X11/extensions/lbxstr.h>
+#include <X11/extensions/lbxdeltastr.h>
+#include <X11/extensions/lbxopts.h>
+
+#define MAX_LBX_CLIENTS MAXCLIENTS
+#define MAX_NUM_PROXIES (MAXCLIENTS >> 1)
+
+typedef struct _LbxClient *LbxClientPtr;
+typedef struct _LbxProxy *LbxProxyPtr;
+
+typedef struct _LbxClient {
+ CARD32 id;
+ ClientPtr client;
+ LbxProxyPtr proxy;
+ Bool ignored;
+ Bool input_blocked;
+ int reqs_pending;
+ long bytes_in_reply;
+ long bytes_remaining;
+ Drawable drawableCache[GFX_CACHE_SIZE];
+ GContext gcontextCache[GFX_CACHE_SIZE];
+ pointer gfx_buffer; /* tmp buffer for unpacking gfx requests */
+ unsigned long gb_size;
+} LbxClientRec;
+
+typedef struct _connectionOutput *OSBufPtr;
+
+typedef struct _LbxProxy {
+ LbxProxyPtr next;
+ /* this array is indexed by lbx proxy index */
+ LbxClientPtr lbxClients[MAX_LBX_CLIENTS];
+ LbxClientPtr curRecv,
+ curDix;
+ int fd;
+ int pid; /* proxy ID */
+ int uid;
+ int numClients;
+ int maxIndex;
+ Bool aborted;
+ int grabClient;
+ pointer compHandle;
+ Bool dosquishing;
+ Bool useTags;
+ LBXDeltasRec indeltas;
+ LBXDeltasRec outdeltas;
+ char *iDeltaBuf;
+ char *replyBuf;
+ char *oDeltaBuf;
+ OSBufPtr ofirst;
+ OSBufPtr olast;
+ CARD32 cur_send_id;
+
+ LbxStreamOpts streamOpts;
+
+ int numBitmapCompMethods;
+ unsigned char *bitmapCompMethods; /* array of indices */
+ int numPixmapCompMethods;
+ unsigned char *pixmapCompMethods; /* array of indices */
+ int **pixmapCompDepths; /* depths supported from each method */
+
+ struct _ColormapRec *grabbedCmaps; /* chained via lbx private */
+ int motion_allowed_events;
+ lbxMotionCache motionCache;
+} LbxProxyRec;
+
+/* This array is indexed by server client index, not lbx proxy index */
+
+extern LbxClientPtr lbxClients[MAXCLIENTS];
+
+#define LbxClient(client) (lbxClients[(client)->index])
+#define LbxProxy(client) (LbxClient(client)->proxy)
+#define LbxMaybeProxy(client) (LbxClient(client) ? LbxProxy(client) : 0)
+#define LbxProxyID(client) (LbxProxy(client)->pid)
+#define LbxProxyClient(proxy) ((proxy)->lbxClients[0]->client)
+
+extern int LbxEventCode;
+
+
+/* os/connection.c */
+extern ClientPtr AllocLbxClientConnection ( ClientPtr client,
+ LbxProxyPtr proxy );
+extern void LbxProxyConnection ( ClientPtr client, LbxProxyPtr proxy );
+
+/* os/libxio.c */
+extern int UncompressedWriteToClient ( ClientPtr who, int count, char *buf );
+extern void LbxForceOutput ( LbxProxyPtr proxy );
+extern void SwitchClientInput ( ClientPtr client, Bool pending );
+extern int PrepareLargeReqBuffer ( ClientPtr client );
+extern Bool AppendFakeRequest ( ClientPtr client, char *data, int count );
+extern void LbxFreeOsBuffers ( LbxProxyPtr proxy );
+extern Bool AllocateLargeReqBuffer ( ClientPtr client, int size );
+extern Bool AddToLargeReqBuffer ( ClientPtr client, char *data, int size );
+extern void LbxPrimeInput ( ClientPtr client, LbxProxyPtr proxy );
+
+/* lbxcmap.c */
+extern int LbxCmapInit ( void );
+extern Bool LbxCheckColorRequest ( ClientPtr client, ColormapPtr pmap,
+ xReq *req );
+extern int LbxCheckCmapGrabbed ( ColormapPtr pmap );
+extern void LbxDisableSmartGrab ( ColormapPtr pmap );
+extern void LbxBeginFreeCellsEvent ( ColormapPtr pmap );
+extern void LbxAddFreeCellToEvent ( ColormapPtr pmap, Pixel pixel );
+extern void LbxEndFreeCellsEvent ( ColormapPtr pmap );
+extern void LbxSortPixelList ( Pixel *pixels, int count );
+extern int ProcLbxGrabCmap ( ClientPtr client );
+extern void LbxReleaseCmap ( ColormapPtr pmap, Bool smart );
+extern int ProcLbxReleaseCmap ( ClientPtr client );
+extern int ProcLbxAllocColor ( ClientPtr client );
+extern int ProcLbxIncrementPixel ( ClientPtr client );
+
+/* lbxdix.h */
+extern void LbxDixInit ( void );
+extern void LbxResetTags ( void );
+extern int LbxSendConnSetup ( ClientPtr client, char *reason );
+extern int LbxGetModifierMapping ( ClientPtr client );
+extern int LbxGetKeyboardMapping ( ClientPtr client );
+extern int LbxQueryFont ( ClientPtr client );
+extern int LbxTagData ( ClientPtr client, XID tag, unsigned long len,
+ pointer data );
+extern int LbxInvalidateTag ( ClientPtr client, XID tag );
+extern void LbxAllowMotion ( ClientPtr client, int num );
+extern void LbxFlushModifierMapTag ( void );
+extern void LbxFlushKeyboardMapTag ( void );
+extern void LbxFreeFontTag ( FontPtr pfont );
+extern void LbxSendInvalidateTag ( ClientPtr client, XID tag, int tagtype );
+extern Bool LbxFlushQTag ( XID tag );
+extern void ProcessQTagZombies ( void );
+extern void LbxQueryTagData ( ClientPtr client, int owner_pid, XID tag,
+ int tagtype );
+
+/* lbxexts.c */
+extern Bool LbxAddExtension ( char *name, int opcode, int ev_base,
+ int err_base );
+extern Bool LbxAddExtensionAlias ( int idx, char *alias );
+extern void LbxDeclareExtensionSecurity ( char *extname, Bool secure );
+extern Bool LbxRegisterExtensionGenerationMasks ( int idx, int num_reqs,
+ char *rep_mask,
+ char *ev_mask );
+extern int LbxQueryExtension ( ClientPtr client, char *ename, int nlen );
+extern void LbxCloseDownExtensions ( void );
+extern void LbxSetReqMask ( CARD8 *mask, int req, Bool on );
+
+/* lbxgfx.c */
+extern int LbxDecodePoly( ClientPtr client, CARD8 xreqtype,
+ int (*decode_rtn)(char *, char *, short *) );
+extern int LbxDecodeFillPoly ( ClientPtr client );
+extern int LbxDecodeCopyArea ( ClientPtr client );
+extern int LbxDecodeCopyPlane ( ClientPtr client );
+extern int LbxDecodePolyText ( ClientPtr client );
+extern int LbxDecodeImageText ( ClientPtr client );
+extern int LbxDecodePutImage ( ClientPtr client );
+extern int LbxDecodeGetImage ( ClientPtr client );
+extern int LbxDecodePoints ( char *in, char *inend, short *out );
+extern int LbxDecodeSegment ( char *in, char *inend, short *out );
+extern int LbxDecodeRectangle ( char *in, char *inend, short *out );
+extern int LbxDecodeArc ( char *in, char *inend, short *out );
+
+/* lbxmain.c */
+extern LbxProxyPtr LbxPidToProxy ( int pid );
+extern void LbxReencodeOutput ( ClientPtr client, char *pbuf, int *pcount,
+ char *cbuf, int *ccount );
+extern void LbxExtensionInit ( void );
+extern void LbxCloseClient ( ClientPtr client );
+extern void LbxSetForBlock ( LbxClientPtr lbxClient );
+extern int ProcLbxDispatch ( ClientPtr client );
+extern int ProcLbxSwitch ( ClientPtr client );
+extern int ProcLbxQueryVersion ( ClientPtr client );
+extern int ProcLbxStartProxy ( ClientPtr client );
+extern int ProcLbxStopProxy ( ClientPtr client );
+extern int ProcLbxBeginLargeRequest ( ClientPtr client );
+extern int ProcLbxLargeRequestData ( ClientPtr client );
+extern int ProcLbxEndLargeRequest ( ClientPtr client );
+extern int ProcLbxInternAtoms ( ClientPtr client );
+extern int ProcLbxGetWinAttrAndGeom ( ClientPtr client );
+extern int ProcLbxNewClient ( ClientPtr client );
+extern int ProcLbxEstablishConnection ( ClientPtr client );
+extern int ProcLbxCloseClient ( ClientPtr client );
+extern int ProcLbxModifySequence ( ClientPtr client );
+extern int ProcLbxAllowMotion ( ClientPtr client );
+extern int ProcLbxGetModifierMapping ( ClientPtr client );
+extern int ProcLbxGetKeyboardMapping ( ClientPtr client );
+extern int ProcLbxQueryFont ( ClientPtr client );
+extern int ProcLbxChangeProperty ( ClientPtr client );
+extern int ProcLbxGetProperty ( ClientPtr client );
+extern int ProcLbxTagData ( ClientPtr client );
+extern int ProcLbxInvalidateTag ( ClientPtr client );
+extern int ProcLbxPolyPoint ( ClientPtr client );
+extern int ProcLbxPolyLine ( ClientPtr client );
+extern int ProcLbxPolySegment ( ClientPtr client );
+extern int ProcLbxPolyRectangle ( ClientPtr client );
+extern int ProcLbxPolyArc ( ClientPtr client );
+extern int ProcLbxFillPoly ( ClientPtr client );
+extern int ProcLbxPolyFillRectangle ( ClientPtr client );
+extern int ProcLbxPolyFillArc ( ClientPtr client );
+extern int ProcLbxCopyArea ( ClientPtr client );
+extern int ProcLbxCopyPlane ( ClientPtr client );
+extern int ProcLbxPolyText ( ClientPtr client );
+extern int ProcLbxImageText ( ClientPtr client );
+extern int ProcLbxQueryExtension ( ClientPtr client );
+extern int ProcLbxPutImage ( ClientPtr client );
+extern int ProcLbxGetImage ( ClientPtr client );
+extern int ProcLbxSync ( ClientPtr client );
+
+/* lbxprop.c */
+extern int LbxChangeProperty ( ClientPtr client );
+extern int LbxGetProperty ( ClientPtr client );
+extern void LbxStallPropRequest ( ClientPtr client, PropertyPtr pProp );
+extern int LbxChangeWindowProperty ( ClientPtr client, WindowPtr pWin,
+ Atom property, Atom type, int format,
+ int mode, unsigned long len,
+ Bool have_data, pointer value,
+ Bool sendevent, XID *tag );
+/* lbxsquish.c */
+extern int LbxSquishEvent ( char *buf );
+
+/* lbwswap.c */
+extern int SProcLbxDispatch( ClientPtr client );
+extern int SProcLbxSwitch ( ClientPtr client );
+extern int SProcLbxBeginLargeRequest ( ClientPtr client );
+extern int SProcLbxLargeRequestData ( ClientPtr client );
+extern int SProcLbxEndLargeRequest ( ClientPtr client );
+extern void LbxWriteSConnSetupPrefix ( ClientPtr pClient,
+ xLbxConnSetupPrefix *pcsp );
+extern void LbxSwapFontInfo ( xLbxFontInfo *pr, Bool compressed );
+
+/* lbxzerorep.c */
+extern void ZeroReplyPadBytes ( char *buf, int reqType );
+
+#endif /* _LBXSERVE_H_ */
diff --git a/nx-X11/programs/Xserver/lbx/lbxsquish.c b/nx-X11/programs/Xserver/lbx/lbxsquish.c
new file mode 100644
index 000000000..8f1cad7c0
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/lbxsquish.c
@@ -0,0 +1,158 @@
+/* $Xorg: lbxsquish.c,v 1.4 2001/02/09 02:05:17 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * Copyright 1994 Network Computing Devices, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name Network Computing Devices, Inc. not be
+ * used in advertising or publicity pertaining to distribution of this
+ * software without specific, written prior permission.
+ *
+ * THIS SOFTWARE IS PROVIDED `AS-IS'. NETWORK COMPUTING DEVICES, INC.,
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
+ * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL NETWORK
+ * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
+ * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
+ * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
+ * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxsquish.c,v 1.3 2001/01/17 22:37:00 dawes Exp $ */
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xos.h>
+#include "misc.h"
+#include "colormapst.h"
+#include "propertyst.h"
+#include "lbxserve.h"
+#define _XLBX_SERVER_
+#include <X11/extensions/lbxstr.h>
+
+/* handles server-side protocol squishing */
+
+static char lbxevdelta[] = {
+ 0,
+ 0,
+ sz_xEvent - lbxsz_KeyButtonEvent,
+ sz_xEvent - lbxsz_KeyButtonEvent,
+ sz_xEvent - lbxsz_KeyButtonEvent,
+ sz_xEvent - lbxsz_KeyButtonEvent,
+ sz_xEvent - lbxsz_KeyButtonEvent,
+ sz_xEvent - lbxsz_EnterLeaveEvent,
+ sz_xEvent - lbxsz_EnterLeaveEvent,
+ sz_xEvent - lbxsz_FocusEvent,
+ sz_xEvent - lbxsz_FocusEvent,
+ sz_xEvent - lbxsz_KeymapEvent,
+ sz_xEvent - lbxsz_ExposeEvent,
+ sz_xEvent - lbxsz_GfxExposeEvent,
+ sz_xEvent - lbxsz_NoExposeEvent,
+ sz_xEvent - lbxsz_VisibilityEvent,
+ sz_xEvent - lbxsz_CreateNotifyEvent,
+ sz_xEvent - lbxsz_DestroyNotifyEvent,
+ sz_xEvent - lbxsz_UnmapNotifyEvent,
+ sz_xEvent - lbxsz_MapNotifyEvent,
+ sz_xEvent - lbxsz_MapRequestEvent,
+ sz_xEvent - lbxsz_ReparentEvent,
+ sz_xEvent - lbxsz_ConfigureNotifyEvent,
+ sz_xEvent - lbxsz_ConfigureRequestEvent,
+ sz_xEvent - lbxsz_GravityEvent,
+ sz_xEvent - lbxsz_ResizeRequestEvent,
+ sz_xEvent - lbxsz_CirculateEvent,
+ sz_xEvent - lbxsz_CirculateEvent,
+ sz_xEvent - lbxsz_PropertyEvent,
+ sz_xEvent - lbxsz_SelectionClearEvent,
+ sz_xEvent - lbxsz_SelectionRequestEvent,
+ sz_xEvent - lbxsz_SelectionNotifyEvent,
+ sz_xEvent - lbxsz_ColormapEvent,
+ sz_xEvent - lbxsz_ClientMessageEvent,
+ sz_xEvent - lbxsz_MappingNotifyEvent
+};
+
+static char lbxevpad[] = {
+ 0,
+ 0,
+ lbxsz_KeyButtonEvent - lbxupsz_KeyButtonEvent,
+ lbxsz_KeyButtonEvent - lbxupsz_KeyButtonEvent,
+ lbxsz_KeyButtonEvent - lbxupsz_KeyButtonEvent,
+ lbxsz_KeyButtonEvent - lbxupsz_KeyButtonEvent,
+ lbxsz_KeyButtonEvent - lbxupsz_KeyButtonEvent,
+ lbxsz_EnterLeaveEvent - lbxupsz_EnterLeaveEvent,
+ lbxsz_EnterLeaveEvent - lbxupsz_EnterLeaveEvent,
+ lbxsz_FocusEvent - lbxupsz_FocusEvent,
+ lbxsz_FocusEvent - lbxupsz_FocusEvent,
+ lbxsz_KeymapEvent - lbxupsz_KeymapEvent,
+ lbxsz_ExposeEvent - lbxupsz_ExposeEvent,
+ lbxsz_GfxExposeEvent - lbxupsz_GfxExposeEvent,
+ lbxsz_NoExposeEvent - lbxupsz_NoExposeEvent,
+ lbxsz_VisibilityEvent - lbxupsz_VisibilityEvent,
+ lbxsz_CreateNotifyEvent - lbxupsz_CreateNotifyEvent,
+ lbxsz_DestroyNotifyEvent - lbxupsz_DestroyNotifyEvent,
+ lbxsz_UnmapNotifyEvent - lbxupsz_UnmapNotifyEvent,
+ lbxsz_MapNotifyEvent - lbxupsz_MapNotifyEvent,
+ lbxsz_MapRequestEvent - lbxupsz_MapRequestEvent,
+ lbxsz_ReparentEvent - lbxupsz_ReparentEvent,
+ lbxsz_ConfigureNotifyEvent - lbxupsz_ConfigureNotifyEvent,
+ lbxsz_ConfigureRequestEvent - lbxupsz_ConfigureRequestEvent,
+ lbxsz_GravityEvent - lbxupsz_GravityEvent,
+ lbxsz_ResizeRequestEvent - lbxupsz_ResizeRequestEvent,
+ lbxsz_CirculateEvent - lbxupsz_CirculateEvent,
+ lbxsz_CirculateEvent - lbxupsz_CirculateEvent,
+ lbxsz_PropertyEvent - lbxupsz_PropertyEvent,
+ lbxsz_SelectionClearEvent - lbxupsz_SelectionClearEvent,
+ lbxsz_SelectionRequestEvent - lbxupsz_SelectionRequestEvent,
+ lbxsz_SelectionNotifyEvent - lbxupsz_SelectionNotifyEvent,
+ lbxsz_ColormapEvent - lbxupsz_ColormapEvent,
+ lbxsz_ClientMessageEvent - lbxupsz_ClientMessageEvent,
+ lbxsz_MappingNotifyEvent - lbxupsz_MappingNotifyEvent
+};
+
+int
+LbxSquishEvent(char *buf)
+{
+ int delta = lbxevdelta[((xEvent *)buf)->u.u.type];
+ int pad = lbxevpad[((xEvent *)buf)->u.u.type];
+
+ if (delta)
+ memmove(buf + delta, buf, sz_xEvent - delta);
+ if (pad) {
+ buf += sz_xEvent;
+ while (--pad >= 0)
+ *--buf = 0;
+ }
+ return delta;
+}
diff --git a/nx-X11/programs/Xserver/lbx/lbxsrvopts.h b/nx-X11/programs/Xserver/lbx/lbxsrvopts.h
new file mode 100644
index 000000000..9cf3d7630
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/lbxsrvopts.h
@@ -0,0 +1,67 @@
+/* $Xorg: lbxsrvopts.h,v 1.3 2000/08/17 19:53:31 cpqbld Exp $ */
+/*
+ * Copyright 1994 Network Computing Devices, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name Network Computing Devices, Inc. not be
+ * used in advertising or publicity pertaining to distribution of this
+ * software without specific, written prior permission.
+ *
+ * THIS SOFTWARE IS PROVIDED `AS-IS'. NETWORK COMPUTING DEVICES, INC.,
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
+ * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL NETWORK
+ * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
+ * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
+ * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
+ * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxsrvopts.h,v 1.2 2000/05/18 23:46:24 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _LBX_SRVOPTS_H_
+#define _LBX_SRVOPTS_H_
+
+#include <X11/extensions/lbxopts.h>
+
+typedef struct _LbxNegOpts {
+ int nopts;
+ short proxyDeltaN;
+ short proxyDeltaMaxLen;
+ short serverDeltaN;
+ short serverDeltaMaxLen;
+ LbxStreamOpts streamOpts;
+ int numBitmapCompMethods;
+ unsigned char *bitmapCompMethods; /* array of indices */
+ int numPixmapCompMethods;
+ unsigned char *pixmapCompMethods; /* array of indices */
+ int **pixmapCompDepths; /* depths supported from each method */
+ Bool squish;
+ Bool useTags;
+} LbxNegOptsRec;
+
+typedef LbxNegOptsRec *LbxNegOptsPtr;
+
+
+extern void LbxOptionInit ( LbxNegOptsPtr pno );
+extern int LbxOptionParse ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+extern LbxBitmapCompMethod *
+LbxSrvrLookupBitmapCompMethod ( LbxProxyPtr proxy, int methodOpCode );
+extern LbxPixmapCompMethod *
+LbxSrvrLookupPixmapCompMethod ( LbxProxyPtr proxy, int methodOpCode );
+extern LbxBitmapCompMethod *
+LbxSrvrFindPreferredBitmapCompMethod ( LbxProxyPtr proxy );
+extern LbxPixmapCompMethod *
+LbxSrvrFindPreferredPixmapCompMethod ( LbxProxyPtr proxy, int format, int depth );
+
+
+#endif /* _LBX_SRVOPTS_H_ */
diff --git a/nx-X11/programs/Xserver/lbx/lbxswap.c b/nx-X11/programs/Xserver/lbx/lbxswap.c
new file mode 100644
index 000000000..848be7f70
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/lbxswap.c
@@ -0,0 +1,828 @@
+/* $Xorg: lbxswap.c,v 1.4 2001/02/09 02:05:17 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * Copyright 1992 Network Computing Devices
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of NCD. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCD. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxswap.c,v 1.3 2001/01/17 22:37:00 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <sys/types.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xos.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#include "swaprep.h"
+#include "propertyst.h"
+#define _XLBX_SERVER_
+#include <X11/extensions/lbxstr.h>
+#include "lbxserve.h"
+#include <X11/Xfuncproto.h>
+
+#include <stdio.h>
+
+static int
+SProcLbxQueryVersion(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxQueryVersionReq);
+
+ swaps(&stuff->length, n);
+ return ProcLbxQueryVersion(client);
+}
+
+static int
+SProcLbxStartProxy(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxStartProxyReq);
+
+ swaps(&stuff->length, n);
+ return ProcLbxStartProxy(client);
+}
+
+static int
+SProcLbxStopProxy(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxStopProxyReq);
+
+ swaps(&stuff->length, n);
+ return ProcLbxStopProxy(client);
+}
+
+int
+SProcLbxSwitch(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxSwitchReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->client, n);
+ return ProcLbxSwitch(client);
+}
+
+int
+SProcLbxBeginLargeRequest (ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxBeginLargeRequestReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->largeReqLength, n);
+ return ProcLbxBeginLargeRequest(client);
+}
+
+int
+SProcLbxLargeRequestData (ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxLargeRequestDataReq);
+
+ swaps(&stuff->length, n);
+ return ProcLbxLargeRequestData(client);
+}
+
+int
+SProcLbxEndLargeRequest (ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxEndLargeRequestReq);
+
+ swaps(&stuff->length, n);
+ return ProcLbxEndLargeRequest(client);
+}
+
+static int
+SProcLbxNewClient(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxNewClientReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->client, n);
+ return ProcLbxNewClient(client);
+}
+
+static int
+SProcLbxCloseClient(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxCloseClientReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->client, n);
+ return ProcLbxCloseClient(client);
+}
+
+static int
+SProcLbxModifySequence(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxModifySequenceReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->adjust, n);
+ return ProcLbxModifySequence(client);
+}
+
+static int
+SProcLbxAllowMotion(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxAllowMotionReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->num, n);
+ return ProcLbxAllowMotion(client);
+}
+
+static int
+SProcLbxIncrementPixel(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxIncrementPixelReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->cmap, n);
+ swapl(&stuff->pixel, n);
+ return ProcLbxIncrementPixel(client);
+}
+
+static int
+SProcLbxGrabCmap(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxGrabCmapReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->cmap, n);
+
+ return ProcLbxGrabCmap(client);
+}
+
+static int
+SProcLbxReleaseCmap(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxReleaseCmapReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->cmap, n);
+
+ return ProcLbxReleaseCmap(client);
+}
+
+static int
+SProcLbxAllocColor(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxAllocColorReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->cmap, n);
+ swapl(&stuff->pixel, n);
+ swaps(&stuff->red, n);
+ swaps(&stuff->green, n);
+ swaps(&stuff->blue, n);
+
+ return ProcLbxAllocColor(client);
+}
+
+static int
+SProcLbxGetModifierMapping(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxGetModifierMappingReq);
+
+ swaps(&stuff->length, n);
+ return ProcLbxGetModifierMapping(client);
+}
+
+static int
+SProcLbxGetKeyboardMapping(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxGetKeyboardMappingReq);
+
+ swaps(&stuff->length, n);
+ return ProcLbxGetKeyboardMapping(client);
+}
+
+static int
+SProcLbxQueryFont(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxQueryFontReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->fid, n);
+ return ProcLbxQueryFont(client);
+}
+
+static int
+SProcLbxChangeProperty(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxChangePropertyReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xLbxChangePropertyReq);
+ swapl(&stuff->window, n);
+ swapl(&stuff->property, n);
+ swapl(&stuff->type, n);
+ swapl(&stuff->nUnits, n);
+ switch (stuff->format) {
+ case 8:
+ break;
+ case 16:
+ SwapRestS(stuff);
+ break;
+ case 32:
+ SwapRestL(stuff);
+ break;
+ }
+ return ProcLbxChangeProperty(client);
+}
+
+static int
+SProcLbxGetProperty(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxGetPropertyReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ swapl(&stuff->property, n);
+ swapl(&stuff->type, n);
+ swapl(&stuff->longOffset, n);
+ swapl(&stuff->longLength, n);
+ return ProcLbxGetProperty(client);
+}
+
+static int
+SProcLbxTagData(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxTagDataReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->tag, n);
+ swapl(&stuff->real_length, n);
+ return ProcLbxTagData(client);
+}
+
+static int
+SProcLbxInvalidateTag(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxInvalidateTagReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->tag, n);
+ return ProcLbxInvalidateTag(client);
+}
+
+static int
+SProcLbxPoly(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxPolyPointReq);
+ char *after;
+
+ swaps(&stuff->length, n);
+ after = ((char *) stuff) + SIZEOF(xLbxPolyPointReq);
+ if (GFXdCacheEnt (stuff->cacheEnts) == GFXCacheNone)
+ {
+ swapl (((Drawable *) after), n);
+ after += sizeof (Drawable);
+ }
+ if (GFXgCacheEnt (stuff->cacheEnts) == GFXCacheNone)
+ swapl (((GContext *) after), n);
+ return ProcLbxDispatch(client);
+}
+
+static int
+SProcLbxFillPoly(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxFillPolyReq);
+ char *after;
+
+ swaps(&stuff->length, n);
+ after = ((char *) stuff) + SIZEOF(xLbxFillPolyReq);
+ if (GFXdCacheEnt (stuff->cacheEnts) == GFXCacheNone)
+ {
+ swapl (((Drawable *) after), n);
+ after += sizeof (Drawable);
+ }
+ if (GFXgCacheEnt (stuff->cacheEnts) == GFXCacheNone)
+ swapl (((GContext *) after), n);
+ return ProcLbxFillPoly(client);
+}
+
+static int
+SProcLbxCopyArea(ClientPtr client)
+{
+ int n;
+
+ REQUEST(xLbxCopyAreaReq);
+ char *after;
+
+ swaps(&stuff->length, n);
+ after = ((char *) stuff) + SIZEOF(xLbxCopyAreaReq);
+ if (GFXdCacheEnt (stuff->srcCache) == GFXCacheNone)
+ {
+ swapl (((Drawable *) after), n);
+ after += sizeof (Drawable);
+ }
+ if (GFXdCacheEnt (stuff->cacheEnts) == GFXCacheNone)
+ {
+ swapl (((Drawable *) after), n);
+ after += sizeof (Drawable);
+ }
+ if (GFXgCacheEnt (stuff->cacheEnts) == GFXCacheNone)
+ swapl (((GContext *) after), n);
+ return ProcLbxCopyArea(client);
+}
+
+static int
+SProcLbxCopyPlane(ClientPtr client)
+{
+ int n;
+
+ REQUEST(xLbxCopyPlaneReq);
+ char *after;
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->bitPlane, n);
+ after = ((char *) stuff) + SIZEOF(xLbxCopyPlaneReq);
+ if (GFXdCacheEnt (stuff->srcCache) == GFXCacheNone)
+ {
+ swapl (((Drawable *) after), n);
+ after += sizeof (Drawable);
+ }
+ if (GFXdCacheEnt (stuff->cacheEnts) == GFXCacheNone)
+ {
+ swapl (((Drawable *) after), n);
+ after += sizeof (Drawable);
+ }
+ if (GFXgCacheEnt (stuff->cacheEnts) == GFXCacheNone)
+ swapl (((GContext *) after), n);
+ return ProcLbxCopyPlane(client);
+}
+
+static int
+SProcLbxPolyText(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxPolyTextReq);
+ char *after;
+
+ swaps(&stuff->length, n);
+ after = ((char *) stuff) + SIZEOF(xLbxPolyTextReq);
+ if (GFXdCacheEnt (stuff->cacheEnts) == GFXCacheNone)
+ {
+ swapl (((Drawable *) after), n);
+ after += sizeof (Drawable);
+ }
+ if (GFXgCacheEnt (stuff->cacheEnts) == GFXCacheNone)
+ swapl (((GContext *) after), n);
+ return ProcLbxDispatch(client);
+}
+
+static int
+SProcLbxImageText(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxImageTextReq);
+ char *after;
+
+ swaps(&stuff->length, n);
+ after = ((char *) stuff) + SIZEOF(xLbxImageTextReq);
+ if (GFXdCacheEnt (stuff->cacheEnts) == GFXCacheNone)
+ {
+ swapl (((Drawable *) after), n);
+ after += sizeof (Drawable);
+ }
+ if (GFXgCacheEnt (stuff->cacheEnts) == GFXCacheNone)
+ swapl (((GContext *) after), n);
+ return ProcLbxDispatch(client);
+}
+
+
+static int
+SProcLbxPutImage(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxPutImageReq);
+
+ swaps (&stuff->length, n);
+ return ProcLbxPutImage(client);
+}
+
+static int
+SProcLbxGetImage(ClientPtr client)
+{
+ register int n;
+
+ REQUEST(xLbxGetImageReq);
+
+ swaps (&stuff->length, n);
+ swapl (&stuff->drawable, n);
+ swaps (&stuff->x, n);
+ swaps (&stuff->y, n);
+ swaps (&stuff->width, n);
+ swaps (&stuff->height, n);
+ swapl (&stuff->planeMask, n);
+ return ProcLbxGetImage(client);
+}
+
+static int
+SProcLbxInternAtoms(ClientPtr client)
+{
+ register int n;
+ char *ptr;
+ char lenbuf[2];
+ CARD16 len;
+ int i;
+
+ REQUEST(xLbxInternAtomsReq);
+
+ swaps (&stuff->length, n);
+ swaps (&stuff->num, n);
+
+ ptr = (char *) stuff + sz_xLbxInternAtomsReq;
+ for (i = 0; i < stuff->num; i++)
+ {
+ swaps (ptr, n);
+ lenbuf[0] = ptr[0];
+ lenbuf[1] = ptr[1];
+ len = *((CARD16 *) lenbuf);
+ ptr += (len + 2);
+ }
+
+ return ProcLbxInternAtoms(client);
+}
+
+
+static int
+SProcLbxGetWinAttrAndGeom(ClientPtr client)
+{
+ int n;
+
+ REQUEST(xLbxGetWinAttrAndGeomReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->id, n);
+
+ return ProcLbxGetWinAttrAndGeom(client);
+}
+
+
+
+static int
+SProcLbxQueryExtension(ClientPtr client)
+{
+ int n;
+
+ REQUEST(xLbxQueryExtensionReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->nbytes, n);
+ return ProcLbxQueryExtension(client);
+}
+
+int
+SProcLbxDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+ switch (stuff->data) {
+ case X_LbxQueryVersion:
+ return SProcLbxQueryVersion(client);
+ case X_LbxStartProxy:
+ return SProcLbxStartProxy(client);
+ case X_LbxStopProxy:
+ return SProcLbxStopProxy(client);
+ case X_LbxNewClient:
+ return SProcLbxNewClient(client);
+ case X_LbxCloseClient:
+ return SProcLbxCloseClient(client);
+ case X_LbxModifySequence:
+ return SProcLbxModifySequence(client);
+ case X_LbxAllowMotion:
+ return SProcLbxAllowMotion(client);
+ case X_LbxIncrementPixel:
+ return SProcLbxIncrementPixel(client);
+ case X_LbxGrabCmap:
+ return SProcLbxGrabCmap(client);
+ case X_LbxReleaseCmap:
+ return SProcLbxReleaseCmap(client);
+ case X_LbxAllocColor:
+ return SProcLbxAllocColor(client);
+ case X_LbxGetModifierMapping:
+ return SProcLbxGetModifierMapping(client);
+ case X_LbxGetKeyboardMapping:
+ return SProcLbxGetKeyboardMapping(client);
+ case X_LbxInvalidateTag:
+ return SProcLbxInvalidateTag(client);
+ case X_LbxPolyPoint:
+ case X_LbxPolyLine:
+ case X_LbxPolySegment:
+ case X_LbxPolyRectangle:
+ case X_LbxPolyArc:
+ case X_LbxPolyFillRectangle:
+ case X_LbxPolyFillArc:
+ return SProcLbxPoly(client);
+ case X_LbxFillPoly:
+ return SProcLbxFillPoly(client);
+ case X_LbxQueryFont:
+ return SProcLbxQueryFont(client);
+ case X_LbxChangeProperty:
+ return SProcLbxChangeProperty(client);
+ case X_LbxGetProperty:
+ return SProcLbxGetProperty(client);
+ case X_LbxTagData:
+ return SProcLbxTagData(client);
+ case X_LbxCopyArea:
+ return SProcLbxCopyArea(client);
+ case X_LbxCopyPlane:
+ return SProcLbxCopyPlane(client);
+ case X_LbxPolyText8:
+ case X_LbxPolyText16:
+ return SProcLbxPolyText(client);
+ case X_LbxImageText8:
+ case X_LbxImageText16:
+ return SProcLbxImageText (client);
+ case X_LbxQueryExtension:
+ return SProcLbxQueryExtension(client);
+ case X_LbxPutImage:
+ return SProcLbxPutImage(client);
+ case X_LbxGetImage:
+ return SProcLbxGetImage(client);
+ case X_LbxInternAtoms:
+ return SProcLbxInternAtoms(client);
+ case X_LbxGetWinAttrAndGeom:
+ return SProcLbxGetWinAttrAndGeom(client);
+ case X_LbxSync:
+ return ProcLbxSync(client); /* nothing to swap */
+ case X_LbxBeginLargeRequest:
+ return SProcLbxBeginLargeRequest(client);
+ case X_LbxLargeRequestData:
+ return SProcLbxLargeRequestData(client);
+ default:
+ return BadRequest;
+ }
+}
+
+#ifdef notyet
+void
+LbxWriteSConnectionInfo(ClientPtr pClient,
+ unsigned long size,
+ char *pInfo)
+{
+ int i, j, k;
+ ScreenPtr pScreen;
+ DepthPtr pDepth;
+ char *pInfoT, *pInfoTBase;
+ xConnSetup *pConnSetup = (xConnSetup *)pInfo;
+
+ pInfoT = pInfoTBase = (char *) ALLOCATE_LOCAL(size);
+ if (!pInfoTBase)
+ {
+ pClient->noClientException = -1;
+ return;
+ }
+ SwapConnSetup(pConnSetup, (xConnSetup *)pInfoT);
+ pInfo += sizeof(xConnSetup);
+ pInfoT += sizeof(xConnSetup);
+
+ /* Copy the vendor string */
+ i = (pConnSetup->nbytesVendor + 3) & ~3;
+ memmove(pInfoT, pInfo, i);
+ pInfo += i;
+ pInfoT += i;
+
+ /* The Pixmap formats don't need to be swapped, just copied. */
+ i = sizeof(xPixmapFormat) * screenInfo.numPixmapFormats;
+ memmove(pInfoT, pInfo, i);
+ pInfo += i;
+ pInfoT += i;
+
+ for(i = 0; i < screenInfo.numScreens; i++)
+ {
+ pScreen = screenInfo.screens[i];
+ SwapWinRoot((xWindowRoot *)pInfo, (xWindowRoot *)pInfoT);
+ pInfo += sizeof(xWindowRoot);
+ pInfoT += sizeof(xWindowRoot);
+ pDepth = pScreen->allowedDepths;
+ for(j = 0; j < pScreen->numDepths; j++, pDepth++)
+ {
+ ((xDepth *)pInfoT)->depth = ((xDepth *)pInfo)->depth;
+ cpswaps(((xDepth *)pInfo)->nVisuals, ((xDepth *)pInfoT)->nVisuals);
+ pInfo += sizeof(xDepth);
+ pInfoT += sizeof(xDepth);
+ for(k = 0; k < pDepth->numVids; k++)
+ {
+ SwapVisual((xVisualType *)pInfo, (xVisualType *)pInfoT);
+ pInfo += sizeof(xVisualType);
+ pInfoT += sizeof(xVisualType);
+ }
+ }
+ }
+ (void)WriteToClient(pClient, (int)size, (char *) pInfoTBase);
+ DEALLOCATE_LOCAL(pInfoTBase);
+}
+
+void
+SwapConnSetup(xConnSetup *pConnSetup,
+ xConnSetup *pConnSetupT)
+{
+ cpswapl(pConnSetup->release, pConnSetupT->release);
+ cpswapl(pConnSetup->ridBase, pConnSetupT->ridBase);
+ cpswapl(pConnSetup->ridMask, pConnSetupT->ridMask);
+ cpswapl(pConnSetup->motionBufferSize, pConnSetupT->motionBufferSize);
+ cpswaps(pConnSetup->nbytesVendor, pConnSetupT->nbytesVendor);
+ cpswaps(pConnSetup->maxRequestSize, pConnSetupT->maxRequestSize);
+ pConnSetupT->minKeyCode = pConnSetup->minKeyCode;
+ pConnSetupT->maxKeyCode = pConnSetup->maxKeyCode;
+ pConnSetupT->numRoots = pConnSetup->numRoots;
+ pConnSetupT->numFormats = pConnSetup->numFormats;
+ pConnSetupT->imageByteOrder = pConnSetup->imageByteOrder;
+ pConnSetupT->bitmapBitOrder = pConnSetup->bitmapBitOrder;
+ pConnSetupT->bitmapScanlineUnit = pConnSetup->bitmapScanlineUnit;
+ pConnSetupT->bitmapScanlinePad = pConnSetup->bitmapScanlinePad;
+}
+
+void
+SwapWinRoot(xWindowRoot *pRoot,
+ xWindowRoot *pRootT)
+{
+ cpswapl(pRoot->windowId, pRootT->windowId);
+ cpswapl(pRoot->defaultColormap, pRootT->defaultColormap);
+ cpswapl(pRoot->whitePixel, pRootT->whitePixel);
+ cpswapl(pRoot->blackPixel, pRootT->blackPixel);
+ cpswapl(pRoot->currentInputMask, pRootT->currentInputMask);
+ cpswaps(pRoot->pixWidth, pRootT->pixWidth);
+ cpswaps(pRoot->pixHeight, pRootT->pixHeight);
+ cpswaps(pRoot->mmWidth, pRootT->mmWidth);
+ cpswaps(pRoot->mmHeight, pRootT->mmHeight);
+ cpswaps(pRoot->minInstalledMaps, pRootT->minInstalledMaps);
+ cpswaps(pRoot->maxInstalledMaps, pRootT->maxInstalledMaps);
+ cpswapl(pRoot->rootVisualID, pRootT->rootVisualID);
+ pRootT->backingStore = pRoot->backingStore;
+ pRootT->saveUnders = pRoot->saveUnders;
+ pRootT->rootDepth = pRoot->rootDepth;
+ pRootT->nDepths = pRoot->nDepths;
+}
+
+void
+SwapVisual(xVisualType *pVis,
+ xVisualType *pVisT;
+{
+ cpswapl(pVis->visualID, pVisT->visualID);
+ pVisT->class = pVis->class;
+ pVisT->bitsPerRGB = pVis->bitsPerRGB;
+ cpswaps(pVis->colormapEntries, pVisT->colormapEntries);
+ cpswapl(pVis->redMask, pVisT->redMask);
+ cpswapl(pVis->greenMask, pVisT->greenMask);
+ cpswapl(pVis->blueMask, pVisT->blueMask);
+}
+#endif
+
+void
+LbxWriteSConnSetupPrefix(ClientPtr pClient,
+ xLbxConnSetupPrefix *pcsp)
+{
+ xLbxConnSetupPrefix cspT;
+
+ cspT.success = pcsp->success;
+ cspT.changeType = pcsp->changeType;
+ cspT.length = pcsp->length;
+ cpswaps(pcsp->majorVersion, cspT.majorVersion);
+ cpswaps(pcsp->minorVersion, cspT.minorVersion);
+ cpswapl(pcsp->tag, cspT.tag);
+
+ (void)WriteToClient(pClient, sizeof(cspT), (char *) &cspT);
+}
+
+void
+LbxSwapFontInfo(xLbxFontInfo *pr,
+ Bool compressed)
+{
+ unsigned i;
+ xCharInfo *pxci;
+ unsigned nchars,
+ nprops;
+ char *pby;
+ register char n;
+
+ nchars = pr->nCharInfos;
+ nprops = pr->nFontProps;
+ swaps(&pr->minCharOrByte2, n);
+ swaps(&pr->maxCharOrByte2, n);
+ swaps(&pr->defaultChar, n);
+ swaps(&pr->nFontProps, n);
+ swaps(&pr->fontAscent, n);
+ swaps(&pr->fontDescent, n);
+ SwapCharInfo(&pr->minBounds);
+ SwapCharInfo(&pr->maxBounds);
+ swapl(&pr->nCharInfos, n);
+
+ pby = (char *) &pr[1];
+ /*
+ * Font properties are an atom and either an int32 or a CARD32, so they
+ * are always 2 4 byte values
+ */
+ for (i = 0; i < nprops; i++) {
+ swapl(pby, n);
+ pby += 4;
+ swapl(pby, n);
+ pby += 4;
+ }
+ if (!compressed) {
+ pxci = (xCharInfo *) pby;
+ for (i = 0; i < nchars; i++, pxci++)
+ SwapCharInfo(pxci);
+ } else {
+ SwapLongs((CARD32 *) pby, nchars);
+ }
+}
diff --git a/nx-X11/programs/Xserver/lbx/lbxtables.c b/nx-X11/programs/Xserver/lbx/lbxtables.c
new file mode 100644
index 000000000..5e8174eeb
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/lbxtables.c
@@ -0,0 +1,39 @@
+/* $Xorg: lbxtables.c,v 1.3 2000/08/17 19:53:32 cpqbld Exp $ */
+/*
+ * Copyright 1993 Network Computing Devices, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name Network Computing Devices, Inc. not be
+ * used in advertising or publicity pertaining to distribution of this
+ * software without specific, written prior permission.
+ *
+ * THIS SOFTWARE IS PROVIDED `AS-IS'. NETWORK COMPUTING DEVICES, INC.,
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
+ * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL NETWORK
+ * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
+ * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
+ * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
+ * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxtables.c,v 1.2 2000/05/18 23:46:24 dawes Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "dix.h"
+
+extern int ProcInitialConnection(ClientPtr client);
+extern int ProcLbxEstablishConnection(ClientPtr client);
+
+int (* LbxInitialVector[3]) (ClientPtr) =
+{
+ 0,
+ ProcInitialConnection,
+ ProcLbxEstablishConnection
+};
diff --git a/nx-X11/programs/Xserver/lbx/lbxtags.c b/nx-X11/programs/Xserver/lbx/lbxtags.c
new file mode 100644
index 000000000..84365b253
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/lbxtags.c
@@ -0,0 +1,237 @@
+/* $Xorg: lbxtags.c,v 1.4 2001/02/09 02:05:17 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * Copyright 1993 Network Computing Devices, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name Network Computing Devices, Inc. not be
+ * used in advertising or publicity pertaining to distribution of this
+ * software without specific, written prior permission.
+ *
+ * THIS SOFTWARE IS PROVIDED `AS-IS'. NETWORK COMPUTING DEVICES, INC.,
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
+ * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL NETWORK
+ * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
+ * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
+ * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
+ * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxtags.c,v 1.3 2001/01/17 22:37:00 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "lbxdata.h"
+#include "resource.h"
+#include "colormapst.h"
+#include "propertyst.h"
+#include "lbxtags.h"
+#define _XLBX_SERVER_
+#include <X11/extensions/lbxstr.h>
+#include "propertyst.h"
+
+static RESTYPE TagResType;
+
+extern int _lbx_fi_junklen;
+
+/* ARGSUSED */
+static int
+tag_free(pointer data,
+ XID id)
+{
+ TagData td = (TagData) data;
+ FontTagInfoPtr ftip;
+ char *t;
+
+ if (td->global)
+ *(td->global) = 0;
+ /* some types need to be freed, others are shared */
+ if (td->data_type == LbxTagTypeFont) {
+ /* remove any back links */
+ ftip = (FontTagInfoPtr) td->tdata;
+ FontSetPrivate(ftip->pfont, lbx_font_private, NULL);
+ t = (char *) ftip->fontinfo;
+ if (!ftip->compression) /* points to xQueryFont, so back up to it */
+ t -= _lbx_fi_junklen;
+ xfree(t);
+ xfree(ftip);
+ }
+ xfree(data);
+ return 0;
+}
+
+void
+TagInit(void)
+{
+ TagResType = CreateNewResourceType(tag_free);
+}
+
+XID
+TagNewTag(void)
+{
+ return FakeClientID(0);
+}
+
+void
+TagClearProxy(XID tid,
+ int pid)
+{
+ TagData td;
+
+ td = (TagData) LookupIDByType(tid, TagResType);
+ if (td)
+ td->sent_to_proxy[pid >> 3] &= ~(1 << (pid & 7));
+}
+
+void
+TagMarkProxy(XID tid,
+ int pid)
+{
+ TagData td;
+
+ td = (TagData) LookupIDByType(tid, TagResType);
+ td->sent_to_proxy[pid >> 3] |= 1 << (pid & 7);
+}
+
+Bool
+TagProxyMarked(XID tid,
+ int pid)
+{
+ TagData td;
+
+ td = (TagData) LookupIDByType(tid, TagResType);
+ return (td->sent_to_proxy[pid >> 3] & (1 << (pid & 7))) != 0;
+}
+
+XID
+TagSaveTag(int dtype,
+ int size,
+ pointer data,
+ XID *global)
+{
+ TagData td;
+
+ td = (TagData) xalloc(sizeof(TagDataRec));
+ if (!td) {
+ if (global)
+ *global = 0;
+ return 0;
+ }
+ bzero((char *) td->sent_to_proxy, (MAX_NUM_PROXIES + 7) / 8);
+ td->tid = TagNewTag();
+ td->data_type = dtype;
+ td->tdata = data;
+ td->size = size;
+ td->global = global;
+ if (!AddResource(td->tid, TagResType, (pointer) td))
+ return 0;
+ if (global)
+ *global = td->tid;
+ return td->tid;
+}
+
+void
+TagDeleteTag(XID tid)
+{
+ int pid;
+ TagData td;
+ LbxProxyPtr proxy;
+ ClientPtr client;
+ LbxClientPtr lbxcp;
+
+ td = (TagData) LookupIDByType(tid, TagResType);
+ if (!td) /* shouldn't happen, but play it safe */
+ return;
+ for (pid = 1; pid < MAX_NUM_PROXIES; pid++) {
+ if (td->sent_to_proxy[pid >> 3] & (1 << (pid & 7))) {
+ proxy = LbxPidToProxy(pid);
+ lbxcp = (proxy != NULL) ? proxy->lbxClients[0] : NULL;
+ if (lbxcp && (client = lbxcp->client))
+ LbxSendInvalidateTag(client, tid, td->data_type);
+ td->sent_to_proxy[pid >> 3] &= ~(1 << (pid & 7));
+ }
+ }
+ if (td->data_type != LbxTagTypeProperty || !LbxFlushQTag(tid))
+ FreeResource(tid, 0);
+ else if (td->global) {
+ *(td->global) = 0;
+ td->global = NULL;
+ }
+}
+
+TagData
+TagGetTag(XID tid)
+{
+ TagData td;
+
+ td = (TagData) LookupIDByType(tid, TagResType);
+ return td;
+}
+
+static void
+LbxFlushTag(pointer value,
+ XID tid,
+ pointer cdata)
+{
+ TagData td = (TagData)value;
+ LbxProxyPtr proxy = (LbxProxyPtr)cdata;
+ int i;
+
+ if ((td->data_type == LbxTagTypeProperty) && td->global) {
+ PropertyPtr pProp = (PropertyPtr)td->tdata;
+ if ((pProp->tag_id == tid) && (pProp->owner_pid == proxy->pid)) {
+ LbxFlushQTag(tid);
+ pProp->size = 0;
+ FreeResource(tid, 0);
+ return;
+ }
+ }
+ td->sent_to_proxy[proxy->pid >> 3] &= ~(1 << (proxy->pid & 7));
+ for (i = 0; i < (MAX_NUM_PROXIES + 7) / 8; i++) {
+ if (td->sent_to_proxy[i])
+ return;
+ }
+ FreeResource(tid, 0);
+}
+
+/*
+ * clear out markers for proxies
+ */
+void
+LbxFlushTags(LbxProxyPtr proxy)
+{
+ FindClientResourcesByType(NULL, TagResType, LbxFlushTag, (pointer)proxy);
+}
diff --git a/nx-X11/programs/Xserver/lbx/lbxtags.h b/nx-X11/programs/Xserver/lbx/lbxtags.h
new file mode 100644
index 000000000..8577bd93c
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/lbxtags.h
@@ -0,0 +1,86 @@
+/* $Xorg: lbxtags.h,v 1.4 2001/02/09 02:05:17 xorgcvs Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/*
+ * Copyright 1993 Network Computing Devices, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name Network Computing Devices, Inc. not be
+ * used in advertising or publicity pertaining to distribution of this
+ * software without specific, written prior permission.
+ *
+ * THIS SOFTWARE IS PROVIDED `AS-IS'. NETWORK COMPUTING DEVICES, INC.,
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
+ * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL NETWORK
+ * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
+ * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
+ * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
+ * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxtags.h,v 1.3 2001/01/17 22:37:00 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _LBXTAGS_H_
+#define _LBXTAGS_H_
+#include "lbxserve.h"
+
+#include "os.h"
+#include "opaque.h"
+#include "resource.h"
+#include <X11/X.h>
+#include <X11/Xproto.h>
+
+typedef struct _tagdata {
+ XID tid;
+ short data_type;
+ unsigned char sent_to_proxy[(MAX_NUM_PROXIES + 7) / 8];
+ int size;
+ pointer tdata;
+ XID *global;
+} TagDataRec;
+
+typedef struct _tagdata *TagData;
+
+extern void TagInit ( void );
+extern XID TagNewTag ( void );
+extern void TagClearProxy ( XID tid, int pid );
+extern void TagMarkProxy ( XID tid, int pid );
+extern Bool TagProxyMarked ( XID tid, int pid );
+extern XID TagSaveTag ( int dtype, int size, pointer data, XID *global );
+extern void TagDeleteTag ( XID tid );
+extern TagData TagGetTag ( XID tid );
+extern void LbxFlushTags ( LbxProxyPtr proxy );
+
+#endif /* _LBXTAGS_H_ */
diff --git a/nx-X11/programs/Xserver/lbx/lbxzerorep.c b/nx-X11/programs/Xserver/lbx/lbxzerorep.c
new file mode 100644
index 000000000..e376908c0
--- /dev/null
+++ b/nx-X11/programs/Xserver/lbx/lbxzerorep.c
@@ -0,0 +1,420 @@
+/* $Xorg: lbxzerorep.c,v 1.4 2001/02/09 02:05:17 xorgcvs Exp $ */
+
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/lbx/lbxzerorep.c,v 1.3 2001/01/17 22:37:00 dawes Exp $ */
+
+/*
+ * This module handles zeroing out unused pad bytes in core X replies.
+ * This will hopefully improve both stream and delta compression,
+ * since we are removing the random values in pad bytes.
+ */
+
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+
+void
+ZeroReplyPadBytes (char *buf,
+ int reqType)
+{
+ switch (reqType) {
+ case X_GetWindowAttributes:
+ {
+ xGetWindowAttributesReply *reply = (xGetWindowAttributesReply *) buf;
+ reply->pad = 0;
+ break;
+ }
+ case X_GetGeometry:
+ {
+ xGetGeometryReply *reply = (xGetGeometryReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ break;
+ }
+ case X_QueryTree:
+ {
+ xQueryTreeReply *reply = (xQueryTreeReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ break;
+ }
+ case X_InternAtom:
+ {
+ xInternAtomReply *reply = (xInternAtomReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ break;
+ }
+ case X_GetAtomName:
+ {
+ xGetAtomNameReply *reply = (xGetAtomNameReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ reply->pad7 = 0;
+ break;
+ }
+ case X_GetProperty:
+ {
+ xGetPropertyReply *reply = (xGetPropertyReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ break;
+ }
+ case X_ListProperties:
+ {
+ xListPropertiesReply *reply = (xListPropertiesReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ reply->pad7 = 0;
+ break;
+ }
+ case X_GetSelectionOwner:
+ {
+ xGetSelectionOwnerReply *reply = (xGetSelectionOwnerReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ break;
+ }
+ case X_GrabKeyboard:
+ case X_GrabPointer:
+ {
+ xGrabKeyboardReply *reply = (xGrabKeyboardReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ break;
+ }
+ case X_QueryPointer:
+ {
+ xQueryPointerReply *reply = (xQueryPointerReply *) buf;
+ reply->pad1 = 0;
+ reply->pad = 0;
+ break;
+ }
+ case X_GetMotionEvents:
+ {
+ xGetMotionEventsReply *reply = (xGetMotionEventsReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ break;
+ }
+ case X_TranslateCoords:
+ {
+ xTranslateCoordsReply *reply = (xTranslateCoordsReply *) buf;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ break;
+ }
+ case X_GetInputFocus:
+ {
+ xGetInputFocusReply *reply = (xGetInputFocusReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ break;
+ }
+ case X_QueryKeymap:
+ {
+ xQueryKeymapReply *reply = (xQueryKeymapReply *) buf;
+ reply->pad1 = 0;
+ break;
+ }
+ case X_QueryFont:
+ {
+ xQueryFontReply *reply = (xQueryFontReply *) buf;
+ reply->pad1 = 0;
+ break;
+ }
+ case X_QueryTextExtents:
+ {
+ xQueryTextExtentsReply *reply = (xQueryTextExtentsReply *) buf;
+ reply->pad = 0;
+ break;
+ }
+ case X_ListFonts:
+ {
+ xListFontsReply *reply = (xListFontsReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ reply->pad7 = 0;
+ break;
+ }
+ case X_GetFontPath:
+ {
+ xGetFontPathReply *reply = (xGetFontPathReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ reply->pad7 = 0;
+ break;
+ }
+ case X_GetImage:
+ {
+ xGetImageReply *reply = (xGetImageReply *) buf;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ reply->pad7 = 0;
+ break;
+ }
+ case X_ListInstalledColormaps:
+ {
+ xListInstalledColormapsReply *reply =
+ (xListInstalledColormapsReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ reply->pad7 = 0;
+ break;
+ }
+ case X_AllocColor:
+ {
+ xAllocColorReply *reply = (xAllocColorReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ break;
+ }
+ case X_AllocNamedColor:
+ {
+ xAllocNamedColorReply *reply = (xAllocNamedColorReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ break;
+ }
+ case X_AllocColorCells:
+ {
+ xAllocColorCellsReply *reply = (xAllocColorCellsReply *) buf;
+ reply->pad1 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ reply->pad7 = 0;
+ break;
+ }
+ case X_AllocColorPlanes:
+ {
+ xAllocColorPlanesReply *reply = (xAllocColorPlanesReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ break;
+ }
+ case X_QueryColors:
+ {
+ xQueryColorsReply *reply = (xQueryColorsReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ reply->pad7 = 0;
+ break;
+ }
+ case X_LookupColor:
+ {
+ xLookupColorReply *reply = (xLookupColorReply *) buf;
+ reply->pad1 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ break;
+ }
+ case X_QueryBestSize:
+ {
+ xQueryBestSizeReply *reply = (xQueryBestSizeReply *) buf;
+ reply->pad1 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ reply->pad7 = 0;
+ break;
+ }
+ case X_QueryExtension:
+ {
+ xQueryExtensionReply *reply = (xQueryExtensionReply *) buf;
+ reply->pad1 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ reply->pad7 = 0;
+ break;
+ }
+ case X_ListExtensions:
+ {
+ xListExtensionsReply *reply = (xListExtensionsReply *) buf;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ reply->pad7 = 0;
+ break;
+ }
+ case X_SetPointerMapping:
+ case X_SetModifierMapping:
+ {
+ xSetMappingReply *reply = (xSetMappingReply *) buf;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ reply->pad7 = 0;
+ break;
+ }
+ case X_GetPointerMapping:
+ {
+ xGetPointerMappingReply *reply = (xGetPointerMappingReply *) buf;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ reply->pad7 = 0;
+ break;
+ }
+ case X_GetKeyboardMapping:
+ {
+ xGetKeyboardMappingReply *reply = (xGetKeyboardMappingReply *) buf;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ reply->pad7 = 0;
+ break;
+ }
+ case X_GetModifierMapping:
+ {
+ xGetModifierMappingReply *reply = (xGetModifierMappingReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ break;
+ }
+ case X_GetKeyboardControl:
+ {
+ xGetKeyboardControlReply *reply = (xGetKeyboardControlReply *) buf;
+ reply->pad = 0;
+ break;
+ }
+ case X_GetPointerControl:
+ {
+ xGetPointerControlReply *reply = (xGetPointerControlReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ break;
+ }
+ case X_GetScreenSaver:
+ {
+ xGetScreenSaverReply *reply = (xGetScreenSaverReply *) buf;
+ reply->pad1 = 0;
+ reply->pad2 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ break;
+ }
+ case X_ListHosts:
+ {
+ xListHostsReply *reply = (xListHostsReply *) buf;
+ reply->pad1 = 0;
+ reply->pad3 = 0;
+ reply->pad4 = 0;
+ reply->pad5 = 0;
+ reply->pad6 = 0;
+ reply->pad7 = 0;
+ break;
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/mfb/Imakefile b/nx-X11/programs/Xserver/mfb/Imakefile
new file mode 100644
index 000000000..b0688ee51
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/Imakefile
@@ -0,0 +1,168 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:53:32 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/mfb/Imakefile,v 3.16 2002/05/31 16:12:18 dawes Exp $
+
+#if DoLoadableServer
+#if !BuildModuleInSubdir
+#define IHaveModules
+#elif !defined(IHaveModules)
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+#endif
+
+#include <Server.tmpl>
+
+#if defined(IHaveModules)
+XF86INCL = -I$(XF86COMSRC) -I$(XF86SRC)
+XFMODSRC = mfbmodule.c
+XFMODOBJ = mfbmodule.o
+#endif
+
+SRCS1 = mfbgc.c mfbwindow.c mfbfont.c \
+ mfbfillrct.c mfbpntwin.c maskbits.c mfbpixmap.c \
+ mfbimage.c mfbline.c mfbbres.c mfbhrzvert.c mfbbresd.c \
+ mfbpushpxl.c mfbzerarc.c mfbfillarc.c \
+ mfbfillsp.c mfbsetsp.c mfbscrinit.c mfbscrclse.c mfbclip.c \
+ mfbbitblt.c mfbgetsp.c mfbpolypnt.c \
+ mfbbltC.c mfbbltX.c mfbbltCI.c mfbbltO.c mfbbltG.c \
+ mfbcmap.c mfbtileC.c mfbtileG.c mfbmisc.c mfbbstore.c $(XFMODSRC)
+
+SRCS = $(SRCS1) mfbseg.c mfbpgbwht.c mfbpgbblak.c mfbpgbinv.c mfbigbwht.c \
+ mfbigbblak.c mfbpawhite.c mfbpablack.c mfbpainv.c mfbtewhite.c \
+ mfbteblack.c mfbbltC.c mfbbltX.c mfbbltCI.c mfbbltO.c mfbbltG.c \
+ mfbtileC.c mfbtileG.c mfbplywhite.c mfbplyblack.c mfbplyinv.c
+
+OBJS = mfbgc.o mfbwindow.o mfbfont.o \
+ mfbfillrct.o mfbpntwin.o maskbits.o mfbpixmap.o \
+ mfbimage.o mfbline.o mfbbres.o mfbhrzvert.o mfbbresd.o mfbseg.o \
+ mfbpushpxl.o mfbzerarc.o mfbfillarc.o \
+ mfbfillsp.o mfbsetsp.o mfbscrinit.o mfbscrclse.o mfbclip.o \
+ mfbbitblt.o mfbgetsp.o mfbpolypnt.o \
+ mfbbltC.o mfbbltX.o mfbbltCI.o mfbbltO.o mfbbltG.o \
+ mfbpgbwht.o mfbpgbblak.o mfbpgbinv.o \
+ mfbigbwht.o mfbigbblak.o mfbcmap.o \
+ mfbpawhite.o mfbpablack.o mfbpainv.o mfbtileC.o mfbtileG.o \
+ mfbtewhite.o mfbteblack.o mfbmisc.o mfbbstore.o \
+ mfbplywhite.o mfbplyblack.o mfbplyinv.o $(XFMODOBJ)
+
+INCLUDES = -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(FONTINCSRC) $(XF86INCL)
+LINTDEFS = -DMFBPOLYGLYPHBLT=mfbPolyGlyphBltWhite \
+ -DMFBIMAGEGLYPHBLT=mfbImageGlyphBltWhite \
+ -DEQWHOLEWORD=MFB_EQWHOLEWORD_WHITE -DOPEQ=MFB_OPEQ_WHITE
+
+LINTLIBS = $(SERVERSRC)/dix/llib-ldix.ln $(SERVERSRC)/os/llib-los.ln \
+ $(SERVERSRC)/mi/llib-lmi.ln
+
+#ifdef IHaveModules
+ModuleObjectRule()
+LibraryModuleTarget(mfb,$(OBJS))
+#else
+NormalLibraryObjectRule()
+NormalLibraryTarget(mfb,$(OBJS))
+#endif
+
+LintLibraryTarget(mfb,$(SRCS1))
+NormalLintTarget($(LINTDEFS) $(SRCS1))
+
+ObjectFromSpecialSource(mfbseg,mfbline,-DPOLYSEGMENT)
+
+ObjectFromSpecialSource(mfbpgbwht,mfbplygblt,-DMFBPOLYGLYPHBLT=mfbPolyGlyphBltWhite -DOPEQ=MFB_OPEQ_WHITE)
+
+ObjectFromSpecialSource(mfbpgbblak,mfbplygblt,-DMFBPOLYGLYPHBLT=mfbPolyGlyphBltBlack -DOPEQ=MFB_OPEQ_BLACK)
+
+ObjectFromSpecialSource(mfbpgbinv,mfbplygblt,-DMFBPOLYGLYPHBLT=mfbPolyGlyphBltInvert -DOPEQ=MFB_OPEQ_INVERT)
+
+ObjectFromSpecialSource(mfbigbwht,mfbimggblt,-DMFBIMAGEGLYPHBLT=mfbImageGlyphBltWhite -DOPEQ=MFB_OPEQ_WHITE)
+
+ObjectFromSpecialSource(mfbigbblak,mfbimggblt,-DMFBIMAGEGLYPHBLT=mfbImageGlyphBltBlack -DOPEQ=MFB_OPEQ_BLACK)
+
+ObjectFromSpecialSource(mfbpawhite,mfbpntarea,-DMFBSOLIDFILLAREA=mfbSolidWhiteArea -DMFBSTIPPLEFILLAREA=mfbStippleWhiteArea -DOPEQ=MFB_OPEQ_WHITE -DEQWHOLEWORD=MFB_EQWHOLEWORD_WHITE)
+
+ObjectFromSpecialSource(mfbpablack,mfbpntarea,-DMFBSOLIDFILLAREA=mfbSolidBlackArea -DMFBSTIPPLEFILLAREA=mfbStippleBlackArea -DOPEQ=MFB_OPEQ_BLACK -DEQWHOLEWORD=MFB_EQWHOLEWORD_BLACK)
+
+ObjectFromSpecialSource(mfbpainv,mfbpntarea,-DMFBSOLIDFILLAREA=mfbSolidInvertArea -DMFBSTIPPLEFILLAREA=mfbStippleInvertArea -DOPEQ=MFB_OPEQ_INVERT -DEQWHOLEWORD=MFB_EQWHOLEWORD_INVERT)
+
+ObjectFromSpecialSource(mfbtewhite,mfbtegblt,-DMFBTEGLYPHBLT=mfbTEGlyphBltWhite -DOP=MFB_OP_WHITE -DCLIPTETEXT=mfbImageGlyphBltWhite)
+
+ObjectFromSpecialSource(mfbteblack,mfbtegblt,-DMFBTEGLYPHBLT=mfbTEGlyphBltBlack -DOP=MFB_OP_BLACK -DCLIPTETEXT=mfbImageGlyphBltBlack)
+
+ObjectFromSpecialSource(mfbplywhite,mfbply1rct,-DMFBFILLPOLY1RECT=mfbFillPolyWhite -DOPEQ=MFB_OPEQ_WHITE -DEQWHOLEWORD=MFB_EQWHOLEWORD_WHITE)
+
+ObjectFromSpecialSource(mfbplyblack,mfbply1rct,-DMFBFILLPOLY1RECT=mfbFillPolyBlack -DOPEQ=MFB_OPEQ_BLACK -DEQWHOLEWORD=MFB_EQWHOLEWORD_BLACK)
+
+ObjectFromSpecialSource(mfbplyinv,mfbply1rct,-DMFBFILLPOLY1RECT=mfbFillPolyInvert -DOPEQ=MFB_OPEQ_INVERT -DEQWHOLEWORD=MFB_EQWHOLEWORD_INVERT)
+
+ObjectFromSpecialSource(mfbbltC,mfbblt,-DMROP=Mcopy)
+
+ObjectFromSpecialSource(mfbbltX,mfbblt,-DMROP=Mxor)
+
+ObjectFromSpecialSource(mfbbltCI,mfbblt,-DMROP=McopyInverted)
+
+ObjectFromSpecialSource(mfbbltO,mfbblt,-DMROP=Mor)
+
+ObjectFromSpecialSource(mfbbltG,mfbblt,-DMROP=0)
+
+ObjectFromSpecialSource(mfbtileC,mfbtile,-DMROP=Mcopy)
+
+ObjectFromSpecialSource(mfbtileG,mfbtile,-DMROP=0)
+
+SpecialCObjectRule(mfbpixmap,$(ICONFIGFILES),$(_NOOP_))
+
+#ifdef IHaveModules
+InstallLibraryModule(mfb,$(MODULEDIR),.)
+#endif
+
+DependTarget()
+
+#ifdef IHaveSubdirs
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+InstallDriverSDKLibraryModule(mfb,$(DRIVERSDKMODULEDIR),.)
+
+InstallDriverSDKNonExecFile(mfb.h,$(DRIVERSDKINCLUDEDIR))
+
+
+#ifdef LinkDirectory
+LinkSourceFile(maskbits.c,LinkDirectory)
+LinkSourceFile(mfbbitblt.c,LinkDirectory)
+LinkSourceFile(mfbblt.c,LinkDirectory)
+LinkSourceFile(mfbbres.c,LinkDirectory)
+LinkSourceFile(mfbbresd.c,LinkDirectory)
+LinkSourceFile(mfbbstore.c,LinkDirectory)
+LinkSourceFile(mfbclip.c,LinkDirectory)
+LinkSourceFile(mfbcmap.c,LinkDirectory)
+LinkSourceFile(mfbfillarc.c,LinkDirectory)
+LinkSourceFile(mfbfillrct.c,LinkDirectory)
+LinkSourceFile(mfbfillsp.c,LinkDirectory)
+LinkSourceFile(mfbfont.c,LinkDirectory)
+LinkSourceFile(mfbgc.c,LinkDirectory)
+LinkSourceFile(mfbgetsp.c,LinkDirectory)
+LinkSourceFile(mfbhrzvert.c,LinkDirectory)
+LinkSourceFile(mfbimage.c,LinkDirectory)
+LinkSourceFile(mfbimggblt.c,LinkDirectory)
+LinkSourceFile(mfbline.c,LinkDirectory)
+LinkSourceFile(mfbmisc.c,LinkDirectory)
+LinkSourceFile(mfbmodule.c,LinkDirectory)
+LinkSourceFile(mfbpixmap.c,LinkDirectory)
+LinkSourceFile(mfbply1rct.c,LinkDirectory)
+LinkSourceFile(mfbplygblt.c,LinkDirectory)
+LinkSourceFile(mfbpntarea.c,LinkDirectory)
+LinkSourceFile(mfbpntwin.c,LinkDirectory)
+LinkSourceFile(mfbpolypnt.c,LinkDirectory)
+LinkSourceFile(mfbpushpxl.c,LinkDirectory)
+LinkSourceFile(mfbscrclse.c,LinkDirectory)
+LinkSourceFile(mfbscrinit.c,LinkDirectory)
+LinkSourceFile(mfbsetsp.c,LinkDirectory)
+LinkSourceFile(mfbtegblt.c,LinkDirectory)
+LinkSourceFile(mfbtile.c,LinkDirectory)
+LinkSourceFile(mfbwindow.c,LinkDirectory)
+LinkSourceFile(mfbzerarc.c,LinkDirectory)
+#endif
+
diff --git a/nx-X11/programs/Xserver/mfb/fastblt.h b/nx-X11/programs/Xserver/mfb/fastblt.h
new file mode 100644
index 000000000..08846a41f
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/fastblt.h
@@ -0,0 +1,98 @@
+/* $Xorg: fastblt.h,v 1.4 2001/02/09 02:05:17 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/mfb/fastblt.h,v 1.4 2001/01/17 22:37:01 dawes Exp $ */
+
+/*
+ * Fast bitblt macros for certain hardware. If your machine has an addressing
+ * mode of small constant + register, you'll probably want this magic specific
+ * code. It's 25% faster for the R2000. I haven't studied the Sparc
+ * instruction set, but I suspect it also has this addressing mode. Also,
+ * unrolling the loop by 32 is possibly excessive for mfb. The number of times
+ * the loop is actually looped through is pretty small.
+ */
+
+/*
+ * WARNING: These macros make *a lot* of assumptions about
+ * the environment they are invoked in. Plenty of implicit
+ * arguments, lots of side effects. Don't use them casually.
+ */
+
+#define SwitchOdd(n) case n: BodyOdd(n)
+#define SwitchEven(n) case n: BodyEven(n)
+
+/* to allow mfb and cfb to share code... */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef BitRight
+#define BitRight(a,b) SCRRIGHT(a,b)
+#define BitLeft(a,b) SCRLEFT(a,b)
+#endif
+
+#ifdef LARGE_INSTRUCTION_CACHE
+#define UNROLL 8
+#define PackedLoop \
+ switch (nl & (UNROLL-1)) { \
+ SwitchOdd( 7) SwitchEven( 6) SwitchOdd( 5) SwitchEven( 4) \
+ SwitchOdd( 3) SwitchEven( 2) SwitchOdd( 1) \
+ } \
+ while ((nl -= UNROLL) >= 0) { \
+ LoopReset \
+ BodyEven( 8) \
+ BodyOdd( 7) BodyEven( 6) BodyOdd( 5) BodyEven( 4) \
+ BodyOdd( 3) BodyEven( 2) BodyOdd( 1) \
+ }
+#else
+#define UNROLL 4
+#define PackedLoop \
+ switch (nl & (UNROLL-1)) { \
+ SwitchOdd( 3) SwitchEven( 2) SwitchOdd( 1) \
+ } \
+ while ((nl -= UNROLL) >= 0) { \
+ LoopReset \
+ BodyEven( 4) \
+ BodyOdd( 3) BodyEven( 2) BodyOdd( 1) \
+ }
+#endif
+
+#define DuffL(counter,label,body) \
+ switch (counter & 3) { \
+ label: \
+ body \
+ case 3: \
+ body \
+ case 2: \
+ body \
+ case 1: \
+ body \
+ case 0: \
+ if ((counter -= 4) >= 0) \
+ goto label; \
+ }
diff --git a/nx-X11/programs/Xserver/mfb/maskbits.c b/nx-X11/programs/Xserver/mfb/maskbits.c
new file mode 100644
index 000000000..d2a90962d
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/maskbits.c
@@ -0,0 +1,1061 @@
+/* $Xorg: maskbits.c,v 1.4 2001/02/09 02:05:17 xorgcvs Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*/
+/* $XFree86: xc/programs/Xserver/mfb/maskbits.c,v 1.5 2001/01/17 22:37:01 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "maskbits.h"
+#include "servermd.h"
+
+/*
+these tables are used by several macros in the mfb code.
+
+ the vax numbers everything left to right, so bit indices on the
+screen match bit indices in longwords. the pc-rt and Sun number
+bits on the screen the way they would be written on paper,
+(i.e. msb to the left), and so a bit index n on the screen is
+bit index PPW-n in a longword
+
+ see also maskbits.h
+*/
+
+#if PPW != 32
+ ERROR MFB must be compiled with PPW 32
+#endif
+
+#if (BITMAP_BIT_ORDER == MSBFirst)
+/* NOTE:
+the first element in starttab could be 0xffffffff. making it 0
+lets us deal with a full first word in the middle loop, rather
+than having to do the multiple reads and masks that we'd
+have to do if we thought it was partial.
+*/
+PixelType starttab[PPW+1] =
+ {
+ LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x7FFFFFFF ),
+ LONG2CHARS( 0x3FFFFFFF ),
+ LONG2CHARS( 0x1FFFFFFF ),
+ LONG2CHARS( 0x0FFFFFFF ),
+ LONG2CHARS( 0x07FFFFFF ),
+ LONG2CHARS( 0x03FFFFFF ),
+ LONG2CHARS( 0x01FFFFFF ),
+ LONG2CHARS( 0x00FFFFFF ),
+ LONG2CHARS( 0x007FFFFF ),
+ LONG2CHARS( 0x003FFFFF ),
+ LONG2CHARS( 0x001FFFFF ),
+ LONG2CHARS( 0x000FFFFF ),
+ LONG2CHARS( 0x0007FFFF ),
+ LONG2CHARS( 0x0003FFFF ),
+ LONG2CHARS( 0x0001FFFF ),
+ LONG2CHARS( 0x0000FFFF ),
+ LONG2CHARS( 0x00007FFF ),
+ LONG2CHARS( 0x00003FFF ),
+ LONG2CHARS( 0x00001FFF ),
+ LONG2CHARS( 0x00000FFF ),
+ LONG2CHARS( 0x000007FF ),
+ LONG2CHARS( 0x000003FF ),
+ LONG2CHARS( 0x000001FF ),
+ LONG2CHARS( 0x000000FF ),
+ LONG2CHARS( 0x0000007F ),
+ LONG2CHARS( 0x0000003F ),
+ LONG2CHARS( 0x0000001F ),
+ LONG2CHARS( 0x0000000F ),
+ LONG2CHARS( 0x00000007 ),
+ LONG2CHARS( 0x00000003 ),
+ LONG2CHARS( 0x00000001 ),
+ LONG2CHARS( 0x00000000 )
+ };
+
+PixelType endtab[PPW+1] =
+ {
+ LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x80000000 ),
+ LONG2CHARS( 0xC0000000 ),
+ LONG2CHARS( 0xE0000000 ),
+ LONG2CHARS( 0xF0000000 ),
+ LONG2CHARS( 0xF8000000 ),
+ LONG2CHARS( 0xFC000000 ),
+ LONG2CHARS( 0xFE000000 ),
+ LONG2CHARS( 0xFF000000 ),
+ LONG2CHARS( 0xFF800000 ),
+ LONG2CHARS( 0xFFC00000 ),
+ LONG2CHARS( 0xFFE00000 ),
+ LONG2CHARS( 0xFFF00000 ),
+ LONG2CHARS( 0xFFF80000 ),
+ LONG2CHARS( 0xFFFC0000 ),
+ LONG2CHARS( 0xFFFE0000 ),
+ LONG2CHARS( 0xFFFF0000 ),
+ LONG2CHARS( 0xFFFF8000 ),
+ LONG2CHARS( 0xFFFFC000 ),
+ LONG2CHARS( 0xFFFFE000 ),
+ LONG2CHARS( 0xFFFFF000 ),
+ LONG2CHARS( 0xFFFFF800 ),
+ LONG2CHARS( 0xFFFFFC00 ),
+ LONG2CHARS( 0xFFFFFE00 ),
+ LONG2CHARS( 0xFFFFFF00 ),
+ LONG2CHARS( 0xFFFFFF80 ),
+ LONG2CHARS( 0xFFFFFFC0 ),
+ LONG2CHARS( 0xFFFFFFE0 ),
+ LONG2CHARS( 0xFFFFFFF0 ),
+ LONG2CHARS( 0xFFFFFFF8 ),
+ LONG2CHARS( 0xFFFFFFFC ),
+ LONG2CHARS( 0xFFFFFFFE ),
+ LONG2CHARS( 0xFFFFFFFF )
+ };
+
+
+#ifdef NEED_OLD_MFB_MASKS
+/* a hack, for now, since the entries for 0 need to be all
+ 1 bits, not all zeros.
+ this means the code DOES NOT WORK for segments of length
+ 0 (which is only a problem in the horizontal line code.)
+*/
+PixelType startpartial[33] =
+ {
+ LONG2CHARS( 0xFFFFFFFF ),
+ LONG2CHARS( 0x7FFFFFFF ),
+ LONG2CHARS( 0x3FFFFFFF ),
+ LONG2CHARS( 0x1FFFFFFF ),
+ LONG2CHARS( 0x0FFFFFFF ),
+ LONG2CHARS( 0x07FFFFFF ),
+ LONG2CHARS( 0x03FFFFFF ),
+ LONG2CHARS( 0x01FFFFFF ),
+ LONG2CHARS( 0x00FFFFFF ),
+ LONG2CHARS( 0x007FFFFF ),
+ LONG2CHARS( 0x003FFFFF ),
+ LONG2CHARS( 0x001FFFFF ),
+ LONG2CHARS( 0x000FFFFF ),
+ LONG2CHARS( 0x0007FFFF ),
+ LONG2CHARS( 0x0003FFFF ),
+ LONG2CHARS( 0x0001FFFF ),
+ LONG2CHARS( 0x0000FFFF ),
+ LONG2CHARS( 0x00007FFF ),
+ LONG2CHARS( 0x00003FFF ),
+ LONG2CHARS( 0x00001FFF ),
+ LONG2CHARS( 0x00000FFF ),
+ LONG2CHARS( 0x000007FF ),
+ LONG2CHARS( 0x000003FF ),
+ LONG2CHARS( 0x000001FF ),
+ LONG2CHARS( 0x000000FF ),
+ LONG2CHARS( 0x0000007F ),
+ LONG2CHARS( 0x0000003F ),
+ LONG2CHARS( 0x0000001F ),
+ LONG2CHARS( 0x0000000F ),
+ LONG2CHARS( 0x00000007 ),
+ LONG2CHARS( 0x00000003 ),
+ LONG2CHARS( 0x00000001 ),
+ LONG2CHARS( 0x00000000 )
+ };
+
+PixelType endpartial[33] =
+ {
+ LONG2CHARS( 0xFFFFFFFF ),
+ LONG2CHARS( 0x80000000 ),
+ LONG2CHARS( 0xC0000000 ),
+ LONG2CHARS( 0xE0000000 ),
+ LONG2CHARS( 0xF0000000 ),
+ LONG2CHARS( 0xF8000000 ),
+ LONG2CHARS( 0xFC000000 ),
+ LONG2CHARS( 0xFE000000 ),
+ LONG2CHARS( 0xFF000000 ),
+ LONG2CHARS( 0xFF800000 ),
+ LONG2CHARS( 0xFFC00000 ),
+ LONG2CHARS( 0xFFE00000 ),
+ LONG2CHARS( 0xFFF00000 ),
+ LONG2CHARS( 0xFFF80000 ),
+ LONG2CHARS( 0xFFFC0000 ),
+ LONG2CHARS( 0xFFFE0000 ),
+ LONG2CHARS( 0xFFFF0000 ),
+ LONG2CHARS( 0xFFFF8000 ),
+ LONG2CHARS( 0xFFFFC000 ),
+ LONG2CHARS( 0xFFFFE000 ),
+ LONG2CHARS( 0xFFFFF000 ),
+ LONG2CHARS( 0xFFFFF800 ),
+ LONG2CHARS( 0xFFFFFC00 ),
+ LONG2CHARS( 0xFFFFFE00 ),
+ LONG2CHARS( 0xFFFFFF00 ),
+ LONG2CHARS( 0xFFFFFF80 ),
+ LONG2CHARS( 0xFFFFFFC0 ),
+ LONG2CHARS( 0xFFFFFFE0 ),
+ LONG2CHARS( 0xFFFFFFF0 ),
+ LONG2CHARS( 0xFFFFFFF8 ),
+ LONG2CHARS( 0xFFFFFFFC ),
+ LONG2CHARS( 0xFFFFFFFE ),
+ LONG2CHARS( 0xFFFFFFFF )
+ };
+#endif /* NEED_OLD_MFB_MASKS */
+
+
+PixelType partmasks[PPW][PPW] = {
+ {LONG2CHARS( 0xFFFFFFFF ), LONG2CHARS( 0x80000000 ), LONG2CHARS( 0xC0000000 ), LONG2CHARS( 0xE0000000 ),
+ LONG2CHARS( 0xF0000000 ), LONG2CHARS( 0xF8000000 ), LONG2CHARS( 0xFC000000 ), LONG2CHARS( 0xFE000000 ),
+ LONG2CHARS( 0xFF000000 ), LONG2CHARS( 0xFF800000 ), LONG2CHARS( 0xFFC00000 ), LONG2CHARS( 0xFFE00000 ),
+ LONG2CHARS( 0xFFF00000 ), LONG2CHARS( 0xFFF80000 ), LONG2CHARS( 0xFFFC0000 ), LONG2CHARS( 0xFFFE0000 ),
+ LONG2CHARS( 0xFFFF0000 ), LONG2CHARS( 0xFFFF8000 ), LONG2CHARS( 0xFFFFC000 ), LONG2CHARS( 0xFFFFE000 ),
+ LONG2CHARS( 0xFFFFF000 ), LONG2CHARS( 0xFFFFF800 ), LONG2CHARS( 0xFFFFFC00 ), LONG2CHARS( 0xFFFFFE00 ),
+ LONG2CHARS( 0xFFFFFF00 ), LONG2CHARS( 0xFFFFFF80 ), LONG2CHARS( 0xFFFFFFC0 ), LONG2CHARS( 0xFFFFFFE0 ),
+ LONG2CHARS( 0xFFFFFFF0 ), LONG2CHARS( 0xFFFFFFF8 ), LONG2CHARS( 0xFFFFFFFC ), LONG2CHARS( 0xFFFFFFFE )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x40000000 ), LONG2CHARS( 0x60000000 ), LONG2CHARS( 0x70000000 ),
+ LONG2CHARS( 0x78000000 ), LONG2CHARS( 0x7C000000 ), LONG2CHARS( 0x7E000000 ), LONG2CHARS( 0x7F000000 ),
+ LONG2CHARS( 0x7F800000 ), LONG2CHARS( 0x7FC00000 ), LONG2CHARS( 0x7FE00000 ), LONG2CHARS( 0x7FF00000 ),
+ LONG2CHARS( 0x7FF80000 ), LONG2CHARS( 0x7FFC0000 ), LONG2CHARS( 0x7FFE0000 ), LONG2CHARS( 0x7FFF0000 ),
+ LONG2CHARS( 0x7FFF8000 ), LONG2CHARS( 0x7FFFC000 ), LONG2CHARS( 0x7FFFE000 ), LONG2CHARS( 0x7FFFF000 ),
+ LONG2CHARS( 0x7FFFF800 ), LONG2CHARS( 0x7FFFFC00 ), LONG2CHARS( 0x7FFFFE00 ), LONG2CHARS( 0x7FFFFF00 ),
+ LONG2CHARS( 0x7FFFFF80 ), LONG2CHARS( 0x7FFFFFC0 ), LONG2CHARS( 0x7FFFFFE0 ), LONG2CHARS( 0x7FFFFFF0 ),
+ LONG2CHARS( 0x7FFFFFF8 ), LONG2CHARS( 0x7FFFFFFC ), LONG2CHARS( 0x7FFFFFFE ), LONG2CHARS( 0x7FFFFFFF )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x20000000 ), LONG2CHARS( 0x30000000 ), LONG2CHARS( 0x38000000 ),
+ LONG2CHARS( 0x3C000000 ), LONG2CHARS( 0x3E000000 ), LONG2CHARS( 0x3F000000 ), LONG2CHARS( 0x3F800000 ),
+ LONG2CHARS( 0x3FC00000 ), LONG2CHARS( 0x3FE00000 ), LONG2CHARS( 0x3FF00000 ), LONG2CHARS( 0x3FF80000 ),
+ LONG2CHARS( 0x3FFC0000 ), LONG2CHARS( 0x3FFE0000 ), LONG2CHARS( 0x3FFF0000 ), LONG2CHARS( 0x3FFF8000 ),
+ LONG2CHARS( 0x3FFFC000 ), LONG2CHARS( 0x3FFFE000 ), LONG2CHARS( 0x3FFFF000 ), LONG2CHARS( 0x3FFFF800 ),
+ LONG2CHARS( 0x3FFFFC00 ), LONG2CHARS( 0x3FFFFE00 ), LONG2CHARS( 0x3FFFFF00 ), LONG2CHARS( 0x3FFFFF80 ),
+ LONG2CHARS( 0x3FFFFFC0 ), LONG2CHARS( 0x3FFFFFE0 ), LONG2CHARS( 0x3FFFFFF0 ), LONG2CHARS( 0x3FFFFFF8 ),
+ LONG2CHARS( 0x3FFFFFFC ), LONG2CHARS( 0x3FFFFFFE ), LONG2CHARS( 0x3FFFFFFF ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x10000000 ), LONG2CHARS( 0x18000000 ), LONG2CHARS( 0x1C000000 ),
+ LONG2CHARS( 0x1E000000 ), LONG2CHARS( 0x1F000000 ), LONG2CHARS( 0x1F800000 ), LONG2CHARS( 0x1FC00000 ),
+ LONG2CHARS( 0x1FE00000 ), LONG2CHARS( 0x1FF00000 ), LONG2CHARS( 0x1FF80000 ), LONG2CHARS( 0x1FFC0000 ),
+ LONG2CHARS( 0x1FFE0000 ), LONG2CHARS( 0x1FFF0000 ), LONG2CHARS( 0x1FFF8000 ), LONG2CHARS( 0x1FFFC000 ),
+ LONG2CHARS( 0x1FFFE000 ), LONG2CHARS( 0x1FFFF000 ), LONG2CHARS( 0x1FFFF800 ), LONG2CHARS( 0x1FFFFC00 ),
+ LONG2CHARS( 0x1FFFFE00 ), LONG2CHARS( 0x1FFFFF00 ), LONG2CHARS( 0x1FFFFF80 ), LONG2CHARS( 0x1FFFFFC0 ),
+ LONG2CHARS( 0x1FFFFFE0 ), LONG2CHARS( 0x1FFFFFF0 ), LONG2CHARS( 0x1FFFFFF8 ), LONG2CHARS( 0x1FFFFFFC ),
+ LONG2CHARS( 0x1FFFFFFE ), LONG2CHARS( 0x1FFFFFFF ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x08000000 ), LONG2CHARS( 0x0C000000 ), LONG2CHARS( 0x0E000000 ),
+ LONG2CHARS( 0x0F000000 ), LONG2CHARS( 0x0F800000 ), LONG2CHARS( 0x0FC00000 ), LONG2CHARS( 0x0FE00000 ),
+ LONG2CHARS( 0x0FF00000 ), LONG2CHARS( 0x0FF80000 ), LONG2CHARS( 0x0FFC0000 ), LONG2CHARS( 0x0FFE0000 ),
+ LONG2CHARS( 0x0FFF0000 ), LONG2CHARS( 0x0FFF8000 ), LONG2CHARS( 0x0FFFC000 ), LONG2CHARS( 0x0FFFE000 ),
+ LONG2CHARS( 0x0FFFF000 ), LONG2CHARS( 0x0FFFF800 ), LONG2CHARS( 0x0FFFFC00 ), LONG2CHARS( 0x0FFFFE00 ),
+ LONG2CHARS( 0x0FFFFF00 ), LONG2CHARS( 0x0FFFFF80 ), LONG2CHARS( 0x0FFFFFC0 ), LONG2CHARS( 0x0FFFFFE0 ),
+ LONG2CHARS( 0x0FFFFFF0 ), LONG2CHARS( 0x0FFFFFF8 ), LONG2CHARS( 0x0FFFFFFC ), LONG2CHARS( 0x0FFFFFFE ),
+ LONG2CHARS( 0x0FFFFFFF ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x04000000 ), LONG2CHARS( 0x06000000 ), LONG2CHARS( 0x07000000 ),
+ LONG2CHARS( 0x07800000 ), LONG2CHARS( 0x07C00000 ), LONG2CHARS( 0x07E00000 ), LONG2CHARS( 0x07F00000 ),
+ LONG2CHARS( 0x07F80000 ), LONG2CHARS( 0x07FC0000 ), LONG2CHARS( 0x07FE0000 ), LONG2CHARS( 0x07FF0000 ),
+ LONG2CHARS( 0x07FF8000 ), LONG2CHARS( 0x07FFC000 ), LONG2CHARS( 0x07FFE000 ), LONG2CHARS( 0x07FFF000 ),
+ LONG2CHARS( 0x07FFF800 ), LONG2CHARS( 0x07FFFC00 ), LONG2CHARS( 0x07FFFE00 ), LONG2CHARS( 0x07FFFF00 ),
+ LONG2CHARS( 0x07FFFF80 ), LONG2CHARS( 0x07FFFFC0 ), LONG2CHARS( 0x07FFFFE0 ), LONG2CHARS( 0x07FFFFF0 ),
+ LONG2CHARS( 0x07FFFFF8 ), LONG2CHARS( 0x07FFFFFC ), LONG2CHARS( 0x07FFFFFE ), LONG2CHARS( 0x07FFFFFF ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x02000000 ), LONG2CHARS( 0x03000000 ), LONG2CHARS( 0x03800000 ),
+ LONG2CHARS( 0x03C00000 ), LONG2CHARS( 0x03E00000 ), LONG2CHARS( 0x03F00000 ), LONG2CHARS( 0x03F80000 ),
+ LONG2CHARS( 0x03FC0000 ), LONG2CHARS( 0x03FE0000 ), LONG2CHARS( 0x03FF0000 ), LONG2CHARS( 0x03FF8000 ),
+ LONG2CHARS( 0x03FFC000 ), LONG2CHARS( 0x03FFE000 ), LONG2CHARS( 0x03FFF000 ), LONG2CHARS( 0x03FFF800 ),
+ LONG2CHARS( 0x03FFFC00 ), LONG2CHARS( 0x03FFFE00 ), LONG2CHARS( 0x03FFFF00 ), LONG2CHARS( 0x03FFFF80 ),
+ LONG2CHARS( 0x03FFFFC0 ), LONG2CHARS( 0x03FFFFE0 ), LONG2CHARS( 0x03FFFFF0 ), LONG2CHARS( 0x03FFFFF8 ),
+ LONG2CHARS( 0x03FFFFFC ), LONG2CHARS( 0x03FFFFFE ), LONG2CHARS( 0x03FFFFFF ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x01000000 ), LONG2CHARS( 0x01800000 ), LONG2CHARS( 0x01C00000 ),
+ LONG2CHARS( 0x01E00000 ), LONG2CHARS( 0x01F00000 ), LONG2CHARS( 0x01F80000 ), LONG2CHARS( 0x01FC0000 ),
+ LONG2CHARS( 0x01FE0000 ), LONG2CHARS( 0x01FF0000 ), LONG2CHARS( 0x01FF8000 ), LONG2CHARS( 0x01FFC000 ),
+ LONG2CHARS( 0x01FFE000 ), LONG2CHARS( 0x01FFF000 ), LONG2CHARS( 0x01FFF800 ), LONG2CHARS( 0x01FFFC00 ),
+ LONG2CHARS( 0x01FFFE00 ), LONG2CHARS( 0x01FFFF00 ), LONG2CHARS( 0x01FFFF80 ), LONG2CHARS( 0x01FFFFC0 ),
+ LONG2CHARS( 0x01FFFFE0 ), LONG2CHARS( 0x01FFFFF0 ), LONG2CHARS( 0x01FFFFF8 ), LONG2CHARS( 0x01FFFFFC ),
+ LONG2CHARS( 0x01FFFFFE ), LONG2CHARS( 0x01FFFFFF ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00800000 ), LONG2CHARS( 0x00C00000 ), LONG2CHARS( 0x00E00000 ),
+ LONG2CHARS( 0x00F00000 ), LONG2CHARS( 0x00F80000 ), LONG2CHARS( 0x00FC0000 ), LONG2CHARS( 0x00FE0000 ),
+ LONG2CHARS( 0x00FF0000 ), LONG2CHARS( 0x00FF8000 ), LONG2CHARS( 0x00FFC000 ), LONG2CHARS( 0x00FFE000 ),
+ LONG2CHARS( 0x00FFF000 ), LONG2CHARS( 0x00FFF800 ), LONG2CHARS( 0x00FFFC00 ), LONG2CHARS( 0x00FFFE00 ),
+ LONG2CHARS( 0x00FFFF00 ), LONG2CHARS( 0x00FFFF80 ), LONG2CHARS( 0x00FFFFC0 ), LONG2CHARS( 0x00FFFFE0 ),
+ LONG2CHARS( 0x00FFFFF0 ), LONG2CHARS( 0x00FFFFF8 ), LONG2CHARS( 0x00FFFFFC ), LONG2CHARS( 0x00FFFFFE ),
+ LONG2CHARS( 0x00FFFFFF ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00400000 ), LONG2CHARS( 0x00600000 ), LONG2CHARS( 0x00700000 ),
+ LONG2CHARS( 0x00780000 ), LONG2CHARS( 0x007C0000 ), LONG2CHARS( 0x007E0000 ), LONG2CHARS( 0x007F0000 ),
+ LONG2CHARS( 0x007F8000 ), LONG2CHARS( 0x007FC000 ), LONG2CHARS( 0x007FE000 ), LONG2CHARS( 0x007FF000 ),
+ LONG2CHARS( 0x007FF800 ), LONG2CHARS( 0x007FFC00 ), LONG2CHARS( 0x007FFE00 ), LONG2CHARS( 0x007FFF00 ),
+ LONG2CHARS( 0x007FFF80 ), LONG2CHARS( 0x007FFFC0 ), LONG2CHARS( 0x007FFFE0 ), LONG2CHARS( 0x007FFFF0 ),
+ LONG2CHARS( 0x007FFFF8 ), LONG2CHARS( 0x007FFFFC ), LONG2CHARS( 0x007FFFFE ), LONG2CHARS( 0x007FFFFF ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00200000 ), LONG2CHARS( 0x00300000 ), LONG2CHARS( 0x00380000 ),
+ LONG2CHARS( 0x003C0000 ), LONG2CHARS( 0x003E0000 ), LONG2CHARS( 0x003F0000 ), LONG2CHARS( 0x003F8000 ),
+ LONG2CHARS( 0x003FC000 ), LONG2CHARS( 0x003FE000 ), LONG2CHARS( 0x003FF000 ), LONG2CHARS( 0x003FF800 ),
+ LONG2CHARS( 0x003FFC00 ), LONG2CHARS( 0x003FFE00 ), LONG2CHARS( 0x003FFF00 ), LONG2CHARS( 0x003FFF80 ),
+ LONG2CHARS( 0x003FFFC0 ), LONG2CHARS( 0x003FFFE0 ), LONG2CHARS( 0x003FFFF0 ), LONG2CHARS( 0x003FFFF8 ),
+ LONG2CHARS( 0x003FFFFC ), LONG2CHARS( 0x003FFFFE ), LONG2CHARS( 0x003FFFFF ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00100000 ), LONG2CHARS( 0x00180000 ), LONG2CHARS( 0x001C0000 ),
+ LONG2CHARS( 0x001E0000 ), LONG2CHARS( 0x001F0000 ), LONG2CHARS( 0x001F8000 ), LONG2CHARS( 0x001FC000 ),
+ LONG2CHARS( 0x001FE000 ), LONG2CHARS( 0x001FF000 ), LONG2CHARS( 0x001FF800 ), LONG2CHARS( 0x001FFC00 ),
+ LONG2CHARS( 0x001FFE00 ), LONG2CHARS( 0x001FFF00 ), LONG2CHARS( 0x001FFF80 ), LONG2CHARS( 0x001FFFC0 ),
+ LONG2CHARS( 0x001FFFE0 ), LONG2CHARS( 0x001FFFF0 ), LONG2CHARS( 0x001FFFF8 ), LONG2CHARS( 0x001FFFFC ),
+ LONG2CHARS( 0x001FFFFE ), LONG2CHARS( 0x001FFFFF ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00080000 ), LONG2CHARS( 0x000C0000 ), LONG2CHARS( 0x000E0000 ),
+ LONG2CHARS( 0x000F0000 ), LONG2CHARS( 0x000F8000 ), LONG2CHARS( 0x000FC000 ), LONG2CHARS( 0x000FE000 ),
+ LONG2CHARS( 0x000FF000 ), LONG2CHARS( 0x000FF800 ), LONG2CHARS( 0x000FFC00 ), LONG2CHARS( 0x000FFE00 ),
+ LONG2CHARS( 0x000FFF00 ), LONG2CHARS( 0x000FFF80 ), LONG2CHARS( 0x000FFFC0 ), LONG2CHARS( 0x000FFFE0 ),
+ LONG2CHARS( 0x000FFFF0 ), LONG2CHARS( 0x000FFFF8 ), LONG2CHARS( 0x000FFFFC ), LONG2CHARS( 0x000FFFFE ),
+ LONG2CHARS( 0x000FFFFF ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00040000 ), LONG2CHARS( 0x00060000 ), LONG2CHARS( 0x00070000 ),
+ LONG2CHARS( 0x00078000 ), LONG2CHARS( 0x0007C000 ), LONG2CHARS( 0x0007E000 ), LONG2CHARS( 0x0007F000 ),
+ LONG2CHARS( 0x0007F800 ), LONG2CHARS( 0x0007FC00 ), LONG2CHARS( 0x0007FE00 ), LONG2CHARS( 0x0007FF00 ),
+ LONG2CHARS( 0x0007FF80 ), LONG2CHARS( 0x0007FFC0 ), LONG2CHARS( 0x0007FFE0 ), LONG2CHARS( 0x0007FFF0 ),
+ LONG2CHARS( 0x0007FFF8 ), LONG2CHARS( 0x0007FFFC ), LONG2CHARS( 0x0007FFFE ), LONG2CHARS( 0x0007FFFF ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00020000 ), LONG2CHARS( 0x00030000 ), LONG2CHARS( 0x00038000 ),
+ LONG2CHARS( 0x0003C000 ), LONG2CHARS( 0x0003E000 ), LONG2CHARS( 0x0003F000 ), LONG2CHARS( 0x0003F800 ),
+ LONG2CHARS( 0x0003FC00 ), LONG2CHARS( 0x0003FE00 ), LONG2CHARS( 0x0003FF00 ), LONG2CHARS( 0x0003FF80 ),
+ LONG2CHARS( 0x0003FFC0 ), LONG2CHARS( 0x0003FFE0 ), LONG2CHARS( 0x0003FFF0 ), LONG2CHARS( 0x0003FFF8 ),
+ LONG2CHARS( 0x0003FFFC ), LONG2CHARS( 0x0003FFFE ), LONG2CHARS( 0x0003FFFF ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00010000 ), LONG2CHARS( 0x00018000 ), LONG2CHARS( 0x0001C000 ),
+ LONG2CHARS( 0x0001E000 ), LONG2CHARS( 0x0001F000 ), LONG2CHARS( 0x0001F800 ), LONG2CHARS( 0x0001FC00 ),
+ LONG2CHARS( 0x0001FE00 ), LONG2CHARS( 0x0001FF00 ), LONG2CHARS( 0x0001FF80 ), LONG2CHARS( 0x0001FFC0 ),
+ LONG2CHARS( 0x0001FFE0 ), LONG2CHARS( 0x0001FFF0 ), LONG2CHARS( 0x0001FFF8 ), LONG2CHARS( 0x0001FFFC ),
+ LONG2CHARS( 0x0001FFFE ), LONG2CHARS( 0x0001FFFF ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00008000 ), LONG2CHARS( 0x0000C000 ), LONG2CHARS( 0x0000E000 ),
+ LONG2CHARS( 0x0000F000 ), LONG2CHARS( 0x0000F800 ), LONG2CHARS( 0x0000FC00 ), LONG2CHARS( 0x0000FE00 ),
+ LONG2CHARS( 0x0000FF00 ), LONG2CHARS( 0x0000FF80 ), LONG2CHARS( 0x0000FFC0 ), LONG2CHARS( 0x0000FFE0 ),
+ LONG2CHARS( 0x0000FFF0 ), LONG2CHARS( 0x0000FFF8 ), LONG2CHARS( 0x0000FFFC ), LONG2CHARS( 0x0000FFFE ),
+ LONG2CHARS( 0x0000FFFF ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00004000 ), LONG2CHARS( 0x00006000 ), LONG2CHARS( 0x00007000 ),
+ LONG2CHARS( 0x00007800 ), LONG2CHARS( 0x00007C00 ), LONG2CHARS( 0x00007E00 ), LONG2CHARS( 0x00007F00 ),
+ LONG2CHARS( 0x00007F80 ), LONG2CHARS( 0x00007FC0 ), LONG2CHARS( 0x00007FE0 ), LONG2CHARS( 0x00007FF0 ),
+ LONG2CHARS( 0x00007FF8 ), LONG2CHARS( 0x00007FFC ), LONG2CHARS( 0x00007FFE ), LONG2CHARS( 0x00007FFF ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00002000 ), LONG2CHARS( 0x00003000 ), LONG2CHARS( 0x00003800 ),
+ LONG2CHARS( 0x00003C00 ), LONG2CHARS( 0x00003E00 ), LONG2CHARS( 0x00003F00 ), LONG2CHARS( 0x00003F80 ),
+ LONG2CHARS( 0x00003FC0 ), LONG2CHARS( 0x00003FE0 ), LONG2CHARS( 0x00003FF0 ), LONG2CHARS( 0x00003FF8 ),
+ LONG2CHARS( 0x00003FFC ), LONG2CHARS( 0x00003FFE ), LONG2CHARS( 0x00003FFF ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00001000 ), LONG2CHARS( 0x00001800 ), LONG2CHARS( 0x00001C00 ),
+ LONG2CHARS( 0x00001E00 ), LONG2CHARS( 0x00001F00 ), LONG2CHARS( 0x00001F80 ), LONG2CHARS( 0x00001FC0 ),
+ LONG2CHARS( 0x00001FE0 ), LONG2CHARS( 0x00001FF0 ), LONG2CHARS( 0x00001FF8 ), LONG2CHARS( 0x00001FFC ),
+ LONG2CHARS( 0x00001FFE ), LONG2CHARS( 0x00001FFF ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000800 ), LONG2CHARS( 0x00000C00 ), LONG2CHARS( 0x00000E00 ),
+ LONG2CHARS( 0x00000F00 ), LONG2CHARS( 0x00000F80 ), LONG2CHARS( 0x00000FC0 ), LONG2CHARS( 0x00000FE0 ),
+ LONG2CHARS( 0x00000FF0 ), LONG2CHARS( 0x00000FF8 ), LONG2CHARS( 0x00000FFC ), LONG2CHARS( 0x00000FFE ),
+ LONG2CHARS( 0x00000FFF ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000400 ), LONG2CHARS( 0x00000600 ), LONG2CHARS( 0x00000700 ),
+ LONG2CHARS( 0x00000780 ), LONG2CHARS( 0x000007C0 ), LONG2CHARS( 0x000007E0 ), LONG2CHARS( 0x000007F0 ),
+ LONG2CHARS( 0x000007F8 ), LONG2CHARS( 0x000007FC ), LONG2CHARS( 0x000007FE ), LONG2CHARS( 0x000007FF ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000200 ), LONG2CHARS( 0x00000300 ), LONG2CHARS( 0x00000380 ),
+ LONG2CHARS( 0x000003C0 ), LONG2CHARS( 0x000003E0 ), LONG2CHARS( 0x000003F0 ), LONG2CHARS( 0x000003F8 ),
+ LONG2CHARS( 0x000003FC ), LONG2CHARS( 0x000003FE ), LONG2CHARS( 0x000003FF ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000100 ), LONG2CHARS( 0x00000180 ), LONG2CHARS( 0x000001C0 ),
+ LONG2CHARS( 0x000001E0 ), LONG2CHARS( 0x000001F0 ), LONG2CHARS( 0x000001F8 ), LONG2CHARS( 0x000001FC ),
+ LONG2CHARS( 0x000001FE ), LONG2CHARS( 0x000001FF ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000080 ), LONG2CHARS( 0x000000C0 ), LONG2CHARS( 0x000000E0 ),
+ LONG2CHARS( 0x000000F0 ), LONG2CHARS( 0x000000F8 ), LONG2CHARS( 0x000000FC ), LONG2CHARS( 0x000000FE ),
+ LONG2CHARS( 0x000000FF ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000040 ), LONG2CHARS( 0x00000060 ), LONG2CHARS( 0x00000070 ),
+ LONG2CHARS( 0x00000078 ), LONG2CHARS( 0x0000007C ), LONG2CHARS( 0x0000007E ), LONG2CHARS( 0x0000007F ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000020 ), LONG2CHARS( 0x00000030 ), LONG2CHARS( 0x00000038 ),
+ LONG2CHARS( 0x0000003C ), LONG2CHARS( 0x0000003E ), LONG2CHARS( 0x0000003F ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000010 ), LONG2CHARS( 0x00000018 ), LONG2CHARS( 0x0000001C ),
+ LONG2CHARS( 0x0000001E ), LONG2CHARS( 0x0000001F ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000008 ), LONG2CHARS( 0x0000000C ), LONG2CHARS( 0x0000000E ),
+ LONG2CHARS( 0x0000000F ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000004 ), LONG2CHARS( 0x00000006 ), LONG2CHARS( 0x00000007 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000002 ), LONG2CHARS( 0x00000003 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000001 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+};
+
+#else /* LSBFirst */
+/* NOTE:
+the first element in starttab could be LONG2CHARS( 0xffffffff. making it 0
+lets us deal with a full first word in the middle loop ), rather
+than having to do the multiple reads and masks that we'd
+have to do if we thought it was partial.
+*/
+PixelType starttab[PPW+1] =
+ {
+ LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0xFFFFFFFE ),
+ LONG2CHARS( 0xFFFFFFFC ),
+ LONG2CHARS( 0xFFFFFFF8 ),
+ LONG2CHARS( 0xFFFFFFF0 ),
+ LONG2CHARS( 0xFFFFFFE0 ),
+ LONG2CHARS( 0xFFFFFFC0 ),
+ LONG2CHARS( 0xFFFFFF80 ),
+ LONG2CHARS( 0xFFFFFF00 ),
+ LONG2CHARS( 0xFFFFFE00 ),
+ LONG2CHARS( 0xFFFFFC00 ),
+ LONG2CHARS( 0xFFFFF800 ),
+ LONG2CHARS( 0xFFFFF000 ),
+ LONG2CHARS( 0xFFFFE000 ),
+ LONG2CHARS( 0xFFFFC000 ),
+ LONG2CHARS( 0xFFFF8000 ),
+ LONG2CHARS( 0xFFFF0000 ),
+ LONG2CHARS( 0xFFFE0000 ),
+ LONG2CHARS( 0xFFFC0000 ),
+ LONG2CHARS( 0xFFF80000 ),
+ LONG2CHARS( 0xFFF00000 ),
+ LONG2CHARS( 0xFFE00000 ),
+ LONG2CHARS( 0xFFC00000 ),
+ LONG2CHARS( 0xFF800000 ),
+ LONG2CHARS( 0xFF000000 ),
+ LONG2CHARS( 0xFE000000 ),
+ LONG2CHARS( 0xFC000000 ),
+ LONG2CHARS( 0xF8000000 ),
+ LONG2CHARS( 0xF0000000 ),
+ LONG2CHARS( 0xE0000000 ),
+ LONG2CHARS( 0xC0000000 ),
+ LONG2CHARS( 0x80000000 ),
+ LONG2CHARS( 0x00000000 )
+ };
+
+PixelType endtab[PPW+1] =
+ {
+ LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0x00000001 ),
+ LONG2CHARS( 0x00000003 ),
+ LONG2CHARS( 0x00000007 ),
+ LONG2CHARS( 0x0000000F ),
+ LONG2CHARS( 0x0000001F ),
+ LONG2CHARS( 0x0000003F ),
+ LONG2CHARS( 0x0000007F ),
+ LONG2CHARS( 0x000000FF ),
+ LONG2CHARS( 0x000001FF ),
+ LONG2CHARS( 0x000003FF ),
+ LONG2CHARS( 0x000007FF ),
+ LONG2CHARS( 0x00000FFF ),
+ LONG2CHARS( 0x00001FFF ),
+ LONG2CHARS( 0x00003FFF ),
+ LONG2CHARS( 0x00007FFF ),
+ LONG2CHARS( 0x0000FFFF ),
+ LONG2CHARS( 0x0001FFFF ),
+ LONG2CHARS( 0x0003FFFF ),
+ LONG2CHARS( 0x0007FFFF ),
+ LONG2CHARS( 0x000FFFFF ),
+ LONG2CHARS( 0x001FFFFF ),
+ LONG2CHARS( 0x003FFFFF ),
+ LONG2CHARS( 0x007FFFFF ),
+ LONG2CHARS( 0x00FFFFFF ),
+ LONG2CHARS( 0x01FFFFFF ),
+ LONG2CHARS( 0x03FFFFFF ),
+ LONG2CHARS( 0x07FFFFFF ),
+ LONG2CHARS( 0x0FFFFFFF ),
+ LONG2CHARS( 0x1FFFFFFF ),
+ LONG2CHARS( 0x3FFFFFFF ),
+ LONG2CHARS( 0x7FFFFFFF ),
+ LONG2CHARS( 0xFFFFFFFF )
+ };
+
+
+#ifdef NEED_OLD_MFB_MASKS
+/* a hack ), for now, since the entries for 0 need to be all
+ 1 bits ), not all zeros.
+ this means the code DOES NOT WORK for segments of length
+ 0 (which is only a problem in the horizontal line code.)
+*/
+PixelType startpartial[33] =
+ {
+ LONG2CHARS( 0xFFFFFFFF ),
+ LONG2CHARS( 0xFFFFFFFE ),
+ LONG2CHARS( 0xFFFFFFFC ),
+ LONG2CHARS( 0xFFFFFFF8 ),
+ LONG2CHARS( 0xFFFFFFF0 ),
+ LONG2CHARS( 0xFFFFFFE0 ),
+ LONG2CHARS( 0xFFFFFFC0 ),
+ LONG2CHARS( 0xFFFFFF80 ),
+ LONG2CHARS( 0xFFFFFF00 ),
+ LONG2CHARS( 0xFFFFFE00 ),
+ LONG2CHARS( 0xFFFFFC00 ),
+ LONG2CHARS( 0xFFFFF800 ),
+ LONG2CHARS( 0xFFFFF000 ),
+ LONG2CHARS( 0xFFFFE000 ),
+ LONG2CHARS( 0xFFFFC000 ),
+ LONG2CHARS( 0xFFFF8000 ),
+ LONG2CHARS( 0xFFFF0000 ),
+ LONG2CHARS( 0xFFFE0000 ),
+ LONG2CHARS( 0xFFFC0000 ),
+ LONG2CHARS( 0xFFF80000 ),
+ LONG2CHARS( 0xFFF00000 ),
+ LONG2CHARS( 0xFFE00000 ),
+ LONG2CHARS( 0xFFC00000 ),
+ LONG2CHARS( 0xFF800000 ),
+ LONG2CHARS( 0xFF000000 ),
+ LONG2CHARS( 0xFE000000 ),
+ LONG2CHARS( 0xFC000000 ),
+ LONG2CHARS( 0xF8000000 ),
+ LONG2CHARS( 0xF0000000 ),
+ LONG2CHARS( 0xE0000000 ),
+ LONG2CHARS( 0xC0000000 ),
+ LONG2CHARS( 0x80000000 ),
+ LONG2CHARS( 0x00000000 )
+ };
+
+PixelType endpartial[33] =
+ {
+ LONG2CHARS( 0xFFFFFFFF ),
+ LONG2CHARS( 0x00000001 ),
+ LONG2CHARS( 0x00000003 ),
+ LONG2CHARS( 0x00000007 ),
+ LONG2CHARS( 0x0000000F ),
+ LONG2CHARS( 0x0000001F ),
+ LONG2CHARS( 0x0000003F ),
+ LONG2CHARS( 0x0000007F ),
+ LONG2CHARS( 0x000000FF ),
+ LONG2CHARS( 0x000001FF ),
+ LONG2CHARS( 0x000003FF ),
+ LONG2CHARS( 0x000007FF ),
+ LONG2CHARS( 0x00000FFF ),
+ LONG2CHARS( 0x00001FFF ),
+ LONG2CHARS( 0x00003FFF ),
+ LONG2CHARS( 0x00007FFF ),
+ LONG2CHARS( 0x0000FFFF ),
+ LONG2CHARS( 0x0001FFFF ),
+ LONG2CHARS( 0x0003FFFF ),
+ LONG2CHARS( 0x0007FFFF ),
+ LONG2CHARS( 0x000FFFFF ),
+ LONG2CHARS( 0x001FFFFF ),
+ LONG2CHARS( 0x003FFFFF ),
+ LONG2CHARS( 0x007FFFFF ),
+ LONG2CHARS( 0x00FFFFFF ),
+ LONG2CHARS( 0x01FFFFFF ),
+ LONG2CHARS( 0x03FFFFFF ),
+ LONG2CHARS( 0x07FFFFFF ),
+ LONG2CHARS( 0x0FFFFFFF ),
+ LONG2CHARS( 0x1FFFFFFF ),
+ LONG2CHARS( 0x3FFFFFFF ),
+ LONG2CHARS( 0x7FFFFFFF ),
+ LONG2CHARS( 0xFFFFFFFF )
+ };
+#endif
+
+
+PixelType partmasks[PPW][PPW] = {
+ {LONG2CHARS( 0xFFFFFFFF ), LONG2CHARS( 0x00000001 ), LONG2CHARS( 0x00000003 ), LONG2CHARS( 0x00000007 ),
+ LONG2CHARS( 0x0000000F ), LONG2CHARS( 0x0000001F ), LONG2CHARS( 0x0000003F ), LONG2CHARS( 0x0000007F ),
+ LONG2CHARS( 0x000000FF ), LONG2CHARS( 0x000001FF ), LONG2CHARS( 0x000003FF ), LONG2CHARS( 0x000007FF ),
+ LONG2CHARS( 0x00000FFF ), LONG2CHARS( 0x00001FFF ), LONG2CHARS( 0x00003FFF ), LONG2CHARS( 0x00007FFF ),
+ LONG2CHARS( 0x0000FFFF ), LONG2CHARS( 0x0001FFFF ), LONG2CHARS( 0x0003FFFF ), LONG2CHARS( 0x0007FFFF ),
+ LONG2CHARS( 0x000FFFFF ), LONG2CHARS( 0x001FFFFF ), LONG2CHARS( 0x003FFFFF ), LONG2CHARS( 0x007FFFFF ),
+ LONG2CHARS( 0x00FFFFFF ), LONG2CHARS( 0x01FFFFFF ), LONG2CHARS( 0x03FFFFFF ), LONG2CHARS( 0x07FFFFFF ),
+ LONG2CHARS( 0x0FFFFFFF ), LONG2CHARS( 0x1FFFFFFF ), LONG2CHARS( 0x3FFFFFFF ), LONG2CHARS( 0x7FFFFFFF )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000002 ), LONG2CHARS( 0x00000006 ), LONG2CHARS( 0x0000000E ),
+ LONG2CHARS( 0x0000001E ), LONG2CHARS( 0x0000003E ), LONG2CHARS( 0x0000007E ), LONG2CHARS( 0x000000FE ),
+ LONG2CHARS( 0x000001FE ), LONG2CHARS( 0x000003FE ), LONG2CHARS( 0x000007FE ), LONG2CHARS( 0x00000FFE ),
+ LONG2CHARS( 0x00001FFE ), LONG2CHARS( 0x00003FFE ), LONG2CHARS( 0x00007FFE ), LONG2CHARS( 0x0000FFFE ),
+ LONG2CHARS( 0x0001FFFE ), LONG2CHARS( 0x0003FFFE ), LONG2CHARS( 0x0007FFFE ), LONG2CHARS( 0x000FFFFE ),
+ LONG2CHARS( 0x001FFFFE ), LONG2CHARS( 0x003FFFFE ), LONG2CHARS( 0x007FFFFE ), LONG2CHARS( 0x00FFFFFE ),
+ LONG2CHARS( 0x01FFFFFE ), LONG2CHARS( 0x03FFFFFE ), LONG2CHARS( 0x07FFFFFE ), LONG2CHARS( 0x0FFFFFFE ),
+ LONG2CHARS( 0x1FFFFFFE ), LONG2CHARS( 0x3FFFFFFE ), LONG2CHARS( 0x7FFFFFFE ), LONG2CHARS( 0xFFFFFFFE )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000004 ), LONG2CHARS( 0x0000000C ), LONG2CHARS( 0x0000001C ),
+ LONG2CHARS( 0x0000003C ), LONG2CHARS( 0x0000007C ), LONG2CHARS( 0x000000FC ), LONG2CHARS( 0x000001FC ),
+ LONG2CHARS( 0x000003FC ), LONG2CHARS( 0x000007FC ), LONG2CHARS( 0x00000FFC ), LONG2CHARS( 0x00001FFC ),
+ LONG2CHARS( 0x00003FFC ), LONG2CHARS( 0x00007FFC ), LONG2CHARS( 0x0000FFFC ), LONG2CHARS( 0x0001FFFC ),
+ LONG2CHARS( 0x0003FFFC ), LONG2CHARS( 0x0007FFFC ), LONG2CHARS( 0x000FFFFC ), LONG2CHARS( 0x001FFFFC ),
+ LONG2CHARS( 0x003FFFFC ), LONG2CHARS( 0x007FFFFC ), LONG2CHARS( 0x00FFFFFC ), LONG2CHARS( 0x01FFFFFC ),
+ LONG2CHARS( 0x03FFFFFC ), LONG2CHARS( 0x07FFFFFC ), LONG2CHARS( 0x0FFFFFFC ), LONG2CHARS( 0x1FFFFFFC ),
+ LONG2CHARS( 0x3FFFFFFC ), LONG2CHARS( 0x7FFFFFFC ), LONG2CHARS( 0xFFFFFFFC ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000008 ), LONG2CHARS( 0x00000018 ), LONG2CHARS( 0x00000038 ),
+ LONG2CHARS( 0x00000078 ), LONG2CHARS( 0x000000F8 ), LONG2CHARS( 0x000001F8 ), LONG2CHARS( 0x000003F8 ),
+ LONG2CHARS( 0x000007F8 ), LONG2CHARS( 0x00000FF8 ), LONG2CHARS( 0x00001FF8 ), LONG2CHARS( 0x00003FF8 ),
+ LONG2CHARS( 0X00007FF8 ), LONG2CHARS( 0x0000FFF8 ), LONG2CHARS( 0x0001FFF8 ), LONG2CHARS( 0x0003FFF8 ),
+ LONG2CHARS( 0X0007FFF8 ), LONG2CHARS( 0x000FFFF8 ), LONG2CHARS( 0x001FFFF8 ), LONG2CHARS( 0x003FFFF8 ),
+ LONG2CHARS( 0X007FFFF8 ), LONG2CHARS( 0x00FFFFF8 ), LONG2CHARS( 0x01FFFFF8 ), LONG2CHARS( 0x03FFFFF8 ),
+ LONG2CHARS( 0X07FFFFF8 ), LONG2CHARS( 0x0FFFFFF8 ), LONG2CHARS( 0x1FFFFFF8 ), LONG2CHARS( 0x3FFFFFF8 ),
+ LONG2CHARS( 0X7FFFFFF8 ), LONG2CHARS( 0xFFFFFFF8 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000010 ), LONG2CHARS( 0x00000030 ), LONG2CHARS( 0x00000070 ),
+ LONG2CHARS( 0X000000F0 ), LONG2CHARS( 0x000001F0 ), LONG2CHARS( 0x000003F0 ), LONG2CHARS( 0x000007F0 ),
+ LONG2CHARS( 0X00000FF0 ), LONG2CHARS( 0x00001FF0 ), LONG2CHARS( 0x00003FF0 ), LONG2CHARS( 0x00007FF0 ),
+ LONG2CHARS( 0X0000FFF0 ), LONG2CHARS( 0x0001FFF0 ), LONG2CHARS( 0x0003FFF0 ), LONG2CHARS( 0x0007FFF0 ),
+ LONG2CHARS( 0X000FFFF0 ), LONG2CHARS( 0x001FFFF0 ), LONG2CHARS( 0x003FFFF0 ), LONG2CHARS( 0x007FFFF0 ),
+ LONG2CHARS( 0X00FFFFF0 ), LONG2CHARS( 0x01FFFFF0 ), LONG2CHARS( 0x03FFFFF0 ), LONG2CHARS( 0x07FFFFF0 ),
+ LONG2CHARS( 0X0FFFFFF0 ), LONG2CHARS( 0x1FFFFFF0 ), LONG2CHARS( 0x3FFFFFF0 ), LONG2CHARS( 0x7FFFFFF0 ),
+ LONG2CHARS( 0XFFFFFFF0 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000020 ), LONG2CHARS( 0x00000060 ), LONG2CHARS( 0x000000E0 ),
+ LONG2CHARS( 0X000001E0 ), LONG2CHARS( 0x000003E0 ), LONG2CHARS( 0x000007E0 ), LONG2CHARS( 0x00000FE0 ),
+ LONG2CHARS( 0X00001FE0 ), LONG2CHARS( 0x00003FE0 ), LONG2CHARS( 0x00007FE0 ), LONG2CHARS( 0x0000FFE0 ),
+ LONG2CHARS( 0X0001FFE0 ), LONG2CHARS( 0x0003FFE0 ), LONG2CHARS( 0x0007FFE0 ), LONG2CHARS( 0x000FFFE0 ),
+ LONG2CHARS( 0X001FFFE0 ), LONG2CHARS( 0x003FFFE0 ), LONG2CHARS( 0x007FFFE0 ), LONG2CHARS( 0x00FFFFE0 ),
+ LONG2CHARS( 0X01FFFFE0 ), LONG2CHARS( 0x03FFFFE0 ), LONG2CHARS( 0x07FFFFE0 ), LONG2CHARS( 0x0FFFFFE0 ),
+ LONG2CHARS( 0X1FFFFFE0 ), LONG2CHARS( 0x3FFFFFE0 ), LONG2CHARS( 0x7FFFFFE0 ), LONG2CHARS( 0xFFFFFFE0 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000040 ), LONG2CHARS( 0x000000C0 ), LONG2CHARS( 0x000001C0 ),
+ LONG2CHARS( 0X000003C0 ), LONG2CHARS( 0x000007C0 ), LONG2CHARS( 0x00000FC0 ), LONG2CHARS( 0x00001FC0 ),
+ LONG2CHARS( 0X00003FC0 ), LONG2CHARS( 0x00007FC0 ), LONG2CHARS( 0x0000FFC0 ), LONG2CHARS( 0x0001FFC0 ),
+ LONG2CHARS( 0X0003FFC0 ), LONG2CHARS( 0x0007FFC0 ), LONG2CHARS( 0x000FFFC0 ), LONG2CHARS( 0x001FFFC0 ),
+ LONG2CHARS( 0X003FFFC0 ), LONG2CHARS( 0x007FFFC0 ), LONG2CHARS( 0x00FFFFC0 ), LONG2CHARS( 0x01FFFFC0 ),
+ LONG2CHARS( 0X03FFFFC0 ), LONG2CHARS( 0x07FFFFC0 ), LONG2CHARS( 0x0FFFFFC0 ), LONG2CHARS( 0x1FFFFFC0 ),
+ LONG2CHARS( 0X3FFFFFC0 ), LONG2CHARS( 0x7FFFFFC0 ), LONG2CHARS( 0xFFFFFFC0 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000080 ), LONG2CHARS( 0x00000180 ), LONG2CHARS( 0x00000380 ),
+ LONG2CHARS( 0X00000780 ), LONG2CHARS( 0x00000F80 ), LONG2CHARS( 0x00001F80 ), LONG2CHARS( 0x00003F80 ),
+ LONG2CHARS( 0X00007F80 ), LONG2CHARS( 0x0000FF80 ), LONG2CHARS( 0x0001FF80 ), LONG2CHARS( 0x0003FF80 ),
+ LONG2CHARS( 0X0007FF80 ), LONG2CHARS( 0x000FFF80 ), LONG2CHARS( 0x001FFF80 ), LONG2CHARS( 0x003FFF80 ),
+ LONG2CHARS( 0X007FFF80 ), LONG2CHARS( 0x00FFFF80 ), LONG2CHARS( 0x01FFFF80 ), LONG2CHARS( 0x03FFFF80 ),
+ LONG2CHARS( 0X07FFFF80 ), LONG2CHARS( 0x0FFFFF80 ), LONG2CHARS( 0x1FFFFF80 ), LONG2CHARS( 0x3FFFFF80 ),
+ LONG2CHARS( 0X7FFFFF80 ), LONG2CHARS( 0xFFFFFF80 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000100 ), LONG2CHARS( 0x00000300 ), LONG2CHARS( 0x00000700 ),
+ LONG2CHARS( 0X00000F00 ), LONG2CHARS( 0x00001F00 ), LONG2CHARS( 0x00003F00 ), LONG2CHARS( 0x00007F00 ),
+ LONG2CHARS( 0X0000FF00 ), LONG2CHARS( 0x0001FF00 ), LONG2CHARS( 0x0003FF00 ), LONG2CHARS( 0x0007FF00 ),
+ LONG2CHARS( 0X000FFF00 ), LONG2CHARS( 0x001FFF00 ), LONG2CHARS( 0x003FFF00 ), LONG2CHARS( 0x007FFF00 ),
+ LONG2CHARS( 0X00FFFF00 ), LONG2CHARS( 0x01FFFF00 ), LONG2CHARS( 0x03FFFF00 ), LONG2CHARS( 0x07FFFF00 ),
+ LONG2CHARS( 0X0FFFFF00 ), LONG2CHARS( 0x1FFFFF00 ), LONG2CHARS( 0x3FFFFF00 ), LONG2CHARS( 0x7FFFFF00 ),
+ LONG2CHARS( 0XFFFFFF00 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000200 ), LONG2CHARS( 0x00000600 ), LONG2CHARS( 0x00000E00 ),
+ LONG2CHARS( 0X00001E00 ), LONG2CHARS( 0x00003E00 ), LONG2CHARS( 0x00007E00 ), LONG2CHARS( 0x0000FE00 ),
+ LONG2CHARS( 0X0001FE00 ), LONG2CHARS( 0x0003FE00 ), LONG2CHARS( 0x0007FE00 ), LONG2CHARS( 0x000FFE00 ),
+ LONG2CHARS( 0X001FFE00 ), LONG2CHARS( 0x003FFE00 ), LONG2CHARS( 0x007FFE00 ), LONG2CHARS( 0x00FFFE00 ),
+ LONG2CHARS( 0X01FFFE00 ), LONG2CHARS( 0x03FFFE00 ), LONG2CHARS( 0x07FFFE00 ), LONG2CHARS( 0x0FFFFE00 ),
+ LONG2CHARS( 0X1FFFFE00 ), LONG2CHARS( 0x3FFFFE00 ), LONG2CHARS( 0x7FFFFE00 ), LONG2CHARS( 0xFFFFFE00 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000400 ), LONG2CHARS( 0x00000C00 ), LONG2CHARS( 0x00001C00 ),
+ LONG2CHARS( 0X00003C00 ), LONG2CHARS( 0x00007C00 ), LONG2CHARS( 0x0000FC00 ), LONG2CHARS( 0x0001FC00 ),
+ LONG2CHARS( 0X0003FC00 ), LONG2CHARS( 0x0007FC00 ), LONG2CHARS( 0x000FFC00 ), LONG2CHARS( 0x001FFC00 ),
+ LONG2CHARS( 0X003FFC00 ), LONG2CHARS( 0x007FFC00 ), LONG2CHARS( 0x00FFFC00 ), LONG2CHARS( 0x01FFFC00 ),
+ LONG2CHARS( 0X03FFFC00 ), LONG2CHARS( 0x07FFFC00 ), LONG2CHARS( 0x0FFFFC00 ), LONG2CHARS( 0x1FFFFC00 ),
+ LONG2CHARS( 0X3FFFFC00 ), LONG2CHARS( 0x7FFFFC00 ), LONG2CHARS( 0xFFFFFC00 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000800 ), LONG2CHARS( 0x00001800 ), LONG2CHARS( 0x00003800 ),
+ LONG2CHARS( 0X00007800 ), LONG2CHARS( 0x0000F800 ), LONG2CHARS( 0x0001F800 ), LONG2CHARS( 0x0003F800 ),
+ LONG2CHARS( 0X0007F800 ), LONG2CHARS( 0x000FF800 ), LONG2CHARS( 0x001FF800 ), LONG2CHARS( 0x003FF800 ),
+ LONG2CHARS( 0X007FF800 ), LONG2CHARS( 0x00FFF800 ), LONG2CHARS( 0x01FFF800 ), LONG2CHARS( 0x03FFF800 ),
+ LONG2CHARS( 0X07FFF800 ), LONG2CHARS( 0x0FFFF800 ), LONG2CHARS( 0x1FFFF800 ), LONG2CHARS( 0x3FFFF800 ),
+ LONG2CHARS( 0X7FFFF800 ), LONG2CHARS( 0xFFFFF800 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00001000 ), LONG2CHARS( 0x00003000 ), LONG2CHARS( 0x00007000 ),
+ LONG2CHARS( 0X0000F000 ), LONG2CHARS( 0x0001F000 ), LONG2CHARS( 0x0003F000 ), LONG2CHARS( 0x0007F000 ),
+ LONG2CHARS( 0X000FF000 ), LONG2CHARS( 0x001FF000 ), LONG2CHARS( 0x003FF000 ), LONG2CHARS( 0x007FF000 ),
+ LONG2CHARS( 0X00FFF000 ), LONG2CHARS( 0x01FFF000 ), LONG2CHARS( 0x03FFF000 ), LONG2CHARS( 0x07FFF000 ),
+ LONG2CHARS( 0X0FFFF000 ), LONG2CHARS( 0x1FFFF000 ), LONG2CHARS( 0x3FFFF000 ), LONG2CHARS( 0x7FFFF000 ),
+ LONG2CHARS( 0XFFFFF000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00002000 ), LONG2CHARS( 0x00006000 ), LONG2CHARS( 0x0000E000 ),
+ LONG2CHARS( 0X0001E000 ), LONG2CHARS( 0x0003E000 ), LONG2CHARS( 0x0007E000 ), LONG2CHARS( 0x000FE000 ),
+ LONG2CHARS( 0X001FE000 ), LONG2CHARS( 0x003FE000 ), LONG2CHARS( 0x007FE000 ), LONG2CHARS( 0x00FFE000 ),
+ LONG2CHARS( 0X01FFE000 ), LONG2CHARS( 0x03FFE000 ), LONG2CHARS( 0x07FFE000 ), LONG2CHARS( 0x0FFFE000 ),
+ LONG2CHARS( 0X1FFFE000 ), LONG2CHARS( 0x3FFFE000 ), LONG2CHARS( 0x7FFFE000 ), LONG2CHARS( 0xFFFFE000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00004000 ), LONG2CHARS( 0x0000C000 ), LONG2CHARS( 0x0001C000 ),
+ LONG2CHARS( 0X0003C000 ), LONG2CHARS( 0x0007C000 ), LONG2CHARS( 0x000FC000 ), LONG2CHARS( 0x001FC000 ),
+ LONG2CHARS( 0X003FC000 ), LONG2CHARS( 0x007FC000 ), LONG2CHARS( 0x00FFC000 ), LONG2CHARS( 0x01FFC000 ),
+ LONG2CHARS( 0X03FFC000 ), LONG2CHARS( 0x07FFC000 ), LONG2CHARS( 0x0FFFC000 ), LONG2CHARS( 0x1FFFC000 ),
+ LONG2CHARS( 0X3FFFC000 ), LONG2CHARS( 0x7FFFC000 ), LONG2CHARS( 0xFFFFC000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00008000 ), LONG2CHARS( 0x00018000 ), LONG2CHARS( 0x00038000 ),
+ LONG2CHARS( 0X00078000 ), LONG2CHARS( 0x000F8000 ), LONG2CHARS( 0x001F8000 ), LONG2CHARS( 0x003F8000 ),
+ LONG2CHARS( 0X007F8000 ), LONG2CHARS( 0x00FF8000 ), LONG2CHARS( 0x01FF8000 ), LONG2CHARS( 0x03FF8000 ),
+ LONG2CHARS( 0X07FF8000 ), LONG2CHARS( 0x0FFF8000 ), LONG2CHARS( 0x1FFF8000 ), LONG2CHARS( 0x3FFF8000 ),
+ LONG2CHARS( 0X7FFF8000 ), LONG2CHARS( 0xFFFF8000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00010000 ), LONG2CHARS( 0x00030000 ), LONG2CHARS( 0x00070000 ),
+ LONG2CHARS( 0X000F0000 ), LONG2CHARS( 0x001F0000 ), LONG2CHARS( 0x003F0000 ), LONG2CHARS( 0x007F0000 ),
+ LONG2CHARS( 0X00FF0000 ), LONG2CHARS( 0x01FF0000 ), LONG2CHARS( 0x03FF0000 ), LONG2CHARS( 0x07FF0000 ),
+ LONG2CHARS( 0X0FFF0000 ), LONG2CHARS( 0x1FFF0000 ), LONG2CHARS( 0x3FFF0000 ), LONG2CHARS( 0x7FFF0000 ),
+ LONG2CHARS( 0XFFFF0000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00020000 ), LONG2CHARS( 0x00060000 ), LONG2CHARS( 0x000E0000 ),
+ LONG2CHARS( 0X001E0000 ), LONG2CHARS( 0x003E0000 ), LONG2CHARS( 0x007E0000 ), LONG2CHARS( 0x00FE0000 ),
+ LONG2CHARS( 0X01FE0000 ), LONG2CHARS( 0x03FE0000 ), LONG2CHARS( 0x07FE0000 ), LONG2CHARS( 0x0FFE0000 ),
+ LONG2CHARS( 0X1FFE0000 ), LONG2CHARS( 0x3FFE0000 ), LONG2CHARS( 0x7FFE0000 ), LONG2CHARS( 0xFFFE0000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00040000 ), LONG2CHARS( 0x000C0000 ), LONG2CHARS( 0x001C0000 ),
+ LONG2CHARS( 0X003C0000 ), LONG2CHARS( 0x007C0000 ), LONG2CHARS( 0x00FC0000 ), LONG2CHARS( 0x01FC0000 ),
+ LONG2CHARS( 0X03FC0000 ), LONG2CHARS( 0x07FC0000 ), LONG2CHARS( 0x0FFC0000 ), LONG2CHARS( 0x1FFC0000 ),
+ LONG2CHARS( 0X3FFC0000 ), LONG2CHARS( 0x7FFC0000 ), LONG2CHARS( 0xFFFC0000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00080000 ), LONG2CHARS( 0x00180000 ), LONG2CHARS( 0x00380000 ),
+ LONG2CHARS( 0X00780000 ), LONG2CHARS( 0x00F80000 ), LONG2CHARS( 0x01F80000 ), LONG2CHARS( 0x03F80000 ),
+ LONG2CHARS( 0X07F80000 ), LONG2CHARS( 0x0FF80000 ), LONG2CHARS( 0x1FF80000 ), LONG2CHARS( 0x3FF80000 ),
+ LONG2CHARS( 0X7FF80000 ), LONG2CHARS( 0xFFF80000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00100000 ), LONG2CHARS( 0x00300000 ), LONG2CHARS( 0x00700000 ),
+ LONG2CHARS( 0X00F00000 ), LONG2CHARS( 0x01F00000 ), LONG2CHARS( 0x03F00000 ), LONG2CHARS( 0x07F00000 ),
+ LONG2CHARS( 0X0FF00000 ), LONG2CHARS( 0x1FF00000 ), LONG2CHARS( 0x3FF00000 ), LONG2CHARS( 0x7FF00000 ),
+ LONG2CHARS( 0XFFF00000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00200000 ), LONG2CHARS( 0x00600000 ), LONG2CHARS( 0x00E00000 ),
+ LONG2CHARS( 0X01E00000 ), LONG2CHARS( 0x03E00000 ), LONG2CHARS( 0x07E00000 ), LONG2CHARS( 0x0FE00000 ),
+ LONG2CHARS( 0X1FE00000 ), LONG2CHARS( 0x3FE00000 ), LONG2CHARS( 0x7FE00000 ), LONG2CHARS( 0xFFE00000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00400000 ), LONG2CHARS( 0x00C00000 ), LONG2CHARS( 0x01C00000 ),
+ LONG2CHARS( 0X03C00000 ), LONG2CHARS( 0x07C00000 ), LONG2CHARS( 0x0FC00000 ), LONG2CHARS( 0x1FC00000 ),
+ LONG2CHARS( 0X3FC00000 ), LONG2CHARS( 0x7FC00000 ), LONG2CHARS( 0xFFC00000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00800000 ), LONG2CHARS( 0x01800000 ), LONG2CHARS( 0x03800000 ),
+ LONG2CHARS( 0X07800000 ), LONG2CHARS( 0x0F800000 ), LONG2CHARS( 0x1F800000 ), LONG2CHARS( 0x3F800000 ),
+ LONG2CHARS( 0X7F800000 ), LONG2CHARS( 0xFF800000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x01000000 ), LONG2CHARS( 0x03000000 ), LONG2CHARS( 0x07000000 ),
+ LONG2CHARS( 0X0F000000 ), LONG2CHARS( 0x1F000000 ), LONG2CHARS( 0x3F000000 ), LONG2CHARS( 0x7F000000 ),
+ LONG2CHARS( 0XFF000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x02000000 ), LONG2CHARS( 0x06000000 ), LONG2CHARS( 0x0E000000 ),
+ LONG2CHARS( 0X1E000000 ), LONG2CHARS( 0x3E000000 ), LONG2CHARS( 0x7E000000 ), LONG2CHARS( 0xFE000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x04000000 ), LONG2CHARS( 0x0C000000 ), LONG2CHARS( 0x1C000000 ),
+ LONG2CHARS( 0X3C000000 ), LONG2CHARS( 0x7C000000 ), LONG2CHARS( 0xFC000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x08000000 ), LONG2CHARS( 0x18000000 ), LONG2CHARS( 0x38000000 ),
+ LONG2CHARS( 0X78000000 ), LONG2CHARS( 0xF8000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x10000000 ), LONG2CHARS( 0x30000000 ), LONG2CHARS( 0x70000000 ),
+ LONG2CHARS( 0XF0000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x20000000 ), LONG2CHARS( 0x60000000 ), LONG2CHARS( 0xE0000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x40000000 ), LONG2CHARS( 0xC0000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+ {LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x80000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ),
+ LONG2CHARS( 0X00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 ), LONG2CHARS( 0x00000000 )},
+};
+
+#endif /* BITMAP_BIT_ORDER */
+
+/* used for masking bits in bresenham lines
+ mask[n] is used to mask out all but bit n in a longword (n is a
+screen position).
+ rmask[n] is used to mask out the single bit at position n (n
+is a screen posiotion.)
+*/
+
+#define _1_ ((PixelType)1)
+
+#if (BITMAP_BIT_ORDER == MSBFirst)
+PixelType mask[PPW] =
+ {
+ LONG2CHARS( _1_<<31 ), LONG2CHARS( 1<<30 ), LONG2CHARS( 1<<29 ),
+ LONG2CHARS( 1<<28 ), LONG2CHARS( 1<<27 ), LONG2CHARS( 1<<26 ),
+ LONG2CHARS( 1<<25 ), LONG2CHARS( 1<<24 ), LONG2CHARS( 1<<23 ),
+ LONG2CHARS( 1<<22 ), LONG2CHARS( 1<<21 ), LONG2CHARS( 1<<20 ),
+ LONG2CHARS( 1<<19 ), LONG2CHARS( 1<<18 ), LONG2CHARS( 1<<17 ),
+ LONG2CHARS( 1<<16 ), LONG2CHARS( 1<<15 ), LONG2CHARS( 1<<14 ),
+ LONG2CHARS( 1<<13 ), LONG2CHARS( 1<<12 ), LONG2CHARS( 1<<11 ),
+ LONG2CHARS( 1<<10 ), LONG2CHARS( 1<<9 ), LONG2CHARS( 1<<8 ),
+ LONG2CHARS( 1<<7 ), LONG2CHARS( 1<<6 ), LONG2CHARS( 1<<5 ),
+ LONG2CHARS( 1<<4 ), LONG2CHARS( 1<<3 ), LONG2CHARS( 1<<2 ),
+ LONG2CHARS( 1<<1 ), LONG2CHARS( 1<<0 )
+ };
+
+PixelType rmask[] =
+ {
+ 0xffffffff ^ LONG2CHARS( _1_<<31 ), 0xffffffff ^ LONG2CHARS( 1<<30 ),
+ 0xffffffff ^ LONG2CHARS( 1<<29 ), 0xffffffff ^ LONG2CHARS( 1<<28),
+ 0xffffffff ^ LONG2CHARS( 1<<27 ), 0xffffffff ^ LONG2CHARS( 1<<26),
+ 0xffffffff ^ LONG2CHARS( 1<<25 ), 0xffffffff ^ LONG2CHARS( 1<<24 ),
+ 0xffffffff ^ LONG2CHARS( 1<<23 ), 0xffffffff ^ LONG2CHARS( 1<<22),
+ 0xffffffff ^ LONG2CHARS( 1<<21 ), 0xffffffff ^ LONG2CHARS( 1<<20),
+ 0xffffffff ^ LONG2CHARS( 1<<19 ), 0xffffffff ^ LONG2CHARS( 1<<18 ),
+ 0xffffffff ^ LONG2CHARS( 1<<17 ), 0xffffffff ^ LONG2CHARS( 1<<16),
+ 0xffffffff ^ LONG2CHARS( 1<<15 ), 0xffffffff ^ LONG2CHARS( 1<<14),
+ 0xffffffff ^ LONG2CHARS( 1<<13 ), 0xffffffff ^ LONG2CHARS( 1<<12 ),
+ 0xffffffff ^ LONG2CHARS( 1<<11 ), 0xffffffff ^ LONG2CHARS( 1<<10),
+ 0xffffffff ^ LONG2CHARS( 1<<9 ), 0xffffffff ^ LONG2CHARS( 1<<8),
+ 0xffffffff ^ LONG2CHARS( 1<<7 ), 0xffffffff ^ LONG2CHARS( 1<<6),
+ 0xffffffff ^ LONG2CHARS( 1<<5 ), 0xffffffff ^ LONG2CHARS( 1<<4),
+ 0xffffffff ^ LONG2CHARS( 1<<3 ), 0xffffffff ^ LONG2CHARS( 1<<2),
+ 0xffffffff ^ LONG2CHARS( 1<<1 ), 0xffffffff ^ LONG2CHARS( 1<<0)
+ };
+#else /* LSBFirst */
+PixelType mask[] =
+ {
+ LONG2CHARS( 1<<0 ), LONG2CHARS( 1<<1 ), LONG2CHARS( 1<<2),
+ LONG2CHARS( 1<<3 ), LONG2CHARS( 1<<4 ), LONG2CHARS( 1<<5),
+ LONG2CHARS( 1<<6 ), LONG2CHARS( 1<<7 ), LONG2CHARS( 1<<8),
+ LONG2CHARS( 1<<9 ), LONG2CHARS( 1<<10 ), LONG2CHARS( 1<<11),
+ LONG2CHARS( 1<<12 ), LONG2CHARS( 1<<13 ), LONG2CHARS( 1<<14),
+ LONG2CHARS( 1<<15 ), LONG2CHARS( 1<<16 ), LONG2CHARS( 1<<17),
+ LONG2CHARS( 1<<18 ), LONG2CHARS( 1<<19 ), LONG2CHARS( 1<<20),
+ LONG2CHARS( 1<<21 ), LONG2CHARS( 1<<22 ), LONG2CHARS( 1<<23),
+ LONG2CHARS( 1<<24 ), LONG2CHARS( 1<<25 ), LONG2CHARS( 1<<26),
+ LONG2CHARS( 1<<27 ), LONG2CHARS( 1<<28 ), LONG2CHARS( 1<<29),
+ LONG2CHARS( 1<<30 ), LONG2CHARS( _1_<<31 )
+ };
+PixelType rmask[] =
+ {
+ 0xffffffff ^ LONG2CHARS( 1<<0), 0xffffffff ^ LONG2CHARS( 1<<1),
+ 0xffffffff ^ LONG2CHARS( 1<<2), 0xffffffff ^ LONG2CHARS( 1<<3),
+ 0xffffffff ^ LONG2CHARS( 1<<4), 0xffffffff ^ LONG2CHARS( 1<<5),
+ 0xffffffff ^ LONG2CHARS( 1<<6), 0xffffffff ^ LONG2CHARS( 1<<7),
+ 0xffffffff ^ LONG2CHARS( 1<<8), 0xffffffff ^ LONG2CHARS( 1<<9),
+ 0xffffffff ^ LONG2CHARS( 1<<10), 0xffffffff ^ LONG2CHARS( 1<<11),
+ 0xffffffff ^ LONG2CHARS( 1<<12), 0xffffffff ^ LONG2CHARS( 1<<13),
+ 0xffffffff ^ LONG2CHARS( 1<<14), 0xffffffff ^ LONG2CHARS( 1<<15),
+ 0xffffffff ^ LONG2CHARS( 1<<16), 0xffffffff ^ LONG2CHARS( 1<<17),
+ 0xffffffff ^ LONG2CHARS( 1<<18), 0xffffffff ^ LONG2CHARS( 1<<19),
+ 0xffffffff ^ LONG2CHARS( 1<<20), 0xffffffff ^ LONG2CHARS( 1<<21),
+ 0xffffffff ^ LONG2CHARS( 1<<22), 0xffffffff ^ LONG2CHARS( 1<<23),
+ 0xffffffff ^ LONG2CHARS( 1<<24), 0xffffffff ^ LONG2CHARS( 1<<25),
+ 0xffffffff ^ LONG2CHARS( 1<<26), 0xffffffff ^ LONG2CHARS( 1<<27),
+ 0xffffffff ^ LONG2CHARS( 1<<28), 0xffffffff ^ LONG2CHARS( 1<<29),
+ 0xffffffff ^ LONG2CHARS( 1<<30), 0xffffffff ^ LONG2CHARS( _1_<<31)
+ };
+#endif /* BITMAP_BIT_ORDER */
+
+#undef _1_
+
+PixelType mfbGetmask(int i) { return mask[i]; }
+PixelType mfbGetrmask(int i) { return rmask[i]; }
+PixelType mfbGetstarttab(int i) { return starttab[i]; }
+PixelType mfbGetendtab(int i) { return endtab[i]; }
+PixelType mfbGetpartmasks(int i, int j) { return partmasks[i][j]; }
+
+/*
+ * Merge raster ops for full src + dest + plane mask
+ *
+ * More clever usage of boolean arithmetic to reduce the
+ * cost of complex raster ops. This is for bitblt and
+ * reduces all 16 raster ops + planemask to a single
+ * expression:
+ *
+ * dst = dst & (src & ca1 ^ cx1) ^ (src & ca2 ^ cx2)
+ *
+ * The array below contains the values for c?? for each
+ * raster op. Those values are further modified by
+ * planemasks on multi-plane displays as follows:
+ *
+ * ca1 &= pm;
+ * cx1 |= ~pm;
+ * ca2 &= pm;
+ * cx2 &= pm;
+ */
+
+#include "mergerop.h"
+
+#define O 0
+#define I ~((MfbBits)0)
+
+mergeRopRec mergeRopBits[16] = {
+{ O,O,O,O, }, /* clear 0x0 0 */
+{ I,O,O,O, }, /* and 0x1 src AND dst */
+{ I,O,I,O, }, /* andReverse 0x2 src AND NOT dst */
+{ O,O,I,O, }, /* copy 0x3 src */
+{ I,I,O,O, }, /* andInverted 0x4 NOT src AND dst */
+{ O,I,O,O, }, /* noop 0x5 dst */
+{ O,I,I,O, }, /* xor 0x6 src XOR dst */
+{ I,I,I,O, }, /* or 0x7 src OR dst */
+{ I,I,I,I, }, /* nor 0x8 NOT src AND NOT dst */
+{ O,I,I,I, }, /* equiv 0x9 NOT src XOR dst */
+{ O,I,O,I, }, /* invert 0xa NOT dst */
+{ I,I,O,I, }, /* orReverse 0xb src OR NOT dst */
+{ O,O,I,I, }, /* copyInverted 0xc NOT src */
+{ I,O,I,I, }, /* orInverted 0xd NOT src OR dst */
+{ I,O,O,I, }, /* nand 0xe NOT src OR NOT dst */
+{ O,O,O,I, }, /* set 0xf 1 */
+};
+
+mergeRopPtr mergeGetRopBits(int i) {
+ return &mergeRopBits[i];
+}
+
+#undef O
+#undef I
diff --git a/nx-X11/programs/Xserver/mfb/maskbits.h b/nx-X11/programs/Xserver/mfb/maskbits.h
new file mode 100644
index 000000000..ed5cc2687
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/maskbits.h
@@ -0,0 +1,691 @@
+/* $XFree86: xc/programs/Xserver/mfb/maskbits.h,v 3.8tsi Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.1, 1/24/89 */
+/***********************************************************
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: maskbits.h,v 1.3 2000/08/17 19:53:34 cpqbld Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+
+
+/* the following notes use the following conventions:
+SCREEN LEFT SCREEN RIGHT
+in this file and maskbits.c, left and right refer to screen coordinates,
+NOT bit numbering in registers.
+
+starttab[n]
+ bits[0,n-1] = 0 bits[n,PLST] = 1
+endtab[n] =
+ bits[0,n-1] = 1 bits[n,PLST] = 0
+
+startpartial[], endpartial[]
+ these are used as accelerators for doing putbits and masking out
+bits that are all contained between longword boudaries. the extra
+256 bytes of data seems a small price to pay -- code is smaller,
+and narrow things (e.g. window borders) go faster.
+
+the names may seem misleading; they are derived not from which end
+of the word the bits are turned on, but at which end of a scanline
+the table tends to be used.
+
+look at the tables and macros to understand boundary conditions.
+(careful readers will note that starttab[n] = ~endtab[n] for n != 0)
+
+-----------------------------------------------------------------------
+these two macros depend on the screen's bit ordering.
+in both of them x is a screen position. they are used to
+combine bits collected from multiple longwords into a
+single destination longword, and to unpack a single
+source longword into multiple destinations.
+
+SCRLEFT(dst, x)
+ takes dst[x, PPW] and moves them to dst[0, PPW-x]
+ the contents of the rest of dst are 0.
+ this is a right shift on LSBFirst (forward-thinking)
+ machines like the VAX, and left shift on MSBFirst
+ (backwards) machines like the 680x0 and pc/rt.
+
+SCRRIGHT(dst, x)
+ takes dst[0,x] and moves them to dst[PPW-x, PPW]
+ the contents of the rest of dst are 0.
+ this is a left shift on LSBFirst, right shift
+ on MSBFirst.
+
+
+the remaining macros are cpu-independent; all bit order dependencies
+are built into the tables and the two macros above.
+
+maskbits(x, w, startmask, endmask, nlw)
+ for a span of width w starting at position x, returns
+a mask for ragged bits at start, mask for ragged bits at end,
+and the number of whole longwords between the ends.
+
+maskpartialbits(x, w, mask)
+ works like maskbits(), except all the bits are in the
+ same longword (i.e. (x&PIM + w) <= PPW)
+
+maskPPWbits(x, w, startmask, endmask, nlw)
+ as maskbits, but does not calculate nlw. it is used by
+ mfbGlyphBlt to put down glyphs <= PPW bits wide.
+
+-------------------------------------------------------------------
+
+NOTE
+ any pointers passed to the following 4 macros are
+ guranteed to be PPW-bit aligned.
+ The only non-PPW-bit-aligned references ever made are
+ to font glyphs, and those are made with getleftbits()
+ and getshiftedleftbits (qq.v.)
+
+ For 64-bit server, it is assumed that we will never have font padding
+ of more than 4 bytes. The code uses int's to access the fonts
+ intead of longs.
+
+getbits(psrc, x, w, dst)
+ starting at position x in psrc (x < PPW), collect w
+ bits and put them in the screen left portion of dst.
+ psrc is a longword pointer. this may span longword boundaries.
+ it special-cases fetching all w bits from one longword.
+
+ +--------+--------+ +--------+
+ | | m |n| | ==> | m |n| |
+ +--------+--------+ +--------+
+ x x+w 0 w
+ psrc psrc+1 dst
+ m = PPW - x
+ n = w - m
+
+ implementation:
+ get m bits, move to screen-left of dst, zeroing rest of dst;
+ get n bits from next word, move screen-right by m, zeroing
+ lower m bits of word.
+ OR the two things together.
+
+putbits(src, x, w, pdst)
+ starting at position x in pdst, put down the screen-leftmost
+ w bits of src. pdst is a longword pointer. this may
+ span longword boundaries.
+ it special-cases putting all w bits into the same longword.
+
+ +--------+ +--------+--------+
+ | m |n| | ==> | | m |n| |
+ +--------+ +--------+--------+
+ 0 w x x+w
+ dst pdst pdst+1
+ m = PPW - x
+ n = w - m
+
+ implementation:
+ get m bits, shift screen-right by x, zero screen-leftmost x
+ bits; zero rightmost m bits of *pdst and OR in stuff
+ from before the semicolon.
+ shift src screen-left by m, zero bits n-PPW;
+ zero leftmost n bits of *(pdst+1) and OR in the
+ stuff from before the semicolon.
+
+putbitsrop(src, x, w, pdst, ROP)
+ like putbits but calls DoRop with the rasterop ROP (see mfb.h for
+ DoRop)
+
+putbitsrrop(src, x, w, pdst, ROP)
+ like putbits but calls DoRRop with the reduced rasterop ROP
+ (see mfb.h for DoRRop)
+
+-----------------------------------------------------------------------
+ The two macros below are used only for getting bits from glyphs
+in fonts, and glyphs in fonts are gotten only with the following two
+mcros.
+ You should tune these macros toyour font format and cpu
+byte ordering.
+
+NOTE
+getleftbits(psrc, w, dst)
+ get the leftmost w (w<=32) bits from *psrc and put them
+ in dst. this is used by the mfbGlyphBlt code for glyphs
+ <=PPW bits wide.
+ psrc is declared (unsigned char *)
+
+ psrc is NOT guaranteed to be PPW-bit aligned. on many
+ machines this will cause problems, so there are several
+ versions of this macro.
+
+ this macro is called ONLY for getting bits from font glyphs,
+ and depends on the server-natural font padding.
+
+ for blazing text performance, you want this macro
+ to touch memory as infrequently as possible (e.g.
+ fetch longwords) and as efficiently as possible
+ (e.g. don't fetch misaligned longwords)
+
+getshiftedleftbits(psrc, offset, w, dst)
+ used by the font code; like getleftbits, but shifts the
+ bits SCRLEFT by offset.
+ this is implemented portably, calling getleftbits()
+ and SCRLEFT().
+ psrc is declared (unsigned char *).
+*/
+
+/* to match CFB and allow algorithm sharing ...
+ * name mfb32 mfb64 explanation
+ * ---- ------ ----- -----------
+ * PGSZ 32 64 pixel group size (in bits; same as PPW for mfb)
+ * PGSZB 4 8 pixel group size (in bytes)
+ * PPW 32 64 pixels per word (pixels per pixel group)
+ * PLST 31 63 index of last pixel in a word (should be PPW-1)
+ * PIM 0x1f 0x3f pixel index mask (index within a pixel group)
+ * PWSH 5 6 pixel-to-word shift (should be log2(PPW))
+ *
+ * The MFB_ versions are here so that cfb can include maskbits.h to get
+ * the bitmap constants without conflicting with its own P* constants.
+ *
+ * Keith Packard (keithp@suse.com):
+ * Note mfb64 is no longer supported; it requires DIX support
+ * for realigning images which costs too much
+ */
+
+/* warning: PixelType definition duplicated in mfb.h */
+#ifndef PixelType
+#define PixelType CARD32
+#endif /* PixelType */
+#ifndef MfbBits
+#define MfbBits CARD32
+#endif
+
+#define MFB_PGSZB 4
+#define MFB_PPW (MFB_PGSZB<<3) /* assuming 8 bits per byte */
+#define MFB_PGSZ MFB_PPW
+#define MFB_PLST (MFB_PPW-1)
+#define MFB_PIM MFB_PLST
+
+/* set PWSH = log2(PPW) using brute force */
+
+#if MFB_PPW == 32
+#define MFB_PWSH 5
+#endif /* MFB_PPW == 32 */
+
+/* XXX don't use these five */
+extern PixelType starttab[];
+extern PixelType endtab[];
+extern PixelType partmasks[MFB_PPW][MFB_PPW];
+extern PixelType rmask[];
+extern PixelType mask[];
+/* XXX use these five */
+extern PixelType mfbGetstarttab(int);
+extern PixelType mfbGetendtab(int);
+extern PixelType mfbGetpartmasks(int, int);
+extern PixelType mfbGetrmask(int);
+extern PixelType mfbGetmask(int);
+
+#ifndef MFB_CONSTS_ONLY
+
+#define PGSZB MFB_PGSZB
+#define PPW MFB_PPW
+#define PGSZ MFB_PGSZ
+#define PLST MFB_PLST
+#define PIM MFB_PIM
+#define PWSH MFB_PWSH
+
+#define BitLeft(b,s) SCRLEFT(b,s)
+#define BitRight(b,s) SCRRIGHT(b,s)
+
+#ifdef XFree86Server
+#define LONG2CHARSSAMEORDER(x) ((MfbBits)(x))
+#define LONG2CHARSDIFFORDER( x ) ( ( ( ( x ) & (MfbBits)0x000000FF ) << 0x18 ) \
+ | ( ( ( x ) & (MfbBits)0x0000FF00 ) << 0x08 ) \
+ | ( ( ( x ) & (MfbBits)0x00FF0000 ) >> 0x08 ) \
+ | ( ( ( x ) & (MfbBits)0xFF000000 ) >> 0x18 ) )
+#endif /* XFree86Server */
+
+#if (BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER)
+#define LONG2CHARS(x) ((MfbBits)(x))
+#else
+/*
+ * the unsigned case below is for compilers like
+ * the Danbury C and i386cc
+ */
+#define LONG2CHARS( x ) ( ( ( ( x ) & (MfbBits)0x000000FF ) << 0x18 ) \
+ | ( ( ( x ) & (MfbBits)0x0000FF00 ) << 0x08 ) \
+ | ( ( ( x ) & (MfbBits)0x00FF0000 ) >> 0x08 ) \
+ | ( ( ( x ) & (MfbBits)0xFF000000 ) >> 0x18 ) )
+#endif /* BITMAP_BIT_ORDER */
+
+#ifdef STRICT_ANSI_SHIFT
+#define SHL(x,y) ((y) >= PPW ? 0 : LONG2CHARS(LONG2CHARS(x) << (y)))
+#define SHR(x,y) ((y) >= PPW ? 0 : LONG2CHARS(LONG2CHARS(x) >> (y)))
+#else
+#define SHL(x,y) LONG2CHARS(LONG2CHARS(x) << (y))
+#define SHR(x,y) LONG2CHARS(LONG2CHARS(x) >> (y))
+#endif
+
+#if (BITMAP_BIT_ORDER == MSBFirst) /* pc/rt, 680x0 */
+#define SCRLEFT(lw, n) SHL((PixelType)(lw),(n))
+#define SCRRIGHT(lw, n) SHR((PixelType)(lw),(n))
+#else /* vax, intel */
+#define SCRLEFT(lw, n) SHR((PixelType)(lw),(n))
+#define SCRRIGHT(lw, n) SHL((PixelType)(lw),(n))
+#endif
+
+#define DoRRop(alu, src, dst) \
+(((alu) == RROP_BLACK) ? ((dst) & ~(src)) : \
+ ((alu) == RROP_WHITE) ? ((dst) | (src)) : \
+ ((alu) == RROP_INVERT) ? ((dst) ^ (src)) : \
+ (dst))
+
+/* A generalized form of a x4 Duff's Device */
+#define Duff(counter, block) { \
+ while (counter >= 4) {\
+ { block; } \
+ { block; } \
+ { block; } \
+ { block; } \
+ counter -= 4; \
+ } \
+ switch (counter & 3) { \
+ case 3: { block; } \
+ case 2: { block; } \
+ case 1: { block; } \
+ case 0: \
+ counter = 0; \
+ } \
+}
+
+#define maskbits(x, w, startmask, endmask, nlw) \
+ startmask = mfbGetstarttab((x) & PIM); \
+ endmask = mfbGetendtab(((x)+(w)) & PIM); \
+ if (startmask) \
+ nlw = (((w) - (PPW - ((x) & PIM))) >> PWSH); \
+ else \
+ nlw = (w) >> PWSH;
+
+#define maskpartialbits(x, w, mask) \
+ mask = mfbGetpartmasks((x) & PIM, (w) & PIM);
+
+#define maskPPWbits(x, w, startmask, endmask) \
+ startmask = mfbGetstarttab((x) & PIM); \
+ endmask = mfbGetendtab(((x)+(w)) & PIM);
+
+#ifdef __GNUC__ /* XXX don't want for Alpha? */
+#ifdef vax
+#define FASTGETBITS(psrc,x,w,dst) \
+ __asm ("extzv %1,%2,%3,%0" \
+ : "=g" (dst) \
+ : "g" (x), "g" (w), "m" (*(char *)(psrc)))
+#define getbits(psrc,x,w,dst) FASTGETBITS(psrc,x,w,dst)
+
+#define FASTPUTBITS(src, x, w, pdst) \
+ __asm ("insv %3,%1,%2,%0" \
+ : "=m" (*(char *)(pdst)) \
+ : "g" (x), "g" (w), "g" (src))
+#define putbits(src, x, w, pdst) FASTPUTBITS(src, x, w, pdst)
+#endif /* vax */
+#ifdef mc68020
+#define FASTGETBITS(psrc, x, w, dst) \
+ __asm ("bfextu %3{%1:%2},%0" \
+ : "=d" (dst) : "di" (x), "di" (w), "o" (*(char *)(psrc)))
+
+#define getbits(psrc,x,w,dst) \
+{ \
+ FASTGETBITS(psrc, x, w, dst);\
+ dst = SHL(dst,(32-(w))); \
+}
+
+#define FASTPUTBITS(src, x, w, pdst) \
+ __asm ("bfins %3,%0{%1:%2}" \
+ : "=o" (*(char *)(pdst)) \
+ : "di" (x), "di" (w), "d" (src), "0" (*(char *) (pdst)))
+
+#define putbits(src, x, w, pdst) FASTPUTBITS(SHR((src),32-(w)), x, w, pdst)
+
+#endif /* mc68020 */
+#endif /* __GNUC__ */
+
+/* The following flag is used to override a bugfix for sun 3/60+CG4 machines,
+ */
+
+/* We don't need to be careful about this unless we're dealing with sun3's
+ * We will default its usage for those who do not know anything, but will
+ * override its effect if the machine doesn't look like a sun3
+ */
+#if !defined(mc68020) || !defined(sun)
+#define NO_3_60_CG4
+#endif
+
+/* This is gross. We want to #define u_putbits as something which can be used
+ * in the case of the 3/60+CG4, but if we use /bin/cc or are on another
+ * machine type, we want nothing to do with u_putbits. What a hastle. Here
+ * I used slo_putbits as something which either u_putbits or putbits could be
+ * defined as.
+ *
+ * putbits gets it iff it is not already defined with FASTPUTBITS above.
+ * u_putbits gets it if we have FASTPUTBITS (putbits) from above and have not
+ * overridden the NO_3_60_CG4 flag.
+ */
+
+#define slo_putbits(src, x, w, pdst) \
+{ \
+ register int n = (x)+(w)-PPW; \
+ \
+ if (n <= 0) \
+ { \
+ register PixelType tmpmask; \
+ maskpartialbits((x), (w), tmpmask); \
+ *(pdst) = (*(pdst) & ~tmpmask) | \
+ (SCRRIGHT(src, x) & tmpmask); \
+ } \
+ else \
+ { \
+ register int d = PPW-(x); \
+ *(pdst) = (*(pdst) & mfbGetendtab(x)) | (SCRRIGHT((src), x)); \
+ (pdst)[1] = ((pdst)[1] & mfbGetstarttab(n)) | \
+ (SCRLEFT(src, d) & mfbGetendtab(n)); \
+ } \
+}
+
+#if defined(putbits) && !defined(NO_3_60_CG4)
+#define u_putbits(src, x, w, pdst) slo_putbits(src, x, w, pdst)
+#else
+#define u_putbits(src, x, w, pdst) putbits(src, x, w, pdst)
+#endif
+
+#if !defined(putbits)
+#define putbits(src, x, w, pdst) slo_putbits(src, x, w, pdst)
+#endif
+
+/* Now if we have not gotten any really good bitfield macros, try some
+ * moderately fast macros. Alas, I don't know how to do asm instructions
+ * without gcc.
+ */
+
+#ifndef getbits
+#define getbits(psrc, x, w, dst) \
+{ \
+ dst = SCRLEFT(*(psrc), (x)); \
+ if ( ((x) + (w)) > PPW) \
+ dst |= (SCRRIGHT(*((psrc)+1), PPW-(x))); \
+}
+#endif
+
+/* We have to special-case putbitsrop because of 3/60+CG4 combos
+ */
+
+#define u_putbitsrop(src, x, w, pdst, rop) \
+{\
+ register PixelType t1, t2; \
+ register int n = (x)+(w)-PPW; \
+ \
+ t1 = SCRRIGHT((src), (x)); \
+ DoRop(t2, rop, t1, *(pdst)); \
+ \
+ if (n <= 0) \
+ { \
+ register PixelType tmpmask; \
+ \
+ maskpartialbits((x), (w), tmpmask); \
+ *(pdst) = (*(pdst) & ~tmpmask) | (t2 & tmpmask); \
+ } \
+ else \
+ { \
+ int m = PPW-(x); \
+ *(pdst) = (*(pdst) & mfbGetendtab(x)) | (t2 & mfbGetstarttab(x)); \
+ t1 = SCRLEFT((src), m); \
+ DoRop(t2, rop, t1, (pdst)[1]); \
+ (pdst)[1] = ((pdst)[1] & mfbGetstarttab(n)) | (t2 & mfbGetendtab(n)); \
+ } \
+}
+
+/* If our getbits and putbits are FAST enough,
+ * do this brute force, it's faster
+ */
+
+#if defined(FASTPUTBITS) && defined(FASTGETBITS) && defined(NO_3_60_CG4)
+#if (BITMAP_BIT_ORDER == MSBFirst)
+#define putbitsrop(src, x, w, pdst, rop) \
+{ \
+ register PixelType _tmp, _tmp2; \
+ FASTGETBITS(pdst, x, w, _tmp); \
+ _tmp2 = SCRRIGHT(src, PPW-(w)); \
+ DoRop(_tmp, rop, _tmp2, _tmp) \
+ FASTPUTBITS(_tmp, x, w, pdst); \
+}
+#define putbitsrrop(src, x, w, pdst, rop) \
+{ \
+ register PixelType _tmp, _tmp2; \
+ \
+ FASTGETBITS(pdst, x, w, _tmp); \
+ _tmp2 = SCRRIGHT(src, PPW-(w)); \
+ _tmp= DoRRop(rop, _tmp2, _tmp); \
+ FASTPUTBITS(_tmp, x, w, pdst); \
+}
+#undef u_putbitsrop
+#else
+#define putbitsrop(src, x, w, pdst, rop) \
+{ \
+ register PixelType _tmp; \
+ FASTGETBITS(pdst, x, w, _tmp); \
+ DoRop(_tmp, rop, src, _tmp) \
+ FASTPUTBITS(_tmp, x, w, pdst); \
+}
+#define putbitsrrop(src, x, w, pdst, rop) \
+{ \
+ register PixelType _tmp; \
+ \
+ FASTGETBITS(pdst, x, w, _tmp); \
+ _tmp= DoRRop(rop, src, _tmp); \
+ FASTPUTBITS(_tmp, x, w, pdst); \
+}
+#undef u_putbitsrop
+#endif
+#endif
+
+#ifndef putbitsrop
+#define putbitsrop(src, x, w, pdst, rop) u_putbitsrop(src, x, w, pdst, rop)
+#endif
+
+#ifndef putbitsrrop
+#define putbitsrrop(src, x, w, pdst, rop) \
+{\
+ register PixelType t1, t2; \
+ register int n = (x)+(w)-PPW; \
+ \
+ t1 = SCRRIGHT((src), (x)); \
+ t2 = DoRRop(rop, t1, *(pdst)); \
+ \
+ if (n <= 0) \
+ { \
+ register PixelType tmpmask; \
+ \
+ maskpartialbits((x), (w), tmpmask); \
+ *(pdst) = (*(pdst) & ~tmpmask) | (t2 & tmpmask); \
+ } \
+ else \
+ { \
+ int m = PPW-(x); \
+ *(pdst) = (*(pdst) & mfbGetendtab(x)) | (t2 & mfbGetstarttab(x)); \
+ t1 = SCRLEFT((src), m); \
+ t2 = DoRRop(rop, t1, (pdst)[1]); \
+ (pdst)[1] = ((pdst)[1] & mfbGetstarttab(n)) | (t2 & mfbGetendtab(n)); \
+ } \
+}
+#endif
+
+#if GETLEFTBITS_ALIGNMENT == 1
+#define getleftbits(psrc, w, dst) dst = *((CARD32 *)(pointer) psrc)
+#endif /* GETLEFTBITS_ALIGNMENT == 1 */
+
+#if GETLEFTBITS_ALIGNMENT == 2
+#define getleftbits(psrc, w, dst) \
+ { \
+ if ( ((int)(psrc)) & 0x01 ) \
+ getbits( ((CARD32 *)(((char *)(psrc))-1)), 8, (w), (dst) ); \
+ else \
+ getbits(psrc, 0, w, dst); \
+ }
+#endif /* GETLEFTBITS_ALIGNMENT == 2 */
+
+#if GETLEFTBITS_ALIGNMENT == 4
+#define getleftbits(psrc, w, dst) \
+ { \
+ int off, off_b; \
+ off_b = (off = ( ((int)(psrc)) & 0x03)) << 3; \
+ getbits( \
+ (CARD32 *)( ((char *)(psrc)) - off), \
+ (off_b), (w), (dst) \
+ ); \
+ }
+#endif /* GETLEFTBITS_ALIGNMENT == 4 */
+
+
+#define getshiftedleftbits(psrc, offset, w, dst) \
+ getleftbits((psrc), (w), (dst)); \
+ dst = SCRLEFT((dst), (offset));
+
+/* FASTGETBITS and FASTPUTBITS are not necessarily correct implementations of
+ * getbits and putbits, but they work if used together.
+ *
+ * On a MSBFirst machine, a cpu bitfield extract instruction (like bfextu)
+ * could normally assign its result to a 32-bit word register in the screen
+ * right position. This saves canceling register shifts by not fighting the
+ * natural cpu byte order.
+ *
+ * Unfortunately, these fail on a 3/60+CG4 and cannot be used unmodified. Sigh.
+ */
+#if defined(FASTGETBITS) && defined(FASTPUTBITS)
+#ifdef NO_3_60_CG4
+#define u_FASTPUT(aa, bb, cc, dd) FASTPUTBITS(aa, bb, cc, dd)
+#else
+#define u_FASTPUT(aa, bb, cc, dd) u_putbits(SCRLEFT(aa, PPW-(cc)), bb, cc, dd)
+#endif
+
+#define getandputbits(psrc, srcbit, dstbit, width, pdst) \
+{ \
+ register PixelType _tmpbits; \
+ FASTGETBITS(psrc, srcbit, width, _tmpbits); \
+ u_FASTPUT(_tmpbits, dstbit, width, pdst); \
+}
+
+#define getandputrop(psrc, srcbit, dstbit, width, pdst, rop) \
+{ \
+ register PixelType _tmpsrc, _tmpdst; \
+ FASTGETBITS(pdst, dstbit, width, _tmpdst); \
+ FASTGETBITS(psrc, srcbit, width, _tmpsrc); \
+ DoRop(_tmpdst, rop, _tmpsrc, _tmpdst); \
+ u_FASTPUT(_tmpdst, dstbit, width, pdst); \
+}
+
+#define getandputrrop(psrc, srcbit, dstbit, width, pdst, rop) \
+{ \
+ register PixelType _tmpsrc, _tmpdst; \
+ FASTGETBITS(pdst, dstbit, width, _tmpdst); \
+ FASTGETBITS(psrc, srcbit, width, _tmpsrc); \
+ _tmpdst = DoRRop(rop, _tmpsrc, _tmpdst); \
+ u_FASTPUT(_tmpdst, dstbit, width, pdst); \
+}
+
+#define getandputbits0(psrc, srcbit, width, pdst) \
+ getandputbits(psrc, srcbit, 0, width, pdst)
+
+#define getandputrop0(psrc, srcbit, width, pdst, rop) \
+ getandputrop(psrc, srcbit, 0, width, pdst, rop)
+
+#define getandputrrop0(psrc, srcbit, width, pdst, rop) \
+ getandputrrop(psrc, srcbit, 0, width, pdst, rop)
+
+
+#else /* Slow poke */
+
+/* pairs of getbits/putbits happen frequently. Some of the code can
+ * be shared or avoided in a few specific instances. It gets us a
+ * small advantage, so we do it. The getandput...0 macros are the only ones
+ * which speed things here. The others are here for compatibility w/the above
+ * FAST ones
+ */
+
+#define getandputbits(psrc, srcbit, dstbit, width, pdst) \
+{ \
+ register PixelType _tmpbits; \
+ getbits(psrc, srcbit, width, _tmpbits); \
+ putbits(_tmpbits, dstbit, width, pdst); \
+}
+
+#define getandputrop(psrc, srcbit, dstbit, width, pdst, rop) \
+{ \
+ register PixelType _tmpbits; \
+ getbits(psrc, srcbit, width, _tmpbits) \
+ putbitsrop(_tmpbits, dstbit, width, pdst, rop) \
+}
+
+#define getandputrrop(psrc, srcbit, dstbit, width, pdst, rop) \
+{ \
+ register PixelType _tmpbits; \
+ getbits(psrc, srcbit, width, _tmpbits) \
+ putbitsrrop(_tmpbits, dstbit, width, pdst, rop) \
+}
+
+
+#define getandputbits0(psrc, sbindex, width, pdst) \
+{ /* unroll the whole damn thing to see how it * behaves */ \
+ register int _flag = PPW - (sbindex); \
+ register PixelType _src; \
+ \
+ _src = SCRLEFT (*(psrc), (sbindex)); \
+ if ((width) > _flag) \
+ _src |= SCRRIGHT (*((psrc) + 1), _flag); \
+ \
+ *(pdst) = (*(pdst) & mfbGetstarttab((width))) | (_src & mfbGetendtab((width))); \
+}
+
+
+#define getandputrop0(psrc, sbindex, width, pdst, rop) \
+{ \
+ register int _flag = PPW - (sbindex); \
+ register PixelType _src; \
+ \
+ _src = SCRLEFT (*(psrc), (sbindex)); \
+ if ((width) > _flag) \
+ _src |= SCRRIGHT (*((psrc) + 1), _flag); \
+ DoRop(_src, rop, _src, *(pdst)); \
+ \
+ *(pdst) = (*(pdst) & mfbGetstarttab((width))) | (_src & mfbGetendtab((width))); \
+}
+
+#define getandputrrop0(psrc, sbindex, width, pdst, rop) \
+{ \
+ int _flag = PPW - (sbindex); \
+ register PixelType _src; \
+ \
+ _src = SCRLEFT (*(psrc), (sbindex)); \
+ if ((width) > _flag) \
+ _src |= SCRRIGHT (*((psrc) + 1), _flag); \
+ _src = DoRRop(rop, _src, *(pdst)); \
+ \
+ *(pdst) = (*(pdst) & mfbGetstarttab((width))) | (_src & mfbGetendtab((width))); \
+}
+
+#endif /* FASTGETBITS && FASTPUTBITS */
+
+#endif /* MFB_CONSTS_ONLY */
diff --git a/nx-X11/programs/Xserver/mfb/mergerop.h b/nx-X11/programs/Xserver/mfb/mergerop.h
new file mode 100644
index 000000000..c8652eb81
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mergerop.h
@@ -0,0 +1,400 @@
+/*
+ * $Xorg: mergerop.h,v 1.4 2001/02/09 02:05:18 xorgcvs Exp $
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/programs/Xserver/mfb/mergerop.h,v 3.13 2001/10/28 03:34:13 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _MERGEROP_H_
+#define _MERGEROP_H_
+
+#ifndef GXcopy
+#include <X11/X.h>
+#endif
+
+typedef struct _mergeRopBits {
+ MfbBits ca1, cx1, ca2, cx2;
+} mergeRopRec, *mergeRopPtr;
+
+extern mergeRopRec mergeRopBits[16];
+extern mergeRopPtr mergeGetRopBits(int i);
+
+#if defined(PPW) && defined(PGSZ) && (PPW != PGSZ) /* cfb */
+#define DeclareMergeRop() MfbBits _ca1 = 0, _cx1 = 0, _ca2 = 0, _cx2 = 0;
+#define DeclarePrebuiltMergeRop() MfbBits _cca, _ccx;
+#if PSZ == 24 /* both for PGSZ == 32 and 64 */
+#define DeclareMergeRop24() \
+ MfbBits _ca1u[4], _cx1u[4], _ca2u[4], _cx2u[4];
+ /* int _unrollidx[3]={0,0,1,2};*/
+#define DeclarePrebuiltMergeRop24() MfbBits _ccau[4], _ccxu[4];
+#endif /* PSZ == 24 */
+#else /* mfb */
+#define DeclareMergeRop() MfbBits _ca1 = 0, _cx1 = 0, _ca2 = 0, _cx2 = 0;
+#define DeclarePrebuiltMergeRop() MfbBits _cca, _ccx;
+#endif
+
+#if defined(PPW) && defined(PGSZ) && (PPW != PGSZ) /* cfb */
+#define InitializeMergeRop(alu,pm) {\
+ MfbBits _pm; \
+ mergeRopPtr _bits; \
+ _pm = PFILL(pm); \
+ _bits = mergeGetRopBits(alu); \
+ _ca1 = _bits->ca1 & _pm; \
+ _cx1 = _bits->cx1 | ~_pm; \
+ _ca2 = _bits->ca2 & _pm; \
+ _cx2 = _bits->cx2 & _pm; \
+}
+#if PSZ == 24
+#if (BITMAP_BIT_ORDER == MSBFirst)
+#define InitializeMergeRop24(alu,pm) {\
+ register int i; \
+ register MfbBits _pm = (pm) & 0xFFFFFF; \
+ mergeRopPtr _bits = mergeGetRopBits(alu); \
+ MfbBits _bits_ca1 = _bits->ca1; \
+ MfbBits _bits_cx1 = _bits->cx1; \
+ MfbBits _bits_ca2 = _bits->ca2; \
+ MfbBits _bits_cx2 = _bits->cx2; \
+ _pm = (_pm << 8) | (_pm >> 16); \
+ for(i = 0; i < 4; i++){ \
+ _ca1u[i] = _bits_ca1 & _pm; \
+ _cx1u[i] = _bits_cx1 | ~_pm; \
+ _ca2u[i] = _bits_ca2 & _pm; \
+ _cx2u[i] = _bits_cx2 & _pm; \
+ _pm = (_pm << 16)|(_pm >> 8); \
+ } \
+}
+#else /*(BITMAP_BIT_ORDER == LSBFirst)*/
+#define InitializeMergeRop24(alu,pm) {\
+ register int i; \
+ register MfbBits _pm = (pm) & cfbmask[0]; \
+ mergeRopPtr _bits = mergeGetRopBits(alu); \
+ MfbBits _bits_ca1 = _bits->ca1 & cfbmask[0]; \
+ MfbBits _bits_cx1 = _bits->cx1 & cfbmask[0]; \
+ MfbBits _bits_ca2 = _bits->ca2 & cfbmask[0]; \
+ MfbBits _bits_cx2 = _bits->cx2 & cfbmask[0]; \
+ _pm |= (_pm << 24); \
+ _bits_ca1 |= (_bits->ca1 << 24); \
+ _bits_cx1 |= (_bits->cx1 << 24); \
+ _bits_ca2 |= (_bits->ca2 << 24); \
+ _bits_cx2 |= (_bits->cx2 << 24); \
+ for(i = 0; i < 4; i++){ \
+ _ca1u[i] = _bits_ca1 & _pm; \
+ _cx1u[i] = _bits_cx1 | ~_pm; \
+ _ca2u[i] = _bits_ca2 & _pm; \
+ _cx2u[i] = _bits_cx2 & _pm; \
+ _pm = (_pm << 16)|(_pm >> 8); \
+ } \
+}
+#endif /*(BITMAP_BIT_ORDER == MSBFirst)*/
+#endif /* PSZ == 24 */
+#else /* mfb */
+#define InitializeMergeRop(alu,pm) {\
+ mergeRopPtr _bits; \
+ _bits = mergeGetRopBits(alu); \
+ _ca1 = _bits->ca1; \
+ _cx1 = _bits->cx1; \
+ _ca2 = _bits->ca2; \
+ _cx2 = _bits->cx2; \
+}
+#endif
+
+/* AND has higher precedence than XOR */
+
+#define DoMergeRop(src, dst) \
+ (((dst) & (((src) & _ca1) ^ _cx1)) ^ (((src) & _ca2) ^ _cx2))
+
+#define DoMergeRop24u(src, dst, i) \
+(((dst) & (((src) & _ca1u[i]) ^ _cx1u[i])) ^ (((src) & _ca2u[i]) ^ _cx2u[i]))
+
+#define DoMaskMergeRop24(src, dst, mask, index) {\
+ register int idx = ((index) & 3)<< 1; \
+ MfbBits _src0 = (src);\
+ MfbBits _src1 = (_src0 & _ca1) ^ _cx1; \
+ MfbBits _src2 = (_src0 & _ca2) ^ _cx2; \
+ *(dst) = (((*(dst)) & cfbrmask[idx]) | (((*(dst)) & cfbmask[idx]) & \
+ (((( _src1 |(~mask))<<cfb24Shift[idx])&cfbmask[idx]) ^ \
+ ((( _src2&(mask))<<cfb24Shift[idx])&cfbmask[idx])))); \
+ idx++; \
+ (dst)++; \
+ *(dst) = (((*(dst)) & cfbrmask[idx]) | (((*(dst)) & cfbmask[idx]) & \
+ ((((_src1 |(~mask))>>cfb24Shift[idx])&cfbmask[idx]) ^ \
+ (((_src2 &(mask))>>cfb24Shift[idx])&cfbmask[idx])))); \
+ (dst)--; \
+ }
+
+#define DoMaskMergeRop(src, dst, mask) \
+ (((dst) & ((((src) & _ca1) ^ _cx1) | ~(mask))) ^ ((((src) & _ca2) ^ _cx2) & (mask)))
+
+#define DoMaskMergeRop24u(src, dst, mask, i) \
+(((dst) & ((((src) & _ca1u[(i)]) ^ _cx1u[(i)]) | ~(mask))) ^ ((((src) & _ca2u[(i)]) ^ _cx2u[(i)]) & (mask)))
+
+#define DoMergeRop24(src,dst,index) {\
+ register int idx = ((index) & 3)<< 1; \
+ MfbBits _src0 = (src);\
+ MfbBits _src1 = (_src0 & _ca1) ^ _cx1; \
+ MfbBits _src2 = (_src0 & _ca2) ^ _cx2; \
+ *(dst) = (((*(dst)) & cfbrmask[idx]) | ((((*(dst)) & cfbmask[idx]) & \
+ ((_src1 << cfb24Shift[idx])&cfbmask[idx])) ^ \
+ ((_src2 << cfb24Shift[idx])&cfbmask[idx]))); \
+ idx++; \
+ (dst)++; \
+ *(dst) = (((*(dst)) & cfbrmask[idx]) | ((((*(dst)) & cfbmask[idx]) & \
+ ((_src1 >> cfb24Shift[idx])&cfbmask[idx])) ^ \
+ ((_src2 >> cfb24Shift[idx])&cfbmask[idx]))); \
+ (dst)--; \
+ }
+
+#define DoPrebuiltMergeRop(dst) (((dst) & _cca) ^ _ccx)
+
+#define DoPrebuiltMergeRop24(dst,index) { \
+ register int idx = ((index) & 3)<< 1; \
+ *(dst) = (((*(dst)) & cfbrmask[idx]) | ((((*(dst)) & cfbmask[idx]) &\
+ (( _cca <<cfb24Shift[idx])&cfbmask[idx])) ^ \
+ (( _ccx <<cfb24Shift[idx])&cfbmask[idx]))); \
+ idx++; \
+ (dst)++; \
+ *(dst) = (((*(dst)) & cfbrmask[idx]) | ((((*(dst)) & cfbmask[idx]) &\
+ (( _cca >>cfb24Shift[idx])&cfbmask[idx])) ^ \
+ (( _ccx >>cfb24Shift[idx])&cfbmask[idx]))); \
+ (dst)--; \
+ }
+
+#define DoMaskPrebuiltMergeRop(dst,mask) \
+ (((dst) & (_cca | ~(mask))) ^ (_ccx & (mask)))
+
+#define PrebuildMergeRop(src) ((_cca = ((src) & _ca1) ^ _cx1), \
+ (_ccx = ((src) & _ca2) ^ _cx2))
+
+#ifndef MROP
+#define MROP 0
+#endif
+
+#define Mclear (1<<GXclear)
+#define Mand (1<<GXand)
+#define MandReverse (1<<GXandReverse)
+#define Mcopy (1<<GXcopy)
+#define MandInverted (1<<GXandInverted)
+#define Mnoop (1<<GXnoop)
+#define Mxor (1<<GXxor)
+#define Mor (1<<GXor)
+#define Mnor (1<<GXnor)
+#define Mequiv (1<<GXequiv)
+#define Minvert (1<<GXinvert)
+#define MorReverse (1<<GXorReverse)
+#define McopyInverted (1<<GXcopyInverted)
+#define MorInverted (1<<GXorInverted)
+#define Mnand (1<<GXnand)
+#define Mset (1<<GXset)
+
+#define MROP_PIXEL24(pix, idx) \
+ (((*(pix) & cfbmask[(idx)<<1]) >> cfb24Shift[(idx)<<1])| \
+ ((*((pix)+1) & cfbmask[((idx)<<1)+1]) << cfb24Shift[((idx)<<1)+1]))
+
+#define MROP_SOLID24P(src,dst,sindex, index) \
+ MROP_SOLID24(MROP_PIXEL24(src,sindex),dst,index)
+
+#define MROP_MASK24P(src,dst,mask,sindex,index) \
+ MROP_MASK24(MROP_PIXEL24(src,sindex),dst,mask,index)
+
+#if (MROP) == Mcopy
+#define MROP_DECLARE()
+#define MROP_DECLARE_REG()
+#define MROP_INITIALIZE(alu,pm)
+#define MROP_SOLID(src,dst) (src)
+#define MROP_SOLID24(src,dst,index) {\
+ register int idx = ((index) & 3)<< 1; \
+ MfbBits _src = (src); \
+ *(dst) = (*(dst) & cfbrmask[idx])|((_src<<cfb24Shift[idx])&cfbmask[idx]); \
+ idx++; \
+ *((dst)+1) = (*((dst)+1) & cfbrmask[idx])|((_src>>cfb24Shift[idx])&cfbmask[idx]); \
+ }
+#define MROP_MASK(src,dst,mask) (((dst) & ~(mask)) | ((src) & (mask)))
+#define MROP_MASK24(src,dst,mask,index) {\
+ register int idx = ((index) & 3)<< 1; \
+ MfbBits _src = (src); \
+ *(dst) = (*(dst) & cfbrmask[idx] &(~(((mask)<< cfb24Shift[idx])&cfbmask[idx])) | \
+ (((_src &(mask))<<cfb24Shift[idx])&cfbmask[idx])); \
+ idx++; \
+ *((dst)+1) = (*((dst)+1) & cfbrmask[idx] &(~(((mask)>>cfb24Shift[idx])&cfbmask[idx])) | \
+ (((_src&(mask))>>cfb24Shift[idx])&cfbmask[idx])); \
+ }
+#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,Copy)
+#endif
+
+#if (MROP) == McopyInverted
+#define MROP_DECLARE()
+#define MROP_DECLARE_REG()
+#define MROP_INITIALIZE(alu,pm)
+#define MROP_SOLID(src,dst) (~(src))
+#define MROP_SOLID24(src,dst,index) {\
+ register int idx = ((index) & 3)<< 1; \
+ MfbBits _src = ~(src); \
+ *(dst) = (*(dst) & cfbrmask[idx])|((_src << cfb24Shift[idx])&cfbmask[idx]); \
+ idx++; \
+ (dst)++; \
+ *(dst) = (*(dst) & cfbrmask[idx])|((_src >>cfb24Shift[idx])&cfbmask[idx]); \
+ (dst)--; \
+ }
+#define MROP_MASK(src,dst,mask) (((dst) & ~(mask)) | ((~(src)) & (mask)))
+#define MROP_MASK24(src,dst,mask,index) {\
+ register int idx = ((index) & 3)<< 1; \
+ MfbBits _src = ~(src); \
+ *(dst) = (*(dst) & cfbrmask[idx] &(~(((mask)<< cfb24Shift[idx])&cfbmask[idx])) | \
+ (((_src &(mask))<<cfb24Shift[idx])&cfbmask[idx])); \
+ idx++; \
+ (dst)++; \
+ *(dst) = (*(dst) & cfbrmask[idx] &(~(((mask)>>cfb24Shift[idx])&cfbmask[idx])) | \
+ ((((_src & (mask))>>cfb24Shift[idx])&cfbmask[idx])); \
+ (dst)--; \
+ }
+#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,CopyInverted)
+#endif
+
+#if (MROP) == Mxor
+#define MROP_DECLARE()
+#define MROP_DECLARE_REG()
+#define MROP_INITIALIZE(alu,pm)
+#define MROP_SOLID(src,dst) ((src) ^ (dst))
+#define MROP_SOLID24(src,dst,index) {\
+ register int idx = ((index) & 3)<< 1; \
+ MfbBits _src = (src); \
+ *(dst) ^= ((_src << cfb24Shift[idx])&cfbmask[idx]); \
+ idx++; \
+ (dst)++; \
+ *(dst) ^= ((_src >>cfb24Shift[idx])&cfbmask[idx]); \
+ (dst)--; \
+ }
+#define MROP_MASK(src,dst,mask) (((src) & (mask)) ^ (dst))
+#define MROP_MASK24(src,dst,mask,index) {\
+ register int idx = ((index) & 3)<< 1; \
+ *(dst) ^= ((((src)&(mask))<<cfb24Shift[idx])&cfbmask[idx]); \
+ idx++; \
+ (dst)++; \
+ *(dst) ^= ((((src)&(mask))>>cfb24Shift[idx])&cfbmask[idx]); \
+ (dst)--; \
+ }
+#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,Xor)
+#endif
+
+#if (MROP) == Mor
+#define MROP_DECLARE()
+#define MROP_DECLARE_REG()
+#define MROP_INITIALIZE(alu,pm)
+#define MROP_SOLID(src,dst) ((src) | (dst))
+#define MROP_SOLID24(src,dst,index) {\
+ register int idx = ((index) & 3)<< 1; \
+ *(dst) |= (((src)<<cfb24Shift[idx])&cfbmask[idx]); \
+ idx++; \
+ (dst)++; \
+ *(dst) |= (((src)>>cfb24Shift[idx])&cfbmask[idx]); \
+ (dst)--; \
+ }
+#define MROP_MASK(src,dst,mask) (((src) & (mask)) | (dst))
+#define MROP_MASK24(src,dst,mask,index) {\
+ register int idx = ((index) & 3)<< 1; \
+ MfbBits _src = (src); \
+ *(dst) |= (((_src &(mask))<<cfb24Shift[idx])&cfbmask[idx]); \
+ idx++; \
+ (dst)++; \
+ *(dst) |= (((_src &(mask))>>cfb24Shift[idx])&cfbmask[idx]); \
+ (dst)--; \
+ }
+#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,Or)
+#endif
+
+#if (MROP) == (Mcopy|Mxor|MandReverse|Mor)
+#define MROP_DECLARE() MfbBits _ca1 = 0, _cx1 = 0;
+#define MROP_DECLARE_REG() register MROP_DECLARE()
+#define MROP_INITIALIZE(alu,pm) { \
+ mergeRopPtr _bits; \
+ _bits = mergeGetRopBits(alu); \
+ _ca1 = _bits->ca1; \
+ _cx1 = _bits->cx1; \
+}
+#define MROP_SOLID(src,dst) \
+ (((dst) & (((src) & _ca1) ^ _cx1)) ^ (src))
+#define MROP_MASK(src,dst,mask) \
+ (((dst) & ((((src) & _ca1) ^ _cx1)) | (~(mask)) ^ ((src) & (mask))))
+#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,CopyXorAndReverseOr)
+#define MROP_PREBUILD(src) PrebuildMergeRop(src)
+#define MROP_PREBUILT_DECLARE() DeclarePrebuiltMergeRop()
+#define MROP_PREBUILT_SOLID(src,dst) DoPrebuiltMergeRop(dst)
+#define MROP_PREBUILT_SOLID24(src,dst,index) DoPrebuiltMergeRop24(dst,index)
+#define MROP_PREBUILT_MASK(src,dst,mask) DoMaskPrebuiltMergeRop(dst,mask)
+#define MROP_PREBUILT_MASK24(src,dst,mask,index) DoMaskPrebuiltMergeRop24(dst,mask,index)
+#endif
+
+#if (MROP) == 0
+#if !defined(PSZ) || (PSZ != 24)
+#define MROP_DECLARE() DeclareMergeRop()
+#define MROP_DECLARE_REG() register DeclareMergeRop()
+#define MROP_INITIALIZE(alu,pm) InitializeMergeRop(alu,pm)
+#define MROP_SOLID(src,dst) DoMergeRop(src,dst)
+#define MROP_MASK(src,dst,mask) DoMaskMergeRop(src, dst, mask)
+#else
+#define MROP_DECLARE() \
+ DeclareMergeRop() \
+ DeclareMergeRop24()
+#define MROP_DECLARE_REG() \
+ register DeclareMergeRop()\
+ DeclareMergeRop24()
+#define MROP_INITIALIZE(alu,pm) \
+ InitializeMergeRop(alu,pm)\
+ InitializeMergeRop24(alu,pm)
+#define MROP_SOLID(src,dst) DoMergeRop24u(src,dst,((int)(&(dst)-pdstBase) % 3))
+#define MROP_MASK(src,dst,mask) DoMaskMergeRop24u(src, dst, mask,((int)(&(dst) - pdstBase)%3))
+#endif
+#define MROP_SOLID24(src,dst,index) DoMergeRop24(src,dst,index)
+#define MROP_MASK24(src,dst,mask,index) DoMaskMergeRop24(src, dst, mask,index)
+#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,General)
+#define MROP_PREBUILD(src) PrebuildMergeRop(src)
+#define MROP_PREBUILT_DECLARE() DeclarePrebuiltMergeRop()
+#define MROP_PREBUILT_SOLID(src,dst) DoPrebuiltMergeRop(dst)
+#define MROP_PREBUILT_SOLID24(src,dst,index) DoPrebuiltMergeRop24(dst,index)
+#define MROP_PREBUILT_MASK(src,dst,mask) DoMaskPrebuiltMergeRop(dst,mask)
+#define MROP_PREBUILT_MASK24(src,dst,mask,index) \
+ DoMaskPrebuiltMergeRop24(dst,mask,index)
+#endif
+
+#ifndef MROP_PREBUILD
+#define MROP_PREBUILD(src)
+#define MROP_PREBUILT_DECLARE()
+#define MROP_PREBUILT_SOLID(src,dst) MROP_SOLID(src,dst)
+#define MROP_PREBUILT_SOLID24(src,dst,index) MROP_SOLID24(src,dst,index)
+#define MROP_PREBUILT_MASK(src,dst,mask) MROP_MASK(src,dst,mask)
+#define MROP_PREBUILT_MASK24(src,dst,mask,index) MROP_MASK24(src,dst,mask,index)
+#endif
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define MROP_NAME_CAT(prefix,suffix) prefix##suffix
+#else
+#define MROP_NAME_CAT(prefix,suffix) prefix/**/suffix
+#endif
+
+#endif
diff --git a/nx-X11/programs/Xserver/mfb/mfb.h b/nx-X11/programs/Xserver/mfb/mfb.h
new file mode 100644
index 000000000..6e7ae43b3
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfb.h
@@ -0,0 +1,1158 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfb.h,v 1.21 2003/07/16 03:35:16 dawes Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfb.h,v 1.4 2001/02/09 02:05:18 xorgcvs Exp $ */
+
+#if !defined(_MFB_H_) || defined(MFB_PROTOTYPES_ONLY)
+#ifndef MFB_PROTOTYPES_ONLY
+#define _MFB_H_
+#endif
+
+/* Monochrome Frame Buffer definitions
+ written by drewry, september 1986
+*/
+#include "pixmap.h"
+#include "region.h"
+#include "gc.h"
+#include "colormap.h"
+#include "miscstruct.h"
+#include "mibstore.h"
+
+extern int InverseAlu[];
+extern int mfbGetInverseAlu(int i);
+
+/* warning: PixelType definition duplicated in maskbits.h */
+#ifndef PixelType
+#define PixelType CARD32
+#endif /* PixelType */
+#ifndef MfbBits
+#define MfbBits CARD32
+#endif
+
+/* mfbbitblt.c */
+
+extern void mfbDoBitblt(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/
+);
+
+extern RegionPtr mfbCopyArea(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr/*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/
+);
+
+extern Bool mfbRegisterCopyPlaneProc(
+ ScreenPtr /*pScreen*/,
+ RegionPtr (* /*proc*/)(
+ DrawablePtr /* pSrcDrawable */,
+ DrawablePtr /* pDstDrawable */,
+ GCPtr /* pGC */,
+ int /* srcx */,
+ int /* srcy */,
+ int /* width */,
+ int /* height */,
+ int /* dstx */,
+ int /* dsty */,
+ unsigned long /* bitPlane */
+ )
+);
+
+extern RegionPtr mfbCopyPlane(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr/*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ unsigned long /*plane*/
+);
+/* mfbbltC.c */
+
+extern void mfbDoBitbltCopy(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/
+);
+/* mfbbltCI.c */
+
+extern void mfbDoBitbltCopyInverted(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/
+);
+/* mfbbltG.c */
+
+extern void mfbDoBitbltGeneral(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/
+);
+/* mfbbltO.c */
+
+extern void mfbDoBitbltOr(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/
+);
+/* mfbbltX.c */
+
+extern void mfbDoBitbltXor(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/
+);
+/* mfbbres.c */
+
+extern void mfbBresS(
+ int /*rop*/,
+ PixelType * /*addrl*/,
+ int /*nlwidth*/,
+ int /*signdx*/,
+ int /*signdy*/,
+ int /*axis*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*e*/,
+ int /*e1*/,
+ int /*e2*/,
+ int /*len*/
+);
+/* mfbbresd.c */
+
+extern void mfbBresD(
+ int /*fgrop*/,
+ int /*bgrop*/,
+ int * /*pdashIndex*/,
+ unsigned char * /*pDash*/,
+ int /*numInDashList*/,
+ int * /*pdashOffset*/,
+ int /*isDoubleDash*/,
+ PixelType * /*addrl*/,
+ int /*nlwidth*/,
+ int /*signdx*/,
+ int /*signdy*/,
+ int /*axis*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*e*/,
+ int /*e1*/,
+ int /*e2*/,
+ int /*len*/
+);
+/* mfbbstore.c */
+
+extern void mfbSaveAreas(
+ PixmapPtr /*pPixmap*/,
+ RegionPtr /*prgnSave*/,
+ int /*xorg*/,
+ int /*yorg*/,
+ WindowPtr /*pWin*/
+);
+
+extern void mfbRestoreAreas(
+ PixmapPtr /*pPixmap*/,
+ RegionPtr /*prgnRestore*/,
+ int /*xorg*/,
+ int /*yorg*/,
+ WindowPtr /*pWin*/
+);
+/* mfbclip.c */
+
+extern RegionPtr mfbPixmapToRegion(
+ PixmapPtr /*pPix*/
+);
+
+#ifndef MFB_PROTOTYPES_ONLY
+typedef RegionPtr (*mfbPixmapToRegionProc)(PixmapPtr);
+
+extern mfbPixmapToRegionProc *mfbPixmapToRegionWeak(void);
+#endif
+
+/* mfbcmap.c */
+
+extern int mfbListInstalledColormaps(
+ ScreenPtr /*pScreen*/,
+ Colormap * /*pmaps*/
+);
+
+extern void mfbInstallColormap(
+ ColormapPtr /*pmap*/
+);
+
+extern void mfbUninstallColormap(
+ ColormapPtr /*pmap*/
+);
+
+extern void mfbResolveColor(
+ unsigned short * /*pred*/,
+ unsigned short * /*pgreen*/,
+ unsigned short * /*pblue*/,
+ VisualPtr /*pVisual*/
+);
+
+extern Bool mfbCreateColormap(
+ ColormapPtr /*pMap*/
+);
+
+extern void mfbDestroyColormap(
+ ColormapPtr /*pMap*/
+);
+
+extern Bool mfbCreateDefColormap(
+ ScreenPtr /*pScreen*/
+);
+/* mfbfillarc.c */
+
+extern void mfbPolyFillArcSolid(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+/* mfbfillrct.c */
+
+extern void mfbPolyFillRect(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nrectFill*/,
+ xRectangle * /*prectInit*/
+);
+/* mfbfillsp.c */
+
+extern void mfbBlackSolidFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void mfbWhiteSolidFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void mfbInvertSolidFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void mfbWhiteStippleFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void mfbBlackStippleFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void mfbInvertStippleFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void mfbTileFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void mfbUnnaturalTileFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+extern void mfbUnnaturalStippleFS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+/* mfbfont.c */
+
+extern Bool mfbRealizeFont(
+ ScreenPtr /*pscr*/,
+ FontPtr /*pFont*/
+);
+
+extern Bool mfbUnrealizeFont(
+ ScreenPtr /*pscr*/,
+ FontPtr /*pFont*/
+);
+
+#ifndef MFB_PROTOTYPES_ONLY
+typedef void (*mfbRealizeFontProc)(ScreenPtr, FontPtr);
+typedef void (*mfbUnrealizeFontProc)(ScreenPtr, FontPtr);
+
+extern mfbRealizeFontProc *mfbRealizeFontWeak(void);
+extern mfbUnrealizeFontProc *mfbUnrealizeFontWeak(void);
+#endif
+
+/* mfbgc.c */
+
+extern Bool mfbCreateGC(
+ GCPtr /*pGC*/
+);
+
+extern void mfbValidateGC(
+ GCPtr /*pGC*/,
+ unsigned long /*changes*/,
+ DrawablePtr /*pDrawable*/
+);
+
+extern int mfbReduceRop(
+ int /*alu*/,
+ Pixel /*src*/
+);
+
+/* mfbgetsp.c */
+
+extern void mfbGetSpans(
+ DrawablePtr /*pDrawable*/,
+ int /*wMax*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ int /*nspans*/,
+ char * /*pdstStart*/
+);
+/* mfbhrzvert.c */
+
+extern void mfbHorzS(
+ int /*rop*/,
+ PixelType * /*addrl*/,
+ int /*nlwidth*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*len*/
+);
+
+extern void mfbVertS(
+ int /*rop*/,
+ PixelType * /*addrl*/,
+ int /*nlwidth*/,
+ int /*x1*/,
+ int /*y1*/,
+ int /*len*/
+);
+/* mfbigbblak.c */
+
+extern void mfbImageGlyphBltBlack(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* mfbigbwht.c */
+
+extern void mfbImageGlyphBltWhite(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* mfbimage.c */
+
+extern void mfbPutImage(
+ DrawablePtr /*dst*/,
+ GCPtr /*pGC*/,
+ int /*depth*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ int /*leftPad*/,
+ int /*format*/,
+ char * /*pImage*/
+);
+
+extern void mfbGetImage(
+ DrawablePtr /*pDrawable*/,
+ int /*sx*/,
+ int /*sy*/,
+ int /*w*/,
+ int /*h*/,
+ unsigned int /*format*/,
+ unsigned long /*planeMask*/,
+ char * /*pdstLine*/
+);
+/* mfbline.c */
+
+extern void mfbLineSS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/
+);
+
+extern void mfbLineSD(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/
+);
+
+/* mfbmisc.c */
+
+extern void mfbQueryBestSize(
+ int /*class*/,
+ unsigned short * /*pwidth*/,
+ unsigned short * /*pheight*/,
+ ScreenPtr /*pScreen*/
+);
+
+#ifndef MFB_PROTOTYPES_ONLY
+typedef void (*mfbQueryBestSizeProc)(int, unsigned short *, unsigned short *,
+ ScreenPtr);
+
+extern mfbQueryBestSizeProc *mfbQueryBestSizeWeak(void);
+#endif
+
+/* mfbpablack.c */
+
+extern void mfbSolidBlackArea(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*nop*/
+);
+
+extern void mfbStippleBlackArea(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*pstipple*/
+);
+/* mfbpainv.c */
+
+extern void mfbSolidInvertArea(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*nop*/
+);
+
+extern void mfbStippleInvertArea(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*pstipple*/
+);
+/* mfbpawhite.c */
+
+extern void mfbSolidWhiteArea(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*nop*/
+);
+
+extern void mfbStippleWhiteArea(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*pstipple*/
+);
+
+/* mfbpgbinv.c */
+
+extern void mfbPolyGlyphBltBlack(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* mfbpgbinv.c */
+
+extern void mfbPolyGlyphBltInvert(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* mfbpgbwht.c */
+
+extern void mfbPolyGlyphBltWhite(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* mfbpixmap.c */
+
+extern PixmapPtr mfbCreatePixmap(
+ ScreenPtr /*pScreen*/,
+ int /*width*/,
+ int /*height*/,
+ int /*depth*/
+);
+
+extern Bool mfbDestroyPixmap(
+ PixmapPtr /*pPixmap*/
+);
+
+extern PixmapPtr mfbCopyPixmap(
+ PixmapPtr /*pSrc*/
+);
+
+extern void mfbPadPixmap(
+ PixmapPtr /*pPixmap*/
+);
+
+extern void mfbXRotatePixmap(
+ PixmapPtr /*pPix*/,
+ int /*rw*/
+);
+
+extern void mfbYRotatePixmap(
+ PixmapPtr /*pPix*/,
+ int /*rh*/
+);
+
+extern void mfbCopyRotatePixmap(
+ PixmapPtr /*psrcPix*/,
+ PixmapPtr * /*ppdstPix*/,
+ int /*xrot*/,
+ int /*yrot*/
+);
+/* mfbplyblack.c */
+
+extern void mfbFillPolyBlack(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*shape*/,
+ int /*mode*/,
+ int /*count*/,
+ DDXPointPtr /*ptsIn*/
+);
+/* mfbplyinv.c */
+
+extern void mfbFillPolyInvert(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*shape*/,
+ int /*mode*/,
+ int /*count*/,
+ DDXPointPtr /*ptsIn*/
+);
+
+/* mfbpntwin.c */
+
+extern void mfbFillPolyWhite(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*shape*/,
+ int /*mode*/,
+ int /*count*/,
+ DDXPointPtr /*ptsIn*/
+);
+/* mfbpntwin.c */
+
+extern void mfbPaintWindow(
+ WindowPtr /*pWin*/,
+ RegionPtr /*pRegion*/,
+ int /*what*/
+);
+/* mfbpolypnt.c */
+
+extern void mfbPolyPoint(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ xPoint * /*pptInit*/
+);
+/* mfbpushpxl.c */
+
+extern void mfbSolidPP(
+ GCPtr /*pGC*/,
+ PixmapPtr /*pBitMap*/,
+ DrawablePtr /*pDrawable*/,
+ int /*dx*/,
+ int /*dy*/,
+ int /*xOrg*/,
+ int /*yOrg*/
+);
+
+extern void mfbPushPixels(
+ GCPtr /*pGC*/,
+ PixmapPtr /*pBitMap*/,
+ DrawablePtr /*pDrawable*/,
+ int /*dx*/,
+ int /*dy*/,
+ int /*xOrg*/,
+ int /*yOrg*/
+);
+
+#ifndef MFB_PROTOTYPES_ONLY
+typedef void (*mfbPushPixelsProc)(GCPtr, PixmapPtr, DrawablePtr, int, int,
+ int, int);
+
+extern mfbPushPixelsProc *mfbPushPixelsWeak(void);
+#endif
+
+/* mfbscrclse.c */
+
+extern Bool mfbCloseScreen(
+ int /*index*/,
+ ScreenPtr /*pScreen*/
+);
+/* mfbscrinit.c */
+
+extern Bool mfbAllocatePrivates(
+ ScreenPtr /*pScreen*/,
+ int * /*pWinIndex*/,
+ int * /*pGCIndex*/
+);
+
+extern Bool mfbScreenInit(
+ ScreenPtr /*pScreen*/,
+ pointer /*pbits*/,
+ int /*xsize*/,
+ int /*ysize*/,
+ int /*dpix*/,
+ int /*dpiy*/,
+ int /*width*/
+);
+
+extern PixmapPtr mfbGetWindowPixmap(
+ WindowPtr /*pWin*/
+);
+
+extern void mfbSetWindowPixmap(
+ WindowPtr /*pWin*/,
+ PixmapPtr /*pPix*/
+);
+
+extern void mfbFillInScreen(ScreenPtr pScreen);
+
+/* mfbseg.c */
+
+extern void mfbSegmentSS(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSeg*/
+);
+
+extern void mfbSegmentSD(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSeg*/
+);
+/* mfbsetsp.c */
+
+extern void mfbSetScanline(
+ int /*y*/,
+ int /*xOrigin*/,
+ int /*xStart*/,
+ int /*xEnd*/,
+ PixelType * /*psrc*/,
+ int /*alu*/,
+ PixelType * /*pdstBase*/,
+ int /*widthDst*/
+);
+
+extern void mfbSetSpans(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ char * /*psrc*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ int /*nspans*/,
+ int /*fSorted*/
+);
+/* mfbteblack.c */
+
+extern void mfbTEGlyphBltBlack(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* mfbtewhite.c */
+
+extern void mfbTEGlyphBltWhite(
+ DrawablePtr /*pDrawable*/,
+ GCPtr/*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+/* mfbtileC.c */
+
+extern void mfbTileAreaPPWCopy(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/
+);
+/* mfbtileG.c */
+
+extern void mfbTileAreaPPWGeneral(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/
+);
+
+extern void mfbTileAreaPPW(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/
+);
+/* mfbwindow.c */
+
+extern Bool mfbCreateWindow(
+ WindowPtr /*pWin*/
+);
+
+extern Bool mfbDestroyWindow(
+ WindowPtr /*pWin*/
+);
+
+extern Bool mfbMapWindow(
+ WindowPtr /*pWindow*/
+);
+
+extern Bool mfbPositionWindow(
+ WindowPtr /*pWin*/,
+ int /*x*/,
+ int /*y*/
+);
+
+extern Bool mfbUnmapWindow(
+ WindowPtr /*pWindow*/
+);
+
+extern void mfbCopyWindow(
+ WindowPtr /*pWin*/,
+ DDXPointRec /*ptOldOrg*/,
+ RegionPtr /*prgnSrc*/
+);
+
+extern Bool mfbChangeWindowAttributes(
+ WindowPtr /*pWin*/,
+ unsigned long /*mask*/
+);
+/* mfbzerarc.c */
+
+extern void mfbZeroPolyArcSS(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+
+#ifndef MFB_PROTOTYPES_ONLY
+/*
+ private filed of pixmap
+ pixmap.devPrivate = (PixelType *)pointer_to_bits
+ pixmap.devKind = width_of_pixmap_in_bytes
+
+ private field of screen
+ a pixmap, for which we allocate storage. devPrivate is a pointer to
+the bits in the hardware framebuffer. note that devKind can be poked to
+make the code work for framebuffers that are wider than their
+displayable screen (e.g. the early vsII, which displayed 960 pixels
+across, but was 1024 in the hardware.)
+
+ private field of GC
+*/
+typedef void (*mfbFillAreaProcPtr)(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*nop*/
+ );
+
+typedef struct {
+ unsigned char rop; /* reduction of rasterop to 1 of 3 */
+ unsigned char ropOpStip; /* rop for opaque stipple */
+ unsigned char ropFillArea; /* == alu, rop, or ropOpStip */
+ unsigned char unused1[sizeof(long) - 3]; /* Alignment */
+ mfbFillAreaProcPtr FillArea; /* fills regions; look at the code */
+ } mfbPrivGC;
+typedef mfbPrivGC *mfbPrivGCPtr;
+#endif
+
+/* XXX these should be static, but it breaks the ABI */
+extern int mfbGCPrivateIndex; /* index into GC private array */
+extern int mfbGetGCPrivateIndex(void);
+extern int mfbWindowPrivateIndex; /* index into Window private array */
+extern int mfbGetWindowPrivateIndex(void);
+#ifdef PIXMAP_PER_WINDOW
+extern int frameWindowPrivateIndex; /* index into Window private array */
+extern int frameGetWindowPrivateIndex(void);
+#endif
+
+#ifndef MFB_PROTOTYPES_ONLY
+/* private field of window */
+typedef struct {
+ unsigned char fastBorder; /* non-zero if border tile is 32 bits wide */
+ unsigned char fastBackground;
+ unsigned short unused; /* pad for alignment with Sun compiler */
+ DDXPointRec oldRotate;
+ PixmapPtr pRotatedBackground;
+ PixmapPtr pRotatedBorder;
+ } mfbPrivWin;
+
+/* Common macros for extracting drawing information */
+
+#define mfbGetTypedWidth(pDrawable,wtype) (\
+ (((pDrawable)->type == DRAWABLE_WINDOW) ? \
+ (int) (((PixmapPtr)((pDrawable)->pScreen->devPrivate))->devKind) : \
+ (int)(((PixmapPtr)pDrawable)->devKind)) / sizeof (wtype))
+
+#define mfbGetByteWidth(pDrawable) mfbGetTypedWidth(pDrawable, unsigned char)
+
+#define mfbGetPixelWidth(pDrawable) mfbGetTypedWidth(pDrawable, PixelType)
+
+#define mfbGetTypedWidthAndPointer(pDrawable, width, pointer, wtype, ptype) {\
+ PixmapPtr _pPix; \
+ if ((pDrawable)->type == DRAWABLE_WINDOW) \
+ _pPix = (PixmapPtr) (pDrawable)->pScreen->devPrivate; \
+ else \
+ _pPix = (PixmapPtr) (pDrawable); \
+ (pointer) = (ptype *) _pPix->devPrivate.ptr; \
+ (width) = ((int) _pPix->devKind) / sizeof (wtype); \
+}
+
+#define mfbGetByteWidthAndPointer(pDrawable, width, pointer) \
+ mfbGetTypedWidthAndPointer(pDrawable, width, pointer, unsigned char, unsigned char)
+
+#define mfbGetPixelWidthAndPointer(pDrawable, width, pointer) \
+ mfbGetTypedWidthAndPointer(pDrawable, width, pointer, PixelType, PixelType)
+
+#define mfbGetWindowTypedWidthAndPointer(pWin, width, pointer, wtype, ptype) {\
+ PixmapPtr _pPix = (PixmapPtr) (pWin)->drawable.pScreen->devPrivate; \
+ (pointer) = (ptype *) _pPix->devPrivate.ptr; \
+ (width) = ((int) _pPix->devKind) / sizeof (wtype); \
+}
+
+#define mfbGetWindowPixelWidthAndPointer(pWin, width, pointer) \
+ mfbGetWindowTypedWidthAndPointer(pWin, width, pointer, PixelType, PixelType)
+
+#define mfbGetWindowByteWidthAndPointer(pWin, width, pointer) \
+ mfbGetWindowTypedWidthAndPointer(pWin, width, pointer, char, char)
+
+/* mfb uses the following macros to calculate addresses in drawables.
+ * To support banked framebuffers, the macros come in four flavors.
+ * All four collapse into the same definition on unbanked devices.
+ *
+ * mfbScanlineFoo - calculate address and do bank switching
+ * mfbScanlineFooNoBankSwitch - calculate address, don't bank switch
+ * mfbScanlineFooSrc - calculate address, switch source bank
+ * mfbScanlineFooDst - calculate address, switch destination bank
+ */
+
+/* The NoBankSwitch versions are the same for banked and unbanked cases */
+
+#define mfbScanlineIncNoBankSwitch(_ptr, _off) _ptr += (_off)
+#define mfbScanlineOffsetNoBankSwitch(_ptr, _off) ((_ptr) + (_off))
+#define mfbScanlineDeltaNoBankSwitch(_ptr, _y, _w) \
+ mfbScanlineOffsetNoBankSwitch(_ptr, (_y) * (_w))
+#define mfbScanlineNoBankSwitch(_ptr, _x, _y, _w) \
+ mfbScanlineOffsetNoBankSwitch(_ptr, (_y) * (_w) + ((_x) >> MFB_PWSH))
+
+#ifdef MFB_LINE_BANK
+
+#include "mfblinebank.h" /* get macro definitions from this file */
+
+#else /* !MFB_LINE_BANK - unbanked case */
+
+#define mfbScanlineInc(_ptr, _off) mfbScanlineIncNoBankSwitch(_ptr, _off)
+#define mfbScanlineIncSrc(_ptr, _off) mfbScanlineInc(_ptr, _off)
+#define mfbScanlineIncDst(_ptr, _off) mfbScanlineInc(_ptr, _off)
+
+#define mfbScanlineOffset(_ptr, _off) mfbScanlineOffsetNoBankSwitch(_ptr, _off)
+#define mfbScanlineOffsetSrc(_ptr, _off) mfbScanlineOffset(_ptr, _off)
+#define mfbScanlineOffsetDst(_ptr, _off) mfbScanlineOffset(_ptr, _off)
+
+#define mfbScanlineSrc(_ptr, _x, _y, _w) mfbScanline(_ptr, _x, _y, _w)
+#define mfbScanlineDst(_ptr, _x, _y, _w) mfbScanline(_ptr, _x, _y, _w)
+
+#define mfbScanlineDeltaSrc(_ptr, _y, _w) mfbScanlineDelta(_ptr, _y, _w)
+#define mfbScanlineDeltaDst(_ptr, _y, _w) mfbScanlineDelta(_ptr, _y, _w)
+
+#endif /* MFB_LINE_BANK */
+
+#define mfbScanlineDelta(_ptr, _y, _w) \
+ mfbScanlineOffset(_ptr, (_y) * (_w))
+
+#define mfbScanline(_ptr, _x, _y, _w) \
+ mfbScanlineOffset(_ptr, (_y) * (_w) + ((_x) >> MFB_PWSH))
+
+
+/* precomputed information about each glyph for GlyphBlt code.
+ this saves recalculating the per glyph information for each box.
+*/
+typedef struct _pos{
+ int xpos; /* xposition of glyph's origin */
+ int xchar; /* x position mod 32 */
+ int leftEdge;
+ int rightEdge;
+ int topEdge;
+ int bottomEdge;
+ PixelType *pdstBase; /* longword with character origin */
+ int widthGlyph; /* width in bytes of this glyph */
+} TEXTPOS;
+
+/* reduced raster ops for mfb */
+#define RROP_BLACK GXclear
+#define RROP_WHITE GXset
+#define RROP_NOP GXnoop
+#define RROP_INVERT GXinvert
+
+/* macros for mfbbitblt.c, mfbfillsp.c
+ these let the code do one switch on the rop per call, rather
+than a switch on the rop per item (span or rectangle.)
+*/
+
+#define fnCLEAR(src, dst) (0)
+#define fnAND(src, dst) (src & dst)
+#define fnANDREVERSE(src, dst) (src & ~dst)
+#define fnCOPY(src, dst) (src)
+#define fnANDINVERTED(src, dst) (~src & dst)
+#define fnNOOP(src, dst) (dst)
+#define fnXOR(src, dst) (src ^ dst)
+#define fnOR(src, dst) (src | dst)
+#define fnNOR(src, dst) (~(src | dst))
+#define fnEQUIV(src, dst) (~src ^ dst)
+#define fnINVERT(src, dst) (~dst)
+#define fnORREVERSE(src, dst) (src | ~dst)
+#define fnCOPYINVERTED(src, dst)(~src)
+#define fnORINVERTED(src, dst) (~src | dst)
+#define fnNAND(src, dst) (~(src & dst))
+#undef fnSET
+#define fnSET(src, dst) (MfbBits)(~0)
+
+/* Using a "switch" statement is much faster in most cases
+ * since the compiler can do a look-up table or multi-way branch
+ * instruction, depending on the architecture. The result on
+ * A Sun 3/50 is at least 2.5 times faster, assuming a uniform
+ * distribution of RasterOp operation types.
+ *
+ * However, doing some profiling on a running system reveals
+ * GXcopy is the operation over 99.5% of the time and
+ * GXxor is the next most frequent (about .4%), so we make special
+ * checks for those first.
+ *
+ * Note that this requires a change to the "calling sequence"
+ * since we can't engineer a "switch" statement to have an lvalue.
+ */
+#undef DoRop
+#define DoRop(result, alu, src, dst) \
+{ \
+ if (alu == GXcopy) \
+ result = fnCOPY (src, dst); \
+ else if (alu == GXxor) \
+ result = fnXOR (src, dst); \
+ else \
+ switch (alu) \
+ { \
+ case GXclear: \
+ result = fnCLEAR (src, dst); \
+ break; \
+ case GXand: \
+ result = fnAND (src, dst); \
+ break; \
+ case GXandReverse: \
+ result = fnANDREVERSE (src, dst); \
+ break; \
+ case GXandInverted: \
+ result = fnANDINVERTED (src, dst); \
+ break; \
+ default: \
+ case GXnoop: \
+ result = fnNOOP (src, dst); \
+ break; \
+ case GXor: \
+ result = fnOR (src, dst); \
+ break; \
+ case GXnor: \
+ result = fnNOR (src, dst); \
+ break; \
+ case GXequiv: \
+ result = fnEQUIV (src, dst); \
+ break; \
+ case GXinvert: \
+ result = fnINVERT (src, dst); \
+ break; \
+ case GXorReverse: \
+ result = fnORREVERSE (src, dst); \
+ break; \
+ case GXcopyInverted: \
+ result = fnCOPYINVERTED (src, dst); \
+ break; \
+ case GXorInverted: \
+ result = fnORINVERTED (src, dst); \
+ break; \
+ case GXnand: \
+ result = fnNAND (src, dst); \
+ break; \
+ case GXset: \
+ result = fnSET (src, dst); \
+ break; \
+ } \
+}
+
+
+/* C expression fragments for various operations. These get passed in
+ * as -D's on the compile command line. See mfb/Imakefile. This
+ * fixes XBUG 6319.
+ *
+ * This seems like a good place to point out that mfb's use of the
+ * words black and white is an unfortunate misnomer. In mfb code, black
+ * means zero, and white means one.
+ */
+#define MFB_OPEQ_WHITE |=
+#define MFB_OPEQ_BLACK &=~
+#define MFB_OPEQ_INVERT ^=
+#define MFB_EQWHOLEWORD_WHITE =~0
+#define MFB_EQWHOLEWORD_BLACK =0
+#define MFB_EQWHOLEWORD_INVERT ^=~0
+#define MFB_OP_WHITE /* nothing */
+#define MFB_OP_BLACK ~
+
+/*
+ * if MFB is built as a module, it shouldn't call libc functions.
+ */
+#ifdef XFree86LOADER
+#include "xf86_ansic.h"
+#endif
+
+#endif /* MFB_PROTOTYPES_ONLY */
+#endif /* _MFB_H_ */
diff --git a/nx-X11/programs/Xserver/mfb/mfbbitblt.c b/nx-X11/programs/Xserver/mfb/mfbbitblt.c
new file mode 100644
index 000000000..70e2a9934
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbbitblt.c
@@ -0,0 +1,510 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbbitblt.c,v 1.7tsi Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbbitblt.c,v 1.4 2001/02/09 02:05:18 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "mi.h"
+
+#include "mfb.h"
+#include "maskbits.h"
+
+
+/* CopyArea and CopyPlane for a monchrome frame buffer
+
+
+ clip the source rectangle to the source's available bits. (this
+avoids copying unnecessary pieces that will just get exposed anyway.)
+this becomes the new shape of the destination.
+ clip the destination region to the composite clip in the
+GC. this requires translating the destination region to (dstx, dsty).
+ build a list of source points, one for each rectangle in the
+destination. this is a simple translation.
+ go do the multiple rectangle copies
+ do graphics exposures
+*/
+/** Optimized for drawing pixmaps into windows, especially when drawing into
+ ** unobscured windows. Calls to the general-purpose region code were
+ ** replaced with rectangle-to-rectangle clipping comparisions. This is
+ ** possible, since the pixmap is a single rectangle. In an unobscured
+ ** window, the destination clip is also a single rectangle, and region
+ ** code can be avoided entirely. This is a big savings, since the region
+ ** code uses XAlloc() and makes many function calls.
+ **
+ ** In addition, if source is a pixmap, there is no need to call the
+ ** expensive miHandleExposures() routine. Instead, we simply return NULL.
+ **
+ ** Previously, drawing a pixmap into an unobscured window executed at least
+ ** 8 XAlloc()'s, 30 function calls, and hundreds of lines of code.
+ **
+ ** Now, the same operation requires no XAlloc()'s, no region function calls,
+ ** and much less overhead. Nice for drawing lots of small pixmaps.
+ */
+
+
+void
+mfbDoBitblt (pSrc, pDst, alu, prgnDst, pptSrc)
+ DrawablePtr pSrc, pDst;
+ int alu;
+ RegionPtr prgnDst;
+ DDXPointPtr pptSrc;
+{
+ switch (alu)
+ {
+ case GXcopy:
+ mfbDoBitbltCopy (pSrc, pDst, alu, prgnDst, pptSrc);
+ break;
+ case GXxor:
+ mfbDoBitbltXor (pSrc, pDst, alu, prgnDst, pptSrc);
+ break;
+ case GXcopyInverted:
+ mfbDoBitbltCopyInverted (pSrc, pDst, alu, prgnDst, pptSrc);
+ break;
+ case GXor:
+ mfbDoBitbltOr (pSrc, pDst, alu, prgnDst, pptSrc);
+ break;
+ default:
+ mfbDoBitbltGeneral (pSrc, pDst, alu, prgnDst, pptSrc);
+ break;
+ }
+}
+
+RegionPtr
+mfbCopyArea(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty)
+register DrawablePtr pSrcDrawable;
+register DrawablePtr pDstDrawable;
+register GC *pGC;
+int srcx, srcy;
+int width, height;
+int dstx, dsty;
+{
+ RegionPtr prgnSrcClip = NULL; /* may be a new region, or just a copy */
+ Bool freeSrcClip = FALSE;
+
+ RegionPtr prgnExposed;
+ RegionRec rgnDst;
+ DDXPointPtr pptSrc;
+ register DDXPointPtr ppt;
+ register BoxPtr pbox;
+ int i;
+ register int dx;
+ register int dy;
+ xRectangle origSource;
+ DDXPointRec origDest;
+ int numRects;
+ BoxRec fastBox;
+ int fastClip = 0; /* for fast clipping with pixmap source */
+ int fastExpose = 0; /* for fast exposures with pixmap source */
+ void (*localDoBitBlt)(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ int /*alu*/,
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*pptSrc*/);
+
+ origSource.x = srcx;
+ origSource.y = srcy;
+ origSource.width = width;
+ origSource.height = height;
+ origDest.x = dstx;
+ origDest.y = dsty;
+
+ if ((pSrcDrawable != pDstDrawable) &&
+ pSrcDrawable->pScreen->SourceValidate)
+ {
+ (*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, srcx, srcy, width, height);
+ }
+
+ switch (pGC->alu) {
+ case GXcopy:
+ localDoBitBlt = mfbDoBitbltCopy;
+ break;
+ case GXcopyInverted:
+ localDoBitBlt = mfbDoBitbltCopyInverted;
+ break;
+ case GXxor:
+ localDoBitBlt = mfbDoBitbltXor;
+ break;
+ case GXor:
+ localDoBitBlt = mfbDoBitbltOr;
+ break;
+ default:
+ localDoBitBlt = mfbDoBitbltGeneral;
+ break;
+ }
+
+ srcx += pSrcDrawable->x;
+ srcy += pSrcDrawable->y;
+
+ /* clip the source */
+
+ if (pSrcDrawable->type == DRAWABLE_PIXMAP)
+ {
+ if ((pSrcDrawable == pDstDrawable) &&
+ (pGC->clientClipType == CT_NONE))
+ {
+ prgnSrcClip = pGC->pCompositeClip;
+ }
+ else
+ {
+ fastClip = 1;
+ }
+ }
+ else
+ {
+ if (pGC->subWindowMode == IncludeInferiors)
+ {
+ if (!((WindowPtr) pSrcDrawable)->parent)
+ {
+ /*
+ * special case bitblt from root window in
+ * IncludeInferiors mode; just like from a pixmap
+ */
+ fastClip = 1;
+ }
+ else if ((pSrcDrawable == pDstDrawable) &&
+ (pGC->clientClipType == CT_NONE))
+ {
+ prgnSrcClip = pGC->pCompositeClip;
+ }
+ else
+ {
+ prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable);
+ freeSrcClip = TRUE;
+ }
+ }
+ else
+ {
+ prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList;
+ }
+ }
+
+ fastBox.x1 = srcx;
+ fastBox.y1 = srcy;
+ fastBox.x2 = srcx + width;
+ fastBox.y2 = srcy + height;
+
+ /* Don't create a source region if we are doing a fast clip */
+ if (fastClip)
+ {
+ fastExpose = 1;
+ /*
+ * clip the source; if regions extend beyond the source size,
+ * make sure exposure events get sent
+ */
+ if (fastBox.x1 < pSrcDrawable->x)
+ {
+ fastBox.x1 = pSrcDrawable->x;
+ fastExpose = 0;
+ }
+ if (fastBox.y1 < pSrcDrawable->y)
+ {
+ fastBox.y1 = pSrcDrawable->y;
+ fastExpose = 0;
+ }
+ if (fastBox.x2 > pSrcDrawable->x + (int) pSrcDrawable->width)
+ {
+ fastBox.x2 = pSrcDrawable->x + (int) pSrcDrawable->width;
+ fastExpose = 0;
+ }
+ if (fastBox.y2 > pSrcDrawable->y + (int) pSrcDrawable->height)
+ {
+ fastBox.y2 = pSrcDrawable->y + (int) pSrcDrawable->height;
+ fastExpose = 0;
+ }
+ }
+ else
+ {
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip);
+ }
+
+ dstx += pDstDrawable->x;
+ dsty += pDstDrawable->y;
+
+ if (pDstDrawable->type == DRAWABLE_WINDOW)
+ {
+ if (!((WindowPtr)pDstDrawable)->realized)
+ {
+ if (!fastClip)
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return NULL;
+ }
+ }
+
+ dx = srcx - dstx;
+ dy = srcy - dsty;
+
+ /* Translate and clip the dst to the destination composite clip */
+ if (fastClip)
+ {
+ RegionPtr cclip;
+
+ /* Translate the region directly */
+ fastBox.x1 -= dx;
+ fastBox.x2 -= dx;
+ fastBox.y1 -= dy;
+ fastBox.y2 -= dy;
+
+ /* If the destination composite clip is one rectangle we can
+ do the clip directly. Otherwise we have to create a full
+ blown region and call intersect */
+ cclip = pGC->pCompositeClip;
+ if (REGION_NUM_RECTS(cclip) == 1)
+ {
+ BoxPtr pBox = REGION_RECTS(cclip);
+
+ if (fastBox.x1 < pBox->x1) fastBox.x1 = pBox->x1;
+ if (fastBox.x2 > pBox->x2) fastBox.x2 = pBox->x2;
+ if (fastBox.y1 < pBox->y1) fastBox.y1 = pBox->y1;
+ if (fastBox.y2 > pBox->y2) fastBox.y2 = pBox->y2;
+
+ /* Check to see if the region is empty */
+ if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2)
+ {
+ REGION_NULL(pGC->pScreen, &rgnDst);
+ }
+ else
+ {
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ }
+ }
+ else
+ {
+ /* We must turn off fastClip now, since we must create
+ a full blown region. It is intersected with the
+ composite clip below. */
+ fastClip = 0;
+ REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ }
+ }
+ else
+ {
+ REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy);
+ }
+
+ if (!fastClip)
+ {
+ REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, pGC->pCompositeClip);
+ }
+
+ /* Do bit blitting */
+ numRects = REGION_NUM_RECTS(&rgnDst);
+ if (numRects && width && height)
+ {
+ if(!(pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(numRects *
+ sizeof(DDXPointRec))))
+ {
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return NULL;
+ }
+ pbox = REGION_RECTS(&rgnDst);
+ ppt = pptSrc;
+ for (i = numRects; --i >= 0; pbox++, ppt++)
+ {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ if (pGC->planemask & 1)
+ (*localDoBitBlt) (pSrcDrawable, pDstDrawable, pGC->alu, &rgnDst, pptSrc);
+
+ DEALLOCATE_LOCAL(pptSrc);
+ }
+
+ prgnExposed = NULL;
+ if (pGC->fExpose)
+ {
+ /* Pixmap sources generate a NoExposed (we return NULL to do this) */
+ if (!fastExpose)
+ prgnExposed =
+ miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
+ origSource.x, origSource.y,
+ (int)origSource.width,
+ (int)origSource.height,
+ origDest.x, origDest.y, (unsigned long)0);
+ }
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ return prgnExposed;
+}
+
+
+/*
+ * Devices which use mfb for 1-bit pixmap support
+ * must register a function for n-to-1 copy operations
+ */
+
+static unsigned long copyPlaneGeneration;
+static int copyPlaneScreenIndex = -1;
+
+Bool
+mfbRegisterCopyPlaneProc (pScreen, proc)
+ ScreenPtr pScreen;
+ RegionPtr (*proc)(
+ DrawablePtr /* pSrcDrawable */,
+ DrawablePtr /* pDstDrawable */,
+ GCPtr /* pGC */,
+ int /* srcx */,
+ int /* srcy */,
+ int /* width */,
+ int /* height */,
+ int /* dstx */,
+ int /* dsty */,
+ unsigned long /* bitPlane */);
+{
+ if (copyPlaneGeneration != serverGeneration)
+ {
+ copyPlaneScreenIndex = AllocateScreenPrivateIndex();
+ if (copyPlaneScreenIndex < 0)
+ return FALSE;
+ copyPlaneGeneration = serverGeneration;
+ }
+ pScreen->devPrivates[copyPlaneScreenIndex].fptr = proc;
+ return TRUE;
+}
+
+/*
+ if fg == 1 and bg ==0, we can do an ordinary CopyArea.
+ if fg == bg, we can do a CopyArea with alu = mfbReduceRop(alu, fg)
+ if fg == 0 and bg == 1, we use the same rasterop, with
+ source operand inverted.
+
+ CopyArea deals with all of the graphics exposure events.
+ This code depends on knowing that we can change the
+alu in the GC without having to call ValidateGC() before calling
+CopyArea().
+
+*/
+
+
+RegionPtr
+mfbCopyPlane(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, plane)
+DrawablePtr pSrcDrawable, pDstDrawable;
+register GC *pGC;
+int srcx, srcy;
+int width, height;
+int dstx, dsty;
+unsigned long plane;
+{
+ int alu;
+ RegionPtr prgnExposed;
+ RegionPtr (*copyPlane)(
+ DrawablePtr /* pSrcDrawable */,
+ DrawablePtr /* pDstDrawable */,
+ GCPtr /* pGC */,
+ int /* srcx */,
+ int /* srcy */,
+ int /* width */,
+ int /* height */,
+ int /* dstx */,
+ int /* dsty */,
+ unsigned long /* bitPlane */);
+
+
+ if (pSrcDrawable->depth != 1)
+ {
+ if (copyPlaneScreenIndex >= 0 &&
+ (copyPlane =
+ pSrcDrawable->pScreen->devPrivates[copyPlaneScreenIndex].fptr)
+ )
+ {
+ return (*copyPlane) (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, plane);
+ }
+ else
+ {
+ FatalError ("No copyPlane proc registered for depth %d\n",
+ pSrcDrawable->depth);
+ }
+ }
+ if (plane != 1)
+ return NULL;
+
+ if ((pGC->fgPixel & 1) == 1 && (pGC->bgPixel & 1) == 0)
+ {
+ prgnExposed = (*pGC->ops->CopyArea)(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+ }
+ else if ((pGC->fgPixel & 1) == (pGC->bgPixel & 1))
+ {
+ alu = pGC->alu;
+ pGC->alu = mfbReduceRop(pGC->alu, pGC->fgPixel);
+ prgnExposed = (*pGC->ops->CopyArea)(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+ pGC->alu = alu;
+ }
+ else /* need to invert the src */
+ {
+ alu = pGC->alu;
+ pGC->alu = InverseAlu[alu];
+ prgnExposed = (*pGC->ops->CopyArea)(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+ pGC->alu = alu;
+ }
+ return prgnExposed;
+}
+
diff --git a/nx-X11/programs/Xserver/mfb/mfbblt.c b/nx-X11/programs/Xserver/mfb/mfbblt.c
new file mode 100644
index 000000000..ce77fe22c
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbblt.c
@@ -0,0 +1,589 @@
+/*
+ * mfb copy area
+ */
+/* $XFree86: xc/programs/Xserver/mfb/mfbblt.c,v 3.3 2001/10/28 03:34:14 tsi Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Author: Keith Packard
+
+*/
+/* $Xorg: mfbblt.c,v 1.4 2001/02/09 02:05:18 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "mfb.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "maskbits.h"
+#include "fastblt.h"
+#include "mergerop.h"
+
+void
+MROP_NAME(mfbDoBitblt)(pSrc, pDst, alu, prgnDst, pptSrc)
+ DrawablePtr pSrc, pDst;
+ int alu;
+ RegionPtr prgnDst;
+ DDXPointPtr pptSrc;
+{
+ PixelType *psrcBase, *pdstBase;
+ /* start of src and dst bitmaps */
+ int widthSrc, widthDst; /* add to get to same position in next line */
+
+ BoxPtr pbox;
+ int nbox;
+
+ BoxPtr pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2;
+ /* temporaries for shuffling rectangles */
+ DDXPointPtr pptTmp, pptNew1, pptNew2;
+ /* shuffling boxes entails shuffling the
+ source points too */
+ int w, h;
+ int xdir; /* 1 = left right, -1 = right left/ */
+ int ydir; /* 1 = top down, -1 = bottom up */
+
+ PixelType *psrcLine, *pdstLine;
+ /* pointers to line with current src and dst */
+ register PixelType *psrc;/* pointer to current src longword */
+ register PixelType *pdst;/* pointer to current dst longword */
+
+ MROP_DECLARE_REG()
+
+ /* following used for looping through a line */
+ PixelType startmask, endmask; /* masks for writing ends of dst */
+ int nlMiddle; /* whole longwords in dst */
+ int xoffSrc, xoffDst;
+ register int leftShift, rightShift;
+ register PixelType bits;
+ register PixelType bits1;
+ register int nl; /* temp copy of nlMiddle */
+ int careful;
+
+ MROP_INITIALIZE(alu,0);
+
+ mfbGetPixelWidthAndPointer(pSrc, widthSrc, psrcBase);
+
+ mfbGetPixelWidthAndPointer(pDst, widthDst, pdstBase);
+
+ /* XXX we have to err on the side of safety when both are windows,
+ * because we don't know if IncludeInferiors is being used.
+ */
+ careful = ((pSrc == pDst) ||
+ ((pSrc->type == DRAWABLE_WINDOW) &&
+ (pDst->type == DRAWABLE_WINDOW)));
+
+ pbox = REGION_RECTS(prgnDst);
+ nbox = REGION_NUM_RECTS(prgnDst);
+
+ pboxNew1 = NULL;
+ pptNew1 = NULL;
+ pboxNew2 = NULL;
+ pptNew2 = NULL;
+ if (careful && (pptSrc->y < pbox->y1))
+ {
+ /* walk source botttom to top */
+ ydir = -1;
+ widthSrc = -widthSrc;
+ widthDst = -widthDst;
+
+ if (nbox > 1)
+ {
+ /* keep ordering in each band, reverse order of bands */
+ pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
+ if(!pboxNew1)
+ return;
+ pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox);
+ if(!pptNew1)
+ {
+ DEALLOCATE_LOCAL(pboxNew1);
+ return;
+ }
+ pboxBase = pboxNext = pbox+nbox-1;
+ while (pboxBase >= pbox)
+ {
+ while ((pboxNext >= pbox) &&
+ (pboxBase->y1 == pboxNext->y1))
+ pboxNext--;
+ pboxTmp = pboxNext+1;
+ pptTmp = pptSrc + (pboxTmp - pbox);
+ while (pboxTmp <= pboxBase)
+ {
+ *pboxNew1++ = *pboxTmp++;
+ *pptNew1++ = *pptTmp++;
+ }
+ pboxBase = pboxNext;
+ }
+ pboxNew1 -= nbox;
+ pbox = pboxNew1;
+ pptNew1 -= nbox;
+ pptSrc = pptNew1;
+ }
+ }
+ else
+ {
+ /* walk source top to bottom */
+ ydir = 1;
+ }
+
+ if (careful && (pptSrc->x < pbox->x1))
+ {
+ /* walk source right to left */
+ xdir = -1;
+
+ if (nbox > 1)
+ {
+ /* reverse order of rects in each band */
+ pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
+ pptNew2 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox);
+ if(!pboxNew2 || !pptNew2)
+ {
+ if (pptNew2) DEALLOCATE_LOCAL(pptNew2);
+ if (pboxNew2) DEALLOCATE_LOCAL(pboxNew2);
+ if (pboxNew1)
+ {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(pboxNew1);
+ }
+ return;
+ }
+ pboxBase = pboxNext = pbox;
+ while (pboxBase < pbox+nbox)
+ {
+ while ((pboxNext < pbox+nbox) &&
+ (pboxNext->y1 == pboxBase->y1))
+ pboxNext++;
+ pboxTmp = pboxNext;
+ pptTmp = pptSrc + (pboxTmp - pbox);
+ while (pboxTmp != pboxBase)
+ {
+ *pboxNew2++ = *--pboxTmp;
+ *pptNew2++ = *--pptTmp;
+ }
+ pboxBase = pboxNext;
+ }
+ pboxNew2 -= nbox;
+ pbox = pboxNew2;
+ pptNew2 -= nbox;
+ pptSrc = pptNew2;
+ }
+ }
+ else
+ {
+ /* walk source left to right */
+ xdir = 1;
+ }
+
+ while(nbox--)
+ {
+ w = pbox->x2 - pbox->x1;
+ h = pbox->y2 - pbox->y1;
+
+ if (ydir == -1) /* start at last scanline of rectangle */
+ {
+ psrcLine = mfbScanlineDeltaSrc(psrcBase, -(pptSrc->y+h-1), widthSrc);
+ pdstLine = mfbScanlineDeltaDst(pdstBase, -(pbox->y2-1), widthDst);
+ }
+ else /* start at first scanline */
+ {
+ psrcLine = mfbScanlineDeltaSrc(psrcBase, pptSrc->y, widthSrc);
+ pdstLine = mfbScanlineDeltaDst(pdstBase, pbox->y1, widthDst);
+ }
+ if ((pbox->x1 & PIM) + w <= PPW)
+ {
+ maskpartialbits (pbox->x1, w, startmask);
+ endmask = 0;
+ nlMiddle = 0;
+ }
+ else
+ {
+ maskbits(pbox->x1, w, startmask, endmask, nlMiddle);
+ }
+ if (xdir == 1)
+ {
+ xoffSrc = pptSrc->x & PIM;
+ xoffDst = pbox->x1 & PIM;
+ pdstLine += (pbox->x1 >> PWSH);
+ psrcLine += (pptSrc->x >> PWSH);
+#ifdef DO_UNALIGNED_BITBLT
+ nl = xoffSrc - xoffDst;
+ psrcLine = (PixelType *)
+ (((unsigned char *) psrcLine) + nl);
+#else
+ if (xoffSrc == xoffDst)
+#endif
+ {
+ while (h--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ if (startmask)
+ {
+ *pdst = MROP_MASK(*psrc, *pdst, startmask);
+ psrc++;
+ pdst++;
+ }
+ nl = nlMiddle;
+
+#ifdef LARGE_INSTRUCTION_CACHE
+#ifdef FAST_CONSTANT_OFFSET_MODE
+
+ psrc += nl & (UNROLL-1);
+ pdst += nl & (UNROLL-1);
+
+#define BodyOdd(n) pdst[-n] = MROP_SOLID (psrc[-n], pdst[-n]);
+#define BodyEven(n) pdst[-n] = MROP_SOLID (psrc[-n], pdst[-n]);
+
+#define LoopReset \
+pdst += UNROLL; \
+psrc += UNROLL;
+
+#else
+
+#define BodyOdd(n) *pdst = MROP_SOLID (*psrc, *pdst); pdst++; psrc++;
+#define BodyEven(n) BodyOdd(n)
+
+#define LoopReset ;
+
+#endif
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+#ifdef NOTDEF
+ /* you'd think this would be faster --
+ * a single instruction instead of 6
+ * but measurements show it to be ~15% slower
+ */
+ while ((nl -= 6) >= 0)
+ {
+ asm ("moveml %1+,#0x0c0f;moveml#0x0c0f,%0"
+ : "=m" (*(char *)pdst)
+ : "m" (*(char *)psrc)
+ : "d0", "d1", "d2", "d3",
+ "a2", "a3");
+ pdst += 6;
+ }
+ nl += 6;
+ while (nl--)
+ *pdst++ = *psrc++;
+#endif
+ DuffL(nl, label1,
+ *pdst = MROP_SOLID (*psrc, *pdst);
+ pdst++; psrc++;)
+#endif
+
+ if (endmask)
+ *pdst = MROP_MASK(*psrc, *pdst, endmask);
+ mfbScanlineIncDst(pdstLine, widthDst);
+ mfbScanlineIncSrc(psrcLine, widthSrc);
+ }
+ }
+#ifndef DO_UNALIGNED_BITBLT
+ else
+ {
+ if (xoffSrc > xoffDst)
+ {
+ leftShift = (xoffSrc - xoffDst);
+ rightShift = PPW - leftShift;
+ }
+ else
+ {
+ rightShift = (xoffDst - xoffSrc);
+ leftShift = PPW - rightShift;
+ }
+ while (h--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ bits = 0;
+ if (xoffSrc > xoffDst)
+ bits = *psrc++;
+ if (startmask)
+ {
+ bits1 = BitLeft(bits,leftShift);
+ if (BitLeft(startmask, rightShift)) {
+ bits = *psrc++;
+ bits1 |= BitRight(bits,rightShift);
+ }
+ *pdst = MROP_MASK(bits1, *pdst, startmask);
+ pdst++;
+ }
+ nl = nlMiddle;
+
+#ifdef LARGE_INSTRUCTION_CACHE
+ bits1 = bits;
+
+#ifdef FAST_CONSTANT_OFFSET_MODE
+
+ psrc += nl & (UNROLL-1);
+ pdst += nl & (UNROLL-1);
+
+#define BodyOdd(n) \
+bits = psrc[-n]; \
+pdst[-n] = MROP_SOLID(BitLeft(bits1, leftShift) | BitRight(bits, rightShift), pdst[-n]);
+
+#define BodyEven(n) \
+bits1 = psrc[-n]; \
+pdst[-n] = MROP_SOLID(BitLeft(bits, leftShift) | BitRight(bits1, rightShift), pdst[-n]);
+
+#define LoopReset \
+pdst += UNROLL; \
+psrc += UNROLL;
+
+#else
+
+#define BodyOdd(n) \
+bits = *psrc++; \
+*pdst = MROP_SOLID(BitLeft(bits1, leftShift) | BitRight(bits, rightShift), *pdst); \
+pdst++;
+
+#define BodyEven(n) \
+bits1 = *psrc++; \
+*pdst = MROP_SOLID(BitLeft(bits, leftShift) | BitRight(bits1, rightShift), *pdst); \
+pdst++;
+
+#define LoopReset ;
+
+#endif /* !FAST_CONSTANT_OFFSET_MODE */
+
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+ DuffL (nl,label2,
+ bits1 = BitLeft(bits, leftShift);
+ bits = *psrc++;
+ *pdst = MROP_SOLID (bits1 | BitRight(bits, rightShift), *pdst);
+ pdst++;
+ )
+#endif
+
+ if (endmask)
+ {
+ bits1 = BitLeft(bits, leftShift);
+ if (BitLeft(endmask, rightShift))
+ {
+ bits = *psrc;
+ bits1 |= BitRight(bits, rightShift);
+ }
+ *pdst = MROP_MASK (bits1, *pdst, endmask);
+ }
+ mfbScanlineIncDst(pdstLine, widthDst);
+ mfbScanlineIncSrc(psrcLine, widthSrc);
+ }
+ }
+#endif /* DO_UNALIGNED_BITBLT */
+ }
+ else /* xdir == -1 */
+ {
+ xoffSrc = (pptSrc->x + w - 1) & PIM;
+ xoffDst = (pbox->x2 - 1) & PIM;
+ pdstLine += ((pbox->x2-1) >> PWSH) + 1;
+ psrcLine += ((pptSrc->x+w - 1) >> PWSH) + 1;
+#ifdef DO_UNALIGNED_BITBLT
+ nl = xoffSrc - xoffDst;
+ psrcLine = (PixelType *)
+ (((unsigned char *) psrcLine) + nl);
+#else
+ if (xoffSrc == xoffDst)
+#endif
+ {
+ while (h--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ if (endmask)
+ {
+ pdst--;
+ psrc--;
+ *pdst = MROP_MASK (*psrc, *pdst, endmask);
+ }
+ nl = nlMiddle;
+
+#ifdef LARGE_INSTRUCTION_CACHE
+#ifdef FAST_CONSTANT_OFFSET_MODE
+ psrc -= nl & (UNROLL - 1);
+ pdst -= nl & (UNROLL - 1);
+
+#define BodyOdd(n) pdst[n-1] = MROP_SOLID (psrc[n-1], pdst[n-1]);
+
+#define BodyEven(n) BodyOdd(n)
+
+#define LoopReset \
+pdst -= UNROLL;\
+psrc -= UNROLL;
+
+#else
+
+#define BodyOdd(n) --pdst; --psrc; *pdst = MROP_SOLID(*psrc, *pdst);
+#define BodyEven(n) BodyOdd(n)
+#define LoopReset ;
+
+#endif
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+ DuffL(nl,label3,
+ --pdst; --psrc; *pdst = MROP_SOLID (*psrc, *pdst);)
+#endif
+
+ if (startmask)
+ {
+ --pdst;
+ --psrc;
+ *pdst = MROP_MASK(*psrc, *pdst, startmask);
+ }
+ mfbScanlineIncDst(pdstLine, widthDst);
+ mfbScanlineIncSrc(psrcLine, widthSrc);
+ }
+ }
+#ifndef DO_UNALIGNED_BITBLT
+ else
+ {
+ if (xoffDst > xoffSrc)
+ {
+ rightShift = (xoffDst - xoffSrc);
+ leftShift = PPW - rightShift;
+ }
+ else
+ {
+ leftShift = (xoffSrc - xoffDst);
+ rightShift = PPW - leftShift;
+ }
+ while (h--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ bits = 0;
+ if (xoffDst > xoffSrc)
+ bits = *--psrc;
+ if (endmask)
+ {
+ bits1 = BitRight(bits, rightShift);
+ if (BitRight(endmask, leftShift)) {
+ bits = *--psrc;
+ bits1 |= BitLeft(bits, leftShift);
+ }
+ pdst--;
+ *pdst = MROP_MASK(bits1, *pdst, endmask);
+ }
+ nl = nlMiddle;
+
+#ifdef LARGE_INSTRUCTION_CACHE
+ bits1 = bits;
+#ifdef FAST_CONSTANT_OFFSET_MODE
+ psrc -= nl & (UNROLL - 1);
+ pdst -= nl & (UNROLL - 1);
+
+#define BodyOdd(n) \
+bits = psrc[n-1]; \
+pdst[n-1] = MROP_SOLID(BitRight(bits1, rightShift) | BitLeft(bits, leftShift),pdst[n-1]);
+
+#define BodyEven(n) \
+bits1 = psrc[n-1]; \
+pdst[n-1] = MROP_SOLID(BitRight(bits, rightShift) | BitLeft(bits1, leftShift),pdst[n-1]);
+
+#define LoopReset \
+pdst -= UNROLL; \
+psrc -= UNROLL;
+
+#else
+
+#define BodyOdd(n) \
+bits = *--psrc; --pdst; \
+*pdst = MROP_SOLID(BitRight(bits1, rightShift) | BitLeft(bits, leftShift),*pdst);
+
+#define BodyEven(n) \
+bits1 = *--psrc; --pdst; \
+*pdst = MROP_SOLID(BitRight(bits, rightShift) | BitLeft(bits1, leftShift),*pdst);
+
+#define LoopReset ;
+
+#endif
+
+ PackedLoop
+
+#undef BodyOdd
+#undef BodyEven
+#undef LoopReset
+
+#else
+ DuffL (nl, label4,
+ bits1 = BitRight(bits, rightShift);
+ bits = *--psrc;
+ --pdst;
+ *pdst = MROP_SOLID(bits1 | BitLeft(bits, leftShift),*pdst);
+ )
+#endif
+
+ if (startmask)
+ {
+ bits1 = BitRight(bits, rightShift);
+ if (BitRight (startmask, leftShift))
+ {
+ bits = *--psrc;
+ bits1 |= BitLeft(bits, leftShift);
+ }
+ --pdst;
+ *pdst = MROP_MASK(bits1, *pdst, startmask);
+ }
+ mfbScanlineIncDst(pdstLine, widthDst);
+ mfbScanlineIncSrc(psrcLine, widthSrc);
+ }
+ }
+#endif
+ }
+ pbox++;
+ pptSrc++;
+ }
+ if (pboxNew2)
+ {
+ DEALLOCATE_LOCAL(pptNew2);
+ DEALLOCATE_LOCAL(pboxNew2);
+ }
+ if (pboxNew1)
+ {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(pboxNew1);
+ }
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbbres.c b/nx-X11/programs/Xserver/mfb/mfbbres.c
new file mode 100644
index 000000000..07c59d184
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbbres.c
@@ -0,0 +1,370 @@
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/* $XFree86: xc/programs/Xserver/mfb/mfbbres.c,v 1.4 2001/01/17 22:37:02 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbbres.c,v 1.4 2001/02/09 02:05:18 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "mfb.h"
+#include "maskbits.h"
+#include "miline.h"
+
+/* Solid bresenham line */
+/* NOTES
+ e2 is used less often than e1, so it's not in a register
+*/
+
+void
+mfbBresS(rop, addrlbase, nlwidth, signdx, signdy, axis, x1, y1, e, e1, e2, len)
+int rop; /* a reduced rasterop */
+PixelType *addrlbase; /* pointer to base of bitmap */
+int nlwidth; /* width in longwords of bitmap */
+int signdx, signdy; /* signs of directions */
+int axis; /* major axis (Y_AXIS or X_AXIS) */
+int x1, y1; /* initial point */
+register int e; /* error accumulator */
+register int e1; /* bresenham increments */
+int e2;
+int len; /* length of line */
+{
+ register int yinc; /* increment to next scanline, in bytes */
+ register PixelType *addrl; /* bitmask 32-bit pointer */
+ register PixelType bit; /* current bit being set/cleared/etc. */
+ PixelType leftbit = mask[0]; /* leftmost bit to process in new word */
+ PixelType rightbit = mask[PPW-1]; /* rightmost bit to process in new word */
+
+ register int e3 = e2-e1;
+ PixelType tmp;
+
+ /* point to longword containing first point */
+ addrl = mfbScanline(addrlbase, x1, y1, nlwidth);
+ yinc = signdy * nlwidth;
+ e = e-e1; /* to make looping easier */
+ bit = mask[x1 & PIM];
+
+ if (!len)
+ return;
+ if (rop == RROP_BLACK)
+ {
+ if (axis == X_AXIS)
+ {
+ if (signdx > 0)
+ {
+ tmp = *addrl;
+ for (;;)
+ {
+ tmp &= ~bit;
+ if (!--len)
+ break;
+ bit = SCRRIGHT(bit,1);
+ e += e1;
+ if (e >= 0)
+ {
+ *addrl = tmp;
+ mfbScanlineInc(addrl, yinc);
+ e += e3;
+ if (!bit)
+ {
+ bit = leftbit;
+ addrl ++;
+ }
+ tmp = *addrl;
+ }
+ else if (!bit)
+ {
+ *addrl = tmp;
+ bit = leftbit;
+ addrl ++;
+ tmp = *addrl;
+ }
+ }
+ *addrl = tmp;
+ }
+ else
+ {
+ tmp = *addrl;
+ for (;;)
+ {
+ tmp &= ~bit;
+ if (!--len)
+ break;
+ e += e1;
+ bit = SCRLEFT(bit,1);
+ if (e >= 0)
+ {
+ *addrl = tmp;
+ mfbScanlineInc(addrl, yinc);
+ e += e3;
+ if (!bit)
+ {
+ bit = rightbit;
+ addrl --;
+ }
+ tmp = *addrl;
+ }
+ else if (!bit)
+ {
+ *addrl = tmp;
+ bit = rightbit;
+ addrl --;
+ tmp = *addrl;
+ }
+ }
+ *addrl = tmp;
+ }
+ } /* if X_AXIS */
+ else
+ {
+ if (signdx > 0)
+ {
+ while(len--)
+ {
+ *addrl &= ~bit;
+ e += e1;
+ if (e >= 0)
+ {
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ e += e3;
+ }
+ mfbScanlineInc(addrl, yinc);
+ }
+ }
+ else
+ {
+ while(len--)
+ {
+ *addrl &= ~bit;
+ e += e1;
+ if (e >= 0)
+ {
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit;addrl --; }
+ e += e3;
+ }
+ mfbScanlineInc(addrl, yinc);
+ }
+ }
+ } /* else Y_AXIS */
+ }
+ else if (rop == RROP_WHITE)
+ {
+ if (axis == X_AXIS)
+ {
+ if (signdx > 0)
+ {
+ tmp = *addrl;
+ for (;;)
+ {
+ tmp |= bit;
+ if (!--len)
+ break;
+ e += e1;
+ bit = SCRRIGHT(bit,1);
+ if (e >= 0)
+ {
+ *addrl = tmp;
+ mfbScanlineInc(addrl, yinc);
+ e += e3;
+ if (!bit)
+ {
+ bit = leftbit;
+ addrl ++;
+ }
+ tmp = *addrl;
+ }
+ else if (!bit)
+ {
+ *addrl = tmp;
+ bit = leftbit;
+ addrl ++;
+ tmp = *addrl;
+ }
+ }
+ *addrl = tmp;
+ }
+ else
+ {
+ tmp = *addrl;
+ for (;;)
+ {
+ tmp |= bit;
+ if (!--len)
+ break;
+ e += e1;
+ bit = SCRLEFT(bit,1);
+ if (e >= 0)
+ {
+ *addrl = tmp;
+ mfbScanlineInc(addrl, yinc);
+ e += e3;
+ if (!bit)
+ {
+ bit = rightbit;
+ addrl --;
+ }
+ tmp = *addrl;
+ }
+ else if (!bit)
+ {
+ *addrl = tmp;
+ bit = rightbit;
+ addrl --;
+ tmp = *addrl;
+ }
+ }
+ *addrl = tmp;
+ }
+ } /* if X_AXIS */
+ else
+ {
+ if (signdx > 0)
+ {
+ while(len--)
+ {
+ *addrl |= bit;
+ e += e1;
+ if (e >= 0)
+ {
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ e += e3;
+ }
+ mfbScanlineInc(addrl, yinc);
+ }
+ }
+ else
+ {
+ while(len--)
+ {
+ *addrl |= bit;
+ e += e1;
+ if (e >= 0)
+ {
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit;addrl --; }
+ e += e3;
+ }
+ mfbScanlineInc(addrl, yinc);
+ }
+ }
+ } /* else Y_AXIS */
+ }
+ else if (rop == RROP_INVERT)
+ {
+ if (axis == X_AXIS)
+ {
+ if (signdx > 0)
+ {
+ while(len--)
+ {
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0)
+ {
+ mfbScanlineInc(addrl, yinc);
+ e += e3;
+ }
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ }
+ }
+ else
+ {
+ while(len--)
+ {
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0)
+ {
+ mfbScanlineInc(addrl, yinc);
+ e += e3;
+ }
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit;addrl --; }
+ }
+ }
+ } /* if X_AXIS */
+ else
+ {
+ if (signdx > 0)
+ {
+ while(len--)
+ {
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0)
+ {
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ e += e3;
+ }
+ mfbScanlineInc(addrl, yinc);
+ }
+ }
+ else
+ {
+ while(len--)
+ {
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0)
+ {
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit; addrl --; }
+ e += e3;
+ }
+ mfbScanlineInc(addrl, yinc);
+ }
+ }
+ } /* else Y_AXIS */
+ }
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbbresd.c b/nx-X11/programs/Xserver/mfb/mfbbresd.c
new file mode 100644
index 000000000..266111e65
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbbresd.c
@@ -0,0 +1,209 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbbresd.c,v 1.4 2001/01/17 22:37:02 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbbresd.c,v 1.4 2001/02/09 02:05:18 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "mfb.h"
+#include "maskbits.h"
+#include "miline.h"
+
+/* Dashed bresenham line */
+
+#define StepDash\
+ if (!--dashRemaining) { \
+ if (++ dashIndex == numInDashList) \
+ dashIndex = 0; \
+ dashRemaining = pDash[dashIndex]; \
+ rop = fgrop; \
+ if (dashIndex & 1) \
+ rop = bgrop; \
+ }
+
+void
+mfbBresD(fgrop, bgrop,
+ pdashIndex, pDash, numInDashList, pdashOffset, isDoubleDash,
+ addrlbase, nlwidth,
+ signdx, signdy, axis, x1, y1, e, e1, e2, len)
+int fgrop, bgrop;
+int *pdashIndex; /* current dash */
+unsigned char *pDash; /* dash list */
+int numInDashList; /* total length of dash list */
+int *pdashOffset; /* offset into current dash */
+int isDoubleDash;
+PixelType *addrlbase; /* pointer to base of bitmap */
+int nlwidth; /* width in longwords of bitmap */
+int signdx, signdy; /* signs of directions */
+int axis; /* major axis (Y_AXIS or X_AXIS) */
+int x1, y1; /* initial point */
+register int e; /* error accumulator */
+register int e1; /* bresenham increments */
+int e2;
+int len; /* length of line */
+{
+ register int yinc; /* increment to next scanline, in bytes */
+ register PixelType *addrl;
+ register int e3 = e2-e1;
+ register MfbBits bit;
+ PixelType leftbit = mask[0]; /* leftmost bit to process in new word */
+ PixelType rightbit = mask[PPW-1]; /* rightmost bit to process in new word */
+ int dashIndex;
+ int dashOffset;
+ int dashRemaining;
+ int rop;
+
+ dashOffset = *pdashOffset;
+ dashIndex = *pdashIndex;
+ dashRemaining = pDash[dashIndex] - dashOffset;
+ rop = fgrop;
+ if (!isDoubleDash)
+ bgrop = -1;
+ if (dashIndex & 1)
+ rop = bgrop;
+
+ /* point to longword containing first point */
+ addrl = mfbScanline(addrlbase, x1, y1, nlwidth);
+ yinc = signdy * nlwidth;
+ e = e-e1; /* to make looping easier */
+ bit = mask[x1 & PIM];
+ if (axis == X_AXIS)
+ {
+ if (signdx > 0)
+ {
+ while(len--)
+ {
+ if (rop == RROP_BLACK)
+ *addrl &= ~bit;
+ else if (rop == RROP_WHITE)
+ *addrl |= bit;
+ else if (rop == RROP_INVERT)
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0)
+ {
+ mfbScanlineInc(addrl, yinc);
+ e += e3;
+ }
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ StepDash
+ }
+ }
+ else
+ {
+ while(len--)
+ {
+ if (rop == RROP_BLACK)
+ *addrl &= ~bit;
+ else if (rop == RROP_WHITE)
+ *addrl |= bit;
+ else if (rop == RROP_INVERT)
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0)
+ {
+ mfbScanlineInc(addrl, yinc);
+ e += e3;
+ }
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit;addrl --; }
+ StepDash
+ }
+ }
+ } /* if X_AXIS */
+ else
+ {
+ if (signdx > 0)
+ {
+ while(len--)
+ {
+ if (rop == RROP_BLACK)
+ *addrl &= ~bit;
+ else if (rop == RROP_WHITE)
+ *addrl |= bit;
+ else if (rop == RROP_INVERT)
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0)
+ {
+ bit = SCRRIGHT(bit,1);
+ if (!bit) { bit = leftbit;addrl ++; }
+ e += e3;
+ }
+ mfbScanlineInc(addrl, yinc);
+ StepDash
+ }
+ }
+ else
+ {
+ while(len--)
+ {
+ if (rop == RROP_BLACK)
+ *addrl &= ~bit;
+ else if (rop == RROP_WHITE)
+ *addrl |= bit;
+ else if (rop == RROP_INVERT)
+ *addrl ^= bit;
+ e += e1;
+ if (e >= 0)
+ {
+ bit = SCRLEFT(bit,1);
+ if (!bit) { bit = rightbit;addrl --; }
+ e += e3;
+ }
+ mfbScanlineInc(addrl, yinc);
+ StepDash
+ }
+ }
+ } /* else Y_AXIS */
+ *pdashIndex = dashIndex;
+ *pdashOffset = pDash[dashIndex] - dashRemaining;
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbbstore.c b/nx-X11/programs/Xserver/mfb/mfbbstore.c
new file mode 100644
index 000000000..270aa78fd
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbbstore.c
@@ -0,0 +1,155 @@
+/* $Xorg: mfbbstore.c,v 1.4 2001/02/09 02:05:18 xorgcvs Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "mfb.h"
+#include <X11/X.h>
+#include "mibstore.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+
+/*-
+ *-----------------------------------------------------------------------
+ * mfbSaveAreas --
+ * Function called by miSaveAreas to actually fetch the areas to be
+ * saved into the backing pixmap. This is very simple to do, since
+ * mfbDoBitblt is designed for this very thing. The region to save is
+ * already destination-relative and we're given the offset to the
+ * window origin, so we have only to create an array of points of the
+ * u.l. corners of the boxes in the region translated to the screen
+ * coordinate system and fetch the screen pixmap out of its devPrivate
+ * field....
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Data are copied from the screen into the pixmap.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+mfbSaveAreas(pPixmap, prgnSave, xorg, yorg, pWin)
+ PixmapPtr pPixmap; /* Backing pixmap */
+ RegionPtr prgnSave; /* Region to save (pixmap-relative) */
+ int xorg; /* X origin of region */
+ int yorg; /* Y origin of region */
+ WindowPtr pWin;
+{
+ register DDXPointPtr pPt;
+ DDXPointPtr pPtsInit;
+ register BoxPtr pBox;
+ register int numRects;
+
+ numRects = REGION_NUM_RECTS(prgnSave);
+ pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects * sizeof(DDXPointRec));
+ if (!pPtsInit)
+ return;
+
+ pBox = REGION_RECTS(prgnSave);
+ pPt = pPtsInit;
+ while (numRects--)
+ {
+ pPt->x = pBox->x1 + xorg;
+ pPt->y = pBox->y1 + yorg;
+ pPt++;
+ pBox++;
+ }
+
+ mfbDoBitblt((DrawablePtr)pPixmap->drawable.pScreen->devPrivate,
+ (DrawablePtr)pPixmap,
+ GXcopy,
+ prgnSave,
+ pPtsInit);
+
+ DEALLOCATE_LOCAL(pPtsInit);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * mfbRestoreAreas --
+ * Function called by miRestoreAreas to actually fetch the areas to be
+ * restored from the backing pixmap. This is very simple to do, since
+ * mfbDoBitblt is designed for this very thing. The region to restore is
+ * already destination-relative and we're given the offset to the
+ * window origin, so we have only to create an array of points of the
+ * u.l. corners of the boxes in the region translated to the pixmap
+ * coordinate system and fetch the screen pixmap out of its devPrivate
+ * field....
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Data are copied from the pixmap into the screen.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+mfbRestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin)
+ PixmapPtr pPixmap; /* Backing pixmap */
+ RegionPtr prgnRestore; /* Region to restore (screen-relative)*/
+ int xorg; /* X origin of window */
+ int yorg; /* Y origin of window */
+ WindowPtr pWin;
+{
+ register DDXPointPtr pPt;
+ DDXPointPtr pPtsInit;
+ register BoxPtr pBox;
+ register int numRects;
+
+ numRects = REGION_NUM_RECTS(prgnRestore);
+ pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(numRects*sizeof(DDXPointRec));
+ if (!pPtsInit)
+ return;
+
+ pBox = REGION_RECTS(prgnRestore);
+ pPt = pPtsInit;
+ while (numRects--)
+ {
+ pPt->x = pBox->x1 - xorg;
+ pPt->y = pBox->y1 - yorg;
+ pPt++;
+ pBox++;
+ }
+
+ mfbDoBitblt((DrawablePtr)pPixmap,
+ (DrawablePtr)pPixmap->drawable.pScreen->devPrivate,
+ GXcopy,
+ prgnRestore,
+ pPtsInit);
+
+ DEALLOCATE_LOCAL(pPtsInit);
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbclip.c b/nx-X11/programs/Xserver/mfb/mfbclip.c
new file mode 100644
index 000000000..5501f0d5c
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbclip.c
@@ -0,0 +1,280 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbclip.c,v 1.5 2001/12/14 20:00:05 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbclip.c,v 1.4 2001/02/09 02:05:18 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "regionstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "regionstr.h"
+#include "gc.h"
+#include "maskbits.h"
+#include "mi.h"
+#include "mfb.h"
+
+#define ADDRECT(reg,r,fr,rx1,ry1,rx2,ry2) \
+if (((rx1) < (rx2)) && ((ry1) < (ry2)) && \
+ (!((reg)->data->numRects && \
+ ((r-1)->y1 == (ry1)) && \
+ ((r-1)->y2 == (ry2)) && \
+ ((r-1)->x1 <= (rx1)) && \
+ ((r-1)->x2 >= (rx2))))) \
+{ \
+ if ((reg)->data->numRects == (reg)->data->size) \
+ { \
+ miRectAlloc(reg, 1); \
+ fr = REGION_BOXPTR(reg); \
+ r = fr + (reg)->data->numRects; \
+ } \
+ r->x1 = (rx1); \
+ r->y1 = (ry1); \
+ r->x2 = (rx2); \
+ r->y2 = (ry2); \
+ (reg)->data->numRects++; \
+ if(r->x1 < (reg)->extents.x1) \
+ (reg)->extents.x1 = r->x1; \
+ if(r->x2 > (reg)->extents.x2) \
+ (reg)->extents.x2 = r->x2; \
+ r++; \
+}
+
+/* Convert bitmap clip mask into clipping region.
+ * First, goes through each line and makes boxes by noting the transitions
+ * from 0 to 1 and 1 to 0.
+ * Then it coalesces the current line with the previous if they have boxes
+ * at the same X coordinates.
+ */
+RegionPtr
+mfbPixmapToRegion(pPix)
+ PixmapPtr pPix;
+{
+ register RegionPtr pReg;
+ register PixelType *pw, w;
+ register int ib;
+ int width, h, base, rx1 = 0, crects;
+ PixelType *pwLineEnd;
+ int irectPrevStart, irectLineStart;
+ register BoxPtr prectO, prectN;
+ BoxPtr FirstRect, rects, prectLineStart;
+ Bool fInBox, fSame;
+ register PixelType mask0 = mask[0];
+ PixelType *pwLine;
+ int nWidth;
+
+ pReg = REGION_CREATE(pPix->drawable.pScreen, NULL, 1);
+ if(!pReg)
+ return NullRegion;
+ FirstRect = REGION_BOXPTR(pReg);
+ rects = FirstRect;
+
+ pwLine = (PixelType *) pPix->devPrivate.ptr;
+ nWidth = pPix->devKind / PGSZB;
+
+ width = pPix->drawable.width;
+ pReg->extents.x1 = width - 1;
+ pReg->extents.x2 = 0;
+ irectPrevStart = -1;
+ for(h = 0; h < pPix->drawable.height; h++)
+ {
+ pw = pwLine;
+ pwLine += nWidth;
+ irectLineStart = rects - FirstRect;
+ /* If the Screen left most bit of the word is set, we're starting in
+ * a box */
+ if(*pw & mask0)
+ {
+ fInBox = TRUE;
+ rx1 = 0;
+ }
+ else
+ fInBox = FALSE;
+ /* Process all words which are fully in the pixmap */
+ pwLineEnd = pw + (width >> PWSH);
+ for (base = 0; pw < pwLineEnd; base += PPW)
+ {
+ w = *pw++;
+ if (fInBox)
+ {
+ if (!~w)
+ continue;
+ }
+ else
+ {
+ if (!w)
+ continue;
+ }
+ for(ib = 0; ib < PPW; ib++)
+ {
+ /* If the Screen left most bit of the word is set, we're
+ * starting a box */
+ if(w & mask0)
+ {
+ if(!fInBox)
+ {
+ rx1 = base + ib;
+ /* start new box */
+ fInBox = TRUE;
+ }
+ }
+ else
+ {
+ if(fInBox)
+ {
+ /* end box */
+ ADDRECT(pReg, rects, FirstRect,
+ rx1, h, base + ib, h + 1);
+ fInBox = FALSE;
+ }
+ }
+ /* Shift the word VISUALLY left one. */
+ w = SCRLEFT(w, 1);
+ }
+ }
+ if(width & PIM)
+ {
+ /* Process final partial word on line */
+ w = *pw++;
+ for(ib = 0; ib < (width & PIM); ib++)
+ {
+ /* If the Screen left most bit of the word is set, we're
+ * starting a box */
+ if(w & mask0)
+ {
+ if(!fInBox)
+ {
+ rx1 = base + ib;
+ /* start new box */
+ fInBox = TRUE;
+ }
+ }
+ else
+ {
+ if(fInBox)
+ {
+ /* end box */
+ ADDRECT(pReg, rects, FirstRect,
+ rx1, h, base + ib, h + 1);
+ fInBox = FALSE;
+ }
+ }
+ /* Shift the word VISUALLY left one. */
+ w = SCRLEFT(w, 1);
+ }
+ }
+ /* If scanline ended with last bit set, end the box */
+ if(fInBox)
+ {
+ ADDRECT(pReg, rects, FirstRect,
+ rx1, h, base + (width & PIM), h + 1);
+ }
+ /* if all rectangles on this line have the same x-coords as
+ * those on the previous line, then add 1 to all the previous y2s and
+ * throw away all the rectangles from this line
+ */
+ fSame = FALSE;
+ if(irectPrevStart != -1)
+ {
+ crects = irectLineStart - irectPrevStart;
+ if(crects == ((rects - FirstRect) - irectLineStart))
+ {
+ prectO = FirstRect + irectPrevStart;
+ prectN = prectLineStart = FirstRect + irectLineStart;
+ fSame = TRUE;
+ while(prectO < prectLineStart)
+ {
+ if((prectO->x1 != prectN->x1) || (prectO->x2 != prectN->x2))
+ {
+ fSame = FALSE;
+ break;
+ }
+ prectO++;
+ prectN++;
+ }
+ if (fSame)
+ {
+ prectO = FirstRect + irectPrevStart;
+ while(prectO < prectLineStart)
+ {
+ prectO->y2 += 1;
+ prectO++;
+ }
+ rects -= crects;
+ pReg->data->numRects -= crects;
+ }
+ }
+ }
+ if(!fSame)
+ irectPrevStart = irectLineStart;
+ }
+ if (!pReg->data->numRects)
+ pReg->extents.x1 = pReg->extents.x2 = 0;
+ else
+ {
+ pReg->extents.y1 = REGION_BOXPTR(pReg)->y1;
+ pReg->extents.y2 = REGION_END(pReg)->y2;
+ if (pReg->data->numRects == 1)
+ {
+ xfree(pReg->data);
+ pReg->data = (RegDataPtr)NULL;
+ }
+ }
+#ifdef DEBUG
+ if (!miValidRegion(pReg))
+ FatalError("Assertion failed file %s, line %d: expr\n", __FILE__, __LINE__);
+#endif
+ return(pReg);
+}
+
+mfbPixmapToRegionProc *
+mfbPixmapToRegionWeak(void)
+{
+ return mfbPixmapToRegion;
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbcmap.c b/nx-X11/programs/Xserver/mfb/mfbcmap.c
new file mode 100644
index 000000000..a16964e15
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbcmap.c
@@ -0,0 +1,164 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbcmap.c,v 1.7tsi Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbcmap.c,v 1.4 2001/02/09 02:05:18 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "colormapst.h"
+#include "resource.h"
+#include "micmap.h"
+#include "mfb.h"
+
+/* A monochrome frame buffer is a static gray colormap with two entries.
+ * We have a "required list" of length 1. Because we can only support 1
+ * colormap, we never have to change it, but we may have to change the
+ * name we call it. If someone installs a new colormap, we know it must
+ * look just like the old one (because we've checked in dispatch that it was
+ * a valid colormap identifier, and all the colormap IDs for this device
+ * look the same). Nevertheless, we still have to uninstall the old colormap
+ * and install the new one. Similarly, if someone uninstalls a colormap,
+ * we have to install the default map, even though we know those two looked
+ * alike.
+ * The required list concept is pretty much irrelevant when you can only
+ * have one map installed at a time.
+ */
+
+int
+mfbListInstalledColormaps(pScreen, pmaps)
+ ScreenPtr pScreen;
+ Colormap *pmaps;
+{
+ return miListInstalledColormaps(pScreen, pmaps);
+}
+
+
+void
+mfbInstallColormap(pmap)
+ ColormapPtr pmap;
+{
+ miInstallColormap(pmap);
+}
+
+void
+mfbUninstallColormap(pmap)
+ ColormapPtr pmap;
+{
+ miUninstallColormap(pmap);
+}
+
+/*ARGSUSED*/
+void
+mfbResolveColor (pred, pgreen, pblue, pVisual)
+ unsigned short *pred;
+ unsigned short *pgreen;
+ unsigned short *pblue;
+ VisualPtr pVisual;
+{
+ /*
+ * Gets intensity from RGB. If intensity is >= half, pick white, else
+ * pick black. This may well be more trouble than it's worth.
+ */
+ *pred = *pgreen = *pblue =
+ (((30L * *pred +
+ 59L * *pgreen +
+ 11L * *pblue) >> 8) >= (((1<<8)-1)*50)) ? ~0 : 0;
+}
+
+Bool
+mfbCreateColormap(pMap)
+ ColormapPtr pMap;
+{
+ ScreenPtr pScreen;
+ unsigned short red0, green0, blue0;
+ unsigned short red1, green1, blue1;
+ Pixel pix;
+
+ pScreen = pMap->pScreen;
+ if (pScreen->whitePixel == 0)
+ {
+ red0 = green0 = blue0 = ~0;
+ red1 = green1 = blue1 = 0;
+ }
+ else
+ {
+ red0 = green0 = blue0 = 0;
+ red1 = green1 = blue1 = ~0;
+ }
+
+ /* this is a monochrome colormap, it only has two entries, just fill
+ * them in by hand. If it were a more complex static map, it would be
+ * worth writing a for loop or three to initialize it */
+
+ /* this will be pixel 0 */
+ pix = 0;
+ if (AllocColor(pMap, &red0, &green0, &blue0, &pix, 0) != Success)
+ return FALSE;
+
+ /* this will be pixel 1 */
+ if (AllocColor(pMap, &red1, &green1, &blue1, &pix, 0) != Success)
+ return FALSE;
+ return TRUE;
+}
+
+/*ARGSUSED*/
+void
+mfbDestroyColormap (pMap)
+ ColormapPtr pMap;
+{
+ return;
+}
+
+Bool
+mfbCreateDefColormap (pScreen)
+ ScreenPtr pScreen;
+{
+ return miCreateDefColormap(pScreen);
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbfillarc.c b/nx-X11/programs/Xserver/mfb/mfbfillarc.c
new file mode 100644
index 000000000..a5442896f
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbfillarc.c
@@ -0,0 +1,333 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbfillarc.c,v 1.5 2001/12/14 20:00:06 dawes Exp $ */
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+********************************************************/
+
+/* $Xorg: mfbfillarc.c,v 1.4 2001/02/09 02:05:18 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "mfb.h"
+#include "maskbits.h"
+#include "mifillarc.h"
+#include "mi.h"
+
+static void
+mfbFillEllipseSolid(
+ DrawablePtr pDraw,
+ xArc *arc,
+ register int rop)
+{
+ int x, y, e;
+ int yk, xk, ym, xm, dx, dy, xorg, yorg;
+ register int slw;
+ miFillArcRec info;
+ PixelType *addrlt, *addrlb;
+ register PixelType *addrl;
+ register int n;
+ int nlwidth;
+ register int xpos;
+ PixelType startmask, endmask;
+ int nlmiddle;
+
+ mfbGetPixelWidthAndPointer(pDraw, nlwidth, addrlt);
+ miFillArcSetup(arc, &info);
+ MIFILLARCSETUP();
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ addrlb = addrlt;
+ addrlt += nlwidth * (yorg - y);
+ addrlb += nlwidth * (yorg + y + dy);
+ while (y)
+ {
+ addrlt += nlwidth;
+ addrlb -= nlwidth;
+ MIFILLARCSTEP(slw);
+ if (!slw)
+ continue;
+ xpos = xorg - x;
+ addrl = mfbScanlineOffset(addrlt, (xpos >> PWSH));
+ if (((xpos & PIM) + slw) < PPW)
+ {
+ maskpartialbits(xpos, slw, startmask);
+ if (rop == RROP_BLACK)
+ *addrl &= ~startmask;
+ else if (rop == RROP_WHITE)
+ *addrl |= startmask;
+ else
+ *addrl ^= startmask;
+ if (miFillArcLower(slw))
+ {
+ addrl = mfbScanlineOffset(addrlb, (xpos >> PWSH));
+ if (rop == RROP_BLACK)
+ *addrl &= ~startmask;
+ else if (rop == RROP_WHITE)
+ *addrl |= startmask;
+ else
+ *addrl ^= startmask;
+ }
+ continue;
+ }
+ maskbits(xpos, slw, startmask, endmask, nlmiddle);
+ if (startmask)
+ {
+ if (rop == RROP_BLACK)
+ *addrl++ &= ~startmask;
+ else if (rop == RROP_WHITE)
+ *addrl++ |= startmask;
+ else
+ *addrl++ ^= startmask;
+ }
+ n = nlmiddle;
+ if (rop == RROP_BLACK)
+ while (n--)
+ *addrl++ = 0;
+ else if (rop == RROP_WHITE)
+ while (n--)
+ *addrl++ = ~0;
+ else
+ while (n--)
+ *addrl++ ^= ~0;
+ if (endmask)
+ {
+ if (rop == RROP_BLACK)
+ *addrl &= ~endmask;
+ else if (rop == RROP_WHITE)
+ *addrl |= endmask;
+ else
+ *addrl ^= endmask;
+ }
+ if (!miFillArcLower(slw))
+ continue;
+ addrl = mfbScanlineOffset(addrlb, (xpos >> PWSH));
+ if (startmask)
+ {
+ if (rop == RROP_BLACK)
+ *addrl++ &= ~startmask;
+ else if (rop == RROP_WHITE)
+ *addrl++ |= startmask;
+ else
+ *addrl++ ^= startmask;
+ }
+ n = nlmiddle;
+ if (rop == RROP_BLACK)
+ while (n--)
+ *addrl++ = 0;
+ else if (rop == RROP_WHITE)
+ while (n--)
+ *addrl++ = ~0;
+ else
+ while (n--)
+ *addrl++ ^= ~0;
+ if (endmask)
+ {
+ if (rop == RROP_BLACK)
+ *addrl &= ~endmask;
+ else if (rop == RROP_WHITE)
+ *addrl |= endmask;
+ else
+ *addrl ^= endmask;
+ }
+ }
+}
+
+#define FILLSPAN(xl,xr,addr) \
+ if (xr >= xl) \
+ { \
+ width = xr - xl + 1; \
+ addrl = mfbScanlineOffset(addr, (xl >> PWSH)); \
+ if (((xl & PIM) + width) < PPW) \
+ { \
+ maskpartialbits(xl, width, startmask); \
+ if (rop == RROP_BLACK) \
+ *addrl &= ~startmask; \
+ else if (rop == RROP_WHITE) \
+ *addrl |= startmask; \
+ else \
+ *addrl ^= startmask; \
+ } \
+ else \
+ { \
+ maskbits(xl, width, startmask, endmask, nlmiddle); \
+ if (startmask) \
+ { \
+ if (rop == RROP_BLACK) \
+ *addrl++ &= ~startmask; \
+ else if (rop == RROP_WHITE) \
+ *addrl++ |= startmask; \
+ else \
+ *addrl++ ^= startmask; \
+ } \
+ n = nlmiddle; \
+ if (rop == RROP_BLACK) \
+ while (n--) \
+ *addrl++ = 0; \
+ else if (rop == RROP_WHITE) \
+ while (n--) \
+ *addrl++ = ~0; \
+ else \
+ while (n--) \
+ *addrl++ ^= ~0; \
+ if (endmask) \
+ { \
+ if (rop == RROP_BLACK) \
+ *addrl &= ~endmask; \
+ else if (rop == RROP_WHITE) \
+ *addrl |= endmask; \
+ else \
+ *addrl ^= endmask; \
+ } \
+ } \
+ }
+
+#define FILLSLICESPANS(flip,addr) \
+ if (!flip) \
+ { \
+ FILLSPAN(xl, xr, addr); \
+ } \
+ else \
+ { \
+ xc = xorg - x; \
+ FILLSPAN(xc, xr, addr); \
+ xc += slw - 1; \
+ FILLSPAN(xl, xc, addr); \
+ }
+
+static void
+mfbFillArcSliceSolidCopy(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ xArc *arc,
+ register int rop)
+{
+ register PixelType *addrl;
+ register int n;
+ int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
+ register int x, y, e;
+ miFillArcRec info;
+ miArcSliceRec slice;
+ int xl, xr, xc;
+ PixelType *addrlt, *addrlb;
+ int nlwidth;
+ int width;
+ PixelType startmask, endmask;
+ int nlmiddle;
+
+ mfbGetPixelWidthAndPointer(pDraw, nlwidth, addrlt);
+ miFillArcSetup(arc, &info);
+ miFillArcSliceSetup(arc, &slice, pGC);
+ MIFILLARCSETUP();
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ addrlb = addrlt;
+ addrlt = mfbScanlineDeltaNoBankSwitch(addrlt, yorg - y, nlwidth);
+ addrlb = mfbScanlineDeltaNoBankSwitch(addrlb, yorg + y + dy, nlwidth);
+ slice.edge1.x += pDraw->x;
+ slice.edge2.x += pDraw->x;
+ while (y > 0)
+ {
+ mfbScanlineIncNoBankSwitch(addrlt, nlwidth);
+ mfbScanlineIncNoBankSwitch(addrlb, -nlwidth);
+ MIFILLARCSTEP(slw);
+ MIARCSLICESTEP(slice.edge1);
+ MIARCSLICESTEP(slice.edge2);
+ if (miFillSliceUpper(slice))
+ {
+ MIARCSLICEUPPER(xl, xr, slice, slw);
+ FILLSLICESPANS(slice.flip_top, addrlt);
+ }
+ if (miFillSliceLower(slice))
+ {
+ MIARCSLICELOWER(xl, xr, slice, slw);
+ FILLSLICESPANS(slice.flip_bot, addrlb);
+ }
+ }
+}
+
+void
+mfbPolyFillArcSolid(pDraw, pGC, narcs, parcs)
+ register DrawablePtr pDraw;
+ GCPtr pGC;
+ int narcs;
+ xArc *parcs;
+{
+ mfbPrivGC *priv;
+ register xArc *arc;
+ register int i;
+ BoxRec box;
+ int x2, y2;
+ RegionPtr cclip;
+ int rop;
+
+ priv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr;
+ rop = priv->rop;
+ if ((rop == RROP_NOP) || !(pGC->planemask & 1))
+ return;
+ cclip = pGC->pCompositeClip;
+ for (arc = parcs, i = narcs; --i >= 0; arc++)
+ {
+ if (miFillArcEmpty(arc))
+ continue;
+ if (miCanFillArc(arc))
+ {
+ box.x1 = arc->x + pDraw->x;
+ box.y1 = arc->y + pDraw->y;
+ /*
+ * Because box.x2 and box.y2 get truncated to 16 bits, and the
+ * RECT_IN_REGION test treats the resulting number as a signed
+ * integer, the RECT_IN_REGION test alone can go the wrong way.
+ * This can result in a server crash because the rendering
+ * routines in this file deal directly with cpu addresses
+ * of pixels to be stored, and do not clip or otherwise check
+ * that all such addresses are within their respective pixmaps.
+ * So we only allow the RECT_IN_REGION test to be used for
+ * values that can be expressed correctly in a signed short.
+ */
+ x2 = box.x1 + (int)arc->width + 1;
+ box.x2 = x2;
+ y2 = box.y1 + (int)arc->height + 1;
+ box.y2 = y2;
+ if ( (x2 <= MAXSHORT) && (y2 <= MAXSHORT) &&
+ (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) )
+ {
+ if ((arc->angle2 >= FULLCIRCLE) ||
+ (arc->angle2 <= -FULLCIRCLE))
+ mfbFillEllipseSolid(pDraw, arc, rop);
+ else
+ mfbFillArcSliceSolidCopy(pDraw, pGC, arc, rop);
+ continue;
+ }
+ }
+ miPolyFillArc(pDraw, pGC, 1, arc);
+ }
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbfillrct.c b/nx-X11/programs/Xserver/mfb/mfbfillrct.c
new file mode 100644
index 000000000..ba8a14283
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbfillrct.c
@@ -0,0 +1,228 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbfillrct.c,v 1.5tsi Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbfillrct.c,v 1.4 2001/02/09 02:05:18 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "pixmapstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "miscstruct.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+
+#include "mfb.h"
+#include "maskbits.h"
+
+#define MODEQ(a, b) ((a) %= (b))
+
+/*
+ filled rectangles.
+ translate the rectangles, clip them, and call the
+helper function in the GC.
+*/
+
+#define NUM_STACK_RECTS 1024
+
+void
+mfbPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nrectFill; /* number of rectangles to fill */
+ xRectangle *prectInit; /* Pointer to first rectangle to fill */
+{
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ register BoxPtr pbox;
+ register BoxPtr pboxClipped;
+ BoxPtr pboxClippedBase;
+ BoxPtr pextent;
+ BoxRec stackRects[NUM_STACK_RECTS];
+ int numRects;
+ int n;
+ int xorg, yorg;
+ mfbPrivGC *priv;
+ int alu;
+ mfbFillAreaProcPtr pfn;
+ PixmapPtr ppix;
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ priv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr;
+ alu = priv->ropFillArea;
+ pfn = priv->FillArea;
+ ppix = pGC->pRotatedPixmap;
+ prgnClip = pGC->pCompositeClip;
+
+ prect = prectInit;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ if (xorg || yorg)
+ {
+ prect = prectInit;
+ n = nrectFill;
+ Duff (n, prect->x += xorg; prect->y += yorg; prect++);
+ }
+
+
+ prect = prectInit;
+
+ numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
+ if (numRects > NUM_STACK_RECTS)
+ {
+ pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(numRects * sizeof(BoxRec));
+ if (!pboxClippedBase)
+ return;
+ }
+ else
+ pboxClippedBase = stackRects;
+
+ pboxClipped = pboxClippedBase;
+
+ if (REGION_NUM_RECTS(prgnClip) == 1)
+ {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_RECTS(prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--)
+ {
+ if ((pboxClipped->x1 = prect->x) < x1)
+ pboxClipped->x1 = x1;
+
+ if ((pboxClipped->y1 = prect->y) < y1)
+ pboxClipped->y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ pboxClipped->x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ pboxClipped->y2 = by2;
+
+ prect++;
+ if ((pboxClipped->x1 < pboxClipped->x2) &&
+ (pboxClipped->y1 < pboxClipped->y2))
+ {
+ pboxClipped++;
+ }
+ }
+ }
+ else
+ {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--)
+ {
+ BoxRec box;
+
+ if ((box.x1 = prect->x) < x1)
+ box.x1 = x1;
+
+ if ((box.y1 = prect->y) < y1)
+ box.y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ box.x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ box.y2 = by2;
+
+ prect++;
+
+ if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
+ continue;
+
+ n = REGION_NUM_RECTS (prgnClip);
+ pbox = REGION_RECTS(prgnClip);
+
+ /* clip the rectangle to each box in the clip region
+ this is logically equivalent to calling Intersect()
+ */
+ while(n--)
+ {
+ pboxClipped->x1 = max(box.x1, pbox->x1);
+ pboxClipped->y1 = max(box.y1, pbox->y1);
+ pboxClipped->x2 = min(box.x2, pbox->x2);
+ pboxClipped->y2 = min(box.y2, pbox->y2);
+ pbox++;
+
+ /* see if clipping left anything */
+ if(pboxClipped->x1 < pboxClipped->x2 &&
+ pboxClipped->y1 < pboxClipped->y2)
+ {
+ pboxClipped++;
+ }
+ }
+ }
+ }
+ if (pboxClipped != pboxClippedBase)
+ (*pfn) (pDrawable,pboxClipped-pboxClippedBase, pboxClippedBase, alu, ppix);
+ if (pboxClippedBase != stackRects)
+ DEALLOCATE_LOCAL(pboxClippedBase);
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbfillsp.c b/nx-X11/programs/Xserver/mfb/mfbfillsp.c
new file mode 100644
index 000000000..f75ccb18d
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbfillsp.c
@@ -0,0 +1,1028 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbfillsp.c,v 1.8 2001/01/17 22:37:02 dawes Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbfillsp.c,v 1.4 2001/02/09 02:05:18 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "mfb.h"
+#include "maskbits.h"
+
+#include "mergerop.h"
+
+#include "servermd.h"
+#include "mi.h"
+#include "mispans.h"
+
+/* scanline filling for monochrome frame buffer
+ written by drewry, oct 1986
+
+ these routines all clip. they assume that anything that has called
+them has already translated the points (i.e. pGC->miTranslate is
+non-zero, which is howit gets set in mfbCreateGC().)
+
+ the number of new scnalines created by clipping ==
+MaxRectsPerBand * nSpans.
+
+ FillSolid is overloaded to be used for OpaqueStipple as well,
+if fgPixel == bgPixel.
+
+
+ FillTiled is overloaded to be used for OpaqueStipple, if
+fgPixel != bgPixel. based on the fill style, it uses
+{RotatedPixmap, gc.alu} or {RotatedPixmap, PrivGC.ropOpStip}
+*/
+
+
+void
+mfbBlackSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *addrl;/* pointer to current longword in bitmap */
+ register int nlmiddle;
+ register PixelType startmask;
+ register PixelType endmask;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
+
+ while (n--)
+ {
+ addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
+
+ if (*pwidth)
+ {
+ if ( ((ppt->x & PIM) + *pwidth) < PPW)
+ {
+ /* all bits inside same longword */
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl &= ~startmask;
+ }
+ else
+ {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ &= ~startmask;
+ Duff (nlmiddle, *addrl++ = 0x0);
+ if (endmask)
+ *addrl &= ~endmask;
+ }
+ }
+ pwidth++;
+ ppt++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+
+
+void
+mfbWhiteSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *addrl;/* pointer to current longword in bitmap */
+ register int nlmiddle;
+ register PixelType startmask;
+ register PixelType endmask;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
+
+ while (n--)
+ {
+ addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
+
+ if (*pwidth)
+ {
+ if ( ((ppt->x & PIM) + *pwidth) < PPW)
+ {
+ /* all bits inside same longword */
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl |= startmask;
+ }
+ else
+ {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ |= startmask;
+ Duff (nlmiddle, *addrl++ = ~0);
+ if (endmask)
+ *addrl |= endmask;
+ }
+ }
+ pwidth++;
+ ppt++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+
+
+void
+mfbInvertSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *addrl;/* pointer to current longword in bitmap */
+ register int nlmiddle;
+ register PixelType startmask;
+ register PixelType endmask;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
+
+ while (n--)
+ {
+ addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
+
+ if (*pwidth)
+ {
+ if ( ((ppt->x & PIM) + *pwidth) < PPW)
+ {
+ /* all bits inside same longword */
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl ^= startmask;
+ }
+ else
+ {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ ^= startmask;
+ Duff (nlmiddle, *addrl++ ^= ~0);
+ if (endmask)
+ *addrl ^= endmask;
+ }
+ }
+ pwidth++;
+ ppt++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+
+void
+mfbWhiteStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *addrl;/* pointer to current longword in bitmap */
+ register PixelType src;
+ register int nlmiddle;
+ register PixelType startmask;
+ register PixelType endmask;
+ PixmapPtr pStipple;
+ PixelType *psrc;
+ int tileHeight;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
+
+ pStipple = pGC->pRotatedPixmap;
+ tileHeight = pStipple->drawable.height;
+ psrc = (PixelType *)(pStipple->devPrivate.ptr);
+
+ while (n--)
+ {
+ addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
+ src = psrc[ppt->y % tileHeight];
+
+ /* all bits inside same longword */
+ if ( ((ppt->x & PIM) + *pwidth) < PPW)
+ {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl |= (src & startmask);
+ }
+ else
+ {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ |= (src & startmask);
+ Duff (nlmiddle, *addrl++ |= src);
+ if (endmask)
+ *addrl |= (src & endmask);
+ }
+ pwidth++;
+ ppt++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+
+void
+mfbBlackStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *addrl; /* pointer to current longword in bitmap */
+ register PixelType src;
+ register int nlmiddle;
+ register PixelType startmask;
+ register PixelType endmask;
+ PixmapPtr pStipple;
+ PixelType *psrc;
+ int tileHeight;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
+
+ pStipple = pGC->pRotatedPixmap;
+ tileHeight = pStipple->drawable.height;
+ psrc = (PixelType *)(pStipple->devPrivate.ptr);
+
+ while (n--)
+ {
+ addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
+ src = psrc[ppt->y % tileHeight];
+
+ /* all bits inside same longword */
+ if ( ((ppt->x & PIM) + *pwidth) < PPW)
+ {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl &= ~(src & startmask);
+ }
+ else
+ {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ &= ~(src & startmask);
+ Duff (nlmiddle, *addrl++ &= ~src);
+ if (endmask)
+ *addrl &= ~(src & endmask);
+ }
+ pwidth++;
+ ppt++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+
+void
+mfbInvertStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *addrl; /* pointer to current longword in bitmap */
+ register PixelType src;
+ register int nlmiddle;
+ register PixelType startmask;
+ register PixelType endmask;
+ PixmapPtr pStipple;
+ PixelType *psrc;
+ int tileHeight;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
+
+ pStipple = pGC->pRotatedPixmap;
+ tileHeight = pStipple->drawable.height;
+ psrc = (PixelType *)(pStipple->devPrivate.ptr);
+
+ while (n--)
+ {
+ addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
+ src = psrc[ppt->y % tileHeight];
+
+ /* all bits inside same longword */
+ if ( ((ppt->x & PIM) + *pwidth) < PPW)
+ {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl ^= (src & startmask);
+ }
+ else
+ {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ *addrl++ ^= (src & startmask);
+ Duff(nlmiddle, *addrl++ ^= src);
+ if (endmask)
+ *addrl ^= (src & endmask);
+ }
+ pwidth++;
+ ppt++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+
+/* this works with tiles of width == PPW */
+#define FILLSPANPPW(ROP) \
+ while (n--) \
+ { \
+ if (*pwidth) \
+ { \
+ addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth); \
+ src = psrc[ppt->y % tileHeight]; \
+ if ( ((ppt->x & PIM) + *pwidth) < PPW) \
+ { \
+ maskpartialbits(ppt->x, *pwidth, startmask); \
+ *addrl = (*addrl & ~startmask) | \
+ (ROP(src, *addrl) & startmask); \
+ } \
+ else \
+ { \
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle); \
+ if (startmask) \
+ { \
+ *addrl = (*addrl & ~startmask) | \
+ (ROP(src, *addrl) & startmask); \
+ addrl++; \
+ } \
+ while (nlmiddle--) \
+ { \
+ *addrl = ROP(src, *addrl); \
+ addrl++; \
+ } \
+ if (endmask) \
+ *addrl = (*addrl & ~endmask) | \
+ (ROP(src, *addrl) & endmask); \
+ } \
+ } \
+ pwidth++; \
+ ppt++; \
+ }
+
+
+
+void
+mfbTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *addrl; /* pointer to current longword in bitmap */
+ register PixelType src;
+ register int nlmiddle;
+ register PixelType startmask;
+ register PixelType endmask;
+ PixmapPtr pTile;
+ PixelType *psrc;
+ int tileHeight;
+ int rop;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ MfbBits flip;
+
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
+
+ pTile = pGC->pRotatedPixmap;
+ tileHeight = pTile->drawable.height;
+ psrc = (PixelType *)(pTile->devPrivate.ptr);
+ if (pGC->fillStyle == FillTiled)
+ rop = pGC->alu;
+ else
+ rop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->ropOpStip;
+
+ flip = 0;
+ switch(rop)
+ {
+ case GXcopyInverted: /* for opaque stipples */
+ flip = ~0;
+ case GXcopy:
+ {
+
+#define DoMaskCopyRop(src,dst,mask) (((dst) & ~(mask)) | ((src) & (mask)))
+
+ while (n--)
+ {
+ if (*pwidth)
+ {
+ addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
+ src = psrc[ppt->y % tileHeight] ^ flip;
+ if ( ((ppt->x & PIM) + *pwidth) < PPW)
+ {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl = DoMaskCopyRop (src, *addrl, startmask);
+ }
+ else
+ {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ {
+ *addrl = DoMaskCopyRop (src, *addrl, startmask);
+ addrl++;
+ }
+ while (nlmiddle--)
+ {
+ *addrl = src;
+ addrl++;
+ }
+ if (endmask)
+ *addrl = DoMaskCopyRop (src, *addrl, endmask);
+ }
+ }
+ pwidth++;
+ ppt++;
+ }
+ }
+ break;
+ default:
+ {
+ register DeclareMergeRop ();
+
+ InitializeMergeRop(rop,~0);
+ while (n--)
+ {
+ if (*pwidth)
+ {
+ addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
+ src = psrc[ppt->y % tileHeight];
+ if ( ((ppt->x & PIM) + *pwidth) < PPW)
+ {
+ maskpartialbits(ppt->x, *pwidth, startmask);
+ *addrl = DoMaskMergeRop (src, *addrl, startmask);
+ }
+ else
+ {
+ maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
+ if (startmask)
+ {
+ *addrl = DoMaskMergeRop (src, *addrl, startmask);
+ addrl++;
+ }
+ while (nlmiddle--)
+ {
+ *addrl = DoMergeRop (src, *addrl);
+ addrl++;
+ }
+ if (endmask)
+ *addrl = DoMaskMergeRop (src, *addrl, endmask);
+ }
+ }
+ pwidth++;
+ ppt++;
+ }
+ }
+ break;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+
+/* Fill spans with tiles that aren't PPW bits wide */
+void
+mfbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ int iline; /* first line of tile to use */
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *pdst;/* pointer to current word in bitmap */
+ register PixelType *psrc;/* pointer to current word in tile */
+ register int nlMiddle;
+ register int rop, nstart;
+ PixelType startmask;
+ PixmapPtr pTile; /* pointer to tile we want to fill with */
+ int w, width, x, xSrc, ySrc, srcStartOver, nend;
+ int tlwidth, rem, tileWidth, tileHeight, endinc;
+ PixelType endmask, *psrcT;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ if (pGC->fillStyle == FillTiled)
+ {
+ pTile = pGC->tile.pixmap;
+ tlwidth = pTile->devKind / PGSZB;
+ rop = pGC->alu;
+ }
+ else
+ {
+ pTile = pGC->stipple;
+ tlwidth = pTile->devKind / PGSZB;
+ rop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->ropOpStip;
+ }
+
+ xSrc = pDrawable->x;
+ ySrc = pDrawable->y;
+
+ mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
+
+ tileWidth = pTile->drawable.width;
+ tileHeight = pTile->drawable.height;
+
+ /* this replaces rotating the tile. Instead we just adjust the offset
+ * at which we start grabbing bits from the tile.
+ * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
+ * so that iline and rem always stay within the tile bounds.
+ */
+ xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;
+ ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;
+
+ while (n--)
+ {
+ iline = (ppt->y - ySrc) % tileHeight;
+ pdst = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
+ psrcT = (PixelType *) pTile->devPrivate.ptr + (iline * tlwidth);
+ x = ppt->x;
+
+ if (*pwidth)
+ {
+ width = *pwidth;
+ while(width > 0)
+ {
+ psrc = psrcT;
+ w = min(tileWidth, width);
+ if((rem = (x - xSrc) % tileWidth) != 0)
+ {
+ /* if we're in the middle of the tile, get
+ as many bits as will finish the span, or
+ as many as will get to the left edge of the tile,
+ or a longword worth, starting at the appropriate
+ offset in the tile.
+ */
+ w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
+ endinc = rem / BITMAP_SCANLINE_PAD;
+ getandputrop((psrc+endinc), (rem&PIM), (x & PIM), w, pdst, rop);
+ if((x & PIM) + w >= PPW)
+ pdst++;
+ }
+ else if(((x & PIM) + w) < PPW)
+ {
+ /* doing < PPW bits is easy, and worth special-casing */
+ putbitsrop(*psrc, x & PIM, w, pdst, rop);
+ }
+ else
+ {
+ /* start at the left edge of the tile,
+ and put down as much as we can
+ */
+ maskbits(x, w, startmask, endmask, nlMiddle);
+
+ if (startmask)
+ nstart = PPW - (x & PIM);
+ else
+ nstart = 0;
+ if (endmask)
+ nend = (x + w) & PIM;
+ else
+ nend = 0;
+
+ srcStartOver = nstart > PLST;
+
+ if(startmask)
+ {
+ putbitsrop(*psrc, (x & PIM), nstart, pdst, rop);
+ pdst++;
+#if defined(__alpha__) || defined(__alpha)
+ /*
+ * XXX workaround an egcs 1.1.2 code generation
+ * bug. This version might actually be faster.
+ */
+ psrc += srcStartOver;
+#else
+ if(srcStartOver)
+ psrc++;
+#endif
+ }
+
+ while(nlMiddle--)
+ {
+ getandputrop0(psrc, nstart, PPW, pdst, rop);
+ pdst++;
+ psrc++;
+ }
+ if(endmask)
+ {
+ getandputrop0(psrc, nstart, nend, pdst, rop);
+ }
+ }
+ x += w;
+ width -= w;
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
+
+
+/* Fill spans with stipples that aren't PPW bits wide */
+void
+mfbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ /* next three parameters are post-clip */
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ int iline; /* first line of tile to use */
+ PixelType *addrlBase; /* pointer to start of bitmap */
+ int nlwidth; /* width in longwords of bitmap */
+ register PixelType *pdst; /* pointer to current word in bitmap */
+ register PixelType *psrc; /* pointer to current word in tile */
+ register int nlMiddle;
+ register int rop, nstart;
+ PixelType startmask;
+ PixmapPtr pTile; /* pointer to tile we want to fill with */
+ int w, width, x, xSrc, ySrc, srcStartOver, nend;
+ PixelType endmask, *psrcT;
+ int tlwidth, rem, tileWidth, endinc;
+ int tileHeight;
+ int *pwidthFree; /* copies of the pointers to free */
+ DDXPointPtr pptFree;
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ n = nInit * miFindMaxBand(pGC->pCompositeClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ pTile = pGC->stipple;
+ rop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop;
+ tlwidth = pTile->devKind / PGSZB;
+ xSrc = pDrawable->x;
+ ySrc = pDrawable->y;
+ mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
+
+ tileWidth = pTile->drawable.width;
+ tileHeight = pTile->drawable.height;
+
+ /* this replaces rotating the stipple. Instead, we just adjust the offset
+ * at which we start grabbing bits from the stipple.
+ * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
+ * so that iline and rem always stay within the tile bounds.
+ */
+ xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;
+ ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;
+ while (n--)
+ {
+ iline = (ppt->y - ySrc) % tileHeight;
+ pdst = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth);
+ psrcT = (PixelType *) pTile->devPrivate.ptr + (iline * tlwidth);
+ x = ppt->x;
+
+ if (*pwidth)
+ {
+ width = *pwidth;
+ while(width > 0)
+ {
+ psrc = psrcT;
+ w = min(tileWidth, width);
+ if((rem = (x - xSrc) % tileWidth) != 0)
+ {
+ /* if we're in the middle of the tile, get
+ as many bits as will finish the span, or
+ as many as will get to the left edge of the tile,
+ or a longword worth, starting at the appropriate
+ offset in the tile.
+ */
+ w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
+ endinc = rem / BITMAP_SCANLINE_PAD;
+ getandputrrop((psrc + endinc), (rem & PIM), (x & PIM),
+ w, pdst, rop)
+ if((x & PIM) + w >= PPW)
+ pdst++;
+ }
+
+ else if(((x & PIM) + w) < PPW)
+ {
+ /* doing < PPW bits is easy, and worth special-casing */
+ putbitsrrop(*psrc, x & PIM, w, pdst, rop);
+ }
+ else
+ {
+ /* start at the left edge of the tile,
+ and put down as much as we can
+ */
+ maskbits(x, w, startmask, endmask, nlMiddle);
+
+ if (startmask)
+ nstart = PPW - (x & PIM);
+ else
+ nstart = 0;
+ if (endmask)
+ nend = (x + w) & PIM;
+ else
+ nend = 0;
+
+ srcStartOver = nstart > PLST;
+
+ if(startmask)
+ {
+ putbitsrrop(*psrc, (x & PIM), nstart, pdst, rop);
+ pdst++;
+ if(srcStartOver)
+ psrc++;
+ }
+
+ while(nlMiddle--)
+ {
+ getandputrrop0(psrc, nstart, PPW, pdst, rop);
+ pdst++;
+ psrc++;
+ }
+ if(endmask)
+ {
+ getandputrrop0(psrc, nstart, nend, pdst, rop);
+ }
+ }
+ x += w;
+ width -= w;
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbfont.c b/nx-X11/programs/Xserver/mfb/mfbfont.c
new file mode 100644
index 000000000..3798cd22b
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbfont.c
@@ -0,0 +1,88 @@
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*/
+/* $Xorg: mfbfont.c,v 1.4 2001/02/09 02:05:18 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "mfb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "scrnintstr.h"
+
+/*ARGSUSED*/
+Bool
+mfbRealizeFont( pscr, pFont)
+ ScreenPtr pscr;
+ FontPtr pFont;
+{
+ return (TRUE);
+}
+
+mfbRealizeFontProc *
+mfbRealizeFontWeak(void)
+{
+ return mfbRealizeFont;
+}
+
+/*ARGSUSED*/
+Bool
+mfbUnrealizeFont( pscr, pFont)
+ ScreenPtr pscr;
+ FontPtr pFont;
+{
+ return (TRUE);
+}
+
+mfbUnrealizeFontProc *
+mfbUnrealizeFontWeak(void)
+{
+ return mfbUnrealizeFont;
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbgc.c b/nx-X11/programs/Xserver/mfb/mfbgc.c
new file mode 100644
index 000000000..c9ff20a45
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbgc.c
@@ -0,0 +1,1151 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbgc.c,v 1.9 2003/07/16 01:38:55 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbgc.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "mfb.h"
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "region.h"
+
+#include "mistruct.h"
+#include "migc.h"
+
+#include "maskbits.h"
+
+static GCFuncs mfbFuncs = {
+ mfbValidateGC,
+ miChangeGC,
+ miCopyGC,
+ miDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip
+};
+
+
+static GCOps whiteTECopyOps = {
+ mfbWhiteSolidFS,
+ mfbSetSpans,
+ mfbPutImage,
+ mfbCopyArea,
+ mfbCopyPlane,
+ mfbPolyPoint,
+ mfbLineSS,
+ mfbSegmentSS,
+ miPolyRectangle,
+ mfbZeroPolyArcSS,
+ mfbFillPolyWhite,
+ mfbPolyFillRect,
+ mfbPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ mfbTEGlyphBltWhite,
+ mfbPolyGlyphBltWhite,
+ mfbSolidPP
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+static GCOps blackTECopyOps = {
+ mfbBlackSolidFS,
+ mfbSetSpans,
+ mfbPutImage,
+ mfbCopyArea,
+ mfbCopyPlane,
+ mfbPolyPoint,
+ mfbLineSS,
+ mfbSegmentSS,
+ miPolyRectangle,
+ mfbZeroPolyArcSS,
+ mfbFillPolyBlack,
+ mfbPolyFillRect,
+ mfbPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ mfbTEGlyphBltBlack,
+ mfbPolyGlyphBltBlack,
+ mfbSolidPP
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+static GCOps whiteTEInvertOps = {
+ mfbInvertSolidFS,
+ mfbSetSpans,
+ mfbPutImage,
+ miCopyArea,
+ miCopyPlane,
+ mfbPolyPoint,
+ mfbLineSS,
+ mfbSegmentSS,
+ miPolyRectangle,
+ miZeroPolyArc,
+ mfbFillPolyInvert,
+ mfbPolyFillRect,
+ mfbPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ mfbTEGlyphBltWhite,
+ mfbPolyGlyphBltInvert,
+ mfbSolidPP
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+static GCOps blackTEInvertOps = {
+ mfbInvertSolidFS,
+ mfbSetSpans,
+ mfbPutImage,
+ mfbCopyArea,
+ mfbCopyPlane,
+ mfbPolyPoint,
+ mfbLineSS,
+ mfbSegmentSS,
+ miPolyRectangle,
+ miZeroPolyArc,
+ mfbFillPolyInvert,
+ mfbPolyFillRect,
+ mfbPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ mfbTEGlyphBltBlack,
+ mfbPolyGlyphBltInvert,
+ mfbSolidPP
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+static GCOps whiteCopyOps = {
+ mfbWhiteSolidFS,
+ mfbSetSpans,
+ mfbPutImage,
+ mfbCopyArea,
+ mfbCopyPlane,
+ mfbPolyPoint,
+ mfbLineSS,
+ mfbSegmentSS,
+ miPolyRectangle,
+ mfbZeroPolyArcSS,
+ mfbFillPolyWhite,
+ mfbPolyFillRect,
+ mfbPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ mfbImageGlyphBltWhite,
+ mfbPolyGlyphBltWhite,
+ mfbSolidPP
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+static GCOps blackCopyOps = {
+ mfbBlackSolidFS,
+ mfbSetSpans,
+ mfbPutImage,
+ mfbCopyArea,
+ mfbCopyPlane,
+ mfbPolyPoint,
+ mfbLineSS,
+ mfbSegmentSS,
+ miPolyRectangle,
+ mfbZeroPolyArcSS,
+ mfbFillPolyBlack,
+ mfbPolyFillRect,
+ mfbPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ mfbImageGlyphBltBlack,
+ mfbPolyGlyphBltBlack,
+ mfbSolidPP
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+static GCOps whiteInvertOps = {
+ mfbInvertSolidFS,
+ mfbSetSpans,
+ mfbPutImage,
+ mfbCopyArea,
+ mfbCopyPlane,
+ mfbPolyPoint,
+ mfbLineSS,
+ mfbSegmentSS,
+ miPolyRectangle,
+ miZeroPolyArc,
+ mfbFillPolyInvert,
+ mfbPolyFillRect,
+ mfbPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ mfbImageGlyphBltWhite,
+ mfbPolyGlyphBltInvert,
+ mfbSolidPP
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+static GCOps blackInvertOps = {
+ mfbInvertSolidFS,
+ mfbSetSpans,
+ mfbPutImage,
+ mfbCopyArea,
+ mfbCopyPlane,
+ mfbPolyPoint,
+ mfbLineSS,
+ mfbSegmentSS,
+ miPolyRectangle,
+ miZeroPolyArc,
+ mfbFillPolyInvert,
+ mfbPolyFillRect,
+ mfbPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ mfbImageGlyphBltBlack,
+ mfbPolyGlyphBltInvert,
+ mfbSolidPP
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+static GCOps whiteWhiteCopyOps = {
+ mfbWhiteSolidFS,
+ mfbSetSpans,
+ mfbPutImage,
+ mfbCopyArea,
+ mfbCopyPlane,
+ mfbPolyPoint,
+ mfbLineSS,
+ mfbSegmentSS,
+ miPolyRectangle,
+ mfbZeroPolyArcSS,
+ mfbFillPolyWhite,
+ mfbPolyFillRect,
+ mfbPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ miImageGlyphBlt,
+ mfbPolyGlyphBltWhite,
+ mfbSolidPP
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+static GCOps blackBlackCopyOps = {
+ mfbBlackSolidFS,
+ mfbSetSpans,
+ mfbPutImage,
+ mfbCopyArea,
+ mfbCopyPlane,
+ mfbPolyPoint,
+ mfbLineSS,
+ mfbSegmentSS,
+ miPolyRectangle,
+ mfbZeroPolyArcSS,
+ mfbFillPolyBlack,
+ mfbPolyFillRect,
+ mfbPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ miImageGlyphBlt,
+ mfbPolyGlyphBltBlack,
+ mfbSolidPP
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+static GCOps fgEqBgInvertOps = {
+ mfbInvertSolidFS,
+ mfbSetSpans,
+ mfbPutImage,
+ mfbCopyArea,
+ mfbCopyPlane,
+ mfbPolyPoint,
+ mfbLineSS,
+ mfbSegmentSS,
+ miPolyRectangle,
+ miZeroPolyArc,
+ mfbFillPolyInvert,
+ mfbPolyFillRect,
+ mfbPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ miImageGlyphBlt,
+ mfbPolyGlyphBltInvert,
+ mfbSolidPP
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+
+struct commonOps {
+ int fg, bg;
+ int rrop;
+ int terminalFont;
+ GCOps *ops;
+ void (*fillArea)(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*nop*/);
+};
+
+static struct commonOps mfbCommonOps[] = {
+ { 1, 0, RROP_WHITE, 1, &whiteTECopyOps, mfbSolidWhiteArea },
+ { 0, 1, RROP_BLACK, 1, &blackTECopyOps, mfbSolidBlackArea },
+ { 1, 0, RROP_INVERT, 1, &whiteTEInvertOps, mfbSolidInvertArea },
+ { 0, 1, RROP_INVERT, 1, &blackTEInvertOps, mfbSolidInvertArea },
+ { 1, 0, RROP_WHITE, 0, &whiteCopyOps, mfbSolidWhiteArea },
+ { 0, 1, RROP_BLACK, 0, &blackCopyOps, mfbSolidBlackArea },
+ { 1, 0, RROP_INVERT, 0, &whiteInvertOps, mfbSolidInvertArea },
+ { 0, 1, RROP_INVERT, 0, &blackInvertOps, mfbSolidInvertArea },
+ { 1, 1, RROP_WHITE, 0, &whiteWhiteCopyOps, mfbSolidWhiteArea },
+ { 0, 0, RROP_BLACK, 0, &blackBlackCopyOps, mfbSolidBlackArea },
+ { 1, 1, RROP_INVERT, 0, &fgEqBgInvertOps, mfbSolidInvertArea },
+ { 0, 0, RROP_INVERT, 0, &fgEqBgInvertOps, mfbSolidInvertArea },
+};
+
+#define numberCommonOps (sizeof (mfbCommonOps) / sizeof (mfbCommonOps[0]))
+
+static GCOps *
+matchCommon (
+ GCPtr pGC)
+{
+ int i;
+ struct commonOps *cop;
+ mfbPrivGC *priv;
+
+ if (pGC->lineWidth != 0)
+ return 0;
+ if (pGC->lineStyle != LineSolid)
+ return 0;
+ if (pGC->fillStyle != FillSolid)
+ return 0;
+ if (!pGC->font ||
+ FONTMAXBOUNDS(pGC->font,rightSideBearing) -
+ FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 ||
+ FONTMINBOUNDS(pGC->font,characterWidth) < 0)
+ return 0;
+ priv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr;
+ for (i = 0; i < numberCommonOps; i++) {
+ cop = &mfbCommonOps[i];
+ if ((pGC->fgPixel & 1) != cop->fg)
+ continue;
+ if ((pGC->bgPixel & 1) != cop->bg)
+ continue;
+ if (priv->rop != cop->rrop)
+ continue;
+ if (cop->terminalFont && !TERMINALFONT(pGC->font))
+ continue;
+ priv->FillArea = cop->fillArea;
+ return cop->ops;
+ }
+ return 0;
+}
+
+
+Bool
+mfbCreateGC(pGC)
+ register GCPtr pGC;
+{
+ mfbPrivGC *pPriv;
+
+ pGC->clientClip = NULL;
+ pGC->clientClipType = CT_NONE;
+
+ /* some of the output primitives aren't really necessary, since
+ they will be filled in ValidateGC because of dix/CreateGC()
+ setting all the change bits. Others are necessary because although
+ they depend on being a monochrome frame buffer, they don't change
+ */
+
+ pGC->ops = &whiteCopyOps;
+ pGC->funcs = &mfbFuncs;
+
+ /* mfb wants to translate before scan convesion */
+ pGC->miTranslate = 1;
+
+ pPriv = (mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr);
+ pPriv->rop = mfbReduceRop(pGC->alu, pGC->fgPixel);
+ pGC->fExpose = TRUE;
+ pGC->pRotatedPixmap = NullPixmap;
+ pGC->freeCompClip = FALSE;
+ pPriv->FillArea = mfbSolidInvertArea;
+ return TRUE;
+}
+
+/* some noop functions */
+static void
+mfbPolyGlyphBltNoop(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr * ppci,
+ pointer pglyphBase)
+{
+ /* this is a no-op function */
+}
+
+static void
+mfbNoopFS(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nInit,
+ DDXPointPtr pptInit,
+ int * pwidthInit,
+ int fSorted)
+{
+ /* this is a no-op function */
+}
+
+static void
+mfbFillPolyNoop(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int count,
+ DDXPointPtr ptsIn)
+{
+ /* this is a no-op function */
+}
+
+
+/* Clipping conventions
+ if the drawable is a window
+ CT_REGION ==> pCompositeClip really is the composite
+ CT_other ==> pCompositeClip is the window clip region
+ if the drawable is a pixmap
+ CT_REGION ==> pCompositeClip is the translated client region
+ clipped to the pixmap boundary
+ CT_other ==> pCompositeClip is the pixmap bounding box
+*/
+
+/*ARGSUSED*/
+void
+mfbValidateGC(pGC, changes, pDrawable)
+ register GCPtr pGC;
+ unsigned long changes;
+ DrawablePtr pDrawable;
+{
+ register mfbPrivGCPtr devPriv;
+ int mask; /* stateChanges */
+ int index; /* used for stepping through bitfields */
+ int xrot, yrot; /* rotations for tile and stipple pattern */
+ int rrop; /* reduced rasterop */
+ /* flags for changing the proc vector
+ and updating things in devPriv
+ */
+ int new_rotate, new_rrop, new_line, new_text, new_fill;
+ DDXPointRec oldOrg; /* origin of thing GC was last used with */
+
+ oldOrg = pGC->lastWinOrg;
+
+ pGC->lastWinOrg.x = pDrawable->x;
+ pGC->lastWinOrg.y = pDrawable->y;
+
+ /* we need to re-rotate the tile if the previous window/pixmap
+ origin (oldOrg) differs from the new window/pixmap origin
+ (pGC->lastWinOrg)
+ */
+ new_rotate = (oldOrg.x != pGC->lastWinOrg.x) ||
+ (oldOrg.y != pGC->lastWinOrg.y);
+
+ devPriv = ((mfbPrivGCPtr) (pGC->devPrivates[mfbGCPrivateIndex].ptr));
+
+ /*
+ if the client clip is different or moved OR
+ the subwindowMode has changed OR
+ the window's clip has changed since the last validation
+ we need to recompute the composite clip
+ */
+ if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
+ (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
+ )
+ {
+ miComputeCompositeClip(pGC, pDrawable);
+ }
+
+ new_rrop = FALSE;
+ new_line = FALSE;
+ new_text = FALSE;
+ new_fill = FALSE;
+
+ mask = changes;
+ while (mask)
+ {
+ index = lowbit (mask);
+ mask &= ~index;
+
+ /* this switch acculmulates a list of which procedures
+ might have to change due to changes in the GC. in
+ some cases (e.g. changing one 16 bit tile for another)
+ we might not really need a change, but the code is
+ being paranoid.
+ this sort of batching wins if, for example, the alu
+ and the font have been changed, or any other pair
+ of items that both change the same thing.
+ */
+ switch (index)
+ {
+ case GCFunction:
+ case GCForeground:
+ new_rrop = TRUE;
+ break;
+ case GCPlaneMask:
+ break;
+ case GCBackground:
+ new_rrop = TRUE; /* for opaque stipples */
+ break;
+ case GCLineStyle:
+ case GCLineWidth:
+ case GCJoinStyle:
+ new_line = TRUE;
+ break;
+ case GCCapStyle:
+ break;
+ case GCFillStyle:
+ new_fill = TRUE;
+ break;
+ case GCFillRule:
+ break;
+ case GCTile:
+ if(pGC->tileIsPixel)
+ break;
+ new_rotate = TRUE;
+ new_fill = TRUE;
+ break;
+
+ case GCStipple:
+ if(pGC->stipple == (PixmapPtr)NULL)
+ break;
+ new_rotate = TRUE;
+ new_fill = TRUE;
+ break;
+
+ case GCTileStipXOrigin:
+ new_rotate = TRUE;
+ break;
+
+ case GCTileStipYOrigin:
+ new_rotate = TRUE;
+ break;
+
+ case GCFont:
+ new_text = TRUE;
+ break;
+ case GCSubwindowMode:
+ break;
+ case GCGraphicsExposures:
+ break;
+ case GCClipXOrigin:
+ break;
+ case GCClipYOrigin:
+ break;
+ case GCClipMask:
+ break;
+ case GCDashOffset:
+ break;
+ case GCDashList:
+ break;
+ case GCArcMode:
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* deal with the changes we've collected .
+ new_rrop must be done first because subsequent things
+ depend on it.
+ */
+
+ if(new_rotate || new_fill)
+ {
+ Bool new_pix = FALSE;
+
+ /* figure out how much to rotate */
+ xrot = pGC->patOrg.x;
+ yrot = pGC->patOrg.y;
+ xrot += pDrawable->x;
+ yrot += pDrawable->y;
+
+ switch (pGC->fillStyle)
+ {
+ case FillTiled:
+ /* copy current tile and stipple */
+ if (!pGC->tileIsPixel && (pGC->tile.pixmap->drawable.width <= PPW) &&
+ !(pGC->tile.pixmap->drawable.width & (pGC->tile.pixmap->drawable.width - 1)))
+ {
+ mfbCopyRotatePixmap(pGC->tile.pixmap,
+ &pGC->pRotatedPixmap, xrot, yrot);
+ new_pix = TRUE;
+ }
+ break;
+ case FillStippled:
+ case FillOpaqueStippled:
+ if (pGC->stipple && (pGC->stipple->drawable.width <= PPW) &&
+ !(pGC->stipple->drawable.width & (pGC->stipple->drawable.width - 1)))
+ {
+ mfbCopyRotatePixmap(pGC->stipple,
+ &pGC->pRotatedPixmap, xrot, yrot);
+ new_pix = TRUE;
+ }
+ }
+ /* destroy any previously rotated tile or stipple */
+ if (!new_pix && pGC->pRotatedPixmap)
+ {
+ (*pDrawable->pScreen->DestroyPixmap)(pGC->pRotatedPixmap);
+ pGC->pRotatedPixmap = (PixmapPtr)NULL;
+ }
+ }
+
+ /*
+ * duck out here when the GC is unchanged
+ */
+
+ if (!changes)
+ return;
+
+ if (new_rrop || new_fill)
+ {
+ rrop = mfbReduceRop(pGC->alu, pGC->fgPixel);
+ devPriv->rop = rrop;
+ new_fill = TRUE;
+ /* FillArea raster op is GC's for tile filling,
+ and the reduced rop for solid and stipple
+ */
+ if (pGC->fillStyle == FillTiled)
+ devPriv->ropFillArea = pGC->alu;
+ else
+ devPriv->ropFillArea = rrop;
+
+ /* opaque stipples:
+ fg bg ropOpStip fill style
+ 1 0 alu tile
+ 0 1 inverseAlu tile
+ 1 1 rrop(fg, alu) solid
+ 0 0 rrop(fg, alu) solid
+ Note that rrop(fg, alu) == mfbPrivGC.rop, so we don't really need to
+ compute it.
+ */
+ if (pGC->fillStyle == FillOpaqueStippled)
+ {
+ if ((pGC->fgPixel & 1) != (pGC->bgPixel & 1))
+ {
+ if (pGC->fgPixel & 1)
+ devPriv->ropOpStip = pGC->alu;
+ else
+ devPriv->ropOpStip = InverseAlu[pGC->alu];
+ }
+ else
+ devPriv->ropOpStip = rrop;
+ devPriv->ropFillArea = devPriv->ropOpStip;
+ }
+ }
+ else
+ rrop = devPriv->rop;
+
+ if (new_line || new_fill || new_text)
+ {
+ GCOps *newops;
+
+ if ((newops = matchCommon (pGC)))
+ {
+ if (pGC->ops->devPrivate.val)
+ miDestroyGCOps (pGC->ops);
+ pGC->ops = newops;
+ new_line = new_fill = new_text = 0;
+ }
+ else
+ {
+ if (!pGC->ops->devPrivate.val)
+ {
+ pGC->ops = miCreateGCOps (pGC->ops);
+ pGC->ops->devPrivate.val = 1;
+ }
+ }
+ }
+
+ if (new_line || new_fill)
+ {
+ if (pGC->lineWidth == 0)
+ {
+ if ((pGC->lineStyle == LineSolid) && (pGC->fillStyle == FillSolid)
+ && ((rrop == RROP_WHITE) || (rrop == RROP_BLACK)))
+ pGC->ops->PolyArc = mfbZeroPolyArcSS;
+ else
+ pGC->ops->PolyArc = miZeroPolyArc;
+ }
+ else
+ pGC->ops->PolyArc = miPolyArc;
+ if (pGC->lineStyle == LineSolid)
+ {
+ if(pGC->lineWidth == 0)
+ {
+ if (pGC->fillStyle == FillSolid)
+ {
+ pGC->ops->PolySegment = mfbSegmentSS;
+ pGC->ops->Polylines = mfbLineSS;
+ }
+ else
+ {
+ pGC->ops->PolySegment = miPolySegment;
+ pGC->ops->Polylines = miZeroLine;
+ }
+ }
+ else
+ {
+ pGC->ops->PolySegment = miPolySegment;
+ pGC->ops->Polylines = miWideLine;
+ }
+ }
+ else
+ {
+ if(pGC->lineWidth == 0 && pGC->fillStyle == FillSolid)
+ {
+ pGC->ops->Polylines = mfbLineSD;
+ pGC->ops->PolySegment = mfbSegmentSD;
+ }
+ else
+ {
+ pGC->ops->Polylines = miWideDash;
+ pGC->ops->PolySegment = miPolySegment;
+ }
+ }
+ }
+
+ if (new_text || new_fill)
+ {
+ if ((pGC->font) &&
+ (FONTMAXBOUNDS(pGC->font,rightSideBearing) -
+ FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 ||
+ FONTMINBOUNDS(pGC->font,characterWidth) < 0))
+ {
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
+ }
+ else
+ {
+ /* special case ImageGlyphBlt for terminal emulator fonts */
+
+
+ if ((pGC->font) &&
+ TERMINALFONT(pGC->font) &&
+ ((pGC->fgPixel & 1) != (pGC->bgPixel & 1)))
+ {
+ /* pcc bug makes this not compile...
+ pGC->ops->ImageGlyphBlt = (pGC->fgPixel & 1) ? mfbTEGlyphBltWhite :
+ mfbTEGlyphBltBlack;
+ */
+ if (pGC->fgPixel & 1)
+ pGC->ops->ImageGlyphBlt = mfbTEGlyphBltWhite;
+ else
+ pGC->ops->ImageGlyphBlt = mfbTEGlyphBltBlack;
+ }
+ else
+
+
+ {
+ if (pGC->fgPixel & 1)
+ pGC->ops->ImageGlyphBlt = mfbImageGlyphBltWhite;
+ else
+ pGC->ops->ImageGlyphBlt = mfbImageGlyphBltBlack;
+ }
+
+ /* now do PolyGlyphBlt */
+ if (pGC->fillStyle == FillSolid ||
+ (pGC->fillStyle == FillOpaqueStippled &&
+ (pGC->fgPixel & 1) == (pGC->bgPixel & 1)
+ )
+ )
+ {
+ if (rrop == RROP_WHITE)
+ pGC->ops->PolyGlyphBlt = mfbPolyGlyphBltWhite;
+ else if (rrop == RROP_BLACK)
+ pGC->ops->PolyGlyphBlt = mfbPolyGlyphBltBlack;
+ else if (rrop == RROP_INVERT)
+ pGC->ops->PolyGlyphBlt = mfbPolyGlyphBltInvert;
+ else
+ pGC->ops->PolyGlyphBlt = mfbPolyGlyphBltNoop;
+ }
+ else
+ {
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ }
+ }
+ }
+
+ if (new_fill)
+
+
+ {
+ /* install a suitable fillspans and pushpixels */
+ pGC->ops->PushPixels = mfbPushPixels;
+ pGC->ops->FillPolygon = miFillPolygon;
+ if ((pGC->fillStyle == FillSolid) ||
+ ((pGC->fillStyle == FillOpaqueStippled) &&
+ ((pGC->fgPixel & 1) == (pGC->bgPixel & 1))))
+ {
+ pGC->ops->PushPixels = mfbSolidPP;
+ switch(devPriv->rop)
+ {
+ case RROP_WHITE:
+ pGC->ops->FillSpans = mfbWhiteSolidFS;
+ pGC->ops->FillPolygon = mfbFillPolyWhite;
+ break;
+ case RROP_BLACK:
+ pGC->ops->FillSpans = mfbBlackSolidFS;
+ pGC->ops->FillPolygon = mfbFillPolyBlack;
+ break;
+ case RROP_INVERT:
+ pGC->ops->FillSpans = mfbInvertSolidFS;
+ pGC->ops->FillPolygon = mfbFillPolyInvert;
+ break;
+ case RROP_NOP:
+ pGC->ops->FillSpans = mfbNoopFS;
+ pGC->ops->FillPolygon = mfbFillPolyNoop;
+ break;
+ }
+ }
+ /* beyond this point, opaqueStippled ==> fg != bg */
+ else if (((pGC->fillStyle == FillTiled) ||
+ (pGC->fillStyle == FillOpaqueStippled)) &&
+ !pGC->pRotatedPixmap)
+ {
+ pGC->ops->FillSpans = mfbUnnaturalTileFS;
+ }
+ else if ((pGC->fillStyle == FillStippled) && !pGC->pRotatedPixmap)
+ {
+ pGC->ops->FillSpans = mfbUnnaturalStippleFS;
+ }
+ else if (pGC->fillStyle == FillStippled)
+ {
+ switch(devPriv->rop)
+ {
+ case RROP_WHITE:
+ pGC->ops->FillSpans = mfbWhiteStippleFS;
+ break;
+ case RROP_BLACK:
+ pGC->ops->FillSpans = mfbBlackStippleFS;
+ break;
+ case RROP_INVERT:
+ pGC->ops->FillSpans = mfbInvertStippleFS;
+ break;
+ case RROP_NOP:
+ pGC->ops->FillSpans = mfbNoopFS;
+ break;
+ }
+ }
+ else /* overload tiles to do parti-colored opaque stipples */
+ {
+ pGC->ops->FillSpans = mfbTileFS;
+ }
+ if (pGC->fillStyle == FillSolid)
+ pGC->ops->PolyFillArc = mfbPolyFillArcSolid;
+ else
+ pGC->ops->PolyFillArc = miPolyFillArc;
+ /* the rectangle code doesn't deal with opaque stipples that
+ are two colors -- we can fool it for fg==bg, though
+ */
+ if ((((pGC->fillStyle == FillTiled) ||
+ (pGC->fillStyle == FillStippled)) &&
+ !pGC->pRotatedPixmap) ||
+ ((pGC->fillStyle == FillOpaqueStippled) &&
+ ((pGC->fgPixel & 1) != (pGC->bgPixel & 1)))
+ )
+ {
+ pGC->ops->PolyFillRect = miPolyFillRect;
+ }
+ else /* deal with solids and natural stipples and tiles */
+ {
+ pGC->ops->PolyFillRect = mfbPolyFillRect;
+
+ if ((pGC->fillStyle == FillSolid) ||
+ ((pGC->fillStyle == FillOpaqueStippled) &&
+ ((pGC->fgPixel & 1) == (pGC->bgPixel & 1))))
+ {
+ switch(devPriv->rop)
+ {
+ case RROP_WHITE:
+ devPriv->FillArea = mfbSolidWhiteArea;
+ break;
+ case RROP_BLACK:
+ devPriv->FillArea = mfbSolidBlackArea;
+ break;
+ case RROP_INVERT:
+ devPriv->FillArea = mfbSolidInvertArea;
+ break;
+ case RROP_NOP:
+ devPriv->FillArea = (mfbFillAreaProcPtr)NoopDDA;
+ break;
+ }
+ }
+ else if (pGC->fillStyle == FillStippled)
+ {
+ switch(devPriv->rop)
+ {
+ case RROP_WHITE:
+ devPriv->FillArea = mfbStippleWhiteArea;
+ break;
+ case RROP_BLACK:
+ devPriv->FillArea = mfbStippleBlackArea;
+ break;
+ case RROP_INVERT:
+ devPriv->FillArea = mfbStippleInvertArea;
+ break;
+ case RROP_NOP:
+ devPriv->FillArea = (mfbFillAreaProcPtr)NoopDDA;
+ break;
+ }
+ }
+ else /* deal with tiles */
+ {
+ switch (pGC->alu)
+ {
+ case GXcopy:
+ devPriv->FillArea = mfbTileAreaPPWCopy;
+ break;
+ default:
+ devPriv->FillArea = mfbTileAreaPPWGeneral;
+ break;
+ }
+ }
+ } /* end of natural rectangles */
+ } /* end of new_fill */
+
+
+}
+
+/* table to map alu(src, dst) to alu(~src, dst) */
+int InverseAlu[16] = {
+ GXclear,
+ GXandInverted,
+ GXnor,
+ GXcopyInverted,
+ GXand,
+ GXnoop,
+ GXequiv,
+ GXorInverted,
+ GXandReverse,
+ GXxor,
+ GXinvert,
+ GXnand,
+ GXcopy,
+ GXor,
+ GXorReverse,
+ GXset
+};
+
+int mfbGetInverseAlu(i)
+ int i;
+{
+ return InverseAlu[i];
+}
+
+int
+mfbReduceRop(alu, src)
+ register int alu;
+ register Pixel src;
+{
+ int rop = 0;
+ if ((src & 1) == 0) /* src is black */
+ {
+ switch(alu)
+ {
+ case GXclear:
+ rop = RROP_BLACK;
+ break;
+ case GXand:
+ rop = RROP_BLACK;
+ break;
+ case GXandReverse:
+ rop = RROP_BLACK;
+ break;
+ case GXcopy:
+ rop = RROP_BLACK;
+ break;
+ case GXandInverted:
+ rop = RROP_NOP;
+ break;
+ case GXnoop:
+ rop = RROP_NOP;
+ break;
+ case GXxor:
+ rop = RROP_NOP;
+ break;
+ case GXor:
+ rop = RROP_NOP;
+ break;
+ case GXnor:
+ rop = RROP_INVERT;
+ break;
+ case GXequiv:
+ rop = RROP_INVERT;
+ break;
+ case GXinvert:
+ rop = RROP_INVERT;
+ break;
+ case GXorReverse:
+ rop = RROP_INVERT;
+ break;
+ case GXcopyInverted:
+ rop = RROP_WHITE;
+ break;
+ case GXorInverted:
+ rop = RROP_WHITE;
+ break;
+ case GXnand:
+ rop = RROP_WHITE;
+ break;
+ case GXset:
+ rop = RROP_WHITE;
+ break;
+ }
+ }
+ else /* src is white */
+ {
+ switch(alu)
+ {
+ case GXclear:
+ rop = RROP_BLACK;
+ break;
+ case GXand:
+ rop = RROP_NOP;
+ break;
+ case GXandReverse:
+ rop = RROP_INVERT;
+ break;
+ case GXcopy:
+ rop = RROP_WHITE;
+ break;
+ case GXandInverted:
+ rop = RROP_BLACK;
+ break;
+ case GXnoop:
+ rop = RROP_NOP;
+ break;
+ case GXxor:
+ rop = RROP_INVERT;
+ break;
+ case GXor:
+ rop = RROP_WHITE;
+ break;
+ case GXnor:
+ rop = RROP_BLACK;
+ break;
+ case GXequiv:
+ rop = RROP_NOP;
+ break;
+ case GXinvert:
+ rop = RROP_INVERT;
+ break;
+ case GXorReverse:
+ rop = RROP_WHITE;
+ break;
+ case GXcopyInverted:
+ rop = RROP_BLACK;
+ break;
+ case GXorInverted:
+ rop = RROP_NOP;
+ break;
+ case GXnand:
+ rop = RROP_INVERT;
+ break;
+ case GXset:
+ rop = RROP_WHITE;
+ break;
+ }
+ }
+ return rop;
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbgetsp.c b/nx-X11/programs/Xserver/mfb/mfbgetsp.c
new file mode 100644
index 000000000..c1017e177
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbgetsp.c
@@ -0,0 +1,159 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbgetsp.c,v 1.3tsi Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbgetsp.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "misc.h"
+#include "region.h"
+#include "gc.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "mfb.h"
+#include "maskbits.h"
+
+#include "servermd.h"
+
+/* GetSpans -- for each span, gets bits from drawable starting at ppt[i]
+ * and continuing for pwidth[i] bits
+ * Each scanline returned will be server scanline padded, i.e., it will come
+ * out to an integral number of words.
+ */
+/*ARGSUSED*/
+void
+mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pchardstStart)
+ DrawablePtr pDrawable; /* drawable from which to get bits */
+ int wMax; /* largest value of all *pwidths */
+ register DDXPointPtr ppt; /* points to start copying from */
+ int *pwidth; /* list of number of bits to copy */
+ int nspans; /* number of scanlines to copy */
+ char *pchardstStart; /* where to put the bits */
+{
+ PixelType *pdstStart = (PixelType *)(pointer)pchardstStart;
+ register PixelType *pdst; /* where to put the bits */
+ register PixelType *psrc; /* where to get the bits */
+ register PixelType tmpSrc; /* scratch buffer for bits */
+ PixelType *psrcBase; /* start of src bitmap */
+ int widthSrc; /* width of pixmap in bytes */
+ register DDXPointPtr pptLast; /* one past last point to get */
+ int xEnd; /* last pixel to copy from */
+ register int nstart;
+ int nend = 0;
+ int srcStartOver;
+ PixelType startmask, endmask;
+ unsigned int srcBit;
+ int nlMiddle, nl;
+ int w;
+
+ pptLast = ppt + nspans;
+
+ mfbGetPixelWidthAndPointer(pDrawable, widthSrc, psrcBase);
+ pdst = pdstStart;
+
+ while(ppt < pptLast)
+ {
+ /* XXX should this really be << PWSH, or * 8, or * PGSZB? */
+ xEnd = min(ppt->x + *pwidth, widthSrc << PWSH);
+ pwidth++;
+ psrc = mfbScanline(psrcBase, ppt->x, ppt->y, widthSrc);
+ w = xEnd - ppt->x;
+ srcBit = ppt->x & PIM;
+
+ if (srcBit + w <= PPW)
+ {
+ getandputbits0(psrc, srcBit, w, pdst);
+ pdst++;
+ }
+ else
+ {
+
+ maskbits(ppt->x, w, startmask, endmask, nlMiddle);
+ if (startmask)
+ nstart = PPW - srcBit;
+ else
+ nstart = 0;
+ if (endmask)
+ nend = xEnd & PIM;
+ srcStartOver = srcBit + nstart > PLST;
+ if (startmask)
+ {
+ getandputbits0(psrc, srcBit, nstart, pdst);
+ if(srcStartOver)
+ psrc++;
+ }
+ nl = nlMiddle;
+#ifdef FASTPUTBITS
+ Duff(nl, putbits(*psrc, nstart, PPW, pdst); psrc++; pdst++;);
+#else
+ while (nl--)
+ {
+ tmpSrc = *psrc;
+ putbits(tmpSrc, nstart, PPW, pdst);
+ psrc++;
+ pdst++;
+ }
+#endif
+ if (endmask)
+ {
+ putbits(*psrc, nstart, nend, pdst);
+ if(nstart + nend > PPW)
+ pdst++;
+ }
+ if (startmask || endmask)
+ pdst++;
+ }
+ ppt++;
+ }
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbhrzvert.c b/nx-X11/programs/Xserver/mfb/mfbhrzvert.c
new file mode 100644
index 000000000..9a9d20dac
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbhrzvert.c
@@ -0,0 +1,179 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbhrzvert.c,v 1.4 2001/01/17 22:37:03 dawes Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbhrzvert.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "gc.h"
+#include "window.h"
+#include "pixmap.h"
+#include "region.h"
+
+#include "mfb.h"
+#include "maskbits.h"
+
+/* horizontal solid line
+ abs(len) > 1
+*/
+void
+mfbHorzS(rop, addrl, nlwidth, x1, y1, len)
+int rop; /* a reduced rasterop */
+register PixelType *addrl; /* pointer to base of bitmap */
+register int nlwidth; /* width in longwords of bitmap */
+int x1; /* initial point */
+int y1;
+int len; /* length of line */
+{
+ register PixelType startmask;
+ register PixelType endmask;
+ register int nlmiddle;
+
+
+ /* force the line to go left to right
+ but don't draw the last point
+ */
+ if (len < 0)
+ {
+ x1 += len;
+ x1 += 1;
+ len = -len;
+ }
+
+ addrl = mfbScanline(addrl, x1, y1, nlwidth);
+
+ /* all bits inside same longword */
+ if ( ((x1 & PIM) + len) < PPW)
+ {
+ maskpartialbits(x1, len, startmask);
+ if (rop == RROP_BLACK)
+ {
+ *addrl &= ~startmask;
+ }
+ else if (rop == RROP_WHITE)
+ {
+ *addrl |= startmask;
+ }
+ else if (rop == RROP_INVERT)
+ {
+ *addrl ^= startmask;
+ }
+ }
+ else
+ {
+ maskbits(x1, len, startmask, endmask, nlmiddle);
+ if (rop == RROP_BLACK)
+ {
+ if (startmask)
+ *addrl++ &= ~startmask;
+ Duff (nlmiddle, *addrl++ = 0x0);
+ if (endmask)
+ *addrl &= ~endmask;
+ }
+ else if (rop == RROP_WHITE)
+ {
+ if (startmask)
+ *addrl++ |= startmask;
+ Duff (nlmiddle, *addrl++ = ~0);
+ if (endmask)
+ *addrl |= endmask;
+ }
+ else if (rop == RROP_INVERT)
+ {
+ if (startmask)
+ *addrl++ ^= startmask;
+ Duff (nlmiddle, *addrl++ ^= ~0);
+ if (endmask)
+ *addrl ^= endmask;
+ }
+ }
+}
+
+/* vertical solid line
+ this uses do loops because pcc (Ultrix 1.2, bsd 4.2) generates
+ better code. sigh. we know that len will never be 0 or 1, so
+ it's OK to use it.
+*/
+
+void
+mfbVertS(rop, addrl, nlwidth, x1, y1, len)
+int rop; /* a reduced rasterop */
+register PixelType *addrl; /* pointer to base of bitmap */
+register int nlwidth; /* width in longwords of bitmap */
+int x1, y1; /* initial point */
+register int len; /* length of line */
+{
+ register PixelType bitmask;
+
+ addrl = mfbScanline(addrl, x1, y1, nlwidth);
+
+ if (len < 0)
+ {
+ nlwidth = -nlwidth;
+ len = -len;
+ }
+
+ if (rop == RROP_BLACK)
+ {
+ bitmask = rmask[x1 & PIM];
+ Duff(len, *addrl &= bitmask; mfbScanlineInc(addrl, nlwidth) );
+ }
+ else if (rop == RROP_WHITE)
+ {
+ bitmask = mask[x1 & PIM];
+ Duff(len, *addrl |= bitmask; mfbScanlineInc(addrl, nlwidth) );
+ }
+ else if (rop == RROP_INVERT)
+ {
+ bitmask = mask[x1 & PIM];
+ Duff(len, *addrl ^= bitmask; mfbScanlineInc(addrl, nlwidth) );
+ }
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbimage.c b/nx-X11/programs/Xserver/mfb/mfbimage.c
new file mode 100644
index 000000000..299905701
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbimage.c
@@ -0,0 +1,177 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbimage.c,v 1.5 2001/01/17 22:37:03 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbimage.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "gcstruct.h"
+
+#include "mfb.h"
+#include "mi.h"
+#include <X11/Xmd.h>
+
+#include "maskbits.h"
+
+#include "servermd.h"
+
+/* Put and Get images on a monochrome frame buffer
+ *
+ * we do this by creating a temporary pixmap and making its
+ * pointer to bits point to the buffer read in from the client.
+ * this works because of the padding rules specified at startup
+ *
+ * Note that CopyArea must know how to copy a bitmap into the server-format
+ * temporary pixmap.
+ *
+ * For speed, mfbPutImage should allocate the temporary pixmap on the stack.
+ *
+ * even though an XYBitmap and an XYPixmap have the same
+ * format (for this device), PutImage has different semantics for the
+ * two. XYPixmap just does the copy; XYBitmap takes gc.fgPixel for
+ * a 1 bit, gc.bgPixel for a 0 bit, which we notice is exactly
+ * like CopyPlane.
+ *
+ * written by drewry, september 1986
+ */
+
+
+
+/*ARGSUSED*/
+void
+mfbPutImage(dst, pGC, depth, x, y, w, h, leftPad, format, pImage)
+ DrawablePtr dst;
+ GCPtr pGC;
+ int depth, x, y, w, h;
+ int leftPad;
+ int format;
+ char *pImage;
+{
+ PixmapPtr pPixmap;
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ /* 0 may confuse CreatePixmap, and will sometimes be
+ passed by the mi text code
+ */
+ if ((w == 0) || (h == 0))
+ return;
+
+ pPixmap = GetScratchPixmapHeader(dst->pScreen, w+leftPad, h, 1, 1,
+ BitmapBytePad(w+leftPad), (pointer)pImage);
+ if (!pPixmap)
+ return;
+
+ pGC->fExpose = FALSE;
+ if (format != XYBitmap)
+ (*pGC->ops->CopyArea)((DrawablePtr)pPixmap, dst, pGC, leftPad, 0,
+ w, h, x, y);
+ else
+ (*pGC->ops->CopyPlane)((DrawablePtr)pPixmap, dst, pGC, leftPad, 0,
+ w, h, x, y, 1);
+ pGC->fExpose = TRUE;
+ FreeScratchPixmapHeader(pPixmap);
+}
+
+
+/*
+ * pdstLine points to space allocated by caller, which he can do since
+ * he knows dimensions of the pixmap
+ * we can call mfbDoBitblt because the dispatcher has promised not to send us
+ * anything that would require going over the edge of the screen.
+ *
+ * XYPixmap and ZPixmap are the same for mfb.
+ * For any planemask with bit 0 == 0, just fill the dst with 0.
+ */
+/*ARGSUSED*/
+void
+mfbGetImage( pDrawable, sx, sy, w, h, format, planeMask, pdstLine)
+ DrawablePtr pDrawable;
+ int sx, sy, w, h;
+ unsigned int format;
+ unsigned long planeMask;
+ char *pdstLine;
+{
+ BoxRec box;
+ DDXPointRec ptSrc;
+ RegionRec rgnDst;
+
+ if (planeMask & 0x1)
+ {
+ ScreenPtr pScreen = pDrawable->pScreen;
+ PixmapPtr pPixmap;
+
+ pPixmap = GetScratchPixmapHeader(pScreen, w, h, /*depth*/ 1, /*bpp*/ 1,
+ BitmapBytePad(w), (pointer)pdstLine);
+ if (!pPixmap)
+ return;
+
+ ptSrc.x = sx + pDrawable->x;
+ ptSrc.y = sy + pDrawable->y;
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = w;
+ box.y2 = h;
+ REGION_INIT(pScreen, &rgnDst, &box, 1);
+ mfbDoBitblt(pDrawable, (DrawablePtr)pPixmap,
+ GXcopy, &rgnDst, &ptSrc);
+ REGION_UNINIT(pScreen, &rgnDst);
+ FreeScratchPixmapHeader(pPixmap);
+ }
+ else
+ {
+ bzero(pdstLine, BitmapBytePad(w) * h);
+ }
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbimggblt.c b/nx-X11/programs/Xserver/mfb/mfbimggblt.c
new file mode 100644
index 000000000..0c0d4140c
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbimggblt.c
@@ -0,0 +1,445 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbimggblt.c,v 3.5tsi Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbimggblt.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "mfb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "maskbits.h"
+
+/*
+ we should eventually special-case fixed-width fonts for ImageText.
+
+ this works for fonts with glyphs <= 32 bits wide.
+
+ the clipping calculations are done for worst-case fonts.
+we make no assumptions about the heights, widths, or bearings
+of the glyphs. if we knew that the glyphs are all the same height,
+we could clip the tops and bottoms per clipping box, rather
+than per character per clipping box. if we knew that the glyphs'
+left and right bearings were wlle-behaved, we could clip a single
+character at the start, output until the last unclipped
+character, and then clip the last one. this is all straightforward
+to determine based on max-bounds and min-bounds from the font.
+ there is some inefficiency introduced in the per-character
+clipping to make what's going on clearer.
+
+ (it is possible, for example, for a font to be defined in which the
+next-to-last character in a font would be clipped out, but the last
+one wouldn't. the code below deals with this.)
+
+ Image text looks at the bits in the glyph and the fg and bg in the
+GC. it paints a rectangle, as defined in the protocol dcoument,
+and the paints the characters.
+
+ to avoid source proliferation, this file is compiled
+three times:
+ MFBIMAGEGLYPHBLT OPEQ
+ mfbImageGlyphBltWhite |=
+ mfbImageGlyphBltBlack &=~
+
+ the register allocations for startmask and endmask may not
+be the right thing. are there two other deserving candidates?
+xoff, pdst, pglyph, and tmpSrc seem like the right things, though.
+*/
+
+void
+MFBIMAGEGLYPHBLT(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ ExtentInfoRec info; /* used by QueryGlyphExtents() */
+ BoxRec bbox; /* string's bounding box */
+ xRectangle backrect;/* backing rectangle to paint.
+ in the general case, NOT necessarily
+ the same as the string's bounding box
+ */
+
+ CharInfoPtr pci;
+ int xorg, yorg; /* origin of drawable in bitmap */
+ int widthDst; /* width of dst in longwords */
+
+ /* these keep track of the character origin */
+ PixelType *pdstBase;
+ /* points to longword with character origin */
+ int xchar; /* xorigin of char (mod 32) */
+
+ /* these are used for placing the glyph */
+ register int xoff; /* x offset of left edge of glyph (mod 32) */
+ register PixelType *pdst;
+ /* pointer to current longword in dst */
+
+ int w; /* width of glyph in bits */
+ int h; /* height of glyph */
+ int widthGlyph; /* width of glyph, in bytes */
+ register unsigned char *pglyph;
+ /* pointer to current row of glyph */
+
+ /* used for putting down glyph */
+ register PixelType tmpSrc;
+ /* for getting bits from glyph */
+ register PixelType startmask;
+ register PixelType endmask;
+
+ register int nFirst;/* bits of glyph in current longword */
+ mfbPrivGC *pPrivGC;
+ mfbFillAreaProcPtr oldFillArea;
+ /* we might temporarily usurp this
+ field in devPriv */
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ mfbGetPixelWidthAndPointer(pDrawable, widthDst, pdstBase);
+
+ QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info);
+
+ backrect.x = x;
+ backrect.y = y - FONTASCENT(pGC->font);
+ backrect.width = info.overallWidth;
+ backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+
+ x += xorg;
+ y += yorg;
+
+ bbox.x1 = x + info.overallLeft;
+ bbox.x2 = x + info.overallRight;
+ bbox.y1 = y - info.overallAscent;
+ bbox.y2 = y + info.overallDescent;
+
+ /* UNCLEAN CODE
+ we know the mfbPolyFillRect uses only two fields in
+ devPrivate[mfbGCPrivateIndex].ptr, one of which (ropFillArea) is
+ irrelevant for solid filling, so we just poke the FillArea
+ field. the GC is now in an inconsistent state, but we'll fix
+ it as soon as PolyFillRect returns. fortunately, the server
+ is single threaded.
+
+ NOTE:
+ if you are not using the standard mfbFillRectangle code, you
+ need to poke any fields in the GC the rectangle stuff need
+ (probably alu, fgPixel, and fillStyle) and in devPrivate[mfbGCPrivateIndex].ptr
+ (probably rop or ropFillArea.) You could just call ValidateGC,
+ but that is usually not a cheap thing to do.
+ */
+
+ pPrivGC = pGC->devPrivates[mfbGCPrivateIndex].ptr;
+ oldFillArea = pPrivGC->FillArea;
+
+ if (pGC->bgPixel & 1)
+ pPrivGC->FillArea = mfbSolidWhiteArea;
+ else
+ pPrivGC->FillArea = mfbSolidBlackArea;
+
+ mfbPolyFillRect(pDrawable, pGC, 1, &backrect);
+ pPrivGC->FillArea = oldFillArea;
+
+ /* the faint-hearted can open their eyes now */
+ switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox))
+ {
+ case rgnOUT:
+ break;
+ case rgnIN:
+ pdstBase = mfbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
+ xchar = x & PIM;
+
+ while(nglyph--)
+ {
+ pci = *ppci;
+ pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
+ h = pci->metrics.ascent + pci->metrics.descent;
+ widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
+
+ /* start at top scanline of glyph */
+ pdst = pdstBase;
+
+ /* find correct word in scanline and x offset within it
+ for left edge of glyph
+ */
+ xoff = xchar + pci->metrics.leftSideBearing;
+ if (xoff > PLST)
+ {
+ pdst++;
+ xoff &= PIM;
+ }
+ else if (xoff < 0)
+ {
+ xoff += PPW;
+ pdst--;
+ }
+
+ pdst = mfbScanlineDelta(pdst, -pci->metrics.ascent, widthDst);
+
+ if ((xoff + w) <= PPW)
+ {
+ /* glyph all in one longword */
+ maskpartialbits(xoff, w, startmask);
+ while (h--)
+ {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst OPEQ (SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ mfbScanlineInc(pdst, widthDst);
+ }
+ }
+ else
+ {
+ /* glyph crosses longword boundary */
+ maskPPWbits(xoff, w, startmask, endmask);
+ nFirst = PPW - xoff;
+ while (h--)
+ {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst OPEQ (SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) OPEQ (SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ mfbScanlineInc(pdst, widthDst);
+ }
+ } /* glyph crosses longwords boundary */
+
+ /* update character origin */
+ x += pci->metrics.characterWidth;
+ xchar += pci->metrics.characterWidth;
+ if (xchar > PLST)
+ {
+ xchar -= PPW;
+ pdstBase++;
+ }
+ else if (xchar < 0)
+ {
+ xchar += PPW;
+ pdstBase--;
+ }
+ ppci++;
+ } /* while nglyph-- */
+ break;
+ case rgnPART:
+ {
+ TEXTPOS *ppos;
+ int nbox;
+ BoxPtr pbox;
+ RegionPtr cclip;
+ int xpos; /* x position of char origin */
+ int i;
+ BoxRec clip;
+ int leftEdge, rightEdge;
+ int topEdge, bottomEdge;
+ int glyphRow; /* first row of glyph not wholly
+ clipped out */
+ int glyphCol; /* leftmost visible column of glyph */
+#if GETLEFTBITS_ALIGNMENT > 1
+ int getWidth; /* bits to get from glyph */
+#endif
+
+ if(!(ppos = (TEXTPOS *)ALLOCATE_LOCAL(nglyph * sizeof(TEXTPOS))))
+ return;
+
+ pdstBase = mfbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
+ xpos = x;
+ xchar = xpos & PIM;
+
+ for (i=0; i<nglyph; i++)
+ {
+ pci = ppci[i];
+
+ ppos[i].xpos = xpos;
+ ppos[i].xchar = xchar;
+ ppos[i].leftEdge = xpos + pci->metrics.leftSideBearing;
+ ppos[i].rightEdge = xpos + pci->metrics.rightSideBearing;
+ ppos[i].topEdge = y - pci->metrics.ascent;
+ ppos[i].bottomEdge = y + pci->metrics.descent;
+ ppos[i].pdstBase = pdstBase;
+ ppos[i].widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
+
+ xpos += pci->metrics.characterWidth;
+ xchar += pci->metrics.characterWidth;
+ if (xchar > PLST)
+ {
+ xchar &= PIM;
+ pdstBase++;
+ }
+ else if (xchar < 0)
+ {
+ xchar += PPW;
+ pdstBase--;
+ }
+ }
+
+ cclip = pGC->pCompositeClip;
+ pbox = REGION_RECTS(cclip);
+ nbox = REGION_NUM_RECTS(cclip);
+
+ /* HACK ALERT
+ since we continue out of the loop below so often, it
+ is easier to increment pbox at the top than at the end.
+ don't try this at home.
+ */
+ pbox--;
+ while(nbox--)
+ {
+ pbox++;
+ clip.x1 = max(bbox.x1, pbox->x1);
+ clip.y1 = max(bbox.y1, pbox->y1);
+ clip.x2 = min(bbox.x2, pbox->x2);
+ clip.y2 = min(bbox.y2, pbox->y2);
+ if ((clip.x2<=clip.x1) || (clip.y2<=clip.y1))
+ continue;
+
+ for(i=0; i<nglyph; i++)
+ {
+ pci = ppci[i];
+ xchar = ppos[i].xchar;
+
+ /* clip the left and right edges */
+ if (ppos[i].leftEdge < clip.x1)
+ leftEdge = clip.x1;
+ else
+ leftEdge = ppos[i].leftEdge;
+
+ if (ppos[i].rightEdge > clip.x2)
+ rightEdge = clip.x2;
+ else
+ rightEdge = ppos[i].rightEdge;
+
+ w = rightEdge - leftEdge;
+ if (w <= 0)
+ continue;
+
+ /* clip the top and bottom edges */
+ if (ppos[i].topEdge < clip.y1)
+ topEdge = clip.y1;
+ else
+ topEdge = ppos[i].topEdge;
+
+ if (ppos[i].bottomEdge > clip.y2)
+ bottomEdge = clip.y2;
+ else
+ bottomEdge = ppos[i].bottomEdge;
+
+ h = bottomEdge - topEdge;
+ if (h <= 0)
+ continue;
+
+ glyphRow = (topEdge - y) + pci->metrics.ascent;
+ widthGlyph = ppos[i].widthGlyph;
+ pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ pglyph += (glyphRow * widthGlyph);
+
+ pdst = ppos[i].pdstBase;
+
+ glyphCol = (leftEdge - ppos[i].xpos) -
+ (pci->metrics.leftSideBearing);
+#if GETLEFTBITS_ALIGNMENT > 1
+ getWidth = w + glyphCol;
+#endif
+ xoff = xchar + (leftEdge - ppos[i].xpos);
+ if (xoff > PLST)
+ {
+ xoff &= PIM;
+ pdst++;
+ }
+ else if (xoff < 0)
+ {
+ xoff += PPW;
+ pdst--;
+ }
+
+ pdst = mfbScanlineDelta(pdst, -(y-topEdge), widthDst);
+
+ if ((xoff + w) <= PPW)
+ {
+ maskpartialbits(xoff, w, startmask);
+ while (h--)
+ {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst OPEQ (SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ mfbScanlineInc(pdst, widthDst);
+ }
+ }
+ else
+ {
+ maskPPWbits(xoff, w, startmask, endmask);
+ nFirst = PPW - xoff;
+ while (h--)
+ {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst OPEQ (SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) OPEQ (SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ mfbScanlineInc(pdst, widthDst);
+ }
+ }
+ } /* for each glyph */
+ } /* while nbox-- */
+ DEALLOCATE_LOCAL(ppos);
+ break;
+ }
+ default:
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbline.c b/nx-X11/programs/Xserver/mfb/mfbline.c
new file mode 100644
index 000000000..af7c27874
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbline.c
@@ -0,0 +1,757 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbline.c,v 1.6 2001/01/17 22:37:03 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbline.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "mistruct.h"
+
+#include "mfb.h"
+#include "maskbits.h"
+#include "miline.h"
+
+/* single-pixel lines on a color frame buffer
+
+ NON-SLOPED LINES
+ horizontal lines are always drawn left to right; we have to
+move the endpoints right by one after they're swapped.
+ horizontal lines will be confined to a single band of a
+region. the code finds that band (giving up if the lower
+bound of the band is above the line we're drawing); then it
+finds the first box in that band that contains part of the
+line. we clip the line to subsequent boxes in that band.
+ vertical lines are always drawn top to bottom (y-increasing.)
+this requires adding one to the y-coordinate of each endpoint
+after swapping.
+
+ SLOPED LINES
+ when clipping a sloped line, we bring the second point inside
+the clipping box, rather than one beyond it, and then add 1 to
+the length of the line before drawing it. this lets us use
+the same box for finding the outcodes for both endpoints. since
+the equation for clipping the second endpoint to an edge gives us
+1 beyond the edge, we then have to move the point towards the
+first point by one step on the major axis.
+ eventually, there will be a diagram here to explain what's going
+on. the method uses Cohen-Sutherland outcodes to determine
+outsideness, and a method similar to Pike's layers for doing the
+actual clipping.
+
+*/
+
+void
+#ifdef POLYSEGMENT
+mfbSegmentSS (pDrawable, pGC, nseg, pSeg)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nseg;
+ register xSegment *pSeg;
+#else
+mfbLineSS (pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt; /* number of points */
+ DDXPointPtr pptInit;
+#endif
+{
+ int nboxInit;
+ register int nbox;
+ BoxPtr pboxInit;
+ register BoxPtr pbox;
+#ifndef POLYSEGMENT
+ register DDXPointPtr ppt; /* pointer to list of translated points */
+#endif
+
+ unsigned int oc1; /* outcode of point 1 */
+ unsigned int oc2; /* outcode of point 2 */
+
+ PixelType *addrlBase; /* pointer to start of drawable */
+#ifndef POLYSEGMENT
+ PixelType *addrl; /* address of destination pixmap */
+#endif
+ int nlwidth; /* width in longwords of destination pixmap */
+ int xorg, yorg; /* origin of window */
+
+ int adx; /* abs values of dx and dy */
+ int ady;
+ int signdx; /* sign of dx and dy */
+ int signdy;
+ int e, e1, e2; /* bresenham error and increments */
+ int len; /* length of segment */
+ int axis; /* major axis */
+ int octant;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+
+ /* a bunch of temporaries */
+ register int y1, y2;
+ register int x1, x2;
+ RegionPtr cclip;
+ int alu;
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ cclip = pGC->pCompositeClip;
+ alu = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop;
+ pboxInit = REGION_RECTS(cclip);
+ nboxInit = REGION_NUM_RECTS(cclip);
+
+ mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase);
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+#ifdef POLYSEGMENT
+ while (nseg--)
+#else
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while(--npt)
+#endif
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+#ifdef POLYSEGMENT
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious)
+ {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+#endif
+
+ if (x1 == x2) /* vertical line */
+ {
+ /* make the line go top to bottom of screen, keeping
+ endpoint semantics
+ */
+ if (y1 > y2)
+ {
+ register int tmp;
+
+ tmp = y2;
+ y2 = y1 + 1;
+ y1 = tmp + 1;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ y1--;
+#endif
+ }
+#ifdef POLYSEGMENT
+ else if (pGC->capStyle != CapNotLast)
+ y2++;
+#endif
+ /* get to first band that might contain part of line */
+ while ((nbox) && (pbox->y2 <= y1))
+ {
+ pbox++;
+ nbox--;
+ }
+
+ if (nbox)
+ {
+ /* stop when lower edge of box is beyond end of line */
+ while((nbox) && (y2 >= pbox->y1))
+ {
+ if ((x1 >= pbox->x1) && (x1 < pbox->x2))
+ {
+ int y1t, y2t;
+ /* this box has part of the line in it */
+ y1t = max(y1, pbox->y1);
+ y2t = min(y2, pbox->y2);
+ if (y1t != y2t)
+ {
+ mfbVertS (alu,
+ addrlBase, nlwidth,
+ x1, y1t, y2t-y1t);
+ }
+ }
+ nbox--;
+ pbox++;
+ }
+ }
+#ifndef POLYSEGMENT
+ y2 = ppt->y + yorg;
+#endif
+ }
+ else if (y1 == y2) /* horizontal line */
+ {
+ /* force line from left to right, keeping
+ endpoint semantics
+ */
+ if (x1 > x2)
+ {
+ register int tmp;
+
+ tmp = x2;
+ x2 = x1 + 1;
+ x1 = tmp + 1;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ x1--;
+#endif
+ }
+#ifdef POLYSEGMENT
+ else if (pGC->capStyle != CapNotLast)
+ x2++;
+#endif
+
+ /* find the correct band */
+ while( (nbox) && (pbox->y2 <= y1))
+ {
+ pbox++;
+ nbox--;
+ }
+
+ /* try to draw the line, if we haven't gone beyond it */
+ if ((nbox) && (pbox->y1 <= y1))
+ {
+ int tmp;
+
+ /* when we leave this band, we're done */
+ tmp = pbox->y1;
+ while((nbox) && (pbox->y1 == tmp))
+ {
+ int x1t, x2t;
+
+ if (pbox->x2 <= x1)
+ {
+ /* skip boxes until one might contain start point */
+ nbox--;
+ pbox++;
+ continue;
+ }
+
+ /* stop if left of box is beyond right of line */
+ if (pbox->x1 >= x2)
+ {
+ nbox = 0;
+ break;
+ }
+
+ x1t = max(x1, pbox->x1);
+ x2t = min(x2, pbox->x2);
+ if (x1t != x2t)
+ {
+ mfbHorzS (alu,
+ addrlBase, nlwidth,
+ x1t, y1, x2t-x1t);
+ }
+ nbox--;
+ pbox++;
+ }
+ }
+#ifndef POLYSEGMENT
+ x2 = ppt->x + xorg;
+#endif
+ }
+ else /* sloped line */
+ {
+ CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy,
+ 1, 1, octant);
+
+ if (adx > ady)
+ {
+ axis = X_AXIS;
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+ }
+ else
+ {
+ axis = Y_AXIS;
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ SetYMajorOctant(octant);
+ }
+
+ FIXUP_ERROR(e, octant, bias);
+
+ /* we have bresenham parameters and two points.
+ all we have to do now is clip and draw.
+ */
+
+ while(nbox--)
+ {
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if ((oc1 | oc2) == 0)
+ {
+ if (axis == X_AXIS)
+ len = adx;
+ else
+ len = ady;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ len++;
+#endif
+ mfbBresS (alu,
+ addrlBase, nlwidth,
+ signdx, signdy, axis, x1, y1,
+ e, e1, e2, len);
+ break;
+ }
+ else if (oc1 & oc2)
+ {
+ pbox++;
+ }
+ else
+ {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int clipdx, clipdy;
+ int err;
+
+ if (miZeroClipLine(pbox->x1, pbox->y1, pbox->x2-1,
+ pbox->y2-1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1)
+ {
+ pbox++;
+ continue;
+ }
+
+ if (axis == X_AXIS)
+ len = abs(new_x2 - new_x1);
+ else
+ len = abs(new_y2 - new_y1);
+#ifdef POLYSEGMENT
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+#else
+ len += (clip2 != 0);
+#endif
+ if (len)
+ {
+ /* unwind bresenham error term to first point */
+ if (clip1)
+ {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ if (axis == X_AXIS)
+ err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));
+ else
+ err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));
+ }
+ else
+ err = e;
+ mfbBresS
+ (alu,
+ addrlBase, nlwidth,
+ signdx, signdy, axis, new_x1, new_y1,
+ err, e1, e2, len);
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+ } /* sloped line */
+ } /* while (nline--) */
+
+#ifndef POLYSEGMENT
+
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1)))
+ {
+ PixelType _mask;
+
+ if (alu == RROP_BLACK)
+ _mask = rmask[x2 & PIM];
+ else
+ _mask = mask[x2 & PIM];
+
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--)
+ {
+ if ((x2 >= pbox->x1) &&
+ (y2 >= pbox->y1) &&
+ (x2 < pbox->x2) &&
+ (y2 < pbox->y2))
+ {
+ addrl = mfbScanline(addrlBase, x2, y2, nlwidth);
+ switch(alu)
+ {
+ case RROP_BLACK:
+ *addrl &= _mask;
+ break;
+ case RROP_WHITE:
+ *addrl |= _mask;
+ break;
+ case RROP_INVERT:
+ *addrl ^= _mask;
+ break;
+ }
+ break;
+ }
+ else
+ pbox++;
+ }
+ }
+#endif
+}
+
+/*
+ * Draw dashed 1-pixel lines.
+ */
+
+void
+#ifdef POLYSEGMENT
+mfbSegmentSD (pDrawable, pGC, nseg, pSeg)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int nseg;
+ register xSegment *pSeg;
+#else
+mfbLineSD( pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt; /* number of points */
+ DDXPointPtr pptInit;
+#endif
+{
+ int nboxInit;
+ register int nbox;
+ BoxPtr pboxInit;
+ register BoxPtr pbox;
+#ifndef POLYSEGMENT
+ register DDXPointPtr ppt; /* pointer to list of translated points */
+#endif
+
+ register unsigned int oc1; /* outcode of point 1 */
+ register unsigned int oc2; /* outcode of point 2 */
+
+ PixelType *addrl; /* address of destination pixmap */
+ int nlwidth; /* width in longwords of destination pixmap */
+ int xorg, yorg; /* origin of window */
+
+ int adx; /* abs values of dx and dy */
+ int ady;
+ int signdx; /* sign of dx and dy */
+ int signdy;
+ int e, e1, e2; /* bresenham error and increments */
+ int len; /* length of segment */
+ int axis; /* major axis */
+ int octant;
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ int x1, x2, y1, y2;
+ RegionPtr cclip;
+ int fgrop = 0, bgrop = 0;
+ unsigned char *pDash;
+ int dashOffset;
+ int numInDashList;
+ int dashIndex;
+ int isDoubleDash;
+ int dashIndexTmp, dashOffsetTmp;
+ int unclippedlen;
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ cclip = pGC->pCompositeClip;
+ fgrop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop;
+ pboxInit = REGION_RECTS(cclip);
+ nboxInit = REGION_NUM_RECTS(cclip);
+
+ mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrl);
+
+ /* compute initial dash values */
+
+ pDash = (unsigned char *) pGC->dash;
+ numInDashList = pGC->numInDashList;
+ isDoubleDash = (pGC->lineStyle == LineDoubleDash);
+ dashIndex = 0;
+ dashOffset = 0;
+ miStepDash ((int)pGC->dashOffset, &dashIndex, pDash,
+ numInDashList, &dashOffset);
+
+ if (isDoubleDash)
+ bgrop = mfbReduceRop(pGC->alu, pGC->bgPixel);
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+#ifdef POLYSEGMENT
+ while (nseg--)
+#else
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while(--npt)
+#endif
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+#ifdef POLYSEGMENT
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious)
+ {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+#endif
+
+ CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy, 1, 1, octant);
+
+ if (adx > ady)
+ {
+ axis = X_AXIS;
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+ unclippedlen = adx;
+ }
+ else
+ {
+ axis = Y_AXIS;
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ unclippedlen = ady;
+ SetYMajorOctant(octant);
+ }
+
+ FIXUP_ERROR(e, octant, bias);
+
+ /* we have bresenham parameters and two points.
+ all we have to do now is clip and draw.
+ */
+
+ while(nbox--)
+ {
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if ((oc1 | oc2) == 0)
+ {
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast)
+ unclippedlen++;
+ dashIndexTmp = dashIndex;
+ dashOffsetTmp = dashOffset;
+ mfbBresD (fgrop, bgrop,
+ &dashIndexTmp, pDash, numInDashList,
+ &dashOffsetTmp, isDoubleDash,
+ addrl, nlwidth,
+ signdx, signdy, axis, x1, y1,
+ e, e1, e2, unclippedlen);
+ break;
+#else
+ mfbBresD (fgrop, bgrop,
+ &dashIndex, pDash, numInDashList,
+ &dashOffset, isDoubleDash,
+ addrl, nlwidth,
+ signdx, signdy, axis, x1, y1,
+ e, e1, e2, unclippedlen);
+ goto dontStep;
+#endif
+ }
+ else if (oc1 & oc2)
+ {
+ pbox++;
+ }
+ else /* have to clip */
+ {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int clipdx, clipdy;
+ int err;
+
+ if (miZeroClipLine(pbox->x1, pbox->y1, pbox->x2-1, pbox->y2-1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1)
+ {
+ pbox++;
+ continue;
+ }
+ dashIndexTmp = dashIndex;
+ dashOffsetTmp = dashOffset;
+ if (clip1)
+ {
+ int dlen;
+
+ if (axis == X_AXIS)
+ dlen = abs(new_x1 - x1);
+ else
+ dlen = abs(new_y1 - y1);
+ miStepDash (dlen, &dashIndexTmp, pDash,
+ numInDashList, &dashOffsetTmp);
+ }
+ if (axis == X_AXIS)
+ len = abs(new_x2 - new_x1);
+ else
+ len = abs(new_y2 - new_y1);
+#ifdef POLYSEGMENT
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+#else
+ len += (clip2 != 0);
+#endif
+ if (len)
+ {
+ /* unwind bresenham error term to first point */
+ if (clip1)
+ {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ if (axis == X_AXIS)
+ err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));
+ else
+ err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));
+ }
+ else
+ err = e;
+ mfbBresD (fgrop, bgrop,
+ &dashIndexTmp, pDash, numInDashList,
+ &dashOffsetTmp, isDoubleDash,
+ addrl, nlwidth,
+ signdx, signdy, axis, new_x1, new_y1,
+ err, e1, e2, len);
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+#ifndef POLYSEGMENT
+ /*
+ * walk the dash list around to the next line
+ */
+ miStepDash (unclippedlen, &dashIndex, pDash,
+ numInDashList, &dashOffset);
+dontStep: ;
+#endif
+ } /* while (nline--) */
+
+#ifndef POLYSEGMENT
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((dashIndex & 1) == 0 || isDoubleDash) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1)))
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--)
+ {
+ if ((x2 >= pbox->x1) &&
+ (y2 >= pbox->y1) &&
+ (x2 < pbox->x2) &&
+ (y2 < pbox->y2))
+ {
+ MfbBits _mask;
+ int rop;
+
+ rop = fgrop;
+ if (dashIndex & 1)
+ rop = bgrop;
+ if (rop == RROP_BLACK)
+ _mask = rmask[x2 & PIM];
+ else
+ _mask = mask[x2 & PIM];
+ addrl = mfbScanline(addrl, x2, y2, nlwidth);
+ if (rop == RROP_BLACK)
+ *addrl &= _mask;
+ else if (rop == RROP_WHITE)
+ *addrl |= _mask;
+ else
+ *addrl ^= _mask;
+ break;
+ }
+ else
+ pbox++;
+ }
+ }
+#endif
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbmisc.c b/nx-X11/programs/Xserver/mfb/mfbmisc.c
new file mode 100644
index 000000000..19ab3fa75
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbmisc.c
@@ -0,0 +1,100 @@
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbmisc.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "cursor.h"
+#include "scrnintstr.h"
+
+#include "mfb.h"
+
+/*ARGSUSED*/
+void
+mfbQueryBestSize(class, pwidth, pheight, pScreen)
+int class;
+unsigned short *pwidth;
+unsigned short *pheight;
+ScreenPtr pScreen;
+{
+ unsigned width, test;
+
+ switch(class)
+ {
+ case CursorShape:
+ if (*pwidth > pScreen->width)
+ *pwidth = pScreen->width;
+ if (*pheight > pScreen->height)
+ *pheight = pScreen->height;
+ break;
+ case TileShape:
+ case StippleShape:
+ width = *pwidth;
+ if (!width) break;
+ /* Return the closes power of two not less than what they gave me */
+ test = 0x80000000;
+ /* Find the highest 1 bit in the width given */
+ while(!(test & width))
+ test >>= 1;
+ /* If their number is greater than that, bump up to the next
+ * power of two */
+ if((test - 1) & width)
+ test <<= 1;
+ *pwidth = test;
+ /* We don't care what height they use */
+ break;
+ }
+}
+
+mfbQueryBestSizeProc *
+mfbQueryBestSizeWeak(void)
+{
+ return mfbQueryBestSize;
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbmodule.c b/nx-X11/programs/Xserver/mfb/mfbmodule.c
new file mode 100644
index 000000000..be3b9eed0
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbmodule.c
@@ -0,0 +1,52 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbmodule.c,v 1.7 1999/01/26 05:54:21 dawes Exp $ */
+/*
+ * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef XFree86LOADER
+#include "xf86Module.h"
+
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "mfb",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_ANSIC, /* Only need the ansic layer */
+ ABI_ANSIC_VERSION,
+ MOD_CLASS_NONE,
+ {0,0,0,0} /* signature, to be patched into the file by a tool */
+};
+
+XF86ModuleData mfbModuleData = { &VersRec, NULL, NULL };
+
+#endif
diff --git a/nx-X11/programs/Xserver/mfb/mfbpixmap.c b/nx-X11/programs/Xserver/mfb/mfbpixmap.c
new file mode 100644
index 000000000..ad0dfe79f
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbpixmap.c
@@ -0,0 +1,298 @@
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbpixmap.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+
+/* pixmap management
+ written by drewry, september 1986
+
+ on a monchrome device, a pixmap is a bitmap.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xmd.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "maskbits.h"
+
+#include "mfb.h"
+#include "mi.h"
+
+#include "servermd.h"
+
+
+PixmapPtr
+mfbCreatePixmap (pScreen, width, height, depth)
+ ScreenPtr pScreen;
+ int width;
+ int height;
+ int depth;
+{
+ PixmapPtr pPixmap;
+ size_t datasize;
+ size_t paddedWidth;
+
+ if (depth != 1)
+ return NullPixmap;
+ paddedWidth = BitmapBytePad(width);
+ if (paddedWidth / 4 > 32767 || height > 32767)
+ return NullPixmap;
+ datasize = height * paddedWidth;
+ pPixmap = AllocatePixmap(pScreen, datasize);
+ if (!pPixmap)
+ return NullPixmap;
+ pPixmap->drawable.type = DRAWABLE_PIXMAP;
+ pPixmap->drawable.class = 0;
+ pPixmap->drawable.pScreen = pScreen;
+ pPixmap->drawable.depth = depth;
+ pPixmap->drawable.bitsPerPixel = depth;
+ pPixmap->drawable.id = 0;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pPixmap->drawable.x = 0;
+ pPixmap->drawable.y = 0;
+ pPixmap->drawable.width = width;
+ pPixmap->drawable.height = height;
+ pPixmap->devKind = paddedWidth;
+ pPixmap->refcnt = 1;
+#ifdef PIXPRIV
+ pPixmap->devPrivate.ptr = datasize ?
+ (pointer)((char *)pPixmap + pScreen->totalPixmapSize) : NULL;
+#else
+ pPixmap->devPrivate.ptr = (pointer)(pPixmap + 1);
+#endif
+ return pPixmap;
+}
+
+
+Bool
+mfbDestroyPixmap(pPixmap)
+ PixmapPtr pPixmap;
+{
+ if(--pPixmap->refcnt)
+ return TRUE;
+ xfree(pPixmap);
+ return TRUE;
+}
+
+
+PixmapPtr
+mfbCopyPixmap(pSrc)
+ register PixmapPtr pSrc;
+{
+ register PixmapPtr pDst;
+ int size;
+ ScreenPtr pScreen;
+
+ size = pSrc->drawable.height * pSrc->devKind;
+ pScreen = pSrc->drawable.pScreen;
+ pDst = (*pScreen->CreatePixmap) (pScreen, pSrc->drawable.width,
+ pSrc->drawable.height, pSrc->drawable.depth);
+ if (!pDst)
+ return NullPixmap;
+ memmove((char *)pDst->devPrivate.ptr, (char *)pSrc->devPrivate.ptr, size);
+ return pDst;
+}
+
+
+/* replicates a pattern to be a full 32 bits wide.
+ relies on the fact that each scnaline is longword padded.
+ doesn't do anything if pixmap is not a factor of 32 wide.
+ changes width field of pixmap if successful, so that the fast
+ XRotatePixmap code gets used if we rotate the pixmap later.
+
+ calculate number of times to repeat
+ for each scanline of pattern
+ zero out area to be filled with replicate
+ left shift and or in original as many times as needed
+*/
+void
+mfbPadPixmap(pPixmap)
+ PixmapPtr pPixmap;
+{
+ register int width = pPixmap->drawable.width;
+ register int h;
+ register PixelType mask;
+ register PixelType *p;
+ register PixelType bits; /* real pattern bits */
+ register int i;
+ int rep; /* repeat count for pattern */
+
+ if (width >= PPW)
+ return;
+
+ rep = PPW/width;
+ if (rep*width != PPW)
+ return;
+
+ mask = endtab[width];
+
+ p = (PixelType *)(pPixmap->devPrivate.ptr);
+ for (h=0; h < pPixmap->drawable.height; h++)
+ {
+ *p &= mask;
+ bits = *p;
+ for(i=1; i<rep; i++)
+ {
+ bits = SCRRIGHT(bits, width);
+ *p |= bits;
+ }
+ p++;
+ }
+ pPixmap->drawable.width = PPW;
+}
+
+/* Rotates pixmap pPix by w pixels to the right on the screen. Assumes that
+ * words are PPW bits wide, and that the least significant bit appears on the
+ * left.
+ */
+void
+mfbXRotatePixmap(pPix, rw)
+ PixmapPtr pPix;
+ register int rw;
+{
+ register PixelType *pw, *pwFinal;
+ register PixelType t;
+
+ if (pPix == NullPixmap)
+ return;
+
+ pw = (PixelType *)pPix->devPrivate.ptr;
+ rw %= (int)pPix->drawable.width;
+ if (rw < 0)
+ rw += (int)pPix->drawable.width;
+ if(pPix->drawable.width == PPW)
+ {
+ pwFinal = pw + pPix->drawable.height;
+ while(pw < pwFinal)
+ {
+ t = *pw;
+ *pw++ = SCRRIGHT(t, rw) |
+ (SCRLEFT(t, (PPW-rw)) & endtab[rw]);
+ }
+ }
+ else
+ {
+ /* We no longer do this. Validate doesn't try to rotate odd-size
+ * tiles or stipples. mfbUnnatural<tile/stipple>FS works directly off
+ * the unrotate tile/stipple in the GC
+ */
+ ErrorF("X internal error: trying to rotate odd-sized pixmap.\n");
+ }
+
+}
+
+/* Rotates pixmap pPix by h lines. Assumes that h is always less than
+ pPix->height
+ works on any width.
+ */
+void
+mfbYRotatePixmap(pPix, rh)
+ register PixmapPtr pPix;
+ int rh;
+{
+ int nbyDown; /* bytes to move down to row 0; also offset of
+ row rh */
+ int nbyUp; /* bytes to move up to line rh; also
+ offset of first line moved down to 0 */
+ char *pbase;
+ char *ptmp;
+ int height;
+
+ if (pPix == NullPixmap)
+ return;
+ height = (int) pPix->drawable.height;
+ rh %= height;
+ if (rh < 0)
+ rh += height;
+
+ pbase = (char *)pPix->devPrivate.ptr;
+
+ nbyDown = rh * pPix->devKind;
+ nbyUp = (pPix->devKind * height) - nbyDown;
+ if(!(ptmp = (char *)ALLOCATE_LOCAL(nbyUp)))
+ return;
+
+ memmove(ptmp, pbase, nbyUp); /* save the low rows */
+ memmove(pbase, pbase+nbyUp, nbyDown); /* slide the top rows down */
+ memmove(pbase+nbyDown, ptmp, nbyUp); /* move lower rows up to row rh */
+ DEALLOCATE_LOCAL(ptmp);
+}
+
+void
+mfbCopyRotatePixmap(psrcPix, ppdstPix, xrot, yrot)
+ register PixmapPtr psrcPix, *ppdstPix;
+ int xrot, yrot;
+{
+ register PixmapPtr pdstPix;
+
+ if ((pdstPix = *ppdstPix) &&
+ (pdstPix->devKind == psrcPix->devKind) &&
+ (pdstPix->drawable.height == psrcPix->drawable.height))
+ {
+ memmove((char *)pdstPix->devPrivate.ptr,
+ (char *)psrcPix->devPrivate.ptr,
+ psrcPix->drawable.height * psrcPix->devKind);
+ pdstPix->drawable.width = psrcPix->drawable.width;
+ pdstPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ }
+ else
+ {
+ if (pdstPix)
+ /* FIX XBUG 6168 */
+ (*pdstPix->drawable.pScreen->DestroyPixmap)(pdstPix);
+ *ppdstPix = pdstPix = mfbCopyPixmap(psrcPix);
+ if (!pdstPix)
+ return;
+ }
+ mfbPadPixmap(pdstPix);
+ if (xrot)
+ mfbXRotatePixmap(pdstPix, xrot);
+ if (yrot)
+ mfbYRotatePixmap(pdstPix, yrot);
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbply1rct.c b/nx-X11/programs/Xserver/mfb/mfbply1rct.c
new file mode 100644
index 000000000..9b783f609
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbply1rct.c
@@ -0,0 +1,261 @@
+/*
+ * $Xorg: mfbply1rct.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $
+ *
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* $XFree86: xc/programs/Xserver/mfb/mfbply1rct.c,v 1.7tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "mistruct.h"
+
+#include "mfb.h"
+#include "maskbits.h"
+
+#if defined(mips) || defined(sparc)
+#define GetHighWord(x) (((int) (x)) >> 16)
+#else
+#define GetHighWord(x) (((int) (x)) / 65536)
+#endif
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define intToCoord(i,x,y) (((x) = GetHighWord(i)), ((y) = (int) ((short) (i))))
+#define coordToInt(x,y) (((x) << 16) | ((y) & 0xffff))
+#define intToX(i) (GetHighWord(i))
+#define intToY(i) ((int) ((short) i))
+#else
+#define intToCoord(i,x,y) (((x) = (int) ((short) (i))), ((y) = GetHighWord(i)))
+#define coordToInt(x,y) (((y) << 16) | ((x) & 0xffff))
+#define intToX(i) ((int) ((short) (i)))
+#define intToY(i) (GetHighWord(i))
+#endif
+
+void
+MFBFILLPOLY1RECT (pDrawable, pGC, shape, mode, count, ptsIn)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int shape;
+ int mode;
+ int count;
+ DDXPointPtr ptsIn;
+{
+ int nlwidth;
+ PixelType *addrl, *addr;
+ int maxy;
+ int origin;
+ register int vertex1, vertex2;
+ int c;
+ BoxPtr extents;
+ int clip;
+ int y;
+ int *vertex1p = NULL, *vertex2p;
+ int *endp;
+ int x1 = 0, x2 = 0;
+ int dx1 = 0, dx2 = 0;
+ int dy1 = 0, dy2 = 0;
+ int e1 = 0, e2 = 0;
+ int step1 = 0, step2 = 0;
+ int sign1 = 0, sign2 = 0;
+ int h;
+ int l, r;
+ PixelType mask, bits = ~((PixelType)0);
+ int nmiddle;
+
+ if (mode == CoordModePrevious || shape != Convex ||
+ REGION_NUM_RECTS(pGC->pCompositeClip) != 1)
+ {
+ miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+ origin = *((int *) &pDrawable->x);
+ vertex2 = origin - ((origin & 0x8000) << 1);
+ extents = &pGC->pCompositeClip->extents;
+ vertex1 = *((int *) &extents->x1) - vertex2;
+ vertex2 = *((int *) &extents->x2) - vertex2 - 0x00010001;
+ clip = 0;
+ y = 32767;
+ maxy = 0;
+ vertex2p = (int *) ptsIn;
+ endp = vertex2p + count;
+ while (count--)
+ {
+ c = *vertex2p;
+ clip |= (c - vertex1) | (vertex2 - c);
+ c = intToY(c);
+ if (c < y)
+ {
+ y = c;
+ vertex1p = vertex2p;
+ }
+ vertex2p++;
+ if (c > maxy)
+ maxy = c;
+ }
+ if (y == maxy)
+ return;
+
+ if (clip & 0x80008000)
+ {
+ miFillPolygon (pDrawable, pGC, shape, mode, vertex2p - (int *) ptsIn, ptsIn);
+ return;
+ }
+
+ mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrl);
+ addrl = mfbScanlineDelta(addrl, y + pDrawable->y, nlwidth);
+ origin = intToX(origin);
+ vertex2p = vertex1p;
+ vertex2 = vertex1 = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+#define Setup(c,x,vertex,dx,dy,e,sign,step) {\
+ x = intToX(vertex); \
+ if ((dy = intToY(c) - y)) { \
+ dx = intToX(c) - x; \
+ step = 0; \
+ if (dx >= 0) \
+ { \
+ e = 0; \
+ sign = 1; \
+ if (dx >= dy) {\
+ step = dx / dy; \
+ dx = dx % dy; \
+ } \
+ } \
+ else \
+ { \
+ e = 1 - dy; \
+ sign = -1; \
+ dx = -dx; \
+ if (dx >= dy) { \
+ step = - (dx / dy); \
+ dx = dx % dy; \
+ } \
+ } \
+ } \
+ x += origin; \
+ vertex = c; \
+}
+
+#define Step(x,dx,dy,e,sign,step) {\
+ x += step; \
+ if ((e += dx) > 0) \
+ { \
+ x += sign; \
+ e -= dy; \
+ } \
+}
+ for (;;)
+ {
+ if (y == intToY(vertex1))
+ {
+ do
+ {
+ if (vertex1p == (int *) ptsIn)
+ vertex1p = endp;
+ c = *--vertex1p;
+ Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1)
+ } while (y >= intToY(vertex1));
+ h = dy1;
+ }
+ else
+ {
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ h = intToY(vertex1) - y;
+ }
+ if (y == intToY(vertex2))
+ {
+ do
+ {
+ c = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+ Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2)
+ } while (y >= intToY(vertex2));
+ if (dy2 < h)
+ h = dy2;
+ }
+ else
+ {
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ if ((c = (intToY(vertex2) - y)) < h)
+ h = c;
+ }
+ /* fill spans for this segment */
+ y += h;
+ for (;;)
+ {
+ l = x1;
+ r = x2;
+ nmiddle = x2 - x1;
+ if (nmiddle < 0)
+ {
+ nmiddle = -nmiddle;
+ l = x2;
+ r = x1;
+ }
+ c = l & PIM;
+ l -= c;
+ l = l >> PWSH;
+ addr = addrl + l;
+ if (c + nmiddle < PPW)
+ {
+ mask = SCRRIGHT (bits,c) ^ SCRRIGHT (bits,c+nmiddle);
+ *addr OPEQ mask;
+ }
+ else
+ {
+ if (c)
+ {
+ mask = SCRRIGHT(bits, c);
+ *addr OPEQ mask;
+ nmiddle += c - PPW;
+ addr++;
+ }
+ nmiddle >>= PWSH;
+ Duff (nmiddle, *addr++ EQWHOLEWORD)
+ if ((mask = ~SCRRIGHT(bits, r & PIM)))
+ *addr OPEQ mask;
+ }
+ if (!--h)
+ break;
+ mfbScanlineInc(addrl, nlwidth);
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ }
+ if (y == maxy)
+ break;
+ mfbScanlineInc(addrl, nlwidth);
+ }
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbplygblt.c b/nx-X11/programs/Xserver/mfb/mfbplygblt.c
new file mode 100644
index 000000000..275e8c646
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbplygblt.c
@@ -0,0 +1,399 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbplygblt.c,v 3.4tsi Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbplygblt.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "mfb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "regionstr.h"
+#include "maskbits.h"
+#include "miscstruct.h"
+
+/*
+ we should eventually special-case fixed-width fonts, although
+its more important for ImageText, which is meant for terminal
+emulators.
+
+ this works for fonts with glyphs <= 32 bits wide.
+
+ the clipping calculations are done for worst-case fonts.
+we make no assumptions about the heights, widths, or bearings
+of the glyphs. if we knew that the glyphs are all the same height,
+we could clip the tops and bottoms per clipping box, rather
+than per character per clipping box. if we knew that the glyphs'
+left and right bearings were well-behaved, we could clip a single
+character at the start, output until the last unclipped
+character, and then clip the last one. this is all straightforward
+to determine based on max-bounds and min-bounds from the font.
+ there is some inefficiency introduced in the per-character
+clipping to make what's going on clearer.
+
+ (it is possible, for example, for a font to be defined in which the
+next-to-last character in a font would be clipped out, but the last
+one wouldn't. the code below deals with this.)
+
+ PolyText looks at the fg color and the rasterop; mfbValidateGC
+swaps in the right routine after looking at the reduced ratserop
+in the private field of the GC.
+
+ the register allocations are provisional; in particualr startmask and
+endmask might not be the right things. pglyph, xoff, pdst, and tmpSrc
+are fairly obvious, though.
+
+ to avoid source proliferation, this file is compiled
+three times:
+ MFBPOLYGLYPHBLT OPEQ
+ mfbPolyGlyphBltWhite |=
+ mfbPolyGlyphBltBlack &=~
+ mfbPolyGlyphBltInvert ^=
+*/
+
+void
+MFBPOLYGLYPHBLT(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs (unused in R5) */
+{
+ ExtentInfoRec info; /* used by QueryGlyphExtents() */
+ BoxRec bbox; /* string's bounding box */
+
+ CharInfoPtr pci;
+ int xorg, yorg; /* origin of drawable in bitmap */
+ int widthDst; /* width of dst in longwords */
+
+ /* these keep track of the character origin */
+ PixelType *pdstBase;
+ /* points to longword with character origin */
+ int xchar; /* xorigin of char (mod 32) */
+
+ /* these are used for placing the glyph */
+ register int xoff; /* x offset of left edge of glyph (mod 32) */
+ register PixelType *pdst;
+ /* pointer to current longword in dst */
+
+ int w; /* width of glyph in bits */
+ int h; /* height of glyph */
+ int widthGlyph; /* width of glyph, in bytes */
+ register unsigned char *pglyph;
+ /* pointer to current row of glyph */
+
+ /* used for putting down glyph */
+ register PixelType tmpSrc;
+ /* for getting bits from glyph */
+ register PixelType startmask;
+ register PixelType endmask;
+ register int nFirst;/* bits of glyph in current longword */
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ mfbGetPixelWidthAndPointer(pDrawable, widthDst, pdstBase);
+
+ x += xorg;
+ y += yorg;
+
+ QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info);
+ bbox.x1 = x + info.overallLeft;
+ bbox.x2 = x + info.overallRight;
+ bbox.y1 = y - info.overallAscent;
+ bbox.y2 = y + info.overallDescent;
+
+ switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox))
+ {
+ case rgnOUT:
+ break;
+ case rgnIN:
+ pdstBase = mfbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
+ xchar = x & PIM;
+
+ while(nglyph--)
+ {
+ pci = *ppci;
+ pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
+ h = pci->metrics.ascent + pci->metrics.descent;
+ widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
+
+ /* start at top scanline of glyph */
+ pdst = pdstBase;
+
+ /* find correct word in scanline and x offset within it
+ for left edge of glyph
+ */
+ xoff = xchar + pci->metrics.leftSideBearing;
+ if (xoff > PLST)
+ {
+ pdst++;
+ xoff &= PIM;
+ }
+ else if (xoff < 0)
+ {
+ xoff += PPW;
+ pdst--;
+ }
+
+ pdst = mfbScanlineDelta(pdst, -pci->metrics.ascent, widthDst);
+
+ if ((xoff + w) <= PPW)
+ {
+ /* glyph all in one longword */
+ maskpartialbits(xoff, w, startmask);
+ while (h--)
+ {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst OPEQ (SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ mfbScanlineInc(pdst, widthDst);
+ }
+ }
+ else
+ {
+ /* glyph crosses longword boundary */
+ maskPPWbits(xoff, w, startmask, endmask);
+ nFirst = PPW - xoff;
+ while (h--)
+ {
+ getleftbits(pglyph, w, tmpSrc);
+ *pdst OPEQ (SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) OPEQ (SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ mfbScanlineInc(pdst, widthDst);
+ }
+ } /* glyph crosses longwords boundary */
+
+ /* update character origin */
+ x += pci->metrics.characterWidth;
+ xchar += pci->metrics.characterWidth;
+ if (xchar > PLST)
+ {
+ xchar -= PPW;
+ pdstBase++;
+ }
+ else if (xchar < 0)
+ {
+ xchar += PPW;
+ pdstBase--;
+ }
+ ppci++;
+ } /* while nglyph-- */
+ break;
+ case rgnPART:
+ {
+ TEXTPOS *ppos;
+ RegionPtr cclip;
+ int nbox;
+ BoxPtr pbox;
+ int xpos; /* x position of char origin */
+ int i;
+ BoxRec clip;
+ int leftEdge, rightEdge;
+ int topEdge, bottomEdge;
+ int glyphRow; /* first row of glyph not wholly
+ clipped out */
+ int glyphCol; /* leftmost visible column of glyph */
+#if GETLEFTBITS_ALIGNMENT > 1
+ int getWidth; /* bits to get from glyph */
+#endif
+
+ if(!(ppos = (TEXTPOS *)ALLOCATE_LOCAL(nglyph * sizeof(TEXTPOS))))
+ return;
+
+ pdstBase = mfbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
+ xpos = x;
+ xchar = xpos & PIM;
+
+ for (i=0; i<nglyph; i++)
+ {
+ pci = ppci[i];
+
+ ppos[i].xpos = xpos;
+ ppos[i].xchar = xchar;
+ ppos[i].leftEdge = xpos + pci->metrics.leftSideBearing;
+ ppos[i].rightEdge = xpos + pci->metrics.rightSideBearing;
+ ppos[i].topEdge = y - pci->metrics.ascent;
+ ppos[i].bottomEdge = y + pci->metrics.descent;
+ ppos[i].pdstBase = pdstBase;
+ ppos[i].widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
+
+ xpos += pci->metrics.characterWidth;
+ xchar += pci->metrics.characterWidth;
+ if (xchar > PLST)
+ {
+ xchar &= PIM;
+ pdstBase++;
+ }
+ else if (xchar < 0)
+ {
+ xchar += PPW;
+ pdstBase--;
+ }
+ }
+
+ cclip = pGC->pCompositeClip;
+ pbox = REGION_RECTS(cclip);
+ nbox = REGION_NUM_RECTS(cclip);
+
+ for (; --nbox >= 0; pbox++)
+ {
+ clip.x1 = max(bbox.x1, pbox->x1);
+ clip.y1 = max(bbox.y1, pbox->y1);
+ clip.x2 = min(bbox.x2, pbox->x2);
+ clip.y2 = min(bbox.y2, pbox->y2);
+ if ((clip.x2<=clip.x1) || (clip.y2<=clip.y1))
+ continue;
+
+ for(i=0; i<nglyph; i++)
+ {
+ pci = ppci[i];
+ xchar = ppos[i].xchar;
+
+ /* clip the left and right edges */
+ if (ppos[i].leftEdge < clip.x1)
+ leftEdge = clip.x1;
+ else
+ leftEdge = ppos[i].leftEdge;
+
+ if (ppos[i].rightEdge > clip.x2)
+ rightEdge = clip.x2;
+ else
+ rightEdge = ppos[i].rightEdge;
+
+ w = rightEdge - leftEdge;
+ if (w <= 0)
+ continue;
+
+ /* clip the top and bottom edges */
+ if (ppos[i].topEdge < clip.y1)
+ topEdge = clip.y1;
+ else
+ topEdge = ppos[i].topEdge;
+
+ if (ppos[i].bottomEdge > clip.y2)
+ bottomEdge = clip.y2;
+ else
+ bottomEdge = ppos[i].bottomEdge;
+
+ h = bottomEdge - topEdge;
+ if (h <= 0)
+ continue;
+
+ glyphRow = (topEdge - y) + pci->metrics.ascent;
+ widthGlyph = ppos[i].widthGlyph;
+ pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ pglyph += (glyphRow * widthGlyph);
+
+ pdst = ppos[i].pdstBase;
+
+ glyphCol = (leftEdge - ppos[i].xpos) -
+ (pci->metrics.leftSideBearing);
+#if GETLEFTBITS_ALIGNMENT > 1
+ getWidth = w + glyphCol;
+#endif
+ xoff = xchar + (leftEdge - ppos[i].xpos);
+ if (xoff > PLST)
+ {
+ xoff &= PIM;
+ pdst++;
+ }
+ else if (xoff < 0)
+ {
+ xoff += PPW;
+ pdst--;
+ }
+
+ pdst = mfbScanlineDelta(pdst, -(y-topEdge), widthDst);
+
+ if ((xoff + w) <= PPW)
+ {
+ maskpartialbits(xoff, w, startmask);
+ while (h--)
+ {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst OPEQ (SCRRIGHT(tmpSrc, xoff) & startmask);
+ pglyph += widthGlyph;
+ mfbScanlineInc(pdst, widthDst);
+ }
+ }
+ else
+ {
+ maskPPWbits(xoff, w, startmask, endmask);
+ nFirst = PPW - xoff;
+ while (h--)
+ {
+ getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ *pdst OPEQ (SCRRIGHT(tmpSrc, xoff) & startmask);
+ *(pdst+1) OPEQ (SCRLEFT(tmpSrc, nFirst) & endmask);
+ pglyph += widthGlyph;
+ mfbScanlineInc(pdst, widthDst);
+ }
+ }
+ } /* for each glyph */
+ } /* while nbox-- */
+ DEALLOCATE_LOCAL(ppos);
+ break;
+ }
+ default:
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbpntarea.c b/nx-X11/programs/Xserver/mfb/mfbpntarea.c
new file mode 100644
index 000000000..0719e4ebd
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbpntarea.c
@@ -0,0 +1,300 @@
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbpntarea.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "windowstr.h"
+#include "regionstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "mfb.h"
+#include "maskbits.h"
+
+/*
+ the solid fillers are called for rectangles and window backgrounds.
+ the boxes are already translated.
+ maybe this should always take a pixmap instead of a drawable?
+
+ NOTE:
+ iy = ++iy < tileHeight ? iy : 0
+is equivalent to iy%= tileheight, and saves a division.
+*/
+
+/*
+ MFBSOLIDFILLAREA OPEQ EQWHOLEOWRD
+ mfbSolidWhiteArea |= = ~0
+ mfbSolidBlackArea &=~ = 0
+ mfbSolidInvertArea ^= ^= ~0
+
+EQWHOLEWORD is used to write whole longwords. it could use OPEQ,
+but *p++ |= ~0 on at least two compilers generates much
+worse code than *p++ = ~0. similarly for *p++ &= ~~0
+and *p++ = 0.
+
+*/
+
+/*ARGSUSED*/
+void
+MFBSOLIDFILLAREA(pDraw, nbox, pbox, alu, nop)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ int alu;
+ PixmapPtr nop;
+{
+ int nlwidth; /* width in longwords of the drawable */
+ int w; /* width of current box */
+ register int h; /* height of current box */
+ register PixelType *p; /* pointer to bits we're writing */
+ register int nlw; /* loop version of nlwMiddle */
+ register PixelType startmask;
+ register PixelType endmask;/* masks for reggedy bits at either end of line */
+ register int nlwExtra;
+ /* to get from right of box to left of next span */
+ int nlwMiddle; /* number of longwords between sides of boxes */
+ PixelType *pbits; /* pointer to start of drawable */
+
+ mfbGetPixelWidthAndPointer(pDraw, nlwidth, pbits);
+
+ while (nbox--)
+ {
+ w = pbox->x2 - pbox->x1;
+ h = pbox->y2 - pbox->y1;
+ p = mfbScanline(pbits, pbox->x1, pbox->y1, nlwidth);
+
+ if ( ((pbox->x1 & PIM) + w) < PPW)
+ {
+ maskpartialbits(pbox->x1, w, startmask);
+ nlwExtra = nlwidth;
+ Duff(h, *p OPEQ startmask; mfbScanlineInc(p, nlwExtra));
+ }
+ else
+ {
+ maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
+ nlwExtra = nlwidth - nlwMiddle;
+
+ if (startmask && endmask)
+ {
+ nlwExtra -= 1;
+ while (h--)
+ {
+ nlw = nlwMiddle;
+ *p OPEQ startmask;
+ p++;
+ Duff(nlw, *p++ EQWHOLEWORD);
+ *p OPEQ endmask;
+ mfbScanlineInc(p, nlwExtra);
+ }
+ }
+ else if (startmask && !endmask)
+ {
+ nlwExtra -= 1;
+ while (h--)
+ {
+ nlw = nlwMiddle;
+ *p OPEQ startmask;
+ p++;
+ Duff(nlw, *p++ EQWHOLEWORD);
+ mfbScanlineInc(p, nlwExtra);
+ }
+ }
+ else if (!startmask && endmask)
+ {
+ while (h--)
+ {
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ EQWHOLEWORD);
+ *p OPEQ endmask;
+ mfbScanlineInc(p, nlwExtra);
+ }
+ }
+ else /* no ragged bits at either end */
+ {
+ while (h--)
+ {
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ EQWHOLEWORD);
+ mfbScanlineInc(p, nlwExtra);
+ }
+ }
+ }
+ pbox++;
+ }
+}
+
+
+
+/* stipple a list of boxes
+
+you can use the reduced rasterop for stipples. if rrop is
+black, AND the destination with (not stipple pattern). if rrop is
+white OR the destination with the stipple pattern. if rrop is invert,
+XOR the destination with the stipple pattern.
+
+ MFBSTIPPLEFILLAREA OPEQ
+ mfbStippleWhiteArea |=
+ mfbStippleBlackArea &=~
+ mfbStippleInveryArea ^=
+*/
+
+/*ARGSUSED*/
+void
+MFBSTIPPLEFILLAREA(pDraw, nbox, pbox, alu, pstipple)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ int alu;
+ PixmapPtr pstipple;
+{
+ register PixelType *psrc;
+ /* pointer to bits in tile, if needed */
+ int tileHeight; /* height of the tile */
+ register PixelType srcpix;
+
+ int nlwidth; /* width in longwords of the drawable */
+ int w; /* width of current box */
+ register int nlw; /* loop version of nlwMiddle */
+ register PixelType *p; /* pointer to bits we're writing */
+ register int h; /* height of current box */
+ PixelType startmask;
+ PixelType endmask; /* masks for reggedy bits at either end of line */
+ int nlwMiddle; /* number of longwords between sides of boxes */
+ int nlwExtra; /* to get from right of box to left of next span */
+ register int iy; /* index of current scanline in tile */
+ PixelType *pbits; /* pointer to start of drawable */
+
+ mfbGetPixelWidthAndPointer(pDraw, nlwidth, pbits);
+
+ tileHeight = pstipple->drawable.height;
+ psrc = (PixelType *)(pstipple->devPrivate.ptr);
+
+ while (nbox--)
+ {
+ w = pbox->x2 - pbox->x1;
+ h = pbox->y2 - pbox->y1;
+ iy = pbox->y1 % tileHeight;
+ p = mfbScanline(pbits, pbox->x1, pbox->y1, nlwidth);
+
+ if ( ((pbox->x1 & PIM) + w) < PPW)
+ {
+ maskpartialbits(pbox->x1, w, startmask);
+ nlwExtra = nlwidth;
+ while (h--)
+ {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ *p OPEQ (srcpix & startmask);
+ mfbScanlineInc(p, nlwExtra);
+ }
+ }
+ else
+ {
+ maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
+ nlwExtra = nlwidth - nlwMiddle;
+
+ if (startmask && endmask)
+ {
+ nlwExtra -= 1;
+ while (h--)
+ {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ *p OPEQ (srcpix & startmask);
+ p++;
+ Duff (nlw, *p++ OPEQ srcpix);
+ *p OPEQ (srcpix & endmask);
+ mfbScanlineInc(p, nlwExtra);
+ }
+ }
+ else if (startmask && !endmask)
+ {
+ nlwExtra -= 1;
+ while (h--)
+ {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ *p OPEQ (srcpix & startmask);
+ p++;
+ Duff(nlw, *p++ OPEQ srcpix);
+ mfbScanlineInc(p, nlwExtra);
+ }
+ }
+ else if (!startmask && endmask)
+ {
+ while (h--)
+ {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ OPEQ srcpix);
+ *p OPEQ (srcpix & endmask);
+ mfbScanlineInc(p, nlwExtra);
+ }
+ }
+ else /* no ragged bits at either end */
+ {
+ while (h--)
+ {
+ srcpix = psrc[iy];
+ iy = ++iy < tileHeight ? iy : 0;
+ nlw = nlwMiddle;
+ Duff(nlw, *p++ OPEQ srcpix);
+ mfbScanlineInc(p, nlwExtra);
+ }
+ }
+ }
+ pbox++;
+ }
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbpntwin.c b/nx-X11/programs/Xserver/mfb/mfbpntwin.c
new file mode 100644
index 000000000..d1c19b691
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbpntwin.c
@@ -0,0 +1,127 @@
+/* $Xorg: mfbpntwin.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "windowstr.h"
+#include "regionstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "mfb.h"
+#include "maskbits.h"
+#include "mi.h"
+
+void
+mfbPaintWindow(pWin, pRegion, what)
+ WindowPtr pWin;
+ RegionPtr pRegion;
+ int what;
+{
+ register mfbPrivWin *pPrivWin;
+
+ pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
+
+ switch (what) {
+ case PW_BACKGROUND:
+ switch (pWin->backgroundState) {
+ case None:
+ return;
+ case ParentRelative:
+ do {
+ pWin = pWin->parent;
+ } while (pWin->backgroundState == ParentRelative);
+ (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
+ what);
+ return;
+ case BackgroundPixmap:
+ if (pPrivWin->fastBackground)
+ {
+ mfbTileAreaPPWCopy((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion), GXcopy,
+ pPrivWin->pRotatedBackground);
+ return;
+ }
+ break;
+ case BackgroundPixel:
+ if (pWin->background.pixel & 1)
+ mfbSolidWhiteArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion), GXset, NullPixmap);
+ else
+ mfbSolidBlackArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion), GXclear, NullPixmap);
+ return;
+ }
+ break;
+ case PW_BORDER:
+ if (pWin->borderIsPixel)
+ {
+ if (pWin->border.pixel & 1)
+ mfbSolidWhiteArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion), GXset, NullPixmap);
+ else
+ mfbSolidBlackArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion), GXclear, NullPixmap);
+ return;
+ }
+ else if (pPrivWin->fastBorder)
+ {
+ mfbTileAreaPPWCopy((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion), GXcopy,
+ pPrivWin->pRotatedBorder);
+ return;
+ }
+ break;
+ }
+ miPaintWindow(pWin, pRegion, what);
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbpolypnt.c b/nx-X11/programs/Xserver/mfb/mfbpolypnt.c
new file mode 100644
index 000000000..e5ac4c874
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbpolypnt.c
@@ -0,0 +1,145 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbpolypnt.c,v 1.4 2001/01/17 22:37:03 dawes Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbpolypnt.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "pixmapstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "miscstruct.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+
+#include "mfb.h"
+#include "maskbits.h"
+
+void
+mfbPolyPoint(pDrawable, pGC, mode, npt, pptInit)
+ register DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt;
+ xPoint *pptInit;
+{
+
+ register BoxPtr pbox;
+ register int nbox;
+
+ register PixelType *addrl;
+ int nlwidth;
+
+ int nptTmp;
+ register xPoint *ppt;
+
+ register int x;
+ register int y;
+ register int rop;
+ mfbPrivGC *pGCPriv;
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ pGCPriv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr;
+ rop = pGCPriv->rop;
+
+ mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrl);
+
+ if ((mode == CoordModePrevious) && (npt > 1))
+ {
+ for (ppt = pptInit + 1, nptTmp = npt - 1; --nptTmp >= 0; ppt++)
+ {
+ ppt->x += (ppt-1)->x;
+ ppt->y += (ppt-1)->y;
+ }
+ }
+
+ nbox = REGION_NUM_RECTS(pGC->pCompositeClip);
+ pbox = REGION_RECTS(pGC->pCompositeClip);
+ for (; --nbox >= 0; pbox++)
+ {
+ if (rop == RROP_BLACK)
+ {
+ for (ppt = pptInit, nptTmp = npt; --nptTmp >= 0; ppt++)
+ {
+ x = ppt->x + pDrawable->x;
+ y = ppt->y + pDrawable->y;
+ if ((x >= pbox->x1) && (x < pbox->x2) &&
+ (y >= pbox->y1) && (y < pbox->y2))
+ *mfbScanline(addrl, x, y, nlwidth) &= rmask[x & PIM];
+ }
+ }
+ else if (rop == RROP_WHITE)
+ {
+ for (ppt = pptInit, nptTmp = npt; --nptTmp >= 0; ppt++)
+ {
+ x = ppt->x + pDrawable->x;
+ y = ppt->y + pDrawable->y;
+ if ((x >= pbox->x1) && (x < pbox->x2) &&
+ (y >= pbox->y1) && (y < pbox->y2))
+ *mfbScanline(addrl, x, y, nlwidth) |= mask[x & PIM];
+ }
+ }
+ else if (rop == RROP_INVERT)
+ {
+ for (ppt = pptInit, nptTmp = npt; --nptTmp >= 0; ppt++)
+ {
+ x = ppt->x + pDrawable->x;
+ y = ppt->y + pDrawable->y;
+ if ((x >= pbox->x1) && (x < pbox->x2) &&
+ (y >= pbox->y1) && (y < pbox->y2))
+ *mfbScanline(addrl, x, y, nlwidth) ^= mask[x & PIM];
+ }
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbpushpxl.c b/nx-X11/programs/Xserver/mfb/mfbpushpxl.c
new file mode 100644
index 000000000..1cbdf9a5b
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbpushpxl.c
@@ -0,0 +1,287 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbpushpxl.c,v 1.6tsi Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbpushpxl.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "miscstruct.h"
+#include "maskbits.h"
+#include "regionstr.h"
+#include "mfb.h"
+
+/* mfbSolidPP is courtesy of xhacks@csri.toronto.edu
+
+ For fillStyle==FillSolid, a monochrome PushPixels can be reduced to
+ a ROP in the following way: (Note that the ROP is the same as the
+ result of ROP(src=0x3,dst=0x5))
+
+ src=0011 0000 0011
+ dst=0101 0101 0101
+ rop fg=0 fg=1
+ GXclear 0x0 0000 0100 0100 0
+ GXand 0x1 0001 0100 0101 s&d
+ GXandReverse 0x2 0010 0100 0110 s&~d
+ GXcopy 0x3 0011 0100 0111 s
+ GXandInverted 0x4 0100 0101 0100 ~s&d
+ GXnoop 0x5 0101 0101 0101 d
+ GXxor 0x6 0110 0101 0110 s^d
+ GXor 0x7 0111 0101 0111 s|d
+ GXnor 0x8 1000 0110 0100 ~s&~d
+ GXequiv 0x9 1001 0110 0101 ~s^d
+ GXinvert 0xa 1010 0110 0110 ~d
+ GXorReverse 0xb 1011 0110 0111 s|~d
+ GXcopyInverted 0xc 1100 0111 0100 ~s
+ GXorInverted 0xd 1101 0111 0101 ~s|d
+ GXnand 0xe 1110 0111 0110 ~s|~d
+ GXset 0xf 1111 0111 0111 1
+
+For src=0: newRop = 0x4|(rop>>2)
+For src=1: newRop = 0x4|(rop&3)
+*/
+
+/* mfbSolidPP -- squeegees the forground color of pGC through pBitMap
+ * into pDrawable. pBitMap is a stencil (dx by dy of it is used, it may
+ * be bigger) which is placed on the drawable at xOrg, yOrg. Where a 1 bit
+ * is set in the bitmap, the fill style is put onto the drawable using
+ * the GC's logical function. The drawable is not changed where the bitmap
+ * has a zero bit or outside the area covered by the stencil.
+ */
+void
+mfbSolidPP(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
+ GCPtr pGC;
+ PixmapPtr pBitMap;
+ DrawablePtr pDrawable;
+ int dx, dy, xOrg, yOrg;
+{
+ unsigned char alu;
+ RegionRec rgnDst;
+ DDXPointPtr pptSrc;
+ BoxRec srcBox;
+ register DDXPointPtr ppt;
+ register BoxPtr pbox;
+ int i;
+
+ if (!(pGC->planemask & 1)) return;
+
+ /* compute the reduced rop function */
+ alu = pGC->alu;
+ if (!(pGC->fgPixel&1)) alu >>= 2;
+ alu = (alu & 0x3) | 0x4;
+ if (alu == GXnoop) return;
+
+ srcBox.x1 = xOrg;
+ srcBox.y1 = yOrg;
+ srcBox.x2 = xOrg + dx;
+ srcBox.y2 = yOrg + dy;
+ REGION_INIT(pGC->pScreen, &rgnDst, &srcBox, 1);
+
+ /* clip the shape of the dst to the destination composite clip */
+ REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, pGC->pCompositeClip);
+
+ if (!REGION_NIL(&rgnDst))
+ {
+ i = REGION_NUM_RECTS(&rgnDst);
+ pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec));
+ if(pptSrc)
+ {
+ for (pbox = REGION_RECTS(&rgnDst), ppt = pptSrc;
+ --i >= 0;
+ pbox++, ppt++)
+ {
+ ppt->x = pbox->x1 - xOrg;
+ ppt->y = pbox->y1 - yOrg;
+ }
+ mfbDoBitblt((DrawablePtr)pBitMap, pDrawable, alu, &rgnDst, pptSrc);
+ DEALLOCATE_LOCAL(pptSrc);
+ }
+ }
+ REGION_UNINIT(pGC->pScreen, &rgnDst);
+}
+
+#define NPT 128
+
+/* mfbPushPixels -- squeegees the forground color of pGC through pBitMap
+ * into pDrawable. pBitMap is a stencil (dx by dy of it is used, it may
+ * be bigger) which is placed on the drawable at xOrg, yOrg. Where a 1 bit
+ * is set in the bitmap, the fill style is put onto the drawable using
+ * the GC's logical function. The drawable is not changed where the bitmap
+ * has a zero bit or outside the area covered by the stencil.
+ */
+void
+mfbPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
+ GCPtr pGC;
+ PixmapPtr pBitMap;
+ DrawablePtr pDrawable;
+ int dx, dy, xOrg, yOrg;
+{
+ int h, dxDivPPW, ibEnd;
+ PixelType *pwLineStart;
+ register PixelType *pw, *pwEnd;
+ register PixelType mask;
+ register int ib;
+ register PixelType w;
+ register int ipt; /* index into above arrays */
+ Bool fInBox;
+ DDXPointRec pt[NPT];
+ int width[NPT];
+
+ /* Now scan convert the pixmap and use the result to call fillspans in
+ * in the drawable with the original GC */
+ ipt = 0;
+ dxDivPPW = dx/PPW;
+ for(h = 0; h < dy; h++)
+ {
+
+ pw = (PixelType *)(pointer)
+ (((char *)(pBitMap->devPrivate.ptr))+(h * pBitMap->devKind));
+ pwLineStart = pw;
+ /* Process all words which are fully in the pixmap */
+
+ fInBox = FALSE;
+ pwEnd = pwLineStart + dxDivPPW;
+ while(pw < pwEnd)
+ {
+ w = *pw;
+ mask = endtab[1];
+ for(ib = 0; ib < PPW; ib++)
+ {
+ if(w & mask)
+ {
+ if(!fInBox)
+ {
+ pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
+ pt[ipt].y = h + yOrg;
+ /* start new box */
+ fInBox = TRUE;
+ }
+ }
+ else
+ {
+ if(fInBox)
+ {
+ width[ipt] = ((pw - pwLineStart) << PWSH) +
+ ib + xOrg - pt[ipt].x;
+ if (++ipt >= NPT)
+ {
+ (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt,
+ width, TRUE);
+ ipt = 0;
+ }
+ /* end box */
+ fInBox = FALSE;
+ }
+ }
+ mask = SCRRIGHT(mask, 1);
+ }
+ pw++;
+ }
+ ibEnd = dx & PIM;
+ if(ibEnd)
+ {
+ /* Process final partial word on line */
+ w = *pw;
+ mask = endtab[1];
+ for(ib = 0; ib < ibEnd; ib++)
+ {
+ if(w & mask)
+ {
+ if(!fInBox)
+ {
+ /* start new box */
+ pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
+ pt[ipt].y = h + yOrg;
+ fInBox = TRUE;
+ }
+ }
+ else
+ {
+ if(fInBox)
+ {
+ /* end box */
+ width[ipt] = ((pw - pwLineStart) << PWSH) +
+ ib + xOrg - pt[ipt].x;
+ if (++ipt >= NPT)
+ {
+ (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt,
+ width, TRUE);
+ ipt = 0;
+ }
+ fInBox = FALSE;
+ }
+ }
+ mask = SCRRIGHT(mask, 1);
+ }
+ }
+ /* If scanline ended with last bit set, end the box */
+ if(fInBox)
+ {
+ width[ipt] = dx + xOrg - pt[ipt].x;
+ if (++ipt >= NPT)
+ {
+ (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt, width, TRUE);
+ ipt = 0;
+ }
+ }
+ }
+ /* Flush any remaining spans */
+ if (ipt)
+ {
+ (*pGC->ops->FillSpans)(pDrawable, pGC, ipt, pt, width, TRUE);
+ }
+}
+
+mfbPushPixelsProc *mfbPushPixelsWeak(void)
+{
+ return mfbPushPixels;
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbscrclse.c b/nx-X11/programs/Xserver/mfb/mfbscrclse.c
new file mode 100644
index 000000000..55445932c
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbscrclse.c
@@ -0,0 +1,66 @@
+/* $Xorg: mfbscrclse.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/mfb/mfbscrclse.c,v 1.3tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "mfb.h"
+#include "scrnintstr.h"
+
+/*ARGSUSED*/
+Bool
+mfbCloseScreen(index, pScreen)
+ int index;
+ register ScreenPtr pScreen;
+{
+ xfree(pScreen->devPrivate);
+ return TRUE;
+}
+
diff --git a/nx-X11/programs/Xserver/mfb/mfbscrinit.c b/nx-X11/programs/Xserver/mfb/mfbscrinit.c
new file mode 100644
index 000000000..9defac1df
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbscrinit.c
@@ -0,0 +1,210 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbscrinit.c,v 3.8tsi Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbscrinit.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h> /* for xColorItem */
+#include <X11/Xmd.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "resource.h"
+#include "colormap.h"
+#include "mfb.h"
+#include "mistruct.h"
+#include "dix.h"
+#include "mi.h"
+#include "mibstore.h"
+#include "migc.h"
+#include "servermd.h"
+
+#ifdef PIXMAP_PER_WINDOW
+int frameWindowPrivateIndex;
+int frameGetWindowPrivateIndex(void) { return frameWindowPrivateIndex; }
+#endif
+int mfbWindowPrivateIndex;
+int mfbGetWindowPrivateIndex(void) { return mfbWindowPrivateIndex; }
+int mfbGCPrivateIndex;
+int mfbGetGCPrivateIndex(void) { return mfbGCPrivateIndex; }
+static unsigned long mfbGeneration = 0;
+
+static VisualRec visual = {
+/* vid class bpRGB cmpE nplan rMask gMask bMask oRed oGreen oBlue */
+ 0, StaticGray, 1, 2, 1, 0, 0, 0, 0, 0, 0
+};
+
+static VisualID VID;
+
+static DepthRec depth = {
+/* depth numVid vids */
+ 1, 1, &VID
+};
+
+
+BSFuncRec mfbBSFuncRec = {
+ mfbSaveAreas,
+ mfbRestoreAreas,
+ (BackingStoreSetClipmaskRgnProcPtr) 0,
+ (BackingStoreGetImagePixmapProcPtr) 0,
+ (BackingStoreGetSpansPixmapProcPtr) 0,
+};
+
+
+Bool
+mfbAllocatePrivates(pScreen, pWinIndex, pGCIndex)
+ ScreenPtr pScreen;
+ int *pWinIndex, *pGCIndex;
+{
+ if (mfbGeneration != serverGeneration)
+ {
+#ifdef PIXMAP_PER_WINDOW
+ frameWindowPrivateIndex = AllocateWindowPrivateIndex();
+#endif
+ mfbWindowPrivateIndex = AllocateWindowPrivateIndex();
+ mfbGCPrivateIndex = miAllocateGCPrivateIndex();
+ visual.vid = FakeClientID(0);
+ VID = visual.vid;
+ mfbGeneration = serverGeneration;
+ }
+ if (pWinIndex)
+ *pWinIndex = mfbWindowPrivateIndex;
+ if (pGCIndex)
+ *pGCIndex = mfbGCPrivateIndex;
+ pScreen->GetWindowPixmap = mfbGetWindowPixmap;
+ pScreen->SetWindowPixmap = mfbSetWindowPixmap;
+ return (AllocateWindowPrivate(pScreen, mfbWindowPrivateIndex,
+ sizeof(mfbPrivWin)) &&
+ AllocateGCPrivate(pScreen, mfbGCPrivateIndex, sizeof(mfbPrivGC)));
+}
+
+
+/* dts * (inch/dot) * (25.4 mm / inch) = mm */
+Bool
+mfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+{
+ if (!mfbAllocatePrivates(pScreen, (int *)NULL, (int *)NULL))
+ return FALSE;
+ pScreen->defColormap = (Colormap) FakeClientID(0);
+ /* whitePixel, blackPixel */
+ pScreen->QueryBestSize = mfbQueryBestSize;
+ /* SaveScreen */
+ pScreen->GetImage = mfbGetImage;
+ pScreen->GetSpans = mfbGetSpans;
+ pScreen->CreateWindow = mfbCreateWindow;
+ pScreen->DestroyWindow = mfbDestroyWindow;
+ pScreen->PositionWindow = mfbPositionWindow;
+ pScreen->ChangeWindowAttributes = mfbChangeWindowAttributes;
+ pScreen->RealizeWindow = mfbMapWindow;
+ pScreen->UnrealizeWindow = mfbUnmapWindow;
+ pScreen->PaintWindowBackground = mfbPaintWindow;
+ pScreen->PaintWindowBorder = mfbPaintWindow;
+ pScreen->CopyWindow = mfbCopyWindow;
+ pScreen->CreatePixmap = mfbCreatePixmap;
+ pScreen->DestroyPixmap = mfbDestroyPixmap;
+ pScreen->RealizeFont = mfbRealizeFont;
+ pScreen->UnrealizeFont = mfbUnrealizeFont;
+ pScreen->CreateGC = mfbCreateGC;
+ pScreen->CreateColormap = mfbCreateColormap;
+ pScreen->DestroyColormap = mfbDestroyColormap;
+ pScreen->InstallColormap = mfbInstallColormap;
+ pScreen->UninstallColormap = mfbUninstallColormap;
+ pScreen->ListInstalledColormaps = mfbListInstalledColormaps;
+ pScreen->StoreColors = (StoreColorsProcPtr)NoopDDA;
+ pScreen->ResolveColor = mfbResolveColor;
+ pScreen->BitmapToRegion = mfbPixmapToRegion;
+ if (!miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
+ 1, 1, &depth, VID, 1, &visual))
+ return FALSE;
+ pScreen->BackingStoreFuncs = mfbBSFuncRec;
+ return TRUE;
+}
+
+PixmapPtr
+mfbGetWindowPixmap(pWin)
+ WindowPtr pWin;
+{
+#ifdef PIXMAP_PER_WINDOW
+ return (PixmapPtr)(pWin->devPrivates[frameWindowPrivateIndex].ptr);
+#else
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ return (* pScreen->GetScreenPixmap)(pScreen);
+#endif
+}
+
+void
+mfbSetWindowPixmap(pWin, pPix)
+ WindowPtr pWin;
+ PixmapPtr pPix;
+{
+#ifdef PIXMAP_PER_WINDOW
+ pWin->devPrivates[frameWindowPrivateIndex].ptr = (pointer)pPix;
+#else
+ (* pWin->drawable.pScreen->SetScreenPixmap)(pPix);
+#endif
+}
+
+void mfbFillInScreen(ScreenPtr pScreen)
+{
+ pScreen->ChangeWindowAttributes = mfbChangeWindowAttributes;
+ pScreen->RealizeWindow = mfbMapWindow;
+ pScreen->UnrealizeWindow = mfbUnmapWindow;
+ pScreen->DestroyPixmap = mfbDestroyPixmap;
+ pScreen->RealizeFont = mfbRealizeFont;
+ pScreen->UnrealizeFont = mfbUnrealizeFont;
+ pScreen->BitmapToRegion = mfbPixmapToRegion;
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbsetsp.c b/nx-X11/programs/Xserver/mfb/mfbsetsp.c
new file mode 100644
index 000000000..485b4e265
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbsetsp.c
@@ -0,0 +1,283 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbsetsp.c,v 1.6tsi Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbsetsp.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "misc.h"
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "mfb.h"
+#include "maskbits.h"
+
+#include "servermd.h"
+
+
+/* mfbSetScanline -- copies the bits from psrc to the drawable starting at
+ * (xStart, y) and continuing to (xEnd, y). xOrigin tells us where psrc
+ * starts on the scanline. (I.e., if this scanline passes through multiple
+ * boxes, we may not want to start grabbing bits at psrc but at some offset
+ * further on.)
+ */
+void
+mfbSetScanline(y, xOrigin, xStart, xEnd, psrc, alu, pdstBase, widthDst)
+ int y;
+ int xOrigin; /* where this scanline starts */
+ int xStart; /* first bit to use from scanline */
+ int xEnd; /* last bit to use from scanline + 1 */
+ register PixelType *psrc;
+ register int alu; /* raster op */
+ PixelType *pdstBase; /* start of the drawable */
+ int widthDst; /* width of drawable in words */
+{
+ int w; /* width of scanline in bits */
+ register PixelType *pdst; /* where to put the bits */
+ register PixelType tmpSrc; /* scratch buffer to collect bits in */
+ int dstBit; /* offset in bits from beginning of
+ * word */
+ register int nstart; /* number of bits from first partial */
+ register int nend; /* " " last partial word */
+ int offSrc;
+ PixelType startmask, endmask;
+ int nlMiddle, nl;
+
+ pdst = mfbScanline(pdstBase, xStart, y, widthDst);
+ psrc += (xStart - xOrigin) >> PWSH;
+ offSrc = (xStart - xOrigin) & PIM;
+ w = xEnd - xStart;
+ dstBit = xStart & PIM;
+
+ if (dstBit + w <= PPW)
+ {
+ getandputrop(psrc, offSrc, dstBit, w, pdst, alu)
+ }
+ else
+ {
+
+ maskbits(xStart, w, startmask, endmask, nlMiddle);
+ if (startmask)
+ nstart = PPW - dstBit;
+ else
+ nstart = 0;
+ if (endmask)
+ nend = xEnd & PIM;
+ else
+ nend = 0;
+ if (startmask)
+ {
+ getandputrop(psrc, offSrc, dstBit, nstart, pdst, alu)
+ pdst++;
+ offSrc += nstart;
+ if (offSrc > PLST)
+ {
+ psrc++;
+ offSrc -= PPW;
+ }
+ }
+ nl = nlMiddle;
+ while (nl--)
+ {
+ getbits(psrc, offSrc, PPW, tmpSrc);
+ DoRop(*pdst, alu, tmpSrc, *pdst);
+ pdst++;
+ psrc++;
+ }
+ if (endmask)
+ {
+ getandputrop0(psrc, offSrc, nend, pdst, alu);
+ }
+
+ }
+}
+
+
+
+/* SetSpans -- for each span copy pwidth[i] bits from psrc to pDrawable at
+ * ppt[i] using the raster op from the GC. If fSorted is TRUE, the scanlines
+ * are in increasing Y order.
+ * Source bit lines are server scanline padded so that they always begin
+ * on a word boundary.
+ */
+void
+mfbSetSpans(pDrawable, pGC, pcharsrc, ppt, pwidth, nspans, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ char *pcharsrc;
+ register DDXPointPtr ppt;
+ int *pwidth;
+ int nspans;
+ int fSorted;
+{
+ PixelType *psrc = (PixelType *)(pointer)pcharsrc;
+ PixelType *pdstBase; /* start of dst bitmap */
+ int widthDst; /* width of bitmap in words */
+ register BoxPtr pbox, pboxLast, pboxTest;
+ register DDXPointPtr pptLast;
+ int alu;
+ RegionPtr prgnDst;
+ int xStart, xEnd;
+ int yMax;
+
+ alu = pGC->alu;
+ prgnDst = pGC->pCompositeClip;
+
+ pptLast = ppt + nspans;
+
+ yMax = pDrawable->y + (int) pDrawable->height;
+ mfbGetPixelWidthAndPointer(pDrawable, widthDst, pdstBase);
+
+ pbox = REGION_RECTS(prgnDst);
+ pboxLast = pbox + REGION_NUM_RECTS(prgnDst);
+
+ if(fSorted)
+ {
+ /* scan lines sorted in ascending order. Because they are sorted, we
+ * don't have to check each scanline against each clip box. We can be
+ * sure that this scanline only has to be clipped to boxes at or after the
+ * beginning of this y-band
+ */
+ pboxTest = pbox;
+ while(ppt < pptLast)
+ {
+ pbox = pboxTest;
+ if(ppt->y >= yMax)
+ break;
+ while(pbox < pboxLast)
+ {
+ if(pbox->y1 > ppt->y)
+ {
+ /* scanline is before clip box */
+ break;
+ }
+ else if(pbox->y2 <= ppt->y)
+ {
+ /* clip box is before scanline */
+ pboxTest = ++pbox;
+ continue;
+ }
+ else if(pbox->x1 > ppt->x + *pwidth)
+ {
+ /* clip box is to right of scanline */
+ break;
+ }
+ else if(pbox->x2 <= ppt->x)
+ {
+ /* scanline is to right of clip box */
+ pbox++;
+ continue;
+ }
+
+ /* at least some of the scanline is in the current clip box */
+ xStart = max(pbox->x1, ppt->x);
+ xEnd = min(ppt->x + *pwidth, pbox->x2);
+ mfbSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu,
+ pdstBase, widthDst);
+ if(ppt->x + *pwidth <= pbox->x2)
+ {
+ /* End of the line, as it were */
+ break;
+ }
+ else
+ pbox++;
+ }
+ /* We've tried this line against every box; it must be outside them
+ * all. move on to the next point */
+ ppt++;
+ psrc += PixmapWidthInPadUnits(*pwidth, 1);
+ pwidth++;
+ }
+ }
+ else
+ {
+ /* scan lines not sorted. We must clip each line against all the boxes */
+ while(ppt < pptLast)
+ {
+ if(ppt->y >= 0 && ppt->y < yMax)
+ {
+
+ for(pbox = REGION_RECTS(prgnDst); pbox< pboxLast; pbox++)
+ {
+ if(pbox->y1 > ppt->y)
+ {
+ /* rest of clip region is above this scanline,
+ * skip it */
+ break;
+ }
+ if(pbox->y2 <= ppt->y)
+ {
+ /* clip box is below scanline */
+ pbox++;
+ break;
+ }
+ if(pbox->x1 <= ppt->x + *pwidth &&
+ pbox->x2 > ppt->x)
+ {
+ xStart = max(pbox->x1, ppt->x);
+ xEnd = min(pbox->x2, ppt->x + *pwidth);
+ mfbSetScanline(ppt->y, ppt->x, xStart, xEnd,
+ psrc, alu, pdstBase, widthDst);
+ }
+
+ }
+ }
+ psrc += PixmapWidthInPadUnits(*pwidth, 1);
+ ppt++;
+ pwidth++;
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbtegblt.c b/nx-X11/programs/Xserver/mfb/mfbtegblt.c
new file mode 100644
index 000000000..ac22aee0c
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbtegblt.c
@@ -0,0 +1,368 @@
+/* $Xorg: mfbtegblt.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* $XFree86: xc/programs/Xserver/mfb/mfbtegblt.c,v 1.7 2001/01/17 22:37:03 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "mfb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "maskbits.h"
+
+/*
+ this works for fonts with glyphs <= PPW bits wide.
+
+ This should be called only with a terminal-emulator font;
+this means that the FIXED_METRICS flag is set, and that
+glyphbounds == charbounds.
+
+ in theory, this goes faster; even if it doesn't, it reduces the
+flicker caused by writing a string over itself with image text (since
+the background gets repainted per character instead of per string.)
+this seems to be important for some converted X10 applications.
+
+ Image text looks at the bits in the glyph and the fg and bg in the
+GC. it paints a rectangle, as defined in the protocol dcoument,
+and the paints the characters.
+
+ to avoid source proliferation, this file is compiled
+two times:
+ MFBTEGLYPHBLT OP
+ mfbTEGlyphBltWhite (white text, black bg )
+ mfbTEGlyphBltBlack ~ (black text, white bg )
+
+*/
+
+#if defined(NO_3_60_CG4) && defined(FASTPUTBITS) && defined(FASTGETBITS)
+#define FASTCHARS
+#endif
+
+/*
+ * this macro "knows" that only characters <= 8 bits wide will
+ * fit this case (which is why it is independent of GLYPHPADBYTES)
+ */
+
+#if (BITMAP_BIT_ORDER == MSBFirst) && (GLYPHPADBYTES != 4)
+#if GLYPHPADBYTES == 1
+#define ShiftAmnt 24
+#else
+#define ShiftAmnt 16
+#endif
+
+/*
+ * XXX XXX XXX There is something horribly, massively wrong here. There are
+ * hardcoded shifts by 64 below; these cannot work on any present-day
+ * architecture.
+ */
+
+/*
+ * Note: for BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER, SCRRIGHT() evaluates its
+ * first argument more than once. Thus the imbedded char++ have to be moved.
+ * (DHD)
+ */
+#if BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER
+#define GetBits4 c = (*char1++ << ShiftAmnt) | \
+ SCRRIGHT (*char2++ << ShiftAmnt, xoff2) | \
+ SCRRIGHT (*char3++ << ShiftAmnt, xoff3) | \
+ SCRRIGHT (*char4++ << ShiftAmnt, xoff4);
+#else /* BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER */
+#define GetBits4 c = (*char1++ << ShiftAmnt) | \
+ SCRRIGHT (*char2 << ShiftAmnt, xoff2) | \
+ SCRRIGHT (*char3 << ShiftAmnt, xoff3) | \
+ SCRRIGHT (*char4 << ShiftAmnt, xoff4); \
+ char2++; char3++; char4++;
+#endif /* BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER */
+
+#else /* (BITMAP_BIT_ORDER != MSBFirst) || (GLYPHPADBYTES == 4) */
+
+#if BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER
+#define GetBits4 c = *char1++ | \
+ SCRRIGHT (*char2++, xoff2) | \
+ SCRRIGHT (*char3++, xoff3) | \
+ SCRRIGHT (*char4++, xoff4);
+#else /* BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER */
+#define GetBits4 c = *char1++ | \
+ SCRRIGHT (*char2, xoff2) | \
+ SCRRIGHT (*char3, xoff3) | \
+ SCRRIGHT (*char4, xoff4); \
+ char2++; char3++; char4++;
+#endif /* BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER */
+
+#endif /* BITMAP_BIT_ORDER && GLYPHPADBYTES */
+
+
+#if GLYPHPADBYTES == 1
+typedef unsigned char *glyphPointer;
+#define USE_LEFTBITS
+#endif
+
+#if GLYPHPADBYTES == 2
+typedef unsigned short *glyphPointer;
+#define USE_LEFTBITS
+#endif
+
+#if GLYPHPADBYTES == 4
+typedef unsigned int *glyphPointer;
+#endif
+
+#ifdef USE_LEFTBITS
+#define GetBits1 getleftbits (char1, widthGlyph, c); \
+ c &= glyphMask; \
+ char1 = (glyphPointer) (((char *) char1) + glyphBytes);
+#else
+#define GetBits1 c = *char1++;
+#endif
+
+void
+MFBTEGLYPHBLT(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ FontPtr pfont = pGC->font;
+ int widthDst;
+ PixelType *pdstBase; /* pointer to longword with top row
+ of current glyph */
+
+ int h; /* height of glyph and char */
+ register int xpos; /* current x */
+ int ypos; /* current y */
+ int widthGlyph;
+
+ int hTmp; /* counter for height */
+ register PixelType startmask, endmask;
+ int nfirst; /* used if glyphs spans a longword boundary */
+ BoxRec bbox; /* for clipping */
+ int widthGlyphs;
+ register PixelType *dst;
+ register PixelType c;
+ register int xoff1, xoff2, xoff3, xoff4;
+ register glyphPointer char1, char2, char3, char4;
+
+#ifdef USE_LEFTBITS
+ register PixelType glyphMask;
+ register PixelType tmpSrc;
+ register int glyphBytes;
+#endif
+
+ if (!(pGC->planemask & 1))
+ return;
+
+ mfbGetPixelWidthAndPointer(pDrawable, widthDst, pdstBase);
+
+ xpos = x + pDrawable->x;
+ ypos = y + pDrawable->y;
+
+ widthGlyph = FONTMAXBOUNDS(pfont,characterWidth);
+ h = FONTASCENT(pfont) + FONTDESCENT(pfont);
+
+ xpos += FONTMAXBOUNDS(pfont,leftSideBearing);
+ ypos -= FONTASCENT(pfont);
+
+ bbox.x1 = xpos;
+ bbox.x2 = xpos + (widthGlyph * nglyph);
+ bbox.y1 = ypos;
+ bbox.y2 = ypos + h;
+
+ switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox))
+ {
+ case rgnPART:
+ /* this is the WRONG thing to do, but it works.
+ calling the non-terminal text is easy, but slow, given
+ what we know about the font.
+
+ the right thing to do is something like:
+ for each clip rectangle
+ compute at which row the glyph starts to be in it,
+ and at which row the glyph ceases to be in it
+ compute which is the first glyph inside the left
+ edge, and the last one inside the right edge
+ draw a fractional first glyph, using only
+ the rows we know are in
+ draw all the whole glyphs, using the appropriate rows
+ draw any pieces of the last glyph, using the right rows
+
+ this way, the code would take advantage of knowing that
+ all glyphs are the same height and don't overlap.
+
+ one day...
+ */
+ CLIPTETEXT(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ case rgnOUT:
+ return;
+ }
+ pdstBase = mfbScanlineDeltaNoBankSwitch(pdstBase, ypos, widthDst);
+ widthGlyphs = widthGlyph * PGSZB;
+
+#ifdef USE_LEFTBITS
+ glyphMask = endtab[widthGlyph];
+ glyphBytes = GLYPHWIDTHBYTESPADDED(*ppci);
+#endif
+
+ if (nglyph >= PGSZB && widthGlyphs <= PPW)
+ {
+ while (nglyph >= PGSZB)
+ {
+ nglyph -= PGSZB;
+ xoff1 = xpos & PIM;
+ xoff2 = widthGlyph;
+ xoff3 = xoff2 + widthGlyph;
+ xoff4 = xoff3 + widthGlyph;
+ char1 = (glyphPointer) FONTGLYPHBITS(pglyphBase,(*ppci++));
+ char2 = (glyphPointer) FONTGLYPHBITS(pglyphBase,(*ppci++));
+ char3 = (glyphPointer) FONTGLYPHBITS(pglyphBase,(*ppci++));
+ char4 = (glyphPointer) FONTGLYPHBITS(pglyphBase,(*ppci++));
+
+ hTmp = h;
+ dst = mfbScanlineOffset(pdstBase, (xpos >> PWSH)); /* switch now */
+
+#ifndef FASTCHARS
+ if (xoff1 + widthGlyphs <= PPW)
+ {
+ maskpartialbits (xoff1, widthGlyphs, startmask);
+#endif
+ while (hTmp--)
+ {
+ GetBits4
+#ifdef FASTCHARS
+# if BITMAP_BIT_ORDER == MSBFirst
+ c >>= PPW - widthGlyphs;
+# endif
+ FASTPUTBITS(OP(c), xoff1, widthGlyphs, dst);
+#else
+ *(dst) = ((*dst) & ~startmask) | (OP(SCRRIGHT(c, xoff1)) & startmask);
+#endif
+ mfbScanlineInc(dst, widthDst);
+ }
+#ifndef FASTCHARS
+ }
+ else
+ {
+ maskPPWbits (xoff1, widthGlyphs, startmask, endmask);
+ nfirst = PPW - xoff1;
+ while (hTmp--)
+ {
+ GetBits4
+ dst[0] = (dst[0] & ~startmask) |
+ (OP(SCRRIGHT(c,xoff1)) & startmask);
+ dst[1] = (dst[1] & ~endmask) |
+ (OP(SCRLEFT(c,nfirst)) & endmask);
+ mfbScanlineInc(dst, widthDst);
+ }
+ }
+#endif
+ xpos += widthGlyphs;
+ }
+ }
+
+ while(nglyph--)
+ {
+ xoff1 = xpos & PIM;
+ char1 = (glyphPointer) FONTGLYPHBITS(pglyphBase,(*ppci++));
+ hTmp = h;
+ dst = mfbScanlineOffset(pdstBase, (xpos >> PWSH));
+
+#ifndef FASTCHARS
+ if (xoff1 + widthGlyph <= PPW)
+ {
+ maskpartialbits (xoff1, widthGlyph, startmask);
+#endif
+ while (hTmp--)
+ {
+#ifdef FASTCHARS
+#ifdef USE_LEFTBITS
+ FASTGETBITS (char1,0,widthGlyph,c);
+ char1 = (glyphPointer) (((char *) char1) + glyphBytes);
+#else
+ c = *char1++;
+#if BITMAP_BIT_ORDER == MSBFirst
+ c >>= PPW - widthGlyph;
+#endif
+#endif
+ FASTPUTBITS (OP(c),xoff1,widthGlyph,dst);
+#else
+ GetBits1
+ (*dst) = ((*dst) & ~startmask) | (OP(SCRRIGHT(c, xoff1)) & startmask);
+#endif
+ mfbScanlineInc(dst, widthDst);
+ }
+#ifndef FASTCHARS
+ }
+ else
+ {
+ maskPPWbits (xoff1, widthGlyph, startmask, endmask);
+ nfirst = PPW - xoff1;
+ while (hTmp--)
+ {
+ GetBits1
+ dst[0] = (dst[0] & ~startmask) |
+ (OP(SCRRIGHT(c,xoff1)) & startmask);
+ dst[1] = (dst[1] & ~endmask) |
+ (OP(SCRLEFT(c,nfirst)) & endmask);
+ mfbScanlineInc(dst, widthDst);
+ }
+ }
+#endif
+ xpos += widthGlyph;
+ }
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbtile.c b/nx-X11/programs/Xserver/mfb/mfbtile.c
new file mode 100644
index 000000000..ecfa06952
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbtile.c
@@ -0,0 +1,240 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbtile.c,v 1.3 2003/02/18 21:30:01 tsi Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mfbtile.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "windowstr.h"
+#include "regionstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "mfb.h"
+#include "maskbits.h"
+
+#include "mergerop.h"
+/*
+
+ the boxes are already translated.
+
+ NOTE:
+ iy = ++iy < tileHeight ? iy : 0
+is equivalent to iy%= tileheight, and saves a division.
+*/
+
+/*
+ tile area with a PPW bit wide pixmap
+*/
+void
+MROP_NAME(mfbTileAreaPPW)(pDraw, nbox, pbox, alu, ptile)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ int alu;
+ PixmapPtr ptile;
+{
+ register PixelType *psrc;
+ /* pointer to bits in tile, if needed */
+ int tileHeight; /* height of the tile */
+ register PixelType srcpix;
+ int nlwidth; /* width in longwords of the drawable */
+ int w; /* width of current box */
+ MROP_DECLARE_REG ()
+ register int h; /* height of current box */
+ register int nlw; /* loop version of nlwMiddle */
+ register PixelType *p; /* pointer to bits we're writing */
+ PixelType startmask;
+ PixelType endmask; /* masks for reggedy bits at either end of line */
+ int nlwMiddle; /* number of longwords between sides of boxes */
+ int nlwExtra; /* to get from right of box to left of next span */
+ register int iy; /* index of current scanline in tile */
+ PixelType *pbits; /* pointer to start of drawable */
+
+ mfbGetPixelWidthAndPointer(pDraw, nlwidth, pbits);
+
+ MROP_INITIALIZE(alu,~0)
+
+ tileHeight = ptile->drawable.height;
+ psrc = (PixelType *)(ptile->devPrivate.ptr);
+
+ while (nbox--)
+ {
+ w = pbox->x2 - pbox->x1;
+ h = pbox->y2 - pbox->y1;
+ iy = pbox->y1 % tileHeight;
+ p = mfbScanline(pbits, pbox->x1, pbox->y1, nlwidth);
+
+ if ( ((pbox->x1 & PIM) + w) < PPW)
+ {
+ maskpartialbits(pbox->x1, w, startmask);
+ nlwExtra = nlwidth;
+ while (h--)
+ {
+ srcpix = psrc[iy];
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ *p = MROP_MASK(srcpix,*p,startmask);
+ mfbScanlineInc(p, nlwExtra);
+ }
+ }
+ else
+ {
+ maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
+ nlwExtra = nlwidth - nlwMiddle;
+
+ if (startmask && endmask)
+ {
+ nlwExtra -= 1;
+ while (h--)
+ {
+ srcpix = psrc[iy];
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ *p = MROP_MASK (srcpix,*p,startmask);
+ p++;
+ while (nlw--)
+ {
+ *p = MROP_SOLID(srcpix,*p);
+ p++;
+ }
+
+ *p = MROP_MASK(srcpix,*p,endmask);
+ mfbScanlineInc(p, nlwExtra);
+ }
+ }
+ else if (startmask && !endmask)
+ {
+ nlwExtra -= 1;
+ while (h--)
+ {
+ srcpix = psrc[iy];
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ *p = MROP_MASK(srcpix,*p,startmask);
+ p++;
+ while (nlw--)
+ {
+ *p = MROP_SOLID(srcpix,*p);
+ p++;
+ }
+ mfbScanlineInc(p, nlwExtra);
+ }
+ }
+ else if (!startmask && endmask)
+ {
+ while (h--)
+ {
+ srcpix = psrc[iy];
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ while (nlw--)
+ {
+ *p = MROP_SOLID(srcpix,*p);
+ p++;
+ }
+
+ *p = MROP_MASK(srcpix,*p,endmask);
+ mfbScanlineInc(p, nlwExtra);
+ }
+ }
+ else /* no ragged bits at either end */
+ {
+ while (h--)
+ {
+ srcpix = psrc[iy];
+ iy++;
+ if (iy == tileHeight)
+ iy = 0;
+ nlw = nlwMiddle;
+ while (nlw--)
+ {
+ *p = MROP_SOLID (srcpix,*p);
+ p++;
+ }
+ mfbScanlineInc(p, nlwExtra);
+ }
+ }
+ }
+ pbox++;
+ }
+}
+
+#if (MROP) == 0
+void
+mfbTileAreaPPW (pDraw, nbox, pbox, alu, ptile)
+ DrawablePtr pDraw;
+ int nbox;
+ BoxPtr pbox;
+ int alu;
+ PixmapPtr ptile;
+{
+ void (*f)(
+ DrawablePtr /*pDraw*/,
+ int /*nbox*/,
+ BoxPtr /*pbox*/,
+ int /*alu*/,
+ PixmapPtr /*ptile*/);
+
+ if (alu == GXcopy)
+ f = mfbTileAreaPPWCopy;
+ else
+ f = mfbTileAreaPPWGeneral;
+ (*f) (pDraw, nbox, pbox, alu, ptile);
+}
+#endif
diff --git a/nx-X11/programs/Xserver/mfb/mfbwindow.c b/nx-X11/programs/Xserver/mfb/mfbwindow.c
new file mode 100644
index 000000000..56f3f468a
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbwindow.c
@@ -0,0 +1,341 @@
+/* $Xorg: mfbwindow.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86$ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "mfb.h"
+#include "mistruct.h"
+#include "regionstr.h"
+#include "maskbits.h"
+
+Bool
+mfbCreateWindow(pWin)
+ register WindowPtr pWin;
+{
+ register mfbPrivWin *pPrivWin;
+
+ pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
+ pPrivWin->pRotatedBorder = NullPixmap;
+ pPrivWin->pRotatedBackground = NullPixmap;
+ pPrivWin->fastBackground = FALSE;
+ pPrivWin->fastBorder = FALSE;
+
+ return (TRUE);
+}
+
+/* This always returns true, because Xfree can't fail. It might be possible
+ * on some devices for Destroy to fail */
+Bool
+mfbDestroyWindow(pWin)
+ WindowPtr pWin;
+{
+ register mfbPrivWin *pPrivWin;
+
+ pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
+
+ if (pPrivWin->pRotatedBorder)
+ (*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
+ if (pPrivWin->pRotatedBackground)
+ (*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBackground);
+ return (TRUE);
+}
+
+/*ARGSUSED*/
+Bool mfbMapWindow(pWindow)
+ WindowPtr pWindow;
+{
+ return (TRUE);
+}
+
+/* (x, y) is the upper left corner of the window on the screen
+ do we really need to pass this? (is it a;ready in pWin->absCorner?)
+ we only do the rotation for pixmaps that are 32 bits wide (padded
+or otherwise.)
+ mfbChangeWindowAttributes() has already put a copy of the pixmap
+in pPrivWin->pRotated*
+*/
+
+/*ARGSUSED*/
+Bool
+mfbPositionWindow(pWin, x, y)
+ register WindowPtr pWin;
+ int x, y;
+{
+ register mfbPrivWin *pPrivWin;
+ int reset = 0;
+
+ pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
+ if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground)
+ {
+ mfbXRotatePixmap(pPrivWin->pRotatedBackground,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ mfbYRotatePixmap(pPrivWin->pRotatedBackground,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ reset = 1;
+ }
+
+ if (!pWin->borderIsPixel && pPrivWin->fastBorder)
+ {
+ while (pWin->backgroundState == ParentRelative)
+ pWin = pWin->parent;
+ mfbXRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ mfbYRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ reset = 1;
+ }
+ if (reset)
+ {
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ }
+
+ /* This is the "wrong" fix to the right problem, but it doesn't really
+ * cost very much. When the window is moved, we need to invalidate any
+ * RotatedPixmap that exists in any GC currently validated against this
+ * window.
+ */
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+ /* Again, we have no failure modes indicated by any of the routines
+ * we've called, so we have to assume it worked */
+ return (TRUE);
+}
+
+/*ARGSUSED*/
+Bool
+mfbUnmapWindow(pWindow)
+ WindowPtr pWindow;
+{
+ return (TRUE);
+}
+
+/* UNCLEAN!
+ this code calls the bitblt helper code directly.
+
+ mfbCopyWindow copies only the parts of the destination that are
+visible in the source.
+*/
+
+
+void
+mfbCopyWindow(pWin, ptOldOrg, prgnSrc)
+ WindowPtr pWin;
+ DDXPointRec ptOldOrg;
+ RegionPtr prgnSrc;
+{
+ DDXPointPtr pptSrc;
+ register DDXPointPtr ppt;
+ RegionPtr prgnDst;
+ register BoxPtr pbox;
+ register int dx, dy;
+ register int i, nbox;
+ WindowPtr pwinRoot;
+
+ pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
+
+ prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+ REGION_INTERSECT(pWin->drawable.pScreen, prgnDst, &pWin->borderClip,
+ prgnSrc);
+
+ pbox = REGION_RECTS(prgnDst);
+ nbox = REGION_NUM_RECTS(prgnDst);
+ if(!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
+ return;
+ ppt = pptSrc;
+
+ for (i=nbox; --i >= 0; ppt++, pbox++)
+ {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ mfbDoBitblt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
+ GXcopy, prgnDst, pptSrc);
+ DEALLOCATE_LOCAL(pptSrc);
+ REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
+}
+
+
+
+/* swap in correct PaintWindow* routine. If we can use a fast output
+routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
+of it in devPrivate.
+*/
+Bool
+mfbChangeWindowAttributes(pWin, mask)
+ register WindowPtr pWin;
+ register unsigned long mask;
+{
+ register unsigned long index;
+ register mfbPrivWin *pPrivWin;
+ WindowPtr pBgWin;
+
+ pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
+ /*
+ * When background state changes from ParentRelative and
+ * we had previously rotated the fast border pixmap to match
+ * the parent relative origin, rerotate to match window
+ */
+ if (mask & (CWBackPixmap | CWBackPixel) &&
+ pWin->backgroundState != ParentRelative &&
+ pPrivWin->fastBorder &&
+ (pPrivWin->oldRotate.x != pWin->drawable.x ||
+ pPrivWin->oldRotate.y != pWin->drawable.y))
+ {
+ mfbXRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ mfbYRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ }
+ while(mask)
+ {
+ index = lowbit (mask);
+ mask &= ~index;
+ switch(index)
+ {
+ case CWBackPixmap:
+ if (pWin->backgroundState == None)
+ {
+ pPrivWin->fastBackground = FALSE;
+ }
+ else if (pWin->backgroundState == ParentRelative)
+ {
+ pPrivWin->fastBackground = FALSE;
+ /* Rotate border to match parent origin */
+ if (pPrivWin->pRotatedBorder) {
+ for (pBgWin = pWin->parent;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+ mfbXRotatePixmap(pPrivWin->pRotatedBorder,
+ pBgWin->drawable.x - pPrivWin->oldRotate.x);
+ mfbYRotatePixmap(pPrivWin->pRotatedBorder,
+ pBgWin->drawable.y - pPrivWin->oldRotate.y);
+ pPrivWin->oldRotate.x = pBgWin->drawable.x;
+ pPrivWin->oldRotate.y = pBgWin->drawable.y;
+ }
+ }
+ else if ((pWin->background.pixmap->drawable.width <= PPW) &&
+ !(pWin->background.pixmap->drawable.width &
+ (pWin->background.pixmap->drawable.width - 1)))
+ {
+ mfbCopyRotatePixmap(pWin->background.pixmap,
+ &pPrivWin->pRotatedBackground,
+ pWin->drawable.x,
+ pWin->drawable.y);
+ if (pPrivWin->pRotatedBackground)
+ {
+ pPrivWin->fastBackground = TRUE;
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ }
+ else
+ {
+ pPrivWin->fastBackground = FALSE;
+ }
+ }
+ else
+ {
+ pPrivWin->fastBackground = FALSE;
+ }
+ break;
+
+ case CWBackPixel:
+ pPrivWin->fastBackground = FALSE;
+ break;
+
+ case CWBorderPixmap:
+ if ((pWin->border.pixmap->drawable.width <= PPW) &&
+ !(pWin->border.pixmap->drawable.width &
+ (pWin->border.pixmap->drawable.width - 1)))
+ {
+ for (pBgWin = pWin;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+ mfbCopyRotatePixmap(pWin->border.pixmap,
+ &pPrivWin->pRotatedBorder,
+ pBgWin->drawable.x,
+ pBgWin->drawable.y);
+ if (pPrivWin->pRotatedBorder)
+ {
+ pPrivWin->fastBorder = TRUE;
+ pPrivWin->oldRotate.x = pBgWin->drawable.x;
+ pPrivWin->oldRotate.y = pBgWin->drawable.y;
+ }
+ else
+ {
+ pPrivWin->fastBorder = FALSE;
+ }
+ }
+ else
+ {
+ pPrivWin->fastBorder = FALSE;
+ }
+ break;
+ case CWBorderPixel:
+ pPrivWin->fastBorder = FALSE;
+ break;
+ }
+ }
+ /* Again, we have no failure modes indicated by any of the routines
+ * we've called, so we have to assume it worked */
+ return (TRUE);
+}
diff --git a/nx-X11/programs/Xserver/mfb/mfbzerarc.c b/nx-X11/programs/Xserver/mfb/mfbzerarc.c
new file mode 100644
index 000000000..92fd81dfb
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/mfbzerarc.c
@@ -0,0 +1,258 @@
+/* $XFree86: xc/programs/Xserver/mfb/mfbzerarc.c,v 3.7 2002/09/27 01:57:47 dawes Exp $ */
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+********************************************************/
+
+/* $Xorg: mfbzerarc.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+
+/* Derived from:
+ * "Algorithm for drawing ellipses or hyperbolae with a digital plotter"
+ * by M. L. V. Pitteway
+ * The Computer Journal, November 1967, Volume 10, Number 3, pp. 282-289
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "mfb.h"
+#include "maskbits.h"
+#include "mizerarc.h"
+#include "mi.h"
+
+/*
+ * Note: LEFTMOST must be the bit leftmost in the actual screen
+ * representation. This depends also on the IMAGE_BYTE_ORDER.
+ * LONG2CHARS() takes care of the re-ordering as required. (DHD)
+ */
+#if (BITMAP_BIT_ORDER == MSBFirst)
+#define LEFTMOST ((PixelType) LONG2CHARS(((MfbBits)1 << PLST)))
+#else
+#define LEFTMOST ((PixelType) LONG2CHARS(1))
+#endif
+
+#define PixelateWhite(addr,yoff,xoff) \
+ *mfbScanlineOffset(addr, (yoff)+((xoff)>>PWSH)) |= \
+ SCRRIGHT (LEFTMOST, ((xoff) & PIM))
+#define PixelateBlack(addr,yoff,xoff) \
+ *mfbScanlineOffset(addr, (yoff)+((xoff)>>PWSH)) &= \
+ ~(SCRRIGHT (LEFTMOST, ((xoff) & PIM)))
+
+#define Pixelate(base,yoff,xoff) \
+{ \
+ paddr = mfbScanlineOffset(base, (yoff) + ((xoff)>>PWSH)); \
+ pmask = SCRRIGHT(LEFTMOST, (xoff) & PIM); \
+ *paddr = (*paddr & ~pmask) | (pixel & pmask); \
+}
+
+#define DoPix(bit,base,yoff,xoff) if (mask & bit) Pixelate(base,yoff,xoff);
+
+static void
+mfbZeroArcSS(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ xArc *arc)
+{
+ miZeroArcRec info;
+ Bool do360;
+ register int x, y, a, b, d, mask;
+ register int k1, k3, dx, dy;
+ PixelType *addrl;
+ PixelType *yorgl, *yorgol;
+ PixelType pixel;
+ int nlwidth, yoffset, dyoffset;
+ PixelType pmask;
+ register PixelType *paddr;
+
+ if (((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop ==
+ RROP_BLACK)
+ pixel = 0;
+ else
+ pixel = ~0;
+
+ mfbGetPixelWidthAndPointer(pDraw, nlwidth, addrl);
+ do360 = miZeroArcSetup(arc, &info, TRUE);
+ yorgl = addrl + ((info.yorg + pDraw->y) * nlwidth);
+ yorgol = addrl + ((info.yorgo + pDraw->y) * nlwidth);
+ info.xorg += pDraw->x;
+ info.xorgo += pDraw->x;
+ MIARCSETUP();
+ yoffset = y ? nlwidth : 0;
+ dyoffset = 0;
+ mask = info.initialMask;
+ if (!(arc->width & 1))
+ {
+ DoPix(2, yorgl, 0, info.xorgo);
+ DoPix(8, yorgol, 0, info.xorgo);
+ }
+ if (!info.end.x || !info.end.y)
+ {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ if (do360 && (arc->width == arc->height) && !(arc->width & 1))
+ {
+ int xoffset = nlwidth;
+ PixelType *yorghl = mfbScanlineDeltaNoBankSwitch(yorgl, info.h, nlwidth);
+ int xorghp = info.xorg + info.h;
+ int xorghn = info.xorg - info.h;
+
+ if (pixel)
+ {
+ while (1)
+ {
+ PixelateWhite(yorgl, yoffset, info.xorg + x);
+ PixelateWhite(yorgl, yoffset, info.xorg - x);
+ PixelateWhite(yorgol, -yoffset, info.xorg - x);
+ PixelateWhite(yorgol, -yoffset, info.xorg + x);
+ if (a < 0)
+ break;
+ PixelateWhite(yorghl, -xoffset, xorghp - y);
+ PixelateWhite(yorghl, -xoffset, xorghn + y);
+ PixelateWhite(yorghl, xoffset, xorghn + y);
+ PixelateWhite(yorghl, xoffset, xorghp - y);
+ xoffset += nlwidth;
+ MIARCCIRCLESTEP(yoffset += nlwidth;);
+ }
+ }
+ else
+ {
+ while (1)
+ {
+ PixelateBlack(yorgl, yoffset, info.xorg + x);
+ PixelateBlack(yorgl, yoffset, info.xorg - x);
+ PixelateBlack(yorgol, -yoffset, info.xorg - x);
+ PixelateBlack(yorgol, -yoffset, info.xorg + x);
+ if (a < 0)
+ break;
+ PixelateBlack(yorghl, -xoffset, xorghp - y);
+ PixelateBlack(yorghl, -xoffset, xorghn + y);
+ PixelateBlack(yorghl, xoffset, xorghn + y);
+ PixelateBlack(yorghl, xoffset, xorghp - y);
+ xoffset += nlwidth;
+ MIARCCIRCLESTEP(yoffset += nlwidth;);
+ }
+ }
+ x = info.w;
+ yoffset = info.h * nlwidth;
+ }
+ else if (do360)
+ {
+ while (y < info.h || x < info.w)
+ {
+ MIARCOCTANTSHIFT(dyoffset = nlwidth;);
+ Pixelate(yorgl, yoffset, info.xorg + x);
+ Pixelate(yorgl, yoffset, info.xorgo - x);
+ Pixelate(yorgol, -yoffset, info.xorgo - x);
+ Pixelate(yorgol, -yoffset, info.xorg + x);
+ MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;);
+ }
+ }
+ else
+ {
+ while (y < info.h || x < info.w)
+ {
+ MIARCOCTANTSHIFT(dyoffset = nlwidth;);
+ if ((x == info.start.x) || (y == info.start.y))
+ {
+ mask = info.start.mask;
+ info.start = info.altstart;
+ }
+ DoPix(1, yorgl, yoffset, info.xorg + x);
+ DoPix(2, yorgl, yoffset, info.xorgo - x);
+ DoPix(4, yorgol, -yoffset, info.xorgo - x);
+ DoPix(8, yorgol, -yoffset, info.xorg + x);
+ if ((x == info.end.x) || (y == info.end.y))
+ {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;);
+ }
+ }
+ if ((x == info.start.x) || (y == info.start.y))
+ mask = info.start.mask;
+ DoPix(1, yorgl, yoffset, info.xorg + x);
+ DoPix(4, yorgol, -yoffset, info.xorgo - x);
+ if (arc->height & 1)
+ {
+ DoPix(2, yorgl, yoffset, info.xorgo - x);
+ DoPix(8, yorgol, -yoffset, info.xorg + x);
+ }
+}
+
+void
+mfbZeroPolyArcSS(pDraw, pGC, narcs, parcs)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int narcs;
+ xArc *parcs;
+{
+ register xArc *arc;
+ register int i;
+ BoxRec box;
+ int x2, y2;
+ RegionPtr cclip;
+
+ if (!(pGC->planemask & 1))
+ return;
+ cclip = pGC->pCompositeClip;
+ for (arc = parcs, i = narcs; --i >= 0; arc++)
+ {
+ if (miCanZeroArc(arc))
+ {
+ box.x1 = arc->x + pDraw->x;
+ box.y1 = arc->y + pDraw->y;
+ /*
+ * Because box.x2 and box.y2 get truncated to 16 bits, and the
+ * RECT_IN_REGION test treats the resulting number as a signed
+ * integer, the RECT_IN_REGION test alone can go the wrong way.
+ * This can result in a server crash because the rendering
+ * routines in this file deal directly with cpu addresses
+ * of pixels to be stored, and do not clip or otherwise check
+ * that all such addresses are within their respective pixmaps.
+ * So we only allow the RECT_IN_REGION test to be used for
+ * values that can be expressed correctly in a signed short.
+ */
+ x2 = box.x1 + (int)arc->width + 1;
+ box.x2 = x2;
+ y2 = box.y1 + (int)arc->height + 1;
+ box.y2 = y2;
+ if ( (x2 <= MAXSHORT) && (y2 <= MAXSHORT) &&
+ (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) )
+ mfbZeroArcSS(pDraw, pGC, arc);
+ else
+ miZeroPolyArc(pDraw, pGC, 1, arc);
+ }
+ else
+ miPolyArc(pDraw, pGC, 1, arc);
+ }
+}
diff --git a/nx-X11/programs/Xserver/mfb/module/Imakefile b/nx-X11/programs/Xserver/mfb/module/Imakefile
new file mode 100644
index 000000000..bea44f4e8
--- /dev/null
+++ b/nx-X11/programs/Xserver/mfb/module/Imakefile
@@ -0,0 +1,6 @@
+XCOMM $XFree86: xc/programs/Xserver/cfb/module/Imakefile,v 1.1 2002/05/31 15:12:56 dawes Exp $
+
+#define IHaveModules
+#define LinkDirectory ..
+
+#include "../Imakefile"
diff --git a/nx-X11/programs/Xserver/mi/Imakefile b/nx-X11/programs/Xserver/mi/Imakefile
new file mode 100644
index 000000000..2bf6e2189
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/Imakefile
@@ -0,0 +1,128 @@
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:53:36 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/mi/Imakefile,v 3.34 2002/05/22 21:38:31 herrb Exp $
+
+#include <Server.tmpl>
+
+#if ! HasCbrt
+CBRT_SRC = cbrt.c
+CBRT_OBJ = cbrt.o
+#endif
+
+#if HasFfs
+FFS_DEFINES = -DHAS_FFS
+#endif
+
+#if DoLoadableServer
+EXTRAMIINITEXTOBJ = miinitext.o
+#else
+MIINITEXTSRC = miinitext.c
+MIINITEXTOBJ = miinitext.o
+#endif
+
+SRCS = $(CBRT_SRC) mivaltree.c mipolyseg.c mipolyrect.c \
+ mipoly.c mipolycon.c mipolygen.c mipolyutil.c \
+ mifillrct.c miwideline.c mispans.c \
+ miarc.c mizerarc.c mifillarc.c \
+ miwindow.c micursor.c miregion.c \
+ mipolytext.c mibitblt.c mipolypnt.c mipushpxl.c \
+ miexpose.c miglblt.c mizerline.c mizerclip.c mifpolycon.c \
+ midash.c mibstore.c mibank.c $(MIINITEXTSRC) mieq.c \
+ mipointer.c misprite.c midispcur.c miscrinit.c miclipn.c migc.c \
+ micmap.c mioverlay.c
+
+OBJS = $(CBRT_OBJ) mivaltree.o mipolyseg.o mipolyrect.o \
+ mipoly.o mipolycon.o mipolygen.o mipolyutil.o \
+ mifillrct.o miwideline.o mispans.o \
+ miarc.o mizerarc.o mifillarc.o \
+ miwindow.o micursor.o miregion.o \
+ mipolytext.o mibitblt.o mipolypnt.o mipushpxl.o \
+ miexpose.o miglblt.o mizerline.o mizerclip.o mifpolycon.o \
+ midash.o mibstore.o mibank.o $(MIINITEXTOBJ) mieq.o \
+ mipointer.o misprite.o midispcur.o miscrinit.o miclipn.o migc.o \
+ micmap.o mioverlay.o
+
+#if (defined (XFree86Version) || defined(XorgVersion))
+/*
+ * Make sure XINPUT, XF86VidTune, etc aren't defined for the miinitext.o
+ * used by Xnest, Xvfb
+ */
+
+#if NXLibraries
+
+/*
+ * To build the NX agent we need the XINPUT symbol
+ * in order to build the XInputExtension, since we
+ * don't use the XF86 module loader.
+ */
+
+EXT_DEFINES = ExtensionDefines -UXF86VIDMODE -UXFreeXDGA -UXF86MISC \
+ -UXFree86LOADER
+
+#else
+
+EXT_DEFINES = ExtensionDefines -UXINPUT -UXF86VIDMODE -UXFreeXDGA -UXF86MISC \
+ -UXFree86LOADER
+
+#endif
+
+#endif
+
+INCLUDES = -I. -I../include -I../../../include/fonts -I../render \
+ -I../xfixes -I../damageext -I../miext/damage \
+ -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(EXTINCSRC) -I$(SERVERSRC)/Xext
+LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+DEFINES = $(FFS_DEFINES)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(mi,$(OBJS))
+LintLibraryTarget(mi,$(SRCS))
+NormalLintTarget($(SRCS))
+
+#ifndef Win32Architecture
+NormalLibraryTarget(cbrt,cbrt.o)
+#endif
+
+SpecialCObjectRule(miinitext,$(ICONFIGFILES),$(EXT_DEFINES))
+SpecialCObjectRule(miscrinit,$(ICONFIGFILES),$(EXT_DEFINES))
+#ifdef ItsyCompilerBug
+SpecialCObjectRule(mipolycon,$(_NOOP_),-O0)
+#endif
+#if defined(OpenBSDArchitecture) && defined(Sparc64Architecture)
+SpecialCObjectRule(mizerclip,NullParameter,-O0)
+#endif
+
+AllTarget($(EXTRAMIINITEXTOBJ))
+
+DependTarget()
+
+InstallDriverSDKNonExecFile(mi.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(mibank.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(mibstore.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(micmap.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(migc.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(miline.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(mipointer.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(mipointrst.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(mizerarc.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(micoord.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/mi/Imakefile.NX.original b/nx-X11/programs/Xserver/mi/Imakefile.NX.original
new file mode 100644
index 000000000..2bf6e2189
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/Imakefile.NX.original
@@ -0,0 +1,128 @@
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:53:36 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/mi/Imakefile,v 3.34 2002/05/22 21:38:31 herrb Exp $
+
+#include <Server.tmpl>
+
+#if ! HasCbrt
+CBRT_SRC = cbrt.c
+CBRT_OBJ = cbrt.o
+#endif
+
+#if HasFfs
+FFS_DEFINES = -DHAS_FFS
+#endif
+
+#if DoLoadableServer
+EXTRAMIINITEXTOBJ = miinitext.o
+#else
+MIINITEXTSRC = miinitext.c
+MIINITEXTOBJ = miinitext.o
+#endif
+
+SRCS = $(CBRT_SRC) mivaltree.c mipolyseg.c mipolyrect.c \
+ mipoly.c mipolycon.c mipolygen.c mipolyutil.c \
+ mifillrct.c miwideline.c mispans.c \
+ miarc.c mizerarc.c mifillarc.c \
+ miwindow.c micursor.c miregion.c \
+ mipolytext.c mibitblt.c mipolypnt.c mipushpxl.c \
+ miexpose.c miglblt.c mizerline.c mizerclip.c mifpolycon.c \
+ midash.c mibstore.c mibank.c $(MIINITEXTSRC) mieq.c \
+ mipointer.c misprite.c midispcur.c miscrinit.c miclipn.c migc.c \
+ micmap.c mioverlay.c
+
+OBJS = $(CBRT_OBJ) mivaltree.o mipolyseg.o mipolyrect.o \
+ mipoly.o mipolycon.o mipolygen.o mipolyutil.o \
+ mifillrct.o miwideline.o mispans.o \
+ miarc.o mizerarc.o mifillarc.o \
+ miwindow.o micursor.o miregion.o \
+ mipolytext.o mibitblt.o mipolypnt.o mipushpxl.o \
+ miexpose.o miglblt.o mizerline.o mizerclip.o mifpolycon.o \
+ midash.o mibstore.o mibank.o $(MIINITEXTOBJ) mieq.o \
+ mipointer.o misprite.o midispcur.o miscrinit.o miclipn.o migc.o \
+ micmap.o mioverlay.o
+
+#if (defined (XFree86Version) || defined(XorgVersion))
+/*
+ * Make sure XINPUT, XF86VidTune, etc aren't defined for the miinitext.o
+ * used by Xnest, Xvfb
+ */
+
+#if NXLibraries
+
+/*
+ * To build the NX agent we need the XINPUT symbol
+ * in order to build the XInputExtension, since we
+ * don't use the XF86 module loader.
+ */
+
+EXT_DEFINES = ExtensionDefines -UXF86VIDMODE -UXFreeXDGA -UXF86MISC \
+ -UXFree86LOADER
+
+#else
+
+EXT_DEFINES = ExtensionDefines -UXINPUT -UXF86VIDMODE -UXFreeXDGA -UXF86MISC \
+ -UXFree86LOADER
+
+#endif
+
+#endif
+
+INCLUDES = -I. -I../include -I../../../include/fonts -I../render \
+ -I../xfixes -I../damageext -I../miext/damage \
+ -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(EXTINCSRC) -I$(SERVERSRC)/Xext
+LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+DEFINES = $(FFS_DEFINES)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(mi,$(OBJS))
+LintLibraryTarget(mi,$(SRCS))
+NormalLintTarget($(SRCS))
+
+#ifndef Win32Architecture
+NormalLibraryTarget(cbrt,cbrt.o)
+#endif
+
+SpecialCObjectRule(miinitext,$(ICONFIGFILES),$(EXT_DEFINES))
+SpecialCObjectRule(miscrinit,$(ICONFIGFILES),$(EXT_DEFINES))
+#ifdef ItsyCompilerBug
+SpecialCObjectRule(mipolycon,$(_NOOP_),-O0)
+#endif
+#if defined(OpenBSDArchitecture) && defined(Sparc64Architecture)
+SpecialCObjectRule(mizerclip,NullParameter,-O0)
+#endif
+
+AllTarget($(EXTRAMIINITEXTOBJ))
+
+DependTarget()
+
+InstallDriverSDKNonExecFile(mi.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(mibank.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(mibstore.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(micmap.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(migc.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(miline.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(mipointer.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(mipointrst.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(mizerarc.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(micoord.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/mi/Imakefile.X.original b/nx-X11/programs/Xserver/mi/Imakefile.X.original
new file mode 100644
index 000000000..a6a3c97fa
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/Imakefile.X.original
@@ -0,0 +1,94 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:53:36 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/mi/Imakefile,v 3.34 2002/05/22 21:38:31 herrb Exp $
+
+#include <Server.tmpl>
+
+#if ! HasCbrt
+CBRT_SRC = cbrt.c
+CBRT_OBJ = cbrt.o
+#endif
+
+#if HasFfs
+FFS_DEFINES = -DHAS_FFS
+#endif
+
+#if DoLoadableServer
+EXTRAMIINITEXTOBJ = miinitext.o
+#else
+MIINITEXTSRC = miinitext.c
+MIINITEXTOBJ = miinitext.o
+#endif
+
+SRCS = $(CBRT_SRC) mivaltree.c mipolyseg.c mipolyrect.c \
+ mipoly.c mipolycon.c mipolygen.c mipolyutil.c \
+ mifillrct.c miwideline.c mispans.c \
+ miarc.c mizerarc.c mifillarc.c \
+ miwindow.c micursor.c miregion.c \
+ mipolytext.c mibitblt.c mipolypnt.c mipushpxl.c \
+ miexpose.c miglblt.c mizerline.c mizerclip.c mifpolycon.c \
+ midash.c mibstore.c mibank.c $(MIINITEXTSRC) mieq.c \
+ mipointer.c misprite.c midispcur.c miscrinit.c miclipn.c migc.c \
+ micmap.c mioverlay.c
+
+OBJS = $(CBRT_OBJ) mivaltree.o mipolyseg.o mipolyrect.o \
+ mipoly.o mipolycon.o mipolygen.o mipolyutil.o \
+ mifillrct.o miwideline.o mispans.o \
+ miarc.o mizerarc.o mifillarc.o \
+ miwindow.o micursor.o miregion.o \
+ mipolytext.o mibitblt.o mipolypnt.o mipushpxl.o \
+ miexpose.o miglblt.o mizerline.o mizerclip.o mifpolycon.o \
+ midash.o mibstore.o mibank.o $(MIINITEXTOBJ) mieq.o \
+ mipointer.o misprite.o midispcur.o miscrinit.o miclipn.o migc.o \
+ micmap.o mioverlay.o
+
+#if (defined (XFree86Version) || defined(XorgVersion))
+/*
+ * Make sure XINPUT, XF86VidTune, etc aren't defined for the miinitext.o
+ * used by Xnest, Xvfb
+ */
+EXT_DEFINES = ExtensionDefines -UXINPUT -UXF86VIDMODE -UXFreeXDGA -UXF86MISC \
+ -UXFree86LOADER
+#endif
+
+INCLUDES = -I. -I../include -I../../../include/fonts -I../render \
+ -I../xfixes -I../damageext -I../miext/damage \
+ -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(EXTINCSRC) -I$(SERVERSRC)/Xext
+LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+DEFINES = $(FFS_DEFINES)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(mi,$(OBJS))
+LintLibraryTarget(mi,$(SRCS))
+NormalLintTarget($(SRCS))
+
+#ifndef Win32Architecture
+NormalLibraryTarget(cbrt,cbrt.o)
+#endif
+
+SpecialCObjectRule(miinitext,$(ICONFIGFILES),$(EXT_DEFINES))
+SpecialCObjectRule(miscrinit,$(ICONFIGFILES),$(EXT_DEFINES))
+#ifdef ItsyCompilerBug
+SpecialCObjectRule(mipolycon,$(_NOOP_),-O0)
+#endif
+#if defined(OpenBSDArchitecture) && defined(Sparc64Architecture)
+SpecialCObjectRule(mizerclip,NullParameter,-O0)
+#endif
+
+AllTarget($(EXTRAMIINITEXTOBJ))
+
+DependTarget()
+
+InstallDriverSDKNonExecFile(mi.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(mibank.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(mibstore.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(micmap.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(migc.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(miline.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(mipointer.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(mipointrst.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(mizerarc.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(micoord.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/mi/cbrt.c b/nx-X11/programs/Xserver/mi/cbrt.c
new file mode 100644
index 000000000..cfc8d84da
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/cbrt.c
@@ -0,0 +1,48 @@
+/* $Xorg: cbrt.c,v 1.4 2001/02/09 02:05:19 xorgcvs Exp $ */
+/*
+
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/mi/cbrt.c,v 3.3 2001/05/29 22:24:06 dawes Exp $ */
+
+/* simple cbrt, in case your math library doesn't have a good one */
+
+/*
+ * Would normally include <math.h> for this, but for the sake of compiler
+ * warnings, we don't want to get duplicate declarations for cbrt().
+ */
+
+double pow(double, double);
+double cbrt(double);
+
+double
+cbrt(double x)
+{
+ if (x > 0.0)
+ return pow(x, 1.0/3.0);
+ else
+ return -pow(-x, 1.0/3.0);
+}
diff --git a/nx-X11/programs/Xserver/mi/mi.h b/nx-X11/programs/Xserver/mi/mi.h
new file mode 100644
index 000000000..3c85693dc
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mi.h
@@ -0,0 +1,645 @@
+/* $Xorg: mi.h,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/mi/mi.h,v 3.9 2001/08/06 20:51:16 dawes Exp $ */
+
+#ifndef MI_H
+#define MI_H
+#include <X11/X.h>
+#include "region.h"
+#include "validate.h"
+#include "window.h"
+#include "gc.h"
+#include <X11/fonts/font.h>
+#include "input.h"
+#include "cursor.h"
+
+#define MiBits CARD32
+
+typedef struct _miDash *miDashPtr;
+#define EVEN_DASH 0
+#define ODD_DASH ~0
+
+/* miarc.c */
+
+extern void miPolyArc(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+
+/* mibitblt.c */
+
+extern RegionPtr miCopyArea(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr /*pGC*/,
+ int /*xIn*/,
+ int /*yIn*/,
+ int /*widthSrc*/,
+ int /*heightSrc*/,
+ int /*xOut*/,
+ int /*yOut*/
+);
+
+extern void miOpqStipDrawable(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ RegionPtr /*prgnSrc*/,
+ MiBits * /*pbits*/,
+ int /*srcx*/,
+ int /*w*/,
+ int /*h*/,
+ int /*dstx*/,
+ int /*dsty*/
+);
+
+extern RegionPtr miCopyPlane(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr /*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ unsigned long /*bitPlane*/
+);
+
+extern void miGetImage(
+ DrawablePtr /*pDraw*/,
+ int /*sx*/,
+ int /*sy*/,
+ int /*w*/,
+ int /*h*/,
+ unsigned int /*format*/,
+ unsigned long /*planeMask*/,
+ char * /*pdstLine*/
+);
+
+extern void miPutImage(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*depth*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ int /*leftPad*/,
+ int /*format*/,
+ char * /*pImage*/
+);
+
+/* miclipn.c */
+
+extern void miClipNotify(
+ void (* /*func*/)(
+ WindowPtr /* pWin */,
+ int /* dx */,
+ int /* dy */
+ )
+);
+
+/* micursor.c */
+
+extern void miRecolorCursor(
+ ScreenPtr /*pScr*/,
+ CursorPtr /*pCurs*/,
+ Bool /*displayed*/
+);
+
+/* midash.c */
+
+extern miDashPtr miDashLine(
+ int /*npt*/,
+ DDXPointPtr /*ppt*/,
+ unsigned int /*nDash*/,
+ unsigned char * /*pDash*/,
+ unsigned int /*offset*/,
+ int * /*pnseg*/
+);
+
+extern void miStepDash(
+ int /*dist*/,
+ int * /*pDashIndex*/,
+ unsigned char * /*pDash*/,
+ int /*numInDashList*/,
+ int * /*pDashOffset*/
+);
+
+/* mieq.c */
+
+
+#ifndef INPUT_H
+typedef struct _DeviceRec *DevicePtr;
+#endif
+
+extern Bool mieqInit(
+ DevicePtr /*pKbd*/,
+ DevicePtr /*pPtr*/
+);
+
+extern void mieqEnqueue(
+ xEventPtr /*e*/
+);
+
+extern void mieqSwitchScreen(
+ ScreenPtr /*pScreen*/,
+ Bool /*fromDIX*/
+);
+
+extern void mieqProcessInputEvents(
+ void
+);
+
+/* miexpose.c */
+
+extern RegionPtr miHandleExposures(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr /*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ unsigned long /*plane*/
+);
+
+extern void miSendGraphicsExpose(
+ ClientPtr /*client*/,
+ RegionPtr /*pRgn*/,
+ XID /*drawable*/,
+ int /*major*/,
+ int /*minor*/
+);
+
+extern void miSendExposures(
+ WindowPtr /*pWin*/,
+ RegionPtr /*pRgn*/,
+ int /*dx*/,
+ int /*dy*/
+);
+
+extern void miWindowExposures(
+ WindowPtr /*pWin*/,
+ RegionPtr /*prgn*/,
+ RegionPtr /*other_exposed*/
+);
+
+extern void miPaintWindow(
+ WindowPtr /*pWin*/,
+ RegionPtr /*prgn*/,
+ int /*what*/
+);
+
+extern void miClearDrawable(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/
+);
+
+/* mifillrct.c */
+
+extern void miPolyFillRect(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nrectFill*/,
+ xRectangle * /*prectInit*/
+);
+
+/* miglblt.c */
+
+extern void miPolyGlyphBlt(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+
+extern void miImageGlyphBlt(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+
+/* mipoly.c */
+
+extern void miFillPolygon(
+ DrawablePtr /*dst*/,
+ GCPtr /*pgc*/,
+ int /*shape*/,
+ int /*mode*/,
+ int /*count*/,
+ DDXPointPtr /*pPts*/
+);
+
+/* mipolycon.c */
+
+extern Bool miFillConvexPoly(
+ DrawablePtr /*dst*/,
+ GCPtr /*pgc*/,
+ int /*count*/,
+ DDXPointPtr /*ptsIn*/
+);
+
+/* mipolygen.c */
+
+extern Bool miFillGeneralPoly(
+ DrawablePtr /*dst*/,
+ GCPtr /*pgc*/,
+ int /*count*/,
+ DDXPointPtr /*ptsIn*/
+);
+
+/* mipolypnt.c */
+
+extern void miPolyPoint(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ xPoint * /*pptInit*/
+);
+
+/* mipolyrect.c */
+
+extern void miPolyRectangle(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*nrects*/,
+ xRectangle * /*pRects*/
+);
+
+/* mipolyseg.c */
+
+extern void miPolySegment(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSegs*/
+);
+
+/* mipolytext.c */
+
+extern int miPolyText(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ char * /*chars*/,
+ FontEncoding /*fontEncoding*/
+);
+
+extern int miPolyText8(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ char * /*chars*/
+);
+
+extern int miPolyText16(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ unsigned short * /*chars*/
+);
+
+extern int miImageText(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ char * /*chars*/,
+ FontEncoding /*fontEncoding*/
+);
+
+extern void miImageText8(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ char * /*chars*/
+);
+
+extern void miImageText16(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ unsigned short * /*chars*/
+);
+
+/* mipushpxl.c */
+
+extern void miPushPixels(
+ GCPtr /*pGC*/,
+ PixmapPtr /*pBitMap*/,
+ DrawablePtr /*pDrawable*/,
+ int /*dx*/,
+ int /*dy*/,
+ int /*xOrg*/,
+ int /*yOrg*/
+);
+
+/* miregion.c */
+
+/* see also region.h */
+
+extern Bool miRectAlloc(
+ RegionPtr /*pRgn*/,
+ int /*n*/
+);
+
+extern void miSetExtents(
+ RegionPtr /*pReg*/
+);
+
+extern int miFindMaxBand(
+ RegionPtr /*prgn*/
+);
+
+#ifdef DEBUG
+extern Bool miValidRegion(
+ RegionPtr /*prgn*/
+);
+#endif
+
+extern Bool miRegionDataCopy(RegionPtr dst, RegionPtr src);
+extern Bool miRegionBroken(RegionPtr pReg);
+
+/* miscrinit.c */
+
+extern Bool miModifyPixmapHeader(
+ PixmapPtr /*pPixmap*/,
+ int /*width*/,
+ int /*height*/,
+ int /*depth*/,
+ int /*bitsPerPixel*/,
+ int /*devKind*/,
+ pointer /*pPixData*/
+);
+
+extern Bool miCloseScreen(
+ int /*index*/,
+ ScreenPtr /*pScreen*/
+);
+
+extern Bool miCreateScreenResources(
+ ScreenPtr /*pScreen*/
+);
+
+extern Bool miScreenDevPrivateInit(
+ ScreenPtr /*pScreen*/,
+ int /*width*/,
+ pointer /*pbits*/
+);
+
+extern Bool miScreenInit(
+ ScreenPtr /*pScreen*/,
+ pointer /*pbits*/,
+ int /*xsize*/,
+ int /*ysize*/,
+ int /*dpix*/,
+ int /*dpiy*/,
+ int /*width*/,
+ int /*rootDepth*/,
+ int /*numDepths*/,
+ DepthPtr /*depths*/,
+ VisualID /*rootVisual*/,
+ int /*numVisuals*/,
+ VisualPtr /*visuals*/
+);
+
+extern int miAllocateGCPrivateIndex(
+ void
+);
+
+extern PixmapPtr miGetScreenPixmap(
+ ScreenPtr pScreen
+);
+
+extern void miSetScreenPixmap(
+ PixmapPtr pPix
+);
+
+/* mivaltree.c */
+
+extern int miShapedWindowIn(
+ ScreenPtr /*pScreen*/,
+ RegionPtr /*universe*/,
+ RegionPtr /*bounding*/,
+ BoxPtr /*rect*/,
+ int /*x*/,
+ int /*y*/
+);
+
+typedef void
+(*SetRedirectBorderClipProcPtr) (WindowPtr pWindow, RegionPtr pRegion);
+
+typedef RegionPtr
+(*GetRedirectBorderClipProcPtr) (WindowPtr pWindow);
+
+void
+miRegisterRedirectBorderClipProc (SetRedirectBorderClipProcPtr setBorderClip,
+ GetRedirectBorderClipProcPtr getBorderClip);
+
+extern int miValidateTree(
+ WindowPtr /*pParent*/,
+ WindowPtr /*pChild*/,
+ VTKind /*kind*/
+);
+
+extern void miWideLine(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pPts*/
+);
+
+extern void miWideDash(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pPts*/
+);
+
+extern void miMiter(
+ void
+);
+
+extern void miNotMiter(
+ void
+);
+
+/* miwindow.c */
+
+extern void miClearToBackground(
+ WindowPtr /*pWin*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ Bool /*generateExposures*/
+);
+
+extern Bool miChangeSaveUnder(
+ WindowPtr /*pWin*/,
+ WindowPtr /*first*/
+);
+
+extern void miPostChangeSaveUnder(
+ WindowPtr /*pWin*/,
+ WindowPtr /*pFirst*/
+);
+
+extern void miMarkWindow(
+ WindowPtr /*pWin*/
+);
+
+extern Bool miMarkOverlappedWindows(
+ WindowPtr /*pWin*/,
+ WindowPtr /*pFirst*/,
+ WindowPtr * /*ppLayerWin*/
+);
+
+extern void miHandleValidateExposures(
+ WindowPtr /*pWin*/
+);
+
+extern void miMoveWindow(
+ WindowPtr /*pWin*/,
+ int /*x*/,
+ int /*y*/,
+ WindowPtr /*pNextSib*/,
+ VTKind /*kind*/
+);
+
+extern void miSlideAndSizeWindow(
+ WindowPtr /*pWin*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*w*/,
+ unsigned int /*h*/,
+ WindowPtr /*pSib*/
+);
+
+extern WindowPtr miGetLayerWindow(
+ WindowPtr /*pWin*/
+);
+
+extern void miSetShape(
+ WindowPtr /*pWin*/
+);
+
+extern void miChangeBorderWidth(
+ WindowPtr /*pWin*/,
+ unsigned int /*width*/
+);
+
+extern void miMarkUnrealizedWindow(
+ WindowPtr /*pChild*/,
+ WindowPtr /*pWin*/,
+ Bool /*fromConfigure*/
+);
+
+extern void miSegregateChildren(WindowPtr pWin, RegionPtr pReg, int depth);
+
+/* mizerarc.c */
+
+extern void miZeroPolyArc(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+
+/* mizerline.c */
+
+extern void miZeroLine(
+ DrawablePtr /*dst*/,
+ GCPtr /*pgc*/,
+ int /*mode*/,
+ int /*nptInit*/,
+ DDXPointRec * /*pptInit*/
+);
+
+extern void miZeroDashLine(
+ DrawablePtr /*dst*/,
+ GCPtr /*pgc*/,
+ int /*mode*/,
+ int /*nptInit*/,
+ DDXPointRec * /*pptInit*/
+);
+
+extern void miPolyFillArc(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+
+#endif /* MI_H */
diff --git a/nx-X11/programs/Xserver/mi/miarc.c b/nx-X11/programs/Xserver/mi/miarc.c
new file mode 100644
index 000000000..08f09b628
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/miarc.c
@@ -0,0 +1,3723 @@
+/* $XdotOrg: xc/programs/Xserver/mi/miarc.c,v 1.6 2005/07/03 08:53:51 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/mi/miarc.c,v 3.14 2003/10/29 22:57:48 tsi Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: miarc.c,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ */
+/* Author: Keith Packard and Bob Scheifler */
+/* Warning: this code is toxic, do not dally very long here. */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#if defined(_XOPEN_SOURCE) || defined(__QNXNTO__) \
+ || (defined(sun) && defined(__SVR4))
+#include <math.h>
+#else
+#define _XOPEN_SOURCE /* to get prototype for hypot on some systems */
+#include <math.h>
+#undef _XOPEN_SOURCE
+#endif
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "misc.h"
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "mifpoly.h"
+#include "mi.h"
+#include "mifillarc.h"
+#include <X11/Xfuncproto.h>
+
+static double miDsin(double a);
+static double miDcos(double a);
+static double miDasin(double v);
+static double miDatan2(double dy, double dx);
+double cbrt(double);
+
+#ifdef ICEILTEMPDECL
+ICEILTEMPDECL
+#endif
+
+/*
+ * some interesting sematic interpretation of the protocol:
+ *
+ * Self intersecting arcs (i.e. those spanning 360 degrees)
+ * never join with other arcs, and are drawn without caps
+ * (unless on/off dashed, in which case each dash segment
+ * is capped, except when the last segment meets the
+ * first segment, when no caps are drawn)
+ *
+ * double dash arcs are drawn in two parts, first the
+ * odd dashes (drawn in background) then the even dashes
+ * (drawn in foreground). This means that overlapping
+ * sections of foreground/background are drawn twice,
+ * first in background then in foreground. The double-draw
+ * occurs even when the function uses the destination values
+ * (e.g. xor mode). This is the same way the wide-line
+ * code works and should be "fixed".
+ *
+ */
+
+#undef max
+#undef min
+
+#if defined (__GNUC__) && !defined (__STRICT_ANSI__)
+#define USE_INLINE
+#endif
+
+#ifdef USE_INLINE
+inline static const int max (const int x, const int y)
+{
+ return x>y? x:y;
+}
+
+inline static const int min (const int x, const int y)
+{
+ return x<y? x:y;
+}
+
+#else
+
+static int
+max (int x, int y)
+{
+ return x>y? x:y;
+}
+
+static int
+min (int x, int y)
+{
+ return x<y? x:y;
+}
+
+#endif
+
+struct bound {
+ double min, max;
+};
+
+struct ibound {
+ int min, max;
+};
+
+#define boundedLe(value, bounds)\
+ ((bounds).min <= (value) && (value) <= (bounds).max)
+
+struct line {
+ double m, b;
+ int valid;
+};
+
+#define intersectLine(y,line) (line.m * (y) + line.b)
+
+/*
+ * these are all y value bounds
+ */
+
+struct arc_bound {
+ struct bound ellipse;
+ struct bound inner;
+ struct bound outer;
+ struct bound right;
+ struct bound left;
+ struct ibound inneri;
+ struct ibound outeri;
+};
+
+struct accelerators {
+ double tail_y;
+ double h2;
+ double w2;
+ double h4;
+ double w4;
+ double h2mw2;
+ double h2l;
+ double w2l;
+ double fromIntX;
+ double fromIntY;
+ struct line left, right;
+ int yorgu;
+ int yorgl;
+ int xorg;
+};
+
+struct arc_def {
+ double w, h, l;
+ double a0, a1;
+};
+
+# define todeg(xAngle) (((double) (xAngle)) / 64.0)
+
+# define RIGHT_END 0
+# define LEFT_END 1
+
+typedef struct _miArcJoin {
+ int arcIndex0, arcIndex1;
+ int phase0, phase1;
+ int end0, end1;
+} miArcJoinRec, *miArcJoinPtr;
+
+typedef struct _miArcCap {
+ int arcIndex;
+ int end;
+} miArcCapRec, *miArcCapPtr;
+
+typedef struct _miArcFace {
+ SppPointRec clock;
+ SppPointRec center;
+ SppPointRec counterClock;
+} miArcFaceRec, *miArcFacePtr;
+
+typedef struct _miArcData {
+ xArc arc;
+ int render; /* non-zero means render after drawing */
+ int join; /* related join */
+ int cap; /* related cap */
+ int selfJoin; /* final dash meets first dash */
+ miArcFaceRec bounds[2];
+ double x0, y0, x1, y1;
+} miArcDataRec, *miArcDataPtr;
+
+/*
+ * This is an entire sequence of arcs, computed and categorized according
+ * to operation. miDashArcs generates either one or two of these.
+ */
+
+typedef struct _miPolyArc {
+ int narcs;
+ miArcDataPtr arcs;
+ int ncaps;
+ miArcCapPtr caps;
+ int njoins;
+ miArcJoinPtr joins;
+} miPolyArcRec, *miPolyArcPtr;
+
+#define GCValsFunction 0
+#define GCValsForeground 1
+#define GCValsBackground 2
+#define GCValsLineWidth 3
+#define GCValsCapStyle 4
+#define GCValsJoinStyle 5
+#define GCValsMask (GCFunction | GCForeground | GCBackground | \
+ GCLineWidth | GCCapStyle | GCJoinStyle)
+static CARD32 gcvals[6];
+
+static void fillSpans(DrawablePtr pDrawable, GCPtr pGC);
+static void newFinalSpan(int y, register int xmin, register int xmax);
+static void drawArc(xArc *tarc, int l, int a0, int a1, miArcFacePtr right,
+ miArcFacePtr left);
+static void drawZeroArc(DrawablePtr pDraw, GCPtr pGC, xArc *tarc, int lw,
+ miArcFacePtr left, miArcFacePtr right);
+static void miArcJoin(DrawablePtr pDraw, GCPtr pGC, miArcFacePtr pLeft,
+ miArcFacePtr pRight, int xOrgLeft, int yOrgLeft,
+ double xFtransLeft, double yFtransLeft,
+ int xOrgRight, int yOrgRight,
+ double xFtransRight, double yFtransRight);
+static void miArcCap(DrawablePtr pDraw, GCPtr pGC, miArcFacePtr pFace,
+ int end, int xOrg, int yOrg, double xFtrans,
+ double yFtrans);
+static void miRoundCap(DrawablePtr pDraw, GCPtr pGC, SppPointRec pCenter,
+ SppPointRec pEnd, SppPointRec pCorner,
+ SppPointRec pOtherCorner, int fLineEnd,
+ int xOrg, int yOrg, double xFtrans, double yFtrans);
+static void miFreeArcs(miPolyArcPtr arcs, GCPtr pGC);
+static miPolyArcPtr miComputeArcs(xArc *parcs, int narcs, GCPtr pGC);
+static int miGetArcPts(SppArcPtr parc, int cpt, SppPointPtr *ppPts);
+
+# define CUBED_ROOT_2 1.2599210498948732038115849718451499938964
+# define CUBED_ROOT_4 1.5874010519681993173435330390930175781250
+
+/*
+ * draw one segment of the arc using the arc spans generation routines
+ */
+
+static void
+miArcSegment(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ xArc tarc,
+ miArcFacePtr right,
+ miArcFacePtr left)
+{
+ int l = pGC->lineWidth;
+ int a0, a1, startAngle, endAngle;
+ miArcFacePtr temp;
+
+ if (!l)
+ l = 1;
+
+ if (tarc.width == 0 || tarc.height == 0) {
+ drawZeroArc (pDraw, pGC, &tarc, l, left, right);
+ return;
+ }
+
+ if (pGC->miTranslate) {
+ tarc.x += pDraw->x;
+ tarc.y += pDraw->y;
+ }
+
+ a0 = tarc.angle1;
+ a1 = tarc.angle2;
+ if (a1 > FULLCIRCLE)
+ a1 = FULLCIRCLE;
+ else if (a1 < -FULLCIRCLE)
+ a1 = -FULLCIRCLE;
+ if (a1 < 0) {
+ startAngle = a0 + a1;
+ endAngle = a0;
+ temp = right;
+ right = left;
+ left = temp;
+ } else {
+ startAngle = a0;
+ endAngle = a0 + a1;
+ }
+ /*
+ * bounds check the two angles
+ */
+ if (startAngle < 0)
+ startAngle = FULLCIRCLE - (-startAngle) % FULLCIRCLE;
+ if (startAngle >= FULLCIRCLE)
+ startAngle = startAngle % FULLCIRCLE;
+ if (endAngle < 0)
+ endAngle = FULLCIRCLE - (-endAngle) % FULLCIRCLE;
+ if (endAngle > FULLCIRCLE)
+ endAngle = (endAngle-1) % FULLCIRCLE + 1;
+ if ((startAngle == endAngle) && a1) {
+ startAngle = 0;
+ endAngle = FULLCIRCLE;
+ }
+
+ drawArc (&tarc, l, startAngle, endAngle, right, left);
+}
+
+/*
+
+Three equations combine to describe the boundaries of the arc
+
+x^2/w^2 + y^2/h^2 = 1 ellipse itself
+(X-x)^2 + (Y-y)^2 = r^2 circle at (x, y) on the ellipse
+(Y-y) = (X-x)*w^2*y/(h^2*x) normal at (x, y) on the ellipse
+
+These lead to a quartic relating Y and y
+
+y^4 - (2Y)y^3 + (Y^2 + (h^4 - w^2*r^2)/(w^2 - h^2))y^2
+ - (2Y*h^4/(w^2 - h^2))y + (Y^2*h^4)/(w^2 - h^2) = 0
+
+The reducible cubic obtained from this quartic is
+
+z^3 - (3N)z^2 - 2V = 0
+
+where
+
+N = (Y^2 + (h^4 - w^2*r^2/(w^2 - h^2)))/6
+V = w^2*r^2*Y^2*h^4/(4 *(w^2 - h^2)^2)
+
+Let
+
+t = z - N
+p = -N^2
+q = -N^3 - V
+
+Then we get
+
+t^3 + 3pt + 2q = 0
+
+The discriminant of this cubic is
+
+D = q^2 + p^3
+
+When D > 0, a real root is obtained as
+
+z = N + cbrt(-q+sqrt(D)) + cbrt(-q-sqrt(D))
+
+When D < 0, a real root is obtained as
+
+z = N - 2m*cos(acos(-q/m^3)/3)
+
+where
+
+m = sqrt(|p|) * sign(q)
+
+Given a real root Z of the cubic, the roots of the quartic are the roots
+of the two quadratics
+
+y^2 + ((b+A)/2)y + (Z + (bZ - d)/A) = 0
+
+where
+
+A = +/- sqrt(8Z + b^2 - 4c)
+b, c, d are the cubic, quadratic, and linear coefficients of the quartic
+
+Some experimentation is then required to determine which solutions
+correspond to the inner and outer boundaries.
+
+*/
+
+typedef struct {
+ short lx, lw, rx, rw;
+} miArcSpan;
+
+typedef struct {
+ miArcSpan *spans;
+ int count1, count2, k;
+ char top, bot, hole;
+} miArcSpanData;
+
+typedef struct {
+ unsigned long lrustamp;
+ unsigned short lw;
+ unsigned short width, height;
+ miArcSpanData *spdata;
+} arcCacheRec;
+
+#define CACHESIZE 25
+
+static void drawQuadrant(struct arc_def *def, struct accelerators *acc,
+ int a0, int a1, int mask, miArcFacePtr right,
+ miArcFacePtr left, miArcSpanData *spdata);
+
+static arcCacheRec arcCache[CACHESIZE];
+static unsigned long lrustamp;
+static arcCacheRec *lastCacheHit = &arcCache[0];
+static RESTYPE cacheType;
+
+/*
+ * External so it can be called when low on memory.
+ * Call with a zero ID in that case.
+ */
+/*ARGSUSED*/
+int
+miFreeArcCache (data, id)
+ pointer data;
+ XID id;
+{
+ int k;
+ arcCacheRec *cent;
+
+ if (id)
+ cacheType = 0;
+
+ for (k = CACHESIZE, cent = &arcCache[0]; --k >= 0; cent++)
+ {
+ if (cent->spdata)
+ {
+ cent->lrustamp = 0;
+ cent->lw = 0;
+ xfree(cent->spdata);
+ cent->spdata = NULL;
+ }
+ }
+ lrustamp = 0;
+ return Success;
+}
+
+static void
+miComputeCircleSpans(
+ int lw,
+ xArc *parc,
+ miArcSpanData *spdata)
+{
+ register miArcSpan *span;
+ int doinner;
+ register int x, y, e;
+ int xk, yk, xm, ym, dx, dy;
+ register int slw, inslw;
+ int inx = 0, iny, ine = 0;
+ int inxk = 0, inyk = 0, inxm = 0, inym = 0;
+
+ doinner = -lw;
+ slw = parc->width - doinner;
+ y = parc->height >> 1;
+ dy = parc->height & 1;
+ dx = 1 - dy;
+ MIWIDEARCSETUP(x, y, dy, slw, e, xk, xm, yk, ym);
+ inslw = parc->width + doinner;
+ if (inslw > 0)
+ {
+ spdata->hole = spdata->top;
+ MIWIDEARCSETUP(inx, iny, dy, inslw, ine, inxk, inxm, inyk, inym);
+ }
+ else
+ {
+ spdata->hole = FALSE;
+ doinner = -y;
+ }
+ spdata->count1 = -doinner - spdata->top;
+ spdata->count2 = y + doinner;
+ span = spdata->spans;
+ while (y)
+ {
+ MIFILLARCSTEP(slw);
+ span->lx = dy - x;
+ if (++doinner <= 0)
+ {
+ span->lw = slw;
+ span->rx = 0;
+ span->rw = span->lx + slw;
+ }
+ else
+ {
+ MIFILLINARCSTEP(inslw);
+ span->lw = x - inx;
+ span->rx = dy - inx + inslw;
+ span->rw = inx - x + slw - inslw;
+ }
+ span++;
+ }
+ if (spdata->bot)
+ {
+ if (spdata->count2)
+ spdata->count2--;
+ else
+ {
+ if (lw > (int)parc->height)
+ span[-1].rx = span[-1].rw = -((lw - (int)parc->height) >> 1);
+ else
+ span[-1].rw = 0;
+ spdata->count1--;
+ }
+ }
+}
+
+static void
+miComputeEllipseSpans(
+ int lw,
+ xArc *parc,
+ miArcSpanData *spdata)
+{
+ register miArcSpan *span;
+ double w, h, r, xorg;
+ double Hs, Hf, WH, K, Vk, Nk, Fk, Vr, N, Nc, Z, rs;
+ double A, T, b, d, x, y, t, inx, outx = 0.0, hepp, hepm;
+ int flip, solution;
+
+ w = (double)parc->width / 2.0;
+ h = (double)parc->height / 2.0;
+ r = lw / 2.0;
+ rs = r * r;
+ Hs = h * h;
+ WH = w * w - Hs;
+ Nk = w * r;
+ Vk = (Nk * Hs) / (WH + WH);
+ Hf = Hs * Hs;
+ Nk = (Hf - Nk * Nk) / WH;
+ Fk = Hf / WH;
+ hepp = h + EPSILON;
+ hepm = h - EPSILON;
+ K = h + ((lw - 1) >> 1);
+ span = spdata->spans;
+ if (parc->width & 1)
+ xorg = .5;
+ else
+ xorg = 0.0;
+ if (spdata->top)
+ {
+ span->lx = 0;
+ span->lw = 1;
+ span++;
+ }
+ spdata->count1 = 0;
+ spdata->count2 = 0;
+ spdata->hole = (spdata->top &&
+ (int)parc->height * lw <= (int)(parc->width * parc->width) &&
+ lw < (int)parc->height);
+ for (; K > 0.0; K -= 1.0)
+ {
+ N = (K * K + Nk) / 6.0;
+ Nc = N * N * N;
+ Vr = Vk * K;
+ t = Nc + Vr * Vr;
+ d = Nc + t;
+ if (d < 0.0) {
+ d = Nc;
+ b = N;
+ if ( (b < 0.0) == (t < 0.0) )
+ {
+ b = -b;
+ d = -d;
+ }
+ Z = N - 2.0 * b * cos(acos(-t / d) / 3.0);
+ if ( (Z < 0.0) == (Vr < 0.0) )
+ flip = 2;
+ else
+ flip = 1;
+ }
+ else
+ {
+ d = Vr * sqrt(d);
+ Z = N + cbrt(t + d) + cbrt(t - d);
+ flip = 0;
+ }
+ A = sqrt((Z + Z) - Nk);
+ T = (Fk - Z) * K / A;
+ inx = 0.0;
+ solution = FALSE;
+ b = -A + K;
+ d = b * b - 4 * (Z + T);
+ if (d >= 0)
+ {
+ d = sqrt(d);
+ y = (b + d) / 2;
+ if ((y >= 0.0) && (y < hepp))
+ {
+ solution = TRUE;
+ if (y > hepm)
+ y = h;
+ t = y / h;
+ x = w * sqrt(1 - (t * t));
+ t = K - y;
+ if (rs - (t * t) >= 0)
+ t = sqrt(rs - (t * t));
+ else
+ t = 0;
+ if (flip == 2)
+ inx = x - t;
+ else
+ outx = x + t;
+ }
+ }
+ b = A + K;
+ d = b * b - 4 * (Z - T);
+ /* Because of the large magnitudes involved, we lose enough precision
+ * that sometimes we end up with a negative value near the axis, when
+ * it should be positive. This is a workaround.
+ */
+ if (d < 0 && !solution)
+ d = 0.0;
+ if (d >= 0) {
+ d = sqrt(d);
+ y = (b + d) / 2;
+ if (y < hepp)
+ {
+ if (y > hepm)
+ y = h;
+ t = y / h;
+ x = w * sqrt(1 - (t * t));
+ t = K - y;
+ if (rs - (t * t) >= 0)
+ inx = x - sqrt(rs - (t * t));
+ else
+ inx = x;
+ }
+ y = (b - d) / 2;
+ if (y >= 0.0)
+ {
+ if (y > hepm)
+ y = h;
+ t = y / h;
+ x = w * sqrt(1 - (t * t));
+ t = K - y;
+ if (rs - (t * t) >= 0)
+ t = sqrt(rs - (t * t));
+ else
+ t = 0;
+ if (flip == 1)
+ inx = x - t;
+ else
+ outx = x + t;
+ }
+ }
+ span->lx = ICEIL(xorg - outx);
+ if (inx <= 0.0)
+ {
+ spdata->count1++;
+ span->lw = ICEIL(xorg + outx) - span->lx;
+ span->rx = ICEIL(xorg + inx);
+ span->rw = -ICEIL(xorg - inx);
+ }
+ else
+ {
+ spdata->count2++;
+ span->lw = ICEIL(xorg - inx) - span->lx;
+ span->rx = ICEIL(xorg + inx);
+ span->rw = ICEIL(xorg + outx) - span->rx;
+ }
+ span++;
+ }
+ if (spdata->bot)
+ {
+ outx = w + r;
+ if (r >= h && r <= w)
+ inx = 0.0;
+ else if (Nk < 0.0 && -Nk < Hs)
+ {
+ inx = w * sqrt(1 + Nk / Hs) - sqrt(rs + Nk);
+ if (inx > w - r)
+ inx = w - r;
+ }
+ else
+ inx = w - r;
+ span->lx = ICEIL(xorg - outx);
+ if (inx <= 0.0)
+ {
+ span->lw = ICEIL(xorg + outx) - span->lx;
+ span->rx = ICEIL(xorg + inx);
+ span->rw = -ICEIL(xorg - inx);
+ }
+ else
+ {
+ span->lw = ICEIL(xorg - inx) - span->lx;
+ span->rx = ICEIL(xorg + inx);
+ span->rw = ICEIL(xorg + outx) - span->rx;
+ }
+ }
+ if (spdata->hole)
+ {
+ span = &spdata->spans[spdata->count1];
+ span->lw = -span->lx;
+ span->rx = 1;
+ span->rw = span->lw;
+ spdata->count1--;
+ spdata->count2++;
+ }
+}
+
+static double
+tailX(
+ double K,
+ struct arc_def *def,
+ struct arc_bound *bounds,
+ struct accelerators *acc)
+{
+ double w, h, r;
+ double Hs, Hf, WH, Vk, Nk, Fk, Vr, N, Nc, Z, rs;
+ double A, T, b, d, x, y, t, hepp, hepm;
+ int flip, solution;
+ double xs[2];
+ double *xp;
+
+ w = def->w;
+ h = def->h;
+ r = def->l;
+ rs = r * r;
+ Hs = acc->h2;
+ WH = -acc->h2mw2;
+ Nk = def->w * r;
+ Vk = (Nk * Hs) / (WH + WH);
+ Hf = acc->h4;
+ Nk = (Hf - Nk * Nk) / WH;
+ if (K == 0.0) {
+ if (Nk < 0.0 && -Nk < Hs) {
+ xs[0] = w * sqrt(1 + Nk / Hs) - sqrt(rs + Nk);
+ xs[1] = w - r;
+ if (acc->left.valid && boundedLe(K, bounds->left) &&
+ !boundedLe(K, bounds->outer) && xs[0] >= 0.0 && xs[1] >= 0.0)
+ return xs[1];
+ if (acc->right.valid && boundedLe(K, bounds->right) &&
+ !boundedLe(K, bounds->inner) && xs[0] <= 0.0 && xs[1] <= 0.0)
+ return xs[1];
+ return xs[0];
+ }
+ return w - r;
+ }
+ Fk = Hf / WH;
+ hepp = h + EPSILON;
+ hepm = h - EPSILON;
+ N = (K * K + Nk) / 6.0;
+ Nc = N * N * N;
+ Vr = Vk * K;
+ xp = xs;
+ xs[0] = 0.0;
+ t = Nc + Vr * Vr;
+ d = Nc + t;
+ if (d < 0.0) {
+ d = Nc;
+ b = N;
+ if ( (b < 0.0) == (t < 0.0) )
+ {
+ b = -b;
+ d = -d;
+ }
+ Z = N - 2.0 * b * cos(acos(-t / d) / 3.0);
+ if ( (Z < 0.0) == (Vr < 0.0) )
+ flip = 2;
+ else
+ flip = 1;
+ }
+ else
+ {
+ d = Vr * sqrt(d);
+ Z = N + cbrt(t + d) + cbrt(t - d);
+ flip = 0;
+ }
+ A = sqrt((Z + Z) - Nk);
+ T = (Fk - Z) * K / A;
+ solution = FALSE;
+ b = -A + K;
+ d = b * b - 4 * (Z + T);
+ if (d >= 0 && flip == 2)
+ {
+ d = sqrt(d);
+ y = (b + d) / 2;
+ if ((y >= 0.0) && (y < hepp))
+ {
+ solution = TRUE;
+ if (y > hepm)
+ y = h;
+ t = y / h;
+ x = w * sqrt(1 - (t * t));
+ t = K - y;
+ if (rs - (t * t) >= 0)
+ t = sqrt(rs - (t * t));
+ else
+ t = 0;
+ *xp++ = x - t;
+ }
+ }
+ b = A + K;
+ d = b * b - 4 * (Z - T);
+ /* Because of the large magnitudes involved, we lose enough precision
+ * that sometimes we end up with a negative value near the axis, when
+ * it should be positive. This is a workaround.
+ */
+ if (d < 0 && !solution)
+ d = 0.0;
+ if (d >= 0) {
+ d = sqrt(d);
+ y = (b + d) / 2;
+ if (y < hepp)
+ {
+ if (y > hepm)
+ y = h;
+ t = y / h;
+ x = w * sqrt(1 - (t * t));
+ t = K - y;
+ if (rs - (t * t) >= 0)
+ *xp++ = x - sqrt(rs - (t * t));
+ else
+ *xp++ = x;
+ }
+ y = (b - d) / 2;
+ if (y >= 0.0 && flip == 1)
+ {
+ if (y > hepm)
+ y = h;
+ t = y / h;
+ x = w * sqrt(1 - (t * t));
+ t = K - y;
+ if (rs - (t * t) >= 0)
+ t = sqrt(rs - (t * t));
+ else
+ t = 0;
+ *xp++ = x - t;
+ }
+ }
+ if (xp > &xs[1]) {
+ if (acc->left.valid && boundedLe(K, bounds->left) &&
+ !boundedLe(K, bounds->outer) && xs[0] >= 0.0 && xs[1] >= 0.0)
+ return xs[1];
+ if (acc->right.valid && boundedLe(K, bounds->right) &&
+ !boundedLe(K, bounds->inner) && xs[0] <= 0.0 && xs[1] <= 0.0)
+ return xs[1];
+ }
+ return xs[0];
+}
+
+static miArcSpanData *
+miComputeWideEllipse(
+ int lw,
+ register xArc *parc,
+ Bool *mustFree)
+{
+ register miArcSpanData *spdata;
+ register arcCacheRec *cent, *lruent;
+ register int k;
+ arcCacheRec fakeent;
+
+ if (!lw)
+ lw = 1;
+ if (parc->height <= 1500)
+ {
+ *mustFree = FALSE;
+ cent = lastCacheHit;
+ if (cent->lw == lw &&
+ cent->width == parc->width && cent->height == parc->height)
+ {
+ cent->lrustamp = ++lrustamp;
+ return cent->spdata;
+ }
+ lruent = &arcCache[0];
+ for (k = CACHESIZE, cent = lruent; --k >= 0; cent++)
+ {
+ if (cent->lw == lw &&
+ cent->width == parc->width && cent->height == parc->height)
+ {
+ cent->lrustamp = ++lrustamp;
+ lastCacheHit = cent;
+ return cent->spdata;
+ }
+ if (cent->lrustamp < lruent->lrustamp)
+ lruent = cent;
+ }
+ if (!cacheType)
+ {
+ cacheType = CreateNewResourceType(miFreeArcCache);
+ (void) AddResource(FakeClientID(0), cacheType, NULL);
+ }
+ } else {
+ lruent = &fakeent;
+ lruent->spdata = NULL;
+ *mustFree = TRUE;
+ }
+ k = (parc->height >> 1) + ((lw - 1) >> 1);
+ spdata = lruent->spdata;
+ if (!spdata || spdata->k != k)
+ {
+ if (spdata)
+ xfree(spdata);
+ spdata = (miArcSpanData *)xalloc(sizeof(miArcSpanData) +
+ sizeof(miArcSpan) * (k + 2));
+ lruent->spdata = spdata;
+ if (!spdata)
+ {
+ lruent->lrustamp = 0;
+ lruent->lw = 0;
+ return spdata;
+ }
+ spdata->spans = (miArcSpan *)(spdata + 1);
+ spdata->k = k;
+ }
+ spdata->top = !(lw & 1) && !(parc->width & 1);
+ spdata->bot = !(parc->height & 1);
+ lruent->lrustamp = ++lrustamp;
+ lruent->lw = lw;
+ lruent->width = parc->width;
+ lruent->height = parc->height;
+ if (lruent != &fakeent)
+ lastCacheHit = lruent;
+ if (parc->width == parc->height)
+ miComputeCircleSpans(lw, parc, spdata);
+ else
+ miComputeEllipseSpans(lw, parc, spdata);
+ return spdata;
+}
+
+static void
+miFillWideEllipse(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ xArc *parc)
+{
+ DDXPointPtr points;
+ register DDXPointPtr pts;
+ int *widths;
+ register int *wids;
+ miArcSpanData *spdata;
+ Bool mustFree;
+ register miArcSpan *span;
+ register int xorg, yorgu, yorgl;
+ register int n;
+
+ yorgu = parc->height + pGC->lineWidth;
+ n = (sizeof(int) * 2) * yorgu;
+ widths = (int *)ALLOCATE_LOCAL(n + (sizeof(DDXPointRec) * 2) * yorgu);
+ if (!widths)
+ return;
+ points = (DDXPointPtr)((char *)widths + n);
+ spdata = miComputeWideEllipse((int)pGC->lineWidth, parc, &mustFree);
+ if (!spdata)
+ {
+ DEALLOCATE_LOCAL(widths);
+ return;
+ }
+ pts = points;
+ wids = widths;
+ span = spdata->spans;
+ xorg = parc->x + (parc->width >> 1);
+ yorgu = parc->y + (parc->height >> 1);
+ yorgl = yorgu + (parc->height & 1);
+ if (pGC->miTranslate)
+ {
+ xorg += pDraw->x;
+ yorgu += pDraw->y;
+ yorgl += pDraw->y;
+ }
+ yorgu -= spdata->k;
+ yorgl += spdata->k;
+ if (spdata->top)
+ {
+ pts->x = xorg;
+ pts->y = yorgu - 1;
+ pts++;
+ *wids++ = 1;
+ span++;
+ }
+ for (n = spdata->count1; --n >= 0; )
+ {
+ pts[0].x = xorg + span->lx;
+ pts[0].y = yorgu;
+ wids[0] = span->lw;
+ pts[1].x = pts[0].x;
+ pts[1].y = yorgl;
+ wids[1] = wids[0];
+ yorgu++;
+ yorgl--;
+ pts += 2;
+ wids += 2;
+ span++;
+ }
+ if (spdata->hole)
+ {
+ pts[0].x = xorg;
+ pts[0].y = yorgl;
+ wids[0] = 1;
+ pts++;
+ wids++;
+ }
+ for (n = spdata->count2; --n >= 0; )
+ {
+ pts[0].x = xorg + span->lx;
+ pts[0].y = yorgu;
+ wids[0] = span->lw;
+ pts[1].x = xorg + span->rx;
+ pts[1].y = pts[0].y;
+ wids[1] = span->rw;
+ pts[2].x = pts[0].x;
+ pts[2].y = yorgl;
+ wids[2] = wids[0];
+ pts[3].x = pts[1].x;
+ pts[3].y = pts[2].y;
+ wids[3] = wids[1];
+ yorgu++;
+ yorgl--;
+ pts += 4;
+ wids += 4;
+ span++;
+ }
+ if (spdata->bot)
+ {
+ if (span->rw <= 0)
+ {
+ pts[0].x = xorg + span->lx;
+ pts[0].y = yorgu;
+ wids[0] = span->lw;
+ pts++;
+ wids++;
+ }
+ else
+ {
+ pts[0].x = xorg + span->lx;
+ pts[0].y = yorgu;
+ wids[0] = span->lw;
+ pts[1].x = xorg + span->rx;
+ pts[1].y = pts[0].y;
+ wids[1] = span->rw;
+ pts += 2;
+ wids += 2;
+ }
+ }
+ if (mustFree)
+ xfree(spdata);
+ (*pGC->ops->FillSpans)(pDraw, pGC, pts - points, points, widths, FALSE);
+
+ DEALLOCATE_LOCAL(widths);
+}
+
+/*
+ * miPolyArc strategy:
+ *
+ * If arc is zero width and solid, we don't have to worry about the rasterop
+ * or join styles. For wide solid circles, we use a fast integer algorithm.
+ * For wide solid ellipses, we use special case floating point code.
+ * Otherwise, we set up pDrawTo and pGCTo according to the rasterop, then
+ * draw using pGCTo and pDrawTo. If the raster-op was "tricky," that is,
+ * if it involves the destination, then we use PushPixels to move the bits
+ * from the scratch drawable to pDraw. (See the wide line code for a
+ * fuller explanation of this.)
+ */
+
+void
+miPolyArc(pDraw, pGC, narcs, parcs)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int narcs;
+ xArc *parcs;
+{
+ register int i;
+ xArc *parc;
+ int xMin, xMax, yMin, yMax;
+ int pixmapWidth = 0, pixmapHeight = 0;
+ int xOrg = 0, yOrg = 0;
+ int width;
+ Bool fTricky;
+ DrawablePtr pDrawTo;
+ CARD32 fg, bg;
+ GCPtr pGCTo;
+ miPolyArcPtr polyArcs;
+ int cap[2], join[2];
+ int iphase;
+ int halfWidth;
+
+ width = pGC->lineWidth;
+ if(width == 0 && pGC->lineStyle == LineSolid)
+ {
+ for(i = narcs, parc = parcs; --i >= 0; parc++)
+ miArcSegment( pDraw, pGC, *parc,
+ (miArcFacePtr) 0, (miArcFacePtr) 0 );
+ fillSpans (pDraw, pGC);
+ }
+ else
+ {
+ if ((pGC->lineStyle == LineSolid) && narcs)
+ {
+ while (parcs->width && parcs->height &&
+ (parcs->angle2 >= FULLCIRCLE ||
+ parcs->angle2 <= -FULLCIRCLE))
+ {
+ miFillWideEllipse(pDraw, pGC, parcs);
+ if (!--narcs)
+ return;
+ parcs++;
+ }
+ }
+
+ /* Set up pDrawTo and pGCTo based on the rasterop */
+ switch(pGC->alu)
+ {
+ case GXclear: /* 0 */
+ case GXcopy: /* src */
+ case GXcopyInverted: /* NOT src */
+ case GXset: /* 1 */
+ fTricky = FALSE;
+ pDrawTo = pDraw;
+ pGCTo = pGC;
+ break;
+ default:
+ fTricky = TRUE;
+
+ /* find bounding box around arcs */
+ xMin = yMin = MAXSHORT;
+ xMax = yMax = MINSHORT;
+
+ for(i = narcs, parc = parcs; --i >= 0; parc++)
+ {
+ xMin = min (xMin, parc->x);
+ yMin = min (yMin, parc->y);
+ xMax = max (xMax, (parc->x + (int) parc->width));
+ yMax = max (yMax, (parc->y + (int) parc->height));
+ }
+
+ /* expand box to deal with line widths */
+ halfWidth = (width + 1)/2;
+ xMin -= halfWidth;
+ yMin -= halfWidth;
+ xMax += halfWidth;
+ yMax += halfWidth;
+
+ /* compute pixmap size; limit it to size of drawable */
+ xOrg = max(xMin, 0);
+ yOrg = max(yMin, 0);
+ pixmapWidth = min(xMax, pDraw->width) - xOrg;
+ pixmapHeight = min(yMax, pDraw->height) - yOrg;
+
+ /* if nothing left, return */
+ if ( (pixmapWidth <= 0) || (pixmapHeight <= 0) ) return;
+
+ for(i = narcs, parc = parcs; --i >= 0; parc++)
+ {
+ parc->x -= xOrg;
+ parc->y -= yOrg;
+ }
+ if (pGC->miTranslate)
+ {
+ xOrg += pDraw->x;
+ yOrg += pDraw->y;
+ }
+
+ /* set up scratch GC */
+
+ pGCTo = GetScratchGC(1, pDraw->pScreen);
+ if (!pGCTo)
+ return;
+ gcvals[GCValsFunction] = GXcopy;
+ gcvals[GCValsForeground] = 1;
+ gcvals[GCValsBackground] = 0;
+ gcvals[GCValsLineWidth] = pGC->lineWidth;
+ gcvals[GCValsCapStyle] = pGC->capStyle;
+ gcvals[GCValsJoinStyle] = pGC->joinStyle;
+ dixChangeGC(NullClient, pGCTo, GCValsMask, gcvals, NULL);
+
+ /* allocate a 1 bit deep pixmap of the appropriate size, and
+ * validate it */
+ pDrawTo = (DrawablePtr)(*pDraw->pScreen->CreatePixmap)
+ (pDraw->pScreen, pixmapWidth, pixmapHeight, 1);
+ if (!pDrawTo)
+ {
+ FreeScratchGC(pGCTo);
+ return;
+ }
+ ValidateGC(pDrawTo, pGCTo);
+ miClearDrawable(pDrawTo, pGCTo);
+ }
+
+ fg = pGC->fgPixel;
+ bg = pGC->bgPixel;
+ if ((pGC->fillStyle == FillTiled) ||
+ (pGC->fillStyle == FillOpaqueStippled))
+ bg = fg; /* the protocol sez these don't cause color changes */
+
+ polyArcs = miComputeArcs (parcs, narcs, pGC);
+
+ if (!polyArcs)
+ {
+ if (fTricky) {
+ (*pDraw->pScreen->DestroyPixmap) ((PixmapPtr)pDrawTo);
+ FreeScratchGC (pGCTo);
+ }
+ return;
+ }
+
+ cap[0] = cap[1] = 0;
+ join[0] = join[1] = 0;
+ for (iphase = ((pGC->lineStyle == LineDoubleDash) ? 1 : 0);
+ iphase >= 0;
+ iphase--)
+ {
+ if (iphase == 1) {
+ dixChangeGC (NullClient, pGC, GCForeground, &bg, NULL);
+ ValidateGC (pDraw, pGC);
+ } else if (pGC->lineStyle == LineDoubleDash) {
+ dixChangeGC (NullClient, pGC, GCForeground, &fg, NULL);
+ ValidateGC (pDraw, pGC);
+ }
+ for (i = 0; i < polyArcs[iphase].narcs; i++) {
+ miArcDataPtr arcData;
+
+ arcData = &polyArcs[iphase].arcs[i];
+ miArcSegment(pDrawTo, pGCTo, arcData->arc,
+ &arcData->bounds[RIGHT_END],
+ &arcData->bounds[LEFT_END]);
+ if (polyArcs[iphase].arcs[i].render) {
+ fillSpans (pDrawTo, pGCTo);
+ /*
+ * don't cap self-joining arcs
+ */
+ if (polyArcs[iphase].arcs[i].selfJoin &&
+ cap[iphase] < polyArcs[iphase].arcs[i].cap)
+ cap[iphase]++;
+ while (cap[iphase] < polyArcs[iphase].arcs[i].cap) {
+ int arcIndex, end;
+ miArcDataPtr arcData0;
+
+ arcIndex = polyArcs[iphase].caps[cap[iphase]].arcIndex;
+ end = polyArcs[iphase].caps[cap[iphase]].end;
+ arcData0 = &polyArcs[iphase].arcs[arcIndex];
+ miArcCap (pDrawTo, pGCTo,
+ &arcData0->bounds[end], end,
+ arcData0->arc.x, arcData0->arc.y,
+ (double) arcData0->arc.width / 2.0,
+ (double) arcData0->arc.height / 2.0);
+ ++cap[iphase];
+ }
+ while (join[iphase] < polyArcs[iphase].arcs[i].join) {
+ int arcIndex0, arcIndex1, end0, end1;
+ int phase0, phase1;
+ miArcDataPtr arcData0, arcData1;
+ miArcJoinPtr joinp;
+
+ joinp = &polyArcs[iphase].joins[join[iphase]];
+ arcIndex0 = joinp->arcIndex0;
+ end0 = joinp->end0;
+ arcIndex1 = joinp->arcIndex1;
+ end1 = joinp->end1;
+ phase0 = joinp->phase0;
+ phase1 = joinp->phase1;
+ arcData0 = &polyArcs[phase0].arcs[arcIndex0];
+ arcData1 = &polyArcs[phase1].arcs[arcIndex1];
+ miArcJoin (pDrawTo, pGCTo,
+ &arcData0->bounds[end0],
+ &arcData1->bounds[end1],
+ arcData0->arc.x, arcData0->arc.y,
+ (double) arcData0->arc.width / 2.0,
+ (double) arcData0->arc.height / 2.0,
+ arcData1->arc.x, arcData1->arc.y,
+ (double) arcData1->arc.width / 2.0,
+ (double) arcData1->arc.height / 2.0);
+ ++join[iphase];
+ }
+ if (fTricky) {
+ if (pGC->serialNumber != pDraw->serialNumber)
+ ValidateGC (pDraw, pGC);
+ (*pGC->ops->PushPixels) (pGC, (PixmapPtr)pDrawTo,
+ pDraw, pixmapWidth, pixmapHeight, xOrg, yOrg);
+ miClearDrawable ((DrawablePtr) pDrawTo, pGCTo);
+ }
+ }
+ }
+ }
+ miFreeArcs(polyArcs, pGC);
+
+ if(fTricky)
+ {
+ (*pGCTo->pScreen->DestroyPixmap)((PixmapPtr)pDrawTo);
+ FreeScratchGC(pGCTo);
+ }
+ }
+}
+
+static double
+angleBetween (SppPointRec center, SppPointRec point1, SppPointRec point2)
+{
+ double a1, a2, a;
+
+ /*
+ * reflect from X coordinates back to ellipse
+ * coordinates -- y increasing upwards
+ */
+ a1 = miDatan2 (- (point1.y - center.y), point1.x - center.x);
+ a2 = miDatan2 (- (point2.y - center.y), point2.x - center.x);
+ a = a2 - a1;
+ if (a <= -180.0)
+ a += 360.0;
+ else if (a > 180.0)
+ a -= 360.0;
+ return a;
+}
+
+static void
+translateBounds (
+ miArcFacePtr b,
+ int x,
+ int y,
+ double fx,
+ double fy)
+{
+ fx += x;
+ fy += y;
+ b->clock.x -= fx;
+ b->clock.y -= fy;
+ b->center.x -= fx;
+ b->center.y -= fy;
+ b->counterClock.x -= fx;
+ b->counterClock.y -= fy;
+}
+
+static void
+miArcJoin(DrawablePtr pDraw, GCPtr pGC, miArcFacePtr pLeft,
+ miArcFacePtr pRight, int xOrgLeft, int yOrgLeft,
+ double xFtransLeft, double yFtransLeft,
+ int xOrgRight, int yOrgRight,
+ double xFtransRight, double yFtransRight)
+{
+ SppPointRec center, corner, otherCorner;
+ SppPointRec poly[5], e;
+ SppPointPtr pArcPts;
+ int cpt;
+ SppArcRec arc;
+ miArcFaceRec Right, Left;
+ int polyLen = 0;
+ int xOrg, yOrg;
+ double xFtrans, yFtrans;
+ double a;
+ double ae, ac2, ec2, bc2, de;
+ double width;
+
+ xOrg = (xOrgRight + xOrgLeft) / 2;
+ yOrg = (yOrgRight + yOrgLeft) / 2;
+ xFtrans = (xFtransLeft + xFtransRight) / 2;
+ yFtrans = (yFtransLeft + yFtransRight) / 2;
+ Right = *pRight;
+ translateBounds (&Right, xOrg - xOrgRight, yOrg - yOrgRight,
+ xFtrans - xFtransRight, yFtrans - yFtransRight);
+ Left = *pLeft;
+ translateBounds (&Left, xOrg - xOrgLeft, yOrg - yOrgLeft,
+ xFtrans - xFtransLeft, yFtrans - yFtransLeft);
+ pRight = &Right;
+ pLeft = &Left;
+
+ if (pRight->clock.x == pLeft->counterClock.x &&
+ pRight->clock.y == pLeft->counterClock.y)
+ return;
+ center = pRight->center;
+ if (0 <= (a = angleBetween (center, pRight->clock, pLeft->counterClock))
+ && a <= 180.0)
+ {
+ corner = pRight->clock;
+ otherCorner = pLeft->counterClock;
+ } else {
+ a = angleBetween (center, pLeft->clock, pRight->counterClock);
+ corner = pLeft->clock;
+ otherCorner = pRight->counterClock;
+ }
+ switch (pGC->joinStyle) {
+ case JoinRound:
+ width = (pGC->lineWidth ? (double)pGC->lineWidth : (double)1);
+
+ arc.x = center.x - width/2;
+ arc.y = center.y - width/2;
+ arc.width = width;
+ arc.height = width;
+ arc.angle1 = -miDatan2 (corner.y - center.y, corner.x - center.x);
+ arc.angle2 = a;
+ pArcPts = (SppPointPtr) xalloc (3 * sizeof (SppPointRec));
+ if (!pArcPts)
+ return;
+ pArcPts[0].x = otherCorner.x;
+ pArcPts[0].y = otherCorner.y;
+ pArcPts[1].x = center.x;
+ pArcPts[1].y = center.y;
+ pArcPts[2].x = corner.x;
+ pArcPts[2].y = corner.y;
+ if( (cpt = miGetArcPts(&arc, 3, &pArcPts)) )
+ {
+ /* by drawing with miFillSppPoly and setting the endpoints of the arc
+ * to be the corners, we assure that the cap will meet up with the
+ * rest of the line */
+ miFillSppPoly(pDraw, pGC, cpt, pArcPts, xOrg, yOrg, xFtrans, yFtrans);
+ }
+ xfree(pArcPts);
+ return;
+ case JoinMiter:
+ /*
+ * don't miter arcs with less than 11 degrees between them
+ */
+ if (a < 169.0) {
+ poly[0] = corner;
+ poly[1] = center;
+ poly[2] = otherCorner;
+ bc2 = (corner.x - otherCorner.x) * (corner.x - otherCorner.x) +
+ (corner.y - otherCorner.y) * (corner.y - otherCorner.y);
+ ec2 = bc2 / 4;
+ ac2 = (corner.x - center.x) * (corner.x - center.x) +
+ (corner.y - center.y) * (corner.y - center.y);
+ ae = sqrt (ac2 - ec2);
+ de = ec2 / ae;
+ e.x = (corner.x + otherCorner.x) / 2;
+ e.y = (corner.y + otherCorner.y) / 2;
+ poly[3].x = e.x + de * (e.x - center.x) / ae;
+ poly[3].y = e.y + de * (e.y - center.y) / ae;
+ poly[4] = corner;
+ polyLen = 5;
+ break;
+ }
+ case JoinBevel:
+ poly[0] = corner;
+ poly[1] = center;
+ poly[2] = otherCorner;
+ poly[3] = corner;
+ polyLen = 4;
+ break;
+ }
+ miFillSppPoly (pDraw, pGC, polyLen, poly, xOrg, yOrg, xFtrans, yFtrans);
+}
+
+/*ARGSUSED*/
+static void
+miArcCap (
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ miArcFacePtr pFace,
+ int end,
+ int xOrg,
+ int yOrg,
+ double xFtrans,
+ double yFtrans)
+{
+ SppPointRec corner, otherCorner, center, endPoint, poly[5];
+
+ corner = pFace->clock;
+ otherCorner = pFace->counterClock;
+ center = pFace->center;
+ switch (pGC->capStyle) {
+ case CapProjecting:
+ poly[0].x = otherCorner.x;
+ poly[0].y = otherCorner.y;
+ poly[1].x = corner.x;
+ poly[1].y = corner.y;
+ poly[2].x = corner.x -
+ (center.y - corner.y);
+ poly[2].y = corner.y +
+ (center.x - corner.x);
+ poly[3].x = otherCorner.x -
+ (otherCorner.y - center.y);
+ poly[3].y = otherCorner.y +
+ (otherCorner.x - center.x);
+ poly[4].x = otherCorner.x;
+ poly[4].y = otherCorner.y;
+ miFillSppPoly (pDraw, pGC, 5, poly, xOrg, yOrg, xFtrans, yFtrans);
+ break;
+ case CapRound:
+ /*
+ * miRoundCap just needs these to be unequal.
+ */
+ endPoint = center;
+ endPoint.x = endPoint.x + 100;
+ miRoundCap (pDraw, pGC, center, endPoint, corner, otherCorner, 0,
+ -xOrg, -yOrg, xFtrans, yFtrans);
+ break;
+ }
+}
+
+/* MIROUNDCAP -- a private helper function
+ * Put Rounded cap on end. pCenter is the center of this end of the line
+ * pEnd is the center of the other end of the line. pCorner is one of the
+ * two corners at this end of the line.
+ * NOTE: pOtherCorner must be counter-clockwise from pCorner.
+ */
+/*ARGSUSED*/
+static void
+miRoundCap(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ SppPointRec pCenter,
+ SppPointRec pEnd,
+ SppPointRec pCorner,
+ SppPointRec pOtherCorner,
+ int fLineEnd,
+ int xOrg,
+ int yOrg,
+ double xFtrans,
+ double yFtrans)
+{
+ int cpt;
+ double width;
+ SppArcRec arc;
+ SppPointPtr pArcPts;
+
+ width = (pGC->lineWidth ? (double)pGC->lineWidth : (double)1);
+
+ arc.x = pCenter.x - width/2;
+ arc.y = pCenter.y - width/2;
+ arc.width = width;
+ arc.height = width;
+ arc.angle1 = -miDatan2 (pCorner.y - pCenter.y, pCorner.x - pCenter.x);
+ if(PTISEQUAL(pCenter, pEnd))
+ arc.angle2 = - 180.0;
+ else {
+ arc.angle2 = -miDatan2 (pOtherCorner.y - pCenter.y, pOtherCorner.x - pCenter.x) - arc.angle1;
+ if (arc.angle2 < 0)
+ arc.angle2 += 360.0;
+ }
+ pArcPts = (SppPointPtr) NULL;
+ if( (cpt = miGetArcPts(&arc, 0, &pArcPts)) )
+ {
+ /* by drawing with miFillSppPoly and setting the endpoints of the arc
+ * to be the corners, we assure that the cap will meet up with the
+ * rest of the line */
+ miFillSppPoly(pDraw, pGC, cpt, pArcPts, -xOrg, -yOrg, xFtrans, yFtrans);
+ }
+ xfree(pArcPts);
+}
+
+/*
+ * To avoid inaccuracy at the cardinal points, use trig functions
+ * which are exact for those angles
+ */
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+#ifndef M_PI_2
+#define M_PI_2 1.57079632679489661923
+#endif
+
+# define Dsin(d) ((d) == 0.0 ? 0.0 : ((d) == 90.0 ? 1.0 : sin(d*M_PI/180.0)))
+# define Dcos(d) ((d) == 0.0 ? 1.0 : ((d) == 90.0 ? 0.0 : cos(d*M_PI/180.0)))
+# define mod(a,b) ((a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
+
+static double
+miDcos (double a)
+{
+ int i;
+
+ if (floor (a/90) == a/90) {
+ i = (int) (a/90.0);
+ switch (mod (i, 4)) {
+ case 0: return 1;
+ case 1: return 0;
+ case 2: return -1;
+ case 3: return 0;
+ }
+ }
+ return cos (a * M_PI / 180.0);
+}
+
+static double
+miDsin (double a)
+{
+ int i;
+
+ if (floor (a/90) == a/90) {
+ i = (int) (a/90.0);
+ switch (mod (i, 4)) {
+ case 0: return 0;
+ case 1: return 1;
+ case 2: return 0;
+ case 3: return -1;
+ }
+ }
+ return sin (a * M_PI / 180.0);
+}
+
+static double
+miDasin (double v)
+{
+ if (v == 0)
+ return 0.0;
+ if (v == 1.0)
+ return 90.0;
+ if (v == -1.0)
+ return -90.0;
+ return asin(v) * (180.0 / M_PI);
+}
+
+static double
+miDatan2 (double dy, double dx)
+{
+ if (dy == 0) {
+ if (dx >= 0)
+ return 0.0;
+ return 180.0;
+ } else if (dx == 0) {
+ if (dy > 0)
+ return 90.0;
+ return -90.0;
+ } else if (Fabs (dy) == Fabs (dx)) {
+ if (dy > 0) {
+ if (dx > 0)
+ return 45.0;
+ return 135.0;
+ } else {
+ if (dx > 0)
+ return 315.0;
+ return 225.0;
+ }
+ } else {
+ return atan2 (dy, dx) * (180.0 / M_PI);
+ }
+}
+
+/* MIGETARCPTS -- Converts an arc into a set of line segments -- a helper
+ * routine for filled arc and line (round cap) code.
+ * Returns the number of points in the arc. Note that it takes a pointer
+ * to a pointer to where it should put the points and an index (cpt).
+ * This procedure allocates the space necessary to fit the arc points.
+ * Sometimes it's convenient for those points to be at the end of an existing
+ * array. (For example, if we want to leave a spare point to make sectors
+ * instead of segments.) So we pass in the xalloc()ed chunk that contains the
+ * array and an index saying where we should start stashing the points.
+ * If there isn't an array already, we just pass in a null pointer and
+ * count on xrealloc() to handle the null pointer correctly.
+ */
+static int
+miGetArcPts(
+ SppArcPtr parc, /* points to an arc */
+ int cpt, /* number of points already in arc list */
+ SppPointPtr *ppPts) /* pointer to pointer to arc-list -- modified */
+{
+ double st, /* Start Theta, start angle */
+ et, /* End Theta, offset from start theta */
+ dt, /* Delta Theta, angle to sweep ellipse */
+ cdt, /* Cos Delta Theta, actually 2 cos(dt) */
+ x0, y0, /* the recurrence formula needs two points to start */
+ x1, y1,
+ x2, y2, /* this will be the new point generated */
+ xc, yc; /* the center point */
+ int count, i;
+ SppPointPtr poly;
+
+ /* The spec says that positive angles indicate counterclockwise motion.
+ * Given our coordinate system (with 0,0 in the upper left corner),
+ * the screen appears flipped in Y. The easiest fix is to negate the
+ * angles given */
+
+ st = - parc->angle1;
+
+ et = - parc->angle2;
+
+ /* Try to get a delta theta that is within 1/2 pixel. Then adjust it
+ * so that it divides evenly into the total.
+ * I'm just using cdt 'cause I'm lazy.
+ */
+ cdt = parc->width;
+ if (parc->height > cdt)
+ cdt = parc->height;
+ cdt /= 2.0;
+ if(cdt <= 0)
+ return 0;
+ if (cdt < 1.0)
+ cdt = 1.0;
+ dt = miDasin ( 1.0 / cdt ); /* minimum step necessary */
+ count = et/dt;
+ count = abs(count) + 1;
+ dt = et/count;
+ count++;
+
+ cdt = 2 * miDcos(dt);
+ if (!(poly = (SppPointPtr) xrealloc((pointer)*ppPts,
+ (cpt + count) * sizeof(SppPointRec))))
+ return(0);
+ *ppPts = poly;
+
+ xc = parc->width/2.0; /* store half width and half height */
+ yc = parc->height/2.0;
+
+ x0 = xc * miDcos(st);
+ y0 = yc * miDsin(st);
+ x1 = xc * miDcos(st + dt);
+ y1 = yc * miDsin(st + dt);
+ xc += parc->x; /* by adding initial point, these become */
+ yc += parc->y; /* the center point */
+
+ poly[cpt].x = (xc + x0);
+ poly[cpt].y = (yc + y0);
+ poly[cpt + 1].x = (xc + x1);
+ poly[cpt + 1].y = (yc + y1);
+
+ for(i = 2; i < count; i++)
+ {
+ x2 = cdt * x1 - x0;
+ y2 = cdt * y1 - y0;
+
+ poly[cpt + i].x = (xc + x2);
+ poly[cpt + i].y = (yc + y2);
+
+ x0 = x1; y0 = y1;
+ x1 = x2; y1 = y2;
+ }
+ /* adjust the last point */
+ if (abs(parc->angle2) >= 360.0)
+ poly[cpt +i -1] = poly[0];
+ else {
+ poly[cpt +i -1].x = (miDcos(st + et) * parc->width/2.0 + xc);
+ poly[cpt +i -1].y = (miDsin(st + et) * parc->height/2.0 + yc);
+ }
+
+ return(count);
+}
+
+struct arcData {
+ double x0, y0, x1, y1;
+ int selfJoin;
+};
+
+# define ADD_REALLOC_STEP 20
+
+static void
+addCap (
+ miArcCapPtr *capsp,
+ int *ncapsp,
+ int *sizep,
+ int end,
+ int arcIndex)
+{
+ int newsize;
+ miArcCapPtr cap;
+
+ if (*ncapsp == *sizep)
+ {
+ newsize = *sizep + ADD_REALLOC_STEP;
+ cap = (miArcCapPtr) xrealloc (*capsp,
+ newsize * sizeof (**capsp));
+ if (!cap)
+ return;
+ *sizep = newsize;
+ *capsp = cap;
+ }
+ cap = &(*capsp)[*ncapsp];
+ cap->end = end;
+ cap->arcIndex = arcIndex;
+ ++*ncapsp;
+}
+
+static void
+addJoin (
+ miArcJoinPtr *joinsp,
+ int *njoinsp,
+ int *sizep,
+ int end0,
+ int index0,
+ int phase0,
+ int end1,
+ int index1,
+ int phase1)
+{
+ int newsize;
+ miArcJoinPtr join;
+
+ if (*njoinsp == *sizep)
+ {
+ newsize = *sizep + ADD_REALLOC_STEP;
+ join = (miArcJoinPtr) xrealloc (*joinsp,
+ newsize * sizeof (**joinsp));
+ if (!join)
+ return;
+ *sizep = newsize;
+ *joinsp = join;
+ }
+ join = &(*joinsp)[*njoinsp];
+ join->end0 = end0;
+ join->arcIndex0 = index0;
+ join->phase0 = phase0;
+ join->end1 = end1;
+ join->arcIndex1 = index1;
+ join->phase1 = phase1;
+ ++*njoinsp;
+}
+
+static miArcDataPtr
+addArc (
+ miArcDataPtr *arcsp,
+ int *narcsp,
+ int *sizep,
+ xArc *xarc)
+{
+ int newsize;
+ miArcDataPtr arc;
+
+ if (*narcsp == *sizep)
+ {
+ newsize = *sizep + ADD_REALLOC_STEP;
+ arc = (miArcDataPtr) xrealloc (*arcsp,
+ newsize * sizeof (**arcsp));
+ if (!arc)
+ return (miArcDataPtr)NULL;
+ *sizep = newsize;
+ *arcsp = arc;
+ }
+ arc = &(*arcsp)[*narcsp];
+ arc->arc = *xarc;
+ ++*narcsp;
+ return arc;
+}
+
+static void
+miFreeArcs(
+ miPolyArcPtr arcs,
+ GCPtr pGC)
+{
+ int iphase;
+
+ for (iphase = ((pGC->lineStyle == LineDoubleDash) ? 1 : 0);
+ iphase >= 0;
+ iphase--)
+ {
+ if (arcs[iphase].narcs > 0)
+ xfree(arcs[iphase].arcs);
+ if (arcs[iphase].njoins > 0)
+ xfree(arcs[iphase].joins);
+ if (arcs[iphase].ncaps > 0)
+ xfree(arcs[iphase].caps);
+ }
+ xfree(arcs);
+}
+
+/*
+ * map angles to radial distance. This only deals with the first quadrant
+ */
+
+/*
+ * a polygonal approximation to the arc for computing arc lengths
+ */
+
+# define DASH_MAP_SIZE 91
+
+# define dashIndexToAngle(di) ((((double) (di)) * 90.0) / ((double) DASH_MAP_SIZE - 1))
+# define xAngleToDashIndex(xa) ((((long) (xa)) * (DASH_MAP_SIZE - 1)) / (90 * 64))
+# define dashIndexToXAngle(di) ((((long) (di)) * (90 * 64)) / (DASH_MAP_SIZE - 1))
+# define dashXAngleStep (((double) (90 * 64)) / ((double) (DASH_MAP_SIZE - 1)))
+
+typedef struct {
+ double map[DASH_MAP_SIZE];
+} dashMap;
+
+static int computeAngleFromPath(int startAngle, int endAngle, dashMap *map,
+ int *lenp, int backwards);
+
+static void
+computeDashMap (
+ xArc *arcp,
+ dashMap *map)
+{
+ int di;
+ double a, x, y, prevx = 0.0, prevy = 0.0, dist;
+
+ for (di = 0; di < DASH_MAP_SIZE; di++) {
+ a = dashIndexToAngle (di);
+ x = ((double) arcp->width / 2.0) * miDcos (a);
+ y = ((double) arcp->height / 2.0) * miDsin (a);
+ if (di == 0) {
+ map->map[di] = 0.0;
+ } else {
+ dist = hypot (x - prevx, y - prevy);
+ map->map[di] = map->map[di - 1] + dist;
+ }
+ prevx = x;
+ prevy = y;
+ }
+}
+
+typedef enum {HORIZONTAL, VERTICAL, OTHER} arcTypes;
+
+/* this routine is a bit gory */
+
+static miPolyArcPtr
+miComputeArcs (
+ xArc *parcs,
+ int narcs,
+ GCPtr pGC)
+{
+ int isDashed, isDoubleDash;
+ int dashOffset;
+ miPolyArcPtr arcs;
+ int start, i, j, k = 0, nexti, nextk = 0;
+ int joinSize[2];
+ int capSize[2];
+ int arcSize[2];
+ int angle2;
+ double a0, a1;
+ struct arcData *data;
+ miArcDataPtr arc;
+ xArc xarc;
+ int iphase, prevphase = 0, joinphase;
+ int arcsJoin;
+ int selfJoin;
+
+ int iDash = 0, dashRemaining;
+ int iDashStart = 0, dashRemainingStart = 0, iphaseStart;
+ int startAngle, spanAngle, endAngle, backwards = 0;
+ int prevDashAngle, dashAngle;
+ dashMap map;
+
+ isDashed = !(pGC->lineStyle == LineSolid);
+ isDoubleDash = (pGC->lineStyle == LineDoubleDash);
+ dashOffset = pGC->dashOffset;
+
+ data = (struct arcData *) ALLOCATE_LOCAL (narcs * sizeof (struct arcData));
+ if (!data)
+ return (miPolyArcPtr)NULL;
+ arcs = (miPolyArcPtr) xalloc (sizeof (*arcs) * (isDoubleDash ? 2 : 1));
+ if (!arcs)
+ {
+ DEALLOCATE_LOCAL(data);
+ return (miPolyArcPtr)NULL;
+ }
+ for (i = 0; i < narcs; i++) {
+ a0 = todeg (parcs[i].angle1);
+ angle2 = parcs[i].angle2;
+ if (angle2 > FULLCIRCLE)
+ angle2 = FULLCIRCLE;
+ else if (angle2 < -FULLCIRCLE)
+ angle2 = -FULLCIRCLE;
+ data[i].selfJoin = angle2 == FULLCIRCLE || angle2 == -FULLCIRCLE;
+ a1 = todeg (parcs[i].angle1 + angle2);
+ data[i].x0 = parcs[i].x + (double) parcs[i].width / 2 * (1 + miDcos (a0));
+ data[i].y0 = parcs[i].y + (double) parcs[i].height / 2 * (1 - miDsin (a0));
+ data[i].x1 = parcs[i].x + (double) parcs[i].width / 2 * (1 + miDcos (a1));
+ data[i].y1 = parcs[i].y + (double) parcs[i].height / 2 * (1 - miDsin (a1));
+ }
+
+ for (iphase = 0; iphase < (isDoubleDash ? 2 : 1); iphase++) {
+ arcs[iphase].njoins = 0;
+ arcs[iphase].joins = 0;
+ joinSize[iphase] = 0;
+
+ arcs[iphase].ncaps = 0;
+ arcs[iphase].caps = 0;
+ capSize[iphase] = 0;
+
+ arcs[iphase].narcs = 0;
+ arcs[iphase].arcs = 0;
+ arcSize[iphase] = 0;
+ }
+
+ iphase = 0;
+ if (isDashed) {
+ iDash = 0;
+ dashRemaining = pGC->dash[0];
+ while (dashOffset > 0) {
+ if (dashOffset >= dashRemaining) {
+ dashOffset -= dashRemaining;
+ iphase = iphase ? 0 : 1;
+ iDash++;
+ if (iDash == pGC->numInDashList)
+ iDash = 0;
+ dashRemaining = pGC->dash[iDash];
+ } else {
+ dashRemaining -= dashOffset;
+ dashOffset = 0;
+ }
+ }
+ iDashStart = iDash;
+ dashRemainingStart = dashRemaining;
+ }
+ iphaseStart = iphase;
+
+ for (i = narcs - 1; i >= 0; i--) {
+ j = i + 1;
+ if (j == narcs)
+ j = 0;
+ if (data[i].selfJoin || i == j ||
+ (UNEQUAL (data[i].x1, data[j].x0) ||
+ UNEQUAL (data[i].y1, data[j].y0)))
+ {
+ if (iphase == 0 || isDoubleDash)
+ addCap (&arcs[iphase].caps, &arcs[iphase].ncaps,
+ &capSize[iphase], RIGHT_END, 0);
+ break;
+ }
+ }
+ start = i + 1;
+ if (start == narcs)
+ start = 0;
+ i = start;
+ for (;;) {
+ j = i + 1;
+ if (j == narcs)
+ j = 0;
+ nexti = i+1;
+ if (nexti == narcs)
+ nexti = 0;
+ if (isDashed) {
+ /*
+ ** deal with dashed arcs. Use special rules for certain 0 area arcs.
+ ** Presumably, the other 0 area arcs still aren't done right.
+ */
+ arcTypes arcType = OTHER;
+ CARD16 thisLength;
+
+ if (parcs[i].height == 0
+ && (parcs[i].angle1 % FULLCIRCLE) == 0x2d00
+ && parcs[i].angle2 == 0x2d00)
+ arcType = HORIZONTAL;
+ else if (parcs[i].width == 0
+ && (parcs[i].angle1 % FULLCIRCLE) == 0x1680
+ && parcs[i].angle2 == 0x2d00)
+ arcType = VERTICAL;
+ if (arcType == OTHER) {
+ /*
+ * precompute an approximation map
+ */
+ computeDashMap (&parcs[i], &map);
+ /*
+ * compute each individual dash segment using the path
+ * length function
+ */
+ startAngle = parcs[i].angle1;
+ spanAngle = parcs[i].angle2;
+ if (spanAngle > FULLCIRCLE)
+ spanAngle = FULLCIRCLE;
+ else if (spanAngle < -FULLCIRCLE)
+ spanAngle = -FULLCIRCLE;
+ if (startAngle < 0)
+ startAngle = FULLCIRCLE - (-startAngle) % FULLCIRCLE;
+ if (startAngle >= FULLCIRCLE)
+ startAngle = startAngle % FULLCIRCLE;
+ endAngle = startAngle + spanAngle;
+ backwards = spanAngle < 0;
+ } else {
+ xarc = parcs[i];
+ if (arcType == VERTICAL) {
+ xarc.angle1 = 0x1680;
+ startAngle = parcs[i].y;
+ endAngle = startAngle + parcs[i].height;
+ } else {
+ xarc.angle1 = 0x2d00;
+ startAngle = parcs[i].x;
+ endAngle = startAngle + parcs[i].width;
+ }
+ }
+ dashAngle = startAngle;
+ selfJoin = data[i].selfJoin &&
+ (iphase == 0 || isDoubleDash);
+ /*
+ * add dashed arcs to each bucket
+ */
+ arc = 0;
+ while (dashAngle != endAngle) {
+ prevDashAngle = dashAngle;
+ if (arcType == OTHER) {
+ dashAngle = computeAngleFromPath (prevDashAngle, endAngle,
+ &map, &dashRemaining, backwards);
+ /* avoid troubles with huge arcs and small dashes */
+ if (dashAngle == prevDashAngle) {
+ if (backwards)
+ dashAngle--;
+ else
+ dashAngle++;
+ }
+ } else {
+ thisLength = (dashAngle + dashRemaining <= endAngle) ?
+ dashRemaining : endAngle - dashAngle;
+ if (arcType == VERTICAL) {
+ xarc.y = dashAngle;
+ xarc.height = thisLength;
+ } else {
+ xarc.x = dashAngle;
+ xarc.width = thisLength;
+ }
+ dashAngle += thisLength;
+ dashRemaining -= thisLength;
+ }
+ if (iphase == 0 || isDoubleDash) {
+ if (arcType == OTHER) {
+ xarc = parcs[i];
+ spanAngle = prevDashAngle;
+ if (spanAngle < 0)
+ spanAngle = FULLCIRCLE - (-spanAngle) % FULLCIRCLE;
+ if (spanAngle >= FULLCIRCLE)
+ spanAngle = spanAngle % FULLCIRCLE;
+ xarc.angle1 = spanAngle;
+ spanAngle = dashAngle - prevDashAngle;
+ if (backwards) {
+ if (dashAngle > prevDashAngle)
+ spanAngle = - FULLCIRCLE + spanAngle;
+ } else {
+ if (dashAngle < prevDashAngle)
+ spanAngle = FULLCIRCLE + spanAngle;
+ }
+ if (spanAngle > FULLCIRCLE)
+ spanAngle = FULLCIRCLE;
+ if (spanAngle < -FULLCIRCLE)
+ spanAngle = -FULLCIRCLE;
+ xarc.angle2 = spanAngle;
+ }
+ arc = addArc (&arcs[iphase].arcs, &arcs[iphase].narcs,
+ &arcSize[iphase], &xarc);
+ if (!arc)
+ goto arcfail;
+ /*
+ * cap each end of an on/off dash
+ */
+ if (!isDoubleDash) {
+ if (prevDashAngle != startAngle) {
+ addCap (&arcs[iphase].caps,
+ &arcs[iphase].ncaps,
+ &capSize[iphase], RIGHT_END,
+ arc - arcs[iphase].arcs);
+
+ }
+ if (dashAngle != endAngle) {
+ addCap (&arcs[iphase].caps,
+ &arcs[iphase].ncaps,
+ &capSize[iphase], LEFT_END,
+ arc - arcs[iphase].arcs);
+ }
+ }
+ arc->cap = arcs[iphase].ncaps;
+ arc->join = arcs[iphase].njoins;
+ arc->render = 0;
+ arc->selfJoin = 0;
+ if (dashAngle == endAngle)
+ arc->selfJoin = selfJoin;
+ }
+ prevphase = iphase;
+ if (dashRemaining <= 0) {
+ ++iDash;
+ if (iDash == pGC->numInDashList)
+ iDash = 0;
+ iphase = iphase ? 0:1;
+ dashRemaining = pGC->dash[iDash];
+ }
+ }
+ /*
+ * make sure a place exists for the position data when
+ * drawing a zero-length arc
+ */
+ if (startAngle == endAngle) {
+ prevphase = iphase;
+ if (!isDoubleDash && iphase == 1)
+ prevphase = 0;
+ arc = addArc (&arcs[prevphase].arcs, &arcs[prevphase].narcs,
+ &arcSize[prevphase], &parcs[i]);
+ if (!arc)
+ goto arcfail;
+ arc->join = arcs[prevphase].njoins;
+ arc->cap = arcs[prevphase].ncaps;
+ arc->selfJoin = data[i].selfJoin;
+ }
+ } else {
+ arc = addArc (&arcs[iphase].arcs, &arcs[iphase].narcs,
+ &arcSize[iphase], &parcs[i]);
+ if (!arc)
+ goto arcfail;
+ arc->join = arcs[iphase].njoins;
+ arc->cap = arcs[iphase].ncaps;
+ arc->selfJoin = data[i].selfJoin;
+ prevphase = iphase;
+ }
+ if (prevphase == 0 || isDoubleDash)
+ k = arcs[prevphase].narcs - 1;
+ if (iphase == 0 || isDoubleDash)
+ nextk = arcs[iphase].narcs;
+ if (nexti == start) {
+ nextk = 0;
+ if (isDashed) {
+ iDash = iDashStart;
+ iphase = iphaseStart;
+ dashRemaining = dashRemainingStart;
+ }
+ }
+ arcsJoin = narcs > 1 && i != j &&
+ ISEQUAL (data[i].x1, data[j].x0) &&
+ ISEQUAL (data[i].y1, data[j].y0) &&
+ !data[i].selfJoin && !data[j].selfJoin;
+ if (arc)
+ {
+ if (arcsJoin)
+ arc->render = 0;
+ else
+ arc->render = 1;
+ }
+ if (arcsJoin &&
+ (prevphase == 0 || isDoubleDash) &&
+ (iphase == 0 || isDoubleDash))
+ {
+ joinphase = iphase;
+ if (isDoubleDash) {
+ if (nexti == start)
+ joinphase = iphaseStart;
+ /*
+ * if the join is right at the dash,
+ * draw the join in foreground
+ * This is because the foreground
+ * arcs are computed second, the results
+ * of which are needed to draw the join
+ */
+ if (joinphase != prevphase)
+ joinphase = 0;
+ }
+ if (joinphase == 0 || isDoubleDash) {
+ addJoin (&arcs[joinphase].joins,
+ &arcs[joinphase].njoins,
+ &joinSize[joinphase],
+ LEFT_END, k, prevphase,
+ RIGHT_END, nextk, iphase);
+ arc->join = arcs[prevphase].njoins;
+ }
+ } else {
+ /*
+ * cap the left end of this arc
+ * unless it joins itself
+ */
+ if ((prevphase == 0 || isDoubleDash) &&
+ !arc->selfJoin)
+ {
+ addCap (&arcs[prevphase].caps, &arcs[prevphase].ncaps,
+ &capSize[prevphase], LEFT_END, k);
+ arc->cap = arcs[prevphase].ncaps;
+ }
+ if (isDashed && !arcsJoin) {
+ iDash = iDashStart;
+ iphase = iphaseStart;
+ dashRemaining = dashRemainingStart;
+ }
+ nextk = arcs[iphase].narcs;
+ if (nexti == start) {
+ nextk = 0;
+ iDash = iDashStart;
+ iphase = iphaseStart;
+ dashRemaining = dashRemainingStart;
+ }
+ /*
+ * cap the right end of the next arc. If the
+ * next arc is actually the first arc, only
+ * cap it if it joins with this arc. This
+ * case will occur when the final dash segment
+ * of an on/off dash is off. Of course, this
+ * cap will be drawn at a strange time, but that
+ * hardly matters...
+ */
+ if ((iphase == 0 || isDoubleDash) &&
+ (nexti != start || (arcsJoin && isDashed)))
+ addCap (&arcs[iphase].caps, &arcs[iphase].ncaps,
+ &capSize[iphase], RIGHT_END, nextk);
+ }
+ i = nexti;
+ if (i == start)
+ break;
+ }
+ /*
+ * make sure the last section is rendered
+ */
+ for (iphase = 0; iphase < (isDoubleDash ? 2 : 1); iphase++)
+ if (arcs[iphase].narcs > 0) {
+ arcs[iphase].arcs[arcs[iphase].narcs-1].render = 1;
+ arcs[iphase].arcs[arcs[iphase].narcs-1].join =
+ arcs[iphase].njoins;
+ arcs[iphase].arcs[arcs[iphase].narcs-1].cap =
+ arcs[iphase].ncaps;
+ }
+ DEALLOCATE_LOCAL(data);
+ return arcs;
+arcfail:
+ miFreeArcs(arcs, pGC);
+ DEALLOCATE_LOCAL(data);
+ return (miPolyArcPtr)NULL;
+}
+
+static double
+angleToLength (
+ int angle,
+ dashMap *map)
+{
+ double len, excesslen, sidelen = map->map[DASH_MAP_SIZE - 1], totallen;
+ int di;
+ int excess;
+ Bool oddSide = FALSE;
+
+ totallen = 0;
+ if (angle >= 0) {
+ while (angle >= 90 * 64) {
+ angle -= 90 * 64;
+ totallen += sidelen;
+ oddSide = !oddSide;
+ }
+ } else {
+ while (angle < 0) {
+ angle += 90 * 64;
+ totallen -= sidelen;
+ oddSide = !oddSide;
+ }
+ }
+ if (oddSide)
+ angle = 90 * 64 - angle;
+
+ di = xAngleToDashIndex (angle);
+ excess = angle - dashIndexToXAngle (di);
+
+ len = map->map[di];
+ /*
+ * linearly interpolate between this point and the next
+ */
+ if (excess > 0) {
+ excesslen = (map->map[di + 1] - map->map[di]) *
+ ((double) excess) / dashXAngleStep;
+ len += excesslen;
+ }
+ if (oddSide)
+ totallen += (sidelen - len);
+ else
+ totallen += len;
+ return totallen;
+}
+
+/*
+ * len is along the arc, but may be more than one rotation
+ */
+
+static int
+lengthToAngle (
+ double len,
+ dashMap *map)
+{
+ double sidelen = map->map[DASH_MAP_SIZE - 1];
+ int angle, angleexcess;
+ Bool oddSide = FALSE;
+ int a0, a1, a;
+
+ angle = 0;
+ /*
+ * step around the ellipse, subtracting sidelens and
+ * adding 90 degrees. oddSide will tell if the
+ * map should be interpolated in reverse
+ */
+ if (len >= 0) {
+ if (sidelen == 0)
+ return 2 * FULLCIRCLE; /* infinity */
+ while (len >= sidelen) {
+ angle += 90 * 64;
+ len -= sidelen;
+ oddSide = !oddSide;
+ }
+ } else {
+ if (sidelen == 0)
+ return -2 * FULLCIRCLE; /* infinity */
+ while (len < 0) {
+ angle -= 90 * 64;
+ len += sidelen;
+ oddSide = !oddSide;
+ }
+ }
+ if (oddSide)
+ len = sidelen - len;
+ a0 = 0;
+ a1 = DASH_MAP_SIZE - 1;
+ /*
+ * binary search for the closest pre-computed length
+ */
+ while (a1 - a0 > 1) {
+ a = (a0 + a1) / 2;
+ if (len > map->map[a])
+ a0 = a;
+ else
+ a1 = a;
+ }
+ angleexcess = dashIndexToXAngle (a0);
+ /*
+ * linearly interpolate to the next point
+ */
+ angleexcess += (len - map->map[a0]) /
+ (map->map[a0+1] - map->map[a0]) * dashXAngleStep;
+ if (oddSide)
+ angle += (90 * 64) - angleexcess;
+ else
+ angle += angleexcess;
+ return angle;
+}
+
+/*
+ * compute the angle of an ellipse which cooresponds to
+ * the given path length. Note that the correct solution
+ * to this problem is an eliptic integral, we'll punt and
+ * approximate (it's only for dashes anyway). This
+ * approximation uses a polygon.
+ *
+ * The remaining portion of len is stored in *lenp -
+ * this will be negative if the arc extends beyond
+ * len and positive if len extends beyond the arc.
+ */
+
+static int
+computeAngleFromPath (
+ int startAngle,
+ int endAngle, /* normalized absolute angles in *64 degrees */
+ dashMap *map,
+ int *lenp,
+ int backwards)
+{
+ int a0, a1, a;
+ double len0;
+ int len;
+
+ a0 = startAngle;
+ a1 = endAngle;
+ len = *lenp;
+ if (backwards) {
+ /*
+ * flip the problem around to always be
+ * forwards
+ */
+ a0 = FULLCIRCLE - a0;
+ a1 = FULLCIRCLE - a1;
+ }
+ if (a1 < a0)
+ a1 += FULLCIRCLE;
+ len0 = angleToLength (a0, map);
+ a = lengthToAngle (len0 + len, map);
+ if (a > a1) {
+ a = a1;
+ len -= angleToLength (a1, map) - len0;
+ } else
+ len = 0;
+ if (backwards)
+ a = FULLCIRCLE - a;
+ *lenp = len;
+ return a;
+}
+
+/*
+ * scan convert wide arcs.
+ */
+
+/*
+ * draw zero width/height arcs
+ */
+
+static void
+drawZeroArc (
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ xArc *tarc,
+ int lw,
+ miArcFacePtr left,
+ miArcFacePtr right)
+{
+ double x0 = 0.0, y0 = 0.0, x1 = 0.0, y1 = 0.0, w, h, x, y;
+ double xmax, ymax, xmin, ymin;
+ int a0, a1;
+ double a, startAngle, endAngle;
+ double l, lx, ly;
+
+ l = lw / 2.0;
+ a0 = tarc->angle1;
+ a1 = tarc->angle2;
+ if (a1 > FULLCIRCLE)
+ a1 = FULLCIRCLE;
+ else if (a1 < -FULLCIRCLE)
+ a1 = -FULLCIRCLE;
+ w = (double)tarc->width / 2.0;
+ h = (double)tarc->height / 2.0;
+ /*
+ * play in X coordinates right away
+ */
+ startAngle = - ((double) a0 / 64.0);
+ endAngle = - ((double) (a0 + a1) / 64.0);
+
+ xmax = -w;
+ xmin = w;
+ ymax = -h;
+ ymin = h;
+ a = startAngle;
+ for (;;)
+ {
+ x = w * miDcos(a);
+ y = h * miDsin(a);
+ if (a == startAngle)
+ {
+ x0 = x;
+ y0 = y;
+ }
+ if (a == endAngle)
+ {
+ x1 = x;
+ y1 = y;
+ }
+ if (x > xmax)
+ xmax = x;
+ if (x < xmin)
+ xmin = x;
+ if (y > ymax)
+ ymax = y;
+ if (y < ymin)
+ ymin = y;
+ if (a == endAngle)
+ break;
+ if (a1 < 0) /* clockwise */
+ {
+ if (floor (a / 90.0) == floor (endAngle / 90.0))
+ a = endAngle;
+ else
+ a = 90 * (floor (a/90.0) + 1);
+ }
+ else
+ {
+ if (ceil (a / 90.0) == ceil (endAngle / 90.0))
+ a = endAngle;
+ else
+ a = 90 * (ceil (a/90.0) - 1);
+ }
+ }
+ lx = ly = l;
+ if ((x1 - x0) + (y1 - y0) < 0)
+ lx = ly = -l;
+ if (h)
+ {
+ ly = 0.0;
+ lx = -lx;
+ }
+ else
+ lx = 0.0;
+ if (right)
+ {
+ right->center.x = x0;
+ right->center.y = y0;
+ right->clock.x = x0 - lx;
+ right->clock.y = y0 - ly;
+ right->counterClock.x = x0 + lx;
+ right->counterClock.y = y0 + ly;
+ }
+ if (left)
+ {
+ left->center.x = x1;
+ left->center.y = y1;
+ left->clock.x = x1 + lx;
+ left->clock.y = y1 + ly;
+ left->counterClock.x = x1 - lx;
+ left->counterClock.y = y1 - ly;
+ }
+
+ x0 = xmin;
+ x1 = xmax;
+ y0 = ymin;
+ y1 = ymax;
+ if (ymin != y1) {
+ xmin = -l;
+ xmax = l;
+ } else {
+ ymin = -l;
+ ymax = l;
+ }
+ if (xmax != xmin && ymax != ymin) {
+ int minx, maxx, miny, maxy;
+ xRectangle rect;
+
+ minx = ICEIL (xmin + w) + tarc->x;
+ maxx = ICEIL (xmax + w) + tarc->x;
+ miny = ICEIL (ymin + h) + tarc->y;
+ maxy = ICEIL (ymax + h) + tarc->y;
+ rect.x = minx;
+ rect.y = miny;
+ rect.width = maxx - minx;
+ rect.height = maxy - miny;
+ (*pGC->ops->PolyFillRect) (pDraw, pGC, 1, &rect);
+ }
+}
+
+/*
+ * this computes the ellipse y value associated with the
+ * bottom of the tail.
+ */
+
+static void
+tailEllipseY (
+ struct arc_def *def,
+ struct accelerators *acc)
+{
+ double t;
+
+ acc->tail_y = 0.0;
+ if (def->w == def->h)
+ return;
+ t = def->l * def->w;
+ if (def->w > def->h) {
+ if (t < acc->h2)
+ return;
+ } else {
+ if (t > acc->h2)
+ return;
+ }
+ t = 2.0 * def->h * t;
+ t = (CUBED_ROOT_4 * acc->h2 - cbrt(t * t)) / acc->h2mw2;
+ if (t > 0.0)
+ acc->tail_y = def->h / CUBED_ROOT_2 * sqrt(t);
+}
+
+/*
+ * inverse functions -- compute edge coordinates
+ * from the ellipse
+ */
+
+static double
+outerXfromXY (
+ double x,
+ double y,
+ struct arc_def *def,
+ struct accelerators *acc)
+{
+ return x + (x * acc->h2l) / sqrt (x*x * acc->h4 + y*y * acc->w4);
+}
+
+static double
+outerYfromXY (
+ double x,
+ double y,
+ struct arc_def *def,
+ struct accelerators *acc)
+{
+ return y + (y * acc->w2l) / sqrt (x*x * acc->h4 + y*y * acc->w4);
+}
+
+static double
+innerXfromXY (
+ double x,
+ double y,
+ struct arc_def *def,
+ struct accelerators *acc)
+{
+ return x - (x * acc->h2l) / sqrt (x*x * acc->h4 + y*y * acc->w4);
+}
+
+static double
+innerYfromXY (
+ double x,
+ double y,
+ struct arc_def *def,
+ struct accelerators *acc)
+{
+ return y - (y * acc->w2l) / sqrt (x*x * acc->h4 + y*y * acc->w4);
+}
+
+static double
+innerYfromY (
+ double y,
+ struct arc_def *def,
+ struct accelerators *acc)
+{
+ double x;
+
+ x = (def->w / def->h) * sqrt (acc->h2 - y*y);
+
+ return y - (y * acc->w2l) / sqrt (x*x * acc->h4 + y*y * acc->w4);
+}
+
+static void
+computeLine (
+ double x1,
+ double y1,
+ double x2,
+ double y2,
+ struct line *line)
+{
+ if (y1 == y2)
+ line->valid = 0;
+ else {
+ line->m = (x1 - x2) / (y1 - y2);
+ line->b = x1 - y1 * line->m;
+ line->valid = 1;
+ }
+}
+
+/*
+ * compute various accelerators for an ellipse. These
+ * are simply values that are used repeatedly in
+ * the computations
+ */
+
+static void
+computeAcc (
+ xArc *tarc,
+ int lw,
+ struct arc_def *def,
+ struct accelerators *acc)
+{
+ def->w = ((double) tarc->width) / 2.0;
+ def->h = ((double) tarc->height) / 2.0;
+ def->l = ((double) lw) / 2.0;
+ acc->h2 = def->h * def->h;
+ acc->w2 = def->w * def->w;
+ acc->h4 = acc->h2 * acc->h2;
+ acc->w4 = acc->w2 * acc->w2;
+ acc->h2l = acc->h2 * def->l;
+ acc->w2l = acc->w2 * def->l;
+ acc->h2mw2 = acc->h2 - acc->w2;
+ acc->fromIntX = (tarc->width & 1) ? 0.5 : 0.0;
+ acc->fromIntY = (tarc->height & 1) ? 0.5 : 0.0;
+ acc->xorg = tarc->x + (tarc->width >> 1);
+ acc->yorgu = tarc->y + (tarc->height >> 1);
+ acc->yorgl = acc->yorgu + (tarc->height & 1);
+ tailEllipseY (def, acc);
+}
+
+/*
+ * compute y value bounds of various portions of the arc,
+ * the outer edge, the ellipse and the inner edge.
+ */
+
+static void
+computeBound (
+ struct arc_def *def,
+ struct arc_bound *bound,
+ struct accelerators *acc,
+ miArcFacePtr right,
+ miArcFacePtr left)
+{
+ double t;
+ double innerTaily;
+ double tail_y;
+ struct bound innerx, outerx;
+ struct bound ellipsex;
+
+ bound->ellipse.min = Dsin (def->a0) * def->h;
+ bound->ellipse.max = Dsin (def->a1) * def->h;
+ if (def->a0 == 45 && def->w == def->h)
+ ellipsex.min = bound->ellipse.min;
+ else
+ ellipsex.min = Dcos (def->a0) * def->w;
+ if (def->a1 == 45 && def->w == def->h)
+ ellipsex.max = bound->ellipse.max;
+ else
+ ellipsex.max = Dcos (def->a1) * def->w;
+ bound->outer.min = outerYfromXY (ellipsex.min, bound->ellipse.min, def, acc);
+ bound->outer.max = outerYfromXY (ellipsex.max, bound->ellipse.max, def, acc);
+ bound->inner.min = innerYfromXY (ellipsex.min, bound->ellipse.min, def, acc);
+ bound->inner.max = innerYfromXY (ellipsex.max, bound->ellipse.max, def, acc);
+
+ outerx.min = outerXfromXY (ellipsex.min, bound->ellipse.min, def, acc);
+ outerx.max = outerXfromXY (ellipsex.max, bound->ellipse.max, def, acc);
+ innerx.min = innerXfromXY (ellipsex.min, bound->ellipse.min, def, acc);
+ innerx.max = innerXfromXY (ellipsex.max, bound->ellipse.max, def, acc);
+
+ /*
+ * save the line end points for the
+ * cap code to use. Careful here, these are
+ * in cartesean coordinates (y increasing upwards)
+ * while the cap code uses inverted coordinates
+ * (y increasing downwards)
+ */
+
+ if (right) {
+ right->counterClock.y = bound->outer.min;
+ right->counterClock.x = outerx.min;
+ right->center.y = bound->ellipse.min;
+ right->center.x = ellipsex.min;
+ right->clock.y = bound->inner.min;
+ right->clock.x = innerx.min;
+ }
+
+ if (left) {
+ left->clock.y = bound->outer.max;
+ left->clock.x = outerx.max;
+ left->center.y = bound->ellipse.max;
+ left->center.x = ellipsex.max;
+ left->counterClock.y = bound->inner.max;
+ left->counterClock.x = innerx.max;
+ }
+
+ bound->left.min = bound->inner.max;
+ bound->left.max = bound->outer.max;
+ bound->right.min = bound->inner.min;
+ bound->right.max = bound->outer.min;
+
+ computeLine (innerx.min, bound->inner.min, outerx.min, bound->outer.min,
+ &acc->right);
+ computeLine (innerx.max, bound->inner.max, outerx.max, bound->outer.max,
+ &acc->left);
+
+ if (bound->inner.min > bound->inner.max) {
+ t = bound->inner.min;
+ bound->inner.min = bound->inner.max;
+ bound->inner.max = t;
+ }
+ tail_y = acc->tail_y;
+ if (tail_y > bound->ellipse.max)
+ tail_y = bound->ellipse.max;
+ else if (tail_y < bound->ellipse.min)
+ tail_y = bound->ellipse.min;
+ innerTaily = innerYfromY (tail_y, def, acc);
+ if (bound->inner.min > innerTaily)
+ bound->inner.min = innerTaily;
+ if (bound->inner.max < innerTaily)
+ bound->inner.max = innerTaily;
+ bound->inneri.min = ICEIL(bound->inner.min - acc->fromIntY);
+ bound->inneri.max = floor(bound->inner.max - acc->fromIntY);
+ bound->outeri.min = ICEIL(bound->outer.min - acc->fromIntY);
+ bound->outeri.max = floor(bound->outer.max - acc->fromIntY);
+}
+
+/*
+ * this section computes the x value of the span at y
+ * intersected with the specified face of the ellipse.
+ *
+ * this is the min/max X value over the set of normal
+ * lines to the entire ellipse, the equation of the
+ * normal lines is:
+ *
+ * ellipse_x h^2 h^2
+ * x = ------------ y + ellipse_x (1 - --- )
+ * ellipse_y w^2 w^2
+ *
+ * compute the derivative with-respect-to ellipse_y and solve
+ * for zero:
+ *
+ * (w^2 - h^2) ellipse_y^3 + h^4 y
+ * 0 = - ----------------------------------
+ * h w ellipse_y^2 sqrt (h^2 - ellipse_y^2)
+ *
+ * ( h^4 y )
+ * ellipse_y = ( ---------- ) ^ (1/3)
+ * ( (h^2 - w^2) )
+ *
+ * The other two solutions to the equation are imaginary.
+ *
+ * This gives the position on the ellipse which generates
+ * the normal with the largest/smallest x intersection point.
+ *
+ * Now compute the second derivative to check whether
+ * the intersection is a minimum or maximum:
+ *
+ * h (y0^3 (w^2 - h^2) + h^2 y (3y0^2 - 2h^2))
+ * - -------------------------------------------
+ * w y0^3 (sqrt (h^2 - y^2)) ^ 3
+ *
+ * as we only care about the sign,
+ *
+ * - (y0^3 (w^2 - h^2) + h^2 y (3y0^2 - 2h^2))
+ *
+ * or (to use accelerators),
+ *
+ * y0^3 (h^2 - w^2) - h^2 y (3y0^2 - 2h^2)
+ *
+ */
+
+/*
+ * computes the position on the ellipse whose normal line
+ * intersects the given scan line maximally
+ */
+
+static double
+hookEllipseY (
+ double scan_y,
+ struct arc_bound *bound,
+ struct accelerators *acc,
+ int left)
+{
+ double ret;
+
+ if (acc->h2mw2 == 0) {
+ if ( (scan_y > 0 && !left) || (scan_y < 0 && left) )
+ return bound->ellipse.min;
+ return bound->ellipse.max;
+ }
+ ret = (acc->h4 * scan_y) / (acc->h2mw2);
+ if (ret >= 0)
+ return cbrt (ret);
+ else
+ return -cbrt (-ret);
+}
+
+/*
+ * computes the X value of the intersection of the
+ * given scan line with the right side of the lower hook
+ */
+
+static double
+hookX (
+ double scan_y,
+ struct arc_def *def,
+ struct arc_bound *bound,
+ struct accelerators *acc,
+ int left)
+{
+ double ellipse_y, x;
+ double maxMin;
+
+ if (def->w != def->h) {
+ ellipse_y = hookEllipseY (scan_y, bound, acc, left);
+ if (boundedLe (ellipse_y, bound->ellipse)) {
+ /*
+ * compute the value of the second
+ * derivative
+ */
+ maxMin = ellipse_y*ellipse_y*ellipse_y * acc->h2mw2 -
+ acc->h2 * scan_y * (3 * ellipse_y*ellipse_y - 2*acc->h2);
+ if ((left && maxMin > 0) || (!left && maxMin < 0)) {
+ if (ellipse_y == 0)
+ return def->w + left ? -def->l : def->l;
+ x = (acc->h2 * scan_y - ellipse_y * acc->h2mw2) *
+ sqrt (acc->h2 - ellipse_y * ellipse_y) /
+ (def->h * def->w * ellipse_y);
+ return x;
+ }
+ }
+ }
+ if (left) {
+ if (acc->left.valid && boundedLe (scan_y, bound->left)) {
+ x = intersectLine (scan_y, acc->left);
+ } else {
+ if (acc->right.valid)
+ x = intersectLine (scan_y, acc->right);
+ else
+ x = def->w - def->l;
+ }
+ } else {
+ if (acc->right.valid && boundedLe (scan_y, bound->right)) {
+ x = intersectLine (scan_y, acc->right);
+ } else {
+ if (acc->left.valid)
+ x = intersectLine (scan_y, acc->left);
+ else
+ x = def->w - def->l;
+ }
+ }
+ return x;
+}
+
+/*
+ * generate the set of spans with
+ * the given y coordinate
+ */
+
+static void
+arcSpan (
+ int y,
+ int lx,
+ int lw,
+ int rx,
+ int rw,
+ struct arc_def *def,
+ struct arc_bound *bounds,
+ struct accelerators *acc,
+ int mask)
+{
+ int linx, loutx, rinx, routx;
+ double x, altx;
+
+ if (boundedLe (y, bounds->inneri)) {
+ linx = -(lx + lw);
+ rinx = rx;
+ } else {
+ /*
+ * intersection with left face
+ */
+ x = hookX (y + acc->fromIntY, def, bounds, acc, 1);
+ if (acc->right.valid &&
+ boundedLe (y + acc->fromIntY, bounds->right))
+ {
+ altx = intersectLine (y + acc->fromIntY, acc->right);
+ if (altx < x)
+ x = altx;
+ }
+ linx = -ICEIL(acc->fromIntX - x);
+ rinx = ICEIL(acc->fromIntX + x);
+ }
+ if (boundedLe (y, bounds->outeri)) {
+ loutx = -lx;
+ routx = rx + rw;
+ } else {
+ /*
+ * intersection with right face
+ */
+ x = hookX (y + acc->fromIntY, def, bounds, acc, 0);
+ if (acc->left.valid &&
+ boundedLe (y + acc->fromIntY, bounds->left))
+ {
+ altx = x;
+ x = intersectLine (y + acc->fromIntY, acc->left);
+ if (x < altx)
+ x = altx;
+ }
+ loutx = -ICEIL(acc->fromIntX - x);
+ routx = ICEIL(acc->fromIntX + x);
+ }
+ if (routx > rinx) {
+ if (mask & 1)
+ newFinalSpan (acc->yorgu - y,
+ acc->xorg + rinx, acc->xorg + routx);
+ if (mask & 8)
+ newFinalSpan (acc->yorgl + y,
+ acc->xorg + rinx, acc->xorg + routx);
+ }
+ if (loutx > linx) {
+ if (mask & 2)
+ newFinalSpan (acc->yorgu - y,
+ acc->xorg - loutx, acc->xorg - linx);
+ if (mask & 4)
+ newFinalSpan (acc->yorgl + y,
+ acc->xorg - loutx, acc->xorg - linx);
+ }
+}
+
+static void
+arcSpan0 (
+ int lx,
+ int lw,
+ int rx,
+ int rw,
+ struct arc_def *def,
+ struct arc_bound *bounds,
+ struct accelerators *acc,
+ int mask)
+{
+ double x;
+
+ if (boundedLe (0, bounds->inneri) &&
+ acc->left.valid && boundedLe (0, bounds->left) &&
+ acc->left.b > 0)
+ {
+ x = def->w - def->l;
+ if (acc->left.b < x)
+ x = acc->left.b;
+ lw = ICEIL(acc->fromIntX - x) - lx;
+ rw += rx;
+ rx = ICEIL(acc->fromIntX + x);
+ rw -= rx;
+ }
+ arcSpan (0, lx, lw, rx, rw, def, bounds, acc, mask);
+}
+
+static void
+tailSpan (
+ int y,
+ int lw,
+ int rw,
+ struct arc_def *def,
+ struct arc_bound *bounds,
+ struct accelerators *acc,
+ int mask)
+{
+ double yy, xalt, x, lx, rx;
+ int n;
+
+ if (boundedLe(y, bounds->outeri))
+ arcSpan (y, 0, lw, -rw, rw, def, bounds, acc, mask);
+ else if (def->w != def->h) {
+ yy = y + acc->fromIntY;
+ x = tailX(yy, def, bounds, acc);
+ if (yy == 0.0 && x == -rw - acc->fromIntX)
+ return;
+ if (acc->right.valid && boundedLe (yy, bounds->right)) {
+ rx = x;
+ lx = -x;
+ xalt = intersectLine (yy, acc->right);
+ if (xalt >= -rw - acc->fromIntX && xalt <= rx)
+ rx = xalt;
+ n = ICEIL(acc->fromIntX + lx);
+ if (lw > n) {
+ if (mask & 2)
+ newFinalSpan (acc->yorgu - y,
+ acc->xorg + n, acc->xorg + lw);
+ if (mask & 4)
+ newFinalSpan (acc->yorgl + y,
+ acc->xorg + n, acc->xorg + lw);
+ }
+ n = ICEIL(acc->fromIntX + rx);
+ if (n > -rw) {
+ if (mask & 1)
+ newFinalSpan (acc->yorgu - y,
+ acc->xorg - rw, acc->xorg + n);
+ if (mask & 8)
+ newFinalSpan (acc->yorgl + y,
+ acc->xorg - rw, acc->xorg + n);
+ }
+ }
+ arcSpan (y,
+ ICEIL(acc->fromIntX - x), 0,
+ ICEIL(acc->fromIntX + x), 0,
+ def, bounds, acc, mask);
+ }
+}
+
+/*
+ * create whole arcs out of pieces. This code is
+ * very bad.
+ */
+
+static struct finalSpan **finalSpans = NULL;
+static int finalMiny = 0, finalMaxy = -1;
+static int finalSize = 0;
+
+static int nspans = 0; /* total spans, not just y coords */
+
+struct finalSpan {
+ struct finalSpan *next;
+ int min, max; /* x values */
+};
+
+static struct finalSpan *freeFinalSpans, *tmpFinalSpan;
+
+# define allocFinalSpan() (freeFinalSpans ?\
+ ((tmpFinalSpan = freeFinalSpans), \
+ (freeFinalSpans = freeFinalSpans->next), \
+ (tmpFinalSpan->next = 0), \
+ tmpFinalSpan) : \
+ realAllocSpan ())
+
+# define SPAN_CHUNK_SIZE 128
+
+struct finalSpanChunk {
+ struct finalSpan data[SPAN_CHUNK_SIZE];
+ struct finalSpanChunk *next;
+};
+
+static struct finalSpanChunk *chunks;
+
+struct finalSpan *
+realAllocSpan ()
+{
+ register struct finalSpanChunk *newChunk;
+ register struct finalSpan *span;
+ register int i;
+
+ newChunk = (struct finalSpanChunk *) xalloc (sizeof (struct finalSpanChunk));
+ if (!newChunk)
+ return (struct finalSpan *) NULL;
+ newChunk->next = chunks;
+ chunks = newChunk;
+ freeFinalSpans = span = newChunk->data + 1;
+ for (i = 1; i < SPAN_CHUNK_SIZE-1; i++) {
+ span->next = span+1;
+ span++;
+ }
+ span->next = 0;
+ span = newChunk->data;
+ span->next = 0;
+ return span;
+}
+
+static void
+disposeFinalSpans (void)
+{
+ struct finalSpanChunk *chunk, *next;
+
+ for (chunk = chunks; chunk; chunk = next) {
+ next = chunk->next;
+ xfree (chunk);
+ }
+ chunks = 0;
+ freeFinalSpans = 0;
+ xfree(finalSpans);
+ finalSpans = 0;
+}
+
+static void
+fillSpans (
+ DrawablePtr pDrawable,
+ GCPtr pGC)
+{
+ register struct finalSpan *span;
+ register DDXPointPtr xSpan;
+ register int *xWidth;
+ register int i;
+ register struct finalSpan **f;
+ register int spany;
+ DDXPointPtr xSpans;
+ int *xWidths;
+
+ if (nspans == 0)
+ return;
+ xSpan = xSpans = (DDXPointPtr) ALLOCATE_LOCAL (nspans * sizeof (DDXPointRec));
+ xWidth = xWidths = (int *) ALLOCATE_LOCAL (nspans * sizeof (int));
+ if (xSpans && xWidths)
+ {
+ i = 0;
+ f = finalSpans;
+ for (spany = finalMiny; spany <= finalMaxy; spany++, f++) {
+ for (span = *f; span; span=span->next) {
+ if (span->max <= span->min)
+ continue;
+ xSpan->x = span->min;
+ xSpan->y = spany;
+ ++xSpan;
+ *xWidth++ = span->max - span->min;
+ ++i;
+ }
+ }
+ (*pGC->ops->FillSpans) (pDrawable, pGC, i, xSpans, xWidths, TRUE);
+ }
+ disposeFinalSpans ();
+ if (xSpans)
+ DEALLOCATE_LOCAL (xSpans);
+ if (xWidths)
+ DEALLOCATE_LOCAL (xWidths);
+ finalMiny = 0;
+ finalMaxy = -1;
+ finalSize = 0;
+ nspans = 0;
+}
+
+# define SPAN_REALLOC 100
+
+# define findSpan(y) ((finalMiny <= (y) && (y) <= finalMaxy) ? \
+ &finalSpans[(y) - finalMiny] : \
+ realFindSpan (y))
+
+static struct finalSpan **
+realFindSpan (int y)
+{
+ struct finalSpan **newSpans;
+ int newSize, newMiny, newMaxy;
+ int change;
+ int i;
+
+ if (y < finalMiny || y > finalMaxy) {
+ if (!finalSize) {
+ finalMiny = y;
+ finalMaxy = y - 1;
+ }
+ if (y < finalMiny)
+ change = finalMiny - y;
+ else
+ change = y - finalMaxy;
+ if (change >= SPAN_REALLOC)
+ change += SPAN_REALLOC;
+ else
+ change = SPAN_REALLOC;
+ newSize = finalSize + change;
+ newSpans = (struct finalSpan **) xalloc
+ (newSize * sizeof (struct finalSpan *));
+ if (!newSpans)
+ return (struct finalSpan **)NULL;
+ newMiny = finalMiny;
+ newMaxy = finalMaxy;
+ if (y < finalMiny)
+ newMiny = finalMiny - change;
+ else
+ newMaxy = finalMaxy + change;
+ if (finalSpans) {
+ memmove(((char *) newSpans) + (finalMiny-newMiny) * sizeof (struct finalSpan *),
+ (char *) finalSpans,
+ finalSize * sizeof (struct finalSpan *));
+ xfree (finalSpans);
+ }
+ if ((i = finalMiny - newMiny) > 0)
+ bzero ((char *)newSpans, i * sizeof (struct finalSpan *));
+ if ((i = newMaxy - finalMaxy) > 0)
+ bzero ((char *)(newSpans + newSize - i),
+ i * sizeof (struct finalSpan *));
+ finalSpans = newSpans;
+ finalMaxy = newMaxy;
+ finalMiny = newMiny;
+ finalSize = newSize;
+ }
+ return &finalSpans[y - finalMiny];
+}
+
+static void
+newFinalSpan (
+ int y,
+ register int xmin,
+ register int xmax)
+{
+ register struct finalSpan *x;
+ register struct finalSpan **f;
+ struct finalSpan *oldx;
+ struct finalSpan *prev;
+
+ f = findSpan (y);
+ if (!f)
+ return;
+ oldx = 0;
+ for (;;) {
+ prev = 0;
+ for (x = *f; x; x=x->next) {
+ if (x == oldx) {
+ prev = x;
+ continue;
+ }
+ if (x->min <= xmax && xmin <= x->max) {
+ if (oldx) {
+ oldx->min = min (x->min, xmin);
+ oldx->max = max (x->max, xmax);
+ if (prev)
+ prev->next = x->next;
+ else
+ *f = x->next;
+ --nspans;
+ } else {
+ x->min = min (x->min, xmin);
+ x->max = max (x->max, xmax);
+ oldx = x;
+ }
+ xmin = oldx->min;
+ xmax = oldx->max;
+ break;
+ }
+ prev = x;
+ }
+ if (!x)
+ break;
+ }
+ if (!oldx) {
+ x = allocFinalSpan ();
+ if (x)
+ {
+ x->min = xmin;
+ x->max = xmax;
+ x->next = *f;
+ *f = x;
+ ++nspans;
+ }
+ }
+}
+
+static void
+mirrorSppPoint (
+ int quadrant,
+ SppPointPtr sppPoint)
+{
+ switch (quadrant) {
+ case 0:
+ break;
+ case 1:
+ sppPoint->x = -sppPoint->x;
+ break;
+ case 2:
+ sppPoint->x = -sppPoint->x;
+ sppPoint->y = -sppPoint->y;
+ break;
+ case 3:
+ sppPoint->y = -sppPoint->y;
+ break;
+ }
+ /*
+ * and translate to X coordinate system
+ */
+ sppPoint->y = -sppPoint->y;
+}
+
+/*
+ * split an arc into pieces which are scan-converted
+ * in the first-quadrant and mirrored into position.
+ * This is necessary as the scan-conversion code can
+ * only deal with arcs completely contained in the
+ * first quadrant.
+ */
+
+static void
+drawArc (
+ xArc *tarc,
+ int l,
+ int a0,
+ int a1,
+ miArcFacePtr right,
+ miArcFacePtr left) /* save end line points */
+{
+ struct arc_def def;
+ struct accelerators acc;
+ int startq, endq, curq;
+ int rightq, leftq = 0, righta = 0, lefta = 0;
+ miArcFacePtr passRight, passLeft;
+ int q0 = 0, q1 = 0, mask;
+ struct band {
+ int a0, a1;
+ int mask;
+ } band[5], sweep[20];
+ int bandno, sweepno;
+ int i, j;
+ int flipRight = 0, flipLeft = 0;
+ int copyEnd = 0;
+ miArcSpanData *spdata;
+ Bool mustFree;
+
+ spdata = miComputeWideEllipse(l, tarc, &mustFree);
+ if (!spdata)
+ return;
+
+ if (a1 < a0)
+ a1 += 360 * 64;
+ startq = a0 / (90 * 64);
+ if (a0 == a1)
+ endq = startq;
+ else
+ endq = (a1-1) / (90 * 64);
+ bandno = 0;
+ curq = startq;
+ rightq = -1;
+ for (;;) {
+ switch (curq) {
+ case 0:
+ if (a0 > 90 * 64)
+ q0 = 0;
+ else
+ q0 = a0;
+ if (a1 < 360 * 64)
+ q1 = min (a1, 90 * 64);
+ else
+ q1 = 90 * 64;
+ if (curq == startq && a0 == q0 && rightq < 0) {
+ righta = q0;
+ rightq = curq;
+ }
+ if (curq == endq && a1 == q1) {
+ lefta = q1;
+ leftq = curq;
+ }
+ break;
+ case 1:
+ if (a1 < 90 * 64)
+ q0 = 0;
+ else
+ q0 = 180 * 64 - min (a1, 180 * 64);
+ if (a0 > 180 * 64)
+ q1 = 90 * 64;
+ else
+ q1 = 180 * 64 - max (a0, 90 * 64);
+ if (curq == startq && 180 * 64 - a0 == q1) {
+ righta = q1;
+ rightq = curq;
+ }
+ if (curq == endq && 180 * 64 - a1 == q0) {
+ lefta = q0;
+ leftq = curq;
+ }
+ break;
+ case 2:
+ if (a0 > 270 * 64)
+ q0 = 0;
+ else
+ q0 = max (a0, 180 * 64) - 180 * 64;
+ if (a1 < 180 * 64)
+ q1 = 90 * 64;
+ else
+ q1 = min (a1, 270 * 64) - 180 * 64;
+ if (curq == startq && a0 - 180*64 == q0) {
+ righta = q0;
+ rightq = curq;
+ }
+ if (curq == endq && a1 - 180 * 64 == q1) {
+ lefta = q1;
+ leftq = curq;
+ }
+ break;
+ case 3:
+ if (a1 < 270 * 64)
+ q0 = 0;
+ else
+ q0 = 360 * 64 - min (a1, 360 * 64);
+ q1 = 360 * 64 - max (a0, 270 * 64);
+ if (curq == startq && 360 * 64 - a0 == q1) {
+ righta = q1;
+ rightq = curq;
+ }
+ if (curq == endq && 360 * 64 - a1 == q0) {
+ lefta = q0;
+ leftq = curq;
+ }
+ break;
+ }
+ band[bandno].a0 = q0;
+ band[bandno].a1 = q1;
+ band[bandno].mask = 1 << curq;
+ bandno++;
+ if (curq == endq)
+ break;
+ curq++;
+ if (curq == 4) {
+ a0 = 0;
+ a1 -= 360 * 64;
+ curq = 0;
+ endq -= 4;
+ }
+ }
+ sweepno = 0;
+ for (;;) {
+ q0 = 90 * 64;
+ mask = 0;
+ /*
+ * find left-most point
+ */
+ for (i = 0; i < bandno; i++)
+ if (band[i].a0 <= q0) {
+ q0 = band[i].a0;
+ q1 = band[i].a1;
+ mask = band[i].mask;
+ }
+ if (!mask)
+ break;
+ /*
+ * locate next point of change
+ */
+ for (i = 0; i < bandno; i++)
+ if (!(mask & band[i].mask)) {
+ if (band[i].a0 == q0) {
+ if (band[i].a1 < q1)
+ q1 = band[i].a1;
+ mask |= band[i].mask;
+ } else if (band[i].a0 < q1)
+ q1 = band[i].a0;
+ }
+ /*
+ * create a new sweep
+ */
+ sweep[sweepno].a0 = q0;
+ sweep[sweepno].a1 = q1;
+ sweep[sweepno].mask = mask;
+ sweepno++;
+ /*
+ * subtract the sweep from the affected bands
+ */
+ for (i = 0; i < bandno; i++)
+ if (band[i].a0 == q0) {
+ band[i].a0 = q1;
+ /*
+ * check if this band is empty
+ */
+ if (band[i].a0 == band[i].a1)
+ band[i].a1 = band[i].a0 = 90 * 64 + 1;
+ }
+ }
+ computeAcc (tarc, l, &def, &acc);
+ for (j = 0; j < sweepno; j++) {
+ mask = sweep[j].mask;
+ passRight = passLeft = 0;
+ if (mask & (1 << rightq)) {
+ if (sweep[j].a0 == righta)
+ passRight = right;
+ else if (sweep[j].a1 == righta) {
+ passLeft = right;
+ flipRight = 1;
+ }
+ }
+ if (mask & (1 << leftq)) {
+ if (sweep[j].a1 == lefta)
+ {
+ if (passLeft)
+ copyEnd = 1;
+ passLeft = left;
+ }
+ else if (sweep[j].a0 == lefta) {
+ if (passRight)
+ copyEnd = 1;
+ passRight = left;
+ flipLeft = 1;
+ }
+ }
+ drawQuadrant (&def, &acc, sweep[j].a0, sweep[j].a1, mask,
+ passRight, passLeft, spdata);
+ }
+ /*
+ * when copyEnd is set, both ends of the arc were computed
+ * at the same time; drawQuadrant only takes one end though,
+ * so the left end will be the only one holding the data. Copy
+ * it from there.
+ */
+ if (copyEnd)
+ *right = *left;
+ /*
+ * mirror the coordinates generated for the
+ * faces of the arc
+ */
+ if (right) {
+ mirrorSppPoint (rightq, &right->clock);
+ mirrorSppPoint (rightq, &right->center);
+ mirrorSppPoint (rightq, &right->counterClock);
+ if (flipRight) {
+ SppPointRec temp;
+
+ temp = right->clock;
+ right->clock = right->counterClock;
+ right->counterClock = temp;
+ }
+ }
+ if (left) {
+ mirrorSppPoint (leftq, &left->counterClock);
+ mirrorSppPoint (leftq, &left->center);
+ mirrorSppPoint (leftq, &left->clock);
+ if (flipLeft) {
+ SppPointRec temp;
+
+ temp = left->clock;
+ left->clock = left->counterClock;
+ left->counterClock = temp;
+ }
+ }
+ if (mustFree)
+ xfree(spdata);
+}
+
+static void
+drawQuadrant (
+ struct arc_def *def,
+ struct accelerators *acc,
+ int a0,
+ int a1,
+ int mask,
+ miArcFacePtr right,
+ miArcFacePtr left,
+ miArcSpanData *spdata)
+{
+ struct arc_bound bound;
+ double yy, x, xalt;
+ int y, miny, maxy;
+ int n;
+ miArcSpan *span;
+
+ def->a0 = ((double) a0) / 64.0;
+ def->a1 = ((double) a1) / 64.0;
+ computeBound (def, &bound, acc, right, left);
+ yy = bound.inner.min;
+ if (bound.outer.min < yy)
+ yy = bound.outer.min;
+ miny = ICEIL(yy - acc->fromIntY);
+ yy = bound.inner.max;
+ if (bound.outer.max > yy)
+ yy = bound.outer.max;
+ maxy = floor(yy - acc->fromIntY);
+ y = spdata->k;
+ span = spdata->spans;
+ if (spdata->top)
+ {
+ if (a1 == 90 * 64 && (mask & 1))
+ newFinalSpan (acc->yorgu - y - 1, acc->xorg, acc->xorg + 1);
+ span++;
+ }
+ for (n = spdata->count1; --n >= 0; )
+ {
+ if (y < miny)
+ return;
+ if (y <= maxy) {
+ arcSpan (y,
+ span->lx, -span->lx, 0, span->lx + span->lw,
+ def, &bound, acc, mask);
+ if (span->rw + span->rx)
+ tailSpan (y, -span->rw, -span->rx, def, &bound, acc, mask);
+ }
+ y--;
+ span++;
+ }
+ if (y < miny)
+ return;
+ if (spdata->hole)
+ {
+ if (y <= maxy)
+ arcSpan (y, 0, 0, 0, 1, def, &bound, acc, mask & 0xc);
+ }
+ for (n = spdata->count2; --n >= 0; )
+ {
+ if (y < miny)
+ return;
+ if (y <= maxy)
+ arcSpan (y, span->lx, span->lw, span->rx, span->rw,
+ def, &bound, acc, mask);
+ y--;
+ span++;
+ }
+ if (spdata->bot && miny <= y && y <= maxy)
+ {
+ n = mask;
+ if (y == miny)
+ n &= 0xc;
+ if (span->rw <= 0) {
+ arcSpan0 (span->lx, -span->lx, 0, span->lx + span->lw,
+ def, &bound, acc, n);
+ if (span->rw + span->rx)
+ tailSpan (y, -span->rw, -span->rx, def, &bound, acc, n);
+ }
+ else
+ arcSpan0 (span->lx, span->lw, span->rx, span->rw,
+ def, &bound, acc, n);
+ y--;
+ }
+ while (y >= miny) {
+ yy = y + acc->fromIntY;
+ if (def->w == def->h) {
+ xalt = def->w - def->l;
+ x = -sqrt(xalt * xalt - yy * yy);
+ } else {
+ x = tailX(yy, def, &bound, acc);
+ if (acc->left.valid && boundedLe (yy, bound.left)) {
+ xalt = intersectLine (yy, acc->left);
+ if (xalt < x)
+ x = xalt;
+ }
+ if (acc->right.valid && boundedLe (yy, bound.right)) {
+ xalt = intersectLine (yy, acc->right);
+ if (xalt < x)
+ x = xalt;
+ }
+ }
+ arcSpan (y,
+ ICEIL(acc->fromIntX - x), 0,
+ ICEIL(acc->fromIntX + x), 0,
+ def, &bound, acc, mask);
+ y--;
+ }
+}
diff --git a/nx-X11/programs/Xserver/mi/mibank.c b/nx-X11/programs/Xserver/mi/mibank.c
new file mode 100644
index 000000000..b09f9fd7c
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mibank.c
@@ -0,0 +1,2577 @@
+/*
+ * Copyright 1997 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of Marc Aurele La France not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. Marc Aurele La France makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as-is" without express or implied warranty.
+ *
+ * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+ * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * Copyright 1990,91,92,93 by Thomas Roell, Germany.
+ * Copyright 1991,92,93 by SGCS (Snitily Graphics Consulting Services), USA.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation, and that the name of Thomas Roell nor
+ * SGCS be used in advertising or publicity pertaining to distribution
+ * of the software without specific, written prior permission.
+ * Thomas Roell nor SGCS makes no representations about the suitability
+ * of this software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ *
+ * THOMAS ROELL AND SGCS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR SGCS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* $XFree86: xc/programs/Xserver/mi/mibank.c,v 1.15 2003/11/10 18:39:16 tsi Exp $ */
+
+/*
+ * This thing originated from an idea of Edwin Goei and his bank switching
+ * code for the DEC TX board.
+ */
+
+/*
+ * Heavily modified for the XFree86 Project to turn this into an mi wrapper.
+ * --- Marc Aurele La France (tsi@xfree86.org)
+ */
+
+/*
+ * "Heavily modified", indeed! By the time this is finalized, there probably
+ * won't be much left of Roell's code...
+ *
+ * Miscellaneous notes:
+ * - Pixels with imbedded bank boundaries are required to be off-screen. There
+ * >might< be a way to fool the underlying framebuffer into dealing with
+ * partial pixels.
+ * - Plans to generalise this to do (hardware) colour plane switching have been
+ * dropped due to colour flashing concerns.
+ *
+ * TODO:
+ * - Allow miModifyBanking() to change BankSize and nBankDepth.
+ * - Re-instate shared and double banking for framebuffers whose pixmap formats
+ * don't describe how the server "sees" the screen.
+ * - Remove remaining assumptions that a pixmap's devPrivate field points
+ * directly to its pixel data.
+ */
+
+/* #define NO_ALLOCA 1 */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "servermd.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "mibank.h"
+
+#define BANK_SINGLE 0
+#define BANK_SHARED 1
+#define BANK_DOUBLE 2
+#define BANK_NOBANK 3
+
+typedef struct _miBankScreen
+{
+ miBankInfoRec BankInfo;
+ unsigned int nBankBPP;
+ unsigned int type;
+
+ unsigned long nBitsPerBank;
+ unsigned long nBitsPerScanline;
+ unsigned long nPixelsPerScanlinePadUnit;
+
+ PixmapPtr pScreenPixmap;
+ PixmapPtr pBankPixmap;
+ GCPtr pBankGC;
+
+ int nBanks, maxRects;
+ RegionPtr *pBanks;
+
+ pointer pbits;
+
+ /*
+ * Screen Wrappers
+ */
+ CreateScreenResourcesProcPtr CreateScreenResources;
+ ModifyPixmapHeaderProcPtr ModifyPixmapHeader;
+ CloseScreenProcPtr CloseScreen;
+ GetImageProcPtr GetImage;
+ GetSpansProcPtr GetSpans;
+ CreateGCProcPtr CreateGC;
+ PaintWindowBackgroundProcPtr PaintWindowBackground;
+ PaintWindowBorderProcPtr PaintWindowBorder;
+ CopyWindowProcPtr CopyWindow;
+ BSFuncRec BackingStoreFuncs;
+} miBankScreenRec, *miBankScreenPtr;
+
+typedef struct _miBankGC
+{
+ GCOps *wrappedOps, *unwrappedOps;
+ GCFuncs *wrappedFuncs, *unwrappedFuncs;
+
+ Bool fastCopy, fastPlane;
+
+ RegionPtr pBankedClips[1];
+} miBankGCRec, *miBankGCPtr;
+
+typedef struct _miBankQueue
+{
+ Bool fastBlit;
+ unsigned short srcBankNo;
+ unsigned short dstBankNo;
+ short x;
+ short y;
+ short w;
+ short h;
+} miBankQueue;
+
+/*
+ * CAVEAT: This banking scheme requires that the DDX store Pixmap data in the
+ * server's address space.
+ */
+
+#define ModifyPixmap(_pPix, _width, _devKind, _pbits) \
+ (*pScreen->ModifyPixmapHeader)((_pPix), \
+ (_width), -1, -1, -1, (_devKind), (_pbits))
+
+#define SET_SINGLE_BANK(_pPix, _width, _devKind, _no) \
+ ModifyPixmap(_pPix, _width, _devKind, \
+ (char *)pScreenPriv->BankInfo.pBankA + \
+ (*pScreenPriv->BankInfo.SetSourceAndDestinationBanks)(pScreen, (_no)) - \
+ (pScreenPriv->BankInfo.BankSize * (_no)))
+
+#define SET_SOURCE_BANK(_pPix, _width, _devKind, _no) \
+ ModifyPixmap(_pPix, _width, _devKind, \
+ (char *)pScreenPriv->BankInfo.pBankA + \
+ (*pScreenPriv->BankInfo.SetSourceBank)(pScreen, (_no)) - \
+ (pScreenPriv->BankInfo.BankSize * (_no)))
+
+#define SET_DESTINATION_BANK(_pPix, _width, _devKind, _no) \
+ ModifyPixmap(_pPix, _width, _devKind, \
+ (char *)pScreenPriv->BankInfo.pBankB + \
+ (*pScreenPriv->BankInfo.SetDestinationBank)(pScreen, (_no)) - \
+ (pScreenPriv->BankInfo.BankSize * (_no)))
+
+#define ALLOCATE_LOCAL_ARRAY(atype, ntype) \
+ (atype *)ALLOCATE_LOCAL((ntype) * sizeof(atype))
+
+static int miBankScreenIndex;
+static int miBankGCIndex;
+static unsigned long miBankGeneration = 0;
+
+#define BANK_SCRPRIVLVAL pScreen->devPrivates[miBankScreenIndex].ptr
+
+#define BANK_SCRPRIVATE ((miBankScreenPtr)(BANK_SCRPRIVLVAL))
+
+#define BANK_GCPRIVLVAL(pGC) (pGC)->devPrivates[miBankGCIndex].ptr
+
+#define BANK_GCPRIVATE(pGC) ((miBankGCPtr)(BANK_GCPRIVLVAL(pGC)))
+
+#define PIXMAP_STATUS(_pPix) \
+ pointer pbits = (_pPix)->devPrivate.ptr
+
+#define PIXMAP_SAVE(_pPix) \
+ PIXMAP_STATUS(_pPix); \
+ if (pbits == (pointer)pScreenPriv) \
+ (_pPix)->devPrivate.ptr = pScreenPriv->pbits
+
+#define PIXMAP_RESTORE(_pPix) \
+ (_pPix)->devPrivate.ptr = pbits
+
+#define BANK_SAVE \
+ int width = pScreenPriv->pBankPixmap->drawable.width; \
+ int devKind = pScreenPriv->pBankPixmap->devKind; \
+ PIXMAP_SAVE(pScreenPriv->pBankPixmap)
+
+#define BANK_RESTORE \
+ pScreenPriv->pBankPixmap->drawable.width = width; \
+ pScreenPriv->pBankPixmap->devKind = devKind; \
+ PIXMAP_RESTORE(pScreenPriv->pBankPixmap)
+
+#define SCREEN_STATUS \
+ PIXMAP_STATUS(pScreenPriv->pScreenPixmap)
+
+#define SCREEN_SAVE \
+ PIXMAP_SAVE(pScreenPriv->pScreenPixmap)
+
+#define SCREEN_RESTORE \
+ PIXMAP_RESTORE(pScreenPriv->pScreenPixmap)
+
+#define SCREEN_INIT \
+ miBankScreenPtr pScreenPriv = BANK_SCRPRIVATE
+
+#define SCREEN_UNWRAP(field) \
+ pScreen->field = pScreenPriv->field
+
+#define SCREEN_WRAP(field, wrapper) \
+ pScreenPriv->field = pScreen->field; \
+ pScreen->field = wrapper
+
+#define GC_INIT(pGC) \
+ miBankGCPtr pGCPriv = BANK_GCPRIVATE(pGC)
+
+#define GC_UNWRAP(pGC) \
+ pGCPriv->unwrappedOps = (pGC)->ops; \
+ pGCPriv->unwrappedFuncs = (pGC)->funcs; \
+ (pGC)->ops = pGCPriv->wrappedOps; \
+ (pGC)->funcs = pGCPriv->wrappedFuncs
+
+#define GC_WRAP(pGC) \
+ pGCPriv->wrappedOps = (pGC)->ops; \
+ pGCPriv->wrappedFuncs = (pGC)->funcs; \
+ (pGC)->ops = pGCPriv->unwrappedOps; \
+ (pGC)->funcs = pGCPriv->unwrappedFuncs
+
+#define IS_BANKED(pDrawable) \
+ ((pbits == (pointer)pScreenPriv) && \
+ (((DrawablePtr)(pDrawable))->type == DRAWABLE_WINDOW))
+
+#define CLIP_SAVE \
+ RegionPtr pOrigCompositeClip = pGC->pCompositeClip
+
+#define CLIP_RESTORE \
+ pGC->pCompositeClip = pOrigCompositeClip
+
+#define GCOP_INIT \
+ ScreenPtr pScreen = pGC->pScreen; \
+ SCREEN_INIT; \
+ GC_INIT(pGC)
+
+#define GCOP_UNWRAP \
+ GC_UNWRAP(pGC)
+
+#define GCOP_WRAP \
+ GC_WRAP(pGC)
+
+#define GCOP_TOP_PART \
+ for (i = 0; i < pScreenPriv->nBanks; i++) \
+ { \
+ if (!(pGC->pCompositeClip = pGCPriv->pBankedClips[i])) \
+ continue; \
+ GCOP_UNWRAP; \
+ SET_SINGLE_BANK(pScreenPriv->pScreenPixmap, -1, -1, i)
+
+#define GCOP_BOTTOM_PART \
+ GCOP_WRAP; \
+ }
+
+#define GCOP_SIMPLE(statement) \
+ if (nArray > 0) \
+ { \
+ GCOP_INIT; \
+ SCREEN_SAVE; \
+ if (!IS_BANKED(pDrawable)) \
+ { \
+ GCOP_UNWRAP; \
+ statement; \
+ GCOP_WRAP; \
+ } \
+ else \
+ { \
+ int i; \
+ CLIP_SAVE; \
+ GCOP_TOP_PART; \
+ statement; \
+ GCOP_BOTTOM_PART; \
+ CLIP_RESTORE; \
+ } \
+ SCREEN_RESTORE; \
+ }
+
+#define GCOP_0D_ARGS mode,
+#define GCOP_1D_ARGS
+#define GCOP_2D_ARGS shape, mode,
+
+#define GCOP_COMPLEX(aop, atype) \
+ if (nArray > 0) \
+ { \
+ GCOP_INIT; \
+ SCREEN_SAVE; \
+ if (!IS_BANKED(pDrawable)) \
+ { \
+ GCOP_UNWRAP; \
+ (*pGC->ops->aop)(pDrawable, pGC, GCOP_ARGS nArray, pArray); \
+ GCOP_WRAP; \
+ } \
+ else \
+ { \
+ atype *aarg = pArray, *acopy; \
+ int i; \
+ CLIP_SAVE; \
+ if ((acopy = ALLOCATE_LOCAL_ARRAY(atype, nArray))) \
+ aarg = acopy; \
+ GCOP_TOP_PART; \
+ if (acopy) \
+ memcpy(acopy, pArray, nArray * sizeof(atype)); \
+ (*pGC->ops->aop)(pDrawable, pGC, GCOP_ARGS nArray, aarg); \
+ GCOP_BOTTOM_PART; \
+ DEALLOCATE_LOCAL(acopy); \
+ CLIP_RESTORE; \
+ } \
+ SCREEN_RESTORE; \
+ }
+
+/*********************
+ * Utility functions *
+ *********************/
+
+static int
+miBankOf(
+ miBankScreenPtr pScreenPriv,
+ int x,
+ int y
+)
+{
+ int iBank = ((x * (int)pScreenPriv->nBankBPP) +
+ (y * (long)pScreenPriv->nBitsPerScanline)) /
+ (long)pScreenPriv->nBitsPerBank;
+
+ if (iBank < 0)
+ iBank = 0;
+ else if (iBank >= pScreenPriv->nBanks)
+ iBank = pScreenPriv->nBanks - 1;
+
+ return iBank;
+}
+
+#define FirstBankOf(_x, _y) miBankOf(pScreenPriv, (_x), (_y))
+#define LastBankOf(_x, _y) miBankOf(pScreenPriv, (_x) - 1, (_y))
+
+/* Determine banking type from the BankInfoRec */
+static unsigned int
+miBankDeriveType(
+ ScreenPtr pScreen,
+ miBankInfoPtr pBankInfo
+)
+{
+ unsigned int type;
+
+ if (pBankInfo->pBankA == pBankInfo->pBankB)
+ {
+ if (pBankInfo->SetSourceBank == pBankInfo->SetDestinationBank)
+ {
+ if (pBankInfo->SetSourceAndDestinationBanks !=
+ pBankInfo->SetSourceBank)
+ return BANK_NOBANK;
+
+ type = BANK_SINGLE;
+ }
+ else
+ {
+ if (pBankInfo->SetSourceAndDestinationBanks ==
+ pBankInfo->SetDestinationBank)
+ return BANK_NOBANK;
+ if (pBankInfo->SetSourceAndDestinationBanks ==
+ pBankInfo->SetSourceBank)
+ return BANK_NOBANK;
+
+ type = BANK_SHARED;
+ }
+ }
+ else
+ {
+ if ((unsigned long)abs((char *)pBankInfo->pBankA -
+ (char *)pBankInfo->pBankB) < pBankInfo->BankSize)
+ return BANK_NOBANK;
+
+ if (pBankInfo->SetSourceBank == pBankInfo->SetDestinationBank)
+ {
+ if (pBankInfo->SetSourceAndDestinationBanks !=
+ pBankInfo->SetSourceBank)
+ return BANK_NOBANK;
+ }
+ else
+ {
+ if (pBankInfo->SetSourceAndDestinationBanks ==
+ pBankInfo->SetDestinationBank)
+ return BANK_NOBANK;
+ }
+
+ type = BANK_DOUBLE;
+ }
+
+ /*
+ * Internal limitation: Currently, only single banking is supported when
+ * the pixmap format and the screen's pixel format are different. The
+ * following test is only partially successful at detecting this condition.
+ */
+ if (pBankInfo->nBankDepth != pScreen->rootDepth)
+ type = BANK_SINGLE;
+
+ return type;
+}
+
+/* Least common multiple */
+static unsigned int
+miLCM(
+ unsigned int x,
+ unsigned int y
+)
+{
+ unsigned int m = x, n = y, o;
+
+ while ((o = m % n))
+ {
+ m = n;
+ n = o;
+ }
+
+ return (x / n) * y;
+}
+
+/******************
+ * GCOps wrappers *
+ ******************/
+
+static void
+miBankFillSpans(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArray,
+ DDXPointPtr pptInit,
+ int *pwidthInit,
+ int fSorted
+)
+{
+ GCOP_SIMPLE((*pGC->ops->FillSpans)(pDrawable, pGC,
+ nArray, pptInit, pwidthInit, fSorted));
+}
+
+static void
+miBankSetSpans(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *psrc,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nArray,
+ int fSorted
+)
+{
+ GCOP_SIMPLE((*pGC->ops->SetSpans)(pDrawable, pGC, psrc,
+ ppt, pwidth, nArray, fSorted));
+}
+
+static void
+miBankPutImage(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int depth,
+ int x,
+ int y,
+ int w,
+ int h,
+ int leftPad,
+ int format,
+ char *pImage
+)
+{
+ if ((w > 0) && (h > 0))
+ {
+ GCOP_INIT;
+ SCREEN_SAVE;
+
+ if (!IS_BANKED(pDrawable))
+ {
+ GCOP_UNWRAP;
+
+ (*pGC->ops->PutImage)(pDrawable, pGC, depth, x, y, w, h,
+ leftPad, format, pImage);
+
+ GCOP_WRAP;
+ }
+ else
+ {
+ int i, j;
+
+ CLIP_SAVE;
+
+ i = FirstBankOf(x + pDrawable->x, y + pDrawable->y);
+ j = LastBankOf(x + pDrawable->x + w, y + pDrawable->y + h);
+ for (; i <= j; i++)
+ {
+ if (!(pGC->pCompositeClip = pGCPriv->pBankedClips[i]))
+ continue;
+
+ GCOP_UNWRAP;
+
+ SET_SINGLE_BANK(pScreenPriv->pScreenPixmap, -1, -1, i);
+
+ (*pGC->ops->PutImage)(pDrawable, pGC, depth, x, y, w, h,
+ leftPad, format, pImage);
+
+ GCOP_WRAP;
+ }
+
+ CLIP_RESTORE;
+ }
+
+ SCREEN_RESTORE;
+ }
+}
+
+/*
+ * Here the CopyArea/CopyPlane wrappers. First off, we have to clip against
+ * the source in order to make the minimal number of copies in case of slow
+ * systems. Also the exposure handling is quite tricky. Special attention
+ * is to be given to the way the copies are sequenced. The list of boxes after
+ * the source clip is used to build a workqueue, that contains the atomic
+ * copies (i.e. only from one bank to one bank). Doing so produces a minimal
+ * list of things to do.
+ */
+static RegionPtr
+miBankCopy(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx,
+ int srcy,
+ int w,
+ int h,
+ int dstx,
+ int dsty,
+ unsigned long plane,
+ Bool SinglePlane
+)
+{
+ int cx1, cy1, cx2, cy2;
+ int ns, nd, nse, nde, dx, dy, xorg = 0, yorg = 0;
+ int maxWidth = 0, maxHeight = 0, paddedWidth = 0;
+ int nBox, nBoxClipSrc, nBoxClipDst, nQueue;
+ BoxPtr pBox, pBoxClipSrc, pBoxClipDst;
+ BoxRec fastBox, ccBox;
+ RegionPtr ret = NULL, prgnSrcClip = NULL;
+ RegionRec rgnDst;
+ char *pImage = NULL;
+ miBankQueue *pQueue, *pQueueNew, *Queue;
+ miBankQueue *pQueueTmp, *pQueueNext, *pQueueBase;
+ Bool fastBlit, freeSrcClip, fastClip;
+ Bool fExpose = FALSE, fastExpose = FALSE;
+
+ GCOP_INIT;
+ SCREEN_SAVE;
+
+ if (!IS_BANKED(pSrc) && !IS_BANKED(pDst))
+ {
+ GCOP_UNWRAP;
+
+ if (SinglePlane)
+ ret = (*pGC->ops->CopyPlane)(pSrc, pDst, pGC,
+ srcx, srcy, w, h, dstx, dsty, plane);
+ else
+ ret = (*pGC->ops->CopyArea)(pSrc, pDst, pGC,
+ srcx, srcy, w, h, dstx, dsty);
+
+ GCOP_WRAP;
+ }
+ else if (!IS_BANKED(pDst))
+ {
+ fExpose = pGC->fExpose;
+ pGC->fExpose = FALSE;
+
+ xorg = pSrc->x;
+ yorg = pSrc->y;
+ dx = dstx - srcx;
+ dy = dsty - srcy;
+ srcx += xorg;
+ srcy += yorg;
+
+ ns = FirstBankOf(srcx, srcy);
+ nse = LastBankOf(srcx + w, srcy + h);
+ for (; ns <= nse; ns++)
+ {
+ if (!pScreenPriv->pBanks[ns])
+ continue;
+
+ nBox = REGION_NUM_RECTS(pScreenPriv->pBanks[ns]);
+ pBox = REGION_RECTS(pScreenPriv->pBanks[ns]);
+
+ for (; nBox--; pBox++)
+ {
+ cx1 = max(pBox->x1, srcx);
+ cy1 = max(pBox->y1, srcy);
+ cx2 = min(pBox->x2, srcx + w);
+ cy2 = min(pBox->y2, srcy + h);
+
+ if ((cx1 >= cx2) || (cy1 >= cy2))
+ continue;
+
+ GCOP_UNWRAP;
+
+ SET_SINGLE_BANK(pScreenPriv->pScreenPixmap, -1, -1, ns);
+
+ if (SinglePlane)
+ (*pGC->ops->CopyPlane)(pSrc, pDst, pGC,
+ cx1 - xorg, cy1 - yorg,
+ cx2 - cx1, cy2 - cy1,
+ cx1 + dx - xorg, cy1 + dy - yorg, plane);
+ else
+ (*pGC->ops->CopyArea)(pSrc, pDst, pGC,
+ cx1 - xorg, cy1 - yorg,
+ cx2 - cx1, cy2 - cy1,
+ cx1 + dx - xorg, cy1 + dy - yorg);
+
+ GCOP_WRAP;
+ }
+ }
+
+ pGC->fExpose = fExpose;
+ srcx -= xorg;
+ srcy -= yorg;
+ }
+ else if (!IS_BANKED(pSrc))
+ {
+ CLIP_SAVE;
+
+ if (pGC->miTranslate)
+ {
+ xorg = pDst->x;
+ yorg = pDst->y;
+ }
+ dx = srcx - dstx;
+ dy = srcy - dsty;
+ dstx += xorg;
+ dsty += yorg;
+
+ nd = FirstBankOf(dstx, dsty);
+ nde = LastBankOf(dstx + w, dsty + h);
+ for (; nd <= nde; nd++)
+ {
+ if (!(pGC->pCompositeClip = pGCPriv->pBankedClips[nd]))
+ continue;
+
+ /*
+ * It's faster to let the lower-level CopyArea do the clipping
+ * within each bank.
+ */
+ nBox = REGION_NUM_RECTS(pScreenPriv->pBanks[nd]);
+ pBox = REGION_RECTS(pScreenPriv->pBanks[nd]);
+
+ for (; nBox--; pBox++)
+ {
+ cx1 = max(pBox->x1, dstx);
+ cy1 = max(pBox->y1, dsty);
+ cx2 = min(pBox->x2, dstx + w);
+ cy2 = min(pBox->y2, dsty + h);
+
+ if ((cx1 >= cx2) || (cy1 >= cy2))
+ continue;
+
+ GCOP_UNWRAP;
+
+ SET_SINGLE_BANK(pScreenPriv->pScreenPixmap, -1, -1, nd);
+
+ if (SinglePlane)
+ (*pGC->ops->CopyPlane)(pSrc, pDst, pGC,
+ cx1 + dx - xorg, cy1 + dy - yorg,
+ cx2 - cx1, cy2 - cy1,
+ cx1 - xorg, cy1 - yorg, plane);
+ else
+ (*pGC->ops->CopyArea)(pSrc, pDst, pGC,
+ cx1 + dx - xorg, cy1 + dy - yorg,
+ cx2 - cx1, cy2 - cy1,
+ cx1 - xorg, cy1 - yorg);
+
+ GCOP_WRAP;
+ }
+ }
+
+ CLIP_RESTORE;
+ }
+ else /* IS_BANKED(pSrc) && IS_BANKED(pDst) */
+ {
+ CLIP_SAVE;
+
+ fExpose = pGC->fExpose;
+
+ fastBox.x1 = srcx + pSrc->x;
+ fastBox.y1 = srcy + pSrc->y;
+ fastBox.x2 = fastBox.x1 + w;
+ fastBox.y2 = fastBox.y1 + h;
+
+ dx = dstx - fastBox.x1;
+ dy = dsty - fastBox.y1;
+ if (pGC->miTranslate)
+ {
+ xorg = pDst->x;
+ yorg = pDst->y;
+ }
+
+ /*
+ * Clip against the source. Otherwise we will blit too much for SINGLE
+ * and SHARED banked systems.
+ */
+ freeSrcClip = FALSE;
+ fastClip = FALSE;
+ fastExpose = FALSE;
+
+ if (pGC->subWindowMode != IncludeInferiors)
+ prgnSrcClip = &((WindowPtr)pSrc)->clipList;
+ else if (!((WindowPtr)pSrc)->parent)
+ fastClip = TRUE;
+ else if ((pSrc == pDst) && (pGC->clientClipType == CT_NONE))
+ prgnSrcClip = pGC->pCompositeClip;
+ else
+ {
+ prgnSrcClip = NotClippedByChildren((WindowPtr)pSrc);
+ freeSrcClip = TRUE;
+ }
+
+ if (fastClip)
+ {
+ fastExpose = TRUE;
+
+ /*
+ * Clip the source. If regions extend beyond the source size, make
+ * sure exposure events get sent.
+ */
+ if (fastBox.x1 < pSrc->x)
+ {
+ fastBox.x1 = pSrc->x;
+ fastExpose = FALSE;
+ }
+ if (fastBox.y1 < pSrc->y)
+ {
+ fastBox.y1 = pSrc->y;
+ fastExpose = FALSE;
+ }
+ if (fastBox.x2 > pSrc->x + (int) pSrc->width)
+ {
+ fastBox.x2 = pSrc->x + (int) pSrc->width;
+ fastExpose = FALSE;
+ }
+ if (fastBox.y2 > pSrc->y + (int) pSrc->height)
+ {
+ fastBox.y2 = pSrc->y + (int) pSrc->height;
+ fastExpose = FALSE;
+ }
+
+ nBox = 1;
+ pBox = &fastBox;
+ }
+ else
+ {
+ REGION_INIT(pScreen, &rgnDst, &fastBox, 1);
+ REGION_INTERSECT(pScreen, &rgnDst, &rgnDst, prgnSrcClip);
+ pBox = REGION_RECTS(&rgnDst);
+ nBox = REGION_NUM_RECTS(&rgnDst);
+ }
+
+ /*
+ * fastBlit can only be TRUE if we don't need to worry about attempts
+ * to read partial pixels through the destination bank.
+ */
+ if (SinglePlane)
+ fastBlit = pGCPriv->fastPlane;
+ else
+ fastBlit = pGCPriv->fastCopy;
+
+ nQueue = nBox * pScreenPriv->maxRects * 2;
+ pQueue = Queue = ALLOCATE_LOCAL_ARRAY(miBankQueue, nQueue);
+
+ if (Queue)
+ {
+ for (; nBox--; pBox++)
+ {
+ ns = FirstBankOf(pBox->x1, pBox->y1);
+ nse = LastBankOf(pBox->x2, pBox->y2);
+ for (; ns <= nse; ns++)
+ {
+ if (!pScreenPriv->pBanks[ns])
+ continue;
+
+ nBoxClipSrc = REGION_NUM_RECTS(pScreenPriv->pBanks[ns]);
+ pBoxClipSrc = REGION_RECTS(pScreenPriv->pBanks[ns]);
+
+ for (; nBoxClipSrc--; pBoxClipSrc++)
+ {
+ cx1 = max(pBox->x1, pBoxClipSrc->x1);
+ cy1 = max(pBox->y1, pBoxClipSrc->y1);
+ cx2 = min(pBox->x2, pBoxClipSrc->x2);
+ cy2 = min(pBox->y2, pBoxClipSrc->y2);
+
+ /* Check to see if the region is empty */
+ if ((cx1 >= cx2) || (cy1 >= cy2))
+ continue;
+
+ /* Translate c[xy]* to destination coordinates */
+ cx1 += dx + xorg;
+ cy1 += dy + yorg;
+ cx2 += dx + xorg;
+ cy2 += dy + yorg;
+
+ nd = FirstBankOf(cx1, cy1);
+ nde = LastBankOf(cx2, cy2);
+ for (; nd <= nde; nd++)
+ {
+ if (!pGCPriv->pBankedClips[nd])
+ continue;
+
+ /*
+ * Clients can send quite large clip descriptions,
+ * so use the bank clips here instead.
+ */
+ nBoxClipDst =
+ REGION_NUM_RECTS(pScreenPriv->pBanks[nd]);
+ pBoxClipDst =
+ REGION_RECTS(pScreenPriv->pBanks[nd]);
+
+ for (; nBoxClipDst--; pBoxClipDst++)
+ {
+ ccBox.x1 = max(cx1, pBoxClipDst->x1);
+ ccBox.y1 = max(cy1, pBoxClipDst->y1);
+ ccBox.x2 = min(cx2, pBoxClipDst->x2);
+ ccBox.y2 = min(cy2, pBoxClipDst->y2);
+
+ /* Check to see if the region is empty */
+ if ((ccBox.x1 >= ccBox.x2) ||
+ (ccBox.y1 >= ccBox.y2))
+ continue;
+
+ pQueue->srcBankNo = ns;
+ pQueue->dstBankNo = nd;
+ pQueue->x = ccBox.x1 - xorg;
+ pQueue->y = ccBox.y1 - yorg;
+ pQueue->w = ccBox.x2 - ccBox.x1;
+ pQueue->h = ccBox.y2 - ccBox.y1;
+
+ if (maxWidth < pQueue->w)
+ maxWidth = pQueue->w;
+ if (maxHeight < pQueue->h)
+ maxHeight = pQueue->h;
+
+ /*
+ * When shared banking is used and the source
+ * and destination banks differ, prevent
+ * attempts to fetch partial scanline pad units
+ * through the destination bank.
+ */
+ pQueue->fastBlit = fastBlit;
+ if (fastBlit &&
+ (pScreenPriv->type == BANK_SHARED) &&
+ (ns != nd) &&
+ ((ccBox.x1 %
+ pScreenPriv->nPixelsPerScanlinePadUnit) ||
+ (ccBox.x2 %
+ pScreenPriv->nPixelsPerScanlinePadUnit) ||
+ (RECT_IN_REGION(pScreen,
+ pGCPriv->pBankedClips[nd], &ccBox) !=
+ rgnIN)))
+ pQueue->fastBlit = FALSE;
+ pQueue++;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!fastClip)
+ {
+ REGION_UNINIT(pScreen, &rgnDst);
+ if (freeSrcClip)
+ REGION_DESTROY(pScreen, prgnSrcClip);
+ }
+
+ pQueueNew = pQueue;
+ nQueue = pQueue - Queue;
+
+ if (nQueue > 0)
+ {
+ BANK_SAVE;
+
+ pQueue = Queue;
+
+ if ((nQueue > 1) &&
+ ((pSrc == pDst) || (pGC->subWindowMode == IncludeInferiors)))
+ {
+ if ((srcy + pSrc->y) < (dsty + yorg))
+ {
+ /* Sort from bottom to top */
+ pQueueBase = pQueueNext = pQueue + nQueue - 1;
+
+ while (pQueueBase >= pQueue)
+ {
+ while ((pQueueNext >= pQueue) &&
+ (pQueueBase->y == pQueueNext->y))
+ pQueueNext--;
+
+ pQueueTmp = pQueueNext + 1;
+ while (pQueueTmp <= pQueueBase)
+ *pQueueNew++ = *pQueueTmp++;
+
+ pQueueBase = pQueueNext;
+ }
+
+ pQueueNew -= nQueue;
+ pQueue = pQueueNew;
+ pQueueNew = Queue;
+ }
+
+ if ((srcx + pSrc->x) < (dstx + xorg))
+ {
+ /* Sort from right to left */
+ pQueueBase = pQueueNext = pQueue;
+
+ while (pQueueBase < pQueue + nQueue)
+ {
+ while ((pQueueNext < pQueue + nQueue) &&
+ (pQueueNext->y == pQueueBase->y))
+ pQueueNext++;
+
+ pQueueTmp = pQueueNext;
+ while (pQueueTmp != pQueueBase)
+ *pQueueNew++ = *--pQueueTmp;
+
+ pQueueBase = pQueueNext;
+ }
+
+ pQueueNew -= nQueue;
+ pQueue = pQueueNew;
+ }
+ }
+
+ paddedWidth = PixmapBytePad(maxWidth,
+ pScreenPriv->pScreenPixmap->drawable.depth);
+ pImage = (char *)ALLOCATE_LOCAL(paddedWidth * maxHeight);
+
+ pGC->fExpose = FALSE;
+
+ while (nQueue--)
+ {
+ pGC->pCompositeClip = pGCPriv->pBankedClips[pQueue->dstBankNo];
+
+ GCOP_UNWRAP;
+
+ if (pQueue->srcBankNo == pQueue->dstBankNo)
+ {
+ SET_SINGLE_BANK(pScreenPriv->pScreenPixmap,
+ -1, -1, pQueue->srcBankNo);
+
+ if (SinglePlane)
+ (*pGC->ops->CopyPlane)(pSrc, pDst, pGC,
+ pQueue->x - dx - pSrc->x, pQueue->y - dy - pSrc->y,
+ pQueue->w, pQueue->h, pQueue->x, pQueue->y, plane);
+ else
+ (*pGC->ops->CopyArea)(pSrc, pDst, pGC,
+ pQueue->x - dx - pSrc->x, pQueue->y - dy - pSrc->y,
+ pQueue->w, pQueue->h, pQueue->x, pQueue->y);
+ }
+ else if (pQueue->fastBlit)
+ {
+ SET_SOURCE_BANK (pScreenPriv->pBankPixmap,
+ pScreenPriv->pScreenPixmap->drawable.width,
+ pScreenPriv->pScreenPixmap->devKind,
+ pQueue->srcBankNo);
+ SET_DESTINATION_BANK(pScreenPriv->pScreenPixmap,
+ -1, -1, pQueue->dstBankNo);
+
+ if (SinglePlane)
+ (*pGC->ops->CopyPlane)(
+ (DrawablePtr)pScreenPriv->pBankPixmap, pDst, pGC,
+ pQueue->x - dx, pQueue->y - dy,
+ pQueue->w, pQueue->h, pQueue->x, pQueue->y, plane);
+ else
+ (*pGC->ops->CopyArea)(
+ (DrawablePtr)pScreenPriv->pBankPixmap, pDst, pGC,
+ pQueue->x - dx, pQueue->y - dy,
+ pQueue->w, pQueue->h, pQueue->x, pQueue->y);
+ }
+ else if (pImage)
+ {
+ ModifyPixmap(pScreenPriv->pBankPixmap,
+ maxWidth, paddedWidth, pImage);
+
+ SET_SINGLE_BANK(pScreenPriv->pScreenPixmap,
+ -1, -1, pQueue->srcBankNo);
+
+ (*pScreenPriv->pBankGC->ops->CopyArea)(
+ pSrc, (DrawablePtr)pScreenPriv->pBankPixmap,
+ pScreenPriv->pBankGC,
+ pQueue->x - dx - pSrc->x, pQueue->y - dy - pSrc->y,
+ pQueue->w, pQueue->h, 0, 0);
+
+ SET_SINGLE_BANK(pScreenPriv->pScreenPixmap,
+ -1, -1, pQueue->dstBankNo);
+
+ if (SinglePlane)
+ (*pGC->ops->CopyPlane)(
+ (DrawablePtr)pScreenPriv->pBankPixmap,
+ pDst, pGC, 0, 0, pQueue->w, pQueue->h,
+ pQueue->x, pQueue->y, plane);
+ else
+ (*pGC->ops->CopyArea)(
+ (DrawablePtr)pScreenPriv->pBankPixmap,
+ pDst, pGC, 0, 0, pQueue->w, pQueue->h,
+ pQueue->x, pQueue->y);
+ }
+
+ GCOP_WRAP;
+
+ pQueue++;
+ }
+
+ DEALLOCATE_LOCAL(pImage);
+
+ BANK_RESTORE;
+ }
+
+ CLIP_RESTORE;
+
+ pGC->fExpose = fExpose;
+
+ DEALLOCATE_LOCAL(Queue);
+ }
+
+ SCREEN_RESTORE;
+
+ if (!fExpose || fastExpose)
+ return ret;
+
+ return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty, 0);
+}
+
+static RegionPtr
+miBankCopyArea(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx,
+ int srcy,
+ int w,
+ int h,
+ int dstx,
+ int dsty
+)
+{
+ return miBankCopy(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty, 0, FALSE);
+}
+
+static RegionPtr
+miBankCopyPlane(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx,
+ int srcy,
+ int w,
+ int h,
+ int dstx,
+ int dsty,
+ unsigned long plane
+)
+{
+ return
+ miBankCopy(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty, plane, TRUE);
+}
+
+static void
+miBankPolyPoint(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int nArray,
+ xPoint *pArray
+)
+{
+# define GCOP_ARGS GCOP_0D_ARGS
+ GCOP_COMPLEX(PolyPoint, xPoint);
+# undef GCOP_ARGS
+}
+
+static void
+miBankPolylines(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int nArray,
+ DDXPointPtr pArray
+)
+{
+# define GCOP_ARGS GCOP_0D_ARGS
+ GCOP_COMPLEX(Polylines, DDXPointRec);
+# undef GCOP_ARGS
+}
+
+static void
+miBankPolySegment(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArray,
+ xSegment *pArray
+)
+{
+# define GCOP_ARGS GCOP_1D_ARGS
+ GCOP_COMPLEX(PolySegment, xSegment);
+# undef GCOP_ARGS
+}
+
+static void
+miBankPolyRectangle(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArray,
+ xRectangle *pArray
+)
+{
+# define GCOP_ARGS GCOP_1D_ARGS
+ GCOP_COMPLEX(PolyRectangle, xRectangle);
+# undef GCOP_ARGS
+}
+
+static void
+miBankPolyArc(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArray,
+ xArc *pArray
+)
+{
+# define GCOP_ARGS GCOP_1D_ARGS
+ GCOP_COMPLEX(PolyArc, xArc);
+# undef GCOP_ARGS
+}
+
+static void
+miBankFillPolygon(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int nArray,
+ DDXPointRec *pArray
+)
+{
+# define GCOP_ARGS GCOP_2D_ARGS
+ GCOP_COMPLEX(FillPolygon, DDXPointRec);
+# undef GCOP_ARGS
+}
+
+static void
+miBankPolyFillRect(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArray,
+ xRectangle *pArray
+)
+{
+# define GCOP_ARGS GCOP_1D_ARGS
+ GCOP_COMPLEX(PolyFillRect, xRectangle);
+# undef GCOP_ARGS
+}
+
+static void
+miBankPolyFillArc(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArray,
+ xArc *pArray
+)
+{
+# define GCOP_ARGS GCOP_1D_ARGS
+ GCOP_COMPLEX(PolyFillArc, xArc);
+# undef GCOP_ARGS
+}
+
+static int
+miBankPolyText8(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int nArray,
+ char *pchar
+)
+{
+ int retval = x;
+
+ GCOP_SIMPLE(retval =
+ (*pGC->ops->PolyText8)(pDrawable, pGC, x, y, nArray, pchar));
+
+ return retval;
+}
+
+static int
+miBankPolyText16(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int nArray,
+ unsigned short *pchar
+)
+{
+ int retval = x;
+
+ GCOP_SIMPLE(retval =
+ (*pGC->ops->PolyText16)(pDrawable, pGC, x, y, nArray, pchar));
+
+ return retval;
+}
+
+static void
+miBankImageText8(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int nArray,
+ char *pchar
+)
+{
+ GCOP_SIMPLE((*pGC->ops->ImageText8)(pDrawable, pGC, x, y, nArray, pchar));
+}
+
+static void
+miBankImageText16(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int nArray,
+ unsigned short *pchar
+)
+{
+ GCOP_SIMPLE((*pGC->ops->ImageText16)(pDrawable, pGC, x, y, nArray, pchar));
+}
+
+static void
+miBankImageGlyphBlt(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nArray,
+ CharInfoPtr *ppci,
+ pointer pglyphBase
+)
+{
+ GCOP_SIMPLE((*pGC->ops->ImageGlyphBlt)(pDrawable, pGC,
+ x, y, nArray, ppci, pglyphBase));
+}
+
+static void
+miBankPolyGlyphBlt(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nArray,
+ CharInfoPtr *ppci,
+ pointer pglyphBase
+)
+{
+ GCOP_SIMPLE((*pGC->ops->PolyGlyphBlt)(pDrawable, pGC,
+ x, y, nArray, ppci, pglyphBase));
+}
+
+static void
+miBankPushPixels(
+ GCPtr pGC,
+ PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int w,
+ int h,
+ int x,
+ int y
+)
+{
+ if ((w > 0) && (h > 0))
+ {
+ GCOP_INIT;
+ SCREEN_SAVE;
+
+ if (!IS_BANKED(pDrawable))
+ {
+ GCOP_UNWRAP;
+
+ (*pGC->ops->PushPixels)(pGC, pBitmap, pDrawable, w, h, x, y);
+
+ GCOP_WRAP;
+ }
+ else
+ {
+ int i, j;
+
+ CLIP_SAVE;
+
+ i = FirstBankOf(x, y);
+ j = LastBankOf(x + w, y + h);
+ for (; i <= j; i++)
+ {
+ if (!(pGC->pCompositeClip = pGCPriv->pBankedClips[i]))
+ continue;
+
+ GCOP_UNWRAP;
+
+ SET_SINGLE_BANK(pScreenPriv->pScreenPixmap, -1, -1, i);
+
+ (*pGC->ops->PushPixels)(pGC, pBitmap, pDrawable, w, h, x, y);
+
+ GCOP_WRAP;
+ }
+
+ CLIP_RESTORE;
+ }
+
+ SCREEN_RESTORE;
+ }
+}
+
+static GCOps miBankGCOps =
+{
+ miBankFillSpans,
+ miBankSetSpans,
+ miBankPutImage,
+ miBankCopyArea,
+ miBankCopyPlane,
+ miBankPolyPoint,
+ miBankPolylines,
+ miBankPolySegment,
+ miBankPolyRectangle,
+ miBankPolyArc,
+ miBankFillPolygon,
+ miBankPolyFillRect,
+ miBankPolyFillArc,
+ miBankPolyText8,
+ miBankPolyText16,
+ miBankImageText8,
+ miBankImageText16,
+ miBankImageGlyphBlt,
+ miBankPolyGlyphBlt,
+ miBankPushPixels,
+#ifdef NEED_LINEHELPER
+ NULL, /* LineHelper */
+#endif
+ {NULL} /* devPrivate */
+};
+
+/********************
+ * GCFuncs wrappers *
+ ********************/
+
+static void
+miBankValidateGC(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDrawable
+)
+{
+ GC_INIT(pGC);
+ GC_UNWRAP(pGC);
+
+ (*pGC->funcs->ValidateGC)(pGC, changes, pDrawable);
+
+ if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
+ (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS)))
+ {
+ ScreenPtr pScreen = pGC->pScreen;
+ RegionPtr prgnClip;
+ unsigned long planemask;
+ int i;
+
+ SCREEN_INIT;
+ SCREEN_SAVE;
+
+ if (IS_BANKED(pDrawable))
+ {
+ for (i = 0; i < pScreenPriv->nBanks; i++)
+ {
+ if (!pScreenPriv->pBanks[i])
+ continue;
+
+ if (!(prgnClip = pGCPriv->pBankedClips[i]))
+ prgnClip = REGION_CREATE(pScreen, NULL, 1);
+
+ REGION_INTERSECT(pScreen, prgnClip,
+ pScreenPriv->pBanks[i], pGC->pCompositeClip);
+
+ if ((REGION_NUM_RECTS(prgnClip) <= 1) &&
+ ((prgnClip->extents.x1 == prgnClip->extents.x2) ||
+ (prgnClip->extents.y1 == prgnClip->extents.y2)))
+ {
+ REGION_DESTROY(pScreen, prgnClip);
+ pGCPriv->pBankedClips[i] = NULL;
+ }
+ else
+ pGCPriv->pBankedClips[i] = prgnClip;
+ }
+
+ /*
+ * fastCopy and fastPlane can only be TRUE if we don't need to
+ * worry about attempts to read partial pixels through the
+ * destination bank.
+ */
+ switch (pScreenPriv->type)
+ {
+ case BANK_SHARED:
+ pGCPriv->fastCopy = pGCPriv->fastPlane = FALSE;
+
+ if ((pGC->alu != GXclear) && (pGC->alu != GXcopy) &&
+ (pGC->alu != GXcopyInverted) && (pGC->alu != GXset))
+ break;
+
+ if (pScreen->rootDepth == 1)
+ pGCPriv->fastPlane = TRUE;
+
+ /* This is probably paranoia */
+ if ((pDrawable->depth != pScreen->rootDepth) ||
+ (pDrawable->depth != pGC->depth))
+ break;
+
+ planemask = (1 << pGC->depth) - 1;
+ if ((pGC->planemask & planemask) == planemask)
+ pGCPriv->fastCopy = TRUE;
+
+ break;
+
+ case BANK_DOUBLE:
+ pGCPriv->fastCopy = pGCPriv->fastPlane = TRUE;
+ break;
+
+ default:
+ pGCPriv->fastCopy = pGCPriv->fastPlane = FALSE;
+ break;
+ }
+ }
+ else
+ {
+ /*
+ * Here we are on a pixmap and don't need all that special clipping
+ * stuff, hence free it.
+ */
+ for (i = 0; i < pScreenPriv->nBanks; i++)
+ {
+ if (!pGCPriv->pBankedClips[i])
+ continue;
+
+ REGION_DESTROY(pScreen, pGCPriv->pBankedClips[i]);
+ pGCPriv->pBankedClips[i] = NULL;
+ }
+ }
+
+ SCREEN_RESTORE;
+ }
+
+ GC_WRAP(pGC);
+}
+
+static void
+miBankChangeGC(
+ GCPtr pGC,
+ unsigned long mask
+)
+{
+ GC_INIT(pGC);
+ GC_UNWRAP(pGC);
+
+ (*pGC->funcs->ChangeGC)(pGC, mask);
+
+ GC_WRAP(pGC);
+}
+
+static void
+miBankCopyGC(
+ GCPtr pGCSrc,
+ unsigned long mask,
+ GCPtr pGCDst
+)
+{
+ GC_INIT(pGCDst);
+ GC_UNWRAP(pGCDst);
+
+ (*pGCDst->funcs->CopyGC)(pGCSrc, mask, pGCDst);
+
+ GC_WRAP(pGCDst);
+}
+
+static void
+miBankDestroyGC(
+ GCPtr pGC
+)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ int i;
+
+ SCREEN_INIT;
+ GC_INIT(pGC);
+ GC_UNWRAP(pGC);
+
+ (*pGC->funcs->DestroyGC)(pGC);
+
+ for (i = 0; i < pScreenPriv->nBanks; i++)
+ {
+ if (!pGCPriv->pBankedClips[i])
+ continue;
+
+ REGION_DESTROY(pScreen, pGCPriv->pBankedClips[i]);
+ pGCPriv->pBankedClips[i] = NULL;
+ }
+
+ GC_WRAP(pGC);
+}
+
+static void
+miBankChangeClip(
+ GCPtr pGC,
+ int type,
+ pointer pvalue,
+ int nrects
+)
+{
+ GC_INIT(pGC);
+ GC_UNWRAP(pGC);
+
+ (*pGC->funcs->ChangeClip)(pGC, type, pvalue, nrects);
+
+ GC_WRAP(pGC);
+}
+
+static void
+miBankDestroyClip(
+ GCPtr pGC
+)
+{
+ GC_INIT(pGC);
+ GC_UNWRAP(pGC);
+
+ (*pGC->funcs->DestroyClip)(pGC);
+
+ GC_WRAP(pGC);
+}
+
+static void
+miBankCopyClip(
+ GCPtr pGCDst,
+ GCPtr pGCSrc
+)
+{
+ GC_INIT(pGCDst);
+ GC_UNWRAP(pGCDst);
+
+ (*pGCDst->funcs->CopyClip)(pGCDst, pGCSrc);
+
+ GC_WRAP(pGCDst);
+}
+
+static GCFuncs miBankGCFuncs =
+{
+ miBankValidateGC,
+ miBankChangeGC,
+ miBankCopyGC,
+ miBankDestroyGC,
+ miBankChangeClip,
+ miBankDestroyClip,
+ miBankCopyClip
+};
+
+/*******************
+ * Screen Wrappers *
+ *******************/
+
+static Bool
+miBankCreateScreenResources(
+ ScreenPtr pScreen
+)
+{
+ Bool retval;
+
+ SCREEN_INIT;
+ SCREEN_UNWRAP(CreateScreenResources);
+
+ if ((retval = (*pScreen->CreateScreenResources)(pScreen)))
+ {
+ /* Set screen buffer address to something recognizable */
+ pScreenPriv->pScreenPixmap = (*pScreen->GetScreenPixmap)(pScreen);
+ pScreenPriv->pbits = pScreenPriv->pScreenPixmap->devPrivate.ptr;
+ pScreenPriv->pScreenPixmap->devPrivate.ptr = (pointer)pScreenPriv;
+
+ /* Get shadow pixmap; width & height of 0 means no pixmap data */
+ pScreenPriv->pBankPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0,
+ pScreenPriv->pScreenPixmap->drawable.depth);
+ if (!pScreenPriv->pBankPixmap)
+ retval = FALSE;
+ }
+
+ /* Shadow the screen */
+ if (retval)
+ retval = (*pScreen->ModifyPixmapHeader)(pScreenPriv->pBankPixmap,
+ pScreenPriv->pScreenPixmap->drawable.width,
+ pScreenPriv->pScreenPixmap->drawable.height,
+ pScreenPriv->pScreenPixmap->drawable.depth,
+ pScreenPriv->pScreenPixmap->drawable.bitsPerPixel,
+ pScreenPriv->pScreenPixmap->devKind, NULL);
+
+ /* Create shadow GC */
+ if (retval)
+ {
+ pScreenPriv->pBankGC = CreateScratchGC(pScreen,
+ pScreenPriv->pBankPixmap->drawable.depth);
+ if (!pScreenPriv->pBankGC)
+ retval = FALSE;
+ }
+
+ /* Validate shadow GC */
+ if (retval)
+ {
+ pScreenPriv->pBankGC->graphicsExposures = FALSE;
+ pScreenPriv->pBankGC->subWindowMode = IncludeInferiors;
+ ValidateGC((DrawablePtr)pScreenPriv->pBankPixmap,
+ pScreenPriv->pBankGC);
+ }
+
+ SCREEN_WRAP(CreateScreenResources, miBankCreateScreenResources);
+
+ return retval;
+}
+
+static Bool
+miBankModifyPixmapHeader(
+ PixmapPtr pPixmap,
+ int width,
+ int height,
+ int depth,
+ int bitsPerPixel,
+ int devKind,
+ pointer pPixData
+)
+{
+ Bool retval = FALSE;
+
+ if (pPixmap)
+ {
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+
+ SCREEN_INIT;
+ PIXMAP_SAVE(pPixmap);
+ SCREEN_UNWRAP(ModifyPixmapHeader);
+
+ retval = (*pScreen->ModifyPixmapHeader)(pPixmap, width, height,
+ depth, bitsPerPixel, devKind, pPixData);
+
+ SCREEN_WRAP(ModifyPixmapHeader, miBankModifyPixmapHeader);
+
+ if (pbits == (pointer)pScreenPriv)
+ {
+ pScreenPriv->pbits = pPixmap->devPrivate.ptr;
+ pPixmap->devPrivate.ptr = pbits;
+ }
+ }
+
+ return retval;
+}
+
+static Bool
+miBankCloseScreen(
+ int nIndex,
+ ScreenPtr pScreen
+)
+{
+ int i;
+
+ SCREEN_INIT;
+
+ /* Free shadow GC */
+ FreeScratchGC(pScreenPriv->pBankGC);
+
+ /* Free shadow pixmap */
+ (*pScreen->DestroyPixmap)(pScreenPriv->pBankPixmap);
+
+ /* Restore screen pixmap devPrivate pointer */
+ pScreenPriv->pScreenPixmap->devPrivate.ptr = pScreenPriv->pbits;
+
+ /* Delete bank clips */
+ for (i = 0; i < pScreenPriv->nBanks; i++)
+ if (pScreenPriv->pBanks[i])
+ REGION_DESTROY(pScreen, pScreenPriv->pBanks[i]);
+
+ Xfree(pScreenPriv->pBanks);
+
+ SCREEN_UNWRAP(CreateScreenResources);
+ SCREEN_UNWRAP(ModifyPixmapHeader);
+ SCREEN_UNWRAP(CloseScreen);
+ SCREEN_UNWRAP(GetImage);
+ SCREEN_UNWRAP(GetSpans);
+ SCREEN_UNWRAP(CreateGC);
+ SCREEN_UNWRAP(PaintWindowBackground);
+ SCREEN_UNWRAP(PaintWindowBorder);
+ SCREEN_UNWRAP(CopyWindow);
+ SCREEN_UNWRAP(BackingStoreFuncs);
+
+ Xfree(pScreenPriv);
+ return (*pScreen->CloseScreen)(nIndex, pScreen);
+}
+
+static void
+miBankGetImage(
+ DrawablePtr pDrawable,
+ int sx,
+ int sy,
+ int w,
+ int h,
+ unsigned int format,
+ unsigned long planemask,
+ char *pImage
+)
+{
+ if ((w > 0) && (h > 0))
+ {
+ ScreenPtr pScreen = pDrawable->pScreen;
+
+ SCREEN_INIT;
+ SCREEN_STATUS;
+ SCREEN_UNWRAP(GetImage);
+
+ if (!IS_BANKED(pDrawable))
+ {
+ (*pScreen->GetImage)(pDrawable, sx, sy, w, h,
+ format, planemask, pImage);
+ }
+ else
+ {
+ int paddedWidth;
+ char *pBankImage;
+
+ paddedWidth = PixmapBytePad(w,
+ pScreenPriv->pScreenPixmap->drawable.depth);
+ pBankImage = (char *)ALLOCATE_LOCAL(paddedWidth * h);
+
+ if (pBankImage)
+ {
+ BANK_SAVE;
+
+ ModifyPixmap(pScreenPriv->pBankPixmap, w, paddedWidth,
+ pBankImage);
+
+ (*pScreenPriv->pBankGC->ops->CopyArea)(
+ (DrawablePtr)WindowTable[pScreen->myNum],
+ (DrawablePtr)pScreenPriv->pBankPixmap,
+ pScreenPriv->pBankGC,
+ sx + pDrawable->x, sy + pDrawable->y, w, h, 0, 0);
+
+ (*pScreen->GetImage)((DrawablePtr)pScreenPriv->pBankPixmap,
+ 0, 0, w, h, format, planemask, pImage);
+
+ BANK_RESTORE;
+
+ DEALLOCATE_LOCAL(pBankImage);
+ }
+ }
+
+ SCREEN_WRAP(GetImage, miBankGetImage);
+ }
+}
+
+static void
+miBankGetSpans(
+ DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pImage
+)
+{
+ if (nspans > 0)
+ {
+ ScreenPtr pScreen = pDrawable->pScreen;
+
+ SCREEN_INIT;
+ SCREEN_STATUS;
+ SCREEN_UNWRAP(GetSpans);
+
+ if (!IS_BANKED(pDrawable))
+ {
+ (*pScreen->GetSpans)(pDrawable, wMax, ppt, pwidth, nspans, pImage);
+ }
+ else
+ {
+ char *pBankImage;
+ int paddedWidth;
+ DDXPointRec pt;
+
+ pt.x = pt.y = 0;
+
+ paddedWidth =
+ PixmapBytePad(pScreenPriv->pScreenPixmap->drawable.width,
+ pScreenPriv->pScreenPixmap->drawable.depth);
+ pBankImage = (char *)ALLOCATE_LOCAL(paddedWidth);
+
+ if (pBankImage)
+ {
+ BANK_SAVE;
+
+ ModifyPixmap(pScreenPriv->pBankPixmap,
+ pScreenPriv->pScreenPixmap->drawable.width,
+ paddedWidth, pBankImage);
+
+ for (; nspans--; ppt++, pwidth++)
+ {
+ if (*pwidth <= 0)
+ continue;
+
+ (*pScreenPriv->pBankGC->ops->CopyArea)(
+ (DrawablePtr)WindowTable[pScreen->myNum],
+ (DrawablePtr)pScreenPriv->pBankPixmap,
+ pScreenPriv->pBankGC,
+ ppt->x, ppt->y, *pwidth, 1, 0, 0);
+
+ (*pScreen->GetSpans)((DrawablePtr)pScreenPriv->pBankPixmap,
+ wMax, &pt, pwidth, 1, pImage);
+
+ pImage = pImage + PixmapBytePad(*pwidth, pDrawable->depth);
+ }
+
+ BANK_RESTORE;
+
+ DEALLOCATE_LOCAL(pBankImage);
+ }
+ }
+
+ SCREEN_WRAP(GetSpans, miBankGetSpans);
+ }
+}
+
+static Bool
+miBankCreateGC(
+ GCPtr pGC
+)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ miBankGCPtr pGCPriv = BANK_GCPRIVATE(pGC);
+ Bool ret;
+
+ SCREEN_INIT;
+ SCREEN_UNWRAP(CreateGC);
+
+ if ((ret = (*pScreen->CreateGC)(pGC)))
+ {
+ pGCPriv->unwrappedOps = &miBankGCOps;
+ pGCPriv->unwrappedFuncs = &miBankGCFuncs;
+ GC_WRAP(pGC);
+
+ memset(&pGCPriv->pBankedClips, 0,
+ pScreenPriv->nBanks * sizeof(pGCPriv->pBankedClips));
+ }
+
+ SCREEN_WRAP(CreateGC, miBankCreateGC);
+
+ return ret;
+}
+
+static void
+miBankPaintWindow(
+ WindowPtr pWin,
+ RegionPtr pRegion,
+ int what
+)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RegionRec tmpReg;
+ int i;
+ PaintWindowProcPtr PaintWindow;
+
+ SCREEN_INIT;
+ SCREEN_SAVE;
+
+ if (what == PW_BORDER)
+ {
+ SCREEN_UNWRAP(PaintWindowBorder);
+ PaintWindow = pScreen->PaintWindowBorder;
+ }
+ else
+ {
+ SCREEN_UNWRAP(PaintWindowBackground);
+ PaintWindow = pScreen->PaintWindowBackground;
+ }
+
+ if (!IS_BANKED(pWin))
+ {
+ (*PaintWindow)(pWin, pRegion, what);
+ }
+ else
+ {
+ REGION_NULL(pScreen, &tmpReg);
+
+ for (i = 0; i < pScreenPriv->nBanks; i++)
+ {
+ if (!pScreenPriv->pBanks[i])
+ continue;
+
+ REGION_INTERSECT(pScreen, &tmpReg, pRegion,
+ pScreenPriv->pBanks[i]);
+
+ if (REGION_NIL(&tmpReg))
+ continue;
+
+ SET_SINGLE_BANK(pScreenPriv->pScreenPixmap, -1, -1, i);
+
+ (*PaintWindow)(pWin, &tmpReg, what);
+ }
+
+ REGION_UNINIT(pScreen, &tmpReg);
+ }
+
+ if (what == PW_BORDER)
+ {
+ SCREEN_WRAP(PaintWindowBorder, miBankPaintWindow);
+ }
+ else
+ {
+ SCREEN_WRAP(PaintWindowBackground, miBankPaintWindow);
+ }
+
+ SCREEN_RESTORE;
+}
+
+static void
+miBankCopyWindow(
+ WindowPtr pWindow,
+ DDXPointRec ptOldOrg,
+ RegionPtr pRgnSrc
+)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ GCPtr pGC;
+ int dx, dy, nBox;
+ DrawablePtr pDrawable = (DrawablePtr)WindowTable[pScreen->myNum];
+ RegionPtr pRgnDst;
+ BoxPtr pBox, pBoxTmp, pBoxNext, pBoxBase, pBoxNew1, pBoxNew2;
+ XID subWindowMode = IncludeInferiors;
+
+ pGC = GetScratchGC(pDrawable->depth, pScreen);
+
+ ChangeGC(pGC, GCSubwindowMode, &subWindowMode);
+ ValidateGC(pDrawable, pGC);
+
+ pRgnDst = REGION_CREATE(pScreen, NULL, 1);
+
+ dx = ptOldOrg.x - pWindow->drawable.x;
+ dy = ptOldOrg.y - pWindow->drawable.y;
+ REGION_TRANSLATE(pScreen, pRgnSrc, -dx, -dy);
+ REGION_INTERSECT(pScreen, pRgnDst, &pWindow->borderClip, pRgnSrc);
+
+ pBox = REGION_RECTS(pRgnDst);
+ nBox = REGION_NUM_RECTS(pRgnDst);
+
+ pBoxNew1 = NULL;
+ pBoxNew2 = NULL;
+
+ if (nBox > 1)
+ {
+ if (dy < 0)
+ {
+ /* Sort boxes from bottom to top */
+ pBoxNew1 = ALLOCATE_LOCAL_ARRAY(BoxRec, nBox);
+
+ if (pBoxNew1)
+ {
+ pBoxBase = pBoxNext = pBox + nBox - 1;
+
+ while (pBoxBase >= pBox)
+ {
+ while ((pBoxNext >= pBox) &&
+ (pBoxBase->y1 == pBoxNext->y1))
+ pBoxNext--;
+
+ pBoxTmp = pBoxNext + 1;
+
+ while (pBoxTmp <= pBoxBase)
+ *pBoxNew1++ = *pBoxTmp++;
+
+ pBoxBase = pBoxNext;
+ }
+
+ pBoxNew1 -= nBox;
+ pBox = pBoxNew1;
+ }
+ }
+
+ if (dx < 0)
+ {
+ /* Sort boxes from right to left */
+ pBoxNew2 = ALLOCATE_LOCAL_ARRAY(BoxRec, nBox);
+
+ if (pBoxNew2)
+ {
+ pBoxBase = pBoxNext = pBox;
+
+ while (pBoxBase < pBox + nBox)
+ {
+ while ((pBoxNext < pBox + nBox) &&
+ (pBoxNext->y1 == pBoxBase->y1))
+ pBoxNext++;
+
+ pBoxTmp = pBoxNext;
+
+ while (pBoxTmp != pBoxBase)
+ *pBoxNew2++ = *--pBoxTmp;
+
+ pBoxBase = pBoxNext;
+ }
+
+ pBoxNew2 -= nBox;
+ pBox = pBoxNew2;
+ }
+ }
+ }
+
+ while (nBox--)
+ {
+ (*pGC->ops->CopyArea)(pDrawable, pDrawable, pGC,
+ pBox->x1 + dx, pBox->y1 + dy,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
+ pBox->x1, pBox->y1);
+
+ pBox++;
+ }
+
+ FreeScratchGC(pGC);
+
+ REGION_DESTROY(pScreen, pRgnDst);
+
+ DEALLOCATE_LOCAL(pBoxNew2);
+ DEALLOCATE_LOCAL(pBoxNew1);
+}
+
+/**************************
+ * Backing store wrappers *
+ **************************/
+
+static void
+miBankSaveAreas(
+ PixmapPtr pPixmap,
+ RegionPtr prgnSave,
+ int xorg,
+ int yorg,
+ WindowPtr pWin
+)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ RegionRec rgnClipped;
+ int i;
+
+ SCREEN_INIT;
+ SCREEN_SAVE;
+ SCREEN_UNWRAP(BackingStoreFuncs.SaveAreas);
+
+ if (!IS_BANKED(pWin))
+ {
+ (*pScreen->BackingStoreFuncs.SaveAreas)(pPixmap, prgnSave, xorg, yorg,
+ pWin);
+ }
+ else
+ {
+ REGION_NULL(pScreen, &rgnClipped);
+ REGION_TRANSLATE(pScreen, prgnSave, xorg, yorg);
+
+ for (i = 0; i < pScreenPriv->nBanks; i++)
+ {
+ if (!pScreenPriv->pBanks[i])
+ continue;
+
+ REGION_INTERSECT(pScreen, &rgnClipped,
+ prgnSave, pScreenPriv->pBanks[i]);
+
+ if (REGION_NIL(&rgnClipped))
+ continue;
+
+ SET_SINGLE_BANK(pScreenPriv->pScreenPixmap, -1, -1, i);
+
+ REGION_TRANSLATE(pScreen, &rgnClipped, -xorg, -yorg);
+
+ (*pScreen->BackingStoreFuncs.SaveAreas)(pPixmap, &rgnClipped,
+ xorg, yorg, pWin);
+ }
+
+ REGION_TRANSLATE(pScreen, prgnSave, -xorg, -yorg);
+ REGION_UNINIT(pScreen, &rgnClipped);
+ }
+
+ SCREEN_WRAP(BackingStoreFuncs.SaveAreas, miBankSaveAreas);
+ SCREEN_RESTORE;
+}
+
+static void
+miBankRestoreAreas(
+ PixmapPtr pPixmap,
+ RegionPtr prgnRestore,
+ int xorg,
+ int yorg,
+ WindowPtr pWin
+)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ RegionRec rgnClipped;
+ int i;
+
+ SCREEN_INIT;
+ SCREEN_SAVE;
+ SCREEN_UNWRAP(BackingStoreFuncs.RestoreAreas);
+
+ if (!IS_BANKED(pWin))
+ {
+ (*pScreen->BackingStoreFuncs.RestoreAreas)(pPixmap, prgnRestore,
+ xorg, yorg, pWin);
+ }
+ else
+ {
+ REGION_NULL(pScreen, &rgnClipped);
+
+ for (i = 0; i < pScreenPriv->nBanks; i++)
+ {
+ if (!pScreenPriv->pBanks[i])
+ continue;
+
+ REGION_INTERSECT(pScreen, &rgnClipped,
+ prgnRestore, pScreenPriv->pBanks[i]);
+
+ if (REGION_NIL(&rgnClipped))
+ continue;
+
+ SET_SINGLE_BANK(pScreenPriv->pScreenPixmap, -1, -1, i);
+
+ (*pScreen->BackingStoreFuncs.RestoreAreas)(pPixmap, &rgnClipped,
+ xorg, yorg, pWin);
+ }
+
+ REGION_UNINIT(pScreen, &rgnClipped);
+ }
+
+ SCREEN_WRAP(BackingStoreFuncs.RestoreAreas, miBankRestoreAreas);
+ SCREEN_RESTORE;
+}
+
+Bool
+miInitializeBanking(
+ ScreenPtr pScreen,
+ unsigned int xsize,
+ unsigned int ysize,
+ unsigned int width,
+ miBankInfoPtr pBankInfo
+)
+{
+ miBankScreenPtr pScreenPriv;
+ unsigned long nBitsPerBank, nBitsPerScanline, nPixelsPerScanlinePadUnit;
+ unsigned long BankBase, ServerPad;
+ unsigned int type, iBank, nBanks, maxRects, we, nBankBPP;
+ int i;
+
+ if (!pBankInfo || !pBankInfo->BankSize)
+ return TRUE; /* No banking required */
+
+ /* Sanity checks */
+
+ if (!pScreen || !xsize || !ysize || (xsize > width) ||
+ !pBankInfo->SetSourceBank || !pBankInfo->SetDestinationBank ||
+ !pBankInfo->SetSourceAndDestinationBanks ||
+ !pBankInfo->pBankA || !pBankInfo->pBankB ||
+ !pBankInfo->nBankDepth)
+ return FALSE;
+
+ /*
+ * DDX *must* have registered a pixmap format whose depth is
+ * pBankInfo->nBankDepth. This is not necessarily the rootDepth
+ * pixmap format.
+ */
+ i = 0;
+ while (screenInfo.formats[i].depth != pBankInfo->nBankDepth)
+ if (++i >= screenInfo.numPixmapFormats)
+ return FALSE;
+ nBankBPP = screenInfo.formats[i].bitsPerPixel;
+
+ i = 0;
+ while (screenInfo.formats[i].depth != pScreen->rootDepth)
+ if (++i >= screenInfo.numPixmapFormats)
+ return FALSE;
+
+ if (nBankBPP > screenInfo.formats[i].bitsPerPixel)
+ return FALSE;
+
+ /* Determine banking type */
+ if ((type = miBankDeriveType(pScreen, pBankInfo)) == BANK_NOBANK)
+ return FALSE;
+
+ /* Internal data */
+
+ nBitsPerBank = pBankInfo->BankSize * 8;
+ ServerPad = PixmapBytePad(1, pBankInfo->nBankDepth) * 8;
+ if (nBitsPerBank % ServerPad)
+ return FALSE;
+ nBitsPerScanline = PixmapBytePad(width, pBankInfo->nBankDepth) * 8;
+ nBanks = ((nBitsPerScanline * (ysize - 1)) +
+ (nBankBPP * xsize) + nBitsPerBank - 1) / nBitsPerBank;
+ nPixelsPerScanlinePadUnit = miLCM(ServerPad, nBankBPP) / nBankBPP;
+
+ /* Private areas */
+
+ if (miBankGeneration != serverGeneration)
+ {
+ if (((miBankScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
+ ((miBankGCIndex = AllocateGCPrivateIndex()) < 0))
+ return FALSE;
+
+ miBankGeneration = serverGeneration;
+ }
+
+ if (!AllocateGCPrivate(pScreen, miBankGCIndex,
+ (nBanks * sizeof(RegionPtr)) +
+ (sizeof(miBankGCRec) - sizeof(RegionPtr))))
+ return FALSE;
+
+ if (!(pScreenPriv = (miBankScreenPtr)Xcalloc(sizeof(miBankScreenRec))))
+ return FALSE;
+
+ if (!(pScreenPriv->pBanks = /* Allocate and clear */
+ (RegionPtr *)Xcalloc(nBanks * sizeof(RegionPtr))))
+ {
+ Xfree(pScreenPriv);
+ return FALSE;
+ }
+
+ /*
+ * Translate banks into clipping regions which are themselves clipped
+ * against the screen. This also ensures that pixels with imbedded bank
+ * boundaries are off-screen.
+ */
+
+ BankBase = 0;
+ maxRects = 0;
+ we = 0;
+ for (iBank = 0; iBank < nBanks; iBank++)
+ {
+ xRectangle pRects[3], *pRect = pRects;
+ unsigned int xb, yb, xe, ye;
+
+ xb = ((BankBase + nBankBPP - 1) % nBitsPerScanline) / nBankBPP;
+ yb = (BankBase + nBankBPP - 1) / nBitsPerScanline;
+ if (xb >= xsize)
+ {
+ xb = we = 0;
+ yb++;
+ }
+ if (yb >= ysize)
+ {
+ we = 0;
+ break;
+ }
+
+ if (we)
+ break;
+
+ BankBase += nBitsPerBank;
+
+ we = (BankBase % nBitsPerScanline) % nBankBPP;
+ xe = (BankBase % nBitsPerScanline) / nBankBPP;
+ ye = BankBase / nBitsPerScanline;
+ if (xe >= xsize)
+ {
+ we = xe = 0;
+ ye++;
+ }
+ if (ye >= ysize)
+ {
+ we = xe = 0;
+ ye = ysize;
+ }
+
+ if (yb == ye)
+ {
+ if (xb >= xe)
+ continue;
+
+ pRect->x = xb;
+ pRect->y = yb;
+ pRect->width = xe - xb;
+ pRect->height = 1;
+ maxRects += 2;
+ pRect++;
+ }
+ else
+ {
+ if (xb)
+ {
+ pRect->x = xb;
+ pRect->y = yb++;
+ pRect->width = xsize - xb;
+ pRect->height = 1;
+ maxRects += 2;
+ pRect++;
+ }
+
+ if (yb < ye)
+ {
+ pRect->x = 0;
+ pRect->y = yb;
+ pRect->width = xsize;
+ pRect->height = ye - yb;
+ maxRects += min(pRect->height, 3) + 1;
+ pRect++;
+ }
+
+ if (xe)
+ {
+ pRect->x = 0;
+ pRect->y = ye;
+ pRect->width = xe;
+ pRect->height = 1;
+ maxRects += 2;
+ pRect++;
+ }
+ }
+
+ pScreenPriv->pBanks[iBank] =
+ RECTS_TO_REGION(pScreen, pRect - pRects, pRects, 0);
+ if (!pScreenPriv->pBanks[iBank] ||
+ REGION_NAR(pScreenPriv->pBanks[iBank]))
+ {
+ we = 1;
+ break;
+ }
+ }
+
+ if (we && (iBank < nBanks))
+ {
+ for (i = iBank; i >= 0; i--)
+ if (pScreenPriv->pBanks[i])
+ REGION_DESTROY(pScreen, pScreenPriv->pBanks[i]);
+
+ Xfree(pScreenPriv->pBanks);
+ Xfree(pScreenPriv);
+
+ return FALSE;
+ }
+
+ /* Open for business */
+
+ pScreenPriv->type = type;
+ pScreenPriv->nBanks = nBanks;
+ pScreenPriv->maxRects = maxRects;
+ pScreenPriv->nBankBPP = nBankBPP;
+ pScreenPriv->BankInfo = *pBankInfo;
+ pScreenPriv->nBitsPerBank = nBitsPerBank;
+ pScreenPriv->nBitsPerScanline = nBitsPerScanline;
+ pScreenPriv->nPixelsPerScanlinePadUnit = nPixelsPerScanlinePadUnit;
+
+ SCREEN_WRAP(CreateScreenResources, miBankCreateScreenResources);
+ SCREEN_WRAP(ModifyPixmapHeader, miBankModifyPixmapHeader);
+ SCREEN_WRAP(CloseScreen, miBankCloseScreen);
+ SCREEN_WRAP(GetImage, miBankGetImage);
+ SCREEN_WRAP(GetSpans, miBankGetSpans);
+ SCREEN_WRAP(CreateGC, miBankCreateGC);
+ SCREEN_WRAP(PaintWindowBackground, miBankPaintWindow);
+ SCREEN_WRAP(PaintWindowBorder, miBankPaintWindow);
+ SCREEN_WRAP(CopyWindow, miBankCopyWindow);
+
+ pScreenPriv->BackingStoreFuncs = pScreen->BackingStoreFuncs;
+
+ pScreen->BackingStoreFuncs.SaveAreas = miBankSaveAreas;
+ pScreen->BackingStoreFuncs.RestoreAreas = miBankRestoreAreas;
+ /* ??????????????????????????????????????????????????????????????
+ pScreen->BackingStoreFuncs.SetClipmaskRgn = miBankSetClipmaskRgn;
+ ?????????????????????????????????????????????????????????????? */
+
+ BANK_SCRPRIVLVAL = (pointer)pScreenPriv;
+
+ return TRUE;
+}
+
+/* This is used to force GC revalidation when the banking type is changed */
+/*ARGSUSED*/
+static int
+miBankNewSerialNumber(
+ WindowPtr pWin,
+ pointer unused
+)
+{
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ return WT_WALKCHILDREN;
+}
+
+/* This entry modifies the banking interface */
+Bool
+miModifyBanking(
+ ScreenPtr pScreen,
+ miBankInfoPtr pBankInfo
+)
+{
+ unsigned int type;
+
+ if (!pScreen)
+ return FALSE;
+
+ if (miBankGeneration == serverGeneration)
+ {
+ SCREEN_INIT;
+
+ if (pScreenPriv)
+ {
+ if (!pBankInfo || !pBankInfo->BankSize ||
+ !pBankInfo->pBankA || !pBankInfo->pBankB ||
+ !pBankInfo->SetSourceBank || !pBankInfo->SetDestinationBank ||
+ !pBankInfo->SetSourceAndDestinationBanks)
+ return FALSE;
+
+ /* BankSize and nBankDepth cannot, as yet, be changed */
+ if ((pScreenPriv->BankInfo.BankSize != pBankInfo->BankSize) ||
+ (pScreenPriv->BankInfo.nBankDepth != pBankInfo->nBankDepth))
+ return FALSE;
+
+ if ((type = miBankDeriveType(pScreen, pBankInfo)) == BANK_NOBANK)
+ return FALSE;
+
+ /* Reset banking info */
+ pScreenPriv->BankInfo = *pBankInfo;
+ if (type != pScreenPriv->type)
+ {
+ /*
+ * Banking type is changing. Revalidate all window GC's.
+ */
+ pScreenPriv->type = type;
+ WalkTree(pScreen, miBankNewSerialNumber, 0);
+ }
+
+ return TRUE;
+ }
+ }
+
+ if (!pBankInfo || !pBankInfo->BankSize)
+ return TRUE; /* No change requested */
+
+ return FALSE;
+}
+
+/*
+ * Given various screen attributes, determine the minimum scanline width such
+ * that each scanline is server and DDX padded and any pixels with imbedded
+ * bank boundaries are off-screen. This function returns -1 if such a width
+ * cannot exist. This function exists because the DDX needs to be able to
+ * determine this width before initializing a frame buffer.
+ */
+int
+miScanLineWidth(
+ unsigned int xsize, /* pixels */
+ unsigned int ysize, /* pixels */
+ unsigned int width, /* pixels */
+ unsigned long BankSize, /* char's */
+ PixmapFormatRec *pBankFormat,
+ unsigned int nWidthUnit /* bits */
+)
+{
+ unsigned long nBitsPerBank, nBitsPerScanline, nBitsPerScanlinePadUnit;
+ unsigned long minBitsPerScanline, maxBitsPerScanline;
+
+ /* Sanity checks */
+
+ if (!nWidthUnit || !pBankFormat)
+ return -1;
+
+ nBitsPerBank = BankSize * 8;
+ if (nBitsPerBank % pBankFormat->scanlinePad)
+ return -1;
+
+ if (xsize > width)
+ width = xsize;
+ nBitsPerScanlinePadUnit = miLCM(pBankFormat->scanlinePad, nWidthUnit);
+ nBitsPerScanline =
+ (((width * pBankFormat->bitsPerPixel) + nBitsPerScanlinePadUnit - 1) /
+ nBitsPerScanlinePadUnit) * nBitsPerScanlinePadUnit;
+ width = nBitsPerScanline / pBankFormat->bitsPerPixel;
+
+ if (!xsize || !(nBitsPerBank % pBankFormat->bitsPerPixel))
+ return (int)width;
+
+ /*
+ * Scanlines will be server-pad aligned at this point. They will also be
+ * a multiple of nWidthUnit bits long. Ensure that pixels with imbedded
+ * bank boundaries are off-screen.
+ *
+ * It seems reasonable to limit total frame buffer size to 1/16 of the
+ * theoretical maximum address space size. On a machine with 32-bit
+ * addresses (to 8-bit quantities) this turns out to be 256MB. Not only
+ * does this provide a simple limiting condition for the loops below, but
+ * it also prevents unsigned long wraparounds.
+ */
+ if (!ysize)
+ return -1;
+
+ minBitsPerScanline = xsize * pBankFormat->bitsPerPixel;
+ if (minBitsPerScanline > nBitsPerBank)
+ return -1;
+
+ if (ysize == 1)
+ return (int)width;
+
+ maxBitsPerScanline =
+ (((unsigned long)(-1) >> 1) - minBitsPerScanline) / (ysize - 1);
+ while (nBitsPerScanline <= maxBitsPerScanline)
+ {
+ unsigned long BankBase, BankUnit;
+
+ BankUnit = ((nBitsPerBank + nBitsPerScanline - 1) / nBitsPerBank) *
+ nBitsPerBank;
+ if (!(BankUnit % nBitsPerScanline))
+ return (int)width;
+
+ for (BankBase = BankUnit; ; BankBase += nBitsPerBank)
+ {
+ unsigned long x, y;
+
+ y = BankBase / nBitsPerScanline;
+ if (y >= ysize)
+ return (int)width;
+
+ x = BankBase % nBitsPerScanline;
+ if (!(x % pBankFormat->bitsPerPixel))
+ continue;
+
+ if (x < minBitsPerScanline)
+ {
+ /*
+ * Skip ahead certain widths by dividing the excess scanline
+ * amongst the y's.
+ */
+ y *= nBitsPerScanlinePadUnit;
+ nBitsPerScanline +=
+ ((x + y - 1) / y) * nBitsPerScanlinePadUnit;
+ width = nBitsPerScanline / pBankFormat->bitsPerPixel;
+ break;
+ }
+
+ if (BankBase != BankUnit)
+ continue;
+
+ if (!(nBitsPerScanline % x))
+ return (int)width;
+
+ BankBase = ((nBitsPerScanline - minBitsPerScanline) /
+ (nBitsPerScanline - x)) * BankUnit;
+ }
+ }
+
+ return -1;
+}
diff --git a/nx-X11/programs/Xserver/mi/mibank.h b/nx-X11/programs/Xserver/mi/mibank.h
new file mode 100644
index 000000000..cf27d1fae
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mibank.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright 1997 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of Marc Aurele La France not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. Marc Aurele La France makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as-is" without express or implied warranty.
+ *
+ * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+ * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* $XFree86: xc/programs/Xserver/mi/mibank.h,v 1.10 2003/01/01 19:16:42 tsi Exp $ */
+
+#ifndef __MIBANK_H__
+#define __MIBANK_H__ 1
+
+#include "scrnintstr.h"
+
+/*
+ * Banking external interface.
+ */
+
+/*
+ * This is the banking function type. The return value is normally zero.
+ * Non-zero returns can be used to implement the likes of scanline interleave,
+ * etc.
+ */
+typedef int miBankProc(
+ ScreenPtr /*pScreen*/,
+ unsigned int /*iBank*/
+);
+
+typedef miBankProc *miBankProcPtr;
+
+typedef struct _miBankInfo
+{
+ /*
+ * Banking refers to the use of one or more apertures (in the server's
+ * address space) to access various parts of a potentially larger hardware
+ * frame buffer.
+ *
+ * Three different banking schemes are supported:
+ *
+ * Single banking is indicated when pBankA and pBankB are equal and all
+ * three miBankProcPtr's point to the same function. Here, both reads and
+ * writes through the aperture access the same hardware location.
+ *
+ * Shared banking is indicated when pBankA and pBankB are equal but the
+ * source and destination functions differ. Here reads through the
+ * aperture do not necessarily access the same hardware location as writes.
+ *
+ * Double banking is indicated when pBankA and pBankB differ. Here two
+ * independent apertures are used to provide read/write access to
+ * potentially different hardware locations.
+ *
+ * Any other combination will result in no banking.
+ */
+ miBankProcPtr SetSourceBank; /* Set pBankA bank number */
+ miBankProcPtr SetDestinationBank; /* Set pBankB bank number */
+ miBankProcPtr SetSourceAndDestinationBanks; /* Set both bank numbers */
+
+ pointer pBankA; /* First aperture location */
+ pointer pBankB; /* First or second aperture location */
+
+ /*
+ * BankSize is in units of sizeof(char) and is the size of each bank.
+ */
+ unsigned long BankSize;
+
+ /*
+ * nBankDepth is the colour depth associated with the maximum number of a
+ * pixel's bits that are simultaneously accessible through the frame buffer
+ * aperture.
+ */
+ unsigned int nBankDepth;
+} miBankInfoRec, *miBankInfoPtr;
+
+Bool
+miInitializeBanking(
+ ScreenPtr /*pScreen*/,
+ unsigned int /*xsize*/,
+ unsigned int /*ysize*/,
+ unsigned int /*width*/,
+ miBankInfoPtr /*pBankInfo*/
+);
+
+Bool
+miModifyBanking(
+ ScreenPtr /*pScreen*/,
+ miBankInfoPtr /*pBankInfo*/
+);
+
+/*
+ * This function determines the minimum screen width, given a initial estimate
+ * and various screen attributes. DDX needs to determine this width before
+ * initializing the screen.
+ */
+int
+miScanLineWidth(
+ unsigned int /*xsize*/,
+ unsigned int /*ysize*/,
+ unsigned int /*width*/,
+ unsigned long /*BankSize*/,
+ PixmapFormatRec * /*pBankFormat*/,
+ unsigned int /*nWidthUnit*/
+);
+
+#endif /* __MIBANK_H__ */
diff --git a/nx-X11/programs/Xserver/mi/mibitblt.c b/nx-X11/programs/Xserver/mi/mibitblt.c
new file mode 100644
index 000000000..0caad083f
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mibitblt.c
@@ -0,0 +1,845 @@
+/* $XFree86: xc/programs/Xserver/mi/mibitblt.c,v 3.10 2001/08/06 20:51:17 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mibitblt.c,v 1.5 2001/02/09 02:05:20 xorgcvs Exp $ */
+/* Author: Todd Newman (aided and abetted by Mr. Drewry) */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+
+#include "misc.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "mi.h"
+#include "regionstr.h"
+#include <X11/Xmd.h>
+#include "servermd.h"
+
+#ifndef HAS_FFS
+extern int ffs(int);
+#endif
+
+/* MICOPYAREA -- public entry for the CopyArea request
+ * For each rectangle in the source region
+ * get the pixels with GetSpans
+ * set them in the destination with SetSpans
+ * We let SetSpans worry about clipping to the destination.
+ */
+RegionPtr
+miCopyArea(pSrcDrawable, pDstDrawable,
+ pGC, xIn, yIn, widthSrc, heightSrc, xOut, yOut)
+ register DrawablePtr pSrcDrawable;
+ register DrawablePtr pDstDrawable;
+ GCPtr pGC;
+ int xIn, yIn;
+ int widthSrc, heightSrc;
+ int xOut, yOut;
+{
+ DDXPointPtr ppt, pptFirst;
+ unsigned int *pwidthFirst, *pwidth, *pbits;
+ BoxRec srcBox, *prect;
+ /* may be a new region, or just a copy */
+ RegionPtr prgnSrcClip;
+ /* non-0 if we've created a src clip */
+ RegionPtr prgnExposed;
+ int realSrcClip = 0;
+ int srcx, srcy, dstx, dsty, i, j, y, width, height,
+ xMin, xMax, yMin, yMax;
+ unsigned int *ordering;
+ int numRects;
+ BoxPtr boxes;
+
+ srcx = xIn + pSrcDrawable->x;
+ srcy = yIn + pSrcDrawable->y;
+
+ /* If the destination isn't realized, this is easy */
+ if (pDstDrawable->type == DRAWABLE_WINDOW &&
+ !((WindowPtr)pDstDrawable)->realized)
+ return (RegionPtr)NULL;
+
+ /* clip the source */
+ if (pSrcDrawable->type == DRAWABLE_PIXMAP)
+ {
+ BoxRec box;
+
+ box.x1 = pSrcDrawable->x;
+ box.y1 = pSrcDrawable->y;
+ box.x2 = pSrcDrawable->x + (int) pSrcDrawable->width;
+ box.y2 = pSrcDrawable->y + (int) pSrcDrawable->height;
+
+ prgnSrcClip = REGION_CREATE(pGC->pScreen, &box, 1);
+ realSrcClip = 1;
+ }
+ else
+ {
+ if (pGC->subWindowMode == IncludeInferiors) {
+ prgnSrcClip = NotClippedByChildren ((WindowPtr) pSrcDrawable);
+ realSrcClip = 1;
+ } else
+ prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList;
+ }
+
+ /* If the src drawable is a window, we need to translate the srcBox so
+ * that we can compare it with the window's clip region later on. */
+ srcBox.x1 = srcx;
+ srcBox.y1 = srcy;
+ srcBox.x2 = srcx + widthSrc;
+ srcBox.y2 = srcy + heightSrc;
+
+ dstx = xOut;
+ dsty = yOut;
+ if (pGC->miTranslate)
+ {
+ dstx += pDstDrawable->x;
+ dsty += pDstDrawable->y;
+ }
+
+ pptFirst = ppt = (DDXPointPtr)
+ ALLOCATE_LOCAL(heightSrc * sizeof(DDXPointRec));
+ pwidthFirst = pwidth = (unsigned int *)
+ ALLOCATE_LOCAL(heightSrc * sizeof(unsigned int));
+ numRects = REGION_NUM_RECTS(prgnSrcClip);
+ boxes = REGION_RECTS(prgnSrcClip);
+ ordering = (unsigned int *)
+ ALLOCATE_LOCAL(numRects * sizeof(unsigned int));
+ if(!pptFirst || !pwidthFirst || !ordering)
+ {
+ if (ordering)
+ DEALLOCATE_LOCAL(ordering);
+ if (pwidthFirst)
+ DEALLOCATE_LOCAL(pwidthFirst);
+ if (pptFirst)
+ DEALLOCATE_LOCAL(pptFirst);
+ return (RegionPtr)NULL;
+ }
+
+ /* If not the same drawable then order of move doesn't matter.
+ Following assumes that boxes are sorted from top
+ to bottom and left to right.
+ */
+ if ((pSrcDrawable != pDstDrawable) &&
+ ((pGC->subWindowMode != IncludeInferiors) ||
+ (pSrcDrawable->type == DRAWABLE_PIXMAP) ||
+ (pDstDrawable->type == DRAWABLE_PIXMAP)))
+ for (i=0; i < numRects; i++)
+ ordering[i] = i;
+ else { /* within same drawable, must sequence moves carefully! */
+ if (dsty <= srcBox.y1) { /* Scroll up or stationary vertical.
+ Vertical order OK */
+ if (dstx <= srcBox.x1) /* Scroll left or stationary horizontal.
+ Horizontal order OK as well */
+ for (i=0; i < numRects; i++)
+ ordering[i] = i;
+ else { /* scroll right. must reverse horizontal banding of rects. */
+ for (i=0, j=1, xMax=0; i < numRects; j=i+1, xMax=i) {
+ /* find extent of current horizontal band */
+ y=boxes[i].y1; /* band has this y coordinate */
+ while ((j < numRects) && (boxes[j].y1 == y))
+ j++;
+ /* reverse the horizontal band in the output ordering */
+ for (j-- ; j >= xMax; j--, i++)
+ ordering[i] = j;
+ }
+ }
+ }
+ else { /* Scroll down. Must reverse vertical banding. */
+ if (dstx < srcBox.x1) { /* Scroll left. Horizontal order OK. */
+ for (i=numRects-1, j=i-1, yMin=i, yMax=0;
+ i >= 0;
+ j=i-1, yMin=i) {
+ /* find extent of current horizontal band */
+ y=boxes[i].y1; /* band has this y coordinate */
+ while ((j >= 0) && (boxes[j].y1 == y))
+ j--;
+ /* reverse the horizontal band in the output ordering */
+ for (j++ ; j <= yMin; j++, i--, yMax++)
+ ordering[yMax] = j;
+ }
+ }
+ else /* Scroll right or horizontal stationary.
+ Reverse horizontal order as well (if stationary, horizontal
+ order can be swapped without penalty and this is faster
+ to compute). */
+ for (i=0, j=numRects-1; i < numRects; i++, j--)
+ ordering[i] = j;
+ }
+ }
+
+ for(i = 0; i < numRects; i++)
+ {
+ prect = &boxes[ordering[i]];
+ xMin = max(prect->x1, srcBox.x1);
+ xMax = min(prect->x2, srcBox.x2);
+ yMin = max(prect->y1, srcBox.y1);
+ yMax = min(prect->y2, srcBox.y2);
+ /* is there anything visible here? */
+ if(xMax <= xMin || yMax <= yMin)
+ continue;
+
+ ppt = pptFirst;
+ pwidth = pwidthFirst;
+ y = yMin;
+ height = yMax - yMin;
+ width = xMax - xMin;
+
+ for(j = 0; j < height; j++)
+ {
+ /* We must untranslate before calling GetSpans */
+ ppt->x = xMin;
+ ppt++->y = y++;
+ *pwidth++ = width;
+ }
+ pbits = (unsigned int *)xalloc(height * PixmapBytePad(width,
+ pSrcDrawable->depth));
+ if (pbits)
+ {
+ (*pSrcDrawable->pScreen->GetSpans)(pSrcDrawable, width, pptFirst,
+ (int *)pwidthFirst, height, (char *)pbits);
+ ppt = pptFirst;
+ pwidth = pwidthFirst;
+ xMin -= (srcx - dstx);
+ y = yMin - (srcy - dsty);
+ for(j = 0; j < height; j++)
+ {
+ ppt->x = xMin;
+ ppt++->y = y++;
+ *pwidth++ = width;
+ }
+
+ (*pGC->ops->SetSpans)(pDstDrawable, pGC, (char *)pbits, pptFirst,
+ (int *)pwidthFirst, height, TRUE);
+ xfree(pbits);
+ }
+ }
+ prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC, xIn, yIn,
+ widthSrc, heightSrc, xOut, yOut, (unsigned long)0);
+ if(realSrcClip)
+ REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+
+ DEALLOCATE_LOCAL(ordering);
+ DEALLOCATE_LOCAL(pwidthFirst);
+ DEALLOCATE_LOCAL(pptFirst);
+ return prgnExposed;
+}
+
+/* MIGETPLANE -- gets a bitmap representing one plane of pDraw
+ * A helper used for CopyPlane and XY format GetImage
+ * No clever strategy here, we grab a scanline at a time, pull out the
+ * bits and then stuff them in a 1 bit deep map.
+ */
+/*
+ * This should be replaced with something more general. mi shouldn't have to
+ * care about such things as scanline padding et alia.
+ */
+static
+MiBits *
+miGetPlane(
+ DrawablePtr pDraw,
+ int planeNum, /* number of the bitPlane */
+ int sx,
+ int sy,
+ int w,
+ int h,
+ MiBits *result)
+{
+ int i, j, k, width, bitsPerPixel, widthInBytes;
+ DDXPointRec pt = {0, 0};
+ MiBits pixel;
+ MiBits bit;
+ unsigned char *pCharsOut = NULL;
+
+#if BITMAP_SCANLINE_UNIT == 8
+#define OUT_TYPE unsigned char
+#endif
+#if BITMAP_SCANLINE_UNIT == 16
+#define OUT_TYPE CARD16
+#endif
+#if BITMAP_SCANLINE_UNIT == 32
+#define OUT_TYPE CARD32
+#endif
+#if BITMAP_SCANLINE_UNIT == 64
+#define OUT_TYPE CARD64
+#endif
+
+ OUT_TYPE *pOut;
+ int delta = 0;
+
+ sx += pDraw->x;
+ sy += pDraw->y;
+ widthInBytes = BitmapBytePad(w);
+ if(!result)
+ result = (MiBits *)xalloc(h * widthInBytes);
+ if (!result)
+ return (MiBits *)NULL;
+ bitsPerPixel = pDraw->bitsPerPixel;
+ bzero((char *)result, h * widthInBytes);
+ pOut = (OUT_TYPE *) result;
+ if(bitsPerPixel == 1)
+ {
+ pCharsOut = (unsigned char *) result;
+ width = w;
+ }
+ else
+ {
+ delta = (widthInBytes / (BITMAP_SCANLINE_UNIT / 8)) -
+ (w / BITMAP_SCANLINE_UNIT);
+ width = 1;
+#if IMAGE_BYTE_ORDER == MSBFirst
+ planeNum += (32 - bitsPerPixel);
+#endif
+ }
+ pt.y = sy;
+ for (i = h; --i >= 0; pt.y++)
+ {
+ pt.x = sx;
+ if(bitsPerPixel == 1)
+ {
+ (*pDraw->pScreen->GetSpans)(pDraw, width, &pt, &width, 1,
+ (char *)pCharsOut);
+ pCharsOut += widthInBytes;
+ }
+ else
+ {
+ k = 0;
+ for(j = w; --j >= 0; pt.x++)
+ {
+ /* Fetch the next pixel */
+ (*pDraw->pScreen->GetSpans)(pDraw, width, &pt, &width, 1,
+ (char *)&pixel);
+ /*
+ * Now get the bit and insert into a bitmap in XY format.
+ */
+ bit = (pixel >> planeNum) & 1;
+#ifndef XFree86Server
+ /* XXX assuming bit order == byte order */
+#if BITMAP_BIT_ORDER == LSBFirst
+ bit <<= k;
+#else
+ bit <<= ((BITMAP_SCANLINE_UNIT - 1) - k);
+#endif
+#else
+ /* XXX assuming byte order == LSBFirst */
+ if (screenInfo.bitmapBitOrder == LSBFirst)
+ bit <<= k;
+ else
+ bit <<= ((screenInfo.bitmapScanlineUnit - 1) -
+ (k % screenInfo.bitmapScanlineUnit)) +
+ ((k / screenInfo.bitmapScanlineUnit) *
+ screenInfo.bitmapScanlineUnit);
+#endif
+ *pOut |= (OUT_TYPE) bit;
+ k++;
+ if (k == BITMAP_SCANLINE_UNIT)
+ {
+ pOut++;
+ k = 0;
+ }
+ }
+ pOut += delta;
+ }
+ }
+ return(result);
+
+}
+
+/* MIOPQSTIPDRAWABLE -- use pbits as an opaque stipple for pDraw.
+ * Drawing through the clip mask we SetSpans() the bits into a
+ * bitmap and stipple those bits onto the destination drawable by doing a
+ * PolyFillRect over the whole drawable,
+ * then we invert the bitmap by copying it onto itself with an alu of
+ * GXinvert, invert the foreground/background colors of the gc, and draw
+ * the background bits.
+ * Note how the clipped out bits of the bitmap are always the background
+ * color so that the stipple never causes FillRect to draw them.
+ */
+void
+miOpqStipDrawable(pDraw, pGC, prgnSrc, pbits, srcx, w, h, dstx, dsty)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ RegionPtr prgnSrc;
+ MiBits *pbits;
+ int srcx, w, h, dstx, dsty;
+{
+ int oldfill, i;
+ unsigned long oldfg;
+ int *pwidth, *pwidthFirst;
+ ChangeGCVal gcv[6];
+ PixmapPtr pStipple, pPixmap;
+ DDXPointRec oldOrg;
+ GCPtr pGCT;
+ DDXPointPtr ppt, pptFirst;
+ xRectangle rect;
+ RegionPtr prgnSrcClip;
+
+ pPixmap = (*pDraw->pScreen->CreatePixmap)
+ (pDraw->pScreen, w + srcx, h, 1);
+ if (!pPixmap)
+ return;
+
+ /* Put the image into a 1 bit deep pixmap */
+ pGCT = GetScratchGC(1, pDraw->pScreen);
+ if (!pGCT)
+ {
+ (*pDraw->pScreen->DestroyPixmap)(pPixmap);
+ return;
+ }
+ /* First set the whole pixmap to 0 */
+ gcv[0].val = 0;
+ dixChangeGC(NullClient, pGCT, GCBackground, NULL, gcv);
+ ValidateGC((DrawablePtr)pPixmap, pGCT);
+ miClearDrawable((DrawablePtr)pPixmap, pGCT);
+ ppt = pptFirst = (DDXPointPtr)ALLOCATE_LOCAL(h * sizeof(DDXPointRec));
+ pwidth = pwidthFirst = (int *)ALLOCATE_LOCAL(h * sizeof(int));
+ if(!pptFirst || !pwidthFirst)
+ {
+ if (pwidthFirst) DEALLOCATE_LOCAL(pwidthFirst);
+ if (pptFirst) DEALLOCATE_LOCAL(pptFirst);
+ FreeScratchGC(pGCT);
+ return;
+ }
+
+ /* we need a temporary region because ChangeClip must be assumed
+ to destroy what it's sent. note that this means we don't
+ have to free prgnSrcClip ourselves.
+ */
+ prgnSrcClip = REGION_CREATE(pGCT->pScreen, NULL, 0);
+ REGION_COPY(pGCT->pScreen, prgnSrcClip, prgnSrc);
+ REGION_TRANSLATE(pGCT->pScreen, prgnSrcClip, srcx, 0);
+ (*pGCT->funcs->ChangeClip)(pGCT, CT_REGION, prgnSrcClip, 0);
+ ValidateGC((DrawablePtr)pPixmap, pGCT);
+
+ /* Since we know pDraw is always a pixmap, we never need to think
+ * about translation here */
+ for(i = 0; i < h; i++)
+ {
+ ppt->x = 0;
+ ppt++->y = i;
+ *pwidth++ = w + srcx;
+ }
+
+ (*pGCT->ops->SetSpans)((DrawablePtr)pPixmap, pGCT, (char *)pbits,
+ pptFirst, pwidthFirst, h, TRUE);
+ DEALLOCATE_LOCAL(pwidthFirst);
+ DEALLOCATE_LOCAL(pptFirst);
+
+
+ /* Save current values from the client GC */
+ oldfill = pGC->fillStyle;
+ pStipple = pGC->stipple;
+ if(pStipple)
+ pStipple->refcnt++;
+ oldOrg = pGC->patOrg;
+
+ /* Set a new stipple in the drawable */
+ gcv[0].val = FillStippled;
+ gcv[1].ptr = pPixmap;
+ gcv[2].val = dstx - srcx;
+ gcv[3].val = dsty;
+
+ dixChangeGC(NullClient, pGC,
+ GCFillStyle | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin,
+ NULL, gcv);
+ ValidateGC(pDraw, pGC);
+
+ /* Fill the drawable with the stipple. This will draw the
+ * foreground color whereever 1 bits are set, leaving everything
+ * with 0 bits untouched. Note that the part outside the clip
+ * region is all 0s. */
+ rect.x = dstx;
+ rect.y = dsty;
+ rect.width = w;
+ rect.height = h;
+ (*pGC->ops->PolyFillRect)(pDraw, pGC, 1, &rect);
+
+ /* Invert the tiling pixmap. This sets 0s for 1s and 1s for 0s, only
+ * within the clipping region, the part outside is still all 0s */
+ gcv[0].val = GXinvert;
+ dixChangeGC(NullClient, pGCT, GCFunction, NULL, gcv);
+ ValidateGC((DrawablePtr)pPixmap, pGCT);
+ (*pGCT->ops->CopyArea)((DrawablePtr)pPixmap, (DrawablePtr)pPixmap,
+ pGCT, 0, 0, w + srcx, h, 0, 0);
+
+ /* Swap foreground and background colors on the GC for the drawable.
+ * Now when we fill the drawable, we will fill in the "Background"
+ * values */
+ oldfg = pGC->fgPixel;
+ gcv[0].val = pGC->bgPixel;
+ gcv[1].val = oldfg;
+ gcv[2].ptr = pPixmap;
+ dixChangeGC(NullClient, pGC, GCForeground | GCBackground | GCStipple,
+ NULL, gcv);
+ ValidateGC(pDraw, pGC);
+ /* PolyFillRect might have bashed the rectangle */
+ rect.x = dstx;
+ rect.y = dsty;
+ rect.width = w;
+ rect.height = h;
+ (*pGC->ops->PolyFillRect)(pDraw, pGC, 1, &rect);
+
+ /* Now put things back */
+ if(pStipple)
+ pStipple->refcnt--;
+ gcv[0].val = oldfg;
+ gcv[1].val = pGC->fgPixel;
+ gcv[2].val = oldfill;
+ gcv[3].ptr = pStipple;
+ gcv[4].val = oldOrg.x;
+ gcv[5].val = oldOrg.y;
+ dixChangeGC(NullClient, pGC,
+ GCForeground | GCBackground | GCFillStyle | GCStipple |
+ GCTileStipXOrigin | GCTileStipYOrigin, NULL, gcv);
+
+ ValidateGC(pDraw, pGC);
+ /* put what we hope is a smaller clip region back in the scratch gc */
+ (*pGCT->funcs->ChangeClip)(pGCT, CT_NONE, NULL, 0);
+ FreeScratchGC(pGCT);
+ (*pDraw->pScreen->DestroyPixmap)(pPixmap);
+
+}
+
+/* MICOPYPLANE -- public entry for the CopyPlane request.
+ * strategy:
+ * First build up a bitmap out of the bits requested
+ * build a source clip
+ * Use the bitmap we've built up as a Stipple for the destination
+ */
+RegionPtr
+miCopyPlane(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, bitPlane)
+ DrawablePtr pSrcDrawable;
+ DrawablePtr pDstDrawable;
+ GCPtr pGC;
+ int srcx, srcy;
+ int width, height;
+ int dstx, dsty;
+ unsigned long bitPlane;
+{
+ MiBits *ptile;
+ BoxRec box;
+ RegionPtr prgnSrc, prgnExposed;
+
+ /* incorporate the source clip */
+
+ box.x1 = srcx + pSrcDrawable->x;
+ box.y1 = srcy + pSrcDrawable->y;
+ box.x2 = box.x1 + width;
+ box.y2 = box.y1 + height;
+ /* clip to visible drawable */
+ if (box.x1 < pSrcDrawable->x)
+ box.x1 = pSrcDrawable->x;
+ if (box.y1 < pSrcDrawable->y)
+ box.y1 = pSrcDrawable->y;
+ if (box.x2 > pSrcDrawable->x + (int) pSrcDrawable->width)
+ box.x2 = pSrcDrawable->x + (int) pSrcDrawable->width;
+ if (box.y2 > pSrcDrawable->y + (int) pSrcDrawable->height)
+ box.y2 = pSrcDrawable->y + (int) pSrcDrawable->height;
+ if (box.x1 > box.x2)
+ box.x2 = box.x1;
+ if (box.y1 > box.y2)
+ box.y2 = box.y1;
+ prgnSrc = REGION_CREATE(pGC->pScreen, &box, 1);
+
+ if (pSrcDrawable->type != DRAWABLE_PIXMAP) {
+ /* clip to visible drawable */
+
+ if (pGC->subWindowMode == IncludeInferiors)
+ {
+ RegionPtr clipList = NotClippedByChildren ((WindowPtr) pSrcDrawable);
+ REGION_INTERSECT(pGC->pScreen, prgnSrc, prgnSrc, clipList);
+ REGION_DESTROY(pGC->pScreen, clipList);
+ } else
+ REGION_INTERSECT(pGC->pScreen, prgnSrc, prgnSrc,
+ &((WindowPtr)pSrcDrawable)->clipList);
+ }
+
+ box = *REGION_EXTENTS(pGC->pScreen, prgnSrc);
+ REGION_TRANSLATE(pGC->pScreen, prgnSrc, -box.x1, -box.y1);
+
+ if ((box.x2 > box.x1) && (box.y2 > box.y1))
+ {
+ /* minimize the size of the data extracted */
+ /* note that we convert the plane mask bitPlane into a plane number */
+ box.x1 -= pSrcDrawable->x;
+ box.x2 -= pSrcDrawable->x;
+ box.y1 -= pSrcDrawable->y;
+ box.y2 -= pSrcDrawable->y;
+ ptile = miGetPlane(pSrcDrawable, ffs(bitPlane) - 1,
+ box.x1, box.y1,
+ box.x2 - box.x1, box.y2 - box.y1,
+ (MiBits *) NULL);
+ if (ptile)
+ {
+ miOpqStipDrawable(pDstDrawable, pGC, prgnSrc, ptile, 0,
+ box.x2 - box.x1, box.y2 - box.y1,
+ dstx + box.x1 - srcx, dsty + box.y1 - srcy);
+ xfree(ptile);
+ }
+ }
+ prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC, srcx, srcy,
+ width, height, dstx, dsty, bitPlane);
+ REGION_DESTROY(pGC->pScreen, prgnSrc);
+ return prgnExposed;
+}
+
+/* MIGETIMAGE -- public entry for the GetImage Request
+ * We're getting the image into a memory buffer. While we have to use GetSpans
+ * to read a line from the device (since we don't know what that looks like),
+ * we can just write into the destination buffer
+ *
+ * two different strategies are used, depending on whether we're getting the
+ * image in Z format or XY format
+ * Z format:
+ * Line at a time, GetSpans a line into the destination buffer, then if the
+ * planemask is not all ones, we do a SetSpans into a temporary buffer (to get
+ * bits turned off) and then another GetSpans to get stuff back (because
+ * pixmaps are opaque, and we are passed in the memory to write into). This is
+ * pretty ugly and slow but works. Life is hard.
+ * XY format:
+ * get the single plane specified in planemask
+ */
+void
+miGetImage(pDraw, sx, sy, w, h, format, planeMask, pDst)
+ DrawablePtr pDraw;
+ int sx, sy, w, h;
+ unsigned int format;
+ unsigned long planeMask;
+ char * pDst;
+{
+ unsigned char depth;
+ int i, linelength, width, srcx, srcy;
+ DDXPointRec pt = {0, 0};
+ XID gcv[2];
+ PixmapPtr pPixmap = (PixmapPtr)NULL;
+ GCPtr pGC = NULL;
+
+ depth = pDraw->depth;
+ if(format == ZPixmap)
+ {
+ if ( (((1<<depth)-1)&planeMask) != (1<<depth)-1 )
+ {
+ xPoint pt;
+
+ pGC = GetScratchGC(depth, pDraw->pScreen);
+ if (!pGC)
+ return;
+ pPixmap = (*pDraw->pScreen->CreatePixmap)
+ (pDraw->pScreen, w, 1, depth);
+ if (!pPixmap)
+ {
+ FreeScratchGC(pGC);
+ return;
+ }
+ /*
+ * Clear the pixmap before doing anything else
+ */
+ ValidateGC((DrawablePtr)pPixmap, pGC);
+ pt.x = pt.y = 0;
+ width = w;
+ (*pGC->ops->FillSpans)((DrawablePtr)pPixmap, pGC, 1, &pt, &width,
+ TRUE);
+
+ /* alu is already GXCopy */
+ gcv[0] = (XID)planeMask;
+ DoChangeGC(pGC, GCPlaneMask, gcv, 0);
+ ValidateGC((DrawablePtr)pPixmap, pGC);
+ }
+
+ linelength = PixmapBytePad(w, depth);
+ srcx = sx + pDraw->x;
+ srcy = sy + pDraw->y;
+ for(i = 0; i < h; i++)
+ {
+ pt.x = srcx;
+ pt.y = srcy + i;
+ width = w;
+ (*pDraw->pScreen->GetSpans)(pDraw, w, &pt, &width, 1, pDst);
+ if (pPixmap)
+ {
+ pt.x = 0;
+ pt.y = 0;
+ width = w;
+ (*pGC->ops->SetSpans)((DrawablePtr)pPixmap, pGC, pDst,
+ &pt, &width, 1, TRUE);
+ (*pDraw->pScreen->GetSpans)((DrawablePtr)pPixmap, w, &pt,
+ &width, 1, pDst);
+ }
+ pDst += linelength;
+ }
+ if (pPixmap)
+ {
+ (*pGC->pScreen->DestroyPixmap)(pPixmap);
+ FreeScratchGC(pGC);
+ }
+ }
+ else
+ {
+ (void) miGetPlane(pDraw, ffs(planeMask) - 1, sx, sy, w, h,
+ (MiBits *)pDst);
+ }
+}
+
+/* MIPUTIMAGE -- public entry for the PutImage request
+ * Here we benefit from knowing the format of the bits pointed to by pImage,
+ * even if we don't know how pDraw represents them.
+ * Three different strategies are used depending on the format
+ * XYBitmap Format:
+ * we just use the Opaque Stipple helper function to cover the destination
+ * Note that this covers all the planes of the drawable with the
+ * foreground color (masked with the GC planemask) where there are 1 bits
+ * and the background color (masked with the GC planemask) where there are
+ * 0 bits
+ * XYPixmap format:
+ * what we're called with is a series of XYBitmaps, but we only want
+ * each XYPixmap to update 1 plane, instead of updating all of them.
+ * we set the foreground color to be all 1s and the background to all 0s
+ * then for each plane, we set the plane mask to only effect that one
+ * plane and recursive call ourself with the format set to XYBitmap
+ * (This clever idea courtesy of RGD.)
+ * ZPixmap format:
+ * This part is simple, just call SetSpans
+ */
+void
+miPutImage(pDraw, pGC, depth, x, y, w, h, leftPad, format, pImage)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int depth, x, y, w, h, leftPad;
+ int format;
+ char *pImage;
+{
+ DDXPointPtr pptFirst, ppt;
+ int *pwidthFirst, *pwidth;
+ RegionPtr prgnSrc;
+ BoxRec box;
+ unsigned long oldFg, oldBg;
+ XID gcv[3];
+ unsigned long oldPlanemask;
+ unsigned long i;
+ long bytesPer;
+
+ if (!w || !h)
+ return;
+ switch(format)
+ {
+ case XYBitmap:
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = w;
+ box.y2 = h;
+ prgnSrc = REGION_CREATE(pGC->pScreen, &box, 1);
+
+ miOpqStipDrawable(pDraw, pGC, prgnSrc, (MiBits *) pImage,
+ leftPad, w, h, x, y);
+ REGION_DESTROY(pGC->pScreen, prgnSrc);
+ break;
+
+ case XYPixmap:
+ depth = pGC->depth;
+ oldPlanemask = pGC->planemask;
+ oldFg = pGC->fgPixel;
+ oldBg = pGC->bgPixel;
+ gcv[0] = (XID)~0;
+ gcv[1] = (XID)0;
+ DoChangeGC(pGC, GCForeground | GCBackground, gcv, 0);
+ bytesPer = (long)h * BitmapBytePad(w + leftPad);
+
+ for (i = 1 << (depth-1); i != 0; i >>= 1, pImage += bytesPer)
+ {
+ if (i & oldPlanemask)
+ {
+ gcv[0] = (XID)i;
+ DoChangeGC(pGC, GCPlaneMask, gcv, 0);
+ ValidateGC(pDraw, pGC);
+ (*pGC->ops->PutImage)(pDraw, pGC, 1, x, y, w, h, leftPad,
+ XYBitmap, (char *)pImage);
+ }
+ }
+ gcv[0] = (XID)oldPlanemask;
+ gcv[1] = (XID)oldFg;
+ gcv[2] = (XID)oldBg;
+ DoChangeGC(pGC, GCPlaneMask | GCForeground | GCBackground, gcv, 0);
+ ValidateGC(pDraw, pGC);
+ break;
+
+ case ZPixmap:
+ ppt = pptFirst = (DDXPointPtr)ALLOCATE_LOCAL(h * sizeof(DDXPointRec));
+ pwidth = pwidthFirst = (int *)ALLOCATE_LOCAL(h * sizeof(int));
+ if(!pptFirst || !pwidthFirst)
+ {
+ if (pwidthFirst)
+ DEALLOCATE_LOCAL(pwidthFirst);
+ if (pptFirst)
+ DEALLOCATE_LOCAL(pptFirst);
+ return;
+ }
+ if (pGC->miTranslate)
+ {
+ x += pDraw->x;
+ y += pDraw->y;
+ }
+
+ for(i = 0; i < h; i++)
+ {
+ ppt->x = x;
+ ppt->y = y + i;
+ ppt++;
+ *pwidth++ = w;
+ }
+
+ (*pGC->ops->SetSpans)(pDraw, pGC, (char *)pImage, pptFirst,
+ pwidthFirst, h, TRUE);
+ DEALLOCATE_LOCAL(pwidthFirst);
+ DEALLOCATE_LOCAL(pptFirst);
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/mi/mibstore.c b/nx-X11/programs/Xserver/mi/mibstore.c
new file mode 100644
index 000000000..98947217c
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mibstore.c
@@ -0,0 +1,3905 @@
+/* $Xorg: mibstore.c,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by the Regents of the University of California
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted, provided
+that the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation, and that the name The Open Group not be used in advertising or publicity
+pertaining to distribution of the software without specific, written prior
+permission.
+
+The University of California makes no representations about the suitability
+of this software for any purpose. It is provided "as is" without express or
+implied warranty.
+
+******************************************************************/
+
+/* $XFree86: xc/programs/Xserver/mi/mibstore.c,v 1.10tsi Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "dixstruct.h" /* For requestingClient */
+#include "mi.h"
+#include "mibstorest.h"
+
+/*
+ * When the server fails to allocate a backing store pixmap, if you want
+ * it to dynamically retry to allocate backing store on every subsequent
+ * graphics op, you can enable BSEAGER; otherwise, backing store will be
+ * disabled on the window until it is unmapped and then remapped.
+ */
+/* #define BSEAGER */
+
+/*-
+ * NOTES ON USAGE:
+ *
+ * The functions in this file implement a machine-independent backing-store
+ * scheme. To use it, the output library must do the following:
+ * - Provide a SaveAreas function that takes a destination pixmap, a
+ * region of the areas to save (in the pixmap's coordinate system)
+ * and the screen origin of the region. It should copy the areas from
+ * the screen into the pixmap.
+ * - Provide a RestoreAreas function that takes a source pixmap, a region
+ * of the areas to restore (in the screen's coordinate system) and the
+ * origin of the pixmap on the screen. It should copy the areas from
+ * the pixmap into the screen.
+ * - Provide a SetClipmaskRgn function that takes a gc and a region
+ * and merges the region into any CT_PIXMAP client clip that
+ * is specified in the GC. This routine is only needed if
+ * miValidateBackingStore will see CT_PIXMAP clip lists; not
+ * true for any of the sample servers (which convert the PIXMAP
+ * clip lists into CT_REGION clip lists; an expensive but simple
+ * to code option).
+ * - The function placed in a window's ClearToBackground vector must call
+ * pScreen->ClearBackingStore with the window, followed by
+ * the window-relative x and y coordinates, followed by the width and
+ * height of the area to be cleared, followed by the generateExposures
+ * flag. This has been taken care of in miClearToBackground.
+ * - Whatever determines GraphicsExpose events for the CopyArea and
+ * CopyPlane requests should call pWin->backStorage->ExposeCopy
+ * with the source and destination drawables, the GC used, a source-
+ * window-relative region of exposed areas, the source and destination
+ * coordinates and the bitplane copied, if CopyPlane, or 0, if
+ * CopyArea.
+ *
+ * JUSTIFICATION
+ * This is a cross between saving everything and just saving the
+ * obscued areas (as in Pike's layers.) This method has the advantage
+ * of only doing each output operation once per pixel, visible or
+ * invisible, and avoids having to do all the crufty storage
+ * management of keeping several separate rectangles. Since the
+ * ddx layer ouput primitives are required to draw through clipping
+ * rectangles anyway, sending multiple drawing requests for each of
+ * several rectangles isn't necessary. (Of course, it could be argued
+ * that the ddx routines should just take one rectangle each and
+ * get called multiple times, but that would make taking advantage of
+ * smart hardware harder, and probably be slower as well.)
+ */
+
+#define SETUP_BACKING_TERSE(pGC) \
+ miBSGCPtr pGCPrivate = (miBSGCPtr)(pGC)->devPrivates[miBSGCIndex].ptr; \
+ GCFuncs *oldFuncs = pGC->funcs;
+
+#define SETUP_BACKING(pDrawable,pGC) \
+ miBSWindowPtr pBackingStore = \
+ (miBSWindowPtr)((WindowPtr)(pDrawable))->backStorage; \
+ DrawablePtr pBackingDrawable = (DrawablePtr) \
+ pBackingStore->pBackingPixmap; \
+ SETUP_BACKING_TERSE(pGC) \
+ GCPtr pBackingGC = pGCPrivate->pBackingGC;
+
+#define PROLOGUE(pGC) { \
+ pGC->ops = pGCPrivate->wrapOps;\
+ pGC->funcs = pGCPrivate->wrapFuncs; \
+ }
+
+#define EPILOGUE(pGC) { \
+ pGCPrivate->wrapOps = (pGC)->ops; \
+ (pGC)->ops = &miBSGCOps; \
+ (pGC)->funcs = oldFuncs; \
+ }
+
+static void miCreateBSPixmap(WindowPtr pWin, BoxPtr pExtents);
+static void miDestroyBSPixmap(WindowPtr pWin);
+static void miTileVirtualBS(WindowPtr pWin);
+static void miBSAllocate(WindowPtr pWin), miBSFree(WindowPtr pWin);
+static Bool miBSCreateGCPrivate(GCPtr pGC);
+static void miBSClearBackingRegion(WindowPtr pWin, RegionPtr pRgn);
+
+#define MoreCopy0 ;
+#define MoreCopy2 *dstCopy++ = *srcCopy++; *dstCopy++ = *srcCopy++;
+#define MoreCopy4 MoreCopy2 MoreCopy2
+
+#define copyData(src,dst,n,morecopy) \
+{ \
+ register short *srcCopy = (short *)(src); \
+ register short *dstCopy = (short *)(dst); \
+ register int i; \
+ register int bsx = pBackingStore->x; \
+ register int bsy = pBackingStore->y; \
+ for (i = n; --i >= 0; ) \
+ { \
+ *dstCopy++ = *srcCopy++ - bsx; \
+ *dstCopy++ = *srcCopy++ - bsy; \
+ morecopy \
+ } \
+}
+
+#define copyPoints(src,dst,n,mode) \
+if (mode == CoordModeOrigin) \
+{ \
+ copyData(src,dst,n,MoreCopy0); \
+} \
+else \
+{ \
+ memmove((char *)(dst), (char *)(src), (n) << 2); \
+ *((short *)(dst)) -= pBackingStore->x; \
+ *((short *)(dst) + 1) -= pBackingStore->y; \
+}
+
+/*
+ * wrappers for screen funcs
+ */
+
+static int miBSScreenIndex;
+static unsigned long miBSGeneration = 0;
+
+static Bool miBSCloseScreen(int i, ScreenPtr pScreen);
+static void miBSGetImage(DrawablePtr pDrawable, int sx, int sy,
+ int w, int h, unsigned int format,
+ unsigned long planemask, char *pdstLine);
+static void miBSGetSpans(DrawablePtr pDrawable, int wMax,
+ DDXPointPtr ppt, int *pwidth, int nspans,
+ char *pdstStart);
+static Bool miBSChangeWindowAttributes(WindowPtr pWin,
+ unsigned long mask);
+static Bool miBSCreateGC(GCPtr pGC);
+static Bool miBSDestroyWindow(WindowPtr pWin);
+
+/*
+ * backing store screen functions
+ */
+
+static void miBSSaveDoomedAreas(WindowPtr pWin, RegionPtr pObscured,
+ int dx, int dy);
+static RegionPtr miBSRestoreAreas(WindowPtr pWin, RegionPtr prgnExposed);
+static void miBSExposeCopy(WindowPtr pSrc, DrawablePtr pDst,
+ GCPtr pGC, RegionPtr prgnExposed,
+ int srcx, int srcy, int dstx, int dsty,
+ unsigned long plane);
+static RegionPtr miBSTranslateBackingStore(WindowPtr pWin, int windx,
+ int windy, RegionPtr oldClip,
+ int oldx, int oldy);
+static RegionPtr miBSClearBackingStore(WindowPtr pWin, int x, int y,
+ int w, int h, Bool generateExposures);
+static void miBSDrawGuarantee(WindowPtr pWin, GCPtr pGC,
+ int guarantee);
+
+/*
+ * wrapper vectors for GC funcs and ops
+ */
+
+static int miBSGCIndex;
+
+static void miBSValidateGC(GCPtr pGC, unsigned long stateChanges,
+ DrawablePtr pDrawable);
+static void miBSCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
+static void miBSDestroyGC(GCPtr pGC);
+static void miBSChangeGC(GCPtr pGC, unsigned long mask);
+static void miBSChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects);
+static void miBSDestroyClip(GCPtr pGC);
+static void miBSCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
+
+static GCFuncs miBSGCFuncs = {
+ miBSValidateGC,
+ miBSChangeGC,
+ miBSCopyGC,
+ miBSDestroyGC,
+ miBSChangeClip,
+ miBSDestroyClip,
+ miBSCopyClip,
+};
+
+static void miBSFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nInit,
+ DDXPointPtr pptInit, int *pwidthInit,
+ int fSorted);
+static void miBSSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *psrc,
+ DDXPointPtr ppt, int *pwidth, int nspans,
+ int fSorted);
+static void miBSPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
+ int x, int y, int w, int h, int leftPad,
+ int format, char *pBits);
+static RegionPtr miBSCopyArea(DrawablePtr pSrc, DrawablePtr pDst,
+ GCPtr pGC, int srcx, int srcy, int w, int h,
+ int dstx, int dsty);
+static RegionPtr miBSCopyPlane(DrawablePtr pSrc, DrawablePtr pDst,
+ GCPtr pGC, int srcx, int srcy, int w, int h,
+ int dstx, int dsty, unsigned long plane);
+static void miBSPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode,
+ int npt, xPoint *pptInit);
+static void miBSPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode,
+ int npt, DDXPointPtr pptInit);
+static void miBSPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
+ xSegment *pSegs);
+static void miBSPolyRectangle(DrawablePtr pDrawable, GCPtr pGC,
+ int nrects, xRectangle *pRects);
+static void miBSPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs,
+ xArc *parcs);
+static void miBSFillPolygon(DrawablePtr pDrawable, GCPtr pGC,
+ int shape, int mode, int count,
+ DDXPointPtr pPts);
+static void miBSPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
+ int nrectFill, xRectangle *prectInit);
+static void miBSPolyFillArc(DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *parcs);
+static int miBSPolyText8(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, char *chars);
+static int miBSPolyText16(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count,
+ unsigned short *chars);
+static void miBSImageText8(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, char *chars);
+static void miBSImageText16(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count,
+ unsigned short *chars);
+static void miBSImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase);
+static void miBSPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase);
+static void miBSPushPixels(GCPtr pGC, PixmapPtr pBitMap,
+ DrawablePtr pDst, int w, int h,
+ int x, int y);
+#ifdef NEED_LINEHELPER
+static void miBSLineHelper(void);
+#endif
+
+static GCOps miBSGCOps = {
+ miBSFillSpans, miBSSetSpans, miBSPutImage,
+ miBSCopyArea, miBSCopyPlane, miBSPolyPoint,
+ miBSPolylines, miBSPolySegment, miBSPolyRectangle,
+ miBSPolyArc, miBSFillPolygon, miBSPolyFillRect,
+ miBSPolyFillArc, miBSPolyText8, miBSPolyText16,
+ miBSImageText8, miBSImageText16, miBSImageGlyphBlt,
+ miBSPolyGlyphBlt, miBSPushPixels
+#ifdef NEED_LINEHELPER
+ , miBSLineHelper
+#endif
+};
+
+#define FUNC_PROLOGUE(pGC, pPriv) \
+ ((pGC)->funcs = pPriv->wrapFuncs),\
+ ((pGC)->ops = pPriv->wrapOps)
+
+#define FUNC_EPILOGUE(pGC, pPriv) \
+ ((pGC)->funcs = &miBSGCFuncs),\
+ ((pGC)->ops = &miBSGCOps)
+
+/*
+ * every GC in the server is initially wrapped with these
+ * "cheap" functions. This allocates no memory and is used
+ * to discover GCs used with windows which have backing
+ * store enabled
+ */
+
+static void miBSCheapValidateGC(GCPtr pGC, unsigned long stateChanges,
+ DrawablePtr pDrawable);
+static void miBSCheapCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
+static void miBSCheapDestroyGC(GCPtr pGC);
+static void miBSCheapChangeGC(GCPtr pGC, unsigned long mask);
+static void miBSCheapChangeClip(GCPtr pGC, int type, pointer pvalue,
+ int nrects);
+static void miBSCheapDestroyClip(GCPtr pGC);
+static void miBSCheapCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
+
+static GCFuncs miBSCheapGCFuncs = {
+ miBSCheapValidateGC,
+ miBSCheapChangeGC,
+ miBSCheapCopyGC,
+ miBSCheapDestroyGC,
+ miBSCheapChangeClip,
+ miBSCheapDestroyClip,
+ miBSCheapCopyClip,
+};
+
+#define CHEAP_FUNC_PROLOGUE(pGC) \
+ ((pGC)->funcs = (GCFuncs *) (pGC)->devPrivates[miBSGCIndex].ptr)
+
+#define CHEAP_FUNC_EPILOGUE(pGC) \
+ ((pGC)->funcs = &miBSCheapGCFuncs)
+
+/*
+ * called from device screen initialization proc. Gets a GCPrivateIndex
+ * and wraps appropriate per-screen functions. pScreen->BackingStoreFuncs
+ * must be previously initialized.
+ */
+
+void
+miInitializeBackingStore (pScreen)
+ ScreenPtr pScreen;
+{
+ miBSScreenPtr pScreenPriv;
+
+ if (miBSGeneration != serverGeneration)
+ {
+ miBSScreenIndex = AllocateScreenPrivateIndex ();
+ if (miBSScreenIndex < 0)
+ return;
+ miBSGCIndex = AllocateGCPrivateIndex ();
+ miBSGeneration = serverGeneration;
+ }
+ if (!AllocateGCPrivate(pScreen, miBSGCIndex, 0))
+ return;
+ pScreenPriv = (miBSScreenPtr) xalloc (sizeof (miBSScreenRec));
+ if (!pScreenPriv)
+ return;
+
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreenPriv->GetImage = pScreen->GetImage;
+ pScreenPriv->GetSpans = pScreen->GetSpans;
+ pScreenPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
+ pScreenPriv->CreateGC = pScreen->CreateGC;
+ pScreenPriv->DestroyWindow = pScreen->DestroyWindow;
+
+ pScreen->CloseScreen = miBSCloseScreen;
+ pScreen->GetImage = miBSGetImage;
+ pScreen->GetSpans = miBSGetSpans;
+ pScreen->ChangeWindowAttributes = miBSChangeWindowAttributes;
+ pScreen->CreateGC = miBSCreateGC;
+ pScreen->DestroyWindow = miBSDestroyWindow;
+
+ pScreen->SaveDoomedAreas = miBSSaveDoomedAreas;
+ pScreen->RestoreAreas = miBSRestoreAreas;
+ pScreen->ExposeCopy = miBSExposeCopy;
+ pScreen->TranslateBackingStore = miBSTranslateBackingStore;
+ pScreen->ClearBackingStore = miBSClearBackingStore;
+ pScreen->DrawGuarantee = miBSDrawGuarantee;
+
+ pScreen->devPrivates[miBSScreenIndex].ptr = (pointer) pScreenPriv;
+}
+
+/*
+ * Screen function wrappers
+ */
+
+#define SCREEN_PROLOGUE(pScreen, field)\
+ ((pScreen)->field = \
+ ((miBSScreenPtr) \
+ (pScreen)->devPrivates[miBSScreenIndex].ptr)->field)
+
+#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
+ ((pScreen)->field = wrapper)
+
+/*
+ * CloseScreen wrapper -- unwrap everything, free the private data
+ * and call the wrapped function
+ */
+
+static Bool
+miBSCloseScreen (i, pScreen)
+ int i;
+ ScreenPtr pScreen;
+{
+ miBSScreenPtr pScreenPriv;
+
+ pScreenPriv = (miBSScreenPtr) pScreen->devPrivates[miBSScreenIndex].ptr;
+
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+ pScreen->GetImage = pScreenPriv->GetImage;
+ pScreen->GetSpans = pScreenPriv->GetSpans;
+ pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes;
+ pScreen->CreateGC = pScreenPriv->CreateGC;
+
+ xfree ((pointer) pScreenPriv);
+
+ return (*pScreen->CloseScreen) (i, pScreen);
+}
+
+static void miBSFillVirtualBits(DrawablePtr pDrawable, GCPtr pGC,
+ RegionPtr pRgn, int x, int y, int state,
+ PixUnion pixunion, unsigned long planemask);
+
+static void
+miBSGetImage (pDrawable, sx, sy, w, h, format, planemask, pdstLine)
+ DrawablePtr pDrawable;
+ int sx, sy, w, h;
+ unsigned int format;
+ unsigned long planemask;
+ char *pdstLine;
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ BoxRec bounds;
+ unsigned char depth;
+
+ SCREEN_PROLOGUE (pScreen, GetImage);
+
+ if (pDrawable->type != DRAWABLE_PIXMAP &&
+ ((WindowPtr) pDrawable)->visibility != VisibilityUnobscured)
+ {
+ PixmapPtr pPixmap;
+ miBSWindowPtr pWindowPriv;
+ GCPtr pGC = NULL;
+ WindowPtr pWin, pSrcWin;
+ int xoff, yoff;
+ RegionRec Remaining;
+ RegionRec Border;
+ RegionRec Inside;
+ BoxPtr pBox;
+ int n;
+
+ pWin = (WindowPtr) pDrawable;
+ pPixmap = 0;
+ depth = pDrawable->depth;
+ bounds.x1 = sx + pDrawable->x;
+ bounds.y1 = sy + pDrawable->y;
+ bounds.x2 = bounds.x1 + w;
+ bounds.y2 = bounds.y1 + h;
+ REGION_INIT(pScreen, &Remaining, &bounds, 0);
+ for (;;)
+ {
+ bounds.x1 = sx + pDrawable->x - pWin->drawable.x;
+ bounds.y1 = sy + pDrawable->y - pWin->drawable.y;
+ bounds.x2 = bounds.x1 + w;
+ bounds.y2 = bounds.y1 + h;
+ if (pWin->viewable && pWin->backStorage &&
+ pWin->drawable.depth == depth &&
+ (RECT_IN_REGION(pScreen, &(pWindowPriv =
+ (miBSWindowPtr) pWin->backStorage)->SavedRegion,
+ &bounds) != rgnOUT ||
+ RECT_IN_REGION(pScreen, &Remaining,
+ REGION_EXTENTS(pScreen, &pWin->borderSize)) != rgnOUT))
+ {
+ if (!pPixmap)
+ {
+ XID subWindowMode = IncludeInferiors;
+ int x, y;
+
+ pPixmap = (*pScreen->CreatePixmap) (pScreen, w, h, depth);
+ if (!pPixmap)
+ goto punt;
+ pGC = GetScratchGC (depth, pScreen);
+ if (!pGC)
+ {
+ (*pScreen->DestroyPixmap) (pPixmap);
+ goto punt;
+ }
+ ChangeGC (pGC, GCSubwindowMode, &subWindowMode);
+ ValidateGC ((DrawablePtr)pPixmap, pGC);
+ REGION_NULL(pScreen, &Border);
+ REGION_NULL(pScreen, &Inside);
+ pSrcWin = (WindowPtr) pDrawable;
+ x = sx;
+ y = sy;
+ if (pSrcWin->parent)
+ {
+ x += pSrcWin->origin.x;
+ y += pSrcWin->origin.y;
+ pSrcWin = pSrcWin->parent;
+ }
+ (*pGC->ops->CopyArea) ((DrawablePtr)pSrcWin,
+ (DrawablePtr)pPixmap, pGC,
+ x, y, w, h,
+ 0, 0);
+ REGION_SUBTRACT(pScreen, &Remaining, &Remaining,
+ &((WindowPtr) pDrawable)->borderClip);
+ }
+
+ REGION_INTERSECT(pScreen, &Inside, &Remaining, &pWin->winSize);
+ REGION_TRANSLATE(pScreen, &Inside,
+ -pWin->drawable.x,
+ -pWin->drawable.y);
+ REGION_INTERSECT(pScreen, &Inside, &Inside,
+ &pWindowPriv->SavedRegion);
+
+ /* offset of sub-window in GetImage pixmap */
+ xoff = pWin->drawable.x - pDrawable->x - sx;
+ yoff = pWin->drawable.y - pDrawable->y - sy;
+
+ if (REGION_NUM_RECTS(&Inside) > 0)
+ {
+ switch (pWindowPriv->status)
+ {
+ case StatusContents:
+ pBox = REGION_RECTS(&Inside);
+ for (n = REGION_NUM_RECTS(&Inside); --n >= 0;)
+ {
+ (*pGC->ops->CopyArea) (
+ (DrawablePtr)pWindowPriv->pBackingPixmap,
+ (DrawablePtr)pPixmap, pGC,
+ pBox->x1 - pWindowPriv->x,
+ pBox->y1 - pWindowPriv->y,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1,
+ pBox->x1 + xoff,
+ pBox->y1 + yoff);
+ ++pBox;
+ }
+ break;
+ case StatusVirtual:
+ case StatusVDirty:
+ if (pWindowPriv->backgroundState == BackgroundPixmap ||
+ pWindowPriv->backgroundState == BackgroundPixel)
+ miBSFillVirtualBits ((DrawablePtr) pPixmap, pGC, &Inside,
+ xoff, yoff,
+ (int) pWindowPriv->backgroundState,
+ pWindowPriv->background, ~0L);
+ break;
+ }
+ }
+ REGION_SUBTRACT(pScreen, &Border, &pWin->borderSize,
+ &pWin->winSize);
+ REGION_INTERSECT(pScreen, &Border, &Border, &Remaining);
+ if (REGION_NUM_RECTS(&Border) > 0)
+ {
+ REGION_TRANSLATE(pScreen, &Border, -pWin->drawable.x,
+ -pWin->drawable.y);
+ miBSFillVirtualBits ((DrawablePtr) pPixmap, pGC, &Border,
+ xoff, yoff,
+ pWin->borderIsPixel ? (int)BackgroundPixel : (int)BackgroundPixmap,
+ pWin->border, ~0L);
+ }
+ }
+
+ if (pWin->viewable && pWin->firstChild)
+ pWin = pWin->firstChild;
+ else
+ {
+ while (!pWin->nextSib && pWin != (WindowPtr) pDrawable)
+ pWin = pWin->parent;
+ if (pWin == (WindowPtr) pDrawable)
+ break;
+ pWin = pWin->nextSib;
+ }
+ }
+
+ REGION_UNINIT(pScreen, &Remaining);
+
+ if (pPixmap)
+ {
+ REGION_UNINIT(pScreen, &Border);
+ REGION_UNINIT(pScreen, &Inside);
+ (*pScreen->GetImage) ((DrawablePtr) pPixmap,
+ 0, 0, w, h, format, planemask, pdstLine);
+ (*pScreen->DestroyPixmap) (pPixmap);
+ FreeScratchGC (pGC);
+ }
+ else
+ {
+ goto punt;
+ }
+ }
+ else
+ {
+punt: ;
+ (*pScreen->GetImage) (pDrawable, sx, sy, w, h,
+ format, planemask, pdstLine);
+ }
+
+ SCREEN_EPILOGUE (pScreen, GetImage, miBSGetImage);
+}
+
+static void
+miBSGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart)
+ DrawablePtr pDrawable;
+ int wMax;
+ DDXPointPtr ppt;
+ int *pwidth;
+ int nspans;
+ char *pdstStart;
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ BoxRec bounds;
+ int i;
+ WindowPtr pWin;
+ int dx, dy;
+
+ SCREEN_PROLOGUE (pScreen, GetSpans);
+
+ if (pDrawable->type != DRAWABLE_PIXMAP && ((WindowPtr) pDrawable)->backStorage)
+ {
+ PixmapPtr pPixmap;
+ miBSWindowPtr pWindowPriv;
+ GCPtr pGC;
+
+ pWin = (WindowPtr) pDrawable;
+ pWindowPriv = (miBSWindowPtr) pWin->backStorage;
+ pPixmap = pWindowPriv->pBackingPixmap;
+
+ bounds.x1 = ppt->x;
+ bounds.y1 = ppt->y;
+ bounds.x2 = bounds.x1 + *pwidth;
+ bounds.y2 = ppt->y;
+ for (i = 0; i < nspans; i++)
+ {
+ if (ppt[i].x < bounds.x1)
+ bounds.x1 = ppt[i].x;
+ if (ppt[i].x + pwidth[i] > bounds.x2)
+ bounds.x2 = ppt[i].x + pwidth[i];
+ if (ppt[i].y < bounds.y1)
+ bounds.y1 = ppt[i].y;
+ else if (ppt[i].y > bounds.y2)
+ bounds.y2 = ppt[i].y;
+ }
+
+ switch (RECT_IN_REGION(pScreen, &pWindowPriv->SavedRegion, &bounds))
+ {
+ case rgnPART:
+ if (!pPixmap)
+ {
+ miCreateBSPixmap (pWin, NullBox);
+ if (!(pPixmap = pWindowPriv->pBackingPixmap))
+ break;
+ }
+ pWindowPriv->status = StatusNoPixmap;
+ pGC = GetScratchGC(pPixmap->drawable.depth,
+ pPixmap->drawable.pScreen);
+ if (pGC)
+ {
+ ValidateGC ((DrawablePtr) pPixmap, pGC);
+ (*pGC->ops->CopyArea)
+ (pDrawable, (DrawablePtr) pPixmap, pGC,
+ bounds.x1, bounds.y1,
+ bounds.x2 - bounds.x1, bounds.y2 - bounds.y1,
+ bounds.x1 + pPixmap->drawable.x - pWin->drawable.x -
+ pWindowPriv->x,
+ bounds.y1 + pPixmap->drawable.y - pWin->drawable.y -
+ pWindowPriv->y);
+ FreeScratchGC(pGC);
+ }
+ pWindowPriv->status = StatusContents;
+ /* fall through */
+ case rgnIN:
+ if (!pPixmap)
+ {
+ miCreateBSPixmap (pWin, NullBox);
+ if (!(pPixmap = pWindowPriv->pBackingPixmap))
+ break;
+ }
+ dx = pPixmap->drawable.x - pWin->drawable.x - pWindowPriv->x;
+ dy = pPixmap->drawable.y - pWin->drawable.y - pWindowPriv->y;
+ for (i = 0; i < nspans; i++)
+ {
+ ppt[i].x += dx;
+ ppt[i].y += dy;
+ }
+ (*pScreen->GetSpans) ((DrawablePtr) pPixmap, wMax, ppt, pwidth,
+ nspans, pdstStart);
+ break;
+ case rgnOUT:
+ (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans,
+ pdstStart);
+ break;
+ }
+ }
+ else
+ {
+ (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+ }
+
+ SCREEN_EPILOGUE (pScreen, GetSpans, miBSGetSpans);
+}
+
+static Bool
+miBSChangeWindowAttributes (pWin, mask)
+ WindowPtr pWin;
+ unsigned long mask;
+{
+ ScreenPtr pScreen;
+ Bool ret;
+
+ pScreen = pWin->drawable.pScreen;
+
+ SCREEN_PROLOGUE (pScreen, ChangeWindowAttributes);
+
+ ret = (*pScreen->ChangeWindowAttributes) (pWin, mask);
+
+ if (ret && (mask & CWBackingStore))
+ {
+ if (pWin->backingStore != NotUseful || pWin->DIXsaveUnder)
+ miBSAllocate (pWin);
+ else
+ miBSFree (pWin);
+ }
+
+ SCREEN_EPILOGUE (pScreen, ChangeWindowAttributes, miBSChangeWindowAttributes);
+
+ return ret;
+}
+
+/*
+ * GC Create wrapper. Set up the cheap GC func wrappers to track
+ * GC validation on BackingStore windows
+ */
+
+static Bool
+miBSCreateGC (pGC)
+ GCPtr pGC;
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ Bool ret;
+
+ SCREEN_PROLOGUE (pScreen, CreateGC);
+
+ if ( (ret = (*pScreen->CreateGC) (pGC)) )
+ {
+ pGC->devPrivates[miBSGCIndex].ptr = (pointer) pGC->funcs;
+ pGC->funcs = &miBSCheapGCFuncs;
+ }
+
+ SCREEN_EPILOGUE (pScreen, CreateGC, miBSCreateGC);
+
+ return ret;
+}
+
+static Bool
+miBSDestroyWindow (pWin)
+ WindowPtr pWin;
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ Bool ret;
+
+ SCREEN_PROLOGUE (pScreen, DestroyWindow);
+
+ ret = (*pScreen->DestroyWindow) (pWin);
+
+ miBSFree (pWin);
+
+ SCREEN_EPILOGUE (pScreen, DestroyWindow, miBSDestroyWindow);
+
+ return ret;
+}
+
+/*
+ * cheap GC func wrappers. Simply track validation on windows
+ * with backing store to enable the real func/op wrappers
+ */
+
+static void
+miBSCheapValidateGC (pGC, stateChanges, pDrawable)
+ GCPtr pGC;
+ unsigned long stateChanges;
+ DrawablePtr pDrawable;
+{
+ CHEAP_FUNC_PROLOGUE (pGC);
+
+ if (pDrawable->type != DRAWABLE_PIXMAP &&
+ ((WindowPtr) pDrawable)->backStorage != NULL &&
+ miBSCreateGCPrivate (pGC))
+ {
+ (*pGC->funcs->ValidateGC) (pGC, stateChanges, pDrawable);
+ }
+ else
+ {
+ (*pGC->funcs->ValidateGC) (pGC, stateChanges, pDrawable);
+
+ /* rewrap funcs as Validate may have changed them */
+ pGC->devPrivates[miBSGCIndex].ptr = (pointer) pGC->funcs;
+
+ CHEAP_FUNC_EPILOGUE (pGC);
+ }
+}
+
+static void
+miBSCheapChangeGC (pGC, mask)
+ GCPtr pGC;
+ unsigned long mask;
+{
+ CHEAP_FUNC_PROLOGUE (pGC);
+
+ (*pGC->funcs->ChangeGC) (pGC, mask);
+
+ CHEAP_FUNC_EPILOGUE (pGC);
+}
+
+static void
+miBSCheapCopyGC (pGCSrc, mask, pGCDst)
+ GCPtr pGCSrc, pGCDst;
+ unsigned long mask;
+{
+ CHEAP_FUNC_PROLOGUE (pGCDst);
+
+ (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
+
+ CHEAP_FUNC_EPILOGUE (pGCDst);
+}
+
+static void
+miBSCheapDestroyGC (pGC)
+ GCPtr pGC;
+{
+ CHEAP_FUNC_PROLOGUE (pGC);
+
+ (*pGC->funcs->DestroyGC) (pGC);
+
+ /* leave it unwrapped */
+}
+
+static void
+miBSCheapChangeClip (pGC, type, pvalue, nrects)
+ GCPtr pGC;
+ int type;
+ pointer pvalue;
+ int nrects;
+{
+ CHEAP_FUNC_PROLOGUE (pGC);
+
+ (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
+
+ CHEAP_FUNC_EPILOGUE (pGC);
+}
+
+static void
+miBSCheapCopyClip(pgcDst, pgcSrc)
+ GCPtr pgcDst, pgcSrc;
+{
+ CHEAP_FUNC_PROLOGUE (pgcDst);
+
+ (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
+
+ CHEAP_FUNC_EPILOGUE (pgcDst);
+}
+
+static void
+miBSCheapDestroyClip(pGC)
+ GCPtr pGC;
+{
+ CHEAP_FUNC_PROLOGUE (pGC);
+
+ (* pGC->funcs->DestroyClip)(pGC);
+
+ CHEAP_FUNC_EPILOGUE (pGC);
+}
+
+/*
+ * create the full func/op wrappers for a GC
+ */
+
+static Bool
+miBSCreateGCPrivate (pGC)
+ GCPtr pGC;
+{
+ miBSGCRec *pPriv;
+
+ pPriv = (miBSGCRec *) xalloc (sizeof (miBSGCRec));
+ if (!pPriv)
+ return FALSE;
+ pPriv->pBackingGC = NULL;
+ pPriv->guarantee = GuaranteeNothing;
+ pPriv->serialNumber = 0;
+ pPriv->stateChanges = (1 << (GCLastBit + 1)) - 1;
+ pPriv->wrapOps = pGC->ops;
+ pPriv->wrapFuncs = pGC->funcs;
+ pGC->funcs = &miBSGCFuncs;
+ pGC->ops = &miBSGCOps;
+ pGC->devPrivates[miBSGCIndex].ptr = (pointer) pPriv;
+ return TRUE;
+}
+
+static void
+miBSDestroyGCPrivate (GCPtr pGC)
+{
+ miBSGCRec *pPriv;
+
+ pPriv = (miBSGCRec *) pGC->devPrivates[miBSGCIndex].ptr;
+ if (pPriv)
+ {
+ pGC->devPrivates[miBSGCIndex].ptr = (pointer) pPriv->wrapFuncs;
+ pGC->funcs = &miBSCheapGCFuncs;
+ pGC->ops = pPriv->wrapOps;
+ if (pPriv->pBackingGC)
+ FreeGC (pPriv->pBackingGC, (GContext) 0);
+ xfree ((pointer) pPriv);
+ }
+}
+
+/*
+ * GC ops -- wrap each GC operation with our own function
+ */
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSFillSpans --
+ * Perform a FillSpans, routing output to backing-store as needed.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSFillSpans(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ DDXPointPtr pptCopy, pptReset;
+ int *pwidthCopy;
+ SETUP_BACKING (pDrawable, pGC);
+
+ PROLOGUE(pGC);
+
+ pptCopy = (DDXPointPtr)ALLOCATE_LOCAL(nInit*sizeof(DDXPointRec));
+ pwidthCopy=(int *)ALLOCATE_LOCAL(nInit*sizeof(int));
+ if (pptCopy && pwidthCopy)
+ {
+ copyData(pptInit, pptCopy, nInit, MoreCopy0);
+ memmove((char *)pwidthCopy,(char *)pwidthInit,nInit*sizeof(int));
+
+ (* pGC->ops->FillSpans)(pDrawable, pGC, nInit, pptInit,
+ pwidthInit, fSorted);
+ if (pGC->miTranslate)
+ {
+ int dx, dy;
+ int nReset;
+
+ pptReset = pptCopy;
+ dx = pDrawable->x - pBackingDrawable->x;
+ dy = pDrawable->y - pBackingDrawable->y;
+ nReset = nInit;
+ while (nReset--)
+ {
+ pptReset->x -= dx;
+ pptReset->y -= dy;
+ ++pptReset;
+ }
+ }
+ (* pBackingGC->ops->FillSpans)(pBackingDrawable,
+ pBackingGC, nInit, pptCopy, pwidthCopy,
+ fSorted);
+ }
+ if (pwidthCopy) DEALLOCATE_LOCAL(pwidthCopy);
+ if (pptCopy) DEALLOCATE_LOCAL(pptCopy);
+
+ EPILOGUE (pGC);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSSetSpans --
+ * Perform a SetSpans, routing output to backing-store as needed.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSSetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ char *psrc;
+ register DDXPointPtr ppt;
+ int *pwidth;
+ int nspans;
+ int fSorted;
+{
+ DDXPointPtr pptCopy, pptReset;
+ int *pwidthCopy;
+ SETUP_BACKING (pDrawable, pGC);
+
+ PROLOGUE(pGC);
+
+ pptCopy = (DDXPointPtr)ALLOCATE_LOCAL(nspans*sizeof(DDXPointRec));
+ pwidthCopy=(int *)ALLOCATE_LOCAL(nspans*sizeof(int));
+ if (pptCopy && pwidthCopy)
+ {
+ copyData(ppt, pptCopy, nspans, MoreCopy0);
+ memmove((char *)pwidthCopy,(char *)pwidth,nspans*sizeof(int));
+
+ (* pGC->ops->SetSpans)(pDrawable, pGC, psrc, ppt, pwidth,
+ nspans, fSorted);
+ if (pGC->miTranslate)
+ {
+ int dx, dy;
+ int nReset;
+
+ pptReset = pptCopy;
+ dx = pDrawable->x - pBackingDrawable->x;
+ dy = pDrawable->y - pBackingDrawable->y;
+ nReset = nspans;
+ while (nReset--)
+ {
+ pptReset->x -= dx;
+ pptReset->y -= dy;
+ ++pptReset;
+ }
+ }
+ (* pBackingGC->ops->SetSpans)(pBackingDrawable, pBackingGC,
+ psrc, pptCopy, pwidthCopy, nspans, fSorted);
+ }
+ if (pwidthCopy) DEALLOCATE_LOCAL(pwidthCopy);
+ if (pptCopy) DEALLOCATE_LOCAL(pptCopy);
+
+ EPILOGUE (pGC);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSPutImage --
+ * Perform a PutImage, routing output to backing-store as needed.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSPutImage(pDrawable, pGC, depth, x, y, w, h, leftPad, format, pBits)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int depth;
+ int x;
+ int y;
+ int w;
+ int h;
+ int leftPad;
+ int format;
+ char *pBits;
+{
+ SETUP_BACKING (pDrawable, pGC);
+
+ PROLOGUE(pGC);
+
+ (*pGC->ops->PutImage)(pDrawable, pGC,
+ depth, x, y, w, h, leftPad, format, pBits);
+ (*pBackingGC->ops->PutImage)(pBackingDrawable, pBackingGC,
+ depth, x - pBackingStore->x, y - pBackingStore->y,
+ w, h, leftPad, format, pBits);
+
+ EPILOGUE (pGC);
+}
+
+typedef RegionPtr (* CopyAreaProcPtr)(DrawablePtr, DrawablePtr, GCPtr,
+ int, int, int, int, int, int);
+typedef RegionPtr (* CopyPlaneProcPtr)(DrawablePtr, DrawablePtr, GCPtr,
+ int, int, int, int, int, int,
+ unsigned long bitPlane);
+/*-
+ *-----------------------------------------------------------------------
+ * miBSDoCopy --
+ * Perform a CopyArea or CopyPlane within a window that has backing
+ * store enabled.
+ *
+ * Results:
+ * TRUE if the copy was performed or FALSE if a regular one should
+ * be done.
+ *
+ * Side Effects:
+ * Things are copied (no s***!)
+ *
+ * Notes:
+ * The idea here is to form two regions that cover the source box.
+ * One contains the exposed rectangles while the other contains
+ * the obscured ones. An array of <box, drawable> pairs is then
+ * formed where the <box> indicates the area to be copied and the
+ * <drawable> indicates from where it is to be copied (exposed regions
+ * come from the screen while obscured ones come from the backing
+ * pixmap). The array 'sequence' is then filled with the indices of
+ * the pairs in the order in which they should be copied to prevent
+ * things from getting screwed up. A call is also made through the
+ * backingGC to take care of any copying into the backing pixmap.
+ *
+ *-----------------------------------------------------------------------
+ */
+static Bool
+miBSDoCopy(
+ WindowPtr pWin, /* Window being scrolled */
+ GCPtr pGC, /* GC we're called through */
+ int srcx, /* X of source rectangle */
+ int srcy, /* Y of source rectangle */
+ int w, /* Width of source rectangle */
+ int h, /* Height of source rectangle */
+ int dstx, /* X of destination rectangle */
+ int dsty, /* Y of destination rectangle */
+ unsigned long plane, /* Plane to copy (0 for CopyArea) */
+ CopyPlaneProcPtr copyProc, /* Procedure to call to perform the copy */
+ RegionPtr *ppRgn) /* resultant Graphics Expose region */
+{
+ RegionPtr pRgnExp; /* Exposed region */
+ RegionPtr pRgnObs; /* Obscured region */
+ BoxRec box; /* Source box (screen coord) */
+ struct BoxDraw {
+ BoxPtr pBox; /* Source box */
+ enum {
+ win, pix
+ } source; /* Place from which to copy */
+ } *boxes; /* Array of box/drawable pairs covering
+ * source box. */
+ int *sequence; /* Sequence of boxes to move */
+ register int i, j, k, l, y;
+ register BoxPtr pBox;
+ int dx, dy, nrects;
+ Bool graphicsExposures;
+ CopyPlaneProcPtr pixCopyProc;
+ int numRectsExp, numRectsObs;
+ BoxPtr pBoxExp, pBoxObs;
+
+ SETUP_BACKING (pWin, pGC);
+ (void)oldFuncs;
+
+ /*
+ * Create a region of exposed boxes in pRgnExp.
+ */
+ box.x1 = srcx + pWin->drawable.x;
+ box.x2 = box.x1 + w;
+ box.y1 = srcy + pWin->drawable.y;
+ box.y2 = box.y1 + h;
+
+ pRgnExp = REGION_CREATE(pGC->pScreen, &box, 1);
+ REGION_INTERSECT(pGC->pScreen, pRgnExp, pRgnExp, &pWin->clipList);
+ pRgnObs = REGION_CREATE(pGC->pScreen, NULL, 1);
+ REGION_INVERSE( pGC->pScreen, pRgnObs, pRgnExp, &box);
+
+ /*
+ * Translate regions into window coordinates for proper calls
+ * to the copyProc, then make sure none of the obscured region sticks
+ * into invalid areas of the backing pixmap.
+ */
+ REGION_TRANSLATE(pGC->pScreen, pRgnExp,
+ -pWin->drawable.x,
+ -pWin->drawable.y);
+ REGION_TRANSLATE(pGC->pScreen, pRgnObs,
+ -pWin->drawable.x,
+ -pWin->drawable.y);
+ REGION_INTERSECT(pGC->pScreen, pRgnObs, pRgnObs, &pBackingStore->SavedRegion);
+
+ /*
+ * If the obscured region is empty, there's no point being fancy.
+ */
+ if (!REGION_NOTEMPTY(pGC->pScreen, pRgnObs))
+ {
+ REGION_DESTROY(pGC->pScreen, pRgnExp);
+ REGION_DESTROY(pGC->pScreen, pRgnObs);
+
+ return (FALSE);
+ }
+
+ numRectsExp = REGION_NUM_RECTS(pRgnExp);
+ pBoxExp = REGION_RECTS(pRgnExp);
+ pBoxObs = REGION_RECTS(pRgnObs);
+ numRectsObs = REGION_NUM_RECTS(pRgnObs);
+ nrects = numRectsExp + numRectsObs;
+
+ boxes = (struct BoxDraw *)ALLOCATE_LOCAL(nrects * sizeof(struct BoxDraw));
+ sequence = (int *) ALLOCATE_LOCAL(nrects * sizeof(int));
+ *ppRgn = NULL;
+
+ if (!boxes || !sequence)
+ {
+ if (sequence) DEALLOCATE_LOCAL(sequence);
+ if (boxes) DEALLOCATE_LOCAL(boxes);
+ REGION_DESTROY(pGC->pScreen, pRgnExp);
+ REGION_DESTROY(pGC->pScreen, pRgnObs);
+
+ return(TRUE);
+ }
+
+ /*
+ * Order the boxes in the two regions so we know from which drawable
+ * to copy which box, storing the result in the boxes array
+ */
+ for (i = 0, j = 0, k = 0;
+ (i < numRectsExp) && (j < numRectsObs);
+ k++)
+ {
+ if (pBoxExp[i].y1 < pBoxObs[j].y1)
+ {
+ boxes[k].pBox = &pBoxExp[i];
+ boxes[k].source = win;
+ i++;
+ }
+ else if ((pBoxObs[j].y1 < pBoxExp[i].y1) ||
+ (pBoxObs[j].x1 < pBoxExp[i].x1))
+ {
+ boxes[k].pBox = &pBoxObs[j];
+ boxes[k].source = pix;
+ j++;
+ }
+ else
+ {
+ boxes[k].pBox = &pBoxExp[i];
+ boxes[k].source = win;
+ i++;
+ }
+ }
+
+ /*
+ * Catch any leftover boxes from either region (note that only
+ * one can have leftover boxes...)
+ */
+ if (i != numRectsExp)
+ {
+ do
+ {
+ boxes[k].pBox = &pBoxExp[i];
+ boxes[k].source = win;
+ i++;
+ k++;
+ } while (i < numRectsExp);
+
+ }
+ else
+ {
+ do
+ {
+ boxes[k].pBox = &pBoxObs[j];
+ boxes[k].source = pix;
+ j++;
+ k++;
+ } while (j < numRectsObs);
+ }
+
+ if (dsty <= srcy)
+ {
+ /*
+ * Scroll up or vertically stationary, so vertical order is ok.
+ */
+ if (dstx <= srcx)
+ {
+ /*
+ * Scroll left or horizontally stationary, so horizontal order
+ * is ok as well.
+ */
+ for (i = 0; i < nrects; i++)
+ {
+ sequence[i] = i;
+ }
+ }
+ else
+ {
+ /*
+ * Scroll right. Need to reverse the rectangles within each
+ * band.
+ */
+ for (i = 0, j = 1, k = 0;
+ i < nrects;
+ j = i + 1, k = i)
+ {
+ y = boxes[i].pBox->y1;
+ while ((j < nrects) && (boxes[j].pBox->y1 == y))
+ {
+ j++;
+ }
+ for (j--; j >= k; j--, i++)
+ {
+ sequence[i] = j;
+ }
+ }
+ }
+ }
+ else
+ {
+ /*
+ * Scroll down. Must reverse vertical banding, at least.
+ */
+ if (dstx < srcx)
+ {
+ /*
+ * Scroll left. Horizontal order is ok.
+ */
+ for (i = nrects - 1, j = i - 1, k = i, l = 0;
+ i >= 0;
+ j = i - 1, k = i)
+ {
+ /*
+ * Find extent of current horizontal band, then reverse
+ * the order of the whole band.
+ */
+ y = boxes[i].pBox->y1;
+ while ((j >= 0) && (boxes[j].pBox->y1 == y))
+ {
+ j--;
+ }
+ for (j++; j <= k; j++, i--, l++)
+ {
+ sequence[l] = j;
+ }
+ }
+ }
+ else
+ {
+ /*
+ * Scroll right or horizontal stationary.
+ * Reverse horizontal order as well (if stationary, horizontal
+ * order can be swapped without penalty and this is faster
+ * to compute).
+ */
+ for (i = 0, j = nrects - 1; i < nrects; i++, j--)
+ {
+ sequence[i] = j;
+ }
+ }
+ }
+
+ /*
+ * XXX: To avoid getting multiple NoExpose events from this operation,
+ * we turn OFF graphicsExposures in the gc and deal with any uncopied
+ * areas later, if there's something not in backing-store.
+ */
+
+ graphicsExposures = pGC->graphicsExposures;
+ pGC->graphicsExposures = FALSE;
+
+ dx = dstx - srcx;
+ dy = dsty - srcy;
+
+ /*
+ * Figure out which copy procedure to use from the backing GC. Note we
+ * must do this because some implementations (sun's, e.g.) have
+ * pBackingGC a fake GC with the real one below it, thus the devPriv for
+ * pBackingGC won't be what the output library expects.
+ */
+ if (plane != 0)
+ {
+ pixCopyProc = pBackingGC->ops->CopyPlane;
+ }
+ else
+ {
+ pixCopyProc = (CopyPlaneProcPtr)pBackingGC->ops->CopyArea;
+ }
+
+ for (i = 0; i < nrects; i++)
+ {
+ pBox = boxes[sequence[i]].pBox;
+
+ /*
+ * If we're copying from the pixmap, we need to place its contents
+ * onto the screen before scrolling the pixmap itself. If we're copying
+ * from the window, we need to copy its contents into the pixmap before
+ * we scroll the window itself.
+ */
+ if (boxes[sequence[i]].source == pix)
+ {
+ (void) (* copyProc) (pBackingDrawable, &(pWin->drawable), pGC,
+ pBox->x1 - pBackingStore->x,
+ pBox->y1 - pBackingStore->y,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
+ pBox->x1 + dx, pBox->y1 + dy, plane);
+ (void) (* pixCopyProc) (pBackingDrawable, pBackingDrawable, pBackingGC,
+ pBox->x1 - pBackingStore->x,
+ pBox->y1 - pBackingStore->y,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
+ pBox->x1 + dx - pBackingStore->x,
+ pBox->y1 + dy - pBackingStore->y, plane);
+ }
+ else
+ {
+ (void) (* pixCopyProc) (&(pWin->drawable), pBackingDrawable, pBackingGC,
+ pBox->x1, pBox->y1,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
+ pBox->x1 + dx - pBackingStore->x,
+ pBox->y1 + dy - pBackingStore->y, plane);
+ (void) (* copyProc) (&(pWin->drawable), &(pWin->drawable), pGC,
+ pBox->x1, pBox->y1,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
+ pBox->x1 + dx, pBox->y1 + dy, plane);
+ }
+ }
+ DEALLOCATE_LOCAL(sequence);
+ DEALLOCATE_LOCAL(boxes);
+
+ pGC->graphicsExposures = graphicsExposures;
+ /*
+ * Form union of rgnExp and rgnObs and see if covers entire area
+ * to be copied. Store the resultant region for miBSCopyArea
+ * to return to dispatch which will send the appropriate expose
+ * events.
+ */
+ REGION_UNION(pGC->pScreen, pRgnExp, pRgnExp, pRgnObs);
+ box.x1 = srcx;
+ box.x2 = srcx + w;
+ box.y1 = srcy;
+ box.y2 = srcy + h;
+ if (RECT_IN_REGION(pGC->pScreen, pRgnExp, &box) == rgnIN)
+ {
+ REGION_EMPTY(pGC->pScreen, pRgnExp);
+ }
+ else
+ {
+ REGION_INVERSE( pGC->pScreen, pRgnExp, pRgnExp, &box);
+ REGION_TRANSLATE( pGC->pScreen, pRgnExp,
+ dx + pWin->drawable.x,
+ dy + pWin->drawable.y);
+ REGION_INTERSECT( pGC->pScreen, pRgnObs, pRgnExp, &pWin->clipList);
+ (*pWin->drawable.pScreen->PaintWindowBackground) (pWin,
+ pRgnObs, PW_BACKGROUND);
+ REGION_TRANSLATE( pGC->pScreen, pRgnExp,
+ -pWin->drawable.x,
+ -pWin->drawable.y);
+ miBSClearBackingRegion (pWin, pRgnExp);
+ }
+ if (graphicsExposures)
+ *ppRgn = pRgnExp;
+ else
+ REGION_DESTROY(pGC->pScreen, pRgnExp);
+ REGION_DESTROY(pGC->pScreen, pRgnObs);
+
+ return (TRUE);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSCopyArea --
+ * Perform a CopyArea from the source to the destination, extracting
+ * from the source's backing-store and storing into the destination's
+ * backing-store without messing anything up. If the source and
+ * destination are different, there's not too much to worry about:
+ * we can just issue several calls to the regular CopyArea function.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static RegionPtr
+miBSCopyArea (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty)
+ DrawablePtr pSrc;
+ DrawablePtr pDst;
+ GCPtr pGC;
+ int srcx;
+ int srcy;
+ int w;
+ int h;
+ int dstx;
+ int dsty;
+{
+ BoxPtr pExtents;
+ long dx, dy;
+ int bsrcx, bsrcy, bw, bh, bdstx, bdsty;
+ RegionPtr pixExposed = 0, winExposed = 0;
+
+ SETUP_BACKING(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ if ((pSrc != pDst) ||
+ (!miBSDoCopy((WindowPtr)pSrc, pGC, srcx, srcy, w, h, dstx, dsty,
+ (unsigned long) 0, (CopyPlaneProcPtr)pGC->ops->CopyArea,
+ &winExposed)))
+ {
+ /*
+ * always copy to the backing store first, miBSDoCopy
+ * returns FALSE if the *source* region is disjoint
+ * from the backing store saved region. So, copying
+ * *to* the backing store is always safe
+ */
+ if (pGC->clientClipType != CT_PIXMAP)
+ {
+ /*
+ * adjust srcx, srcy, w, h, dstx, dsty to be clipped to
+ * the backing store. An unnecessary optimisation,
+ * but a useful one when GetSpans is slow.
+ */
+ pExtents = REGION_EXTENTS(pDst->pScreen,
+ (RegionPtr)pBackingGC->clientClip);
+ bsrcx = srcx;
+ bsrcy = srcy;
+ bw = w;
+ bh = h;
+ bdstx = dstx;
+ bdsty = dsty;
+ dx = pExtents->x1 - bdstx;
+ if (dx > 0)
+ {
+ bsrcx += dx;
+ bdstx += dx;
+ bw -= dx;
+ }
+ dy = pExtents->y1 - bdsty;
+ if (dy > 0)
+ {
+ bsrcy += dy;
+ bdsty += dy;
+ bh -= dy;
+ }
+ dx = (bdstx + bw) - pExtents->x2;
+ if (dx > 0)
+ bw -= dx;
+ dy = (bdsty + bh) - pExtents->y2;
+ if (dy > 0)
+ bh -= dy;
+ if (bw > 0 && bh > 0)
+ pixExposed = (* pBackingGC->ops->CopyArea) (pSrc,
+ pBackingDrawable, pBackingGC,
+ bsrcx, bsrcy, bw, bh, bdstx - pBackingStore->x,
+ bdsty - pBackingStore->y);
+ }
+ else
+ pixExposed = (* pBackingGC->ops->CopyArea) (pSrc,
+ pBackingDrawable, pBackingGC,
+ srcx, srcy, w, h,
+ dstx - pBackingStore->x, dsty - pBackingStore->y);
+
+ winExposed = (* pGC->ops->CopyArea) (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty);
+ }
+
+ /*
+ * compute the composite graphics exposure region
+ */
+ if (winExposed)
+ {
+ if (pixExposed){
+ REGION_UNION(pDst->pScreen, winExposed, winExposed, pixExposed);
+ REGION_DESTROY(pDst->pScreen, pixExposed);
+ }
+ } else
+ winExposed = pixExposed;
+
+ EPILOGUE (pGC);
+
+ return winExposed;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSCopyPlane --
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static RegionPtr
+miBSCopyPlane (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty, plane)
+ DrawablePtr pSrc;
+ DrawablePtr pDst;
+ register GC *pGC;
+ int srcx,
+ srcy;
+ int w,
+ h;
+ int dstx,
+ dsty;
+ unsigned long plane;
+{
+ BoxPtr pExtents;
+ long dx, dy;
+ int bsrcx, bsrcy, bw, bh, bdstx, bdsty;
+ RegionPtr winExposed = 0, pixExposed = 0;
+ SETUP_BACKING(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ if ((pSrc != pDst) ||
+ (!miBSDoCopy((WindowPtr)pSrc, pGC, srcx, srcy, w, h, dstx, dsty,
+ plane, pGC->ops->CopyPlane, &winExposed)))
+ {
+ /*
+ * always copy to the backing store first, miBSDoCopy
+ * returns FALSE if the *source* region is disjoint
+ * from the backing store saved region. So, copying
+ * *to* the backing store is always safe
+ */
+ if (pGC->clientClipType != CT_PIXMAP)
+ {
+ /*
+ * adjust srcx, srcy, w, h, dstx, dsty to be clipped to
+ * the backing store. An unnecessary optimisation,
+ * but a useful one when GetSpans is slow.
+ */
+ pExtents = REGION_EXTENTS(pDst->pScreen,
+ (RegionPtr)pBackingGC->clientClip);
+ bsrcx = srcx;
+ bsrcy = srcy;
+ bw = w;
+ bh = h;
+ bdstx = dstx;
+ bdsty = dsty;
+ dx = pExtents->x1 - bdstx;
+ if (dx > 0)
+ {
+ bsrcx += dx;
+ bdstx += dx;
+ bw -= dx;
+ }
+ dy = pExtents->y1 - bdsty;
+ if (dy > 0)
+ {
+ bsrcy += dy;
+ bdsty += dy;
+ bh -= dy;
+ }
+ dx = (bdstx + bw) - pExtents->x2;
+ if (dx > 0)
+ bw -= dx;
+ dy = (bdsty + bh) - pExtents->y2;
+ if (dy > 0)
+ bh -= dy;
+ if (bw > 0 && bh > 0)
+ pixExposed = (* pBackingGC->ops->CopyPlane) (pSrc,
+ pBackingDrawable,
+ pBackingGC, bsrcx, bsrcy, bw, bh,
+ bdstx - pBackingStore->x,
+ bdsty - pBackingStore->y, plane);
+ }
+ else
+ pixExposed = (* pBackingGC->ops->CopyPlane) (pSrc,
+ pBackingDrawable,
+ pBackingGC, srcx, srcy, w, h,
+ dstx - pBackingStore->x,
+ dsty - pBackingStore->y, plane);
+
+ winExposed = (* pGC->ops->CopyPlane) (pSrc, pDst, pGC, srcx, srcy, w, h,
+ dstx, dsty, plane);
+
+ }
+
+ /*
+ * compute the composite graphics exposure region
+ */
+ if (winExposed)
+ {
+ if (pixExposed)
+ {
+ REGION_UNION(pDst->pScreen, winExposed, winExposed, pixExposed);
+ REGION_DESTROY(pDst->pScreen, pixExposed);
+ }
+ } else
+ winExposed = pixExposed;
+
+ EPILOGUE (pGC);
+
+ return winExposed;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSPolyPoint --
+ * Perform a PolyPoint, routing output to backing-store as needed.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSPolyPoint (pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt;
+ xPoint *pptInit;
+{
+ xPoint *pptCopy;
+ SETUP_BACKING (pDrawable, pGC);
+
+ PROLOGUE(pGC);
+
+ pptCopy = (xPoint *)ALLOCATE_LOCAL(npt*sizeof(xPoint));
+ if (pptCopy)
+ {
+ copyPoints(pptInit, pptCopy, npt, mode);
+
+ (* pGC->ops->PolyPoint) (pDrawable, pGC, mode, npt, pptInit);
+
+ (* pBackingGC->ops->PolyPoint) (pBackingDrawable,
+ pBackingGC, mode, npt, pptCopy);
+
+ DEALLOCATE_LOCAL(pptCopy);
+ }
+
+ EPILOGUE (pGC);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSPolyLines --
+ * Perform a Polylines, routing output to backing-store as needed.
+ *
+ * Results:
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSPolylines (pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode;
+ int npt;
+ DDXPointPtr pptInit;
+{
+ DDXPointPtr pptCopy;
+ SETUP_BACKING (pDrawable, pGC);
+
+ PROLOGUE(pGC);
+
+ pptCopy = (DDXPointPtr)ALLOCATE_LOCAL(npt*sizeof(DDXPointRec));
+ if (pptCopy)
+ {
+ copyPoints(pptInit, pptCopy, npt, mode);
+
+ (* pGC->ops->Polylines)(pDrawable, pGC, mode, npt, pptInit);
+ (* pBackingGC->ops->Polylines)(pBackingDrawable,
+ pBackingGC, mode, npt, pptCopy);
+ DEALLOCATE_LOCAL(pptCopy);
+ }
+
+ EPILOGUE (pGC);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSPolySegment --
+ * Perform a PolySegment, routing output to backing-store as needed.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSPolySegment(pDrawable, pGC, nseg, pSegs)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nseg;
+ xSegment *pSegs;
+{
+ xSegment *pSegsCopy;
+
+ SETUP_BACKING (pDrawable, pGC);
+
+ PROLOGUE(pGC);
+
+ pSegsCopy = (xSegment *)ALLOCATE_LOCAL(nseg*sizeof(xSegment));
+ if (pSegsCopy)
+ {
+ copyData(pSegs, pSegsCopy, nseg << 1, MoreCopy0);
+
+ (* pGC->ops->PolySegment)(pDrawable, pGC, nseg, pSegs);
+ (* pBackingGC->ops->PolySegment)(pBackingDrawable,
+ pBackingGC, nseg, pSegsCopy);
+
+ DEALLOCATE_LOCAL(pSegsCopy);
+ }
+
+ EPILOGUE (pGC);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSPolyRectangle --
+ * Perform a PolyRectangle, routing output to backing-store as needed.
+ *
+ * Results:
+ * None
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSPolyRectangle(pDrawable, pGC, nrects, pRects)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nrects;
+ xRectangle *pRects;
+{
+ xRectangle *pRectsCopy;
+ SETUP_BACKING (pDrawable, pGC);
+
+ PROLOGUE(pGC);
+
+ pRectsCopy =(xRectangle *)ALLOCATE_LOCAL(nrects*sizeof(xRectangle));
+ if (pRectsCopy)
+ {
+ copyData(pRects, pRectsCopy, nrects, MoreCopy2);
+
+ (* pGC->ops->PolyRectangle)(pDrawable, pGC, nrects, pRects);
+ (* pBackingGC->ops->PolyRectangle)(pBackingDrawable,
+ pBackingGC, nrects, pRectsCopy);
+
+ DEALLOCATE_LOCAL(pRectsCopy);
+ }
+
+ EPILOGUE (pGC);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSPolyArc --
+ * Perform a PolyArc, routing output to backing-store as needed.
+ *
+ * Results:
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSPolyArc(pDrawable, pGC, narcs, parcs)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int narcs;
+ xArc *parcs;
+{
+ xArc *pArcsCopy;
+ SETUP_BACKING (pDrawable, pGC);
+
+ PROLOGUE(pGC);
+
+ pArcsCopy = (xArc *)ALLOCATE_LOCAL(narcs*sizeof(xArc));
+ if (pArcsCopy)
+ {
+ copyData(parcs, pArcsCopy, narcs, MoreCopy4);
+
+ (* pGC->ops->PolyArc)(pDrawable, pGC, narcs, parcs);
+ (* pBackingGC->ops->PolyArc)(pBackingDrawable, pBackingGC,
+ narcs, pArcsCopy);
+
+ DEALLOCATE_LOCAL(pArcsCopy);
+ }
+
+ EPILOGUE (pGC);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSFillPolygon --
+ * Perform a FillPolygon, routing output to backing-store as needed.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSFillPolygon(pDrawable, pGC, shape, mode, count, pPts)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int shape, mode;
+ register int count;
+ DDXPointPtr pPts;
+{
+ DDXPointPtr pPtsCopy;
+ SETUP_BACKING (pDrawable, pGC);
+
+ PROLOGUE(pGC);
+
+ pPtsCopy = (DDXPointPtr)ALLOCATE_LOCAL(count*sizeof(DDXPointRec));
+ if (pPtsCopy)
+ {
+ copyPoints(pPts, pPtsCopy, count, mode);
+ (* pGC->ops->FillPolygon)(pDrawable, pGC, shape, mode, count, pPts);
+ (* pBackingGC->ops->FillPolygon)(pBackingDrawable,
+ pBackingGC, shape, mode,
+ count, pPtsCopy);
+
+ DEALLOCATE_LOCAL(pPtsCopy);
+ }
+
+ EPILOGUE (pGC);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSPolyFillRect --
+ * Perform a PolyFillRect, routing output to backing-store as needed.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nrectFill; /* number of rectangles to fill */
+ xRectangle *prectInit; /* Pointer to first rectangle to fill */
+{
+ xRectangle *pRectCopy;
+ SETUP_BACKING (pDrawable, pGC);
+
+ PROLOGUE(pGC);
+
+ pRectCopy =
+ (xRectangle *)ALLOCATE_LOCAL(nrectFill*sizeof(xRectangle));
+ if (pRectCopy)
+ {
+ copyData(prectInit, pRectCopy, nrectFill, MoreCopy2);
+
+ (* pGC->ops->PolyFillRect)(pDrawable, pGC, nrectFill, prectInit);
+ (* pBackingGC->ops->PolyFillRect)(pBackingDrawable,
+ pBackingGC, nrectFill, pRectCopy);
+
+ DEALLOCATE_LOCAL(pRectCopy);
+ }
+
+ EPILOGUE (pGC);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSPolyFillArc --
+ * Perform a PolyFillArc, routing output to backing-store as needed.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSPolyFillArc(pDrawable, pGC, narcs, parcs)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int narcs;
+ xArc *parcs;
+{
+ xArc *pArcsCopy;
+ SETUP_BACKING (pDrawable, pGC);
+
+ PROLOGUE(pGC);
+
+ pArcsCopy = (xArc *)ALLOCATE_LOCAL(narcs*sizeof(xArc));
+ if (pArcsCopy)
+ {
+ copyData(parcs, pArcsCopy, narcs, MoreCopy4);
+ (* pGC->ops->PolyFillArc)(pDrawable, pGC, narcs, parcs);
+ (* pBackingGC->ops->PolyFillArc)(pBackingDrawable,
+ pBackingGC, narcs, pArcsCopy);
+ DEALLOCATE_LOCAL(pArcsCopy);
+ }
+
+ EPILOGUE (pGC);
+}
+
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSPolyText8 --
+ * Perform a PolyText8, routing output to backing-store as needed.
+ *
+ * Results:
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static int
+miBSPolyText8(pDrawable, pGC, x, y, count, chars)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int x, y;
+ int count;
+ char *chars;
+{
+ int result;
+ SETUP_BACKING (pDrawable, pGC);
+
+ PROLOGUE(pGC);
+
+ result = (* pGC->ops->PolyText8)(pDrawable, pGC, x, y, count, chars);
+ (* pBackingGC->ops->PolyText8)(pBackingDrawable, pBackingGC,
+ x - pBackingStore->x, y - pBackingStore->y,
+ count, chars);
+
+ EPILOGUE (pGC);
+ return result;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSPolyText16 --
+ * Perform a PolyText16, routing output to backing-store as needed.
+ *
+ * Results:
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static int
+miBSPolyText16(pDrawable, pGC, x, y, count, chars)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int x, y;
+ int count;
+ unsigned short *chars;
+{
+ int result;
+ SETUP_BACKING (pDrawable, pGC);
+
+ PROLOGUE(pGC);
+
+ result = (* pGC->ops->PolyText16)(pDrawable, pGC, x, y, count, chars);
+ (* pBackingGC->ops->PolyText16)(pBackingDrawable, pBackingGC,
+ x - pBackingStore->x, y - pBackingStore->y,
+ count, chars);
+
+ EPILOGUE (pGC);
+
+ return result;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSImageText8 --
+ * Perform a ImageText8, routing output to backing-store as needed.
+ *
+ * Results:
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSImageText8(pDrawable, pGC, x, y, count, chars)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int x, y;
+ int count;
+ char *chars;
+{
+ SETUP_BACKING (pDrawable, pGC);
+ PROLOGUE(pGC);
+
+ (* pGC->ops->ImageText8)(pDrawable, pGC, x, y, count, chars);
+ (* pBackingGC->ops->ImageText8)(pBackingDrawable, pBackingGC,
+ x - pBackingStore->x, y - pBackingStore->y,
+ count, chars);
+
+ EPILOGUE (pGC);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSImageText16 --
+ * Perform a ImageText16, routing output to backing-store as needed.
+ *
+ * Results:
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSImageText16(pDrawable, pGC, x, y, count, chars)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int x, y;
+ int count;
+ unsigned short *chars;
+{
+ SETUP_BACKING (pDrawable, pGC);
+ PROLOGUE(pGC);
+
+ (* pGC->ops->ImageText16)(pDrawable, pGC, x, y, count, chars);
+ (* pBackingGC->ops->ImageText16)(pBackingDrawable, pBackingGC,
+ x - pBackingStore->x, y - pBackingStore->y,
+ count, chars);
+
+ EPILOGUE (pGC);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSImageGlyphBlt --
+ * Perform a ImageGlyphBlt, routing output to backing-store as needed.
+ *
+ * Results:
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ SETUP_BACKING (pDrawable, pGC);
+ PROLOGUE(pGC);
+
+ (* pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci,
+ pglyphBase);
+ (* pBackingGC->ops->ImageGlyphBlt)(pBackingDrawable, pBackingGC,
+ x - pBackingStore->x, y - pBackingStore->y,
+ nglyph, ppci, pglyphBase);
+
+ EPILOGUE (pGC);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSPolyGlyphBlt --
+ * Perform a PolyGlyphBlt, routing output to backing-store as needed.
+ *
+ * Results:
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSPolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ SETUP_BACKING (pDrawable, pGC);
+ PROLOGUE(pGC);
+
+ (* pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph,
+ ppci, pglyphBase);
+ (* pBackingGC->ops->PolyGlyphBlt)(pBackingDrawable, pBackingGC,
+ x - pBackingStore->x, y - pBackingStore->y,
+ nglyph, ppci, pglyphBase);
+ EPILOGUE (pGC);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSPushPixels --
+ * Perform a PushPixels, routing output to backing-store as needed.
+ *
+ * Results:
+ *
+ * Side Effects:
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSPushPixels(pGC, pBitMap, pDst, w, h, x, y)
+ GCPtr pGC;
+ PixmapPtr pBitMap;
+ DrawablePtr pDst;
+ int w, h, x, y;
+{
+ SETUP_BACKING (pDst, pGC);
+ PROLOGUE(pGC);
+
+ (* pGC->ops->PushPixels)(pGC, pBitMap, pDst, w, h, x, y);
+ if (pGC->miTranslate) {
+ x -= pDst->x;
+ y -= pDst->y;
+ }
+ (* pBackingGC->ops->PushPixels)(pBackingGC, pBitMap,
+ pBackingDrawable, w, h,
+ x - pBackingStore->x, y - pBackingStore->y);
+
+ EPILOGUE (pGC);
+}
+
+#ifdef NEED_LINEHELPER
+/*-
+ *-----------------------------------------------------------------------
+ * miBSLineHelper --
+ *
+ * Results: should never be called
+ *
+ * Side Effects: server dies
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSLineHelper()
+{
+ FatalError("miBSLineHelper called\n");
+}
+#endif
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSClearBackingStore --
+ * Clear the given area of the backing pixmap with the background of
+ * the window, whatever it is. If generateExposures is TRUE, generate
+ * exposure events for the area. Note that if the area has any
+ * part outside the saved portions of the window, we do not allow the
+ * count in the expose events to be 0, since there will be more
+ * expose events to come.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Areas of pixmap are cleared and Expose events are generated.
+ *
+ *-----------------------------------------------------------------------
+ */
+static RegionPtr
+miBSClearBackingStore(pWin, x, y, w, h, generateExposures)
+ WindowPtr pWin;
+ int x;
+ int y;
+ int w;
+ int h;
+ Bool generateExposures;
+{
+ RegionPtr pRgn;
+ int i;
+ miBSWindowPtr pBackingStore;
+ ScreenPtr pScreen;
+ GCPtr pGC;
+ int ts_x_origin,
+ ts_y_origin;
+ pointer gcvalues[4];
+ unsigned long gcmask;
+ xRectangle *rects;
+ BoxPtr pBox;
+ BoxRec box;
+ PixUnion background;
+ char backgroundState;
+ int numRects;
+
+ pBackingStore = (miBSWindowPtr)pWin->backStorage;
+ pScreen = pWin->drawable.pScreen;
+
+ if ((pBackingStore->status == StatusNoPixmap) ||
+ (pBackingStore->status == StatusBadAlloc))
+ return NullRegion;
+
+ if (w == 0)
+ w = (int) pWin->drawable.width - x;
+ if (h == 0)
+ h = (int) pWin->drawable.height - y;
+
+ box.x1 = x;
+ box.y1 = y;
+ box.x2 = x + w;
+ box.y2 = y + h;
+ pRgn = REGION_CREATE(pWin->drawable.pScreen, &box, 1);
+ if (!pRgn)
+ return NullRegion;
+ REGION_INTERSECT( pScreen, pRgn, pRgn, &pBackingStore->SavedRegion);
+
+ if (REGION_NOTEMPTY( pScreen, pRgn))
+ {
+ /*
+ * if clearing entire window, simply make new virtual
+ * tile. For the root window, we also destroy the pixmap
+ * to save a pile of memory
+ */
+ if (x == 0 && y == 0 &&
+ w == pWin->drawable.width &&
+ h == pWin->drawable.height)
+ {
+ if (!pWin->parent)
+ miDestroyBSPixmap (pWin);
+ if (pBackingStore->status != StatusContents)
+ miTileVirtualBS (pWin);
+ }
+
+ ts_x_origin = ts_y_origin = 0;
+
+ backgroundState = pWin->backgroundState;
+ background = pWin->background;
+ if (backgroundState == ParentRelative) {
+ WindowPtr pParent;
+
+ pParent = pWin;
+ while (pParent->backgroundState == ParentRelative) {
+ ts_x_origin -= pParent->origin.x;
+ ts_y_origin -= pParent->origin.y;
+ pParent = pParent->parent;
+ }
+ backgroundState = pParent->backgroundState;
+ background = pParent->background;
+ }
+
+ if ((backgroundState != None) &&
+ ((pBackingStore->status == StatusContents) ||
+ !SameBackground (pBackingStore->backgroundState,
+ pBackingStore->background,
+ backgroundState,
+ background)))
+ {
+ if (!pBackingStore->pBackingPixmap)
+ miCreateBSPixmap(pWin, NullBox);
+
+ pGC = GetScratchGC(pWin->drawable.depth, pScreen);
+ if (pGC && pBackingStore->pBackingPixmap)
+ {
+ /*
+ * First take care of any ParentRelative stuff by altering the
+ * tile/stipple origin to match the coordinates of the upper-left
+ * corner of the first ancestor without a ParentRelative background.
+ * This coordinate is, of course, negative.
+ */
+
+ if (backgroundState == BackgroundPixel)
+ {
+ gcvalues[0] = (pointer) background.pixel;
+ gcvalues[1] = (pointer)FillSolid;
+ gcmask = GCForeground|GCFillStyle;
+ }
+ else
+ {
+ gcvalues[0] = (pointer)FillTiled;
+ gcvalues[1] = (pointer) background.pixmap;
+ gcmask = GCFillStyle|GCTile;
+ }
+ gcvalues[2] = (pointer)(long)(ts_x_origin - pBackingStore->x);
+ gcvalues[3] = (pointer)(long)(ts_y_origin - pBackingStore->y);
+ gcmask |= GCTileStipXOrigin|GCTileStipYOrigin;
+ DoChangeGC(pGC, gcmask, (XID *)gcvalues, TRUE);
+ ValidateGC((DrawablePtr)pBackingStore->pBackingPixmap, pGC);
+
+ /*
+ * Figure out the array of rectangles to fill and fill them with
+ * PolyFillRect in the proper mode, as set in the GC above.
+ */
+ numRects = REGION_NUM_RECTS(pRgn);
+ rects = (xRectangle *)ALLOCATE_LOCAL(numRects*sizeof(xRectangle));
+
+ if (rects)
+ {
+ for (i = 0, pBox = REGION_RECTS(pRgn);
+ i < numRects;
+ i++, pBox++)
+ {
+ rects[i].x = pBox->x1 - pBackingStore->x;
+ rects[i].y = pBox->y1 - pBackingStore->y;
+ rects[i].width = pBox->x2 - pBox->x1;
+ rects[i].height = pBox->y2 - pBox->y1;
+ }
+ (* pGC->ops->PolyFillRect) (
+ (DrawablePtr)pBackingStore->pBackingPixmap,
+ pGC, numRects, rects);
+ DEALLOCATE_LOCAL(rects);
+ }
+ FreeScratchGC(pGC);
+ }
+ }
+
+ if (!generateExposures)
+ {
+ REGION_DESTROY(pScreen, pRgn);
+ pRgn = NULL;
+ }
+ else
+ {
+ /*
+ * result must be screen relative, but is currently
+ * drawable relative.
+ */
+ REGION_TRANSLATE(pScreen, pRgn, pWin->drawable.x,
+ pWin->drawable.y);
+ }
+ }
+ else
+ {
+ REGION_DESTROY( pScreen, pRgn);
+ pRgn = NULL;
+ }
+ return pRgn;
+}
+
+static void
+miBSClearBackingRegion (pWin, pRgn)
+ WindowPtr pWin;
+ RegionPtr pRgn;
+{
+ BoxPtr pBox;
+ int i;
+
+ i = REGION_NUM_RECTS(pRgn);
+ pBox = REGION_RECTS(pRgn);
+ while (i--)
+ {
+ (void) miBSClearBackingStore(pWin, pBox->x1, pBox->y1,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1,
+ FALSE);
+ pBox++;
+ }
+}
+
+/*
+ * fill a region of the destination with virtual bits
+ *
+ * pRgn is to be translated by (x,y)
+ */
+
+static void
+miBSFillVirtualBits (pDrawable, pGC, pRgn, x, y, state, pixunion, planeMask)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ RegionPtr pRgn;
+ int x, y;
+ int state;
+ PixUnion pixunion;
+ unsigned long planeMask;
+{
+ int i;
+ BITS32 gcmask;
+ pointer gcval[5];
+ xRectangle *pRect;
+ BoxPtr pBox;
+ WindowPtr pWin;
+ int numRects;
+
+ if (state == None)
+ return;
+ numRects = REGION_NUM_RECTS(pRgn);
+ pRect = (xRectangle *)ALLOCATE_LOCAL(numRects * sizeof(xRectangle));
+ if (!pRect)
+ return;
+ pWin = 0;
+ if (pDrawable->type != DRAWABLE_PIXMAP)
+ {
+ pWin = (WindowPtr) pDrawable;
+ if (!pWin->backStorage)
+ pWin = 0;
+ }
+ i = 0;
+ gcmask = 0;
+ gcval[i++] = (pointer)planeMask;
+ gcmask |= GCPlaneMask;
+ if (state == BackgroundPixel)
+ {
+ if (pGC->fgPixel != pixunion.pixel)
+ {
+ gcval[i++] = (pointer)pixunion.pixel;
+ gcmask |= GCForeground;
+ }
+ if (pGC->fillStyle != FillSolid)
+ {
+ gcval[i++] = (pointer)FillSolid;
+ gcmask |= GCFillStyle;
+ }
+ }
+ else
+ {
+ if (pGC->fillStyle != FillTiled)
+ {
+ gcval[i++] = (pointer)FillTiled;
+ gcmask |= GCFillStyle;
+ }
+ if (pGC->tileIsPixel || pGC->tile.pixmap != pixunion.pixmap)
+ {
+ gcval[i++] = (pointer)pixunion.pixmap;
+ gcmask |= GCTile;
+ }
+ if (pGC->patOrg.x != x)
+ {
+ gcval[i++] = (pointer)(long)x;
+ gcmask |= GCTileStipXOrigin;
+ }
+ if (pGC->patOrg.y != y)
+ {
+ gcval[i++] = (pointer)(long)y;
+ gcmask |= GCTileStipYOrigin;
+ }
+ }
+ if (gcmask)
+ DoChangeGC (pGC, gcmask, (XID *)gcval, 1);
+
+ if (pWin)
+ (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack);
+
+ if (pDrawable->serialNumber != pGC->serialNumber)
+ ValidateGC (pDrawable, pGC);
+
+ pBox = REGION_RECTS(pRgn);
+ for (i = numRects; --i >= 0; pBox++, pRect++)
+ {
+ pRect->x = pBox->x1 + x;
+ pRect->y = pBox->y1 + y;
+ pRect->width = pBox->x2 - pBox->x1;
+ pRect->height = pBox->y2 - pBox->y1;
+ }
+ pRect -= numRects;
+ (*pGC->ops->PolyFillRect) (pDrawable, pGC, numRects, pRect);
+ if (pWin)
+ (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeNothing);
+ DEALLOCATE_LOCAL (pRect);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSAllocate --
+ * Create and install backing store info for a window
+ *
+ *-----------------------------------------------------------------------
+ */
+
+static void
+miBSAllocate(pWin)
+ WindowPtr pWin;
+{
+ register miBSWindowPtr pBackingStore;
+ register ScreenPtr pScreen;
+
+ if (pWin->drawable.pScreen->backingStoreSupport == NotUseful)
+ return;
+ pScreen = pWin->drawable.pScreen;
+ if (!(pBackingStore = (miBSWindowPtr)pWin->backStorage))
+ {
+
+ pBackingStore = (miBSWindowPtr)xalloc(sizeof(miBSWindowRec));
+ if (!pBackingStore)
+ return;
+
+ pBackingStore->pBackingPixmap = NullPixmap;
+ pBackingStore->x = 0;
+ pBackingStore->y = 0;
+ REGION_NULL( pScreen, &pBackingStore->SavedRegion);
+ pBackingStore->viewable = (char)pWin->viewable;
+ pBackingStore->status = StatusNoPixmap;
+ pBackingStore->backgroundState = None;
+ pWin->backStorage = (pointer) pBackingStore;
+ }
+
+ /*
+ * Now want to initialize the backing pixmap and SavedRegion if
+ * necessary. The initialization consists of finding all the
+ * currently-obscured regions, by taking the inverse of the window's
+ * clip list, storing the result in SavedRegion, and exposing those
+ * areas of the window.
+ */
+
+ if (pBackingStore->status == StatusNoPixmap &&
+ ((pWin->backingStore == WhenMapped && pWin->viewable) ||
+ (pWin->backingStore == Always)))
+ {
+ BoxRec box;
+ RegionPtr pSavedRegion;
+
+ pSavedRegion = &pBackingStore->SavedRegion;
+
+ box.x1 = pWin->drawable.x;
+ box.x2 = box.x1 + (int) pWin->drawable.width;
+ box.y1 = pWin->drawable.y;
+ box.y2 = pWin->drawable.y + (int) pWin->drawable.height;
+
+ REGION_INVERSE( pScreen, pSavedRegion, &pWin->clipList, &box);
+ REGION_TRANSLATE( pScreen, pSavedRegion,
+ -pWin->drawable.x,
+ -pWin->drawable.y);
+#ifdef SHAPE
+ if (wBoundingShape (pWin))
+ REGION_INTERSECT(pScreen, pSavedRegion, pSavedRegion,
+ wBoundingShape (pWin));
+ if (wClipShape (pWin))
+ REGION_INTERSECT(pScreen, pSavedRegion, pSavedRegion,
+ wClipShape (pWin));
+#endif
+ /* if window is already on-screen, assume it has been drawn to */
+ if (pWin->viewable)
+ pBackingStore->status = StatusVDirty;
+ miTileVirtualBS (pWin);
+
+ /*
+ * deliver all the newly available regions
+ * as exposure events to the window
+ */
+
+ miSendExposures(pWin, pSavedRegion, 0, 0);
+ }
+ else if (!pWin->viewable)
+ {
+ /*
+ * Turn off backing store when we're not supposed to
+ * be saving anything
+ */
+ if (pBackingStore->status != StatusNoPixmap)
+ {
+ REGION_EMPTY( pScreen, &pBackingStore->SavedRegion);
+ miDestroyBSPixmap (pWin);
+ }
+ }
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSFree --
+ * Destroy and free all the stuff associated with the backing-store
+ * for the given window.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * The backing pixmap and all the regions and GC's are destroyed.
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSFree(pWin)
+ WindowPtr pWin;
+{
+ miBSWindowPtr pBackingStore;
+ register ScreenPtr pScreen;
+
+ pScreen = pWin->drawable.pScreen;
+
+ pBackingStore = (miBSWindowPtr)pWin->backStorage;
+ if (pBackingStore)
+ {
+ miDestroyBSPixmap (pWin);
+
+ REGION_UNINIT( pScreen, &pBackingStore->SavedRegion);
+
+ xfree(pBackingStore);
+ pWin->backStorage = NULL;
+ }
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miResizeBackingStore --
+ * Alter the size of the backing pixmap as necessary when the
+ * SavedRegion changes size. The contents of the old pixmap are
+ * copied/shifted into the new/same pixmap.
+ *
+ * Results:
+ * The new Pixmap is created as necessary.
+ *
+ * Side Effects:
+ * The old pixmap is destroyed.
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miResizeBackingStore(
+ WindowPtr pWin,
+ int dx, /* bits are moving this far */
+ int dy, /* bits are moving this far */
+ Bool saveBits) /* bits are useful */
+{
+ miBSWindowPtr pBackingStore;
+ PixmapPtr pBackingPixmap;
+ ScreenPtr pScreen;
+ GC *pGC;
+ BoxPtr extents;
+ PixmapPtr pNewPixmap;
+ int nx, ny;
+ int nw, nh;
+
+ pBackingStore = (miBSWindowPtr)(pWin->backStorage);
+ pBackingPixmap = pBackingStore->pBackingPixmap;
+ if (!pBackingPixmap)
+ return;
+ pScreen = pWin->drawable.pScreen;
+ extents = REGION_EXTENTS(pScreen, &pBackingStore->SavedRegion);
+ pNewPixmap = pBackingPixmap;
+
+ nw = extents->x2 - extents->x1;
+ nh = extents->y2 - extents->y1;
+
+ /* the policy here could be more sophisticated */
+ if (nw != pBackingPixmap->drawable.width ||
+ nh != pBackingPixmap->drawable.height)
+ {
+ if (!saveBits || !nw || !nh)
+ {
+ pNewPixmap = NullPixmap;
+ pBackingStore->status = StatusNoPixmap;
+ }
+ else
+ {
+ pNewPixmap = (PixmapPtr)(*pScreen->CreatePixmap)
+ (pScreen,
+ nw, nh,
+ pWin->drawable.depth);
+ if (!pNewPixmap)
+ {
+#ifdef BSEAGER
+ pBackingStore->status = StatusNoPixmap;
+#else
+ pBackingStore->status = StatusBadAlloc;
+#endif
+ }
+ }
+ }
+ if (!pNewPixmap)
+ {
+ pBackingStore->x = 0;
+ pBackingStore->y = 0;
+ }
+ else
+ {
+ nx = pBackingStore->x - extents->x1 + dx;
+ ny = pBackingStore->y - extents->y1 + dy;
+ pBackingStore->x = extents->x1;
+ pBackingStore->y = extents->y1;
+
+ if (saveBits && (pNewPixmap != pBackingPixmap || nx != 0 || ny != 0))
+ {
+ pGC = GetScratchGC(pNewPixmap->drawable.depth, pScreen);
+ if (pGC)
+ {
+ ValidateGC((DrawablePtr)pNewPixmap, pGC);
+ /* if we implement a policy where the pixmap can be larger than
+ * the region extents, we might want to optimize this copyarea
+ * by only copying the old extents, rather than the entire
+ * pixmap
+ */
+ (*pGC->ops->CopyArea)((DrawablePtr)pBackingPixmap,
+ (DrawablePtr)pNewPixmap, pGC,
+ 0, 0,
+ pBackingPixmap->drawable.width,
+ pBackingPixmap->drawable.height,
+ nx, ny);
+ FreeScratchGC(pGC);
+ }
+ }
+ }
+ /* SavedRegion is used in the backingGC clip; force an update */
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ if (pNewPixmap != pBackingPixmap)
+ {
+ (* pScreen->DestroyPixmap)(pBackingPixmap);
+ pBackingStore->pBackingPixmap = pNewPixmap;
+ }
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSSaveDoomedAreas --
+ * Saved the areas of the given window that are about to be
+ * obscured. If the window has moved, pObscured is expected to
+ * be at the new screen location and (dx,dy) is expected to be the offset
+ * to the window's previous location.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * The region is copied from the screen into pBackingPixmap and
+ * SavedRegion is updated.
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSSaveDoomedAreas(pWin, pObscured, dx, dy)
+ register WindowPtr pWin;
+ RegionPtr pObscured;
+ int dx, dy;
+{
+ miBSWindowPtr pBackingStore;
+ ScreenPtr pScreen;
+ int x, y;
+
+ pBackingStore = (miBSWindowPtr)pWin->backStorage;
+ pScreen = pWin->drawable.pScreen;
+
+ /*
+ * If the window isn't realized, it's being unmapped, thus we don't
+ * want to save anything if backingStore isn't Always.
+ */
+ if (!pWin->realized)
+ {
+ pBackingStore->viewable = (char)pWin->viewable;
+ if (pWin->backingStore != Always)
+ {
+ REGION_EMPTY( pScreen, &pBackingStore->SavedRegion);
+ miDestroyBSPixmap (pWin);
+ return;
+ }
+ if (pBackingStore->status == StatusBadAlloc)
+ pBackingStore->status = StatusNoPixmap;
+ }
+
+ /* Don't even pretend to save anything for a virtual background None */
+ if ((pBackingStore->status == StatusVirtual) &&
+ (pBackingStore->backgroundState == None))
+ return;
+
+ if (REGION_NOTEMPTY(pScreen, pObscured))
+ {
+ BoxRec oldExtents;
+ x = pWin->drawable.x;
+ y = pWin->drawable.y;
+ REGION_TRANSLATE(pScreen, pObscured, -x, -y);
+ oldExtents = *REGION_EXTENTS(pScreen, &pBackingStore->SavedRegion);
+ REGION_UNION( pScreen, &pBackingStore->SavedRegion,
+ &pBackingStore->SavedRegion,
+ pObscured);
+ /*
+ * only save the bits if we've actually
+ * started using backing store
+ */
+ if (pBackingStore->status != StatusVirtual)
+ {
+ if (!pBackingStore->pBackingPixmap)
+ miCreateBSPixmap (pWin, &oldExtents);
+ else
+ miResizeBackingStore(pWin, 0, 0, TRUE);
+
+ if (pBackingStore->pBackingPixmap) {
+ if (pBackingStore->x | pBackingStore->y)
+ {
+ REGION_TRANSLATE( pScreen, pObscured,
+ -pBackingStore->x,
+ -pBackingStore->y);
+ x += pBackingStore->x;
+ y += pBackingStore->y;
+ }
+ (* pScreen->BackingStoreFuncs.SaveAreas)
+ (pBackingStore->pBackingPixmap, pObscured,
+ x - dx, y - dy, pWin);
+ }
+ }
+ REGION_TRANSLATE(pScreen, pObscured, x, y);
+ }
+ else
+ {
+ if (REGION_BROKEN (pScreen, pObscured))
+ {
+ REGION_EMPTY( pScreen, &pBackingStore->SavedRegion);
+ miDestroyBSPixmap (pWin);
+ return;
+ }
+ }
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSRestoreAreas --
+ * Restore areas from backing-store that are no longer obscured.
+ * expects prgnExposed to contain a screen-relative area.
+ *
+ * Results:
+ * The region to generate exposure events on (which may be
+ * different from the region to paint).
+ *
+ * Side Effects:
+ * Areas are copied from pBackingPixmap to the screen. prgnExposed
+ * is altered to contain the region that could not be restored from
+ * backing-store.
+ *
+ * Notes:
+ * This is called before sending any exposure events to the client,
+ * and so might be called if the window has grown. Changing the backing
+ * pixmap doesn't require revalidating the backingGC because the
+ * client's next output request will result in a call to ValidateGC,
+ * since the window clip region has changed, which will in turn call
+ * miValidateBackingStore.
+ *-----------------------------------------------------------------------
+ */
+static RegionPtr
+miBSRestoreAreas(pWin, prgnExposed)
+ register WindowPtr pWin;
+ RegionPtr prgnExposed;
+{
+ PixmapPtr pBackingPixmap;
+ miBSWindowPtr pBackingStore;
+ RegionPtr prgnSaved;
+ RegionPtr prgnRestored;
+ register ScreenPtr pScreen;
+ RegionPtr exposures = prgnExposed;
+
+ pScreen = pWin->drawable.pScreen;
+ pBackingStore = (miBSWindowPtr)pWin->backStorage;
+ pBackingPixmap = pBackingStore->pBackingPixmap;
+
+ prgnSaved = &pBackingStore->SavedRegion;
+
+ if (pBackingStore->status == StatusContents)
+ {
+ REGION_TRANSLATE(pScreen, prgnSaved, pWin->drawable.x,
+ pWin->drawable.y);
+
+ prgnRestored = REGION_CREATE( pScreen, (BoxPtr)NULL, 1);
+ REGION_INTERSECT( pScreen, prgnRestored, prgnExposed, prgnSaved);
+
+ /*
+ * Since prgnExposed is no longer obscured, we no longer
+ * will have a valid copy of it in backing-store, but there is a valid
+ * copy of it on screen, so subtract the area we just restored from
+ * from the area to be exposed.
+ */
+
+ if (REGION_NOTEMPTY( pScreen, prgnRestored))
+ {
+ REGION_SUBTRACT( pScreen, prgnSaved, prgnSaved, prgnExposed);
+ REGION_SUBTRACT( pScreen, prgnExposed, prgnExposed, prgnRestored);
+
+ /*
+ * Do the actual restoration
+ */
+ (* pScreen->BackingStoreFuncs.RestoreAreas) (pBackingPixmap,
+ prgnRestored,
+ pWin->drawable.x + pBackingStore->x,
+ pWin->drawable.y + pBackingStore->y,
+ pWin);
+ /*
+ * if the saved region is completely empty, dispose of the
+ * backing pixmap, otherwise, retranslate the saved
+ * region to window relative
+ */
+
+ if (REGION_NOTEMPTY(pScreen, prgnSaved))
+ {
+ REGION_TRANSLATE(pScreen, prgnSaved,
+ -pWin->drawable.x,
+ -pWin->drawable.y);
+ miResizeBackingStore(pWin, 0, 0, TRUE);
+ }
+ else
+ miDestroyBSPixmap (pWin);
+ }
+ else
+ REGION_TRANSLATE(pScreen, prgnSaved,
+ -pWin->drawable.x, -pWin->drawable.y);
+ REGION_DESTROY( pScreen, prgnRestored);
+
+ }
+ else if ((pBackingStore->status == StatusVirtual) ||
+ (pBackingStore->status == StatusVDirty))
+ {
+ REGION_TRANSLATE(pScreen, prgnSaved,
+ pWin->drawable.x, pWin->drawable.y);
+ exposures = REGION_CREATE( pScreen, NullBox, 1);
+ if (SameBackground (pBackingStore->backgroundState,
+ pBackingStore->background,
+ pWin->backgroundState,
+ pWin->background))
+ {
+ REGION_SUBTRACT( pScreen, exposures, prgnExposed, prgnSaved);
+ }
+ else
+ {
+ miTileVirtualBS(pWin);
+
+ /* we need to expose all we have (virtually) retiled */
+ REGION_UNION( pScreen, exposures, prgnExposed, prgnSaved);
+ }
+ REGION_SUBTRACT( pScreen, prgnSaved, prgnSaved, prgnExposed);
+ REGION_TRANSLATE(pScreen, prgnSaved,
+ -pWin->drawable.x, -pWin->drawable.y);
+ }
+ else if (pWin->viewable && !pBackingStore->viewable &&
+ pWin->backingStore != Always)
+ {
+ /*
+ * The window was just mapped and nothing has been saved in
+ * backing-store from the last time it was mapped. We want to capture
+ * any output to regions that are already obscured but there are no
+ * bits to snag off the screen, so we initialize things just as we did
+ * in miBSAllocate, above.
+ */
+ BoxRec box;
+
+ prgnSaved = &pBackingStore->SavedRegion;
+
+ box.x1 = pWin->drawable.x;
+ box.x2 = box.x1 + (int) pWin->drawable.width;
+ box.y1 = pWin->drawable.y;
+ box.y2 = box.y1 + (int) pWin->drawable.height;
+
+ REGION_INVERSE( pScreen, prgnSaved, &pWin->clipList, &box);
+ REGION_TRANSLATE( pScreen, prgnSaved,
+ -pWin->drawable.x,
+ -pWin->drawable.y);
+#ifdef SHAPE
+ if (wBoundingShape (pWin))
+ REGION_INTERSECT(pScreen, prgnSaved, prgnSaved,
+ wBoundingShape (pWin));
+ if (wClipShape (pWin))
+ REGION_INTERSECT(pScreen, prgnSaved, prgnSaved,
+ wClipShape (pWin));
+#endif
+ miTileVirtualBS(pWin);
+
+ exposures = REGION_CREATE( pScreen, &box, 1);
+ }
+ pBackingStore->viewable = (char)pWin->viewable;
+ return exposures;
+}
+
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSTranslateBackingStore --
+ * Shift the backing-store in the given direction. Called when bit
+ * gravity is shifting things around.
+ *
+ * Results:
+ * An occluded region of the window which should be sent exposure events.
+ * This region should be in absolute coordinates (i.e. include
+ * new window position).
+ *
+ * Side Effects:
+ * If the window changed size as well as position, the backing pixmap
+ * is resized. The contents of the backing pixmap are shifted
+ *
+ * Warning:
+ * Bob and I have rewritten this routine quite a few times, each
+ * time it gets a few more cases correct, and introducing some
+ * interesting bugs. Naturally, I think the code is correct this
+ * time.
+ *
+ * Let me try to explain what this routine is for:
+ *
+ * It's called from SlideAndSizeWindow whenever a window
+ * with backing store is resized. There are two separate
+ * possibilities:
+ *
+ * a) The window has ForgetGravity
+ *
+ * In this case, windx, windy will be 0 and oldClip will
+ * be NULL. This indicates that all of the window contents
+ * currently saved offscreen should be discarded, and the
+ * entire window exposed. TranslateBackingStore, then, should
+ * prepare a completely new backing store region based on the
+ * new window clipList and return that region for exposure.
+ *
+ * b) The window has some other gravity
+ *
+ * In this case, windx, windy will be set to the distance
+ * that the bits should move within the window. oldClip
+ * will be set to the old visible portion of the window.
+ * TranslateBackingStore, then, should adjust the backing
+ * store to accommodate the portion of the existing backing
+ * store bits which coorespond to backing store bits which
+ * will still be occluded in the new configuration. oldx,oldy
+ * are set to the old position of the window on the screen.
+ *
+ * Furthermore, in this case any contents of the screen which
+ * are about to become occluded should be fetched from the screen
+ * and placed in backing store. This is to avoid the eventual
+ * occlusion by the win gravity shifting the child window bits around
+ * on top of this window, and potentially losing information
+ *
+ * It's also called from SetShape, but I think (he says not
+ * really knowing for sure) that this code will even work
+ * in that case.
+ *-----------------------------------------------------------------------
+ */
+
+static RegionPtr
+miBSTranslateBackingStore(pWin, windx, windy, oldClip, oldx, oldy)
+ WindowPtr pWin;
+ int windx; /* bit translation distance in window */
+ int windy;
+ RegionPtr oldClip; /* Region being copied */
+ int oldx; /* old window position */
+ int oldy;
+{
+ register miBSWindowPtr pBackingStore;
+ register RegionPtr pSavedRegion;
+ register RegionPtr newSaved, doomed;
+ register ScreenPtr pScreen;
+ BoxRec extents;
+ int scrdx; /* bit translation distance on screen */
+ int scrdy;
+ int dx; /* distance window moved on screen */
+ int dy;
+
+ pScreen = pWin->drawable.pScreen;
+ pBackingStore = (miBSWindowPtr)(pWin->backStorage);
+ if ((pBackingStore->status == StatusNoPixmap) ||
+ (pBackingStore->status == StatusBadAlloc))
+ return NullRegion;
+
+ /*
+ * Compute the new saved region
+ */
+
+ newSaved = REGION_CREATE( pScreen, NullBox, 1);
+ extents.x1 = pWin->drawable.x;
+ extents.x2 = pWin->drawable.x + (int) pWin->drawable.width;
+ extents.y1 = pWin->drawable.y;
+ extents.y2 = pWin->drawable.y + (int) pWin->drawable.height;
+ REGION_INVERSE( pScreen, newSaved, &pWin->clipList, &extents);
+
+ REGION_TRANSLATE( pScreen, newSaved,
+ -pWin->drawable.x, -pWin->drawable.y);
+#ifdef SHAPE
+ if (wBoundingShape (pWin) || wClipShape (pWin)) {
+ if (wBoundingShape (pWin))
+ REGION_INTERSECT( pScreen, newSaved, newSaved,
+ wBoundingShape (pWin));
+ if (wClipShape (pWin))
+ REGION_INTERSECT( pScreen, newSaved, newSaved, wClipShape (pWin));
+ }
+#endif
+
+ pSavedRegion = &pBackingStore->SavedRegion;
+
+ /* now find any visible areas we can save from the screen */
+ /* and then translate newSaved to old local coordinates */
+ if (oldClip)
+ {
+ /* bit gravity makes things virtually too hard, punt */
+ if (((windx != 0) || (windy != 0)) &&
+ (pBackingStore->status != StatusContents))
+ miCreateBSPixmap(pWin, NullBox);
+
+ /*
+ * The window is moving this far on the screen
+ */
+ dx = pWin->drawable.x - oldx;
+ dy = pWin->drawable.y - oldy;
+ /*
+ * The bits will be moving on the screen by the
+ * amount the window is moving + the amount the
+ * bits are moving within the window
+ */
+ scrdx = windx + dx;
+ scrdy = windy + dy;
+
+ /*
+ * intersect at old bit position to discover the
+ * bits on the screen which can be put into the
+ * new backing store
+ */
+ REGION_TRANSLATE( pScreen, oldClip, windx - oldx, windy - oldy);
+ doomed = REGION_CREATE( pScreen, NullBox, 1);
+ REGION_INTERSECT( pScreen, doomed, oldClip, newSaved);
+ REGION_TRANSLATE( pScreen, oldClip, oldx - windx, oldy - windy);
+
+ /*
+ * Translate the old saved region to the position in the
+ * window where it will appear to be
+ */
+ REGION_TRANSLATE( pScreen, pSavedRegion, windx, windy);
+
+ /*
+ * Add the old saved region to the new saved region, so
+ * that calls to RestoreAreas will be able to fetch those
+ * bits back
+ */
+ REGION_UNION( pScreen, newSaved, newSaved, pSavedRegion);
+
+ /*
+ * Swap the new saved region into the window
+ */
+ {
+ RegionRec tmp;
+
+ tmp = *pSavedRegion;
+ *pSavedRegion = *newSaved;
+ *newSaved = tmp;
+ }
+ miResizeBackingStore (pWin, windx, windy, TRUE);
+
+ /*
+ * Compute the newly enabled region
+ * of backing store. This region will be
+ * set to background in the backing pixmap and
+ * sent as exposure events to the client.
+ */
+ REGION_SUBTRACT( pScreen, newSaved, pSavedRegion, newSaved);
+
+ /*
+ * Fetch bits which will be obscured from
+ * the screen
+ */
+ if (REGION_NOTEMPTY( pScreen, doomed))
+ {
+ /*
+ * Don't clear regions which have bits on the
+ * screen
+ */
+ REGION_SUBTRACT( pScreen, newSaved, newSaved, doomed);
+
+ /*
+ * Make the region to SaveDoomedAreas absolute, instead
+ * of window relative.
+ */
+ REGION_TRANSLATE( pScreen, doomed,
+ pWin->drawable.x, pWin->drawable.y);
+ (* pScreen->SaveDoomedAreas) (pWin, doomed, scrdx, scrdy);
+ }
+
+ REGION_DESTROY(pScreen, doomed);
+
+ /*
+ * and clear whatever there is that's new
+ */
+ if (REGION_NOTEMPTY( pScreen, newSaved))
+ {
+ miBSClearBackingRegion (pWin, newSaved);
+ /*
+ * Make the exposed region absolute
+ */
+ REGION_TRANSLATE(pScreen, newSaved,
+ pWin->drawable.x,
+ pWin->drawable.y);
+ }
+ else
+ {
+ REGION_DESTROY(pScreen, newSaved);
+ newSaved = NullRegion;
+ }
+ }
+ else
+ {
+ /*
+ * ForgetGravity: just reset backing store and
+ * expose the whole mess
+ */
+ REGION_COPY( pScreen, pSavedRegion, newSaved);
+ REGION_TRANSLATE( pScreen, newSaved,
+ pWin->drawable.x, pWin->drawable.y);
+
+ miResizeBackingStore (pWin, 0, 0, FALSE);
+ (void) miBSClearBackingStore (pWin, 0, 0, 0, 0, FALSE);
+ }
+
+ return newSaved;
+}
+
+/*
+ * Inform the backing store layer that you are about to validate
+ * a gc with a window, and that subsequent output to the window
+ * is (or is not) guaranteed to be already clipped to the visible
+ * regions of the window.
+ */
+
+static void
+miBSDrawGuarantee (pWin, pGC, guarantee)
+ WindowPtr pWin;
+ GCPtr pGC;
+ int guarantee;
+{
+ miBSGCPtr pPriv;
+
+ if (pWin->backStorage)
+ {
+ pPriv = (miBSGCPtr)pGC->devPrivates[miBSGCIndex].ptr;
+ if (!pPriv)
+ (void) miBSCreateGCPrivate (pGC);
+ pPriv = (miBSGCPtr)pGC->devPrivates[miBSGCIndex].ptr;
+ if (pPriv)
+ {
+ /*
+ * XXX KLUDGE ALERT
+ *
+ * when the GC is Cheap pPriv will point
+ * at some device's gc func structure. guarantee
+ * will point at the ChangeGC entry of that struct
+ * and will never match a valid guarantee value.
+ */
+ switch (pPriv->guarantee)
+ {
+ case GuaranteeNothing:
+ case GuaranteeVisBack:
+ pPriv->guarantee = guarantee;
+ break;
+ }
+ }
+ }
+}
+
+#define noBackingCopy (GCGraphicsExposures|GCClipXOrigin|GCClipYOrigin| \
+ GCClipMask|GCSubwindowMode| \
+ GCTileStipXOrigin|GCTileStipYOrigin)
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSValidateGC --
+ * Wrapper around output-library's ValidateGC routine
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ *
+ * Notes:
+ * The idea here is to perform several functions:
+ * - All the output calls must be intercepted and routed to
+ * backing-store as necessary.
+ * - pGC in the window's devBackingStore must be set up with the
+ * clip list appropriate for writing to pBackingPixmap (i.e.
+ * the inverse of the window's clipList intersected with the
+ * clientClip of the GC). Since the destination for this GC is
+ * a pixmap, it is sufficient to set the clip list as its
+ * clientClip.
+ *-----------------------------------------------------------------------
+ */
+
+static void
+miBSValidateGC (pGC, stateChanges, pDrawable)
+ GCPtr pGC;
+ unsigned long stateChanges;
+ DrawablePtr pDrawable;
+{
+ GCPtr pBackingGC;
+ miBSWindowPtr pWindowPriv = NULL;
+ miBSGCPtr pPriv;
+ WindowPtr pWin;
+ int lift_functions;
+ RegionPtr backingCompositeClip = NULL;
+
+ if (pDrawable->type != DRAWABLE_PIXMAP)
+ {
+ pWin = (WindowPtr) pDrawable;
+ pWindowPriv = (miBSWindowPtr) pWin->backStorage;
+ lift_functions = (pWindowPriv == (miBSWindowPtr) NULL);
+ }
+ else
+ {
+ pWin = (WindowPtr) NULL;
+ lift_functions = TRUE;
+ }
+
+ pPriv = (miBSGCPtr)pGC->devPrivates[miBSGCIndex].ptr;
+
+ FUNC_PROLOGUE (pGC, pPriv);
+
+ (*pGC->funcs->ValidateGC) (pGC, stateChanges, pDrawable);
+
+ /*
+ * rewrap funcs and ops as Validate may have changed them
+ */
+
+ pPriv->wrapFuncs = pGC->funcs;
+ pPriv->wrapOps = pGC->ops;
+
+ if (!lift_functions && ((pPriv->guarantee == GuaranteeVisBack) ||
+ (pWindowPriv->status == StatusNoPixmap) ||
+ (pWindowPriv->status == StatusBadAlloc)))
+ lift_functions = TRUE;
+
+ /*
+ * check to see if a new backingCompositeClip region must
+ * be generated
+ */
+
+ if (!lift_functions &&
+ ((pDrawable->serialNumber != pPriv->serialNumber) ||
+ (stateChanges&(GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode))))
+ {
+ if (REGION_NOTEMPTY(pGC->pScreen, &pWindowPriv->SavedRegion))
+ {
+ backingCompositeClip = REGION_CREATE(pGC->pScreen, NULL, 1);
+ if ((pGC->clientClipType == CT_NONE) ||
+ (pGC->clientClipType == CT_PIXMAP))
+ {
+ REGION_COPY(pGC->pScreen, backingCompositeClip,
+ &pWindowPriv->SavedRegion);
+ }
+ else
+ {
+ /*
+ * Make a new copy of the client clip, translated to
+ * its proper origin.
+ */
+
+ REGION_COPY(pGC->pScreen, backingCompositeClip,
+ pGC->clientClip);
+ REGION_TRANSLATE(pGC->pScreen, backingCompositeClip,
+ pGC->clipOrg.x,
+ pGC->clipOrg.y);
+ REGION_INTERSECT(pGC->pScreen, backingCompositeClip,
+ backingCompositeClip,
+ &pWindowPriv->SavedRegion);
+ }
+ if (pGC->subWindowMode == IncludeInferiors)
+ {
+ RegionPtr translatedClip;
+
+ /* XXX
+ * any output in IncludeInferiors mode will not
+ * be redirected to Inferiors backing store. This
+ * can be fixed only at great cost to the shadow routines.
+ */
+ translatedClip = NotClippedByChildren (pWin);
+ REGION_TRANSLATE(pGC->pScreen, translatedClip,
+ -pDrawable->x,
+ -pDrawable->y);
+ REGION_SUBTRACT(pGC->pScreen, backingCompositeClip,
+ backingCompositeClip, translatedClip);
+ REGION_DESTROY(pGC->pScreen, translatedClip);
+ }
+ if (!REGION_NOTEMPTY(pGC->pScreen, backingCompositeClip))
+ lift_functions = TRUE;
+ }
+ else
+ {
+ lift_functions = TRUE;
+ }
+
+ /* Reset the status when drawing to an unoccluded window so that
+ * future SaveAreas will actually copy bits from the screen. Note that
+ * output to root window in IncludeInferiors mode will not cause this
+ * to change. This causes all transient graphics by the window
+ * manager to the root window to not enable backing store.
+ */
+ if (lift_functions && (pWindowPriv->status == StatusVirtual) &&
+ (pWin->parent || pGC->subWindowMode != IncludeInferiors))
+ pWindowPriv->status = StatusVDirty;
+ }
+
+ /*
+ * if no backing store has been allocated, and it's needed,
+ * create it now.
+ */
+
+ if (!lift_functions && !pWindowPriv->pBackingPixmap)
+ {
+ miCreateBSPixmap (pWin, NullBox);
+ if (!pWindowPriv->pBackingPixmap)
+ lift_functions = TRUE;
+ }
+
+ /*
+ * create the backing GC if needed, lift functions
+ * if the creation fails
+ */
+
+ if (!lift_functions && !pPriv->pBackingGC)
+ {
+ int status;
+ XID noexpose = xFalse;
+
+ /* We never want ops with the backingGC to generate GraphicsExpose */
+ pBackingGC = CreateGC ((DrawablePtr)pWindowPriv->pBackingPixmap,
+ GCGraphicsExposures, &noexpose, &status);
+ if (status != Success)
+ lift_functions = TRUE;
+ else
+ pPriv->pBackingGC = pBackingGC;
+ }
+
+ pBackingGC = pPriv->pBackingGC;
+
+ pPriv->stateChanges |= stateChanges;
+
+ if (lift_functions)
+ {
+ if (backingCompositeClip)
+ REGION_DESTROY( pGC->pScreen, backingCompositeClip);
+
+ /* unwrap the GC again */
+ miBSDestroyGCPrivate (pGC);
+
+ return;
+ }
+
+ /*
+ * the rest of this function gets the pBackingGC
+ * into shape for possible draws
+ */
+
+ pPriv->stateChanges &= ~noBackingCopy;
+ if (pPriv->stateChanges)
+ CopyGC(pGC, pBackingGC, pPriv->stateChanges);
+ if ((pGC->patOrg.x - pWindowPriv->x) != pBackingGC->patOrg.x ||
+ (pGC->patOrg.y - pWindowPriv->y) != pBackingGC->patOrg.y)
+ {
+ XID vals[2];
+ vals[0] = pGC->patOrg.x - pWindowPriv->x;
+ vals[1] = pGC->patOrg.y - pWindowPriv->y;
+ DoChangeGC(pBackingGC, GCTileStipXOrigin|GCTileStipYOrigin, vals, 0);
+ }
+ pPriv->stateChanges = 0;
+
+ if (backingCompositeClip)
+ {
+ XID vals[2];
+
+ if (pGC->clientClipType == CT_PIXMAP)
+ {
+ (*pBackingGC->funcs->CopyClip)(pBackingGC, pGC);
+ REGION_TRANSLATE(pGC->pScreen, backingCompositeClip,
+ -pGC->clipOrg.x, -pGC->clipOrg.y);
+ vals[0] = pGC->clipOrg.x - pWindowPriv->x;
+ vals[1] = pGC->clipOrg.y - pWindowPriv->y;
+ DoChangeGC(pBackingGC, GCClipXOrigin|GCClipYOrigin, vals, 0);
+ (* pGC->pScreen->BackingStoreFuncs.SetClipmaskRgn)
+ (pBackingGC, backingCompositeClip);
+ REGION_DESTROY( pGC->pScreen, backingCompositeClip);
+ }
+ else
+ {
+ vals[0] = -pWindowPriv->x;
+ vals[1] = -pWindowPriv->y;
+ DoChangeGC(pBackingGC, GCClipXOrigin|GCClipYOrigin, vals, 0);
+ (*pBackingGC->funcs->ChangeClip) (pBackingGC, CT_REGION, backingCompositeClip, 0);
+ }
+ pPriv->serialNumber = pDrawable->serialNumber;
+ }
+
+ if (pWindowPriv->pBackingPixmap->drawable.serialNumber
+ != pBackingGC->serialNumber)
+ {
+ ValidateGC((DrawablePtr)pWindowPriv->pBackingPixmap, pBackingGC);
+ }
+
+ if (pBackingGC->clientClip == 0)
+ ErrorF ("backing store clip list nil");
+
+ FUNC_EPILOGUE (pGC, pPriv);
+}
+
+static void
+miBSChangeGC (pGC, mask)
+ GCPtr pGC;
+ unsigned long mask;
+{
+ miBSGCPtr pPriv = (miBSGCPtr) (pGC)->devPrivates[miBSGCIndex].ptr;
+
+ FUNC_PROLOGUE (pGC, pPriv);
+
+ (*pGC->funcs->ChangeGC) (pGC, mask);
+
+ FUNC_EPILOGUE (pGC, pPriv);
+}
+
+static void
+miBSCopyGC (pGCSrc, mask, pGCDst)
+ GCPtr pGCSrc, pGCDst;
+ unsigned long mask;
+{
+ miBSGCPtr pPriv = (miBSGCPtr) (pGCDst)->devPrivates[miBSGCIndex].ptr;
+
+ FUNC_PROLOGUE (pGCDst, pPriv);
+
+ (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
+
+ FUNC_EPILOGUE (pGCDst, pPriv);
+}
+
+static void
+miBSDestroyGC (pGC)
+ GCPtr pGC;
+{
+ miBSGCPtr pPriv = (miBSGCPtr) (pGC)->devPrivates[miBSGCIndex].ptr;
+
+ FUNC_PROLOGUE (pGC, pPriv);
+
+ if (pPriv->pBackingGC)
+ FreeGC(pPriv->pBackingGC, (GContext)0);
+
+ (*pGC->funcs->DestroyGC) (pGC);
+
+ FUNC_EPILOGUE (pGC, pPriv);
+
+ xfree(pPriv);
+}
+
+static void
+miBSChangeClip(pGC, type, pvalue, nrects)
+ GCPtr pGC;
+ int type;
+ pointer pvalue;
+ int nrects;
+{
+ miBSGCPtr pPriv = (miBSGCPtr) (pGC)->devPrivates[miBSGCIndex].ptr;
+
+ FUNC_PROLOGUE (pGC, pPriv);
+
+ (* pGC->funcs->ChangeClip)(pGC, type, pvalue, nrects);
+
+ FUNC_EPILOGUE (pGC, pPriv);
+}
+
+static void
+miBSCopyClip(pgcDst, pgcSrc)
+ GCPtr pgcDst, pgcSrc;
+{
+ miBSGCPtr pPriv = (miBSGCPtr) (pgcDst)->devPrivates[miBSGCIndex].ptr;
+
+ FUNC_PROLOGUE (pgcDst, pPriv);
+
+ (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
+
+ FUNC_EPILOGUE (pgcDst, pPriv);
+}
+
+static void
+miBSDestroyClip(pGC)
+ GCPtr pGC;
+{
+ miBSGCPtr pPriv = (miBSGCPtr) (pGC)->devPrivates[miBSGCIndex].ptr;
+
+ FUNC_PROLOGUE (pGC, pPriv);
+
+ (* pGC->funcs->DestroyClip)(pGC);
+
+ FUNC_EPILOGUE (pGC, pPriv);
+}
+
+static void
+miDestroyBSPixmap (pWin)
+ WindowPtr pWin;
+{
+ miBSWindowPtr pBackingStore;
+ ScreenPtr pScreen;
+
+ pScreen = pWin->drawable.pScreen;
+ pBackingStore = (miBSWindowPtr) pWin->backStorage;
+ if (pBackingStore->pBackingPixmap)
+ (* pScreen->DestroyPixmap)(pBackingStore->pBackingPixmap);
+ pBackingStore->pBackingPixmap = NullPixmap;
+ pBackingStore->x = 0;
+ pBackingStore->y = 0;
+ if (pBackingStore->backgroundState == BackgroundPixmap)
+ (* pScreen->DestroyPixmap)(pBackingStore->background.pixmap);
+ pBackingStore->backgroundState = None;
+ pBackingStore->status = StatusNoPixmap;
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+}
+
+static void
+miTileVirtualBS (pWin)
+ WindowPtr pWin;
+{
+ miBSWindowPtr pBackingStore;
+
+ pBackingStore = (miBSWindowPtr) pWin->backStorage;
+ if (pBackingStore->backgroundState == BackgroundPixmap)
+ (* pWin->drawable.pScreen->DestroyPixmap)
+ (pBackingStore->background.pixmap);
+ pBackingStore->backgroundState = pWin->backgroundState;
+ pBackingStore->background = pWin->background;
+ if (pBackingStore->backgroundState == BackgroundPixmap)
+ pBackingStore->background.pixmap->refcnt++;
+
+ if (pBackingStore->status != StatusVDirty)
+ pBackingStore->status = StatusVirtual;
+
+ /*
+ * punt parent relative tiles and do it now
+ */
+ if (pBackingStore->backgroundState == ParentRelative)
+ miCreateBSPixmap (pWin, NullBox);
+}
+
+#ifdef DEBUG
+static int BSAllocationsFailed = 0;
+#define FAILEDSIZE 32
+static struct { int w, h; } failedRecord[FAILEDSIZE];
+static int failedIndex;
+#endif
+
+static void
+miCreateBSPixmap (pWin, pExtents)
+ WindowPtr pWin;
+ BoxPtr pExtents;
+{
+ miBSWindowPtr pBackingStore;
+ ScreenPtr pScreen;
+ PixUnion background;
+ char backgroundState = 0;
+ BoxPtr extents;
+ Bool backSet;
+
+ pScreen = pWin->drawable.pScreen;
+ pBackingStore = (miBSWindowPtr) pWin->backStorage;
+ if (pBackingStore->status == StatusBadAlloc)
+ return;
+ backSet = ((pBackingStore->status == StatusVirtual) ||
+ (pBackingStore->status == StatusVDirty));
+
+ extents = REGION_EXTENTS( pScreen, &pBackingStore->SavedRegion);
+
+ if (!pBackingStore->pBackingPixmap &&
+ extents->x2 != extents->x1 &&
+ extents->y2 != extents->y1)
+ {
+ /* the policy here could be more sophisticated */
+ pBackingStore->x = extents->x1;
+ pBackingStore->y = extents->y1;
+ pBackingStore->pBackingPixmap =
+ (PixmapPtr)(* pScreen->CreatePixmap)
+ (pScreen,
+ extents->x2 - extents->x1,
+ extents->y2 - extents->y1,
+ pWin->drawable.depth);
+ }
+ if (!pBackingStore->pBackingPixmap)
+ {
+#ifdef DEBUG
+ BSAllocationsFailed++;
+ /*
+ * record failed allocations
+ */
+ failedRecord[failedIndex].w = pWin->drawable.width;
+ failedRecord[failedIndex].h = pWin->drawable.height;
+ failedIndex++;
+ if (failedIndex == FAILEDSIZE)
+ failedIndex = 0;
+#endif
+#ifdef BSEAGER
+ pBackingStore->status = StatusNoPixmap;
+#else
+ pBackingStore->status = StatusBadAlloc;
+#endif
+ return;
+ }
+
+ pBackingStore->status = StatusContents;
+
+ if (backSet)
+ {
+ backgroundState = pWin->backgroundState;
+ background = pWin->background;
+
+ pWin->backgroundState = pBackingStore->backgroundState;
+ pWin->background = pBackingStore->background;
+ if (pWin->backgroundState == BackgroundPixmap)
+ pWin->background.pixmap->refcnt++;
+ }
+
+ if (!pExtents)
+ pExtents = extents;
+
+ if (pExtents->y1 != pExtents->y2)
+ {
+ RegionPtr exposed;
+
+ exposed = miBSClearBackingStore(pWin,
+ pExtents->x1, pExtents->y1,
+ pExtents->x2 - pExtents->x1,
+ pExtents->y2 - pExtents->y1,
+ !backSet);
+ if (exposed)
+ {
+ miSendExposures(pWin, exposed, pWin->drawable.x, pWin->drawable.y);
+ REGION_DESTROY( pScreen, exposed);
+ }
+ }
+
+ if (backSet)
+ {
+ if (pWin->backgroundState == BackgroundPixmap)
+ (* pScreen->DestroyPixmap) (pWin->background.pixmap);
+ pWin->backgroundState = backgroundState;
+ pWin->background = background;
+ if (pBackingStore->backgroundState == BackgroundPixmap)
+ (* pScreen->DestroyPixmap) (pBackingStore->background.pixmap);
+ pBackingStore->backgroundState = None;
+ }
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miBSExposeCopy --
+ * Handle the restoration of areas exposed by graphics operations.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * prgnExposed has the areas exposed from backing-store removed
+ * from it.
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miBSExposeCopy (pSrc, pDst, pGC, prgnExposed, srcx, srcy, dstx, dsty, plane)
+ WindowPtr pSrc;
+ DrawablePtr pDst;
+ GCPtr pGC;
+ RegionPtr prgnExposed;
+ int srcx, srcy;
+ int dstx, dsty;
+ unsigned long plane;
+{
+ RegionRec tempRgn;
+ miBSWindowPtr pBackingStore;
+ CopyPlaneProcPtr copyProc;
+ GCPtr pScratchGC;
+ register BoxPtr pBox;
+ register int i;
+ register int dx, dy;
+ BITS32 gcMask;
+
+ if (!REGION_NOTEMPTY(pGC->pScreen, prgnExposed))
+ return;
+ pBackingStore = (miBSWindowPtr)pSrc->backStorage;
+
+ if ((pBackingStore->status == StatusNoPixmap) ||
+ (pBackingStore->status == StatusBadAlloc))
+ return;
+
+ REGION_NULL( pGC->pScreen, &tempRgn);
+ REGION_INTERSECT( pGC->pScreen, &tempRgn, prgnExposed,
+ &pBackingStore->SavedRegion);
+ REGION_SUBTRACT( pGC->pScreen, prgnExposed, prgnExposed, &tempRgn);
+
+ if (plane != 0) {
+ copyProc = pGC->ops->CopyPlane;
+ } else {
+ copyProc = (CopyPlaneProcPtr)pGC->ops->CopyArea;
+ }
+
+ dx = dstx - srcx;
+ dy = dsty - srcy;
+
+ switch (pBackingStore->status) {
+ case StatusVirtual:
+ case StatusVDirty:
+ pScratchGC = GetScratchGC (pDst->depth, pDst->pScreen);
+ if (pScratchGC)
+ {
+ gcMask = 0;
+ if (pGC->alu != pScratchGC->alu)
+ gcMask = GCFunction;
+ if (pGC->planemask != pScratchGC->planemask)
+ gcMask |= GCPlaneMask;
+ if (gcMask)
+ CopyGC (pGC, pScratchGC, gcMask);
+ miBSFillVirtualBits (pDst, pScratchGC, &tempRgn, dx, dy,
+ (int) pBackingStore->backgroundState,
+ pBackingStore->background,
+ ~0L);
+ FreeScratchGC (pScratchGC);
+ }
+ break;
+ case StatusContents:
+ for (i = REGION_NUM_RECTS(&tempRgn), pBox = REGION_RECTS(&tempRgn);
+ --i >= 0;
+ pBox++)
+ {
+ (* copyProc) (&(pBackingStore->pBackingPixmap->drawable), pDst, pGC,
+ pBox->x1 - pBackingStore->x,
+ pBox->y1 - pBackingStore->y,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
+ pBox->x1 + dx, pBox->y1 + dy, plane);
+ }
+ break;
+ }
+ REGION_UNINIT( pGC->pScreen, &tempRgn);
+}
diff --git a/nx-X11/programs/Xserver/mi/mibstore.h b/nx-X11/programs/Xserver/mi/mibstore.h
new file mode 100644
index 000000000..fb58975c6
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mibstore.h
@@ -0,0 +1,30 @@
+/*-
+ * mibstore.h --
+ * Header file for users of the MI backing-store scheme.
+ *
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ *
+ * "$Xorg: mibstore.h,v 1.3 2000/08/17 19:53:37 cpqbld Exp $
+ */
+
+
+/* $XFree86: xc/programs/Xserver/mi/mibstore.h,v 1.4 2001/01/17 22:37:06 dawes Exp $ */
+
+#ifndef _MIBSTORE_H
+#define _MIBSTORE_H
+
+#include "screenint.h"
+
+extern void miInitializeBackingStore(
+ ScreenPtr /*pScreen*/
+);
+
+#endif /* _MIBSTORE_H */
diff --git a/nx-X11/programs/Xserver/mi/mibstorest.h b/nx-X11/programs/Xserver/mi/mibstorest.h
new file mode 100644
index 000000000..787b9d4f4
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mibstorest.h
@@ -0,0 +1,93 @@
+/*
+ * mibstorest.h
+ *
+ * internal structure definitions for mi backing store
+ */
+
+/* $Xorg: mibstorest.h,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+
+/* $XFree86: xc/programs/Xserver/mi/mibstorest.h,v 1.4 2001/01/17 22:37:06 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "mibstore.h"
+#include "regionstr.h"
+
+/*
+ * One of these structures is allocated per GC used with a backing-store
+ * drawable.
+ */
+
+typedef struct {
+ GCPtr pBackingGC; /* Copy of the GC but with graphicsExposures
+ * set FALSE and the clientClip set to
+ * clip output to the valid regions of the
+ * backing pixmap. */
+ int guarantee; /* GuaranteeNothing, etc. */
+ unsigned long serialNumber; /* clientClip computed time */
+ unsigned long stateChanges; /* changes in parent gc since last copy */
+ GCOps *wrapOps; /* wrapped ops */
+ GCFuncs *wrapFuncs; /* wrapped funcs */
+} miBSGCRec, *miBSGCPtr;
+
+/*
+ * one of these structures is allocated per Window with backing store
+ */
+
+typedef struct {
+ PixmapPtr pBackingPixmap; /* Pixmap for saved areas */
+ short x; /* origin of pixmap relative to window */
+ short y;
+ RegionRec SavedRegion; /* Valid area in pBackingPixmap */
+ char viewable; /* Tracks pWin->viewable so SavedRegion may
+ * be initialized correctly when the window
+ * is first mapped */
+ char status; /* StatusNoPixmap, etc. */
+ char backgroundState; /* background type */
+ PixUnion background; /* background pattern */
+} miBSWindowRec, *miBSWindowPtr;
+
+#define StatusNoPixmap 1 /* pixmap has not been created */
+#define StatusVirtual 2 /* pixmap is virtual, tiled with background */
+#define StatusVDirty 3 /* pixmap is virtual, visiblt has contents */
+#define StatusBadAlloc 4 /* pixmap create failed, do not try again */
+#define StatusContents 5 /* pixmap is created, has valid contents */
+
+typedef struct {
+ /*
+ * screen func wrappers
+ */
+ CloseScreenProcPtr CloseScreen;
+ GetImageProcPtr GetImage;
+ GetSpansProcPtr GetSpans;
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+ CreateGCProcPtr CreateGC;
+ DestroyWindowProcPtr DestroyWindow;
+} miBSScreenRec, *miBSScreenPtr;
diff --git a/nx-X11/programs/Xserver/mi/miclipn.c b/nx-X11/programs/Xserver/mi/miclipn.c
new file mode 100644
index 000000000..14ff0d69a
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/miclipn.c
@@ -0,0 +1,84 @@
+/* $Xorg: miclipn.c,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ */
+/*
+
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/mi/miclipn.c,v 1.3 2001/08/06 21:46:04 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "mi.h"
+
+static void (*clipNotify)(WindowPtr,int,int) = 0;
+static void (*ClipNotifies[MAXSCREENS])(WindowPtr,int,int);
+
+static void
+miClipNotifyWrapper(
+ WindowPtr pWin,
+ int dx,
+ int dy )
+{
+ if (clipNotify)
+ (*clipNotify)(pWin, dx, dy);
+ if (ClipNotifies[pWin->drawable.pScreen->myNum])
+ (*ClipNotifies[pWin->drawable.pScreen->myNum])(pWin, dx, dy);
+}
+
+/*
+ * miClipNotify --
+ * Hook to let DDX request notification when the clipList of
+ * a window is recomputed on any screen. For R4 compatibility;
+ * better if you wrap the ClipNotify screen proc yourself.
+ */
+
+static unsigned long clipGeneration = 0;
+
+void
+miClipNotify (
+ void (*func)(
+ WindowPtr /* pWin */,
+ int /* dx */,
+ int /* dy */
+ ) )
+{
+ int i;
+
+ clipNotify = func;
+ if (clipGeneration != serverGeneration)
+ {
+ clipGeneration = serverGeneration;
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ ClipNotifies[i] = screenInfo.screens[i]->ClipNotify;
+ screenInfo.screens[i]->ClipNotify = miClipNotifyWrapper;
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/mi/micmap.c b/nx-X11/programs/Xserver/mi/micmap.c
new file mode 100644
index 000000000..98f3e521d
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/micmap.c
@@ -0,0 +1,697 @@
+/* $XConsortium: cfbcmap.c,v 4.19 94/04/17 20:28:46 dpw Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/mi/micmap.c,v 1.10 2000/09/20 00:09:14 keithp Exp $ */
+
+/*
+ * This is based on cfbcmap.c. The functions here are useful independently
+ * of cfb, which is the reason for including them here. How "mi" these
+ * are may be debatable.
+ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "colormapst.h"
+#include "resource.h"
+#include "globals.h"
+#include "micmap.h"
+
+ColormapPtr miInstalledMaps[MAXSCREENS];
+
+static Bool miDoInitVisuals(VisualPtr *visualp, DepthPtr *depthp, int *nvisualp,
+ int *ndepthp, int *rootDepthp, VisualID *defaultVisp,
+ unsigned long sizes, int bitsPerRGB, int preferredVis);
+
+miInitVisualsProcPtr miInitVisualsProc = miDoInitVisuals;
+
+int
+miListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
+{
+ if (miInstalledMaps[pScreen->myNum]) {
+ *pmaps = miInstalledMaps[pScreen->myNum]->mid;
+ return (1);
+ }
+ return 0;
+}
+
+void
+miInstallColormap(ColormapPtr pmap)
+{
+ int index = pmap->pScreen->myNum;
+ ColormapPtr oldpmap = miInstalledMaps[index];
+
+ if(pmap != oldpmap)
+ {
+ /* Uninstall pInstalledMap. No hardware changes required, just
+ * notify all interested parties. */
+ if(oldpmap != (ColormapPtr)None)
+ WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid);
+ /* Install pmap */
+ miInstalledMaps[index] = pmap;
+ WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid);
+
+ }
+}
+
+void
+miUninstallColormap(ColormapPtr pmap)
+{
+ int index = pmap->pScreen->myNum;
+ ColormapPtr curpmap = miInstalledMaps[index];
+
+ if(pmap == curpmap)
+ {
+ if (pmap->mid != pmap->pScreen->defColormap)
+ {
+ curpmap = (ColormapPtr) LookupIDByType(pmap->pScreen->defColormap,
+ RT_COLORMAP);
+ (*pmap->pScreen->InstallColormap)(curpmap);
+ }
+ }
+}
+
+void
+miResolveColor(unsigned short *pred, unsigned short *pgreen,
+ unsigned short *pblue, VisualPtr pVisual)
+{
+ int shift = 16 - pVisual->bitsPerRGBValue;
+ unsigned lim = (1 << pVisual->bitsPerRGBValue) - 1;
+
+ if ((pVisual->class | DynamicClass) == GrayScale)
+ {
+ /* rescale to gray then rgb bits */
+ *pred = (30L * *pred + 59L * *pgreen + 11L * *pblue) / 100;
+ *pblue = *pgreen = *pred = ((*pred >> shift) * 65535) / lim;
+ }
+ else
+ {
+ /* rescale to rgb bits */
+ *pred = ((*pred >> shift) * 65535) / lim;
+ *pgreen = ((*pgreen >> shift) * 65535) / lim;
+ *pblue = ((*pblue >> shift) * 65535) / lim;
+ }
+}
+
+Bool
+miInitializeColormap(ColormapPtr pmap)
+{
+ register unsigned i;
+ register VisualPtr pVisual;
+ unsigned lim, maxent, shift;
+
+ pVisual = pmap->pVisual;
+ lim = (1 << pVisual->bitsPerRGBValue) - 1;
+ shift = 16 - pVisual->bitsPerRGBValue;
+ maxent = pVisual->ColormapEntries - 1;
+ if (pVisual->class == TrueColor)
+ {
+ unsigned limr, limg, limb;
+
+ limr = pVisual->redMask >> pVisual->offsetRed;
+ limg = pVisual->greenMask >> pVisual->offsetGreen;
+ limb = pVisual->blueMask >> pVisual->offsetBlue;
+ for(i = 0; i <= maxent; i++)
+ {
+ /* rescale to [0..65535] then rgb bits */
+ pmap->red[i].co.local.red =
+ ((((i * 65535) / limr) >> shift) * 65535) / lim;
+ pmap->green[i].co.local.green =
+ ((((i * 65535) / limg) >> shift) * 65535) / lim;
+ pmap->blue[i].co.local.blue =
+ ((((i * 65535) / limb) >> shift) * 65535) / lim;
+ }
+ }
+ else if (pVisual->class == StaticColor)
+ {
+ unsigned limr, limg, limb;
+
+ limr = pVisual->redMask >> pVisual->offsetRed;
+ limg = pVisual->greenMask >> pVisual->offsetGreen;
+ limb = pVisual->blueMask >> pVisual->offsetBlue;
+ for(i = 0; i <= maxent; i++)
+ {
+ /* rescale to [0..65535] then rgb bits */
+ pmap->red[i].co.local.red =
+ ((((((i & pVisual->redMask) >> pVisual->offsetRed)
+ * 65535) / limr) >> shift) * 65535) / lim;
+ pmap->red[i].co.local.green =
+ ((((((i & pVisual->greenMask) >> pVisual->offsetGreen)
+ * 65535) / limg) >> shift) * 65535) / lim;
+ pmap->red[i].co.local.blue =
+ ((((((i & pVisual->blueMask) >> pVisual->offsetBlue)
+ * 65535) / limb) >> shift) * 65535) / lim;
+ }
+ }
+ else if (pVisual->class == StaticGray)
+ {
+ for(i = 0; i <= maxent; i++)
+ {
+ /* rescale to [0..65535] then rgb bits */
+ pmap->red[i].co.local.red = ((((i * 65535) / maxent) >> shift)
+ * 65535) / lim;
+ pmap->red[i].co.local.green = pmap->red[i].co.local.red;
+ pmap->red[i].co.local.blue = pmap->red[i].co.local.red;
+ }
+ }
+ return TRUE;
+}
+
+/* When simulating DirectColor on PseudoColor hardware, multiple
+ entries of the colormap must be updated
+ */
+
+#define AddElement(mask) { \
+ pixel = red | green | blue; \
+ for (i = 0; i < nresult; i++) \
+ if (outdefs[i].pixel == pixel) \
+ break; \
+ if (i == nresult) \
+ { \
+ nresult++; \
+ outdefs[i].pixel = pixel; \
+ outdefs[i].flags = 0; \
+ } \
+ outdefs[i].flags |= (mask); \
+ outdefs[i].red = pmap->red[red >> pVisual->offsetRed].co.local.red; \
+ outdefs[i].green = pmap->green[green >> pVisual->offsetGreen].co.local.green; \
+ outdefs[i].blue = pmap->blue[blue >> pVisual->offsetBlue].co.local.blue; \
+}
+
+int
+miExpandDirectColors(ColormapPtr pmap, int ndef, xColorItem *indefs,
+ xColorItem *outdefs)
+{
+ register int red, green, blue;
+ int maxred, maxgreen, maxblue;
+ int stepred, stepgreen, stepblue;
+ VisualPtr pVisual;
+ register int pixel;
+ register int nresult;
+ register int i;
+
+ pVisual = pmap->pVisual;
+
+ stepred = 1 << pVisual->offsetRed;
+ stepgreen = 1 << pVisual->offsetGreen;
+ stepblue = 1 << pVisual->offsetBlue;
+ maxred = pVisual->redMask;
+ maxgreen = pVisual->greenMask;
+ maxblue = pVisual->blueMask;
+ nresult = 0;
+ for (;ndef--; indefs++)
+ {
+ if (indefs->flags & DoRed)
+ {
+ red = indefs->pixel & pVisual->redMask;
+ for (green = 0; green <= maxgreen; green += stepgreen)
+ {
+ for (blue = 0; blue <= maxblue; blue += stepblue)
+ {
+ AddElement (DoRed)
+ }
+ }
+ }
+ if (indefs->flags & DoGreen)
+ {
+ green = indefs->pixel & pVisual->greenMask;
+ for (red = 0; red <= maxred; red += stepred)
+ {
+ for (blue = 0; blue <= maxblue; blue += stepblue)
+ {
+ AddElement (DoGreen)
+ }
+ }
+ }
+ if (indefs->flags & DoBlue)
+ {
+ blue = indefs->pixel & pVisual->blueMask;
+ for (red = 0; red <= maxred; red += stepred)
+ {
+ for (green = 0; green <= maxgreen; green += stepgreen)
+ {
+ AddElement (DoBlue)
+ }
+ }
+ }
+ }
+ return nresult;
+}
+
+Bool
+miCreateDefColormap(ScreenPtr pScreen)
+{
+/*
+ * In the following sources PC X server vendors may want to delete
+ * "_not_tog" from "#ifdef WIN32_not_tog"
+ */
+#ifdef WIN32_not_tog
+ /*
+ * these are the MS-Windows desktop colors, adjusted for X's 16-bit
+ * color specifications.
+ */
+ static xColorItem citems[] = {
+ { 0, 0, 0, 0, 0, 0 },
+ { 1, 0x8000, 0, 0, 0, 0 },
+ { 2, 0, 0x8000, 0, 0, 0 },
+ { 3, 0x8000, 0x8000, 0, 0, 0 },
+ { 4, 0, 0, 0x8000, 0, 0 },
+ { 5, 0x8000, 0, 0x8000, 0, 0 },
+ { 6, 0, 0x8000, 0x8000, 0, 0 },
+ { 7, 0xc000, 0xc000, 0xc000, 0, 0 },
+ { 8, 0xc000, 0xdc00, 0xc000, 0, 0 },
+ { 9, 0xa600, 0xca00, 0xf000, 0, 0 },
+ { 246, 0xff00, 0xfb00, 0xf000, 0, 0 },
+ { 247, 0xa000, 0xa000, 0xa400, 0, 0 },
+ { 248, 0x8000, 0x8000, 0x8000, 0, 0 },
+ { 249, 0xff00, 0, 0, 0, 0 },
+ { 250, 0, 0xff00, 0, 0, 0 },
+ { 251, 0xff00, 0xff00, 0, 0, 0 },
+ { 252, 0, 0, 0xff00, 0, 0 },
+ { 253, 0xff00, 0, 0xff00, 0, 0 },
+ { 254, 0, 0xff00, 0xff00, 0, 0 },
+ { 255, 0xff00, 0xff00, 0xff00, 0, 0 }
+ };
+#define NUM_DESKTOP_COLORS sizeof citems / sizeof citems[0]
+ int i;
+#else
+ unsigned short zero = 0, ones = 0xFFFF;
+#endif
+ Pixel wp, bp;
+ VisualPtr pVisual;
+ ColormapPtr cmap;
+ int alloctype;
+
+ for (pVisual = pScreen->visuals;
+ pVisual->vid != pScreen->rootVisual;
+ pVisual++)
+ ;
+
+ if (pScreen->rootDepth == 1 || (pVisual->class & DynamicClass))
+ alloctype = AllocNone;
+ else
+ alloctype = AllocAll;
+
+ if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &cmap,
+ alloctype, 0) != Success)
+ return FALSE;
+
+ if (pScreen->rootDepth > 1) {
+ wp = pScreen->whitePixel;
+ bp = pScreen->blackPixel;
+#ifdef WIN32_not_tog
+ for (i = 0; i < NUM_DESKTOP_COLORS; i++) {
+ if (AllocColor (cmap,
+ &citems[i].red, &citems[i].green, &citems[i].blue,
+ &citems[i].pixel, 0) != Success)
+ return FALSE;
+ }
+#else
+ if ((AllocColor(cmap, &ones, &ones, &ones, &wp, 0) !=
+ Success) ||
+ (AllocColor(cmap, &zero, &zero, &zero, &bp, 0) !=
+ Success))
+ return FALSE;
+ pScreen->whitePixel = wp;
+ pScreen->blackPixel = bp;
+#endif
+ }
+
+ (*pScreen->InstallColormap)(cmap);
+ return TRUE;
+}
+
+/*
+ * Default true color bitmasks, should be overridden by
+ * driver
+ */
+
+#define _RZ(d) ((d + 2) / 3)
+#define _RS(d) 0
+#define _RM(d) ((1 << _RZ(d)) - 1)
+#define _GZ(d) ((d - _RZ(d) + 1) / 2)
+#define _GS(d) _RZ(d)
+#define _GM(d) (((1 << _GZ(d)) - 1) << _GS(d))
+#define _BZ(d) (d - _RZ(d) - _GZ(d))
+#define _BS(d) (_RZ(d) + _GZ(d))
+#define _BM(d) (((1 << _BZ(d)) - 1) << _BS(d))
+#define _CE(d) (1 << _RZ(d))
+
+typedef struct _miVisuals {
+ struct _miVisuals *next;
+ int depth;
+ int bitsPerRGB;
+ int visuals;
+ int count;
+ int preferredCVC;
+ Pixel redMask, greenMask, blueMask;
+} miVisualsRec, *miVisualsPtr;
+
+static int miVisualPriority[] = {
+ PseudoColor, GrayScale, StaticColor, TrueColor, DirectColor, StaticGray
+};
+
+#define NUM_PRIORITY 6
+
+static miVisualsPtr miVisuals;
+
+void
+miClearVisualTypes()
+{
+ miVisualsPtr v;
+
+ while ((v = miVisuals)) {
+ miVisuals = v->next;
+ xfree(v);
+ }
+}
+
+
+Bool
+miSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB,
+ int preferredCVC,
+ Pixel redMask, Pixel greenMask, Pixel blueMask)
+{
+ miVisualsPtr new, *prev, v;
+ int count;
+
+ new = (miVisualsPtr) xalloc (sizeof *new);
+ if (!new)
+ return FALSE;
+ if (!redMask || !greenMask || !blueMask)
+ {
+ redMask = _RM(depth);
+ greenMask = _GM(depth);
+ blueMask = _BM(depth);
+ }
+ new->next = 0;
+ new->depth = depth;
+ new->visuals = visuals;
+ new->bitsPerRGB = bitsPerRGB;
+ new->preferredCVC = preferredCVC;
+ new->redMask = redMask;
+ new->greenMask = greenMask;
+ new->blueMask = blueMask;
+ count = (visuals >> 1) & 033333333333;
+ count = visuals - count - ((count >> 1) & 033333333333);
+ count = (((count + (count >> 3)) & 030707070707) % 077); /* HAKMEM 169 */
+ new->count = count;
+ for (prev = &miVisuals; (v = *prev); prev = &v->next);
+ *prev = new;
+ return TRUE;
+}
+
+Bool
+miSetVisualTypes(int depth, int visuals, int bitsPerRGB, int preferredCVC)
+{
+ return miSetVisualTypesAndMasks (depth, visuals, bitsPerRGB,
+ preferredCVC, 0, 0, 0);
+}
+
+int
+miGetDefaultVisualMask(int depth)
+{
+ if (depth > MAX_PSEUDO_DEPTH)
+ return LARGE_VISUALS;
+ else if (depth >= MIN_TRUE_DEPTH)
+ return ALL_VISUALS;
+ else if (depth == 1)
+ return StaticGrayMask;
+ else
+ return SMALL_VISUALS;
+}
+
+static Bool
+miVisualTypesSet (int depth)
+{
+ miVisualsPtr visuals;
+
+ for (visuals = miVisuals; visuals; visuals = visuals->next)
+ if (visuals->depth == depth)
+ return TRUE;
+ return FALSE;
+}
+
+Bool
+miSetPixmapDepths (void)
+{
+ int d, f;
+
+ /* Add any unlisted depths from the pixmap formats */
+ for (f = 0; f < screenInfo.numPixmapFormats; f++)
+ {
+ d = screenInfo.formats[f].depth;
+ if (!miVisualTypesSet (d))
+ {
+ if (!miSetVisualTypes (d, 0, 0, -1))
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+Bool
+miInitVisuals(VisualPtr *visualp, DepthPtr *depthp, int *nvisualp,
+ int *ndepthp, int *rootDepthp, VisualID *defaultVisp,
+ unsigned long sizes, int bitsPerRGB, int preferredVis)
+
+{
+ if (miInitVisualsProc)
+ return miInitVisualsProc(visualp, depthp, nvisualp, ndepthp,
+ rootDepthp, defaultVisp, sizes, bitsPerRGB,
+ preferredVis);
+ else
+ return FALSE;
+}
+
+/*
+ * Distance to least significant one bit
+ */
+static int
+maskShift (Pixel p)
+{
+ int s;
+
+ if (!p) return 0;
+ s = 0;
+ while (!(p & 1))
+ {
+ s++;
+ p >>= 1;
+ }
+ return s;
+}
+
+/*
+ * Given a list of formats for a screen, create a list
+ * of visuals and depths for the screen which corespond to
+ * the set which can be used with this version of cfb.
+ */
+
+static Bool
+miDoInitVisuals(VisualPtr *visualp, DepthPtr *depthp, int *nvisualp,
+ int *ndepthp, int *rootDepthp, VisualID *defaultVisp,
+ unsigned long sizes, int bitsPerRGB, int preferredVis)
+{
+ int i, j = 0, k;
+ VisualPtr visual;
+ DepthPtr depth;
+ VisualID *vid;
+ int d, b;
+ int f;
+ int ndepth, nvisual;
+ int nvtype;
+ int vtype;
+ miVisualsPtr visuals, nextVisuals;
+ int *preferredCVCs, *prefp;
+ int first_depth;
+
+ /* none specified, we'll guess from pixmap formats */
+ if (!miVisuals)
+ {
+ for (f = 0; f < screenInfo.numPixmapFormats; f++)
+ {
+ d = screenInfo.formats[f].depth;
+ b = screenInfo.formats[f].bitsPerPixel;
+ if (sizes & (1 << (b - 1)))
+ vtype = miGetDefaultVisualMask(d);
+ else
+ vtype = 0;
+ if (!miSetVisualTypes (d, vtype, bitsPerRGB, -1))
+ return FALSE;
+ }
+ }
+ nvisual = 0;
+ ndepth = 0;
+ for (visuals = miVisuals; visuals; visuals = nextVisuals)
+ {
+ nextVisuals = visuals->next;
+ ndepth++;
+ nvisual += visuals->count;
+ }
+ depth = (DepthPtr) xalloc (ndepth * sizeof (DepthRec));
+ visual = (VisualPtr) xalloc (nvisual * sizeof (VisualRec));
+ preferredCVCs = (int *)xalloc(ndepth * sizeof(int));
+ if (!depth || !visual || !preferredCVCs)
+ {
+ xfree (depth);
+ xfree (visual);
+ xfree (preferredCVCs);
+ return FALSE;
+ }
+ *depthp = depth;
+ *visualp = visual;
+ *ndepthp = ndepth;
+ *nvisualp = nvisual;
+ prefp = preferredCVCs;
+ for (visuals = miVisuals; visuals; visuals = nextVisuals)
+ {
+ nextVisuals = visuals->next;
+ d = visuals->depth;
+ vtype = visuals->visuals;
+ nvtype = visuals->count;
+ *prefp = visuals->preferredCVC;
+ prefp++;
+ vid = NULL;
+ if (nvtype)
+ {
+ vid = (VisualID *) xalloc (nvtype * sizeof (VisualID));
+ if (!vid)
+ return FALSE;
+ }
+ depth->depth = d;
+ depth->numVids = nvtype;
+ depth->vids = vid;
+ depth++;
+ for (i = 0; i < NUM_PRIORITY; i++) {
+ if (! (vtype & (1 << miVisualPriority[i])))
+ continue;
+ visual->class = miVisualPriority[i];
+ visual->bitsPerRGBValue = visuals->bitsPerRGB;
+ visual->ColormapEntries = 1 << d;
+ visual->nplanes = d;
+ visual->vid = *vid = FakeClientID (0);
+ switch (visual->class) {
+ case PseudoColor:
+ case GrayScale:
+ case StaticGray:
+ visual->redMask = 0;
+ visual->greenMask = 0;
+ visual->blueMask = 0;
+ visual->offsetRed = 0;
+ visual->offsetGreen = 0;
+ visual->offsetBlue = 0;
+ break;
+ case DirectColor:
+ case TrueColor:
+ visual->ColormapEntries = _CE(d);
+ /* fall through */
+ case StaticColor:
+ visual->redMask = visuals->redMask;
+ visual->greenMask = visuals->greenMask;
+ visual->blueMask = visuals->blueMask;
+ visual->offsetRed = maskShift (visuals->redMask);
+ visual->offsetGreen = maskShift (visuals->greenMask);
+ visual->offsetBlue = maskShift (visuals->blueMask);
+ }
+ vid++;
+ visual++;
+ }
+ xfree (visuals);
+ }
+ miVisuals = NULL;
+ visual = *visualp;
+ depth = *depthp;
+
+ /*
+ * if we did not supplyied by a preferred visual class
+ * check if there is a preferred class in one of the depth
+ * structures - if there is, we want to start looking for the
+ * default visual/depth from that depth.
+ */
+ first_depth = 0;
+ if (preferredVis < 0 && defaultColorVisualClass < 0 ) {
+ for (i = 0; i < ndepth; i++) {
+ if (preferredCVCs[i] >= 0) {
+ first_depth = i;
+ break;
+ }
+ }
+ }
+
+ for (i = first_depth; i < ndepth; i++)
+ {
+ int prefColorVisualClass = -1;
+
+ if (defaultColorVisualClass >= 0)
+ prefColorVisualClass = defaultColorVisualClass;
+ else if (preferredVis >= 0)
+ prefColorVisualClass = preferredVis;
+ else if (preferredCVCs[i] >= 0)
+ prefColorVisualClass = preferredCVCs[i];
+
+ if (*rootDepthp && *rootDepthp != depth[i].depth)
+ continue;
+
+ for (j = 0; j < depth[i].numVids; j++)
+ {
+ for (k = 0; k < nvisual; k++)
+ if (visual[k].vid == depth[i].vids[j])
+ break;
+ if (k == nvisual)
+ continue;
+ if (prefColorVisualClass < 0 ||
+ visual[k].class == prefColorVisualClass)
+ break;
+ }
+ if (j != depth[i].numVids)
+ break;
+ }
+ if (i == ndepth) {
+ i = 0;
+ j = 0;
+ }
+ *rootDepthp = depth[i].depth;
+ *defaultVisp = depth[i].vids[j];
+ xfree(preferredCVCs);
+
+ return TRUE;
+}
+
+void
+miResetInitVisuals()
+{
+ miInitVisualsProc = miDoInitVisuals;
+}
+
diff --git a/nx-X11/programs/Xserver/mi/micmap.h b/nx-X11/programs/Xserver/mi/micmap.h
new file mode 100644
index 000000000..ca2a417be
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/micmap.h
@@ -0,0 +1,65 @@
+/* $XFree86: xc/programs/Xserver/mi/micmap.h,v 1.5 1999/06/14 07:32:11 dawes Exp $ */
+
+#include "colormapst.h"
+
+#ifndef _MICMAP_H_
+#define _MICMAP_H_
+
+extern ColormapPtr miInstalledMaps[MAXSCREENS];
+
+typedef Bool (* miInitVisualsProcPtr)(VisualPtr *, DepthPtr *, int *, int *,
+ int *, VisualID *, unsigned long, int,
+ int);
+
+extern miInitVisualsProcPtr miInitVisualsProc;
+
+int miListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps);
+void miInstallColormap(ColormapPtr pmap);
+void miUninstallColormap(ColormapPtr pmap);
+
+void miResolveColor(unsigned short *, unsigned short *, unsigned short *,
+ VisualPtr);
+Bool miInitializeColormap(ColormapPtr);
+int miExpandDirectColors(ColormapPtr, int, xColorItem *, xColorItem *);
+Bool miCreateDefColormap(ScreenPtr);
+void miClearVisualTypes(void);
+Bool miSetVisualTypes(int, int, int, int);
+Bool miSetPixmapDepths(void);
+Bool miSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB,
+ int preferredCVC,
+ Pixel redMask, Pixel greenMask, Pixel blueMask);
+int miGetDefaultVisualMask(int);
+Bool miInitVisuals(VisualPtr *, DepthPtr *, int *, int *, int *, VisualID *,
+ unsigned long, int, int);
+void miResetInitVisuals(void);
+
+void miHookInitVisuals(void (**old)(miInitVisualsProcPtr *),
+ void (*new)(miInitVisualsProcPtr *));
+
+
+#define MAX_PSEUDO_DEPTH 10
+#define MIN_TRUE_DEPTH 6
+
+#define StaticGrayMask (1 << StaticGray)
+#define GrayScaleMask (1 << GrayScale)
+#define StaticColorMask (1 << StaticColor)
+#define PseudoColorMask (1 << PseudoColor)
+#define TrueColorMask (1 << TrueColor)
+#define DirectColorMask (1 << DirectColor)
+
+#define ALL_VISUALS (StaticGrayMask|\
+ GrayScaleMask|\
+ StaticColorMask|\
+ PseudoColorMask|\
+ TrueColorMask|\
+ DirectColorMask)
+
+#define LARGE_VISUALS (TrueColorMask|\
+ DirectColorMask)
+
+#define SMALL_VISUALS (StaticGrayMask|\
+ GrayScaleMask|\
+ StaticColorMask|\
+ PseudoColorMask)
+
+#endif /* _MICMAP_H_ */
diff --git a/nx-X11/programs/Xserver/mi/micoord.h b/nx-X11/programs/Xserver/mi/micoord.h
new file mode 100644
index 000000000..e4b242475
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/micoord.h
@@ -0,0 +1,71 @@
+/* $XFree86: xc/programs/Xserver/mi/micoord.h,v 1.7 2003/10/29 22:57:48 tsi Exp $ */
+/*
+ * Copyright (C) 2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ *
+ */
+
+#ifndef _MICOORD_H_
+#define _MICOORD_H_ 1
+
+#include "servermd.h"
+
+/* Macros which handle a coordinate in a single register */
+
+/*
+ * Most compilers will convert divisions by 65536 into shifts, if signed
+ * shifts exist. If your machine does arithmetic shifts and your compiler
+ * can't get it right, add to this line.
+ */
+
+/*
+ * mips compiler - what a joke - it CSEs the 65536 constant into a reg
+ * forcing as to use div instead of shift. Let's be explicit.
+ */
+
+#if defined(mips) || defined(sgi) || \
+ defined(sparc) || defined(__sparc64__) || \
+ defined(__alpha) || defined(__alpha__) || \
+ defined(__i386__) || defined(i386) || \
+ defined(__ia64__) || defined(ia64) || \
+ defined(__s390x__) || defined(__s390__) || \
+ defined(__amd64__) || defined(amd64) || defined(__amd64)
+#define GetHighWord(x) (((int) (x)) >> 16)
+#else
+#define GetHighWord(x) (((int) (x)) / 65536)
+#endif
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define intToCoord(i,x,y) (((x) = GetHighWord(i)), ((y) = (int) ((short) (i))))
+#define coordToInt(x,y) (((x) << 16) | ((y) & 0xffff))
+#define intToX(i) (GetHighWord(i))
+#define intToY(i) ((int) ((short) i))
+#else
+#define intToCoord(i,x,y) (((x) = (int) ((short) (i))), ((y) = GetHighWord(i)))
+#define coordToInt(x,y) (((y) << 16) | ((x) & 0xffff))
+#define intToX(i) ((int) ((short) (i)))
+#define intToY(i) (GetHighWord(i))
+#endif
+
+#endif /* _MICOORD_H_ */
diff --git a/nx-X11/programs/Xserver/mi/micursor.c b/nx-X11/programs/Xserver/mi/micursor.c
new file mode 100644
index 000000000..d499e60f5
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/micursor.c
@@ -0,0 +1,77 @@
+/* $XFree86: xc/programs/Xserver/mi/micursor.c,v 1.2 2001/05/29 22:24:06 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: micursor.c,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "scrnintstr.h"
+#include "cursor.h"
+#include "misc.h"
+#include "mi.h"
+
+extern Bool Must_have_memory;
+
+void
+miRecolorCursor( pScr, pCurs, displayed)
+ ScreenPtr pScr;
+ CursorPtr pCurs;
+ Bool displayed;
+{
+ /*
+ * This is guaranteed to correct any color-dependent state which may have
+ * been bound up in private state created by RealizeCursor
+ */
+ (* pScr->UnrealizeCursor)( pScr, pCurs);
+ Must_have_memory = TRUE; /* XXX */
+ (* pScr->RealizeCursor)( pScr, pCurs);
+ Must_have_memory = FALSE; /* XXX */
+ if ( displayed)
+ (* pScr->DisplayCursor)( pScr, pCurs);
+
+}
diff --git a/nx-X11/programs/Xserver/mi/midash.c b/nx-X11/programs/Xserver/mi/midash.c
new file mode 100644
index 000000000..5def4d9c8
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/midash.c
@@ -0,0 +1,315 @@
+/* $XFree86: xc/programs/Xserver/mi/midash.c,v 1.4 2001/12/14 20:00:21 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: midash.c,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "regionstr.h"
+#include "mistruct.h"
+#include "mifpoly.h"
+
+static miDashPtr CheckDashStorage(miDashPtr *ppseg, int nseg, int *pnsegMax);
+
+/* return a list of DashRec. there will be an extra
+entry at the end holding the last point of the polyline.
+ this means that the code that actually draws dashes can
+get a pair of points for every dash. only the point in the last
+dash record is useful; the other fields are not used.
+ nseg is the number of segments, not the number of points.
+
+example:
+
+ dash1.start
+ dash2.start
+ dash3.start
+ last-point
+
+defines a list of segments
+ (dash1.pt, dash2.pt)
+ (dash2.pt, dash3.pt)
+ (dash3.pt, last-point)
+and nseg == 3.
+
+NOTE:
+ EVEN_DASH == ~ODD_DASH
+
+NOTE ALSO:
+ miDashLines may return 0 segments, going from pt[0] to pt[0] with one dash.
+*/
+
+miDashPtr
+miDashLine(npt, ppt, nDash, pDash, offset, pnseg)
+int npt;
+DDXPointPtr ppt;
+unsigned int nDash;
+unsigned char *pDash;
+unsigned int offset;
+int *pnseg;
+{
+ DDXPointRec pt1, pt2;
+ int lenCur; /* npt used from this dash */
+ int lenMax; /* npt in this dash */
+ int iDash = 0; /* index of current dash */
+ int which; /* EVEN_DASH or ODD_DASH */
+ miDashPtr pseg; /* list of dash segments */
+ miDashPtr psegBase; /* start of list */
+ int nseg = 0; /* number of dashes so far */
+ int nsegMax = 0; /* num segs we can fit in this list */
+
+ int x, y, len;
+ int adx, ady, signdx, signdy;
+ int du, dv, e1, e2, e, base_e = 0;
+
+ lenCur = offset;
+ which = EVEN_DASH;
+ while(lenCur >= pDash[iDash])
+ {
+ lenCur -= pDash[iDash];
+ iDash++;
+ if (iDash >= nDash)
+ iDash = 0;
+ which = ~which;
+ }
+ lenMax = pDash[iDash];
+
+ psegBase = (miDashPtr)NULL;
+ pt2 = ppt[0]; /* just in case there is only one point */
+
+ while(--npt)
+ {
+ if (PtEqual(ppt[0], ppt[1]))
+ {
+ ppt++;
+ continue; /* no duplicated points in polyline */
+ }
+ pt1 = *ppt++;
+ pt2 = *ppt;
+
+ adx = pt2.x - pt1.x;
+ ady = pt2.y - pt1.y;
+ signdx = sign(adx);
+ signdy = sign(ady);
+ adx = abs(adx);
+ ady = abs(ady);
+
+ if (adx > ady)
+ {
+ du = adx;
+ dv = ady;
+ len = adx;
+ }
+ else
+ {
+ du = ady;
+ dv = adx;
+ len = ady;
+ }
+
+ e1 = dv * 2;
+ e2 = e1 - 2*du;
+ e = e1 - du;
+ x = pt1.x;
+ y = pt1.y;
+
+ nseg++;
+ pseg = CheckDashStorage(&psegBase, nseg, &nsegMax);
+ if (!pseg)
+ return (miDashPtr)NULL;
+ pseg->pt = pt1;
+ pseg->e1 = e1;
+ pseg->e2 = e2;
+ base_e = pseg->e = e;
+ pseg->which = which;
+ pseg->newLine = 1;
+
+ while (len--)
+ {
+ if (adx > ady)
+ {
+ /* X_AXIS */
+ if (((signdx > 0) && (e < 0)) ||
+ ((signdx <=0) && (e <=0))
+ )
+ {
+ e += e1;
+ }
+ else
+ {
+ y += signdy;
+ e += e2;
+ }
+ x += signdx;
+ }
+ else
+ {
+ /* Y_AXIS */
+ if (((signdx > 0) && (e < 0)) ||
+ ((signdx <=0) && (e <=0))
+ )
+ {
+ e +=e1;
+ }
+ else
+ {
+ x += signdx;
+ e += e2;
+ }
+ y += signdy;
+ }
+
+ lenCur++;
+ if (lenCur >= lenMax && (len || npt <= 1))
+ {
+ nseg++;
+ pseg = CheckDashStorage(&psegBase, nseg, &nsegMax);
+ if (!pseg)
+ return (miDashPtr)NULL;
+ pseg->pt.x = x;
+ pseg->pt.y = y;
+ pseg->e1 = e1;
+ pseg->e2 = e2;
+ pseg->e = e;
+ which = ~which;
+ pseg->which = which;
+ pseg->newLine = 0;
+
+ /* move on to next dash */
+ iDash++;
+ if (iDash >= nDash)
+ iDash = 0;
+ lenMax = pDash[iDash];
+ lenCur = 0;
+ }
+ } /* while len-- */
+ } /* while --npt */
+
+ if (lenCur == 0 && nseg != 0)
+ {
+ nseg--;
+ which = ~which;
+ }
+ *pnseg = nseg;
+ pseg = CheckDashStorage(&psegBase, nseg+1, &nsegMax);
+ if (!pseg)
+ return (miDashPtr)NULL;
+ pseg->pt = pt2;
+ pseg->e = base_e;
+ pseg->which = which;
+ pseg->newLine = 0;
+ return psegBase;
+}
+
+
+#define NSEGDELTA 16
+
+/* returns a pointer to the pseg[nseg-1], growing the storage as
+necessary. this interface seems unnecessarily cumbersome.
+
+*/
+
+static
+miDashPtr
+CheckDashStorage(
+ miDashPtr *ppseg, /* base pointer */
+ int nseg, /* number of segment we want to write to */
+ int *pnsegMax) /* size (in segments) of list so far */
+{
+ if (nseg > *pnsegMax)
+ {
+ miDashPtr newppseg;
+
+ *pnsegMax += NSEGDELTA;
+ newppseg = (miDashPtr)xrealloc(*ppseg,
+ (*pnsegMax)*sizeof(miDashRec));
+ if (!newppseg)
+ {
+ xfree(*ppseg);
+ return (miDashPtr)NULL;
+ }
+ *ppseg = newppseg;
+ }
+ return(*ppseg+(nseg-1));
+}
+
+void
+miStepDash (dist, pDashIndex, pDash, numInDashList, pDashOffset)
+ int dist; /* distance to step */
+ int *pDashIndex; /* current dash */
+ unsigned char *pDash; /* dash list */
+ int numInDashList; /* total length of dash list */
+ int *pDashOffset; /* offset into current dash */
+{
+ int dashIndex, dashOffset;
+ int totallen;
+ int i;
+
+ dashIndex = *pDashIndex;
+ dashOffset = *pDashOffset;
+ if (dist < pDash[dashIndex] - dashOffset)
+ {
+ *pDashOffset = dashOffset + dist;
+ return;
+ }
+ dist -= pDash[dashIndex] - dashOffset;
+ if (++dashIndex == numInDashList)
+ dashIndex = 0;
+ totallen = 0;
+ for (i = 0; i < numInDashList; i++)
+ totallen += pDash[i];
+ if (totallen <= dist)
+ dist = dist % totallen;
+ while (dist >= pDash[dashIndex])
+ {
+ dist -= pDash[dashIndex];
+ if (++dashIndex == numInDashList)
+ dashIndex = 0;
+ }
+ *pDashIndex = dashIndex;
+ *pDashOffset = dist;
+}
diff --git a/nx-X11/programs/Xserver/mi/midispcur.c b/nx-X11/programs/Xserver/mi/midispcur.c
new file mode 100644
index 000000000..080ac1c59
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/midispcur.c
@@ -0,0 +1,816 @@
+/*
+ * midispcur.c
+ *
+ * machine independent cursor display routines
+ */
+
+/* $Xorg: midispcur.c,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+/* $XFree86: xc/programs/Xserver/mi/midispcur.c,v 1.9 2002/12/09 04:10:57 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#define NEED_EVENTS
+# include <X11/X.h>
+# include "misc.h"
+# include "input.h"
+# include "cursorstr.h"
+# include "windowstr.h"
+# include "regionstr.h"
+# include "dixstruct.h"
+# include "scrnintstr.h"
+# include "servermd.h"
+# include "mipointer.h"
+# include "misprite.h"
+# include "gcstruct.h"
+
+#ifdef ARGB_CURSOR
+# include "picturestr.h"
+#endif
+
+/* per-screen private data */
+
+static int miDCScreenIndex;
+static unsigned long miDCGeneration = 0;
+
+static Bool miDCCloseScreen(int index, ScreenPtr pScreen);
+
+typedef struct {
+ GCPtr pSourceGC, pMaskGC;
+ GCPtr pSaveGC, pRestoreGC;
+ GCPtr pMoveGC;
+ GCPtr pPixSourceGC, pPixMaskGC;
+ CloseScreenProcPtr CloseScreen;
+ PixmapPtr pSave, pTemp;
+#ifdef ARGB_CURSOR
+ PicturePtr pRootPicture;
+ PicturePtr pTempPicture;
+#endif
+} miDCScreenRec, *miDCScreenPtr;
+
+/* per-cursor per-screen private data */
+typedef struct {
+ PixmapPtr sourceBits; /* source bits */
+ PixmapPtr maskBits; /* mask bits */
+#ifdef ARGB_CURSOR
+ PicturePtr pPicture;
+#endif
+} miDCCursorRec, *miDCCursorPtr;
+
+/*
+ * sprite/cursor method table
+ */
+
+static Bool miDCRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
+static Bool miDCUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
+static Bool miDCPutUpCursor(ScreenPtr pScreen, CursorPtr pCursor,
+ int x, int y, unsigned long source,
+ unsigned long mask);
+static Bool miDCSaveUnderCursor(ScreenPtr pScreen, int x, int y,
+ int w, int h);
+static Bool miDCRestoreUnderCursor(ScreenPtr pScreen, int x, int y,
+ int w, int h);
+static Bool miDCMoveCursor(ScreenPtr pScreen, CursorPtr pCursor,
+ int x, int y, int w, int h, int dx, int dy,
+ unsigned long source, unsigned long mask);
+static Bool miDCChangeSave(ScreenPtr pScreen, int x, int y, int w, int h,
+ int dx, int dy);
+
+static miSpriteCursorFuncRec miDCFuncs = {
+ miDCRealizeCursor,
+ miDCUnrealizeCursor,
+ miDCPutUpCursor,
+ miDCSaveUnderCursor,
+ miDCRestoreUnderCursor,
+ miDCMoveCursor,
+ miDCChangeSave,
+};
+
+Bool
+miDCInitialize (pScreen, screenFuncs)
+ ScreenPtr pScreen;
+ miPointerScreenFuncPtr screenFuncs;
+{
+ miDCScreenPtr pScreenPriv;
+
+ if (miDCGeneration != serverGeneration)
+ {
+ miDCScreenIndex = AllocateScreenPrivateIndex ();
+ if (miDCScreenIndex < 0)
+ return FALSE;
+ miDCGeneration = serverGeneration;
+ }
+ pScreenPriv = (miDCScreenPtr) xalloc (sizeof (miDCScreenRec));
+ if (!pScreenPriv)
+ return FALSE;
+
+ /*
+ * initialize the entire private structure to zeros
+ */
+
+ pScreenPriv->pSourceGC =
+ pScreenPriv->pMaskGC =
+ pScreenPriv->pSaveGC =
+ pScreenPriv->pRestoreGC =
+ pScreenPriv->pMoveGC =
+ pScreenPriv->pPixSourceGC =
+ pScreenPriv->pPixMaskGC = NULL;
+#ifdef ARGB_CURSOR
+ pScreenPriv->pRootPicture = NULL;
+ pScreenPriv->pTempPicture = NULL;
+#endif
+
+ pScreenPriv->pSave = pScreenPriv->pTemp = NULL;
+
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = miDCCloseScreen;
+
+ pScreen->devPrivates[miDCScreenIndex].ptr = (pointer) pScreenPriv;
+
+ if (!miSpriteInitialize (pScreen, &miDCFuncs, screenFuncs))
+ {
+ xfree ((pointer) pScreenPriv);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+#define tossGC(gc) (gc ? FreeGC (gc, (GContext) 0) : 0)
+#define tossPix(pix) (pix ? (*pScreen->DestroyPixmap) (pix) : TRUE)
+#define tossPict(pict) (pict ? FreePicture (pict, 0) : 0)
+
+static Bool
+miDCCloseScreen (index, pScreen)
+ int index;
+ ScreenPtr pScreen;
+{
+ miDCScreenPtr pScreenPriv;
+
+ pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+ tossGC (pScreenPriv->pSourceGC);
+ tossGC (pScreenPriv->pMaskGC);
+ tossGC (pScreenPriv->pSaveGC);
+ tossGC (pScreenPriv->pRestoreGC);
+ tossGC (pScreenPriv->pMoveGC);
+ tossGC (pScreenPriv->pPixSourceGC);
+ tossGC (pScreenPriv->pPixMaskGC);
+ tossPix (pScreenPriv->pSave);
+ tossPix (pScreenPriv->pTemp);
+#ifdef ARGB_CURSOR
+ tossPict (pScreenPriv->pRootPicture);
+ tossPict (pScreenPriv->pTempPicture);
+#endif
+ xfree ((pointer) pScreenPriv);
+ return (*pScreen->CloseScreen) (index, pScreen);
+}
+
+static Bool
+miDCRealizeCursor (pScreen, pCursor)
+ ScreenPtr pScreen;
+ CursorPtr pCursor;
+{
+ if (pCursor->bits->refcnt <= 1)
+ pCursor->bits->devPriv[pScreen->myNum] = (pointer)NULL;
+ return TRUE;
+}
+
+#ifdef ARGB_CURSOR
+#define EnsurePicture(picture,draw,win) (picture || miDCMakePicture(&picture,draw,win))
+
+static VisualPtr
+miDCGetWindowVisual (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ VisualID vid = wVisual (pWin);
+ int i;
+
+ for (i = 0; i < pScreen->numVisuals; i++)
+ if (pScreen->visuals[i].vid == vid)
+ return &pScreen->visuals[i];
+ return 0;
+}
+
+static PicturePtr
+miDCMakePicture (PicturePtr *ppPicture, DrawablePtr pDraw, WindowPtr pWin)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ VisualPtr pVisual;
+ PictFormatPtr pFormat;
+ XID subwindow_mode = IncludeInferiors;
+ PicturePtr pPicture;
+ int error;
+
+ pVisual = miDCGetWindowVisual (pWin);
+ if (!pVisual)
+ return 0;
+ pFormat = PictureMatchVisual (pScreen, pDraw->depth, pVisual);
+ if (!pFormat)
+ return 0;
+ pPicture = CreatePicture (0, pDraw, pFormat,
+ CPSubwindowMode, &subwindow_mode,
+ serverClient, &error);
+ *ppPicture = pPicture;
+ return pPicture;
+}
+#endif
+
+static miDCCursorPtr
+miDCRealize (
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ miDCCursorPtr pPriv;
+ GCPtr pGC;
+ XID gcvals[3];
+
+ pPriv = (miDCCursorPtr) xalloc (sizeof (miDCCursorRec));
+ if (!pPriv)
+ return (miDCCursorPtr)NULL;
+#ifdef ARGB_CURSOR
+ if (pCursor->bits->argb)
+ {
+ PixmapPtr pPixmap;
+ PictFormatPtr pFormat;
+ int error;
+
+ pFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
+ if (!pFormat)
+ {
+ xfree ((pointer) pPriv);
+ return (miDCCursorPtr)NULL;
+ }
+
+ pPriv->sourceBits = 0;
+ pPriv->maskBits = 0;
+ pPixmap = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width,
+ pCursor->bits->height, 32);
+ if (!pPixmap)
+ {
+ xfree ((pointer) pPriv);
+ return (miDCCursorPtr)NULL;
+ }
+ pGC = GetScratchGC (32, pScreen);
+ if (!pGC)
+ {
+ (*pScreen->DestroyPixmap) (pPixmap);
+ xfree ((pointer) pPriv);
+ return (miDCCursorPtr)NULL;
+ }
+ ValidateGC (&pPixmap->drawable, pGC);
+ (*pGC->ops->PutImage) (&pPixmap->drawable, pGC, 32,
+ 0, 0, pCursor->bits->width,
+ pCursor->bits->height,
+ 0, ZPixmap, (char *) pCursor->bits->argb);
+ FreeScratchGC (pGC);
+ pPriv->pPicture = CreatePicture (0, &pPixmap->drawable,
+ pFormat, 0, 0, serverClient, &error);
+ (*pScreen->DestroyPixmap) (pPixmap);
+ if (!pPriv->pPicture)
+ {
+ xfree ((pointer) pPriv);
+ return (miDCCursorPtr)NULL;
+ }
+ pCursor->bits->devPriv[pScreen->myNum] = (pointer) pPriv;
+ return pPriv;
+ }
+ pPriv->pPicture = 0;
+#endif
+ pPriv->sourceBits = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width, pCursor->bits->height, 1);
+ if (!pPriv->sourceBits)
+ {
+ xfree ((pointer) pPriv);
+ return (miDCCursorPtr)NULL;
+ }
+ pPriv->maskBits = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width, pCursor->bits->height, 1);
+ if (!pPriv->maskBits)
+ {
+ (*pScreen->DestroyPixmap) (pPriv->sourceBits);
+ xfree ((pointer) pPriv);
+ return (miDCCursorPtr)NULL;
+ }
+ pCursor->bits->devPriv[pScreen->myNum] = (pointer) pPriv;
+
+ /* create the two sets of bits, clipping as appropriate */
+
+ pGC = GetScratchGC (1, pScreen);
+ if (!pGC)
+ {
+ (void) miDCUnrealizeCursor (pScreen, pCursor);
+ return (miDCCursorPtr)NULL;
+ }
+
+ ValidateGC ((DrawablePtr)pPriv->sourceBits, pGC);
+ (*pGC->ops->PutImage) ((DrawablePtr)pPriv->sourceBits, pGC, 1,
+ 0, 0, pCursor->bits->width, pCursor->bits->height,
+ 0, XYPixmap, (char *)pCursor->bits->source);
+ gcvals[0] = GXand;
+ ChangeGC (pGC, GCFunction, gcvals);
+ ValidateGC ((DrawablePtr)pPriv->sourceBits, pGC);
+ (*pGC->ops->PutImage) ((DrawablePtr)pPriv->sourceBits, pGC, 1,
+ 0, 0, pCursor->bits->width, pCursor->bits->height,
+ 0, XYPixmap, (char *)pCursor->bits->mask);
+
+ /* mask bits -- pCursor->mask & ~pCursor->source */
+ gcvals[0] = GXcopy;
+ ChangeGC (pGC, GCFunction, gcvals);
+ ValidateGC ((DrawablePtr)pPriv->maskBits, pGC);
+ (*pGC->ops->PutImage) ((DrawablePtr)pPriv->maskBits, pGC, 1,
+ 0, 0, pCursor->bits->width, pCursor->bits->height,
+ 0, XYPixmap, (char *)pCursor->bits->mask);
+ gcvals[0] = GXandInverted;
+ ChangeGC (pGC, GCFunction, gcvals);
+ ValidateGC ((DrawablePtr)pPriv->maskBits, pGC);
+ (*pGC->ops->PutImage) ((DrawablePtr)pPriv->maskBits, pGC, 1,
+ 0, 0, pCursor->bits->width, pCursor->bits->height,
+ 0, XYPixmap, (char *)pCursor->bits->source);
+ FreeScratchGC (pGC);
+ return pPriv;
+}
+
+static Bool
+miDCUnrealizeCursor (pScreen, pCursor)
+ ScreenPtr pScreen;
+ CursorPtr pCursor;
+{
+ miDCCursorPtr pPriv;
+
+ pPriv = (miDCCursorPtr) pCursor->bits->devPriv[pScreen->myNum];
+ if (pPriv && (pCursor->bits->refcnt <= 1))
+ {
+ if (pPriv->sourceBits)
+ (*pScreen->DestroyPixmap) (pPriv->sourceBits);
+ if (pPriv->maskBits)
+ (*pScreen->DestroyPixmap) (pPriv->maskBits);
+#ifdef ARGB_CURSOR
+ if (pPriv->pPicture)
+ FreePicture (pPriv->pPicture, 0);
+#endif
+ xfree ((pointer) pPriv);
+ pCursor->bits->devPriv[pScreen->myNum] = (pointer)NULL;
+ }
+ return TRUE;
+}
+
+static void
+miDCPutBits (
+ DrawablePtr pDrawable,
+ miDCCursorPtr pPriv,
+ GCPtr sourceGC,
+ GCPtr maskGC,
+ int x_org,
+ int y_org,
+ unsigned w,
+ unsigned h,
+ unsigned long source,
+ unsigned long mask)
+{
+ XID gcvals[1];
+ int x, y;
+
+ if (sourceGC->fgPixel != source)
+ {
+ gcvals[0] = source;
+ DoChangeGC (sourceGC, GCForeground, gcvals, 0);
+ }
+ if (sourceGC->serialNumber != pDrawable->serialNumber)
+ ValidateGC (pDrawable, sourceGC);
+
+ if(sourceGC->miTranslate)
+ {
+ x = pDrawable->x + x_org;
+ y = pDrawable->y + y_org;
+ }
+ else
+ {
+ x = x_org;
+ y = y_org;
+ }
+
+ (*sourceGC->ops->PushPixels) (sourceGC, pPriv->sourceBits, pDrawable, w, h, x, y);
+ if (maskGC->fgPixel != mask)
+ {
+ gcvals[0] = mask;
+ DoChangeGC (maskGC, GCForeground, gcvals, 0);
+ }
+ if (maskGC->serialNumber != pDrawable->serialNumber)
+ ValidateGC (pDrawable, maskGC);
+
+ if(maskGC->miTranslate)
+ {
+ x = pDrawable->x + x_org;
+ y = pDrawable->y + y_org;
+ }
+ else
+ {
+ x = x_org;
+ y = y_org;
+ }
+
+ (*maskGC->ops->PushPixels) (maskGC, pPriv->maskBits, pDrawable, w, h, x, y);
+}
+
+#define EnsureGC(gc,win) (gc || miDCMakeGC(&gc, win))
+
+static GCPtr
+miDCMakeGC(
+ GCPtr *ppGC,
+ WindowPtr pWin)
+{
+ GCPtr pGC;
+ int status;
+ XID gcvals[2];
+
+ gcvals[0] = IncludeInferiors;
+ gcvals[1] = FALSE;
+ pGC = CreateGC((DrawablePtr)pWin,
+ GCSubwindowMode|GCGraphicsExposures, gcvals, &status);
+ if (pGC && pWin->drawable.pScreen->DrawGuarantee)
+ (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack);
+ *ppGC = pGC;
+ return pGC;
+}
+
+
+static Bool
+miDCPutUpCursor (pScreen, pCursor, x, y, source, mask)
+ ScreenPtr pScreen;
+ CursorPtr pCursor;
+ int x, y;
+ unsigned long source, mask;
+{
+ miDCScreenPtr pScreenPriv;
+ miDCCursorPtr pPriv;
+ WindowPtr pWin;
+
+ pPriv = (miDCCursorPtr) pCursor->bits->devPriv[pScreen->myNum];
+ if (!pPriv)
+ {
+ pPriv = miDCRealize(pScreen, pCursor);
+ if (!pPriv)
+ return FALSE;
+ }
+ pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pWin = WindowTable[pScreen->myNum];
+#ifdef ARGB_CURSOR
+ if (pPriv->pPicture)
+ {
+ if (!EnsurePicture(pScreenPriv->pRootPicture, &pWin->drawable, pWin))
+ return FALSE;
+ CompositePicture (PictOpOver,
+ pPriv->pPicture,
+ NULL,
+ pScreenPriv->pRootPicture,
+ 0, 0, 0, 0,
+ x, y,
+ pCursor->bits->width,
+ pCursor->bits->height);
+ }
+ else
+#endif
+ {
+ if (!EnsureGC(pScreenPriv->pSourceGC, pWin))
+ return FALSE;
+ if (!EnsureGC(pScreenPriv->pMaskGC, pWin))
+ {
+ FreeGC (pScreenPriv->pSourceGC, (GContext) 0);
+ pScreenPriv->pSourceGC = 0;
+ return FALSE;
+ }
+ miDCPutBits ((DrawablePtr)pWin, pPriv,
+ pScreenPriv->pSourceGC, pScreenPriv->pMaskGC,
+ x, y, pCursor->bits->width, pCursor->bits->height,
+ source, mask);
+ }
+ return TRUE;
+}
+
+static Bool
+miDCSaveUnderCursor (pScreen, x, y, w, h)
+ ScreenPtr pScreen;
+ int x, y, w, h;
+{
+ miDCScreenPtr pScreenPriv;
+ PixmapPtr pSave;
+ WindowPtr pWin;
+ GCPtr pGC;
+
+ pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pSave = pScreenPriv->pSave;
+ pWin = WindowTable[pScreen->myNum];
+ if (!pSave || pSave->drawable.width < w || pSave->drawable.height < h)
+ {
+ if (pSave)
+ (*pScreen->DestroyPixmap) (pSave);
+ pScreenPriv->pSave = pSave =
+ (*pScreen->CreatePixmap) (pScreen, w, h, pScreen->rootDepth);
+ if (!pSave)
+ return FALSE;
+ }
+ if (!EnsureGC(pScreenPriv->pSaveGC, pWin))
+ return FALSE;
+ pGC = pScreenPriv->pSaveGC;
+ if (pSave->drawable.serialNumber != pGC->serialNumber)
+ ValidateGC ((DrawablePtr) pSave, pGC);
+ (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
+ x, y, w, h, 0, 0);
+ return TRUE;
+}
+
+static Bool
+miDCRestoreUnderCursor (pScreen, x, y, w, h)
+ ScreenPtr pScreen;
+ int x, y, w, h;
+{
+ miDCScreenPtr pScreenPriv;
+ PixmapPtr pSave;
+ WindowPtr pWin;
+ GCPtr pGC;
+
+ pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pSave = pScreenPriv->pSave;
+ pWin = WindowTable[pScreen->myNum];
+ if (!pSave)
+ return FALSE;
+ if (!EnsureGC(pScreenPriv->pRestoreGC, pWin))
+ return FALSE;
+ pGC = pScreenPriv->pRestoreGC;
+ if (pWin->drawable.serialNumber != pGC->serialNumber)
+ ValidateGC ((DrawablePtr) pWin, pGC);
+ (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
+ 0, 0, w, h, x, y);
+ return TRUE;
+}
+
+static Bool
+miDCChangeSave (pScreen, x, y, w, h, dx, dy)
+ ScreenPtr pScreen;
+ int x, y, w, h, dx, dy;
+{
+ miDCScreenPtr pScreenPriv;
+ PixmapPtr pSave;
+ WindowPtr pWin;
+ GCPtr pGC;
+ int sourcex, sourcey, destx, desty, copyw, copyh;
+
+ pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pSave = pScreenPriv->pSave;
+ pWin = WindowTable[pScreen->myNum];
+ /*
+ * restore the bits which are about to get trashed
+ */
+ if (!pSave)
+ return FALSE;
+ if (!EnsureGC(pScreenPriv->pRestoreGC, pWin))
+ return FALSE;
+ pGC = pScreenPriv->pRestoreGC;
+ if (pWin->drawable.serialNumber != pGC->serialNumber)
+ ValidateGC ((DrawablePtr) pWin, pGC);
+ /*
+ * copy the old bits to the screen.
+ */
+ if (dy > 0)
+ {
+ (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
+ 0, h - dy, w, dy, x + dx, y + h);
+ }
+ else if (dy < 0)
+ {
+ (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
+ 0, 0, w, -dy, x + dx, y + dy);
+ }
+ if (dy >= 0)
+ {
+ desty = y + dy;
+ sourcey = 0;
+ copyh = h - dy;
+ }
+ else
+ {
+ desty = y;
+ sourcey = - dy;
+ copyh = h + dy;
+ }
+ if (dx > 0)
+ {
+ (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
+ w - dx, sourcey, dx, copyh, x + w, desty);
+ }
+ else if (dx < 0)
+ {
+ (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
+ 0, sourcey, -dx, copyh, x + dx, desty);
+ }
+ if (!EnsureGC(pScreenPriv->pSaveGC, pWin))
+ return FALSE;
+ pGC = pScreenPriv->pSaveGC;
+ if (pSave->drawable.serialNumber != pGC->serialNumber)
+ ValidateGC ((DrawablePtr) pSave, pGC);
+ /*
+ * move the bits that are still valid within the pixmap
+ */
+ if (dx >= 0)
+ {
+ sourcex = 0;
+ destx = dx;
+ copyw = w - dx;
+ }
+ else
+ {
+ destx = 0;
+ sourcex = - dx;
+ copyw = w + dx;
+ }
+ if (dy >= 0)
+ {
+ sourcey = 0;
+ desty = dy;
+ copyh = h - dy;
+ }
+ else
+ {
+ desty = 0;
+ sourcey = -dy;
+ copyh = h + dy;
+ }
+ (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pSave, pGC,
+ sourcex, sourcey, copyw, copyh, destx, desty);
+ /*
+ * copy the new bits from the screen into the remaining areas of the
+ * pixmap
+ */
+ if (dy > 0)
+ {
+ (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
+ x, y, w, dy, 0, 0);
+ }
+ else if (dy < 0)
+ {
+ (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
+ x, y + h + dy, w, -dy, 0, h + dy);
+ }
+ if (dy >= 0)
+ {
+ desty = dy;
+ sourcey = y + dy;
+ copyh = h - dy;
+ }
+ else
+ {
+ desty = 0;
+ sourcey = y;
+ copyh = h + dy;
+ }
+ if (dx > 0)
+ {
+ (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
+ x, sourcey, dx, copyh, 0, desty);
+ }
+ else if (dx < 0)
+ {
+ (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
+ x + w + dx, sourcey, -dx, copyh, w + dx, desty);
+ }
+ return TRUE;
+}
+
+static Bool
+miDCMoveCursor (pScreen, pCursor, x, y, w, h, dx, dy, source, mask)
+ ScreenPtr pScreen;
+ CursorPtr pCursor;
+ int x, y, w, h, dx, dy;
+ unsigned long source, mask;
+{
+ miDCCursorPtr pPriv;
+ miDCScreenPtr pScreenPriv;
+ int status;
+ WindowPtr pWin;
+ GCPtr pGC;
+ XID gcval = FALSE;
+ PixmapPtr pTemp;
+
+ pPriv = (miDCCursorPtr) pCursor->bits->devPriv[pScreen->myNum];
+ if (!pPriv)
+ {
+ pPriv = miDCRealize(pScreen, pCursor);
+ if (!pPriv)
+ return FALSE;
+ }
+ pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pWin = WindowTable[pScreen->myNum];
+ pTemp = pScreenPriv->pTemp;
+ if (!pTemp ||
+ pTemp->drawable.width != pScreenPriv->pSave->drawable.width ||
+ pTemp->drawable.height != pScreenPriv->pSave->drawable.height)
+ {
+ if (pTemp)
+ (*pScreen->DestroyPixmap) (pTemp);
+#ifdef ARGB_CURSOR
+ if (pScreenPriv->pTempPicture)
+ {
+ FreePicture (pScreenPriv->pTempPicture, 0);
+ pScreenPriv->pTempPicture = 0;
+ }
+#endif
+ pScreenPriv->pTemp = pTemp = (*pScreen->CreatePixmap)
+ (pScreen, w, h, pScreenPriv->pSave->drawable.depth);
+ if (!pTemp)
+ return FALSE;
+ }
+ if (!pScreenPriv->pMoveGC)
+ {
+ pScreenPriv->pMoveGC = CreateGC ((DrawablePtr)pTemp,
+ GCGraphicsExposures, &gcval, &status);
+ if (!pScreenPriv->pMoveGC)
+ return FALSE;
+ }
+ /*
+ * copy the saved area to a temporary pixmap
+ */
+ pGC = pScreenPriv->pMoveGC;
+ if (pGC->serialNumber != pTemp->drawable.serialNumber)
+ ValidateGC ((DrawablePtr) pTemp, pGC);
+ (*pGC->ops->CopyArea)((DrawablePtr)pScreenPriv->pSave,
+ (DrawablePtr)pTemp, pGC, 0, 0, w, h, 0, 0);
+
+ /*
+ * draw the cursor in the temporary pixmap
+ */
+#ifdef ARGB_CURSOR
+ if (pPriv->pPicture)
+ {
+ if (!EnsurePicture(pScreenPriv->pTempPicture, &pTemp->drawable, pWin))
+ return FALSE;
+ CompositePicture (PictOpOver,
+ pPriv->pPicture,
+ NULL,
+ pScreenPriv->pTempPicture,
+ 0, 0, 0, 0,
+ dx, dy,
+ pCursor->bits->width,
+ pCursor->bits->height);
+ }
+ else
+#endif
+ {
+ if (!pScreenPriv->pPixSourceGC)
+ {
+ pScreenPriv->pPixSourceGC = CreateGC ((DrawablePtr)pTemp,
+ GCGraphicsExposures, &gcval, &status);
+ if (!pScreenPriv->pPixSourceGC)
+ return FALSE;
+ }
+ if (!pScreenPriv->pPixMaskGC)
+ {
+ pScreenPriv->pPixMaskGC = CreateGC ((DrawablePtr)pTemp,
+ GCGraphicsExposures, &gcval, &status);
+ if (!pScreenPriv->pPixMaskGC)
+ return FALSE;
+ }
+ miDCPutBits ((DrawablePtr)pTemp, pPriv,
+ pScreenPriv->pPixSourceGC, pScreenPriv->pPixMaskGC,
+ dx, dy, pCursor->bits->width, pCursor->bits->height,
+ source, mask);
+ }
+
+ /*
+ * copy the temporary pixmap onto the screen
+ */
+
+ if (!EnsureGC(pScreenPriv->pRestoreGC, pWin))
+ return FALSE;
+ pGC = pScreenPriv->pRestoreGC;
+ if (pWin->drawable.serialNumber != pGC->serialNumber)
+ ValidateGC ((DrawablePtr) pWin, pGC);
+
+ (*pGC->ops->CopyArea) ((DrawablePtr) pTemp, (DrawablePtr) pWin,
+ pGC,
+ 0, 0, w, h, x, y);
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/mi/mieq.c b/nx-X11/programs/Xserver/mi/mieq.c
new file mode 100644
index 000000000..37662625e
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mieq.c
@@ -0,0 +1,192 @@
+/*
+ * $Xorg: mieq.c,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $
+ *
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/programs/Xserver/mi/mieq.c,v 1.2 2001/05/25 18:41:01 dawes Exp $ */
+
+/*
+ * mieq.c
+ *
+ * Machine independent event queue
+ *
+ */
+
+# define NEED_EVENTS
+# include <X11/X.h>
+# include <X11/Xmd.h>
+# include <X11/Xproto.h>
+# include "misc.h"
+# include "windowstr.h"
+# include "pixmapstr.h"
+# include "inputstr.h"
+# include "mi.h"
+# include "scrnintstr.h"
+
+#define QUEUE_SIZE 256
+
+typedef struct _Event {
+ xEvent event;
+ ScreenPtr pScreen;
+} EventRec, *EventPtr;
+
+typedef struct _EventQueue {
+ HWEventQueueType head, tail; /* long for SetInputCheck */
+ CARD32 lastEventTime; /* to avoid time running backwards */
+ Bool lastMotion;
+ EventRec events[QUEUE_SIZE]; /* static allocation for signals */
+ DevicePtr pKbd, pPtr; /* device pointer, to get funcs */
+ ScreenPtr pEnqueueScreen; /* screen events are being delivered to */
+ ScreenPtr pDequeueScreen; /* screen events are being dispatched to */
+} EventQueueRec, *EventQueuePtr;
+
+static EventQueueRec miEventQueue;
+
+Bool
+mieqInit (pKbd, pPtr)
+ DevicePtr pKbd, pPtr;
+{
+ miEventQueue.head = miEventQueue.tail = 0;
+ miEventQueue.lastEventTime = GetTimeInMillis ();
+ miEventQueue.pKbd = pKbd;
+ miEventQueue.pPtr = pPtr;
+ miEventQueue.lastMotion = FALSE;
+ miEventQueue.pEnqueueScreen = screenInfo.screens[0];
+ miEventQueue.pDequeueScreen = miEventQueue.pEnqueueScreen;
+ SetInputCheck (&miEventQueue.head, &miEventQueue.tail);
+ return TRUE;
+}
+
+/*
+ * Must be reentrant with ProcessInputEvents. Assumption: mieqEnqueue
+ * will never be interrupted. If this is called from both signal
+ * handlers and regular code, make sure the signal is suspended when
+ * called from regular code.
+ */
+
+void
+mieqEnqueue (e)
+ xEvent *e;
+{
+ HWEventQueueType oldtail, newtail;
+ Bool isMotion;
+
+ oldtail = miEventQueue.tail;
+ isMotion = e->u.u.type == MotionNotify;
+ if (isMotion && miEventQueue.lastMotion && oldtail != miEventQueue.head)
+ {
+ if (oldtail == 0)
+ oldtail = QUEUE_SIZE;
+ oldtail = oldtail - 1;
+ }
+ else
+ {
+ newtail = oldtail + 1;
+ if (newtail == QUEUE_SIZE)
+ newtail = 0;
+ /* Toss events which come in late */
+ if (newtail == miEventQueue.head)
+ return;
+ miEventQueue.tail = newtail;
+ }
+ miEventQueue.lastMotion = isMotion;
+ miEventQueue.events[oldtail].event = *e;
+ /*
+ * Make sure that event times don't go backwards - this
+ * is "unnecessary", but very useful
+ */
+ if (e->u.keyButtonPointer.time < miEventQueue.lastEventTime &&
+ miEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000)
+ {
+ miEventQueue.events[oldtail].event.u.keyButtonPointer.time =
+ miEventQueue.lastEventTime;
+ }
+ miEventQueue.lastEventTime =
+ miEventQueue.events[oldtail].event.u.keyButtonPointer.time;
+ miEventQueue.events[oldtail].pScreen = miEventQueue.pEnqueueScreen;
+}
+
+void
+mieqSwitchScreen (pScreen, fromDIX)
+ ScreenPtr pScreen;
+ Bool fromDIX;
+{
+ miEventQueue.pEnqueueScreen = pScreen;
+ if (fromDIX)
+ miEventQueue.pDequeueScreen = pScreen;
+}
+
+/*
+ * Call this from ProcessInputEvents()
+ */
+
+void mieqProcessInputEvents ()
+{
+ EventRec *e;
+ int x, y;
+ xEvent xe;
+
+ while (miEventQueue.head != miEventQueue.tail)
+ {
+ if (screenIsSaved == SCREEN_SAVER_ON)
+ SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
+
+ e = &miEventQueue.events[miEventQueue.head];
+ /*
+ * Assumption - screen switching can only occur on motion events
+ */
+ if (e->pScreen != miEventQueue.pDequeueScreen)
+ {
+ miEventQueue.pDequeueScreen = e->pScreen;
+ x = e->event.u.keyButtonPointer.rootX;
+ y = e->event.u.keyButtonPointer.rootY;
+ if (miEventQueue.head == QUEUE_SIZE - 1)
+ miEventQueue.head = 0;
+ else
+ ++miEventQueue.head;
+ NewCurrentScreen (miEventQueue.pDequeueScreen, x, y);
+ }
+ else
+ {
+ xe = e->event;
+ if (miEventQueue.head == QUEUE_SIZE - 1)
+ miEventQueue.head = 0;
+ else
+ ++miEventQueue.head;
+ switch (xe.u.u.type)
+ {
+ case KeyPress:
+ case KeyRelease:
+ (*miEventQueue.pKbd->processInputProc)
+ (&xe, (DeviceIntPtr)miEventQueue.pKbd, 1);
+ break;
+ default:
+ (*miEventQueue.pPtr->processInputProc)
+ (&xe, (DeviceIntPtr)miEventQueue.pPtr, 1);
+ break;
+ }
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/mi/miexpose.c b/nx-X11/programs/Xserver/mi/miexpose.c
new file mode 100644
index 000000000..9a0bd06b5
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/miexpose.c
@@ -0,0 +1,905 @@
+/* $XdotOrg: xc/programs/Xserver/mi/miexpose.c,v 1.6 2005/07/03 08:53:51 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/mi/miexpose.c,v 3.9tsi Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/*****************************************************************
+
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+
+/* $Xorg: miexpose.c,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include <X11/Xprotostr.h>
+
+#include "misc.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmap.h"
+#include "input.h"
+
+#include "dixstruct.h"
+#include "mi.h"
+#include <X11/Xmd.h>
+
+#include "globals.h"
+
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+
+/*
+ machine-independent graphics exposure code. any device that uses
+the region package can call this.
+*/
+
+#ifndef RECTLIMIT
+#define RECTLIMIT 25 /* pick a number, any number > 8 */
+#endif
+
+/* miHandleExposures
+ generate a region for exposures for areas that were copied from obscured or
+non-existent areas to non-obscured areas of the destination. Paint the
+background for the region, if the destination is a window.
+
+NOTE:
+ this should generally be called, even if graphicsExposures is false,
+because this is where bits get recovered from backing store.
+
+NOTE:
+ added argument 'plane' is used to indicate how exposures from backing
+store should be accomplished. If plane is 0 (i.e. no bit plane), CopyArea
+should be used, else a CopyPlane of the indicated plane will be used. The
+exposing is done by the backing store's GraphicsExpose function, of course.
+
+*/
+
+RegionPtr
+miHandleExposures(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, plane)
+ register DrawablePtr pSrcDrawable;
+ register DrawablePtr pDstDrawable;
+ GCPtr pGC;
+ int srcx, srcy;
+ int width, height;
+ int dstx, dsty;
+ unsigned long plane;
+{
+ register ScreenPtr pscr;
+ RegionPtr prgnSrcClip; /* drawable-relative source clip */
+ RegionRec rgnSrcRec;
+ RegionPtr prgnDstClip; /* drawable-relative dest clip */
+ RegionRec rgnDstRec;
+ BoxRec srcBox; /* unclipped source */
+ RegionRec rgnExposed; /* exposed region, calculated source-
+ relative, made dst relative to
+ intersect with visible parts of
+ dest and send events to client,
+ and then screen relative to paint
+ the window background
+ */
+ WindowPtr pSrcWin;
+ BoxRec expBox;
+ Bool extents;
+
+ /* This prevents warning about pscr not being used. */
+ pGC->pScreen = pscr = pGC->pScreen;
+
+ /* avoid work if we can */
+ if (!pGC->graphicsExposures &&
+ (pDstDrawable->type == DRAWABLE_PIXMAP) &&
+ ((pSrcDrawable->type == DRAWABLE_PIXMAP) ||
+ (((WindowPtr)pSrcDrawable)->backStorage == NULL)))
+ return NULL;
+
+ srcBox.x1 = srcx;
+ srcBox.y1 = srcy;
+ srcBox.x2 = srcx+width;
+ srcBox.y2 = srcy+height;
+
+ if (pSrcDrawable->type != DRAWABLE_PIXMAP)
+ {
+ BoxRec TsrcBox;
+
+ TsrcBox.x1 = srcx + pSrcDrawable->x;
+ TsrcBox.y1 = srcy + pSrcDrawable->y;
+ TsrcBox.x2 = TsrcBox.x1 + width;
+ TsrcBox.y2 = TsrcBox.y1 + height;
+ pSrcWin = (WindowPtr) pSrcDrawable;
+ if (pGC->subWindowMode == IncludeInferiors)
+ {
+ prgnSrcClip = NotClippedByChildren (pSrcWin);
+ if ((RECT_IN_REGION(pscr, prgnSrcClip, &TsrcBox)) == rgnIN)
+ {
+ REGION_DESTROY(pscr, prgnSrcClip);
+ return NULL;
+ }
+ }
+ else
+ {
+ if ((RECT_IN_REGION(pscr, &pSrcWin->clipList, &TsrcBox)) == rgnIN)
+ return NULL;
+ prgnSrcClip = &rgnSrcRec;
+ REGION_NULL(pscr, prgnSrcClip);
+ REGION_COPY(pscr, prgnSrcClip, &pSrcWin->clipList);
+ }
+ REGION_TRANSLATE(pscr, prgnSrcClip,
+ -pSrcDrawable->x, -pSrcDrawable->y);
+ }
+ else
+ {
+ BoxRec box;
+
+ if ((srcBox.x1 >= 0) && (srcBox.y1 >= 0) &&
+ (srcBox.x2 <= pSrcDrawable->width) &&
+ (srcBox.y2 <= pSrcDrawable->height))
+ return NULL;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pSrcDrawable->width;
+ box.y2 = pSrcDrawable->height;
+ prgnSrcClip = &rgnSrcRec;
+ REGION_INIT(pscr, prgnSrcClip, &box, 1);
+ pSrcWin = (WindowPtr)NULL;
+ }
+
+ if (pDstDrawable == pSrcDrawable)
+ {
+ prgnDstClip = prgnSrcClip;
+ }
+ else if (pDstDrawable->type != DRAWABLE_PIXMAP)
+ {
+ if (pGC->subWindowMode == IncludeInferiors)
+ {
+ prgnDstClip = NotClippedByChildren((WindowPtr)pDstDrawable);
+ }
+ else
+ {
+ prgnDstClip = &rgnDstRec;
+ REGION_NULL(pscr, prgnDstClip);
+ REGION_COPY(pscr, prgnDstClip,
+ &((WindowPtr)pDstDrawable)->clipList);
+ }
+ REGION_TRANSLATE(pscr, prgnDstClip,
+ -pDstDrawable->x, -pDstDrawable->y);
+ }
+ else
+ {
+ BoxRec box;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pDstDrawable->width;
+ box.y2 = pDstDrawable->height;
+ prgnDstClip = &rgnDstRec;
+ REGION_INIT(pscr, prgnDstClip, &box, 1);
+ }
+
+ /* drawable-relative source region */
+ REGION_INIT(pscr, &rgnExposed, &srcBox, 1);
+
+ /* now get the hidden parts of the source box*/
+ REGION_SUBTRACT(pscr, &rgnExposed, &rgnExposed, prgnSrcClip);
+
+ if (pSrcWin && pSrcWin->backStorage)
+ {
+ /*
+ * Copy any areas from the source backing store. Modifies
+ * rgnExposed.
+ */
+ (* pSrcWin->drawable.pScreen->ExposeCopy) ((WindowPtr)pSrcDrawable,
+ pDstDrawable,
+ pGC,
+ &rgnExposed,
+ srcx, srcy,
+ dstx, dsty,
+ plane);
+ }
+
+ /* move them over the destination */
+ REGION_TRANSLATE(pscr, &rgnExposed, dstx-srcx, dsty-srcy);
+
+ /* intersect with visible areas of dest */
+ REGION_INTERSECT(pscr, &rgnExposed, &rgnExposed, prgnDstClip);
+
+ /*
+ * If we have LOTS of rectangles, we decide to take the extents
+ * and force an exposure on that. This should require much less
+ * work overall, on both client and server. This is cheating, but
+ * isn't prohibited by the protocol ("spontaneous combustion" :-)
+ * for windows.
+ */
+ extents = pGC->graphicsExposures &&
+ (REGION_NUM_RECTS(&rgnExposed) > RECTLIMIT) &&
+ (pDstDrawable->type != DRAWABLE_PIXMAP);
+#ifdef SHAPE
+ if (pSrcWin)
+ {
+ RegionPtr region;
+ if (!(region = wClipShape (pSrcWin)))
+ region = wBoundingShape (pSrcWin);
+ /*
+ * If you try to CopyArea the extents of a shaped window, compacting the
+ * exposed region will undo all our work!
+ */
+ if (extents && pSrcWin && region &&
+ (RECT_IN_REGION(pscr, region, &srcBox) != rgnIN))
+ extents = FALSE;
+ }
+#endif
+ if (extents)
+ {
+ WindowPtr pWin = (WindowPtr)pDstDrawable;
+
+ expBox = *REGION_EXTENTS(pscr, &rgnExposed);
+ REGION_RESET(pscr, &rgnExposed, &expBox);
+ /* need to clear out new areas of backing store */
+ if (pWin->backStorage)
+ (void) (* pWin->drawable.pScreen->ClearBackingStore)(
+ pWin,
+ expBox.x1,
+ expBox.y1,
+ expBox.x2 - expBox.x1,
+ expBox.y2 - expBox.y1,
+ FALSE);
+ }
+ if ((pDstDrawable->type != DRAWABLE_PIXMAP) &&
+ (((WindowPtr)pDstDrawable)->backgroundState != None))
+ {
+ WindowPtr pWin = (WindowPtr)pDstDrawable;
+
+ /* make the exposed area screen-relative */
+ REGION_TRANSLATE(pscr, &rgnExposed,
+ pDstDrawable->x, pDstDrawable->y);
+
+ if (extents)
+ {
+ /* PaintWindowBackground doesn't clip, so we have to */
+ REGION_INTERSECT(pscr, &rgnExposed, &rgnExposed, &pWin->clipList);
+ }
+ (*pWin->drawable.pScreen->PaintWindowBackground)(
+ (WindowPtr)pDstDrawable, &rgnExposed, PW_BACKGROUND);
+
+ if (extents)
+ {
+ REGION_RESET(pscr, &rgnExposed, &expBox);
+ }
+ else
+ REGION_TRANSLATE(pscr, &rgnExposed,
+ -pDstDrawable->x, -pDstDrawable->y);
+ }
+ if (prgnDstClip == &rgnDstRec)
+ {
+ REGION_UNINIT(pscr, prgnDstClip);
+ }
+ else if (prgnDstClip != prgnSrcClip)
+ {
+ REGION_DESTROY(pscr, prgnDstClip);
+ }
+
+ if (prgnSrcClip == &rgnSrcRec)
+ {
+ REGION_UNINIT(pscr, prgnSrcClip);
+ }
+ else
+ {
+ REGION_DESTROY(pscr, prgnSrcClip);
+ }
+
+ if (pGC->graphicsExposures)
+ {
+ /* don't look */
+ RegionPtr exposed = REGION_CREATE(pscr, NullBox, 0);
+ *exposed = rgnExposed;
+ return exposed;
+ }
+ else
+ {
+ REGION_UNINIT(pscr, &rgnExposed);
+ return NULL;
+ }
+}
+
+/* send GraphicsExpose events, or a NoExpose event, based on the region */
+
+void
+miSendGraphicsExpose (client, pRgn, drawable, major, minor)
+ ClientPtr client;
+ RegionPtr pRgn;
+ XID drawable;
+ int major;
+ int minor;
+{
+ if (pRgn && !REGION_NIL(pRgn))
+ {
+ xEvent *pEvent;
+ register xEvent *pe;
+ register BoxPtr pBox;
+ register int i;
+ int numRects;
+
+ numRects = REGION_NUM_RECTS(pRgn);
+ pBox = REGION_RECTS(pRgn);
+ if(!(pEvent = (xEvent *)ALLOCATE_LOCAL(numRects * sizeof(xEvent))))
+ return;
+ pe = pEvent;
+
+ for (i=1; i<=numRects; i++, pe++, pBox++)
+ {
+ pe->u.u.type = GraphicsExpose;
+ pe->u.graphicsExposure.drawable = drawable;
+ pe->u.graphicsExposure.x = pBox->x1;
+ pe->u.graphicsExposure.y = pBox->y1;
+ pe->u.graphicsExposure.width = pBox->x2 - pBox->x1;
+ pe->u.graphicsExposure.height = pBox->y2 - pBox->y1;
+ pe->u.graphicsExposure.count = numRects - i;
+ pe->u.graphicsExposure.majorEvent = major;
+ pe->u.graphicsExposure.minorEvent = minor;
+ }
+ TryClientEvents(client, pEvent, numRects,
+ (Mask)0, NoEventMask, NullGrab);
+ DEALLOCATE_LOCAL(pEvent);
+ }
+ else
+ {
+ xEvent event;
+ event.u.u.type = NoExpose;
+ event.u.noExposure.drawable = drawable;
+ event.u.noExposure.majorEvent = major;
+ event.u.noExposure.minorEvent = minor;
+ TryClientEvents(client, &event, 1,
+ (Mask)0, NoEventMask, NullGrab);
+ }
+}
+
+
+void
+miSendExposures(pWin, pRgn, dx, dy)
+ WindowPtr pWin;
+ RegionPtr pRgn;
+ register int dx, dy;
+{
+ register BoxPtr pBox;
+ int numRects;
+ register xEvent *pEvent, *pe;
+ register int i;
+
+ pBox = REGION_RECTS(pRgn);
+ numRects = REGION_NUM_RECTS(pRgn);
+ if(!(pEvent = (xEvent *) ALLOCATE_LOCAL(numRects * sizeof(xEvent))))
+ return;
+
+ for (i=numRects, pe = pEvent; --i >= 0; pe++, pBox++)
+ {
+ pe->u.u.type = Expose;
+ pe->u.expose.window = pWin->drawable.id;
+ pe->u.expose.x = pBox->x1 - dx;
+ pe->u.expose.y = pBox->y1 - dy;
+ pe->u.expose.width = pBox->x2 - pBox->x1;
+ pe->u.expose.height = pBox->y2 - pBox->y1;
+ pe->u.expose.count = i;
+ }
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ int scrnum = pWin->drawable.pScreen->myNum;
+ int x = 0, y = 0;
+ XID realWin = 0;
+
+ if(!pWin->parent) {
+ x = panoramiXdataPtr[scrnum].x;
+ y = panoramiXdataPtr[scrnum].y;
+ pWin = WindowTable[0];
+ realWin = pWin->drawable.id;
+ } else if (scrnum) {
+ PanoramiXRes *win;
+ win = PanoramiXFindIDByScrnum(XRT_WINDOW,
+ pWin->drawable.id, scrnum);
+ if(!win) {
+ DEALLOCATE_LOCAL(pEvent);
+ return;
+ }
+ realWin = win->info[0].id;
+ pWin = LookupIDByType(realWin, RT_WINDOW);
+ }
+ if(x || y || scrnum)
+ for (i = 0; i < numRects; i++) {
+ pEvent[i].u.expose.window = realWin;
+ pEvent[i].u.expose.x += x;
+ pEvent[i].u.expose.y += y;
+ }
+ }
+#endif
+
+ DeliverEvents(pWin, pEvent, numRects, NullWindow);
+
+ DEALLOCATE_LOCAL(pEvent);
+}
+
+void
+miWindowExposures(pWin, prgn, other_exposed)
+ WindowPtr pWin;
+ register RegionPtr prgn, other_exposed;
+{
+ RegionPtr exposures = prgn;
+ if (pWin->backStorage && prgn)
+ /*
+ * in some cases, backing store will cause a different
+ * region to be exposed than needs to be repainted
+ * (like when a window is mapped). RestoreAreas is
+ * allowed to return a region other than prgn,
+ * in which case this routine will free the resultant
+ * region. If exposures is null, then no events will
+ * be sent to the client; if prgn is empty
+ * no areas will be repainted.
+ */
+ exposures = (*pWin->drawable.pScreen->RestoreAreas)(pWin, prgn);
+ if ((prgn && !REGION_NIL(prgn)) ||
+ (exposures && !REGION_NIL(exposures)) || other_exposed)
+ {
+ RegionRec expRec;
+ int clientInterested;
+
+ /*
+ * Restore from backing-store FIRST.
+ */
+ clientInterested = (pWin->eventMask|wOtherEventMasks(pWin)) & ExposureMask;
+ if (other_exposed)
+ {
+ if (exposures)
+ {
+ REGION_UNION(pWin->drawable.pScreen, other_exposed,
+ exposures,
+ other_exposed);
+ if (exposures != prgn)
+ REGION_DESTROY(pWin->drawable.pScreen, exposures);
+ }
+ exposures = other_exposed;
+ }
+ if (clientInterested && exposures && (REGION_NUM_RECTS(exposures) > RECTLIMIT))
+ {
+ /*
+ * If we have LOTS of rectangles, we decide to take the extents
+ * and force an exposure on that. This should require much less
+ * work overall, on both client and server. This is cheating, but
+ * isn't prohibited by the protocol ("spontaneous combustion" :-).
+ */
+ BoxRec box;
+
+ box = *REGION_EXTENTS( pWin->drawable.pScreen, exposures);
+ if (exposures == prgn) {
+ exposures = &expRec;
+ REGION_INIT( pWin->drawable.pScreen, exposures, &box, 1);
+ REGION_RESET( pWin->drawable.pScreen, prgn, &box);
+ } else {
+ REGION_RESET( pWin->drawable.pScreen, exposures, &box);
+ REGION_UNION( pWin->drawable.pScreen, prgn, prgn, exposures);
+ }
+ /* PaintWindowBackground doesn't clip, so we have to */
+ REGION_INTERSECT( pWin->drawable.pScreen, prgn, prgn, &pWin->clipList);
+ /* need to clear out new areas of backing store, too */
+ if (pWin->backStorage)
+ (void) (* pWin->drawable.pScreen->ClearBackingStore)(
+ pWin,
+ box.x1 - pWin->drawable.x,
+ box.y1 - pWin->drawable.y,
+ box.x2 - box.x1,
+ box.y2 - box.y1,
+ FALSE);
+ }
+ if (prgn && !REGION_NIL(prgn))
+ (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, prgn, PW_BACKGROUND);
+ if (clientInterested && exposures && !REGION_NIL(exposures))
+ miSendExposures(pWin, exposures,
+ pWin->drawable.x, pWin->drawable.y);
+ if (exposures == &expRec)
+ {
+ REGION_UNINIT( pWin->drawable.pScreen, exposures);
+ }
+ else if (exposures && exposures != prgn && exposures != other_exposed)
+ REGION_DESTROY( pWin->drawable.pScreen, exposures);
+ if (prgn)
+ REGION_EMPTY( pWin->drawable.pScreen, prgn);
+ }
+ else if (exposures && exposures != prgn)
+ REGION_DESTROY( pWin->drawable.pScreen, exposures);
+}
+
+
+/*
+ this code is highly unlikely. it is not haile selassie.
+
+ there is some hair here. we can't just use the window's
+clip region as it is, because if we are painting the border,
+the border is not in the client area and so we will be excluded
+when we validate the GC, and if we are painting a parent-relative
+background, the area we want to paint is in some other window.
+since we trust the code calling us to tell us to paint only areas
+that are really ours, we will temporarily give the window a
+clipList the size of the whole screen and an origin at (0,0).
+this more or less assumes that ddX code will do translation
+based on the window's absolute position, and that ValidateGC will
+look at clipList, and that no other fields from the
+window will be used. it's not possible to just draw
+in the root because it may be a different depth.
+
+to get the tile to align correctly we set the GC's tile origin to
+be the (x,y) of the window's upper left corner, after which we
+get the right bits when drawing into the root.
+
+because the clip_mask is being set to None, we may call DoChangeGC with
+fPointer set true, thus we no longer need to install the background or
+border tile in the resource table.
+*/
+
+static RESTYPE ResType = 0;
+static int numGCs = 0;
+static GCPtr screenContext[MAXSCREENS];
+
+/*ARGSUSED*/
+static int
+tossGC (
+ pointer value,
+ XID id)
+{
+ GCPtr pGC = (GCPtr)value;
+ screenContext[pGC->pScreen->myNum] = (GCPtr)NULL;
+ FreeGC (pGC, id);
+ numGCs--;
+ if (!numGCs)
+ ResType = 0;
+
+ return 0;
+}
+
+
+void
+miPaintWindow(pWin, prgn, what)
+register WindowPtr pWin;
+RegionPtr prgn;
+int what;
+{
+ int status;
+
+ Bool usingScratchGC = FALSE;
+ WindowPtr pRoot;
+
+#define FUNCTION 0
+#define FOREGROUND 1
+#define TILE 2
+#define FILLSTYLE 3
+#define ABSX 4
+#define ABSY 5
+#define CLIPMASK 6
+#define SUBWINDOW 7
+#define COUNT_BITS 8
+
+ ChangeGCVal gcval[7];
+ ChangeGCVal newValues [COUNT_BITS];
+
+ BITS32 gcmask, index, mask;
+ RegionRec prgnWin;
+ DDXPointRec oldCorner;
+ BoxRec box;
+ WindowPtr pBgWin;
+ GCPtr pGC;
+ register int i;
+ register BoxPtr pbox;
+ register ScreenPtr pScreen = pWin->drawable.pScreen;
+ register xRectangle *prect;
+ int numRects;
+
+ gcmask = 0;
+
+ if (what == PW_BACKGROUND)
+ {
+ switch (pWin->backgroundState) {
+ case None:
+ return;
+ case ParentRelative:
+ (*pWin->parent->drawable.pScreen->PaintWindowBackground)(pWin->parent, prgn, what);
+ return;
+ case BackgroundPixel:
+ newValues[FOREGROUND].val = pWin->background.pixel;
+ newValues[FILLSTYLE].val = FillSolid;
+ gcmask |= GCForeground | GCFillStyle;
+ break;
+ case BackgroundPixmap:
+ newValues[TILE].ptr = (pointer)pWin->background.pixmap;
+ newValues[FILLSTYLE].val = FillTiled;
+ gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
+ break;
+ }
+ }
+ else
+ {
+ if (pWin->borderIsPixel)
+ {
+ newValues[FOREGROUND].val = pWin->border.pixel;
+ newValues[FILLSTYLE].val = FillSolid;
+ gcmask |= GCForeground | GCFillStyle;
+ }
+ else
+ {
+ newValues[TILE].ptr = (pointer)pWin->border.pixmap;
+ newValues[FILLSTYLE].val = FillTiled;
+ gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
+ }
+ }
+
+ prect = (xRectangle *)ALLOCATE_LOCAL(REGION_NUM_RECTS(prgn) *
+ sizeof(xRectangle));
+ if (!prect)
+ return;
+
+ newValues[FUNCTION].val = GXcopy;
+ gcmask |= GCFunction | GCClipMask;
+
+ i = pScreen->myNum;
+ pRoot = WindowTable[i];
+
+ pBgWin = pWin;
+ if (what == PW_BORDER)
+ {
+ while (pBgWin->backgroundState == ParentRelative)
+ pBgWin = pBgWin->parent;
+ }
+
+ if ((pWin->drawable.depth != pRoot->drawable.depth) ||
+ (pWin->drawable.bitsPerPixel != pRoot->drawable.bitsPerPixel))
+ {
+ usingScratchGC = TRUE;
+ pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
+ if (!pGC)
+ {
+ DEALLOCATE_LOCAL(prect);
+ return;
+ }
+ /*
+ * mash the clip list so we can paint the border by
+ * mangling the window in place, pretending it
+ * spans the entire screen
+ */
+ if (what == PW_BORDER)
+ {
+ prgnWin = pWin->clipList;
+ oldCorner.x = pWin->drawable.x;
+ oldCorner.y = pWin->drawable.y;
+ pWin->drawable.x = pWin->drawable.y = 0;
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pScreen->width;
+ box.y2 = pScreen->height;
+ REGION_INIT(pScreen, &pWin->clipList, &box, 1);
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ newValues[ABSX].val = pBgWin->drawable.x;
+ newValues[ABSY].val = pBgWin->drawable.y;
+ }
+ else
+ {
+ newValues[ABSX].val = 0;
+ newValues[ABSY].val = 0;
+ }
+ } else {
+ /*
+ * draw the background to the root window
+ */
+ if (screenContext[i] == (GCPtr)NULL)
+ {
+ if (!ResType && !(ResType = CreateNewResourceType(tossGC)))
+ return;
+ screenContext[i] = CreateGC((DrawablePtr)pWin, (BITS32) 0,
+ (XID *)NULL, &status);
+ if (!screenContext[i])
+ return;
+ numGCs++;
+ if (!AddResource(FakeClientID(0), ResType,
+ (pointer)screenContext[i]))
+ return;
+ }
+ pGC = screenContext[i];
+ newValues[SUBWINDOW].val = IncludeInferiors;
+ newValues[ABSX].val = pBgWin->drawable.x;
+ newValues[ABSY].val = pBgWin->drawable.y;
+ gcmask |= GCSubwindowMode;
+ pWin = pRoot;
+ }
+
+ if (pWin->backStorage)
+ (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack);
+
+ mask = gcmask;
+ gcmask = 0;
+ i = 0;
+ while (mask) {
+ index = lowbit (mask);
+ mask &= ~index;
+ switch (index) {
+ case GCFunction:
+ if (pGC->alu != newValues[FUNCTION].val) {
+ gcmask |= index;
+ gcval[i++].val = newValues[FUNCTION].val;
+ }
+ break;
+ case GCTileStipXOrigin:
+ if ( pGC->patOrg.x != newValues[ABSX].val) {
+ gcmask |= index;
+ gcval[i++].val = newValues[ABSX].val;
+ }
+ break;
+ case GCTileStipYOrigin:
+ if ( pGC->patOrg.y != newValues[ABSY].val) {
+ gcmask |= index;
+ gcval[i++].val = newValues[ABSY].val;
+ }
+ break;
+ case GCClipMask:
+ if ( pGC->clientClipType != CT_NONE) {
+ gcmask |= index;
+ gcval[i++].val = CT_NONE;
+ }
+ break;
+ case GCSubwindowMode:
+ if ( pGC->subWindowMode != newValues[SUBWINDOW].val) {
+ gcmask |= index;
+ gcval[i++].val = newValues[SUBWINDOW].val;
+ }
+ break;
+ case GCTile:
+ if (pGC->tileIsPixel || pGC->tile.pixmap != newValues[TILE].ptr)
+ {
+ gcmask |= index;
+ gcval[i++].ptr = newValues[TILE].ptr;
+ }
+ break;
+ case GCFillStyle:
+ if ( pGC->fillStyle != newValues[FILLSTYLE].val) {
+ gcmask |= index;
+ gcval[i++].val = newValues[FILLSTYLE].val;
+ }
+ break;
+ case GCForeground:
+ if ( pGC->fgPixel != newValues[FOREGROUND].val) {
+ gcmask |= index;
+ gcval[i++].val = newValues[FOREGROUND].val;
+ }
+ break;
+ }
+ }
+
+ if (gcmask)
+ dixChangeGC(NullClient, pGC, gcmask, NULL, gcval);
+
+ if (pWin->drawable.serialNumber != pGC->serialNumber)
+ ValidateGC((DrawablePtr)pWin, pGC);
+
+ numRects = REGION_NUM_RECTS(prgn);
+ pbox = REGION_RECTS(prgn);
+ for (i= numRects; --i >= 0; pbox++, prect++)
+ {
+ prect->x = pbox->x1 - pWin->drawable.x;
+ prect->y = pbox->y1 - pWin->drawable.y;
+ prect->width = pbox->x2 - pbox->x1;
+ prect->height = pbox->y2 - pbox->y1;
+ }
+ prect -= numRects;
+ (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
+ DEALLOCATE_LOCAL(prect);
+
+ if (pWin->backStorage)
+ (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeNothing);
+
+ if (usingScratchGC)
+ {
+ if (what == PW_BORDER)
+ {
+ REGION_UNINIT(pScreen, &pWin->clipList);
+ pWin->clipList = prgnWin;
+ pWin->drawable.x = oldCorner.x;
+ pWin->drawable.y = oldCorner.y;
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ }
+ FreeScratchGC(pGC);
+ }
+}
+
+
+/* MICLEARDRAWABLE -- sets the entire drawable to the background color of
+ * the GC. Useful when we have a scratch drawable and need to initialize
+ * it. */
+void
+miClearDrawable(pDraw, pGC)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+{
+ XID fg = pGC->fgPixel;
+ XID bg = pGC->bgPixel;
+ xRectangle rect;
+
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = pDraw->width;
+ rect.height = pDraw->height;
+ DoChangeGC(pGC, GCForeground, &bg, 0);
+ ValidateGC(pDraw, pGC);
+ (*pGC->ops->PolyFillRect)(pDraw, pGC, 1, &rect);
+ DoChangeGC(pGC, GCForeground, &fg, 0);
+ ValidateGC(pDraw, pGC);
+}
diff --git a/nx-X11/programs/Xserver/mi/mifillarc.c b/nx-X11/programs/Xserver/mi/mifillarc.c
new file mode 100644
index 000000000..0dcf25d05
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mifillarc.c
@@ -0,0 +1,817 @@
+/* $XFree86: xc/programs/Xserver/mi/mifillarc.c,v 3.7 2001/12/14 20:00:22 dawes Exp $ */
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Author: Bob Scheifler, MIT X Consortium
+
+********************************************************/
+
+/* $Xorg: mifillarc.c,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <math.h>
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "mifpoly.h"
+#include "mi.h"
+#include "mifillarc.h"
+
+#define QUADRANT (90 * 64)
+#define HALFCIRCLE (180 * 64)
+#define QUADRANT3 (270 * 64)
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+#define Dsin(d) sin((double)d*(M_PI/11520.0))
+#define Dcos(d) cos((double)d*(M_PI/11520.0))
+
+void
+miFillArcSetup(arc, info)
+ register xArc *arc;
+ register miFillArcRec *info;
+{
+ info->y = arc->height >> 1;
+ info->dy = arc->height & 1;
+ info->yorg = arc->y + info->y;
+ info->dx = arc->width & 1;
+ info->xorg = arc->x + (arc->width >> 1) + info->dx;
+ info->dx = 1 - info->dx;
+ if (arc->width == arc->height)
+ {
+ /* (2x - 2xorg)^2 = d^2 - (2y - 2yorg)^2 */
+ /* even: xorg = yorg = 0 odd: xorg = .5, yorg = -.5 */
+ info->ym = 8;
+ info->xm = 8;
+ info->yk = info->y << 3;
+ if (!info->dx)
+ {
+ info->xk = 0;
+ info->e = -1;
+ }
+ else
+ {
+ info->y++;
+ info->yk += 4;
+ info->xk = -4;
+ info->e = - (info->y << 3);
+ }
+ }
+ else
+ {
+ /* h^2 * (2x - 2xorg)^2 = w^2 * h^2 - w^2 * (2y - 2yorg)^2 */
+ /* even: xorg = yorg = 0 odd: xorg = .5, yorg = -.5 */
+ info->ym = (arc->width * arc->width) << 3;
+ info->xm = (arc->height * arc->height) << 3;
+ info->yk = info->y * info->ym;
+ if (!info->dy)
+ info->yk -= info->ym >> 1;
+ if (!info->dx)
+ {
+ info->xk = 0;
+ info->e = - (info->xm >> 3);
+ }
+ else
+ {
+ info->y++;
+ info->yk += info->ym;
+ info->xk = -(info->xm >> 1);
+ info->e = info->xk - info->yk;
+ }
+ }
+}
+
+void
+miFillArcDSetup(arc, info)
+ register xArc *arc;
+ register miFillArcDRec *info;
+{
+ /* h^2 * (2x - 2xorg)^2 = w^2 * h^2 - w^2 * (2y - 2yorg)^2 */
+ /* even: xorg = yorg = 0 odd: xorg = .5, yorg = -.5 */
+ info->y = arc->height >> 1;
+ info->dy = arc->height & 1;
+ info->yorg = arc->y + info->y;
+ info->dx = arc->width & 1;
+ info->xorg = arc->x + (arc->width >> 1) + info->dx;
+ info->dx = 1 - info->dx;
+ info->ym = ((double)arc->width) * (arc->width * 8);
+ info->xm = ((double)arc->height) * (arc->height * 8);
+ info->yk = info->y * info->ym;
+ if (!info->dy)
+ info->yk -= info->ym / 2.0;
+ if (!info->dx)
+ {
+ info->xk = 0;
+ info->e = - (info->xm / 8.0);
+ }
+ else
+ {
+ info->y++;
+ info->yk += info->ym;
+ info->xk = -info->xm / 2.0;
+ info->e = info->xk - info->yk;
+ }
+}
+
+static void
+miGetArcEdge(
+ register xArc *arc,
+ register miSliceEdgePtr edge,
+ int k,
+ Bool top,
+ Bool left )
+{
+ register int xady, y;
+
+ y = arc->height >> 1;
+ if (!(arc->width & 1))
+ y++;
+ if (!top)
+ {
+ y = -y;
+ if (arc->height & 1)
+ y--;
+ }
+ xady = k + y * edge->dx;
+ if (xady <= 0)
+ edge->x = - ((-xady) / edge->dy + 1);
+ else
+ edge->x = (xady - 1) / edge->dy;
+ edge->e = xady - edge->x * edge->dy;
+ if ((top && (edge->dx < 0)) || (!top && (edge->dx > 0)))
+ edge->e = edge->dy - edge->e + 1;
+ if (left)
+ edge->x++;
+ edge->x += arc->x + (arc->width >> 1);
+ if (edge->dx > 0)
+ {
+ edge->deltax = 1;
+ edge->stepx = edge->dx / edge->dy;
+ edge->dx = edge->dx % edge->dy;
+ }
+ else
+ {
+ edge->deltax = -1;
+ edge->stepx = - ((-edge->dx) / edge->dy);
+ edge->dx = (-edge->dx) % edge->dy;
+ }
+ if (!top)
+ {
+ edge->deltax = -edge->deltax;
+ edge->stepx = -edge->stepx;
+ }
+}
+
+void
+miEllipseAngleToSlope (angle, width, height, dxp, dyp, d_dxp, d_dyp)
+ int angle;
+ int width;
+ int height;
+ int *dxp;
+ int *dyp;
+ double *d_dxp;
+ double *d_dyp;
+{
+ int dx, dy;
+ double d_dx, d_dy, scale;
+ Bool negative_dx, negative_dy;
+
+ switch (angle) {
+ case 0:
+ *dxp = -1;
+ *dyp = 0;
+ if (d_dxp) {
+ *d_dxp = width / 2.0;
+ *d_dyp = 0;
+ }
+ break;
+ case QUADRANT:
+ *dxp = 0;
+ *dyp = 1;
+ if (d_dxp) {
+ *d_dxp = 0;
+ *d_dyp = - height / 2.0;
+ }
+ break;
+ case HALFCIRCLE:
+ *dxp = 1;
+ *dyp = 0;
+ if (d_dxp) {
+ *d_dxp = - width / 2.0;
+ *d_dyp = 0;
+ }
+ break;
+ case QUADRANT3:
+ *dxp = 0;
+ *dyp = -1;
+ if (d_dxp) {
+ *d_dxp = 0;
+ *d_dyp = height / 2.0;
+ }
+ break;
+ default:
+ d_dx = Dcos(angle) * width;
+ d_dy = Dsin(angle) * height;
+ if (d_dxp) {
+ *d_dxp = d_dx / 2.0;
+ *d_dyp = - d_dy / 2.0;
+ }
+ negative_dx = FALSE;
+ if (d_dx < 0.0)
+ {
+ d_dx = -d_dx;
+ negative_dx = TRUE;
+ }
+ negative_dy = FALSE;
+ if (d_dy < 0.0)
+ {
+ d_dy = -d_dy;
+ negative_dy = TRUE;
+ }
+ scale = d_dx;
+ if (d_dy > d_dx)
+ scale = d_dy;
+ dx = floor ((d_dx * 32768) / scale + 0.5);
+ if (negative_dx)
+ dx = -dx;
+ *dxp = dx;
+ dy = floor ((d_dy * 32768) / scale + 0.5);
+ if (negative_dy)
+ dy = -dy;
+ *dyp = dy;
+ break;
+ }
+}
+
+static void
+miGetPieEdge(
+ register xArc *arc,
+ register int angle,
+ register miSliceEdgePtr edge,
+ Bool top,
+ Bool left )
+{
+ register int k;
+ int dx, dy;
+
+ miEllipseAngleToSlope (angle, arc->width, arc->height, &dx, &dy, 0, 0);
+
+ if (dy == 0)
+ {
+ edge->x = left ? -65536 : 65536;
+ edge->stepx = 0;
+ edge->e = 0;
+ edge->dx = -1;
+ return;
+ }
+ if (dx == 0)
+ {
+ edge->x = arc->x + (arc->width >> 1);
+ if (left && (arc->width & 1))
+ edge->x++;
+ else if (!left && !(arc->width & 1))
+ edge->x--;
+ edge->stepx = 0;
+ edge->e = 0;
+ edge->dx = -1;
+ return;
+ }
+ if (dy < 0) {
+ dx = -dx;
+ dy = -dy;
+ }
+ k = (arc->height & 1) ? dx : 0;
+ if (arc->width & 1)
+ k += dy;
+ edge->dx = dx << 1;
+ edge->dy = dy << 1;
+ miGetArcEdge(arc, edge, k, top, left);
+}
+
+void
+miFillArcSliceSetup(arc, slice, pGC)
+ register xArc *arc;
+ register miArcSliceRec *slice;
+ GCPtr pGC;
+{
+ register int angle1, angle2;
+
+ angle1 = arc->angle1;
+ if (arc->angle2 < 0)
+ {
+ angle2 = angle1;
+ angle1 += arc->angle2;
+ }
+ else
+ angle2 = angle1 + arc->angle2;
+ while (angle1 < 0)
+ angle1 += FULLCIRCLE;
+ while (angle1 >= FULLCIRCLE)
+ angle1 -= FULLCIRCLE;
+ while (angle2 < 0)
+ angle2 += FULLCIRCLE;
+ while (angle2 >= FULLCIRCLE)
+ angle2 -= FULLCIRCLE;
+ slice->min_top_y = 0;
+ slice->max_top_y = arc->height >> 1;
+ slice->min_bot_y = 1 - (arc->height & 1);
+ slice->max_bot_y = slice->max_top_y - 1;
+ slice->flip_top = FALSE;
+ slice->flip_bot = FALSE;
+ if (pGC->arcMode == ArcPieSlice)
+ {
+ slice->edge1_top = (angle1 < HALFCIRCLE);
+ slice->edge2_top = (angle2 <= HALFCIRCLE);
+ if ((angle2 == 0) || (angle1 == HALFCIRCLE))
+ {
+ if (angle2 ? slice->edge2_top : slice->edge1_top)
+ slice->min_top_y = slice->min_bot_y;
+ else
+ slice->min_top_y = arc->height;
+ slice->min_bot_y = 0;
+ }
+ else if ((angle1 == 0) || (angle2 == HALFCIRCLE))
+ {
+ slice->min_top_y = slice->min_bot_y;
+ if (angle1 ? slice->edge1_top : slice->edge2_top)
+ slice->min_bot_y = arc->height;
+ else
+ slice->min_bot_y = 0;
+ }
+ else if (slice->edge1_top == slice->edge2_top)
+ {
+ if (angle2 < angle1)
+ {
+ slice->flip_top = slice->edge1_top;
+ slice->flip_bot = !slice->edge1_top;
+ }
+ else if (slice->edge1_top)
+ {
+ slice->min_top_y = 1;
+ slice->min_bot_y = arc->height;
+ }
+ else
+ {
+ slice->min_bot_y = 0;
+ slice->min_top_y = arc->height;
+ }
+ }
+ miGetPieEdge(arc, angle1, &slice->edge1,
+ slice->edge1_top, !slice->edge1_top);
+ miGetPieEdge(arc, angle2, &slice->edge2,
+ slice->edge2_top, slice->edge2_top);
+ }
+ else
+ {
+ double w2, h2, x1, y1, x2, y2, dx, dy, scale;
+ int signdx, signdy, y, k;
+ Bool isInt1 = TRUE, isInt2 = TRUE;
+
+ w2 = (double)arc->width / 2.0;
+ h2 = (double)arc->height / 2.0;
+ if ((angle1 == 0) || (angle1 == HALFCIRCLE))
+ {
+ x1 = angle1 ? -w2 : w2;
+ y1 = 0.0;
+ }
+ else if ((angle1 == QUADRANT) || (angle1 == QUADRANT3))
+ {
+ x1 = 0.0;
+ y1 = (angle1 == QUADRANT) ? h2 : -h2;
+ }
+ else
+ {
+ isInt1 = FALSE;
+ x1 = Dcos(angle1) * w2;
+ y1 = Dsin(angle1) * h2;
+ }
+ if ((angle2 == 0) || (angle2 == HALFCIRCLE))
+ {
+ x2 = angle2 ? -w2 : w2;
+ y2 = 0.0;
+ }
+ else if ((angle2 == QUADRANT) || (angle2 == QUADRANT3))
+ {
+ x2 = 0.0;
+ y2 = (angle2 == QUADRANT) ? h2 : -h2;
+ }
+ else
+ {
+ isInt2 = FALSE;
+ x2 = Dcos(angle2) * w2;
+ y2 = Dsin(angle2) * h2;
+ }
+ dx = x2 - x1;
+ dy = y2 - y1;
+ if (arc->height & 1)
+ {
+ y1 -= 0.5;
+ y2 -= 0.5;
+ }
+ if (arc->width & 1)
+ {
+ x1 += 0.5;
+ x2 += 0.5;
+ }
+ if (dy < 0.0)
+ {
+ dy = -dy;
+ signdy = -1;
+ }
+ else
+ signdy = 1;
+ if (dx < 0.0)
+ {
+ dx = -dx;
+ signdx = -1;
+ }
+ else
+ signdx = 1;
+ if (isInt1 && isInt2)
+ {
+ slice->edge1.dx = dx * 2;
+ slice->edge1.dy = dy * 2;
+ }
+ else
+ {
+ scale = (dx > dy) ? dx : dy;
+ slice->edge1.dx = floor((dx * 32768) / scale + .5);
+ slice->edge1.dy = floor((dy * 32768) / scale + .5);
+ }
+ if (!slice->edge1.dy)
+ {
+ if (signdx < 0)
+ {
+ y = floor(y1 + 1.0);
+ if (y >= 0)
+ {
+ slice->min_top_y = y;
+ slice->min_bot_y = arc->height;
+ }
+ else
+ {
+ slice->max_bot_y = -y - (arc->height & 1);
+ }
+ }
+ else
+ {
+ y = floor(y1);
+ if (y >= 0)
+ slice->max_top_y = y;
+ else
+ {
+ slice->min_top_y = arc->height;
+ slice->min_bot_y = -y - (arc->height & 1);
+ }
+ }
+ slice->edge1_top = TRUE;
+ slice->edge1.x = 65536;
+ slice->edge1.stepx = 0;
+ slice->edge1.e = 0;
+ slice->edge1.dx = -1;
+ slice->edge2 = slice->edge1;
+ slice->edge2_top = FALSE;
+ }
+ else if (!slice->edge1.dx)
+ {
+ if (signdy < 0)
+ x1 -= 1.0;
+ slice->edge1.x = ceil(x1);
+ slice->edge1_top = signdy < 0;
+ slice->edge1.x += arc->x + (arc->width >> 1);
+ slice->edge1.stepx = 0;
+ slice->edge1.e = 0;
+ slice->edge1.dx = -1;
+ slice->edge2_top = !slice->edge1_top;
+ slice->edge2 = slice->edge1;
+ }
+ else
+ {
+ if (signdx < 0)
+ slice->edge1.dx = -slice->edge1.dx;
+ if (signdy < 0)
+ slice->edge1.dx = -slice->edge1.dx;
+ k = ceil(((x1 + x2) * slice->edge1.dy - (y1 + y2) * slice->edge1.dx) / 2.0);
+ slice->edge2.dx = slice->edge1.dx;
+ slice->edge2.dy = slice->edge1.dy;
+ slice->edge1_top = signdy < 0;
+ slice->edge2_top = !slice->edge1_top;
+ miGetArcEdge(arc, &slice->edge1, k,
+ slice->edge1_top, !slice->edge1_top);
+ miGetArcEdge(arc, &slice->edge2, k,
+ slice->edge2_top, slice->edge2_top);
+ }
+ }
+}
+
+#define ADDSPANS() \
+ pts->x = xorg - x; \
+ pts->y = yorg - y; \
+ *wids = slw; \
+ pts++; \
+ wids++; \
+ if (miFillArcLower(slw)) \
+ { \
+ pts->x = xorg - x; \
+ pts->y = yorg + y + dy; \
+ pts++; \
+ *wids++ = slw; \
+ }
+
+static void
+miFillEllipseI(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ xArc *arc )
+{
+ register int x, y, e;
+ int yk, xk, ym, xm, dx, dy, xorg, yorg;
+ int slw;
+ miFillArcRec info;
+ DDXPointPtr points;
+ register DDXPointPtr pts;
+ int *widths;
+ register int *wids;
+
+ points = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * arc->height);
+ if (!points)
+ return;
+ widths = (int *)ALLOCATE_LOCAL(sizeof(int) * arc->height);
+ if (!widths)
+ {
+ DEALLOCATE_LOCAL(points);
+ return;
+ }
+ miFillArcSetup(arc, &info);
+ MIFILLARCSETUP();
+ if (pGC->miTranslate)
+ {
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ }
+ pts = points;
+ wids = widths;
+ while (y > 0)
+ {
+ MIFILLARCSTEP(slw);
+ ADDSPANS();
+ }
+ (*pGC->ops->FillSpans)(pDraw, pGC, pts - points, points, widths, FALSE);
+ DEALLOCATE_LOCAL(widths);
+ DEALLOCATE_LOCAL(points);
+}
+
+static void
+miFillEllipseD(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ xArc *arc )
+{
+ register int x, y;
+ int xorg, yorg, dx, dy, slw;
+ double e, yk, xk, ym, xm;
+ miFillArcDRec info;
+ DDXPointPtr points;
+ register DDXPointPtr pts;
+ int *widths;
+ register int *wids;
+
+ points = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * arc->height);
+ if (!points)
+ return;
+ widths = (int *)ALLOCATE_LOCAL(sizeof(int) * arc->height);
+ if (!widths)
+ {
+ DEALLOCATE_LOCAL(points);
+ return;
+ }
+ miFillArcDSetup(arc, &info);
+ MIFILLARCSETUP();
+ if (pGC->miTranslate)
+ {
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ }
+ pts = points;
+ wids = widths;
+ while (y > 0)
+ {
+ MIFILLARCSTEP(slw);
+ ADDSPANS();
+ }
+ (*pGC->ops->FillSpans)(pDraw, pGC, pts - points, points, widths, FALSE);
+ DEALLOCATE_LOCAL(widths);
+ DEALLOCATE_LOCAL(points);
+}
+
+#define ADDSPAN(l,r) \
+ if (r >= l) \
+ { \
+ pts->x = l; \
+ pts->y = ya; \
+ pts++; \
+ *wids++ = r - l + 1; \
+ }
+
+#define ADDSLICESPANS(flip) \
+ if (!flip) \
+ { \
+ ADDSPAN(xl, xr); \
+ } \
+ else \
+ { \
+ xc = xorg - x; \
+ ADDSPAN(xc, xr); \
+ xc += slw - 1; \
+ ADDSPAN(xl, xc); \
+ }
+
+static void
+miFillArcSliceI(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ xArc *arc )
+{
+ int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
+ register int x, y, e;
+ miFillArcRec info;
+ miArcSliceRec slice;
+ int ya, xl, xr, xc;
+ DDXPointPtr points;
+ register DDXPointPtr pts;
+ int *widths;
+ register int *wids;
+
+ miFillArcSetup(arc, &info);
+ miFillArcSliceSetup(arc, &slice, pGC);
+ MIFILLARCSETUP();
+ slw = arc->height;
+ if (slice.flip_top || slice.flip_bot)
+ slw += (arc->height >> 1) + 1;
+ points = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * slw);
+ if (!points)
+ return;
+ widths = (int *)ALLOCATE_LOCAL(sizeof(int) * slw);
+ if (!widths)
+ {
+ DEALLOCATE_LOCAL(points);
+ return;
+ }
+ if (pGC->miTranslate)
+ {
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ slice.edge1.x += pDraw->x;
+ slice.edge2.x += pDraw->x;
+ }
+ pts = points;
+ wids = widths;
+ while (y > 0)
+ {
+ MIFILLARCSTEP(slw);
+ MIARCSLICESTEP(slice.edge1);
+ MIARCSLICESTEP(slice.edge2);
+ if (miFillSliceUpper(slice))
+ {
+ ya = yorg - y;
+ MIARCSLICEUPPER(xl, xr, slice, slw);
+ ADDSLICESPANS(slice.flip_top);
+ }
+ if (miFillSliceLower(slice))
+ {
+ ya = yorg + y + dy;
+ MIARCSLICELOWER(xl, xr, slice, slw);
+ ADDSLICESPANS(slice.flip_bot);
+ }
+ }
+ (*pGC->ops->FillSpans)(pDraw, pGC, pts - points, points, widths, FALSE);
+ DEALLOCATE_LOCAL(widths);
+ DEALLOCATE_LOCAL(points);
+}
+
+static void
+miFillArcSliceD(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ xArc *arc )
+{
+ register int x, y;
+ int dx, dy, xorg, yorg, slw;
+ double e, yk, xk, ym, xm;
+ miFillArcDRec info;
+ miArcSliceRec slice;
+ int ya, xl, xr, xc;
+ DDXPointPtr points;
+ register DDXPointPtr pts;
+ int *widths;
+ register int *wids;
+
+ miFillArcDSetup(arc, &info);
+ miFillArcSliceSetup(arc, &slice, pGC);
+ MIFILLARCSETUP();
+ slw = arc->height;
+ if (slice.flip_top || slice.flip_bot)
+ slw += (arc->height >> 1) + 1;
+ points = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * slw);
+ if (!points)
+ return;
+ widths = (int *)ALLOCATE_LOCAL(sizeof(int) * slw);
+ if (!widths)
+ {
+ DEALLOCATE_LOCAL(points);
+ return;
+ }
+ if (pGC->miTranslate)
+ {
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ slice.edge1.x += pDraw->x;
+ slice.edge2.x += pDraw->x;
+ }
+ pts = points;
+ wids = widths;
+ while (y > 0)
+ {
+ MIFILLARCSTEP(slw);
+ MIARCSLICESTEP(slice.edge1);
+ MIARCSLICESTEP(slice.edge2);
+ if (miFillSliceUpper(slice))
+ {
+ ya = yorg - y;
+ MIARCSLICEUPPER(xl, xr, slice, slw);
+ ADDSLICESPANS(slice.flip_top);
+ }
+ if (miFillSliceLower(slice))
+ {
+ ya = yorg + y + dy;
+ MIARCSLICELOWER(xl, xr, slice, slw);
+ ADDSLICESPANS(slice.flip_bot);
+ }
+ }
+ (*pGC->ops->FillSpans)(pDraw, pGC, pts - points, points, widths, FALSE);
+ DEALLOCATE_LOCAL(widths);
+ DEALLOCATE_LOCAL(points);
+}
+
+/* MIPOLYFILLARC -- The public entry for the PolyFillArc request.
+ * Since we don't have to worry about overlapping segments, we can just
+ * fill each arc as it comes.
+ */
+void
+miPolyFillArc(pDraw, pGC, narcs, parcs)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int narcs;
+ xArc *parcs;
+{
+ register int i;
+ register xArc *arc;
+
+ for(i = narcs, arc = parcs; --i >= 0; arc++)
+ {
+ if (miFillArcEmpty(arc))
+ continue;;
+ if ((arc->angle2 >= FULLCIRCLE) || (arc->angle2 <= -FULLCIRCLE))
+ {
+ if (miCanFillArc(arc))
+ miFillEllipseI(pDraw, pGC, arc);
+ else
+ miFillEllipseD(pDraw, pGC, arc);
+ }
+ else
+ {
+ if (miCanFillArc(arc))
+ miFillArcSliceI(pDraw, pGC, arc);
+ else
+ miFillArcSliceD(pDraw, pGC, arc);
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/mi/mifillarc.h b/nx-X11/programs/Xserver/mi/mifillarc.h
new file mode 100644
index 000000000..ff39bac1d
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mifillarc.h
@@ -0,0 +1,216 @@
+/* $XFree86: xc/programs/Xserver/mi/mifillarc.h,v 3.6 2001/10/25 12:03:47 alanh Exp $ */
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+********************************************************/
+
+/* $Xorg: mifillarc.h,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ */
+
+#ifndef __MIFILLARC_H__
+#define __MIFILLARC_H__
+
+#define FULLCIRCLE (360 * 64)
+
+typedef struct _miFillArc {
+ int xorg, yorg;
+ int y;
+ int dx, dy;
+ int e;
+ int ym, yk, xm, xk;
+} miFillArcRec;
+
+/* could use 64-bit integers */
+typedef struct _miFillArcD {
+ int xorg, yorg;
+ int y;
+ int dx, dy;
+ double e;
+ double ym, yk, xm, xk;
+} miFillArcDRec;
+
+#define miFillArcEmpty(arc) (!(arc)->angle2 || \
+ !(arc)->width || !(arc)->height || \
+ (((arc)->width == 1) && ((arc)->height & 1)))
+
+#define miCanFillArc(arc) (((arc)->width == (arc)->height) || \
+ (((arc)->width <= 800) && ((arc)->height <= 800)))
+
+#define MIFILLARCSETUP() \
+ x = 0; \
+ y = info.y; \
+ e = info.e; \
+ xk = info.xk; \
+ xm = info.xm; \
+ yk = info.yk; \
+ ym = info.ym; \
+ dx = info.dx; \
+ dy = info.dy; \
+ xorg = info.xorg; \
+ yorg = info.yorg
+
+#define MIFILLARCSTEP(slw) \
+ e += yk; \
+ while (e >= 0) \
+ { \
+ x++; \
+ xk -= xm; \
+ e += xk; \
+ } \
+ y--; \
+ yk -= ym; \
+ slw = (x << 1) + dx; \
+ if ((e == xk) && (slw > 1)) \
+ slw--
+
+#define MIFILLCIRCSTEP(slw) MIFILLARCSTEP(slw)
+#define MIFILLELLSTEP(slw) MIFILLARCSTEP(slw)
+
+#define miFillArcLower(slw) (((y + dy) != 0) && ((slw > 1) || (e != xk)))
+
+typedef struct _miSliceEdge {
+ int x;
+ int stepx;
+ int deltax;
+ int e;
+ int dy;
+ int dx;
+} miSliceEdgeRec, *miSliceEdgePtr;
+
+typedef struct _miArcSlice {
+ miSliceEdgeRec edge1, edge2;
+ int min_top_y, max_top_y;
+ int min_bot_y, max_bot_y;
+ Bool edge1_top, edge2_top;
+ Bool flip_top, flip_bot;
+} miArcSliceRec;
+
+#define MIARCSLICESTEP(edge) \
+ edge.x -= edge.stepx; \
+ edge.e -= edge.dx; \
+ if (edge.e <= 0) \
+ { \
+ edge.x -= edge.deltax; \
+ edge.e += edge.dy; \
+ }
+
+#define miFillSliceUpper(slice) \
+ ((y >= slice.min_top_y) && (y <= slice.max_top_y))
+
+#define miFillSliceLower(slice) \
+ ((y >= slice.min_bot_y) && (y <= slice.max_bot_y))
+
+#define MIARCSLICEUPPER(xl,xr,slice,slw) \
+ xl = xorg - x; \
+ xr = xl + slw - 1; \
+ if (slice.edge1_top && (slice.edge1.x < xr)) \
+ xr = slice.edge1.x; \
+ if (slice.edge2_top && (slice.edge2.x > xl)) \
+ xl = slice.edge2.x;
+
+#define MIARCSLICELOWER(xl,xr,slice,slw) \
+ xl = xorg - x; \
+ xr = xl + slw - 1; \
+ if (!slice.edge1_top && (slice.edge1.x > xl)) \
+ xl = slice.edge1.x; \
+ if (!slice.edge2_top && (slice.edge2.x < xr)) \
+ xr = slice.edge2.x;
+
+#define MIWIDEARCSETUP(x,y,dy,slw,e,xk,xm,yk,ym) \
+ x = 0; \
+ y = slw >> 1; \
+ yk = y << 3; \
+ xm = 8; \
+ ym = 8; \
+ if (dy) \
+ { \
+ xk = 0; \
+ if (slw & 1) \
+ e = -1; \
+ else \
+ e = -(y << 2) - 2; \
+ } \
+ else \
+ { \
+ y++; \
+ yk += 4; \
+ xk = -4; \
+ if (slw & 1) \
+ e = -(y << 2) - 3; \
+ else \
+ e = - (y << 3); \
+ }
+
+#define MIFILLINARCSTEP(slw) \
+ ine += inyk; \
+ while (ine >= 0) \
+ { \
+ inx++; \
+ inxk -= inxm; \
+ ine += inxk; \
+ } \
+ iny--; \
+ inyk -= inym; \
+ slw = (inx << 1) + dx; \
+ if ((ine == inxk) && (slw > 1)) \
+ slw--
+
+#define miFillInArcLower(slw) (((iny + dy) != 0) && \
+ ((slw > 1) || (ine != inxk)))
+
+extern int miFreeArcCache(
+ pointer /*data*/,
+ XID /*id*/
+);
+
+extern struct finalSpan *realAllocSpan(
+ void
+);
+
+extern void miFillArcSetup(
+ xArc * /*arc*/,
+ miFillArcRec * /*info*/
+);
+
+extern void miFillArcDSetup(
+ xArc * /*arc*/,
+ miFillArcDRec * /*info*/
+);
+
+extern void miEllipseAngleToSlope(
+ int /*angle*/,
+ int /*width*/,
+ int /*height*/,
+ int * /*dxp*/,
+ int * /*dyp*/,
+ double * /*d_dxp*/,
+ double * /*d_dyp*/
+);
+
+extern void miFillArcSliceSetup(
+ xArc * /*arc*/,
+ miArcSliceRec * /*slice*/,
+ GCPtr /*pGC*/
+);
+
+#endif /* __MIFILLARC_H__ */
diff --git a/nx-X11/programs/Xserver/mi/mifillrct.c b/nx-X11/programs/Xserver/mi/mifillrct.c
new file mode 100644
index 000000000..9f68db720
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mifillrct.c
@@ -0,0 +1,144 @@
+/* $XFree86: xc/programs/Xserver/mi/mifillrct.c,v 1.2 2001/05/29 22:24:06 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mifillrct.c,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmap.h"
+#include "mi.h"
+#include "misc.h"
+
+/* mi rectangles
+ written by newman, with debts to all and sundry
+*/
+
+/* MIPOLYFILLRECT -- public entry for PolyFillRect request
+ * very straight forward: translate rectangles if necessary
+ * then call FillSpans to fill each rectangle. We let FillSpans worry about
+ * clipping to the destination
+ */
+void
+miPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nrectFill; /* number of rectangles to fill */
+ xRectangle *prectInit; /* Pointer to first rectangle to fill */
+{
+ int i;
+ register int height;
+ register int width;
+ register xRectangle *prect;
+ int xorg;
+ register int yorg;
+ int maxheight;
+ DDXPointPtr pptFirst;
+ register DDXPointPtr ppt;
+ int *pwFirst;
+ register int *pw;
+
+ if (pGC->miTranslate)
+ {
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ prect = prectInit;
+ maxheight = 0;
+ for (i = 0; i<nrectFill; i++, prect++)
+ {
+ prect->x += xorg;
+ prect->y += yorg;
+ maxheight = max(maxheight, prect->height);
+ }
+ }
+ else
+ {
+ prect = prectInit;
+ maxheight = 0;
+ for (i = 0; i<nrectFill; i++, prect++)
+ maxheight = max(maxheight, prect->height);
+ }
+
+ pptFirst = (DDXPointPtr) ALLOCATE_LOCAL(maxheight * sizeof(DDXPointRec));
+ pwFirst = (int *) ALLOCATE_LOCAL(maxheight * sizeof(int));
+ if(!pptFirst || !pwFirst)
+ {
+ if (pwFirst) DEALLOCATE_LOCAL(pwFirst);
+ if (pptFirst) DEALLOCATE_LOCAL(pptFirst);
+ return;
+ }
+
+ prect = prectInit;
+ while(nrectFill--)
+ {
+ ppt = pptFirst;
+ pw = pwFirst;
+ height = prect->height;
+ width = prect->width;
+ xorg = prect->x;
+ yorg = prect->y;
+ while(height--)
+ {
+ *pw++ = width;
+ ppt->x = xorg;
+ ppt->y = yorg;
+ ppt++;
+ yorg++;
+ }
+ (* pGC->ops->FillSpans)(pDrawable, pGC,
+ prect->height, pptFirst, pwFirst,
+ 1);
+ prect++;
+ }
+ DEALLOCATE_LOCAL(pwFirst);
+ DEALLOCATE_LOCAL(pptFirst);
+}
diff --git a/nx-X11/programs/Xserver/mi/mifpoly.h b/nx-X11/programs/Xserver/mi/mifpoly.h
new file mode 100644
index 000000000..79f606b4d
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mifpoly.h
@@ -0,0 +1,111 @@
+/* $Xorg: mifpoly.h,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/mi/mifpoly.h,v 1.3 2001/10/25 12:03:47 alanh Exp $ */
+
+#ifndef __MIFPOLY_H__
+#define __MIFPOLY_H__
+
+#define EPSILON 0.000001
+#define ISEQUAL(a,b) (Fabs((a) - (b)) <= EPSILON)
+#define UNEQUAL(a,b) (Fabs((a) - (b)) > EPSILON)
+#define WITHINHALF(a, b) (((a) - (b) > 0.0) ? (a) - (b) < 0.5 : \
+ (b) - (a) <= 0.5)
+#define ROUNDTOINT(x) ((int) (((x) > 0.0) ? ((x) + 0.5) : ((x) - 0.5)))
+#define ISZERO(x) (Fabs((x)) <= EPSILON)
+#define PTISEQUAL(a,b) (ISEQUAL(a.x,b.x) && ISEQUAL(a.y,b.y))
+#define PTUNEQUAL(a,b) (UNEQUAL(a.x,b.x) || UNEQUAL(a.y,b.y))
+#define PtEqual(a, b) (((a).x == (b).x) && ((a).y == (b).y))
+
+#define NotEnd 0
+#define FirstEnd 1
+#define SecondEnd 2
+
+#define SQSECANT 108.856472512142 /* 1/sin^2(11/2) - for 11o miter cutoff */
+#define D2SECANT 5.21671526231167 /* 1/2*sin(11/2) - max extension per width */
+
+#ifdef NOINLINEICEIL
+#define ICEIL(x) ((int)ceil(x))
+#else
+#ifdef __GNUC__
+static __inline int ICEIL(double x)
+{
+ int _cTmp = x;
+ return ((x == _cTmp) || (x < 0.0)) ? _cTmp : _cTmp+1;
+}
+#else
+#define ICEIL(x) ((((x) == (_cTmp = (x))) || ((x) < 0.0)) ? _cTmp : _cTmp+1)
+#define ICEILTEMPDECL static int _cTmp;
+#endif
+#endif
+
+/* Point with sub-pixel positioning. In this case we use doubles, but
+ * see mifpolycon.c for other suggestions
+ */
+typedef struct _SppPoint {
+ double x, y;
+} SppPointRec, *SppPointPtr;
+
+typedef struct _SppArc {
+ double x, y, width, height;
+ double angle1, angle2;
+} SppArcRec, *SppArcPtr;
+
+/* mifpolycon.c */
+
+extern void miFillSppPoly(
+ DrawablePtr /*dst*/,
+ GCPtr /*pgc*/,
+ int /*count*/,
+ SppPointPtr /*ptsIn*/,
+ int /*xTrans*/,
+ int /*yTrans*/,
+ double /*xFtrans*/,
+ double /*yFtrans*/
+);
+
+#endif /* __MIFPOLY_H__ */
diff --git a/nx-X11/programs/Xserver/mi/mifpolycon.c b/nx-X11/programs/Xserver/mi/mifpolycon.c
new file mode 100644
index 000000000..40b83586f
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mifpolycon.c
@@ -0,0 +1,284 @@
+/* $XFree86: xc/programs/Xserver/mi/mifpolycon.c,v 1.2 2001/08/06 20:51:18 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mifpolycon.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <math.h>
+#include <X11/X.h>
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "mifpoly.h"
+
+static int GetFPolyYBounds(register SppPointPtr pts, int n, double yFtrans,
+ int *by, int *ty);
+
+#ifdef ICEILTEMPDECL
+ICEILTEMPDECL
+#endif
+
+/*
+ * Written by Todd Newman; April. 1987.
+ *
+ * Fill a convex polygon. If the given polygon
+ * is not convex, then the result is undefined.
+ * The algorithm is to order the edges from smallest
+ * y to largest by partitioning the array into a left
+ * edge list and a right edge list. The algorithm used
+ * to traverse each edge is digital differencing analyzer
+ * line algorithm with y as the major axis. There's some funny linear
+ * interpolation involved because of the subpixel postioning.
+ */
+void
+miFillSppPoly(dst, pgc, count, ptsIn, xTrans, yTrans, xFtrans, yFtrans)
+ DrawablePtr dst;
+ GCPtr pgc;
+ int count; /* number of points */
+ SppPointPtr ptsIn; /* the points */
+ int xTrans, yTrans; /* Translate each point by this */
+ double xFtrans, yFtrans; /* translate before conversion
+ by this amount. This provides
+ a mechanism to match rounding
+ errors with any shape that must
+ meet the polygon exactly.
+ */
+{
+ double xl = 0.0, xr = 0.0, /* x vals of left and right edges */
+ ml = 0.0, /* left edge slope */
+ mr = 0.0, /* right edge slope */
+ dy, /* delta y */
+ i; /* loop counter */
+ int y, /* current scanline */
+ j,
+ imin, /* index of vertex with smallest y */
+ ymin, /* y-extents of polygon */
+ ymax,
+ *width,
+ *FirstWidth, /* output buffer */
+ *Marked; /* set if this vertex has been used */
+ register int left, right, /* indices to first endpoints */
+ nextleft,
+ nextright; /* indices to second endpoints */
+ DDXPointPtr ptsOut,
+ FirstPoint; /* output buffer */
+
+ if (pgc->miTranslate)
+ {
+ xTrans += dst->x;
+ yTrans += dst->y;
+ }
+
+ imin = GetFPolyYBounds(ptsIn, count, yFtrans, &ymin, &ymax);
+
+ y = ymax - ymin + 1;
+ if ((count < 3) || (y <= 0))
+ return;
+ ptsOut = FirstPoint = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * y);
+ width = FirstWidth = (int *) ALLOCATE_LOCAL(sizeof(int) * y);
+ Marked = (int *) ALLOCATE_LOCAL(sizeof(int) * count);
+
+ if(!ptsOut || !width || !Marked)
+ {
+ if (Marked) DEALLOCATE_LOCAL(Marked);
+ if (width) DEALLOCATE_LOCAL(width);
+ if (ptsOut) DEALLOCATE_LOCAL(ptsOut);
+ return;
+ }
+
+ for(j = 0; j < count; j++)
+ Marked[j] = 0;
+ nextleft = nextright = imin;
+ Marked[imin] = -1;
+ y = ICEIL(ptsIn[nextleft].y + yFtrans);
+
+ /*
+ * loop through all edges of the polygon
+ */
+ do
+ {
+ /* add a left edge if we need to */
+ if ((y > (ptsIn[nextleft].y + yFtrans) ||
+ ISEQUAL(y, ptsIn[nextleft].y + yFtrans)) &&
+ Marked[nextleft] != 1)
+ {
+ Marked[nextleft]++;
+ left = nextleft++;
+
+ /* find the next edge, considering the end conditions */
+ if (nextleft >= count)
+ nextleft = 0;
+
+ /* now compute the starting point and slope */
+ dy = ptsIn[nextleft].y - ptsIn[left].y;
+ if (dy != 0.0)
+ {
+ ml = (ptsIn[nextleft].x - ptsIn[left].x) / dy;
+ dy = y - (ptsIn[left].y + yFtrans);
+ xl = (ptsIn[left].x + xFtrans) + ml * max(dy, 0);
+ }
+ }
+
+ /* add a right edge if we need to */
+ if ((y > ptsIn[nextright].y + yFtrans) ||
+ (ISEQUAL(y, ptsIn[nextright].y + yFtrans)
+ && Marked[nextright] != 1))
+ {
+ Marked[nextright]++;
+ right = nextright--;
+
+ /* find the next edge, considering the end conditions */
+ if (nextright < 0)
+ nextright = count - 1;
+
+ /* now compute the starting point and slope */
+ dy = ptsIn[nextright].y - ptsIn[right].y;
+ if (dy != 0.0)
+ {
+ mr = (ptsIn[nextright].x - ptsIn[right].x) / dy;
+ dy = y - (ptsIn[right].y + yFtrans);
+ xr = (ptsIn[right].x + xFtrans) + mr * max(dy, 0);
+ }
+ }
+
+
+ /*
+ * generate scans to fill while we still have
+ * a right edge as well as a left edge.
+ */
+ i = (min(ptsIn[nextleft].y, ptsIn[nextright].y) + yFtrans) - y;
+
+ if (i < EPSILON)
+ {
+ if(Marked[nextleft] && Marked[nextright])
+ {
+ /* Arrgh, we're trapped! (no more points)
+ * Out, we've got to get out of here before this decadence saps
+ * our will completely! */
+ break;
+ }
+ continue;
+ }
+ else
+ {
+ j = (int) i;
+ if(!j)
+ j++;
+ }
+ while (j > 0)
+ {
+ int cxl, cxr;
+
+ ptsOut->y = (y) + yTrans;
+
+ cxl = ICEIL(xl);
+ cxr = ICEIL(xr);
+ /* reverse the edges if necessary */
+ if (xl < xr)
+ {
+ *(width++) = cxr - cxl;
+ (ptsOut++)->x = cxl + xTrans;
+ }
+ else
+ {
+ *(width++) = cxl - cxr;
+ (ptsOut++)->x = cxr + xTrans;
+ }
+ y++;
+
+ /* increment down the edges */
+ xl += ml;
+ xr += mr;
+ j--;
+ }
+ } while (y <= ymax);
+
+ /* Finally, fill the spans we've collected */
+ (*pgc->ops->FillSpans)(dst, pgc,
+ ptsOut-FirstPoint, FirstPoint, FirstWidth, 1);
+ DEALLOCATE_LOCAL(Marked);
+ DEALLOCATE_LOCAL(FirstWidth);
+ DEALLOCATE_LOCAL(FirstPoint);
+}
+
+
+/* Find the index of the point with the smallest y.also return the
+ * smallest and largest y */
+static
+int
+GetFPolyYBounds(
+ register SppPointPtr pts,
+ int n,
+ double yFtrans,
+ int *by,
+ int *ty)
+{
+ register SppPointPtr ptMin;
+ double ymin, ymax;
+ SppPointPtr ptsStart = pts;
+
+ ptMin = pts;
+ ymin = ymax = (pts++)->y;
+
+ while (--n > 0) {
+ if (pts->y < ymin)
+ {
+ ptMin = pts;
+ ymin = pts->y;
+ }
+ if(pts->y > ymax)
+ ymax = pts->y;
+
+ pts++;
+ }
+
+ *by = ICEIL(ymin + yFtrans);
+ *ty = ICEIL(ymax + yFtrans - 1);
+ return(ptMin-ptsStart);
+}
diff --git a/nx-X11/programs/Xserver/mi/migc.c b/nx-X11/programs/Xserver/mi/migc.c
new file mode 100644
index 000000000..0cffe98a4
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/migc.c
@@ -0,0 +1,301 @@
+/* $Xorg: migc.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/* $XFree86: xc/programs/Xserver/mi/migc.c,v 1.8 2001/08/06 20:51:18 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "migc.h"
+
+/* ARGSUSED */
+void
+miChangeGC(pGC, mask)
+ GCPtr pGC;
+ unsigned long mask;
+{
+ return;
+}
+
+void
+miDestroyGC(pGC)
+ GCPtr pGC;
+{
+ if (pGC->pRotatedPixmap)
+ (*pGC->pScreen->DestroyPixmap) (pGC->pRotatedPixmap);
+ if (pGC->freeCompClip)
+ REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
+ miDestroyGCOps(pGC->ops);
+}
+
+/*
+ * create a private op array for a gc
+ */
+
+GCOpsPtr
+miCreateGCOps(prototype)
+ GCOpsPtr prototype;
+{
+ GCOpsPtr ret;
+
+ /* XXX */ Must_have_memory = TRUE;
+ ret = (GCOpsPtr) xalloc(sizeof(GCOps));
+ /* XXX */ Must_have_memory = FALSE;
+ if (!ret)
+ return 0;
+ *ret = *prototype;
+ ret->devPrivate.val = 1;
+ return ret;
+}
+
+void
+miDestroyGCOps(ops)
+ GCOpsPtr ops;
+{
+ if (ops->devPrivate.val)
+ xfree(ops);
+}
+
+
+void
+miDestroyClip(pGC)
+ GCPtr pGC;
+{
+ if (pGC->clientClipType == CT_NONE)
+ return;
+ else if (pGC->clientClipType == CT_PIXMAP)
+ {
+ (*pGC->pScreen->DestroyPixmap) ((PixmapPtr) (pGC->clientClip));
+ }
+ else
+ {
+ /*
+ * we know we'll never have a list of rectangles, since ChangeClip
+ * immediately turns them into a region
+ */
+ REGION_DESTROY(pGC->pScreen, pGC->clientClip);
+ }
+ pGC->clientClip = NULL;
+ pGC->clientClipType = CT_NONE;
+}
+
+void
+miChangeClip(pGC, type, pvalue, nrects)
+ GCPtr pGC;
+ int type;
+ pointer pvalue;
+ int nrects;
+{
+ (*pGC->funcs->DestroyClip) (pGC);
+ if (type == CT_PIXMAP)
+ {
+ /* convert the pixmap to a region */
+ pGC->clientClip = (pointer) BITMAP_TO_REGION(pGC->pScreen,
+ (PixmapPtr) pvalue);
+ (*pGC->pScreen->DestroyPixmap) (pvalue);
+ }
+ else if (type == CT_REGION)
+ {
+ /* stuff the region in the GC */
+ pGC->clientClip = pvalue;
+ }
+ else if (type != CT_NONE)
+ {
+ pGC->clientClip = (pointer) RECTS_TO_REGION(pGC->pScreen, nrects,
+ (xRectangle *) pvalue,
+ type);
+ xfree(pvalue);
+ }
+ pGC->clientClipType = (type != CT_NONE && pGC->clientClip) ? CT_REGION : CT_NONE;
+ pGC->stateChanges |= GCClipMask;
+}
+
+void
+miCopyClip(pgcDst, pgcSrc)
+ GCPtr pgcDst, pgcSrc;
+{
+ RegionPtr prgnNew;
+
+ switch (pgcSrc->clientClipType)
+ {
+ case CT_PIXMAP:
+ ((PixmapPtr) pgcSrc->clientClip)->refcnt++;
+ /* Fall through !! */
+ case CT_NONE:
+ (*pgcDst->funcs->ChangeClip) (pgcDst, (int) pgcSrc->clientClipType,
+ pgcSrc->clientClip, 0);
+ break;
+ case CT_REGION:
+ prgnNew = REGION_CREATE(pgcSrc->pScreen, NULL, 1);
+ REGION_COPY(pgcDst->pScreen, prgnNew,
+ (RegionPtr) (pgcSrc->clientClip));
+ (*pgcDst->funcs->ChangeClip) (pgcDst, CT_REGION, (pointer) prgnNew, 0);
+ break;
+ }
+}
+
+/* ARGSUSED */
+void
+miCopyGC(pGCSrc, changes, pGCDst)
+ GCPtr pGCSrc;
+ unsigned long changes;
+ GCPtr pGCDst;
+{
+ return;
+}
+
+void
+miComputeCompositeClip(pGC, pDrawable)
+ GCPtr pGC;
+ DrawablePtr pDrawable;
+{
+ ScreenPtr pScreen;
+
+ /* This prevents warnings about pScreen not being used. */
+ pGC->pScreen = pScreen = pGC->pScreen;
+
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ {
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ RegionPtr pregWin;
+ Bool freeTmpClip, freeCompClip;
+
+ if (pGC->subWindowMode == IncludeInferiors)
+ {
+ pregWin = NotClippedByChildren(pWin);
+ freeTmpClip = TRUE;
+ }
+ else
+ {
+ pregWin = &pWin->clipList;
+ freeTmpClip = FALSE;
+ }
+ freeCompClip = pGC->freeCompClip;
+
+ /*
+ * if there is no client clip, we can get by with just keeping the
+ * pointer we got, and remembering whether or not should destroy (or
+ * maybe re-use) it later. this way, we avoid unnecessary copying of
+ * regions. (this wins especially if many clients clip by children
+ * and have no client clip.)
+ */
+ if (pGC->clientClipType == CT_NONE)
+ {
+ if (freeCompClip)
+ REGION_DESTROY(pScreen, pGC->pCompositeClip);
+ pGC->pCompositeClip = pregWin;
+ pGC->freeCompClip = freeTmpClip;
+ }
+ else
+ {
+ /*
+ * we need one 'real' region to put into the composite clip. if
+ * pregWin the current composite clip are real, we can get rid of
+ * one. if pregWin is real and the current composite clip isn't,
+ * use pregWin for the composite clip. if the current composite
+ * clip is real and pregWin isn't, use the current composite
+ * clip. if neither is real, create a new region.
+ */
+
+ REGION_TRANSLATE(pScreen, pGC->clientClip,
+ pDrawable->x + pGC->clipOrg.x,
+ pDrawable->y + pGC->clipOrg.y);
+
+ if (freeCompClip)
+ {
+ REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
+ pregWin, pGC->clientClip);
+ if (freeTmpClip)
+ REGION_DESTROY(pScreen, pregWin);
+ }
+ else if (freeTmpClip)
+ {
+ REGION_INTERSECT(pScreen, pregWin, pregWin, pGC->clientClip);
+ pGC->pCompositeClip = pregWin;
+ }
+ else
+ {
+ pGC->pCompositeClip = REGION_CREATE(pScreen, NullBox, 0);
+ REGION_INTERSECT(pScreen, pGC->pCompositeClip,
+ pregWin, pGC->clientClip);
+ }
+ pGC->freeCompClip = TRUE;
+ REGION_TRANSLATE(pScreen, pGC->clientClip,
+ -(pDrawable->x + pGC->clipOrg.x),
+ -(pDrawable->y + pGC->clipOrg.y));
+ }
+ } /* end of composite clip for a window */
+ else
+ {
+ BoxRec pixbounds;
+
+ /* XXX should we translate by drawable.x/y here ? */
+ /* If you want pixmaps in offscreen memory, yes */
+ pixbounds.x1 = pDrawable->x;
+ pixbounds.y1 = pDrawable->y;
+ pixbounds.x2 = pDrawable->x + pDrawable->width;
+ pixbounds.y2 = pDrawable->y + pDrawable->height;
+
+ if (pGC->freeCompClip)
+ {
+ REGION_RESET(pScreen, pGC->pCompositeClip, &pixbounds);
+ }
+ else
+ {
+ pGC->freeCompClip = TRUE;
+ pGC->pCompositeClip = REGION_CREATE(pScreen, &pixbounds, 1);
+ }
+
+ if (pGC->clientClipType == CT_REGION)
+ {
+ if(pDrawable->x || pDrawable->y) {
+ REGION_TRANSLATE(pScreen, pGC->clientClip,
+ pDrawable->x + pGC->clipOrg.x,
+ pDrawable->y + pGC->clipOrg.y);
+ REGION_INTERSECT(pScreen, pGC->pCompositeClip,
+ pGC->pCompositeClip, pGC->clientClip);
+ REGION_TRANSLATE(pScreen, pGC->clientClip,
+ -(pDrawable->x + pGC->clipOrg.x),
+ -(pDrawable->y + pGC->clipOrg.y));
+ } else {
+ REGION_TRANSLATE(pScreen, pGC->pCompositeClip,
+ -pGC->clipOrg.x, -pGC->clipOrg.y);
+ REGION_INTERSECT(pScreen, pGC->pCompositeClip,
+ pGC->pCompositeClip, pGC->clientClip);
+ REGION_TRANSLATE(pScreen, pGC->pCompositeClip,
+ pGC->clipOrg.x, pGC->clipOrg.y);
+ }
+ }
+ } /* end of composite clip for pixmap */
+} /* end miComputeCompositeClip */
diff --git a/nx-X11/programs/Xserver/mi/migc.h b/nx-X11/programs/Xserver/mi/migc.h
new file mode 100644
index 000000000..d906c6334
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/migc.h
@@ -0,0 +1,74 @@
+/* $Xorg: migc.h,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/* $XFree86: xc/programs/Xserver/mi/migc.h,v 1.7 2001/08/06 20:51:18 dawes Exp $ */
+
+extern void miChangeGC(
+ GCPtr /*pGC*/,
+ unsigned long /*mask*/
+);
+
+extern void miDestroyGC(
+ GCPtr /*pGC*/
+);
+
+extern GCOpsPtr miCreateGCOps(
+ GCOpsPtr /*prototype*/
+);
+
+extern void miDestroyGCOps(
+ GCOpsPtr /*ops*/
+);
+
+extern void miDestroyClip(
+ GCPtr /*pGC*/
+);
+
+extern void miChangeClip(
+ GCPtr /*pGC*/,
+ int /*type*/,
+ pointer /*pvalue*/,
+ int /*nrects*/
+);
+
+extern void miCopyClip(
+ GCPtr /*pgcDst*/,
+ GCPtr /*pgcSrc*/
+);
+
+extern void miCopyGC(
+ GCPtr /*pGCSrc*/,
+ unsigned long /*changes*/,
+ GCPtr /*pGCDst*/
+);
+
+extern void miComputeCompositeClip(
+ GCPtr /*pGC*/,
+ DrawablePtr /*pDrawable*/
+);
diff --git a/nx-X11/programs/Xserver/mi/miglblt.c b/nx-X11/programs/Xserver/mi/miglblt.c
new file mode 100644
index 000000000..12d0aa932
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/miglblt.c
@@ -0,0 +1,255 @@
+/* $XFree86: xc/programs/Xserver/mi/miglblt.c,v 1.5 2001/05/29 22:24:07 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* $Xorg: miglblt.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmap.h"
+#include "servermd.h"
+#include "mi.h"
+
+/*
+ machine-independent glyph blt.
+ assumes that glyph bits in snf are written in bytes,
+have same bit order as the server's bitmap format,
+and are byte padded. this corresponds to the snf distributed
+with the sample server.
+
+ get a scratch GC.
+ in the scratch GC set alu = GXcopy, fg = 1, bg = 0
+ allocate a bitmap big enough to hold the largest glyph in the font
+ validate the scratch gc with the bitmap
+ for each glyph
+ carefully put the bits of the glyph in a buffer,
+ padded to the server pixmap scanline padding rules
+ fake a call to PutImage from the buffer into the bitmap
+ use the bitmap in a call to PushPixels
+*/
+
+void
+miPolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ int width, height;
+ PixmapPtr pPixmap;
+ int nbyLine; /* bytes per line of padded pixmap */
+ FontPtr pfont;
+ GCPtr pGCtmp;
+ register int i;
+ register int j;
+ unsigned char *pbits; /* buffer for PutImage */
+ register unsigned char *pb; /* temp pointer into buffer */
+ register CharInfoPtr pci; /* currect char info */
+ register unsigned char *pglyph; /* pointer bits in glyph */
+ int gWidth, gHeight; /* width and height of glyph */
+ register int nbyGlyphWidth; /* bytes per scanline of glyph */
+ int nbyPadGlyph; /* server padded line of glyph */
+
+ XID gcvals[3];
+
+ if (pGC->miTranslate)
+ {
+ x += pDrawable->x;
+ y += pDrawable->y;
+ }
+
+ pfont = pGC->font;
+ width = FONTMAXBOUNDS(pfont,rightSideBearing) -
+ FONTMINBOUNDS(pfont,leftSideBearing);
+ height = FONTMAXBOUNDS(pfont,ascent) +
+ FONTMAXBOUNDS(pfont,descent);
+
+ pPixmap = (*pDrawable->pScreen->CreatePixmap)(pDrawable->pScreen,
+ width, height, 1);
+ if (!pPixmap)
+ return;
+
+ pGCtmp = GetScratchGC(1, pDrawable->pScreen);
+ if (!pGCtmp)
+ {
+ (*pDrawable->pScreen->DestroyPixmap)(pPixmap);
+ return;
+ }
+
+ gcvals[0] = GXcopy;
+ gcvals[1] = 1;
+ gcvals[2] = 0;
+
+ DoChangeGC(pGCtmp, GCFunction|GCForeground|GCBackground, gcvals, 0);
+
+ nbyLine = BitmapBytePad(width);
+ pbits = (unsigned char *)ALLOCATE_LOCAL(height*nbyLine);
+ if (!pbits)
+ {
+ (*pDrawable->pScreen->DestroyPixmap)(pPixmap);
+ FreeScratchGC(pGCtmp);
+ return;
+ }
+ while(nglyph--)
+ {
+ pci = *ppci++;
+ pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ gWidth = GLYPHWIDTHPIXELS(pci);
+ gHeight = GLYPHHEIGHTPIXELS(pci);
+ if (gWidth && gHeight)
+ {
+ nbyGlyphWidth = GLYPHWIDTHBYTESPADDED(pci);
+ nbyPadGlyph = BitmapBytePad(gWidth);
+
+ if (nbyGlyphWidth == nbyPadGlyph
+#if GLYPHPADBYTES != 4
+ && (((int) pglyph) & 3) == 0
+#endif
+ )
+ {
+ pb = pglyph;
+ }
+ else
+ {
+ for (i=0, pb = pbits; i<gHeight; i++, pb = pbits+(i*nbyPadGlyph))
+ for (j = 0; j < nbyGlyphWidth; j++)
+ *pb++ = *pglyph++;
+ pb = pbits;
+ }
+
+ if ((pGCtmp->serialNumber) != (pPixmap->drawable.serialNumber))
+ ValidateGC((DrawablePtr)pPixmap, pGCtmp);
+ (*pGCtmp->ops->PutImage)((DrawablePtr)pPixmap, pGCtmp,
+ pPixmap->drawable.depth,
+ 0, 0, gWidth, gHeight,
+ 0, XYBitmap, (char *)pb);
+
+ if ((pGC->serialNumber) != (pDrawable->serialNumber))
+ ValidateGC(pDrawable, pGC);
+ (*pGC->ops->PushPixels)(pGC, pPixmap, pDrawable,
+ gWidth, gHeight,
+ x + pci->metrics.leftSideBearing,
+ y - pci->metrics.ascent);
+ }
+ x += pci->metrics.characterWidth;
+ }
+ (*pDrawable->pScreen->DestroyPixmap)(pPixmap);
+ DEALLOCATE_LOCAL(pbits);
+ FreeScratchGC(pGCtmp);
+}
+
+
+void
+miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ pointer pglyphBase; /* start of array of glyphs */
+{
+ ExtentInfoRec info; /* used by QueryGlyphExtents() */
+ XID gcvals[3];
+ int oldAlu, oldFS;
+ unsigned long oldFG;
+ xRectangle backrect;
+
+ QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info);
+
+ if (info.overallWidth >= 0)
+ {
+ backrect.x = x;
+ backrect.width = info.overallWidth;
+ }
+ else
+ {
+ backrect.x = x + info.overallWidth;
+ backrect.width = -info.overallWidth;
+ }
+ backrect.y = y - FONTASCENT(pGC->font);
+ backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+
+ oldAlu = pGC->alu;
+ oldFG = pGC->fgPixel;
+ oldFS = pGC->fillStyle;
+
+ /* fill in the background */
+ gcvals[0] = GXcopy;
+ gcvals[1] = pGC->bgPixel;
+ gcvals[2] = FillSolid;
+ DoChangeGC(pGC, GCFunction|GCForeground|GCFillStyle, gcvals, 0);
+ ValidateGC(pDrawable, pGC);
+ (*pGC->ops->PolyFillRect)(pDrawable, pGC, 1, &backrect);
+
+ /* put down the glyphs */
+ gcvals[0] = oldFG;
+ DoChangeGC(pGC, GCForeground, gcvals, 0);
+ ValidateGC(pDrawable, pGC);
+ (*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci,
+ pglyphBase);
+
+ /* put all the toys away when done playing */
+ gcvals[0] = oldAlu;
+ gcvals[1] = oldFG;
+ gcvals[2] = oldFS;
+ DoChangeGC(pGC, GCFunction|GCForeground|GCFillStyle, gcvals, 0);
+ ValidateGC(pDrawable, pGC);
+
+}
diff --git a/nx-X11/programs/Xserver/mi/miinitext.c b/nx-X11/programs/Xserver/mi/miinitext.c
new file mode 100644
index 000000000..f3be9da5d
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/miinitext.c
@@ -0,0 +1,799 @@
+/* $XdotOrg: xc/programs/Xserver/mi/miinitext.c,v 1.26 2005/07/16 03:49:59 kem Exp $ */
+/* $XFree86: xc/programs/Xserver/mi/miinitext.c,v 3.67 2003/01/12 02:44:27 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: miinitext.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#undef DPMSExtension
+#endif
+
+#include "misc.h"
+#include "extension.h"
+#include "micmap.h"
+
+#if defined(QNX4) /* sleaze for Watcom on QNX4 ... */
+#undef GLXEXT
+#endif
+
+/* Make sure Xprt only announces extensions it supports */
+#ifdef PRINT_ONLY_SERVER
+#undef MITSHM /* this is incompatible to the vector-based Xprint DDX */
+#undef XKB
+#undef PANORAMIX
+#undef RES
+#undef XINPUT
+#undef XV
+#undef SCREENSAVER
+#undef XIDLE
+#undef XRECORD
+#undef XF86VIDMODE
+#undef XF86MISC
+#undef XFreeXDGA
+#undef XF86DRI
+#undef DPMSExtension
+#undef DPSEXT
+#undef FONTCACHE
+#undef DAMAGE
+#undef XFIXES
+#undef XEVIE
+#else
+#ifndef LOADABLEPRINTDDX
+#undef XPRINT
+#endif /* LOADABLEPRINTDDX */
+#endif /* PRINT_ONLY_SERVER */
+
+
+extern Bool noTestExtensions;
+
+#ifdef BIGREQS
+extern Bool noBigReqExtension;
+#endif
+#ifdef COMPOSITE
+extern Bool noCompositeExtension;
+#endif
+#ifdef DAMAGE
+extern Bool noDamageExtension;
+#endif
+#ifdef DBE
+extern Bool noDbeExtension;
+#endif
+#ifdef DPSEXT
+extern Bool noDPSExtension;
+#endif
+#ifdef DPMSExtension
+extern Bool noDPMSExtension;
+#endif
+#ifdef EVI
+extern Bool noEVIExtension;
+#endif
+#ifdef FONTCACHE
+extern Bool noFontCacheExtension;
+#endif
+#ifdef GLXEXT
+extern Bool noGlxExtension;
+#endif
+#ifdef LBX
+extern Bool noLbxExtension;
+#endif
+#ifdef SCREENSAVER
+extern Bool noScreenSaverExtension;
+#endif
+#ifdef MITSHM
+extern Bool noMITShmExtension;
+#endif
+#ifdef MITMISC
+extern Bool noMITMiscExtension;
+#endif
+#ifdef MULTIBUFFER
+extern Bool noMultibufferExtension;
+#endif
+#ifdef RANDR
+extern Bool noRRExtension;
+#endif
+#ifdef RENDER
+extern Bool noRenderExtension;
+#endif
+#ifdef SHAPE
+extern Bool noShapeExtension;
+#endif
+#ifdef XCSECURITY
+extern Bool noSecurityExtension;
+#endif
+#ifdef XSYNC
+extern Bool noSyncExtension;
+#endif
+#ifdef TOGCUP
+extern Bool noXcupExtension;
+#endif
+#ifdef RES
+extern Bool noResExtension;
+#endif
+#ifdef XAPPGROUP
+extern Bool noXagExtension;
+#endif
+#ifdef XCMISC
+extern Bool noXCMiscExtension;
+#endif
+#ifdef XEVIE
+extern Bool noXevieExtension;
+#endif
+#ifdef XF86BIGFONT
+extern Bool noXFree86BigfontExtension;
+#endif
+#ifdef XFreeXDGA
+extern Bool noXFree86DGAExtension;
+#endif
+#ifdef XF86DRI
+extern Bool noXFree86DRIExtension;
+#endif
+#ifdef XF86MISC
+extern Bool noXFree86MiscExtension;
+#endif
+#ifdef XF86VIDMODE
+extern Bool noXFree86VidModeExtension;
+#endif
+#ifdef XFIXES
+extern Bool noXFixesExtension;
+#endif
+#ifdef XKB
+/* |noXkbExtension| is defined in xc/programs/Xserver/xkb/xkbInit.c */
+extern Bool noXkbExtension;
+#endif
+#ifdef PANORAMIX
+extern Bool noPanoramiXExtension;
+#endif
+#ifdef XINPUT
+extern Bool noXInputExtension;
+#endif
+#ifdef XIDLE
+extern Bool noXIdleExtension;
+#endif
+#ifdef XV
+extern Bool noXvExtension;
+#endif
+
+#ifndef XFree86LOADER
+#define INITARGS void
+typedef void (*InitExtension)(INITARGS);
+#else /* XFree86Loader */
+#include "loaderProcs.h"
+#endif
+
+#ifdef MITSHM
+#define _XSHM_SERVER_
+#include <X11/extensions/shmstr.h>
+#endif
+#ifdef XTEST
+#define _XTEST_SERVER_
+#include <X11/extensions/XTest.h>
+#endif
+#ifdef XKB
+#include <X11/extensions/XKB.h>
+#endif
+#ifdef LBX
+#define _XLBX_SERVER_
+#include <X11/extensions/lbxstr.h>
+#endif
+#ifdef XPRINT
+#include "Print.h"
+#endif
+#ifdef XAPPGROUP
+#define _XAG_SERVER_
+#include <X11/extensions/Xagstr.h>
+#endif
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/securstr.h>
+#endif
+#ifdef PANORAMIX
+#include <X11/extensions/panoramiXproto.h>
+#endif
+#ifdef XF86BIGFONT
+#include <X11/extensions/xf86bigfstr.h>
+#endif
+#ifdef RES
+#include <X11/extensions/XResproto.h>
+#endif
+
+/* FIXME: this whole block of externs should be from the appropriate headers */
+#ifdef XTESTEXT1
+extern void XTestExtension1Init(INITARGS);
+#endif
+#ifdef SHAPE
+extern void ShapeExtensionInit(INITARGS);
+#endif
+#ifdef EVI
+extern void EVIExtensionInit(INITARGS);
+#endif
+#ifdef MITSHM
+extern void ShmExtensionInit(INITARGS);
+#endif
+#ifdef MULTIBUFFER
+extern void MultibufferExtensionInit(INITARGS);
+#endif
+#ifdef PANORAMIX
+extern void PanoramiXExtensionInit(INITARGS);
+#endif
+#ifdef XINPUT
+extern void XInputExtensionInit(INITARGS);
+#endif
+#ifdef XTEST
+extern void XTestExtensionInit(INITARGS);
+#endif
+#ifdef BIGREQS
+extern void BigReqExtensionInit(INITARGS);
+#endif
+#ifdef MITMISC
+extern void MITMiscExtensionInit(INITARGS);
+#endif
+#ifdef XIDLE
+extern void XIdleExtensionInit(INITARGS);
+#endif
+#ifdef XTRAP
+extern void DEC_XTRAPInit(INITARGS);
+#endif
+#ifdef SCREENSAVER
+extern void ScreenSaverExtensionInit (INITARGS);
+#endif
+#ifdef XV
+extern void XvExtensionInit(INITARGS);
+extern void XvMCExtensionInit(INITARGS);
+#endif
+#ifdef XSYNC
+extern void SyncExtensionInit(INITARGS);
+#endif
+#ifdef XKB
+extern void XkbExtensionInit(INITARGS);
+#endif
+#ifdef XCMISC
+extern void XCMiscExtensionInit(INITARGS);
+#endif
+#ifdef XRECORD
+extern void RecordExtensionInit(INITARGS);
+#endif
+#ifdef LBX
+extern void LbxExtensionInit(INITARGS);
+#endif
+#ifdef DBE
+extern void DbeExtensionInit(INITARGS);
+#endif
+#ifdef XAPPGROUP
+extern void XagExtensionInit(INITARGS);
+#endif
+#ifdef XCSECURITY
+extern void SecurityExtensionInit(INITARGS);
+#endif
+#ifdef XPRINT
+extern void XpExtensionInit(INITARGS);
+#endif
+#ifdef XF86BIGFONT
+extern void XFree86BigfontExtensionInit(INITARGS);
+#endif
+#ifdef XF86VIDMODE
+extern void XFree86VidModeExtensionInit(INITARGS);
+#endif
+#ifdef XF86MISC
+extern void XFree86MiscExtensionInit(INITARGS);
+#endif
+#ifdef XFreeXDGA
+extern void XFree86DGAExtensionInit(INITARGS);
+#endif
+#ifdef GLXEXT
+#ifndef __DARWIN__
+extern void GlxExtensionInit(INITARGS);
+extern void GlxWrapInitVisuals(miInitVisualsProcPtr *);
+#else
+extern void DarwinGlxExtensionInit(INITARGS);
+extern void DarwinGlxWrapInitVisuals(miInitVisualsProcPtr *);
+#endif
+#endif
+#ifdef XF86DRI
+extern void XFree86DRIExtensionInit(INITARGS);
+#endif
+#ifdef TOGCUP
+extern void XcupExtensionInit(INITARGS);
+#endif
+#ifdef DPMSExtension
+extern void DPMSExtensionInit(INITARGS);
+#endif
+#ifdef DPSEXT
+extern void DPSExtensionInit(INITARGS);
+#endif
+#ifdef FONTCACHE
+extern void FontCacheExtensionInit(INITARGS);
+#endif
+#ifdef RENDER
+extern void RenderExtensionInit(INITARGS);
+#endif
+#ifdef RANDR
+extern void RRExtensionInit(INITARGS);
+#endif
+#ifdef RES
+extern void ResExtensionInit(INITARGS);
+#endif
+#ifdef DMXEXT
+extern void DMXExtensionInit(INITARGS);
+#endif
+#ifdef XEVIE
+extern void XevieExtensionInit(INITARGS);
+#endif
+#ifdef XFIXES
+extern void XFixesExtensionInit(INITARGS);
+#endif
+#ifdef DAMAGE
+extern void DamageExtensionInit(INITARGS);
+#endif
+#ifdef COMPOSITE
+extern void CompositeExtensionInit(INITARGS);
+#endif
+
+/* The following is only a small first step towards run-time
+ * configurable extensions.
+ */
+typedef struct {
+ char *name;
+ Bool *disablePtr;
+} ExtensionToggle;
+
+static ExtensionToggle ExtensionToggleList[] =
+{
+ /* sort order is extension name string as shown in xdpyinfo */
+#ifdef BIGREQS
+ { "BIG-REQUESTS", &noBigReqExtension },
+#endif
+#ifdef COMPOSITE
+ { "Composite", &noCompositeExtension },
+#endif
+#ifdef DAMAGE
+ { "DAMAGE", &noDamageExtension },
+#endif
+#ifdef DBE
+ { "DOUBLE-BUFFER", &noDbeExtension },
+#endif
+#ifdef DPSEXT
+ { "DPSExtension", &noDPSExtension },
+#endif
+#ifdef DPMSExtension
+ { "DPMS", &noDPMSExtension },
+#endif
+#ifdef EVI
+ { "Extended-Visual-Information", &noEVIExtension },
+#endif
+#ifdef FONTCACHE
+ { "FontCache", &noFontCacheExtension },
+#endif
+#ifdef GLXEXT
+ { "GLX", &noGlxExtension },
+#endif
+#ifdef LBX
+ { "LBX", &noLbxExtension },
+#endif
+#ifdef SCREENSAVER
+ { "MIT-SCREEN-SAVER", &noScreenSaverExtension },
+#endif
+#ifdef MITSHM
+ { SHMNAME, &noMITShmExtension },
+#endif
+#ifdef MITMISC
+ { "MIT-SUNDRY-NONSTANDARD", &noMITMiscExtension },
+#endif
+#ifdef MULTIBUFFER
+ { "Multi-Buffering", &noMultibufferExtension },
+#endif
+#ifdef RANDR
+ { "RANDR", &noRRExtension },
+#endif
+#ifdef RENDER
+ { "RENDER", &noRenderExtension },
+#endif
+#ifdef SHAPE
+ { "SHAPE", &noShapeExtension },
+#endif
+#ifdef XCSECURITY
+ { "SECURITY", &noSecurityExtension },
+#endif
+#ifdef XSYNC
+ { "SYNC", &noSyncExtension },
+#endif
+#ifdef TOGCUP
+ { "TOG-CUP", &noXcupExtension },
+#endif
+#ifdef RES
+ { "X-Resource", &noResExtension },
+#endif
+#ifdef XAPPGROUP
+ { "XC-APPGROUP", &noXagExtension },
+#endif
+#ifdef XCMISC
+ { "XC-MISC", &noXCMiscExtension },
+#endif
+#ifdef XEVIE
+ { "XEVIE", &noXevieExtension },
+#endif
+#ifdef XF86BIGFONT
+ { "XFree86-Bigfont", &noXFree86BigfontExtension },
+#endif
+#ifdef XFreeXDGA
+ { "XFree86-DGA", &noXFree86DGAExtension },
+#endif
+#ifdef XF86DRI
+ { "XFree86-DRI", &noXFree86DRIExtension },
+#endif
+#ifdef XF86MISC
+ { "XFree86-Misc", &noXFree86MiscExtension },
+#endif
+#ifdef XF86VIDMODE
+ { "XFree86-VidModeExtension", &noXFree86VidModeExtension },
+#endif
+#ifdef XFIXES
+ { "XFIXES", &noXFixesExtension },
+#endif
+#ifdef PANORAMIX
+ { "XINERAMA", &noPanoramiXExtension },
+#endif
+#ifdef XINPUT
+ { "XInputExtension", &noXInputExtension },
+#endif
+#ifdef XKB
+ { "XKEYBOARD", &noXkbExtension },
+#endif
+ { "XTEST", &noTestExtensions },
+#ifdef XV
+ { "XVideo", &noXvExtension },
+#endif
+ { NULL, NULL }
+};
+
+Bool EnableDisableExtension(char *name, Bool enable)
+{
+ ExtensionToggle *ext = &ExtensionToggleList[0];
+
+ for (ext = &ExtensionToggleList[0]; ext->name != NULL; ext++) {
+ if (strcmp(name, ext->name) == 0) {
+ *ext->disablePtr = !enable;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+void EnableDisableExtensionError(char *name, Bool enable)
+{
+ ExtensionToggle *ext = &ExtensionToggleList[0];
+
+ ErrorF("Extension \"%s\" is not recognized\n", name);
+ ErrorF("Only the following extensions can be run-time %s:\n",
+ enable ? "enabled" : "disabled");
+ for (ext = &ExtensionToggleList[0]; ext->name != NULL; ext++)
+ ErrorF(" %s\n", ext->name);
+}
+
+#ifndef XFree86LOADER
+
+/*ARGSUSED*/
+void
+InitExtensions(argc, argv)
+ int argc;
+ char *argv[];
+{
+#ifdef PANORAMIX
+# if !defined(PRINT_ONLY_SERVER) && !defined(NO_PANORAMIX)
+ if (!noPanoramiXExtension) PanoramiXExtensionInit();
+# endif
+#endif
+#ifdef XTESTEXT1
+ if (!noTestExtensions) XTestExtension1Init();
+#endif
+#ifdef SHAPE
+ if (!noShapeExtension) ShapeExtensionInit();
+#endif
+#ifdef MITSHM
+ if (!noMITShmExtension) ShmExtensionInit();
+#endif
+#ifdef EVI
+ if (!noEVIExtension) EVIExtensionInit();
+#endif
+#ifdef MULTIBUFFER
+ if (!noMultibufferExtension) MultibufferExtensionInit();
+#endif
+#if defined(XINPUT) && !defined(NO_HW_ONLY_EXTS)
+ if (!noXInputExtension) XInputExtensionInit();
+#endif
+#ifdef XTEST
+ if (!noTestExtensions) XTestExtensionInit();
+#endif
+#ifdef BIGREQS
+ if (!noBigReqExtension) BigReqExtensionInit();
+#endif
+#ifdef MITMISC
+ if (!noMITMiscExtension) MITMiscExtensionInit();
+#endif
+#ifdef XIDLE
+ if (!noXIdleExtension) XIdleExtensionInit();
+#endif
+#ifdef XTRAP
+ if (!noTestExtensions) DEC_XTRAPInit();
+#endif
+#if defined(SCREENSAVER) && !defined(PRINT_ONLY_SERVER)
+ if (!noScreenSaverExtension) ScreenSaverExtensionInit ();
+#endif
+#ifdef XV
+ if (!noXvExtension) {
+ XvExtensionInit();
+ XvMCExtensionInit();
+ }
+#endif
+#ifdef XSYNC
+ if (!noSyncExtension) SyncExtensionInit();
+#endif
+#if defined(XKB) && !defined(PRINT_ONLY_SERVER) && !defined(NO_HW_ONLY_EXTS)
+ if (!noXkbExtension) XkbExtensionInit();
+#endif
+#ifdef XCMISC
+ if (!noXCMiscExtension) XCMiscExtensionInit();
+#endif
+#ifdef XRECORD
+ if (!noTestExtensions) RecordExtensionInit();
+#endif
+#ifdef LBX
+ if (!noLbxExtension) LbxExtensionInit();
+#endif
+#ifdef DBE
+ if (!noDbeExtension) DbeExtensionInit();
+#endif
+#ifdef XAPPGROUP
+ if (!noXagExtension) XagExtensionInit();
+#endif
+#ifdef XCSECURITY
+ if (!noSecurityExtension) SecurityExtensionInit();
+#endif
+#ifdef XPRINT
+ XpExtensionInit(); /* server-specific extension, cannot be disabled */
+#endif
+#ifdef TOGCUP
+ if (!noXcupExtension) XcupExtensionInit();
+#endif
+#if defined(DPMSExtension) && !defined(NO_HW_ONLY_EXTS)
+ if (!noDPMSExtension) DPMSExtensionInit();
+#endif
+#ifdef FONTCACHE
+ if (!noFontCacheExtension) FontCacheExtensionInit();
+#endif
+#ifdef XF86BIGFONT
+ if (!noXFree86BigfontExtension) XFree86BigfontExtensionInit();
+#endif
+#if !defined(PRINT_ONLY_SERVER) && !defined(NO_HW_ONLY_EXTS)
+#if defined(XF86VIDMODE)
+ if (!noXFree86VidModeExtension) XFree86VidModeExtensionInit();
+#endif
+#if defined(XF86MISC)
+ if (!noXFree86MiscExtension) XFree86MiscExtensionInit();
+#endif
+#if defined(XFreeXDGA)
+ if (!noXFree86DGAExtension) XFree86DGAExtensionInit();
+#endif
+#ifdef XF86DRI
+ if (!noXFree86DRIExtension) XFree86DRIExtensionInit();
+#endif
+#endif
+#ifdef GLXEXT
+#ifndef __DARWIN__
+ if (!noGlxExtension) GlxExtensionInit();
+#else
+ if (!noGlxExtension) DarwinGlxExtensionInit();
+#endif
+#endif
+#ifdef DPSEXT
+#ifndef XPRINT
+ if (!noDPSExtension) DPSExtensionInit();
+#endif
+#endif
+#ifdef XFIXES
+ /* must be before Render to layer DisplayCursor correctly */
+ if (!noXFixesExtension) XFixesExtensionInit();
+#endif
+#ifdef RENDER
+ if (!noRenderExtension) RenderExtensionInit();
+#endif
+#ifdef RANDR
+ if (!noRRExtension) RRExtensionInit();
+#endif
+#ifdef RES
+ if (!noResExtension) ResExtensionInit();
+#endif
+#ifdef DMXEXT
+ DMXExtensionInit(); /* server-specific extension, cannot be disabled */
+#endif
+#ifdef XEVIE
+ if (!noXevieExtension) XevieExtensionInit();
+#endif
+#ifdef COMPOSITE
+ if (!noCompositeExtension) CompositeExtensionInit();
+#endif
+#ifdef DAMAGE
+ if (!noDamageExtension) DamageExtensionInit();
+#endif
+}
+
+void
+InitVisualWrap()
+{
+ miResetInitVisuals();
+#ifdef GLXEXT
+#ifndef __DARWIN__
+ GlxWrapInitVisuals(&miInitVisualsProc);
+#else
+ DarwinGlxWrapInitVisuals(&miInitVisualsProc);
+#endif
+#endif
+}
+
+#else /* XFree86LOADER */
+/* List of built-in (statically linked) extensions */
+static ExtensionModule staticExtensions[] = {
+#ifdef XTESTEXT1
+ { XTestExtension1Init, "XTEST1", &noTestExtensions, NULL, NULL },
+#endif
+#ifdef MITSHM
+ { ShmExtensionInit, SHMNAME, &noMITShmExtension, NULL, NULL },
+#endif
+#ifdef XINPUT
+ { XInputExtensionInit, "XInputExtension", &noXInputExtension, NULL, NULL },
+#endif
+#ifdef XTEST
+ { XTestExtensionInit, XTestExtensionName, &noTestExtensions, NULL, NULL },
+#endif
+#ifdef XIDLE
+ { XIdleExtensionInit, "XIDLE", &noXIdleExtension, NULL, NULL },
+#endif
+#ifdef XKB
+ { XkbExtensionInit, XkbName, &noXkbExtension, NULL, NULL },
+#endif
+#ifdef LBX
+ { LbxExtensionInit, LBXNAME, &noLbxExtension, NULL, NULL },
+#endif
+#ifdef XAPPGROUP
+ { XagExtensionInit, XAGNAME, &noXagExtension, NULL, NULL },
+#endif
+#ifdef XCSECURITY
+ { SecurityExtensionInit, SECURITY_EXTENSION_NAME, &noSecurityExtension, NULL, NULL },
+#endif
+#ifdef XPRINT
+ { XpExtensionInit, XP_PRINTNAME, NULL, NULL, NULL },
+#endif
+#ifdef PANORAMIX
+ { PanoramiXExtensionInit, PANORAMIX_PROTOCOL_NAME, &noPanoramiXExtension, NULL, NULL },
+#endif
+#ifdef XFIXES
+ /* must be before Render to layer DisplayCursor correctly */
+ { XFixesExtensionInit, "XFIXES", &noXFixesExtension, NULL, NULL },
+#endif
+#ifdef XF86BIGFONT
+ { XFree86BigfontExtensionInit, XF86BIGFONTNAME, &noXFree86BigfontExtension, NULL, NULL },
+#endif
+#ifdef RENDER
+ { RenderExtensionInit, "RENDER", &noRenderExtension, NULL, NULL },
+#endif
+#ifdef RANDR
+ { RRExtensionInit, "RANDR", &noRRExtension, NULL, NULL },
+#endif
+#ifdef COMPOSITE
+ { CompositeExtensionInit, "COMPOSITE", &noCompositeExtension, NULL },
+#endif
+#ifdef DAMAGE
+ { DamageExtensionInit, "DAMAGE", &noDamageExtension, NULL },
+#endif
+#ifdef XEVIE
+ { XevieExtensionInit, "XEVIE", &noXevieExtension, NULL },
+#endif
+ { NULL, NULL, NULL, NULL, NULL }
+};
+
+/*ARGSUSED*/
+void
+InitExtensions(argc, argv)
+ int argc;
+ char *argv[];
+{
+ int i;
+ ExtensionModule *ext;
+ static Bool listInitialised = FALSE;
+
+ if (!listInitialised) {
+ /* Add built-in extensions to the list. */
+ for (i = 0; staticExtensions[i].name; i++)
+ LoadExtension(&staticExtensions[i], TRUE);
+
+ /* Sort the extensions according the init dependencies. */
+ LoaderSortExtensions();
+ listInitialised = TRUE;
+ }
+
+ for (i = 0; ExtensionModuleList[i].name != NULL; i++) {
+ ext = &ExtensionModuleList[i];
+ if (ext->initFunc != NULL &&
+ (ext->disablePtr == NULL ||
+ (ext->disablePtr != NULL && !*ext->disablePtr))) {
+ (ext->initFunc)();
+ }
+ }
+}
+
+static void (*__miHookInitVisualsFunction)(miInitVisualsProcPtr *);
+
+void
+InitVisualWrap()
+{
+ miResetInitVisuals();
+ if (__miHookInitVisualsFunction)
+ (*__miHookInitVisualsFunction)(&miInitVisualsProc);
+}
+
+void miHookInitVisuals(void (**old)(miInitVisualsProcPtr *),
+ void (*new)(miInitVisualsProcPtr *))
+{
+ if (old)
+ *old = __miHookInitVisualsFunction;
+ __miHookInitVisualsFunction = new;
+}
+
+#endif /* XFree86LOADER */
diff --git a/nx-X11/programs/Xserver/mi/miline.h b/nx-X11/programs/Xserver/mi/miline.h
new file mode 100644
index 000000000..f52a51ebd
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/miline.h
@@ -0,0 +1,174 @@
+/* $Xorg: miline.h,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+
+/*
+
+Copyright 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/mi/miline.h,v 1.6 2001/08/06 20:51:19 dawes Exp $ */
+
+#ifndef MILINE_H
+
+#include "screenint.h"
+
+/*
+ * Public definitions used for configuring basic pixelization aspects
+ * of the sample implementation line-drawing routines provided in
+ * {mfb,mi,cfb*} at run-time.
+ */
+
+#define XDECREASING 4
+#define YDECREASING 2
+#define YMAJOR 1
+
+#define OCTANT1 (1 << (YDECREASING))
+#define OCTANT2 (1 << (YDECREASING|YMAJOR))
+#define OCTANT3 (1 << (XDECREASING|YDECREASING|YMAJOR))
+#define OCTANT4 (1 << (XDECREASING|YDECREASING))
+#define OCTANT5 (1 << (XDECREASING))
+#define OCTANT6 (1 << (XDECREASING|YMAJOR))
+#define OCTANT7 (1 << (YMAJOR))
+#define OCTANT8 (1 << (0))
+
+#define XMAJOROCTANTS (OCTANT1 | OCTANT4 | OCTANT5 | OCTANT8)
+
+#define DEFAULTZEROLINEBIAS (OCTANT2 | OCTANT3 | OCTANT4 | OCTANT5)
+
+/*
+ * Devices can configure the rendering of routines in mi, mfb, and cfb*
+ * by specifying a thin line bias to be applied to a particular screen
+ * using the following function. The bias parameter is an OR'ing of
+ * the appropriate OCTANT constants defined above to indicate which
+ * octants to bias a line to prefer an axial step when the Bresenham
+ * error term is exactly zero. The octants are mapped as follows:
+ *
+ * \ | /
+ * \ 3 | 2 /
+ * \ | /
+ * 4 \ | / 1
+ * \|/
+ * -----------
+ * /|\
+ * 5 / | \ 8
+ * / | \
+ * / 6 | 7 \
+ * / | \
+ *
+ * For more information, see "Ambiguities in Incremental Line Rastering,"
+ * Jack E. Bresenham, IEEE CG&A, May 1987.
+ */
+
+extern void miSetZeroLineBias(
+ ScreenPtr /* pScreen */,
+ unsigned int /* bias */
+);
+
+/*
+ * Private definitions needed for drawing thin (zero width) lines
+ * Used by the mi, mfb, and all cfb* components.
+ */
+
+#define X_AXIS 0
+#define Y_AXIS 1
+
+#define OUT_LEFT 0x08
+#define OUT_RIGHT 0x04
+#define OUT_ABOVE 0x02
+#define OUT_BELOW 0x01
+
+#define OUTCODES(_result, _x, _y, _pbox) \
+ if ( (_x) < (_pbox)->x1) (_result) |= OUT_LEFT; \
+ else if ( (_x) >= (_pbox)->x2) (_result) |= OUT_RIGHT; \
+ if ( (_y) < (_pbox)->y1) (_result) |= OUT_ABOVE; \
+ else if ( (_y) >= (_pbox)->y2) (_result) |= OUT_BELOW;
+
+#define MIOUTCODES(outcode, x, y, xmin, ymin, xmax, ymax) \
+{\
+ if (x < xmin) outcode |= OUT_LEFT;\
+ if (x > xmax) outcode |= OUT_RIGHT;\
+ if (y < ymin) outcode |= OUT_ABOVE;\
+ if (y > ymax) outcode |= OUT_BELOW;\
+}
+
+#define SWAPINT(i, j) \
+{ register int _t = i; i = j; j = _t; }
+
+#define SWAPPT(i, j) \
+{ DDXPointRec _t; _t = i; i = j; j = _t; }
+
+#define SWAPINT_PAIR(x1, y1, x2, y2)\
+{ int t = x1; x1 = x2; x2 = t;\
+ t = y1; y1 = y2; y2 = t;\
+}
+
+#define miGetZeroLineBias(_pScreen) \
+ ((miZeroLineScreenIndex < 0) ? \
+ 0 : ((_pScreen)->devPrivates[miZeroLineScreenIndex].uval))
+
+#define CalcLineDeltas(_x1,_y1,_x2,_y2,_adx,_ady,_sx,_sy,_SX,_SY,_octant) \
+ (_octant) = 0; \
+ (_sx) = (_SX); \
+ if (((_adx) = (_x2) - (_x1)) < 0) { \
+ (_adx) = -(_adx); \
+ (_sx = -(_sx)); \
+ (_octant) |= XDECREASING; \
+ } \
+ (_sy) = (_SY); \
+ if (((_ady) = (_y2) - (_y1)) < 0) { \
+ (_ady) = -(_ady); \
+ (_sy = -(_sy)); \
+ (_octant) |= YDECREASING; \
+ }
+
+#define SetYMajorOctant(_octant) ((_octant) |= YMAJOR)
+
+#define FIXUP_ERROR(_e, _octant, _bias) \
+ (_e) -= (((_bias) >> (_octant)) & 1)
+
+#define IsXMajorOctant(_octant) (!((_octant) & YMAJOR))
+#define IsYMajorOctant(_octant) ((_octant) & YMAJOR)
+#define IsXDecreasingOctant(_octant) ((_octant) & XDECREASING)
+#define IsYDecreasingOctant(_octant) ((_octant) & YDECREASING)
+
+extern int miZeroLineScreenIndex;
+
+extern int miZeroClipLine(
+ int /*xmin*/,
+ int /*ymin*/,
+ int /*xmax*/,
+ int /*ymax*/,
+ int * /*new_x1*/,
+ int * /*new_y1*/,
+ int * /*new_x2*/,
+ int * /*new_y2*/,
+ unsigned int /*adx*/,
+ unsigned int /*ady*/,
+ int * /*pt1_clipped*/,
+ int * /*pt2_clipped*/,
+ int /*octant*/,
+ unsigned int /*bias*/,
+ int /*oc1*/,
+ int /*oc2*/
+);
+
+#endif /* MILINE_H */
diff --git a/nx-X11/programs/Xserver/mi/mioverlay.c b/nx-X11/programs/Xserver/mi/mioverlay.c
new file mode 100644
index 000000000..545927b53
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mioverlay.c
@@ -0,0 +1,2079 @@
+/* $XFree86: xc/programs/Xserver/mi/mioverlay.c,v 3.15tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "gcstruct.h"
+#include "regionstr.h"
+#include "mivalidate.h"
+#include "mioverlay.h"
+#include "migc.h"
+
+#include "globals.h"
+
+
+typedef struct {
+ RegionRec exposed;
+ RegionRec borderExposed;
+ RegionPtr borderVisible;
+ DDXPointRec oldAbsCorner;
+} miOverlayValDataRec, *miOverlayValDataPtr;
+
+typedef struct _TreeRec {
+ WindowPtr pWin;
+ struct _TreeRec *parent;
+ struct _TreeRec *firstChild;
+ struct _TreeRec *lastChild;
+ struct _TreeRec *prevSib;
+ struct _TreeRec *nextSib;
+ RegionRec borderClip;
+ RegionRec clipList;
+ unsigned visibility;
+ miOverlayValDataPtr valdata;
+} miOverlayTreeRec, *miOverlayTreePtr;
+
+typedef struct {
+ miOverlayTreePtr tree;
+} miOverlayWindowRec, *miOverlayWindowPtr;
+
+typedef struct {
+ CloseScreenProcPtr CloseScreen;
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ RealizeWindowProcPtr RealizeWindow;
+ miOverlayTransFunc MakeTransparent;
+ miOverlayInOverlayFunc InOverlay;
+ Bool underlayMarked;
+ Bool copyUnderlay;
+} miOverlayScreenRec, *miOverlayScreenPtr;
+
+static unsigned long miOverlayGeneration = 0;
+int miOverlayWindowIndex = -1;
+int miOverlayScreenIndex = -1;
+
+static void RebuildTree(WindowPtr);
+static Bool HasUnderlayChildren(WindowPtr);
+static void MarkUnderlayWindow(WindowPtr);
+static Bool CollectUnderlayChildrenRegions(WindowPtr, RegionPtr);
+
+static Bool miOverlayCloseScreen(int, ScreenPtr);
+static Bool miOverlayCreateWindow(WindowPtr);
+static Bool miOverlayDestroyWindow(WindowPtr);
+static Bool miOverlayUnrealizeWindow(WindowPtr);
+static Bool miOverlayRealizeWindow(WindowPtr);
+static void miOverlayMarkWindow(WindowPtr);
+static void miOverlayReparentWindow(WindowPtr, WindowPtr);
+static void miOverlayRestackWindow(WindowPtr, WindowPtr);
+static Bool miOverlayMarkOverlappedWindows(WindowPtr, WindowPtr, WindowPtr*);
+static void miOverlayMarkUnrealizedWindow(WindowPtr, WindowPtr, Bool);
+static int miOverlayValidateTree(WindowPtr, WindowPtr, VTKind);
+static void miOverlayHandleExposures(WindowPtr);
+static void miOverlayMoveWindow(WindowPtr, int, int, WindowPtr, VTKind);
+static void miOverlayWindowExposures(WindowPtr, RegionPtr, RegionPtr);
+static void miOverlayResizeWindow(WindowPtr, int, int, unsigned int,
+ unsigned int, WindowPtr);
+static void miOverlayClearToBackground(WindowPtr, int, int, int, int, Bool);
+
+#ifdef SHAPE
+static void miOverlaySetShape(WindowPtr);
+#endif
+static void miOverlayChangeBorderWidth(WindowPtr, unsigned int);
+
+#define MIOVERLAY_GET_SCREEN_PRIVATE(pScreen) \
+ ((miOverlayScreenPtr)((pScreen)->devPrivates[miOverlayScreenIndex].ptr))
+#define MIOVERLAY_GET_WINDOW_PRIVATE(pWin) \
+ ((miOverlayWindowPtr)((pWin)->devPrivates[miOverlayWindowIndex].ptr))
+#define MIOVERLAY_GET_WINDOW_TREE(pWin) \
+ (MIOVERLAY_GET_WINDOW_PRIVATE(pWin)->tree)
+
+#define IN_UNDERLAY(w) MIOVERLAY_GET_WINDOW_TREE(w)
+#define IN_OVERLAY(w) !MIOVERLAY_GET_WINDOW_TREE(w)
+
+#define MARK_OVERLAY(w) miMarkWindow(w)
+#define MARK_UNDERLAY(w) MarkUnderlayWindow(w)
+
+#define HasParentRelativeBorder(w) (!(w)->borderIsPixel && \
+ HasBorder(w) && \
+ (w)->backgroundState == ParentRelative)
+
+Bool
+miInitOverlay(
+ ScreenPtr pScreen,
+ miOverlayInOverlayFunc inOverlayFunc,
+ miOverlayTransFunc transFunc
+){
+ miOverlayScreenPtr pScreenPriv;
+
+ if(!inOverlayFunc || !transFunc) return FALSE;
+
+ if(miOverlayGeneration != serverGeneration) {
+ if(((miOverlayScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
+ ((miOverlayWindowIndex = AllocateWindowPrivateIndex()) < 0))
+ return FALSE;
+
+ miOverlayGeneration = serverGeneration;
+ }
+
+ if(!AllocateWindowPrivate(pScreen, miOverlayWindowIndex,
+ sizeof(miOverlayWindowRec)))
+ return FALSE;
+
+ if(!(pScreenPriv = xalloc(sizeof(miOverlayScreenRec))))
+ return FALSE;
+
+ pScreen->devPrivates[miOverlayScreenIndex].ptr = (pointer)pScreenPriv;
+
+ pScreenPriv->InOverlay = inOverlayFunc;
+ pScreenPriv->MakeTransparent = transFunc;
+ pScreenPriv->underlayMarked = FALSE;
+
+
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreenPriv->CreateWindow = pScreen->CreateWindow;
+ pScreenPriv->DestroyWindow = pScreen->DestroyWindow;
+ pScreenPriv->UnrealizeWindow = pScreen->UnrealizeWindow;
+ pScreenPriv->RealizeWindow = pScreen->RealizeWindow;
+
+ pScreen->CloseScreen = miOverlayCloseScreen;
+ pScreen->CreateWindow = miOverlayCreateWindow;
+ pScreen->DestroyWindow = miOverlayDestroyWindow;
+ pScreen->UnrealizeWindow = miOverlayUnrealizeWindow;
+ pScreen->RealizeWindow = miOverlayRealizeWindow;
+
+ pScreen->ReparentWindow = miOverlayReparentWindow;
+ pScreen->RestackWindow = miOverlayRestackWindow;
+ pScreen->MarkOverlappedWindows = miOverlayMarkOverlappedWindows;
+ pScreen->MarkUnrealizedWindow = miOverlayMarkUnrealizedWindow;
+ pScreen->ValidateTree = miOverlayValidateTree;
+ pScreen->HandleExposures = miOverlayHandleExposures;
+ pScreen->MoveWindow = miOverlayMoveWindow;
+ pScreen->WindowExposures = miOverlayWindowExposures;
+ pScreen->ResizeWindow = miOverlayResizeWindow;
+ pScreen->MarkWindow = miOverlayMarkWindow;
+ pScreen->ClearToBackground = miOverlayClearToBackground;
+#ifdef SHAPE
+ pScreen->SetShape = miOverlaySetShape;
+#endif
+ pScreen->ChangeBorderWidth = miOverlayChangeBorderWidth;
+
+ return TRUE;
+}
+
+
+static Bool
+miOverlayCloseScreen(int i, ScreenPtr pScreen)
+{
+ miOverlayScreenPtr pScreenPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
+
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+ pScreen->CreateWindow = pScreenPriv->CreateWindow;
+ pScreen->DestroyWindow = pScreenPriv->DestroyWindow;
+ pScreen->UnrealizeWindow = pScreenPriv->UnrealizeWindow;
+ pScreen->RealizeWindow = pScreenPriv->RealizeWindow;
+
+ xfree(pScreenPriv);
+
+ return (*pScreen->CloseScreen)(i, pScreen);
+}
+
+
+static Bool
+miOverlayCreateWindow(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ miOverlayScreenPtr pScreenPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
+ miOverlayWindowPtr pWinPriv = MIOVERLAY_GET_WINDOW_PRIVATE(pWin);
+ miOverlayTreePtr pTree = NULL;
+ Bool result = TRUE;
+
+ pWinPriv->tree = NULL;
+
+ if(!pWin->parent || !((*pScreenPriv->InOverlay)(pWin))) {
+ if(!(pTree = (miOverlayTreePtr)xcalloc(1, sizeof(miOverlayTreeRec))))
+ return FALSE;
+ }
+
+ if(pScreenPriv->CreateWindow) {
+ pScreen->CreateWindow = pScreenPriv->CreateWindow;
+ result = (*pScreen->CreateWindow)(pWin);
+ pScreen->CreateWindow = miOverlayCreateWindow;
+ }
+
+ if (pTree) {
+ if(result) {
+ pTree->pWin = pWin;
+ pTree->visibility = VisibilityNotViewable;
+ pWinPriv->tree = pTree;
+ if(pWin->parent) {
+ REGION_NULL(pScreen, &(pTree->borderClip));
+ REGION_NULL(pScreen, &(pTree->clipList));
+ RebuildTree(pWin);
+ } else {
+ BoxRec fullBox;
+ fullBox.x1 = 0;
+ fullBox.y1 = 0;
+ fullBox.x2 = pScreen->width;
+ fullBox.y2 = pScreen->height;
+ REGION_INIT(pScreen, &(pTree->borderClip), &fullBox, 1);
+ REGION_INIT(pScreen, &(pTree->clipList), &fullBox, 1);
+ }
+ } else xfree(pTree);
+ }
+
+ return TRUE;
+}
+
+
+static Bool
+miOverlayDestroyWindow(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ miOverlayScreenPtr pScreenPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
+ miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
+ Bool result = TRUE;
+
+ if (pTree) {
+ if(pTree->prevSib)
+ pTree->prevSib->nextSib = pTree->nextSib;
+ else if(pTree->parent)
+ pTree->parent->firstChild = pTree->nextSib;
+
+ if(pTree->nextSib)
+ pTree->nextSib->prevSib = pTree->prevSib;
+ else if(pTree->parent)
+ pTree->parent->lastChild = pTree->prevSib;
+
+ REGION_UNINIT(pScreen, &(pTree->borderClip));
+ REGION_UNINIT(pScreen, &(pTree->clipList));
+ xfree(pTree);
+ }
+
+ if(pScreenPriv->DestroyWindow) {
+ pScreen->DestroyWindow = pScreenPriv->DestroyWindow;
+ result = (*pScreen->DestroyWindow)(pWin);
+ pScreen->DestroyWindow = miOverlayDestroyWindow;
+ }
+
+ return result;
+}
+
+static Bool
+miOverlayUnrealizeWindow(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ miOverlayScreenPtr pScreenPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
+ miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
+ Bool result = TRUE;
+
+ if(pTree) pTree->visibility = VisibilityNotViewable;
+
+ if(pScreenPriv->UnrealizeWindow) {
+ pScreen->UnrealizeWindow = pScreenPriv->UnrealizeWindow;
+ result = (*pScreen->UnrealizeWindow)(pWin);
+ pScreen->UnrealizeWindow = miOverlayUnrealizeWindow;
+ }
+
+ return result;
+}
+
+
+static Bool
+miOverlayRealizeWindow(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ miOverlayScreenPtr pScreenPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
+ Bool result = TRUE;
+
+ if(pScreenPriv->RealizeWindow) {
+ pScreen->RealizeWindow = pScreenPriv->RealizeWindow;
+ result = (*pScreen->RealizeWindow)(pWin);
+ pScreen->RealizeWindow = miOverlayRealizeWindow;
+ }
+
+ /* we only need to catch the root window realization */
+
+ if(result && !pWin->parent && !((*pScreenPriv->InOverlay)(pWin)))
+ {
+ BoxRec box;
+ box.x1 = box.y1 = 0;
+ box.x2 = pWin->drawable.width;
+ box.y2 = pWin->drawable.height;
+ (*pScreenPriv->MakeTransparent)(pScreen, 1, &box);
+ }
+
+ return result;
+}
+
+
+static void
+miOverlayReparentWindow(WindowPtr pWin, WindowPtr pPriorParent)
+{
+ if(IN_UNDERLAY(pWin) || HasUnderlayChildren(pWin)) {
+ /* This could probably be more optimal */
+ RebuildTree(WindowTable[pWin->drawable.pScreen->myNum]->firstChild);
+ }
+}
+
+static void
+miOverlayRestackWindow(WindowPtr pWin, WindowPtr oldNextSib)
+{
+ if(IN_UNDERLAY(pWin) || HasUnderlayChildren(pWin)) {
+ /* This could probably be more optimal */
+ RebuildTree(pWin);
+ }
+}
+
+
+static Bool
+miOverlayMarkOverlappedWindows(
+ WindowPtr pWin,
+ WindowPtr pFirst,
+ WindowPtr *pLayerWin
+){
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pChild, pLast;
+ Bool overMarked, underMarked, doUnderlay, markAll;
+ miOverlayTreePtr pTree = NULL, tLast, tChild;
+ BoxPtr box;
+
+ overMarked = underMarked = markAll = FALSE;
+
+ if(pLayerWin) *pLayerWin = pWin; /* hah! */
+
+ doUnderlay = (IN_UNDERLAY(pWin) || HasUnderlayChildren(pWin));
+
+ box = REGION_EXTENTS(pScreen, &pWin->borderSize);
+
+ if((pChild = pFirst)) {
+ pLast = pChild->parent->lastChild;
+ while (1) {
+ if (pChild == pWin) markAll = TRUE;
+
+ if(doUnderlay && IN_UNDERLAY(pChild))
+ pTree = MIOVERLAY_GET_WINDOW_TREE(pChild);
+
+ if(pChild->viewable) {
+ if (REGION_BROKEN (pScreen, &pChild->winSize))
+ SetWinSize (pChild);
+ if (REGION_BROKEN (pScreen, &pChild->borderSize))
+ SetBorderSize (pChild);
+
+ if (markAll ||
+ RECT_IN_REGION(pScreen, &pChild->borderSize, box))
+ {
+ MARK_OVERLAY(pChild);
+ overMarked = TRUE;
+ if(doUnderlay && IN_UNDERLAY(pChild)) {
+ MARK_UNDERLAY(pChild);
+ underMarked = TRUE;
+ }
+ if (pChild->firstChild) {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ }
+ while (!pChild->nextSib && (pChild != pLast)) {
+ pChild = pChild->parent;
+ if(doUnderlay && IN_UNDERLAY(pChild))
+ pTree = MIOVERLAY_GET_WINDOW_TREE(pChild);
+ }
+
+ if(pChild == pWin) markAll = FALSE;
+
+ if (pChild == pLast) break;
+
+ pChild = pChild->nextSib;
+ }
+ if(overMarked)
+ MARK_OVERLAY(pWin->parent);
+ }
+
+ if(doUnderlay && !pTree) {
+ if(!(pTree = MIOVERLAY_GET_WINDOW_TREE(pWin))) {
+ pChild = pWin->lastChild;
+ while(1) {
+ if((pTree = MIOVERLAY_GET_WINDOW_TREE(pChild)))
+ break;
+
+ if(pChild->lastChild) {
+ pChild = pChild->lastChild;
+ continue;
+ }
+
+ while(!pChild->prevSib) pChild = pChild->parent;
+
+ pChild = pChild->prevSib;
+ }
+ }
+ }
+
+ if(pTree && pTree->nextSib) {
+ tChild = pTree->parent->lastChild;
+ tLast = pTree->nextSib;
+
+ while(1) {
+ if(tChild->pWin->viewable) {
+ if (REGION_BROKEN (pScreen, &tChild->pWin->winSize))
+ SetWinSize (tChild->pWin);
+ if (REGION_BROKEN (pScreen, &tChild->pWin->borderSize))
+ SetBorderSize (tChild->pWin);
+
+ if(RECT_IN_REGION(pScreen, &(tChild->pWin->borderSize), box))
+ {
+ MARK_UNDERLAY(tChild->pWin);
+ underMarked = TRUE;
+ }
+ }
+
+ if(tChild->lastChild) {
+ tChild = tChild->lastChild;
+ continue;
+ }
+
+ while(!tChild->prevSib && (tChild != tLast))
+ tChild = tChild->parent;
+
+ if(tChild == tLast) break;
+
+ tChild = tChild->prevSib;
+ }
+ }
+
+ if(underMarked) {
+ MARK_UNDERLAY(pTree->parent->pWin);
+ MIOVERLAY_GET_SCREEN_PRIVATE(pScreen)->underlayMarked = TRUE;
+ }
+
+ return (underMarked || overMarked);
+}
+
+
+static void
+miOverlayComputeClips(
+ WindowPtr pParent,
+ RegionPtr universe,
+ VTKind kind,
+ RegionPtr exposed
+){
+ ScreenPtr pScreen = pParent->drawable.pScreen;
+ int oldVis, newVis, dx, dy;
+ BoxRec borderSize;
+ RegionPtr borderVisible;
+ RegionRec childUniverse, childUnion;
+ miOverlayTreePtr tParent = MIOVERLAY_GET_WINDOW_TREE(pParent);
+ miOverlayTreePtr tChild;
+ Bool overlap;
+
+ borderSize.x1 = pParent->drawable.x - wBorderWidth(pParent);
+ borderSize.y1 = pParent->drawable.y - wBorderWidth(pParent);
+ dx = (int) pParent->drawable.x + (int) pParent->drawable.width +
+ wBorderWidth(pParent);
+ if (dx > 32767) dx = 32767;
+ borderSize.x2 = dx;
+ dy = (int) pParent->drawable.y + (int) pParent->drawable.height +
+ wBorderWidth(pParent);
+ if (dy > 32767) dy = 32767;
+ borderSize.y2 = dy;
+
+ oldVis = tParent->visibility;
+ switch (RECT_IN_REGION( pScreen, universe, &borderSize)) {
+ case rgnIN:
+ newVis = VisibilityUnobscured;
+ break;
+ case rgnPART:
+ newVis = VisibilityPartiallyObscured;
+#ifdef SHAPE
+ {
+ RegionPtr pBounding;
+
+ if ((pBounding = wBoundingShape (pParent))) {
+ switch (miShapedWindowIn (pScreen, universe, pBounding,
+ &borderSize,
+ pParent->drawable.x,
+ pParent->drawable.y))
+ {
+ case rgnIN:
+ newVis = VisibilityUnobscured;
+ break;
+ case rgnOUT:
+ newVis = VisibilityFullyObscured;
+ break;
+ }
+ }
+ }
+#endif
+ break;
+ default:
+ newVis = VisibilityFullyObscured;
+ break;
+ }
+ tParent->visibility = newVis;
+
+ dx = pParent->drawable.x - tParent->valdata->oldAbsCorner.x;
+ dy = pParent->drawable.y - tParent->valdata->oldAbsCorner.y;
+
+ switch (kind) {
+ case VTMap:
+ case VTStack:
+ case VTUnmap:
+ break;
+ case VTMove:
+ if ((oldVis == newVis) &&
+ ((oldVis == VisibilityFullyObscured) ||
+ (oldVis == VisibilityUnobscured)))
+ {
+ tChild = tParent;
+ while (1) {
+ if (tChild->pWin->viewable) {
+ if (tChild->visibility != VisibilityFullyObscured) {
+ REGION_TRANSLATE( pScreen, &tChild->borderClip, dx, dy);
+ REGION_TRANSLATE( pScreen, &tChild->clipList, dx, dy);
+
+ tChild->pWin->drawable.serialNumber =
+ NEXT_SERIAL_NUMBER;
+ if (pScreen->ClipNotify)
+ (* pScreen->ClipNotify) (tChild->pWin, dx, dy);
+ }
+ if (tChild->valdata) {
+ REGION_NULL(pScreen, &tChild->valdata->borderExposed);
+ if (HasParentRelativeBorder(tChild->pWin)){
+ REGION_SUBTRACT(pScreen,
+ &tChild->valdata->borderExposed,
+ &tChild->borderClip,
+ &tChild->pWin->winSize);
+ }
+ REGION_NULL(pScreen, &tChild->valdata->exposed);
+ }
+ if (tChild->firstChild) {
+ tChild = tChild->firstChild;
+ continue;
+ }
+ }
+ while (!tChild->nextSib && (tChild != tParent))
+ tChild = tChild->parent;
+ if (tChild == tParent)
+ break;
+ tChild = tChild->nextSib;
+ }
+ return;
+ }
+ /* fall through */
+ default:
+ if (dx || dy) {
+ REGION_TRANSLATE( pScreen, &tParent->borderClip, dx, dy);
+ REGION_TRANSLATE( pScreen, &tParent->clipList, dx, dy);
+ }
+ break;
+ case VTBroken:
+ REGION_EMPTY (pScreen, &tParent->borderClip);
+ REGION_EMPTY (pScreen, &tParent->clipList);
+ break;
+ }
+
+ borderVisible = tParent->valdata->borderVisible;
+ REGION_NULL(pScreen, &tParent->valdata->borderExposed);
+ REGION_NULL(pScreen, &tParent->valdata->exposed);
+
+ if (HasBorder (pParent)) {
+ if (borderVisible) {
+ REGION_SUBTRACT( pScreen, exposed, universe, borderVisible);
+ REGION_DESTROY( pScreen, borderVisible);
+ } else
+ REGION_SUBTRACT( pScreen, exposed, universe, &tParent->borderClip);
+
+ if (HasParentRelativeBorder(pParent) && (dx || dy))
+ REGION_SUBTRACT( pScreen, &tParent->valdata->borderExposed,
+ universe, &pParent->winSize);
+ else
+ REGION_SUBTRACT( pScreen, &tParent->valdata->borderExposed,
+ exposed, &pParent->winSize);
+
+ REGION_COPY( pScreen, &tParent->borderClip, universe);
+ REGION_INTERSECT( pScreen, universe, universe, &pParent->winSize);
+ }
+ else
+ REGION_COPY( pScreen, &tParent->borderClip, universe);
+
+ if ((tChild = tParent->firstChild) && pParent->mapped) {
+ REGION_NULL(pScreen, &childUniverse);
+ REGION_NULL(pScreen, &childUnion);
+
+ for (; tChild; tChild = tChild->nextSib) {
+ if (tChild->pWin->viewable)
+ REGION_APPEND( pScreen, &childUnion, &tChild->pWin->borderSize);
+ }
+
+ REGION_VALIDATE( pScreen, &childUnion, &overlap);
+
+ for (tChild = tParent->firstChild;
+ tChild;
+ tChild = tChild->nextSib)
+ {
+ if (tChild->pWin->viewable) {
+ if (tChild->valdata) {
+ REGION_INTERSECT( pScreen, &childUniverse, universe,
+ &tChild->pWin->borderSize);
+ miOverlayComputeClips (tChild->pWin, &childUniverse,
+ kind, exposed);
+ }
+ if (overlap)
+ REGION_SUBTRACT( pScreen, universe, universe,
+ &tChild->pWin->borderSize);
+ }
+ }
+ if (!overlap)
+ REGION_SUBTRACT( pScreen, universe, universe, &childUnion);
+ REGION_UNINIT( pScreen, &childUnion);
+ REGION_UNINIT( pScreen, &childUniverse);
+ }
+
+ if (oldVis == VisibilityFullyObscured ||
+ oldVis == VisibilityNotViewable)
+ {
+ REGION_COPY( pScreen, &tParent->valdata->exposed, universe);
+ }
+ else if (newVis != VisibilityFullyObscured &&
+ newVis != VisibilityNotViewable)
+ {
+ REGION_SUBTRACT( pScreen, &tParent->valdata->exposed,
+ universe, &tParent->clipList);
+ }
+
+ /* HACK ALERT - copying contents of regions, instead of regions */
+ {
+ RegionRec tmp;
+
+ tmp = tParent->clipList;
+ tParent->clipList = *universe;
+ *universe = tmp;
+ }
+
+ pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+ if (pScreen->ClipNotify)
+ (* pScreen->ClipNotify) (pParent, dx, dy);
+}
+
+
+static void
+miOverlayMarkWindow(WindowPtr pWin)
+{
+ miOverlayTreePtr pTree = NULL;
+ WindowPtr pChild, pGrandChild;
+
+ miMarkWindow(pWin);
+
+ /* look for UnmapValdata among immediate children */
+
+ if(!(pChild = pWin->firstChild)) return;
+
+ for( ; pChild; pChild = pChild->nextSib) {
+ if(pChild->valdata == UnmapValData) {
+ if(IN_UNDERLAY(pChild)) {
+ pTree = MIOVERLAY_GET_WINDOW_TREE(pChild);
+ pTree->valdata = (miOverlayValDataPtr)UnmapValData;
+ continue;
+ } else {
+ if(!(pGrandChild = pChild->firstChild))
+ continue;
+
+ while(1) {
+ if(IN_UNDERLAY(pGrandChild)) {
+ pTree = MIOVERLAY_GET_WINDOW_TREE(pGrandChild);
+ pTree->valdata = (miOverlayValDataPtr)UnmapValData;
+ } else if(pGrandChild->firstChild) {
+ pGrandChild = pGrandChild->firstChild;
+ continue;
+ }
+
+ while(!pGrandChild->nextSib && (pGrandChild != pChild))
+ pGrandChild = pGrandChild->parent;
+
+ if(pChild == pGrandChild) break;
+
+ pGrandChild = pGrandChild->nextSib;
+ }
+ }
+ }
+ }
+
+ if(pTree) {
+ MARK_UNDERLAY(pTree->parent->pWin);
+ MIOVERLAY_GET_SCREEN_PRIVATE(
+ pWin->drawable.pScreen)->underlayMarked = TRUE;
+ }
+}
+
+static void
+miOverlayMarkUnrealizedWindow(
+ WindowPtr pChild,
+ WindowPtr pWin,
+ Bool fromConfigure
+){
+ if ((pChild != pWin) || fromConfigure) {
+ miOverlayTreePtr pTree;
+
+ REGION_EMPTY(pChild->drawable.pScreen, &pChild->clipList);
+ if (pChild->drawable.pScreen->ClipNotify)
+ (* pChild->drawable.pScreen->ClipNotify)(pChild, 0, 0);
+ REGION_EMPTY(pChild->drawable.pScreen, &pChild->borderClip);
+ if((pTree = MIOVERLAY_GET_WINDOW_TREE(pChild))) {
+ if(pTree->valdata != (miOverlayValDataPtr)UnmapValData) {
+ REGION_EMPTY(pChild->drawable.pScreen, &pTree->clipList);
+ REGION_EMPTY(pChild->drawable.pScreen, &pTree->borderClip);
+ }
+ }
+ }
+}
+
+
+static int
+miOverlayValidateTree(
+ WindowPtr pParent,
+ WindowPtr pChild, /* first child effected */
+ VTKind kind
+){
+ ScreenPtr pScreen = pParent->drawable.pScreen;
+ miOverlayScreenPtr pPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
+ RegionRec totalClip, childClip, exposed;
+ miOverlayTreePtr tParent, tChild, tWin;
+ Bool overlap;
+ WindowPtr newParent;
+
+ if(!pPriv->underlayMarked)
+ goto SKIP_UNDERLAY;
+
+ if (!pChild) pChild = pParent->firstChild;
+
+ REGION_NULL(pScreen, &totalClip);
+ REGION_NULL(pScreen, &childClip);
+ REGION_NULL(pScreen, &exposed);
+
+ newParent = pParent;
+
+ while(IN_OVERLAY(newParent))
+ newParent = newParent->parent;
+
+ tParent = MIOVERLAY_GET_WINDOW_TREE(newParent);
+
+ if(IN_UNDERLAY(pChild))
+ tChild = MIOVERLAY_GET_WINDOW_TREE(pChild);
+ else
+ tChild = tParent->firstChild;
+
+ if (REGION_BROKEN (pScreen, &tParent->clipList) &&
+ !REGION_BROKEN (pScreen, &tParent->borderClip))
+ {
+ kind = VTBroken;
+ REGION_COPY (pScreen, &totalClip, &tParent->borderClip);
+ REGION_INTERSECT (pScreen, &totalClip, &totalClip,
+ &tParent->pWin->winSize);
+
+ for (tWin = tParent->firstChild; tWin != tChild; tWin = tWin->nextSib) {
+ if (tWin->pWin->viewable)
+ REGION_SUBTRACT (pScreen, &totalClip, &totalClip,
+ &tWin->pWin->borderSize);
+ }
+ REGION_EMPTY (pScreen, &tParent->clipList);
+ } else {
+ for(tWin = tChild; tWin; tWin = tWin->nextSib) {
+ if(tWin->valdata)
+ REGION_APPEND(pScreen, &totalClip, &tWin->borderClip);
+ }
+ REGION_VALIDATE(pScreen, &totalClip, &overlap);
+ }
+
+ if(kind != VTStack)
+ REGION_UNION(pScreen, &totalClip, &totalClip, &tParent->clipList);
+
+ for(tWin = tChild; tWin; tWin = tWin->nextSib) {
+ if(tWin->valdata) {
+ if(tWin->pWin->viewable) {
+ REGION_INTERSECT(pScreen, &childClip, &totalClip,
+ &tWin->pWin->borderSize);
+ miOverlayComputeClips(tWin->pWin, &childClip, kind, &exposed);
+ REGION_SUBTRACT(pScreen, &totalClip, &totalClip,
+ &tWin->pWin->borderSize);
+ } else { /* Means we are unmapping */
+ REGION_EMPTY(pScreen, &tWin->clipList);
+ REGION_EMPTY( pScreen, &tWin->borderClip);
+ tWin->valdata = NULL;
+ }
+ }
+ }
+
+ REGION_UNINIT(pScreen, &childClip);
+
+ if(!((*pPriv->InOverlay)(newParent))) {
+ REGION_NULL(pScreen, &tParent->valdata->exposed);
+ REGION_NULL(pScreen, &tParent->valdata->borderExposed);
+ }
+
+ switch (kind) {
+ case VTStack:
+ break;
+ default:
+ if(!((*pPriv->InOverlay)(newParent)))
+ REGION_SUBTRACT(pScreen, &tParent->valdata->exposed, &totalClip,
+ &tParent->clipList);
+ /* fall through */
+ case VTMap:
+ REGION_COPY( pScreen, &tParent->clipList, &totalClip);
+ if(!((*pPriv->InOverlay)(newParent)))
+ newParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ break;
+ }
+
+ REGION_UNINIT( pScreen, &totalClip);
+ REGION_UNINIT( pScreen, &exposed);
+
+SKIP_UNDERLAY:
+
+ miValidateTree(pParent, pChild, kind);
+
+ return 1;
+}
+
+
+static void
+miOverlayHandleExposures(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ miOverlayScreenPtr pPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
+ WindowPtr pChild;
+ ValidatePtr val;
+ void (* WindowExposures)(WindowPtr, RegionPtr, RegionPtr);
+
+ WindowExposures = pWin->drawable.pScreen->WindowExposures;
+ if(pPriv->underlayMarked) {
+ miOverlayTreePtr pTree;
+ miOverlayValDataPtr mival;
+
+ pChild = pWin;
+ while(IN_OVERLAY(pChild))
+ pChild = pChild->parent;
+
+ pTree = MIOVERLAY_GET_WINDOW_TREE(pChild);
+
+ while (1) {
+ if((mival = pTree->valdata)) {
+ if(!((*pPriv->InOverlay)(pTree->pWin))) {
+ if (REGION_NOTEMPTY(pScreen, &mival->borderExposed))
+ (*pWin->drawable.pScreen->PaintWindowBorder)(
+ pTree->pWin, &mival->borderExposed, PW_BORDER);
+ REGION_UNINIT(pScreen, &mival->borderExposed);
+
+ (*WindowExposures)(pTree->pWin,&mival->exposed,NullRegion);
+ REGION_UNINIT(pScreen, &mival->exposed);
+ }
+ xfree(mival);
+ pTree->valdata = NULL;
+ if (pTree->firstChild) {
+ pTree = pTree->firstChild;
+ continue;
+ }
+ }
+ while (!pTree->nextSib && (pTree->pWin != pChild))
+ pTree = pTree->parent;
+ if (pTree->pWin == pChild)
+ break;
+ pTree = pTree->nextSib;
+ }
+ pPriv->underlayMarked = FALSE;
+ }
+
+ pChild = pWin;
+ while (1) {
+ if ( (val = pChild->valdata) ) {
+ if(!((*pPriv->InOverlay)(pChild))) {
+ REGION_UNION(pScreen, &val->after.exposed, &val->after.exposed,
+ &val->after.borderExposed);
+
+ if (REGION_NOTEMPTY(pScreen, &val->after.exposed)) {
+ (*(MIOVERLAY_GET_SCREEN_PRIVATE(pScreen)->MakeTransparent))(
+ pScreen,
+ REGION_NUM_RECTS(&val->after.exposed),
+ REGION_RECTS(&val->after.exposed));
+ }
+ } else {
+ if (REGION_NOTEMPTY(pScreen, &val->after.borderExposed))
+ (*pChild->drawable.pScreen->PaintWindowBorder)(pChild,
+ &val->after.borderExposed,
+ PW_BORDER);
+ (*WindowExposures)(pChild, &val->after.exposed, NullRegion);
+ }
+ REGION_UNINIT(pScreen, &val->after.borderExposed);
+ REGION_UNINIT(pScreen, &val->after.exposed);
+ xfree(val);
+ pChild->valdata = (ValidatePtr)NULL;
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ while (!pChild->nextSib && (pChild != pWin))
+ pChild = pChild->parent;
+ if (pChild == pWin)
+ break;
+ pChild = pChild->nextSib;
+ }
+}
+
+
+static void
+miOverlayMoveWindow(
+ WindowPtr pWin,
+ int x,
+ int y,
+ WindowPtr pNextSib,
+ VTKind kind
+){
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
+ WindowPtr pParent, windowToValidate;
+ Bool WasViewable = (Bool)(pWin->viewable);
+ short bw;
+ RegionRec overReg, underReg;
+ DDXPointRec oldpt;
+#ifdef DO_SAVE_UNDERS
+ Bool dosave = FALSE;
+#endif
+
+ if (!(pParent = pWin->parent))
+ return ;
+ bw = wBorderWidth (pWin);
+
+ oldpt.x = pWin->drawable.x;
+ oldpt.y = pWin->drawable.y;
+ if (WasViewable) {
+ REGION_NULL(pScreen, &overReg);
+ REGION_NULL(pScreen, &underReg);
+ if(pTree) {
+ REGION_COPY(pScreen, &overReg, &pWin->borderClip);
+ REGION_COPY(pScreen, &underReg, &pTree->borderClip);
+ } else {
+ REGION_COPY(pScreen, &overReg, &pWin->borderClip);
+ CollectUnderlayChildrenRegions(pWin, &underReg);
+ }
+ (*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
+ }
+ pWin->origin.x = x + (int)bw;
+ pWin->origin.y = y + (int)bw;
+ x = pWin->drawable.x = pParent->drawable.x + x + (int)bw;
+ y = pWin->drawable.y = pParent->drawable.y + y + (int)bw;
+
+ SetWinSize (pWin);
+ SetBorderSize (pWin);
+
+ (*pScreen->PositionWindow)(pWin, x, y);
+
+ windowToValidate = MoveWindowInStack(pWin, pNextSib);
+
+ ResizeChildrenWinSize(pWin, x - oldpt.x, y - oldpt.y, 0, 0);
+
+ if (WasViewable) {
+ miOverlayScreenPtr pPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
+ (*pScreen->MarkOverlappedWindows) (pWin, windowToValidate, NULL);
+
+#ifdef DO_SAVE_UNDERS
+ if (DO_SAVE_UNDERS(pWin))
+ dosave = (*pScreen->ChangeSaveUnder)(pWin, windowToValidate);
+#endif /* DO_SAVE_UNDERS */
+
+ (*pScreen->ValidateTree)(pWin->parent, NullWindow, kind);
+ if(REGION_NOTEMPTY(pScreen, &underReg)) {
+ pPriv->copyUnderlay = TRUE;
+ (* pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, &underReg);
+ }
+ REGION_UNINIT(pScreen, &underReg);
+ if(REGION_NOTEMPTY(pScreen, &overReg)) {
+ pPriv->copyUnderlay = FALSE;
+ (* pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, &overReg);
+ }
+ REGION_UNINIT(pScreen, &overReg);
+ (*pScreen->HandleExposures)(pWin->parent);
+
+#ifdef DO_SAVE_UNDERS
+ if (dosave)
+ (*pScreen->PostChangeSaveUnder)(pWin, windowToValidate);
+#endif /* DO_SAVE_UNDERS */
+ if (pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pWin->parent, NullWindow, kind);
+ }
+ if (pWin->realized)
+ WindowsRestructured ();
+}
+
+#ifndef RECTLIMIT
+#define RECTLIMIT 25
+#endif
+
+static void
+miOverlayWindowExposures(
+ WindowPtr pWin,
+ register RegionPtr prgn,
+ RegionPtr other_exposed
+){
+ RegionPtr exposures = prgn;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ if (pWin->backStorage && prgn)
+ exposures = (*pScreen->RestoreAreas)(pWin, prgn);
+ if ((prgn && !REGION_NIL(prgn)) ||
+ (exposures && !REGION_NIL(exposures)) || other_exposed)
+ {
+ RegionRec expRec;
+ int clientInterested;
+
+ clientInterested = (pWin->eventMask|wOtherEventMasks(pWin)) &
+ ExposureMask;
+ if (other_exposed) {
+ if (exposures) {
+ REGION_UNION(pScreen, other_exposed, exposures, other_exposed);
+ if (exposures != prgn)
+ REGION_DESTROY(pScreen, exposures);
+ }
+ exposures = other_exposed;
+ }
+ if (clientInterested && exposures &&
+ (REGION_NUM_RECTS(exposures) > RECTLIMIT))
+ {
+ miOverlayScreenPtr pPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
+ BoxRec box;
+
+ box = *REGION_EXTENTS(pScreen, exposures);
+ if (exposures == prgn) {
+ exposures = &expRec;
+ REGION_INIT(pScreen, exposures, &box, 1);
+ REGION_RESET(pScreen, prgn, &box);
+ } else {
+ REGION_RESET(pScreen, exposures, &box);
+ REGION_UNION(pScreen, prgn, prgn, exposures);
+ }
+ /* This is the only reason why we are replacing mi's version
+ of this file */
+
+ if(!((*pPriv->InOverlay)(pWin))) {
+ miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
+ REGION_INTERSECT(pScreen, prgn, prgn, &pTree->clipList);
+ } else
+ REGION_INTERSECT(pScreen, prgn, prgn, &pWin->clipList);
+
+ /* need to clear out new areas of backing store, too */
+ if (pWin->backStorage)
+ (void) (*pScreen->ClearBackingStore)(
+ pWin,
+ box.x1 - pWin->drawable.x,
+ box.y1 - pWin->drawable.y,
+ box.x2 - box.x1,
+ box.y2 - box.y1,
+ FALSE);
+ }
+ if (prgn && !REGION_NIL(prgn))
+ (*pScreen->PaintWindowBackground)(
+ pWin, prgn, PW_BACKGROUND);
+ if (clientInterested && exposures && !REGION_NIL(exposures))
+ miSendExposures(pWin, exposures,
+ pWin->drawable.x, pWin->drawable.y);
+ if (exposures == &expRec) {
+ REGION_UNINIT(pScreen, exposures);
+ }
+ else if (exposures && exposures != prgn && exposures != other_exposed)
+ REGION_DESTROY(pScreen, exposures);
+ if (prgn)
+ REGION_EMPTY(pScreen, prgn);
+ }
+ else if (exposures && exposures != prgn)
+ REGION_DESTROY(pScreen, exposures);
+}
+
+
+typedef struct {
+ RegionPtr over;
+ RegionPtr under;
+} miOverlayTwoRegions;
+
+static int
+miOverlayRecomputeExposures (
+ WindowPtr pWin,
+ pointer value
+){
+ register ScreenPtr pScreen;
+ miOverlayTwoRegions *pValid = (miOverlayTwoRegions*)value;
+ miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
+
+ /* This prevents warning about pScreen not being used. */
+ pWin->drawable.pScreen = pScreen = pWin->drawable.pScreen;
+
+ if (pWin->valdata) {
+ /*
+ * compute exposed regions of this window
+ */
+ REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed,
+ &pWin->clipList, pValid->over);
+ /*
+ * compute exposed regions of the border
+ */
+ REGION_SUBTRACT(pScreen, &pWin->valdata->after.borderExposed,
+ &pWin->borderClip, &pWin->winSize);
+ REGION_SUBTRACT(pScreen, &pWin->valdata->after.borderExposed,
+ &pWin->valdata->after.borderExposed, pValid->over);
+ }
+
+ if(pTree && pTree->valdata) {
+ REGION_SUBTRACT(pScreen, &pTree->valdata->exposed,
+ &pTree->clipList, pValid->under);
+ REGION_SUBTRACT(pScreen, &pTree->valdata->borderExposed,
+ &pTree->borderClip, &pWin->winSize);
+ REGION_SUBTRACT(pScreen, &pTree->valdata->borderExposed,
+ &pTree->valdata->borderExposed, pValid->under);
+ } else if (!pWin->valdata)
+ return WT_NOMATCH;
+
+ return WT_WALKCHILDREN;
+}
+
+static void
+miOverlayResizeWindow(
+ WindowPtr pWin,
+ int x, int y,
+ unsigned int w, unsigned int h,
+ WindowPtr pSib
+){
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pParent;
+ miOverlayTreePtr tChild, pTree;
+ Bool WasViewable = (Bool)(pWin->viewable);
+ unsigned short width = pWin->drawable.width;
+ unsigned short height = pWin->drawable.height;
+ short oldx = pWin->drawable.x;
+ short oldy = pWin->drawable.y;
+ int bw = wBorderWidth (pWin);
+ short dw, dh;
+ DDXPointRec oldpt;
+ RegionPtr oldRegion = NULL, oldRegion2 = NULL;
+ WindowPtr pFirstChange;
+ register WindowPtr pChild;
+ RegionPtr gravitate[StaticGravity + 1];
+ RegionPtr gravitate2[StaticGravity + 1];
+ register unsigned g;
+ int nx, ny; /* destination x,y */
+ int newx, newy; /* new inner window position */
+ RegionPtr pRegion = NULL;
+ RegionPtr destClip, destClip2;
+ RegionPtr oldWinClip = NULL, oldWinClip2 = NULL;
+ RegionPtr borderVisible = NullRegion;
+ RegionPtr borderVisible2 = NullRegion;
+ RegionPtr bsExposed = NullRegion; /* backing store exposures */
+ Bool shrunk = FALSE; /* shrunk in an inner dimension */
+ Bool moved = FALSE; /* window position changed */
+#ifdef DO_SAVE_UNDERS
+ Bool dosave = FALSE;
+#endif
+ Bool doUnderlay;
+
+ /* if this is a root window, can't be resized */
+ if (!(pParent = pWin->parent))
+ return ;
+
+ pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
+ doUnderlay = ((pTree) || HasUnderlayChildren(pWin));
+ newx = pParent->drawable.x + x + bw;
+ newy = pParent->drawable.y + y + bw;
+ if (WasViewable)
+ {
+ /*
+ * save the visible region of the window
+ */
+ oldRegion = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_COPY(pScreen, oldRegion, &pWin->winSize);
+ if(doUnderlay) {
+ oldRegion2 = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_COPY(pScreen, oldRegion2, &pWin->winSize);
+ }
+
+ /*
+ * categorize child windows into regions to be moved
+ */
+ for (g = 0; g <= StaticGravity; g++)
+ gravitate[g] = gravitate2[g] = NULL;
+ for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) {
+ g = pChild->winGravity;
+ if (g != UnmapGravity) {
+ if (!gravitate[g])
+ gravitate[g] = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_UNION(pScreen, gravitate[g],
+ gravitate[g], &pChild->borderClip);
+
+ if(doUnderlay) {
+ if (!gravitate2[g])
+ gravitate2[g] = REGION_CREATE(pScreen, NullBox, 0);
+
+ if((tChild = MIOVERLAY_GET_WINDOW_TREE(pChild))) {
+ REGION_UNION(pScreen, gravitate2[g],
+ gravitate2[g], &tChild->borderClip);
+ } else
+ CollectUnderlayChildrenRegions(pChild, gravitate2[g]);
+ }
+ } else {
+ UnmapWindow(pChild, TRUE);
+ }
+ }
+ (*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
+
+
+ oldWinClip = oldWinClip2 = NULL;
+ if (pWin->bitGravity != ForgetGravity) {
+ oldWinClip = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_COPY(pScreen, oldWinClip, &pWin->clipList);
+ if(pTree) {
+ oldWinClip2 = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_COPY(pScreen, oldWinClip2, &pTree->clipList);
+ }
+ }
+ /*
+ * if the window is changing size, borderExposed
+ * can't be computed correctly without some help.
+ */
+ if (pWin->drawable.height > h || pWin->drawable.width > w)
+ shrunk = TRUE;
+
+ if (newx != oldx || newy != oldy)
+ moved = TRUE;
+
+ if ((pWin->drawable.height != h || pWin->drawable.width != w) &&
+ HasBorder (pWin))
+ {
+ borderVisible = REGION_CREATE(pScreen, NullBox, 1);
+ if(pTree)
+ borderVisible2 = REGION_CREATE(pScreen, NullBox, 1);
+ /* for tiled borders, we punt and draw the whole thing */
+ if (pWin->borderIsPixel || !moved)
+ {
+ if (shrunk || moved)
+ REGION_SUBTRACT(pScreen, borderVisible,
+ &pWin->borderClip,
+ &pWin->winSize);
+ else
+ REGION_COPY(pScreen, borderVisible,
+ &pWin->borderClip);
+ if(pTree) {
+ if (shrunk || moved)
+ REGION_SUBTRACT(pScreen, borderVisible,
+ &pTree->borderClip,
+ &pWin->winSize);
+ else
+ REGION_COPY(pScreen, borderVisible,
+ &pTree->borderClip);
+ }
+ }
+ }
+ }
+ pWin->origin.x = x + bw;
+ pWin->origin.y = y + bw;
+ pWin->drawable.height = h;
+ pWin->drawable.width = w;
+
+ x = pWin->drawable.x = newx;
+ y = pWin->drawable.y = newy;
+
+ SetWinSize (pWin);
+ SetBorderSize (pWin);
+
+ dw = (int)w - (int)width;
+ dh = (int)h - (int)height;
+ ResizeChildrenWinSize(pWin, x - oldx, y - oldy, dw, dh);
+
+ /* let the hardware adjust background and border pixmaps, if any */
+ (*pScreen->PositionWindow)(pWin, x, y);
+
+ pFirstChange = MoveWindowInStack(pWin, pSib);
+
+ if (WasViewable) {
+ pRegion = REGION_CREATE(pScreen, NullBox, 1);
+ if (pWin->backStorage)
+ REGION_COPY(pScreen, pRegion, &pWin->clipList);
+
+ (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange, NULL);
+
+ pWin->valdata->before.resized = TRUE;
+ pWin->valdata->before.borderVisible = borderVisible;
+ if(pTree)
+ pTree->valdata->borderVisible = borderVisible2;
+
+#ifdef DO_SAVE_UNDERS
+ if (DO_SAVE_UNDERS(pWin))
+ dosave = (*pScreen->ChangeSaveUnder)(pWin, pFirstChange);
+#endif /* DO_SAVE_UNDERS */
+
+ (*pScreen->ValidateTree)(pWin->parent, pFirstChange, VTOther);
+ /*
+ * the entire window is trashed unless bitGravity
+ * recovers portions of it
+ */
+ REGION_COPY(pScreen, &pWin->valdata->after.exposed, &pWin->clipList);
+ if(pTree)
+ REGION_COPY(pScreen, &pTree->valdata->exposed, &pTree->clipList);
+ }
+
+ GravityTranslate (x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny);
+
+ if (pWin->backStorage && ((pWin->backingStore == Always) || WasViewable)) {
+ if (!WasViewable)
+ pRegion = &pWin->clipList; /* a convenient empty region */
+ if (pWin->bitGravity == ForgetGravity)
+ bsExposed = (*pScreen->TranslateBackingStore)
+ (pWin, 0, 0, NullRegion, oldx, oldy);
+ else
+ bsExposed = (*pScreen->TranslateBackingStore)
+ (pWin, nx - x, ny - y, pRegion, oldx, oldy);
+ }
+
+ if (WasViewable) {
+ miOverlayScreenPtr pPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
+ miOverlayTwoRegions TwoRegions;
+
+ /* avoid the border */
+ if (HasBorder (pWin)) {
+ int offx, offy, dx, dy;
+
+ /* kruft to avoid double translates for each gravity */
+ offx = 0;
+ offy = 0;
+ for (g = 0; g <= StaticGravity; g++) {
+ if (!gravitate[g] && !gravitate2[g])
+ continue;
+
+ /* align winSize to gravitate[g].
+ * winSize is in new coordinates,
+ * gravitate[g] is still in old coordinates */
+ GravityTranslate (x, y, oldx, oldy, dw, dh, g, &nx, &ny);
+
+ dx = (oldx - nx) - offx;
+ dy = (oldy - ny) - offy;
+ if (dx || dy) {
+ REGION_TRANSLATE(pScreen, &pWin->winSize, dx, dy);
+ offx += dx;
+ offy += dy;
+ }
+ if(gravitate[g])
+ REGION_INTERSECT(pScreen, gravitate[g], gravitate[g],
+ &pWin->winSize);
+ if(gravitate2[g])
+ REGION_INTERSECT(pScreen, gravitate2[g], gravitate2[g],
+ &pWin->winSize);
+ }
+ /* get winSize back where it belongs */
+ if (offx || offy)
+ REGION_TRANSLATE(pScreen, &pWin->winSize, -offx, -offy);
+ }
+ /*
+ * add screen bits to the appropriate bucket
+ */
+
+ if (oldWinClip2)
+ {
+ REGION_COPY(pScreen, pRegion, oldWinClip2);
+ REGION_TRANSLATE(pScreen, pRegion, nx - oldx, ny - oldy);
+ REGION_INTERSECT(pScreen, oldWinClip2, pRegion, &pTree->clipList);
+
+ for (g = pWin->bitGravity + 1; g <= StaticGravity; g++) {
+ if (gravitate2[g])
+ REGION_SUBTRACT(pScreen, oldWinClip2, oldWinClip2,
+ gravitate2[g]);
+ }
+ REGION_TRANSLATE(pScreen, oldWinClip2, oldx - nx, oldy - ny);
+ g = pWin->bitGravity;
+ if (!gravitate2[g])
+ gravitate2[g] = oldWinClip2;
+ else {
+ REGION_UNION(pScreen,gravitate2[g],gravitate2[g],oldWinClip2);
+ REGION_DESTROY(pScreen, oldWinClip2);
+ }
+ }
+
+ if (oldWinClip)
+ {
+ /*
+ * clip to new clipList
+ */
+ REGION_COPY(pScreen, pRegion, oldWinClip);
+ REGION_TRANSLATE(pScreen, pRegion, nx - oldx, ny - oldy);
+ REGION_INTERSECT(pScreen, oldWinClip, pRegion, &pWin->clipList);
+ /*
+ * don't step on any gravity bits which will be copied after this
+ * region. Note -- this assumes that the regions will be copied
+ * in gravity order.
+ */
+ for (g = pWin->bitGravity + 1; g <= StaticGravity; g++) {
+ if (gravitate[g])
+ REGION_SUBTRACT(pScreen, oldWinClip, oldWinClip,
+ gravitate[g]);
+ }
+ REGION_TRANSLATE(pScreen, oldWinClip, oldx - nx, oldy - ny);
+ g = pWin->bitGravity;
+ if (!gravitate[g])
+ gravitate[g] = oldWinClip;
+ else {
+ REGION_UNION(pScreen, gravitate[g], gravitate[g], oldWinClip);
+ REGION_DESTROY(pScreen, oldWinClip);
+ }
+ }
+
+ /*
+ * move the bits on the screen
+ */
+
+ destClip = destClip2 = NULL;
+
+ for (g = 0; g <= StaticGravity; g++) {
+ if (!gravitate[g] && !gravitate2[g])
+ continue;
+
+ GravityTranslate (x, y, oldx, oldy, dw, dh, g, &nx, &ny);
+
+ oldpt.x = oldx + (x - nx);
+ oldpt.y = oldy + (y - ny);
+
+ /* Note that gravitate[g] is *translated* by CopyWindow */
+
+ /* only copy the remaining useful bits */
+
+ if(gravitate[g])
+ REGION_INTERSECT(pScreen, gravitate[g],
+ gravitate[g], oldRegion);
+ if(gravitate2[g])
+ REGION_INTERSECT(pScreen, gravitate2[g],
+ gravitate2[g], oldRegion2);
+
+ /* clip to not overwrite already copied areas */
+
+ if (destClip && gravitate[g]) {
+ REGION_TRANSLATE(pScreen, destClip, oldpt.x - x, oldpt.y - y);
+ REGION_SUBTRACT(pScreen, gravitate[g], gravitate[g], destClip);
+ REGION_TRANSLATE(pScreen, destClip, x - oldpt.x, y - oldpt.y);
+ }
+ if (destClip2 && gravitate2[g]) {
+ REGION_TRANSLATE(pScreen, destClip2, oldpt.x - x, oldpt.y - y);
+ REGION_SUBTRACT(pScreen,gravitate2[g],gravitate2[g],destClip2);
+ REGION_TRANSLATE(pScreen, destClip2, x - oldpt.x, y - oldpt.y);
+ }
+
+ /* and move those bits */
+
+ if (oldpt.x != x || oldpt.y != y) {
+ if(gravitate2[g]) {
+ pPriv->copyUnderlay = TRUE;
+ (*pWin->drawable.pScreen->CopyWindow)(
+ pWin, oldpt, gravitate2[g]);
+ }
+ if(gravitate[g]) {
+ pPriv->copyUnderlay = FALSE;
+ (*pWin->drawable.pScreen->CopyWindow)(
+ pWin, oldpt, gravitate[g]);
+ }
+ }
+
+ /* remove any overwritten bits from the remaining useful bits */
+
+ if(gravitate[g])
+ REGION_SUBTRACT(pScreen, oldRegion, oldRegion, gravitate[g]);
+ if(gravitate2[g])
+ REGION_SUBTRACT(pScreen, oldRegion2, oldRegion2, gravitate2[g]);
+
+ /*
+ * recompute exposed regions of child windows
+ */
+
+
+ for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) {
+ if (pChild->winGravity != g)
+ continue;
+
+ TwoRegions.over = gravitate[g];
+ TwoRegions.under = gravitate2[g];
+
+ TraverseTree (pChild, miOverlayRecomputeExposures,
+ (pointer)(&TwoRegions));
+ }
+
+ /*
+ * remove the successfully copied regions of the
+ * window from its exposed region
+ */
+
+ if (g == pWin->bitGravity) {
+ if(gravitate[g])
+ REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed,
+ &pWin->valdata->after.exposed, gravitate[g]);
+ if(gravitate2[g] && pTree)
+ REGION_SUBTRACT(pScreen, &pTree->valdata->exposed,
+ &pTree->valdata->exposed, gravitate2[g]);
+ }
+ if(gravitate[g]) {
+ if (!destClip)
+ destClip = gravitate[g];
+ else {
+ REGION_UNION(pScreen, destClip, destClip, gravitate[g]);
+ REGION_DESTROY(pScreen, gravitate[g]);
+ }
+ }
+ if(gravitate2[g]) {
+ if (!destClip2)
+ destClip2 = gravitate2[g];
+ else {
+ REGION_UNION(pScreen, destClip2, destClip2, gravitate2[g]);
+ REGION_DESTROY(pScreen, gravitate2[g]);
+ }
+ }
+ }
+
+ REGION_DESTROY(pScreen, pRegion);
+ REGION_DESTROY(pScreen, oldRegion);
+ if(doUnderlay)
+ REGION_DESTROY(pScreen, oldRegion2);
+ if (destClip)
+ REGION_DESTROY(pScreen, destClip);
+ if (destClip2)
+ REGION_DESTROY(pScreen, destClip2);
+ if (bsExposed) {
+ RegionPtr valExposed = NullRegion;
+
+ if (pWin->valdata)
+ valExposed = &pWin->valdata->after.exposed;
+ (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
+ if (valExposed)
+ REGION_EMPTY(pScreen, valExposed);
+ REGION_DESTROY(pScreen, bsExposed);
+ }
+ (*pScreen->HandleExposures)(pWin->parent);
+#ifdef DO_SAVE_UNDERS
+ if (dosave)
+ (*pScreen->PostChangeSaveUnder)(pWin, pFirstChange);
+#endif /* DO_SAVE_UNDERS */
+ if (pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pWin->parent, pFirstChange, VTOther);
+ }
+ else if (bsExposed) {
+ (*pScreen->WindowExposures) (pWin, NullRegion, bsExposed);
+ REGION_DESTROY(pScreen, bsExposed);
+ }
+ if (pWin->realized)
+ WindowsRestructured ();
+}
+
+
+#ifdef SHAPE
+static void
+miOverlaySetShape(WindowPtr pWin)
+{
+ Bool WasViewable = (Bool)(pWin->viewable);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RegionPtr pOldClip = NULL, bsExposed;
+#ifdef DO_SAVE_UNDERS
+ Bool dosave = FALSE;
+#endif
+
+ if (WasViewable) {
+ (*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
+
+ if (HasBorder (pWin)) {
+ RegionPtr borderVisible;
+
+ borderVisible = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_SUBTRACT(pScreen, borderVisible,
+ &pWin->borderClip, &pWin->winSize);
+ pWin->valdata->before.borderVisible = borderVisible;
+ pWin->valdata->before.resized = TRUE;
+ if(IN_UNDERLAY(pWin)) {
+ miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
+ RegionPtr borderVisible2;
+
+ borderVisible2 = REGION_CREATE(pScreen, NULL, 1);
+ REGION_SUBTRACT(pScreen, borderVisible2,
+ &pTree->borderClip, &pWin->winSize);
+ pTree->valdata->borderVisible = borderVisible2;
+ }
+ }
+ }
+
+ SetWinSize (pWin);
+ SetBorderSize (pWin);
+
+ ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
+
+ if (WasViewable) {
+ if (pWin->backStorage) {
+ pOldClip = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_COPY(pScreen, pOldClip, &pWin->clipList);
+ }
+
+ (*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
+
+#ifdef DO_SAVE_UNDERS
+ if (DO_SAVE_UNDERS(pWin))
+ dosave = (*pScreen->ChangeSaveUnder)(pWin, pWin);
+#endif /* DO_SAVE_UNDERS */
+
+ (*pScreen->ValidateTree)(pWin->parent, NullWindow, VTOther);
+ }
+
+ if (pWin->backStorage && ((pWin->backingStore == Always) || WasViewable)) {
+ if (!WasViewable)
+ pOldClip = &pWin->clipList; /* a convenient empty region */
+ bsExposed = (*pScreen->TranslateBackingStore)
+ (pWin, 0, 0, pOldClip,
+ pWin->drawable.x, pWin->drawable.y);
+ if (WasViewable)
+ REGION_DESTROY(pScreen, pOldClip);
+ if (bsExposed)
+ {
+ RegionPtr valExposed = NullRegion;
+
+ if (pWin->valdata)
+ valExposed = &pWin->valdata->after.exposed;
+ (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
+ if (valExposed)
+ REGION_EMPTY(pScreen, valExposed);
+ REGION_DESTROY(pScreen, bsExposed);
+ }
+ }
+ if (WasViewable) {
+ (*pScreen->HandleExposures)(pWin->parent);
+#ifdef DO_SAVE_UNDERS
+ if (dosave)
+ (*pScreen->PostChangeSaveUnder)(pWin, pWin);
+#endif /* DO_SAVE_UNDERS */
+ if (pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pWin->parent, NullWindow, VTOther);
+ }
+ if (pWin->realized)
+ WindowsRestructured ();
+ CheckCursorConfinement(pWin);
+}
+#endif
+
+
+
+static void
+miOverlayChangeBorderWidth(
+ WindowPtr pWin,
+ unsigned int width
+){
+ int oldwidth;
+ register ScreenPtr pScreen;
+ Bool WasViewable = (Bool)(pWin->viewable);
+ Bool HadBorder;
+#ifdef DO_SAVE_UNDERS
+ Bool dosave = FALSE;
+#endif
+
+ oldwidth = wBorderWidth (pWin);
+ if (oldwidth == width)
+ return;
+ HadBorder = HasBorder(pWin);
+ pScreen = pWin->drawable.pScreen;
+ if (WasViewable && (width < oldwidth))
+ (*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
+
+ pWin->borderWidth = width;
+ SetBorderSize (pWin);
+
+ if (WasViewable) {
+ if (width > oldwidth) {
+ (*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
+
+ if (HadBorder) {
+ RegionPtr borderVisible;
+ borderVisible = REGION_CREATE(pScreen, NULL, 1);
+ REGION_SUBTRACT(pScreen, borderVisible,
+ &pWin->borderClip, &pWin->winSize);
+ pWin->valdata->before.borderVisible = borderVisible;
+ if(IN_UNDERLAY(pWin)) {
+ miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
+ RegionPtr borderVisible2;
+
+ borderVisible2 = REGION_CREATE(pScreen, NULL, 1);
+ REGION_SUBTRACT(pScreen, borderVisible2,
+ &pTree->borderClip, &pWin->winSize);
+ pTree->valdata->borderVisible = borderVisible2;
+ }
+ }
+ }
+#ifdef DO_SAVE_UNDERS
+ if (DO_SAVE_UNDERS(pWin))
+ dosave = (*pScreen->ChangeSaveUnder)(pWin, pWin->nextSib);
+#endif /* DO_SAVE_UNDERS */
+ (*pScreen->ValidateTree)(pWin->parent, pWin, VTOther);
+ (*pScreen->HandleExposures)(pWin->parent);
+
+#ifdef DO_SAVE_UNDERS
+ if (dosave)
+ (*pScreen->PostChangeSaveUnder)(pWin, pWin->nextSib);
+#endif /* DO_SAVE_UNDERS */
+ if (pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pWin->parent, pWin, VTOther);
+ }
+ if (pWin->realized)
+ WindowsRestructured ();
+}
+
+/* We need this as an addition since the xf86 common code doesn't
+ know about the second tree which is static to this file. */
+
+void
+miOverlaySetRootClip(ScreenPtr pScreen, Bool enable)
+{
+ WindowPtr pRoot = WindowTable[pScreen->myNum];
+ miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pRoot);
+
+ MARK_UNDERLAY(pRoot);
+
+ if(enable) {
+ BoxRec box;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pScreen->width;
+ box.y2 = pScreen->height;
+
+ REGION_RESET(pScreen, &pTree->borderClip, &box);
+ } else
+ REGION_EMPTY(pScreen, &pTree->borderClip);
+
+ REGION_BREAK(pScreen, &pTree->clipList);
+}
+
+static void
+miOverlayClearToBackground(
+ WindowPtr pWin,
+ int x, int y,
+ int w, int h,
+ Bool generateExposures
+)
+{
+ miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
+ BoxRec box;
+ RegionRec reg;
+ RegionPtr pBSReg = NullRegion;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ miOverlayScreenPtr pScreenPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
+ RegionPtr clipList;
+ BoxPtr extents;
+ int x1, y1, x2, y2;
+
+ x1 = pWin->drawable.x + x;
+ y1 = pWin->drawable.y + y;
+ if (w)
+ x2 = x1 + (int) w;
+ else
+ x2 = x1 + (int) pWin->drawable.width - (int) x;
+ if (h)
+ y2 = y1 + h;
+ else
+ y2 = y1 + (int) pWin->drawable.height - (int) y;
+
+ clipList = ((*pScreenPriv->InOverlay)(pWin)) ? &pWin->clipList :
+ &pTree->clipList;
+
+ extents = REGION_EXTENTS(pScreen, clipList);
+
+ if (x1 < extents->x1) x1 = extents->x1;
+ if (x2 > extents->x2) x2 = extents->x2;
+ if (y1 < extents->y1) y1 = extents->y1;
+ if (y2 > extents->y2) y2 = extents->y2;
+
+ if (x2 <= x1 || y2 <= y1)
+ x2 = x1 = y2 = y1 = 0;
+
+ box.x1 = x1; box.x2 = x2;
+ box.y1 = y1; box.y2 = y2;
+
+ REGION_INIT(pScreen, &reg, &box, 1);
+ if (pWin->backStorage) {
+ pBSReg = (* pScreen->ClearBackingStore)(pWin, x, y, w, h,
+ generateExposures);
+ }
+
+ REGION_INTERSECT(pScreen, &reg, &reg, clipList);
+ if (generateExposures)
+ (*pScreen->WindowExposures)(pWin, &reg, pBSReg);
+ else if (pWin->backgroundState != None)
+ (*pScreen->PaintWindowBackground)(pWin, &reg, PW_BACKGROUND);
+ REGION_UNINIT(pScreen, &reg);
+ if (pBSReg)
+ REGION_DESTROY(pScreen, pBSReg);
+}
+
+
+/****************************************************************/
+
+/* not used */
+Bool
+miOverlayGetPrivateClips(
+ WindowPtr pWin,
+ RegionPtr *borderClip,
+ RegionPtr *clipList
+){
+ miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
+
+ if(pTree) {
+ *borderClip = &(pTree->borderClip);
+ *clipList = &(pTree->clipList);
+ return TRUE;
+ }
+
+ *borderClip = *clipList = NULL;
+
+ return FALSE;
+}
+
+void
+miOverlaySetTransFunction (
+ ScreenPtr pScreen,
+ miOverlayTransFunc transFunc
+){
+ MIOVERLAY_GET_SCREEN_PRIVATE(pScreen)->MakeTransparent = transFunc;
+}
+
+Bool
+miOverlayCopyUnderlay(ScreenPtr pScreen)
+{
+ return MIOVERLAY_GET_SCREEN_PRIVATE(pScreen)->copyUnderlay;
+}
+
+void
+miOverlayComputeCompositeClip(GCPtr pGC, WindowPtr pWin)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
+ RegionPtr pregWin;
+ Bool freeTmpClip, freeCompClip;
+
+ if(!pTree) {
+ miComputeCompositeClip(pGC, &pWin->drawable);
+ return;
+ }
+
+ if (pGC->subWindowMode == IncludeInferiors) {
+ pregWin = REGION_CREATE(pScreen, NullBox, 1);
+ freeTmpClip = TRUE;
+ if (pWin->parent || (screenIsSaved != SCREEN_SAVER_ON) ||
+ !HasSaverWindow (pScreen->myNum))
+ {
+ REGION_INTERSECT(pScreen,pregWin,&pTree->borderClip,&pWin->winSize);
+ }
+ } else {
+ pregWin = &pTree->clipList;
+ freeTmpClip = FALSE;
+ }
+ freeCompClip = pGC->freeCompClip;
+ if (pGC->clientClipType == CT_NONE) {
+ if (freeCompClip)
+ REGION_DESTROY(pScreen, pGC->pCompositeClip);
+ pGC->pCompositeClip = pregWin;
+ pGC->freeCompClip = freeTmpClip;
+ } else {
+ REGION_TRANSLATE(pScreen, pGC->clientClip,
+ pWin->drawable.x + pGC->clipOrg.x,
+ pWin->drawable.y + pGC->clipOrg.y);
+
+ if (freeCompClip) {
+ REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
+ pregWin, pGC->clientClip);
+ if (freeTmpClip)
+ REGION_DESTROY(pScreen, pregWin);
+ } else if (freeTmpClip) {
+ REGION_INTERSECT(pScreen, pregWin, pregWin, pGC->clientClip);
+ pGC->pCompositeClip = pregWin;
+ } else {
+ pGC->pCompositeClip = REGION_CREATE(pScreen, NullBox, 0);
+ REGION_INTERSECT(pScreen, pGC->pCompositeClip,
+ pregWin, pGC->clientClip);
+ }
+ pGC->freeCompClip = TRUE;
+ REGION_TRANSLATE(pScreen, pGC->clientClip,
+ -(pWin->drawable.x + pGC->clipOrg.x),
+ -(pWin->drawable.y + pGC->clipOrg.y));
+ }
+}
+
+Bool
+miOverlayCollectUnderlayRegions(
+ WindowPtr pWin,
+ RegionPtr *region
+){
+ miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
+
+ if(pTree) {
+ *region = &pTree->borderClip;
+ return FALSE;
+ }
+
+ *region = REGION_CREATE(pWin->drawable.pScreen, NullBox, 0);
+
+ CollectUnderlayChildrenRegions(pWin, *region);
+
+ return TRUE;
+}
+
+
+static miOverlayTreePtr
+DoLeaf(
+ WindowPtr pWin,
+ miOverlayTreePtr parent,
+ miOverlayTreePtr prevSib
+){
+ miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
+
+ pTree->parent = parent;
+ pTree->firstChild = NULL;
+ pTree->lastChild = NULL;
+ pTree->prevSib = prevSib;
+ pTree->nextSib = NULL;
+
+ if(prevSib)
+ prevSib->nextSib = pTree;
+
+ if(!parent->firstChild)
+ parent->firstChild = parent->lastChild = pTree;
+ else if(parent->lastChild == prevSib)
+ parent->lastChild = pTree;
+
+ return pTree;
+}
+
+static void
+RebuildTree(WindowPtr pWin)
+{
+ miOverlayTreePtr parent, prevSib, tChild;
+ WindowPtr pChild;
+
+ prevSib = tChild = NULL;
+
+ pWin = pWin->parent;
+
+ while(IN_OVERLAY(pWin))
+ pWin = pWin->parent;
+
+ parent = MIOVERLAY_GET_WINDOW_TREE(pWin);
+
+ pChild = pWin->firstChild;
+ parent->firstChild = parent->lastChild = NULL;
+
+ while(1) {
+ if(IN_UNDERLAY(pChild))
+ prevSib = tChild = DoLeaf(pChild, parent, prevSib);
+
+ if(pChild->firstChild) {
+ if(IN_UNDERLAY(pChild)) {
+ parent = tChild;
+ prevSib = NULL;
+ }
+ pChild = pChild->firstChild;
+ continue;
+ }
+
+ while(!pChild->nextSib) {
+ pChild = pChild->parent;
+ if(pChild == pWin) return;
+ if(IN_UNDERLAY(pChild)) {
+ prevSib = tChild = MIOVERLAY_GET_WINDOW_TREE(pChild);
+ parent = tChild->parent;
+ }
+ }
+
+ pChild = pChild->nextSib;
+ }
+}
+
+
+static Bool
+HasUnderlayChildren(WindowPtr pWin)
+{
+ WindowPtr pChild;
+
+ if(!(pChild = pWin->firstChild))
+ return FALSE;
+
+ while(1) {
+ if(IN_UNDERLAY(pChild))
+ return TRUE;
+
+ if(pChild->firstChild) {
+ pChild = pChild->firstChild;
+ continue;
+ }
+
+ while(!pChild->nextSib && (pWin != pChild))
+ pChild = pChild->parent;
+
+ if(pChild == pWin) break;
+
+ pChild = pChild->nextSib;
+ }
+
+ return FALSE;
+}
+
+
+static Bool
+CollectUnderlayChildrenRegions(WindowPtr pWin, RegionPtr pReg)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pChild;
+ miOverlayTreePtr pTree;
+ Bool hasUnderlay;
+
+ if(!(pChild = pWin->firstChild))
+ return FALSE;
+
+ hasUnderlay = FALSE;
+
+ while(1) {
+ if((pTree = MIOVERLAY_GET_WINDOW_TREE(pChild))) {
+ REGION_APPEND(pScreen, pReg, &pTree->borderClip);
+ hasUnderlay = TRUE;
+ } else
+ if(pChild->firstChild) {
+ pChild = pChild->firstChild;
+ continue;
+ }
+
+ while(!pChild->nextSib && (pWin != pChild))
+ pChild = pChild->parent;
+
+ if(pChild == pWin) break;
+
+ pChild = pChild->nextSib;
+ }
+
+ if(hasUnderlay) {
+ Bool overlap;
+ REGION_VALIDATE(pScreen, pReg, &overlap);
+ }
+
+ return hasUnderlay;
+}
+
+
+static void
+MarkUnderlayWindow(WindowPtr pWin)
+{
+ miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
+
+ if(pTree->valdata) return;
+ pTree->valdata = (miOverlayValDataPtr)xnfalloc(sizeof(miOverlayValDataRec));
+ pTree->valdata->oldAbsCorner.x = pWin->drawable.x;
+ pTree->valdata->oldAbsCorner.y = pWin->drawable.y;
+ pTree->valdata->borderVisible = NullRegion;
+}
diff --git a/nx-X11/programs/Xserver/mi/mioverlay.h b/nx-X11/programs/Xserver/mi/mioverlay.h
new file mode 100644
index 000000000..a1d1e1a18
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mioverlay.h
@@ -0,0 +1,33 @@
+/* $XFree86: xc/programs/Xserver/mi/mioverlay.h,v 3.3 2000/02/29 00:16:03 mvojkovi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef __MIOVERLAY_H
+#define __MIOVERLAY_H
+
+typedef void (*miOverlayTransFunc)(ScreenPtr, int, BoxPtr);
+typedef Bool (*miOverlayInOverlayFunc)(WindowPtr);
+
+Bool
+miInitOverlay(
+ ScreenPtr pScreen,
+ miOverlayInOverlayFunc inOverlay,
+ miOverlayTransFunc trans
+);
+
+Bool
+miOverlayGetPrivateClips(
+ WindowPtr pWin,
+ RegionPtr *borderClip,
+ RegionPtr *clipList
+);
+
+Bool miOverlayCollectUnderlayRegions(WindowPtr, RegionPtr*);
+void miOverlayComputeCompositeClip(GCPtr, WindowPtr);
+Bool miOverlayCopyUnderlay(ScreenPtr);
+void miOverlaySetTransFunction(ScreenPtr, miOverlayTransFunc);
+void miOverlaySetRootClip(ScreenPtr, Bool);
+
+#endif /* __MIOVERLAY_H */
diff --git a/nx-X11/programs/Xserver/mi/mipointer.c b/nx-X11/programs/Xserver/mi/mipointer.c
new file mode 100644
index 000000000..432cc1606
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mipointer.c
@@ -0,0 +1,544 @@
+/*
+ * mipointer.c
+ */
+
+/* $Xorg: mipointer.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+/* $XFree86: xc/programs/Xserver/mi/mipointer.c,v 3.9 2001/09/04 14:03:28 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+# define NEED_EVENTS
+# include <X11/X.h>
+# include <X11/Xmd.h>
+# include <X11/Xproto.h>
+# include "misc.h"
+# include "windowstr.h"
+# include "pixmapstr.h"
+# include "mi.h"
+# include "scrnintstr.h"
+# include "mipointrst.h"
+# include "cursorstr.h"
+# include "dixstruct.h"
+
+int miPointerScreenIndex;
+static unsigned long miPointerGeneration = 0;
+
+#define GetScreenPrivate(s) ((miPointerScreenPtr) ((s)->devPrivates[miPointerScreenIndex].ptr))
+#define SetupScreen(s) miPointerScreenPtr pScreenPriv = GetScreenPrivate(s)
+
+/*
+ * until more than one pointer device exists.
+ */
+
+static miPointerRec miPointer;
+
+static Bool miPointerRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
+static Bool miPointerUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
+static Bool miPointerDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor);
+static void miPointerConstrainCursor(ScreenPtr pScreen, BoxPtr pBox);
+static void miPointerPointerNonInterestBox(ScreenPtr pScreen, BoxPtr pBox);
+static void miPointerCursorLimits(ScreenPtr pScreen, CursorPtr pCursor,
+ BoxPtr pHotBox, BoxPtr pTopLeftBox);
+static Bool miPointerSetCursorPosition(ScreenPtr pScreen, int x, int y,
+ Bool generateEvent);
+static Bool miPointerCloseScreen(int index, ScreenPtr pScreen);
+static void miPointerMove(ScreenPtr pScreen, int x, int y, unsigned long time);
+
+Bool
+miPointerInitialize (pScreen, spriteFuncs, screenFuncs, waitForUpdate)
+ ScreenPtr pScreen;
+ miPointerSpriteFuncPtr spriteFuncs;
+ miPointerScreenFuncPtr screenFuncs;
+ Bool waitForUpdate;
+{
+ miPointerScreenPtr pScreenPriv;
+
+ if (miPointerGeneration != serverGeneration)
+ {
+ miPointerScreenIndex = AllocateScreenPrivateIndex();
+ if (miPointerScreenIndex < 0)
+ return FALSE;
+ miPointerGeneration = serverGeneration;
+ }
+ pScreenPriv = (miPointerScreenPtr) xalloc (sizeof (miPointerScreenRec));
+ if (!pScreenPriv)
+ return FALSE;
+ pScreenPriv->spriteFuncs = spriteFuncs;
+ pScreenPriv->screenFuncs = screenFuncs;
+ /*
+ * check for uninitialized methods
+ */
+ if (!screenFuncs->EnqueueEvent)
+ screenFuncs->EnqueueEvent = mieqEnqueue;
+ if (!screenFuncs->NewEventScreen)
+ screenFuncs->NewEventScreen = mieqSwitchScreen;
+ pScreenPriv->waitForUpdate = waitForUpdate;
+ pScreenPriv->showTransparent = FALSE;
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = miPointerCloseScreen;
+ pScreen->devPrivates[miPointerScreenIndex].ptr = (pointer) pScreenPriv;
+ /*
+ * set up screen cursor method table
+ */
+ pScreen->ConstrainCursor = miPointerConstrainCursor;
+ pScreen->CursorLimits = miPointerCursorLimits;
+ pScreen->DisplayCursor = miPointerDisplayCursor;
+ pScreen->RealizeCursor = miPointerRealizeCursor;
+ pScreen->UnrealizeCursor = miPointerUnrealizeCursor;
+ pScreen->SetCursorPosition = miPointerSetCursorPosition;
+ pScreen->RecolorCursor = miRecolorCursor;
+ pScreen->PointerNonInterestBox = miPointerPointerNonInterestBox;
+ /*
+ * set up the pointer object
+ */
+ miPointer.pScreen = NULL;
+ miPointer.pSpriteScreen = NULL;
+ miPointer.pCursor = NULL;
+ miPointer.pSpriteCursor = NULL;
+ miPointer.limits.x1 = 0;
+ miPointer.limits.x2 = 32767;
+ miPointer.limits.y1 = 0;
+ miPointer.limits.y2 = 32767;
+ miPointer.confined = FALSE;
+ miPointer.x = 0;
+ miPointer.y = 0;
+ miPointer.history_start = miPointer.history_end = 0;
+ return TRUE;
+}
+
+static Bool
+miPointerCloseScreen (index, pScreen)
+ int index;
+ ScreenPtr pScreen;
+{
+ SetupScreen(pScreen);
+
+ if (pScreen == miPointer.pScreen)
+ miPointer.pScreen = 0;
+ if (pScreen == miPointer.pSpriteScreen)
+ miPointer.pSpriteScreen = 0;
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+ xfree ((pointer) pScreenPriv);
+ return (*pScreen->CloseScreen) (index, pScreen);
+}
+
+/*
+ * DIX/DDX interface routines
+ */
+
+static Bool
+miPointerRealizeCursor (pScreen, pCursor)
+ ScreenPtr pScreen;
+ CursorPtr pCursor;
+{
+ SetupScreen(pScreen);
+
+ return (*pScreenPriv->spriteFuncs->RealizeCursor) (pScreen, pCursor);
+}
+
+static Bool
+miPointerUnrealizeCursor (pScreen, pCursor)
+ ScreenPtr pScreen;
+ CursorPtr pCursor;
+{
+ SetupScreen(pScreen);
+
+ return (*pScreenPriv->spriteFuncs->UnrealizeCursor) (pScreen, pCursor);
+}
+
+static Bool
+miPointerDisplayCursor (pScreen, pCursor)
+ ScreenPtr pScreen;
+ CursorPtr pCursor;
+{
+ miPointer.pCursor = pCursor;
+ miPointer.pScreen = pScreen;
+ miPointerUpdate ();
+ return TRUE;
+}
+
+static void
+miPointerConstrainCursor (pScreen, pBox)
+ ScreenPtr pScreen;
+ BoxPtr pBox;
+{
+ miPointer.limits = *pBox;
+ miPointer.confined = PointerConfinedToScreen();
+}
+
+/*ARGSUSED*/
+static void
+miPointerPointerNonInterestBox (pScreen, pBox)
+ ScreenPtr pScreen;
+ BoxPtr pBox;
+{
+ /* until DIX uses this, this will remain a stub */
+}
+
+/*ARGSUSED*/
+static void
+miPointerCursorLimits(pScreen, pCursor, pHotBox, pTopLeftBox)
+ ScreenPtr pScreen;
+ CursorPtr pCursor;
+ BoxPtr pHotBox;
+ BoxPtr pTopLeftBox;
+{
+ *pTopLeftBox = *pHotBox;
+}
+
+static Bool GenerateEvent;
+
+static Bool
+miPointerSetCursorPosition(pScreen, x, y, generateEvent)
+ ScreenPtr pScreen;
+ int x, y;
+ Bool generateEvent;
+{
+ SetupScreen (pScreen);
+
+ GenerateEvent = generateEvent;
+ /* device dependent - must pend signal and call miPointerWarpCursor */
+ (*pScreenPriv->screenFuncs->WarpCursor) (pScreen, x, y);
+ if (!generateEvent)
+ miPointerUpdate();
+ return TRUE;
+}
+
+/* Once signals are ignored, the WarpCursor function can call this */
+
+void
+miPointerWarpCursor (pScreen, x, y)
+ ScreenPtr pScreen;
+ int x, y;
+{
+ SetupScreen (pScreen);
+
+ if (miPointer.pScreen != pScreen)
+ (*pScreenPriv->screenFuncs->NewEventScreen) (pScreen, TRUE);
+
+ if (GenerateEvent)
+ {
+ miPointerMove (pScreen, x, y, GetTimeInMillis());
+ }
+ else
+ {
+ /* everything from miPointerMove except the event and history */
+
+ if (!pScreenPriv->waitForUpdate && pScreen == miPointer.pSpriteScreen)
+ {
+ miPointer.devx = x;
+ miPointer.devy = y;
+ if(!miPointer.pCursor->bits->emptyMask)
+ (*pScreenPriv->spriteFuncs->MoveCursor) (pScreen, x, y);
+ }
+ miPointer.x = x;
+ miPointer.y = y;
+ miPointer.pScreen = pScreen;
+ }
+}
+
+/*
+ * Pointer/CursorDisplay interface routines
+ */
+
+int
+miPointerGetMotionBufferSize ()
+{
+ return MOTION_SIZE;
+}
+
+int
+miPointerGetMotionEvents (pPtr, coords, start, stop, pScreen)
+ DeviceIntPtr pPtr;
+ xTimecoord *coords;
+ unsigned long start, stop;
+ ScreenPtr pScreen;
+{
+ int i;
+ int count = 0;
+ miHistoryPtr h;
+
+ for (i = miPointer.history_start; i != miPointer.history_end;)
+ {
+ h = &miPointer.history[i];
+ if (h->event.time >= stop)
+ break;
+ if (h->event.time >= start)
+ {
+ *coords++ = h->event;
+ count++;
+ }
+ if (++i == MOTION_SIZE) i = 0;
+ }
+ return count;
+}
+
+
+/*
+ * miPointerUpdate
+ *
+ * Syncronize the sprite with the cursor - called from ProcessInputEvents
+ */
+
+void
+miPointerUpdate ()
+{
+ ScreenPtr pScreen;
+ miPointerScreenPtr pScreenPriv;
+ CursorPtr pCursor;
+ int x, y, devx, devy;
+
+ pScreen = miPointer.pScreen;
+ x = miPointer.x;
+ y = miPointer.y;
+ devx = miPointer.devx;
+ devy = miPointer.devy;
+ if (!pScreen)
+ return;
+ pScreenPriv = GetScreenPrivate (pScreen);
+ /*
+ * if the cursor has switched screens, disable the sprite
+ * on the old screen
+ */
+ if (pScreen != miPointer.pSpriteScreen)
+ {
+ if (miPointer.pSpriteScreen)
+ {
+ miPointerScreenPtr pOldPriv;
+
+ pOldPriv = GetScreenPrivate (miPointer.pSpriteScreen);
+ if (miPointer.pCursor)
+ {
+ (*pOldPriv->spriteFuncs->SetCursor)
+ (miPointer.pSpriteScreen, NullCursor, 0, 0);
+ }
+ (*pOldPriv->screenFuncs->CrossScreen) (miPointer.pSpriteScreen, FALSE);
+ }
+ (*pScreenPriv->screenFuncs->CrossScreen) (pScreen, TRUE);
+ (*pScreenPriv->spriteFuncs->SetCursor)
+ (pScreen, miPointer.pCursor, x, y);
+ miPointer.devx = x;
+ miPointer.devy = y;
+ miPointer.pSpriteCursor = miPointer.pCursor;
+ miPointer.pSpriteScreen = pScreen;
+ }
+ /*
+ * if the cursor has changed, display the new one
+ */
+ else if (miPointer.pCursor != miPointer.pSpriteCursor)
+ {
+ pCursor = miPointer.pCursor;
+ if (pCursor->bits->emptyMask && !pScreenPriv->showTransparent)
+ pCursor = NullCursor;
+ (*pScreenPriv->spriteFuncs->SetCursor) (pScreen, pCursor, x, y);
+
+ miPointer.devx = x;
+ miPointer.devy = y;
+ miPointer.pSpriteCursor = miPointer.pCursor;
+ }
+ else if (x != devx || y != devy)
+ {
+ miPointer.devx = x;
+ miPointer.devy = y;
+ if(!miPointer.pCursor->bits->emptyMask)
+ (*pScreenPriv->spriteFuncs->MoveCursor) (pScreen, x, y);
+ }
+}
+
+/*
+ * miPointerDeltaCursor. The pointer has moved dx,dy from it's previous
+ * position.
+ */
+
+void
+miPointerDeltaCursor (dx, dy, time)
+ int dx, dy;
+ unsigned long time;
+{
+ miPointerAbsoluteCursor (miPointer.x + dx, miPointer.y + dy, time);
+}
+
+void
+miPointerSetNewScreen(int screen_no, int x, int y)
+{
+ miPointerScreenPtr pScreenPriv;
+ ScreenPtr pScreen;
+
+ pScreen = screenInfo.screens[screen_no];
+ pScreenPriv = GetScreenPrivate (pScreen);
+ (*pScreenPriv->screenFuncs->NewEventScreen) (pScreen, FALSE);
+ NewCurrentScreen (pScreen, x, y);
+ miPointer.limits.x2 = pScreen->width;
+ miPointer.limits.y2 = pScreen->height;
+}
+
+ScreenPtr
+miPointerCurrentScreen ()
+{
+ return (miPointer.pScreen);
+}
+
+/*
+ * miPointerAbsoluteCursor. The pointer has moved to x,y
+ */
+
+void
+miPointerAbsoluteCursor (x, y, time)
+ int x, y;
+ unsigned long time;
+{
+ miPointerScreenPtr pScreenPriv;
+ ScreenPtr pScreen;
+ ScreenPtr newScreen;
+
+ pScreen = miPointer.pScreen;
+ if (!pScreen)
+ return; /* called before ready */
+ if (x < 0 || x >= pScreen->width || y < 0 || y >= pScreen->height)
+ {
+ pScreenPriv = GetScreenPrivate (pScreen);
+ if (!miPointer.confined)
+ {
+ newScreen = pScreen;
+ (*pScreenPriv->screenFuncs->CursorOffScreen) (&newScreen, &x, &y);
+ if (newScreen != pScreen)
+ {
+ pScreen = newScreen;
+ (*pScreenPriv->screenFuncs->NewEventScreen) (pScreen, FALSE);
+ pScreenPriv = GetScreenPrivate (pScreen);
+ /* Smash the confine to the new screen */
+ miPointer.limits.x2 = pScreen->width;
+ miPointer.limits.y2 = pScreen->height;
+ }
+ }
+ }
+ /*
+ * constrain the hot-spot to the current
+ * limits
+ */
+ if (x < miPointer.limits.x1)
+ x = miPointer.limits.x1;
+ if (x >= miPointer.limits.x2)
+ x = miPointer.limits.x2 - 1;
+ if (y < miPointer.limits.y1)
+ y = miPointer.limits.y1;
+ if (y >= miPointer.limits.y2)
+ y = miPointer.limits.y2 - 1;
+ if (miPointer.x == x && miPointer.y == y && miPointer.pScreen == pScreen)
+ return;
+ miPointerMove (pScreen, x, y, time);
+}
+
+void
+miPointerPosition (x, y)
+ int *x, *y;
+{
+ *x = miPointer.x;
+ *y = miPointer.y;
+}
+
+/*
+ * miPointerMove. The pointer has moved to x,y on current screen
+ */
+
+static void
+miPointerMove (pScreen, x, y, time)
+ ScreenPtr pScreen;
+ int x, y;
+ unsigned long time;
+{
+ SetupScreen(pScreen);
+ xEvent xE;
+ miHistoryPtr history;
+ int prev, end, start;
+
+ if (!pScreenPriv->waitForUpdate && pScreen == miPointer.pSpriteScreen)
+ {
+ miPointer.devx = x;
+ miPointer.devy = y;
+ if(!miPointer.pCursor->bits->emptyMask)
+ (*pScreenPriv->spriteFuncs->MoveCursor) (pScreen, x, y);
+ }
+ miPointer.x = x;
+ miPointer.y = y;
+ miPointer.pScreen = pScreen;
+
+ xE.u.u.type = MotionNotify;
+ xE.u.keyButtonPointer.rootX = x;
+ xE.u.keyButtonPointer.rootY = y;
+ xE.u.keyButtonPointer.time = time;
+ (*pScreenPriv->screenFuncs->EnqueueEvent) (&xE);
+
+ end = miPointer.history_end;
+ start = miPointer.history_start;
+ prev = end - 1;
+ if (end == 0)
+ prev = MOTION_SIZE - 1;
+ history = &miPointer.history[prev];
+ if (end == start || history->event.time != time)
+ {
+ history = &miPointer.history[end];
+ if (++end == MOTION_SIZE)
+ end = 0;
+ if (end == start)
+ {
+ start = end + 1;
+ if (start == MOTION_SIZE)
+ start = 0;
+ miPointer.history_start = start;
+ }
+ miPointer.history_end = end;
+ }
+ history->event.x = x;
+ history->event.y = y;
+ history->event.time = time;
+ history->pScreen = pScreen;
+}
+
+void
+_miRegisterPointerDevice (pScreen, pDevice)
+ ScreenPtr pScreen;
+ DeviceIntPtr pDevice;
+{
+ miPointer.pPointer = (DevicePtr)pDevice;
+}
+
+/* obsolete: for binary compatibility */
+
+#ifdef miRegisterPointerDevice
+#undef miRegisterPointerDevice
+void
+miRegisterPointerDevice (pScreen, pDevice)
+ ScreenPtr pScreen;
+ DevicePtr pDevice;
+{
+ miPointer.pPointer = pDevice;
+}
+#endif /* miRegisterPointerDevice */
diff --git a/nx-X11/programs/Xserver/mi/mipointer.h b/nx-X11/programs/Xserver/mi/mipointer.h
new file mode 100644
index 000000000..f8e7fd084
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mipointer.h
@@ -0,0 +1,162 @@
+/*
+ * mipointer.h
+ *
+ */
+
+/* $Xorg: mipointer.h,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+/* $XFree86: xc/programs/Xserver/mi/mipointer.h,v 3.8 2001/08/06 20:51:19 dawes Exp $ */
+
+#ifndef MIPOINTER_H
+#define MIPOINTER_H
+
+#include "cursor.h"
+#include "input.h"
+
+typedef struct _miPointerSpriteFuncRec {
+ Bool (*RealizeCursor)(
+ ScreenPtr /* pScr */,
+ CursorPtr /* pCurs */
+ );
+ Bool (*UnrealizeCursor)(
+ ScreenPtr /* pScr */,
+ CursorPtr /* pCurs */
+ );
+ void (*SetCursor)(
+ ScreenPtr /* pScr */,
+ CursorPtr /* pCurs */,
+ int /* x */,
+ int /* y */
+ );
+ void (*MoveCursor)(
+ ScreenPtr /* pScr */,
+ int /* x */,
+ int /* y */
+ );
+} miPointerSpriteFuncRec, *miPointerSpriteFuncPtr;
+
+typedef struct _miPointerScreenFuncRec {
+ Bool (*CursorOffScreen)(
+ ScreenPtr* /* ppScr */,
+ int* /* px */,
+ int* /* py */
+ );
+ void (*CrossScreen)(
+ ScreenPtr /* pScr */,
+ int /* entering */
+ );
+ void (*WarpCursor)(
+ ScreenPtr /* pScr */,
+ int /* x */,
+ int /* y */
+ );
+ void (*EnqueueEvent)(
+ xEventPtr /* event */
+ );
+ void (*NewEventScreen)(
+ ScreenPtr /* pScr */,
+ Bool /* fromDIX */
+ );
+} miPointerScreenFuncRec, *miPointerScreenFuncPtr;
+
+extern Bool miDCInitialize(
+ ScreenPtr /*pScreen*/,
+ miPointerScreenFuncPtr /*screenFuncs*/
+);
+
+extern Bool miPointerInitialize(
+ ScreenPtr /*pScreen*/,
+ miPointerSpriteFuncPtr /*spriteFuncs*/,
+ miPointerScreenFuncPtr /*screenFuncs*/,
+ Bool /*waitForUpdate*/
+);
+
+extern void miPointerWarpCursor(
+ ScreenPtr /*pScreen*/,
+ int /*x*/,
+ int /*y*/
+);
+
+extern int miPointerGetMotionBufferSize(
+ void
+);
+
+extern int miPointerGetMotionEvents(
+ DeviceIntPtr /*pPtr*/,
+ xTimecoord * /*coords*/,
+ unsigned long /*start*/,
+ unsigned long /*stop*/,
+ ScreenPtr /*pScreen*/
+);
+
+extern void miPointerUpdate(
+ void
+);
+
+extern void miPointerDeltaCursor(
+ int /*dx*/,
+ int /*dy*/,
+ unsigned long /*time*/
+);
+
+extern void miPointerAbsoluteCursor(
+ int /*x*/,
+ int /*y*/,
+ unsigned long /*time*/
+);
+
+extern void miPointerPosition(
+ int * /*x*/,
+ int * /*y*/
+);
+
+#undef miRegisterPointerDevice
+extern void miRegisterPointerDevice(
+ ScreenPtr /*pScreen*/,
+ DevicePtr /*pDevice*/
+);
+
+extern void miPointerSetNewScreen(
+ int, /*screen_no*/
+ int, /*x*/
+ int /*y*/
+);
+extern ScreenPtr miPointerCurrentScreen(
+ void
+);
+
+#define miRegisterPointerDevice(pScreen,pDevice) \
+ _miRegisterPointerDevice(pScreen,pDevice)
+
+extern void _miRegisterPointerDevice(
+ ScreenPtr /*pScreen*/,
+ DeviceIntPtr /*pDevice*/
+);
+
+extern int miPointerScreenIndex;
+
+#endif /* MIPOINTER_H */
diff --git a/nx-X11/programs/Xserver/mi/mipointrst.h b/nx-X11/programs/Xserver/mi/mipointrst.h
new file mode 100644
index 000000000..682f8ac88
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mipointrst.h
@@ -0,0 +1,64 @@
+/*
+ * mipointrst.h
+ *
+ */
+
+/* $Xorg: mipointrst.h,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+/* $XFree86: xc/programs/Xserver/mi/mipointrst.h,v 1.3 2001/04/19 14:14:07 tsi Exp $ */
+
+#include "mipointer.h"
+#include "scrnintstr.h"
+
+#define MOTION_SIZE 256
+
+typedef struct {
+ xTimecoord event;
+ ScreenPtr pScreen;
+} miHistoryRec, *miHistoryPtr;
+
+typedef struct {
+ ScreenPtr pScreen; /* current screen */
+ ScreenPtr pSpriteScreen;/* screen containing current sprite */
+ CursorPtr pCursor; /* current cursor */
+ CursorPtr pSpriteCursor;/* cursor on screen */
+ BoxRec limits; /* current constraints */
+ Bool confined; /* pointer can't change screens */
+ int x, y; /* hot spot location */
+ int devx, devy; /* sprite position */
+ DevicePtr pPointer; /* pointer device structure */
+ miHistoryRec history[MOTION_SIZE];
+ int history_start, history_end;
+} miPointerRec, *miPointerPtr;
+
+typedef struct {
+ miPointerSpriteFuncPtr spriteFuncs; /* sprite-specific methods */
+ miPointerScreenFuncPtr screenFuncs; /* screen-specific methods */
+ CloseScreenProcPtr CloseScreen;
+ Bool waitForUpdate; /* don't move cursor in SIGIO */
+ Bool showTransparent; /* show empty cursors */
+} miPointerScreenRec, *miPointerScreenPtr;
diff --git a/nx-X11/programs/Xserver/mi/mipoly.c b/nx-X11/programs/Xserver/mi/mipoly.c
new file mode 100644
index 000000000..403d3da56
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mipoly.c
@@ -0,0 +1,129 @@
+/* $XFree86$ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mipoly.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+/*
+ * mipoly.c
+ *
+ * Written by Brian Kelleher; June 1986
+ *
+ * Draw polygons. This routine translates the point by the
+ * origin if pGC->miTranslate is non-zero, and calls
+ * to the appropriate routine to actually scan convert the
+ * polygon.
+ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "mi.h"
+#include "regionstr.h"
+
+
+void
+miFillPolygon(dst, pgc, shape, mode, count, pPts)
+ DrawablePtr dst;
+ register GCPtr pgc;
+ int shape, mode;
+ register int count;
+ DDXPointPtr pPts;
+{
+ int i;
+ register int xorg, yorg;
+ register DDXPointPtr ppt;
+
+ if (count == 0)
+ return;
+
+ ppt = pPts;
+ if (pgc->miTranslate)
+ {
+ xorg = dst->x;
+ yorg = dst->y;
+
+ if (mode == CoordModeOrigin)
+ {
+ for (i = 0; i<count; i++)
+ {
+ ppt->x += xorg;
+ ppt++->y += yorg;
+ }
+ }
+ else
+ {
+ ppt->x += xorg;
+ ppt++->y += yorg;
+ for (i = 1; i<count; i++)
+ {
+ ppt->x += (ppt-1)->x;
+ ppt->y += (ppt-1)->y;
+ ppt++;
+ }
+ }
+ }
+ else
+ {
+ if (mode == CoordModePrevious)
+ {
+ ppt++;
+ for (i = 1; i<count; i++)
+ {
+ ppt->x += (ppt-1)->x;
+ ppt->y += (ppt-1)->y;
+ ppt++;
+ }
+ }
+ }
+ if (shape == Convex)
+ miFillConvexPoly(dst, pgc, count, pPts);
+ else
+ miFillGeneralPoly(dst, pgc, count, pPts);
+}
diff --git a/nx-X11/programs/Xserver/mi/mipoly.h b/nx-X11/programs/Xserver/mi/mipoly.h
new file mode 100644
index 000000000..88a1782de
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mipoly.h
@@ -0,0 +1,217 @@
+/* $Xorg: mipoly.h,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/mi/mipoly.h,v 1.2 2001/08/06 20:51:19 dawes Exp $ */
+
+
+/*
+ * fill.h
+ *
+ * Created by Brian Kelleher; Oct 1985
+ *
+ * Include file for filled polygon routines.
+ *
+ * These are the data structures needed to scan
+ * convert regions. Two different scan conversion
+ * methods are available -- the even-odd method, and
+ * the winding number method.
+ * The even-odd rule states that a point is inside
+ * the polygon if a ray drawn from that point in any
+ * direction will pass through an odd number of
+ * path segments.
+ * By the winding number rule, a point is decided
+ * to be inside the polygon if a ray drawn from that
+ * point in any direction passes through a different
+ * number of clockwise and counter-clockwise path
+ * segments.
+ *
+ * These data structures are adapted somewhat from
+ * the algorithm in (Foley/Van Dam) for scan converting
+ * polygons.
+ * The basic algorithm is to start at the top (smallest y)
+ * of the polygon, stepping down to the bottom of
+ * the polygon by incrementing the y coordinate. We
+ * keep a list of edges which the current scanline crosses,
+ * sorted by x. This list is called the Active Edge Table (AET)
+ * As we change the y-coordinate, we update each entry in
+ * in the active edge table to reflect the edges new xcoord.
+ * This list must be sorted at each scanline in case
+ * two edges intersect.
+ * We also keep a data structure known as the Edge Table (ET),
+ * which keeps track of all the edges which the current
+ * scanline has not yet reached. The ET is basically a
+ * list of ScanLineList structures containing a list of
+ * edges which are entered at a given scanline. There is one
+ * ScanLineList per scanline at which an edge is entered.
+ * When we enter a new edge, we move it from the ET to the AET.
+ *
+ * From the AET, we can implement the even-odd rule as in
+ * (Foley/Van Dam).
+ * The winding number rule is a little trickier. We also
+ * keep the EdgeTableEntries in the AET linked by the
+ * nextWETE (winding EdgeTableEntry) link. This allows
+ * the edges to be linked just as before for updating
+ * purposes, but only uses the edges linked by the nextWETE
+ * link as edges representing spans of the polygon to
+ * drawn (as with the even-odd rule).
+ */
+
+/*
+ * for the winding number rule
+ */
+#define CLOCKWISE 1
+#define COUNTERCLOCKWISE -1
+
+typedef struct _EdgeTableEntry {
+ int ymax; /* ycoord at which we exit this edge. */
+ BRESINFO bres; /* Bresenham info to run the edge */
+ struct _EdgeTableEntry *next; /* next in the list */
+ struct _EdgeTableEntry *back; /* for insertion sort */
+ struct _EdgeTableEntry *nextWETE; /* for winding num rule */
+ int ClockWise; /* flag for winding number rule */
+} EdgeTableEntry;
+
+
+typedef struct _ScanLineList{
+ int scanline; /* the scanline represented */
+ EdgeTableEntry *edgelist; /* header node */
+ struct _ScanLineList *next; /* next in the list */
+} ScanLineList;
+
+
+typedef struct {
+ int ymax; /* ymax for the polygon */
+ int ymin; /* ymin for the polygon */
+ ScanLineList scanlines; /* header node */
+} EdgeTable;
+
+
+/*
+ * Here is a struct to help with storage allocation
+ * so we can allocate a big chunk at a time, and then take
+ * pieces from this heap when we need to.
+ */
+#define SLLSPERBLOCK 25
+
+typedef struct _ScanLineListBlock {
+ ScanLineList SLLs[SLLSPERBLOCK];
+ struct _ScanLineListBlock *next;
+} ScanLineListBlock;
+
+/*
+ * number of points to buffer before sending them off
+ * to scanlines() : Must be an even number
+ */
+#define NUMPTSTOBUFFER 200
+
+
+/*
+ *
+ * a few macros for the inner loops of the fill code where
+ * performance considerations don't allow a procedure call.
+ *
+ * Evaluate the given edge at the given scanline.
+ * If the edge has expired, then we leave it and fix up
+ * the active edge table; otherwise, we increment the
+ * x value to be ready for the next scanline.
+ * The winding number rule is in effect, so we must notify
+ * the caller when the edge has been removed so he
+ * can reorder the Winding Active Edge Table.
+ */
+#define EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) { \
+ if (pAET->ymax == y) { /* leaving this edge */ \
+ pPrevAET->next = pAET->next; \
+ pAET = pPrevAET->next; \
+ fixWAET = 1; \
+ if (pAET) \
+ pAET->back = pPrevAET; \
+ } \
+ else { \
+ BRESINCRPGONSTRUCT(pAET->bres); \
+ pPrevAET = pAET; \
+ pAET = pAET->next; \
+ } \
+}
+
+
+/*
+ * Evaluate the given edge at the given scanline.
+ * If the edge has expired, then we leave it and fix up
+ * the active edge table; otherwise, we increment the
+ * x value to be ready for the next scanline.
+ * The even-odd rule is in effect.
+ */
+#define EVALUATEEDGEEVENODD(pAET, pPrevAET, y) { \
+ if (pAET->ymax == y) { /* leaving this edge */ \
+ pPrevAET->next = pAET->next; \
+ pAET = pPrevAET->next; \
+ if (pAET) \
+ pAET->back = pPrevAET; \
+ } \
+ else { \
+ BRESINCRPGONSTRUCT(pAET->bres); \
+ pPrevAET = pAET; \
+ pAET = pAET->next; \
+ } \
+}
+
+/* mipolyutil.c */
+
+extern Bool miInsertEdgeInET(
+ EdgeTable * /*ET*/,
+ EdgeTableEntry * /*ETE*/,
+ int /*scanline*/,
+ ScanLineListBlock ** /*SLLBlock*/,
+ int * /*iSLLBlock*/
+);
+
+extern Bool miCreateETandAET(
+ int /*count*/,
+ DDXPointPtr /*pts*/,
+ EdgeTable * /*ET*/,
+ EdgeTableEntry * /*AET*/,
+ EdgeTableEntry * /*pETEs*/,
+ ScanLineListBlock * /*pSLLBlock*/
+);
+
+extern void miloadAET(
+ EdgeTableEntry * /*AET*/,
+ EdgeTableEntry * /*ETEs*/
+);
+
+extern void micomputeWAET(
+ EdgeTableEntry * /*AET*/
+);
+
+extern int miInsertionSort(
+ EdgeTableEntry * /*AET*/
+);
+
+extern void miFreeStorage(
+ ScanLineListBlock * /*pSLLBlock*/
+);
diff --git a/nx-X11/programs/Xserver/mi/mipolycon.c b/nx-X11/programs/Xserver/mi/mipolycon.c
new file mode 100644
index 000000000..10c43a78e
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mipolycon.c
@@ -0,0 +1,248 @@
+/* $XFree86: xc/programs/Xserver/mi/mipolycon.c,v 1.3 2001/08/06 21:46:04 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mipolycon.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "gcstruct.h"
+#include "pixmap.h"
+#include "mi.h"
+#include "miscanfill.h"
+
+static int getPolyYBounds(DDXPointPtr pts, int n, int *by, int *ty);
+
+/*
+ * convexpoly.c
+ *
+ * Written by Brian Kelleher; Dec. 1985.
+ *
+ * Fill a convex polygon. If the given polygon
+ * is not convex, then the result is undefined.
+ * The algorithm is to order the edges from smallest
+ * y to largest by partitioning the array into a left
+ * edge list and a right edge list. The algorithm used
+ * to traverse each edge is an extension of Bresenham's
+ * line algorithm with y as the major axis.
+ * For a derivation of the algorithm, see the author of
+ * this code.
+ */
+Bool
+miFillConvexPoly(dst, pgc, count, ptsIn)
+ DrawablePtr dst;
+ GCPtr pgc;
+ int count; /* number of points */
+ DDXPointPtr ptsIn; /* the points */
+{
+ register int xl = 0, xr = 0; /* x vals of left and right edges */
+ register int dl = 0, dr = 0; /* decision variables */
+ register int ml = 0, m1l = 0;/* left edge slope and slope+1 */
+ int mr = 0, m1r = 0; /* right edge slope and slope+1 */
+ int incr1l = 0, incr2l = 0; /* left edge error increments */
+ int incr1r = 0, incr2r = 0; /* right edge error increments */
+ int dy; /* delta y */
+ int y; /* current scanline */
+ int left, right; /* indices to first endpoints */
+ int i; /* loop counter */
+ int nextleft, nextright; /* indices to second endpoints */
+ DDXPointPtr ptsOut, FirstPoint; /* output buffer */
+ int *width, *FirstWidth; /* output buffer */
+ int imin; /* index of smallest vertex (in y) */
+ int ymin; /* y-extents of polygon */
+ int ymax;
+
+ /*
+ * find leftx, bottomy, rightx, topy, and the index
+ * of bottomy. Also translate the points.
+ */
+ imin = getPolyYBounds(ptsIn, count, &ymin, &ymax);
+
+ dy = ymax - ymin + 1;
+ if ((count < 3) || (dy < 0))
+ return(TRUE);
+ ptsOut = FirstPoint = (DDXPointPtr )ALLOCATE_LOCAL(sizeof(DDXPointRec)*dy);
+ width = FirstWidth = (int *)ALLOCATE_LOCAL(sizeof(int) * dy);
+ if(!FirstPoint || !FirstWidth)
+ {
+ if (FirstWidth) DEALLOCATE_LOCAL(FirstWidth);
+ if (FirstPoint) DEALLOCATE_LOCAL(FirstPoint);
+ return(FALSE);
+ }
+
+ nextleft = nextright = imin;
+ y = ptsIn[nextleft].y;
+
+ /*
+ * loop through all edges of the polygon
+ */
+ do {
+ /*
+ * add a left edge if we need to
+ */
+ if (ptsIn[nextleft].y == y) {
+ left = nextleft;
+
+ /*
+ * find the next edge, considering the end
+ * conditions of the array.
+ */
+ nextleft++;
+ if (nextleft >= count)
+ nextleft = 0;
+
+ /*
+ * now compute all of the random information
+ * needed to run the iterative algorithm.
+ */
+ BRESINITPGON(ptsIn[nextleft].y-ptsIn[left].y,
+ ptsIn[left].x,ptsIn[nextleft].x,
+ xl, dl, ml, m1l, incr1l, incr2l);
+ }
+
+ /*
+ * add a right edge if we need to
+ */
+ if (ptsIn[nextright].y == y) {
+ right = nextright;
+
+ /*
+ * find the next edge, considering the end
+ * conditions of the array.
+ */
+ nextright--;
+ if (nextright < 0)
+ nextright = count-1;
+
+ /*
+ * now compute all of the random information
+ * needed to run the iterative algorithm.
+ */
+ BRESINITPGON(ptsIn[nextright].y-ptsIn[right].y,
+ ptsIn[right].x,ptsIn[nextright].x,
+ xr, dr, mr, m1r, incr1r, incr2r);
+ }
+
+ /*
+ * generate scans to fill while we still have
+ * a right edge as well as a left edge.
+ */
+ i = min(ptsIn[nextleft].y, ptsIn[nextright].y) - y;
+ /* in case we're called with non-convex polygon */
+ if(i < 0)
+ {
+ DEALLOCATE_LOCAL(FirstWidth);
+ DEALLOCATE_LOCAL(FirstPoint);
+ return(TRUE);
+ }
+ while (i-- > 0)
+ {
+ ptsOut->y = y;
+
+ /*
+ * reverse the edges if necessary
+ */
+ if (xl < xr)
+ {
+ *(width++) = xr - xl;
+ (ptsOut++)->x = xl;
+ }
+ else
+ {
+ *(width++) = xl - xr;
+ (ptsOut++)->x = xr;
+ }
+ y++;
+
+ /* increment down the edges */
+ BRESINCRPGON(dl, xl, ml, m1l, incr1l, incr2l);
+ BRESINCRPGON(dr, xr, mr, m1r, incr1r, incr2r);
+ }
+ } while (y != ymax);
+
+ /*
+ * Finally, fill the <remaining> spans
+ */
+ (*pgc->ops->FillSpans)(dst, pgc,
+ ptsOut-FirstPoint,FirstPoint,FirstWidth,
+ 1);
+ DEALLOCATE_LOCAL(FirstWidth);
+ DEALLOCATE_LOCAL(FirstPoint);
+ return(TRUE);
+}
+
+
+/*
+ * Find the index of the point with the smallest y.
+ */
+static int
+getPolyYBounds(DDXPointPtr pts, int n, int *by, int *ty)
+{
+ register DDXPointPtr ptMin;
+ int ymin, ymax;
+ DDXPointPtr ptsStart = pts;
+
+ ptMin = pts;
+ ymin = ymax = (pts++)->y;
+
+ while (--n > 0) {
+ if (pts->y < ymin)
+ {
+ ptMin = pts;
+ ymin = pts->y;
+ }
+ if(pts->y > ymax)
+ ymax = pts->y;
+
+ pts++;
+ }
+
+ *by = ymin;
+ *ty = ymax;
+ return(ptMin-ptsStart);
+}
diff --git a/nx-X11/programs/Xserver/mi/mipolygen.c b/nx-X11/programs/Xserver/mi/mipolygen.c
new file mode 100644
index 000000000..c3d9ef397
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mipolygen.c
@@ -0,0 +1,232 @@
+/* $XFree86: xc/programs/Xserver/mi/mipolygen.c,v 1.2 2001/05/29 22:24:07 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mipolygen.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "gcstruct.h"
+#include "miscanfill.h"
+#include "mipoly.h"
+#include "pixmap.h"
+#include "mi.h"
+
+/*
+ *
+ * Written by Brian Kelleher; Oct. 1985
+ *
+ * Routine to fill a polygon. Two fill rules are
+ * supported: frWINDING and frEVENODD.
+ *
+ * See fillpoly.h for a complete description of the algorithm.
+ */
+
+Bool
+miFillGeneralPoly(dst, pgc, count, ptsIn)
+ DrawablePtr dst;
+ GCPtr pgc;
+ int count; /* number of points */
+ DDXPointPtr ptsIn; /* the points */
+{
+ register EdgeTableEntry *pAET; /* the Active Edge Table */
+ register int y; /* the current scanline */
+ register int nPts = 0; /* number of pts in buffer */
+ register EdgeTableEntry *pWETE; /* Winding Edge Table */
+ register ScanLineList *pSLL; /* Current ScanLineList */
+ register DDXPointPtr ptsOut; /* ptr to output buffers */
+ int *width;
+ DDXPointRec FirstPoint[NUMPTSTOBUFFER]; /* the output buffers */
+ int FirstWidth[NUMPTSTOBUFFER];
+ EdgeTableEntry *pPrevAET; /* previous AET entry */
+ EdgeTable ET; /* Edge Table header node */
+ EdgeTableEntry AET; /* Active ET header node */
+ EdgeTableEntry *pETEs; /* Edge Table Entries buff */
+ ScanLineListBlock SLLBlock; /* header for ScanLineList */
+ int fixWAET = 0;
+
+ if (count < 3)
+ return(TRUE);
+
+ if(!(pETEs = (EdgeTableEntry *)
+ ALLOCATE_LOCAL(sizeof(EdgeTableEntry) * count)))
+ return(FALSE);
+ ptsOut = FirstPoint;
+ width = FirstWidth;
+ if (!miCreateETandAET(count, ptsIn, &ET, &AET, pETEs, &SLLBlock))
+ {
+ DEALLOCATE_LOCAL(pETEs);
+ return(FALSE);
+ }
+ pSLL = ET.scanlines.next;
+
+ if (pgc->fillRule == EvenOddRule)
+ {
+ /*
+ * for each scanline
+ */
+ for (y = ET.ymin; y < ET.ymax; y++)
+ {
+ /*
+ * Add a new edge to the active edge table when we
+ * get to the next edge.
+ */
+ if (pSLL && y == pSLL->scanline)
+ {
+ miloadAET(&AET, pSLL->edgelist);
+ pSLL = pSLL->next;
+ }
+ pPrevAET = &AET;
+ pAET = AET.next;
+
+ /*
+ * for each active edge
+ */
+ while (pAET)
+ {
+ ptsOut->x = pAET->bres.minor;
+ ptsOut++->y = y;
+ *width++ = pAET->next->bres.minor - pAET->bres.minor;
+ nPts++;
+
+ /*
+ * send out the buffer when its full
+ */
+ if (nPts == NUMPTSTOBUFFER)
+ {
+ (*pgc->ops->FillSpans)(dst, pgc,
+ nPts, FirstPoint, FirstWidth,
+ 1);
+ ptsOut = FirstPoint;
+ width = FirstWidth;
+ nPts = 0;
+ }
+ EVALUATEEDGEEVENODD(pAET, pPrevAET, y)
+ EVALUATEEDGEEVENODD(pAET, pPrevAET, y);
+ }
+ miInsertionSort(&AET);
+ }
+ }
+ else /* default to WindingNumber */
+ {
+ /*
+ * for each scanline
+ */
+ for (y = ET.ymin; y < ET.ymax; y++)
+ {
+ /*
+ * Add a new edge to the active edge table when we
+ * get to the next edge.
+ */
+ if (pSLL && y == pSLL->scanline)
+ {
+ miloadAET(&AET, pSLL->edgelist);
+ micomputeWAET(&AET);
+ pSLL = pSLL->next;
+ }
+ pPrevAET = &AET;
+ pAET = AET.next;
+ pWETE = pAET;
+
+ /*
+ * for each active edge
+ */
+ while (pAET)
+ {
+ /*
+ * if the next edge in the active edge table is
+ * also the next edge in the winding active edge
+ * table.
+ */
+ if (pWETE == pAET)
+ {
+ ptsOut->x = pAET->bres.minor;
+ ptsOut++->y = y;
+ *width++ = pAET->nextWETE->bres.minor - pAET->bres.minor;
+ nPts++;
+
+ /*
+ * send out the buffer
+ */
+ if (nPts == NUMPTSTOBUFFER)
+ {
+ (*pgc->ops->FillSpans)(dst, pgc, nPts, FirstPoint,
+ FirstWidth, 1);
+ ptsOut = FirstPoint;
+ width = FirstWidth;
+ nPts = 0;
+ }
+
+ pWETE = pWETE->nextWETE;
+ while (pWETE != pAET)
+ EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
+ pWETE = pWETE->nextWETE;
+ }
+ EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
+ }
+
+ /*
+ * reevaluate the Winding active edge table if we
+ * just had to resort it or if we just exited an edge.
+ */
+ if (miInsertionSort(&AET) || fixWAET)
+ {
+ micomputeWAET(&AET);
+ fixWAET = 0;
+ }
+ }
+ }
+
+ /*
+ * Get any spans that we missed by buffering
+ */
+ (*pgc->ops->FillSpans)(dst, pgc, nPts, FirstPoint, FirstWidth, 1);
+ DEALLOCATE_LOCAL(pETEs);
+ miFreeStorage(SLLBlock.next);
+ return(TRUE);
+}
diff --git a/nx-X11/programs/Xserver/mi/mipolypnt.c b/nx-X11/programs/Xserver/mi/mipolypnt.c
new file mode 100644
index 000000000..5d615c28d
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mipolypnt.c
@@ -0,0 +1,125 @@
+/* $XFree86: xc/programs/Xserver/mi/mipolypnt.c,v 1.2 2001/05/29 22:24:07 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mipolypnt.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "pixmapstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "mi.h"
+
+void
+miPolyPoint(pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt;
+ xPoint *pptInit;
+{
+
+ int xorg;
+ int yorg;
+ int nptTmp;
+ XID fsOld, fsNew;
+ int *pwidthInit, *pwidth;
+ int i;
+ register xPoint *ppt;
+
+ /* make pointlist origin relative */
+ if (mode == CoordModePrevious)
+ {
+ ppt = pptInit;
+ nptTmp = npt;
+ nptTmp--;
+ while(nptTmp--)
+ {
+ ppt++;
+ ppt->x += (ppt-1)->x;
+ ppt->y += (ppt-1)->y;
+ }
+ }
+
+ if(pGC->miTranslate)
+ {
+ ppt = pptInit;
+ nptTmp = npt;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ while(nptTmp--)
+ {
+ ppt->x += xorg;
+ ppt++->y += yorg;
+ }
+ }
+
+ fsOld = pGC->fillStyle;
+ fsNew = FillSolid;
+ if(pGC->fillStyle != FillSolid)
+ {
+ DoChangeGC(pGC, GCFillStyle, &fsNew, 0);
+ ValidateGC(pDrawable, pGC);
+ }
+ if(!(pwidthInit = (int *)ALLOCATE_LOCAL(npt * sizeof(int))))
+ return;
+ pwidth = pwidthInit;
+ for(i = 0; i < npt; i++)
+ *pwidth++ = 1;
+ (*pGC->ops->FillSpans)(pDrawable, pGC, npt, pptInit, pwidthInit, FALSE);
+
+ if(fsOld != FillSolid)
+ {
+ DoChangeGC(pGC, GCFillStyle, &fsOld, 0);
+ ValidateGC(pDrawable, pGC);
+ }
+ DEALLOCATE_LOCAL(pwidthInit);
+}
+
diff --git a/nx-X11/programs/Xserver/mi/mipolyrect.c b/nx-X11/programs/Xserver/mi/mipolyrect.c
new file mode 100644
index 000000000..6740ea8f6
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mipolyrect.c
@@ -0,0 +1,193 @@
+/* $XFree86: xc/programs/Xserver/mi/mipolyrect.c,v 1.3 2001/12/14 20:00:25 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mipolyrect.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "pixmap.h"
+#include "mi.h"
+
+void
+miPolyRectangle(pDraw, pGC, nrects, pRects)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int nrects;
+ xRectangle *pRects;
+{
+ int i;
+ xRectangle *pR = pRects;
+ DDXPointRec rect[5];
+ int bound_tmp;
+
+#define MINBOUND(dst,eqn) bound_tmp = eqn; \
+ if (bound_tmp < -32768) \
+ bound_tmp = -32768; \
+ dst = bound_tmp;
+
+#define MAXBOUND(dst,eqn) bound_tmp = eqn; \
+ if (bound_tmp > 32767) \
+ bound_tmp = 32767; \
+ dst = bound_tmp;
+
+#define MAXUBOUND(dst,eqn) bound_tmp = eqn; \
+ if (bound_tmp > 65535) \
+ bound_tmp = 65535; \
+ dst = bound_tmp;
+
+ if (pGC->lineStyle == LineSolid && pGC->joinStyle == JoinMiter &&
+ pGC->lineWidth != 0)
+ {
+ xRectangle *tmp, *t;
+ int ntmp;
+ int offset1, offset2, offset3;
+ int x, y, width, height;
+
+ ntmp = (nrects << 2);
+ offset2 = pGC->lineWidth;
+ offset1 = offset2 >> 1;
+ offset3 = offset2 - offset1;
+ tmp = (xRectangle *) ALLOCATE_LOCAL(ntmp * sizeof (xRectangle));
+ if (!tmp)
+ return;
+ t = tmp;
+ for (i = 0; i < nrects; i++)
+ {
+ x = pR->x;
+ y = pR->y;
+ width = pR->width;
+ height = pR->height;
+ pR++;
+ if (width == 0 && height == 0)
+ {
+ rect[0].x = x;
+ rect[0].y = y;
+ rect[1].x = x;
+ rect[1].y = y;
+ (*pGC->ops->Polylines)(pDraw, pGC, CoordModeOrigin, 2, rect);
+ }
+ else if (height < offset2 || width < offset1)
+ {
+ if (height == 0)
+ {
+ t->x = x;
+ t->width = width;
+ }
+ else
+ {
+ MINBOUND (t->x, x - offset1)
+ MAXUBOUND (t->width, width + offset2)
+ }
+ if (width == 0)
+ {
+ t->y = y;
+ t->height = height;
+ }
+ else
+ {
+ MINBOUND (t->y, y - offset1)
+ MAXUBOUND (t->height, height + offset2)
+ }
+ t++;
+ }
+ else
+ {
+ MINBOUND(t->x, x - offset1)
+ MINBOUND(t->y, y - offset1)
+ MAXUBOUND(t->width, width + offset2)
+ t->height = offset2;
+ t++;
+ MINBOUND(t->x, x - offset1)
+ MAXBOUND(t->y, y + offset3);
+ t->width = offset2;
+ t->height = height - offset2;
+ t++;
+ MAXBOUND(t->x, x + width - offset1);
+ MAXBOUND(t->y, y + offset3)
+ t->width = offset2;
+ t->height = height - offset2;
+ t++;
+ MINBOUND(t->x, x - offset1)
+ MAXBOUND(t->y, y + height - offset1)
+ MAXUBOUND(t->width, width + offset2)
+ t->height = offset2;
+ t++;
+ }
+ }
+ (*pGC->ops->PolyFillRect) (pDraw, pGC, t - tmp, tmp);
+ DEALLOCATE_LOCAL ((pointer) tmp);
+ }
+ else
+ {
+
+ for (i=0; i<nrects; i++)
+ {
+ rect[0].x = pR->x;
+ rect[0].y = pR->y;
+
+ MAXBOUND(rect[1].x, pR->x + (int) pR->width)
+ rect[1].y = rect[0].y;
+
+ rect[2].x = rect[1].x;
+ MAXBOUND(rect[2].y, pR->y + (int) pR->height);
+
+ rect[3].x = rect[0].x;
+ rect[3].y = rect[2].y;
+
+ rect[4].x = rect[0].x;
+ rect[4].y = rect[0].y;
+
+ (*pGC->ops->Polylines)(pDraw, pGC, CoordModeOrigin, 5, rect);
+ pR++;
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/mi/mipolyseg.c b/nx-X11/programs/Xserver/mi/mipolyseg.c
new file mode 100644
index 000000000..dcf3d815a
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mipolyseg.c
@@ -0,0 +1,85 @@
+/* $XFree86: xc/programs/Xserver/mi/mipolyseg.c,v 1.3 2001/12/14 20:00:26 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mipolyseg.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "pixmap.h"
+#include "mi.h"
+
+/*****************************************************************
+ * miPolySegment
+ *
+ * For each segment, draws a line between (x1, y1) and (x2, y2). The
+ * lines are drawn in the order listed.
+ *
+ * Walks the segments, compressing them into format for PolyLines.
+ *
+ *****************************************************************/
+
+
+void
+miPolySegment(pDraw, pGC, nseg, pSegs)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int nseg;
+ xSegment *pSegs;
+{
+ int i;
+
+ for (i=0; i<nseg; i++)
+ {
+ (*pGC->ops->Polylines)(pDraw, pGC, CoordModeOrigin, 2,(DDXPointPtr)pSegs);
+ pSegs++;
+ }
+}
diff --git a/nx-X11/programs/Xserver/mi/mipolytext.c b/nx-X11/programs/Xserver/mi/mipolytext.c
new file mode 100644
index 000000000..c2bbaba38
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mipolytext.c
@@ -0,0 +1,202 @@
+/* $XFree86: xc/programs/Xserver/mi/mipolytext.c,v 1.2 2001/08/06 20:51:19 dawes Exp $ */
+/*******************************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+************************************************************************/
+/* $Xorg: mipolytext.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+/*
+ * mipolytext.c - text routines
+ *
+ * Author: haynes
+ * Digital Equipment Corporation
+ * Western Software Laboratory
+ * Date: Thu Feb 5 1987
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "gcstruct.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "mi.h"
+
+int
+miPolyText(pDraw, pGC, x, y, count, chars, fontEncoding)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int x, y;
+ int count;
+ char *chars;
+ FontEncoding fontEncoding;
+{
+ unsigned long n, i;
+ int w;
+ CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */
+
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars,
+ fontEncoding, &n, charinfo);
+ w = 0;
+ for (i=0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
+ if (n != 0)
+ (*pGC->ops->PolyGlyphBlt)(
+ pDraw, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font));
+ return x+w;
+}
+
+
+int
+miPolyText8(pDraw, pGC, x, y, count, chars)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int x, y;
+ int count;
+ char *chars;
+{
+ unsigned long n, i;
+ int w;
+ CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */
+
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars,
+ Linear8Bit, &n, charinfo);
+ w = 0;
+ for (i=0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
+ if (n != 0)
+ (*pGC->ops->PolyGlyphBlt)(
+ pDraw, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font));
+ return x+w;
+}
+
+
+int
+miPolyText16(pDraw, pGC, x, y, count, chars)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int x, y;
+ int count;
+ unsigned short *chars;
+{
+ unsigned long n, i;
+ int w;
+ CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */
+
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars,
+ (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
+ &n, charinfo);
+ w = 0;
+ for (i=0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
+ if (n != 0)
+ (*pGC->ops->PolyGlyphBlt)(
+ pDraw, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font));
+ return x+w;
+}
+
+
+int
+miImageText(pDraw, pGC, x, y, count, chars, fontEncoding)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int x, y;
+ int count;
+ char *chars;
+ FontEncoding fontEncoding;
+{
+ unsigned long n, i;
+ FontPtr font = pGC->font;
+ int w;
+ CharInfoPtr charinfo[255];
+
+ GetGlyphs(font, (unsigned long)count, (unsigned char *)chars,
+ fontEncoding, &n, charinfo);
+ w = 0;
+ for (i=0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
+ if (n !=0 )
+ (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, n, charinfo, FONTGLYPHS(font));
+ return x+w;
+}
+
+
+void
+miImageText8(pDraw, pGC, x, y, count, chars)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int x, y;
+ int count;
+ char *chars;
+{
+ unsigned long n;
+ FontPtr font = pGC->font;
+ CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */
+
+ GetGlyphs(font, (unsigned long)count, (unsigned char *)chars,
+ Linear8Bit, &n, charinfo);
+ if (n !=0 )
+ (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, n, charinfo, FONTGLYPHS(font));
+}
+
+
+void
+miImageText16(pDraw, pGC, x, y, count, chars)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int x, y;
+ int count;
+ unsigned short *chars;
+{
+ unsigned long n;
+ FontPtr font = pGC->font;
+ CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */
+
+ GetGlyphs(font, (unsigned long)count, (unsigned char *)chars,
+ (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
+ &n, charinfo);
+ if (n !=0 )
+ (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, n, charinfo, FONTGLYPHS(font));
+}
diff --git a/nx-X11/programs/Xserver/mi/mipolyutil.c b/nx-X11/programs/Xserver/mi/mipolyutil.c
new file mode 100644
index 000000000..be62250ee
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mipolyutil.c
@@ -0,0 +1,401 @@
+/* $XFree86: xc/programs/Xserver/mi/mipolyutil.c,v 1.9 2001/12/14 20:00:26 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mipolyutil.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "regionstr.h"
+#include "gc.h"
+#include "miscanfill.h"
+#include "mipoly.h"
+#include "misc.h" /* MAXINT */
+
+/*
+ * fillUtils.c
+ *
+ * Written by Brian Kelleher; Oct. 1985
+ *
+ * This module contains all of the utility functions
+ * needed to scan convert a polygon.
+ *
+ */
+
+/*
+ * InsertEdgeInET
+ *
+ * Insert the given edge into the edge table.
+ * First we must find the correct bucket in the
+ * Edge table, then find the right slot in the
+ * bucket. Finally, we can insert it.
+ *
+ */
+Bool
+miInsertEdgeInET(ET, ETE, scanline, SLLBlock, iSLLBlock)
+ EdgeTable *ET;
+ EdgeTableEntry *ETE;
+ int scanline;
+ ScanLineListBlock **SLLBlock;
+ int *iSLLBlock;
+{
+ register EdgeTableEntry *start, *prev;
+ register ScanLineList *pSLL, *pPrevSLL;
+ ScanLineListBlock *tmpSLLBlock;
+
+ /*
+ * find the right bucket to put the edge into
+ */
+ pPrevSLL = &ET->scanlines;
+ pSLL = pPrevSLL->next;
+ while (pSLL && (pSLL->scanline < scanline))
+ {
+ pPrevSLL = pSLL;
+ pSLL = pSLL->next;
+ }
+
+ /*
+ * reassign pSLL (pointer to ScanLineList) if necessary
+ */
+ if ((!pSLL) || (pSLL->scanline > scanline))
+ {
+ if (*iSLLBlock > SLLSPERBLOCK-1)
+ {
+ tmpSLLBlock =
+ (ScanLineListBlock *)xalloc(sizeof(ScanLineListBlock));
+ if (!tmpSLLBlock)
+ return FALSE;
+ (*SLLBlock)->next = tmpSLLBlock;
+ tmpSLLBlock->next = (ScanLineListBlock *)NULL;
+ *SLLBlock = tmpSLLBlock;
+ *iSLLBlock = 0;
+ }
+ pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]);
+
+ pSLL->next = pPrevSLL->next;
+ pSLL->edgelist = (EdgeTableEntry *)NULL;
+ pPrevSLL->next = pSLL;
+ }
+ pSLL->scanline = scanline;
+
+ /*
+ * now insert the edge in the right bucket
+ */
+ prev = (EdgeTableEntry *)NULL;
+ start = pSLL->edgelist;
+ while (start && (start->bres.minor < ETE->bres.minor))
+ {
+ prev = start;
+ start = start->next;
+ }
+ ETE->next = start;
+
+ if (prev)
+ prev->next = ETE;
+ else
+ pSLL->edgelist = ETE;
+ return TRUE;
+}
+
+/*
+ * CreateEdgeTable
+ *
+ * This routine creates the edge table for
+ * scan converting polygons.
+ * The Edge Table (ET) looks like:
+ *
+ * EdgeTable
+ * --------
+ * | ymax | ScanLineLists
+ * |scanline|-->------------>-------------->...
+ * -------- |scanline| |scanline|
+ * |edgelist| |edgelist|
+ * --------- ---------
+ * | |
+ * | |
+ * V V
+ * list of ETEs list of ETEs
+ *
+ * where ETE is an EdgeTableEntry data structure,
+ * and there is one ScanLineList per scanline at
+ * which an edge is initially entered.
+ *
+ */
+
+Bool
+miCreateETandAET(count, pts, ET, AET, pETEs, pSLLBlock)
+ register int count;
+ register DDXPointPtr pts;
+ EdgeTable *ET;
+ EdgeTableEntry *AET;
+ register EdgeTableEntry *pETEs;
+ ScanLineListBlock *pSLLBlock;
+{
+ register DDXPointPtr top, bottom;
+ register DDXPointPtr PrevPt, CurrPt;
+ int iSLLBlock = 0;
+
+ int dy;
+
+ if (count < 2) return TRUE;
+
+ /*
+ * initialize the Active Edge Table
+ */
+ AET->next = (EdgeTableEntry *)NULL;
+ AET->back = (EdgeTableEntry *)NULL;
+ AET->nextWETE = (EdgeTableEntry *)NULL;
+ AET->bres.minor = MININT;
+
+ /*
+ * initialize the Edge Table.
+ */
+ ET->scanlines.next = (ScanLineList *)NULL;
+ ET->ymax = MININT;
+ ET->ymin = MAXINT;
+ pSLLBlock->next = (ScanLineListBlock *)NULL;
+
+ PrevPt = &pts[count-1];
+
+ /*
+ * for each vertex in the array of points.
+ * In this loop we are dealing with two vertices at
+ * a time -- these make up one edge of the polygon.
+ */
+ while (count--)
+ {
+ CurrPt = pts++;
+
+ /*
+ * find out which point is above and which is below.
+ */
+ if (PrevPt->y > CurrPt->y)
+ {
+ bottom = PrevPt, top = CurrPt;
+ pETEs->ClockWise = 0;
+ }
+ else
+ {
+ bottom = CurrPt, top = PrevPt;
+ pETEs->ClockWise = 1;
+ }
+
+ /*
+ * don't add horizontal edges to the Edge table.
+ */
+ if (bottom->y != top->y)
+ {
+ pETEs->ymax = bottom->y-1; /* -1 so we don't get last scanline */
+
+ /*
+ * initialize integer edge algorithm
+ */
+ dy = bottom->y - top->y;
+ BRESINITPGONSTRUCT(dy, top->x, bottom->x, pETEs->bres);
+
+ if (!miInsertEdgeInET(ET, pETEs, top->y, &pSLLBlock, &iSLLBlock))
+ {
+ miFreeStorage(pSLLBlock->next);
+ return FALSE;
+ }
+
+ ET->ymax = max(ET->ymax, PrevPt->y);
+ ET->ymin = min(ET->ymin, PrevPt->y);
+ pETEs++;
+ }
+
+ PrevPt = CurrPt;
+ }
+ return TRUE;
+}
+
+/*
+ * loadAET
+ *
+ * This routine moves EdgeTableEntries from the
+ * EdgeTable into the Active Edge Table,
+ * leaving them sorted by smaller x coordinate.
+ *
+ */
+
+void
+miloadAET(AET, ETEs)
+ register EdgeTableEntry *AET, *ETEs;
+{
+ register EdgeTableEntry *pPrevAET;
+ register EdgeTableEntry *tmp;
+
+ pPrevAET = AET;
+ AET = AET->next;
+ while (ETEs)
+ {
+ while (AET && (AET->bres.minor < ETEs->bres.minor))
+ {
+ pPrevAET = AET;
+ AET = AET->next;
+ }
+ tmp = ETEs->next;
+ ETEs->next = AET;
+ if (AET)
+ AET->back = ETEs;
+ ETEs->back = pPrevAET;
+ pPrevAET->next = ETEs;
+ pPrevAET = ETEs;
+
+ ETEs = tmp;
+ }
+}
+
+/*
+ * computeWAET
+ *
+ * This routine links the AET by the
+ * nextWETE (winding EdgeTableEntry) link for
+ * use by the winding number rule. The final
+ * Active Edge Table (AET) might look something
+ * like:
+ *
+ * AET
+ * ---------- --------- ---------
+ * |ymax | |ymax | |ymax |
+ * | ... | |... | |... |
+ * |next |->|next |->|next |->...
+ * |nextWETE| |nextWETE| |nextWETE|
+ * --------- --------- ^--------
+ * | | |
+ * V-------------------> V---> ...
+ *
+ */
+void
+micomputeWAET(AET)
+ register EdgeTableEntry *AET;
+{
+ register EdgeTableEntry *pWETE;
+ register int inside = 1;
+ register int isInside = 0;
+
+ AET->nextWETE = (EdgeTableEntry *)NULL;
+ pWETE = AET;
+ AET = AET->next;
+ while (AET)
+ {
+ if (AET->ClockWise)
+ isInside++;
+ else
+ isInside--;
+
+ if ((!inside && !isInside) ||
+ ( inside && isInside))
+ {
+ pWETE->nextWETE = AET;
+ pWETE = AET;
+ inside = !inside;
+ }
+ AET = AET->next;
+ }
+ pWETE->nextWETE = (EdgeTableEntry *)NULL;
+}
+
+/*
+ * InsertionSort
+ *
+ * Just a simple insertion sort using
+ * pointers and back pointers to sort the Active
+ * Edge Table.
+ *
+ */
+
+int
+miInsertionSort(AET)
+ register EdgeTableEntry *AET;
+{
+ register EdgeTableEntry *pETEchase;
+ register EdgeTableEntry *pETEinsert;
+ register EdgeTableEntry *pETEchaseBackTMP;
+ register int changed = 0;
+
+ AET = AET->next;
+ while (AET)
+ {
+ pETEinsert = AET;
+ pETEchase = AET;
+ while (pETEchase->back->bres.minor > AET->bres.minor)
+ pETEchase = pETEchase->back;
+
+ AET = AET->next;
+ if (pETEchase != pETEinsert)
+ {
+ pETEchaseBackTMP = pETEchase->back;
+ pETEinsert->back->next = AET;
+ if (AET)
+ AET->back = pETEinsert->back;
+ pETEinsert->next = pETEchase;
+ pETEchase->back->next = pETEinsert;
+ pETEchase->back = pETEinsert;
+ pETEinsert->back = pETEchaseBackTMP;
+ changed = 1;
+ }
+ }
+ return(changed);
+}
+
+/*
+ * Clean up our act.
+ */
+void
+miFreeStorage(pSLLBlock)
+ register ScanLineListBlock *pSLLBlock;
+{
+ register ScanLineListBlock *tmpSLLBlock;
+
+ while (pSLLBlock)
+ {
+ tmpSLLBlock = pSLLBlock->next;
+ xfree(pSLLBlock);
+ pSLLBlock = tmpSLLBlock;
+ }
+}
diff --git a/nx-X11/programs/Xserver/mi/mipushpxl.c b/nx-X11/programs/Xserver/mi/mipushpxl.c
new file mode 100644
index 000000000..5fce1cae7
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mipushpxl.c
@@ -0,0 +1,261 @@
+/* $XFree86: xc/programs/Xserver/mi/mipushpxl.c,v 3.12 2001/12/14 20:00:26 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mipushpxl.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "../mfb/maskbits.h"
+#include "mi.h"
+
+#define NPT 128
+
+/* miPushPixels -- squeegees the fill style of pGC through pBitMap
+ * into pDrawable. pBitMap is a stencil (dx by dy of it is used, it may
+ * be bigger) which is placed on the drawable at xOrg, yOrg. Where a 1 bit
+ * is set in the bitmap, the fill style is put onto the drawable using
+ * the GC's logical function. The drawable is not changed where the bitmap
+ * has a zero bit or outside the area covered by the stencil.
+
+WARNING:
+ this code works if the 1-bit deep pixmap format returned by GetSpans
+is the same as the format defined by the mfb code (i.e. 32-bit padding
+per scanline, scanline unit = 32 bits; later, this might mean
+bitsizeof(int) padding and sacnline unit == bitsizeof(int).)
+
+ */
+
+/*
+ * in order to have both (MSB_FIRST and LSB_FIRST) versions of this
+ * in the server, we need to rename one of them
+ */
+void
+miPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
+ GCPtr pGC;
+ PixmapPtr pBitMap;
+ DrawablePtr pDrawable;
+ int dx, dy, xOrg, yOrg;
+{
+ int h, dxDivPPW, ibEnd;
+ MiBits *pwLineStart;
+ register MiBits *pw, *pwEnd;
+ register MiBits msk;
+ register int ib, w;
+ register int ipt; /* index into above arrays */
+ Bool fInBox;
+ DDXPointRec pt[NPT], ptThisLine;
+ int width[NPT];
+#ifdef XFree86Server
+ PixelType startmask;
+ if (screenInfo.bitmapBitOrder == IMAGE_BYTE_ORDER)
+ if (screenInfo.bitmapBitOrder == LSBFirst)
+ startmask = (MiBits)(-1) ^
+ LONG2CHARSSAMEORDER((MiBits)(-1) << 1);
+ else
+ startmask = (MiBits)(-1) ^
+ LONG2CHARSSAMEORDER((MiBits)(-1) >> 1);
+ else
+ if (screenInfo.bitmapBitOrder == LSBFirst)
+ startmask = (MiBits)(-1) ^
+ LONG2CHARSDIFFORDER((MiBits)(-1) << 1);
+ else
+ startmask = (MiBits)(-1) ^
+ LONG2CHARSDIFFORDER((MiBits)(-1) >> 1);
+#endif
+
+ pwLineStart = (MiBits *)xalloc(BitmapBytePad(dx));
+ if (!pwLineStart)
+ return;
+ ipt = 0;
+ dxDivPPW = dx/PPW;
+
+ for(h = 0, ptThisLine.x = 0, ptThisLine.y = 0;
+ h < dy;
+ h++, ptThisLine.y++)
+ {
+
+ (*pBitMap->drawable.pScreen->GetSpans)((DrawablePtr)pBitMap, dx,
+ &ptThisLine, &dx, 1, (char *)pwLineStart);
+
+ pw = pwLineStart;
+ /* Process all words which are fully in the pixmap */
+
+ fInBox = FALSE;
+ pwEnd = pwLineStart + dxDivPPW;
+ while(pw < pwEnd)
+ {
+ w = *pw;
+#ifdef XFree86Server
+ msk = startmask;
+#else
+ msk = (MiBits)(-1) ^ SCRRIGHT((MiBits)(-1), 1);
+#endif
+ for(ib = 0; ib < PPW; ib++)
+ {
+ if(w & msk)
+ {
+ if(!fInBox)
+ {
+ pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
+ pt[ipt].y = h + yOrg;
+ /* start new box */
+ fInBox = TRUE;
+ }
+ }
+ else
+ {
+ if(fInBox)
+ {
+ width[ipt] = ((pw - pwLineStart) << PWSH) +
+ ib + xOrg - pt[ipt].x;
+ if (++ipt >= NPT)
+ {
+ (*pGC->ops->FillSpans)(pDrawable, pGC,
+ NPT, pt, width, TRUE);
+ ipt = 0;
+ }
+ /* end box */
+ fInBox = FALSE;
+ }
+ }
+#ifdef XFree86Server
+ /* This is not quite right, but it'll do for now */
+ if (screenInfo.bitmapBitOrder == IMAGE_BYTE_ORDER)
+ if (screenInfo.bitmapBitOrder == LSBFirst)
+ msk = LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk) << 1);
+ else
+ msk = LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk) >> 1);
+ else
+ if (screenInfo.bitmapBitOrder == LSBFirst)
+ msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) << 1);
+ else
+ msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) >> 1);
+#else
+ msk = SCRRIGHT(msk, 1);
+#endif
+ }
+ pw++;
+ }
+ ibEnd = dx & PIM;
+ if(ibEnd)
+ {
+ /* Process final partial word on line */
+ w = *pw;
+#ifdef XFree86Server
+ msk = startmask;
+#else
+ msk = (MiBits)(-1) ^ SCRRIGHT((MiBits)(-1), 1);
+#endif
+ for(ib = 0; ib < ibEnd; ib++)
+ {
+ if(w & msk)
+ {
+ if(!fInBox)
+ {
+ /* start new box */
+ pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
+ pt[ipt].y = h + yOrg;
+ fInBox = TRUE;
+ }
+ }
+ else
+ {
+ if(fInBox)
+ {
+ /* end box */
+ width[ipt] = ((pw - pwLineStart) << PWSH) +
+ ib + xOrg - pt[ipt].x;
+ if (++ipt >= NPT)
+ {
+ (*pGC->ops->FillSpans)(pDrawable,
+ pGC, NPT, pt, width, TRUE);
+ ipt = 0;
+ }
+ fInBox = FALSE;
+ }
+ }
+#ifdef XFree86Server
+ /* This is not quite right, but it'll do for now */
+ if (screenInfo.bitmapBitOrder == IMAGE_BYTE_ORDER)
+ if (screenInfo.bitmapBitOrder == LSBFirst)
+ msk = LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk) << 1);
+ else
+ msk = LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk) >> 1);
+ else
+ if (screenInfo.bitmapBitOrder == LSBFirst)
+ msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) << 1);
+ else
+ msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) >> 1);
+#else
+ msk = SCRRIGHT(msk, 1);
+#endif
+ }
+ }
+ /* If scanline ended with last bit set, end the box */
+ if(fInBox)
+ {
+ width[ipt] = dx + xOrg - pt[ipt].x;
+ if (++ipt >= NPT)
+ {
+ (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt, width, TRUE);
+ ipt = 0;
+ }
+ }
+ }
+ xfree(pwLineStart);
+ /* Flush any remaining spans */
+ if (ipt)
+ {
+ (*pGC->ops->FillSpans)(pDrawable, pGC, ipt, pt, width, TRUE);
+ }
+}
diff --git a/nx-X11/programs/Xserver/mi/miregion.c b/nx-X11/programs/Xserver/mi/miregion.c
new file mode 100644
index 000000000..df3324865
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/miregion.c
@@ -0,0 +1,2563 @@
+/* $XFree86: xc/programs/Xserver/mi/miregion.c,v 1.9 2003/04/23 21:51:53 tsi Exp $ */
+/***********************************************************
+
+Copyright 1987, 1988, 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987, 1988, 1989 by
+Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: miregion.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+
+/* The panoramix components contained the following notice */
+/*****************************************************************
+
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "regionstr.h"
+#include <X11/Xprotostr.h>
+#include "gc.h"
+#include "mi.h"
+#include "mispans.h"
+
+#if defined (__GNUC__) && !defined (NO_INLINES)
+#define INLINE __inline
+#else
+#define INLINE
+#endif
+
+#undef assert
+#ifdef DEBUG
+#define assert(expr) {if (!(expr)) \
+ FatalError("Assertion failed file %s, line %d: expr\n", \
+ __FILE__, __LINE__); }
+#else
+#define assert(expr)
+#endif
+
+#define good(reg) assert(miValidRegion(reg))
+
+/*
+ * The functions in this file implement the Region abstraction used extensively
+ * throughout the X11 sample server. A Region is simply a set of disjoint
+ * (non-overlapping) rectangles, plus an "extent" rectangle which is the
+ * smallest single rectangle that contains all the non-overlapping rectangles.
+ *
+ * A Region is implemented as a "y-x-banded" array of rectangles. This array
+ * imposes two degrees of order. First, all rectangles are sorted by top side
+ * y coordinate first (y1), and then by left side x coordinate (x1).
+ *
+ * Furthermore, the rectangles are grouped into "bands". Each rectangle in a
+ * band has the same top y coordinate (y1), and each has the same bottom y
+ * coordinate (y2). Thus all rectangles in a band differ only in their left
+ * and right side (x1 and x2). Bands are implicit in the array of rectangles:
+ * there is no separate list of band start pointers.
+ *
+ * The y-x band representation does not minimize rectangles. In particular,
+ * if a rectangle vertically crosses a band (the rectangle has scanlines in
+ * the y1 to y2 area spanned by the band), then the rectangle may be broken
+ * down into two or more smaller rectangles stacked one atop the other.
+ *
+ * ----------- -----------
+ * | | | | band 0
+ * | | -------- ----------- --------
+ * | | | | in y-x banded | | | | band 1
+ * | | | | form is | | | |
+ * ----------- | | ----------- --------
+ * | | | | band 2
+ * -------- --------
+ *
+ * An added constraint on the rectangles is that they must cover as much
+ * horizontal area as possible: no two rectangles within a band are allowed
+ * to touch.
+ *
+ * Whenever possible, bands will be merged together to cover a greater vertical
+ * distance (and thus reduce the number of rectangles). Two bands can be merged
+ * only if the bottom of one touches the top of the other and they have
+ * rectangles in the same places (of the same width, of course).
+ *
+ * Adam de Boor wrote most of the original region code. Joel McCormack
+ * substantially modified or rewrote most of the core arithmetic routines,
+ * and added miRegionValidate in order to support several speed improvements
+ * to miValidateTree. Bob Scheifler changed the representation to be more
+ * compact when empty or a single rectangle, and did a bunch of gratuitous
+ * reformatting.
+ */
+
+/* true iff two Boxes overlap */
+#define EXTENTCHECK(r1,r2) \
+ (!( ((r1)->x2 <= (r2)->x1) || \
+ ((r1)->x1 >= (r2)->x2) || \
+ ((r1)->y2 <= (r2)->y1) || \
+ ((r1)->y1 >= (r2)->y2) ) )
+
+/* true iff (x,y) is in Box */
+#define INBOX(r,x,y) \
+ ( ((r)->x2 > x) && \
+ ((r)->x1 <= x) && \
+ ((r)->y2 > y) && \
+ ((r)->y1 <= y) )
+
+/* true iff Box r1 contains Box r2 */
+#define SUBSUMES(r1,r2) \
+ ( ((r1)->x1 <= (r2)->x1) && \
+ ((r1)->x2 >= (r2)->x2) && \
+ ((r1)->y1 <= (r2)->y1) && \
+ ((r1)->y2 >= (r2)->y2) )
+
+#define xallocData(n) (RegDataPtr)xalloc(REGION_SZOF(n))
+#define xfreeData(reg) if ((reg)->data && (reg)->data->size) xfree((reg)->data)
+
+#define RECTALLOC_BAIL(pReg,n,bail) \
+if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \
+ if (!miRectAlloc(pReg, n)) { goto bail; }
+
+#define RECTALLOC(pReg,n) \
+if (!(pReg)->data || (((pReg)->data->numRects + (n)) > (pReg)->data->size)) \
+ if (!miRectAlloc(pReg, n)) { return FALSE; }
+
+#define ADDRECT(pNextRect,nx1,ny1,nx2,ny2) \
+{ \
+ pNextRect->x1 = nx1; \
+ pNextRect->y1 = ny1; \
+ pNextRect->x2 = nx2; \
+ pNextRect->y2 = ny2; \
+ pNextRect++; \
+}
+
+#define NEWRECT(pReg,pNextRect,nx1,ny1,nx2,ny2) \
+{ \
+ if (!(pReg)->data || ((pReg)->data->numRects == (pReg)->data->size))\
+ { \
+ if (!miRectAlloc(pReg, 1)) \
+ return FALSE; \
+ pNextRect = REGION_TOP(pReg); \
+ } \
+ ADDRECT(pNextRect,nx1,ny1,nx2,ny2); \
+ pReg->data->numRects++; \
+ assert(pReg->data->numRects<=pReg->data->size); \
+}
+
+
+#define DOWNSIZE(reg,numRects) \
+if (((numRects) < ((reg)->data->size >> 1)) && ((reg)->data->size > 50)) \
+{ \
+ RegDataPtr NewData; \
+ NewData = (RegDataPtr)xrealloc((reg)->data, REGION_SZOF(numRects)); \
+ if (NewData) \
+ { \
+ NewData->size = (numRects); \
+ (reg)->data = NewData; \
+ } \
+}
+
+
+BoxRec miEmptyBox = {0, 0, 0, 0};
+RegDataRec miEmptyData = {0, 0};
+
+RegDataRec miBrokenData = {0, 0};
+RegionRec miBrokenRegion = { { 0, 0, 0, 0 }, &miBrokenData };
+
+#ifdef DEBUG
+int
+miPrintRegion(rgn)
+ RegionPtr rgn;
+{
+ int num, size;
+ register int i;
+ BoxPtr rects;
+
+ num = REGION_NUM_RECTS(rgn);
+ size = REGION_SIZE(rgn);
+ rects = REGION_RECTS(rgn);
+ ErrorF("num: %d size: %d\n", num, size);
+ ErrorF("extents: %d %d %d %d\n",
+ rgn->extents.x1, rgn->extents.y1, rgn->extents.x2, rgn->extents.y2);
+ for (i = 0; i < num; i++)
+ ErrorF("%d %d %d %d \n",
+ rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2);
+ ErrorF("\n");
+ return(num);
+}
+#endif /* DEBUG */
+
+Bool
+miRegionEqual(reg1, reg2)
+ RegionPtr reg1;
+ RegionPtr reg2;
+{
+ int i, num;
+ BoxPtr rects1, rects2;
+
+ if (reg1->extents.x1 != reg2->extents.x1) return FALSE;
+ if (reg1->extents.x2 != reg2->extents.x2) return FALSE;
+ if (reg1->extents.y1 != reg2->extents.y1) return FALSE;
+ if (reg1->extents.y2 != reg2->extents.y2) return FALSE;
+
+ num = REGION_NUM_RECTS(reg1);
+ if (num != REGION_NUM_RECTS(reg2)) return FALSE;
+
+ rects1 = REGION_RECTS(reg1);
+ rects2 = REGION_RECTS(reg2);
+ for (i = 0; i != num; i++) {
+ if (rects1[i].x1 != rects2[i].x1) return FALSE;
+ if (rects1[i].x2 != rects2[i].x2) return FALSE;
+ if (rects1[i].y1 != rects2[i].y1) return FALSE;
+ if (rects1[i].y2 != rects2[i].y2) return FALSE;
+ }
+ return TRUE;
+}
+
+#ifdef DEBUG
+Bool
+miValidRegion(reg)
+ RegionPtr reg;
+{
+ register int i, numRects;
+
+ if ((reg->extents.x1 > reg->extents.x2) ||
+ (reg->extents.y1 > reg->extents.y2))
+ return FALSE;
+ numRects = REGION_NUM_RECTS(reg);
+ if (!numRects)
+ return ((reg->extents.x1 == reg->extents.x2) &&
+ (reg->extents.y1 == reg->extents.y2) &&
+ (reg->data->size || (reg->data == &miEmptyData)));
+ else if (numRects == 1)
+ return (!reg->data);
+ else
+ {
+ register BoxPtr pboxP, pboxN;
+ BoxRec box;
+
+ pboxP = REGION_RECTS(reg);
+ box = *pboxP;
+ box.y2 = pboxP[numRects-1].y2;
+ pboxN = pboxP + 1;
+ for (i = numRects; --i > 0; pboxP++, pboxN++)
+ {
+ if ((pboxN->x1 >= pboxN->x2) ||
+ (pboxN->y1 >= pboxN->y2))
+ return FALSE;
+ if (pboxN->x1 < box.x1)
+ box.x1 = pboxN->x1;
+ if (pboxN->x2 > box.x2)
+ box.x2 = pboxN->x2;
+ if ((pboxN->y1 < pboxP->y1) ||
+ ((pboxN->y1 == pboxP->y1) &&
+ ((pboxN->x1 < pboxP->x2) || (pboxN->y2 != pboxP->y2))))
+ return FALSE;
+ }
+ return ((box.x1 == reg->extents.x1) &&
+ (box.x2 == reg->extents.x2) &&
+ (box.y1 == reg->extents.y1) &&
+ (box.y2 == reg->extents.y2));
+ }
+}
+
+#endif /* DEBUG */
+
+
+/*****************************************************************
+ * RegionCreate(rect, size)
+ * This routine does a simple malloc to make a structure of
+ * REGION of "size" number of rectangles.
+ *****************************************************************/
+
+RegionPtr
+miRegionCreate(rect, size)
+ BoxPtr rect;
+ int size;
+{
+ register RegionPtr pReg;
+
+ pReg = (RegionPtr)xalloc(sizeof(RegionRec));
+ if (!pReg)
+ return &miBrokenRegion;
+ if (rect)
+ {
+ pReg->extents = *rect;
+ pReg->data = (RegDataPtr)NULL;
+ }
+ else
+ {
+ pReg->extents = miEmptyBox;
+ if ((size > 1) && (pReg->data = xallocData(size)))
+ {
+ pReg->data->size = size;
+ pReg->data->numRects = 0;
+ }
+ else
+ pReg->data = &miEmptyData;
+ }
+ return(pReg);
+}
+
+/*****************************************************************
+ * RegionInit(pReg, rect, size)
+ * Outer region rect is statically allocated.
+ *****************************************************************/
+
+void
+miRegionInit(pReg, rect, size)
+ RegionPtr pReg;
+ BoxPtr rect;
+ int size;
+{
+ if (rect)
+ {
+ pReg->extents = *rect;
+ pReg->data = (RegDataPtr)NULL;
+ }
+ else
+ {
+ pReg->extents = miEmptyBox;
+ if ((size > 1) && (pReg->data = xallocData(size)))
+ {
+ pReg->data->size = size;
+ pReg->data->numRects = 0;
+ }
+ else
+ pReg->data = &miEmptyData;
+ }
+}
+
+void
+miRegionDestroy(pReg)
+ RegionPtr pReg;
+{
+ good(pReg);
+ xfreeData(pReg);
+ if (pReg != &miBrokenRegion)
+ xfree(pReg);
+}
+
+void
+miRegionUninit(pReg)
+ RegionPtr pReg;
+{
+ good(pReg);
+ xfreeData(pReg);
+}
+
+Bool
+miRegionBreak (pReg)
+ RegionPtr pReg;
+{
+ xfreeData (pReg);
+ pReg->extents = miEmptyBox;
+ pReg->data = &miBrokenData;
+ return FALSE;
+}
+
+Bool
+miRectAlloc(
+ register RegionPtr pRgn,
+ int n)
+{
+ RegDataPtr data;
+
+ if (!pRgn->data)
+ {
+ n++;
+ pRgn->data = xallocData(n);
+ if (!pRgn->data)
+ return miRegionBreak (pRgn);
+ pRgn->data->numRects = 1;
+ *REGION_BOXPTR(pRgn) = pRgn->extents;
+ }
+ else if (!pRgn->data->size)
+ {
+ pRgn->data = xallocData(n);
+ if (!pRgn->data)
+ return miRegionBreak (pRgn);
+ pRgn->data->numRects = 0;
+ }
+ else
+ {
+ if (n == 1)
+ {
+ n = pRgn->data->numRects;
+ if (n > 500) /* XXX pick numbers out of a hat */
+ n = 250;
+ }
+ n += pRgn->data->numRects;
+ data = (RegDataPtr)xrealloc(pRgn->data, REGION_SZOF(n));
+ if (!data)
+ return miRegionBreak (pRgn);
+ pRgn->data = data;
+ }
+ pRgn->data->size = n;
+ return TRUE;
+}
+
+Bool
+miRegionCopy(dst, src)
+ register RegionPtr dst;
+ register RegionPtr src;
+{
+ good(dst);
+ good(src);
+ if (dst == src)
+ return TRUE;
+ dst->extents = src->extents;
+ if (!src->data || !src->data->size)
+ {
+ xfreeData(dst);
+ dst->data = src->data;
+ return TRUE;
+ }
+ if (!dst->data || (dst->data->size < src->data->numRects))
+ {
+ xfreeData(dst);
+ dst->data = xallocData(src->data->numRects);
+ if (!dst->data)
+ return miRegionBreak (dst);
+ dst->data->size = src->data->numRects;
+ }
+ dst->data->numRects = src->data->numRects;
+ memmove((char *)REGION_BOXPTR(dst),(char *)REGION_BOXPTR(src),
+ dst->data->numRects * sizeof(BoxRec));
+ return TRUE;
+}
+
+
+/*======================================================================
+ * Generic Region Operator
+ *====================================================================*/
+
+/*-
+ *-----------------------------------------------------------------------
+ * miCoalesce --
+ * Attempt to merge the boxes in the current band with those in the
+ * previous one. We are guaranteed that the current band extends to
+ * the end of the rects array. Used only by miRegionOp.
+ *
+ * Results:
+ * The new index for the previous band.
+ *
+ * Side Effects:
+ * If coalescing takes place:
+ * - rectangles in the previous band will have their y2 fields
+ * altered.
+ * - pReg->data->numRects will be decreased.
+ *
+ *-----------------------------------------------------------------------
+ */
+INLINE static int
+miCoalesce (
+ register RegionPtr pReg, /* Region to coalesce */
+ int prevStart, /* Index of start of previous band */
+ int curStart) /* Index of start of current band */
+{
+ register BoxPtr pPrevBox; /* Current box in previous band */
+ register BoxPtr pCurBox; /* Current box in current band */
+ register int numRects; /* Number rectangles in both bands */
+ register int y2; /* Bottom of current band */
+ /*
+ * Figure out how many rectangles are in the band.
+ */
+ numRects = curStart - prevStart;
+ assert(numRects == pReg->data->numRects - curStart);
+
+ if (!numRects) return curStart;
+
+ /*
+ * The bands may only be coalesced if the bottom of the previous
+ * matches the top scanline of the current.
+ */
+ pPrevBox = REGION_BOX(pReg, prevStart);
+ pCurBox = REGION_BOX(pReg, curStart);
+ if (pPrevBox->y2 != pCurBox->y1) return curStart;
+
+ /*
+ * Make sure the bands have boxes in the same places. This
+ * assumes that boxes have been added in such a way that they
+ * cover the most area possible. I.e. two boxes in a band must
+ * have some horizontal space between them.
+ */
+ y2 = pCurBox->y2;
+
+ do {
+ if ((pPrevBox->x1 != pCurBox->x1) || (pPrevBox->x2 != pCurBox->x2)) {
+ return (curStart);
+ }
+ pPrevBox++;
+ pCurBox++;
+ numRects--;
+ } while (numRects);
+
+ /*
+ * The bands may be merged, so set the bottom y of each box
+ * in the previous band to the bottom y of the current band.
+ */
+ numRects = curStart - prevStart;
+ pReg->data->numRects -= numRects;
+ do {
+ pPrevBox--;
+ pPrevBox->y2 = y2;
+ numRects--;
+ } while (numRects);
+ return prevStart;
+}
+
+
+/* Quicky macro to avoid trivial reject procedure calls to miCoalesce */
+
+#define Coalesce(newReg, prevBand, curBand) \
+ if (curBand - prevBand == newReg->data->numRects - curBand) { \
+ prevBand = miCoalesce(newReg, prevBand, curBand); \
+ } else { \
+ prevBand = curBand; \
+ }
+
+/*-
+ *-----------------------------------------------------------------------
+ * miAppendNonO --
+ * Handle a non-overlapping band for the union and subtract operations.
+ * Just adds the (top/bottom-clipped) rectangles into the region.
+ * Doesn't have to check for subsumption or anything.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * pReg->data->numRects is incremented and the rectangles overwritten
+ * with the rectangles we're passed.
+ *
+ *-----------------------------------------------------------------------
+ */
+
+INLINE static Bool
+miAppendNonO (
+ register RegionPtr pReg,
+ register BoxPtr r,
+ BoxPtr rEnd,
+ register int y1,
+ register int y2)
+{
+ register BoxPtr pNextRect;
+ register int newRects;
+
+ newRects = rEnd - r;
+
+ assert(y1 < y2);
+ assert(newRects != 0);
+
+ /* Make sure we have enough space for all rectangles to be added */
+ RECTALLOC(pReg, newRects);
+ pNextRect = REGION_TOP(pReg);
+ pReg->data->numRects += newRects;
+ do {
+ assert(r->x1 < r->x2);
+ ADDRECT(pNextRect, r->x1, y1, r->x2, y2);
+ r++;
+ } while (r != rEnd);
+
+ return TRUE;
+}
+
+#define FindBand(r, rBandEnd, rEnd, ry1) \
+{ \
+ ry1 = r->y1; \
+ rBandEnd = r+1; \
+ while ((rBandEnd != rEnd) && (rBandEnd->y1 == ry1)) { \
+ rBandEnd++; \
+ } \
+}
+
+#define AppendRegions(newReg, r, rEnd) \
+{ \
+ int newRects; \
+ if ((newRects = rEnd - r)) { \
+ RECTALLOC(newReg, newRects); \
+ memmove((char *)REGION_TOP(newReg),(char *)r, \
+ newRects * sizeof(BoxRec)); \
+ newReg->data->numRects += newRects; \
+ } \
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miRegionOp --
+ * Apply an operation to two regions. Called by miUnion, miInverse,
+ * miSubtract, miIntersect.... Both regions MUST have at least one
+ * rectangle, and cannot be the same object.
+ *
+ * Results:
+ * TRUE if successful.
+ *
+ * Side Effects:
+ * The new region is overwritten.
+ * pOverlap set to TRUE if overlapFunc ever returns TRUE.
+ *
+ * Notes:
+ * The idea behind this function is to view the two regions as sets.
+ * Together they cover a rectangle of area that this function divides
+ * into horizontal bands where points are covered only by one region
+ * or by both. For the first case, the nonOverlapFunc is called with
+ * each the band and the band's upper and lower extents. For the
+ * second, the overlapFunc is called to process the entire band. It
+ * is responsible for clipping the rectangles in the band, though
+ * this function provides the boundaries.
+ * At the end of each band, the new region is coalesced, if possible,
+ * to reduce the number of rectangles in the region.
+ *
+ *-----------------------------------------------------------------------
+ */
+
+typedef Bool (*OverlapProcPtr)(
+ RegionPtr pReg,
+ BoxPtr r1,
+ BoxPtr r1End,
+ BoxPtr r2,
+ BoxPtr r2End,
+ short y1,
+ short y2,
+ Bool *pOverlap);
+
+static Bool
+miRegionOp(
+ RegionPtr newReg, /* Place to store result */
+ RegionPtr reg1, /* First region in operation */
+ RegionPtr reg2, /* 2d region in operation */
+ OverlapProcPtr overlapFunc, /* Function to call for over-
+ * lapping bands */
+ Bool appendNon1, /* Append non-overlapping bands */
+ /* in region 1 ? */
+ Bool appendNon2, /* Append non-overlapping bands */
+ /* in region 2 ? */
+ Bool *pOverlap)
+{
+ register BoxPtr r1; /* Pointer into first region */
+ register BoxPtr r2; /* Pointer into 2d region */
+ BoxPtr r1End; /* End of 1st region */
+ BoxPtr r2End; /* End of 2d region */
+ short ybot; /* Bottom of intersection */
+ short ytop; /* Top of intersection */
+ RegDataPtr oldData; /* Old data for newReg */
+ int prevBand; /* Index of start of
+ * previous band in newReg */
+ int curBand; /* Index of start of current
+ * band in newReg */
+ register BoxPtr r1BandEnd; /* End of current band in r1 */
+ register BoxPtr r2BandEnd; /* End of current band in r2 */
+ short top; /* Top of non-overlapping band */
+ short bot; /* Bottom of non-overlapping band*/
+ register int r1y1; /* Temps for r1->y1 and r2->y1 */
+ register int r2y1;
+ int newSize;
+ int numRects;
+
+ /*
+ * Break any region computed from a broken region
+ */
+ if (REGION_NAR (reg1) || REGION_NAR(reg2))
+ return miRegionBreak (newReg);
+
+ /*
+ * Initialization:
+ * set r1, r2, r1End and r2End appropriately, save the rectangles
+ * of the destination region until the end in case it's one of
+ * the two source regions, then mark the "new" region empty, allocating
+ * another array of rectangles for it to use.
+ */
+
+ r1 = REGION_RECTS(reg1);
+ newSize = REGION_NUM_RECTS(reg1);
+ r1End = r1 + newSize;
+ numRects = REGION_NUM_RECTS(reg2);
+ r2 = REGION_RECTS(reg2);
+ r2End = r2 + numRects;
+ assert(r1 != r1End);
+ assert(r2 != r2End);
+
+ oldData = (RegDataPtr)NULL;
+ if (((newReg == reg1) && (newSize > 1)) ||
+ ((newReg == reg2) && (numRects > 1)))
+ {
+ oldData = newReg->data;
+ newReg->data = &miEmptyData;
+ }
+ /* guess at new size */
+ if (numRects > newSize)
+ newSize = numRects;
+ newSize <<= 1;
+ if (!newReg->data)
+ newReg->data = &miEmptyData;
+ else if (newReg->data->size)
+ newReg->data->numRects = 0;
+ if (newSize > newReg->data->size)
+ if (!miRectAlloc(newReg, newSize))
+ return FALSE;
+
+ /*
+ * Initialize ybot.
+ * In the upcoming loop, ybot and ytop serve different functions depending
+ * on whether the band being handled is an overlapping or non-overlapping
+ * band.
+ * In the case of a non-overlapping band (only one of the regions
+ * has points in the band), ybot is the bottom of the most recent
+ * intersection and thus clips the top of the rectangles in that band.
+ * ytop is the top of the next intersection between the two regions and
+ * serves to clip the bottom of the rectangles in the current band.
+ * For an overlapping band (where the two regions intersect), ytop clips
+ * the top of the rectangles of both regions and ybot clips the bottoms.
+ */
+
+ ybot = min(r1->y1, r2->y1);
+
+ /*
+ * prevBand serves to mark the start of the previous band so rectangles
+ * can be coalesced into larger rectangles. qv. miCoalesce, above.
+ * In the beginning, there is no previous band, so prevBand == curBand
+ * (curBand is set later on, of course, but the first band will always
+ * start at index 0). prevBand and curBand must be indices because of
+ * the possible expansion, and resultant moving, of the new region's
+ * array of rectangles.
+ */
+ prevBand = 0;
+
+ do {
+ /*
+ * This algorithm proceeds one source-band (as opposed to a
+ * destination band, which is determined by where the two regions
+ * intersect) at a time. r1BandEnd and r2BandEnd serve to mark the
+ * rectangle after the last one in the current band for their
+ * respective regions.
+ */
+ assert(r1 != r1End);
+ assert(r2 != r2End);
+
+ FindBand(r1, r1BandEnd, r1End, r1y1);
+ FindBand(r2, r2BandEnd, r2End, r2y1);
+
+ /*
+ * First handle the band that doesn't intersect, if any.
+ *
+ * Note that attention is restricted to one band in the
+ * non-intersecting region at once, so if a region has n
+ * bands between the current position and the next place it overlaps
+ * the other, this entire loop will be passed through n times.
+ */
+ if (r1y1 < r2y1) {
+ if (appendNon1) {
+ top = max(r1y1, ybot);
+ bot = min(r1->y2, r2y1);
+ if (top != bot) {
+ curBand = newReg->data->numRects;
+ miAppendNonO(newReg, r1, r1BandEnd, top, bot);
+ Coalesce(newReg, prevBand, curBand);
+ }
+ }
+ ytop = r2y1;
+ } else if (r2y1 < r1y1) {
+ if (appendNon2) {
+ top = max(r2y1, ybot);
+ bot = min(r2->y2, r1y1);
+ if (top != bot) {
+ curBand = newReg->data->numRects;
+ miAppendNonO(newReg, r2, r2BandEnd, top, bot);
+ Coalesce(newReg, prevBand, curBand);
+ }
+ }
+ ytop = r1y1;
+ } else {
+ ytop = r1y1;
+ }
+
+ /*
+ * Now see if we've hit an intersecting band. The two bands only
+ * intersect if ybot > ytop
+ */
+ ybot = min(r1->y2, r2->y2);
+ if (ybot > ytop) {
+ curBand = newReg->data->numRects;
+ (* overlapFunc)(newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot,
+ pOverlap);
+ Coalesce(newReg, prevBand, curBand);
+ }
+
+ /*
+ * If we've finished with a band (y2 == ybot) we skip forward
+ * in the region to the next band.
+ */
+ if (r1->y2 == ybot) r1 = r1BandEnd;
+ if (r2->y2 == ybot) r2 = r2BandEnd;
+
+ } while (r1 != r1End && r2 != r2End);
+
+ /*
+ * Deal with whichever region (if any) still has rectangles left.
+ *
+ * We only need to worry about banding and coalescing for the very first
+ * band left. After that, we can just group all remaining boxes,
+ * regardless of how many bands, into one final append to the list.
+ */
+
+ if ((r1 != r1End) && appendNon1) {
+ /* Do first nonOverlap1Func call, which may be able to coalesce */
+ FindBand(r1, r1BandEnd, r1End, r1y1);
+ curBand = newReg->data->numRects;
+ miAppendNonO(newReg, r1, r1BandEnd, max(r1y1, ybot), r1->y2);
+ Coalesce(newReg, prevBand, curBand);
+ /* Just append the rest of the boxes */
+ AppendRegions(newReg, r1BandEnd, r1End);
+
+ } else if ((r2 != r2End) && appendNon2) {
+ /* Do first nonOverlap2Func call, which may be able to coalesce */
+ FindBand(r2, r2BandEnd, r2End, r2y1);
+ curBand = newReg->data->numRects;
+ miAppendNonO(newReg, r2, r2BandEnd, max(r2y1, ybot), r2->y2);
+ Coalesce(newReg, prevBand, curBand);
+ /* Append rest of boxes */
+ AppendRegions(newReg, r2BandEnd, r2End);
+ }
+
+ if (oldData)
+ xfree(oldData);
+
+ if (!(numRects = newReg->data->numRects))
+ {
+ xfreeData(newReg);
+ newReg->data = &miEmptyData;
+ }
+ else if (numRects == 1)
+ {
+ newReg->extents = *REGION_BOXPTR(newReg);
+ xfreeData(newReg);
+ newReg->data = (RegDataPtr)NULL;
+ }
+ else
+ {
+ DOWNSIZE(newReg, numRects);
+ }
+
+ return TRUE;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miSetExtents --
+ * Reset the extents of a region to what they should be. Called by
+ * miSubtract and miIntersect as they can't figure it out along the
+ * way or do so easily, as miUnion can.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * The region's 'extents' structure is overwritten.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+miSetExtents (pReg)
+ register RegionPtr pReg;
+{
+ register BoxPtr pBox, pBoxEnd;
+
+ if (!pReg->data)
+ return;
+ if (!pReg->data->size)
+ {
+ pReg->extents.x2 = pReg->extents.x1;
+ pReg->extents.y2 = pReg->extents.y1;
+ return;
+ }
+
+ pBox = REGION_BOXPTR(pReg);
+ pBoxEnd = REGION_END(pReg);
+
+ /*
+ * Since pBox is the first rectangle in the region, it must have the
+ * smallest y1 and since pBoxEnd is the last rectangle in the region,
+ * it must have the largest y2, because of banding. Initialize x1 and
+ * x2 from pBox and pBoxEnd, resp., as good things to initialize them
+ * to...
+ */
+ pReg->extents.x1 = pBox->x1;
+ pReg->extents.y1 = pBox->y1;
+ pReg->extents.x2 = pBoxEnd->x2;
+ pReg->extents.y2 = pBoxEnd->y2;
+
+ assert(pReg->extents.y1 < pReg->extents.y2);
+ while (pBox <= pBoxEnd) {
+ if (pBox->x1 < pReg->extents.x1)
+ pReg->extents.x1 = pBox->x1;
+ if (pBox->x2 > pReg->extents.x2)
+ pReg->extents.x2 = pBox->x2;
+ pBox++;
+ };
+
+ assert(pReg->extents.x1 < pReg->extents.x2);
+}
+
+/*======================================================================
+ * Region Intersection
+ *====================================================================*/
+/*-
+ *-----------------------------------------------------------------------
+ * miIntersectO --
+ * Handle an overlapping band for miIntersect.
+ *
+ * Results:
+ * TRUE if successful.
+ *
+ * Side Effects:
+ * Rectangles may be added to the region.
+ *
+ *-----------------------------------------------------------------------
+ */
+/*ARGSUSED*/
+static Bool
+miIntersectO (
+ register RegionPtr pReg,
+ register BoxPtr r1,
+ BoxPtr r1End,
+ register BoxPtr r2,
+ BoxPtr r2End,
+ short y1,
+ short y2,
+ Bool *pOverlap)
+{
+ register int x1;
+ register int x2;
+ register BoxPtr pNextRect;
+
+ pNextRect = REGION_TOP(pReg);
+
+ assert(y1 < y2);
+ assert(r1 != r1End && r2 != r2End);
+
+ do {
+ x1 = max(r1->x1, r2->x1);
+ x2 = min(r1->x2, r2->x2);
+
+ /*
+ * If there's any overlap between the two rectangles, add that
+ * overlap to the new region.
+ */
+ if (x1 < x2)
+ NEWRECT(pReg, pNextRect, x1, y1, x2, y2);
+
+ /*
+ * Advance the pointer(s) with the leftmost right side, since the next
+ * rectangle on that list may still overlap the other region's
+ * current rectangle.
+ */
+ if (r1->x2 == x2) {
+ r1++;
+ }
+ if (r2->x2 == x2) {
+ r2++;
+ }
+ } while ((r1 != r1End) && (r2 != r2End));
+
+ return TRUE;
+}
+
+
+Bool
+miIntersect(newReg, reg1, reg2)
+ register RegionPtr newReg; /* destination Region */
+ register RegionPtr reg1;
+ register RegionPtr reg2; /* source regions */
+{
+ good(reg1);
+ good(reg2);
+ good(newReg);
+ /* check for trivial reject */
+ if (REGION_NIL(reg1) || REGION_NIL(reg2) ||
+ !EXTENTCHECK(&reg1->extents, &reg2->extents))
+ {
+ /* Covers about 20% of all cases */
+ xfreeData(newReg);
+ newReg->extents.x2 = newReg->extents.x1;
+ newReg->extents.y2 = newReg->extents.y1;
+ if (REGION_NAR(reg1) || REGION_NAR(reg2))
+ {
+ newReg->data = &miBrokenData;
+ return FALSE;
+ }
+ else
+ newReg->data = &miEmptyData;
+ }
+ else if (!reg1->data && !reg2->data)
+ {
+ /* Covers about 80% of cases that aren't trivially rejected */
+ newReg->extents.x1 = max(reg1->extents.x1, reg2->extents.x1);
+ newReg->extents.y1 = max(reg1->extents.y1, reg2->extents.y1);
+ newReg->extents.x2 = min(reg1->extents.x2, reg2->extents.x2);
+ newReg->extents.y2 = min(reg1->extents.y2, reg2->extents.y2);
+ xfreeData(newReg);
+ newReg->data = (RegDataPtr)NULL;
+ }
+ else if (!reg2->data && SUBSUMES(&reg2->extents, &reg1->extents))
+ {
+ return miRegionCopy(newReg, reg1);
+ }
+ else if (!reg1->data && SUBSUMES(&reg1->extents, &reg2->extents))
+ {
+ return miRegionCopy(newReg, reg2);
+ }
+ else if (reg1 == reg2)
+ {
+ return miRegionCopy(newReg, reg1);
+ }
+ else
+ {
+ /* General purpose intersection */
+ Bool overlap; /* result ignored */
+ if (!miRegionOp(newReg, reg1, reg2, miIntersectO, FALSE, FALSE,
+ &overlap))
+ return FALSE;
+ miSetExtents(newReg);
+ }
+
+ good(newReg);
+ return(TRUE);
+}
+
+#define MERGERECT(r) \
+{ \
+ if (r->x1 <= x2) { \
+ /* Merge with current rectangle */ \
+ if (r->x1 < x2) *pOverlap = TRUE; \
+ if (x2 < r->x2) x2 = r->x2; \
+ } else { \
+ /* Add current rectangle, start new one */ \
+ NEWRECT(pReg, pNextRect, x1, y1, x2, y2); \
+ x1 = r->x1; \
+ x2 = r->x2; \
+ } \
+ r++; \
+}
+
+/*======================================================================
+ * Region Union
+ *====================================================================*/
+
+/*-
+ *-----------------------------------------------------------------------
+ * miUnionO --
+ * Handle an overlapping band for the union operation. Picks the
+ * left-most rectangle each time and merges it into the region.
+ *
+ * Results:
+ * TRUE if successful.
+ *
+ * Side Effects:
+ * pReg is overwritten.
+ * pOverlap is set to TRUE if any boxes overlap.
+ *
+ *-----------------------------------------------------------------------
+ */
+static Bool
+miUnionO (
+ register RegionPtr pReg,
+ register BoxPtr r1,
+ BoxPtr r1End,
+ register BoxPtr r2,
+ BoxPtr r2End,
+ short y1,
+ short y2,
+ Bool *pOverlap)
+{
+ register BoxPtr pNextRect;
+ register int x1; /* left and right side of current union */
+ register int x2;
+
+ assert (y1 < y2);
+ assert(r1 != r1End && r2 != r2End);
+
+ pNextRect = REGION_TOP(pReg);
+
+ /* Start off current rectangle */
+ if (r1->x1 < r2->x1)
+ {
+ x1 = r1->x1;
+ x2 = r1->x2;
+ r1++;
+ }
+ else
+ {
+ x1 = r2->x1;
+ x2 = r2->x2;
+ r2++;
+ }
+ while (r1 != r1End && r2 != r2End)
+ {
+ if (r1->x1 < r2->x1) MERGERECT(r1) else MERGERECT(r2);
+ }
+
+ /* Finish off whoever (if any) is left */
+ if (r1 != r1End)
+ {
+ do
+ {
+ MERGERECT(r1);
+ } while (r1 != r1End);
+ }
+ else if (r2 != r2End)
+ {
+ do
+ {
+ MERGERECT(r2);
+ } while (r2 != r2End);
+ }
+
+ /* Add current rectangle */
+ NEWRECT(pReg, pNextRect, x1, y1, x2, y2);
+
+ return TRUE;
+}
+
+Bool
+miUnion(newReg, reg1, reg2)
+ RegionPtr newReg; /* destination Region */
+ register RegionPtr reg1;
+ register RegionPtr reg2; /* source regions */
+{
+ Bool overlap; /* result ignored */
+
+ /* Return TRUE if some overlap between reg1, reg2 */
+ good(reg1);
+ good(reg2);
+ good(newReg);
+ /* checks all the simple cases */
+
+ /*
+ * Region 1 and 2 are the same
+ */
+ if (reg1 == reg2)
+ {
+ return miRegionCopy(newReg, reg1);
+ }
+
+ /*
+ * Region 1 is empty
+ */
+ if (REGION_NIL(reg1))
+ {
+ if (REGION_NAR(reg1))
+ return miRegionBreak (newReg);
+ if (newReg != reg2)
+ return miRegionCopy(newReg, reg2);
+ return TRUE;
+ }
+
+ /*
+ * Region 2 is empty
+ */
+ if (REGION_NIL(reg2))
+ {
+ if (REGION_NAR(reg2))
+ return miRegionBreak (newReg);
+ if (newReg != reg1)
+ return miRegionCopy(newReg, reg1);
+ return TRUE;
+ }
+
+ /*
+ * Region 1 completely subsumes region 2
+ */
+ if (!reg1->data && SUBSUMES(&reg1->extents, &reg2->extents))
+ {
+ if (newReg != reg1)
+ return miRegionCopy(newReg, reg1);
+ return TRUE;
+ }
+
+ /*
+ * Region 2 completely subsumes region 1
+ */
+ if (!reg2->data && SUBSUMES(&reg2->extents, &reg1->extents))
+ {
+ if (newReg != reg2)
+ return miRegionCopy(newReg, reg2);
+ return TRUE;
+ }
+
+ if (!miRegionOp(newReg, reg1, reg2, miUnionO, TRUE, TRUE, &overlap))
+ return FALSE;
+
+ newReg->extents.x1 = min(reg1->extents.x1, reg2->extents.x1);
+ newReg->extents.y1 = min(reg1->extents.y1, reg2->extents.y1);
+ newReg->extents.x2 = max(reg1->extents.x2, reg2->extents.x2);
+ newReg->extents.y2 = max(reg1->extents.y2, reg2->extents.y2);
+ good(newReg);
+ return TRUE;
+}
+
+
+/*======================================================================
+ * Batch Rectangle Union
+ *====================================================================*/
+
+/*-
+ *-----------------------------------------------------------------------
+ * miRegionAppend --
+ *
+ * "Append" the rgn rectangles onto the end of dstrgn, maintaining
+ * knowledge of YX-banding when it's easy. Otherwise, dstrgn just
+ * becomes a non-y-x-banded random collection of rectangles, and not
+ * yet a true region. After a sequence of appends, the caller must
+ * call miRegionValidate to ensure that a valid region is constructed.
+ *
+ * Results:
+ * TRUE if successful.
+ *
+ * Side Effects:
+ * dstrgn is modified if rgn has rectangles.
+ *
+ */
+Bool
+miRegionAppend(dstrgn, rgn)
+ register RegionPtr dstrgn;
+ register RegionPtr rgn;
+{
+ int numRects, dnumRects, size;
+ BoxPtr new, old;
+ Bool prepend;
+
+ if (REGION_NAR(rgn))
+ return miRegionBreak (dstrgn);
+
+ if (!rgn->data && (dstrgn->data == &miEmptyData))
+ {
+ dstrgn->extents = rgn->extents;
+ dstrgn->data = (RegDataPtr)NULL;
+ return TRUE;
+ }
+
+ numRects = REGION_NUM_RECTS(rgn);
+ if (!numRects)
+ return TRUE;
+ prepend = FALSE;
+ size = numRects;
+ dnumRects = REGION_NUM_RECTS(dstrgn);
+ if (!dnumRects && (size < 200))
+ size = 200; /* XXX pick numbers out of a hat */
+ RECTALLOC(dstrgn, size);
+ old = REGION_RECTS(rgn);
+ if (!dnumRects)
+ dstrgn->extents = rgn->extents;
+ else if (dstrgn->extents.x2 > dstrgn->extents.x1)
+ {
+ register BoxPtr first, last;
+
+ first = old;
+ last = REGION_BOXPTR(dstrgn) + (dnumRects - 1);
+ if ((first->y1 > last->y2) ||
+ ((first->y1 == last->y1) && (first->y2 == last->y2) &&
+ (first->x1 > last->x2)))
+ {
+ if (rgn->extents.x1 < dstrgn->extents.x1)
+ dstrgn->extents.x1 = rgn->extents.x1;
+ if (rgn->extents.x2 > dstrgn->extents.x2)
+ dstrgn->extents.x2 = rgn->extents.x2;
+ dstrgn->extents.y2 = rgn->extents.y2;
+ }
+ else
+ {
+ first = REGION_BOXPTR(dstrgn);
+ last = old + (numRects - 1);
+ if ((first->y1 > last->y2) ||
+ ((first->y1 == last->y1) && (first->y2 == last->y2) &&
+ (first->x1 > last->x2)))
+ {
+ prepend = TRUE;
+ if (rgn->extents.x1 < dstrgn->extents.x1)
+ dstrgn->extents.x1 = rgn->extents.x1;
+ if (rgn->extents.x2 > dstrgn->extents.x2)
+ dstrgn->extents.x2 = rgn->extents.x2;
+ dstrgn->extents.y1 = rgn->extents.y1;
+ }
+ else
+ dstrgn->extents.x2 = dstrgn->extents.x1;
+ }
+ }
+ if (prepend)
+ {
+ new = REGION_BOX(dstrgn, numRects);
+ if (dnumRects == 1)
+ *new = *REGION_BOXPTR(dstrgn);
+ else
+ memmove((char *)new,(char *)REGION_BOXPTR(dstrgn),
+ dnumRects * sizeof(BoxRec));
+ new = REGION_BOXPTR(dstrgn);
+ }
+ else
+ new = REGION_BOXPTR(dstrgn) + dnumRects;
+ if (numRects == 1)
+ *new = *old;
+ else
+ memmove((char *)new, (char *)old, numRects * sizeof(BoxRec));
+ dstrgn->data->numRects += numRects;
+ return TRUE;
+}
+
+
+#define ExchangeRects(a, b) \
+{ \
+ BoxRec t; \
+ t = rects[a]; \
+ rects[a] = rects[b]; \
+ rects[b] = t; \
+}
+
+static void
+QuickSortRects(
+ register BoxRec rects[],
+ register int numRects)
+{
+ register int y1;
+ register int x1;
+ register int i, j;
+ register BoxPtr r;
+
+ /* Always called with numRects > 1 */
+
+ do
+ {
+ if (numRects == 2)
+ {
+ if (rects[0].y1 > rects[1].y1 ||
+ (rects[0].y1 == rects[1].y1 && rects[0].x1 > rects[1].x1))
+ ExchangeRects(0, 1);
+ return;
+ }
+
+ /* Choose partition element, stick in location 0 */
+ ExchangeRects(0, numRects >> 1);
+ y1 = rects[0].y1;
+ x1 = rects[0].x1;
+
+ /* Partition array */
+ i = 0;
+ j = numRects;
+ do
+ {
+ r = &(rects[i]);
+ do
+ {
+ r++;
+ i++;
+ } while (i != numRects &&
+ (r->y1 < y1 || (r->y1 == y1 && r->x1 < x1)));
+ r = &(rects[j]);
+ do
+ {
+ r--;
+ j--;
+ } while (y1 < r->y1 || (y1 == r->y1 && x1 < r->x1));
+ if (i < j)
+ ExchangeRects(i, j);
+ } while (i < j);
+
+ /* Move partition element back to middle */
+ ExchangeRects(0, j);
+
+ /* Recurse */
+ if (numRects-j-1 > 1)
+ QuickSortRects(&rects[j+1], numRects-j-1);
+ numRects = j;
+ } while (numRects > 1);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miRegionValidate --
+ *
+ * Take a ``region'' which is a non-y-x-banded random collection of
+ * rectangles, and compute a nice region which is the union of all the
+ * rectangles.
+ *
+ * Results:
+ * TRUE if successful.
+ *
+ * Side Effects:
+ * The passed-in ``region'' may be modified.
+ * pOverlap set to TRUE if any retangles overlapped, else FALSE;
+ *
+ * Strategy:
+ * Step 1. Sort the rectangles into ascending order with primary key y1
+ * and secondary key x1.
+ *
+ * Step 2. Split the rectangles into the minimum number of proper y-x
+ * banded regions. This may require horizontally merging
+ * rectangles, and vertically coalescing bands. With any luck,
+ * this step in an identity tranformation (ala the Box widget),
+ * or a coalescing into 1 box (ala Menus).
+ *
+ * Step 3. Merge the separate regions down to a single region by calling
+ * miUnion. Maximize the work each miUnion call does by using
+ * a binary merge.
+ *
+ *-----------------------------------------------------------------------
+ */
+
+Bool
+miRegionValidate(badreg, pOverlap)
+ RegionPtr badreg;
+ Bool *pOverlap;
+{
+ /* Descriptor for regions under construction in Step 2. */
+ typedef struct {
+ RegionRec reg;
+ int prevBand;
+ int curBand;
+ } RegionInfo;
+
+ int numRects; /* Original numRects for badreg */
+ RegionInfo *ri; /* Array of current regions */
+ int numRI; /* Number of entries used in ri */
+ int sizeRI; /* Number of entries available in ri */
+ int i; /* Index into rects */
+ register int j; /* Index into ri */
+ register RegionInfo *rit; /* &ri[j] */
+ register RegionPtr reg; /* ri[j].reg */
+ register BoxPtr box; /* Current box in rects */
+ register BoxPtr riBox; /* Last box in ri[j].reg */
+ register RegionPtr hreg; /* ri[j_half].reg */
+ Bool ret = TRUE;
+
+ *pOverlap = FALSE;
+ if (!badreg->data)
+ {
+ good(badreg);
+ return TRUE;
+ }
+ numRects = badreg->data->numRects;
+ if (!numRects)
+ {
+ if (REGION_NAR(badreg))
+ return FALSE;
+ good(badreg);
+ return TRUE;
+ }
+ if (badreg->extents.x1 < badreg->extents.x2)
+ {
+ if ((numRects) == 1)
+ {
+ xfreeData(badreg);
+ badreg->data = (RegDataPtr) NULL;
+ }
+ else
+ {
+ DOWNSIZE(badreg, numRects);
+ }
+ good(badreg);
+ return TRUE;
+ }
+
+ /* Step 1: Sort the rects array into ascending (y1, x1) order */
+ QuickSortRects(REGION_BOXPTR(badreg), numRects);
+
+ /* Step 2: Scatter the sorted array into the minimum number of regions */
+
+ /* Set up the first region to be the first rectangle in badreg */
+ /* Note that step 2 code will never overflow the ri[0].reg rects array */
+ ri = (RegionInfo *) xalloc(4 * sizeof(RegionInfo));
+ if (!ri)
+ return miRegionBreak (badreg);
+ sizeRI = 4;
+ numRI = 1;
+ ri[0].prevBand = 0;
+ ri[0].curBand = 0;
+ ri[0].reg = *badreg;
+ box = REGION_BOXPTR(&ri[0].reg);
+ ri[0].reg.extents = *box;
+ ri[0].reg.data->numRects = 1;
+
+ /* Now scatter rectangles into the minimum set of valid regions. If the
+ next rectangle to be added to a region would force an existing rectangle
+ in the region to be split up in order to maintain y-x banding, just
+ forget it. Try the next region. If it doesn't fit cleanly into any
+ region, make a new one. */
+
+ for (i = numRects; --i > 0;)
+ {
+ box++;
+ /* Look for a region to append box to */
+ for (j = numRI, rit = ri; --j >= 0; rit++)
+ {
+ reg = &rit->reg;
+ riBox = REGION_END(reg);
+
+ if (box->y1 == riBox->y1 && box->y2 == riBox->y2)
+ {
+ /* box is in same band as riBox. Merge or append it */
+ if (box->x1 <= riBox->x2)
+ {
+ /* Merge it with riBox */
+ if (box->x1 < riBox->x2) *pOverlap = TRUE;
+ if (box->x2 > riBox->x2) riBox->x2 = box->x2;
+ }
+ else
+ {
+ RECTALLOC_BAIL(reg, 1, bail);
+ *REGION_TOP(reg) = *box;
+ reg->data->numRects++;
+ }
+ goto NextRect; /* So sue me */
+ }
+ else if (box->y1 >= riBox->y2)
+ {
+ /* Put box into new band */
+ if (reg->extents.x2 < riBox->x2) reg->extents.x2 = riBox->x2;
+ if (reg->extents.x1 > box->x1) reg->extents.x1 = box->x1;
+ Coalesce(reg, rit->prevBand, rit->curBand);
+ rit->curBand = reg->data->numRects;
+ RECTALLOC_BAIL(reg, 1, bail);
+ *REGION_TOP(reg) = *box;
+ reg->data->numRects++;
+ goto NextRect;
+ }
+ /* Well, this region was inappropriate. Try the next one. */
+ } /* for j */
+
+ /* Uh-oh. No regions were appropriate. Create a new one. */
+ if (sizeRI == numRI)
+ {
+ /* Oops, allocate space for new region information */
+ sizeRI <<= 1;
+ rit = (RegionInfo *) xrealloc(ri, sizeRI * sizeof(RegionInfo));
+ if (!rit)
+ goto bail;
+ ri = rit;
+ rit = &ri[numRI];
+ }
+ numRI++;
+ rit->prevBand = 0;
+ rit->curBand = 0;
+ rit->reg.extents = *box;
+ rit->reg.data = (RegDataPtr)NULL;
+ if (!miRectAlloc(&rit->reg, (i+numRI) / numRI)) /* MUST force allocation */
+ goto bail;
+NextRect: ;
+ } /* for i */
+
+ /* Make a final pass over each region in order to Coalesce and set
+ extents.x2 and extents.y2 */
+
+ for (j = numRI, rit = ri; --j >= 0; rit++)
+ {
+ reg = &rit->reg;
+ riBox = REGION_END(reg);
+ reg->extents.y2 = riBox->y2;
+ if (reg->extents.x2 < riBox->x2) reg->extents.x2 = riBox->x2;
+ Coalesce(reg, rit->prevBand, rit->curBand);
+ if (reg->data->numRects == 1) /* keep unions happy below */
+ {
+ xfreeData(reg);
+ reg->data = (RegDataPtr)NULL;
+ }
+ }
+
+ /* Step 3: Union all regions into a single region */
+ while (numRI > 1)
+ {
+ int half = numRI/2;
+ for (j = numRI & 1; j < (half + (numRI & 1)); j++)
+ {
+ reg = &ri[j].reg;
+ hreg = &ri[j+half].reg;
+ if (!miRegionOp(reg, reg, hreg, miUnionO, TRUE, TRUE, pOverlap))
+ ret = FALSE;
+ if (hreg->extents.x1 < reg->extents.x1)
+ reg->extents.x1 = hreg->extents.x1;
+ if (hreg->extents.y1 < reg->extents.y1)
+ reg->extents.y1 = hreg->extents.y1;
+ if (hreg->extents.x2 > reg->extents.x2)
+ reg->extents.x2 = hreg->extents.x2;
+ if (hreg->extents.y2 > reg->extents.y2)
+ reg->extents.y2 = hreg->extents.y2;
+ xfreeData(hreg);
+ }
+ numRI -= half;
+ }
+ *badreg = ri[0].reg;
+ xfree(ri);
+ good(badreg);
+ return ret;
+bail:
+ for (i = 0; i < numRI; i++)
+ xfreeData(&ri[i].reg);
+ xfree (ri);
+ return miRegionBreak (badreg);
+}
+
+RegionPtr
+miRectsToRegion(nrects, prect, ctype)
+ int nrects;
+ register xRectangle *prect;
+ int ctype;
+{
+ register RegionPtr pRgn;
+ register RegDataPtr pData;
+ register BoxPtr pBox;
+ register int i;
+ int x1, y1, x2, y2;
+
+ pRgn = miRegionCreate(NullBox, 0);
+ if (REGION_NAR (pRgn))
+ return pRgn;
+ if (!nrects)
+ return pRgn;
+ if (nrects == 1)
+ {
+ x1 = prect->x;
+ y1 = prect->y;
+ if ((x2 = x1 + (int) prect->width) > MAXSHORT)
+ x2 = MAXSHORT;
+ if ((y2 = y1 + (int) prect->height) > MAXSHORT)
+ y2 = MAXSHORT;
+ if (x1 != x2 && y1 != y2)
+ {
+ pRgn->extents.x1 = x1;
+ pRgn->extents.y1 = y1;
+ pRgn->extents.x2 = x2;
+ pRgn->extents.y2 = y2;
+ pRgn->data = (RegDataPtr)NULL;
+ }
+ return pRgn;
+ }
+ pData = xallocData(nrects);
+ if (!pData)
+ {
+ miRegionBreak (pRgn);
+ return pRgn;
+ }
+ pBox = (BoxPtr) (pData + 1);
+ for (i = nrects; --i >= 0; prect++)
+ {
+ x1 = prect->x;
+ y1 = prect->y;
+ if ((x2 = x1 + (int) prect->width) > MAXSHORT)
+ x2 = MAXSHORT;
+ if ((y2 = y1 + (int) prect->height) > MAXSHORT)
+ y2 = MAXSHORT;
+ if (x1 != x2 && y1 != y2)
+ {
+ pBox->x1 = x1;
+ pBox->y1 = y1;
+ pBox->x2 = x2;
+ pBox->y2 = y2;
+ pBox++;
+ }
+ }
+ if (pBox != (BoxPtr) (pData + 1))
+ {
+ pData->size = nrects;
+ pData->numRects = pBox - (BoxPtr) (pData + 1);
+ pRgn->data = pData;
+ if (ctype != CT_YXBANDED)
+ {
+ Bool overlap; /* result ignored */
+ pRgn->extents.x1 = pRgn->extents.x2 = 0;
+ miRegionValidate(pRgn, &overlap);
+ }
+ else
+ miSetExtents(pRgn);
+ good(pRgn);
+ }
+ else
+ {
+ xfree (pData);
+ }
+ return pRgn;
+}
+
+/*======================================================================
+ * Region Subtraction
+ *====================================================================*/
+
+
+/*-
+ *-----------------------------------------------------------------------
+ * miSubtractO --
+ * Overlapping band subtraction. x1 is the left-most point not yet
+ * checked.
+ *
+ * Results:
+ * TRUE if successful.
+ *
+ * Side Effects:
+ * pReg may have rectangles added to it.
+ *
+ *-----------------------------------------------------------------------
+ */
+/*ARGSUSED*/
+static Bool
+miSubtractO (
+ register RegionPtr pReg,
+ register BoxPtr r1,
+ BoxPtr r1End,
+ register BoxPtr r2,
+ BoxPtr r2End,
+ register short y1,
+ short y2,
+ Bool *pOverlap)
+{
+ register BoxPtr pNextRect;
+ register int x1;
+
+ x1 = r1->x1;
+
+ assert(y1<y2);
+ assert(r1 != r1End && r2 != r2End);
+
+ pNextRect = REGION_TOP(pReg);
+
+ do
+ {
+ if (r2->x2 <= x1)
+ {
+ /*
+ * Subtrahend entirely to left of minuend: go to next subtrahend.
+ */
+ r2++;
+ }
+ else if (r2->x1 <= x1)
+ {
+ /*
+ * Subtrahend preceeds minuend: nuke left edge of minuend.
+ */
+ x1 = r2->x2;
+ if (x1 >= r1->x2)
+ {
+ /*
+ * Minuend completely covered: advance to next minuend and
+ * reset left fence to edge of new minuend.
+ */
+ r1++;
+ if (r1 != r1End)
+ x1 = r1->x1;
+ }
+ else
+ {
+ /*
+ * Subtrahend now used up since it doesn't extend beyond
+ * minuend
+ */
+ r2++;
+ }
+ }
+ else if (r2->x1 < r1->x2)
+ {
+ /*
+ * Left part of subtrahend covers part of minuend: add uncovered
+ * part of minuend to region and skip to next subtrahend.
+ */
+ assert(x1<r2->x1);
+ NEWRECT(pReg, pNextRect, x1, y1, r2->x1, y2);
+
+ x1 = r2->x2;
+ if (x1 >= r1->x2)
+ {
+ /*
+ * Minuend used up: advance to new...
+ */
+ r1++;
+ if (r1 != r1End)
+ x1 = r1->x1;
+ }
+ else
+ {
+ /*
+ * Subtrahend used up
+ */
+ r2++;
+ }
+ }
+ else
+ {
+ /*
+ * Minuend used up: add any remaining piece before advancing.
+ */
+ if (r1->x2 > x1)
+ NEWRECT(pReg, pNextRect, x1, y1, r1->x2, y2);
+ r1++;
+ if (r1 != r1End)
+ x1 = r1->x1;
+ }
+ } while ((r1 != r1End) && (r2 != r2End));
+
+
+ /*
+ * Add remaining minuend rectangles to region.
+ */
+ while (r1 != r1End)
+ {
+ assert(x1<r1->x2);
+ NEWRECT(pReg, pNextRect, x1, y1, r1->x2, y2);
+ r1++;
+ if (r1 != r1End)
+ x1 = r1->x1;
+ }
+ return TRUE;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miSubtract --
+ * Subtract regS from regM and leave the result in regD.
+ * S stands for subtrahend, M for minuend and D for difference.
+ *
+ * Results:
+ * TRUE if successful.
+ *
+ * Side Effects:
+ * regD is overwritten.
+ *
+ *-----------------------------------------------------------------------
+ */
+Bool
+miSubtract(regD, regM, regS)
+ register RegionPtr regD;
+ register RegionPtr regM;
+ register RegionPtr regS;
+{
+ Bool overlap; /* result ignored */
+
+ good(regM);
+ good(regS);
+ good(regD);
+ /* check for trivial rejects */
+ if (REGION_NIL(regM) || REGION_NIL(regS) ||
+ !EXTENTCHECK(&regM->extents, &regS->extents))
+ {
+ if (REGION_NAR (regS))
+ return miRegionBreak (regD);
+ return miRegionCopy(regD, regM);
+ }
+ else if (regM == regS)
+ {
+ xfreeData(regD);
+ regD->extents.x2 = regD->extents.x1;
+ regD->extents.y2 = regD->extents.y1;
+ regD->data = &miEmptyData;
+ return TRUE;
+ }
+
+ /* Add those rectangles in region 1 that aren't in region 2,
+ do yucky substraction for overlaps, and
+ just throw away rectangles in region 2 that aren't in region 1 */
+ if (!miRegionOp(regD, regM, regS, miSubtractO, TRUE, FALSE, &overlap))
+ return FALSE;
+
+ /*
+ * Can't alter RegD's extents before we call miRegionOp because
+ * it might be one of the source regions and miRegionOp depends
+ * on the extents of those regions being unaltered. Besides, this
+ * way there's no checking against rectangles that will be nuked
+ * due to coalescing, so we have to examine fewer rectangles.
+ */
+ miSetExtents(regD);
+ good(regD);
+ return TRUE;
+}
+
+/*======================================================================
+ * Region Inversion
+ *====================================================================*/
+
+/*-
+ *-----------------------------------------------------------------------
+ * miInverse --
+ * Take a region and a box and return a region that is everything
+ * in the box but not in the region. The careful reader will note
+ * that this is the same as subtracting the region from the box...
+ *
+ * Results:
+ * TRUE.
+ *
+ * Side Effects:
+ * newReg is overwritten.
+ *
+ *-----------------------------------------------------------------------
+ */
+Bool
+miInverse(newReg, reg1, invRect)
+ RegionPtr newReg; /* Destination region */
+ RegionPtr reg1; /* Region to invert */
+ BoxPtr invRect; /* Bounding box for inversion */
+{
+ RegionRec invReg; /* Quick and dirty region made from the
+ * bounding box */
+ Bool overlap; /* result ignored */
+
+ good(reg1);
+ good(newReg);
+ /* check for trivial rejects */
+ if (REGION_NIL(reg1) || !EXTENTCHECK(invRect, &reg1->extents))
+ {
+ if (REGION_NAR(reg1))
+ return miRegionBreak (newReg);
+ newReg->extents = *invRect;
+ xfreeData(newReg);
+ newReg->data = (RegDataPtr)NULL;
+ return TRUE;
+ }
+
+ /* Add those rectangles in region 1 that aren't in region 2,
+ do yucky substraction for overlaps, and
+ just throw away rectangles in region 2 that aren't in region 1 */
+ invReg.extents = *invRect;
+ invReg.data = (RegDataPtr)NULL;
+ if (!miRegionOp(newReg, &invReg, reg1, miSubtractO, TRUE, FALSE, &overlap))
+ return FALSE;
+
+ /*
+ * Can't alter newReg's extents before we call miRegionOp because
+ * it might be one of the source regions and miRegionOp depends
+ * on the extents of those regions being unaltered. Besides, this
+ * way there's no checking against rectangles that will be nuked
+ * due to coalescing, so we have to examine fewer rectangles.
+ */
+ miSetExtents(newReg);
+ good(newReg);
+ return TRUE;
+}
+
+/*
+ * RectIn(region, rect)
+ * This routine takes a pointer to a region and a pointer to a box
+ * and determines if the box is outside/inside/partly inside the region.
+ *
+ * The idea is to travel through the list of rectangles trying to cover the
+ * passed box with them. Anytime a piece of the rectangle isn't covered
+ * by a band of rectangles, partOut is set TRUE. Any time a rectangle in
+ * the region covers part of the box, partIn is set TRUE. The process ends
+ * when either the box has been completely covered (we reached a band that
+ * doesn't overlap the box, partIn is TRUE and partOut is false), the
+ * box has been partially covered (partIn == partOut == TRUE -- because of
+ * the banding, the first time this is true we know the box is only
+ * partially in the region) or is outside the region (we reached a band
+ * that doesn't overlap the box at all and partIn is false)
+ */
+
+int
+miRectIn(region, prect)
+ register RegionPtr region;
+ register BoxPtr prect;
+{
+ register int x;
+ register int y;
+ register BoxPtr pbox;
+ register BoxPtr pboxEnd;
+ int partIn, partOut;
+ int numRects;
+
+ good(region);
+ numRects = REGION_NUM_RECTS(region);
+ /* useful optimization */
+ if (!numRects || !EXTENTCHECK(&region->extents, prect))
+ return(rgnOUT);
+
+ if (numRects == 1)
+ {
+ /* We know that it must be rgnIN or rgnPART */
+ if (SUBSUMES(&region->extents, prect))
+ return(rgnIN);
+ else
+ return(rgnPART);
+ }
+
+ partOut = FALSE;
+ partIn = FALSE;
+
+ /* (x,y) starts at upper left of rect, moving to the right and down */
+ x = prect->x1;
+ y = prect->y1;
+
+ /* can stop when both partOut and partIn are TRUE, or we reach prect->y2 */
+ for (pbox = REGION_BOXPTR(region), pboxEnd = pbox + numRects;
+ pbox != pboxEnd;
+ pbox++)
+ {
+
+ if (pbox->y2 <= y)
+ continue; /* getting up to speed or skipping remainder of band */
+
+ if (pbox->y1 > y)
+ {
+ partOut = TRUE; /* missed part of rectangle above */
+ if (partIn || (pbox->y1 >= prect->y2))
+ break;
+ y = pbox->y1; /* x guaranteed to be == prect->x1 */
+ }
+
+ if (pbox->x2 <= x)
+ continue; /* not far enough over yet */
+
+ if (pbox->x1 > x)
+ {
+ partOut = TRUE; /* missed part of rectangle to left */
+ if (partIn)
+ break;
+ }
+
+ if (pbox->x1 < prect->x2)
+ {
+ partIn = TRUE; /* definitely overlap */
+ if (partOut)
+ break;
+ }
+
+ if (pbox->x2 >= prect->x2)
+ {
+ y = pbox->y2; /* finished with this band */
+ if (y >= prect->y2)
+ break;
+ x = prect->x1; /* reset x out to left again */
+ }
+ else
+ {
+ /*
+ * Because boxes in a band are maximal width, if the first box
+ * to overlap the rectangle doesn't completely cover it in that
+ * band, the rectangle must be partially out, since some of it
+ * will be uncovered in that band. partIn will have been set true
+ * by now...
+ */
+ partOut = TRUE;
+ break;
+ }
+ }
+
+ return(partIn ? ((y < prect->y2) ? rgnPART : rgnIN) : rgnOUT);
+}
+
+/* TranslateRegion(pReg, x, y)
+ translates in place
+*/
+
+void
+miTranslateRegion(pReg, x, y)
+ register RegionPtr pReg;
+ register int x;
+ register int y;
+{
+ int x1, x2, y1, y2;
+ register int nbox;
+ register BoxPtr pbox;
+
+ good(pReg);
+ pReg->extents.x1 = x1 = pReg->extents.x1 + x;
+ pReg->extents.y1 = y1 = pReg->extents.y1 + y;
+ pReg->extents.x2 = x2 = pReg->extents.x2 + x;
+ pReg->extents.y2 = y2 = pReg->extents.y2 + y;
+ if (((x1 - MINSHORT)|(y1 - MINSHORT)|(MAXSHORT - x2)|(MAXSHORT - y2)) >= 0)
+ {
+ if (pReg->data && (nbox = pReg->data->numRects))
+ {
+ for (pbox = REGION_BOXPTR(pReg); nbox--; pbox++)
+ {
+ pbox->x1 += x;
+ pbox->y1 += y;
+ pbox->x2 += x;
+ pbox->y2 += y;
+ }
+ }
+ return;
+ }
+ if (((x2 - MINSHORT)|(y2 - MINSHORT)|(MAXSHORT - x1)|(MAXSHORT - y1)) <= 0)
+ {
+ pReg->extents.x2 = pReg->extents.x1;
+ pReg->extents.y2 = pReg->extents.y1;
+ xfreeData(pReg);
+ pReg->data = &miEmptyData;
+ return;
+ }
+ if (x1 < MINSHORT)
+ pReg->extents.x1 = MINSHORT;
+ else if (x2 > MAXSHORT)
+ pReg->extents.x2 = MAXSHORT;
+ if (y1 < MINSHORT)
+ pReg->extents.y1 = MINSHORT;
+ else if (y2 > MAXSHORT)
+ pReg->extents.y2 = MAXSHORT;
+ if (pReg->data && (nbox = pReg->data->numRects))
+ {
+ register BoxPtr pboxout;
+
+ for (pboxout = pbox = REGION_BOXPTR(pReg); nbox--; pbox++)
+ {
+ pboxout->x1 = x1 = pbox->x1 + x;
+ pboxout->y1 = y1 = pbox->y1 + y;
+ pboxout->x2 = x2 = pbox->x2 + x;
+ pboxout->y2 = y2 = pbox->y2 + y;
+ if (((x2 - MINSHORT)|(y2 - MINSHORT)|
+ (MAXSHORT - x1)|(MAXSHORT - y1)) <= 0)
+ {
+ pReg->data->numRects--;
+ continue;
+ }
+ if (x1 < MINSHORT)
+ pboxout->x1 = MINSHORT;
+ else if (x2 > MAXSHORT)
+ pboxout->x2 = MAXSHORT;
+ if (y1 < MINSHORT)
+ pboxout->y1 = MINSHORT;
+ else if (y2 > MAXSHORT)
+ pboxout->y2 = MAXSHORT;
+ pboxout++;
+ }
+ if (pboxout != pbox)
+ {
+ if (pReg->data->numRects == 1)
+ {
+ pReg->extents = *REGION_BOXPTR(pReg);
+ xfreeData(pReg);
+ pReg->data = (RegDataPtr)NULL;
+ }
+ else
+ miSetExtents(pReg);
+ }
+ }
+}
+
+Bool
+miRegionDataCopy(
+ register RegionPtr dst,
+ register RegionPtr src)
+{
+ good(dst);
+ good(src);
+ if (dst->data)
+ return TRUE;
+ if (dst == src)
+ return TRUE;
+ if (!src->data || !src->data->size)
+ {
+ xfreeData(dst);
+ dst->data = (RegDataPtr)NULL;
+ return TRUE;
+ }
+ if (!dst->data || (dst->data->size < src->data->numRects))
+ {
+ xfreeData(dst);
+ dst->data = xallocData(src->data->numRects);
+ if (!dst->data)
+ return miRegionBreak (dst);
+ }
+ dst->data->size = src->data->size;
+ dst->data->numRects = src->data->numRects;
+ return TRUE;
+}
+
+void
+miRegionReset(pReg, pBox)
+ RegionPtr pReg;
+ BoxPtr pBox;
+{
+ good(pReg);
+ assert(pBox->x1<=pBox->x2);
+ assert(pBox->y1<=pBox->y2);
+ pReg->extents = *pBox;
+ xfreeData(pReg);
+ pReg->data = (RegDataPtr)NULL;
+}
+
+Bool
+miPointInRegion(pReg, x, y, box)
+ register RegionPtr pReg;
+ register int x, y;
+ BoxPtr box; /* "return" value */
+{
+ register BoxPtr pbox, pboxEnd;
+ int numRects;
+
+ good(pReg);
+ numRects = REGION_NUM_RECTS(pReg);
+ if (!numRects || !INBOX(&pReg->extents, x, y))
+ return(FALSE);
+ if (numRects == 1)
+ {
+ *box = pReg->extents;
+ return(TRUE);
+ }
+ for (pbox = REGION_BOXPTR(pReg), pboxEnd = pbox + numRects;
+ pbox != pboxEnd;
+ pbox++)
+ {
+ if (y >= pbox->y2)
+ continue; /* not there yet */
+ if ((y < pbox->y1) || (x < pbox->x1))
+ break; /* missed it */
+ if (x >= pbox->x2)
+ continue; /* not there yet */
+ *box = *pbox;
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+Bool
+miRegionNotEmpty(pReg)
+ RegionPtr pReg;
+{
+ good(pReg);
+ return(!REGION_NIL(pReg));
+}
+
+Bool
+miRegionBroken(RegionPtr pReg)
+{
+ good(pReg);
+ return (REGION_NAR(pReg));
+}
+
+void
+miRegionEmpty(pReg)
+ RegionPtr pReg;
+{
+ good(pReg);
+ xfreeData(pReg);
+ pReg->extents.x2 = pReg->extents.x1;
+ pReg->extents.y2 = pReg->extents.y1;
+ pReg->data = &miEmptyData;
+}
+
+BoxPtr
+miRegionExtents(pReg)
+ RegionPtr pReg;
+{
+ good(pReg);
+ return(&pReg->extents);
+}
+
+#define ExchangeSpans(a, b) \
+{ \
+ DDXPointRec tpt; \
+ register int tw; \
+ \
+ tpt = spans[a]; spans[a] = spans[b]; spans[b] = tpt; \
+ tw = widths[a]; widths[a] = widths[b]; widths[b] = tw; \
+}
+
+/* ||| I should apply the merge sort code to rectangle sorting above, and see
+ if mapping time can be improved. But right now I've been at work 12 hours,
+ so forget it.
+*/
+
+static void QuickSortSpans(
+ register DDXPointRec spans[],
+ register int widths[],
+ register int numSpans)
+{
+ register int y;
+ register int i, j, m;
+ register DDXPointPtr r;
+
+ /* Always called with numSpans > 1 */
+ /* Sorts only by y, doesn't bother to sort by x */
+
+ do
+ {
+ if (numSpans < 9)
+ {
+ /* Do insertion sort */
+ register int yprev;
+
+ yprev = spans[0].y;
+ i = 1;
+ do
+ { /* while i != numSpans */
+ y = spans[i].y;
+ if (yprev > y)
+ {
+ /* spans[i] is out of order. Move into proper location. */
+ DDXPointRec tpt;
+ int tw, k;
+
+ for (j = 0; y >= spans[j].y; j++) {}
+ tpt = spans[i];
+ tw = widths[i];
+ for (k = i; k != j; k--)
+ {
+ spans[k] = spans[k-1];
+ widths[k] = widths[k-1];
+ }
+ spans[j] = tpt;
+ widths[j] = tw;
+ y = spans[i].y;
+ } /* if out of order */
+ yprev = y;
+ i++;
+ } while (i != numSpans);
+ return;
+ }
+
+ /* Choose partition element, stick in location 0 */
+ m = numSpans / 2;
+ if (spans[m].y > spans[0].y) ExchangeSpans(m, 0);
+ if (spans[m].y > spans[numSpans-1].y) ExchangeSpans(m, numSpans-1);
+ if (spans[m].y > spans[0].y) ExchangeSpans(m, 0);
+ y = spans[0].y;
+
+ /* Partition array */
+ i = 0;
+ j = numSpans;
+ do
+ {
+ r = &(spans[i]);
+ do
+ {
+ r++;
+ i++;
+ } while (i != numSpans && r->y < y);
+ r = &(spans[j]);
+ do
+ {
+ r--;
+ j--;
+ } while (y < r->y);
+ if (i < j)
+ ExchangeSpans(i, j);
+ } while (i < j);
+
+ /* Move partition element back to middle */
+ ExchangeSpans(0, j);
+
+ /* Recurse */
+ if (numSpans-j-1 > 1)
+ QuickSortSpans(&spans[j+1], &widths[j+1], numSpans-j-1);
+ numSpans = j;
+ } while (numSpans > 1);
+}
+
+#define NextBand() \
+{ \
+ clipy1 = pboxBandStart->y1; \
+ clipy2 = pboxBandStart->y2; \
+ pboxBandEnd = pboxBandStart + 1; \
+ while (pboxBandEnd != pboxLast && pboxBandEnd->y1 == clipy1) { \
+ pboxBandEnd++; \
+ } \
+ for (; ppt != pptLast && ppt->y < clipy1; ppt++, pwidth++) {} \
+}
+
+/*
+ Clip a list of scanlines to a region. The caller has allocated the
+ space. FSorted is non-zero if the scanline origins are in ascending
+ order.
+ returns the number of new, clipped scanlines.
+*/
+
+int
+miClipSpans(
+ RegionPtr prgnDst,
+ register DDXPointPtr ppt,
+ register int *pwidth,
+ int nspans,
+ register DDXPointPtr pptNew,
+ int *pwidthNew,
+ int fSorted)
+{
+ register DDXPointPtr pptLast;
+ int *pwidthNewStart; /* the vengeance of Xerox! */
+ register int y, x1, x2;
+ register int numRects;
+
+ good(prgnDst);
+ pptLast = ppt + nspans;
+ pwidthNewStart = pwidthNew;
+
+ if (!prgnDst->data)
+ {
+ /* Do special fast code with clip boundaries in registers(?) */
+ /* It doesn't pay much to make use of fSorted in this case,
+ so we lump everything together. */
+
+ register int clipx1, clipx2, clipy1, clipy2;
+
+ clipx1 = prgnDst->extents.x1;
+ clipy1 = prgnDst->extents.y1;
+ clipx2 = prgnDst->extents.x2;
+ clipy2 = prgnDst->extents.y2;
+
+ for (; ppt != pptLast; ppt++, pwidth++)
+ {
+ y = ppt->y;
+ x1 = ppt->x;
+ if (clipy1 <= y && y < clipy2)
+ {
+ x2 = x1 + *pwidth;
+ if (x1 < clipx1) x1 = clipx1;
+ if (x2 > clipx2) x2 = clipx2;
+ if (x1 < x2)
+ {
+ /* part of span in clip rectangle */
+ pptNew->x = x1;
+ pptNew->y = y;
+ *pwidthNew = x2 - x1;
+ pptNew++;
+ pwidthNew++;
+ }
+ }
+ } /* end for */
+
+ }
+ else if ((numRects = prgnDst->data->numRects))
+ {
+ /* Have to clip against many boxes */
+ BoxPtr pboxBandStart, pboxBandEnd;
+ register BoxPtr pbox;
+ register BoxPtr pboxLast;
+ register int clipy1, clipy2;
+
+ /* In this case, taking advantage of sorted spans gains more than
+ the sorting costs. */
+ if ((! fSorted) && (nspans > 1))
+ QuickSortSpans(ppt, pwidth, nspans);
+
+ pboxBandStart = REGION_BOXPTR(prgnDst);
+ pboxLast = pboxBandStart + numRects;
+
+ NextBand();
+
+ for (; ppt != pptLast; )
+ {
+ y = ppt->y;
+ if (y < clipy2)
+ {
+ /* span is in the current band */
+ pbox = pboxBandStart;
+ x1 = ppt->x;
+ x2 = x1 + *pwidth;
+ do
+ { /* For each box in band */
+ register int newx1, newx2;
+
+ newx1 = x1;
+ newx2 = x2;
+ if (newx1 < pbox->x1) newx1 = pbox->x1;
+ if (newx2 > pbox->x2) newx2 = pbox->x2;
+ if (newx1 < newx2)
+ {
+ /* Part of span in clip rectangle */
+ pptNew->x = newx1;
+ pptNew->y = y;
+ *pwidthNew = newx2 - newx1;
+ pptNew++;
+ pwidthNew++;
+ }
+ pbox++;
+ } while (pbox != pboxBandEnd);
+ ppt++;
+ pwidth++;
+ }
+ else
+ {
+ /* Move to next band, adjust ppt as needed */
+ pboxBandStart = pboxBandEnd;
+ if (pboxBandStart == pboxLast)
+ break; /* We're completely done */
+ NextBand();
+ }
+ }
+ }
+ return (pwidthNew - pwidthNewStart);
+}
+
+/* find the band in a region with the most rectangles */
+int
+miFindMaxBand(prgn)
+ RegionPtr prgn;
+{
+ register int nbox;
+ register BoxPtr pbox;
+ register int nThisBand;
+ register int nMaxBand = 0;
+ short yThisBand;
+
+ good(prgn);
+ nbox = REGION_NUM_RECTS(prgn);
+ pbox = REGION_RECTS(prgn);
+
+ while(nbox > 0)
+ {
+ yThisBand = pbox->y1;
+ nThisBand = 0;
+ while((nbox > 0) && (pbox->y1 == yThisBand))
+ {
+ nbox--;
+ pbox++;
+ nThisBand++;
+ }
+ if (nThisBand > nMaxBand)
+ nMaxBand = nThisBand;
+ }
+ return (nMaxBand);
+}
diff --git a/nx-X11/programs/Xserver/mi/miscanfill.h b/nx-X11/programs/Xserver/mi/miscanfill.h
new file mode 100644
index 000000000..49058c1c9
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/miscanfill.h
@@ -0,0 +1,148 @@
+/* $Xorg: miscanfill.h,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef SCANFILLINCLUDED
+#define SCANFILLINCLUDED
+/*
+ * scanfill.h
+ *
+ * Written by Brian Kelleher; Jan 1985
+ *
+ * This file contains a few macros to help track
+ * the edge of a filled object. The object is assumed
+ * to be filled in scanline order, and thus the
+ * algorithm used is an extension of Bresenham's line
+ * drawing algorithm which assumes that y is always the
+ * major axis.
+ * Since these pieces of code are the same for any filled shape,
+ * it is more convenient to gather the library in one
+ * place, but since these pieces of code are also in
+ * the inner loops of output primitives, procedure call
+ * overhead is out of the question.
+ * See the author for a derivation if needed.
+ */
+
+
+/*
+ * In scan converting polygons, we want to choose those pixels
+ * which are inside the polygon. Thus, we add .5 to the starting
+ * x coordinate for both left and right edges. Now we choose the
+ * first pixel which is inside the pgon for the left edge and the
+ * first pixel which is outside the pgon for the right edge.
+ * Draw the left pixel, but not the right.
+ *
+ * How to add .5 to the starting x coordinate:
+ * If the edge is moving to the right, then subtract dy from the
+ * error term from the general form of the algorithm.
+ * If the edge is moving to the left, then add dy to the error term.
+ *
+ * The reason for the difference between edges moving to the left
+ * and edges moving to the right is simple: If an edge is moving
+ * to the right, then we want the algorithm to flip immediately.
+ * If it is moving to the left, then we don't want it to flip until
+ * we traverse an entire pixel.
+ */
+#define BRESINITPGON(dy, x1, x2, xStart, d, m, m1, incr1, incr2) { \
+ int dx; /* local storage */ \
+\
+ /* \
+ * if the edge is horizontal, then it is ignored \
+ * and assumed not to be processed. Otherwise, do this stuff. \
+ */ \
+ if ((dy) != 0) { \
+ xStart = (x1); \
+ dx = (x2) - xStart; \
+ if (dx < 0) { \
+ m = dx / (dy); \
+ m1 = m - 1; \
+ incr1 = -2 * dx + 2 * (dy) * m1; \
+ incr2 = -2 * dx + 2 * (dy) * m; \
+ d = 2 * m * (dy) - 2 * dx - 2 * (dy); \
+ } else { \
+ m = dx / (dy); \
+ m1 = m + 1; \
+ incr1 = 2 * dx - 2 * (dy) * m1; \
+ incr2 = 2 * dx - 2 * (dy) * m; \
+ d = -2 * m * (dy) + 2 * dx; \
+ } \
+ } \
+}
+
+#define BRESINCRPGON(d, minval, m, m1, incr1, incr2) { \
+ if (m1 > 0) { \
+ if (d > 0) { \
+ minval += m1; \
+ d += incr1; \
+ } \
+ else { \
+ minval += m; \
+ d += incr2; \
+ } \
+ } else {\
+ if (d >= 0) { \
+ minval += m1; \
+ d += incr1; \
+ } \
+ else { \
+ minval += m; \
+ d += incr2; \
+ } \
+ } \
+}
+
+
+/*
+ * This structure contains all of the information needed
+ * to run the bresenham algorithm.
+ * The variables may be hardcoded into the declarations
+ * instead of using this structure to make use of
+ * register declarations.
+ */
+typedef struct {
+ int minor; /* minor axis */
+ int d; /* decision variable */
+ int m, m1; /* slope and slope+1 */
+ int incr1, incr2; /* error increments */
+} BRESINFO;
+
+
+#define BRESINITPGONSTRUCT(dmaj, min1, min2, bres) \
+ BRESINITPGON(dmaj, min1, min2, bres.minor, bres.d, \
+ bres.m, bres.m1, bres.incr1, bres.incr2)
+
+#define BRESINCRPGONSTRUCT(bres) \
+ BRESINCRPGON(bres.d, bres.minor, bres.m, bres.m1, bres.incr1, bres.incr2)
+
+
+#endif
diff --git a/nx-X11/programs/Xserver/mi/miscrinit.c b/nx-X11/programs/Xserver/mi/miscrinit.c
new file mode 100644
index 000000000..ae9b6c2ee
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/miscrinit.c
@@ -0,0 +1,372 @@
+/* $Xorg: miscrinit.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+/*
+
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/mi/miscrinit.c,v 3.15tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "servermd.h"
+#include "misc.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "dix.h"
+#include "miline.h"
+#ifdef MITSHM
+#define _XSHM_SERVER_
+#include <X11/extensions/XShm.h>
+#endif
+
+/* We use this structure to propogate some information from miScreenInit to
+ * miCreateScreenResources. miScreenInit allocates the structure, fills it
+ * in, and puts it into pScreen->devPrivate. miCreateScreenResources
+ * extracts the info and frees the structure. We could've accomplished the
+ * same thing by adding fields to the screen structure, but they would have
+ * ended up being redundant, and would have exposed this mi implementation
+ * detail to the whole server.
+ */
+
+typedef struct
+{
+ pointer pbits; /* pointer to framebuffer */
+ int width; /* delta to add to a framebuffer addr to move one row down */
+} miScreenInitParmsRec, *miScreenInitParmsPtr;
+
+
+/* this plugs into pScreen->ModifyPixmapHeader */
+Bool
+miModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel, devKind,
+ pPixData)
+ PixmapPtr pPixmap;
+ int width;
+ int height;
+ int depth;
+ int bitsPerPixel;
+ int devKind;
+ pointer pPixData;
+{
+ if (!pPixmap)
+ return FALSE;
+
+ /*
+ * If all arguments are specified, reinitialize everything (including
+ * validated state).
+ */
+ if ((width > 0) && (height > 0) && (depth > 0) && (bitsPerPixel > 0) &&
+ (devKind > 0) && pPixData) {
+ pPixmap->drawable.depth = depth;
+ pPixmap->drawable.bitsPerPixel = bitsPerPixel;
+ pPixmap->drawable.id = 0;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pPixmap->drawable.x = 0;
+ pPixmap->drawable.y = 0;
+ pPixmap->drawable.width = width;
+ pPixmap->drawable.height = height;
+ pPixmap->devKind = devKind;
+ pPixmap->refcnt = 1;
+ pPixmap->devPrivate.ptr = pPixData;
+ } else {
+ /*
+ * Only modify specified fields, keeping all others intact.
+ */
+
+ if (width > 0)
+ pPixmap->drawable.width = width;
+
+ if (height > 0)
+ pPixmap->drawable.height = height;
+
+ if (depth > 0)
+ pPixmap->drawable.depth = depth;
+
+ if (bitsPerPixel > 0)
+ pPixmap->drawable.bitsPerPixel = bitsPerPixel;
+ else if ((bitsPerPixel < 0) && (depth > 0))
+ pPixmap->drawable.bitsPerPixel = BitsPerPixel(depth);
+
+ /*
+ * CAVEAT: Non-SI DDXen may use devKind and devPrivate fields for
+ * other purposes.
+ */
+ if (devKind > 0)
+ pPixmap->devKind = devKind;
+ else if ((devKind < 0) && ((width > 0) || (depth > 0)))
+ pPixmap->devKind = PixmapBytePad(pPixmap->drawable.width,
+ pPixmap->drawable.depth);
+
+ if (pPixData)
+ pPixmap->devPrivate.ptr = pPixData;
+ }
+ return TRUE;
+}
+
+
+/*ARGSUSED*/
+Bool
+miCloseScreen (iScreen, pScreen)
+ int iScreen;
+ ScreenPtr pScreen;
+{
+ return ((*pScreen->DestroyPixmap)((PixmapPtr)pScreen->devPrivate));
+}
+
+/* With the introduction of pixmap privates, the "screen pixmap" can no
+ * longer be created in miScreenInit, since all the modules that could
+ * possibly ask for pixmap private space have not been initialized at
+ * that time. pScreen->CreateScreenResources is called after all
+ * possible private-requesting modules have been inited; we create the
+ * screen pixmap here.
+ */
+Bool
+miCreateScreenResources(pScreen)
+ ScreenPtr pScreen;
+{
+ miScreenInitParmsPtr pScrInitParms;
+ pointer value;
+
+ pScrInitParms = (miScreenInitParmsPtr)pScreen->devPrivate;
+
+ /* if width is non-zero, pScreen->devPrivate will be a pixmap
+ * else it will just take the value pbits
+ */
+ if (pScrInitParms->width)
+ {
+ PixmapPtr pPixmap;
+
+ /* create a pixmap with no data, then redirect it to point to
+ * the screen
+ */
+ pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, pScreen->rootDepth);
+ if (!pPixmap)
+ return FALSE;
+
+ if (!(*pScreen->ModifyPixmapHeader)(pPixmap, pScreen->width,
+ pScreen->height, pScreen->rootDepth,
+ BitsPerPixel(pScreen->rootDepth),
+ PixmapBytePad(pScrInitParms->width, pScreen->rootDepth),
+ pScrInitParms->pbits))
+ return FALSE;
+ value = (pointer)pPixmap;
+ }
+ else
+ {
+ value = pScrInitParms->pbits;
+ }
+ xfree(pScreen->devPrivate); /* freeing miScreenInitParmsRec */
+ pScreen->devPrivate = value; /* pPixmap or pbits */
+ return TRUE;
+}
+
+Bool
+miScreenDevPrivateInit(pScreen, width, pbits)
+ register ScreenPtr pScreen;
+ int width;
+ pointer pbits;
+{
+ miScreenInitParmsPtr pScrInitParms;
+
+ /* Stash pbits and width in a short-lived miScreenInitParmsRec attached
+ * to the screen, until CreateScreenResources can put them in the
+ * screen pixmap.
+ */
+ pScrInitParms = (miScreenInitParmsPtr)xalloc(sizeof(miScreenInitParmsRec));
+ if (!pScrInitParms)
+ return FALSE;
+ pScrInitParms->pbits = pbits;
+ pScrInitParms->width = width;
+ pScreen->devPrivate = (pointer)pScrInitParms;
+ return TRUE;
+}
+
+Bool
+miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
+ rootDepth, numDepths, depths, rootVisual, numVisuals, visuals)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bits */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int rootDepth; /* depth of root window */
+ int numDepths; /* number of depths supported */
+ DepthRec *depths; /* supported depths */
+ VisualID rootVisual; /* root visual */
+ int numVisuals; /* number of visuals supported */
+ VisualRec *visuals; /* supported visuals */
+{
+ pScreen->width = xsize;
+ pScreen->height = ysize;
+ pScreen->mmWidth = (xsize * 254 + dpix * 5) / (dpix * 10);
+ pScreen->mmHeight = (ysize * 254 + dpiy * 5) / (dpiy * 10);
+ pScreen->numDepths = numDepths;
+ pScreen->rootDepth = rootDepth;
+ pScreen->allowedDepths = depths;
+ pScreen->rootVisual = rootVisual;
+ /* defColormap */
+ pScreen->minInstalledCmaps = 1;
+ pScreen->maxInstalledCmaps = 1;
+ pScreen->backingStoreSupport = NotUseful;
+ pScreen->saveUnderSupport = NotUseful;
+ /* whitePixel, blackPixel */
+ pScreen->ModifyPixmapHeader = miModifyPixmapHeader;
+ pScreen->CreateScreenResources = miCreateScreenResources;
+ pScreen->GetScreenPixmap = miGetScreenPixmap;
+ pScreen->SetScreenPixmap = miSetScreenPixmap;
+ pScreen->numVisuals = numVisuals;
+ pScreen->visuals = visuals;
+ if (width)
+ {
+#ifdef MITSHM
+ ShmRegisterFbFuncs(pScreen);
+#endif
+ pScreen->CloseScreen = miCloseScreen;
+ }
+ /* else CloseScreen */
+ /* QueryBestSize, SaveScreen, GetImage, GetSpans */
+ pScreen->PointerNonInterestBox = (PointerNonInterestBoxProcPtr) 0;
+ pScreen->SourceValidate = (SourceValidateProcPtr) 0;
+ /* CreateWindow, DestroyWindow, PositionWindow, ChangeWindowAttributes */
+ /* RealizeWindow, UnrealizeWindow */
+ pScreen->ValidateTree = miValidateTree;
+ pScreen->PostValidateTree = (PostValidateTreeProcPtr) 0;
+ pScreen->WindowExposures = miWindowExposures;
+ /* PaintWindowBackground, PaintWindowBorder, CopyWindow */
+ pScreen->ClearToBackground = miClearToBackground;
+ pScreen->ClipNotify = (ClipNotifyProcPtr) 0;
+ pScreen->RestackWindow = (RestackWindowProcPtr) 0;
+ /* CreatePixmap, DestroyPixmap */
+ /* RealizeFont, UnrealizeFont */
+ /* CreateGC */
+ /* CreateColormap, DestroyColormap, InstallColormap, UninstallColormap */
+ /* ListInstalledColormaps, StoreColors, ResolveColor */
+#ifdef NEED_SCREEN_REGIONS
+ pScreen->RegionCreate = miRegionCreate;
+ pScreen->RegionInit = miRegionInit;
+ pScreen->RegionCopy = miRegionCopy;
+ pScreen->RegionDestroy = miRegionDestroy;
+ pScreen->RegionUninit = miRegionUninit;
+ pScreen->Intersect = miIntersect;
+ pScreen->Union = miUnion;
+ pScreen->Subtract = miSubtract;
+ pScreen->Inverse = miInverse;
+ pScreen->RegionReset = miRegionReset;
+ pScreen->TranslateRegion = miTranslateRegion;
+ pScreen->RectIn = miRectIn;
+ pScreen->PointInRegion = miPointInRegion;
+ pScreen->RegionNotEmpty = miRegionNotEmpty;
+ pScreen->RegionEqual = miRegionEqual;
+ pScreen->RegionBroken = miRegionBroken;
+ pScreen->RegionBreak = miRegionBreak;
+ pScreen->RegionEmpty = miRegionEmpty;
+ pScreen->RegionExtents = miRegionExtents;
+ pScreen->RegionAppend = miRegionAppend;
+ pScreen->RegionValidate = miRegionValidate;
+#endif /* NEED_SCREEN_REGIONS */
+ /* BitmapToRegion */
+#ifdef NEED_SCREEN_REGIONS
+ pScreen->RectsToRegion = miRectsToRegion;
+#endif /* NEED_SCREEN_REGIONS */
+ pScreen->SendGraphicsExpose = miSendGraphicsExpose;
+ pScreen->BlockHandler = (ScreenBlockHandlerProcPtr)NoopDDA;
+ pScreen->WakeupHandler = (ScreenWakeupHandlerProcPtr)NoopDDA;
+ pScreen->blockData = (pointer)0;
+ pScreen->wakeupData = (pointer)0;
+ pScreen->MarkWindow = miMarkWindow;
+ pScreen->MarkOverlappedWindows = miMarkOverlappedWindows;
+ pScreen->ChangeSaveUnder = miChangeSaveUnder;
+ pScreen->PostChangeSaveUnder = miPostChangeSaveUnder;
+ pScreen->MoveWindow = miMoveWindow;
+ pScreen->ResizeWindow = miSlideAndSizeWindow;
+ pScreen->GetLayerWindow = miGetLayerWindow;
+ pScreen->HandleExposures = miHandleValidateExposures;
+ pScreen->ReparentWindow = (ReparentWindowProcPtr) 0;
+ pScreen->ChangeBorderWidth = miChangeBorderWidth;
+#ifdef SHAPE
+ pScreen->SetShape = miSetShape;
+#endif
+ pScreen->MarkUnrealizedWindow = miMarkUnrealizedWindow;
+
+ pScreen->SaveDoomedAreas = 0;
+ pScreen->RestoreAreas = 0;
+ pScreen->ExposeCopy = 0;
+ pScreen->TranslateBackingStore = 0;
+ pScreen->ClearBackingStore = 0;
+ pScreen->DrawGuarantee = 0;
+
+ miSetZeroLineBias(pScreen, DEFAULTZEROLINEBIAS);
+
+ return miScreenDevPrivateInit(pScreen, width, pbits);
+}
+
+int
+miAllocateGCPrivateIndex()
+{
+ static int privateIndex = -1;
+ static unsigned long miGeneration = 0;
+
+ if (miGeneration != serverGeneration)
+ {
+ privateIndex = AllocateGCPrivateIndex();
+ miGeneration = serverGeneration;
+ }
+ return privateIndex;
+}
+
+int miZeroLineScreenIndex;
+unsigned int miZeroLineGeneration = 0;
+
+void
+miSetZeroLineBias(pScreen, bias)
+ ScreenPtr pScreen;
+ unsigned int bias;
+{
+ if (miZeroLineGeneration != serverGeneration)
+ {
+ miZeroLineScreenIndex = AllocateScreenPrivateIndex();
+ miZeroLineGeneration = serverGeneration;
+ }
+ if (miZeroLineScreenIndex >= 0)
+ pScreen->devPrivates[miZeroLineScreenIndex].uval = bias;
+}
+
+PixmapPtr
+miGetScreenPixmap(pScreen)
+ ScreenPtr pScreen;
+{
+ return (PixmapPtr)(pScreen->devPrivate);
+}
+
+void
+miSetScreenPixmap(pPix)
+ PixmapPtr pPix;
+{
+ if (pPix)
+ pPix->drawable.pScreen->devPrivate = (pointer)pPix;
+}
diff --git a/nx-X11/programs/Xserver/mi/mispans.c b/nx-X11/programs/Xserver/mi/mispans.c
new file mode 100644
index 000000000..48252f323
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mispans.c
@@ -0,0 +1,563 @@
+/* $XFree86: xc/programs/Xserver/mi/mispans.c,v 3.3 2001/08/06 20:51:20 dawes Exp $ */
+/***********************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* $Xorg: mispans.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "misc.h"
+#include "pixmapstr.h"
+#include "gcstruct.h"
+#include "mispans.h"
+
+/*
+
+These routines maintain lists of Spans, in order to implement the
+``touch-each-pixel-once'' rules of wide lines and arcs.
+
+Written by Joel McCormack, Summer 1989.
+
+*/
+
+
+void miInitSpanGroup(spanGroup)
+ SpanGroup *spanGroup;
+{
+ spanGroup->size = 0;
+ spanGroup->count = 0;
+ spanGroup->group = NULL;
+ spanGroup->ymin = MAXSHORT;
+ spanGroup->ymax = MINSHORT;
+} /* InitSpanGroup */
+
+#define YMIN(spans) (spans->points[0].y)
+#define YMAX(spans) (spans->points[spans->count-1].y)
+
+void miSubtractSpans (spanGroup, sub)
+ SpanGroup *spanGroup;
+ Spans *sub;
+{
+ int i, subCount, spansCount;
+ int ymin, ymax, xmin, xmax;
+ Spans *spans;
+ DDXPointPtr subPt, spansPt;
+ int *subWid, *spansWid;
+ int extra;
+
+ ymin = YMIN(sub);
+ ymax = YMAX(sub);
+ spans = spanGroup->group;
+ for (i = spanGroup->count; i; i--, spans++) {
+ if (YMIN(spans) <= ymax && ymin <= YMAX(spans)) {
+ subCount = sub->count;
+ subPt = sub->points;
+ subWid = sub->widths;
+ spansCount = spans->count;
+ spansPt = spans->points;
+ spansWid = spans->widths;
+ extra = 0;
+ for (;;)
+ {
+ while (spansCount && spansPt->y < subPt->y)
+ {
+ spansPt++; spansWid++; spansCount--;
+ }
+ if (!spansCount)
+ break;
+ while (subCount && subPt->y < spansPt->y)
+ {
+ subPt++; subWid++; subCount--;
+ }
+ if (!subCount)
+ break;
+ if (subPt->y == spansPt->y)
+ {
+ xmin = subPt->x;
+ xmax = xmin + *subWid;
+ if (xmin >= spansPt->x + *spansWid || spansPt->x >= xmax)
+ {
+ ;
+ }
+ else if (xmin <= spansPt->x)
+ {
+ if (xmax >= spansPt->x + *spansWid)
+ {
+ memmove (spansPt, spansPt + 1, sizeof *spansPt * (spansCount - 1));
+ memmove (spansWid, spansWid + 1, sizeof *spansWid * (spansCount - 1));
+ spansPt--;
+ spansWid--;
+ spans->count--;
+ extra++;
+ }
+ else
+ {
+ *spansWid = *spansWid - (xmax - spansPt->x);
+ spansPt->x = xmax;
+ }
+ }
+ else
+ {
+ if (xmax >= spansPt->x + *spansWid)
+ {
+ *spansWid = xmin - spansPt->x;
+ }
+ else
+ {
+ if (!extra) {
+ DDXPointPtr newPt;
+ int *newwid;
+
+#define EXTRA 8
+ newPt = (DDXPointPtr) xrealloc (spans->points, (spans->count + EXTRA) * sizeof (DDXPointRec));
+ if (!newPt)
+ break;
+ spansPt = newPt + (spansPt - spans->points);
+ spans->points = newPt;
+ newwid = (int *) xrealloc (spans->widths, (spans->count + EXTRA) * sizeof (int));
+ if (!newwid)
+ break;
+ spansWid = newwid + (spansWid - spans->widths);
+ spans->widths = newwid;
+ extra = EXTRA;
+ }
+ memmove (spansPt + 1, spansPt, sizeof *spansPt * (spansCount));
+ memmove (spansWid + 1, spansWid, sizeof *spansWid * (spansCount));
+ spans->count++;
+ extra--;
+ *spansWid = xmin - spansPt->x;
+ spansWid++;
+ spansPt++;
+ *spansWid = *spansWid - (xmax - spansPt->x);
+ spansPt->x = xmax;
+ }
+ }
+ }
+ spansPt++; spansWid++; spansCount--;
+ }
+ }
+ }
+}
+
+void miAppendSpans(spanGroup, otherGroup, spans)
+ SpanGroup *spanGroup;
+ SpanGroup *otherGroup;
+ Spans *spans;
+{
+ register int ymin, ymax;
+ register int spansCount;
+
+ spansCount = spans->count;
+ if (spansCount > 0) {
+ if (spanGroup->size == spanGroup->count) {
+ spanGroup->size = (spanGroup->size + 8) * 2;
+ spanGroup->group = (Spans *)
+ xrealloc(spanGroup->group, sizeof(Spans) * spanGroup->size);
+ }
+
+ spanGroup->group[spanGroup->count] = *spans;
+ (spanGroup->count)++;
+ ymin = spans->points[0].y;
+ if (ymin < spanGroup->ymin) spanGroup->ymin = ymin;
+ ymax = spans->points[spansCount - 1].y;
+ if (ymax > spanGroup->ymax) spanGroup->ymax = ymax;
+ if (otherGroup &&
+ otherGroup->ymin < ymax &&
+ ymin < otherGroup->ymax)
+ {
+ miSubtractSpans (otherGroup, spans);
+ }
+ }
+ else
+ {
+ xfree (spans->points);
+ xfree (spans->widths);
+ }
+} /* AppendSpans */
+
+void miFreeSpanGroup(spanGroup)
+ SpanGroup *spanGroup;
+{
+ if (spanGroup->group != NULL) xfree(spanGroup->group);
+}
+
+static void QuickSortSpansX(
+ register DDXPointRec points[],
+ register int widths[],
+ register int numSpans )
+{
+ register int x;
+ register int i, j, m;
+ register DDXPointPtr r;
+
+/* Always called with numSpans > 1 */
+/* Sorts only by x, as all y should be the same */
+
+#define ExchangeSpans(a, b) \
+{ \
+ DDXPointRec tpt; \
+ register int tw; \
+ \
+ tpt = points[a]; points[a] = points[b]; points[b] = tpt; \
+ tw = widths[a]; widths[a] = widths[b]; widths[b] = tw; \
+}
+
+ do {
+ if (numSpans < 9) {
+ /* Do insertion sort */
+ register int xprev;
+
+ xprev = points[0].x;
+ i = 1;
+ do { /* while i != numSpans */
+ x = points[i].x;
+ if (xprev > x) {
+ /* points[i] is out of order. Move into proper location. */
+ DDXPointRec tpt;
+ int tw, k;
+
+ for (j = 0; x >= points[j].x; j++) {}
+ tpt = points[i];
+ tw = widths[i];
+ for (k = i; k != j; k--) {
+ points[k] = points[k-1];
+ widths[k] = widths[k-1];
+ }
+ points[j] = tpt;
+ widths[j] = tw;
+ x = points[i].x;
+ } /* if out of order */
+ xprev = x;
+ i++;
+ } while (i != numSpans);
+ return;
+ }
+
+ /* Choose partition element, stick in location 0 */
+ m = numSpans / 2;
+ if (points[m].x > points[0].x) ExchangeSpans(m, 0);
+ if (points[m].x > points[numSpans-1].x) ExchangeSpans(m, numSpans-1);
+ if (points[m].x > points[0].x) ExchangeSpans(m, 0);
+ x = points[0].x;
+
+ /* Partition array */
+ i = 0;
+ j = numSpans;
+ do {
+ r = &(points[i]);
+ do {
+ r++;
+ i++;
+ } while (i != numSpans && r->x < x);
+ r = &(points[j]);
+ do {
+ r--;
+ j--;
+ } while (x < r->x);
+ if (i < j) ExchangeSpans(i, j);
+ } while (i < j);
+
+ /* Move partition element back to middle */
+ ExchangeSpans(0, j);
+
+ /* Recurse */
+ if (numSpans-j-1 > 1)
+ QuickSortSpansX(&points[j+1], &widths[j+1], numSpans-j-1);
+ numSpans = j;
+ } while (numSpans > 1);
+} /* QuickSortSpans */
+
+
+static int UniquifySpansX(
+ Spans *spans,
+ register DDXPointRec *newPoints,
+ register int *newWidths )
+{
+ register int newx1, newx2, oldpt, i, y;
+ register DDXPointRec *oldPoints;
+ register int *oldWidths;
+ int *startNewWidths;
+
+/* Always called with numSpans > 1 */
+/* Uniquify the spans, and stash them into newPoints and newWidths. Return the
+ number of unique spans. */
+
+
+ startNewWidths = newWidths;
+
+ oldPoints = spans->points;
+ oldWidths = spans->widths;
+
+ y = oldPoints->y;
+ newx1 = oldPoints->x;
+ newx2 = newx1 + *oldWidths;
+
+ for (i = spans->count-1; i != 0; i--) {
+ oldPoints++;
+ oldWidths++;
+ oldpt = oldPoints->x;
+ if (oldpt > newx2) {
+ /* Write current span, start a new one */
+ newPoints->x = newx1;
+ newPoints->y = y;
+ *newWidths = newx2 - newx1;
+ newPoints++;
+ newWidths++;
+ newx1 = oldpt;
+ newx2 = oldpt + *oldWidths;
+ } else {
+ /* extend current span, if old extends beyond new */
+ oldpt = oldpt + *oldWidths;
+ if (oldpt > newx2) newx2 = oldpt;
+ }
+ } /* for */
+
+ /* Write final span */
+ newPoints->x = newx1;
+ *newWidths = newx2 - newx1;
+ newPoints->y = y;
+
+ return (newWidths - startNewWidths) + 1;
+} /* UniquifySpansX */
+
+void
+miDisposeSpanGroup (spanGroup)
+ SpanGroup *spanGroup;
+{
+ int i;
+ Spans *spans;
+
+ for (i = 0; i < spanGroup->count; i++)
+ {
+ spans = spanGroup->group + i;
+ xfree (spans->points);
+ xfree (spans->widths);
+ }
+}
+
+void miFillUniqueSpanGroup(pDraw, pGC, spanGroup)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ SpanGroup *spanGroup;
+{
+ register int i;
+ register Spans *spans;
+ register Spans *yspans;
+ register int *ysizes;
+ register int ymin, ylength;
+
+ /* Outgoing spans for one big call to FillSpans */
+ register DDXPointPtr points;
+ register int *widths;
+ register int count;
+
+ if (spanGroup->count == 0) return;
+
+ if (spanGroup->count == 1) {
+ /* Already should be sorted, unique */
+ spans = spanGroup->group;
+ (*pGC->ops->FillSpans)
+ (pDraw, pGC, spans->count, spans->points, spans->widths, TRUE);
+ xfree(spans->points);
+ xfree(spans->widths);
+ }
+ else
+ {
+ /* Yuck. Gross. Radix sort into y buckets, then sort x and uniquify */
+ /* This seems to be the fastest thing to do. I've tried sorting on
+ both x and y at the same time rather than creating into all those
+ y buckets, but it was somewhat slower. */
+
+ ymin = spanGroup->ymin;
+ ylength = spanGroup->ymax - ymin + 1;
+
+ /* Allocate Spans for y buckets */
+ yspans = (Spans *) xalloc(ylength * sizeof(Spans));
+ ysizes = (int *) xalloc(ylength * sizeof (int));
+
+ if (!yspans || !ysizes)
+ {
+ if (yspans)
+ xfree (yspans);
+ if (ysizes)
+ xfree (ysizes);
+ miDisposeSpanGroup (spanGroup);
+ return;
+ }
+
+ for (i = 0; i != ylength; i++) {
+ ysizes[i] = 0;
+ yspans[i].count = 0;
+ yspans[i].points = NULL;
+ yspans[i].widths = NULL;
+ }
+
+ /* Go through every single span and put it into the correct bucket */
+ count = 0;
+ for (i = 0, spans = spanGroup->group;
+ i != spanGroup->count;
+ i++, spans++) {
+ int index;
+ int j;
+
+ for (j = 0, points = spans->points, widths = spans->widths;
+ j != spans->count;
+ j++, points++, widths++) {
+ index = points->y - ymin;
+ if (index >= 0 && index < ylength) {
+ Spans *newspans = &(yspans[index]);
+ if (newspans->count == ysizes[index]) {
+ DDXPointPtr newpoints;
+ int *newwidths;
+ ysizes[index] = (ysizes[index] + 8) * 2;
+ newpoints = (DDXPointPtr) xrealloc(
+ newspans->points,
+ ysizes[index] * sizeof(DDXPointRec));
+ newwidths = (int *) xrealloc(
+ newspans->widths,
+ ysizes[index] * sizeof(int));
+ if (!newpoints || !newwidths)
+ {
+ int i;
+
+ for (i = 0; i < ylength; i++)
+ {
+ xfree (yspans[i].points);
+ xfree (yspans[i].widths);
+ }
+ xfree (yspans);
+ xfree (ysizes);
+ miDisposeSpanGroup (spanGroup);
+ return;
+ }
+ newspans->points = newpoints;
+ newspans->widths = newwidths;
+ }
+ newspans->points[newspans->count] = *points;
+ newspans->widths[newspans->count] = *widths;
+ (newspans->count)++;
+ } /* if y value of span in range */
+ } /* for j through spans */
+ count += spans->count;
+ xfree(spans->points);
+ spans->points = NULL;
+ xfree(spans->widths);
+ spans->widths = NULL;
+ } /* for i thorough Spans */
+
+ /* Now sort by x and uniquify each bucket into the final array */
+ points = (DDXPointPtr) xalloc(count * sizeof(DDXPointRec));
+ widths = (int *) xalloc(count * sizeof(int));
+ if (!points || !widths)
+ {
+ int i;
+
+ for (i = 0; i < ylength; i++)
+ {
+ xfree (yspans[i].points);
+ xfree (yspans[i].widths);
+ }
+ xfree (yspans);
+ xfree (ysizes);
+ if (points)
+ xfree (points);
+ if (widths)
+ xfree (widths);
+ return;
+ }
+ count = 0;
+ for (i = 0; i != ylength; i++) {
+ int ycount = yspans[i].count;
+ if (ycount > 0) {
+ if (ycount > 1) {
+ QuickSortSpansX(yspans[i].points, yspans[i].widths, ycount);
+ count += UniquifySpansX
+ (&(yspans[i]), &(points[count]), &(widths[count]));
+ } else {
+ points[count] = yspans[i].points[0];
+ widths[count] = yspans[i].widths[0];
+ count++;
+ }
+ xfree(yspans[i].points);
+ xfree(yspans[i].widths);
+ }
+ }
+
+ (*pGC->ops->FillSpans) (pDraw, pGC, count, points, widths, TRUE);
+ xfree(points);
+ xfree(widths);
+ xfree(yspans);
+ xfree(ysizes); /* use (DE)ALLOCATE_LOCAL for these? */
+ }
+
+ spanGroup->count = 0;
+ spanGroup->ymin = MAXSHORT;
+ spanGroup->ymax = MINSHORT;
+}
+
+
+void miFillSpanGroup(pDraw, pGC, spanGroup)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ SpanGroup *spanGroup;
+{
+ register int i;
+ register Spans *spans;
+
+ for (i = 0, spans = spanGroup->group; i != spanGroup->count; i++, spans++) {
+ (*pGC->ops->FillSpans)
+ (pDraw, pGC, spans->count, spans->points, spans->widths, TRUE);
+ xfree(spans->points);
+ xfree(spans->widths);
+ }
+
+ spanGroup->count = 0;
+ spanGroup->ymin = MAXSHORT;
+ spanGroup->ymax = MINSHORT;
+} /* FillSpanGroup */
diff --git a/nx-X11/programs/Xserver/mi/mispans.h b/nx-X11/programs/Xserver/mi/mispans.h
new file mode 100644
index 000000000..b6e97e2b4
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mispans.h
@@ -0,0 +1,117 @@
+/* $XFree86: xc/programs/Xserver/mi/mispans.h,v 1.2 2001/08/06 20:51:20 dawes Exp $ */
+/***********************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* $Xorg: mispans.h,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
+
+typedef struct {
+ int count; /* number of spans */
+ DDXPointPtr points; /* pointer to list of start points */
+ int *widths; /* pointer to list of widths */
+} Spans;
+
+typedef struct {
+ int size; /* Total number of *Spans allocated */
+ int count; /* Number of *Spans actually in group */
+ Spans *group; /* List of Spans */
+ int ymin, ymax; /* Min, max y values encountered */
+} SpanGroup;
+
+/* Initialize SpanGroup. MUST BE DONE before use. */
+extern void miInitSpanGroup(
+ SpanGroup * /*spanGroup*/
+);
+
+/* Add a Spans to a SpanGroup. The spans MUST BE in y-sorted order */
+extern void miAppendSpans(
+ SpanGroup * /*spanGroup*/,
+ SpanGroup * /*otherGroup*/,
+ Spans * /*spans*/
+);
+
+/* Paint a span group, possibly with some overlap */
+extern void miFillSpanGroup(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ SpanGroup * /*spanGroup*/
+);
+
+/* Paint a span group, insuring that each pixel is painted at most once */
+extern void miFillUniqueSpanGroup(
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ SpanGroup * /*spanGroup*/
+);
+
+/* Free up data in a span group. MUST BE DONE or you'll suffer memory leaks */
+extern void miFreeSpanGroup(
+ SpanGroup * /*spanGroup*/
+);
+
+extern void miSubtractSpans(
+ SpanGroup * /*spanGroup*/,
+ Spans * /*sub*/
+);
+
+extern void miDisposeSpanGroup(
+ SpanGroup * /*spanGroup*/
+);
+
+extern int miClipSpans(
+ RegionPtr /*prgnDst*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ int /*nspans*/,
+ DDXPointPtr /*pptNew*/,
+ int * /*pwidthNew*/,
+ int /*fSorted*/
+);
+
+/* Rops which must use span groups */
+#define miSpansCarefulRop(rop) (((rop) & 0xc) == 0x8 || ((rop) & 0x3) == 0x2)
+#define miSpansEasyRop(rop) (!miSpansCarefulRop(rop))
+
diff --git a/nx-X11/programs/Xserver/mi/misprite.c b/nx-X11/programs/Xserver/mi/misprite.c
new file mode 100644
index 000000000..b76542774
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/misprite.c
@@ -0,0 +1,831 @@
+/*
+ * misprite.c
+ *
+ * machine independent software sprite routines
+ */
+
+/* $Xorg: misprite.c,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+/* $XFree86: xc/programs/Xserver/mi/misprite.c,v 3.10tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+# include <X11/X.h>
+# include <X11/Xproto.h>
+# include "misc.h"
+# include "pixmapstr.h"
+# include "input.h"
+# include "mi.h"
+# include "cursorstr.h"
+# include <X11/fonts/font.h>
+# include "scrnintstr.h"
+# include "colormapst.h"
+# include "windowstr.h"
+# include "gcstruct.h"
+# include "mipointer.h"
+# include "mispritest.h"
+# include "dixfontstr.h"
+# include <X11/fonts/fontstruct.h>
+
+#ifdef RENDER
+# include "mipict.h"
+#endif
+# include "damage.h"
+
+#define SPRITE_DEBUG_ENABLE 0
+#if SPRITE_DEBUG_ENABLE
+#define SPRITE_DEBUG(x) ErrorF x
+#else
+#define SPRITE_DEBUG(x)
+#endif
+
+/*
+ * screen wrappers
+ */
+
+static int miSpriteScreenIndex;
+static unsigned long miSpriteGeneration = 0;
+
+static Bool miSpriteCloseScreen(int i, ScreenPtr pScreen);
+static void miSpriteGetImage(DrawablePtr pDrawable, int sx, int sy,
+ int w, int h, unsigned int format,
+ unsigned long planemask, char *pdstLine);
+static void miSpriteGetSpans(DrawablePtr pDrawable, int wMax,
+ DDXPointPtr ppt, int *pwidth, int nspans,
+ char *pdstStart);
+static void miSpriteSourceValidate(DrawablePtr pDrawable, int x, int y,
+ int width, int height);
+static void miSpriteCopyWindow (WindowPtr pWindow,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc);
+static void miSpriteBlockHandler(int i, pointer blockData,
+ pointer pTimeout,
+ pointer pReadMask);
+static void miSpriteInstallColormap(ColormapPtr pMap);
+static void miSpriteStoreColors(ColormapPtr pMap, int ndef,
+ xColorItem *pdef);
+
+static void miSpriteSaveDoomedAreas(WindowPtr pWin,
+ RegionPtr pObscured, int dx,
+ int dy);
+static void miSpriteComputeSaved(ScreenPtr pScreen);
+
+#define SCREEN_PROLOGUE(pScreen, field)\
+ ((pScreen)->field = \
+ ((miSpriteScreenPtr) (pScreen)->devPrivates[miSpriteScreenIndex].ptr)->field)
+
+#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
+ ((pScreen)->field = wrapper)
+
+/*
+ * pointer-sprite method table
+ */
+
+static Bool miSpriteRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
+static Bool miSpriteUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
+static void miSpriteSetCursor(ScreenPtr pScreen, CursorPtr pCursor,
+ int x, int y);
+static void miSpriteMoveCursor(ScreenPtr pScreen, int x, int y);
+
+miPointerSpriteFuncRec miSpritePointerFuncs = {
+ miSpriteRealizeCursor,
+ miSpriteUnrealizeCursor,
+ miSpriteSetCursor,
+ miSpriteMoveCursor,
+};
+
+/*
+ * other misc functions
+ */
+
+static void miSpriteRemoveCursor(ScreenPtr pScreen);
+static void miSpriteRestoreCursor(ScreenPtr pScreen);
+
+static void
+miSpriteReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
+{
+ ScreenPtr pScreen = closure;
+ miSpriteScreenPtr pScreenPriv;
+
+ pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+
+ if (pScreenPriv->isUp &&
+ RECT_IN_REGION (pScreen, pRegion, &pScreenPriv->saved) != rgnOUT)
+ {
+ SPRITE_DEBUG(("Damage remove\n"));
+ miSpriteRemoveCursor (pScreen);
+ }
+}
+
+/*
+ * miSpriteInitialize -- called from device-dependent screen
+ * initialization proc after all of the function pointers have
+ * been stored in the screen structure.
+ */
+
+Bool
+miSpriteInitialize (pScreen, cursorFuncs, screenFuncs)
+ ScreenPtr pScreen;
+ miSpriteCursorFuncPtr cursorFuncs;
+ miPointerScreenFuncPtr screenFuncs;
+{
+ miSpriteScreenPtr pScreenPriv;
+ VisualPtr pVisual;
+
+ if (!DamageSetup (pScreen))
+ return FALSE;
+
+ if (miSpriteGeneration != serverGeneration)
+ {
+ miSpriteScreenIndex = AllocateScreenPrivateIndex ();
+ if (miSpriteScreenIndex < 0)
+ return FALSE;
+ miSpriteGeneration = serverGeneration;
+ }
+
+ pScreenPriv = (miSpriteScreenPtr) xalloc (sizeof (miSpriteScreenRec));
+ if (!pScreenPriv)
+ return FALSE;
+
+ pScreenPriv->pDamage = DamageCreate (miSpriteReportDamage,
+ (DamageDestroyFunc) 0,
+ DamageReportRawRegion,
+ TRUE,
+ pScreen,
+ (void *) pScreen);
+
+ if (!miPointerInitialize (pScreen, &miSpritePointerFuncs, screenFuncs,TRUE))
+ {
+ xfree ((pointer) pScreenPriv);
+ return FALSE;
+ }
+ for (pVisual = pScreen->visuals;
+ pVisual->vid != pScreen->rootVisual;
+ pVisual++)
+ ;
+ pScreenPriv->pVisual = pVisual;
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreenPriv->GetImage = pScreen->GetImage;
+ pScreenPriv->GetSpans = pScreen->GetSpans;
+ pScreenPriv->SourceValidate = pScreen->SourceValidate;
+
+ pScreenPriv->CopyWindow = pScreen->CopyWindow;
+
+ pScreenPriv->SaveDoomedAreas = pScreen->SaveDoomedAreas;
+
+ pScreenPriv->InstallColormap = pScreen->InstallColormap;
+ pScreenPriv->StoreColors = pScreen->StoreColors;
+
+ pScreenPriv->BlockHandler = pScreen->BlockHandler;
+
+ pScreenPriv->pCursor = NULL;
+ pScreenPriv->x = 0;
+ pScreenPriv->y = 0;
+ pScreenPriv->isUp = FALSE;
+ pScreenPriv->shouldBeUp = FALSE;
+ pScreenPriv->pCacheWin = NullWindow;
+ pScreenPriv->isInCacheWin = FALSE;
+ pScreenPriv->checkPixels = TRUE;
+ pScreenPriv->pInstalledMap = NULL;
+ pScreenPriv->pColormap = NULL;
+ pScreenPriv->funcs = cursorFuncs;
+ pScreenPriv->colors[SOURCE_COLOR].red = 0;
+ pScreenPriv->colors[SOURCE_COLOR].green = 0;
+ pScreenPriv->colors[SOURCE_COLOR].blue = 0;
+ pScreenPriv->colors[MASK_COLOR].red = 0;
+ pScreenPriv->colors[MASK_COLOR].green = 0;
+ pScreenPriv->colors[MASK_COLOR].blue = 0;
+ pScreen->devPrivates[miSpriteScreenIndex].ptr = (pointer) pScreenPriv;
+
+ pScreen->CloseScreen = miSpriteCloseScreen;
+ pScreen->GetImage = miSpriteGetImage;
+ pScreen->GetSpans = miSpriteGetSpans;
+ pScreen->SourceValidate = miSpriteSourceValidate;
+
+ pScreen->CopyWindow = miSpriteCopyWindow;
+
+ pScreen->SaveDoomedAreas = miSpriteSaveDoomedAreas;
+
+ pScreen->InstallColormap = miSpriteInstallColormap;
+ pScreen->StoreColors = miSpriteStoreColors;
+
+ pScreen->BlockHandler = miSpriteBlockHandler;
+
+ return TRUE;
+}
+
+/*
+ * Screen wrappers
+ */
+
+/*
+ * CloseScreen wrapper -- unwrap everything, free the private data
+ * and call the wrapped function
+ */
+
+static Bool
+miSpriteCloseScreen (i, pScreen)
+ int i;
+ ScreenPtr pScreen;
+{
+ miSpriteScreenPtr pScreenPriv;
+
+ pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+ pScreen->GetImage = pScreenPriv->GetImage;
+ pScreen->GetSpans = pScreenPriv->GetSpans;
+ pScreen->SourceValidate = pScreenPriv->SourceValidate;
+ pScreen->BlockHandler = pScreenPriv->BlockHandler;
+ pScreen->InstallColormap = pScreenPriv->InstallColormap;
+ pScreen->StoreColors = pScreenPriv->StoreColors;
+
+ pScreen->SaveDoomedAreas = pScreenPriv->SaveDoomedAreas;
+ miSpriteIsUpFALSE (pScreen, pScreenPriv);
+ DamageDestroy (pScreenPriv->pDamage);
+
+ xfree ((pointer) pScreenPriv);
+
+ return (*pScreen->CloseScreen) (i, pScreen);
+}
+
+static void
+miSpriteGetImage (pDrawable, sx, sy, w, h, format, planemask, pdstLine)
+ DrawablePtr pDrawable;
+ int sx, sy, w, h;
+ unsigned int format;
+ unsigned long planemask;
+ char *pdstLine;
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ miSpriteScreenPtr pScreenPriv;
+
+ SCREEN_PROLOGUE (pScreen, GetImage);
+
+ pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+
+ if (pDrawable->type == DRAWABLE_WINDOW &&
+ pScreenPriv->isUp &&
+ ORG_OVERLAP(&pScreenPriv->saved,pDrawable->x,pDrawable->y, sx, sy, w, h))
+ {
+ SPRITE_DEBUG (("GetImage remove\n"));
+ miSpriteRemoveCursor (pScreen);
+ }
+
+ (*pScreen->GetImage) (pDrawable, sx, sy, w, h,
+ format, planemask, pdstLine);
+
+ SCREEN_EPILOGUE (pScreen, GetImage, miSpriteGetImage);
+}
+
+static void
+miSpriteGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart)
+ DrawablePtr pDrawable;
+ int wMax;
+ DDXPointPtr ppt;
+ int *pwidth;
+ int nspans;
+ char *pdstStart;
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ miSpriteScreenPtr pScreenPriv;
+
+ SCREEN_PROLOGUE (pScreen, GetSpans);
+
+ pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+
+ if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp)
+ {
+ register DDXPointPtr pts;
+ register int *widths;
+ register int nPts;
+ register int xorg,
+ yorg;
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+
+ for (pts = ppt, widths = pwidth, nPts = nspans;
+ nPts--;
+ pts++, widths++)
+ {
+ if (SPN_OVERLAP(&pScreenPriv->saved,pts->y+yorg,
+ pts->x+xorg,*widths))
+ {
+ SPRITE_DEBUG (("GetSpans remove\n"));
+ miSpriteRemoveCursor (pScreen);
+ break;
+ }
+ }
+ }
+
+ (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+
+ SCREEN_EPILOGUE (pScreen, GetSpans, miSpriteGetSpans);
+}
+
+static void
+miSpriteSourceValidate (pDrawable, x, y, width, height)
+ DrawablePtr pDrawable;
+ int x, y, width, height;
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ miSpriteScreenPtr pScreenPriv;
+
+ SCREEN_PROLOGUE (pScreen, SourceValidate);
+
+ pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+
+ if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp &&
+ ORG_OVERLAP(&pScreenPriv->saved, pDrawable->x, pDrawable->y,
+ x, y, width, height))
+ {
+ SPRITE_DEBUG (("SourceValidate remove\n"));
+ miSpriteRemoveCursor (pScreen);
+ }
+
+ if (pScreen->SourceValidate)
+ (*pScreen->SourceValidate) (pDrawable, x, y, width, height);
+
+ SCREEN_EPILOGUE (pScreen, SourceValidate, miSpriteSourceValidate);
+}
+
+static void
+miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ miSpriteScreenPtr pScreenPriv;
+
+ SCREEN_PROLOGUE (pScreen, CopyWindow);
+
+ pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ /*
+ * Damage will take care of destination check
+ */
+ if (pScreenPriv->isUp &&
+ RECT_IN_REGION (pScreen, prgnSrc, &pScreenPriv->saved) != rgnOUT)
+ {
+ SPRITE_DEBUG (("CopyWindow remove\n"));
+ miSpriteRemoveCursor (pScreen);
+ }
+
+ (*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc);
+ SCREEN_EPILOGUE (pScreen, CopyWindow, miSpriteCopyWindow);
+}
+
+static void
+miSpriteBlockHandler (i, blockData, pTimeout, pReadmask)
+ int i;
+ pointer blockData;
+ pointer pTimeout;
+ pointer pReadmask;
+{
+ ScreenPtr pScreen = screenInfo.screens[i];
+ miSpriteScreenPtr pPriv;
+
+ pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+
+ SCREEN_PROLOGUE(pScreen, BlockHandler);
+
+ (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
+
+ SCREEN_EPILOGUE(pScreen, BlockHandler, miSpriteBlockHandler);
+
+ if (!pPriv->isUp && pPriv->shouldBeUp)
+ {
+ SPRITE_DEBUG (("BlockHandler restore\n"));
+ miSpriteRestoreCursor (pScreen);
+ }
+}
+
+static void
+miSpriteInstallColormap (pMap)
+ ColormapPtr pMap;
+{
+ ScreenPtr pScreen = pMap->pScreen;
+ miSpriteScreenPtr pPriv;
+
+ pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+
+ SCREEN_PROLOGUE(pScreen, InstallColormap);
+
+ (*pScreen->InstallColormap) (pMap);
+
+ SCREEN_EPILOGUE(pScreen, InstallColormap, miSpriteInstallColormap);
+
+ pPriv->pInstalledMap = pMap;
+ if (pPriv->pColormap != pMap)
+ {
+ pPriv->checkPixels = TRUE;
+ if (pPriv->isUp)
+ miSpriteRemoveCursor (pScreen);
+ }
+}
+
+static void
+miSpriteStoreColors (pMap, ndef, pdef)
+ ColormapPtr pMap;
+ int ndef;
+ xColorItem *pdef;
+{
+ ScreenPtr pScreen = pMap->pScreen;
+ miSpriteScreenPtr pPriv;
+ int i;
+ int updated;
+ VisualPtr pVisual;
+
+ pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+
+ SCREEN_PROLOGUE(pScreen, StoreColors);
+
+ (*pScreen->StoreColors) (pMap, ndef, pdef);
+
+ SCREEN_EPILOGUE(pScreen, StoreColors, miSpriteStoreColors);
+
+ if (pPriv->pColormap == pMap)
+ {
+ updated = 0;
+ pVisual = pMap->pVisual;
+ if (pVisual->class == DirectColor)
+ {
+ /* Direct color - match on any of the subfields */
+
+#define MaskMatch(a,b,mask) (((a) & (pVisual->mask)) == ((b) & (pVisual->mask)))
+
+#define UpdateDAC(plane,dac,mask) {\
+ if (MaskMatch (pPriv->colors[plane].pixel,pdef[i].pixel,mask)) {\
+ pPriv->colors[plane].dac = pdef[i].dac; \
+ updated = 1; \
+ } \
+}
+
+#define CheckDirect(plane) \
+ UpdateDAC(plane,red,redMask) \
+ UpdateDAC(plane,green,greenMask) \
+ UpdateDAC(plane,blue,blueMask)
+
+ for (i = 0; i < ndef; i++)
+ {
+ CheckDirect (SOURCE_COLOR)
+ CheckDirect (MASK_COLOR)
+ }
+ }
+ else
+ {
+ /* PseudoColor/GrayScale - match on exact pixel */
+ for (i = 0; i < ndef; i++)
+ {
+ if (pdef[i].pixel == pPriv->colors[SOURCE_COLOR].pixel)
+ {
+ pPriv->colors[SOURCE_COLOR] = pdef[i];
+ if (++updated == 2)
+ break;
+ }
+ if (pdef[i].pixel == pPriv->colors[MASK_COLOR].pixel)
+ {
+ pPriv->colors[MASK_COLOR] = pdef[i];
+ if (++updated == 2)
+ break;
+ }
+ }
+ }
+ if (updated)
+ {
+ pPriv->checkPixels = TRUE;
+ if (pPriv->isUp)
+ miSpriteRemoveCursor (pScreen);
+ }
+ }
+}
+
+static void
+miSpriteFindColors (ScreenPtr pScreen)
+{
+ miSpriteScreenPtr pScreenPriv = (miSpriteScreenPtr)
+ pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ CursorPtr pCursor;
+ xColorItem *sourceColor, *maskColor;
+
+ pCursor = pScreenPriv->pCursor;
+ sourceColor = &pScreenPriv->colors[SOURCE_COLOR];
+ maskColor = &pScreenPriv->colors[MASK_COLOR];
+ if (pScreenPriv->pColormap != pScreenPriv->pInstalledMap ||
+ !(pCursor->foreRed == sourceColor->red &&
+ pCursor->foreGreen == sourceColor->green &&
+ pCursor->foreBlue == sourceColor->blue &&
+ pCursor->backRed == maskColor->red &&
+ pCursor->backGreen == maskColor->green &&
+ pCursor->backBlue == maskColor->blue))
+ {
+ pScreenPriv->pColormap = pScreenPriv->pInstalledMap;
+ sourceColor->red = pCursor->foreRed;
+ sourceColor->green = pCursor->foreGreen;
+ sourceColor->blue = pCursor->foreBlue;
+ FakeAllocColor (pScreenPriv->pColormap, sourceColor);
+ maskColor->red = pCursor->backRed;
+ maskColor->green = pCursor->backGreen;
+ maskColor->blue = pCursor->backBlue;
+ FakeAllocColor (pScreenPriv->pColormap, maskColor);
+ /* "free" the pixels right away, don't let this confuse you */
+ FakeFreeColor(pScreenPriv->pColormap, sourceColor->pixel);
+ FakeFreeColor(pScreenPriv->pColormap, maskColor->pixel);
+ }
+ pScreenPriv->checkPixels = FALSE;
+}
+
+/*
+ * BackingStore wrappers
+ */
+
+static void
+miSpriteSaveDoomedAreas (pWin, pObscured, dx, dy)
+ WindowPtr pWin;
+ RegionPtr pObscured;
+ int dx, dy;
+{
+ ScreenPtr pScreen;
+ miSpriteScreenPtr pScreenPriv;
+ BoxRec cursorBox;
+
+ pScreen = pWin->drawable.pScreen;
+
+ SCREEN_PROLOGUE (pScreen, SaveDoomedAreas);
+
+ pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ if (pScreenPriv->isUp)
+ {
+ cursorBox = pScreenPriv->saved;
+
+ if (dx || dy)
+ {
+ cursorBox.x1 += dx;
+ cursorBox.y1 += dy;
+ cursorBox.x2 += dx;
+ cursorBox.y2 += dy;
+ }
+ if (RECT_IN_REGION( pScreen, pObscured, &cursorBox) != rgnOUT)
+ miSpriteRemoveCursor (pScreen);
+ }
+
+ (*pScreen->SaveDoomedAreas) (pWin, pObscured, dx, dy);
+
+ SCREEN_EPILOGUE (pScreen, SaveDoomedAreas, miSpriteSaveDoomedAreas);
+}
+
+/*
+ * miPointer interface routines
+ */
+
+#define SPRITE_PAD 8
+
+static Bool
+miSpriteRealizeCursor (pScreen, pCursor)
+ ScreenPtr pScreen;
+ CursorPtr pCursor;
+{
+ miSpriteScreenPtr pScreenPriv;
+
+ pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ if (pCursor == pScreenPriv->pCursor)
+ pScreenPriv->checkPixels = TRUE;
+ return (*pScreenPriv->funcs->RealizeCursor) (pScreen, pCursor);
+}
+
+static Bool
+miSpriteUnrealizeCursor (pScreen, pCursor)
+ ScreenPtr pScreen;
+ CursorPtr pCursor;
+{
+ miSpriteScreenPtr pScreenPriv;
+
+ pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ return (*pScreenPriv->funcs->UnrealizeCursor) (pScreen, pCursor);
+}
+
+static void
+miSpriteSetCursor (pScreen, pCursor, x, y)
+ ScreenPtr pScreen;
+ CursorPtr pCursor;
+ int x;
+ int y;
+{
+ miSpriteScreenPtr pScreenPriv;
+
+ pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ if (!pCursor)
+ {
+ pScreenPriv->shouldBeUp = FALSE;
+ if (pScreenPriv->isUp)
+ miSpriteRemoveCursor (pScreen);
+ pScreenPriv->pCursor = 0;
+ return;
+ }
+ pScreenPriv->shouldBeUp = TRUE;
+ if (pScreenPriv->x == x &&
+ pScreenPriv->y == y &&
+ pScreenPriv->pCursor == pCursor &&
+ !pScreenPriv->checkPixels)
+ {
+ return;
+ }
+ pScreenPriv->x = x;
+ pScreenPriv->y = y;
+ pScreenPriv->pCacheWin = NullWindow;
+ if (pScreenPriv->checkPixels || pScreenPriv->pCursor != pCursor)
+ {
+ pScreenPriv->pCursor = pCursor;
+ miSpriteFindColors (pScreen);
+ }
+ if (pScreenPriv->isUp) {
+ int sx, sy;
+ /*
+ * check to see if the old saved region
+ * encloses the new sprite, in which case we use
+ * the flicker-free MoveCursor primitive.
+ */
+ sx = pScreenPriv->x - (int)pCursor->bits->xhot;
+ sy = pScreenPriv->y - (int)pCursor->bits->yhot;
+ if (sx + (int) pCursor->bits->width >= pScreenPriv->saved.x1 &&
+ sx < pScreenPriv->saved.x2 &&
+ sy + (int) pCursor->bits->height >= pScreenPriv->saved.y1 &&
+ sy < pScreenPriv->saved.y2 &&
+ (int) pCursor->bits->width + (2 * SPRITE_PAD) ==
+ pScreenPriv->saved.x2 - pScreenPriv->saved.x1 &&
+ (int) pCursor->bits->height + (2 * SPRITE_PAD) ==
+ pScreenPriv->saved.y2 - pScreenPriv->saved.y1
+ )
+ {
+ DamageDrawInternal (pScreen, TRUE);
+ miSpriteIsUpFALSE (pScreen, pScreenPriv);
+ if (!(sx >= pScreenPriv->saved.x1 &&
+ sx + (int)pCursor->bits->width < pScreenPriv->saved.x2 &&
+ sy >= pScreenPriv->saved.y1 &&
+ sy + (int)pCursor->bits->height < pScreenPriv->saved.y2))
+ {
+ int oldx1, oldy1, dx, dy;
+
+ oldx1 = pScreenPriv->saved.x1;
+ oldy1 = pScreenPriv->saved.y1;
+ dx = oldx1 - (sx - SPRITE_PAD);
+ dy = oldy1 - (sy - SPRITE_PAD);
+ pScreenPriv->saved.x1 -= dx;
+ pScreenPriv->saved.y1 -= dy;
+ pScreenPriv->saved.x2 -= dx;
+ pScreenPriv->saved.y2 -= dy;
+ (void) (*pScreenPriv->funcs->ChangeSave) (pScreen,
+ pScreenPriv->saved.x1,
+ pScreenPriv->saved.y1,
+ pScreenPriv->saved.x2 - pScreenPriv->saved.x1,
+ pScreenPriv->saved.y2 - pScreenPriv->saved.y1,
+ dx, dy);
+ }
+ (void) (*pScreenPriv->funcs->MoveCursor) (pScreen, pCursor,
+ pScreenPriv->saved.x1,
+ pScreenPriv->saved.y1,
+ pScreenPriv->saved.x2 - pScreenPriv->saved.x1,
+ pScreenPriv->saved.y2 - pScreenPriv->saved.y1,
+ sx - pScreenPriv->saved.x1,
+ sy - pScreenPriv->saved.y1,
+ pScreenPriv->colors[SOURCE_COLOR].pixel,
+ pScreenPriv->colors[MASK_COLOR].pixel);
+ miSpriteIsUpTRUE (pScreen, pScreenPriv);
+ DamageDrawInternal (pScreen, FALSE);
+ }
+ else
+ {
+ SPRITE_DEBUG (("SetCursor remove\n"));
+ miSpriteRemoveCursor (pScreen);
+ }
+ }
+ if (!pScreenPriv->isUp && pScreenPriv->pCursor)
+ {
+ SPRITE_DEBUG (("SetCursor restore\n"));
+ miSpriteRestoreCursor (pScreen);
+ }
+}
+
+static void
+miSpriteMoveCursor (pScreen, x, y)
+ ScreenPtr pScreen;
+ int x, y;
+{
+ miSpriteScreenPtr pScreenPriv;
+
+ pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ miSpriteSetCursor (pScreen, pScreenPriv->pCursor, x, y);
+}
+
+/*
+ * undraw/draw cursor
+ */
+
+static void
+miSpriteRemoveCursor (pScreen)
+ ScreenPtr pScreen;
+{
+ miSpriteScreenPtr pScreenPriv;
+
+ DamageDrawInternal (pScreen, TRUE);
+ pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ miSpriteIsUpFALSE (pScreen, pScreenPriv);
+ pScreenPriv->pCacheWin = NullWindow;
+ if (!(*pScreenPriv->funcs->RestoreUnderCursor) (pScreen,
+ pScreenPriv->saved.x1,
+ pScreenPriv->saved.y1,
+ pScreenPriv->saved.x2 - pScreenPriv->saved.x1,
+ pScreenPriv->saved.y2 - pScreenPriv->saved.y1))
+ {
+ miSpriteIsUpTRUE (pScreen, pScreenPriv);
+ }
+ DamageDrawInternal (pScreen, FALSE);
+}
+
+/*
+ * Called from the block handler, restores the cursor
+ * before waiting for something to do.
+ */
+
+static void
+miSpriteRestoreCursor (pScreen)
+ ScreenPtr pScreen;
+{
+ miSpriteScreenPtr pScreenPriv;
+ int x, y;
+ CursorPtr pCursor;
+
+ DamageDrawInternal (pScreen, TRUE);
+ miSpriteComputeSaved (pScreen);
+ pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pCursor = pScreenPriv->pCursor;
+ x = pScreenPriv->x - (int)pCursor->bits->xhot;
+ y = pScreenPriv->y - (int)pCursor->bits->yhot;
+ if ((*pScreenPriv->funcs->SaveUnderCursor) (pScreen,
+ pScreenPriv->saved.x1,
+ pScreenPriv->saved.y1,
+ pScreenPriv->saved.x2 - pScreenPriv->saved.x1,
+ pScreenPriv->saved.y2 - pScreenPriv->saved.y1))
+ {
+ if (pScreenPriv->checkPixels)
+ miSpriteFindColors (pScreen);
+ if ((*pScreenPriv->funcs->PutUpCursor) (pScreen, pCursor, x, y,
+ pScreenPriv->colors[SOURCE_COLOR].pixel,
+ pScreenPriv->colors[MASK_COLOR].pixel))
+ {
+ miSpriteIsUpTRUE (pScreen, pScreenPriv);
+ }
+ }
+ DamageDrawInternal (pScreen, FALSE);
+}
+
+/*
+ * compute the desired area of the screen to save
+ */
+
+static void
+miSpriteComputeSaved (pScreen)
+ ScreenPtr pScreen;
+{
+ miSpriteScreenPtr pScreenPriv;
+ int x, y, w, h;
+ int wpad, hpad;
+ CursorPtr pCursor;
+
+ pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pCursor = pScreenPriv->pCursor;
+ x = pScreenPriv->x - (int)pCursor->bits->xhot;
+ y = pScreenPriv->y - (int)pCursor->bits->yhot;
+ w = pCursor->bits->width;
+ h = pCursor->bits->height;
+ wpad = SPRITE_PAD;
+ hpad = SPRITE_PAD;
+ pScreenPriv->saved.x1 = x - wpad;
+ pScreenPriv->saved.y1 = y - hpad;
+ pScreenPriv->saved.x2 = pScreenPriv->saved.x1 + w + wpad * 2;
+ pScreenPriv->saved.y2 = pScreenPriv->saved.y1 + h + hpad * 2;
+}
diff --git a/nx-X11/programs/Xserver/mi/misprite.h b/nx-X11/programs/Xserver/mi/misprite.h
new file mode 100644
index 000000000..b4cc84ecf
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/misprite.h
@@ -0,0 +1,96 @@
+/*
+ * misprite.h
+ *
+ * software-sprite/sprite drawing interface spec
+ *
+ * mi versions of these routines exist.
+ */
+
+/* $Xorg: misprite.h,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+/* $XFree86: xc/programs/Xserver/mi/misprite.h,v 1.2 2001/08/06 20:51:20 dawes Exp $ */
+
+typedef struct {
+ Bool (*RealizeCursor)(
+ ScreenPtr /*pScreen*/,
+ CursorPtr /*pCursor*/
+);
+ Bool (*UnrealizeCursor)(
+ ScreenPtr /*pScreen*/,
+ CursorPtr /*pCursor*/
+);
+ Bool (*PutUpCursor)(
+ ScreenPtr /*pScreen*/,
+ CursorPtr /*pCursor*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned long /*source*/,
+ unsigned long /*mask*/
+);
+ Bool (*SaveUnderCursor)(
+ ScreenPtr /*pScreen*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/
+);
+ Bool (*RestoreUnderCursor)(
+ ScreenPtr /*pScreen*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/
+);
+ Bool (*MoveCursor)(
+ ScreenPtr /*pScreen*/,
+ CursorPtr /*pCursor*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ int /*dx*/,
+ int /*dy*/,
+ unsigned long /*source*/,
+ unsigned long /*mask*/
+);
+ Bool (*ChangeSave)(
+ ScreenPtr /*pScreen*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ int /*dx*/,
+ int /*dy*/
+);
+
+} miSpriteCursorFuncRec, *miSpriteCursorFuncPtr;
+
+extern Bool miSpriteInitialize(
+ ScreenPtr /*pScreen*/,
+ miSpriteCursorFuncPtr /*cursorFuncs*/,
+ miPointerScreenFuncPtr /*screenFuncs*/
+);
diff --git a/nx-X11/programs/Xserver/mi/mispritest.h b/nx-X11/programs/Xserver/mi/mispritest.h
new file mode 100644
index 000000000..dca1fa619
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mispritest.h
@@ -0,0 +1,134 @@
+/*
+ * mispritest.h
+ *
+ * mi sprite structures
+ */
+
+/* $Xorg: mispritest.h,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+*/
+/* $XFree86: xc/programs/Xserver/mi/mispritest.h,v 1.4 2001/01/17 22:37:07 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _MISPRITEST_H_
+#define _MISPRITEST_H_
+
+# include "misprite.h"
+#ifdef RENDER
+# include "picturestr.h"
+#endif
+# include "damage.h"
+
+/*
+ * per screen information
+ */
+
+typedef struct {
+ /* screen procedures */
+ CloseScreenProcPtr CloseScreen;
+ GetImageProcPtr GetImage;
+ GetSpansProcPtr GetSpans;
+ SourceValidateProcPtr SourceValidate;
+
+ /* window procedures */
+ CopyWindowProcPtr CopyWindow;
+
+ /* backing store procedures */
+ SaveDoomedAreasProcPtr SaveDoomedAreas;
+
+ /* colormap procedures */
+ InstallColormapProcPtr InstallColormap;
+ StoreColorsProcPtr StoreColors;
+
+ /* os layer procedures */
+ ScreenBlockHandlerProcPtr BlockHandler;
+
+ CursorPtr pCursor;
+ int x; /* cursor hotspot */
+ int y;
+ BoxRec saved; /* saved area from the screen */
+ Bool isUp; /* cursor in frame buffer */
+ Bool shouldBeUp; /* cursor should be displayed */
+ WindowPtr pCacheWin; /* window the cursor last seen in */
+ Bool isInCacheWin;
+ Bool checkPixels; /* check colormap collision */
+ xColorItem colors[2];
+ ColormapPtr pInstalledMap;
+ ColormapPtr pColormap;
+ VisualPtr pVisual;
+ miSpriteCursorFuncPtr funcs;
+ DamagePtr pDamage; /* damage tracking structure */
+} miSpriteScreenRec, *miSpriteScreenPtr;
+
+#define SOURCE_COLOR 0
+#define MASK_COLOR 1
+
+#define miSpriteIsUpTRUE(pScreen, pScreenPriv) if (!pScreenPriv->isUp) { \
+ pScreenPriv->isUp = TRUE; \
+ DamageRegister (&(*pScreen->GetScreenPixmap) (pScreen)->drawable, pScreenPriv->pDamage); \
+}
+
+#define miSpriteIsUpFALSE(pScreen, pScreenPriv) if (pScreenPriv->isUp) { \
+ DamageUnregister (&(*pScreen->GetScreenPixmap) (pScreen)->drawable, pScreenPriv->pDamage); \
+ pScreenPriv->isUp = FALSE; \
+}
+
+/*
+ * Overlap BoxPtr and Box elements
+ */
+#define BOX_OVERLAP(pCbox,X1,Y1,X2,Y2) \
+ (((pCbox)->x1 <= (X2)) && ((X1) <= (pCbox)->x2) && \
+ ((pCbox)->y1 <= (Y2)) && ((Y1) <= (pCbox)->y2))
+
+/*
+ * Overlap BoxPtr, origins, and rectangle
+ */
+#define ORG_OVERLAP(pCbox,xorg,yorg,x,y,w,h) \
+ BOX_OVERLAP((pCbox),(x)+(xorg),(y)+(yorg),(x)+(xorg)+(w),(y)+(yorg)+(h))
+
+/*
+ * Overlap BoxPtr, origins and RectPtr
+ */
+#define ORGRECT_OVERLAP(pCbox,xorg,yorg,pRect) \
+ ORG_OVERLAP((pCbox),(xorg),(yorg),(pRect)->x,(pRect)->y, \
+ (int)((pRect)->width), (int)((pRect)->height))
+/*
+ * Overlap BoxPtr and horizontal span
+ */
+#define SPN_OVERLAP(pCbox,y,x,w) BOX_OVERLAP((pCbox),(x),(y),(x)+(w),(y))
+
+#define LINE_SORT(x1,y1,x2,y2) \
+{ int _t; \
+ if (x1 > x2) { _t = x1; x1 = x2; x2 = _t; } \
+ if (y1 > y2) { _t = y1; y1 = y2; y2 = _t; } }
+
+#define LINE_OVERLAP(pCbox,x1,y1,x2,y2,lw2) \
+ BOX_OVERLAP((pCbox), (x1)-(lw2), (y1)-(lw2), (x2)+(lw2), (y2)+(lw2))
+
+#endif /* _MISPRITEST_H_ */
diff --git a/nx-X11/programs/Xserver/mi/mistruct.h b/nx-X11/programs/Xserver/mi/mistruct.h
new file mode 100644
index 000000000..98879b72d
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mistruct.h
@@ -0,0 +1,65 @@
+/* $Xorg: mistruct.h,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86$ */
+
+#ifndef MISTRUCT_H
+#define MISTRUCT_H
+
+#include "mi.h"
+#include "regionstr.h"
+
+/* information about dashes */
+typedef struct _miDash {
+ DDXPointRec pt;
+ int e1, e2; /* keep these, so we don't have to do it again */
+ int e; /* bresenham error term for this point on line */
+ int which;
+ int newLine;/* 0 if part of same original line as previous dash */
+ } miDashRec;
+
+#endif /* MISTRUCT_H */
diff --git a/nx-X11/programs/Xserver/mi/mivalidate.h b/nx-X11/programs/Xserver/mi/mivalidate.h
new file mode 100644
index 000000000..612b67e1d
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mivalidate.h
@@ -0,0 +1,55 @@
+/* $Xorg: mivalidate.h,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86$ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef MIVALIDATE_H
+#define MIVALIDATE_H
+
+#include "regionstr.h"
+
+typedef union _Validate {
+ struct BeforeValidate {
+ DDXPointRec oldAbsCorner; /* old window position */
+ RegionPtr borderVisible; /* visible region of border, */
+ /* non-null when size changes */
+ Bool resized; /* unclipped winSize has changed - */
+ /* don't call SaveDoomedAreas */
+ } before;
+ struct AfterValidate {
+ RegionRec exposed; /* exposed regions, absolute pos */
+ RegionRec borderExposed;
+ } after;
+} ValidateRec;
+
+#endif /* MIVALIDATE_H */
diff --git a/nx-X11/programs/Xserver/mi/mivaltree.c b/nx-X11/programs/Xserver/mi/mivaltree.c
new file mode 100644
index 000000000..d745238b6
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mivaltree.c
@@ -0,0 +1,826 @@
+/* $Xorg: mivaltree.c,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
+/* $XdotOrg: xc/programs/Xserver/mi/mivaltree.c,v 1.6 2005/07/03 07:01:51 daniels Exp $ */
+/*
+ * mivaltree.c --
+ * Functions for recalculating window clip lists. Main function
+ * is miValidateTree.
+ *
+
+Copyright 1987, 1988, 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+ *
+ * Copyright 1987, 1988, 1989 by
+ * Digital Equipment Corporation, Maynard, Massachusetts,
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ ******************************************************************/
+
+/* The panoramix components contained the following notice */
+/*****************************************************************
+
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+
+/* $XFree86: xc/programs/Xserver/mi/mivaltree.c,v 1.9tsi Exp $ */
+
+ /*
+ * Aug '86: Susan Angebranndt -- original code
+ * July '87: Adam de Boor -- substantially modified and commented
+ * Summer '89: Joel McCormack -- so fast you wouldn't believe it possible.
+ * In particular, much improved code for window mapping and
+ * circulating.
+ * Bob Scheifler -- avoid miComputeClips for unmapped windows,
+ * valdata changes
+ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "regionstr.h"
+#include "mivalidate.h"
+
+#include "globals.h"
+
+#ifdef SHAPE
+/*
+ * Compute the visibility of a shaped window
+ */
+int
+miShapedWindowIn (pScreen, universe, bounding, rect, x, y)
+ ScreenPtr pScreen;
+ RegionPtr universe, bounding;
+ BoxPtr rect;
+ register int x, y;
+{
+ BoxRec box;
+ register BoxPtr boundBox;
+ int nbox;
+ Bool someIn, someOut;
+ register int t, x1, y1, x2, y2;
+
+ nbox = REGION_NUM_RECTS (bounding);
+ boundBox = REGION_RECTS (bounding);
+ someIn = someOut = FALSE;
+ x1 = rect->x1;
+ y1 = rect->y1;
+ x2 = rect->x2;
+ y2 = rect->y2;
+ while (nbox--)
+ {
+ if ((t = boundBox->x1 + x) < x1)
+ t = x1;
+ box.x1 = t;
+ if ((t = boundBox->y1 + y) < y1)
+ t = y1;
+ box.y1 = t;
+ if ((t = boundBox->x2 + x) > x2)
+ t = x2;
+ box.x2 = t;
+ if ((t = boundBox->y2 + y) > y2)
+ t = y2;
+ box.y2 = t;
+ if (box.x1 > box.x2)
+ box.x2 = box.x1;
+ if (box.y1 > box.y2)
+ box.y2 = box.y1;
+ switch (RECT_IN_REGION(pScreen, universe, &box))
+ {
+ case rgnIN:
+ if (someOut)
+ return rgnPART;
+ someIn = TRUE;
+ break;
+ case rgnOUT:
+ if (someIn)
+ return rgnPART;
+ someOut = TRUE;
+ break;
+ default:
+ return rgnPART;
+ }
+ boundBox++;
+ }
+ if (someIn)
+ return rgnIN;
+ return rgnOUT;
+}
+#endif
+
+static GetRedirectBorderClipProcPtr miGetRedirectBorderClipProc;
+static SetRedirectBorderClipProcPtr miSetRedirectBorderClipProc;
+
+void
+miRegisterRedirectBorderClipProc (SetRedirectBorderClipProcPtr setBorderClip,
+ GetRedirectBorderClipProcPtr getBorderClip)
+{
+ miSetRedirectBorderClipProc = setBorderClip;
+ miGetRedirectBorderClipProc = getBorderClip;
+}
+
+#define HasParentRelativeBorder(w) (!(w)->borderIsPixel && \
+ HasBorder(w) && \
+ (w)->backgroundState == ParentRelative)
+
+
+/*
+ *-----------------------------------------------------------------------
+ * miComputeClips --
+ * Recompute the clipList, borderClip, exposed and borderExposed
+ * regions for pParent and its children. Only viewable windows are
+ * taken into account.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * clipList, borderClip, exposed and borderExposed are altered.
+ * A VisibilityNotify event may be generated on the parent window.
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miComputeClips (
+ register WindowPtr pParent,
+ register ScreenPtr pScreen,
+ register RegionPtr universe,
+ VTKind kind,
+ RegionPtr exposed ) /* for intermediate calculations */
+{
+ int dx,
+ dy;
+ RegionRec childUniverse;
+ register WindowPtr pChild;
+ int oldVis, newVis;
+ BoxRec borderSize;
+ RegionRec childUnion;
+ Bool overlap;
+ RegionPtr borderVisible;
+ Bool resized;
+ /*
+ * Figure out the new visibility of this window.
+ * The extent of the universe should be the same as the extent of
+ * the borderSize region. If the window is unobscured, this rectangle
+ * will be completely inside the universe (the universe will cover it
+ * completely). If the window is completely obscured, none of the
+ * universe will cover the rectangle.
+ */
+ borderSize.x1 = pParent->drawable.x - wBorderWidth(pParent);
+ borderSize.y1 = pParent->drawable.y - wBorderWidth(pParent);
+ dx = (int) pParent->drawable.x + (int) pParent->drawable.width + wBorderWidth(pParent);
+ if (dx > 32767)
+ dx = 32767;
+ borderSize.x2 = dx;
+ dy = (int) pParent->drawable.y + (int) pParent->drawable.height + wBorderWidth(pParent);
+ if (dy > 32767)
+ dy = 32767;
+ borderSize.y2 = dy;
+
+ oldVis = pParent->visibility;
+ switch (RECT_IN_REGION( pScreen, universe, &borderSize))
+ {
+ case rgnIN:
+ newVis = VisibilityUnobscured;
+ break;
+ case rgnPART:
+ newVis = VisibilityPartiallyObscured;
+#ifdef SHAPE
+ {
+ RegionPtr pBounding;
+
+ if ((pBounding = wBoundingShape (pParent)))
+ {
+ switch (miShapedWindowIn (pScreen, universe, pBounding,
+ &borderSize,
+ pParent->drawable.x,
+ pParent->drawable.y))
+ {
+ case rgnIN:
+ newVis = VisibilityUnobscured;
+ break;
+ case rgnOUT:
+ newVis = VisibilityFullyObscured;
+ break;
+ }
+ }
+ }
+#endif
+ break;
+ default:
+ newVis = VisibilityFullyObscured;
+ break;
+ }
+ pParent->visibility = newVis;
+ if (oldVis != newVis &&
+ ((pParent->eventMask | wOtherEventMasks(pParent)) & VisibilityChangeMask))
+ SendVisibilityNotify(pParent);
+
+#ifdef COMPOSITE
+ /*
+ * In redirected drawing case, reset universe to borderSize
+ */
+ if (pParent->redirectDraw)
+ {
+ if (miSetRedirectBorderClipProc)
+ (*miSetRedirectBorderClipProc) (pParent, universe);
+ REGION_COPY(pScreen, universe, &pParent->borderSize);
+ }
+#endif
+
+ dx = pParent->drawable.x - pParent->valdata->before.oldAbsCorner.x;
+ dy = pParent->drawable.y - pParent->valdata->before.oldAbsCorner.y;
+
+ /*
+ * avoid computations when dealing with simple operations
+ */
+
+ switch (kind) {
+ case VTMap:
+ case VTStack:
+ case VTUnmap:
+ break;
+ case VTMove:
+ if ((oldVis == newVis) &&
+ ((oldVis == VisibilityFullyObscured) ||
+ (oldVis == VisibilityUnobscured)))
+ {
+ pChild = pParent;
+ while (1)
+ {
+ if (pChild->viewable)
+ {
+ if (pChild->visibility != VisibilityFullyObscured)
+ {
+ REGION_TRANSLATE( pScreen, &pChild->borderClip,
+ dx, dy);
+ REGION_TRANSLATE( pScreen, &pChild->clipList,
+ dx, dy);
+ pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ if (pScreen->ClipNotify)
+ (* pScreen->ClipNotify) (pChild, dx, dy);
+
+ }
+ if (pChild->valdata)
+ {
+ REGION_NULL(pScreen,
+ &pChild->valdata->after.borderExposed);
+ if (HasParentRelativeBorder(pChild))
+ {
+ REGION_SUBTRACT(pScreen,
+ &pChild->valdata->after.borderExposed,
+ &pChild->borderClip,
+ &pChild->winSize);
+ }
+ REGION_NULL(pScreen, &pChild->valdata->after.exposed);
+ }
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ while (!pChild->nextSib && (pChild != pParent))
+ pChild = pChild->parent;
+ if (pChild == pParent)
+ break;
+ pChild = pChild->nextSib;
+ }
+ return;
+ }
+ /* fall through */
+ default:
+ /*
+ * To calculate exposures correctly, we have to translate the old
+ * borderClip and clipList regions to the window's new location so there
+ * is a correspondence between pieces of the new and old clipping regions.
+ */
+ if (dx || dy)
+ {
+ /*
+ * We translate the old clipList because that will be exposed or copied
+ * if gravity is right.
+ */
+ REGION_TRANSLATE( pScreen, &pParent->borderClip, dx, dy);
+ REGION_TRANSLATE( pScreen, &pParent->clipList, dx, dy);
+ }
+ break;
+ case VTBroken:
+ REGION_EMPTY (pScreen, &pParent->borderClip);
+ REGION_EMPTY (pScreen, &pParent->clipList);
+ break;
+ }
+
+ borderVisible = pParent->valdata->before.borderVisible;
+ resized = pParent->valdata->before.resized;
+ REGION_NULL(pScreen, &pParent->valdata->after.borderExposed);
+ REGION_NULL(pScreen, &pParent->valdata->after.exposed);
+
+ /*
+ * Since the borderClip must not be clipped by the children, we do
+ * the border exposure first...
+ *
+ * 'universe' is the window's borderClip. To figure the exposures, remove
+ * the area that used to be exposed from the new.
+ * This leaves a region of pieces that weren't exposed before.
+ */
+
+ if (HasBorder (pParent))
+ {
+ if (borderVisible)
+ {
+ /*
+ * when the border changes shape, the old visible portions
+ * of the border will be saved by DIX in borderVisible --
+ * use that region and destroy it
+ */
+ REGION_SUBTRACT( pScreen, exposed, universe, borderVisible);
+ REGION_DESTROY( pScreen, borderVisible);
+ }
+ else
+ {
+ REGION_SUBTRACT( pScreen, exposed, universe, &pParent->borderClip);
+ }
+ if (HasParentRelativeBorder(pParent) && (dx || dy))
+ REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed,
+ universe,
+ &pParent->winSize);
+ else
+ REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed,
+ exposed, &pParent->winSize);
+
+ REGION_COPY( pScreen, &pParent->borderClip, universe);
+
+ /*
+ * To get the right clipList for the parent, and to make doubly sure
+ * that no child overlaps the parent's border, we remove the parent's
+ * border from the universe before proceeding.
+ */
+
+ REGION_INTERSECT( pScreen, universe, universe, &pParent->winSize);
+ }
+ else
+ REGION_COPY( pScreen, &pParent->borderClip, universe);
+
+ if ((pChild = pParent->firstChild) && pParent->mapped)
+ {
+ REGION_NULL(pScreen, &childUniverse);
+ REGION_NULL(pScreen, &childUnion);
+ if ((pChild->drawable.y < pParent->lastChild->drawable.y) ||
+ ((pChild->drawable.y == pParent->lastChild->drawable.y) &&
+ (pChild->drawable.x < pParent->lastChild->drawable.x)))
+ {
+ for (; pChild; pChild = pChild->nextSib)
+ {
+ if (pChild->viewable)
+ REGION_APPEND( pScreen, &childUnion, &pChild->borderSize);
+ }
+ }
+ else
+ {
+ for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib)
+ {
+ if (pChild->viewable)
+ REGION_APPEND( pScreen, &childUnion, &pChild->borderSize);
+ }
+ }
+ REGION_VALIDATE( pScreen, &childUnion, &overlap);
+
+ for (pChild = pParent->firstChild;
+ pChild;
+ pChild = pChild->nextSib)
+ {
+ if (pChild->viewable) {
+ /*
+ * If the child is viewable, we want to remove its extents
+ * from the current universe, but we only re-clip it if
+ * it's been marked.
+ */
+ if (pChild->valdata) {
+ /*
+ * Figure out the new universe from the child's
+ * perspective and recurse.
+ */
+ REGION_INTERSECT( pScreen, &childUniverse,
+ universe,
+ &pChild->borderSize);
+ miComputeClips (pChild, pScreen, &childUniverse, kind,
+ exposed);
+ }
+ /*
+ * Once the child has been processed, we remove its extents
+ * from the current universe, thus denying its space to any
+ * other sibling.
+ */
+ if (overlap)
+ REGION_SUBTRACT( pScreen, universe, universe,
+ &pChild->borderSize);
+ }
+ }
+ if (!overlap)
+ REGION_SUBTRACT( pScreen, universe, universe, &childUnion);
+ REGION_UNINIT( pScreen, &childUnion);
+ REGION_UNINIT( pScreen, &childUniverse);
+ } /* if any children */
+
+ /*
+ * 'universe' now contains the new clipList for the parent window.
+ *
+ * To figure the exposure of the window we subtract the old clip from the
+ * new, just as for the border.
+ */
+
+ if (oldVis == VisibilityFullyObscured ||
+ oldVis == VisibilityNotViewable)
+ {
+ REGION_COPY( pScreen, &pParent->valdata->after.exposed, universe);
+ }
+ else if (newVis != VisibilityFullyObscured &&
+ newVis != VisibilityNotViewable)
+ {
+ REGION_SUBTRACT( pScreen, &pParent->valdata->after.exposed,
+ universe, &pParent->clipList);
+ }
+
+ /*
+ * One last thing: backing storage. We have to try to save what parts of
+ * the window are about to be obscured. We can just subtract the universe
+ * from the old clipList and get the areas that were in the old but aren't
+ * in the new and, hence, are about to be obscured.
+ */
+ if (pParent->backStorage && !resized)
+ {
+ REGION_SUBTRACT( pScreen, exposed, &pParent->clipList, universe);
+ (* pScreen->SaveDoomedAreas)(pParent, exposed, dx, dy);
+ }
+
+ /* HACK ALERT - copying contents of regions, instead of regions */
+ {
+ RegionRec tmp;
+
+ tmp = pParent->clipList;
+ pParent->clipList = *universe;
+ *universe = tmp;
+ }
+
+#ifdef NOTDEF
+ REGION_COPY( pScreen, &pParent->clipList, universe);
+#endif
+
+ pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+ if (pScreen->ClipNotify)
+ (* pScreen->ClipNotify) (pParent, dx, dy);
+}
+
+static void
+miTreeObscured(
+ register WindowPtr pParent )
+{
+ register WindowPtr pChild;
+ register int oldVis;
+
+ pChild = pParent;
+ while (1)
+ {
+ if (pChild->viewable)
+ {
+ oldVis = pChild->visibility;
+ if (oldVis != (pChild->visibility = VisibilityFullyObscured) &&
+ ((pChild->eventMask | wOtherEventMasks(pChild)) & VisibilityChangeMask))
+ SendVisibilityNotify(pChild);
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ while (!pChild->nextSib && (pChild != pParent))
+ pChild = pChild->parent;
+ if (pChild == pParent)
+ break;
+ pChild = pChild->nextSib;
+ }
+}
+
+/*
+ *-----------------------------------------------------------------------
+ * miValidateTree --
+ * Recomputes the clip list for pParent and all its inferiors.
+ *
+ * Results:
+ * Always returns 1.
+ *
+ * Side Effects:
+ * The clipList, borderClip, exposed, and borderExposed regions for
+ * each marked window are altered.
+ *
+ * Notes:
+ * This routine assumes that all affected windows have been marked
+ * (valdata created) and their winSize and borderSize regions
+ * adjusted to correspond to their new positions. The borderClip and
+ * clipList regions should not have been touched.
+ *
+ * The top-most level is treated differently from all lower levels
+ * because pParent is unchanged. For the top level, we merge the
+ * regions taken up by the marked children back into the clipList
+ * for pParent, thus forming a region from which the marked children
+ * can claim their areas. For lower levels, where the old clipList
+ * and borderClip are invalid, we can't do this and have to do the
+ * extra operations done in miComputeClips, but this is much faster
+ * e.g. when only one child has moved...
+ *
+ *-----------------------------------------------------------------------
+ */
+/*ARGSUSED*/
+int
+miValidateTree (pParent, pChild, kind)
+ WindowPtr pParent; /* Parent to validate */
+ WindowPtr pChild; /* First child of pParent that was
+ * affected */
+ VTKind kind; /* What kind of configuration caused call */
+{
+ RegionRec totalClip; /* Total clipping region available to
+ * the marked children. pParent's clipList
+ * merged with the borderClips of all
+ * the marked children. */
+ RegionRec childClip; /* The new borderClip for the current
+ * child */
+ RegionRec childUnion; /* the space covered by borderSize for
+ * all marked children */
+ RegionRec exposed; /* For intermediate calculations */
+ register ScreenPtr pScreen;
+ register WindowPtr pWin;
+ Bool overlap;
+ int viewvals;
+ Bool forward;
+
+ pScreen = pParent->drawable.pScreen;
+ if (pChild == NullWindow)
+ pChild = pParent->firstChild;
+
+ REGION_NULL(pScreen, &childClip);
+ REGION_NULL(pScreen, &exposed);
+
+ /*
+ * compute the area of the parent window occupied
+ * by the marked children + the parent itself. This
+ * is the area which can be divied up among the marked
+ * children in their new configuration.
+ */
+ REGION_NULL(pScreen, &totalClip);
+ viewvals = 0;
+ if (REGION_BROKEN (pScreen, &pParent->clipList) &&
+ !REGION_BROKEN (pScreen, &pParent->borderClip))
+ {
+ kind = VTBroken;
+ /*
+ * When rebuilding clip lists after out of memory,
+ * assume everything is busted.
+ */
+ forward = TRUE;
+ REGION_COPY (pScreen, &totalClip, &pParent->borderClip);
+ REGION_INTERSECT (pScreen, &totalClip, &totalClip, &pParent->winSize);
+
+ for (pWin = pParent->firstChild; pWin != pChild; pWin = pWin->nextSib)
+ {
+ if (pWin->viewable)
+ REGION_SUBTRACT (pScreen, &totalClip, &totalClip, &pWin->borderSize);
+ }
+ for (pWin = pChild; pWin; pWin = pWin->nextSib)
+ if (pWin->valdata && pWin->viewable)
+ viewvals++;
+
+ REGION_EMPTY (pScreen, &pParent->clipList);
+ }
+ else
+ {
+ if ((pChild->drawable.y < pParent->lastChild->drawable.y) ||
+ ((pChild->drawable.y == pParent->lastChild->drawable.y) &&
+ (pChild->drawable.x < pParent->lastChild->drawable.x)))
+ {
+ forward = TRUE;
+ for (pWin = pChild; pWin; pWin = pWin->nextSib)
+ {
+ if (pWin->valdata)
+ {
+ RegionPtr pBorderClip = &pWin->borderClip;
+#ifdef COMPOSITE
+ if (pWin->redirectDraw && miGetRedirectBorderClipProc)
+ pBorderClip = (*miGetRedirectBorderClipProc)(pWin);
+#endif
+ REGION_APPEND( pScreen, &totalClip, pBorderClip );
+ if (pWin->viewable)
+ viewvals++;
+ }
+ }
+ }
+ else
+ {
+ forward = FALSE;
+ pWin = pParent->lastChild;
+ while (1)
+ {
+ if (pWin->valdata)
+ {
+ RegionPtr pBorderClip = &pWin->borderClip;
+#ifdef COMPOSITE
+ if (pWin->redirectDraw && miGetRedirectBorderClipProc)
+ pBorderClip = (*miGetRedirectBorderClipProc)(pWin);
+#endif
+ REGION_APPEND( pScreen, &totalClip, pBorderClip );
+ if (pWin->viewable)
+ viewvals++;
+ }
+ if (pWin == pChild)
+ break;
+ pWin = pWin->prevSib;
+ }
+ }
+ REGION_VALIDATE( pScreen, &totalClip, &overlap);
+ }
+
+ /*
+ * Now go through the children of the root and figure their new
+ * borderClips from the totalClip, passing that off to miComputeClips
+ * to handle recursively. Once that's done, we remove the child
+ * from the totalClip to clip any siblings below it.
+ */
+
+ overlap = TRUE;
+ if (kind != VTStack)
+ {
+ REGION_UNION( pScreen, &totalClip, &totalClip, &pParent->clipList);
+ if (viewvals > 1)
+ {
+ /*
+ * precompute childUnion to discover whether any of them
+ * overlap. This seems redundant, but performance studies
+ * have demonstrated that the cost of this loop is
+ * lower than the cost of multiple Subtracts in the
+ * loop below.
+ */
+ REGION_NULL(pScreen, &childUnion);
+ if (forward)
+ {
+ for (pWin = pChild; pWin; pWin = pWin->nextSib)
+ if (pWin->valdata && pWin->viewable)
+ REGION_APPEND( pScreen, &childUnion,
+ &pWin->borderSize);
+ }
+ else
+ {
+ pWin = pParent->lastChild;
+ while (1)
+ {
+ if (pWin->valdata && pWin->viewable)
+ REGION_APPEND( pScreen, &childUnion,
+ &pWin->borderSize);
+ if (pWin == pChild)
+ break;
+ pWin = pWin->prevSib;
+ }
+ }
+ REGION_VALIDATE(pScreen, &childUnion, &overlap);
+ if (overlap)
+ REGION_UNINIT(pScreen, &childUnion);
+ }
+ }
+
+ for (pWin = pChild;
+ pWin != NullWindow;
+ pWin = pWin->nextSib)
+ {
+ if (pWin->viewable) {
+ if (pWin->valdata) {
+ REGION_INTERSECT( pScreen, &childClip,
+ &totalClip,
+ &pWin->borderSize);
+ miComputeClips (pWin, pScreen, &childClip, kind, &exposed);
+ if (overlap)
+ {
+ REGION_SUBTRACT( pScreen, &totalClip,
+ &totalClip,
+ &pWin->borderSize);
+ }
+ } else if (pWin->visibility == VisibilityNotViewable) {
+ miTreeObscured(pWin);
+ }
+ } else {
+ if (pWin->valdata) {
+ REGION_EMPTY( pScreen, &pWin->clipList);
+ if (pScreen->ClipNotify)
+ (* pScreen->ClipNotify) (pWin, 0, 0);
+ REGION_EMPTY( pScreen, &pWin->borderClip);
+ pWin->valdata = (ValidatePtr)NULL;
+ }
+ }
+ }
+
+ REGION_UNINIT( pScreen, &childClip);
+ if (!overlap)
+ {
+ REGION_SUBTRACT(pScreen, &totalClip, &totalClip, &childUnion);
+ REGION_UNINIT(pScreen, &childUnion);
+ }
+
+ REGION_NULL(pScreen, &pParent->valdata->after.exposed);
+ REGION_NULL(pScreen, &pParent->valdata->after.borderExposed);
+
+ /*
+ * each case below is responsible for updating the
+ * clipList and serial number for the parent window
+ */
+
+ switch (kind) {
+ case VTStack:
+ break;
+ default:
+ /*
+ * totalClip contains the new clipList for the parent. Figure out
+ * exposures and obscures as per miComputeClips and reset the parent's
+ * clipList.
+ */
+ REGION_SUBTRACT( pScreen, &pParent->valdata->after.exposed,
+ &totalClip, &pParent->clipList);
+ /* fall through */
+ case VTMap:
+ if (pParent->backStorage) {
+ REGION_SUBTRACT( pScreen, &exposed, &pParent->clipList, &totalClip);
+ (* pScreen->SaveDoomedAreas)(pParent, &exposed, 0, 0);
+ }
+
+ REGION_COPY( pScreen, &pParent->clipList, &totalClip);
+ pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ break;
+ }
+
+ REGION_UNINIT( pScreen, &totalClip);
+ REGION_UNINIT( pScreen, &exposed);
+ if (pScreen->ClipNotify)
+ (*pScreen->ClipNotify) (pParent, 0, 0);
+ return (1);
+}
diff --git a/nx-X11/programs/Xserver/mi/miwideline.c b/nx-X11/programs/Xserver/mi/miwideline.c
new file mode 100644
index 000000000..44cf18f2e
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/miwideline.c
@@ -0,0 +1,2242 @@
+/* $Xorg: miwideline.c,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
+/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/mi/miwideline.c,v 1.12 2001/12/14 20:00:28 dawes Exp $ */
+
+/* Author: Keith Packard, MIT X Consortium */
+
+/*
+ * Mostly integer wideline code. Uses a technique similar to
+ * bresenham zero-width lines, except walks an X edge
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#ifdef _XOPEN_SOURCE
+#include <math.h>
+#else
+#define _XOPEN_SOURCE /* to get prototype for hypot on some systems */
+#include <math.h>
+#undef _XOPEN_SOURCE
+#endif
+#include <X11/X.h>
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "regionstr.h"
+#include "miwideline.h"
+#include "mi.h"
+
+#ifdef ICEILTEMPDECL
+ICEILTEMPDECL
+#endif
+
+static void miLineArc(DrawablePtr pDraw, register GCPtr pGC,
+ unsigned long pixel, SpanDataPtr spanData,
+ register LineFacePtr leftFace,
+ register LineFacePtr rightFace,
+ double xorg, double yorg, Bool isInt);
+
+
+/*
+ * spans-based polygon filler
+ */
+
+void
+miFillPolyHelper (pDrawable, pGC, pixel, spanData, y, overall_height,
+ left, right, left_count, right_count)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ unsigned long pixel;
+ SpanDataPtr spanData;
+ int y; /* start y coordinate */
+ int overall_height; /* height of entire segment */
+ PolyEdgePtr left, right;
+ int left_count, right_count;
+{
+ register int left_x = 0, left_e = 0;
+ int left_stepx = 0;
+ int left_signdx = 0;
+ int left_dy = 0, left_dx = 0;
+
+ register int right_x = 0, right_e = 0;
+ int right_stepx = 0;
+ int right_signdx = 0;
+ int right_dy = 0, right_dx = 0;
+
+ int height = 0;
+ int left_height = 0, right_height = 0;
+
+ register DDXPointPtr ppt;
+ DDXPointPtr pptInit = NULL;
+ register int *pwidth;
+ int *pwidthInit = NULL;
+ XID oldPixel;
+ int xorg;
+ Spans spanRec;
+
+ left_height = 0;
+ right_height = 0;
+
+ if (!spanData)
+ {
+ pptInit = (DDXPointPtr) ALLOCATE_LOCAL (overall_height * sizeof(*ppt));
+ if (!pptInit)
+ return;
+ pwidthInit = (int *) ALLOCATE_LOCAL (overall_height * sizeof(*pwidth));
+ if (!pwidthInit)
+ {
+ DEALLOCATE_LOCAL (pptInit);
+ return;
+ }
+ ppt = pptInit;
+ pwidth = pwidthInit;
+ oldPixel = pGC->fgPixel;
+ if (pixel != oldPixel)
+ {
+ DoChangeGC (pGC, GCForeground, (XID *)&pixel, FALSE);
+ ValidateGC (pDrawable, pGC);
+ }
+ }
+ else
+ {
+ spanRec.points = (DDXPointPtr) xalloc (overall_height * sizeof (*ppt));
+ if (!spanRec.points)
+ return;
+ spanRec.widths = (int *) xalloc (overall_height * sizeof (int));
+ if (!spanRec.widths)
+ {
+ xfree (spanRec.points);
+ return;
+ }
+ ppt = spanRec.points;
+ pwidth = spanRec.widths;
+ }
+
+ xorg = 0;
+ if (pGC->miTranslate)
+ {
+ y += pDrawable->y;
+ xorg = pDrawable->x;
+ }
+ while ((left_count || left_height) &&
+ (right_count || right_height))
+ {
+ MIPOLYRELOADLEFT
+ MIPOLYRELOADRIGHT
+
+ height = left_height;
+ if (height > right_height)
+ height = right_height;
+
+ left_height -= height;
+ right_height -= height;
+
+ while (--height >= 0)
+ {
+ if (right_x >= left_x)
+ {
+ ppt->y = y;
+ ppt->x = left_x + xorg;
+ ppt++;
+ *pwidth++ = right_x - left_x + 1;
+ }
+ y++;
+
+ MIPOLYSTEPLEFT
+
+ MIPOLYSTEPRIGHT
+ }
+ }
+ if (!spanData)
+ {
+ (*pGC->ops->FillSpans) (pDrawable, pGC, ppt - pptInit, pptInit, pwidthInit, TRUE);
+ DEALLOCATE_LOCAL (pwidthInit);
+ DEALLOCATE_LOCAL (pptInit);
+ if (pixel != oldPixel)
+ {
+ DoChangeGC (pGC, GCForeground, &oldPixel, FALSE);
+ ValidateGC (pDrawable, pGC);
+ }
+ }
+ else
+ {
+ spanRec.count = ppt - spanRec.points;
+ AppendSpanGroup (pGC, pixel, &spanRec, spanData)
+ }
+}
+
+static void
+miFillRectPolyHelper (
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ unsigned long pixel,
+ SpanDataPtr spanData,
+ int x,
+ int y,
+ int w,
+ int h)
+{
+ register DDXPointPtr ppt;
+ register int *pwidth;
+ XID oldPixel;
+ Spans spanRec;
+ xRectangle rect;
+
+ if (!spanData)
+ {
+ rect.x = x;
+ rect.y = y;
+ rect.width = w;
+ rect.height = h;
+ oldPixel = pGC->fgPixel;
+ if (pixel != oldPixel)
+ {
+ DoChangeGC (pGC, GCForeground, (XID *)&pixel, FALSE);
+ ValidateGC (pDrawable, pGC);
+ }
+ (*pGC->ops->PolyFillRect) (pDrawable, pGC, 1, &rect);
+ if (pixel != oldPixel)
+ {
+ DoChangeGC (pGC, GCForeground, &oldPixel, FALSE);
+ ValidateGC (pDrawable, pGC);
+ }
+ }
+ else
+ {
+ spanRec.points = (DDXPointPtr) xalloc (h * sizeof (*ppt));
+ if (!spanRec.points)
+ return;
+ spanRec.widths = (int *) xalloc (h * sizeof (int));
+ if (!spanRec.widths)
+ {
+ xfree (spanRec.points);
+ return;
+ }
+ ppt = spanRec.points;
+ pwidth = spanRec.widths;
+
+ if (pGC->miTranslate)
+ {
+ y += pDrawable->y;
+ x += pDrawable->x;
+ }
+ while (h--)
+ {
+ ppt->x = x;
+ ppt->y = y;
+ ppt++;
+ *pwidth++ = w;
+ y++;
+ }
+ spanRec.count = ppt - spanRec.points;
+ AppendSpanGroup (pGC, pixel, &spanRec, spanData)
+ }
+}
+
+/* static */ int
+miPolyBuildEdge (x0, y0, k, dx, dy, xi, yi, left, edge)
+ double x0, y0;
+ double k; /* x0 * dy - y0 * dx */
+ register int dx, dy;
+ int xi, yi;
+ int left;
+ register PolyEdgePtr edge;
+{
+ int x, y, e;
+ int xady;
+
+ if (dy < 0)
+ {
+ dy = -dy;
+ dx = -dx;
+ k = -k;
+ }
+
+#ifdef NOTDEF
+ {
+ double realk, kerror;
+ realk = x0 * dy - y0 * dx;
+ kerror = Fabs (realk - k);
+ if (kerror > .1)
+ printf ("realk: %g k: %g\n", realk, k);
+ }
+#endif
+ y = ICEIL (y0);
+ xady = ICEIL (k) + y * dx;
+
+ if (xady <= 0)
+ x = - (-xady / dy) - 1;
+ else
+ x = (xady - 1) / dy;
+
+ e = xady - x * dy;
+
+ if (dx >= 0)
+ {
+ edge->signdx = 1;
+ edge->stepx = dx / dy;
+ edge->dx = dx % dy;
+ }
+ else
+ {
+ edge->signdx = -1;
+ edge->stepx = - (-dx / dy);
+ edge->dx = -dx % dy;
+ e = dy - e + 1;
+ }
+ edge->dy = dy;
+ edge->x = x + left + xi;
+ edge->e = e - dy; /* bias to compare against 0 instead of dy */
+ return y + yi;
+}
+
+#define StepAround(v, incr, max) (((v) + (incr) < 0) ? (max - 1) : ((v) + (incr) == max) ? 0 : ((v) + (incr)))
+
+/* static */ int
+miPolyBuildPoly (vertices, slopes, count, xi, yi, left, right, pnleft, pnright, h)
+ register PolyVertexPtr vertices;
+ register PolySlopePtr slopes;
+ int count;
+ int xi, yi;
+ PolyEdgePtr left, right;
+ int *pnleft, *pnright;
+ int *h;
+{
+ int top, bottom;
+ double miny, maxy;
+ register int i;
+ int j;
+ int clockwise;
+ int slopeoff;
+ register int s;
+ register int nright, nleft;
+ int y, lasty = 0, bottomy, topy = 0;
+
+ /* find the top of the polygon */
+ maxy = miny = vertices[0].y;
+ bottom = top = 0;
+ for (i = 1; i < count; i++)
+ {
+ if (vertices[i].y < miny)
+ {
+ top = i;
+ miny = vertices[i].y;
+ }
+ if (vertices[i].y >= maxy)
+ {
+ bottom = i;
+ maxy = vertices[i].y;
+ }
+ }
+ clockwise = 1;
+ slopeoff = 0;
+
+ i = top;
+ j = StepAround (top, -1, count);
+
+ if (slopes[j].dy * slopes[i].dx > slopes[i].dy * slopes[j].dx)
+ {
+ clockwise = -1;
+ slopeoff = -1;
+ }
+
+ bottomy = ICEIL (maxy) + yi;
+
+ nright = 0;
+
+ s = StepAround (top, slopeoff, count);
+ i = top;
+ while (i != bottom)
+ {
+ if (slopes[s].dy != 0)
+ {
+ y = miPolyBuildEdge (vertices[i].x, vertices[i].y,
+ slopes[s].k,
+ slopes[s].dx, slopes[s].dy,
+ xi, yi, 0,
+ &right[nright]);
+ if (nright != 0)
+ right[nright-1].height = y - lasty;
+ else
+ topy = y;
+ nright++;
+ lasty = y;
+ }
+
+ i = StepAround (i, clockwise, count);
+ s = StepAround (s, clockwise, count);
+ }
+ if (nright != 0)
+ right[nright-1].height = bottomy - lasty;
+
+ if (slopeoff == 0)
+ slopeoff = -1;
+ else
+ slopeoff = 0;
+
+ nleft = 0;
+ s = StepAround (top, slopeoff, count);
+ i = top;
+ while (i != bottom)
+ {
+ if (slopes[s].dy != 0)
+ {
+ y = miPolyBuildEdge (vertices[i].x, vertices[i].y,
+ slopes[s].k,
+ slopes[s].dx, slopes[s].dy, xi, yi, 1,
+ &left[nleft]);
+
+ if (nleft != 0)
+ left[nleft-1].height = y - lasty;
+ nleft++;
+ lasty = y;
+ }
+ i = StepAround (i, -clockwise, count);
+ s = StepAround (s, -clockwise, count);
+ }
+ if (nleft != 0)
+ left[nleft-1].height = bottomy - lasty;
+ *pnleft = nleft;
+ *pnright = nright;
+ *h = bottomy - topy;
+ return topy;
+}
+
+static void
+miLineOnePoint (
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ unsigned long pixel,
+ SpanDataPtr spanData,
+ int x,
+ int y)
+{
+ DDXPointRec pt;
+ int wid;
+ unsigned long oldPixel;
+
+ MILINESETPIXEL (pDrawable, pGC, pixel, oldPixel);
+ if (pGC->fillStyle == FillSolid)
+ {
+ pt.x = x;
+ pt.y = y;
+ (*pGC->ops->PolyPoint) (pDrawable, pGC, CoordModeOrigin, 1, &pt);
+ }
+ else
+ {
+ wid = 1;
+ if (pGC->miTranslate)
+ {
+ x += pDrawable->x;
+ y += pDrawable->y;
+ }
+ pt.x = x;
+ pt.y = y;
+ (*pGC->ops->FillSpans) (pDrawable, pGC, 1, &pt, &wid, TRUE);
+ }
+ MILINERESETPIXEL (pDrawable, pGC, pixel, oldPixel);
+}
+
+static void
+miLineJoin (
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ unsigned long pixel,
+ SpanDataPtr spanData,
+ register LineFacePtr pLeft,
+ register LineFacePtr pRight)
+{
+ double mx = 0, my = 0;
+ double denom = 0.0;
+ PolyVertexRec vertices[4];
+ PolySlopeRec slopes[4];
+ int edgecount;
+ PolyEdgeRec left[4], right[4];
+ int nleft, nright;
+ int y, height;
+ int swapslopes;
+ int joinStyle = pGC->joinStyle;
+ int lw = pGC->lineWidth;
+
+ if (lw == 1 && !spanData) {
+ /* See if one of the lines will draw the joining pixel */
+ if (pLeft->dx > 0 || (pLeft->dx == 0 && pLeft->dy > 0))
+ return;
+ if (pRight->dx > 0 || (pRight->dx == 0 && pRight->dy > 0))
+ return;
+ if (joinStyle != JoinRound) {
+ denom = - pLeft->dx * (double)pRight->dy + pRight->dx * (double)pLeft->dy;
+ if (denom == 0)
+ return; /* no join to draw */
+ }
+ if (joinStyle != JoinMiter) {
+ miLineOnePoint (pDrawable, pGC, pixel, spanData, pLeft->x, pLeft->y);
+ return;
+ }
+ } else {
+ if (joinStyle == JoinRound)
+ {
+ miLineArc(pDrawable, pGC, pixel, spanData,
+ pLeft, pRight,
+ (double)0.0, (double)0.0, TRUE);
+ return;
+ }
+ denom = - pLeft->dx * (double)pRight->dy + pRight->dx * (double)pLeft->dy;
+ if (denom == 0.0)
+ return; /* no join to draw */
+ }
+
+ swapslopes = 0;
+ if (denom > 0)
+ {
+ pLeft->xa = -pLeft->xa;
+ pLeft->ya = -pLeft->ya;
+ pLeft->dx = -pLeft->dx;
+ pLeft->dy = -pLeft->dy;
+ }
+ else
+ {
+ swapslopes = 1;
+ pRight->xa = -pRight->xa;
+ pRight->ya = -pRight->ya;
+ pRight->dx = -pRight->dx;
+ pRight->dy = -pRight->dy;
+ }
+
+ vertices[0].x = pRight->xa;
+ vertices[0].y = pRight->ya;
+ slopes[0].dx = -pRight->dy;
+ slopes[0].dy = pRight->dx;
+ slopes[0].k = 0;
+
+ vertices[1].x = 0;
+ vertices[1].y = 0;
+ slopes[1].dx = pLeft->dy;
+ slopes[1].dy = -pLeft->dx;
+ slopes[1].k = 0;
+
+ vertices[2].x = pLeft->xa;
+ vertices[2].y = pLeft->ya;
+
+ if (joinStyle == JoinMiter)
+ {
+ my = (pLeft->dy * (pRight->xa * pRight->dy - pRight->ya * pRight->dx) -
+ pRight->dy * (pLeft->xa * pLeft->dy - pLeft->ya * pLeft->dx )) /
+ denom;
+ if (pLeft->dy != 0)
+ {
+ mx = pLeft->xa + (my - pLeft->ya) *
+ (double) pLeft->dx / (double) pLeft->dy;
+ }
+ else
+ {
+ mx = pRight->xa + (my - pRight->ya) *
+ (double) pRight->dx / (double) pRight->dy;
+ }
+ /* check miter limit */
+ if ((mx * mx + my * my) * 4 > SQSECANT * lw * lw)
+ joinStyle = JoinBevel;
+ }
+
+ if (joinStyle == JoinMiter)
+ {
+ slopes[2].dx = pLeft->dx;
+ slopes[2].dy = pLeft->dy;
+ slopes[2].k = pLeft->k;
+ if (swapslopes)
+ {
+ slopes[2].dx = -slopes[2].dx;
+ slopes[2].dy = -slopes[2].dy;
+ slopes[2].k = -slopes[2].k;
+ }
+ vertices[3].x = mx;
+ vertices[3].y = my;
+ slopes[3].dx = pRight->dx;
+ slopes[3].dy = pRight->dy;
+ slopes[3].k = pRight->k;
+ if (swapslopes)
+ {
+ slopes[3].dx = -slopes[3].dx;
+ slopes[3].dy = -slopes[3].dy;
+ slopes[3].k = -slopes[3].k;
+ }
+ edgecount = 4;
+ }
+ else
+ {
+ double scale, dx, dy, adx, ady;
+
+ adx = dx = pRight->xa - pLeft->xa;
+ ady = dy = pRight->ya - pLeft->ya;
+ if (adx < 0)
+ adx = -adx;
+ if (ady < 0)
+ ady = -ady;
+ scale = ady;
+ if (adx > ady)
+ scale = adx;
+ slopes[2].dx = (dx * 65536) / scale;
+ slopes[2].dy = (dy * 65536) / scale;
+ slopes[2].k = ((pLeft->xa + pRight->xa) * slopes[2].dy -
+ (pLeft->ya + pRight->ya) * slopes[2].dx) / 2.0;
+ edgecount = 3;
+ }
+
+ y = miPolyBuildPoly (vertices, slopes, edgecount, pLeft->x, pLeft->y,
+ left, right, &nleft, &nright, &height);
+ miFillPolyHelper (pDrawable, pGC, pixel, spanData, y, height, left, right, nleft, nright);
+}
+
+static int
+miLineArcI (
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int xorg,
+ int yorg,
+ DDXPointPtr points,
+ int *widths)
+{
+ register DDXPointPtr tpts, bpts;
+ register int *twids, *bwids;
+ register int x, y, e, ex, slw;
+
+ tpts = points;
+ twids = widths;
+ if (pGC->miTranslate)
+ {
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ }
+ slw = pGC->lineWidth;
+ if (slw == 1)
+ {
+ tpts->x = xorg;
+ tpts->y = yorg;
+ *twids = 1;
+ return 1;
+ }
+ bpts = tpts + slw;
+ bwids = twids + slw;
+ y = (slw >> 1) + 1;
+ if (slw & 1)
+ e = - ((y << 2) + 3);
+ else
+ e = - (y << 3);
+ ex = -4;
+ x = 0;
+ while (y)
+ {
+ e += (y << 3) - 4;
+ while (e >= 0)
+ {
+ x++;
+ e += (ex = -((x << 3) + 4));
+ }
+ y--;
+ slw = (x << 1) + 1;
+ if ((e == ex) && (slw > 1))
+ slw--;
+ tpts->x = xorg - x;
+ tpts->y = yorg - y;
+ tpts++;
+ *twids++ = slw;
+ if ((y != 0) && ((slw > 1) || (e != ex)))
+ {
+ bpts--;
+ bpts->x = xorg - x;
+ bpts->y = yorg + y;
+ *--bwids = slw;
+ }
+ }
+ return (pGC->lineWidth);
+}
+
+#define CLIPSTEPEDGE(edgey,edge,edgeleft) \
+ if (ybase == edgey) \
+ { \
+ if (edgeleft) \
+ { \
+ if (edge->x > xcl) \
+ xcl = edge->x; \
+ } \
+ else \
+ { \
+ if (edge->x < xcr) \
+ xcr = edge->x; \
+ } \
+ edgey++; \
+ edge->x += edge->stepx; \
+ edge->e += edge->dx; \
+ if (edge->e > 0) \
+ { \
+ edge->x += edge->signdx; \
+ edge->e -= edge->dy; \
+ } \
+ }
+
+static int
+miLineArcD (
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ double xorg,
+ double yorg,
+ DDXPointPtr points,
+ int *widths,
+ PolyEdgePtr edge1,
+ int edgey1,
+ Bool edgeleft1,
+ PolyEdgePtr edge2,
+ int edgey2,
+ Bool edgeleft2)
+{
+ register DDXPointPtr pts;
+ register int *wids;
+ double radius, x0, y0, el, er, yk, xlk, xrk, k;
+ int xbase, ybase, y, boty, xl, xr, xcl, xcr;
+ int ymin, ymax;
+ Bool edge1IsMin, edge2IsMin;
+ int ymin1, ymin2;
+
+ pts = points;
+ wids = widths;
+ xbase = floor(xorg);
+ x0 = xorg - xbase;
+ ybase = ICEIL (yorg);
+ y0 = yorg - ybase;
+ if (pGC->miTranslate)
+ {
+ xbase += pDraw->x;
+ ybase += pDraw->y;
+ edge1->x += pDraw->x;
+ edge2->x += pDraw->x;
+ edgey1 += pDraw->y;
+ edgey2 += pDraw->y;
+ }
+ xlk = x0 + x0 + 1.0;
+ xrk = x0 + x0 - 1.0;
+ yk = y0 + y0 - 1.0;
+ radius = ((double)pGC->lineWidth) / 2.0;
+ y = floor(radius - y0 + 1.0);
+ ybase -= y;
+ ymin = ybase;
+ ymax = 65536;
+ edge1IsMin = FALSE;
+ ymin1 = edgey1;
+ if (edge1->dy >= 0)
+ {
+ if (!edge1->dy)
+ {
+ if (edgeleft1)
+ edge1IsMin = TRUE;
+ else
+ ymax = edgey1;
+ edgey1 = 65536;
+ }
+ else
+ {
+ if ((edge1->signdx < 0) == edgeleft1)
+ edge1IsMin = TRUE;
+ }
+ }
+ edge2IsMin = FALSE;
+ ymin2 = edgey2;
+ if (edge2->dy >= 0)
+ {
+ if (!edge2->dy)
+ {
+ if (edgeleft2)
+ edge2IsMin = TRUE;
+ else
+ ymax = edgey2;
+ edgey2 = 65536;
+ }
+ else
+ {
+ if ((edge2->signdx < 0) == edgeleft2)
+ edge2IsMin = TRUE;
+ }
+ }
+ if (edge1IsMin)
+ {
+ ymin = ymin1;
+ if (edge2IsMin && ymin1 > ymin2)
+ ymin = ymin2;
+ } else if (edge2IsMin)
+ ymin = ymin2;
+ el = radius * radius - ((y + y0) * (y + y0)) - (x0 * x0);
+ er = el + xrk;
+ xl = 1;
+ xr = 0;
+ if (x0 < 0.5)
+ {
+ xl = 0;
+ el -= xlk;
+ }
+ boty = (y0 < -0.5) ? 1 : 0;
+ if (ybase + y - boty > ymax)
+ boty = ymax - ybase - y;
+ while (y > boty)
+ {
+ k = (y << 1) + yk;
+ er += k;
+ while (er > 0.0)
+ {
+ xr++;
+ er += xrk - (xr << 1);
+ }
+ el += k;
+ while (el >= 0.0)
+ {
+ xl--;
+ el += (xl << 1) - xlk;
+ }
+ y--;
+ ybase++;
+ if (ybase < ymin)
+ continue;
+ xcl = xl + xbase;
+ xcr = xr + xbase;
+ CLIPSTEPEDGE(edgey1, edge1, edgeleft1);
+ CLIPSTEPEDGE(edgey2, edge2, edgeleft2);
+ if (xcr >= xcl)
+ {
+ pts->x = xcl;
+ pts->y = ybase;
+ pts++;
+ *wids++ = xcr - xcl + 1;
+ }
+ }
+ er = xrk - (xr << 1) - er;
+ el = (xl << 1) - xlk - el;
+ boty = floor(-y0 - radius + 1.0);
+ if (ybase + y - boty > ymax)
+ boty = ymax - ybase - y;
+ while (y > boty)
+ {
+ k = (y << 1) + yk;
+ er -= k;
+ while ((er >= 0.0) && (xr >= 0))
+ {
+ xr--;
+ er += xrk - (xr << 1);
+ }
+ el -= k;
+ while ((el > 0.0) && (xl <= 0))
+ {
+ xl++;
+ el += (xl << 1) - xlk;
+ }
+ y--;
+ ybase++;
+ if (ybase < ymin)
+ continue;
+ xcl = xl + xbase;
+ xcr = xr + xbase;
+ CLIPSTEPEDGE(edgey1, edge1, edgeleft1);
+ CLIPSTEPEDGE(edgey2, edge2, edgeleft2);
+ if (xcr >= xcl)
+ {
+ pts->x = xcl;
+ pts->y = ybase;
+ pts++;
+ *wids++ = xcr - xcl + 1;
+ }
+ }
+ return (pts - points);
+}
+
+int
+miRoundJoinFace (face, edge, leftEdge)
+ register LineFacePtr face;
+ register PolyEdgePtr edge;
+ Bool *leftEdge;
+{
+ int y;
+ int dx, dy;
+ double xa, ya;
+ Bool left;
+
+ dx = -face->dy;
+ dy = face->dx;
+ xa = face->xa;
+ ya = face->ya;
+ left = 1;
+ if (ya > 0)
+ {
+ ya = 0.0;
+ xa = 0.0;
+ }
+ if (dy < 0 || (dy == 0 && dx > 0))
+ {
+ dx = -dx;
+ dy = -dy;
+ left = !left;
+ }
+ if (dx == 0 && dy == 0)
+ dy = 1;
+ if (dy == 0)
+ {
+ y = ICEIL (face->ya) + face->y;
+ edge->x = -32767;
+ edge->stepx = 0;
+ edge->signdx = 0;
+ edge->e = -1;
+ edge->dy = 0;
+ edge->dx = 0;
+ edge->height = 0;
+ }
+ else
+ {
+ y = miPolyBuildEdge (xa, ya, 0.0, dx, dy, face->x, face->y, !left, edge);
+ edge->height = 32767;
+ }
+ *leftEdge = !left;
+ return y;
+}
+
+void
+miRoundJoinClip (pLeft, pRight, edge1, edge2, y1, y2, left1, left2)
+ register LineFacePtr pLeft, pRight;
+ PolyEdgePtr edge1, edge2;
+ int *y1, *y2;
+ Bool *left1, *left2;
+{
+ double denom;
+
+ denom = - pLeft->dx * (double)pRight->dy + pRight->dx * (double)pLeft->dy;
+
+ if (denom >= 0)
+ {
+ pLeft->xa = -pLeft->xa;
+ pLeft->ya = -pLeft->ya;
+ }
+ else
+ {
+ pRight->xa = -pRight->xa;
+ pRight->ya = -pRight->ya;
+ }
+ *y1 = miRoundJoinFace (pLeft, edge1, left1);
+ *y2 = miRoundJoinFace (pRight, edge2, left2);
+}
+
+int
+miRoundCapClip (face, isInt, edge, leftEdge)
+ register LineFacePtr face;
+ Bool isInt;
+ register PolyEdgePtr edge;
+ Bool *leftEdge;
+{
+ int y;
+ register int dx, dy;
+ double xa, ya, k;
+ Bool left;
+
+ dx = -face->dy;
+ dy = face->dx;
+ xa = face->xa;
+ ya = face->ya;
+ k = 0.0;
+ if (!isInt)
+ k = face->k;
+ left = 1;
+ if (dy < 0 || (dy == 0 && dx > 0))
+ {
+ dx = -dx;
+ dy = -dy;
+ xa = -xa;
+ ya = -ya;
+ left = !left;
+ }
+ if (dx == 0 && dy == 0)
+ dy = 1;
+ if (dy == 0)
+ {
+ y = ICEIL (face->ya) + face->y;
+ edge->x = -32767;
+ edge->stepx = 0;
+ edge->signdx = 0;
+ edge->e = -1;
+ edge->dy = 0;
+ edge->dx = 0;
+ edge->height = 0;
+ }
+ else
+ {
+ y = miPolyBuildEdge (xa, ya, k, dx, dy, face->x, face->y, !left, edge);
+ edge->height = 32767;
+ }
+ *leftEdge = !left;
+ return y;
+}
+
+static void
+miLineArc (
+ DrawablePtr pDraw,
+ register GCPtr pGC,
+ unsigned long pixel,
+ SpanDataPtr spanData,
+ register LineFacePtr leftFace,
+ register LineFacePtr rightFace,
+ double xorg,
+ double yorg,
+ Bool isInt)
+{
+ DDXPointPtr points;
+ int *widths;
+ int xorgi = 0, yorgi = 0;
+ XID oldPixel;
+ Spans spanRec;
+ int n;
+ PolyEdgeRec edge1, edge2;
+ int edgey1, edgey2;
+ Bool edgeleft1, edgeleft2;
+
+ if (isInt)
+ {
+ xorgi = leftFace ? leftFace->x : rightFace->x;
+ yorgi = leftFace ? leftFace->y : rightFace->y;
+ }
+ edgey1 = 65536;
+ edgey2 = 65536;
+ edge1.x = 0; /* not used, keep memory checkers happy */
+ edge1.dy = -1;
+ edge2.x = 0; /* not used, keep memory checkers happy */
+ edge2.dy = -1;
+ edgeleft1 = FALSE;
+ edgeleft2 = FALSE;
+ if ((pGC->lineStyle != LineSolid || pGC->lineWidth > 2) &&
+ ((pGC->capStyle == CapRound && pGC->joinStyle != JoinRound) ||
+ (pGC->joinStyle == JoinRound && pGC->capStyle == CapButt)))
+ {
+ if (isInt)
+ {
+ xorg = (double) xorgi;
+ yorg = (double) yorgi;
+ }
+ if (leftFace && rightFace)
+ {
+ miRoundJoinClip (leftFace, rightFace, &edge1, &edge2,
+ &edgey1, &edgey2, &edgeleft1, &edgeleft2);
+ }
+ else if (leftFace)
+ {
+ edgey1 = miRoundCapClip (leftFace, isInt, &edge1, &edgeleft1);
+ }
+ else if (rightFace)
+ {
+ edgey2 = miRoundCapClip (rightFace, isInt, &edge2, &edgeleft2);
+ }
+ isInt = FALSE;
+ }
+ if (!spanData)
+ {
+ points = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * pGC->lineWidth);
+ if (!points)
+ return;
+ widths = (int *)ALLOCATE_LOCAL(sizeof(int) * pGC->lineWidth);
+ if (!widths)
+ {
+ DEALLOCATE_LOCAL(points);
+ return;
+ }
+ oldPixel = pGC->fgPixel;
+ if (pixel != oldPixel)
+ {
+ DoChangeGC(pGC, GCForeground, (XID *)&pixel, FALSE);
+ ValidateGC (pDraw, pGC);
+ }
+ }
+ else
+ {
+ points = (DDXPointPtr) xalloc (pGC->lineWidth * sizeof (DDXPointRec));
+ if (!points)
+ return;
+ widths = (int *) xalloc (pGC->lineWidth * sizeof (int));
+ if (!widths)
+ {
+ xfree (points);
+ return;
+ }
+ spanRec.points = points;
+ spanRec.widths = widths;
+ }
+ if (isInt)
+ n = miLineArcI(pDraw, pGC, xorgi, yorgi, points, widths);
+ else
+ n = miLineArcD(pDraw, pGC, xorg, yorg, points, widths,
+ &edge1, edgey1, edgeleft1,
+ &edge2, edgey2, edgeleft2);
+
+ if (!spanData)
+ {
+ (*pGC->ops->FillSpans)(pDraw, pGC, n, points, widths, TRUE);
+ DEALLOCATE_LOCAL(widths);
+ DEALLOCATE_LOCAL(points);
+ if (pixel != oldPixel)
+ {
+ DoChangeGC(pGC, GCForeground, &oldPixel, FALSE);
+ ValidateGC (pDraw, pGC);
+ }
+ }
+ else
+ {
+ spanRec.count = n;
+ AppendSpanGroup (pGC, pixel, &spanRec, spanData)
+ }
+}
+
+void
+miLineProjectingCap (pDrawable, pGC, pixel, spanData, face, isLeft, xorg, yorg, isInt)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ unsigned long pixel;
+ SpanDataPtr spanData;
+ register LineFacePtr face;
+ Bool isLeft;
+ double xorg, yorg;
+ Bool isInt;
+{
+ int xorgi = 0, yorgi = 0;
+ int lw;
+ PolyEdgeRec lefts[2], rights[2];
+ int lefty, righty, topy, bottomy;
+ PolyEdgePtr left, right;
+ PolyEdgePtr top, bottom;
+ double xa,ya;
+ double k;
+ double xap, yap;
+ int dx, dy;
+ double projectXoff, projectYoff;
+ double maxy;
+ int finaly;
+
+ if (isInt)
+ {
+ xorgi = face->x;
+ yorgi = face->y;
+ }
+ lw = pGC->lineWidth;
+ dx = face->dx;
+ dy = face->dy;
+ k = face->k;
+ if (dy == 0)
+ {
+ lefts[0].height = lw;
+ lefts[0].x = xorgi;
+ if (isLeft)
+ lefts[0].x -= (lw >> 1);
+ lefts[0].stepx = 0;
+ lefts[0].signdx = 1;
+ lefts[0].e = -lw;
+ lefts[0].dx = 0;
+ lefts[0].dy = lw;
+ rights[0].height = lw;
+ rights[0].x = xorgi;
+ if (!isLeft)
+ rights[0].x += ((lw + 1) >> 1);
+ rights[0].stepx = 0;
+ rights[0].signdx = 1;
+ rights[0].e = -lw;
+ rights[0].dx = 0;
+ rights[0].dy = lw;
+ miFillPolyHelper (pDrawable, pGC, pixel, spanData, yorgi - (lw >> 1), lw,
+ lefts, rights, 1, 1);
+ }
+ else if (dx == 0)
+ {
+ if (dy < 0) {
+ dy = -dy;
+ isLeft = !isLeft;
+ }
+ topy = yorgi;
+ bottomy = yorgi + dy;
+ if (isLeft)
+ topy -= (lw >> 1);
+ else
+ bottomy += (lw >> 1);
+ lefts[0].height = bottomy - topy;
+ lefts[0].x = xorgi - (lw >> 1);
+ lefts[0].stepx = 0;
+ lefts[0].signdx = 1;
+ lefts[0].e = -dy;
+ lefts[0].dx = dx;
+ lefts[0].dy = dy;
+
+ rights[0].height = bottomy - topy;
+ rights[0].x = lefts[0].x + (lw-1);
+ rights[0].stepx = 0;
+ rights[0].signdx = 1;
+ rights[0].e = -dy;
+ rights[0].dx = dx;
+ rights[0].dy = dy;
+ miFillPolyHelper (pDrawable, pGC, pixel, spanData, topy, bottomy - topy, lefts, rights, 1, 1);
+ }
+ else
+ {
+ xa = face->xa;
+ ya = face->ya;
+ projectXoff = -ya;
+ projectYoff = xa;
+ if (dx < 0)
+ {
+ right = &rights[1];
+ left = &lefts[0];
+ top = &rights[0];
+ bottom = &lefts[1];
+ }
+ else
+ {
+ right = &rights[0];
+ left = &lefts[1];
+ top = &lefts[0];
+ bottom = &rights[1];
+ }
+ if (isLeft)
+ {
+ righty = miPolyBuildEdge (xa, ya,
+ k, dx, dy, xorgi, yorgi, 0, right);
+
+ xa = -xa;
+ ya = -ya;
+ k = -k;
+ lefty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff,
+ k, dx, dy, xorgi, yorgi, 1, left);
+ if (dx > 0)
+ {
+ ya = -ya;
+ xa = -xa;
+ }
+ xap = xa - projectXoff;
+ yap = ya - projectYoff;
+ topy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy,
+ -dy, dx, xorgi, yorgi, dx > 0, top);
+ bottomy = miPolyBuildEdge (xa, ya,
+ 0.0, -dy, dx, xorgi, yorgi, dx < 0, bottom);
+ maxy = -ya;
+ }
+ else
+ {
+ righty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff,
+ k, dx, dy, xorgi, yorgi, 0, right);
+
+ xa = -xa;
+ ya = -ya;
+ k = -k;
+ lefty = miPolyBuildEdge (xa, ya,
+ k, dx, dy, xorgi, yorgi, 1, left);
+ if (dx > 0)
+ {
+ ya = -ya;
+ xa = -xa;
+ }
+ xap = xa - projectXoff;
+ yap = ya - projectYoff;
+ topy = miPolyBuildEdge (xa, ya, 0.0, -dy, dx, xorgi, xorgi, dx > 0, top);
+ bottomy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy,
+ -dy, dx, xorgi, xorgi, dx < 0, bottom);
+ maxy = -ya + projectYoff;
+ }
+ finaly = ICEIL(maxy) + yorgi;
+ if (dx < 0)
+ {
+ left->height = bottomy - lefty;
+ right->height = finaly - righty;
+ top->height = righty - topy;
+ }
+ else
+ {
+ right->height = bottomy - righty;
+ left->height = finaly - lefty;
+ top->height = lefty - topy;
+ }
+ bottom->height = finaly - bottomy;
+ miFillPolyHelper (pDrawable, pGC, pixel, spanData, topy,
+ bottom->height + bottomy - topy, lefts, rights, 2, 2);
+ }
+}
+
+static void
+miWideSegment (
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ unsigned long pixel,
+ SpanDataPtr spanData,
+ register int x1,
+ register int y1,
+ register int x2,
+ register int y2,
+ Bool projectLeft,
+ Bool projectRight,
+ register LineFacePtr leftFace,
+ register LineFacePtr rightFace)
+{
+ double l, L, r;
+ double xa, ya;
+ double projectXoff = 0.0, projectYoff = 0.0;
+ double k;
+ double maxy;
+ int x, y;
+ int dx, dy;
+ int finaly;
+ PolyEdgePtr left, right;
+ PolyEdgePtr top, bottom;
+ int lefty, righty, topy, bottomy;
+ int signdx;
+ PolyEdgeRec lefts[2], rights[2];
+ LineFacePtr tface;
+ int lw = pGC->lineWidth;
+
+ /* draw top-to-bottom always */
+ if (y2 < y1 || (y2 == y1 && x2 < x1))
+ {
+ x = x1;
+ x1 = x2;
+ x2 = x;
+
+ y = y1;
+ y1 = y2;
+ y2 = y;
+
+ x = projectLeft;
+ projectLeft = projectRight;
+ projectRight = x;
+
+ tface = leftFace;
+ leftFace = rightFace;
+ rightFace = tface;
+ }
+
+ dy = y2 - y1;
+ signdx = 1;
+ dx = x2 - x1;
+ if (dx < 0)
+ signdx = -1;
+
+ leftFace->x = x1;
+ leftFace->y = y1;
+ leftFace->dx = dx;
+ leftFace->dy = dy;
+
+ rightFace->x = x2;
+ rightFace->y = y2;
+ rightFace->dx = -dx;
+ rightFace->dy = -dy;
+
+ if (dy == 0)
+ {
+ rightFace->xa = 0;
+ rightFace->ya = (double) lw / 2.0;
+ rightFace->k = -(double) (lw * dx) / 2.0;
+ leftFace->xa = 0;
+ leftFace->ya = -rightFace->ya;
+ leftFace->k = rightFace->k;
+ x = x1;
+ if (projectLeft)
+ x -= (lw >> 1);
+ y = y1 - (lw >> 1);
+ dx = x2 - x;
+ if (projectRight)
+ dx += ((lw + 1) >> 1);
+ dy = lw;
+ miFillRectPolyHelper (pDrawable, pGC, pixel, spanData,
+ x, y, dx, dy);
+ }
+ else if (dx == 0)
+ {
+ leftFace->xa = (double) lw / 2.0;
+ leftFace->ya = 0;
+ leftFace->k = (double) (lw * dy) / 2.0;
+ rightFace->xa = -leftFace->xa;
+ rightFace->ya = 0;
+ rightFace->k = leftFace->k;
+ y = y1;
+ if (projectLeft)
+ y -= lw >> 1;
+ x = x1 - (lw >> 1);
+ dy = y2 - y;
+ if (projectRight)
+ dy += ((lw + 1) >> 1);
+ dx = lw;
+ miFillRectPolyHelper (pDrawable, pGC, pixel, spanData,
+ x, y, dx, dy);
+ }
+ else
+ {
+ l = ((double) lw) / 2.0;
+ L = hypot ((double) dx, (double) dy);
+
+ if (dx < 0)
+ {
+ right = &rights[1];
+ left = &lefts[0];
+ top = &rights[0];
+ bottom = &lefts[1];
+ }
+ else
+ {
+ right = &rights[0];
+ left = &lefts[1];
+ top = &lefts[0];
+ bottom = &rights[1];
+ }
+ r = l / L;
+
+ /* coord of upper bound at integral y */
+ ya = -r * dx;
+ xa = r * dy;
+
+ if (projectLeft | projectRight)
+ {
+ projectXoff = -ya;
+ projectYoff = xa;
+ }
+
+ /* xa * dy - ya * dx */
+ k = l * L;
+
+ leftFace->xa = xa;
+ leftFace->ya = ya;
+ leftFace->k = k;
+ rightFace->xa = -xa;
+ rightFace->ya = -ya;
+ rightFace->k = k;
+
+ if (projectLeft)
+ righty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff,
+ k, dx, dy, x1, y1, 0, right);
+ else
+ righty = miPolyBuildEdge (xa, ya,
+ k, dx, dy, x1, y1, 0, right);
+
+ /* coord of lower bound at integral y */
+ ya = -ya;
+ xa = -xa;
+
+ /* xa * dy - ya * dx */
+ k = - k;
+
+ if (projectLeft)
+ lefty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff,
+ k, dx, dy, x1, y1, 1, left);
+ else
+ lefty = miPolyBuildEdge (xa, ya,
+ k, dx, dy, x1, y1, 1, left);
+
+ /* coord of top face at integral y */
+
+ if (signdx > 0)
+ {
+ ya = -ya;
+ xa = -xa;
+ }
+
+ if (projectLeft)
+ {
+ double xap = xa - projectXoff;
+ double yap = ya - projectYoff;
+ topy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy,
+ -dy, dx, x1, y1, dx > 0, top);
+ }
+ else
+ topy = miPolyBuildEdge (xa, ya, 0.0, -dy, dx, x1, y1, dx > 0, top);
+
+ /* coord of bottom face at integral y */
+
+ if (projectRight)
+ {
+ double xap = xa + projectXoff;
+ double yap = ya + projectYoff;
+ bottomy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy,
+ -dy, dx, x2, y2, dx < 0, bottom);
+ maxy = -ya + projectYoff;
+ }
+ else
+ {
+ bottomy = miPolyBuildEdge (xa, ya,
+ 0.0, -dy, dx, x2, y2, dx < 0, bottom);
+ maxy = -ya;
+ }
+
+ finaly = ICEIL (maxy) + y2;
+
+ if (dx < 0)
+ {
+ left->height = bottomy - lefty;
+ right->height = finaly - righty;
+ top->height = righty - topy;
+ }
+ else
+ {
+ right->height = bottomy - righty;
+ left->height = finaly - lefty;
+ top->height = lefty - topy;
+ }
+ bottom->height = finaly - bottomy;
+ miFillPolyHelper (pDrawable, pGC, pixel, spanData, topy,
+ bottom->height + bottomy - topy, lefts, rights, 2, 2);
+ }
+}
+
+SpanDataPtr
+miSetupSpanData (pGC, spanData, npt)
+ register GCPtr pGC;
+ SpanDataPtr spanData;
+ int npt;
+{
+ if ((npt < 3 && pGC->capStyle != CapRound) || miSpansEasyRop(pGC->alu))
+ return (SpanDataPtr) NULL;
+ if (pGC->lineStyle == LineDoubleDash)
+ miInitSpanGroup (&spanData->bgGroup);
+ miInitSpanGroup (&spanData->fgGroup);
+ return spanData;
+}
+
+void
+miCleanupSpanData (pDrawable, pGC, spanData)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ SpanDataPtr spanData;
+{
+ if (pGC->lineStyle == LineDoubleDash)
+ {
+ XID oldPixel, pixel;
+
+ pixel = pGC->bgPixel;
+ oldPixel = pGC->fgPixel;
+ if (pixel != oldPixel)
+ {
+ DoChangeGC (pGC, GCForeground, &pixel, FALSE);
+ ValidateGC (pDrawable, pGC);
+ }
+ miFillUniqueSpanGroup (pDrawable, pGC, &spanData->bgGroup);
+ miFreeSpanGroup (&spanData->bgGroup);
+ if (pixel != oldPixel)
+ {
+ DoChangeGC (pGC, GCForeground, &oldPixel, FALSE);
+ ValidateGC (pDrawable, pGC);
+ }
+ }
+ miFillUniqueSpanGroup (pDrawable, pGC, &spanData->fgGroup);
+ miFreeSpanGroup (&spanData->fgGroup);
+}
+
+void
+miWideLine (pDrawable, pGC, mode, npt, pPts)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int mode;
+ register int npt;
+ register DDXPointPtr pPts;
+{
+ int x1, y1, x2, y2;
+ SpanDataRec spanDataRec;
+ SpanDataPtr spanData;
+ unsigned long pixel;
+ Bool projectLeft, projectRight;
+ LineFaceRec leftFace, rightFace, prevRightFace;
+ LineFaceRec firstFace;
+ register int first;
+ Bool somethingDrawn = FALSE;
+ Bool selfJoin;
+
+ spanData = miSetupSpanData (pGC, &spanDataRec, npt);
+ pixel = pGC->fgPixel;
+ x2 = pPts->x;
+ y2 = pPts->y;
+ first = TRUE;
+ selfJoin = FALSE;
+ if (npt > 1)
+ {
+ if (mode == CoordModePrevious)
+ {
+ int nptTmp;
+ DDXPointPtr pPtsTmp;
+
+ x1 = x2;
+ y1 = y2;
+ nptTmp = npt;
+ pPtsTmp = pPts + 1;
+ while (--nptTmp)
+ {
+ x1 += pPtsTmp->x;
+ y1 += pPtsTmp->y;
+ ++pPtsTmp;
+ }
+ if (x2 == x1 && y2 == y1)
+ selfJoin = TRUE;
+ }
+ else if (x2 == pPts[npt-1].x && y2 == pPts[npt-1].y)
+ {
+ selfJoin = TRUE;
+ }
+ }
+ projectLeft = pGC->capStyle == CapProjecting && !selfJoin;
+ projectRight = FALSE;
+ while (--npt)
+ {
+ x1 = x2;
+ y1 = y2;
+ ++pPts;
+ x2 = pPts->x;
+ y2 = pPts->y;
+ if (mode == CoordModePrevious)
+ {
+ x2 += x1;
+ y2 += y1;
+ }
+ if (x1 != x2 || y1 != y2)
+ {
+ somethingDrawn = TRUE;
+ if (npt == 1 && pGC->capStyle == CapProjecting && !selfJoin)
+ projectRight = TRUE;
+ miWideSegment (pDrawable, pGC, pixel, spanData, x1, y1, x2, y2,
+ projectLeft, projectRight, &leftFace, &rightFace);
+ if (first)
+ {
+ if (selfJoin)
+ firstFace = leftFace;
+ else if (pGC->capStyle == CapRound)
+ {
+ if (pGC->lineWidth == 1 && !spanData)
+ miLineOnePoint (pDrawable, pGC, pixel, spanData, x1, y1);
+ else
+ miLineArc (pDrawable, pGC, pixel, spanData,
+ &leftFace, (LineFacePtr) NULL,
+ (double)0.0, (double)0.0,
+ TRUE);
+ }
+ }
+ else
+ {
+ miLineJoin (pDrawable, pGC, pixel, spanData, &leftFace,
+ &prevRightFace);
+ }
+ prevRightFace = rightFace;
+ first = FALSE;
+ projectLeft = FALSE;
+ }
+ if (npt == 1 && somethingDrawn)
+ {
+ if (selfJoin)
+ miLineJoin (pDrawable, pGC, pixel, spanData, &firstFace,
+ &rightFace);
+ else if (pGC->capStyle == CapRound)
+ {
+ if (pGC->lineWidth == 1 && !spanData)
+ miLineOnePoint (pDrawable, pGC, pixel, spanData, x2, y2);
+ else
+ miLineArc (pDrawable, pGC, pixel, spanData,
+ (LineFacePtr) NULL, &rightFace,
+ (double)0.0, (double)0.0,
+ TRUE);
+ }
+ }
+ }
+ /* handle crock where all points are coincedent */
+ if (!somethingDrawn)
+ {
+ projectLeft = pGC->capStyle == CapProjecting;
+ miWideSegment (pDrawable, pGC, pixel, spanData,
+ x2, y2, x2, y2, projectLeft, projectLeft,
+ &leftFace, &rightFace);
+ if (pGC->capStyle == CapRound)
+ {
+ miLineArc (pDrawable, pGC, pixel, spanData,
+ &leftFace, (LineFacePtr) NULL,
+ (double)0.0, (double)0.0,
+ TRUE);
+ rightFace.dx = -1; /* sleezy hack to make it work */
+ miLineArc (pDrawable, pGC, pixel, spanData,
+ (LineFacePtr) NULL, &rightFace,
+ (double)0.0, (double)0.0,
+ TRUE);
+ }
+ }
+ if (spanData)
+ miCleanupSpanData (pDrawable, pGC, spanData);
+}
+
+#define V_TOP 0
+#define V_RIGHT 1
+#define V_BOTTOM 2
+#define V_LEFT 3
+
+static void
+miWideDashSegment (
+ DrawablePtr pDrawable,
+ register GCPtr pGC,
+ SpanDataPtr spanData,
+ int *pDashOffset,
+ int *pDashIndex,
+ int x1,
+ int y1,
+ int x2,
+ int y2,
+ Bool projectLeft,
+ Bool projectRight,
+ LineFacePtr leftFace,
+ LineFacePtr rightFace)
+{
+ int dashIndex, dashRemain;
+ unsigned char *pDash;
+ double L, l;
+ double k;
+ PolyVertexRec vertices[4];
+ PolyVertexRec saveRight, saveBottom;
+ PolySlopeRec slopes[4];
+ PolyEdgeRec left[2], right[2];
+ LineFaceRec lcapFace, rcapFace;
+ int nleft, nright;
+ int h;
+ int y;
+ int dy, dx;
+ unsigned long pixel;
+ double LRemain;
+ double r;
+ double rdx, rdy;
+ double dashDx, dashDy;
+ double saveK = 0.0;
+ Bool first = TRUE;
+ double lcenterx, lcentery, rcenterx = 0.0, rcentery = 0.0;
+ unsigned long fgPixel, bgPixel;
+
+ dx = x2 - x1;
+ dy = y2 - y1;
+ dashIndex = *pDashIndex;
+ pDash = pGC->dash;
+ dashRemain = pDash[dashIndex] - *pDashOffset;
+ fgPixel = pGC->fgPixel;
+ bgPixel = pGC->bgPixel;
+ if (pGC->fillStyle == FillOpaqueStippled ||
+ pGC->fillStyle == FillTiled)
+ {
+ bgPixel = fgPixel;
+ }
+
+ l = ((double) pGC->lineWidth) / 2.0;
+ if (dx == 0)
+ {
+ L = dy;
+ rdx = 0;
+ rdy = l;
+ if (dy < 0)
+ {
+ L = -dy;
+ rdy = -l;
+ }
+ }
+ else if (dy == 0)
+ {
+ L = dx;
+ rdx = l;
+ rdy = 0;
+ if (dx < 0)
+ {
+ L = -dx;
+ rdx = -l;
+ }
+ }
+ else
+ {
+ L = hypot ((double) dx, (double) dy);
+ r = l / L;
+
+ rdx = r * dx;
+ rdy = r * dy;
+ }
+ k = l * L;
+ LRemain = L;
+ /* All position comments are relative to a line with dx and dy > 0,
+ * but the code does not depend on this */
+ /* top */
+ slopes[V_TOP].dx = dx;
+ slopes[V_TOP].dy = dy;
+ slopes[V_TOP].k = k;
+ /* right */
+ slopes[V_RIGHT].dx = -dy;
+ slopes[V_RIGHT].dy = dx;
+ slopes[V_RIGHT].k = 0;
+ /* bottom */
+ slopes[V_BOTTOM].dx = -dx;
+ slopes[V_BOTTOM].dy = -dy;
+ slopes[V_BOTTOM].k = k;
+ /* left */
+ slopes[V_LEFT].dx = dy;
+ slopes[V_LEFT].dy = -dx;
+ slopes[V_LEFT].k = 0;
+
+ /* preload the start coordinates */
+ vertices[V_RIGHT].x = vertices[V_TOP].x = rdy;
+ vertices[V_RIGHT].y = vertices[V_TOP].y = -rdx;
+
+ vertices[V_BOTTOM].x = vertices[V_LEFT].x = -rdy;
+ vertices[V_BOTTOM].y = vertices[V_LEFT].y = rdx;
+
+ if (projectLeft)
+ {
+ vertices[V_TOP].x -= rdx;
+ vertices[V_TOP].y -= rdy;
+
+ vertices[V_LEFT].x -= rdx;
+ vertices[V_LEFT].y -= rdy;
+
+ slopes[V_LEFT].k = rdx * dx + rdy * dy;
+ }
+
+ lcenterx = x1;
+ lcentery = y1;
+
+ if (pGC->capStyle == CapRound)
+ {
+ lcapFace.dx = dx;
+ lcapFace.dy = dy;
+ lcapFace.x = x1;
+ lcapFace.y = y1;
+
+ rcapFace.dx = -dx;
+ rcapFace.dy = -dy;
+ rcapFace.x = x1;
+ rcapFace.y = y1;
+ }
+ while (LRemain > dashRemain)
+ {
+ dashDx = (dashRemain * dx) / L;
+ dashDy = (dashRemain * dy) / L;
+
+ rcenterx = lcenterx + dashDx;
+ rcentery = lcentery + dashDy;
+
+ vertices[V_RIGHT].x += dashDx;
+ vertices[V_RIGHT].y += dashDy;
+
+ vertices[V_BOTTOM].x += dashDx;
+ vertices[V_BOTTOM].y += dashDy;
+
+ slopes[V_RIGHT].k = vertices[V_RIGHT].x * dx + vertices[V_RIGHT].y * dy;
+
+ if (pGC->lineStyle == LineDoubleDash || !(dashIndex & 1))
+ {
+ if (pGC->lineStyle == LineOnOffDash &&
+ pGC->capStyle == CapProjecting)
+ {
+ saveRight = vertices[V_RIGHT];
+ saveBottom = vertices[V_BOTTOM];
+ saveK = slopes[V_RIGHT].k;
+
+ if (!first)
+ {
+ vertices[V_TOP].x -= rdx;
+ vertices[V_TOP].y -= rdy;
+
+ vertices[V_LEFT].x -= rdx;
+ vertices[V_LEFT].y -= rdy;
+
+ slopes[V_LEFT].k = vertices[V_LEFT].x *
+ slopes[V_LEFT].dy -
+ vertices[V_LEFT].y *
+ slopes[V_LEFT].dx;
+ }
+
+ vertices[V_RIGHT].x += rdx;
+ vertices[V_RIGHT].y += rdy;
+
+ vertices[V_BOTTOM].x += rdx;
+ vertices[V_BOTTOM].y += rdy;
+
+ slopes[V_RIGHT].k = vertices[V_RIGHT].x *
+ slopes[V_RIGHT].dy -
+ vertices[V_RIGHT].y *
+ slopes[V_RIGHT].dx;
+ }
+ y = miPolyBuildPoly (vertices, slopes, 4, x1, y1,
+ left, right, &nleft, &nright, &h);
+ pixel = (dashIndex & 1) ? bgPixel : fgPixel;
+ miFillPolyHelper (pDrawable, pGC, pixel, spanData, y, h, left, right, nleft, nright);
+
+ if (pGC->lineStyle == LineOnOffDash)
+ {
+ switch (pGC->capStyle)
+ {
+ case CapProjecting:
+ vertices[V_BOTTOM] = saveBottom;
+ vertices[V_RIGHT] = saveRight;
+ slopes[V_RIGHT].k = saveK;
+ break;
+ case CapRound:
+ if (!first)
+ {
+ if (dx < 0)
+ {
+ lcapFace.xa = -vertices[V_LEFT].x;
+ lcapFace.ya = -vertices[V_LEFT].y;
+ lcapFace.k = slopes[V_LEFT].k;
+ }
+ else
+ {
+ lcapFace.xa = vertices[V_TOP].x;
+ lcapFace.ya = vertices[V_TOP].y;
+ lcapFace.k = -slopes[V_LEFT].k;
+ }
+ miLineArc (pDrawable, pGC, pixel, spanData,
+ &lcapFace, (LineFacePtr) NULL,
+ lcenterx, lcentery, FALSE);
+ }
+ if (dx < 0)
+ {
+ rcapFace.xa = vertices[V_BOTTOM].x;
+ rcapFace.ya = vertices[V_BOTTOM].y;
+ rcapFace.k = slopes[V_RIGHT].k;
+ }
+ else
+ {
+ rcapFace.xa = -vertices[V_RIGHT].x;
+ rcapFace.ya = -vertices[V_RIGHT].y;
+ rcapFace.k = -slopes[V_RIGHT].k;
+ }
+ miLineArc (pDrawable, pGC, pixel, spanData,
+ (LineFacePtr) NULL, &rcapFace,
+ rcenterx, rcentery, FALSE);
+ break;
+ }
+ }
+ }
+ LRemain -= dashRemain;
+ ++dashIndex;
+ if (dashIndex == pGC->numInDashList)
+ dashIndex = 0;
+ dashRemain = pDash[dashIndex];
+
+ lcenterx = rcenterx;
+ lcentery = rcentery;
+
+ vertices[V_TOP] = vertices[V_RIGHT];
+ vertices[V_LEFT] = vertices[V_BOTTOM];
+ slopes[V_LEFT].k = -slopes[V_RIGHT].k;
+ first = FALSE;
+ }
+
+ if (pGC->lineStyle == LineDoubleDash || !(dashIndex & 1))
+ {
+ vertices[V_TOP].x -= dx;
+ vertices[V_TOP].y -= dy;
+
+ vertices[V_LEFT].x -= dx;
+ vertices[V_LEFT].y -= dy;
+
+ vertices[V_RIGHT].x = rdy;
+ vertices[V_RIGHT].y = -rdx;
+
+ vertices[V_BOTTOM].x = -rdy;
+ vertices[V_BOTTOM].y = rdx;
+
+
+ if (projectRight)
+ {
+ vertices[V_RIGHT].x += rdx;
+ vertices[V_RIGHT].y += rdy;
+
+ vertices[V_BOTTOM].x += rdx;
+ vertices[V_BOTTOM].y += rdy;
+ slopes[V_RIGHT].k = vertices[V_RIGHT].x *
+ slopes[V_RIGHT].dy -
+ vertices[V_RIGHT].y *
+ slopes[V_RIGHT].dx;
+ }
+ else
+ slopes[V_RIGHT].k = 0;
+
+ if (!first && pGC->lineStyle == LineOnOffDash &&
+ pGC->capStyle == CapProjecting)
+ {
+ vertices[V_TOP].x -= rdx;
+ vertices[V_TOP].y -= rdy;
+
+ vertices[V_LEFT].x -= rdx;
+ vertices[V_LEFT].y -= rdy;
+ slopes[V_LEFT].k = vertices[V_LEFT].x *
+ slopes[V_LEFT].dy -
+ vertices[V_LEFT].y *
+ slopes[V_LEFT].dx;
+ }
+ else
+ slopes[V_LEFT].k += dx * dx + dy * dy;
+
+
+ y = miPolyBuildPoly (vertices, slopes, 4, x2, y2,
+ left, right, &nleft, &nright, &h);
+
+ pixel = (dashIndex & 1) ? pGC->bgPixel : pGC->fgPixel;
+ miFillPolyHelper (pDrawable, pGC, pixel, spanData, y, h, left, right, nleft, nright);
+ if (!first && pGC->lineStyle == LineOnOffDash &&
+ pGC->capStyle == CapRound)
+ {
+ lcapFace.x = x2;
+ lcapFace.y = y2;
+ if (dx < 0)
+ {
+ lcapFace.xa = -vertices[V_LEFT].x;
+ lcapFace.ya = -vertices[V_LEFT].y;
+ lcapFace.k = slopes[V_LEFT].k;
+ }
+ else
+ {
+ lcapFace.xa = vertices[V_TOP].x;
+ lcapFace.ya = vertices[V_TOP].y;
+ lcapFace.k = -slopes[V_LEFT].k;
+ }
+ miLineArc (pDrawable, pGC, pixel, spanData,
+ &lcapFace, (LineFacePtr) NULL,
+ rcenterx, rcentery, FALSE);
+ }
+ }
+ dashRemain = ((double) dashRemain) - LRemain;
+ if (dashRemain == 0)
+ {
+ dashIndex++;
+ if (dashIndex == pGC->numInDashList)
+ dashIndex = 0;
+ dashRemain = pDash[dashIndex];
+ }
+
+ leftFace->x = x1;
+ leftFace->y = y1;
+ leftFace->dx = dx;
+ leftFace->dy = dy;
+ leftFace->xa = rdy;
+ leftFace->ya = -rdx;
+ leftFace->k = k;
+
+ rightFace->x = x2;
+ rightFace->y = y2;
+ rightFace->dx = -dx;
+ rightFace->dy = -dy;
+ rightFace->xa = -rdy;
+ rightFace->ya = rdx;
+ rightFace->k = k;
+
+ *pDashIndex = dashIndex;
+ *pDashOffset = pDash[dashIndex] - dashRemain;
+}
+
+void
+miWideDash (pDrawable, pGC, mode, npt, pPts)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int mode;
+ register int npt;
+ register DDXPointPtr pPts;
+{
+ int x1, y1, x2, y2;
+ unsigned long pixel;
+ Bool projectLeft, projectRight;
+ LineFaceRec leftFace, rightFace, prevRightFace;
+ LineFaceRec firstFace;
+ int first;
+ int dashIndex, dashOffset;
+ register int prevDashIndex;
+ SpanDataRec spanDataRec;
+ SpanDataPtr spanData;
+ Bool somethingDrawn = FALSE;
+ Bool selfJoin;
+ Bool endIsFg = FALSE, startIsFg = FALSE;
+ Bool firstIsFg = FALSE, prevIsFg = FALSE;
+
+#ifndef XFree86Server
+ /* XXX backward compatibility */
+ if (pGC->lineWidth == 0)
+ {
+ miZeroDashLine (pDrawable, pGC, mode, npt, pPts);
+ return;
+ }
+#endif
+ if (pGC->lineStyle == LineDoubleDash &&
+ (pGC->fillStyle == FillOpaqueStippled || pGC->fillStyle == FillTiled))
+ {
+ miWideLine (pDrawable, pGC, mode, npt, pPts);
+ return;
+ }
+ if (npt == 0)
+ return;
+ spanData = miSetupSpanData (pGC, &spanDataRec, npt);
+ x2 = pPts->x;
+ y2 = pPts->y;
+ first = TRUE;
+ selfJoin = FALSE;
+ if (mode == CoordModePrevious)
+ {
+ int nptTmp;
+ DDXPointPtr pPtsTmp;
+
+ x1 = x2;
+ y1 = y2;
+ nptTmp = npt;
+ pPtsTmp = pPts + 1;
+ while (--nptTmp)
+ {
+ x1 += pPtsTmp->x;
+ y1 += pPtsTmp->y;
+ ++pPtsTmp;
+ }
+ if (x2 == x1 && y2 == y1)
+ selfJoin = TRUE;
+ }
+ else if (x2 == pPts[npt-1].x && y2 == pPts[npt-1].y)
+ {
+ selfJoin = TRUE;
+ }
+ projectLeft = pGC->capStyle == CapProjecting && !selfJoin;
+ projectRight = FALSE;
+ dashIndex = 0;
+ dashOffset = 0;
+ miStepDash ((int)pGC->dashOffset, &dashIndex,
+ pGC->dash, (int)pGC->numInDashList, &dashOffset);
+ while (--npt)
+ {
+ x1 = x2;
+ y1 = y2;
+ ++pPts;
+ x2 = pPts->x;
+ y2 = pPts->y;
+ if (mode == CoordModePrevious)
+ {
+ x2 += x1;
+ y2 += y1;
+ }
+ if (x1 != x2 || y1 != y2)
+ {
+ somethingDrawn = TRUE;
+ if (npt == 1 && pGC->capStyle == CapProjecting &&
+ (!selfJoin || !firstIsFg))
+ projectRight = TRUE;
+ prevDashIndex = dashIndex;
+ miWideDashSegment (pDrawable, pGC, spanData, &dashOffset, &dashIndex,
+ x1, y1, x2, y2,
+ projectLeft, projectRight, &leftFace, &rightFace);
+ startIsFg = !(prevDashIndex & 1);
+ endIsFg = (dashIndex & 1) ^ (dashOffset != 0);
+ if (pGC->lineStyle == LineDoubleDash || startIsFg)
+ {
+ pixel = startIsFg ? pGC->fgPixel : pGC->bgPixel;
+ if (first || (pGC->lineStyle == LineOnOffDash && !prevIsFg))
+ {
+ if (first && selfJoin)
+ {
+ firstFace = leftFace;
+ firstIsFg = startIsFg;
+ }
+ else if (pGC->capStyle == CapRound)
+ miLineArc (pDrawable, pGC, pixel, spanData,
+ &leftFace, (LineFacePtr) NULL,
+ (double)0.0, (double)0.0, TRUE);
+ }
+ else
+ {
+ miLineJoin (pDrawable, pGC, pixel, spanData, &leftFace,
+ &prevRightFace);
+ }
+ }
+ prevRightFace = rightFace;
+ prevIsFg = endIsFg;
+ first = FALSE;
+ projectLeft = FALSE;
+ }
+ if (npt == 1 && somethingDrawn)
+ {
+ if (pGC->lineStyle == LineDoubleDash || endIsFg)
+ {
+ pixel = endIsFg ? pGC->fgPixel : pGC->bgPixel;
+ if (selfJoin && (pGC->lineStyle == LineDoubleDash || firstIsFg))
+ {
+ miLineJoin (pDrawable, pGC, pixel, spanData, &firstFace,
+ &rightFace);
+ }
+ else
+ {
+ if (pGC->capStyle == CapRound)
+ miLineArc (pDrawable, pGC, pixel, spanData,
+ (LineFacePtr) NULL, &rightFace,
+ (double)0.0, (double)0.0, TRUE);
+ }
+ }
+ else
+ {
+ /* glue a cap to the start of the line if
+ * we're OnOffDash and ended on odd dash
+ */
+ if (selfJoin && firstIsFg)
+ {
+ pixel = pGC->fgPixel;
+ if (pGC->capStyle == CapProjecting)
+ miLineProjectingCap (pDrawable, pGC, pixel, spanData,
+ &firstFace, TRUE,
+ (double)0.0, (double)0.0, TRUE);
+ else if (pGC->capStyle == CapRound)
+ miLineArc (pDrawable, pGC, pixel, spanData,
+ &firstFace, (LineFacePtr) NULL,
+ (double)0.0, (double)0.0, TRUE);
+ }
+ }
+ }
+ }
+ /* handle crock where all points are coincident */
+ if (!somethingDrawn && (pGC->lineStyle == LineDoubleDash || !(dashIndex & 1)))
+ {
+ /* not the same as endIsFg computation above */
+ pixel = (dashIndex & 1) ? pGC->bgPixel : pGC->fgPixel;
+ switch (pGC->capStyle) {
+ case CapRound:
+ miLineArc (pDrawable, pGC, pixel, spanData,
+ (LineFacePtr) NULL, (LineFacePtr) NULL,
+ (double)x2, (double)y2,
+ FALSE);
+ break;
+ case CapProjecting:
+ x1 = pGC->lineWidth;
+ miFillRectPolyHelper (pDrawable, pGC, pixel, spanData,
+ x2 - (x1 >> 1), y2 - (x1 >> 1), x1, x1);
+ break;
+ }
+ }
+ if (spanData)
+ miCleanupSpanData (pDrawable, pGC, spanData);
+}
+
+/* these are stubs to allow old ddx ValidateGCs to work without change */
+
+void
+miMiter()
+{
+}
+
+void
+miNotMiter()
+{
+}
diff --git a/nx-X11/programs/Xserver/mi/miwideline.h b/nx-X11/programs/Xserver/mi/miwideline.h
new file mode 100644
index 000000000..96d6aae86
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/miwideline.h
@@ -0,0 +1,224 @@
+/* $Xorg: miwideline.h,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
+/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/mi/miwideline.h,v 1.11 2001/10/25 12:03:47 alanh Exp $ */
+
+/* Author: Keith Packard, MIT X Consortium */
+
+#include "mispans.h"
+#include "mifpoly.h" /* for ICEIL */
+
+/*
+ * interface data to span-merging polygon filler
+ */
+
+typedef struct _SpanData {
+ SpanGroup fgGroup, bgGroup;
+} SpanDataRec, *SpanDataPtr;
+
+#define AppendSpanGroup(pGC, pixel, spanPtr, spanData) { \
+ SpanGroup *group, *othergroup = NULL; \
+ if (pixel == pGC->fgPixel) \
+ { \
+ group = &spanData->fgGroup; \
+ if (pGC->lineStyle == LineDoubleDash) \
+ othergroup = &spanData->bgGroup; \
+ } \
+ else \
+ { \
+ group = &spanData->bgGroup; \
+ othergroup = &spanData->fgGroup; \
+ } \
+ miAppendSpans (group, othergroup, spanPtr); \
+}
+
+/*
+ * Polygon edge description for integer wide-line routines
+ */
+
+typedef struct _PolyEdge {
+ int height; /* number of scanlines to process */
+ int x; /* starting x coordinate */
+ int stepx; /* fixed integral dx */
+ int signdx; /* variable dx sign */
+ int e; /* initial error term */
+ int dy;
+ int dx;
+} PolyEdgeRec, *PolyEdgePtr;
+
+#define SQSECANT 108.856472512142 /* 1/sin^2(11/2) - miter limit constant */
+
+/*
+ * types for general polygon routines
+ */
+
+typedef struct _PolyVertex {
+ double x, y;
+} PolyVertexRec, *PolyVertexPtr;
+
+typedef struct _PolySlope {
+ int dx, dy;
+ double k; /* x0 * dy - y0 * dx */
+} PolySlopeRec, *PolySlopePtr;
+
+/*
+ * Line face description for caps/joins
+ */
+
+typedef struct _LineFace {
+ double xa, ya;
+ int dx, dy;
+ int x, y;
+ double k;
+} LineFaceRec, *LineFacePtr;
+
+/*
+ * macros for polygon fillers
+ */
+
+#define MIPOLYRELOADLEFT if (!left_height && left_count) { \
+ left_height = left->height; \
+ left_x = left->x; \
+ left_stepx = left->stepx; \
+ left_signdx = left->signdx; \
+ left_e = left->e; \
+ left_dy = left->dy; \
+ left_dx = left->dx; \
+ --left_count; \
+ ++left; \
+ }
+
+#define MIPOLYRELOADRIGHT if (!right_height && right_count) { \
+ right_height = right->height; \
+ right_x = right->x; \
+ right_stepx = right->stepx; \
+ right_signdx = right->signdx; \
+ right_e = right->e; \
+ right_dy = right->dy; \
+ right_dx = right->dx; \
+ --right_count; \
+ ++right; \
+ }
+
+#define MIPOLYSTEPLEFT left_x += left_stepx; \
+ left_e += left_dx; \
+ if (left_e > 0) \
+ { \
+ left_x += left_signdx; \
+ left_e -= left_dy; \
+ }
+
+#define MIPOLYSTEPRIGHT right_x += right_stepx; \
+ right_e += right_dx; \
+ if (right_e > 0) \
+ { \
+ right_x += right_signdx; \
+ right_e -= right_dy; \
+ }
+
+#define MILINESETPIXEL(pDrawable, pGC, pixel, oldPixel) { \
+ oldPixel = pGC->fgPixel; \
+ if (pixel != oldPixel) { \
+ DoChangeGC (pGC, GCForeground, (XID *) &pixel, FALSE); \
+ ValidateGC (pDrawable, pGC); \
+ } \
+}
+#define MILINERESETPIXEL(pDrawable, pGC, pixel, oldPixel) { \
+ if (pixel != oldPixel) { \
+ DoChangeGC (pGC, GCForeground, (XID *) &oldPixel, FALSE); \
+ ValidateGC (pDrawable, pGC); \
+ } \
+}
+
+extern void miFillPolyHelper(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ unsigned long /*pixel*/,
+ SpanDataPtr /*spanData*/,
+ int /*y*/,
+ int /*overall_height*/,
+ PolyEdgePtr /*left*/,
+ PolyEdgePtr /*right*/,
+ int /*left_count*/,
+ int /*right_count*/
+);
+extern int miRoundJoinFace(
+ LineFacePtr /*face*/,
+ PolyEdgePtr /*edge*/,
+ Bool * /*leftEdge*/
+);
+
+extern void miRoundJoinClip(
+ LineFacePtr /*pLeft*/,
+ LineFacePtr /*pRight*/,
+ PolyEdgePtr /*edge1*/,
+ PolyEdgePtr /*edge2*/,
+ int * /*y1*/,
+ int * /*y2*/,
+ Bool * /*left1*/,
+ Bool * /*left2*/
+);
+
+extern int miRoundCapClip(
+ LineFacePtr /*face*/,
+ Bool /*isInt*/,
+ PolyEdgePtr /*edge*/,
+ Bool * /*leftEdge*/
+);
+
+extern void miLineProjectingCap(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ unsigned long /*pixel*/,
+ SpanDataPtr /*spanData*/,
+ LineFacePtr /*face*/,
+ Bool /*isLeft*/,
+ double /*xorg*/,
+ double /*yorg*/,
+ Bool /*isInt*/
+);
+
+extern SpanDataPtr miSetupSpanData(
+ GCPtr /*pGC*/,
+ SpanDataPtr /*spanData*/,
+ int /*npt*/
+);
+
+extern void miCleanupSpanData(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ SpanDataPtr /*spanData*/
+);
+
+extern int miPolyBuildEdge(double x0, double y0, double k, int dx, int dy,
+ int xi, int yi, int left, PolyEdgePtr edge);
+extern int miPolyBuildPoly(PolyVertexPtr vertices, PolySlopePtr slopes,
+ int count, int xi, int yi, PolyEdgePtr left,
+ PolyEdgePtr right, int *pnleft, int *pnright,
+ int *h);
+
diff --git a/nx-X11/programs/Xserver/mi/miwindow.c b/nx-X11/programs/Xserver/mi/miwindow.c
new file mode 100644
index 000000000..280d0f8eb
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/miwindow.c
@@ -0,0 +1,1184 @@
+/* $XFree86: xc/programs/Xserver/mi/miwindow.c,v 1.9tsi Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: miwindow.c,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "regionstr.h"
+#include "region.h"
+#include "mi.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "mivalidate.h"
+
+void
+miClearToBackground(pWin, x, y, w, h, generateExposures)
+ WindowPtr pWin;
+ int x,y;
+ int w,h;
+ Bool generateExposures;
+{
+ BoxRec box;
+ RegionRec reg;
+ RegionPtr pBSReg = NullRegion;
+ ScreenPtr pScreen;
+ BoxPtr extents;
+ int x1, y1, x2, y2;
+
+ /* compute everything using ints to avoid overflow */
+
+ x1 = pWin->drawable.x + x;
+ y1 = pWin->drawable.y + y;
+ if (w)
+ x2 = x1 + (int) w;
+ else
+ x2 = x1 + (int) pWin->drawable.width - (int) x;
+ if (h)
+ y2 = y1 + h;
+ else
+ y2 = y1 + (int) pWin->drawable.height - (int) y;
+
+ extents = &pWin->clipList.extents;
+
+ /* clip the resulting rectangle to the window clipList extents. This
+ * makes sure that the result will fit in a box, given that the
+ * screen is < 32768 on a side.
+ */
+
+ if (x1 < extents->x1)
+ x1 = extents->x1;
+ if (x2 > extents->x2)
+ x2 = extents->x2;
+ if (y1 < extents->y1)
+ y1 = extents->y1;
+ if (y2 > extents->y2)
+ y2 = extents->y2;
+
+ if (x2 <= x1 || y2 <= y1)
+ {
+ x2 = x1 = 0;
+ y2 = y1 = 0;
+ }
+
+ box.x1 = x1;
+ box.x2 = x2;
+ box.y1 = y1;
+ box.y2 = y2;
+
+ pScreen = pWin->drawable.pScreen;
+ REGION_INIT(pScreen, &reg, &box, 1);
+ if (pWin->backStorage)
+ {
+ /*
+ * If the window has backing-store on, call through the
+ * ClearToBackground vector to handle the special semantics
+ * (i.e. things backing store is to be cleared out and
+ * an Expose event is to be generated for those areas in backing
+ * store if generateExposures is TRUE).
+ */
+ pBSReg = (* pScreen->ClearBackingStore)(pWin, x, y, w, h,
+ generateExposures);
+ }
+
+ REGION_INTERSECT(pScreen, &reg, &reg, &pWin->clipList);
+ if (generateExposures)
+ (*pScreen->WindowExposures)(pWin, &reg, pBSReg);
+ else if (pWin->backgroundState != None)
+ (*pScreen->PaintWindowBackground)(pWin, &reg, PW_BACKGROUND);
+ REGION_UNINIT(pScreen, &reg);
+ if (pBSReg)
+ REGION_DESTROY(pScreen, pBSReg);
+}
+
+/*
+ * For SaveUnders using backing-store. The idea is that when a window is mapped
+ * with saveUnder set TRUE, any windows it obscures will have its backing
+ * store turned on setting the DIXsaveUnder bit,
+ * The backing-store code must be written to allow for this
+ */
+
+/*-
+ *-----------------------------------------------------------------------
+ * miCheckSubSaveUnder --
+ * Check all the inferiors of a window for coverage by saveUnder
+ * windows. Called from ChangeSaveUnder and CheckSaveUnder.
+ * This code is very inefficient.
+ *
+ * Results:
+ * TRUE if any windows need to have backing-store removed.
+ *
+ * Side Effects:
+ * Windows may have backing-store turned on or off.
+ *
+ *-----------------------------------------------------------------------
+ */
+static Bool
+miCheckSubSaveUnder(
+ register WindowPtr pParent, /* Parent to check */
+ WindowPtr pFirst, /* first reconfigured window */
+ RegionPtr pRegion) /* Initial area obscured by saveUnder */
+{
+ register WindowPtr pChild; /* Current child */
+ register ScreenPtr pScreen; /* Screen to use */
+ RegionRec SubRegion; /* Area of children obscured */
+ Bool res = FALSE; /* result */
+ Bool subInited=FALSE;/* SubRegion initialized */
+
+ pScreen = pParent->drawable.pScreen;
+ if ( (pChild = pParent->firstChild) )
+ {
+ /*
+ * build region above first changed window
+ */
+
+ for (; pChild != pFirst; pChild = pChild->nextSib)
+ if (pChild->viewable && pChild->saveUnder)
+ REGION_UNION(pScreen, pRegion, pRegion, &pChild->borderSize);
+
+ /*
+ * check region below and including first changed window
+ */
+
+ for (; pChild; pChild = pChild->nextSib)
+ {
+ if (pChild->viewable)
+ {
+ /*
+ * don't save under nephew/niece windows;
+ * use a separate region
+ */
+
+ if (pChild->firstChild)
+ {
+ if (!subInited)
+ {
+ REGION_NULL(pScreen, &SubRegion);
+ subInited = TRUE;
+ }
+ REGION_COPY(pScreen, &SubRegion, pRegion);
+ res |= miCheckSubSaveUnder(pChild, pChild->firstChild,
+ &SubRegion);
+ }
+ else
+ {
+ res |= miCheckSubSaveUnder(pChild, pChild->firstChild,
+ pRegion);
+ }
+
+ if (pChild->saveUnder)
+ REGION_UNION(pScreen, pRegion, pRegion, &pChild->borderSize);
+ }
+ }
+
+ if (subInited)
+ REGION_UNINIT(pScreen, &SubRegion);
+ }
+
+ /*
+ * Check the state of this window. DIX save unders are
+ * enabled for viewable windows with some client expressing
+ * exposure interest and which intersect the save under region
+ */
+
+ if (pParent->viewable &&
+ ((pParent->eventMask | wOtherEventMasks(pParent)) & ExposureMask) &&
+ REGION_NOTEMPTY(pScreen, &pParent->borderSize) &&
+ RECT_IN_REGION(pScreen, pRegion, REGION_EXTENTS(pScreen,
+ &pParent->borderSize)) != rgnOUT)
+ {
+ if (!pParent->DIXsaveUnder)
+ {
+ pParent->DIXsaveUnder = TRUE;
+ (*pScreen->ChangeWindowAttributes) (pParent, CWBackingStore);
+ }
+ }
+ else
+ {
+ if (pParent->DIXsaveUnder)
+ {
+ res = TRUE;
+ pParent->DIXsaveUnder = FALSE;
+ }
+ }
+ return res;
+}
+
+
+/*-
+ *-----------------------------------------------------------------------
+ * miChangeSaveUnder --
+ * Change the save-under state of a tree of windows. Called when
+ * a window with saveUnder TRUE is mapped/unmapped/reconfigured.
+ *
+ * Results:
+ * TRUE if any windows need to have backing-store removed (which
+ * means that PostChangeSaveUnder needs to be called later to
+ * finish the job).
+ *
+ * Side Effects:
+ * Windows may have backing-store turned on or off.
+ *
+ *-----------------------------------------------------------------------
+ */
+Bool
+miChangeSaveUnder(pWin, first)
+ register WindowPtr pWin;
+ WindowPtr first; /* First window to check.
+ * Used when pWin was restacked */
+{
+ RegionRec rgn; /* Area obscured by saveUnder windows */
+ register ScreenPtr pScreen;
+ Bool res;
+
+ if (!deltaSaveUndersViewable && !numSaveUndersViewable)
+ return FALSE;
+ numSaveUndersViewable += deltaSaveUndersViewable;
+ deltaSaveUndersViewable = 0;
+ pScreen = pWin->drawable.pScreen;
+ REGION_NULL(pScreen, &rgn);
+ res = miCheckSubSaveUnder (pWin->parent,
+ pWin->saveUnder ? first : pWin->nextSib,
+ &rgn);
+ REGION_UNINIT(pScreen, &rgn);
+ return res;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miPostChangeSaveUnder --
+ * Actually turn backing-store off for those windows that no longer
+ * need to have it on.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Backing-store and SAVE_UNDER_CHANGE_BIT are turned off for those
+ * windows affected.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+miPostChangeSaveUnder(pWin, pFirst)
+ WindowPtr pWin;
+ WindowPtr pFirst;
+{
+ register WindowPtr pParent, pChild;
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+
+ if (!(pParent = pWin->parent))
+ return;
+ ChangeWindowAttributes = pParent->drawable.pScreen->ChangeWindowAttributes;
+ if (!pParent->DIXsaveUnder &&
+ (pParent->backingStore == NotUseful) && pParent->backStorage)
+ (*ChangeWindowAttributes)(pParent, CWBackingStore);
+ if (!(pChild = pFirst))
+ return;
+ while (1)
+ {
+ if (!pChild->DIXsaveUnder &&
+ (pChild->backingStore == NotUseful) && pChild->backStorage)
+ (*ChangeWindowAttributes)(pChild, CWBackingStore);
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ while (!pChild->nextSib)
+ {
+ pChild = pChild->parent;
+ if (pChild == pParent)
+ return;
+ }
+ pChild = pChild->nextSib;
+ }
+}
+
+void
+miMarkWindow(pWin)
+ register WindowPtr pWin;
+{
+ register ValidatePtr val;
+
+ if (pWin->valdata)
+ return;
+ val = (ValidatePtr)xnfalloc(sizeof(ValidateRec));
+ val->before.oldAbsCorner.x = pWin->drawable.x;
+ val->before.oldAbsCorner.y = pWin->drawable.y;
+ val->before.borderVisible = NullRegion;
+ val->before.resized = FALSE;
+ pWin->valdata = val;
+}
+
+Bool
+miMarkOverlappedWindows(pWin, pFirst, ppLayerWin)
+ WindowPtr pWin;
+ WindowPtr pFirst;
+ WindowPtr *ppLayerWin;
+{
+ register BoxPtr box;
+ register WindowPtr pChild, pLast;
+ Bool anyMarked = FALSE;
+ MarkWindowProcPtr MarkWindow = pWin->drawable.pScreen->MarkWindow;
+ ScreenPtr pScreen;
+
+ pScreen = pWin->drawable.pScreen;
+
+ /* single layered systems are easy */
+ if (ppLayerWin) *ppLayerWin = pWin;
+
+ if (pWin == pFirst)
+ {
+ /* Blindly mark pWin and all of its inferiors. This is a slight
+ * overkill if there are mapped windows that outside pWin's border,
+ * but it's better than wasting time on RectIn checks.
+ */
+ pChild = pWin;
+ while (1)
+ {
+ if (pChild->viewable)
+ {
+ if (REGION_BROKEN (pScreen, &pChild->winSize))
+ SetWinSize (pChild);
+ if (REGION_BROKEN (pScreen, &pChild->borderSize))
+ SetBorderSize (pChild);
+ (* MarkWindow)(pChild);
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ while (!pChild->nextSib && (pChild != pWin))
+ pChild = pChild->parent;
+ if (pChild == pWin)
+ break;
+ pChild = pChild->nextSib;
+ }
+ anyMarked = TRUE;
+ pFirst = pFirst->nextSib;
+ }
+ if ( (pChild = pFirst) )
+ {
+ box = REGION_EXTENTS(pChild->drawable.pScreen, &pWin->borderSize);
+ pLast = pChild->parent->lastChild;
+ while (1)
+ {
+ if (pChild->viewable)
+ {
+ if (REGION_BROKEN (pScreen, &pChild->winSize))
+ SetWinSize (pChild);
+ if (REGION_BROKEN (pScreen, &pChild->borderSize))
+ SetBorderSize (pChild);
+ if (RECT_IN_REGION(pScreen, &pChild->borderSize, box))
+ {
+ (* MarkWindow)(pChild);
+ anyMarked = TRUE;
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ }
+ while (!pChild->nextSib && (pChild != pLast))
+ pChild = pChild->parent;
+ if (pChild == pLast)
+ break;
+ pChild = pChild->nextSib;
+ }
+ }
+ if (anyMarked)
+ (* MarkWindow)(pWin->parent);
+ return anyMarked;
+}
+
+/*****
+ * miHandleValidateExposures(pWin)
+ * starting at pWin, draw background in any windows that have exposure
+ * regions, translate the regions, restore any backing store,
+ * and then send any regions still exposed to the client
+ *****/
+void
+miHandleValidateExposures(pWin)
+ WindowPtr pWin;
+{
+ register WindowPtr pChild;
+ register ValidatePtr val;
+ ScreenPtr pScreen;
+ WindowExposuresProcPtr WindowExposures;
+
+ pScreen = pWin->drawable.pScreen;
+
+ pChild = pWin;
+ WindowExposures = pChild->drawable.pScreen->WindowExposures;
+ while (1)
+ {
+ if ( (val = pChild->valdata) )
+ {
+ if (REGION_NOTEMPTY(pScreen, &val->after.borderExposed))
+ (*pChild->drawable.pScreen->PaintWindowBorder)(pChild,
+ &val->after.borderExposed,
+ PW_BORDER);
+ REGION_UNINIT(pScreen, &val->after.borderExposed);
+ (*WindowExposures)(pChild, &val->after.exposed, NullRegion);
+ REGION_UNINIT(pScreen, &val->after.exposed);
+ xfree(val);
+ pChild->valdata = (ValidatePtr)NULL;
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ while (!pChild->nextSib && (pChild != pWin))
+ pChild = pChild->parent;
+ if (pChild == pWin)
+ break;
+ pChild = pChild->nextSib;
+ }
+}
+
+void
+miMoveWindow(pWin, x, y, pNextSib, kind)
+ register WindowPtr pWin;
+ int x,y;
+ WindowPtr pNextSib;
+ VTKind kind;
+{
+ WindowPtr pParent;
+ Bool WasViewable = (Bool)(pWin->viewable);
+ short bw;
+ RegionPtr oldRegion = NULL;
+ DDXPointRec oldpt;
+ Bool anyMarked = FALSE;
+ register ScreenPtr pScreen;
+ WindowPtr windowToValidate;
+#ifdef DO_SAVE_UNDERS
+ Bool dosave = FALSE;
+#endif
+ WindowPtr pLayerWin;
+
+ /* if this is a root window, can't be moved */
+ if (!(pParent = pWin->parent))
+ return ;
+ pScreen = pWin->drawable.pScreen;
+ bw = wBorderWidth (pWin);
+
+ oldpt.x = pWin->drawable.x;
+ oldpt.y = pWin->drawable.y;
+ if (WasViewable)
+ {
+ oldRegion = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_COPY(pScreen, oldRegion, &pWin->borderClip);
+ anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin);
+ }
+ pWin->origin.x = x + (int)bw;
+ pWin->origin.y = y + (int)bw;
+ x = pWin->drawable.x = pParent->drawable.x + x + (int)bw;
+ y = pWin->drawable.y = pParent->drawable.y + y + (int)bw;
+
+ SetWinSize (pWin);
+ SetBorderSize (pWin);
+
+ (*pScreen->PositionWindow)(pWin, x, y);
+
+ windowToValidate = MoveWindowInStack(pWin, pNextSib);
+
+ ResizeChildrenWinSize(pWin, x - oldpt.x, y - oldpt.y, 0, 0);
+
+ if (WasViewable)
+ {
+ if (pLayerWin == pWin)
+ anyMarked |= (*pScreen->MarkOverlappedWindows)
+ (pWin, windowToValidate, (WindowPtr *)NULL);
+ else
+ anyMarked |= (*pScreen->MarkOverlappedWindows)
+ (pWin, pLayerWin, (WindowPtr *)NULL);
+
+#ifdef DO_SAVE_UNDERS
+ if (DO_SAVE_UNDERS(pWin))
+ {
+ dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, windowToValidate);
+ }
+#endif /* DO_SAVE_UNDERS */
+
+ if (anyMarked)
+ {
+ (*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, kind);
+ (* pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, oldRegion);
+ REGION_DESTROY(pScreen, oldRegion);
+ /* XXX need to retile border if ParentRelative origin */
+ (*pScreen->HandleExposures)(pLayerWin->parent);
+ }
+#ifdef DO_SAVE_UNDERS
+ if (dosave)
+ (*pScreen->PostChangeSaveUnder)(pLayerWin, windowToValidate);
+#endif /* DO_SAVE_UNDERS */
+ if (anyMarked && pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, kind);
+ }
+ if (pWin->realized)
+ WindowsRestructured ();
+}
+
+
+/*
+ * pValid is a region of the screen which has been
+ * successfully copied -- recomputed exposed regions for affected windows
+ */
+
+static int
+miRecomputeExposures (
+ register WindowPtr pWin,
+ pointer value) /* must conform to VisitWindowProcPtr */
+{
+ register ScreenPtr pScreen;
+ RegionPtr pValid = (RegionPtr)value;
+
+ if (pWin->valdata)
+ {
+ pScreen = pWin->drawable.pScreen;
+ /*
+ * compute exposed regions of this window
+ */
+ REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed,
+ &pWin->clipList, pValid);
+ /*
+ * compute exposed regions of the border
+ */
+ REGION_SUBTRACT(pScreen, &pWin->valdata->after.borderExposed,
+ &pWin->borderClip, &pWin->winSize);
+ REGION_SUBTRACT(pScreen, &pWin->valdata->after.borderExposed,
+ &pWin->valdata->after.borderExposed, pValid);
+ return WT_WALKCHILDREN;
+ }
+ return WT_NOMATCH;
+}
+
+void
+miSlideAndSizeWindow(pWin, x, y, w, h, pSib)
+ register WindowPtr pWin;
+ int x,y;
+ unsigned int w, h;
+ WindowPtr pSib;
+{
+ WindowPtr pParent;
+ Bool WasViewable = (Bool)(pWin->viewable);
+ unsigned short width = pWin->drawable.width,
+ height = pWin->drawable.height;
+ short oldx = pWin->drawable.x,
+ oldy = pWin->drawable.y;
+ int bw = wBorderWidth (pWin);
+ short dw, dh;
+ DDXPointRec oldpt;
+ RegionPtr oldRegion = NULL;
+ Bool anyMarked = FALSE;
+ register ScreenPtr pScreen;
+ WindowPtr pFirstChange;
+ register WindowPtr pChild;
+ RegionPtr gravitate[StaticGravity + 1];
+ register unsigned g;
+ int nx, ny; /* destination x,y */
+ int newx, newy; /* new inner window position */
+ RegionPtr pRegion = NULL;
+ RegionPtr destClip; /* portions of destination already written */
+ RegionPtr oldWinClip = NULL; /* old clip list for window */
+ RegionPtr borderVisible = NullRegion; /* visible area of the border */
+ RegionPtr bsExposed = NullRegion; /* backing store exposures */
+ Bool shrunk = FALSE; /* shrunk in an inner dimension */
+ Bool moved = FALSE; /* window position changed */
+#ifdef DO_SAVE_UNDERS
+ Bool dosave = FALSE;
+#endif
+ WindowPtr pLayerWin;
+
+ /* if this is a root window, can't be resized */
+ if (!(pParent = pWin->parent))
+ return ;
+
+ pScreen = pWin->drawable.pScreen;
+ newx = pParent->drawable.x + x + bw;
+ newy = pParent->drawable.y + y + bw;
+ if (WasViewable)
+ {
+ anyMarked = FALSE;
+ /*
+ * save the visible region of the window
+ */
+ oldRegion = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_COPY(pScreen, oldRegion, &pWin->winSize);
+
+ /*
+ * categorize child windows into regions to be moved
+ */
+ for (g = 0; g <= StaticGravity; g++)
+ gravitate[g] = (RegionPtr) NULL;
+ for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
+ {
+ g = pChild->winGravity;
+ if (g != UnmapGravity)
+ {
+ if (!gravitate[g])
+ gravitate[g] = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_UNION(pScreen, gravitate[g],
+ gravitate[g], &pChild->borderClip);
+ }
+ else
+ {
+ UnmapWindow(pChild, TRUE);
+ anyMarked = TRUE;
+ }
+ }
+ anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin,
+ &pLayerWin);
+
+ oldWinClip = NULL;
+ if (pWin->bitGravity != ForgetGravity)
+ {
+ oldWinClip = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_COPY(pScreen, oldWinClip, &pWin->clipList);
+ }
+ /*
+ * if the window is changing size, borderExposed
+ * can't be computed correctly without some help.
+ */
+ if (pWin->drawable.height > h || pWin->drawable.width > w)
+ shrunk = TRUE;
+
+ if (newx != oldx || newy != oldy)
+ moved = TRUE;
+
+ if ((pWin->drawable.height != h || pWin->drawable.width != w) &&
+ HasBorder (pWin))
+ {
+ borderVisible = REGION_CREATE(pScreen, NullBox, 1);
+ /* for tiled borders, we punt and draw the whole thing */
+ if (pWin->borderIsPixel || !moved)
+ {
+ if (shrunk || moved)
+ REGION_SUBTRACT(pScreen, borderVisible,
+ &pWin->borderClip,
+ &pWin->winSize);
+ else
+ REGION_COPY(pScreen, borderVisible,
+ &pWin->borderClip);
+ }
+ }
+ }
+ pWin->origin.x = x + bw;
+ pWin->origin.y = y + bw;
+ pWin->drawable.height = h;
+ pWin->drawable.width = w;
+
+ x = pWin->drawable.x = newx;
+ y = pWin->drawable.y = newy;
+
+ SetWinSize (pWin);
+ SetBorderSize (pWin);
+
+ dw = (int)w - (int)width;
+ dh = (int)h - (int)height;
+ ResizeChildrenWinSize(pWin, x - oldx, y - oldy, dw, dh);
+
+ /* let the hardware adjust background and border pixmaps, if any */
+ (*pScreen->PositionWindow)(pWin, x, y);
+
+ pFirstChange = MoveWindowInStack(pWin, pSib);
+
+ if (WasViewable)
+ {
+ pRegion = REGION_CREATE(pScreen, NullBox, 1);
+ if (pWin->backStorage)
+ REGION_COPY(pScreen, pRegion, &pWin->clipList);
+
+ if (pLayerWin == pWin)
+ anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange,
+ (WindowPtr *)NULL);
+ else
+ anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pLayerWin,
+ (WindowPtr *)NULL);
+
+ if (pWin->valdata)
+ {
+ pWin->valdata->before.resized = TRUE;
+ pWin->valdata->before.borderVisible = borderVisible;
+ }
+
+#ifdef DO_SAVE_UNDERS
+ if (DO_SAVE_UNDERS(pWin))
+ {
+ dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pFirstChange);
+ }
+#endif /* DO_SAVE_UNDERS */
+
+ if (anyMarked)
+ (*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, VTOther);
+ /*
+ * the entire window is trashed unless bitGravity
+ * recovers portions of it
+ */
+ REGION_COPY(pScreen, &pWin->valdata->after.exposed, &pWin->clipList);
+ }
+
+ GravityTranslate (x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny);
+
+ if (pWin->backStorage &&
+ ((pWin->backingStore == Always) || WasViewable))
+ {
+ if (!WasViewable)
+ pRegion = &pWin->clipList; /* a convenient empty region */
+ if (pWin->bitGravity == ForgetGravity)
+ bsExposed = (*pScreen->TranslateBackingStore)
+ (pWin, 0, 0, NullRegion, oldx, oldy);
+ else
+ {
+ bsExposed = (*pScreen->TranslateBackingStore)
+ (pWin, nx - x, ny - y, pRegion, oldx, oldy);
+ }
+ }
+
+ if (WasViewable)
+ {
+ /* avoid the border */
+ if (HasBorder (pWin))
+ {
+ int offx, offy, dx, dy;
+
+ /* kruft to avoid double translates for each gravity */
+ offx = 0;
+ offy = 0;
+ for (g = 0; g <= StaticGravity; g++)
+ {
+ if (!gravitate[g])
+ continue;
+
+ /* align winSize to gravitate[g].
+ * winSize is in new coordinates,
+ * gravitate[g] is still in old coordinates */
+ GravityTranslate (x, y, oldx, oldy, dw, dh, g, &nx, &ny);
+
+ dx = (oldx - nx) - offx;
+ dy = (oldy - ny) - offy;
+ if (dx || dy)
+ {
+ REGION_TRANSLATE(pScreen, &pWin->winSize, dx, dy);
+ offx += dx;
+ offy += dy;
+ }
+ REGION_INTERSECT(pScreen, gravitate[g], gravitate[g],
+ &pWin->winSize);
+ }
+ /* get winSize back where it belongs */
+ if (offx || offy)
+ REGION_TRANSLATE(pScreen, &pWin->winSize, -offx, -offy);
+ }
+ /*
+ * add screen bits to the appropriate bucket
+ */
+
+ if (oldWinClip)
+ {
+ /*
+ * clip to new clipList
+ */
+ REGION_COPY(pScreen, pRegion, oldWinClip);
+ REGION_TRANSLATE(pScreen, pRegion, nx - oldx, ny - oldy);
+ REGION_INTERSECT(pScreen, oldWinClip, pRegion, &pWin->clipList);
+ /*
+ * don't step on any gravity bits which will be copied after this
+ * region. Note -- this assumes that the regions will be copied
+ * in gravity order.
+ */
+ for (g = pWin->bitGravity + 1; g <= StaticGravity; g++)
+ {
+ if (gravitate[g])
+ REGION_SUBTRACT(pScreen, oldWinClip, oldWinClip,
+ gravitate[g]);
+ }
+ REGION_TRANSLATE(pScreen, oldWinClip, oldx - nx, oldy - ny);
+ g = pWin->bitGravity;
+ if (!gravitate[g])
+ gravitate[g] = oldWinClip;
+ else
+ {
+ REGION_UNION(pScreen, gravitate[g], gravitate[g], oldWinClip);
+ REGION_DESTROY(pScreen, oldWinClip);
+ }
+ }
+
+ /*
+ * move the bits on the screen
+ */
+
+ destClip = NULL;
+
+ for (g = 0; g <= StaticGravity; g++)
+ {
+ if (!gravitate[g])
+ continue;
+
+ GravityTranslate (x, y, oldx, oldy, dw, dh, g, &nx, &ny);
+
+ oldpt.x = oldx + (x - nx);
+ oldpt.y = oldy + (y - ny);
+
+ /* Note that gravitate[g] is *translated* by CopyWindow */
+
+ /* only copy the remaining useful bits */
+
+ REGION_INTERSECT(pScreen, gravitate[g], gravitate[g], oldRegion);
+
+ /* clip to not overwrite already copied areas */
+
+ if (destClip) {
+ REGION_TRANSLATE(pScreen, destClip, oldpt.x - x, oldpt.y - y);
+ REGION_SUBTRACT(pScreen, gravitate[g], gravitate[g], destClip);
+ REGION_TRANSLATE(pScreen, destClip, x - oldpt.x, y - oldpt.y);
+ }
+
+ /* and move those bits */
+
+ if (oldpt.x != x || oldpt.y != y
+#ifdef COMPOSITE
+ || pWin->redirectDraw
+#endif
+ )
+ {
+ (*pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, gravitate[g]);
+ }
+
+ /* remove any overwritten bits from the remaining useful bits */
+
+ REGION_SUBTRACT(pScreen, oldRegion, oldRegion, gravitate[g]);
+
+ /*
+ * recompute exposed regions of child windows
+ */
+
+ for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
+ {
+ if (pChild->winGravity != g)
+ continue;
+ REGION_INTERSECT(pScreen, pRegion,
+ &pChild->borderClip, gravitate[g]);
+ TraverseTree (pChild, miRecomputeExposures, (pointer)pRegion);
+ }
+
+ /*
+ * remove the successfully copied regions of the
+ * window from its exposed region
+ */
+
+ if (g == pWin->bitGravity)
+ REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed,
+ &pWin->valdata->after.exposed, gravitate[g]);
+ if (!destClip)
+ destClip = gravitate[g];
+ else
+ {
+ REGION_UNION(pScreen, destClip, destClip, gravitate[g]);
+ REGION_DESTROY(pScreen, gravitate[g]);
+ }
+ }
+
+ REGION_DESTROY(pScreen, oldRegion);
+ REGION_DESTROY(pScreen, pRegion);
+ if (destClip)
+ REGION_DESTROY(pScreen, destClip);
+ if (bsExposed)
+ {
+ RegionPtr valExposed = NullRegion;
+
+ if (pWin->valdata)
+ valExposed = &pWin->valdata->after.exposed;
+ (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
+ if (valExposed)
+ REGION_EMPTY(pScreen, valExposed);
+ REGION_DESTROY(pScreen, bsExposed);
+ }
+ if (anyMarked)
+ (*pScreen->HandleExposures)(pLayerWin->parent);
+#ifdef DO_SAVE_UNDERS
+ if (dosave)
+ {
+ (*pScreen->PostChangeSaveUnder)(pLayerWin, pFirstChange);
+ }
+#endif /* DO_SAVE_UNDERS */
+ if (anyMarked && pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange,
+ VTOther);
+ }
+ else if (bsExposed)
+ {
+ (*pScreen->WindowExposures) (pWin, NullRegion, bsExposed);
+ REGION_DESTROY(pScreen, bsExposed);
+ }
+ if (pWin->realized)
+ WindowsRestructured ();
+}
+
+WindowPtr
+miGetLayerWindow(pWin)
+ WindowPtr pWin;
+{
+ return pWin->firstChild;
+}
+
+#ifdef SHAPE
+/******
+ *
+ * miSetShape
+ * The border/window shape has changed. Recompute winSize/borderSize
+ * and send appropriate exposure events
+ */
+
+void
+miSetShape(pWin)
+ register WindowPtr pWin;
+{
+ Bool WasViewable = (Bool)(pWin->viewable);
+ register ScreenPtr pScreen = pWin->drawable.pScreen;
+ Bool anyMarked = FALSE;
+ RegionPtr pOldClip = NULL, bsExposed;
+#ifdef DO_SAVE_UNDERS
+ Bool dosave = FALSE;
+#endif
+ WindowPtr pLayerWin;
+
+ if (WasViewable)
+ {
+ anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin,
+ &pLayerWin);
+ if (pWin->valdata)
+ {
+ if (HasBorder (pWin))
+ {
+ RegionPtr borderVisible;
+
+ borderVisible = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_SUBTRACT(pScreen, borderVisible,
+ &pWin->borderClip, &pWin->winSize);
+ pWin->valdata->before.borderVisible = borderVisible;
+ }
+ pWin->valdata->before.resized = TRUE;
+ }
+ }
+
+ SetWinSize (pWin);
+ SetBorderSize (pWin);
+
+ ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
+
+ if (WasViewable)
+ {
+ if (pWin->backStorage)
+ {
+ pOldClip = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_COPY(pScreen, pOldClip, &pWin->clipList);
+ }
+
+ anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin,
+ (WindowPtr *)NULL);
+
+#ifdef DO_SAVE_UNDERS
+ if (DO_SAVE_UNDERS(pWin))
+ {
+ dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin);
+ }
+#endif /* DO_SAVE_UNDERS */
+
+ if (anyMarked)
+ (*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, VTOther);
+ }
+
+ if (pWin->backStorage &&
+ ((pWin->backingStore == Always) || WasViewable))
+ {
+ if (!WasViewable)
+ pOldClip = &pWin->clipList; /* a convenient empty region */
+ bsExposed = (*pScreen->TranslateBackingStore)
+ (pWin, 0, 0, pOldClip,
+ pWin->drawable.x, pWin->drawable.y);
+ if (WasViewable)
+ REGION_DESTROY(pScreen, pOldClip);
+ if (bsExposed)
+ {
+ RegionPtr valExposed = NullRegion;
+
+ if (pWin->valdata)
+ valExposed = &pWin->valdata->after.exposed;
+ (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
+ if (valExposed)
+ REGION_EMPTY(pScreen, valExposed);
+ REGION_DESTROY(pScreen, bsExposed);
+ }
+ }
+ if (WasViewable)
+ {
+ if (anyMarked)
+ (*pScreen->HandleExposures)(pLayerWin->parent);
+#ifdef DO_SAVE_UNDERS
+ if (dosave)
+ (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin);
+#endif /* DO_SAVE_UNDERS */
+ if (anyMarked && pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, VTOther);
+ }
+ if (pWin->realized)
+ WindowsRestructured ();
+ CheckCursorConfinement(pWin);
+}
+#endif
+
+/* Keeps the same inside(!) origin */
+
+void
+miChangeBorderWidth(pWin, width)
+ register WindowPtr pWin;
+ unsigned int width;
+{
+ int oldwidth;
+ Bool anyMarked = FALSE;
+ register ScreenPtr pScreen;
+ Bool WasViewable = (Bool)(pWin->viewable);
+ Bool HadBorder;
+#ifdef DO_SAVE_UNDERS
+ Bool dosave = FALSE;
+#endif
+ WindowPtr pLayerWin;
+
+ oldwidth = wBorderWidth (pWin);
+ if (oldwidth == width)
+ return;
+ HadBorder = HasBorder(pWin);
+ pScreen = pWin->drawable.pScreen;
+ if (WasViewable && width < oldwidth)
+ anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin);
+
+ pWin->borderWidth = width;
+ SetBorderSize (pWin);
+
+ if (WasViewable)
+ {
+ if (width > oldwidth)
+ {
+ anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin,
+ &pLayerWin);
+ /*
+ * save the old border visible region to correctly compute
+ * borderExposed.
+ */
+ if (pWin->valdata && HadBorder)
+ {
+ RegionPtr borderVisible;
+ borderVisible = REGION_CREATE(pScreen, NULL, 1);
+ REGION_SUBTRACT(pScreen, borderVisible,
+ &pWin->borderClip, &pWin->winSize);
+ pWin->valdata->before.borderVisible = borderVisible;
+ }
+ }
+#ifdef DO_SAVE_UNDERS
+ if (DO_SAVE_UNDERS(pWin))
+ {
+ dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib);
+ }
+#endif /* DO_SAVE_UNDERS */
+
+ if (anyMarked)
+ {
+ (*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTOther);
+ (*pScreen->HandleExposures)(pLayerWin->parent);
+ }
+#ifdef DO_SAVE_UNDERS
+ if (dosave)
+ (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib);
+#endif /* DO_SAVE_UNDERS */
+ if (anyMarked && pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin,
+ VTOther);
+ }
+ if (pWin->realized)
+ WindowsRestructured ();
+}
+
+void
+miMarkUnrealizedWindow(pChild, pWin, fromConfigure)
+ WindowPtr pChild;
+ WindowPtr pWin;
+ Bool fromConfigure;
+{
+ if ((pChild != pWin) || fromConfigure)
+ {
+ REGION_EMPTY(pChild->drawable.pScreen, &pChild->clipList);
+ if (pChild->drawable.pScreen->ClipNotify)
+ (* pChild->drawable.pScreen->ClipNotify)(pChild, 0, 0);
+ REGION_EMPTY(pChild->drawable.pScreen, &pChild->borderClip);
+ }
+}
+
+void
+miSegregateChildren(WindowPtr pWin, RegionPtr pReg, int depth)
+{
+ ScreenPtr pScreen;
+ WindowPtr pChild;
+
+ pScreen = pWin->drawable.pScreen;
+
+ for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
+ {
+ if (pChild->drawable.depth == depth)
+ REGION_UNION(pScreen, pReg, pReg, &pChild->borderClip);
+
+ if (pChild->firstChild)
+ miSegregateChildren(pChild, pReg, depth);
+ }
+}
diff --git a/nx-X11/programs/Xserver/mi/mizerarc.c b/nx-X11/programs/Xserver/mi/mizerarc.c
new file mode 100644
index 000000000..62402f41b
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mizerarc.c
@@ -0,0 +1,855 @@
+/* $XFree86: xc/programs/Xserver/mi/mizerarc.c,v 1.6 2001/12/14 20:00:28 dawes Exp $ */
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Author: Bob Scheifler, MIT X Consortium
+
+********************************************************/
+
+/* $Xorg: mizerarc.c,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
+
+/* Derived from:
+ * "Algorithm for drawing ellipses or hyperbolae with a digital plotter"
+ * by M. L. V. Pitteway
+ * The Computer Journal, November 1967, Volume 10, Number 3, pp. 282-289
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <math.h>
+#include <X11/X.h>
+#include <X11/Xprotostr.h>
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "mi.h"
+#include "mizerarc.h"
+
+#define FULLCIRCLE (360 * 64)
+#define OCTANT (45 * 64)
+#define QUADRANT (90 * 64)
+#define HALFCIRCLE (180 * 64)
+#define QUADRANT3 (270 * 64)
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+#define Dsin(d) ((d) == 0 ? 0.0 : ((d) == QUADRANT ? 1.0 : \
+ ((d) == HALFCIRCLE ? 0.0 : \
+ ((d) == QUADRANT3 ? -1.0 : sin((double)d*(M_PI/11520.0))))))
+
+#define Dcos(d) ((d) == 0 ? 1.0 : ((d) == QUADRANT ? 0.0 : \
+ ((d) == HALFCIRCLE ? -1.0 : \
+ ((d) == QUADRANT3 ? 0.0 : cos((double)d*(M_PI/11520.0))))))
+
+#define EPSILON45 64
+
+typedef struct {
+ int skipStart;
+ int haveStart;
+ DDXPointRec startPt;
+ int haveLast;
+ int skipLast;
+ DDXPointRec endPt;
+ int dashIndex;
+ int dashOffset;
+ int dashIndexInit;
+ int dashOffsetInit;
+} DashInfo;
+
+static miZeroArcPtRec oob = {65536, 65536, 0};
+
+/*
+ * (x - l)^2 / (W/2)^2 + (y + H/2)^2 / (H/2)^2 = 1
+ *
+ * where l is either 0 or .5
+ *
+ * alpha = 4(W^2)
+ * beta = 4(H^2)
+ * gamma = 0
+ * u = 2(W^2)H
+ * v = 4(H^2)l
+ * k = -4(H^2)(l^2)
+ *
+ */
+
+Bool
+miZeroArcSetup(arc, info, ok360)
+ register xArc *arc;
+ register miZeroArcRec *info;
+ Bool ok360;
+{
+ int l;
+ int angle1, angle2;
+ int startseg, endseg;
+ int startAngle, endAngle;
+ int i, overlap;
+ miZeroArcPtRec start, end;
+
+ l = arc->width & 1;
+ if (arc->width == arc->height)
+ {
+ info->alpha = 4;
+ info->beta = 4;
+ info->k1 = -8;
+ info->k3 = -16;
+ info->b = 12;
+ info->a = (arc->width << 2) - 12;
+ info->d = 17 - (arc->width << 1);
+ if (l)
+ {
+ info->b -= 4;
+ info->a += 4;
+ info->d -= 7;
+ }
+ }
+ else if (!arc->width || !arc->height)
+ {
+ info->alpha = 0;
+ info->beta = 0;
+ info->k1 = 0;
+ info->k3 = 0;
+ info->a = -(int)arc->height;
+ info->b = 0;
+ info->d = -1;
+ }
+ else
+ {
+ /* initial conditions */
+ info->alpha = (arc->width * arc->width) << 2;
+ info->beta = (arc->height * arc->height) << 2;
+ info->k1 = info->beta << 1;
+ info->k3 = info->k1 + (info->alpha << 1);
+ info->b = l ? 0 : -info->beta;
+ info->a = info->alpha * arc->height;
+ info->d = info->b - (info->a >> 1) - (info->alpha >> 2);
+ if (l)
+ info->d -= info->beta >> 2;
+ info->a -= info->b;
+ /* take first step, d < 0 always */
+ info->b -= info->k1;
+ info->a += info->k1;
+ info->d += info->b;
+ /* octant change, b < 0 always */
+ info->k1 = -info->k1;
+ info->k3 = -info->k3;
+ info->b = -info->b;
+ info->d = info->b - info->a - info->d;
+ info->a = info->a - (info->b << 1);
+ }
+ info->dx = 1;
+ info->dy = 0;
+ info->w = (arc->width + 1) >> 1;
+ info->h = arc->height >> 1;
+ info->xorg = arc->x + (arc->width >> 1);
+ info->yorg = arc->y;
+ info->xorgo = info->xorg + l;
+ info->yorgo = info->yorg + arc->height;
+ if (!arc->width)
+ {
+ if (!arc->height)
+ {
+ info->x = 0;
+ info->y = 0;
+ info->initialMask = 0;
+ info->startAngle = 0;
+ info->endAngle = 0;
+ info->start = oob;
+ info->end = oob;
+ return FALSE;
+ }
+ info->x = 0;
+ info->y = 1;
+ }
+ else
+ {
+ info->x = 1;
+ info->y = 0;
+ }
+ angle1 = arc->angle1;
+ angle2 = arc->angle2;
+ if ((angle1 == 0) && (angle2 >= FULLCIRCLE))
+ {
+ startAngle = 0;
+ endAngle = 0;
+ }
+ else
+ {
+ if (angle2 > FULLCIRCLE)
+ angle2 = FULLCIRCLE;
+ else if (angle2 < -FULLCIRCLE)
+ angle2 = -FULLCIRCLE;
+ if (angle2 < 0)
+ {
+ startAngle = angle1 + angle2;
+ endAngle = angle1;
+ }
+ else
+ {
+ startAngle = angle1;
+ endAngle = angle1 + angle2;
+ }
+ if (startAngle < 0)
+ startAngle = FULLCIRCLE - (-startAngle) % FULLCIRCLE;
+ if (startAngle >= FULLCIRCLE)
+ startAngle = startAngle % FULLCIRCLE;
+ if (endAngle < 0)
+ endAngle = FULLCIRCLE - (-endAngle) % FULLCIRCLE;
+ if (endAngle >= FULLCIRCLE)
+ endAngle = endAngle % FULLCIRCLE;
+ }
+ info->startAngle = startAngle;
+ info->endAngle = endAngle;
+ if (ok360 && (startAngle == endAngle) && arc->angle2 &&
+ arc->width && arc->height)
+ {
+ info->initialMask = 0xf;
+ info->start = oob;
+ info->end = oob;
+ return TRUE;
+ }
+ startseg = startAngle / OCTANT;
+ if (!arc->height || (((startseg + 1) & 2) && arc->width))
+ {
+ start.x = Dcos(startAngle) * ((arc->width + 1) / 2.0);
+ if (start.x < 0)
+ start.x = -start.x;
+ start.y = -1;
+ }
+ else
+ {
+ start.y = Dsin(startAngle) * (arc->height / 2.0);
+ if (start.y < 0)
+ start.y = -start.y;
+ start.y = info->h - start.y;
+ start.x = 65536;
+ }
+ endseg = endAngle / OCTANT;
+ if (!arc->height || (((endseg + 1) & 2) && arc->width))
+ {
+ end.x = Dcos(endAngle) * ((arc->width + 1) / 2.0);
+ if (end.x < 0)
+ end.x = -end.x;
+ end.y = -1;
+ }
+ else
+ {
+ end.y = Dsin(endAngle) * (arc->height / 2.0);
+ if (end.y < 0)
+ end.y = -end.y;
+ end.y = info->h - end.y;
+ end.x = 65536;
+ }
+ info->firstx = start.x;
+ info->firsty = start.y;
+ info->initialMask = 0;
+ overlap = arc->angle2 && (endAngle <= startAngle);
+ for (i = 0; i < 4; i++)
+ {
+ if (overlap ?
+ ((i * QUADRANT <= endAngle) || ((i + 1) * QUADRANT > startAngle)) :
+ ((i * QUADRANT <= endAngle) && ((i + 1) * QUADRANT > startAngle)))
+ info->initialMask |= (1 << i);
+ }
+ start.mask = info->initialMask;
+ end.mask = info->initialMask;
+ startseg >>= 1;
+ endseg >>= 1;
+ overlap = overlap && (endseg == startseg);
+ if (start.x != end.x || start.y != end.y || !overlap)
+ {
+ if (startseg & 1)
+ {
+ if (!overlap)
+ info->initialMask &= ~(1 << startseg);
+ if (start.x > end.x || start.y > end.y)
+ end.mask &= ~(1 << startseg);
+ }
+ else
+ {
+ start.mask &= ~(1 << startseg);
+ if (((start.x < end.x || start.y < end.y) ||
+ (start.x == end.x && start.y == end.y && (endseg & 1))) &&
+ !overlap)
+ end.mask &= ~(1 << startseg);
+ }
+ if (endseg & 1)
+ {
+ end.mask &= ~(1 << endseg);
+ if (((start.x > end.x || start.y > end.y) ||
+ (start.x == end.x && start.y == end.y && !(startseg & 1))) &&
+ !overlap)
+ start.mask &= ~(1 << endseg);
+ }
+ else
+ {
+ if (!overlap)
+ info->initialMask &= ~(1 << endseg);
+ if (start.x < end.x || start.y < end.y)
+ start.mask &= ~(1 << endseg);
+ }
+ }
+ /* take care of case when start and stop are both near 45 */
+ /* handle here rather than adding extra code to pixelization loops */
+ if (startAngle &&
+ ((start.y < 0 && end.y >= 0) || (start.y >= 0 && end.y < 0)))
+ {
+ i = (startAngle + OCTANT) % OCTANT;
+ if (i < EPSILON45 || i > OCTANT - EPSILON45)
+ {
+ i = (endAngle + OCTANT) % OCTANT;
+ if (i < EPSILON45 || i > OCTANT - EPSILON45)
+ {
+ if (start.y < 0)
+ {
+ i = Dsin(startAngle) * (arc->height / 2.0);
+ if (i < 0)
+ i = -i;
+ if (info->h - i == end.y)
+ start.mask = end.mask;
+ }
+ else
+ {
+ i = Dsin(endAngle) * (arc->height / 2.0);
+ if (i < 0)
+ i = -i;
+ if (info->h - i == start.y)
+ end.mask = start.mask;
+ }
+ }
+ }
+ }
+ if (startseg & 1)
+ {
+ info->start = start;
+ info->end = oob;
+ }
+ else
+ {
+ info->end = start;
+ info->start = oob;
+ }
+ if (endseg & 1)
+ {
+ info->altend = end;
+ if (info->altend.x < info->end.x || info->altend.y < info->end.y)
+ {
+ miZeroArcPtRec tmp;
+ tmp = info->altend;
+ info->altend = info->end;
+ info->end = tmp;
+ }
+ info->altstart = oob;
+ }
+ else
+ {
+ info->altstart = end;
+ if (info->altstart.x < info->start.x ||
+ info->altstart.y < info->start.y)
+ {
+ miZeroArcPtRec tmp;
+ tmp = info->altstart;
+ info->altstart = info->start;
+ info->start = tmp;
+ }
+ info->altend = oob;
+ }
+ if (!info->start.x || !info->start.y)
+ {
+ info->initialMask = info->start.mask;
+ info->start = info->altstart;
+ }
+ if (!arc->width && (arc->height == 1))
+ {
+ /* kludge! */
+ info->initialMask |= info->end.mask;
+ info->initialMask |= info->initialMask << 1;
+ info->end.x = 0;
+ info->end.mask = 0;
+ }
+ return FALSE;
+}
+
+#define Pixelate(xval,yval) \
+ { \
+ pts->x = xval; \
+ pts->y = yval; \
+ pts++; \
+ }
+
+#define DoPix(idx,xval,yval) if (mask & (1 << idx)) Pixelate(xval, yval);
+
+DDXPointPtr
+miZeroArcPts(arc, pts)
+ xArc *arc;
+ register DDXPointPtr pts;
+{
+ miZeroArcRec info;
+ register int x, y, a, b, d, mask;
+ register int k1, k3, dx, dy;
+ Bool do360;
+
+ do360 = miZeroArcSetup(arc, &info, TRUE);
+ MIARCSETUP();
+ mask = info.initialMask;
+ if (!(arc->width & 1))
+ {
+ DoPix(1, info.xorgo, info.yorg);
+ DoPix(3, info.xorgo, info.yorgo);
+ }
+ if (!info.end.x || !info.end.y)
+ {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ if (do360 && (arc->width == arc->height) && !(arc->width & 1))
+ {
+ int yorgh = info.yorg + info.h;
+ int xorghp = info.xorg + info.h;
+ int xorghn = info.xorg - info.h;
+
+ while (1)
+ {
+ Pixelate(info.xorg + x, info.yorg + y);
+ Pixelate(info.xorg - x, info.yorg + y);
+ Pixelate(info.xorg - x, info.yorgo - y);
+ Pixelate(info.xorg + x, info.yorgo - y);
+ if (a < 0)
+ break;
+ Pixelate(xorghp - y, yorgh - x);
+ Pixelate(xorghn + y, yorgh - x);
+ Pixelate(xorghn + y, yorgh + x);
+ Pixelate(xorghp - y, yorgh + x);
+ MIARCCIRCLESTEP(;);
+ }
+ if (x > 1 && pts[-1].x == pts[-5].x && pts[-1].y == pts[-5].y)
+ pts -= 4;
+ x = info.w;
+ y = info.h;
+ }
+ else if (do360)
+ {
+ while (y < info.h || x < info.w)
+ {
+ MIARCOCTANTSHIFT(;);
+ Pixelate(info.xorg + x, info.yorg + y);
+ Pixelate(info.xorgo - x, info.yorg + y);
+ Pixelate(info.xorgo - x, info.yorgo - y);
+ Pixelate(info.xorg + x, info.yorgo - y);
+ MIARCSTEP(;,;);
+ }
+ }
+ else
+ {
+ while (y < info.h || x < info.w)
+ {
+ MIARCOCTANTSHIFT(;);
+ if ((x == info.start.x) || (y == info.start.y))
+ {
+ mask = info.start.mask;
+ info.start = info.altstart;
+ }
+ DoPix(0, info.xorg + x, info.yorg + y);
+ DoPix(1, info.xorgo - x, info.yorg + y);
+ DoPix(2, info.xorgo - x, info.yorgo - y);
+ DoPix(3, info.xorg + x, info.yorgo - y);
+ if ((x == info.end.x) || (y == info.end.y))
+ {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ MIARCSTEP(;,;);
+ }
+ }
+ if ((x == info.start.x) || (y == info.start.y))
+ mask = info.start.mask;
+ DoPix(0, info.xorg + x, info.yorg + y);
+ DoPix(2, info.xorgo - x, info.yorgo - y);
+ if (arc->height & 1)
+ {
+ DoPix(1, info.xorgo - x, info.yorg + y);
+ DoPix(3, info.xorg + x, info.yorgo - y);
+ }
+ return pts;
+}
+
+#undef DoPix
+#define DoPix(idx,xval,yval) \
+ if (mask & (1 << idx)) \
+ { \
+ arcPts[idx]->x = xval; \
+ arcPts[idx]->y = yval; \
+ arcPts[idx]++; \
+ }
+
+static void
+miZeroArcDashPts(
+ GCPtr pGC,
+ xArc *arc,
+ DashInfo *dinfo,
+ register DDXPointPtr points,
+ int maxPts,
+ register DDXPointPtr *evenPts,
+ register DDXPointPtr *oddPts )
+{
+ miZeroArcRec info;
+ register int x, y, a, b, d, mask;
+ register int k1, k3, dx, dy;
+ int dashRemaining;
+ DDXPointPtr arcPts[4];
+ DDXPointPtr startPts[5], endPts[5];
+ int deltas[5];
+ DDXPointPtr startPt, pt, lastPt, pts;
+ int i, j, delta, ptsdelta, seg, startseg;
+
+ for (i = 0; i < 4; i++)
+ arcPts[i] = points + (i * maxPts);
+ (void)miZeroArcSetup(arc, &info, FALSE);
+ MIARCSETUP();
+ mask = info.initialMask;
+ startseg = info.startAngle / QUADRANT;
+ startPt = arcPts[startseg];
+ if (!(arc->width & 1))
+ {
+ DoPix(1, info.xorgo, info.yorg);
+ DoPix(3, info.xorgo, info.yorgo);
+ }
+ if (!info.end.x || !info.end.y)
+ {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ while (y < info.h || x < info.w)
+ {
+ MIARCOCTANTSHIFT(;);
+ if ((x == info.firstx) || (y == info.firsty))
+ startPt = arcPts[startseg];
+ if ((x == info.start.x) || (y == info.start.y))
+ {
+ mask = info.start.mask;
+ info.start = info.altstart;
+ }
+ DoPix(0, info.xorg + x, info.yorg + y);
+ DoPix(1, info.xorgo - x, info.yorg + y);
+ DoPix(2, info.xorgo - x, info.yorgo - y);
+ DoPix(3, info.xorg + x, info.yorgo - y);
+ if ((x == info.end.x) || (y == info.end.y))
+ {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ MIARCSTEP(;,;);
+ }
+ if ((x == info.firstx) || (y == info.firsty))
+ startPt = arcPts[startseg];
+ if ((x == info.start.x) || (y == info.start.y))
+ mask = info.start.mask;
+ DoPix(0, info.xorg + x, info.yorg + y);
+ DoPix(2, info.xorgo - x, info.yorgo - y);
+ if (arc->height & 1)
+ {
+ DoPix(1, info.xorgo - x, info.yorg + y);
+ DoPix(3, info.xorg + x, info.yorgo - y);
+ }
+ for (i = 0; i < 4; i++)
+ {
+ seg = (startseg + i) & 3;
+ pt = points + (seg * maxPts);
+ if (seg & 1)
+ {
+ startPts[i] = pt;
+ endPts[i] = arcPts[seg];
+ deltas[i] = 1;
+ }
+ else
+ {
+ startPts[i] = arcPts[seg] - 1;
+ endPts[i] = pt - 1;
+ deltas[i] = -1;
+ }
+ }
+ startPts[4] = startPts[0];
+ endPts[4] = startPt;
+ startPts[0] = startPt;
+ if (startseg & 1)
+ {
+ if (startPts[4] != endPts[4])
+ endPts[4]--;
+ deltas[4] = 1;
+ }
+ else
+ {
+ if (startPts[0] > startPts[4])
+ startPts[0]--;
+ if (startPts[4] < endPts[4])
+ endPts[4]--;
+ deltas[4] = -1;
+ }
+ if (arc->angle2 < 0)
+ {
+ DDXPointPtr tmps, tmpe;
+ int tmpd;
+
+ tmpd = deltas[0];
+ tmps = startPts[0] - tmpd;
+ tmpe = endPts[0] - tmpd;
+ startPts[0] = endPts[4] - deltas[4];
+ endPts[0] = startPts[4] - deltas[4];
+ deltas[0] = -deltas[4];
+ startPts[4] = tmpe;
+ endPts[4] = tmps;
+ deltas[4] = -tmpd;
+ tmpd = deltas[1];
+ tmps = startPts[1] - tmpd;
+ tmpe = endPts[1] - tmpd;
+ startPts[1] = endPts[3] - deltas[3];
+ endPts[1] = startPts[3] - deltas[3];
+ deltas[1] = -deltas[3];
+ startPts[3] = tmpe;
+ endPts[3] = tmps;
+ deltas[3] = -tmpd;
+ tmps = startPts[2] - deltas[2];
+ startPts[2] = endPts[2] - deltas[2];
+ endPts[2] = tmps;
+ deltas[2] = -deltas[2];
+ }
+ for (i = 0; i < 5 && startPts[i] == endPts[i]; i++)
+ ;
+ if (i == 5)
+ return;
+ pt = startPts[i];
+ for (j = 4; startPts[j] == endPts[j]; j--)
+ ;
+ lastPt = endPts[j] - deltas[j];
+ if (dinfo->haveLast &&
+ (pt->x == dinfo->endPt.x) && (pt->y == dinfo->endPt.y))
+ {
+ startPts[i] += deltas[i];
+ }
+ else
+ {
+ dinfo->dashIndex = dinfo->dashIndexInit;
+ dinfo->dashOffset = dinfo->dashOffsetInit;
+ }
+ if (!dinfo->skipStart && (info.startAngle != info.endAngle))
+ {
+ dinfo->startPt = *pt;
+ dinfo->haveStart = TRUE;
+ }
+ else if (!dinfo->skipLast && dinfo->haveStart &&
+ (lastPt->x == dinfo->startPt.x) &&
+ (lastPt->y == dinfo->startPt.y) &&
+ (lastPt != startPts[i]))
+ endPts[j] = lastPt;
+ if (info.startAngle != info.endAngle)
+ {
+ dinfo->haveLast = TRUE;
+ dinfo->endPt = *lastPt;
+ }
+ dashRemaining = pGC->dash[dinfo->dashIndex] - dinfo->dashOffset;
+ for (i = 0; i < 5; i++)
+ {
+ pt = startPts[i];
+ lastPt = endPts[i];
+ delta = deltas[i];
+ while (pt != lastPt)
+ {
+ if (dinfo->dashIndex & 1)
+ {
+ pts = *oddPts;
+ ptsdelta = -1;
+ }
+ else
+ {
+ pts = *evenPts;
+ ptsdelta = 1;
+ }
+ while ((pt != lastPt) && --dashRemaining >= 0)
+ {
+ *pts = *pt;
+ pts += ptsdelta;
+ pt += delta;
+ }
+ if (dinfo->dashIndex & 1)
+ *oddPts = pts;
+ else
+ *evenPts = pts;
+ if (dashRemaining <= 0)
+ {
+ if (++(dinfo->dashIndex) == pGC->numInDashList)
+ dinfo->dashIndex = 0;
+ dashRemaining = pGC->dash[dinfo->dashIndex];
+ }
+ }
+ }
+ dinfo->dashOffset = pGC->dash[dinfo->dashIndex] - dashRemaining;
+}
+
+void
+miZeroPolyArc(pDraw, pGC, narcs, parcs)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int narcs;
+ xArc *parcs;
+{
+ int maxPts = 0;
+ register int n, maxw = 0;
+ register xArc *arc;
+ register int i;
+ DDXPointPtr points, pts, oddPts;
+ register DDXPointPtr pt;
+ int numPts;
+ Bool dospans;
+ int *widths = NULL;
+ XID fgPixel = pGC->fgPixel;
+ DashInfo dinfo;
+
+ for (arc = parcs, i = narcs; --i >= 0; arc++)
+ {
+ if (!miCanZeroArc(arc))
+ miPolyArc(pDraw, pGC, 1, arc);
+ else
+ {
+ if (arc->width > arc->height)
+ n = arc->width + (arc->height >> 1);
+ else
+ n = arc->height + (arc->width >> 1);
+ if (n > maxPts)
+ maxPts = n;
+ }
+ }
+ if (!maxPts)
+ return;
+ numPts = maxPts << 2;
+ dospans = (pGC->fillStyle != FillSolid);
+ if (dospans)
+ {
+ widths = (int *)ALLOCATE_LOCAL(sizeof(int) * numPts);
+ if (!widths)
+ return;
+ maxw = 0;
+ }
+ if (pGC->lineStyle != LineSolid)
+ {
+ numPts <<= 1;
+ dinfo.haveStart = FALSE;
+ dinfo.skipStart = FALSE;
+ dinfo.haveLast = FALSE;
+ dinfo.dashIndexInit = 0;
+ dinfo.dashOffsetInit = 0;
+ miStepDash((int)pGC->dashOffset, &dinfo.dashIndexInit,
+ (unsigned char *) pGC->dash, (int)pGC->numInDashList,
+ &dinfo.dashOffsetInit);
+ }
+ points = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * numPts);
+ if (!points)
+ {
+ if (dospans)
+ {
+ DEALLOCATE_LOCAL(widths);
+ }
+ return;
+ }
+ for (arc = parcs, i = narcs; --i >= 0; arc++)
+ {
+ if (miCanZeroArc(arc))
+ {
+ if (pGC->lineStyle == LineSolid)
+ pts = miZeroArcPts(arc, points);
+ else
+ {
+ pts = points;
+ oddPts = &points[(numPts >> 1) - 1];
+ dinfo.skipLast = i;
+ miZeroArcDashPts(pGC, arc, &dinfo,
+ oddPts + 1, maxPts, &pts, &oddPts);
+ dinfo.skipStart = TRUE;
+ }
+ n = pts - points;
+ if (!dospans)
+ (*pGC->ops->PolyPoint)(pDraw, pGC, CoordModeOrigin, n, points);
+ else
+ {
+ if (n > maxw)
+ {
+ while (maxw < n)
+ widths[maxw++] = 1;
+ }
+ if (pGC->miTranslate)
+ {
+ for (pt = points; pt != pts; pt++)
+ {
+ pt->x += pDraw->x;
+ pt->y += pDraw->y;
+ }
+ }
+ (*pGC->ops->FillSpans)(pDraw, pGC, n, points, widths, FALSE);
+ }
+ if (pGC->lineStyle != LineDoubleDash)
+ continue;
+ if ((pGC->fillStyle == FillSolid) ||
+ (pGC->fillStyle == FillStippled))
+ {
+ DoChangeGC(pGC, GCForeground, (XID *)&pGC->bgPixel, 0);
+ ValidateGC(pDraw, pGC);
+ }
+ pts = &points[numPts >> 1];
+ oddPts++;
+ n = pts - oddPts;
+ if (!dospans)
+ (*pGC->ops->PolyPoint)(pDraw, pGC, CoordModeOrigin, n, oddPts);
+ else
+ {
+ if (n > maxw)
+ {
+ while (maxw < n)
+ widths[maxw++] = 1;
+ }
+ if (pGC->miTranslate)
+ {
+ for (pt = oddPts; pt != pts; pt++)
+ {
+ pt->x += pDraw->x;
+ pt->y += pDraw->y;
+ }
+ }
+ (*pGC->ops->FillSpans)(pDraw, pGC, n, oddPts, widths, FALSE);
+ }
+ if ((pGC->fillStyle == FillSolid) ||
+ (pGC->fillStyle == FillStippled))
+ {
+ DoChangeGC(pGC, GCForeground, &fgPixel, 0);
+ ValidateGC(pDraw, pGC);
+ }
+ }
+ }
+ DEALLOCATE_LOCAL(points);
+ if (dospans)
+ {
+ DEALLOCATE_LOCAL(widths);
+ }
+}
diff --git a/nx-X11/programs/Xserver/mi/mizerarc.h b/nx-X11/programs/Xserver/mi/mizerarc.h
new file mode 100644
index 000000000..99062d192
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mizerarc.h
@@ -0,0 +1,134 @@
+/* $XFree86: xc/programs/Xserver/mi/mizerarc.h,v 1.2 2001/08/06 20:51:20 dawes Exp $ */
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+********************************************************/
+
+/* $Xorg: mizerarc.h,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
+
+typedef struct {
+ int x;
+ int y;
+ int mask;
+} miZeroArcPtRec;
+
+typedef struct {
+ int x, y, k1, k3, a, b, d, dx, dy;
+ int alpha, beta;
+ int xorg, yorg;
+ int xorgo, yorgo;
+ int w, h;
+ int initialMask;
+ miZeroArcPtRec start, altstart, end, altend;
+ int firstx, firsty;
+ int startAngle, endAngle;
+} miZeroArcRec;
+
+#define miCanZeroArc(arc) (((arc)->width == (arc)->height) || \
+ (((arc)->width <= 800) && ((arc)->height <= 800)))
+
+#define MIARCSETUP() \
+ x = info.x; \
+ y = info.y; \
+ k1 = info.k1; \
+ k3 = info.k3; \
+ a = info.a; \
+ b = info.b; \
+ d = info.d; \
+ dx = info.dx; \
+ dy = info.dy
+
+#define MIARCOCTANTSHIFT(clause) \
+ if (a < 0) \
+ { \
+ if (y == info.h) \
+ { \
+ d = -1; \
+ a = b = k1 = 0; \
+ } \
+ else \
+ { \
+ dx = (k1 << 1) - k3; \
+ k1 = dx - k1; \
+ k3 = -k3; \
+ b = b + a - (k1 >> 1); \
+ d = b + ((-a) >> 1) - d + (k3 >> 3); \
+ if (dx < 0) \
+ a = -((-dx) >> 1) - a; \
+ else \
+ a = (dx >> 1) - a; \
+ dx = 0; \
+ dy = 1; \
+ clause \
+ } \
+ }
+
+#define MIARCSTEP(move1,move2) \
+ b -= k1; \
+ if (d < 0) \
+ { \
+ x += dx; \
+ y += dy; \
+ a += k1; \
+ d += b; \
+ move1 \
+ } \
+ else \
+ { \
+ x++; \
+ y++; \
+ a += k3; \
+ d -= a; \
+ move2 \
+ }
+
+#define MIARCCIRCLESTEP(clause) \
+ b -= k1; \
+ x++; \
+ if (d < 0) \
+ { \
+ a += k1; \
+ d += b; \
+ } \
+ else \
+ { \
+ y++; \
+ a += k3; \
+ d -= a; \
+ clause \
+ }
+
+/* mizerarc.c */
+
+extern Bool miZeroArcSetup(
+ xArc * /*arc*/,
+ miZeroArcRec * /*info*/,
+ Bool /*ok360*/
+);
+
+extern DDXPointPtr miZeroArcPts(
+ xArc * /*arc*/,
+ DDXPointPtr /*pts*/
+);
+
diff --git a/nx-X11/programs/Xserver/mi/mizerclip.c b/nx-X11/programs/Xserver/mi/mizerclip.c
new file mode 100644
index 000000000..e648b21d4
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mizerclip.c
@@ -0,0 +1,636 @@
+/* $XFree86: xc/programs/Xserver/mi/mizerclip.c,v 1.2 2001/08/06 20:51:20 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "misc.h"
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmap.h"
+#include "mi.h"
+#include "miline.h"
+
+/*
+
+The bresenham error equation used in the mi/mfb/cfb line routines is:
+
+ e = error
+ dx = difference in raw X coordinates
+ dy = difference in raw Y coordinates
+ M = # of steps in X direction
+ N = # of steps in Y direction
+ B = 0 to prefer diagonal steps in a given octant,
+ 1 to prefer axial steps in a given octant
+
+ For X major lines:
+ e = 2Mdy - 2Ndx - dx - B
+ -2dx <= e < 0
+
+ For Y major lines:
+ e = 2Ndx - 2Mdy - dy - B
+ -2dy <= e < 0
+
+At the start of the line, we have taken 0 X steps and 0 Y steps,
+so M = 0 and N = 0:
+
+ X major e = 2Mdy - 2Ndx - dx - B
+ = -dx - B
+
+ Y major e = 2Ndx - 2Mdy - dy - B
+ = -dy - B
+
+At the end of the line, we have taken dx X steps and dy Y steps,
+so M = dx and N = dy:
+
+ X major e = 2Mdy - 2Ndx - dx - B
+ = 2dxdy - 2dydx - dx - B
+ = -dx - B
+ Y major e = 2Ndx - 2Mdy - dy - B
+ = 2dydx - 2dxdy - dy - B
+ = -dy - B
+
+Thus, the error term is the same at the start and end of the line.
+
+Let us consider clipping an X coordinate. There are 4 cases which
+represent the two independent cases of clipping the start vs. the
+end of the line and an X major vs. a Y major line. In any of these
+cases, we know the number of X steps (M) and we wish to find the
+number of Y steps (N). Thus, we will solve our error term equation.
+If we are clipping the start of the line, we will find the smallest
+N that satisfies our error term inequality. If we are clipping the
+end of the line, we will find the largest number of Y steps that
+satisfies the inequality. In that case, since we are representing
+the Y steps as (dy - N), we will actually want to solve for the
+smallest N in that equation.
+
+Case 1: X major, starting X coordinate moved by M steps
+
+ -2dx <= 2Mdy - 2Ndx - dx - B < 0
+ 2Ndx <= 2Mdy - dx - B + 2dx 2Ndx > 2Mdy - dx - B
+ 2Ndx <= 2Mdy + dx - B N > (2Mdy - dx - B) / 2dx
+ N <= (2Mdy + dx - B) / 2dx
+
+Since we are trying to find the smallest N that satisfies these
+equations, we should use the > inequality to find the smallest:
+
+ N = floor((2Mdy - dx - B) / 2dx) + 1
+ = floor((2Mdy - dx - B + 2dx) / 2dx)
+ = floor((2Mdy + dx - B) / 2dx)
+
+Case 1b: X major, ending X coordinate moved to M steps
+
+Same derivations as Case 1, but we want the largest N that satisfies
+the equations, so we use the <= inequality:
+
+ N = floor((2Mdy + dx - B) / 2dx)
+
+Case 2: X major, ending X coordinate moved by M steps
+
+ -2dx <= 2(dx - M)dy - 2(dy - N)dx - dx - B < 0
+ -2dx <= 2dxdy - 2Mdy - 2dxdy + 2Ndx - dx - B < 0
+ -2dx <= 2Ndx - 2Mdy - dx - B < 0
+ 2Ndx >= 2Mdy + dx + B - 2dx 2Ndx < 2Mdy + dx + B
+ 2Ndx >= 2Mdy - dx + B N < (2Mdy + dx + B) / 2dx
+ N >= (2Mdy - dx + B) / 2dx
+
+Since we are trying to find the highest number of Y steps that
+satisfies these equations, we need to find the smallest N, so
+we should use the >= inequality to find the smallest:
+
+ N = ceiling((2Mdy - dx + B) / 2dx)
+ = floor((2Mdy - dx + B + 2dx - 1) / 2dx)
+ = floor((2Mdy + dx + B - 1) / 2dx)
+
+Case 2b: X major, starting X coordinate moved to M steps from end
+
+Same derivations as Case 2, but we want the smallest number of Y
+steps, so we want the highest N, so we use the < inequality:
+
+ N = ceiling((2Mdy + dx + B) / 2dx) - 1
+ = floor((2Mdy + dx + B + 2dx - 1) / 2dx) - 1
+ = floor((2Mdy + dx + B + 2dx - 1 - 2dx) / 2dx)
+ = floor((2Mdy + dx + B - 1) / 2dx)
+
+Case 3: Y major, starting X coordinate moved by M steps
+
+ -2dy <= 2Ndx - 2Mdy - dy - B < 0
+ 2Ndx >= 2Mdy + dy + B - 2dy 2Ndx < 2Mdy + dy + B
+ 2Ndx >= 2Mdy - dy + B N < (2Mdy + dy + B) / 2dx
+ N >= (2Mdy - dy + B) / 2dx
+
+Since we are trying to find the smallest N that satisfies these
+equations, we should use the >= inequality to find the smallest:
+
+ N = ceiling((2Mdy - dy + B) / 2dx)
+ = floor((2Mdy - dy + B + 2dx - 1) / 2dx)
+ = floor((2Mdy - dy + B - 1) / 2dx) + 1
+
+Case 3b: Y major, ending X coordinate moved to M steps
+
+Same derivations as Case 3, but we want the largest N that satisfies
+the equations, so we use the < inequality:
+
+ N = ceiling((2Mdy + dy + B) / 2dx) - 1
+ = floor((2Mdy + dy + B + 2dx - 1) / 2dx) - 1
+ = floor((2Mdy + dy + B + 2dx - 1 - 2dx) / 2dx)
+ = floor((2Mdy + dy + B - 1) / 2dx)
+
+Case 4: Y major, ending X coordinate moved by M steps
+
+ -2dy <= 2(dy - N)dx - 2(dx - M)dy - dy - B < 0
+ -2dy <= 2dxdy - 2Ndx - 2dxdy + 2Mdy - dy - B < 0
+ -2dy <= 2Mdy - 2Ndx - dy - B < 0
+ 2Ndx <= 2Mdy - dy - B + 2dy 2Ndx > 2Mdy - dy - B
+ 2Ndx <= 2Mdy + dy - B N > (2Mdy - dy - B) / 2dx
+ N <= (2Mdy + dy - B) / 2dx
+
+Since we are trying to find the highest number of Y steps that
+satisfies these equations, we need to find the smallest N, so
+we should use the > inequality to find the smallest:
+
+ N = floor((2Mdy - dy - B) / 2dx) + 1
+
+Case 4b: Y major, starting X coordinate moved to M steps from end
+
+Same analysis as Case 4, but we want the smallest number of Y steps
+which means the largest N, so we use the <= inequality:
+
+ N = floor((2Mdy + dy - B) / 2dx)
+
+Now let's try the Y coordinates, we have the same 4 cases.
+
+Case 5: X major, starting Y coordinate moved by N steps
+
+ -2dx <= 2Mdy - 2Ndx - dx - B < 0
+ 2Mdy >= 2Ndx + dx + B - 2dx 2Mdy < 2Ndx + dx + B
+ 2Mdy >= 2Ndx - dx + B M < (2Ndx + dx + B) / 2dy
+ M >= (2Ndx - dx + B) / 2dy
+
+Since we are trying to find the smallest M, we use the >= inequality:
+
+ M = ceiling((2Ndx - dx + B) / 2dy)
+ = floor((2Ndx - dx + B + 2dy - 1) / 2dy)
+ = floor((2Ndx - dx + B - 1) / 2dy) + 1
+
+Case 5b: X major, ending Y coordinate moved to N steps
+
+Same derivations as Case 5, but we want the largest M that satisfies
+the equations, so we use the < inequality:
+
+ M = ceiling((2Ndx + dx + B) / 2dy) - 1
+ = floor((2Ndx + dx + B + 2dy - 1) / 2dy) - 1
+ = floor((2Ndx + dx + B + 2dy - 1 - 2dy) / 2dy)
+ = floor((2Ndx + dx + B - 1) / 2dy)
+
+Case 6: X major, ending Y coordinate moved by N steps
+
+ -2dx <= 2(dx - M)dy - 2(dy - N)dx - dx - B < 0
+ -2dx <= 2dxdy - 2Mdy - 2dxdy + 2Ndx - dx - B < 0
+ -2dx <= 2Ndx - 2Mdy - dx - B < 0
+ 2Mdy <= 2Ndx - dx - B + 2dx 2Mdy > 2Ndx - dx - B
+ 2Mdy <= 2Ndx + dx - B M > (2Ndx - dx - B) / 2dy
+ M <= (2Ndx + dx - B) / 2dy
+
+Largest # of X steps means smallest M, so use the > inequality:
+
+ M = floor((2Ndx - dx - B) / 2dy) + 1
+
+Case 6b: X major, starting Y coordinate moved to N steps from end
+
+Same derivations as Case 6, but we want the smallest # of X steps
+which means the largest M, so use the <= inequality:
+
+ M = floor((2Ndx + dx - B) / 2dy)
+
+Case 7: Y major, starting Y coordinate moved by N steps
+
+ -2dy <= 2Ndx - 2Mdy - dy - B < 0
+ 2Mdy <= 2Ndx - dy - B + 2dy 2Mdy > 2Ndx - dy - B
+ 2Mdy <= 2Ndx + dy - B M > (2Ndx - dy - B) / 2dy
+ M <= (2Ndx + dy - B) / 2dy
+
+To find the smallest M, use the > inequality:
+
+ M = floor((2Ndx - dy - B) / 2dy) + 1
+ = floor((2Ndx - dy - B + 2dy) / 2dy)
+ = floor((2Ndx + dy - B) / 2dy)
+
+Case 7b: Y major, ending Y coordinate moved to N steps
+
+Same derivations as Case 7, but we want the largest M that satisfies
+the equations, so use the <= inequality:
+
+ M = floor((2Ndx + dy - B) / 2dy)
+
+Case 8: Y major, ending Y coordinate moved by N steps
+
+ -2dy <= 2(dy - N)dx - 2(dx - M)dy - dy - B < 0
+ -2dy <= 2dxdy - 2Ndx - 2dxdy + 2Mdy - dy - B < 0
+ -2dy <= 2Mdy - 2Ndx - dy - B < 0
+ 2Mdy >= 2Ndx + dy + B - 2dy 2Mdy < 2Ndx + dy + B
+ 2Mdy >= 2Ndx - dy + B M < (2Ndx + dy + B) / 2dy
+ M >= (2Ndx - dy + B) / 2dy
+
+To find the highest X steps, find the smallest M, use the >= inequality:
+
+ M = ceiling((2Ndx - dy + B) / 2dy)
+ = floor((2Ndx - dy + B + 2dy - 1) / 2dy)
+ = floor((2Ndx + dy + B - 1) / 2dy)
+
+Case 8b: Y major, starting Y coordinate moved to N steps from the end
+
+Same derivations as Case 8, but we want to find the smallest # of X
+steps which means the largest M, so we use the < inequality:
+
+ M = ceiling((2Ndx + dy + B) / 2dy) - 1
+ = floor((2Ndx + dy + B + 2dy - 1) / 2dy) - 1
+ = floor((2Ndx + dy + B + 2dy - 1 - 2dy) / 2dy)
+ = floor((2Ndx + dy + B - 1) / 2dy)
+
+So, our equations are:
+
+ 1: X major move x1 to x1+M floor((2Mdy + dx - B) / 2dx)
+ 1b: X major move x2 to x1+M floor((2Mdy + dx - B) / 2dx)
+ 2: X major move x2 to x2-M floor((2Mdy + dx + B - 1) / 2dx)
+ 2b: X major move x1 to x2-M floor((2Mdy + dx + B - 1) / 2dx)
+
+ 3: Y major move x1 to x1+M floor((2Mdy - dy + B - 1) / 2dx) + 1
+ 3b: Y major move x2 to x1+M floor((2Mdy + dy + B - 1) / 2dx)
+ 4: Y major move x2 to x2-M floor((2Mdy - dy - B) / 2dx) + 1
+ 4b: Y major move x1 to x2-M floor((2Mdy + dy - B) / 2dx)
+
+ 5: X major move y1 to y1+N floor((2Ndx - dx + B - 1) / 2dy) + 1
+ 5b: X major move y2 to y1+N floor((2Ndx + dx + B - 1) / 2dy)
+ 6: X major move y2 to y2-N floor((2Ndx - dx - B) / 2dy) + 1
+ 6b: X major move y1 to y2-N floor((2Ndx + dx - B) / 2dy)
+
+ 7: Y major move y1 to y1+N floor((2Ndx + dy - B) / 2dy)
+ 7b: Y major move y2 to y1+N floor((2Ndx + dy - B) / 2dy)
+ 8: Y major move y2 to y2-N floor((2Ndx + dy + B - 1) / 2dy)
+ 8b: Y major move y1 to y2-N floor((2Ndx + dy + B - 1) / 2dy)
+
+We have the following constraints on all of the above terms:
+
+ 0 < M,N <= 2^15 2^15 can be imposed by miZeroClipLine
+ 0 <= dx/dy <= 2^16 - 1
+ 0 <= B <= 1
+
+The floor in all of the above equations can be accomplished with a
+simple C divide operation provided that both numerator and denominator
+are positive.
+
+Since dx,dy >= 0 and since moving an X coordinate implies that dx != 0
+and moving a Y coordinate implies dy != 0, we know that the denominators
+are all > 0.
+
+For all lines, (-B) and (B-1) are both either 0 or -1, depending on the
+bias. Thus, we have to show that the 2MNdxy +/- dxy terms are all >= 1
+or > 0 to prove that the numerators are positive (or zero).
+
+For X Major lines we know that dx > 0 and since 2Mdy is >= 0 due to the
+constraints, the first four equations all have numerators >= 0.
+
+For the second four equations, M > 0, so 2Mdy >= 2dy so (2Mdy - dy) >= dy
+So (2Mdy - dy) > 0, since they are Y major lines. Also, (2Mdy + dy) >= 3dy
+or (2Mdy + dy) > 0. So all of their numerators are >= 0.
+
+For the third set of four equations, N > 0, so 2Ndx >= 2dx so (2Ndx - dx)
+>= dx > 0. Similarly (2Ndx + dx) >= 3dx > 0. So all numerators >= 0.
+
+For the fourth set of equations, dy > 0 and 2Ndx >= 0, so all numerators
+are > 0.
+
+To consider overflow, consider the case of 2 * M,N * dx,dy + dx,dy. This
+is bounded <= 2 * 2^15 * (2^16 - 1) + (2^16 - 1)
+ <= 2^16 * (2^16 - 1) + (2^16 - 1)
+ <= 2^32 - 2^16 + 2^16 - 1
+ <= 2^32 - 1
+Since the (-B) and (B-1) terms are all 0 or -1, the maximum value of
+the numerator is therefore (2^32 - 1), which does not overflow an unsigned
+32 bit variable.
+
+*/
+
+/* Bit codes for the terms of the 16 clipping equations defined below. */
+
+#define T_2NDX (1 << 0)
+#define T_2MDY (0) /* implicit term */
+#define T_DXNOTY (1 << 1)
+#define T_DYNOTX (0) /* implicit term */
+#define T_SUBDXORY (1 << 2)
+#define T_ADDDX (T_DXNOTY) /* composite term */
+#define T_SUBDX (T_DXNOTY | T_SUBDXORY) /* composite term */
+#define T_ADDDY (T_DYNOTX) /* composite term */
+#define T_SUBDY (T_DYNOTX | T_SUBDXORY) /* composite term */
+#define T_BIASSUBONE (1 << 3)
+#define T_SUBBIAS (0) /* implicit term */
+#define T_DIV2DX (1 << 4)
+#define T_DIV2DY (0) /* implicit term */
+#define T_ADDONE (1 << 5)
+
+/* Bit masks defining the 16 equations used in miZeroClipLine. */
+
+#define EQN1 (T_2MDY | T_ADDDX | T_SUBBIAS | T_DIV2DX)
+#define EQN1B (T_2MDY | T_ADDDX | T_SUBBIAS | T_DIV2DX)
+#define EQN2 (T_2MDY | T_ADDDX | T_BIASSUBONE | T_DIV2DX)
+#define EQN2B (T_2MDY | T_ADDDX | T_BIASSUBONE | T_DIV2DX)
+
+#define EQN3 (T_2MDY | T_SUBDY | T_BIASSUBONE | T_DIV2DX | T_ADDONE)
+#define EQN3B (T_2MDY | T_ADDDY | T_BIASSUBONE | T_DIV2DX)
+#define EQN4 (T_2MDY | T_SUBDY | T_SUBBIAS | T_DIV2DX | T_ADDONE)
+#define EQN4B (T_2MDY | T_ADDDY | T_SUBBIAS | T_DIV2DX)
+
+#define EQN5 (T_2NDX | T_SUBDX | T_BIASSUBONE | T_DIV2DY | T_ADDONE)
+#define EQN5B (T_2NDX | T_ADDDX | T_BIASSUBONE | T_DIV2DY)
+#define EQN6 (T_2NDX | T_SUBDX | T_SUBBIAS | T_DIV2DY | T_ADDONE)
+#define EQN6B (T_2NDX | T_ADDDX | T_SUBBIAS | T_DIV2DY)
+
+#define EQN7 (T_2NDX | T_ADDDY | T_SUBBIAS | T_DIV2DY)
+#define EQN7B (T_2NDX | T_ADDDY | T_SUBBIAS | T_DIV2DY)
+#define EQN8 (T_2NDX | T_ADDDY | T_BIASSUBONE | T_DIV2DY)
+#define EQN8B (T_2NDX | T_ADDDY | T_BIASSUBONE | T_DIV2DY)
+
+/* miZeroClipLine
+ *
+ * returns: 1 for partially clipped line
+ * -1 for completely clipped line
+ *
+ */
+int
+miZeroClipLine(xmin, ymin, xmax, ymax,
+ new_x1, new_y1, new_x2, new_y2,
+ adx, ady,
+ pt1_clipped, pt2_clipped, octant, bias, oc1, oc2)
+ int xmin, ymin, xmax, ymax;
+ int *new_x1, *new_y1, *new_x2, *new_y2;
+ int *pt1_clipped, *pt2_clipped;
+ unsigned int adx, ady;
+ int octant;
+ unsigned int bias;
+ int oc1, oc2;
+{
+ int swapped = 0;
+ int clipDone = 0;
+ CARD32 utmp = 0;
+ int clip1, clip2;
+ int x1, y1, x2, y2;
+ int x1_orig, y1_orig, x2_orig, y2_orig;
+ int xmajor;
+ int negslope = 0, anchorval = 0;
+ unsigned int eqn = 0;
+
+ x1 = x1_orig = *new_x1;
+ y1 = y1_orig = *new_y1;
+ x2 = x2_orig = *new_x2;
+ y2 = y2_orig = *new_y2;
+
+ clip1 = 0;
+ clip2 = 0;
+
+ xmajor = IsXMajorOctant(octant);
+ bias = ((bias >> octant) & 1);
+
+ while (1)
+ {
+ if ((oc1 & oc2) != 0) /* trivial reject */
+ {
+ clipDone = -1;
+ clip1 = oc1;
+ clip2 = oc2;
+ break;
+ }
+ else if ((oc1 | oc2) == 0) /* trivial accept */
+ {
+ clipDone = 1;
+ if (swapped)
+ {
+ SWAPINT_PAIR(x1, y1, x2, y2);
+ SWAPINT(clip1, clip2);
+ }
+ break;
+ }
+ else /* have to clip */
+ {
+ /* only clip one point at a time */
+ if (oc1 == 0)
+ {
+ SWAPINT_PAIR(x1, y1, x2, y2);
+ SWAPINT_PAIR(x1_orig, y1_orig, x2_orig, y2_orig);
+ SWAPINT(oc1, oc2);
+ SWAPINT(clip1, clip2);
+ swapped = !swapped;
+ }
+
+ clip1 |= oc1;
+ if (oc1 & OUT_LEFT)
+ {
+ negslope = IsYDecreasingOctant(octant);
+ utmp = xmin - x1_orig;
+ if (utmp <= 32767) /* clip based on near endpt */
+ {
+ if (xmajor)
+ eqn = (swapped) ? EQN2 : EQN1;
+ else
+ eqn = (swapped) ? EQN4 : EQN3;
+ anchorval = y1_orig;
+ }
+ else /* clip based on far endpt */
+ {
+ utmp = x2_orig - xmin;
+ if (xmajor)
+ eqn = (swapped) ? EQN1B : EQN2B;
+ else
+ eqn = (swapped) ? EQN3B : EQN4B;
+ anchorval = y2_orig;
+ negslope = !negslope;
+ }
+ x1 = xmin;
+ }
+ else if (oc1 & OUT_ABOVE)
+ {
+ negslope = IsXDecreasingOctant(octant);
+ utmp = ymin - y1_orig;
+ if (utmp <= 32767) /* clip based on near endpt */
+ {
+ if (xmajor)
+ eqn = (swapped) ? EQN6 : EQN5;
+ else
+ eqn = (swapped) ? EQN8 : EQN7;
+ anchorval = x1_orig;
+ }
+ else /* clip based on far endpt */
+ {
+ utmp = y2_orig - ymin;
+ if (xmajor)
+ eqn = (swapped) ? EQN5B : EQN6B;
+ else
+ eqn = (swapped) ? EQN7B : EQN8B;
+ anchorval = x2_orig;
+ negslope = !negslope;
+ }
+ y1 = ymin;
+ }
+ else if (oc1 & OUT_RIGHT)
+ {
+ negslope = IsYDecreasingOctant(octant);
+ utmp = x1_orig - xmax;
+ if (utmp <= 32767) /* clip based on near endpt */
+ {
+ if (xmajor)
+ eqn = (swapped) ? EQN2 : EQN1;
+ else
+ eqn = (swapped) ? EQN4 : EQN3;
+ anchorval = y1_orig;
+ }
+ else /* clip based on far endpt */
+ {
+ /*
+ * Technically since the equations can handle
+ * utmp == 32768, this overflow code isn't
+ * needed since X11 protocol can't generate
+ * a line which goes more than 32768 pixels
+ * to the right of a clip rectangle.
+ */
+ utmp = xmax - x2_orig;
+ if (xmajor)
+ eqn = (swapped) ? EQN1B : EQN2B;
+ else
+ eqn = (swapped) ? EQN3B : EQN4B;
+ anchorval = y2_orig;
+ negslope = !negslope;
+ }
+ x1 = xmax;
+ }
+ else if (oc1 & OUT_BELOW)
+ {
+ negslope = IsXDecreasingOctant(octant);
+ utmp = y1_orig - ymax;
+ if (utmp <= 32767) /* clip based on near endpt */
+ {
+ if (xmajor)
+ eqn = (swapped) ? EQN6 : EQN5;
+ else
+ eqn = (swapped) ? EQN8 : EQN7;
+ anchorval = x1_orig;
+ }
+ else /* clip based on far endpt */
+ {
+ /*
+ * Technically since the equations can handle
+ * utmp == 32768, this overflow code isn't
+ * needed since X11 protocol can't generate
+ * a line which goes more than 32768 pixels
+ * below the bottom of a clip rectangle.
+ */
+ utmp = ymax - y2_orig;
+ if (xmajor)
+ eqn = (swapped) ? EQN5B : EQN6B;
+ else
+ eqn = (swapped) ? EQN7B : EQN8B;
+ anchorval = x2_orig;
+ negslope = !negslope;
+ }
+ y1 = ymax;
+ }
+
+ if (swapped)
+ negslope = !negslope;
+
+ utmp <<= 1; /* utmp = 2N or 2M */
+ if (eqn & T_2NDX)
+ utmp = (utmp * adx);
+ else /* (eqn & T_2MDY) */
+ utmp = (utmp * ady);
+ if (eqn & T_DXNOTY)
+ if (eqn & T_SUBDXORY)
+ utmp -= adx;
+ else
+ utmp += adx;
+ else /* (eqn & T_DYNOTX) */
+ if (eqn & T_SUBDXORY)
+ utmp -= ady;
+ else
+ utmp += ady;
+ if (eqn & T_BIASSUBONE)
+ utmp += bias - 1;
+ else /* (eqn & T_SUBBIAS) */
+ utmp -= bias;
+ if (eqn & T_DIV2DX)
+ utmp /= (adx << 1);
+ else /* (eqn & T_DIV2DY) */
+ utmp /= (ady << 1);
+ if (eqn & T_ADDONE)
+ utmp++;
+
+ if (negslope)
+ utmp = -utmp;
+
+ if (eqn & T_2NDX) /* We are calculating X steps */
+ x1 = anchorval + utmp;
+ else /* else, Y steps */
+ y1 = anchorval + utmp;
+
+ oc1 = 0;
+ MIOUTCODES(oc1, x1, y1, xmin, ymin, xmax, ymax);
+ }
+ }
+
+ *new_x1 = x1;
+ *new_y1 = y1;
+ *new_x2 = x2;
+ *new_y2 = y2;
+
+ *pt1_clipped = clip1;
+ *pt2_clipped = clip2;
+
+ return clipDone;
+}
diff --git a/nx-X11/programs/Xserver/mi/mizerline.c b/nx-X11/programs/Xserver/mi/mizerline.c
new file mode 100644
index 000000000..8e62a8c94
--- /dev/null
+++ b/nx-X11/programs/Xserver/mi/mizerline.c
@@ -0,0 +1,380 @@
+/* $XFree86: xc/programs/Xserver/mi/mizerline.c,v 3.6 2001/08/06 20:51:20 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: mizerline.c,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "misc.h"
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmap.h"
+#include "mi.h"
+#include "miline.h"
+
+/* Draw lineSolid, fillStyle-independent zero width lines.
+ *
+ * Must keep X and Y coordinates in "ints" at least until after they're
+ * translated and clipped to accomodate CoordModePrevious lines with very
+ * large coordinates.
+ *
+ * Draws the same pixels regardless of sign(dx) or sign(dy).
+ *
+ * Ken Whaley
+ *
+ */
+
+/* largest positive value that can fit into a component of a point.
+ * Assumes that the point structure is {type x, y;} where type is
+ * a signed type.
+ */
+#define MAX_COORDINATE ((1 << (((sizeof(DDXPointRec) >> 1) << 3) - 1)) - 1)
+
+#define MI_OUTPUT_POINT(xx, yy)\
+{\
+ if ( !new_span && yy == current_y)\
+ {\
+ if (xx < spans->x)\
+ spans->x = xx;\
+ ++*widths;\
+ }\
+ else\
+ {\
+ ++Nspans;\
+ ++spans;\
+ ++widths;\
+ spans->x = xx;\
+ spans->y = yy;\
+ *widths = 1;\
+ current_y = yy;\
+ new_span = FALSE;\
+ }\
+}
+
+void
+miZeroLine(pDraw, pGC, mode, npt, pptInit)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt; /* number of points */
+ DDXPointPtr pptInit;
+{
+ int Nspans, current_y = 0;
+ DDXPointPtr ppt;
+ DDXPointPtr pspanInit, spans;
+ int *pwidthInit, *widths, list_len;
+ int xleft, ytop, xright, ybottom;
+ int new_x1, new_y1, new_x2, new_y2;
+ int x = 0, y = 0, x1, y1, x2, y2, xstart, ystart;
+ int oc1, oc2;
+ int result;
+ int pt1_clipped, pt2_clipped = 0;
+ Bool new_span;
+ int signdx, signdy;
+ int clipdx, clipdy;
+ int width, height;
+ int adx, ady;
+ int octant;
+ unsigned int bias = miGetZeroLineBias(pDraw->pScreen);
+ int e, e1, e2, e3; /* Bresenham error terms */
+ int length; /* length of lines == # of pixels on major axis */
+
+ xleft = pDraw->x;
+ ytop = pDraw->y;
+ xright = pDraw->x + pDraw->width - 1;
+ ybottom = pDraw->y + pDraw->height - 1;
+
+ if (!pGC->miTranslate)
+ {
+ /* do everything in drawable-relative coordinates */
+ xleft = 0;
+ ytop = 0;
+ xright -= pDraw->x;
+ ybottom -= pDraw->y;
+ }
+
+ /* it doesn't matter whether we're in drawable or screen coordinates,
+ * FillSpans simply cannot take starting coordinates outside of the
+ * range of a DDXPointRec component.
+ */
+ if (xright > MAX_COORDINATE)
+ xright = MAX_COORDINATE;
+ if (ybottom > MAX_COORDINATE)
+ ybottom = MAX_COORDINATE;
+
+ /* since we're clipping to the drawable's boundaries & coordinate
+ * space boundaries, we're guaranteed that the larger of width/height
+ * is the longest span we'll need to output
+ */
+ width = xright - xleft + 1;
+ height = ybottom - ytop + 1;
+ list_len = (height >= width) ? height : width;
+ pspanInit = (DDXPointPtr)ALLOCATE_LOCAL(list_len * sizeof(DDXPointRec));
+ pwidthInit = (int *)ALLOCATE_LOCAL(list_len * sizeof(int));
+ if (!pspanInit || !pwidthInit)
+ return;
+
+ Nspans = 0;
+ new_span = TRUE;
+ spans = pspanInit - 1;
+ widths = pwidthInit - 1;
+ ppt = pptInit;
+
+ xstart = ppt->x;
+ ystart = ppt->y;
+ if (pGC->miTranslate)
+ {
+ xstart += pDraw->x;
+ ystart += pDraw->y;
+ }
+
+ /* x2, y2, oc2 copied to x1, y1, oc1 at top of loop to simplify
+ * iteration logic
+ */
+ x2 = xstart;
+ y2 = ystart;
+ oc2 = 0;
+ MIOUTCODES(oc2, x2, y2, xleft, ytop, xright, ybottom);
+
+ while (--npt > 0)
+ {
+ if (Nspans > 0)
+ (*pGC->ops->FillSpans)(pDraw, pGC, Nspans, pspanInit,
+ pwidthInit, FALSE);
+ Nspans = 0;
+ new_span = TRUE;
+ spans = pspanInit - 1;
+ widths = pwidthInit - 1;
+
+ x1 = x2;
+ y1 = y2;
+ oc1 = oc2;
+ ++ppt;
+
+ x2 = ppt->x;
+ y2 = ppt->y;
+ if (pGC->miTranslate && (mode != CoordModePrevious))
+ {
+ x2 += pDraw->x;
+ y2 += pDraw->y;
+ }
+ else if (mode == CoordModePrevious)
+ {
+ x2 += x1;
+ y2 += y1;
+ }
+
+ oc2 = 0;
+ MIOUTCODES(oc2, x2, y2, xleft, ytop, xright, ybottom);
+
+ CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy, 1, 1, octant);
+
+ if (adx > ady)
+ {
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+ length = adx; /* don't draw endpoint in main loop */
+
+ FIXUP_ERROR(e, octant, bias);
+
+ new_x1 = x1;
+ new_y1 = y1;
+ new_x2 = x2;
+ new_y2 = y2;
+ pt1_clipped = 0;
+ pt2_clipped = 0;
+
+ if ((oc1 | oc2) != 0)
+ {
+ result = miZeroClipLine(xleft, ytop, xright, ybottom,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady,
+ &pt1_clipped, &pt2_clipped,
+ octant, bias, oc1, oc2);
+ if (result == -1)
+ continue;
+
+ length = abs(new_x2 - new_x1);
+
+ /* if we've clipped the endpoint, always draw the full length
+ * of the segment, because then the capstyle doesn't matter
+ */
+ if (pt2_clipped)
+ length++;
+
+ if (pt1_clipped)
+ {
+ /* must calculate new error terms */
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ e += (clipdy * e2) + ((clipdx - clipdy) * e1);
+ }
+ }
+
+ /* draw the segment */
+
+ x = new_x1;
+ y = new_y1;
+
+ e3 = e2 - e1;
+ e = e - e1;
+
+ while (length--)
+ {
+ MI_OUTPUT_POINT(x, y);
+ e += e1;
+ if (e >= 0)
+ {
+ y += signdy;
+ e += e3;
+ }
+ x += signdx;
+ }
+ }
+ else /* Y major line */
+ {
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ length = ady; /* don't draw endpoint in main loop */
+
+ SetYMajorOctant(octant);
+ FIXUP_ERROR(e, octant, bias);
+
+ new_x1 = x1;
+ new_y1 = y1;
+ new_x2 = x2;
+ new_y2 = y2;
+ pt1_clipped = 0;
+ pt2_clipped = 0;
+
+ if ((oc1 | oc2) != 0)
+ {
+ result = miZeroClipLine(xleft, ytop, xright, ybottom,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady,
+ &pt1_clipped, &pt2_clipped,
+ octant, bias, oc1, oc2);
+ if (result == -1)
+ continue;
+
+ length = abs(new_y2 - new_y1);
+
+ /* if we've clipped the endpoint, always draw the full length
+ * of the segment, because then the capstyle doesn't matter
+ */
+ if (pt2_clipped)
+ length++;
+
+ if (pt1_clipped)
+ {
+ /* must calculate new error terms */
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ e += (clipdx * e2) + ((clipdy - clipdx) * e1);
+ }
+ }
+
+ /* draw the segment */
+
+ x = new_x1;
+ y = new_y1;
+
+ e3 = e2 - e1;
+ e = e - e1;
+
+ while (length--)
+ {
+ MI_OUTPUT_POINT(x, y);
+ e += e1;
+ if (e >= 0)
+ {
+ x += signdx;
+ e += e3;
+ }
+ y += signdy;
+ }
+ }
+ }
+
+ /* only do the capnotlast check on the last segment
+ * and only if the endpoint wasn't clipped. And then, if the last
+ * point is the same as the first point, do not draw it, unless the
+ * line is degenerate
+ */
+ if ( (! pt2_clipped) && (pGC->capStyle != CapNotLast) &&
+ (((xstart != x2) || (ystart != y2)) || (ppt == pptInit + 1)))
+ {
+ MI_OUTPUT_POINT(x, y);
+ }
+
+ if (Nspans > 0)
+ (*pGC->ops->FillSpans)(pDraw, pGC, Nspans, pspanInit,
+ pwidthInit, FALSE);
+
+ DEALLOCATE_LOCAL(pwidthInit);
+ DEALLOCATE_LOCAL(pspanInit);
+}
+
+void
+miZeroDashLine(dst, pgc, mode, nptInit, pptInit)
+DrawablePtr dst;
+GCPtr pgc;
+int mode;
+int nptInit; /* number of points in polyline */
+DDXPointRec *pptInit; /* points in the polyline */
+{
+ /* XXX kludge until real zero-width dash code is written */
+ pgc->lineWidth = 1;
+ miWideDash (dst, pgc, mode, nptInit, pptInit);
+ pgc->lineWidth = 0;
+}
diff --git a/nx-X11/programs/Xserver/miext/cw/Imakefile b/nx-X11/programs/Xserver/miext/cw/Imakefile
new file mode 100755
index 000000000..39106ac13
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/cw/Imakefile
@@ -0,0 +1,22 @@
+#define IHaveModules
+#include <Server.tmpl>
+
+SRCS = cw.c cw_ops.c cw_render.c
+
+OBJS = cw.o cw_ops.o cw_render.o
+
+ INCLUDES = -I../../mi -I../../fb -I../../render -I../../composite \
+ -I../../include -I$(XINCLUDESRC) $(EXTRAINCLUDES) \
+ -I$(EXTINCSRC)
+ LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln \
+ ../../mi/llib-lmi.ln
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(cw,$(OBJS))
+LintLibraryTarget(cw,$(SRCS))
+
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
+InstallDriverSDKNonExecFile(cw.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/miext/cw/cw.c b/nx-X11/programs/Xserver/miext/cw/cw.c
new file mode 100644
index 000000000..0fdd6547e
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/cw/cw.c
@@ -0,0 +1,699 @@
+/*
+ * Copyright © 2004 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $Header: /cvs/xorg/xc/programs/Xserver/miext/cw/cw.c,v 1.23 2005/10/02 08:28:26 anholt Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "cw.h"
+
+#define CW_DEBUG 1
+
+#if CW_DEBUG
+#define CW_ASSERT(x) do { \
+ if (!(x)) { \
+ ErrorF("composite wrapper: assertion failed at %s:%d\n", __FUNC__, \
+ __LINE__); \
+ } \
+} while (0)
+#else
+#define CW_ASSERT(x) do {} while (0)
+#endif
+
+int cwGCIndex;
+int cwScreenIndex;
+int cwWindowIndex;
+#ifdef RENDER
+int cwPictureIndex;
+#endif
+static Bool cwDisabled[MAXSCREENS];
+static unsigned long cwGeneration = 0;
+extern GCOps cwGCOps;
+
+static Bool
+cwCloseScreen (int i, ScreenPtr pScreen);
+
+static void
+cwValidateGC(GCPtr pGC, unsigned long stateChanges, DrawablePtr pDrawable);
+static void
+cwChangeGC(GCPtr pGC, unsigned long mask);
+static void
+cwCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
+static void
+cwDestroyGC(GCPtr pGC);
+static void
+cwChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects);
+static void
+cwCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
+static void
+cwDestroyClip(GCPtr pGC);
+
+GCFuncs cwGCFuncs = {
+ cwValidateGC,
+ cwChangeGC,
+ cwCopyGC,
+ cwDestroyGC,
+ cwChangeClip,
+ cwDestroyClip,
+ cwCopyClip,
+};
+
+/* Find the real drawable to draw to, and provide offsets that will translate
+ * window coordinates to backing pixmap coordinates.
+ */
+DrawablePtr
+cwGetBackingDrawable(DrawablePtr pDrawable, int *x_off, int *y_off)
+{
+ PixmapPtr pPixmap;
+
+ if (pDrawable->type == DRAWABLE_WINDOW &&
+ (pPixmap = getCwPixmap ((WindowPtr) pDrawable)))
+ {
+ *x_off = pDrawable->x - pPixmap->screen_x;
+ *y_off = pDrawable->y - pPixmap->screen_y;
+ return &pPixmap->drawable;
+ } else {
+ *x_off = *y_off = 0;
+ return pDrawable;
+ }
+}
+
+#define FUNC_PROLOGUE(pGC, pPriv) do { \
+ (pGC)->funcs = (pPriv)->wrapFuncs; \
+ (pGC)->ops = (pPriv)->wrapOps; \
+} while (0)
+
+#define FUNC_EPILOGUE(pGC, pPriv) do { \
+ (pPriv)->wrapFuncs = (pGC)->funcs; \
+ (pPriv)->wrapOps = (pGC)->ops; \
+ (pGC)->funcs = &cwGCFuncs; \
+ (pGC)->ops = &cwGCOps; \
+} while (0)
+
+
+static Bool
+cwCreateBackingGC(GCPtr pGC, DrawablePtr pDrawable)
+{
+ cwGCRec *pPriv = getCwGC(pGC);
+ int status, x_off, y_off;
+ XID noexpose = xFalse;
+ DrawablePtr pBackingDrawable;
+
+ pBackingDrawable = cwGetBackingDrawable(pDrawable, &x_off, &y_off);
+ pPriv->pBackingGC = CreateGC(pBackingDrawable, GCGraphicsExposures,
+ &noexpose, &status);
+ if (status != Success)
+ return FALSE;
+
+ pPriv->serialNumber = 0;
+ pPriv->stateChanges = (1 << (GCLastBit + 1)) - 1;
+
+ return TRUE;
+}
+
+static void
+cwDestroyBackingGC(GCPtr pGC)
+{
+ cwGCPtr pPriv;
+
+ pPriv = (cwGCPtr) getCwGC (pGC);
+
+ if (pPriv->pBackingGC) {
+ FreeGC(pPriv->pBackingGC, (XID)0);
+ pPriv->pBackingGC = NULL;
+ }
+}
+
+static void
+cwValidateGC(GCPtr pGC, unsigned long stateChanges, DrawablePtr pDrawable)
+{
+ GCPtr pBackingGC;
+ cwGCPtr pPriv;
+ DrawablePtr pBackingDrawable;
+ int x_off, y_off;
+
+ pPriv = (cwGCPtr) getCwGC (pGC);
+
+ FUNC_PROLOGUE(pGC, pPriv);
+
+ /*
+ * Must call ValidateGC to ensure pGC->pCompositeClip is valid
+ */
+ (*pGC->funcs->ValidateGC)(pGC, stateChanges, pDrawable);
+
+ if (!cwDrawableIsRedirWindow(pDrawable)) {
+ cwDestroyBackingGC(pGC);
+ FUNC_EPILOGUE(pGC, pPriv);
+ return;
+ } else {
+ if (!pPriv->pBackingGC && !cwCreateBackingGC(pGC, pDrawable)) {
+ FUNC_EPILOGUE(pGC, pPriv);
+ return;
+ }
+ }
+
+ pBackingGC = pPriv->pBackingGC;
+ pBackingDrawable = cwGetBackingDrawable(pDrawable, &x_off, &y_off);
+
+ pPriv->stateChanges |= stateChanges;
+
+ /*
+ * Copy the composite clip into the backing GC if either
+ * the drawable clip list has changed or the client has changed
+ * the client clip data
+ */
+ if (pDrawable->serialNumber != pPriv->serialNumber ||
+ (pPriv->stateChanges & (GCClipXOrigin|GCClipYOrigin|GCClipMask)))
+ {
+ XID vals[2];
+ RegionPtr pCompositeClip;
+
+ pCompositeClip = REGION_CREATE (pScreen, NULL, 0);
+ REGION_COPY (pScreen, pCompositeClip, pGC->pCompositeClip);
+
+ /* Either the drawable has changed, or the clip list in the drawable has
+ * changed. Copy the new clip list over and set the new translated
+ * offset for it.
+ */
+
+ (*pBackingGC->funcs->ChangeClip) (pBackingGC, CT_REGION,
+ (pointer) pCompositeClip, 0);
+
+ vals[0] = x_off - pDrawable->x;
+ vals[1] = y_off - pDrawable->y;
+ dixChangeGC(NullClient, pBackingGC,
+ (GCClipXOrigin | GCClipYOrigin), vals, NULL);
+
+ pPriv->serialNumber = pDrawable->serialNumber;
+ /*
+ * Mask off any client clip changes to make sure
+ * the clip list set above remains in effect
+ */
+ pPriv->stateChanges &= ~(GCClipXOrigin|GCClipYOrigin|GCClipMask);
+ }
+
+ if (pPriv->stateChanges) {
+ CopyGC(pGC, pBackingGC, pPriv->stateChanges);
+ pPriv->stateChanges = 0;
+ }
+
+ if ((pGC->patOrg.x + x_off) != pBackingGC->patOrg.x ||
+ (pGC->patOrg.y + y_off) != pBackingGC->patOrg.y)
+ {
+ XID vals[2];
+ vals[0] = pGC->patOrg.x + x_off;
+ vals[1] = pGC->patOrg.y + y_off;
+ dixChangeGC(NullClient, pBackingGC,
+ (GCTileStipXOrigin | GCTileStipYOrigin), vals, NULL);
+ }
+
+ ValidateGC(pBackingDrawable, pBackingGC);
+
+ FUNC_EPILOGUE(pGC, pPriv);
+}
+
+static void
+cwChangeGC(GCPtr pGC, unsigned long mask)
+{
+ cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr;
+
+ FUNC_PROLOGUE(pGC, pPriv);
+
+ (*pGC->funcs->ChangeGC) (pGC, mask);
+
+ FUNC_EPILOGUE(pGC, pPriv);
+}
+
+static void
+cwCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
+{
+ cwGCPtr pPriv = (cwGCPtr)(pGCDst)->devPrivates[cwGCIndex].ptr;
+
+ FUNC_PROLOGUE(pGCDst, pPriv);
+
+ (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
+
+ FUNC_EPILOGUE(pGCDst, pPriv);
+}
+
+static void
+cwDestroyGC(GCPtr pGC)
+{
+ cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr;
+
+ FUNC_PROLOGUE(pGC, pPriv);
+
+ cwDestroyBackingGC(pGC);
+
+ (*pGC->funcs->DestroyGC) (pGC);
+
+ /* leave it unwrapped */
+}
+
+static void
+cwChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects)
+{
+ cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr;
+
+ FUNC_PROLOGUE(pGC, pPriv);
+
+ (*pGC->funcs->ChangeClip)(pGC, type, pvalue, nrects);
+
+ FUNC_EPILOGUE(pGC, pPriv);
+}
+
+static void
+cwCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
+{
+ cwGCPtr pPriv = (cwGCPtr)(pgcDst)->devPrivates[cwGCIndex].ptr;
+
+ FUNC_PROLOGUE(pgcDst, pPriv);
+
+ (*pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
+
+ FUNC_EPILOGUE(pgcDst, pPriv);
+}
+
+static void
+cwDestroyClip(GCPtr pGC)
+{
+ cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr;
+
+ FUNC_PROLOGUE(pGC, pPriv);
+
+ (*pGC->funcs->DestroyClip)(pGC);
+
+ FUNC_EPILOGUE(pGC, pPriv);
+}
+
+/*
+ * Screen wrappers.
+ */
+
+#define SCREEN_PROLOGUE(pScreen, field) \
+ ((pScreen)->field = getCwScreen(pScreen)->field)
+
+#define SCREEN_EPILOGUE(pScreen, field, wrapper) do { \
+ getCwScreen(pScreen)->field = (pScreen)->field; \
+ (pScreen)->field = (wrapper); \
+} while (0)
+
+static Bool
+cwCreateGC(GCPtr pGC)
+{
+ cwGCPtr pPriv = getCwGC(pGC);
+ ScreenPtr pScreen = pGC->pScreen;
+ Bool ret;
+
+ bzero(pPriv, sizeof(cwGCRec));
+ SCREEN_PROLOGUE(pScreen, CreateGC);
+
+ if ( (ret = (*pScreen->CreateGC)(pGC)) )
+ FUNC_EPILOGUE(pGC, pPriv);
+
+ SCREEN_EPILOGUE(pScreen, CreateGC, cwCreateGC);
+
+ return ret;
+}
+
+static void
+cwGetImage(DrawablePtr pSrc, int x, int y, int w, int h, unsigned int format,
+ unsigned long planemask, char *pdstLine)
+{
+ ScreenPtr pScreen = pSrc->pScreen;
+ DrawablePtr pBackingDrawable;
+ int src_off_x, src_off_y;
+
+ SCREEN_PROLOGUE(pScreen, GetImage);
+
+ pBackingDrawable = cwGetBackingDrawable(pSrc, &src_off_x, &src_off_y);
+
+ CW_OFFSET_XY_SRC(x, y);
+
+ (*pScreen->GetImage)(pBackingDrawable, x, y, w, h, format, planemask,
+ pdstLine);
+
+ SCREEN_EPILOGUE(pScreen, GetImage, cwGetImage);
+}
+
+static void
+cwGetSpans(DrawablePtr pSrc, int wMax, DDXPointPtr ppt, int *pwidth,
+ int nspans, char *pdstStart)
+{
+ ScreenPtr pScreen = pSrc->pScreen;
+ DrawablePtr pBackingDrawable;
+ int i;
+ int src_off_x, src_off_y;
+
+ SCREEN_PROLOGUE(pScreen, GetSpans);
+
+ pBackingDrawable = cwGetBackingDrawable(pSrc, &src_off_x, &src_off_y);
+
+ for (i = 0; i < nspans; i++)
+ CW_OFFSET_XY_SRC(ppt[i].x, ppt[i].y);
+
+ (*pScreen->GetSpans)(pBackingDrawable, wMax, ppt, pwidth, nspans,
+ pdstStart);
+
+ SCREEN_EPILOGUE(pScreen, GetSpans, cwGetSpans);
+}
+
+static void
+cwFillRegionSolid(DrawablePtr pDrawable, RegionPtr pRegion, unsigned long pixel)
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ GCPtr pGC;
+ BoxPtr pBox;
+ int nbox, i;
+ ChangeGCVal v[3];
+
+ pGC = GetScratchGC(pDrawable->depth, pScreen);
+ v[0].val = GXcopy;
+ v[1].val = pixel;
+ v[2].val = FillSolid;
+ dixChangeGC(NullClient, pGC, (GCFunction | GCForeground | GCFillStyle),
+ NULL, v);
+ ValidateGC(pDrawable, pGC);
+
+ pBox = REGION_RECTS(pRegion);
+ nbox = REGION_NUM_RECTS(pRegion);
+
+ for (i = 0; i < nbox; i++, pBox++) {
+ xRectangle rect;
+ rect.x = pBox->x1;
+ rect.y = pBox->y1;
+ rect.width = pBox->x2 - pBox->x1;
+ rect.height = pBox->y2 - pBox->y1;
+ (*pGC->ops->PolyFillRect)(pDrawable, pGC, 1, &rect);
+ }
+
+ FreeScratchGC(pGC);
+}
+
+static void
+cwFillRegionTiled(DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
+ int x_off, int y_off)
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ GCPtr pGC;
+ BoxPtr pBox;
+ int nbox, i;
+ ChangeGCVal v[5];
+
+ pGC = GetScratchGC(pDrawable->depth, pScreen);
+ v[0].val = GXcopy;
+ v[1].val = FillTiled;
+ v[2].ptr = (pointer) pTile;
+ v[3].val = x_off;
+ v[4].val = y_off;
+ dixChangeGC(NullClient, pGC, (GCFunction | GCFillStyle | GCTile |
+ GCTileStipXOrigin | GCTileStipYOrigin), NULL, v);
+
+ ValidateGC(pDrawable, pGC);
+
+ pBox = REGION_RECTS(pRegion);
+ nbox = REGION_NUM_RECTS(pRegion);
+
+ for (i = 0; i < nbox; i++, pBox++) {
+ xRectangle rect;
+ rect.x = pBox->x1;
+ rect.y = pBox->y1;
+ rect.width = pBox->x2 - pBox->x1;
+ rect.height = pBox->y2 - pBox->y1;
+ (*pGC->ops->PolyFillRect)(pDrawable, pGC, 1, &rect);
+ }
+
+ FreeScratchGC(pGC);
+}
+
+static void
+cwPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ SCREEN_PROLOGUE(pScreen, PaintWindowBackground);
+
+ if (!cwDrawableIsRedirWindow((DrawablePtr)pWin)) {
+ (*pScreen->PaintWindowBackground)(pWin, pRegion, what);
+ } else {
+ DrawablePtr pBackingDrawable;
+ int x_off, y_off, x_screen, y_screen;
+
+ while (pWin && pWin->backgroundState == ParentRelative)
+ pWin = pWin->parent;
+
+ pBackingDrawable = cwGetBackingDrawable((DrawablePtr)pWin, &x_off,
+ &y_off);
+
+ x_screen = x_off - pWin->drawable.x;
+ y_screen = y_off - pWin->drawable.y;
+
+ if (pWin && (pWin->backgroundState == BackgroundPixel ||
+ pWin->backgroundState == BackgroundPixmap))
+ {
+ REGION_TRANSLATE(pScreen, pRegion, x_screen, y_screen);
+
+ if (pWin->backgroundState == BackgroundPixel) {
+ cwFillRegionSolid(pBackingDrawable, pRegion,
+ pWin->background.pixel);
+ } else {
+ cwFillRegionTiled(pBackingDrawable, pRegion,
+ pWin->background.pixmap, x_off, y_off);
+ }
+
+ REGION_TRANSLATE(pScreen, pRegion, -x_screen, -y_screen);
+ }
+ }
+
+ SCREEN_EPILOGUE(pScreen, PaintWindowBackground, cwPaintWindowBackground);
+}
+
+static void
+cwPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ SCREEN_PROLOGUE(pScreen, PaintWindowBorder);
+
+ if (!cwDrawableIsRedirWindow((DrawablePtr)pWin)) {
+ (*pScreen->PaintWindowBorder)(pWin, pRegion, what);
+ } else {
+ DrawablePtr pBackingDrawable;
+ int x_off, y_off, x_screen, y_screen;
+
+ pBackingDrawable = cwGetBackingDrawable((DrawablePtr)pWin, &x_off,
+ &y_off);
+
+ x_screen = x_off - pWin->drawable.x;
+ y_screen = y_off - pWin->drawable.y;
+
+ REGION_TRANSLATE(pScreen, pRegion, x_screen, y_screen);
+
+ if (pWin->borderIsPixel) {
+ cwFillRegionSolid(pBackingDrawable, pRegion, pWin->border.pixel);
+ } else {
+ cwFillRegionTiled(pBackingDrawable, pRegion, pWin->border.pixmap,
+ x_off, y_off);
+ }
+
+ REGION_TRANSLATE(pScreen, pRegion, -x_screen, -y_screen);
+ }
+
+ SCREEN_EPILOGUE(pScreen, PaintWindowBorder, cwPaintWindowBorder);
+}
+
+static void
+cwCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ SCREEN_PROLOGUE(pScreen, CopyWindow);
+
+ if (!cwDrawableIsRedirWindow((DrawablePtr)pWin)) {
+ (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
+ } else {
+ GCPtr pGC;
+ BoxPtr pExtents;
+ int x_off, y_off;
+ int dx, dy;
+ PixmapPtr pBackingPixmap;
+ RegionPtr pClip;
+ int src_x, src_y, dst_x, dst_y, w, h;
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+
+ pExtents = REGION_EXTENTS(pScreen, prgnSrc);
+
+ pBackingPixmap = (PixmapPtr) cwGetBackingDrawable((DrawablePtr)pWin,
+ &x_off, &y_off);
+
+ src_x = pExtents->x1 - pBackingPixmap->screen_x;
+ src_y = pExtents->y1 - pBackingPixmap->screen_y;
+ w = pExtents->x2 - pExtents->x1;
+ h = pExtents->y2 - pExtents->y1;
+ dst_x = src_x - dx;
+ dst_y = src_y - dy;
+
+ /* Translate region (as required by API) */
+ REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
+
+ pGC = GetScratchGC(pBackingPixmap->drawable.depth, pScreen);
+ /*
+ * Copy region to GC as clip, aligning as dest clip
+ */
+ pClip = REGION_CREATE (pScreen, NULL, 0);
+ REGION_INTERSECT(pScreen, pClip, &pWin->borderClip, prgnSrc);
+ REGION_TRANSLATE(pScreen, pClip,
+ -pBackingPixmap->screen_x,
+ -pBackingPixmap->screen_y);
+
+ (*pGC->funcs->ChangeClip) (pGC, CT_REGION, pClip, 0);
+
+ ValidateGC(&pBackingPixmap->drawable, pGC);
+
+ (*pGC->ops->CopyArea) (&pBackingPixmap->drawable,
+ &pBackingPixmap->drawable, pGC,
+ src_x, src_y, w, h, dst_x, dst_y);
+
+ (*pGC->funcs->DestroyClip) (pGC);
+
+ FreeScratchGC(pGC);
+ }
+
+ SCREEN_EPILOGUE(pScreen, CopyWindow, cwCopyWindow);
+}
+
+static PixmapPtr
+cwGetWindowPixmap (WindowPtr pWin)
+{
+ PixmapPtr pPixmap = getCwPixmap (pWin);
+
+ if (!pPixmap)
+ {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ SCREEN_PROLOGUE(pScreen, GetWindowPixmap);
+ if (pScreen->GetWindowPixmap)
+ pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ SCREEN_EPILOGUE(pScreen, GetWindowPixmap, cwGetWindowPixmap);
+ }
+ return pPixmap;
+}
+
+static void
+cwSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+
+ if (pPixmap == (*pScreen->GetScreenPixmap) (pScreen))
+ pPixmap = NULL;
+ setCwPixmap (pWindow, pPixmap);
+}
+
+/* Screen initialization/teardown */
+void
+miInitializeCompositeWrapper(ScreenPtr pScreen)
+{
+ cwScreenPtr pScreenPriv;
+
+ if (cwDisabled[pScreen->myNum])
+ return;
+
+ if (cwGeneration != serverGeneration)
+ {
+ cwScreenIndex = AllocateScreenPrivateIndex();
+ if (cwScreenIndex < 0)
+ return;
+ cwGCIndex = AllocateGCPrivateIndex();
+ cwWindowIndex = AllocateWindowPrivateIndex();
+#ifdef RENDER
+ cwPictureIndex = AllocatePicturePrivateIndex();
+#endif
+ cwGeneration = serverGeneration;
+ }
+ if (!AllocateGCPrivate(pScreen, cwGCIndex, sizeof(cwGCRec)))
+ return;
+ if (!AllocateWindowPrivate(pScreen, cwWindowIndex, 0))
+ return;
+#ifdef RENDER
+ if (!AllocatePicturePrivate(pScreen, cwPictureIndex, 0))
+ return;
+#endif
+ pScreenPriv = (cwScreenPtr)xalloc(sizeof(cwScreenRec));
+ if (!pScreenPriv)
+ return;
+
+ pScreen->devPrivates[cwScreenIndex].ptr = (pointer)pScreenPriv;
+
+ SCREEN_EPILOGUE(pScreen, CloseScreen, cwCloseScreen);
+ SCREEN_EPILOGUE(pScreen, GetImage, cwGetImage);
+ SCREEN_EPILOGUE(pScreen, GetSpans, cwGetSpans);
+ SCREEN_EPILOGUE(pScreen, CreateGC, cwCreateGC);
+ SCREEN_EPILOGUE(pScreen, PaintWindowBackground, cwPaintWindowBackground);
+ SCREEN_EPILOGUE(pScreen, PaintWindowBorder, cwPaintWindowBorder);
+ SCREEN_EPILOGUE(pScreen, CopyWindow, cwCopyWindow);
+
+ SCREEN_EPILOGUE(pScreen, SetWindowPixmap, cwSetWindowPixmap);
+ SCREEN_EPILOGUE(pScreen, GetWindowPixmap, cwGetWindowPixmap);
+
+#ifdef RENDER
+ if (GetPictureScreen (pScreen))
+ cwInitializeRender(pScreen);
+#endif
+}
+
+void
+miDisableCompositeWrapper(ScreenPtr pScreen)
+{
+ cwDisabled[pScreen->myNum] = TRUE;
+}
+
+static Bool
+cwCloseScreen (int i, ScreenPtr pScreen)
+{
+ cwScreenPtr pScreenPriv;
+#ifdef RENDER
+ PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
+#endif
+
+ pScreenPriv = (cwScreenPtr)pScreen->devPrivates[cwScreenIndex].ptr;
+
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+ pScreen->GetImage = pScreenPriv->GetImage;
+ pScreen->GetSpans = pScreenPriv->GetSpans;
+ pScreen->CreateGC = pScreenPriv->CreateGC;
+ pScreen->PaintWindowBackground = pScreenPriv->PaintWindowBackground;
+ pScreen->PaintWindowBorder = pScreenPriv->PaintWindowBorder;
+ pScreen->CopyWindow = pScreenPriv->CopyWindow;
+
+#ifdef RENDER
+ if (ps)
+ cwFiniRender(pScreen);
+#endif
+
+ xfree((pointer)pScreenPriv);
+
+ return (*pScreen->CloseScreen)(i, pScreen);
+}
diff --git a/nx-X11/programs/Xserver/miext/cw/cw.h b/nx-X11/programs/Xserver/miext/cw/cw.h
new file mode 100644
index 000000000..2563aed5e
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/cw/cw.h
@@ -0,0 +1,174 @@
+/*
+ * Copyright © 2004 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $Header: /cvs/xorg/xc/programs/Xserver/miext/cw/cw.h,v 1.14 2005/12/09 18:32:46 ajax Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "gcstruct.h"
+#include "picturestr.h"
+
+/*
+ * One of these structures is allocated per GC that gets used with a window with
+ * backing pixmap.
+ */
+
+typedef struct {
+ GCPtr pBackingGC; /* Copy of the GC but with graphicsExposures
+ * set FALSE and the clientClip set to
+ * clip output to the valid regions of the
+ * backing pixmap. */
+ unsigned long serialNumber; /* clientClip computed time */
+ unsigned long stateChanges; /* changes in parent gc since last copy */
+ GCOps *wrapOps; /* wrapped ops */
+ GCFuncs *wrapFuncs; /* wrapped funcs */
+} cwGCRec, *cwGCPtr;
+
+extern int cwGCIndex;
+
+#define getCwGC(pGC) ((cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr)
+#define setCwGC(pGC,p) ((pGC)->devPrivates[cwGCIndex].ptr = (pointer) (p))
+
+/*
+ * One of these structures is allocated per Picture that gets used with a
+ * window with a backing pixmap
+ */
+
+typedef struct {
+ PicturePtr pBackingPicture;
+ unsigned long serialNumber;
+ unsigned long stateChanges;
+} cwPictureRec, *cwPicturePtr;
+
+#define getCwPicture(pPicture) ((cwPicturePtr)(pPicture)->devPrivates[cwPictureIndex].ptr)
+#define setCwPicture(pPicture,p) ((pPicture)->devPrivates[cwPictureIndex].ptr = (pointer) (p))
+
+extern int cwPictureIndex;
+
+extern int cwWindowIndex;
+
+#define cwWindowPrivate(pWindow) ((pWindow)->devPrivates[cwWindowIndex].ptr)
+#define getCwPixmap(pWindow) ((PixmapPtr) cwWindowPrivate(pWindow))
+#define setCwPixmap(pWindow,pPixmap) (cwWindowPrivate(pWindow) = (pointer) (pPixmap))
+
+#define cwDrawableIsRedirWindow(pDraw) \
+ ((pDraw)->type == DRAWABLE_WINDOW && \
+ getCwPixmap((WindowPtr) (pDraw)) != NULL)
+
+typedef struct {
+ /*
+ * screen func wrappers
+ */
+ CloseScreenProcPtr CloseScreen;
+ GetImageProcPtr GetImage;
+ GetSpansProcPtr GetSpans;
+ CreateGCProcPtr CreateGC;
+
+ PaintWindowBackgroundProcPtr PaintWindowBackground;
+ PaintWindowBorderProcPtr PaintWindowBorder;
+ CopyWindowProcPtr CopyWindow;
+
+ GetWindowPixmapProcPtr GetWindowPixmap;
+ SetWindowPixmapProcPtr SetWindowPixmap;
+
+#ifdef RENDER
+ DestroyPictureProcPtr DestroyPicture;
+ ChangePictureClipProcPtr ChangePictureClip;
+ DestroyPictureClipProcPtr DestroyPictureClip;
+
+ ChangePictureProcPtr ChangePicture;
+ ValidatePictureProcPtr ValidatePicture;
+
+ CompositeProcPtr Composite;
+ GlyphsProcPtr Glyphs;
+ CompositeRectsProcPtr CompositeRects;
+
+ TrapezoidsProcPtr Trapezoids;
+ TrianglesProcPtr Triangles;
+ TriStripProcPtr TriStrip;
+ TriFanProcPtr TriFan;
+
+ RasterizeTrapezoidProcPtr RasterizeTrapezoid;
+#endif
+} cwScreenRec, *cwScreenPtr;
+
+extern int cwScreenIndex;
+
+#define getCwScreen(pScreen) ((cwScreenPtr)(pScreen)->devPrivates[cwScreenIndex].ptr)
+#define setCwScreen(pScreen,p) ((cwScreenPtr)(pScreen)->devPrivates[cwScreenIndex].ptr = (p))
+
+#define CW_OFFSET_XYPOINTS(ppt, npt) do { \
+ DDXPointPtr _ppt = (DDXPointPtr)(ppt); \
+ int _i; \
+ for (_i = 0; _i < npt; _i++) { \
+ _ppt[_i].x += dst_off_x; \
+ _ppt[_i].y += dst_off_y; \
+ } \
+} while (0)
+
+#define CW_OFFSET_RECTS(prect, nrect) do { \
+ int _i; \
+ for (_i = 0; _i < nrect; _i++) { \
+ (prect)[_i].x += dst_off_x; \
+ (prect)[_i].y += dst_off_y; \
+ } \
+} while (0)
+
+#define CW_OFFSET_ARCS(parc, narc) do { \
+ int _i; \
+ for (_i = 0; _i < narc; _i++) { \
+ (parc)[_i].x += dst_off_x; \
+ (parc)[_i].y += dst_off_y; \
+ } \
+} while (0)
+
+#define CW_OFFSET_XY_DST(x, y) do { \
+ (x) = (x) + dst_off_x; \
+ (y) = (y) + dst_off_y; \
+} while (0)
+
+#define CW_OFFSET_XY_SRC(x, y) do { \
+ (x) = (x) + src_off_x; \
+ (y) = (y) + src_off_y; \
+} while (0)
+
+/* cw.c */
+DrawablePtr
+cwGetBackingDrawable(DrawablePtr pDrawable, int *x_off, int *y_off);
+
+/* cw_render.c */
+
+void
+cwInitializeRender (ScreenPtr pScreen);
+
+void
+cwFiniRender (ScreenPtr pScreen);
+
+/* cw.c */
+
+void
+miInitializeCompositeWrapper(ScreenPtr pScreen);
+
+/* Must be called before miInitializeCompositeWrapper */
+void
+miDisableCompositeWrapper(ScreenPtr pScreen);
diff --git a/nx-X11/programs/Xserver/miext/cw/cw_ops.c b/nx-X11/programs/Xserver/miext/cw/cw_ops.c
new file mode 100644
index 000000000..567a8c93c
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/cw/cw_ops.c
@@ -0,0 +1,470 @@
+/*
+ * Copyright © 2004 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $Header: /cvs/xorg/xc/programs/Xserver/miext/cw/cw_ops.c,v 1.9 2005/07/03 07:02:01 daniels Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "gcstruct.h"
+#include "cw.h"
+
+#define SETUP_BACKING_DST(_pDst, _pGC) \
+ cwGCPtr pGCPrivate = getCwGC (_pGC); \
+ int dst_off_x, dst_off_y; \
+ DrawablePtr pBackingDst = cwGetBackingDrawable(pDst, &dst_off_x, \
+ &dst_off_y); \
+ GCPtr pBackingGC = pGCPrivate->pBackingGC ? pGCPrivate->pBackingGC : _pGC
+
+#define SETUP_BACKING_SRC(pSrc, pGC) \
+ int src_off_x, src_off_y; \
+ DrawablePtr pBackingSrc = cwGetBackingDrawable(pSrc, &src_off_x, \
+ &src_off_y)
+
+#define PROLOGUE(pGC) do { \
+ pGC->funcs = pGCPrivate->wrapFuncs;\
+ pGC->ops = pGCPrivate->wrapOps;\
+} while (0)
+
+#define EPILOGUE(pGC) do { \
+ pGCPrivate->wrapFuncs = (pGC)->funcs; \
+ pGCPrivate->wrapOps = (pGC)->ops; \
+ (pGC)->funcs = &cwGCFuncs; \
+ (pGC)->ops = &cwGCOps; \
+} while (0)
+
+extern GCFuncs cwGCFuncs;
+
+/*
+ * GC ops -- wrap each GC operation with our own function
+ */
+
+static void cwFillSpans(DrawablePtr pDst, GCPtr pGC, int nInit,
+ DDXPointPtr pptInit, int *pwidthInit, int fSorted);
+static void cwSetSpans(DrawablePtr pDst, GCPtr pGC, char *psrc,
+ DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
+static void cwPutImage(DrawablePtr pDst, GCPtr pGC, int depth,
+ int x, int y, int w, int h, int leftPad, int format,
+ char *pBits);
+static RegionPtr cwCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h,
+ int dstx, int dsty);
+static RegionPtr cwCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h,
+ int dstx, int dsty, unsigned long plane);
+static void cwPolyPoint(DrawablePtr pDst, GCPtr pGC, int mode, int npt,
+ xPoint *pptInit);
+static void cwPolylines(DrawablePtr pDst, GCPtr pGC, int mode, int npt,
+ DDXPointPtr pptInit);
+static void cwPolySegment(DrawablePtr pDst, GCPtr pGC, int nseg,
+ xSegment *pSegs);
+static void cwPolyRectangle(DrawablePtr pDst, GCPtr pGC,
+ int nrects, xRectangle *pRects);
+static void cwPolyArc(DrawablePtr pDst, GCPtr pGC, int narcs, xArc *parcs);
+static void cwFillPolygon(DrawablePtr pDst, GCPtr pGC, int shape, int mode,
+ int count, DDXPointPtr pPts);
+static void cwPolyFillRect(DrawablePtr pDst, GCPtr pGC,
+ int nrectFill, xRectangle *prectInit);
+static void cwPolyFillArc(DrawablePtr pDst, GCPtr pGC,
+ int narcs, xArc *parcs);
+static int cwPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ int count, char *chars);
+static int cwPolyText16(DrawablePtr pDst, GCPtr pGC, int x, int y,
+ int count, unsigned short *chars);
+static void cwImageText8(DrawablePtr pDst, GCPtr pGC, int x, int y,
+ int count, char *chars);
+static void cwImageText16(DrawablePtr pDst, GCPtr pGC, int x, int y,
+ int count, unsigned short *chars);
+static void cwImageGlyphBlt(DrawablePtr pDst, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci,
+ pointer pglyphBase);
+static void cwPolyGlyphBlt(DrawablePtr pDst, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci,
+ pointer pglyphBase);
+static void cwPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst,
+ int w, int h, int x, int y);
+
+GCOps cwGCOps = {
+ cwFillSpans,
+ cwSetSpans,
+ cwPutImage,
+ cwCopyArea,
+ cwCopyPlane,
+ cwPolyPoint,
+ cwPolylines,
+ cwPolySegment,
+ cwPolyRectangle,
+ cwPolyArc,
+ cwFillPolygon,
+ cwPolyFillRect,
+ cwPolyFillArc,
+ cwPolyText8,
+ cwPolyText16,
+ cwImageText8,
+ cwImageText16,
+ cwImageGlyphBlt,
+ cwPolyGlyphBlt,
+ cwPushPixels
+};
+
+static void
+cwFillSpans(DrawablePtr pDst, GCPtr pGC, int nspans, DDXPointPtr ppt,
+ int *pwidth, int fSorted)
+{
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ CW_OFFSET_XYPOINTS(ppt, nspans);
+
+ (*pBackingGC->ops->FillSpans)(pBackingDst, pBackingGC, nspans, ppt,
+ pwidth, fSorted);
+
+ EPILOGUE(pGC);
+}
+
+static void
+cwSetSpans(DrawablePtr pDst, GCPtr pGC, char *psrc, DDXPointPtr ppt,
+ int *pwidth, int nspans, int fSorted)
+{
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ CW_OFFSET_XYPOINTS(ppt, nspans);
+
+ (*pBackingGC->ops->SetSpans)(pBackingDst, pBackingGC, psrc, ppt, pwidth,
+ nspans, fSorted);
+
+ EPILOGUE(pGC);
+}
+
+static void
+cwPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, int w, int h,
+ int leftPad, int format, char *pBits)
+{
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ CW_OFFSET_XY_DST(x, y);
+
+ (*pBackingGC->ops->PutImage)(pBackingDst, pBackingGC, depth, x, y, w, h,
+ leftPad, format, pBits);
+
+ EPILOGUE(pGC);
+}
+
+static RegionPtr
+cwCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy,
+ int w, int h, int dstx, int dsty)
+{
+ int odstx, odsty;
+ RegionPtr exposed = NULL;
+ SETUP_BACKING_DST(pDst, pGC);
+ SETUP_BACKING_SRC(pSrc, pGC);
+
+ PROLOGUE(pGC);
+
+ odstx = dstx;
+ odsty = dsty;
+ CW_OFFSET_XY_DST(dstx, dsty);
+ CW_OFFSET_XY_SRC(srcx, srcy);
+
+ exposed = (*pBackingGC->ops->CopyArea)(pBackingSrc, pBackingDst,
+ pBackingGC, srcx, srcy, w, h,
+ dstx, dsty);
+
+ if (exposed != NULL)
+ REGION_TRANSLATE(pDst->pScreen, exposed, odstx - dstx, odsty - dsty);
+
+ EPILOGUE(pGC);
+
+ return exposed;
+}
+
+static RegionPtr
+cwCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy,
+ int w, int h, int dstx, int dsty, unsigned long plane)
+{
+ int odstx, odsty;
+ RegionPtr exposed = NULL;
+ SETUP_BACKING_DST(pDst, pGC);
+ SETUP_BACKING_SRC(pSrc, pGC);
+
+ PROLOGUE(pGC);
+
+ odstx = dstx;
+ odsty = dsty;
+ CW_OFFSET_XY_DST(dstx, dsty);
+ CW_OFFSET_XY_SRC(srcx, srcy);
+
+ exposed = (*pBackingGC->ops->CopyPlane)(pBackingSrc, pBackingDst,
+ pBackingGC, srcx, srcy, w, h,
+ dstx, dsty, plane);
+
+ if (exposed != NULL)
+ REGION_TRANSLATE(pDst->pScreen, exposed, odstx - dstx, odsty - dsty);
+
+ EPILOGUE(pGC);
+
+ return exposed;
+}
+
+static void
+cwPolyPoint(DrawablePtr pDst, GCPtr pGC, int mode, int npt, xPoint *ppt)
+{
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ if (mode == CoordModeOrigin)
+ CW_OFFSET_XYPOINTS(ppt, npt);
+ else
+ CW_OFFSET_XYPOINTS(ppt, 1);
+
+ (*pBackingGC->ops->PolyPoint)(pBackingDst, pBackingGC, mode, npt, ppt);
+
+ EPILOGUE(pGC);
+}
+
+static void
+cwPolylines(DrawablePtr pDst, GCPtr pGC, int mode, int npt, DDXPointPtr ppt)
+{
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ if (mode == CoordModeOrigin)
+ CW_OFFSET_XYPOINTS(ppt, npt);
+ else
+ CW_OFFSET_XYPOINTS(ppt, 1);
+
+ (*pBackingGC->ops->Polylines)(pBackingDst, pBackingGC, mode, npt, ppt);
+
+ EPILOGUE(pGC);
+}
+
+static void
+cwPolySegment(DrawablePtr pDst, GCPtr pGC, int nseg, xSegment *pSegs)
+{
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ CW_OFFSET_XYPOINTS(pSegs, nseg * 2);
+
+ (*pBackingGC->ops->PolySegment)(pBackingDst, pBackingGC, nseg, pSegs);
+
+ EPILOGUE(pGC);
+}
+
+static void
+cwPolyRectangle(DrawablePtr pDst, GCPtr pGC, int nrects, xRectangle *pRects)
+{
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ CW_OFFSET_RECTS(pRects, nrects);
+
+ (*pBackingGC->ops->PolyRectangle)(pBackingDst, pBackingGC, nrects, pRects);
+
+ EPILOGUE(pGC);
+}
+
+static void
+cwPolyArc(DrawablePtr pDst, GCPtr pGC, int narcs, xArc *pArcs)
+{
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ CW_OFFSET_RECTS(pArcs, narcs);
+
+ (*pBackingGC->ops->PolyArc)(pBackingDst, pBackingGC, narcs, pArcs);
+
+ EPILOGUE(pGC);
+}
+
+static void
+cwFillPolygon(DrawablePtr pDst, GCPtr pGC, int shape, int mode, int npt,
+ DDXPointPtr ppt)
+{
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ if (mode == CoordModeOrigin)
+ CW_OFFSET_XYPOINTS(ppt, npt);
+ else
+ CW_OFFSET_XYPOINTS(ppt, 1);
+
+ (*pBackingGC->ops->FillPolygon)(pBackingDst, pBackingGC, shape, mode, npt,
+ ppt);
+
+ EPILOGUE(pGC);
+}
+
+static void
+cwPolyFillRect(DrawablePtr pDst, GCPtr pGC, int nrects, xRectangle *pRects)
+{
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ CW_OFFSET_RECTS(pRects, nrects);
+
+ (*pBackingGC->ops->PolyFillRect)(pBackingDst, pBackingGC, nrects, pRects);
+
+ EPILOGUE(pGC);
+}
+
+static void
+cwPolyFillArc(DrawablePtr pDst, GCPtr pGC, int narcs, xArc *parcs)
+{
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ CW_OFFSET_RECTS(parcs, narcs);
+
+ (*pBackingGC->ops->PolyFillArc)(pBackingDst, pBackingGC, narcs, parcs);
+
+ EPILOGUE(pGC);
+}
+
+static int
+cwPolyText8(DrawablePtr pDst, GCPtr pGC, int x, int y, int count, char *chars)
+{
+ int result;
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ CW_OFFSET_XY_DST(x, y);
+
+ result = (*pBackingGC->ops->PolyText8)(pBackingDst, pBackingGC, x, y,
+ count, chars);
+
+ EPILOGUE(pGC);
+
+ return result;
+}
+
+static int
+cwPolyText16(DrawablePtr pDst, GCPtr pGC, int x, int y, int count,
+ unsigned short *chars)
+{
+ int result;
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ CW_OFFSET_XY_DST(x, y);
+
+ result = (*pBackingGC->ops->PolyText16)(pBackingDst, pBackingGC, x, y,
+ count, chars);
+
+ EPILOGUE(pGC);
+ return result;
+}
+
+static void
+cwImageText8(DrawablePtr pDst, GCPtr pGC, int x, int y, int count, char *chars)
+{
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ CW_OFFSET_XY_DST(x, y);
+
+ (*pBackingGC->ops->ImageText8)(pBackingDst, pBackingGC, x, y, count,
+ chars);
+
+ EPILOGUE(pGC);
+}
+
+static void
+cwImageText16(DrawablePtr pDst, GCPtr pGC, int x, int y, int count,
+ unsigned short *chars)
+{
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ CW_OFFSET_XY_DST(x, y);
+
+ (*pBackingGC->ops->ImageText16)(pBackingDst, pBackingGC, x, y, count,
+ chars);
+
+ EPILOGUE(pGC);
+}
+
+static void
+cwImageGlyphBlt(DrawablePtr pDst, GCPtr pGC, int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase)
+{
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ CW_OFFSET_XY_DST(x, y);
+
+ (*pBackingGC->ops->ImageGlyphBlt)(pBackingDst, pBackingGC, x, y, nglyph,
+ ppci, pglyphBase);
+
+ EPILOGUE(pGC);
+}
+
+static void
+cwPolyGlyphBlt(DrawablePtr pDst, GCPtr pGC, int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase)
+{
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ CW_OFFSET_XY_DST(x, y);
+
+ (*pBackingGC->ops->PolyGlyphBlt)(pBackingDst, pBackingGC, x, y, nglyph,
+ ppci, pglyphBase);
+
+ EPILOGUE(pGC);
+}
+
+static void
+cwPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, int w, int h,
+ int x, int y)
+{
+ SETUP_BACKING_DST(pDst, pGC);
+
+ PROLOGUE(pGC);
+
+ CW_OFFSET_XY_DST(x, y);
+
+ (*pBackingGC->ops->PushPixels)(pBackingGC, pBitMap, pBackingDst, w, h,
+ x, y);
+
+ EPILOGUE(pGC);
+}
+
diff --git a/nx-X11/programs/Xserver/miext/cw/cw_render.c b/nx-X11/programs/Xserver/miext/cw/cw_render.c
new file mode 100644
index 000000000..74c52afb0
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/cw/cw_render.c
@@ -0,0 +1,501 @@
+/*
+ * Copyright © 2004 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $Header: /cvs/xorg/xc/programs/Xserver/miext/cw/cw_render.c,v 1.14 2005/07/03 07:02:01 daniels Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "cw.h"
+
+#ifdef RENDER
+
+#define cwPsDecl(pScreen) \
+ PictureScreenPtr ps = GetPictureScreen (pScreen); \
+ cwScreenPtr pCwScreen = getCwScreen (pScreen)
+
+#define cwPicturePrivate \
+ cwPicturePtr pPicturePrivate = getCwPicture(pPicture)
+
+#define cwSrcPictureDecl \
+ int src_picture_x_off, src_picture_y_off; \
+ PicturePtr pBackingSrcPicture = cwGetBackingPicture(pSrcPicture, \
+ &src_picture_x_off,\
+ &src_picture_y_off)
+
+#define cwDstPictureDecl \
+ int dst_picture_x_off, dst_picture_y_off; \
+ PicturePtr pBackingDstPicture = cwGetBackingPicture(pDstPicture, \
+ &dst_picture_x_off,\
+ &dst_picture_y_off)
+
+#define cwMskPictureDecl \
+ int msk_picture_x_off = 0, msk_picture_y_off = 0; \
+ PicturePtr pBackingMskPicture = (!pMskPicture ? 0 : \
+ cwGetBackingPicture(pMskPicture, \
+ &msk_picture_x_off,\
+ &msk_picture_y_off))
+
+#define cwPsUnwrap(elt) { \
+ ps->elt = pCwScreen->elt; \
+}
+
+#define cwPsWrap(elt,func) { \
+ pCwScreen->elt = ps->elt; \
+ ps->elt = func; \
+}
+
+static cwPicturePtr
+cwCreatePicturePrivate (PicturePtr pPicture)
+{
+ WindowPtr pWindow = (WindowPtr) pPicture->pDrawable;
+ PixmapPtr pPixmap = getCwPixmap (pWindow);
+ int error;
+ cwPicturePtr pPicturePrivate;
+
+ pPicturePrivate = xalloc (sizeof (cwPictureRec));
+ if (!pPicturePrivate)
+ return NULL;
+
+ pPicturePrivate->pBackingPicture = CreatePicture (0, &pPixmap->drawable,
+ pPicture->pFormat,
+ 0, 0, serverClient,
+ &error);
+ if (!pPicturePrivate->pBackingPicture)
+ {
+ xfree (pPicturePrivate);
+ return NULL;
+ }
+
+ /*
+ * Ensure that this serial number does not match the window's
+ */
+ pPicturePrivate->serialNumber = pPixmap->drawable.serialNumber;
+ pPicturePrivate->stateChanges = (1 << (CPLastBit + 1)) - 1;
+
+ setCwPicture(pPicture, pPicturePrivate);
+
+ return pPicturePrivate;
+}
+
+static void
+cwDestroyPicturePrivate (PicturePtr pPicture)
+{
+ cwPicturePrivate;
+
+ if (pPicturePrivate)
+ {
+ if (pPicturePrivate->pBackingPicture)
+ FreePicture (pPicturePrivate->pBackingPicture, 0);
+ xfree (pPicturePrivate);
+ setCwPicture(pPicture, NULL);
+ }
+}
+
+static PicturePtr
+cwGetBackingPicture (PicturePtr pPicture, int *x_off, int *y_off)
+{
+ cwPicturePrivate;
+
+ if (pPicturePrivate)
+ {
+ DrawablePtr pDrawable = pPicture->pDrawable;
+ WindowPtr pWindow = (WindowPtr) pDrawable;
+ PixmapPtr pPixmap = getCwPixmap (pWindow);
+
+ *x_off = pDrawable->x - pPixmap->screen_x;
+ *y_off = pDrawable->y - pPixmap->screen_y;
+
+ return pPicturePrivate->pBackingPicture;
+ }
+ else
+ {
+ *x_off = *y_off = 0;
+ return pPicture;
+ }
+}
+
+static void
+cwDestroyPicture (PicturePtr pPicture)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+
+ cwPsUnwrap(DestroyPicture);
+ cwDestroyPicturePrivate (pPicture);
+ (*ps->DestroyPicture) (pPicture);
+ cwPsWrap(DestroyPicture, cwDestroyPicture);
+}
+
+static void
+cwChangePicture (PicturePtr pPicture, Mask mask)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+ cwPicturePtr pPicturePrivate = getCwPicture(pPicture);
+
+ cwPsUnwrap(ChangePicture);
+ (*ps->ChangePicture) (pPicture, mask);
+ if (pPicturePrivate)
+ pPicturePrivate->stateChanges |= mask;
+ cwPsWrap(ChangePicture, cwChangePicture);
+}
+
+
+static void
+cwValidatePicture (PicturePtr pPicture,
+ Mask mask)
+{
+ DrawablePtr pDrawable = pPicture->pDrawable;
+ ScreenPtr pScreen = pDrawable->pScreen;
+ cwPsDecl(pScreen);
+ cwPicturePrivate;
+
+ cwPsUnwrap(ValidatePicture);
+
+ /*
+ * Must call ValidatePicture to ensure pPicture->pCompositeClip is valid
+ */
+ (*ps->ValidatePicture) (pPicture, mask);
+
+ if (!cwDrawableIsRedirWindow (pDrawable))
+ {
+ if (pPicturePrivate)
+ cwDestroyPicturePrivate (pPicture);
+ }
+ else
+ {
+ PicturePtr pBackingPicture;
+ DrawablePtr pBackingDrawable;
+ int x_off, y_off;
+
+ pBackingDrawable = cwGetBackingDrawable(pDrawable, &x_off, &y_off);
+
+ if (pPicturePrivate &&
+ pPicturePrivate->pBackingPicture->pDrawable != pBackingDrawable)
+ {
+ cwDestroyPicturePrivate (pPicture);
+ pPicturePrivate = 0;
+ }
+
+ if (!pPicturePrivate)
+ {
+ pPicturePrivate = cwCreatePicturePrivate (pPicture);
+ if (!pPicturePrivate)
+ {
+ cwPsWrap(ValidatePicture, cwValidatePicture);
+ return;
+ }
+ }
+
+ pBackingPicture = pPicturePrivate->pBackingPicture;
+
+ /*
+ * Always copy transform and filters because there's no
+ * indication of when they've changed
+ */
+ SetPictureTransform(pBackingPicture, pPicture->transform);
+
+ if (pBackingPicture->filter != pPicture->filter ||
+ pPicture->filter_nparams > 0)
+ {
+ char *filter = PictureGetFilterName (pPicture->filter);
+
+ SetPictureFilter(pBackingPicture,
+ filter, strlen (filter),
+ pPicture->filter_params,
+ pPicture->filter_nparams);
+ }
+
+ pPicturePrivate->stateChanges |= mask;
+
+ if (pPicturePrivate->serialNumber != pDrawable->serialNumber ||
+ (pPicturePrivate->stateChanges & (CPClipXOrigin|CPClipYOrigin|CPClipMask)))
+ {
+ SetPictureClipRegion (pBackingPicture,
+ x_off - pDrawable->x,
+ y_off - pDrawable->y,
+ pPicture->pCompositeClip);
+
+ pPicturePrivate->serialNumber = pDrawable->serialNumber;
+ pPicturePrivate->stateChanges &= ~(CPClipXOrigin | CPClipYOrigin | CPClipMask);
+ }
+
+ CopyPicture(pPicture, pPicturePrivate->stateChanges, pBackingPicture);
+
+ ValidatePicture (pBackingPicture);
+ }
+ cwPsWrap(ValidatePicture, cwValidatePicture);
+}
+
+static void
+cwComposite (CARD8 op,
+ PicturePtr pSrcPicture,
+ PicturePtr pMskPicture,
+ PicturePtr pDstPicture,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMsk,
+ INT16 yMsk,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+ cwSrcPictureDecl;
+ cwMskPictureDecl;
+ cwDstPictureDecl;
+
+ cwPsUnwrap(Composite);
+ (*ps->Composite) (op, pBackingSrcPicture, pBackingMskPicture, pBackingDstPicture,
+ xSrc + src_picture_x_off, ySrc + src_picture_y_off,
+ xMsk + msk_picture_x_off, yMsk + msk_picture_y_off,
+ xDst + dst_picture_x_off, yDst + dst_picture_y_off,
+ width, height);
+ cwPsWrap(Composite, cwComposite);
+}
+
+static void
+cwGlyphs (CARD8 op,
+ PicturePtr pSrcPicture,
+ PicturePtr pDstPicture,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlists,
+ GlyphListPtr lists,
+ GlyphPtr *glyphs)
+{
+ ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+ cwSrcPictureDecl;
+ cwDstPictureDecl;
+
+ cwPsUnwrap(Glyphs);
+ if (nlists)
+ {
+ lists->xOff += dst_picture_x_off;
+ lists->yOff += dst_picture_y_off;
+ }
+ (*ps->Glyphs) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
+ xSrc + src_picture_x_off, ySrc + src_picture_y_off,
+ nlists, lists, glyphs);
+ cwPsWrap(Glyphs, cwGlyphs);
+}
+
+static void
+cwCompositeRects (CARD8 op,
+ PicturePtr pDstPicture,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects)
+{
+ ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+ cwDstPictureDecl;
+ int i;
+
+ cwPsUnwrap(CompositeRects);
+ for (i = 0; i < nRect; i++)
+ {
+ rects[i].x += dst_picture_x_off;
+ rects[i].y += dst_picture_y_off;
+ }
+ (*ps->CompositeRects) (op, pBackingDstPicture, color, nRect, rects);
+ cwPsWrap(CompositeRects, cwCompositeRects);
+}
+
+static void
+cwTrapezoids (CARD8 op,
+ PicturePtr pSrcPicture,
+ PicturePtr pDstPicture,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntrap,
+ xTrapezoid *traps)
+{
+ ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+ cwSrcPictureDecl;
+ cwDstPictureDecl;
+ int i;
+
+ cwPsUnwrap(Trapezoids);
+ if (dst_picture_x_off || dst_picture_y_off) {
+ for (i = 0; i < ntrap; i++)
+ {
+ traps[i].top += dst_picture_y_off << 16;
+ traps[i].bottom += dst_picture_y_off << 16;
+ traps[i].left.p1.x += dst_picture_x_off << 16;
+ traps[i].left.p1.y += dst_picture_y_off << 16;
+ traps[i].left.p2.x += dst_picture_x_off << 16;
+ traps[i].left.p2.y += dst_picture_y_off << 16;
+ traps[i].right.p1.x += dst_picture_x_off << 16;
+ traps[i].right.p1.y += dst_picture_y_off << 16;
+ traps[i].right.p2.x += dst_picture_x_off << 16;
+ traps[i].right.p2.y += dst_picture_y_off << 16;
+ }
+ }
+ (*ps->Trapezoids) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
+ xSrc + src_picture_x_off, ySrc + src_picture_y_off,
+ ntrap, traps);
+ cwPsWrap(Trapezoids, cwTrapezoids);
+}
+
+static void
+cwTriangles (CARD8 op,
+ PicturePtr pSrcPicture,
+ PicturePtr pDstPicture,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntri,
+ xTriangle *tris)
+{
+ ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+ cwSrcPictureDecl;
+ cwDstPictureDecl;
+ int i;
+
+ cwPsUnwrap(Triangles);
+ if (dst_picture_x_off || dst_picture_y_off) {
+ for (i = 0; i < ntri; i++)
+ {
+ tris[i].p1.x += dst_picture_x_off << 16;
+ tris[i].p1.y += dst_picture_y_off << 16;
+ tris[i].p2.x += dst_picture_x_off << 16;
+ tris[i].p2.y += dst_picture_y_off << 16;
+ tris[i].p3.x += dst_picture_x_off << 16;
+ tris[i].p3.y += dst_picture_y_off << 16;
+ }
+ }
+ (*ps->Triangles) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
+ xSrc + src_picture_x_off, ySrc + src_picture_y_off,
+ ntri, tris);
+ cwPsWrap(Triangles, cwTriangles);
+}
+
+static void
+cwTriStrip (CARD8 op,
+ PicturePtr pSrcPicture,
+ PicturePtr pDstPicture,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoint,
+ xPointFixed *points)
+{
+ ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+ cwSrcPictureDecl;
+ cwDstPictureDecl;
+ int i;
+
+ cwPsUnwrap(TriStrip);
+ if (dst_picture_x_off || dst_picture_y_off) {
+ for (i = 0; i < npoint; i++)
+ {
+ points[i].x += dst_picture_x_off << 16;
+ points[i].y += dst_picture_y_off << 16;
+ }
+ }
+ (*ps->TriStrip) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
+ xSrc + src_picture_x_off, ySrc + src_picture_y_off,
+ npoint, points);
+ cwPsWrap(TriStrip, cwTriStrip);
+}
+
+static void
+cwTriFan (CARD8 op,
+ PicturePtr pSrcPicture,
+ PicturePtr pDstPicture,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoint,
+ xPointFixed *points)
+{
+ ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
+ cwPsDecl(pScreen);
+ cwSrcPictureDecl;
+ cwDstPictureDecl;
+ int i;
+
+ cwPsUnwrap(TriFan);
+ if (dst_picture_x_off || dst_picture_y_off) {
+ for (i = 0; i < npoint; i++)
+ {
+ points[i].x += dst_picture_x_off << 16;
+ points[i].y += dst_picture_y_off << 16;
+ }
+ }
+ (*ps->TriFan) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
+ xSrc + src_picture_x_off, ySrc + src_picture_y_off,
+ npoint, points);
+ cwPsWrap(TriFan, cwTriFan);
+}
+
+void
+cwInitializeRender (ScreenPtr pScreen)
+{
+ cwPsDecl (pScreen);
+
+ cwPsWrap(DestroyPicture, cwDestroyPicture);
+ cwPsWrap(ChangePicture, cwChangePicture);
+ cwPsWrap(ValidatePicture, cwValidatePicture);
+ cwPsWrap(Composite, cwComposite);
+ cwPsWrap(Glyphs, cwGlyphs);
+ cwPsWrap(CompositeRects, cwCompositeRects);
+ cwPsWrap(Trapezoids, cwTrapezoids);
+ cwPsWrap(Triangles, cwTriangles);
+ cwPsWrap(TriStrip, cwTriStrip);
+ cwPsWrap(TriFan, cwTriFan);
+ /* There is no need to wrap AddTraps as far as we can tell. AddTraps can
+ * only be done on alpha-only pictures, and we won't be getting
+ * alpha-only window pictures, so there's no need to translate.
+ */
+}
+
+void
+cwFiniRender (ScreenPtr pScreen)
+{
+ cwPsDecl (pScreen);
+
+ cwPsUnwrap(DestroyPicture);
+ cwPsUnwrap(ChangePicture);
+ cwPsUnwrap(ValidatePicture);
+ cwPsUnwrap(Composite);
+ cwPsUnwrap(Glyphs);
+ cwPsUnwrap(CompositeRects);
+ cwPsUnwrap(Trapezoids);
+ cwPsUnwrap(Triangles);
+ cwPsUnwrap(TriStrip);
+ cwPsUnwrap(TriFan);
+}
+
+#endif /* RENDER */
diff --git a/nx-X11/programs/Xserver/miext/damage/Imakefile b/nx-X11/programs/Xserver/miext/damage/Imakefile
new file mode 100755
index 000000000..1fa5cf126
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/damage/Imakefile
@@ -0,0 +1,26 @@
+#define IHaveModules
+#include <Server.tmpl>
+
+#if BuildRootless
+DEFINES = -DROOTLESS_WORKAROUND
+#endif
+
+SRCS = damage.c
+
+OBJS = damage.o
+
+ INCLUDES = -I. -I../shadow -I../../mi -I../../fb -I../../include -I$(XINCLUDESRC) \
+ -I$(FONTINCSRC) -I$(XF86SRC)/common $(EXTRAINCLUDES) \
+ -I../../render -I../cw -I$(EXTINCSRC)
+ LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln \
+ ../../mi/llib-lmi.ln
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(damage,$(OBJS))
+LintLibraryTarget(damage,$(SRCS))
+
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
+InstallDriverSDKNonExecFile(damage.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/miext/damage/damage.c b/nx-X11/programs/Xserver/miext/damage/damage.c
new file mode 100755
index 000000000..286728cd1
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/damage/damage.c
@@ -0,0 +1,1966 @@
+/*
+ * $Id: damage.c,v 1.19 2005/10/06 21:55:41 anholt Exp $
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "damage.h"
+#include "damagestr.h"
+#ifdef COMPOSITE
+#include "cw.h"
+#endif
+
+#define wrap(priv, real, mem, func) {\
+ priv->mem = real->mem; \
+ real->mem = func; \
+}
+
+#define unwrap(priv, real, mem) {\
+ real->mem = priv->mem; \
+}
+
+#define BOX_SAME(a,b) \
+ ((a)->x1 == (b)->x1 && \
+ (a)->y1 == (b)->y1 && \
+ (a)->x2 == (b)->x2 && \
+ (a)->y2 == (b)->y2)
+
+#define DAMAGE_VALIDATE_ENABLE 0
+#define DAMAGE_DEBUG_ENABLE 0
+#if DAMAGE_DEBUG_ENABLE
+#define DAMAGE_DEBUG(x) ErrorF x
+#else
+#define DAMAGE_DEBUG(x)
+#endif
+
+#define getPixmapDamageRef(pPixmap) \
+ ((DamagePtr *) &(pPixmap->devPrivates[damagePixPrivateIndex].ptr))
+
+#define pixmapDamage(pPixmap) damagePixPriv(pPixmap)
+
+static DamagePtr *
+getDrawableDamageRef (DrawablePtr pDrawable)
+{
+ PixmapPtr pPixmap;
+
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ {
+ ScreenPtr pScreen = pDrawable->pScreen;
+
+ pPixmap = 0;
+ if (pScreen->GetWindowPixmap
+#ifdef ROOTLESS_WORKAROUND
+ && ((WindowPtr)pDrawable)->viewable
+#endif
+ )
+ pPixmap = (*pScreen->GetWindowPixmap) ((WindowPtr)pDrawable);
+
+ if (!pPixmap)
+ {
+ damageScrPriv(pScreen);
+
+ return &pScrPriv->pScreenDamage;
+ }
+ }
+ else
+ pPixmap = (PixmapPtr) pDrawable;
+ return getPixmapDamageRef (pPixmap);
+}
+
+#define getDrawableDamage(pDrawable) (*getDrawableDamageRef (pDrawable))
+#define getWindowDamage(pWin) getDrawableDamage(&(pWin)->drawable)
+
+#define drawableDamage(pDrawable) \
+ DamagePtr pDamage = getDrawableDamage(pDrawable)
+
+#define windowDamage(pWin) drawableDamage(&(pWin)->drawable)
+
+#define winDamageRef(pWindow) \
+ DamagePtr *pPrev = (DamagePtr *) \
+ &(pWindow->devPrivates[damageWinPrivateIndex].ptr)
+
+#if DAMAGE_DEBUG_ENABLE
+static void
+_damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, int subWindowMode, const char *where)
+#define damageDamageRegion(d,r,c,m) _damageDamageRegion(d,r,c,m,__FUNCTION__)
+#else
+static void
+damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
+ int subWindowMode)
+#endif
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ damageScrPriv(pScreen);
+ drawableDamage(pDrawable);
+ DamagePtr pNext;
+ RegionRec clippedRec;
+ RegionPtr pDamageRegion;
+ RegionRec pixClip;
+ Bool was_empty;
+ RegionRec tmpRegion;
+ BoxRec tmpBox;
+ int draw_x, draw_y;
+#ifdef COMPOSITE
+ int screen_x = 0, screen_y = 0;
+#endif
+
+ /* short circuit for empty regions */
+ if (!REGION_NOTEMPTY(pScreen, pRegion))
+ return;
+
+#ifdef COMPOSITE
+ /*
+ * When drawing to a pixmap which is storing window contents,
+ * the region presented is in pixmap relative coordinates which
+ * need to be converted to screen relative coordinates
+ */
+ if (pDrawable->type != DRAWABLE_WINDOW)
+ {
+ screen_x = ((PixmapPtr) pDrawable)->screen_x - pDrawable->x;
+ screen_y = ((PixmapPtr) pDrawable)->screen_y - pDrawable->y;
+ }
+ if (screen_x || screen_y)
+ REGION_TRANSLATE (pScreen, pRegion, screen_x, screen_y);
+#endif
+
+ if (pDrawable->type == DRAWABLE_WINDOW &&
+ ((WindowPtr)(pDrawable))->backingStore == NotUseful)
+ {
+ if (subWindowMode == ClipByChildren)
+ {
+ REGION_INTERSECT(pScreen, pRegion, pRegion,
+ &((WindowPtr)(pDrawable))->clipList);
+ }
+ else if (subWindowMode == IncludeInferiors)
+ {
+ RegionPtr pTempRegion =
+ NotClippedByChildren((WindowPtr)(pDrawable));
+ REGION_INTERSECT(pScreen, pRegion, pRegion, pTempRegion);
+ REGION_DESTROY(pScreen, pTempRegion);
+ }
+ /* If subWindowMode is set to an invalid value, don't perform
+ * any drawable-based clipping. */
+ }
+
+
+ REGION_NULL (pScreen, &clippedRec);
+ for (; pDamage; pDamage = pNext)
+ {
+ pNext = pDamage->pNext;
+ /*
+ * Check for internal damage and don't send events
+ */
+ if (pScrPriv->internalLevel > 0 && !pDamage->isInternal)
+ {
+ DAMAGE_DEBUG (("non internal damage, skipping at %d\n",
+ pScrPriv->internalLevel));
+ continue;
+ }
+ /*
+ * Check for unrealized windows
+ */
+ if (pDamage->pDrawable->type == DRAWABLE_WINDOW &&
+ !((WindowPtr) (pDamage->pDrawable))->realized)
+ {
+#if 0
+ DAMAGE_DEBUG (("damage while window unrealized\n"));
+#endif
+ continue;
+ }
+
+ draw_x = pDamage->pDrawable->x;
+ draw_y = pDamage->pDrawable->y;
+#ifdef COMPOSITE
+ /*
+ * Need to move everyone to screen coordinates
+ * XXX what about off-screen pixmaps with non-zero x/y?
+ */
+ if (pDamage->pDrawable->type != DRAWABLE_WINDOW)
+ {
+ draw_x += ((PixmapPtr) pDamage->pDrawable)->screen_x;
+ draw_y += ((PixmapPtr) pDamage->pDrawable)->screen_y;
+ }
+#endif
+
+ /*
+ * Clip against border or pixmap bounds
+ */
+
+ pDamageRegion = pRegion;
+ if (clip || pDamage->pDrawable != pDrawable)
+ {
+ pDamageRegion = &clippedRec;
+ if (pDamage->pDrawable->type == DRAWABLE_WINDOW) {
+ REGION_INTERSECT (pScreen, pDamageRegion, pRegion,
+ &((WindowPtr)(pDamage->pDrawable))->borderClip);
+ } else {
+ BoxRec box;
+ box.x1 = draw_x;
+ box.y1 = draw_y;
+ box.x2 = draw_x + pDamage->pDrawable->width;
+ box.y2 = draw_y + pDamage->pDrawable->height;
+ REGION_INIT(pScreen, &pixClip, &box, 1);
+ REGION_INTERSECT (pScreen, pDamageRegion, pRegion, &pixClip);
+ REGION_UNINIT(pScreen, &pixClip);
+ }
+ /*
+ * Short circuit empty results
+ */
+ if (!REGION_NOTEMPTY(pScreen, pDamageRegion))
+ continue;
+ }
+
+ DAMAGE_DEBUG (("%s %d x %d +%d +%d (target 0x%lx monitor 0x%lx)\n",
+ where,
+ pDamageRegion->extents.x2 - pDamageRegion->extents.x1,
+ pDamageRegion->extents.y2 - pDamageRegion->extents.y1,
+ pDamageRegion->extents.x1, pDamageRegion->extents.y1,
+ pDrawable->id, pDamage->pDrawable->id));
+
+ /*
+ * Move region to target coordinate space
+ */
+ if (draw_x || draw_y)
+ REGION_TRANSLATE (pScreen, pDamageRegion, -draw_x, -draw_y);
+
+ switch (pDamage->damageLevel) {
+ case DamageReportRawRegion:
+ (*pDamage->damageReport) (pDamage, pDamageRegion, pDamage->closure);
+ break;
+ case DamageReportDeltaRegion:
+ REGION_NULL (pScreen, &tmpRegion);
+ REGION_SUBTRACT (pScreen, &tmpRegion, pDamageRegion, &pDamage->damage);
+ if (REGION_NOTEMPTY (pScreen, &tmpRegion))
+ {
+ REGION_UNION(pScreen, &pDamage->damage,
+ &pDamage->damage, pDamageRegion);
+ (*pDamage->damageReport) (pDamage, &tmpRegion, pDamage->closure);
+ }
+ REGION_UNINIT(pScreen, &tmpRegion);
+ break;
+ case DamageReportBoundingBox:
+ tmpBox = *REGION_EXTENTS (pScreen, &pDamage->damage);
+ REGION_UNION(pScreen, &pDamage->damage,
+ &pDamage->damage, pDamageRegion);
+ if (!BOX_SAME (&tmpBox, REGION_EXTENTS (pScreen, &pDamage->damage)))
+ (*pDamage->damageReport) (pDamage, &pDamage->damage, pDamage->closure);
+ break;
+ case DamageReportNonEmpty:
+ was_empty = !REGION_NOTEMPTY(pScreen, &pDamage->damage);
+ REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
+ pDamageRegion);
+ if (was_empty && REGION_NOTEMPTY(pScreen, &pDamage->damage))
+ (*pDamage->damageReport) (pDamage, &pDamage->damage, pDamage->closure);
+ break;
+ case DamageReportNone:
+ REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
+ pDamageRegion);
+ break;
+ }
+ /*
+ * translate original region back
+ */
+ if (pDamageRegion == pRegion && (draw_x || draw_y))
+ REGION_TRANSLATE (pScreen, pDamageRegion, draw_x, draw_y);
+ }
+#ifdef COMPOSITE
+ if (screen_x || screen_y)
+ REGION_TRANSLATE (pScreen, pRegion, -screen_x, -screen_y);
+#endif
+
+ REGION_UNINIT (pScreen, &clippedRec);
+}
+
+#if DAMAGE_DEBUG_ENABLE
+#define damageDamageBox(d,b,m) _damageDamageBox(d,b,m,__FUNCTION__)
+static void
+_damageDamageBox (DrawablePtr pDrawable, BoxPtr pBox, int subWindowMode, const char *where)
+#else
+static void
+damageDamageBox (DrawablePtr pDrawable, BoxPtr pBox, int subWindowMode)
+#endif
+{
+ RegionRec region;
+
+ REGION_INIT (pDrawable->pScreen, &region, pBox, 1);
+#if DAMAGE_DEBUG_ENABLE
+ _damageDamageRegion (pDrawable, &region, TRUE, subWindowMode, where);
+#else
+ damageDamageRegion (pDrawable, &region, TRUE, subWindowMode);
+#endif
+ REGION_UNINIT (pDrawable->pScreen, &region);
+}
+
+static void damageValidateGC(GCPtr, unsigned long, DrawablePtr);
+static void damageChangeGC(GCPtr, unsigned long);
+static void damageCopyGC(GCPtr, unsigned long, GCPtr);
+static void damageDestroyGC(GCPtr);
+static void damageChangeClip(GCPtr, int, pointer, int);
+static void damageDestroyClip(GCPtr);
+static void damageCopyClip(GCPtr, GCPtr);
+
+GCFuncs damageGCFuncs = {
+ damageValidateGC, damageChangeGC, damageCopyGC, damageDestroyGC,
+ damageChangeClip, damageDestroyClip, damageCopyClip
+};
+
+extern GCOps damageGCOps;
+
+static Bool
+damageCreateGC(GCPtr pGC)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ damageScrPriv(pScreen);
+ damageGCPriv(pGC);
+ Bool ret;
+
+ pGC->pCompositeClip = 0;
+ unwrap (pScrPriv, pScreen, CreateGC);
+ if((ret = (*pScreen->CreateGC) (pGC))) {
+ pGCPriv->ops = NULL;
+ pGCPriv->funcs = pGC->funcs;
+ pGC->funcs = &damageGCFuncs;
+ }
+ wrap (pScrPriv, pScreen, CreateGC, damageCreateGC);
+
+ return ret;
+}
+
+#ifdef NOTUSED
+static void
+damageWrapGC (GCPtr pGC)
+{
+ damageGCPriv(pGC);
+
+ pGCPriv->ops = NULL;
+ pGCPriv->funcs = pGC->funcs;
+ pGC->funcs = &damageGCFuncs;
+}
+
+static void
+damageUnwrapGC (GCPtr pGC)
+{
+ damageGCPriv(pGC);
+
+ pGC->funcs = pGCPriv->funcs;
+ if (pGCPriv->ops)
+ pGC->ops = pGCPriv->ops;
+}
+#endif
+
+#define DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable) \
+ damageGCPriv(pGC); \
+ GCFuncs *oldFuncs = pGC->funcs; \
+ unwrap(pGCPriv, pGC, funcs); \
+ unwrap(pGCPriv, pGC, ops); \
+
+#define DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable) \
+ wrap(pGCPriv, pGC, funcs, oldFuncs); \
+ wrap(pGCPriv, pGC, ops, &damageGCOps)
+
+#define DAMAGE_GC_FUNC_PROLOGUE(pGC) \
+ damageGCPriv(pGC); \
+ unwrap(pGCPriv, pGC, funcs); \
+ if (pGCPriv->ops) unwrap(pGCPriv, pGC, ops)
+
+#define DAMAGE_GC_FUNC_EPILOGUE(pGC) \
+ wrap(pGCPriv, pGC, funcs, &damageGCFuncs); \
+ if (pGCPriv->ops) wrap(pGCPriv, pGC, ops, &damageGCOps)
+
+static void
+damageValidateGC(GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDrawable)
+{
+ DAMAGE_GC_FUNC_PROLOGUE (pGC);
+ (*pGC->funcs->ValidateGC)(pGC, changes, pDrawable);
+ pGCPriv->ops = pGC->ops; /* just so it's not NULL */
+ DAMAGE_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+damageDestroyGC(GCPtr pGC)
+{
+ DAMAGE_GC_FUNC_PROLOGUE (pGC);
+ (*pGC->funcs->DestroyGC)(pGC);
+ DAMAGE_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+damageChangeGC (GCPtr pGC,
+ unsigned long mask)
+{
+ DAMAGE_GC_FUNC_PROLOGUE (pGC);
+ (*pGC->funcs->ChangeGC) (pGC, mask);
+ DAMAGE_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+damageCopyGC (GCPtr pGCSrc,
+ unsigned long mask,
+ GCPtr pGCDst)
+{
+ DAMAGE_GC_FUNC_PROLOGUE (pGCDst);
+ (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
+ DAMAGE_GC_FUNC_EPILOGUE (pGCDst);
+}
+
+static void
+damageChangeClip (GCPtr pGC,
+ int type,
+ pointer pvalue,
+ int nrects)
+{
+ DAMAGE_GC_FUNC_PROLOGUE (pGC);
+ (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
+ DAMAGE_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+damageCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
+{
+ DAMAGE_GC_FUNC_PROLOGUE (pgcDst);
+ (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
+ DAMAGE_GC_FUNC_EPILOGUE (pgcDst);
+}
+
+static void
+damageDestroyClip(GCPtr pGC)
+{
+ DAMAGE_GC_FUNC_PROLOGUE (pGC);
+ (* pGC->funcs->DestroyClip)(pGC);
+ DAMAGE_GC_FUNC_EPILOGUE (pGC);
+}
+
+#define TRIM_BOX(box, pGC) if (pGC->pCompositeClip) { \
+ BoxPtr extents = &pGC->pCompositeClip->extents;\
+ if(box.x1 < extents->x1) box.x1 = extents->x1; \
+ if(box.x2 > extents->x2) box.x2 = extents->x2; \
+ if(box.y1 < extents->y1) box.y1 = extents->y1; \
+ if(box.y2 > extents->y2) box.y2 = extents->y2; \
+ }
+
+#define TRANSLATE_BOX(box, pDrawable) { \
+ box.x1 += pDrawable->x; \
+ box.x2 += pDrawable->x; \
+ box.y1 += pDrawable->y; \
+ box.y2 += pDrawable->y; \
+ }
+
+#define TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC) { \
+ TRANSLATE_BOX(box, pDrawable); \
+ TRIM_BOX(box, pGC); \
+ }
+
+#define BOX_NOT_EMPTY(box) \
+ (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0))
+
+#define checkGCDamage(d,g) (getDrawableDamage(d) && \
+ (!g->pCompositeClip ||\
+ REGION_NOTEMPTY(d->pScreen, \
+ g->pCompositeClip)))
+
+#ifdef RENDER
+
+#define TRIM_PICTURE_BOX(box, pDst) { \
+ BoxPtr extents = &pDst->pCompositeClip->extents;\
+ if(box.x1 < extents->x1) box.x1 = extents->x1; \
+ if(box.x2 > extents->x2) box.x2 = extents->x2; \
+ if(box.y1 < extents->y1) box.y1 = extents->y1; \
+ if(box.y2 > extents->y2) box.y2 = extents->y2; \
+ }
+
+#define checkPictureDamage(p) (getDrawableDamage(p->pDrawable) && \
+ REGION_NOTEMPTY(pScreen, p->pCompositeClip))
+
+static void
+damageComposite (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ damageScrPriv(pScreen);
+
+ if (checkPictureDamage (pDst))
+ {
+ BoxRec box;
+
+ box.x1 = xDst + pDst->pDrawable->x;
+ box.y1 = yDst + pDst->pDrawable->y;
+ box.x2 = box.x1 + width;
+ box.y2 = box.y1 + height;
+ TRIM_PICTURE_BOX(box, pDst);
+ if (BOX_NOT_EMPTY(box))
+ damageDamageBox (pDst->pDrawable, &box, pDst->subWindowMode);
+ }
+ unwrap (pScrPriv, ps, Composite);
+ (*ps->Composite) (op,
+ pSrc,
+ pMask,
+ pDst,
+ xSrc,
+ ySrc,
+ xMask,
+ yMask,
+ xDst,
+ yDst,
+ width,
+ height);
+ wrap (pScrPriv, ps, Composite, damageComposite);
+}
+
+static void
+damageGlyphs (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlist,
+ GlyphListPtr list,
+ GlyphPtr *glyphs)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ damageScrPriv(pScreen);
+
+ if (checkPictureDamage (pDst))
+ {
+ int nlistTmp = nlist;
+ GlyphListPtr listTmp = list;
+ GlyphPtr *glyphsTmp = glyphs;
+ int x, y;
+ int n;
+ GlyphPtr glyph;
+ BoxRec box;
+ int x1, y1, x2, y2;
+
+ box.x1 = 32767;
+ box.y1 = 32767;
+ box.x2 = -32767;
+ box.y2 = -32767;
+ x = pDst->pDrawable->x;
+ y = pDst->pDrawable->y;
+ while (nlistTmp--)
+ {
+ x += listTmp->xOff;
+ y += listTmp->yOff;
+ n = listTmp->len;
+ while (n--)
+ {
+ glyph = *glyphsTmp++;
+ x1 = x - glyph->info.x;
+ y1 = y - glyph->info.y;
+ x2 = x1 + glyph->info.width;
+ y2 = y1 + glyph->info.height;
+ if (x1 < box.x1)
+ box.x1 = x1;
+ if (y1 < box.y1)
+ box.y1 = y1;
+ if (x2 > box.x2)
+ box.x2 = x2;
+ if (y2 > box.y2)
+ box.y2 = y2;
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ }
+ listTmp++;
+ }
+ TRIM_PICTURE_BOX (box, pDst);
+ if (BOX_NOT_EMPTY(box))
+ damageDamageBox (pDst->pDrawable, &box, pDst->subWindowMode);
+ }
+ unwrap (pScrPriv, ps, Glyphs);
+ (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
+ wrap (pScrPriv, ps, Glyphs, damageGlyphs);
+}
+#endif
+
+/**********************************************************/
+
+
+static void
+damageFillSpans(DrawablePtr pDrawable,
+ GC *pGC,
+ int npt,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+
+ if (npt && checkGCDamage (pDrawable, pGC))
+ {
+ int nptTmp = npt;
+ DDXPointPtr pptTmp = ppt;
+ int *pwidthTmp = pwidth;
+ BoxRec box;
+
+ box.x1 = pptTmp->x;
+ box.x2 = box.x1 + *pwidthTmp;
+ box.y2 = box.y1 = pptTmp->y;
+
+ while(--nptTmp)
+ {
+ pptTmp++;
+ pwidthTmp++;
+ if(box.x1 > pptTmp->x) box.x1 = pptTmp->x;
+ if(box.x2 < (pptTmp->x + *pwidthTmp))
+ box.x2 = pptTmp->x + *pwidthTmp;
+ if(box.y1 > pptTmp->y) box.y1 = pptTmp->y;
+ else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y;
+ }
+
+ box.y2++;
+
+ if(!pGC->miTranslate) {
+ TRANSLATE_BOX(box, pDrawable);
+ }
+ TRIM_BOX(box, pGC);
+
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDrawable, &box, pGC->subWindowMode);
+ }
+
+ (*pGC->ops->FillSpans)(pDrawable, pGC, npt, ppt, pwidth, fSorted);
+
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+}
+
+static void
+damageSetSpans(DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *pcharsrc,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int npt,
+ int fSorted)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+
+ if (npt && checkGCDamage (pDrawable, pGC))
+ {
+ DDXPointPtr pptTmp = ppt;
+ int *pwidthTmp = pwidth;
+ int nptTmp = npt;
+ BoxRec box;
+
+ box.x1 = pptTmp->x;
+ box.x2 = box.x1 + *pwidthTmp;
+ box.y2 = box.y1 = pptTmp->y;
+
+ while(--nptTmp)
+ {
+ pptTmp++;
+ pwidthTmp++;
+ if(box.x1 > pptTmp->x) box.x1 = pptTmp->x;
+ if(box.x2 < (pptTmp->x + *pwidthTmp))
+ box.x2 = pptTmp->x + *pwidthTmp;
+ if(box.y1 > pptTmp->y) box.y1 = pptTmp->y;
+ else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y;
+ }
+
+ box.y2++;
+
+ if(!pGC->miTranslate) {
+ TRANSLATE_BOX(box, pDrawable);
+ }
+ TRIM_BOX(box, pGC);
+
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDrawable, &box, pGC->subWindowMode);
+ }
+ (*pGC->ops->SetSpans)(pDrawable, pGC, pcharsrc, ppt, pwidth, npt, fSorted);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+}
+
+static void
+damagePutImage(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int depth,
+ int x,
+ int y,
+ int w,
+ int h,
+ int leftPad,
+ int format,
+ char *pImage)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+ if (checkGCDamage (pDrawable, pGC))
+ {
+ BoxRec box;
+
+ box.x1 = x + pDrawable->x;
+ box.x2 = box.x1 + w;
+ box.y1 = y + pDrawable->y;
+ box.y2 = box.y1 + h;
+
+ TRIM_BOX(box, pGC);
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDrawable, &box, pGC->subWindowMode);
+ }
+ (*pGC->ops->PutImage)(pDrawable, pGC, depth, x, y, w, h,
+ leftPad, format, pImage);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+}
+
+static RegionPtr
+damageCopyArea(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC *pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx,
+ int dsty)
+{
+ RegionPtr ret;
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDst);
+
+ /* The driver will only call SourceValidate() when pSrc != pDst,
+ * but the software sprite (misprite.c) always need to know when a
+ * drawable is copied so it can remove the sprite. See #1030. */
+ if ((pSrc == pDst) && pSrc->pScreen->SourceValidate &&
+ pSrc->type == DRAWABLE_WINDOW &&
+ ((WindowPtr)pSrc)->viewable)
+ {
+ (*pSrc->pScreen->SourceValidate) (pSrc, srcx, srcy, width, height);
+ }
+
+ if (checkGCDamage (pDst, pGC))
+ {
+ BoxRec box;
+
+ box.x1 = dstx + pDst->x;
+ box.x2 = box.x1 + width;
+ box.y1 = dsty + pDst->y;
+ box.y2 = box.y1 + height;
+
+ TRIM_BOX(box, pGC);
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDst, &box, pGC->subWindowMode);
+ }
+
+ ret = (*pGC->ops->CopyArea)(pSrc, pDst,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDst);
+ return ret;
+}
+
+static RegionPtr
+damageCopyPlane(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx,
+ int dsty,
+ unsigned long bitPlane)
+{
+ RegionPtr ret;
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDst);
+
+ /* The driver will only call SourceValidate() when pSrc != pDst,
+ * but the software sprite (misprite.c) always need to know when a
+ * drawable is copied so it can remove the sprite. See #1030. */
+ if ((pSrc == pDst) && pSrc->pScreen->SourceValidate &&
+ pSrc->type == DRAWABLE_WINDOW &&
+ ((WindowPtr)pSrc)->viewable)
+ {
+ (*pSrc->pScreen->SourceValidate) (pSrc, srcx, srcy, width, height);
+ }
+
+ if (checkGCDamage (pDst, pGC))
+ {
+ BoxRec box;
+
+ box.x1 = dstx + pDst->x;
+ box.x2 = box.x1 + width;
+ box.y1 = dsty + pDst->y;
+ box.y2 = box.y1 + height;
+
+ TRIM_BOX(box, pGC);
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDst, &box, pGC->subWindowMode);
+ }
+
+ ret = (*pGC->ops->CopyPlane)(pSrc, pDst,
+ pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDst);
+ return ret;
+}
+
+static void
+damagePolyPoint(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ xPoint *ppt)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+
+ if (npt && checkGCDamage (pDrawable, pGC))
+ {
+ BoxRec box;
+ int nptTmp = npt;
+ xPoint *pptTmp = ppt;
+
+ box.x2 = box.x1 = pptTmp->x;
+ box.y2 = box.y1 = pptTmp->y;
+
+ /* this could be slow if the points were spread out */
+
+ while(--nptTmp)
+ {
+ pptTmp++;
+ if(box.x1 > pptTmp->x) box.x1 = pptTmp->x;
+ else if(box.x2 < pptTmp->x) box.x2 = pptTmp->x;
+ if(box.y1 > pptTmp->y) box.y1 = pptTmp->y;
+ else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y;
+ }
+
+ box.x2++;
+ box.y2++;
+
+ TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDrawable, &box, pGC->subWindowMode);
+ }
+ (*pGC->ops->PolyPoint)(pDrawable, pGC, mode, npt, ppt);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+}
+
+static void
+damagePolylines(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr ppt)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+
+ if (npt && checkGCDamage (pDrawable, pGC))
+ {
+ int nptTmp = npt;
+ DDXPointPtr pptTmp = ppt;
+ BoxRec box;
+ int extra = pGC->lineWidth >> 1;
+
+ box.x2 = box.x1 = pptTmp->x;
+ box.y2 = box.y1 = pptTmp->y;
+
+ if(nptTmp > 1)
+ {
+ if(pGC->joinStyle == JoinMiter)
+ extra = 6 * pGC->lineWidth;
+ else if(pGC->capStyle == CapProjecting)
+ extra = pGC->lineWidth;
+ }
+
+ if(mode == CoordModePrevious)
+ {
+ int x = box.x1;
+ int y = box.y1;
+ while(--nptTmp)
+ {
+ pptTmp++;
+ x += pptTmp->x;
+ y += pptTmp->y;
+ if(box.x1 > x) box.x1 = x;
+ else if(box.x2 < x) box.x2 = x;
+ if(box.y1 > y) box.y1 = y;
+ else if(box.y2 < y) box.y2 = y;
+ }
+ }
+ else
+ {
+ while(--nptTmp)
+ {
+ pptTmp++;
+ if(box.x1 > pptTmp->x) box.x1 = pptTmp->x;
+ else if(box.x2 < pptTmp->x) box.x2 = pptTmp->x;
+ if(box.y1 > pptTmp->y) box.y1 = pptTmp->y;
+ else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ if(extra)
+ {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDrawable, &box, pGC->subWindowMode);
+ }
+ (*pGC->ops->Polylines)(pDrawable, pGC, mode, npt, ppt);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+}
+
+static void
+damagePolySegment(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nSeg,
+ xSegment *pSeg)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+
+ if (nSeg && checkGCDamage (pDrawable, pGC))
+ {
+ BoxRec box;
+ int extra = pGC->lineWidth;
+ int nsegTmp = nSeg;
+ xSegment *pSegTmp = pSeg;
+
+ if(pGC->capStyle != CapProjecting)
+ extra >>= 1;
+
+ if(pSegTmp->x2 > pSegTmp->x1) {
+ box.x1 = pSegTmp->x1;
+ box.x2 = pSegTmp->x2;
+ } else {
+ box.x2 = pSegTmp->x1;
+ box.x1 = pSegTmp->x2;
+ }
+
+ if(pSegTmp->y2 > pSegTmp->y1) {
+ box.y1 = pSegTmp->y1;
+ box.y2 = pSegTmp->y2;
+ } else {
+ box.y2 = pSegTmp->y1;
+ box.y1 = pSegTmp->y2;
+ }
+
+ while(--nsegTmp)
+ {
+ pSegTmp++;
+ if(pSegTmp->x2 > pSegTmp->x1)
+ {
+ if(pSegTmp->x1 < box.x1) box.x1 = pSegTmp->x1;
+ if(pSegTmp->x2 > box.x2) box.x2 = pSegTmp->x2;
+ }
+ else
+ {
+ if(pSegTmp->x2 < box.x1) box.x1 = pSegTmp->x2;
+ if(pSegTmp->x1 > box.x2) box.x2 = pSegTmp->x1;
+ }
+ if(pSegTmp->y2 > pSegTmp->y1)
+ {
+ if(pSegTmp->y1 < box.y1) box.y1 = pSegTmp->y1;
+ if(pSegTmp->y2 > box.y2) box.y2 = pSegTmp->y2;
+ }
+ else
+ {
+ if(pSegTmp->y2 < box.y1) box.y1 = pSegTmp->y2;
+ if(pSegTmp->y1 > box.y2) box.y2 = pSegTmp->y1;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ if(extra)
+ {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDrawable, &box, pGC->subWindowMode);
+ }
+ (*pGC->ops->PolySegment)(pDrawable, pGC, nSeg, pSeg);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+}
+
+static void
+damagePolyRectangle(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nRects,
+ xRectangle *pRects)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+
+ if (nRects && checkGCDamage (pDrawable, pGC))
+ {
+ BoxRec box;
+ int offset1, offset2, offset3;
+ int nRectsTmp = nRects;
+ xRectangle *pRectsTmp = pRects;
+
+ offset2 = pGC->lineWidth;
+ if(!offset2) offset2 = 1;
+ offset1 = offset2 >> 1;
+ offset3 = offset2 - offset1;
+
+ while(nRectsTmp--)
+ {
+ box.x1 = pRectsTmp->x - offset1;
+ box.y1 = pRectsTmp->y - offset1;
+ box.x2 = box.x1 + pRectsTmp->width + offset2;
+ box.y2 = box.y1 + offset2;
+ TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDrawable, &box, pGC->subWindowMode);
+
+ box.x1 = pRectsTmp->x - offset1;
+ box.y1 = pRectsTmp->y + offset3;
+ box.x2 = box.x1 + offset2;
+ box.y2 = box.y1 + pRectsTmp->height - offset2;
+ TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDrawable, &box, pGC->subWindowMode);
+
+ box.x1 = pRectsTmp->x + pRectsTmp->width - offset1;
+ box.y1 = pRectsTmp->y + offset3;
+ box.x2 = box.x1 + offset2;
+ box.y2 = box.y1 + pRectsTmp->height - offset2;
+ TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDrawable, &box, pGC->subWindowMode);
+
+ box.x1 = pRectsTmp->x - offset1;
+ box.y1 = pRectsTmp->y + pRectsTmp->height - offset1;
+ box.x2 = box.x1 + pRectsTmp->width + offset2;
+ box.y2 = box.y1 + offset2;
+ TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDrawable, &box, pGC->subWindowMode);
+
+ pRectsTmp++;
+ }
+ }
+ (*pGC->ops->PolyRectangle)(pDrawable, pGC, nRects, pRects);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+}
+
+static void
+damagePolyArc(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArcs,
+ xArc *pArcs)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+
+ if (nArcs && checkGCDamage (pDrawable, pGC))
+ {
+ int extra = pGC->lineWidth >> 1;
+ BoxRec box;
+ int nArcsTmp = nArcs;
+ xArc *pArcsTmp = pArcs;
+
+ box.x1 = pArcsTmp->x;
+ box.x2 = box.x1 + pArcsTmp->width;
+ box.y1 = pArcsTmp->y;
+ box.y2 = box.y1 + pArcsTmp->height;
+
+ while(--nArcsTmp)
+ {
+ pArcsTmp++;
+ if(box.x1 > pArcsTmp->x)
+ box.x1 = pArcsTmp->x;
+ if(box.x2 < (pArcsTmp->x + pArcsTmp->width))
+ box.x2 = pArcsTmp->x + pArcsTmp->width;
+ if(box.y1 > pArcsTmp->y)
+ box.y1 = pArcsTmp->y;
+ if(box.y2 < (pArcsTmp->y + pArcsTmp->height))
+ box.y2 = pArcsTmp->y + pArcsTmp->height;
+ }
+
+ if(extra)
+ {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ box.x2++;
+ box.y2++;
+
+ TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDrawable, &box, pGC->subWindowMode);
+ }
+ (*pGC->ops->PolyArc)(pDrawable, pGC, nArcs, pArcs);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+}
+
+static void
+damageFillPolygon(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int npt,
+ DDXPointPtr ppt)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+
+ if (npt > 2 && checkGCDamage (pDrawable, pGC))
+ {
+ DDXPointPtr pptTmp = ppt;
+ int nptTmp = npt;
+ BoxRec box;
+
+ box.x2 = box.x1 = pptTmp->x;
+ box.y2 = box.y1 = pptTmp->y;
+
+ if(mode != CoordModeOrigin)
+ {
+ int x = box.x1;
+ int y = box.y1;
+ while(--nptTmp)
+ {
+ pptTmp++;
+ x += pptTmp->x;
+ y += pptTmp->y;
+ if(box.x1 > x) box.x1 = x;
+ else if(box.x2 < x) box.x2 = x;
+ if(box.y1 > y) box.y1 = y;
+ else if(box.y2 < y) box.y2 = y;
+ }
+ }
+ else
+ {
+ while(--nptTmp)
+ {
+ pptTmp++;
+ if(box.x1 > pptTmp->x) box.x1 = pptTmp->x;
+ else if(box.x2 < pptTmp->x) box.x2 = pptTmp->x;
+ if(box.y1 > pptTmp->y) box.y1 = pptTmp->y;
+ else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDrawable, &box, pGC->subWindowMode);
+ }
+
+ (*pGC->ops->FillPolygon)(pDrawable, pGC, shape, mode, npt, ppt);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+}
+
+
+static void
+damagePolyFillRect(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nRects,
+ xRectangle *pRects)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+ if (nRects && checkGCDamage (pDrawable, pGC))
+ {
+ BoxRec box;
+ xRectangle *pRectsTmp = pRects;
+ int nRectsTmp = nRects;
+
+ box.x1 = pRectsTmp->x;
+ box.x2 = box.x1 + pRectsTmp->width;
+ box.y1 = pRectsTmp->y;
+ box.y2 = box.y1 + pRectsTmp->height;
+
+ while(--nRectsTmp)
+ {
+ pRectsTmp++;
+ if(box.x1 > pRectsTmp->x) box.x1 = pRectsTmp->x;
+ if(box.x2 < (pRectsTmp->x + pRectsTmp->width))
+ box.x2 = pRectsTmp->x + pRectsTmp->width;
+ if(box.y1 > pRectsTmp->y) box.y1 = pRectsTmp->y;
+ if(box.y2 < (pRectsTmp->y + pRectsTmp->height))
+ box.y2 = pRectsTmp->y + pRectsTmp->height;
+ }
+
+ TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDrawable, &box, pGC->subWindowMode);
+ }
+ (*pGC->ops->PolyFillRect)(pDrawable, pGC, nRects, pRects);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+}
+
+
+static void
+damagePolyFillArc(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArcs,
+ xArc *pArcs)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+
+ if (nArcs && checkGCDamage (pDrawable, pGC))
+ {
+ BoxRec box;
+ int nArcsTmp = nArcs;
+ xArc *pArcsTmp = pArcs;
+
+ box.x1 = pArcsTmp->x;
+ box.x2 = box.x1 + pArcsTmp->width;
+ box.y1 = pArcsTmp->y;
+ box.y2 = box.y1 + pArcsTmp->height;
+
+ while(--nArcsTmp)
+ {
+ pArcsTmp++;
+ if(box.x1 > pArcsTmp->x)
+ box.x1 = pArcsTmp->x;
+ if(box.x2 < (pArcsTmp->x + pArcsTmp->width))
+ box.x2 = pArcsTmp->x + pArcsTmp->width;
+ if(box.y1 > pArcsTmp->y)
+ box.y1 = pArcsTmp->y;
+ if(box.y2 < (pArcsTmp->y + pArcsTmp->height))
+ box.y2 = pArcsTmp->y + pArcsTmp->height;
+ }
+
+ TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDrawable, &box, pGC->subWindowMode);
+ }
+ (*pGC->ops->PolyFillArc)(pDrawable, pGC, nArcs, pArcs);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+}
+
+/*
+ * general Poly/Image text function. Extract glyph information,
+ * compute bounding box and remove cursor if it is overlapped.
+ */
+
+static void
+damageDamageChars (DrawablePtr pDrawable,
+ FontPtr font,
+ int x,
+ int y,
+ unsigned int n,
+ CharInfoPtr *charinfo,
+ Bool imageblt,
+ int subWindowMode)
+{
+ ExtentInfoRec extents;
+ BoxRec box;
+
+ QueryGlyphExtents(font, charinfo, n, &extents);
+ if (imageblt)
+ {
+ if (extents.overallWidth > extents.overallRight)
+ extents.overallRight = extents.overallWidth;
+ if (extents.overallWidth < extents.overallLeft)
+ extents.overallLeft = extents.overallWidth;
+ if (extents.overallLeft > 0)
+ extents.overallLeft = 0;
+ if (extents.fontAscent > extents.overallAscent)
+ extents.overallAscent = extents.fontAscent;
+ if (extents.fontDescent > extents.overallDescent)
+ extents.overallDescent = extents.fontDescent;
+ }
+ box.x1 = x + extents.overallLeft;
+ box.y1 = y - extents.overallAscent;
+ box.x2 = x + extents.overallRight;
+ box.y2 = y + extents.overallDescent;
+ damageDamageBox (pDrawable, &box, subWindowMode);
+}
+
+/*
+ * values for textType:
+ */
+#define TT_POLY8 0
+#define TT_IMAGE8 1
+#define TT_POLY16 2
+#define TT_IMAGE16 3
+
+static int
+damageText (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned long count,
+ char *chars,
+ FontEncoding fontEncoding,
+ Bool textType)
+{
+ CharInfoPtr *charinfo;
+ CharInfoPtr *info;
+ unsigned long i;
+ unsigned int n;
+ int w;
+ Bool imageblt;
+
+ imageblt = (textType == TT_IMAGE8) || (textType == TT_IMAGE16);
+
+ charinfo = (CharInfoPtr *) ALLOCATE_LOCAL(count * sizeof(CharInfoPtr));
+ if (!charinfo)
+ return x;
+
+ GetGlyphs(pGC->font, count, (unsigned char *)chars,
+ fontEncoding, &i, charinfo);
+ n = (unsigned int)i;
+ w = 0;
+ if (!imageblt)
+ for (info = charinfo; i--; info++)
+ w += (*info)->metrics.characterWidth;
+
+ if (n != 0) {
+ damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y, n,
+ charinfo, imageblt, pGC->subWindowMode);
+ if (imageblt)
+ (*pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, n, charinfo,
+ FONTGLYPHS(pGC->font));
+ else
+ (*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, n, charinfo,
+ FONTGLYPHS(pGC->font));
+ }
+ DEALLOCATE_LOCAL(charinfo);
+ return x + w;
+}
+
+static int
+damagePolyText8(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *chars)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+
+ if (checkGCDamage (pDrawable, pGC))
+ x = damageText (pDrawable, pGC, x, y, (unsigned long) count, chars,
+ Linear8Bit, TT_POLY8);
+ else
+ x = (*pGC->ops->PolyText8)(pDrawable, pGC, x, y, count, chars);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+ return x;
+}
+
+static int
+damagePolyText16(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *chars)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+
+ if (checkGCDamage (pDrawable, pGC))
+ x = damageText (pDrawable, pGC, x, y, (unsigned long) count, (char *) chars,
+ FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit,
+ TT_POLY16);
+ else
+ x = (*pGC->ops->PolyText16)(pDrawable, pGC, x, y, count, chars);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+ return x;
+}
+
+static void
+damageImageText8(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *chars)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+
+ if (checkGCDamage (pDrawable, pGC))
+ damageText (pDrawable, pGC, x, y, (unsigned long) count, chars,
+ Linear8Bit, TT_IMAGE8);
+ else
+ (*pGC->ops->ImageText8)(pDrawable, pGC, x, y, count, chars);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+}
+
+static void
+damageImageText16(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *chars)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+
+ if (checkGCDamage (pDrawable, pGC))
+ damageText (pDrawable, pGC, x, y, (unsigned long) count, (char *) chars,
+ FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit,
+ TT_IMAGE16);
+ else
+ (*pGC->ops->ImageText16)(pDrawable, pGC, x, y, count, chars);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+}
+
+
+static void
+damageImageGlyphBlt(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+ damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y,
+ nglyph, ppci, TRUE, pGC->subWindowMode);
+ (*pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, nglyph,
+ ppci, pglyphBase);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+}
+
+static void
+damagePolyGlyphBlt(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+ damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y,
+ nglyph, ppci, FALSE, pGC->subWindowMode);
+ (*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph,
+ ppci, pglyphBase);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+}
+
+static void
+damagePushPixels(GCPtr pGC,
+ PixmapPtr pBitMap,
+ DrawablePtr pDrawable,
+ int dx,
+ int dy,
+ int xOrg,
+ int yOrg)
+{
+ DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);
+ if(checkGCDamage (pDrawable, pGC))
+ {
+ BoxRec box;
+
+ box.x1 = xOrg;
+ box.y1 = yOrg;
+
+ if(!pGC->miTranslate) {
+ box.x1 += pDrawable->x;
+ box.y1 += pDrawable->y;
+ }
+
+ box.x2 = box.x1 + dx;
+ box.y2 = box.y1 + dy;
+
+ TRIM_BOX(box, pGC);
+ if(BOX_NOT_EMPTY(box))
+ damageDamageBox (pDrawable, &box, pGC->subWindowMode);
+ }
+ (*pGC->ops->PushPixels)(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg);
+ DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
+}
+
+static void
+damageRemoveDamage (DamagePtr *pPrev, DamagePtr pDamage)
+{
+ while (*pPrev)
+ {
+ if (*pPrev == pDamage)
+ {
+ *pPrev = pDamage->pNext;
+ return;
+ }
+ pPrev = &(*pPrev)->pNext;
+ }
+#if DAMAGE_VALIDATE_ENABLE
+ ErrorF ("Damage not on list\n");
+ abort ();
+#endif
+}
+
+static void
+damageInsertDamage (DamagePtr *pPrev, DamagePtr pDamage)
+{
+#if DAMAGE_VALIDATE_ENABLE
+ DamagePtr pOld;
+
+ for (pOld = *pPrev; pOld; pOld = pOld->pNext)
+ if (pOld == pDamage) {
+ ErrorF ("Damage already on list\n");
+ abort ();
+ }
+#endif
+ pDamage->pNext = *pPrev;
+ *pPrev = pDamage;
+}
+
+static Bool
+damageDestroyPixmap (PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ damageScrPriv(pScreen);
+
+ if (pPixmap->refcnt == 1)
+ {
+ DamagePtr *pPrev = getPixmapDamageRef (pPixmap);
+ DamagePtr pDamage;
+
+ while ((pDamage = *pPrev))
+ {
+ damageRemoveDamage (pPrev, pDamage);
+ if (!pDamage->isWindow)
+ DamageDestroy (pDamage);
+ }
+ }
+ unwrap (pScrPriv, pScreen, DestroyPixmap);
+ (*pScreen->DestroyPixmap) (pPixmap);
+ wrap (pScrPriv, pScreen, DestroyPixmap, damageDestroyPixmap);
+ return TRUE;
+}
+
+static void
+damagePaintWindow(WindowPtr pWindow,
+ RegionPtr prgn,
+ int what)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ damageScrPriv(pScreen);
+
+ /*
+ * Painting background none doesn't actually *do* anything, so
+ * no damage is recorded
+ */
+ if ((what != PW_BACKGROUND || pWindow->backgroundState != None) &&
+ getWindowDamage (pWindow))
+ damageDamageRegion (&pWindow->drawable, prgn, FALSE, -1);
+ if(what == PW_BACKGROUND) {
+ unwrap (pScrPriv, pScreen, PaintWindowBackground);
+ (*pScreen->PaintWindowBackground) (pWindow, prgn, what);
+ wrap (pScrPriv, pScreen, PaintWindowBackground, damagePaintWindow);
+ } else {
+ unwrap (pScrPriv, pScreen, PaintWindowBorder);
+ (*pScreen->PaintWindowBorder) (pWindow, prgn, what);
+ wrap (pScrPriv, pScreen, PaintWindowBorder, damagePaintWindow);
+ }
+}
+
+
+static void
+damageCopyWindow(WindowPtr pWindow,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ damageScrPriv(pScreen);
+
+ if (getWindowDamage (pWindow))
+ {
+ int dx = pWindow->drawable.x - ptOldOrg.x;
+ int dy = pWindow->drawable.y - ptOldOrg.y;
+
+ /*
+ * The region comes in source relative, but the damage occurs
+ * at the destination location. Translate back and forth.
+ */
+ REGION_TRANSLATE (pScreen, prgnSrc, dx, dy);
+ damageDamageRegion (&pWindow->drawable, prgnSrc, FALSE, -1);
+ REGION_TRANSLATE (pScreen, prgnSrc, -dx, -dy);
+ }
+ unwrap (pScrPriv, pScreen, CopyWindow);
+ (*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc);
+ wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow);
+}
+
+GCOps damageGCOps = {
+ damageFillSpans, damageSetSpans,
+ damagePutImage, damageCopyArea,
+ damageCopyPlane, damagePolyPoint,
+ damagePolylines, damagePolySegment,
+ damagePolyRectangle, damagePolyArc,
+ damageFillPolygon, damagePolyFillRect,
+ damagePolyFillArc, damagePolyText8,
+ damagePolyText16, damageImageText8,
+ damageImageText16, damageImageGlyphBlt,
+ damagePolyGlyphBlt, damagePushPixels,
+#ifdef NEED_LINEHELPER
+ NULL,
+#endif
+ {NULL} /* devPrivate */
+};
+
+static void
+damageRestoreAreas (PixmapPtr pPixmap,
+ RegionPtr prgn,
+ int xorg,
+ int yorg,
+ WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ damageScrPriv(pScreen);
+
+ damageDamageRegion (&pWindow->drawable, prgn, FALSE, -1);
+ unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas);
+ (*pScreen->BackingStoreFuncs.RestoreAreas) (pPixmap, prgn,
+ xorg, yorg, pWindow);
+ wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas,
+ damageRestoreAreas);
+}
+
+static void
+damageSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
+{
+ DamagePtr pDamage;
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ damageScrPriv(pScreen);
+
+ if ((pDamage = damageGetWinPriv(pWindow)))
+ {
+ PixmapPtr pOldPixmap = (*pScreen->GetWindowPixmap) (pWindow);
+ DamagePtr *pPrev = getPixmapDamageRef(pOldPixmap);
+
+ while (pDamage)
+ {
+ damageRemoveDamage (pPrev, pDamage);
+ pDamage = pDamage->pNextWin;
+ }
+ }
+ unwrap (pScrPriv, pScreen, SetWindowPixmap);
+ (*pScreen->SetWindowPixmap) (pWindow, pPixmap);
+ wrap (pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap);
+ if ((pDamage = damageGetWinPriv(pWindow)))
+ {
+ DamagePtr *pPrev = getPixmapDamageRef(pPixmap);
+
+ while (pDamage)
+ {
+ damageInsertDamage (pPrev, pDamage);
+ pDamage = pDamage->pNextWin;
+ }
+ }
+}
+
+static Bool
+damageDestroyWindow (WindowPtr pWindow)
+{
+ DamagePtr pDamage;
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ Bool ret;
+ damageScrPriv(pScreen);
+
+ while ((pDamage = damageGetWinPriv(pWindow)))
+ {
+ DamageUnregister (&pWindow->drawable, pDamage);
+ DamageDestroy (pDamage);
+ }
+ unwrap (pScrPriv, pScreen, DestroyWindow);
+ ret = (*pScreen->DestroyWindow) (pWindow);
+ wrap (pScrPriv, pScreen, DestroyWindow, damageDestroyWindow);
+ return ret;
+}
+
+static Bool
+damageCloseScreen (int i, ScreenPtr pScreen)
+{
+ damageScrPriv(pScreen);
+
+ unwrap (pScrPriv, pScreen, DestroyPixmap);
+ unwrap (pScrPriv, pScreen, CreateGC);
+ unwrap (pScrPriv, pScreen, PaintWindowBackground);
+ unwrap (pScrPriv, pScreen, PaintWindowBorder);
+ unwrap (pScrPriv, pScreen, CopyWindow);
+ unwrap (pScrPriv, pScreen, CloseScreen);
+ unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas);
+ xfree (pScrPriv);
+ return (*pScreen->CloseScreen) (i, pScreen);
+}
+
+int damageScrPrivateIndex;
+int damagePixPrivateIndex;
+int damageGCPrivateIndex;
+int damageWinPrivateIndex;
+int damageGeneration;
+
+Bool
+DamageSetup (ScreenPtr pScreen)
+{
+ DamageScrPrivPtr pScrPriv;
+#ifdef RENDER
+ PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
+#endif
+
+ if (damageGeneration != serverGeneration)
+ {
+ damageScrPrivateIndex = AllocateScreenPrivateIndex ();
+ if (damageScrPrivateIndex == -1)
+ return FALSE;
+ damageGCPrivateIndex = AllocateGCPrivateIndex ();
+ if (damageGCPrivateIndex == -1)
+ return FALSE;
+ damagePixPrivateIndex = AllocatePixmapPrivateIndex ();
+ if (damagePixPrivateIndex == -1)
+ return FALSE;
+ damageWinPrivateIndex = AllocateWindowPrivateIndex ();
+ if (damageWinPrivateIndex == -1)
+ return FALSE;
+ damageGeneration = serverGeneration;
+ }
+ if (pScreen->devPrivates[damageScrPrivateIndex].ptr)
+ return TRUE;
+
+ if (!AllocateGCPrivate (pScreen, damageGCPrivateIndex, sizeof (DamageGCPrivRec)))
+ return FALSE;
+ if (!AllocatePixmapPrivate (pScreen, damagePixPrivateIndex, 0))
+ return FALSE;
+ if (!AllocateWindowPrivate (pScreen, damageWinPrivateIndex, 0))
+ return FALSE;
+
+ pScrPriv = (DamageScrPrivPtr) xalloc (sizeof (DamageScrPrivRec));
+ if (!pScrPriv)
+ return FALSE;
+
+#ifdef COMPOSITE
+ /* This is a kludge to ensure wrapping order with the composite wrapper.
+ * If it's done from compinit.c, then DamageSetup may be called before the
+ * extension init phase, so that cw will be higher in the wrapping chain and
+ * rewrite drawables before damage gets to it, causing confusion.
+ */
+ if (!noCompositeExtension)
+ miInitializeCompositeWrapper (pScreen);
+#endif
+
+ pScrPriv->internalLevel = 0;
+ pScrPriv->pScreenDamage = 0;
+
+ wrap (pScrPriv, pScreen, DestroyPixmap, damageDestroyPixmap);
+ wrap (pScrPriv, pScreen, CreateGC, damageCreateGC);
+ wrap (pScrPriv, pScreen, PaintWindowBackground, damagePaintWindow);
+ wrap (pScrPriv, pScreen, PaintWindowBorder, damagePaintWindow);
+ wrap (pScrPriv, pScreen, DestroyWindow, damageDestroyWindow);
+ wrap (pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap);
+ wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow);
+ wrap (pScrPriv, pScreen, CloseScreen, damageCloseScreen);
+ wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas,
+ damageRestoreAreas);
+#ifdef RENDER
+ if (ps) {
+ wrap (pScrPriv, ps, Glyphs, damageGlyphs);
+ wrap (pScrPriv, ps, Composite, damageComposite);
+ }
+#endif
+
+ pScreen->devPrivates[damageScrPrivateIndex].ptr = (pointer) pScrPriv;
+ return TRUE;
+}
+
+DamagePtr
+DamageCreate (DamageReportFunc damageReport,
+ DamageDestroyFunc damageDestroy,
+ DamageReportLevel damageLevel,
+ Bool isInternal,
+ ScreenPtr pScreen,
+ void *closure)
+{
+ DamagePtr pDamage;
+
+ pDamage = xalloc (sizeof (DamageRec));
+ if (!pDamage)
+ return 0;
+ pDamage->pNext = 0;
+ pDamage->pNextWin = 0;
+ REGION_NULL(pScreen, &pDamage->damage);
+
+ pDamage->damageLevel = damageLevel;
+ pDamage->isInternal = isInternal;
+ pDamage->closure = closure;
+ pDamage->isWindow = FALSE;
+ pDamage->pDrawable = 0;
+
+ pDamage->damageReport = damageReport;
+ pDamage->damageDestroy = damageDestroy;
+ return pDamage;
+}
+
+void
+DamageRegister (DrawablePtr pDrawable,
+ DamagePtr pDamage)
+{
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ {
+ WindowPtr pWindow = (WindowPtr) pDrawable;
+ winDamageRef(pWindow);
+
+#if DAMAGE_VALIDATE_ENABLE
+ DamagePtr pOld;
+
+ for (pOld = *pPrev; pOld; pOld = pOld->pNextWin)
+ if (pOld == pDamage) {
+ ErrorF ("Damage already on window list\n");
+ abort ();
+ }
+#endif
+ pDamage->pNextWin = *pPrev;
+ *pPrev = pDamage;
+ pDamage->isWindow = TRUE;
+ }
+ else
+ pDamage->isWindow = FALSE;
+ pDamage->pDrawable = pDrawable;
+ damageInsertDamage (getDrawableDamageRef (pDrawable), pDamage);
+}
+
+void
+DamageDrawInternal (ScreenPtr pScreen, Bool enable)
+{
+ damageScrPriv (pScreen);
+
+ pScrPriv->internalLevel += enable ? 1 : -1;
+}
+
+void
+DamageUnregister (DrawablePtr pDrawable,
+ DamagePtr pDamage)
+{
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ {
+ WindowPtr pWindow = (WindowPtr) pDrawable;
+ winDamageRef (pWindow);
+#if DAMAGE_VALIDATE_ENABLE
+ int found = 0;
+#endif
+
+ while (*pPrev)
+ {
+ if (*pPrev == pDamage)
+ {
+ *pPrev = pDamage->pNextWin;
+#if DAMAGE_VALIDATE_ENABLE
+ found = 1;
+#endif
+ break;
+ }
+ pPrev = &(*pPrev)->pNextWin;
+ }
+#if DAMAGE_VALIDATE_ENABLE
+ if (!found) {
+ ErrorF ("Damage not on window list\n");
+ abort ();
+ }
+#endif
+ }
+ pDamage->pDrawable = 0;
+ damageRemoveDamage (getDrawableDamageRef (pDrawable), pDamage);
+}
+
+void
+DamageDestroy (DamagePtr pDamage)
+{
+ if (pDamage->damageDestroy)
+ (*pDamage->damageDestroy) (pDamage, pDamage->closure);
+ REGION_UNINIT (pDamage->pDrawable->pScreen, &pDamage->damage);
+ xfree (pDamage);
+}
+
+Bool
+DamageSubtract (DamagePtr pDamage,
+ const RegionPtr pRegion)
+{
+ RegionPtr pClip;
+ RegionRec pixmapClip;
+ DrawablePtr pDrawable = pDamage->pDrawable;
+
+ REGION_SUBTRACT (pDrawable->pScreen, &pDamage->damage, &pDamage->damage, pRegion);
+ if (pDrawable)
+ {
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ pClip = &((WindowPtr) pDrawable)->borderClip;
+ else
+ {
+ BoxRec box;
+
+ box.x1 = pDrawable->x;
+ box.y1 = pDrawable->y;
+ box.x2 = pDrawable->x + pDrawable->width;
+ box.y2 = pDrawable->y + pDrawable->height;
+ REGION_INIT (pDrawable->pScreen, &pixmapClip, &box, 1);
+ pClip = &pixmapClip;
+ }
+ REGION_TRANSLATE (pDrawable->pScreen, &pDamage->damage, pDrawable->x, pDrawable->y);
+ REGION_INTERSECT (pDrawable->pScreen, &pDamage->damage, &pDamage->damage, pClip);
+ REGION_TRANSLATE (pDrawable->pScreen, &pDamage->damage, -pDrawable->x, -pDrawable->y);
+ if (pDrawable->type != DRAWABLE_WINDOW)
+ REGION_UNINIT(pDrawable->pScreen, &pixmapClip);
+ }
+ return REGION_NOTEMPTY (pDrawable->pScreen, &pDamage->damage);
+}
+
+void
+DamageEmpty (DamagePtr pDamage)
+{
+ REGION_EMPTY (pDamage->pDrawable->pScreen, &pDamage->damage);
+}
+
+RegionPtr
+DamageRegion (DamagePtr pDamage)
+{
+ return &pDamage->damage;
+}
+
+void
+DamageDamageRegion (DrawablePtr pDrawable,
+ RegionPtr pRegion)
+{
+ damageDamageRegion (pDrawable, pRegion, FALSE, -1);
+}
diff --git a/nx-X11/programs/Xserver/miext/damage/damage.h b/nx-X11/programs/Xserver/miext/damage/damage.h
new file mode 100755
index 000000000..a363e09bb
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/damage/damage.h
@@ -0,0 +1,84 @@
+/*
+ * $Id: damage.h,v 1.4 2005/07/03 07:02:01 daniels Exp $
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _DAMAGE_H_
+#define _DAMAGE_H_
+
+typedef struct _damage *DamagePtr;
+
+typedef enum _damageReportLevel {
+ DamageReportRawRegion,
+ DamageReportDeltaRegion,
+ DamageReportBoundingBox,
+ DamageReportNonEmpty,
+ DamageReportNone
+} DamageReportLevel;
+
+typedef void (*DamageReportFunc) (DamagePtr pDamage, RegionPtr pRegion, void *closure);
+typedef void (*DamageDestroyFunc) (DamagePtr pDamage, void *closure);
+
+Bool
+DamageSetup (ScreenPtr pScreen);
+
+DamagePtr
+DamageCreate (DamageReportFunc damageReport,
+ DamageDestroyFunc damageDestroy,
+ DamageReportLevel damageLevel,
+ Bool isInternal,
+ ScreenPtr pScreen,
+ void * closure);
+
+void
+DamageDrawInternal (ScreenPtr pScreen, Bool enable);
+
+void
+DamageRegister (DrawablePtr pDrawable,
+ DamagePtr pDamage);
+
+void
+DamageUnregister (DrawablePtr pDrawable,
+ DamagePtr pDamage);
+
+void
+DamageDestroy (DamagePtr pDamage);
+
+Bool
+DamageSubtract (DamagePtr pDamage,
+ const RegionPtr pRegion);
+
+void
+DamageEmpty (DamagePtr pDamage);
+
+RegionPtr
+DamageRegion (DamagePtr pDamage);
+
+void
+DamageDamageRegion (DrawablePtr pDrawable,
+ const RegionPtr pRegion);
+
+#endif /* _DAMAGE_H_ */
diff --git a/nx-X11/programs/Xserver/miext/damage/damagestr.h b/nx-X11/programs/Xserver/miext/damage/damagestr.h
new file mode 100755
index 000000000..d7dd11d92
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/damage/damagestr.h
@@ -0,0 +1,113 @@
+/*
+ * $Id: damagestr.h,v 1.6 2005/07/03 07:02:01 daniels Exp $
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _DAMAGESTR_H_
+#define _DAMAGESTR_H_
+
+#include "damage.h"
+#ifdef RENDER
+# include "picturestr.h"
+#endif
+
+typedef struct _damage {
+ DamagePtr pNext;
+ DamagePtr pNextWin;
+ RegionRec damage;
+
+ DamageReportLevel damageLevel;
+ Bool isInternal;
+ void *closure;
+ Bool isWindow;
+ DrawablePtr pDrawable;
+
+ DamageReportFunc damageReport;
+ DamageDestroyFunc damageDestroy;
+} DamageRec;
+
+typedef struct _damageScrPriv {
+ int internalLevel;
+
+ /*
+ * For DDXen which don't provide GetScreenPixmap, this provides
+ * a place to hook damage for windows on the screen
+ */
+ DamagePtr pScreenDamage;
+
+ PaintWindowBackgroundProcPtr PaintWindowBackground;
+ PaintWindowBorderProcPtr PaintWindowBorder;
+ CopyWindowProcPtr CopyWindow;
+ CloseScreenProcPtr CloseScreen;
+ CreateGCProcPtr CreateGC;
+ DestroyPixmapProcPtr DestroyPixmap;
+ SetWindowPixmapProcPtr SetWindowPixmap;
+ DestroyWindowProcPtr DestroyWindow;
+#ifdef RENDER
+ CompositeProcPtr Composite;
+ GlyphsProcPtr Glyphs;
+#endif
+ BSFuncRec BackingStoreFuncs;
+} DamageScrPrivRec, *DamageScrPrivPtr;
+
+typedef struct _damageGCPriv {
+ GCOps *ops;
+ GCFuncs *funcs;
+} DamageGCPrivRec, *DamageGCPrivPtr;
+
+extern int damageScrPrivateIndex;
+extern int damagePixPrivateIndex;
+extern int damageGCPrivateIndex;
+extern int damageWinPrivateIndex;
+
+#define damageGetScrPriv(pScr) \
+ ((DamageScrPrivPtr) (pScr)->devPrivates[damageScrPrivateIndex].ptr)
+
+#define damageScrPriv(pScr) \
+ DamageScrPrivPtr pScrPriv = damageGetScrPriv(pScr)
+
+#define damageGetPixPriv(pPix) \
+ ((DamagePtr) (pPix)->devPrivates[damagePixPrivateIndex].ptr)
+
+#define damgeSetPixPriv(pPix,v) \
+ ((pPix)->devPrivates[damagePixPrivateIndex].ptr = (pointer ) (v))
+
+#define damagePixPriv(pPix) \
+ DamagePtr pDamage = damageGetPixPriv(pPix)
+
+#define damageGetGCPriv(pGC) \
+ ((DamageGCPrivPtr) (pGC)->devPrivates[damageGCPrivateIndex].ptr)
+
+#define damageGCPriv(pGC) \
+ DamageGCPrivPtr pGCPriv = damageGetGCPriv(pGC)
+
+#define damageGetWinPriv(pWin) \
+ ((DamagePtr) (pWin)->devPrivates[damageWinPrivateIndex].ptr)
+
+#define damageSetWinPriv(pWin,d) \
+ ((pWin)->devPrivates[damageWinPrivateIndex].ptr = (d))
+
+#endif /* _DAMAGESTR_H_ */
diff --git a/nx-X11/programs/Xserver/miext/layer/Imakefile b/nx-X11/programs/Xserver/miext/layer/Imakefile
new file mode 100644
index 000000000..32507d20a
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/layer/Imakefile
@@ -0,0 +1,49 @@
+XCOMM $XFree86: xc/programs/Xserver/miext/layer/Imakefile,v 1.1 2001/05/29 04:54:13 keithp Exp $
+XCOMM
+XCOMM
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#if (defined(XFree86Version) || defined(XorgVersion))
+#if DoLoadableServer
+XFMODSRC = laymodule.c
+XFMODOBJ = laymodule.o
+#endif
+#endif
+
+#if BuildRender
+RENDERSRC = layerpict.c
+RENDEROBJ = layerpict.o
+#endif
+
+SRCS = layergc.c \
+ layerinit.c \
+ $(RENDERSRC) \
+ layerwin.c \
+ $(XFMODSRC)
+
+OBJS = layergc.o \
+ layerinit.o \
+ $(RENDEROBJ) \
+ layerwin.o \
+ $(XFMODOBJ)
+
+ INCLUDES = -I. -I../shadow -I../../mi -I../../fb -I../../include -I$(XINCLUDESRC) \
+ -I$(FONTINCSRC) -I$(XF86SRC)/common $(EXTRAINCLUDES) \
+ -I../../render -I$(EXTINCSRC)
+ LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln \
+ ../../mi/llib-lmi.ln
+
+NormalLibraryObjectRule()
+LibraryModuleTarget(layer,$(OBJS))
+LintLibraryTarget(layer,$(SRCS))
+
+NormalLintTarget($(SRCS))
+
+InstallLibraryModule(layer,$(MODULEDIR),.)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(layer,$(DRIVERSDKMODULEDIR),.)
+InstallDriverSDKNonExecFile(layer.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/miext/layer/layer.h b/nx-X11/programs/Xserver/miext/layer/layer.h
new file mode 100644
index 000000000..e8f3a856e
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/layer/layer.h
@@ -0,0 +1,149 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/layer/layer.h,v 1.4 2001/08/01 00:44:58 tsi Exp $
+ *
+ * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _LAYER_H_
+#define _LAYER_H_
+
+#include <shadow.h>
+
+#define LAYER_FB 0
+#define LAYER_SHADOW 1
+
+typedef struct _LayerKind *LayerKindPtr;
+typedef struct _LayerWin *LayerWinPtr;
+typedef struct _LayerList *LayerListPtr;
+typedef struct _LayerGC *LayerGCPtr;
+typedef struct _Layer *LayerPtr;
+typedef struct _LayerScreen *LayerScreenPtr;
+
+/*
+ * We'll try to work without a list of windows in each layer
+ * for now, this will make computing bounding boxes for each
+ * layer rather expensive, so that may need to change at some point.
+ */
+
+#define LAYER_SCREEN_PIXMAP ((PixmapPtr) 1)
+
+typedef struct _Layer {
+ LayerPtr pNext; /* a list of all layers for this screen */
+ LayerKindPtr pKind; /* characteristics of this layer */
+ int refcnt; /* reference count, layer is freed when zero */
+ int windows; /* number of windows, free pixmap when zero */
+ int depth; /* window depth in this layer */
+ PixmapPtr pPixmap; /* pixmap for this layer (may be frame buffer) */
+ Bool freePixmap; /* whether to free this pixmap when done */
+ RegionRec region; /* valid set of pPixmap for drawing */
+ ShadowUpdateProc update; /* for shadow layers, update/window/closure values */
+ ShadowWindowProc window;
+ int randr;
+ void *closure;
+} LayerRec;
+
+/*
+ * Call this before wrapping stuff for acceleration, it
+ * gives layer pointers to the raw frame buffer functions
+ */
+
+Bool
+LayerStartInit (ScreenPtr pScreen);
+
+/*
+ * Initialize wrappers for each acceleration type and
+ * call this function, it will move the needed functions
+ * into a new LayerKind and replace them with the generic
+ * functions.
+ */
+
+int
+LayerNewKind (ScreenPtr pScreen);
+
+/*
+ * Finally, call this function and layer
+ * will wrap the screen functions and prepare for execution
+ */
+
+Bool
+LayerFinishInit (ScreenPtr pScreen);
+
+/*
+ * At any point after LayerStartInit, a new layer can be created.
+ */
+LayerPtr
+LayerCreate (ScreenPtr pScreen,
+ int kind,
+ int depth,
+ PixmapPtr pPixmap,
+ ShadowUpdateProc update,
+ ShadowWindowProc window,
+ int randr,
+ void *closure);
+
+/*
+ * Create a layer pixmap
+ */
+Bool
+LayerCreatePixmap (ScreenPtr pScreen, LayerPtr pLayer);
+
+/*
+ * Change a layer pixmap
+ */
+void
+LayerSetPixmap (ScreenPtr pScreen, LayerPtr pLayer, PixmapPtr pPixmap);
+
+/*
+ * Destroy a layer pixmap
+ */
+void
+LayerDestroyPixmap (ScreenPtr pScreen, LayerPtr pLayer);
+
+/*
+ * Change a layer kind
+ */
+void
+LayerSetKind (ScreenPtr pScreen, LayerPtr pLayer, int kind);
+
+/*
+ * Destroy a layer. The layer must not contain any windows.
+ */
+void
+LayerDestroy (ScreenPtr pScreen, LayerPtr layer);
+
+/*
+ * Add a window to a layer
+ */
+Bool
+LayerWindowAdd (ScreenPtr pScreen, LayerPtr pLayer, WindowPtr pWin);
+
+/*
+ * Remove a window from a layer
+ */
+
+void
+LayerWindowRemove (ScreenPtr pScreen, LayerPtr pLayer, WindowPtr pWin);
+
+#endif /* _LAYER_H_ */
diff --git a/nx-X11/programs/Xserver/miext/layer/layergc.c b/nx-X11/programs/Xserver/miext/layer/layergc.c
new file mode 100644
index 000000000..343edfcf5
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/layer/layergc.c
@@ -0,0 +1,194 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/layer/layergc.c,v 1.4 2001/08/27 03:55:46 keithp Exp $
+ *
+ * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "layerstr.h"
+
+GCFuncs layerGCFuncs = {
+ layerValidateGC, layerChangeGC, layerCopyGC, layerDestroyGC,
+ layerChangeClip, layerDestroyClip, layerCopyClip
+};
+
+#if 0
+/*
+ * XXX dont need this until this supports
+ * separate clipping and multiple layers
+ */
+GCOps layerGCOps = {
+ layerFillSpans, layerSetSpans,
+ layerPutImage, layerCopyArea,
+ layerCopyPlane, layerPolyPoint,
+ layerPolylines, layerPolySegment,
+ layerPolyRectangle, layerPolyArc,
+ layerFillPolygon, layerPolyFillRect,
+ layerPolyFillArc, layerPolyText8,
+ layerPolyText16, layerImageText8,
+ layerImageText16, layerImageGlyphBlt,
+ layerPolyGlyphBlt, layerPushPixels,
+#ifdef NEED_LINEHELPER
+ NULL,
+#endif
+ {NULL} /* devPrivate */
+};
+#endif
+
+Bool
+layerCreateGC (GCPtr pGC)
+{
+ Bool ret = TRUE;
+ LayerKindPtr pLayKind;
+ ScreenPtr pScreen = pGC->pScreen;
+ layerScrPriv(pScreen);
+ layerGCPriv(pGC);
+
+ /*
+ * XXX assume the first layer can handle all GCs
+ */
+ pLayKind = &pLayScr->kinds[0];
+ if (pLayScr->pLayers)
+ pLayKind = pLayScr->pLayers->pKind;
+ pLayGC->pKind = pLayKind;
+ LayerUnwrap (pScreen,pLayGC->pKind,CreateGC);
+
+ if (!(*pScreen->CreateGC) (pGC))
+ ret = FALSE;
+ LayerWrap (pScreen,pLayKind,CreateGC,layerCreateGC);
+
+ LayerWrap (pGC,pLayGC,funcs,&layerGCFuncs);
+
+ return ret;
+}
+
+void
+layerValidateGC(GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDraw)
+{
+ layerGCPriv(pGC);
+ LayerKindPtr pKind;
+
+ if (pDraw->type == DRAWABLE_WINDOW)
+ {
+ layerWinPriv ((WindowPtr) pDraw);
+ pKind = layerWinLayer (pLayWin)->pKind;
+ }
+ else
+ {
+ /* XXX assume the first layer can handle all pixmaps */
+ layerScrPriv (pDraw->pScreen);
+ pKind = &pLayScr->kinds[0];
+ if (pLayScr->pLayers)
+ pKind = pLayScr->pLayers->pKind;
+ }
+
+ LayerUnwrap (pGC,pLayGC,funcs);
+ if (pKind != pLayGC->pKind)
+ {
+ /*
+ * Clean up the previous user
+ */
+ CreateGCProcPtr CreateGC;
+ (*pGC->funcs->DestroyGC) (pGC);
+
+ pGC->serialNumber = GC_CHANGE_SERIAL_BIT;
+
+ pLayGC->pKind = pKind;
+
+ /*
+ * Temporarily unwrap Create GC and let
+ * the new code setup the GC
+ */
+ CreateGC = pGC->pScreen->CreateGC;
+ LayerUnwrap (pGC->pScreen, pLayGC->pKind, CreateGC);
+ (*pGC->pScreen->CreateGC) (pGC);
+ LayerWrap (pGC->pScreen, pLayGC->pKind, CreateGC, CreateGC);
+ }
+
+ (*pGC->funcs->ValidateGC) (pGC, changes, pDraw);
+ LayerWrap(pGC,pLayGC,funcs,&layerGCFuncs);
+}
+
+void
+layerDestroyGC(GCPtr pGC)
+{
+ layerGCPriv(pGC);
+ LayerUnwrap (pGC,pLayGC,funcs);
+ (*pGC->funcs->DestroyGC)(pGC);
+ LayerWrap(pGC,pLayGC,funcs,&layerGCFuncs);
+}
+
+void
+layerChangeGC (GCPtr pGC,
+ unsigned long mask)
+{
+ layerGCPriv(pGC);
+ LayerUnwrap (pGC,pLayGC,funcs);
+ (*pGC->funcs->ChangeGC) (pGC, mask);
+ LayerWrap(pGC,pLayGC,funcs,&layerGCFuncs);
+}
+
+void
+layerCopyGC (GCPtr pGCSrc,
+ unsigned long mask,
+ GCPtr pGCDst)
+{
+ layerGCPriv(pGCDst);
+ LayerUnwrap (pGCDst,pLayGC,funcs);
+ (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
+ LayerWrap(pGCDst,pLayGC,funcs,&layerGCFuncs);
+}
+
+void
+layerChangeClip (GCPtr pGC,
+ int type,
+ pointer pvalue,
+ int nrects)
+{
+ layerGCPriv(pGC);
+ LayerUnwrap (pGC,pLayGC,funcs);
+ (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
+ LayerWrap(pGC,pLayGC,funcs,&layerGCFuncs);
+}
+
+void
+layerCopyClip(GCPtr pGCDst, GCPtr pGCSrc)
+{
+ layerGCPriv(pGCDst);
+ LayerUnwrap (pGCDst,pLayGC,funcs);
+ (*pGCDst->funcs->CopyClip) (pGCDst, pGCSrc);
+ LayerWrap(pGCDst,pLayGC,funcs,&layerGCFuncs);
+}
+
+void
+layerDestroyClip(GCPtr pGC)
+{
+ layerGCPriv(pGC);
+ LayerUnwrap (pGC,pLayGC,funcs);
+ (*pGC->funcs->DestroyClip) (pGC);
+ LayerWrap(pGC,pLayGC,funcs,&layerGCFuncs);
+}
+
diff --git a/nx-X11/programs/Xserver/miext/layer/layerinit.c b/nx-X11/programs/Xserver/miext/layer/layerinit.c
new file mode 100644
index 000000000..994c6747c
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/layer/layerinit.c
@@ -0,0 +1,363 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/layer/layerinit.c,v 1.6tsi Exp $
+ *
+ * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "layerstr.h"
+
+int layerScrPrivateIndex;
+int layerGCPrivateIndex;
+int layerWinPrivateIndex;
+int layerGeneration;
+
+/*
+ * Call this before wrapping stuff for acceleration, it
+ * gives layer pointers to the raw frame buffer functions
+ */
+
+extern const GCFuncs fbGCFuncs;
+extern GCFuncs shadowGCFuncs;
+
+Bool
+LayerStartInit (ScreenPtr pScreen)
+{
+ LayerScreenPtr pScrPriv;
+
+ if (layerGeneration != serverGeneration)
+ {
+ layerScrPrivateIndex = AllocateScreenPrivateIndex ();
+ if (layerScrPrivateIndex == -1)
+ return FALSE;
+ layerGCPrivateIndex = AllocateGCPrivateIndex ();
+ if (layerGCPrivateIndex == -1)
+ return FALSE;
+ layerWinPrivateIndex = AllocateWindowPrivateIndex ();
+ if (layerWinPrivateIndex == -1)
+ return FALSE;
+ layerGeneration = serverGeneration;
+ }
+ if (!AllocateGCPrivate (pScreen, layerGCPrivateIndex, sizeof (LayerGCRec)))
+ return FALSE;
+ if (!AllocateWindowPrivate (pScreen, layerWinPrivateIndex, sizeof (LayerWinRec)))
+ return FALSE;
+ pScrPriv = (LayerScreenPtr) xalloc (sizeof (LayerScreenRec));
+ if (!pScrPriv)
+ return FALSE;
+ pScrPriv->nkinds = 0;
+ pScrPriv->kinds = 0;
+ pScrPriv->pLayers = 0;
+ pScreen->devPrivates[layerScrPrivateIndex].ptr = (pointer) pScrPriv;
+ /*
+ * Add fb kind -- always 0
+ */
+ if (LayerNewKind (pScreen) < 0)
+ {
+ pScreen->devPrivates[layerScrPrivateIndex].ptr = 0;
+ xfree (pScrPriv);
+ return FALSE;
+ }
+ /*
+ * Add shadow kind -- always 1
+ */
+ if (!shadowSetup (pScreen))
+ return FALSE;
+ if (LayerNewKind (pScreen) < 0)
+ {
+ pScreen->devPrivates[layerScrPrivateIndex].ptr = 0;
+ xfree (pScrPriv->kinds);
+ xfree (pScrPriv);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/*
+ * Initialize wrappers for each acceleration type and
+ * call this function, it will move the needed functions
+ * into a new LayerKind and replace them with the generic
+ * functions.
+ */
+
+int
+LayerNewKind (ScreenPtr pScreen)
+{
+ layerScrPriv(pScreen);
+ LayerKindPtr pLayKind, pLayKinds;
+#ifdef RENDER
+ PictureScreenPtr ps = GetPictureScreen (pScreen);
+#endif
+ LayerPtr pLayer;
+
+ /*
+ * Allocate a new kind structure
+ */
+ if (pLayScr->kinds)
+ pLayKinds = (LayerKindPtr) xrealloc ((pointer) pLayScr->kinds,
+ (pLayScr->nkinds + 1) * sizeof (LayerKindRec));
+ else
+ pLayKinds = (LayerKindPtr) xalloc (sizeof (LayerKindRec));
+ if (!pLayKinds)
+ return -1;
+
+ /*
+ * Fix up existing layers to point at the new kind
+ */
+ for (pLayer = pLayScr->pLayers; pLayer; pLayer = pLayer->pNext)
+ {
+ int kind = pLayer->pKind - pLayScr->kinds;
+
+ pLayer->pKind = &pLayKinds[kind];
+ }
+
+ pLayScr->kinds = pLayKinds;
+ pLayKind = &pLayScr->kinds[pLayScr->nkinds];
+ pLayKind->kind = pLayScr->nkinds;
+
+ /*
+ * Extract wrapped functions from screen and stick in kind
+ */
+ pLayKind->CloseScreen = pScreen->CloseScreen;
+
+ pLayKind->CreateWindow = pScreen->CreateWindow;
+ pLayKind->DestroyWindow = pScreen->DestroyWindow;
+ pLayKind->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
+ pLayKind->PaintWindowBackground = pScreen->PaintWindowBackground;
+ pLayKind->PaintWindowBorder = pScreen->PaintWindowBorder;
+ pLayKind->CopyWindow = pScreen->CopyWindow;
+
+ pLayKind->CreatePixmap = pScreen->CreatePixmap;
+ pLayKind->DestroyPixmap = pScreen->DestroyPixmap;
+
+ pLayKind->CreateGC = pScreen->CreateGC;
+
+#ifdef RENDER
+ if (ps)
+ {
+ pLayKind->Composite = ps->Composite;
+ pLayKind->Glyphs = ps->Glyphs;
+ pLayKind->CompositeRects = ps->CompositeRects;
+ }
+#endif
+ /*
+ * If not underlying frame buffer kind,
+ * replace screen functions with those
+ */
+ if (pLayKind->kind != 0)
+ {
+ pScreen->CloseScreen = pLayKinds->CloseScreen;
+
+ pScreen->CreateWindow = pLayKinds->CreateWindow;
+ pScreen->DestroyWindow = pLayKinds->DestroyWindow;
+ pScreen->ChangeWindowAttributes = pLayKinds->ChangeWindowAttributes;
+ pScreen->PaintWindowBackground = pLayKinds->PaintWindowBackground;
+ pScreen->PaintWindowBorder = pLayKinds->PaintWindowBorder;
+ pScreen->CopyWindow = pLayKinds->CopyWindow;
+
+ pScreen->CreatePixmap = pLayKinds->CreatePixmap;
+ pScreen->DestroyPixmap = pLayKinds->DestroyPixmap;
+
+ pScreen->CreateGC = pLayKinds->CreateGC;
+
+#ifdef RENDER
+ if (ps)
+ {
+ ps->Composite = pLayKinds->Composite;
+ ps->Glyphs = pLayKinds->Glyphs;
+ ps->CompositeRects = pLayKinds->CompositeRects;
+ }
+#endif
+ }
+
+ pLayScr->nkinds++;
+ return pLayKind->kind;
+}
+
+/*
+ * Finally, call this function and layer
+ * will wrap the screen functions and prepare for execution
+ */
+
+Bool
+LayerFinishInit (ScreenPtr pScreen)
+{
+#ifdef RENDER
+ PictureScreenPtr ps = GetPictureScreen (pScreen);
+#endif
+
+ pScreen->CloseScreen = layerCloseScreen;
+
+ pScreen->CreateWindow = layerCreateWindow;
+ pScreen->DestroyWindow = layerDestroyWindow;
+ pScreen->ChangeWindowAttributes = layerChangeWindowAttributes;
+ pScreen->PaintWindowBackground = layerPaintWindowBackground;
+ pScreen->PaintWindowBorder = layerPaintWindowBorder;
+ pScreen->CopyWindow = layerCopyWindow;
+
+ pScreen->CreatePixmap = layerCreatePixmap;
+ pScreen->DestroyPixmap = layerDestroyPixmap;
+
+ pScreen->CreateGC = layerCreateGC;
+
+#ifdef RENDER
+ if (ps)
+ {
+ ps->Composite = layerComposite;
+ ps->Glyphs = layerGlyphs;
+ ps->CompositeRects = layerCompositeRects;
+ }
+#endif
+
+ return TRUE;
+}
+
+/*
+ * At any point after LayerStartInit, a new layer can be created.
+ */
+LayerPtr
+LayerCreate (ScreenPtr pScreen,
+ int kind,
+ int depth,
+ PixmapPtr pPixmap,
+ ShadowUpdateProc update,
+ ShadowWindowProc window,
+ int randr,
+ void *closure)
+{
+ layerScrPriv(pScreen);
+ LayerPtr pLay, *pPrev;
+ LayerKindPtr pLayKind;
+
+ if (kind < 0 || pLayScr->nkinds <= kind)
+ return 0;
+ pLayKind = &pLayScr->kinds[kind];
+ pLay = (LayerPtr) xalloc (sizeof (LayerRec));
+ if (!pLay)
+ return 0;
+ /*
+ * Initialize the layer
+ */
+ pLay->pNext = 0;
+ pLay->pKind = pLayKind;
+ pLay->refcnt = 1;
+ pLay->windows = 0;
+ pLay->depth = depth;
+ pLay->pPixmap = pPixmap;
+ pLay->update = update;
+ pLay->window = window;
+ pLay->randr = randr;
+ pLay->closure = closure;
+ if (pPixmap == LAYER_SCREEN_PIXMAP)
+ pLay->freePixmap = FALSE;
+ else
+ {
+ pLay->freePixmap = TRUE;
+ if (pPixmap)
+ pPixmap->refcnt++;
+ }
+ REGION_NULL(pScreen, &pLay->region);
+ /*
+ * Hook the layer at the end of the list
+ */
+ for (pPrev = &pLayScr->pLayers; *pPrev; pPrev = &(*pPrev)->pNext)
+ ;
+ *pPrev = pLay;
+ return pLay;
+}
+
+/*
+ * Change a layer pixmap
+ */
+void
+LayerSetPixmap (ScreenPtr pScreen, LayerPtr pLayer, PixmapPtr pPixmap)
+{
+ LayerDestroyPixmap (pScreen, pLayer);
+ pLayer->pPixmap = pPixmap;
+ if (pPixmap == LAYER_SCREEN_PIXMAP)
+ pLayer->freePixmap = FALSE;
+ else
+ {
+ if (pPixmap)
+ pPixmap->refcnt++;
+ pLayer->freePixmap = TRUE;
+ }
+}
+
+/*
+ * Destroy a layer. The layer must not contain any windows.
+ */
+void
+LayerDestroy (ScreenPtr pScreen, LayerPtr pLay)
+{
+ layerScrPriv(pScreen);
+ LayerPtr *pPrev;
+
+ --pLay->refcnt;
+ if (pLay->refcnt > 0)
+ return;
+ /*
+ * Unhook the layer from the list
+ */
+ for (pPrev = &pLayScr->pLayers; *pPrev; pPrev = &(*pPrev)->pNext)
+ if (*pPrev == pLay)
+ {
+ *pPrev = pLay->pNext;
+ break;
+ }
+ /*
+ * Free associated storage
+ */
+ LayerDestroyPixmap (pScreen, pLay);
+ REGION_UNINIT (pScreen, &pLay->region);
+ xfree (pLay);
+}
+
+/*
+ * CloseScreen wrapper
+ */
+Bool
+layerCloseScreen (int index, ScreenPtr pScreen)
+{
+ layerScrPriv(pScreen);
+ int kind;
+
+ /* XXX this is a mess -- fbCloseScreen can only be called once,
+ * and yet the intervening layers need to be called as well.
+ */
+ kind = pLayScr->nkinds - 1;
+ pScreen->CloseScreen = pLayScr->kinds[kind].CloseScreen;
+ (*pScreen->CloseScreen) (index, pScreen);
+
+ /*
+ * make sure the shadow layer is cleaned up as well
+ */
+ if (kind != LAYER_SHADOW)
+ xfree (shadowGetScrPriv (pScreen));
+
+ xfree (pLayScr->kinds);
+ xfree (pLayScr);
+ pScreen->devPrivates[layerScrPrivateIndex].ptr = 0;
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/miext/layer/layerpict.c b/nx-X11/programs/Xserver/miext/layer/layerpict.c
new file mode 100644
index 000000000..16e46f0ab
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/layer/layerpict.c
@@ -0,0 +1,149 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "layerstr.h"
+
+void
+layerComposite (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ LayerPtr pLayer;
+ LayerWinLoopRec loop;
+ DrawablePtr pDstDrawable = pDst->pDrawable;
+ ScreenPtr pScreen = pDstDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen (pScreen);
+
+ if (pDstDrawable->type == DRAWABLE_WINDOW)
+ {
+ WindowPtr pWin = (WindowPtr) pDstDrawable;
+ for (pLayer = LayerWindowFirst (pWin, &loop);
+ pLayer;
+ pLayer = LayerWindowNext (pWin, &loop))
+ {
+ LayerUnwrap (ps, pLayer->pKind, Composite);
+ (*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc,
+ xMask, yMask, xDst, yDst, width, height);
+ LayerWrap (ps, pLayer->pKind, Composite, layerComposite);
+ }
+ LayerWindowDone (pWin, &loop);
+ }
+ else
+ {
+ layerScrPriv (pScreen);
+ LayerUnwrap (ps, &pLayScr->kinds[LAYER_FB], Composite);
+ (*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc,
+ xMask, yMask, xDst, yDst, width, height);
+ LayerWrap (ps, &pLayScr->kinds[LAYER_FB], Composite, layerComposite);
+ }
+}
+
+void
+layerGlyphs (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlist,
+ GlyphListPtr list,
+ GlyphPtr *glyphs)
+{
+ LayerPtr pLayer;
+ LayerWinLoopRec loop;
+ DrawablePtr pDstDrawable = pDst->pDrawable;
+ ScreenPtr pScreen = pDstDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen (pScreen);
+
+ if (pDstDrawable->type == DRAWABLE_WINDOW)
+ {
+ WindowPtr pWin = (WindowPtr) pDstDrawable;
+ for (pLayer = LayerWindowFirst (pWin, &loop);
+ pLayer;
+ pLayer = LayerWindowNext (pWin, &loop))
+ {
+ LayerUnwrap (ps, pLayer->pKind, Glyphs);
+ (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc,
+ nlist, list, glyphs);
+ LayerWrap (ps, pLayer->pKind, Glyphs, layerGlyphs);
+ }
+ LayerWindowDone (pWin, &loop);
+ }
+ else
+ {
+ layerScrPriv (pScreen);
+ LayerUnwrap (ps, &pLayScr->kinds[LAYER_FB], Glyphs);
+ (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc,
+ nlist, list, glyphs);
+ LayerWrap (ps, &pLayScr->kinds[LAYER_FB], Glyphs, layerGlyphs);
+ }
+}
+
+void
+layerCompositeRects (CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects)
+{
+ LayerPtr pLayer;
+ LayerWinLoopRec loop;
+ DrawablePtr pDstDrawable = pDst->pDrawable;
+ ScreenPtr pScreen = pDstDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen (pScreen);
+
+ if (pDstDrawable->type == DRAWABLE_WINDOW)
+ {
+ WindowPtr pWin = (WindowPtr) pDstDrawable;
+ for (pLayer = LayerWindowFirst (pWin, &loop);
+ pLayer;
+ pLayer = LayerWindowNext (pWin, &loop))
+ {
+ LayerUnwrap (ps, pLayer->pKind, CompositeRects);
+ (*ps->CompositeRects) (op, pDst, color, nRect, rects);
+ LayerWrap (ps, pLayer->pKind, CompositeRects, layerCompositeRects);
+ }
+ LayerWindowDone (pWin, &loop);
+ }
+ else
+ {
+ layerScrPriv (pScreen);
+ LayerUnwrap (ps, &pLayScr->kinds[LAYER_FB], CompositeRects);
+ (*ps->CompositeRects) (op, pDst, color, nRect, rects);
+ LayerWrap (ps, &pLayScr->kinds[LAYER_FB], CompositeRects, layerCompositeRects);
+ }
+}
diff --git a/nx-X11/programs/Xserver/miext/layer/layerstr.h b/nx-X11/programs/Xserver/miext/layer/layerstr.h
new file mode 100644
index 000000000..fb5a0d411
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/layer/layerstr.h
@@ -0,0 +1,425 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/layer/layerstr.h,v 1.2 2001/06/04 09:45:41 keithp Exp $
+ *
+ * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _LAYERSTR_H_
+#define _LAYERSTR_H_
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "layer.h"
+#ifdef RENDER
+#include "picturestr.h"
+#endif
+
+extern int layerScrPrivateIndex;
+extern int layerGCPrivateIndex;
+extern int layerWinPrivateIndex;
+
+/*
+ * One of these for each possible set of underlying
+ * rendering code. The first kind always points at the
+ * underlying frame buffer code and is created in LayerStartInit
+ * so that LayerNewKind can unwrap the screen and prepare it
+ * for another wrapping sequence.
+ *
+ * The set of functions wrapped here must be at least the union
+ * of all functions wrapped by any rendering layer in use; they're
+ * easy to add, so don't be shy
+ */
+
+typedef struct _LayerKind {
+ int kind; /* kind index */
+
+ CloseScreenProcPtr CloseScreen;
+
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+ PaintWindowBackgroundProcPtr PaintWindowBackground;
+ PaintWindowBorderProcPtr PaintWindowBorder;
+ CopyWindowProcPtr CopyWindow;
+
+ CreatePixmapProcPtr CreatePixmap;
+ DestroyPixmapProcPtr DestroyPixmap;
+
+ CreateGCProcPtr CreateGC;
+#ifdef RENDER
+ CompositeProcPtr Composite;
+ GlyphsProcPtr Glyphs;
+ CompositeRectsProcPtr CompositeRects;
+#endif
+} LayerKindRec;
+
+#define LayerWrap(orig,lay,member,func) \
+ (((lay)->member = (orig)->member),\
+ ((orig)->member = (func)))
+#define LayerUnwrap(orig,lay,member) \
+ ((orig)->member = (lay)->member)
+
+/*
+ * This is the window private structure allocated for
+ * all windows. There are two possible alternatives here,
+ * either the window belongs to a single layer and uses its
+ * internal clip/borderClip lists or the window belongs to one
+ * or more layers and uses a separate clip/borderclip for each
+ * layer. When this is integrated into the core window struct,
+ * the LayerWinKind can become a single bit saving 8 bytes per
+ * window.
+ */
+
+typedef struct _LayerWin {
+ Bool isList;
+ union {
+ LayerPtr pLayer;
+ LayerListPtr pLayList;
+ } u;
+} LayerWinRec;
+
+typedef struct _LayerList {
+ LayerListPtr pNext; /* list of layers for this window */
+ LayerPtr pLayer; /* the layer */
+ Bool inheritClip; /* use the window clipList/borderClip */
+ RegionRec clipList; /* per-layer clip/border clip lists */
+ RegionRec borderClip;
+} LayerListRec;
+
+#define layerGetWinPriv(pWin) ((LayerWinPtr) (pWin)->devPrivates[layerWinPrivateIndex].ptr)
+#define layerWinPriv(pWin) LayerWinPtr pLayWin = layerGetWinPriv(pWin)
+
+#define layerWinLayer(pLayWin) ((pLayWin)->isList ? (pLayWin)->u.pLayList->pLayer : (pLayWin)->u.pLayer)
+
+typedef struct _LayerWinLoop {
+ LayerWinPtr pLayWin;
+ LayerListPtr pLayList;
+ PixmapPtr pPixmap; /* original window pixmap */
+ RegionRec clipList; /* saved original clipList contents */
+ RegionRec borderClip; /* saved original borderClip contents */
+} LayerWinLoopRec, *LayerWinLoopPtr;
+
+#define layerWinFirstLayer(pLayWin,pLayList) ((pLayWin)->isList ? ((pLayList) = (pLayWin)->u.pLayList)->pLayer : pLayWin->u.pLayer)
+#define layerWinNextLayer(pLayWin,pLayList) ((pLayWin)->isList ? ((pLayList) = (pLayList)->pNext)->pLayer : 0)
+
+LayerPtr
+LayerWindowFirst (WindowPtr pWin, LayerWinLoopPtr pLoop);
+
+LayerPtr
+LayerWindowNext (WindowPtr pWin, LayerWinLoopPtr pLoop);
+
+void
+LayerWindowDone (WindowPtr pWin, LayerWinLoopPtr pLoop);
+
+
+/*
+ * This is the GC private structure allocated for all GCs.
+ * XXX this is really messed up; I'm not sure how to fix it yet
+ */
+
+typedef struct _LayerGC {
+ GCFuncs *funcs;
+ LayerKindPtr pKind;
+} LayerGCRec;
+
+#define layerGetGCPriv(pGC) ((LayerGCPtr) (pGC)->devPrivates[layerGCPrivateIndex].ptr)
+#define layerGCPriv(pGC) LayerGCPtr pLayGC = layerGetGCPriv(pGC)
+
+/*
+ * This is the screen private, it contains
+ * the layer kinds and the layers themselves
+ */
+typedef struct _LayerScreen {
+ int nkinds; /* number of elements in kinds array */
+ LayerKindPtr kinds; /* created kinds; reallocated when new ones added */
+ LayerPtr pLayers; /* list of layers for this screen */
+} LayerScreenRec;
+
+#define layerGetScrPriv(pScreen) ((LayerScreenPtr) (pScreen)->devPrivates[layerScrPrivateIndex].ptr)
+#define layerScrPriv(pScreen) LayerScreenPtr pLayScr = layerGetScrPriv(pScreen)
+
+Bool
+layerCloseScreen (int index, ScreenPtr pScreen);
+
+Bool
+layerCreateWindow (WindowPtr pWin);
+
+Bool
+layerDestroyWindow (WindowPtr pWin);
+
+Bool
+layerChangeWindowAttributes (WindowPtr pWin, unsigned long mask);
+
+void
+layerPaintWindowBackground (WindowPtr pWin, RegionPtr pRegion, int what);
+
+void
+layerPaintWindowBorder (WindowPtr pWin, RegionPtr pRegion, int what);
+
+void
+layerCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
+
+PixmapPtr
+layerCreatePixmap (ScreenPtr pScreen, int width, int height, int depth);
+
+Bool
+layerDestroyPixmap (PixmapPtr pPixmap);
+
+Bool
+layerCreateGC (GCPtr pGC);
+
+#ifdef RENDER
+void
+layerComposite (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+void
+layerGlyphs (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlist,
+ GlyphListPtr list,
+ GlyphPtr *glyphs);
+
+void
+layerCompositeRects (CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects);
+#endif
+void layerValidateGC(GCPtr, unsigned long, DrawablePtr);
+void layerChangeGC(GCPtr, unsigned long);
+void layerCopyGC(GCPtr, unsigned long, GCPtr);
+void layerDestroyGC(GCPtr);
+void layerChangeClip(GCPtr, int, pointer, int);
+void layerDestroyClip(GCPtr);
+void layerCopyClip(GCPtr, GCPtr);
+
+void
+layerFillSpans(DrawablePtr pDraw,
+ GC *pGC,
+ int nInit,
+ DDXPointPtr pptInit,
+ int *pwidthInit,
+ int fSorted);
+
+void
+layerSetSpans(DrawablePtr pDraw,
+ GCPtr pGC,
+ char *pcharsrc,
+ DDXPointPtr pptInit,
+ int *pwidthInit,
+ int nspans,
+ int fSorted);
+
+void
+layerPutImage(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int depth,
+ int x, int y, int w, int h,
+ int leftPad,
+ int format,
+ char *pImage
+);
+
+RegionPtr
+layerCopyArea(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC *pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty
+);
+
+RegionPtr
+layerCopyPlane(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty,
+ unsigned long bitPlane
+);
+
+void
+layerPolyPoint(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ xPoint *pptInit
+);
+void
+layerPolylines(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr pptInit
+);
+
+void
+layerPolySegment(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSeg
+);
+
+void
+layerPolyRectangle(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nRects,
+ xRectangle *pRects
+);
+
+void
+layerPolyArc(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int narcs,
+ xArc *parcs
+);
+
+void
+layerFillPolygon(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int count,
+ DDXPointPtr pptInit
+);
+
+void
+layerPolyFillRect(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nRectsInit,
+ xRectangle *pRectsInit
+);
+
+void
+layerPolyFillArc(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int narcs,
+ xArc *parcs
+);
+
+int
+layerPolyText8(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *chars
+);
+
+int
+layerPolyText16(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *chars
+);
+
+void
+layerImageText8(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *chars
+);
+
+void
+layerImageText16(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *chars
+);
+
+void
+layerImageGlyphBlt(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase
+);
+
+void
+layerPolyGlyphBlt(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase
+);
+
+void
+layerPushPixels(
+ GCPtr pGC,
+ PixmapPtr pBitMap,
+ DrawablePtr pDraw,
+ int dx, int dy, int xOrg, int yOrg
+);
+
+#endif /* _LAYERSTR_H_ */
diff --git a/nx-X11/programs/Xserver/miext/layer/layerwin.c b/nx-X11/programs/Xserver/miext/layer/layerwin.c
new file mode 100644
index 000000000..7afe90ade
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/layer/layerwin.c
@@ -0,0 +1,487 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/layer/layerwin.c,v 1.7tsi Exp $
+ *
+ * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "layerstr.h"
+
+static LayerListPtr
+NewLayerList (ScreenPtr pScreen, LayerPtr pLayer)
+{
+ LayerListPtr pLayList;
+
+ pLayList = (LayerListPtr) xalloc (sizeof (LayerListRec));
+ if (!pLayList)
+ return 0;
+ pLayList->pNext = 0;
+ pLayList->pLayer = pLayer;
+ pLayList->inheritClip = TRUE;
+ REGION_NULL (pScreen, &pLayList->clipList);
+ REGION_NULL (pScreen, &pLayList->borderClip);
+ return pLayList;
+}
+
+static void
+FreeLayerList (ScreenPtr pScreen, LayerListPtr pLayList)
+{
+ REGION_UNINIT (pScreen, &pLayList->clipList);
+ REGION_UNINIT (pScreen, &pLayList->borderClip);
+ xfree (pLayList);
+}
+
+/*
+ * Create pixmap for a layer
+ */
+
+Bool
+LayerCreatePixmap (ScreenPtr pScreen, LayerPtr pLayer)
+{
+ LayerKindPtr pKind = pLayer->pKind;
+
+ LayerUnwrap (pScreen, pKind, CreatePixmap);
+ /* XXX create full-screen sized layers all around */
+ pLayer->pPixmap = (*pScreen->CreatePixmap) (pScreen, pScreen->width,
+ pScreen->height, pLayer->depth);
+ LayerWrap (pScreen, pKind, CreatePixmap, layerCreatePixmap);
+ if (!pLayer->pPixmap)
+ return FALSE;
+ if (pLayer->pKind->kind == LAYER_SHADOW)
+ {
+ if (!shadowAdd (pScreen, pLayer->pPixmap, pLayer->update,
+ pLayer->window, pLayer->randr,
+ pLayer->closure))
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/*
+ * Destroy pixmap for a layer
+ */
+
+void
+LayerDestroyPixmap (ScreenPtr pScreen, LayerPtr pLayer)
+{
+ if (pLayer->pPixmap)
+ {
+ if (pLayer->pKind->kind == LAYER_SHADOW)
+ shadowRemove (pScreen, pLayer->pPixmap);
+ if (pLayer->freePixmap)
+ {
+ LayerKindPtr pKind = pLayer->pKind;
+
+ LayerUnwrap (pScreen, pKind, DestroyPixmap);
+ (*pScreen->DestroyPixmap) (pLayer->pPixmap);
+ LayerWrap (pScreen, pKind, DestroyPixmap, layerDestroyPixmap);
+ }
+ pLayer->pPixmap = 0;
+ }
+}
+
+/*
+ * Add a window to a layer
+ */
+Bool
+LayerWindowAdd (ScreenPtr pScreen, LayerPtr pLayer, WindowPtr pWin)
+{
+ layerWinPriv(pWin);
+
+ if (pLayer->pPixmap == LAYER_SCREEN_PIXMAP)
+ pLayer->pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
+ else if (!pLayer->pPixmap && !LayerCreatePixmap (pScreen, pLayer))
+ return FALSE;
+ /*
+ * Add a new layer list if needed
+ */
+ if (pLayWin->isList || pLayWin->u.pLayer)
+ {
+ LayerListPtr pPrev;
+ LayerListPtr pLayList;
+
+ if (!pLayWin->isList)
+ {
+ pPrev = NewLayerList (pScreen, pLayWin->u.pLayer);
+ if (!pPrev)
+ return FALSE;
+ }
+ else
+ {
+ for (pPrev = pLayWin->u.pLayList; pPrev->pNext; pPrev = pPrev->pNext)
+ ;
+ }
+ pLayList = NewLayerList (pScreen, pLayer);
+ if (!pLayList)
+ {
+ if (!pLayWin->isList)
+ FreeLayerList (pScreen, pPrev);
+ return FALSE;
+ }
+ pPrev->pNext = pLayList;
+ if (!pLayWin->isList)
+ {
+ pLayWin->isList = TRUE;
+ pLayWin->u.pLayList = pPrev;
+ }
+ }
+ else
+ pLayWin->u.pLayer = pLayer;
+ /*
+ * XXX only one layer supported for drawing, last one wins
+ */
+ (*pScreen->SetWindowPixmap) (pWin, pLayer->pPixmap);
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pLayer->refcnt++;
+ pLayer->windows++;
+ return TRUE;
+}
+
+/*
+ * Remove a window from a layer
+ */
+
+void
+LayerWindowRemove (ScreenPtr pScreen, LayerPtr pLayer, WindowPtr pWin)
+{
+ layerWinPriv(pWin);
+
+ if (pLayWin->isList)
+ {
+ LayerListPtr *pPrev;
+ LayerListPtr pLayList;
+
+ for (pPrev = &pLayWin->u.pLayList; (pLayList = *pPrev); pPrev = &pLayList->pNext)
+ {
+ if (pLayList->pLayer == pLayer)
+ {
+ *pPrev = pLayList->pNext;
+ FreeLayerList (pScreen, pLayList);
+ --pLayer->windows;
+ if (pLayer->windows <= 0)
+ LayerDestroyPixmap (pScreen, pLayer);
+ LayerDestroy (pScreen, pLayer);
+ break;
+ }
+ }
+ pLayList = pLayWin->u.pLayList;
+ if (!pLayList)
+ {
+ /*
+ * List is empty, set isList back to false
+ */
+ pLayWin->isList = FALSE;
+ pLayWin->u.pLayer = 0;
+ }
+ else if (!pLayList->pNext && pLayList->inheritClip)
+ {
+ /*
+ * List contains a single element using the
+ * window clip, free the list structure and
+ * host the layer back to the window private
+ */
+ pLayer = pLayList->pLayer;
+ FreeLayerList (pScreen, pLayList);
+ pLayWin->isList = FALSE;
+ pLayWin->u.pLayer = pLayer;
+ }
+ }
+ else
+ {
+ if (pLayWin->u.pLayer == pLayer)
+ {
+ --pLayer->windows;
+ if (pLayer->windows <= 0)
+ LayerDestroyPixmap (pScreen, pLayer);
+ LayerDestroy (pScreen, pLayer);
+ pLayWin->u.pLayer = 0;
+ }
+ }
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+}
+
+/*
+ * Looping primitives for window layering. Usage:
+ *
+ * for (pLayer = LayerWindowFirst (pWin, &loop);
+ * pLayer;
+ * pLayer = LayerWindowNext (&loop))
+ * {
+ * ...
+ * }
+ * LayerWindowDone (pWin, &loop);
+ */
+
+LayerPtr
+LayerWindowFirst (WindowPtr pWin, LayerWinLoopPtr pLoop)
+{
+ layerWinPriv (pWin);
+
+ pLoop->pLayWin = pLayWin;
+ if (!pLayWin->isList)
+ return pLayWin->u.pLayer;
+
+ /*
+ * Preserve original state
+ */
+ pLoop->clipList = pWin->clipList;
+ pLoop->borderClip = pWin->borderClip;
+ pLoop->pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);
+
+ /*
+ * Set initial list element
+ */
+ pLoop->pLayList = pLayWin->u.pLayList;
+
+ /*
+ * Return first layer
+ */
+ return LayerWindowNext (pWin, pLoop);
+}
+
+LayerPtr
+LayerWindowNext (WindowPtr pWin, LayerWinLoopPtr pLoop)
+{
+ LayerPtr pLayer;
+ LayerWinPtr pLayWin = pLoop->pLayWin;
+ LayerListPtr pLayList;
+
+ if (!pLayWin->isList)
+ return 0;
+
+ pLayList = pLoop->pLayList;
+ pLayer = pLayList->pLayer;
+ /*
+ * Configure window for this layer
+ */
+ (*pWin->drawable.pScreen->SetWindowPixmap) (pWin, pLayer->pPixmap);
+ if (!pLayList->inheritClip)
+ {
+ pWin->clipList = pLayList->clipList;
+ pWin->borderClip = pLayList->borderClip;
+ }
+ /*
+ * Step to next layer list
+ */
+ pLoop->pLayList = pLayList->pNext;
+ /*
+ * Return layer
+ */
+ return pLayer;
+}
+
+void
+LayerWindowDone (WindowPtr pWin, LayerWinLoopPtr pLoop)
+{
+ LayerWinPtr pLayWin = pLoop->pLayWin;
+
+ if (!pLayWin->isList)
+ return;
+ /*
+ * clean up after the loop
+ */
+ pWin->clipList = pLoop->clipList;
+ pWin->borderClip = pLoop->clipList;
+ (*pWin->drawable.pScreen->SetWindowPixmap) (pWin, pLoop->pPixmap);
+}
+
+Bool
+layerCreateWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ layerWinPriv(pWin);
+ layerScrPriv(pScreen);
+ LayerPtr pLayer;
+ Bool ret;
+
+ pLayWin->isList = FALSE;
+ pLayWin->u.pLayer = 0;
+
+ /*
+ * input only windows don't live in any layer
+ */
+ if (pWin->drawable.type == UNDRAWABLE_WINDOW)
+ return TRUE;
+ /*
+ * Use a reasonable default layer -- the first
+ * layer matching the windows depth. Subsystems needing
+ * alternative layering semantics can override this by
+ * replacing this function. Perhaps a new screen function
+ * could be used to select the correct initial window
+ * layer instead.
+ */
+ for (pLayer = pLayScr->pLayers; pLayer; pLayer = pLayer->pNext)
+ if (pLayer->depth == pWin->drawable.depth)
+ break;
+ ret = TRUE;
+ if (pLayer)
+ {
+ pScreen->CreateWindow = pLayer->pKind->CreateWindow;
+ ret = (*pScreen->CreateWindow) (pWin);
+ pLayer->pKind->CreateWindow = pScreen->CreateWindow;
+ pScreen->CreateWindow = layerCreateWindow;
+ LayerWindowAdd (pScreen, pLayer, pWin);
+ }
+ return ret;
+}
+
+Bool
+layerDestroyWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ layerWinPriv(pWin);
+ LayerPtr pLayer;
+ Bool ret = TRUE;
+
+ while ((pLayer = layerWinLayer (pLayWin)))
+ {
+ LayerUnwrap (pScreen, pLayer->pKind, DestroyWindow);
+ ret = (*pScreen->DestroyWindow) (pWin);
+ LayerWrap (pScreen, pLayer->pKind, DestroyWindow, layerDestroyWindow);
+ LayerWindowRemove (pWin->drawable.pScreen, pLayer, pWin);
+ }
+ return ret;
+}
+
+Bool
+layerChangeWindowAttributes (WindowPtr pWin, unsigned long mask)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ LayerPtr pLay;
+ LayerWinLoopRec loop;
+ Bool ret = TRUE;
+
+ for (pLay = LayerWindowFirst (pWin, &loop);
+ pLay;
+ pLay = LayerWindowNext (pWin, &loop))
+ {
+ LayerUnwrap(pScreen,pLay->pKind,ChangeWindowAttributes);
+ if (!(*pScreen->ChangeWindowAttributes) (pWin, mask))
+ ret = FALSE;
+ LayerWrap(pScreen,pLay->pKind,ChangeWindowAttributes,layerChangeWindowAttributes);
+ }
+ LayerWindowDone (pWin, &loop);
+ return ret;
+}
+
+void
+layerPaintWindowBackground (WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ LayerPtr pLay;
+ LayerWinLoopRec loop;
+
+ for (pLay = LayerWindowFirst (pWin, &loop);
+ pLay;
+ pLay = LayerWindowNext (pWin, &loop))
+ {
+ LayerUnwrap(pScreen,pLay->pKind,PaintWindowBackground);
+ (*pScreen->PaintWindowBackground) (pWin, pRegion, what);
+ LayerWrap(pScreen,pLay->pKind,PaintWindowBackground,layerPaintWindowBackground);
+ }
+ LayerWindowDone (pWin, &loop);
+}
+
+void
+layerPaintWindowBorder (WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ LayerPtr pLay;
+ LayerWinLoopRec loop;
+
+ for (pLay = LayerWindowFirst (pWin, &loop);
+ pLay;
+ pLay = LayerWindowNext (pWin, &loop))
+ {
+ LayerUnwrap(pScreen,pLay->pKind,PaintWindowBorder);
+ (*pScreen->PaintWindowBorder) (pWin, pRegion, what);
+ LayerWrap(pScreen,pLay->pKind,PaintWindowBorder,layerPaintWindowBorder);
+ }
+ LayerWindowDone (pWin, &loop);
+}
+
+void
+layerCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ LayerPtr pLay;
+ LayerWinLoopRec loop;
+ int dx = 0, dy = 0;
+
+ for (pLay = LayerWindowFirst (pWin, &loop);
+ pLay;
+ pLay = LayerWindowNext (pWin, &loop))
+ {
+ LayerUnwrap(pScreen,pLay->pKind,CopyWindow);
+ /*
+ * Undo the translation done within the last CopyWindow proc (sigh)
+ */
+ if (dx || dy)
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, dx, dy);
+ (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
+ LayerWrap(pScreen,pLay->pKind,CopyWindow,layerCopyWindow);
+ /*
+ * Save offset to undo translation next time around
+ */
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ }
+ LayerWindowDone (pWin, &loop);
+}
+
+PixmapPtr
+layerCreatePixmap (ScreenPtr pScreen, int width, int height, int depth)
+{
+ /* XXX assume the first layer can handle all pixmaps */
+ layerScrPriv (pScreen);
+ LayerKindPtr pKind;
+ PixmapPtr pPixmap;
+
+ pKind = &pLayScr->kinds[0];
+ if (pLayScr->pLayers)
+ pKind = pLayScr->pLayers->pKind;
+ LayerUnwrap (pScreen, pKind, CreatePixmap);
+ pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, depth);
+ LayerWrap (pScreen,pKind,CreatePixmap,layerCreatePixmap);
+ return pPixmap;
+}
+
+Bool
+layerDestroyPixmap (PixmapPtr pPixmap)
+{
+ /* XXX assume the first layer can handle all pixmaps */
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ layerScrPriv (pScreen);
+ LayerKindPtr pKind;
+ Bool ret;
+
+ pKind = &pLayScr->kinds[0];
+ if (pLayScr->pLayers)
+ pKind = pLayScr->pLayers->pKind;
+ LayerUnwrap (pScreen, pKind, DestroyPixmap);
+ ret = (*pScreen->DestroyPixmap) (pPixmap);
+ LayerWrap (pScreen,pKind,DestroyPixmap,layerDestroyPixmap);
+ return ret;
+}
+
diff --git a/nx-X11/programs/Xserver/miext/layer/laymodule.c b/nx-X11/programs/Xserver/miext/layer/laymodule.c
new file mode 100644
index 000000000..5af41617a
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/layer/laymodule.c
@@ -0,0 +1,60 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef XFree86LOADER
+
+#include "xf86Module.h"
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "layer.h"
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "layer",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_ANSIC, /* Only need the ansic layer */
+ ABI_ANSIC_VERSION,
+ MOD_CLASS_NONE,
+ {0,0,0,0} /* signature, to be patched into the file by a tool */
+};
+
+XF86ModuleData layerModuleData = { &VersRec, NULL, NULL };
+
+#endif
diff --git a/nx-X11/programs/Xserver/miext/rootless/Imakefile b/nx-X11/programs/Xserver/miext/rootless/Imakefile
new file mode 100644
index 000000000..2a2bbb2c8
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/Imakefile
@@ -0,0 +1,54 @@
+XCOMM $XFree86: xc/programs/Xserver/miext/rootless/Imakefile,v 1.2 2003/09/16 00:36:20 torrey Exp $
+
+#include <Server.tmpl>
+
+#ifdef DarwinArchitecture
+#define RootlessSafeAlpha YES
+#define RootlessAcceleration YES
+#elif (defined(XWinServer) && XWinServer) || (defined(NXWinServer) && NXWinServer) || defined(Win32Architecture)
+#define RootlessSafeAlpha YES
+#define RootlessAcceleration YES
+#else
+#define RootlessSafeAlpha NO
+#define RootlessAcceleration NO
+#endif
+
+#if RootlessSafeAlpha || RootlessAcceleration
+#define IHaveSubdirs
+#endif
+
+#if RootlessSafeAlpha
+ALPHADIRS = safeAlpha
+#endif
+
+#if RootlessAcceleration
+ACCELDIRS = accel
+#endif
+
+SRCS = rootlessCommon.c \
+ rootlessScreen.c \
+ rootlessWindow.c \
+ rootlessGC.c \
+ rootlessValTree.c
+
+OBJS = rootlessCommon.o \
+ rootlessScreen.o \
+ rootlessWindow.o \
+ rootlessGC.o \
+ rootlessValTree.o
+
+INCLUDES = -I. -I$(SERVERSRC)/fb -I$(SERVERSRC)/mi -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(SERVERSRC)/render \
+ -I$(EXTINCSRC) -I$(ACCELDIRS)
+
+NormalLibraryObjectRule()
+LibraryModuleTarget(rootless,$(OBJS))
+
+DependTarget()
+
+SUBDIRS = $(ALPHADIRS) $(ACCELDIRS)
+
+#if RootlessSafeAlpha || RootlessAcceleration
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
diff --git a/nx-X11/programs/Xserver/miext/rootless/Imakefile.NX.original b/nx-X11/programs/Xserver/miext/rootless/Imakefile.NX.original
new file mode 100644
index 000000000..2a2bbb2c8
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/Imakefile.NX.original
@@ -0,0 +1,54 @@
+XCOMM $XFree86: xc/programs/Xserver/miext/rootless/Imakefile,v 1.2 2003/09/16 00:36:20 torrey Exp $
+
+#include <Server.tmpl>
+
+#ifdef DarwinArchitecture
+#define RootlessSafeAlpha YES
+#define RootlessAcceleration YES
+#elif (defined(XWinServer) && XWinServer) || (defined(NXWinServer) && NXWinServer) || defined(Win32Architecture)
+#define RootlessSafeAlpha YES
+#define RootlessAcceleration YES
+#else
+#define RootlessSafeAlpha NO
+#define RootlessAcceleration NO
+#endif
+
+#if RootlessSafeAlpha || RootlessAcceleration
+#define IHaveSubdirs
+#endif
+
+#if RootlessSafeAlpha
+ALPHADIRS = safeAlpha
+#endif
+
+#if RootlessAcceleration
+ACCELDIRS = accel
+#endif
+
+SRCS = rootlessCommon.c \
+ rootlessScreen.c \
+ rootlessWindow.c \
+ rootlessGC.c \
+ rootlessValTree.c
+
+OBJS = rootlessCommon.o \
+ rootlessScreen.o \
+ rootlessWindow.o \
+ rootlessGC.o \
+ rootlessValTree.o
+
+INCLUDES = -I. -I$(SERVERSRC)/fb -I$(SERVERSRC)/mi -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(SERVERSRC)/render \
+ -I$(EXTINCSRC) -I$(ACCELDIRS)
+
+NormalLibraryObjectRule()
+LibraryModuleTarget(rootless,$(OBJS))
+
+DependTarget()
+
+SUBDIRS = $(ALPHADIRS) $(ACCELDIRS)
+
+#if RootlessSafeAlpha || RootlessAcceleration
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
diff --git a/nx-X11/programs/Xserver/miext/rootless/Imakefile.X.original b/nx-X11/programs/Xserver/miext/rootless/Imakefile.X.original
new file mode 100644
index 000000000..2d6066f41
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/Imakefile.X.original
@@ -0,0 +1,54 @@
+XCOMM $XFree86: xc/programs/Xserver/miext/rootless/Imakefile,v 1.2 2003/09/16 00:36:20 torrey Exp $
+
+#include <Server.tmpl>
+
+#ifdef DarwinArchitecture
+#define RootlessSafeAlpha YES
+#define RootlessAcceleration YES
+#elif (defined(XWinServer) && XWinServer) || defined(Win32Architecture)
+#define RootlessSafeAlpha YES
+#define RootlessAcceleration YES
+#else
+#define RootlessSafeAlpha NO
+#define RootlessAcceleration NO
+#endif
+
+#if RootlessSafeAlpha || RootlessAcceleration
+#define IHaveSubdirs
+#endif
+
+#if RootlessSafeAlpha
+ALPHADIRS = safeAlpha
+#endif
+
+#if RootlessAcceleration
+ACCELDIRS = accel
+#endif
+
+SRCS = rootlessCommon.c \
+ rootlessScreen.c \
+ rootlessWindow.c \
+ rootlessGC.c \
+ rootlessValTree.c
+
+OBJS = rootlessCommon.o \
+ rootlessScreen.o \
+ rootlessWindow.o \
+ rootlessGC.o \
+ rootlessValTree.o
+
+INCLUDES = -I. -I$(SERVERSRC)/fb -I$(SERVERSRC)/mi -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(SERVERSRC)/render \
+ -I$(EXTINCSRC) -I$(ACCELDIRS)
+
+NormalLibraryObjectRule()
+LibraryModuleTarget(rootless,$(OBJS))
+
+DependTarget()
+
+SUBDIRS = $(ALPHADIRS) $(ACCELDIRS)
+
+#if RootlessSafeAlpha || RootlessAcceleration
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
diff --git a/nx-X11/programs/Xserver/miext/rootless/README.txt b/nx-X11/programs/Xserver/miext/rootless/README.txt
new file mode 100644
index 000000000..ffd17902f
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/README.txt
@@ -0,0 +1,403 @@
+ Generic Rootless Layer
+ Version 1.0
+ July 13, 2004
+
+ Torrey T. Lyons
+ torrey@xfree86.org
+
+
+Introduction
+
+ The generic rootless layer allows an X server to be implemented
+on top of another window server in a cooperative manner. This allows the
+X11 windows and native windows of the underlying window server to
+coexist on the same screen. The layer is called "rootless" because the root
+window of the X server is generally not drawn. Instead, each top-level
+child of the root window is represented as a separate on-screen window by
+the underlying window server. The layer is referred to as "generic"
+because it abstracts away the details of the underlying window system and
+contains code that is useful for any rootless X server. The code for the
+generic rootless layer is located in xc/programs/Xserver/miext/rootless. To
+build a complete rootless X server requires a specific rootless
+implementation, which provides functions that allow the generic rootless
+layer to interact with the underlying window system.
+
+
+Concepts
+
+ In the context of a rootless X server the term window is used to
+mean many fundamentally different things. For X11 a window is a DDX
+resource that describes a visible, or potentially visible, rectangle on the
+screen. A top-level window is a direct child of the root window. To avoid
+confusion, an on-screen native window of the underlying window system
+is referred to as a "frame". The generic rootless layer associates each
+mapped top-level X11 window with a frame. An X11 window may be said
+to be "framed" if it or its top-level parent is represented by a frame.
+
+ The generic rootless layer models each frame as being backed at
+all times by a backing buffer, which is periodically flushed to the screen.
+If the underlying window system does not provide a backing buffer for
+frames, this must be done by the rootless implementation. The generic
+rootless layer model does not assume it always has access to the frames'
+backing buffers. Any drawing to the buffer will be proceeded by a call to
+the rootless implementation's StartDrawing() function and StopDrawing()
+will be called when the drawing is concluded. The address of the frame's
+backing buffer is returned by the StartDrawing() function and it can
+change between successive calls.
+
+ Because each frame is assumed to have a backing buffer, the
+generic rootless layer will stop Expose events being generated when the
+regions of visibility of a frame change on screen. This is similar to backing
+store, but backing buffers are different in that they always store a copy of
+the entire window contents, not just the obscured portions. The price paid
+in increased memory consumption is made up by the greatly decreased
+complexity in not having to track and record regions as they are obscured.
+
+
+Rootless Implementation
+
+ The specifics of the underlying window system are provided to the
+generic rootless layer through rootless implementation functions, compile-
+time options, and runtime parameters. The rootless implementation
+functions are a list of functions that allow the generic rootless layer to
+perform operations such as creating, destroying, moving, and resizing
+frames. Some of the implementation functions are optional. A detailed
+description of the rootless implementation functions is provided in
+Appendix A.
+
+ By design, a rootless implementation should only have to include
+the rootless.h header file. The rootlessCommon.h file contains definitions
+internal to the generic rootless layer. (If you find you need to use
+rootlessCommon.h in your implementation, let the generic rootless layer
+maintainers know. This could be an area where the generic rootless layer
+should be generalized.) A rootless implementation should also modify
+rootlessConfig.h to specify compile time options for its platform.
+
+ The following compile-time options are defined in
+rootlessConfig.h:
+
+ o ROOTLESS_ACCEL: If true, use the optional rootless acceleration
+ functions where possible to a accelerate X11 drawing primitives.
+ If false, all drawing will be done with fb.
+
+ o ROOTLESS_GLOBAL_COORDS: This option controls the way that frame
+ coordinates are passed to the rootless implementation. If false,
+ the coordinates are passed per screen relative to the origin of
+ the screen the frame is currently on. Some implementations may
+ prefer to work in a single global coordinate space that spans all
+ screens. If this option is true, the coordinates are passed after
+ adding the coordinates of the screen origin and an overall offset of
+ (rootlessGlobalOffsetX, rootlessGlobalOffsetY).
+
+ o ROOTLESS_PROTECT_ALPHA: By default for a color bit depth of 24 and
+ 32 bits per pixel, fb will overwrite the "unused" 8 bits to optimize
+ drawing speed. If this is true, the alpha channel of frames is
+ protected and is not modified when drawing to them. The bits
+ containing the alpha channel are defined by the macro
+ RootlessAlphaMask(bpp), which should return a bit mask for
+ various bits per pixel.
+
+ o ROOTLESS_REDISPLAY_DELAY: Time in milliseconds between updates to
+ the underlying window server. Most operations will be buffered until
+ this time has expired.
+
+ o ROOTLESS_RESIZE_GRAVITY: If the underlying window system supports it,
+ some frame resizes can be optimized by relying on the frame contents
+ maintaining a particular gravity during the resize. In this way less
+ of the frame contents need to be preserved by the generic rootless
+ layer. If true, the generic rootless layer will pass gravity hints
+ during resizing and rely on the frame contents being preserved
+ accordingly.
+
+ o ROOTLESS_TRACK_DAMAGE: The generic rootless layer draws to the
+ frames' backing buffers and periodically flushes the modified
+ regions to the underlying window server. If this option is true,
+ the generic rootless layer will track these damaged regions.
+ Currently it uses the miRegion code and will not simplify damaged
+ regions even when updating a bounding region would be more
+ efficient. Some window systems provide a more efficient way to
+ track damaged regions. If this option is false, the rootless
+ implementation function DamageRects() is called whenever a
+ backing buffer is modified and the rootless implementation is
+ expected to track the damaged regions itself.
+
+ The following runtime options are defined in rootless.h:
+
+ o rootlessGlobalOffsetX, rootlessGlobalOffsetY: These are only
+ used if ROOTLESS_GLOBAL_COORDS is true. They specify the global
+ offset that is applied to all screens when converting from
+ screen-local to global coordinates.
+
+ o rootless_CopyBytes_threshold, rootless_FillBytes_threshold,
+ rootless_CompositePixels_threshold, rootless_CopyWindow_threshold:
+ The minimum number of bytes or pixels for which to use the rootless
+ implementation's respective acceleration function. The rootless
+ acceleration functions are all optional so these will only be used
+ if the respective acceleration function pointer is not NULL.
+
+
+Accelerated Drawing
+
+ The rootless implementation typically does not have direct access
+to the hardware. Its access to the graphics hardware is generally through
+the API of the underlying window system. This underlying API may not
+overlap well with the X11 drawing primitives. The generic rootless layer
+falls back to using fb for all its 2-D drawing. Providing optional rootless
+implementation acceleration functions can accelerate some graphics
+primitives and some window functions. Typically calling through to the
+underlying window systems API will not speed up these operations for
+small enough areas. The rootless_*_threshold runtime options allow the
+rootless implementation to provide hints for when the acceleration
+functions should be used instead of fb.
+
+
+Alpha Channel Protection
+
+ If the bits per pixel is greater then the color bit depth, the contents
+of the extra bits are undefined by the X11 protocol. Some window systems
+will use these extra bits as an alpha channel. The generic rootless layer can
+be configured to protect these bits and make sure they are not modified by
+other parts of the X server. To protect the alpha channel
+ROOTLESS_PROTECT_ALPHA and RootlessAlphaMask(bpp) must be
+set appropriately as described under the compile time options. This
+ensures that the X11 graphics primitives do not overwrite the alpha
+channel in an attempt to optimize drawing. In addition, the window
+functions PaintWindow() and Composite() must be replaced by alpha
+channel safe variants. These are provided in rootless/safeAlpha.
+
+
+Credits
+
+ The generic rootless layer was originally conceived and developed
+by Greg Parker as part of the XDarwin X server on Mac OS X. John
+Harper made later optimizations to this code but removed its generic
+independence of the underlying window system. Torrey T. Lyons
+reintroduced the generic abstractions and made the rootless code suitable
+for use by other X servers.
+
+
+Appendix A: Rootless Implementation Functions
+
+ The rootless implementation functions are defined in rootless.h. It
+is intended that rootless.h contains the complete interface that is needed by
+rootless implementations. The definitions contained in rootlessCommon.h
+are intended for internal use by the generic rootless layer and are more
+likely to change.
+
+ Most of these functions take a RootlessFrameID as a parameter.
+The RootlessFrameID is an opaque object that is returned by the
+implementation's CreateFrame() function. The generic rootless layer does
+not use this frame id other than to pass it back to the rootless
+implementation to indicate the frame to operate on.
+
+/*
+ * Create a new frame.
+ * The frame is created unmapped.
+ *
+ * pFrame RootlessWindowPtr for this frame should be completely
+ * initialized before calling except for pFrame->wid, which
+ * is set by this function.
+ * pScreen Screen on which to place the new frame
+ * newX, newY Position of the frame. These will be identical to pFrame-x,
+ * pFrame->y unless ROOTLESS_GLOBAL_COORDS is set.
+ * pNewShape Shape for the frame (in frame-local coordinates). NULL for
+ * unshaped frames.
+ */
+typedef Bool (*RootlessCreateFrameProc)
+ (RootlessWindowPtr pFrame, ScreenPtr pScreen, int newX, int newY,
+ RegionPtr pNewShape);
+
+/*
+ * Destroy a frame.
+ * Drawing is stopped and all updates are flushed before this is called.
+ *
+ * wid Frame id
+ */
+typedef void (*RootlessDestroyFrameProc)
+ (RootlessFrameID wid);
+
+/*
+ * Move a frame on screen.
+ * Drawing is stopped and all updates are flushed before this is called.
+ *
+ * wid Frame id
+ * pScreen Screen to move the new frame to
+ * newX, newY New position of the frame
+ */
+typedef void (*RootlessMoveFrameProc)
+ (RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY);
+
+/*
+ * Resize and move a frame.
+ * Drawing is stopped and all updates are flushed before this is called.
+ *
+ * wid Frame id
+ * pScreen Screen to move the new frame to
+ * newX, newY New position of the frame
+ * newW, newH New size of the frame
+ * gravity Gravity for window contents (rl_gravity_enum). This is always
+ * RL_GRAVITY_NONE unless ROOTLESS_RESIZE_GRAVITY is set.
+ */
+typedef void (*RootlessResizeFrameProc)
+ (RootlessFrameID wid, ScreenPtr pScreen,
+ int newX, int newY, unsigned int newW, unsigned int newH,
+ unsigned int gravity);
+
+/*
+ * Change frame ordering (AKA stacking, layering).
+ * Drawing is stopped before this is called. Unmapped frames are mapped by
+ * setting their ordering.
+ *
+ * wid Frame id
+ * nextWid Frame id of frame that is now above this one or NULL if this
+ * frame is at the top.
+ */
+typedef void (*RootlessRestackFrameProc)
+ (RootlessFrameID wid, RootlessFrameID nextWid);
+
+/*
+ * Change frame's shape.
+ * Drawing is stopped before this is called.
+ *
+ * wid Frame id
+ * pNewShape New shape for the frame (in frame-local coordinates)
+ * or NULL if now unshaped.
+ */
+typedef void (*RootlessReshapeFrameProc)
+ (RootlessFrameID wid, RegionPtr pNewShape);
+
+/*
+ * Unmap a frame.
+ *
+ * wid Frame id
+ */
+typedef void (*RootlessUnmapFrameProc)
+ (RootlessFrameID wid);
+
+/*
+ * Start drawing to a frame.
+ * Prepare a frame for direct access to its backing buffer.
+ *
+ * wid Frame id
+ * pixelData Address of the backing buffer (returned)
+ * bytesPerRow Width in bytes of the backing buffer (returned)
+ */
+typedef void (*RootlessStartDrawingProc)
+ (RootlessFrameID wid, char **pixelData, int *bytesPerRow);
+
+/*
+ * Stop drawing to a frame.
+ * No drawing to the frame's backing buffer will occur until drawing
+ * is started again.
+ *
+ * wid Frame id
+ * flush Flush drawing updates for this frame to the screen. This
+ * will always be FALSE if ROOTLESS_TRACK_DAMAGE is set.
+ */
+typedef void (*RootlessStopDrawingProc)
+ (RootlessFrameID wid, Bool flush);
+
+/*
+ * Flush drawing updates to the screen.
+ * Drawing is stopped before this is called.
+ *
+ * wid Frame id
+ * pDamage Region containing all the changed pixels in frame-local
+ * coordinates. This is clipped to the window's clip. This
+ * will be NULL if ROOTLESS_TRACK_DAMAGE is not set.
+ */
+typedef void (*RootlessUpdateRegionProc)
+ (RootlessFrameID wid, RegionPtr pDamage);
+
+/*
+ * Mark damaged rectangles as requiring redisplay to screen.
+ * This will only be called if ROOTLESS_TRACK_DAMAGE is not set.
+ *
+ * wid Frame id
+ * nrects Number of damaged rectangles
+ * rects Array of damaged rectangles in frame-local coordinates
+ * shift_x, Vector to shift rectangles by
+ * shift_y
+ */
+typedef void (*RootlessDamageRectsProc)
+ (RootlessFrameID wid, int nrects, const BoxRec *rects,
+ int shift_x, int shift_y);
+
+/*
+ * Switch the window associated with a frame. (Optional)
+ * When a framed window is reparented, the frame is resized and set to
+ * use the new top-level parent. If defined this function will be called
+ * afterwards for implementation specific bookkeeping.
+ *
+ * pFrame Frame whose window has switched
+ * oldWin Previous window wrapped by this frame
+ */
+typedef void (*RootlessSwitchWindowProc)
+ (RootlessWindowPtr pFrame, WindowPtr oldWin);
+
+/*
+ * Copy bytes. (Optional)
+ * Source and destinate may overlap and the right thing should happen.
+ *
+ * width Bytes to copy per row
+ * height Number of rows
+ * src Source data
+ * srcRowBytes Width of source in bytes
+ * dst Destination data
+ * dstRowBytes Width of destination in bytes
+ */
+typedef void (*RootlessCopyBytesProc)
+ (unsigned int width, unsigned int height,
+ const void *src, unsigned int srcRowBytes,
+ void *dst, unsigned int dstRowBytes);
+
+/*
+ * Fill memory with 32-bit pattern. (Optional)
+ *
+ * width Bytes to fill per row
+ * height Number of rows
+ * value 32-bit pattern to fill with
+ * dst Destination data
+ * dstRowBytes Width of destination in bytes
+ */
+typedef void (*RootlessFillBytesProc)
+ (unsigned int width, unsigned int height, unsigned int value,
+ void *dst, unsigned int dstRowBytes);
+
+/*
+ * Composite pixels from source and mask to destination. (Optional)
+ *
+ * width, height Size of area to composite to in pizels
+ * function Composite function built with RL_COMPOSITE_FUNCTION
+ * src Source data
+ * srcRowBytes Width of source in bytes (Passing NULL means source
+ * is a single pixel.
+ * mask Mask data
+ * maskRowBytes Width of mask in bytes
+ * dst Destination data
+ * dstRowBytes Width of destination in bytes
+ *
+ * For src and dst, the first element of the array is the color data. If
+ * the second element is non-null it implies there is alpha data (which
+ * may be meshed or planar). Data without alpha is assumed to be opaque.
+ *
+ * An X11 error code is returned.
+ */
+typedef int (*RootlessCompositePixelsProc)
+ (unsigned int width, unsigned int height, unsigned int function,
+ void *src[2], unsigned int srcRowBytes[2],
+ void *mask, unsigned int maskRowBytes,
+ void *dst[2], unsigned int dstRowBytes[2]);
+
+/*
+ * Copy area in frame to another part of frame. (Optional)
+ *
+ * wid Frame id
+ * dstNrects Number of rectangles to copy
+ * dstRects Array of rectangles to copy
+ * dx, dy Number of pixels away to copy area
+ */
+typedef void (*RootlessCopyWindowProc)
+ (RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
+ int dx, int dy);
+
diff --git a/nx-X11/programs/Xserver/miext/rootless/accel/Imakefile b/nx-X11/programs/Xserver/miext/rootless/accel/Imakefile
new file mode 100644
index 000000000..a3dabe64b
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/accel/Imakefile
@@ -0,0 +1,30 @@
+XCOMM $XFree86: xc/programs/Xserver/miext/rootless/safeAlpha/Imakefile,v 1.1 2003/09/16 00:36:20 torrey Exp $
+
+#include <Server.tmpl>
+
+SRCS = rlAccel.c \
+ rlBlt.c \
+ rlCopy.c \
+ rlFill.c \
+ rlFillRect.c \
+ rlFillSpans.c \
+ rlGlyph.c \
+ rlSolid.c
+
+OBJS = rlAccel.o \
+ rlBlt.o \
+ rlCopy.o \
+ rlFill.o \
+ rlFillRect.o \
+ rlFillSpans.o \
+ rlGlyph.o \
+ rlSolid.o
+
+INCLUDES = -I. -I$(SERVERSRC)/fb -I$(SERVERSRC)/mi -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(SERVERSRC)/render \
+ -I$(EXTINCSRC) -I$(SERVERSRC)/Xext -I..
+
+NormalLibraryObjectRule()
+LibraryModuleTarget(rlAccel,$(OBJS))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/miext/rootless/accel/rlAccel.c b/nx-X11/programs/Xserver/miext/rootless/accel/rlAccel.c
new file mode 100644
index 000000000..9977c9e4a
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/accel/rlAccel.c
@@ -0,0 +1,155 @@
+/*
+ * Support for accelerated rootless code
+ */
+/*
+ * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XdotOrg: xc/programs/Xserver/miext/rootless/accel/rlAccel.c,v 1.5 2005/07/03 07:02:03 daniels Exp $ */
+
+/*
+ * The accelerated rootless code replaces some GC operations from fb with
+ * versions that call the rootless acceleration functions where appropriate.
+ * To work properly, this must be wrapped directly on top of fb. Nothing
+ * underneath this layer besides fb will get called.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "rootless.h"
+#include "rlAccel.h"
+
+typedef struct _rlAccelScreenRec {
+ CreateGCProcPtr CreateGC;
+ CloseScreenProcPtr CloseScreen;
+} rlAccelScreenRec, *rlAccelScreenPtr;
+
+static int rlAccelScreenPrivateIndex = -1;
+
+#define RLACCELREC(pScreen) \
+ ((rlAccelScreenRec *)(pScreen)->devPrivates[rlAccelScreenPrivateIndex].ptr)
+
+/* This is mostly identical to fbGCOps. */
+static GCOps rlAccelOps = {
+ rlFillSpans,
+ fbSetSpans,
+ fbPutImage,
+ rlCopyArea,
+ fbCopyPlane,
+ fbPolyPoint,
+ fbPolyLine,
+ fbPolySegment,
+ fbPolyRectangle,
+ fbPolyArc,
+ miFillPolygon,
+ rlPolyFillRect,
+ fbPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ rlImageGlyphBlt,
+ fbPolyGlyphBlt,
+ fbPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+
+/*
+ * Screen function to create a graphics context
+ */
+static Bool
+rlCreateGC(GCPtr pGC)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ rlAccelScreenRec *s = RLACCELREC(pScreen);
+ Bool result;
+
+ // Unwrap and call
+ pScreen->CreateGC = s->CreateGC;
+ result = s->CreateGC(pGC);
+
+ // Accelerated GC ops replace some fb GC ops
+ pGC->ops = &rlAccelOps;
+
+ // Rewrap
+ s->CreateGC = pScreen->CreateGC;
+ pScreen->CreateGC = rlCreateGC;
+
+ return result;
+}
+
+
+/*
+ * Clean up when closing a screen on server reset
+ */
+static Bool
+rlCloseScreen (int iScreen, ScreenPtr pScreen)
+{
+ rlAccelScreenRec *s = RLACCELREC(pScreen);
+ Bool result;
+
+ // Unwrap
+ pScreen->CloseScreen = s->CloseScreen;
+ result = pScreen->CloseScreen(iScreen, pScreen);
+
+ xfree(s);
+
+ return result;
+}
+
+
+/*
+ * RootlessAccelInit
+ * Called by the rootless implementation to initialize accelerated
+ * rootless drawing.
+ */
+Bool
+RootlessAccelInit(ScreenPtr pScreen)
+{
+ static unsigned long rlAccelGeneration = 0;
+ rlAccelScreenRec *s;
+
+ if (rlAccelGeneration != serverGeneration) {
+ rlAccelScreenPrivateIndex = AllocateScreenPrivateIndex();
+ if (rlAccelScreenPrivateIndex == -1) return FALSE;
+ rlAccelGeneration = serverGeneration;
+ }
+
+ s = xalloc(sizeof(rlAccelScreenRec));
+ if (!s) return FALSE;
+ RLACCELREC(pScreen) = s;
+
+ // Wrap the screen functions we need
+ s->CreateGC = pScreen->CreateGC;
+ pScreen->CreateGC = rlCreateGC;
+ s->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = rlCloseScreen;
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/miext/rootless/accel/rlAccel.h b/nx-X11/programs/Xserver/miext/rootless/accel/rlAccel.h
new file mode 100644
index 000000000..a4402bdf2
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/accel/rlAccel.h
@@ -0,0 +1,141 @@
+/*
+ * Rootless Acceleration Code
+ */
+/*
+ * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessCommon.c,v 1.4 2003/10/18 00:00:34 torrey Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+/*
+ * rlBlt.c
+ */
+void
+rlBlt (FbBits *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ ScreenPtr pDstScreen,
+ FbBits *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+ int bpp,
+
+ Bool reverse,
+ Bool upsidedown);
+
+/*
+ * rlCopy.c
+ */
+RegionPtr
+rlCopyArea (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut);
+
+/*
+ * rlFill.c
+ */
+void
+rlFill (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int width,
+ int height);
+
+void
+rlSolidBoxClipped (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int x1,
+ int y1,
+ int x2,
+ int y2,
+ FbBits and,
+ FbBits xor);
+
+/*
+ * rlFillRect.c
+ */
+void
+rlPolyFillRect(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nrect,
+ xRectangle *prect);
+
+/*
+ * rlFillSpans.c
+ */
+void
+rlFillSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted);
+
+/*
+ * rlGlyph.c
+ */
+void
+rlImageGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppciInit,
+ pointer pglyphBase);
+
+/*
+ * rlSolid.c
+ */
+void
+rlSolid (ScreenPtr pScreen,
+ FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int bpp,
+
+ int width,
+ int height,
+
+ FbBits and,
+ FbBits xor);
diff --git a/nx-X11/programs/Xserver/miext/rootless/accel/rlBlt.c b/nx-X11/programs/Xserver/miext/rootless/accel/rlBlt.c
new file mode 100644
index 000000000..e5fa5f7bd
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/accel/rlBlt.c
@@ -0,0 +1,370 @@
+/*
+ * Accelerated rootless blit
+ */
+/*
+ * This code is largely copied from fbBlt.c.
+ *
+ * Copyright © 1998 Keith Packard
+ * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
+ * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbblt.c,v 1.8 2000/09/28 00:47:22 keithp Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include "rootlessCommon.h"
+#include "rlAccel.h"
+
+
+void
+rlBlt (FbBits *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ ScreenPtr pDstScreen,
+ FbBits *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+ int bpp,
+
+ Bool reverse,
+ Bool upsidedown)
+{
+ FbBits *src, *dst;
+ int leftShift, rightShift;
+ FbBits startmask, endmask;
+ FbBits bits, bits1;
+ int n, nmiddle;
+ Bool destInvarient;
+ int startbyte, endbyte;
+ FbDeclareMergeRop ();
+
+#ifdef FB_24BIT
+ if (bpp == 24 && !FbCheck24Pix (pm))
+ {
+ fbBlt24 (srcLine, srcStride, srcX, dstLine, dstStride, dstX,
+ width, height, alu, pm, reverse, upsidedown);
+ return;
+ }
+#endif
+ FbInitializeMergeRop(alu, pm);
+ destInvarient = FbDestInvarientMergeRop();
+ if (upsidedown)
+ {
+ srcLine += (height - 1) * (srcStride);
+ dstLine += (height - 1) * (dstStride);
+ srcStride = -srcStride;
+ dstStride = -dstStride;
+ }
+ FbMaskBitsBytes (dstX, width, destInvarient, startmask, startbyte,
+ nmiddle, endmask, endbyte);
+
+ /*
+ * Beginning of the rootless acceleration code
+ */
+ if (!startmask && !endmask && alu == GXcopy &&
+ height * nmiddle * sizeof(*dst) > rootless_CopyBytes_threshold)
+ {
+ if (pm == FB_ALLONES && SCREENREC(pDstScreen)->imp->CopyBytes)
+ {
+ SCREENREC(pDstScreen)->imp->CopyBytes(
+ nmiddle * sizeof(*dst), height,
+ (char *) srcLine + (srcX >> 3),
+ srcStride * sizeof (*src),
+ (char *) dstLine + (dstX >> 3),
+ dstStride * sizeof (*dst));
+ return;
+ }
+
+ /* FIXME: the pm test here isn't super-wonderful - just because
+ we don't care about the top eight bits doesn't necessarily
+ mean we want them set to 255. But doing this does give a
+ factor of two performance improvement when copying from a
+ pixmap to a window, which is pretty common.. */
+
+ else if (bpp == 32 && sizeof(FbBits) == 4 &&
+ pm == 0x00FFFFFFUL && !reverse &&
+ SCREENREC(pDstScreen)->imp->CompositePixels)
+ {
+ /* need to copy XRGB to ARGB. */
+
+ void *src[2], *dest[2];
+ unsigned int src_rowbytes[2], dest_rowbytes[2];
+ unsigned int fn;
+
+ src[0] = (char *) srcLine + (srcX >> 3);
+ src[1] = NULL;
+ src_rowbytes[0] = srcStride * sizeof(*src);
+ src_rowbytes[1] = 0;
+
+ dest[0] = (char *) dstLine + (dstX >> 3);
+ dest[1] = dest[0];
+ dest_rowbytes[0] = dstStride * sizeof(*dst);
+ dest_rowbytes[1] = dest_rowbytes[0];
+
+ fn = RL_COMPOSITE_FUNCTION(RL_COMPOSITE_SRC, RL_DEPTH_ARGB8888,
+ RL_DEPTH_NIL, RL_DEPTH_ARGB8888);
+
+ if (SCREENREC(pDstScreen)->imp->CompositePixels(
+ nmiddle, height,
+ fn, src, src_rowbytes,
+ NULL, 0, dest, dest_rowbytes) == Success)
+ {
+ return;
+ }
+ }
+ }
+ /* End of the rootless acceleration code */
+
+ if (reverse)
+ {
+ srcLine += ((srcX + width - 1) >> FB_SHIFT) + 1;
+ dstLine += ((dstX + width - 1) >> FB_SHIFT) + 1;
+ srcX = (srcX + width - 1) & FB_MASK;
+ dstX = (dstX + width - 1) & FB_MASK;
+ }
+ else
+ {
+ srcLine += srcX >> FB_SHIFT;
+ dstLine += dstX >> FB_SHIFT;
+ srcX &= FB_MASK;
+ dstX &= FB_MASK;
+ }
+ if (srcX == dstX)
+ {
+ while (height--)
+ {
+ src = srcLine;
+ srcLine += srcStride;
+ dst = dstLine;
+ dstLine += dstStride;
+ if (reverse)
+ {
+ if (endmask)
+ {
+ bits = *--src;
+ --dst;
+ FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
+ }
+ n = nmiddle;
+ if (destInvarient)
+ {
+ while (n--)
+ *--dst = FbDoDestInvarientMergeRop(*--src);
+ }
+ else
+ {
+ while (n--)
+ {
+ bits = *--src;
+ --dst;
+ *dst = FbDoMergeRop (bits, *dst);
+ }
+ }
+ if (startmask)
+ {
+ bits = *--src;
+ --dst;
+ FbDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask);
+ }
+ }
+ else
+ {
+ if (startmask)
+ {
+ bits = *src++;
+ FbDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask);
+ dst++;
+ }
+ n = nmiddle;
+ if (destInvarient)
+ {
+#if 0
+ /*
+ * This provides some speedup on screen->screen blts
+ * over the PCI bus, usually about 10%. But fb
+ * isn't usually used for this operation...
+ */
+ if (_ca2 + 1 == 0 && _cx2 == 0)
+ {
+ FbBits t1, t2, t3, t4;
+ while (n >= 4)
+ {
+ t1 = *src++;
+ t2 = *src++;
+ t3 = *src++;
+ t4 = *src++;
+ *dst++ = t1;
+ *dst++ = t2;
+ *dst++ = t3;
+ *dst++ = t4;
+ n -= 4;
+ }
+ }
+#endif
+ while (n--)
+ *dst++ = FbDoDestInvarientMergeRop(*src++);
+ }
+ else
+ {
+ while (n--)
+ {
+ bits = *src++;
+ *dst = FbDoMergeRop (bits, *dst);
+ dst++;
+ }
+ }
+ if (endmask)
+ {
+ bits = *src;
+ FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
+ }
+ }
+ }
+ }
+ else
+ {
+ if (srcX > dstX)
+ {
+ leftShift = srcX - dstX;
+ rightShift = FB_UNIT - leftShift;
+ }
+ else
+ {
+ rightShift = dstX - srcX;
+ leftShift = FB_UNIT - rightShift;
+ }
+ while (height--)
+ {
+ src = srcLine;
+ srcLine += srcStride;
+ dst = dstLine;
+ dstLine += dstStride;
+
+ bits1 = 0;
+ if (reverse)
+ {
+ if (srcX < dstX)
+ bits1 = *--src;
+ if (endmask)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ if (FbScrRight(endmask, leftShift))
+ {
+ bits1 = *--src;
+ bits |= FbScrLeft(bits1, leftShift);
+ }
+ --dst;
+ FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
+ }
+ n = nmiddle;
+ if (destInvarient)
+ {
+ while (n--)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ bits1 = *--src;
+ bits |= FbScrLeft(bits1, leftShift);
+ --dst;
+ *dst = FbDoDestInvarientMergeRop(bits);
+ }
+ }
+ else
+ {
+ while (n--)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ bits1 = *--src;
+ bits |= FbScrLeft(bits1, leftShift);
+ --dst;
+ *dst = FbDoMergeRop(bits, *dst);
+ }
+ }
+ if (startmask)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ if (FbScrRight(startmask, leftShift))
+ {
+ bits1 = *--src;
+ bits |= FbScrLeft(bits1, leftShift);
+ }
+ --dst;
+ FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask);
+ }
+ }
+ else
+ {
+ if (srcX > dstX)
+ bits1 = *src++;
+ if (startmask)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ bits1 = *src++;
+ bits |= FbScrRight(bits1, rightShift);
+ FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask);
+ dst++;
+ }
+ n = nmiddle;
+ if (destInvarient)
+ {
+ while (n--)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ bits1 = *src++;
+ bits |= FbScrRight(bits1, rightShift);
+ *dst = FbDoDestInvarientMergeRop(bits);
+ dst++;
+ }
+ }
+ else
+ {
+ while (n--)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ bits1 = *src++;
+ bits |= FbScrRight(bits1, rightShift);
+ *dst = FbDoMergeRop(bits, *dst);
+ dst++;
+ }
+ }
+ if (endmask)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ if (FbScrLeft(endmask, rightShift))
+ {
+ bits1 = *src;
+ bits |= FbScrRight(bits1, rightShift);
+ }
+ FbDoRightMaskByteMergeRop (dst, bits, endbyte, endmask);
+ }
+ }
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/miext/rootless/accel/rlCopy.c b/nx-X11/programs/Xserver/miext/rootless/accel/rlCopy.c
new file mode 100644
index 000000000..ccea7fbd3
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/accel/rlCopy.c
@@ -0,0 +1,107 @@
+/*
+ * This code is largely copied from fbcopy.c.
+ *
+ * Copyright © 1998 Keith Packard
+ * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbcopy.c,v 1.12 2001/07/16 05:04:05 keithp Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include "rlAccel.h"
+
+
+void
+rlCopyNtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ CARD8 alu = pGC ? pGC->alu : GXcopy;
+ FbBits pm = pGC ? fbGetGCPrivate(pGC)->pm : FB_ALLONES;
+ FbBits *src;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+
+ fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+ fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ while (nbox--)
+ {
+ rlBlt (src + (pbox->y1 + dy + srcYoff) * srcStride,
+ srcStride,
+ (pbox->x1 + dx + srcXoff) * srcBpp,
+
+ pDstDrawable->pScreen,
+ dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+
+ (pbox->x2 - pbox->x1) * dstBpp,
+ (pbox->y2 - pbox->y1),
+
+ alu,
+ pm,
+ dstBpp,
+
+ reverse,
+ upsidedown);
+ pbox++;
+ }
+}
+
+RegionPtr
+rlCopyArea (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int xIn,
+ int yIn,
+ int widthSrc,
+ int heightSrc,
+ int xOut,
+ int yOut)
+{
+ fbCopyProc copy;
+
+#ifdef FB_24_32BIT
+ if (pSrcDrawable->bitsPerPixel != pDstDrawable->bitsPerPixel)
+ copy = fb24_32CopyMtoN;
+ else
+#endif
+ copy = rlCopyNtoN;
+ return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, xIn, yIn,
+ widthSrc, heightSrc, xOut, yOut, copy, 0, 0);
+}
diff --git a/nx-X11/programs/Xserver/miext/rootless/accel/rlFill.c b/nx-X11/programs/Xserver/miext/rootless/accel/rlFill.c
new file mode 100644
index 000000000..a6ed2fbbb
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/accel/rlFill.c
@@ -0,0 +1,221 @@
+/*
+ * This code is largely copied from fbfill.c.
+ *
+ * Copyright © 1998 Keith Packard
+ * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbfill.c,v 1.6 2003/01/31 00:01:45 torrey Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include "rlAccel.h"
+
+
+void
+rlFill (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ rlSolid (pDrawable->pScreen,
+ dst + (y + dstYoff) * dstStride,
+ dstStride,
+ (x + dstXoff) * dstBpp,
+ dstBpp,
+ width * dstBpp, height,
+ pPriv->and, pPriv->xor);
+ break;
+ case FillStippled:
+ case FillOpaqueStippled: {
+ PixmapPtr pStip = pGC->stipple;
+ int stipWidth = pStip->drawable.width;
+ int stipHeight = pStip->drawable.height;
+
+ if (dstBpp == 1)
+ {
+ int alu;
+ FbBits *stip;
+ FbStride stipStride;
+ int stipBpp;
+ int stipXoff, stipYoff; /* XXX assumed to be zero */
+
+ if (pGC->fillStyle == FillStippled)
+ alu = FbStipple1Rop(pGC->alu,pGC->fgPixel);
+ else
+ alu = FbOpaqueStipple1Rop(pGC->alu,pGC->fgPixel,pGC->bgPixel);
+ fbGetDrawable (&pStip->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff);
+ fbTile (dst + (y + dstYoff) * dstStride,
+ dstStride,
+ x + dstXoff,
+ width, height,
+ stip,
+ stipStride,
+ stipWidth,
+ stipHeight,
+ alu,
+ pPriv->pm,
+ dstBpp,
+
+ (pGC->patOrg.x + pDrawable->x + dstXoff),
+ pGC->patOrg.y + pDrawable->y + dstYoff - y);
+ }
+ else
+ {
+ FbStip *stip;
+ FbStride stipStride;
+ int stipBpp;
+ int stipXoff, stipYoff; /* XXX assumed to be zero */
+ FbBits fgand, fgxor, bgand, bgxor;
+
+ fgand = pPriv->and;
+ fgxor = pPriv->xor;
+ if (pGC->fillStyle == FillStippled)
+ {
+ bgand = fbAnd(GXnoop,(FbBits) 0,FB_ALLONES);
+ bgxor = fbXor(GXnoop,(FbBits) 0,FB_ALLONES);
+ }
+ else
+ {
+ bgand = pPriv->bgand;
+ bgxor = pPriv->bgxor;
+ }
+
+ fbGetStipDrawable (&pStip->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff);
+ fbStipple (dst + (y + dstYoff) * dstStride,
+ dstStride,
+ (x + dstXoff) * dstBpp,
+ dstBpp,
+ width * dstBpp, height,
+ stip,
+ stipStride,
+ stipWidth,
+ stipHeight,
+ pPriv->evenStipple,
+ fgand, fgxor,
+ bgand, bgxor,
+ pGC->patOrg.x + pDrawable->x + dstXoff,
+ pGC->patOrg.y + pDrawable->y + dstYoff - y);
+ }
+ break;
+ }
+ case FillTiled: {
+ PixmapPtr pTile = pGC->tile.pixmap;
+ FbBits *tile;
+ FbStride tileStride;
+ int tileBpp;
+ int tileWidth;
+ int tileHeight;
+ int tileXoff, tileYoff; /* XXX assumed to be zero */
+
+ fbGetDrawable (&pTile->drawable, tile, tileStride, tileBpp, tileXoff, tileYoff);
+ tileWidth = pTile->drawable.width;
+ tileHeight = pTile->drawable.height;
+ fbTile (dst + (y + dstYoff) * dstStride,
+ dstStride,
+ (x + dstXoff) * dstBpp,
+ width * dstBpp, height,
+ tile,
+ tileStride,
+ tileWidth * tileBpp,
+ tileHeight,
+ pGC->alu,
+ pPriv->pm,
+ dstBpp,
+ (pGC->patOrg.x + pDrawable->x + dstXoff) * dstBpp,
+ pGC->patOrg.y + pDrawable->y + dstYoff - y);
+ break;
+ }
+ }
+ fbValidateDrawable (pDrawable);
+}
+
+void
+rlSolidBoxClipped (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int x1,
+ int y1,
+ int x2,
+ int y2,
+ FbBits and,
+ FbBits xor)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ BoxPtr pbox;
+ int nbox;
+ int partX1, partX2, partY1, partY2;
+
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+ for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip);
+ nbox--;
+ pbox++)
+ {
+ partX1 = pbox->x1;
+ if (partX1 < x1)
+ partX1 = x1;
+
+ partX2 = pbox->x2;
+ if (partX2 > x2)
+ partX2 = x2;
+
+ if (partX2 <= partX1)
+ continue;
+
+ partY1 = pbox->y1;
+ if (partY1 < y1)
+ partY1 = y1;
+
+ partY2 = pbox->y2;
+ if (partY2 > y2)
+ partY2 = y2;
+
+ if (partY2 <= partY1)
+ continue;
+
+ rlSolid (pDrawable->pScreen,
+ dst + (partY1 + dstYoff) * dstStride,
+ dstStride,
+ (partX1 + dstXoff) * dstBpp,
+ dstBpp,
+
+ (partX2 - partX1) * dstBpp,
+ (partY2 - partY1),
+ and, xor);
+ }
+}
diff --git a/nx-X11/programs/Xserver/miext/rootless/accel/rlFillRect.c b/nx-X11/programs/Xserver/miext/rootless/accel/rlFillRect.c
new file mode 100644
index 000000000..e4bab4f53
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/accel/rlFillRect.c
@@ -0,0 +1,118 @@
+/*
+ * This code is largely copied from fbfillrect.c.
+ *
+ * Copyright © 1998 Keith Packard
+ * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbfillrect.c,v 1.2 2000/02/23 20:29:43 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include "rlAccel.h"
+
+
+void
+rlPolyFillRect(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nrect,
+ xRectangle *prect)
+{
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ register BoxPtr pbox;
+ BoxPtr pextent;
+ int extentX1, extentX2, extentY1, extentY2;
+ int fullX1, fullX2, fullY1, fullY2;
+ int partX1, partX2, partY1, partY2;
+ int xorg, yorg;
+ int n;
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, pClip);
+ extentX1 = pextent->x1;
+ extentY1 = pextent->y1;
+ extentX2 = pextent->x2;
+ extentY2 = pextent->y2;
+ while (nrect--)
+ {
+ fullX1 = prect->x + xorg;
+ fullY1 = prect->y + yorg;
+ fullX2 = fullX1 + (int) prect->width;
+ fullY2 = fullY1 + (int) prect->height;
+ prect++;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+
+ if (fullY1 < extentY1)
+ fullY1 = extentY1;
+
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullY2 > extentY2)
+ fullY2 = extentY2;
+
+ if ((fullX1 >= fullX2) || (fullY1 >= fullY2))
+ continue;
+ n = REGION_NUM_RECTS (pClip);
+ if (n == 1)
+ {
+ rlFill (pDrawable,
+ pGC,
+ fullX1, fullY1, fullX2-fullX1, fullY2-fullY1);
+ }
+ else
+ {
+ pbox = REGION_RECTS(pClip);
+ /*
+ * clip the rectangle to each box in the clip region
+ * this is logically equivalent to calling Intersect()
+ */
+ while(n--)
+ {
+ partX1 = pbox->x1;
+ if (partX1 < fullX1)
+ partX1 = fullX1;
+ partY1 = pbox->y1;
+ if (partY1 < fullY1)
+ partY1 = fullY1;
+ partX2 = pbox->x2;
+ if (partX2 > fullX2)
+ partX2 = fullX2;
+ partY2 = pbox->y2;
+ if (partY2 > fullY2)
+ partY2 = fullY2;
+
+ pbox++;
+
+ if (partX1 < partX2 && partY1 < partY2)
+ rlFill (pDrawable, pGC,
+ partX1, partY1,
+ partX2 - partX1, partY2 - partY1);
+ }
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/miext/rootless/accel/rlFillSpans.c b/nx-X11/programs/Xserver/miext/rootless/accel/rlFillSpans.c
new file mode 100644
index 000000000..9942d70e4
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/accel/rlFillSpans.c
@@ -0,0 +1,106 @@
+/*
+ * This code is largely copied from fbfillsp.c.
+ *
+ * Copyright © 1998 Keith Packard
+ * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbfillsp.c,v 1.2 2000/02/23 20:29:43 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include "rlAccel.h"
+
+
+void
+rlFillSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted)
+{
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ BoxPtr pextent, pbox;
+ int nbox;
+ int extentX1, extentX2, extentY1, extentY2;
+ int fullX1, fullX2, fullY1;
+ int partX1, partX2;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, pClip);
+ extentX1 = pextent->x1;
+ extentY1 = pextent->y1;
+ extentX2 = pextent->x2;
+ extentY2 = pextent->y2;
+ while (n--)
+ {
+ fullX1 = ppt->x;
+ fullY1 = ppt->y;
+ fullX2 = fullX1 + (int) *pwidth;
+ ppt++;
+ pwidth++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ nbox = REGION_NUM_RECTS (pClip);
+ if (nbox == 1)
+ {
+ rlFill (pDrawable,
+ pGC,
+ fullX1, fullY1, fullX2-fullX1, 1);
+ }
+ else
+ {
+ pbox = REGION_RECTS(pClip);
+ while(nbox--)
+ {
+ if (pbox->y1 <= fullY1 && fullY1 < pbox->y2)
+ {
+ partX1 = pbox->x1;
+ if (partX1 < fullX1)
+ partX1 = fullX1;
+ partX2 = pbox->x2;
+ if (partX2 > fullX2)
+ partX2 = fullX2;
+ if (partX2 > partX1)
+ {
+ rlFill (pDrawable, pGC,
+ partX1, fullY1,
+ partX2 - partX1, 1);
+ }
+ }
+ pbox++;
+ }
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/miext/rootless/accel/rlGlyph.c b/nx-X11/programs/Xserver/miext/rootless/accel/rlGlyph.c
new file mode 100644
index 000000000..3f1571963
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/accel/rlGlyph.c
@@ -0,0 +1,170 @@
+/*
+ * This code is largely copied from fbglyph.c.
+ *
+ * Copyright © 1998 Keith Packard
+ * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbglyph.c,v 1.12 2001/09/07 15:16:00 keithp Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "rlAccel.h"
+
+
+void
+rlImageGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppciInit,
+ pointer pglyphBase)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ CharInfoPtr *ppci;
+ CharInfoPtr pci;
+ unsigned char *pglyph; /* pointer bits in glyph */
+ int gWidth, gHeight; /* width and height of glyph */
+ FbStride gStride; /* stride of glyph */
+ Bool opaque;
+ int n;
+ int gx, gy;
+#ifndef FBNOPIXADDR
+ void (*glyph) (FbBits *,
+ FbStride,
+ int,
+ FbStip *,
+ FbBits,
+ int,
+ int);
+ FbBits *dst = 0;
+ FbStride dstStride = 0;
+ int dstBpp = 0;
+ int dstXoff = 0, dstYoff = 0;
+
+ glyph = 0;
+ if (pPriv->and == 0)
+ {
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ switch (dstBpp) {
+ case 8: glyph = fbGlyph8; break;
+ case 16: glyph = fbGlyph16; break;
+#ifdef FB_24BIT
+ case 24: glyph = fbGlyph24; break;
+#endif
+ case 32: glyph = fbGlyph32; break;
+ }
+ }
+#endif
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ if (TERMINALFONT (pGC->font)
+#ifndef FBNOPIXADDR
+ && !glyph
+#endif
+ )
+ {
+ opaque = TRUE;
+ }
+ else
+ {
+ int xBack, widthBack;
+ int yBack, heightBack;
+
+ ppci = ppciInit;
+ n = nglyph;
+ widthBack = 0;
+ while (n--)
+ widthBack += (*ppci++)->metrics.characterWidth;
+
+ xBack = x;
+ if (widthBack < 0)
+ {
+ xBack += widthBack;
+ widthBack = -widthBack;
+ }
+ yBack = y - FONTASCENT(pGC->font);
+ heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+ rlSolidBoxClipped (pDrawable,
+ fbGetCompositeClip(pGC),
+ xBack,
+ yBack,
+ xBack + widthBack,
+ yBack + heightBack,
+ fbAnd(GXcopy,pPriv->bg,pPriv->pm),
+ fbXor(GXcopy,pPriv->bg,pPriv->pm));
+ opaque = FALSE;
+ }
+
+ ppci = ppciInit;
+ while (nglyph--)
+ {
+ pci = *ppci++;
+ pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ gWidth = GLYPHWIDTHPIXELS(pci);
+ gHeight = GLYPHHEIGHTPIXELS(pci);
+ if (gWidth && gHeight)
+ {
+ gx = x + pci->metrics.leftSideBearing;
+ gy = y - pci->metrics.ascent;
+#ifndef FBNOPIXADDR
+ if (glyph && gWidth <= sizeof (FbStip) * 8 &&
+ fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
+ {
+ (*glyph) (dst + (gy + dstYoff) * dstStride,
+ dstStride,
+ dstBpp,
+ (FbStip *) pglyph,
+ pPriv->fg,
+ gx + dstXoff,
+ gHeight);
+ }
+ else
+#endif
+ {
+ gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
+ fbPutXYImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pPriv->fg,
+ pPriv->bg,
+ pPriv->pm,
+ GXcopy,
+ opaque,
+
+ gx,
+ gy,
+ gWidth, gHeight,
+
+ (FbStip *) pglyph,
+ gStride,
+ 0);
+ }
+ }
+ x += pci->metrics.characterWidth;
+ }
+}
diff --git a/nx-X11/programs/Xserver/miext/rootless/accel/rlSolid.c b/nx-X11/programs/Xserver/miext/rootless/accel/rlSolid.c
new file mode 100644
index 000000000..edce3d2c4
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/accel/rlSolid.c
@@ -0,0 +1,112 @@
+/*
+ * Accelerated rootless fill
+ */
+/*
+ * This code is largely copied from fbsolid.c.
+ *
+ * Copyright © 1998 Keith Packard
+ * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
+ * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/fb/fbsolid.c,v 1.8 2001/10/28 03:33:08 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include "rootlessCommon.h"
+
+
+void
+rlSolid (ScreenPtr pScreen,
+ FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int bpp,
+
+ int width,
+ int height,
+
+ FbBits and,
+ FbBits xor)
+{
+ FbBits startmask, endmask;
+ int n, nmiddle;
+ int startbyte, endbyte;
+
+#ifdef FB_24BIT
+ if (bpp == 24 && (!FbCheck24Pix(and) || !FbCheck24Pix(xor)))
+ {
+ fbSolid24 (dst, dstStride, dstX, width, height, and, xor);
+ return;
+ }
+#endif
+
+ dst += dstX >> FB_SHIFT;
+ dstX &= FB_MASK;
+ FbMaskBitsBytes(dstX, width, and == 0, startmask, startbyte,
+ nmiddle, endmask, endbyte);
+
+ /*
+ * Beginning of the rootless acceleration code
+ */
+ if (!startmask && !endmask && !and &&
+ height * nmiddle * sizeof (*dst) > rootless_FillBytes_threshold &&
+ SCREENREC(pScreen)->imp->FillBytes)
+ {
+ if (bpp <= 8)
+ xor |= xor << 8;
+ if (bpp <= 16)
+ xor |= xor << 16;
+
+ SCREENREC(pScreen)->imp->FillBytes(nmiddle * sizeof (*dst), height,
+ xor, (char *) dst + (dstX >> 3),
+ dstStride * sizeof (*dst));
+ return;
+ }
+ /* End of the rootless acceleration code */
+
+ if (startmask)
+ dstStride--;
+ dstStride -= nmiddle;
+ while (height--)
+ {
+ if (startmask)
+ {
+ FbDoLeftMaskByteRRop(dst,startbyte,startmask,and,xor);
+ dst++;
+ }
+ n = nmiddle;
+ if (!and)
+ while (n--)
+ *dst++ = xor;
+ else
+ while (n--)
+ {
+ *dst = FbDoRRop (*dst, and, xor);
+ dst++;
+ }
+ if (endmask)
+ FbDoRightMaskByteRRop(dst,endbyte,endmask,and,xor);
+ dst += dstStride;
+ }
+}
diff --git a/nx-X11/programs/Xserver/miext/rootless/rootless.h b/nx-X11/programs/Xserver/miext/rootless/rootless.h
new file mode 100644
index 000000000..dec0e2c64
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/rootless.h
@@ -0,0 +1,436 @@
+/*
+ * External interface to generic rootless mode
+ */
+/*
+ * Copyright (c) 2001 Greg Parker. All Rights Reserved.
+ * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/miext/rootless/rootless.h,v 1.7 2004/07/02 01:30:33 torrey Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _ROOTLESS_H
+#define _ROOTLESS_H
+
+#include "rootlessConfig.h"
+#include "mi.h"
+#include "gcstruct.h"
+
+/*
+ Each top-level rootless window has a one-to-one correspondence to a physical
+ on-screen window. The physical window is refered to as a "frame".
+ */
+
+typedef void * RootlessFrameID;
+
+/*
+ * RootlessWindowRec
+ * This structure stores the per-frame data used by the rootless code.
+ * Each top-level X window has one RootlessWindowRec associated with it.
+ */
+typedef struct _RootlessWindowRec {
+ // Position and size includes the window border
+ // Position is in per-screen coordinates
+ int x, y;
+ unsigned int width, height;
+ unsigned int borderWidth;
+
+ RootlessFrameID wid; // implementation specific frame id
+ WindowPtr win; // underlying X window
+
+ // Valid only when drawing (ie. is_drawing is set)
+ char *pixelData;
+ int bytesPerRow;
+
+ PixmapPtr pixmap;
+ PixmapPtr oldPixmap;
+
+#ifdef ROOTLESS_TRACK_DAMAGE
+ RegionRec damage;
+#endif
+
+ unsigned int is_drawing :1; // Currently drawing?
+ unsigned int is_reorder_pending :1;
+} RootlessWindowRec, *RootlessWindowPtr;
+
+
+/* Offset for screen-local to global coordinate transforms */
+#ifdef ROOTLESS_GLOBAL_COORDS
+extern int rootlessGlobalOffsetX;
+extern int rootlessGlobalOffsetY;
+#endif
+
+/* The minimum number of bytes or pixels for which to use the
+ implementation's accelerated functions. */
+extern unsigned int rootless_CopyBytes_threshold;
+extern unsigned int rootless_FillBytes_threshold;
+extern unsigned int rootless_CompositePixels_threshold;
+extern unsigned int rootless_CopyWindow_threshold;
+
+/* Operations used by CompositePixels */
+enum rl_composite_op_enum {
+ RL_COMPOSITE_SRC = 0,
+ RL_COMPOSITE_OVER,
+};
+
+/* Data formats for depth field and composite functions */
+enum rl_depth_enum {
+ RL_DEPTH_NIL = 0, /* null source when compositing */
+ RL_DEPTH_ARGB8888,
+ RL_DEPTH_RGB555,
+ RL_DEPTH_A8, /* for masks when compositing */
+ RL_DEPTH_INDEX8,
+};
+
+/* Macro to form the composite function for CompositePixels */
+#define RL_COMPOSITE_FUNCTION(op, src_depth, mask_depth, dest_depth) \
+ (((op) << 24) | ((src_depth) << 16) \
+ | ((mask_depth) << 8) | ((dest_depth) << 0))
+
+/* Gravity for window contents during resizing */
+enum rl_gravity_enum {
+ RL_GRAVITY_NONE = 0, /* no gravity, fill everything */
+ RL_GRAVITY_NORTH_WEST = 1, /* anchor to top-left corner */
+ RL_GRAVITY_NORTH_EAST = 2, /* anchor to top-right corner */
+ RL_GRAVITY_SOUTH_EAST = 3, /* anchor to bottom-right corner */
+ RL_GRAVITY_SOUTH_WEST = 4, /* anchor to bottom-left corner */
+};
+
+
+/*------------------------------------------
+ Rootless Implementation Functions
+ ------------------------------------------*/
+
+/*
+ * Create a new frame.
+ * The frame is created unmapped.
+ *
+ * pFrame RootlessWindowPtr for this frame should be completely
+ * initialized before calling except for pFrame->wid, which
+ * is set by this function.
+ * pScreen Screen on which to place the new frame
+ * newX, newY Position of the frame. These will be identical to pFrame-x,
+ * pFrame->y unless ROOTLESS_GLOBAL_COORDS is set.
+ * pNewShape Shape for the frame (in frame-local coordinates). NULL for
+ * unshaped frames.
+ */
+typedef Bool (*RootlessCreateFrameProc)
+ (RootlessWindowPtr pFrame, ScreenPtr pScreen, int newX, int newY,
+ RegionPtr pNewShape);
+
+/*
+ * Destroy a frame.
+ * Drawing is stopped and all updates are flushed before this is called.
+ *
+ * wid Frame id
+ */
+typedef void (*RootlessDestroyFrameProc)
+ (RootlessFrameID wid);
+
+/*
+ * Move a frame on screen.
+ * Drawing is stopped and all updates are flushed before this is called.
+ *
+ * wid Frame id
+ * pScreen Screen to move the new frame to
+ * newX, newY New position of the frame
+ */
+typedef void (*RootlessMoveFrameProc)
+ (RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY);
+
+/*
+ * Resize and move a frame.
+ * Drawing is stopped and all updates are flushed before this is called.
+ *
+ * wid Frame id
+ * pScreen Screen to move the new frame to
+ * newX, newY New position of the frame
+ * newW, newH New size of the frame
+ * gravity Gravity for window contents (rl_gravity_enum). This is always
+ * RL_GRAVITY_NONE unless ROOTLESS_RESIZE_GRAVITY is set.
+ */
+typedef void (*RootlessResizeFrameProc)
+ (RootlessFrameID wid, ScreenPtr pScreen,
+ int newX, int newY, unsigned int newW, unsigned int newH,
+ unsigned int gravity);
+
+/*
+ * Change frame ordering (AKA stacking, layering).
+ * Drawing is stopped before this is called. Unmapped frames are mapped by
+ * setting their ordering.
+ *
+ * wid Frame id
+ * nextWid Frame id of frame that is now above this one or NULL if this
+ * frame is at the top.
+ */
+typedef void (*RootlessRestackFrameProc)
+ (RootlessFrameID wid, RootlessFrameID nextWid);
+
+/*
+ * Change frame's shape.
+ * Drawing is stopped before this is called.
+ *
+ * wid Frame id
+ * pNewShape New shape for the frame (in frame-local coordinates)
+ * or NULL if now unshaped.
+ */
+typedef void (*RootlessReshapeFrameProc)
+ (RootlessFrameID wid, RegionPtr pNewShape);
+
+/*
+ * Unmap a frame.
+ *
+ * wid Frame id
+ */
+typedef void (*RootlessUnmapFrameProc)
+ (RootlessFrameID wid);
+
+/*
+ * Start drawing to a frame.
+ * Prepare a frame for direct access to its backing buffer.
+ *
+ * wid Frame id
+ * pixelData Address of the backing buffer (returned)
+ * bytesPerRow Width in bytes of the backing buffer (returned)
+ */
+typedef void (*RootlessStartDrawingProc)
+ (RootlessFrameID wid, char **pixelData, int *bytesPerRow);
+
+/*
+ * Stop drawing to a frame.
+ * No drawing to the frame's backing buffer will occur until drawing
+ * is started again.
+ *
+ * wid Frame id
+ * flush Flush drawing updates for this frame to the screen. This
+ * will always be FALSE if ROOTLESS_TRACK_DAMAGE is set.
+ */
+typedef void (*RootlessStopDrawingProc)
+ (RootlessFrameID wid, Bool flush);
+
+/*
+ * Flush drawing updates to the screen.
+ * Drawing is stopped before this is called.
+ *
+ * wid Frame id
+ * pDamage Region containing all the changed pixels in frame-lcoal
+ * coordinates. This is clipped to the window's clip. This
+ * will be NULL if ROOTLESS_TRACK_DAMAGE is not set.
+ */
+typedef void (*RootlessUpdateRegionProc)
+ (RootlessFrameID wid, RegionPtr pDamage);
+
+/*
+ * Mark damaged rectangles as requiring redisplay to screen.
+ * This will only be called if ROOTLESS_TRACK_DAMAGE is not set.
+ *
+ * wid Frame id
+ * nrects Number of damaged rectangles
+ * rects Array of damaged rectangles in frame-local coordinates
+ * shift_x, Vector to shift rectangles by
+ * shift_y
+ */
+typedef void (*RootlessDamageRectsProc)
+ (RootlessFrameID wid, int nrects, const BoxRec *rects,
+ int shift_x, int shift_y);
+
+/*
+ * Switch the window associated with a frame. (Optional)
+ * When a framed window is reparented, the frame is resized and set to
+ * use the new top-level parent. If defined this function will be called
+ * afterwards for implementation specific bookkeeping.
+ *
+ * pFrame Frame whose window has switched
+ * oldWin Previous window wrapped by this frame
+ */
+typedef void (*RootlessSwitchWindowProc)
+ (RootlessWindowPtr pFrame, WindowPtr oldWin);
+
+/*
+ * Check if window should be reordered. (Optional)
+ * The underlying window system may animate windows being ordered in.
+ * We want them to be mapped but remain ordered out until the animation
+ * completes. If defined this function will be called to check if a
+ * framed window should be reordered now. If this function returns
+ * FALSE, the window will still be mapped from the X11 perspective, but
+ * the RestackFrame function will not be called for its frame.
+ *
+ * pFrame Frame to reorder
+ */
+typedef Bool (*RootlessDoReorderWindowProc)
+ (RootlessWindowPtr pFrame);
+
+/*
+ * Copy bytes. (Optional)
+ * Source and destinate may overlap and the right thing should happen.
+ *
+ * width Bytes to copy per row
+ * height Number of rows
+ * src Source data
+ * srcRowBytes Width of source in bytes
+ * dst Destination data
+ * dstRowBytes Width of destination in bytes
+ */
+typedef void (*RootlessCopyBytesProc)
+ (unsigned int width, unsigned int height,
+ const void *src, unsigned int srcRowBytes,
+ void *dst, unsigned int dstRowBytes);
+
+/*
+ * Fill memory with 32-bit pattern. (Optional)
+ *
+ * width Bytes to fill per row
+ * height Number of rows
+ * value 32-bit pattern to fill with
+ * dst Destination data
+ * dstRowBytes Width of destination in bytes
+ */
+typedef void (*RootlessFillBytesProc)
+ (unsigned int width, unsigned int height, unsigned int value,
+ void *dst, unsigned int dstRowBytes);
+
+/*
+ * Composite pixels from source and mask to destination. (Optional)
+ *
+ * width, height Size of area to composite to in pizels
+ * function Composite function built with RL_COMPOSITE_FUNCTION
+ * src Source data
+ * srcRowBytes Width of source in bytes (Passing NULL means source
+ * is a single pixel.
+ * mask Mask data
+ * maskRowBytes Width of mask in bytes
+ * dst Destination data
+ * dstRowBytes Width of destination in bytes
+ *
+ * For src and dst, the first element of the array is the color data. If
+ * the second element is non-null it implies there is alpha data (which
+ * may be meshed or planar). Data without alpha is assumed to be opaque.
+ *
+ * An X11 error code is returned.
+ */
+typedef int (*RootlessCompositePixelsProc)
+ (unsigned int width, unsigned int height, unsigned int function,
+ void *src[2], unsigned int srcRowBytes[2],
+ void *mask, unsigned int maskRowBytes,
+ void *dst[2], unsigned int dstRowBytes[2]);
+
+/*
+ * Copy area in frame to another part of frame. (Optional)
+ *
+ * wid Frame id
+ * dstNrects Number of rectangles to copy
+ * dstRects Array of rectangles to copy
+ * dx, dy Number of pixels away to copy area
+ */
+typedef void (*RootlessCopyWindowProc)
+ (RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
+ int dx, int dy);
+
+/*
+ * Rootless implementation function list
+ */
+typedef struct _RootlessFrameProcs {
+ RootlessCreateFrameProc CreateFrame;
+ RootlessDestroyFrameProc DestroyFrame;
+
+ RootlessMoveFrameProc MoveFrame;
+ RootlessResizeFrameProc ResizeFrame;
+ RootlessRestackFrameProc RestackFrame;
+ RootlessReshapeFrameProc ReshapeFrame;
+ RootlessUnmapFrameProc UnmapFrame;
+
+ RootlessStartDrawingProc StartDrawing;
+ RootlessStopDrawingProc StopDrawing;
+ RootlessUpdateRegionProc UpdateRegion;
+#ifndef ROOTLESS_TRACK_DAMAGE
+ RootlessDamageRectsProc DamageRects;
+#endif
+
+ /* Optional frame functions */
+ RootlessSwitchWindowProc SwitchWindow;
+ RootlessDoReorderWindowProc DoReorderWindow;
+
+ /* Optional acceleration functions */
+ RootlessCopyBytesProc CopyBytes;
+ RootlessFillBytesProc FillBytes;
+ RootlessCompositePixelsProc CompositePixels;
+ RootlessCopyWindowProc CopyWindow;
+} RootlessFrameProcsRec, *RootlessFrameProcsPtr;
+
+
+/*
+ * Initialize rootless mode on the given screen.
+ */
+Bool RootlessInit(ScreenPtr pScreen, RootlessFrameProcsPtr procs);
+
+/*
+ * Initialize acceleration for rootless mode on a given screen.
+ * Note: RootlessAccelInit() must be called before DamageSetup()
+ * and RootlessInit() must be called afterwards.
+ */
+Bool RootlessAccelInit(ScreenPtr pScreen);
+
+/*
+ * Return the frame ID for the physical window displaying the given window.
+ *
+ * create If true and the window has no frame, attempt to create one
+ */
+RootlessFrameID RootlessFrameForWindow(WindowPtr pWin, Bool create);
+
+/*
+ * Return the top-level parent of a window.
+ * The root is the top-level parent of itself, even though the root is
+ * not otherwise considered to be a top-level window.
+ */
+WindowPtr TopLevelParent(WindowPtr pWindow);
+
+/*
+ * Prepare a window for direct access to its backing buffer.
+ */
+void RootlessStartDrawing(WindowPtr pWindow);
+
+/*
+ * Finish drawing to a window's backing buffer.
+ *
+ * flush If true and ROOTLESS_TRACK_DAMAGE is set, damaged areas
+ * are flushed to the screen.
+ */
+void RootlessStopDrawing(WindowPtr pWindow, Bool flush);
+
+/*
+ * Alocate a new screen pixmap.
+ * miCreateScreenResources does not do this properly with a null
+ * framebuffer pointer.
+ */
+void RootlessUpdateScreenPixmap(ScreenPtr pScreen);
+
+/*
+ * Reposition all windows on a screen to their correct positions.
+ */
+void RootlessRepositionWindows(ScreenPtr pScreen);
+
+#endif /* _ROOTLESS_H */
diff --git a/nx-X11/programs/Xserver/miext/rootless/rootlessCommon.c b/nx-X11/programs/Xserver/miext/rootless/rootlessCommon.c
new file mode 100644
index 000000000..33321105e
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/rootlessCommon.c
@@ -0,0 +1,405 @@
+/*
+ * Common rootless definitions and code
+ */
+/*
+ * Copyright (c) 2001 Greg Parker. All Rights Reserved.
+ * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessCommon.c,v 1.6 2004/07/02 01:30:33 torrey Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "rootlessCommon.h"
+
+unsigned int rootless_CopyBytes_threshold = 0;
+unsigned int rootless_FillBytes_threshold = 0;
+unsigned int rootless_CompositePixels_threshold = 0;
+unsigned int rootless_CopyWindow_threshold = 0;
+#ifdef ROOTLESS_GLOBAL_COORDS
+int rootlessGlobalOffsetX = 0;
+int rootlessGlobalOffsetY = 0;
+#endif
+
+RegionRec rootlessHugeRoot = {{-32767, -32767, 32767, 32767}, NULL};
+
+/* Following macro from miregion.c */
+
+/* true iff two Boxes overlap */
+#define EXTENTCHECK(r1,r2) \
+ (!( ((r1)->x2 <= (r2)->x1) || \
+ ((r1)->x1 >= (r2)->x2) || \
+ ((r1)->y2 <= (r2)->y1) || \
+ ((r1)->y1 >= (r2)->y2) ) )
+
+
+/*
+ * TopLevelParent
+ * Returns the top-level parent of pWindow.
+ * The root is the top-level parent of itself, even though the root is
+ * not otherwise considered to be a top-level window.
+ */
+WindowPtr
+TopLevelParent(WindowPtr pWindow)
+{
+ WindowPtr top;
+
+ if (IsRoot(pWindow))
+ return pWindow;
+
+ top = pWindow;
+ while (top && ! IsTopLevel(top))
+ top = top->parent;
+
+ return top;
+}
+
+
+/*
+ * IsFramedWindow
+ * Returns TRUE if this window is visible inside a frame
+ * (e.g. it is visible and has a top-level or root parent)
+ */
+Bool
+IsFramedWindow(WindowPtr pWin)
+{
+ WindowPtr top;
+
+ if (!pWin->realized)
+ return FALSE;
+ top = TopLevelParent(pWin);
+
+ return (top && WINREC(top));
+}
+
+
+/*
+ * RootlessStartDrawing
+ * Prepare a window for direct access to its backing buffer.
+ * Each top-level parent has a Pixmap representing its backing buffer,
+ * which all of its children inherit.
+ */
+void RootlessStartDrawing(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ WindowPtr top = TopLevelParent(pWindow);
+ RootlessWindowRec *winRec;
+
+ if (top == NULL)
+ return;
+ winRec = WINREC(top);
+ if (winRec == NULL)
+ return;
+
+ // Make sure the window's top-level parent is prepared for drawing.
+ if (!winRec->is_drawing) {
+ int bw = wBorderWidth(top);
+
+ SCREENREC(pScreen)->imp->StartDrawing(winRec->wid, &winRec->pixelData,
+ &winRec->bytesPerRow);
+
+ winRec->pixmap =
+ GetScratchPixmapHeader(pScreen, winRec->width, winRec->height,
+ top->drawable.depth,
+ top->drawable.bitsPerPixel,
+ winRec->bytesPerRow,
+ winRec->pixelData);
+ SetPixmapBaseToScreen(winRec->pixmap,
+ top->drawable.x - bw, top->drawable.y - bw);
+
+ winRec->is_drawing = TRUE;
+ }
+
+ winRec->oldPixmap = pScreen->GetWindowPixmap(pWindow);
+ pScreen->SetWindowPixmap(pWindow, winRec->pixmap);
+}
+
+
+/*
+ * RootlessStopDrawing
+ * Stop drawing to a window's backing buffer. If flush is true,
+ * damaged regions are flushed to the screen.
+ */
+void RootlessStopDrawing(WindowPtr pWindow, Bool flush)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ WindowPtr top = TopLevelParent(pWindow);
+ RootlessWindowRec *winRec;
+
+ if (top == NULL)
+ return;
+ winRec = WINREC(top);
+ if (winRec == NULL)
+ return;
+
+ if (winRec->is_drawing) {
+ SCREENREC(pScreen)->imp->StopDrawing(winRec->wid, flush);
+
+ FreeScratchPixmapHeader(winRec->pixmap);
+ pScreen->SetWindowPixmap(pWindow, winRec->oldPixmap);
+ winRec->pixmap = NULL;
+
+ winRec->is_drawing = FALSE;
+ }
+ else if (flush) {
+ SCREENREC(pScreen)->imp->UpdateRegion(winRec->wid, NULL);
+ }
+
+ if (flush && winRec->is_reorder_pending) {
+ winRec->is_reorder_pending = FALSE;
+ RootlessReorderWindow(pWindow);
+ }
+}
+
+
+/*
+ * RootlessDamageRegion
+ * Mark a damaged region as requiring redisplay to screen.
+ * pRegion is in GLOBAL coordinates.
+ */
+void
+RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ RootlessWindowRec *winRec;
+ RegionRec clipped;
+ WindowPtr pTop;
+ BoxPtr b1, b2;
+
+ RL_DEBUG_MSG("Damaged win 0x%x ", pWindow);
+
+ pTop = TopLevelParent(pWindow);
+ if (pTop == NULL)
+ return;
+
+ winRec = WINREC(pTop);
+ if (winRec == NULL)
+ return;
+
+ /* We need to intersect the drawn region with the clip of the window
+ to avoid marking places we didn't actually draw (which can cause
+ problems when the window has an extra client-side backing store)
+
+ But this is a costly operation and since we'll normally just be
+ drawing inside the clip, go to some lengths to avoid the general
+ case intersection. */
+
+ b1 = REGION_EXTENTS(pScreen, &pWindow->borderClip);
+ b2 = REGION_EXTENTS(pScreen, pRegion);
+
+ if (EXTENTCHECK(b1, b2)) {
+ /* Regions may overlap. */
+
+ if (REGION_NUM_RECTS(pRegion) == 1) {
+ int in;
+
+ /* Damaged region only has a single rect, so we can
+ just compare that against the region */
+
+ in = RECT_IN_REGION(pScreen, &pWindow->borderClip,
+ REGION_RECTS (pRegion));
+ if (in == rgnIN) {
+ /* clip totally contains pRegion */
+
+#ifdef ROOTLESS_TRACK_DAMAGE
+ REGION_UNION(pScreen, &winRec->damage,
+ &winRec->damage, (pRegion));
+#else
+ SCREENREC(pScreen)->imp->DamageRects(winRec->wid,
+ REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ -winRec->x, -winRec->y);
+#endif
+
+ RootlessQueueRedisplay(pTop->drawable.pScreen);
+ goto out;
+ }
+ else if (in == rgnOUT) {
+ /* clip doesn't contain pRegion */
+
+ goto out;
+ }
+ }
+
+ /* clip overlaps pRegion, need to intersect */
+
+ REGION_NULL(pScreen, &clipped);
+ REGION_INTERSECT(pScreen, &clipped, &pWindow->borderClip, pRegion);
+
+#ifdef ROOTLESS_TRACK_DAMAGE
+ REGION_UNION(pScreen, &winRec->damage,
+ &winRec->damage, (pRegion));
+#else
+ SCREENREC(pScreen)->imp->DamageRects(winRec->wid,
+ REGION_NUM_RECTS(&clipped),
+ REGION_RECTS(&clipped),
+ -winRec->x, -winRec->y);
+#endif
+
+ REGION_UNINIT(pScreen, &clipped);
+
+ RootlessQueueRedisplay(pTop->drawable.pScreen);
+ }
+
+out:
+#ifdef ROOTLESSDEBUG
+ {
+ BoxRec *box = REGION_RECTS(pRegion), *end;
+ int numBox = REGION_NUM_RECTS(pRegion);
+
+ for (end = box+numBox; box < end; box++) {
+ RL_DEBUG_MSG("Damage rect: %i, %i, %i, %i\n",
+ box->x1, box->x2, box->y1, box->y2);
+ }
+ }
+#endif
+ return;
+}
+
+
+/*
+ * RootlessDamageBox
+ * Mark a damaged box as requiring redisplay to screen.
+ * pRegion is in GLOBAL coordinates.
+ */
+void
+RootlessDamageBox(WindowPtr pWindow, BoxPtr pBox)
+{
+ RegionRec region;
+
+ REGION_INIT(pWindow->drawable.pScreen, &region, pBox, 1);
+
+ RootlessDamageRegion(pWindow, &region);
+
+ REGION_UNINIT(pWindow->drawable.pScreen, &region); /* no-op */
+}
+
+
+/*
+ * RootlessDamageRect
+ * Mark a damaged rectangle as requiring redisplay to screen.
+ * (x, y, w, h) is in window-local coordinates.
+ */
+void
+RootlessDamageRect(WindowPtr pWindow, int x, int y, int w, int h)
+{
+ BoxRec box;
+ RegionRec region;
+
+ x += pWindow->drawable.x;
+ y += pWindow->drawable.y;
+
+ box.x1 = x;
+ box.x2 = x + w;
+ box.y1 = y;
+ box.y2 = y + h;
+
+ REGION_INIT(pWindow->drawable.pScreen, &region, &box, 1);
+
+ RootlessDamageRegion(pWindow, &region);
+
+ REGION_UNINIT(pWindow->drawable.pScreen, &region); /* no-op */
+}
+
+
+/*
+ * RootlessRedisplay
+ * Stop drawing and redisplay the damaged region of a window.
+ */
+void
+RootlessRedisplay(WindowPtr pWindow)
+{
+#ifdef ROOTLESS_TRACK_DAMAGE
+
+ RootlessWindowRec *winRec = WINREC(pWindow);
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+
+ RootlessStopDrawing(pWindow, FALSE);
+
+ if (REGION_NOTEMPTY(pScreen, &winRec->damage)) {
+ RL_DEBUG_MSG("Redisplay Win 0x%x, %i x %i @ (%i, %i)\n",
+ pWindow, winRec->width, winRec->height,
+ winRec->x, winRec->y);
+
+ // move region to window local coords
+ REGION_TRANSLATE(pScreen, &winRec->damage,
+ -winRec->x, -winRec->y);
+
+ SCREENREC(pScreen)->imp->UpdateRegion(winRec->wid, &winRec->damage);
+
+ REGION_EMPTY(pScreen, &winRec->damage);
+ }
+
+#else /* !ROOTLESS_TRACK_DAMAGE */
+
+ RootlessStopDrawing(pWindow, TRUE);
+
+#endif
+}
+
+
+/*
+ * RootlessRepositionWindows
+ * Reposition all windows on a screen to their correct positions.
+ */
+void
+RootlessRepositionWindows(ScreenPtr pScreen)
+{
+ WindowPtr root = WindowTable[pScreen->myNum];
+ WindowPtr win;
+
+ if (root != NULL) {
+ RootlessRepositionWindow(root);
+
+ for (win = root->firstChild; win; win = win->nextSib) {
+ if (WINREC(win) != NULL)
+ RootlessRepositionWindow(win);
+ }
+ }
+}
+
+
+/*
+ * RootlessRedisplayScreen
+ * Walk every window on a screen and redisplay the damaged regions.
+ */
+void
+RootlessRedisplayScreen(ScreenPtr pScreen)
+{
+ WindowPtr root = WindowTable[pScreen->myNum];
+
+ if (root != NULL) {
+ WindowPtr win;
+
+ RootlessRedisplay(root);
+ for (win = root->firstChild; win; win = win->nextSib) {
+ if (WINREC(win) != NULL) {
+ RootlessRedisplay(win);
+ }
+ }
+ }
+}
diff --git a/nx-X11/programs/Xserver/miext/rootless/rootlessCommon.h b/nx-X11/programs/Xserver/miext/rootless/rootlessCommon.h
new file mode 100644
index 000000000..beb1fd666
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/rootlessCommon.h
@@ -0,0 +1,261 @@
+/*
+ * Common internal rootless definitions and code
+ */
+/*
+ * Copyright (c) 2001 Greg Parker. All Rights Reserved.
+ * Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessCommon.h,v 1.5 2004/07/02 01:30:33 torrey Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _ROOTLESSCOMMON_H
+#define _ROOTLESSCOMMON_H
+
+#include "rootless.h"
+#include "fb.h"
+
+#ifdef RENDER
+#include "picturestr.h"
+#endif
+
+
+// Debug output, or not.
+#ifdef ROOTLESSDEBUG
+#define RL_DEBUG_MSG ErrorF
+#else
+#define RL_DEBUG_MSG(a, ...)
+#endif
+
+
+// Global variables
+extern int rootlessGCPrivateIndex;
+extern int rootlessScreenPrivateIndex;
+extern int rootlessWindowPrivateIndex;
+
+
+// RootlessGCRec: private per-gc data
+typedef struct {
+ GCFuncs *originalFuncs;
+ GCOps *originalOps;
+} RootlessGCRec;
+
+
+// RootlessScreenRec: per-screen private data
+typedef struct _RootlessScreenRec {
+ // Rootless implementation functions
+ RootlessFrameProcsPtr imp;
+
+ // Wrapped screen functions
+ CreateScreenResourcesProcPtr CreateScreenResources;
+ CloseScreenProcPtr CloseScreen;
+
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ MoveWindowProcPtr MoveWindow;
+ ResizeWindowProcPtr ResizeWindow;
+ RestackWindowProcPtr RestackWindow;
+ ReparentWindowProcPtr ReparentWindow;
+ ChangeBorderWidthProcPtr ChangeBorderWidth;
+ PositionWindowProcPtr PositionWindow;
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+
+ CreateGCProcPtr CreateGC;
+ PaintWindowBackgroundProcPtr PaintWindowBackground;
+ PaintWindowBorderProcPtr PaintWindowBorder;
+ CopyWindowProcPtr CopyWindow;
+ GetImageProcPtr GetImage;
+ SourceValidateProcPtr SourceValidate;
+
+ MarkOverlappedWindowsProcPtr MarkOverlappedWindows;
+ ValidateTreeProcPtr ValidateTree;
+
+#ifdef SHAPE
+ SetShapeProcPtr SetShape;
+#endif
+
+#ifdef RENDER
+ CompositeProcPtr Composite;
+ GlyphsProcPtr Glyphs;
+#endif
+
+ void *pixmap_data;
+ unsigned int pixmap_data_size;
+
+ void *redisplay_timer;
+ unsigned int redisplay_timer_set :1;
+ unsigned int redisplay_queued :1;
+ unsigned int redisplay_expired :1;
+} RootlessScreenRec, *RootlessScreenPtr;
+
+
+#undef MIN
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
+#undef MAX
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+
+// "Definition of the Porting Layer for the X11 Sample Server" says
+// unwrap and rewrap of screen functions is unnecessary, but
+// screen->CreateGC changes after a call to cfbCreateGC.
+
+#define SCREEN_UNWRAP(screen, fn) \
+ screen->fn = SCREENREC(screen)->fn;
+
+#define SCREEN_WRAP(screen, fn) \
+ SCREENREC(screen)->fn = screen->fn; \
+ screen->fn = Rootless##fn
+
+
+// Accessors for screen and window privates
+
+#define SCREENREC(pScreen) \
+ ((RootlessScreenRec *)(pScreen)->devPrivates[rootlessScreenPrivateIndex].ptr)
+
+#define WINREC(pWin) \
+ ((RootlessWindowRec *)(pWin)->devPrivates[rootlessWindowPrivateIndex].ptr)
+
+
+// Call a rootless implementation function.
+// Many rootless implementation functions are allowed to be NULL.
+#define CallFrameProc(pScreen, proc, params) \
+ if (SCREENREC(pScreen)->frameProcs.proc) { \
+ RL_DEBUG_MSG("calling frame proc " #proc " "); \
+ SCREENREC(pScreen)->frameProcs.proc params; \
+ }
+
+
+// BoxRec manipulators
+// Copied from shadowfb
+
+#define TRIM_BOX(box, pGC) { \
+ BoxPtr extents = &pGC->pCompositeClip->extents;\
+ if(box.x1 < extents->x1) box.x1 = extents->x1; \
+ if(box.x2 > extents->x2) box.x2 = extents->x2; \
+ if(box.y1 < extents->y1) box.y1 = extents->y1; \
+ if(box.y2 > extents->y2) box.y2 = extents->y2; \
+}
+
+#define TRANSLATE_BOX(box, pDraw) { \
+ box.x1 += pDraw->x; \
+ box.x2 += pDraw->x; \
+ box.y1 += pDraw->y; \
+ box.y2 += pDraw->y; \
+}
+
+#define TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC) { \
+ TRANSLATE_BOX(box, pDraw); \
+ TRIM_BOX(box, pGC); \
+}
+
+#define BOX_NOT_EMPTY(box) \
+ (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0))
+
+
+// HUGE_ROOT and NORMAL_ROOT
+// We don't want to clip windows to the edge of the screen.
+// HUGE_ROOT temporarily makes the root window really big.
+// This is needed as a wrapper around any function that calls
+// SetWinSize or SetBorderSize which clip a window against its
+// parents, including the root.
+
+extern RegionRec rootlessHugeRoot;
+
+#define HUGE_ROOT(pWin) \
+ do { \
+ WindowPtr w = pWin; \
+ while (w->parent) \
+ w = w->parent; \
+ saveRoot = w->winSize; \
+ w->winSize = rootlessHugeRoot; \
+ } while (0)
+
+#define NORMAL_ROOT(pWin) \
+ do { \
+ WindowPtr w = pWin; \
+ while (w->parent) \
+ w = w->parent; \
+ w->winSize = saveRoot; \
+ } while (0)
+
+
+// Returns TRUE if this window is a top-level window (i.e. child of the root)
+// The root is not a top-level window.
+#define IsTopLevel(pWin) \
+ ((pWin) && (pWin)->parent && !(pWin)->parent->parent)
+
+// Returns TRUE if this window is a root window
+#define IsRoot(pWin) \
+ ((pWin) == WindowTable[(pWin)->drawable.pScreen->myNum])
+
+
+/*
+ * SetPixmapBaseToScreen
+ * Move the given pixmap's base address to where pixel (0, 0)
+ * would be if the pixmap's actual data started at (x, y).
+ * Can't access the bits before the first word of the drawable's data in
+ * rootless mode, so make sure our base address is always 32-bit aligned.
+ */
+#define SetPixmapBaseToScreen(pix, _x, _y) { \
+ PixmapPtr _pPix = (PixmapPtr) (pix); \
+ _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
+ ((int)(_x) * _pPix->drawable.bitsPerPixel/8 + \
+ (int)(_y) * _pPix->devKind); \
+ if (_pPix->drawable.bitsPerPixel != FB_UNIT) { \
+ unsigned _diff = ((unsigned) _pPix->devPrivate.ptr) & \
+ (FB_UNIT / CHAR_BIT - 1); \
+ _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
+ _diff; \
+ _pPix->drawable.x = _diff / \
+ (_pPix->drawable.bitsPerPixel / CHAR_BIT); \
+ } \
+}
+
+
+// Returns TRUE if this window is visible inside a frame
+// (e.g. it is visible and has a top-level or root parent)
+Bool IsFramedWindow(WindowPtr pWin);
+
+// Routines that cause regions to get redrawn.
+// DamageRegion and DamageRect are in global coordinates.
+// DamageBox is in window-local coordinates.
+void RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion);
+void RootlessDamageRect(WindowPtr pWindow, int x, int y, int w, int h);
+void RootlessDamageBox(WindowPtr pWindow, BoxPtr pBox);
+void RootlessRedisplay(WindowPtr pWindow);
+void RootlessRedisplayScreen(ScreenPtr pScreen);
+
+void RootlessQueueRedisplay(ScreenPtr pScreen);
+
+// Move a window to its proper location on the screen.
+void RootlessRepositionWindow(WindowPtr pWin);
+
+// Move the window to it's correct place in the physical stacking order.
+void RootlessReorderWindow(WindowPtr pWin);
+
+#endif /* _ROOTLESSCOMMON_H */
diff --git a/nx-X11/programs/Xserver/miext/rootless/rootlessConfig.h b/nx-X11/programs/Xserver/miext/rootless/rootlessConfig.h
new file mode 100644
index 000000000..eabbaef43
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/rootlessConfig.h
@@ -0,0 +1,68 @@
+/*
+ * Platform specific rootless configuration
+ */
+/*
+ * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessConfig.h,v 1.1 2003/04/15 01:05:44 torrey Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _ROOTLESSCONFIG_H
+#define _ROOTLESSCONFIG_H
+
+#ifdef __DARWIN__
+
+# define ROOTLESS_ACCEL TRUE
+# define ROOTLESS_GLOBAL_COORDS TRUE
+# define ROOTLESS_PROTECT_ALPHA TRUE
+# define ROOTLESS_REDISPLAY_DELAY 10
+# define ROOTLESS_RESIZE_GRAVITY TRUE
+# undef ROOTLESS_TRACK_DAMAGE
+
+/* Bit mask for alpha channel with a particular number of bits per
+ pixel. Note that we only care for 32bpp data. Mac OS X uses planar
+ alpha for 16bpp. */
+# define RootlessAlphaMask(bpp) ((bpp) == 32 ? 0xFF000000 : 0)
+
+#endif /* __DARWIN__ */
+
+#if defined(__CYGWIN__) || defined(WIN32)
+
+# define ROOTLESS_ACCEL YES
+# define ROOTLESS_GLOBAL_COORDS TRUE
+# define ROOTLESS_PROTECT_ALPHA NO
+# define ROOTLESS_REDISPLAY_DELAY 10
+# undef ROOTLESS_RESIZE_GRAVITY
+# undef ROOTLESS_TRACK_DAMAGE
+/*# define ROOTLESSDEBUG*/
+
+# define RootlessAlphaMask(bpp) ((bpp) == 32 ? 0xFF000000 : 0)
+
+#endif /* __CYGWIN__ */
+
+#endif /* _ROOTLESSCONFIG_H */
diff --git a/nx-X11/programs/Xserver/miext/rootless/rootlessGC.c b/nx-X11/programs/Xserver/miext/rootless/rootlessGC.c
new file mode 100644
index 000000000..61987addb
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/rootlessGC.c
@@ -0,0 +1,1508 @@
+/*
+ * Graphics Context support for generic rootless X server
+ */
+/*
+ * Copyright (c) 2001 Greg Parker. All Rights Reserved.
+ * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessGC.c,v 1.1 2003/04/15 01:05:44 torrey Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "mi.h"
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "dixfontstr.h"
+#include "mivalidate.h"
+#include "fb.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "rootlessCommon.h"
+
+
+// GC functions
+static void RootlessValidateGC(GCPtr pGC, unsigned long changes,
+ DrawablePtr pDrawable);
+static void RootlessChangeGC(GCPtr pGC, unsigned long mask);
+static void RootlessCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
+static void RootlessDestroyGC(GCPtr pGC);
+static void RootlessChangeClip(GCPtr pGC, int type, pointer pvalue,
+ int nrects);
+static void RootlessDestroyClip(GCPtr pGC);
+static void RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
+
+GCFuncs rootlessGCFuncs = {
+ RootlessValidateGC,
+ RootlessChangeGC,
+ RootlessCopyGC,
+ RootlessDestroyGC,
+ RootlessChangeClip,
+ RootlessDestroyClip,
+ RootlessCopyClip,
+};
+
+// GC operations
+static void RootlessFillSpans();
+static void RootlessSetSpans();
+static void RootlessPutImage();
+static RegionPtr RootlessCopyArea();
+static RegionPtr RootlessCopyPlane();
+static void RootlessPolyPoint();
+static void RootlessPolylines();
+static void RootlessPolySegment();
+static void RootlessPolyRectangle();
+static void RootlessPolyArc();
+static void RootlessFillPolygon();
+static void RootlessPolyFillRect();
+static void RootlessPolyFillArc();
+static int RootlessPolyText8();
+static int RootlessPolyText16();
+static void RootlessImageText8();
+static void RootlessImageText16();
+static void RootlessImageGlyphBlt();
+static void RootlessPolyGlyphBlt();
+static void RootlessPushPixels();
+
+static GCOps rootlessGCOps = {
+ RootlessFillSpans,
+ RootlessSetSpans,
+ RootlessPutImage,
+ RootlessCopyArea,
+ RootlessCopyPlane,
+ RootlessPolyPoint,
+ RootlessPolylines,
+ RootlessPolySegment,
+ RootlessPolyRectangle,
+ RootlessPolyArc,
+ RootlessFillPolygon,
+ RootlessPolyFillRect,
+ RootlessPolyFillArc,
+ RootlessPolyText8,
+ RootlessPolyText16,
+ RootlessImageText8,
+ RootlessImageText16,
+ RootlessImageGlyphBlt,
+ RootlessPolyGlyphBlt,
+ RootlessPushPixels
+#ifdef NEED_LINEHELPER
+ , NULL
+#endif
+};
+
+/*
+ There are two issues we must contend with when drawing. These are
+ controlled with ROOTLESS_PROTECT_ALPHA and ROOTLESS_ACCEL.
+
+ If ROOTLESS_PROTECT_ALPHA is set, we have to make sure that the alpha
+ channel of the on screen windows is always opaque. fb makes this harder
+ than it would otherwise be by noticing that a planemask of 0x00ffffff
+ includes all bits when depth==24, and so it "optimizes" the planemask to
+ 0xffffffff. We work around this by temporarily setting depth=bpp while
+ changing the GC.
+
+ So the normal situation (in 32 bit mode) is that the planemask is
+ 0x00ffffff and thus fb leaves the alpha channel alone. The rootless
+ implementation is responsible for setting the alpha channel opaque
+ initially.
+
+ Unfortunately drawing with a planemask that doesn't have all bits set
+ normally causes fb to fall off its fastest paths when blitting and
+ filling. So we try to recognize when we can relax the planemask back to
+ 0xffffffff, and do that for the duration of the drawing operation,
+ setting the alpha channel in fg/bg pixels to opaque at the same time. We
+ can do this when drawing op is GXcopy. We can also do this when copying
+ from another window since its alpha channel must also be opaque.
+
+ The other issue to consider is that the rootless implementation may
+ provide accelerated drawing functions if ROOTLESS_ACCEL is set. For some
+ drawing primitives we swap in rootless acceleration functions, which use
+ the accelerated drawing functions where possible.
+
+ Where both alpha protection and acceleration is used, it is even a bigger
+ win to relax the planemask to all ones because most accelerated drawing
+ functions can only be used in this case. However, even if we can't set
+ the planemask to all ones, we can still use the accelerated
+ CompositePixels function for GXcopy if it is a forward copy. This is
+ mainly intended for copying from pixmaps to windows. The CompositePixels
+ operation used sets alpha to 0xFF during the copy.
+
+ The three macros below are used to implement this, potentially accelerated
+ drawing ops look something like this:
+
+ OP {
+ GC_SAVE(gc);
+ GCOP_UNWRAP(gc);
+
+ ...
+
+ if (canAccelxxx(..) && otherwise-suitable)
+ GC_UNSET_PM(gc, dst);
+
+ gc->funcs->OP(gc, ...);
+
+ GC_RESTORE(gc, dst);
+ GCOP_WRAP(gc);
+ }
+
+ */
+
+#define GC_SAVE(pGC) \
+ unsigned long _save_fg = (pGC)->fgPixel; \
+ unsigned long _save_bg = (pGC)->bgPixel; \
+ unsigned long _save_pm = (pGC)->planemask; \
+ Bool _changed = FALSE
+
+#define GC_RESTORE(pGC, pDraw) \
+ do { \
+ if (_changed) { \
+ unsigned int depth = (pDraw)->depth; \
+ (pGC)->fgPixel = _save_fg; \
+ (pGC)->bgPixel = _save_bg; \
+ (pGC)->planemask = _save_pm; \
+ (pDraw)->depth = (pDraw)->bitsPerPixel; \
+ VALIDATE_GC(pGC, GCForeground | GCBackground | \
+ GCPlaneMask, pDraw); \
+ (pDraw)->depth = depth; \
+ } \
+ } while (0)
+
+#define GC_UNSET_PM(pGC, pDraw) \
+ do { \
+ unsigned int mask = RootlessAlphaMask ((pDraw)->bitsPerPixel); \
+ if (((pGC)->planemask & mask) != mask) { \
+ unsigned int depth = (pDraw)->depth; \
+ (pGC)->fgPixel |= mask; \
+ (pGC)->bgPixel |= mask; \
+ (pGC)->planemask |= mask; \
+ (pDraw)->depth = (pDraw)->bitsPerPixel; \
+ VALIDATE_GC(pGC, GCForeground | \
+ GCBackground | GCPlaneMask, pDraw); \
+ (pDraw)->depth = depth; \
+ _changed = TRUE; \
+ } \
+ } while (0)
+
+#define VALIDATE_GC(pGC, changes, pDrawable) \
+ do { \
+ pGC->funcs->ValidateGC(pGC, changes, pDrawable); \
+ if (((WindowPtr) pDrawable)->viewable) { \
+ gcrec->originalOps = pGC->ops; \
+ } \
+ } while(0)
+
+static RootlessWindowRec *
+canAccelBlit (DrawablePtr pDraw, GCPtr pGC)
+{
+ WindowPtr pTop;
+ RootlessWindowRec *winRec;
+ unsigned int pm;
+
+ if (pGC->alu != GXcopy)
+ return NULL;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return NULL;
+
+ pm = ~RootlessAlphaMask(pDraw->bitsPerPixel);
+ if ((pGC->planemask & pm) != pm)
+ return NULL;
+
+ pTop = TopLevelParent((WindowPtr) pDraw);
+ if (pTop == NULL)
+ return NULL;
+
+ winRec = WINREC(pTop);
+ if (winRec == NULL)
+ return NULL;
+
+ return winRec;
+}
+
+static inline RootlessWindowRec *
+canAccelFill(DrawablePtr pDraw, GCPtr pGC)
+{
+ if (pGC->fillStyle != FillSolid)
+ return NULL;
+
+ return canAccelBlit(pDraw, pGC);
+}
+
+static unsigned int
+boxBytes(DrawablePtr pDraw, BoxRec *box)
+{
+ unsigned int pixels;
+
+ pixels = (box->x2 - box->x1) * (box->y2 - box->y1);
+
+ return pixels * (pDraw->bitsPerPixel >> 3);
+}
+
+
+/*
+ * Screen function to create a graphics context
+ */
+Bool
+RootlessCreateGC(GCPtr pGC)
+{
+ RootlessGCRec *gcrec;
+ RootlessScreenRec *s;
+ Bool result;
+
+ SCREEN_UNWRAP(pGC->pScreen, CreateGC);
+ s = (RootlessScreenRec *) pGC->pScreen->
+ devPrivates[rootlessScreenPrivateIndex].ptr;
+ result = s->CreateGC(pGC);
+
+ gcrec = (RootlessGCRec *) pGC->devPrivates[rootlessGCPrivateIndex].ptr;
+ gcrec->originalOps = NULL; // don't wrap ops yet
+ gcrec->originalFuncs = pGC->funcs;
+ pGC->funcs = &rootlessGCFuncs;
+
+ SCREEN_WRAP(pGC->pScreen, CreateGC);
+ return result;
+}
+
+
+/*
+ * GC funcs
+ *
+ * These wrap lower level GC funcs.
+ * ValidateGC wraps the GC ops iff dest is viewable.
+ * All the others just unwrap and call.
+ */
+
+// GCFUNC_UNRAP assumes funcs have been wrapped and
+// does not assume ops have been wrapped
+#define GCFUNC_UNWRAP(pGC) \
+ RootlessGCRec *gcrec = (RootlessGCRec *) \
+ (pGC)->devPrivates[rootlessGCPrivateIndex].ptr; \
+ (pGC)->funcs = gcrec->originalFuncs; \
+ if (gcrec->originalOps) { \
+ (pGC)->ops = gcrec->originalOps; \
+}
+
+#define GCFUNC_WRAP(pGC) \
+ gcrec->originalFuncs = (pGC)->funcs; \
+ (pGC)->funcs = &rootlessGCFuncs; \
+ if (gcrec->originalOps) { \
+ gcrec->originalOps = (pGC)->ops; \
+ (pGC)->ops = &rootlessGCOps; \
+}
+
+
+static void
+RootlessValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
+{
+ GCFUNC_UNWRAP(pGC);
+
+ gcrec->originalOps = NULL;
+
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ {
+#ifdef ROOTLESS_PROTECT_ALPHA
+ unsigned int depth = pDrawable->depth;
+
+ // We force a planemask so fb doesn't overwrite the alpha channel.
+ // Left to its own devices, fb will optimize away the planemask.
+ pDrawable->depth = pDrawable->bitsPerPixel;
+ pGC->planemask &= ~RootlessAlphaMask(pDrawable->bitsPerPixel);
+ VALIDATE_GC(pGC, changes | GCPlaneMask, pDrawable);
+ pDrawable->depth = depth;
+#else
+ VALIDATE_GC(pGC, changes, pDrawable);
+#endif
+ } else {
+ pGC->funcs->ValidateGC(pGC, changes, pDrawable);
+ }
+
+ GCFUNC_WRAP(pGC);
+}
+
+static void RootlessChangeGC(GCPtr pGC, unsigned long mask)
+{
+ GCFUNC_UNWRAP(pGC);
+ pGC->funcs->ChangeGC(pGC, mask);
+ GCFUNC_WRAP(pGC);
+}
+
+static void RootlessCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
+{
+ GCFUNC_UNWRAP(pGCDst);
+ pGCDst->funcs->CopyGC(pGCSrc, mask, pGCDst);
+ GCFUNC_WRAP(pGCDst);
+}
+
+static void RootlessDestroyGC(GCPtr pGC)
+{
+ GCFUNC_UNWRAP(pGC);
+ pGC->funcs->DestroyGC(pGC);
+ GCFUNC_WRAP(pGC);
+}
+
+static void RootlessChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects)
+{
+ GCFUNC_UNWRAP(pGC);
+ pGC->funcs->ChangeClip(pGC, type, pvalue, nrects);
+ GCFUNC_WRAP(pGC);
+}
+
+static void RootlessDestroyClip(GCPtr pGC)
+{
+ GCFUNC_UNWRAP(pGC);
+ pGC->funcs->DestroyClip(pGC);
+ GCFUNC_WRAP(pGC);
+}
+
+static void RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
+{
+ GCFUNC_UNWRAP(pgcDst);
+ pgcDst->funcs->CopyClip(pgcDst, pgcSrc);
+ GCFUNC_WRAP(pgcDst);
+}
+
+
+/*
+ * GC ops
+ *
+ * We can't use shadowfb because shadowfb assumes one pixmap
+ * and our root window is a special case.
+ * However, much of this code is copied from shadowfb.
+ */
+
+// assumes both funcs and ops are wrapped
+#define GCOP_UNWRAP(pGC) \
+ RootlessGCRec *gcrec = (RootlessGCRec *) \
+ (pGC)->devPrivates[rootlessGCPrivateIndex].ptr; \
+ GCFuncs *saveFuncs = pGC->funcs; \
+ (pGC)->funcs = gcrec->originalFuncs; \
+ (pGC)->ops = gcrec->originalOps;
+
+#define GCOP_WRAP(pGC) \
+ gcrec->originalOps = (pGC)->ops; \
+ (pGC)->funcs = saveFuncs; \
+ (pGC)->ops = &rootlessGCOps;
+
+/* Turn drawing on the root into a no-op */
+#define GC_IS_ROOT(pDst) ((pDst)->type == DRAWABLE_WINDOW \
+ && IsRoot ((WindowPtr) (pDst)))
+
+#define GC_SKIP_ROOT(pDst) \
+ do { \
+ if (GC_IS_ROOT (pDst)) \
+ return; \
+ } while (0)
+
+
+static void
+RootlessFillSpans(DrawablePtr dst, GCPtr pGC, int nInit,
+ DDXPointPtr pptInit, int *pwidthInit, int sorted)
+{
+ GC_SAVE(pGC);
+ GCOP_UNWRAP(pGC);
+ GC_SKIP_ROOT(dst);
+ RL_DEBUG_MSG("fill spans start ");
+
+ if (nInit <= 0) {
+ pGC->ops->FillSpans(dst, pGC, nInit, pptInit, pwidthInit, sorted);
+ } else {
+ DDXPointPtr ppt = pptInit;
+ int *pwidth = pwidthInit;
+ int i = nInit;
+ BoxRec box;
+
+ box.x1 = ppt->x;
+ box.x2 = box.x1 + *pwidth;
+ box.y2 = box.y1 = ppt->y;
+
+ while (--i) {
+ ppt++;
+ pwidth++;
+ if (box.x1 > ppt->x)
+ box.x1 = ppt->x;
+ if (box.x2 < (ppt->x + *pwidth))
+ box.x2 = ppt->x + *pwidth;
+ if (box.y1 > ppt->y)
+ box.y1 = ppt->y;
+ else if (box.y2 < ppt->y)
+ box.y2 = ppt->y;
+ }
+
+ box.y2++;
+
+ RootlessStartDrawing((WindowPtr) dst);
+
+ if (canAccelFill(dst, pGC) &&
+ boxBytes(dst, &box) >= rootless_FillBytes_threshold)
+ {
+ GC_UNSET_PM(pGC, dst);
+ }
+
+ pGC->ops->FillSpans(dst, pGC, nInit, pptInit, pwidthInit, sorted);
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GC_RESTORE(pGC, dst);
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("fill spans end\n");
+}
+
+static void
+RootlessSetSpans(DrawablePtr dst, GCPtr pGC, char *pSrc,
+ DDXPointPtr pptInit, int *pwidthInit,
+ int nspans, int sorted)
+{
+ GCOP_UNWRAP(pGC);
+ GC_SKIP_ROOT(dst);
+ RL_DEBUG_MSG("set spans start ");
+
+ if (nspans <= 0) {
+ pGC->ops->SetSpans(dst, pGC, pSrc, pptInit, pwidthInit,
+ nspans, sorted);
+ } else {
+ DDXPointPtr ppt = pptInit;
+ int *pwidth = pwidthInit;
+ int i = nspans;
+ BoxRec box;
+
+ box.x1 = ppt->x;
+ box.x2 = box.x1 + *pwidth;
+ box.y2 = box.y1 = ppt->y;
+
+ while (--i) {
+ ppt++;
+ pwidth++;
+ if (box.x1 > ppt->x)
+ box.x1 = ppt->x;
+ if (box.x2 < (ppt->x + *pwidth))
+ box.x2 = ppt->x + *pwidth;
+ if (box.y1 > ppt->y)
+ box.y1 = ppt->y;
+ else if (box.y2 < ppt->y)
+ box.y2 = ppt->y;
+ }
+
+ box.y2++;
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->SetSpans(dst, pGC, pSrc, pptInit, pwidthInit,
+ nspans, sorted);
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("set spans end\n");
+}
+
+static void
+RootlessPutImage(DrawablePtr dst, GCPtr pGC,
+ int depth, int x, int y, int w, int h,
+ int leftPad, int format, char *pBits)
+{
+ BoxRec box;
+
+ GCOP_UNWRAP(pGC);
+ GC_SKIP_ROOT(dst);
+ RL_DEBUG_MSG("put image start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->PutImage(dst, pGC, depth, x,y,w,h, leftPad, format, pBits);
+
+ box.x1 = x + dst->x;
+ box.x2 = box.x1 + w;
+ box.y1 = y + dst->y;
+ box.y2 = box.y1 + h;
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("put image end\n");
+}
+
+/* changed area is *dest* rect */
+static RegionPtr
+RootlessCopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC,
+ int srcx, int srcy, int w, int h,
+ int dstx, int dsty)
+{
+ RegionPtr result;
+ BoxRec box;
+
+ GC_SAVE(pGC);
+ GCOP_UNWRAP(pGC);
+
+ if (GC_IS_ROOT(dst) || GC_IS_ROOT(pSrc))
+ return NULL; /* nothing exposed */
+
+ RL_DEBUG_MSG("copy area start (src 0x%x, dst 0x%x)", pSrc, dst);
+
+ if (pSrc->type == DRAWABLE_WINDOW && IsFramedWindow((WindowPtr)pSrc)) {
+ unsigned int bytes;
+
+ /* If both source and dest are windows, and we're doing
+ a simple copy operation, we can remove the alpha-protecting
+ planemask (since source has opaque alpha as well) */
+
+ bytes = w * h * (pSrc->depth >> 3);
+
+ if (bytes >= rootless_CopyBytes_threshold && canAccelBlit(pSrc, pGC))
+ {
+ GC_UNSET_PM(pGC, dst);
+ }
+
+ RootlessStartDrawing((WindowPtr) pSrc);
+ }
+ RootlessStartDrawing((WindowPtr) dst);
+ result = pGC->ops->CopyArea(pSrc, dst, pGC, srcx, srcy, w, h, dstx, dsty);
+
+ box.x1 = dstx + dst->x;
+ box.x2 = box.x1 + w;
+ box.y1 = dsty + dst->y;
+ box.y2 = box.y1 + h;
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ GC_RESTORE(pGC, dst);
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("copy area end\n");
+ return result;
+}
+
+/* changed area is *dest* rect */
+static RegionPtr RootlessCopyPlane(DrawablePtr pSrc, DrawablePtr dst,
+ GCPtr pGC, int srcx, int srcy,
+ int w, int h, int dstx, int dsty,
+ unsigned long plane)
+{
+ RegionPtr result;
+ BoxRec box;
+
+ GCOP_UNWRAP(pGC);
+
+ if (GC_IS_ROOT(dst) || GC_IS_ROOT(pSrc))
+ return NULL; /* nothing exposed */
+
+ RL_DEBUG_MSG("copy plane start ");
+
+ if (pSrc->type == DRAWABLE_WINDOW && IsFramedWindow((WindowPtr)pSrc)) {
+ RootlessStartDrawing((WindowPtr) pSrc);
+ }
+ RootlessStartDrawing((WindowPtr) dst);
+ result = pGC->ops->CopyPlane(pSrc, dst, pGC, srcx, srcy, w, h,
+ dstx, dsty, plane);
+
+ box.x1 = dstx + dst->x;
+ box.x2 = box.x1 + w;
+ box.y1 = dsty + dst->y;
+ box.y2 = box.y1 + h;
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("copy plane end\n");
+ return result;
+}
+
+// Options for size of changed area:
+// 0 = box per point
+// 1 = big box around all points
+// 2 = accumulate point in 20 pixel radius
+#define ROOTLESS_CHANGED_AREA 1
+#define abs(a) ((a) > 0 ? (a) : -(a))
+
+/* changed area is box around all points */
+static void RootlessPolyPoint(DrawablePtr dst, GCPtr pGC,
+ int mode, int npt, DDXPointPtr pptInit)
+{
+ GCOP_UNWRAP(pGC);
+ GC_SKIP_ROOT(dst);
+ RL_DEBUG_MSG("polypoint start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->PolyPoint(dst, pGC, mode, npt, pptInit);
+
+ if (npt > 0) {
+#if ROOTLESS_CHANGED_AREA==0
+ // box per point
+ BoxRec box;
+
+ while (npt) {
+ box.x1 = pptInit->x;
+ box.y1 = pptInit->y;
+ box.x2 = box.x1 + 1;
+ box.y2 = box.y1 + 1;
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ npt--;
+ pptInit++;
+ }
+
+#elif ROOTLESS_CHANGED_AREA==1
+ // one big box
+ BoxRec box;
+
+ box.x2 = box.x1 = pptInit->x;
+ box.y2 = box.y1 = pptInit->y;
+ while (--npt) {
+ pptInit++;
+ if (box.x1 > pptInit->x)
+ box.x1 = pptInit->x;
+ else if (box.x2 < pptInit->x)
+ box.x2 = pptInit->x;
+ if (box.y1 > pptInit->y)
+ box.y1 = pptInit->y;
+ else if (box.y2 < pptInit->y)
+ box.y2 = pptInit->y;
+ }
+
+ box.x2++;
+ box.y2++;
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+#elif ROOTLESS_CHANGED_AREA==2
+ // clever(?) method: accumulate point in 20-pixel radius
+ BoxRec box;
+ int firstx, firsty;
+
+ box.x2 = box.x1 = firstx = pptInit->x;
+ box.y2 = box.y1 = firsty = pptInit->y;
+ while (--npt) {
+ pptInit++;
+ if (abs(pptInit->x - firstx) > 20 ||
+ abs(pptInit->y - firsty) > 20) {
+ box.x2++;
+ box.y2++;
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ box.x2 = box.x1 = firstx = pptInit->x;
+ box.y2 = box.y1 = firsty = pptInit->y;
+ } else {
+ if (box.x1 > pptInit->x) box.x1 = pptInit->x;
+ else if (box.x2 < pptInit->x) box.x2 = pptInit->x;
+ if (box.y1 > pptInit->y) box.y1 = pptInit->y;
+ else if (box.y2 < pptInit->y) box.y2 = pptInit->y;
+ }
+ }
+ box.x2++;
+ box.y2++;
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox((WindowPtr) dst, &box);
+#endif /* ROOTLESS_CHANGED_AREA */
+ }
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("polypoint end\n");
+}
+
+#undef ROOTLESS_CHANGED_AREA
+
+/* changed area is box around each line */
+static void RootlessPolylines(DrawablePtr dst, GCPtr pGC,
+ int mode, int npt, DDXPointPtr pptInit)
+{
+ GCOP_UNWRAP(pGC);
+ GC_SKIP_ROOT(dst);
+ RL_DEBUG_MSG("poly lines start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->Polylines(dst, pGC, mode, npt, pptInit);
+
+ if (npt > 0) {
+ BoxRec box;
+ int extra = pGC->lineWidth >> 1;
+
+ box.x2 = box.x1 = pptInit->x;
+ box.y2 = box.y1 = pptInit->y;
+
+ if (npt > 1) {
+ if (pGC->joinStyle == JoinMiter)
+ extra = 6 * pGC->lineWidth;
+ else if (pGC->capStyle == CapProjecting)
+ extra = pGC->lineWidth;
+ }
+
+ if (mode == CoordModePrevious) {
+ int x = box.x1;
+ int y = box.y1;
+
+ while (--npt) {
+ pptInit++;
+ x += pptInit->x;
+ y += pptInit->y;
+ if (box.x1 > x)
+ box.x1 = x;
+ else if (box.x2 < x)
+ box.x2 = x;
+ if (box.y1 > y)
+ box.y1 = y;
+ else if (box.y2 < y)
+ box.y2 = y;
+ }
+ } else {
+ while (--npt) {
+ pptInit++;
+ if (box.x1 > pptInit->x)
+ box.x1 = pptInit->x;
+ else if (box.x2 < pptInit->x)
+ box.x2 = pptInit->x;
+ if (box.y1 > pptInit->y)
+ box.y1 = pptInit->y;
+ else if (box.y2 < pptInit->y)
+ box.y2 = pptInit->y;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ if (extra) {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("poly lines end\n");
+}
+
+/* changed area is box around each line segment */
+static void RootlessPolySegment(DrawablePtr dst, GCPtr pGC,
+ int nseg, xSegment *pSeg)
+{
+ GCOP_UNWRAP(pGC);
+ GC_SKIP_ROOT(dst);
+ RL_DEBUG_MSG("poly segment start (win 0x%x)", dst);
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->PolySegment(dst, pGC, nseg, pSeg);
+
+ if (nseg > 0) {
+ BoxRec box;
+ int extra = pGC->lineWidth;
+
+ if (pGC->capStyle != CapProjecting)
+ extra >>= 1;
+
+ if (pSeg->x2 > pSeg->x1) {
+ box.x1 = pSeg->x1;
+ box.x2 = pSeg->x2;
+ } else {
+ box.x2 = pSeg->x1;
+ box.x1 = pSeg->x2;
+ }
+
+ if (pSeg->y2 > pSeg->y1) {
+ box.y1 = pSeg->y1;
+ box.y2 = pSeg->y2;
+ } else {
+ box.y2 = pSeg->y1;
+ box.y1 = pSeg->y2;
+ }
+
+ while (--nseg) {
+ pSeg++;
+ if (pSeg->x2 > pSeg->x1) {
+ if (pSeg->x1 < box.x1) box.x1 = pSeg->x1;
+ if (pSeg->x2 > box.x2) box.x2 = pSeg->x2;
+ } else {
+ if (pSeg->x2 < box.x1) box.x1 = pSeg->x2;
+ if (pSeg->x1 > box.x2) box.x2 = pSeg->x1;
+ }
+ if (pSeg->y2 > pSeg->y1) {
+ if (pSeg->y1 < box.y1) box.y1 = pSeg->y1;
+ if (pSeg->y2 > box.y2) box.y2 = pSeg->y2;
+ } else {
+ if (pSeg->y2 < box.y1) box.y1 = pSeg->y2;
+ if (pSeg->y1 > box.y2) box.y2 = pSeg->y1;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ if (extra) {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("poly segment end\n");
+}
+
+/* changed area is box around each line (not entire rects) */
+static void RootlessPolyRectangle(DrawablePtr dst, GCPtr pGC,
+ int nRects, xRectangle *pRects)
+{
+ GCOP_UNWRAP(pGC);
+ GC_SKIP_ROOT(dst);
+ RL_DEBUG_MSG("poly rectangle start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->PolyRectangle(dst, pGC, nRects, pRects);
+
+ if (nRects > 0) {
+ BoxRec box;
+ int offset1, offset2, offset3;
+
+ offset2 = pGC->lineWidth;
+ if (!offset2) offset2 = 1;
+ offset1 = offset2 >> 1;
+ offset3 = offset2 - offset1;
+
+ while (nRects--) {
+ box.x1 = pRects->x - offset1;
+ box.y1 = pRects->y - offset1;
+ box.x2 = box.x1 + pRects->width + offset2;
+ box.y2 = box.y1 + offset2;
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ box.x1 = pRects->x - offset1;
+ box.y1 = pRects->y + offset3;
+ box.x2 = box.x1 + offset2;
+ box.y2 = box.y1 + pRects->height - offset2;
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ box.x1 = pRects->x + pRects->width - offset1;
+ box.y1 = pRects->y + offset3;
+ box.x2 = box.x1 + offset2;
+ box.y2 = box.y1 + pRects->height - offset2;
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ box.x1 = pRects->x - offset1;
+ box.y1 = pRects->y + pRects->height - offset1;
+ box.x2 = box.x1 + pRects->width + offset2;
+ box.y2 = box.y1 + offset2;
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ pRects++;
+ }
+ }
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("poly rectangle end\n");
+}
+
+
+/* changed area is box around each arc (assumes all arcs are 360 degrees) */
+static void RootlessPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc *parcs)
+{
+ GCOP_UNWRAP(pGC);
+ GC_SKIP_ROOT(dst);
+ RL_DEBUG_MSG("poly arc start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->PolyArc(dst, pGC, narcs, parcs);
+
+ if (narcs > 0) {
+ int extra = pGC->lineWidth >> 1;
+ BoxRec box;
+
+ box.x1 = parcs->x;
+ box.x2 = box.x1 + parcs->width;
+ box.y1 = parcs->y;
+ box.y2 = box.y1 + parcs->height;
+
+ /* should I break these up instead ? */
+
+ while (--narcs) {
+ parcs++;
+ if (box.x1 > parcs->x)
+ box.x1 = parcs->x;
+ if (box.x2 < (parcs->x + parcs->width))
+ box.x2 = parcs->x + parcs->width;
+ if (box.y1 > parcs->y)
+ box.y1 = parcs->y;
+ if (box.y2 < (parcs->y + parcs->height))
+ box.y2 = parcs->y + parcs->height;
+ }
+
+ if (extra) {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ box.x2++;
+ box.y2++;
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("poly arc end\n");
+}
+
+
+/* changed area is box around each poly */
+static void RootlessFillPolygon(DrawablePtr dst, GCPtr pGC,
+ int shape, int mode, int count,
+ DDXPointPtr pptInit)
+{
+ GC_SAVE(pGC);
+ GCOP_UNWRAP(pGC);
+ GC_SKIP_ROOT(dst);
+ RL_DEBUG_MSG("fill poly start (win 0x%x, fillStyle 0x%x)", dst,
+ pGC->fillStyle);
+
+ if (count <= 2) {
+ pGC->ops->FillPolygon(dst, pGC, shape, mode, count, pptInit);
+ } else {
+ DDXPointPtr ppt = pptInit;
+ int i = count;
+ BoxRec box;
+
+ box.x2 = box.x1 = ppt->x;
+ box.y2 = box.y1 = ppt->y;
+
+ if (mode != CoordModeOrigin) {
+ int x = box.x1;
+ int y = box.y1;
+
+ while (--i) {
+ ppt++;
+ x += ppt->x;
+ y += ppt->y;
+ if (box.x1 > x)
+ box.x1 = x;
+ else if (box.x2 < x)
+ box.x2 = x;
+ if (box.y1 > y)
+ box.y1 = y;
+ else if (box.y2 < y)
+ box.y2 = y;
+ }
+ } else {
+ while (--i) {
+ ppt++;
+ if (box.x1 > ppt->x)
+ box.x1 = ppt->x;
+ else if (box.x2 < ppt->x)
+ box.x2 = ppt->x;
+ if (box.y1 > ppt->y)
+ box.y1 = ppt->y;
+ else if (box.y2 < ppt->y)
+ box.y2 = ppt->y;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ RootlessStartDrawing((WindowPtr) dst);
+
+ if (canAccelFill(dst, pGC) &&
+ boxBytes(dst, &box) >= rootless_FillBytes_threshold)
+ {
+ GC_UNSET_PM(pGC, dst);
+ }
+
+ pGC->ops->FillPolygon(dst, pGC, shape, mode, count, pptInit);
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GC_RESTORE(pGC, dst);
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("fill poly end\n");
+}
+
+/* changed area is the rects */
+static void RootlessPolyFillRect(DrawablePtr dst, GCPtr pGC,
+ int nRectsInit, xRectangle *pRectsInit)
+{
+ GC_SAVE(pGC);
+ GCOP_UNWRAP(pGC);
+ GC_SKIP_ROOT(dst);
+ RL_DEBUG_MSG("fill rect start (win 0x%x, fillStyle 0x%x)", dst,
+ pGC->fillStyle);
+
+ if (nRectsInit <= 0) {
+ pGC->ops->PolyFillRect(dst, pGC, nRectsInit, pRectsInit);
+ } else {
+ BoxRec box;
+ xRectangle *pRects = pRectsInit;
+ int nRects = nRectsInit;
+
+ box.x1 = pRects->x;
+ box.x2 = box.x1 + pRects->width;
+ box.y1 = pRects->y;
+ box.y2 = box.y1 + pRects->height;
+
+ while (--nRects) {
+ pRects++;
+ if (box.x1 > pRects->x)
+ box.x1 = pRects->x;
+ if (box.x2 < (pRects->x + pRects->width))
+ box.x2 = pRects->x + pRects->width;
+ if (box.y1 > pRects->y)
+ box.y1 = pRects->y;
+ if (box.y2 < (pRects->y + pRects->height))
+ box.y2 = pRects->y + pRects->height;
+ }
+
+ RootlessStartDrawing((WindowPtr) dst);
+
+ if (canAccelFill(dst, pGC) &&
+ boxBytes(dst, &box) >= rootless_FillBytes_threshold)
+ {
+ GC_UNSET_PM(pGC, dst);
+ }
+
+ pGC->ops->PolyFillRect(dst, pGC, nRectsInit, pRectsInit);
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GC_RESTORE(pGC, dst);
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("fill rect end\n");
+}
+
+
+/* changed area is box around each arc (assuming arcs are all 360 degrees) */
+static void RootlessPolyFillArc(DrawablePtr dst, GCPtr pGC,
+ int narcsInit, xArc *parcsInit)
+{
+ GC_SAVE(pGC);
+ GCOP_UNWRAP(pGC);
+ GC_SKIP_ROOT(dst);
+ RL_DEBUG_MSG("fill arc start ");
+
+ if (narcsInit > 0) {
+ BoxRec box;
+ int narcs = narcsInit;
+ xArc *parcs = parcsInit;
+
+ box.x1 = parcs->x;
+ box.x2 = box.x1 + parcs->width;
+ box.y1 = parcs->y;
+ box.y2 = box.y1 + parcs->height;
+
+ /* should I break these up instead ? */
+
+ while (--narcs) {
+ parcs++;
+ if (box.x1 > parcs->x)
+ box.x1 = parcs->x;
+ if (box.x2 < (parcs->x + parcs->width))
+ box.x2 = parcs->x + parcs->width;
+ if (box.y1 > parcs->y)
+ box.y1 = parcs->y;
+ if (box.y2 < (parcs->y + parcs->height))
+ box.y2 = parcs->y + parcs->height;
+ }
+
+ RootlessStartDrawing((WindowPtr) dst);
+
+ if (canAccelFill(dst, pGC) &&
+ boxBytes(dst, &box) >= rootless_FillBytes_threshold)
+ {
+ GC_UNSET_PM(pGC, dst);
+ }
+
+ pGC->ops->PolyFillArc(dst, pGC, narcsInit, parcsInit);
+
+ TRIM_AND_TRANSLATE_BOX(box, dst, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ } else {
+ pGC->ops->PolyFillArc(dst, pGC, narcsInit, parcsInit);
+ }
+
+ GC_RESTORE(pGC, dst);
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("fill arc end\n");
+}
+
+
+static void RootlessImageText8(DrawablePtr dst, GCPtr pGC,
+ int x, int y, int count, char *chars)
+{
+ GC_SAVE(pGC);
+ GCOP_UNWRAP(pGC);
+ GC_SKIP_ROOT(dst);
+ RL_DEBUG_MSG("imagetext8 start ");
+
+ if (count > 0) {
+ int top, bot, Min, Max;
+ BoxRec box;
+
+ top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+ bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+ Min = count * FONTMINBOUNDS(pGC->font, characterWidth);
+ if (Min > 0) Min = 0;
+ Max = count * FONTMAXBOUNDS(pGC->font, characterWidth);
+ if (Max < 0) Max = 0;
+
+ /* ugh */
+ box.x1 = dst->x + x + Min +
+ FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = dst->x + x + Max +
+ FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ box.y1 = dst->y + y - top;
+ box.y2 = dst->y + y + bot;
+
+ RootlessStartDrawing((WindowPtr) dst);
+
+ if (canAccelFill(dst, pGC) &&
+ boxBytes(dst, &box) >= rootless_FillBytes_threshold)
+ {
+ GC_UNSET_PM(pGC, dst);
+ }
+
+ pGC->ops->ImageText8(dst, pGC, x, y, count, chars);
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ } else {
+ pGC->ops->ImageText8(dst, pGC, x, y, count, chars);
+ }
+
+ GC_RESTORE(pGC, dst);
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("imagetext8 end\n");
+}
+
+static int RootlessPolyText8(DrawablePtr dst, GCPtr pGC,
+ int x, int y, int count, char *chars)
+{
+ int width; // the result, sorta
+
+ GCOP_UNWRAP(pGC);
+
+ if (GC_IS_ROOT(dst))
+ return 0;
+
+ RL_DEBUG_MSG("polytext8 start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ width = pGC->ops->PolyText8(dst, pGC, x, y, count, chars);
+ width -= x;
+
+ if (width > 0) {
+ BoxRec box;
+
+ /* ugh */
+ box.x1 = dst->x + x + FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = dst->x + x + FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ if (count > 1) {
+ if (width > 0) box.x2 += width;
+ else box.x1 += width;
+ }
+
+ box.y1 = dst->y + y - FONTMAXBOUNDS(pGC->font, ascent);
+ box.y2 = dst->y + y + FONTMAXBOUNDS(pGC->font, descent);
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("polytext8 end\n");
+ return (width + x);
+}
+
+static void RootlessImageText16(DrawablePtr dst, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars)
+{
+ GC_SAVE(pGC);
+ GCOP_UNWRAP(pGC);
+ GC_SKIP_ROOT(dst);
+ RL_DEBUG_MSG("imagetext16 start ");
+
+ if (count > 0) {
+ int top, bot, Min, Max;
+ BoxRec box;
+
+ top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+ bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+ Min = count * FONTMINBOUNDS(pGC->font, characterWidth);
+ if (Min > 0) Min = 0;
+ Max = count * FONTMAXBOUNDS(pGC->font, characterWidth);
+ if (Max < 0) Max = 0;
+
+ /* ugh */
+ box.x1 = dst->x + x + Min +
+ FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = dst->x + x + Max +
+ FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ box.y1 = dst->y + y - top;
+ box.y2 = dst->y + y + bot;
+
+ RootlessStartDrawing((WindowPtr) dst);
+
+ if (canAccelFill(dst, pGC) &&
+ boxBytes(dst, &box) >= rootless_FillBytes_threshold)
+ {
+ GC_UNSET_PM(pGC, dst);
+ }
+
+ pGC->ops->ImageText16(dst, pGC, x, y, count, chars);
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ } else {
+ pGC->ops->ImageText16(dst, pGC, x, y, count, chars);
+ }
+
+ GC_RESTORE(pGC, dst);
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("imagetext16 end\n");
+}
+
+static int RootlessPolyText16(DrawablePtr dst, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars)
+{
+ int width; // the result, sorta
+
+ GCOP_UNWRAP(pGC);
+
+ if (GC_IS_ROOT(dst))
+ return 0;
+
+ RL_DEBUG_MSG("polytext16 start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ width = pGC->ops->PolyText16(dst, pGC, x, y, count, chars);
+ width -= x;
+
+ if (width > 0) {
+ BoxRec box;
+
+ /* ugh */
+ box.x1 = dst->x + x + FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = dst->x + x + FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ if (count > 1) {
+ if (width > 0) box.x2 += width;
+ else box.x1 += width;
+ }
+
+ box.y1 = dst->y + y - FONTMAXBOUNDS(pGC->font, ascent);
+ box.y2 = dst->y + y + FONTMAXBOUNDS(pGC->font, descent);
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("polytext16 end\n");
+ return width + x;
+}
+
+static void RootlessImageGlyphBlt(DrawablePtr dst, GCPtr pGC,
+ int x, int y, unsigned int nglyphInit,
+ CharInfoPtr *ppciInit, pointer unused)
+{
+ GC_SAVE(pGC);
+ GCOP_UNWRAP(pGC);
+ GC_SKIP_ROOT(dst);
+ RL_DEBUG_MSG("imageglyph start ");
+
+ if (nglyphInit > 0) {
+ int top, bot, width = 0;
+ BoxRec box;
+ unsigned int nglyph = nglyphInit;
+ CharInfoPtr *ppci = ppciInit;
+
+ top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+ bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+ box.x1 = ppci[0]->metrics.leftSideBearing;
+ if (box.x1 > 0) box.x1 = 0;
+ box.x2 = ppci[nglyph - 1]->metrics.rightSideBearing -
+ ppci[nglyph - 1]->metrics.characterWidth;
+ if (box.x2 < 0) box.x2 = 0;
+
+ box.x2 += dst->x + x;
+ box.x1 += dst->x + x;
+
+ while (nglyph--) {
+ width += (*ppci)->metrics.characterWidth;
+ ppci++;
+ }
+
+ if (width > 0)
+ box.x2 += width;
+ else
+ box.x1 += width;
+
+ box.y1 = dst->y + y - top;
+ box.y2 = dst->y + y + bot;
+
+ RootlessStartDrawing((WindowPtr) dst);
+
+ if (canAccelFill(dst, pGC) &&
+ boxBytes(dst, &box) >= rootless_FillBytes_threshold)
+ {
+ GC_UNSET_PM(pGC, dst);
+ }
+
+ pGC->ops->ImageGlyphBlt(dst, pGC, x, y, nglyphInit, ppciInit, unused);
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ } else {
+ pGC->ops->ImageGlyphBlt(dst, pGC, x, y, nglyphInit, ppciInit, unused);
+ }
+
+ GC_RESTORE(pGC, dst);
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("imageglyph end\n");
+}
+
+static void RootlessPolyGlyphBlt(DrawablePtr dst, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase)
+{
+ GCOP_UNWRAP(pGC);
+ GC_SKIP_ROOT(dst);
+ RL_DEBUG_MSG("polyglyph start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->PolyGlyphBlt(dst, pGC, x, y, nglyph, ppci, pglyphBase);
+
+ if (nglyph > 0) {
+ BoxRec box;
+
+ /* ugh */
+ box.x1 = dst->x + x + ppci[0]->metrics.leftSideBearing;
+ box.x2 = dst->x + x + ppci[nglyph - 1]->metrics.rightSideBearing;
+
+ if (nglyph > 1) {
+ int width = 0;
+
+ while (--nglyph) {
+ width += (*ppci)->metrics.characterWidth;
+ ppci++;
+ }
+
+ if (width > 0) box.x2 += width;
+ else box.x1 += width;
+ }
+
+ box.y1 = dst->y + y - FONTMAXBOUNDS(pGC->font, ascent);
+ box.y2 = dst->y + y + FONTMAXBOUNDS(pGC->font, descent);
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+ }
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("polyglyph end\n");
+}
+
+
+/* changed area is in dest */
+static void
+RootlessPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr dst,
+ int dx, int dy, int xOrg, int yOrg)
+{
+ BoxRec box;
+
+ GCOP_UNWRAP(pGC);
+ GC_SKIP_ROOT(dst);
+ RL_DEBUG_MSG("push pixels start ");
+
+ RootlessStartDrawing((WindowPtr) dst);
+ pGC->ops->PushPixels(pGC, pBitMap, dst, dx, dy, xOrg, yOrg);
+
+ box.x1 = xOrg + dst->x;
+ box.x2 = box.x1 + dx;
+ box.y1 = yOrg + dst->y;
+ box.y2 = box.y1 + dy;
+
+ TRIM_BOX(box, pGC);
+ if (BOX_NOT_EMPTY(box))
+ RootlessDamageBox ((WindowPtr) dst, &box);
+
+ GCOP_WRAP(pGC);
+ RL_DEBUG_MSG("push pixels end\n");
+}
diff --git a/nx-X11/programs/Xserver/miext/rootless/rootlessScreen.c b/nx-X11/programs/Xserver/miext/rootless/rootlessScreen.c
new file mode 100644
index 000000000..6b7697383
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/rootlessScreen.c
@@ -0,0 +1,670 @@
+/*
+ * Screen routines for generic rootless X server
+ */
+/*
+ * Copyright (c) 2001 Greg Parker. All Rights Reserved.
+ * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessScreen.c,v 1.2 2003/04/30 23:15:35 torrey Exp $ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "mi.h"
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "propertyst.h"
+#include "mivalidate.h"
+#include "picturestr.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+
+#include "rootlessCommon.h"
+#include "rootlessWindow.h"
+
+/* In milliseconds */
+#ifndef ROOTLESS_REDISPLAY_DELAY
+#define ROOTLESS_REDISPLAY_DELAY 10
+#endif
+
+extern int RootlessMiValidateTree(WindowPtr pRoot, WindowPtr pChild,
+ VTKind kind);
+extern Bool RootlessCreateGC(GCPtr pGC);
+
+// Initialize globals
+int rootlessGCPrivateIndex = -1;
+int rootlessScreenPrivateIndex = -1;
+int rootlessWindowPrivateIndex = -1;
+
+
+/*
+ * RootlessUpdateScreenPixmap
+ * miCreateScreenResources does not like a null framebuffer pointer,
+ * it leaves the screen pixmap with an uninitialized data pointer.
+ * Thus, rootless implementations typically set the framebuffer width
+ * to zero so that miCreateScreenResources does not allocate a screen
+ * pixmap for us. We allocate our own screen pixmap here since we need
+ * the screen pixmap to be valid (e.g. CopyArea from the root window).
+ */
+void
+RootlessUpdateScreenPixmap(ScreenPtr pScreen)
+{
+ RootlessScreenRec *s = SCREENREC(pScreen);
+ PixmapPtr pPix;
+ unsigned int rowbytes;
+
+ pPix = (*pScreen->GetScreenPixmap)(pScreen);
+ if (pPix == NULL) {
+ pPix = (*pScreen->CreatePixmap)(pScreen, 0, 0, pScreen->rootDepth);
+ (*pScreen->SetScreenPixmap)(pPix);
+ }
+
+ rowbytes = PixmapBytePad(pScreen->width, pScreen->rootDepth);
+
+ if (s->pixmap_data_size < rowbytes) {
+ if (s->pixmap_data != NULL)
+ xfree(s->pixmap_data);
+
+ s->pixmap_data_size = rowbytes;
+ s->pixmap_data = xalloc(s->pixmap_data_size);
+ if (s->pixmap_data == NULL)
+ return;
+
+ memset(s->pixmap_data, 0xFF, s->pixmap_data_size);
+
+ pScreen->ModifyPixmapHeader(pPix, pScreen->width, pScreen->height,
+ pScreen->rootDepth,
+ BitsPerPixel(pScreen->rootDepth),
+ 0, s->pixmap_data);
+ /* ModifyPixmapHeader ignores zero arguments, so install rowbytes
+ by hand. */
+ pPix->devKind = 0;
+ }
+}
+
+
+/*
+ * RootlessCreateScreenResources
+ * Rootless implementations typically set a null framebuffer pointer, which
+ * causes problems with miCreateScreenResources. We fix things up here.
+ */
+static Bool
+RootlessCreateScreenResources(ScreenPtr pScreen)
+{
+ Bool ret = TRUE;
+
+ SCREEN_UNWRAP(pScreen, CreateScreenResources);
+
+ if (pScreen->CreateScreenResources != NULL)
+ ret = (*pScreen->CreateScreenResources)(pScreen);
+
+ SCREEN_WRAP(pScreen, CreateScreenResources);
+
+ if (!ret)
+ return ret;
+
+ /* Make sure we have a valid screen pixmap. */
+
+ RootlessUpdateScreenPixmap(pScreen);
+
+ return ret;
+}
+
+
+static Bool
+RootlessCloseScreen(int i, ScreenPtr pScreen)
+{
+ RootlessScreenRec *s;
+
+ s = SCREENREC(pScreen);
+
+ // fixme unwrap everything that was wrapped?
+ pScreen->CloseScreen = s->CloseScreen;
+
+ if (s->pixmap_data != NULL) {
+ xfree (s->pixmap_data);
+ s->pixmap_data = NULL;
+ s->pixmap_data_size = 0;
+ }
+
+ xfree(s);
+ return pScreen->CloseScreen(i, pScreen);
+}
+
+
+static void
+RootlessGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
+ unsigned int format, unsigned long planeMask, char *pdstLine)
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ SCREEN_UNWRAP(pScreen, GetImage);
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ int x0, y0, x1, y1;
+ RootlessWindowRec *winRec;
+
+ // Many apps use GetImage to sync with the visible frame buffer
+ // FIXME: entire screen or just window or all screens?
+ RootlessRedisplayScreen(pScreen);
+
+ // RedisplayScreen stops drawing, so we need to start it again
+ RootlessStartDrawing((WindowPtr)pDrawable);
+
+ /* Check that we have some place to read from. */
+ winRec = WINREC(TopLevelParent((WindowPtr) pDrawable));
+ if (winRec == NULL)
+ goto out;
+
+ /* Clip to top-level window bounds. */
+ /* FIXME: fbGetImage uses the width parameter to calculate the
+ stride of the destination pixmap. If w is clipped, the data
+ returned will be garbage, although we will not crash. */
+
+ x0 = pDrawable->x + sx;
+ y0 = pDrawable->y + sy;
+ x1 = x0 + w;
+ y1 = y0 + h;
+
+ x0 = MAX (x0, winRec->x);
+ y0 = MAX (y0, winRec->y);
+ x1 = MIN (x1, winRec->x + winRec->width);
+ y1 = MIN (y1, winRec->y + winRec->height);
+
+ sx = x0 - pDrawable->x;
+ sy = y0 - pDrawable->y;
+ w = x1 - x0;
+ h = y1 - y0;
+
+ if (w <= 0 || h <= 0)
+ goto out;
+ }
+
+ pScreen->GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+
+out:
+ SCREEN_WRAP(pScreen, GetImage);
+}
+
+
+/*
+ * RootlessSourceValidate
+ * CopyArea and CopyPlane use a GC tied to the destination drawable.
+ * StartDrawing/StopDrawing wrappers won't be called if source is
+ * a visible window but the destination isn't. So, we call StartDrawing
+ * here and leave StopDrawing for the block handler.
+ */
+static void
+RootlessSourceValidate(DrawablePtr pDrawable, int x, int y, int w, int h)
+{
+ SCREEN_UNWRAP(pDrawable->pScreen, SourceValidate);
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ WindowPtr pWin = (WindowPtr)pDrawable;
+ RootlessStartDrawing(pWin);
+ }
+ if (pDrawable->pScreen->SourceValidate) {
+ pDrawable->pScreen->SourceValidate(pDrawable, x, y, w, h);
+ }
+ SCREEN_WRAP(pDrawable->pScreen, SourceValidate);
+}
+
+#ifdef RENDER
+
+static void
+RootlessComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
+ INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
+ INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ WindowPtr srcWin, dstWin, maskWin = NULL;
+
+ if (pMask) { // pMask can be NULL
+ maskWin = (pMask->pDrawable->type == DRAWABLE_WINDOW) ?
+ (WindowPtr)pMask->pDrawable : NULL;
+ }
+ srcWin = (pSrc->pDrawable->type == DRAWABLE_WINDOW) ?
+ (WindowPtr)pSrc->pDrawable : NULL;
+ dstWin = (pDst->pDrawable->type == DRAWABLE_WINDOW) ?
+ (WindowPtr)pDst->pDrawable : NULL;
+
+ // SCREEN_UNWRAP(ps, Composite);
+ ps->Composite = SCREENREC(pScreen)->Composite;
+
+ if (srcWin && IsFramedWindow(srcWin))
+ RootlessStartDrawing(srcWin);
+ if (maskWin && IsFramedWindow(maskWin))
+ RootlessStartDrawing(maskWin);
+ if (dstWin && IsFramedWindow(dstWin))
+ RootlessStartDrawing(dstWin);
+
+ ps->Composite(op, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask,
+ xDst, yDst, width, height);
+
+ if (dstWin && IsFramedWindow(dstWin)) {
+ RootlessDamageRect(dstWin, xDst, yDst, width, height);
+ }
+
+ ps->Composite = RootlessComposite;
+ // SCREEN_WRAP(ps, Composite);
+}
+
+
+static void
+RootlessGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+ PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
+ int nlist, GlyphListPtr list, GlyphPtr *glyphs)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ int x, y;
+ int n;
+ GlyphPtr glyph;
+ WindowPtr srcWin, dstWin;
+
+ srcWin = (pSrc->pDrawable->type == DRAWABLE_WINDOW) ?
+ (WindowPtr)pSrc->pDrawable : NULL;
+ dstWin = (pDst->pDrawable->type == DRAWABLE_WINDOW) ?
+ (WindowPtr)pDst->pDrawable : NULL;
+
+ if (srcWin && IsFramedWindow(srcWin)) RootlessStartDrawing(srcWin);
+ if (dstWin && IsFramedWindow(dstWin)) RootlessStartDrawing(dstWin);
+
+ //SCREEN_UNWRAP(ps, Glyphs);
+ ps->Glyphs = SCREENREC(pScreen)->Glyphs;
+ ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
+ ps->Glyphs = RootlessGlyphs;
+ //SCREEN_WRAP(ps, Glyphs);
+
+ if (dstWin && IsFramedWindow(dstWin)) {
+ x = xSrc;
+ y = ySrc;
+
+ while (nlist--) {
+ x += list->xOff;
+ y += list->yOff;
+ n = list->len;
+
+ /* Calling DamageRect for the bounding box of each glyph is
+ inefficient. So compute the union of all glyphs in a list
+ and damage that. */
+
+ if (n > 0) {
+ BoxRec box;
+
+ glyph = *glyphs++;
+
+ box.x1 = x - glyph->info.x;
+ box.y1 = y - glyph->info.y;
+ box.x2 = box.x1 + glyph->info.width;
+ box.y2 = box.y2 + glyph->info.height;
+
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+
+ while (--n > 0) {
+ short x1, y1, x2, y2;
+
+ glyph = *glyphs++;
+
+ x1 = x - glyph->info.x;
+ y1 = y - glyph->info.y;
+ x2 = x1 + glyph->info.width;
+ y2 = y1 + glyph->info.height;
+
+ box.x1 = MAX (box.x1, x1);
+ box.y1 = MAX (box.y1, y1);
+ box.x2 = MAX (box.x2, x2);
+ box.y2 = MAX (box.y2, y2);
+
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ }
+
+ RootlessDamageBox(dstWin, &box);
+ }
+ list++;
+ }
+ }
+}
+
+#endif // RENDER
+
+
+/*
+ * RootlessValidateTree
+ * ValidateTree is modified in two ways:
+ * - top-level windows don't clip each other
+ * - windows aren't clipped against root.
+ * These only matter when validating from the root.
+ */
+static int
+RootlessValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
+{
+ int result;
+ RegionRec saveRoot;
+ ScreenPtr pScreen = pParent->drawable.pScreen;
+
+ SCREEN_UNWRAP(pScreen, ValidateTree);
+ RL_DEBUG_MSG("VALIDATETREE start ");
+
+ // Use our custom version to validate from root
+ if (IsRoot(pParent)) {
+ RL_DEBUG_MSG("custom ");
+ result = RootlessMiValidateTree(pParent, pChild, kind);
+ } else {
+ HUGE_ROOT(pParent);
+ result = pScreen->ValidateTree(pParent, pChild, kind);
+ NORMAL_ROOT(pParent);
+ }
+
+ SCREEN_WRAP(pScreen, ValidateTree);
+ RL_DEBUG_MSG("VALIDATETREE end\n");
+
+ return result;
+}
+
+
+/*
+ * RootlessMarkOverlappedWindows
+ * MarkOverlappedWindows is modified to ignore overlapping
+ * top-level windows.
+ */
+static Bool
+RootlessMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst,
+ WindowPtr *ppLayerWin)
+{
+ RegionRec saveRoot;
+ Bool result;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ SCREEN_UNWRAP(pScreen, MarkOverlappedWindows);
+ RL_DEBUG_MSG("MARKOVERLAPPEDWINDOWS start ");
+
+ HUGE_ROOT(pWin);
+ if (IsRoot(pWin)) {
+ // root - mark nothing
+ RL_DEBUG_MSG("is root not marking ");
+ result = FALSE;
+ }
+ else if (! IsTopLevel(pWin)) {
+ // not top-level window - mark normally
+ result = pScreen->MarkOverlappedWindows(pWin, pFirst, ppLayerWin);
+ }
+ else {
+ //top-level window - mark children ONLY - NO overlaps with sibs (?)
+ // This code copied from miMarkOverlappedWindows()
+
+ register WindowPtr pChild;
+ Bool anyMarked = FALSE;
+ void (* MarkWindow)() = pScreen->MarkWindow;
+
+ RL_DEBUG_MSG("is top level! ");
+ /* single layered systems are easy */
+ if (ppLayerWin) *ppLayerWin = pWin;
+
+ if (pWin == pFirst) {
+ /* Blindly mark pWin and all of its inferiors. This is a slight
+ * overkill if there are mapped windows that outside pWin's border,
+ * but it's better than wasting time on RectIn checks.
+ */
+ pChild = pWin;
+ while (1) {
+ if (pChild->viewable) {
+ if (REGION_BROKEN (pScreen, &pChild->winSize))
+ SetWinSize (pChild);
+ if (REGION_BROKEN (pScreen, &pChild->borderSize))
+ SetBorderSize (pChild);
+ (* MarkWindow)(pChild);
+ if (pChild->firstChild) {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ while (!pChild->nextSib && (pChild != pWin))
+ pChild = pChild->parent;
+ if (pChild == pWin)
+ break;
+ pChild = pChild->nextSib;
+ }
+ anyMarked = TRUE;
+ pFirst = pFirst->nextSib;
+ }
+ if (anyMarked)
+ (* MarkWindow)(pWin->parent);
+ result = anyMarked;
+ }
+ NORMAL_ROOT(pWin);
+ SCREEN_WRAP(pScreen, MarkOverlappedWindows);
+ RL_DEBUG_MSG("MARKOVERLAPPEDWINDOWS end\n");
+
+ return result;
+}
+
+
+static CARD32
+RootlessRedisplayCallback(OsTimerPtr timer, CARD32 time, void *arg)
+{
+ RootlessScreenRec *screenRec = arg;
+
+ if (!screenRec->redisplay_queued) {
+ /* No update needed. Stop the timer. */
+
+ screenRec->redisplay_timer_set = FALSE;
+ return 0;
+ }
+
+ screenRec->redisplay_queued = FALSE;
+
+ /* Mark that we should redisplay before waiting for I/O next time */
+ screenRec->redisplay_expired = TRUE;
+
+ /* Reinstall the timer immediately, so we get as close to our
+ redisplay interval as possible. */
+
+ return ROOTLESS_REDISPLAY_DELAY;
+}
+
+
+/*
+ * RootlessQueueRedisplay
+ * Queue a redisplay after a timer delay to ensure we do not redisplay
+ * too frequently.
+ */
+void
+RootlessQueueRedisplay(ScreenPtr pScreen)
+{
+ RootlessScreenRec *screenRec = SCREENREC(pScreen);
+
+ screenRec->redisplay_queued = TRUE;
+
+ if (screenRec->redisplay_timer_set)
+ return;
+
+ screenRec->redisplay_timer = TimerSet(screenRec->redisplay_timer,
+ 0, ROOTLESS_REDISPLAY_DELAY,
+ RootlessRedisplayCallback,
+ screenRec);
+ screenRec->redisplay_timer_set = TRUE;
+}
+
+
+/*
+ * RootlessBlockHandler
+ * If the redisplay timer has expired, flush drawing before blocking
+ * on select().
+ */
+static void
+RootlessBlockHandler(pointer pbdata, OSTimePtr pTimeout, pointer pReadmask)
+{
+ ScreenPtr pScreen = pbdata;
+ RootlessScreenRec *screenRec = SCREENREC(pScreen);
+
+ if (screenRec->redisplay_expired) {
+ screenRec->redisplay_expired = FALSE;
+
+ RootlessRedisplayScreen(pScreen);
+ }
+}
+
+
+static void
+RootlessWakeupHandler(pointer data, int i, pointer LastSelectMask)
+{
+ // nothing here
+}
+
+
+static Bool
+RootlessAllocatePrivates(ScreenPtr pScreen)
+{
+ RootlessScreenRec *s;
+ static unsigned long rootlessGeneration = 0;
+
+ if (rootlessGeneration != serverGeneration) {
+ rootlessScreenPrivateIndex = AllocateScreenPrivateIndex();
+ if (rootlessScreenPrivateIndex == -1) return FALSE;
+ rootlessGCPrivateIndex = AllocateGCPrivateIndex();
+ if (rootlessGCPrivateIndex == -1) return FALSE;
+ rootlessWindowPrivateIndex = AllocateWindowPrivateIndex();
+ if (rootlessWindowPrivateIndex == -1) return FALSE;
+ rootlessGeneration = serverGeneration;
+ }
+
+ // no allocation needed for screen privates
+ if (!AllocateGCPrivate(pScreen, rootlessGCPrivateIndex,
+ sizeof(RootlessGCRec)))
+ return FALSE;
+ if (!AllocateWindowPrivate(pScreen, rootlessWindowPrivateIndex, 0))
+ return FALSE;
+
+ s = xalloc(sizeof(RootlessScreenRec));
+ if (! s) return FALSE;
+ SCREENREC(pScreen) = s;
+
+ s->pixmap_data = NULL;
+ s->pixmap_data_size = 0;
+
+ s->redisplay_timer = NULL;
+ s->redisplay_timer_set = FALSE;
+
+ return TRUE;
+}
+
+
+static void
+RootlessWrap(ScreenPtr pScreen)
+{
+ RootlessScreenRec *s = (RootlessScreenRec*)
+ pScreen->devPrivates[rootlessScreenPrivateIndex].ptr;
+
+#define WRAP(a) \
+ if (pScreen->a) { \
+ s->a = pScreen->a; \
+ } else { \
+ RL_DEBUG_MSG("null screen fn " #a "\n"); \
+ s->a = NULL; \
+ } \
+ pScreen->a = Rootless##a
+
+ WRAP(CreateScreenResources);
+ WRAP(CloseScreen);
+ WRAP(CreateGC);
+ WRAP(PaintWindowBackground);
+ WRAP(PaintWindowBorder);
+ WRAP(CopyWindow);
+ WRAP(GetImage);
+ WRAP(SourceValidate);
+ WRAP(CreateWindow);
+ WRAP(DestroyWindow);
+ WRAP(RealizeWindow);
+ WRAP(UnrealizeWindow);
+ WRAP(MoveWindow);
+ WRAP(PositionWindow);
+ WRAP(ResizeWindow);
+ WRAP(RestackWindow);
+ WRAP(ReparentWindow);
+ WRAP(ChangeBorderWidth);
+ WRAP(MarkOverlappedWindows);
+ WRAP(ValidateTree);
+ WRAP(ChangeWindowAttributes);
+
+#ifdef SHAPE
+ WRAP(SetShape);
+#endif
+
+#ifdef RENDER
+ {
+ // Composite and Glyphs don't use normal screen wrapping
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ s->Composite = ps->Composite;
+ ps->Composite = RootlessComposite;
+ s->Glyphs = ps->Glyphs;
+ ps->Glyphs = RootlessGlyphs;
+ }
+#endif
+
+ // WRAP(ClearToBackground); fixme put this back? useful for shaped wins?
+ // WRAP(RestoreAreas); fixme put this back?
+
+#undef WRAP
+}
+
+
+/*
+ * RootlessInit
+ * Called by the rootless implementation to initialize the rootless layer.
+ * Rootless wraps lots of stuff and needs a bunch of devPrivates.
+ */
+Bool RootlessInit(ScreenPtr pScreen, RootlessFrameProcsPtr procs)
+{
+ RootlessScreenRec *s;
+
+ if (!RootlessAllocatePrivates(pScreen))
+ return FALSE;
+
+ s = (RootlessScreenRec*)
+ pScreen->devPrivates[rootlessScreenPrivateIndex].ptr;
+
+ s->imp = procs;
+
+ RootlessWrap(pScreen);
+
+ if (!RegisterBlockAndWakeupHandlers(RootlessBlockHandler,
+ RootlessWakeupHandler,
+ (pointer) pScreen))
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/miext/rootless/rootlessValTree.c b/nx-X11/programs/Xserver/miext/rootless/rootlessValTree.c
new file mode 100644
index 000000000..2717ddf6f
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/rootlessValTree.c
@@ -0,0 +1,648 @@
+/*
+ * Calculate window clip lists for rootless mode
+ *
+ * This file is very closely based on mivaltree.c.
+ */
+/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessValTree.c,v 1.1tsi Exp $ */
+
+/*
+ * mivaltree.c --
+ * Functions for recalculating window clip lists. Main function
+ * is miValidateTree.
+ *
+
+Copyright 1987, 1988, 1989, 1998 The Open Group
+
+All Rights Reserved.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+ *
+ * Copyright 1987, 1988, 1989 by
+ * Digital Equipment Corporation, Maynard, Massachusetts,
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ ******************************************************************/
+
+/* The panoramix components contained the following notice */
+/*****************************************************************
+
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+ /*
+ * Aug '86: Susan Angebranndt -- original code
+ * July '87: Adam de Boor -- substantially modified and commented
+ * Summer '89: Joel McCormack -- so fast you wouldn't believe it possible.
+ * In particular, much improved code for window mapping and
+ * circulating.
+ * Bob Scheifler -- avoid miComputeClips for unmapped windows,
+ * valdata changes
+ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "regionstr.h"
+#include "mivalidate.h"
+
+#include "globals.h"
+
+#ifdef SHAPE
+/*
+ * Compute the visibility of a shaped window
+ */
+int
+RootlessShapedWindowIn (pScreen, universe, bounding, rect, x, y)
+ ScreenPtr pScreen;
+ RegionPtr universe, bounding;
+ BoxPtr rect;
+ register int x, y;
+{
+ BoxRec box;
+ register BoxPtr boundBox;
+ int nbox;
+ Bool someIn, someOut;
+ register int t, x1, y1, x2, y2;
+
+ nbox = REGION_NUM_RECTS (bounding);
+ boundBox = REGION_RECTS (bounding);
+ someIn = someOut = FALSE;
+ x1 = rect->x1;
+ y1 = rect->y1;
+ x2 = rect->x2;
+ y2 = rect->y2;
+ while (nbox--)
+ {
+ if ((t = boundBox->x1 + x) < x1)
+ t = x1;
+ box.x1 = t;
+ if ((t = boundBox->y1 + y) < y1)
+ t = y1;
+ box.y1 = t;
+ if ((t = boundBox->x2 + x) > x2)
+ t = x2;
+ box.x2 = t;
+ if ((t = boundBox->y2 + y) > y2)
+ t = y2;
+ box.y2 = t;
+ if (box.x1 > box.x2)
+ box.x2 = box.x1;
+ if (box.y1 > box.y2)
+ box.y2 = box.y1;
+ switch (RECT_IN_REGION(pScreen, universe, &box))
+ {
+ case rgnIN:
+ if (someOut)
+ return rgnPART;
+ someIn = TRUE;
+ break;
+ case rgnOUT:
+ if (someIn)
+ return rgnPART;
+ someOut = TRUE;
+ break;
+ default:
+ return rgnPART;
+ }
+ boundBox++;
+ }
+ if (someIn)
+ return rgnIN;
+ return rgnOUT;
+}
+#endif
+
+#define HasParentRelativeBorder(w) (!(w)->borderIsPixel && \
+ HasBorder(w) && \
+ (w)->backgroundState == ParentRelative)
+
+
+/*
+ *-----------------------------------------------------------------------
+ * RootlessComputeClips --
+ * Recompute the clipList, borderClip, exposed and borderExposed
+ * regions for pParent and its children. Only viewable windows are
+ * taken into account.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * clipList, borderClip, exposed and borderExposed are altered.
+ * A VisibilityNotify event may be generated on the parent window.
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+RootlessComputeClips (pParent, pScreen, universe, kind, exposed)
+ register WindowPtr pParent;
+ register ScreenPtr pScreen;
+ register RegionPtr universe;
+ VTKind kind;
+ RegionPtr exposed; /* for intermediate calculations */
+{
+ int dx,
+ dy;
+ RegionRec childUniverse;
+ register WindowPtr pChild;
+ int oldVis, newVis;
+ BoxRec borderSize;
+ RegionRec childUnion;
+ Bool overlap;
+ RegionPtr borderVisible;
+ Bool resized;
+ /*
+ * Figure out the new visibility of this window.
+ * The extent of the universe should be the same as the extent of
+ * the borderSize region. If the window is unobscured, this rectangle
+ * will be completely inside the universe (the universe will cover it
+ * completely). If the window is completely obscured, none of the
+ * universe will cover the rectangle.
+ */
+ borderSize.x1 = pParent->drawable.x - wBorderWidth(pParent);
+ borderSize.y1 = pParent->drawable.y - wBorderWidth(pParent);
+ dx = (int) pParent->drawable.x + (int) pParent->drawable.width + wBorderWidth(pParent);
+ if (dx > 32767)
+ dx = 32767;
+ borderSize.x2 = dx;
+ dy = (int) pParent->drawable.y + (int) pParent->drawable.height + wBorderWidth(pParent);
+ if (dy > 32767)
+ dy = 32767;
+ borderSize.y2 = dy;
+
+ oldVis = pParent->visibility;
+ switch (RECT_IN_REGION( pScreen, universe, &borderSize))
+ {
+ case rgnIN:
+ newVis = VisibilityUnobscured;
+ break;
+ case rgnPART:
+ newVis = VisibilityPartiallyObscured;
+#ifdef SHAPE
+ {
+ RegionPtr pBounding;
+
+ if ((pBounding = wBoundingShape (pParent)))
+ {
+ switch (RootlessShapedWindowIn (pScreen, universe,
+ pBounding, &borderSize,
+ pParent->drawable.x,
+ pParent->drawable.y))
+ {
+ case rgnIN:
+ newVis = VisibilityUnobscured;
+ break;
+ case rgnOUT:
+ newVis = VisibilityFullyObscured;
+ break;
+ }
+ }
+ }
+#endif
+ break;
+ default:
+ newVis = VisibilityFullyObscured;
+ break;
+ }
+
+ pParent->visibility = newVis;
+ if (oldVis != newVis &&
+ ((pParent->eventMask | wOtherEventMasks(pParent)) & VisibilityChangeMask))
+ SendVisibilityNotify(pParent);
+
+ dx = pParent->drawable.x - pParent->valdata->before.oldAbsCorner.x;
+ dy = pParent->drawable.y - pParent->valdata->before.oldAbsCorner.y;
+
+ /*
+ * avoid computations when dealing with simple operations
+ */
+
+ switch (kind) {
+ case VTMap:
+ case VTStack:
+ case VTUnmap:
+ break;
+ case VTMove:
+ if ((oldVis == newVis) &&
+ ((oldVis == VisibilityFullyObscured) ||
+ (oldVis == VisibilityUnobscured)))
+ {
+ pChild = pParent;
+ while (1)
+ {
+ if (pChild->viewable)
+ {
+ if (pChild->visibility != VisibilityFullyObscured)
+ {
+ REGION_TRANSLATE( pScreen, &pChild->borderClip,
+ dx, dy);
+ REGION_TRANSLATE( pScreen, &pChild->clipList,
+ dx, dy);
+ pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ if (pScreen->ClipNotify)
+ (* pScreen->ClipNotify) (pChild, dx, dy);
+
+ }
+ if (pChild->valdata)
+ {
+ REGION_NULL(pScreen,
+ &pChild->valdata->after.borderExposed);
+ if (HasParentRelativeBorder(pChild))
+ {
+ REGION_SUBTRACT(pScreen,
+ &pChild->valdata->after.borderExposed,
+ &pChild->borderClip,
+ &pChild->winSize);
+ }
+ REGION_NULL(pScreen, &pChild->valdata->after.exposed);
+ }
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ while (!pChild->nextSib && (pChild != pParent))
+ pChild = pChild->parent;
+ if (pChild == pParent)
+ break;
+ pChild = pChild->nextSib;
+ }
+ return;
+ }
+ /* fall through */
+ default:
+ /*
+ * To calculate exposures correctly, we have to translate the old
+ * borderClip and clipList regions to the window's new location so there
+ * is a correspondence between pieces of the new and old clipping regions.
+ */
+ if (dx || dy)
+ {
+ /*
+ * We translate the old clipList because that will be exposed or copied
+ * if gravity is right.
+ */
+ REGION_TRANSLATE( pScreen, &pParent->borderClip, dx, dy);
+ REGION_TRANSLATE( pScreen, &pParent->clipList, dx, dy);
+ }
+ break;
+ case VTBroken:
+ REGION_EMPTY (pScreen, &pParent->borderClip);
+ REGION_EMPTY (pScreen, &pParent->clipList);
+ break;
+ }
+
+ borderVisible = pParent->valdata->before.borderVisible;
+ resized = pParent->valdata->before.resized;
+ REGION_NULL(pScreen, &pParent->valdata->after.borderExposed);
+ REGION_NULL(pScreen, &pParent->valdata->after.exposed);
+
+ /*
+ * Since the borderClip must not be clipped by the children, we do
+ * the border exposure first...
+ *
+ * 'universe' is the window's borderClip. To figure the exposures, remove
+ * the area that used to be exposed from the new.
+ * This leaves a region of pieces that weren't exposed before.
+ */
+
+ if (HasBorder (pParent))
+ {
+ if (borderVisible)
+ {
+ /*
+ * when the border changes shape, the old visible portions
+ * of the border will be saved by DIX in borderVisible --
+ * use that region and destroy it
+ */
+ REGION_SUBTRACT( pScreen, exposed, universe, borderVisible);
+ REGION_DESTROY( pScreen, borderVisible);
+ }
+ else
+ {
+ REGION_SUBTRACT( pScreen, exposed, universe, &pParent->borderClip);
+ }
+ if (HasParentRelativeBorder(pParent) && (dx || dy)) {
+ REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed,
+ universe,
+ &pParent->winSize);
+ } else {
+ REGION_SUBTRACT( pScreen, &pParent->valdata->after.borderExposed,
+ exposed, &pParent->winSize);
+ }
+
+ REGION_COPY( pScreen, &pParent->borderClip, universe);
+
+ /*
+ * To get the right clipList for the parent, and to make doubly sure
+ * that no child overlaps the parent's border, we remove the parent's
+ * border from the universe before proceeding.
+ */
+
+ REGION_INTERSECT( pScreen, universe, universe, &pParent->winSize);
+ }
+ else
+ REGION_COPY( pScreen, &pParent->borderClip, universe);
+
+ if ((pChild = pParent->firstChild) && pParent->mapped)
+ {
+ REGION_NULL(pScreen, &childUniverse);
+ REGION_NULL(pScreen, &childUnion);
+ if ((pChild->drawable.y < pParent->lastChild->drawable.y) ||
+ ((pChild->drawable.y == pParent->lastChild->drawable.y) &&
+ (pChild->drawable.x < pParent->lastChild->drawable.x)))
+ {
+ for (; pChild; pChild = pChild->nextSib)
+ {
+ if (pChild->viewable)
+ REGION_APPEND( pScreen, &childUnion, &pChild->borderSize);
+ }
+ }
+ else
+ {
+ for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib)
+ {
+ if (pChild->viewable)
+ REGION_APPEND( pScreen, &childUnion, &pChild->borderSize);
+ }
+ }
+ REGION_VALIDATE( pScreen, &childUnion, &overlap);
+
+ for (pChild = pParent->firstChild;
+ pChild;
+ pChild = pChild->nextSib)
+ {
+ if (pChild->viewable) {
+ /*
+ * If the child is viewable, we want to remove its extents
+ * from the current universe, but we only re-clip it if
+ * it's been marked.
+ */
+ if (pChild->valdata) {
+ /*
+ * Figure out the new universe from the child's
+ * perspective and recurse.
+ */
+ REGION_INTERSECT( pScreen, &childUniverse,
+ universe,
+ &pChild->borderSize);
+ RootlessComputeClips (pChild, pScreen, &childUniverse,
+ kind, exposed);
+ }
+ /*
+ * Once the child has been processed, we remove its extents
+ * from the current universe, thus denying its space to any
+ * other sibling.
+ */
+ if (overlap)
+ REGION_SUBTRACT( pScreen, universe, universe,
+ &pChild->borderSize);
+ }
+ }
+ if (!overlap)
+ REGION_SUBTRACT( pScreen, universe, universe, &childUnion);
+ REGION_UNINIT( pScreen, &childUnion);
+ REGION_UNINIT( pScreen, &childUniverse);
+ } /* if any children */
+
+ /*
+ * 'universe' now contains the new clipList for the parent window.
+ *
+ * To figure the exposure of the window we subtract the old clip from the
+ * new, just as for the border.
+ */
+
+ if (oldVis == VisibilityFullyObscured ||
+ oldVis == VisibilityNotViewable)
+ {
+ REGION_COPY( pScreen, &pParent->valdata->after.exposed, universe);
+ }
+ else if (newVis != VisibilityFullyObscured &&
+ newVis != VisibilityNotViewable)
+ {
+ REGION_SUBTRACT( pScreen, &pParent->valdata->after.exposed,
+ universe, &pParent->clipList);
+ }
+
+ /*
+ * One last thing: backing storage. We have to try to save what parts of
+ * the window are about to be obscured. We can just subtract the universe
+ * from the old clipList and get the areas that were in the old but aren't
+ * in the new and, hence, are about to be obscured.
+ */
+ if (pParent->backStorage && !resized)
+ {
+ REGION_SUBTRACT( pScreen, exposed, &pParent->clipList, universe);
+ (* pScreen->SaveDoomedAreas)(pParent, exposed, dx, dy);
+ }
+
+ /* HACK ALERT - copying contents of regions, instead of regions */
+ {
+ RegionRec tmp;
+
+ tmp = pParent->clipList;
+ pParent->clipList = *universe;
+ *universe = tmp;
+ }
+
+#ifdef NOTDEF
+ REGION_COPY( pScreen, &pParent->clipList, universe);
+#endif
+
+ pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+ if (pScreen->ClipNotify)
+ (* pScreen->ClipNotify) (pParent, dx, dy);
+}
+
+static void
+RootlessTreeObscured(pParent)
+ register WindowPtr pParent;
+{
+ register WindowPtr pChild;
+ register int oldVis;
+
+ pChild = pParent;
+ while (1)
+ {
+ if (pChild->viewable)
+ {
+ oldVis = pChild->visibility;
+ if (oldVis != (pChild->visibility = VisibilityFullyObscured) &&
+ ((pChild->eventMask | wOtherEventMasks(pChild)) & VisibilityChangeMask))
+ SendVisibilityNotify(pChild);
+ if (pChild->firstChild)
+ {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ while (!pChild->nextSib && (pChild != pParent))
+ pChild = pChild->parent;
+ if (pChild == pParent)
+ break;
+ pChild = pChild->nextSib;
+ }
+}
+
+/*
+ *-----------------------------------------------------------------------
+ * RootlessMiValidateTree --
+ * Recomputes the clip list for pParent and all its inferiors.
+ *
+ * Results:
+ * Always returns 1.
+ *
+ * Side Effects:
+ * The clipList, borderClip, exposed, and borderExposed regions for
+ * each marked window are altered.
+ *
+ * Notes:
+ * This routine assumes that all affected windows have been marked
+ * (valdata created) and their winSize and borderSize regions
+ * adjusted to correspond to their new positions. The borderClip and
+ * clipList regions should not have been touched.
+ *
+ * The top-most level is treated differently from all lower levels
+ * because pParent is unchanged. For the top level, we merge the
+ * regions taken up by the marked children back into the clipList
+ * for pParent, thus forming a region from which the marked children
+ * can claim their areas. For lower levels, where the old clipList
+ * and borderClip are invalid, we can't do this and have to do the
+ * extra operations done in miComputeClips, but this is much faster
+ * e.g. when only one child has moved...
+ *
+ *-----------------------------------------------------------------------
+ */
+/*
+ Quartz version: used for validate from root in rootless mode.
+ We need to make sure top-level windows don't clip each other,
+ and that top-level windows aren't clipped to the root window.
+*/
+/*ARGSUSED*/
+// fixme this is ugly
+// Xprint/ValTree.c doesn't work, but maybe that method can?
+int
+RootlessMiValidateTree (pRoot, pChild, kind)
+ WindowPtr pRoot; /* Parent to validate */
+ WindowPtr pChild; /* First child of pRoot that was
+ * affected */
+ VTKind kind; /* What kind of configuration caused call */
+{
+ RegionRec childClip; /* The new borderClip for the current
+ * child */
+ RegionRec exposed; /* For intermediate calculations */
+ register ScreenPtr pScreen;
+ register WindowPtr pWin;
+
+ pScreen = pRoot->drawable.pScreen;
+ if (pChild == NullWindow)
+ pChild = pRoot->firstChild;
+
+ REGION_NULL(pScreen, &childClip);
+ REGION_NULL(pScreen, &exposed);
+
+ if (REGION_BROKEN (pScreen, &pRoot->clipList) &&
+ !REGION_BROKEN (pScreen, &pRoot->borderClip))
+ {
+ // fixme this might not work, but hopefully doesn't happen anyway.
+ kind = VTBroken;
+ REGION_EMPTY (pScreen, &pRoot->clipList);
+ ErrorF("ValidateTree: BUSTED!\n");
+ }
+
+ /*
+ * Recursively compute the clips for all children of the root.
+ * They don't clip against each other or the root itself, so
+ * childClip is always reset to that child's size.
+ */
+
+ for (pWin = pChild;
+ pWin != NullWindow;
+ pWin = pWin->nextSib)
+ {
+ if (pWin->viewable) {
+ if (pWin->valdata) {
+ REGION_COPY( pScreen, &childClip, &pWin->borderSize);
+ RootlessComputeClips (pWin, pScreen, &childClip, kind, &exposed);
+ } else if (pWin->visibility == VisibilityNotViewable) {
+ RootlessTreeObscured(pWin);
+ }
+ } else {
+ if (pWin->valdata) {
+ REGION_EMPTY( pScreen, &pWin->clipList);
+ if (pScreen->ClipNotify)
+ (* pScreen->ClipNotify) (pWin, 0, 0);
+ REGION_EMPTY( pScreen, &pWin->borderClip);
+ pWin->valdata = (ValidatePtr)NULL;
+ }
+ }
+ }
+
+ REGION_UNINIT(pScreen, &childClip);
+
+ /* The root is never clipped by its children, so nothing on the root
+ is ever exposed by moving or mapping its children. */
+ REGION_NULL(pScreen, &pRoot->valdata->after.exposed);
+ REGION_NULL(pScreen, &pRoot->valdata->after.borderExposed);
+
+ return 1;
+}
diff --git a/nx-X11/programs/Xserver/miext/rootless/rootlessWindow.c b/nx-X11/programs/Xserver/miext/rootless/rootlessWindow.c
new file mode 100644
index 000000000..6eb66501d
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/rootlessWindow.c
@@ -0,0 +1,1468 @@
+/* $XdotOrg: xc/programs/Xserver/miext/rootless/rootlessWindow.c,v 1.6 2005/07/03 07:02:02 daniels Exp $ */
+/*
+ * Rootless window management
+ */
+/*
+ * Copyright (c) 2001 Greg Parker. All Rights Reserved.
+ * Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessWindow.c,v 1.12 2004/07/02 01:30:33 torrey Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "rootlessCommon.h"
+#include "rootlessWindow.h"
+
+#include "fb.h"
+
+
+#ifdef ROOTLESS_GLOBAL_COORDS
+#define SCREEN_TO_GLOBAL_X \
+ (dixScreenOrigins[pScreen->myNum].x + rootlessGlobalOffsetX)
+#define SCREEN_TO_GLOBAL_Y \
+ (dixScreenOrigins[pScreen->myNum].y + rootlessGlobalOffsetY)
+#else
+#define SCREEN_TO_GLOBAL_X 0
+#define SCREEN_TO_GLOBAL_Y 0
+#endif
+
+
+/*
+ * RootlessCreateWindow
+ * For now, don't create a physical window until either the window is
+ * realized, or we really need it (e.g. to attach VRAM surfaces to).
+ * Do reset the window size so it's not clipped by the root window.
+ */
+Bool
+RootlessCreateWindow(WindowPtr pWin)
+{
+ Bool result;
+ RegionRec saveRoot;
+
+ WINREC(pWin) = NULL;
+
+ SCREEN_UNWRAP(pWin->drawable.pScreen, CreateWindow);
+
+ if (!IsRoot(pWin)) {
+ /* win/border size set by DIX, not by wrapped CreateWindow, so
+ correct it here. Don't HUGE_ROOT when pWin is the root! */
+
+ HUGE_ROOT(pWin);
+ SetWinSize(pWin);
+ SetBorderSize(pWin);
+ }
+
+ result = pWin->drawable.pScreen->CreateWindow(pWin);
+
+ if (pWin->parent) {
+ NORMAL_ROOT(pWin);
+ }
+
+ SCREEN_WRAP(pWin->drawable.pScreen, CreateWindow);
+
+ return result;
+}
+
+
+/*
+ * RootlessDestroyFrame
+ * Destroy the physical window associated with the given window.
+ */
+static void
+RootlessDestroyFrame(WindowPtr pWin, RootlessWindowPtr winRec)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ SCREENREC(pScreen)->imp->DestroyFrame(winRec->wid);
+
+#ifdef ROOTLESS_TRACK_DAMAGE
+ REGION_UNINIT(pScreen, &winRec->damage);
+#endif
+
+ xfree(winRec);
+ WINREC(pWin) = NULL;
+}
+
+
+/*
+ * RootlessDestroyWindow
+ * Destroy the physical window associated with the given window.
+ */
+Bool
+RootlessDestroyWindow(WindowPtr pWin)
+{
+ RootlessWindowRec *winRec = WINREC(pWin);
+ Bool result;
+
+ if (winRec != NULL) {
+ RootlessDestroyFrame(pWin, winRec);
+ }
+
+ SCREEN_UNWRAP(pWin->drawable.pScreen, DestroyWindow);
+ result = pWin->drawable.pScreen->DestroyWindow(pWin);
+ SCREEN_WRAP(pWin->drawable.pScreen, DestroyWindow);
+
+ return result;
+}
+
+
+#ifdef SHAPE
+
+static Bool
+RootlessGetShape(WindowPtr pWin, RegionPtr pShape)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ if (wBoundingShape(pWin) == NULL)
+ return FALSE;
+
+ /* wBoundingShape is relative to *inner* origin of window.
+ Translate by borderWidth to get the outside-relative position. */
+
+ REGION_NULL(pScreen, pShape);
+ REGION_COPY(pScreen, pShape, wBoundingShape(pWin));
+ REGION_TRANSLATE(pScreen, pShape, pWin->borderWidth, pWin->borderWidth);
+
+ return TRUE;
+}
+
+
+/*
+ * RootlessReshapeFrame
+ * Set the frame shape.
+ */
+static void RootlessReshapeFrame(WindowPtr pWin)
+{
+ RootlessWindowRec *winRec = WINREC(pWin);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RegionRec newShape;
+ RegionPtr pShape;
+
+ // If the window is not yet framed, do nothing
+ if (winRec == NULL)
+ return;
+
+ if (IsRoot(pWin))
+ return;
+
+ RootlessStopDrawing(pWin, FALSE);
+
+ pShape = RootlessGetShape(pWin, &newShape) ? &newShape : NULL;
+
+#ifdef ROOTLESSDEBUG
+ RL_DEBUG_MSG("reshaping...");
+ if (pShape != NULL) {
+ RL_DEBUG_MSG("numrects %d, extents %d %d %d %d ",
+ REGION_NUM_RECTS(&newShape),
+ newShape.extents.x1, newShape.extents.y1,
+ newShape.extents.x2, newShape.extents.y2);
+ } else {
+ RL_DEBUG_MSG("no shape ");
+ }
+#endif
+
+ SCREENREC(pScreen)->imp->ReshapeFrame(winRec->wid, pShape);
+
+ if (pShape != NULL)
+ REGION_UNINIT(pScreen, &newShape);
+}
+
+
+/*
+ * RootlessSetShape
+ * Shape is usually set before a window is mapped and the window will
+ * not have a frame associated with it. In this case, the frame will be
+ * shaped when the window is framed.
+ */
+void
+RootlessSetShape(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ SCREEN_UNWRAP(pScreen, SetShape);
+ pScreen->SetShape(pWin);
+ SCREEN_WRAP(pScreen, SetShape);
+
+ RootlessReshapeFrame(pWin);
+}
+
+#endif // SHAPE
+
+
+/* Disallow ParentRelative background on top-level windows
+ because the root window doesn't really have the right background
+ and fb will try to draw on the root instead of on the window.
+ ParentRelative prevention is also in PaintWindowBackground/Border()
+ so it is no longer really needed here. */
+Bool
+RootlessChangeWindowAttributes(WindowPtr pWin, unsigned long vmask)
+{
+ Bool result;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ RL_DEBUG_MSG("change window attributes start ");
+
+ SCREEN_UNWRAP(pScreen, ChangeWindowAttributes);
+ result = pScreen->ChangeWindowAttributes(pWin, vmask);
+ SCREEN_WRAP(pScreen, ChangeWindowAttributes);
+
+ if (WINREC(pWin)) {
+ // disallow ParentRelative background state
+ if (pWin->backgroundState == ParentRelative) {
+ XID pixel = 0;
+ ChangeWindowAttributes(pWin, CWBackPixel, &pixel, serverClient);
+ }
+ }
+
+ RL_DEBUG_MSG("change window attributes end\n");
+ return result;
+}
+
+
+/*
+ * RootlessPositionWindow
+ * This is a hook for when DIX moves or resizes a window.
+ * Update the frame position now although the physical window is moved
+ * in RootlessMoveWindow. (x, y) are *inside* position. After this,
+ * mi and fb are expecting the pixmap to be at the new location.
+ */
+Bool
+RootlessPositionWindow(WindowPtr pWin, int x, int y)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RootlessWindowRec *winRec = WINREC(pWin);
+ Bool result;
+
+ RL_DEBUG_MSG("positionwindow start (win 0x%x @ %i, %i)\n", pWin, x, y);
+
+ if (winRec) {
+ if (winRec->is_drawing) {
+ // Reset frame's pixmap and move it to the new position.
+ int bw = wBorderWidth(pWin);
+
+ winRec->pixmap->devPrivate.ptr = winRec->pixelData;
+ SetPixmapBaseToScreen(winRec->pixmap, x - bw, y - bw);
+
+#ifdef ROOTLESS_TRACK_DAMAGE
+ // Move damaged region to correspond to new window position
+ if (REGION_NOTEMPTY(pScreen, &winRec->damage)) {
+ REGION_TRANSLATE(pScreen, &winRec->damage,
+ x - bw - winRec->x,
+ y - bw - winRec->y);
+ }
+#endif
+ }
+ }
+
+ SCREEN_UNWRAP(pScreen, PositionWindow);
+ result = pScreen->PositionWindow(pWin, x, y);
+ SCREEN_WRAP(pScreen, PositionWindow);
+
+ RL_DEBUG_MSG("positionwindow end\n");
+ return result;
+}
+
+
+/*
+ * RootlessInitializeFrame
+ * Initialize some basic attributes of the frame. Note that winRec
+ * may already have valid data in it, so don't overwrite anything
+ * valuable.
+ */
+static void
+RootlessInitializeFrame(WindowPtr pWin, RootlessWindowRec *winRec)
+{
+ DrawablePtr d = &pWin->drawable;
+ int bw = wBorderWidth(pWin);
+
+ winRec->win = pWin;
+
+ winRec->x = d->x - bw;
+ winRec->y = d->y - bw;
+ winRec->width = d->width + 2*bw;
+ winRec->height = d->height + 2*bw;
+ winRec->borderWidth = bw;
+
+#ifdef ROOTLESS_TRACK_DAMAGE
+ REGION_NULL(pScreen, &winRec->damage);
+#endif
+}
+
+
+/*
+ * RootlessEnsureFrame
+ * Make sure the given window is framed. If the window doesn't have a
+ * physical window associated with it, attempt to create one. If that
+ * is unsuccessful, return NULL.
+ */
+static RootlessWindowRec *
+RootlessEnsureFrame(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RootlessWindowRec *winRec;
+#ifdef SHAPE
+ RegionRec shape;
+ RegionPtr pShape = NULL;
+#endif
+
+ if (WINREC(pWin) != NULL)
+ return WINREC(pWin);
+
+ if (!IsTopLevel(pWin))
+ return NULL;
+
+ if (pWin->drawable.class != InputOutput)
+ return NULL;
+
+ winRec = xalloc(sizeof(RootlessWindowRec));
+
+ if (!winRec)
+ return NULL;
+
+ RootlessInitializeFrame(pWin, winRec);
+
+ winRec->is_drawing = FALSE;
+ winRec->is_reorder_pending = FALSE;
+ winRec->pixmap = NULL;
+ winRec->wid = NULL;
+
+ WINREC(pWin) = winRec;
+
+#ifdef SHAPE
+ // Set the frame's shape if the window is shaped
+ if (RootlessGetShape(pWin, &shape))
+ pShape = &shape;
+#endif
+
+ RL_DEBUG_MSG("creating frame ");
+
+ if (!SCREENREC(pScreen)->imp->CreateFrame(winRec, pScreen,
+ winRec->x + SCREEN_TO_GLOBAL_X,
+ winRec->y + SCREEN_TO_GLOBAL_Y,
+ pShape))
+ {
+ RL_DEBUG_MSG("implementation failed to create frame!\n");
+ xfree(winRec);
+ WINREC(pWin) = NULL;
+ return NULL;
+ }
+
+#ifdef SHAPE
+ if (pShape != NULL)
+ REGION_UNINIT(pScreen, &shape);
+#endif
+
+ return winRec;
+}
+
+
+/*
+ * RootlessRealizeWindow
+ * The frame is usually created here and not in CreateWindow so that
+ * windows do not eat memory until they are realized.
+ */
+Bool
+RootlessRealizeWindow(WindowPtr pWin)
+{
+ Bool result;
+ RegionRec saveRoot;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ RL_DEBUG_MSG("realizewindow start (win 0x%x) ", pWin);
+
+ if ((IsTopLevel(pWin) && pWin->drawable.class == InputOutput)) {
+ RootlessWindowRec *winRec;
+
+ winRec = RootlessEnsureFrame(pWin);
+ if (winRec == NULL)
+ return FALSE;
+
+ winRec->is_reorder_pending = TRUE;
+
+ RL_DEBUG_MSG("Top level window ");
+
+ // Disallow ParentRelative background state on top-level windows.
+ // This might have been set before the window was mapped.
+ if (pWin->backgroundState == ParentRelative) {
+ XID pixel = 0;
+ ChangeWindowAttributes(pWin, CWBackPixel, &pixel, serverClient);
+ }
+ }
+
+ if (!IsRoot(pWin)) HUGE_ROOT(pWin);
+ SCREEN_UNWRAP(pScreen, RealizeWindow);
+ result = pScreen->RealizeWindow(pWin);
+ SCREEN_WRAP(pScreen, RealizeWindow);
+ if (!IsRoot(pWin)) NORMAL_ROOT(pWin);
+
+ RL_DEBUG_MSG("realizewindow end\n");
+ return result;
+}
+
+
+/*
+ * RootlessFrameForWindow
+ * Returns the frame ID for the physical window displaying the given window.
+ * If CREATE is true and the window has no frame, attempt to create one.
+ */
+RootlessFrameID
+RootlessFrameForWindow(WindowPtr pWin, Bool create)
+{
+ WindowPtr pTopWin;
+ RootlessWindowRec *winRec;
+
+ pTopWin = TopLevelParent(pWin);
+ if (pTopWin == NULL)
+ return NULL;
+
+ winRec = WINREC(pTopWin);
+
+ if (winRec == NULL && create && pWin->drawable.class == InputOutput) {
+ winRec = RootlessEnsureFrame(pTopWin);
+ }
+
+ if (winRec == NULL)
+ return NULL;
+
+ return winRec->wid;
+}
+
+
+/*
+ * RootlessUnrealizeWindow
+ * Unmap the physical window.
+ */
+Bool
+RootlessUnrealizeWindow(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RootlessWindowRec *winRec = WINREC(pWin);
+ Bool result;
+
+ RL_DEBUG_MSG("unrealizewindow start ");
+
+ if (winRec) {
+ RootlessStopDrawing(pWin, FALSE);
+
+ SCREENREC(pScreen)->imp->UnmapFrame(winRec->wid);
+
+ winRec->is_reorder_pending = FALSE;
+ }
+
+ SCREEN_UNWRAP(pScreen, UnrealizeWindow);
+ result = pScreen->UnrealizeWindow(pWin);
+ SCREEN_WRAP(pScreen, UnrealizeWindow);
+
+ RL_DEBUG_MSG("unrealizewindow end\n");
+ return result;
+}
+
+
+/*
+ * RootlessReorderWindow
+ * Reorder the frame associated with the given window so that it's
+ * physically above the window below it in the X stacking order.
+ */
+void
+RootlessReorderWindow(WindowPtr pWin)
+{
+ RootlessWindowRec *winRec = WINREC(pWin);
+
+ if (winRec != NULL && !winRec->is_reorder_pending) {
+ WindowPtr newPrevW;
+ RootlessWindowRec *newPrev;
+ RootlessFrameID newPrevID;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ /* Check if the implementation wants the frame to not be reordered
+ even though the X11 window is restacked. This can be useful if
+ frames are ordered-in with animation so that the reordering is not
+ done until the animation is complete. */
+ if (SCREENREC(pScreen)->imp->DoReorderWindow) {
+ if (!SCREENREC(pScreen)->imp->DoReorderWindow(winRec))
+ return;
+ }
+
+ RootlessStopDrawing(pWin, FALSE);
+
+ /* Find the next window above this one that has a mapped frame. */
+
+ newPrevW = pWin->prevSib;
+ while (newPrevW && (WINREC(newPrevW) == NULL || !newPrevW->realized))
+ newPrevW = newPrevW->prevSib;
+
+ newPrev = newPrevW != NULL ? WINREC(newPrevW) : NULL;
+ newPrevID = newPrev != NULL ? newPrev->wid : 0;
+
+ /* If it exists, reorder the frame above us first. */
+
+ if (newPrev && newPrev->is_reorder_pending) {
+ newPrev->is_reorder_pending = FALSE;
+ RootlessReorderWindow(newPrevW);
+ }
+
+ SCREENREC(pScreen)->imp->RestackFrame(winRec->wid, newPrevID);
+ }
+}
+
+
+/*
+ * RootlessRestackWindow
+ * This is a hook for when DIX changes the window stacking order.
+ * The window has already been inserted into its new position in the
+ * DIX window stack. We need to change the order of the physical
+ * window to match.
+ */
+void
+RootlessRestackWindow(WindowPtr pWin, WindowPtr pOldNextSib)
+{
+ RegionRec saveRoot;
+ RootlessWindowRec *winRec = WINREC(pWin);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ RL_DEBUG_MSG("restackwindow start ");
+ if (winRec)
+ RL_DEBUG_MSG("restack top level \n");
+
+ HUGE_ROOT(pWin);
+ SCREEN_UNWRAP(pScreen, RestackWindow);
+
+ if (pScreen->RestackWindow)
+ pScreen->RestackWindow(pWin, pOldNextSib);
+
+ SCREEN_WRAP(pScreen, RestackWindow);
+ NORMAL_ROOT(pWin);
+
+ if (winRec && pWin->viewable) {
+ RootlessReorderWindow(pWin);
+ }
+
+ RL_DEBUG_MSG("restackwindow end\n");
+}
+
+
+/*
+ * Specialized window copy procedures
+ */
+
+// Globals needed during window resize and move.
+static pointer gResizeDeathBits = NULL;
+static int gResizeDeathCount = 0;
+static PixmapPtr gResizeDeathPix[2] = {NULL, NULL};
+static BoxRec gResizeDeathBounds[2];
+static CopyWindowProcPtr gResizeOldCopyWindowProc = NULL;
+
+/*
+ * RootlessNoCopyWindow
+ * CopyWindow() that doesn't do anything. For MoveWindow() of
+ * top-level windows.
+ */
+static void
+RootlessNoCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc)
+{
+ // some code expects the region to be translated
+ int dx = ptOldOrg.x - pWin->drawable.x;
+ int dy = ptOldOrg.y - pWin->drawable.y;
+
+ RL_DEBUG_MSG("ROOTLESSNOCOPYWINDOW ");
+
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+}
+
+
+/*
+ * RootlessResizeCopyWindow
+ * CopyWindow used during ResizeWindow for gravity moves. Based on
+ * fbCopyWindow. The original always draws on the root pixmap, which
+ * we don't have. Instead, draw on the parent window's pixmap.
+ * Resize version: the old location's pixels are in gResizeCopyWindowSource.
+ */
+static void
+RootlessResizeCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RegionRec rgnDst;
+ int dx, dy;
+
+ RL_DEBUG_MSG("resizecopywindowFB start (win 0x%x) ", pWin);
+
+ /* Don't unwrap pScreen->CopyWindow.
+ The bogus rewrap with RootlessCopyWindow causes a crash if
+ CopyWindow is called again during the same resize. */
+
+ if (gResizeDeathCount == 0)
+ return;
+
+ RootlessStartDrawing(pWin);
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
+ REGION_NULL(pScreen, &rgnDst);
+ REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+
+ if (gResizeDeathCount == 1) {
+ /* Simple case, we only have a single source pixmap. */
+
+ fbCopyRegion(&gResizeDeathPix[0]->drawable,
+ &pScreen->GetWindowPixmap(pWin)->drawable, 0,
+ &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
+ }
+ else {
+ int i;
+ RegionRec clip, clipped;
+
+ /* More complex case, N source pixmaps (usually two). So we
+ intersect the destination with each source and copy those bits. */
+
+ for (i = 0; i < gResizeDeathCount; i++) {
+ REGION_INIT(pScreen, &clip, gResizeDeathBounds + 0, 1);
+ REGION_NULL(pScreen, &clipped);
+ REGION_INTERSECT(pScreen, &rgnDst, &clip, &clipped);
+
+ fbCopyRegion(&gResizeDeathPix[i]->drawable,
+ &pScreen->GetWindowPixmap(pWin)->drawable, 0,
+ &clipped, dx, dy, fbCopyWindowProc, 0, 0);
+
+ REGION_UNINIT(pScreen, &clipped);
+ REGION_UNINIT(pScreen, &clip);
+ }
+ }
+
+ /* Don't update - resize will update everything */
+ REGION_UNINIT(pScreen, &rgnDst);
+
+ fbValidateDrawable(&pWin->drawable);
+
+ RL_DEBUG_MSG("resizecopywindowFB end\n");
+}
+
+
+/*
+ * RootlessCopyWindow
+ * Update *new* location of window. Old location is redrawn with
+ * PaintWindowBackground/Border. Cloned from fbCopyWindow.
+ * The original always draws on the root pixmap, which we don't have.
+ * Instead, draw on the parent window's pixmap.
+ */
+void
+RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RegionRec rgnDst;
+ int dx, dy;
+ BoxPtr extents;
+ int area;
+
+ RL_DEBUG_MSG("copywindowFB start (win 0x%x) ", pWin);
+
+ SCREEN_UNWRAP(pScreen, CopyWindow);
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
+
+ REGION_NULL(pScreen, &rgnDst);
+ REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+
+ extents = REGION_EXTENTS(pScreen, &rgnDst);
+ area = (extents->x2 - extents->x1) * (extents->y2 - extents->y1);
+
+ /* If the area exceeds threshold, use the implementation's
+ accelerated version. */
+ if (area > rootless_CopyWindow_threshold &&
+ SCREENREC(pScreen)->imp->CopyWindow)
+ {
+ RootlessWindowRec *winRec;
+ WindowPtr top;
+
+ top = TopLevelParent(pWin);
+ if (top == NULL) {
+ RL_DEBUG_MSG("no parent\n");
+ return;
+ }
+
+ winRec = WINREC(top);
+ if (winRec == NULL) {
+ RL_DEBUG_MSG("not framed\n");
+ return;
+ }
+
+ /* Move region to window local coords */
+ REGION_TRANSLATE(pScreen, &rgnDst, -winRec->x, -winRec->y);
+
+ RootlessStopDrawing(pWin, FALSE);
+
+ SCREENREC(pScreen)->imp->CopyWindow(winRec->wid,
+ REGION_NUM_RECTS(&rgnDst),
+ REGION_RECTS(&rgnDst),
+ dx, dy);
+ }
+ else {
+ RootlessStartDrawing(pWin);
+
+ fbCopyRegion((DrawablePtr) pWin, (DrawablePtr) pWin,
+ 0, &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
+
+ /* prgnSrc has been translated to dst position */
+ RootlessDamageRegion(pWin, prgnSrc);
+ }
+
+ REGION_UNINIT(pScreen, &rgnDst);
+ fbValidateDrawable(&pWin->drawable);
+
+ SCREEN_WRAP(pScreen, CopyWindow);
+
+ RL_DEBUG_MSG("copywindowFB end\n");
+}
+
+
+/*
+ * Window resize procedures
+ */
+
+enum {
+ WIDTH_SMALLER = 1,
+ HEIGHT_SMALLER = 2,
+};
+
+
+/*
+ * ResizeWeighting
+ * Choose gravity to avoid local copies. Do that by looking for
+ * a corner that doesn't move _relative to the screen_.
+ */
+static inline unsigned int
+ResizeWeighting(int oldX1, int oldY1, int oldX2, int oldY2, int oldBW,
+ int newX1, int newY1, int newX2, int newY2, int newBW)
+{
+#ifdef ROOTLESS_RESIZE_GRAVITY
+ if (newBW != oldBW)
+ return RL_GRAVITY_NONE;
+
+ if (newX1 == oldX1 && newY1 == oldY1)
+ return RL_GRAVITY_NORTH_WEST;
+ else if (newX1 == oldX1 && newY2 == oldY2)
+ return RL_GRAVITY_SOUTH_WEST;
+ else if (newX2 == oldX2 && newY2 == oldY2)
+ return RL_GRAVITY_SOUTH_EAST;
+ else if (newX2 == oldX2 && newY1 == oldY1)
+ return RL_GRAVITY_NORTH_EAST;
+ else
+ return RL_GRAVITY_NONE;
+#else
+ return RL_GRAVITY_NONE;
+#endif
+}
+
+
+/*
+ * StartFrameResize
+ * Prepare to resize a top-level window. The old window's pixels are
+ * saved and the implementation is told to change the window size.
+ * (x,y,w,h) is outer frame of window (outside border)
+ */
+static Bool
+StartFrameResize(WindowPtr pWin, Bool gravity,
+ int oldX, int oldY, int oldW, int oldH, int oldBW,
+ int newX, int newY, int newW, int newH, int newBW)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RootlessWindowRec *winRec = WINREC(pWin);
+ Bool need_window_source = FALSE, resize_after = FALSE;
+
+ BoxRec rect;
+ int oldX2, newX2;
+ int oldY2, newY2;
+ unsigned int weight;
+
+ oldX2 = oldX + oldW, newX2 = newX + newW;
+ oldY2 = oldY + oldH, newY2 = newY + newH;
+
+ /* Decide which resize weighting to use */
+ weight = ResizeWeighting(oldX, oldY, oldW, oldH, oldBW,
+ newX, newY, newW, newH, newBW);
+
+ /* Compute intersection between old and new rects */
+ rect.x1 = max(oldX, newX);
+ rect.y1 = max(oldY, newY);
+ rect.x2 = min(oldX2, newX2);
+ rect.y2 = min(oldY2, newY2);
+
+ RL_DEBUG_MSG("RESIZE TOPLEVEL WINDOW with gravity %i ", gravity);
+ RL_DEBUG_MSG("%d %d %d %d %d %d %d %d %d %d\n",
+ oldX, oldY, oldW, oldH, oldBW,
+ newX, newY, newW, newH, newBW);
+
+ RootlessRedisplay(pWin);
+
+ /* If gravity is true, then we need to have a way of recovering all
+ the original bits in the window for when X rearranges the contents
+ based on the various gravity settings. The obvious way is to just
+ snapshot the entire backing store before resizing it, but that
+ it slow on large windows.
+
+ So the optimization here is to use the implementation's resize
+ weighting options (if available) to allow us to reason about what
+ is left in the backing store after the resize. We can then only
+ copy what won't be there after the resize, and do a two-stage copy
+ operation.
+
+ Most of these optimizations are only applied when the top-left
+ corner of the window is fixed, since that's the common case. They
+ could probably be extended with some thought. */
+
+ gResizeDeathCount = 0;
+
+ if (gravity && weight == RL_GRAVITY_NORTH_WEST) {
+ unsigned int code = 0;
+
+ /* Top left corner is anchored. We never need to copy the
+ entire window. */
+
+ need_window_source = TRUE;
+
+ /* These comparisons were chosen to avoid setting bits when the sizes
+ are the same. (So the fastest case automatically gets taken when
+ dimensions are unchanging.) */
+
+ if (newW < oldW)
+ code |= WIDTH_SMALLER;
+ if (newH < oldH)
+ code |= HEIGHT_SMALLER;
+
+ if (((code ^ (code >> 1)) & 1) == 0) {
+ /* Both dimensions are either getting larger, or both
+ are getting smaller. No need to copy anything. */
+
+ if (code == (WIDTH_SMALLER | HEIGHT_SMALLER)) {
+ /* Since the window is getting smaller, we can do gravity
+ repair on it with it's current size, then resize it
+ afterwards. */
+
+ resize_after = TRUE;
+ }
+
+ gResizeDeathCount = 1;
+ }
+ else {
+ unsigned int copy_rowbytes, Bpp;
+ unsigned int copy_rect_width, copy_rect_height;
+ BoxRec copy_rect;
+
+ /* We can get away with a partial copy. 'rect' is the
+ intersection between old and new bounds, so copy
+ everything to the right of or below the intersection. */
+
+ RootlessStartDrawing(pWin);
+
+ if (code == WIDTH_SMALLER) {
+ copy_rect.x1 = rect.x2;
+ copy_rect.y1 = rect.y1;
+ copy_rect.x2 = oldX2;
+ copy_rect.y2 = oldY2;
+ }
+ else if (code == HEIGHT_SMALLER) {
+ copy_rect.x1 = rect.x1;
+ copy_rect.y1 = rect.y2;
+ copy_rect.x2 = oldX2;
+ copy_rect.y2 = oldY2;
+ }
+ else
+ abort();
+
+ Bpp = winRec->win->drawable.bitsPerPixel / 8;
+ copy_rect_width = copy_rect.x2 - copy_rect.x1;
+ copy_rect_height = copy_rect.y2 - copy_rect.y1;
+ copy_rowbytes = ((copy_rect_width * Bpp) + 31) & ~31;
+ gResizeDeathBits = xalloc(copy_rowbytes
+ * copy_rect_height);
+
+ if (copy_rect_width * copy_rect_height >
+ rootless_CopyBytes_threshold &&
+ SCREENREC(pScreen)->imp->CopyBytes)
+ {
+ SCREENREC(pScreen)->imp->CopyBytes(
+ copy_rect_width * Bpp, copy_rect_height,
+ ((char *) winRec->pixelData)
+ + ((copy_rect.y1 - oldY) * winRec->bytesPerRow)
+ + (copy_rect.x1 - oldX) * Bpp, winRec->bytesPerRow,
+ gResizeDeathBits, copy_rowbytes);
+ } else {
+ fbBlt((FbBits *) (winRec->pixelData
+ + ((copy_rect.y1 - oldY) * winRec->bytesPerRow)
+ + (copy_rect.x1 - oldX) * Bpp),
+ winRec->bytesPerRow / sizeof(FbBits), 0,
+ (FbBits *) gResizeDeathBits,
+ copy_rowbytes / sizeof(FbBits), 0,
+ copy_rect_width * Bpp, copy_rect_height,
+ GXcopy, FB_ALLONES, Bpp, 0, 0);
+ }
+
+ gResizeDeathBounds[1] = copy_rect;
+ gResizeDeathPix[1]
+ = GetScratchPixmapHeader(pScreen, copy_rect_width,
+ copy_rect_height,
+ winRec->win->drawable.depth,
+ winRec->win->drawable.bitsPerPixel,
+ winRec->bytesPerRow,
+ (void *) gResizeDeathBits);
+
+ SetPixmapBaseToScreen(gResizeDeathPix[1],
+ copy_rect.x1, copy_rect.y1);
+
+ gResizeDeathCount = 2;
+ }
+ }
+ else if (gravity) {
+ /* The general case. Just copy everything. */
+
+ RootlessStartDrawing(pWin);
+
+ gResizeDeathBits = xalloc(winRec->bytesPerRow * winRec->height);
+
+ memcpy(gResizeDeathBits, winRec->pixelData,
+ winRec->bytesPerRow * winRec->height);
+
+ gResizeDeathBounds[0] = (BoxRec) {oldX, oldY, oldX2, oldY2};
+ gResizeDeathPix[0]
+ = GetScratchPixmapHeader(pScreen, winRec->width,
+ winRec->height,
+ winRec->win->drawable.depth,
+ winRec->win->drawable.bitsPerPixel,
+ winRec->bytesPerRow,
+ (void *) gResizeDeathBits);
+
+ SetPixmapBaseToScreen(gResizeDeathPix[0], oldX, oldY);
+ gResizeDeathCount = 1;
+ }
+
+ RootlessStopDrawing(pWin, FALSE);
+
+ winRec->x = newX;
+ winRec->y = newY;
+ winRec->width = newW;
+ winRec->height = newH;
+ winRec->borderWidth = newBW;
+
+ /* Unless both dimensions are getting smaller, Resize the frame
+ before doing gravity repair */
+
+ if (!resize_after) {
+ SCREENREC(pScreen)->imp->ResizeFrame(winRec->wid, pScreen,
+ newX + SCREEN_TO_GLOBAL_X,
+ newY + SCREEN_TO_GLOBAL_Y,
+ newW, newH, weight);
+ }
+
+ RootlessStartDrawing(pWin);
+
+ /* If necessary, create a source pixmap pointing at the current
+ window bits. */
+
+ if (need_window_source) {
+ gResizeDeathBounds[0] = (BoxRec) {oldX, oldY, oldX2, oldY2};
+ gResizeDeathPix[0]
+ = GetScratchPixmapHeader(pScreen, oldW, oldH,
+ winRec->win->drawable.depth,
+ winRec->win->drawable.bitsPerPixel,
+ winRec->bytesPerRow, winRec->pixelData);
+
+ SetPixmapBaseToScreen(gResizeDeathPix[0], oldX, oldY);
+ }
+
+ /* Use custom CopyWindow when moving gravity bits around
+ ResizeWindow assumes the old window contents are in the same
+ pixmap, but here they're in deathPix instead. */
+
+ if (gravity) {
+ gResizeOldCopyWindowProc = pScreen->CopyWindow;
+ pScreen->CopyWindow = RootlessResizeCopyWindow;
+ }
+
+ /* If we can't rely on the window server preserving the bits we
+ need in the position we need, copy the pixels in the
+ intersection from src to dst. ResizeWindow assumes these pixels
+ are already present when making gravity adjustments. pWin
+ currently has new-sized pixmap but is in old position.
+
+ FIXME: border width change! (?) */
+
+ if (gravity && weight == RL_GRAVITY_NONE) {
+ PixmapPtr src, dst;
+
+ assert(gResizeDeathCount == 1);
+
+ src = gResizeDeathPix[0];
+ dst = pScreen->GetWindowPixmap(pWin);
+
+ RL_DEBUG_MSG("Resize copy rect %d %d %d %d\n",
+ rect.x1, rect.y1, rect.x2, rect.y2);
+
+ /* rect is the intersection of the old location and new location */
+ if (BOX_NOT_EMPTY(rect) && src != NULL && dst != NULL) {
+ /* The window drawable still has the old frame position, which
+ means that DST doesn't actually point at the origin of our
+ physical backing store when adjusted by the drawable.x,y
+ position. So sneakily adjust it temporarily while copying.. */
+
+ ((PixmapPtr) dst)->devPrivate.ptr = winRec->pixelData;
+ SetPixmapBaseToScreen(dst, newX, newY);
+
+ fbCopyWindowProc(&src->drawable, &dst->drawable, NULL,
+ &rect, 1, 0, 0, FALSE, FALSE, 0, 0);
+
+ ((PixmapPtr) dst)->devPrivate.ptr = winRec->pixelData;
+ SetPixmapBaseToScreen(dst, oldX, oldY);
+ }
+ }
+
+ return resize_after;
+}
+
+
+static void
+FinishFrameResize(WindowPtr pWin, Bool gravity, int oldX, int oldY,
+ unsigned int oldW, unsigned int oldH, unsigned int oldBW,
+ int newX, int newY, unsigned int newW, unsigned int newH,
+ unsigned int newBW, Bool resize_now)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RootlessWindowRec *winRec = WINREC(pWin);
+ int i;
+
+ RootlessStopDrawing(pWin, FALSE);
+
+ if (resize_now) {
+ unsigned int weight;
+
+ /* We didn't resize anything earlier, so do it now, now that
+ we've finished gravitating the bits. */
+
+ weight = ResizeWeighting(oldX, oldY, oldW, oldH, oldBW,
+ newX, newY, newW, newH, newBW);
+
+ SCREENREC(pScreen)->imp->ResizeFrame(winRec->wid, pScreen,
+ newX + SCREEN_TO_GLOBAL_X,
+ newY + SCREEN_TO_GLOBAL_Y,
+ newW, newH, weight);
+ }
+
+ /* Redraw everything. FIXME: there must be times when we don't need
+ to do this. Perhaps when top-left weighting and no gravity? */
+
+ RootlessDamageRect(pWin, -newBW, -newBW, newW, newH);
+
+ for (i = 0; i < 2; i++) {
+ if (gResizeDeathPix[i] != NULL) {
+ FreeScratchPixmapHeader(gResizeDeathPix[i]);
+ gResizeDeathPix[i] = NULL;
+ }
+ }
+
+ if (gResizeDeathBits != NULL) {
+ xfree(gResizeDeathBits);
+ gResizeDeathBits = NULL;
+ }
+
+ if (gravity) {
+ pScreen->CopyWindow = gResizeOldCopyWindowProc;
+ }
+}
+
+
+/*
+ * RootlessMoveWindow
+ * If kind==VTOther, window border is resizing (and borderWidth is
+ * already changed!!@#$) This case works like window resize, not move.
+ */
+void
+RootlessMoveWindow(WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind)
+{
+ RootlessWindowRec *winRec = WINREC(pWin);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ CopyWindowProcPtr oldCopyWindowProc = NULL;
+ int oldX = 0, oldY = 0, newX = 0, newY = 0;
+ unsigned int oldW = 0, oldH = 0, oldBW = 0;
+ unsigned int newW = 0, newH = 0, newBW = 0;
+ Bool resize_after = FALSE;
+ RegionRec saveRoot;
+
+ RL_DEBUG_MSG("movewindow start \n");
+
+ if (winRec) {
+ if (kind == VTMove) {
+ oldX = winRec->x;
+ oldY = winRec->y;
+ RootlessRedisplay(pWin);
+ RootlessStartDrawing(pWin);
+ } else {
+ RL_DEBUG_MSG("movewindow border resizing ");
+
+ oldBW = winRec->borderWidth;
+ oldX = winRec->x;
+ oldY = winRec->y;
+ oldW = winRec->width;
+ oldH = winRec->height;
+
+ newBW = wBorderWidth(pWin);
+ newX = x;
+ newY = y;
+ newW = pWin->drawable.width + 2*newBW;
+ newH = pWin->drawable.height + 2*newBW;
+
+ resize_after = StartFrameResize(pWin, FALSE,
+ oldX, oldY, oldW, oldH, oldBW,
+ newX, newY, newW, newH, newBW);
+ }
+ }
+
+ HUGE_ROOT(pWin);
+ SCREEN_UNWRAP(pScreen, MoveWindow);
+
+ if (winRec) {
+ oldCopyWindowProc = pScreen->CopyWindow;
+ pScreen->CopyWindow = RootlessNoCopyWindow;
+ }
+ pScreen->MoveWindow(pWin, x, y, pSib, kind);
+ if (winRec) {
+ pScreen->CopyWindow = oldCopyWindowProc;
+ }
+
+ NORMAL_ROOT(pWin);
+ SCREEN_WRAP(pScreen, MoveWindow);
+
+ if (winRec) {
+ if (kind == VTMove) {
+ winRec->x = x;
+ winRec->y = y;
+ RootlessStopDrawing(pWin, FALSE);
+ SCREENREC(pScreen)->imp->MoveFrame(winRec->wid, pScreen,
+ x + SCREEN_TO_GLOBAL_X,
+ y + SCREEN_TO_GLOBAL_Y);
+ } else {
+ FinishFrameResize(pWin, FALSE, oldX, oldY, oldW, oldH, oldBW,
+ newX, newY, newW, newH, newBW, resize_after);
+ }
+ }
+
+ RL_DEBUG_MSG("movewindow end\n");
+}
+
+
+/*
+ * RootlessResizeWindow
+ * Note: (x, y, w, h) as passed to this procedure don't match the frame
+ * definition. (x,y) is corner of very outer edge, *outside* border.
+ * w,h is width and height *inside* border, *ignoring* border width.
+ * The rect (x, y, w, h) doesn't mean anything. (x, y, w+2*bw, h+2*bw)
+ * is total rect and (x+bw, y+bw, w, h) is inner rect.
+ */
+void
+RootlessResizeWindow(WindowPtr pWin, int x, int y,
+ unsigned int w, unsigned int h, WindowPtr pSib)
+{
+ RootlessWindowRec *winRec = WINREC(pWin);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ int oldX = 0, oldY = 0, newX = 0, newY = 0;
+ unsigned int oldW = 0, oldH = 0, oldBW = 0, newW = 0, newH = 0, newBW = 0;
+ Bool resize_after = FALSE;
+ RegionRec saveRoot;
+
+ RL_DEBUG_MSG("resizewindow start (win 0x%x) ", pWin);
+
+ if (winRec) {
+ oldBW = winRec->borderWidth;
+ oldX = winRec->x;
+ oldY = winRec->y;
+ oldW = winRec->width;
+ oldH = winRec->height;
+
+ newBW = oldBW;
+ newX = x;
+ newY = y;
+ newW = w + 2*newBW;
+ newH = h + 2*newBW;
+
+ resize_after = StartFrameResize(pWin, TRUE,
+ oldX, oldY, oldW, oldH, oldBW,
+ newX, newY, newW, newH, newBW);
+ }
+
+ HUGE_ROOT(pWin);
+ SCREEN_UNWRAP(pScreen, ResizeWindow);
+ pScreen->ResizeWindow(pWin, x, y, w, h, pSib);
+ SCREEN_WRAP(pScreen, ResizeWindow);
+ NORMAL_ROOT(pWin);
+
+ if (winRec) {
+ FinishFrameResize(pWin, TRUE, oldX, oldY, oldW, oldH, oldBW,
+ newX, newY, newW, newH, newBW, resize_after);
+ }
+
+ RL_DEBUG_MSG("resizewindow end\n");
+}
+
+
+/*
+ * RootlessRepositionWindow
+ * Called by the implementation when a window needs to be repositioned to
+ * its correct location on the screen. This routine is typically needed
+ * due to changes in the underlying window system, such as a screen layout
+ * change.
+ */
+void
+RootlessRepositionWindow(WindowPtr pWin)
+{
+ RootlessWindowRec *winRec = WINREC(pWin);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ if (winRec == NULL)
+ return;
+
+ RootlessStopDrawing(pWin, FALSE);
+ SCREENREC(pScreen)->imp->MoveFrame(winRec->wid, pScreen,
+ winRec->x + SCREEN_TO_GLOBAL_X,
+ winRec->y + SCREEN_TO_GLOBAL_Y);
+
+ RootlessReorderWindow(pWin);
+}
+
+
+/*
+ * RootlessReparentWindow
+ * Called after a window has been reparented. Generally windows are not
+ * framed until they are mapped. However, a window may be framed early by the
+ * implementation calling RootlessFrameForWindow. (e.g. this could be needed
+ * to attach a VRAM surface to it.) If the window is subsequently reparented
+ * by the window manager before being mapped, we need to give the frame to
+ * the new top-level window.
+ */
+void
+RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RootlessWindowRec *winRec = WINREC(pWin);
+ WindowPtr pTopWin;
+
+ /* Check that window is not top-level now, but used to be. */
+ if (IsRoot(pWin) || IsRoot(pWin->parent)
+ || IsTopLevel(pWin) || winRec == NULL)
+ {
+ goto out;
+ }
+
+ /* If the formerly top-level window has a frame, we want to give the
+ frame to its new top-level parent. If we can't do that, we'll just
+ have to jettison it... */
+
+ pTopWin = TopLevelParent(pWin);
+ assert(pTopWin != pWin);
+
+ if (WINREC(pTopWin) != NULL) {
+ /* We're screwed. */
+ RootlessDestroyFrame(pWin, winRec);
+ } else {
+ if (!pTopWin->realized && pWin->realized) {
+ SCREENREC(pScreen)->imp->UnmapFrame(winRec->wid);
+ }
+
+ /* Switch the frame record from one to the other. */
+
+ WINREC(pWin) = NULL;
+ WINREC(pTopWin) = winRec;
+
+ RootlessInitializeFrame(pTopWin, winRec);
+ RootlessReshapeFrame(pTopWin);
+
+ SCREENREC(pScreen)->imp->ResizeFrame(winRec->wid, pScreen,
+ winRec->x + SCREEN_TO_GLOBAL_X,
+ winRec->y + SCREEN_TO_GLOBAL_Y,
+ winRec->width, winRec->height,
+ RL_GRAVITY_NONE);
+
+ if (SCREENREC(pScreen)->imp->SwitchWindow) {
+ SCREENREC(pScreen)->imp->SwitchWindow(winRec, pWin);
+ }
+
+ if (pTopWin->realized && !pWin->realized)
+ winRec->is_reorder_pending = TRUE;
+ }
+
+out:
+ if (SCREENREC(pScreen)->ReparentWindow) {
+ SCREEN_UNWRAP(pScreen, ReparentWindow);
+ pScreen->ReparentWindow(pWin, pPriorParent);
+ SCREEN_WRAP(pScreen, ReparentWindow);
+ }
+}
+
+
+/*
+ * SetPixmapOfAncestors
+ * Set the Pixmaps on all ParentRelative windows up the ancestor chain.
+ */
+static void
+SetPixmapOfAncestors(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr topWin = TopLevelParent(pWin);
+ RootlessWindowRec *topWinRec = WINREC(topWin);
+
+ while (pWin->backgroundState == ParentRelative) {
+ if (pWin == topWin) {
+ // disallow ParentRelative background state on top level
+ XID pixel = 0;
+ ChangeWindowAttributes(pWin, CWBackPixel, &pixel, serverClient);
+ RL_DEBUG_MSG("Cleared ParentRelative on 0x%x.\n", pWin);
+ break;
+ }
+
+ pWin = pWin->parent;
+ pScreen->SetWindowPixmap(pWin, topWinRec->pixmap);
+ }
+}
+
+
+/*
+ * RootlessPaintWindowBackground
+ */
+void
+RootlessPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ if (IsRoot(pWin))
+ return;
+
+ RL_DEBUG_MSG("paintwindowbackground start (win 0x%x, framed %i) ",
+ pWin, IsFramedWindow(pWin));
+
+ if (IsFramedWindow(pWin)) {
+ RootlessStartDrawing(pWin);
+ RootlessDamageRegion(pWin, pRegion);
+
+ // For ParentRelative windows, we have to make sure the window
+ // pixmap is set correctly all the way up the ancestor chain.
+ if (pWin->backgroundState == ParentRelative) {
+ SetPixmapOfAncestors(pWin);
+ }
+ }
+
+ SCREEN_UNWRAP(pScreen, PaintWindowBackground);
+ pScreen->PaintWindowBackground(pWin, pRegion, what);
+ SCREEN_WRAP(pScreen, PaintWindowBackground);
+
+ RL_DEBUG_MSG("paintwindowbackground end\n");
+}
+
+
+/*
+ * RootlessPaintWindowBorder
+ */
+void
+RootlessPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ RL_DEBUG_MSG("paintwindowborder start (win 0x%x) ", pWin);
+
+ if (IsFramedWindow(pWin)) {
+ RootlessStartDrawing(pWin);
+ RootlessDamageRegion(pWin, pRegion);
+
+ // For ParentRelative windows with tiled borders, we have to make
+ // sure the window pixmap is set correctly all the way up the
+ // ancestor chain.
+ if (!pWin->borderIsPixel &&
+ pWin->backgroundState == ParentRelative)
+ {
+ SetPixmapOfAncestors(pWin);
+ }
+ }
+
+ SCREEN_UNWRAP(pWin->drawable.pScreen, PaintWindowBorder);
+ pWin->drawable.pScreen->PaintWindowBorder(pWin, pRegion, what);
+ SCREEN_WRAP(pWin->drawable.pScreen, PaintWindowBorder);
+
+ RL_DEBUG_MSG("paintwindowborder end\n");
+}
+
+
+/*
+ * RootlessChangeBorderWidth
+ * FIXME: untested!
+ * pWin inside corner stays the same; pWin->drawable.[xy] stays the same
+ * Frame moves and resizes.
+ */
+void
+RootlessChangeBorderWidth(WindowPtr pWin, unsigned int width)
+{
+ RegionRec saveRoot;
+ Bool resize_after = FALSE;
+
+ RL_DEBUG_MSG("change border width ");
+
+ if (width != wBorderWidth(pWin)) {
+ RootlessWindowRec *winRec = WINREC(pWin);
+ int oldX = 0, oldY = 0, newX = 0, newY = 0;
+ unsigned int oldW = 0, oldH = 0, oldBW = 0;
+ unsigned int newW = 0, newH = 0, newBW = 0;
+
+ if (winRec) {
+ oldBW = winRec->borderWidth;
+ oldX = winRec->x;
+ oldY = winRec->y;
+ oldW = winRec->width;
+ oldH = winRec->height;
+
+ newBW = width;
+ newX = pWin->drawable.x - newBW;
+ newY = pWin->drawable.y - newBW;
+ newW = pWin->drawable.width + 2*newBW;
+ newH = pWin->drawable.height + 2*newBW;
+
+ resize_after = StartFrameResize(pWin, FALSE,
+ oldX, oldY, oldW, oldH, oldBW,
+ newX, newY, newW, newH, newBW);
+ }
+
+ HUGE_ROOT(pWin);
+ SCREEN_UNWRAP(pWin->drawable.pScreen, ChangeBorderWidth);
+ pWin->drawable.pScreen->ChangeBorderWidth(pWin, width);
+ SCREEN_WRAP(pWin->drawable.pScreen, ChangeBorderWidth);
+ NORMAL_ROOT(pWin);
+
+ if (winRec) {
+ FinishFrameResize(pWin, FALSE, oldX, oldY, oldW, oldH, oldBW,
+ newX, newY, newW, newH, newBW, resize_after);
+ }
+ }
+
+ RL_DEBUG_MSG("change border width end\n");
+}
diff --git a/nx-X11/programs/Xserver/miext/rootless/rootlessWindow.h b/nx-X11/programs/Xserver/miext/rootless/rootlessWindow.h
new file mode 100644
index 000000000..9cceed347
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/rootlessWindow.h
@@ -0,0 +1,64 @@
+/*
+ * Rootless window management
+ */
+/*
+ * Copyright (c) 2001 Greg Parker. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessWindow.h,v 1.1 2003/04/15 01:05:44 torrey Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _ROOTLESSWINDOW_H
+#define _ROOTLESSWINDOW_H
+
+#include "rootlessCommon.h"
+
+
+Bool RootlessCreateWindow(WindowPtr pWin);
+Bool RootlessDestroyWindow(WindowPtr pWin);
+
+#ifdef SHAPE
+void RootlessSetShape(WindowPtr pWin);
+#endif // SHAPE
+
+Bool RootlessChangeWindowAttributes(WindowPtr pWin, unsigned long vmask);
+Bool RootlessPositionWindow(WindowPtr pWin, int x, int y);
+Bool RootlessRealizeWindow(WindowPtr pWin);
+Bool RootlessUnrealizeWindow(WindowPtr pWin);
+void RootlessRestackWindow(WindowPtr pWin, WindowPtr pOldNextSib);
+void RootlessCopyWindow(WindowPtr pWin,DDXPointRec ptOldOrg,RegionPtr prgnSrc);
+void RootlessMoveWindow(WindowPtr pWin,int x,int y,WindowPtr pSib,VTKind kind);
+void RootlessResizeWindow(WindowPtr pWin, int x, int y,
+ unsigned int w, unsigned int h, WindowPtr pSib);
+void RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent);
+void RootlessPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion,
+ int what);
+void RootlessPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion,
+ int what);
+void RootlessChangeBorderWidth(WindowPtr pWin, unsigned int width);
+
+#endif
diff --git a/nx-X11/programs/Xserver/miext/rootless/safeAlpha/Imakefile b/nx-X11/programs/Xserver/miext/rootless/safeAlpha/Imakefile
new file mode 100644
index 000000000..bb14bb146
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/safeAlpha/Imakefile
@@ -0,0 +1,18 @@
+XCOMM $XFree86: xc/programs/Xserver/miext/rootless/Imakefile,v 1.1 2003/04/15 01:05:44 torrey Exp $
+
+#include <Server.tmpl>
+
+SRCS = safeAlphaPicture.c \
+ safeAlphaWindow.c
+
+OBJS = safeAlphaPicture.o \
+ safeAlphaWindow.o
+
+ INCLUDES = -I. -I$(SERVERSRC)/fb -I$(SERVERSRC)/mi -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(SERVERSRC)/render \
+ -I$(EXTINCSRC) -I$(SERVERSRC)/Xext -I..
+
+NormalLibraryObjectRule()
+LibraryModuleTarget(safeAlpha,$(OBJS))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/miext/rootless/safeAlpha/safeAlpha.h b/nx-X11/programs/Xserver/miext/rootless/safeAlpha/safeAlpha.h
new file mode 100644
index 000000000..63922aeec
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/safeAlpha/safeAlpha.h
@@ -0,0 +1,45 @@
+/*
+ * Replacement functions to protect the alpha channel
+ */
+/*
+ * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* $XFree86: xc/programs/Xserver/miext/rootless/safeAlpha/safeAlpha.h,v 1.2 2003/10/18 00:00:34 torrey Exp $ */
+
+#ifndef _SAFEALPHA_H
+#define _SAFEALPHA_H
+
+#include "picturestr.h"
+
+void SafeAlphaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
+
+#ifdef RENDER
+void
+SafeAlphaComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
+ INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
+ INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
+#endif /* RENDER */
+
+#endif /* _SAFEALPHA_H */
diff --git a/nx-X11/programs/Xserver/miext/rootless/safeAlpha/safeAlphaPicture.c b/nx-X11/programs/Xserver/miext/rootless/safeAlpha/safeAlphaPicture.c
new file mode 100644
index 000000000..f73a3b5c1
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/safeAlpha/safeAlphaPicture.c
@@ -0,0 +1,643 @@
+/*
+ * Support for RENDER extension while protecting the alpha channel
+ */
+/*
+ * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
+ * Copyright (c) 2002 Apple Computer, Inc. All Rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* This file is largely based on fbcompose.c and fbpict.c, which contain
+ * the following copyright:
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ */
+ /* $XFree86: xc/programs/Xserver/miext/rootless/safeAlpha/safeAlphaPicture.c,v 1.3 2003/10/24 00:33:15 torrey Exp $ */
+
+#ifdef RENDER
+
+#include "fb.h"
+#include "picturestr.h"
+#include "mipict.h"
+#include "fbpict.h"
+#include "safeAlpha.h"
+#include "rootlessCommon.h"
+
+# define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
+
+
+typedef void (*CompositeFunc) (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+
+/* Optimized version of fbCompositeSolidMask_nx8x8888 */
+void
+SafeAlphaCompositeSolidMask_nx8x8888(
+ CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ CARD32 src, srca;
+ CARD32 *dstLine, *dst, d, dstMask;
+ CARD8 *maskLine, *mask, m;
+ FbStride dstStride, maskStride;
+ CARD16 w;
+
+ fbComposeGetSolid(pSrc, src, pDst->format);
+
+ dstMask = FbFullMask (pDst->pDrawable->depth);
+ srca = src >> 24;
+ if (src == 0)
+ return;
+
+ fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
+ fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
+
+ if (dstMask == FB_ALLONES && pDst->pDrawable->bitsPerPixel == 32 &&
+ width * height > rootless_CompositePixels_threshold &&
+ SCREENREC(pDst->pDrawable->pScreen)->imp->CompositePixels)
+ {
+ void *srcp[2], *destp[2];
+ unsigned int dest_rowbytes[2];
+ unsigned int fn;
+
+ srcp[0] = &src; srcp[1] = &src;
+ /* null rowbytes pointer means use first value as a constant */
+ destp[0] = dstLine; destp[1] = dstLine;
+ dest_rowbytes[0] = dstStride * 4; dest_rowbytes[1] = dest_rowbytes[0];
+ fn = RL_COMPOSITE_FUNCTION(RL_COMPOSITE_OVER, RL_DEPTH_ARGB8888,
+ RL_DEPTH_A8, RL_DEPTH_ARGB8888);
+
+ if (SCREENREC(pDst->pDrawable->pScreen)->imp->CompositePixels(
+ width, height, fn, srcp, NULL,
+ maskLine, maskStride,
+ destp, dest_rowbytes) == Success)
+ {
+ return;
+ }
+ }
+
+ while (height--)
+ {
+ dst = dstLine;
+ dstLine += dstStride;
+ mask = maskLine;
+ maskLine += maskStride;
+ w = width;
+
+ while (w--)
+ {
+ m = *mask++;
+ if (m == 0xff)
+ {
+ if (srca == 0xff)
+ *dst = src & dstMask;
+ else
+ *dst = fbOver (src, *dst) & dstMask;
+ }
+ else if (m)
+ {
+ d = fbIn (src, m);
+ *dst = fbOver (d, *dst) & dstMask;
+ }
+ dst++;
+ }
+ }
+}
+
+void
+SafeAlphaComposite (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ RegionRec region;
+ int n;
+ BoxPtr pbox;
+ CompositeFunc func = 0;
+ Bool srcRepeat = pSrc->repeat;
+ Bool maskRepeat = FALSE;
+ Bool srcAlphaMap = pSrc->alphaMap != 0;
+ Bool maskAlphaMap = FALSE;
+ Bool dstAlphaMap = pDst->alphaMap != 0;
+ int x_msk, y_msk, x_src, y_src, x_dst, y_dst;
+ int w, h, w_this, h_this;
+ int dstDepth = pDst->pDrawable->depth;
+ int oldFormat = pDst->format;
+
+ xDst += pDst->pDrawable->x;
+ yDst += pDst->pDrawable->y;
+ xSrc += pSrc->pDrawable->x;
+ ySrc += pSrc->pDrawable->y;
+ if (pMask)
+ {
+ xMask += pMask->pDrawable->x;
+ yMask += pMask->pDrawable->y;
+ maskRepeat = pMask->repeat;
+ maskAlphaMap = pMask->alphaMap != 0;
+ }
+
+
+ /*
+ * We can use the more optimized fbpict code, but it sets bits above
+ * the depth to zero. Temporarily adjust destination depth if needed.
+ */
+ if (pDst->pDrawable->type == DRAWABLE_WINDOW
+ && pDst->pDrawable->depth == 24
+ && pDst->pDrawable->bitsPerPixel == 32)
+ {
+ pDst->pDrawable->depth = 32;
+ }
+ /* For rootless preserve the alpha in x8r8g8b8 which really is
+ * a8r8g8b8
+ */
+ if (oldFormat == PICT_x8r8g8b8)
+ {
+ pDst->format = PICT_a8r8g8b8;
+ }
+
+
+
+ if (!pSrc->transform && !(pMask && pMask->transform))
+ if (!maskAlphaMap && !srcAlphaMap && !dstAlphaMap)
+ switch (op) {
+ case PictOpSrc:
+#ifdef USE_MMX
+ if (!pMask && pSrc->format == pDst->format &&
+ pSrc->pDrawable != pDst->pDrawable)
+ {
+ func = fbCompositeCopyAreammx;
+ }
+#endif
+ break;
+ case PictOpOver:
+ if (pMask)
+ {
+ if (srcRepeat &&
+ pSrc->pDrawable->width == 1 &&
+ pSrc->pDrawable->height == 1)
+ {
+ srcRepeat = FALSE;
+ if (PICT_FORMAT_COLOR(pSrc->format)) {
+ switch (pMask->format) {
+ case PICT_a8:
+ switch (pDst->format) {
+ case PICT_r5g6b5:
+ case PICT_b5g6r5:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8x0565mmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8x0565;
+ break;
+ case PICT_r8g8b8:
+ case PICT_b8g8r8:
+ func = fbCompositeSolidMask_nx8x0888;
+ break;
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+ case PICT_a8b8g8r8:
+ case PICT_x8b8g8r8:
+ func = SafeAlphaCompositeSolidMask_nx8x8888;
+ break;
+ }
+ break;
+ case PICT_a8r8g8b8:
+ if (pMask->componentAlpha) {
+ switch (pDst->format) {
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8888x8888Cmmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8888x8888C;
+ break;
+ case PICT_r5g6b5:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8888x0565Cmmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8888x0565C;
+ break;
+ }
+ }
+ break;
+ case PICT_a8b8g8r8:
+ if (pMask->componentAlpha) {
+ switch (pDst->format) {
+ case PICT_a8b8g8r8:
+ case PICT_x8b8g8r8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8888x8888Cmmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8888x8888C;
+ break;
+ case PICT_b5g6r5:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSolidMask_nx8888x0565Cmmx;
+ else
+#endif
+ func = fbCompositeSolidMask_nx8888x0565C;
+ break;
+ }
+ }
+ break;
+ case PICT_a1:
+ switch (pDst->format) {
+ case PICT_r5g6b5:
+ case PICT_b5g6r5:
+ case PICT_r8g8b8:
+ case PICT_b8g8r8:
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+ case PICT_a8b8g8r8:
+ case PICT_x8b8g8r8:
+ func = fbCompositeSolidMask_nx1xn;
+ break;
+ }
+ break;
+ }
+ }
+ }
+ else /* has mask and non-repeating source */
+ {
+ if (pSrc->pDrawable == pMask->pDrawable &&
+ xSrc == xMask && ySrc == yMask &&
+ !pMask->componentAlpha)
+ {
+ /* source == mask: non-premultiplied data */
+ switch (pSrc->format) {
+ case PICT_x8b8g8r8:
+ switch (pMask->format) {
+ case PICT_a8r8g8b8:
+ case PICT_a8b8g8r8:
+ switch (pDst->format) {
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888RevNPx8888mmx;
+#endif
+ break;
+ case PICT_r5g6b5:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888RevNPx0565mmx;
+#endif
+ break;
+ }
+ break;
+ }
+ break;
+ case PICT_x8r8g8b8:
+ switch (pMask->format) {
+ case PICT_a8r8g8b8:
+ case PICT_a8b8g8r8:
+ switch (pDst->format) {
+ case PICT_a8b8g8r8:
+ case PICT_x8b8g8r8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888RevNPx8888mmx;
+#endif
+ break;
+ case PICT_r5g6b5:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888RevNPx0565mmx;
+#endif
+ break;
+ }
+ break;
+ }
+ break;
+ }
+ break;
+ }
+ else
+ {
+ /* non-repeating source, repeating mask => translucent window */
+ if (maskRepeat &&
+ pMask->pDrawable->width == 1 &&
+ pMask->pDrawable->height == 1)
+ {
+ if (pSrc->format == PICT_x8r8g8b8 &&
+ pDst->format == PICT_x8r8g8b8 &&
+ pMask->format == PICT_a8)
+ {
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888x8x8888mmx;
+#endif
+ }
+ }
+ }
+ }
+ }
+ else /* no mask */
+ {
+ if (srcRepeat &&
+ pSrc->pDrawable->width == 1 &&
+ pSrc->pDrawable->height == 1)
+ {
+ /* no mask and repeating source */
+ switch (pSrc->format) {
+ case PICT_a8r8g8b8:
+ switch (pDst->format) {
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ {
+ srcRepeat = FALSE;
+ func = fbCompositeSolid_nx8888mmx;
+ }
+#endif
+ break;
+ case PICT_r5g6b5:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ {
+ srcRepeat = FALSE;
+ func = fbCompositeSolid_nx0565mmx;
+ }
+#endif
+ break;
+ }
+ break;
+ }
+ }
+ else
+ {
+ switch (pSrc->format) {
+ case PICT_a8r8g8b8:
+ switch (pDst->format) {
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888x8888mmx;
+ else
+#endif
+ func = fbCompositeSrc_8888x8888;
+ break;
+ case PICT_r8g8b8:
+ func = fbCompositeSrc_8888x0888;
+ break;
+ case PICT_r5g6b5:
+ func = fbCompositeSrc_8888x0565;
+ break;
+ }
+ break;
+ case PICT_x8r8g8b8:
+ switch (pDst->format) {
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeCopyAreammx;
+#endif
+ break;
+ }
+ case PICT_x8b8g8r8:
+ switch (pDst->format) {
+ case PICT_a8b8g8r8:
+ case PICT_x8b8g8r8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeCopyAreammx;
+#endif
+ break;
+ }
+ break;
+ case PICT_a8b8g8r8:
+ switch (pDst->format) {
+ case PICT_a8b8g8r8:
+ case PICT_x8b8g8r8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrc_8888x8888mmx;
+ else
+#endif
+ func = fbCompositeSrc_8888x8888;
+ break;
+ case PICT_b8g8r8:
+ func = fbCompositeSrc_8888x0888;
+ break;
+ case PICT_b5g6r5:
+ func = fbCompositeSrc_8888x0565;
+ break;
+ }
+ break;
+ case PICT_r5g6b5:
+ switch (pDst->format) {
+ case PICT_r5g6b5:
+ func = fbCompositeSrc_0565x0565;
+ break;
+ }
+ break;
+ case PICT_b5g6r5:
+ switch (pDst->format) {
+ case PICT_b5g6r5:
+ func = fbCompositeSrc_0565x0565;
+ break;
+ }
+ break;
+ }
+ }
+ }
+ break;
+ case PictOpAdd:
+ if (pMask == 0)
+ {
+ switch (pSrc->format) {
+ case PICT_a8r8g8b8:
+ switch (pDst->format) {
+ case PICT_a8r8g8b8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrcAdd_8888x8888mmx;
+ else
+#endif
+ func = fbCompositeSrcAdd_8888x8888;
+ break;
+ }
+ break;
+ case PICT_a8b8g8r8:
+ switch (pDst->format) {
+ case PICT_a8b8g8r8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrcAdd_8888x8888mmx;
+ else
+#endif
+ func = fbCompositeSrcAdd_8888x8888;
+ break;
+ }
+ break;
+ case PICT_a8:
+ switch (pDst->format) {
+ case PICT_a8:
+#ifdef USE_MMX
+ if (fbHaveMMX())
+ func = fbCompositeSrcAdd_8000x8000mmx;
+ else
+#endif
+ func = fbCompositeSrcAdd_8000x8000;
+ break;
+ }
+ break;
+ case PICT_a1:
+ switch (pDst->format) {
+ case PICT_a1:
+ func = fbCompositeSrcAdd_1000x1000;
+ break;
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ if (!func) {
+ /* no fast path, use the general code */
+ fbCompositeGeneral(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
+ // Reset destination depth and format to their true value
+ pDst->pDrawable->depth = dstDepth;
+ pDst->format = oldFormat;
+ return;
+ }
+
+ if (!miComputeCompositeRegion (&region,
+ pSrc,
+ pMask,
+ pDst,
+ xSrc,
+ ySrc,
+ xMask,
+ yMask,
+ xDst,
+ yDst,
+ width,
+ height))
+ return;
+
+ n = REGION_NUM_RECTS (&region);
+ pbox = REGION_RECTS (&region);
+ while (n--)
+ {
+ h = pbox->y2 - pbox->y1;
+ y_src = pbox->y1 - yDst + ySrc;
+ y_msk = pbox->y1 - yDst + yMask;
+ y_dst = pbox->y1;
+ while (h)
+ {
+ h_this = h;
+ w = pbox->x2 - pbox->x1;
+ x_src = pbox->x1 - xDst + xSrc;
+ x_msk = pbox->x1 - xDst + xMask;
+ x_dst = pbox->x1;
+ if (maskRepeat)
+ {
+ y_msk = mod (y_msk, pMask->pDrawable->height);
+ if (h_this > pMask->pDrawable->height - y_msk)
+ h_this = pMask->pDrawable->height - y_msk;
+ }
+ if (srcRepeat)
+ {
+ y_src = mod (y_src, pSrc->pDrawable->height);
+ if (h_this > pSrc->pDrawable->height - y_src)
+ h_this = pSrc->pDrawable->height - y_src;
+ }
+ while (w)
+ {
+ w_this = w;
+ if (maskRepeat)
+ {
+ x_msk = mod (x_msk, pMask->pDrawable->width);
+ if (w_this > pMask->pDrawable->width - x_msk)
+ w_this = pMask->pDrawable->width - x_msk;
+ }
+ if (srcRepeat)
+ {
+ x_src = mod (x_src, pSrc->pDrawable->width);
+ if (w_this > pSrc->pDrawable->width - x_src)
+ w_this = pSrc->pDrawable->width - x_src;
+ }
+ (*func) (op, pSrc, pMask, pDst,
+ x_src, y_src, x_msk, y_msk, x_dst, y_dst,
+ w_this, h_this);
+ w -= w_this;
+ x_src += w_this;
+ x_msk += w_this;
+ x_dst += w_this;
+ }
+ h -= h_this;
+ y_src += h_this;
+ y_msk += h_this;
+ y_dst += h_this;
+ }
+ pbox++;
+ }
+ REGION_UNINIT (pDst->pDrawable->pScreen, &region);
+
+ // Reset destination depth/format to its true value
+ pDst->pDrawable->depth = dstDepth;
+ pDst->format = oldFormat;
+}
+
+#endif /* RENDER */
diff --git a/nx-X11/programs/Xserver/miext/rootless/safeAlpha/safeAlphaWindow.c b/nx-X11/programs/Xserver/miext/rootless/safeAlpha/safeAlphaWindow.c
new file mode 100644
index 000000000..ff812385b
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/rootless/safeAlpha/safeAlphaWindow.c
@@ -0,0 +1,175 @@
+/* $XdotOrg: xc/programs/Xserver/miext/rootless/safeAlpha/safeAlphaWindow.c,v 1.4 2005/07/01 22:43:42 daniels Exp $ */
+/*
+ * Specialized window functions to protect the alpha channel
+ */
+/*
+ * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* Portions of this file are based on fbwindow.c, which contains the
+ * following copyright:
+ *
+ * Copyright © 1998 Keith Packard
+ */
+/* $XFree86: xc/programs/Xserver/miext/rootless/safeAlpha/safeAlphaWindow.c,v 1.1 2003/09/16 00:36:20 torrey Exp $ */
+
+#include "fb.h"
+#include "safeAlpha.h"
+#include "rootlessCommon.h"
+
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+
+/*
+ * SafeAlphaFillRegionTiled
+ * Fill using a tile while leaving the alpha channel untouched.
+ * Based on fbfillRegionTiled.
+ */
+void
+SafeAlphaFillRegionTiled(
+ DrawablePtr pDrawable,
+ RegionPtr pRegion,
+ PixmapPtr pTile)
+{
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbBits *tile;
+ FbStride tileStride;
+ int tileBpp;
+ int tileXoff, tileYoff; /* XXX assumed to be zero */
+ int tileWidth, tileHeight;
+ int n = REGION_NUM_RECTS(pRegion);
+ BoxPtr pbox = REGION_RECTS(pRegion);
+ int xRot = pDrawable->x;
+ int yRot = pDrawable->y;
+ FbBits planeMask;
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ {
+ int index = pDrawable->pScreen->myNum;
+ if(&WindowTable[index]->drawable == pDrawable)
+ {
+ xRot -= panoramiXdataPtr[index].x;
+ yRot -= panoramiXdataPtr[index].y;
+ }
+ }
+#endif
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ fbGetDrawable (&pTile->drawable, tile, tileStride, tileBpp,
+ tileXoff, tileYoff);
+ tileWidth = pTile->drawable.width;
+ tileHeight = pTile->drawable.height;
+ xRot += dstXoff;
+ yRot += dstYoff;
+ planeMask = FB_ALLONES & ~RootlessAlphaMask(dstBpp);
+
+ while (n--)
+ {
+ fbTile (dst + (pbox->y1 + dstYoff) * dstStride,
+ dstStride,
+ (pbox->x1 + dstXoff) * dstBpp,
+ (pbox->x2 - pbox->x1) * dstBpp,
+ pbox->y2 - pbox->y1,
+ tile,
+ tileStride,
+ tileWidth * dstBpp,
+ tileHeight,
+ GXcopy,
+ planeMask,
+ dstBpp,
+ xRot * dstBpp,
+ yRot - pbox->y1);
+ pbox++;
+ }
+}
+
+
+/*
+ * SafeAlphaPaintWindow
+ * Paint the window while filling in the alpha channel with all on.
+ * We can't use fbPaintWindow because it zeros the alpha channel.
+ */
+void
+SafeAlphaPaintWindow(
+ WindowPtr pWin,
+ RegionPtr pRegion,
+ int what)
+{
+ switch (what) {
+ case PW_BACKGROUND:
+
+ switch (pWin->backgroundState) {
+ case None:
+ break;
+ case ParentRelative:
+ do {
+ pWin = pWin->parent;
+ } while (pWin->backgroundState == ParentRelative);
+ (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
+ what);
+ break;
+ case BackgroundPixmap:
+ SafeAlphaFillRegionTiled (&pWin->drawable,
+ pRegion,
+ pWin->background.pixmap);
+ break;
+ case BackgroundPixel:
+ {
+ Pixel pixel = pWin->background.pixel |
+ RootlessAlphaMask(pWin->drawable.bitsPerPixel);
+ fbFillRegionSolid (&pWin->drawable, pRegion, 0,
+ fbReplicatePixel (pixel,
+ pWin->drawable.bitsPerPixel));
+ break;
+ }
+ }
+ break;
+ case PW_BORDER:
+ if (pWin->borderIsPixel)
+ {
+ Pixel pixel = pWin->border.pixel |
+ RootlessAlphaMask(pWin->drawable.bitsPerPixel);
+ fbFillRegionSolid (&pWin->drawable, pRegion, 0,
+ fbReplicatePixel (pixel,
+ pWin->drawable.bitsPerPixel));
+ }
+ else
+ {
+ WindowPtr pBgWin;
+ for (pBgWin = pWin; pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+
+ SafeAlphaFillRegionTiled (&pBgWin->drawable,
+ pRegion,
+ pWin->border.pixmap);
+ }
+ break;
+ }
+ fbValidateDrawable (&pWin->drawable);
+}
diff --git a/nx-X11/programs/Xserver/miext/shadow/Imakefile b/nx-X11/programs/Xserver/miext/shadow/Imakefile
new file mode 100644
index 000000000..fd97ab1cc
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/Imakefile
@@ -0,0 +1,66 @@
+XCOMM $XFree86: xc/programs/Xserver/miext/shadow/Imakefile,v 1.6 2001/07/20 19:25:02 keithp Exp $
+XCOMM
+XCOMM
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#if (defined (XFree86Version) || defined(XorgVersion))
+#if DoLoadableServer
+XFMODSRC = shmodule.c
+XFMODOBJ = shmodule.o
+#endif
+#endif
+
+SRCS = $(XFMODSRC) \
+ shadow.c \
+ shalloc.c \
+ shplanar.c \
+ shplanar8.c \
+ shpacked.c \
+ shrotate.c \
+ shrot8pack_90.c \
+ shrot8pack_180.c \
+ shrot8pack_270.c \
+ shrot16pack_90.c \
+ shrot16pack_180.c \
+ shrot16pack_270.c \
+ shrot32pack_90.c \
+ shrot32pack_180.c \
+ shrot32pack_270.c
+
+OBJS = $(XFMODOBJ) \
+ shadow.o \
+ shalloc.o \
+ shplanar.o \
+ shplanar8.o \
+ shpacked.o \
+ shrotate.o \
+ shrot8pack_90.o \
+ shrot8pack_180.o \
+ shrot8pack_270.o \
+ shrot16pack_90.o \
+ shrot16pack_180.o \
+ shrot16pack_270.o \
+ shrot32pack_90.o \
+ shrot32pack_180.o \
+ shrot32pack_270.o
+
+ INCLUDES = -I. -I../../mi -I../../fb -I../../include -I$(XINCLUDESRC) \
+ -I$(FONTINCSRC) -I$(XF86SRC)/common $(EXTRAINCLUDES) \
+ -I../../render -I$(EXTINCSRC)
+ LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln \
+ ../../mi/llib-lmi.ln
+
+NormalLibraryObjectRule()
+LibraryModuleTarget(shadow,$(OBJS))
+LintLibraryTarget(shadow,$(SRCS))
+
+NormalLintTarget($(SRCS))
+
+InstallLibraryModule(shadow,$(MODULEDIR),.)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(shadow,$(DRIVERSDKMODULEDIR),.)
+InstallDriverSDKNonExecFile(shadow.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/miext/shadow/shadow.c b/nx-X11/programs/Xserver/miext/shadow/shadow.c
new file mode 100644
index 000000000..92cb5e980
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shadow.c
@@ -0,0 +1,1544 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shadow.c,v 1.14tsi Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "shadow.h"
+
+typedef struct _shadowGCPriv {
+ GCOps *ops;
+ GCFuncs *funcs;
+} shadowGCPrivRec, *shadowGCPrivPtr;
+
+int shadowScrPrivateIndex;
+int shadowGCPrivateIndex;
+int shadowGeneration;
+
+#define shadowGetGCPriv(pGC) \
+ ((shadowGCPrivPtr) (pGC)->devPrivates[shadowGCPrivateIndex].ptr)
+#define shadowGCPriv(pGC) \
+ shadowGCPrivPtr pGCPriv = shadowGetGCPriv(pGC)
+
+#define wrap(priv, real, mem, func) {\
+ priv->mem = real->mem; \
+ real->mem = func; \
+}
+
+#define unwrap(priv, real, mem) {\
+ real->mem = priv->mem; \
+}
+
+static void
+shadowRedisplay (ScreenPtr pScreen)
+{
+ shadowScrPriv(pScreen);
+ shadowBufPtr pBuf;
+
+ for (pBuf = pScrPriv->pBuf; pBuf; pBuf = pBuf->pNext)
+ {
+ if (REGION_NOTEMPTY (pScreen, &pBuf->damage))
+ {
+ REGION_INTERSECT (pScreen, &pBuf->damage, &pBuf->damage,
+ &WindowTable[pScreen->myNum]->borderClip);
+ (*pBuf->update) (pScreen, pBuf);
+ REGION_EMPTY (pScreen, &pBuf->damage);
+ }
+ }
+}
+
+static void
+shadowBlockHandler (pointer data,
+ OSTimePtr pTimeout,
+ pointer pRead)
+{
+ ScreenPtr pScreen = (ScreenPtr) data;
+
+ shadowRedisplay (pScreen);
+}
+
+static void
+shadowWakeupHandler (pointer data, int i, pointer LastSelectMask)
+{
+}
+
+static void
+shadowDamageRegion (WindowPtr pWindow, RegionPtr pRegion)
+{
+ shadowBufPtr pBuf = shadowFindBuf (pWindow);
+
+ if (!pBuf)
+ abort ();
+
+ REGION_INTERSECT(pWindow->drawable.pScreen, pRegion, pRegion,
+ &pWindow->borderClip);
+ REGION_UNION(pWindow->drawable.pScreen, &pBuf->damage, &pBuf->damage,
+ pRegion);
+#ifdef ALWAYS_DISPLAY
+ shadowRedisplay (pWindow->drawable.pScreen);
+#endif
+}
+
+static void
+shadowDamageBox (WindowPtr pWindow, BoxPtr pBox)
+{
+ RegionRec region;
+
+ REGION_INIT (pWindow->drawable.pScreen, &region, pBox, 1);
+ shadowDamageRegion (pWindow, &region);
+ REGION_UNINIT (pWindow->drawable.pScreen, &region);
+}
+
+static void
+shadowDamageRect (WindowPtr pWindow, int x, int y, int w, int h)
+{
+ BoxRec box;
+
+ x += pWindow->drawable.x;
+ y += pWindow->drawable.y;
+ box.x1 = x;
+ box.x2 = x + w;
+ box.y1 = y;
+ box.y2 = y + h;
+ shadowDamageBox (pWindow, &box);
+}
+
+static void shadowValidateGC(GCPtr, unsigned long, DrawablePtr);
+static void shadowChangeGC(GCPtr, unsigned long);
+static void shadowCopyGC(GCPtr, unsigned long, GCPtr);
+static void shadowDestroyGC(GCPtr);
+static void shadowChangeClip(GCPtr, int, pointer, int);
+static void shadowDestroyClip(GCPtr);
+static void shadowCopyClip(GCPtr, GCPtr);
+
+GCFuncs shadowGCFuncs = {
+ shadowValidateGC, shadowChangeGC, shadowCopyGC, shadowDestroyGC,
+ shadowChangeClip, shadowDestroyClip, shadowCopyClip
+};
+
+extern GCOps shadowGCOps;
+
+static Bool
+shadowCreateGC(GCPtr pGC)
+{
+ ScreenPtr pScreen = pGC->pScreen;
+ shadowScrPriv(pScreen);
+ shadowGCPriv(pGC);
+ Bool ret;
+
+ unwrap (pScrPriv, pScreen, CreateGC);
+ if((ret = (*pScreen->CreateGC) (pGC))) {
+ pGCPriv->ops = NULL;
+ pGCPriv->funcs = pGC->funcs;
+ pGC->funcs = &shadowGCFuncs;
+ }
+ wrap (pScrPriv, pScreen, CreateGC, shadowCreateGC);
+
+ return ret;
+}
+
+void
+shadowWrapGC (GCPtr pGC)
+{
+ shadowGCPriv(pGC);
+
+ pGCPriv->ops = NULL;
+ pGCPriv->funcs = pGC->funcs;
+ pGC->funcs = &shadowGCFuncs;
+}
+
+void
+shadowUnwrapGC (GCPtr pGC)
+{
+ shadowGCPriv(pGC);
+
+ pGC->funcs = pGCPriv->funcs;
+ if (pGCPriv->ops)
+ pGC->ops = pGCPriv->ops;
+}
+
+#define SHADOW_GC_OP_PROLOGUE(pGC, pDraw) \
+ shadowGCPriv(pGC); \
+ GCFuncs *oldFuncs = pGC->funcs; \
+ unwrap(pGCPriv, pGC, funcs); \
+ unwrap(pGCPriv, pGC, ops); \
+
+#define SHADOW_GC_OP_EPILOGUE(pGC, pDraw) \
+ wrap(pGCPriv, pGC, funcs, oldFuncs); \
+ wrap(pGCPriv, pGC, ops, &shadowGCOps)
+
+#define SHADOW_GC_FUNC_PROLOGUE(pGC) \
+ shadowGCPriv(pGC); \
+ unwrap(pGCPriv, pGC, funcs); \
+ if (pGCPriv->ops) unwrap(pGCPriv, pGC, ops)
+
+#define SHADOW_GC_FUNC_EPILOGUE(pGC) \
+ wrap(pGCPriv, pGC, funcs, &shadowGCFuncs); \
+ if (pGCPriv->ops) wrap(pGCPriv, pGC, ops, &shadowGCOps)
+
+static void
+shadowValidateGC(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDraw
+){
+ SHADOW_GC_FUNC_PROLOGUE (pGC);
+ (*pGC->funcs->ValidateGC)(pGC, changes, pDraw);
+ if(pDraw->type == DRAWABLE_WINDOW)
+ pGCPriv->ops = pGC->ops; /* just so it's not NULL */
+ else
+ pGCPriv->ops = NULL;
+ SHADOW_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+shadowDestroyGC(GCPtr pGC)
+{
+ SHADOW_GC_FUNC_PROLOGUE (pGC);
+ (*pGC->funcs->DestroyGC)(pGC);
+ SHADOW_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+shadowChangeGC (
+ GCPtr pGC,
+ unsigned long mask
+){
+ SHADOW_GC_FUNC_PROLOGUE (pGC);
+ (*pGC->funcs->ChangeGC) (pGC, mask);
+ SHADOW_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+shadowCopyGC (
+ GCPtr pGCSrc,
+ unsigned long mask,
+ GCPtr pGCDst
+){
+ SHADOW_GC_FUNC_PROLOGUE (pGCDst);
+ (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
+ SHADOW_GC_FUNC_EPILOGUE (pGCDst);
+}
+
+static void
+shadowChangeClip (
+ GCPtr pGC,
+ int type,
+ pointer pvalue,
+ int nrects
+){
+ SHADOW_GC_FUNC_PROLOGUE (pGC);
+ (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
+ SHADOW_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+shadowCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
+{
+ SHADOW_GC_FUNC_PROLOGUE (pgcDst);
+ (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
+ SHADOW_GC_FUNC_EPILOGUE (pgcDst);
+}
+
+static void
+shadowDestroyClip(GCPtr pGC)
+{
+ SHADOW_GC_FUNC_PROLOGUE (pGC);
+ (* pGC->funcs->DestroyClip)(pGC);
+ SHADOW_GC_FUNC_EPILOGUE (pGC);
+}
+
+#define IS_VISIBLE(pWin) 1
+
+
+#define TRIM_BOX(box, pGC) { \
+ BoxPtr extents = &pGC->pCompositeClip->extents;\
+ if(box.x1 < extents->x1) box.x1 = extents->x1; \
+ if(box.x2 > extents->x2) box.x2 = extents->x2; \
+ if(box.y1 < extents->y1) box.y1 = extents->y1; \
+ if(box.y2 > extents->y2) box.y2 = extents->y2; \
+ }
+
+#define TRANSLATE_BOX(box, pDraw) { \
+ box.x1 += pDraw->x; \
+ box.x2 += pDraw->x; \
+ box.y1 += pDraw->y; \
+ box.y2 += pDraw->y; \
+ }
+
+#define TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC) { \
+ TRANSLATE_BOX(box, pDraw); \
+ TRIM_BOX(box, pGC); \
+ }
+
+#define BOX_NOT_EMPTY(box) \
+ (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0))
+
+#ifdef RENDER
+static void
+shadowComposite (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ shadowScrPriv(pScreen);
+
+ unwrap (pScrPriv, ps, Composite);
+ (*ps->Composite) (op,
+ pSrc,
+ pMask,
+ pDst,
+ xSrc,
+ ySrc,
+ xMask,
+ yMask,
+ xDst,
+ yDst,
+ width,
+ height);
+ wrap (pScrPriv, ps, Composite, shadowComposite);
+ if (pDst->pDrawable->type == DRAWABLE_WINDOW)
+ shadowDamageRect ((WindowPtr) pDst->pDrawable, xDst, yDst,
+ width, height);
+}
+
+static void
+shadowGlyphs (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlist,
+ GlyphListPtr list,
+ GlyphPtr *glyphs)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ shadowScrPriv(pScreen);
+ int x, y;
+ int n;
+ GlyphPtr glyph;
+
+ unwrap (pScrPriv, ps, Glyphs);
+ (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
+ wrap (pScrPriv, ps, Glyphs, shadowGlyphs);
+ if (pDst->pDrawable->type == DRAWABLE_WINDOW)
+ {
+ x = xSrc;
+ y = ySrc;
+ while (nlist--)
+ {
+ x += list->xOff;
+ y += list->yOff;
+ n = list->len;
+ while (n--)
+ {
+ glyph = *glyphs++;
+ shadowDamageRect ((WindowPtr) pDst->pDrawable,
+ x - glyph->info.x,
+ y - glyph->info.y,
+ glyph->info.width,
+ glyph->info.height);
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ }
+ list++;
+ }
+ }
+}
+#endif
+
+/**********************************************************/
+
+
+static void
+shadowFillSpans(
+ DrawablePtr pDraw,
+ GC *pGC,
+ int nInit,
+ DDXPointPtr pptInit,
+ int *pwidthInit,
+ int fSorted
+){
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && nInit) {
+ DDXPointPtr ppt = pptInit;
+ int *pwidth = pwidthInit;
+ int i = nInit;
+ BoxRec box;
+
+ box.x1 = ppt->x;
+ box.x2 = box.x1 + *pwidth;
+ box.y2 = box.y1 = ppt->y;
+
+ while(--i) {
+ ppt++;
+ pwidth++;
+ if(box.x1 > ppt->x) box.x1 = ppt->x;
+ if(box.x2 < (ppt->x + *pwidth))
+ box.x2 = ppt->x + *pwidth;
+ if(box.y1 > ppt->y) box.y1 = ppt->y;
+ else if(box.y2 < ppt->y) box.y2 = ppt->y;
+ }
+
+ box.y2++;
+
+ (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
+
+ if(!pGC->miTranslate) {
+ TRANSLATE_BOX(box, pDraw);
+ }
+ TRIM_BOX(box, pGC);
+
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ } else
+ (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
+
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+}
+
+static void
+shadowSetSpans(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ char *pcharsrc,
+ DDXPointPtr pptInit,
+ int *pwidthInit,
+ int nspans,
+ int fSorted
+){
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && nspans) {
+ DDXPointPtr ppt = pptInit;
+ int *pwidth = pwidthInit;
+ int i = nspans;
+ BoxRec box;
+
+ box.x1 = ppt->x;
+ box.x2 = box.x1 + *pwidth;
+ box.y2 = box.y1 = ppt->y;
+
+ while(--i) {
+ ppt++;
+ pwidth++;
+ if(box.x1 > ppt->x) box.x1 = ppt->x;
+ if(box.x2 < (ppt->x + *pwidth))
+ box.x2 = ppt->x + *pwidth;
+ if(box.y1 > ppt->y) box.y1 = ppt->y;
+ else if(box.y2 < ppt->y) box.y2 = ppt->y;
+ }
+
+ box.y2++;
+
+ (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit,
+ pwidthInit, nspans, fSorted);
+
+ if(!pGC->miTranslate) {
+ TRANSLATE_BOX(box, pDraw);
+ }
+ TRIM_BOX(box, pGC);
+
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ } else
+ (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit,
+ pwidthInit, nspans, fSorted);
+
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+}
+
+static void
+shadowPutImage(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int depth,
+ int x, int y, int w, int h,
+ int leftPad,
+ int format,
+ char *pImage
+){
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h,
+ leftPad, format, pImage);
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw)) {
+ BoxRec box;
+
+ box.x1 = x + pDraw->x;
+ box.x2 = box.x1 + w;
+ box.y1 = y + pDraw->y;
+ box.y2 = box.y1 + h;
+
+ TRIM_BOX(box, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ }
+}
+
+static RegionPtr
+shadowCopyArea(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC *pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty
+){
+ RegionPtr ret;
+ SHADOW_GC_OP_PROLOGUE(pGC, pDst);
+ ret = (*pGC->ops->CopyArea)(pSrc, pDst,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+ SHADOW_GC_OP_EPILOGUE(pGC, pDst);
+
+ if(IS_VISIBLE(pDst)) {
+ BoxRec box;
+
+ box.x1 = dstx + pDst->x;
+ box.x2 = box.x1 + width;
+ box.y1 = dsty + pDst->y;
+ box.y2 = box.y1 + height;
+
+ TRIM_BOX(box, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDst, &box);
+ }
+
+ return ret;
+}
+
+static RegionPtr
+shadowCopyPlane(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx, int srcy,
+ int width, int height,
+ int dstx, int dsty,
+ unsigned long bitPlane
+){
+ RegionPtr ret;
+ SHADOW_GC_OP_PROLOGUE(pGC, pDst);
+ ret = (*pGC->ops->CopyPlane)(pSrc, pDst,
+ pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
+ SHADOW_GC_OP_EPILOGUE(pGC, pDst);
+
+ if(IS_VISIBLE(pDst)) {
+ BoxRec box;
+
+ box.x1 = dstx + pDst->x;
+ box.x2 = box.x1 + width;
+ box.y1 = dsty + pDst->y;
+ box.y2 = box.y1 + height;
+
+ TRIM_BOX(box, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDst, &box);
+ }
+
+ return ret;
+}
+
+static void
+shadowPolyPoint(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ xPoint *pptInit
+){
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && npt) {
+ BoxRec box;
+
+ box.x2 = box.x1 = pptInit->x;
+ box.y2 = box.y1 = pptInit->y;
+
+ /* this could be slow if the points were spread out */
+
+ while(--npt) {
+ pptInit++;
+ if(box.x1 > pptInit->x) box.x1 = pptInit->x;
+ else if(box.x2 < pptInit->x) box.x2 = pptInit->x;
+ if(box.y1 > pptInit->y) box.y1 = pptInit->y;
+ else if(box.y2 < pptInit->y) box.y2 = pptInit->y;
+ }
+
+ box.x2++;
+ box.y2++;
+
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ }
+}
+
+static void
+shadowPolylines(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr pptInit
+){
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+
+ if(IS_VISIBLE(pDraw) && npt) {
+ BoxRec box;
+ int extra = pGC->lineWidth >> 1;
+
+ box.x2 = box.x1 = pptInit->x;
+ box.y2 = box.y1 = pptInit->y;
+
+ if(npt > 1) {
+ if(pGC->joinStyle == JoinMiter)
+ extra = 6 * pGC->lineWidth;
+ else if(pGC->capStyle == CapProjecting)
+ extra = pGC->lineWidth;
+ }
+
+ if(mode == CoordModePrevious) {
+ int x = box.x1;
+ int y = box.y1;
+ while(--npt) {
+ pptInit++;
+ x += pptInit->x;
+ y += pptInit->y;
+ if(box.x1 > x) box.x1 = x;
+ else if(box.x2 < x) box.x2 = x;
+ if(box.y1 > y) box.y1 = y;
+ else if(box.y2 < y) box.y2 = y;
+ }
+ } else {
+ while(--npt) {
+ pptInit++;
+ if(box.x1 > pptInit->x) box.x1 = pptInit->x;
+ else if(box.x2 < pptInit->x) box.x2 = pptInit->x;
+ if(box.y1 > pptInit->y) box.y1 = pptInit->y;
+ else if(box.y2 < pptInit->y) box.y2 = pptInit->y;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ if(extra) {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ }
+}
+
+static void
+shadowPolySegment(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSeg
+){
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && nseg) {
+ BoxRec box;
+ int extra = pGC->lineWidth;
+
+ if(pGC->capStyle != CapProjecting)
+ extra >>= 1;
+
+ if(pSeg->x2 > pSeg->x1) {
+ box.x1 = pSeg->x1;
+ box.x2 = pSeg->x2;
+ } else {
+ box.x2 = pSeg->x1;
+ box.x1 = pSeg->x2;
+ }
+
+ if(pSeg->y2 > pSeg->y1) {
+ box.y1 = pSeg->y1;
+ box.y2 = pSeg->y2;
+ } else {
+ box.y2 = pSeg->y1;
+ box.y1 = pSeg->y2;
+ }
+
+ while(--nseg) {
+ pSeg++;
+ if(pSeg->x2 > pSeg->x1) {
+ if(pSeg->x1 < box.x1) box.x1 = pSeg->x1;
+ if(pSeg->x2 > box.x2) box.x2 = pSeg->x2;
+ } else {
+ if(pSeg->x2 < box.x1) box.x1 = pSeg->x2;
+ if(pSeg->x1 > box.x2) box.x2 = pSeg->x1;
+ }
+ if(pSeg->y2 > pSeg->y1) {
+ if(pSeg->y1 < box.y1) box.y1 = pSeg->y1;
+ if(pSeg->y2 > box.y2) box.y2 = pSeg->y2;
+ } else {
+ if(pSeg->y2 < box.y1) box.y1 = pSeg->y2;
+ if(pSeg->y1 > box.y2) box.y2 = pSeg->y1;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ if(extra) {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ }
+}
+
+static void
+shadowPolyRectangle(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nRects,
+ xRectangle *pRects
+){
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->PolyRectangle)(pDraw, pGC, nRects, pRects);
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && nRects)
+ {
+ BoxRec box;
+ int offset1, offset2, offset3;
+
+ offset2 = pGC->lineWidth;
+ if(!offset2) offset2 = 1;
+ offset1 = offset2 >> 1;
+ offset3 = offset2 - offset1;
+
+ while(nRects--)
+ {
+ box.x1 = pRects->x - offset1;
+ box.y1 = pRects->y - offset1;
+ box.x2 = box.x1 + pRects->width + offset2;
+ box.y2 = box.y1 + offset2;
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+
+ box.x1 = pRects->x - offset1;
+ box.y1 = pRects->y + offset3;
+ box.x2 = box.x1 + offset2;
+ box.y2 = box.y1 + pRects->height - offset2;
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+
+ box.x1 = pRects->x + pRects->width - offset1;
+ box.y1 = pRects->y + offset3;
+ box.x2 = box.x1 + offset2;
+ box.y2 = box.y1 + pRects->height - offset2;
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+
+ box.x1 = pRects->x - offset1;
+ box.y1 = pRects->y + pRects->height - offset1;
+ box.x2 = box.x1 + pRects->width + offset2;
+ box.y2 = box.y1 + offset2;
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+
+ pRects++;
+ }
+ }
+ }
+
+static void
+shadowPolyArc(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int narcs,
+ xArc *parcs
+){
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && narcs) {
+ int extra = pGC->lineWidth >> 1;
+ BoxRec box;
+
+ box.x1 = parcs->x;
+ box.x2 = box.x1 + parcs->width;
+ box.y1 = parcs->y;
+ box.y2 = box.y1 + parcs->height;
+
+ /* should I break these up instead ? */
+
+ while(--narcs) {
+ parcs++;
+ if(box.x1 > parcs->x) box.x1 = parcs->x;
+ if(box.x2 < (parcs->x + parcs->width))
+ box.x2 = parcs->x + parcs->width;
+ if(box.y1 > parcs->y) box.y1 = parcs->y;
+ if(box.y2 < (parcs->y + parcs->height))
+ box.y2 = parcs->y + parcs->height;
+ }
+
+ if(extra) {
+ box.x1 -= extra;
+ box.x2 += extra;
+ box.y1 -= extra;
+ box.y2 += extra;
+ }
+
+ box.x2++;
+ box.y2++;
+
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ }
+}
+
+static void
+shadowFillPolygon(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int count,
+ DDXPointPtr pptInit
+){
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && (count > 2)) {
+ DDXPointPtr ppt = pptInit;
+ int i = count;
+ BoxRec box;
+
+ box.x2 = box.x1 = ppt->x;
+ box.y2 = box.y1 = ppt->y;
+
+ if(mode != CoordModeOrigin) {
+ int x = box.x1;
+ int y = box.y1;
+ while(--i) {
+ ppt++;
+ x += ppt->x;
+ y += ppt->y;
+ if(box.x1 > x) box.x1 = x;
+ else if(box.x2 < x) box.x2 = x;
+ if(box.y1 > y) box.y1 = y;
+ else if(box.y2 < y) box.y2 = y;
+ }
+ } else {
+ while(--i) {
+ ppt++;
+ if(box.x1 > ppt->x) box.x1 = ppt->x;
+ else if(box.x2 < ppt->x) box.x2 = ppt->x;
+ if(box.y1 > ppt->y) box.y1 = ppt->y;
+ else if(box.y2 < ppt->y) box.y2 = ppt->y;
+ }
+ }
+
+ box.x2++;
+ box.y2++;
+
+ (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, pptInit);
+
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ } else
+ (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, pptInit);
+
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+}
+
+
+static void
+shadowPolyFillRect(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nRectsInit,
+ xRectangle *pRectsInit
+){
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && nRectsInit) {
+ BoxRec box;
+ xRectangle *pRects = pRectsInit;
+ int nRects = nRectsInit;
+
+ box.x1 = pRects->x;
+ box.x2 = box.x1 + pRects->width;
+ box.y1 = pRects->y;
+ box.y2 = box.y1 + pRects->height;
+
+ while(--nRects) {
+ pRects++;
+ if(box.x1 > pRects->x) box.x1 = pRects->x;
+ if(box.x2 < (pRects->x + pRects->width))
+ box.x2 = pRects->x + pRects->width;
+ if(box.y1 > pRects->y) box.y1 = pRects->y;
+ if(box.y2 < (pRects->y + pRects->height))
+ box.y2 = pRects->y + pRects->height;
+ }
+
+ /* cfb messes with the pRectsInit so we have to do our
+ calculations first */
+
+ (*pGC->ops->PolyFillRect)(pDraw, pGC, nRectsInit, pRectsInit);
+
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ } else
+ (*pGC->ops->PolyFillRect)(pDraw, pGC, nRectsInit, pRectsInit);
+
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+}
+
+
+static void
+shadowPolyFillArc(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int narcs,
+ xArc *parcs
+){
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && narcs) {
+ BoxRec box;
+
+ box.x1 = parcs->x;
+ box.x2 = box.x1 + parcs->width;
+ box.y1 = parcs->y;
+ box.y2 = box.y1 + parcs->height;
+
+ /* should I break these up instead ? */
+
+ while(--narcs) {
+ parcs++;
+ if(box.x1 > parcs->x) box.x1 = parcs->x;
+ if(box.x2 < (parcs->x + parcs->width))
+ box.x2 = parcs->x + parcs->width;
+ if(box.y1 > parcs->y) box.y1 = parcs->y;
+ if(box.y2 < (parcs->y + parcs->height))
+ box.y2 = parcs->y + parcs->height;
+ }
+
+ TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ }
+
+}
+
+static int
+shadowPolyText8(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *chars
+){
+ int width;
+
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+ width = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+ width -= x;
+
+ if(IS_VISIBLE(pDraw) && (width > 0)) {
+ BoxRec box;
+
+ /* ugh */
+ box.x1 = pDraw->x + x + FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = pDraw->x + x + FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ if(count > 1) {
+ if(width > 0) box.x2 += width;
+ else box.x1 += width;
+ }
+
+ box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent);
+ box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent);
+
+ TRIM_BOX(box, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ }
+
+ return (width + x);
+}
+
+static int
+shadowPolyText16(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *chars
+){
+ int width;
+
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+ width = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+ width -= x;
+
+ if(IS_VISIBLE(pDraw) && (width > 0)) {
+ BoxRec box;
+
+ /* ugh */
+ box.x1 = pDraw->x + x + FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = pDraw->x + x + FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ if(count > 1) {
+ if(width > 0) box.x2 += width;
+ else box.x1 += width;
+ }
+
+ box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent);
+ box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent);
+
+ TRIM_BOX(box, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ }
+
+ return (width + x);
+}
+
+static void
+shadowImageText8(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *chars
+){
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && count) {
+ int top, bot, Min, Max;
+ BoxRec box;
+
+ top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+ bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+ Min = count * FONTMINBOUNDS(pGC->font, characterWidth);
+ if(Min > 0) Min = 0;
+ Max = count * FONTMAXBOUNDS(pGC->font, characterWidth);
+ if(Max < 0) Max = 0;
+
+ /* ugh */
+ box.x1 = pDraw->x + x + Min +
+ FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = pDraw->x + x + Max +
+ FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ box.y1 = pDraw->y + y - top;
+ box.y2 = pDraw->y + y + bot;
+
+ TRIM_BOX(box, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ }
+}
+static void
+shadowImageText16(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *chars
+){
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && count) {
+ int top, bot, Min, Max;
+ BoxRec box;
+
+ top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+ bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+ Min = count * FONTMINBOUNDS(pGC->font, characterWidth);
+ if(Min > 0) Min = 0;
+ Max = count * FONTMAXBOUNDS(pGC->font, characterWidth);
+ if(Max < 0) Max = 0;
+
+ /* ugh */
+ box.x1 = pDraw->x + x + Min +
+ FONTMINBOUNDS(pGC->font, leftSideBearing);
+ box.x2 = pDraw->x + x + Max +
+ FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+ box.y1 = pDraw->y + y - top;
+ box.y2 = pDraw->y + y + bot;
+
+ TRIM_BOX(box, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ }
+}
+
+
+static void
+shadowImageGlyphBlt(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase
+){
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, nglyph,
+ ppci, pglyphBase);
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && nglyph) {
+ int top, bot, width = 0;
+ BoxRec box;
+
+ top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+ bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+ box.x1 = ppci[0]->metrics.leftSideBearing;
+ if(box.x1 > 0) box.x1 = 0;
+ box.x2 = ppci[nglyph - 1]->metrics.rightSideBearing -
+ ppci[nglyph - 1]->metrics.characterWidth;
+ if(box.x2 < 0) box.x2 = 0;
+
+ box.x2 += pDraw->x + x;
+ box.x1 += pDraw->x + x;
+
+ while(nglyph--) {
+ width += (*ppci)->metrics.characterWidth;
+ ppci++;
+ }
+
+ if(width > 0)
+ box.x2 += width;
+ else
+ box.x1 += width;
+
+ box.y1 = pDraw->y + y - top;
+ box.y2 = pDraw->y + y + bot;
+
+ TRIM_BOX(box, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ }
+}
+
+static void
+shadowPolyGlyphBlt(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int x, int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase
+){
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, x, y, nglyph,
+ ppci, pglyphBase);
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw) && nglyph) {
+ BoxRec box;
+
+ /* ugh */
+ box.x1 = pDraw->x + x + ppci[0]->metrics.leftSideBearing;
+ box.x2 = pDraw->x + x + ppci[nglyph - 1]->metrics.rightSideBearing;
+
+ if(nglyph > 1) {
+ int width = 0;
+
+ while(--nglyph) {
+ width += (*ppci)->metrics.characterWidth;
+ ppci++;
+ }
+
+ if(width > 0) box.x2 += width;
+ else box.x1 += width;
+ }
+
+ box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent);
+ box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent);
+
+ TRIM_BOX(box, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ }
+}
+
+static void
+shadowPushPixels(
+ GCPtr pGC,
+ PixmapPtr pBitMap,
+ DrawablePtr pDraw,
+ int dx, int dy, int xOrg, int yOrg
+){
+ SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+ (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
+ SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+ if(IS_VISIBLE(pDraw)) {
+ BoxRec box;
+
+ box.x1 = xOrg;
+ box.y1 = yOrg;
+
+ if(!pGC->miTranslate) {
+ box.x1 += pDraw->x;
+ box.y1 += pDraw->y;
+ }
+
+ box.x2 = box.x1 + dx;
+ box.y2 = box.y1 + dy;
+
+ TRIM_BOX(box, pGC);
+ if(BOX_NOT_EMPTY(box))
+ shadowDamageBox ((WindowPtr) pDraw, &box);
+ }
+}
+
+
+static void
+shadowPaintWindow(
+ WindowPtr pWindow,
+ RegionPtr prgn,
+ int what
+){
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ shadowScrPriv(pScreen);
+
+ if(what == PW_BACKGROUND) {
+ unwrap (pScrPriv, pScreen, PaintWindowBackground);
+ (*pScreen->PaintWindowBackground) (pWindow, prgn, what);
+ wrap (pScrPriv, pScreen, PaintWindowBackground, shadowPaintWindow);
+ } else {
+ unwrap (pScrPriv, pScreen, PaintWindowBorder);
+ (*pScreen->PaintWindowBorder) (pWindow, prgn, what);
+ wrap (pScrPriv, pScreen, PaintWindowBorder, shadowPaintWindow);
+ }
+ shadowDamageRegion (pWindow, prgn);
+}
+
+
+static void
+shadowCopyWindow(
+ WindowPtr pWindow,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgn
+){
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ shadowScrPriv(pScreen);
+
+ unwrap (pScrPriv, pScreen, CopyWindow);
+ (*pScreen->CopyWindow) (pWindow, ptOldOrg, prgn);
+ wrap (pScrPriv, pScreen, CopyWindow, shadowCopyWindow);
+ shadowDamageRegion (pWindow, prgn);
+}
+
+GCOps shadowGCOps = {
+ shadowFillSpans, shadowSetSpans,
+ shadowPutImage, shadowCopyArea,
+ shadowCopyPlane, shadowPolyPoint,
+ shadowPolylines, shadowPolySegment,
+ shadowPolyRectangle, shadowPolyArc,
+ shadowFillPolygon, shadowPolyFillRect,
+ shadowPolyFillArc, shadowPolyText8,
+ shadowPolyText16, shadowImageText8,
+ shadowImageText16, shadowImageGlyphBlt,
+ shadowPolyGlyphBlt, shadowPushPixels,
+#ifdef NEED_LINEHELPER
+ NULL,
+#endif
+ {NULL} /* devPrivate */
+};
+
+static void
+shadowGetImage (DrawablePtr pDrawable,
+ int sx,
+ int sy,
+ int w,
+ int h,
+ unsigned int format,
+ unsigned long planeMask,
+ char * pdstLine)
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ shadowScrPriv(pScreen);
+
+ /* Many apps use GetImage to sync with the visable frame buffer */
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ shadowRedisplay (pScreen);
+ unwrap (pScrPriv, pScreen, GetImage);
+ (*pScreen->GetImage) (pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+ wrap (pScrPriv, pScreen, GetImage, shadowGetImage);
+}
+
+static void
+shadowRestoreAreas (PixmapPtr pPixmap,
+ RegionPtr prgn,
+ int xorg,
+ int yorg,
+ WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ shadowScrPriv(pScreen);
+
+ unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas);
+ (*pScreen->BackingStoreFuncs.RestoreAreas) (pPixmap, prgn,
+ xorg, yorg, pWin);
+ wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas,
+ shadowRestoreAreas);
+ shadowDamageRegion (pWin, prgn);
+}
+
+static Bool
+shadowCloseScreen (int i, ScreenPtr pScreen)
+{
+ shadowScrPriv(pScreen);
+
+ unwrap (pScrPriv, pScreen, CreateGC);
+ unwrap (pScrPriv, pScreen, PaintWindowBackground);
+ unwrap (pScrPriv, pScreen, PaintWindowBorder);
+ unwrap (pScrPriv, pScreen, CopyWindow);
+ unwrap (pScrPriv, pScreen, CloseScreen);
+ unwrap (pScrPriv, pScreen, GetImage);
+ unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas);
+ xfree (pScrPriv);
+ return (*pScreen->CloseScreen) (i, pScreen);
+}
+
+Bool
+shadowSetup (ScreenPtr pScreen)
+{
+ shadowScrPrivPtr pScrPriv;
+#ifdef RENDER
+ PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
+#endif
+
+ if (shadowGeneration != serverGeneration)
+ {
+ shadowScrPrivateIndex = AllocateScreenPrivateIndex ();
+ if (shadowScrPrivateIndex == -1)
+ return FALSE;
+ shadowGCPrivateIndex = AllocateGCPrivateIndex ();
+ if (shadowGCPrivateIndex == -1)
+ return FALSE;
+ shadowGeneration = serverGeneration;
+ }
+ if (!AllocateGCPrivate (pScreen, shadowGCPrivateIndex, sizeof (shadowGCPrivRec)))
+ return FALSE;
+ pScrPriv = (shadowScrPrivPtr) xalloc (sizeof (shadowScrPrivRec));
+ if (!pScrPriv)
+ return FALSE;
+
+ if (!RegisterBlockAndWakeupHandlers (shadowBlockHandler,
+ shadowWakeupHandler,
+ (pointer) pScreen))
+ return FALSE;
+
+ wrap (pScrPriv, pScreen, CreateGC, shadowCreateGC);
+ wrap (pScrPriv, pScreen, PaintWindowBackground, shadowPaintWindow);
+ wrap (pScrPriv, pScreen, PaintWindowBorder, shadowPaintWindow);
+ wrap (pScrPriv, pScreen, CopyWindow, shadowCopyWindow);
+ wrap (pScrPriv, pScreen, CloseScreen, shadowCloseScreen);
+ wrap (pScrPriv, pScreen, GetImage, shadowGetImage);
+ wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas,
+ shadowRestoreAreas);
+#ifdef RENDER
+ if (ps) {
+ wrap (pScrPriv, ps, Glyphs, shadowGlyphs);
+ wrap (pScrPriv, ps, Composite, shadowComposite);
+ }
+#endif
+ pScrPriv->pBuf = 0;
+
+ pScreen->devPrivates[shadowScrPrivateIndex].ptr = (pointer) pScrPriv;
+ return TRUE;
+}
+
+Bool
+shadowAdd (ScreenPtr pScreen,
+ PixmapPtr pPixmap,
+ ShadowUpdateProc update,
+ ShadowWindowProc window,
+ int randr,
+ void *closure)
+{
+ shadowScrPriv(pScreen);
+ shadowBufPtr pBuf;
+
+ pBuf = (shadowBufPtr) xalloc (sizeof (shadowBufRec));
+ if (!pBuf)
+ return FALSE;
+ /*
+ * Map simple rotation values to bitmasks; fortunately,
+ * these are all unique
+ */
+ switch (randr) {
+ case 0:
+ randr = SHADOW_ROTATE_0;
+ break;
+ case 90:
+ randr = SHADOW_ROTATE_90;
+ break;
+ case 180:
+ randr = SHADOW_ROTATE_180;
+ break;
+ case 270:
+ randr = SHADOW_ROTATE_270;
+ break;
+ }
+ pBuf->pPixmap = pPixmap;
+ pBuf->update = update;
+ pBuf->window = window;
+ REGION_NULL(pScreen, &pBuf->damage);
+ pBuf->pNext = pScrPriv->pBuf;
+ pBuf->randr = randr;
+ pBuf->closure = 0;
+ pScrPriv->pBuf = pBuf;
+ return TRUE;
+}
+
+void
+shadowRemove (ScreenPtr pScreen, PixmapPtr pPixmap)
+{
+ shadowScrPriv(pScreen);
+ shadowBufPtr pBuf, *pPrev;
+
+ for (pPrev = &pScrPriv->pBuf; (pBuf = *pPrev); pPrev = &pBuf->pNext)
+ if (pBuf->pPixmap == pPixmap)
+ {
+ REGION_UNINIT (pScreen, &pBuf->damage);
+ *pPrev = pBuf->pNext;
+ xfree (pBuf);
+ break;
+ }
+}
+
+shadowBufPtr
+shadowFindBuf (WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ shadowScrPriv(pScreen);
+ shadowBufPtr pBuf, *pPrev;
+ PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWindow);
+
+ for (pPrev = &pScrPriv->pBuf; (pBuf = *pPrev); pPrev = &pBuf->pNext)
+ {
+ if (!pBuf->pPixmap)
+ pBuf->pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
+ if (pBuf->pPixmap == pPixmap)
+ {
+ /*
+ * Reorder so this one is first next time
+ */
+ if (pPrev != &pScrPriv->pBuf)
+ {
+ *pPrev = pBuf->pNext;
+ pBuf->pNext = pScrPriv->pBuf;
+ pScrPriv->pBuf = pBuf;
+ }
+ return pBuf;
+ }
+ }
+ return 0;
+}
+
+Bool
+shadowInit (ScreenPtr pScreen, ShadowUpdateProc update, ShadowWindowProc window)
+{
+ if (!shadowSetup (pScreen))
+ return FALSE;
+
+ if (!shadowAdd (pScreen, 0, update, window, SHADOW_ROTATE_0, 0))
+ return FALSE;
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/miext/shadow/shadow.h b/nx-X11/programs/Xserver/miext/shadow/shadow.h
new file mode 100644
index 000000000..85b2604f5
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shadow.h
@@ -0,0 +1,179 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shadow.h,v 1.6tsi Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _SHADOW_H_
+#define _SHADOW_H_
+
+#include "scrnintstr.h"
+
+#ifdef RENDER
+#include "picturestr.h"
+#endif
+
+typedef struct _shadowBuf *shadowBufPtr;
+
+typedef void (*ShadowUpdateProc) (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+#define SHADOW_WINDOW_RELOCATE 1
+#define SHADOW_WINDOW_READ 2
+#define SHADOW_WINDOW_WRITE 4
+
+typedef void *(*ShadowWindowProc) (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure);
+
+typedef struct _shadowBuf {
+ shadowBufPtr pNext;
+ ShadowUpdateProc update;
+ ShadowWindowProc window;
+ RegionRec damage;
+ PixmapPtr pPixmap;
+ void *closure;
+ int randr;
+} shadowBufRec;
+
+/* Match defines from randr extension */
+#define SHADOW_ROTATE_0 1
+#define SHADOW_ROTATE_90 2
+#define SHADOW_ROTATE_180 4
+#define SHADOW_ROTATE_270 8
+#define SHADOW_ROTATE_ALL (SHADOW_ROTATE_0|SHADOW_ROTATE_90|\
+ SHADOW_ROTATE_180|SHADOW_ROTATE_270)
+#define SHADOW_REFLECT_X 16
+#define SHADOW_REFLECT_Y 32
+#define SHADOW_REFLECT_ALL (SHADOW_REFLECT_X|SHADOW_REFLECT_Y)
+
+typedef struct _shadowScrPriv {
+ PaintWindowBackgroundProcPtr PaintWindowBackground;
+ PaintWindowBorderProcPtr PaintWindowBorder;
+ CopyWindowProcPtr CopyWindow;
+ CloseScreenProcPtr CloseScreen;
+ CreateGCProcPtr CreateGC;
+ GetImageProcPtr GetImage;
+#ifdef RENDER
+ CompositeProcPtr Composite;
+ GlyphsProcPtr Glyphs;
+#endif
+ shadowBufPtr pBuf;
+ BSFuncRec BackingStoreFuncs;
+} shadowScrPrivRec, *shadowScrPrivPtr;
+
+extern int shadowScrPrivateIndex;
+
+#define shadowGetScrPriv(pScr) ((shadowScrPrivPtr) (pScr)->devPrivates[shadowScrPrivateIndex].ptr)
+#define shadowScrPriv(pScr) shadowScrPrivPtr pScrPriv = shadowGetScrPriv(pScr)
+
+Bool
+shadowSetup (ScreenPtr pScreen);
+
+Bool
+shadowAdd (ScreenPtr pScreen,
+ PixmapPtr pPixmap,
+ ShadowUpdateProc update,
+ ShadowWindowProc window,
+ int randr,
+ void *closure);
+
+void
+shadowRemove (ScreenPtr pScreen, PixmapPtr pPixmap);
+
+shadowBufPtr
+shadowFindBuf (WindowPtr pWindow);
+
+Bool
+shadowInit (ScreenPtr pScreen, ShadowUpdateProc update, ShadowWindowProc window);
+
+void *
+shadowAlloc (int width, int height, int bpp);
+
+void
+shadowUpdatePacked (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+void
+shadowUpdatePlanar4 (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+void
+shadowUpdatePlanar4x8 (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+void
+shadowUpdateRotatePacked (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+void
+shadowUpdateRotate8_90 (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+void
+shadowUpdateRotate16_90 (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+void
+shadowUpdateRotate32_90 (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+void
+shadowUpdateRotate8_180 (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+void
+shadowUpdateRotate16_180 (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+void
+shadowUpdateRotate32_180 (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+void
+shadowUpdateRotate8_270 (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+void
+shadowUpdateRotate16_270 (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+void
+shadowUpdateRotate32_270 (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+typedef void (* shadowUpdateProc)(ScreenPtr, shadowBufPtr);
+
+shadowUpdateProc shadowUpdatePackedWeak(void);
+shadowUpdateProc shadowUpdatePlanar4Weak(void);
+shadowUpdateProc shadowUpdatePlanar4x8Weak(void);
+shadowUpdateProc shadowUpdateRotatePackedWeak(void);
+
+void
+shadowWrapGC (GCPtr pGC);
+
+void
+shadowUnwrapGC (GCPtr pGC);
+
+#endif /* _SHADOW_H_ */
diff --git a/nx-X11/programs/Xserver/miext/shadow/shalloc.c b/nx-X11/programs/Xserver/miext/shadow/shalloc.c
new file mode 100644
index 000000000..5c01f2aac
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shalloc.c
@@ -0,0 +1,52 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "shadow.h"
+
+void *
+shadowAlloc (int width, int height, int bpp)
+{
+ int stride;
+ void *fb;
+
+ /* Cant use PixmapBytePad -- the structure is probably not initialized yet */
+ stride = BitmapBytePad (width * bpp);
+ fb = xalloc (stride * height);
+ return fb;
+}
diff --git a/nx-X11/programs/Xserver/miext/shadow/shmodule.c b/nx-X11/programs/Xserver/miext/shadow/shmodule.c
new file mode 100644
index 000000000..5f347a3b5
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shmodule.c
@@ -0,0 +1,60 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef XFree86LOADER
+
+#include "xf86Module.h"
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "shadow.h"
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "shadow",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_ANSIC, /* Only need the ansic layer */
+ ABI_ANSIC_VERSION,
+ MOD_CLASS_NONE,
+ {0,0,0,0} /* signature, to be patched into the file by a tool */
+};
+
+XF86ModuleData shadowModuleData = { &VersRec, NULL, NULL };
+
+#endif
diff --git a/nx-X11/programs/Xserver/miext/shadow/shpacked.c b/nx-X11/programs/Xserver/miext/shadow/shpacked.c
new file mode 100644
index 000000000..3fdee1473
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shpacked.c
@@ -0,0 +1,114 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shpacked.c,v 1.4 2001/05/29 04:54:13 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "shadow.h"
+#include "fb.h"
+
+void
+shadowUpdatePacked (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ RegionPtr damage = &pBuf->damage;
+ PixmapPtr pShadow = pBuf->pPixmap;
+ int nbox = REGION_NUM_RECTS (damage);
+ BoxPtr pbox = REGION_RECTS (damage);
+ FbBits *shaBase, *shaLine, *sha;
+ FbStride shaStride;
+ int scrBase, scrLine, scr;
+ int shaBpp;
+ int shaXoff, shaYoff; /* XXX assumed to be zero */
+ int x, y, w, h, width;
+ int i;
+ FbBits *winBase = NULL, *win;
+ CARD32 winSize;
+
+ fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff);
+ while (nbox--)
+ {
+ x = pbox->x1 * shaBpp;
+ y = pbox->y1;
+ w = (pbox->x2 - pbox->x1) * shaBpp;
+ h = pbox->y2 - pbox->y1;
+
+ scrLine = (x >> FB_SHIFT);
+ shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
+
+ x &= FB_MASK;
+ w = (w + x + FB_MASK) >> FB_SHIFT;
+
+ while (h--)
+ {
+ winSize = 0;
+ scrBase = 0;
+ width = w;
+ scr = scrLine;
+ sha = shaLine;
+ while (width) {
+ /* how much remains in this window */
+ i = scrBase + winSize - scr;
+ if (i <= 0 || scr < scrBase)
+ {
+ winBase = (FbBits *) (*pBuf->window) (pScreen,
+ y,
+ scr * sizeof (FbBits),
+ SHADOW_WINDOW_WRITE,
+ &winSize,
+ pBuf->closure);
+ if(!winBase)
+ return;
+ scrBase = scr;
+ winSize /= sizeof (FbBits);
+ i = winSize;
+ }
+ win = winBase + (scr - scrBase);
+ if (i > width)
+ i = width;
+ width -= i;
+ scr += i;
+#define PickBit(a,i) (((a) >> (i)) & 1)
+ while (i--)
+ *win++ = *sha++;
+ }
+ shaLine += shaStride;
+ y++;
+ }
+ pbox++;
+ }
+}
+
+shadowUpdateProc shadowUpdatePackedWeak(void) { return shadowUpdatePacked; }
diff --git a/nx-X11/programs/Xserver/miext/shadow/shplanar.c b/nx-X11/programs/Xserver/miext/shadow/shplanar.c
new file mode 100644
index 000000000..979905b86
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shplanar.c
@@ -0,0 +1,179 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shplanar.c,v 1.3 2001/05/29 04:54:13 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "shadow.h"
+#include "fb.h"
+
+/*
+ * 32 4-bit pixels per write
+ */
+
+#define PL_SHIFT 7
+#define PL_UNIT (1 << PL_SHIFT)
+#define PL_MASK (PL_UNIT - 1)
+
+/*
+ * 32->8 conversion:
+ *
+ * 7 6 5 4 3 2 1 0
+ * A B C D E F G H
+ *
+ * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * m . . . H . . . G . . . F . . . E . . . D . . . C . . . B . . . A
+ * m1 G . . . F . . . E . . . D . . . C . . . B . . . A . . . . . . . m << (7 - (p))
+ * m2 . H . . . G . . . F . . . E . . . D . . . C . . . B . . . A . . (m >> (p)) << 2
+ * m3 G E C A m1 & 0x80808080
+ * m4 H F D B m2 & 0x40404040
+ * m5 G H E F C D A B m3 | m4
+ * m6 G H E F C D G H A B E F m5 | (m5 >> 20)
+ * m7 G H E F C D G H A B C D E F G H m6 | (m6 >> 10)
+ */
+
+#if 0
+#define GetBits(p,o,d) {\
+ m = sha[o]; \
+ m1 = m << (7 - (p)); \
+ m2 = (m >> (p)) << 2; \
+ m3 = m1 & 0x80808080; \
+ m4 = m2 & 0x40404040; \
+ m5 = m3 | m4; \
+ m6 = m5 | (m5 >> 20); \
+ d = m6 | (m6 >> 10); \
+}
+#else
+#define GetBits(p,o,d) {\
+ m = sha[o]; \
+ m5 = ((m << (7 - (p))) & 0x80808080) | (((m >> (p)) << 2) & 0x40404040); \
+ m6 = m5 | (m5 >> 20); \
+ d = m6 | (m6 >> 10); \
+}
+#endif
+
+void
+shadowUpdatePlanar4 (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ RegionPtr damage = &pBuf->damage;
+ PixmapPtr pShadow = pBuf->pPixmap;
+ int nbox = REGION_NUM_RECTS (damage);
+ BoxPtr pbox = REGION_RECTS (damage);
+ CARD32 *shaBase, *shaLine, *sha;
+ FbStride shaStride;
+ int scrBase, scrLine, scr;
+ int shaBpp;
+ int shaXoff, shaYoff; /* XXX assumed to be zero */
+ int x, y, w, h, width;
+ int i;
+ CARD32 *winBase = NULL, *win;
+ CARD32 winSize;
+ int plane;
+ CARD32 m,m5,m6;
+ CARD8 s1, s2, s3, s4;
+
+ fbGetStipDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff);
+ while (nbox--)
+ {
+ x = (pbox->x1) * shaBpp;
+ y = (pbox->y1);
+ w = (pbox->x2 - pbox->x1) * shaBpp;
+ h = pbox->y2 - pbox->y1;
+
+ w = (w + (x & PL_MASK) + PL_MASK) >> PL_SHIFT;
+ x &= ~PL_MASK;
+
+ scrLine = (x >> PL_SHIFT);
+ shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
+
+ while (h--)
+ {
+ for (plane = 0; plane < 4; plane++)
+ {
+ width = w;
+ scr = scrLine;
+ sha = shaLine;
+ winSize = 0;
+ scrBase = 0;
+ while (width) {
+ /* how much remains in this window */
+ i = scrBase + winSize - scr;
+ if (i <= 0 || scr < scrBase)
+ {
+ winBase = (CARD32 *) (*pBuf->window) (pScreen,
+ y,
+ (scr << 4) | (plane),
+ SHADOW_WINDOW_WRITE,
+ &winSize,
+ pBuf->closure);
+ if(!winBase)
+ return;
+ winSize >>= 2;
+ scrBase = scr;
+ i = winSize;
+ }
+ win = winBase + (scr - scrBase);
+ if (i > width)
+ i = width;
+ width -= i;
+ scr += i;
+
+ while (i--)
+ {
+ GetBits(plane,0,s1);
+ GetBits(plane,1,s2);
+ GetBits(plane,2,s3);
+ GetBits(plane,3,s4);
+ *win++ = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
+ sha += 4;
+ }
+ }
+ }
+ shaLine += shaStride;
+ y++;
+ }
+ pbox++;
+ }
+}
+
+shadowUpdateProc shadowUpdatePlanar4Weak(void) {
+ return shadowUpdatePlanar4;
+}
+
+shadowUpdateProc shadowUpdatePlanar4x8Weak(void) {
+ return shadowUpdatePlanar4x8;
+}
diff --git a/nx-X11/programs/Xserver/miext/shadow/shplanar8.c b/nx-X11/programs/Xserver/miext/shadow/shplanar8.c
new file mode 100644
index 000000000..f1d87dc50
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shplanar8.c
@@ -0,0 +1,174 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shplanar8.c,v 1.3 2001/05/29 04:54:13 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "shadow.h"
+#include "fb.h"
+
+/*
+ * Expose 8bpp depth 4
+ */
+
+/*
+ * 32->8 conversion:
+ *
+ * 7 6 5 4 3 2 1 0
+ * A B C D E F G H
+ *
+ * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+ * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * m1 D x x x x x x x C x x x x x x x B x x x x x x x A x x x x x x x sha[0] << (7-(p))
+ * m2 x x x x H x x x x x x x G x x x x x x x F x x x x x x x E x x x sha[1] << (3-(p))
+ * m3 D C B A m1 & 0x80808080
+ * m4 H G F E m2 & 0x08080808
+ * m5 D H C G B F A E m3 | m4
+ * m6 D H C G B F m5 >> 9
+ * m7 D H C D G H B C F G A B E F m5 | m6
+ * m8 D H C D G H m7 >> 18
+ * m9 D H C D G H B C D F G H A B C D E F G H m7 | m8
+ */
+
+#define PL_SHIFT 8
+#define PL_UNIT (1 << PL_SHIFT)
+#define PL_MASK (PL_UNIT - 1)
+
+#if 0
+#define GetBits(p,o,d) { \
+ CARD32 m1,m2,m3,m4,m5,m6,m7,m8; \
+ m1 = sha[o] << (7 - (p)); \
+ m2 = sha[(o)+1] << (3 - (p)); \
+ m3 = m1 & 0x80808080; \
+ m4 = m2 & 0x08080808; \
+ m5 = m3 | m4; \
+ m6 = m5 >> 9; \
+ m7 = m5 | m6; \
+ m8 = m7 >> 18; \
+ d = m7 | m8; \
+}
+#else
+#define GetBits(p,o,d) { \
+ CARD32 m5,m7; \
+ m5 = ((sha[o] << (7 - (p))) & 0x80808080) | ((sha[(o)+1] << (3 - (p))) & 0x08080808); \
+ m7 = m5 | (m5 >> 9); \
+ d = m7 | (m7 >> 18); \
+}
+#endif
+
+void
+shadowUpdatePlanar4x8 (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ RegionPtr damage = &pBuf->damage;
+ PixmapPtr pShadow = pBuf->pPixmap;
+ int nbox = REGION_NUM_RECTS (damage);
+ BoxPtr pbox = REGION_RECTS (damage);
+ CARD32 *shaBase, *shaLine, *sha;
+ CARD8 s1, s2, s3, s4;
+ FbStride shaStride;
+ int scrBase, scrLine, scr;
+ int shaBpp;
+ int shaXoff, shaYoff; /* XXX assumed to be zero */
+ int x, y, w, h, width;
+ int i;
+ CARD32 *winBase = NULL, *win;
+ CARD32 winSize;
+ int plane;
+
+ fbGetStipDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff);
+ while (nbox--)
+ {
+ x = pbox->x1 * shaBpp;
+ y = pbox->y1;
+ w = (pbox->x2 - pbox->x1) * shaBpp;
+ h = pbox->y2 - pbox->y1;
+
+ w = (w + (x & PL_MASK) + PL_MASK) >> PL_SHIFT;
+ x &= ~PL_MASK;
+
+ scrLine = (x >> PL_SHIFT);
+ shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
+
+ while (h--)
+ {
+ for (plane = 0; plane < 4; plane++)
+ {
+ width = w;
+ scr = scrLine;
+ sha = shaLine;
+ winSize = 0;
+ scrBase = 0;
+ while (width) {
+ /* how much remains in this window */
+ i = scrBase + winSize - scr;
+ if (i <= 0 || scr < scrBase)
+ {
+ winBase = (CARD32 *) (*pBuf->window) (pScreen,
+ y,
+ (scr << 4) | (plane),
+ SHADOW_WINDOW_WRITE,
+ &winSize,
+ pBuf->closure);
+ if(!winBase)
+ return;
+ winSize >>= 2;
+ scrBase = scr;
+ i = winSize;
+ }
+ win = winBase + (scr - scrBase);
+ if (i > width)
+ i = width;
+ width -= i;
+ scr += i;
+
+ while (i--)
+ {
+ GetBits(plane,0,s1);
+ GetBits(plane,2,s2);
+ GetBits(plane,4,s3);
+ GetBits(plane,6,s4);
+ *win++ = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
+ sha += 8;
+ }
+ }
+ }
+ shaLine += shaStride;
+ y++;
+ }
+ pbox++;
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/miext/shadow/shrot16pack.c b/nx-X11/programs/Xserver/miext/shadow/shrot16pack.c
new file mode 100644
index 000000000..2ec41bb07
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shrot16pack.c
@@ -0,0 +1,32 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define FUNC shadowUpdateRotate16
+#define Data CARD16
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "shrotpack.h"
diff --git a/nx-X11/programs/Xserver/miext/shadow/shrot16pack_180.c b/nx-X11/programs/Xserver/miext/shadow/shrot16pack_180.c
new file mode 100644
index 000000000..06b1603ba
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shrot16pack_180.c
@@ -0,0 +1,33 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define FUNC shadowUpdateRotate16_180
+#define Data CARD16
+#define ROTATE 180
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "shrotpack.h"
diff --git a/nx-X11/programs/Xserver/miext/shadow/shrot16pack_270.c b/nx-X11/programs/Xserver/miext/shadow/shrot16pack_270.c
new file mode 100644
index 000000000..1ad952ec6
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shrot16pack_270.c
@@ -0,0 +1,33 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define FUNC shadowUpdateRotate16_270
+#define Data CARD16
+#define ROTATE 270
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "shrotpack.h"
diff --git a/nx-X11/programs/Xserver/miext/shadow/shrot16pack_90.c b/nx-X11/programs/Xserver/miext/shadow/shrot16pack_90.c
new file mode 100644
index 000000000..cfef7785c
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shrot16pack_90.c
@@ -0,0 +1,33 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define FUNC shadowUpdateRotate16_90
+#define Data CARD16
+#define ROTATE 90
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "shrotpack.h"
diff --git a/nx-X11/programs/Xserver/miext/shadow/shrot32pack.c b/nx-X11/programs/Xserver/miext/shadow/shrot32pack.c
new file mode 100644
index 000000000..95c7c292c
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shrot32pack.c
@@ -0,0 +1,32 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define FUNC shadowUpdateRotate32
+#define Data CARD32
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "shrotpack.h"
diff --git a/nx-X11/programs/Xserver/miext/shadow/shrot32pack_180.c b/nx-X11/programs/Xserver/miext/shadow/shrot32pack_180.c
new file mode 100644
index 000000000..cbadba59d
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shrot32pack_180.c
@@ -0,0 +1,33 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define FUNC shadowUpdateRotate32_180
+#define Data CARD32
+#define ROTATE 180
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "shrotpack.h"
diff --git a/nx-X11/programs/Xserver/miext/shadow/shrot32pack_270.c b/nx-X11/programs/Xserver/miext/shadow/shrot32pack_270.c
new file mode 100644
index 000000000..8f434b08e
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shrot32pack_270.c
@@ -0,0 +1,33 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define FUNC shadowUpdateRotate32_270
+#define Data CARD32
+#define ROTATE 270
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "shrotpack.h"
diff --git a/nx-X11/programs/Xserver/miext/shadow/shrot32pack_90.c b/nx-X11/programs/Xserver/miext/shadow/shrot32pack_90.c
new file mode 100644
index 000000000..98c22c37d
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shrot32pack_90.c
@@ -0,0 +1,33 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define FUNC shadowUpdateRotate32_90
+#define Data CARD32
+#define ROTATE 90
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "shrotpack.h"
diff --git a/nx-X11/programs/Xserver/miext/shadow/shrot8pack.c b/nx-X11/programs/Xserver/miext/shadow/shrot8pack.c
new file mode 100644
index 000000000..9e77f43e8
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shrot8pack.c
@@ -0,0 +1,32 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define FUNC shadowUpdateRotate8
+#define Data CARD8
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "shrotpack.h"
diff --git a/nx-X11/programs/Xserver/miext/shadow/shrot8pack_180.c b/nx-X11/programs/Xserver/miext/shadow/shrot8pack_180.c
new file mode 100644
index 000000000..6f4eca93e
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shrot8pack_180.c
@@ -0,0 +1,33 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define FUNC shadowUpdateRotate8_180
+#define Data CARD8
+#define ROTATE 180
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "shrotpack.h"
diff --git a/nx-X11/programs/Xserver/miext/shadow/shrot8pack_270.c b/nx-X11/programs/Xserver/miext/shadow/shrot8pack_270.c
new file mode 100644
index 000000000..d56a3366c
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shrot8pack_270.c
@@ -0,0 +1,33 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define FUNC shadowUpdateRotate8_270
+#define Data CARD8
+#define ROTATE 270
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "shrotpack.h"
diff --git a/nx-X11/programs/Xserver/miext/shadow/shrot8pack_90.c b/nx-X11/programs/Xserver/miext/shadow/shrot8pack_90.c
new file mode 100644
index 000000000..2fed8126d
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shrot8pack_90.c
@@ -0,0 +1,33 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define FUNC shadowUpdateRotate8_90
+#define Data CARD8
+#define ROTATE 90
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "shrotpack.h"
diff --git a/nx-X11/programs/Xserver/miext/shadow/shrotate.c b/nx-X11/programs/Xserver/miext/shadow/shrotate.c
new file mode 100644
index 000000000..927bc61be
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shrotate.c
@@ -0,0 +1,314 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shrotate.c,v 1.4tsi Exp $
+ *
+ * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "shadow.h"
+#include "fb.h"
+
+/*
+ * These indicate which way the source (shadow) is scanned when
+ * walking the screen in a particular direction
+ */
+
+#define LEFT_TO_RIGHT 1
+#define RIGHT_TO_LEFT -1
+#define TOP_TO_BOTTOM 2
+#define BOTTOM_TO_TOP -2
+
+void
+shadowUpdateRotatePacked (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ RegionPtr damage = &pBuf->damage;
+ PixmapPtr pShadow = pBuf->pPixmap;
+ int nbox = REGION_NUM_RECTS (damage);
+ BoxPtr pbox = REGION_RECTS (damage);
+ FbBits *shaBits;
+ FbStride shaStride;
+ int shaBpp;
+ int shaXoff, shaYoff;
+ int box_x1, box_x2, box_y1, box_y2;
+ int sha_x1 = 0, sha_y1 = 0;
+ int scr_x1 = 0, scr_x2 = 0, scr_y1 = 0, scr_y2 = 0, scr_w, scr_h;
+ int scr_x, scr_y;
+ int w;
+ int pixelsPerBits;
+ int pixelsMask;
+ FbStride shaStepOverY = 0, shaStepDownY = 0;
+ FbStride shaStepOverX = 0, shaStepDownX = 0;
+ FbBits *shaLine, *sha;
+ int shaHeight = pShadow->drawable.height;
+ int shaWidth = pShadow->drawable.width;
+ FbBits shaMask;
+ int shaFirstShift, shaShift;
+ int o_x_dir;
+ int o_y_dir;
+ int x_dir;
+ int y_dir;
+
+ fbGetDrawable (&pShadow->drawable, shaBits, shaStride, shaBpp, shaXoff, shaYoff);
+ pixelsPerBits = (sizeof (FbBits) * 8) / shaBpp;
+ pixelsMask = ~(pixelsPerBits - 1);
+ shaMask = FbBitsMask (FB_UNIT-shaBpp, shaBpp);
+ /*
+ * Compute rotation related constants to walk the shadow
+ */
+ o_x_dir = LEFT_TO_RIGHT;
+ o_y_dir = TOP_TO_BOTTOM;
+ if (pBuf->randr & SHADOW_REFLECT_X)
+ o_x_dir = -o_x_dir;
+ if (pBuf->randr & SHADOW_REFLECT_Y)
+ o_y_dir = -o_y_dir;
+ switch (pBuf->randr & (SHADOW_ROTATE_ALL)) {
+ case SHADOW_ROTATE_0: /* upper left shadow -> upper left screen */
+ default:
+ x_dir = o_x_dir;
+ y_dir = o_y_dir;
+ break;
+ case SHADOW_ROTATE_90: /* upper right shadow -> upper left screen */
+ x_dir = o_y_dir;
+ y_dir = -o_x_dir;
+ break;
+ case SHADOW_ROTATE_180: /* lower right shadow -> upper left screen */
+ x_dir = -o_x_dir;
+ y_dir = -o_y_dir;
+ break;
+ case SHADOW_ROTATE_270: /* lower left shadow -> upper left screen */
+ x_dir = -o_y_dir;
+ y_dir = o_x_dir;
+ break;
+ }
+ switch (x_dir) {
+ case LEFT_TO_RIGHT:
+ shaStepOverX = shaBpp;
+ shaStepOverY = 0;
+ break;
+ case TOP_TO_BOTTOM:
+ shaStepOverX = 0;
+ shaStepOverY = shaStride;
+ break;
+ case RIGHT_TO_LEFT:
+ shaStepOverX = -shaBpp;
+ shaStepOverY = 0;
+ break;
+ case BOTTOM_TO_TOP:
+ shaStepOverX = 0;
+ shaStepOverY = -shaStride;
+ break;
+ }
+ switch (y_dir) {
+ case TOP_TO_BOTTOM:
+ shaStepDownX = 0;
+ shaStepDownY = shaStride;
+ break;
+ case RIGHT_TO_LEFT:
+ shaStepDownX = -shaBpp;
+ shaStepDownY = 0;
+ break;
+ case BOTTOM_TO_TOP:
+ shaStepDownX = 0;
+ shaStepDownY = -shaStride;
+ break;
+ case LEFT_TO_RIGHT:
+ shaStepDownX = shaBpp;
+ shaStepDownY = 0;
+ break;
+ }
+
+ while (nbox--)
+ {
+ box_x1 = pbox->x1;
+ box_y1 = pbox->y1;
+ box_x2 = pbox->x2;
+ box_y2 = pbox->y2;
+ pbox++;
+
+ /*
+ * Compute screen and shadow locations for this box
+ */
+ switch (x_dir) {
+ case LEFT_TO_RIGHT:
+ scr_x1 = box_x1 & pixelsMask;
+ scr_x2 = (box_x2 + pixelsPerBits - 1) & pixelsMask;
+
+ sha_x1 = scr_x1;
+ break;
+ case TOP_TO_BOTTOM:
+ scr_x1 = box_y1 & pixelsMask;
+ scr_x2 = (box_y2 + pixelsPerBits - 1) & pixelsMask;
+
+ sha_y1 = scr_x1;
+ break;
+ case RIGHT_TO_LEFT:
+ scr_x1 = (shaWidth - box_x2) & pixelsMask;
+ scr_x2 = (shaWidth - box_x1 + pixelsPerBits - 1) & pixelsMask;
+
+ sha_x1 = (shaWidth - scr_x1 - 1);
+ break;
+ case BOTTOM_TO_TOP:
+ scr_x1 = (shaHeight - box_y2) & pixelsMask;
+ scr_x2 = (shaHeight - box_y1 + pixelsPerBits - 1) & pixelsMask;
+
+ sha_y1 = (shaHeight - scr_x1 - 1);
+ break;
+ }
+ switch (y_dir) {
+ case TOP_TO_BOTTOM:
+ scr_y1 = box_y1;
+ scr_y2 = box_y2;
+
+ sha_y1 = scr_y1;
+ break;
+ case RIGHT_TO_LEFT:
+ scr_y1 = (shaWidth - box_x2);
+ scr_y2 = (shaWidth - box_x1);
+
+ sha_x1 = box_x2 - 1;
+ break;
+ case BOTTOM_TO_TOP:
+ scr_y1 = shaHeight - box_y2;
+ scr_y2 = shaHeight - box_y1;
+
+ sha_y1 = box_y2 - 1;
+ break;
+ case LEFT_TO_RIGHT:
+ scr_y1 = box_x1;
+ scr_y2 = box_x2;
+
+ sha_x1 = box_x1;
+ break;
+ }
+ scr_w = ((scr_x2 - scr_x1) * shaBpp) >> FB_SHIFT;
+ scr_h = scr_y2 - scr_y1;
+ scr_y = scr_y1;
+
+ /* shift amount for first pixel on screen */
+ shaFirstShift = FB_UNIT - ((sha_x1 * shaBpp) & FB_MASK) - shaBpp;
+
+ /* pointer to shadow data first placed on screen */
+ shaLine = (shaBits +
+ sha_y1 * shaStride +
+ ((sha_x1 * shaBpp) >> FB_SHIFT));
+
+ /*
+ * Copy the bits, always write across the physical frame buffer
+ * to take advantage of write combining.
+ */
+ while (scr_h--)
+ {
+ int p;
+ FbBits bits;
+ FbBits *win;
+ int i;
+ CARD32 winSize;
+
+ sha = shaLine;
+ shaShift = shaFirstShift;
+ w = scr_w;
+ scr_x = scr_x1 * shaBpp >> FB_SHIFT;
+
+ while (w)
+ {
+ /*
+ * Map some of this line
+ */
+ win = (FbBits *) (*pBuf->window) (pScreen,
+ scr_y,
+ scr_x << 2,
+ SHADOW_WINDOW_WRITE,
+ &winSize,
+ pBuf->closure);
+ i = (winSize >> 2);
+ if (i > w)
+ i = w;
+ w -= i;
+ scr_x += i;
+ /*
+ * Copy the portion of the line mapped
+ */
+ while (i--)
+ {
+ bits = 0;
+ p = pixelsPerBits;
+ /*
+ * Build one word of output from multiple inputs
+ *
+ * Note that for 90/270 rotations, this will walk
+ * down the shadow hitting each scanline once.
+ * This is probably not very efficient.
+ */
+ while (p--)
+ {
+ bits = FbScrLeft(bits, shaBpp);
+ bits |= FbScrRight (*sha, shaShift) & shaMask;
+
+ shaShift -= shaStepOverX;
+ if (shaShift >= FB_UNIT)
+ {
+ shaShift -= FB_UNIT;
+ sha--;
+ }
+ else if (shaShift < 0)
+ {
+ shaShift += FB_UNIT;
+ sha++;
+ }
+ sha += shaStepOverY;
+ }
+ *win++ = bits;
+ }
+ }
+ scr_y++;
+ shaFirstShift -= shaStepDownX;
+ if (shaFirstShift >= FB_UNIT)
+ {
+ shaFirstShift -= FB_UNIT;
+ shaLine--;
+ }
+ else if (shaFirstShift < 0)
+ {
+ shaFirstShift += FB_UNIT;
+ shaLine++;
+ }
+ shaLine += shaStepDownY;
+ }
+ }
+}
+
+shadowUpdateProc shadowUpdateRotatePackedWeak(void) {
+ return shadowUpdateRotatePacked;
+}
diff --git a/nx-X11/programs/Xserver/miext/shadow/shrotpack.h b/nx-X11/programs/Xserver/miext/shadow/shrotpack.h
new file mode 100644
index 000000000..062d8c394
--- /dev/null
+++ b/nx-X11/programs/Xserver/miext/shadow/shrotpack.h
@@ -0,0 +1,186 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shrotpack.h,v 1.3 2001/05/29 04:54:13 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * Thanks to Daniel Chemko <dchemko@intrinsyc.com> for making the 90 and 180
+ * orientations work.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/fonts/font.h>
+#include "dixfontstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "mi.h"
+#include "regionstr.h"
+#include "globals.h"
+#include "gcstruct.h"
+#include "shadow.h"
+#include "fb.h"
+
+#define DANDEBUG 0
+
+#if ROTATE == 270
+
+#define SCRLEFT(x,y,w,h) (pScreen->height - ((y) + (h)))
+#define SCRY(x,y,w,h) (x)
+#define SCRWIDTH(x,y,w,h) (h)
+#define FIRSTSHA(x,y,w,h) (((y) + (h) - 1) * shaStride + (x))
+#define STEPDOWN(x,y,w,h) ((w)--)
+#define NEXTY(x,y,w,h) ((x)++)
+#define SHASTEPX(stride) -(stride)
+#define SHASTEPY(stride) (1)
+
+#elif ROTATE == 90
+
+#define SCRLEFT(x,y,w,h) (y)
+#define SCRY(x,y,w,h) (pScreen->width - ((x) + (w)) - 1)
+#define SCRWIDTH(x,y,w,h) (h)
+#define FIRSTSHA(x,y,w,h) ((y) * shaStride + (x + w - 1))
+#define STEPDOWN(x,y,w,h) ((w)--)
+#define NEXTY(x,y,w,h) ((void)(x))
+#define SHASTEPX(stride) (stride)
+#define SHASTEPY(stride) (-1)
+
+#elif ROTATE == 180
+
+#define SCRLEFT(x,y,w,h) (pScreen->width - ((x) + (w)))
+#define SCRY(x,y,w,h) (pScreen->height - ((y) + (h)) - 1)
+#define SCRWIDTH(x,y,w,h) (w)
+#define FIRSTSHA(x,y,w,h) ((y + h - 1) * shaStride + (x + w - 1))
+#define STEPDOWN(x,y,w,h) ((h)--)
+#define NEXTY(x,y,w,h) ((void)(y))
+#define SHASTEPX(stride) (-1)
+#define SHASTEPY(stride) -(stride)
+
+#else
+
+#define SCRLEFT(x,y,w,h) (x)
+#define SCRY(x,y,w,h) (y)
+#define SCRWIDTH(x,y,w,h) (w)
+#define FIRSTSHA(x,y,w,h) ((y) * shaStride + (x))
+#define STEPDOWN(x,y,w,h) ((h)--)
+#define NEXTY(x,y,w,h) ((y)++)
+#define SHASTEPX(stride) (1)
+#define SHASTEPY(stride) (stride)
+
+#endif
+
+void
+FUNC (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ RegionPtr damage = &pBuf->damage;
+ PixmapPtr pShadow = pBuf->pPixmap;
+ int nbox = REGION_NUM_RECTS (damage);
+ BoxPtr pbox = REGION_RECTS (damage);
+ FbBits *shaBits;
+ Data *shaBase, *shaLine, *sha;
+ FbStride shaStride;
+ int scrBase, scrLine, scr;
+ int shaBpp;
+ int shaXoff, shaYoff; /* XXX assumed to be zero */
+ int x, y, w, h, width;
+ int i;
+ Data *winBase = NULL, *win;
+ CARD32 winSize;
+
+ fbGetDrawable (&pShadow->drawable, shaBits, shaStride, shaBpp, shaXoff, shaYoff);
+ shaBase = (Data *) shaBits;
+ shaStride = shaStride * sizeof (FbBits) / sizeof (Data);
+#if (DANDEBUG > 1)
+ ErrorF ("-> Entering Shadow Update:\r\n |- Origins: pShadow=%x, pScreen=%x, damage=%x\r\n |- Metrics: shaStride=%d, shaBase=%x, shaBpp=%d\r\n | \n", pShadow, pScreen, damage, shaStride, shaBase, shaBpp);
+#endif
+ while (nbox--)
+ {
+ x = pbox->x1;
+ y = pbox->y1;
+ w = (pbox->x2 - pbox->x1);
+ h = pbox->y2 - pbox->y1;
+
+#if (DANDEBUG > 2)
+ ErrorF (" |-> Redrawing box - Metrics: X=%d, Y=%d, Width=%d, Height=%d\n", x, y, w, h);
+#endif
+ scrLine = SCRLEFT(x,y,w,h);
+ shaLine = shaBase + FIRSTSHA(x,y,w,h);
+
+ while (STEPDOWN(x,y,w,h))
+ {
+ winSize = 0;
+ scrBase = 0;
+ width = SCRWIDTH(x,y,w,h);
+ scr = scrLine;
+ sha = shaLine;
+#if (DANDEBUG > 3)
+ ErrorF (" | |-> StepDown - Metrics: width=%d, scr=%x, sha=%x\n", width, scr, sha);
+#endif
+ while (width)
+ {
+ /* how much remains in this window */
+ i = scrBase + winSize - scr;
+ if (i <= 0 || scr < scrBase)
+ {
+ winBase = (Data *) (*pBuf->window) (pScreen,
+ SCRY(x,y,w,h),
+ scr * sizeof (Data),
+ SHADOW_WINDOW_WRITE,
+ &winSize,
+ pBuf->closure);
+ if(!winBase)
+ return;
+ scrBase = scr;
+ winSize /= sizeof (Data);
+ i = winSize;
+#if(DANDEBUG > 4)
+ ErrorF (" | | |-> Starting New Line - Metrics: winBase=%x, scrBase=%x, winSize=%d\r\n | | | Xstride=%d, Ystride=%d, w=%d h=%d\n", winBase, scrBase, winSize, SHASTEPX(shaStride), SHASTEPY(shaStride), w, h);
+#endif
+ }
+ win = winBase + (scr - scrBase);
+ if (i > width)
+ i = width;
+ width -= i;
+ scr += i;
+#if(DANDEBUG > 5)
+ ErrorF (" | | |-> Writing Line - Metrics: win=%x, sha=%x\n", win, sha);
+#endif
+ while (i--)
+ {
+#if(DANDEBUG > 6)
+ ErrorF (" | | |-> Writing Pixel - Metrics: win=%x, sha=%d, remaining=%d\n", win, sha, i);
+#endif
+ *win++ = *sha;
+ sha += SHASTEPX(shaStride);
+ } /* i */
+ } /* width */
+ shaLine += SHASTEPY(shaStride);
+ NEXTY(x,y,w,h);
+ } /* STEPDOWN */
+ pbox++;
+ } /* nbox */
+}
diff --git a/nx-X11/programs/Xserver/os/Imakefile b/nx-X11/programs/Xserver/os/Imakefile
new file mode 100644
index 000000000..1f46c2934
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/Imakefile
@@ -0,0 +1,235 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:53:40 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/os/Imakefile,v 3.40 2003/09/09 03:20:41 dawes Exp $
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+#include <Server.tmpl>
+
+/*
+ * If you have any extra files to be put into the library, define them here.
+ */
+
+#if NXLibraries
+
+NX_INCLUDES = -I../../../../nxcomp
+
+NX_DEFINES = -DNX_TRANS_SOCKET \
+ -DNX_TRANS_AUTH \
+ -DNX_TRANS_FOPEN \
+ -DNX_TRANS_SLEEP \
+ -DNX_TRANS_EXIT \
+ -DNX_TRANS_WAKEUP=1000
+
+# -DNX_TRANS_WARN \
+# -DNX_TRANS_INFO \
+# -DNX_TRANS_TEST \
+# -DNX_TRANS_DEBUG \
+
+#endif
+
+/*
+ * do not modify the following two definitions
+ */
+
+#ifndef OtherSources
+#define OtherSources
+#endif
+
+#ifndef OtherObjects
+#define OtherObjects
+#endif
+
+#if HasXdmAuth
+XDMAUTHDEFS = -DHASXDMAUTH
+XDMAUTHOBJS = xdmauth.o
+XDMAUTHSRCS = xdmauth.c
+#else
+XDMAUTHDEFS =
+XDMAUTHOBJS =
+XDMAUTHSCRS =
+#endif
+
+#if HasSecureRPC
+RPCDEFS = -DSECURE_RPC
+RPCOBJS = rpcauth.o
+RPCSRCS = rpcauth.c
+#else
+RPCDEFS =
+RPCOBJS =
+RPCSRCS =
+#endif
+
+#if HasKrb5
+KRB5OBJS = k5auth.o k5encode.o
+KRB5SRCS = k5auth.c k5encode.c
+#endif
+
+#if HasBSD44Sockets
+ SOCK_DEFINES = -DBSD44SOCKETS
+#endif
+
+#if HasGetIfAddrs
+ IFADDRS_DEFINES = -DHAS_GETIFADDRS
+#endif
+
+#if BuildLBX
+ LBX_SRCS = lbxio.c
+ LBX_OBJS = lbxio.o
+#else
+ LBX_SRCS =
+ LBX_OBJS =
+#endif
+
+#if !defined(DDXOsColor)
+COLOR_SRCS=oscolor.c
+COLOR_OBJS=oscolor.o
+#endif
+
+#if UseInternalMalloc
+MALLOC_SRCS=xalloc.c
+MALLOC_OBJS=xalloc.o
+#endif
+
+#if !HasSnprintf
+SNPRINTF_SRCS = snprintf.c
+SNPRINTF_OBJS = snprintf.o
+#endif
+
+#if !HasStrlcat
+STRLCAT_SRCS = strlcat.c strlcpy.c
+STRLCAT_OBJS = strlcat.o strlcpy.o
+#endif
+
+#if HasGetpeerucred
+GETPEER_DEFINES = -DHAS_GETPEERUCRED
+#else
+# if HasGetpeereid
+GETPEER_DEFINES = -DHAS_GETPEEREID
+# endif
+#endif
+
+BOOTSTRAPCFLAGS =
+ SRCS = WaitFor.c access.c connection.c io.c $(COLOR_SRCS) \
+ osinit.c utils.c log.c auth.c mitauth.c secauth.c \
+ $(XDMAUTHSRCS) $(RPCSRCS) $(KRB5SRCS) xdmcp.c OtherSources \
+ transport.c $(SNPRINTF_SRCS) $(STRLCAT_SRCS) \
+ $(MALLOC_SRCS) $(LBX_SRCS) xprintf.c
+ OBJS = WaitFor.o access.o connection.o io.o $(COLOR_OBJS) \
+ osinit.o utils.o log.o auth.o mitauth.o secauth.o \
+ $(XDMAUTHOBJS) $(RPCOBJS) $(KRB5OBJS) xdmcp.o OtherObjects \
+ transport.o $(SNPRINTF_OBJS) $(STRLCAT_OBJS) \
+ $(MALLOC_OBJS) $(LBX_OBJS) xprintf.o
+
+#if SpecialMalloc
+ MEM_DEFINES = -DSPECIAL_MALLOC
+#endif /* SpecialMalloc */
+#if UseInternalMalloc
+ MEM_DEFINES = -DINTERNAL_MALLOC
+#endif
+#if UseMemLeak
+ MEM_DEFINES = -DMEMBUG
+#endif
+#if UseRgbTxt
+ RGB_DEFINES = -DUSE_RGB_TXT
+#endif
+ DBM_DEFINES = NdbmDefines
+ ADM_DEFINES = -DADMPATH=\"$(ADMDIR)/X\%smsgs\"
+ XDMCP_DEFINES = ServerXdmcpDefines
+ KRB5_DEFINES = Krb5Defines
+ XALLOC_DEFINES = XallocDefines
+ ERROR_DEFINES = ServerErrorDefines
+#if HasPam && HasPamMisc
+ PAM_DEFINES = -DUSE_PAM
+#endif
+ DEFINES = -DXSERV_t -DTRANS_SERVER $(CONNECTION_FLAGS) $(MEM_DEFINES) \
+ $(XDMAUTHDEFS) $(RPCDEFS) $(SIGNAL_DEFINES) $(OS_DEFINES) \
+ $(KRB5_DEFINES) $(RGB_DEFINES) $(GETPEER_DEFINES) \
+ $(RANDOM_DEFINES) $(BUGMSG) $(XTRANS_FAILDEFINES) $(NX_DEFINES)
+ INCLUDES = -I. -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) \
+ -I$(SERVERSRC)/Xext -I$(FONTINCSRC) -I$(SERVERSRC)/render \
+ -I$(TOP)/lib/Xau -I../lbx -I../Xprint Krb5Includes $(NX_INCLUDES)
+ DEPEND_DEFINES = $(DBM_DEFINES) $(XDMCP_DEFINES) $(EXT_DEFINES) \
+ $(TRANS_INCLUDES) $(CONNECTION_FLAGS) $(GETPEER_DEFINES) \
+ DependDefines
+ LINTLIBS = ../dix/llib-ldix.ln
+
+#ifdef NEED_ALLOCA_FROM_LIBPW
+ PWLIB = /lib/libPW.a
+#endif /* NEED_ALLOCA_FROM_LIBPW */
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(os,$(OBJS))
+LintLibraryTarget(os,$(SRCS))
+NormalLintTarget($(SRCS))
+
+#ifdef NEED_ALLOCA_FROM_LIBPW
+XCOMM
+XCOMM And this one is to get the version of alloca that lives in /lib/libPW.a
+XCOMM without getting all of the rest of the stuff in there.
+XCOMM
+alloca.o: $(PWLIB)
+ rm -f alloca.o
+ ar x $(PWLIB) alloca.o
+#endif /* NEED_ALLOCA_FROM_LIBPW */
+
+SpecialCObjectRule(access,$(ICONFIGFILES),$(XDMCP_DEFINES) $(SOCK_DEFINES) $(IFADDRS_DEFINES))
+SpecialCObjectRule(auth,$(ICONFIGFILES),$(XDMCP_DEFINES))
+SpecialCObjectRule(xdmauth,$(ICONFIGFILES),$(XDMCP_DEFINES))
+SpecialCObjectRule(xdmcp,$(ICONFIGFILES),$(SOCK_DEFINES) $(XDMCP_DEFINES))
+SpecialCObjectRule(connection,$(ICONFIGFILES),$(SOCK_DEFINES) $(XDMCP_DEFINES))
+SpecialCObjectRule(transport,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES))
+LinkSourceFile(transport.c,$(TRANSCOMMSRC))
+SpecialCObjectRule(osinit,$(ICONFIGFILES),$(ADM_DEFINES))
+SpecialCObjectRule(WaitFor,$(ICONFIGFILES),$(EXT_DEFINES))
+SpecialCObjectRule(io,$(ICONFIGFILES),$(EXT_DEFINES))
+#if BuildLBX
+SpecialCObjectRule(lbxio,$(ICONFIGFILES),$(EXT_DEFINES))
+#endif
+SpecialCObjectRule(utils,$(ICONFIGFILES),$(XDMCP_DEFINES) $(EXT_DEFINES) $(ERROR_DEFINES) $(PAM_DEFINES))
+SpecialCObjectRule(xalloc,$(ICONFIGFILES),$(XALLOC_DEFINES))
+#if defined(SparcArchitecture) && HasGcc && !HasGcc2
+oscolor.o: oscolor.c $(ICONFIGFILES)
+ $(RM) $@
+ cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
+#else
+SpecialCObjectRule(oscolor,$(ICONFIGFILES),$(DBM_DEFINES))
+#endif
+
+#if HasKrb5
+LinkSourceFile(k5encode.c,$(XAUTHSRC))
+#endif
+
+#if !HasSnprintf
+LinkSourceFile(snprintf.c,$(LIBSRC)/misc)
+#endif
+
+#if !HasStrlcat
+LinkSourceFile(strlcat.c,$(LIBSRC)/misc)
+LinkSourceFile(strlcpy.c,$(LIBSRC)/misc)
+#endif
+
+#if DoLoadableServer
+AllTarget(libcwrapper.o)
+ObjectFromSpecialSource(libcwrapper,$(XF86OSSRC)/shared/libc_wrapper,-DSELF_CONTAINED_WRAPPER)
+#endif
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/os/Imakefile.NX.original b/nx-X11/programs/Xserver/os/Imakefile.NX.original
new file mode 100644
index 000000000..1f46c2934
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/Imakefile.NX.original
@@ -0,0 +1,235 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:53:40 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/os/Imakefile,v 3.40 2003/09/09 03:20:41 dawes Exp $
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+#include <Server.tmpl>
+
+/*
+ * If you have any extra files to be put into the library, define them here.
+ */
+
+#if NXLibraries
+
+NX_INCLUDES = -I../../../../nxcomp
+
+NX_DEFINES = -DNX_TRANS_SOCKET \
+ -DNX_TRANS_AUTH \
+ -DNX_TRANS_FOPEN \
+ -DNX_TRANS_SLEEP \
+ -DNX_TRANS_EXIT \
+ -DNX_TRANS_WAKEUP=1000
+
+# -DNX_TRANS_WARN \
+# -DNX_TRANS_INFO \
+# -DNX_TRANS_TEST \
+# -DNX_TRANS_DEBUG \
+
+#endif
+
+/*
+ * do not modify the following two definitions
+ */
+
+#ifndef OtherSources
+#define OtherSources
+#endif
+
+#ifndef OtherObjects
+#define OtherObjects
+#endif
+
+#if HasXdmAuth
+XDMAUTHDEFS = -DHASXDMAUTH
+XDMAUTHOBJS = xdmauth.o
+XDMAUTHSRCS = xdmauth.c
+#else
+XDMAUTHDEFS =
+XDMAUTHOBJS =
+XDMAUTHSCRS =
+#endif
+
+#if HasSecureRPC
+RPCDEFS = -DSECURE_RPC
+RPCOBJS = rpcauth.o
+RPCSRCS = rpcauth.c
+#else
+RPCDEFS =
+RPCOBJS =
+RPCSRCS =
+#endif
+
+#if HasKrb5
+KRB5OBJS = k5auth.o k5encode.o
+KRB5SRCS = k5auth.c k5encode.c
+#endif
+
+#if HasBSD44Sockets
+ SOCK_DEFINES = -DBSD44SOCKETS
+#endif
+
+#if HasGetIfAddrs
+ IFADDRS_DEFINES = -DHAS_GETIFADDRS
+#endif
+
+#if BuildLBX
+ LBX_SRCS = lbxio.c
+ LBX_OBJS = lbxio.o
+#else
+ LBX_SRCS =
+ LBX_OBJS =
+#endif
+
+#if !defined(DDXOsColor)
+COLOR_SRCS=oscolor.c
+COLOR_OBJS=oscolor.o
+#endif
+
+#if UseInternalMalloc
+MALLOC_SRCS=xalloc.c
+MALLOC_OBJS=xalloc.o
+#endif
+
+#if !HasSnprintf
+SNPRINTF_SRCS = snprintf.c
+SNPRINTF_OBJS = snprintf.o
+#endif
+
+#if !HasStrlcat
+STRLCAT_SRCS = strlcat.c strlcpy.c
+STRLCAT_OBJS = strlcat.o strlcpy.o
+#endif
+
+#if HasGetpeerucred
+GETPEER_DEFINES = -DHAS_GETPEERUCRED
+#else
+# if HasGetpeereid
+GETPEER_DEFINES = -DHAS_GETPEEREID
+# endif
+#endif
+
+BOOTSTRAPCFLAGS =
+ SRCS = WaitFor.c access.c connection.c io.c $(COLOR_SRCS) \
+ osinit.c utils.c log.c auth.c mitauth.c secauth.c \
+ $(XDMAUTHSRCS) $(RPCSRCS) $(KRB5SRCS) xdmcp.c OtherSources \
+ transport.c $(SNPRINTF_SRCS) $(STRLCAT_SRCS) \
+ $(MALLOC_SRCS) $(LBX_SRCS) xprintf.c
+ OBJS = WaitFor.o access.o connection.o io.o $(COLOR_OBJS) \
+ osinit.o utils.o log.o auth.o mitauth.o secauth.o \
+ $(XDMAUTHOBJS) $(RPCOBJS) $(KRB5OBJS) xdmcp.o OtherObjects \
+ transport.o $(SNPRINTF_OBJS) $(STRLCAT_OBJS) \
+ $(MALLOC_OBJS) $(LBX_OBJS) xprintf.o
+
+#if SpecialMalloc
+ MEM_DEFINES = -DSPECIAL_MALLOC
+#endif /* SpecialMalloc */
+#if UseInternalMalloc
+ MEM_DEFINES = -DINTERNAL_MALLOC
+#endif
+#if UseMemLeak
+ MEM_DEFINES = -DMEMBUG
+#endif
+#if UseRgbTxt
+ RGB_DEFINES = -DUSE_RGB_TXT
+#endif
+ DBM_DEFINES = NdbmDefines
+ ADM_DEFINES = -DADMPATH=\"$(ADMDIR)/X\%smsgs\"
+ XDMCP_DEFINES = ServerXdmcpDefines
+ KRB5_DEFINES = Krb5Defines
+ XALLOC_DEFINES = XallocDefines
+ ERROR_DEFINES = ServerErrorDefines
+#if HasPam && HasPamMisc
+ PAM_DEFINES = -DUSE_PAM
+#endif
+ DEFINES = -DXSERV_t -DTRANS_SERVER $(CONNECTION_FLAGS) $(MEM_DEFINES) \
+ $(XDMAUTHDEFS) $(RPCDEFS) $(SIGNAL_DEFINES) $(OS_DEFINES) \
+ $(KRB5_DEFINES) $(RGB_DEFINES) $(GETPEER_DEFINES) \
+ $(RANDOM_DEFINES) $(BUGMSG) $(XTRANS_FAILDEFINES) $(NX_DEFINES)
+ INCLUDES = -I. -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) \
+ -I$(SERVERSRC)/Xext -I$(FONTINCSRC) -I$(SERVERSRC)/render \
+ -I$(TOP)/lib/Xau -I../lbx -I../Xprint Krb5Includes $(NX_INCLUDES)
+ DEPEND_DEFINES = $(DBM_DEFINES) $(XDMCP_DEFINES) $(EXT_DEFINES) \
+ $(TRANS_INCLUDES) $(CONNECTION_FLAGS) $(GETPEER_DEFINES) \
+ DependDefines
+ LINTLIBS = ../dix/llib-ldix.ln
+
+#ifdef NEED_ALLOCA_FROM_LIBPW
+ PWLIB = /lib/libPW.a
+#endif /* NEED_ALLOCA_FROM_LIBPW */
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(os,$(OBJS))
+LintLibraryTarget(os,$(SRCS))
+NormalLintTarget($(SRCS))
+
+#ifdef NEED_ALLOCA_FROM_LIBPW
+XCOMM
+XCOMM And this one is to get the version of alloca that lives in /lib/libPW.a
+XCOMM without getting all of the rest of the stuff in there.
+XCOMM
+alloca.o: $(PWLIB)
+ rm -f alloca.o
+ ar x $(PWLIB) alloca.o
+#endif /* NEED_ALLOCA_FROM_LIBPW */
+
+SpecialCObjectRule(access,$(ICONFIGFILES),$(XDMCP_DEFINES) $(SOCK_DEFINES) $(IFADDRS_DEFINES))
+SpecialCObjectRule(auth,$(ICONFIGFILES),$(XDMCP_DEFINES))
+SpecialCObjectRule(xdmauth,$(ICONFIGFILES),$(XDMCP_DEFINES))
+SpecialCObjectRule(xdmcp,$(ICONFIGFILES),$(SOCK_DEFINES) $(XDMCP_DEFINES))
+SpecialCObjectRule(connection,$(ICONFIGFILES),$(SOCK_DEFINES) $(XDMCP_DEFINES))
+SpecialCObjectRule(transport,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES))
+LinkSourceFile(transport.c,$(TRANSCOMMSRC))
+SpecialCObjectRule(osinit,$(ICONFIGFILES),$(ADM_DEFINES))
+SpecialCObjectRule(WaitFor,$(ICONFIGFILES),$(EXT_DEFINES))
+SpecialCObjectRule(io,$(ICONFIGFILES),$(EXT_DEFINES))
+#if BuildLBX
+SpecialCObjectRule(lbxio,$(ICONFIGFILES),$(EXT_DEFINES))
+#endif
+SpecialCObjectRule(utils,$(ICONFIGFILES),$(XDMCP_DEFINES) $(EXT_DEFINES) $(ERROR_DEFINES) $(PAM_DEFINES))
+SpecialCObjectRule(xalloc,$(ICONFIGFILES),$(XALLOC_DEFINES))
+#if defined(SparcArchitecture) && HasGcc && !HasGcc2
+oscolor.o: oscolor.c $(ICONFIGFILES)
+ $(RM) $@
+ cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
+#else
+SpecialCObjectRule(oscolor,$(ICONFIGFILES),$(DBM_DEFINES))
+#endif
+
+#if HasKrb5
+LinkSourceFile(k5encode.c,$(XAUTHSRC))
+#endif
+
+#if !HasSnprintf
+LinkSourceFile(snprintf.c,$(LIBSRC)/misc)
+#endif
+
+#if !HasStrlcat
+LinkSourceFile(strlcat.c,$(LIBSRC)/misc)
+LinkSourceFile(strlcpy.c,$(LIBSRC)/misc)
+#endif
+
+#if DoLoadableServer
+AllTarget(libcwrapper.o)
+ObjectFromSpecialSource(libcwrapper,$(XF86OSSRC)/shared/libc_wrapper,-DSELF_CONTAINED_WRAPPER)
+#endif
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/os/Imakefile.X.original b/nx-X11/programs/Xserver/os/Imakefile.X.original
new file mode 100644
index 000000000..c24a016dc
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/Imakefile.X.original
@@ -0,0 +1,200 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:53:40 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/os/Imakefile,v 3.40 2003/09/09 03:20:41 dawes Exp $
+
+#include <Server.tmpl>
+
+/*
+ * If you have any extra files to be put into the library, define them here.
+ */
+
+/*
+ * do not modify the following two definitions
+ */
+
+#ifndef OtherSources
+#define OtherSources
+#endif
+
+#ifndef OtherObjects
+#define OtherObjects
+#endif
+
+#if HasXdmAuth
+XDMAUTHDEFS = -DHASXDMAUTH
+XDMAUTHOBJS = xdmauth.o
+XDMAUTHSRCS = xdmauth.c
+#else
+XDMAUTHDEFS =
+XDMAUTHOBJS =
+XDMAUTHSCRS =
+#endif
+
+#if HasSecureRPC
+RPCDEFS = -DSECURE_RPC
+RPCOBJS = rpcauth.o
+RPCSRCS = rpcauth.c
+#else
+RPCDEFS =
+RPCOBJS =
+RPCSRCS =
+#endif
+
+#if HasKrb5
+KRB5OBJS = k5auth.o k5encode.o
+KRB5SRCS = k5auth.c k5encode.c
+#endif
+
+#if HasBSD44Sockets
+ SOCK_DEFINES = -DBSD44SOCKETS
+#endif
+
+#if HasGetIfAddrs
+ IFADDRS_DEFINES = -DHAS_GETIFADDRS
+#endif
+
+#if BuildLBX
+ LBX_SRCS = lbxio.c
+ LBX_OBJS = lbxio.o
+#else
+ LBX_SRCS =
+ LBX_OBJS =
+#endif
+
+#if !defined(DDXOsColor)
+COLOR_SRCS=oscolor.c
+COLOR_OBJS=oscolor.o
+#endif
+
+#if UseInternalMalloc
+MALLOC_SRCS=xalloc.c
+MALLOC_OBJS=xalloc.o
+#endif
+
+#if !HasSnprintf
+SNPRINTF_SRCS = snprintf.c
+SNPRINTF_OBJS = snprintf.o
+#endif
+
+#if !HasStrlcat
+STRLCAT_SRCS = strlcat.c strlcpy.c
+STRLCAT_OBJS = strlcat.o strlcpy.o
+#endif
+
+#if HasGetpeerucred
+GETPEER_DEFINES = -DHAS_GETPEERUCRED
+#else
+# if HasGetpeereid
+GETPEER_DEFINES = -DHAS_GETPEEREID
+# endif
+#endif
+
+BOOTSTRAPCFLAGS =
+ SRCS = WaitFor.c access.c connection.c io.c $(COLOR_SRCS) \
+ osinit.c utils.c log.c auth.c mitauth.c secauth.c \
+ $(XDMAUTHSRCS) $(RPCSRCS) $(KRB5SRCS) xdmcp.c OtherSources \
+ transport.c $(SNPRINTF_SRCS) $(STRLCAT_SRCS) \
+ $(MALLOC_SRCS) $(LBX_SRCS) xprintf.c
+ OBJS = WaitFor.o access.o connection.o io.o $(COLOR_OBJS) \
+ osinit.o utils.o log.o auth.o mitauth.o secauth.o \
+ $(XDMAUTHOBJS) $(RPCOBJS) $(KRB5OBJS) xdmcp.o OtherObjects \
+ transport.o $(SNPRINTF_OBJS) $(STRLCAT_OBJS) \
+ $(MALLOC_OBJS) $(LBX_OBJS) xprintf.o
+
+#if SpecialMalloc
+ MEM_DEFINES = -DSPECIAL_MALLOC
+#endif /* SpecialMalloc */
+#if UseInternalMalloc
+ MEM_DEFINES = -DINTERNAL_MALLOC
+#endif
+#if UseMemLeak
+ MEM_DEFINES = -DMEMBUG
+#endif
+#if UseRgbTxt
+ RGB_DEFINES = -DUSE_RGB_TXT
+#endif
+ DBM_DEFINES = NdbmDefines
+ ADM_DEFINES = -DADMPATH=\"$(ADMDIR)/X\%smsgs\"
+ XDMCP_DEFINES = ServerXdmcpDefines
+ KRB5_DEFINES = Krb5Defines
+ XALLOC_DEFINES = XallocDefines
+ ERROR_DEFINES = ServerErrorDefines
+#if HasPam && HasPamMisc
+ PAM_DEFINES = -DUSE_PAM
+#endif
+ DEFINES = -DXSERV_t -DTRANS_SERVER $(CONNECTION_FLAGS) $(MEM_DEFINES) \
+ $(XDMAUTHDEFS) $(RPCDEFS) $(SIGNAL_DEFINES) $(OS_DEFINES) \
+ $(KRB5_DEFINES) $(RGB_DEFINES) $(GETPEER_DEFINES) \
+ $(RANDOM_DEFINES) $(BUGMSG) $(XTRANS_FAILDEFINES)
+ INCLUDES = -I. -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) \
+ -I$(SERVERSRC)/Xext -I$(FONTINCSRC) -I$(SERVERSRC)/render \
+ -I$(TOP)/lib/Xau -I../lbx -I../Xprint Krb5Includes
+ DEPEND_DEFINES = $(DBM_DEFINES) $(XDMCP_DEFINES) $(EXT_DEFINES) \
+ $(TRANS_INCLUDES) $(CONNECTION_FLAGS) $(GETPEER_DEFINES) \
+ DependDefines
+ LINTLIBS = ../dix/llib-ldix.ln
+
+#ifdef NEED_ALLOCA_FROM_LIBPW
+ PWLIB = /lib/libPW.a
+#endif /* NEED_ALLOCA_FROM_LIBPW */
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(os,$(OBJS))
+LintLibraryTarget(os,$(SRCS))
+NormalLintTarget($(SRCS))
+
+#ifdef NEED_ALLOCA_FROM_LIBPW
+XCOMM
+XCOMM And this one is to get the version of alloca that lives in /lib/libPW.a
+XCOMM without getting all of the rest of the stuff in there.
+XCOMM
+alloca.o: $(PWLIB)
+ rm -f alloca.o
+ ar x $(PWLIB) alloca.o
+#endif /* NEED_ALLOCA_FROM_LIBPW */
+
+SpecialCObjectRule(access,$(ICONFIGFILES),$(XDMCP_DEFINES) $(SOCK_DEFINES) $(IFADDRS_DEFINES))
+SpecialCObjectRule(auth,$(ICONFIGFILES),$(XDMCP_DEFINES))
+SpecialCObjectRule(xdmauth,$(ICONFIGFILES),$(XDMCP_DEFINES))
+SpecialCObjectRule(xdmcp,$(ICONFIGFILES),$(SOCK_DEFINES) $(XDMCP_DEFINES))
+SpecialCObjectRule(connection,$(ICONFIGFILES),$(SOCK_DEFINES) $(XDMCP_DEFINES))
+SpecialCObjectRule(transport,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES))
+LinkSourceFile(transport.c,$(TRANSCOMMSRC))
+SpecialCObjectRule(osinit,$(ICONFIGFILES),$(ADM_DEFINES))
+SpecialCObjectRule(WaitFor,$(ICONFIGFILES),$(EXT_DEFINES))
+SpecialCObjectRule(io,$(ICONFIGFILES),$(EXT_DEFINES))
+#if BuildLBX
+SpecialCObjectRule(lbxio,$(ICONFIGFILES),$(EXT_DEFINES))
+#endif
+SpecialCObjectRule(utils,$(ICONFIGFILES),$(XDMCP_DEFINES) $(EXT_DEFINES) $(ERROR_DEFINES) $(PAM_DEFINES))
+SpecialCObjectRule(xalloc,$(ICONFIGFILES),$(XALLOC_DEFINES))
+#if defined(SparcArchitecture) && HasGcc && !HasGcc2
+oscolor.o: oscolor.c $(ICONFIGFILES)
+ $(RM) $@
+ cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
+#else
+SpecialCObjectRule(oscolor,$(ICONFIGFILES),$(DBM_DEFINES))
+#endif
+
+#if HasKrb5
+LinkSourceFile(k5encode.c,$(XAUTHSRC))
+#endif
+
+#if !HasSnprintf
+LinkSourceFile(snprintf.c,$(LIBSRC)/misc)
+#endif
+
+#if !HasStrlcat
+LinkSourceFile(strlcat.c,$(LIBSRC)/misc)
+LinkSourceFile(strlcpy.c,$(LIBSRC)/misc)
+#endif
+
+#if DoLoadableServer
+AllTarget(libcwrapper.o)
+ObjectFromSpecialSource(libcwrapper,$(XF86OSSRC)/shared/libc_wrapper,-DSELF_CONTAINED_WRAPPER)
+#endif
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/os/WaitFor.c b/nx-X11/programs/Xserver/os/WaitFor.c
new file mode 100644
index 000000000..b4991d4ed
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/WaitFor.c
@@ -0,0 +1,882 @@
+/* $XFree86: xc/programs/Xserver/os/WaitFor.c,v 3.42 2003/10/16 01:33:35 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* $Xorg: WaitFor.c,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+/*****************************************************************
+ * OS Dependent input routines:
+ *
+ * WaitForSomething
+ * TimerForce, TimerSet, TimerCheck, TimerFree
+ *
+ *****************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#endif
+#include <X11/Xos.h> /* for strings, fcntl, time */
+#include <errno.h>
+#include <stdio.h>
+#include <X11/X.h>
+#include "misc.h"
+
+#ifdef __UNIXOS2__
+#define select(n,r,w,x,t) os2PseudoSelect(n,r,w,x,t)
+#endif
+#include "osdep.h"
+#include <X11/Xpoll.h>
+#include "dixstruct.h"
+#include "opaque.h"
+#ifdef DPMSExtension
+#include "dpmsproc.h"
+#endif
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_WAKEUP)
+
+static unsigned long startTimeInMillis;
+
+#endif
+
+#ifdef WIN32
+/* Error codes from windows sockets differ from fileio error codes */
+#undef EINTR
+#define EINTR WSAEINTR
+#undef EINVAL
+#define EINVAL WSAEINVAL
+#undef EBADF
+#define EBADF WSAENOTSOCK
+/* Windows select does not set errno. Use GetErrno as wrapper for
+ WSAGetLastError */
+#define GetErrno WSAGetLastError
+#else
+/* This is just a fallback to errno to hide the differences between unix and
+ Windows in the code */
+#define GetErrno() errno
+#endif
+
+/* modifications by raphael */
+int
+mffs(fd_mask mask)
+{
+ int i;
+
+ if (!mask) return 0;
+ i = 1;
+ while (!(mask & 1))
+ {
+ i++;
+ mask >>= 1;
+ }
+ return i;
+}
+
+#ifdef DPMSExtension
+#define DPMS_SERVER
+#include <X11/extensions/dpms.h>
+#endif
+
+#ifdef XTESTEXT1
+/*
+ * defined in xtestext1dd.c
+ */
+extern int playback_on;
+#endif /* XTESTEXT1 */
+
+struct _OsTimerRec {
+ OsTimerPtr next;
+ CARD32 expires;
+ OsTimerCallback callback;
+ pointer arg;
+};
+
+static void DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev);
+static OsTimerPtr timers = NULL;
+
+/*****************
+ * WaitForSomething:
+ * Make the server suspend until there is
+ * 1. data from clients or
+ * 2. input events available or
+ * 3. ddx notices something of interest (graphics
+ * queue ready, etc.) or
+ * 4. clients that have buffered replies/events are ready
+ *
+ * If the time between INPUT events is
+ * greater than ScreenSaverTime, the display is turned off (or
+ * saved, depending on the hardware). So, WaitForSomething()
+ * has to handle this also (that's why the select() has a timeout.
+ * For more info on ClientsWithInput, see ReadRequestFromClient().
+ * pClientsReady is an array to store ready client->index values into.
+ *****************/
+
+int
+WaitForSomething(int *pClientsReady)
+{
+ int i;
+ struct timeval waittime, *wt;
+ INT32 timeout = 0;
+ fd_set clientsReadable;
+ fd_set clientsWritable;
+ int curclient;
+ int selecterr;
+ int nready;
+ fd_set devicesReadable;
+ CARD32 now = 0;
+#ifdef SMART_SCHEDULE
+ Bool someReady = FALSE;
+#endif
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: Got called.\n");
+#endif
+
+ FD_ZERO(&clientsReadable);
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_WAKEUP)
+
+ startTimeInMillis = GetTimeInMillis();
+
+#endif
+
+ /* We need a while loop here to handle
+ crashed connections and the screen saver timeout */
+ while (1)
+ {
+ /* deal with any blocked jobs */
+ if (workQueue)
+ ProcessWorkQueue();
+ if (XFD_ANYSET (&ClientsWithInput))
+ {
+#ifdef SMART_SCHEDULE
+ if (!SmartScheduleDisable)
+ {
+ someReady = TRUE;
+ waittime.tv_sec = 0;
+ waittime.tv_usec = 0;
+ wt = &waittime;
+ }
+ else
+#endif
+ {
+ XFD_COPYSET (&ClientsWithInput, &clientsReadable);
+ break;
+ }
+ }
+#ifdef SMART_SCHEDULE
+ if (someReady)
+ {
+ XFD_COPYSET(&AllSockets, &LastSelectMask);
+ XFD_UNSET(&LastSelectMask, &ClientsWithInput);
+ }
+ else
+ {
+#endif
+ wt = NULL;
+ if (timers)
+ {
+ now = GetTimeInMillis();
+ timeout = timers->expires - now;
+ if (timeout < 0)
+ timeout = 0;
+ waittime.tv_sec = timeout / MILLI_PER_SECOND;
+ waittime.tv_usec = (timeout % MILLI_PER_SECOND) *
+ (1000000 / MILLI_PER_SECOND);
+ wt = &waittime;
+ }
+ XFD_COPYSET(&AllSockets, &LastSelectMask);
+#ifdef SMART_SCHEDULE
+ }
+ SmartScheduleIdle = TRUE;
+#endif
+ BlockHandler((pointer)&wt, (pointer)&LastSelectMask);
+ if (NewOutputPending)
+ FlushAllOutput();
+#ifdef XTESTEXT1
+ /* XXX how does this interact with new write block handling? */
+ if (playback_on) {
+ wt = &waittime;
+ XTestComputeWaitTime (&waittime);
+ }
+#endif /* XTESTEXT1 */
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_WAKEUP)
+
+ /*
+ * If caller has marked the first element of pClientsReady[],
+ * bail out of select after a short timeout. We need this to
+ * let the NX agent remove the splash screen when the timeout
+ * is expired. A better option would be to use the existing
+ * screen-saver timeout but it can be modified by clients, so
+ * we would need a special handling. This hack is trivial and
+ * keeps WaitForSomething() backward compatible with the exis-
+ * ting servers.
+ */
+
+ if (pClientsReady[0] == -1)
+ {
+ unsigned long timeoutInMillis;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_WAKEUP) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: pClientsReady[0] is [%d], pClientsReady[1] is [%d].\n",
+ pClientsReady[0], pClientsReady[1]);
+#endif
+
+ timeoutInMillis = GetTimeInMillis();
+
+ if (timeoutInMillis - startTimeInMillis >= NX_TRANS_WAKEUP)
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_WAKEUP) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: Returning 0 because of wakeup timeout.\n");
+#endif
+ return 0;
+ }
+
+ timeoutInMillis = NX_TRANS_WAKEUP - (timeoutInMillis - startTimeInMillis);
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_WAKEUP) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: Milliseconds to next wakeup are %ld.\n",
+ timeoutInMillis);
+#endif
+ if (wt == NULL || (wt -> tv_sec * MILLI_PER_SECOND +
+ wt -> tv_usec / MILLI_PER_SECOND) > timeoutInMillis)
+ {
+ if ((waittime.tv_sec * MILLI_PER_SECOND +
+ waittime.tv_usec / MILLI_PER_SECOND) > timeoutInMillis)
+ {
+ waittime.tv_sec = timeoutInMillis / MILLI_PER_SECOND;
+ waittime.tv_usec = (timeoutInMillis * MILLI_PER_SECOND) %
+ (MILLI_PER_SECOND * 1000);
+ wt = &waittime;
+ }
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_WAKEUP) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: Next wakeup timeout set to %ld milliseconds.\n",
+ (waittime.tv_sec * MILLI_PER_SECOND) +
+ (waittime.tv_usec / MILLI_PER_SECOND));
+#endif
+ }
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_WAKEUP) && defined(NX_TRANS_DEBUG)
+ else
+ {
+ fprintf(stderr, "WaitForSomething: Using existing timeout of %ld milliseconds.\n",
+ (waittime.tv_sec * MILLI_PER_SECOND) +
+ (waittime.tv_usec / MILLI_PER_SECOND));
+ }
+#endif
+ }
+#endif
+
+ /* keep this check close to select() call to minimize race */
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ if (dispatchException)
+ {
+ i = -1;
+
+ fprintf(stderr, "WaitForSomething: Value of dispatchException is true. Set i = -1.\n");
+ }
+#else
+ if (dispatchException)
+ i = -1;
+#endif
+ else if (AnyClientsWriteBlocked)
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ if (wt == NULL)
+ {
+ fprintf(stderr, "WaitForSomething: Executing select with LastSelectMask and "
+ "clientsWritable and null timeout.\n");
+ }
+ else
+ {
+ fprintf(stderr, "WaitForSomething: Executing select with LastSelectMask, "
+ "clientsWritable, %ld secs and %ld usecs.\n",
+ wt -> tv_sec, wt -> tv_usec);
+ }
+#endif
+ XFD_COPYSET(&ClientsWriteBlocked, &clientsWritable);
+ i = Select (MaxClients, &LastSelectMask, &clientsWritable, NULL, wt);
+ }
+ else
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ if (wt == NULL)
+ {
+ fprintf(stderr, "WaitForSomething: Executing select with LastSelectMask and null timeout.\n");
+ }
+ else
+ {
+ fprintf(stderr, "WaitForSomething: Executing select with LastSelectMask, %ld secs and %ld usecs.\n",
+ wt -> tv_sec, wt -> tv_usec);
+ }
+#endif
+ i = Select (MaxClients, &LastSelectMask, NULL, NULL, wt);
+ }
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: Bailed out with i = [%d] and errno = [%d].\n", i, errno);
+
+ if (i < 0)
+ {
+ fprintf(stderr, "WaitForSomething: Error is [%s].\n", strerror(errno));
+ }
+#endif
+ selecterr = GetErrno();
+ WakeupHandler(i, (pointer)&LastSelectMask);
+#ifdef XTESTEXT1
+ if (playback_on) {
+ i = XTestProcessInputAction (i, &waittime);
+ }
+#endif /* XTESTEXT1 */
+#ifdef SMART_SCHEDULE
+ if (i >= 0)
+ {
+ SmartScheduleIdle = FALSE;
+ SmartScheduleIdleCount = 0;
+ if (SmartScheduleTimerStopped)
+ (void) SmartScheduleStartTimer ();
+ }
+#endif
+ if (i <= 0) /* An error or timeout occurred */
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ if (dispatchException)
+ {
+ fprintf(stderr, "WaitForSomething: Returning 0 because of (dispatchException).\n");
+ return 0;
+ }
+#else
+ if (dispatchException)
+ return 0;
+#endif
+ if (i < 0)
+ {
+ if (selecterr == EBADF) /* Some client disconnected */
+ {
+ CheckConnections ();
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ if (! XFD_ANYSET (&AllClients))
+ {
+ fprintf(stderr, "WaitForSomething: Returning 0 because of (! XFD_ANYSET (&AllClients)).\n");
+ return 0;
+ }
+#else
+ if (! XFD_ANYSET (&AllClients))
+ return 0;
+#endif
+ }
+ else if (selecterr == EINVAL)
+ {
+ FatalError("WaitForSomething(): select: errno=%d\n",
+ selecterr);
+ }
+ else if (selecterr != EINTR)
+ {
+ ErrorF("WaitForSomething(): select: errno=%d\n",
+ selecterr);
+ }
+ }
+#ifdef SMART_SCHEDULE
+ else if (someReady)
+ {
+ /*
+ * If no-one else is home, bail quickly
+ */
+ XFD_COPYSET(&ClientsWithInput, &LastSelectMask);
+ XFD_COPYSET(&ClientsWithInput, &clientsReadable);
+ break;
+ }
+#endif
+#if defined(NX_TRANS_SOCKET)
+ if (*checkForInput[0] != *checkForInput[1])
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: Returning 0 because of (*checkForInput[0] != *checkForInput[1]).\n");
+#endif
+ return 0;
+ }
+#else
+ if (*checkForInput[0] != *checkForInput[1])
+ return 0;
+#endif
+
+ if (timers)
+ {
+ int expired = 0;
+ now = GetTimeInMillis();
+ if ((int) (timers->expires - now) <= 0)
+ expired = 1;
+
+ while (timers && (int) (timers->expires - now) <= 0)
+ DoTimer(timers, now, &timers);
+
+ if (expired)
+ return 0;
+ }
+ }
+ else
+ {
+ fd_set tmp_set;
+
+ if (*checkForInput[0] == *checkForInput[1]) {
+ if (timers)
+ {
+ int expired = 0;
+ now = GetTimeInMillis();
+ if ((int) (timers->expires - now) <= 0)
+ expired = 1;
+
+ while (timers && (int) (timers->expires - now) <= 0)
+ DoTimer(timers, now, &timers);
+
+ if (expired)
+ return 0;
+ }
+ }
+#ifdef SMART_SCHEDULE
+ if (someReady)
+ XFD_ORSET(&LastSelectMask, &ClientsWithInput, &LastSelectMask);
+#endif
+ if (AnyClientsWriteBlocked && XFD_ANYSET (&clientsWritable))
+ {
+ NewOutputPending = TRUE;
+ XFD_ORSET(&OutputPending, &clientsWritable, &OutputPending);
+ XFD_UNSET(&ClientsWriteBlocked, &clientsWritable);
+ if (! XFD_ANYSET(&ClientsWriteBlocked))
+ AnyClientsWriteBlocked = FALSE;
+ }
+
+ XFD_ANDSET(&devicesReadable, &LastSelectMask, &EnabledDevices);
+ XFD_ANDSET(&clientsReadable, &LastSelectMask, &AllClients);
+ XFD_ANDSET(&tmp_set, &LastSelectMask, &WellKnownConnections);
+ if (XFD_ANYSET(&tmp_set))
+ QueueWorkProc(EstablishNewConnections, NULL,
+ (pointer)&LastSelectMask);
+#ifdef DPMSExtension
+ if (XFD_ANYSET (&devicesReadable) && (DPMSPowerLevel != DPMSModeOn))
+ DPMSSet(DPMSModeOn);
+#endif
+ if (XFD_ANYSET (&devicesReadable) || XFD_ANYSET (&clientsReadable))
+ break;
+#ifdef WIN32
+ /* Windows keyboard and mouse events are added to the input queue
+ in Block- and WakupHandlers. There is no device to check if
+ data is ready. So check here if new input is available */
+#if defined(NX_TRANS_SOCKET)
+ if (*checkForInput[0] != *checkForInput[1])
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: Returning 0 because of (*checkForInput[0] != *checkForInput[1]).\n");
+#endif
+ return 0;
+ }
+#else
+ if (*checkForInput[0] != *checkForInput[1])
+ return 0;
+#endif
+#endif
+ }
+ }
+
+ nready = 0;
+ if (XFD_ANYSET (&clientsReadable))
+ {
+#ifndef WIN32
+ for (i=0; i<howmany(XFD_SETSIZE, NFDBITS); i++)
+ {
+ int highest_priority = 0;
+
+ while (clientsReadable.fds_bits[i])
+ {
+ int client_priority, client_index;
+
+ curclient = ffs (clientsReadable.fds_bits[i]) - 1;
+ client_index = /* raphael: modified */
+ ConnectionTranslation[curclient + (i * (sizeof(fd_mask) * 8))];
+#else
+ int highest_priority = 0;
+ fd_set savedClientsReadable;
+ XFD_COPYSET(&clientsReadable, &savedClientsReadable);
+ for (i = 0; i < XFD_SETCOUNT(&savedClientsReadable); i++)
+ {
+ int client_priority, client_index;
+
+ curclient = XFD_FD(&savedClientsReadable, i);
+ client_index = GetConnectionTranslation(curclient);
+#endif
+#ifdef XSYNC
+ /* We implement "strict" priorities.
+ * Only the highest priority client is returned to
+ * dix. If multiple clients at the same priority are
+ * ready, they are all returned. This means that an
+ * aggressive client could take over the server.
+ * This was not considered a big problem because
+ * aggressive clients can hose the server in so many
+ * other ways :)
+ */
+ client_priority = clients[client_index]->priority;
+ if (nready == 0 || client_priority > highest_priority)
+ {
+ /* Either we found the first client, or we found
+ * a client whose priority is greater than all others
+ * that have been found so far. Either way, we want
+ * to initialize the list of clients to contain just
+ * this client.
+ */
+ pClientsReady[0] = client_index;
+ highest_priority = client_priority;
+ nready = 1;
+ }
+ /* the following if makes sure that multiple same-priority
+ * clients get batched together
+ */
+ else if (client_priority == highest_priority)
+#endif
+ {
+ pClientsReady[nready++] = client_index;
+ }
+#ifndef WIN32
+ clientsReadable.fds_bits[i] &= ~(((fd_mask)1L) << curclient);
+ }
+#else
+ FD_CLR(curclient, &clientsReadable);
+#endif
+ }
+ }
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: Returning nready.\n");
+#endif
+ return nready;
+}
+
+#if 0
+/*
+ * This is not always a macro.
+ */
+ANYSET(FdMask *src)
+{
+ int i;
+
+ for (i=0; i<mskcnt; i++)
+ if (src[ i ])
+ return (TRUE);
+ return (FALSE);
+}
+#endif
+
+
+static void
+DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev)
+{
+ CARD32 newTime;
+
+ *prev = timer->next;
+ timer->next = NULL;
+ newTime = (*timer->callback)(timer, now, timer->arg);
+ if (newTime)
+ TimerSet(timer, 0, newTime, timer->callback, timer->arg);
+}
+
+OsTimerPtr
+TimerSet(OsTimerPtr timer, int flags, CARD32 millis,
+ OsTimerCallback func, pointer arg)
+{
+ register OsTimerPtr *prev;
+ CARD32 now = GetTimeInMillis();
+
+ if (!timer)
+ {
+ timer = (OsTimerPtr)xalloc(sizeof(struct _OsTimerRec));
+ if (!timer)
+ return NULL;
+ }
+ else
+ {
+ for (prev = &timers; *prev; prev = &(*prev)->next)
+ {
+ if (*prev == timer)
+ {
+ *prev = timer->next;
+ if (flags & TimerForceOld)
+ (void)(*timer->callback)(timer, now, timer->arg);
+ break;
+ }
+ }
+ }
+ if (!millis)
+ return timer;
+ if (!(flags & TimerAbsolute))
+ millis += now;
+ timer->expires = millis;
+ timer->callback = func;
+ timer->arg = arg;
+ if ((int) (millis - now) <= 0)
+ {
+ timer->next = NULL;
+ millis = (*timer->callback)(timer, now, timer->arg);
+ if (!millis)
+ return timer;
+ }
+ for (prev = &timers;
+ *prev && (int) ((*prev)->expires - millis) <= 0;
+ prev = &(*prev)->next)
+ ;
+ timer->next = *prev;
+ *prev = timer;
+ return timer;
+}
+
+Bool
+TimerForce(OsTimerPtr timer)
+{
+ OsTimerPtr *prev;
+
+ for (prev = &timers; *prev; prev = &(*prev)->next)
+ {
+ if (*prev == timer)
+ {
+ DoTimer(timer, GetTimeInMillis(), prev);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+void
+TimerCancel(OsTimerPtr timer)
+{
+ OsTimerPtr *prev;
+
+ if (!timer)
+ return;
+ for (prev = &timers; *prev; prev = &(*prev)->next)
+ {
+ if (*prev == timer)
+ {
+ *prev = timer->next;
+ break;
+ }
+ }
+}
+
+void
+TimerFree(OsTimerPtr timer)
+{
+ if (!timer)
+ return;
+ TimerCancel(timer);
+ xfree(timer);
+}
+
+void
+TimerCheck(void)
+{
+ CARD32 now = GetTimeInMillis();
+
+ while (timers && (int) (timers->expires - now) <= 0)
+ DoTimer(timers, now, &timers);
+}
+
+void
+TimerInit(void)
+{
+ OsTimerPtr timer;
+
+ while ((timer = timers))
+ {
+ timers = timer->next;
+ xfree(timer);
+ }
+}
+
+static CARD32
+ScreenSaverTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+ INT32 timeout = now - lastDeviceEventTime.milliseconds;
+
+ if (timeout < ScreenSaverTime) {
+ return ScreenSaverTime - timeout;
+ }
+
+ ResetOsBuffers(); /* not ideal, but better than nothing */
+ SaveScreens(SCREEN_SAVER_ON, ScreenSaverActive);
+
+#ifdef DPMSExtension
+ if (ScreenSaverInterval > 0 && DPMSPowerLevel == DPMSModeOn)
+#else
+ if (ScreenSaverInterval > 0)
+#endif /* DPMSExtension */
+ return ScreenSaverInterval;
+
+ return 0;
+}
+
+static OsTimerPtr ScreenSaverTimer = NULL;
+
+void
+FreeScreenSaverTimer(void)
+{
+ if (ScreenSaverTimer) {
+ TimerFree(ScreenSaverTimer);
+ ScreenSaverTimer = NULL;
+ }
+}
+
+void
+SetScreenSaverTimer(void)
+{
+ if (ScreenSaverTime > 0) {
+ ScreenSaverTimer = TimerSet(ScreenSaverTimer, 0, ScreenSaverTime,
+ ScreenSaverTimeoutExpire, NULL);
+ } else if (ScreenSaverTimer) {
+ FreeScreenSaverTimer();
+ }
+}
+
+#ifdef DPMSExtension
+
+static OsTimerPtr DPMSStandbyTimer = NULL;
+static OsTimerPtr DPMSSuspendTimer = NULL;
+static OsTimerPtr DPMSOffTimer = NULL;
+
+static CARD32
+DPMSStandbyTimerExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+ INT32 timeout = now - lastDeviceEventTime.milliseconds;
+
+ if (timeout < DPMSStandbyTime) {
+ return DPMSStandbyTime - timeout;
+ }
+ if (DPMSPowerLevel < DPMSModeStandby) {
+ if (DPMSEnabled)
+ DPMSSet(DPMSModeStandby);
+ }
+ return DPMSStandbyTime;
+}
+
+static CARD32
+DPMSSuspendTimerExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+ INT32 timeout = now - lastDeviceEventTime.milliseconds;
+
+ if (timeout < DPMSSuspendTime) {
+ return DPMSSuspendTime - timeout;
+ }
+ if (DPMSPowerLevel < DPMSModeSuspend) {
+ if (DPMSEnabled)
+ DPMSSet(DPMSModeSuspend);
+ }
+ return DPMSSuspendTime;
+}
+
+static CARD32
+DPMSOffTimerExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+ INT32 timeout = now - lastDeviceEventTime.milliseconds;
+
+ if (timeout < DPMSOffTime) {
+ return DPMSOffTime - timeout;
+ }
+ if (DPMSPowerLevel < DPMSModeOff) {
+ if (DPMSEnabled)
+ DPMSSet(DPMSModeOff);
+ }
+ return DPMSOffTime;
+}
+
+void
+FreeDPMSTimers(void)
+{
+ if (DPMSStandbyTimer) {
+ TimerFree(DPMSStandbyTimer);
+ DPMSStandbyTimer = NULL;
+ }
+ if (DPMSSuspendTimer) {
+ TimerFree(DPMSSuspendTimer);
+ DPMSSuspendTimer = NULL;
+ }
+ if (DPMSOffTimer) {
+ TimerFree(DPMSOffTimer);
+ DPMSOffTimer = NULL;
+ }
+}
+
+void
+SetDPMSTimers(void)
+{
+ if (!DPMSEnabled)
+ return;
+
+ DPMSStandbyTimer = TimerSet(DPMSStandbyTimer, 0, DPMSStandbyTime,
+ DPMSStandbyTimerExpire, NULL);
+ DPMSSuspendTimer = TimerSet(DPMSSuspendTimer, 0, DPMSSuspendTime,
+ DPMSSuspendTimerExpire, NULL);
+ DPMSOffTimer = TimerSet(DPMSOffTimer, 0, DPMSOffTime,
+ DPMSOffTimerExpire, NULL);
+}
+#endif
diff --git a/nx-X11/programs/Xserver/os/WaitFor.c.NX.original b/nx-X11/programs/Xserver/os/WaitFor.c.NX.original
new file mode 100644
index 000000000..b4991d4ed
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/WaitFor.c.NX.original
@@ -0,0 +1,882 @@
+/* $XFree86: xc/programs/Xserver/os/WaitFor.c,v 3.42 2003/10/16 01:33:35 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* $Xorg: WaitFor.c,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+/*****************************************************************
+ * OS Dependent input routines:
+ *
+ * WaitForSomething
+ * TimerForce, TimerSet, TimerCheck, TimerFree
+ *
+ *****************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#endif
+#include <X11/Xos.h> /* for strings, fcntl, time */
+#include <errno.h>
+#include <stdio.h>
+#include <X11/X.h>
+#include "misc.h"
+
+#ifdef __UNIXOS2__
+#define select(n,r,w,x,t) os2PseudoSelect(n,r,w,x,t)
+#endif
+#include "osdep.h"
+#include <X11/Xpoll.h>
+#include "dixstruct.h"
+#include "opaque.h"
+#ifdef DPMSExtension
+#include "dpmsproc.h"
+#endif
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_WAKEUP)
+
+static unsigned long startTimeInMillis;
+
+#endif
+
+#ifdef WIN32
+/* Error codes from windows sockets differ from fileio error codes */
+#undef EINTR
+#define EINTR WSAEINTR
+#undef EINVAL
+#define EINVAL WSAEINVAL
+#undef EBADF
+#define EBADF WSAENOTSOCK
+/* Windows select does not set errno. Use GetErrno as wrapper for
+ WSAGetLastError */
+#define GetErrno WSAGetLastError
+#else
+/* This is just a fallback to errno to hide the differences between unix and
+ Windows in the code */
+#define GetErrno() errno
+#endif
+
+/* modifications by raphael */
+int
+mffs(fd_mask mask)
+{
+ int i;
+
+ if (!mask) return 0;
+ i = 1;
+ while (!(mask & 1))
+ {
+ i++;
+ mask >>= 1;
+ }
+ return i;
+}
+
+#ifdef DPMSExtension
+#define DPMS_SERVER
+#include <X11/extensions/dpms.h>
+#endif
+
+#ifdef XTESTEXT1
+/*
+ * defined in xtestext1dd.c
+ */
+extern int playback_on;
+#endif /* XTESTEXT1 */
+
+struct _OsTimerRec {
+ OsTimerPtr next;
+ CARD32 expires;
+ OsTimerCallback callback;
+ pointer arg;
+};
+
+static void DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev);
+static OsTimerPtr timers = NULL;
+
+/*****************
+ * WaitForSomething:
+ * Make the server suspend until there is
+ * 1. data from clients or
+ * 2. input events available or
+ * 3. ddx notices something of interest (graphics
+ * queue ready, etc.) or
+ * 4. clients that have buffered replies/events are ready
+ *
+ * If the time between INPUT events is
+ * greater than ScreenSaverTime, the display is turned off (or
+ * saved, depending on the hardware). So, WaitForSomething()
+ * has to handle this also (that's why the select() has a timeout.
+ * For more info on ClientsWithInput, see ReadRequestFromClient().
+ * pClientsReady is an array to store ready client->index values into.
+ *****************/
+
+int
+WaitForSomething(int *pClientsReady)
+{
+ int i;
+ struct timeval waittime, *wt;
+ INT32 timeout = 0;
+ fd_set clientsReadable;
+ fd_set clientsWritable;
+ int curclient;
+ int selecterr;
+ int nready;
+ fd_set devicesReadable;
+ CARD32 now = 0;
+#ifdef SMART_SCHEDULE
+ Bool someReady = FALSE;
+#endif
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: Got called.\n");
+#endif
+
+ FD_ZERO(&clientsReadable);
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_WAKEUP)
+
+ startTimeInMillis = GetTimeInMillis();
+
+#endif
+
+ /* We need a while loop here to handle
+ crashed connections and the screen saver timeout */
+ while (1)
+ {
+ /* deal with any blocked jobs */
+ if (workQueue)
+ ProcessWorkQueue();
+ if (XFD_ANYSET (&ClientsWithInput))
+ {
+#ifdef SMART_SCHEDULE
+ if (!SmartScheduleDisable)
+ {
+ someReady = TRUE;
+ waittime.tv_sec = 0;
+ waittime.tv_usec = 0;
+ wt = &waittime;
+ }
+ else
+#endif
+ {
+ XFD_COPYSET (&ClientsWithInput, &clientsReadable);
+ break;
+ }
+ }
+#ifdef SMART_SCHEDULE
+ if (someReady)
+ {
+ XFD_COPYSET(&AllSockets, &LastSelectMask);
+ XFD_UNSET(&LastSelectMask, &ClientsWithInput);
+ }
+ else
+ {
+#endif
+ wt = NULL;
+ if (timers)
+ {
+ now = GetTimeInMillis();
+ timeout = timers->expires - now;
+ if (timeout < 0)
+ timeout = 0;
+ waittime.tv_sec = timeout / MILLI_PER_SECOND;
+ waittime.tv_usec = (timeout % MILLI_PER_SECOND) *
+ (1000000 / MILLI_PER_SECOND);
+ wt = &waittime;
+ }
+ XFD_COPYSET(&AllSockets, &LastSelectMask);
+#ifdef SMART_SCHEDULE
+ }
+ SmartScheduleIdle = TRUE;
+#endif
+ BlockHandler((pointer)&wt, (pointer)&LastSelectMask);
+ if (NewOutputPending)
+ FlushAllOutput();
+#ifdef XTESTEXT1
+ /* XXX how does this interact with new write block handling? */
+ if (playback_on) {
+ wt = &waittime;
+ XTestComputeWaitTime (&waittime);
+ }
+#endif /* XTESTEXT1 */
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_WAKEUP)
+
+ /*
+ * If caller has marked the first element of pClientsReady[],
+ * bail out of select after a short timeout. We need this to
+ * let the NX agent remove the splash screen when the timeout
+ * is expired. A better option would be to use the existing
+ * screen-saver timeout but it can be modified by clients, so
+ * we would need a special handling. This hack is trivial and
+ * keeps WaitForSomething() backward compatible with the exis-
+ * ting servers.
+ */
+
+ if (pClientsReady[0] == -1)
+ {
+ unsigned long timeoutInMillis;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_WAKEUP) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: pClientsReady[0] is [%d], pClientsReady[1] is [%d].\n",
+ pClientsReady[0], pClientsReady[1]);
+#endif
+
+ timeoutInMillis = GetTimeInMillis();
+
+ if (timeoutInMillis - startTimeInMillis >= NX_TRANS_WAKEUP)
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_WAKEUP) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: Returning 0 because of wakeup timeout.\n");
+#endif
+ return 0;
+ }
+
+ timeoutInMillis = NX_TRANS_WAKEUP - (timeoutInMillis - startTimeInMillis);
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_WAKEUP) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: Milliseconds to next wakeup are %ld.\n",
+ timeoutInMillis);
+#endif
+ if (wt == NULL || (wt -> tv_sec * MILLI_PER_SECOND +
+ wt -> tv_usec / MILLI_PER_SECOND) > timeoutInMillis)
+ {
+ if ((waittime.tv_sec * MILLI_PER_SECOND +
+ waittime.tv_usec / MILLI_PER_SECOND) > timeoutInMillis)
+ {
+ waittime.tv_sec = timeoutInMillis / MILLI_PER_SECOND;
+ waittime.tv_usec = (timeoutInMillis * MILLI_PER_SECOND) %
+ (MILLI_PER_SECOND * 1000);
+ wt = &waittime;
+ }
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_WAKEUP) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: Next wakeup timeout set to %ld milliseconds.\n",
+ (waittime.tv_sec * MILLI_PER_SECOND) +
+ (waittime.tv_usec / MILLI_PER_SECOND));
+#endif
+ }
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_WAKEUP) && defined(NX_TRANS_DEBUG)
+ else
+ {
+ fprintf(stderr, "WaitForSomething: Using existing timeout of %ld milliseconds.\n",
+ (waittime.tv_sec * MILLI_PER_SECOND) +
+ (waittime.tv_usec / MILLI_PER_SECOND));
+ }
+#endif
+ }
+#endif
+
+ /* keep this check close to select() call to minimize race */
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ if (dispatchException)
+ {
+ i = -1;
+
+ fprintf(stderr, "WaitForSomething: Value of dispatchException is true. Set i = -1.\n");
+ }
+#else
+ if (dispatchException)
+ i = -1;
+#endif
+ else if (AnyClientsWriteBlocked)
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ if (wt == NULL)
+ {
+ fprintf(stderr, "WaitForSomething: Executing select with LastSelectMask and "
+ "clientsWritable and null timeout.\n");
+ }
+ else
+ {
+ fprintf(stderr, "WaitForSomething: Executing select with LastSelectMask, "
+ "clientsWritable, %ld secs and %ld usecs.\n",
+ wt -> tv_sec, wt -> tv_usec);
+ }
+#endif
+ XFD_COPYSET(&ClientsWriteBlocked, &clientsWritable);
+ i = Select (MaxClients, &LastSelectMask, &clientsWritable, NULL, wt);
+ }
+ else
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ if (wt == NULL)
+ {
+ fprintf(stderr, "WaitForSomething: Executing select with LastSelectMask and null timeout.\n");
+ }
+ else
+ {
+ fprintf(stderr, "WaitForSomething: Executing select with LastSelectMask, %ld secs and %ld usecs.\n",
+ wt -> tv_sec, wt -> tv_usec);
+ }
+#endif
+ i = Select (MaxClients, &LastSelectMask, NULL, NULL, wt);
+ }
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: Bailed out with i = [%d] and errno = [%d].\n", i, errno);
+
+ if (i < 0)
+ {
+ fprintf(stderr, "WaitForSomething: Error is [%s].\n", strerror(errno));
+ }
+#endif
+ selecterr = GetErrno();
+ WakeupHandler(i, (pointer)&LastSelectMask);
+#ifdef XTESTEXT1
+ if (playback_on) {
+ i = XTestProcessInputAction (i, &waittime);
+ }
+#endif /* XTESTEXT1 */
+#ifdef SMART_SCHEDULE
+ if (i >= 0)
+ {
+ SmartScheduleIdle = FALSE;
+ SmartScheduleIdleCount = 0;
+ if (SmartScheduleTimerStopped)
+ (void) SmartScheduleStartTimer ();
+ }
+#endif
+ if (i <= 0) /* An error or timeout occurred */
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ if (dispatchException)
+ {
+ fprintf(stderr, "WaitForSomething: Returning 0 because of (dispatchException).\n");
+ return 0;
+ }
+#else
+ if (dispatchException)
+ return 0;
+#endif
+ if (i < 0)
+ {
+ if (selecterr == EBADF) /* Some client disconnected */
+ {
+ CheckConnections ();
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ if (! XFD_ANYSET (&AllClients))
+ {
+ fprintf(stderr, "WaitForSomething: Returning 0 because of (! XFD_ANYSET (&AllClients)).\n");
+ return 0;
+ }
+#else
+ if (! XFD_ANYSET (&AllClients))
+ return 0;
+#endif
+ }
+ else if (selecterr == EINVAL)
+ {
+ FatalError("WaitForSomething(): select: errno=%d\n",
+ selecterr);
+ }
+ else if (selecterr != EINTR)
+ {
+ ErrorF("WaitForSomething(): select: errno=%d\n",
+ selecterr);
+ }
+ }
+#ifdef SMART_SCHEDULE
+ else if (someReady)
+ {
+ /*
+ * If no-one else is home, bail quickly
+ */
+ XFD_COPYSET(&ClientsWithInput, &LastSelectMask);
+ XFD_COPYSET(&ClientsWithInput, &clientsReadable);
+ break;
+ }
+#endif
+#if defined(NX_TRANS_SOCKET)
+ if (*checkForInput[0] != *checkForInput[1])
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: Returning 0 because of (*checkForInput[0] != *checkForInput[1]).\n");
+#endif
+ return 0;
+ }
+#else
+ if (*checkForInput[0] != *checkForInput[1])
+ return 0;
+#endif
+
+ if (timers)
+ {
+ int expired = 0;
+ now = GetTimeInMillis();
+ if ((int) (timers->expires - now) <= 0)
+ expired = 1;
+
+ while (timers && (int) (timers->expires - now) <= 0)
+ DoTimer(timers, now, &timers);
+
+ if (expired)
+ return 0;
+ }
+ }
+ else
+ {
+ fd_set tmp_set;
+
+ if (*checkForInput[0] == *checkForInput[1]) {
+ if (timers)
+ {
+ int expired = 0;
+ now = GetTimeInMillis();
+ if ((int) (timers->expires - now) <= 0)
+ expired = 1;
+
+ while (timers && (int) (timers->expires - now) <= 0)
+ DoTimer(timers, now, &timers);
+
+ if (expired)
+ return 0;
+ }
+ }
+#ifdef SMART_SCHEDULE
+ if (someReady)
+ XFD_ORSET(&LastSelectMask, &ClientsWithInput, &LastSelectMask);
+#endif
+ if (AnyClientsWriteBlocked && XFD_ANYSET (&clientsWritable))
+ {
+ NewOutputPending = TRUE;
+ XFD_ORSET(&OutputPending, &clientsWritable, &OutputPending);
+ XFD_UNSET(&ClientsWriteBlocked, &clientsWritable);
+ if (! XFD_ANYSET(&ClientsWriteBlocked))
+ AnyClientsWriteBlocked = FALSE;
+ }
+
+ XFD_ANDSET(&devicesReadable, &LastSelectMask, &EnabledDevices);
+ XFD_ANDSET(&clientsReadable, &LastSelectMask, &AllClients);
+ XFD_ANDSET(&tmp_set, &LastSelectMask, &WellKnownConnections);
+ if (XFD_ANYSET(&tmp_set))
+ QueueWorkProc(EstablishNewConnections, NULL,
+ (pointer)&LastSelectMask);
+#ifdef DPMSExtension
+ if (XFD_ANYSET (&devicesReadable) && (DPMSPowerLevel != DPMSModeOn))
+ DPMSSet(DPMSModeOn);
+#endif
+ if (XFD_ANYSET (&devicesReadable) || XFD_ANYSET (&clientsReadable))
+ break;
+#ifdef WIN32
+ /* Windows keyboard and mouse events are added to the input queue
+ in Block- and WakupHandlers. There is no device to check if
+ data is ready. So check here if new input is available */
+#if defined(NX_TRANS_SOCKET)
+ if (*checkForInput[0] != *checkForInput[1])
+ {
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: Returning 0 because of (*checkForInput[0] != *checkForInput[1]).\n");
+#endif
+ return 0;
+ }
+#else
+ if (*checkForInput[0] != *checkForInput[1])
+ return 0;
+#endif
+#endif
+ }
+ }
+
+ nready = 0;
+ if (XFD_ANYSET (&clientsReadable))
+ {
+#ifndef WIN32
+ for (i=0; i<howmany(XFD_SETSIZE, NFDBITS); i++)
+ {
+ int highest_priority = 0;
+
+ while (clientsReadable.fds_bits[i])
+ {
+ int client_priority, client_index;
+
+ curclient = ffs (clientsReadable.fds_bits[i]) - 1;
+ client_index = /* raphael: modified */
+ ConnectionTranslation[curclient + (i * (sizeof(fd_mask) * 8))];
+#else
+ int highest_priority = 0;
+ fd_set savedClientsReadable;
+ XFD_COPYSET(&clientsReadable, &savedClientsReadable);
+ for (i = 0; i < XFD_SETCOUNT(&savedClientsReadable); i++)
+ {
+ int client_priority, client_index;
+
+ curclient = XFD_FD(&savedClientsReadable, i);
+ client_index = GetConnectionTranslation(curclient);
+#endif
+#ifdef XSYNC
+ /* We implement "strict" priorities.
+ * Only the highest priority client is returned to
+ * dix. If multiple clients at the same priority are
+ * ready, they are all returned. This means that an
+ * aggressive client could take over the server.
+ * This was not considered a big problem because
+ * aggressive clients can hose the server in so many
+ * other ways :)
+ */
+ client_priority = clients[client_index]->priority;
+ if (nready == 0 || client_priority > highest_priority)
+ {
+ /* Either we found the first client, or we found
+ * a client whose priority is greater than all others
+ * that have been found so far. Either way, we want
+ * to initialize the list of clients to contain just
+ * this client.
+ */
+ pClientsReady[0] = client_index;
+ highest_priority = client_priority;
+ nready = 1;
+ }
+ /* the following if makes sure that multiple same-priority
+ * clients get batched together
+ */
+ else if (client_priority == highest_priority)
+#endif
+ {
+ pClientsReady[nready++] = client_index;
+ }
+#ifndef WIN32
+ clientsReadable.fds_bits[i] &= ~(((fd_mask)1L) << curclient);
+ }
+#else
+ FD_CLR(curclient, &clientsReadable);
+#endif
+ }
+ }
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
+ fprintf(stderr, "WaitForSomething: Returning nready.\n");
+#endif
+ return nready;
+}
+
+#if 0
+/*
+ * This is not always a macro.
+ */
+ANYSET(FdMask *src)
+{
+ int i;
+
+ for (i=0; i<mskcnt; i++)
+ if (src[ i ])
+ return (TRUE);
+ return (FALSE);
+}
+#endif
+
+
+static void
+DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev)
+{
+ CARD32 newTime;
+
+ *prev = timer->next;
+ timer->next = NULL;
+ newTime = (*timer->callback)(timer, now, timer->arg);
+ if (newTime)
+ TimerSet(timer, 0, newTime, timer->callback, timer->arg);
+}
+
+OsTimerPtr
+TimerSet(OsTimerPtr timer, int flags, CARD32 millis,
+ OsTimerCallback func, pointer arg)
+{
+ register OsTimerPtr *prev;
+ CARD32 now = GetTimeInMillis();
+
+ if (!timer)
+ {
+ timer = (OsTimerPtr)xalloc(sizeof(struct _OsTimerRec));
+ if (!timer)
+ return NULL;
+ }
+ else
+ {
+ for (prev = &timers; *prev; prev = &(*prev)->next)
+ {
+ if (*prev == timer)
+ {
+ *prev = timer->next;
+ if (flags & TimerForceOld)
+ (void)(*timer->callback)(timer, now, timer->arg);
+ break;
+ }
+ }
+ }
+ if (!millis)
+ return timer;
+ if (!(flags & TimerAbsolute))
+ millis += now;
+ timer->expires = millis;
+ timer->callback = func;
+ timer->arg = arg;
+ if ((int) (millis - now) <= 0)
+ {
+ timer->next = NULL;
+ millis = (*timer->callback)(timer, now, timer->arg);
+ if (!millis)
+ return timer;
+ }
+ for (prev = &timers;
+ *prev && (int) ((*prev)->expires - millis) <= 0;
+ prev = &(*prev)->next)
+ ;
+ timer->next = *prev;
+ *prev = timer;
+ return timer;
+}
+
+Bool
+TimerForce(OsTimerPtr timer)
+{
+ OsTimerPtr *prev;
+
+ for (prev = &timers; *prev; prev = &(*prev)->next)
+ {
+ if (*prev == timer)
+ {
+ DoTimer(timer, GetTimeInMillis(), prev);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+void
+TimerCancel(OsTimerPtr timer)
+{
+ OsTimerPtr *prev;
+
+ if (!timer)
+ return;
+ for (prev = &timers; *prev; prev = &(*prev)->next)
+ {
+ if (*prev == timer)
+ {
+ *prev = timer->next;
+ break;
+ }
+ }
+}
+
+void
+TimerFree(OsTimerPtr timer)
+{
+ if (!timer)
+ return;
+ TimerCancel(timer);
+ xfree(timer);
+}
+
+void
+TimerCheck(void)
+{
+ CARD32 now = GetTimeInMillis();
+
+ while (timers && (int) (timers->expires - now) <= 0)
+ DoTimer(timers, now, &timers);
+}
+
+void
+TimerInit(void)
+{
+ OsTimerPtr timer;
+
+ while ((timer = timers))
+ {
+ timers = timer->next;
+ xfree(timer);
+ }
+}
+
+static CARD32
+ScreenSaverTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+ INT32 timeout = now - lastDeviceEventTime.milliseconds;
+
+ if (timeout < ScreenSaverTime) {
+ return ScreenSaverTime - timeout;
+ }
+
+ ResetOsBuffers(); /* not ideal, but better than nothing */
+ SaveScreens(SCREEN_SAVER_ON, ScreenSaverActive);
+
+#ifdef DPMSExtension
+ if (ScreenSaverInterval > 0 && DPMSPowerLevel == DPMSModeOn)
+#else
+ if (ScreenSaverInterval > 0)
+#endif /* DPMSExtension */
+ return ScreenSaverInterval;
+
+ return 0;
+}
+
+static OsTimerPtr ScreenSaverTimer = NULL;
+
+void
+FreeScreenSaverTimer(void)
+{
+ if (ScreenSaverTimer) {
+ TimerFree(ScreenSaverTimer);
+ ScreenSaverTimer = NULL;
+ }
+}
+
+void
+SetScreenSaverTimer(void)
+{
+ if (ScreenSaverTime > 0) {
+ ScreenSaverTimer = TimerSet(ScreenSaverTimer, 0, ScreenSaverTime,
+ ScreenSaverTimeoutExpire, NULL);
+ } else if (ScreenSaverTimer) {
+ FreeScreenSaverTimer();
+ }
+}
+
+#ifdef DPMSExtension
+
+static OsTimerPtr DPMSStandbyTimer = NULL;
+static OsTimerPtr DPMSSuspendTimer = NULL;
+static OsTimerPtr DPMSOffTimer = NULL;
+
+static CARD32
+DPMSStandbyTimerExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+ INT32 timeout = now - lastDeviceEventTime.milliseconds;
+
+ if (timeout < DPMSStandbyTime) {
+ return DPMSStandbyTime - timeout;
+ }
+ if (DPMSPowerLevel < DPMSModeStandby) {
+ if (DPMSEnabled)
+ DPMSSet(DPMSModeStandby);
+ }
+ return DPMSStandbyTime;
+}
+
+static CARD32
+DPMSSuspendTimerExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+ INT32 timeout = now - lastDeviceEventTime.milliseconds;
+
+ if (timeout < DPMSSuspendTime) {
+ return DPMSSuspendTime - timeout;
+ }
+ if (DPMSPowerLevel < DPMSModeSuspend) {
+ if (DPMSEnabled)
+ DPMSSet(DPMSModeSuspend);
+ }
+ return DPMSSuspendTime;
+}
+
+static CARD32
+DPMSOffTimerExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+ INT32 timeout = now - lastDeviceEventTime.milliseconds;
+
+ if (timeout < DPMSOffTime) {
+ return DPMSOffTime - timeout;
+ }
+ if (DPMSPowerLevel < DPMSModeOff) {
+ if (DPMSEnabled)
+ DPMSSet(DPMSModeOff);
+ }
+ return DPMSOffTime;
+}
+
+void
+FreeDPMSTimers(void)
+{
+ if (DPMSStandbyTimer) {
+ TimerFree(DPMSStandbyTimer);
+ DPMSStandbyTimer = NULL;
+ }
+ if (DPMSSuspendTimer) {
+ TimerFree(DPMSSuspendTimer);
+ DPMSSuspendTimer = NULL;
+ }
+ if (DPMSOffTimer) {
+ TimerFree(DPMSOffTimer);
+ DPMSOffTimer = NULL;
+ }
+}
+
+void
+SetDPMSTimers(void)
+{
+ if (!DPMSEnabled)
+ return;
+
+ DPMSStandbyTimer = TimerSet(DPMSStandbyTimer, 0, DPMSStandbyTime,
+ DPMSStandbyTimerExpire, NULL);
+ DPMSSuspendTimer = TimerSet(DPMSSuspendTimer, 0, DPMSSuspendTime,
+ DPMSSuspendTimerExpire, NULL);
+ DPMSOffTimer = TimerSet(DPMSOffTimer, 0, DPMSOffTime,
+ DPMSOffTimerExpire, NULL);
+}
+#endif
diff --git a/nx-X11/programs/Xserver/os/WaitFor.c.X.original b/nx-X11/programs/Xserver/os/WaitFor.c.X.original
new file mode 100644
index 000000000..31e16210b
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/WaitFor.c.X.original
@@ -0,0 +1,701 @@
+/* $XFree86: xc/programs/Xserver/os/WaitFor.c,v 3.42 2003/10/16 01:33:35 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* $Xorg: WaitFor.c,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
+
+/*****************************************************************
+ * OS Dependent input routines:
+ *
+ * WaitForSomething
+ * TimerForce, TimerSet, TimerCheck, TimerFree
+ *
+ *****************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#endif
+#include <X11/Xos.h> /* for strings, fcntl, time */
+#include <errno.h>
+#include <stdio.h>
+#include <X11/X.h>
+#include "misc.h"
+
+#ifdef __UNIXOS2__
+#define select(n,r,w,x,t) os2PseudoSelect(n,r,w,x,t)
+#endif
+#include "osdep.h"
+#include <X11/Xpoll.h>
+#include "dixstruct.h"
+#include "opaque.h"
+#ifdef DPMSExtension
+#include "dpmsproc.h"
+#endif
+
+#ifdef WIN32
+/* Error codes from windows sockets differ from fileio error codes */
+#undef EINTR
+#define EINTR WSAEINTR
+#undef EINVAL
+#define EINVAL WSAEINVAL
+#undef EBADF
+#define EBADF WSAENOTSOCK
+/* Windows select does not set errno. Use GetErrno as wrapper for
+ WSAGetLastError */
+#define GetErrno WSAGetLastError
+#else
+/* This is just a fallback to errno to hide the differences between unix and
+ Windows in the code */
+#define GetErrno() errno
+#endif
+
+/* modifications by raphael */
+int
+mffs(fd_mask mask)
+{
+ int i;
+
+ if (!mask) return 0;
+ i = 1;
+ while (!(mask & 1))
+ {
+ i++;
+ mask >>= 1;
+ }
+ return i;
+}
+
+#ifdef DPMSExtension
+#define DPMS_SERVER
+#include <X11/extensions/dpms.h>
+#endif
+
+#ifdef XTESTEXT1
+/*
+ * defined in xtestext1dd.c
+ */
+extern int playback_on;
+#endif /* XTESTEXT1 */
+
+struct _OsTimerRec {
+ OsTimerPtr next;
+ CARD32 expires;
+ OsTimerCallback callback;
+ pointer arg;
+};
+
+static void DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev);
+static OsTimerPtr timers = NULL;
+
+/*****************
+ * WaitForSomething:
+ * Make the server suspend until there is
+ * 1. data from clients or
+ * 2. input events available or
+ * 3. ddx notices something of interest (graphics
+ * queue ready, etc.) or
+ * 4. clients that have buffered replies/events are ready
+ *
+ * If the time between INPUT events is
+ * greater than ScreenSaverTime, the display is turned off (or
+ * saved, depending on the hardware). So, WaitForSomething()
+ * has to handle this also (that's why the select() has a timeout.
+ * For more info on ClientsWithInput, see ReadRequestFromClient().
+ * pClientsReady is an array to store ready client->index values into.
+ *****************/
+
+int
+WaitForSomething(int *pClientsReady)
+{
+ int i;
+ struct timeval waittime, *wt;
+ INT32 timeout = 0;
+ fd_set clientsReadable;
+ fd_set clientsWritable;
+ int curclient;
+ int selecterr;
+ int nready;
+ fd_set devicesReadable;
+ CARD32 now = 0;
+#ifdef SMART_SCHEDULE
+ Bool someReady = FALSE;
+#endif
+
+ FD_ZERO(&clientsReadable);
+
+ /* We need a while loop here to handle
+ crashed connections and the screen saver timeout */
+ while (1)
+ {
+ /* deal with any blocked jobs */
+ if (workQueue)
+ ProcessWorkQueue();
+ if (XFD_ANYSET (&ClientsWithInput))
+ {
+#ifdef SMART_SCHEDULE
+ if (!SmartScheduleDisable)
+ {
+ someReady = TRUE;
+ waittime.tv_sec = 0;
+ waittime.tv_usec = 0;
+ wt = &waittime;
+ }
+ else
+#endif
+ {
+ XFD_COPYSET (&ClientsWithInput, &clientsReadable);
+ break;
+ }
+ }
+#ifdef SMART_SCHEDULE
+ if (someReady)
+ {
+ XFD_COPYSET(&AllSockets, &LastSelectMask);
+ XFD_UNSET(&LastSelectMask, &ClientsWithInput);
+ }
+ else
+ {
+#endif
+ wt = NULL;
+ if (timers)
+ {
+ now = GetTimeInMillis();
+ timeout = timers->expires - now;
+ if (timeout < 0)
+ timeout = 0;
+ waittime.tv_sec = timeout / MILLI_PER_SECOND;
+ waittime.tv_usec = (timeout % MILLI_PER_SECOND) *
+ (1000000 / MILLI_PER_SECOND);
+ wt = &waittime;
+ }
+ XFD_COPYSET(&AllSockets, &LastSelectMask);
+#ifdef SMART_SCHEDULE
+ }
+ SmartScheduleIdle = TRUE;
+#endif
+ BlockHandler((pointer)&wt, (pointer)&LastSelectMask);
+ if (NewOutputPending)
+ FlushAllOutput();
+#ifdef XTESTEXT1
+ /* XXX how does this interact with new write block handling? */
+ if (playback_on) {
+ wt = &waittime;
+ XTestComputeWaitTime (&waittime);
+ }
+#endif /* XTESTEXT1 */
+ /* keep this check close to select() call to minimize race */
+ if (dispatchException)
+ i = -1;
+ else if (AnyClientsWriteBlocked)
+ {
+ XFD_COPYSET(&ClientsWriteBlocked, &clientsWritable);
+ i = Select (MaxClients, &LastSelectMask, &clientsWritable, NULL, wt);
+ }
+ else
+ {
+ i = Select (MaxClients, &LastSelectMask, NULL, NULL, wt);
+ }
+ selecterr = GetErrno();
+ WakeupHandler(i, (pointer)&LastSelectMask);
+#ifdef XTESTEXT1
+ if (playback_on) {
+ i = XTestProcessInputAction (i, &waittime);
+ }
+#endif /* XTESTEXT1 */
+#ifdef SMART_SCHEDULE
+ if (i >= 0)
+ {
+ SmartScheduleIdle = FALSE;
+ SmartScheduleIdleCount = 0;
+ if (SmartScheduleTimerStopped)
+ (void) SmartScheduleStartTimer ();
+ }
+#endif
+ if (i <= 0) /* An error or timeout occurred */
+ {
+ if (dispatchException)
+ return 0;
+ if (i < 0)
+ {
+ if (selecterr == EBADF) /* Some client disconnected */
+ {
+ CheckConnections ();
+ if (! XFD_ANYSET (&AllClients))
+ return 0;
+ }
+ else if (selecterr == EINVAL)
+ {
+ FatalError("WaitForSomething(): select: errno=%d\n",
+ selecterr);
+ }
+ else if (selecterr != EINTR)
+ {
+ ErrorF("WaitForSomething(): select: errno=%d\n",
+ selecterr);
+ }
+ }
+#ifdef SMART_SCHEDULE
+ else if (someReady)
+ {
+ /*
+ * If no-one else is home, bail quickly
+ */
+ XFD_COPYSET(&ClientsWithInput, &LastSelectMask);
+ XFD_COPYSET(&ClientsWithInput, &clientsReadable);
+ break;
+ }
+#endif
+ if (*checkForInput[0] != *checkForInput[1])
+ return 0;
+
+ if (timers)
+ {
+ int expired = 0;
+ now = GetTimeInMillis();
+ if ((int) (timers->expires - now) <= 0)
+ expired = 1;
+
+ while (timers && (int) (timers->expires - now) <= 0)
+ DoTimer(timers, now, &timers);
+
+ if (expired)
+ return 0;
+ }
+ }
+ else
+ {
+ fd_set tmp_set;
+
+ if (*checkForInput[0] == *checkForInput[1]) {
+ if (timers)
+ {
+ int expired = 0;
+ now = GetTimeInMillis();
+ if ((int) (timers->expires - now) <= 0)
+ expired = 1;
+
+ while (timers && (int) (timers->expires - now) <= 0)
+ DoTimer(timers, now, &timers);
+
+ if (expired)
+ return 0;
+ }
+ }
+#ifdef SMART_SCHEDULE
+ if (someReady)
+ XFD_ORSET(&LastSelectMask, &ClientsWithInput, &LastSelectMask);
+#endif
+ if (AnyClientsWriteBlocked && XFD_ANYSET (&clientsWritable))
+ {
+ NewOutputPending = TRUE;
+ XFD_ORSET(&OutputPending, &clientsWritable, &OutputPending);
+ XFD_UNSET(&ClientsWriteBlocked, &clientsWritable);
+ if (! XFD_ANYSET(&ClientsWriteBlocked))
+ AnyClientsWriteBlocked = FALSE;
+ }
+
+ XFD_ANDSET(&devicesReadable, &LastSelectMask, &EnabledDevices);
+ XFD_ANDSET(&clientsReadable, &LastSelectMask, &AllClients);
+ XFD_ANDSET(&tmp_set, &LastSelectMask, &WellKnownConnections);
+ if (XFD_ANYSET(&tmp_set))
+ QueueWorkProc(EstablishNewConnections, NULL,
+ (pointer)&LastSelectMask);
+#ifdef DPMSExtension
+ if (XFD_ANYSET (&devicesReadable) && (DPMSPowerLevel != DPMSModeOn))
+ DPMSSet(DPMSModeOn);
+#endif
+ if (XFD_ANYSET (&devicesReadable) || XFD_ANYSET (&clientsReadable))
+ break;
+#ifdef WIN32
+ /* Windows keyboard and mouse events are added to the input queue
+ in Block- and WakupHandlers. There is no device to check if
+ data is ready. So check here if new input is available */
+ if (*checkForInput[0] != *checkForInput[1])
+ return 0;
+#endif
+ }
+ }
+
+ nready = 0;
+ if (XFD_ANYSET (&clientsReadable))
+ {
+#ifndef WIN32
+ for (i=0; i<howmany(XFD_SETSIZE, NFDBITS); i++)
+ {
+ int highest_priority = 0;
+
+ while (clientsReadable.fds_bits[i])
+ {
+ int client_priority, client_index;
+
+ curclient = ffs (clientsReadable.fds_bits[i]) - 1;
+ client_index = /* raphael: modified */
+ ConnectionTranslation[curclient + (i * (sizeof(fd_mask) * 8))];
+#else
+ int highest_priority = 0;
+ fd_set savedClientsReadable;
+ XFD_COPYSET(&clientsReadable, &savedClientsReadable);
+ for (i = 0; i < XFD_SETCOUNT(&savedClientsReadable); i++)
+ {
+ int client_priority, client_index;
+
+ curclient = XFD_FD(&savedClientsReadable, i);
+ client_index = GetConnectionTranslation(curclient);
+#endif
+#ifdef XSYNC
+ /* We implement "strict" priorities.
+ * Only the highest priority client is returned to
+ * dix. If multiple clients at the same priority are
+ * ready, they are all returned. This means that an
+ * aggressive client could take over the server.
+ * This was not considered a big problem because
+ * aggressive clients can hose the server in so many
+ * other ways :)
+ */
+ client_priority = clients[client_index]->priority;
+ if (nready == 0 || client_priority > highest_priority)
+ {
+ /* Either we found the first client, or we found
+ * a client whose priority is greater than all others
+ * that have been found so far. Either way, we want
+ * to initialize the list of clients to contain just
+ * this client.
+ */
+ pClientsReady[0] = client_index;
+ highest_priority = client_priority;
+ nready = 1;
+ }
+ /* the following if makes sure that multiple same-priority
+ * clients get batched together
+ */
+ else if (client_priority == highest_priority)
+#endif
+ {
+ pClientsReady[nready++] = client_index;
+ }
+#ifndef WIN32
+ clientsReadable.fds_bits[i] &= ~(((fd_mask)1L) << curclient);
+ }
+#else
+ FD_CLR(curclient, &clientsReadable);
+#endif
+ }
+ }
+ return nready;
+}
+
+#if 0
+/*
+ * This is not always a macro.
+ */
+ANYSET(FdMask *src)
+{
+ int i;
+
+ for (i=0; i<mskcnt; i++)
+ if (src[ i ])
+ return (TRUE);
+ return (FALSE);
+}
+#endif
+
+
+static void
+DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev)
+{
+ CARD32 newTime;
+
+ *prev = timer->next;
+ timer->next = NULL;
+ newTime = (*timer->callback)(timer, now, timer->arg);
+ if (newTime)
+ TimerSet(timer, 0, newTime, timer->callback, timer->arg);
+}
+
+OsTimerPtr
+TimerSet(OsTimerPtr timer, int flags, CARD32 millis,
+ OsTimerCallback func, pointer arg)
+{
+ register OsTimerPtr *prev;
+ CARD32 now = GetTimeInMillis();
+
+ if (!timer)
+ {
+ timer = (OsTimerPtr)xalloc(sizeof(struct _OsTimerRec));
+ if (!timer)
+ return NULL;
+ }
+ else
+ {
+ for (prev = &timers; *prev; prev = &(*prev)->next)
+ {
+ if (*prev == timer)
+ {
+ *prev = timer->next;
+ if (flags & TimerForceOld)
+ (void)(*timer->callback)(timer, now, timer->arg);
+ break;
+ }
+ }
+ }
+ if (!millis)
+ return timer;
+ if (!(flags & TimerAbsolute))
+ millis += now;
+ timer->expires = millis;
+ timer->callback = func;
+ timer->arg = arg;
+ if ((int) (millis - now) <= 0)
+ {
+ timer->next = NULL;
+ millis = (*timer->callback)(timer, now, timer->arg);
+ if (!millis)
+ return timer;
+ }
+ for (prev = &timers;
+ *prev && (int) ((*prev)->expires - millis) <= 0;
+ prev = &(*prev)->next)
+ ;
+ timer->next = *prev;
+ *prev = timer;
+ return timer;
+}
+
+Bool
+TimerForce(OsTimerPtr timer)
+{
+ OsTimerPtr *prev;
+
+ for (prev = &timers; *prev; prev = &(*prev)->next)
+ {
+ if (*prev == timer)
+ {
+ DoTimer(timer, GetTimeInMillis(), prev);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+void
+TimerCancel(OsTimerPtr timer)
+{
+ OsTimerPtr *prev;
+
+ if (!timer)
+ return;
+ for (prev = &timers; *prev; prev = &(*prev)->next)
+ {
+ if (*prev == timer)
+ {
+ *prev = timer->next;
+ break;
+ }
+ }
+}
+
+void
+TimerFree(OsTimerPtr timer)
+{
+ if (!timer)
+ return;
+ TimerCancel(timer);
+ xfree(timer);
+}
+
+void
+TimerCheck(void)
+{
+ CARD32 now = GetTimeInMillis();
+
+ while (timers && (int) (timers->expires - now) <= 0)
+ DoTimer(timers, now, &timers);
+}
+
+void
+TimerInit(void)
+{
+ OsTimerPtr timer;
+
+ while ((timer = timers))
+ {
+ timers = timer->next;
+ xfree(timer);
+ }
+}
+
+static CARD32
+ScreenSaverTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+ INT32 timeout = now - lastDeviceEventTime.milliseconds;
+
+ if (timeout < ScreenSaverTime) {
+ return ScreenSaverTime - timeout;
+ }
+
+ ResetOsBuffers(); /* not ideal, but better than nothing */
+ SaveScreens(SCREEN_SAVER_ON, ScreenSaverActive);
+
+#ifdef DPMSExtension
+ if (ScreenSaverInterval > 0 && DPMSPowerLevel == DPMSModeOn)
+#else
+ if (ScreenSaverInterval > 0)
+#endif /* DPMSExtension */
+ return ScreenSaverInterval;
+
+ return 0;
+}
+
+static OsTimerPtr ScreenSaverTimer = NULL;
+
+void
+FreeScreenSaverTimer(void)
+{
+ if (ScreenSaverTimer) {
+ TimerFree(ScreenSaverTimer);
+ ScreenSaverTimer = NULL;
+ }
+}
+
+void
+SetScreenSaverTimer(void)
+{
+ if (ScreenSaverTime > 0) {
+ ScreenSaverTimer = TimerSet(ScreenSaverTimer, 0, ScreenSaverTime,
+ ScreenSaverTimeoutExpire, NULL);
+ } else if (ScreenSaverTimer) {
+ FreeScreenSaverTimer();
+ }
+}
+
+#ifdef DPMSExtension
+
+static OsTimerPtr DPMSStandbyTimer = NULL;
+static OsTimerPtr DPMSSuspendTimer = NULL;
+static OsTimerPtr DPMSOffTimer = NULL;
+
+static CARD32
+DPMSStandbyTimerExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+ INT32 timeout = now - lastDeviceEventTime.milliseconds;
+
+ if (timeout < DPMSStandbyTime) {
+ return DPMSStandbyTime - timeout;
+ }
+ if (DPMSPowerLevel < DPMSModeStandby) {
+ if (DPMSEnabled)
+ DPMSSet(DPMSModeStandby);
+ }
+ return DPMSStandbyTime;
+}
+
+static CARD32
+DPMSSuspendTimerExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+ INT32 timeout = now - lastDeviceEventTime.milliseconds;
+
+ if (timeout < DPMSSuspendTime) {
+ return DPMSSuspendTime - timeout;
+ }
+ if (DPMSPowerLevel < DPMSModeSuspend) {
+ if (DPMSEnabled)
+ DPMSSet(DPMSModeSuspend);
+ }
+ return DPMSSuspendTime;
+}
+
+static CARD32
+DPMSOffTimerExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+ INT32 timeout = now - lastDeviceEventTime.milliseconds;
+
+ if (timeout < DPMSOffTime) {
+ return DPMSOffTime - timeout;
+ }
+ if (DPMSPowerLevel < DPMSModeOff) {
+ if (DPMSEnabled)
+ DPMSSet(DPMSModeOff);
+ }
+ return DPMSOffTime;
+}
+
+void
+FreeDPMSTimers(void)
+{
+ if (DPMSStandbyTimer) {
+ TimerFree(DPMSStandbyTimer);
+ DPMSStandbyTimer = NULL;
+ }
+ if (DPMSSuspendTimer) {
+ TimerFree(DPMSSuspendTimer);
+ DPMSSuspendTimer = NULL;
+ }
+ if (DPMSOffTimer) {
+ TimerFree(DPMSOffTimer);
+ DPMSOffTimer = NULL;
+ }
+}
+
+void
+SetDPMSTimers(void)
+{
+ if (!DPMSEnabled)
+ return;
+
+ DPMSStandbyTimer = TimerSet(DPMSStandbyTimer, 0, DPMSStandbyTime,
+ DPMSStandbyTimerExpire, NULL);
+ DPMSSuspendTimer = TimerSet(DPMSSuspendTimer, 0, DPMSSuspendTime,
+ DPMSSuspendTimerExpire, NULL);
+ DPMSOffTimer = TimerSet(DPMSOffTimer, 0, DPMSOffTime,
+ DPMSOffTimerExpire, NULL);
+}
+#endif
diff --git a/nx-X11/programs/Xserver/os/access.c b/nx-X11/programs/Xserver/os/access.c
new file mode 100644
index 000000000..b6a70a703
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/access.c
@@ -0,0 +1,2429 @@
+/* $Xorg: access.c,v 1.5 2001/02/09 02:05:23 xorgcvs Exp $ */
+/* $XdotOrg: xc/programs/Xserver/os/access.c,v 1.13 2005/11/08 06:33:30 jkj Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+Copyright 2004 Sun Microsystems, Inc.
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+X Window System is a trademark of The Open Group.
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/os/access.c,v 3.53 2004/01/02 18:23:19 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xtrans/Xtrans.h>
+#include <X11/Xauth.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "site.h"
+#include <errno.h>
+#include <sys/types.h>
+#ifndef WIN32
+#ifndef Lynx
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif
+#include <sys/ioctl.h>
+#include <ctype.h>
+
+#if defined(TCPCONN) || defined(STREAMSCONN) || defined(ISC) || defined(__SCO__)
+#include <netinet/in.h>
+#endif /* TCPCONN || STREAMSCONN || ISC || __SCO__ */
+#ifdef DNETCONN
+#include <netdnet/dn.h>
+#include <netdnet/dnetdb.h>
+#endif
+
+#ifdef HAS_GETPEERUCRED
+# include <ucred.h>
+# ifdef sun
+# include <zone.h>
+# endif
+#endif
+
+#if defined(DGUX)
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <ctype.h>
+#include <sys/utsname.h>
+#include <sys/stream.h>
+#include <sys/stropts.h>
+#include <sys/param.h>
+#include <sys/sockio.h>
+#endif
+
+
+#if defined(hpux) || defined(QNX4)
+# include <sys/utsname.h>
+# ifdef HAS_IFREQ
+# include <net/if.h>
+# endif
+#else
+#if defined(SVR4) || (defined(SYSV) && defined(i386)) || defined(__GNU__)
+# include <sys/utsname.h>
+#endif
+#if defined(SYSV) && defined(i386)
+# include <sys/stream.h>
+# ifdef ISC
+# include <sys/stropts.h>
+# include <sys/sioctl.h>
+# endif /* ISC */
+#endif
+#ifdef __GNU__
+#undef SIOCGIFCONF
+#include <netdb.h>
+#else /*!__GNU__*/
+# include <net/if.h>
+#endif /*__GNU__ */
+#endif /* hpux */
+
+#ifdef SVR4
+#include <sys/sockio.h>
+#include <sys/stropts.h>
+#endif
+
+#include <netdb.h>
+
+#ifdef CSRG_BASED
+#include <sys/param.h>
+#if (BSD >= 199103)
+#define VARIABLE_IFREQ
+#endif
+#endif
+
+#ifdef BSD44SOCKETS
+#ifndef VARIABLE_IFREQ
+#define VARIABLE_IFREQ
+#endif
+#endif
+
+#ifdef HAS_GETIFADDRS
+#include <ifaddrs.h>
+#endif
+
+/* Solaris provides an extended interface SIOCGLIFCONF. Other systems
+ * may have this as well, but the code has only been tested on Solaris
+ * so far, so we only enable it there. Other platforms may be added as
+ * needed.
+ *
+ * Test for Solaris commented out -- TSI @ UQV 2003.06.13
+ */
+#ifdef SIOCGLIFCONF
+/* #if defined(sun) */
+#define USE_SIOCGLIFCONF
+/* #endif */
+#endif
+
+#endif /* WIN32 */
+
+#ifndef PATH_MAX
+#ifndef Lynx
+#include <sys/param.h>
+#else
+#include <param.h>
+#endif
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+#endif
+
+#ifdef __SCO__
+/* The system defined value is wrong. MAXPATHLEN is set in sco5.cf. */
+#undef PATH_MAX
+#endif
+
+#define X_INCLUDE_NETDB_H
+#include <X11/Xos_r.h>
+
+#include "dixstruct.h"
+#include "osdep.h"
+
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+
+Bool defeatAccessControl = FALSE;
+
+#define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len)
+#define acopy(a1, a2, len) memmove((char *)(a2), (char *)(a1), len)
+#define addrEqual(fam, address, length, host) \
+ ((fam) == (host)->family &&\
+ (length) == (host)->len &&\
+ !acmp (address, (host)->addr, length))
+
+static int ConvertAddr(struct sockaddr * /*saddr*/,
+ int * /*len*/,
+ pointer * /*addr*/);
+
+static int CheckAddr(int /*family*/,
+ pointer /*pAddr*/,
+ unsigned /*length*/);
+
+static Bool NewHost(int /*family*/,
+ pointer /*addr*/,
+ int /*len*/,
+ int /* addingLocalHosts */);
+
+int LocalClientCredAndGroups(ClientPtr client, int *pUid, int *pGid,
+ int **pSuppGids, int *nSuppGids);
+
+
+/* XFree86 bug #156: To keep track of which hosts were explicitly requested in
+ /etc/X<display>.hosts, we've added a requested field to the HOST struct,
+ and a LocalHostRequested variable. These default to FALSE, but are set
+ to TRUE in ResetHosts when reading in /etc/X<display>.hosts. They are
+ checked in DisableLocalHost(), which is called to disable the default
+ local host entries when stronger authentication is turned on. */
+
+typedef struct _host {
+ short family;
+ short len;
+ unsigned char *addr;
+ struct _host *next;
+ int requested;
+} HOST;
+
+#define MakeHost(h,l) (h)=(HOST *) xalloc(sizeof *(h)+(l));\
+ if (h) { \
+ (h)->addr=(unsigned char *) ((h) + 1);\
+ (h)->requested = FALSE; \
+ }
+#define FreeHost(h) xfree(h)
+static HOST *selfhosts = NULL;
+static HOST *validhosts = NULL;
+static int AccessEnabled = DEFAULT_ACCESS_CONTROL;
+static int LocalHostEnabled = FALSE;
+static int LocalHostRequested = FALSE;
+static int UsingXdmcp = FALSE;
+
+/* FamilyServerInterpreted implementation */
+static Bool siAddrMatch(int family, pointer addr, int len, HOST *host,
+ ClientPtr client);
+static int siCheckAddr(const char *addrString, int length);
+static void siTypesInitialize(void);
+
+/*
+ * called when authorization is not enabled to add the
+ * local host to the access list
+ */
+
+void
+EnableLocalHost (void)
+{
+ if (!UsingXdmcp)
+ {
+ LocalHostEnabled = TRUE;
+ AddLocalHosts ();
+ }
+}
+
+/*
+ * called when authorization is enabled to keep us secure
+ */
+void
+DisableLocalHost (void)
+{
+ HOST *self;
+
+ if (!LocalHostRequested) /* Fix for XFree86 bug #156 */
+ LocalHostEnabled = FALSE;
+ for (self = selfhosts; self; self = self->next) {
+ if (!self->requested) /* Fix for XFree86 bug #156 */
+ (void) RemoveHost ((ClientPtr)NULL, self->family, self->len, (pointer)self->addr);
+ }
+}
+
+/*
+ * called at init time when XDMCP will be used; xdmcp always
+ * adds local hosts manually when needed
+ */
+
+void
+AccessUsingXdmcp (void)
+{
+ UsingXdmcp = TRUE;
+ LocalHostEnabled = FALSE;
+}
+
+
+#if ((defined(SVR4) && !defined(DGUX) && !defined(SCO325) && !defined(sun) && !defined(NCR)) || defined(ISC)) && !defined(__sgi) && defined(SIOCGIFCONF) && !defined(USE_SIOCGLIFCONF)
+
+/* Deal with different SIOCGIFCONF ioctl semantics on these OSs */
+
+static int
+ifioctl (int fd, int cmd, char *arg)
+{
+ struct strioctl ioc;
+ int ret;
+
+ bzero((char *) &ioc, sizeof(ioc));
+ ioc.ic_cmd = cmd;
+ ioc.ic_timout = 0;
+ if (cmd == SIOCGIFCONF)
+ {
+ ioc.ic_len = ((struct ifconf *) arg)->ifc_len;
+ ioc.ic_dp = ((struct ifconf *) arg)->ifc_buf;
+#ifdef ISC
+ /* SIOCGIFCONF is somewhat brain damaged on ISC. The argument
+ * buffer must contain the ifconf structure as header. Ifc_req
+ * is also not a pointer but a one element array of ifreq
+ * structures. On return this array is extended by enough
+ * ifreq fields to hold all interfaces. The return buffer length
+ * is placed in the buffer header.
+ */
+ ((struct ifconf *) ioc.ic_dp)->ifc_len =
+ ioc.ic_len - sizeof(struct ifconf);
+#endif
+ }
+ else
+ {
+ ioc.ic_len = sizeof(struct ifreq);
+ ioc.ic_dp = arg;
+ }
+ ret = ioctl(fd, I_STR, (char *) &ioc);
+ if (ret >= 0 && cmd == SIOCGIFCONF)
+#ifdef SVR4
+ ((struct ifconf *) arg)->ifc_len = ioc.ic_len;
+#endif
+#ifdef ISC
+ {
+ ((struct ifconf *) arg)->ifc_len =
+ ((struct ifconf *)ioc.ic_dp)->ifc_len;
+ ((struct ifconf *) arg)->ifc_buf =
+ (caddr_t)((struct ifconf *)ioc.ic_dp)->ifc_req;
+ }
+#endif
+ return(ret);
+}
+#else /* Case DGUX, sun, SCO325 NCR and others */
+#define ifioctl ioctl
+#endif /* ((SVR4 && !DGUX !sun !SCO325 !NCR) || ISC) && SIOCGIFCONF */
+
+/*
+ * DefineSelf (fd):
+ *
+ * Define this host for access control. Find all the hosts the OS knows about
+ * for this fd and add them to the selfhosts list.
+ */
+
+#ifdef WINTCP /* NCR Wollongong based TCP */
+
+#include <sys/un.h>
+#include <stropts.h>
+#include <tiuser.h>
+
+#include <sys/stream.h>
+#include <net/if.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+
+void
+DefineSelf (int fd)
+{
+ /*
+ * The Wolongong drivers used by NCR SVR4/MP-RAS don't understand the
+ * socket IO calls that most other drivers seem to like. Because of
+ * this, this routine must be special cased for NCR. Eventually,
+ * this will be cleared up.
+ */
+
+ struct ipb ifnet;
+ struct in_ifaddr ifaddr;
+ struct strioctl str;
+ unsigned char *addr;
+ register HOST *host;
+ int family, len;
+
+ if ((fd = open ("/dev/ip", O_RDWR, 0 )) < 0)
+ Error ("Getting interface configuration (1)");
+
+ /* Indicate that we want to start at the begining */
+ ifnet.ib_next = (struct ipb *) 1;
+
+ while (ifnet.ib_next)
+ {
+ str.ic_cmd = IPIOC_GETIPB;
+ str.ic_timout = 0;
+ str.ic_len = sizeof (struct ipb);
+ str.ic_dp = (char *) &ifnet;
+
+ if (ioctl (fd, (int) I_STR, (char *) &str) < 0)
+ {
+ close (fd);
+ Error ("Getting interface configuration (2)");
+ }
+
+ ifaddr.ia_next = (struct in_ifaddr *) ifnet.if_addrlist;
+ str.ic_cmd = IPIOC_GETINADDR;
+ str.ic_timout = 0;
+ str.ic_len = sizeof (struct in_ifaddr);
+ str.ic_dp = (char *) &ifaddr;
+
+ if (ioctl (fd, (int) I_STR, (char *) &str) < 0)
+ {
+ close (fd);
+ Error ("Getting interface configuration (3)");
+ }
+
+ len = sizeof(struct sockaddr_in);
+ family = ConvertAddr (IA_SIN(&ifaddr), &len, (pointer *)&addr);
+ if (family == -1 || family == FamilyLocal)
+ continue;
+ for (host = selfhosts;
+ host && !addrEqual (family, addr, len, host);
+ host = host->next)
+ ;
+ if (host)
+ continue;
+ MakeHost(host,len)
+ if (host)
+ {
+ host->family = family;
+ host->len = len;
+ acopy(addr, host->addr, len);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
+#ifdef XDMCP
+ {
+ struct sockaddr broad_addr;
+
+ /*
+ * If this isn't an Internet Address, don't register it.
+ */
+ if (family != FamilyInternet)
+ continue;
+
+ /*
+ * Ignore 'localhost' entries as they're not useful
+ * on the other end of the wire.
+ */
+ if (len == 4 &&
+ addr[0] == 127 && addr[1] == 0 &&
+ addr[2] == 0 && addr[3] == 1)
+ continue;
+
+ /*
+ * Ignore '0.0.0.0' entries as they are
+ * returned by some OSes for unconfigured NICs but they are
+ * not useful on the other end of the wire.
+ */
+ if (len == 4 &&
+ addr[0] == 0 && addr[1] == 0 &&
+ addr[2] == 0 && addr[3] == 0)
+ continue;
+
+ XdmcpRegisterConnection (family, (char *)addr, len);
+
+
+#define IA_BROADADDR(ia) ((struct sockaddr_in *)(&((struct in_ifaddr *)ia)->ia_broadaddr))
+
+ XdmcpRegisterBroadcastAddress (
+ (struct sockaddr_in *) IA_BROADADDR(&ifaddr));
+
+#undef IA_BROADADDR
+ }
+#endif /* XDMCP */
+ }
+
+ close(fd);
+
+ /*
+ * add something of FamilyLocalHost
+ */
+ for (host = selfhosts;
+ host && !addrEqual(FamilyLocalHost, "", 0, host);
+ host = host->next);
+ if (!host)
+ {
+ MakeHost(host, 0);
+ if (host)
+ {
+ host->family = FamilyLocalHost;
+ host->len = 0;
+ acopy("", host->addr, 0);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
+ }
+}
+
+#else /* WINTCP */
+
+#if !defined(SIOCGIFCONF) || (defined (hpux) && ! defined (HAS_IFREQ)) || defined(QNX4)
+void
+DefineSelf (int fd)
+{
+#if !defined(TCPCONN) && !defined(STREAMSCONN) && !defined(UNIXCONN) && !defined(MNX_TCPCONN)
+ return;
+#else
+ register int n;
+ int len;
+ caddr_t addr;
+ int family;
+ register HOST *host;
+
+#ifndef WIN32
+ struct utsname name;
+#else
+ struct {
+ char nodename[512];
+ } name;
+#endif
+
+ register struct hostent *hp;
+
+ union {
+ struct sockaddr sa;
+ struct sockaddr_in in;
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_in6 in6;
+#endif
+ } saddr;
+
+ struct sockaddr_in *inetaddr;
+ struct sockaddr_in6 *inet6addr;
+ struct sockaddr_in broad_addr;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+
+ /* Why not use gethostname()? Well, at least on my system, I've had to
+ * make an ugly kernel patch to get a name longer than 8 characters, and
+ * uname() lets me access to the whole string (it smashes release, you
+ * see), whereas gethostname() kindly truncates it for me.
+ */
+#ifndef QNX4
+#ifndef WIN32
+ uname(&name);
+#else
+ gethostname(name.nodename, sizeof(name.nodename));
+#endif
+#else
+ /* QNX4's uname returns node number in name.nodename, not the hostname
+ have to overwrite it */
+ char hname[1024];
+ gethostname(hname, 1024);
+ name.nodename = hname;
+#endif
+
+ hp = _XGethostbyname(name.nodename, hparams);
+ if (hp != NULL)
+ {
+ saddr.sa.sa_family = hp->h_addrtype;
+ switch (hp->h_addrtype) {
+ case AF_INET:
+ inetaddr = (struct sockaddr_in *) (&(saddr.sa));
+ acopy ( hp->h_addr, &(inetaddr->sin_addr), hp->h_length);
+ len = sizeof(saddr.sa);
+ break;
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6:
+ inet6addr = (struct sockaddr_in6 *) (&(saddr.sa));
+ acopy ( hp->h_addr, &(inet6addr->sin6_addr), hp->h_length);
+ len = sizeof(saddr.in6);
+ break;
+#endif
+ default:
+ goto DefineLocalHost;
+ }
+ family = ConvertAddr ( &(saddr.sa), &len, (pointer *)&addr);
+ if ( family != -1 && family != FamilyLocal )
+ {
+ for (host = selfhosts;
+ host && !addrEqual (family, addr, len, host);
+ host = host->next) ;
+ if (!host)
+ {
+ /* add this host to the host list. */
+ MakeHost(host,len)
+ if (host)
+ {
+ host->family = family;
+ host->len = len;
+ acopy ( addr, host->addr, len);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
+#ifdef XDMCP
+ /*
+ * If this is an Internet Address, but not the localhost
+ * address (127.0.0.1), nor the bogus address (0.0.0.0),
+ * register it.
+ */
+ if (family == FamilyInternet &&
+ !(len == 4 &&
+ ((addr[0] == 127 && addr[1] == 0 &&
+ addr[2] == 0 && addr[3] == 1) ||
+ (addr[0] == 0 && addr[1] == 0 &&
+ addr[2] == 0 && addr[3] == 0)))
+ )
+ {
+ XdmcpRegisterConnection (family, (char *)addr, len);
+ broad_addr = *inetaddr;
+ ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
+ htonl (INADDR_BROADCAST);
+ XdmcpRegisterBroadcastAddress ((struct sockaddr_in *)
+ &broad_addr);
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ else if (family == FamilyInternet6 &&
+ !(IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr)))
+ {
+ XdmcpRegisterConnection (family, (char *)addr, len);
+ }
+#endif
+
+#endif /* XDMCP */
+ }
+ }
+ }
+ /*
+ * now add a host of family FamilyLocalHost...
+ */
+DefineLocalHost:
+ for (host = selfhosts;
+ host && !addrEqual(FamilyLocalHost, "", 0, host);
+ host = host->next);
+ if (!host)
+ {
+ MakeHost(host, 0);
+ if (host)
+ {
+ host->family = FamilyLocalHost;
+ host->len = 0;
+ acopy("", host->addr, 0);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
+ }
+#endif /* !TCPCONN && !STREAMSCONN && !UNIXCONN && !MNX_TCPCONN */
+}
+
+#else
+
+#ifdef USE_SIOCGLIFCONF
+#define ifr_type struct lifreq
+#else
+#define ifr_type struct ifreq
+#endif
+
+#ifdef VARIABLE_IFREQ
+#define ifr_size(p) (sizeof (struct ifreq) + \
+ (p->ifr_addr.sa_len > sizeof (p->ifr_addr) ? \
+ p->ifr_addr.sa_len - sizeof (p->ifr_addr) : 0))
+#define ifraddr_size(a) (a.sa_len)
+#else
+#ifdef QNX4
+#define ifr_size(p) (p->ifr_addr.sa_len + IFNAMSIZ)
+#define ifraddr_size(a) (a.sa_len)
+#else
+#define ifr_size(p) (sizeof (ifr_type))
+#define ifraddr_size(a) (sizeof (a))
+#endif
+#endif
+
+#if defined(DEF_SELF_DEBUG) || (defined(IPv6) && defined(AF_INET6))
+#include <arpa/inet.h>
+#endif
+
+#if defined(IPv6) && defined(AF_INET6)
+static void
+in6_fillscopeid(struct sockaddr_in6 *sin6)
+{
+#if defined(__KAME__)
+ if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
+ sin6->sin6_scope_id =
+ ntohs(*(u_int16_t *)&sin6->sin6_addr.s6_addr[2]);
+ sin6->sin6_addr.s6_addr[2] = sin6->sin6_addr.s6_addr[3] = 0;
+ }
+#endif
+}
+#endif
+
+void
+DefineSelf (int fd)
+{
+#ifndef HAS_GETIFADDRS
+ char buf[2048], *cp, *cplim;
+ void * bufptr = buf;
+#ifdef USE_SIOCGLIFCONF
+ struct lifconf ifc;
+ register struct lifreq *ifr;
+#ifdef SIOCGLIFNUM
+ struct lifnum ifn;
+#endif
+#else
+ struct ifconf ifc;
+ register struct ifreq *ifr;
+#endif
+#else
+ struct ifaddrs * ifap, *ifr;
+#endif
+ int len;
+ unsigned char * addr;
+ int family;
+ register HOST *host;
+
+#ifdef DNETCONN
+ struct dn_naddr *dnaddr = getnodeadd();
+ /*
+ * AF_DECnet may not be listed in the interface list. Instead use
+ * the supported library call to find out the local address (if any).
+ */
+ if (dnaddr)
+ {
+ addr = (unsigned char *) dnaddr;
+ len = dnaddr->a_len + sizeof(dnaddr->a_len);
+ family = FamilyDECnet;
+ for (host = selfhosts;
+ host && !addrEqual (family, addr, len, host);
+ host = host->next)
+ ;
+ if (!host)
+ {
+ MakeHost(host,len)
+ if (host)
+ {
+ host->family = family;
+ host->len = len;
+ acopy(addr, host->addr, len);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
+ }
+ }
+#endif /* DNETCONN */
+#ifndef HAS_GETIFADDRS
+
+ len = sizeof(buf);
+
+#ifdef USE_SIOCGLIFCONF
+
+#ifdef SIOCGLIFNUM
+ ifn.lifn_family = AF_UNSPEC;
+ ifn.lifn_flags = 0;
+ if (ioctl (fd, SIOCGLIFNUM, (char *) &ifn) < 0)
+ Error ("Getting interface count");
+ if (len < (ifn.lifn_count * sizeof(struct lifreq))) {
+ len = ifn.lifn_count * sizeof(struct lifreq);
+ bufptr = xalloc(len);
+ }
+#endif
+
+ ifc.lifc_family = AF_UNSPEC;
+ ifc.lifc_flags = 0;
+ ifc.lifc_len = len;
+ ifc.lifc_buf = bufptr;
+
+#define IFC_IOCTL_REQ SIOCGLIFCONF
+#define IFC_IFC_REQ ifc.lifc_req
+#define IFC_IFC_LEN ifc.lifc_len
+#define IFR_IFR_ADDR ifr->lifr_addr
+#define IFR_IFR_NAME ifr->lifr_name
+
+#else /* Use SIOCGIFCONF */
+ ifc.ifc_len = len;
+ ifc.ifc_buf = bufptr;
+
+#define IFC_IOCTL_REQ SIOCGIFCONF
+#ifdef ISC
+#define IFC_IFC_REQ (struct ifreq *) ifc.ifc_buf
+#else
+#define IFC_IFC_REQ ifc.ifc_req
+#endif /* ISC */
+#define IFC_IFC_LEN ifc.ifc_len
+#define IFR_IFR_ADDR ifr->ifr_addr
+#define IFR_IFR_NAME ifr->ifr_name
+#endif
+
+ if (ifioctl (fd, IFC_IOCTL_REQ, (pointer) &ifc) < 0)
+ Error ("Getting interface configuration (4)");
+
+ cplim = (char *) IFC_IFC_REQ + IFC_IFC_LEN;
+
+ for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr))
+ {
+ ifr = (ifr_type *) cp;
+ len = ifraddr_size (IFR_IFR_ADDR);
+ family = ConvertAddr ((struct sockaddr *) &IFR_IFR_ADDR,
+ &len, (pointer *)&addr);
+#ifdef DNETCONN
+ /*
+ * DECnet was handled up above.
+ */
+ if (family == AF_DECnet)
+ continue;
+#endif /* DNETCONN */
+ if (family == -1 || family == FamilyLocal)
+ continue;
+#if defined(IPv6) && defined(AF_INET6)
+ if (family == FamilyInternet6)
+ in6_fillscopeid((struct sockaddr_in6 *)&IFR_IFR_ADDR);
+#endif
+#ifdef DEF_SELF_DEBUG
+ if (family == FamilyInternet)
+ ErrorF("Xserver: DefineSelf(): ifname = %s, addr = %d.%d.%d.%d\n",
+ IFR_IFR_NAME, addr[0], addr[1], addr[2], addr[3]);
+#if defined(IPv6) && defined(AF_INET6)
+ else if (family == FamilyInternet6) {
+ char cp[INET6_ADDRSTRLEN] = "";
+ inet_ntop(AF_INET6, addr, cp, sizeof(cp));
+ ErrorF("Xserver: DefineSelf(): ifname = %s, addr = %s\n",
+ IFR_IFR_NAME, cp);
+ }
+#endif
+#endif /* DEF_SELF_DEBUG */
+ for (host = selfhosts;
+ host && !addrEqual (family, addr, len, host);
+ host = host->next)
+ ;
+ if (host)
+ continue;
+ MakeHost(host,len)
+ if (host)
+ {
+ host->family = family;
+ host->len = len;
+ acopy(addr, host->addr, len);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
+#ifdef XDMCP
+ {
+#ifdef USE_SIOCGLIFCONF
+ struct sockaddr_storage broad_addr;
+#else
+ struct sockaddr broad_addr;
+#endif
+
+ /*
+ * If this isn't an Internet Address, don't register it.
+ */
+ if (family != FamilyInternet
+#if defined(IPv6) && defined(AF_INET6)
+ && family != FamilyInternet6
+#endif
+ )
+ continue;
+
+ /*
+ * ignore 'localhost' entries as they're not useful
+ * on the other end of the wire
+ */
+ if (family == FamilyInternet &&
+ addr[0] == 127 && addr[1] == 0 &&
+ addr[2] == 0 && addr[3] == 1)
+ continue;
+#if defined(IPv6) && defined(AF_INET6)
+ else if (family == FamilyInternet6 &&
+ IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr))
+ continue;
+#endif
+
+ /*
+ * Ignore '0.0.0.0' entries as they are
+ * returned by some OSes for unconfigured NICs but they are
+ * not useful on the other end of the wire.
+ */
+ if (len == 4 &&
+ addr[0] == 0 && addr[1] == 0 &&
+ addr[2] == 0 && addr[3] == 0)
+ continue;
+
+ XdmcpRegisterConnection (family, (char *)addr, len);
+
+#if defined(IPv6) && defined(AF_INET6)
+ /* IPv6 doesn't support broadcasting, so we drop out here */
+ if (family == FamilyInternet6)
+ continue;
+#endif
+
+ broad_addr = IFR_IFR_ADDR;
+
+ ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
+ htonl (INADDR_BROADCAST);
+#if defined(USE_SIOCGLIFCONF) && defined(SIOCGLIFBRDADDR)
+ {
+ struct lifreq broad_req;
+
+ broad_req = *ifr;
+ if (ioctl (fd, SIOCGLIFFLAGS, (char *) &broad_req) != -1 &&
+ (broad_req.lifr_flags & IFF_BROADCAST) &&
+ (broad_req.lifr_flags & IFF_UP)
+ )
+ {
+ broad_req = *ifr;
+ if (ioctl (fd, SIOCGLIFBRDADDR, &broad_req) != -1)
+ broad_addr = broad_req.lifr_broadaddr;
+ else
+ continue;
+ }
+ else
+ continue;
+ }
+
+#elif defined(SIOCGIFBRDADDR)
+ {
+ struct ifreq broad_req;
+
+ broad_req = *ifr;
+ if (ifioctl (fd, SIOCGIFFLAGS, (pointer) &broad_req) != -1 &&
+ (broad_req.ifr_flags & IFF_BROADCAST) &&
+ (broad_req.ifr_flags & IFF_UP)
+ )
+ {
+ broad_req = *ifr;
+ if (ifioctl (fd, SIOCGIFBRDADDR, (pointer) &broad_req) != -1)
+ broad_addr = broad_req.ifr_addr;
+ else
+ continue;
+ }
+ else
+ continue;
+ }
+#endif /* SIOCGIFBRDADDR */
+#ifdef DEF_SELF_DEBUG
+ ErrorF("Xserver: DefineSelf(): ifname = %s, baddr = %s\n",
+ IFR_IFR_NAME,
+ inet_ntoa(((struct sockaddr_in *) &broad_addr)->sin_addr));
+#endif /* DEF_SELF_DEBUG */
+ XdmcpRegisterBroadcastAddress ((struct sockaddr_in *) &broad_addr);
+ }
+#endif /* XDMCP */
+ }
+ if (bufptr != buf)
+ free(bufptr);
+#else /* HAS_GETIFADDRS */
+ if (getifaddrs(&ifap) < 0) {
+ ErrorF("Warning: getifaddrs returns %s\n", strerror(errno));
+ return;
+ }
+ for (ifr = ifap; ifr != NULL; ifr = ifr->ifa_next) {
+#ifdef DNETCONN
+ if (ifr->ifa_addr.sa_family == AF_DECnet)
+ continue;
+#endif /* DNETCONN */
+ len = sizeof(*(ifr->ifa_addr));
+ family = ConvertAddr(ifr->ifa_addr, &len, (pointer *)&addr);
+ if (family == -1 || family == FamilyLocal)
+ continue;
+#if defined(IPv6) && defined(AF_INET6)
+ if (family == FamilyInternet6)
+ in6_fillscopeid((struct sockaddr_in6 *)ifr->ifa_addr);
+#endif
+
+#ifdef DEF_SELF_DEBUG
+ if (family == FamilyInternet)
+ ErrorF("Xserver: DefineSelf(): ifname = %s, addr = %d.%d.%d.%d\n",
+ ifr->ifa_name, addr[0], addr[1], addr[2], addr[3]);
+#if defined(IPv6) && defined(AF_INET6)
+ else if (family == FamilyInternet6) {
+ char cp[INET6_ADDRSTRLEN];
+
+ inet_ntop(AF_INET6, addr, cp, sizeof(cp));
+ ErrorF("Xserver: DefineSelf(): ifname = %s addr = %s\n",
+ ifr->ifa_name, cp);
+ }
+#endif
+#endif /* DEF_SELF_DEBUG */
+ for (host = selfhosts;
+ host != NULL && !addrEqual(family, addr, len, host);
+ host = host->next)
+ ;
+ if (host != NULL)
+ continue;
+ MakeHost(host, len);
+ if (host != NULL) {
+ host->family = family;
+ host->len = len;
+ acopy(addr, host->addr, len);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
+#ifdef XDMCP
+ {
+ struct sockaddr broad_addr;
+ /*
+ * If this isn't an Internet Address, don't register it.
+ */
+ if (family != FamilyInternet
+#if defined(IPv6) && defined(AF_INET6)
+ && family != FamilyInternet6
+#endif
+ )
+ continue;
+
+ /*
+ * ignore 'localhost' entries as they're not useful
+ * on the other end of the wire
+ */
+ if (ifr->ifa_flags & IFF_LOOPBACK)
+ continue;
+
+ if (family == FamilyInternet &&
+ addr[0] == 127 && addr[1] == 0 &&
+ addr[2] == 0 && addr[3] == 1)
+ continue;
+
+ /*
+ * Ignore '0.0.0.0' entries as they are
+ * returned by some OSes for unconfigured NICs but they are
+ * not useful on the other end of the wire.
+ */
+ if (len == 4 &&
+ addr[0] == 0 && addr[1] == 0 &&
+ addr[2] == 0 && addr[3] == 0)
+ continue;
+#if defined(IPv6) && defined(AF_INET6)
+ else if (family == FamilyInternet6 &&
+ IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr))
+ continue;
+#endif
+ XdmcpRegisterConnection(family, (char *)addr, len);
+#if defined(IPv6) && defined(AF_INET6)
+ if (family == FamilyInternet6)
+ /* IPv6 doesn't support broadcasting, so we drop out here */
+ continue;
+#endif
+ if ((ifr->ifa_flags & IFF_BROADCAST) &&
+ (ifr->ifa_flags & IFF_UP))
+ broad_addr = *ifr->ifa_broadaddr;
+ else
+ continue;
+#ifdef DEF_SELF_DEBUG
+ ErrorF("Xserver: DefineSelf(): ifname = %s, baddr = %s\n",
+ ifr->ifa_name,
+ inet_ntoa(((struct sockaddr_in *) &broad_addr)->sin_addr));
+#endif /* DEF_SELF_DEBUG */
+ XdmcpRegisterBroadcastAddress((struct sockaddr_in *)
+ &broad_addr);
+ }
+#endif /* XDMCP */
+
+ } /* for */
+ freeifaddrs(ifap);
+#endif /* HAS_GETIFADDRS */
+
+ /*
+ * add something of FamilyLocalHost
+ */
+ for (host = selfhosts;
+ host && !addrEqual(FamilyLocalHost, "", 0, host);
+ host = host->next);
+ if (!host)
+ {
+ MakeHost(host, 0);
+ if (host)
+ {
+ host->family = FamilyLocalHost;
+ host->len = 0;
+ acopy("", host->addr, 0);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
+ }
+}
+#endif /* hpux && !HAS_IFREQ */
+#endif /* WINTCP */
+
+#ifdef XDMCP
+void
+AugmentSelf(pointer from, int len)
+{
+ int family;
+ pointer addr;
+ register HOST *host;
+
+ family = ConvertAddr(from, &len, (pointer *)&addr);
+ if (family == -1 || family == FamilyLocal)
+ return;
+ for (host = selfhosts; host; host = host->next)
+ {
+ if (addrEqual(family, addr, len, host))
+ return;
+ }
+ MakeHost(host,len)
+ if (!host)
+ return;
+ host->family = family;
+ host->len = len;
+ acopy(addr, host->addr, len);
+ host->next = selfhosts;
+ selfhosts = host;
+}
+#endif
+
+void
+AddLocalHosts (void)
+{
+ HOST *self;
+
+ for (self = selfhosts; self; self = self->next)
+ /* Fix for XFree86 bug #156: pass addingLocal = TRUE to
+ * NewHost to tell that we are adding the default local
+ * host entries and not to flag the entries as being
+ * explicitely requested */
+ (void) NewHost (self->family, self->addr, self->len, TRUE);
+}
+
+/* Reset access control list to initial hosts */
+void
+ResetHosts (char *display)
+{
+ register HOST *host;
+ char lhostname[120], ohostname[120];
+ char *hostname = ohostname;
+ char fname[PATH_MAX + 1];
+ int fnamelen;
+ FILE *fd;
+ char *ptr;
+ int i, hostlen;
+#if ((defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)) && \
+ (!defined(IPv6) || !defined(AF_INET6))) || defined(DNETCONN)
+ union {
+ struct sockaddr sa;
+#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
+ struct sockaddr_in in;
+#endif /* TCPCONN || STREAMSCONN */
+#ifdef DNETCONN
+ struct sockaddr_dn dn;
+#endif
+ } saddr;
+#endif
+#ifdef DNETCONN
+ struct nodeent *np;
+ struct dn_naddr dnaddr, *dnaddrp, *dnet_addr();
+#endif
+#ifdef K5AUTH
+ krb5_principal princ;
+ krb5_data kbuf;
+#endif
+ int family = 0;
+ pointer addr;
+ int len;
+
+ siTypesInitialize();
+ AccessEnabled = defeatAccessControl ? FALSE : DEFAULT_ACCESS_CONTROL;
+ LocalHostEnabled = FALSE;
+ while ((host = validhosts) != 0)
+ {
+ validhosts = host->next;
+ FreeHost (host);
+ }
+
+#define ETC_HOST_PREFIX "/etc/X"
+#define ETC_HOST_SUFFIX ".hosts"
+ fnamelen = strlen(ETC_HOST_PREFIX) + strlen(ETC_HOST_SUFFIX) +
+ strlen(display) + 1;
+ if (fnamelen > sizeof(fname))
+ FatalError("Display name `%s' is too long\n", display);
+ sprintf(fname, ETC_HOST_PREFIX "%s" ETC_HOST_SUFFIX, display);
+#ifdef __UNIXOS2__
+ strcpy(fname, (char*)__XOS2RedirRoot(fname));
+#endif /* __UNIXOS2__ */
+
+ if ((fd = fopen (fname, "r")) != 0)
+ {
+ while (fgets (ohostname, sizeof (ohostname), fd))
+ {
+ family = FamilyWild;
+ if (*ohostname == '#')
+ continue;
+ if ((ptr = strchr(ohostname, '\n')) != 0)
+ *ptr = 0;
+#ifdef __UNIXOS2__
+ if ((ptr = strchr(ohostname, '\r')) != 0)
+ *ptr = 0;
+#endif
+ hostlen = strlen(ohostname) + 1;
+ for (i = 0; i < hostlen; i++)
+ lhostname[i] = tolower(ohostname[i]);
+ hostname = ohostname;
+ if (!strncmp("local:", lhostname, 6))
+ {
+ family = FamilyLocalHost;
+ NewHost(family, "", 0, FALSE);
+ LocalHostRequested = TRUE; /* Fix for XFree86 bug #156 */
+ }
+#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
+ else if (!strncmp("inet:", lhostname, 5))
+ {
+ family = FamilyInternet;
+ hostname = ohostname + 5;
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ else if (!strncmp("inet6:", lhostname, 6))
+ {
+ family = FamilyInternet6;
+ hostname = ohostname + 6;
+ }
+#endif
+#endif
+#ifdef DNETCONN
+ else if (!strncmp("dnet:", lhostname, 5))
+ {
+ family = FamilyDECnet;
+ hostname = ohostname + 5;
+ }
+#endif
+#ifdef SECURE_RPC
+ else if (!strncmp("nis:", lhostname, 4))
+ {
+ family = FamilyNetname;
+ hostname = ohostname + 4;
+ }
+#endif
+#ifdef K5AUTH
+ else if (!strncmp("krb:", lhostname, 4))
+ {
+ family = FamilyKrb5Principal;
+ hostname = ohostname + 4;
+ }
+#endif
+ else if (!strncmp("si:", lhostname, 3))
+ {
+ family = FamilyServerInterpreted;
+ hostname = ohostname + 3;
+ hostlen -= 3;
+ }
+
+
+ if (family == FamilyServerInterpreted)
+ {
+ len = siCheckAddr(hostname, hostlen);
+ if (len >= 0) {
+ NewHost(family, hostname, len, FALSE);
+ }
+ }
+ else
+#ifdef DNETCONN
+ if ((family == FamilyDECnet) || ((family == FamilyWild) &&
+ (ptr = strchr(hostname, ':')) && (*(ptr + 1) == ':') &&
+ !(*ptr = '\0'))) /* bash trailing colons if necessary */
+ {
+ /* node name (DECnet names end in "::") */
+ dnaddrp = dnet_addr(hostname);
+ if (!dnaddrp && (np = getnodebyname (hostname)))
+ {
+ /* node was specified by name */
+ saddr.sa.sa_family = np->n_addrtype;
+ len = sizeof(saddr.sa);
+ if (ConvertAddr (&saddr.sa, &len, (pointer *)&addr) == FamilyDECnet)
+ {
+ bzero ((char *) &dnaddr, sizeof (dnaddr));
+ dnaddr.a_len = np->n_length;
+ acopy (np->n_addr, dnaddr.a_addr, np->n_length);
+ dnaddrp = &dnaddr;
+ }
+ }
+ if (dnaddrp)
+ (void) NewHost(FamilyDECnet, (pointer)dnaddrp,
+ (int)(dnaddrp->a_len + sizeof(dnaddrp->a_len)), FALSE);
+ }
+ else
+#endif /* DNETCONN */
+#ifdef K5AUTH
+ if (family == FamilyKrb5Principal)
+ {
+ krb5_parse_name(hostname, &princ);
+ XauKrb5Encode(princ, &kbuf);
+ (void) NewHost(FamilyKrb5Principal, kbuf.data, kbuf.length, FALSE);
+ krb5_free_principal(princ);
+ }
+ else
+#endif
+#ifdef SECURE_RPC
+ if ((family == FamilyNetname) || (strchr(hostname, '@')))
+ {
+ SecureRPCInit ();
+ (void) NewHost (FamilyNetname, hostname, strlen (hostname), FALSE);
+ }
+ else
+#endif /* SECURE_RPC */
+#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
+ {
+#if defined(IPv6) && defined(AF_INET6)
+ if ( (family == FamilyInternet) || (family == FamilyInternet6) ||
+ (family == FamilyWild) )
+ {
+ struct addrinfo *addresses;
+ struct addrinfo *a;
+ int f;
+
+ if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) {
+ for (a = addresses ; a != NULL ; a = a->ai_next) {
+ len = a->ai_addrlen;
+ f = ConvertAddr(a->ai_addr,&len,(pointer *)&addr);
+ if ( (family == f) ||
+ ((family == FamilyWild) && (f != -1)) ) {
+ NewHost(f, addr, len, FALSE);
+ }
+ }
+ freeaddrinfo(addresses);
+ }
+ }
+#else
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+ register struct hostent *hp;
+
+ /* host name */
+ if ((family == FamilyInternet &&
+ ((hp = _XGethostbyname(hostname, hparams)) != 0)) ||
+ ((hp = _XGethostbyname(hostname, hparams)) != 0))
+ {
+ saddr.sa.sa_family = hp->h_addrtype;
+ len = sizeof(saddr.sa);
+ if ((family = ConvertAddr (&saddr.sa, &len, (pointer *)&addr)) != -1)
+ {
+#ifdef h_addr /* new 4.3bsd version of gethostent */
+ char **list;
+
+ /* iterate over the addresses */
+ for (list = hp->h_addr_list; *list; list++)
+ (void) NewHost (family, (pointer)*list, len, FALSE);
+#else
+ (void) NewHost (family, (pointer)hp->h_addr, len, FALSE);
+#endif
+ }
+ }
+#endif /* IPv6 */
+ }
+#endif /* TCPCONN || STREAMSCONN */
+ family = FamilyWild;
+ }
+ fclose (fd);
+ }
+}
+
+/* Is client on the local host */
+Bool LocalClient(ClientPtr client)
+{
+ int alen, family, notused;
+ Xtransaddr *from = NULL;
+ pointer addr;
+ register HOST *host;
+
+#ifdef XCSECURITY
+ /* untrusted clients can't change host access */
+ if (client->trustLevel != XSecurityClientTrusted)
+ {
+ SecurityAudit("client %d attempted to change host access\n",
+ client->index);
+ return FALSE;
+ }
+#endif
+#ifdef LBX
+ if (!((OsCommPtr)client->osPrivate)->trans_conn)
+ return FALSE;
+#endif
+ if (!_XSERVTransGetPeerAddr (((OsCommPtr)client->osPrivate)->trans_conn,
+ &notused, &alen, &from))
+ {
+ family = ConvertAddr ((struct sockaddr *) from,
+ &alen, (pointer *)&addr);
+ if (family == -1)
+ {
+ xfree ((char *) from);
+ return FALSE;
+ }
+ if (family == FamilyLocal)
+ {
+ xfree ((char *) from);
+ return TRUE;
+ }
+ for (host = selfhosts; host; host = host->next)
+ {
+ if (addrEqual (family, addr, alen, host))
+ return TRUE;
+ }
+ xfree ((char *) from);
+ }
+ return FALSE;
+}
+
+/*
+ * Return the uid and gid of a connected local client
+ * or the uid/gid for nobody those ids cannot be determined
+ *
+ * Used by XShm to test access rights to shared memory segments
+ */
+int
+LocalClientCred(ClientPtr client, int *pUid, int *pGid)
+{
+ return LocalClientCredAndGroups(client, pUid, pGid, NULL, NULL);
+}
+
+/*
+ * Return the uid and all gids of a connected local client
+ * or the uid/gid for nobody those ids cannot be determined
+ *
+ * If the caller passes non-NULL values for pSuppGids & nSuppGids,
+ * they are responsible for calling XFree(*pSuppGids) to release the
+ * memory allocated for the supplemental group ids list.
+ *
+ * Used by localuser & localgroup ServerInterpreted access control forms below
+ */
+int
+LocalClientCredAndGroups(ClientPtr client, int *pUid, int *pGid,
+ int **pSuppGids, int *nSuppGids)
+{
+#if defined(HAS_GETPEEREID) || defined(HAS_GETPEERUCRED) || defined(SO_PEERCRED)
+ int fd;
+ XtransConnInfo ci;
+#ifdef HAS_GETPEEREID
+ uid_t uid;
+ gid_t gid;
+#elif defined(HAS_GETPEERUCRED)
+ ucred_t *peercred = NULL;
+#elif defined(SO_PEERCRED)
+ struct ucred peercred;
+ socklen_t so_len = sizeof(peercred);
+#endif
+
+ if (client == NULL)
+ return -1;
+ ci = ((OsCommPtr)client->osPrivate)->trans_conn;
+#if !(defined(sun) && defined(HAS_GETPEERUCRED))
+ /* Most implementations can only determine peer credentials for Unix
+ * domain sockets - Solaris getpeerucred can work with a bit more, so
+ * we just let it tell us if the connection type is supported or not
+ */
+ if (!_XSERVTransIsLocal(ci)) {
+ return -1;
+ }
+#endif
+
+ if (pSuppGids != NULL)
+ *pSuppGids = NULL;
+ if (nSuppGids != NULL)
+ *nSuppGids = 0;
+
+ fd = _XSERVTransGetConnectionNumber(ci);
+#ifdef HAS_GETPEEREID
+ if (getpeereid(fd, &uid, &gid) == -1)
+ return -1;
+ if (pUid != NULL)
+ *pUid = uid;
+ if (pGid != NULL)
+ *pGid = gid;
+ return 0;
+#elif defined(HAS_GETPEERUCRED)
+ if (getpeerucred(fd, &peercred) < 0)
+ return -1;
+#ifdef sun /* Ensure process is in the same zone */
+ if (getzoneid() != ucred_getzoneid(peercred)) {
+ ucred_free(peercred);
+ return -1;
+ }
+#endif
+ if (pUid != NULL)
+ *pUid = ucred_geteuid(peercred);
+ if (pGid != NULL)
+ *pGid = ucred_getegid(peercred);
+ if (pSuppGids != NULL && nSuppGids != NULL) {
+ const gid_t *gids;
+ *nSuppGids = ucred_getgroups(peercred, &gids);
+ if (*nSuppGids > 0) {
+ *pSuppGids = xalloc(sizeof(int) * (*nSuppGids));
+ if (*pSuppGids == NULL) {
+ *nSuppGids = 0;
+ } else {
+ int i;
+ for (i = 0 ; i < *nSuppGids; i++) {
+ (*pSuppGids)[i] = (int) gids[i];
+ }
+ }
+ }
+ }
+ ucred_free(peercred);
+ return 0;
+#elif defined(SO_PEERCRED)
+ if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &peercred, &so_len) == -1)
+ return -1;
+ if (pUid != NULL)
+ *pUid = peercred.uid;
+ if (pGid != NULL)
+ *pGid = peercred.gid;
+ return 0;
+#endif
+#else
+ /* No system call available to get the credentials of the peer */
+#define NO_LOCAL_CLIENT_CRED
+ return -1;
+#endif
+}
+
+static Bool
+AuthorizedClient(ClientPtr client)
+{
+ if (!client || defeatAccessControl)
+ return TRUE;
+ return LocalClient(client);
+}
+
+/* Add a host to the access control list. This is the external interface
+ * called from the dispatcher */
+
+int
+AddHost (ClientPtr client,
+ int family,
+ unsigned length, /* of bytes in pAddr */
+ pointer pAddr)
+{
+ int len;
+
+ if (!AuthorizedClient(client))
+ return(BadAccess);
+ switch (family) {
+ case FamilyLocalHost:
+ len = length;
+ LocalHostEnabled = TRUE;
+ break;
+#ifdef K5AUTH
+ case FamilyKrb5Principal:
+ len = length;
+ break;
+#endif
+#ifdef SECURE_RPC
+ case FamilyNetname:
+ len = length;
+ SecureRPCInit ();
+ break;
+#endif
+ case FamilyInternet:
+#if defined(IPv6) && defined(AF_INET6)
+ case FamilyInternet6:
+#endif
+ case FamilyDECnet:
+ case FamilyChaos:
+ case FamilyServerInterpreted:
+ if ((len = CheckAddr (family, pAddr, length)) < 0)
+ {
+ client->errorValue = length;
+ return (BadValue);
+ }
+ break;
+ case FamilyLocal:
+ default:
+ client->errorValue = family;
+ return (BadValue);
+ }
+ if (NewHost (family, pAddr, len, FALSE))
+ return Success;
+ return BadAlloc;
+}
+
+Bool
+ForEachHostInFamily (int family,
+ Bool (*func)(
+ unsigned char * /* addr */,
+ short /* len */,
+ pointer /* closure */),
+ pointer closure)
+{
+ HOST *host;
+
+ for (host = validhosts; host; host = host->next)
+ if (family == host->family && func (host->addr, host->len, closure))
+ return TRUE;
+ return FALSE;
+}
+
+/* Add a host to the access control list. This is the internal interface
+ * called when starting or resetting the server */
+static Bool
+NewHost (int family,
+ pointer addr,
+ int len,
+ int addingLocalHosts)
+{
+ register HOST *host;
+
+ for (host = validhosts; host; host = host->next)
+ {
+ if (addrEqual (family, addr, len, host))
+ return TRUE;
+ }
+ if (!addingLocalHosts) { /* Fix for XFree86 bug #156 */
+ for (host = selfhosts; host; host = host->next) {
+ if (addrEqual (family, addr, len, host)) {
+ host->requested = TRUE;
+ break;
+ }
+ }
+ }
+ MakeHost(host,len)
+ if (!host)
+ return FALSE;
+ host->family = family;
+ host->len = len;
+ acopy(addr, host->addr, len);
+ host->next = validhosts;
+ validhosts = host;
+ return TRUE;
+}
+
+/* Remove a host from the access control list */
+
+int
+RemoveHost (
+ ClientPtr client,
+ int family,
+ unsigned length, /* of bytes in pAddr */
+ pointer pAddr)
+{
+ int len;
+ register HOST *host, **prev;
+
+ if (!AuthorizedClient(client))
+ return(BadAccess);
+ switch (family) {
+ case FamilyLocalHost:
+ len = length;
+ LocalHostEnabled = FALSE;
+ break;
+#ifdef K5AUTH
+ case FamilyKrb5Principal:
+ len = length;
+ break;
+#endif
+#ifdef SECURE_RPC
+ case FamilyNetname:
+ len = length;
+ break;
+#endif
+ case FamilyInternet:
+#if defined(IPv6) && defined(AF_INET6)
+ case FamilyInternet6:
+#endif
+ case FamilyDECnet:
+ case FamilyChaos:
+ case FamilyServerInterpreted:
+ if ((len = CheckAddr (family, pAddr, length)) < 0)
+ {
+ client->errorValue = length;
+ return(BadValue);
+ }
+ break;
+ case FamilyLocal:
+ default:
+ client->errorValue = family;
+ return(BadValue);
+ }
+ for (prev = &validhosts;
+ (host = *prev) && (!addrEqual (family, pAddr, len, host));
+ prev = &host->next)
+ ;
+ if (host)
+ {
+ *prev = host->next;
+ FreeHost (host);
+ }
+ return (Success);
+}
+
+/* Get all hosts in the access control list */
+int
+GetHosts (
+ pointer *data,
+ int *pnHosts,
+ int *pLen,
+ BOOL *pEnabled)
+{
+ int len;
+ register int n = 0;
+ register unsigned char *ptr;
+ register HOST *host;
+ int nHosts = 0;
+
+ *pEnabled = AccessEnabled ? EnableAccess : DisableAccess;
+ for (host = validhosts; host; host = host->next)
+ {
+ nHosts++;
+ n += (((host->len + 3) >> 2) << 2) + sizeof(xHostEntry);
+ }
+ if (n)
+ {
+ *data = ptr = (pointer) xalloc (n);
+ if (!ptr)
+ {
+ return(BadAlloc);
+ }
+ for (host = validhosts; host; host = host->next)
+ {
+ len = host->len;
+ ((xHostEntry *)ptr)->family = host->family;
+ ((xHostEntry *)ptr)->length = len;
+ ptr += sizeof(xHostEntry);
+ acopy (host->addr, ptr, len);
+ ptr += ((len + 3) >> 2) << 2;
+ }
+ } else {
+ *data = NULL;
+ }
+ *pnHosts = nHosts;
+ *pLen = n;
+ return(Success);
+}
+
+/* Check for valid address family and length, and return address length. */
+
+/*ARGSUSED*/
+static int
+CheckAddr (
+ int family,
+ pointer pAddr,
+ unsigned length)
+{
+ int len;
+
+ switch (family)
+ {
+#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
+ case FamilyInternet:
+ if (length == sizeof (struct in_addr))
+ len = length;
+ else
+ len = -1;
+ break;
+#if defined(IPv6) && defined(AF_INET6)
+ case FamilyInternet6:
+ if (length == sizeof (struct in6_addr))
+ len = length;
+ else
+ len = -1;
+ break;
+#endif
+#endif
+#ifdef DNETCONN
+ case FamilyDECnet:
+ {
+ struct dn_naddr *dnaddr = (struct dn_naddr *) pAddr;
+
+ if ((length < sizeof(dnaddr->a_len)) ||
+ (length < dnaddr->a_len + sizeof(dnaddr->a_len)))
+ len = -1;
+ else
+ len = dnaddr->a_len + sizeof(dnaddr->a_len);
+ if (len > sizeof(struct dn_naddr))
+ len = -1;
+ }
+ break;
+#endif
+ case FamilyServerInterpreted:
+ len = siCheckAddr(pAddr, length);
+ break;
+ default:
+ len = -1;
+ }
+ return (len);
+}
+
+/* Check if a host is not in the access control list.
+ * Returns 1 if host is invalid, 0 if we've found it. */
+
+int
+InvalidHost (
+ register struct sockaddr *saddr,
+ int len,
+ ClientPtr client)
+{
+ int family;
+ pointer addr;
+ register HOST *selfhost, *host;
+
+ if (!AccessEnabled) /* just let them in */
+ return(0);
+ family = ConvertAddr (saddr, &len, (pointer *)&addr);
+ if (family == -1)
+ return 1;
+ if (family == FamilyLocal)
+ {
+ if (!LocalHostEnabled)
+ {
+ /*
+ * check to see if any local address is enabled. This
+ * implicitly enables local connections.
+ */
+ for (selfhost = selfhosts; selfhost; selfhost=selfhost->next)
+ {
+ for (host = validhosts; host; host=host->next)
+ {
+ if (addrEqual (selfhost->family, selfhost->addr,
+ selfhost->len, host))
+ return 0;
+ }
+ }
+ } else
+ return 0;
+ }
+ for (host = validhosts; host; host = host->next)
+ {
+ if ((host->family == FamilyServerInterpreted)) {
+ if (siAddrMatch (family, addr, len, host, client)) {
+ return (0);
+ }
+ } else {
+ if (addrEqual (family, addr, len, host))
+ return (0);
+ }
+
+ }
+ return (1);
+}
+
+static int
+ConvertAddr (
+ register struct sockaddr *saddr,
+ int *len,
+ pointer *addr)
+{
+ if (*len == 0)
+ return (FamilyLocal);
+ switch (saddr->sa_family)
+ {
+ case AF_UNSPEC:
+#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
+ case AF_UNIX:
+#endif
+ return FamilyLocal;
+#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
+ case AF_INET:
+#ifdef WIN32
+ if (16777343 == *(long*)&((struct sockaddr_in *) saddr)->sin_addr)
+ return FamilyLocal;
+#endif
+ *len = sizeof (struct in_addr);
+ *addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr);
+ return FamilyInternet;
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6:
+ {
+ struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) saddr;
+ if (IN6_IS_ADDR_V4MAPPED(&(saddr6->sin6_addr))) {
+ *len = sizeof (struct in_addr);
+ *addr = (pointer) &(saddr6->sin6_addr.s6_addr[12]);
+ return FamilyInternet;
+ } else {
+ *len = sizeof (struct in6_addr);
+ *addr = (pointer) &(saddr6->sin6_addr);
+ return FamilyInternet6;
+ }
+ }
+#endif
+#endif
+#ifdef DNETCONN
+ case AF_DECnet:
+ {
+ struct sockaddr_dn *sdn = (struct sockaddr_dn *) saddr;
+ *len = sdn->sdn_nodeaddrl + sizeof(sdn->sdn_nodeaddrl);
+ *addr = (pointer) &(sdn->sdn_add);
+ }
+ return FamilyDECnet;
+#endif
+#ifdef CHAOSCONN
+ case AF_CHAOS:
+ {
+ not implemented
+ }
+ return FamilyChaos;
+#endif
+ default:
+ return -1;
+ }
+}
+
+int
+ChangeAccessControl(
+ ClientPtr client,
+ int fEnabled)
+{
+ if (!AuthorizedClient(client))
+ return BadAccess;
+ AccessEnabled = fEnabled;
+ return Success;
+}
+
+/* returns FALSE if xhost + in effect, else TRUE */
+int
+GetAccessControl(void)
+{
+ return AccessEnabled;
+}
+
+/*****************************************************************************
+ * FamilyServerInterpreted host entry implementation
+ *
+ * Supports an extensible system of host types which the server can interpret
+ * See the IPv6 extensions to the X11 protocol spec for the definition.
+ *
+ * Currently supported schemes:
+ *
+ * hostname - hostname as defined in IETF RFC 2396
+ * ipv6 - IPv6 literal address as defined in IETF RFC's 3513 and <TBD>
+ *
+ * See xc/doc/specs/SIAddresses for formal definitions of each type.
+ */
+
+/* These definitions and the siTypeAdd function could be exported in the
+ * future to enable loading additional host types, but that was not done for
+ * the initial implementation.
+ */
+typedef Bool (*siAddrMatchFunc)(int family, pointer addr, int len,
+ const char *siAddr, int siAddrlen, ClientPtr client, void *siTypePriv);
+typedef int (*siCheckAddrFunc)(const char *addrString, int length,
+ void *siTypePriv);
+
+struct siType {
+ struct siType * next;
+ const char * typeName;
+ siAddrMatchFunc addrMatch;
+ siCheckAddrFunc checkAddr;
+ void * typePriv; /* Private data for type routines */
+};
+
+static struct siType *siTypeList;
+
+static int
+siTypeAdd(const char *typeName, siAddrMatchFunc addrMatch,
+ siCheckAddrFunc checkAddr, void *typePriv)
+{
+ struct siType *s, *p;
+
+ if ((typeName == NULL) || (addrMatch == NULL) || (checkAddr == NULL))
+ return BadValue;
+
+ for (s = siTypeList, p = NULL; s != NULL ; p = s, s = s->next) {
+ if (strcmp(typeName, s->typeName) == 0) {
+ s->addrMatch = addrMatch;
+ s->checkAddr = checkAddr;
+ s->typePriv = typePriv;
+ return Success;
+ }
+ }
+
+ s = (struct siType *) xalloc(sizeof(struct siType));
+ if (s == NULL)
+ return BadAlloc;
+
+ if (p == NULL)
+ siTypeList = s;
+ else
+ p->next = s;
+
+ s->next = NULL;
+ s->typeName = typeName;
+ s->addrMatch = addrMatch;
+ s->checkAddr = checkAddr;
+ s->typePriv = typePriv;
+ return Success;
+}
+
+/* Checks to see if a host matches a server-interpreted host entry */
+static Bool
+siAddrMatch(int family, pointer addr, int len, HOST *host, ClientPtr client)
+{
+ Bool matches = FALSE;
+ struct siType *s;
+ const char *valueString;
+ int addrlen;
+
+ valueString = (const char *) memchr(host->addr, '\0', host->len);
+ if (valueString != NULL) {
+ for (s = siTypeList; s != NULL ; s = s->next) {
+ if (strcmp((char *) host->addr, s->typeName) == 0) {
+ addrlen = host->len - (strlen((char *)host->addr) + 1);
+ matches = s->addrMatch(family, addr, len,
+ valueString + 1, addrlen, client, s->typePriv);
+ break;
+ }
+ }
+#ifdef FAMILY_SI_DEBUG
+ ErrorF(
+ "Xserver: siAddrMatch(): type = %s, value = %*.*s -- %s\n",
+ host->addr, addrlen, addrlen, valueString + 1,
+ (matches) ? "accepted" : "rejected");
+#endif
+ }
+ return matches;
+}
+
+static int
+siCheckAddr(const char *addrString, int length)
+{
+ const char *valueString;
+ int addrlen, typelen;
+ int len = -1;
+ struct siType *s;
+
+ /* Make sure there is a \0 byte inside the specified length
+ to separate the address type from the address value. */
+ valueString = (const char *) memchr(addrString, '\0', length);
+ if (valueString != NULL) {
+ /* Make sure the first string is a recognized address type,
+ * and the second string is a valid address of that type.
+ */
+ typelen = strlen(addrString) + 1;
+ addrlen = length - typelen;
+
+ for (s = siTypeList; s != NULL ; s = s->next) {
+ if (strcmp(addrString, s->typeName) == 0) {
+ len = s->checkAddr(valueString + 1, addrlen, s->typePriv);
+ if (len >= 0) {
+ len += typelen;
+ }
+ break;
+ }
+ }
+#ifdef FAMILY_SI_DEBUG
+ {
+ const char *resultMsg;
+
+ if (s == NULL) {
+ resultMsg = "type not registered";
+ } else {
+ if (len == -1)
+ resultMsg = "rejected";
+ else
+ resultMsg = "accepted";
+ }
+
+ ErrorF("Xserver: siCheckAddr(): type = %s, value = %*.*s, len = %d -- %s\n",
+ addrString, addrlen, addrlen, valueString + 1, len, resultMsg);
+ }
+#endif
+ }
+ return len;
+}
+
+
+/***
+ * Hostname server-interpreted host type
+ *
+ * Stored as hostname string, explicitly defined to be resolved ONLY
+ * at access check time, to allow for hosts with dynamic addresses
+ * but static hostnames, such as found in some DHCP & mobile setups.
+ *
+ * Hostname must conform to IETF RFC 2396 sec. 3.2.2, which defines it as:
+ * hostname = *( domainlabel "." ) toplabel [ "." ]
+ * domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
+ * toplabel = alpha | alpha *( alphanum | "-" ) alphanum
+ */
+
+#ifdef NI_MAXHOST
+# define SI_HOSTNAME_MAXLEN NI_MAXHOST
+#else
+# ifdef MAXHOSTNAMELEN
+# define SI_HOSTNAME_MAXLEN MAXHOSTNAMELEN
+# else
+# define SI_HOSTNAME_MAXLEN 256
+# endif
+#endif
+
+static Bool
+siHostnameAddrMatch(int family, pointer addr, int len,
+ const char *siAddr, int siAddrLen, ClientPtr client, void *typePriv)
+{
+ Bool res = FALSE;
+
+/* Currently only supports checking against IPv4 & IPv6 connections, but
+ * support for other address families, such as DECnet, could be added if
+ * desired.
+ */
+#if defined(IPv6) && defined(AF_INET6)
+ if ((family == FamilyInternet) || (family == FamilyInternet6)) {
+ char hostname[SI_HOSTNAME_MAXLEN];
+ struct addrinfo *addresses;
+ struct addrinfo *a;
+ int f, hostaddrlen;
+ pointer hostaddr;
+
+ if (siAddrLen >= sizeof(hostname))
+ return FALSE;
+
+ strncpy(hostname, siAddr, siAddrLen);
+ hostname[siAddrLen] = '\0';
+
+ if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) {
+ for (a = addresses ; a != NULL ; a = a->ai_next) {
+ hostaddrlen = a->ai_addrlen;
+ f = ConvertAddr(a->ai_addr,&hostaddrlen,&hostaddr);
+ if ((f == family) && (len == hostaddrlen) &&
+ (acmp (addr, hostaddr, len) == 0) ) {
+ res = TRUE;
+ break;
+ }
+ }
+ freeaddrinfo(addresses);
+ }
+ }
+#else /* IPv6 not supported, use gethostbyname instead for IPv4 */
+ if (family == FamilyInternet) {
+ register struct hostent *hp;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+ char hostname[SI_HOSTNAME_MAXLEN];
+ int f, hostaddrlen;
+ pointer hostaddr;
+ const char **addrlist;
+
+ if (siAddrLen >= sizeof(hostname))
+ return FALSE;
+
+ strncpy(hostname, siAddr, siAddrLen);
+ hostname[siAddrLen] = '\0';
+
+ if ((hp = _XGethostbyname(hostname, hparams)) != NULL) {
+#ifdef h_addr /* new 4.3bsd version of gethostent */
+ /* iterate over the addresses */
+ for (addrlist = hp->h_addr_list; *addrlist; addrlist++)
+#else
+ addrlist = &hp->h_addr;
+#endif
+ {
+ struct sockaddr_in sin;
+
+ sin.sin_family = hp->h_addrtype;
+ acopy ( *addrlist, &(sin.sin_addr), hp->h_length);
+ hostaddrlen = sizeof(sin);
+ f = ConvertAddr ((struct sockaddr *)&sin,
+ &hostaddrlen, &hostaddr);
+ if ((f == family) && (len == hostaddrlen) &&
+ (acmp (addr, hostaddr, len) == 0) ) {
+ res = TRUE;
+ break;
+ }
+ }
+ }
+ }
+#endif
+ return res;
+}
+
+
+static int
+siHostnameCheckAddr(const char *valueString, int length, void *typePriv)
+{
+ /* Check conformance of hostname to RFC 2396 sec. 3.2.2 definition.
+ * We do not use ctype functions here to avoid locale-specific
+ * character sets. Hostnames must be pure ASCII.
+ */
+ int len = length;
+ int i;
+ Bool dotAllowed = FALSE;
+ Bool dashAllowed = FALSE;
+
+ if ((length <= 0) || (length >= SI_HOSTNAME_MAXLEN)) {
+ len = -1;
+ } else {
+ for (i = 0; i < length; i++) {
+ char c = valueString[i];
+
+ if (c == 0x2E) { /* '.' */
+ if (dotAllowed == FALSE) {
+ len = -1;
+ break;
+ } else {
+ dotAllowed = FALSE;
+ dashAllowed = FALSE;
+ }
+ } else if (c == 0x2D) { /* '-' */
+ if (dashAllowed == FALSE) {
+ len = -1;
+ break;
+ } else {
+ dotAllowed = FALSE;
+ }
+ } else if (((c >= 0x30) && (c <= 0x3A)) /* 0-9 */ ||
+ ((c >= 0x61) && (c <= 0x7A)) /* a-z */ ||
+ ((c >= 0x41) && (c <= 0x5A)) /* A-Z */) {
+ dotAllowed = TRUE;
+ dashAllowed = TRUE;
+ } else { /* Invalid character */
+ len = -1;
+ break;
+ }
+ }
+ }
+ return len;
+}
+
+#if defined(IPv6) && defined(AF_INET6)
+/***
+ * "ipv6" server interpreted type
+ *
+ * Currently supports only IPv6 literal address as specified in IETF RFC 3513
+ *
+ * Once draft-ietf-ipv6-scoping-arch-00.txt becomes an RFC, support will be
+ * added for the scoped address format it specifies.
+ */
+
+/* Maximum length of an IPv6 address string - increase when adding support
+ * for scoped address qualifiers. Includes room for trailing NUL byte.
+ */
+#define SI_IPv6_MAXLEN INET6_ADDRSTRLEN
+
+static Bool
+siIPv6AddrMatch(int family, pointer addr, int len,
+ const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv)
+{
+ struct in6_addr addr6;
+ char addrbuf[SI_IPv6_MAXLEN];
+
+ if ((family != FamilyInternet6) || (len != sizeof(addr6)))
+ return FALSE;
+
+ memcpy(addrbuf, siAddr, siAddrlen);
+ addrbuf[siAddrlen] = '\0';
+
+ if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) {
+ perror("inet_pton");
+ return FALSE;
+ }
+
+ if (memcmp(addr, &addr6, len) == 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+static int
+siIPv6CheckAddr(const char *addrString, int length, void *typePriv)
+{
+ int len;
+
+ /* Minimum length is 3 (smallest legal address is "::1") */
+ if (length < 3) {
+ /* Address is too short! */
+ len = -1;
+ } else if (length >= SI_IPv6_MAXLEN) {
+ /* Address is too long! */
+ len = -1;
+ } else {
+ /* Assume inet_pton is sufficient validation */
+ struct in6_addr addr6;
+ char addrbuf[SI_IPv6_MAXLEN];
+
+ memcpy(addrbuf, addrString, length);
+ addrbuf[length] = '\0';
+
+ if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) {
+ perror("inet_pton");
+ len = -1;
+ } else {
+ len = length;
+ }
+ }
+ return len;
+}
+#endif /* IPv6 */
+
+#if !defined(NO_LOCAL_CLIENT_CRED)
+/***
+ * "localuser" & "localgroup" server interpreted types
+ *
+ * Allows local connections from a given local user or group
+ */
+
+#include <pwd.h>
+#include <grp.h>
+
+#define LOCAL_USER 1
+#define LOCAL_GROUP 2
+
+typedef struct {
+ int credType;
+} siLocalCredPrivRec, *siLocalCredPrivPtr;
+
+static siLocalCredPrivRec siLocalUserPriv = { LOCAL_USER };
+static siLocalCredPrivRec siLocalGroupPriv = { LOCAL_GROUP };
+
+static Bool
+siLocalCredGetId(const char *addr, int len, siLocalCredPrivPtr lcPriv, int *id)
+{
+ Bool parsedOK = FALSE;
+ char *addrbuf = xalloc(len + 1);
+
+ if (addrbuf == NULL) {
+ return FALSE;
+ }
+
+ memcpy(addrbuf, addr, len);
+ addrbuf[len] = '\0';
+
+ if (addr[0] == '#') { /* numeric id */
+ char *cp;
+ errno = 0;
+ *id = strtol(addrbuf + 1, &cp, 0);
+ if ((errno == 0) && (cp != (addrbuf+1))) {
+ parsedOK = TRUE;
+ }
+ } else { /* non-numeric name */
+ if (lcPriv->credType == LOCAL_USER) {
+ struct passwd *pw = getpwnam(addrbuf);
+
+ if (pw != NULL) {
+ *id = (int) pw->pw_uid;
+ parsedOK = TRUE;
+ }
+ } else { /* group */
+ struct group *gr = getgrnam(addrbuf);
+
+ if (gr != NULL) {
+ *id = (int) gr->gr_gid;
+ parsedOK = TRUE;
+ }
+ }
+ }
+
+ xfree(addrbuf);
+ return parsedOK;
+}
+
+static Bool
+siLocalCredAddrMatch(int family, pointer addr, int len,
+ const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv)
+{
+ int connUid, connGid, *connSuppGids, connNumSuppGids, siAddrId;
+ siLocalCredPrivPtr lcPriv = (siLocalCredPrivPtr) typePriv;
+
+ if (LocalClientCredAndGroups(client, &connUid, &connGid,
+ &connSuppGids, &connNumSuppGids) == -1) {
+ return FALSE;
+ }
+
+ if (siLocalCredGetId(siAddr, siAddrlen, lcPriv, &siAddrId) == FALSE) {
+ return FALSE;
+ }
+
+ if (lcPriv->credType == LOCAL_USER) {
+ if (connUid == siAddrId) {
+ return TRUE;
+ }
+ } else {
+ if (connGid == siAddrId) {
+ return TRUE;
+ }
+ if (connSuppGids != NULL) {
+ int i;
+
+ for (i = 0 ; i < connNumSuppGids; i++) {
+ if (connSuppGids[i] == siAddrId) {
+ xfree(connSuppGids);
+ return TRUE;
+ }
+ }
+ xfree(connSuppGids);
+ }
+ }
+ return FALSE;
+}
+
+static int
+siLocalCredCheckAddr(const char *addrString, int length, void *typePriv)
+{
+ int len = length;
+ int id;
+
+ if (siLocalCredGetId(addrString, length,
+ (siLocalCredPrivPtr)typePriv, &id) == FALSE) {
+ len = -1;
+ }
+ return len;
+}
+#endif /* localuser */
+
+static void
+siTypesInitialize(void)
+{
+ siTypeAdd("hostname", siHostnameAddrMatch, siHostnameCheckAddr, NULL);
+#if defined(IPv6) && defined(AF_INET6)
+ siTypeAdd("ipv6", siIPv6AddrMatch, siIPv6CheckAddr, NULL);
+#endif
+#if !defined(NO_LOCAL_CLIENT_CRED)
+ siTypeAdd("localuser", siLocalCredAddrMatch, siLocalCredCheckAddr,
+ &siLocalUserPriv);
+ siTypeAdd("localgroup", siLocalCredAddrMatch, siLocalCredCheckAddr,
+ &siLocalGroupPriv);
+#endif
+}
diff --git a/nx-X11/programs/Xserver/os/auth.c b/nx-X11/programs/Xserver/os/auth.c
new file mode 100644
index 000000000..dc72fe3a2
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/auth.c
@@ -0,0 +1,608 @@
+/* $Xorg: auth.c,v 1.5 2001/02/09 02:05:23 xorgcvs Exp $ */
+/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: auth.c,v 1.13 2003/04/27 21:31:08 herrb Exp $ */
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+/*
+ * authorization hooks for the server
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef K5AUTH
+# include <krb5/krb5.h>
+#endif
+# include <X11/X.h>
+# include <X11/Xauth.h>
+# include "misc.h"
+# include "osdep.h"
+# include "dixstruct.h"
+# include <sys/types.h>
+# include <sys/stat.h>
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+# include <X11/extensions/security.h>
+#endif
+#ifdef WIN32
+#include <X11/Xw32defs.h>
+#endif
+
+struct protocol {
+ unsigned short name_length;
+ char *name;
+ AuthAddCFunc Add; /* new authorization data */
+ AuthCheckFunc Check; /* verify client authorization data */
+ AuthRstCFunc Reset; /* delete all authorization data entries */
+ AuthToIDFunc ToID; /* convert cookie to ID */
+ AuthFromIDFunc FromID; /* convert ID to cookie */
+ AuthRemCFunc Remove; /* remove a specific cookie */
+#ifdef XCSECURITY
+ AuthGenCFunc Generate;
+#endif
+};
+
+static struct protocol protocols[] = {
+{ (unsigned short) 18, "MIT-MAGIC-COOKIE-1",
+ MitAddCookie, MitCheckCookie, MitResetCookie,
+ MitToID, MitFromID, MitRemoveCookie,
+#ifdef XCSECURITY
+ MitGenerateCookie
+#endif
+},
+#ifdef HASXDMAUTH
+{ (unsigned short) 19, "XDM-AUTHORIZATION-1",
+ XdmAddCookie, XdmCheckCookie, XdmResetCookie,
+ XdmToID, XdmFromID, XdmRemoveCookie,
+#ifdef XCSECURITY
+ NULL
+#endif
+},
+#endif
+#ifdef SECURE_RPC
+{ (unsigned short) 9, "SUN-DES-1",
+ SecureRPCAdd, SecureRPCCheck, SecureRPCReset,
+ SecureRPCToID, SecureRPCFromID,SecureRPCRemove,
+#ifdef XCSECURITY
+ NULL
+#endif
+},
+#endif
+#ifdef K5AUTH
+{ (unsigned short) 14, "MIT-KERBEROS-5",
+ K5Add, K5Check, K5Reset,
+ K5ToID, K5FromID, K5Remove,
+#ifdef XCSECURITY
+ NULL
+#endif
+},
+#endif
+#ifdef XCSECURITY
+{ (unsigned short) XSecurityAuthorizationNameLen,
+ XSecurityAuthorizationName,
+ NULL, AuthSecurityCheck, NULL,
+ NULL, NULL, NULL,
+ NULL
+},
+#endif
+};
+
+# define NUM_AUTHORIZATION (sizeof (protocols) /\
+ sizeof (struct protocol))
+
+/*
+ * Initialize all classes of authorization by reading the
+ * specified authorization file
+ */
+
+static char *authorization_file = (char *)NULL;
+
+static Bool ShouldLoadAuth = TRUE;
+
+void
+InitAuthorization (char *file_name)
+{
+#ifdef __sun
+ char * envBuffer;
+#endif
+ authorization_file = file_name;
+#ifdef NX_TRANS_AUTH
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "InitAuthorization: Going to propagate auth file '%s' to the environment.\n",
+ authorization_file);
+#endif
+#ifdef __sun
+ envBuffer = malloc(15+strlen(authorization_file));
+ sprintf(envBuffer,"NX_XAUTHORITY=%s",authorization_file);
+ putenv(envBuffer);
+#else
+ setenv("NX_XAUTHORITY", authorization_file, 1);
+#endif
+#endif
+
+}
+
+static int
+LoadAuthorization (void)
+{
+ FILE *f;
+ Xauth *auth;
+ int i;
+ int count = 0;
+
+ ShouldLoadAuth = FALSE;
+ if (!authorization_file)
+ return 0;
+
+#ifdef NX_TRANS_AUTH
+
+ /*
+ * We think that the way LoadAuthorization() is working is wrong.
+ * It doesn't reset the list of stored authorizations before reading
+ * the new cookies. Our take is that if a new auth file is to be
+ * read, the only cookies that are to be accepted are those that are
+ * in the new file, not those in the file -plus- those that have
+ * been in the file in the past. Furthermore, if the list can't be
+ * read or it is empty, it should assume that it ignores which co-
+ * okies are valid and thus it should disable any access. Your mile-
+ * age can vary. A less draconian approach could be to leave the old
+ * cookies if the file can't be read and remove them only if the
+ * file is empty.
+ *
+ * Adding the cookies without removing the old values for the same
+ * protocol has an important implication. If an user shares the co-
+ * okie with somebody and later wants to revoke the access to the
+ * display, changing the cookie will not work. This is especially
+ * important with NX. For security reasons, after reconnecting the
+ * session to a different display, it is advisable to generate a
+ * new set of cookies, but doing that it is useless with the current
+ * code, as the old cookies are going to be still accepted. On the
+ * same topic, consider that once an user has got access to the X
+ * server, he/she can freely enable host authentication from any
+ * host, so the safe behaviour should be to reset the host based
+ * authenthication at least at reconnection, and keep as valid only
+ * the cookies that are actually in the file. This behaviour would
+ * surely break many applications, among them a SSH connection run
+ * inside a NX session, as ssh -X reads the cookie for the display
+ * only at session startup and does not read the cookies again
+ * when the auth file is changed.
+ *
+ * Another bug (or feature, depending on how you want to consider
+ * it) is that if the authority file contains entries for different
+ * displays (as it is the norm when the authority file is the default
+ * .Xauthority in the user's home), the server will match -any- of
+ * the cookies, even cookies that are not for its own display. This
+ * means that you have be careful when passing an authority file to
+ * nxagent or Xnest and maybe keep separate files for letting nxagent
+ * find the cookie to be used to connect to the remote display and
+ * for letting it find what cookies to accept. If the file is the
+ * same, clients will be able to connect to nxagent with both the
+ * cookies.
+ */
+
+#ifdef NX_TRANS_AUTH_RESET
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "LoadAuthorization: Resetting authorization info.\n");
+ #endif
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].Reset) {
+ (*protocols[i].Reset) ();
+ }
+ }
+
+#endif
+
+#endif /* #ifdef NX_TRANS_AUTH */
+
+ f = Fopen (authorization_file, "r");
+ if (!f)
+ return -1;
+
+ while ((auth = XauReadAuth (f)) != 0) {
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == auth->name_length &&
+ memcmp (protocols[i].name, auth->name, (int) auth->name_length) == 0 &&
+ protocols[i].Add)
+ {
+#ifdef NX_TRANS_AUTH
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "LoadAuthorization: Adding new record from file [%s].\n",
+ authorization_file);
+ #endif
+
+#endif
+ ++count;
+ (*protocols[i].Add) (auth->data_length, auth->data,
+ FakeClientID(0));
+ }
+ }
+ XauDisposeAuth (auth);
+ }
+
+#ifdef NX_TRANS_AUTH
+
+ if (count == 0)
+ {
+ fprintf(stderr, "Warning: No authorization record could be read from file '%s'.\n",
+ authorization_file);
+
+ fprintf(stderr, "Warning: Please, create a valid authorization cookie using the command\n"
+ "Warning: 'xauth -f %s add <display> MIT-MAGIC-COOKIE-1 <cookie>'.\n",
+ authorization_file);
+ }
+
+#endif
+
+#ifdef NX_TRANS_AUTH
+ if (Fclose (f) != 0)
+ {
+ /*
+ * If the Fclose() fails, for example because of a signal,
+ * it's advisable to return the number of protocols read,
+ * if any, or otherwise the server would believe that no
+ * cookie is valid and eventually fall back to host based
+ * authentication. Note anyway that the new code in Check-
+ * Authorization() doesn't care the return value and gives
+ * a chance to the function to check the file at the next
+ * connection.
+ */
+
+ if (count > 0)
+ {
+ return count;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+#else
+ Fclose (f);
+#endif
+ return count;
+}
+
+#ifdef XDMCP
+/*
+ * XdmcpInit calls this function to discover all authorization
+ * schemes supported by the display
+ */
+void
+RegisterAuthorizations (void)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++)
+ XdmcpRegisterAuthorization (protocols[i].name,
+ (int)protocols[i].name_length);
+}
+#endif
+
+XID
+CheckAuthorization (
+ unsigned int name_length,
+ char *name,
+ unsigned int data_length,
+ char *data,
+ ClientPtr client,
+ char **reason) /* failure message. NULL for default msg */
+{
+ int i;
+ struct stat buf;
+ static time_t lastmod = 0;
+
+ #ifndef NX_TRANS_AUTH
+ static Bool loaded = FALSE;
+ #endif
+
+ if (!authorization_file || stat(authorization_file, &buf))
+ {
+ if (lastmod != 0) {
+ lastmod = 0;
+ ShouldLoadAuth = TRUE; /* stat lost, so force reload */
+ }
+ }
+ else if (buf.st_mtime > lastmod)
+ {
+ lastmod = buf.st_mtime;
+ ShouldLoadAuth = TRUE;
+ }
+ if (ShouldLoadAuth)
+ {
+ int loadauth = LoadAuthorization();
+
+ /*
+ * If the authorization file has at least one entry for this server,
+ * disable local host access. (loadauth > 0)
+ *
+ * If there are zero entries (either initially or when the
+ * authorization file is later reloaded), or if a valid
+ * authorization file was never loaded, enable local host access.
+ * (loadauth == 0 || !loaded)
+ *
+ * If the authorization file was loaded initially (with valid
+ * entries for this server), and reloading it later fails, don't
+ * change anything. (loadauth == -1 && loaded)
+ */
+
+#ifdef NX_TRANS_AUTH
+
+ /*
+ * The implementation of CheckAuthorization() was changed. The way
+ * the auth file was handled previously was questionable and could
+ * open the way to a vast array of security problems. There might be
+ * ways for an attacker to prevent the server from reading the file
+ * and it was enough for the server to fail reading the file once
+ * (because of a not blocked signal, for example) to leave the dis-
+ * play open to all the users running a session on the same terminal
+ * server.
+ *
+ * In NX we want to have only two cases: either we have to check an
+ * authorization file or we don't. In the first case we need to do our
+ * best to read the file at any new client access and never fall back
+ * to host based authentication. Falling back to local host access has
+ * no way back, as it will always take precedence over the auth cookie
+ * (unless the user explicitly disables, one by one, all the rules
+ * allowing local access, if and only if he/she becomes aware of the
+ * problem). In the second case we assume that user doesn't care secu-
+ * rity and so allow unrestricted access from the local machine.
+ */
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "CheckAuthorization: Going to set authorization with loadauth [%d].\n",
+ loadauth);
+ #endif
+
+ if (authorization_file)
+ {
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "CheckAuthorization: Disabling local host access.\n");
+ #endif
+
+ DisableLocalHost();
+ }
+ else
+ {
+ /*
+ * Enable host-based authentication only if
+ * the authorization file was not specified
+ * either on the command line or in the env-
+ * ironment.
+ */
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "CheckAuthorization: Enabling local host access.\n");
+ #endif
+
+ EnableLocalHost();
+ }
+
+ /*
+ * Avoid the 'unused variable' warning.
+ */
+
+ loadauth = loadauth;
+
+#else /* #ifdef NX_TRANS_AUTH */
+
+ if (loadauth > 0)
+ {
+ DisableLocalHost(); /* got at least one */
+ loaded = TRUE;
+ }
+ else if (loadauth == 0 || !loaded)
+ EnableLocalHost ();
+
+#endif /* #ifdef NX_TRANS_AUTH */
+ }
+ if (name_length) {
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == name_length &&
+ memcmp (protocols[i].name, name, (int) name_length) == 0)
+ {
+ return (*protocols[i].Check) (data_length, data, client, reason);
+ }
+ *reason = "Protocol not supported by server\n";
+ }
+ } else *reason = "No protocol specified\n";
+ return (XID) ~0L;
+}
+
+void
+ResetAuthorization (void)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++)
+ if (protocols[i].Reset)
+ (*protocols[i].Reset)();
+ ShouldLoadAuth = TRUE;
+}
+
+XID
+AuthorizationToID (
+ unsigned short name_length,
+ char *name,
+ unsigned short data_length,
+ char *data)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == name_length &&
+ memcmp (protocols[i].name, name, (int) name_length) == 0 &&
+ protocols[i].ToID)
+ {
+ return (*protocols[i].ToID) (data_length, data);
+ }
+ }
+ return (XID) ~0L;
+}
+
+int
+AuthorizationFromID (
+ XID id,
+ unsigned short *name_lenp,
+ char **namep,
+ unsigned short *data_lenp,
+ char **datap)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].FromID &&
+ (*protocols[i].FromID) (id, data_lenp, datap)) {
+ *name_lenp = protocols[i].name_length;
+ *namep = protocols[i].name;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int
+RemoveAuthorization (
+ unsigned short name_length,
+ char *name,
+ unsigned short data_length,
+ char *data)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == name_length &&
+ memcmp (protocols[i].name, name, (int) name_length) == 0 &&
+ protocols[i].Remove)
+ {
+ return (*protocols[i].Remove) (data_length, data);
+ }
+ }
+ return 0;
+}
+
+int
+AddAuthorization (unsigned name_length, char *name, unsigned data_length, char *data)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == name_length &&
+ memcmp (protocols[i].name, name, (int) name_length) == 0 &&
+ protocols[i].Add)
+ {
+ return (*protocols[i].Add) (data_length, data, FakeClientID(0));
+ }
+ }
+ return 0;
+}
+
+#ifdef XCSECURITY
+
+XID
+GenerateAuthorization(
+ unsigned name_length,
+ char *name,
+ unsigned data_length,
+ char *data,
+ unsigned *data_length_return,
+ char **data_return)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == name_length &&
+ memcmp (protocols[i].name, name, (int) name_length) == 0 &&
+ protocols[i].Generate)
+ {
+ return (*protocols[i].Generate) (data_length, data,
+ FakeClientID(0), data_length_return, data_return);
+ }
+ }
+ return -1;
+}
+
+/* A random number generator that is more unpredictable
+ than that shipped with some systems.
+ This code is taken from the C standard. */
+
+static unsigned long int next = 1;
+
+static int
+xdm_rand(void)
+{
+ next = next * 1103515245 + 12345;
+ return (unsigned int)(next/65536) % 32768;
+}
+
+static void
+xdm_srand(unsigned int seed)
+{
+ next = seed;
+}
+
+void
+GenerateRandomData (int len, char *buf)
+{
+ static int seed;
+ int value;
+ int i;
+
+ seed += GetTimeInMillis();
+ xdm_srand (seed);
+ for (i = 0; i < len; i++)
+ {
+ value = xdm_rand ();
+ buf[i] ^= (value & 0xff00) >> 8;
+ }
+
+ /* XXX add getrusage, popen("ps -ale") */
+}
+
+#endif /* XCSECURITY */
diff --git a/nx-X11/programs/Xserver/os/auth.c.NX.original b/nx-X11/programs/Xserver/os/auth.c.NX.original
new file mode 100644
index 000000000..dc72fe3a2
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/auth.c.NX.original
@@ -0,0 +1,608 @@
+/* $Xorg: auth.c,v 1.5 2001/02/09 02:05:23 xorgcvs Exp $ */
+/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: auth.c,v 1.13 2003/04/27 21:31:08 herrb Exp $ */
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+/*
+ * authorization hooks for the server
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef K5AUTH
+# include <krb5/krb5.h>
+#endif
+# include <X11/X.h>
+# include <X11/Xauth.h>
+# include "misc.h"
+# include "osdep.h"
+# include "dixstruct.h"
+# include <sys/types.h>
+# include <sys/stat.h>
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+# include <X11/extensions/security.h>
+#endif
+#ifdef WIN32
+#include <X11/Xw32defs.h>
+#endif
+
+struct protocol {
+ unsigned short name_length;
+ char *name;
+ AuthAddCFunc Add; /* new authorization data */
+ AuthCheckFunc Check; /* verify client authorization data */
+ AuthRstCFunc Reset; /* delete all authorization data entries */
+ AuthToIDFunc ToID; /* convert cookie to ID */
+ AuthFromIDFunc FromID; /* convert ID to cookie */
+ AuthRemCFunc Remove; /* remove a specific cookie */
+#ifdef XCSECURITY
+ AuthGenCFunc Generate;
+#endif
+};
+
+static struct protocol protocols[] = {
+{ (unsigned short) 18, "MIT-MAGIC-COOKIE-1",
+ MitAddCookie, MitCheckCookie, MitResetCookie,
+ MitToID, MitFromID, MitRemoveCookie,
+#ifdef XCSECURITY
+ MitGenerateCookie
+#endif
+},
+#ifdef HASXDMAUTH
+{ (unsigned short) 19, "XDM-AUTHORIZATION-1",
+ XdmAddCookie, XdmCheckCookie, XdmResetCookie,
+ XdmToID, XdmFromID, XdmRemoveCookie,
+#ifdef XCSECURITY
+ NULL
+#endif
+},
+#endif
+#ifdef SECURE_RPC
+{ (unsigned short) 9, "SUN-DES-1",
+ SecureRPCAdd, SecureRPCCheck, SecureRPCReset,
+ SecureRPCToID, SecureRPCFromID,SecureRPCRemove,
+#ifdef XCSECURITY
+ NULL
+#endif
+},
+#endif
+#ifdef K5AUTH
+{ (unsigned short) 14, "MIT-KERBEROS-5",
+ K5Add, K5Check, K5Reset,
+ K5ToID, K5FromID, K5Remove,
+#ifdef XCSECURITY
+ NULL
+#endif
+},
+#endif
+#ifdef XCSECURITY
+{ (unsigned short) XSecurityAuthorizationNameLen,
+ XSecurityAuthorizationName,
+ NULL, AuthSecurityCheck, NULL,
+ NULL, NULL, NULL,
+ NULL
+},
+#endif
+};
+
+# define NUM_AUTHORIZATION (sizeof (protocols) /\
+ sizeof (struct protocol))
+
+/*
+ * Initialize all classes of authorization by reading the
+ * specified authorization file
+ */
+
+static char *authorization_file = (char *)NULL;
+
+static Bool ShouldLoadAuth = TRUE;
+
+void
+InitAuthorization (char *file_name)
+{
+#ifdef __sun
+ char * envBuffer;
+#endif
+ authorization_file = file_name;
+#ifdef NX_TRANS_AUTH
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "InitAuthorization: Going to propagate auth file '%s' to the environment.\n",
+ authorization_file);
+#endif
+#ifdef __sun
+ envBuffer = malloc(15+strlen(authorization_file));
+ sprintf(envBuffer,"NX_XAUTHORITY=%s",authorization_file);
+ putenv(envBuffer);
+#else
+ setenv("NX_XAUTHORITY", authorization_file, 1);
+#endif
+#endif
+
+}
+
+static int
+LoadAuthorization (void)
+{
+ FILE *f;
+ Xauth *auth;
+ int i;
+ int count = 0;
+
+ ShouldLoadAuth = FALSE;
+ if (!authorization_file)
+ return 0;
+
+#ifdef NX_TRANS_AUTH
+
+ /*
+ * We think that the way LoadAuthorization() is working is wrong.
+ * It doesn't reset the list of stored authorizations before reading
+ * the new cookies. Our take is that if a new auth file is to be
+ * read, the only cookies that are to be accepted are those that are
+ * in the new file, not those in the file -plus- those that have
+ * been in the file in the past. Furthermore, if the list can't be
+ * read or it is empty, it should assume that it ignores which co-
+ * okies are valid and thus it should disable any access. Your mile-
+ * age can vary. A less draconian approach could be to leave the old
+ * cookies if the file can't be read and remove them only if the
+ * file is empty.
+ *
+ * Adding the cookies without removing the old values for the same
+ * protocol has an important implication. If an user shares the co-
+ * okie with somebody and later wants to revoke the access to the
+ * display, changing the cookie will not work. This is especially
+ * important with NX. For security reasons, after reconnecting the
+ * session to a different display, it is advisable to generate a
+ * new set of cookies, but doing that it is useless with the current
+ * code, as the old cookies are going to be still accepted. On the
+ * same topic, consider that once an user has got access to the X
+ * server, he/she can freely enable host authentication from any
+ * host, so the safe behaviour should be to reset the host based
+ * authenthication at least at reconnection, and keep as valid only
+ * the cookies that are actually in the file. This behaviour would
+ * surely break many applications, among them a SSH connection run
+ * inside a NX session, as ssh -X reads the cookie for the display
+ * only at session startup and does not read the cookies again
+ * when the auth file is changed.
+ *
+ * Another bug (or feature, depending on how you want to consider
+ * it) is that if the authority file contains entries for different
+ * displays (as it is the norm when the authority file is the default
+ * .Xauthority in the user's home), the server will match -any- of
+ * the cookies, even cookies that are not for its own display. This
+ * means that you have be careful when passing an authority file to
+ * nxagent or Xnest and maybe keep separate files for letting nxagent
+ * find the cookie to be used to connect to the remote display and
+ * for letting it find what cookies to accept. If the file is the
+ * same, clients will be able to connect to nxagent with both the
+ * cookies.
+ */
+
+#ifdef NX_TRANS_AUTH_RESET
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "LoadAuthorization: Resetting authorization info.\n");
+ #endif
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].Reset) {
+ (*protocols[i].Reset) ();
+ }
+ }
+
+#endif
+
+#endif /* #ifdef NX_TRANS_AUTH */
+
+ f = Fopen (authorization_file, "r");
+ if (!f)
+ return -1;
+
+ while ((auth = XauReadAuth (f)) != 0) {
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == auth->name_length &&
+ memcmp (protocols[i].name, auth->name, (int) auth->name_length) == 0 &&
+ protocols[i].Add)
+ {
+#ifdef NX_TRANS_AUTH
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "LoadAuthorization: Adding new record from file [%s].\n",
+ authorization_file);
+ #endif
+
+#endif
+ ++count;
+ (*protocols[i].Add) (auth->data_length, auth->data,
+ FakeClientID(0));
+ }
+ }
+ XauDisposeAuth (auth);
+ }
+
+#ifdef NX_TRANS_AUTH
+
+ if (count == 0)
+ {
+ fprintf(stderr, "Warning: No authorization record could be read from file '%s'.\n",
+ authorization_file);
+
+ fprintf(stderr, "Warning: Please, create a valid authorization cookie using the command\n"
+ "Warning: 'xauth -f %s add <display> MIT-MAGIC-COOKIE-1 <cookie>'.\n",
+ authorization_file);
+ }
+
+#endif
+
+#ifdef NX_TRANS_AUTH
+ if (Fclose (f) != 0)
+ {
+ /*
+ * If the Fclose() fails, for example because of a signal,
+ * it's advisable to return the number of protocols read,
+ * if any, or otherwise the server would believe that no
+ * cookie is valid and eventually fall back to host based
+ * authentication. Note anyway that the new code in Check-
+ * Authorization() doesn't care the return value and gives
+ * a chance to the function to check the file at the next
+ * connection.
+ */
+
+ if (count > 0)
+ {
+ return count;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+#else
+ Fclose (f);
+#endif
+ return count;
+}
+
+#ifdef XDMCP
+/*
+ * XdmcpInit calls this function to discover all authorization
+ * schemes supported by the display
+ */
+void
+RegisterAuthorizations (void)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++)
+ XdmcpRegisterAuthorization (protocols[i].name,
+ (int)protocols[i].name_length);
+}
+#endif
+
+XID
+CheckAuthorization (
+ unsigned int name_length,
+ char *name,
+ unsigned int data_length,
+ char *data,
+ ClientPtr client,
+ char **reason) /* failure message. NULL for default msg */
+{
+ int i;
+ struct stat buf;
+ static time_t lastmod = 0;
+
+ #ifndef NX_TRANS_AUTH
+ static Bool loaded = FALSE;
+ #endif
+
+ if (!authorization_file || stat(authorization_file, &buf))
+ {
+ if (lastmod != 0) {
+ lastmod = 0;
+ ShouldLoadAuth = TRUE; /* stat lost, so force reload */
+ }
+ }
+ else if (buf.st_mtime > lastmod)
+ {
+ lastmod = buf.st_mtime;
+ ShouldLoadAuth = TRUE;
+ }
+ if (ShouldLoadAuth)
+ {
+ int loadauth = LoadAuthorization();
+
+ /*
+ * If the authorization file has at least one entry for this server,
+ * disable local host access. (loadauth > 0)
+ *
+ * If there are zero entries (either initially or when the
+ * authorization file is later reloaded), or if a valid
+ * authorization file was never loaded, enable local host access.
+ * (loadauth == 0 || !loaded)
+ *
+ * If the authorization file was loaded initially (with valid
+ * entries for this server), and reloading it later fails, don't
+ * change anything. (loadauth == -1 && loaded)
+ */
+
+#ifdef NX_TRANS_AUTH
+
+ /*
+ * The implementation of CheckAuthorization() was changed. The way
+ * the auth file was handled previously was questionable and could
+ * open the way to a vast array of security problems. There might be
+ * ways for an attacker to prevent the server from reading the file
+ * and it was enough for the server to fail reading the file once
+ * (because of a not blocked signal, for example) to leave the dis-
+ * play open to all the users running a session on the same terminal
+ * server.
+ *
+ * In NX we want to have only two cases: either we have to check an
+ * authorization file or we don't. In the first case we need to do our
+ * best to read the file at any new client access and never fall back
+ * to host based authentication. Falling back to local host access has
+ * no way back, as it will always take precedence over the auth cookie
+ * (unless the user explicitly disables, one by one, all the rules
+ * allowing local access, if and only if he/she becomes aware of the
+ * problem). In the second case we assume that user doesn't care secu-
+ * rity and so allow unrestricted access from the local machine.
+ */
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "CheckAuthorization: Going to set authorization with loadauth [%d].\n",
+ loadauth);
+ #endif
+
+ if (authorization_file)
+ {
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "CheckAuthorization: Disabling local host access.\n");
+ #endif
+
+ DisableLocalHost();
+ }
+ else
+ {
+ /*
+ * Enable host-based authentication only if
+ * the authorization file was not specified
+ * either on the command line or in the env-
+ * ironment.
+ */
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "CheckAuthorization: Enabling local host access.\n");
+ #endif
+
+ EnableLocalHost();
+ }
+
+ /*
+ * Avoid the 'unused variable' warning.
+ */
+
+ loadauth = loadauth;
+
+#else /* #ifdef NX_TRANS_AUTH */
+
+ if (loadauth > 0)
+ {
+ DisableLocalHost(); /* got at least one */
+ loaded = TRUE;
+ }
+ else if (loadauth == 0 || !loaded)
+ EnableLocalHost ();
+
+#endif /* #ifdef NX_TRANS_AUTH */
+ }
+ if (name_length) {
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == name_length &&
+ memcmp (protocols[i].name, name, (int) name_length) == 0)
+ {
+ return (*protocols[i].Check) (data_length, data, client, reason);
+ }
+ *reason = "Protocol not supported by server\n";
+ }
+ } else *reason = "No protocol specified\n";
+ return (XID) ~0L;
+}
+
+void
+ResetAuthorization (void)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++)
+ if (protocols[i].Reset)
+ (*protocols[i].Reset)();
+ ShouldLoadAuth = TRUE;
+}
+
+XID
+AuthorizationToID (
+ unsigned short name_length,
+ char *name,
+ unsigned short data_length,
+ char *data)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == name_length &&
+ memcmp (protocols[i].name, name, (int) name_length) == 0 &&
+ protocols[i].ToID)
+ {
+ return (*protocols[i].ToID) (data_length, data);
+ }
+ }
+ return (XID) ~0L;
+}
+
+int
+AuthorizationFromID (
+ XID id,
+ unsigned short *name_lenp,
+ char **namep,
+ unsigned short *data_lenp,
+ char **datap)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].FromID &&
+ (*protocols[i].FromID) (id, data_lenp, datap)) {
+ *name_lenp = protocols[i].name_length;
+ *namep = protocols[i].name;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int
+RemoveAuthorization (
+ unsigned short name_length,
+ char *name,
+ unsigned short data_length,
+ char *data)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == name_length &&
+ memcmp (protocols[i].name, name, (int) name_length) == 0 &&
+ protocols[i].Remove)
+ {
+ return (*protocols[i].Remove) (data_length, data);
+ }
+ }
+ return 0;
+}
+
+int
+AddAuthorization (unsigned name_length, char *name, unsigned data_length, char *data)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == name_length &&
+ memcmp (protocols[i].name, name, (int) name_length) == 0 &&
+ protocols[i].Add)
+ {
+ return (*protocols[i].Add) (data_length, data, FakeClientID(0));
+ }
+ }
+ return 0;
+}
+
+#ifdef XCSECURITY
+
+XID
+GenerateAuthorization(
+ unsigned name_length,
+ char *name,
+ unsigned data_length,
+ char *data,
+ unsigned *data_length_return,
+ char **data_return)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == name_length &&
+ memcmp (protocols[i].name, name, (int) name_length) == 0 &&
+ protocols[i].Generate)
+ {
+ return (*protocols[i].Generate) (data_length, data,
+ FakeClientID(0), data_length_return, data_return);
+ }
+ }
+ return -1;
+}
+
+/* A random number generator that is more unpredictable
+ than that shipped with some systems.
+ This code is taken from the C standard. */
+
+static unsigned long int next = 1;
+
+static int
+xdm_rand(void)
+{
+ next = next * 1103515245 + 12345;
+ return (unsigned int)(next/65536) % 32768;
+}
+
+static void
+xdm_srand(unsigned int seed)
+{
+ next = seed;
+}
+
+void
+GenerateRandomData (int len, char *buf)
+{
+ static int seed;
+ int value;
+ int i;
+
+ seed += GetTimeInMillis();
+ xdm_srand (seed);
+ for (i = 0; i < len; i++)
+ {
+ value = xdm_rand ();
+ buf[i] ^= (value & 0xff00) >> 8;
+ }
+
+ /* XXX add getrusage, popen("ps -ale") */
+}
+
+#endif /* XCSECURITY */
diff --git a/nx-X11/programs/Xserver/os/auth.c.X.original b/nx-X11/programs/Xserver/os/auth.c.X.original
new file mode 100644
index 000000000..19c5534d3
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/auth.c.X.original
@@ -0,0 +1,400 @@
+/* $Xorg: auth.c,v 1.5 2001/02/09 02:05:23 xorgcvs Exp $ */
+/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: auth.c,v 1.13 2003/04/27 21:31:08 herrb Exp $ */
+
+/*
+ * authorization hooks for the server
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef K5AUTH
+# include <krb5/krb5.h>
+#endif
+# include <X11/X.h>
+# include <X11/Xauth.h>
+# include "misc.h"
+# include "osdep.h"
+# include "dixstruct.h"
+# include <sys/types.h>
+# include <sys/stat.h>
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+# include <X11/extensions/security.h>
+#endif
+#ifdef WIN32
+#include <X11/Xw32defs.h>
+#endif
+
+struct protocol {
+ unsigned short name_length;
+ char *name;
+ AuthAddCFunc Add; /* new authorization data */
+ AuthCheckFunc Check; /* verify client authorization data */
+ AuthRstCFunc Reset; /* delete all authorization data entries */
+ AuthToIDFunc ToID; /* convert cookie to ID */
+ AuthFromIDFunc FromID; /* convert ID to cookie */
+ AuthRemCFunc Remove; /* remove a specific cookie */
+#ifdef XCSECURITY
+ AuthGenCFunc Generate;
+#endif
+};
+
+static struct protocol protocols[] = {
+{ (unsigned short) 18, "MIT-MAGIC-COOKIE-1",
+ MitAddCookie, MitCheckCookie, MitResetCookie,
+ MitToID, MitFromID, MitRemoveCookie,
+#ifdef XCSECURITY
+ MitGenerateCookie
+#endif
+},
+#ifdef HASXDMAUTH
+{ (unsigned short) 19, "XDM-AUTHORIZATION-1",
+ XdmAddCookie, XdmCheckCookie, XdmResetCookie,
+ XdmToID, XdmFromID, XdmRemoveCookie,
+#ifdef XCSECURITY
+ NULL
+#endif
+},
+#endif
+#ifdef SECURE_RPC
+{ (unsigned short) 9, "SUN-DES-1",
+ SecureRPCAdd, SecureRPCCheck, SecureRPCReset,
+ SecureRPCToID, SecureRPCFromID,SecureRPCRemove,
+#ifdef XCSECURITY
+ NULL
+#endif
+},
+#endif
+#ifdef K5AUTH
+{ (unsigned short) 14, "MIT-KERBEROS-5",
+ K5Add, K5Check, K5Reset,
+ K5ToID, K5FromID, K5Remove,
+#ifdef XCSECURITY
+ NULL
+#endif
+},
+#endif
+#ifdef XCSECURITY
+{ (unsigned short) XSecurityAuthorizationNameLen,
+ XSecurityAuthorizationName,
+ NULL, AuthSecurityCheck, NULL,
+ NULL, NULL, NULL,
+ NULL
+},
+#endif
+};
+
+# define NUM_AUTHORIZATION (sizeof (protocols) /\
+ sizeof (struct protocol))
+
+/*
+ * Initialize all classes of authorization by reading the
+ * specified authorization file
+ */
+
+static char *authorization_file = (char *)NULL;
+
+static Bool ShouldLoadAuth = TRUE;
+
+void
+InitAuthorization (char *file_name)
+{
+ authorization_file = file_name;
+}
+
+static int
+LoadAuthorization (void)
+{
+ FILE *f;
+ Xauth *auth;
+ int i;
+ int count = 0;
+
+ ShouldLoadAuth = FALSE;
+ if (!authorization_file)
+ return 0;
+
+ f = Fopen (authorization_file, "r");
+ if (!f)
+ return -1;
+
+ while ((auth = XauReadAuth (f)) != 0) {
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == auth->name_length &&
+ memcmp (protocols[i].name, auth->name, (int) auth->name_length) == 0 &&
+ protocols[i].Add)
+ {
+ ++count;
+ (*protocols[i].Add) (auth->data_length, auth->data,
+ FakeClientID(0));
+ }
+ }
+ XauDisposeAuth (auth);
+ }
+
+ Fclose (f);
+ return count;
+}
+
+#ifdef XDMCP
+/*
+ * XdmcpInit calls this function to discover all authorization
+ * schemes supported by the display
+ */
+void
+RegisterAuthorizations (void)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++)
+ XdmcpRegisterAuthorization (protocols[i].name,
+ (int)protocols[i].name_length);
+}
+#endif
+
+XID
+CheckAuthorization (
+ unsigned int name_length,
+ char *name,
+ unsigned int data_length,
+ char *data,
+ ClientPtr client,
+ char **reason) /* failure message. NULL for default msg */
+{
+ int i;
+ struct stat buf;
+ static time_t lastmod = 0;
+ static Bool loaded = FALSE;
+
+ if (!authorization_file || stat(authorization_file, &buf))
+ {
+ if (lastmod != 0) {
+ lastmod = 0;
+ ShouldLoadAuth = TRUE; /* stat lost, so force reload */
+ }
+ }
+ else if (buf.st_mtime > lastmod)
+ {
+ lastmod = buf.st_mtime;
+ ShouldLoadAuth = TRUE;
+ }
+ if (ShouldLoadAuth)
+ {
+ int loadauth = LoadAuthorization();
+
+ /*
+ * If the authorization file has at least one entry for this server,
+ * disable local host access. (loadauth > 0)
+ *
+ * If there are zero entries (either initially or when the
+ * authorization file is later reloaded), or if a valid
+ * authorization file was never loaded, enable local host access.
+ * (loadauth == 0 || !loaded)
+ *
+ * If the authorization file was loaded initially (with valid
+ * entries for this server), and reloading it later fails, don't
+ * change anything. (loadauth == -1 && loaded)
+ */
+
+ if (loadauth > 0)
+ {
+ DisableLocalHost(); /* got at least one */
+ loaded = TRUE;
+ }
+ else if (loadauth == 0 || !loaded)
+ EnableLocalHost ();
+ }
+ if (name_length) {
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == name_length &&
+ memcmp (protocols[i].name, name, (int) name_length) == 0)
+ {
+ return (*protocols[i].Check) (data_length, data, client, reason);
+ }
+ *reason = "Protocol not supported by server\n";
+ }
+ } else *reason = "No protocol specified\n";
+ return (XID) ~0L;
+}
+
+void
+ResetAuthorization (void)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++)
+ if (protocols[i].Reset)
+ (*protocols[i].Reset)();
+ ShouldLoadAuth = TRUE;
+}
+
+XID
+AuthorizationToID (
+ unsigned short name_length,
+ char *name,
+ unsigned short data_length,
+ char *data)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == name_length &&
+ memcmp (protocols[i].name, name, (int) name_length) == 0 &&
+ protocols[i].ToID)
+ {
+ return (*protocols[i].ToID) (data_length, data);
+ }
+ }
+ return (XID) ~0L;
+}
+
+int
+AuthorizationFromID (
+ XID id,
+ unsigned short *name_lenp,
+ char **namep,
+ unsigned short *data_lenp,
+ char **datap)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].FromID &&
+ (*protocols[i].FromID) (id, data_lenp, datap)) {
+ *name_lenp = protocols[i].name_length;
+ *namep = protocols[i].name;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int
+RemoveAuthorization (
+ unsigned short name_length,
+ char *name,
+ unsigned short data_length,
+ char *data)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == name_length &&
+ memcmp (protocols[i].name, name, (int) name_length) == 0 &&
+ protocols[i].Remove)
+ {
+ return (*protocols[i].Remove) (data_length, data);
+ }
+ }
+ return 0;
+}
+
+int
+AddAuthorization (unsigned name_length, char *name, unsigned data_length, char *data)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == name_length &&
+ memcmp (protocols[i].name, name, (int) name_length) == 0 &&
+ protocols[i].Add)
+ {
+ return (*protocols[i].Add) (data_length, data, FakeClientID(0));
+ }
+ }
+ return 0;
+}
+
+#ifdef XCSECURITY
+
+XID
+GenerateAuthorization(
+ unsigned name_length,
+ char *name,
+ unsigned data_length,
+ char *data,
+ unsigned *data_length_return,
+ char **data_return)
+{
+ int i;
+
+ for (i = 0; i < NUM_AUTHORIZATION; i++) {
+ if (protocols[i].name_length == name_length &&
+ memcmp (protocols[i].name, name, (int) name_length) == 0 &&
+ protocols[i].Generate)
+ {
+ return (*protocols[i].Generate) (data_length, data,
+ FakeClientID(0), data_length_return, data_return);
+ }
+ }
+ return -1;
+}
+
+/* A random number generator that is more unpredictable
+ than that shipped with some systems.
+ This code is taken from the C standard. */
+
+static unsigned long int next = 1;
+
+static int
+xdm_rand(void)
+{
+ next = next * 1103515245 + 12345;
+ return (unsigned int)(next/65536) % 32768;
+}
+
+static void
+xdm_srand(unsigned int seed)
+{
+ next = seed;
+}
+
+void
+GenerateRandomData (int len, char *buf)
+{
+ static int seed;
+ int value;
+ int i;
+
+ seed += GetTimeInMillis();
+ xdm_srand (seed);
+ for (i = 0; i < len; i++)
+ {
+ value = xdm_rand ();
+ buf[i] ^= (value & 0xff00) >> 8;
+ }
+
+ /* XXX add getrusage, popen("ps -ale") */
+}
+
+#endif /* XCSECURITY */
diff --git a/nx-X11/programs/Xserver/os/connection.c b/nx-X11/programs/Xserver/os/connection.c
new file mode 100644
index 000000000..e3319b338
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/connection.c
@@ -0,0 +1,1424 @@
+/* $Xorg: connection.c,v 1.6 2001/02/09 02:05:23 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/os/connection.c,v 3.64 2003/10/07 22:50:42 herrb Exp $ */
+/*****************************************************************
+ * Stuff to create connections --- OS dependent
+ *
+ * EstablishNewConnections, CreateWellKnownSockets, ResetWellKnownSockets,
+ * CloseDownConnection, CheckConnections, AddEnabledDevice,
+ * RemoveEnabledDevice, OnlyListToOneClient,
+ * ListenToAllClients,
+ *
+ * (WaitForSomething is in its own file)
+ *
+ * In this implementation, a client socket table is not kept.
+ * Instead, what would be the index into the table is just the
+ * file descriptor of the socket. This won't work for if the
+ * socket ids aren't small nums (0 - 2^8)
+ *
+ *****************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#endif
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#define XSERV_t
+#define TRANS_SERVER
+#define TRANS_REOPEN
+#include <X11/Xtrans/Xtrans.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifndef WIN32
+#if defined(Lynx)
+#include <socket.h>
+#else
+#include <sys/socket.h>
+#endif
+
+#ifdef hpux
+#include <sys/utsname.h>
+#include <sys/ioctl.h>
+#endif
+
+#if defined(DGUX)
+#include <sys/ioctl.h>
+#include <sys/utsname.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <sys/param.h>
+#include <unistd.h>
+#endif
+
+
+#ifdef AIXV3
+#include <sys/ioctl.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define select(n,r,w,x,t) os2PseudoSelect(n,r,w,x,t)
+extern __const__ int _nfiles;
+#endif
+
+#if defined(TCPCONN) || defined(STREAMSCONN)
+# include <netinet/in.h>
+# include <arpa/inet.h>
+# if !defined(hpux)
+# ifdef apollo
+# ifndef NO_TCP_H
+# include <netinet/tcp.h>
+# endif
+# else
+# ifdef CSRG_BASED
+# include <sys/param.h>
+# endif
+# ifndef __UNIXOS2__
+# include <netinet/tcp.h>
+# endif
+# endif
+# endif
+# include <arpa/inet.h>
+#endif
+
+#if !defined(__UNIXOS2__)
+#ifndef Lynx
+#include <sys/uio.h>
+#else
+#include <uio.h>
+#endif
+#endif
+#endif /* WIN32 */
+#include "misc.h" /* for typedef of pointer */
+#include "osdep.h"
+#include <X11/Xpoll.h>
+#include "opaque.h"
+#include "dixstruct.h"
+#ifdef XAPPGROUP
+#include <X11/extensions/Xagsrv.h>
+#endif
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+#ifdef LBX
+#include "colormapst.h"
+#include "propertyst.h"
+#include "lbxserve.h"
+#include "osdep.h"
+#endif
+
+#ifdef X_NOT_POSIX
+#define Pid_t int
+#else
+#define Pid_t pid_t
+#endif
+
+#ifdef DNETCONN
+#include <netdnet/dn.h>
+#endif /* DNETCONN */
+
+int lastfdesc; /* maximum file descriptor */
+
+fd_set WellKnownConnections; /* Listener mask */
+fd_set EnabledDevices; /* mask for input devices that are on */
+fd_set AllSockets; /* select on this */
+fd_set AllClients; /* available clients */
+fd_set LastSelectMask; /* mask returned from last select call */
+fd_set ClientsWithInput; /* clients with FULL requests in buffer */
+fd_set ClientsWriteBlocked; /* clients who cannot receive output */
+fd_set OutputPending; /* clients with reply/event data ready to go */
+int MaxClients = 0;
+Bool NewOutputPending; /* not yet attempted to write some new output */
+Bool AnyClientsWriteBlocked; /* true if some client blocked on write */
+
+Bool RunFromSmartParent; /* send SIGUSR1 to parent process */
+Bool PartialNetwork; /* continue even if unable to bind all addrs */
+static Pid_t ParentProcess;
+#ifdef __UNIXOS2__
+Pid_t GetPPID(Pid_t pid);
+#endif
+
+static Bool debug_conns = FALSE;
+
+fd_set IgnoredClientsWithInput;
+static fd_set GrabImperviousClients;
+static fd_set SavedAllClients;
+static fd_set SavedAllSockets;
+static fd_set SavedClientsWithInput;
+int GrabInProgress = 0;
+
+#if !defined(WIN32)
+int *ConnectionTranslation = NULL;
+#else
+/*
+ * On NT fds are not between 0 and MAXSOCKS, they are unrelated, and there is
+ * not even a known maximum value, so use something quite arbitrary for now.
+ * Do storage is a hash table of size 256. Collisions are handled in a linked
+ * list.
+ */
+
+#undef MAXSOCKS
+#define MAXSOCKS 500
+#undef MAXSELECT
+#define MAXSELECT 500
+#define MAXFD 500
+
+struct _ct_node {
+ struct _ct_node *next;
+ int key;
+ int value;
+};
+
+struct _ct_node *ct_head[256];
+
+void InitConnectionTranslation(void)
+{
+ bzero(ct_head, sizeof(ct_head));
+}
+
+int GetConnectionTranslation(int conn)
+{
+ struct _ct_node *node = ct_head[conn & 0xff];
+ while (node != NULL)
+ {
+ if (node->key == conn)
+ return node->value;
+ node = node->next;
+ }
+ return 0;
+}
+
+void SetConnectionTranslation(int conn, int client)
+{
+ struct _ct_node **node = ct_head + (conn & 0xff);
+ if (client == 0) /* remove entry */
+ {
+ while (*node != NULL)
+ {
+ if ((*node)->key == conn)
+ {
+ struct _ct_node *temp = *node;
+ *node = (*node)->next;
+ free(temp);
+ return;
+ }
+ node = &((*node)->next);
+ }
+ return;
+ } else
+ {
+ while (*node != NULL)
+ {
+ if ((*node)->key == conn)
+ {
+ (*node)->value = client;
+ return;
+ }
+ node = &((*node)->next);
+ }
+ *node = (struct _ct_node*)xalloc(sizeof(struct _ct_node));
+ (*node)->next = NULL;
+ (*node)->key = conn;
+ (*node)->value = client;
+ return;
+ }
+}
+
+void ClearConnectionTranslation(void)
+{
+ unsigned i;
+ for (i = 0; i < 256; i++)
+ {
+ struct _ct_node *node = ct_head[i];
+ while (node != NULL)
+ {
+ struct _ct_node *temp = node;
+ node = node->next;
+ xfree(temp);
+ }
+ }
+}
+#endif
+
+XtransConnInfo *ListenTransConns = NULL;
+int *ListenTransFds = NULL;
+int ListenTransCount;
+
+static void ErrorConnMax(XtransConnInfo /* trans_conn */);
+
+#ifndef LBX
+static
+void CloseDownFileDescriptor(
+ OsCommPtr /*oc*/
+);
+#endif
+
+
+static XtransConnInfo
+lookup_trans_conn (int fd)
+{
+ if (ListenTransFds)
+ {
+ int i;
+ for (i = 0; i < ListenTransCount; i++)
+ if (ListenTransFds[i] == fd)
+ return ListenTransConns[i];
+ }
+
+ return (NULL);
+}
+
+/* Set MaxClients and lastfdesc, and allocate ConnectionTranslation */
+
+void
+InitConnectionLimits(void)
+{
+ lastfdesc = -1;
+
+#ifndef __CYGWIN__
+
+#ifndef __UNIXOS2__
+
+#if !defined(XNO_SYSCONF) && defined(_SC_OPEN_MAX)
+ lastfdesc = sysconf(_SC_OPEN_MAX) - 1;
+#endif
+
+#ifdef HAS_GETDTABLESIZE
+ if (lastfdesc < 0)
+ lastfdesc = getdtablesize() - 1;
+#endif
+
+#ifdef _NFILE
+ if (lastfdesc < 0)
+ lastfdesc = _NFILE - 1;
+#endif
+
+#else /* __UNIXOS2__ */
+ lastfdesc = _nfiles - 1;
+#endif
+
+#endif /* __CYGWIN__ */
+
+ /* This is the fallback */
+ if (lastfdesc < 0)
+ lastfdesc = MAXSOCKS;
+
+ if (lastfdesc > MAXSELECT)
+ lastfdesc = MAXSELECT;
+
+ if (lastfdesc > MAXCLIENTS)
+ {
+ lastfdesc = MAXCLIENTS;
+ if (debug_conns)
+ ErrorF( "REACHED MAXIMUM CLIENTS LIMIT %d\n", MAXCLIENTS);
+ }
+ MaxClients = lastfdesc;
+
+#ifdef DEBUG
+ ErrorF("InitConnectionLimits: MaxClients = %d\n", MaxClients);
+#endif
+
+#if !defined(WIN32)
+ ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1));
+#else
+ InitConnectionTranslation();
+#endif
+}
+
+
+/*****************
+ * CreateWellKnownSockets
+ * At initialization, create the sockets to listen on for new clients.
+ *****************/
+
+void
+CreateWellKnownSockets(void)
+{
+ int i;
+ int partial;
+ char port[20];
+ OsSigHandlerPtr handler;
+
+ FD_ZERO(&AllSockets);
+ FD_ZERO(&AllClients);
+ FD_ZERO(&LastSelectMask);
+ FD_ZERO(&ClientsWithInput);
+
+#if !defined(WIN32)
+ for (i=0; i<MaxClients; i++) ConnectionTranslation[i] = 0;
+#else
+ ClearConnectionTranslation();
+#endif
+
+ FD_ZERO (&WellKnownConnections);
+
+ sprintf (port, "%d", atoi (display));
+
+ if ((_XSERVTransMakeAllCOTSServerListeners (port, &partial,
+ &ListenTransCount, &ListenTransConns) >= 0) &&
+ (ListenTransCount >= 1))
+ {
+ if (!PartialNetwork && partial)
+ {
+ FatalError ("Failed to establish all listening sockets");
+ }
+ else
+ {
+ ListenTransFds = (int *) xalloc (ListenTransCount * sizeof (int));
+
+ for (i = 0; i < ListenTransCount; i++)
+ {
+ int fd = _XSERVTransGetConnectionNumber (ListenTransConns[i]);
+
+ ListenTransFds[i] = fd;
+ FD_SET (fd, &WellKnownConnections);
+
+ if (!_XSERVTransIsLocal (ListenTransConns[i]))
+ {
+ DefineSelf (fd);
+ }
+ }
+ }
+ }
+
+ if (!XFD_ANYSET (&WellKnownConnections))
+ FatalError ("Cannot establish any listening sockets - Make sure an X server isn't already running");
+#if !defined(WIN32)
+ OsSignal (SIGPIPE, SIG_IGN);
+ OsSignal (SIGHUP, AutoResetServer);
+#endif
+ OsSignal (SIGINT, GiveUp);
+ OsSignal (SIGTERM, GiveUp);
+ XFD_COPYSET (&WellKnownConnections, &AllSockets);
+ ResetHosts(display);
+ /*
+ * Magic: If SIGUSR1 was set to SIG_IGN when
+ * the server started, assume that either
+ *
+ * a- The parent process is ignoring SIGUSR1
+ *
+ * or
+ *
+ * b- The parent process is expecting a SIGUSR1
+ * when the server is ready to accept connections
+ *
+ * In the first case, the signal will be harmless,
+ * in the second case, the signal will be quite
+ * useful
+ */
+#if !defined(WIN32)
+ handler = OsSignal (SIGUSR1, SIG_IGN);
+ if ( handler == SIG_IGN)
+ RunFromSmartParent = TRUE;
+ OsSignal(SIGUSR1, handler);
+ ParentProcess = getppid ();
+#ifdef __UNIXOS2__
+ /*
+ * fg030505: under OS/2, xinit is not the parent process but
+ * the "grant parent" process of the server because execvpe()
+ * presents us an additional process number;
+ * GetPPID(pid) is part of libemxfix
+ */
+ ParentProcess = GetPPID (ParentProcess);
+#endif /* __UNIXOS2__ */
+ if (RunFromSmartParent) {
+ if (ParentProcess > 1) {
+ kill (ParentProcess, SIGUSR1);
+ }
+ }
+#endif
+#ifdef XDMCP
+ XdmcpInit ();
+#endif
+}
+
+#ifdef NX_TRANS_SOCKET
+
+/*
+ * The following block is now defined also
+ * under Cygwin to support this environment.
+ */
+
+#ifndef __DARWIN__
+
+/*
+ * This is defined in Xtranssock.c and must
+ * be called explicitly as it doesn't share
+ * a pointer in the transport function table.
+ */
+
+extern void _XSERVTransSocketRejectConnection(XtransConnInfo);
+
+void
+RejectWellKnownSockets ()
+{
+ int i;
+
+ for (i = 0; i < ListenTransCount; i++)
+ {
+ _XSERVTransSocketRejectConnection(ListenTransConns[i]);
+ }
+}
+
+#endif /* #ifndef __DARWIN__ */
+
+#else /* #ifdef NX_TRANS_SOCKET */
+
+void
+RejectWellKnownSockets ()
+{
+}
+
+#endif /* #ifdef NX_TRANS_SOCKET */
+
+void
+ResetWellKnownSockets (void)
+{
+ int i;
+
+ ResetOsBuffers();
+
+ for (i = 0; i < ListenTransCount; i++)
+ {
+ int status = _XSERVTransResetListener (ListenTransConns[i]);
+
+ if (status != TRANS_RESET_NOOP)
+ {
+ if (status == TRANS_RESET_FAILURE)
+ {
+ /*
+ * ListenTransConns[i] freed by xtrans.
+ * Remove it from out list.
+ */
+
+ FD_CLR (ListenTransFds[i], &WellKnownConnections);
+ ListenTransFds[i] = ListenTransFds[ListenTransCount - 1];
+ ListenTransConns[i] = ListenTransConns[ListenTransCount - 1];
+ ListenTransCount -= 1;
+ i -= 1;
+ }
+ else if (status == TRANS_RESET_NEW_FD)
+ {
+ /*
+ * A new file descriptor was allocated (the old one was closed)
+ */
+
+ int newfd = _XSERVTransGetConnectionNumber (ListenTransConns[i]);
+
+ FD_CLR (ListenTransFds[i], &WellKnownConnections);
+ ListenTransFds[i] = newfd;
+ FD_SET(newfd, &WellKnownConnections);
+ }
+ }
+ }
+
+ ResetAuthorization ();
+ ResetHosts(display);
+ /*
+ * See above in CreateWellKnownSockets about SIGUSR1
+ */
+#if !defined(WIN32)
+ if (RunFromSmartParent) {
+ if (ParentProcess > 1) {
+ kill (ParentProcess, SIGUSR1);
+ }
+ }
+#endif
+ /*
+ * restart XDMCP
+ */
+#ifdef XDMCP
+ XdmcpReset ();
+#endif
+}
+
+void
+CloseWellKnownConnections(void)
+{
+ int i;
+
+ for (i = 0; i < ListenTransCount; i++)
+ _XSERVTransClose (ListenTransConns[i]);
+}
+
+static void
+AuthAudit (ClientPtr client, Bool letin,
+ struct sockaddr *saddr, int len,
+ unsigned int proto_n, char *auth_proto, int auth_id)
+{
+ char addr[128];
+ char *out = addr;
+
+ if (!((OsCommPtr)client->osPrivate)->trans_conn) {
+ strcpy(addr, "LBX proxy at ");
+ out += strlen(addr);
+ }
+ if (!len)
+ strcpy(out, "local host");
+ else
+ switch (saddr->sa_family)
+ {
+ case AF_UNSPEC:
+#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
+ case AF_UNIX:
+#endif
+ strcpy(out, "local host");
+ break;
+#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
+ case AF_INET:
+ sprintf(out, "IP %s",
+ inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr));
+ break;
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6: {
+ char ipaddr[INET6_ADDRSTRLEN];
+ inet_ntop(AF_INET6, &((struct sockaddr_in6 *) saddr)->sin6_addr,
+ ipaddr, sizeof(ipaddr));
+ sprintf(out, "IP %s", ipaddr);
+ }
+ break;
+#endif
+#endif
+#ifdef DNETCONN
+ case AF_DECnet:
+ sprintf(out, "DN %s",
+ dnet_ntoa(&((struct sockaddr_dn *) saddr)->sdn_add));
+ break;
+#endif
+ default:
+ strcpy(out, "unknown address");
+ }
+
+ if (proto_n)
+ AuditF("client %d %s from %s\n Auth name: %.*s ID: %d\n",
+ client->index, letin ? "connected" : "rejected", addr,
+ (int)proto_n, auth_proto, auth_id);
+ else
+ AuditF("client %d %s from %s\n",
+ client->index, letin ? "connected" : "rejected", addr);
+}
+
+XID
+AuthorizationIDOfClient(ClientPtr client)
+{
+ if (client->osPrivate)
+ return ((OsCommPtr)client->osPrivate)->auth_id;
+ else
+ return None;
+}
+
+
+/*****************************************************************
+ * ClientAuthorized
+ *
+ * Sent by the client at connection setup:
+ * typedef struct _xConnClientPrefix {
+ * CARD8 byteOrder;
+ * BYTE pad;
+ * CARD16 majorVersion, minorVersion;
+ * CARD16 nbytesAuthProto;
+ * CARD16 nbytesAuthString;
+ * } xConnClientPrefix;
+ *
+ * It is hoped that eventually one protocol will be agreed upon. In the
+ * mean time, a server that implements a different protocol than the
+ * client expects, or a server that only implements the host-based
+ * mechanism, will simply ignore this information.
+ *
+ *****************************************************************/
+
+char *
+ClientAuthorized(ClientPtr client,
+ unsigned int proto_n, char *auth_proto,
+ unsigned int string_n, char *auth_string)
+{
+ OsCommPtr priv;
+ Xtransaddr *from = NULL;
+ int family;
+ int fromlen;
+ XID auth_id;
+ char *reason = NULL;
+ XtransConnInfo trans_conn;
+ int restore_trans_conn = 0;
+ ClientPtr lbxpc = NULL;
+
+ priv = (OsCommPtr)client->osPrivate;
+ trans_conn = priv->trans_conn;
+
+#ifdef LBX
+ if (!trans_conn) {
+ /*
+ * Since trans_conn is NULL, this must be a proxy's client for
+ * which we have NO address. Therefore, we will temporarily
+ * set the client's trans_conn to the proxy's trans_conn and
+ * after CheckAuthorization the client's trans_conn will be
+ * restored.
+ *
+ * If XDM-AUTHORIZATION-1 is being used, CheckAuthorization
+ * will eventually call XdmAuthorizationValidate and this
+ * later function may use the client's trans_conn to get the
+ * client's address. Since a XDM-AUTH-1 auth string includes
+ * the client's address, this address is compared to the address
+ * in the client's trans_conn. If the proxy and client are
+ * on the same host, the comparison will fail; otherwise the
+ * comparison will fail and the client will not be authorized
+ * to connect to the server.
+ *
+ * The basis for this additional code is to prevent a
+ * NULL pointer dereference of the client's trans_conn.
+ * The fundamental problem - the fact that the client's
+ * trans_conn is NULL - is because the NewClient
+ * request in version 1.0 of the LBX protocol does not
+ * send the client's address to the server. When the
+ * spec is changed and the client's address is sent to
+ * server in the NewClient request, this additional code
+ * should be removed.
+ *
+ * See defect number XWSog08218 for more information.
+ */
+ lbxpc = LbxProxyClient(priv->proxy);
+ trans_conn = ((OsCommPtr)lbxpc->osPrivate)->trans_conn;
+ priv->trans_conn = trans_conn;
+ restore_trans_conn = 1;
+ }
+#endif
+
+ auth_id = CheckAuthorization (proto_n, auth_proto,
+ string_n, auth_string, client, &reason);
+
+#ifdef LBX
+ if (! priv->trans_conn) {
+ if (auth_id == (XID) ~0L && !GetAccessControl())
+ auth_id = ((OsCommPtr)lbxpc->osPrivate)->auth_id;
+#ifdef XCSECURITY
+ else if (auth_id != (XID) ~0L && !SecuritySameLevel(lbxpc, auth_id)) {
+ auth_id = (XID) ~0L;
+ reason = "Client trust level differs from that of LBX Proxy";
+ }
+#endif
+ }
+#endif
+ if (auth_id == (XID) ~0L)
+ {
+ if (
+#ifdef XCSECURITY
+ (proto_n == 0 ||
+ strncmp (auth_proto, XSecurityAuthorizationName, proto_n) != 0) &&
+#endif
+ _XSERVTransGetPeerAddr (trans_conn,
+ &family, &fromlen, &from) != -1)
+ {
+ if (
+#ifdef LBX
+ !trans_conn ||
+#endif
+ InvalidHost ((struct sockaddr *) from, fromlen, client))
+ AuthAudit(client, FALSE, (struct sockaddr *) from,
+ fromlen, proto_n, auth_proto, auth_id);
+ else
+ {
+ auth_id = (XID) 0;
+ if (auditTrailLevel > 1)
+ AuthAudit(client, TRUE,
+ (struct sockaddr *) from, fromlen,
+ proto_n, auth_proto, auth_id);
+ }
+
+ xfree ((char *) from);
+ }
+
+ if (auth_id == (XID) ~0L) {
+#ifdef LBX
+ /*
+ * Restore client's trans_conn state
+ */
+ if (restore_trans_conn) {
+ priv->trans_conn = NULL;
+ }
+#endif
+ if (reason)
+ return reason;
+ else
+ return "Client is not authorized to connect to Server";
+ }
+ }
+ else if (auditTrailLevel > 1)
+ {
+ if (_XSERVTransGetPeerAddr (trans_conn,
+ &family, &fromlen, &from) != -1)
+ {
+ AuthAudit(client, TRUE, (struct sockaddr *) from, fromlen,
+ proto_n, auth_proto, auth_id);
+
+ xfree ((char *) from);
+ }
+ }
+ priv->auth_id = auth_id;
+ priv->conn_time = 0;
+
+#ifdef XDMCP
+ /* indicate to Xdmcp protocol that we've opened new client */
+ XdmcpOpenDisplay(priv->fd);
+#endif /* XDMCP */
+#ifdef XAPPGROUP
+ if (ClientStateCallback)
+ XagCallClientStateChange (client);
+#endif
+ /* At this point, if the client is authorized to change the access control
+ * list, we should getpeername() information, and add the client to
+ * the selfhosts list. It's not really the host machine, but the
+ * true purpose of the selfhosts list is to see who may change the
+ * access control list.
+ */
+#ifdef LBX
+ if (restore_trans_conn) {
+ priv->trans_conn = NULL;
+ }
+#endif
+ return((char *)NULL);
+}
+
+static ClientPtr
+#ifdef LBX
+AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time,
+ int (*Flush)(
+ ClientPtr /*who*/, OsCommPtr /*oc*/,
+ char * /*extraBuf*/, int /*extraCount*/),
+ void (*Close)(
+ ClientPtr /*client*/),
+ LbxProxyPtr proxy)
+#else
+AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time)
+#endif
+{
+ OsCommPtr oc;
+ ClientPtr client;
+
+ if (
+#ifdef LBX
+ trans_conn &&
+#endif
+#ifndef WIN32
+ fd >= lastfdesc
+#else
+ XFD_SETCOUNT(&AllClients) >= MaxClients
+#endif
+ )
+ return NullClient;
+ oc = (OsCommPtr)xalloc(sizeof(OsCommRec));
+ if (!oc)
+ return NullClient;
+ oc->trans_conn = trans_conn;
+ oc->fd = fd;
+ oc->input = (ConnectionInputPtr)NULL;
+ oc->output = (ConnectionOutputPtr)NULL;
+ oc->auth_id = None;
+ oc->conn_time = conn_time;
+#ifdef LBX
+ oc->proxy = proxy;
+ oc->Flush = Flush;
+ oc->Close = Close;
+ oc->largereq = (ConnectionInputPtr) NULL;
+#endif
+ if (!(client = NextAvailableClient((pointer)oc)))
+ {
+ xfree (oc);
+ return NullClient;
+ }
+#ifdef LBX
+ if (trans_conn)
+#endif
+ {
+#if !defined(WIN32)
+ ConnectionTranslation[fd] = client->index;
+#else
+ SetConnectionTranslation(fd, client->index);
+#endif
+ if (GrabInProgress)
+ {
+ FD_SET(fd, &SavedAllClients);
+ FD_SET(fd, &SavedAllSockets);
+ }
+ else
+ {
+ FD_SET(fd, &AllClients);
+ FD_SET(fd, &AllSockets);
+ }
+ }
+
+#ifdef DEBUG
+ ErrorF("AllocNewConnection: client index = %d, socket fd = %d\n",
+ client->index, fd);
+#endif
+
+ return client;
+}
+
+#ifdef LBX
+
+int
+ClientConnectionNumber (ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
+
+ return oc->fd;
+}
+
+ClientPtr
+AllocLbxClientConnection (ClientPtr client, LbxProxyPtr proxy)
+{
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
+
+ return AllocNewConnection ((XtransConnInfo)NULL, oc->fd, GetTimeInMillis(),
+ LbxFlushClient, LbxCloseClient, proxy);
+}
+
+void
+LbxProxyConnection (ClientPtr client, LbxProxyPtr proxy)
+{
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
+
+ FlushClient(client, oc, (char *)NULL, 0);
+ oc->proxy = proxy;
+ oc->Flush = LbxFlushClient;
+ oc->Close = LbxCloseClient;
+ LbxPrimeInput(client, proxy);
+}
+
+#endif
+
+/*****************
+ * EstablishNewConnections
+ * If anyone is waiting on listened sockets, accept them.
+ * Returns a mask with indices of new clients. Updates AllClients
+ * and AllSockets.
+ *****************/
+
+/*ARGSUSED*/
+Bool
+EstablishNewConnections(ClientPtr clientUnused, pointer closure)
+{
+ fd_set readyconnections; /* set of listeners that are ready */
+ int curconn; /* fd of listener that's ready */
+ register int newconn; /* fd of new client */
+ CARD32 connect_time;
+ register int i;
+ register ClientPtr client;
+ register OsCommPtr oc;
+ fd_set tmask;
+
+ XFD_ANDSET (&tmask, (fd_set*)closure, &WellKnownConnections);
+ XFD_COPYSET(&tmask, &readyconnections);
+ if (!XFD_ANYSET(&readyconnections))
+ return TRUE;
+ connect_time = GetTimeInMillis();
+ /* kill off stragglers */
+ for (i=1; i<currentMaxClients; i++)
+ {
+ if ((client = clients[i]))
+ {
+ oc = (OsCommPtr)(client->osPrivate);
+ if ((oc && (oc->conn_time != 0) &&
+ (connect_time - oc->conn_time) >= TimeOutValue) ||
+ (client->noClientException != Success && !client->clientGone))
+ CloseDownClient(client);
+ }
+ }
+#ifndef WIN32
+ for (i = 0; i < howmany(XFD_SETSIZE, NFDBITS); i++)
+ {
+ while (readyconnections.fds_bits[i])
+#else
+ for (i = 0; i < XFD_SETCOUNT(&readyconnections); i++)
+#endif
+ {
+ XtransConnInfo trans_conn, new_trans_conn;
+ int status;
+
+#ifndef WIN32
+ curconn = ffs (readyconnections.fds_bits[i]) - 1;
+ readyconnections.fds_bits[i] &= ~((fd_mask)1 << curconn);
+ curconn += (i * (sizeof(fd_mask)*8));
+#else
+ curconn = XFD_FD(&readyconnections, i);
+#endif
+
+ if ((trans_conn = lookup_trans_conn (curconn)) == NULL)
+ continue;
+
+ if ((new_trans_conn = _XSERVTransAccept (trans_conn, &status)) == NULL)
+ continue;
+
+ newconn = _XSERVTransGetConnectionNumber (new_trans_conn);
+
+ if (newconn < lastfdesc)
+ {
+ int clientid;
+#if !defined(WIN32)
+ clientid = ConnectionTranslation[newconn];
+#else
+ clientid = GetConnectionTranslation(newconn);
+#endif
+ if(clientid && (client = clients[clientid]))
+ CloseDownClient(client);
+ }
+
+ _XSERVTransSetOption(new_trans_conn, TRANS_NONBLOCKING, 1);
+
+ if (!AllocNewConnection (new_trans_conn, newconn, connect_time
+#ifdef LBX
+ , StandardFlushClient,
+ CloseDownFileDescriptor, (LbxProxyPtr)NULL
+#endif
+ ))
+ {
+ ErrorConnMax(new_trans_conn);
+ _XSERVTransClose(new_trans_conn);
+ }
+ }
+#ifndef WIN32
+ }
+#endif
+ return TRUE;
+}
+
+#define NOROOM "Maximum number of clients reached"
+
+/************
+ * ErrorConnMax
+ * Fail a connection due to lack of client or file descriptor space
+ ************/
+
+static void
+ErrorConnMax(XtransConnInfo trans_conn)
+{
+ int fd = _XSERVTransGetConnectionNumber (trans_conn);
+ xConnSetupPrefix csp;
+ char pad[3];
+ struct iovec iov[3];
+ char byteOrder = 0;
+ int whichbyte = 1;
+ struct timeval waittime;
+ fd_set mask;
+
+ /* if these seems like a lot of trouble to go to, it probably is */
+ waittime.tv_sec = BOTIMEOUT / MILLI_PER_SECOND;
+ waittime.tv_usec = (BOTIMEOUT % MILLI_PER_SECOND) *
+ (1000000 / MILLI_PER_SECOND);
+ FD_ZERO(&mask);
+ FD_SET(fd, &mask);
+ (void)Select(fd + 1, &mask, NULL, NULL, &waittime);
+ /* try to read the byte-order of the connection */
+ (void)_XSERVTransRead(trans_conn, &byteOrder, 1);
+ if ((byteOrder == 'l') || (byteOrder == 'B'))
+ {
+ csp.success = xFalse;
+ csp.lengthReason = sizeof(NOROOM) - 1;
+ csp.length = (sizeof(NOROOM) + 2) >> 2;
+ csp.majorVersion = X_PROTOCOL;
+ csp.minorVersion = X_PROTOCOL_REVISION;
+ if (((*(char *) &whichbyte) && (byteOrder == 'B')) ||
+ (!(*(char *) &whichbyte) && (byteOrder == 'l')))
+ {
+ swaps(&csp.majorVersion, whichbyte);
+ swaps(&csp.minorVersion, whichbyte);
+ swaps(&csp.length, whichbyte);
+ }
+ iov[0].iov_len = sz_xConnSetupPrefix;
+ iov[0].iov_base = (char *) &csp;
+ iov[1].iov_len = csp.lengthReason;
+ iov[1].iov_base = NOROOM;
+ iov[2].iov_len = (4 - (csp.lengthReason & 3)) & 3;
+ iov[2].iov_base = pad;
+ (void)_XSERVTransWritev(trans_conn, iov, 3);
+ }
+}
+
+/************
+ * CloseDownFileDescriptor:
+ * Remove this file descriptor and it's I/O buffers, etc.
+ ************/
+
+#ifdef LBX
+void
+CloseDownFileDescriptor(ClientPtr client)
+#else
+static void
+CloseDownFileDescriptor(OsCommPtr oc)
+#endif
+{
+#ifdef LBX
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
+#endif
+ int connection = oc->fd;
+
+ if (oc->trans_conn) {
+ _XSERVTransDisconnect(oc->trans_conn);
+ _XSERVTransClose(oc->trans_conn);
+ }
+#ifndef LBX
+ FreeOsBuffers(oc);
+ xfree(oc);
+#endif
+#ifndef WIN32
+ ConnectionTranslation[connection] = 0;
+#else
+ SetConnectionTranslation(connection, 0);
+#endif
+ FD_CLR(connection, &AllSockets);
+ FD_CLR(connection, &AllClients);
+ FD_CLR(connection, &ClientsWithInput);
+ FD_CLR(connection, &GrabImperviousClients);
+ if (GrabInProgress)
+ {
+ FD_CLR(connection, &SavedAllSockets);
+ FD_CLR(connection, &SavedAllClients);
+ FD_CLR(connection, &SavedClientsWithInput);
+ }
+ FD_CLR(connection, &ClientsWriteBlocked);
+ if (!XFD_ANYSET(&ClientsWriteBlocked))
+ AnyClientsWriteBlocked = FALSE;
+ FD_CLR(connection, &OutputPending);
+}
+
+/*****************
+ * CheckConnections
+ * Some connection has died, go find which one and shut it down
+ * The file descriptor has been closed, but is still in AllClients.
+ * If would truly be wonderful if select() would put the bogus
+ * file descriptors in the exception mask, but nooooo. So we have
+ * to check each and every socket individually.
+ *****************/
+
+void
+CheckConnections(void)
+{
+#ifndef WIN32
+ fd_mask mask;
+#endif
+ fd_set tmask;
+ int curclient, curoff;
+ int i;
+ struct timeval notime;
+ int r;
+#ifdef WIN32
+ fd_set savedAllClients;
+#endif
+
+ notime.tv_sec = 0;
+ notime.tv_usec = 0;
+
+#ifndef WIN32
+ for (i=0; i<howmany(XFD_SETSIZE, NFDBITS); i++)
+ {
+ mask = AllClients.fds_bits[i];
+ while (mask)
+ {
+ curoff = ffs (mask) - 1;
+ curclient = curoff + (i * (sizeof(fd_mask)*8));
+ FD_ZERO(&tmask);
+ FD_SET(curclient, &tmask);
+ r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
+ if (r < 0)
+ CloseDownClient(clients[ConnectionTranslation[curclient]]);
+ mask &= ~((fd_mask)1 << curoff);
+ }
+ }
+#else
+ XFD_COPYSET(&AllClients, &savedAllClients);
+ for (i = 0; i < XFD_SETCOUNT(&savedAllClients); i++)
+ {
+ curclient = XFD_FD(&savedAllClients, i);
+ FD_ZERO(&tmask);
+ FD_SET(curclient, &tmask);
+ r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
+ if (r < 0)
+ CloseDownClient(clients[GetConnectionTranslation(curclient)]);
+ }
+#endif
+}
+
+
+/*****************
+ * CloseDownConnection
+ * Delete client from AllClients and free resources
+ *****************/
+
+void
+CloseDownConnection(ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+
+ if (oc->output && oc->output->count)
+ FlushClient(client, oc, (char *)NULL, 0);
+#ifdef XDMCP
+ XdmcpCloseDisplay(oc->fd);
+#endif
+#ifndef LBX
+ CloseDownFileDescriptor(oc);
+#else
+ (*oc->Close) (client);
+ FreeOsBuffers(oc);
+ xfree(oc);
+#endif
+ client->osPrivate = (pointer)NULL;
+ if (auditTrailLevel > 1)
+ AuditF("client %d disconnected\n", client->index);
+}
+
+void
+AddEnabledDevice(int fd)
+{
+ FD_SET(fd, &EnabledDevices);
+ FD_SET(fd, &AllSockets);
+ if (GrabInProgress)
+ FD_SET(fd, &SavedAllSockets);
+}
+
+void
+RemoveEnabledDevice(int fd)
+{
+ FD_CLR(fd, &EnabledDevices);
+ FD_CLR(fd, &AllSockets);
+ if (GrabInProgress)
+ FD_CLR(fd, &SavedAllSockets);
+}
+
+/*****************
+ * OnlyListenToOneClient:
+ * Only accept requests from one client. Continue to handle new
+ * connections, but don't take any protocol requests from the new
+ * ones. Note that if GrabInProgress is set, EstablishNewConnections
+ * needs to put new clients into SavedAllSockets and SavedAllClients.
+ * Note also that there is no timeout for this in the protocol.
+ * This routine is "undone" by ListenToAllClients()
+ *****************/
+
+void
+OnlyListenToOneClient(ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ int connection = oc->fd;
+
+ if (! GrabInProgress)
+ {
+ XFD_COPYSET(&ClientsWithInput, &SavedClientsWithInput);
+ XFD_ANDSET(&ClientsWithInput,
+ &ClientsWithInput, &GrabImperviousClients);
+ if (FD_ISSET(connection, &SavedClientsWithInput))
+ {
+ FD_CLR(connection, &SavedClientsWithInput);
+ FD_SET(connection, &ClientsWithInput);
+ }
+ XFD_UNSET(&SavedClientsWithInput, &GrabImperviousClients);
+ XFD_COPYSET(&AllSockets, &SavedAllSockets);
+ XFD_COPYSET(&AllClients, &SavedAllClients);
+ XFD_UNSET(&AllSockets, &AllClients);
+ XFD_ANDSET(&AllClients, &AllClients, &GrabImperviousClients);
+ FD_SET(connection, &AllClients);
+ XFD_ORSET(&AllSockets, &AllSockets, &AllClients);
+ GrabInProgress = client->index;
+ }
+}
+
+/****************
+ * ListenToAllClients:
+ * Undoes OnlyListentToOneClient()
+ ****************/
+
+void
+ListenToAllClients(void)
+{
+ if (GrabInProgress)
+ {
+ XFD_ORSET(&AllSockets, &AllSockets, &SavedAllSockets);
+ XFD_ORSET(&AllClients, &AllClients, &SavedAllClients);
+ XFD_ORSET(&ClientsWithInput, &ClientsWithInput, &SavedClientsWithInput);
+ GrabInProgress = 0;
+ }
+}
+
+/****************
+ * IgnoreClient
+ * Removes one client from input masks.
+ * Must have cooresponding call to AttendClient.
+ ****************/
+
+void
+IgnoreClient (ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ int connection = oc->fd;
+#ifdef LBX
+ LbxClientPtr lbxClient = LbxClient(client);
+#endif
+
+ isItTimeToYield = TRUE;
+#ifdef LBX
+ if (lbxClient) {
+ lbxClient->ignored = TRUE;
+ return;
+ }
+#endif
+ if (!GrabInProgress || FD_ISSET(connection, &AllClients))
+ {
+ if (FD_ISSET (connection, &ClientsWithInput))
+ FD_SET(connection, &IgnoredClientsWithInput);
+ else
+ FD_CLR(connection, &IgnoredClientsWithInput);
+ FD_CLR(connection, &ClientsWithInput);
+ FD_CLR(connection, &AllSockets);
+ FD_CLR(connection, &AllClients);
+ FD_CLR(connection, &LastSelectMask);
+ }
+ else
+ {
+ if (FD_ISSET (connection, &SavedClientsWithInput))
+ FD_SET(connection, &IgnoredClientsWithInput);
+ else
+ FD_CLR(connection, &IgnoredClientsWithInput);
+ FD_CLR(connection, &SavedClientsWithInput);
+ FD_CLR(connection, &SavedAllSockets);
+ FD_CLR(connection, &SavedAllClients);
+ }
+}
+
+/****************
+ * AttendClient
+ * Adds one client back into the input masks.
+ ****************/
+
+void
+AttendClient (ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ int connection = oc->fd;
+#ifdef LBX
+ LbxClientPtr lbxClient = LbxClient(client);
+
+ if (lbxClient) {
+ lbxClient->ignored = FALSE;
+ return;
+ }
+#endif
+ if (!GrabInProgress || GrabInProgress == client->index ||
+ FD_ISSET(connection, &GrabImperviousClients))
+ {
+ FD_SET(connection, &AllClients);
+ FD_SET(connection, &AllSockets);
+ FD_SET(connection, &LastSelectMask);
+ if (FD_ISSET (connection, &IgnoredClientsWithInput))
+ FD_SET(connection, &ClientsWithInput);
+ }
+ else
+ {
+ FD_SET(connection, &SavedAllClients);
+ FD_SET(connection, &SavedAllSockets);
+ if (FD_ISSET(connection, &IgnoredClientsWithInput))
+ FD_SET(connection, &SavedClientsWithInput);
+ }
+}
+
+/* make client impervious to grabs; assume only executing client calls this */
+
+void
+MakeClientGrabImpervious(ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ int connection = oc->fd;
+
+ FD_SET(connection, &GrabImperviousClients);
+
+ if (ServerGrabCallback)
+ {
+ ServerGrabInfoRec grabinfo;
+ grabinfo.client = client;
+ grabinfo.grabstate = CLIENT_IMPERVIOUS;
+ CallCallbacks(&ServerGrabCallback, &grabinfo);
+ }
+}
+
+/* make client pervious to grabs; assume only executing client calls this */
+
+void
+MakeClientGrabPervious(ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ int connection = oc->fd;
+
+ FD_CLR(connection, &GrabImperviousClients);
+ if (GrabInProgress && (GrabInProgress != client->index))
+ {
+ if (FD_ISSET(connection, &ClientsWithInput))
+ {
+ FD_SET(connection, &SavedClientsWithInput);
+ FD_CLR(connection, &ClientsWithInput);
+ }
+ FD_CLR(connection, &AllSockets);
+ FD_CLR(connection, &AllClients);
+ isItTimeToYield = TRUE;
+ }
+
+ if (ServerGrabCallback)
+ {
+ ServerGrabInfoRec grabinfo;
+ grabinfo.client = client;
+ grabinfo.grabstate = CLIENT_PERVIOUS;
+ CallCallbacks(&ServerGrabCallback, &grabinfo);
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/os/connection.c.NX.original b/nx-X11/programs/Xserver/os/connection.c.NX.original
new file mode 100644
index 000000000..e3319b338
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/connection.c.NX.original
@@ -0,0 +1,1424 @@
+/* $Xorg: connection.c,v 1.6 2001/02/09 02:05:23 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/os/connection.c,v 3.64 2003/10/07 22:50:42 herrb Exp $ */
+/*****************************************************************
+ * Stuff to create connections --- OS dependent
+ *
+ * EstablishNewConnections, CreateWellKnownSockets, ResetWellKnownSockets,
+ * CloseDownConnection, CheckConnections, AddEnabledDevice,
+ * RemoveEnabledDevice, OnlyListToOneClient,
+ * ListenToAllClients,
+ *
+ * (WaitForSomething is in its own file)
+ *
+ * In this implementation, a client socket table is not kept.
+ * Instead, what would be the index into the table is just the
+ * file descriptor of the socket. This won't work for if the
+ * socket ids aren't small nums (0 - 2^8)
+ *
+ *****************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#endif
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#define XSERV_t
+#define TRANS_SERVER
+#define TRANS_REOPEN
+#include <X11/Xtrans/Xtrans.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifndef WIN32
+#if defined(Lynx)
+#include <socket.h>
+#else
+#include <sys/socket.h>
+#endif
+
+#ifdef hpux
+#include <sys/utsname.h>
+#include <sys/ioctl.h>
+#endif
+
+#if defined(DGUX)
+#include <sys/ioctl.h>
+#include <sys/utsname.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <sys/param.h>
+#include <unistd.h>
+#endif
+
+
+#ifdef AIXV3
+#include <sys/ioctl.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define select(n,r,w,x,t) os2PseudoSelect(n,r,w,x,t)
+extern __const__ int _nfiles;
+#endif
+
+#if defined(TCPCONN) || defined(STREAMSCONN)
+# include <netinet/in.h>
+# include <arpa/inet.h>
+# if !defined(hpux)
+# ifdef apollo
+# ifndef NO_TCP_H
+# include <netinet/tcp.h>
+# endif
+# else
+# ifdef CSRG_BASED
+# include <sys/param.h>
+# endif
+# ifndef __UNIXOS2__
+# include <netinet/tcp.h>
+# endif
+# endif
+# endif
+# include <arpa/inet.h>
+#endif
+
+#if !defined(__UNIXOS2__)
+#ifndef Lynx
+#include <sys/uio.h>
+#else
+#include <uio.h>
+#endif
+#endif
+#endif /* WIN32 */
+#include "misc.h" /* for typedef of pointer */
+#include "osdep.h"
+#include <X11/Xpoll.h>
+#include "opaque.h"
+#include "dixstruct.h"
+#ifdef XAPPGROUP
+#include <X11/extensions/Xagsrv.h>
+#endif
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+#ifdef LBX
+#include "colormapst.h"
+#include "propertyst.h"
+#include "lbxserve.h"
+#include "osdep.h"
+#endif
+
+#ifdef X_NOT_POSIX
+#define Pid_t int
+#else
+#define Pid_t pid_t
+#endif
+
+#ifdef DNETCONN
+#include <netdnet/dn.h>
+#endif /* DNETCONN */
+
+int lastfdesc; /* maximum file descriptor */
+
+fd_set WellKnownConnections; /* Listener mask */
+fd_set EnabledDevices; /* mask for input devices that are on */
+fd_set AllSockets; /* select on this */
+fd_set AllClients; /* available clients */
+fd_set LastSelectMask; /* mask returned from last select call */
+fd_set ClientsWithInput; /* clients with FULL requests in buffer */
+fd_set ClientsWriteBlocked; /* clients who cannot receive output */
+fd_set OutputPending; /* clients with reply/event data ready to go */
+int MaxClients = 0;
+Bool NewOutputPending; /* not yet attempted to write some new output */
+Bool AnyClientsWriteBlocked; /* true if some client blocked on write */
+
+Bool RunFromSmartParent; /* send SIGUSR1 to parent process */
+Bool PartialNetwork; /* continue even if unable to bind all addrs */
+static Pid_t ParentProcess;
+#ifdef __UNIXOS2__
+Pid_t GetPPID(Pid_t pid);
+#endif
+
+static Bool debug_conns = FALSE;
+
+fd_set IgnoredClientsWithInput;
+static fd_set GrabImperviousClients;
+static fd_set SavedAllClients;
+static fd_set SavedAllSockets;
+static fd_set SavedClientsWithInput;
+int GrabInProgress = 0;
+
+#if !defined(WIN32)
+int *ConnectionTranslation = NULL;
+#else
+/*
+ * On NT fds are not between 0 and MAXSOCKS, they are unrelated, and there is
+ * not even a known maximum value, so use something quite arbitrary for now.
+ * Do storage is a hash table of size 256. Collisions are handled in a linked
+ * list.
+ */
+
+#undef MAXSOCKS
+#define MAXSOCKS 500
+#undef MAXSELECT
+#define MAXSELECT 500
+#define MAXFD 500
+
+struct _ct_node {
+ struct _ct_node *next;
+ int key;
+ int value;
+};
+
+struct _ct_node *ct_head[256];
+
+void InitConnectionTranslation(void)
+{
+ bzero(ct_head, sizeof(ct_head));
+}
+
+int GetConnectionTranslation(int conn)
+{
+ struct _ct_node *node = ct_head[conn & 0xff];
+ while (node != NULL)
+ {
+ if (node->key == conn)
+ return node->value;
+ node = node->next;
+ }
+ return 0;
+}
+
+void SetConnectionTranslation(int conn, int client)
+{
+ struct _ct_node **node = ct_head + (conn & 0xff);
+ if (client == 0) /* remove entry */
+ {
+ while (*node != NULL)
+ {
+ if ((*node)->key == conn)
+ {
+ struct _ct_node *temp = *node;
+ *node = (*node)->next;
+ free(temp);
+ return;
+ }
+ node = &((*node)->next);
+ }
+ return;
+ } else
+ {
+ while (*node != NULL)
+ {
+ if ((*node)->key == conn)
+ {
+ (*node)->value = client;
+ return;
+ }
+ node = &((*node)->next);
+ }
+ *node = (struct _ct_node*)xalloc(sizeof(struct _ct_node));
+ (*node)->next = NULL;
+ (*node)->key = conn;
+ (*node)->value = client;
+ return;
+ }
+}
+
+void ClearConnectionTranslation(void)
+{
+ unsigned i;
+ for (i = 0; i < 256; i++)
+ {
+ struct _ct_node *node = ct_head[i];
+ while (node != NULL)
+ {
+ struct _ct_node *temp = node;
+ node = node->next;
+ xfree(temp);
+ }
+ }
+}
+#endif
+
+XtransConnInfo *ListenTransConns = NULL;
+int *ListenTransFds = NULL;
+int ListenTransCount;
+
+static void ErrorConnMax(XtransConnInfo /* trans_conn */);
+
+#ifndef LBX
+static
+void CloseDownFileDescriptor(
+ OsCommPtr /*oc*/
+);
+#endif
+
+
+static XtransConnInfo
+lookup_trans_conn (int fd)
+{
+ if (ListenTransFds)
+ {
+ int i;
+ for (i = 0; i < ListenTransCount; i++)
+ if (ListenTransFds[i] == fd)
+ return ListenTransConns[i];
+ }
+
+ return (NULL);
+}
+
+/* Set MaxClients and lastfdesc, and allocate ConnectionTranslation */
+
+void
+InitConnectionLimits(void)
+{
+ lastfdesc = -1;
+
+#ifndef __CYGWIN__
+
+#ifndef __UNIXOS2__
+
+#if !defined(XNO_SYSCONF) && defined(_SC_OPEN_MAX)
+ lastfdesc = sysconf(_SC_OPEN_MAX) - 1;
+#endif
+
+#ifdef HAS_GETDTABLESIZE
+ if (lastfdesc < 0)
+ lastfdesc = getdtablesize() - 1;
+#endif
+
+#ifdef _NFILE
+ if (lastfdesc < 0)
+ lastfdesc = _NFILE - 1;
+#endif
+
+#else /* __UNIXOS2__ */
+ lastfdesc = _nfiles - 1;
+#endif
+
+#endif /* __CYGWIN__ */
+
+ /* This is the fallback */
+ if (lastfdesc < 0)
+ lastfdesc = MAXSOCKS;
+
+ if (lastfdesc > MAXSELECT)
+ lastfdesc = MAXSELECT;
+
+ if (lastfdesc > MAXCLIENTS)
+ {
+ lastfdesc = MAXCLIENTS;
+ if (debug_conns)
+ ErrorF( "REACHED MAXIMUM CLIENTS LIMIT %d\n", MAXCLIENTS);
+ }
+ MaxClients = lastfdesc;
+
+#ifdef DEBUG
+ ErrorF("InitConnectionLimits: MaxClients = %d\n", MaxClients);
+#endif
+
+#if !defined(WIN32)
+ ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1));
+#else
+ InitConnectionTranslation();
+#endif
+}
+
+
+/*****************
+ * CreateWellKnownSockets
+ * At initialization, create the sockets to listen on for new clients.
+ *****************/
+
+void
+CreateWellKnownSockets(void)
+{
+ int i;
+ int partial;
+ char port[20];
+ OsSigHandlerPtr handler;
+
+ FD_ZERO(&AllSockets);
+ FD_ZERO(&AllClients);
+ FD_ZERO(&LastSelectMask);
+ FD_ZERO(&ClientsWithInput);
+
+#if !defined(WIN32)
+ for (i=0; i<MaxClients; i++) ConnectionTranslation[i] = 0;
+#else
+ ClearConnectionTranslation();
+#endif
+
+ FD_ZERO (&WellKnownConnections);
+
+ sprintf (port, "%d", atoi (display));
+
+ if ((_XSERVTransMakeAllCOTSServerListeners (port, &partial,
+ &ListenTransCount, &ListenTransConns) >= 0) &&
+ (ListenTransCount >= 1))
+ {
+ if (!PartialNetwork && partial)
+ {
+ FatalError ("Failed to establish all listening sockets");
+ }
+ else
+ {
+ ListenTransFds = (int *) xalloc (ListenTransCount * sizeof (int));
+
+ for (i = 0; i < ListenTransCount; i++)
+ {
+ int fd = _XSERVTransGetConnectionNumber (ListenTransConns[i]);
+
+ ListenTransFds[i] = fd;
+ FD_SET (fd, &WellKnownConnections);
+
+ if (!_XSERVTransIsLocal (ListenTransConns[i]))
+ {
+ DefineSelf (fd);
+ }
+ }
+ }
+ }
+
+ if (!XFD_ANYSET (&WellKnownConnections))
+ FatalError ("Cannot establish any listening sockets - Make sure an X server isn't already running");
+#if !defined(WIN32)
+ OsSignal (SIGPIPE, SIG_IGN);
+ OsSignal (SIGHUP, AutoResetServer);
+#endif
+ OsSignal (SIGINT, GiveUp);
+ OsSignal (SIGTERM, GiveUp);
+ XFD_COPYSET (&WellKnownConnections, &AllSockets);
+ ResetHosts(display);
+ /*
+ * Magic: If SIGUSR1 was set to SIG_IGN when
+ * the server started, assume that either
+ *
+ * a- The parent process is ignoring SIGUSR1
+ *
+ * or
+ *
+ * b- The parent process is expecting a SIGUSR1
+ * when the server is ready to accept connections
+ *
+ * In the first case, the signal will be harmless,
+ * in the second case, the signal will be quite
+ * useful
+ */
+#if !defined(WIN32)
+ handler = OsSignal (SIGUSR1, SIG_IGN);
+ if ( handler == SIG_IGN)
+ RunFromSmartParent = TRUE;
+ OsSignal(SIGUSR1, handler);
+ ParentProcess = getppid ();
+#ifdef __UNIXOS2__
+ /*
+ * fg030505: under OS/2, xinit is not the parent process but
+ * the "grant parent" process of the server because execvpe()
+ * presents us an additional process number;
+ * GetPPID(pid) is part of libemxfix
+ */
+ ParentProcess = GetPPID (ParentProcess);
+#endif /* __UNIXOS2__ */
+ if (RunFromSmartParent) {
+ if (ParentProcess > 1) {
+ kill (ParentProcess, SIGUSR1);
+ }
+ }
+#endif
+#ifdef XDMCP
+ XdmcpInit ();
+#endif
+}
+
+#ifdef NX_TRANS_SOCKET
+
+/*
+ * The following block is now defined also
+ * under Cygwin to support this environment.
+ */
+
+#ifndef __DARWIN__
+
+/*
+ * This is defined in Xtranssock.c and must
+ * be called explicitly as it doesn't share
+ * a pointer in the transport function table.
+ */
+
+extern void _XSERVTransSocketRejectConnection(XtransConnInfo);
+
+void
+RejectWellKnownSockets ()
+{
+ int i;
+
+ for (i = 0; i < ListenTransCount; i++)
+ {
+ _XSERVTransSocketRejectConnection(ListenTransConns[i]);
+ }
+}
+
+#endif /* #ifndef __DARWIN__ */
+
+#else /* #ifdef NX_TRANS_SOCKET */
+
+void
+RejectWellKnownSockets ()
+{
+}
+
+#endif /* #ifdef NX_TRANS_SOCKET */
+
+void
+ResetWellKnownSockets (void)
+{
+ int i;
+
+ ResetOsBuffers();
+
+ for (i = 0; i < ListenTransCount; i++)
+ {
+ int status = _XSERVTransResetListener (ListenTransConns[i]);
+
+ if (status != TRANS_RESET_NOOP)
+ {
+ if (status == TRANS_RESET_FAILURE)
+ {
+ /*
+ * ListenTransConns[i] freed by xtrans.
+ * Remove it from out list.
+ */
+
+ FD_CLR (ListenTransFds[i], &WellKnownConnections);
+ ListenTransFds[i] = ListenTransFds[ListenTransCount - 1];
+ ListenTransConns[i] = ListenTransConns[ListenTransCount - 1];
+ ListenTransCount -= 1;
+ i -= 1;
+ }
+ else if (status == TRANS_RESET_NEW_FD)
+ {
+ /*
+ * A new file descriptor was allocated (the old one was closed)
+ */
+
+ int newfd = _XSERVTransGetConnectionNumber (ListenTransConns[i]);
+
+ FD_CLR (ListenTransFds[i], &WellKnownConnections);
+ ListenTransFds[i] = newfd;
+ FD_SET(newfd, &WellKnownConnections);
+ }
+ }
+ }
+
+ ResetAuthorization ();
+ ResetHosts(display);
+ /*
+ * See above in CreateWellKnownSockets about SIGUSR1
+ */
+#if !defined(WIN32)
+ if (RunFromSmartParent) {
+ if (ParentProcess > 1) {
+ kill (ParentProcess, SIGUSR1);
+ }
+ }
+#endif
+ /*
+ * restart XDMCP
+ */
+#ifdef XDMCP
+ XdmcpReset ();
+#endif
+}
+
+void
+CloseWellKnownConnections(void)
+{
+ int i;
+
+ for (i = 0; i < ListenTransCount; i++)
+ _XSERVTransClose (ListenTransConns[i]);
+}
+
+static void
+AuthAudit (ClientPtr client, Bool letin,
+ struct sockaddr *saddr, int len,
+ unsigned int proto_n, char *auth_proto, int auth_id)
+{
+ char addr[128];
+ char *out = addr;
+
+ if (!((OsCommPtr)client->osPrivate)->trans_conn) {
+ strcpy(addr, "LBX proxy at ");
+ out += strlen(addr);
+ }
+ if (!len)
+ strcpy(out, "local host");
+ else
+ switch (saddr->sa_family)
+ {
+ case AF_UNSPEC:
+#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
+ case AF_UNIX:
+#endif
+ strcpy(out, "local host");
+ break;
+#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
+ case AF_INET:
+ sprintf(out, "IP %s",
+ inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr));
+ break;
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6: {
+ char ipaddr[INET6_ADDRSTRLEN];
+ inet_ntop(AF_INET6, &((struct sockaddr_in6 *) saddr)->sin6_addr,
+ ipaddr, sizeof(ipaddr));
+ sprintf(out, "IP %s", ipaddr);
+ }
+ break;
+#endif
+#endif
+#ifdef DNETCONN
+ case AF_DECnet:
+ sprintf(out, "DN %s",
+ dnet_ntoa(&((struct sockaddr_dn *) saddr)->sdn_add));
+ break;
+#endif
+ default:
+ strcpy(out, "unknown address");
+ }
+
+ if (proto_n)
+ AuditF("client %d %s from %s\n Auth name: %.*s ID: %d\n",
+ client->index, letin ? "connected" : "rejected", addr,
+ (int)proto_n, auth_proto, auth_id);
+ else
+ AuditF("client %d %s from %s\n",
+ client->index, letin ? "connected" : "rejected", addr);
+}
+
+XID
+AuthorizationIDOfClient(ClientPtr client)
+{
+ if (client->osPrivate)
+ return ((OsCommPtr)client->osPrivate)->auth_id;
+ else
+ return None;
+}
+
+
+/*****************************************************************
+ * ClientAuthorized
+ *
+ * Sent by the client at connection setup:
+ * typedef struct _xConnClientPrefix {
+ * CARD8 byteOrder;
+ * BYTE pad;
+ * CARD16 majorVersion, minorVersion;
+ * CARD16 nbytesAuthProto;
+ * CARD16 nbytesAuthString;
+ * } xConnClientPrefix;
+ *
+ * It is hoped that eventually one protocol will be agreed upon. In the
+ * mean time, a server that implements a different protocol than the
+ * client expects, or a server that only implements the host-based
+ * mechanism, will simply ignore this information.
+ *
+ *****************************************************************/
+
+char *
+ClientAuthorized(ClientPtr client,
+ unsigned int proto_n, char *auth_proto,
+ unsigned int string_n, char *auth_string)
+{
+ OsCommPtr priv;
+ Xtransaddr *from = NULL;
+ int family;
+ int fromlen;
+ XID auth_id;
+ char *reason = NULL;
+ XtransConnInfo trans_conn;
+ int restore_trans_conn = 0;
+ ClientPtr lbxpc = NULL;
+
+ priv = (OsCommPtr)client->osPrivate;
+ trans_conn = priv->trans_conn;
+
+#ifdef LBX
+ if (!trans_conn) {
+ /*
+ * Since trans_conn is NULL, this must be a proxy's client for
+ * which we have NO address. Therefore, we will temporarily
+ * set the client's trans_conn to the proxy's trans_conn and
+ * after CheckAuthorization the client's trans_conn will be
+ * restored.
+ *
+ * If XDM-AUTHORIZATION-1 is being used, CheckAuthorization
+ * will eventually call XdmAuthorizationValidate and this
+ * later function may use the client's trans_conn to get the
+ * client's address. Since a XDM-AUTH-1 auth string includes
+ * the client's address, this address is compared to the address
+ * in the client's trans_conn. If the proxy and client are
+ * on the same host, the comparison will fail; otherwise the
+ * comparison will fail and the client will not be authorized
+ * to connect to the server.
+ *
+ * The basis for this additional code is to prevent a
+ * NULL pointer dereference of the client's trans_conn.
+ * The fundamental problem - the fact that the client's
+ * trans_conn is NULL - is because the NewClient
+ * request in version 1.0 of the LBX protocol does not
+ * send the client's address to the server. When the
+ * spec is changed and the client's address is sent to
+ * server in the NewClient request, this additional code
+ * should be removed.
+ *
+ * See defect number XWSog08218 for more information.
+ */
+ lbxpc = LbxProxyClient(priv->proxy);
+ trans_conn = ((OsCommPtr)lbxpc->osPrivate)->trans_conn;
+ priv->trans_conn = trans_conn;
+ restore_trans_conn = 1;
+ }
+#endif
+
+ auth_id = CheckAuthorization (proto_n, auth_proto,
+ string_n, auth_string, client, &reason);
+
+#ifdef LBX
+ if (! priv->trans_conn) {
+ if (auth_id == (XID) ~0L && !GetAccessControl())
+ auth_id = ((OsCommPtr)lbxpc->osPrivate)->auth_id;
+#ifdef XCSECURITY
+ else if (auth_id != (XID) ~0L && !SecuritySameLevel(lbxpc, auth_id)) {
+ auth_id = (XID) ~0L;
+ reason = "Client trust level differs from that of LBX Proxy";
+ }
+#endif
+ }
+#endif
+ if (auth_id == (XID) ~0L)
+ {
+ if (
+#ifdef XCSECURITY
+ (proto_n == 0 ||
+ strncmp (auth_proto, XSecurityAuthorizationName, proto_n) != 0) &&
+#endif
+ _XSERVTransGetPeerAddr (trans_conn,
+ &family, &fromlen, &from) != -1)
+ {
+ if (
+#ifdef LBX
+ !trans_conn ||
+#endif
+ InvalidHost ((struct sockaddr *) from, fromlen, client))
+ AuthAudit(client, FALSE, (struct sockaddr *) from,
+ fromlen, proto_n, auth_proto, auth_id);
+ else
+ {
+ auth_id = (XID) 0;
+ if (auditTrailLevel > 1)
+ AuthAudit(client, TRUE,
+ (struct sockaddr *) from, fromlen,
+ proto_n, auth_proto, auth_id);
+ }
+
+ xfree ((char *) from);
+ }
+
+ if (auth_id == (XID) ~0L) {
+#ifdef LBX
+ /*
+ * Restore client's trans_conn state
+ */
+ if (restore_trans_conn) {
+ priv->trans_conn = NULL;
+ }
+#endif
+ if (reason)
+ return reason;
+ else
+ return "Client is not authorized to connect to Server";
+ }
+ }
+ else if (auditTrailLevel > 1)
+ {
+ if (_XSERVTransGetPeerAddr (trans_conn,
+ &family, &fromlen, &from) != -1)
+ {
+ AuthAudit(client, TRUE, (struct sockaddr *) from, fromlen,
+ proto_n, auth_proto, auth_id);
+
+ xfree ((char *) from);
+ }
+ }
+ priv->auth_id = auth_id;
+ priv->conn_time = 0;
+
+#ifdef XDMCP
+ /* indicate to Xdmcp protocol that we've opened new client */
+ XdmcpOpenDisplay(priv->fd);
+#endif /* XDMCP */
+#ifdef XAPPGROUP
+ if (ClientStateCallback)
+ XagCallClientStateChange (client);
+#endif
+ /* At this point, if the client is authorized to change the access control
+ * list, we should getpeername() information, and add the client to
+ * the selfhosts list. It's not really the host machine, but the
+ * true purpose of the selfhosts list is to see who may change the
+ * access control list.
+ */
+#ifdef LBX
+ if (restore_trans_conn) {
+ priv->trans_conn = NULL;
+ }
+#endif
+ return((char *)NULL);
+}
+
+static ClientPtr
+#ifdef LBX
+AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time,
+ int (*Flush)(
+ ClientPtr /*who*/, OsCommPtr /*oc*/,
+ char * /*extraBuf*/, int /*extraCount*/),
+ void (*Close)(
+ ClientPtr /*client*/),
+ LbxProxyPtr proxy)
+#else
+AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time)
+#endif
+{
+ OsCommPtr oc;
+ ClientPtr client;
+
+ if (
+#ifdef LBX
+ trans_conn &&
+#endif
+#ifndef WIN32
+ fd >= lastfdesc
+#else
+ XFD_SETCOUNT(&AllClients) >= MaxClients
+#endif
+ )
+ return NullClient;
+ oc = (OsCommPtr)xalloc(sizeof(OsCommRec));
+ if (!oc)
+ return NullClient;
+ oc->trans_conn = trans_conn;
+ oc->fd = fd;
+ oc->input = (ConnectionInputPtr)NULL;
+ oc->output = (ConnectionOutputPtr)NULL;
+ oc->auth_id = None;
+ oc->conn_time = conn_time;
+#ifdef LBX
+ oc->proxy = proxy;
+ oc->Flush = Flush;
+ oc->Close = Close;
+ oc->largereq = (ConnectionInputPtr) NULL;
+#endif
+ if (!(client = NextAvailableClient((pointer)oc)))
+ {
+ xfree (oc);
+ return NullClient;
+ }
+#ifdef LBX
+ if (trans_conn)
+#endif
+ {
+#if !defined(WIN32)
+ ConnectionTranslation[fd] = client->index;
+#else
+ SetConnectionTranslation(fd, client->index);
+#endif
+ if (GrabInProgress)
+ {
+ FD_SET(fd, &SavedAllClients);
+ FD_SET(fd, &SavedAllSockets);
+ }
+ else
+ {
+ FD_SET(fd, &AllClients);
+ FD_SET(fd, &AllSockets);
+ }
+ }
+
+#ifdef DEBUG
+ ErrorF("AllocNewConnection: client index = %d, socket fd = %d\n",
+ client->index, fd);
+#endif
+
+ return client;
+}
+
+#ifdef LBX
+
+int
+ClientConnectionNumber (ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
+
+ return oc->fd;
+}
+
+ClientPtr
+AllocLbxClientConnection (ClientPtr client, LbxProxyPtr proxy)
+{
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
+
+ return AllocNewConnection ((XtransConnInfo)NULL, oc->fd, GetTimeInMillis(),
+ LbxFlushClient, LbxCloseClient, proxy);
+}
+
+void
+LbxProxyConnection (ClientPtr client, LbxProxyPtr proxy)
+{
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
+
+ FlushClient(client, oc, (char *)NULL, 0);
+ oc->proxy = proxy;
+ oc->Flush = LbxFlushClient;
+ oc->Close = LbxCloseClient;
+ LbxPrimeInput(client, proxy);
+}
+
+#endif
+
+/*****************
+ * EstablishNewConnections
+ * If anyone is waiting on listened sockets, accept them.
+ * Returns a mask with indices of new clients. Updates AllClients
+ * and AllSockets.
+ *****************/
+
+/*ARGSUSED*/
+Bool
+EstablishNewConnections(ClientPtr clientUnused, pointer closure)
+{
+ fd_set readyconnections; /* set of listeners that are ready */
+ int curconn; /* fd of listener that's ready */
+ register int newconn; /* fd of new client */
+ CARD32 connect_time;
+ register int i;
+ register ClientPtr client;
+ register OsCommPtr oc;
+ fd_set tmask;
+
+ XFD_ANDSET (&tmask, (fd_set*)closure, &WellKnownConnections);
+ XFD_COPYSET(&tmask, &readyconnections);
+ if (!XFD_ANYSET(&readyconnections))
+ return TRUE;
+ connect_time = GetTimeInMillis();
+ /* kill off stragglers */
+ for (i=1; i<currentMaxClients; i++)
+ {
+ if ((client = clients[i]))
+ {
+ oc = (OsCommPtr)(client->osPrivate);
+ if ((oc && (oc->conn_time != 0) &&
+ (connect_time - oc->conn_time) >= TimeOutValue) ||
+ (client->noClientException != Success && !client->clientGone))
+ CloseDownClient(client);
+ }
+ }
+#ifndef WIN32
+ for (i = 0; i < howmany(XFD_SETSIZE, NFDBITS); i++)
+ {
+ while (readyconnections.fds_bits[i])
+#else
+ for (i = 0; i < XFD_SETCOUNT(&readyconnections); i++)
+#endif
+ {
+ XtransConnInfo trans_conn, new_trans_conn;
+ int status;
+
+#ifndef WIN32
+ curconn = ffs (readyconnections.fds_bits[i]) - 1;
+ readyconnections.fds_bits[i] &= ~((fd_mask)1 << curconn);
+ curconn += (i * (sizeof(fd_mask)*8));
+#else
+ curconn = XFD_FD(&readyconnections, i);
+#endif
+
+ if ((trans_conn = lookup_trans_conn (curconn)) == NULL)
+ continue;
+
+ if ((new_trans_conn = _XSERVTransAccept (trans_conn, &status)) == NULL)
+ continue;
+
+ newconn = _XSERVTransGetConnectionNumber (new_trans_conn);
+
+ if (newconn < lastfdesc)
+ {
+ int clientid;
+#if !defined(WIN32)
+ clientid = ConnectionTranslation[newconn];
+#else
+ clientid = GetConnectionTranslation(newconn);
+#endif
+ if(clientid && (client = clients[clientid]))
+ CloseDownClient(client);
+ }
+
+ _XSERVTransSetOption(new_trans_conn, TRANS_NONBLOCKING, 1);
+
+ if (!AllocNewConnection (new_trans_conn, newconn, connect_time
+#ifdef LBX
+ , StandardFlushClient,
+ CloseDownFileDescriptor, (LbxProxyPtr)NULL
+#endif
+ ))
+ {
+ ErrorConnMax(new_trans_conn);
+ _XSERVTransClose(new_trans_conn);
+ }
+ }
+#ifndef WIN32
+ }
+#endif
+ return TRUE;
+}
+
+#define NOROOM "Maximum number of clients reached"
+
+/************
+ * ErrorConnMax
+ * Fail a connection due to lack of client or file descriptor space
+ ************/
+
+static void
+ErrorConnMax(XtransConnInfo trans_conn)
+{
+ int fd = _XSERVTransGetConnectionNumber (trans_conn);
+ xConnSetupPrefix csp;
+ char pad[3];
+ struct iovec iov[3];
+ char byteOrder = 0;
+ int whichbyte = 1;
+ struct timeval waittime;
+ fd_set mask;
+
+ /* if these seems like a lot of trouble to go to, it probably is */
+ waittime.tv_sec = BOTIMEOUT / MILLI_PER_SECOND;
+ waittime.tv_usec = (BOTIMEOUT % MILLI_PER_SECOND) *
+ (1000000 / MILLI_PER_SECOND);
+ FD_ZERO(&mask);
+ FD_SET(fd, &mask);
+ (void)Select(fd + 1, &mask, NULL, NULL, &waittime);
+ /* try to read the byte-order of the connection */
+ (void)_XSERVTransRead(trans_conn, &byteOrder, 1);
+ if ((byteOrder == 'l') || (byteOrder == 'B'))
+ {
+ csp.success = xFalse;
+ csp.lengthReason = sizeof(NOROOM) - 1;
+ csp.length = (sizeof(NOROOM) + 2) >> 2;
+ csp.majorVersion = X_PROTOCOL;
+ csp.minorVersion = X_PROTOCOL_REVISION;
+ if (((*(char *) &whichbyte) && (byteOrder == 'B')) ||
+ (!(*(char *) &whichbyte) && (byteOrder == 'l')))
+ {
+ swaps(&csp.majorVersion, whichbyte);
+ swaps(&csp.minorVersion, whichbyte);
+ swaps(&csp.length, whichbyte);
+ }
+ iov[0].iov_len = sz_xConnSetupPrefix;
+ iov[0].iov_base = (char *) &csp;
+ iov[1].iov_len = csp.lengthReason;
+ iov[1].iov_base = NOROOM;
+ iov[2].iov_len = (4 - (csp.lengthReason & 3)) & 3;
+ iov[2].iov_base = pad;
+ (void)_XSERVTransWritev(trans_conn, iov, 3);
+ }
+}
+
+/************
+ * CloseDownFileDescriptor:
+ * Remove this file descriptor and it's I/O buffers, etc.
+ ************/
+
+#ifdef LBX
+void
+CloseDownFileDescriptor(ClientPtr client)
+#else
+static void
+CloseDownFileDescriptor(OsCommPtr oc)
+#endif
+{
+#ifdef LBX
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
+#endif
+ int connection = oc->fd;
+
+ if (oc->trans_conn) {
+ _XSERVTransDisconnect(oc->trans_conn);
+ _XSERVTransClose(oc->trans_conn);
+ }
+#ifndef LBX
+ FreeOsBuffers(oc);
+ xfree(oc);
+#endif
+#ifndef WIN32
+ ConnectionTranslation[connection] = 0;
+#else
+ SetConnectionTranslation(connection, 0);
+#endif
+ FD_CLR(connection, &AllSockets);
+ FD_CLR(connection, &AllClients);
+ FD_CLR(connection, &ClientsWithInput);
+ FD_CLR(connection, &GrabImperviousClients);
+ if (GrabInProgress)
+ {
+ FD_CLR(connection, &SavedAllSockets);
+ FD_CLR(connection, &SavedAllClients);
+ FD_CLR(connection, &SavedClientsWithInput);
+ }
+ FD_CLR(connection, &ClientsWriteBlocked);
+ if (!XFD_ANYSET(&ClientsWriteBlocked))
+ AnyClientsWriteBlocked = FALSE;
+ FD_CLR(connection, &OutputPending);
+}
+
+/*****************
+ * CheckConnections
+ * Some connection has died, go find which one and shut it down
+ * The file descriptor has been closed, but is still in AllClients.
+ * If would truly be wonderful if select() would put the bogus
+ * file descriptors in the exception mask, but nooooo. So we have
+ * to check each and every socket individually.
+ *****************/
+
+void
+CheckConnections(void)
+{
+#ifndef WIN32
+ fd_mask mask;
+#endif
+ fd_set tmask;
+ int curclient, curoff;
+ int i;
+ struct timeval notime;
+ int r;
+#ifdef WIN32
+ fd_set savedAllClients;
+#endif
+
+ notime.tv_sec = 0;
+ notime.tv_usec = 0;
+
+#ifndef WIN32
+ for (i=0; i<howmany(XFD_SETSIZE, NFDBITS); i++)
+ {
+ mask = AllClients.fds_bits[i];
+ while (mask)
+ {
+ curoff = ffs (mask) - 1;
+ curclient = curoff + (i * (sizeof(fd_mask)*8));
+ FD_ZERO(&tmask);
+ FD_SET(curclient, &tmask);
+ r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
+ if (r < 0)
+ CloseDownClient(clients[ConnectionTranslation[curclient]]);
+ mask &= ~((fd_mask)1 << curoff);
+ }
+ }
+#else
+ XFD_COPYSET(&AllClients, &savedAllClients);
+ for (i = 0; i < XFD_SETCOUNT(&savedAllClients); i++)
+ {
+ curclient = XFD_FD(&savedAllClients, i);
+ FD_ZERO(&tmask);
+ FD_SET(curclient, &tmask);
+ r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
+ if (r < 0)
+ CloseDownClient(clients[GetConnectionTranslation(curclient)]);
+ }
+#endif
+}
+
+
+/*****************
+ * CloseDownConnection
+ * Delete client from AllClients and free resources
+ *****************/
+
+void
+CloseDownConnection(ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+
+ if (oc->output && oc->output->count)
+ FlushClient(client, oc, (char *)NULL, 0);
+#ifdef XDMCP
+ XdmcpCloseDisplay(oc->fd);
+#endif
+#ifndef LBX
+ CloseDownFileDescriptor(oc);
+#else
+ (*oc->Close) (client);
+ FreeOsBuffers(oc);
+ xfree(oc);
+#endif
+ client->osPrivate = (pointer)NULL;
+ if (auditTrailLevel > 1)
+ AuditF("client %d disconnected\n", client->index);
+}
+
+void
+AddEnabledDevice(int fd)
+{
+ FD_SET(fd, &EnabledDevices);
+ FD_SET(fd, &AllSockets);
+ if (GrabInProgress)
+ FD_SET(fd, &SavedAllSockets);
+}
+
+void
+RemoveEnabledDevice(int fd)
+{
+ FD_CLR(fd, &EnabledDevices);
+ FD_CLR(fd, &AllSockets);
+ if (GrabInProgress)
+ FD_CLR(fd, &SavedAllSockets);
+}
+
+/*****************
+ * OnlyListenToOneClient:
+ * Only accept requests from one client. Continue to handle new
+ * connections, but don't take any protocol requests from the new
+ * ones. Note that if GrabInProgress is set, EstablishNewConnections
+ * needs to put new clients into SavedAllSockets and SavedAllClients.
+ * Note also that there is no timeout for this in the protocol.
+ * This routine is "undone" by ListenToAllClients()
+ *****************/
+
+void
+OnlyListenToOneClient(ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ int connection = oc->fd;
+
+ if (! GrabInProgress)
+ {
+ XFD_COPYSET(&ClientsWithInput, &SavedClientsWithInput);
+ XFD_ANDSET(&ClientsWithInput,
+ &ClientsWithInput, &GrabImperviousClients);
+ if (FD_ISSET(connection, &SavedClientsWithInput))
+ {
+ FD_CLR(connection, &SavedClientsWithInput);
+ FD_SET(connection, &ClientsWithInput);
+ }
+ XFD_UNSET(&SavedClientsWithInput, &GrabImperviousClients);
+ XFD_COPYSET(&AllSockets, &SavedAllSockets);
+ XFD_COPYSET(&AllClients, &SavedAllClients);
+ XFD_UNSET(&AllSockets, &AllClients);
+ XFD_ANDSET(&AllClients, &AllClients, &GrabImperviousClients);
+ FD_SET(connection, &AllClients);
+ XFD_ORSET(&AllSockets, &AllSockets, &AllClients);
+ GrabInProgress = client->index;
+ }
+}
+
+/****************
+ * ListenToAllClients:
+ * Undoes OnlyListentToOneClient()
+ ****************/
+
+void
+ListenToAllClients(void)
+{
+ if (GrabInProgress)
+ {
+ XFD_ORSET(&AllSockets, &AllSockets, &SavedAllSockets);
+ XFD_ORSET(&AllClients, &AllClients, &SavedAllClients);
+ XFD_ORSET(&ClientsWithInput, &ClientsWithInput, &SavedClientsWithInput);
+ GrabInProgress = 0;
+ }
+}
+
+/****************
+ * IgnoreClient
+ * Removes one client from input masks.
+ * Must have cooresponding call to AttendClient.
+ ****************/
+
+void
+IgnoreClient (ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ int connection = oc->fd;
+#ifdef LBX
+ LbxClientPtr lbxClient = LbxClient(client);
+#endif
+
+ isItTimeToYield = TRUE;
+#ifdef LBX
+ if (lbxClient) {
+ lbxClient->ignored = TRUE;
+ return;
+ }
+#endif
+ if (!GrabInProgress || FD_ISSET(connection, &AllClients))
+ {
+ if (FD_ISSET (connection, &ClientsWithInput))
+ FD_SET(connection, &IgnoredClientsWithInput);
+ else
+ FD_CLR(connection, &IgnoredClientsWithInput);
+ FD_CLR(connection, &ClientsWithInput);
+ FD_CLR(connection, &AllSockets);
+ FD_CLR(connection, &AllClients);
+ FD_CLR(connection, &LastSelectMask);
+ }
+ else
+ {
+ if (FD_ISSET (connection, &SavedClientsWithInput))
+ FD_SET(connection, &IgnoredClientsWithInput);
+ else
+ FD_CLR(connection, &IgnoredClientsWithInput);
+ FD_CLR(connection, &SavedClientsWithInput);
+ FD_CLR(connection, &SavedAllSockets);
+ FD_CLR(connection, &SavedAllClients);
+ }
+}
+
+/****************
+ * AttendClient
+ * Adds one client back into the input masks.
+ ****************/
+
+void
+AttendClient (ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ int connection = oc->fd;
+#ifdef LBX
+ LbxClientPtr lbxClient = LbxClient(client);
+
+ if (lbxClient) {
+ lbxClient->ignored = FALSE;
+ return;
+ }
+#endif
+ if (!GrabInProgress || GrabInProgress == client->index ||
+ FD_ISSET(connection, &GrabImperviousClients))
+ {
+ FD_SET(connection, &AllClients);
+ FD_SET(connection, &AllSockets);
+ FD_SET(connection, &LastSelectMask);
+ if (FD_ISSET (connection, &IgnoredClientsWithInput))
+ FD_SET(connection, &ClientsWithInput);
+ }
+ else
+ {
+ FD_SET(connection, &SavedAllClients);
+ FD_SET(connection, &SavedAllSockets);
+ if (FD_ISSET(connection, &IgnoredClientsWithInput))
+ FD_SET(connection, &SavedClientsWithInput);
+ }
+}
+
+/* make client impervious to grabs; assume only executing client calls this */
+
+void
+MakeClientGrabImpervious(ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ int connection = oc->fd;
+
+ FD_SET(connection, &GrabImperviousClients);
+
+ if (ServerGrabCallback)
+ {
+ ServerGrabInfoRec grabinfo;
+ grabinfo.client = client;
+ grabinfo.grabstate = CLIENT_IMPERVIOUS;
+ CallCallbacks(&ServerGrabCallback, &grabinfo);
+ }
+}
+
+/* make client pervious to grabs; assume only executing client calls this */
+
+void
+MakeClientGrabPervious(ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ int connection = oc->fd;
+
+ FD_CLR(connection, &GrabImperviousClients);
+ if (GrabInProgress && (GrabInProgress != client->index))
+ {
+ if (FD_ISSET(connection, &ClientsWithInput))
+ {
+ FD_SET(connection, &SavedClientsWithInput);
+ FD_CLR(connection, &ClientsWithInput);
+ }
+ FD_CLR(connection, &AllSockets);
+ FD_CLR(connection, &AllClients);
+ isItTimeToYield = TRUE;
+ }
+
+ if (ServerGrabCallback)
+ {
+ ServerGrabInfoRec grabinfo;
+ grabinfo.client = client;
+ grabinfo.grabstate = CLIENT_PERVIOUS;
+ CallCallbacks(&ServerGrabCallback, &grabinfo);
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/os/connection.c.X.original b/nx-X11/programs/Xserver/os/connection.c.X.original
new file mode 100644
index 000000000..0a12c655d
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/connection.c.X.original
@@ -0,0 +1,1385 @@
+/* $Xorg: connection.c,v 1.6 2001/02/09 02:05:23 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1987, 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $XFree86: xc/programs/Xserver/os/connection.c,v 3.64 2003/10/07 22:50:42 herrb Exp $ */
+/*****************************************************************
+ * Stuff to create connections --- OS dependent
+ *
+ * EstablishNewConnections, CreateWellKnownSockets, ResetWellKnownSockets,
+ * CloseDownConnection, CheckConnections, AddEnabledDevice,
+ * RemoveEnabledDevice, OnlyListToOneClient,
+ * ListenToAllClients,
+ *
+ * (WaitForSomething is in its own file)
+ *
+ * In this implementation, a client socket table is not kept.
+ * Instead, what would be the index into the table is just the
+ * file descriptor of the socket. This won't work for if the
+ * socket ids aren't small nums (0 - 2^8)
+ *
+ *****************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#endif
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#define XSERV_t
+#define TRANS_SERVER
+#define TRANS_REOPEN
+#include <X11/Xtrans/Xtrans.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifndef WIN32
+#if defined(Lynx)
+#include <socket.h>
+#else
+#include <sys/socket.h>
+#endif
+
+#ifdef hpux
+#include <sys/utsname.h>
+#include <sys/ioctl.h>
+#endif
+
+#if defined(DGUX)
+#include <sys/ioctl.h>
+#include <sys/utsname.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <sys/param.h>
+#include <unistd.h>
+#endif
+
+
+#ifdef AIXV3
+#include <sys/ioctl.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define select(n,r,w,x,t) os2PseudoSelect(n,r,w,x,t)
+extern __const__ int _nfiles;
+#endif
+
+#if defined(TCPCONN) || defined(STREAMSCONN)
+# include <netinet/in.h>
+# include <arpa/inet.h>
+# if !defined(hpux)
+# ifdef apollo
+# ifndef NO_TCP_H
+# include <netinet/tcp.h>
+# endif
+# else
+# ifdef CSRG_BASED
+# include <sys/param.h>
+# endif
+# ifndef __UNIXOS2__
+# include <netinet/tcp.h>
+# endif
+# endif
+# endif
+# include <arpa/inet.h>
+#endif
+
+#if !defined(__UNIXOS2__)
+#ifndef Lynx
+#include <sys/uio.h>
+#else
+#include <uio.h>
+#endif
+#endif
+#endif /* WIN32 */
+#include "misc.h" /* for typedef of pointer */
+#include "osdep.h"
+#include <X11/Xpoll.h>
+#include "opaque.h"
+#include "dixstruct.h"
+#ifdef XAPPGROUP
+#include <X11/extensions/Xagsrv.h>
+#endif
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+#ifdef LBX
+#include "colormapst.h"
+#include "propertyst.h"
+#include "lbxserve.h"
+#include "osdep.h"
+#endif
+
+#ifdef X_NOT_POSIX
+#define Pid_t int
+#else
+#define Pid_t pid_t
+#endif
+
+#ifdef DNETCONN
+#include <netdnet/dn.h>
+#endif /* DNETCONN */
+
+int lastfdesc; /* maximum file descriptor */
+
+fd_set WellKnownConnections; /* Listener mask */
+fd_set EnabledDevices; /* mask for input devices that are on */
+fd_set AllSockets; /* select on this */
+fd_set AllClients; /* available clients */
+fd_set LastSelectMask; /* mask returned from last select call */
+fd_set ClientsWithInput; /* clients with FULL requests in buffer */
+fd_set ClientsWriteBlocked; /* clients who cannot receive output */
+fd_set OutputPending; /* clients with reply/event data ready to go */
+int MaxClients = 0;
+Bool NewOutputPending; /* not yet attempted to write some new output */
+Bool AnyClientsWriteBlocked; /* true if some client blocked on write */
+
+Bool RunFromSmartParent; /* send SIGUSR1 to parent process */
+Bool PartialNetwork; /* continue even if unable to bind all addrs */
+static Pid_t ParentProcess;
+#ifdef __UNIXOS2__
+Pid_t GetPPID(Pid_t pid);
+#endif
+
+static Bool debug_conns = FALSE;
+
+fd_set IgnoredClientsWithInput;
+static fd_set GrabImperviousClients;
+static fd_set SavedAllClients;
+static fd_set SavedAllSockets;
+static fd_set SavedClientsWithInput;
+int GrabInProgress = 0;
+
+#if !defined(WIN32)
+int *ConnectionTranslation = NULL;
+#else
+/*
+ * On NT fds are not between 0 and MAXSOCKS, they are unrelated, and there is
+ * not even a known maximum value, so use something quite arbitrary for now.
+ * Do storage is a hash table of size 256. Collisions are handled in a linked
+ * list.
+ */
+
+#undef MAXSOCKS
+#define MAXSOCKS 500
+#undef MAXSELECT
+#define MAXSELECT 500
+#define MAXFD 500
+
+struct _ct_node {
+ struct _ct_node *next;
+ int key;
+ int value;
+};
+
+struct _ct_node *ct_head[256];
+
+void InitConnectionTranslation(void)
+{
+ bzero(ct_head, sizeof(ct_head));
+}
+
+int GetConnectionTranslation(int conn)
+{
+ struct _ct_node *node = ct_head[conn & 0xff];
+ while (node != NULL)
+ {
+ if (node->key == conn)
+ return node->value;
+ node = node->next;
+ }
+ return 0;
+}
+
+void SetConnectionTranslation(int conn, int client)
+{
+ struct _ct_node **node = ct_head + (conn & 0xff);
+ if (client == 0) /* remove entry */
+ {
+ while (*node != NULL)
+ {
+ if ((*node)->key == conn)
+ {
+ struct _ct_node *temp = *node;
+ *node = (*node)->next;
+ free(temp);
+ return;
+ }
+ node = &((*node)->next);
+ }
+ return;
+ } else
+ {
+ while (*node != NULL)
+ {
+ if ((*node)->key == conn)
+ {
+ (*node)->value = client;
+ return;
+ }
+ node = &((*node)->next);
+ }
+ *node = (struct _ct_node*)xalloc(sizeof(struct _ct_node));
+ (*node)->next = NULL;
+ (*node)->key = conn;
+ (*node)->value = client;
+ return;
+ }
+}
+
+void ClearConnectionTranslation(void)
+{
+ unsigned i;
+ for (i = 0; i < 256; i++)
+ {
+ struct _ct_node *node = ct_head[i];
+ while (node != NULL)
+ {
+ struct _ct_node *temp = node;
+ node = node->next;
+ xfree(temp);
+ }
+ }
+}
+#endif
+
+XtransConnInfo *ListenTransConns = NULL;
+int *ListenTransFds = NULL;
+int ListenTransCount;
+
+static void ErrorConnMax(XtransConnInfo /* trans_conn */);
+
+#ifndef LBX
+static
+void CloseDownFileDescriptor(
+ OsCommPtr /*oc*/
+);
+#endif
+
+
+static XtransConnInfo
+lookup_trans_conn (int fd)
+{
+ if (ListenTransFds)
+ {
+ int i;
+ for (i = 0; i < ListenTransCount; i++)
+ if (ListenTransFds[i] == fd)
+ return ListenTransConns[i];
+ }
+
+ return (NULL);
+}
+
+/* Set MaxClients and lastfdesc, and allocate ConnectionTranslation */
+
+void
+InitConnectionLimits(void)
+{
+ lastfdesc = -1;
+
+#ifndef __CYGWIN__
+
+#ifndef __UNIXOS2__
+
+#if !defined(XNO_SYSCONF) && defined(_SC_OPEN_MAX)
+ lastfdesc = sysconf(_SC_OPEN_MAX) - 1;
+#endif
+
+#ifdef HAS_GETDTABLESIZE
+ if (lastfdesc < 0)
+ lastfdesc = getdtablesize() - 1;
+#endif
+
+#ifdef _NFILE
+ if (lastfdesc < 0)
+ lastfdesc = _NFILE - 1;
+#endif
+
+#else /* __UNIXOS2__ */
+ lastfdesc = _nfiles - 1;
+#endif
+
+#endif /* __CYGWIN__ */
+
+ /* This is the fallback */
+ if (lastfdesc < 0)
+ lastfdesc = MAXSOCKS;
+
+ if (lastfdesc > MAXSELECT)
+ lastfdesc = MAXSELECT;
+
+ if (lastfdesc > MAXCLIENTS)
+ {
+ lastfdesc = MAXCLIENTS;
+ if (debug_conns)
+ ErrorF( "REACHED MAXIMUM CLIENTS LIMIT %d\n", MAXCLIENTS);
+ }
+ MaxClients = lastfdesc;
+
+#ifdef DEBUG
+ ErrorF("InitConnectionLimits: MaxClients = %d\n", MaxClients);
+#endif
+
+#if !defined(WIN32)
+ ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1));
+#else
+ InitConnectionTranslation();
+#endif
+}
+
+
+/*****************
+ * CreateWellKnownSockets
+ * At initialization, create the sockets to listen on for new clients.
+ *****************/
+
+void
+CreateWellKnownSockets(void)
+{
+ int i;
+ int partial;
+ char port[20];
+ OsSigHandlerPtr handler;
+
+ FD_ZERO(&AllSockets);
+ FD_ZERO(&AllClients);
+ FD_ZERO(&LastSelectMask);
+ FD_ZERO(&ClientsWithInput);
+
+#if !defined(WIN32)
+ for (i=0; i<MaxClients; i++) ConnectionTranslation[i] = 0;
+#else
+ ClearConnectionTranslation();
+#endif
+
+ FD_ZERO (&WellKnownConnections);
+
+ sprintf (port, "%d", atoi (display));
+
+ if ((_XSERVTransMakeAllCOTSServerListeners (port, &partial,
+ &ListenTransCount, &ListenTransConns) >= 0) &&
+ (ListenTransCount >= 1))
+ {
+ if (!PartialNetwork && partial)
+ {
+ FatalError ("Failed to establish all listening sockets");
+ }
+ else
+ {
+ ListenTransFds = (int *) xalloc (ListenTransCount * sizeof (int));
+
+ for (i = 0; i < ListenTransCount; i++)
+ {
+ int fd = _XSERVTransGetConnectionNumber (ListenTransConns[i]);
+
+ ListenTransFds[i] = fd;
+ FD_SET (fd, &WellKnownConnections);
+
+ if (!_XSERVTransIsLocal (ListenTransConns[i]))
+ {
+ DefineSelf (fd);
+ }
+ }
+ }
+ }
+
+ if (!XFD_ANYSET (&WellKnownConnections))
+ FatalError ("Cannot establish any listening sockets - Make sure an X server isn't already running");
+#if !defined(WIN32)
+ OsSignal (SIGPIPE, SIG_IGN);
+ OsSignal (SIGHUP, AutoResetServer);
+#endif
+ OsSignal (SIGINT, GiveUp);
+ OsSignal (SIGTERM, GiveUp);
+ XFD_COPYSET (&WellKnownConnections, &AllSockets);
+ ResetHosts(display);
+ /*
+ * Magic: If SIGUSR1 was set to SIG_IGN when
+ * the server started, assume that either
+ *
+ * a- The parent process is ignoring SIGUSR1
+ *
+ * or
+ *
+ * b- The parent process is expecting a SIGUSR1
+ * when the server is ready to accept connections
+ *
+ * In the first case, the signal will be harmless,
+ * in the second case, the signal will be quite
+ * useful
+ */
+#if !defined(WIN32)
+ handler = OsSignal (SIGUSR1, SIG_IGN);
+ if ( handler == SIG_IGN)
+ RunFromSmartParent = TRUE;
+ OsSignal(SIGUSR1, handler);
+ ParentProcess = getppid ();
+#ifdef __UNIXOS2__
+ /*
+ * fg030505: under OS/2, xinit is not the parent process but
+ * the "grant parent" process of the server because execvpe()
+ * presents us an additional process number;
+ * GetPPID(pid) is part of libemxfix
+ */
+ ParentProcess = GetPPID (ParentProcess);
+#endif /* __UNIXOS2__ */
+ if (RunFromSmartParent) {
+ if (ParentProcess > 1) {
+ kill (ParentProcess, SIGUSR1);
+ }
+ }
+#endif
+#ifdef XDMCP
+ XdmcpInit ();
+#endif
+}
+
+void
+ResetWellKnownSockets (void)
+{
+ int i;
+
+ ResetOsBuffers();
+
+ for (i = 0; i < ListenTransCount; i++)
+ {
+ int status = _XSERVTransResetListener (ListenTransConns[i]);
+
+ if (status != TRANS_RESET_NOOP)
+ {
+ if (status == TRANS_RESET_FAILURE)
+ {
+ /*
+ * ListenTransConns[i] freed by xtrans.
+ * Remove it from out list.
+ */
+
+ FD_CLR (ListenTransFds[i], &WellKnownConnections);
+ ListenTransFds[i] = ListenTransFds[ListenTransCount - 1];
+ ListenTransConns[i] = ListenTransConns[ListenTransCount - 1];
+ ListenTransCount -= 1;
+ i -= 1;
+ }
+ else if (status == TRANS_RESET_NEW_FD)
+ {
+ /*
+ * A new file descriptor was allocated (the old one was closed)
+ */
+
+ int newfd = _XSERVTransGetConnectionNumber (ListenTransConns[i]);
+
+ FD_CLR (ListenTransFds[i], &WellKnownConnections);
+ ListenTransFds[i] = newfd;
+ FD_SET(newfd, &WellKnownConnections);
+ }
+ }
+ }
+
+ ResetAuthorization ();
+ ResetHosts(display);
+ /*
+ * See above in CreateWellKnownSockets about SIGUSR1
+ */
+#if !defined(WIN32)
+ if (RunFromSmartParent) {
+ if (ParentProcess > 1) {
+ kill (ParentProcess, SIGUSR1);
+ }
+ }
+#endif
+ /*
+ * restart XDMCP
+ */
+#ifdef XDMCP
+ XdmcpReset ();
+#endif
+}
+
+void
+CloseWellKnownConnections(void)
+{
+ int i;
+
+ for (i = 0; i < ListenTransCount; i++)
+ _XSERVTransClose (ListenTransConns[i]);
+}
+
+static void
+AuthAudit (ClientPtr client, Bool letin,
+ struct sockaddr *saddr, int len,
+ unsigned int proto_n, char *auth_proto, int auth_id)
+{
+ char addr[128];
+ char *out = addr;
+
+ if (!((OsCommPtr)client->osPrivate)->trans_conn) {
+ strcpy(addr, "LBX proxy at ");
+ out += strlen(addr);
+ }
+ if (!len)
+ strcpy(out, "local host");
+ else
+ switch (saddr->sa_family)
+ {
+ case AF_UNSPEC:
+#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
+ case AF_UNIX:
+#endif
+ strcpy(out, "local host");
+ break;
+#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
+ case AF_INET:
+ sprintf(out, "IP %s",
+ inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr));
+ break;
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6: {
+ char ipaddr[INET6_ADDRSTRLEN];
+ inet_ntop(AF_INET6, &((struct sockaddr_in6 *) saddr)->sin6_addr,
+ ipaddr, sizeof(ipaddr));
+ sprintf(out, "IP %s", ipaddr);
+ }
+ break;
+#endif
+#endif
+#ifdef DNETCONN
+ case AF_DECnet:
+ sprintf(out, "DN %s",
+ dnet_ntoa(&((struct sockaddr_dn *) saddr)->sdn_add));
+ break;
+#endif
+ default:
+ strcpy(out, "unknown address");
+ }
+
+ if (proto_n)
+ AuditF("client %d %s from %s\n Auth name: %.*s ID: %d\n",
+ client->index, letin ? "connected" : "rejected", addr,
+ (int)proto_n, auth_proto, auth_id);
+ else
+ AuditF("client %d %s from %s\n",
+ client->index, letin ? "connected" : "rejected", addr);
+}
+
+XID
+AuthorizationIDOfClient(ClientPtr client)
+{
+ if (client->osPrivate)
+ return ((OsCommPtr)client->osPrivate)->auth_id;
+ else
+ return None;
+}
+
+
+/*****************************************************************
+ * ClientAuthorized
+ *
+ * Sent by the client at connection setup:
+ * typedef struct _xConnClientPrefix {
+ * CARD8 byteOrder;
+ * BYTE pad;
+ * CARD16 majorVersion, minorVersion;
+ * CARD16 nbytesAuthProto;
+ * CARD16 nbytesAuthString;
+ * } xConnClientPrefix;
+ *
+ * It is hoped that eventually one protocol will be agreed upon. In the
+ * mean time, a server that implements a different protocol than the
+ * client expects, or a server that only implements the host-based
+ * mechanism, will simply ignore this information.
+ *
+ *****************************************************************/
+
+char *
+ClientAuthorized(ClientPtr client,
+ unsigned int proto_n, char *auth_proto,
+ unsigned int string_n, char *auth_string)
+{
+ OsCommPtr priv;
+ Xtransaddr *from = NULL;
+ int family;
+ int fromlen;
+ XID auth_id;
+ char *reason = NULL;
+ XtransConnInfo trans_conn;
+ int restore_trans_conn = 0;
+ ClientPtr lbxpc = NULL;
+
+ priv = (OsCommPtr)client->osPrivate;
+ trans_conn = priv->trans_conn;
+
+#ifdef LBX
+ if (!trans_conn) {
+ /*
+ * Since trans_conn is NULL, this must be a proxy's client for
+ * which we have NO address. Therefore, we will temporarily
+ * set the client's trans_conn to the proxy's trans_conn and
+ * after CheckAuthorization the client's trans_conn will be
+ * restored.
+ *
+ * If XDM-AUTHORIZATION-1 is being used, CheckAuthorization
+ * will eventually call XdmAuthorizationValidate and this
+ * later function may use the client's trans_conn to get the
+ * client's address. Since a XDM-AUTH-1 auth string includes
+ * the client's address, this address is compared to the address
+ * in the client's trans_conn. If the proxy and client are
+ * on the same host, the comparison will fail; otherwise the
+ * comparison will fail and the client will not be authorized
+ * to connect to the server.
+ *
+ * The basis for this additional code is to prevent a
+ * NULL pointer dereference of the client's trans_conn.
+ * The fundamental problem - the fact that the client's
+ * trans_conn is NULL - is because the NewClient
+ * request in version 1.0 of the LBX protocol does not
+ * send the client's address to the server. When the
+ * spec is changed and the client's address is sent to
+ * server in the NewClient request, this additional code
+ * should be removed.
+ *
+ * See defect number XWSog08218 for more information.
+ */
+ lbxpc = LbxProxyClient(priv->proxy);
+ trans_conn = ((OsCommPtr)lbxpc->osPrivate)->trans_conn;
+ priv->trans_conn = trans_conn;
+ restore_trans_conn = 1;
+ }
+#endif
+
+ auth_id = CheckAuthorization (proto_n, auth_proto,
+ string_n, auth_string, client, &reason);
+
+#ifdef LBX
+ if (! priv->trans_conn) {
+ if (auth_id == (XID) ~0L && !GetAccessControl())
+ auth_id = ((OsCommPtr)lbxpc->osPrivate)->auth_id;
+#ifdef XCSECURITY
+ else if (auth_id != (XID) ~0L && !SecuritySameLevel(lbxpc, auth_id)) {
+ auth_id = (XID) ~0L;
+ reason = "Client trust level differs from that of LBX Proxy";
+ }
+#endif
+ }
+#endif
+ if (auth_id == (XID) ~0L)
+ {
+ if (
+#ifdef XCSECURITY
+ (proto_n == 0 ||
+ strncmp (auth_proto, XSecurityAuthorizationName, proto_n) != 0) &&
+#endif
+ _XSERVTransGetPeerAddr (trans_conn,
+ &family, &fromlen, &from) != -1)
+ {
+ if (
+#ifdef LBX
+ !trans_conn ||
+#endif
+ InvalidHost ((struct sockaddr *) from, fromlen, client))
+ AuthAudit(client, FALSE, (struct sockaddr *) from,
+ fromlen, proto_n, auth_proto, auth_id);
+ else
+ {
+ auth_id = (XID) 0;
+ if (auditTrailLevel > 1)
+ AuthAudit(client, TRUE,
+ (struct sockaddr *) from, fromlen,
+ proto_n, auth_proto, auth_id);
+ }
+
+ xfree ((char *) from);
+ }
+
+ if (auth_id == (XID) ~0L) {
+#ifdef LBX
+ /*
+ * Restore client's trans_conn state
+ */
+ if (restore_trans_conn) {
+ priv->trans_conn = NULL;
+ }
+#endif
+ if (reason)
+ return reason;
+ else
+ return "Client is not authorized to connect to Server";
+ }
+ }
+ else if (auditTrailLevel > 1)
+ {
+ if (_XSERVTransGetPeerAddr (trans_conn,
+ &family, &fromlen, &from) != -1)
+ {
+ AuthAudit(client, TRUE, (struct sockaddr *) from, fromlen,
+ proto_n, auth_proto, auth_id);
+
+ xfree ((char *) from);
+ }
+ }
+ priv->auth_id = auth_id;
+ priv->conn_time = 0;
+
+#ifdef XDMCP
+ /* indicate to Xdmcp protocol that we've opened new client */
+ XdmcpOpenDisplay(priv->fd);
+#endif /* XDMCP */
+#ifdef XAPPGROUP
+ if (ClientStateCallback)
+ XagCallClientStateChange (client);
+#endif
+ /* At this point, if the client is authorized to change the access control
+ * list, we should getpeername() information, and add the client to
+ * the selfhosts list. It's not really the host machine, but the
+ * true purpose of the selfhosts list is to see who may change the
+ * access control list.
+ */
+#ifdef LBX
+ if (restore_trans_conn) {
+ priv->trans_conn = NULL;
+ }
+#endif
+ return((char *)NULL);
+}
+
+static ClientPtr
+#ifdef LBX
+AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time,
+ int (*Flush)(
+ ClientPtr /*who*/, OsCommPtr /*oc*/,
+ char * /*extraBuf*/, int /*extraCount*/),
+ void (*Close)(
+ ClientPtr /*client*/),
+ LbxProxyPtr proxy)
+#else
+AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time)
+#endif
+{
+ OsCommPtr oc;
+ ClientPtr client;
+
+ if (
+#ifdef LBX
+ trans_conn &&
+#endif
+#ifndef WIN32
+ fd >= lastfdesc
+#else
+ XFD_SETCOUNT(&AllClients) >= MaxClients
+#endif
+ )
+ return NullClient;
+ oc = (OsCommPtr)xalloc(sizeof(OsCommRec));
+ if (!oc)
+ return NullClient;
+ oc->trans_conn = trans_conn;
+ oc->fd = fd;
+ oc->input = (ConnectionInputPtr)NULL;
+ oc->output = (ConnectionOutputPtr)NULL;
+ oc->auth_id = None;
+ oc->conn_time = conn_time;
+#ifdef LBX
+ oc->proxy = proxy;
+ oc->Flush = Flush;
+ oc->Close = Close;
+ oc->largereq = (ConnectionInputPtr) NULL;
+#endif
+ if (!(client = NextAvailableClient((pointer)oc)))
+ {
+ xfree (oc);
+ return NullClient;
+ }
+#ifdef LBX
+ if (trans_conn)
+#endif
+ {
+#if !defined(WIN32)
+ ConnectionTranslation[fd] = client->index;
+#else
+ SetConnectionTranslation(fd, client->index);
+#endif
+ if (GrabInProgress)
+ {
+ FD_SET(fd, &SavedAllClients);
+ FD_SET(fd, &SavedAllSockets);
+ }
+ else
+ {
+ FD_SET(fd, &AllClients);
+ FD_SET(fd, &AllSockets);
+ }
+ }
+
+#ifdef DEBUG
+ ErrorF("AllocNewConnection: client index = %d, socket fd = %d\n",
+ client->index, fd);
+#endif
+
+ return client;
+}
+
+#ifdef LBX
+
+int
+ClientConnectionNumber (ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
+
+ return oc->fd;
+}
+
+ClientPtr
+AllocLbxClientConnection (ClientPtr client, LbxProxyPtr proxy)
+{
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
+
+ return AllocNewConnection ((XtransConnInfo)NULL, oc->fd, GetTimeInMillis(),
+ LbxFlushClient, LbxCloseClient, proxy);
+}
+
+void
+LbxProxyConnection (ClientPtr client, LbxProxyPtr proxy)
+{
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
+
+ FlushClient(client, oc, (char *)NULL, 0);
+ oc->proxy = proxy;
+ oc->Flush = LbxFlushClient;
+ oc->Close = LbxCloseClient;
+ LbxPrimeInput(client, proxy);
+}
+
+#endif
+
+/*****************
+ * EstablishNewConnections
+ * If anyone is waiting on listened sockets, accept them.
+ * Returns a mask with indices of new clients. Updates AllClients
+ * and AllSockets.
+ *****************/
+
+/*ARGSUSED*/
+Bool
+EstablishNewConnections(ClientPtr clientUnused, pointer closure)
+{
+ fd_set readyconnections; /* set of listeners that are ready */
+ int curconn; /* fd of listener that's ready */
+ register int newconn; /* fd of new client */
+ CARD32 connect_time;
+ register int i;
+ register ClientPtr client;
+ register OsCommPtr oc;
+ fd_set tmask;
+
+ XFD_ANDSET (&tmask, (fd_set*)closure, &WellKnownConnections);
+ XFD_COPYSET(&tmask, &readyconnections);
+ if (!XFD_ANYSET(&readyconnections))
+ return TRUE;
+ connect_time = GetTimeInMillis();
+ /* kill off stragglers */
+ for (i=1; i<currentMaxClients; i++)
+ {
+ if ((client = clients[i]))
+ {
+ oc = (OsCommPtr)(client->osPrivate);
+ if ((oc && (oc->conn_time != 0) &&
+ (connect_time - oc->conn_time) >= TimeOutValue) ||
+ (client->noClientException != Success && !client->clientGone))
+ CloseDownClient(client);
+ }
+ }
+#ifndef WIN32
+ for (i = 0; i < howmany(XFD_SETSIZE, NFDBITS); i++)
+ {
+ while (readyconnections.fds_bits[i])
+#else
+ for (i = 0; i < XFD_SETCOUNT(&readyconnections); i++)
+#endif
+ {
+ XtransConnInfo trans_conn, new_trans_conn;
+ int status;
+
+#ifndef WIN32
+ curconn = ffs (readyconnections.fds_bits[i]) - 1;
+ readyconnections.fds_bits[i] &= ~((fd_mask)1 << curconn);
+ curconn += (i * (sizeof(fd_mask)*8));
+#else
+ curconn = XFD_FD(&readyconnections, i);
+#endif
+
+ if ((trans_conn = lookup_trans_conn (curconn)) == NULL)
+ continue;
+
+ if ((new_trans_conn = _XSERVTransAccept (trans_conn, &status)) == NULL)
+ continue;
+
+ newconn = _XSERVTransGetConnectionNumber (new_trans_conn);
+
+ if (newconn < lastfdesc)
+ {
+ int clientid;
+#if !defined(WIN32)
+ clientid = ConnectionTranslation[newconn];
+#else
+ clientid = GetConnectionTranslation(newconn);
+#endif
+ if(clientid && (client = clients[clientid]))
+ CloseDownClient(client);
+ }
+
+ _XSERVTransSetOption(new_trans_conn, TRANS_NONBLOCKING, 1);
+
+ if (!AllocNewConnection (new_trans_conn, newconn, connect_time
+#ifdef LBX
+ , StandardFlushClient,
+ CloseDownFileDescriptor, (LbxProxyPtr)NULL
+#endif
+ ))
+ {
+ ErrorConnMax(new_trans_conn);
+ _XSERVTransClose(new_trans_conn);
+ }
+ }
+#ifndef WIN32
+ }
+#endif
+ return TRUE;
+}
+
+#define NOROOM "Maximum number of clients reached"
+
+/************
+ * ErrorConnMax
+ * Fail a connection due to lack of client or file descriptor space
+ ************/
+
+static void
+ErrorConnMax(XtransConnInfo trans_conn)
+{
+ int fd = _XSERVTransGetConnectionNumber (trans_conn);
+ xConnSetupPrefix csp;
+ char pad[3];
+ struct iovec iov[3];
+ char byteOrder = 0;
+ int whichbyte = 1;
+ struct timeval waittime;
+ fd_set mask;
+
+ /* if these seems like a lot of trouble to go to, it probably is */
+ waittime.tv_sec = BOTIMEOUT / MILLI_PER_SECOND;
+ waittime.tv_usec = (BOTIMEOUT % MILLI_PER_SECOND) *
+ (1000000 / MILLI_PER_SECOND);
+ FD_ZERO(&mask);
+ FD_SET(fd, &mask);
+ (void)Select(fd + 1, &mask, NULL, NULL, &waittime);
+ /* try to read the byte-order of the connection */
+ (void)_XSERVTransRead(trans_conn, &byteOrder, 1);
+ if ((byteOrder == 'l') || (byteOrder == 'B'))
+ {
+ csp.success = xFalse;
+ csp.lengthReason = sizeof(NOROOM) - 1;
+ csp.length = (sizeof(NOROOM) + 2) >> 2;
+ csp.majorVersion = X_PROTOCOL;
+ csp.minorVersion = X_PROTOCOL_REVISION;
+ if (((*(char *) &whichbyte) && (byteOrder == 'B')) ||
+ (!(*(char *) &whichbyte) && (byteOrder == 'l')))
+ {
+ swaps(&csp.majorVersion, whichbyte);
+ swaps(&csp.minorVersion, whichbyte);
+ swaps(&csp.length, whichbyte);
+ }
+ iov[0].iov_len = sz_xConnSetupPrefix;
+ iov[0].iov_base = (char *) &csp;
+ iov[1].iov_len = csp.lengthReason;
+ iov[1].iov_base = NOROOM;
+ iov[2].iov_len = (4 - (csp.lengthReason & 3)) & 3;
+ iov[2].iov_base = pad;
+ (void)_XSERVTransWritev(trans_conn, iov, 3);
+ }
+}
+
+/************
+ * CloseDownFileDescriptor:
+ * Remove this file descriptor and it's I/O buffers, etc.
+ ************/
+
+#ifdef LBX
+void
+CloseDownFileDescriptor(ClientPtr client)
+#else
+static void
+CloseDownFileDescriptor(OsCommPtr oc)
+#endif
+{
+#ifdef LBX
+ OsCommPtr oc = (OsCommPtr) client->osPrivate;
+#endif
+ int connection = oc->fd;
+
+ if (oc->trans_conn) {
+ _XSERVTransDisconnect(oc->trans_conn);
+ _XSERVTransClose(oc->trans_conn);
+ }
+#ifndef LBX
+ FreeOsBuffers(oc);
+ xfree(oc);
+#endif
+#ifndef WIN32
+ ConnectionTranslation[connection] = 0;
+#else
+ SetConnectionTranslation(connection, 0);
+#endif
+ FD_CLR(connection, &AllSockets);
+ FD_CLR(connection, &AllClients);
+ FD_CLR(connection, &ClientsWithInput);
+ FD_CLR(connection, &GrabImperviousClients);
+ if (GrabInProgress)
+ {
+ FD_CLR(connection, &SavedAllSockets);
+ FD_CLR(connection, &SavedAllClients);
+ FD_CLR(connection, &SavedClientsWithInput);
+ }
+ FD_CLR(connection, &ClientsWriteBlocked);
+ if (!XFD_ANYSET(&ClientsWriteBlocked))
+ AnyClientsWriteBlocked = FALSE;
+ FD_CLR(connection, &OutputPending);
+}
+
+/*****************
+ * CheckConnections
+ * Some connection has died, go find which one and shut it down
+ * The file descriptor has been closed, but is still in AllClients.
+ * If would truly be wonderful if select() would put the bogus
+ * file descriptors in the exception mask, but nooooo. So we have
+ * to check each and every socket individually.
+ *****************/
+
+void
+CheckConnections(void)
+{
+#ifndef WIN32
+ fd_mask mask;
+#endif
+ fd_set tmask;
+ int curclient, curoff;
+ int i;
+ struct timeval notime;
+ int r;
+#ifdef WIN32
+ fd_set savedAllClients;
+#endif
+
+ notime.tv_sec = 0;
+ notime.tv_usec = 0;
+
+#ifndef WIN32
+ for (i=0; i<howmany(XFD_SETSIZE, NFDBITS); i++)
+ {
+ mask = AllClients.fds_bits[i];
+ while (mask)
+ {
+ curoff = ffs (mask) - 1;
+ curclient = curoff + (i * (sizeof(fd_mask)*8));
+ FD_ZERO(&tmask);
+ FD_SET(curclient, &tmask);
+ r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
+ if (r < 0)
+ CloseDownClient(clients[ConnectionTranslation[curclient]]);
+ mask &= ~((fd_mask)1 << curoff);
+ }
+ }
+#else
+ XFD_COPYSET(&AllClients, &savedAllClients);
+ for (i = 0; i < XFD_SETCOUNT(&savedAllClients); i++)
+ {
+ curclient = XFD_FD(&savedAllClients, i);
+ FD_ZERO(&tmask);
+ FD_SET(curclient, &tmask);
+ r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
+ if (r < 0)
+ CloseDownClient(clients[GetConnectionTranslation(curclient)]);
+ }
+#endif
+}
+
+
+/*****************
+ * CloseDownConnection
+ * Delete client from AllClients and free resources
+ *****************/
+
+void
+CloseDownConnection(ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+
+ if (oc->output && oc->output->count)
+ FlushClient(client, oc, (char *)NULL, 0);
+#ifdef XDMCP
+ XdmcpCloseDisplay(oc->fd);
+#endif
+#ifndef LBX
+ CloseDownFileDescriptor(oc);
+#else
+ (*oc->Close) (client);
+ FreeOsBuffers(oc);
+ xfree(oc);
+#endif
+ client->osPrivate = (pointer)NULL;
+ if (auditTrailLevel > 1)
+ AuditF("client %d disconnected\n", client->index);
+}
+
+void
+AddEnabledDevice(int fd)
+{
+ FD_SET(fd, &EnabledDevices);
+ FD_SET(fd, &AllSockets);
+ if (GrabInProgress)
+ FD_SET(fd, &SavedAllSockets);
+}
+
+void
+RemoveEnabledDevice(int fd)
+{
+ FD_CLR(fd, &EnabledDevices);
+ FD_CLR(fd, &AllSockets);
+ if (GrabInProgress)
+ FD_CLR(fd, &SavedAllSockets);
+}
+
+/*****************
+ * OnlyListenToOneClient:
+ * Only accept requests from one client. Continue to handle new
+ * connections, but don't take any protocol requests from the new
+ * ones. Note that if GrabInProgress is set, EstablishNewConnections
+ * needs to put new clients into SavedAllSockets and SavedAllClients.
+ * Note also that there is no timeout for this in the protocol.
+ * This routine is "undone" by ListenToAllClients()
+ *****************/
+
+void
+OnlyListenToOneClient(ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ int connection = oc->fd;
+
+ if (! GrabInProgress)
+ {
+ XFD_COPYSET(&ClientsWithInput, &SavedClientsWithInput);
+ XFD_ANDSET(&ClientsWithInput,
+ &ClientsWithInput, &GrabImperviousClients);
+ if (FD_ISSET(connection, &SavedClientsWithInput))
+ {
+ FD_CLR(connection, &SavedClientsWithInput);
+ FD_SET(connection, &ClientsWithInput);
+ }
+ XFD_UNSET(&SavedClientsWithInput, &GrabImperviousClients);
+ XFD_COPYSET(&AllSockets, &SavedAllSockets);
+ XFD_COPYSET(&AllClients, &SavedAllClients);
+ XFD_UNSET(&AllSockets, &AllClients);
+ XFD_ANDSET(&AllClients, &AllClients, &GrabImperviousClients);
+ FD_SET(connection, &AllClients);
+ XFD_ORSET(&AllSockets, &AllSockets, &AllClients);
+ GrabInProgress = client->index;
+ }
+}
+
+/****************
+ * ListenToAllClients:
+ * Undoes OnlyListentToOneClient()
+ ****************/
+
+void
+ListenToAllClients(void)
+{
+ if (GrabInProgress)
+ {
+ XFD_ORSET(&AllSockets, &AllSockets, &SavedAllSockets);
+ XFD_ORSET(&AllClients, &AllClients, &SavedAllClients);
+ XFD_ORSET(&ClientsWithInput, &ClientsWithInput, &SavedClientsWithInput);
+ GrabInProgress = 0;
+ }
+}
+
+/****************
+ * IgnoreClient
+ * Removes one client from input masks.
+ * Must have cooresponding call to AttendClient.
+ ****************/
+
+void
+IgnoreClient (ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ int connection = oc->fd;
+#ifdef LBX
+ LbxClientPtr lbxClient = LbxClient(client);
+#endif
+
+ isItTimeToYield = TRUE;
+#ifdef LBX
+ if (lbxClient) {
+ lbxClient->ignored = TRUE;
+ return;
+ }
+#endif
+ if (!GrabInProgress || FD_ISSET(connection, &AllClients))
+ {
+ if (FD_ISSET (connection, &ClientsWithInput))
+ FD_SET(connection, &IgnoredClientsWithInput);
+ else
+ FD_CLR(connection, &IgnoredClientsWithInput);
+ FD_CLR(connection, &ClientsWithInput);
+ FD_CLR(connection, &AllSockets);
+ FD_CLR(connection, &AllClients);
+ FD_CLR(connection, &LastSelectMask);
+ }
+ else
+ {
+ if (FD_ISSET (connection, &SavedClientsWithInput))
+ FD_SET(connection, &IgnoredClientsWithInput);
+ else
+ FD_CLR(connection, &IgnoredClientsWithInput);
+ FD_CLR(connection, &SavedClientsWithInput);
+ FD_CLR(connection, &SavedAllSockets);
+ FD_CLR(connection, &SavedAllClients);
+ }
+}
+
+/****************
+ * AttendClient
+ * Adds one client back into the input masks.
+ ****************/
+
+void
+AttendClient (ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ int connection = oc->fd;
+#ifdef LBX
+ LbxClientPtr lbxClient = LbxClient(client);
+
+ if (lbxClient) {
+ lbxClient->ignored = FALSE;
+ return;
+ }
+#endif
+ if (!GrabInProgress || GrabInProgress == client->index ||
+ FD_ISSET(connection, &GrabImperviousClients))
+ {
+ FD_SET(connection, &AllClients);
+ FD_SET(connection, &AllSockets);
+ FD_SET(connection, &LastSelectMask);
+ if (FD_ISSET (connection, &IgnoredClientsWithInput))
+ FD_SET(connection, &ClientsWithInput);
+ }
+ else
+ {
+ FD_SET(connection, &SavedAllClients);
+ FD_SET(connection, &SavedAllSockets);
+ if (FD_ISSET(connection, &IgnoredClientsWithInput))
+ FD_SET(connection, &SavedClientsWithInput);
+ }
+}
+
+/* make client impervious to grabs; assume only executing client calls this */
+
+void
+MakeClientGrabImpervious(ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ int connection = oc->fd;
+
+ FD_SET(connection, &GrabImperviousClients);
+
+ if (ServerGrabCallback)
+ {
+ ServerGrabInfoRec grabinfo;
+ grabinfo.client = client;
+ grabinfo.grabstate = CLIENT_IMPERVIOUS;
+ CallCallbacks(&ServerGrabCallback, &grabinfo);
+ }
+}
+
+/* make client pervious to grabs; assume only executing client calls this */
+
+void
+MakeClientGrabPervious(ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ int connection = oc->fd;
+
+ FD_CLR(connection, &GrabImperviousClients);
+ if (GrabInProgress && (GrabInProgress != client->index))
+ {
+ if (FD_ISSET(connection, &ClientsWithInput))
+ {
+ FD_SET(connection, &SavedClientsWithInput);
+ FD_CLR(connection, &ClientsWithInput);
+ }
+ FD_CLR(connection, &AllSockets);
+ FD_CLR(connection, &AllClients);
+ isItTimeToYield = TRUE;
+ }
+
+ if (ServerGrabCallback)
+ {
+ ServerGrabInfoRec grabinfo;
+ grabinfo.client = client;
+ grabinfo.grabstate = CLIENT_PERVIOUS;
+ CallCallbacks(&ServerGrabCallback, &grabinfo);
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/os/io.c b/nx-X11/programs/Xserver/os/io.c
new file mode 100644
index 000000000..76edbaeee
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/io.c
@@ -0,0 +1,1347 @@
+/***********************************************************
+
+Copyright 1987, 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+
+******************************************************************/
+/* $Xorg: io.c,v 1.6 2001/02/09 02:05:23 xorgcvs Exp $ */
+/*****************************************************************
+ * i/o functions
+ *
+ * WriteToClient, ReadRequestFromClient
+ * InsertFakeRequest, ResetCurrentRequest
+ *
+ *****************************************************************/
+/* $XFree86: xc/programs/Xserver/os/io.c,v 3.34 2002/05/31 18:46:05 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#if 0
+#define DEBUG_COMMUNICATION
+#endif
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#endif
+#include <stdio.h>
+#include <X11/Xtrans/Xtrans.h>
+#include <X11/Xmd.h>
+#include <errno.h>
+#if !defined(__UNIXOS2__) && !defined(WIN32)
+#ifndef Lynx
+#include <sys/uio.h>
+#else
+#include <uio.h>
+#endif
+#endif
+#include <X11/X.h>
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#include "os.h"
+#include "osdep.h"
+#include <X11/Xpoll.h>
+#include "opaque.h"
+#include "dixstruct.h"
+#include "misc.h"
+#ifdef LBX
+#include "colormapst.h"
+#include "propertyst.h"
+#include "lbxserve.h"
+#endif
+
+CallbackListPtr ReplyCallback;
+CallbackListPtr FlushCallback;
+
+/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
+ * systems are broken and return EWOULDBLOCK when they should return EAGAIN
+ */
+#ifndef __UNIXOS2__
+#ifndef WIN32
+#if defined(EAGAIN) && defined(EWOULDBLOCK)
+#define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK)
+#else
+#ifdef EAGAIN
+#define ETEST(err) (err == EAGAIN)
+#else
+#define ETEST(err) (err == EWOULDBLOCK)
+#endif
+#endif
+#else /* WIN32 The socket errorcodes differ from the normal errors*/
+#define ETEST(err) (err == EAGAIN || err == WSAEWOULDBLOCK)
+#endif
+#else /* __UNIXOS2__ Writing to full pipes may return ENOSPC */
+#define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK || err == ENOSPC)
+#endif
+
+Bool CriticalOutputPending;
+int timesThisConnection = 0;
+ConnectionInputPtr FreeInputs = (ConnectionInputPtr)NULL;
+ConnectionOutputPtr FreeOutputs = (ConnectionOutputPtr)NULL;
+OsCommPtr AvailableInput = (OsCommPtr)NULL;
+
+#define get_req_len(req,cli) ((cli)->swapped ? \
+ lswaps((req)->length) : (req)->length)
+
+#ifdef BIGREQS
+#include <X11/extensions/bigreqstr.h>
+
+#define get_big_req_len(req,cli) ((cli)->swapped ? \
+ lswapl(((xBigReq *)(req))->length) : \
+ ((xBigReq *)(req))->length)
+#endif
+
+#define MAX_TIMES_PER 10
+
+/*
+ * A lot of the code in this file manipulates a ConnectionInputPtr:
+ *
+ * -----------------------------------------------
+ * |------- bufcnt ------->| | |
+ * | |- gotnow ->| | |
+ * | |-------- needed ------>| |
+ * |-----------+--------- size --------+---------->|
+ * -----------------------------------------------
+ * ^ ^
+ * | |
+ * buffer bufptr
+ *
+ * buffer is a pointer to the start of the buffer.
+ * bufptr points to the start of the current request.
+ * bufcnt counts how many bytes are in the buffer.
+ * size is the size of the buffer in bytes.
+ *
+ * In several of the functions, gotnow and needed are local variables
+ * that do the following:
+ *
+ * gotnow is the number of bytes of the request that we're
+ * trying to read that are currently in the buffer.
+ * Typically, gotnow = (buffer + bufcnt) - bufptr
+ *
+ * needed = the length of the request that we're trying to
+ * read. Watch out: needed sometimes counts bytes and sometimes
+ * counts CARD32's.
+ */
+
+
+/*****************************************************************
+ * ReadRequestFromClient
+ * Returns one request in client->requestBuffer. The request
+ * length will be in client->req_len. Return status is:
+ *
+ * > 0 if successful, specifies length in bytes of the request
+ * = 0 if entire request is not yet available
+ * < 0 if client should be terminated
+ *
+ * The request returned must be contiguous so that it can be
+ * cast in the dispatcher to the correct request type. Because requests
+ * are variable length, ReadRequestFromClient() must look at the first 4
+ * or 8 bytes of a request to determine the length (the request length is
+ * in the 3rd and 4th bytes of the request unless it is a Big Request
+ * (see the Big Request Extension), in which case the 3rd and 4th bytes
+ * are zero and the following 4 bytes are the request length.
+ *
+ * Note: in order to make the server scheduler (WaitForSomething())
+ * "fair", the ClientsWithInput mask is used. This mask tells which
+ * clients have FULL requests left in their buffers. Clients with
+ * partial requests require a read. Basically, client buffers
+ * are drained before select() is called again. But, we can't keep
+ * reading from a client that is sending buckets of data (or has
+ * a partial request) because others clients need to be scheduled.
+ *****************************************************************/
+
+#define YieldControl() \
+ { isItTimeToYield = TRUE; \
+ timesThisConnection = 0; }
+#define YieldControlNoInput() \
+ { YieldControl(); \
+ FD_CLR(fd, &ClientsWithInput); }
+#define YieldControlDeath() \
+ { timesThisConnection = 0; }
+
+#ifdef hpux_not_tog
+#define LBX_NEED_OLD_SYMBOL_FOR_LOADABLES
+#endif
+
+#ifdef LBX
+#ifdef LBX_NEED_OLD_SYMBOL_FOR_LOADABLES
+#undef ReadRequestFromClient
+int
+ReadRequestFromClient(ClientPtr client)
+{
+ return (*client->readRequest)(client);
+}
+#endif
+int
+StandardReadRequestFromClient(ClientPtr client)
+#else
+int
+ReadRequestFromClient(ClientPtr client)
+#endif
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ ConnectionInputPtr oci = oc->input;
+ int fd = oc->fd;
+ unsigned int gotnow, needed;
+ int result;
+ register xReq *request;
+ Bool need_header;
+#ifdef BIGREQS
+ Bool move_header;
+#endif
+
+ /* If an input buffer was empty, either free it if it is too big
+ * or link it into our list of free input buffers. This means that
+ * different clients can share the same input buffer (at different
+ * times). This was done to save memory.
+ */
+
+ if (AvailableInput)
+ {
+ if (AvailableInput != oc)
+ {
+ register ConnectionInputPtr aci = AvailableInput->input;
+ if (aci->size > BUFWATERMARK)
+ {
+ xfree(aci->buffer);
+ xfree(aci);
+ }
+ else
+ {
+ aci->next = FreeInputs;
+ FreeInputs = aci;
+ }
+ AvailableInput->input = (ConnectionInputPtr)NULL;
+ }
+ AvailableInput = (OsCommPtr)NULL;
+ }
+
+ /* make sure we have an input buffer */
+
+ if (!oci)
+ {
+ if ((oci = FreeInputs))
+ {
+ FreeInputs = oci->next;
+ }
+ else if (!(oci = AllocateInputBuffer()))
+ {
+ YieldControlDeath();
+ return -1;
+ }
+ oc->input = oci;
+ }
+
+ /* advance to start of next request */
+
+ oci->bufptr += oci->lenLastReq;
+
+ need_header = FALSE;
+#ifdef BIGREQS
+ move_header = FALSE;
+#endif
+ gotnow = oci->bufcnt + oci->buffer - oci->bufptr;
+ if (gotnow < sizeof(xReq))
+ {
+ /* We don't have an entire xReq yet. Can't tell how big
+ * the request will be until we get the whole xReq.
+ */
+ needed = sizeof(xReq);
+ need_header = TRUE;
+ }
+ else
+ {
+ /* We have a whole xReq. We can tell how big the whole
+ * request will be unless it is a Big Request.
+ */
+ request = (xReq *)oci->bufptr;
+ needed = get_req_len(request, client);
+#ifdef BIGREQS
+ if (!needed && client->big_requests)
+ {
+ /* It's a Big Request. */
+ move_header = TRUE;
+ if (gotnow < sizeof(xBigReq))
+ {
+ /* Still need more data to tell just how big. */
+ needed = sizeof(xBigReq) >> 2; /* needed is in CARD32s now */
+ need_header = TRUE;
+ }
+ else
+ needed = get_big_req_len(request, client);
+ }
+#endif
+ client->req_len = needed;
+ needed <<= 2; /* needed is in bytes now */
+ }
+ if (gotnow < needed)
+ {
+ /* Need to read more data, either so that we can get a
+ * complete xReq (if need_header is TRUE), a complete
+ * xBigReq (if move_header is TRUE), or the rest of the
+ * request (if need_header and move_header are both FALSE).
+ */
+
+ oci->lenLastReq = 0;
+ if (needed > MAXBUFSIZE)
+ {
+ /* request is too big for us to handle */
+ YieldControlDeath();
+ return -1;
+ }
+ if ((gotnow == 0) ||
+ ((oci->bufptr - oci->buffer + needed) > oci->size))
+ {
+ /* no data, or the request is too big to fit in the buffer */
+
+ if ((gotnow > 0) && (oci->bufptr != oci->buffer))
+ /* save the data we've already read */
+ memmove(oci->buffer, oci->bufptr, gotnow);
+ if (needed > oci->size)
+ {
+ /* make buffer bigger to accomodate request */
+ char *ibuf;
+
+ ibuf = (char *)xrealloc(oci->buffer, needed);
+ if (!ibuf)
+ {
+ YieldControlDeath();
+ return -1;
+ }
+ oci->size = needed;
+ oci->buffer = ibuf;
+ }
+ oci->bufptr = oci->buffer;
+ oci->bufcnt = gotnow;
+ }
+ /* XXX this is a workaround. This function is sometimes called
+ * after the trans_conn has been freed. In this case trans_conn
+ * will be null. Really ought to restructure things so that we
+ * never get here in those circumstances.
+ */
+ if (!oc->trans_conn)
+ {
+ /* treat as if an error occured on the read, which is what
+ * used to happen
+ */
+ YieldControlDeath();
+ return -1;
+ }
+#ifdef LBX
+ if (oc->proxy && oc->proxy->compHandle)
+ result = (*oc->proxy->streamOpts.streamCompRead)(fd,
+ (unsigned char *)oci->buffer + oci->bufcnt,
+ oci->size - oci->bufcnt);
+ else
+#endif
+ result = _XSERVTransRead(oc->trans_conn, oci->buffer + oci->bufcnt,
+ oci->size - oci->bufcnt);
+ if (result <= 0)
+ {
+ if ((result < 0) && ETEST(errno))
+ {
+#if defined(SVR4) && defined(i386) && !defined(sun)
+#if defined(LBX) && 0
+ /*
+ * For LBX connections, we can get a valid EWOULDBLOCK
+ * There is probably a better way of distinguishing LBX
+ * connections, but this works. (DHD)
+ */
+ extern int LbxRead();
+ if (oc->Read == LbxRead)
+#else
+ if (0)
+#endif
+#endif
+ {
+ YieldControlNoInput();
+ return 0;
+ }
+ }
+ YieldControlDeath();
+ return -1;
+ }
+ oci->bufcnt += result;
+ gotnow += result;
+ /* free up some space after huge requests */
+ if ((oci->size > BUFWATERMARK) &&
+ (oci->bufcnt < BUFSIZE) && (needed < BUFSIZE))
+ {
+ char *ibuf;
+
+ ibuf = (char *)xrealloc(oci->buffer, BUFSIZE);
+ if (ibuf)
+ {
+ oci->size = BUFSIZE;
+ oci->buffer = ibuf;
+ oci->bufptr = ibuf + oci->bufcnt - gotnow;
+ }
+ }
+ if (need_header && gotnow >= needed)
+ {
+ /* We wanted an xReq, now we've gotten it. */
+ request = (xReq *)oci->bufptr;
+ needed = get_req_len(request, client);
+#ifdef BIGREQS
+ if (!needed && client->big_requests)
+ {
+ move_header = TRUE;
+ if (gotnow < sizeof(xBigReq))
+ needed = sizeof(xBigReq) >> 2;
+ else
+ needed = get_big_req_len(request, client);
+ }
+#endif
+ client->req_len = needed;
+ needed <<= 2;
+ }
+ if (gotnow < needed)
+ {
+ /* Still don't have enough; punt. */
+ YieldControlNoInput();
+ return 0;
+ }
+ }
+ if (needed == 0)
+ {
+#ifdef BIGREQS
+ if (client->big_requests)
+ needed = sizeof(xBigReq);
+ else
+#endif
+ needed = sizeof(xReq);
+ }
+ oci->lenLastReq = needed;
+
+ /*
+ * Check to see if client has at least one whole request in the
+ * buffer beyond the request we're returning to the caller.
+ * If there is only a partial request, treat like buffer
+ * is empty so that select() will be called again and other clients
+ * can get into the queue.
+ */
+
+ gotnow -= needed;
+ if (gotnow >= sizeof(xReq))
+ {
+ request = (xReq *)(oci->bufptr + needed);
+ if (gotnow >= (result = (get_req_len(request, client) << 2))
+#ifdef BIGREQS
+ && (result ||
+ (client->big_requests &&
+ (gotnow >= sizeof(xBigReq) &&
+ gotnow >= (get_big_req_len(request, client) << 2))))
+#endif
+ )
+ FD_SET(fd, &ClientsWithInput);
+ else
+ {
+#ifdef SMART_SCHEDULE
+ if (!SmartScheduleDisable)
+ FD_CLR(fd, &ClientsWithInput);
+ else
+#endif
+ YieldControlNoInput();
+ }
+ }
+ else
+ {
+ if (!gotnow)
+ AvailableInput = oc;
+#ifdef SMART_SCHEDULE
+ if (!SmartScheduleDisable)
+ FD_CLR(fd, &ClientsWithInput);
+ else
+#endif
+ YieldControlNoInput();
+ }
+#ifdef SMART_SCHEDULE
+ if (SmartScheduleDisable)
+#endif
+ if (++timesThisConnection >= MAX_TIMES_PER)
+ YieldControl();
+#ifdef BIGREQS
+ if (move_header)
+ {
+ request = (xReq *)oci->bufptr;
+ oci->bufptr += (sizeof(xBigReq) - sizeof(xReq));
+ *(xReq *)oci->bufptr = *request;
+ oci->lenLastReq -= (sizeof(xBigReq) - sizeof(xReq));
+ client->req_len -= (sizeof(xBigReq) - sizeof(xReq)) >> 2;
+ }
+#endif
+ client->requestBuffer = (pointer)oci->bufptr;
+#ifdef DEBUG_COMMUNICATION
+ {
+ xReq *req = client->requestBuffer;
+ ErrorF("REQUEST: ClientIDX: %i, type: 0x%x data: 0x%x len: %i\n",
+ client->index,req->reqType,req->data,req->length);
+ }
+#endif
+ return needed;
+}
+
+/*****************************************************************
+ * InsertFakeRequest
+ * Splice a consed up (possibly partial) request in as the next request.
+ *
+ **********************/
+
+Bool
+InsertFakeRequest(ClientPtr client, char *data, int count)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ ConnectionInputPtr oci = oc->input;
+ int fd = oc->fd;
+ int gotnow, moveup;
+
+ if (AvailableInput)
+ {
+ if (AvailableInput != oc)
+ {
+ ConnectionInputPtr aci = AvailableInput->input;
+ if (aci->size > BUFWATERMARK)
+ {
+ xfree(aci->buffer);
+ xfree(aci);
+ }
+ else
+ {
+ aci->next = FreeInputs;
+ FreeInputs = aci;
+ }
+ AvailableInput->input = (ConnectionInputPtr)NULL;
+ }
+ AvailableInput = (OsCommPtr)NULL;
+ }
+ if (!oci)
+ {
+ if ((oci = FreeInputs))
+ FreeInputs = oci->next;
+ else if (!(oci = AllocateInputBuffer()))
+ return FALSE;
+ oc->input = oci;
+ }
+ oci->bufptr += oci->lenLastReq;
+ oci->lenLastReq = 0;
+ gotnow = oci->bufcnt + oci->buffer - oci->bufptr;
+ if ((gotnow + count) > oci->size)
+ {
+ char *ibuf;
+
+ ibuf = (char *)xrealloc(oci->buffer, gotnow + count);
+ if (!ibuf)
+ return(FALSE);
+ oci->size = gotnow + count;
+ oci->buffer = ibuf;
+ oci->bufptr = ibuf + oci->bufcnt - gotnow;
+ }
+ moveup = count - (oci->bufptr - oci->buffer);
+ if (moveup > 0)
+ {
+ if (gotnow > 0)
+ memmove(oci->bufptr + moveup, oci->bufptr, gotnow);
+ oci->bufptr += moveup;
+ oci->bufcnt += moveup;
+ }
+ memmove(oci->bufptr - count, data, count);
+ oci->bufptr -= count;
+ gotnow += count;
+ if ((gotnow >= sizeof(xReq)) &&
+ (gotnow >= (int)(get_req_len((xReq *)oci->bufptr, client) << 2)))
+ FD_SET(fd, &ClientsWithInput);
+ else
+ YieldControlNoInput();
+ return(TRUE);
+}
+
+/*****************************************************************
+ * ResetRequestFromClient
+ * Reset to reexecute the current request, and yield.
+ *
+ **********************/
+
+void
+ResetCurrentRequest(ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ register ConnectionInputPtr oci = oc->input;
+ int fd = oc->fd;
+ register xReq *request;
+ int gotnow, needed;
+#ifdef LBX
+ LbxClientPtr lbxClient = LbxClient(client);
+
+ if (lbxClient) {
+ LbxSetForBlock(lbxClient);
+ if (!oci) {
+ AppendFakeRequest(client,
+ client->requestBuffer, client->req_len << 2);
+ return;
+ }
+ }
+#endif
+ if (AvailableInput == oc)
+ AvailableInput = (OsCommPtr)NULL;
+ oci->lenLastReq = 0;
+ gotnow = oci->bufcnt + oci->buffer - oci->bufptr;
+ if (gotnow < sizeof(xReq))
+ {
+ YieldControlNoInput();
+ }
+ else
+ {
+ request = (xReq *)oci->bufptr;
+ needed = get_req_len(request, client);
+#ifdef BIGREQS
+ if (!needed && client->big_requests)
+ {
+ oci->bufptr -= sizeof(xBigReq) - sizeof(xReq);
+ *(xReq *)oci->bufptr = *request;
+ ((xBigReq *)oci->bufptr)->length = client->req_len;
+ if (client->swapped)
+ {
+ char n;
+ swapl(&((xBigReq *)oci->bufptr)->length, n);
+ }
+ }
+#endif
+ if (gotnow >= (needed << 2))
+ {
+ if (FD_ISSET(fd, &AllClients))
+ {
+ FD_SET(fd, &ClientsWithInput);
+ }
+ else
+ {
+ FD_SET(fd, &IgnoredClientsWithInput);
+ }
+ YieldControl();
+ }
+ else
+ YieldControlNoInput();
+ }
+}
+
+
+
+/*****************************************************************
+ * PeekNextRequest and SkipRequests were implemented to support DBE
+ * idioms, but can certainly be used outside of DBE. There are two
+ * related macros in os.h, ReqLen and CastxReq. See the porting
+ * layer document for more details.
+ *
+ **********************/
+
+
+/*****************************************************************
+ * PeekNextRequest
+ * lets you look ahead at the unexecuted requests in a
+ * client's request buffer.
+ *
+ * Note: this implementation of PeekNextRequest ignores the
+ * readmore parameter.
+ *
+ **********************/
+
+xReqPtr
+PeekNextRequest(
+ xReqPtr req, /* request we're starting from */
+ ClientPtr client, /* client whose requests we're skipping */
+ Bool readmore) /* attempt to read more if next request isn't there? */
+{
+ register ConnectionInputPtr oci = ((OsCommPtr)client->osPrivate)->input;
+ xReqPtr pnextreq;
+ int needed, gotnow, reqlen;
+
+ if (!oci) return NULL;
+
+ if (!req)
+ {
+ /* caller wants the request after the one currently being executed */
+ pnextreq = (xReqPtr)
+ (((CARD32 *)client->requestBuffer) + client->req_len);
+ }
+ else
+ {
+ /* caller wants the request after the one specified by req */
+ reqlen = get_req_len(req, client);
+#ifdef BIGREQS
+ if (!reqlen) reqlen = get_big_req_len(req, client);
+#endif
+ pnextreq = (xReqPtr)(((char *)req) + (reqlen << 2));
+ }
+
+ /* see how much of the next request we have available */
+
+ gotnow = oci->bufcnt - (((char *)pnextreq) - oci->buffer);
+
+ if (gotnow < sizeof(xReq))
+ return NULL;
+
+ needed = get_req_len(pnextreq, client) << 2;
+#ifdef BIGREQS
+ if (!needed)
+ {
+ /* it's a big request */
+ if (gotnow < sizeof(xBigReq))
+ return NULL;
+ needed = get_big_req_len(pnextreq, client) << 2;
+ }
+#endif
+
+ /* if we have less than we need, return NULL */
+
+ return (gotnow < needed) ? NULL : pnextreq;
+}
+
+/*****************************************************************
+ * SkipRequests
+ * lets you skip over some of the requests in a client's
+ * request buffer. Presumably the caller has used PeekNextRequest
+ * to examine the requests being skipped and has performed whatever
+ * actions they dictate.
+ *
+ **********************/
+
+CallbackListPtr SkippedRequestsCallback = NULL;
+
+void
+SkipRequests(
+ xReqPtr req, /* last request being skipped */
+ ClientPtr client, /* client whose requests we're skipping */
+ int numskipped) /* how many requests we're skipping */
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ register ConnectionInputPtr oci = oc->input;
+ int reqlen;
+
+ /* see if anyone wants to snoop the skipped requests */
+
+ if (SkippedRequestsCallback)
+ {
+ SkippedRequestInfoRec skipinfo;
+ skipinfo.req = req;
+ skipinfo.client = client;
+ skipinfo.numskipped = numskipped;
+ CallCallbacks(&SkippedRequestsCallback, &skipinfo);
+ }
+
+ /* adjust the sequence number */
+ client->sequence += numskipped;
+
+ /* twiddle the oci to skip over the requests */
+
+ reqlen = get_req_len(req, client);
+#ifdef BIGREQS
+ if (!reqlen) reqlen = get_big_req_len(req, client);
+#endif
+ reqlen <<= 2;
+ oci->bufptr = (char *)req;
+ oci->lenLastReq = reqlen;
+
+ /* see if any requests left in the buffer */
+
+ if ( ((char *)req + reqlen) == (oci->buffer + oci->bufcnt) )
+ {
+ /* no requests; mark input buffer as available and client
+ * as having no input
+ */
+ int fd = oc->fd;
+ AvailableInput = oc;
+ YieldControlNoInput();
+ }
+}
+
+
+ /* lookup table for adding padding bytes to data that is read from
+ or written to the X socket. */
+static int padlength[4] = {0, 3, 2, 1};
+
+ /********************
+ * FlushAllOutput()
+ * Flush all clients with output. However, if some client still
+ * has input in the queue (more requests), then don't flush. This
+ * will prevent the output queue from being flushed every time around
+ * the round robin queue. Now, some say that it SHOULD be flushed
+ * every time around, but...
+ *
+ **********************/
+
+void
+FlushAllOutput(void)
+{
+ register int index, base;
+ register fd_mask mask; /* raphael */
+ OsCommPtr oc;
+ register ClientPtr client;
+ Bool newoutput = NewOutputPending;
+#if defined(WIN32)
+ fd_set newOutputPending;
+#endif
+
+ if (FlushCallback)
+ CallCallbacks(&FlushCallback, NULL);
+
+ if (!newoutput)
+ return;
+
+ /*
+ * It may be that some client still has critical output pending,
+ * but he is not yet ready to receive it anyway, so we will
+ * simply wait for the select to tell us when he's ready to receive.
+ */
+ CriticalOutputPending = FALSE;
+ NewOutputPending = FALSE;
+
+#ifndef WIN32
+ for (base = 0; base < howmany(XFD_SETSIZE, NFDBITS); base++)
+ {
+ mask = OutputPending.fds_bits[ base ];
+ OutputPending.fds_bits[ base ] = 0;
+ while (mask)
+ {
+ index = ffs(mask) - 1;
+ mask &= ~lowbit(mask);
+ if ((index = ConnectionTranslation[(base * (sizeof(fd_mask)*8)) + index]) == 0)
+ continue;
+ client = clients[index];
+ if (client->clientGone)
+ continue;
+ oc = (OsCommPtr)client->osPrivate;
+ if (
+#ifdef LBX
+ !oc->proxy &&
+#endif
+ FD_ISSET(oc->fd, &ClientsWithInput))
+ {
+ FD_SET(oc->fd, &OutputPending); /* set the bit again */
+ NewOutputPending = TRUE;
+ }
+ else
+ (void)FlushClient(client, oc, (char *)NULL, 0);
+ }
+ }
+#else /* WIN32 */
+ FD_ZERO(&newOutputPending);
+ for (base = 0; base < XFD_SETCOUNT(&OutputPending); base++)
+ {
+ index = XFD_FD(&OutputPending, base);
+ if ((index = GetConnectionTranslation(index)) == 0)
+ continue;
+ client = clients[index];
+ if (client->clientGone)
+ continue;
+ oc = (OsCommPtr)client->osPrivate;
+ if (
+#ifdef LBX
+ !oc->proxy &&
+#endif
+ FD_ISSET(oc->fd, &ClientsWithInput))
+ {
+ FD_SET(oc->fd, &newOutputPending); /* set the bit again */
+ NewOutputPending = TRUE;
+ }
+ else
+ (void)FlushClient(client, oc, (char *)NULL, 0);
+ }
+ XFD_COPYSET(&newOutputPending, &OutputPending);
+#endif /* WIN32 */
+}
+
+void
+FlushIfCriticalOutputPending(void)
+{
+ if (CriticalOutputPending)
+ FlushAllOutput();
+}
+
+void
+SetCriticalOutputPending(void)
+{
+ CriticalOutputPending = TRUE;
+}
+
+/*****************
+ * WriteToClient
+ * Copies buf into ClientPtr.buf if it fits (with padding), else
+ * flushes ClientPtr.buf and buf to client. As of this writing,
+ * every use of WriteToClient is cast to void, and the result
+ * is ignored. Potentially, this could be used by requests
+ * that are sending several chunks of data and want to break
+ * out of a loop on error. Thus, we will leave the type of
+ * this routine as int.
+ *****************/
+
+int
+WriteToClient (ClientPtr who, int count, char *buf)
+{
+ OsCommPtr oc = (OsCommPtr)who->osPrivate;
+ ConnectionOutputPtr oco = oc->output;
+ int padBytes;
+#ifdef DEBUG_COMMUNICATION
+ Bool multicount = FALSE;
+#endif
+ if (!count)
+ return(0);
+#ifdef DEBUG_COMMUNICATION
+ {
+ char info[128];
+ xError *err;
+ xGenericReply *rep;
+ xEvent *ev;
+
+ if (!who->replyBytesRemaining) {
+ switch(buf[0]) {
+ case X_Reply:
+ rep = (xGenericReply*)buf;
+ if (rep->sequenceNumber == who->sequence) {
+ snprintf(info,127,"Xreply: type: 0x%x data: 0x%x "
+ "len: %i seq#: 0x%x", rep->type, rep->data1,
+ rep->length, rep->sequenceNumber);
+ multicount = TRUE;
+ }
+ break;
+ case X_Error:
+ err = (xError*)buf;
+ snprintf(info,127,"Xerror: Code: 0x%x resID: 0x%x maj: 0x%x "
+ "min: %x", err->errorCode,err->resourceID,
+ err->minorCode,err->majorCode);
+ break;
+ default:
+ if ((buf[0] & 0x7f) == KeymapNotify)
+ snprintf(info,127,"KeymapNotifyEvent: %i",buf[0]);
+ else {
+ ev = (xEvent*)buf;
+ snprintf(info,127,"XEvent: type: 0x%x detail: 0x%x "
+ "seq#: 0x%x", ev->u.u.type, ev->u.u.detail,
+ ev->u.u.sequenceNumber);
+ }
+ }
+ ErrorF("REPLY: ClientIDX: %i %s\n",who->index, info);
+ } else
+ multicount = TRUE;
+ }
+#endif
+
+ if (!oco)
+ {
+ if ((oco = FreeOutputs))
+ {
+ FreeOutputs = oco->next;
+ }
+ else if (!(oco = AllocateOutputBuffer()))
+ {
+ if (oc->trans_conn) {
+ _XSERVTransDisconnect(oc->trans_conn);
+ _XSERVTransClose(oc->trans_conn);
+ oc->trans_conn = NULL;
+ }
+ MarkClientException(who);
+ return -1;
+ }
+ oc->output = oco;
+ }
+
+ padBytes = padlength[count & 3];
+
+ if(ReplyCallback)
+ {
+ ReplyInfoRec replyinfo;
+
+ replyinfo.client = who;
+ replyinfo.replyData = buf;
+ replyinfo.dataLenBytes = count + padBytes;
+ if (who->replyBytesRemaining)
+ { /* still sending data of an earlier reply */
+ who->replyBytesRemaining -= count + padBytes;
+ replyinfo.startOfReply = FALSE;
+ replyinfo.bytesRemaining = who->replyBytesRemaining;
+ CallCallbacks((&ReplyCallback), (pointer)&replyinfo);
+ }
+ else if (who->clientState == ClientStateRunning
+ && buf[0] == X_Reply)
+ { /* start of new reply */
+ CARD32 replylen;
+ unsigned long bytesleft;
+ char n;
+
+ replylen = ((xGenericReply *)buf)->length;
+ if (who->swapped)
+ swapl(&replylen, n);
+ bytesleft = (replylen * 4) + SIZEOF(xReply) - count - padBytes;
+ replyinfo.startOfReply = TRUE;
+ replyinfo.bytesRemaining = who->replyBytesRemaining = bytesleft;
+ CallCallbacks((&ReplyCallback), (pointer)&replyinfo);
+ }
+ }
+#ifdef DEBUG_COMMUNICATION
+ else if (multicount) {
+ if (who->replyBytesRemaining) {
+ who->replyBytesRemaining -= (count + padBytes);
+ } else {
+ CARD32 replylen;
+ replylen = ((xGenericReply *)buf)->length;
+ who->replyBytesRemaining =
+ (replylen * 4) + SIZEOF(xReply) - count - padBytes;
+ }
+ }
+#endif
+ if (oco->count + count + padBytes > oco->size)
+ {
+ FD_CLR(oc->fd, &OutputPending);
+ if(!XFD_ANYSET(&OutputPending)) {
+ CriticalOutputPending = FALSE;
+ NewOutputPending = FALSE;
+ }
+ return FlushClient(who, oc, buf, count);
+ }
+
+ NewOutputPending = TRUE;
+ FD_SET(oc->fd, &OutputPending);
+ memmove((char *)oco->buf + oco->count, buf, count);
+ oco->count += count + padBytes;
+ return(count);
+}
+
+ /********************
+ * FlushClient()
+ * If the client isn't keeping up with us, then we try to continue
+ * buffering the data and set the apropriate bit in ClientsWritable
+ * (which is used by WaitFor in the select). If the connection yields
+ * a permanent error, or we can't allocate any more space, we then
+ * close the connection.
+ *
+ **********************/
+
+#ifdef LBX
+#ifdef LBX_NEED_OLD_SYMBOL_FOR_LOADABLES
+#undef FlushClient
+int
+FlushClient(ClientPtr who, OsCommPtr oc, char *extraBuf, int extraCount)
+{
+ return (*oc->Flush)(who, oc, extraBuf, extraCount);
+}
+#endif
+int
+StandardFlushClient(ClientPtr who, OsCommPtr oc,
+ char *extraBuf, int extraCount)
+#else
+int
+FlushClient(ClientPtr who, OsCommPtr oc, char *extraBuf, int extraCount)
+#endif
+{
+ ConnectionOutputPtr oco = oc->output;
+ int connection = oc->fd;
+ XtransConnInfo trans_conn = oc->trans_conn;
+ struct iovec iov[3];
+ static char padBuffer[3];
+ long written;
+ long padsize;
+ long notWritten;
+ long todo;
+
+ if (!oco)
+ return 0;
+ written = 0;
+ padsize = padlength[extraCount & 3];
+ notWritten = oco->count + extraCount + padsize;
+ todo = notWritten;
+ while (notWritten) {
+ long before = written; /* amount of whole thing written */
+ long remain = todo; /* amount to try this time, <= notWritten */
+ int i = 0;
+ long len;
+
+ /* You could be very general here and have "in" and "out" iovecs
+ * and write a loop without using a macro, but what the heck. This
+ * translates to:
+ *
+ * how much of this piece is new?
+ * if more new then we are trying this time, clamp
+ * if nothing new
+ * then bump down amount already written, for next piece
+ * else put new stuff in iovec, will need all of next piece
+ *
+ * Note that todo had better be at least 1 or else we'll end up
+ * writing 0 iovecs.
+ */
+#define InsertIOV(pointer, length) \
+ len = (length) - before; \
+ if (len > remain) \
+ len = remain; \
+ if (len <= 0) { \
+ before = (-len); \
+ } else { \
+ iov[i].iov_len = len; \
+ iov[i].iov_base = (pointer) + before; \
+ i++; \
+ remain -= len; \
+ before = 0; \
+ }
+
+ InsertIOV ((char *)oco->buf, oco->count)
+ InsertIOV (extraBuf, extraCount)
+ InsertIOV (padBuffer, padsize)
+
+ errno = 0;
+ if (trans_conn && (len = _XSERVTransWritev(trans_conn, iov, i)) >= 0)
+ {
+ written += len;
+ notWritten -= len;
+ todo = notWritten;
+ }
+ else if (ETEST(errno)
+#ifdef SUNSYSV /* check for another brain-damaged OS bug */
+ || (errno == 0)
+#endif
+#ifdef EMSGSIZE /* check for another brain-damaged OS bug */
+ || ((errno == EMSGSIZE) && (todo == 1))
+#endif
+ )
+ {
+ /* If we've arrived here, then the client is stuffed to the gills
+ and not ready to accept more. Make a note of it and buffer
+ the rest. */
+ FD_SET(connection, &ClientsWriteBlocked);
+ AnyClientsWriteBlocked = TRUE;
+
+ if (written < oco->count)
+ {
+ if (written > 0)
+ {
+ oco->count -= written;
+ memmove((char *)oco->buf,
+ (char *)oco->buf + written,
+ oco->count);
+ written = 0;
+ }
+ }
+ else
+ {
+ written -= oco->count;
+ oco->count = 0;
+ }
+
+ if (notWritten > oco->size)
+ {
+ unsigned char *obuf;
+
+ obuf = (unsigned char *)xrealloc(oco->buf,
+ notWritten + BUFSIZE);
+ if (!obuf)
+ {
+ _XSERVTransDisconnect(oc->trans_conn);
+ _XSERVTransClose(oc->trans_conn);
+ oc->trans_conn = NULL;
+ MarkClientException(who);
+ oco->count = 0;
+ return(-1);
+ }
+ oco->size = notWritten + BUFSIZE;
+ oco->buf = obuf;
+ }
+
+ /* If the amount written extended into the padBuffer, then the
+ difference "extraCount - written" may be less than 0 */
+ if ((len = extraCount - written) > 0)
+ memmove ((char *)oco->buf + oco->count,
+ extraBuf + written,
+ len);
+
+ oco->count = notWritten; /* this will include the pad */
+ /* return only the amount explicitly requested */
+ return extraCount;
+ }
+#ifdef EMSGSIZE /* check for another brain-damaged OS bug */
+ else if (errno == EMSGSIZE)
+ {
+ todo >>= 1;
+ }
+#endif
+ else
+ {
+ if (oc->trans_conn)
+ {
+ _XSERVTransDisconnect(oc->trans_conn);
+ _XSERVTransClose(oc->trans_conn);
+ oc->trans_conn = NULL;
+ }
+ MarkClientException(who);
+ oco->count = 0;
+ return(-1);
+ }
+ }
+
+ /* everything was flushed out */
+ oco->count = 0;
+ /* check to see if this client was write blocked */
+ if (AnyClientsWriteBlocked)
+ {
+ FD_CLR(oc->fd, &ClientsWriteBlocked);
+ if (! XFD_ANYSET(&ClientsWriteBlocked))
+ AnyClientsWriteBlocked = FALSE;
+ }
+ if (oco->size > BUFWATERMARK)
+ {
+ xfree(oco->buf);
+ xfree(oco);
+ }
+ else
+ {
+ oco->next = FreeOutputs;
+ FreeOutputs = oco;
+ }
+ oc->output = (ConnectionOutputPtr)NULL;
+ return extraCount; /* return only the amount explicitly requested */
+}
+
+ConnectionInputPtr
+AllocateInputBuffer(void)
+{
+ ConnectionInputPtr oci;
+
+ oci = (ConnectionInputPtr)xalloc(sizeof(ConnectionInput));
+ if (!oci)
+ return (ConnectionInputPtr)NULL;
+ oci->buffer = (char *)xalloc(BUFSIZE);
+ if (!oci->buffer)
+ {
+ xfree(oci);
+ return (ConnectionInputPtr)NULL;
+ }
+ oci->size = BUFSIZE;
+ oci->bufptr = oci->buffer;
+ oci->bufcnt = 0;
+ oci->lenLastReq = 0;
+ return oci;
+}
+
+ConnectionOutputPtr
+AllocateOutputBuffer(void)
+{
+ ConnectionOutputPtr oco;
+
+ oco = (ConnectionOutputPtr)xalloc(sizeof(ConnectionOutput));
+ if (!oco)
+ return (ConnectionOutputPtr)NULL;
+ oco->buf = (unsigned char *) xalloc(BUFSIZE);
+ if (!oco->buf)
+ {
+ xfree(oco);
+ return (ConnectionOutputPtr)NULL;
+ }
+ oco->size = BUFSIZE;
+ oco->count = 0;
+#ifdef LBX
+ oco->nocompress = FALSE;
+#endif
+ return oco;
+}
+
+void
+FreeOsBuffers(OsCommPtr oc)
+{
+ ConnectionInputPtr oci;
+ ConnectionOutputPtr oco;
+
+ if (AvailableInput == oc)
+ AvailableInput = (OsCommPtr)NULL;
+ if ((oci = oc->input))
+ {
+ if (FreeInputs)
+ {
+ xfree(oci->buffer);
+ xfree(oci);
+ }
+ else
+ {
+ FreeInputs = oci;
+ oci->next = (ConnectionInputPtr)NULL;
+ oci->bufptr = oci->buffer;
+ oci->bufcnt = 0;
+ oci->lenLastReq = 0;
+ }
+ }
+ if ((oco = oc->output))
+ {
+ if (FreeOutputs)
+ {
+ xfree(oco->buf);
+ xfree(oco);
+ }
+ else
+ {
+ FreeOutputs = oco;
+ oco->next = (ConnectionOutputPtr)NULL;
+ oco->count = 0;
+ }
+ }
+#ifdef LBX
+ if ((oci = oc->largereq)) {
+ xfree(oci->buffer);
+ xfree(oci);
+ }
+#endif
+}
+
+void
+ResetOsBuffers(void)
+{
+ ConnectionInputPtr oci;
+ ConnectionOutputPtr oco;
+
+ while ((oci = FreeInputs))
+ {
+ FreeInputs = oci->next;
+ xfree(oci->buffer);
+ xfree(oci);
+ }
+ while ((oco = FreeOutputs))
+ {
+ FreeOutputs = oco->next;
+ xfree(oco->buf);
+ xfree(oco);
+ }
+}
diff --git a/nx-X11/programs/Xserver/os/k5auth.c b/nx-X11/programs/Xserver/os/k5auth.c
new file mode 100644
index 000000000..78301ad10
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/k5auth.c
@@ -0,0 +1,801 @@
+/* $Xorg: k5auth.c,v 1.4 2001/02/09 02:05:23 xorgcvs Exp $ */
+/*
+
+Copyright 1993, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/os/k5auth.c,v 3.4 2001/01/17 22:37:10 dawes Exp $ */
+
+/*
+ * Kerberos V5 authentication scheme
+ * Author: Tom Yu <tlyu@MIT.EDU>
+ *
+ * Mostly snarfed wholesale from the user_user demo in the
+ * krb5 distribution. (At least the checking part)
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#ifdef TCPCONN
+#include <netinet/in.h>
+#endif
+#ifdef DNETCONN
+#include <netdnet/dn.h>
+#endif
+#include <arpa/inet.h>
+#include <krb5/krb5.h>
+/* 9/93: krb5.h leaks some symbols */
+#undef BITS32
+#undef xfree
+#include <krb5/los-proto.h>
+#include <X11/X.h>
+#include "os.h"
+#include "osdep.h"
+#include <X11/Xproto.h>
+#include <X11/Xfuncs.h>
+#include "dixstruct.h"
+#include <com_err.h>
+#include "Xauth.h"
+
+extern int (*k5_Vector[256])();
+extern int SendConnSetup();
+extern char *display; /* need this to generate rcache name */
+
+static XID krb5_id = ~0L;
+static krb5_principal srvname = NULL; /* service name */
+static char *ccname = NULL;
+static char *ktname = NULL; /* key table name */
+static char kerror[256];
+
+/*
+ * tgt_keyproc:
+ *
+ * extract session key from a credentials struct
+ */
+krb5_error_code tgt_keyproc(keyprocarg, principal, vno, key)
+ krb5_pointer keyprocarg;
+ krb5_principal principal;
+ krb5_kvno vno;
+ krb5_keyblock **key;
+{
+ krb5_creds *creds = (krb5_creds *)keyprocarg;
+
+ return krb5_copy_keyblock(&creds->keyblock, key);
+}
+
+/*
+ * k5_cmpenc:
+ *
+ * compare "encoded" principals
+ */
+Bool k5_cmpenc(pname, plen, buf)
+ unsigned char *pname;
+ short plen;
+ krb5_data *buf;
+{
+ return (plen == buf->length &&
+ memcmp(pname, buf->data, plen) == 0);
+}
+
+/*
+ * K5Check:
+ *
+ * This is stage 0 of the krb5 authentication protocol. It
+ * goes through the current credentials cache and extracts the
+ * primary principal and tgt to send to the client, or as
+ * appropriate, extracts from a keytab.
+ *
+ * The packet sent to the client has the following format:
+ *
+ * CARD8 reqType = 2
+ * CARD8 data = 0
+ * CARD16 length = total length of packet (in 32 bit units)
+ * CARD16 plen = length of encoded principal following
+ * STRING8 princ = encoded principal
+ * STRING8 ticket = server tgt
+ *
+ * For client-server authentication, the packet is as follows:
+ *
+ * CARD8 reqType = 3
+ * CARD8 data = 0
+ * CARD16 length = total length
+ * STRING8 princ = encoded principal of server
+ */
+XID K5Check(data_length, data, client, reason)
+ unsigned short data_length;
+ char *data;
+ ClientPtr client;
+ char **reason;
+{
+ krb5_error_code retval;
+ CARD16 tlen;
+ krb5_principal sprinc, cprinc;
+ krb5_ccache cc;
+ krb5_creds *creds;
+ char *outbuf, *cp;
+ krb5_data princ;
+ register char n;
+ xReq prefix;
+
+ if (krb5_id == ~0L)
+ return ~0L;
+ if (!ccname && !srvname)
+ return ~0L;
+ if (ccname)
+ {
+ if ((creds = (krb5_creds *)malloc(sizeof(krb5_creds))) == NULL)
+ return ~0L;
+ if (retval = krb5_cc_resolve(ccname, &cc))
+ return ~0L;
+ bzero((char*)creds, sizeof (krb5_creds));
+ if (retval = krb5_cc_get_principal(cc, &cprinc))
+ {
+ krb5_free_creds(creds);
+ krb5_cc_close(cc);
+ return ~0L;
+ }
+ creds->client = cprinc;
+ if (retval =
+ krb5_build_principal_ext(&sprinc,
+ krb5_princ_realm(creds->client)->length,
+ krb5_princ_realm(creds->client)->data,
+ 6, "krbtgt",
+ krb5_princ_realm(creds->client)->length,
+ krb5_princ_realm(creds->client)->data,
+ 0))
+ {
+ krb5_free_creds(creds);
+ krb5_cc_close(cc);
+ return ~0L;
+ }
+ creds->server = sprinc;
+ retval = krb5_get_credentials(KRB5_GC_CACHED, cc, creds);
+ krb5_cc_close(cc);
+ if (retval)
+ {
+ krb5_free_creds(creds);
+ return ~0L;
+ }
+ if (retval = XauKrb5Encode(cprinc, &princ))
+ {
+ krb5_free_creds(creds);
+ return ~0L;
+ }
+ tlen = sz_xReq + 2 + princ.length + creds->ticket.length;
+ prefix.reqType = 2; /* opcode = authenticate user-to-user */
+ }
+ else if (srvname)
+ {
+ if (retval = XauKrb5Encode(srvname, &princ))
+ {
+ return ~0L;
+ }
+ tlen = sz_xReq + princ.length;
+ prefix.reqType = 3; /* opcode = authenticate client-server */
+ }
+ prefix.data = 0; /* stage = 0 */
+ prefix.length = (tlen + 3) >> 2; /* round up to nearest multiple
+ of 4 bytes */
+ if (client->swapped)
+ {
+ swaps(&prefix.length, n);
+ }
+ if ((cp = outbuf = (char *)malloc(tlen)) == NULL)
+ {
+ if (ccname)
+ {
+ krb5_free_creds(creds);
+ }
+ free(princ.data);
+ return ~0L;
+ }
+ memcpy(cp, &prefix, sz_xReq);
+ cp += sz_xReq;
+ if (ccname)
+ {
+ memcpy(cp, &princ.length, 2);
+ if (client->swapped)
+ {
+ swaps((CARD16 *)cp, n);
+ }
+ cp += 2;
+ }
+ memcpy(cp, princ.data, princ.length);
+ cp += princ.length;
+ free(princ.data); /* we don't need that anymore */
+ if (ccname)
+ memcpy(cp, creds->ticket.data, creds->ticket.length);
+ WriteToClient(client, tlen, outbuf);
+ free(outbuf);
+ client->requestVector = k5_Vector; /* hack in our dispatch vector */
+ client->clientState = ClientStateAuthenticating;
+ if (ccname)
+ {
+ ((OsCommPtr)client->osPrivate)->authstate.srvcreds = (pointer)creds; /* save tgt creds */
+ ((OsCommPtr)client->osPrivate)->authstate.ktname = NULL;
+ ((OsCommPtr)client->osPrivate)->authstate.srvname = NULL;
+ }
+ if (srvname)
+ {
+ ((OsCommPtr)client->osPrivate)->authstate.srvcreds = NULL;
+ ((OsCommPtr)client->osPrivate)->authstate.ktname = (pointer)ktname;
+ ((OsCommPtr)client->osPrivate)->authstate.srvname = (pointer)srvname;
+ }
+ ((OsCommPtr)client->osPrivate)->authstate.stageno = 1; /* next stage is 1 */
+ return krb5_id;
+}
+
+/*
+ * k5_stage1:
+ *
+ * This gets called out of the dispatcher after K5Check frobs with the
+ * client->requestVector. It accepts the ap_req from the client and verifies
+ * it. In addition, if the client has set AP_OPTS_MUTUAL_REQUIRED, it then
+ * sends an ap_rep to the client to achieve mutual authentication.
+ *
+ * client stage1 packet format is as follows:
+ *
+ * CARD8 reqType = 1
+ * CARD8 data = ignored
+ * CARD16 length = total length
+ * STRING8 data = the actual ap_req
+ *
+ * stage2 packet sent back to client for mutual authentication:
+ *
+ * CARD8 reqType = 2
+ * CARD8 data = 2
+ * CARD16 length = total length
+ * STRING8 data = the ap_rep
+ */
+int k5_stage1(client)
+ register ClientPtr client;
+{
+ long addrlen;
+ krb5_error_code retval, retval2;
+ register char n;
+ struct sockaddr cli_net_addr;
+ xReq prefix;
+ krb5_principal cprinc;
+ krb5_data buf;
+ krb5_creds *creds = (krb5_creds *)((OsCommPtr)client->osPrivate)->authstate.srvcreds;
+ krb5_keyblock *skey;
+ krb5_address cli_addr, **localaddrs = NULL;
+ krb5_tkt_authent *authdat;
+ krb5_ap_rep_enc_part rep;
+ krb5_int32 ctime, cusec;
+ krb5_rcache rcache = NULL;
+ char *cachename = NULL, *rc_type = NULL, *rc_base = "rcX", *kt = NULL;
+ REQUEST(xReq);
+
+ if (((OsCommPtr)client->osPrivate)->authstate.stageno != 1)
+ {
+ if (creds)
+ krb5_free_creds(creds);
+ return(SendConnSetup(client, "expected Krb5 stage1 packet"));
+ }
+ addrlen = sizeof (cli_net_addr);
+ if (getpeername(((OsCommPtr)client->osPrivate)->fd,
+ &cli_net_addr, &addrlen) == -1)
+ {
+ if (creds)
+ krb5_free_creds(creds);
+ return(SendConnSetup(client, "Krb5 stage1: getpeername failed"));
+ }
+ if (cli_net_addr.sa_family == AF_UNSPEC
+#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN)
+ || cli_net_addr.sa_family == AF_UNIX
+#endif
+ ) /* assume local host */
+ {
+ krb5_os_localaddr(&localaddrs);
+ if (!localaddrs || !localaddrs[0])
+ {
+ if (creds)
+ krb5_free_creds(creds);
+ return(SendConnSetup(client, "Krb5 failed to get localaddrs"));
+ }
+ cli_addr.addrtype = localaddrs[0]->addrtype;
+ cli_addr.length = localaddrs[0]->length;
+ cli_addr.contents = localaddrs[0]->contents;
+ }
+ else
+ {
+ cli_addr.addrtype = cli_net_addr.sa_family; /* the values
+ are compatible */
+ switch (cli_net_addr.sa_family)
+ {
+#ifdef TCPCONN
+ case AF_INET:
+ cli_addr.length = sizeof (struct in_addr);
+ cli_addr.contents =
+ (krb5_octet *)&((struct sockaddr_in *)&cli_net_addr)->sin_addr;
+ break;
+#endif
+#ifdef DNETCONN
+ case AF_DECnet:
+ cli_addr.length = sizeof (struct dn_naddr);
+ cli_addr.contents =
+ (krb5_octet *)&((struct sockaddr_dn *)&cli_net_addr)->sdn_add;
+ break;
+#endif
+ default:
+ if (localaddrs)
+ krb5_free_addresses(localaddrs);
+ if (creds)
+ krb5_free_creds(creds);
+ sprintf(kerror, "Krb5 stage1: unknown address family %d from getpeername",
+ cli_net_addr.sa_family);
+ return(SendConnSetup(client, kerror));
+ }
+ }
+ if ((rcache = (krb5_rcache)malloc(sizeof(*rcache))) == NULL)
+ {
+ if (localaddrs)
+ krb5_free_addresses(localaddrs);
+ if (creds)
+ krb5_free_creds(creds);
+ return(SendConnSetup(client, "malloc bombed for krb5_rcache"));
+ }
+ if ((rc_type = krb5_rc_default_type()) == NULL)
+ rc_type = "dfl";
+ if (retval = krb5_rc_resolve_type(&rcache, rc_type))
+ {
+ if (localaddrs)
+ krb5_free_addresses(localaddrs);
+ if (creds)
+ krb5_free_creds(creds);
+ free(rcache);
+ strcpy(kerror, "krb5_rc_resolve_type failed: ");
+ strncat(kerror, error_message(retval), 231);
+ return(SendConnSetup(client, kerror));
+ }
+ if ((cachename = (char *)malloc(strlen(rc_base) + strlen(display) + 1))
+ == NULL)
+ {
+ if (localaddrs)
+ krb5_free_addresses(localaddrs);
+ if (creds)
+ krb5_free_creds(creds);
+ free(rcache);
+ return(SendConnSetup(client, "Krb5: malloc bombed for cachename"));
+ }
+ strcpy(cachename, rc_base);
+ strcat(cachename, display);
+ if (retval = krb5_rc_resolve(rcache, cachename))
+ {
+ if (localaddrs)
+ krb5_free_addresses(localaddrs);
+ if (creds)
+ krb5_free_creds(creds);
+ free(rcache);
+ free(cachename);
+ strcpy(kerror, "krb5_rc_resolve failed: ");
+ strncat(kerror, error_message(retval), 236);
+ return(SendConnSetup(client, kerror));
+ }
+ free(cachename);
+ if (krb5_rc_recover(rcache))
+ {
+ extern krb5_deltat krb5_clockskew;
+ if (retval = krb5_rc_initialize(rcache, krb5_clockskew))
+ {
+ if (localaddrs)
+ krb5_free_addresses(localaddrs);
+ if (creds)
+ krb5_free_creds(creds);
+ if (retval2 = krb5_rc_close(rcache))
+ {
+ strcpy(kerror, "krb5_rc_close failed: ");
+ strncat(kerror, error_message(retval2), 238);
+ return(SendConnSetup(client, kerror));
+ }
+ free(rcache);
+ strcpy(kerror, "krb5_rc_initialize failed: ");
+ strncat(kerror, error_message(retval), 233);
+ return(SendConnSetup(client, kerror));
+ }
+ }
+ buf.length = (stuff->length << 2) - sz_xReq;
+ buf.data = (char *)stuff + sz_xReq;
+ if (creds)
+ {
+ retval = krb5_rd_req(&buf,
+ NULL, /* don't bother with server name */
+ &cli_addr,
+ NULL, /* no fetchfrom */
+ tgt_keyproc,
+ creds, /* credentials as arg to
+ keyproc */
+ rcache,
+ &authdat);
+ krb5_free_creds(creds);
+ }
+ else if (kt = (char *)((OsCommPtr)client->osPrivate)->authstate.ktname)
+ {
+ retval = krb5_rd_req(&buf, srvname, &cli_addr, kt, NULL, NULL,
+ rcache, &authdat);
+ ((OsCommPtr)client->osPrivate)->authstate.ktname = NULL;
+ }
+ else
+ {
+ if (localaddrs)
+ krb5_free_addresses(localaddrs);
+ return(SendConnSetup(client, "Krb5: neither srvcreds nor ktname set"));
+ }
+ if (localaddrs)
+ krb5_free_addresses(localaddrs);
+ if (rcache)
+ {
+ if (retval2 = krb5_rc_close(rcache))
+ {
+ strcpy(kerror, "krb5_rc_close failed (2): ");
+ strncat(kerror, error_message(retval2), 230);
+ return(SendConnSetup(client, kerror));
+ }
+ free(rcache);
+ }
+ if (retval)
+ {
+ strcpy(kerror, "Krb5: Bad application request: ");
+ strncat(kerror, error_message(retval), 224);
+ return(SendConnSetup(client, kerror));
+ }
+ cprinc = authdat->ticket->enc_part2->client;
+ skey = authdat->ticket->enc_part2->session;
+ if (XauKrb5Encode(cprinc, &buf))
+ {
+ krb5_free_tkt_authent(authdat);
+ return(SendConnSetup(client, "XauKrb5Encode bombed"));
+ }
+ /*
+ * Now check to see if the principal we got is one that we want to let in
+ */
+ if (ForEachHostInFamily(FamilyKrb5Principal, k5_cmpenc, (pointer)&buf))
+ {
+ free(buf.data);
+ /*
+ * The following deals with sending an ap_rep to the client to
+ * achieve mutual authentication. The client sends back a stage 3
+ * packet if all is ok.
+ */
+ if (authdat->ap_options | AP_OPTS_MUTUAL_REQUIRED)
+ {
+ /*
+ * stage 2: send ap_rep to client
+ */
+ if (retval = krb5_us_timeofday(&ctime, &cusec))
+ {
+ krb5_free_tkt_authent(authdat);
+ strcpy(kerror, "error in krb5_us_timeofday: ");
+ strncat(kerror, error_message(retval), 234);
+ return(SendConnSetup(client, kerror));
+ }
+ rep.ctime = ctime;
+ rep.cusec = cusec;
+ rep.subkey = NULL;
+ rep.seq_number = 0;
+ if (retval = krb5_mk_rep(&rep, skey, &buf))
+ {
+ krb5_free_tkt_authent(authdat);
+ strcpy(kerror, "error in krb5_mk_rep: ");
+ strncat(kerror, error_message(retval), 238);
+ return(SendConnSetup(client, kerror));
+ }
+ prefix.reqType = 2; /* opcode = authenticate */
+ prefix.data = 2; /* stage = 2 */
+ prefix.length = (buf.length + sz_xReq + 3) >> 2;
+ if (client->swapped)
+ {
+ swaps(&prefix.length, n);
+ }
+ WriteToClient(client, sz_xReq, (char *)&prefix);
+ WriteToClient(client, buf.length, buf.data);
+ free(buf.data);
+ krb5_free_tkt_authent(authdat);
+ ((OsCommPtr)client->osPrivate)->authstate.stageno = 3; /* expect stage3 packet */
+ return(Success);
+ }
+ else
+ {
+ free(buf.data);
+ krb5_free_tkt_authent(authdat);
+ return(SendConnSetup(client, NULL)); /* success! */
+ }
+ }
+ else
+ {
+ char *kname;
+
+ krb5_free_tkt_authent(authdat);
+ free(buf.data);
+ retval = krb5_unparse_name(cprinc, &kname);
+ if (retval == 0)
+ {
+ sprintf(kerror, "Principal \"%s\" is not authorized to connect",
+ kname);
+ if (kname)
+ free(kname);
+ return(SendConnSetup(client, kerror));
+ }
+ else
+ return(SendConnSetup(client,"Principal is not authorized to connect to Server"));
+ }
+}
+
+/*
+ * k5_stage3:
+ *
+ * Get the short ack packet from the client. This packet can conceivably
+ * be expanded to allow for switching on end-to-end encryption.
+ *
+ * stage3 packet format:
+ *
+ * CARD8 reqType = 3
+ * CARD8 data = ignored (for now)
+ * CARD16 length = should be zero
+ */
+int k5_stage3(client)
+ register ClientPtr client;
+{
+ REQUEST(xReq);
+
+ if (((OsCommPtr)client->osPrivate)->authstate.stageno != 3)
+ {
+ return(SendConnSetup(client, "expected Krb5 stage3 packet"));
+ }
+ else
+ return(SendConnSetup(client, NULL)); /* success! */
+}
+
+k5_bad(client)
+ register ClientPtr client;
+{
+ if (((OsCommPtr)client->osPrivate)->authstate.srvcreds)
+ krb5_free_creds((krb5_creds *)((OsCommPtr)client->osPrivate)->authstate.srvcreds);
+ sprintf(kerror, "unrecognized Krb5 auth packet %d, expecting %d",
+ ((xReq *)client->requestBuffer)->reqType,
+ ((OsCommPtr)client->osPrivate)->authstate.stageno);
+ return(SendConnSetup(client, kerror));
+}
+
+/*
+ * K5Add:
+ *
+ * Takes the name of a credentials cache and resolves it. Also adds the
+ * primary principal of the ccache to the acl.
+ *
+ * Now will also take a service name.
+ */
+int K5Add(data_length, data, id)
+ unsigned short data_length;
+ char *data;
+ XID id;
+{
+ krb5_principal princ;
+ krb5_error_code retval;
+ krb5_keytab_entry tmp_entry;
+ krb5_keytab keytab;
+ krb5_kvno kvno = 0;
+ krb5_ccache cc;
+ char *nbuf, *cp;
+ krb5_data kbuf;
+ int i, ktlen;
+
+ krb5_init_ets(); /* can't think of a better place to put it */
+ krb5_id = ~0L;
+ if (data_length < 3)
+ return 0;
+ if ((nbuf = (char *)malloc(data_length - 2)) == NULL)
+ return 0;
+ memcpy(nbuf, data + 3, data_length - 3);
+ nbuf[data_length - 3] = '\0';
+ if (ccname)
+ {
+ free(ccname);
+ ccname = NULL;
+ }
+ if (srvname)
+ {
+ krb5_free_principal(srvname);
+ srvname = NULL;
+ }
+ if (ktname)
+ {
+ free(ktname);
+ ktname = NULL;
+ }
+ if (!strncmp(data, "UU:", 3))
+ {
+ if (retval = krb5_cc_resolve(nbuf, &cc))
+ {
+ ErrorF("K5Add: krb5_cc_resolve of \"%s\" failed: %s\n",
+ nbuf, error_message(retval));
+ free(nbuf);
+ return 0;
+ }
+ if (cc && !(retval = krb5_cc_get_principal(cc, &princ)))
+ {
+ if (XauKrb5Encode(princ, &kbuf))
+ {
+ free(nbuf);
+ krb5_free_principal(princ);
+ krb5_cc_close(cc);
+ return 0;
+ }
+ if (krb5_cc_close(cc))
+ return 0;
+ AddHost(NULL, FamilyKrb5Principal, kbuf.length, kbuf.data);
+ krb5_free_principal(princ);
+ free(kbuf.data);
+ ccname = nbuf;
+ krb5_id = id;
+ return 1;
+ }
+ else
+ {
+ ErrorF("K5Add: getting principal from cache \"%s\" failed: %s\n",
+ nbuf, error_message(retval));
+ }
+ }
+ else if (!strncmp(data, "CS:", 3))
+ {
+ if ((cp = strchr(nbuf, ',')) == NULL)
+ {
+ free(nbuf);
+ return 0;
+ }
+ *cp = '\0'; /* gross but it works :-) */
+ ktlen = strlen(cp + 1);
+ if ((ktname = (char *)malloc(ktlen + 1)) == NULL)
+ {
+ free(nbuf);
+ return 0;
+ }
+ strcpy(ktname, cp + 1);
+ retval = krb5_sname_to_principal(NULL, /* NULL for hostname uses
+ local host name*/
+ nbuf, KRB5_NT_SRV_HST,
+ &srvname);
+ free(nbuf);
+ if (retval)
+ {
+ free(ktname);
+ ktname = NULL;
+ return 0;
+ }
+ if (retval = krb5_kt_resolve(ktname, &keytab))
+ {
+ free(ktname);
+ ktname = NULL;
+ krb5_free_principal(srvname);
+ srvname = NULL;
+ return 0;
+ }
+ retval = krb5_kt_get_entry(keytab, srvname, kvno, &tmp_entry);
+ krb5_kt_free_entry(&tmp_entry);
+ if (retval)
+ {
+ free(ktname);
+ ktname = NULL;
+ krb5_free_principal(srvname);
+ srvname = NULL;
+ return 0;
+ }
+ if (XauKrb5Encode(srvname, &kbuf))
+ {
+ free(ktname);
+ ktname = NULL;
+ krb5_free_principal(srvname);
+ srvname = NULL;
+ return 0;
+ }
+ AddHost(NULL, FamilyKrb5Principal, kbuf.length, kbuf.data);
+ krb5_id = id;
+ return 1;
+ }
+ else
+ {
+ ErrorF("K5Add: credentials cache name \"%.*s\" in auth file: unknown type\n",
+ data_length, data);
+ }
+ return 0;
+}
+
+/*
+ * K5Reset:
+ *
+ * Reset krb5_id, also nuke the current principal from the acl.
+ */
+int K5Reset()
+{
+ krb5_principal princ;
+ krb5_error_code retval;
+ krb5_ccache cc;
+ krb5_data kbuf;
+ int i;
+
+ if (ccname)
+ {
+ if (retval = krb5_cc_resolve(ccname, &cc))
+ {
+ free(ccname);
+ ccname = NULL;
+ }
+ if (cc && !(retval = krb5_cc_get_principal(cc, &princ)))
+ {
+ if (XauKrb5Encode(princ, &kbuf))
+ return 1;
+ RemoveHost(NULL, FamilyKrb5Principal, kbuf.length, kbuf.data);
+ krb5_free_principal(princ);
+ free(kbuf.data);
+ if (krb5_cc_close(cc))
+ return 1;
+ free(ccname);
+ ccname = NULL;
+ }
+ }
+ if (srvname)
+ {
+ if (XauKrb5Encode(srvname, &kbuf))
+ return 1;
+ RemoveHost(NULL, FamilyKrb5Principal, kbuf.length, kbuf.data);
+ krb5_free_principal(srvname);
+ free(kbuf.data);
+ srvname = NULL;
+ }
+ if (ktname)
+ {
+ free(ktname);
+ ktname = NULL;
+ }
+ krb5_id = ~0L;
+ return 0;
+}
+
+XID K5ToID(data_length, data)
+ unsigned short data_length;
+ char *data;
+{
+ return krb5_id;
+}
+
+int K5FromID(id, data_lenp, datap)
+ XID id;
+ unsigned short *data_lenp;
+ char **datap;
+{
+ return 0;
+}
+
+int K5Remove(data_length, data)
+ unsigned short data_length;
+ char *data;
+{
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/os/lbxio.c b/nx-X11/programs/Xserver/os/lbxio.c
new file mode 100644
index 000000000..97ae958e3
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/lbxio.c
@@ -0,0 +1,555 @@
+/* $XFree86: xc/programs/Xserver/os/lbxio.c,v 3.17 2002/05/31 18:46:06 dawes Exp $ */
+/*
+
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/***********************************************************
+Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts,
+and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Digital or MIT not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: lbxio.c,v 1.4 2001/02/09 02:05:23 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <X11/Xtrans/Xtrans.h>
+#include <X11/Xmd.h>
+#include <errno.h>
+#ifndef Lynx
+#include <sys/param.h>
+#ifndef __UNIXOS2__
+#include <sys/uio.h>
+#endif
+#else
+#include <uio.h>
+#endif
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "os.h"
+#include <X11/Xpoll.h>
+#include "osdep.h"
+#include "opaque.h"
+#include "dixstruct.h"
+#include "misc.h"
+#include "colormapst.h"
+#include "propertyst.h"
+#include "lbxserve.h"
+
+/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
+ * systems are broken and return EWOULDBLOCK when they should return EAGAIN
+ */
+#if defined(EAGAIN) && defined(EWOULDBLOCK)
+#define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK)
+#else
+#ifdef EAGAIN
+#define ETEST(err) (err == EAGAIN)
+#else
+#define ETEST(err) (err == EWOULDBLOCK)
+#endif
+#endif
+
+#define get_req_len(req,cli) ((cli)->swapped ? \
+ lswaps((req)->length) : (req)->length)
+
+#define YieldControl() \
+ { isItTimeToYield = TRUE; \
+ timesThisConnection = 0; }
+#define YieldControlNoInput() \
+ { YieldControl(); \
+ FD_CLR(fd, &ClientsWithInput); }
+
+void
+SwitchClientInput (ClientPtr client, Bool pending)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+
+#ifndef WIN32
+ ConnectionTranslation[oc->fd] = client->index;
+#else
+ SetConnectionTranslation(oc->fd, client->index);
+#endif
+ if (pending)
+ FD_SET(oc->fd, &ClientsWithInput);
+ else
+ YieldControl();
+}
+
+void
+LbxPrimeInput(ClientPtr client, LbxProxyPtr proxy)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ ConnectionInputPtr oci = oc->input;
+
+ if (oci && proxy->compHandle) {
+ char *extra = oci->bufptr + oci->lenLastReq;
+ int left = oci->bufcnt + oci->buffer - extra;
+
+ (*proxy->streamOpts.streamCompStuffInput)(oc->fd,
+ (unsigned char *)extra,
+ left);
+ oci->bufcnt -= left;
+ AvailableInput = oc;
+ }
+}
+
+void
+AvailableClientInput (ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+
+ if (FD_ISSET(oc->fd, &AllSockets))
+ FD_SET(oc->fd, &ClientsWithInput);
+}
+
+/*****************************************************************
+ * AppendFakeRequest
+ * Append a (possibly partial) request in as the last request.
+ *
+ **********************/
+
+Bool
+AppendFakeRequest (ClientPtr client, char *data, int count)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ ConnectionInputPtr oci = oc->input;
+ int fd = oc->fd;
+ int gotnow;
+
+ if (!oci)
+ {
+ if ((oci = FreeInputs))
+ FreeInputs = oci->next;
+ else if (!(oci = AllocateInputBuffer()))
+ return FALSE;
+ oc->input = oci;
+ } else if (AvailableInput == oc)
+ AvailableInput = (OsCommPtr)NULL;
+ /* do not free AvailableInput here, it could be proxy's */
+ oci->bufptr += oci->lenLastReq;
+ oci->lenLastReq = 0;
+ gotnow = oci->bufcnt + oci->buffer - oci->bufptr;
+ if ((gotnow + count) > oci->size)
+ {
+ char *ibuf;
+
+ ibuf = (char *)xrealloc(oci->buffer, gotnow + count);
+ if (!ibuf)
+ return(FALSE);
+ oci->size = gotnow + count;
+ oci->buffer = ibuf;
+ oci->bufptr = ibuf + oci->bufcnt - gotnow;
+ }
+ if (oci->bufcnt + count > oci->size) {
+ memmove(oci->buffer, oci->bufptr, gotnow);
+ oci->bufcnt = gotnow;
+ oci->bufptr = oci->buffer;
+ }
+ memmove(oci->bufptr + gotnow, data, count);
+ oci->bufcnt += count;
+ gotnow += count;
+ if ((gotnow >= sizeof(xReq)) &&
+ (gotnow >= (int)(get_req_len((xReq *)oci->bufptr, client) << 2)))
+ FD_SET(fd, &ClientsWithInput);
+ else
+ YieldControlNoInput();
+ return(TRUE);
+}
+
+static int
+LbxWrite(XtransConnInfo trans_conn, LbxProxyPtr proxy,
+ char *buf, int len)
+{
+ struct iovec iov;
+ int n;
+ int notWritten;
+
+ notWritten = len;
+ iov.iov_base = buf;
+ iov.iov_len = len;
+ while (notWritten) {
+ errno = 0;
+ if (proxy->compHandle)
+ n = (*proxy->streamOpts.streamCompWriteV)(proxy->fd, &iov, 1);
+ else
+ n = _XSERVTransWritev(trans_conn, &iov, 1);
+ if (n >= 0) {
+ iov.iov_base = (char *)iov.iov_base + n;
+ notWritten -= n;
+ iov.iov_len = notWritten;
+ }
+ else if (ETEST(errno)
+#ifdef SUNSYSV /* check for another brain-damaged OS bug */
+ || (errno == 0)
+#endif
+#ifdef EMSGSIZE /* check for another brain-damaged OS bug */
+ || ((errno == EMSGSIZE) && (iov.iov_len == 1))
+#endif
+ )
+ break;
+#ifdef EMSGSIZE /* check for another brain-damaged OS bug */
+ else if (errno == EMSGSIZE)
+ iov.iov_len >>= 1;
+#endif
+ else
+ return -1;
+ }
+ return len - notWritten;
+}
+
+static Bool
+LbxAppendOutput(LbxProxyPtr proxy, ClientPtr client, ConnectionOutputPtr oco)
+{
+ ConnectionOutputPtr noco = proxy->olast;
+ LbxClientPtr lbxClient = LbxClient(client);
+
+ if (!lbxClient) {
+ xfree(oco->buf);
+ xfree(oco);
+ return TRUE;
+ }
+ if (noco)
+ LbxReencodeOutput(client,
+ (char *)noco->buf, &noco->count,
+ (char *)oco->buf, &oco->count);
+ else
+ LbxReencodeOutput(client,
+ (char *)NULL, (int *)NULL,
+ (char *)oco->buf, &oco->count);
+ if (!oco->count) {
+ if (oco->size > BUFWATERMARK)
+ {
+ xfree(oco->buf);
+ xfree(oco);
+ }
+ else
+ {
+ oco->next = FreeOutputs;
+ FreeOutputs = oco;
+ }
+ return TRUE;
+ }
+ if ((lbxClient->id != proxy->cur_send_id) && proxy->lbxClients[0]) {
+ xLbxSwitchEvent *ev;
+ int n;
+
+ if (!noco || (noco->size - noco->count) < sz_xLbxSwitchEvent) {
+ if ((noco = FreeOutputs))
+ FreeOutputs = noco->next;
+ else
+ noco = AllocateOutputBuffer();
+ if (!noco) {
+ MarkClientException(client);
+ return FALSE;
+ }
+ noco->next = NULL;
+ if (proxy->olast)
+ proxy->olast->next = noco;
+ else
+ proxy->ofirst = noco;
+ proxy->olast = noco;
+ }
+ ev = (xLbxSwitchEvent *) (noco->buf + noco->count);
+ noco->count += sz_xLbxSwitchEvent;
+ proxy->cur_send_id = lbxClient->id;
+ ev->type = LbxEventCode;
+ ev->lbxType = LbxSwitchEvent;
+ ev->pad = 0;
+ ev->client = proxy->cur_send_id;
+ if (LbxProxyClient(proxy)->swapped) {
+ swapl(&ev->client, n);
+ }
+ }
+ oco->next = NULL;
+ if (proxy->olast)
+ proxy->olast->next = oco;
+ else
+ proxy->ofirst = oco;
+ proxy->olast = oco;
+ return TRUE;
+}
+
+static int
+LbxClientOutput(ClientPtr client, OsCommPtr oc,
+ char *extraBuf, int extraCount, Bool nocompress)
+{
+ ConnectionOutputPtr oco;
+ int len;
+
+ if ((oco = oc->output)) {
+ oc->output = NULL;
+ if (!LbxAppendOutput(oc->proxy, client, oco))
+ return -1;
+ }
+
+ if (extraCount) {
+ NewOutputPending = TRUE;
+ FD_SET(oc->fd, &OutputPending);
+ len = (extraCount + 3) & ~3;
+ if ((oco = FreeOutputs) && (oco->size >= len))
+ FreeOutputs = oco->next;
+ else {
+ oco = (ConnectionOutputPtr)xalloc(sizeof(ConnectionOutput));
+ if (!oco) {
+ MarkClientException(client);
+ return -1;
+ }
+ oco->size = len;
+ if (oco->size < BUFSIZE)
+ oco->size = BUFSIZE;
+ oco->buf = (unsigned char *) xalloc(oco->size);
+ if (!oco->buf) {
+ xfree(oco);
+ MarkClientException(client);
+ return -1;
+ }
+ }
+ oco->count = len;
+ oco->nocompress = nocompress;
+ memmove((char *)oco->buf, extraBuf, extraCount);
+ if (!nocompress && oco->count < oco->size)
+ oc->output = oco;
+ else if (!LbxAppendOutput(oc->proxy, client, oco))
+ return -1;
+ }
+ return extraCount;
+}
+
+void
+LbxForceOutput(LbxProxyPtr proxy)
+{
+ int i;
+ LbxClientPtr lbxClient;
+ OsCommPtr coc;
+ ConnectionOutputPtr oco;
+
+ for (i = proxy->maxIndex; i >= 0; i--) { /* proxy must be last */
+ lbxClient = proxy->lbxClients[i];
+ if (!lbxClient)
+ continue;
+ coc = (OsCommPtr)lbxClient->client->osPrivate;
+ if ((oco = coc->output)) {
+ coc->output = NULL;
+ LbxAppendOutput(proxy, lbxClient->client, oco);
+ }
+ }
+}
+
+int
+LbxFlushClient(ClientPtr who, OsCommPtr oc,
+ char *extraBuf, int extraCount)
+{
+ LbxProxyPtr proxy;
+ ConnectionOutputPtr oco;
+ int n;
+ XtransConnInfo trans_conn = NULL;
+
+ if (extraBuf)
+ return LbxClientOutput(who, oc, extraBuf, extraCount, FALSE);
+ proxy = oc->proxy;
+ if (!proxy->lbxClients[0])
+ return 0;
+ LbxForceOutput(proxy);
+ if (!proxy->compHandle)
+ trans_conn = ((OsCommPtr)LbxProxyClient(proxy)->osPrivate)->trans_conn;
+ while ((oco = proxy->ofirst)) {
+ /* XXX bundle up into writev someday */
+ if (proxy->compHandle) {
+ if (oco->nocompress)
+ (*proxy->streamOpts.streamCompOff)(proxy->fd);
+ n = LbxWrite(NULL, proxy, (char *)oco->buf, oco->count);
+ if (oco->nocompress)
+ (*proxy->streamOpts.streamCompOn)(proxy->fd);
+ } else
+ n = LbxWrite(trans_conn, proxy, (char *)oco->buf, oco->count);
+ if (n < 0) {
+ ClientPtr pclient = LbxProxyClient(proxy);
+ if (proxy->compHandle)
+ trans_conn = ((OsCommPtr)pclient->osPrivate)->trans_conn;
+ _XSERVTransDisconnect(trans_conn);
+ _XSERVTransClose(trans_conn);
+ ((OsCommPtr)pclient->osPrivate)->trans_conn = NULL;
+ MarkClientException(pclient);
+ return 0;
+ } else if (n == oco->count) {
+ proxy->ofirst = oco->next;
+ if (!proxy->ofirst)
+ proxy->olast = NULL;
+ if (oco->size > BUFWATERMARK)
+ {
+ xfree(oco->buf);
+ xfree(oco);
+ }
+ else
+ {
+ oco->next = FreeOutputs;
+ oco->count = 0;
+ FreeOutputs = oco;
+ }
+ } else {
+ if (n) {
+ oco->count -= n;
+ memmove((char *)oco->buf, (char *)oco->buf + n, oco->count);
+ }
+ break;
+ }
+ }
+ if ((proxy->compHandle &&
+ (*proxy->streamOpts.streamCompFlush)(proxy->fd)) ||
+ proxy->ofirst) {
+ FD_SET(proxy->fd, &ClientsWriteBlocked);
+ AnyClientsWriteBlocked = TRUE;
+ }
+ return 0;
+}
+
+int
+UncompressedWriteToClient (ClientPtr who, int count, char *buf)
+{
+ return LbxClientOutput(who, (OsCommPtr)who->osPrivate, buf, count, TRUE);
+}
+
+void
+LbxFreeOsBuffers(LbxProxyPtr proxy)
+{
+ ConnectionOutputPtr oco;
+
+ while ((oco = proxy->ofirst)) {
+ proxy->ofirst = oco->next;
+ xfree(oco->buf);
+ xfree(oco);
+ }
+}
+
+Bool
+AllocateLargeReqBuffer(ClientPtr client, int size)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ ConnectionInputPtr oci;
+
+ if (!(oci = oc->largereq)) {
+ if ((oci = FreeInputs))
+ FreeInputs = oci->next;
+ else {
+ oci = (ConnectionInputPtr)xalloc(sizeof(ConnectionInput));
+ if (!oci)
+ return FALSE;
+ oci->buffer = NULL;
+ oci->size = 0;
+ }
+ }
+ if (oci->size < size) {
+ char *ibuf;
+
+ oci->size = size;
+ if (size < BUFSIZE)
+ oci->size = BUFSIZE;
+ if (!(ibuf = (char *)xrealloc(oci->buffer, oci->size)))
+ {
+ xfree(oci->buffer);
+ xfree(oci);
+ oc->largereq = NULL;
+ return FALSE;
+ }
+ oci->buffer = ibuf;
+ }
+ oci->bufptr = oci->buffer;
+ oci->bufcnt = 0;
+ oci->lenLastReq = size;
+ oc->largereq = oci;
+ return TRUE;
+}
+
+Bool
+AddToLargeReqBuffer(ClientPtr client, char *data, int size)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ ConnectionInputPtr oci = oc->largereq;
+
+ if (!oci || (oci->bufcnt + size > oci->lenLastReq))
+ return FALSE;
+ memcpy(oci->buffer + oci->bufcnt, data, size);
+ oci->bufcnt += size;
+ return TRUE;
+}
+
+static OsCommRec lbxAvailableInput;
+
+int
+PrepareLargeReqBuffer(ClientPtr client)
+{
+ OsCommPtr oc = (OsCommPtr)client->osPrivate;
+ ConnectionInputPtr oci = oc->largereq;
+
+ if (!oci)
+ return client->req_len << 2;
+ oc->largereq = NULL;
+ if (oci->bufcnt != oci->lenLastReq) {
+ xfree(oci->buffer);
+ xfree(oci);
+ return client->req_len << 2;
+ }
+ client->requestBuffer = oci->buffer;
+ client->req_len = oci->lenLastReq >> 2;
+ oci->bufcnt = 0;
+ oci->lenLastReq = 0;
+ if (AvailableInput)
+ {
+ ConnectionInputPtr aci = AvailableInput->input;
+ if (aci->size > BUFWATERMARK)
+ {
+ xfree(aci->buffer);
+ xfree(aci);
+ }
+ else
+ {
+ aci->next = FreeInputs;
+ FreeInputs = aci;
+ }
+ AvailableInput->input = (ConnectionInputPtr)NULL;
+ }
+ lbxAvailableInput.input = oci;
+ AvailableInput = &lbxAvailableInput;
+ return client->req_len << 2;
+}
diff --git a/nx-X11/programs/Xserver/os/log.c b/nx-X11/programs/Xserver/os/log.c
new file mode 100644
index 000000000..e09943723
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/log.c
@@ -0,0 +1,716 @@
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1994 Quarterdeck Office Systems.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Digital and
+Quarterdeck not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+DIGITAL AND QUARTERDECK DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
+OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
+OR PERFORMANCE OF THIS SOFTWARE.
+
+*/
+
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* $XFree86: xc/programs/Xserver/os/log.c,v 1.6 2003/11/07 13:45:27 tsi Exp $ */
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xos.h>
+#include <stdio.h>
+#include <time.h>
+#include <sys/stat.h>
+#include <stdarg.h>
+#include <stdlib.h> /* for malloc() */
+#include <errno.h>
+
+#include "site.h"
+#include "opaque.h"
+
+#ifdef WIN32
+#include <process.h>
+#define getpid(x) _getpid(x)
+#endif
+
+#ifdef NX_TRANS_SOCKET
+
+#include "NX.h"
+
+#endif
+
+#ifdef DDXOSVERRORF
+void (*OsVendorVErrorFProc)(const char *, va_list args) = NULL;
+#ifdef NX_TRANS_EXIT
+int OsVendorVErrorFFatal = 0;
+#endif
+#endif
+
+static FILE *logFile = NULL;
+static Bool logFlush = FALSE;
+static Bool logSync = FALSE;
+static int logVerbosity = DEFAULT_LOG_VERBOSITY;
+static int logFileVerbosity = DEFAULT_LOG_FILE_VERBOSITY;
+
+/* Buffer to information logged before the log file is opened. */
+static char *saveBuffer = NULL;
+static int bufferSize = 0, bufferUnused = 0, bufferPos = 0;
+static Bool needBuffer = TRUE;
+
+/* Prefix strings for log messages. */
+#ifndef X_UNKNOWN_STRING
+#define X_UNKNOWN_STRING "(\?\?)"
+#endif
+#ifndef X_PROBE_STRING
+#define X_PROBE_STRING "(--)"
+#endif
+#ifndef X_CONFIG_STRING
+#define X_CONFIG_STRING "(**)"
+#endif
+#ifndef X_DEFAULT_STRING
+#define X_DEFAULT_STRING "(==)"
+#endif
+#ifndef X_CMDLINE_STRING
+#define X_CMDLINE_STRING "(++)"
+#endif
+#ifndef X_NOTICE_STRING
+#define X_NOTICE_STRING "(!!)"
+#endif
+#ifndef X_ERROR_STRING
+#define X_ERROR_STRING "(EE)"
+#endif
+#ifndef X_WARNING_STRING
+#define X_WARNING_STRING "(WW)"
+#endif
+#ifndef X_INFO_STRING
+#define X_INFO_STRING "(II)"
+#endif
+#ifndef X_NOT_IMPLEMENTED_STRING
+#define X_NOT_IMPLEMENTED_STRING "(NI)"
+#endif
+
+/*
+ * LogInit is called to start logging to a file. It is also called (with
+ * NULL arguments) when logging to a file is not wanted. It must always be
+ * called, otherwise log messages will continue to accumulate in a buffer.
+ *
+ * %s, if present in the fname or backup strings, is expanded to the display
+ * string.
+ */
+
+const char *
+LogInit(const char *fname, const char *backup)
+{
+ char *logFileName = NULL;
+
+ if (fname && *fname) {
+ /* xalloc() can't be used yet. */
+ logFileName = malloc(strlen(fname) + strlen(display) + 1);
+ if (!logFileName)
+ FatalError("Cannot allocate space for the log file name\n");
+ sprintf(logFileName, fname, display);
+
+ if (backup && *backup) {
+ struct stat buf;
+
+ if (!stat(logFileName, &buf) && S_ISREG(buf.st_mode)) {
+ char *suffix;
+ char *oldLog;
+
+ oldLog = malloc(strlen(logFileName) + strlen(backup) +
+ strlen(display) + 1);
+ suffix = malloc(strlen(backup) + strlen(display) + 1);
+ if (!oldLog || !suffix)
+ FatalError("Cannot allocate space for the log file name\n");
+ sprintf(suffix, backup, display);
+ sprintf(oldLog, "%s%s", logFileName, suffix);
+ free(suffix);
+#ifdef __UNIXOS2__
+ remove(oldLog);
+#endif
+ if (rename(logFileName, oldLog) == -1) {
+ FatalError("Cannot move old log file (\"%s\" to \"%s\"\n",
+ logFileName, oldLog);
+ }
+ free(oldLog);
+ }
+ }
+ if ((logFile = fopen(logFileName, "w")) == NULL)
+ FatalError("Cannot open log file \"%s\"\n", logFileName);
+ setvbuf(logFile, NULL, _IONBF, 0);
+
+ /* Flush saved log information. */
+ if (saveBuffer && bufferSize > 0) {
+ fwrite(saveBuffer, bufferPos, 1, logFile);
+ fflush(logFile);
+#ifndef WIN32
+ fsync(fileno(logFile));
+#endif
+ }
+ }
+
+ /*
+ * Unconditionally free the buffer, and flag that the buffer is no longer
+ * needed.
+ */
+ if (saveBuffer && bufferSize > 0) {
+ free(saveBuffer); /* Must be free(), not xfree() */
+ saveBuffer = NULL;
+ bufferSize = 0;
+ }
+ needBuffer = FALSE;
+
+ return logFileName;
+}
+
+void
+LogClose()
+{
+ if (logFile) {
+ fclose(logFile);
+ logFile = NULL;
+ }
+}
+
+Bool
+LogSetParameter(LogParameter param, int value)
+{
+ switch (param) {
+ case XLOG_FLUSH:
+ logFlush = value ? TRUE : FALSE;
+ return TRUE;
+ case XLOG_SYNC:
+ logSync = value ? TRUE : FALSE;
+ return TRUE;
+ case XLOG_VERBOSITY:
+ logVerbosity = value;
+ return TRUE;
+ case XLOG_FILE_VERBOSITY:
+ logFileVerbosity = value;
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
+/* This function does the actual log message writes. */
+
+void
+LogVWrite(int verb, const char *f, va_list args)
+{
+ static char tmpBuffer[1024];
+ int len = 0;
+
+ /*
+ * Since a va_list can only be processed once, write the string to a
+ * buffer, and then write the buffer out to the appropriate output
+ * stream(s).
+ */
+ if (verb < 0 || logFileVerbosity >= verb || logVerbosity >= verb) {
+ vsnprintf(tmpBuffer, sizeof(tmpBuffer), f, args);
+#ifdef NX_TRANS_EXIT
+ /*
+ * Beautify the message. Make the
+ * first letter uppercase.
+ */
+
+ *tmpBuffer = toupper(*tmpBuffer);
+
+ /*
+ * Remove the trailing newline.
+ */
+
+ if (strlen(tmpBuffer) > 0 &&
+ *(tmpBuffer + strlen(tmpBuffer) - 1) == '\n') {
+ *(tmpBuffer + strlen(tmpBuffer) - 1) = '\0';
+ }
+
+ /*
+ * Remove the trailing full-stop.
+ */
+
+ if (strlen(tmpBuffer) > 0 &&
+ *(tmpBuffer + strlen(tmpBuffer) - 1) == '.') {
+ *(tmpBuffer + strlen(tmpBuffer) - 1) = '\0';
+ }
+#endif /* #ifdef NX_TRANS_EXIT */
+ len = strlen(tmpBuffer);
+ }
+ if ((verb < 0 || logVerbosity >= verb) && len > 0)
+ fwrite(tmpBuffer, len, 1, stderr);
+ if ((verb < 0 || logFileVerbosity >= verb) && len > 0) {
+ if (logFile) {
+ fwrite(tmpBuffer, len, 1, logFile);
+ if (logFlush) {
+ fflush(logFile);
+#ifndef WIN32
+ if (logSync)
+ fsync(fileno(logFile));
+#endif
+ }
+ } else if (needBuffer) {
+ /*
+ * Note, this code is used before OsInit() has been called, so
+ * xalloc() and friends can't be used.
+ */
+ if (len > bufferUnused) {
+ bufferSize += 1024;
+ bufferUnused += 1024;
+ if (saveBuffer)
+ saveBuffer = realloc(saveBuffer, bufferSize);
+ else
+ saveBuffer = malloc(bufferSize);
+ if (!saveBuffer)
+ FatalError("realloc() failed while saving log messages\n");
+ }
+ bufferUnused -= len;
+ memcpy(saveBuffer + bufferPos, tmpBuffer, len);
+ bufferPos += len;
+ }
+ }
+}
+
+void
+LogWrite(int verb, const char *f, ...)
+{
+ va_list args;
+
+ va_start(args, f);
+ LogVWrite(verb, f, args);
+ va_end(args);
+}
+
+void
+LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
+{
+ const char *s = X_UNKNOWN_STRING;
+ char *tmpBuf = NULL;
+
+ /* Ignore verbosity for X_ERROR */
+ if (logVerbosity >= verb || logFileVerbosity >= verb || type == X_ERROR) {
+ switch (type) {
+ case X_PROBED:
+ s = X_PROBE_STRING;
+ break;
+ case X_CONFIG:
+ s = X_CONFIG_STRING;
+ break;
+ case X_DEFAULT:
+ s = X_DEFAULT_STRING;
+ break;
+ case X_CMDLINE:
+ s = X_CMDLINE_STRING;
+ break;
+ case X_NOTICE:
+ s = X_NOTICE_STRING;
+ break;
+ case X_ERROR:
+ s = X_ERROR_STRING;
+ if (verb > 0)
+ verb = 0;
+ break;
+ case X_WARNING:
+ s = X_WARNING_STRING;
+ break;
+ case X_INFO:
+ s = X_INFO_STRING;
+ break;
+ case X_NOT_IMPLEMENTED:
+ s = X_NOT_IMPLEMENTED_STRING;
+ break;
+ case X_UNKNOWN:
+ s = X_UNKNOWN_STRING;
+ break;
+ case X_NONE:
+ s = NULL;
+ break;
+ }
+
+ /*
+ * Prefix the format string with the message type. We do it this way
+ * so that LogVWrite() is only called once per message.
+ */
+ if (s) {
+ tmpBuf = malloc(strlen(format) + strlen(s) + 1 + 1);
+ /* Silently return if malloc fails here. */
+ if (!tmpBuf)
+ return;
+ sprintf(tmpBuf, "%s ", s);
+ strcat(tmpBuf, format);
+ LogVWrite(verb, tmpBuf, args);
+ free(tmpBuf);
+ } else
+ LogVWrite(verb, format, args);
+ }
+}
+
+/* Log message with verbosity level specified. */
+void
+LogMessageVerb(MessageType type, int verb, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ LogVMessageVerb(type, verb, format, ap);
+ va_end(ap);
+}
+
+/* Log a message with the standard verbosity level of 1. */
+void
+LogMessage(MessageType type, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ LogVMessageVerb(type, 1, format, ap);
+ va_end(ap);
+}
+
+#ifdef __GNUC__
+void AbortServer(void) __attribute__((noreturn));
+#endif
+
+void
+AbortServer(void)
+{
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "AbortServer: Going to abort the current server.\n");
+#endif
+ OsCleanup(TRUE);
+ AbortDDX();
+ fflush(stderr);
+ if (CoreDump)
+ abort();
+#ifdef NX_TRANS_EXIT
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "AbortServer: Going to clean up NX resources and exit.\n");
+#endif
+ NXTransExit(1);
+#else /* #ifdef NX_TRANS_EXIT */
+ exit (1);
+#endif
+}
+
+#ifndef AUDIT_PREFIX
+#define AUDIT_PREFIX "AUDIT: %s: %ld %s: "
+#endif
+#ifndef AUDIT_TIMEOUT
+#define AUDIT_TIMEOUT ((CARD32)(120 * 1000)) /* 2 mn */
+#endif
+
+static int nrepeat = 0;
+static int oldlen = -1;
+static OsTimerPtr auditTimer = NULL;
+
+void
+FreeAuditTimer(void)
+{
+ if (auditTimer != NULL) {
+ /* Force output of pending messages */
+ TimerForce(auditTimer);
+ TimerFree(auditTimer);
+ auditTimer = NULL;
+ }
+}
+
+static char *
+AuditPrefix(void)
+{
+ time_t tm;
+ char *autime, *s;
+ char *tmpBuf;
+ int len;
+
+ time(&tm);
+ autime = ctime(&tm);
+ if ((s = strchr(autime, '\n')))
+ *s = '\0';
+ if ((s = strrchr(argvGlobal[0], '/')))
+ s++;
+ else
+ s = argvGlobal[0];
+ len = strlen(AUDIT_PREFIX) + strlen(autime) + 10 + strlen(s) + 1;
+ tmpBuf = malloc(len);
+ if (!tmpBuf)
+ return NULL;
+ snprintf(tmpBuf, len, AUDIT_PREFIX, autime, (unsigned long)getpid(), s);
+ return tmpBuf;
+}
+
+void
+AuditF(const char * f, ...)
+{
+ va_list args;
+
+ va_start(args, f);
+
+ VAuditF(f, args);
+ va_end(args);
+}
+
+static CARD32
+AuditFlush(OsTimerPtr timer, CARD32 now, pointer arg)
+{
+ char *prefix;
+
+ if (nrepeat > 0) {
+ prefix = AuditPrefix();
+ ErrorF("%slast message repeated %d times\n",
+ prefix != NULL ? prefix : "", nrepeat);
+ nrepeat = 0;
+ if (prefix != NULL)
+ free(prefix);
+ return AUDIT_TIMEOUT;
+ } else {
+ /* if the timer expires without anything to print, flush the message */
+ oldlen = -1;
+ return 0;
+ }
+}
+
+void
+VAuditF(const char *f, va_list args)
+{
+ char *prefix;
+ char buf[1024];
+ int len;
+ static char oldbuf[1024];
+
+ prefix = AuditPrefix();
+ len = vsnprintf(buf, sizeof(buf), f, args);
+
+#if 1
+ /* XXX Compressing duplicated messages is temporarily disabled to
+ * work around bugzilla 964:
+ * https://freedesktop.org/bugzilla/show_bug.cgi?id=964
+ */
+ ErrorF("%s%s", prefix != NULL ? prefix : "", buf);
+ oldlen = -1;
+ nrepeat = 0;
+#else
+ if (len == oldlen && strcmp(buf, oldbuf) == 0) {
+ /* Message already seen */
+ nrepeat++;
+ } else {
+ /* new message */
+ if (auditTimer != NULL)
+ TimerForce(auditTimer);
+ ErrorF("%s%s", prefix != NULL ? prefix : "", buf);
+ strlcpy(oldbuf, buf, sizeof(oldbuf));
+ oldlen = len;
+ nrepeat = 0;
+ auditTimer = TimerSet(auditTimer, 0, AUDIT_TIMEOUT, AuditFlush, NULL);
+ }
+#endif
+ if (prefix != NULL)
+ free(prefix);
+}
+
+void
+FatalError(const char *f, ...)
+{
+ va_list args;
+ static Bool beenhere = FALSE;
+
+#ifdef NX_TRANS_EXIT
+ if (beenhere) {
+ fprintf(stderr, "Error: Aborting session with fatal error function reentered.\n");
+ }
+ else {
+ /*
+ * Tell to the log function that this
+ * is a fatal error.
+ */
+
+ OsVendorVErrorFFatal = 1;
+
+ fprintf(stderr, "Error: Aborting session with '");
+
+ va_start(args, f);
+ VErrorF(f, args);
+ va_end(args);
+
+ fprintf(stderr, "'.\n");
+ }
+#else /* #ifdef NX_TRANS_EXIT */
+ if (beenhere)
+ ErrorF("\nFatalError re-entered, aborting\n");
+ else
+ ErrorF("\nFatal server error:\n");
+
+ va_start(args, f);
+ VErrorF(f, args);
+ va_end(args);
+ ErrorF("\n");
+#endif /* #ifdef NX_TRANS_EXIT */
+#ifdef DDXOSFATALERROR
+ if (!beenhere)
+ OsVendorFatalError();
+#endif
+#ifdef ABORTONFATALERROR
+ abort();
+#endif
+ if (!beenhere) {
+ beenhere = TRUE;
+ AbortServer();
+ } else
+ abort();
+ /*NOTREACHED*/
+}
+
+void
+VErrorF(const char *f, va_list args)
+{
+#ifdef DDXOSVERRORF
+ if (OsVendorVErrorFProc)
+ OsVendorVErrorFProc(f, args);
+ else
+ LogVWrite(-1, f, args);
+#else
+ LogVWrite(-1, f, args);
+#endif
+}
+
+void
+ErrorF(const char * f, ...)
+{
+ va_list args;
+
+ va_start(args, f);
+ VErrorF(f, args);
+ va_end(args);
+}
+
+/* A perror() workalike. */
+
+#ifndef NEED_STRERROR
+#ifdef SYSV
+#if !defined(ISC) || defined(ISC202) || defined(ISC22)
+#define NEED_STRERROR
+#endif
+#endif
+#endif
+
+#if defined(NEED_STRERROR) && !defined(strerror)
+extern char *sys_errlist[];
+extern int sys_nerr;
+#define strerror(n) \
+ ((n) >= 0 && (n) < sys_nerr) ? sys_errlist[(n)] : "unknown error"
+#endif
+
+void
+Error(char *str)
+{
+ char *err = NULL;
+ int saveErrno = errno;
+
+ if (str) {
+ err = malloc(strlen(strerror(saveErrno)) + strlen(str) + 2 + 1);
+ if (!err)
+ return;
+ sprintf(err, "%s: ", str);
+ strcat(err, strerror(saveErrno));
+ LogWrite(-1, err);
+ } else
+ LogWrite(-1, strerror(saveErrno));
+}
+
+void
+LogPrintMarkers()
+{
+ /* Show what the message marker symbols mean. */
+ ErrorF("Markers: ");
+ LogMessageVerb(X_PROBED, -1, "probed, ");
+ LogMessageVerb(X_CONFIG, -1, "from config file, ");
+ LogMessageVerb(X_DEFAULT, -1, "default setting,\n\t");
+ LogMessageVerb(X_CMDLINE, -1, "from command line, ");
+ LogMessageVerb(X_NOTICE, -1, "notice, ");
+ LogMessageVerb(X_INFO, -1, "informational,\n\t");
+ LogMessageVerb(X_WARNING, -1, "warning, ");
+ LogMessageVerb(X_ERROR, -1, "error, ");
+ LogMessageVerb(X_NOT_IMPLEMENTED, -1, "not implemented, ");
+ LogMessageVerb(X_UNKNOWN, -1, "unknown.\n");
+}
+
diff --git a/nx-X11/programs/Xserver/os/log.c.NX.original b/nx-X11/programs/Xserver/os/log.c.NX.original
new file mode 100644
index 000000000..e09943723
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/log.c.NX.original
@@ -0,0 +1,716 @@
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1994 Quarterdeck Office Systems.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Digital and
+Quarterdeck not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+DIGITAL AND QUARTERDECK DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
+OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
+OR PERFORMANCE OF THIS SOFTWARE.
+
+*/
+
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* $XFree86: xc/programs/Xserver/os/log.c,v 1.6 2003/11/07 13:45:27 tsi Exp $ */
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xos.h>
+#include <stdio.h>
+#include <time.h>
+#include <sys/stat.h>
+#include <stdarg.h>
+#include <stdlib.h> /* for malloc() */
+#include <errno.h>
+
+#include "site.h"
+#include "opaque.h"
+
+#ifdef WIN32
+#include <process.h>
+#define getpid(x) _getpid(x)
+#endif
+
+#ifdef NX_TRANS_SOCKET
+
+#include "NX.h"
+
+#endif
+
+#ifdef DDXOSVERRORF
+void (*OsVendorVErrorFProc)(const char *, va_list args) = NULL;
+#ifdef NX_TRANS_EXIT
+int OsVendorVErrorFFatal = 0;
+#endif
+#endif
+
+static FILE *logFile = NULL;
+static Bool logFlush = FALSE;
+static Bool logSync = FALSE;
+static int logVerbosity = DEFAULT_LOG_VERBOSITY;
+static int logFileVerbosity = DEFAULT_LOG_FILE_VERBOSITY;
+
+/* Buffer to information logged before the log file is opened. */
+static char *saveBuffer = NULL;
+static int bufferSize = 0, bufferUnused = 0, bufferPos = 0;
+static Bool needBuffer = TRUE;
+
+/* Prefix strings for log messages. */
+#ifndef X_UNKNOWN_STRING
+#define X_UNKNOWN_STRING "(\?\?)"
+#endif
+#ifndef X_PROBE_STRING
+#define X_PROBE_STRING "(--)"
+#endif
+#ifndef X_CONFIG_STRING
+#define X_CONFIG_STRING "(**)"
+#endif
+#ifndef X_DEFAULT_STRING
+#define X_DEFAULT_STRING "(==)"
+#endif
+#ifndef X_CMDLINE_STRING
+#define X_CMDLINE_STRING "(++)"
+#endif
+#ifndef X_NOTICE_STRING
+#define X_NOTICE_STRING "(!!)"
+#endif
+#ifndef X_ERROR_STRING
+#define X_ERROR_STRING "(EE)"
+#endif
+#ifndef X_WARNING_STRING
+#define X_WARNING_STRING "(WW)"
+#endif
+#ifndef X_INFO_STRING
+#define X_INFO_STRING "(II)"
+#endif
+#ifndef X_NOT_IMPLEMENTED_STRING
+#define X_NOT_IMPLEMENTED_STRING "(NI)"
+#endif
+
+/*
+ * LogInit is called to start logging to a file. It is also called (with
+ * NULL arguments) when logging to a file is not wanted. It must always be
+ * called, otherwise log messages will continue to accumulate in a buffer.
+ *
+ * %s, if present in the fname or backup strings, is expanded to the display
+ * string.
+ */
+
+const char *
+LogInit(const char *fname, const char *backup)
+{
+ char *logFileName = NULL;
+
+ if (fname && *fname) {
+ /* xalloc() can't be used yet. */
+ logFileName = malloc(strlen(fname) + strlen(display) + 1);
+ if (!logFileName)
+ FatalError("Cannot allocate space for the log file name\n");
+ sprintf(logFileName, fname, display);
+
+ if (backup && *backup) {
+ struct stat buf;
+
+ if (!stat(logFileName, &buf) && S_ISREG(buf.st_mode)) {
+ char *suffix;
+ char *oldLog;
+
+ oldLog = malloc(strlen(logFileName) + strlen(backup) +
+ strlen(display) + 1);
+ suffix = malloc(strlen(backup) + strlen(display) + 1);
+ if (!oldLog || !suffix)
+ FatalError("Cannot allocate space for the log file name\n");
+ sprintf(suffix, backup, display);
+ sprintf(oldLog, "%s%s", logFileName, suffix);
+ free(suffix);
+#ifdef __UNIXOS2__
+ remove(oldLog);
+#endif
+ if (rename(logFileName, oldLog) == -1) {
+ FatalError("Cannot move old log file (\"%s\" to \"%s\"\n",
+ logFileName, oldLog);
+ }
+ free(oldLog);
+ }
+ }
+ if ((logFile = fopen(logFileName, "w")) == NULL)
+ FatalError("Cannot open log file \"%s\"\n", logFileName);
+ setvbuf(logFile, NULL, _IONBF, 0);
+
+ /* Flush saved log information. */
+ if (saveBuffer && bufferSize > 0) {
+ fwrite(saveBuffer, bufferPos, 1, logFile);
+ fflush(logFile);
+#ifndef WIN32
+ fsync(fileno(logFile));
+#endif
+ }
+ }
+
+ /*
+ * Unconditionally free the buffer, and flag that the buffer is no longer
+ * needed.
+ */
+ if (saveBuffer && bufferSize > 0) {
+ free(saveBuffer); /* Must be free(), not xfree() */
+ saveBuffer = NULL;
+ bufferSize = 0;
+ }
+ needBuffer = FALSE;
+
+ return logFileName;
+}
+
+void
+LogClose()
+{
+ if (logFile) {
+ fclose(logFile);
+ logFile = NULL;
+ }
+}
+
+Bool
+LogSetParameter(LogParameter param, int value)
+{
+ switch (param) {
+ case XLOG_FLUSH:
+ logFlush = value ? TRUE : FALSE;
+ return TRUE;
+ case XLOG_SYNC:
+ logSync = value ? TRUE : FALSE;
+ return TRUE;
+ case XLOG_VERBOSITY:
+ logVerbosity = value;
+ return TRUE;
+ case XLOG_FILE_VERBOSITY:
+ logFileVerbosity = value;
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
+/* This function does the actual log message writes. */
+
+void
+LogVWrite(int verb, const char *f, va_list args)
+{
+ static char tmpBuffer[1024];
+ int len = 0;
+
+ /*
+ * Since a va_list can only be processed once, write the string to a
+ * buffer, and then write the buffer out to the appropriate output
+ * stream(s).
+ */
+ if (verb < 0 || logFileVerbosity >= verb || logVerbosity >= verb) {
+ vsnprintf(tmpBuffer, sizeof(tmpBuffer), f, args);
+#ifdef NX_TRANS_EXIT
+ /*
+ * Beautify the message. Make the
+ * first letter uppercase.
+ */
+
+ *tmpBuffer = toupper(*tmpBuffer);
+
+ /*
+ * Remove the trailing newline.
+ */
+
+ if (strlen(tmpBuffer) > 0 &&
+ *(tmpBuffer + strlen(tmpBuffer) - 1) == '\n') {
+ *(tmpBuffer + strlen(tmpBuffer) - 1) = '\0';
+ }
+
+ /*
+ * Remove the trailing full-stop.
+ */
+
+ if (strlen(tmpBuffer) > 0 &&
+ *(tmpBuffer + strlen(tmpBuffer) - 1) == '.') {
+ *(tmpBuffer + strlen(tmpBuffer) - 1) = '\0';
+ }
+#endif /* #ifdef NX_TRANS_EXIT */
+ len = strlen(tmpBuffer);
+ }
+ if ((verb < 0 || logVerbosity >= verb) && len > 0)
+ fwrite(tmpBuffer, len, 1, stderr);
+ if ((verb < 0 || logFileVerbosity >= verb) && len > 0) {
+ if (logFile) {
+ fwrite(tmpBuffer, len, 1, logFile);
+ if (logFlush) {
+ fflush(logFile);
+#ifndef WIN32
+ if (logSync)
+ fsync(fileno(logFile));
+#endif
+ }
+ } else if (needBuffer) {
+ /*
+ * Note, this code is used before OsInit() has been called, so
+ * xalloc() and friends can't be used.
+ */
+ if (len > bufferUnused) {
+ bufferSize += 1024;
+ bufferUnused += 1024;
+ if (saveBuffer)
+ saveBuffer = realloc(saveBuffer, bufferSize);
+ else
+ saveBuffer = malloc(bufferSize);
+ if (!saveBuffer)
+ FatalError("realloc() failed while saving log messages\n");
+ }
+ bufferUnused -= len;
+ memcpy(saveBuffer + bufferPos, tmpBuffer, len);
+ bufferPos += len;
+ }
+ }
+}
+
+void
+LogWrite(int verb, const char *f, ...)
+{
+ va_list args;
+
+ va_start(args, f);
+ LogVWrite(verb, f, args);
+ va_end(args);
+}
+
+void
+LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
+{
+ const char *s = X_UNKNOWN_STRING;
+ char *tmpBuf = NULL;
+
+ /* Ignore verbosity for X_ERROR */
+ if (logVerbosity >= verb || logFileVerbosity >= verb || type == X_ERROR) {
+ switch (type) {
+ case X_PROBED:
+ s = X_PROBE_STRING;
+ break;
+ case X_CONFIG:
+ s = X_CONFIG_STRING;
+ break;
+ case X_DEFAULT:
+ s = X_DEFAULT_STRING;
+ break;
+ case X_CMDLINE:
+ s = X_CMDLINE_STRING;
+ break;
+ case X_NOTICE:
+ s = X_NOTICE_STRING;
+ break;
+ case X_ERROR:
+ s = X_ERROR_STRING;
+ if (verb > 0)
+ verb = 0;
+ break;
+ case X_WARNING:
+ s = X_WARNING_STRING;
+ break;
+ case X_INFO:
+ s = X_INFO_STRING;
+ break;
+ case X_NOT_IMPLEMENTED:
+ s = X_NOT_IMPLEMENTED_STRING;
+ break;
+ case X_UNKNOWN:
+ s = X_UNKNOWN_STRING;
+ break;
+ case X_NONE:
+ s = NULL;
+ break;
+ }
+
+ /*
+ * Prefix the format string with the message type. We do it this way
+ * so that LogVWrite() is only called once per message.
+ */
+ if (s) {
+ tmpBuf = malloc(strlen(format) + strlen(s) + 1 + 1);
+ /* Silently return if malloc fails here. */
+ if (!tmpBuf)
+ return;
+ sprintf(tmpBuf, "%s ", s);
+ strcat(tmpBuf, format);
+ LogVWrite(verb, tmpBuf, args);
+ free(tmpBuf);
+ } else
+ LogVWrite(verb, format, args);
+ }
+}
+
+/* Log message with verbosity level specified. */
+void
+LogMessageVerb(MessageType type, int verb, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ LogVMessageVerb(type, verb, format, ap);
+ va_end(ap);
+}
+
+/* Log a message with the standard verbosity level of 1. */
+void
+LogMessage(MessageType type, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ LogVMessageVerb(type, 1, format, ap);
+ va_end(ap);
+}
+
+#ifdef __GNUC__
+void AbortServer(void) __attribute__((noreturn));
+#endif
+
+void
+AbortServer(void)
+{
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "AbortServer: Going to abort the current server.\n");
+#endif
+ OsCleanup(TRUE);
+ AbortDDX();
+ fflush(stderr);
+ if (CoreDump)
+ abort();
+#ifdef NX_TRANS_EXIT
+#ifdef NX_TRANS_TEST
+ fprintf(stderr, "AbortServer: Going to clean up NX resources and exit.\n");
+#endif
+ NXTransExit(1);
+#else /* #ifdef NX_TRANS_EXIT */
+ exit (1);
+#endif
+}
+
+#ifndef AUDIT_PREFIX
+#define AUDIT_PREFIX "AUDIT: %s: %ld %s: "
+#endif
+#ifndef AUDIT_TIMEOUT
+#define AUDIT_TIMEOUT ((CARD32)(120 * 1000)) /* 2 mn */
+#endif
+
+static int nrepeat = 0;
+static int oldlen = -1;
+static OsTimerPtr auditTimer = NULL;
+
+void
+FreeAuditTimer(void)
+{
+ if (auditTimer != NULL) {
+ /* Force output of pending messages */
+ TimerForce(auditTimer);
+ TimerFree(auditTimer);
+ auditTimer = NULL;
+ }
+}
+
+static char *
+AuditPrefix(void)
+{
+ time_t tm;
+ char *autime, *s;
+ char *tmpBuf;
+ int len;
+
+ time(&tm);
+ autime = ctime(&tm);
+ if ((s = strchr(autime, '\n')))
+ *s = '\0';
+ if ((s = strrchr(argvGlobal[0], '/')))
+ s++;
+ else
+ s = argvGlobal[0];
+ len = strlen(AUDIT_PREFIX) + strlen(autime) + 10 + strlen(s) + 1;
+ tmpBuf = malloc(len);
+ if (!tmpBuf)
+ return NULL;
+ snprintf(tmpBuf, len, AUDIT_PREFIX, autime, (unsigned long)getpid(), s);
+ return tmpBuf;
+}
+
+void
+AuditF(const char * f, ...)
+{
+ va_list args;
+
+ va_start(args, f);
+
+ VAuditF(f, args);
+ va_end(args);
+}
+
+static CARD32
+AuditFlush(OsTimerPtr timer, CARD32 now, pointer arg)
+{
+ char *prefix;
+
+ if (nrepeat > 0) {
+ prefix = AuditPrefix();
+ ErrorF("%slast message repeated %d times\n",
+ prefix != NULL ? prefix : "", nrepeat);
+ nrepeat = 0;
+ if (prefix != NULL)
+ free(prefix);
+ return AUDIT_TIMEOUT;
+ } else {
+ /* if the timer expires without anything to print, flush the message */
+ oldlen = -1;
+ return 0;
+ }
+}
+
+void
+VAuditF(const char *f, va_list args)
+{
+ char *prefix;
+ char buf[1024];
+ int len;
+ static char oldbuf[1024];
+
+ prefix = AuditPrefix();
+ len = vsnprintf(buf, sizeof(buf), f, args);
+
+#if 1
+ /* XXX Compressing duplicated messages is temporarily disabled to
+ * work around bugzilla 964:
+ * https://freedesktop.org/bugzilla/show_bug.cgi?id=964
+ */
+ ErrorF("%s%s", prefix != NULL ? prefix : "", buf);
+ oldlen = -1;
+ nrepeat = 0;
+#else
+ if (len == oldlen && strcmp(buf, oldbuf) == 0) {
+ /* Message already seen */
+ nrepeat++;
+ } else {
+ /* new message */
+ if (auditTimer != NULL)
+ TimerForce(auditTimer);
+ ErrorF("%s%s", prefix != NULL ? prefix : "", buf);
+ strlcpy(oldbuf, buf, sizeof(oldbuf));
+ oldlen = len;
+ nrepeat = 0;
+ auditTimer = TimerSet(auditTimer, 0, AUDIT_TIMEOUT, AuditFlush, NULL);
+ }
+#endif
+ if (prefix != NULL)
+ free(prefix);
+}
+
+void
+FatalError(const char *f, ...)
+{
+ va_list args;
+ static Bool beenhere = FALSE;
+
+#ifdef NX_TRANS_EXIT
+ if (beenhere) {
+ fprintf(stderr, "Error: Aborting session with fatal error function reentered.\n");
+ }
+ else {
+ /*
+ * Tell to the log function that this
+ * is a fatal error.
+ */
+
+ OsVendorVErrorFFatal = 1;
+
+ fprintf(stderr, "Error: Aborting session with '");
+
+ va_start(args, f);
+ VErrorF(f, args);
+ va_end(args);
+
+ fprintf(stderr, "'.\n");
+ }
+#else /* #ifdef NX_TRANS_EXIT */
+ if (beenhere)
+ ErrorF("\nFatalError re-entered, aborting\n");
+ else
+ ErrorF("\nFatal server error:\n");
+
+ va_start(args, f);
+ VErrorF(f, args);
+ va_end(args);
+ ErrorF("\n");
+#endif /* #ifdef NX_TRANS_EXIT */
+#ifdef DDXOSFATALERROR
+ if (!beenhere)
+ OsVendorFatalError();
+#endif
+#ifdef ABORTONFATALERROR
+ abort();
+#endif
+ if (!beenhere) {
+ beenhere = TRUE;
+ AbortServer();
+ } else
+ abort();
+ /*NOTREACHED*/
+}
+
+void
+VErrorF(const char *f, va_list args)
+{
+#ifdef DDXOSVERRORF
+ if (OsVendorVErrorFProc)
+ OsVendorVErrorFProc(f, args);
+ else
+ LogVWrite(-1, f, args);
+#else
+ LogVWrite(-1, f, args);
+#endif
+}
+
+void
+ErrorF(const char * f, ...)
+{
+ va_list args;
+
+ va_start(args, f);
+ VErrorF(f, args);
+ va_end(args);
+}
+
+/* A perror() workalike. */
+
+#ifndef NEED_STRERROR
+#ifdef SYSV
+#if !defined(ISC) || defined(ISC202) || defined(ISC22)
+#define NEED_STRERROR
+#endif
+#endif
+#endif
+
+#if defined(NEED_STRERROR) && !defined(strerror)
+extern char *sys_errlist[];
+extern int sys_nerr;
+#define strerror(n) \
+ ((n) >= 0 && (n) < sys_nerr) ? sys_errlist[(n)] : "unknown error"
+#endif
+
+void
+Error(char *str)
+{
+ char *err = NULL;
+ int saveErrno = errno;
+
+ if (str) {
+ err = malloc(strlen(strerror(saveErrno)) + strlen(str) + 2 + 1);
+ if (!err)
+ return;
+ sprintf(err, "%s: ", str);
+ strcat(err, strerror(saveErrno));
+ LogWrite(-1, err);
+ } else
+ LogWrite(-1, strerror(saveErrno));
+}
+
+void
+LogPrintMarkers()
+{
+ /* Show what the message marker symbols mean. */
+ ErrorF("Markers: ");
+ LogMessageVerb(X_PROBED, -1, "probed, ");
+ LogMessageVerb(X_CONFIG, -1, "from config file, ");
+ LogMessageVerb(X_DEFAULT, -1, "default setting,\n\t");
+ LogMessageVerb(X_CMDLINE, -1, "from command line, ");
+ LogMessageVerb(X_NOTICE, -1, "notice, ");
+ LogMessageVerb(X_INFO, -1, "informational,\n\t");
+ LogMessageVerb(X_WARNING, -1, "warning, ");
+ LogMessageVerb(X_ERROR, -1, "error, ");
+ LogMessageVerb(X_NOT_IMPLEMENTED, -1, "not implemented, ");
+ LogMessageVerb(X_UNKNOWN, -1, "unknown.\n");
+}
+
diff --git a/nx-X11/programs/Xserver/os/log.c.X.original b/nx-X11/programs/Xserver/os/log.c.X.original
new file mode 100644
index 000000000..4bebbe784
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/log.c.X.original
@@ -0,0 +1,633 @@
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1994 Quarterdeck Office Systems.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Digital and
+Quarterdeck not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+DIGITAL AND QUARTERDECK DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
+OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
+OR PERFORMANCE OF THIS SOFTWARE.
+
+*/
+
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* $XFree86: xc/programs/Xserver/os/log.c,v 1.6 2003/11/07 13:45:27 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xos.h>
+#include <stdio.h>
+#include <time.h>
+#include <sys/stat.h>
+#include <stdarg.h>
+#include <stdlib.h> /* for malloc() */
+#include <errno.h>
+
+#include "site.h"
+#include "opaque.h"
+
+#ifdef WIN32
+#include <process.h>
+#define getpid(x) _getpid(x)
+#endif
+
+
+#ifdef DDXOSVERRORF
+void (*OsVendorVErrorFProc)(const char *, va_list args) = NULL;
+#endif
+
+static FILE *logFile = NULL;
+static Bool logFlush = FALSE;
+static Bool logSync = FALSE;
+static int logVerbosity = DEFAULT_LOG_VERBOSITY;
+static int logFileVerbosity = DEFAULT_LOG_FILE_VERBOSITY;
+
+/* Buffer to information logged before the log file is opened. */
+static char *saveBuffer = NULL;
+static int bufferSize = 0, bufferUnused = 0, bufferPos = 0;
+static Bool needBuffer = TRUE;
+
+/* Prefix strings for log messages. */
+#ifndef X_UNKNOWN_STRING
+#define X_UNKNOWN_STRING "(\?\?)"
+#endif
+#ifndef X_PROBE_STRING
+#define X_PROBE_STRING "(--)"
+#endif
+#ifndef X_CONFIG_STRING
+#define X_CONFIG_STRING "(**)"
+#endif
+#ifndef X_DEFAULT_STRING
+#define X_DEFAULT_STRING "(==)"
+#endif
+#ifndef X_CMDLINE_STRING
+#define X_CMDLINE_STRING "(++)"
+#endif
+#ifndef X_NOTICE_STRING
+#define X_NOTICE_STRING "(!!)"
+#endif
+#ifndef X_ERROR_STRING
+#define X_ERROR_STRING "(EE)"
+#endif
+#ifndef X_WARNING_STRING
+#define X_WARNING_STRING "(WW)"
+#endif
+#ifndef X_INFO_STRING
+#define X_INFO_STRING "(II)"
+#endif
+#ifndef X_NOT_IMPLEMENTED_STRING
+#define X_NOT_IMPLEMENTED_STRING "(NI)"
+#endif
+
+/*
+ * LogInit is called to start logging to a file. It is also called (with
+ * NULL arguments) when logging to a file is not wanted. It must always be
+ * called, otherwise log messages will continue to accumulate in a buffer.
+ *
+ * %s, if present in the fname or backup strings, is expanded to the display
+ * string.
+ */
+
+const char *
+LogInit(const char *fname, const char *backup)
+{
+ char *logFileName = NULL;
+
+ if (fname && *fname) {
+ /* xalloc() can't be used yet. */
+ logFileName = malloc(strlen(fname) + strlen(display) + 1);
+ if (!logFileName)
+ FatalError("Cannot allocate space for the log file name\n");
+ sprintf(logFileName, fname, display);
+
+ if (backup && *backup) {
+ struct stat buf;
+
+ if (!stat(logFileName, &buf) && S_ISREG(buf.st_mode)) {
+ char *suffix;
+ char *oldLog;
+
+ oldLog = malloc(strlen(logFileName) + strlen(backup) +
+ strlen(display) + 1);
+ suffix = malloc(strlen(backup) + strlen(display) + 1);
+ if (!oldLog || !suffix)
+ FatalError("Cannot allocate space for the log file name\n");
+ sprintf(suffix, backup, display);
+ sprintf(oldLog, "%s%s", logFileName, suffix);
+ free(suffix);
+#ifdef __UNIXOS2__
+ remove(oldLog);
+#endif
+ if (rename(logFileName, oldLog) == -1) {
+ FatalError("Cannot move old log file (\"%s\" to \"%s\"\n",
+ logFileName, oldLog);
+ }
+ free(oldLog);
+ }
+ }
+ if ((logFile = fopen(logFileName, "w")) == NULL)
+ FatalError("Cannot open log file \"%s\"\n", logFileName);
+ setvbuf(logFile, NULL, _IONBF, 0);
+
+ /* Flush saved log information. */
+ if (saveBuffer && bufferSize > 0) {
+ fwrite(saveBuffer, bufferPos, 1, logFile);
+ fflush(logFile);
+#ifndef WIN32
+ fsync(fileno(logFile));
+#endif
+ }
+ }
+
+ /*
+ * Unconditionally free the buffer, and flag that the buffer is no longer
+ * needed.
+ */
+ if (saveBuffer && bufferSize > 0) {
+ free(saveBuffer); /* Must be free(), not xfree() */
+ saveBuffer = NULL;
+ bufferSize = 0;
+ }
+ needBuffer = FALSE;
+
+ return logFileName;
+}
+
+void
+LogClose()
+{
+ if (logFile) {
+ fclose(logFile);
+ logFile = NULL;
+ }
+}
+
+Bool
+LogSetParameter(LogParameter param, int value)
+{
+ switch (param) {
+ case XLOG_FLUSH:
+ logFlush = value ? TRUE : FALSE;
+ return TRUE;
+ case XLOG_SYNC:
+ logSync = value ? TRUE : FALSE;
+ return TRUE;
+ case XLOG_VERBOSITY:
+ logVerbosity = value;
+ return TRUE;
+ case XLOG_FILE_VERBOSITY:
+ logFileVerbosity = value;
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
+/* This function does the actual log message writes. */
+
+void
+LogVWrite(int verb, const char *f, va_list args)
+{
+ static char tmpBuffer[1024];
+ int len = 0;
+
+ /*
+ * Since a va_list can only be processed once, write the string to a
+ * buffer, and then write the buffer out to the appropriate output
+ * stream(s).
+ */
+ if (verb < 0 || logFileVerbosity >= verb || logVerbosity >= verb) {
+ vsnprintf(tmpBuffer, sizeof(tmpBuffer), f, args);
+ len = strlen(tmpBuffer);
+ }
+ if ((verb < 0 || logVerbosity >= verb) && len > 0)
+ fwrite(tmpBuffer, len, 1, stderr);
+ if ((verb < 0 || logFileVerbosity >= verb) && len > 0) {
+ if (logFile) {
+ fwrite(tmpBuffer, len, 1, logFile);
+ if (logFlush) {
+ fflush(logFile);
+#ifndef WIN32
+ if (logSync)
+ fsync(fileno(logFile));
+#endif
+ }
+ } else if (needBuffer) {
+ /*
+ * Note, this code is used before OsInit() has been called, so
+ * xalloc() and friends can't be used.
+ */
+ if (len > bufferUnused) {
+ bufferSize += 1024;
+ bufferUnused += 1024;
+ if (saveBuffer)
+ saveBuffer = realloc(saveBuffer, bufferSize);
+ else
+ saveBuffer = malloc(bufferSize);
+ if (!saveBuffer)
+ FatalError("realloc() failed while saving log messages\n");
+ }
+ bufferUnused -= len;
+ memcpy(saveBuffer + bufferPos, tmpBuffer, len);
+ bufferPos += len;
+ }
+ }
+}
+
+void
+LogWrite(int verb, const char *f, ...)
+{
+ va_list args;
+
+ va_start(args, f);
+ LogVWrite(verb, f, args);
+ va_end(args);
+}
+
+void
+LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
+{
+ const char *s = X_UNKNOWN_STRING;
+ char *tmpBuf = NULL;
+
+ /* Ignore verbosity for X_ERROR */
+ if (logVerbosity >= verb || logFileVerbosity >= verb || type == X_ERROR) {
+ switch (type) {
+ case X_PROBED:
+ s = X_PROBE_STRING;
+ break;
+ case X_CONFIG:
+ s = X_CONFIG_STRING;
+ break;
+ case X_DEFAULT:
+ s = X_DEFAULT_STRING;
+ break;
+ case X_CMDLINE:
+ s = X_CMDLINE_STRING;
+ break;
+ case X_NOTICE:
+ s = X_NOTICE_STRING;
+ break;
+ case X_ERROR:
+ s = X_ERROR_STRING;
+ if (verb > 0)
+ verb = 0;
+ break;
+ case X_WARNING:
+ s = X_WARNING_STRING;
+ break;
+ case X_INFO:
+ s = X_INFO_STRING;
+ break;
+ case X_NOT_IMPLEMENTED:
+ s = X_NOT_IMPLEMENTED_STRING;
+ break;
+ case X_UNKNOWN:
+ s = X_UNKNOWN_STRING;
+ break;
+ case X_NONE:
+ s = NULL;
+ break;
+ }
+
+ /*
+ * Prefix the format string with the message type. We do it this way
+ * so that LogVWrite() is only called once per message.
+ */
+ if (s) {
+ tmpBuf = malloc(strlen(format) + strlen(s) + 1 + 1);
+ /* Silently return if malloc fails here. */
+ if (!tmpBuf)
+ return;
+ sprintf(tmpBuf, "%s ", s);
+ strcat(tmpBuf, format);
+ LogVWrite(verb, tmpBuf, args);
+ free(tmpBuf);
+ } else
+ LogVWrite(verb, format, args);
+ }
+}
+
+/* Log message with verbosity level specified. */
+void
+LogMessageVerb(MessageType type, int verb, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ LogVMessageVerb(type, verb, format, ap);
+ va_end(ap);
+}
+
+/* Log a message with the standard verbosity level of 1. */
+void
+LogMessage(MessageType type, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ LogVMessageVerb(type, 1, format, ap);
+ va_end(ap);
+}
+
+#ifdef __GNUC__
+void AbortServer(void) __attribute__((noreturn));
+#endif
+
+void
+AbortServer(void)
+{
+ OsCleanup(TRUE);
+ AbortDDX();
+ fflush(stderr);
+ if (CoreDump)
+ abort();
+ exit (1);
+}
+
+#ifndef AUDIT_PREFIX
+#define AUDIT_PREFIX "AUDIT: %s: %ld %s: "
+#endif
+#ifndef AUDIT_TIMEOUT
+#define AUDIT_TIMEOUT ((CARD32)(120 * 1000)) /* 2 mn */
+#endif
+
+static int nrepeat = 0;
+static int oldlen = -1;
+static OsTimerPtr auditTimer = NULL;
+
+void
+FreeAuditTimer(void)
+{
+ if (auditTimer != NULL) {
+ /* Force output of pending messages */
+ TimerForce(auditTimer);
+ TimerFree(auditTimer);
+ auditTimer = NULL;
+ }
+}
+
+static char *
+AuditPrefix(void)
+{
+ time_t tm;
+ char *autime, *s;
+ char *tmpBuf;
+ int len;
+
+ time(&tm);
+ autime = ctime(&tm);
+ if ((s = strchr(autime, '\n')))
+ *s = '\0';
+ if ((s = strrchr(argvGlobal[0], '/')))
+ s++;
+ else
+ s = argvGlobal[0];
+ len = strlen(AUDIT_PREFIX) + strlen(autime) + 10 + strlen(s) + 1;
+ tmpBuf = malloc(len);
+ if (!tmpBuf)
+ return NULL;
+ snprintf(tmpBuf, len, AUDIT_PREFIX, autime, (unsigned long)getpid(), s);
+ return tmpBuf;
+}
+
+void
+AuditF(const char * f, ...)
+{
+ va_list args;
+
+ va_start(args, f);
+
+ VAuditF(f, args);
+ va_end(args);
+}
+
+static CARD32
+AuditFlush(OsTimerPtr timer, CARD32 now, pointer arg)
+{
+ char *prefix;
+
+ if (nrepeat > 0) {
+ prefix = AuditPrefix();
+ ErrorF("%slast message repeated %d times\n",
+ prefix != NULL ? prefix : "", nrepeat);
+ nrepeat = 0;
+ if (prefix != NULL)
+ free(prefix);
+ return AUDIT_TIMEOUT;
+ } else {
+ /* if the timer expires without anything to print, flush the message */
+ oldlen = -1;
+ return 0;
+ }
+}
+
+void
+VAuditF(const char *f, va_list args)
+{
+ char *prefix;
+ char buf[1024];
+ int len;
+ static char oldbuf[1024];
+
+ prefix = AuditPrefix();
+ len = vsnprintf(buf, sizeof(buf), f, args);
+
+#if 1
+ /* XXX Compressing duplicated messages is temporarily disabled to
+ * work around bugzilla 964:
+ * https://freedesktop.org/bugzilla/show_bug.cgi?id=964
+ */
+ ErrorF("%s%s", prefix != NULL ? prefix : "", buf);
+ oldlen = -1;
+ nrepeat = 0;
+#else
+ if (len == oldlen && strcmp(buf, oldbuf) == 0) {
+ /* Message already seen */
+ nrepeat++;
+ } else {
+ /* new message */
+ if (auditTimer != NULL)
+ TimerForce(auditTimer);
+ ErrorF("%s%s", prefix != NULL ? prefix : "", buf);
+ strlcpy(oldbuf, buf, sizeof(oldbuf));
+ oldlen = len;
+ nrepeat = 0;
+ auditTimer = TimerSet(auditTimer, 0, AUDIT_TIMEOUT, AuditFlush, NULL);
+ }
+#endif
+ if (prefix != NULL)
+ free(prefix);
+}
+
+void
+FatalError(const char *f, ...)
+{
+ va_list args;
+ static Bool beenhere = FALSE;
+
+ if (beenhere)
+ ErrorF("\nFatalError re-entered, aborting\n");
+ else
+ ErrorF("\nFatal server error:\n");
+
+ va_start(args, f);
+ VErrorF(f, args);
+ va_end(args);
+ ErrorF("\n");
+#ifdef DDXOSFATALERROR
+ if (!beenhere)
+ OsVendorFatalError();
+#endif
+#ifdef ABORTONFATALERROR
+ abort();
+#endif
+ if (!beenhere) {
+ beenhere = TRUE;
+ AbortServer();
+ } else
+ abort();
+ /*NOTREACHED*/
+}
+
+void
+VErrorF(const char *f, va_list args)
+{
+#ifdef DDXOSVERRORF
+ if (OsVendorVErrorFProc)
+ OsVendorVErrorFProc(f, args);
+ else
+ LogVWrite(-1, f, args);
+#else
+ LogVWrite(-1, f, args);
+#endif
+}
+
+void
+ErrorF(const char * f, ...)
+{
+ va_list args;
+
+ va_start(args, f);
+ VErrorF(f, args);
+ va_end(args);
+}
+
+/* A perror() workalike. */
+
+#ifndef NEED_STRERROR
+#ifdef SYSV
+#if !defined(ISC) || defined(ISC202) || defined(ISC22)
+#define NEED_STRERROR
+#endif
+#endif
+#endif
+
+#if defined(NEED_STRERROR) && !defined(strerror)
+extern char *sys_errlist[];
+extern int sys_nerr;
+#define strerror(n) \
+ ((n) >= 0 && (n) < sys_nerr) ? sys_errlist[(n)] : "unknown error"
+#endif
+
+void
+Error(char *str)
+{
+ char *err = NULL;
+ int saveErrno = errno;
+
+ if (str) {
+ err = malloc(strlen(strerror(saveErrno)) + strlen(str) + 2 + 1);
+ if (!err)
+ return;
+ sprintf(err, "%s: ", str);
+ strcat(err, strerror(saveErrno));
+ LogWrite(-1, err);
+ } else
+ LogWrite(-1, strerror(saveErrno));
+}
+
+void
+LogPrintMarkers()
+{
+ /* Show what the message marker symbols mean. */
+ ErrorF("Markers: ");
+ LogMessageVerb(X_PROBED, -1, "probed, ");
+ LogMessageVerb(X_CONFIG, -1, "from config file, ");
+ LogMessageVerb(X_DEFAULT, -1, "default setting,\n\t");
+ LogMessageVerb(X_CMDLINE, -1, "from command line, ");
+ LogMessageVerb(X_NOTICE, -1, "notice, ");
+ LogMessageVerb(X_INFO, -1, "informational,\n\t");
+ LogMessageVerb(X_WARNING, -1, "warning, ");
+ LogMessageVerb(X_ERROR, -1, "error, ");
+ LogMessageVerb(X_NOT_IMPLEMENTED, -1, "not implemented, ");
+ LogMessageVerb(X_UNKNOWN, -1, "unknown.\n");
+}
+
diff --git a/nx-X11/programs/Xserver/os/mitauth.c b/nx-X11/programs/Xserver/os/mitauth.c
new file mode 100644
index 000000000..2f42fd41f
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/mitauth.c
@@ -0,0 +1,199 @@
+/* $Xorg: mitauth.c,v 1.4 2001/02/09 02:05:23 xorgcvs Exp $ */
+/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/os/mitauth.c,v 1.4 2001/01/17 22:37:11 dawes Exp $ */
+
+/*
+ * MIT-MAGIC-COOKIE-1 authorization scheme
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "osdep.h"
+#include "dixstruct.h"
+
+static struct auth {
+ struct auth *next;
+ unsigned short len;
+ char *data;
+ XID id;
+} *mit_auth;
+
+int
+MitAddCookie (
+ unsigned short data_length,
+ char *data,
+ XID id)
+{
+ struct auth *new;
+
+ new = (struct auth *) xalloc (sizeof (struct auth));
+ if (!new)
+ return 0;
+ new->data = (char *) xalloc ((unsigned) data_length);
+ if (!new->data) {
+ xfree(new);
+ return 0;
+ }
+ new->next = mit_auth;
+ mit_auth = new;
+ memmove(new->data, data, (int) data_length);
+ new->len = data_length;
+ new->id = id;
+ return 1;
+}
+
+XID
+MitCheckCookie (
+ unsigned short data_length,
+ char *data,
+ ClientPtr client,
+ char **reason)
+{
+ struct auth *auth;
+
+ for (auth = mit_auth; auth; auth=auth->next) {
+ if (data_length == auth->len &&
+ memcmp (data, auth->data, (int) data_length) == 0)
+ return auth->id;
+ }
+ *reason = "Invalid MIT-MAGIC-COOKIE-1 key";
+ return (XID) -1;
+}
+
+int
+MitResetCookie (void)
+{
+ struct auth *auth, *next;
+
+ for (auth = mit_auth; auth; auth=next) {
+ next = auth->next;
+ xfree (auth->data);
+ xfree (auth);
+ }
+ mit_auth = 0;
+ return 0;
+}
+
+XID
+MitToID (
+ unsigned short data_length,
+ char *data)
+{
+ struct auth *auth;
+
+ for (auth = mit_auth; auth; auth=auth->next) {
+ if (data_length == auth->len &&
+ memcmp (data, auth->data, data_length) == 0)
+ return auth->id;
+ }
+ return (XID) -1;
+}
+
+int
+MitFromID (
+ XID id,
+ unsigned short *data_lenp,
+ char **datap)
+{
+ struct auth *auth;
+
+ for (auth = mit_auth; auth; auth=auth->next) {
+ if (id == auth->id) {
+ *data_lenp = auth->len;
+ *datap = auth->data;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int
+MitRemoveCookie (
+ unsigned short data_length,
+ char *data)
+{
+ struct auth *auth, *prev;
+
+ prev = 0;
+ for (auth = mit_auth; auth; prev = auth, auth=auth->next) {
+ if (data_length == auth->len &&
+ memcmp (data, auth->data, data_length) == 0)
+ {
+ if (prev)
+ prev->next = auth->next;
+ else
+ mit_auth = auth->next;
+ xfree (auth->data);
+ xfree (auth);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+#ifdef XCSECURITY
+
+static char cookie[16]; /* 128 bits */
+
+XID
+MitGenerateCookie (
+ unsigned data_length,
+ char *data,
+ XID id,
+ unsigned *data_length_return,
+ char **data_return)
+{
+ int i = 0;
+ int status;
+
+ while (data_length--)
+ {
+ cookie[i++] += *data++;
+ if (i >= sizeof (cookie)) i = 0;
+ }
+ GenerateRandomData(sizeof (cookie), cookie);
+ status = MitAddCookie(sizeof (cookie), cookie, id);
+ if (!status)
+ {
+ id = -1;
+ }
+ else
+ {
+ *data_return = cookie;
+ *data_length_return = sizeof (cookie);
+ }
+ return id;
+}
+
+#endif /* XCSECURITY */
diff --git a/nx-X11/programs/Xserver/os/oscolor.c b/nx-X11/programs/Xserver/os/oscolor.c
new file mode 100644
index 000000000..ecb76ccd6
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/oscolor.c
@@ -0,0 +1,483 @@
+/* $XFree86: xc/programs/Xserver/os/oscolor.c,v 3.10 2003/07/16 01:39:03 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: oscolor.c,v 1.4 2001/02/09 02:05:23 xorgcvs Exp $ */
+
+#ifdef NX_TRANS_SOCKET
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+static char* nxAltRgbPaths[] = {"/usr/share/X11/rgb", "/etc/X11/rgb"};
+static char _NXRgbPath[1024];
+
+#endif
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef USE_RGB_TXT
+
+#ifdef NDBM
+#include <ndbm.h>
+#else
+#ifdef SVR4
+#include <rpcsvc/dbm.h>
+#else
+#include <dbm.h>
+#endif
+#endif
+#include "rgb.h"
+#include "os.h"
+#include "opaque.h"
+
+/* Note that we are assuming there is only one database for all the screens. */
+
+#ifdef NDBM
+DBM *rgb_dbm = (DBM *)NULL;
+#else
+int rgb_dbm = 0;
+#endif
+
+extern void CopyISOLatin1Lowered(
+ unsigned char * /*dest*/,
+ unsigned char * /*source*/,
+ int /*length*/);
+
+int
+OsInitColors(void)
+{
+ if (!rgb_dbm)
+ {
+#ifdef NDBM
+ rgb_dbm = dbm_open(rgbPath, 0, 0);
+#else
+ if (dbminit(rgbPath) == 0)
+ rgb_dbm = 1;
+#endif
+ if (!rgb_dbm) {
+ ErrorF( "Couldn't open RGB_DB '%s'\n", rgbPath );
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+/*ARGSUSED*/
+int
+OsLookupColor(int screen, char *name, unsigned int len,
+ unsigned short *pred, unsigned short *pgreen, unsigned short *pblue)
+{
+ datum dbent;
+ RGB rgb;
+ char buf[64];
+ char *lowername;
+
+ if(!rgb_dbm)
+ return(0);
+
+ /* we use xalloc here so that we can compile with cc without alloca
+ * when otherwise using gcc */
+ if (len < sizeof(buf))
+ lowername = buf;
+ else if (!(lowername = (char *)xalloc(len + 1)))
+ return(0);
+ CopyISOLatin1Lowered ((unsigned char *) lowername, (unsigned char *) name,
+ (int)len);
+
+ dbent.dptr = lowername;
+ dbent.dsize = len;
+#ifdef NDBM
+ dbent = dbm_fetch(rgb_dbm, dbent);
+#else
+ dbent = fetch (dbent);
+#endif
+
+ if (len >= sizeof(buf))
+ xfree(lowername);
+
+ if(dbent.dptr)
+ {
+ memmove((char *) &rgb, dbent.dptr, sizeof (RGB));
+ *pred = rgb.red;
+ *pgreen = rgb.green;
+ *pblue = rgb.blue;
+ return (1);
+ }
+ return(0);
+}
+
+#else /* USE_RGB_TXT */
+
+
+/*
+ * The dbm routines are a porting hassle. This implementation will do
+ * the same thing by reading the rgb.txt file directly, which is much
+ * more portable.
+ */
+
+#include <stdio.h>
+#include "os.h"
+#include "opaque.h"
+
+#define HASHSIZE 511
+
+typedef struct _dbEntry * dbEntryPtr;
+typedef struct _dbEntry {
+ dbEntryPtr link;
+ unsigned short red;
+ unsigned short green;
+ unsigned short blue;
+ char name[1]; /* some compilers complain if [0] */
+} dbEntry;
+
+
+extern void CopyISOLatin1Lowered(
+ unsigned char * /*dest*/,
+ unsigned char * /*source*/,
+ int /*length*/);
+
+static dbEntryPtr hashTab[HASHSIZE];
+
+#ifdef NX_TRANS_SOCKET
+
+static int NXVerifyRgbPath(char *path)
+{
+ int size;
+ char *rgbPath;
+ struct stat rgbFileStat;
+
+ /*
+ * Check if rgb file is present.
+ */
+
+ size = strlen(path) + strlen(".txt") + 1;
+
+ rgbPath = (char *) ALLOCATE_LOCAL(size + 1);
+
+ strcpy(rgbPath, path);
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "NXVerifyRgbPath: Looking for [%s] file.\n",
+ rgbPath);
+ #endif
+
+ if (stat(rgbPath, &rgbFileStat) != 0)
+ {
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "NXVerifyRgbPath: Can't find the rgb file [%s].\n",
+ rgbPath);
+ #endif
+
+ strcat(rgbPath, ".txt");
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "NXVerifyRgbPath: Looking for [%s] file.\n",
+ rgbPath);
+ #endif
+
+ if (stat(rgbPath, &rgbFileStat) != 0)
+ {
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "NXVerifyRgbPath: Can't find the rgb file [%s].\n",
+ rgbPath);
+ #endif
+
+ DEALLOCATE_LOCAL(rgbPath);
+
+ return 0;
+ }
+ }
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "NXVerifyRgbPath: rgb path [%s] is valid.\n",
+ path);
+ #endif
+
+ DEALLOCATE_LOCAL(rgbPath);
+
+ return 1;
+}
+
+static const char *_NXGetRgbPath(const char *path)
+{
+ const char *systemEnv;
+ char rgbPath[1024];
+ int numAltRgbPaths;
+ int i;
+
+ /*
+ * Check the environment only once.
+ */
+
+ if (*_NXRgbPath != '\0')
+ {
+ return _NXRgbPath;
+ }
+
+ systemEnv = getenv("NX_SYSTEM");
+
+ if (systemEnv != NULL && *systemEnv != '\0')
+ {
+ if (strlen(systemEnv) + strlen("/share/rgb") + 1 > 1024)
+ {
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetRgbPath: WARNING! Maximum length of rgb file path exceeded.\n");
+ #endif
+
+ goto _NXGetRgbPathError;
+ }
+
+ strcpy(rgbPath, systemEnv);
+ strcat(rgbPath, "/share/rgb");
+
+ if (NXVerifyRgbPath(rgbPath) == 1)
+ {
+ strcpy(_NXRgbPath, systemEnv);
+ strcat(_NXRgbPath, "/share/rgb");
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetRgbPath: Using rgb file path [%s].\n",
+ _NXRgbPath);
+ #endif
+
+ return _NXRgbPath;
+ }
+ }
+
+ numAltRgbPaths = sizeof(nxAltRgbPaths) / sizeof(*nxAltRgbPaths);
+
+ for (i = 0; i < numAltRgbPaths; i++)
+ {
+ if (NXVerifyRgbPath(nxAltRgbPaths[i]) == 1)
+ {
+ if (strlen(nxAltRgbPaths[i]) + 1 > 1024)
+ {
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetRgbPath: WARNING! Maximum length of rgb file path exceeded.\n");
+ #endif
+
+ goto _NXGetRgbPathError;
+ }
+
+ strcpy(_NXRgbPath, nxAltRgbPaths[i]);
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetRgbPath: Using rgb file path [%s].\n",
+ _NXRgbPath);
+ #endif
+
+ return _NXRgbPath;
+ }
+ }
+
+_NXGetRgbPathError:
+
+ strcpy(_NXRgbPath, path);
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetRgbPath: Using default rgb file path [%s].\n",
+ _NXRgbPath);
+ #endif
+
+ return _NXRgbPath;
+}
+
+#endif
+
+static dbEntryPtr
+lookup(char *name, int len, Bool create)
+{
+ unsigned int h = 0, g;
+ dbEntryPtr entry, *prev = NULL;
+ char *str = name;
+
+ if (!(name = (char*)ALLOCATE_LOCAL(len +1))) return NULL;
+ CopyISOLatin1Lowered((unsigned char *)name, (unsigned char *)str, len);
+ name[len] = '\0';
+
+ for(str = name; *str; str++) {
+ h = (h << 4) + *str;
+ if ((g = h) & 0xf0000000) h ^= (g >> 24);
+ h &= g;
+ }
+ h %= HASHSIZE;
+
+ if ( (entry = hashTab[h]) )
+ {
+ for( ; entry; prev = (dbEntryPtr*)entry, entry = entry->link )
+ if (! strcmp(name, entry->name) ) break;
+ }
+ else
+ prev = &(hashTab[h]);
+
+ if (!entry && create && (entry = (dbEntryPtr)xalloc(sizeof(dbEntry) +len)))
+ {
+ *prev = entry;
+ entry->link = NULL;
+ strcpy( entry->name, name );
+ }
+
+ DEALLOCATE_LOCAL(name);
+
+ return entry;
+}
+
+
+Bool
+OsInitColors(void)
+{
+ FILE *rgb;
+ char *path;
+ char line[BUFSIZ];
+ char name[BUFSIZ];
+ int red, green, blue, lineno = 0;
+ dbEntryPtr entry;
+
+ static Bool was_here = FALSE;
+
+ if (!was_here)
+ {
+#ifndef __UNIXOS2__
+#ifdef NX_TRANS_SOCKET
+ /*
+ * Add the trailing '.txt' if a
+ * 'rgb' file is not found.
+ */
+
+ struct stat statbuf;
+
+ path = (char*)ALLOCATE_LOCAL(strlen(_NXGetRgbPath(rgbPath)) + 5);
+ strcpy(path, _NXGetRgbPath(rgbPath));
+
+ if (stat(path, &statbuf) != 0)
+ {
+ strcat(path, ".txt");
+ }
+#else
+ path = (char*)ALLOCATE_LOCAL(strlen(rgbPath) +5);
+ strcpy(path, rgbPath);
+ strcat(path, ".txt");
+#endif
+#else
+ char *tmp = (char*)__XOS2RedirRoot(rgbPath);
+ path = (char*)ALLOCATE_LOCAL(strlen(tmp) +5);
+ strcpy(path, tmp);
+ strcat(path, ".txt");
+#endif
+ if (!(rgb = fopen(path, "r")))
+ {
+#ifdef NX_TRANS_SOCKET
+ ErrorF( "Couldn't open RGB_DB '%s'\n", _NXGetRgbPath(rgbPath));
+#else
+ ErrorF( "Couldn't open RGB_DB '%s'\n", rgbPath );
+#endif
+ DEALLOCATE_LOCAL(path);
+ return FALSE;
+ }
+
+ while(fgets(line, sizeof(line), rgb))
+ {
+ lineno++;
+#ifndef __UNIXOS2__
+ if (sscanf(line,"%d %d %d %[^\n]\n", &red, &green, &blue, name) == 4)
+#else
+ if (sscanf(line,"%d %d %d %[^\n\r]\n", &red, &green, &blue, name) == 4)
+#endif
+ {
+ if (red >= 0 && red <= 0xff &&
+ green >= 0 && green <= 0xff &&
+ blue >= 0 && blue <= 0xff)
+ {
+ if ((entry = lookup(name, strlen(name), TRUE)))
+ {
+ entry->red = (red * 65535) / 255;
+ entry->green = (green * 65535) / 255;
+ entry->blue = (blue * 65535) / 255;
+ }
+ }
+ else
+ ErrorF("Value out of range: %s:%d\n", path, lineno);
+ }
+ else if (*line && *line != '#' && *line != '!')
+ ErrorF("Syntax Error: %s:%d\n", path, lineno);
+ }
+
+ fclose(rgb);
+ DEALLOCATE_LOCAL(path);
+
+ was_here = TRUE;
+ }
+
+ return TRUE;
+}
+
+
+
+Bool
+OsLookupColor(int screen, char *name, unsigned int len,
+ unsigned short *pred, unsigned short *pgreen, unsigned short *pblue)
+{
+ dbEntryPtr entry;
+
+ if ((entry = lookup(name, len, FALSE)))
+ {
+ *pred = entry->red;
+ *pgreen = entry->green;
+ *pblue = entry->blue;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+#endif /* USE_RGB_TXT */
diff --git a/nx-X11/programs/Xserver/os/oscolor.c.NX.original b/nx-X11/programs/Xserver/os/oscolor.c.NX.original
new file mode 100644
index 000000000..ecb76ccd6
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/oscolor.c.NX.original
@@ -0,0 +1,483 @@
+/* $XFree86: xc/programs/Xserver/os/oscolor.c,v 3.10 2003/07/16 01:39:03 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: oscolor.c,v 1.4 2001/02/09 02:05:23 xorgcvs Exp $ */
+
+#ifdef NX_TRANS_SOCKET
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+static char* nxAltRgbPaths[] = {"/usr/share/X11/rgb", "/etc/X11/rgb"};
+static char _NXRgbPath[1024];
+
+#endif
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef USE_RGB_TXT
+
+#ifdef NDBM
+#include <ndbm.h>
+#else
+#ifdef SVR4
+#include <rpcsvc/dbm.h>
+#else
+#include <dbm.h>
+#endif
+#endif
+#include "rgb.h"
+#include "os.h"
+#include "opaque.h"
+
+/* Note that we are assuming there is only one database for all the screens. */
+
+#ifdef NDBM
+DBM *rgb_dbm = (DBM *)NULL;
+#else
+int rgb_dbm = 0;
+#endif
+
+extern void CopyISOLatin1Lowered(
+ unsigned char * /*dest*/,
+ unsigned char * /*source*/,
+ int /*length*/);
+
+int
+OsInitColors(void)
+{
+ if (!rgb_dbm)
+ {
+#ifdef NDBM
+ rgb_dbm = dbm_open(rgbPath, 0, 0);
+#else
+ if (dbminit(rgbPath) == 0)
+ rgb_dbm = 1;
+#endif
+ if (!rgb_dbm) {
+ ErrorF( "Couldn't open RGB_DB '%s'\n", rgbPath );
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+/*ARGSUSED*/
+int
+OsLookupColor(int screen, char *name, unsigned int len,
+ unsigned short *pred, unsigned short *pgreen, unsigned short *pblue)
+{
+ datum dbent;
+ RGB rgb;
+ char buf[64];
+ char *lowername;
+
+ if(!rgb_dbm)
+ return(0);
+
+ /* we use xalloc here so that we can compile with cc without alloca
+ * when otherwise using gcc */
+ if (len < sizeof(buf))
+ lowername = buf;
+ else if (!(lowername = (char *)xalloc(len + 1)))
+ return(0);
+ CopyISOLatin1Lowered ((unsigned char *) lowername, (unsigned char *) name,
+ (int)len);
+
+ dbent.dptr = lowername;
+ dbent.dsize = len;
+#ifdef NDBM
+ dbent = dbm_fetch(rgb_dbm, dbent);
+#else
+ dbent = fetch (dbent);
+#endif
+
+ if (len >= sizeof(buf))
+ xfree(lowername);
+
+ if(dbent.dptr)
+ {
+ memmove((char *) &rgb, dbent.dptr, sizeof (RGB));
+ *pred = rgb.red;
+ *pgreen = rgb.green;
+ *pblue = rgb.blue;
+ return (1);
+ }
+ return(0);
+}
+
+#else /* USE_RGB_TXT */
+
+
+/*
+ * The dbm routines are a porting hassle. This implementation will do
+ * the same thing by reading the rgb.txt file directly, which is much
+ * more portable.
+ */
+
+#include <stdio.h>
+#include "os.h"
+#include "opaque.h"
+
+#define HASHSIZE 511
+
+typedef struct _dbEntry * dbEntryPtr;
+typedef struct _dbEntry {
+ dbEntryPtr link;
+ unsigned short red;
+ unsigned short green;
+ unsigned short blue;
+ char name[1]; /* some compilers complain if [0] */
+} dbEntry;
+
+
+extern void CopyISOLatin1Lowered(
+ unsigned char * /*dest*/,
+ unsigned char * /*source*/,
+ int /*length*/);
+
+static dbEntryPtr hashTab[HASHSIZE];
+
+#ifdef NX_TRANS_SOCKET
+
+static int NXVerifyRgbPath(char *path)
+{
+ int size;
+ char *rgbPath;
+ struct stat rgbFileStat;
+
+ /*
+ * Check if rgb file is present.
+ */
+
+ size = strlen(path) + strlen(".txt") + 1;
+
+ rgbPath = (char *) ALLOCATE_LOCAL(size + 1);
+
+ strcpy(rgbPath, path);
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "NXVerifyRgbPath: Looking for [%s] file.\n",
+ rgbPath);
+ #endif
+
+ if (stat(rgbPath, &rgbFileStat) != 0)
+ {
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "NXVerifyRgbPath: Can't find the rgb file [%s].\n",
+ rgbPath);
+ #endif
+
+ strcat(rgbPath, ".txt");
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "NXVerifyRgbPath: Looking for [%s] file.\n",
+ rgbPath);
+ #endif
+
+ if (stat(rgbPath, &rgbFileStat) != 0)
+ {
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "NXVerifyRgbPath: Can't find the rgb file [%s].\n",
+ rgbPath);
+ #endif
+
+ DEALLOCATE_LOCAL(rgbPath);
+
+ return 0;
+ }
+ }
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "NXVerifyRgbPath: rgb path [%s] is valid.\n",
+ path);
+ #endif
+
+ DEALLOCATE_LOCAL(rgbPath);
+
+ return 1;
+}
+
+static const char *_NXGetRgbPath(const char *path)
+{
+ const char *systemEnv;
+ char rgbPath[1024];
+ int numAltRgbPaths;
+ int i;
+
+ /*
+ * Check the environment only once.
+ */
+
+ if (*_NXRgbPath != '\0')
+ {
+ return _NXRgbPath;
+ }
+
+ systemEnv = getenv("NX_SYSTEM");
+
+ if (systemEnv != NULL && *systemEnv != '\0')
+ {
+ if (strlen(systemEnv) + strlen("/share/rgb") + 1 > 1024)
+ {
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetRgbPath: WARNING! Maximum length of rgb file path exceeded.\n");
+ #endif
+
+ goto _NXGetRgbPathError;
+ }
+
+ strcpy(rgbPath, systemEnv);
+ strcat(rgbPath, "/share/rgb");
+
+ if (NXVerifyRgbPath(rgbPath) == 1)
+ {
+ strcpy(_NXRgbPath, systemEnv);
+ strcat(_NXRgbPath, "/share/rgb");
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetRgbPath: Using rgb file path [%s].\n",
+ _NXRgbPath);
+ #endif
+
+ return _NXRgbPath;
+ }
+ }
+
+ numAltRgbPaths = sizeof(nxAltRgbPaths) / sizeof(*nxAltRgbPaths);
+
+ for (i = 0; i < numAltRgbPaths; i++)
+ {
+ if (NXVerifyRgbPath(nxAltRgbPaths[i]) == 1)
+ {
+ if (strlen(nxAltRgbPaths[i]) + 1 > 1024)
+ {
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetRgbPath: WARNING! Maximum length of rgb file path exceeded.\n");
+ #endif
+
+ goto _NXGetRgbPathError;
+ }
+
+ strcpy(_NXRgbPath, nxAltRgbPaths[i]);
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetRgbPath: Using rgb file path [%s].\n",
+ _NXRgbPath);
+ #endif
+
+ return _NXRgbPath;
+ }
+ }
+
+_NXGetRgbPathError:
+
+ strcpy(_NXRgbPath, path);
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "_NXGetRgbPath: Using default rgb file path [%s].\n",
+ _NXRgbPath);
+ #endif
+
+ return _NXRgbPath;
+}
+
+#endif
+
+static dbEntryPtr
+lookup(char *name, int len, Bool create)
+{
+ unsigned int h = 0, g;
+ dbEntryPtr entry, *prev = NULL;
+ char *str = name;
+
+ if (!(name = (char*)ALLOCATE_LOCAL(len +1))) return NULL;
+ CopyISOLatin1Lowered((unsigned char *)name, (unsigned char *)str, len);
+ name[len] = '\0';
+
+ for(str = name; *str; str++) {
+ h = (h << 4) + *str;
+ if ((g = h) & 0xf0000000) h ^= (g >> 24);
+ h &= g;
+ }
+ h %= HASHSIZE;
+
+ if ( (entry = hashTab[h]) )
+ {
+ for( ; entry; prev = (dbEntryPtr*)entry, entry = entry->link )
+ if (! strcmp(name, entry->name) ) break;
+ }
+ else
+ prev = &(hashTab[h]);
+
+ if (!entry && create && (entry = (dbEntryPtr)xalloc(sizeof(dbEntry) +len)))
+ {
+ *prev = entry;
+ entry->link = NULL;
+ strcpy( entry->name, name );
+ }
+
+ DEALLOCATE_LOCAL(name);
+
+ return entry;
+}
+
+
+Bool
+OsInitColors(void)
+{
+ FILE *rgb;
+ char *path;
+ char line[BUFSIZ];
+ char name[BUFSIZ];
+ int red, green, blue, lineno = 0;
+ dbEntryPtr entry;
+
+ static Bool was_here = FALSE;
+
+ if (!was_here)
+ {
+#ifndef __UNIXOS2__
+#ifdef NX_TRANS_SOCKET
+ /*
+ * Add the trailing '.txt' if a
+ * 'rgb' file is not found.
+ */
+
+ struct stat statbuf;
+
+ path = (char*)ALLOCATE_LOCAL(strlen(_NXGetRgbPath(rgbPath)) + 5);
+ strcpy(path, _NXGetRgbPath(rgbPath));
+
+ if (stat(path, &statbuf) != 0)
+ {
+ strcat(path, ".txt");
+ }
+#else
+ path = (char*)ALLOCATE_LOCAL(strlen(rgbPath) +5);
+ strcpy(path, rgbPath);
+ strcat(path, ".txt");
+#endif
+#else
+ char *tmp = (char*)__XOS2RedirRoot(rgbPath);
+ path = (char*)ALLOCATE_LOCAL(strlen(tmp) +5);
+ strcpy(path, tmp);
+ strcat(path, ".txt");
+#endif
+ if (!(rgb = fopen(path, "r")))
+ {
+#ifdef NX_TRANS_SOCKET
+ ErrorF( "Couldn't open RGB_DB '%s'\n", _NXGetRgbPath(rgbPath));
+#else
+ ErrorF( "Couldn't open RGB_DB '%s'\n", rgbPath );
+#endif
+ DEALLOCATE_LOCAL(path);
+ return FALSE;
+ }
+
+ while(fgets(line, sizeof(line), rgb))
+ {
+ lineno++;
+#ifndef __UNIXOS2__
+ if (sscanf(line,"%d %d %d %[^\n]\n", &red, &green, &blue, name) == 4)
+#else
+ if (sscanf(line,"%d %d %d %[^\n\r]\n", &red, &green, &blue, name) == 4)
+#endif
+ {
+ if (red >= 0 && red <= 0xff &&
+ green >= 0 && green <= 0xff &&
+ blue >= 0 && blue <= 0xff)
+ {
+ if ((entry = lookup(name, strlen(name), TRUE)))
+ {
+ entry->red = (red * 65535) / 255;
+ entry->green = (green * 65535) / 255;
+ entry->blue = (blue * 65535) / 255;
+ }
+ }
+ else
+ ErrorF("Value out of range: %s:%d\n", path, lineno);
+ }
+ else if (*line && *line != '#' && *line != '!')
+ ErrorF("Syntax Error: %s:%d\n", path, lineno);
+ }
+
+ fclose(rgb);
+ DEALLOCATE_LOCAL(path);
+
+ was_here = TRUE;
+ }
+
+ return TRUE;
+}
+
+
+
+Bool
+OsLookupColor(int screen, char *name, unsigned int len,
+ unsigned short *pred, unsigned short *pgreen, unsigned short *pblue)
+{
+ dbEntryPtr entry;
+
+ if ((entry = lookup(name, len, FALSE)))
+ {
+ *pred = entry->red;
+ *pgreen = entry->green;
+ *pblue = entry->blue;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+#endif /* USE_RGB_TXT */
diff --git a/nx-X11/programs/Xserver/os/oscolor.c.X.original b/nx-X11/programs/Xserver/os/oscolor.c.X.original
new file mode 100644
index 000000000..fdbde7906
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/oscolor.c.X.original
@@ -0,0 +1,303 @@
+/* $XFree86: xc/programs/Xserver/os/oscolor.c,v 3.10 2003/07/16 01:39:03 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: oscolor.c,v 1.4 2001/02/09 02:05:23 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef USE_RGB_TXT
+
+#ifdef NDBM
+#include <ndbm.h>
+#else
+#ifdef SVR4
+#include <rpcsvc/dbm.h>
+#else
+#include <dbm.h>
+#endif
+#endif
+#include "rgb.h"
+#include "os.h"
+#include "opaque.h"
+
+/* Note that we are assuming there is only one database for all the screens. */
+
+#ifdef NDBM
+DBM *rgb_dbm = (DBM *)NULL;
+#else
+int rgb_dbm = 0;
+#endif
+
+extern void CopyISOLatin1Lowered(
+ unsigned char * /*dest*/,
+ unsigned char * /*source*/,
+ int /*length*/);
+
+int
+OsInitColors(void)
+{
+ if (!rgb_dbm)
+ {
+#ifdef NDBM
+ rgb_dbm = dbm_open(rgbPath, 0, 0);
+#else
+ if (dbminit(rgbPath) == 0)
+ rgb_dbm = 1;
+#endif
+ if (!rgb_dbm) {
+ ErrorF( "Couldn't open RGB_DB '%s'\n", rgbPath );
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+/*ARGSUSED*/
+int
+OsLookupColor(int screen, char *name, unsigned int len,
+ unsigned short *pred, unsigned short *pgreen, unsigned short *pblue)
+{
+ datum dbent;
+ RGB rgb;
+ char buf[64];
+ char *lowername;
+
+ if(!rgb_dbm)
+ return(0);
+
+ /* we use xalloc here so that we can compile with cc without alloca
+ * when otherwise using gcc */
+ if (len < sizeof(buf))
+ lowername = buf;
+ else if (!(lowername = (char *)xalloc(len + 1)))
+ return(0);
+ CopyISOLatin1Lowered ((unsigned char *) lowername, (unsigned char *) name,
+ (int)len);
+
+ dbent.dptr = lowername;
+ dbent.dsize = len;
+#ifdef NDBM
+ dbent = dbm_fetch(rgb_dbm, dbent);
+#else
+ dbent = fetch (dbent);
+#endif
+
+ if (len >= sizeof(buf))
+ xfree(lowername);
+
+ if(dbent.dptr)
+ {
+ memmove((char *) &rgb, dbent.dptr, sizeof (RGB));
+ *pred = rgb.red;
+ *pgreen = rgb.green;
+ *pblue = rgb.blue;
+ return (1);
+ }
+ return(0);
+}
+
+#else /* USE_RGB_TXT */
+
+
+/*
+ * The dbm routines are a porting hassle. This implementation will do
+ * the same thing by reading the rgb.txt file directly, which is much
+ * more portable.
+ */
+
+#include <stdio.h>
+#include "os.h"
+#include "opaque.h"
+
+#define HASHSIZE 511
+
+typedef struct _dbEntry * dbEntryPtr;
+typedef struct _dbEntry {
+ dbEntryPtr link;
+ unsigned short red;
+ unsigned short green;
+ unsigned short blue;
+ char name[1]; /* some compilers complain if [0] */
+} dbEntry;
+
+
+extern void CopyISOLatin1Lowered(
+ unsigned char * /*dest*/,
+ unsigned char * /*source*/,
+ int /*length*/);
+
+static dbEntryPtr hashTab[HASHSIZE];
+
+
+static dbEntryPtr
+lookup(char *name, int len, Bool create)
+{
+ unsigned int h = 0, g;
+ dbEntryPtr entry, *prev = NULL;
+ char *str = name;
+
+ if (!(name = (char*)ALLOCATE_LOCAL(len +1))) return NULL;
+ CopyISOLatin1Lowered((unsigned char *)name, (unsigned char *)str, len);
+ name[len] = '\0';
+
+ for(str = name; *str; str++) {
+ h = (h << 4) + *str;
+ if ((g = h) & 0xf0000000) h ^= (g >> 24);
+ h &= g;
+ }
+ h %= HASHSIZE;
+
+ if ( (entry = hashTab[h]) )
+ {
+ for( ; entry; prev = (dbEntryPtr*)entry, entry = entry->link )
+ if (! strcmp(name, entry->name) ) break;
+ }
+ else
+ prev = &(hashTab[h]);
+
+ if (!entry && create && (entry = (dbEntryPtr)xalloc(sizeof(dbEntry) +len)))
+ {
+ *prev = entry;
+ entry->link = NULL;
+ strcpy( entry->name, name );
+ }
+
+ DEALLOCATE_LOCAL(name);
+
+ return entry;
+}
+
+
+Bool
+OsInitColors(void)
+{
+ FILE *rgb;
+ char *path;
+ char line[BUFSIZ];
+ char name[BUFSIZ];
+ int red, green, blue, lineno = 0;
+ dbEntryPtr entry;
+
+ static Bool was_here = FALSE;
+
+ if (!was_here)
+ {
+#ifndef __UNIXOS2__
+ path = (char*)ALLOCATE_LOCAL(strlen(rgbPath) +5);
+ strcpy(path, rgbPath);
+ strcat(path, ".txt");
+#else
+ char *tmp = (char*)__XOS2RedirRoot(rgbPath);
+ path = (char*)ALLOCATE_LOCAL(strlen(tmp) +5);
+ strcpy(path, tmp);
+ strcat(path, ".txt");
+#endif
+ if (!(rgb = fopen(path, "r")))
+ {
+ ErrorF( "Couldn't open RGB_DB '%s'\n", rgbPath );
+ DEALLOCATE_LOCAL(path);
+ return FALSE;
+ }
+
+ while(fgets(line, sizeof(line), rgb))
+ {
+ lineno++;
+#ifndef __UNIXOS2__
+ if (sscanf(line,"%d %d %d %[^\n]\n", &red, &green, &blue, name) == 4)
+#else
+ if (sscanf(line,"%d %d %d %[^\n\r]\n", &red, &green, &blue, name) == 4)
+#endif
+ {
+ if (red >= 0 && red <= 0xff &&
+ green >= 0 && green <= 0xff &&
+ blue >= 0 && blue <= 0xff)
+ {
+ if ((entry = lookup(name, strlen(name), TRUE)))
+ {
+ entry->red = (red * 65535) / 255;
+ entry->green = (green * 65535) / 255;
+ entry->blue = (blue * 65535) / 255;
+ }
+ }
+ else
+ ErrorF("Value out of range: %s:%d\n", path, lineno);
+ }
+ else if (*line && *line != '#' && *line != '!')
+ ErrorF("Syntax Error: %s:%d\n", path, lineno);
+ }
+
+ fclose(rgb);
+ DEALLOCATE_LOCAL(path);
+
+ was_here = TRUE;
+ }
+
+ return TRUE;
+}
+
+
+
+Bool
+OsLookupColor(int screen, char *name, unsigned int len,
+ unsigned short *pred, unsigned short *pgreen, unsigned short *pblue)
+{
+ dbEntryPtr entry;
+
+ if ((entry = lookup(name, len, FALSE)))
+ {
+ *pred = entry->red;
+ *pgreen = entry->green;
+ *pblue = entry->blue;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+#endif /* USE_RGB_TXT */
diff --git a/nx-X11/programs/Xserver/os/osdep.h b/nx-X11/programs/Xserver/os/osdep.h
new file mode 100644
index 000000000..b837d7605
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/osdep.h
@@ -0,0 +1,358 @@
+/* $XFree86: xc/programs/Xserver/os/osdep.h,v 3.17 2002/05/31 18:46:06 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: osdep.h,v 1.5 2001/02/09 02:05:23 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _OSDEP_H_
+#define _OSDEP_H_ 1
+
+#define BOTIMEOUT 200 /* in milliseconds */
+#define BUFSIZE 4096
+#define BUFWATERMARK 8192
+#ifndef MAXBUFSIZE
+#define MAXBUFSIZE (1 << 22)
+#endif
+
+#include <X11/Xdmcp.h>
+
+#ifndef sgi /* SGI defines OPEN_MAX in a useless way */
+#ifndef X_NOT_POSIX
+#ifdef _POSIX_SOURCE
+#include <limits.h>
+#else
+#define _POSIX_SOURCE
+#include <limits.h>
+#undef _POSIX_SOURCE
+#endif
+#else /* X_NOT_POSIX */
+#ifdef WIN32
+#define _POSIX_
+#include <limits.h>
+#undef _POSIX_
+#endif
+#endif /* X_NOT_POSIX */
+#endif
+
+#ifdef __QNX__
+#define NOFILES_MAX 256
+#endif
+#ifndef OPEN_MAX
+#ifdef SVR4
+#define OPEN_MAX 256
+#else
+#include <sys/param.h>
+#ifndef OPEN_MAX
+#if defined(NOFILE) && !defined(NOFILES_MAX)
+#define OPEN_MAX NOFILE
+#else
+#if !defined(__UNIXOS2__) && !defined(WIN32)
+#define OPEN_MAX NOFILES_MAX
+#else
+#define OPEN_MAX 256
+#endif
+#endif
+#endif
+#endif
+#endif
+
+#include <X11/Xpoll.h>
+
+/*
+ * MAXSOCKS is used only for initialising MaxClients when no other method
+ * like sysconf(_SC_OPEN_MAX) is not supported.
+ */
+
+#if OPEN_MAX <= 256
+#define MAXSOCKS (OPEN_MAX - 1)
+#else
+#define MAXSOCKS 256
+#endif
+
+/* MAXSELECT is the number of fds that select() can handle */
+#define MAXSELECT (sizeof(fd_set) * NBBY)
+
+#if !defined(hpux) && !defined(SVR4) && !defined(SYSV)
+#define HAS_GETDTABLESIZE
+#endif
+
+#include <stddef.h>
+
+typedef Bool (*ValidatorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
+typedef Bool (*GeneratorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
+typedef Bool (*AddAuthorFunc)(unsigned name_length, char *name, unsigned data_length, char *data);
+
+typedef struct _connectionInput {
+ struct _connectionInput *next;
+ char *buffer; /* contains current client input */
+ char *bufptr; /* pointer to current start of data */
+ int bufcnt; /* count of bytes in buffer */
+ int lenLastReq;
+ int size;
+} ConnectionInput, *ConnectionInputPtr;
+
+typedef struct _connectionOutput {
+ struct _connectionOutput *next;
+ int size;
+ unsigned char *buf;
+ int count;
+#ifdef LBX
+ Bool nocompress;
+#endif
+} ConnectionOutput, *ConnectionOutputPtr;
+
+#ifdef K5AUTH
+typedef struct _k5_state {
+ int stageno; /* current stage of auth protocol */
+ pointer srvcreds; /* server credentials */
+ pointer srvname; /* server principal name */
+ pointer ktname; /* key table: principal-key pairs */
+ pointer skey; /* session key */
+} k5_state;
+#endif
+
+#ifdef LBX
+typedef struct _LbxProxy *OsProxyPtr;
+#endif
+
+struct _osComm;
+
+#define AuthInitArgs void
+typedef void (*AuthInitFunc) (AuthInitArgs);
+
+#define AuthAddCArgs unsigned short data_length, char *data, XID id
+typedef int (*AuthAddCFunc) (AuthAddCArgs);
+
+#define AuthCheckArgs unsigned short data_length, char *data, ClientPtr client, char **reason
+typedef XID (*AuthCheckFunc) (AuthCheckArgs);
+
+#define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap
+typedef int (*AuthFromIDFunc) (AuthFromIDArgs);
+
+#define AuthGenCArgs unsigned data_length, char *data, XID id, unsigned *data_length_return, char **data_return
+typedef XID (*AuthGenCFunc) (AuthGenCArgs);
+
+#define AuthRemCArgs unsigned short data_length, char *data
+typedef int (*AuthRemCFunc) (AuthRemCArgs);
+
+#define AuthRstCArgs void
+typedef int (*AuthRstCFunc) (AuthRstCArgs);
+
+#define AuthToIDArgs unsigned short data_length, char *data
+typedef XID (*AuthToIDFunc) (AuthToIDArgs);
+
+typedef void (*OsCloseFunc)(ClientPtr);
+
+typedef int (*OsFlushFunc)(ClientPtr who, struct _osComm * oc, char* extraBuf, int extraCount);
+
+typedef struct _osComm {
+ int fd;
+ ConnectionInputPtr input;
+ ConnectionOutputPtr output;
+ XID auth_id; /* authorization id */
+#ifdef K5AUTH
+ k5_state authstate; /* state of setup auth conversation */
+#endif
+ CARD32 conn_time; /* timestamp if not established, else 0 */
+ struct _XtransConnInfo *trans_conn; /* transport connection object */
+#ifdef LBX
+ OsProxyPtr proxy;
+ ConnectionInputPtr largereq;
+ OsCloseFunc Close;
+ OsFlushFunc Flush;
+#endif
+} OsCommRec, *OsCommPtr;
+
+#ifdef LBX
+#define FlushClient(who, oc, extraBuf, extraCount) \
+ (*(oc)->Flush)(who, oc, extraBuf, extraCount)
+extern int StandardFlushClient(
+ ClientPtr /*who*/,
+ OsCommPtr /*oc*/,
+ char* /*extraBuf*/,
+ int /*extraCount*/
+);
+extern int LbxFlushClient(ClientPtr /*who*/, OsCommPtr /*oc*/,
+ char * /*extraBuf*/, int /*extraCount*/);
+#else
+extern int FlushClient(
+ ClientPtr /*who*/,
+ OsCommPtr /*oc*/,
+ char* /*extraBuf*/,
+ int /*extraCount*/
+);
+#endif
+
+extern void FreeOsBuffers(
+ OsCommPtr /*oc*/
+);
+
+#include "dix.h"
+
+extern ConnectionInputPtr AllocateInputBuffer(void);
+
+extern ConnectionOutputPtr AllocateOutputBuffer(void);
+
+extern fd_set AllSockets;
+extern fd_set AllClients;
+extern fd_set LastSelectMask;
+extern fd_set WellKnownConnections;
+extern fd_set EnabledDevices;
+extern fd_set ClientsWithInput;
+extern fd_set ClientsWriteBlocked;
+extern fd_set OutputPending;
+extern fd_set IgnoredClientsWithInput;
+
+#ifndef WIN32
+extern int *ConnectionTranslation;
+#else
+extern int GetConnectionTranslation(int conn);
+extern void SetConnectionTranslation(int conn, int client);
+extern void ClearConnectionTranslation();
+#endif
+
+extern Bool NewOutputPending;
+extern Bool AnyClientsWriteBlocked;
+extern Bool CriticalOutputPending;
+
+extern int timesThisConnection;
+extern ConnectionInputPtr FreeInputs;
+extern ConnectionOutputPtr FreeOutputs;
+extern OsCommPtr AvailableInput;
+
+extern WorkQueuePtr workQueue;
+
+/* added by raphael */
+#ifdef WIN32
+typedef long int fd_mask;
+#endif
+#define ffs mffs
+extern int mffs(fd_mask);
+
+/* in auth.c */
+extern void GenerateRandomData (int len, char *buf);
+
+/* in mitauth.c */
+extern XID MitCheckCookie (AuthCheckArgs);
+extern XID MitGenerateCookie (AuthGenCArgs);
+extern XID MitToID (AuthToIDArgs);
+extern int MitAddCookie (AuthAddCArgs);
+extern int MitFromID (AuthFromIDArgs);
+extern int MitRemoveCookie (AuthRemCArgs);
+extern int MitResetCookie (AuthRstCArgs);
+
+/* in xdmauth.c */
+#ifdef HASXDMAUTH
+extern XID XdmCheckCookie (AuthCheckArgs);
+extern XID XdmToID (AuthToIDArgs);
+extern int XdmAddCookie (AuthAddCArgs);
+extern int XdmFromID (AuthFromIDArgs);
+extern int XdmRemoveCookie (AuthRemCArgs);
+extern int XdmResetCookie (AuthRstCArgs);
+#endif
+
+/* in rpcauth.c */
+#ifdef SECURE_RPC
+extern void SecureRPCInit (AuthInitArgs);
+extern XID SecureRPCCheck (AuthCheckArgs);
+extern XID SecureRPCToID (AuthToIDArgs);
+extern int SecureRPCAdd (AuthAddCArgs);
+extern int SecureRPCFromID (AuthFromIDArgs);
+extern int SecureRPCRemove (AuthRemCArgs);
+extern int SecureRPCReset (AuthRstCArgs);
+#endif
+
+/* in k5auth.c */
+#ifdef K5AUTH
+extern XID K5Check (AuthCheckArgs);
+extern XID K5ToID (AuthToIDArgs);
+extern int K5Add (AuthAddCArgs);
+extern int K5FromID (AuthFromIDArgs);
+extern int K5Remove (AuthRemCArgs);
+extern int K5Reset (AuthRstCArgs);
+#endif
+
+/* in secauth.c */
+extern XID AuthSecurityCheck (AuthCheckArgs);
+
+/* in xdmcp.c */
+extern void XdmcpUseMsg (void);
+extern int XdmcpOptions(int argc, char **argv, int i);
+extern void XdmcpSetAuthentication (ARRAY8Ptr name);
+extern void XdmcpRegisterConnection (
+ int type,
+ char *address,
+ int addrlen);
+extern void XdmcpRegisterAuthorizations (void);
+extern void XdmcpRegisterAuthorization (char *name, int namelen);
+extern void XdmcpRegisterDisplayClass (char *name, int length);
+extern void XdmcpInit (void);
+extern void XdmcpReset (void);
+extern void XdmcpOpenDisplay(int sock);
+extern void XdmcpCloseDisplay(int sock);
+extern void XdmcpRegisterAuthentication (
+ char *name,
+ int namelen,
+ char *data,
+ int datalen,
+ ValidatorFunc Validator,
+ GeneratorFunc Generator,
+ AddAuthorFunc AddAuth);
+extern int XdmcpCheckAuthentication (ARRAY8Ptr Name, ARRAY8Ptr Data, int packet_type);
+extern int XdmcpAddAuthorization (ARRAY8Ptr name, ARRAY8Ptr data);
+
+struct sockaddr_in;
+extern void XdmcpRegisterBroadcastAddress (struct sockaddr_in *addr);
+
+#ifdef HASXDMAUTH
+extern void XdmAuthenticationInit (char *cookie, int cookie_length);
+#endif
+
+#endif /* _OSDEP_H_ */
diff --git a/nx-X11/programs/Xserver/os/osinit.c b/nx-X11/programs/Xserver/os/osinit.c
new file mode 100644
index 000000000..ea99ace21
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/osinit.c
@@ -0,0 +1,246 @@
+/* $XFree86: xc/programs/Xserver/os/osinit.c,v 3.29 2003/09/09 03:20:41 dawes Exp $ */
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+/* $Xorg: osinit.c,v 1.4 2001/02/09 02:05:23 xorgcvs Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <X11/X.h>
+#include "os.h"
+#include "osdep.h"
+#include <X11/Xos.h>
+
+#ifdef SMART_SCHEDULE
+#include "dixstruct.h"
+#endif
+
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+
+#if defined(Lynx) || defined(__SCO__)
+#include <sys/wait.h>
+#endif
+
+#if !defined(SYSV) && !defined(WIN32) && !defined(Lynx) && !defined(QNX4)
+#include <sys/resource.h>
+#endif
+
+#ifndef ADMPATH
+#define ADMPATH "/usr/adm/X%smsgs"
+#endif
+
+extern char *display;
+#ifdef RLIMIT_DATA
+int limitDataSpace = -1;
+#endif
+#ifdef RLIMIT_STACK
+int limitStackSpace = -1;
+#endif
+#ifdef RLIMIT_NOFILE
+int limitNoFile = -1;
+#endif
+
+Bool OsDelayInitColors = FALSE;
+
+#ifdef XFree86LOADER
+extern void xf86WrapperInit(void);
+#endif
+
+void
+OsInit(void)
+{
+ static Bool been_here = FALSE;
+ static char* admpath = ADMPATH;
+ static char* devnull = "/dev/null";
+ char fname[PATH_MAX];
+
+#ifdef macII
+ set42sig();
+#endif
+
+ if (!been_here) {
+#ifdef XFree86LOADER
+ xf86WrapperInit();
+#endif
+#if !defined(__SCO__) && !defined(__CYGWIN__) && !defined(__UNIXWARE__)
+ fclose(stdin);
+ fclose(stdout);
+#endif
+ /*
+ * If a write of zero bytes to stderr returns non-zero, i.e. -1,
+ * then writing to stderr failed, and we'll write somewhere else
+ * instead. (Apparently this never happens in the Real World.)
+ */
+ if (write (2, fname, 0) == -1)
+ {
+ FILE *err;
+
+ if (strlen (display) + strlen (admpath) + 1 < sizeof fname)
+ sprintf (fname, admpath, display);
+ else
+ strcpy (fname, devnull);
+ /*
+ * uses stdio to avoid os dependencies here,
+ * a real os would use
+ * open (fname, O_WRONLY|O_APPEND|O_CREAT, 0666)
+ */
+ if (!(err = fopen (fname, "a+")))
+ err = fopen (devnull, "w");
+ if (err && (fileno(err) != 2)) {
+ dup2 (fileno (err), 2);
+ fclose (err);
+ }
+#if defined(SYSV) || defined(SVR4) || defined(__UNIXOS2__) || defined(WIN32) || defined(__CYGWIN__)
+ {
+ static char buf[BUFSIZ];
+ setvbuf (stderr, buf, _IOLBF, BUFSIZ);
+ }
+#else
+ setlinebuf(stderr);
+#endif
+ }
+
+#ifndef X_NOT_POSIX
+ if (getpgrp () == 0)
+ setpgid (0, 0);
+#else
+#if !defined(SYSV) && !defined(WIN32)
+ if (getpgrp (0) == 0)
+ setpgrp (0, getpid ());
+#endif
+#endif
+
+#ifdef RLIMIT_DATA
+ if (limitDataSpace >= 0)
+ {
+ struct rlimit rlim;
+
+ if (!getrlimit(RLIMIT_DATA, &rlim))
+ {
+ if ((limitDataSpace > 0) && (limitDataSpace < rlim.rlim_max))
+ rlim.rlim_cur = limitDataSpace;
+ else
+ rlim.rlim_cur = rlim.rlim_max;
+ (void)setrlimit(RLIMIT_DATA, &rlim);
+ }
+ }
+#endif
+#ifdef RLIMIT_STACK
+ if (limitStackSpace >= 0)
+ {
+ struct rlimit rlim;
+
+ if (!getrlimit(RLIMIT_STACK, &rlim))
+ {
+ if ((limitStackSpace > 0) && (limitStackSpace < rlim.rlim_max))
+ rlim.rlim_cur = limitStackSpace;
+ else
+ rlim.rlim_cur = rlim.rlim_max;
+ (void)setrlimit(RLIMIT_STACK, &rlim);
+ }
+ }
+#endif
+#ifdef RLIMIT_NOFILE
+ if (limitNoFile >= 0)
+ {
+ struct rlimit rlim;
+
+ if (!getrlimit(RLIMIT_NOFILE, &rlim))
+ {
+ if ((limitNoFile > 0) && (limitNoFile < rlim.rlim_max))
+ rlim.rlim_cur = limitNoFile;
+ else
+ rlim.rlim_cur = rlim.rlim_max;
+#if 0
+ if (rlim.rlim_cur > MAXSOCKS)
+ rlim.rlim_cur = MAXSOCKS;
+#endif
+ (void)setrlimit(RLIMIT_NOFILE, &rlim);
+ }
+ }
+#endif
+#ifdef SERVER_LOCK
+ LockServer();
+#endif
+ been_here = TRUE;
+ }
+ TimerInit();
+#ifdef DDXOSINIT
+ OsVendorInit();
+#endif
+ /*
+ * No log file by default. OsVendorInit() should call LogInit() with the
+ * log file name if logging to a file is desired.
+ */
+ LogInit(NULL, NULL);
+#ifdef SMART_SCHEDULE
+ if (!SmartScheduleDisable)
+ if (!SmartScheduleInit ())
+ SmartScheduleDisable = TRUE;
+#endif
+ OsInitAllocator();
+ if (!OsDelayInitColors) OsInitColors();
+}
+
+void
+OsCleanup(Bool terminating)
+{
+#ifdef SERVER_LOCK
+ if (terminating)
+ {
+ UnlockServer();
+ }
+#endif
+}
diff --git a/nx-X11/programs/Xserver/os/rpcauth.c b/nx-X11/programs/Xserver/os/rpcauth.c
new file mode 100644
index 000000000..3c5cb5946
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/rpcauth.c
@@ -0,0 +1,204 @@
+/* $Xorg: rpcauth.c,v 1.4 2001/02/09 02:05:23 xorgcvs Exp $ */
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/os/rpcauth.c,v 3.7 2001/12/14 20:00:35 dawes Exp $ */
+
+/*
+ * SUN-DES-1 authentication mechanism
+ * Author: Mayank Choudhary, Sun Microsystems
+ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef SECURE_RPC
+
+#include <X11/X.h>
+#include "Xauth.h"
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+
+#include <rpc/rpc.h>
+
+#ifdef sun
+/* <rpc/auth.h> only includes this if _KERNEL is #defined... */
+extern bool_t xdr_opaque_auth(XDR *, struct opaque_auth *);
+#endif
+
+#if defined(DGUX)
+#include <time.h>
+#include <rpc/auth_des.h>
+#endif /* DGUX */
+
+#ifdef ultrix
+#include <time.h>
+#include <rpc/auth_des.h>
+#endif
+
+static enum auth_stat why;
+
+static char *
+authdes_ezdecode(char *inmsg, int len)
+{
+ struct rpc_msg msg;
+ char cred_area[MAX_AUTH_BYTES];
+ char verf_area[MAX_AUTH_BYTES];
+ char *temp_inmsg;
+ struct svc_req r;
+ bool_t res0, res1;
+ XDR xdr;
+ SVCXPRT xprt;
+
+ temp_inmsg = (char *) xalloc(len);
+ memmove(temp_inmsg, inmsg, len);
+
+ memset((char *)&msg, 0, sizeof(msg));
+ memset((char *)&r, 0, sizeof(r));
+ memset(cred_area, 0, sizeof(cred_area));
+ memset(verf_area, 0, sizeof(verf_area));
+
+ msg.rm_call.cb_cred.oa_base = cred_area;
+ msg.rm_call.cb_verf.oa_base = verf_area;
+ why = AUTH_FAILED;
+ xdrmem_create(&xdr, temp_inmsg, len, XDR_DECODE);
+
+ if ((r.rq_clntcred = (caddr_t) xalloc(MAX_AUTH_BYTES)) == NULL)
+ goto bad1;
+ r.rq_xprt = &xprt;
+
+ /* decode into msg */
+ res0 = xdr_opaque_auth(&xdr, &(msg.rm_call.cb_cred));
+ res1 = xdr_opaque_auth(&xdr, &(msg.rm_call.cb_verf));
+ if ( ! (res0 && res1) )
+ goto bad2;
+
+ /* do the authentication */
+
+ r.rq_cred = msg.rm_call.cb_cred; /* read by opaque stuff */
+ if (r.rq_cred.oa_flavor != AUTH_DES) {
+ why = AUTH_TOOWEAK;
+ goto bad2;
+ }
+#ifdef SVR4
+ if ((why = __authenticate(&r, &msg)) != AUTH_OK) {
+#else
+ if ((why = _authenticate(&r, &msg)) != AUTH_OK) {
+#endif
+ goto bad2;
+ }
+ return (((struct authdes_cred *) r.rq_clntcred)->adc_fullname.name);
+
+bad2:
+ xfree(r.rq_clntcred);
+bad1:
+ return ((char *)0); /* ((struct authdes_cred *) NULL); */
+}
+
+static XID rpc_id = (XID) ~0L;
+
+static Bool
+CheckNetName (
+ unsigned char *addr,
+ short len,
+ pointer closure
+)
+{
+ return (len == strlen ((char *) closure) &&
+ strncmp ((char *) addr, (char *) closure, len) == 0);
+}
+
+static char rpc_error[MAXNETNAMELEN+50];
+
+XID
+SecureRPCCheck (unsigned short data_length, char *data,
+ ClientPtr client, char **reason)
+{
+ char *fullname;
+
+ if (rpc_id == (XID) ~0L) {
+ *reason = "Secure RPC authorization not initialized";
+ } else {
+ fullname = authdes_ezdecode(data, data_length);
+ if (fullname == (char *)0) {
+ sprintf(rpc_error, "Unable to authenticate secure RPC client (why=%d)", why);
+ *reason = rpc_error;
+ } else {
+ if (ForEachHostInFamily (FamilyNetname, CheckNetName, fullname))
+ return rpc_id;
+ sprintf(rpc_error, "Principal \"%s\" is not authorized to connect",
+ fullname);
+ *reason = rpc_error;
+ }
+ }
+ return (XID) ~0L;
+}
+
+void
+SecureRPCInit (void)
+{
+ if (rpc_id == ~0L)
+ AddAuthorization (9, "SUN-DES-1", 0, (char *) 0);
+}
+
+int
+SecureRPCAdd (unsigned short data_length, char *data, XID id)
+{
+ if (data_length)
+ AddHost ((pointer) 0, FamilyNetname, data_length, data);
+ rpc_id = id;
+ return 1;
+}
+
+int
+SecureRPCReset (void)
+{
+ rpc_id = (XID) ~0L;
+ return 1;
+}
+
+XID
+SecureRPCToID (unsigned short data_length, char *data)
+{
+ return rpc_id;
+}
+
+int
+SecureRPCFromID (XID id, unsigned short *data_lenp, char **datap)
+{
+ return 0;
+}
+
+int
+SecureRPCRemove (unsigned short data_length, char *data)
+{
+ return 0;
+}
+#endif /* SECURE_RPC */
diff --git a/nx-X11/programs/Xserver/os/secauth.c b/nx-X11/programs/Xserver/os/secauth.c
new file mode 100644
index 000000000..1000b4e79
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/secauth.c
@@ -0,0 +1,205 @@
+/* $Xorg: secauth.c,v 1.4 2001/02/09 02:05:23 xorgcvs Exp $ */
+/*
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+*/
+/* $XFree86: xc/programs/Xserver/os/secauth.c,v 1.10 2001/08/01 00:44:59 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "osdep.h"
+#include "dixstruct.h"
+#include "swaprep.h"
+
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+
+static char InvalidPolicyReason[] = "invalid policy specification";
+static char PolicyViolationReason[] = "policy violation";
+
+static Bool
+AuthCheckSitePolicy(
+ unsigned short *data_lengthP,
+ char **dataP,
+ ClientPtr client,
+ char **reason)
+{
+ CARD8 *policy = *(CARD8 **)dataP;
+ int length;
+ Bool permit;
+ int nPolicies;
+ char **sitePolicies;
+ int nSitePolicies;
+ Bool found = FALSE;
+
+ if ((length = *data_lengthP) < 2) {
+ *reason = InvalidPolicyReason;
+ return FALSE;
+ }
+
+ permit = (*policy++ == 0);
+ nPolicies = (CARD8) *policy++;
+
+ length -= 2;
+
+ sitePolicies = SecurityGetSitePolicyStrings(&nSitePolicies);
+
+ while (nPolicies) {
+ int strLen, sitePolicy;
+
+ if (length == 0) {
+ *reason = InvalidPolicyReason;
+ return FALSE;
+ }
+
+ strLen = (CARD8) *policy++;
+ if (--length < strLen) {
+ *reason = InvalidPolicyReason;
+ return FALSE;
+ }
+
+ if (!found)
+ {
+ for (sitePolicy = 0; sitePolicy < nSitePolicies; sitePolicy++)
+ {
+ char *testPolicy = sitePolicies[sitePolicy];
+ if ((strLen == strlen(testPolicy)) &&
+ (strncmp((char *)policy, testPolicy, strLen) == 0))
+ {
+ found = TRUE; /* need to continue parsing the policy... */
+ break;
+ }
+ }
+ }
+
+ policy += strLen;
+ length -= strLen;
+ nPolicies--;
+ }
+
+ if (found != permit)
+ {
+ *reason = PolicyViolationReason;
+ return FALSE;
+ }
+
+ *data_lengthP = length;
+ *dataP = (char *)policy;
+ return TRUE;
+}
+
+XID
+AuthSecurityCheck (
+ unsigned short data_length,
+ char *data,
+ ClientPtr client,
+ char **reason)
+{
+#ifdef XCSECURITY
+ xConnSetupPrefix csp;
+ xReq freq;
+
+ if (client->clientState == ClientStateCheckedSecurity)
+ {
+ *reason = "repeated security check not permitted";
+ return (XID) -1;
+ }
+ else if (data_length > 0)
+ {
+ char policy_mask = *data++;
+
+ if (--data_length == 1) {
+ *reason = InvalidPolicyReason;
+ return (XID) -1;
+ }
+
+ if (policy_mask & 0x01) /* Extensions policy */
+ {
+ /* AuthCheckExtensionPolicy(&data_length, &data, client, reason) */
+ *reason = "security policy not implemented";
+ return (XID) -1;
+ }
+
+ if (policy_mask & 0x02) /* Site policy */
+ {
+ if (!AuthCheckSitePolicy(&data_length, &data, client, reason))
+ return (XID) -1;
+ }
+
+ if (data_length > 0) { /* did we consume the whole policy? */
+ *reason = InvalidPolicyReason;
+ return (XID) -1;
+ }
+
+ }
+ else if (!GetAccessControl())
+ {
+ /*
+ * The client - possibly the X FireWall Proxy - gave
+ * no auth data and host-based authorization is turned
+ * off. In this case, the client should be denied
+ * access to the X server.
+ */
+ *reason = "server host access control is disabled";
+ return (XID) -1;
+ }
+
+ client->clientState = ClientStateCheckingSecurity;
+
+ csp.success = 2 /* Authenticate */;
+ csp.lengthReason = 0;
+ csp.length = 0;
+ csp.majorVersion = X_PROTOCOL;
+ csp.minorVersion = X_PROTOCOL_REVISION;
+ if (client->swapped)
+ WriteSConnSetupPrefix(client, &csp);
+ else
+ (void)WriteToClient(client, sz_xConnSetupPrefix, (char *) &csp);
+
+ /*
+ * Next time the client sends the real auth data, we want
+ * ProcEstablishConnection to be called.
+ */
+
+ freq.reqType = 1;
+ freq.length = (sz_xReq + sz_xConnClientPrefix) >> 2;
+ client->swapped = FALSE;
+ if (!InsertFakeRequest(client, (char *)&freq, sz_xReq))
+ {
+ *reason = "internal error";
+ return (XID) -1;
+ }
+
+ return (XID) 0;
+#else
+ *reason = "method not supported";
+ return (XID) -1;
+#endif
+}
diff --git a/nx-X11/programs/Xserver/os/utils.c b/nx-X11/programs/Xserver/os/utils.c
new file mode 100644
index 000000000..c806621ff
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/utils.c
@@ -0,0 +1,2427 @@
+/* $XdotOrg: xc/programs/Xserver/os/utils.c,v 1.21 2005/11/08 06:33:30 jkj Exp $ */
+/* $Xorg: utils.c,v 1.5 2001/02/09 02:05:24 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1994 Quarterdeck Office Systems.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Digital and
+Quarterdeck not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+DIGITAL AND QUARTERDECK DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
+OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
+OR PERFORMANCE OF THIS SOFTWARE.
+
+*/
+/* $XFree86: xc/programs/Xserver/os/utils.c,v 3.96 2004/01/07 04:16:37 dawes Exp $ */
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef __CYGWIN__
+#include <stdlib.h>
+#include <signal.h>
+#endif
+
+#if defined(WIN32) && !defined(__CYGWIN__)
+#include <X11/Xwinsock.h>
+#endif
+#include <X11/Xos.h>
+#include <stdio.h>
+#include "misc.h"
+#include <X11/X.h>
+#include <X11/Xtrans/Xtrans.h>
+#include "input.h"
+#include "dixfont.h"
+#include "osdep.h"
+#ifdef X_POSIX_C_SOURCE
+#define _POSIX_C_SOURCE X_POSIX_C_SOURCE
+#include <signal.h>
+#undef _POSIX_C_SOURCE
+#else
+#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE)
+#include <signal.h>
+#else
+#define _POSIX_SOURCE
+#include <signal.h>
+#undef _POSIX_SOURCE
+#endif
+#endif
+#ifndef WIN32
+#include <sys/wait.h>
+#endif
+#if !defined(SYSV) && !defined(WIN32) && !defined(Lynx) && !defined(QNX4)
+#include <sys/resource.h>
+#endif
+#include <time.h>
+#include <sys/stat.h>
+#include <ctype.h> /* for isspace */
+#include <stdarg.h>
+
+#if defined(DGUX)
+#include <sys/resource.h>
+#include <netdb.h>
+#endif
+
+#include <stdlib.h> /* for malloc() */
+
+#if defined(TCPCONN) || defined(STREAMSCONN)
+# ifndef WIN32
+# include <netdb.h>
+# endif
+#endif
+
+#include "opaque.h"
+
+#ifdef SMART_SCHEDULE
+#include "dixstruct.h"
+#endif
+
+#ifdef XKB
+#include <X11/extensions/XKBsrv.h>
+#endif
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+
+#ifdef RENDER
+#include "picture.h"
+#endif
+
+#ifdef XPRINT
+#include "DiPrint.h"
+#endif
+
+Bool noTestExtensions;
+#ifdef BIGREQS
+Bool noBigReqExtension = FALSE;
+#endif
+#ifdef COMPOSITE
+/* COMPOSITE is disabled by default for now until the
+ * interface is stable */
+Bool noCompositeExtension = TRUE;
+#endif
+#ifdef DAMAGE
+Bool noDamageExtension = FALSE;
+#endif
+#ifdef DBE
+Bool noDbeExtension = FALSE;
+#endif
+#ifdef DPSEXT
+Bool noDPSExtension = FALSE;
+#endif
+#ifdef DPMSExtension
+Bool noDPMSExtension = FALSE;
+#endif
+#ifdef EVI
+Bool noEVIExtension = FALSE;
+#endif
+#ifdef FONTCACHE
+Bool noFontCacheExtension = FALSE;
+#endif
+#ifdef GLXEXT
+Bool noGlxExtension = FALSE;
+#endif
+#ifdef LBX
+Bool noLbxExtension = FALSE;
+#endif
+#ifdef SCREENSAVER
+Bool noScreenSaverExtension = FALSE;
+#endif
+#ifdef MITSHM
+Bool noMITShmExtension = FALSE;
+#endif
+#ifdef MITMISC
+Bool noMITMiscExtension = FALSE;
+#endif
+#ifdef MULTIBUFFER
+Bool noMultibufferExtension = FALSE;
+#endif
+#ifdef RANDR
+Bool noRRExtension = FALSE;
+#endif
+#ifdef RENDER
+Bool noRenderExtension = FALSE;
+#endif
+#ifdef SHAPE
+Bool noShapeExtension = FALSE;
+#endif
+#ifdef XCSECURITY
+Bool noSecurityExtension = FALSE;
+#endif
+#ifdef XSYNC
+Bool noSyncExtension = FALSE;
+#endif
+#ifdef TOGCUP
+Bool noXcupExtension = FALSE;
+#endif
+#ifdef RES
+Bool noResExtension = FALSE;
+#endif
+#ifdef XAPPGROUP
+Bool noXagExtension = FALSE;
+#endif
+#ifdef XCMISC
+Bool noXCMiscExtension = FALSE;
+#endif
+#ifdef XEVIE
+/* Xevie is disabled by default for now until the
+ * interface is stable */
+Bool noXevieExtension = TRUE;
+#endif
+#ifdef XF86BIGFONT
+Bool noXFree86BigfontExtension = FALSE;
+#endif
+#ifdef XFreeXDGA
+Bool noXFree86DGAExtension = FALSE;
+#endif
+#ifdef XF86DRI
+Bool noXFree86DRIExtension = FALSE;
+#endif
+#ifdef XF86MISC
+Bool noXFree86MiscExtension = FALSE;
+#endif
+#ifdef XF86VIDMODE
+Bool noXFree86VidModeExtension = FALSE;
+#endif
+#ifdef XFIXES
+Bool noXFixesExtension = FALSE;
+#endif
+/* |noXkbExtension| is defined in xc/programs/Xserver/xkb/xkbInit.c */
+#ifdef PANORAMIX
+/* Xinerama is disabled by default unless enabled via +xinerama */
+Bool noPanoramiXExtension = TRUE;
+#endif
+#ifdef XINPUT
+Bool noXInputExtension = FALSE;
+#endif
+#ifdef XIDLE
+Bool noXIdleExtension = FALSE;
+#endif
+#ifdef XV
+Bool noXvExtension = FALSE;
+#endif
+
+#define X_INCLUDE_NETDB_H
+#include <X11/Xos_r.h>
+
+#include <errno.h>
+
+#ifdef NX_TRANS_SOCKET
+
+#include "NX.h"
+#include "NXvars.h"
+
+#endif
+
+#ifdef NX_TRANS_EXIT
+
+void (*OsVendorStartRedirectErrorFProc)() = NULL;
+void (*OsVendorEndRedirectErrorFProc)() = NULL;
+
+#endif
+
+Bool CoreDump;
+
+#ifdef PANORAMIX
+Bool PanoramiXVisibilityNotifySent = FALSE;
+Bool PanoramiXMapped = FALSE;
+Bool PanoramiXWindowExposureSent = FALSE;
+Bool PanoramiXOneExposeRequest = FALSE;
+Bool PanoramiXExtensionDisabledHack = FALSE;
+#endif
+
+int auditTrailLevel = 1;
+
+Bool Must_have_memory = FALSE;
+
+#ifdef AIXV3
+int SyncOn = 0;
+extern int SelectWaitTime;
+#endif
+
+#ifdef DEBUG
+#ifndef SPECIAL_MALLOC
+#define MEMBUG
+#endif
+#endif
+
+#if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED)
+#define HAS_SAVED_IDS_AND_SETEUID
+#endif
+
+#ifdef MEMBUG
+#define MEM_FAIL_SCALE 100000
+long Memory_fail = 0;
+#include <stdlib.h> /* for random() */
+#endif
+
+#ifdef sgi
+int userdefinedfontpath = 0;
+#endif /* sgi */
+
+char *dev_tty_from_init = NULL; /* since we need to parse it anyway */
+
+extern char dispatchExceptionAtReset;
+
+/* Extension enable/disable in miinitext.c */
+extern Bool EnableDisableExtension(char *name, Bool enable);
+extern void EnableDisableExtensionError(char *name, Bool enable);
+
+OsSigHandlerPtr
+OsSignal(sig, handler)
+ int sig;
+ OsSigHandlerPtr handler;
+{
+#ifdef X_NOT_POSIX
+ return signal(sig, handler);
+#else
+ struct sigaction act, oact;
+
+ sigemptyset(&act.sa_mask);
+ if (handler != SIG_IGN)
+ sigaddset(&act.sa_mask, sig);
+ act.sa_flags = 0;
+ act.sa_handler = handler;
+ sigaction(sig, &act, &oact);
+ return oact.sa_handler;
+#endif
+}
+
+#ifdef SERVER_LOCK
+/*
+ * Explicit support for a server lock file like the ones used for UUCP.
+ * For architectures with virtual terminals that can run more than one
+ * server at a time. This keeps the servers from stomping on each other
+ * if the user forgets to give them different display numbers.
+ */
+#ifndef __UNIXOS2__
+#define LOCK_DIR "/tmp"
+#endif
+#define LOCK_TMP_PREFIX "/.tX"
+#define LOCK_PREFIX "/.X"
+#define LOCK_SUFFIX "-lock"
+
+#if defined(DGUX)
+#include <limits.h>
+#include <sys/param.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define link rename
+#endif
+
+#ifndef PATH_MAX
+#ifndef Lynx
+#include <sys/param.h>
+#else
+#include <param.h>
+#endif
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+#endif
+
+static Bool StillLocking = FALSE;
+static char LockFile[PATH_MAX];
+static Bool nolock = FALSE;
+
+/*
+ * LockServer --
+ * Check if the server lock file exists. If so, check if the PID
+ * contained inside is valid. If so, then die. Otherwise, create
+ * the lock file containing the PID.
+ */
+void
+LockServer(void)
+{
+ char tmp[PATH_MAX], pid_str[12];
+ int lfd, i, haslock, l_pid, t;
+ char *tmppath = NULL;
+ int len;
+ char port[20];
+
+ if (nolock) return;
+ /*
+ * Path names
+ */
+#ifndef __UNIXOS2__
+ tmppath = LOCK_DIR;
+#else
+ /* OS/2 uses TMP directory, must also prepare for 8.3 names */
+ tmppath = getenv("TMP");
+ if (!tmppath)
+ FatalError("No TMP dir found\n");
+#endif
+
+ sprintf(port, "%d", atoi(display));
+ len = strlen(LOCK_PREFIX) > strlen(LOCK_TMP_PREFIX) ? strlen(LOCK_PREFIX) :
+ strlen(LOCK_TMP_PREFIX);
+ len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1;
+ if (len > sizeof(LockFile))
+ FatalError("Display name `%s' is too long\n", port);
+ (void)sprintf(tmp, "%s" LOCK_TMP_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
+ (void)sprintf(LockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
+
+ /*
+ * Create a temporary file containing our PID. Attempt three times
+ * to create the file.
+ */
+ StillLocking = TRUE;
+ i = 0;
+ do {
+ i++;
+ lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644);
+ if (lfd < 0)
+ sleep(2);
+ else
+ break;
+ } while (i < 3);
+ if (lfd < 0) {
+ unlink(tmp);
+ i = 0;
+ do {
+ i++;
+ lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644);
+ if (lfd < 0)
+ sleep(2);
+ else
+ break;
+ } while (i < 3);
+ }
+ if (lfd < 0)
+ FatalError("Could not create lock file in %s\n", tmp);
+ (void) sprintf(pid_str, "%10ld\n", (long)getpid());
+ (void) write(lfd, pid_str, 11);
+#ifndef __UNIXOS2__
+#ifndef USE_CHMOD
+ (void) fchmod(lfd, 0444);
+#else
+ (void) chmod(tmp, 0444);
+#endif
+#endif
+ (void) close(lfd);
+
+ /*
+ * OK. Now the tmp file exists. Try three times to move it in place
+ * for the lock.
+ */
+ i = 0;
+ haslock = 0;
+ while ((!haslock) && (i++ < 3)) {
+ haslock = (link(tmp,LockFile) == 0);
+ if (haslock) {
+ /*
+ * We're done.
+ */
+ break;
+ }
+ else {
+ /*
+ * Read the pid from the existing file
+ */
+ lfd = open(LockFile, O_RDONLY);
+ if (lfd < 0) {
+ unlink(tmp);
+ FatalError("Can't read lock file %s\n", LockFile);
+ }
+ pid_str[0] = '\0';
+ if (read(lfd, pid_str, 11) != 11) {
+ /*
+ * Bogus lock file.
+ */
+ unlink(LockFile);
+ close(lfd);
+ continue;
+ }
+ pid_str[11] = '\0';
+ sscanf(pid_str, "%d", &l_pid);
+ close(lfd);
+
+ /*
+ * Now try to kill the PID to see if it exists.
+ */
+ errno = 0;
+ t = kill(l_pid, 0);
+ if ((t< 0) && (errno == ESRCH)) {
+ /*
+ * Stale lock file.
+ */
+ unlink(LockFile);
+ continue;
+ }
+ else if (((t < 0) && (errno == EPERM)) || (t == 0)) {
+ /*
+ * Process is still active.
+ */
+ unlink(tmp);
+ FatalError("Server is already active for display %s\n%s %s\n%s\n",
+ port, "\tIf this server is no longer running, remove",
+ LockFile, "\tand start again.");
+ }
+ }
+ }
+ unlink(tmp);
+ if (!haslock)
+ FatalError("Could not create server lock file: %s\n", LockFile);
+ StillLocking = FALSE;
+}
+
+/*
+ * UnlockServer --
+ * Remove the server lock file.
+ */
+void
+UnlockServer(void)
+{
+ if (nolock) return;
+
+ if (!StillLocking){
+
+#ifdef __UNIXOS2__
+ (void) chmod(LockFile,S_IREAD|S_IWRITE);
+#endif /* __UNIXOS2__ */
+ (void) unlink(LockFile);
+ }
+}
+#endif /* SERVER_LOCK */
+
+/* Force connections to close on SIGHUP from init */
+
+/*ARGSUSED*/
+SIGVAL
+AutoResetServer (int sig)
+{
+ int olderrno = errno;
+
+ dispatchException |= DE_RESET;
+ isItTimeToYield = TRUE;
+#ifdef GPROF
+ chdir ("/tmp");
+ exit (0);
+#endif
+#if defined(SYSV) && defined(X_NOT_POSIX)
+ OsSignal (SIGHUP, AutoResetServer);
+#endif
+ errno = olderrno;
+}
+
+/* Force connections to close and then exit on SIGTERM, SIGINT */
+
+/*ARGSUSED*/
+SIGVAL
+GiveUp(int sig)
+{
+ int olderrno = errno;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "GiveUp: Called with signal [%d].\n", sig);
+#endif
+
+ dispatchException |= DE_TERMINATE;
+ isItTimeToYield = TRUE;
+#if defined(SYSV) && defined(X_NOT_POSIX)
+ if (sig)
+ OsSignal(sig, SIG_IGN);
+#endif
+ errno = olderrno;
+}
+
+#ifndef DDXTIME
+CARD32
+GetTimeInMillis(void)
+{
+ struct timeval tp;
+
+ X_GETTIMEOFDAY(&tp);
+ return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);
+}
+#endif
+
+void
+AdjustWaitForDelay (pointer waitTime, unsigned long newdelay)
+{
+ static struct timeval delay_val;
+ struct timeval **wt = (struct timeval **) waitTime;
+ unsigned long olddelay;
+
+ if (*wt == NULL)
+ {
+ delay_val.tv_sec = newdelay / 1000;
+ delay_val.tv_usec = 1000 * (newdelay % 1000);
+ *wt = &delay_val;
+ }
+ else
+ {
+ olddelay = (*wt)->tv_sec * 1000 + (*wt)->tv_usec / 1000;
+ if (newdelay < olddelay)
+ {
+ (*wt)->tv_sec = newdelay / 1000;
+ (*wt)->tv_usec = 1000 * (newdelay % 1000);
+ }
+ }
+}
+
+void UseMsg(void)
+{
+#if !defined(AIXrt) && !defined(AIX386)
+ ErrorF("use: X [:<display>] [option]\n");
+ ErrorF("-a # mouse acceleration (pixels)\n");
+ ErrorF("-ac disable access control restrictions\n");
+#ifdef MEMBUG
+ ErrorF("-alloc int chance alloc should fail\n");
+#endif
+ ErrorF("-audit int set audit trail level\n");
+ ErrorF("-auth file select authorization file\n");
+ ErrorF("bc enable bug compatibility\n");
+ ErrorF("-br create root window with black background\n");
+ ErrorF("+bs enable any backing store support\n");
+ ErrorF("-bs disable any backing store support\n");
+ ErrorF("-c turns off key-click\n");
+ ErrorF("c # key-click volume (0-100)\n");
+ ErrorF("-cc int default color visual class\n");
+ ErrorF("-co file color database file\n");
+#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
+ ErrorF("-config file read options from file\n");
+#endif
+ ErrorF("-core generate core dump on fatal error\n");
+ ErrorF("-dpi int screen resolution in dots per inch\n");
+#ifdef DPMSExtension
+ ErrorF("dpms enables VESA DPMS monitor control\n");
+ ErrorF("-dpms disables VESA DPMS monitor control\n");
+#endif
+ ErrorF("-deferglyphs [none|all|16] defer loading of [no|all|16-bit] glyphs\n");
+ ErrorF("-f # bell base (0-100)\n");
+ ErrorF("-fc string cursor font\n");
+ ErrorF("-fn string default font name\n");
+ ErrorF("-fp string default font path\n");
+ ErrorF("-help prints message with these options\n");
+ ErrorF("-I ignore all remaining arguments\n");
+#ifdef RLIMIT_DATA
+ ErrorF("-ld int limit data space to N Kb\n");
+#endif
+#ifdef RLIMIT_NOFILE
+ ErrorF("-lf int limit number of open files to N\n");
+#endif
+#ifdef RLIMIT_STACK
+ ErrorF("-ls int limit stack space to N Kb\n");
+#endif
+#ifdef SERVER_LOCK
+ ErrorF("-nolock disable the locking mechanism\n");
+#endif
+#ifndef NOLOGOHACK
+ ErrorF("-logo enable logo in screen saver\n");
+ ErrorF("nologo disable logo in screen saver\n");
+#endif
+ ErrorF("-nolisten string don't listen on protocol\n");
+ ErrorF("-noreset don't reset after last client exists\n");
+ ErrorF("-reset reset after last client exists\n");
+ ErrorF("-p # screen-saver pattern duration (minutes)\n");
+ ErrorF("-pn accept failure to listen on all ports\n");
+ ErrorF("-nopn reject failure to listen on all ports\n");
+ ErrorF("-r turns off auto-repeat\n");
+ ErrorF("r turns on auto-repeat \n");
+#ifdef RENDER
+ ErrorF("-render [default|mono|gray|color] set render color alloc policy\n");
+#endif
+ ErrorF("-s # screen-saver timeout (minutes)\n");
+#ifdef XCSECURITY
+ ErrorF("-sp file security policy file\n");
+#endif
+#ifdef XPRINT
+ PrinterUseMsg();
+#endif
+ ErrorF("-su disable any save under support\n");
+ ErrorF("-t # mouse threshold (pixels)\n");
+ ErrorF("-terminate terminate at server reset\n");
+ ErrorF("-to # connection time out\n");
+ ErrorF("-tst disable testing extensions\n");
+ ErrorF("ttyxx server started from init on /dev/ttyxx\n");
+ ErrorF("v video blanking for screen-saver\n");
+ ErrorF("-v screen-saver without video blanking\n");
+ ErrorF("-wm WhenMapped default backing-store\n");
+ ErrorF("-x string loads named extension at init time \n");
+ ErrorF("-maxbigreqsize set maximal bigrequest size \n");
+#ifdef PANORAMIX
+ ErrorF("+xinerama Enable XINERAMA extension\n");
+ ErrorF("-xinerama Disable XINERAMA extension\n");
+#endif
+#ifdef SMART_SCHEDULE
+ ErrorF("-dumbSched Disable smart scheduling, enable old behavior\n");
+ ErrorF("-schedInterval int Set scheduler interval in msec\n");
+#endif
+ ErrorF("+extension name Enable extension\n");
+ ErrorF("-extension name Disable extension\n");
+#ifdef XDMCP
+ XdmcpUseMsg();
+#endif
+#endif /* !AIXrt && ! AIX386 */
+#ifdef XKB
+ XkbUseMsg();
+#endif
+ ddxUseMsg();
+}
+
+/* This function performs a rudimentary sanity check
+ * on the display name passed in on the command-line,
+ * since this string is used to generate filenames.
+ * It is especially important that the display name
+ * not contain a "/" and not start with a "-".
+ * --kvajk
+ */
+static int
+VerifyDisplayName(const char *d)
+{
+ if ( d == (char *)0 ) return( 0 ); /* null */
+ if ( *d == '\0' ) return( 0 ); /* empty */
+ if ( *d == '-' ) return( 0 ); /* could be confused for an option */
+ if ( *d == '.' ) return( 0 ); /* must not equal "." or ".." */
+ if ( strchr(d, '/') != (char *)0 ) return( 0 ); /* very important!!! */
+ return( 1 );
+}
+
+/*
+ * This function is responsible for doing initalisation of any global
+ * variables at an very early point of server startup (even before
+ * |ProcessCommandLine()|.
+ */
+void InitGlobals(void)
+{
+ ddxInitGlobals();
+}
+
+
+/*
+ * This function parses the command line. Handles device-independent fields
+ * and allows ddx to handle additional fields. It is not allowed to modify
+ * argc or any of the strings pointed to by argv.
+ */
+void
+ProcessCommandLine(int argc, char *argv[])
+{
+ int i, skip;
+
+ defaultKeyboardControl.autoRepeat = TRUE;
+
+#ifdef NO_PART_NET
+ PartialNetwork = FALSE;
+#else
+ PartialNetwork = TRUE;
+#endif
+
+ for ( i = 1; i < argc; i++ )
+ {
+ /* call ddx first, so it can peek/override if it wants */
+ if((skip = ddxProcessArgument(argc, argv, i)))
+ {
+ i += (skip - 1);
+ }
+ else if(argv[i][0] == ':')
+ {
+ /* initialize display */
+ display = argv[i];
+ display++;
+ if( ! VerifyDisplayName( display ) ) {
+ ErrorF("Bad display name: %s\n", display);
+ UseMsg();
+ FatalError("Bad display name, exiting: %s\n", display);
+ }
+ }
+ else if ( strcmp( argv[i], "-a") == 0)
+ {
+ if(++i < argc)
+ defaultPointerControl.num = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-ac") == 0)
+ {
+ defeatAccessControl = TRUE;
+ }
+#ifdef MEMBUG
+ else if ( strcmp( argv[i], "-alloc") == 0)
+ {
+ if(++i < argc)
+ Memory_fail = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+#endif
+ else if ( strcmp( argv[i], "-audit") == 0)
+ {
+ if(++i < argc)
+ auditTrailLevel = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-auth") == 0)
+ {
+ if(++i < argc)
+ InitAuthorization (argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "bc") == 0)
+ permitOldBugs = TRUE;
+ else if ( strcmp( argv[i], "-br") == 0)
+ blackRoot = TRUE;
+ else if ( strcmp( argv[i], "+bs") == 0)
+ enableBackingStore = TRUE;
+ else if ( strcmp( argv[i], "-bs") == 0)
+ disableBackingStore = TRUE;
+ else if ( strcmp( argv[i], "c") == 0)
+ {
+ if(++i < argc)
+ defaultKeyboardControl.click = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-c") == 0)
+ {
+ defaultKeyboardControl.click = 0;
+ }
+ else if ( strcmp( argv[i], "-cc") == 0)
+ {
+ if(++i < argc)
+ defaultColorVisualClass = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-co") == 0)
+ {
+ if(++i < argc)
+ rgbPath = argv[i];
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-core") == 0)
+ CoreDump = TRUE;
+ else if ( strcmp( argv[i], "-dpi") == 0)
+ {
+ if(++i < argc)
+ monitorResolution = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+#ifdef DPMSExtension
+ else if ( strcmp( argv[i], "dpms") == 0)
+ DPMSEnabledSwitch = TRUE;
+ else if ( strcmp( argv[i], "-dpms") == 0)
+ DPMSDisabledSwitch = TRUE;
+#endif
+ else if ( strcmp( argv[i], "-deferglyphs") == 0)
+ {
+ if(++i >= argc || !ParseGlyphCachingMode(argv[i]))
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-f") == 0)
+ {
+ if(++i < argc)
+ defaultKeyboardControl.bell = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-fc") == 0)
+ {
+ if(++i < argc)
+ defaultCursorFont = argv[i];
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-fn") == 0)
+ {
+ if(++i < argc)
+ defaultTextFont = argv[i];
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-fp") == 0)
+ {
+ if(++i < argc)
+ {
+#ifdef sgi
+ userdefinedfontpath = 1;
+#endif /* sgi */
+ defaultFontPath = argv[i];
+ }
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-help") == 0)
+ {
+ UseMsg();
+ exit(0);
+ }
+#ifdef XKB
+ else if ( (skip=XkbProcessArguments(argc,argv,i))!=0 ) {
+ if (skip>0)
+ i+= skip-1;
+ else UseMsg();
+ }
+#endif
+#ifdef RLIMIT_DATA
+ else if ( strcmp( argv[i], "-ld") == 0)
+ {
+ if(++i < argc)
+ {
+ limitDataSpace = atoi(argv[i]);
+ if (limitDataSpace > 0)
+ limitDataSpace *= 1024;
+ }
+ else
+ UseMsg();
+ }
+#endif
+#ifdef RLIMIT_NOFILE
+ else if ( strcmp( argv[i], "-lf") == 0)
+ {
+ if(++i < argc)
+ limitNoFile = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+#endif
+#ifdef RLIMIT_STACK
+ else if ( strcmp( argv[i], "-ls") == 0)
+ {
+ if(++i < argc)
+ {
+ limitStackSpace = atoi(argv[i]);
+ if (limitStackSpace > 0)
+ limitStackSpace *= 1024;
+ }
+ else
+ UseMsg();
+ }
+#endif
+#ifdef SERVER_LOCK
+ else if ( strcmp ( argv[i], "-nolock") == 0)
+ {
+#if !defined(WIN32) && !defined(__UNIXOS2__) && !defined(__CYGWIN__)
+ if (getuid() != 0)
+ ErrorF("Warning: the -nolock option can only be used by root\n");
+ else
+#endif
+ nolock = TRUE;
+ }
+#endif
+#ifndef NOLOGOHACK
+ else if ( strcmp( argv[i], "-logo") == 0)
+ {
+ logoScreenSaver = 1;
+ }
+ else if ( strcmp( argv[i], "nologo") == 0)
+ {
+ logoScreenSaver = 0;
+ }
+#endif
+ else if ( strcmp( argv[i], "-nolisten") == 0)
+ {
+ if(++i < argc) {
+ if (_XSERVTransNoListen(argv[i]))
+ FatalError ("Failed to disable listen for %s transport",
+ argv[i]);
+ } else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-noreset") == 0)
+ {
+ dispatchExceptionAtReset = 0;
+ }
+ else if ( strcmp( argv[i], "-reset") == 0)
+ {
+ dispatchExceptionAtReset = DE_RESET;
+ }
+ else if ( strcmp( argv[i], "-p") == 0)
+ {
+ if(++i < argc)
+ defaultScreenSaverInterval = ((CARD32)atoi(argv[i])) *
+ MILLI_PER_MIN;
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-pn") == 0)
+ PartialNetwork = TRUE;
+ else if ( strcmp( argv[i], "-nopn") == 0)
+ PartialNetwork = FALSE;
+ else if ( strcmp( argv[i], "r") == 0)
+ defaultKeyboardControl.autoRepeat = TRUE;
+ else if ( strcmp( argv[i], "-r") == 0)
+ defaultKeyboardControl.autoRepeat = FALSE;
+ else if ( strcmp( argv[i], "-s") == 0)
+ {
+ if(++i < argc)
+ defaultScreenSaverTime = ((CARD32)atoi(argv[i])) *
+ MILLI_PER_MIN;
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-su") == 0)
+ disableSaveUnders = TRUE;
+ else if ( strcmp( argv[i], "-t") == 0)
+ {
+ if(++i < argc)
+ defaultPointerControl.threshold = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-terminate") == 0)
+ {
+ dispatchExceptionAtReset = DE_TERMINATE;
+ }
+ else if ( strcmp( argv[i], "-to") == 0)
+ {
+ if(++i < argc)
+ TimeOutValue = ((CARD32)atoi(argv[i])) * MILLI_PER_SECOND;
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-tst") == 0)
+ {
+ noTestExtensions = TRUE;
+ }
+ else if ( strcmp( argv[i], "v") == 0)
+ defaultScreenSaverBlanking = PreferBlanking;
+ else if ( strcmp( argv[i], "-v") == 0)
+ defaultScreenSaverBlanking = DontPreferBlanking;
+ else if ( strcmp( argv[i], "-wm") == 0)
+ defaultBackingStore = WhenMapped;
+ else if ( strcmp( argv[i], "-maxbigreqsize") == 0) {
+ if(++i < argc) {
+ long reqSizeArg = atol(argv[i]);
+
+ /* Request size > 128MB does not make much sense... */
+ if( reqSizeArg > 0L && reqSizeArg < 128L ) {
+ maxBigRequestSize = (reqSizeArg * 1048576L) - 1L;
+ }
+ else
+ {
+ UseMsg();
+ }
+ }
+ else
+ {
+ UseMsg();
+ }
+ }
+#ifdef PANORAMIX
+ else if ( strcmp( argv[i], "+xinerama") == 0){
+ noPanoramiXExtension = FALSE;
+ }
+ else if ( strcmp( argv[i], "-xinerama") == 0){
+ noPanoramiXExtension = TRUE;
+ }
+ else if ( strcmp( argv[i], "-disablexineramaextension") == 0){
+ PanoramiXExtensionDisabledHack = TRUE;
+ }
+#endif
+ else if ( strcmp( argv[i], "-x") == 0)
+ {
+ if(++i >= argc)
+ UseMsg();
+ /* For U**x, which doesn't support dynamic loading, there's nothing
+ * to do when we see a -x. Either the extension is linked in or
+ * it isn't */
+ }
+ else if ( strcmp( argv[i], "-I") == 0)
+ {
+ /* ignore all remaining arguments */
+ break;
+ }
+ else if (strncmp (argv[i], "tty", 3) == 0)
+ {
+ /* just in case any body is interested */
+ dev_tty_from_init = argv[i];
+ }
+#ifdef XDMCP
+ else if ((skip = XdmcpOptions(argc, argv, i)) != i)
+ {
+ i = skip - 1;
+ }
+#endif
+#ifdef XPRINT
+ else if ((skip = PrinterOptions(argc, argv, i)) != i)
+ {
+ i = skip - 1;
+ }
+#endif
+#ifdef XCSECURITY
+ else if ((skip = XSecurityOptions(argc, argv, i)) != i)
+ {
+ i = skip - 1;
+ }
+#endif
+#ifdef AIXV3
+ else if ( strcmp( argv[i], "-timeout") == 0)
+ {
+ if(++i < argc)
+ SelectWaitTime = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-sync") == 0)
+ {
+ SyncOn++;
+ }
+#endif
+#ifdef SMART_SCHEDULE
+ else if ( strcmp( argv[i], "-dumbSched") == 0)
+ {
+ SmartScheduleDisable = TRUE;
+ }
+ else if ( strcmp( argv[i], "-schedInterval") == 0)
+ {
+ if (++i < argc)
+ {
+ SmartScheduleInterval = atoi(argv[i]);
+ SmartScheduleSlice = SmartScheduleInterval;
+ }
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-schedMax") == 0)
+ {
+ if (++i < argc)
+ {
+ SmartScheduleMaxSlice = atoi(argv[i]);
+ }
+ else
+ UseMsg();
+ }
+#endif
+#ifdef RENDER
+ else if ( strcmp( argv[i], "-render" ) == 0)
+ {
+ if (++i < argc)
+ {
+ int policy = PictureParseCmapPolicy (argv[i]);
+
+ if (policy != PictureCmapPolicyInvalid)
+ PictureCmapPolicy = policy;
+ else
+ UseMsg ();
+ }
+ else
+ UseMsg ();
+ }
+#endif
+ else if ( strcmp( argv[i], "+extension") == 0)
+ {
+ if (++i < argc)
+ {
+ if (!EnableDisableExtension(argv[i], TRUE))
+ EnableDisableExtensionError(argv[i], TRUE);
+ }
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-extension") == 0)
+ {
+ if (++i < argc)
+ {
+ if (!EnableDisableExtension(argv[i], FALSE))
+ EnableDisableExtensionError(argv[i], FALSE);
+ }
+ else
+ UseMsg();
+ }
+ else
+ {
+ ErrorF("Unrecognized option: %s\n", argv[i]);
+ UseMsg();
+ FatalError("Unrecognized option: %s\n", argv[i]);
+ }
+ }
+}
+
+#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
+static void
+InsertFileIntoCommandLine(
+ int *resargc, char ***resargv,
+ int prefix_argc, char **prefix_argv,
+ char *filename,
+ int suffix_argc, char **suffix_argv)
+{
+ struct stat st;
+ FILE *f;
+ char *p;
+ char *q;
+ int insert_argc;
+ char *buf;
+ int len;
+ int i;
+
+ f = fopen(filename, "r");
+ if (!f)
+ FatalError("Can't open option file %s\n", filename);
+
+ fstat(fileno(f), &st);
+
+ buf = (char *) xalloc((unsigned) st.st_size + 1);
+ if (!buf)
+ FatalError("Out of Memory\n");
+
+ len = fread(buf, 1, (unsigned) st.st_size, f);
+
+ fclose(f);
+
+ if (len < 0)
+ FatalError("Error reading option file %s\n", filename);
+
+ buf[len] = '\0';
+
+ p = buf;
+ q = buf;
+ insert_argc = 0;
+
+ while (*p)
+ {
+ while (isspace(*p))
+ p++;
+ if (!*p)
+ break;
+ if (*p == '#')
+ {
+ while (*p && *p != '\n')
+ p++;
+ } else
+ {
+ while (*p && !isspace(*p))
+ *q++ = *p++;
+ /* Since p and q might still be pointing at the same place, we */
+ /* need to step p over the whitespace now before we add the null. */
+ if (*p)
+ p++;
+ *q++ = '\0';
+ insert_argc++;
+ }
+ }
+
+ buf = (char *) xrealloc(buf, q - buf);
+ if (!buf)
+ FatalError("Out of memory reallocing option buf\n");
+
+ *resargc = prefix_argc + insert_argc + suffix_argc;
+ *resargv = (char **) xalloc((*resargc + 1) * sizeof(char *));
+ if (!*resargv)
+ FatalError("Out of Memory\n");
+
+ memcpy(*resargv, prefix_argv, prefix_argc * sizeof(char *));
+
+ p = buf;
+ for (i = 0; i < insert_argc; i++)
+ {
+ (*resargv)[prefix_argc + i] = p;
+ p += strlen(p) + 1;
+ }
+
+ memcpy(*resargv + prefix_argc + insert_argc,
+ suffix_argv, suffix_argc * sizeof(char *));
+
+ (*resargv)[*resargc] = NULL;
+} /* end InsertFileIntoCommandLine */
+
+
+void
+ExpandCommandLine(int *pargc, char ***pargv)
+{
+ int i;
+
+#if !defined(WIN32) && !defined(__UNIXOS2__) && !defined(__CYGWIN__)
+ if (getuid() != geteuid())
+ return;
+#endif
+
+ for (i = 1; i < *pargc; i++)
+ {
+ if ( (0 == strcmp((*pargv)[i], "-config")) && (i < (*pargc - 1)) )
+ {
+ InsertFileIntoCommandLine(pargc, pargv,
+ i, *pargv,
+ (*pargv)[i+1], /* filename */
+ *pargc - i - 2, *pargv + i + 2);
+ i--;
+ }
+ }
+} /* end ExpandCommandLine */
+#endif
+
+/* Implement a simple-minded font authorization scheme. The authorization
+ name is "hp-hostname-1", the contents are simply the host name. */
+int
+set_font_authorizations(char **authorizations, int *authlen, pointer client)
+{
+#define AUTHORIZATION_NAME "hp-hostname-1"
+#if defined(TCPCONN) || defined(STREAMSCONN)
+ static char *result = NULL;
+ static char *p = NULL;
+
+ if (p == NULL)
+ {
+ char hname[1024], *hnameptr;
+ unsigned int len;
+#if defined(IPv6) && defined(AF_INET6)
+ struct addrinfo hints, *ai = NULL;
+#else
+ struct hostent *host;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+#endif
+
+ gethostname(hname, 1024);
+#if defined(IPv6) && defined(AF_INET6)
+ bzero(&hints, sizeof(hints));
+ hints.ai_flags = AI_CANONNAME;
+ if (getaddrinfo(hname, NULL, &hints, &ai) == 0) {
+ hnameptr = ai->ai_canonname;
+ } else {
+ hnameptr = hname;
+ }
+#else
+ host = _XGethostbyname(hname, hparams);
+ if (host == NULL)
+ hnameptr = hname;
+ else
+ hnameptr = host->h_name;
+#endif
+
+ len = strlen(hnameptr) + 1;
+ result = xalloc(len + sizeof(AUTHORIZATION_NAME) + 4);
+
+ p = result;
+ *p++ = sizeof(AUTHORIZATION_NAME) >> 8;
+ *p++ = sizeof(AUTHORIZATION_NAME) & 0xff;
+ *p++ = (len) >> 8;
+ *p++ = (len & 0xff);
+
+ memmove(p, AUTHORIZATION_NAME, sizeof(AUTHORIZATION_NAME));
+ p += sizeof(AUTHORIZATION_NAME);
+ memmove(p, hnameptr, len);
+ p += len;
+#if defined(IPv6) && defined(AF_INET6)
+ if (ai) {
+ freeaddrinfo(ai);
+ }
+#endif
+ }
+ *authlen = p - result;
+ *authorizations = result;
+ return 1;
+#else /* TCPCONN */
+ return 0;
+#endif /* TCPCONN */
+}
+
+/* XALLOC -- X's internal memory allocator. Why does it return unsigned
+ * long * instead of the more common char *? Well, if you read K&R you'll
+ * see they say that alloc must return a pointer "suitable for conversion"
+ * to whatever type you really want. In a full-blown generic allocator
+ * there's no way to solve the alignment problems without potentially
+ * wasting lots of space. But we have a more limited problem. We know
+ * we're only ever returning pointers to structures which will have to
+ * be long word aligned. So we are making a stronger guarantee. It might
+ * have made sense to make Xalloc return char * to conform with people's
+ * expectations of malloc, but this makes lint happier.
+ */
+
+#ifndef INTERNAL_MALLOC
+
+void *
+Xalloc(unsigned long amount)
+{
+ register pointer ptr;
+
+ if ((long)amount <= 0) {
+ return (unsigned long *)NULL;
+ }
+ /* aligned extra on long word boundary */
+ amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
+#ifdef MEMBUG
+ if (!Must_have_memory && Memory_fail &&
+ ((random() % MEM_FAIL_SCALE) < Memory_fail))
+ return (unsigned long *)NULL;
+#endif
+ if ((ptr = (pointer)malloc(amount))) {
+ return (unsigned long *)ptr;
+ }
+ if (Must_have_memory)
+ FatalError("Out of memory");
+ return (unsigned long *)NULL;
+}
+
+/*****************
+ * XNFalloc
+ * "no failure" realloc, alternate interface to Xalloc w/o Must_have_memory
+ *****************/
+
+void *
+XNFalloc(unsigned long amount)
+{
+ register pointer ptr;
+
+ if ((long)amount <= 0)
+ {
+ return (unsigned long *)NULL;
+ }
+ /* aligned extra on long word boundary */
+ amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
+ ptr = (pointer)malloc(amount);
+ if (!ptr)
+ {
+ FatalError("Out of memory");
+ }
+ return ((unsigned long *)ptr);
+}
+
+/*****************
+ * Xcalloc
+ *****************/
+
+void *
+Xcalloc(unsigned long amount)
+{
+ unsigned long *ret;
+
+ ret = Xalloc (amount);
+ if (ret)
+ bzero ((char *) ret, (int) amount);
+ return ret;
+}
+
+/*****************
+ * XNFcalloc
+ *****************/
+
+void *
+XNFcalloc(unsigned long amount)
+{
+ unsigned long *ret;
+
+ ret = Xalloc (amount);
+ if (ret)
+ bzero ((char *) ret, (int) amount);
+ else if ((long)amount > 0)
+ FatalError("Out of memory");
+ return ret;
+}
+
+/*****************
+ * Xrealloc
+ *****************/
+
+void *
+Xrealloc(pointer ptr, unsigned long amount)
+{
+#ifdef MEMBUG
+ if (!Must_have_memory && Memory_fail &&
+ ((random() % MEM_FAIL_SCALE) < Memory_fail))
+ return (unsigned long *)NULL;
+#endif
+ if ((long)amount <= 0)
+ {
+ if (ptr && !amount)
+ free(ptr);
+ return (unsigned long *)NULL;
+ }
+ amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
+ if (ptr)
+ ptr = (pointer)realloc((char *)ptr, amount);
+ else
+ ptr = (pointer)malloc(amount);
+ if (ptr)
+ return (unsigned long *)ptr;
+ if (Must_have_memory)
+ FatalError("Out of memory");
+ return (unsigned long *)NULL;
+}
+
+/*****************
+ * XNFrealloc
+ * "no failure" realloc, alternate interface to Xrealloc w/o Must_have_memory
+ *****************/
+
+void *
+XNFrealloc(pointer ptr, unsigned long amount)
+{
+ if (( ptr = (pointer)Xrealloc( ptr, amount ) ) == NULL)
+ {
+ if ((long)amount > 0)
+ FatalError( "Out of memory" );
+ }
+ return ((unsigned long *)ptr);
+}
+
+/*****************
+ * Xfree
+ * calls free
+ *****************/
+
+void
+Xfree(pointer ptr)
+{
+ if (ptr)
+ free((char *)ptr);
+}
+
+void
+OsInitAllocator (void)
+{
+#ifdef MEMBUG
+ static int been_here;
+
+ /* Check the memory system after each generation */
+ if (been_here)
+ CheckMemory ();
+ else
+ been_here = 1;
+#endif
+}
+#endif /* !INTERNAL_MALLOC */
+
+
+char *
+Xstrdup(const char *s)
+{
+ char *sd;
+
+ if (s == NULL)
+ return NULL;
+
+ sd = (char *)Xalloc(strlen(s) + 1);
+ if (sd != NULL)
+ strcpy(sd, s);
+ return sd;
+}
+
+
+char *
+XNFstrdup(const char *s)
+{
+ char *sd;
+
+ if (s == NULL)
+ return NULL;
+
+ sd = (char *)XNFalloc(strlen(s) + 1);
+ strcpy(sd, s);
+ return sd;
+}
+
+#ifdef SMART_SCHEDULE
+
+unsigned long SmartScheduleIdleCount;
+Bool SmartScheduleIdle;
+Bool SmartScheduleTimerStopped;
+
+#ifdef SIGVTALRM
+#define SMART_SCHEDULE_POSSIBLE
+#endif
+
+#ifdef SMART_SCHEDULE_POSSIBLE
+#define SMART_SCHEDULE_SIGNAL SIGALRM
+#define SMART_SCHEDULE_TIMER ITIMER_REAL
+#endif
+
+#ifdef NX_TRANS_SOCKET
+void
+SmartScheduleStopTimer (void)
+#else
+static void
+SmartScheduleStopTimer (void)
+#endif
+{
+#ifdef SMART_SCHEDULE_POSSIBLE
+ struct itimerval timer;
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "SmartScheduleStopTimer: Stopping timer.\n");
+ #endif
+
+ timer.it_interval.tv_sec = 0;
+ timer.it_interval.tv_usec = 0;
+ timer.it_value.tv_sec = 0;
+ timer.it_value.tv_usec = 0;
+ (void) setitimer (ITIMER_REAL, &timer, 0);
+ SmartScheduleTimerStopped = TRUE;
+#endif
+}
+
+Bool
+SmartScheduleStartTimer (void)
+{
+#ifdef SMART_SCHEDULE_POSSIBLE
+ struct itimerval timer;
+
+ #ifdef NX_TRANS_SOCKET
+
+ if (SmartScheduleDisable)
+ {
+ return FALSE;
+ }
+
+ #endif
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "SmartScheduleStartTimer: Starting timer with [%ld] ms.\n",
+ SmartScheduleInterval);
+ #endif
+
+ SmartScheduleTimerStopped = FALSE;
+ timer.it_interval.tv_sec = 0;
+ timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
+ timer.it_value.tv_sec = 0;
+ timer.it_value.tv_usec = SmartScheduleInterval * 1000;
+ return setitimer (ITIMER_REAL, &timer, 0) >= 0;
+#endif
+ return FALSE;
+}
+
+#ifdef SMART_SCHEDULE_POSSIBLE
+static void
+SmartScheduleTimer (int sig)
+{
+ int olderrno = errno;
+
+ SmartScheduleTime += SmartScheduleInterval;
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "SmartScheduleTimer: Got timer with time [%ld] ms.\n",
+ SmartScheduleTime);
+ #endif
+
+ if (SmartScheduleIdle)
+ {
+ SmartScheduleStopTimer ();
+ }
+ errno = olderrno;
+}
+#endif
+
+Bool
+SmartScheduleInit (void)
+{
+#ifdef SMART_SCHEDULE_POSSIBLE
+ struct sigaction act;
+
+ if (SmartScheduleDisable)
+ return TRUE;
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "SmartScheduleInit: Initializing the smart scheduler.\n");
+ #endif
+
+ bzero ((char *) &act, sizeof(struct sigaction));
+
+ /* Set up the timer signal function */
+ act.sa_handler = SmartScheduleTimer;
+ sigemptyset (&act.sa_mask);
+ sigaddset (&act.sa_mask, SMART_SCHEDULE_SIGNAL);
+ if (sigaction (SMART_SCHEDULE_SIGNAL, &act, 0) < 0)
+ {
+ perror ("sigaction for smart scheduler");
+ return FALSE;
+ }
+ /* Set up the virtual timer */
+ if (!SmartScheduleStartTimer ())
+ {
+ perror ("scheduling timer");
+ return FALSE;
+ }
+ /* stop the timer and wait for WaitForSomething to start it */
+ SmartScheduleStopTimer ();
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+#endif
+
+#ifdef SIG_BLOCK
+static sigset_t PreviousSignalMask;
+static int BlockedSignalCount;
+#endif
+
+void
+OsBlockSignals (void)
+{
+#ifdef SIG_BLOCK
+ if (BlockedSignalCount++ == 0)
+ {
+ sigset_t set;
+
+ sigemptyset (&set);
+#ifdef SIGALRM
+ sigaddset (&set, SIGALRM);
+#endif
+#ifdef SIGVTALRM
+ sigaddset (&set, SIGVTALRM);
+#endif
+#ifdef SIGWINCH
+ sigaddset (&set, SIGWINCH);
+#endif
+#ifdef SIGIO
+ sigaddset (&set, SIGIO);
+#endif
+#ifdef SIGTSTP
+ sigaddset (&set, SIGTSTP);
+#endif
+#ifdef SIGTTIN
+ sigaddset (&set, SIGTTIN);
+#endif
+#ifdef SIGTTOU
+ sigaddset (&set, SIGTTOU);
+#endif
+#ifdef SIGCHLD
+ sigaddset (&set, SIGCHLD);
+#endif
+ sigprocmask (SIG_BLOCK, &set, &PreviousSignalMask);
+ }
+#endif
+}
+
+void
+OsReleaseSignals (void)
+{
+#ifdef SIG_BLOCK
+ if (--BlockedSignalCount == 0)
+ {
+ sigprocmask (SIG_SETMASK, &PreviousSignalMask, 0);
+ }
+#endif
+}
+
+#if !defined(WIN32) && !defined(__UNIXOS2__)
+/*
+ * "safer" versions of system(3), popen(3) and pclose(3) which give up
+ * all privs before running a command.
+ *
+ * This is based on the code in FreeBSD 2.2 libc.
+ *
+ * XXX It'd be good to redirect stderr so that it ends up in the log file
+ * as well. As it is now, xkbcomp messages don't end up in the log file.
+ */
+
+int
+System(char *command)
+{
+ int pid, p;
+#ifdef SIGCHLD
+ void (*csig)(int);
+#endif
+ int status;
+
+ if (!command)
+ return(1);
+
+#ifdef SIGCHLD
+ csig = signal(SIGCHLD, SIG_DFL);
+#endif
+
+#ifdef DEBUG
+ ErrorF("System: `%s'\n", command);
+#endif
+
+#ifdef NX_TRANS_EXIT
+ if (OsVendorStartRedirectErrorFProc != NULL) {
+ OsVendorStartRedirectErrorFProc();
+ }
+#endif
+ switch (pid = fork()) {
+ case -1: /* error */
+ p = -1;
+ case 0: /* child */
+ if (setgid(getgid()) == -1)
+ _exit(127);
+ if (setuid(getuid()) == -1)
+ _exit(127);
+ execl("/bin/sh", "sh", "-c", command, (char *)NULL);
+ _exit(127);
+ default: /* parent */
+ do {
+ p = waitpid(pid, &status, 0);
+ } while (p == -1 && errno == EINTR);
+
+ }
+#ifdef NX_TRANS_EXIT
+ if (OsVendorEndRedirectErrorFProc != NULL) {
+ OsVendorEndRedirectErrorFProc();
+ }
+#endif
+
+#ifdef SIGCHLD
+ signal(SIGCHLD, csig);
+#endif
+
+ return p == -1 ? -1 : status;
+}
+
+static struct pid {
+ struct pid *next;
+ FILE *fp;
+ int pid;
+} *pidlist;
+
+pointer
+Popen(char *command, char *type)
+{
+ struct pid *cur;
+ FILE *iop;
+ int pdes[2], pid;
+
+ if (command == NULL || type == NULL)
+ return NULL;
+
+ if ((*type != 'r' && *type != 'w') || type[1])
+ return NULL;
+
+ if ((cur = (struct pid *)xalloc(sizeof(struct pid))) == NULL)
+ return NULL;
+
+ if (pipe(pdes) < 0) {
+ xfree(cur);
+ return NULL;
+ }
+
+#ifdef NX_TRANS_EXIT
+ if (OsVendorStartRedirectErrorFProc != NULL) {
+ OsVendorStartRedirectErrorFProc();
+ }
+#endif
+ switch (pid = fork()) {
+ case -1: /* error */
+ close(pdes[0]);
+ close(pdes[1]);
+ xfree(cur);
+ return NULL;
+ case 0: /* child */
+ if (setgid(getgid()) == -1)
+ _exit(127);
+ if (setuid(getuid()) == -1)
+ _exit(127);
+ if (*type == 'r') {
+ if (pdes[1] != 1) {
+ /* stdout */
+ dup2(pdes[1], 1);
+ close(pdes[1]);
+ }
+ close(pdes[0]);
+ } else {
+ if (pdes[0] != 0) {
+ /* stdin */
+ dup2(pdes[0], 0);
+ close(pdes[0]);
+ }
+ close(pdes[1]);
+ }
+
+ #ifdef NX_TRANS_SOCKET
+
+ /*
+ * Check if the child process should not
+ * use the parent's libraries.
+ */
+
+ if (_NXUnsetLibraryPath)
+ {
+ #ifndef __sun
+
+ unsetenv ("LD_LIBRARY_PATH");
+
+ #else
+
+ extern char **environ;
+
+ char **ep = environ;
+
+ ep = environ;
+
+ while (*ep)
+ {
+ if (!strncmp("LD_LIBRARY_PATH=", *ep, strlen("LD_LIBRARY_PATH=")))
+ {
+ break;
+ }
+
+ *ep++;
+ }
+
+ while (*ep)
+ {
+ *ep = *(ep + 1);
+ ep++;
+ }
+
+ #endif
+ }
+
+ #endif
+
+ execl("/bin/sh", "sh", "-c", command, (char *)NULL);
+ _exit(127);
+ }
+
+ /* Avoid EINTR during stdio calls */
+ OsBlockSignals ();
+
+ /* parent */
+ if (*type == 'r') {
+ iop = fdopen(pdes[0], type);
+ close(pdes[1]);
+ } else {
+ iop = fdopen(pdes[1], type);
+ close(pdes[0]);
+ }
+
+ cur->fp = iop;
+ cur->pid = pid;
+ cur->next = pidlist;
+ pidlist = cur;
+
+#ifdef DEBUG
+ ErrorF("Popen: `%s', fp = %p\n", command, iop);
+#endif
+
+ return iop;
+}
+
+/* fopen that drops privileges */
+pointer
+Fopen(char *file, char *type)
+{
+ FILE *iop;
+#ifndef HAS_SAVED_IDS_AND_SETEUID
+ struct pid *cur;
+ int pdes[2], pid;
+
+ if (file == NULL || type == NULL)
+ return NULL;
+
+ if ((*type != 'r' && *type != 'w') || type[1])
+ return NULL;
+
+ if ((cur = (struct pid *)xalloc(sizeof(struct pid))) == NULL)
+ return NULL;
+
+ if (pipe(pdes) < 0) {
+ xfree(cur);
+ return NULL;
+ }
+
+ switch (pid = fork()) {
+ case -1: /* error */
+ close(pdes[0]);
+ close(pdes[1]);
+ xfree(cur);
+ return NULL;
+ case 0: /* child */
+ if (setgid(getgid()) == -1)
+ _exit(127);
+ if (setuid(getuid()) == -1)
+ _exit(127);
+ if (*type == 'r') {
+ if (pdes[1] != 1) {
+ /* stdout */
+ dup2(pdes[1], 1);
+ close(pdes[1]);
+ }
+ close(pdes[0]);
+ } else {
+ if (pdes[0] != 0) {
+ /* stdin */
+ dup2(pdes[0], 0);
+ close(pdes[0]);
+ }
+ close(pdes[1]);
+ }
+ execl("/bin/cat", "cat", file, (char *)NULL);
+ _exit(127);
+ }
+
+ /* Avoid EINTR during stdio calls */
+ OsBlockSignals ();
+
+ /* parent */
+ if (*type == 'r') {
+ iop = fdopen(pdes[0], type);
+ close(pdes[1]);
+ } else {
+ iop = fdopen(pdes[1], type);
+ close(pdes[0]);
+ }
+
+ cur->fp = iop;
+ cur->pid = pid;
+ cur->next = pidlist;
+ pidlist = cur;
+
+#ifdef DEBUG
+ ErrorF("Popen: `%s', fp = %p\n", command, iop);
+#endif
+
+ return iop;
+#else
+ int ruid, euid;
+
+ ruid = getuid();
+ euid = geteuid();
+
+ if (seteuid(ruid) == -1) {
+ return NULL;
+ }
+ iop = fopen(file, type);
+
+ if (seteuid(euid) == -1) {
+ fclose(iop);
+ return NULL;
+ }
+ return iop;
+#endif /* HAS_SAVED_IDS_AND_SETEUID */
+}
+
+int
+Pclose(pointer iop)
+{
+ struct pid *cur, *last;
+ int pstat;
+ int pid;
+
+#ifdef DEBUG
+ ErrorF("Pclose: fp = %p\n", iop);
+#endif
+
+ fclose(iop);
+
+ for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next)
+ if (cur->fp == iop)
+ break;
+ if (cur == NULL)
+ return -1;
+
+ do {
+ pid = waitpid(cur->pid, &pstat, 0);
+ } while (pid == -1 && errno == EINTR);
+
+ if (last == NULL)
+ pidlist = cur->next;
+ else
+ last->next = cur->next;
+ xfree(cur);
+
+ /* allow EINTR again */
+ OsReleaseSignals ();
+
+#ifdef NX_TRANS_EXIT
+ if (OsVendorEndRedirectErrorFProc != NULL) {
+ OsVendorEndRedirectErrorFProc();
+ }
+#endif
+ return pid == -1 ? -1 : pstat;
+}
+
+int
+Fclose(pointer iop)
+{
+#ifdef HAS_SAVED_IDS_AND_SETEUID
+ return fclose(iop);
+#else
+ return Pclose(iop);
+#endif
+}
+
+#endif /* !WIN32 && !__UNIXOS2__ */
+
+
+/*
+ * CheckUserParameters: check for long command line arguments and long
+ * environment variables. By default, these checks are only done when
+ * the server's euid != ruid. In 3.3.x, these checks were done in an
+ * external wrapper utility.
+ */
+
+/* Consider LD* variables insecure? */
+#ifndef REMOVE_ENV_LD
+#define REMOVE_ENV_LD 1
+#endif
+
+/* Remove long environment variables? */
+#ifndef REMOVE_LONG_ENV
+#define REMOVE_LONG_ENV 1
+#endif
+
+/*
+ * Disallow stdout or stderr as pipes? It's possible to block the X server
+ * when piping stdout+stderr to a pipe.
+ *
+ * Don't enable this because it looks like it's going to cause problems.
+ */
+#ifndef NO_OUTPUT_PIPES
+#define NO_OUTPUT_PIPES 0
+#endif
+
+
+/* Check args and env only if running setuid (euid == 0 && euid != uid) ? */
+#ifndef CHECK_EUID
+#ifndef WIN32
+#define CHECK_EUID 1
+#else
+#define CHECK_EUID 0
+#endif
+#endif
+
+/*
+ * Maybe the locale can be faked to make isprint(3) report that everything
+ * is printable? Avoid it by default.
+ */
+#ifndef USE_ISPRINT
+#define USE_ISPRINT 0
+#endif
+
+#define MAX_ARG_LENGTH 128
+#define MAX_ENV_LENGTH 256
+#define MAX_ENV_PATH_LENGTH 2048 /* Limit for *PATH and TERMCAP */
+
+#if USE_ISPRINT
+#include <ctype.h>
+#define checkPrintable(c) isprint(c)
+#else
+#define checkPrintable(c) (((c) & 0x7f) >= 0x20 && ((c) & 0x7f) != 0x7f)
+#endif
+
+enum BadCode {
+ NotBad = 0,
+ UnsafeArg,
+ ArgTooLong,
+ UnprintableArg,
+ EnvTooLong,
+ OutputIsPipe,
+ InternalError
+};
+
+#if defined(VENDORSUPPORT)
+#define BUGADDRESS VENDORSUPPORT
+#elif defined(BUILDERADDR)
+#define BUGADDRESS BUILDERADDR
+#else
+#define BUGADDRESS "xorg@freedesktop.org"
+#endif
+
+#define ARGMSG \
+ "\nIf the arguments used are valid, and have been rejected incorrectly\n" \
+ "please send details of the arguments and why they are valid to\n" \
+ "%s. In the meantime, you can start the Xserver as\n" \
+ "the \"super user\" (root).\n"
+
+#define ENVMSG \
+ "\nIf the environment is valid, and have been rejected incorrectly\n" \
+ "please send details of the environment and why it is valid to\n" \
+ "%s. In the meantime, you can start the Xserver as\n" \
+ "the \"super user\" (root).\n"
+
+void
+CheckUserParameters(int argc, char **argv, char **envp)
+{
+ enum BadCode bad = NotBad;
+ int i = 0, j;
+ char *a, *e = NULL;
+#if defined(__QNX__) && !defined(__QNXNTO__)
+ char cmd_name[64];
+#endif
+
+#if CHECK_EUID
+ if (geteuid() == 0 && getuid() != geteuid())
+#endif
+ {
+ /* Check each argv[] */
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-fp") == 0)
+ {
+ i++; /* continue with next argument. skip the length check */
+ if (i >= argc)
+ break;
+ } else
+ {
+ if (strlen(argv[i]) > MAX_ARG_LENGTH) {
+ bad = ArgTooLong;
+ break;
+ }
+ }
+ a = argv[i];
+ while (*a) {
+ if (checkPrintable(*a) == 0) {
+ bad = UnprintableArg;
+ break;
+ }
+ a++;
+ }
+ if (bad)
+ break;
+ }
+ if (!bad) {
+ /* Check each envp[] */
+ for (i = 0; envp[i]; i++) {
+
+ /* Check for bad environment variables and values */
+#if REMOVE_ENV_LD
+ while (envp[i] && (strncmp(envp[i], "LD", 2) == 0)) {
+#ifdef ENVDEBUG
+ ErrorF("CheckUserParameters: removing %s from the "
+ "environment\n", strtok(envp[i], "="));
+#endif
+ for (j = i; envp[j]; j++) {
+ envp[j] = envp[j+1];
+ }
+ }
+#endif
+ if (envp[i] && (strlen(envp[i]) > MAX_ENV_LENGTH)) {
+#if REMOVE_LONG_ENV
+#ifdef ENVDEBUG
+ ErrorF("CheckUserParameters: removing %s from the "
+ "environment\n", strtok(envp[i], "="));
+#endif
+ for (j = i; envp[j]; j++) {
+ envp[j] = envp[j+1];
+ }
+ i--;
+#else
+ char *eq;
+ int len;
+
+ eq = strchr(envp[i], '=');
+ if (!eq)
+ continue;
+ len = eq - envp[i];
+ e = malloc(len + 1);
+ if (!e) {
+ bad = InternalError;
+ break;
+ }
+ strncpy(e, envp[i], len);
+ e[len] = 0;
+ if (len >= 4 &&
+ (strcmp(e + len - 4, "PATH") == 0 ||
+ strcmp(e, "TERMCAP") == 0)) {
+ if (strlen(envp[i]) > MAX_ENV_PATH_LENGTH) {
+ bad = EnvTooLong;
+ break;
+ } else {
+ free(e);
+ }
+ } else {
+ bad = EnvTooLong;
+ break;
+ }
+#endif
+ }
+ }
+ }
+#if NO_OUTPUT_PIPES
+ if (!bad) {
+ struct stat buf;
+
+ if (fstat(fileno(stdout), &buf) == 0 && S_ISFIFO(buf.st_mode))
+ bad = OutputIsPipe;
+ if (fstat(fileno(stderr), &buf) == 0 && S_ISFIFO(buf.st_mode))
+ bad = OutputIsPipe;
+ }
+#endif
+ }
+ switch (bad) {
+ case NotBad:
+ return;
+ case UnsafeArg:
+ ErrorF("Command line argument number %d is unsafe\n", i);
+ ErrorF(ARGMSG, BUGADDRESS);
+ break;
+ case ArgTooLong:
+ ErrorF("Command line argument number %d is too long\n", i);
+ ErrorF(ARGMSG, BUGADDRESS);
+ break;
+ case UnprintableArg:
+ ErrorF("Command line argument number %d contains unprintable"
+ " characters\n", i);
+ ErrorF(ARGMSG, BUGADDRESS);
+ break;
+ case EnvTooLong:
+ ErrorF("Environment variable `%s' is too long\n", e);
+ ErrorF(ENVMSG, BUGADDRESS);
+ break;
+ case OutputIsPipe:
+ ErrorF("Stdout and/or stderr is a pipe\n");
+ break;
+ case InternalError:
+ ErrorF("Internal Error\n");
+ break;
+ default:
+ ErrorF("Unknown error\n");
+ ErrorF(ARGMSG, BUGADDRESS);
+ ErrorF(ENVMSG, BUGADDRESS);
+ break;
+ }
+ FatalError("X server aborted because of unsafe environment\n");
+}
+
+/*
+ * CheckUserAuthorization: check if the user is allowed to start the
+ * X server. This usually means some sort of PAM checking, and it is
+ * usually only done for setuid servers (uid != euid).
+ */
+
+#ifdef USE_PAM
+#include <security/pam_appl.h>
+#include <security/pam_misc.h>
+#include <pwd.h>
+#endif /* USE_PAM */
+
+void
+CheckUserAuthorization(void)
+{
+#ifdef USE_PAM
+ static struct pam_conv conv = {
+ misc_conv,
+ NULL
+ };
+
+ pam_handle_t *pamh = NULL;
+ struct passwd *pw;
+ int retval;
+
+ if (getuid() != geteuid()) {
+ pw = getpwuid(getuid());
+ if (pw == NULL)
+ FatalError("getpwuid() failed for uid %d\n", getuid());
+
+ retval = pam_start("xserver", pw->pw_name, &conv, &pamh);
+ if (retval != PAM_SUCCESS)
+ FatalError("pam_start() failed.\n"
+ "\tMissing or mangled PAM config file or module?\n");
+
+ retval = pam_authenticate(pamh, 0);
+ if (retval != PAM_SUCCESS) {
+ pam_end(pamh, retval);
+ FatalError("PAM authentication failed, cannot start X server.\n"
+ "\tPerhaps you do not have console ownership?\n");
+ }
+
+ retval = pam_acct_mgmt(pamh, 0);
+ if (retval != PAM_SUCCESS) {
+ pam_end(pamh, retval);
+ FatalError("PAM authentication failed, cannot start X server.\n"
+ "\tPerhaps you do not have console ownership?\n");
+ }
+
+ /* this is not a session, so do not do session management */
+ pam_end(pamh, PAM_SUCCESS);
+ }
+#endif
+}
+
+#ifdef __SCO__
+#include <fcntl.h>
+
+static void
+lockit (int fd, short what)
+{
+ struct flock lck;
+
+ lck.l_whence = 0;
+ lck.l_start = 0;
+ lck.l_len = 1;
+ lck.l_type = what;
+
+ (void)fcntl (fd, F_SETLKW, &lck);
+}
+
+/* SCO OpenServer 5 lacks pread/pwrite. Emulate them. */
+ssize_t
+pread (int fd, void *buf, size_t nbytes, off_t offset)
+{
+ off_t saved;
+ ssize_t ret;
+
+ lockit (fd, F_RDLCK);
+ saved = lseek (fd, 0, SEEK_CUR);
+ lseek (fd, offset, SEEK_SET);
+ ret = read (fd, buf, nbytes);
+ lseek (fd, saved, SEEK_SET);
+ lockit (fd, F_UNLCK);
+
+ return ret;
+}
+
+ssize_t
+pwrite (int fd, const void *buf, size_t nbytes, off_t offset)
+{
+ off_t saved;
+ ssize_t ret;
+
+ lockit (fd, F_WRLCK);
+ saved = lseek (fd, 0, SEEK_CUR);
+ lseek (fd, offset, SEEK_SET);
+ ret = write (fd, buf, nbytes);
+ lseek (fd, saved, SEEK_SET);
+ lockit (fd, F_UNLCK);
+
+ return ret;
+}
+#endif /* __SCO__ */
diff --git a/nx-X11/programs/Xserver/os/utils.c.NX.original b/nx-X11/programs/Xserver/os/utils.c.NX.original
new file mode 100644
index 000000000..c806621ff
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/utils.c.NX.original
@@ -0,0 +1,2427 @@
+/* $XdotOrg: xc/programs/Xserver/os/utils.c,v 1.21 2005/11/08 06:33:30 jkj Exp $ */
+/* $Xorg: utils.c,v 1.5 2001/02/09 02:05:24 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1994 Quarterdeck Office Systems.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Digital and
+Quarterdeck not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+DIGITAL AND QUARTERDECK DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
+OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
+OR PERFORMANCE OF THIS SOFTWARE.
+
+*/
+/* $XFree86: xc/programs/Xserver/os/utils.c,v 3.96 2004/01/07 04:16:37 dawes Exp $ */
+
+/**************************************************************************/
+/* */
+/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */
+/* */
+/* NX-X11, NX protocol compression and NX extensions to this software */
+/* are copyright of NoMachine. Redistribution and use of the present */
+/* software is allowed according to terms specified in the file LICENSE */
+/* which comes in the source distribution. */
+/* */
+/* Check http://www.nomachine.com/licensing.html for applicability. */
+/* */
+/* NX and NoMachine are trademarks of NoMachine S.r.l. */
+/* */
+/* All rights reserved. */
+/* */
+/**************************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef __CYGWIN__
+#include <stdlib.h>
+#include <signal.h>
+#endif
+
+#if defined(WIN32) && !defined(__CYGWIN__)
+#include <X11/Xwinsock.h>
+#endif
+#include <X11/Xos.h>
+#include <stdio.h>
+#include "misc.h"
+#include <X11/X.h>
+#include <X11/Xtrans/Xtrans.h>
+#include "input.h"
+#include "dixfont.h"
+#include "osdep.h"
+#ifdef X_POSIX_C_SOURCE
+#define _POSIX_C_SOURCE X_POSIX_C_SOURCE
+#include <signal.h>
+#undef _POSIX_C_SOURCE
+#else
+#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE)
+#include <signal.h>
+#else
+#define _POSIX_SOURCE
+#include <signal.h>
+#undef _POSIX_SOURCE
+#endif
+#endif
+#ifndef WIN32
+#include <sys/wait.h>
+#endif
+#if !defined(SYSV) && !defined(WIN32) && !defined(Lynx) && !defined(QNX4)
+#include <sys/resource.h>
+#endif
+#include <time.h>
+#include <sys/stat.h>
+#include <ctype.h> /* for isspace */
+#include <stdarg.h>
+
+#if defined(DGUX)
+#include <sys/resource.h>
+#include <netdb.h>
+#endif
+
+#include <stdlib.h> /* for malloc() */
+
+#if defined(TCPCONN) || defined(STREAMSCONN)
+# ifndef WIN32
+# include <netdb.h>
+# endif
+#endif
+
+#include "opaque.h"
+
+#ifdef SMART_SCHEDULE
+#include "dixstruct.h"
+#endif
+
+#ifdef XKB
+#include <X11/extensions/XKBsrv.h>
+#endif
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+
+#ifdef RENDER
+#include "picture.h"
+#endif
+
+#ifdef XPRINT
+#include "DiPrint.h"
+#endif
+
+Bool noTestExtensions;
+#ifdef BIGREQS
+Bool noBigReqExtension = FALSE;
+#endif
+#ifdef COMPOSITE
+/* COMPOSITE is disabled by default for now until the
+ * interface is stable */
+Bool noCompositeExtension = TRUE;
+#endif
+#ifdef DAMAGE
+Bool noDamageExtension = FALSE;
+#endif
+#ifdef DBE
+Bool noDbeExtension = FALSE;
+#endif
+#ifdef DPSEXT
+Bool noDPSExtension = FALSE;
+#endif
+#ifdef DPMSExtension
+Bool noDPMSExtension = FALSE;
+#endif
+#ifdef EVI
+Bool noEVIExtension = FALSE;
+#endif
+#ifdef FONTCACHE
+Bool noFontCacheExtension = FALSE;
+#endif
+#ifdef GLXEXT
+Bool noGlxExtension = FALSE;
+#endif
+#ifdef LBX
+Bool noLbxExtension = FALSE;
+#endif
+#ifdef SCREENSAVER
+Bool noScreenSaverExtension = FALSE;
+#endif
+#ifdef MITSHM
+Bool noMITShmExtension = FALSE;
+#endif
+#ifdef MITMISC
+Bool noMITMiscExtension = FALSE;
+#endif
+#ifdef MULTIBUFFER
+Bool noMultibufferExtension = FALSE;
+#endif
+#ifdef RANDR
+Bool noRRExtension = FALSE;
+#endif
+#ifdef RENDER
+Bool noRenderExtension = FALSE;
+#endif
+#ifdef SHAPE
+Bool noShapeExtension = FALSE;
+#endif
+#ifdef XCSECURITY
+Bool noSecurityExtension = FALSE;
+#endif
+#ifdef XSYNC
+Bool noSyncExtension = FALSE;
+#endif
+#ifdef TOGCUP
+Bool noXcupExtension = FALSE;
+#endif
+#ifdef RES
+Bool noResExtension = FALSE;
+#endif
+#ifdef XAPPGROUP
+Bool noXagExtension = FALSE;
+#endif
+#ifdef XCMISC
+Bool noXCMiscExtension = FALSE;
+#endif
+#ifdef XEVIE
+/* Xevie is disabled by default for now until the
+ * interface is stable */
+Bool noXevieExtension = TRUE;
+#endif
+#ifdef XF86BIGFONT
+Bool noXFree86BigfontExtension = FALSE;
+#endif
+#ifdef XFreeXDGA
+Bool noXFree86DGAExtension = FALSE;
+#endif
+#ifdef XF86DRI
+Bool noXFree86DRIExtension = FALSE;
+#endif
+#ifdef XF86MISC
+Bool noXFree86MiscExtension = FALSE;
+#endif
+#ifdef XF86VIDMODE
+Bool noXFree86VidModeExtension = FALSE;
+#endif
+#ifdef XFIXES
+Bool noXFixesExtension = FALSE;
+#endif
+/* |noXkbExtension| is defined in xc/programs/Xserver/xkb/xkbInit.c */
+#ifdef PANORAMIX
+/* Xinerama is disabled by default unless enabled via +xinerama */
+Bool noPanoramiXExtension = TRUE;
+#endif
+#ifdef XINPUT
+Bool noXInputExtension = FALSE;
+#endif
+#ifdef XIDLE
+Bool noXIdleExtension = FALSE;
+#endif
+#ifdef XV
+Bool noXvExtension = FALSE;
+#endif
+
+#define X_INCLUDE_NETDB_H
+#include <X11/Xos_r.h>
+
+#include <errno.h>
+
+#ifdef NX_TRANS_SOCKET
+
+#include "NX.h"
+#include "NXvars.h"
+
+#endif
+
+#ifdef NX_TRANS_EXIT
+
+void (*OsVendorStartRedirectErrorFProc)() = NULL;
+void (*OsVendorEndRedirectErrorFProc)() = NULL;
+
+#endif
+
+Bool CoreDump;
+
+#ifdef PANORAMIX
+Bool PanoramiXVisibilityNotifySent = FALSE;
+Bool PanoramiXMapped = FALSE;
+Bool PanoramiXWindowExposureSent = FALSE;
+Bool PanoramiXOneExposeRequest = FALSE;
+Bool PanoramiXExtensionDisabledHack = FALSE;
+#endif
+
+int auditTrailLevel = 1;
+
+Bool Must_have_memory = FALSE;
+
+#ifdef AIXV3
+int SyncOn = 0;
+extern int SelectWaitTime;
+#endif
+
+#ifdef DEBUG
+#ifndef SPECIAL_MALLOC
+#define MEMBUG
+#endif
+#endif
+
+#if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED)
+#define HAS_SAVED_IDS_AND_SETEUID
+#endif
+
+#ifdef MEMBUG
+#define MEM_FAIL_SCALE 100000
+long Memory_fail = 0;
+#include <stdlib.h> /* for random() */
+#endif
+
+#ifdef sgi
+int userdefinedfontpath = 0;
+#endif /* sgi */
+
+char *dev_tty_from_init = NULL; /* since we need to parse it anyway */
+
+extern char dispatchExceptionAtReset;
+
+/* Extension enable/disable in miinitext.c */
+extern Bool EnableDisableExtension(char *name, Bool enable);
+extern void EnableDisableExtensionError(char *name, Bool enable);
+
+OsSigHandlerPtr
+OsSignal(sig, handler)
+ int sig;
+ OsSigHandlerPtr handler;
+{
+#ifdef X_NOT_POSIX
+ return signal(sig, handler);
+#else
+ struct sigaction act, oact;
+
+ sigemptyset(&act.sa_mask);
+ if (handler != SIG_IGN)
+ sigaddset(&act.sa_mask, sig);
+ act.sa_flags = 0;
+ act.sa_handler = handler;
+ sigaction(sig, &act, &oact);
+ return oact.sa_handler;
+#endif
+}
+
+#ifdef SERVER_LOCK
+/*
+ * Explicit support for a server lock file like the ones used for UUCP.
+ * For architectures with virtual terminals that can run more than one
+ * server at a time. This keeps the servers from stomping on each other
+ * if the user forgets to give them different display numbers.
+ */
+#ifndef __UNIXOS2__
+#define LOCK_DIR "/tmp"
+#endif
+#define LOCK_TMP_PREFIX "/.tX"
+#define LOCK_PREFIX "/.X"
+#define LOCK_SUFFIX "-lock"
+
+#if defined(DGUX)
+#include <limits.h>
+#include <sys/param.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define link rename
+#endif
+
+#ifndef PATH_MAX
+#ifndef Lynx
+#include <sys/param.h>
+#else
+#include <param.h>
+#endif
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+#endif
+
+static Bool StillLocking = FALSE;
+static char LockFile[PATH_MAX];
+static Bool nolock = FALSE;
+
+/*
+ * LockServer --
+ * Check if the server lock file exists. If so, check if the PID
+ * contained inside is valid. If so, then die. Otherwise, create
+ * the lock file containing the PID.
+ */
+void
+LockServer(void)
+{
+ char tmp[PATH_MAX], pid_str[12];
+ int lfd, i, haslock, l_pid, t;
+ char *tmppath = NULL;
+ int len;
+ char port[20];
+
+ if (nolock) return;
+ /*
+ * Path names
+ */
+#ifndef __UNIXOS2__
+ tmppath = LOCK_DIR;
+#else
+ /* OS/2 uses TMP directory, must also prepare for 8.3 names */
+ tmppath = getenv("TMP");
+ if (!tmppath)
+ FatalError("No TMP dir found\n");
+#endif
+
+ sprintf(port, "%d", atoi(display));
+ len = strlen(LOCK_PREFIX) > strlen(LOCK_TMP_PREFIX) ? strlen(LOCK_PREFIX) :
+ strlen(LOCK_TMP_PREFIX);
+ len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1;
+ if (len > sizeof(LockFile))
+ FatalError("Display name `%s' is too long\n", port);
+ (void)sprintf(tmp, "%s" LOCK_TMP_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
+ (void)sprintf(LockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
+
+ /*
+ * Create a temporary file containing our PID. Attempt three times
+ * to create the file.
+ */
+ StillLocking = TRUE;
+ i = 0;
+ do {
+ i++;
+ lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644);
+ if (lfd < 0)
+ sleep(2);
+ else
+ break;
+ } while (i < 3);
+ if (lfd < 0) {
+ unlink(tmp);
+ i = 0;
+ do {
+ i++;
+ lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644);
+ if (lfd < 0)
+ sleep(2);
+ else
+ break;
+ } while (i < 3);
+ }
+ if (lfd < 0)
+ FatalError("Could not create lock file in %s\n", tmp);
+ (void) sprintf(pid_str, "%10ld\n", (long)getpid());
+ (void) write(lfd, pid_str, 11);
+#ifndef __UNIXOS2__
+#ifndef USE_CHMOD
+ (void) fchmod(lfd, 0444);
+#else
+ (void) chmod(tmp, 0444);
+#endif
+#endif
+ (void) close(lfd);
+
+ /*
+ * OK. Now the tmp file exists. Try three times to move it in place
+ * for the lock.
+ */
+ i = 0;
+ haslock = 0;
+ while ((!haslock) && (i++ < 3)) {
+ haslock = (link(tmp,LockFile) == 0);
+ if (haslock) {
+ /*
+ * We're done.
+ */
+ break;
+ }
+ else {
+ /*
+ * Read the pid from the existing file
+ */
+ lfd = open(LockFile, O_RDONLY);
+ if (lfd < 0) {
+ unlink(tmp);
+ FatalError("Can't read lock file %s\n", LockFile);
+ }
+ pid_str[0] = '\0';
+ if (read(lfd, pid_str, 11) != 11) {
+ /*
+ * Bogus lock file.
+ */
+ unlink(LockFile);
+ close(lfd);
+ continue;
+ }
+ pid_str[11] = '\0';
+ sscanf(pid_str, "%d", &l_pid);
+ close(lfd);
+
+ /*
+ * Now try to kill the PID to see if it exists.
+ */
+ errno = 0;
+ t = kill(l_pid, 0);
+ if ((t< 0) && (errno == ESRCH)) {
+ /*
+ * Stale lock file.
+ */
+ unlink(LockFile);
+ continue;
+ }
+ else if (((t < 0) && (errno == EPERM)) || (t == 0)) {
+ /*
+ * Process is still active.
+ */
+ unlink(tmp);
+ FatalError("Server is already active for display %s\n%s %s\n%s\n",
+ port, "\tIf this server is no longer running, remove",
+ LockFile, "\tand start again.");
+ }
+ }
+ }
+ unlink(tmp);
+ if (!haslock)
+ FatalError("Could not create server lock file: %s\n", LockFile);
+ StillLocking = FALSE;
+}
+
+/*
+ * UnlockServer --
+ * Remove the server lock file.
+ */
+void
+UnlockServer(void)
+{
+ if (nolock) return;
+
+ if (!StillLocking){
+
+#ifdef __UNIXOS2__
+ (void) chmod(LockFile,S_IREAD|S_IWRITE);
+#endif /* __UNIXOS2__ */
+ (void) unlink(LockFile);
+ }
+}
+#endif /* SERVER_LOCK */
+
+/* Force connections to close on SIGHUP from init */
+
+/*ARGSUSED*/
+SIGVAL
+AutoResetServer (int sig)
+{
+ int olderrno = errno;
+
+ dispatchException |= DE_RESET;
+ isItTimeToYield = TRUE;
+#ifdef GPROF
+ chdir ("/tmp");
+ exit (0);
+#endif
+#if defined(SYSV) && defined(X_NOT_POSIX)
+ OsSignal (SIGHUP, AutoResetServer);
+#endif
+ errno = olderrno;
+}
+
+/* Force connections to close and then exit on SIGTERM, SIGINT */
+
+/*ARGSUSED*/
+SIGVAL
+GiveUp(int sig)
+{
+ int olderrno = errno;
+
+#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST)
+ fprintf(stderr, "GiveUp: Called with signal [%d].\n", sig);
+#endif
+
+ dispatchException |= DE_TERMINATE;
+ isItTimeToYield = TRUE;
+#if defined(SYSV) && defined(X_NOT_POSIX)
+ if (sig)
+ OsSignal(sig, SIG_IGN);
+#endif
+ errno = olderrno;
+}
+
+#ifndef DDXTIME
+CARD32
+GetTimeInMillis(void)
+{
+ struct timeval tp;
+
+ X_GETTIMEOFDAY(&tp);
+ return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);
+}
+#endif
+
+void
+AdjustWaitForDelay (pointer waitTime, unsigned long newdelay)
+{
+ static struct timeval delay_val;
+ struct timeval **wt = (struct timeval **) waitTime;
+ unsigned long olddelay;
+
+ if (*wt == NULL)
+ {
+ delay_val.tv_sec = newdelay / 1000;
+ delay_val.tv_usec = 1000 * (newdelay % 1000);
+ *wt = &delay_val;
+ }
+ else
+ {
+ olddelay = (*wt)->tv_sec * 1000 + (*wt)->tv_usec / 1000;
+ if (newdelay < olddelay)
+ {
+ (*wt)->tv_sec = newdelay / 1000;
+ (*wt)->tv_usec = 1000 * (newdelay % 1000);
+ }
+ }
+}
+
+void UseMsg(void)
+{
+#if !defined(AIXrt) && !defined(AIX386)
+ ErrorF("use: X [:<display>] [option]\n");
+ ErrorF("-a # mouse acceleration (pixels)\n");
+ ErrorF("-ac disable access control restrictions\n");
+#ifdef MEMBUG
+ ErrorF("-alloc int chance alloc should fail\n");
+#endif
+ ErrorF("-audit int set audit trail level\n");
+ ErrorF("-auth file select authorization file\n");
+ ErrorF("bc enable bug compatibility\n");
+ ErrorF("-br create root window with black background\n");
+ ErrorF("+bs enable any backing store support\n");
+ ErrorF("-bs disable any backing store support\n");
+ ErrorF("-c turns off key-click\n");
+ ErrorF("c # key-click volume (0-100)\n");
+ ErrorF("-cc int default color visual class\n");
+ ErrorF("-co file color database file\n");
+#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
+ ErrorF("-config file read options from file\n");
+#endif
+ ErrorF("-core generate core dump on fatal error\n");
+ ErrorF("-dpi int screen resolution in dots per inch\n");
+#ifdef DPMSExtension
+ ErrorF("dpms enables VESA DPMS monitor control\n");
+ ErrorF("-dpms disables VESA DPMS monitor control\n");
+#endif
+ ErrorF("-deferglyphs [none|all|16] defer loading of [no|all|16-bit] glyphs\n");
+ ErrorF("-f # bell base (0-100)\n");
+ ErrorF("-fc string cursor font\n");
+ ErrorF("-fn string default font name\n");
+ ErrorF("-fp string default font path\n");
+ ErrorF("-help prints message with these options\n");
+ ErrorF("-I ignore all remaining arguments\n");
+#ifdef RLIMIT_DATA
+ ErrorF("-ld int limit data space to N Kb\n");
+#endif
+#ifdef RLIMIT_NOFILE
+ ErrorF("-lf int limit number of open files to N\n");
+#endif
+#ifdef RLIMIT_STACK
+ ErrorF("-ls int limit stack space to N Kb\n");
+#endif
+#ifdef SERVER_LOCK
+ ErrorF("-nolock disable the locking mechanism\n");
+#endif
+#ifndef NOLOGOHACK
+ ErrorF("-logo enable logo in screen saver\n");
+ ErrorF("nologo disable logo in screen saver\n");
+#endif
+ ErrorF("-nolisten string don't listen on protocol\n");
+ ErrorF("-noreset don't reset after last client exists\n");
+ ErrorF("-reset reset after last client exists\n");
+ ErrorF("-p # screen-saver pattern duration (minutes)\n");
+ ErrorF("-pn accept failure to listen on all ports\n");
+ ErrorF("-nopn reject failure to listen on all ports\n");
+ ErrorF("-r turns off auto-repeat\n");
+ ErrorF("r turns on auto-repeat \n");
+#ifdef RENDER
+ ErrorF("-render [default|mono|gray|color] set render color alloc policy\n");
+#endif
+ ErrorF("-s # screen-saver timeout (minutes)\n");
+#ifdef XCSECURITY
+ ErrorF("-sp file security policy file\n");
+#endif
+#ifdef XPRINT
+ PrinterUseMsg();
+#endif
+ ErrorF("-su disable any save under support\n");
+ ErrorF("-t # mouse threshold (pixels)\n");
+ ErrorF("-terminate terminate at server reset\n");
+ ErrorF("-to # connection time out\n");
+ ErrorF("-tst disable testing extensions\n");
+ ErrorF("ttyxx server started from init on /dev/ttyxx\n");
+ ErrorF("v video blanking for screen-saver\n");
+ ErrorF("-v screen-saver without video blanking\n");
+ ErrorF("-wm WhenMapped default backing-store\n");
+ ErrorF("-x string loads named extension at init time \n");
+ ErrorF("-maxbigreqsize set maximal bigrequest size \n");
+#ifdef PANORAMIX
+ ErrorF("+xinerama Enable XINERAMA extension\n");
+ ErrorF("-xinerama Disable XINERAMA extension\n");
+#endif
+#ifdef SMART_SCHEDULE
+ ErrorF("-dumbSched Disable smart scheduling, enable old behavior\n");
+ ErrorF("-schedInterval int Set scheduler interval in msec\n");
+#endif
+ ErrorF("+extension name Enable extension\n");
+ ErrorF("-extension name Disable extension\n");
+#ifdef XDMCP
+ XdmcpUseMsg();
+#endif
+#endif /* !AIXrt && ! AIX386 */
+#ifdef XKB
+ XkbUseMsg();
+#endif
+ ddxUseMsg();
+}
+
+/* This function performs a rudimentary sanity check
+ * on the display name passed in on the command-line,
+ * since this string is used to generate filenames.
+ * It is especially important that the display name
+ * not contain a "/" and not start with a "-".
+ * --kvajk
+ */
+static int
+VerifyDisplayName(const char *d)
+{
+ if ( d == (char *)0 ) return( 0 ); /* null */
+ if ( *d == '\0' ) return( 0 ); /* empty */
+ if ( *d == '-' ) return( 0 ); /* could be confused for an option */
+ if ( *d == '.' ) return( 0 ); /* must not equal "." or ".." */
+ if ( strchr(d, '/') != (char *)0 ) return( 0 ); /* very important!!! */
+ return( 1 );
+}
+
+/*
+ * This function is responsible for doing initalisation of any global
+ * variables at an very early point of server startup (even before
+ * |ProcessCommandLine()|.
+ */
+void InitGlobals(void)
+{
+ ddxInitGlobals();
+}
+
+
+/*
+ * This function parses the command line. Handles device-independent fields
+ * and allows ddx to handle additional fields. It is not allowed to modify
+ * argc or any of the strings pointed to by argv.
+ */
+void
+ProcessCommandLine(int argc, char *argv[])
+{
+ int i, skip;
+
+ defaultKeyboardControl.autoRepeat = TRUE;
+
+#ifdef NO_PART_NET
+ PartialNetwork = FALSE;
+#else
+ PartialNetwork = TRUE;
+#endif
+
+ for ( i = 1; i < argc; i++ )
+ {
+ /* call ddx first, so it can peek/override if it wants */
+ if((skip = ddxProcessArgument(argc, argv, i)))
+ {
+ i += (skip - 1);
+ }
+ else if(argv[i][0] == ':')
+ {
+ /* initialize display */
+ display = argv[i];
+ display++;
+ if( ! VerifyDisplayName( display ) ) {
+ ErrorF("Bad display name: %s\n", display);
+ UseMsg();
+ FatalError("Bad display name, exiting: %s\n", display);
+ }
+ }
+ else if ( strcmp( argv[i], "-a") == 0)
+ {
+ if(++i < argc)
+ defaultPointerControl.num = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-ac") == 0)
+ {
+ defeatAccessControl = TRUE;
+ }
+#ifdef MEMBUG
+ else if ( strcmp( argv[i], "-alloc") == 0)
+ {
+ if(++i < argc)
+ Memory_fail = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+#endif
+ else if ( strcmp( argv[i], "-audit") == 0)
+ {
+ if(++i < argc)
+ auditTrailLevel = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-auth") == 0)
+ {
+ if(++i < argc)
+ InitAuthorization (argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "bc") == 0)
+ permitOldBugs = TRUE;
+ else if ( strcmp( argv[i], "-br") == 0)
+ blackRoot = TRUE;
+ else if ( strcmp( argv[i], "+bs") == 0)
+ enableBackingStore = TRUE;
+ else if ( strcmp( argv[i], "-bs") == 0)
+ disableBackingStore = TRUE;
+ else if ( strcmp( argv[i], "c") == 0)
+ {
+ if(++i < argc)
+ defaultKeyboardControl.click = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-c") == 0)
+ {
+ defaultKeyboardControl.click = 0;
+ }
+ else if ( strcmp( argv[i], "-cc") == 0)
+ {
+ if(++i < argc)
+ defaultColorVisualClass = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-co") == 0)
+ {
+ if(++i < argc)
+ rgbPath = argv[i];
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-core") == 0)
+ CoreDump = TRUE;
+ else if ( strcmp( argv[i], "-dpi") == 0)
+ {
+ if(++i < argc)
+ monitorResolution = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+#ifdef DPMSExtension
+ else if ( strcmp( argv[i], "dpms") == 0)
+ DPMSEnabledSwitch = TRUE;
+ else if ( strcmp( argv[i], "-dpms") == 0)
+ DPMSDisabledSwitch = TRUE;
+#endif
+ else if ( strcmp( argv[i], "-deferglyphs") == 0)
+ {
+ if(++i >= argc || !ParseGlyphCachingMode(argv[i]))
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-f") == 0)
+ {
+ if(++i < argc)
+ defaultKeyboardControl.bell = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-fc") == 0)
+ {
+ if(++i < argc)
+ defaultCursorFont = argv[i];
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-fn") == 0)
+ {
+ if(++i < argc)
+ defaultTextFont = argv[i];
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-fp") == 0)
+ {
+ if(++i < argc)
+ {
+#ifdef sgi
+ userdefinedfontpath = 1;
+#endif /* sgi */
+ defaultFontPath = argv[i];
+ }
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-help") == 0)
+ {
+ UseMsg();
+ exit(0);
+ }
+#ifdef XKB
+ else if ( (skip=XkbProcessArguments(argc,argv,i))!=0 ) {
+ if (skip>0)
+ i+= skip-1;
+ else UseMsg();
+ }
+#endif
+#ifdef RLIMIT_DATA
+ else if ( strcmp( argv[i], "-ld") == 0)
+ {
+ if(++i < argc)
+ {
+ limitDataSpace = atoi(argv[i]);
+ if (limitDataSpace > 0)
+ limitDataSpace *= 1024;
+ }
+ else
+ UseMsg();
+ }
+#endif
+#ifdef RLIMIT_NOFILE
+ else if ( strcmp( argv[i], "-lf") == 0)
+ {
+ if(++i < argc)
+ limitNoFile = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+#endif
+#ifdef RLIMIT_STACK
+ else if ( strcmp( argv[i], "-ls") == 0)
+ {
+ if(++i < argc)
+ {
+ limitStackSpace = atoi(argv[i]);
+ if (limitStackSpace > 0)
+ limitStackSpace *= 1024;
+ }
+ else
+ UseMsg();
+ }
+#endif
+#ifdef SERVER_LOCK
+ else if ( strcmp ( argv[i], "-nolock") == 0)
+ {
+#if !defined(WIN32) && !defined(__UNIXOS2__) && !defined(__CYGWIN__)
+ if (getuid() != 0)
+ ErrorF("Warning: the -nolock option can only be used by root\n");
+ else
+#endif
+ nolock = TRUE;
+ }
+#endif
+#ifndef NOLOGOHACK
+ else if ( strcmp( argv[i], "-logo") == 0)
+ {
+ logoScreenSaver = 1;
+ }
+ else if ( strcmp( argv[i], "nologo") == 0)
+ {
+ logoScreenSaver = 0;
+ }
+#endif
+ else if ( strcmp( argv[i], "-nolisten") == 0)
+ {
+ if(++i < argc) {
+ if (_XSERVTransNoListen(argv[i]))
+ FatalError ("Failed to disable listen for %s transport",
+ argv[i]);
+ } else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-noreset") == 0)
+ {
+ dispatchExceptionAtReset = 0;
+ }
+ else if ( strcmp( argv[i], "-reset") == 0)
+ {
+ dispatchExceptionAtReset = DE_RESET;
+ }
+ else if ( strcmp( argv[i], "-p") == 0)
+ {
+ if(++i < argc)
+ defaultScreenSaverInterval = ((CARD32)atoi(argv[i])) *
+ MILLI_PER_MIN;
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-pn") == 0)
+ PartialNetwork = TRUE;
+ else if ( strcmp( argv[i], "-nopn") == 0)
+ PartialNetwork = FALSE;
+ else if ( strcmp( argv[i], "r") == 0)
+ defaultKeyboardControl.autoRepeat = TRUE;
+ else if ( strcmp( argv[i], "-r") == 0)
+ defaultKeyboardControl.autoRepeat = FALSE;
+ else if ( strcmp( argv[i], "-s") == 0)
+ {
+ if(++i < argc)
+ defaultScreenSaverTime = ((CARD32)atoi(argv[i])) *
+ MILLI_PER_MIN;
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-su") == 0)
+ disableSaveUnders = TRUE;
+ else if ( strcmp( argv[i], "-t") == 0)
+ {
+ if(++i < argc)
+ defaultPointerControl.threshold = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-terminate") == 0)
+ {
+ dispatchExceptionAtReset = DE_TERMINATE;
+ }
+ else if ( strcmp( argv[i], "-to") == 0)
+ {
+ if(++i < argc)
+ TimeOutValue = ((CARD32)atoi(argv[i])) * MILLI_PER_SECOND;
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-tst") == 0)
+ {
+ noTestExtensions = TRUE;
+ }
+ else if ( strcmp( argv[i], "v") == 0)
+ defaultScreenSaverBlanking = PreferBlanking;
+ else if ( strcmp( argv[i], "-v") == 0)
+ defaultScreenSaverBlanking = DontPreferBlanking;
+ else if ( strcmp( argv[i], "-wm") == 0)
+ defaultBackingStore = WhenMapped;
+ else if ( strcmp( argv[i], "-maxbigreqsize") == 0) {
+ if(++i < argc) {
+ long reqSizeArg = atol(argv[i]);
+
+ /* Request size > 128MB does not make much sense... */
+ if( reqSizeArg > 0L && reqSizeArg < 128L ) {
+ maxBigRequestSize = (reqSizeArg * 1048576L) - 1L;
+ }
+ else
+ {
+ UseMsg();
+ }
+ }
+ else
+ {
+ UseMsg();
+ }
+ }
+#ifdef PANORAMIX
+ else if ( strcmp( argv[i], "+xinerama") == 0){
+ noPanoramiXExtension = FALSE;
+ }
+ else if ( strcmp( argv[i], "-xinerama") == 0){
+ noPanoramiXExtension = TRUE;
+ }
+ else if ( strcmp( argv[i], "-disablexineramaextension") == 0){
+ PanoramiXExtensionDisabledHack = TRUE;
+ }
+#endif
+ else if ( strcmp( argv[i], "-x") == 0)
+ {
+ if(++i >= argc)
+ UseMsg();
+ /* For U**x, which doesn't support dynamic loading, there's nothing
+ * to do when we see a -x. Either the extension is linked in or
+ * it isn't */
+ }
+ else if ( strcmp( argv[i], "-I") == 0)
+ {
+ /* ignore all remaining arguments */
+ break;
+ }
+ else if (strncmp (argv[i], "tty", 3) == 0)
+ {
+ /* just in case any body is interested */
+ dev_tty_from_init = argv[i];
+ }
+#ifdef XDMCP
+ else if ((skip = XdmcpOptions(argc, argv, i)) != i)
+ {
+ i = skip - 1;
+ }
+#endif
+#ifdef XPRINT
+ else if ((skip = PrinterOptions(argc, argv, i)) != i)
+ {
+ i = skip - 1;
+ }
+#endif
+#ifdef XCSECURITY
+ else if ((skip = XSecurityOptions(argc, argv, i)) != i)
+ {
+ i = skip - 1;
+ }
+#endif
+#ifdef AIXV3
+ else if ( strcmp( argv[i], "-timeout") == 0)
+ {
+ if(++i < argc)
+ SelectWaitTime = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-sync") == 0)
+ {
+ SyncOn++;
+ }
+#endif
+#ifdef SMART_SCHEDULE
+ else if ( strcmp( argv[i], "-dumbSched") == 0)
+ {
+ SmartScheduleDisable = TRUE;
+ }
+ else if ( strcmp( argv[i], "-schedInterval") == 0)
+ {
+ if (++i < argc)
+ {
+ SmartScheduleInterval = atoi(argv[i]);
+ SmartScheduleSlice = SmartScheduleInterval;
+ }
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-schedMax") == 0)
+ {
+ if (++i < argc)
+ {
+ SmartScheduleMaxSlice = atoi(argv[i]);
+ }
+ else
+ UseMsg();
+ }
+#endif
+#ifdef RENDER
+ else if ( strcmp( argv[i], "-render" ) == 0)
+ {
+ if (++i < argc)
+ {
+ int policy = PictureParseCmapPolicy (argv[i]);
+
+ if (policy != PictureCmapPolicyInvalid)
+ PictureCmapPolicy = policy;
+ else
+ UseMsg ();
+ }
+ else
+ UseMsg ();
+ }
+#endif
+ else if ( strcmp( argv[i], "+extension") == 0)
+ {
+ if (++i < argc)
+ {
+ if (!EnableDisableExtension(argv[i], TRUE))
+ EnableDisableExtensionError(argv[i], TRUE);
+ }
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-extension") == 0)
+ {
+ if (++i < argc)
+ {
+ if (!EnableDisableExtension(argv[i], FALSE))
+ EnableDisableExtensionError(argv[i], FALSE);
+ }
+ else
+ UseMsg();
+ }
+ else
+ {
+ ErrorF("Unrecognized option: %s\n", argv[i]);
+ UseMsg();
+ FatalError("Unrecognized option: %s\n", argv[i]);
+ }
+ }
+}
+
+#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
+static void
+InsertFileIntoCommandLine(
+ int *resargc, char ***resargv,
+ int prefix_argc, char **prefix_argv,
+ char *filename,
+ int suffix_argc, char **suffix_argv)
+{
+ struct stat st;
+ FILE *f;
+ char *p;
+ char *q;
+ int insert_argc;
+ char *buf;
+ int len;
+ int i;
+
+ f = fopen(filename, "r");
+ if (!f)
+ FatalError("Can't open option file %s\n", filename);
+
+ fstat(fileno(f), &st);
+
+ buf = (char *) xalloc((unsigned) st.st_size + 1);
+ if (!buf)
+ FatalError("Out of Memory\n");
+
+ len = fread(buf, 1, (unsigned) st.st_size, f);
+
+ fclose(f);
+
+ if (len < 0)
+ FatalError("Error reading option file %s\n", filename);
+
+ buf[len] = '\0';
+
+ p = buf;
+ q = buf;
+ insert_argc = 0;
+
+ while (*p)
+ {
+ while (isspace(*p))
+ p++;
+ if (!*p)
+ break;
+ if (*p == '#')
+ {
+ while (*p && *p != '\n')
+ p++;
+ } else
+ {
+ while (*p && !isspace(*p))
+ *q++ = *p++;
+ /* Since p and q might still be pointing at the same place, we */
+ /* need to step p over the whitespace now before we add the null. */
+ if (*p)
+ p++;
+ *q++ = '\0';
+ insert_argc++;
+ }
+ }
+
+ buf = (char *) xrealloc(buf, q - buf);
+ if (!buf)
+ FatalError("Out of memory reallocing option buf\n");
+
+ *resargc = prefix_argc + insert_argc + suffix_argc;
+ *resargv = (char **) xalloc((*resargc + 1) * sizeof(char *));
+ if (!*resargv)
+ FatalError("Out of Memory\n");
+
+ memcpy(*resargv, prefix_argv, prefix_argc * sizeof(char *));
+
+ p = buf;
+ for (i = 0; i < insert_argc; i++)
+ {
+ (*resargv)[prefix_argc + i] = p;
+ p += strlen(p) + 1;
+ }
+
+ memcpy(*resargv + prefix_argc + insert_argc,
+ suffix_argv, suffix_argc * sizeof(char *));
+
+ (*resargv)[*resargc] = NULL;
+} /* end InsertFileIntoCommandLine */
+
+
+void
+ExpandCommandLine(int *pargc, char ***pargv)
+{
+ int i;
+
+#if !defined(WIN32) && !defined(__UNIXOS2__) && !defined(__CYGWIN__)
+ if (getuid() != geteuid())
+ return;
+#endif
+
+ for (i = 1; i < *pargc; i++)
+ {
+ if ( (0 == strcmp((*pargv)[i], "-config")) && (i < (*pargc - 1)) )
+ {
+ InsertFileIntoCommandLine(pargc, pargv,
+ i, *pargv,
+ (*pargv)[i+1], /* filename */
+ *pargc - i - 2, *pargv + i + 2);
+ i--;
+ }
+ }
+} /* end ExpandCommandLine */
+#endif
+
+/* Implement a simple-minded font authorization scheme. The authorization
+ name is "hp-hostname-1", the contents are simply the host name. */
+int
+set_font_authorizations(char **authorizations, int *authlen, pointer client)
+{
+#define AUTHORIZATION_NAME "hp-hostname-1"
+#if defined(TCPCONN) || defined(STREAMSCONN)
+ static char *result = NULL;
+ static char *p = NULL;
+
+ if (p == NULL)
+ {
+ char hname[1024], *hnameptr;
+ unsigned int len;
+#if defined(IPv6) && defined(AF_INET6)
+ struct addrinfo hints, *ai = NULL;
+#else
+ struct hostent *host;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+#endif
+
+ gethostname(hname, 1024);
+#if defined(IPv6) && defined(AF_INET6)
+ bzero(&hints, sizeof(hints));
+ hints.ai_flags = AI_CANONNAME;
+ if (getaddrinfo(hname, NULL, &hints, &ai) == 0) {
+ hnameptr = ai->ai_canonname;
+ } else {
+ hnameptr = hname;
+ }
+#else
+ host = _XGethostbyname(hname, hparams);
+ if (host == NULL)
+ hnameptr = hname;
+ else
+ hnameptr = host->h_name;
+#endif
+
+ len = strlen(hnameptr) + 1;
+ result = xalloc(len + sizeof(AUTHORIZATION_NAME) + 4);
+
+ p = result;
+ *p++ = sizeof(AUTHORIZATION_NAME) >> 8;
+ *p++ = sizeof(AUTHORIZATION_NAME) & 0xff;
+ *p++ = (len) >> 8;
+ *p++ = (len & 0xff);
+
+ memmove(p, AUTHORIZATION_NAME, sizeof(AUTHORIZATION_NAME));
+ p += sizeof(AUTHORIZATION_NAME);
+ memmove(p, hnameptr, len);
+ p += len;
+#if defined(IPv6) && defined(AF_INET6)
+ if (ai) {
+ freeaddrinfo(ai);
+ }
+#endif
+ }
+ *authlen = p - result;
+ *authorizations = result;
+ return 1;
+#else /* TCPCONN */
+ return 0;
+#endif /* TCPCONN */
+}
+
+/* XALLOC -- X's internal memory allocator. Why does it return unsigned
+ * long * instead of the more common char *? Well, if you read K&R you'll
+ * see they say that alloc must return a pointer "suitable for conversion"
+ * to whatever type you really want. In a full-blown generic allocator
+ * there's no way to solve the alignment problems without potentially
+ * wasting lots of space. But we have a more limited problem. We know
+ * we're only ever returning pointers to structures which will have to
+ * be long word aligned. So we are making a stronger guarantee. It might
+ * have made sense to make Xalloc return char * to conform with people's
+ * expectations of malloc, but this makes lint happier.
+ */
+
+#ifndef INTERNAL_MALLOC
+
+void *
+Xalloc(unsigned long amount)
+{
+ register pointer ptr;
+
+ if ((long)amount <= 0) {
+ return (unsigned long *)NULL;
+ }
+ /* aligned extra on long word boundary */
+ amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
+#ifdef MEMBUG
+ if (!Must_have_memory && Memory_fail &&
+ ((random() % MEM_FAIL_SCALE) < Memory_fail))
+ return (unsigned long *)NULL;
+#endif
+ if ((ptr = (pointer)malloc(amount))) {
+ return (unsigned long *)ptr;
+ }
+ if (Must_have_memory)
+ FatalError("Out of memory");
+ return (unsigned long *)NULL;
+}
+
+/*****************
+ * XNFalloc
+ * "no failure" realloc, alternate interface to Xalloc w/o Must_have_memory
+ *****************/
+
+void *
+XNFalloc(unsigned long amount)
+{
+ register pointer ptr;
+
+ if ((long)amount <= 0)
+ {
+ return (unsigned long *)NULL;
+ }
+ /* aligned extra on long word boundary */
+ amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
+ ptr = (pointer)malloc(amount);
+ if (!ptr)
+ {
+ FatalError("Out of memory");
+ }
+ return ((unsigned long *)ptr);
+}
+
+/*****************
+ * Xcalloc
+ *****************/
+
+void *
+Xcalloc(unsigned long amount)
+{
+ unsigned long *ret;
+
+ ret = Xalloc (amount);
+ if (ret)
+ bzero ((char *) ret, (int) amount);
+ return ret;
+}
+
+/*****************
+ * XNFcalloc
+ *****************/
+
+void *
+XNFcalloc(unsigned long amount)
+{
+ unsigned long *ret;
+
+ ret = Xalloc (amount);
+ if (ret)
+ bzero ((char *) ret, (int) amount);
+ else if ((long)amount > 0)
+ FatalError("Out of memory");
+ return ret;
+}
+
+/*****************
+ * Xrealloc
+ *****************/
+
+void *
+Xrealloc(pointer ptr, unsigned long amount)
+{
+#ifdef MEMBUG
+ if (!Must_have_memory && Memory_fail &&
+ ((random() % MEM_FAIL_SCALE) < Memory_fail))
+ return (unsigned long *)NULL;
+#endif
+ if ((long)amount <= 0)
+ {
+ if (ptr && !amount)
+ free(ptr);
+ return (unsigned long *)NULL;
+ }
+ amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
+ if (ptr)
+ ptr = (pointer)realloc((char *)ptr, amount);
+ else
+ ptr = (pointer)malloc(amount);
+ if (ptr)
+ return (unsigned long *)ptr;
+ if (Must_have_memory)
+ FatalError("Out of memory");
+ return (unsigned long *)NULL;
+}
+
+/*****************
+ * XNFrealloc
+ * "no failure" realloc, alternate interface to Xrealloc w/o Must_have_memory
+ *****************/
+
+void *
+XNFrealloc(pointer ptr, unsigned long amount)
+{
+ if (( ptr = (pointer)Xrealloc( ptr, amount ) ) == NULL)
+ {
+ if ((long)amount > 0)
+ FatalError( "Out of memory" );
+ }
+ return ((unsigned long *)ptr);
+}
+
+/*****************
+ * Xfree
+ * calls free
+ *****************/
+
+void
+Xfree(pointer ptr)
+{
+ if (ptr)
+ free((char *)ptr);
+}
+
+void
+OsInitAllocator (void)
+{
+#ifdef MEMBUG
+ static int been_here;
+
+ /* Check the memory system after each generation */
+ if (been_here)
+ CheckMemory ();
+ else
+ been_here = 1;
+#endif
+}
+#endif /* !INTERNAL_MALLOC */
+
+
+char *
+Xstrdup(const char *s)
+{
+ char *sd;
+
+ if (s == NULL)
+ return NULL;
+
+ sd = (char *)Xalloc(strlen(s) + 1);
+ if (sd != NULL)
+ strcpy(sd, s);
+ return sd;
+}
+
+
+char *
+XNFstrdup(const char *s)
+{
+ char *sd;
+
+ if (s == NULL)
+ return NULL;
+
+ sd = (char *)XNFalloc(strlen(s) + 1);
+ strcpy(sd, s);
+ return sd;
+}
+
+#ifdef SMART_SCHEDULE
+
+unsigned long SmartScheduleIdleCount;
+Bool SmartScheduleIdle;
+Bool SmartScheduleTimerStopped;
+
+#ifdef SIGVTALRM
+#define SMART_SCHEDULE_POSSIBLE
+#endif
+
+#ifdef SMART_SCHEDULE_POSSIBLE
+#define SMART_SCHEDULE_SIGNAL SIGALRM
+#define SMART_SCHEDULE_TIMER ITIMER_REAL
+#endif
+
+#ifdef NX_TRANS_SOCKET
+void
+SmartScheduleStopTimer (void)
+#else
+static void
+SmartScheduleStopTimer (void)
+#endif
+{
+#ifdef SMART_SCHEDULE_POSSIBLE
+ struct itimerval timer;
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "SmartScheduleStopTimer: Stopping timer.\n");
+ #endif
+
+ timer.it_interval.tv_sec = 0;
+ timer.it_interval.tv_usec = 0;
+ timer.it_value.tv_sec = 0;
+ timer.it_value.tv_usec = 0;
+ (void) setitimer (ITIMER_REAL, &timer, 0);
+ SmartScheduleTimerStopped = TRUE;
+#endif
+}
+
+Bool
+SmartScheduleStartTimer (void)
+{
+#ifdef SMART_SCHEDULE_POSSIBLE
+ struct itimerval timer;
+
+ #ifdef NX_TRANS_SOCKET
+
+ if (SmartScheduleDisable)
+ {
+ return FALSE;
+ }
+
+ #endif
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "SmartScheduleStartTimer: Starting timer with [%ld] ms.\n",
+ SmartScheduleInterval);
+ #endif
+
+ SmartScheduleTimerStopped = FALSE;
+ timer.it_interval.tv_sec = 0;
+ timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
+ timer.it_value.tv_sec = 0;
+ timer.it_value.tv_usec = SmartScheduleInterval * 1000;
+ return setitimer (ITIMER_REAL, &timer, 0) >= 0;
+#endif
+ return FALSE;
+}
+
+#ifdef SMART_SCHEDULE_POSSIBLE
+static void
+SmartScheduleTimer (int sig)
+{
+ int olderrno = errno;
+
+ SmartScheduleTime += SmartScheduleInterval;
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "SmartScheduleTimer: Got timer with time [%ld] ms.\n",
+ SmartScheduleTime);
+ #endif
+
+ if (SmartScheduleIdle)
+ {
+ SmartScheduleStopTimer ();
+ }
+ errno = olderrno;
+}
+#endif
+
+Bool
+SmartScheduleInit (void)
+{
+#ifdef SMART_SCHEDULE_POSSIBLE
+ struct sigaction act;
+
+ if (SmartScheduleDisable)
+ return TRUE;
+
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "SmartScheduleInit: Initializing the smart scheduler.\n");
+ #endif
+
+ bzero ((char *) &act, sizeof(struct sigaction));
+
+ /* Set up the timer signal function */
+ act.sa_handler = SmartScheduleTimer;
+ sigemptyset (&act.sa_mask);
+ sigaddset (&act.sa_mask, SMART_SCHEDULE_SIGNAL);
+ if (sigaction (SMART_SCHEDULE_SIGNAL, &act, 0) < 0)
+ {
+ perror ("sigaction for smart scheduler");
+ return FALSE;
+ }
+ /* Set up the virtual timer */
+ if (!SmartScheduleStartTimer ())
+ {
+ perror ("scheduling timer");
+ return FALSE;
+ }
+ /* stop the timer and wait for WaitForSomething to start it */
+ SmartScheduleStopTimer ();
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+#endif
+
+#ifdef SIG_BLOCK
+static sigset_t PreviousSignalMask;
+static int BlockedSignalCount;
+#endif
+
+void
+OsBlockSignals (void)
+{
+#ifdef SIG_BLOCK
+ if (BlockedSignalCount++ == 0)
+ {
+ sigset_t set;
+
+ sigemptyset (&set);
+#ifdef SIGALRM
+ sigaddset (&set, SIGALRM);
+#endif
+#ifdef SIGVTALRM
+ sigaddset (&set, SIGVTALRM);
+#endif
+#ifdef SIGWINCH
+ sigaddset (&set, SIGWINCH);
+#endif
+#ifdef SIGIO
+ sigaddset (&set, SIGIO);
+#endif
+#ifdef SIGTSTP
+ sigaddset (&set, SIGTSTP);
+#endif
+#ifdef SIGTTIN
+ sigaddset (&set, SIGTTIN);
+#endif
+#ifdef SIGTTOU
+ sigaddset (&set, SIGTTOU);
+#endif
+#ifdef SIGCHLD
+ sigaddset (&set, SIGCHLD);
+#endif
+ sigprocmask (SIG_BLOCK, &set, &PreviousSignalMask);
+ }
+#endif
+}
+
+void
+OsReleaseSignals (void)
+{
+#ifdef SIG_BLOCK
+ if (--BlockedSignalCount == 0)
+ {
+ sigprocmask (SIG_SETMASK, &PreviousSignalMask, 0);
+ }
+#endif
+}
+
+#if !defined(WIN32) && !defined(__UNIXOS2__)
+/*
+ * "safer" versions of system(3), popen(3) and pclose(3) which give up
+ * all privs before running a command.
+ *
+ * This is based on the code in FreeBSD 2.2 libc.
+ *
+ * XXX It'd be good to redirect stderr so that it ends up in the log file
+ * as well. As it is now, xkbcomp messages don't end up in the log file.
+ */
+
+int
+System(char *command)
+{
+ int pid, p;
+#ifdef SIGCHLD
+ void (*csig)(int);
+#endif
+ int status;
+
+ if (!command)
+ return(1);
+
+#ifdef SIGCHLD
+ csig = signal(SIGCHLD, SIG_DFL);
+#endif
+
+#ifdef DEBUG
+ ErrorF("System: `%s'\n", command);
+#endif
+
+#ifdef NX_TRANS_EXIT
+ if (OsVendorStartRedirectErrorFProc != NULL) {
+ OsVendorStartRedirectErrorFProc();
+ }
+#endif
+ switch (pid = fork()) {
+ case -1: /* error */
+ p = -1;
+ case 0: /* child */
+ if (setgid(getgid()) == -1)
+ _exit(127);
+ if (setuid(getuid()) == -1)
+ _exit(127);
+ execl("/bin/sh", "sh", "-c", command, (char *)NULL);
+ _exit(127);
+ default: /* parent */
+ do {
+ p = waitpid(pid, &status, 0);
+ } while (p == -1 && errno == EINTR);
+
+ }
+#ifdef NX_TRANS_EXIT
+ if (OsVendorEndRedirectErrorFProc != NULL) {
+ OsVendorEndRedirectErrorFProc();
+ }
+#endif
+
+#ifdef SIGCHLD
+ signal(SIGCHLD, csig);
+#endif
+
+ return p == -1 ? -1 : status;
+}
+
+static struct pid {
+ struct pid *next;
+ FILE *fp;
+ int pid;
+} *pidlist;
+
+pointer
+Popen(char *command, char *type)
+{
+ struct pid *cur;
+ FILE *iop;
+ int pdes[2], pid;
+
+ if (command == NULL || type == NULL)
+ return NULL;
+
+ if ((*type != 'r' && *type != 'w') || type[1])
+ return NULL;
+
+ if ((cur = (struct pid *)xalloc(sizeof(struct pid))) == NULL)
+ return NULL;
+
+ if (pipe(pdes) < 0) {
+ xfree(cur);
+ return NULL;
+ }
+
+#ifdef NX_TRANS_EXIT
+ if (OsVendorStartRedirectErrorFProc != NULL) {
+ OsVendorStartRedirectErrorFProc();
+ }
+#endif
+ switch (pid = fork()) {
+ case -1: /* error */
+ close(pdes[0]);
+ close(pdes[1]);
+ xfree(cur);
+ return NULL;
+ case 0: /* child */
+ if (setgid(getgid()) == -1)
+ _exit(127);
+ if (setuid(getuid()) == -1)
+ _exit(127);
+ if (*type == 'r') {
+ if (pdes[1] != 1) {
+ /* stdout */
+ dup2(pdes[1], 1);
+ close(pdes[1]);
+ }
+ close(pdes[0]);
+ } else {
+ if (pdes[0] != 0) {
+ /* stdin */
+ dup2(pdes[0], 0);
+ close(pdes[0]);
+ }
+ close(pdes[1]);
+ }
+
+ #ifdef NX_TRANS_SOCKET
+
+ /*
+ * Check if the child process should not
+ * use the parent's libraries.
+ */
+
+ if (_NXUnsetLibraryPath)
+ {
+ #ifndef __sun
+
+ unsetenv ("LD_LIBRARY_PATH");
+
+ #else
+
+ extern char **environ;
+
+ char **ep = environ;
+
+ ep = environ;
+
+ while (*ep)
+ {
+ if (!strncmp("LD_LIBRARY_PATH=", *ep, strlen("LD_LIBRARY_PATH=")))
+ {
+ break;
+ }
+
+ *ep++;
+ }
+
+ while (*ep)
+ {
+ *ep = *(ep + 1);
+ ep++;
+ }
+
+ #endif
+ }
+
+ #endif
+
+ execl("/bin/sh", "sh", "-c", command, (char *)NULL);
+ _exit(127);
+ }
+
+ /* Avoid EINTR during stdio calls */
+ OsBlockSignals ();
+
+ /* parent */
+ if (*type == 'r') {
+ iop = fdopen(pdes[0], type);
+ close(pdes[1]);
+ } else {
+ iop = fdopen(pdes[1], type);
+ close(pdes[0]);
+ }
+
+ cur->fp = iop;
+ cur->pid = pid;
+ cur->next = pidlist;
+ pidlist = cur;
+
+#ifdef DEBUG
+ ErrorF("Popen: `%s', fp = %p\n", command, iop);
+#endif
+
+ return iop;
+}
+
+/* fopen that drops privileges */
+pointer
+Fopen(char *file, char *type)
+{
+ FILE *iop;
+#ifndef HAS_SAVED_IDS_AND_SETEUID
+ struct pid *cur;
+ int pdes[2], pid;
+
+ if (file == NULL || type == NULL)
+ return NULL;
+
+ if ((*type != 'r' && *type != 'w') || type[1])
+ return NULL;
+
+ if ((cur = (struct pid *)xalloc(sizeof(struct pid))) == NULL)
+ return NULL;
+
+ if (pipe(pdes) < 0) {
+ xfree(cur);
+ return NULL;
+ }
+
+ switch (pid = fork()) {
+ case -1: /* error */
+ close(pdes[0]);
+ close(pdes[1]);
+ xfree(cur);
+ return NULL;
+ case 0: /* child */
+ if (setgid(getgid()) == -1)
+ _exit(127);
+ if (setuid(getuid()) == -1)
+ _exit(127);
+ if (*type == 'r') {
+ if (pdes[1] != 1) {
+ /* stdout */
+ dup2(pdes[1], 1);
+ close(pdes[1]);
+ }
+ close(pdes[0]);
+ } else {
+ if (pdes[0] != 0) {
+ /* stdin */
+ dup2(pdes[0], 0);
+ close(pdes[0]);
+ }
+ close(pdes[1]);
+ }
+ execl("/bin/cat", "cat", file, (char *)NULL);
+ _exit(127);
+ }
+
+ /* Avoid EINTR during stdio calls */
+ OsBlockSignals ();
+
+ /* parent */
+ if (*type == 'r') {
+ iop = fdopen(pdes[0], type);
+ close(pdes[1]);
+ } else {
+ iop = fdopen(pdes[1], type);
+ close(pdes[0]);
+ }
+
+ cur->fp = iop;
+ cur->pid = pid;
+ cur->next = pidlist;
+ pidlist = cur;
+
+#ifdef DEBUG
+ ErrorF("Popen: `%s', fp = %p\n", command, iop);
+#endif
+
+ return iop;
+#else
+ int ruid, euid;
+
+ ruid = getuid();
+ euid = geteuid();
+
+ if (seteuid(ruid) == -1) {
+ return NULL;
+ }
+ iop = fopen(file, type);
+
+ if (seteuid(euid) == -1) {
+ fclose(iop);
+ return NULL;
+ }
+ return iop;
+#endif /* HAS_SAVED_IDS_AND_SETEUID */
+}
+
+int
+Pclose(pointer iop)
+{
+ struct pid *cur, *last;
+ int pstat;
+ int pid;
+
+#ifdef DEBUG
+ ErrorF("Pclose: fp = %p\n", iop);
+#endif
+
+ fclose(iop);
+
+ for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next)
+ if (cur->fp == iop)
+ break;
+ if (cur == NULL)
+ return -1;
+
+ do {
+ pid = waitpid(cur->pid, &pstat, 0);
+ } while (pid == -1 && errno == EINTR);
+
+ if (last == NULL)
+ pidlist = cur->next;
+ else
+ last->next = cur->next;
+ xfree(cur);
+
+ /* allow EINTR again */
+ OsReleaseSignals ();
+
+#ifdef NX_TRANS_EXIT
+ if (OsVendorEndRedirectErrorFProc != NULL) {
+ OsVendorEndRedirectErrorFProc();
+ }
+#endif
+ return pid == -1 ? -1 : pstat;
+}
+
+int
+Fclose(pointer iop)
+{
+#ifdef HAS_SAVED_IDS_AND_SETEUID
+ return fclose(iop);
+#else
+ return Pclose(iop);
+#endif
+}
+
+#endif /* !WIN32 && !__UNIXOS2__ */
+
+
+/*
+ * CheckUserParameters: check for long command line arguments and long
+ * environment variables. By default, these checks are only done when
+ * the server's euid != ruid. In 3.3.x, these checks were done in an
+ * external wrapper utility.
+ */
+
+/* Consider LD* variables insecure? */
+#ifndef REMOVE_ENV_LD
+#define REMOVE_ENV_LD 1
+#endif
+
+/* Remove long environment variables? */
+#ifndef REMOVE_LONG_ENV
+#define REMOVE_LONG_ENV 1
+#endif
+
+/*
+ * Disallow stdout or stderr as pipes? It's possible to block the X server
+ * when piping stdout+stderr to a pipe.
+ *
+ * Don't enable this because it looks like it's going to cause problems.
+ */
+#ifndef NO_OUTPUT_PIPES
+#define NO_OUTPUT_PIPES 0
+#endif
+
+
+/* Check args and env only if running setuid (euid == 0 && euid != uid) ? */
+#ifndef CHECK_EUID
+#ifndef WIN32
+#define CHECK_EUID 1
+#else
+#define CHECK_EUID 0
+#endif
+#endif
+
+/*
+ * Maybe the locale can be faked to make isprint(3) report that everything
+ * is printable? Avoid it by default.
+ */
+#ifndef USE_ISPRINT
+#define USE_ISPRINT 0
+#endif
+
+#define MAX_ARG_LENGTH 128
+#define MAX_ENV_LENGTH 256
+#define MAX_ENV_PATH_LENGTH 2048 /* Limit for *PATH and TERMCAP */
+
+#if USE_ISPRINT
+#include <ctype.h>
+#define checkPrintable(c) isprint(c)
+#else
+#define checkPrintable(c) (((c) & 0x7f) >= 0x20 && ((c) & 0x7f) != 0x7f)
+#endif
+
+enum BadCode {
+ NotBad = 0,
+ UnsafeArg,
+ ArgTooLong,
+ UnprintableArg,
+ EnvTooLong,
+ OutputIsPipe,
+ InternalError
+};
+
+#if defined(VENDORSUPPORT)
+#define BUGADDRESS VENDORSUPPORT
+#elif defined(BUILDERADDR)
+#define BUGADDRESS BUILDERADDR
+#else
+#define BUGADDRESS "xorg@freedesktop.org"
+#endif
+
+#define ARGMSG \
+ "\nIf the arguments used are valid, and have been rejected incorrectly\n" \
+ "please send details of the arguments and why they are valid to\n" \
+ "%s. In the meantime, you can start the Xserver as\n" \
+ "the \"super user\" (root).\n"
+
+#define ENVMSG \
+ "\nIf the environment is valid, and have been rejected incorrectly\n" \
+ "please send details of the environment and why it is valid to\n" \
+ "%s. In the meantime, you can start the Xserver as\n" \
+ "the \"super user\" (root).\n"
+
+void
+CheckUserParameters(int argc, char **argv, char **envp)
+{
+ enum BadCode bad = NotBad;
+ int i = 0, j;
+ char *a, *e = NULL;
+#if defined(__QNX__) && !defined(__QNXNTO__)
+ char cmd_name[64];
+#endif
+
+#if CHECK_EUID
+ if (geteuid() == 0 && getuid() != geteuid())
+#endif
+ {
+ /* Check each argv[] */
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-fp") == 0)
+ {
+ i++; /* continue with next argument. skip the length check */
+ if (i >= argc)
+ break;
+ } else
+ {
+ if (strlen(argv[i]) > MAX_ARG_LENGTH) {
+ bad = ArgTooLong;
+ break;
+ }
+ }
+ a = argv[i];
+ while (*a) {
+ if (checkPrintable(*a) == 0) {
+ bad = UnprintableArg;
+ break;
+ }
+ a++;
+ }
+ if (bad)
+ break;
+ }
+ if (!bad) {
+ /* Check each envp[] */
+ for (i = 0; envp[i]; i++) {
+
+ /* Check for bad environment variables and values */
+#if REMOVE_ENV_LD
+ while (envp[i] && (strncmp(envp[i], "LD", 2) == 0)) {
+#ifdef ENVDEBUG
+ ErrorF("CheckUserParameters: removing %s from the "
+ "environment\n", strtok(envp[i], "="));
+#endif
+ for (j = i; envp[j]; j++) {
+ envp[j] = envp[j+1];
+ }
+ }
+#endif
+ if (envp[i] && (strlen(envp[i]) > MAX_ENV_LENGTH)) {
+#if REMOVE_LONG_ENV
+#ifdef ENVDEBUG
+ ErrorF("CheckUserParameters: removing %s from the "
+ "environment\n", strtok(envp[i], "="));
+#endif
+ for (j = i; envp[j]; j++) {
+ envp[j] = envp[j+1];
+ }
+ i--;
+#else
+ char *eq;
+ int len;
+
+ eq = strchr(envp[i], '=');
+ if (!eq)
+ continue;
+ len = eq - envp[i];
+ e = malloc(len + 1);
+ if (!e) {
+ bad = InternalError;
+ break;
+ }
+ strncpy(e, envp[i], len);
+ e[len] = 0;
+ if (len >= 4 &&
+ (strcmp(e + len - 4, "PATH") == 0 ||
+ strcmp(e, "TERMCAP") == 0)) {
+ if (strlen(envp[i]) > MAX_ENV_PATH_LENGTH) {
+ bad = EnvTooLong;
+ break;
+ } else {
+ free(e);
+ }
+ } else {
+ bad = EnvTooLong;
+ break;
+ }
+#endif
+ }
+ }
+ }
+#if NO_OUTPUT_PIPES
+ if (!bad) {
+ struct stat buf;
+
+ if (fstat(fileno(stdout), &buf) == 0 && S_ISFIFO(buf.st_mode))
+ bad = OutputIsPipe;
+ if (fstat(fileno(stderr), &buf) == 0 && S_ISFIFO(buf.st_mode))
+ bad = OutputIsPipe;
+ }
+#endif
+ }
+ switch (bad) {
+ case NotBad:
+ return;
+ case UnsafeArg:
+ ErrorF("Command line argument number %d is unsafe\n", i);
+ ErrorF(ARGMSG, BUGADDRESS);
+ break;
+ case ArgTooLong:
+ ErrorF("Command line argument number %d is too long\n", i);
+ ErrorF(ARGMSG, BUGADDRESS);
+ break;
+ case UnprintableArg:
+ ErrorF("Command line argument number %d contains unprintable"
+ " characters\n", i);
+ ErrorF(ARGMSG, BUGADDRESS);
+ break;
+ case EnvTooLong:
+ ErrorF("Environment variable `%s' is too long\n", e);
+ ErrorF(ENVMSG, BUGADDRESS);
+ break;
+ case OutputIsPipe:
+ ErrorF("Stdout and/or stderr is a pipe\n");
+ break;
+ case InternalError:
+ ErrorF("Internal Error\n");
+ break;
+ default:
+ ErrorF("Unknown error\n");
+ ErrorF(ARGMSG, BUGADDRESS);
+ ErrorF(ENVMSG, BUGADDRESS);
+ break;
+ }
+ FatalError("X server aborted because of unsafe environment\n");
+}
+
+/*
+ * CheckUserAuthorization: check if the user is allowed to start the
+ * X server. This usually means some sort of PAM checking, and it is
+ * usually only done for setuid servers (uid != euid).
+ */
+
+#ifdef USE_PAM
+#include <security/pam_appl.h>
+#include <security/pam_misc.h>
+#include <pwd.h>
+#endif /* USE_PAM */
+
+void
+CheckUserAuthorization(void)
+{
+#ifdef USE_PAM
+ static struct pam_conv conv = {
+ misc_conv,
+ NULL
+ };
+
+ pam_handle_t *pamh = NULL;
+ struct passwd *pw;
+ int retval;
+
+ if (getuid() != geteuid()) {
+ pw = getpwuid(getuid());
+ if (pw == NULL)
+ FatalError("getpwuid() failed for uid %d\n", getuid());
+
+ retval = pam_start("xserver", pw->pw_name, &conv, &pamh);
+ if (retval != PAM_SUCCESS)
+ FatalError("pam_start() failed.\n"
+ "\tMissing or mangled PAM config file or module?\n");
+
+ retval = pam_authenticate(pamh, 0);
+ if (retval != PAM_SUCCESS) {
+ pam_end(pamh, retval);
+ FatalError("PAM authentication failed, cannot start X server.\n"
+ "\tPerhaps you do not have console ownership?\n");
+ }
+
+ retval = pam_acct_mgmt(pamh, 0);
+ if (retval != PAM_SUCCESS) {
+ pam_end(pamh, retval);
+ FatalError("PAM authentication failed, cannot start X server.\n"
+ "\tPerhaps you do not have console ownership?\n");
+ }
+
+ /* this is not a session, so do not do session management */
+ pam_end(pamh, PAM_SUCCESS);
+ }
+#endif
+}
+
+#ifdef __SCO__
+#include <fcntl.h>
+
+static void
+lockit (int fd, short what)
+{
+ struct flock lck;
+
+ lck.l_whence = 0;
+ lck.l_start = 0;
+ lck.l_len = 1;
+ lck.l_type = what;
+
+ (void)fcntl (fd, F_SETLKW, &lck);
+}
+
+/* SCO OpenServer 5 lacks pread/pwrite. Emulate them. */
+ssize_t
+pread (int fd, void *buf, size_t nbytes, off_t offset)
+{
+ off_t saved;
+ ssize_t ret;
+
+ lockit (fd, F_RDLCK);
+ saved = lseek (fd, 0, SEEK_CUR);
+ lseek (fd, offset, SEEK_SET);
+ ret = read (fd, buf, nbytes);
+ lseek (fd, saved, SEEK_SET);
+ lockit (fd, F_UNLCK);
+
+ return ret;
+}
+
+ssize_t
+pwrite (int fd, const void *buf, size_t nbytes, off_t offset)
+{
+ off_t saved;
+ ssize_t ret;
+
+ lockit (fd, F_WRLCK);
+ saved = lseek (fd, 0, SEEK_CUR);
+ lseek (fd, offset, SEEK_SET);
+ ret = write (fd, buf, nbytes);
+ lseek (fd, saved, SEEK_SET);
+ lockit (fd, F_UNLCK);
+
+ return ret;
+}
+#endif /* __SCO__ */
diff --git a/nx-X11/programs/Xserver/os/utils.c.X.original b/nx-X11/programs/Xserver/os/utils.c.X.original
new file mode 100644
index 000000000..b0a806fd7
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/utils.c.X.original
@@ -0,0 +1,2296 @@
+/* $XdotOrg: xc/programs/Xserver/os/utils.c,v 1.21 2005/11/08 06:33:30 jkj Exp $ */
+/* $Xorg: utils.c,v 1.5 2001/02/09 02:05:24 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1994 Quarterdeck Office Systems.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Digital and
+Quarterdeck not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+DIGITAL AND QUARTERDECK DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
+OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
+OR PERFORMANCE OF THIS SOFTWARE.
+
+*/
+/* $XFree86: xc/programs/Xserver/os/utils.c,v 3.96 2004/01/07 04:16:37 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef __CYGWIN__
+#include <stdlib.h>
+#include <signal.h>
+#endif
+
+#if defined(WIN32) && !defined(__CYGWIN__)
+#include <X11/Xwinsock.h>
+#endif
+#include <X11/Xos.h>
+#include <stdio.h>
+#include "misc.h"
+#include <X11/X.h>
+#include <X11/Xtrans/Xtrans.h>
+#include "input.h"
+#include "dixfont.h"
+#include "osdep.h"
+#ifdef X_POSIX_C_SOURCE
+#define _POSIX_C_SOURCE X_POSIX_C_SOURCE
+#include <signal.h>
+#undef _POSIX_C_SOURCE
+#else
+#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE)
+#include <signal.h>
+#else
+#define _POSIX_SOURCE
+#include <signal.h>
+#undef _POSIX_SOURCE
+#endif
+#endif
+#ifndef WIN32
+#include <sys/wait.h>
+#endif
+#if !defined(SYSV) && !defined(WIN32) && !defined(Lynx) && !defined(QNX4)
+#include <sys/resource.h>
+#endif
+#include <time.h>
+#include <sys/stat.h>
+#include <ctype.h> /* for isspace */
+#include <stdarg.h>
+
+#if defined(DGUX)
+#include <sys/resource.h>
+#include <netdb.h>
+#endif
+
+#include <stdlib.h> /* for malloc() */
+
+#if defined(TCPCONN) || defined(STREAMSCONN)
+# ifndef WIN32
+# include <netdb.h>
+# endif
+#endif
+
+#include "opaque.h"
+
+#ifdef SMART_SCHEDULE
+#include "dixstruct.h"
+#endif
+
+#ifdef XKB
+#include <X11/extensions/XKBsrv.h>
+#endif
+#ifdef XCSECURITY
+#define _SECURITY_SERVER
+#include <X11/extensions/security.h>
+#endif
+
+#ifdef RENDER
+#include "picture.h"
+#endif
+
+#ifdef XPRINT
+#include "DiPrint.h"
+#endif
+
+Bool noTestExtensions;
+#ifdef BIGREQS
+Bool noBigReqExtension = FALSE;
+#endif
+#ifdef COMPOSITE
+/* COMPOSITE is disabled by default for now until the
+ * interface is stable */
+Bool noCompositeExtension = TRUE;
+#endif
+#ifdef DAMAGE
+Bool noDamageExtension = FALSE;
+#endif
+#ifdef DBE
+Bool noDbeExtension = FALSE;
+#endif
+#ifdef DPSEXT
+Bool noDPSExtension = FALSE;
+#endif
+#ifdef DPMSExtension
+Bool noDPMSExtension = FALSE;
+#endif
+#ifdef EVI
+Bool noEVIExtension = FALSE;
+#endif
+#ifdef FONTCACHE
+Bool noFontCacheExtension = FALSE;
+#endif
+#ifdef GLXEXT
+Bool noGlxExtension = FALSE;
+#endif
+#ifdef LBX
+Bool noLbxExtension = FALSE;
+#endif
+#ifdef SCREENSAVER
+Bool noScreenSaverExtension = FALSE;
+#endif
+#ifdef MITSHM
+Bool noMITShmExtension = FALSE;
+#endif
+#ifdef MITMISC
+Bool noMITMiscExtension = FALSE;
+#endif
+#ifdef MULTIBUFFER
+Bool noMultibufferExtension = FALSE;
+#endif
+#ifdef RANDR
+Bool noRRExtension = FALSE;
+#endif
+#ifdef RENDER
+Bool noRenderExtension = FALSE;
+#endif
+#ifdef SHAPE
+Bool noShapeExtension = FALSE;
+#endif
+#ifdef XCSECURITY
+Bool noSecurityExtension = FALSE;
+#endif
+#ifdef XSYNC
+Bool noSyncExtension = FALSE;
+#endif
+#ifdef TOGCUP
+Bool noXcupExtension = FALSE;
+#endif
+#ifdef RES
+Bool noResExtension = FALSE;
+#endif
+#ifdef XAPPGROUP
+Bool noXagExtension = FALSE;
+#endif
+#ifdef XCMISC
+Bool noXCMiscExtension = FALSE;
+#endif
+#ifdef XEVIE
+/* Xevie is disabled by default for now until the
+ * interface is stable */
+Bool noXevieExtension = TRUE;
+#endif
+#ifdef XF86BIGFONT
+Bool noXFree86BigfontExtension = FALSE;
+#endif
+#ifdef XFreeXDGA
+Bool noXFree86DGAExtension = FALSE;
+#endif
+#ifdef XF86DRI
+Bool noXFree86DRIExtension = FALSE;
+#endif
+#ifdef XF86MISC
+Bool noXFree86MiscExtension = FALSE;
+#endif
+#ifdef XF86VIDMODE
+Bool noXFree86VidModeExtension = FALSE;
+#endif
+#ifdef XFIXES
+Bool noXFixesExtension = FALSE;
+#endif
+/* |noXkbExtension| is defined in xc/programs/Xserver/xkb/xkbInit.c */
+#ifdef PANORAMIX
+/* Xinerama is disabled by default unless enabled via +xinerama */
+Bool noPanoramiXExtension = TRUE;
+#endif
+#ifdef XINPUT
+Bool noXInputExtension = FALSE;
+#endif
+#ifdef XIDLE
+Bool noXIdleExtension = FALSE;
+#endif
+#ifdef XV
+Bool noXvExtension = FALSE;
+#endif
+
+#define X_INCLUDE_NETDB_H
+#include <X11/Xos_r.h>
+
+#include <errno.h>
+
+Bool CoreDump;
+
+#ifdef PANORAMIX
+Bool PanoramiXVisibilityNotifySent = FALSE;
+Bool PanoramiXMapped = FALSE;
+Bool PanoramiXWindowExposureSent = FALSE;
+Bool PanoramiXOneExposeRequest = FALSE;
+Bool PanoramiXExtensionDisabledHack = FALSE;
+#endif
+
+int auditTrailLevel = 1;
+
+Bool Must_have_memory = FALSE;
+
+#ifdef AIXV3
+int SyncOn = 0;
+extern int SelectWaitTime;
+#endif
+
+#ifdef DEBUG
+#ifndef SPECIAL_MALLOC
+#define MEMBUG
+#endif
+#endif
+
+#if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED)
+#define HAS_SAVED_IDS_AND_SETEUID
+#endif
+
+#ifdef MEMBUG
+#define MEM_FAIL_SCALE 100000
+long Memory_fail = 0;
+#include <stdlib.h> /* for random() */
+#endif
+
+#ifdef sgi
+int userdefinedfontpath = 0;
+#endif /* sgi */
+
+char *dev_tty_from_init = NULL; /* since we need to parse it anyway */
+
+extern char dispatchExceptionAtReset;
+
+/* Extension enable/disable in miinitext.c */
+extern Bool EnableDisableExtension(char *name, Bool enable);
+extern void EnableDisableExtensionError(char *name, Bool enable);
+
+OsSigHandlerPtr
+OsSignal(sig, handler)
+ int sig;
+ OsSigHandlerPtr handler;
+{
+#ifdef X_NOT_POSIX
+ return signal(sig, handler);
+#else
+ struct sigaction act, oact;
+
+ sigemptyset(&act.sa_mask);
+ if (handler != SIG_IGN)
+ sigaddset(&act.sa_mask, sig);
+ act.sa_flags = 0;
+ act.sa_handler = handler;
+ sigaction(sig, &act, &oact);
+ return oact.sa_handler;
+#endif
+}
+
+#ifdef SERVER_LOCK
+/*
+ * Explicit support for a server lock file like the ones used for UUCP.
+ * For architectures with virtual terminals that can run more than one
+ * server at a time. This keeps the servers from stomping on each other
+ * if the user forgets to give them different display numbers.
+ */
+#ifndef __UNIXOS2__
+#define LOCK_DIR "/tmp"
+#endif
+#define LOCK_TMP_PREFIX "/.tX"
+#define LOCK_PREFIX "/.X"
+#define LOCK_SUFFIX "-lock"
+
+#if defined(DGUX)
+#include <limits.h>
+#include <sys/param.h>
+#endif
+
+#ifdef __UNIXOS2__
+#define link rename
+#endif
+
+#ifndef PATH_MAX
+#ifndef Lynx
+#include <sys/param.h>
+#else
+#include <param.h>
+#endif
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+#endif
+
+static Bool StillLocking = FALSE;
+static char LockFile[PATH_MAX];
+static Bool nolock = FALSE;
+
+/*
+ * LockServer --
+ * Check if the server lock file exists. If so, check if the PID
+ * contained inside is valid. If so, then die. Otherwise, create
+ * the lock file containing the PID.
+ */
+void
+LockServer(void)
+{
+ char tmp[PATH_MAX], pid_str[12];
+ int lfd, i, haslock, l_pid, t;
+ char *tmppath = NULL;
+ int len;
+ char port[20];
+
+ if (nolock) return;
+ /*
+ * Path names
+ */
+#ifndef __UNIXOS2__
+ tmppath = LOCK_DIR;
+#else
+ /* OS/2 uses TMP directory, must also prepare for 8.3 names */
+ tmppath = getenv("TMP");
+ if (!tmppath)
+ FatalError("No TMP dir found\n");
+#endif
+
+ sprintf(port, "%d", atoi(display));
+ len = strlen(LOCK_PREFIX) > strlen(LOCK_TMP_PREFIX) ? strlen(LOCK_PREFIX) :
+ strlen(LOCK_TMP_PREFIX);
+ len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1;
+ if (len > sizeof(LockFile))
+ FatalError("Display name `%s' is too long\n", port);
+ (void)sprintf(tmp, "%s" LOCK_TMP_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
+ (void)sprintf(LockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
+
+ /*
+ * Create a temporary file containing our PID. Attempt three times
+ * to create the file.
+ */
+ StillLocking = TRUE;
+ i = 0;
+ do {
+ i++;
+ lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644);
+ if (lfd < 0)
+ sleep(2);
+ else
+ break;
+ } while (i < 3);
+ if (lfd < 0) {
+ unlink(tmp);
+ i = 0;
+ do {
+ i++;
+ lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644);
+ if (lfd < 0)
+ sleep(2);
+ else
+ break;
+ } while (i < 3);
+ }
+ if (lfd < 0)
+ FatalError("Could not create lock file in %s\n", tmp);
+ (void) sprintf(pid_str, "%10ld\n", (long)getpid());
+ (void) write(lfd, pid_str, 11);
+#ifndef __UNIXOS2__
+#ifndef USE_CHMOD
+ (void) fchmod(lfd, 0444);
+#else
+ (void) chmod(tmp, 0444);
+#endif
+#endif
+ (void) close(lfd);
+
+ /*
+ * OK. Now the tmp file exists. Try three times to move it in place
+ * for the lock.
+ */
+ i = 0;
+ haslock = 0;
+ while ((!haslock) && (i++ < 3)) {
+ haslock = (link(tmp,LockFile) == 0);
+ if (haslock) {
+ /*
+ * We're done.
+ */
+ break;
+ }
+ else {
+ /*
+ * Read the pid from the existing file
+ */
+ lfd = open(LockFile, O_RDONLY);
+ if (lfd < 0) {
+ unlink(tmp);
+ FatalError("Can't read lock file %s\n", LockFile);
+ }
+ pid_str[0] = '\0';
+ if (read(lfd, pid_str, 11) != 11) {
+ /*
+ * Bogus lock file.
+ */
+ unlink(LockFile);
+ close(lfd);
+ continue;
+ }
+ pid_str[11] = '\0';
+ sscanf(pid_str, "%d", &l_pid);
+ close(lfd);
+
+ /*
+ * Now try to kill the PID to see if it exists.
+ */
+ errno = 0;
+ t = kill(l_pid, 0);
+ if ((t< 0) && (errno == ESRCH)) {
+ /*
+ * Stale lock file.
+ */
+ unlink(LockFile);
+ continue;
+ }
+ else if (((t < 0) && (errno == EPERM)) || (t == 0)) {
+ /*
+ * Process is still active.
+ */
+ unlink(tmp);
+ FatalError("Server is already active for display %s\n%s %s\n%s\n",
+ port, "\tIf this server is no longer running, remove",
+ LockFile, "\tand start again.");
+ }
+ }
+ }
+ unlink(tmp);
+ if (!haslock)
+ FatalError("Could not create server lock file: %s\n", LockFile);
+ StillLocking = FALSE;
+}
+
+/*
+ * UnlockServer --
+ * Remove the server lock file.
+ */
+void
+UnlockServer(void)
+{
+ if (nolock) return;
+
+ if (!StillLocking){
+
+#ifdef __UNIXOS2__
+ (void) chmod(LockFile,S_IREAD|S_IWRITE);
+#endif /* __UNIXOS2__ */
+ (void) unlink(LockFile);
+ }
+}
+#endif /* SERVER_LOCK */
+
+/* Force connections to close on SIGHUP from init */
+
+/*ARGSUSED*/
+SIGVAL
+AutoResetServer (int sig)
+{
+ int olderrno = errno;
+
+ dispatchException |= DE_RESET;
+ isItTimeToYield = TRUE;
+#ifdef GPROF
+ chdir ("/tmp");
+ exit (0);
+#endif
+#if defined(SYSV) && defined(X_NOT_POSIX)
+ OsSignal (SIGHUP, AutoResetServer);
+#endif
+ errno = olderrno;
+}
+
+/* Force connections to close and then exit on SIGTERM, SIGINT */
+
+/*ARGSUSED*/
+SIGVAL
+GiveUp(int sig)
+{
+ int olderrno = errno;
+
+ dispatchException |= DE_TERMINATE;
+ isItTimeToYield = TRUE;
+#if defined(SYSV) && defined(X_NOT_POSIX)
+ if (sig)
+ OsSignal(sig, SIG_IGN);
+#endif
+ errno = olderrno;
+}
+
+#ifndef DDXTIME
+CARD32
+GetTimeInMillis(void)
+{
+ struct timeval tp;
+
+ X_GETTIMEOFDAY(&tp);
+ return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);
+}
+#endif
+
+void
+AdjustWaitForDelay (pointer waitTime, unsigned long newdelay)
+{
+ static struct timeval delay_val;
+ struct timeval **wt = (struct timeval **) waitTime;
+ unsigned long olddelay;
+
+ if (*wt == NULL)
+ {
+ delay_val.tv_sec = newdelay / 1000;
+ delay_val.tv_usec = 1000 * (newdelay % 1000);
+ *wt = &delay_val;
+ }
+ else
+ {
+ olddelay = (*wt)->tv_sec * 1000 + (*wt)->tv_usec / 1000;
+ if (newdelay < olddelay)
+ {
+ (*wt)->tv_sec = newdelay / 1000;
+ (*wt)->tv_usec = 1000 * (newdelay % 1000);
+ }
+ }
+}
+
+void UseMsg(void)
+{
+#if !defined(AIXrt) && !defined(AIX386)
+ ErrorF("use: X [:<display>] [option]\n");
+ ErrorF("-a # mouse acceleration (pixels)\n");
+ ErrorF("-ac disable access control restrictions\n");
+#ifdef MEMBUG
+ ErrorF("-alloc int chance alloc should fail\n");
+#endif
+ ErrorF("-audit int set audit trail level\n");
+ ErrorF("-auth file select authorization file\n");
+ ErrorF("bc enable bug compatibility\n");
+ ErrorF("-br create root window with black background\n");
+ ErrorF("+bs enable any backing store support\n");
+ ErrorF("-bs disable any backing store support\n");
+ ErrorF("-c turns off key-click\n");
+ ErrorF("c # key-click volume (0-100)\n");
+ ErrorF("-cc int default color visual class\n");
+ ErrorF("-co file color database file\n");
+#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
+ ErrorF("-config file read options from file\n");
+#endif
+ ErrorF("-core generate core dump on fatal error\n");
+ ErrorF("-dpi int screen resolution in dots per inch\n");
+#ifdef DPMSExtension
+ ErrorF("dpms enables VESA DPMS monitor control\n");
+ ErrorF("-dpms disables VESA DPMS monitor control\n");
+#endif
+ ErrorF("-deferglyphs [none|all|16] defer loading of [no|all|16-bit] glyphs\n");
+ ErrorF("-f # bell base (0-100)\n");
+ ErrorF("-fc string cursor font\n");
+ ErrorF("-fn string default font name\n");
+ ErrorF("-fp string default font path\n");
+ ErrorF("-help prints message with these options\n");
+ ErrorF("-I ignore all remaining arguments\n");
+#ifdef RLIMIT_DATA
+ ErrorF("-ld int limit data space to N Kb\n");
+#endif
+#ifdef RLIMIT_NOFILE
+ ErrorF("-lf int limit number of open files to N\n");
+#endif
+#ifdef RLIMIT_STACK
+ ErrorF("-ls int limit stack space to N Kb\n");
+#endif
+#ifdef SERVER_LOCK
+ ErrorF("-nolock disable the locking mechanism\n");
+#endif
+#ifndef NOLOGOHACK
+ ErrorF("-logo enable logo in screen saver\n");
+ ErrorF("nologo disable logo in screen saver\n");
+#endif
+ ErrorF("-nolisten string don't listen on protocol\n");
+ ErrorF("-noreset don't reset after last client exists\n");
+ ErrorF("-reset reset after last client exists\n");
+ ErrorF("-p # screen-saver pattern duration (minutes)\n");
+ ErrorF("-pn accept failure to listen on all ports\n");
+ ErrorF("-nopn reject failure to listen on all ports\n");
+ ErrorF("-r turns off auto-repeat\n");
+ ErrorF("r turns on auto-repeat \n");
+#ifdef RENDER
+ ErrorF("-render [default|mono|gray|color] set render color alloc policy\n");
+#endif
+ ErrorF("-s # screen-saver timeout (minutes)\n");
+#ifdef XCSECURITY
+ ErrorF("-sp file security policy file\n");
+#endif
+#ifdef XPRINT
+ PrinterUseMsg();
+#endif
+ ErrorF("-su disable any save under support\n");
+ ErrorF("-t # mouse threshold (pixels)\n");
+ ErrorF("-terminate terminate at server reset\n");
+ ErrorF("-to # connection time out\n");
+ ErrorF("-tst disable testing extensions\n");
+ ErrorF("ttyxx server started from init on /dev/ttyxx\n");
+ ErrorF("v video blanking for screen-saver\n");
+ ErrorF("-v screen-saver without video blanking\n");
+ ErrorF("-wm WhenMapped default backing-store\n");
+ ErrorF("-x string loads named extension at init time \n");
+ ErrorF("-maxbigreqsize set maximal bigrequest size \n");
+#ifdef PANORAMIX
+ ErrorF("+xinerama Enable XINERAMA extension\n");
+ ErrorF("-xinerama Disable XINERAMA extension\n");
+#endif
+#ifdef SMART_SCHEDULE
+ ErrorF("-dumbSched Disable smart scheduling, enable old behavior\n");
+ ErrorF("-schedInterval int Set scheduler interval in msec\n");
+#endif
+ ErrorF("+extension name Enable extension\n");
+ ErrorF("-extension name Disable extension\n");
+#ifdef XDMCP
+ XdmcpUseMsg();
+#endif
+#endif /* !AIXrt && ! AIX386 */
+#ifdef XKB
+ XkbUseMsg();
+#endif
+ ddxUseMsg();
+}
+
+/* This function performs a rudimentary sanity check
+ * on the display name passed in on the command-line,
+ * since this string is used to generate filenames.
+ * It is especially important that the display name
+ * not contain a "/" and not start with a "-".
+ * --kvajk
+ */
+static int
+VerifyDisplayName(const char *d)
+{
+ if ( d == (char *)0 ) return( 0 ); /* null */
+ if ( *d == '\0' ) return( 0 ); /* empty */
+ if ( *d == '-' ) return( 0 ); /* could be confused for an option */
+ if ( *d == '.' ) return( 0 ); /* must not equal "." or ".." */
+ if ( strchr(d, '/') != (char *)0 ) return( 0 ); /* very important!!! */
+ return( 1 );
+}
+
+/*
+ * This function is responsible for doing initalisation of any global
+ * variables at an very early point of server startup (even before
+ * |ProcessCommandLine()|.
+ */
+void InitGlobals(void)
+{
+ ddxInitGlobals();
+}
+
+
+/*
+ * This function parses the command line. Handles device-independent fields
+ * and allows ddx to handle additional fields. It is not allowed to modify
+ * argc or any of the strings pointed to by argv.
+ */
+void
+ProcessCommandLine(int argc, char *argv[])
+{
+ int i, skip;
+
+ defaultKeyboardControl.autoRepeat = TRUE;
+
+#ifdef NO_PART_NET
+ PartialNetwork = FALSE;
+#else
+ PartialNetwork = TRUE;
+#endif
+
+ for ( i = 1; i < argc; i++ )
+ {
+ /* call ddx first, so it can peek/override if it wants */
+ if((skip = ddxProcessArgument(argc, argv, i)))
+ {
+ i += (skip - 1);
+ }
+ else if(argv[i][0] == ':')
+ {
+ /* initialize display */
+ display = argv[i];
+ display++;
+ if( ! VerifyDisplayName( display ) ) {
+ ErrorF("Bad display name: %s\n", display);
+ UseMsg();
+ FatalError("Bad display name, exiting: %s\n", display);
+ }
+ }
+ else if ( strcmp( argv[i], "-a") == 0)
+ {
+ if(++i < argc)
+ defaultPointerControl.num = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-ac") == 0)
+ {
+ defeatAccessControl = TRUE;
+ }
+#ifdef MEMBUG
+ else if ( strcmp( argv[i], "-alloc") == 0)
+ {
+ if(++i < argc)
+ Memory_fail = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+#endif
+ else if ( strcmp( argv[i], "-audit") == 0)
+ {
+ if(++i < argc)
+ auditTrailLevel = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-auth") == 0)
+ {
+ if(++i < argc)
+ InitAuthorization (argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "bc") == 0)
+ permitOldBugs = TRUE;
+ else if ( strcmp( argv[i], "-br") == 0)
+ blackRoot = TRUE;
+ else if ( strcmp( argv[i], "+bs") == 0)
+ enableBackingStore = TRUE;
+ else if ( strcmp( argv[i], "-bs") == 0)
+ disableBackingStore = TRUE;
+ else if ( strcmp( argv[i], "c") == 0)
+ {
+ if(++i < argc)
+ defaultKeyboardControl.click = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-c") == 0)
+ {
+ defaultKeyboardControl.click = 0;
+ }
+ else if ( strcmp( argv[i], "-cc") == 0)
+ {
+ if(++i < argc)
+ defaultColorVisualClass = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-co") == 0)
+ {
+ if(++i < argc)
+ rgbPath = argv[i];
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-core") == 0)
+ CoreDump = TRUE;
+ else if ( strcmp( argv[i], "-dpi") == 0)
+ {
+ if(++i < argc)
+ monitorResolution = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+#ifdef DPMSExtension
+ else if ( strcmp( argv[i], "dpms") == 0)
+ DPMSEnabledSwitch = TRUE;
+ else if ( strcmp( argv[i], "-dpms") == 0)
+ DPMSDisabledSwitch = TRUE;
+#endif
+ else if ( strcmp( argv[i], "-deferglyphs") == 0)
+ {
+ if(++i >= argc || !ParseGlyphCachingMode(argv[i]))
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-f") == 0)
+ {
+ if(++i < argc)
+ defaultKeyboardControl.bell = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-fc") == 0)
+ {
+ if(++i < argc)
+ defaultCursorFont = argv[i];
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-fn") == 0)
+ {
+ if(++i < argc)
+ defaultTextFont = argv[i];
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-fp") == 0)
+ {
+ if(++i < argc)
+ {
+#ifdef sgi
+ userdefinedfontpath = 1;
+#endif /* sgi */
+ defaultFontPath = argv[i];
+ }
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-help") == 0)
+ {
+ UseMsg();
+ exit(0);
+ }
+#ifdef XKB
+ else if ( (skip=XkbProcessArguments(argc,argv,i))!=0 ) {
+ if (skip>0)
+ i+= skip-1;
+ else UseMsg();
+ }
+#endif
+#ifdef RLIMIT_DATA
+ else if ( strcmp( argv[i], "-ld") == 0)
+ {
+ if(++i < argc)
+ {
+ limitDataSpace = atoi(argv[i]);
+ if (limitDataSpace > 0)
+ limitDataSpace *= 1024;
+ }
+ else
+ UseMsg();
+ }
+#endif
+#ifdef RLIMIT_NOFILE
+ else if ( strcmp( argv[i], "-lf") == 0)
+ {
+ if(++i < argc)
+ limitNoFile = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+#endif
+#ifdef RLIMIT_STACK
+ else if ( strcmp( argv[i], "-ls") == 0)
+ {
+ if(++i < argc)
+ {
+ limitStackSpace = atoi(argv[i]);
+ if (limitStackSpace > 0)
+ limitStackSpace *= 1024;
+ }
+ else
+ UseMsg();
+ }
+#endif
+#ifdef SERVER_LOCK
+ else if ( strcmp ( argv[i], "-nolock") == 0)
+ {
+#if !defined(WIN32) && !defined(__UNIXOS2__) && !defined(__CYGWIN__)
+ if (getuid() != 0)
+ ErrorF("Warning: the -nolock option can only be used by root\n");
+ else
+#endif
+ nolock = TRUE;
+ }
+#endif
+#ifndef NOLOGOHACK
+ else if ( strcmp( argv[i], "-logo") == 0)
+ {
+ logoScreenSaver = 1;
+ }
+ else if ( strcmp( argv[i], "nologo") == 0)
+ {
+ logoScreenSaver = 0;
+ }
+#endif
+ else if ( strcmp( argv[i], "-nolisten") == 0)
+ {
+ if(++i < argc) {
+ if (_XSERVTransNoListen(argv[i]))
+ FatalError ("Failed to disable listen for %s transport",
+ argv[i]);
+ } else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-noreset") == 0)
+ {
+ dispatchExceptionAtReset = 0;
+ }
+ else if ( strcmp( argv[i], "-reset") == 0)
+ {
+ dispatchExceptionAtReset = DE_RESET;
+ }
+ else if ( strcmp( argv[i], "-p") == 0)
+ {
+ if(++i < argc)
+ defaultScreenSaverInterval = ((CARD32)atoi(argv[i])) *
+ MILLI_PER_MIN;
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-pn") == 0)
+ PartialNetwork = TRUE;
+ else if ( strcmp( argv[i], "-nopn") == 0)
+ PartialNetwork = FALSE;
+ else if ( strcmp( argv[i], "r") == 0)
+ defaultKeyboardControl.autoRepeat = TRUE;
+ else if ( strcmp( argv[i], "-r") == 0)
+ defaultKeyboardControl.autoRepeat = FALSE;
+ else if ( strcmp( argv[i], "-s") == 0)
+ {
+ if(++i < argc)
+ defaultScreenSaverTime = ((CARD32)atoi(argv[i])) *
+ MILLI_PER_MIN;
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-su") == 0)
+ disableSaveUnders = TRUE;
+ else if ( strcmp( argv[i], "-t") == 0)
+ {
+ if(++i < argc)
+ defaultPointerControl.threshold = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-terminate") == 0)
+ {
+ dispatchExceptionAtReset = DE_TERMINATE;
+ }
+ else if ( strcmp( argv[i], "-to") == 0)
+ {
+ if(++i < argc)
+ TimeOutValue = ((CARD32)atoi(argv[i])) * MILLI_PER_SECOND;
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-tst") == 0)
+ {
+ noTestExtensions = TRUE;
+ }
+ else if ( strcmp( argv[i], "v") == 0)
+ defaultScreenSaverBlanking = PreferBlanking;
+ else if ( strcmp( argv[i], "-v") == 0)
+ defaultScreenSaverBlanking = DontPreferBlanking;
+ else if ( strcmp( argv[i], "-wm") == 0)
+ defaultBackingStore = WhenMapped;
+ else if ( strcmp( argv[i], "-maxbigreqsize") == 0) {
+ if(++i < argc) {
+ long reqSizeArg = atol(argv[i]);
+
+ /* Request size > 128MB does not make much sense... */
+ if( reqSizeArg > 0L && reqSizeArg < 128L ) {
+ maxBigRequestSize = (reqSizeArg * 1048576L) - 1L;
+ }
+ else
+ {
+ UseMsg();
+ }
+ }
+ else
+ {
+ UseMsg();
+ }
+ }
+#ifdef PANORAMIX
+ else if ( strcmp( argv[i], "+xinerama") == 0){
+ noPanoramiXExtension = FALSE;
+ }
+ else if ( strcmp( argv[i], "-xinerama") == 0){
+ noPanoramiXExtension = TRUE;
+ }
+ else if ( strcmp( argv[i], "-disablexineramaextension") == 0){
+ PanoramiXExtensionDisabledHack = TRUE;
+ }
+#endif
+ else if ( strcmp( argv[i], "-x") == 0)
+ {
+ if(++i >= argc)
+ UseMsg();
+ /* For U**x, which doesn't support dynamic loading, there's nothing
+ * to do when we see a -x. Either the extension is linked in or
+ * it isn't */
+ }
+ else if ( strcmp( argv[i], "-I") == 0)
+ {
+ /* ignore all remaining arguments */
+ break;
+ }
+ else if (strncmp (argv[i], "tty", 3) == 0)
+ {
+ /* just in case any body is interested */
+ dev_tty_from_init = argv[i];
+ }
+#ifdef XDMCP
+ else if ((skip = XdmcpOptions(argc, argv, i)) != i)
+ {
+ i = skip - 1;
+ }
+#endif
+#ifdef XPRINT
+ else if ((skip = PrinterOptions(argc, argv, i)) != i)
+ {
+ i = skip - 1;
+ }
+#endif
+#ifdef XCSECURITY
+ else if ((skip = XSecurityOptions(argc, argv, i)) != i)
+ {
+ i = skip - 1;
+ }
+#endif
+#ifdef AIXV3
+ else if ( strcmp( argv[i], "-timeout") == 0)
+ {
+ if(++i < argc)
+ SelectWaitTime = atoi(argv[i]);
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-sync") == 0)
+ {
+ SyncOn++;
+ }
+#endif
+#ifdef SMART_SCHEDULE
+ else if ( strcmp( argv[i], "-dumbSched") == 0)
+ {
+ SmartScheduleDisable = TRUE;
+ }
+ else if ( strcmp( argv[i], "-schedInterval") == 0)
+ {
+ if (++i < argc)
+ {
+ SmartScheduleInterval = atoi(argv[i]);
+ SmartScheduleSlice = SmartScheduleInterval;
+ }
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-schedMax") == 0)
+ {
+ if (++i < argc)
+ {
+ SmartScheduleMaxSlice = atoi(argv[i]);
+ }
+ else
+ UseMsg();
+ }
+#endif
+#ifdef RENDER
+ else if ( strcmp( argv[i], "-render" ) == 0)
+ {
+ if (++i < argc)
+ {
+ int policy = PictureParseCmapPolicy (argv[i]);
+
+ if (policy != PictureCmapPolicyInvalid)
+ PictureCmapPolicy = policy;
+ else
+ UseMsg ();
+ }
+ else
+ UseMsg ();
+ }
+#endif
+ else if ( strcmp( argv[i], "+extension") == 0)
+ {
+ if (++i < argc)
+ {
+ if (!EnableDisableExtension(argv[i], TRUE))
+ EnableDisableExtensionError(argv[i], TRUE);
+ }
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-extension") == 0)
+ {
+ if (++i < argc)
+ {
+ if (!EnableDisableExtension(argv[i], FALSE))
+ EnableDisableExtensionError(argv[i], FALSE);
+ }
+ else
+ UseMsg();
+ }
+ else
+ {
+ ErrorF("Unrecognized option: %s\n", argv[i]);
+ UseMsg();
+ FatalError("Unrecognized option: %s\n", argv[i]);
+ }
+ }
+}
+
+#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
+static void
+InsertFileIntoCommandLine(
+ int *resargc, char ***resargv,
+ int prefix_argc, char **prefix_argv,
+ char *filename,
+ int suffix_argc, char **suffix_argv)
+{
+ struct stat st;
+ FILE *f;
+ char *p;
+ char *q;
+ int insert_argc;
+ char *buf;
+ int len;
+ int i;
+
+ f = fopen(filename, "r");
+ if (!f)
+ FatalError("Can't open option file %s\n", filename);
+
+ fstat(fileno(f), &st);
+
+ buf = (char *) xalloc((unsigned) st.st_size + 1);
+ if (!buf)
+ FatalError("Out of Memory\n");
+
+ len = fread(buf, 1, (unsigned) st.st_size, f);
+
+ fclose(f);
+
+ if (len < 0)
+ FatalError("Error reading option file %s\n", filename);
+
+ buf[len] = '\0';
+
+ p = buf;
+ q = buf;
+ insert_argc = 0;
+
+ while (*p)
+ {
+ while (isspace(*p))
+ p++;
+ if (!*p)
+ break;
+ if (*p == '#')
+ {
+ while (*p && *p != '\n')
+ p++;
+ } else
+ {
+ while (*p && !isspace(*p))
+ *q++ = *p++;
+ /* Since p and q might still be pointing at the same place, we */
+ /* need to step p over the whitespace now before we add the null. */
+ if (*p)
+ p++;
+ *q++ = '\0';
+ insert_argc++;
+ }
+ }
+
+ buf = (char *) xrealloc(buf, q - buf);
+ if (!buf)
+ FatalError("Out of memory reallocing option buf\n");
+
+ *resargc = prefix_argc + insert_argc + suffix_argc;
+ *resargv = (char **) xalloc((*resargc + 1) * sizeof(char *));
+ if (!*resargv)
+ FatalError("Out of Memory\n");
+
+ memcpy(*resargv, prefix_argv, prefix_argc * sizeof(char *));
+
+ p = buf;
+ for (i = 0; i < insert_argc; i++)
+ {
+ (*resargv)[prefix_argc + i] = p;
+ p += strlen(p) + 1;
+ }
+
+ memcpy(*resargv + prefix_argc + insert_argc,
+ suffix_argv, suffix_argc * sizeof(char *));
+
+ (*resargv)[*resargc] = NULL;
+} /* end InsertFileIntoCommandLine */
+
+
+void
+ExpandCommandLine(int *pargc, char ***pargv)
+{
+ int i;
+
+#if !defined(WIN32) && !defined(__UNIXOS2__) && !defined(__CYGWIN__)
+ if (getuid() != geteuid())
+ return;
+#endif
+
+ for (i = 1; i < *pargc; i++)
+ {
+ if ( (0 == strcmp((*pargv)[i], "-config")) && (i < (*pargc - 1)) )
+ {
+ InsertFileIntoCommandLine(pargc, pargv,
+ i, *pargv,
+ (*pargv)[i+1], /* filename */
+ *pargc - i - 2, *pargv + i + 2);
+ i--;
+ }
+ }
+} /* end ExpandCommandLine */
+#endif
+
+/* Implement a simple-minded font authorization scheme. The authorization
+ name is "hp-hostname-1", the contents are simply the host name. */
+int
+set_font_authorizations(char **authorizations, int *authlen, pointer client)
+{
+#define AUTHORIZATION_NAME "hp-hostname-1"
+#if defined(TCPCONN) || defined(STREAMSCONN)
+ static char *result = NULL;
+ static char *p = NULL;
+
+ if (p == NULL)
+ {
+ char hname[1024], *hnameptr;
+ unsigned int len;
+#if defined(IPv6) && defined(AF_INET6)
+ struct addrinfo hints, *ai = NULL;
+#else
+ struct hostent *host;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+#endif
+
+ gethostname(hname, 1024);
+#if defined(IPv6) && defined(AF_INET6)
+ bzero(&hints, sizeof(hints));
+ hints.ai_flags = AI_CANONNAME;
+ if (getaddrinfo(hname, NULL, &hints, &ai) == 0) {
+ hnameptr = ai->ai_canonname;
+ } else {
+ hnameptr = hname;
+ }
+#else
+ host = _XGethostbyname(hname, hparams);
+ if (host == NULL)
+ hnameptr = hname;
+ else
+ hnameptr = host->h_name;
+#endif
+
+ len = strlen(hnameptr) + 1;
+ result = xalloc(len + sizeof(AUTHORIZATION_NAME) + 4);
+
+ p = result;
+ *p++ = sizeof(AUTHORIZATION_NAME) >> 8;
+ *p++ = sizeof(AUTHORIZATION_NAME) & 0xff;
+ *p++ = (len) >> 8;
+ *p++ = (len & 0xff);
+
+ memmove(p, AUTHORIZATION_NAME, sizeof(AUTHORIZATION_NAME));
+ p += sizeof(AUTHORIZATION_NAME);
+ memmove(p, hnameptr, len);
+ p += len;
+#if defined(IPv6) && defined(AF_INET6)
+ if (ai) {
+ freeaddrinfo(ai);
+ }
+#endif
+ }
+ *authlen = p - result;
+ *authorizations = result;
+ return 1;
+#else /* TCPCONN */
+ return 0;
+#endif /* TCPCONN */
+}
+
+/* XALLOC -- X's internal memory allocator. Why does it return unsigned
+ * long * instead of the more common char *? Well, if you read K&R you'll
+ * see they say that alloc must return a pointer "suitable for conversion"
+ * to whatever type you really want. In a full-blown generic allocator
+ * there's no way to solve the alignment problems without potentially
+ * wasting lots of space. But we have a more limited problem. We know
+ * we're only ever returning pointers to structures which will have to
+ * be long word aligned. So we are making a stronger guarantee. It might
+ * have made sense to make Xalloc return char * to conform with people's
+ * expectations of malloc, but this makes lint happier.
+ */
+
+#ifndef INTERNAL_MALLOC
+
+void *
+Xalloc(unsigned long amount)
+{
+ register pointer ptr;
+
+ if ((long)amount <= 0) {
+ return (unsigned long *)NULL;
+ }
+ /* aligned extra on long word boundary */
+ amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
+#ifdef MEMBUG
+ if (!Must_have_memory && Memory_fail &&
+ ((random() % MEM_FAIL_SCALE) < Memory_fail))
+ return (unsigned long *)NULL;
+#endif
+ if ((ptr = (pointer)malloc(amount))) {
+ return (unsigned long *)ptr;
+ }
+ if (Must_have_memory)
+ FatalError("Out of memory");
+ return (unsigned long *)NULL;
+}
+
+/*****************
+ * XNFalloc
+ * "no failure" realloc, alternate interface to Xalloc w/o Must_have_memory
+ *****************/
+
+void *
+XNFalloc(unsigned long amount)
+{
+ register pointer ptr;
+
+ if ((long)amount <= 0)
+ {
+ return (unsigned long *)NULL;
+ }
+ /* aligned extra on long word boundary */
+ amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
+ ptr = (pointer)malloc(amount);
+ if (!ptr)
+ {
+ FatalError("Out of memory");
+ }
+ return ((unsigned long *)ptr);
+}
+
+/*****************
+ * Xcalloc
+ *****************/
+
+void *
+Xcalloc(unsigned long amount)
+{
+ unsigned long *ret;
+
+ ret = Xalloc (amount);
+ if (ret)
+ bzero ((char *) ret, (int) amount);
+ return ret;
+}
+
+/*****************
+ * XNFcalloc
+ *****************/
+
+void *
+XNFcalloc(unsigned long amount)
+{
+ unsigned long *ret;
+
+ ret = Xalloc (amount);
+ if (ret)
+ bzero ((char *) ret, (int) amount);
+ else if ((long)amount > 0)
+ FatalError("Out of memory");
+ return ret;
+}
+
+/*****************
+ * Xrealloc
+ *****************/
+
+void *
+Xrealloc(pointer ptr, unsigned long amount)
+{
+#ifdef MEMBUG
+ if (!Must_have_memory && Memory_fail &&
+ ((random() % MEM_FAIL_SCALE) < Memory_fail))
+ return (unsigned long *)NULL;
+#endif
+ if ((long)amount <= 0)
+ {
+ if (ptr && !amount)
+ free(ptr);
+ return (unsigned long *)NULL;
+ }
+ amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
+ if (ptr)
+ ptr = (pointer)realloc((char *)ptr, amount);
+ else
+ ptr = (pointer)malloc(amount);
+ if (ptr)
+ return (unsigned long *)ptr;
+ if (Must_have_memory)
+ FatalError("Out of memory");
+ return (unsigned long *)NULL;
+}
+
+/*****************
+ * XNFrealloc
+ * "no failure" realloc, alternate interface to Xrealloc w/o Must_have_memory
+ *****************/
+
+void *
+XNFrealloc(pointer ptr, unsigned long amount)
+{
+ if (( ptr = (pointer)Xrealloc( ptr, amount ) ) == NULL)
+ {
+ if ((long)amount > 0)
+ FatalError( "Out of memory" );
+ }
+ return ((unsigned long *)ptr);
+}
+
+/*****************
+ * Xfree
+ * calls free
+ *****************/
+
+void
+Xfree(pointer ptr)
+{
+ if (ptr)
+ free((char *)ptr);
+}
+
+void
+OsInitAllocator (void)
+{
+#ifdef MEMBUG
+ static int been_here;
+
+ /* Check the memory system after each generation */
+ if (been_here)
+ CheckMemory ();
+ else
+ been_here = 1;
+#endif
+}
+#endif /* !INTERNAL_MALLOC */
+
+
+char *
+Xstrdup(const char *s)
+{
+ char *sd;
+
+ if (s == NULL)
+ return NULL;
+
+ sd = (char *)Xalloc(strlen(s) + 1);
+ if (sd != NULL)
+ strcpy(sd, s);
+ return sd;
+}
+
+
+char *
+XNFstrdup(const char *s)
+{
+ char *sd;
+
+ if (s == NULL)
+ return NULL;
+
+ sd = (char *)XNFalloc(strlen(s) + 1);
+ strcpy(sd, s);
+ return sd;
+}
+
+#ifdef SMART_SCHEDULE
+
+unsigned long SmartScheduleIdleCount;
+Bool SmartScheduleIdle;
+Bool SmartScheduleTimerStopped;
+
+#ifdef SIGVTALRM
+#define SMART_SCHEDULE_POSSIBLE
+#endif
+
+#ifdef SMART_SCHEDULE_POSSIBLE
+#define SMART_SCHEDULE_SIGNAL SIGALRM
+#define SMART_SCHEDULE_TIMER ITIMER_REAL
+#endif
+
+static void
+SmartScheduleStopTimer (void)
+{
+#ifdef SMART_SCHEDULE_POSSIBLE
+ struct itimerval timer;
+
+ timer.it_interval.tv_sec = 0;
+ timer.it_interval.tv_usec = 0;
+ timer.it_value.tv_sec = 0;
+ timer.it_value.tv_usec = 0;
+ (void) setitimer (ITIMER_REAL, &timer, 0);
+ SmartScheduleTimerStopped = TRUE;
+#endif
+}
+
+Bool
+SmartScheduleStartTimer (void)
+{
+#ifdef SMART_SCHEDULE_POSSIBLE
+ struct itimerval timer;
+
+ SmartScheduleTimerStopped = FALSE;
+ timer.it_interval.tv_sec = 0;
+ timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
+ timer.it_value.tv_sec = 0;
+ timer.it_value.tv_usec = SmartScheduleInterval * 1000;
+ return setitimer (ITIMER_REAL, &timer, 0) >= 0;
+#endif
+ return FALSE;
+}
+
+#ifdef SMART_SCHEDULE_POSSIBLE
+static void
+SmartScheduleTimer (int sig)
+{
+ int olderrno = errno;
+
+ SmartScheduleTime += SmartScheduleInterval;
+ if (SmartScheduleIdle)
+ {
+ SmartScheduleStopTimer ();
+ }
+ errno = olderrno;
+}
+#endif
+
+Bool
+SmartScheduleInit (void)
+{
+#ifdef SMART_SCHEDULE_POSSIBLE
+ struct sigaction act;
+
+ if (SmartScheduleDisable)
+ return TRUE;
+
+ bzero ((char *) &act, sizeof(struct sigaction));
+
+ /* Set up the timer signal function */
+ act.sa_handler = SmartScheduleTimer;
+ sigemptyset (&act.sa_mask);
+ sigaddset (&act.sa_mask, SMART_SCHEDULE_SIGNAL);
+ if (sigaction (SMART_SCHEDULE_SIGNAL, &act, 0) < 0)
+ {
+ perror ("sigaction for smart scheduler");
+ return FALSE;
+ }
+ /* Set up the virtual timer */
+ if (!SmartScheduleStartTimer ())
+ {
+ perror ("scheduling timer");
+ return FALSE;
+ }
+ /* stop the timer and wait for WaitForSomething to start it */
+ SmartScheduleStopTimer ();
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+#endif
+
+#ifdef SIG_BLOCK
+static sigset_t PreviousSignalMask;
+static int BlockedSignalCount;
+#endif
+
+void
+OsBlockSignals (void)
+{
+#ifdef SIG_BLOCK
+ if (BlockedSignalCount++ == 0)
+ {
+ sigset_t set;
+
+ sigemptyset (&set);
+#ifdef SIGALRM
+ sigaddset (&set, SIGALRM);
+#endif
+#ifdef SIGVTALRM
+ sigaddset (&set, SIGVTALRM);
+#endif
+#ifdef SIGWINCH
+ sigaddset (&set, SIGWINCH);
+#endif
+#ifdef SIGIO
+ sigaddset (&set, SIGIO);
+#endif
+#ifdef SIGTSTP
+ sigaddset (&set, SIGTSTP);
+#endif
+#ifdef SIGTTIN
+ sigaddset (&set, SIGTTIN);
+#endif
+#ifdef SIGTTOU
+ sigaddset (&set, SIGTTOU);
+#endif
+#ifdef SIGCHLD
+ sigaddset (&set, SIGCHLD);
+#endif
+ sigprocmask (SIG_BLOCK, &set, &PreviousSignalMask);
+ }
+#endif
+}
+
+void
+OsReleaseSignals (void)
+{
+#ifdef SIG_BLOCK
+ if (--BlockedSignalCount == 0)
+ {
+ sigprocmask (SIG_SETMASK, &PreviousSignalMask, 0);
+ }
+#endif
+}
+
+#if !defined(WIN32) && !defined(__UNIXOS2__)
+/*
+ * "safer" versions of system(3), popen(3) and pclose(3) which give up
+ * all privs before running a command.
+ *
+ * This is based on the code in FreeBSD 2.2 libc.
+ *
+ * XXX It'd be good to redirect stderr so that it ends up in the log file
+ * as well. As it is now, xkbcomp messages don't end up in the log file.
+ */
+
+int
+System(char *command)
+{
+ int pid, p;
+#ifdef SIGCHLD
+ void (*csig)(int);
+#endif
+ int status;
+
+ if (!command)
+ return(1);
+
+#ifdef SIGCHLD
+ csig = signal(SIGCHLD, SIG_DFL);
+#endif
+
+#ifdef DEBUG
+ ErrorF("System: `%s'\n", command);
+#endif
+
+ switch (pid = fork()) {
+ case -1: /* error */
+ p = -1;
+ case 0: /* child */
+ if (setgid(getgid()) == -1)
+ _exit(127);
+ if (setuid(getuid()) == -1)
+ _exit(127);
+ execl("/bin/sh", "sh", "-c", command, (char *)NULL);
+ _exit(127);
+ default: /* parent */
+ do {
+ p = waitpid(pid, &status, 0);
+ } while (p == -1 && errno == EINTR);
+
+ }
+
+#ifdef SIGCHLD
+ signal(SIGCHLD, csig);
+#endif
+
+ return p == -1 ? -1 : status;
+}
+
+static struct pid {
+ struct pid *next;
+ FILE *fp;
+ int pid;
+} *pidlist;
+
+pointer
+Popen(char *command, char *type)
+{
+ struct pid *cur;
+ FILE *iop;
+ int pdes[2], pid;
+
+ if (command == NULL || type == NULL)
+ return NULL;
+
+ if ((*type != 'r' && *type != 'w') || type[1])
+ return NULL;
+
+ if ((cur = (struct pid *)xalloc(sizeof(struct pid))) == NULL)
+ return NULL;
+
+ if (pipe(pdes) < 0) {
+ xfree(cur);
+ return NULL;
+ }
+
+ switch (pid = fork()) {
+ case -1: /* error */
+ close(pdes[0]);
+ close(pdes[1]);
+ xfree(cur);
+ return NULL;
+ case 0: /* child */
+ if (setgid(getgid()) == -1)
+ _exit(127);
+ if (setuid(getuid()) == -1)
+ _exit(127);
+ if (*type == 'r') {
+ if (pdes[1] != 1) {
+ /* stdout */
+ dup2(pdes[1], 1);
+ close(pdes[1]);
+ }
+ close(pdes[0]);
+ } else {
+ if (pdes[0] != 0) {
+ /* stdin */
+ dup2(pdes[0], 0);
+ close(pdes[0]);
+ }
+ close(pdes[1]);
+ }
+ execl("/bin/sh", "sh", "-c", command, (char *)NULL);
+ _exit(127);
+ }
+
+ /* Avoid EINTR during stdio calls */
+ OsBlockSignals ();
+
+ /* parent */
+ if (*type == 'r') {
+ iop = fdopen(pdes[0], type);
+ close(pdes[1]);
+ } else {
+ iop = fdopen(pdes[1], type);
+ close(pdes[0]);
+ }
+
+ cur->fp = iop;
+ cur->pid = pid;
+ cur->next = pidlist;
+ pidlist = cur;
+
+#ifdef DEBUG
+ ErrorF("Popen: `%s', fp = %p\n", command, iop);
+#endif
+
+ return iop;
+}
+
+/* fopen that drops privileges */
+pointer
+Fopen(char *file, char *type)
+{
+ FILE *iop;
+#ifndef HAS_SAVED_IDS_AND_SETEUID
+ struct pid *cur;
+ int pdes[2], pid;
+
+ if (file == NULL || type == NULL)
+ return NULL;
+
+ if ((*type != 'r' && *type != 'w') || type[1])
+ return NULL;
+
+ if ((cur = (struct pid *)xalloc(sizeof(struct pid))) == NULL)
+ return NULL;
+
+ if (pipe(pdes) < 0) {
+ xfree(cur);
+ return NULL;
+ }
+
+ switch (pid = fork()) {
+ case -1: /* error */
+ close(pdes[0]);
+ close(pdes[1]);
+ xfree(cur);
+ return NULL;
+ case 0: /* child */
+ if (setgid(getgid()) == -1)
+ _exit(127);
+ if (setuid(getuid()) == -1)
+ _exit(127);
+ if (*type == 'r') {
+ if (pdes[1] != 1) {
+ /* stdout */
+ dup2(pdes[1], 1);
+ close(pdes[1]);
+ }
+ close(pdes[0]);
+ } else {
+ if (pdes[0] != 0) {
+ /* stdin */
+ dup2(pdes[0], 0);
+ close(pdes[0]);
+ }
+ close(pdes[1]);
+ }
+ execl("/bin/cat", "cat", file, (char *)NULL);
+ _exit(127);
+ }
+
+ /* Avoid EINTR during stdio calls */
+ OsBlockSignals ();
+
+ /* parent */
+ if (*type == 'r') {
+ iop = fdopen(pdes[0], type);
+ close(pdes[1]);
+ } else {
+ iop = fdopen(pdes[1], type);
+ close(pdes[0]);
+ }
+
+ cur->fp = iop;
+ cur->pid = pid;
+ cur->next = pidlist;
+ pidlist = cur;
+
+#ifdef DEBUG
+ ErrorF("Popen: `%s', fp = %p\n", command, iop);
+#endif
+
+ return iop;
+#else
+ int ruid, euid;
+
+ ruid = getuid();
+ euid = geteuid();
+
+ if (seteuid(ruid) == -1) {
+ return NULL;
+ }
+ iop = fopen(file, type);
+
+ if (seteuid(euid) == -1) {
+ fclose(iop);
+ return NULL;
+ }
+ return iop;
+#endif /* HAS_SAVED_IDS_AND_SETEUID */
+}
+
+int
+Pclose(pointer iop)
+{
+ struct pid *cur, *last;
+ int pstat;
+ int pid;
+
+#ifdef DEBUG
+ ErrorF("Pclose: fp = %p\n", iop);
+#endif
+
+ fclose(iop);
+
+ for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next)
+ if (cur->fp == iop)
+ break;
+ if (cur == NULL)
+ return -1;
+
+ do {
+ pid = waitpid(cur->pid, &pstat, 0);
+ } while (pid == -1 && errno == EINTR);
+
+ if (last == NULL)
+ pidlist = cur->next;
+ else
+ last->next = cur->next;
+ xfree(cur);
+
+ /* allow EINTR again */
+ OsReleaseSignals ();
+
+ return pid == -1 ? -1 : pstat;
+}
+
+int
+Fclose(pointer iop)
+{
+#ifdef HAS_SAVED_IDS_AND_SETEUID
+ return fclose(iop);
+#else
+ return Pclose(iop);
+#endif
+}
+
+#endif /* !WIN32 && !__UNIXOS2__ */
+
+
+/*
+ * CheckUserParameters: check for long command line arguments and long
+ * environment variables. By default, these checks are only done when
+ * the server's euid != ruid. In 3.3.x, these checks were done in an
+ * external wrapper utility.
+ */
+
+/* Consider LD* variables insecure? */
+#ifndef REMOVE_ENV_LD
+#define REMOVE_ENV_LD 1
+#endif
+
+/* Remove long environment variables? */
+#ifndef REMOVE_LONG_ENV
+#define REMOVE_LONG_ENV 1
+#endif
+
+/*
+ * Disallow stdout or stderr as pipes? It's possible to block the X server
+ * when piping stdout+stderr to a pipe.
+ *
+ * Don't enable this because it looks like it's going to cause problems.
+ */
+#ifndef NO_OUTPUT_PIPES
+#define NO_OUTPUT_PIPES 0
+#endif
+
+
+/* Check args and env only if running setuid (euid == 0 && euid != uid) ? */
+#ifndef CHECK_EUID
+#ifndef WIN32
+#define CHECK_EUID 1
+#else
+#define CHECK_EUID 0
+#endif
+#endif
+
+/*
+ * Maybe the locale can be faked to make isprint(3) report that everything
+ * is printable? Avoid it by default.
+ */
+#ifndef USE_ISPRINT
+#define USE_ISPRINT 0
+#endif
+
+#define MAX_ARG_LENGTH 128
+#define MAX_ENV_LENGTH 256
+#define MAX_ENV_PATH_LENGTH 2048 /* Limit for *PATH and TERMCAP */
+
+#if USE_ISPRINT
+#include <ctype.h>
+#define checkPrintable(c) isprint(c)
+#else
+#define checkPrintable(c) (((c) & 0x7f) >= 0x20 && ((c) & 0x7f) != 0x7f)
+#endif
+
+enum BadCode {
+ NotBad = 0,
+ UnsafeArg,
+ ArgTooLong,
+ UnprintableArg,
+ EnvTooLong,
+ OutputIsPipe,
+ InternalError
+};
+
+#if defined(VENDORSUPPORT)
+#define BUGADDRESS VENDORSUPPORT
+#elif defined(BUILDERADDR)
+#define BUGADDRESS BUILDERADDR
+#else
+#define BUGADDRESS "xorg@freedesktop.org"
+#endif
+
+#define ARGMSG \
+ "\nIf the arguments used are valid, and have been rejected incorrectly\n" \
+ "please send details of the arguments and why they are valid to\n" \
+ "%s. In the meantime, you can start the Xserver as\n" \
+ "the \"super user\" (root).\n"
+
+#define ENVMSG \
+ "\nIf the environment is valid, and have been rejected incorrectly\n" \
+ "please send details of the environment and why it is valid to\n" \
+ "%s. In the meantime, you can start the Xserver as\n" \
+ "the \"super user\" (root).\n"
+
+void
+CheckUserParameters(int argc, char **argv, char **envp)
+{
+ enum BadCode bad = NotBad;
+ int i = 0, j;
+ char *a, *e = NULL;
+#if defined(__QNX__) && !defined(__QNXNTO__)
+ char cmd_name[64];
+#endif
+
+#if CHECK_EUID
+ if (geteuid() == 0 && getuid() != geteuid())
+#endif
+ {
+ /* Check each argv[] */
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-fp") == 0)
+ {
+ i++; /* continue with next argument. skip the length check */
+ if (i >= argc)
+ break;
+ } else
+ {
+ if (strlen(argv[i]) > MAX_ARG_LENGTH) {
+ bad = ArgTooLong;
+ break;
+ }
+ }
+ a = argv[i];
+ while (*a) {
+ if (checkPrintable(*a) == 0) {
+ bad = UnprintableArg;
+ break;
+ }
+ a++;
+ }
+ if (bad)
+ break;
+ }
+ if (!bad) {
+ /* Check each envp[] */
+ for (i = 0; envp[i]; i++) {
+
+ /* Check for bad environment variables and values */
+#if REMOVE_ENV_LD
+ while (envp[i] && (strncmp(envp[i], "LD", 2) == 0)) {
+#ifdef ENVDEBUG
+ ErrorF("CheckUserParameters: removing %s from the "
+ "environment\n", strtok(envp[i], "="));
+#endif
+ for (j = i; envp[j]; j++) {
+ envp[j] = envp[j+1];
+ }
+ }
+#endif
+ if (envp[i] && (strlen(envp[i]) > MAX_ENV_LENGTH)) {
+#if REMOVE_LONG_ENV
+#ifdef ENVDEBUG
+ ErrorF("CheckUserParameters: removing %s from the "
+ "environment\n", strtok(envp[i], "="));
+#endif
+ for (j = i; envp[j]; j++) {
+ envp[j] = envp[j+1];
+ }
+ i--;
+#else
+ char *eq;
+ int len;
+
+ eq = strchr(envp[i], '=');
+ if (!eq)
+ continue;
+ len = eq - envp[i];
+ e = malloc(len + 1);
+ if (!e) {
+ bad = InternalError;
+ break;
+ }
+ strncpy(e, envp[i], len);
+ e[len] = 0;
+ if (len >= 4 &&
+ (strcmp(e + len - 4, "PATH") == 0 ||
+ strcmp(e, "TERMCAP") == 0)) {
+ if (strlen(envp[i]) > MAX_ENV_PATH_LENGTH) {
+ bad = EnvTooLong;
+ break;
+ } else {
+ free(e);
+ }
+ } else {
+ bad = EnvTooLong;
+ break;
+ }
+#endif
+ }
+ }
+ }
+#if NO_OUTPUT_PIPES
+ if (!bad) {
+ struct stat buf;
+
+ if (fstat(fileno(stdout), &buf) == 0 && S_ISFIFO(buf.st_mode))
+ bad = OutputIsPipe;
+ if (fstat(fileno(stderr), &buf) == 0 && S_ISFIFO(buf.st_mode))
+ bad = OutputIsPipe;
+ }
+#endif
+ }
+ switch (bad) {
+ case NotBad:
+ return;
+ case UnsafeArg:
+ ErrorF("Command line argument number %d is unsafe\n", i);
+ ErrorF(ARGMSG, BUGADDRESS);
+ break;
+ case ArgTooLong:
+ ErrorF("Command line argument number %d is too long\n", i);
+ ErrorF(ARGMSG, BUGADDRESS);
+ break;
+ case UnprintableArg:
+ ErrorF("Command line argument number %d contains unprintable"
+ " characters\n", i);
+ ErrorF(ARGMSG, BUGADDRESS);
+ break;
+ case EnvTooLong:
+ ErrorF("Environment variable `%s' is too long\n", e);
+ ErrorF(ENVMSG, BUGADDRESS);
+ break;
+ case OutputIsPipe:
+ ErrorF("Stdout and/or stderr is a pipe\n");
+ break;
+ case InternalError:
+ ErrorF("Internal Error\n");
+ break;
+ default:
+ ErrorF("Unknown error\n");
+ ErrorF(ARGMSG, BUGADDRESS);
+ ErrorF(ENVMSG, BUGADDRESS);
+ break;
+ }
+ FatalError("X server aborted because of unsafe environment\n");
+}
+
+/*
+ * CheckUserAuthorization: check if the user is allowed to start the
+ * X server. This usually means some sort of PAM checking, and it is
+ * usually only done for setuid servers (uid != euid).
+ */
+
+#ifdef USE_PAM
+#include <security/pam_appl.h>
+#include <security/pam_misc.h>
+#include <pwd.h>
+#endif /* USE_PAM */
+
+void
+CheckUserAuthorization(void)
+{
+#ifdef USE_PAM
+ static struct pam_conv conv = {
+ misc_conv,
+ NULL
+ };
+
+ pam_handle_t *pamh = NULL;
+ struct passwd *pw;
+ int retval;
+
+ if (getuid() != geteuid()) {
+ pw = getpwuid(getuid());
+ if (pw == NULL)
+ FatalError("getpwuid() failed for uid %d\n", getuid());
+
+ retval = pam_start("xserver", pw->pw_name, &conv, &pamh);
+ if (retval != PAM_SUCCESS)
+ FatalError("pam_start() failed.\n"
+ "\tMissing or mangled PAM config file or module?\n");
+
+ retval = pam_authenticate(pamh, 0);
+ if (retval != PAM_SUCCESS) {
+ pam_end(pamh, retval);
+ FatalError("PAM authentication failed, cannot start X server.\n"
+ "\tPerhaps you do not have console ownership?\n");
+ }
+
+ retval = pam_acct_mgmt(pamh, 0);
+ if (retval != PAM_SUCCESS) {
+ pam_end(pamh, retval);
+ FatalError("PAM authentication failed, cannot start X server.\n"
+ "\tPerhaps you do not have console ownership?\n");
+ }
+
+ /* this is not a session, so do not do session management */
+ pam_end(pamh, PAM_SUCCESS);
+ }
+#endif
+}
+
+#ifdef __SCO__
+#include <fcntl.h>
+
+static void
+lockit (int fd, short what)
+{
+ struct flock lck;
+
+ lck.l_whence = 0;
+ lck.l_start = 0;
+ lck.l_len = 1;
+ lck.l_type = what;
+
+ (void)fcntl (fd, F_SETLKW, &lck);
+}
+
+/* SCO OpenServer 5 lacks pread/pwrite. Emulate them. */
+ssize_t
+pread (int fd, void *buf, size_t nbytes, off_t offset)
+{
+ off_t saved;
+ ssize_t ret;
+
+ lockit (fd, F_RDLCK);
+ saved = lseek (fd, 0, SEEK_CUR);
+ lseek (fd, offset, SEEK_SET);
+ ret = read (fd, buf, nbytes);
+ lseek (fd, saved, SEEK_SET);
+ lockit (fd, F_UNLCK);
+
+ return ret;
+}
+
+ssize_t
+pwrite (int fd, const void *buf, size_t nbytes, off_t offset)
+{
+ off_t saved;
+ ssize_t ret;
+
+ lockit (fd, F_WRLCK);
+ saved = lseek (fd, 0, SEEK_CUR);
+ lseek (fd, offset, SEEK_SET);
+ ret = write (fd, buf, nbytes);
+ lseek (fd, saved, SEEK_SET);
+ lockit (fd, F_UNLCK);
+
+ return ret;
+}
+#endif /* __SCO__ */
diff --git a/nx-X11/programs/Xserver/os/xalloc.c b/nx-X11/programs/Xserver/os/xalloc.c
new file mode 100644
index 000000000..e1cdbfc5b
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/xalloc.c
@@ -0,0 +1,817 @@
+#define FATALERRORS 1
+/*
+Copyright (C) 1995 Pascal Haible. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+PASCAL HAIBLE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+Except as contained in this notice, the name of Pascal Haible shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from
+Pascal Haible.
+*/
+
+/* $XFree86: xc/programs/Xserver/os/xalloc.c,v 3.35tsi Exp $ */
+
+/* Only used if INTERNAL_MALLOC is defined
+ * - otherwise xalloc() in utils.c is used
+ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef INTERNAL_MALLOC
+
+#include <stdlib.h> /* for malloc() etc. */
+
+#include <X11/Xos.h>
+#include "misc.h"
+#include <X11/X.h>
+
+#ifdef XALLOC_LOG
+#include <stdio.h>
+#endif
+
+extern Bool Must_have_memory;
+
+/*
+ ***** New malloc approach for the X server *****
+ * Pascal Haible 1995
+ *
+ * Some statistics about memory allocation of the X server
+ * The test session included several clients of different size, including
+ * xv, emacs and xpaint with a new canvas of 3000x2000, zoom 5.
+ * All clients were running together.
+ * A protocolling version of Xalloc recorded 318917 allocating actions
+ * (191573 Xalloc, 85942 XNFalloc, 41438 Xrealloc, 279727 Xfree).
+ * Results grouped by size, excluding the next lower size
+ * (i.e. size=32 means 16<size<=32):
+ *
+ * size nr of alloc max nr of blocks allocated together
+ * 8 1114 287
+ * 16 17341 4104
+ * 32 147352 2068
+ * 64 59053 2518
+ * 128 46882 1230
+ * 256 20544 1217
+ * 512 6808 117
+ * 1024 8254 171
+ * 2048 4841 287
+ * 4096 2429 84
+ * 8192 3364 85
+ * 16384 573 22
+ * 32768 49 7
+ * 65536 45 5
+ * 131072 48 2
+ * 262144 209 2
+ * 524288 7 4
+ * 1048576 2 1
+ * 8388608 2 2
+ *
+ * The most used sizes:
+ * count size
+ * 24 136267
+ * 40 37055
+ * 72 17278
+ * 56 13504
+ * 80 9372
+ * 16 8966
+ * 32 8411
+ * 136 8399
+ * 104 7690
+ * 12 7630
+ * 120 5512
+ * 88 4634
+ * 152 3062
+ * 52 2881
+ * 48 2736
+ * 156 1569
+ * 168 1487
+ * 160 1483
+ * 28 1446
+ * 1608 1379
+ * 184 1305
+ * 552 1270
+ * 64 934
+ * 320 891
+ * 8 754
+ *
+ * Conclusions: more than the half of all allocations are <= 32 bytes.
+ * But of these about 150,000 blocks, only a maximum of about 6,000 are
+ * allocated together (including memory leaks..).
+ * On the other side, only 935 of the 191573 or 0.5% were larger than 8kB
+ * (362 or 0.2% larger than 16k).
+ *
+ * What makes the server really grow is the fragmentation of the heap,
+ * and the fact that it can't shrink.
+ * To cure this, we do the following:
+ * - large blocks (>=11k) are mmapped on xalloc, and unmapped on xfree,
+ * so we don't need any free lists etc.
+ * As this needs 2 system calls, we only do this for the quite
+ * infrequent large (>=11k) blocks.
+ * - instead of reinventing the wheel, we use system malloc for medium
+ * sized blocks (>256, <11k).
+ * - for small blocks (<=256) we use an other approach:
+ * As we need many small blocks, and most ones for a short time,
+ * we don't go through the system malloc:
+ * for each fixed sizes a seperate list of free blocks is kept.
+ * to KISS (Keep it Small and Simple), we don't free them
+ * (not freeing a block of 32 bytes won't be worse than having fragmented
+ * a larger area on allocation).
+ * This way, we (almost) allways have a fitting free block right at hand,
+ * and don't have to walk any lists.
+ */
+
+/*
+ * structure layout of a allocated block
+ * unsigned long size:
+ * rounded up netto size for small and medium blocks
+ * brutto size == mmap'ed area for large blocks
+ * unsigned long DEBUG ? MAGIC : unused
+ * .... data
+ * ( unsigned long MAGIC2 ) only if SIZE_TAIL defined
+ *
+ */
+
+/* use otherwise unused long in the header to store a magic */
+/* shouldn't this be removed for production release ? */
+#define XALLOC_DEBUG
+
+#ifdef XALLOC_DEBUG
+/* Xfree fills the memory with a certain pattern (currently 0xF0) */
+/* this should really be removed for production release! */
+#define XFREE_ERASES
+#endif
+
+/* this must be a multiple of SIZE_STEPS below */
+#define MAX_SMALL 264 /* quite many blocks of 264 */
+
+#define MIN_LARGE (11*1024)
+/* worst case is 25% loss with a page size of 4k */
+
+/* SIZE_STEPS defines the granularity of size of small blocks -
+ * this makes blocks align to that, too! */
+#define SIZE_STEPS (sizeof(double))
+#define SIZE_HEADER (2*sizeof(long)) /* = sizeof(double) for 32bit */
+#ifdef XALLOC_DEBUG
+#if defined(__sparc__)
+#define SIZE_TAIL (2*sizeof(long)) /* = sizeof(double) for 32bit */
+#else
+#define SIZE_TAIL (sizeof(long))
+#endif
+#endif
+
+#undef TAIL_SIZE
+#ifdef SIZE_TAIL
+#define TAIL_SIZE SIZE_TAIL
+#else
+#define TAIL_SIZE 0
+#endif
+
+#if defined (_LP64) || \
+ defined(__alpha__) || defined(__alpha) || \
+ defined(__ia64__) || defined(ia64) || \
+ defined(__sparc64__) || \
+ defined(__s390x__) || \
+ defined(__amd64__) || defined(amd64) || \
+ defined(__powerpc64__) || \
+ (defined(sgi) && _MIPS_SZLONG == 64))
+#define MAGIC 0x1404196414071968
+#define MAGIC_FREE 0x1506196615061966
+#define MAGIC2 0x2515207525182079
+#else
+#define MAGIC 0x14071968
+#define MAGIC_FREE 0x15061966
+#define MAGIC2 0x25182079
+#endif
+
+/* To get some statistics about memory allocation */
+
+#ifdef XALLOC_LOG
+#define XALLOC_LOG_FILE "/tmp/Xalloc.log" /* unsecure... */
+#define LOG_BODY(_body) \
+ { FILE *f; \
+ f = fopen(XALLOC_LOG_FILE, "a"); \
+ if (NULL!=f) { \
+ _body; \
+ fclose(f); \
+ } \
+ }
+#if defined(linux) && defined(i386)
+#define LOG_ALLOC(_fun, _size, _ret) \
+ { unsigned long *from; \
+ __asm__("movl %%ebp,%0" : /*OUT*/ "=r" (from) : /*IN*/ ); \
+ LOG_BODY(fprintf(f, "%s\t%i\t%p\t[%lu]\n", _fun, _size, _ret, *(from+1))) \
+ }
+#else
+#define LOG_ALLOC(_fun, _size, _ret) \
+ LOG_BODY(fprintf(f, "%s\t%i\t%p\n", _fun, _size, _ret))
+#endif
+#define LOG_REALLOC(_fun, _ptr, _size, _ret) \
+ LOG_BODY(fprintf(f, "%s\t%p\t%i\t%p\n", _fun, _ptr, _size, _ret))
+#define LOG_FREE(_fun, _ptr) \
+ LOG_BODY(fprintf(f, "%s\t%p\n", _fun, _ptr))
+#else
+#define LOG_ALLOC(_fun, _size, _ret)
+#define LOG_REALLOC(_fun, _ptr, _size, _ret)
+#define LOG_FREE(_fun, _ptr)
+#endif /* XALLOC_LOG */
+
+static unsigned long *free_lists[MAX_SMALL/SIZE_STEPS];
+
+/*
+ * systems that support it should define HAS_MMAP_ANON or MMAP_DEV_ZERO
+ * and include the appropriate header files for
+ * mmap(), munmap(), PROT_READ, PROT_WRITE, MAP_PRIVATE,
+ * PAGE_SIZE or _SC_PAGESIZE (and MAP_ANON for HAS_MMAP_ANON).
+ *
+ * systems that don't support MAP_ANON fall through to the 2 fold behaviour
+ */
+
+#if defined(linux)
+#define HAS_MMAP_ANON
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <asm/page.h> /* PAGE_SIZE */
+#define HAS_SC_PAGESIZE /* _SC_PAGESIZE may be an enum for Linux */
+#define HAS_GETPAGESIZE
+#endif /* linux */
+
+#if defined(__GNU__)
+#define HAS_MMAP_ANON
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <mach/vm_param.h> /* PAGE_SIZE */
+#define HAS_SC_PAGESIZE
+#define HAS_GETPAGESIZE
+#endif /* __GNU__ */
+
+#if defined(CSRG_BASED)
+#define HAS_MMAP_ANON
+#define HAS_GETPAGESIZE
+#include <sys/types.h>
+#include <sys/mman.h>
+#endif /* CSRG_BASED */
+
+#if defined(DGUX)
+#define HAS_GETPAGESIZE
+#define MMAP_DEV_ZERO
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#endif /* DGUX */
+
+#if defined(SVR4) && !defined(DGUX)
+#define MMAP_DEV_ZERO
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#endif /* SVR4 && !DGUX */
+
+#if defined(sun) && !defined(SVR4) /* SunOS */
+#define MMAP_DEV_ZERO /* doesn't SunOS have MAP_ANON ?? */
+#define HAS_GETPAGESIZE
+#include <sys/types.h>
+#include <sys/mman.h>
+#endif /* sun && !SVR4 */
+
+#ifdef XNO_SYSCONF
+#undef _SC_PAGESIZE
+#endif
+
+#if defined(HAS_MMAP_ANON) || defined (MMAP_DEV_ZERO)
+static int pagesize;
+#endif
+
+#ifdef MMAP_DEV_ZERO
+static int devzerofd = -1;
+#include <errno.h>
+#endif
+
+/*
+ * empty trap function for gdb. Breakpoint here
+ * to find who tries to free a free area
+ */
+void XfreeTrap(void)
+{
+}
+
+void *
+Xalloc (unsigned long amount)
+{
+ register unsigned long *ptr;
+ int indx;
+
+ /* sanity checks */
+
+ /* zero size requested */
+ if (amount == 0) {
+ LOG_ALLOC("Xalloc=0", amount, 0);
+ return NULL;
+ }
+ /* negative size (or size > 2GB) - what do we do? */
+ if ((long)amount < 0) {
+ /* Diagnostic */
+#ifdef FATALERRORS
+ FatalError("Xalloc: Xalloc(<0)\n");
+#else
+ ErrorF("Xalloc warning: Xalloc(<0) ignored..\n");
+#endif
+ LOG_ALLOC("Xalloc<0", amount, 0);
+ return NULL;
+ }
+
+ /* alignment check */
+#if defined(__alpha__) || defined(__alpha) || \
+ defined(__sparc__) || \
+ defined(__mips__) || \
+ defined(__powerpc__) || \
+ defined(__arm32__) || \
+ defined(__ia64__) || defined(ia64) || \
+ defined(__s390x__) || defined(__s390__)
+ amount = (amount + (sizeof(long)-1)) & ~(sizeof(long)-1);
+#endif
+
+ if (amount <= MAX_SMALL) {
+ /*
+ * small block
+ */
+ /* pick a ready to use small chunk */
+ indx = (amount-1) / SIZE_STEPS;
+ ptr = free_lists[indx];
+ if (NULL == ptr) {
+ /* list empty - get 20 or 40 more */
+ /* amount = size rounded up */
+ amount = (indx+1) * SIZE_STEPS;
+ ptr = (unsigned long *)calloc(1,(amount+SIZE_HEADER+TAIL_SIZE)
+ * (amount<100 ? 40 : 20));
+ if (NULL!=ptr) {
+ int i;
+ unsigned long *p1, *p2;
+ p1 = 0;
+ p2 = (unsigned long *)((char *)ptr + SIZE_HEADER);
+ for (i=0; i<(amount<100 ? 40 : 20); i++) {
+ p1 = p2;
+ p1[-2] = amount;
+#ifdef XALLOC_DEBUG
+ p1[-1] = MAGIC_FREE;
+#endif /* XALLOC_DEBUG */
+#ifdef SIZE_TAIL
+ *(unsigned long *)((unsigned char *)p1 + amount) = MAGIC2;
+#endif /* SIZE_TAIL */
+ p2 = (unsigned long *)((char *)p1 + SIZE_HEADER + amount + TAIL_SIZE);
+ *(unsigned long **)p1 = p2;
+ }
+ /* last one has no next one */
+ *(unsigned long **)p1 = NULL;
+ /* put the second in the list */
+ free_lists[indx] = (unsigned long *)((char *)ptr + SIZE_HEADER + amount + TAIL_SIZE + SIZE_HEADER);
+ /* take the fist one */
+ ptr = (unsigned long *)((char *)ptr + SIZE_HEADER);
+ LOG_ALLOC("Xalloc-S", amount, ptr);
+ ptr[-1] = MAGIC;
+ return (void *)ptr;
+ } /* else fall through to 'Out of memory' */
+ } else {
+ /* take that piece of mem out of the list */
+ free_lists[indx] = *((unsigned long **)ptr);
+ /* already has size (and evtl. magic) filled in */
+#ifdef XALLOC_DEBUG
+ ptr[-1] = MAGIC;
+#endif /* XALLOC_DEBUG */
+ LOG_ALLOC("Xalloc-S", amount, ptr);
+ return (void *)ptr;
+ }
+
+#if defined(HAS_MMAP_ANON) || defined(MMAP_DEV_ZERO)
+ } else if (amount >= MIN_LARGE) {
+ /*
+ * large block
+ */
+ /* mmapped malloc */
+ /* round up amount */
+ amount += SIZE_HEADER + TAIL_SIZE;
+ /* round up brutto amount to a multiple of the page size */
+ amount = (amount + pagesize-1) & ~(pagesize-1);
+#ifdef MMAP_DEV_ZERO
+ ptr = (unsigned long *)mmap((caddr_t)0,
+ (size_t)amount,
+ PROT_READ | PROT_WRITE,
+ MAP_PRIVATE,
+ devzerofd,
+ (off_t)0);
+#else
+ ptr = (unsigned long *)mmap((caddr_t)0,
+ (size_t)amount,
+ PROT_READ | PROT_WRITE,
+ MAP_ANON | MAP_PRIVATE,
+ -1,
+ (off_t)0);
+#endif
+ if (-1!=(long)ptr) {
+ ptr[0] = amount - SIZE_HEADER - TAIL_SIZE;
+#ifdef XALLOC_DEBUG
+ ptr[1] = MAGIC;
+#endif /* XALLOC_DEBUG */
+#ifdef SIZE_TAIL
+ ((unsigned long *)((char *)ptr + amount - TAIL_SIZE))[0] = MAGIC2;
+#endif /* SIZE_TAIL */
+ ptr = (unsigned long *)((char *)ptr + SIZE_HEADER);
+ LOG_ALLOC("Xalloc-L", amount, ptr);
+ return (void *)ptr;
+ } /* else fall through to 'Out of memory' */
+#endif /* HAS_MMAP_ANON || MMAP_DEV_ZERO */
+ } else {
+ /*
+ * medium sized block
+ */
+ /* 'normal' malloc() */
+ ptr=(unsigned long *)calloc(1,amount+SIZE_HEADER+TAIL_SIZE);
+ if (ptr != (unsigned long *)NULL) {
+ ptr[0] = amount;
+#ifdef XALLOC_DEBUG
+ ptr[1] = MAGIC;
+#endif /* XALLOC_DEBUG */
+#ifdef SIZE_TAIL
+ *(unsigned long *)((char *)ptr + amount + SIZE_HEADER) = MAGIC2;
+#endif /* SIZE_TAIL */
+ ptr = (unsigned long *)((char *)ptr + SIZE_HEADER);
+ LOG_ALLOC("Xalloc-M", amount, ptr);
+ return (void *)ptr;
+ }
+ }
+ if (Must_have_memory)
+ FatalError("Out of memory");
+ LOG_ALLOC("Xalloc-oom", amount, 0);
+ return NULL;
+}
+
+/*****************
+ * XNFalloc
+ * "no failure" realloc, alternate interface to Xalloc w/o Must_have_memory
+ *****************/
+
+pointer
+XNFalloc (unsigned long amount)
+{
+ register pointer ptr;
+
+ /* zero size requested */
+ if (amount == 0) {
+ LOG_ALLOC("XNFalloc=0", amount, 0);
+ return NULL;
+ }
+ /* negative size (or size > 2GB) - what do we do? */
+ if ((long)amount < 0) {
+ /* Diagnostic */
+#ifdef FATALERRORS
+ FatalError("Xalloc: XNFalloc(<0)\n");
+#else
+ ErrorF("Xalloc warning: XNFalloc(<0) ignored..\n");
+#endif
+ LOG_ALLOC("XNFalloc<0", amount, 0);
+ return (unsigned long *)NULL;
+ }
+ ptr = Xalloc(amount);
+ if (!ptr)
+ {
+ FatalError("Out of memory");
+ }
+ return ptr;
+}
+
+/*****************
+ * Xcalloc
+ *****************/
+
+pointer
+Xcalloc (unsigned long amount)
+{
+ pointer ret;
+
+ ret = Xalloc (amount);
+ if (ret != 0
+#if defined(HAS_MMAP_ANON) || defined(MMAP_DEV_ZERO)
+ && (amount < MIN_LARGE) /* mmaped anonymous mem is already cleared */
+#endif
+ )
+ bzero ((char *) ret, (int) amount);
+ return ret;
+}
+
+/*****************
+ * XNFcalloc
+ *****************/
+void *
+XNFcalloc (unsigned long amount)
+{
+ pointer ret;
+
+ ret = XNFalloc (amount);
+ if (ret != 0
+#if defined(HAS_MMAP_ANON) || defined(MMAP_DEV_ZERO)
+ && (amount < MIN_LARGE) /* mmaped anonymous mem is already cleared */
+#endif
+ )
+ bzero ((char *) ret, (int) amount);
+ return ret;
+}
+
+/*****************
+ * Xrealloc
+ *****************/
+
+void *
+Xrealloc (pointer ptr, unsigned long amount)
+{
+ register unsigned long *new_ptr;
+
+ /* zero size requested */
+ if (amount == 0) {
+ if (ptr)
+ Xfree(ptr);
+ LOG_REALLOC("Xrealloc=0", ptr, amount, 0);
+ return NULL;
+ }
+ /* negative size (or size > 2GB) - what do we do? */
+ if ((long)amount < 0) {
+ /* Diagnostic */
+#ifdef FATALERRORS
+ FatalError("Xalloc: Xrealloc(<0)\n");
+#else
+ ErrorF("Xalloc warning: Xrealloc(<0) ignored..\n");
+#endif
+ if (ptr)
+ Xfree(ptr); /* ?? */
+ LOG_REALLOC("Xrealloc<0", ptr, amount, 0);
+ return NULL;
+ }
+
+ new_ptr = Xalloc(amount);
+ if ( (new_ptr) && (ptr) ) {
+ unsigned long old_size;
+ old_size = ((unsigned long *)ptr)[-2];
+#ifdef XALLOC_DEBUG
+ if (MAGIC != ((unsigned long *)ptr)[-1]) {
+ if (MAGIC_FREE == ((unsigned long *)ptr)[-1]) {
+#ifdef FATALERRORS
+ XfreeTrap();
+ FatalError("Xalloc error: range already freed in Xrealloc() :-(\n");
+#else
+ ErrorF("Xalloc error: range already freed in Xrealloc() :-(\a\n");
+ sleep(5);
+ XfreeTrap();
+#endif
+ LOG_REALLOC("Xalloc error: ranged already freed in Xrealloc() :-(",
+ ptr, amount, 0);
+ return NULL;
+ }
+#ifdef FATALERRORS
+ XfreeTrap();
+ FatalError("Xalloc error: header corrupt in Xrealloc() :-(\n");
+#else
+ ErrorF("Xalloc error: header corrupt in Xrealloc() :-(\n");
+ XfreeTrap();
+#endif
+ LOG_REALLOC("Xalloc error: header corrupt in Xrealloc() :-(",
+ ptr, amount, 0);
+ return NULL;
+ }
+#endif /* XALLOC_DEBUG */
+ /* copy min(old size, new size) */
+ memcpy((char *)new_ptr, (char *)ptr, (amount < old_size ? amount : old_size));
+ }
+ if (ptr)
+ Xfree(ptr);
+ if (new_ptr) {
+ LOG_REALLOC("Xrealloc", ptr, amount, new_ptr);
+ return (void *)new_ptr;
+ }
+ if (Must_have_memory)
+ FatalError("Out of memory");
+ LOG_REALLOC("Xrealloc", ptr, amount, 0);
+ return NULL;
+}
+
+/*****************
+ * XNFrealloc
+ * "no failure" realloc, alternate interface to Xrealloc w/o Must_have_memory
+ *****************/
+
+void *
+XNFrealloc (pointer ptr, unsigned long amount)
+{
+ if (( ptr = (pointer)Xrealloc( ptr, amount ) ) == NULL)
+ {
+ FatalError( "Out of memory" );
+ }
+ return ptr;
+}
+
+/*****************
+ * Xfree
+ * calls free
+ *****************/
+
+void
+Xfree(pointer ptr)
+{
+ unsigned long size;
+ unsigned long *pheader;
+
+ /* free(NULL) IS valid :-( - and widely used throughout the server.. */
+ if (!ptr)
+ return;
+
+ pheader = (unsigned long *)((char *)ptr - SIZE_HEADER);
+#ifdef XALLOC_DEBUG
+ if (MAGIC != pheader[1]) {
+ /* Diagnostic */
+ if (MAGIC_FREE == pheader[1]) {
+#ifdef FATALERRORS
+ XfreeTrap();
+ FatalError("Xalloc error: range already freed in Xrealloc() :-(\n");
+#else
+ ErrorF("Xalloc error: range already freed in Xrealloc() :-(\a\n");
+ sleep(5);
+ XfreeTrap();
+#endif
+ LOG_FREE("Xalloc error: ranged already freed in Xrealloc() :-(", ptr);
+ return;
+ }
+#ifdef FATALERRORS
+ XfreeTrap();
+ FatalError("Xalloc error: Header corrupt in Xfree() :-(\n");
+#else
+ ErrorF("Xalloc error: Header corrupt in Xfree() :-(\n");
+ XfreeTrap();
+#endif
+ LOG_FREE("Xalloc error: Header corrupt in Xfree() :-(", ptr);
+ return;
+ }
+#endif /* XALLOC_DEBUG */
+
+ size = pheader[0];
+ if (size <= MAX_SMALL) {
+ int indx;
+ /*
+ * small block
+ */
+#ifdef SIZE_TAIL
+ if (MAGIC2 != *(unsigned long *)((char *)ptr + size)) {
+ /* Diagnostic */
+#ifdef FATALERRORS
+ XfreeTrap();
+ FatalError("Xalloc error: Tail corrupt in Xfree() for small block (adr=0x%x, val=0x%x)\n",(char *)ptr + size,*(unsigned long *)((char *)ptr + size));
+#else
+ ErrorF("Xalloc error: Tail corrupt in Xfree() for small block (adr=0x%x, val=0x%x)\n",(char *)ptr + size,*(unsigned long *)((char *)ptr + size));
+ XfreeTrap();
+#endif
+ LOG_FREE("Xalloc error: Tail corrupt in Xfree() for small block", ptr);
+ return;
+ }
+#endif /* SIZE_TAIL */
+
+#ifdef XFREE_ERASES
+ memset(ptr,0xF0,size);
+#endif /* XFREE_ERASES */
+#ifdef XALLOC_DEBUG
+ pheader[1] = MAGIC_FREE;
+#endif
+ /* put this small block at the head of the list */
+ indx = (size-1) / SIZE_STEPS;
+ *(unsigned long **)(ptr) = free_lists[indx];
+ free_lists[indx] = (unsigned long *)ptr;
+ LOG_FREE("Xfree", ptr);
+ return;
+
+#if defined(HAS_MMAP_ANON) || defined(MMAP_DEV_ZERO)
+ } else if (size >= MIN_LARGE) {
+ /*
+ * large block
+ */
+#ifdef SIZE_TAIL
+ if (MAGIC2 != ((unsigned long *)((char *)ptr + size))[0]) {
+ /* Diagnostic */
+#ifdef FATALERRORS
+ XfreeTrap();
+ FatalError("Xalloc error: Tail corrupt in Xfree() for big block (adr=0x%x, val=0x%x)\n",(char *)ptr+size,((unsigned long *)((char *)ptr + size))[0]);
+#else
+ ErrorF("Xalloc error: Tail corrupt in Xfree() for big block (adr=0x%x, val=0x%x)\n",(char *)ptr+size,((unsigned long *)((char *)ptr + size))[0]);
+ XfreeTrap();
+#endif
+ LOG_FREE("Xalloc error: Tail corrupt in Xfree() for big block", ptr);
+ return;
+ }
+ size += SIZE_TAIL;
+#endif /* SIZE_TAIL */
+
+ LOG_FREE("Xfree", ptr);
+ size += SIZE_HEADER;
+ munmap((caddr_t)pheader, (size_t)size);
+ /* no need to clear - mem is inaccessible after munmap.. */
+#endif /* HAS_MMAP_ANON */
+
+ } else {
+ /*
+ * medium sized block
+ */
+#ifdef SIZE_TAIL
+ if (MAGIC2 != *(unsigned long *)((char *)ptr + size)) {
+ /* Diagnostic */
+#ifdef FATALERRORS
+ XfreeTrap();
+ FatalError("Xalloc error: Tail corrupt in Xfree() for medium block (adr=0x%x, val=0x%x)\n",(char *)ptr + size,*(unsigned long *)((char *)ptr + size));
+#else
+ ErrorF("Xalloc error: Tail corrupt in Xfree() for medium block (adr=0x%x, val=0x%x)\n",(char *)ptr + size,*(unsigned long *)((char *)ptr + size));
+ XfreeTrap();
+#endif
+ LOG_FREE("Xalloc error: Tail corrupt in Xfree() for medium block", ptr);
+ return;
+ }
+#endif /* SIZE_TAIL */
+
+#ifdef XFREE_ERASES
+ memset(pheader,0xF0,size+SIZE_HEADER);
+#endif /* XFREE_ERASES */
+#ifdef XALLOC_DEBUG
+ pheader[1] = MAGIC_FREE;
+#endif
+
+ LOG_FREE("Xfree", ptr);
+ free((char *)pheader);
+ }
+}
+
+void
+OsInitAllocator (void)
+{
+ static Bool beenhere = FALSE;
+
+ if (beenhere)
+ return;
+ beenhere = TRUE;
+
+#if defined(HAS_MMAP_ANON) || defined (MMAP_DEV_ZERO)
+ pagesize = -1;
+#if defined(_SC_PAGESIZE) || defined(HAS_SC_PAGESIZE)
+ pagesize = sysconf(_SC_PAGESIZE);
+#endif
+#ifdef _SC_PAGE_SIZE
+ if (pagesize == -1)
+ pagesize = sysconf(_SC_PAGE_SIZE);
+#endif
+#ifdef HAS_GETPAGESIZE
+ if (pagesize == -1)
+ pagesize = getpagesize();
+#endif
+#ifdef PAGE_SIZE
+ if (pagesize == -1)
+ pagesize = PAGE_SIZE;
+#endif
+ if (pagesize == -1)
+ FatalError("OsInitAllocator: Cannot determine page size\n");
+#endif
+
+ /* set up linked lists of free blocks */
+ bzero ((char *) free_lists, MAX_SMALL/SIZE_STEPS*sizeof(unsigned long *));
+
+#ifdef MMAP_DEV_ZERO
+ /* open /dev/zero on systems that have mmap, but not MAP_ANON */
+ if (devzerofd < 0) {
+ if ((devzerofd = open("/dev/zero", O_RDWR, 0)) < 0)
+ FatalError("OsInitAllocator: Cannot open /dev/zero (errno=%d)\n",
+ errno);
+ }
+#endif
+
+#ifdef XALLOC_LOG
+ /* reset the log file to zero length */
+ {
+ FILE *f;
+ f = fopen(XALLOC_LOG_FILE, "w");
+ if (NULL!=f)
+ fclose(f);
+ }
+#endif
+}
+
+#else /* !INTERNAL_MALLOC */
+/* This is to avoid an empty .o */
+static int no_internal_xalloc;
+#endif /* INTERNAL_MALLOC */
diff --git a/nx-X11/programs/Xserver/os/xdmauth.c b/nx-X11/programs/Xserver/os/xdmauth.c
new file mode 100644
index 000000000..e02ca349c
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/xdmauth.c
@@ -0,0 +1,502 @@
+/* $Xorg: xdmauth.c,v 1.4 2001/02/09 02:05:24 xorgcvs Exp $ */
+/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xdmauth.c,v 1.7 2002/11/05 05:50:34 keithp Exp $ */
+
+/*
+ * XDM-AUTHENTICATION-1 (XDMCP authentication) and
+ * XDM-AUTHORIZATION-1 (client authorization) protocols
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <X11/X.h>
+#include <X11/Xtrans/Xtrans.h>
+#include "os.h"
+#include "osdep.h"
+#include "dixstruct.h"
+
+#ifdef HASXDMAUTH
+
+static Bool authFromXDMCP;
+
+#ifdef XDMCP
+#include <X11/Xmd.h>
+#undef REQUEST
+#include <X11/Xdmcp.h>
+
+/* XDM-AUTHENTICATION-1 */
+
+static XdmAuthKeyRec privateKey;
+static char XdmAuthenticationName[] = "XDM-AUTHENTICATION-1";
+#define XdmAuthenticationNameLen (sizeof XdmAuthenticationName - 1)
+static XdmAuthKeyRec rho;
+
+static Bool
+XdmAuthenticationValidator (ARRAY8Ptr privateData, ARRAY8Ptr incomingData,
+ xdmOpCode packet_type)
+{
+ XdmAuthKeyPtr incoming;
+
+ XdmcpUnwrap (incomingData->data, &privateKey,
+ incomingData->data,incomingData->length);
+ switch (packet_type)
+ {
+ case ACCEPT:
+ if (incomingData->length != 8)
+ return FALSE;
+ incoming = (XdmAuthKeyPtr) incomingData->data;
+ XdmcpDecrementKey (incoming);
+ return XdmcpCompareKeys (incoming, &rho);
+ }
+ return FALSE;
+}
+
+static Bool
+XdmAuthenticationGenerator (ARRAY8Ptr privateData, ARRAY8Ptr outgoingData,
+ xdmOpCode packet_type)
+{
+ outgoingData->length = 0;
+ outgoingData->data = 0;
+ switch (packet_type)
+ {
+ case REQUEST:
+ if (XdmcpAllocARRAY8 (outgoingData, 8))
+ XdmcpWrap (&rho, &privateKey, outgoingData->data, 8);
+ }
+ return TRUE;
+}
+
+static Bool
+XdmAuthenticationAddAuth (int name_len, char *name,
+ int data_len, char *data)
+{
+ Bool ret;
+ XdmcpUnwrap (data, (unsigned char *)&privateKey, data, data_len);
+ authFromXDMCP = TRUE;
+ ret = AddAuthorization (name_len, name, data_len, data);
+ authFromXDMCP = FALSE;
+ return ret;
+}
+
+
+#define atox(c) ('0' <= c && c <= '9' ? c - '0' : \
+ 'a' <= c && c <= 'f' ? c - 'a' + 10 : \
+ 'A' <= c && c <= 'F' ? c - 'A' + 10 : -1)
+
+static int
+HexToBinary (char *in, char *out, int len)
+{
+ int top, bottom;
+
+ while (len > 0)
+ {
+ top = atox(in[0]);
+ if (top == -1)
+ return 0;
+ bottom = atox(in[1]);
+ if (bottom == -1)
+ return 0;
+ *out++ = (top << 4) | bottom;
+ in += 2;
+ len -= 2;
+ }
+ if (len)
+ return 0;
+ *out++ = '\0';
+ return 1;
+}
+
+void
+XdmAuthenticationInit (char *cookie, int cookie_len)
+{
+ bzero (privateKey.data, 8);
+ if (!strncmp (cookie, "0x", 2) || !strncmp (cookie, "0X", 2))
+ {
+ if (cookie_len > 2 + 2 * 8)
+ cookie_len = 2 + 2 * 8;
+ HexToBinary (cookie + 2, (char *)privateKey.data, cookie_len - 2);
+ }
+ else
+ {
+ if (cookie_len > 7)
+ cookie_len = 7;
+ memmove (privateKey.data + 1, cookie, cookie_len);
+ }
+ XdmcpGenerateKey (&rho);
+ XdmcpRegisterAuthentication (XdmAuthenticationName, XdmAuthenticationNameLen,
+ (unsigned char *)&rho,
+ sizeof (rho),
+ XdmAuthenticationValidator,
+ XdmAuthenticationGenerator,
+ XdmAuthenticationAddAuth);
+}
+
+#endif /* XDMCP */
+
+/* XDM-AUTHORIZATION-1 */
+typedef struct _XdmAuthorization {
+ struct _XdmAuthorization *next;
+ XdmAuthKeyRec rho;
+ XdmAuthKeyRec key;
+ XID id;
+} XdmAuthorizationRec, *XdmAuthorizationPtr;
+
+static XdmAuthorizationPtr xdmAuth;
+
+typedef struct _XdmClientAuth {
+ struct _XdmClientAuth *next;
+ XdmAuthKeyRec rho;
+ char client[6];
+ long time;
+} XdmClientAuthRec, *XdmClientAuthPtr;
+
+static XdmClientAuthPtr xdmClients;
+static long clockOffset;
+static Bool gotClock;
+
+#define TwentyMinutes (20 * 60)
+#define TwentyFiveMinutes (25 * 60)
+
+static Bool
+XdmClientAuthCompare (XdmClientAuthPtr a, XdmClientAuthPtr b)
+{
+ int i;
+
+ if (!XdmcpCompareKeys (&a->rho, &b->rho))
+ return FALSE;
+ for (i = 0; i < 6; i++)
+ if (a->client[i] != b->client[i])
+ return FALSE;
+ return a->time == b->time;
+}
+
+static void
+XdmClientAuthDecode (unsigned char *plain, XdmClientAuthPtr auth)
+{
+ int i, j;
+
+ j = 0;
+ for (i = 0; i < 8; i++)
+ {
+ auth->rho.data[i] = plain[j];
+ ++j;
+ }
+ for (i = 0; i < 6; i++)
+ {
+ auth->client[i] = plain[j];
+ ++j;
+ }
+ auth->time = 0;
+ for (i = 0; i < 4; i++)
+ {
+ auth->time |= plain[j] << ((3 - i) << 3);
+ j++;
+ }
+}
+
+static void
+XdmClientAuthTimeout (long now)
+{
+ XdmClientAuthPtr client, next, prev;
+
+ prev = 0;
+ for (client = xdmClients; client; client=next)
+ {
+ next = client->next;
+ if (abs (now - client->time) > TwentyFiveMinutes)
+ {
+ if (prev)
+ prev->next = next;
+ else
+ xdmClients = next;
+ xfree (client);
+ }
+ else
+ prev = client;
+ }
+}
+
+static XdmClientAuthPtr
+XdmAuthorizationValidate (unsigned char *plain, int length,
+ XdmAuthKeyPtr rho, ClientPtr xclient, char **reason)
+{
+ XdmClientAuthPtr client, existing;
+ long now;
+ int i;
+
+ if (length != (192 / 8)) {
+ if (reason)
+ *reason = "Bad XDM authorization key length";
+ return NULL;
+ }
+ client = (XdmClientAuthPtr) xalloc (sizeof (XdmClientAuthRec));
+ if (!client)
+ return NULL;
+ XdmClientAuthDecode (plain, client);
+ if (!XdmcpCompareKeys (&client->rho, rho))
+ {
+ xfree (client);
+ if (reason)
+ *reason = "Invalid XDM-AUTHORIZATION-1 key (failed key comparison)";
+ return NULL;
+ }
+ for (i = 18; i < 24; i++)
+ if (plain[i] != 0) {
+ xfree (client);
+ if (reason)
+ *reason = "Invalid XDM-AUTHORIZATION-1 key (failed NULL check)";
+ return NULL;
+ }
+ if (xclient) {
+ int family, addr_len;
+ Xtransaddr *addr;
+
+ if (_XSERVTransGetPeerAddr(((OsCommPtr)xclient->osPrivate)->trans_conn,
+ &family, &addr_len, &addr) == 0
+ && _XSERVTransConvertAddress(&family, &addr_len, &addr) == 0) {
+#if defined(TCPCONN) || defined(STREAMSCONN)
+ if (family == FamilyInternet &&
+ memcmp((char *)addr, client->client, 4) != 0) {
+ xfree (client);
+ xfree (addr);
+ if (reason)
+ *reason = "Invalid XDM-AUTHORIZATION-1 key (failed address comparison)";
+ return NULL;
+
+ }
+#endif
+ xfree (addr);
+ }
+ }
+ now = time(0);
+ if (!gotClock)
+ {
+ clockOffset = client->time - now;
+ gotClock = TRUE;
+ }
+ now += clockOffset;
+ XdmClientAuthTimeout (now);
+ if (abs (client->time - now) > TwentyMinutes)
+ {
+ xfree (client);
+ if (reason)
+ *reason = "Excessive XDM-AUTHORIZATION-1 time offset";
+ return NULL;
+ }
+ for (existing = xdmClients; existing; existing=existing->next)
+ {
+ if (XdmClientAuthCompare (existing, client))
+ {
+ xfree (client);
+ if (reason)
+ *reason = "XDM authorization key matches an existing client!";
+ return NULL;
+ }
+ }
+ return client;
+}
+
+int
+XdmAddCookie (unsigned short data_length, char *data, XID id)
+{
+ XdmAuthorizationPtr new;
+ unsigned char *rho_bits, *key_bits;
+
+ switch (data_length)
+ {
+ case 16: /* auth from files is 16 bytes long */
+#ifdef XDMCP
+ if (authFromXDMCP)
+ {
+ /* R5 xdm sent bogus authorization data in the accept packet,
+ * but we can recover */
+ rho_bits = rho.data;
+ key_bits = (unsigned char *) data;
+ key_bits[0] = '\0';
+ }
+ else
+#endif
+ {
+ rho_bits = (unsigned char *) data;
+ key_bits = (unsigned char *) (data + 8);
+ }
+ break;
+#ifdef XDMCP
+ case 8: /* auth from XDMCP is 8 bytes long */
+ rho_bits = rho.data;
+ key_bits = (unsigned char *) data;
+ break;
+#endif
+ default:
+ return 0;
+ }
+ /* the first octet of the key must be zero */
+ if (key_bits[0] != '\0')
+ return 0;
+ new = (XdmAuthorizationPtr) xalloc (sizeof (XdmAuthorizationRec));
+ if (!new)
+ return 0;
+ new->next = xdmAuth;
+ xdmAuth = new;
+ memmove (new->key.data, key_bits, (int) 8);
+ memmove (new->rho.data, rho_bits, (int) 8);
+ new->id = id;
+ return 1;
+}
+
+XID
+XdmCheckCookie (unsigned short cookie_length, char *cookie,
+ ClientPtr xclient, char **reason)
+{
+ XdmAuthorizationPtr auth;
+ XdmClientAuthPtr client;
+ unsigned char *plain;
+
+ /* Auth packets must be a multiple of 8 bytes long */
+ if (cookie_length & 7)
+ return (XID) -1;
+ plain = (unsigned char *) xalloc (cookie_length);
+ if (!plain)
+ return (XID) -1;
+ for (auth = xdmAuth; auth; auth=auth->next) {
+ XdmcpUnwrap (cookie, (unsigned char *)&auth->key, plain, cookie_length);
+ if ((client = XdmAuthorizationValidate (plain, cookie_length, &auth->rho, xclient, reason)) != NULL)
+ {
+ client->next = xdmClients;
+ xdmClients = client;
+ xfree (plain);
+ return auth->id;
+ }
+ }
+ xfree (plain);
+ return (XID) -1;
+}
+
+int
+XdmResetCookie (void)
+{
+ XdmAuthorizationPtr auth, next_auth;
+ XdmClientAuthPtr client, next_client;
+
+ for (auth = xdmAuth; auth; auth=next_auth)
+ {
+ next_auth = auth->next;
+ xfree (auth);
+ }
+ xdmAuth = 0;
+ for (client = xdmClients; client; client=next_client)
+ {
+ next_client = client->next;
+ xfree (client);
+ }
+ xdmClients = (XdmClientAuthPtr) 0;
+ return 1;
+}
+
+XID
+XdmToID (unsigned short cookie_length, char *cookie)
+{
+ XdmAuthorizationPtr auth;
+ XdmClientAuthPtr client;
+ unsigned char *plain;
+
+ plain = (unsigned char *) xalloc (cookie_length);
+ if (!plain)
+ return (XID) -1;
+ for (auth = xdmAuth; auth; auth=auth->next) {
+ XdmcpUnwrap (cookie, (unsigned char *)&auth->key, plain, cookie_length);
+ if ((client = XdmAuthorizationValidate (plain, cookie_length, &auth->rho, NULL, NULL)) != NULL)
+ {
+ xfree (client);
+ xfree (cookie);
+ return auth->id;
+ }
+ }
+ xfree (cookie);
+ return (XID) -1;
+}
+
+int
+XdmFromID (XID id, unsigned short *data_lenp, char **datap)
+{
+ XdmAuthorizationPtr auth;
+
+ for (auth = xdmAuth; auth; auth=auth->next) {
+ if (id == auth->id) {
+ *data_lenp = 16;
+ *datap = (char *) &auth->rho;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int
+XdmRemoveCookie (unsigned short data_length, char *data)
+{
+ XdmAuthorizationPtr auth, prev;
+ XdmAuthKeyPtr key_bits, rho_bits;
+
+ prev = 0;
+ switch (data_length)
+ {
+ case 16:
+ rho_bits = (XdmAuthKeyPtr) data;
+ key_bits = (XdmAuthKeyPtr) (data + 8);
+ break;
+#ifdef XDMCP
+ case 8:
+ rho_bits = &rho;
+ key_bits = (XdmAuthKeyPtr) data;
+ break;
+#endif
+ default:
+ return 0;
+ }
+ for (auth = xdmAuth; auth; auth=auth->next) {
+ if (XdmcpCompareKeys (rho_bits, &auth->rho) &&
+ XdmcpCompareKeys (key_bits, &auth->key))
+ {
+ if (prev)
+ prev->next = auth->next;
+ else
+ xdmAuth = auth->next;
+ xfree (auth);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+#endif
diff --git a/nx-X11/programs/Xserver/os/xdmcp.c b/nx-X11/programs/Xserver/os/xdmcp.c
new file mode 100644
index 000000000..032d58f15
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/xdmcp.c
@@ -0,0 +1,1710 @@
+/* $XdotOrg: xc/programs/Xserver/os/xdmcp.c,v 1.10 2005/07/03 08:53:52 daniels Exp $ */
+/* $Xorg: xdmcp.c,v 1.4 2001/01/31 13:37:19 pookie Exp $ */
+/*
+ * Copyright 1989 Network Computing Devices, Inc., Mountain View, California.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of N.C.D. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. N.C.D. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/os/xdmcp.c,v 3.31 2003/12/30 21:24:32 herrb Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#endif
+
+#include <X11/Xos.h>
+
+#if !defined(WIN32)
+#ifndef Lynx
+#include <sys/param.h>
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif
+#include <netinet/in.h>
+#include <netdb.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "misc.h"
+#include <X11/Xpoll.h>
+#include "osdep.h"
+#include "input.h"
+#include "dixstruct.h"
+#include "opaque.h"
+
+#if defined(DGUX)
+#include <net/net_ioctl.h>
+#include <sys/ioctl.h>
+#endif
+
+#ifdef STREAMSCONN
+#include <tiuser.h>
+#include <netconfig.h>
+#include <netdir.h>
+#endif
+
+#ifndef NX_TRANS_SOCKET
+
+#define NX_TRANS_SOCKET
+#define NX_TRANS_TEST
+
+#endif
+
+#ifdef XDMCP
+#undef REQUEST
+
+#ifdef XDMCP_NO_IPV6
+#undef IPv6
+#endif
+
+#include <X11/Xdmcp.h>
+
+#define X_INCLUDE_NETDB_H
+#include <X11/Xos_r.h>
+
+#ifdef NX_TRANS_SOCKET
+
+xdmcp_states XdmcpState;
+
+int XdmcpStartTime;
+int XdmcpTimeOutRtx;
+
+#endif
+
+extern char *defaultDisplayClass;
+
+static int xdmcpSocket, sessionSocket;
+static xdmcp_states state;
+#if defined(IPv6) && defined(AF_INET6)
+static int xdmcpSocket6;
+static struct sockaddr_storage req_sockaddr;
+#else
+static struct sockaddr_in req_sockaddr;
+#endif
+static int req_socklen;
+static CARD32 SessionID;
+static CARD32 timeOutTime;
+static int timeOutRtx;
+static CARD32 defaultKeepaliveDormancy = XDM_DEF_DORMANCY;
+static CARD32 keepaliveDormancy = XDM_DEF_DORMANCY;
+static CARD16 DisplayNumber;
+static xdmcp_states XDM_INIT_STATE = XDM_OFF;
+#ifdef HASXDMAUTH
+static char *xdmAuthCookie;
+#endif
+
+static XdmcpBuffer buffer;
+
+#if defined(IPv6) && defined(AF_INET6)
+
+static struct addrinfo *mgrAddr;
+static struct addrinfo *mgrAddrFirst;
+
+#define SOCKADDR_TYPE struct sockaddr_storage
+#define SOCKADDR_FAMILY(s) ((struct sockaddr *)&(s))->sa_family
+
+#ifdef BSD44SOCKETS
+#define SOCKLEN_FIELD(s) ((struct sockaddr *)&(s))->sa_len
+#define SOCKLEN_TYPE unsigned char
+#else
+#define SOCKLEN_TYPE unsigned int
+#endif
+
+#else
+
+#define SOCKADDR_TYPE struct sockaddr_in
+#define SOCKADDR_FAMILY(s) (s).sin_family
+
+#ifdef BSD44SOCKETS
+#define SOCKLEN_FIELD(s) (s).sin_len
+#define SOCKLEN_TYPE unsigned char
+#else
+#define SOCKLEN_TYPE size_t
+#endif
+
+#endif
+
+static SOCKADDR_TYPE ManagerAddress;
+static SOCKADDR_TYPE FromAddress;
+
+#ifdef SOCKLEN_FIELD
+#define ManagerAddressLen SOCKLEN_FIELD(ManagerAddress)
+#define FromAddressLen SOCKLEN_FIELD(FromAddress)
+#else
+static SOCKLEN_TYPE ManagerAddressLen, FromAddressLen;
+#endif
+
+#if defined(IPv6) && defined(AF_INET6)
+static struct multicastinfo {
+ struct multicastinfo *next;
+ struct addrinfo *ai;
+ int hops;
+} *mcastlist;
+#endif
+
+static void XdmcpAddHost(
+ struct sockaddr *from,
+ int fromlen,
+ ARRAY8Ptr AuthenticationName,
+ ARRAY8Ptr hostname,
+ ARRAY8Ptr status);
+
+static void XdmcpSelectHost(
+ struct sockaddr *host_sockaddr,
+ int host_len,
+ ARRAY8Ptr AuthenticationName);
+
+static void get_xdmcp_sock(void);
+
+static void send_query_msg(void);
+
+static void recv_willing_msg(
+ struct sockaddr * /*from*/,
+ int /*fromlen*/,
+ unsigned /*length*/);
+
+static void send_request_msg(void);
+
+static void recv_accept_msg(unsigned /*length*/);
+
+static void recv_decline_msg(unsigned /*length*/);
+
+static void send_manage_msg(void);
+
+static void recv_refuse_msg(unsigned /*length*/);
+
+static void recv_failed_msg(unsigned /*length*/);
+
+static void send_keepalive_msg(void);
+
+static void recv_alive_msg(unsigned /*length*/);
+
+static void XdmcpFatal(
+ char * /*type*/,
+ ARRAY8Ptr /*status*/);
+
+static void XdmcpWarning(char * /*str*/);
+
+static void get_manager_by_name(
+ int /*argc*/,
+ char ** /*argv*/,
+ int /*i*/);
+
+static void get_fromaddr_by_name(int /*argc*/, char ** /*argv*/, int /*i*/);
+
+#if defined(IPv6) && defined(AF_INET6)
+static int get_mcast_options(int /*argc*/, char ** /*argv*/, int /*i*/);
+#endif
+
+static void receive_packet(int /*socketfd*/);
+
+static void send_packet(void);
+
+extern void XdmcpDeadSession(char * /*reason*/);
+
+static void timeout(void);
+
+static void restart(void);
+
+static void XdmcpBlockHandler(
+ pointer /*data*/,
+ struct timeval ** /*wt*/,
+ pointer /*LastSelectMask*/);
+
+static void XdmcpWakeupHandler(
+ pointer /*data*/,
+ int /*i*/,
+ pointer /*LastSelectMask*/);
+
+void XdmcpRegisterManufacturerDisplayID(
+ char * /*name*/,
+ int /*length*/);
+
+
+static unsigned short xdm_udp_port = XDM_UDP_PORT;
+static Bool OneSession = FALSE;
+static const char *xdm_from = NULL;
+
+void
+XdmcpUseMsg (void)
+{
+ ErrorF("-query host-name contact named host for XDMCP\n");
+ ErrorF("-broadcast broadcast for XDMCP\n");
+#if defined(IPv6) && defined(AF_INET6)
+ ErrorF("-multicast [addr [hops]] IPv6 multicast for XDMCP\n");
+#endif
+ ErrorF("-indirect host-name contact named host for indirect XDMCP\n");
+ ErrorF("-port port-num UDP port number to send messages to\n");
+ ErrorF("-from local-address specify the local address to connect from\n");
+ ErrorF("-once Terminate server after one session\n");
+ ErrorF("-class display-class specify display class to send in manage\n");
+#ifdef HASXDMAUTH
+ ErrorF("-cookie xdm-auth-bits specify the magic cookie for XDMCP\n");
+#endif
+ ErrorF("-displayID display-id manufacturer display ID for request\n");
+}
+
+int
+XdmcpOptions(int argc, char **argv, int i)
+{
+ if (strcmp(argv[i], "-query") == 0) {
+ get_manager_by_name(argc, argv, i++);
+ XDM_INIT_STATE = XDM_QUERY;
+ AccessUsingXdmcp ();
+ return (i + 1);
+ }
+ if (strcmp(argv[i], "-broadcast") == 0) {
+ XDM_INIT_STATE = XDM_BROADCAST;
+ AccessUsingXdmcp ();
+ return (i + 1);
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ if (strcmp(argv[i], "-multicast") == 0) {
+ i = get_mcast_options(argc, argv, ++i);
+ XDM_INIT_STATE = XDM_MULTICAST;
+ AccessUsingXdmcp ();
+ return (i + 1);
+ }
+#endif
+ if (strcmp(argv[i], "-indirect") == 0) {
+ get_manager_by_name(argc, argv, i++);
+ XDM_INIT_STATE = XDM_INDIRECT;
+ AccessUsingXdmcp ();
+ return (i + 1);
+ }
+ if (strcmp(argv[i], "-port") == 0) {
+ if (++i == argc) {
+ FatalError("Xserver: missing port number in command line\n");
+ }
+ xdm_udp_port = (unsigned short) atoi(argv[i]);
+ return (i + 1);
+ }
+ if (strcmp(argv[i], "-from") == 0) {
+ get_fromaddr_by_name(argc, argv, ++i);
+ return (i + 1);
+ }
+ if (strcmp(argv[i], "-once") == 0) {
+ OneSession = TRUE;
+ return (i + 1);
+ }
+ if (strcmp(argv[i], "-class") == 0) {
+ if (++i == argc) {
+ FatalError("Xserver: missing class name in command line\n");
+ }
+ defaultDisplayClass = argv[i];
+ return (i + 1);
+ }
+#ifdef HASXDMAUTH
+ if (strcmp(argv[i], "-cookie") == 0) {
+ if (++i == argc) {
+ FatalError("Xserver: missing cookie data in command line\n");
+ }
+ xdmAuthCookie = argv[i];
+ return (i + 1);
+ }
+#endif
+ if (strcmp(argv[i], "-displayID") == 0) {
+ if (++i == argc) {
+ FatalError("Xserver: missing displayID in command line\n");
+ }
+ XdmcpRegisterManufacturerDisplayID (argv[i], strlen (argv[i]));
+ return (i + 1);
+ }
+ return (i);
+}
+
+/*
+ * This section is a collection of routines for
+ * registering server-specific data with the XDMCP
+ * state machine.
+ */
+
+
+/*
+ * Save all broadcast addresses away so BroadcastQuery
+ * packets get sent everywhere
+ */
+
+#define MAX_BROADCAST 10
+
+/* This stays sockaddr_in since IPv6 doesn't support broadcast */
+static struct sockaddr_in BroadcastAddresses[MAX_BROADCAST];
+static int NumBroadcastAddresses;
+
+void
+XdmcpRegisterBroadcastAddress (struct sockaddr_in *addr)
+{
+ struct sockaddr_in *bcast;
+ if (NumBroadcastAddresses >= MAX_BROADCAST)
+ return;
+ bcast = &BroadcastAddresses[NumBroadcastAddresses++];
+ bzero (bcast, sizeof (struct sockaddr_in));
+#ifdef BSD44SOCKETS
+ bcast->sin_len = addr->sin_len;
+#endif
+ bcast->sin_family = addr->sin_family;
+ bcast->sin_port = htons (xdm_udp_port);
+ bcast->sin_addr = addr->sin_addr;
+}
+
+/*
+ * Each authentication type is registered here; Validator
+ * will be called to check all access attempts using
+ * the specified authentication type
+ */
+
+static ARRAYofARRAY8 AuthenticationNames, AuthenticationDatas;
+typedef struct _AuthenticationFuncs {
+ ValidatorFunc Validator;
+ GeneratorFunc Generator;
+ AddAuthorFunc AddAuth;
+} AuthenticationFuncsRec, *AuthenticationFuncsPtr;
+
+static AuthenticationFuncsPtr AuthenticationFuncsList;
+
+void
+XdmcpRegisterAuthentication (
+ char *name,
+ int namelen,
+ char *data,
+ int datalen,
+ ValidatorFunc Validator,
+ GeneratorFunc Generator,
+ AddAuthorFunc AddAuth)
+{
+ int i;
+ ARRAY8 AuthenticationName, AuthenticationData;
+ static AuthenticationFuncsPtr newFuncs;
+
+ if (!XdmcpAllocARRAY8 (&AuthenticationName, namelen))
+ return;
+ if (!XdmcpAllocARRAY8 (&AuthenticationData, datalen))
+ {
+ XdmcpDisposeARRAY8 (&AuthenticationName);
+ return;
+ }
+ for (i = 0; i < namelen; i++)
+ AuthenticationName.data[i] = name[i];
+ for (i = 0; i < datalen; i++)
+ AuthenticationData.data[i] = data[i];
+ if (!(XdmcpReallocARRAYofARRAY8 (&AuthenticationNames,
+ AuthenticationNames.length + 1) &&
+ XdmcpReallocARRAYofARRAY8 (&AuthenticationDatas,
+ AuthenticationDatas.length + 1) &&
+ (newFuncs = (AuthenticationFuncsPtr) xalloc (
+ (AuthenticationNames.length + 1) * sizeof (AuthenticationFuncsRec)))))
+ {
+ XdmcpDisposeARRAY8 (&AuthenticationName);
+ XdmcpDisposeARRAY8 (&AuthenticationData);
+ return;
+ }
+ for (i = 0; i < AuthenticationNames.length - 1; i++)
+ newFuncs[i] = AuthenticationFuncsList[i];
+ newFuncs[AuthenticationNames.length-1].Validator = Validator;
+ newFuncs[AuthenticationNames.length-1].Generator = Generator;
+ newFuncs[AuthenticationNames.length-1].AddAuth = AddAuth;
+ xfree (AuthenticationFuncsList);
+ AuthenticationFuncsList = newFuncs;
+ AuthenticationNames.data[AuthenticationNames.length-1] = AuthenticationName;
+ AuthenticationDatas.data[AuthenticationDatas.length-1] = AuthenticationData;
+}
+
+/*
+ * Select the authentication type to be used; this is
+ * set by the manager of the host to be connected to.
+ */
+
+ARRAY8 noAuthenticationName = {(CARD16) 0, (CARD8Ptr) 0};
+ARRAY8 noAuthenticationData = {(CARD16) 0, (CARD8Ptr) 0};
+ARRAY8Ptr AuthenticationName = &noAuthenticationName;
+ARRAY8Ptr AuthenticationData = &noAuthenticationData;
+AuthenticationFuncsPtr AuthenticationFuncs;
+
+void
+XdmcpSetAuthentication (ARRAY8Ptr name)
+{
+ int i;
+
+ for (i = 0; i < AuthenticationNames.length; i++)
+ if (XdmcpARRAY8Equal (&AuthenticationNames.data[i], name))
+ {
+ AuthenticationName = &AuthenticationNames.data[i];
+ AuthenticationData = &AuthenticationDatas.data[i];
+ AuthenticationFuncs = &AuthenticationFuncsList[i];
+ break;
+ }
+}
+
+/*
+ * Register the host address for the display
+ */
+
+static ARRAY16 ConnectionTypes;
+static ARRAYofARRAY8 ConnectionAddresses;
+static long xdmcpGeneration;
+
+void
+XdmcpRegisterConnection (
+ int type,
+ char *address,
+ int addrlen)
+{
+ int i;
+ CARD8 *newAddress;
+
+ if (xdmcpGeneration != serverGeneration)
+ {
+ XdmcpDisposeARRAY16 (&ConnectionTypes);
+ XdmcpDisposeARRAYofARRAY8 (&ConnectionAddresses);
+ xdmcpGeneration = serverGeneration;
+ }
+ if (xdm_from != NULL) { /* Only register the requested address */
+ const void *regAddr = address;
+ const void *fromAddr = NULL;
+ int regAddrlen = addrlen;
+
+ if (addrlen == sizeof(struct in_addr)) {
+ if (SOCKADDR_FAMILY(FromAddress) == AF_INET) {
+ fromAddr = &((struct sockaddr_in *)&FromAddress)->sin_addr;
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ else if ((SOCKADDR_FAMILY(FromAddress) == AF_INET6) &&
+ IN6_IS_ADDR_V4MAPPED(
+ &((struct sockaddr_in6 *)&FromAddress)->sin6_addr)) {
+ fromAddr = &((struct sockaddr_in6 *)&FromAddress)->sin6_addr.s6_addr[12];
+ }
+#endif
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ else if (addrlen == sizeof(struct in6_addr)) {
+ if (SOCKADDR_FAMILY(FromAddress) == AF_INET6) {
+ fromAddr = &((struct sockaddr_in6 *)&FromAddress)->sin6_addr;
+ } else if ((SOCKADDR_FAMILY(FromAddress) == AF_INET) &&
+ IN6_IS_ADDR_V4MAPPED((struct in6_addr *) address)) {
+ fromAddr = &((struct sockaddr_in *)&FromAddress)->sin_addr;
+ regAddr = &((struct sockaddr_in6 *)&address)->sin6_addr.s6_addr[12];
+ regAddrlen = sizeof(struct in_addr);
+ }
+ }
+#endif
+ if (fromAddr && memcmp(regAddr, fromAddr, regAddrlen) != 0) {
+ return;
+ }
+ }
+ newAddress = (CARD8 *) xalloc (addrlen * sizeof (CARD8));
+ if (!newAddress)
+ return;
+ if (!XdmcpReallocARRAY16 (&ConnectionTypes, ConnectionTypes.length + 1))
+ {
+ xfree (newAddress);
+ return;
+ }
+ if (!XdmcpReallocARRAYofARRAY8 (&ConnectionAddresses,
+ ConnectionAddresses.length + 1))
+ {
+ xfree (newAddress);
+ return;
+ }
+ ConnectionTypes.data[ConnectionTypes.length - 1] = (CARD16) type;
+ for (i = 0; i < addrlen; i++)
+ newAddress[i] = address[i];
+ ConnectionAddresses.data[ConnectionAddresses.length-1].data = newAddress;
+ ConnectionAddresses.data[ConnectionAddresses.length-1].length = addrlen;
+}
+
+/*
+ * Register an Authorization Name. XDMCP advertises this list
+ * to the manager.
+ */
+
+static ARRAYofARRAY8 AuthorizationNames;
+
+void
+XdmcpRegisterAuthorizations (void)
+{
+ XdmcpDisposeARRAYofARRAY8 (&AuthorizationNames);
+ RegisterAuthorizations ();
+}
+
+void
+XdmcpRegisterAuthorization (char *name, int namelen)
+{
+ ARRAY8 authName;
+ int i;
+
+ authName.data = (CARD8 *) xalloc (namelen * sizeof (CARD8));
+ if (!authName.data)
+ return;
+ if (!XdmcpReallocARRAYofARRAY8 (&AuthorizationNames, AuthorizationNames.length +1))
+ {
+ xfree (authName.data);
+ return;
+ }
+ for (i = 0; i < namelen; i++)
+ authName.data[i] = (CARD8) name[i];
+ authName.length = namelen;
+ AuthorizationNames.data[AuthorizationNames.length-1] = authName;
+}
+
+/*
+ * Register the DisplayClass string
+ */
+
+ARRAY8 DisplayClass;
+
+void
+XdmcpRegisterDisplayClass (char *name, int length)
+{
+ int i;
+
+ XdmcpDisposeARRAY8 (&DisplayClass);
+ if (!XdmcpAllocARRAY8 (&DisplayClass, length))
+ return;
+ for (i = 0; i < length; i++)
+ DisplayClass.data[i] = (CARD8) name[i];
+}
+
+/*
+ * Register the Manufacturer display ID
+ */
+
+ARRAY8 ManufacturerDisplayID;
+
+void
+XdmcpRegisterManufacturerDisplayID (char *name, int length)
+{
+ int i;
+
+ XdmcpDisposeARRAY8 (&ManufacturerDisplayID);
+ if (!XdmcpAllocARRAY8 (&ManufacturerDisplayID, length))
+ return;
+ for (i = 0; i < length; i++)
+ ManufacturerDisplayID.data[i] = (CARD8) name[i];
+}
+
+/*
+ * initialize XDMCP; create the socket, compute the display
+ * number, set up the state machine
+ */
+
+void
+XdmcpInit(void)
+{
+#ifdef NX_TRANS_SOCKET
+
+ XdmcpStartTime = GetTimeInMillis();
+
+#endif
+
+ state = XDM_INIT_STATE;
+#ifdef HASXDMAUTH
+ if (xdmAuthCookie)
+ XdmAuthenticationInit (xdmAuthCookie, strlen (xdmAuthCookie));
+#endif
+ if (state != XDM_OFF)
+ {
+ XdmcpRegisterAuthorizations();
+ XdmcpRegisterDisplayClass (defaultDisplayClass, strlen (defaultDisplayClass));
+ AccessUsingXdmcp();
+ RegisterBlockAndWakeupHandlers (XdmcpBlockHandler, XdmcpWakeupHandler,
+ (pointer) 0);
+ timeOutRtx = 0;
+ DisplayNumber = (CARD16) atoi(display);
+ get_xdmcp_sock();
+ send_packet();
+ }
+}
+
+void
+XdmcpReset (void)
+{
+ state = XDM_INIT_STATE;
+ if (state != XDM_OFF)
+ {
+ RegisterBlockAndWakeupHandlers (XdmcpBlockHandler, XdmcpWakeupHandler,
+ (pointer) 0);
+ timeOutRtx = 0;
+ send_packet();
+ }
+}
+
+/*
+ * Called whenever a new connection is created; notices the
+ * first connection and saves it to terminate the session
+ * when it is closed
+ */
+
+void
+XdmcpOpenDisplay(int sock)
+{
+ if (state != XDM_AWAIT_MANAGE_RESPONSE)
+ return;
+ state = XDM_RUN_SESSION;
+ sessionSocket = sock;
+}
+
+void
+XdmcpCloseDisplay(int sock)
+{
+ if ((state != XDM_RUN_SESSION && state != XDM_AWAIT_ALIVE_RESPONSE)
+ || sessionSocket != sock)
+ return;
+ state = XDM_INIT_STATE;
+ if (OneSession)
+ dispatchException |= DE_TERMINATE;
+ else
+ dispatchException |= DE_RESET;
+ isItTimeToYield = TRUE;
+}
+
+/*
+ * called before going to sleep, this routine
+ * may modify the timeout value about to be sent
+ * to select; in this way XDMCP can do appropriate things
+ * dynamically while starting up
+ */
+
+/*ARGSUSED*/
+static void
+XdmcpBlockHandler(
+ pointer data, /* unused */
+ struct timeval **wt,
+ pointer pReadmask)
+{
+ fd_set *LastSelectMask = (fd_set*)pReadmask;
+ CARD32 millisToGo;
+
+ if (state == XDM_OFF)
+ return;
+ FD_SET(xdmcpSocket, LastSelectMask);
+#if defined(IPv6) && defined(AF_INET6)
+ if (xdmcpSocket6 >= 0)
+ FD_SET(xdmcpSocket6, LastSelectMask);
+#endif
+ if (timeOutTime == 0)
+ return;
+ millisToGo = timeOutTime - GetTimeInMillis();
+ if ((int) millisToGo < 0)
+ millisToGo = 0;
+ AdjustWaitForDelay (wt, millisToGo);
+}
+
+/*
+ * called after select returns; this routine will
+ * recognise when XDMCP packets await and
+ * process them appropriately
+ */
+
+/*ARGSUSED*/
+static void
+XdmcpWakeupHandler(
+ pointer data, /* unused */
+ int i,
+ pointer pReadmask)
+{
+ fd_set* LastSelectMask = (fd_set*)pReadmask;
+ fd_set devicesReadable;
+
+#ifdef NX_TRANS_SOCKET
+
+ XdmcpState = state;
+ XdmcpTimeOutRtx = timeOutRtx;
+
+#endif
+
+ if (state == XDM_OFF)
+ return;
+ if (i > 0)
+ {
+ if (FD_ISSET(xdmcpSocket, LastSelectMask))
+ {
+ receive_packet(xdmcpSocket);
+ FD_CLR(xdmcpSocket, LastSelectMask);
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ if (xdmcpSocket6 >= 0 && FD_ISSET(xdmcpSocket6, LastSelectMask))
+ {
+ receive_packet(xdmcpSocket6);
+ FD_CLR(xdmcpSocket6, LastSelectMask);
+ }
+#endif
+ XFD_ANDSET(&devicesReadable, LastSelectMask, &EnabledDevices);
+ if (XFD_ANYSET(&devicesReadable))
+ {
+ if (state == XDM_AWAIT_USER_INPUT)
+ restart();
+ else if (state == XDM_RUN_SESSION)
+ keepaliveDormancy = defaultKeepaliveDormancy;
+ }
+ if (XFD_ANYSET(&AllClients) && state == XDM_RUN_SESSION)
+ timeOutTime = GetTimeInMillis() + keepaliveDormancy * 1000;
+ }
+ else if (timeOutTime && (int) (GetTimeInMillis() - timeOutTime) >= 0)
+ {
+ if (state == XDM_RUN_SESSION)
+ {
+ state = XDM_KEEPALIVE;
+ send_packet();
+ }
+ else
+ timeout();
+ }
+}
+
+/*
+ * This routine should be called from the routine that drives the
+ * user's host menu when the user selects a host
+ */
+
+static void
+XdmcpSelectHost(
+ struct sockaddr *host_sockaddr,
+ int host_len,
+ ARRAY8Ptr AuthenticationName)
+{
+ state = XDM_START_CONNECTION;
+ memmove(&req_sockaddr, host_sockaddr, host_len);
+ req_socklen = host_len;
+ XdmcpSetAuthentication (AuthenticationName);
+ send_packet();
+}
+
+/*
+ * !!! this routine should be replaced by a routine that adds
+ * the host to the user's host menu. the current version just
+ * selects the first host to respond with willing message.
+ */
+
+/*ARGSUSED*/
+static void
+XdmcpAddHost(
+ struct sockaddr *from,
+ int fromlen,
+ ARRAY8Ptr AuthenticationName,
+ ARRAY8Ptr hostname,
+ ARRAY8Ptr status)
+{
+ XdmcpSelectHost(from, fromlen, AuthenticationName);
+}
+
+/*
+ * A message is queued on the socket; read it and
+ * do the appropriate thing
+ */
+
+ARRAY8 UnwillingMessage = { (CARD8) 14, (CARD8 *) "Host unwilling" };
+
+static void
+receive_packet(int socketfd)
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_storage from;
+#else
+ struct sockaddr_in from;
+#endif
+ int fromlen = sizeof(from);
+ XdmcpHeader header;
+
+ /* read message off socket */
+ if (!XdmcpFill (socketfd, &buffer, (XdmcpNetaddr) &from, &fromlen))
+ return;
+
+ /* reset retransmission backoff */
+ timeOutRtx = 0;
+
+ if (!XdmcpReadHeader (&buffer, &header))
+ return;
+
+ if (header.version != XDM_PROTOCOL_VERSION)
+ return;
+
+ switch (header.opcode) {
+ case WILLING:
+ recv_willing_msg((struct sockaddr *) &from, fromlen, header.length);
+ break;
+ case UNWILLING:
+ XdmcpFatal("Manager unwilling", &UnwillingMessage);
+ break;
+ case ACCEPT:
+ recv_accept_msg(header.length);
+ break;
+ case DECLINE:
+ recv_decline_msg(header.length);
+ break;
+ case REFUSE:
+ recv_refuse_msg(header.length);
+ break;
+ case FAILED:
+ recv_failed_msg(header.length);
+ break;
+ case ALIVE:
+ recv_alive_msg(header.length);
+ break;
+ }
+}
+
+/*
+ * send the appropriate message given the current state
+ */
+
+static void
+send_packet(void)
+{
+ int rtx;
+ switch (state) {
+ case XDM_QUERY:
+ case XDM_BROADCAST:
+ case XDM_INDIRECT:
+#if defined(IPv6) && defined(AF_INET6)
+ case XDM_MULTICAST:
+#endif
+ send_query_msg();
+ break;
+ case XDM_START_CONNECTION:
+ send_request_msg();
+ break;
+ case XDM_MANAGE:
+ send_manage_msg();
+ break;
+ case XDM_KEEPALIVE:
+ send_keepalive_msg();
+ break;
+ default:
+ break;
+ }
+ rtx = (XDM_MIN_RTX << timeOutRtx);
+ if (rtx > XDM_MAX_RTX)
+ rtx = XDM_MAX_RTX;
+ timeOutTime = GetTimeInMillis() + rtx * 1000;
+}
+
+/*
+ * The session is declared dead for some reason; too many
+ * timeouts, or Keepalive failure.
+ */
+
+void
+XdmcpDeadSession (char *reason)
+{
+ ErrorF ("XDM: %s, declaring session dead\n", reason);
+ state = XDM_INIT_STATE;
+ isItTimeToYield = TRUE;
+ dispatchException |= DE_RESET;
+ timeOutTime = 0;
+ timeOutRtx = 0;
+ send_packet();
+}
+
+/*
+ * Timeout waiting for an XDMCP response.
+ */
+
+static void
+timeout(void)
+{
+ timeOutRtx++;
+ if (state == XDM_AWAIT_ALIVE_RESPONSE && timeOutRtx >= XDM_KA_RTX_LIMIT )
+ {
+ XdmcpDeadSession ("too many keepalive retransmissions");
+ return;
+ }
+ else if (timeOutRtx >= XDM_RTX_LIMIT)
+ {
+ /* Quit if "-once" specified, otherwise reset and try again. */
+ if (OneSession) {
+ dispatchException |= DE_TERMINATE;
+ ErrorF("XDM: too many retransmissions\n");
+ } else {
+ XdmcpDeadSession("too many retransmissions");
+ }
+ return;
+ }
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (state == XDM_COLLECT_QUERY || state == XDM_COLLECT_INDIRECT_QUERY) {
+ /* Try next address */
+ for (mgrAddr = mgrAddr->ai_next; ; mgrAddr = mgrAddr->ai_next) {
+ if (mgrAddr == NULL) {
+ mgrAddr = mgrAddrFirst;
+ }
+ if (mgrAddr->ai_family == AF_INET
+ || mgrAddr->ai_family == AF_INET6)
+ break;
+ }
+#ifndef SIN6_LEN
+ ManagerAddressLen = mgrAddr->ai_addrlen;
+#endif
+ memcpy(&ManagerAddress, mgrAddr->ai_addr, mgrAddr->ai_addrlen);
+ }
+#endif
+
+ switch (state) {
+ case XDM_COLLECT_QUERY:
+ state = XDM_QUERY;
+ break;
+ case XDM_COLLECT_BROADCAST_QUERY:
+ state = XDM_BROADCAST;
+ break;
+#if defined(IPv6) && defined(AF_INET6)
+ case XDM_COLLECT_MULTICAST_QUERY:
+ state = XDM_MULTICAST;
+ break;
+#endif
+ case XDM_COLLECT_INDIRECT_QUERY:
+ state = XDM_INDIRECT;
+ break;
+ case XDM_AWAIT_REQUEST_RESPONSE:
+ state = XDM_START_CONNECTION;
+ break;
+ case XDM_AWAIT_MANAGE_RESPONSE:
+ state = XDM_MANAGE;
+ break;
+ case XDM_AWAIT_ALIVE_RESPONSE:
+ state = XDM_KEEPALIVE;
+ break;
+ default:
+ break;
+ }
+ send_packet();
+}
+
+static void
+restart(void)
+{
+ state = XDM_INIT_STATE;
+ timeOutRtx = 0;
+ send_packet();
+}
+
+int
+XdmcpCheckAuthentication (
+ ARRAY8Ptr Name,
+ ARRAY8Ptr Data,
+ int packet_type)
+{
+ return (XdmcpARRAY8Equal (Name, AuthenticationName) &&
+ (AuthenticationName->length == 0 ||
+ (*AuthenticationFuncs->Validator) (AuthenticationData, Data, packet_type)));
+}
+
+int
+XdmcpAddAuthorization (
+ ARRAY8Ptr name,
+ ARRAY8Ptr data)
+{
+ AddAuthorFunc AddAuth;
+
+ if (AuthenticationFuncs && AuthenticationFuncs->AddAuth)
+ AddAuth = AuthenticationFuncs->AddAuth;
+ else
+ AddAuth = AddAuthorization;
+ return (*AddAuth) ((unsigned short)name->length,
+ (char *)name->data,
+ (unsigned short)data->length,
+ (char *)data->data);
+}
+
+/*
+ * from here to the end of this file are routines private
+ * to the state machine.
+ */
+
+static void
+get_xdmcp_sock(void)
+{
+#ifdef STREAMSCONN
+ struct netconfig *nconf;
+
+ if ((xdmcpSocket = t_open("/dev/udp", O_RDWR, 0)) < 0) {
+ XdmcpWarning("t_open() of /dev/udp failed");
+ return;
+ }
+
+ if( t_bind(xdmcpSocket,NULL,NULL) < 0 ) {
+ XdmcpWarning("UDP socket creation failed");
+ t_error("t_bind(xdmcpSocket) failed" );
+ t_close(xdmcpSocket);
+ return;
+ }
+
+ /*
+ * This part of the code looks contrived. It will actually fit in nicely
+ * when the CLTS part of Xtrans is implemented.
+ */
+
+ if( (nconf=getnetconfigent("udp")) == NULL ) {
+ XdmcpWarning("UDP socket creation failed: getnetconfigent()");
+ t_unbind(xdmcpSocket);
+ t_close(xdmcpSocket);
+ return;
+ }
+
+ if( netdir_options(nconf, ND_SET_BROADCAST, xdmcpSocket, NULL) ) {
+ XdmcpWarning("UDP set broadcast option failed: netdir_options()");
+ freenetconfigent(nconf);
+ t_unbind(xdmcpSocket);
+ t_close(xdmcpSocket);
+ return;
+ }
+
+ freenetconfigent(nconf);
+#else
+ int soopts = 1;
+
+#if defined(IPv6) && defined(AF_INET6)
+ if ((xdmcpSocket6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
+ XdmcpWarning("INET6 UDP socket creation failed");
+#endif
+ if ((xdmcpSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+ XdmcpWarning("UDP socket creation failed");
+#ifdef SO_BROADCAST
+ else if (setsockopt(xdmcpSocket, SOL_SOCKET, SO_BROADCAST, (char *)&soopts,
+ sizeof(soopts)) < 0)
+ XdmcpWarning("UDP set broadcast socket-option failed");
+#endif /* SO_BROADCAST */
+ if (xdmcpSocket >= 0 && xdm_from != NULL) {
+ if (bind(xdmcpSocket, (struct sockaddr *)&FromAddress,
+ FromAddressLen) < 0) {
+ FatalError("Xserver: failed to bind to -from address: %s\n", xdm_from);
+ }
+ }
+#endif /* STREAMSCONN */
+}
+
+static void
+send_query_msg(void)
+{
+ XdmcpHeader header;
+ Bool broadcast = FALSE;
+#if defined(IPv6) && defined(AF_INET6)
+ Bool multicast = FALSE;
+#endif
+ int i;
+ int socketfd = xdmcpSocket;
+
+ header.version = XDM_PROTOCOL_VERSION;
+ switch(state){
+ case XDM_QUERY:
+ header.opcode = (CARD16) QUERY;
+ state = XDM_COLLECT_QUERY;
+ break;
+ case XDM_BROADCAST:
+ header.opcode = (CARD16) BROADCAST_QUERY;
+ state = XDM_COLLECT_BROADCAST_QUERY;
+ broadcast = TRUE;
+ break;
+#if defined(IPv6) && defined(AF_INET6)
+ case XDM_MULTICAST:
+ header.opcode = (CARD16) BROADCAST_QUERY;
+ state = XDM_COLLECT_MULTICAST_QUERY;
+ multicast = TRUE;
+ break;
+#endif
+ case XDM_INDIRECT:
+ header.opcode = (CARD16) INDIRECT_QUERY;
+ state = XDM_COLLECT_INDIRECT_QUERY;
+ break;
+ default:
+ break;
+ }
+ header.length = 1;
+ for (i = 0; i < AuthenticationNames.length; i++)
+ header.length += 2 + AuthenticationNames.data[i].length;
+
+ XdmcpWriteHeader (&buffer, &header);
+ XdmcpWriteARRAYofARRAY8 (&buffer, &AuthenticationNames);
+ if (broadcast)
+ {
+ int i;
+
+ for (i = 0; i < NumBroadcastAddresses; i++)
+ XdmcpFlush (xdmcpSocket, &buffer, (XdmcpNetaddr) &BroadcastAddresses[i],
+ sizeof (struct sockaddr_in));
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ else if (multicast)
+ {
+ struct multicastinfo *mcl;
+ struct addrinfo *ai;
+
+ for (mcl = mcastlist; mcl != NULL; mcl = mcl->next) {
+ for (ai = mcl->ai ; ai != NULL; ai = ai->ai_next) {
+ if (ai->ai_family == AF_INET) {
+ unsigned char hopflag = (unsigned char) mcl->hops;
+ socketfd = xdmcpSocket;
+ setsockopt(socketfd, IPPROTO_IP, IP_MULTICAST_TTL,
+ &hopflag, sizeof(hopflag));
+ } else if (ai->ai_family == AF_INET6) {
+ int hopflag6 = mcl->hops;
+ socketfd = xdmcpSocket6;
+ setsockopt(socketfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
+ &hopflag6, sizeof(hopflag6));
+ } else {
+ continue;
+ }
+ XdmcpFlush (socketfd, &buffer,
+ (XdmcpNetaddr) ai->ai_addr, ai->ai_addrlen);
+ break;
+ }
+ }
+ }
+#endif
+ else
+ {
+#if defined(IPv6) && defined(AF_INET6)
+ if (SOCKADDR_FAMILY(ManagerAddress) == AF_INET6)
+ socketfd = xdmcpSocket6;
+#endif
+ XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &ManagerAddress,
+ ManagerAddressLen);
+ }
+}
+
+static void
+recv_willing_msg(
+ struct sockaddr *from,
+ int fromlen,
+ unsigned length)
+{
+ ARRAY8 authenticationName;
+ ARRAY8 hostname;
+ ARRAY8 status;
+
+ authenticationName.data = 0;
+ hostname.data = 0;
+ status.data = 0;
+ if (XdmcpReadARRAY8 (&buffer, &authenticationName) &&
+ XdmcpReadARRAY8 (&buffer, &hostname) &&
+ XdmcpReadARRAY8 (&buffer, &status))
+ {
+ if (length == 6 + authenticationName.length +
+ hostname.length + status.length)
+ {
+ switch (state)
+ {
+ case XDM_COLLECT_QUERY:
+ XdmcpSelectHost(from, fromlen, &authenticationName);
+ break;
+ case XDM_COLLECT_BROADCAST_QUERY:
+#if defined(IPv6) && defined(AF_INET6)
+ case XDM_COLLECT_MULTICAST_QUERY:
+#endif
+ case XDM_COLLECT_INDIRECT_QUERY:
+ XdmcpAddHost(from, fromlen, &authenticationName, &hostname, &status);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ XdmcpDisposeARRAY8 (&authenticationName);
+ XdmcpDisposeARRAY8 (&hostname);
+ XdmcpDisposeARRAY8 (&status);
+}
+
+static void
+send_request_msg(void)
+{
+ XdmcpHeader header;
+ int length;
+ int i;
+ CARD16 XdmcpConnectionType;
+ ARRAY8 authenticationData;
+ int socketfd = xdmcpSocket;
+
+ switch (SOCKADDR_FAMILY(ManagerAddress))
+ {
+ case AF_INET: XdmcpConnectionType=FamilyInternet; break;
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6: XdmcpConnectionType=FamilyInternet6; break;
+#endif
+ default: XdmcpConnectionType=0xffff; break;
+ }
+
+ header.version = XDM_PROTOCOL_VERSION;
+ header.opcode = (CARD16) REQUEST;
+
+ length = 2; /* display number */
+ length += 1 + 2 * ConnectionTypes.length; /* connection types */
+ length += 1; /* connection addresses */
+ for (i = 0; i < ConnectionAddresses.length; i++)
+ length += 2 + ConnectionAddresses.data[i].length;
+ authenticationData.length = 0;
+ authenticationData.data = 0;
+ if (AuthenticationFuncs)
+ {
+ (*AuthenticationFuncs->Generator) (AuthenticationData,
+ &authenticationData,
+ REQUEST);
+ }
+ length += 2 + AuthenticationName->length; /* authentication name */
+ length += 2 + authenticationData.length; /* authentication data */
+ length += 1; /* authorization names */
+ for (i = 0; i < AuthorizationNames.length; i++)
+ length += 2 + AuthorizationNames.data[i].length;
+ length += 2 + ManufacturerDisplayID.length; /* display ID */
+ header.length = length;
+
+ if (!XdmcpWriteHeader (&buffer, &header))
+ {
+ XdmcpDisposeARRAY8 (&authenticationData);
+ return;
+ }
+ XdmcpWriteCARD16 (&buffer, DisplayNumber);
+ XdmcpWriteCARD8 (&buffer, ConnectionTypes.length);
+
+ /* The connection array is send reordered, so that connections of */
+ /* the same address type as the XDMCP manager connection are send */
+ /* first. This works around a bug in xdm. mario@klebsch.de */
+ for (i = 0; i < (int)ConnectionTypes.length; i++)
+ if (ConnectionTypes.data[i]==XdmcpConnectionType)
+ XdmcpWriteCARD16 (&buffer, ConnectionTypes.data[i]);
+ for (i = 0; i < (int)ConnectionTypes.length; i++)
+ if (ConnectionTypes.data[i]!=XdmcpConnectionType)
+ XdmcpWriteCARD16 (&buffer, ConnectionTypes.data[i]);
+
+ XdmcpWriteCARD8 (&buffer, ConnectionAddresses.length);
+ for (i = 0; i < (int)ConnectionAddresses.length; i++)
+ if ( (i<ConnectionTypes.length) &&
+ (ConnectionTypes.data[i]==XdmcpConnectionType) )
+ XdmcpWriteARRAY8 (&buffer, &ConnectionAddresses.data[i]);
+ for (i = 0; i < (int)ConnectionAddresses.length; i++)
+ if ( (i>=ConnectionTypes.length) ||
+ (ConnectionTypes.data[i]!=XdmcpConnectionType) )
+ XdmcpWriteARRAY8 (&buffer, &ConnectionAddresses.data[i]);
+
+ XdmcpWriteARRAY8 (&buffer, AuthenticationName);
+ XdmcpWriteARRAY8 (&buffer, &authenticationData);
+ XdmcpDisposeARRAY8 (&authenticationData);
+ XdmcpWriteARRAYofARRAY8 (&buffer, &AuthorizationNames);
+ XdmcpWriteARRAY8 (&buffer, &ManufacturerDisplayID);
+#if defined(IPv6) && defined(AF_INET6)
+ if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6)
+ socketfd = xdmcpSocket6;
+#endif
+ if (XdmcpFlush (socketfd, &buffer,
+ (XdmcpNetaddr) &req_sockaddr, req_socklen))
+ state = XDM_AWAIT_REQUEST_RESPONSE;
+}
+
+static void
+recv_accept_msg(unsigned length)
+{
+ CARD32 AcceptSessionID;
+ ARRAY8 AcceptAuthenticationName, AcceptAuthenticationData;
+ ARRAY8 AcceptAuthorizationName, AcceptAuthorizationData;
+
+ if (state != XDM_AWAIT_REQUEST_RESPONSE)
+ return;
+ AcceptAuthenticationName.data = 0;
+ AcceptAuthenticationData.data = 0;
+ AcceptAuthorizationName.data = 0;
+ AcceptAuthorizationData.data = 0;
+ if (XdmcpReadCARD32 (&buffer, &AcceptSessionID) &&
+ XdmcpReadARRAY8 (&buffer, &AcceptAuthenticationName) &&
+ XdmcpReadARRAY8 (&buffer, &AcceptAuthenticationData) &&
+ XdmcpReadARRAY8 (&buffer, &AcceptAuthorizationName) &&
+ XdmcpReadARRAY8 (&buffer, &AcceptAuthorizationData))
+ {
+ if (length == 12 + AcceptAuthenticationName.length +
+ AcceptAuthenticationData.length +
+ AcceptAuthorizationName.length +
+ AcceptAuthorizationData.length)
+ {
+ if (!XdmcpCheckAuthentication (&AcceptAuthenticationName,
+ &AcceptAuthenticationData, ACCEPT))
+ {
+ XdmcpFatal ("Authentication Failure", &AcceptAuthenticationName);
+ }
+ /* permit access control manipulations from this host */
+ AugmentSelf (&req_sockaddr, req_socklen);
+ /* if the authorization specified in the packet fails
+ * to be acceptable, enable the local addresses
+ */
+ if (!XdmcpAddAuthorization (&AcceptAuthorizationName,
+ &AcceptAuthorizationData))
+ {
+ AddLocalHosts ();
+ }
+ SessionID = AcceptSessionID;
+ state = XDM_MANAGE;
+ send_packet();
+ }
+ }
+ XdmcpDisposeARRAY8 (&AcceptAuthenticationName);
+ XdmcpDisposeARRAY8 (&AcceptAuthenticationData);
+ XdmcpDisposeARRAY8 (&AcceptAuthorizationName);
+ XdmcpDisposeARRAY8 (&AcceptAuthorizationData);
+}
+
+static void
+recv_decline_msg(unsigned length)
+{
+ ARRAY8 status, DeclineAuthenticationName, DeclineAuthenticationData;
+
+ status.data = 0;
+ DeclineAuthenticationName.data = 0;
+ DeclineAuthenticationData.data = 0;
+ if (XdmcpReadARRAY8 (&buffer, &status) &&
+ XdmcpReadARRAY8 (&buffer, &DeclineAuthenticationName) &&
+ XdmcpReadARRAY8 (&buffer, &DeclineAuthenticationData))
+ {
+ if (length == 6 + status.length +
+ DeclineAuthenticationName.length +
+ DeclineAuthenticationData.length &&
+ XdmcpCheckAuthentication (&DeclineAuthenticationName,
+ &DeclineAuthenticationData, DECLINE))
+ {
+ XdmcpFatal ("Session declined", &status);
+ }
+ }
+ XdmcpDisposeARRAY8 (&status);
+ XdmcpDisposeARRAY8 (&DeclineAuthenticationName);
+ XdmcpDisposeARRAY8 (&DeclineAuthenticationData);
+}
+
+static void
+send_manage_msg(void)
+{
+ XdmcpHeader header;
+ int socketfd = xdmcpSocket;
+
+ header.version = XDM_PROTOCOL_VERSION;
+ header.opcode = (CARD16) MANAGE;
+ header.length = 8 + DisplayClass.length;
+
+ if (!XdmcpWriteHeader (&buffer, &header))
+ return;
+ XdmcpWriteCARD32 (&buffer, SessionID);
+ XdmcpWriteCARD16 (&buffer, DisplayNumber);
+ XdmcpWriteARRAY8 (&buffer, &DisplayClass);
+ state = XDM_AWAIT_MANAGE_RESPONSE;
+#if defined(IPv6) && defined(AF_INET6)
+ if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6)
+ socketfd = xdmcpSocket6;
+#endif
+ XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen);
+}
+
+static void
+recv_refuse_msg(unsigned length)
+{
+ CARD32 RefusedSessionID;
+
+ if (state != XDM_AWAIT_MANAGE_RESPONSE)
+ return;
+ if (length != 4)
+ return;
+ if (XdmcpReadCARD32 (&buffer, &RefusedSessionID))
+ {
+ if (RefusedSessionID == SessionID)
+ {
+ state = XDM_START_CONNECTION;
+ send_packet();
+ }
+ }
+}
+
+static void
+recv_failed_msg(unsigned length)
+{
+ CARD32 FailedSessionID;
+ ARRAY8 status;
+
+ if (state != XDM_AWAIT_MANAGE_RESPONSE)
+ return;
+ status.data = 0;
+ if (XdmcpReadCARD32 (&buffer, &FailedSessionID) &&
+ XdmcpReadARRAY8 (&buffer, &status))
+ {
+ if (length == 6 + status.length &&
+ SessionID == FailedSessionID)
+ {
+ XdmcpFatal ("Session failed", &status);
+ }
+ }
+ XdmcpDisposeARRAY8 (&status);
+}
+
+static void
+send_keepalive_msg(void)
+{
+ XdmcpHeader header;
+ int socketfd = xdmcpSocket;
+
+ header.version = XDM_PROTOCOL_VERSION;
+ header.opcode = (CARD16) KEEPALIVE;
+ header.length = 6;
+
+ XdmcpWriteHeader (&buffer, &header);
+ XdmcpWriteCARD16 (&buffer, DisplayNumber);
+ XdmcpWriteCARD32 (&buffer, SessionID);
+
+ state = XDM_AWAIT_ALIVE_RESPONSE;
+#if defined(IPv6) && defined(AF_INET6)
+ if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6)
+ socketfd = xdmcpSocket6;
+#endif
+ XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen);
+}
+
+static void
+recv_alive_msg (unsigned length)
+{
+ CARD8 SessionRunning;
+ CARD32 AliveSessionID;
+
+ if (state != XDM_AWAIT_ALIVE_RESPONSE)
+ return;
+ if (length != 5)
+ return;
+ if (XdmcpReadCARD8 (&buffer, &SessionRunning) &&
+ XdmcpReadCARD32 (&buffer, &AliveSessionID))
+ {
+ if (SessionRunning && AliveSessionID == SessionID)
+ {
+ /* backoff dormancy period */
+ state = XDM_RUN_SESSION;
+ if ((GetTimeInMillis() - lastDeviceEventTime.milliseconds) >
+ keepaliveDormancy * 1000)
+ {
+ keepaliveDormancy <<= 1;
+ if (keepaliveDormancy > XDM_MAX_DORMANCY)
+ keepaliveDormancy = XDM_MAX_DORMANCY;
+ }
+ timeOutTime = GetTimeInMillis() + keepaliveDormancy * 1000;
+ }
+ else
+ {
+ XdmcpDeadSession ("Alive response indicates session dead");
+ }
+ }
+}
+
+static void
+XdmcpFatal (
+ char *type,
+ ARRAY8Ptr status)
+{
+ FatalError ("XDMCP fatal error: %s %*.*s\n", type,
+ status->length, status->length, status->data);
+}
+
+static void
+XdmcpWarning(char *str)
+{
+ ErrorF("XDMCP warning: %s\n", str);
+}
+
+static void
+get_addr_by_name(
+ char * argtype,
+ char * namestr,
+ int port,
+ int socktype,
+ SOCKADDR_TYPE *addr,
+ SOCKLEN_TYPE *addrlen
+#if defined(IPv6) && defined(AF_INET6)
+ ,
+ struct addrinfo **aip,
+ struct addrinfo **aifirstp
+#endif
+ )
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct addrinfo *ai;
+ struct addrinfo hints;
+ char portstr[6];
+ char *pport = portstr;
+ int gaierr;
+
+ bzero(&hints, sizeof(hints));
+ hints.ai_socktype = socktype;
+
+ if (port == 0) {
+ pport = NULL;
+ } else if (port > 0 && port < 65535) {
+ sprintf(portstr, "%d", port);
+ } else {
+ FatalError("Xserver: port out of range: %d\n", port);
+ }
+
+ if (*aifirstp != NULL) {
+ freeaddrinfo(*aifirstp);
+ *aifirstp = NULL;
+ }
+
+ if ((gaierr = getaddrinfo(namestr, pport, &hints, aifirstp)) == 0) {
+ for (ai = *aifirstp; ai != NULL; ai = ai->ai_next) {
+ if (ai->ai_family == AF_INET || ai->ai_family == AF_INET6)
+ break;
+ }
+ if ((ai == NULL) || (ai->ai_addrlen > sizeof(SOCKADDR_TYPE))) {
+ FatalError ("Xserver: %s host %s not on supported network type\n",
+ argtype, namestr);
+ } else {
+ *aip = ai;
+ *addrlen = ai->ai_addrlen;
+ memcpy(addr, ai->ai_addr, ai->ai_addrlen);
+ }
+ } else {
+ FatalError("Xserver: %s: %s %s\n", gai_strerror(gaierr), argtype, namestr);
+ }
+#else
+ struct hostent *hep;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+#if defined(WIN32) && (defined(TCPCONN) || defined(DNETCONN))
+ _XSERVTransWSAStartup();
+#endif
+ if (!(hep = _XGethostbyname(namestr, hparams)))
+ {
+ FatalError("Xserver: %s unknown host: %s\n", argtype, namestr);
+ }
+ if (hep->h_length == sizeof (struct in_addr))
+ {
+ memmove(&addr->sin_addr, hep->h_addr, hep->h_length);
+ *addrlen = sizeof(struct sockaddr_in);
+ addr->sin_family = AF_INET;
+ addr->sin_port = htons (port);
+ }
+ else
+ {
+ FatalError("Xserver: %s host on strange network %s\n", argtype, namestr);
+ }
+#endif
+}
+
+static void
+get_manager_by_name(
+ int argc,
+ char **argv,
+ int i)
+{
+
+ if ((i + 1) == argc)
+ {
+ FatalError("Xserver: missing %s host name in command line\n", argv[i]);
+ }
+
+ get_addr_by_name(argv[i], argv[i+1], xdm_udp_port, SOCK_DGRAM,
+ &ManagerAddress, &ManagerAddressLen
+#if defined(IPv6) && defined(AF_INET6)
+ , &mgrAddr, &mgrAddrFirst
+#endif
+ );
+}
+
+
+static void
+get_fromaddr_by_name(
+ int argc,
+ char **argv,
+ int i)
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct addrinfo *ai = NULL;
+ struct addrinfo *aifirst = NULL;
+#endif
+ if (i == argc)
+ {
+ FatalError("Xserver: missing -from host name in command line\n");
+ }
+ get_addr_by_name("-from", argv[i], 0, 0, &FromAddress, &FromAddressLen
+#if defined(IPv6) && defined(AF_INET6)
+ , &ai, &aifirst
+#endif
+ );
+ xdm_from = argv[i];
+}
+
+
+#if defined(IPv6) && defined(AF_INET6)
+static int
+get_mcast_options(argc, argv, i)
+ int argc, i;
+ char **argv;
+{
+ char *address = XDM_DEFAULT_MCAST_ADDR6;
+ int hopcount = 1;
+ struct addrinfo hints;
+ char portstr[6];
+ int gaierr;
+ struct addrinfo *ai, *firstai;
+
+ if ((i < argc) && (argv[i][0] != '-') && (argv[i][0] != '+')) {
+ address = argv[i++];
+ if ((i < argc) && (argv[i][0] != '-') && (argv[i][0] != '+')) {
+ hopcount = strtol(argv[i++], NULL, 10);
+ if ((hopcount < 1) || (hopcount > 255)) {
+ FatalError("Xserver: multicast hop count out of range: %d\n",
+ hopcount);
+ }
+ }
+ }
+
+ if (xdm_udp_port > 0 && xdm_udp_port < 65535) {
+ sprintf(portstr, "%d", xdm_udp_port);
+ } else {
+ FatalError("Xserver: port out of range: %d\n", xdm_udp_port);
+ }
+ bzero(&hints, sizeof(hints));
+ hints.ai_socktype = SOCK_DGRAM;
+
+ if ((gaierr = getaddrinfo(address, portstr, &hints, &firstai)) == 0) {
+ for (ai = firstai; ai != NULL; ai = ai->ai_next) {
+ if (((ai->ai_family == AF_INET) &&
+ IN_MULTICAST(((struct sockaddr_in *) ai->ai_addr)
+ ->sin_addr.s_addr))
+ || ((ai->ai_family == AF_INET6) &&
+ IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6 *) ai->ai_addr)
+ ->sin6_addr)))
+ break;
+ }
+ if (ai == NULL) {
+ FatalError ("Xserver: address not supported multicast type %s\n",
+ address);
+ } else {
+ struct multicastinfo *mcastinfo, *mcl;
+
+ mcastinfo = malloc(sizeof(struct multicastinfo));
+ mcastinfo->next = NULL;
+ mcastinfo->ai = firstai;
+ mcastinfo->hops = hopcount;
+
+ if (mcastlist == NULL) {
+ mcastlist = mcastinfo;
+ } else {
+ for (mcl = mcastlist; mcl->next != NULL; mcl = mcl->next) {
+ /* Do nothing - just find end of list */
+ }
+ mcl->next = mcastinfo;
+ }
+ }
+ } else {
+ FatalError("Xserver: %s: %s\n", gai_strerror(gaierr), address);
+ }
+ return i;
+}
+#endif
+
+#else
+static int xdmcp_non_empty; /* avoid complaint by ranlib */
+#endif /* XDMCP */
diff --git a/nx-X11/programs/Xserver/os/xdmcp.c.NX.original b/nx-X11/programs/Xserver/os/xdmcp.c.NX.original
new file mode 100644
index 000000000..032d58f15
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/xdmcp.c.NX.original
@@ -0,0 +1,1710 @@
+/* $XdotOrg: xc/programs/Xserver/os/xdmcp.c,v 1.10 2005/07/03 08:53:52 daniels Exp $ */
+/* $Xorg: xdmcp.c,v 1.4 2001/01/31 13:37:19 pookie Exp $ */
+/*
+ * Copyright 1989 Network Computing Devices, Inc., Mountain View, California.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of N.C.D. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. N.C.D. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/os/xdmcp.c,v 3.31 2003/12/30 21:24:32 herrb Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#endif
+
+#include <X11/Xos.h>
+
+#if !defined(WIN32)
+#ifndef Lynx
+#include <sys/param.h>
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif
+#include <netinet/in.h>
+#include <netdb.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "misc.h"
+#include <X11/Xpoll.h>
+#include "osdep.h"
+#include "input.h"
+#include "dixstruct.h"
+#include "opaque.h"
+
+#if defined(DGUX)
+#include <net/net_ioctl.h>
+#include <sys/ioctl.h>
+#endif
+
+#ifdef STREAMSCONN
+#include <tiuser.h>
+#include <netconfig.h>
+#include <netdir.h>
+#endif
+
+#ifndef NX_TRANS_SOCKET
+
+#define NX_TRANS_SOCKET
+#define NX_TRANS_TEST
+
+#endif
+
+#ifdef XDMCP
+#undef REQUEST
+
+#ifdef XDMCP_NO_IPV6
+#undef IPv6
+#endif
+
+#include <X11/Xdmcp.h>
+
+#define X_INCLUDE_NETDB_H
+#include <X11/Xos_r.h>
+
+#ifdef NX_TRANS_SOCKET
+
+xdmcp_states XdmcpState;
+
+int XdmcpStartTime;
+int XdmcpTimeOutRtx;
+
+#endif
+
+extern char *defaultDisplayClass;
+
+static int xdmcpSocket, sessionSocket;
+static xdmcp_states state;
+#if defined(IPv6) && defined(AF_INET6)
+static int xdmcpSocket6;
+static struct sockaddr_storage req_sockaddr;
+#else
+static struct sockaddr_in req_sockaddr;
+#endif
+static int req_socklen;
+static CARD32 SessionID;
+static CARD32 timeOutTime;
+static int timeOutRtx;
+static CARD32 defaultKeepaliveDormancy = XDM_DEF_DORMANCY;
+static CARD32 keepaliveDormancy = XDM_DEF_DORMANCY;
+static CARD16 DisplayNumber;
+static xdmcp_states XDM_INIT_STATE = XDM_OFF;
+#ifdef HASXDMAUTH
+static char *xdmAuthCookie;
+#endif
+
+static XdmcpBuffer buffer;
+
+#if defined(IPv6) && defined(AF_INET6)
+
+static struct addrinfo *mgrAddr;
+static struct addrinfo *mgrAddrFirst;
+
+#define SOCKADDR_TYPE struct sockaddr_storage
+#define SOCKADDR_FAMILY(s) ((struct sockaddr *)&(s))->sa_family
+
+#ifdef BSD44SOCKETS
+#define SOCKLEN_FIELD(s) ((struct sockaddr *)&(s))->sa_len
+#define SOCKLEN_TYPE unsigned char
+#else
+#define SOCKLEN_TYPE unsigned int
+#endif
+
+#else
+
+#define SOCKADDR_TYPE struct sockaddr_in
+#define SOCKADDR_FAMILY(s) (s).sin_family
+
+#ifdef BSD44SOCKETS
+#define SOCKLEN_FIELD(s) (s).sin_len
+#define SOCKLEN_TYPE unsigned char
+#else
+#define SOCKLEN_TYPE size_t
+#endif
+
+#endif
+
+static SOCKADDR_TYPE ManagerAddress;
+static SOCKADDR_TYPE FromAddress;
+
+#ifdef SOCKLEN_FIELD
+#define ManagerAddressLen SOCKLEN_FIELD(ManagerAddress)
+#define FromAddressLen SOCKLEN_FIELD(FromAddress)
+#else
+static SOCKLEN_TYPE ManagerAddressLen, FromAddressLen;
+#endif
+
+#if defined(IPv6) && defined(AF_INET6)
+static struct multicastinfo {
+ struct multicastinfo *next;
+ struct addrinfo *ai;
+ int hops;
+} *mcastlist;
+#endif
+
+static void XdmcpAddHost(
+ struct sockaddr *from,
+ int fromlen,
+ ARRAY8Ptr AuthenticationName,
+ ARRAY8Ptr hostname,
+ ARRAY8Ptr status);
+
+static void XdmcpSelectHost(
+ struct sockaddr *host_sockaddr,
+ int host_len,
+ ARRAY8Ptr AuthenticationName);
+
+static void get_xdmcp_sock(void);
+
+static void send_query_msg(void);
+
+static void recv_willing_msg(
+ struct sockaddr * /*from*/,
+ int /*fromlen*/,
+ unsigned /*length*/);
+
+static void send_request_msg(void);
+
+static void recv_accept_msg(unsigned /*length*/);
+
+static void recv_decline_msg(unsigned /*length*/);
+
+static void send_manage_msg(void);
+
+static void recv_refuse_msg(unsigned /*length*/);
+
+static void recv_failed_msg(unsigned /*length*/);
+
+static void send_keepalive_msg(void);
+
+static void recv_alive_msg(unsigned /*length*/);
+
+static void XdmcpFatal(
+ char * /*type*/,
+ ARRAY8Ptr /*status*/);
+
+static void XdmcpWarning(char * /*str*/);
+
+static void get_manager_by_name(
+ int /*argc*/,
+ char ** /*argv*/,
+ int /*i*/);
+
+static void get_fromaddr_by_name(int /*argc*/, char ** /*argv*/, int /*i*/);
+
+#if defined(IPv6) && defined(AF_INET6)
+static int get_mcast_options(int /*argc*/, char ** /*argv*/, int /*i*/);
+#endif
+
+static void receive_packet(int /*socketfd*/);
+
+static void send_packet(void);
+
+extern void XdmcpDeadSession(char * /*reason*/);
+
+static void timeout(void);
+
+static void restart(void);
+
+static void XdmcpBlockHandler(
+ pointer /*data*/,
+ struct timeval ** /*wt*/,
+ pointer /*LastSelectMask*/);
+
+static void XdmcpWakeupHandler(
+ pointer /*data*/,
+ int /*i*/,
+ pointer /*LastSelectMask*/);
+
+void XdmcpRegisterManufacturerDisplayID(
+ char * /*name*/,
+ int /*length*/);
+
+
+static unsigned short xdm_udp_port = XDM_UDP_PORT;
+static Bool OneSession = FALSE;
+static const char *xdm_from = NULL;
+
+void
+XdmcpUseMsg (void)
+{
+ ErrorF("-query host-name contact named host for XDMCP\n");
+ ErrorF("-broadcast broadcast for XDMCP\n");
+#if defined(IPv6) && defined(AF_INET6)
+ ErrorF("-multicast [addr [hops]] IPv6 multicast for XDMCP\n");
+#endif
+ ErrorF("-indirect host-name contact named host for indirect XDMCP\n");
+ ErrorF("-port port-num UDP port number to send messages to\n");
+ ErrorF("-from local-address specify the local address to connect from\n");
+ ErrorF("-once Terminate server after one session\n");
+ ErrorF("-class display-class specify display class to send in manage\n");
+#ifdef HASXDMAUTH
+ ErrorF("-cookie xdm-auth-bits specify the magic cookie for XDMCP\n");
+#endif
+ ErrorF("-displayID display-id manufacturer display ID for request\n");
+}
+
+int
+XdmcpOptions(int argc, char **argv, int i)
+{
+ if (strcmp(argv[i], "-query") == 0) {
+ get_manager_by_name(argc, argv, i++);
+ XDM_INIT_STATE = XDM_QUERY;
+ AccessUsingXdmcp ();
+ return (i + 1);
+ }
+ if (strcmp(argv[i], "-broadcast") == 0) {
+ XDM_INIT_STATE = XDM_BROADCAST;
+ AccessUsingXdmcp ();
+ return (i + 1);
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ if (strcmp(argv[i], "-multicast") == 0) {
+ i = get_mcast_options(argc, argv, ++i);
+ XDM_INIT_STATE = XDM_MULTICAST;
+ AccessUsingXdmcp ();
+ return (i + 1);
+ }
+#endif
+ if (strcmp(argv[i], "-indirect") == 0) {
+ get_manager_by_name(argc, argv, i++);
+ XDM_INIT_STATE = XDM_INDIRECT;
+ AccessUsingXdmcp ();
+ return (i + 1);
+ }
+ if (strcmp(argv[i], "-port") == 0) {
+ if (++i == argc) {
+ FatalError("Xserver: missing port number in command line\n");
+ }
+ xdm_udp_port = (unsigned short) atoi(argv[i]);
+ return (i + 1);
+ }
+ if (strcmp(argv[i], "-from") == 0) {
+ get_fromaddr_by_name(argc, argv, ++i);
+ return (i + 1);
+ }
+ if (strcmp(argv[i], "-once") == 0) {
+ OneSession = TRUE;
+ return (i + 1);
+ }
+ if (strcmp(argv[i], "-class") == 0) {
+ if (++i == argc) {
+ FatalError("Xserver: missing class name in command line\n");
+ }
+ defaultDisplayClass = argv[i];
+ return (i + 1);
+ }
+#ifdef HASXDMAUTH
+ if (strcmp(argv[i], "-cookie") == 0) {
+ if (++i == argc) {
+ FatalError("Xserver: missing cookie data in command line\n");
+ }
+ xdmAuthCookie = argv[i];
+ return (i + 1);
+ }
+#endif
+ if (strcmp(argv[i], "-displayID") == 0) {
+ if (++i == argc) {
+ FatalError("Xserver: missing displayID in command line\n");
+ }
+ XdmcpRegisterManufacturerDisplayID (argv[i], strlen (argv[i]));
+ return (i + 1);
+ }
+ return (i);
+}
+
+/*
+ * This section is a collection of routines for
+ * registering server-specific data with the XDMCP
+ * state machine.
+ */
+
+
+/*
+ * Save all broadcast addresses away so BroadcastQuery
+ * packets get sent everywhere
+ */
+
+#define MAX_BROADCAST 10
+
+/* This stays sockaddr_in since IPv6 doesn't support broadcast */
+static struct sockaddr_in BroadcastAddresses[MAX_BROADCAST];
+static int NumBroadcastAddresses;
+
+void
+XdmcpRegisterBroadcastAddress (struct sockaddr_in *addr)
+{
+ struct sockaddr_in *bcast;
+ if (NumBroadcastAddresses >= MAX_BROADCAST)
+ return;
+ bcast = &BroadcastAddresses[NumBroadcastAddresses++];
+ bzero (bcast, sizeof (struct sockaddr_in));
+#ifdef BSD44SOCKETS
+ bcast->sin_len = addr->sin_len;
+#endif
+ bcast->sin_family = addr->sin_family;
+ bcast->sin_port = htons (xdm_udp_port);
+ bcast->sin_addr = addr->sin_addr;
+}
+
+/*
+ * Each authentication type is registered here; Validator
+ * will be called to check all access attempts using
+ * the specified authentication type
+ */
+
+static ARRAYofARRAY8 AuthenticationNames, AuthenticationDatas;
+typedef struct _AuthenticationFuncs {
+ ValidatorFunc Validator;
+ GeneratorFunc Generator;
+ AddAuthorFunc AddAuth;
+} AuthenticationFuncsRec, *AuthenticationFuncsPtr;
+
+static AuthenticationFuncsPtr AuthenticationFuncsList;
+
+void
+XdmcpRegisterAuthentication (
+ char *name,
+ int namelen,
+ char *data,
+ int datalen,
+ ValidatorFunc Validator,
+ GeneratorFunc Generator,
+ AddAuthorFunc AddAuth)
+{
+ int i;
+ ARRAY8 AuthenticationName, AuthenticationData;
+ static AuthenticationFuncsPtr newFuncs;
+
+ if (!XdmcpAllocARRAY8 (&AuthenticationName, namelen))
+ return;
+ if (!XdmcpAllocARRAY8 (&AuthenticationData, datalen))
+ {
+ XdmcpDisposeARRAY8 (&AuthenticationName);
+ return;
+ }
+ for (i = 0; i < namelen; i++)
+ AuthenticationName.data[i] = name[i];
+ for (i = 0; i < datalen; i++)
+ AuthenticationData.data[i] = data[i];
+ if (!(XdmcpReallocARRAYofARRAY8 (&AuthenticationNames,
+ AuthenticationNames.length + 1) &&
+ XdmcpReallocARRAYofARRAY8 (&AuthenticationDatas,
+ AuthenticationDatas.length + 1) &&
+ (newFuncs = (AuthenticationFuncsPtr) xalloc (
+ (AuthenticationNames.length + 1) * sizeof (AuthenticationFuncsRec)))))
+ {
+ XdmcpDisposeARRAY8 (&AuthenticationName);
+ XdmcpDisposeARRAY8 (&AuthenticationData);
+ return;
+ }
+ for (i = 0; i < AuthenticationNames.length - 1; i++)
+ newFuncs[i] = AuthenticationFuncsList[i];
+ newFuncs[AuthenticationNames.length-1].Validator = Validator;
+ newFuncs[AuthenticationNames.length-1].Generator = Generator;
+ newFuncs[AuthenticationNames.length-1].AddAuth = AddAuth;
+ xfree (AuthenticationFuncsList);
+ AuthenticationFuncsList = newFuncs;
+ AuthenticationNames.data[AuthenticationNames.length-1] = AuthenticationName;
+ AuthenticationDatas.data[AuthenticationDatas.length-1] = AuthenticationData;
+}
+
+/*
+ * Select the authentication type to be used; this is
+ * set by the manager of the host to be connected to.
+ */
+
+ARRAY8 noAuthenticationName = {(CARD16) 0, (CARD8Ptr) 0};
+ARRAY8 noAuthenticationData = {(CARD16) 0, (CARD8Ptr) 0};
+ARRAY8Ptr AuthenticationName = &noAuthenticationName;
+ARRAY8Ptr AuthenticationData = &noAuthenticationData;
+AuthenticationFuncsPtr AuthenticationFuncs;
+
+void
+XdmcpSetAuthentication (ARRAY8Ptr name)
+{
+ int i;
+
+ for (i = 0; i < AuthenticationNames.length; i++)
+ if (XdmcpARRAY8Equal (&AuthenticationNames.data[i], name))
+ {
+ AuthenticationName = &AuthenticationNames.data[i];
+ AuthenticationData = &AuthenticationDatas.data[i];
+ AuthenticationFuncs = &AuthenticationFuncsList[i];
+ break;
+ }
+}
+
+/*
+ * Register the host address for the display
+ */
+
+static ARRAY16 ConnectionTypes;
+static ARRAYofARRAY8 ConnectionAddresses;
+static long xdmcpGeneration;
+
+void
+XdmcpRegisterConnection (
+ int type,
+ char *address,
+ int addrlen)
+{
+ int i;
+ CARD8 *newAddress;
+
+ if (xdmcpGeneration != serverGeneration)
+ {
+ XdmcpDisposeARRAY16 (&ConnectionTypes);
+ XdmcpDisposeARRAYofARRAY8 (&ConnectionAddresses);
+ xdmcpGeneration = serverGeneration;
+ }
+ if (xdm_from != NULL) { /* Only register the requested address */
+ const void *regAddr = address;
+ const void *fromAddr = NULL;
+ int regAddrlen = addrlen;
+
+ if (addrlen == sizeof(struct in_addr)) {
+ if (SOCKADDR_FAMILY(FromAddress) == AF_INET) {
+ fromAddr = &((struct sockaddr_in *)&FromAddress)->sin_addr;
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ else if ((SOCKADDR_FAMILY(FromAddress) == AF_INET6) &&
+ IN6_IS_ADDR_V4MAPPED(
+ &((struct sockaddr_in6 *)&FromAddress)->sin6_addr)) {
+ fromAddr = &((struct sockaddr_in6 *)&FromAddress)->sin6_addr.s6_addr[12];
+ }
+#endif
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ else if (addrlen == sizeof(struct in6_addr)) {
+ if (SOCKADDR_FAMILY(FromAddress) == AF_INET6) {
+ fromAddr = &((struct sockaddr_in6 *)&FromAddress)->sin6_addr;
+ } else if ((SOCKADDR_FAMILY(FromAddress) == AF_INET) &&
+ IN6_IS_ADDR_V4MAPPED((struct in6_addr *) address)) {
+ fromAddr = &((struct sockaddr_in *)&FromAddress)->sin_addr;
+ regAddr = &((struct sockaddr_in6 *)&address)->sin6_addr.s6_addr[12];
+ regAddrlen = sizeof(struct in_addr);
+ }
+ }
+#endif
+ if (fromAddr && memcmp(regAddr, fromAddr, regAddrlen) != 0) {
+ return;
+ }
+ }
+ newAddress = (CARD8 *) xalloc (addrlen * sizeof (CARD8));
+ if (!newAddress)
+ return;
+ if (!XdmcpReallocARRAY16 (&ConnectionTypes, ConnectionTypes.length + 1))
+ {
+ xfree (newAddress);
+ return;
+ }
+ if (!XdmcpReallocARRAYofARRAY8 (&ConnectionAddresses,
+ ConnectionAddresses.length + 1))
+ {
+ xfree (newAddress);
+ return;
+ }
+ ConnectionTypes.data[ConnectionTypes.length - 1] = (CARD16) type;
+ for (i = 0; i < addrlen; i++)
+ newAddress[i] = address[i];
+ ConnectionAddresses.data[ConnectionAddresses.length-1].data = newAddress;
+ ConnectionAddresses.data[ConnectionAddresses.length-1].length = addrlen;
+}
+
+/*
+ * Register an Authorization Name. XDMCP advertises this list
+ * to the manager.
+ */
+
+static ARRAYofARRAY8 AuthorizationNames;
+
+void
+XdmcpRegisterAuthorizations (void)
+{
+ XdmcpDisposeARRAYofARRAY8 (&AuthorizationNames);
+ RegisterAuthorizations ();
+}
+
+void
+XdmcpRegisterAuthorization (char *name, int namelen)
+{
+ ARRAY8 authName;
+ int i;
+
+ authName.data = (CARD8 *) xalloc (namelen * sizeof (CARD8));
+ if (!authName.data)
+ return;
+ if (!XdmcpReallocARRAYofARRAY8 (&AuthorizationNames, AuthorizationNames.length +1))
+ {
+ xfree (authName.data);
+ return;
+ }
+ for (i = 0; i < namelen; i++)
+ authName.data[i] = (CARD8) name[i];
+ authName.length = namelen;
+ AuthorizationNames.data[AuthorizationNames.length-1] = authName;
+}
+
+/*
+ * Register the DisplayClass string
+ */
+
+ARRAY8 DisplayClass;
+
+void
+XdmcpRegisterDisplayClass (char *name, int length)
+{
+ int i;
+
+ XdmcpDisposeARRAY8 (&DisplayClass);
+ if (!XdmcpAllocARRAY8 (&DisplayClass, length))
+ return;
+ for (i = 0; i < length; i++)
+ DisplayClass.data[i] = (CARD8) name[i];
+}
+
+/*
+ * Register the Manufacturer display ID
+ */
+
+ARRAY8 ManufacturerDisplayID;
+
+void
+XdmcpRegisterManufacturerDisplayID (char *name, int length)
+{
+ int i;
+
+ XdmcpDisposeARRAY8 (&ManufacturerDisplayID);
+ if (!XdmcpAllocARRAY8 (&ManufacturerDisplayID, length))
+ return;
+ for (i = 0; i < length; i++)
+ ManufacturerDisplayID.data[i] = (CARD8) name[i];
+}
+
+/*
+ * initialize XDMCP; create the socket, compute the display
+ * number, set up the state machine
+ */
+
+void
+XdmcpInit(void)
+{
+#ifdef NX_TRANS_SOCKET
+
+ XdmcpStartTime = GetTimeInMillis();
+
+#endif
+
+ state = XDM_INIT_STATE;
+#ifdef HASXDMAUTH
+ if (xdmAuthCookie)
+ XdmAuthenticationInit (xdmAuthCookie, strlen (xdmAuthCookie));
+#endif
+ if (state != XDM_OFF)
+ {
+ XdmcpRegisterAuthorizations();
+ XdmcpRegisterDisplayClass (defaultDisplayClass, strlen (defaultDisplayClass));
+ AccessUsingXdmcp();
+ RegisterBlockAndWakeupHandlers (XdmcpBlockHandler, XdmcpWakeupHandler,
+ (pointer) 0);
+ timeOutRtx = 0;
+ DisplayNumber = (CARD16) atoi(display);
+ get_xdmcp_sock();
+ send_packet();
+ }
+}
+
+void
+XdmcpReset (void)
+{
+ state = XDM_INIT_STATE;
+ if (state != XDM_OFF)
+ {
+ RegisterBlockAndWakeupHandlers (XdmcpBlockHandler, XdmcpWakeupHandler,
+ (pointer) 0);
+ timeOutRtx = 0;
+ send_packet();
+ }
+}
+
+/*
+ * Called whenever a new connection is created; notices the
+ * first connection and saves it to terminate the session
+ * when it is closed
+ */
+
+void
+XdmcpOpenDisplay(int sock)
+{
+ if (state != XDM_AWAIT_MANAGE_RESPONSE)
+ return;
+ state = XDM_RUN_SESSION;
+ sessionSocket = sock;
+}
+
+void
+XdmcpCloseDisplay(int sock)
+{
+ if ((state != XDM_RUN_SESSION && state != XDM_AWAIT_ALIVE_RESPONSE)
+ || sessionSocket != sock)
+ return;
+ state = XDM_INIT_STATE;
+ if (OneSession)
+ dispatchException |= DE_TERMINATE;
+ else
+ dispatchException |= DE_RESET;
+ isItTimeToYield = TRUE;
+}
+
+/*
+ * called before going to sleep, this routine
+ * may modify the timeout value about to be sent
+ * to select; in this way XDMCP can do appropriate things
+ * dynamically while starting up
+ */
+
+/*ARGSUSED*/
+static void
+XdmcpBlockHandler(
+ pointer data, /* unused */
+ struct timeval **wt,
+ pointer pReadmask)
+{
+ fd_set *LastSelectMask = (fd_set*)pReadmask;
+ CARD32 millisToGo;
+
+ if (state == XDM_OFF)
+ return;
+ FD_SET(xdmcpSocket, LastSelectMask);
+#if defined(IPv6) && defined(AF_INET6)
+ if (xdmcpSocket6 >= 0)
+ FD_SET(xdmcpSocket6, LastSelectMask);
+#endif
+ if (timeOutTime == 0)
+ return;
+ millisToGo = timeOutTime - GetTimeInMillis();
+ if ((int) millisToGo < 0)
+ millisToGo = 0;
+ AdjustWaitForDelay (wt, millisToGo);
+}
+
+/*
+ * called after select returns; this routine will
+ * recognise when XDMCP packets await and
+ * process them appropriately
+ */
+
+/*ARGSUSED*/
+static void
+XdmcpWakeupHandler(
+ pointer data, /* unused */
+ int i,
+ pointer pReadmask)
+{
+ fd_set* LastSelectMask = (fd_set*)pReadmask;
+ fd_set devicesReadable;
+
+#ifdef NX_TRANS_SOCKET
+
+ XdmcpState = state;
+ XdmcpTimeOutRtx = timeOutRtx;
+
+#endif
+
+ if (state == XDM_OFF)
+ return;
+ if (i > 0)
+ {
+ if (FD_ISSET(xdmcpSocket, LastSelectMask))
+ {
+ receive_packet(xdmcpSocket);
+ FD_CLR(xdmcpSocket, LastSelectMask);
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ if (xdmcpSocket6 >= 0 && FD_ISSET(xdmcpSocket6, LastSelectMask))
+ {
+ receive_packet(xdmcpSocket6);
+ FD_CLR(xdmcpSocket6, LastSelectMask);
+ }
+#endif
+ XFD_ANDSET(&devicesReadable, LastSelectMask, &EnabledDevices);
+ if (XFD_ANYSET(&devicesReadable))
+ {
+ if (state == XDM_AWAIT_USER_INPUT)
+ restart();
+ else if (state == XDM_RUN_SESSION)
+ keepaliveDormancy = defaultKeepaliveDormancy;
+ }
+ if (XFD_ANYSET(&AllClients) && state == XDM_RUN_SESSION)
+ timeOutTime = GetTimeInMillis() + keepaliveDormancy * 1000;
+ }
+ else if (timeOutTime && (int) (GetTimeInMillis() - timeOutTime) >= 0)
+ {
+ if (state == XDM_RUN_SESSION)
+ {
+ state = XDM_KEEPALIVE;
+ send_packet();
+ }
+ else
+ timeout();
+ }
+}
+
+/*
+ * This routine should be called from the routine that drives the
+ * user's host menu when the user selects a host
+ */
+
+static void
+XdmcpSelectHost(
+ struct sockaddr *host_sockaddr,
+ int host_len,
+ ARRAY8Ptr AuthenticationName)
+{
+ state = XDM_START_CONNECTION;
+ memmove(&req_sockaddr, host_sockaddr, host_len);
+ req_socklen = host_len;
+ XdmcpSetAuthentication (AuthenticationName);
+ send_packet();
+}
+
+/*
+ * !!! this routine should be replaced by a routine that adds
+ * the host to the user's host menu. the current version just
+ * selects the first host to respond with willing message.
+ */
+
+/*ARGSUSED*/
+static void
+XdmcpAddHost(
+ struct sockaddr *from,
+ int fromlen,
+ ARRAY8Ptr AuthenticationName,
+ ARRAY8Ptr hostname,
+ ARRAY8Ptr status)
+{
+ XdmcpSelectHost(from, fromlen, AuthenticationName);
+}
+
+/*
+ * A message is queued on the socket; read it and
+ * do the appropriate thing
+ */
+
+ARRAY8 UnwillingMessage = { (CARD8) 14, (CARD8 *) "Host unwilling" };
+
+static void
+receive_packet(int socketfd)
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_storage from;
+#else
+ struct sockaddr_in from;
+#endif
+ int fromlen = sizeof(from);
+ XdmcpHeader header;
+
+ /* read message off socket */
+ if (!XdmcpFill (socketfd, &buffer, (XdmcpNetaddr) &from, &fromlen))
+ return;
+
+ /* reset retransmission backoff */
+ timeOutRtx = 0;
+
+ if (!XdmcpReadHeader (&buffer, &header))
+ return;
+
+ if (header.version != XDM_PROTOCOL_VERSION)
+ return;
+
+ switch (header.opcode) {
+ case WILLING:
+ recv_willing_msg((struct sockaddr *) &from, fromlen, header.length);
+ break;
+ case UNWILLING:
+ XdmcpFatal("Manager unwilling", &UnwillingMessage);
+ break;
+ case ACCEPT:
+ recv_accept_msg(header.length);
+ break;
+ case DECLINE:
+ recv_decline_msg(header.length);
+ break;
+ case REFUSE:
+ recv_refuse_msg(header.length);
+ break;
+ case FAILED:
+ recv_failed_msg(header.length);
+ break;
+ case ALIVE:
+ recv_alive_msg(header.length);
+ break;
+ }
+}
+
+/*
+ * send the appropriate message given the current state
+ */
+
+static void
+send_packet(void)
+{
+ int rtx;
+ switch (state) {
+ case XDM_QUERY:
+ case XDM_BROADCAST:
+ case XDM_INDIRECT:
+#if defined(IPv6) && defined(AF_INET6)
+ case XDM_MULTICAST:
+#endif
+ send_query_msg();
+ break;
+ case XDM_START_CONNECTION:
+ send_request_msg();
+ break;
+ case XDM_MANAGE:
+ send_manage_msg();
+ break;
+ case XDM_KEEPALIVE:
+ send_keepalive_msg();
+ break;
+ default:
+ break;
+ }
+ rtx = (XDM_MIN_RTX << timeOutRtx);
+ if (rtx > XDM_MAX_RTX)
+ rtx = XDM_MAX_RTX;
+ timeOutTime = GetTimeInMillis() + rtx * 1000;
+}
+
+/*
+ * The session is declared dead for some reason; too many
+ * timeouts, or Keepalive failure.
+ */
+
+void
+XdmcpDeadSession (char *reason)
+{
+ ErrorF ("XDM: %s, declaring session dead\n", reason);
+ state = XDM_INIT_STATE;
+ isItTimeToYield = TRUE;
+ dispatchException |= DE_RESET;
+ timeOutTime = 0;
+ timeOutRtx = 0;
+ send_packet();
+}
+
+/*
+ * Timeout waiting for an XDMCP response.
+ */
+
+static void
+timeout(void)
+{
+ timeOutRtx++;
+ if (state == XDM_AWAIT_ALIVE_RESPONSE && timeOutRtx >= XDM_KA_RTX_LIMIT )
+ {
+ XdmcpDeadSession ("too many keepalive retransmissions");
+ return;
+ }
+ else if (timeOutRtx >= XDM_RTX_LIMIT)
+ {
+ /* Quit if "-once" specified, otherwise reset and try again. */
+ if (OneSession) {
+ dispatchException |= DE_TERMINATE;
+ ErrorF("XDM: too many retransmissions\n");
+ } else {
+ XdmcpDeadSession("too many retransmissions");
+ }
+ return;
+ }
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (state == XDM_COLLECT_QUERY || state == XDM_COLLECT_INDIRECT_QUERY) {
+ /* Try next address */
+ for (mgrAddr = mgrAddr->ai_next; ; mgrAddr = mgrAddr->ai_next) {
+ if (mgrAddr == NULL) {
+ mgrAddr = mgrAddrFirst;
+ }
+ if (mgrAddr->ai_family == AF_INET
+ || mgrAddr->ai_family == AF_INET6)
+ break;
+ }
+#ifndef SIN6_LEN
+ ManagerAddressLen = mgrAddr->ai_addrlen;
+#endif
+ memcpy(&ManagerAddress, mgrAddr->ai_addr, mgrAddr->ai_addrlen);
+ }
+#endif
+
+ switch (state) {
+ case XDM_COLLECT_QUERY:
+ state = XDM_QUERY;
+ break;
+ case XDM_COLLECT_BROADCAST_QUERY:
+ state = XDM_BROADCAST;
+ break;
+#if defined(IPv6) && defined(AF_INET6)
+ case XDM_COLLECT_MULTICAST_QUERY:
+ state = XDM_MULTICAST;
+ break;
+#endif
+ case XDM_COLLECT_INDIRECT_QUERY:
+ state = XDM_INDIRECT;
+ break;
+ case XDM_AWAIT_REQUEST_RESPONSE:
+ state = XDM_START_CONNECTION;
+ break;
+ case XDM_AWAIT_MANAGE_RESPONSE:
+ state = XDM_MANAGE;
+ break;
+ case XDM_AWAIT_ALIVE_RESPONSE:
+ state = XDM_KEEPALIVE;
+ break;
+ default:
+ break;
+ }
+ send_packet();
+}
+
+static void
+restart(void)
+{
+ state = XDM_INIT_STATE;
+ timeOutRtx = 0;
+ send_packet();
+}
+
+int
+XdmcpCheckAuthentication (
+ ARRAY8Ptr Name,
+ ARRAY8Ptr Data,
+ int packet_type)
+{
+ return (XdmcpARRAY8Equal (Name, AuthenticationName) &&
+ (AuthenticationName->length == 0 ||
+ (*AuthenticationFuncs->Validator) (AuthenticationData, Data, packet_type)));
+}
+
+int
+XdmcpAddAuthorization (
+ ARRAY8Ptr name,
+ ARRAY8Ptr data)
+{
+ AddAuthorFunc AddAuth;
+
+ if (AuthenticationFuncs && AuthenticationFuncs->AddAuth)
+ AddAuth = AuthenticationFuncs->AddAuth;
+ else
+ AddAuth = AddAuthorization;
+ return (*AddAuth) ((unsigned short)name->length,
+ (char *)name->data,
+ (unsigned short)data->length,
+ (char *)data->data);
+}
+
+/*
+ * from here to the end of this file are routines private
+ * to the state machine.
+ */
+
+static void
+get_xdmcp_sock(void)
+{
+#ifdef STREAMSCONN
+ struct netconfig *nconf;
+
+ if ((xdmcpSocket = t_open("/dev/udp", O_RDWR, 0)) < 0) {
+ XdmcpWarning("t_open() of /dev/udp failed");
+ return;
+ }
+
+ if( t_bind(xdmcpSocket,NULL,NULL) < 0 ) {
+ XdmcpWarning("UDP socket creation failed");
+ t_error("t_bind(xdmcpSocket) failed" );
+ t_close(xdmcpSocket);
+ return;
+ }
+
+ /*
+ * This part of the code looks contrived. It will actually fit in nicely
+ * when the CLTS part of Xtrans is implemented.
+ */
+
+ if( (nconf=getnetconfigent("udp")) == NULL ) {
+ XdmcpWarning("UDP socket creation failed: getnetconfigent()");
+ t_unbind(xdmcpSocket);
+ t_close(xdmcpSocket);
+ return;
+ }
+
+ if( netdir_options(nconf, ND_SET_BROADCAST, xdmcpSocket, NULL) ) {
+ XdmcpWarning("UDP set broadcast option failed: netdir_options()");
+ freenetconfigent(nconf);
+ t_unbind(xdmcpSocket);
+ t_close(xdmcpSocket);
+ return;
+ }
+
+ freenetconfigent(nconf);
+#else
+ int soopts = 1;
+
+#if defined(IPv6) && defined(AF_INET6)
+ if ((xdmcpSocket6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
+ XdmcpWarning("INET6 UDP socket creation failed");
+#endif
+ if ((xdmcpSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+ XdmcpWarning("UDP socket creation failed");
+#ifdef SO_BROADCAST
+ else if (setsockopt(xdmcpSocket, SOL_SOCKET, SO_BROADCAST, (char *)&soopts,
+ sizeof(soopts)) < 0)
+ XdmcpWarning("UDP set broadcast socket-option failed");
+#endif /* SO_BROADCAST */
+ if (xdmcpSocket >= 0 && xdm_from != NULL) {
+ if (bind(xdmcpSocket, (struct sockaddr *)&FromAddress,
+ FromAddressLen) < 0) {
+ FatalError("Xserver: failed to bind to -from address: %s\n", xdm_from);
+ }
+ }
+#endif /* STREAMSCONN */
+}
+
+static void
+send_query_msg(void)
+{
+ XdmcpHeader header;
+ Bool broadcast = FALSE;
+#if defined(IPv6) && defined(AF_INET6)
+ Bool multicast = FALSE;
+#endif
+ int i;
+ int socketfd = xdmcpSocket;
+
+ header.version = XDM_PROTOCOL_VERSION;
+ switch(state){
+ case XDM_QUERY:
+ header.opcode = (CARD16) QUERY;
+ state = XDM_COLLECT_QUERY;
+ break;
+ case XDM_BROADCAST:
+ header.opcode = (CARD16) BROADCAST_QUERY;
+ state = XDM_COLLECT_BROADCAST_QUERY;
+ broadcast = TRUE;
+ break;
+#if defined(IPv6) && defined(AF_INET6)
+ case XDM_MULTICAST:
+ header.opcode = (CARD16) BROADCAST_QUERY;
+ state = XDM_COLLECT_MULTICAST_QUERY;
+ multicast = TRUE;
+ break;
+#endif
+ case XDM_INDIRECT:
+ header.opcode = (CARD16) INDIRECT_QUERY;
+ state = XDM_COLLECT_INDIRECT_QUERY;
+ break;
+ default:
+ break;
+ }
+ header.length = 1;
+ for (i = 0; i < AuthenticationNames.length; i++)
+ header.length += 2 + AuthenticationNames.data[i].length;
+
+ XdmcpWriteHeader (&buffer, &header);
+ XdmcpWriteARRAYofARRAY8 (&buffer, &AuthenticationNames);
+ if (broadcast)
+ {
+ int i;
+
+ for (i = 0; i < NumBroadcastAddresses; i++)
+ XdmcpFlush (xdmcpSocket, &buffer, (XdmcpNetaddr) &BroadcastAddresses[i],
+ sizeof (struct sockaddr_in));
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ else if (multicast)
+ {
+ struct multicastinfo *mcl;
+ struct addrinfo *ai;
+
+ for (mcl = mcastlist; mcl != NULL; mcl = mcl->next) {
+ for (ai = mcl->ai ; ai != NULL; ai = ai->ai_next) {
+ if (ai->ai_family == AF_INET) {
+ unsigned char hopflag = (unsigned char) mcl->hops;
+ socketfd = xdmcpSocket;
+ setsockopt(socketfd, IPPROTO_IP, IP_MULTICAST_TTL,
+ &hopflag, sizeof(hopflag));
+ } else if (ai->ai_family == AF_INET6) {
+ int hopflag6 = mcl->hops;
+ socketfd = xdmcpSocket6;
+ setsockopt(socketfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
+ &hopflag6, sizeof(hopflag6));
+ } else {
+ continue;
+ }
+ XdmcpFlush (socketfd, &buffer,
+ (XdmcpNetaddr) ai->ai_addr, ai->ai_addrlen);
+ break;
+ }
+ }
+ }
+#endif
+ else
+ {
+#if defined(IPv6) && defined(AF_INET6)
+ if (SOCKADDR_FAMILY(ManagerAddress) == AF_INET6)
+ socketfd = xdmcpSocket6;
+#endif
+ XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &ManagerAddress,
+ ManagerAddressLen);
+ }
+}
+
+static void
+recv_willing_msg(
+ struct sockaddr *from,
+ int fromlen,
+ unsigned length)
+{
+ ARRAY8 authenticationName;
+ ARRAY8 hostname;
+ ARRAY8 status;
+
+ authenticationName.data = 0;
+ hostname.data = 0;
+ status.data = 0;
+ if (XdmcpReadARRAY8 (&buffer, &authenticationName) &&
+ XdmcpReadARRAY8 (&buffer, &hostname) &&
+ XdmcpReadARRAY8 (&buffer, &status))
+ {
+ if (length == 6 + authenticationName.length +
+ hostname.length + status.length)
+ {
+ switch (state)
+ {
+ case XDM_COLLECT_QUERY:
+ XdmcpSelectHost(from, fromlen, &authenticationName);
+ break;
+ case XDM_COLLECT_BROADCAST_QUERY:
+#if defined(IPv6) && defined(AF_INET6)
+ case XDM_COLLECT_MULTICAST_QUERY:
+#endif
+ case XDM_COLLECT_INDIRECT_QUERY:
+ XdmcpAddHost(from, fromlen, &authenticationName, &hostname, &status);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ XdmcpDisposeARRAY8 (&authenticationName);
+ XdmcpDisposeARRAY8 (&hostname);
+ XdmcpDisposeARRAY8 (&status);
+}
+
+static void
+send_request_msg(void)
+{
+ XdmcpHeader header;
+ int length;
+ int i;
+ CARD16 XdmcpConnectionType;
+ ARRAY8 authenticationData;
+ int socketfd = xdmcpSocket;
+
+ switch (SOCKADDR_FAMILY(ManagerAddress))
+ {
+ case AF_INET: XdmcpConnectionType=FamilyInternet; break;
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6: XdmcpConnectionType=FamilyInternet6; break;
+#endif
+ default: XdmcpConnectionType=0xffff; break;
+ }
+
+ header.version = XDM_PROTOCOL_VERSION;
+ header.opcode = (CARD16) REQUEST;
+
+ length = 2; /* display number */
+ length += 1 + 2 * ConnectionTypes.length; /* connection types */
+ length += 1; /* connection addresses */
+ for (i = 0; i < ConnectionAddresses.length; i++)
+ length += 2 + ConnectionAddresses.data[i].length;
+ authenticationData.length = 0;
+ authenticationData.data = 0;
+ if (AuthenticationFuncs)
+ {
+ (*AuthenticationFuncs->Generator) (AuthenticationData,
+ &authenticationData,
+ REQUEST);
+ }
+ length += 2 + AuthenticationName->length; /* authentication name */
+ length += 2 + authenticationData.length; /* authentication data */
+ length += 1; /* authorization names */
+ for (i = 0; i < AuthorizationNames.length; i++)
+ length += 2 + AuthorizationNames.data[i].length;
+ length += 2 + ManufacturerDisplayID.length; /* display ID */
+ header.length = length;
+
+ if (!XdmcpWriteHeader (&buffer, &header))
+ {
+ XdmcpDisposeARRAY8 (&authenticationData);
+ return;
+ }
+ XdmcpWriteCARD16 (&buffer, DisplayNumber);
+ XdmcpWriteCARD8 (&buffer, ConnectionTypes.length);
+
+ /* The connection array is send reordered, so that connections of */
+ /* the same address type as the XDMCP manager connection are send */
+ /* first. This works around a bug in xdm. mario@klebsch.de */
+ for (i = 0; i < (int)ConnectionTypes.length; i++)
+ if (ConnectionTypes.data[i]==XdmcpConnectionType)
+ XdmcpWriteCARD16 (&buffer, ConnectionTypes.data[i]);
+ for (i = 0; i < (int)ConnectionTypes.length; i++)
+ if (ConnectionTypes.data[i]!=XdmcpConnectionType)
+ XdmcpWriteCARD16 (&buffer, ConnectionTypes.data[i]);
+
+ XdmcpWriteCARD8 (&buffer, ConnectionAddresses.length);
+ for (i = 0; i < (int)ConnectionAddresses.length; i++)
+ if ( (i<ConnectionTypes.length) &&
+ (ConnectionTypes.data[i]==XdmcpConnectionType) )
+ XdmcpWriteARRAY8 (&buffer, &ConnectionAddresses.data[i]);
+ for (i = 0; i < (int)ConnectionAddresses.length; i++)
+ if ( (i>=ConnectionTypes.length) ||
+ (ConnectionTypes.data[i]!=XdmcpConnectionType) )
+ XdmcpWriteARRAY8 (&buffer, &ConnectionAddresses.data[i]);
+
+ XdmcpWriteARRAY8 (&buffer, AuthenticationName);
+ XdmcpWriteARRAY8 (&buffer, &authenticationData);
+ XdmcpDisposeARRAY8 (&authenticationData);
+ XdmcpWriteARRAYofARRAY8 (&buffer, &AuthorizationNames);
+ XdmcpWriteARRAY8 (&buffer, &ManufacturerDisplayID);
+#if defined(IPv6) && defined(AF_INET6)
+ if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6)
+ socketfd = xdmcpSocket6;
+#endif
+ if (XdmcpFlush (socketfd, &buffer,
+ (XdmcpNetaddr) &req_sockaddr, req_socklen))
+ state = XDM_AWAIT_REQUEST_RESPONSE;
+}
+
+static void
+recv_accept_msg(unsigned length)
+{
+ CARD32 AcceptSessionID;
+ ARRAY8 AcceptAuthenticationName, AcceptAuthenticationData;
+ ARRAY8 AcceptAuthorizationName, AcceptAuthorizationData;
+
+ if (state != XDM_AWAIT_REQUEST_RESPONSE)
+ return;
+ AcceptAuthenticationName.data = 0;
+ AcceptAuthenticationData.data = 0;
+ AcceptAuthorizationName.data = 0;
+ AcceptAuthorizationData.data = 0;
+ if (XdmcpReadCARD32 (&buffer, &AcceptSessionID) &&
+ XdmcpReadARRAY8 (&buffer, &AcceptAuthenticationName) &&
+ XdmcpReadARRAY8 (&buffer, &AcceptAuthenticationData) &&
+ XdmcpReadARRAY8 (&buffer, &AcceptAuthorizationName) &&
+ XdmcpReadARRAY8 (&buffer, &AcceptAuthorizationData))
+ {
+ if (length == 12 + AcceptAuthenticationName.length +
+ AcceptAuthenticationData.length +
+ AcceptAuthorizationName.length +
+ AcceptAuthorizationData.length)
+ {
+ if (!XdmcpCheckAuthentication (&AcceptAuthenticationName,
+ &AcceptAuthenticationData, ACCEPT))
+ {
+ XdmcpFatal ("Authentication Failure", &AcceptAuthenticationName);
+ }
+ /* permit access control manipulations from this host */
+ AugmentSelf (&req_sockaddr, req_socklen);
+ /* if the authorization specified in the packet fails
+ * to be acceptable, enable the local addresses
+ */
+ if (!XdmcpAddAuthorization (&AcceptAuthorizationName,
+ &AcceptAuthorizationData))
+ {
+ AddLocalHosts ();
+ }
+ SessionID = AcceptSessionID;
+ state = XDM_MANAGE;
+ send_packet();
+ }
+ }
+ XdmcpDisposeARRAY8 (&AcceptAuthenticationName);
+ XdmcpDisposeARRAY8 (&AcceptAuthenticationData);
+ XdmcpDisposeARRAY8 (&AcceptAuthorizationName);
+ XdmcpDisposeARRAY8 (&AcceptAuthorizationData);
+}
+
+static void
+recv_decline_msg(unsigned length)
+{
+ ARRAY8 status, DeclineAuthenticationName, DeclineAuthenticationData;
+
+ status.data = 0;
+ DeclineAuthenticationName.data = 0;
+ DeclineAuthenticationData.data = 0;
+ if (XdmcpReadARRAY8 (&buffer, &status) &&
+ XdmcpReadARRAY8 (&buffer, &DeclineAuthenticationName) &&
+ XdmcpReadARRAY8 (&buffer, &DeclineAuthenticationData))
+ {
+ if (length == 6 + status.length +
+ DeclineAuthenticationName.length +
+ DeclineAuthenticationData.length &&
+ XdmcpCheckAuthentication (&DeclineAuthenticationName,
+ &DeclineAuthenticationData, DECLINE))
+ {
+ XdmcpFatal ("Session declined", &status);
+ }
+ }
+ XdmcpDisposeARRAY8 (&status);
+ XdmcpDisposeARRAY8 (&DeclineAuthenticationName);
+ XdmcpDisposeARRAY8 (&DeclineAuthenticationData);
+}
+
+static void
+send_manage_msg(void)
+{
+ XdmcpHeader header;
+ int socketfd = xdmcpSocket;
+
+ header.version = XDM_PROTOCOL_VERSION;
+ header.opcode = (CARD16) MANAGE;
+ header.length = 8 + DisplayClass.length;
+
+ if (!XdmcpWriteHeader (&buffer, &header))
+ return;
+ XdmcpWriteCARD32 (&buffer, SessionID);
+ XdmcpWriteCARD16 (&buffer, DisplayNumber);
+ XdmcpWriteARRAY8 (&buffer, &DisplayClass);
+ state = XDM_AWAIT_MANAGE_RESPONSE;
+#if defined(IPv6) && defined(AF_INET6)
+ if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6)
+ socketfd = xdmcpSocket6;
+#endif
+ XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen);
+}
+
+static void
+recv_refuse_msg(unsigned length)
+{
+ CARD32 RefusedSessionID;
+
+ if (state != XDM_AWAIT_MANAGE_RESPONSE)
+ return;
+ if (length != 4)
+ return;
+ if (XdmcpReadCARD32 (&buffer, &RefusedSessionID))
+ {
+ if (RefusedSessionID == SessionID)
+ {
+ state = XDM_START_CONNECTION;
+ send_packet();
+ }
+ }
+}
+
+static void
+recv_failed_msg(unsigned length)
+{
+ CARD32 FailedSessionID;
+ ARRAY8 status;
+
+ if (state != XDM_AWAIT_MANAGE_RESPONSE)
+ return;
+ status.data = 0;
+ if (XdmcpReadCARD32 (&buffer, &FailedSessionID) &&
+ XdmcpReadARRAY8 (&buffer, &status))
+ {
+ if (length == 6 + status.length &&
+ SessionID == FailedSessionID)
+ {
+ XdmcpFatal ("Session failed", &status);
+ }
+ }
+ XdmcpDisposeARRAY8 (&status);
+}
+
+static void
+send_keepalive_msg(void)
+{
+ XdmcpHeader header;
+ int socketfd = xdmcpSocket;
+
+ header.version = XDM_PROTOCOL_VERSION;
+ header.opcode = (CARD16) KEEPALIVE;
+ header.length = 6;
+
+ XdmcpWriteHeader (&buffer, &header);
+ XdmcpWriteCARD16 (&buffer, DisplayNumber);
+ XdmcpWriteCARD32 (&buffer, SessionID);
+
+ state = XDM_AWAIT_ALIVE_RESPONSE;
+#if defined(IPv6) && defined(AF_INET6)
+ if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6)
+ socketfd = xdmcpSocket6;
+#endif
+ XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen);
+}
+
+static void
+recv_alive_msg (unsigned length)
+{
+ CARD8 SessionRunning;
+ CARD32 AliveSessionID;
+
+ if (state != XDM_AWAIT_ALIVE_RESPONSE)
+ return;
+ if (length != 5)
+ return;
+ if (XdmcpReadCARD8 (&buffer, &SessionRunning) &&
+ XdmcpReadCARD32 (&buffer, &AliveSessionID))
+ {
+ if (SessionRunning && AliveSessionID == SessionID)
+ {
+ /* backoff dormancy period */
+ state = XDM_RUN_SESSION;
+ if ((GetTimeInMillis() - lastDeviceEventTime.milliseconds) >
+ keepaliveDormancy * 1000)
+ {
+ keepaliveDormancy <<= 1;
+ if (keepaliveDormancy > XDM_MAX_DORMANCY)
+ keepaliveDormancy = XDM_MAX_DORMANCY;
+ }
+ timeOutTime = GetTimeInMillis() + keepaliveDormancy * 1000;
+ }
+ else
+ {
+ XdmcpDeadSession ("Alive response indicates session dead");
+ }
+ }
+}
+
+static void
+XdmcpFatal (
+ char *type,
+ ARRAY8Ptr status)
+{
+ FatalError ("XDMCP fatal error: %s %*.*s\n", type,
+ status->length, status->length, status->data);
+}
+
+static void
+XdmcpWarning(char *str)
+{
+ ErrorF("XDMCP warning: %s\n", str);
+}
+
+static void
+get_addr_by_name(
+ char * argtype,
+ char * namestr,
+ int port,
+ int socktype,
+ SOCKADDR_TYPE *addr,
+ SOCKLEN_TYPE *addrlen
+#if defined(IPv6) && defined(AF_INET6)
+ ,
+ struct addrinfo **aip,
+ struct addrinfo **aifirstp
+#endif
+ )
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct addrinfo *ai;
+ struct addrinfo hints;
+ char portstr[6];
+ char *pport = portstr;
+ int gaierr;
+
+ bzero(&hints, sizeof(hints));
+ hints.ai_socktype = socktype;
+
+ if (port == 0) {
+ pport = NULL;
+ } else if (port > 0 && port < 65535) {
+ sprintf(portstr, "%d", port);
+ } else {
+ FatalError("Xserver: port out of range: %d\n", port);
+ }
+
+ if (*aifirstp != NULL) {
+ freeaddrinfo(*aifirstp);
+ *aifirstp = NULL;
+ }
+
+ if ((gaierr = getaddrinfo(namestr, pport, &hints, aifirstp)) == 0) {
+ for (ai = *aifirstp; ai != NULL; ai = ai->ai_next) {
+ if (ai->ai_family == AF_INET || ai->ai_family == AF_INET6)
+ break;
+ }
+ if ((ai == NULL) || (ai->ai_addrlen > sizeof(SOCKADDR_TYPE))) {
+ FatalError ("Xserver: %s host %s not on supported network type\n",
+ argtype, namestr);
+ } else {
+ *aip = ai;
+ *addrlen = ai->ai_addrlen;
+ memcpy(addr, ai->ai_addr, ai->ai_addrlen);
+ }
+ } else {
+ FatalError("Xserver: %s: %s %s\n", gai_strerror(gaierr), argtype, namestr);
+ }
+#else
+ struct hostent *hep;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+#if defined(WIN32) && (defined(TCPCONN) || defined(DNETCONN))
+ _XSERVTransWSAStartup();
+#endif
+ if (!(hep = _XGethostbyname(namestr, hparams)))
+ {
+ FatalError("Xserver: %s unknown host: %s\n", argtype, namestr);
+ }
+ if (hep->h_length == sizeof (struct in_addr))
+ {
+ memmove(&addr->sin_addr, hep->h_addr, hep->h_length);
+ *addrlen = sizeof(struct sockaddr_in);
+ addr->sin_family = AF_INET;
+ addr->sin_port = htons (port);
+ }
+ else
+ {
+ FatalError("Xserver: %s host on strange network %s\n", argtype, namestr);
+ }
+#endif
+}
+
+static void
+get_manager_by_name(
+ int argc,
+ char **argv,
+ int i)
+{
+
+ if ((i + 1) == argc)
+ {
+ FatalError("Xserver: missing %s host name in command line\n", argv[i]);
+ }
+
+ get_addr_by_name(argv[i], argv[i+1], xdm_udp_port, SOCK_DGRAM,
+ &ManagerAddress, &ManagerAddressLen
+#if defined(IPv6) && defined(AF_INET6)
+ , &mgrAddr, &mgrAddrFirst
+#endif
+ );
+}
+
+
+static void
+get_fromaddr_by_name(
+ int argc,
+ char **argv,
+ int i)
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct addrinfo *ai = NULL;
+ struct addrinfo *aifirst = NULL;
+#endif
+ if (i == argc)
+ {
+ FatalError("Xserver: missing -from host name in command line\n");
+ }
+ get_addr_by_name("-from", argv[i], 0, 0, &FromAddress, &FromAddressLen
+#if defined(IPv6) && defined(AF_INET6)
+ , &ai, &aifirst
+#endif
+ );
+ xdm_from = argv[i];
+}
+
+
+#if defined(IPv6) && defined(AF_INET6)
+static int
+get_mcast_options(argc, argv, i)
+ int argc, i;
+ char **argv;
+{
+ char *address = XDM_DEFAULT_MCAST_ADDR6;
+ int hopcount = 1;
+ struct addrinfo hints;
+ char portstr[6];
+ int gaierr;
+ struct addrinfo *ai, *firstai;
+
+ if ((i < argc) && (argv[i][0] != '-') && (argv[i][0] != '+')) {
+ address = argv[i++];
+ if ((i < argc) && (argv[i][0] != '-') && (argv[i][0] != '+')) {
+ hopcount = strtol(argv[i++], NULL, 10);
+ if ((hopcount < 1) || (hopcount > 255)) {
+ FatalError("Xserver: multicast hop count out of range: %d\n",
+ hopcount);
+ }
+ }
+ }
+
+ if (xdm_udp_port > 0 && xdm_udp_port < 65535) {
+ sprintf(portstr, "%d", xdm_udp_port);
+ } else {
+ FatalError("Xserver: port out of range: %d\n", xdm_udp_port);
+ }
+ bzero(&hints, sizeof(hints));
+ hints.ai_socktype = SOCK_DGRAM;
+
+ if ((gaierr = getaddrinfo(address, portstr, &hints, &firstai)) == 0) {
+ for (ai = firstai; ai != NULL; ai = ai->ai_next) {
+ if (((ai->ai_family == AF_INET) &&
+ IN_MULTICAST(((struct sockaddr_in *) ai->ai_addr)
+ ->sin_addr.s_addr))
+ || ((ai->ai_family == AF_INET6) &&
+ IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6 *) ai->ai_addr)
+ ->sin6_addr)))
+ break;
+ }
+ if (ai == NULL) {
+ FatalError ("Xserver: address not supported multicast type %s\n",
+ address);
+ } else {
+ struct multicastinfo *mcastinfo, *mcl;
+
+ mcastinfo = malloc(sizeof(struct multicastinfo));
+ mcastinfo->next = NULL;
+ mcastinfo->ai = firstai;
+ mcastinfo->hops = hopcount;
+
+ if (mcastlist == NULL) {
+ mcastlist = mcastinfo;
+ } else {
+ for (mcl = mcastlist; mcl->next != NULL; mcl = mcl->next) {
+ /* Do nothing - just find end of list */
+ }
+ mcl->next = mcastinfo;
+ }
+ }
+ } else {
+ FatalError("Xserver: %s: %s\n", gai_strerror(gaierr), address);
+ }
+ return i;
+}
+#endif
+
+#else
+static int xdmcp_non_empty; /* avoid complaint by ranlib */
+#endif /* XDMCP */
diff --git a/nx-X11/programs/Xserver/os/xdmcp.c.X.original b/nx-X11/programs/Xserver/os/xdmcp.c.X.original
new file mode 100644
index 000000000..19a62a56b
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/xdmcp.c.X.original
@@ -0,0 +1,1681 @@
+/* $XdotOrg: xc/programs/Xserver/os/xdmcp.c,v 1.10 2005/07/03 08:53:52 daniels Exp $ */
+/* $Xorg: xdmcp.c,v 1.4 2001/01/31 13:37:19 pookie Exp $ */
+/*
+ * Copyright 1989 Network Computing Devices, Inc., Mountain View, California.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of N.C.D. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. N.C.D. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/os/xdmcp.c,v 3.31 2003/12/30 21:24:32 herrb Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#endif
+
+#include <X11/Xos.h>
+
+#if !defined(WIN32)
+#ifndef Lynx
+#include <sys/param.h>
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif
+#include <netinet/in.h>
+#include <netdb.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "misc.h"
+#include <X11/Xpoll.h>
+#include "osdep.h"
+#include "input.h"
+#include "dixstruct.h"
+#include "opaque.h"
+
+#if defined(DGUX)
+#include <net/net_ioctl.h>
+#include <sys/ioctl.h>
+#endif
+
+#ifdef STREAMSCONN
+#include <tiuser.h>
+#include <netconfig.h>
+#include <netdir.h>
+#endif
+
+#ifdef XDMCP
+#undef REQUEST
+
+#ifdef XDMCP_NO_IPV6
+#undef IPv6
+#endif
+
+#include <X11/Xdmcp.h>
+
+#define X_INCLUDE_NETDB_H
+#include <X11/Xos_r.h>
+
+extern char *defaultDisplayClass;
+
+static int xdmcpSocket, sessionSocket;
+static xdmcp_states state;
+#if defined(IPv6) && defined(AF_INET6)
+static int xdmcpSocket6;
+static struct sockaddr_storage req_sockaddr;
+#else
+static struct sockaddr_in req_sockaddr;
+#endif
+static int req_socklen;
+static CARD32 SessionID;
+static CARD32 timeOutTime;
+static int timeOutRtx;
+static CARD32 defaultKeepaliveDormancy = XDM_DEF_DORMANCY;
+static CARD32 keepaliveDormancy = XDM_DEF_DORMANCY;
+static CARD16 DisplayNumber;
+static xdmcp_states XDM_INIT_STATE = XDM_OFF;
+#ifdef HASXDMAUTH
+static char *xdmAuthCookie;
+#endif
+
+static XdmcpBuffer buffer;
+
+#if defined(IPv6) && defined(AF_INET6)
+
+static struct addrinfo *mgrAddr;
+static struct addrinfo *mgrAddrFirst;
+
+#define SOCKADDR_TYPE struct sockaddr_storage
+#define SOCKADDR_FAMILY(s) ((struct sockaddr *)&(s))->sa_family
+
+#ifdef BSD44SOCKETS
+#define SOCKLEN_FIELD(s) ((struct sockaddr *)&(s))->sa_len
+#define SOCKLEN_TYPE unsigned char
+#else
+#define SOCKLEN_TYPE unsigned int
+#endif
+
+#else
+
+#define SOCKADDR_TYPE struct sockaddr_in
+#define SOCKADDR_FAMILY(s) (s).sin_family
+
+#ifdef BSD44SOCKETS
+#define SOCKLEN_FIELD(s) (s).sin_len
+#define SOCKLEN_TYPE unsigned char
+#else
+#define SOCKLEN_TYPE size_t
+#endif
+
+#endif
+
+static SOCKADDR_TYPE ManagerAddress;
+static SOCKADDR_TYPE FromAddress;
+
+#ifdef SOCKLEN_FIELD
+#define ManagerAddressLen SOCKLEN_FIELD(ManagerAddress)
+#define FromAddressLen SOCKLEN_FIELD(FromAddress)
+#else
+static SOCKLEN_TYPE ManagerAddressLen, FromAddressLen;
+#endif
+
+#if defined(IPv6) && defined(AF_INET6)
+static struct multicastinfo {
+ struct multicastinfo *next;
+ struct addrinfo *ai;
+ int hops;
+} *mcastlist;
+#endif
+
+static void XdmcpAddHost(
+ struct sockaddr *from,
+ int fromlen,
+ ARRAY8Ptr AuthenticationName,
+ ARRAY8Ptr hostname,
+ ARRAY8Ptr status);
+
+static void XdmcpSelectHost(
+ struct sockaddr *host_sockaddr,
+ int host_len,
+ ARRAY8Ptr AuthenticationName);
+
+static void get_xdmcp_sock(void);
+
+static void send_query_msg(void);
+
+static void recv_willing_msg(
+ struct sockaddr * /*from*/,
+ int /*fromlen*/,
+ unsigned /*length*/);
+
+static void send_request_msg(void);
+
+static void recv_accept_msg(unsigned /*length*/);
+
+static void recv_decline_msg(unsigned /*length*/);
+
+static void send_manage_msg(void);
+
+static void recv_refuse_msg(unsigned /*length*/);
+
+static void recv_failed_msg(unsigned /*length*/);
+
+static void send_keepalive_msg(void);
+
+static void recv_alive_msg(unsigned /*length*/);
+
+static void XdmcpFatal(
+ char * /*type*/,
+ ARRAY8Ptr /*status*/);
+
+static void XdmcpWarning(char * /*str*/);
+
+static void get_manager_by_name(
+ int /*argc*/,
+ char ** /*argv*/,
+ int /*i*/);
+
+static void get_fromaddr_by_name(int /*argc*/, char ** /*argv*/, int /*i*/);
+
+#if defined(IPv6) && defined(AF_INET6)
+static int get_mcast_options(int /*argc*/, char ** /*argv*/, int /*i*/);
+#endif
+
+static void receive_packet(int /*socketfd*/);
+
+static void send_packet(void);
+
+extern void XdmcpDeadSession(char * /*reason*/);
+
+static void timeout(void);
+
+static void restart(void);
+
+static void XdmcpBlockHandler(
+ pointer /*data*/,
+ struct timeval ** /*wt*/,
+ pointer /*LastSelectMask*/);
+
+static void XdmcpWakeupHandler(
+ pointer /*data*/,
+ int /*i*/,
+ pointer /*LastSelectMask*/);
+
+void XdmcpRegisterManufacturerDisplayID(
+ char * /*name*/,
+ int /*length*/);
+
+
+static unsigned short xdm_udp_port = XDM_UDP_PORT;
+static Bool OneSession = FALSE;
+static const char *xdm_from = NULL;
+
+void
+XdmcpUseMsg (void)
+{
+ ErrorF("-query host-name contact named host for XDMCP\n");
+ ErrorF("-broadcast broadcast for XDMCP\n");
+#if defined(IPv6) && defined(AF_INET6)
+ ErrorF("-multicast [addr [hops]] IPv6 multicast for XDMCP\n");
+#endif
+ ErrorF("-indirect host-name contact named host for indirect XDMCP\n");
+ ErrorF("-port port-num UDP port number to send messages to\n");
+ ErrorF("-from local-address specify the local address to connect from\n");
+ ErrorF("-once Terminate server after one session\n");
+ ErrorF("-class display-class specify display class to send in manage\n");
+#ifdef HASXDMAUTH
+ ErrorF("-cookie xdm-auth-bits specify the magic cookie for XDMCP\n");
+#endif
+ ErrorF("-displayID display-id manufacturer display ID for request\n");
+}
+
+int
+XdmcpOptions(int argc, char **argv, int i)
+{
+ if (strcmp(argv[i], "-query") == 0) {
+ get_manager_by_name(argc, argv, i++);
+ XDM_INIT_STATE = XDM_QUERY;
+ AccessUsingXdmcp ();
+ return (i + 1);
+ }
+ if (strcmp(argv[i], "-broadcast") == 0) {
+ XDM_INIT_STATE = XDM_BROADCAST;
+ AccessUsingXdmcp ();
+ return (i + 1);
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ if (strcmp(argv[i], "-multicast") == 0) {
+ i = get_mcast_options(argc, argv, ++i);
+ XDM_INIT_STATE = XDM_MULTICAST;
+ AccessUsingXdmcp ();
+ return (i + 1);
+ }
+#endif
+ if (strcmp(argv[i], "-indirect") == 0) {
+ get_manager_by_name(argc, argv, i++);
+ XDM_INIT_STATE = XDM_INDIRECT;
+ AccessUsingXdmcp ();
+ return (i + 1);
+ }
+ if (strcmp(argv[i], "-port") == 0) {
+ if (++i == argc) {
+ FatalError("Xserver: missing port number in command line\n");
+ }
+ xdm_udp_port = (unsigned short) atoi(argv[i]);
+ return (i + 1);
+ }
+ if (strcmp(argv[i], "-from") == 0) {
+ get_fromaddr_by_name(argc, argv, ++i);
+ return (i + 1);
+ }
+ if (strcmp(argv[i], "-once") == 0) {
+ OneSession = TRUE;
+ return (i + 1);
+ }
+ if (strcmp(argv[i], "-class") == 0) {
+ if (++i == argc) {
+ FatalError("Xserver: missing class name in command line\n");
+ }
+ defaultDisplayClass = argv[i];
+ return (i + 1);
+ }
+#ifdef HASXDMAUTH
+ if (strcmp(argv[i], "-cookie") == 0) {
+ if (++i == argc) {
+ FatalError("Xserver: missing cookie data in command line\n");
+ }
+ xdmAuthCookie = argv[i];
+ return (i + 1);
+ }
+#endif
+ if (strcmp(argv[i], "-displayID") == 0) {
+ if (++i == argc) {
+ FatalError("Xserver: missing displayID in command line\n");
+ }
+ XdmcpRegisterManufacturerDisplayID (argv[i], strlen (argv[i]));
+ return (i + 1);
+ }
+ return (i);
+}
+
+/*
+ * This section is a collection of routines for
+ * registering server-specific data with the XDMCP
+ * state machine.
+ */
+
+
+/*
+ * Save all broadcast addresses away so BroadcastQuery
+ * packets get sent everywhere
+ */
+
+#define MAX_BROADCAST 10
+
+/* This stays sockaddr_in since IPv6 doesn't support broadcast */
+static struct sockaddr_in BroadcastAddresses[MAX_BROADCAST];
+static int NumBroadcastAddresses;
+
+void
+XdmcpRegisterBroadcastAddress (struct sockaddr_in *addr)
+{
+ struct sockaddr_in *bcast;
+ if (NumBroadcastAddresses >= MAX_BROADCAST)
+ return;
+ bcast = &BroadcastAddresses[NumBroadcastAddresses++];
+ bzero (bcast, sizeof (struct sockaddr_in));
+#ifdef BSD44SOCKETS
+ bcast->sin_len = addr->sin_len;
+#endif
+ bcast->sin_family = addr->sin_family;
+ bcast->sin_port = htons (xdm_udp_port);
+ bcast->sin_addr = addr->sin_addr;
+}
+
+/*
+ * Each authentication type is registered here; Validator
+ * will be called to check all access attempts using
+ * the specified authentication type
+ */
+
+static ARRAYofARRAY8 AuthenticationNames, AuthenticationDatas;
+typedef struct _AuthenticationFuncs {
+ ValidatorFunc Validator;
+ GeneratorFunc Generator;
+ AddAuthorFunc AddAuth;
+} AuthenticationFuncsRec, *AuthenticationFuncsPtr;
+
+static AuthenticationFuncsPtr AuthenticationFuncsList;
+
+void
+XdmcpRegisterAuthentication (
+ char *name,
+ int namelen,
+ char *data,
+ int datalen,
+ ValidatorFunc Validator,
+ GeneratorFunc Generator,
+ AddAuthorFunc AddAuth)
+{
+ int i;
+ ARRAY8 AuthenticationName, AuthenticationData;
+ static AuthenticationFuncsPtr newFuncs;
+
+ if (!XdmcpAllocARRAY8 (&AuthenticationName, namelen))
+ return;
+ if (!XdmcpAllocARRAY8 (&AuthenticationData, datalen))
+ {
+ XdmcpDisposeARRAY8 (&AuthenticationName);
+ return;
+ }
+ for (i = 0; i < namelen; i++)
+ AuthenticationName.data[i] = name[i];
+ for (i = 0; i < datalen; i++)
+ AuthenticationData.data[i] = data[i];
+ if (!(XdmcpReallocARRAYofARRAY8 (&AuthenticationNames,
+ AuthenticationNames.length + 1) &&
+ XdmcpReallocARRAYofARRAY8 (&AuthenticationDatas,
+ AuthenticationDatas.length + 1) &&
+ (newFuncs = (AuthenticationFuncsPtr) xalloc (
+ (AuthenticationNames.length + 1) * sizeof (AuthenticationFuncsRec)))))
+ {
+ XdmcpDisposeARRAY8 (&AuthenticationName);
+ XdmcpDisposeARRAY8 (&AuthenticationData);
+ return;
+ }
+ for (i = 0; i < AuthenticationNames.length - 1; i++)
+ newFuncs[i] = AuthenticationFuncsList[i];
+ newFuncs[AuthenticationNames.length-1].Validator = Validator;
+ newFuncs[AuthenticationNames.length-1].Generator = Generator;
+ newFuncs[AuthenticationNames.length-1].AddAuth = AddAuth;
+ xfree (AuthenticationFuncsList);
+ AuthenticationFuncsList = newFuncs;
+ AuthenticationNames.data[AuthenticationNames.length-1] = AuthenticationName;
+ AuthenticationDatas.data[AuthenticationDatas.length-1] = AuthenticationData;
+}
+
+/*
+ * Select the authentication type to be used; this is
+ * set by the manager of the host to be connected to.
+ */
+
+ARRAY8 noAuthenticationName = {(CARD16) 0, (CARD8Ptr) 0};
+ARRAY8 noAuthenticationData = {(CARD16) 0, (CARD8Ptr) 0};
+ARRAY8Ptr AuthenticationName = &noAuthenticationName;
+ARRAY8Ptr AuthenticationData = &noAuthenticationData;
+AuthenticationFuncsPtr AuthenticationFuncs;
+
+void
+XdmcpSetAuthentication (ARRAY8Ptr name)
+{
+ int i;
+
+ for (i = 0; i < AuthenticationNames.length; i++)
+ if (XdmcpARRAY8Equal (&AuthenticationNames.data[i], name))
+ {
+ AuthenticationName = &AuthenticationNames.data[i];
+ AuthenticationData = &AuthenticationDatas.data[i];
+ AuthenticationFuncs = &AuthenticationFuncsList[i];
+ break;
+ }
+}
+
+/*
+ * Register the host address for the display
+ */
+
+static ARRAY16 ConnectionTypes;
+static ARRAYofARRAY8 ConnectionAddresses;
+static long xdmcpGeneration;
+
+void
+XdmcpRegisterConnection (
+ int type,
+ char *address,
+ int addrlen)
+{
+ int i;
+ CARD8 *newAddress;
+
+ if (xdmcpGeneration != serverGeneration)
+ {
+ XdmcpDisposeARRAY16 (&ConnectionTypes);
+ XdmcpDisposeARRAYofARRAY8 (&ConnectionAddresses);
+ xdmcpGeneration = serverGeneration;
+ }
+ if (xdm_from != NULL) { /* Only register the requested address */
+ const void *regAddr = address;
+ const void *fromAddr = NULL;
+ int regAddrlen = addrlen;
+
+ if (addrlen == sizeof(struct in_addr)) {
+ if (SOCKADDR_FAMILY(FromAddress) == AF_INET) {
+ fromAddr = &((struct sockaddr_in *)&FromAddress)->sin_addr;
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ else if ((SOCKADDR_FAMILY(FromAddress) == AF_INET6) &&
+ IN6_IS_ADDR_V4MAPPED(
+ &((struct sockaddr_in6 *)&FromAddress)->sin6_addr)) {
+ fromAddr = &((struct sockaddr_in6 *)&FromAddress)->sin6_addr.s6_addr[12];
+ }
+#endif
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ else if (addrlen == sizeof(struct in6_addr)) {
+ if (SOCKADDR_FAMILY(FromAddress) == AF_INET6) {
+ fromAddr = &((struct sockaddr_in6 *)&FromAddress)->sin6_addr;
+ } else if ((SOCKADDR_FAMILY(FromAddress) == AF_INET) &&
+ IN6_IS_ADDR_V4MAPPED((struct in6_addr *) address)) {
+ fromAddr = &((struct sockaddr_in *)&FromAddress)->sin_addr;
+ regAddr = &((struct sockaddr_in6 *)&address)->sin6_addr.s6_addr[12];
+ regAddrlen = sizeof(struct in_addr);
+ }
+ }
+#endif
+ if (fromAddr && memcmp(regAddr, fromAddr, regAddrlen) != 0) {
+ return;
+ }
+ }
+ newAddress = (CARD8 *) xalloc (addrlen * sizeof (CARD8));
+ if (!newAddress)
+ return;
+ if (!XdmcpReallocARRAY16 (&ConnectionTypes, ConnectionTypes.length + 1))
+ {
+ xfree (newAddress);
+ return;
+ }
+ if (!XdmcpReallocARRAYofARRAY8 (&ConnectionAddresses,
+ ConnectionAddresses.length + 1))
+ {
+ xfree (newAddress);
+ return;
+ }
+ ConnectionTypes.data[ConnectionTypes.length - 1] = (CARD16) type;
+ for (i = 0; i < addrlen; i++)
+ newAddress[i] = address[i];
+ ConnectionAddresses.data[ConnectionAddresses.length-1].data = newAddress;
+ ConnectionAddresses.data[ConnectionAddresses.length-1].length = addrlen;
+}
+
+/*
+ * Register an Authorization Name. XDMCP advertises this list
+ * to the manager.
+ */
+
+static ARRAYofARRAY8 AuthorizationNames;
+
+void
+XdmcpRegisterAuthorizations (void)
+{
+ XdmcpDisposeARRAYofARRAY8 (&AuthorizationNames);
+ RegisterAuthorizations ();
+}
+
+void
+XdmcpRegisterAuthorization (char *name, int namelen)
+{
+ ARRAY8 authName;
+ int i;
+
+ authName.data = (CARD8 *) xalloc (namelen * sizeof (CARD8));
+ if (!authName.data)
+ return;
+ if (!XdmcpReallocARRAYofARRAY8 (&AuthorizationNames, AuthorizationNames.length +1))
+ {
+ xfree (authName.data);
+ return;
+ }
+ for (i = 0; i < namelen; i++)
+ authName.data[i] = (CARD8) name[i];
+ authName.length = namelen;
+ AuthorizationNames.data[AuthorizationNames.length-1] = authName;
+}
+
+/*
+ * Register the DisplayClass string
+ */
+
+ARRAY8 DisplayClass;
+
+void
+XdmcpRegisterDisplayClass (char *name, int length)
+{
+ int i;
+
+ XdmcpDisposeARRAY8 (&DisplayClass);
+ if (!XdmcpAllocARRAY8 (&DisplayClass, length))
+ return;
+ for (i = 0; i < length; i++)
+ DisplayClass.data[i] = (CARD8) name[i];
+}
+
+/*
+ * Register the Manufacturer display ID
+ */
+
+ARRAY8 ManufacturerDisplayID;
+
+void
+XdmcpRegisterManufacturerDisplayID (char *name, int length)
+{
+ int i;
+
+ XdmcpDisposeARRAY8 (&ManufacturerDisplayID);
+ if (!XdmcpAllocARRAY8 (&ManufacturerDisplayID, length))
+ return;
+ for (i = 0; i < length; i++)
+ ManufacturerDisplayID.data[i] = (CARD8) name[i];
+}
+
+/*
+ * initialize XDMCP; create the socket, compute the display
+ * number, set up the state machine
+ */
+
+void
+XdmcpInit(void)
+{
+ state = XDM_INIT_STATE;
+#ifdef HASXDMAUTH
+ if (xdmAuthCookie)
+ XdmAuthenticationInit (xdmAuthCookie, strlen (xdmAuthCookie));
+#endif
+ if (state != XDM_OFF)
+ {
+ XdmcpRegisterAuthorizations();
+ XdmcpRegisterDisplayClass (defaultDisplayClass, strlen (defaultDisplayClass));
+ AccessUsingXdmcp();
+ RegisterBlockAndWakeupHandlers (XdmcpBlockHandler, XdmcpWakeupHandler,
+ (pointer) 0);
+ timeOutRtx = 0;
+ DisplayNumber = (CARD16) atoi(display);
+ get_xdmcp_sock();
+ send_packet();
+ }
+}
+
+void
+XdmcpReset (void)
+{
+ state = XDM_INIT_STATE;
+ if (state != XDM_OFF)
+ {
+ RegisterBlockAndWakeupHandlers (XdmcpBlockHandler, XdmcpWakeupHandler,
+ (pointer) 0);
+ timeOutRtx = 0;
+ send_packet();
+ }
+}
+
+/*
+ * Called whenever a new connection is created; notices the
+ * first connection and saves it to terminate the session
+ * when it is closed
+ */
+
+void
+XdmcpOpenDisplay(int sock)
+{
+ if (state != XDM_AWAIT_MANAGE_RESPONSE)
+ return;
+ state = XDM_RUN_SESSION;
+ sessionSocket = sock;
+}
+
+void
+XdmcpCloseDisplay(int sock)
+{
+ if ((state != XDM_RUN_SESSION && state != XDM_AWAIT_ALIVE_RESPONSE)
+ || sessionSocket != sock)
+ return;
+ state = XDM_INIT_STATE;
+ if (OneSession)
+ dispatchException |= DE_TERMINATE;
+ else
+ dispatchException |= DE_RESET;
+ isItTimeToYield = TRUE;
+}
+
+/*
+ * called before going to sleep, this routine
+ * may modify the timeout value about to be sent
+ * to select; in this way XDMCP can do appropriate things
+ * dynamically while starting up
+ */
+
+/*ARGSUSED*/
+static void
+XdmcpBlockHandler(
+ pointer data, /* unused */
+ struct timeval **wt,
+ pointer pReadmask)
+{
+ fd_set *LastSelectMask = (fd_set*)pReadmask;
+ CARD32 millisToGo;
+
+ if (state == XDM_OFF)
+ return;
+ FD_SET(xdmcpSocket, LastSelectMask);
+#if defined(IPv6) && defined(AF_INET6)
+ if (xdmcpSocket6 >= 0)
+ FD_SET(xdmcpSocket6, LastSelectMask);
+#endif
+ if (timeOutTime == 0)
+ return;
+ millisToGo = timeOutTime - GetTimeInMillis();
+ if ((int) millisToGo < 0)
+ millisToGo = 0;
+ AdjustWaitForDelay (wt, millisToGo);
+}
+
+/*
+ * called after select returns; this routine will
+ * recognise when XDMCP packets await and
+ * process them appropriately
+ */
+
+/*ARGSUSED*/
+static void
+XdmcpWakeupHandler(
+ pointer data, /* unused */
+ int i,
+ pointer pReadmask)
+{
+ fd_set* LastSelectMask = (fd_set*)pReadmask;
+ fd_set devicesReadable;
+
+ if (state == XDM_OFF)
+ return;
+ if (i > 0)
+ {
+ if (FD_ISSET(xdmcpSocket, LastSelectMask))
+ {
+ receive_packet(xdmcpSocket);
+ FD_CLR(xdmcpSocket, LastSelectMask);
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ if (xdmcpSocket6 >= 0 && FD_ISSET(xdmcpSocket6, LastSelectMask))
+ {
+ receive_packet(xdmcpSocket6);
+ FD_CLR(xdmcpSocket6, LastSelectMask);
+ }
+#endif
+ XFD_ANDSET(&devicesReadable, LastSelectMask, &EnabledDevices);
+ if (XFD_ANYSET(&devicesReadable))
+ {
+ if (state == XDM_AWAIT_USER_INPUT)
+ restart();
+ else if (state == XDM_RUN_SESSION)
+ keepaliveDormancy = defaultKeepaliveDormancy;
+ }
+ if (XFD_ANYSET(&AllClients) && state == XDM_RUN_SESSION)
+ timeOutTime = GetTimeInMillis() + keepaliveDormancy * 1000;
+ }
+ else if (timeOutTime && (int) (GetTimeInMillis() - timeOutTime) >= 0)
+ {
+ if (state == XDM_RUN_SESSION)
+ {
+ state = XDM_KEEPALIVE;
+ send_packet();
+ }
+ else
+ timeout();
+ }
+}
+
+/*
+ * This routine should be called from the routine that drives the
+ * user's host menu when the user selects a host
+ */
+
+static void
+XdmcpSelectHost(
+ struct sockaddr *host_sockaddr,
+ int host_len,
+ ARRAY8Ptr AuthenticationName)
+{
+ state = XDM_START_CONNECTION;
+ memmove(&req_sockaddr, host_sockaddr, host_len);
+ req_socklen = host_len;
+ XdmcpSetAuthentication (AuthenticationName);
+ send_packet();
+}
+
+/*
+ * !!! this routine should be replaced by a routine that adds
+ * the host to the user's host menu. the current version just
+ * selects the first host to respond with willing message.
+ */
+
+/*ARGSUSED*/
+static void
+XdmcpAddHost(
+ struct sockaddr *from,
+ int fromlen,
+ ARRAY8Ptr AuthenticationName,
+ ARRAY8Ptr hostname,
+ ARRAY8Ptr status)
+{
+ XdmcpSelectHost(from, fromlen, AuthenticationName);
+}
+
+/*
+ * A message is queued on the socket; read it and
+ * do the appropriate thing
+ */
+
+ARRAY8 UnwillingMessage = { (CARD8) 14, (CARD8 *) "Host unwilling" };
+
+static void
+receive_packet(int socketfd)
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_storage from;
+#else
+ struct sockaddr_in from;
+#endif
+ int fromlen = sizeof(from);
+ XdmcpHeader header;
+
+ /* read message off socket */
+ if (!XdmcpFill (socketfd, &buffer, (XdmcpNetaddr) &from, &fromlen))
+ return;
+
+ /* reset retransmission backoff */
+ timeOutRtx = 0;
+
+ if (!XdmcpReadHeader (&buffer, &header))
+ return;
+
+ if (header.version != XDM_PROTOCOL_VERSION)
+ return;
+
+ switch (header.opcode) {
+ case WILLING:
+ recv_willing_msg((struct sockaddr *) &from, fromlen, header.length);
+ break;
+ case UNWILLING:
+ XdmcpFatal("Manager unwilling", &UnwillingMessage);
+ break;
+ case ACCEPT:
+ recv_accept_msg(header.length);
+ break;
+ case DECLINE:
+ recv_decline_msg(header.length);
+ break;
+ case REFUSE:
+ recv_refuse_msg(header.length);
+ break;
+ case FAILED:
+ recv_failed_msg(header.length);
+ break;
+ case ALIVE:
+ recv_alive_msg(header.length);
+ break;
+ }
+}
+
+/*
+ * send the appropriate message given the current state
+ */
+
+static void
+send_packet(void)
+{
+ int rtx;
+ switch (state) {
+ case XDM_QUERY:
+ case XDM_BROADCAST:
+ case XDM_INDIRECT:
+#if defined(IPv6) && defined(AF_INET6)
+ case XDM_MULTICAST:
+#endif
+ send_query_msg();
+ break;
+ case XDM_START_CONNECTION:
+ send_request_msg();
+ break;
+ case XDM_MANAGE:
+ send_manage_msg();
+ break;
+ case XDM_KEEPALIVE:
+ send_keepalive_msg();
+ break;
+ default:
+ break;
+ }
+ rtx = (XDM_MIN_RTX << timeOutRtx);
+ if (rtx > XDM_MAX_RTX)
+ rtx = XDM_MAX_RTX;
+ timeOutTime = GetTimeInMillis() + rtx * 1000;
+}
+
+/*
+ * The session is declared dead for some reason; too many
+ * timeouts, or Keepalive failure.
+ */
+
+void
+XdmcpDeadSession (char *reason)
+{
+ ErrorF ("XDM: %s, declaring session dead\n", reason);
+ state = XDM_INIT_STATE;
+ isItTimeToYield = TRUE;
+ dispatchException |= DE_RESET;
+ timeOutTime = 0;
+ timeOutRtx = 0;
+ send_packet();
+}
+
+/*
+ * Timeout waiting for an XDMCP response.
+ */
+
+static void
+timeout(void)
+{
+ timeOutRtx++;
+ if (state == XDM_AWAIT_ALIVE_RESPONSE && timeOutRtx >= XDM_KA_RTX_LIMIT )
+ {
+ XdmcpDeadSession ("too many keepalive retransmissions");
+ return;
+ }
+ else if (timeOutRtx >= XDM_RTX_LIMIT)
+ {
+ /* Quit if "-once" specified, otherwise reset and try again. */
+ if (OneSession) {
+ dispatchException |= DE_TERMINATE;
+ ErrorF("XDM: too many retransmissions\n");
+ } else {
+ XdmcpDeadSession("too many retransmissions");
+ }
+ return;
+ }
+
+#if defined(IPv6) && defined(AF_INET6)
+ if (state == XDM_COLLECT_QUERY || state == XDM_COLLECT_INDIRECT_QUERY) {
+ /* Try next address */
+ for (mgrAddr = mgrAddr->ai_next; ; mgrAddr = mgrAddr->ai_next) {
+ if (mgrAddr == NULL) {
+ mgrAddr = mgrAddrFirst;
+ }
+ if (mgrAddr->ai_family == AF_INET
+ || mgrAddr->ai_family == AF_INET6)
+ break;
+ }
+#ifndef SIN6_LEN
+ ManagerAddressLen = mgrAddr->ai_addrlen;
+#endif
+ memcpy(&ManagerAddress, mgrAddr->ai_addr, mgrAddr->ai_addrlen);
+ }
+#endif
+
+ switch (state) {
+ case XDM_COLLECT_QUERY:
+ state = XDM_QUERY;
+ break;
+ case XDM_COLLECT_BROADCAST_QUERY:
+ state = XDM_BROADCAST;
+ break;
+#if defined(IPv6) && defined(AF_INET6)
+ case XDM_COLLECT_MULTICAST_QUERY:
+ state = XDM_MULTICAST;
+ break;
+#endif
+ case XDM_COLLECT_INDIRECT_QUERY:
+ state = XDM_INDIRECT;
+ break;
+ case XDM_AWAIT_REQUEST_RESPONSE:
+ state = XDM_START_CONNECTION;
+ break;
+ case XDM_AWAIT_MANAGE_RESPONSE:
+ state = XDM_MANAGE;
+ break;
+ case XDM_AWAIT_ALIVE_RESPONSE:
+ state = XDM_KEEPALIVE;
+ break;
+ default:
+ break;
+ }
+ send_packet();
+}
+
+static void
+restart(void)
+{
+ state = XDM_INIT_STATE;
+ timeOutRtx = 0;
+ send_packet();
+}
+
+int
+XdmcpCheckAuthentication (
+ ARRAY8Ptr Name,
+ ARRAY8Ptr Data,
+ int packet_type)
+{
+ return (XdmcpARRAY8Equal (Name, AuthenticationName) &&
+ (AuthenticationName->length == 0 ||
+ (*AuthenticationFuncs->Validator) (AuthenticationData, Data, packet_type)));
+}
+
+int
+XdmcpAddAuthorization (
+ ARRAY8Ptr name,
+ ARRAY8Ptr data)
+{
+ AddAuthorFunc AddAuth;
+
+ if (AuthenticationFuncs && AuthenticationFuncs->AddAuth)
+ AddAuth = AuthenticationFuncs->AddAuth;
+ else
+ AddAuth = AddAuthorization;
+ return (*AddAuth) ((unsigned short)name->length,
+ (char *)name->data,
+ (unsigned short)data->length,
+ (char *)data->data);
+}
+
+/*
+ * from here to the end of this file are routines private
+ * to the state machine.
+ */
+
+static void
+get_xdmcp_sock(void)
+{
+#ifdef STREAMSCONN
+ struct netconfig *nconf;
+
+ if ((xdmcpSocket = t_open("/dev/udp", O_RDWR, 0)) < 0) {
+ XdmcpWarning("t_open() of /dev/udp failed");
+ return;
+ }
+
+ if( t_bind(xdmcpSocket,NULL,NULL) < 0 ) {
+ XdmcpWarning("UDP socket creation failed");
+ t_error("t_bind(xdmcpSocket) failed" );
+ t_close(xdmcpSocket);
+ return;
+ }
+
+ /*
+ * This part of the code looks contrived. It will actually fit in nicely
+ * when the CLTS part of Xtrans is implemented.
+ */
+
+ if( (nconf=getnetconfigent("udp")) == NULL ) {
+ XdmcpWarning("UDP socket creation failed: getnetconfigent()");
+ t_unbind(xdmcpSocket);
+ t_close(xdmcpSocket);
+ return;
+ }
+
+ if( netdir_options(nconf, ND_SET_BROADCAST, xdmcpSocket, NULL) ) {
+ XdmcpWarning("UDP set broadcast option failed: netdir_options()");
+ freenetconfigent(nconf);
+ t_unbind(xdmcpSocket);
+ t_close(xdmcpSocket);
+ return;
+ }
+
+ freenetconfigent(nconf);
+#else
+ int soopts = 1;
+
+#if defined(IPv6) && defined(AF_INET6)
+ if ((xdmcpSocket6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
+ XdmcpWarning("INET6 UDP socket creation failed");
+#endif
+ if ((xdmcpSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+ XdmcpWarning("UDP socket creation failed");
+#ifdef SO_BROADCAST
+ else if (setsockopt(xdmcpSocket, SOL_SOCKET, SO_BROADCAST, (char *)&soopts,
+ sizeof(soopts)) < 0)
+ XdmcpWarning("UDP set broadcast socket-option failed");
+#endif /* SO_BROADCAST */
+ if (xdmcpSocket >= 0 && xdm_from != NULL) {
+ if (bind(xdmcpSocket, (struct sockaddr *)&FromAddress,
+ FromAddressLen) < 0) {
+ FatalError("Xserver: failed to bind to -from address: %s\n", xdm_from);
+ }
+ }
+#endif /* STREAMSCONN */
+}
+
+static void
+send_query_msg(void)
+{
+ XdmcpHeader header;
+ Bool broadcast = FALSE;
+#if defined(IPv6) && defined(AF_INET6)
+ Bool multicast = FALSE;
+#endif
+ int i;
+ int socketfd = xdmcpSocket;
+
+ header.version = XDM_PROTOCOL_VERSION;
+ switch(state){
+ case XDM_QUERY:
+ header.opcode = (CARD16) QUERY;
+ state = XDM_COLLECT_QUERY;
+ break;
+ case XDM_BROADCAST:
+ header.opcode = (CARD16) BROADCAST_QUERY;
+ state = XDM_COLLECT_BROADCAST_QUERY;
+ broadcast = TRUE;
+ break;
+#if defined(IPv6) && defined(AF_INET6)
+ case XDM_MULTICAST:
+ header.opcode = (CARD16) BROADCAST_QUERY;
+ state = XDM_COLLECT_MULTICAST_QUERY;
+ multicast = TRUE;
+ break;
+#endif
+ case XDM_INDIRECT:
+ header.opcode = (CARD16) INDIRECT_QUERY;
+ state = XDM_COLLECT_INDIRECT_QUERY;
+ break;
+ default:
+ break;
+ }
+ header.length = 1;
+ for (i = 0; i < AuthenticationNames.length; i++)
+ header.length += 2 + AuthenticationNames.data[i].length;
+
+ XdmcpWriteHeader (&buffer, &header);
+ XdmcpWriteARRAYofARRAY8 (&buffer, &AuthenticationNames);
+ if (broadcast)
+ {
+ int i;
+
+ for (i = 0; i < NumBroadcastAddresses; i++)
+ XdmcpFlush (xdmcpSocket, &buffer, (XdmcpNetaddr) &BroadcastAddresses[i],
+ sizeof (struct sockaddr_in));
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ else if (multicast)
+ {
+ struct multicastinfo *mcl;
+ struct addrinfo *ai;
+
+ for (mcl = mcastlist; mcl != NULL; mcl = mcl->next) {
+ for (ai = mcl->ai ; ai != NULL; ai = ai->ai_next) {
+ if (ai->ai_family == AF_INET) {
+ unsigned char hopflag = (unsigned char) mcl->hops;
+ socketfd = xdmcpSocket;
+ setsockopt(socketfd, IPPROTO_IP, IP_MULTICAST_TTL,
+ &hopflag, sizeof(hopflag));
+ } else if (ai->ai_family == AF_INET6) {
+ int hopflag6 = mcl->hops;
+ socketfd = xdmcpSocket6;
+ setsockopt(socketfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
+ &hopflag6, sizeof(hopflag6));
+ } else {
+ continue;
+ }
+ XdmcpFlush (socketfd, &buffer,
+ (XdmcpNetaddr) ai->ai_addr, ai->ai_addrlen);
+ break;
+ }
+ }
+ }
+#endif
+ else
+ {
+#if defined(IPv6) && defined(AF_INET6)
+ if (SOCKADDR_FAMILY(ManagerAddress) == AF_INET6)
+ socketfd = xdmcpSocket6;
+#endif
+ XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &ManagerAddress,
+ ManagerAddressLen);
+ }
+}
+
+static void
+recv_willing_msg(
+ struct sockaddr *from,
+ int fromlen,
+ unsigned length)
+{
+ ARRAY8 authenticationName;
+ ARRAY8 hostname;
+ ARRAY8 status;
+
+ authenticationName.data = 0;
+ hostname.data = 0;
+ status.data = 0;
+ if (XdmcpReadARRAY8 (&buffer, &authenticationName) &&
+ XdmcpReadARRAY8 (&buffer, &hostname) &&
+ XdmcpReadARRAY8 (&buffer, &status))
+ {
+ if (length == 6 + authenticationName.length +
+ hostname.length + status.length)
+ {
+ switch (state)
+ {
+ case XDM_COLLECT_QUERY:
+ XdmcpSelectHost(from, fromlen, &authenticationName);
+ break;
+ case XDM_COLLECT_BROADCAST_QUERY:
+#if defined(IPv6) && defined(AF_INET6)
+ case XDM_COLLECT_MULTICAST_QUERY:
+#endif
+ case XDM_COLLECT_INDIRECT_QUERY:
+ XdmcpAddHost(from, fromlen, &authenticationName, &hostname, &status);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ XdmcpDisposeARRAY8 (&authenticationName);
+ XdmcpDisposeARRAY8 (&hostname);
+ XdmcpDisposeARRAY8 (&status);
+}
+
+static void
+send_request_msg(void)
+{
+ XdmcpHeader header;
+ int length;
+ int i;
+ CARD16 XdmcpConnectionType;
+ ARRAY8 authenticationData;
+ int socketfd = xdmcpSocket;
+
+ switch (SOCKADDR_FAMILY(ManagerAddress))
+ {
+ case AF_INET: XdmcpConnectionType=FamilyInternet; break;
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6: XdmcpConnectionType=FamilyInternet6; break;
+#endif
+ default: XdmcpConnectionType=0xffff; break;
+ }
+
+ header.version = XDM_PROTOCOL_VERSION;
+ header.opcode = (CARD16) REQUEST;
+
+ length = 2; /* display number */
+ length += 1 + 2 * ConnectionTypes.length; /* connection types */
+ length += 1; /* connection addresses */
+ for (i = 0; i < ConnectionAddresses.length; i++)
+ length += 2 + ConnectionAddresses.data[i].length;
+ authenticationData.length = 0;
+ authenticationData.data = 0;
+ if (AuthenticationFuncs)
+ {
+ (*AuthenticationFuncs->Generator) (AuthenticationData,
+ &authenticationData,
+ REQUEST);
+ }
+ length += 2 + AuthenticationName->length; /* authentication name */
+ length += 2 + authenticationData.length; /* authentication data */
+ length += 1; /* authorization names */
+ for (i = 0; i < AuthorizationNames.length; i++)
+ length += 2 + AuthorizationNames.data[i].length;
+ length += 2 + ManufacturerDisplayID.length; /* display ID */
+ header.length = length;
+
+ if (!XdmcpWriteHeader (&buffer, &header))
+ {
+ XdmcpDisposeARRAY8 (&authenticationData);
+ return;
+ }
+ XdmcpWriteCARD16 (&buffer, DisplayNumber);
+ XdmcpWriteCARD8 (&buffer, ConnectionTypes.length);
+
+ /* The connection array is send reordered, so that connections of */
+ /* the same address type as the XDMCP manager connection are send */
+ /* first. This works around a bug in xdm. mario@klebsch.de */
+ for (i = 0; i < (int)ConnectionTypes.length; i++)
+ if (ConnectionTypes.data[i]==XdmcpConnectionType)
+ XdmcpWriteCARD16 (&buffer, ConnectionTypes.data[i]);
+ for (i = 0; i < (int)ConnectionTypes.length; i++)
+ if (ConnectionTypes.data[i]!=XdmcpConnectionType)
+ XdmcpWriteCARD16 (&buffer, ConnectionTypes.data[i]);
+
+ XdmcpWriteCARD8 (&buffer, ConnectionAddresses.length);
+ for (i = 0; i < (int)ConnectionAddresses.length; i++)
+ if ( (i<ConnectionTypes.length) &&
+ (ConnectionTypes.data[i]==XdmcpConnectionType) )
+ XdmcpWriteARRAY8 (&buffer, &ConnectionAddresses.data[i]);
+ for (i = 0; i < (int)ConnectionAddresses.length; i++)
+ if ( (i>=ConnectionTypes.length) ||
+ (ConnectionTypes.data[i]!=XdmcpConnectionType) )
+ XdmcpWriteARRAY8 (&buffer, &ConnectionAddresses.data[i]);
+
+ XdmcpWriteARRAY8 (&buffer, AuthenticationName);
+ XdmcpWriteARRAY8 (&buffer, &authenticationData);
+ XdmcpDisposeARRAY8 (&authenticationData);
+ XdmcpWriteARRAYofARRAY8 (&buffer, &AuthorizationNames);
+ XdmcpWriteARRAY8 (&buffer, &ManufacturerDisplayID);
+#if defined(IPv6) && defined(AF_INET6)
+ if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6)
+ socketfd = xdmcpSocket6;
+#endif
+ if (XdmcpFlush (socketfd, &buffer,
+ (XdmcpNetaddr) &req_sockaddr, req_socklen))
+ state = XDM_AWAIT_REQUEST_RESPONSE;
+}
+
+static void
+recv_accept_msg(unsigned length)
+{
+ CARD32 AcceptSessionID;
+ ARRAY8 AcceptAuthenticationName, AcceptAuthenticationData;
+ ARRAY8 AcceptAuthorizationName, AcceptAuthorizationData;
+
+ if (state != XDM_AWAIT_REQUEST_RESPONSE)
+ return;
+ AcceptAuthenticationName.data = 0;
+ AcceptAuthenticationData.data = 0;
+ AcceptAuthorizationName.data = 0;
+ AcceptAuthorizationData.data = 0;
+ if (XdmcpReadCARD32 (&buffer, &AcceptSessionID) &&
+ XdmcpReadARRAY8 (&buffer, &AcceptAuthenticationName) &&
+ XdmcpReadARRAY8 (&buffer, &AcceptAuthenticationData) &&
+ XdmcpReadARRAY8 (&buffer, &AcceptAuthorizationName) &&
+ XdmcpReadARRAY8 (&buffer, &AcceptAuthorizationData))
+ {
+ if (length == 12 + AcceptAuthenticationName.length +
+ AcceptAuthenticationData.length +
+ AcceptAuthorizationName.length +
+ AcceptAuthorizationData.length)
+ {
+ if (!XdmcpCheckAuthentication (&AcceptAuthenticationName,
+ &AcceptAuthenticationData, ACCEPT))
+ {
+ XdmcpFatal ("Authentication Failure", &AcceptAuthenticationName);
+ }
+ /* permit access control manipulations from this host */
+ AugmentSelf (&req_sockaddr, req_socklen);
+ /* if the authorization specified in the packet fails
+ * to be acceptable, enable the local addresses
+ */
+ if (!XdmcpAddAuthorization (&AcceptAuthorizationName,
+ &AcceptAuthorizationData))
+ {
+ AddLocalHosts ();
+ }
+ SessionID = AcceptSessionID;
+ state = XDM_MANAGE;
+ send_packet();
+ }
+ }
+ XdmcpDisposeARRAY8 (&AcceptAuthenticationName);
+ XdmcpDisposeARRAY8 (&AcceptAuthenticationData);
+ XdmcpDisposeARRAY8 (&AcceptAuthorizationName);
+ XdmcpDisposeARRAY8 (&AcceptAuthorizationData);
+}
+
+static void
+recv_decline_msg(unsigned length)
+{
+ ARRAY8 status, DeclineAuthenticationName, DeclineAuthenticationData;
+
+ status.data = 0;
+ DeclineAuthenticationName.data = 0;
+ DeclineAuthenticationData.data = 0;
+ if (XdmcpReadARRAY8 (&buffer, &status) &&
+ XdmcpReadARRAY8 (&buffer, &DeclineAuthenticationName) &&
+ XdmcpReadARRAY8 (&buffer, &DeclineAuthenticationData))
+ {
+ if (length == 6 + status.length +
+ DeclineAuthenticationName.length +
+ DeclineAuthenticationData.length &&
+ XdmcpCheckAuthentication (&DeclineAuthenticationName,
+ &DeclineAuthenticationData, DECLINE))
+ {
+ XdmcpFatal ("Session declined", &status);
+ }
+ }
+ XdmcpDisposeARRAY8 (&status);
+ XdmcpDisposeARRAY8 (&DeclineAuthenticationName);
+ XdmcpDisposeARRAY8 (&DeclineAuthenticationData);
+}
+
+static void
+send_manage_msg(void)
+{
+ XdmcpHeader header;
+ int socketfd = xdmcpSocket;
+
+ header.version = XDM_PROTOCOL_VERSION;
+ header.opcode = (CARD16) MANAGE;
+ header.length = 8 + DisplayClass.length;
+
+ if (!XdmcpWriteHeader (&buffer, &header))
+ return;
+ XdmcpWriteCARD32 (&buffer, SessionID);
+ XdmcpWriteCARD16 (&buffer, DisplayNumber);
+ XdmcpWriteARRAY8 (&buffer, &DisplayClass);
+ state = XDM_AWAIT_MANAGE_RESPONSE;
+#if defined(IPv6) && defined(AF_INET6)
+ if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6)
+ socketfd = xdmcpSocket6;
+#endif
+ XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen);
+}
+
+static void
+recv_refuse_msg(unsigned length)
+{
+ CARD32 RefusedSessionID;
+
+ if (state != XDM_AWAIT_MANAGE_RESPONSE)
+ return;
+ if (length != 4)
+ return;
+ if (XdmcpReadCARD32 (&buffer, &RefusedSessionID))
+ {
+ if (RefusedSessionID == SessionID)
+ {
+ state = XDM_START_CONNECTION;
+ send_packet();
+ }
+ }
+}
+
+static void
+recv_failed_msg(unsigned length)
+{
+ CARD32 FailedSessionID;
+ ARRAY8 status;
+
+ if (state != XDM_AWAIT_MANAGE_RESPONSE)
+ return;
+ status.data = 0;
+ if (XdmcpReadCARD32 (&buffer, &FailedSessionID) &&
+ XdmcpReadARRAY8 (&buffer, &status))
+ {
+ if (length == 6 + status.length &&
+ SessionID == FailedSessionID)
+ {
+ XdmcpFatal ("Session failed", &status);
+ }
+ }
+ XdmcpDisposeARRAY8 (&status);
+}
+
+static void
+send_keepalive_msg(void)
+{
+ XdmcpHeader header;
+ int socketfd = xdmcpSocket;
+
+ header.version = XDM_PROTOCOL_VERSION;
+ header.opcode = (CARD16) KEEPALIVE;
+ header.length = 6;
+
+ XdmcpWriteHeader (&buffer, &header);
+ XdmcpWriteCARD16 (&buffer, DisplayNumber);
+ XdmcpWriteCARD32 (&buffer, SessionID);
+
+ state = XDM_AWAIT_ALIVE_RESPONSE;
+#if defined(IPv6) && defined(AF_INET6)
+ if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6)
+ socketfd = xdmcpSocket6;
+#endif
+ XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen);
+}
+
+static void
+recv_alive_msg (unsigned length)
+{
+ CARD8 SessionRunning;
+ CARD32 AliveSessionID;
+
+ if (state != XDM_AWAIT_ALIVE_RESPONSE)
+ return;
+ if (length != 5)
+ return;
+ if (XdmcpReadCARD8 (&buffer, &SessionRunning) &&
+ XdmcpReadCARD32 (&buffer, &AliveSessionID))
+ {
+ if (SessionRunning && AliveSessionID == SessionID)
+ {
+ /* backoff dormancy period */
+ state = XDM_RUN_SESSION;
+ if ((GetTimeInMillis() - lastDeviceEventTime.milliseconds) >
+ keepaliveDormancy * 1000)
+ {
+ keepaliveDormancy <<= 1;
+ if (keepaliveDormancy > XDM_MAX_DORMANCY)
+ keepaliveDormancy = XDM_MAX_DORMANCY;
+ }
+ timeOutTime = GetTimeInMillis() + keepaliveDormancy * 1000;
+ }
+ else
+ {
+ XdmcpDeadSession ("Alive response indicates session dead");
+ }
+ }
+}
+
+static void
+XdmcpFatal (
+ char *type,
+ ARRAY8Ptr status)
+{
+ FatalError ("XDMCP fatal error: %s %*.*s\n", type,
+ status->length, status->length, status->data);
+}
+
+static void
+XdmcpWarning(char *str)
+{
+ ErrorF("XDMCP warning: %s\n", str);
+}
+
+static void
+get_addr_by_name(
+ char * argtype,
+ char * namestr,
+ int port,
+ int socktype,
+ SOCKADDR_TYPE *addr,
+ SOCKLEN_TYPE *addrlen
+#if defined(IPv6) && defined(AF_INET6)
+ ,
+ struct addrinfo **aip,
+ struct addrinfo **aifirstp
+#endif
+ )
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct addrinfo *ai;
+ struct addrinfo hints;
+ char portstr[6];
+ char *pport = portstr;
+ int gaierr;
+
+ bzero(&hints, sizeof(hints));
+ hints.ai_socktype = socktype;
+
+ if (port == 0) {
+ pport = NULL;
+ } else if (port > 0 && port < 65535) {
+ sprintf(portstr, "%d", port);
+ } else {
+ FatalError("Xserver: port out of range: %d\n", port);
+ }
+
+ if (*aifirstp != NULL) {
+ freeaddrinfo(*aifirstp);
+ *aifirstp = NULL;
+ }
+
+ if ((gaierr = getaddrinfo(namestr, pport, &hints, aifirstp)) == 0) {
+ for (ai = *aifirstp; ai != NULL; ai = ai->ai_next) {
+ if (ai->ai_family == AF_INET || ai->ai_family == AF_INET6)
+ break;
+ }
+ if ((ai == NULL) || (ai->ai_addrlen > sizeof(SOCKADDR_TYPE))) {
+ FatalError ("Xserver: %s host %s not on supported network type\n",
+ argtype, namestr);
+ } else {
+ *aip = ai;
+ *addrlen = ai->ai_addrlen;
+ memcpy(addr, ai->ai_addr, ai->ai_addrlen);
+ }
+ } else {
+ FatalError("Xserver: %s: %s %s\n", gai_strerror(gaierr), argtype, namestr);
+ }
+#else
+ struct hostent *hep;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+#if defined(WIN32) && (defined(TCPCONN) || defined(DNETCONN))
+ _XSERVTransWSAStartup();
+#endif
+ if (!(hep = _XGethostbyname(namestr, hparams)))
+ {
+ FatalError("Xserver: %s unknown host: %s\n", argtype, namestr);
+ }
+ if (hep->h_length == sizeof (struct in_addr))
+ {
+ memmove(&addr->sin_addr, hep->h_addr, hep->h_length);
+ *addrlen = sizeof(struct sockaddr_in);
+ addr->sin_family = AF_INET;
+ addr->sin_port = htons (port);
+ }
+ else
+ {
+ FatalError("Xserver: %s host on strange network %s\n", argtype, namestr);
+ }
+#endif
+}
+
+static void
+get_manager_by_name(
+ int argc,
+ char **argv,
+ int i)
+{
+
+ if ((i + 1) == argc)
+ {
+ FatalError("Xserver: missing %s host name in command line\n", argv[i]);
+ }
+
+ get_addr_by_name(argv[i], argv[i+1], xdm_udp_port, SOCK_DGRAM,
+ &ManagerAddress, &ManagerAddressLen
+#if defined(IPv6) && defined(AF_INET6)
+ , &mgrAddr, &mgrAddrFirst
+#endif
+ );
+}
+
+
+static void
+get_fromaddr_by_name(
+ int argc,
+ char **argv,
+ int i)
+{
+#if defined(IPv6) && defined(AF_INET6)
+ struct addrinfo *ai = NULL;
+ struct addrinfo *aifirst = NULL;
+#endif
+ if (i == argc)
+ {
+ FatalError("Xserver: missing -from host name in command line\n");
+ }
+ get_addr_by_name("-from", argv[i], 0, 0, &FromAddress, &FromAddressLen
+#if defined(IPv6) && defined(AF_INET6)
+ , &ai, &aifirst
+#endif
+ );
+ xdm_from = argv[i];
+}
+
+
+#if defined(IPv6) && defined(AF_INET6)
+static int
+get_mcast_options(argc, argv, i)
+ int argc, i;
+ char **argv;
+{
+ char *address = XDM_DEFAULT_MCAST_ADDR6;
+ int hopcount = 1;
+ struct addrinfo hints;
+ char portstr[6];
+ int gaierr;
+ struct addrinfo *ai, *firstai;
+
+ if ((i < argc) && (argv[i][0] != '-') && (argv[i][0] != '+')) {
+ address = argv[i++];
+ if ((i < argc) && (argv[i][0] != '-') && (argv[i][0] != '+')) {
+ hopcount = strtol(argv[i++], NULL, 10);
+ if ((hopcount < 1) || (hopcount > 255)) {
+ FatalError("Xserver: multicast hop count out of range: %d\n",
+ hopcount);
+ }
+ }
+ }
+
+ if (xdm_udp_port > 0 && xdm_udp_port < 65535) {
+ sprintf(portstr, "%d", xdm_udp_port);
+ } else {
+ FatalError("Xserver: port out of range: %d\n", xdm_udp_port);
+ }
+ bzero(&hints, sizeof(hints));
+ hints.ai_socktype = SOCK_DGRAM;
+
+ if ((gaierr = getaddrinfo(address, portstr, &hints, &firstai)) == 0) {
+ for (ai = firstai; ai != NULL; ai = ai->ai_next) {
+ if (((ai->ai_family == AF_INET) &&
+ IN_MULTICAST(((struct sockaddr_in *) ai->ai_addr)
+ ->sin_addr.s_addr))
+ || ((ai->ai_family == AF_INET6) &&
+ IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6 *) ai->ai_addr)
+ ->sin6_addr)))
+ break;
+ }
+ if (ai == NULL) {
+ FatalError ("Xserver: address not supported multicast type %s\n",
+ address);
+ } else {
+ struct multicastinfo *mcastinfo, *mcl;
+
+ mcastinfo = malloc(sizeof(struct multicastinfo));
+ mcastinfo->next = NULL;
+ mcastinfo->ai = firstai;
+ mcastinfo->hops = hopcount;
+
+ if (mcastlist == NULL) {
+ mcastlist = mcastinfo;
+ } else {
+ for (mcl = mcastlist; mcl->next != NULL; mcl = mcl->next) {
+ /* Do nothing - just find end of list */
+ }
+ mcl->next = mcastinfo;
+ }
+ }
+ } else {
+ FatalError("Xserver: %s: %s\n", gai_strerror(gaierr), address);
+ }
+ return i;
+}
+#endif
+
+#else
+static int xdmcp_non_empty; /* avoid complaint by ranlib */
+#endif /* XDMCP */
diff --git a/nx-X11/programs/Xserver/os/xprintf.c b/nx-X11/programs/Xserver/os/xprintf.c
new file mode 100644
index 000000000..07eaa1f58
--- /dev/null
+++ b/nx-X11/programs/Xserver/os/xprintf.c
@@ -0,0 +1,104 @@
+/*
+ * printf routines which xalloc their buffer
+ */
+/*
+ * Copyright (c) 2004 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xos.h>
+#include "os.h"
+#include <stdarg.h>
+#include <stdio.h>
+
+#ifndef va_copy
+# ifdef __va_copy
+# define va_copy __va_copy
+# else
+# error "no working va_copy was found"
+# endif
+#endif
+
+char *
+Xvprintf(const char *format, va_list va)
+{
+ char *ret;
+ int size;
+ va_list va2;
+
+ va_copy(va2, va);
+ size = vsnprintf(NULL, 0, format, va2);
+ va_end(va2);
+
+ ret = (char *)Xalloc(size + 1);
+ if (ret == NULL)
+ return NULL;
+
+ vsnprintf(ret, size + 1, format, va);
+ ret[size] = 0;
+ return ret;
+}
+
+char *Xprintf(const char *format, ...)
+{
+ char *ret;
+ va_list va;
+ va_start(va, format);
+ ret = Xvprintf(format, va);
+ va_end(va);
+ return ret;
+}
+
+char *
+XNFvprintf(const char *format, va_list va)
+{
+ char *ret;
+ int size;
+ va_list va2;
+
+ va_copy(va2, va);
+ size = vsnprintf(NULL, 0, format, va2);
+ va_end(va2);
+
+ ret = (char *)XNFalloc(size + 1);
+ if (ret == NULL)
+ return NULL;
+
+ vsnprintf(ret, size + 1, format, va);
+ ret[size] = 0;
+ return ret;
+}
+
+char *XNFprintf(const char *format, ...)
+{
+ char *ret;
+ va_list va;
+ va_start(va, format);
+ ret = XNFvprintf(format, va);
+ va_end(va);
+ return ret;
+}
diff --git a/nx-X11/programs/Xserver/randr/Imakefile b/nx-X11/programs/Xserver/randr/Imakefile
new file mode 100644
index 000000000..73b0dfbba
--- /dev/null
+++ b/nx-X11/programs/Xserver/randr/Imakefile
@@ -0,0 +1,18 @@
+XCOMM $XFree86: xc/programs/Xserver/randr/Imakefile,v 1.1 2001/05/23 03:29:44 keithp Exp $
+#include <Server.tmpl>
+
+ SRCS = randr.c mirandr.c
+
+ OBJS = randr.o mirandr.o
+
+ INCLUDES = -I../include -I../mi -I../../../include/fonts \
+ -I../fb -I../hw/kdrive -I$(EXTINCSRC) -I$(XINCLUDESRC) \
+ -I$(FONTINCSRC) -I../render
+ LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+
+NormalLibraryTarget(randr,$(OBJS))
+NormalLibraryObjectRule()
+LintLibraryTarget(randr,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/randr/mirandr.c b/nx-X11/programs/Xserver/randr/mirandr.c
new file mode 100644
index 000000000..b1e19a746
--- /dev/null
+++ b/nx-X11/programs/Xserver/randr/mirandr.c
@@ -0,0 +1,102 @@
+/*
+ * $XFree86: xc/programs/Xserver/randr/mirandr.c,v 1.5 2001/06/04 09:45:40 keithp Exp $
+ *
+ * Copyright © 2000, Compaq Computer Corporation,
+ * Copyright © 2002, Hewlett Packard, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Compaq or HP not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. HP makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL HP
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Jim Gettys, HP Labs, Hewlett-Packard, Inc.
+ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "scrnintstr.h"
+#include "mi.h"
+#include <X11/extensions/randr.h>
+#include "randrstr.h"
+#include <stdio.h>
+
+/*
+ * This function assumes that only a single depth can be
+ * displayed at a time, but that all visuals of that depth
+ * can be displayed simultaneously. It further assumes that
+ * only a single size is available. Hardware providing
+ * additional capabilties should use different code.
+ * XXX what to do here....
+ */
+
+Bool
+miRRGetInfo (ScreenPtr pScreen, Rotation *rotations)
+{
+ int i;
+ Bool setConfig = FALSE;
+
+ *rotations = RR_Rotate_0;
+ for (i = 0; i < pScreen->numDepths; i++)
+ {
+ if (pScreen->allowedDepths[i].numVids)
+ {
+ RRScreenSizePtr pSize;
+
+ pSize = RRRegisterSize (pScreen,
+ pScreen->width,
+ pScreen->height,
+ pScreen->mmWidth,
+ pScreen->mmHeight);
+ if (!pSize)
+ return FALSE;
+ if (!setConfig)
+ {
+ RRSetCurrentConfig (pScreen, RR_Rotate_0, 0, pSize);
+ setConfig = TRUE;
+ }
+ }
+ }
+ return TRUE;
+}
+
+/*
+ * Any hardware that can actually change anything will need something
+ * different here
+ */
+Bool
+miRRSetConfig (ScreenPtr pScreen,
+ Rotation rotation,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ return TRUE;
+}
+
+
+Bool
+miRandRInit (ScreenPtr pScreen)
+{
+ rrScrPrivPtr rp;
+
+ if (!RRScreenInit (pScreen))
+ return FALSE;
+ rp = rrGetScrPriv(pScreen);
+ rp->rrGetInfo = miRRGetInfo;
+ rp->rrSetConfig = miRRSetConfig;
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/randr/randr.c b/nx-X11/programs/Xserver/randr/randr.c
new file mode 100644
index 000000000..3911a3498
--- /dev/null
+++ b/nx-X11/programs/Xserver/randr/randr.c
@@ -0,0 +1,1319 @@
+/*
+ * $XFree86: xc/programs/Xserver/randr/randr.c,v 1.21tsi Exp $
+ *
+ * Copyright © 2000, Compaq Computer Corporation,
+ * Copyright © 2002, Hewlett Packard, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Compaq or HP not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. HP makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL HP
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Jim Gettys, HP Labs, Hewlett-Packard, Inc.
+ */
+
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "extnsionst.h"
+#include "servermd.h"
+#include <X11/extensions/randr.h>
+#include <X11/extensions/randrproto.h>
+#include "randrstr.h"
+#ifdef RENDER
+#include <X11/extensions/render.h> /* we share subpixel order information */
+#include "picturestr.h"
+#endif
+#include <X11/Xfuncproto.h>
+#ifdef EXTMODULE
+#include "xf86_ansic.h"
+#endif
+
+/* From render.h */
+#ifndef SubPixelUnknown
+#define SubPixelUnknown 0
+#endif
+
+#define RR_VALIDATE
+int RRGeneration;
+int RRNScreens;
+
+static int ProcRRQueryVersion (ClientPtr pClient);
+static int ProcRRDispatch (ClientPtr pClient);
+static int SProcRRDispatch (ClientPtr pClient);
+static int SProcRRQueryVersion (ClientPtr pClient);
+
+#define wrap(priv,real,mem,func) {\
+ priv->mem = real->mem; \
+ real->mem = func; \
+}
+
+#define unwrap(priv,real,mem) {\
+ real->mem = priv->mem; \
+}
+
+#if 0
+static CARD8 RRReqCode;
+static int RRErrBase;
+#endif
+static int RREventBase;
+static RESTYPE ClientType, EventType; /* resource types for event masks */
+static int RRClientPrivateIndex;
+
+typedef struct _RRTimes {
+ TimeStamp setTime;
+ TimeStamp configTime;
+} RRTimesRec, *RRTimesPtr;
+
+typedef struct _RRClient {
+ int major_version;
+ int minor_version;
+/* RRTimesRec times[0]; */
+} RRClientRec, *RRClientPtr;
+
+/*
+ * each window has a list of clients requesting
+ * RRNotify events. Each client has a resource
+ * for each window it selects RRNotify input for,
+ * this resource is used to delete the RRNotifyRec
+ * entry from the per-window queue.
+ */
+
+typedef struct _RREvent *RREventPtr;
+
+typedef struct _RREvent {
+ RREventPtr next;
+ ClientPtr client;
+ WindowPtr window;
+ XID clientResource;
+ int mask;
+} RREventRec;
+
+int rrPrivIndex = -1;
+
+#define GetRRClient(pClient) ((RRClientPtr) (pClient)->devPrivates[RRClientPrivateIndex].ptr)
+#define rrClientPriv(pClient) RRClientPtr pRRClient = GetRRClient(pClient)
+
+static Bool
+RRClientKnowsRates (ClientPtr pClient)
+{
+ rrClientPriv(pClient);
+
+ return (pRRClient->major_version > 1 ||
+ (pRRClient->major_version == 1 && pRRClient->minor_version >= 1));
+}
+
+static void
+RRClientCallback (CallbackListPtr *list,
+ pointer closure,
+ pointer data)
+{
+ NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
+ ClientPtr pClient = clientinfo->client;
+ rrClientPriv(pClient);
+ RRTimesPtr pTimes = (RRTimesPtr) (pRRClient + 1);
+ int i;
+
+ pRRClient->major_version = 0;
+ pRRClient->minor_version = 0;
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ rrScrPriv(pScreen);
+
+ if (pScrPriv)
+ {
+ pTimes[i].setTime = pScrPriv->lastSetTime;
+ pTimes[i].configTime = pScrPriv->lastConfigTime;
+ }
+ }
+}
+
+static void
+RRResetProc (ExtensionEntry *extEntry)
+{
+}
+
+static Bool
+RRCloseScreen (int i, ScreenPtr pScreen)
+{
+ rrScrPriv(pScreen);
+
+ unwrap (pScrPriv, pScreen, CloseScreen);
+ if (pScrPriv->pSizes)
+ xfree (pScrPriv->pSizes);
+ xfree (pScrPriv);
+ RRNScreens -= 1; /* ok, one fewer screen with RandR running */
+ return (*pScreen->CloseScreen) (i, pScreen);
+}
+
+static void
+SRRScreenChangeNotifyEvent(xRRScreenChangeNotifyEvent *from,
+ xRRScreenChangeNotifyEvent *to)
+{
+ to->type = from->type;
+ to->rotation = from->rotation;
+ cpswaps(from->sequenceNumber, to->sequenceNumber);
+ cpswapl(from->timestamp, to->timestamp);
+ cpswapl(from->configTimestamp, to->configTimestamp);
+ cpswapl(from->root, to->root);
+ cpswapl(from->window, to->window);
+ cpswaps(from->sizeID, to->sizeID);
+ cpswaps(from->widthInPixels, to->widthInPixels);
+ cpswaps(from->heightInPixels, to->heightInPixels);
+ cpswaps(from->widthInMillimeters, to->widthInMillimeters);
+ cpswaps(from->heightInMillimeters, to->heightInMillimeters);
+ cpswaps(from->subpixelOrder, to->subpixelOrder);
+}
+
+Bool RRScreenInit(ScreenPtr pScreen)
+{
+ rrScrPrivPtr pScrPriv;
+
+ if (RRGeneration != serverGeneration)
+ {
+ if ((rrPrivIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+ RRGeneration = serverGeneration;
+ }
+
+ pScrPriv = (rrScrPrivPtr) xalloc (sizeof (rrScrPrivRec));
+ if (!pScrPriv)
+ return FALSE;
+
+ SetRRScreen(pScreen, pScrPriv);
+
+ /*
+ * Calling function best set these function vectors
+ */
+ pScrPriv->rrSetConfig = 0;
+ pScrPriv->rrGetInfo = 0;
+ /*
+ * This value doesn't really matter -- any client must call
+ * GetScreenInfo before reading it which will automatically update
+ * the time
+ */
+ pScrPriv->lastSetTime = currentTime;
+ pScrPriv->lastConfigTime = currentTime;
+
+ wrap (pScrPriv, pScreen, CloseScreen, RRCloseScreen);
+
+ pScrPriv->rotations = RR_Rotate_0;
+
+ pScrPriv->nSizes = 0;
+ pScrPriv->nSizesInUse = 0;
+ pScrPriv->pSizes = 0;
+
+ pScrPriv->rotation = RR_Rotate_0;
+ pScrPriv->size = -1;
+
+ RRNScreens += 1; /* keep count of screens that implement randr */
+ return TRUE;
+}
+
+/*ARGSUSED*/
+static int
+RRFreeClient (pointer data, XID id)
+{
+ RREventPtr pRREvent;
+ WindowPtr pWin;
+ RREventPtr *pHead, pCur, pPrev;
+
+ pRREvent = (RREventPtr) data;
+ pWin = pRREvent->window;
+ pHead = (RREventPtr *) LookupIDByType(pWin->drawable.id, EventType);
+ if (pHead) {
+ pPrev = 0;
+ for (pCur = *pHead; pCur && pCur != pRREvent; pCur=pCur->next)
+ pPrev = pCur;
+ if (pCur)
+ {
+ if (pPrev)
+ pPrev->next = pRREvent->next;
+ else
+ *pHead = pRREvent->next;
+ }
+ }
+ xfree ((pointer) pRREvent);
+ return 1;
+}
+
+/*ARGSUSED*/
+static int
+RRFreeEvents (pointer data, XID id)
+{
+ RREventPtr *pHead, pCur, pNext;
+
+ pHead = (RREventPtr *) data;
+ for (pCur = *pHead; pCur; pCur = pNext) {
+ pNext = pCur->next;
+ FreeResource (pCur->clientResource, ClientType);
+ xfree ((pointer) pCur);
+ }
+ xfree ((pointer) pHead);
+ return 1;
+}
+
+void
+RRExtensionInit (void)
+{
+ ExtensionEntry *extEntry;
+
+ if (RRNScreens == 0) return;
+
+ RRClientPrivateIndex = AllocateClientPrivateIndex ();
+ if (!AllocateClientPrivate (RRClientPrivateIndex,
+ sizeof (RRClientRec) +
+ screenInfo.numScreens * sizeof (RRTimesRec)))
+ return;
+ if (!AddCallback (&ClientStateCallback, RRClientCallback, 0))
+ return;
+
+ ClientType = CreateNewResourceType(RRFreeClient);
+ if (!ClientType)
+ return;
+ EventType = CreateNewResourceType(RRFreeEvents);
+ if (!EventType)
+ return;
+ extEntry = AddExtension (RANDR_NAME, RRNumberEvents, RRNumberErrors,
+ ProcRRDispatch, SProcRRDispatch,
+ RRResetProc, StandardMinorOpcode);
+ if (!extEntry)
+ return;
+#if 0
+ RRReqCode = (CARD8) extEntry->base;
+ RRErrBase = extEntry->errorBase;
+#endif
+ RREventBase = extEntry->eventBase;
+ EventSwapVector[RREventBase + RRScreenChangeNotify] = (EventSwapPtr)
+ SRRScreenChangeNotifyEvent;
+
+ return;
+}
+
+static int
+TellChanged (WindowPtr pWin, pointer value)
+{
+ RREventPtr *pHead, pRREvent;
+ ClientPtr client;
+ xRRScreenChangeNotifyEvent se;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ rrScrPriv(pScreen);
+ RRScreenSizePtr pSize;
+ WindowPtr pRoot = WindowTable[pScreen->myNum];
+
+ pHead = (RREventPtr *) LookupIDByType (pWin->drawable.id, EventType);
+ if (!pHead)
+ return WT_WALKCHILDREN;
+
+ se.type = RRScreenChangeNotify + RREventBase;
+ se.rotation = (CARD8) pScrPriv->rotation;
+ se.timestamp = pScrPriv->lastSetTime.milliseconds;
+ se.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
+ se.root = pRoot->drawable.id;
+ se.window = pWin->drawable.id;
+#ifdef RENDER
+ se.subpixelOrder = PictureGetSubpixelOrder (pScreen);
+#else
+ se.subpixelOrder = SubPixelUnknown;
+#endif
+ if (pScrPriv->size >= 0)
+ {
+ pSize = &pScrPriv->pSizes[pScrPriv->size];
+ se.sizeID = pSize->id;
+ se.widthInPixels = pSize->width;
+ se.heightInPixels = pSize->height;
+ se.widthInMillimeters = pSize->mmWidth;
+ se.heightInMillimeters = pSize->mmHeight;
+ }
+ else
+ {
+ /*
+ * This "shouldn't happen", but a broken DDX can
+ * forget to set the current configuration on GetInfo
+ */
+ se.sizeID = 0xffff;
+ se.widthInPixels = 0;
+ se.heightInPixels = 0;
+ se.widthInMillimeters = 0;
+ se.heightInMillimeters = 0;
+ }
+ for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next)
+ {
+ client = pRREvent->client;
+ if (client == serverClient || client->clientGone)
+ continue;
+ se.sequenceNumber = client->sequence;
+ if(pRREvent->mask & RRScreenChangeNotifyMask)
+ WriteEventsToClient (client, 1, (xEvent *) &se);
+ }
+ return WT_WALKCHILDREN;
+}
+
+static Bool
+RRGetInfo (ScreenPtr pScreen)
+{
+ rrScrPriv (pScreen);
+ int i, j, k, l;
+ Bool changed;
+ Rotation rotations;
+ RRScreenSizePtr pSize;
+ RRScreenRatePtr pRate;
+
+ for (i = 0; i < pScrPriv->nSizes; i++)
+ {
+ pSize = &pScrPriv->pSizes[i];
+ pSize->oldReferenced = pSize->referenced;
+ pSize->referenced = FALSE;
+ for (k = 0; k < pSize->nRates; k++)
+ {
+ pRate = &pSize->pRates[k];
+ pRate->oldReferenced = pRate->referenced;
+ pRate->referenced = FALSE;
+ }
+ }
+ if (!(*pScrPriv->rrGetInfo) (pScreen, &rotations))
+ return FALSE;
+
+ changed = FALSE;
+
+ /*
+ * Check whether anything changed and simultaneously generate
+ * the protocol id values for the objects
+ */
+ if (rotations != pScrPriv->rotations)
+ {
+ pScrPriv->rotations = rotations;
+ changed = TRUE;
+ }
+
+ j = 0;
+ for (i = 0; i < pScrPriv->nSizes; i++)
+ {
+ pSize = &pScrPriv->pSizes[i];
+ if (pSize->oldReferenced != pSize->referenced)
+ changed = TRUE;
+ if (pSize->referenced)
+ pSize->id = j++;
+ l = 0;
+ for (k = 0; k < pSize->nRates; k++)
+ {
+ pRate = &pSize->pRates[k];
+ if (pRate->oldReferenced != pRate->referenced)
+ changed = TRUE;
+ if (pRate->referenced)
+ l++;
+ }
+ pSize->nRatesInUse = l;
+ }
+ pScrPriv->nSizesInUse = j;
+ if (changed)
+ {
+ UpdateCurrentTime ();
+ pScrPriv->lastConfigTime = currentTime;
+ WalkTree (pScreen, TellChanged, (pointer) pScreen);
+ }
+ return TRUE;
+}
+
+static void
+RRSendConfigNotify (ScreenPtr pScreen)
+{
+ WindowPtr pWin = WindowTable[pScreen->myNum];
+ xEvent event;
+
+ event.u.u.type = ConfigureNotify;
+ event.u.configureNotify.window = pWin->drawable.id;
+ event.u.configureNotify.aboveSibling = None;
+ event.u.configureNotify.x = 0;
+ event.u.configureNotify.y = 0;
+
+ /* XXX xinerama stuff ? */
+
+ event.u.configureNotify.width = pWin->drawable.width;
+ event.u.configureNotify.height = pWin->drawable.height;
+ event.u.configureNotify.borderWidth = wBorderWidth (pWin);
+ event.u.configureNotify.override = pWin->overrideRedirect;
+ DeliverEvents(pWin, &event, 1, NullWindow);
+}
+
+static int
+ProcRRQueryVersion (ClientPtr client)
+{
+ xRRQueryVersionReply rep;
+ register int n;
+ REQUEST(xRRQueryVersionReq);
+ rrClientPriv(client);
+
+ REQUEST_SIZE_MATCH(xRRQueryVersionReq);
+ pRRClient->major_version = stuff->majorVersion;
+ pRRClient->minor_version = stuff->minorVersion;
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = RANDR_MAJOR;
+ rep.minorVersion = RANDR_MINOR;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.majorVersion, n);
+ swapl(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof(xRRQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+
+extern char *ConnectionInfo;
+
+static int padlength[4] = {0, 3, 2, 1};
+
+static void
+RREditConnectionInfo (ScreenPtr pScreen)
+{
+ xConnSetup *connSetup;
+ char *vendor;
+ xPixmapFormat *formats;
+ xWindowRoot *root;
+ xDepth *depth;
+ xVisualType *visual;
+ int screen = 0;
+ int d;
+
+ connSetup = (xConnSetup *) ConnectionInfo;
+ vendor = (char *) connSetup + sizeof (xConnSetup);
+ formats = (xPixmapFormat *) ((char *) vendor +
+ connSetup->nbytesVendor +
+ padlength[connSetup->nbytesVendor & 3]);
+ root = (xWindowRoot *) ((char *) formats +
+ sizeof (xPixmapFormat) * screenInfo.numPixmapFormats);
+ while (screen != pScreen->myNum)
+ {
+ depth = (xDepth *) ((char *) root +
+ sizeof (xWindowRoot));
+ for (d = 0; d < root->nDepths; d++)
+ {
+ visual = (xVisualType *) ((char *) depth +
+ sizeof (xDepth));
+ depth = (xDepth *) ((char *) visual +
+ depth->nVisuals * sizeof (xVisualType));
+ }
+ root = (xWindowRoot *) ((char *) depth);
+ screen++;
+ }
+ root->pixWidth = pScreen->width;
+ root->pixHeight = pScreen->height;
+ root->mmWidth = pScreen->mmWidth;
+ root->mmHeight = pScreen->mmHeight;
+}
+
+static int
+ProcRRGetScreenInfo (ClientPtr client)
+{
+ REQUEST(xRRGetScreenInfoReq);
+ xRRGetScreenInfoReply rep;
+ WindowPtr pWin;
+ int n;
+ ScreenPtr pScreen;
+ rrScrPrivPtr pScrPriv;
+ CARD8 *extra;
+ unsigned long extraLen;
+
+ REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityReadAccess);
+
+ if (!pWin)
+ return BadWindow;
+
+ pScreen = pWin->drawable.pScreen;
+ pScrPriv = rrGetScrPriv(pScreen);
+ rep.pad = 0;
+ if (!pScrPriv)
+ {
+ rep.type = X_Reply;
+ rep.setOfRotations = RR_Rotate_0;;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
+ rep.timestamp = currentTime.milliseconds;
+ rep.configTimestamp = currentTime.milliseconds;
+ rep.nSizes = 0;
+ rep.sizeID = 0;
+ rep.rotation = RR_Rotate_0;
+ rep.rate = 0;
+ rep.nrateEnts = 0;
+ extra = 0;
+ extraLen = 0;
+ }
+ else
+ {
+ int i, j;
+ xScreenSizes *size;
+ CARD16 *rates;
+ CARD8 *data8;
+ Bool has_rate = RRClientKnowsRates (client);
+
+ RRGetInfo (pScreen);
+
+ rep.type = X_Reply;
+ rep.setOfRotations = pScrPriv->rotations;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
+ rep.timestamp = pScrPriv->lastSetTime.milliseconds;
+ rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
+ rep.rotation = pScrPriv->rotation;
+ rep.nSizes = pScrPriv->nSizesInUse;
+ rep.rate = pScrPriv->rate;
+ rep.nrateEnts = 0;
+ if (has_rate)
+ {
+ for (i = 0; i < pScrPriv->nSizes; i++)
+ {
+ RRScreenSizePtr pSize = &pScrPriv->pSizes[i];
+ if (pSize->referenced)
+ {
+ rep.nrateEnts += (1 + pSize->nRatesInUse);
+ }
+ }
+ }
+
+ if (pScrPriv->size >= 0)
+ rep.sizeID = pScrPriv->pSizes[pScrPriv->size].id;
+ else
+ return BadImplementation;
+
+ extraLen = (rep.nSizes * sizeof (xScreenSizes) +
+ rep.nrateEnts * sizeof (CARD16));
+
+ extra = (CARD8 *) xalloc (extraLen);
+ if (!extra)
+ return BadAlloc;
+ /*
+ * First comes the size information
+ */
+ size = (xScreenSizes *) extra;
+ rates = (CARD16 *) (size + rep.nSizes);
+ for (i = 0; i < pScrPriv->nSizes; i++)
+ {
+ RRScreenSizePtr pSize = &pScrPriv->pSizes[i];
+ if (pSize->referenced)
+ {
+ size->widthInPixels = pSize->width;
+ size->heightInPixels = pSize->height;
+ size->widthInMillimeters = pSize->mmWidth;
+ size->heightInMillimeters = pSize->mmHeight;
+ if (client->swapped)
+ {
+ swaps (&size->widthInPixels, n);
+ swaps (&size->heightInPixels, n);
+ swaps (&size->widthInMillimeters, n);
+ swaps (&size->heightInMillimeters, n);
+ }
+ size++;
+ if (has_rate)
+ {
+ *rates = pSize->nRatesInUse;
+ if (client->swapped)
+ {
+ swaps (rates, n);
+ }
+ rates++;
+ for (j = 0; j < pSize->nRates; j++)
+ {
+ RRScreenRatePtr pRate = &pSize->pRates[j];
+ if (pRate->referenced)
+ {
+ *rates = pRate->rate;
+ if (client->swapped)
+ {
+ swaps (rates, n);
+ }
+ rates++;
+ }
+ }
+ }
+ }
+ }
+ data8 = (CARD8 *) rates;
+
+ if (data8 - (CARD8 *) extra != extraLen)
+ FatalError ("RRGetScreenInfo bad extra len %ld != %ld\n",
+ (unsigned long)(data8 - (CARD8 *) extra), extraLen);
+ rep.length = (extraLen + 3) >> 2;
+ }
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.timestamp, n);
+ swaps(&rep.rotation, n);
+ swaps(&rep.nSizes, n);
+ swaps(&rep.sizeID, n);
+ swaps(&rep.rate, n);
+ swaps(&rep.nrateEnts, n);
+ }
+ WriteToClient(client, sizeof(xRRGetScreenInfoReply), (char *)&rep);
+ if (extraLen)
+ {
+ WriteToClient (client, extraLen, (char *) extra);
+ xfree (extra);
+ }
+ return (client->noClientException);
+}
+
+static int
+ProcRRSetScreenConfig (ClientPtr client)
+{
+ REQUEST(xRRSetScreenConfigReq);
+ xRRSetScreenConfigReply rep;
+ DrawablePtr pDraw;
+ int n;
+ ScreenPtr pScreen;
+ rrScrPrivPtr pScrPriv;
+ TimeStamp configTime;
+ TimeStamp time;
+ RRScreenSizePtr pSize;
+ int i;
+ Rotation rotation;
+ int rate;
+ short oldWidth, oldHeight;
+ Bool has_rate;
+
+ UpdateCurrentTime ();
+
+ if (RRClientKnowsRates (client))
+ {
+ REQUEST_SIZE_MATCH (xRRSetScreenConfigReq);
+ has_rate = TRUE;
+ }
+ else
+ {
+ REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq);
+ has_rate = FALSE;
+ }
+
+ SECURITY_VERIFY_DRAWABLE(pDraw, stuff->drawable, client,
+ SecurityWriteAccess);
+
+ pScreen = pDraw->pScreen;
+
+ pScrPriv = rrGetScrPriv(pScreen);
+
+ time = ClientTimeToServerTime(stuff->timestamp);
+ configTime = ClientTimeToServerTime(stuff->configTimestamp);
+
+ oldWidth = pScreen->width;
+ oldHeight = pScreen->height;
+
+ if (!pScrPriv)
+ {
+ time = currentTime;
+ rep.status = RRSetConfigFailed;
+ goto sendReply;
+ }
+ if (!RRGetInfo (pScreen))
+ return BadAlloc;
+
+ /*
+ * if the client's config timestamp is not the same as the last config
+ * timestamp, then the config information isn't up-to-date and
+ * can't even be validated
+ */
+ if (CompareTimeStamps (configTime, pScrPriv->lastConfigTime) != 0)
+ {
+ rep.status = RRSetConfigInvalidConfigTime;
+ goto sendReply;
+ }
+
+ /*
+ * Search for the requested size
+ */
+ pSize = 0;
+ for (i = 0; i < pScrPriv->nSizes; i++)
+ {
+ pSize = &pScrPriv->pSizes[i];
+ if (pSize->referenced && pSize->id == stuff->sizeID)
+ {
+ break;
+ }
+ }
+ if (i == pScrPriv->nSizes)
+ {
+ /*
+ * Invalid size ID
+ */
+ client->errorValue = stuff->sizeID;
+ return BadValue;
+ }
+
+ /*
+ * Validate requested rotation
+ */
+ rotation = (Rotation) stuff->rotation;
+
+ /* test the rotation bits only! */
+ switch (rotation & 0xf) {
+ case RR_Rotate_0:
+ case RR_Rotate_90:
+ case RR_Rotate_180:
+ case RR_Rotate_270:
+ break;
+ default:
+ /*
+ * Invalid rotation
+ */
+ client->errorValue = stuff->rotation;
+ return BadValue;
+ }
+
+ if ((~pScrPriv->rotations) & rotation)
+ {
+ /*
+ * requested rotation or reflection not supported by screen
+ */
+ client->errorValue = stuff->rotation;
+ return BadMatch;
+ }
+
+ /*
+ * Validate requested refresh
+ */
+ if (has_rate)
+ rate = (int) stuff->rate;
+ else
+ rate = 0;
+
+ if (rate)
+ {
+ for (i = 0; i < pSize->nRates; i++)
+ {
+ RRScreenRatePtr pRate = &pSize->pRates[i];
+ if (pRate->referenced && pRate->rate == rate)
+ break;
+ }
+ if (i == pSize->nRates)
+ {
+ /*
+ * Invalid rate
+ */
+ client->errorValue = rate;
+ return BadValue;
+ }
+ }
+
+ /*
+ * Make sure the requested set-time is not older than
+ * the last set-time
+ */
+ if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0)
+ {
+ rep.status = RRSetConfigInvalidTime;
+ goto sendReply;
+ }
+
+ /*
+ * call out to ddx routine to effect the change
+ */
+ if (!(*pScrPriv->rrSetConfig) (pScreen, rotation, rate,
+ pSize))
+ {
+ /*
+ * unknown DDX failure, report to client
+ */
+ rep.status = RRSetConfigFailed;
+ goto sendReply;
+ }
+
+ /*
+ * set current extension configuration pointers
+ */
+ RRSetCurrentConfig (pScreen, rotation, rate, pSize);
+
+ /*
+ * Deliver ScreenChangeNotify events whenever
+ * the configuration is updated
+ */
+ WalkTree (pScreen, TellChanged, (pointer) pScreen);
+
+ /*
+ * Deliver ConfigureNotify events when root changes
+ * pixel size
+ */
+ if (oldWidth != pScreen->width || oldHeight != pScreen->height)
+ RRSendConfigNotify (pScreen);
+ RREditConnectionInfo (pScreen);
+
+ /*
+ * Fix pointer bounds and location
+ */
+ ScreenRestructured (pScreen);
+ pScrPriv->lastSetTime = time;
+
+ /*
+ * Report Success
+ */
+ rep.status = RRSetConfigSuccess;
+
+sendReply:
+
+ rep.type = X_Reply;
+ /* rep.status has already been filled in */
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ rep.newTimestamp = pScrPriv->lastSetTime.milliseconds;
+ rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds;
+ rep.root = WindowTable[pDraw->pScreen->myNum]->drawable.id;
+
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.newTimestamp, n);
+ swapl(&rep.newConfigTimestamp, n);
+ swapl(&rep.root, n);
+ }
+ WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *)&rep);
+
+ return (client->noClientException);
+}
+
+int
+RRSetScreenConfig (ScreenPtr pScreen,
+ Rotation rotation,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ rrScrPrivPtr pScrPriv;
+ int i;
+ short oldWidth, oldHeight;
+
+ pScrPriv = rrGetScrPriv(pScreen);
+
+ oldWidth = pScreen->width;
+ oldHeight = pScreen->height;
+
+ if (!RRGetInfo (pScreen))
+ return BadAlloc;
+
+ /*
+ * Validate requested rotation
+ */
+
+ /* test the rotation bits only! */
+ switch (rotation & 0xf) {
+ case RR_Rotate_0:
+ case RR_Rotate_90:
+ case RR_Rotate_180:
+ case RR_Rotate_270:
+ break;
+ default:
+ /*
+ * Invalid rotation
+ */
+ return BadValue;
+ }
+
+ if ((~pScrPriv->rotations) & rotation)
+ {
+ /*
+ * requested rotation or reflection not supported by screen
+ */
+ return BadMatch;
+ }
+
+ /*
+ * Validate requested refresh
+ */
+ if (rate)
+ {
+ for (i = 0; i < pSize->nRates; i++)
+ {
+ RRScreenRatePtr pRate = &pSize->pRates[i];
+ if (pRate->referenced && pRate->rate == rate)
+ break;
+ }
+ if (i == pSize->nRates)
+ {
+ /*
+ * Invalid rate
+ */
+ return BadValue;
+ }
+ }
+
+ /*
+ * call out to ddx routine to effect the change
+ */
+ if (!(*pScrPriv->rrSetConfig) (pScreen, rotation, rate,
+ pSize))
+ {
+ /*
+ * unknown DDX failure, report to client
+ */
+ return BadImplementation;
+ }
+
+ /*
+ * set current extension configuration pointers
+ */
+ RRSetCurrentConfig (pScreen, rotation, rate, pSize);
+
+ /*
+ * Deliver ScreenChangeNotify events whenever
+ * the configuration is updated
+ */
+ WalkTree (pScreen, TellChanged, (pointer) pScreen);
+
+ /*
+ * Deliver ConfigureNotify events when root changes
+ * pixel size
+ */
+ if (oldWidth != pScreen->width || oldHeight != pScreen->height)
+ RRSendConfigNotify (pScreen);
+ RREditConnectionInfo (pScreen);
+
+ /*
+ * Fix pointer bounds and location
+ */
+ ScreenRestructured (pScreen);
+
+ return Success;
+}
+
+static int
+ProcRRSelectInput (ClientPtr client)
+{
+ REQUEST(xRRSelectInputReq);
+ rrClientPriv(client);
+ RRTimesPtr pTimes;
+ WindowPtr pWin;
+ RREventPtr pRREvent, pNewRREvent, *pHead;
+ XID clientResource;
+
+ REQUEST_SIZE_MATCH(xRRSelectInputReq);
+ pWin = SecurityLookupWindow (stuff->window, client, SecurityWriteAccess);
+ if (!pWin)
+ return BadWindow;
+ pHead = (RREventPtr *)SecurityLookupIDByType(client,
+ pWin->drawable.id, EventType,
+ SecurityWriteAccess);
+
+ if (stuff->enable & (RRScreenChangeNotifyMask))
+ {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ rrScrPriv (pScreen);
+
+ if (pHead)
+ {
+ /* check for existing entry. */
+ for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next)
+ if (pRREvent->client == client)
+ return Success;
+ }
+
+ /* build the entry */
+ pNewRREvent = (RREventPtr) xalloc (sizeof (RREventRec));
+ if (!pNewRREvent)
+ return BadAlloc;
+ pNewRREvent->next = 0;
+ pNewRREvent->client = client;
+ pNewRREvent->window = pWin;
+ pNewRREvent->mask = stuff->enable;
+ /*
+ * add a resource that will be deleted when
+ * the client goes away
+ */
+ clientResource = FakeClientID (client->index);
+ pNewRREvent->clientResource = clientResource;
+ if (!AddResource (clientResource, ClientType, (pointer)pNewRREvent))
+ return BadAlloc;
+ /*
+ * create a resource to contain a pointer to the list
+ * of clients selecting input. This must be indirect as
+ * the list may be arbitrarily rearranged which cannot be
+ * done through the resource database.
+ */
+ if (!pHead)
+ {
+ pHead = (RREventPtr *) xalloc (sizeof (RREventPtr));
+ if (!pHead ||
+ !AddResource (pWin->drawable.id, EventType, (pointer)pHead))
+ {
+ FreeResource (clientResource, RT_NONE);
+ return BadAlloc;
+ }
+ *pHead = 0;
+ }
+ pNewRREvent->next = *pHead;
+ *pHead = pNewRREvent;
+ /*
+ * Now see if the client needs an event
+ */
+ if (pScrPriv)
+ {
+ pTimes = &((RRTimesPtr) (pRRClient + 1))[pScreen->myNum];
+ if (CompareTimeStamps (pTimes->setTime,
+ pScrPriv->lastSetTime) != 0 ||
+ CompareTimeStamps (pTimes->configTime,
+ pScrPriv->lastConfigTime) != 0)
+ {
+ TellChanged (pWin, (pointer) pScreen);
+ }
+ }
+ }
+ else if (stuff->enable == xFalse)
+ {
+ /* delete the interest */
+ if (pHead) {
+ pNewRREvent = 0;
+ for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) {
+ if (pRREvent->client == client)
+ break;
+ pNewRREvent = pRREvent;
+ }
+ if (pRREvent) {
+ FreeResource (pRREvent->clientResource, ClientType);
+ if (pNewRREvent)
+ pNewRREvent->next = pRREvent->next;
+ else
+ *pHead = pRREvent->next;
+ xfree (pRREvent);
+ }
+ }
+ }
+ else
+ {
+ client->errorValue = stuff->enable;
+ return BadValue;
+ }
+ return Success;
+}
+
+
+static int
+ProcRRDispatch (ClientPtr client)
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_RRQueryVersion:
+ return ProcRRQueryVersion(client);
+ case X_RRSetScreenConfig:
+ return ProcRRSetScreenConfig(client);
+ case X_RRSelectInput:
+ return ProcRRSelectInput(client);
+ case X_RRGetScreenInfo:
+ return ProcRRGetScreenInfo(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static int
+SProcRRQueryVersion (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRRQueryVersionReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->majorVersion, n);
+ swapl(&stuff->minorVersion, n);
+ return ProcRRQueryVersion(client);
+}
+
+static int
+SProcRRGetScreenInfo (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRRGetScreenInfoReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ return ProcRRGetScreenInfo(client);
+}
+
+static int
+SProcRRSetScreenConfig (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRRSetScreenConfigReq);
+
+ if (RRClientKnowsRates (client))
+ {
+ REQUEST_SIZE_MATCH (xRRSetScreenConfigReq);
+ swaps (&stuff->rate, n);
+ }
+ else
+ {
+ REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq);
+ }
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->timestamp, n);
+ swaps(&stuff->sizeID, n);
+ swaps(&stuff->rotation, n);
+ return ProcRRSetScreenConfig(client);
+}
+
+static int
+SProcRRSelectInput (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRRSelectInputReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ return ProcRRSelectInput(client);
+}
+
+
+static int
+SProcRRDispatch (ClientPtr client)
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_RRQueryVersion:
+ return SProcRRQueryVersion(client);
+ case X_RRSetScreenConfig:
+ return SProcRRSetScreenConfig(client);
+ case X_RRSelectInput:
+ return SProcRRSelectInput(client);
+ case X_RRGetScreenInfo:
+ return SProcRRGetScreenInfo(client);
+ default:
+ return BadRequest;
+ }
+}
+
+
+static Bool
+RRScreenSizeMatches (RRScreenSizePtr a,
+ RRScreenSizePtr b)
+{
+ if (a->width != b->width)
+ return FALSE;
+ if (a->height != b->height)
+ return FALSE;
+ if (a->mmWidth != b->mmWidth)
+ return FALSE;
+ if (a->mmHeight != b->mmHeight)
+ return FALSE;
+ return TRUE;
+}
+
+RRScreenSizePtr
+RRRegisterSize (ScreenPtr pScreen,
+ short width,
+ short height,
+ short mmWidth,
+ short mmHeight)
+{
+ rrScrPriv (pScreen);
+ int i;
+ RRScreenSize tmp;
+ RRScreenSizePtr pNew;
+
+ if (!pScrPriv)
+ return 0;
+
+ tmp.width = width;
+ tmp.height= height;
+ tmp.mmWidth = mmWidth;
+ tmp.mmHeight = mmHeight;
+ tmp.pRates = 0;
+ tmp.nRates = 0;
+ tmp.nRatesInUse = 0;
+ tmp.referenced = TRUE;
+ tmp.oldReferenced = FALSE;
+ for (i = 0; i < pScrPriv->nSizes; i++)
+ if (RRScreenSizeMatches (&tmp, &pScrPriv->pSizes[i]))
+ {
+ pScrPriv->pSizes[i].referenced = TRUE;
+ return &pScrPriv->pSizes[i];
+ }
+ pNew = xrealloc (pScrPriv->pSizes,
+ (pScrPriv->nSizes + 1) * sizeof (RRScreenSize));
+ if (!pNew)
+ return 0;
+ pNew[pScrPriv->nSizes++] = tmp;
+ pScrPriv->pSizes = pNew;
+ return &pNew[pScrPriv->nSizes-1];
+}
+
+Bool RRRegisterRate (ScreenPtr pScreen,
+ RRScreenSizePtr pSize,
+ int rate)
+{
+ rrScrPriv(pScreen);
+ int i;
+ RRScreenRatePtr pNew, pRate;
+
+ if (!pScrPriv)
+ return FALSE;
+
+ for (i = 0; i < pSize->nRates; i++)
+ {
+ pRate = &pSize->pRates[i];
+ if (pRate->rate == rate)
+ {
+ pRate->referenced = TRUE;
+ return TRUE;
+ }
+ }
+
+ pNew = xrealloc (pSize->pRates,
+ (pSize->nRates + 1) * sizeof (RRScreenRate));
+ if (!pNew)
+ return FALSE;
+ pRate = &pNew[pSize->nRates++];
+ pRate->rate = rate;
+ pRate->referenced = TRUE;
+ pRate->oldReferenced = FALSE;
+ pSize->pRates = pNew;
+ return TRUE;
+}
+
+void
+RRSetCurrentConfig (ScreenPtr pScreen,
+ Rotation rotation,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ rrScrPriv (pScreen);
+
+ if (!pScrPriv)
+ return;
+
+ pScrPriv->rotation = rotation;
+ pScrPriv->size = pSize - pScrPriv->pSizes;
+ pScrPriv->rate = rate;
+}
diff --git a/nx-X11/programs/Xserver/randr/randrstr.h b/nx-X11/programs/Xserver/randr/randrstr.h
new file mode 100644
index 000000000..cd4ce3846
--- /dev/null
+++ b/nx-X11/programs/Xserver/randr/randrstr.h
@@ -0,0 +1,142 @@
+/*
+ * $XFree86: xc/programs/Xserver/randr/randrstr.h,v 1.5 2002/09/29 23:39:45 keithp Exp $
+ *
+ * Copyright © 2000 Compaq Computer Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Compaq not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Compaq makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * COMPAQ DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL COMPAQ BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _RANDRSTR_H_
+#define _RANDRSTR_H_
+
+#include <X11/extensions/randr.h>
+
+typedef struct _rrScreenRate {
+ int rate;
+ Bool referenced;
+ Bool oldReferenced;
+} RRScreenRate, *RRScreenRatePtr;
+
+typedef struct _rrScreenSize {
+ int id;
+ short width, height;
+ short mmWidth, mmHeight;
+ RRScreenRatePtr pRates;
+ int nRates;
+ int nRatesInUse;
+ Bool referenced;
+ Bool oldReferenced;
+} RRScreenSize, *RRScreenSizePtr;
+
+typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen,
+ Rotation rotation,
+ int rate,
+ RRScreenSizePtr pSize);
+
+typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations);
+typedef Bool (*RRCloseScreenProcPtr) ( int i, ScreenPtr pscreen);
+
+typedef struct _rrScrPriv {
+ RRSetConfigProcPtr rrSetConfig;
+ RRGetInfoProcPtr rrGetInfo;
+
+ TimeStamp lastSetTime; /* last changed by client */
+ TimeStamp lastConfigTime; /* possible configs changed */
+ RRCloseScreenProcPtr CloseScreen;
+
+ /*
+ * Configuration information
+ */
+ Rotation rotations;
+
+ int nSizes;
+ int nSizesInUse;
+ RRScreenSizePtr pSizes;
+
+ /*
+ * Current state
+ */
+ Rotation rotation;
+ int size;
+ int rate;
+} rrScrPrivRec, *rrScrPrivPtr;
+
+extern int rrPrivIndex;
+
+#define rrGetScrPriv(pScr) ((rrScrPrivPtr) (pScr)->devPrivates[rrPrivIndex].ptr)
+#define rrScrPriv(pScr) rrScrPrivPtr pScrPriv = rrGetScrPriv(pScr)
+#define SetRRScreen(s,p) ((s)->devPrivates[rrPrivIndex].ptr = (pointer) (p))
+
+/* Initialize the extension */
+void
+RRExtensionInit (void);
+
+/*
+ * Then, register the specific size with the screen
+ */
+
+RRScreenSizePtr
+RRRegisterSize (ScreenPtr pScreen,
+ short width,
+ short height,
+ short mmWidth,
+ short mmHeight);
+
+Bool RRRegisterRate (ScreenPtr pScreen,
+ RRScreenSizePtr pSize,
+ int rate);
+
+/*
+ * Finally, set the current configuration of the screen
+ */
+
+void
+RRSetCurrentConfig (ScreenPtr pScreen,
+ Rotation rotation,
+ int rate,
+ RRScreenSizePtr pSize);
+
+Bool RRScreenInit(ScreenPtr pScreen);
+
+int
+RRSetScreenConfig (ScreenPtr pScreen,
+ Rotation rotation,
+ int rate,
+ RRScreenSizePtr pSize);
+
+Bool
+miRandRInit (ScreenPtr pScreen);
+
+Bool
+miRRGetInfo (ScreenPtr pScreen, Rotation *rotations);
+
+Bool
+miRRSetConfig (ScreenPtr pScreen,
+ Rotation rotation,
+ int rate,
+ RRScreenSizePtr size);
+
+Bool
+miRRGetScreenInfo (ScreenPtr pScreen);
+
+#endif /* _RANDRSTR_H_ */
diff --git a/nx-X11/programs/Xserver/record/Imakefile b/nx-X11/programs/Xserver/record/Imakefile
new file mode 100644
index 000000000..4d4bf6a73
--- /dev/null
+++ b/nx-X11/programs/Xserver/record/Imakefile
@@ -0,0 +1,33 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:53:45 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/record/Imakefile,v 1.12 2001/11/02 23:29:34 dawes Exp $
+
+#if DoLoadableServer
+#define IHaveSubdirs
+#endif
+
+#include <Server.tmpl>
+
+#if DoLoadableServer
+ SUBDIRS = module
+#endif
+ SRCS = record.c set.c
+ OBJS = record.o set.o
+ INCLUDES = -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/Xext
+ LINTLIBS = ../dix/llib-ldix.ln
+ DEFINES = -DNDEBUG
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(record,$(OBJS))
+LintLibraryTarget(record,$(SRCS))
+NormalLintTarget($(SRCS))
+
+#if DoLoadableServer
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/record/module/Imakefile b/nx-X11/programs/Xserver/record/module/Imakefile
new file mode 100644
index 000000000..1a9aa1fee
--- /dev/null
+++ b/nx-X11/programs/Xserver/record/module/Imakefile
@@ -0,0 +1,34 @@
+XCOMM $XFree86: xc/programs/Xserver/record/module/Imakefile,v 1.1 2000/04/05 18:14:03 dawes Exp $
+XCOMM
+XCOMM
+XCOMM $XConsortium: Imakefile /main/3 1996/09/28 17:15:43 rws $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#if DoLoadableServer
+ MSRCS = recordmod.c
+ MOBJS = recordmod.o
+#endif
+
+ SRCS = record.c set.c $(MSRCS)
+ OBJS = record.o set.o $(MOBJS)
+ INCLUDES = -I.. -I../../include -I$(XINCLUDESRC) -I$(EXTINCSRC) \
+ -I$(SERVERSRC)/Xext
+ LINTLIBS = ../../dix/llib-ldix.ln
+ DEFINES = -DNDEBUG
+
+LinkSourceFile(recordmod.c,..)
+LinkSourceFile(record.c,..)
+LinkSourceFile(set.c,..)
+
+ModuleObjectRule()
+LibraryModuleTarget(record,$(OBJS))
+LintLibraryTarget(record,$(SRCS))
+NormalLintTarget($(SRCS))
+
+InstallLibraryModule(record,$(MODULEDIR),extensions)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(record,$(DRIVERSDKMODULEDIR),extensions)
diff --git a/nx-X11/programs/Xserver/record/record.c b/nx-X11/programs/Xserver/record/record.c
new file mode 100644
index 000000000..beea616c0
--- /dev/null
+++ b/nx-X11/programs/Xserver/record/record.c
@@ -0,0 +1,3053 @@
+/* $XdotOrg: xc/programs/Xserver/record/record.c,v 1.5 2005/07/03 07:02:08 daniels Exp $ */
+/* $Xorg: record.c,v 1.4 2001/02/09 02:05:27 xorgcvs Exp $ */
+
+/*
+
+Copyright 1995, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+Author: David P. Wiggins, The Open Group
+
+This work benefited from earlier work done by Martha Zimet of NCD
+and Jim Haggerty of Metheus.
+
+*/
+/* $XFree86: xc/programs/Xserver/record/record.c,v 1.11 2003/11/03 05:12:01 tsi Exp $ */
+
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "dixstruct.h"
+#include "extnsionst.h"
+#define _XRECORD_SERVER_
+#include <X11/extensions/recordstr.h>
+#include "set.h"
+
+#ifndef XFree86LOADER
+#include <stdio.h>
+#include <assert.h>
+#else
+#include "xf86_ansic.h"
+#endif
+
+#ifdef PANORAMIX
+#include "globals.h"
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#include "cursor.h"
+#endif
+
+static RESTYPE RTContext; /* internal resource type for Record contexts */
+static int RecordErrorBase; /* first Record error number */
+
+/* How many bytes of protocol data to buffer in a context. Don't set to less
+ * than 32.
+ */
+#define REPLY_BUF_SIZE 1024
+
+/* Record Context structure */
+
+typedef struct {
+ XID id; /* resource id of context */
+ ClientPtr pRecordingClient; /* client that has context enabled */
+ struct _RecordClientsAndProtocolRec *pListOfRCAP; /* all registered info */
+ ClientPtr pBufClient; /* client whose protocol is in replyBuffer*/
+ unsigned int continuedReply:1; /* recording a reply that is split up? */
+ char elemHeaders; /* element header flags (time/seq no.) */
+ char bufCategory; /* category of protocol in replyBuffer */
+ int numBufBytes; /* number of bytes in replyBuffer */
+ char replyBuffer[REPLY_BUF_SIZE]; /* buffered recorded protocol */
+} RecordContextRec, *RecordContextPtr;
+
+/* RecordMinorOpRec - to hold minor opcode selections for extension requests
+ * and replies
+ */
+
+typedef union {
+ int count; /* first element of array: how many "major" structs to follow */
+ struct { /* rest of array elements are this */
+ short first; /* first major opcode */
+ short last; /* last major opcode */
+ RecordSetPtr pMinOpSet; /* minor opcode set for above major range */
+ } major;
+} RecordMinorOpRec, *RecordMinorOpPtr;
+
+
+/* RecordClientsAndProtocolRec, nicknamed RCAP - holds all the client and
+ * protocol selections passed in a single CreateContext or RegisterClients.
+ * Generally, a context will have one of these from the create and an
+ * additional one for each RegisterClients. RCAPs are freed when all their
+ * clients are unregistered.
+ */
+
+typedef struct _RecordClientsAndProtocolRec {
+ RecordContextPtr pContext; /* context that owns this RCAP */
+ struct _RecordClientsAndProtocolRec *pNextRCAP; /* next RCAP on context */
+ RecordSetPtr pRequestMajorOpSet; /* requests to record */
+ RecordMinorOpPtr pRequestMinOpInfo; /* extension requests to record */
+ RecordSetPtr pReplyMajorOpSet; /* replies to record */
+ RecordMinorOpPtr pReplyMinOpInfo; /* extension replies to record */
+ RecordSetPtr pDeviceEventSet; /* device events to record */
+ RecordSetPtr pDeliveredEventSet; /* delivered events to record */
+ RecordSetPtr pErrorSet; /* errors to record */
+ XID * pClientIDs; /* array of clients to record */
+ short numClients; /* number of clients in pClientIDs */
+ short sizeClients; /* size of pClientIDs array */
+ unsigned int clientStarted:1; /* record new client connections? */
+ unsigned int clientDied:1; /* record client disconnections? */
+ unsigned int clientIDsSeparatelyAllocated:1; /* pClientIDs malloced? */
+} RecordClientsAndProtocolRec, *RecordClientsAndProtocolPtr;
+
+/* how much bigger to make pRCAP->pClientIDs when reallocing */
+#define CLIENT_ARRAY_GROWTH_INCREMENT 4
+
+/* counts the total number of RCAPs belonging to enabled contexts. */
+static int numEnabledRCAPs;
+
+/* void VERIFY_CONTEXT(RecordContextPtr, XID, ClientPtr)
+ * In the spirit of the VERIFY_* macros in dix.h, this macro fills in
+ * the context pointer if the given ID is a valid Record Context, else it
+ * returns an error.
+ */
+#define VERIFY_CONTEXT(_pContext, _contextid, _client) { \
+ (_pContext) = (RecordContextPtr)LookupIDByType((_contextid), RTContext); \
+ if (!(_pContext)) { \
+ (_client)->errorValue = (_contextid); \
+ return RecordErrorBase + XRecordBadContext; \
+ } \
+}
+
+static int RecordDeleteContext(
+ pointer /*value*/,
+ XID /*id*/
+);
+
+
+/***************************************************************************/
+
+/* client private stuff */
+
+/* To make declarations less obfuscated, have a typedef for a pointer to a
+ * Proc function.
+ */
+typedef int (*ProcFunctionPtr)(
+ ClientPtr /*pClient*/
+);
+
+/* Record client private. Generally a client only has one of these if
+ * any of its requests are being recorded.
+ */
+typedef struct {
+/* ptr to client's proc vector before Record stuck its nose in */
+ ProcFunctionPtr *originalVector;
+
+/* proc vector with pointers for recorded requests redirected to the
+ * function RecordARequest
+ */
+ ProcFunctionPtr recordVector[256];
+} RecordClientPrivateRec, *RecordClientPrivatePtr;
+
+static int RecordClientPrivateIndex;
+
+/* RecordClientPrivatePtr RecordClientPrivate(ClientPtr)
+ * gets the client private of the given client. Syntactic sugar.
+ */
+#define RecordClientPrivate(_pClient) (RecordClientPrivatePtr) \
+ ((_pClient)->devPrivates[RecordClientPrivateIndex].ptr)
+
+
+/***************************************************************************/
+
+/* global list of all contexts */
+
+static RecordContextPtr *ppAllContexts;
+
+static int numContexts;/* number of contexts in ppAllContexts */
+
+/* number of currently enabled contexts. All enabled contexts are bunched
+ * up at the front of the ppAllContexts array, from ppAllContexts[0] to
+ * ppAllContexts[numEnabledContexts-1], to eliminate time spent skipping
+ * past disabled contexts.
+ */
+static int numEnabledContexts;
+
+/* RecordFindContextOnAllContexts
+ *
+ * Arguments:
+ * pContext is the context to search for.
+ *
+ * Returns:
+ * The index into the array ppAllContexts at which pContext is stored.
+ * If pContext is not found in ppAllContexts, returns -1.
+ *
+ * Side Effects: none.
+ */
+static int
+RecordFindContextOnAllContexts(pContext)
+ RecordContextPtr pContext;
+{
+ int i;
+
+ assert(numContexts >= numEnabledContexts);
+ for (i = 0; i < numContexts; i++)
+ {
+ if (ppAllContexts[i] == pContext)
+ return i;
+ }
+ return -1;
+} /* RecordFindContextOnAllContexts */
+
+
+/***************************************************************************/
+
+/* RecordFlushReplyBuffer
+ *
+ * Arguments:
+ * pContext is the context to flush.
+ * data1 is a pointer to additional data, and len1 is its length in bytes.
+ * data2 is a pointer to additional data, and len2 is its length in bytes.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * If the context is enabled, any buffered (recorded) protocol is written
+ * to the recording client, and the number of buffered bytes is set to
+ * zero. If len1 is not zero, data1/len1 are then written to the
+ * recording client, and similarly for data2/len2 (written after
+ * data1/len1).
+ */
+static void
+RecordFlushReplyBuffer(
+ RecordContextPtr pContext,
+ pointer data1,
+ int len1,
+ pointer data2,
+ int len2
+)
+{
+ if (!pContext->pRecordingClient || pContext->pRecordingClient->clientGone)
+ return;
+ if (pContext->numBufBytes)
+ WriteToClient(pContext->pRecordingClient, pContext->numBufBytes,
+ (char *)pContext->replyBuffer);
+ pContext->numBufBytes = 0;
+ if (len1)
+ WriteToClient(pContext->pRecordingClient, len1, (char *)data1);
+ if (len2)
+ WriteToClient(pContext->pRecordingClient, len2, (char *)data2);
+} /* RecordFlushReplyBuffer */
+
+
+/* RecordAProtocolElement
+ *
+ * Arguments:
+ * pContext is the context that is recording a protocol element.
+ * pClient is the client whose protocol is being recorded. For
+ * device events and EndOfData, pClient is NULL.
+ * category is the category of the protocol element, as defined
+ * by the RECORD spec.
+ * data is a pointer to the protocol data, and datalen is its length
+ * in bytes.
+ * futurelen is the number of bytes that will be sent in subsequent
+ * calls to this function to complete this protocol element.
+ * In those subsequent calls, futurelen will be -1 to indicate
+ * that the current data is a continuation of the same protocol
+ * element.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * The context may be flushed. The new protocol element will be
+ * added to the context's protocol buffer with appropriate element
+ * headers prepended (sequence number and timestamp). If the data
+ * is continuation data (futurelen == -1), element headers won't
+ * be added. If the protocol element and headers won't fit in
+ * the context's buffer, it is sent directly to the recording
+ * client (after any buffered data).
+ */
+static void
+RecordAProtocolElement(RecordContextPtr pContext, ClientPtr pClient,
+ int category, pointer data, int datalen, int futurelen)
+{
+ CARD32 elemHeaderData[2];
+ int numElemHeaders = 0;
+ Bool recordingClientSwapped = pContext->pRecordingClient->swapped;
+ int n;
+ CARD32 serverTime = 0;
+ Bool gotServerTime = FALSE;
+ int replylen;
+
+ if (futurelen >= 0)
+ { /* start of new protocol element */
+ xRecordEnableContextReply *pRep = (xRecordEnableContextReply *)
+ pContext->replyBuffer;
+ if (pContext->pBufClient != pClient ||
+ pContext->bufCategory != category)
+ {
+ RecordFlushReplyBuffer(pContext, NULL, 0, NULL, 0);
+ pContext->pBufClient = pClient;
+ pContext->bufCategory = category;
+ }
+
+ if (!pContext->numBufBytes)
+ {
+ serverTime = GetTimeInMillis();
+ gotServerTime = TRUE;
+ pRep->type = X_Reply;
+ pRep->category = category;
+ pRep->sequenceNumber = pContext->pRecordingClient->sequence;
+ pRep->length = 0;
+ pRep->elementHeader = pContext->elemHeaders;
+ pRep->serverTime = serverTime;
+ if (pClient)
+ {
+ pRep->clientSwapped =
+ (pClient->swapped != recordingClientSwapped);
+ pRep->idBase = pClient->clientAsMask;
+ pRep->recordedSequenceNumber = pClient->sequence;
+ }
+ else /* it's a device event, StartOfData, or EndOfData */
+ {
+ pRep->clientSwapped = (category != XRecordFromServer) &&
+ recordingClientSwapped;
+ pRep->idBase = 0;
+ pRep->recordedSequenceNumber = 0;
+ }
+
+ if (recordingClientSwapped)
+ {
+ swaps(&pRep->sequenceNumber, n);
+ swapl(&pRep->length, n);
+ swapl(&pRep->idBase, n);
+ swapl(&pRep->serverTime, n);
+ swapl(&pRep->recordedSequenceNumber, n);
+ }
+ pContext->numBufBytes = SIZEOF(xRecordEnableContextReply);
+ }
+
+ /* generate element headers if needed */
+
+ if ( ( (pContext->elemHeaders & XRecordFromClientTime)
+ && category == XRecordFromClient)
+ ||
+ ( (pContext->elemHeaders & XRecordFromServerTime)
+ && category == XRecordFromServer))
+ {
+ if (gotServerTime)
+ elemHeaderData[numElemHeaders] = serverTime;
+ else
+ elemHeaderData[numElemHeaders] = GetTimeInMillis();
+ if (recordingClientSwapped)
+ swapl(&elemHeaderData[numElemHeaders], n);
+ numElemHeaders++;
+ }
+
+ if ( (pContext->elemHeaders & XRecordFromClientSequence)
+ &&
+ (category == XRecordFromClient || category == XRecordClientDied))
+ {
+ elemHeaderData[numElemHeaders] = pClient->sequence;
+ if (recordingClientSwapped)
+ swapl(&elemHeaderData[numElemHeaders], n);
+ numElemHeaders++;
+ }
+
+ /* adjust reply length */
+
+ replylen = pRep->length;
+ if (recordingClientSwapped) swapl(&replylen, n);
+ replylen += numElemHeaders + (datalen >> 2) + (futurelen >> 2);
+ if (recordingClientSwapped) swapl(&replylen, n);
+ pRep->length = replylen;
+ } /* end if not continued reply */
+
+ numElemHeaders *= 4;
+
+ /* if space available >= space needed, buffer the data */
+
+ if (REPLY_BUF_SIZE - pContext->numBufBytes >= datalen + numElemHeaders)
+ {
+ if (numElemHeaders)
+ {
+ memcpy(pContext->replyBuffer + pContext->numBufBytes,
+ elemHeaderData, numElemHeaders);
+ pContext->numBufBytes += numElemHeaders;
+ }
+ if (datalen)
+ {
+ memcpy(pContext->replyBuffer + pContext->numBufBytes,
+ data, datalen);
+ pContext->numBufBytes += datalen;
+ }
+ }
+ else
+ RecordFlushReplyBuffer(pContext, (pointer)elemHeaderData,
+ numElemHeaders, (pointer)data, datalen);
+
+} /* RecordAProtocolElement */
+
+
+/* RecordFindClientOnContext
+ *
+ * Arguments:
+ * pContext is the context to search.
+ * clientspec is the resource ID mask identifying the client to search
+ * for, or XRecordFutureClients.
+ * pposition is a pointer to an int, or NULL. See Returns.
+ *
+ * Returns:
+ * The RCAP on which clientspec was found, or NULL if not found on
+ * any RCAP on the given context.
+ * If pposition was not NULL and the returned RCAP is not NULL,
+ * *pposition will be set to the index into the returned the RCAP's
+ * pClientIDs array that holds clientspec.
+ *
+ * Side Effects: none.
+ */
+static RecordClientsAndProtocolPtr
+RecordFindClientOnContext(
+ RecordContextPtr pContext,
+ XID clientspec,
+ int *pposition
+)
+{
+ RecordClientsAndProtocolPtr pRCAP;
+
+ for (pRCAP = pContext->pListOfRCAP; pRCAP; pRCAP = pRCAP->pNextRCAP)
+ {
+ int i;
+ for (i = 0; i < pRCAP->numClients; i++)
+ {
+ if (pRCAP->pClientIDs[i] == clientspec)
+ {
+ if (pposition)
+ *pposition = i;
+ return pRCAP;
+ }
+ }
+ }
+ return NULL;
+} /* RecordFindClientOnContext */
+
+
+/* RecordABigRequest
+ *
+ * Arguments:
+ * pContext is the recording context.
+ * client is the client being recorded.
+ * stuff is a pointer to the big request of client (see the Big Requests
+ * extension for details.)
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * The big request is recorded with the correct length field re-inserted.
+ *
+ * Note: this function exists mainly to make RecordARequest smaller.
+ */
+static void
+RecordABigRequest(pContext, client, stuff)
+ RecordContextPtr pContext;
+ ClientPtr client;
+ xReq *stuff;
+{
+ CARD32 bigLength;
+ char n;
+ int bytesLeft;
+
+ /* note: client->req_len has been frobbed by ReadRequestFromClient
+ * (os/io.c) to discount the extra 4 bytes taken by the extended length
+ * field in a big request. The actual request length to record is
+ * client->req_len + 1 (measured in CARD32s).
+ */
+
+ /* record the request header */
+ bytesLeft = client->req_len << 2;
+ RecordAProtocolElement(pContext, client, XRecordFromClient,
+ (pointer)stuff, SIZEOF(xReq), bytesLeft);
+
+ /* reinsert the extended length field that was squished out */
+ bigLength = client->req_len + (sizeof(bigLength) >> 2);
+ if (client->swapped)
+ swapl(&bigLength, n);
+ RecordAProtocolElement(pContext, client, XRecordFromClient,
+ (pointer)&bigLength, sizeof(bigLength), /* continuation */ -1);
+ bytesLeft -= sizeof(bigLength);
+
+ /* record the rest of the request after the length */
+ RecordAProtocolElement(pContext, client, XRecordFromClient,
+ (pointer)(stuff + 1), bytesLeft, /* continuation */ -1);
+} /* RecordABigRequest */
+
+
+/* RecordARequest
+ *
+ * Arguments:
+ * client is a client that the server has dispatched a request to by
+ * calling client->requestVector[request opcode] .
+ * The request is in client->requestBuffer.
+ *
+ * Returns:
+ * Whatever is returned by the "real" Proc function for this request.
+ * The "real" Proc function is the function that was in
+ * client->requestVector[request opcode] before it was replaced by
+ * RecordARequest. (See the function RecordInstallHooks.)
+ *
+ * Side Effects:
+ * The request is recorded by all contexts that have registered this
+ * request for this client. The real Proc function is called.
+ */
+static int
+RecordARequest(client)
+ ClientPtr client;
+{
+ RecordContextPtr pContext;
+ RecordClientsAndProtocolPtr pRCAP;
+ int i;
+ RecordClientPrivatePtr pClientPriv;
+ REQUEST(xReq);
+ int majorop;
+
+ majorop = stuff->reqType;
+ for (i = 0; i < numEnabledContexts; i++)
+ {
+ pContext = ppAllContexts[i];
+ pRCAP = RecordFindClientOnContext(pContext, client->clientAsMask,
+ NULL);
+ if (pRCAP && pRCAP->pRequestMajorOpSet &&
+ RecordIsMemberOfSet(pRCAP->pRequestMajorOpSet, majorop))
+ {
+ if (majorop <= 127)
+ { /* core request */
+
+ if (stuff->length == 0)
+ RecordABigRequest(pContext, client, stuff);
+ else
+ RecordAProtocolElement(pContext, client, XRecordFromClient,
+ (pointer)stuff, client->req_len << 2, 0);
+ }
+ else /* extension, check minor opcode */
+ {
+ int minorop = MinorOpcodeOfRequest(client);
+ int numMinOpInfo;
+ RecordMinorOpPtr pMinorOpInfo = pRCAP->pRequestMinOpInfo;
+
+ assert (pMinorOpInfo);
+ numMinOpInfo = pMinorOpInfo->count;
+ pMinorOpInfo++;
+ assert (numMinOpInfo);
+ for ( ; numMinOpInfo; numMinOpInfo--, pMinorOpInfo++)
+ {
+ if (majorop >= pMinorOpInfo->major.first &&
+ majorop <= pMinorOpInfo->major.last &&
+ RecordIsMemberOfSet(pMinorOpInfo->major.pMinOpSet,
+ minorop))
+ {
+ if (stuff->length == 0)
+ RecordABigRequest(pContext, client, stuff);
+ else
+ RecordAProtocolElement(pContext, client,
+ XRecordFromClient, (pointer)stuff,
+ client->req_len << 2, 0);
+ break;
+ }
+ } /* end for each minor op info */
+ } /* end extension request */
+ } /* end this RCAP wants this major opcode */
+ } /* end for each context */
+ pClientPriv = RecordClientPrivate(client);
+ assert(pClientPriv);
+ return (* pClientPriv->originalVector[majorop])(client);
+} /* RecordARequest */
+
+
+/* RecordASkippedRequest
+ *
+ * Arguments:
+ * pcbl is &SkippedRequestCallback.
+ * nulldata is NULL.
+ * calldata is a pointer to a SkippedRequestInfoRec (include/os.h)
+ * which provides information about requests that the server is
+ * skipping. The client's proc vector won't be called for skipped
+ * requests, so that's why we have to catch them here.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * The skipped requests are recorded by all contexts that have
+ * registered those requests for this client.
+ *
+ * Note: most servers don't skip requests, so calls to this will probably
+ * be rare. For more information on skipped requests, search for
+ * the word skip in ddx.tbl.ms (the porting layer document).
+ */
+static void
+RecordASkippedRequest(pcbl , nulldata, calldata)
+ CallbackListPtr *pcbl;
+ pointer nulldata;
+ pointer calldata;
+{
+ SkippedRequestInfoRec *psi = (SkippedRequestInfoRec *)calldata;
+ RecordContextPtr pContext;
+ RecordClientsAndProtocolPtr pRCAP;
+ xReqPtr stuff = psi->req;
+ ClientPtr client = psi->client;
+ int numSkippedRequests = psi->numskipped;
+ int reqlen;
+ int i;
+ int majorop;
+
+ while (numSkippedRequests--)
+ {
+ majorop = stuff->reqType;
+ reqlen = ReqLen(stuff, client);
+ /* handle big request */
+ if (stuff->length == 0)
+ reqlen += 4;
+ for (i = 0; i < numEnabledContexts; i++)
+ {
+ pContext = ppAllContexts[i];
+ pRCAP = RecordFindClientOnContext(pContext, client->clientAsMask,
+ NULL);
+ if (pRCAP && pRCAP->pRequestMajorOpSet &&
+ RecordIsMemberOfSet(pRCAP->pRequestMajorOpSet, majorop))
+ {
+ if (majorop <= 127)
+ { /* core request */
+
+ RecordAProtocolElement(pContext, client, XRecordFromClient,
+ (pointer)stuff, reqlen, 0);
+ }
+ else /* extension, check minor opcode */
+ {
+ int minorop = MinorOpcodeOfRequest(client);
+ int numMinOpInfo;
+ RecordMinorOpPtr pMinorOpInfo = pRCAP->pRequestMinOpInfo;
+
+ assert (pMinorOpInfo);
+ numMinOpInfo = pMinorOpInfo->count;
+ pMinorOpInfo++;
+ assert (numMinOpInfo);
+ for ( ; numMinOpInfo; numMinOpInfo--, pMinorOpInfo++)
+ {
+ if (majorop >= pMinorOpInfo->major.first &&
+ majorop <= pMinorOpInfo->major.last &&
+ RecordIsMemberOfSet(pMinorOpInfo->major.pMinOpSet,
+ minorop))
+ {
+ RecordAProtocolElement(pContext, client,
+ XRecordFromClient, (pointer)stuff,
+ reqlen, 0);
+ break;
+ }
+ } /* end for each minor op info */
+ } /* end extension request */
+ } /* end this RCAP wants this major opcode */
+ } /* end for each context */
+
+ /* go to next request */
+ stuff = (xReqPtr)( ((char *)stuff) + reqlen);
+
+ } /* end for each skipped request */
+} /* RecordASkippedRequest */
+
+
+/* RecordAReply
+ *
+ * Arguments:
+ * pcbl is &ReplyCallback.
+ * nulldata is NULL.
+ * calldata is a pointer to a ReplyInfoRec (include/os.h)
+ * which provides information about replies that are being sent
+ * to clients.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * The reply is recorded by all contexts that have registered this
+ * reply type for this client. If more data belonging to the same
+ * reply is expected, and if the reply is being recorded by any
+ * context, pContext->continuedReply is set to 1.
+ * If pContext->continuedReply was already 1 and this is the last
+ * chunk of data belonging to this reply, it is set to 0.
+ */
+static void
+RecordAReply(pcbl, nulldata, calldata)
+ CallbackListPtr *pcbl;
+ pointer nulldata;
+ pointer calldata;
+{
+ RecordContextPtr pContext;
+ RecordClientsAndProtocolPtr pRCAP;
+ int eci;
+ int majorop;
+ ReplyInfoRec *pri = (ReplyInfoRec *)calldata;
+ ClientPtr client = pri->client;
+ REQUEST(xReq);
+
+ majorop = stuff->reqType;
+ for (eci = 0; eci < numEnabledContexts; eci++)
+ {
+ pContext = ppAllContexts[eci];
+ pRCAP = RecordFindClientOnContext(pContext, client->clientAsMask,
+ NULL);
+ if (pRCAP)
+ {
+ if (pContext->continuedReply)
+ {
+ RecordAProtocolElement(pContext, client, XRecordFromServer,
+ pri->replyData, pri->dataLenBytes, /* continuation */ -1);
+ if (!pri->bytesRemaining)
+ pContext->continuedReply = 0;
+ }
+ else if (pri->startOfReply && pRCAP->pReplyMajorOpSet &&
+ RecordIsMemberOfSet(pRCAP->pReplyMajorOpSet, majorop))
+ {
+ if (majorop <= 127)
+ { /* core reply */
+ RecordAProtocolElement(pContext, client, XRecordFromServer,
+ pri->replyData, pri->dataLenBytes, pri->bytesRemaining);
+ if (pri->bytesRemaining)
+ pContext->continuedReply = 1;
+ }
+ else /* extension, check minor opcode */
+ {
+ int minorop = MinorOpcodeOfRequest(client);
+ int numMinOpInfo;
+ RecordMinorOpPtr pMinorOpInfo = pRCAP->pReplyMinOpInfo;
+ assert (pMinorOpInfo);
+ numMinOpInfo = pMinorOpInfo->count;
+ pMinorOpInfo++;
+ assert (numMinOpInfo);
+ for ( ; numMinOpInfo; numMinOpInfo--, pMinorOpInfo++)
+ {
+ if (majorop >= pMinorOpInfo->major.first &&
+ majorop <= pMinorOpInfo->major.last &&
+ RecordIsMemberOfSet(pMinorOpInfo->major.pMinOpSet,
+ minorop))
+ {
+ RecordAProtocolElement(pContext, client,
+ XRecordFromServer, pri->replyData,
+ pri->dataLenBytes, pri->bytesRemaining);
+ if (pri->bytesRemaining)
+ pContext->continuedReply = 1;
+ break;
+ }
+ } /* end for each minor op info */
+ } /* end extension reply */
+ } /* end continued reply vs. start of reply */
+ } /* end client is registered on this context */
+ } /* end for each context */
+} /* RecordAReply */
+
+
+/* RecordADeliveredEventOrError
+ *
+ * Arguments:
+ * pcbl is &EventCallback.
+ * nulldata is NULL.
+ * calldata is a pointer to a EventInfoRec (include/dix.h)
+ * which provides information about events that are being sent
+ * to clients.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * The event or error is recorded by all contexts that have registered
+ * it for this client.
+ */
+static void
+RecordADeliveredEventOrError(pcbl, nulldata, calldata)
+ CallbackListPtr *pcbl;
+ pointer nulldata;
+ pointer calldata;
+{
+ EventInfoRec *pei = (EventInfoRec *)calldata;
+ RecordContextPtr pContext;
+ RecordClientsAndProtocolPtr pRCAP;
+ int eci; /* enabled context index */
+ ClientPtr pClient = pei->client;
+
+ for (eci = 0; eci < numEnabledContexts; eci++)
+ {
+ pContext = ppAllContexts[eci];
+ pRCAP = RecordFindClientOnContext(pContext, pClient->clientAsMask,
+ NULL);
+ if (pRCAP && (pRCAP->pDeliveredEventSet || pRCAP->pErrorSet))
+ {
+ int ev; /* event index */
+ xEvent *pev = pei->events;
+ for (ev = 0; ev < pei->count; ev++, pev++)
+ {
+ int recordit;
+ if (pev->u.u.type == X_Error)
+ {
+ recordit = RecordIsMemberOfSet(pRCAP->pErrorSet,
+ ((xError *)(pev))->errorCode);
+ }
+ else
+ {
+ recordit = RecordIsMemberOfSet(pRCAP->pDeliveredEventSet,
+ pev->u.u.type & 0177);
+ }
+ if (recordit)
+ {
+ xEvent swappedEvent;
+ xEvent *pEvToRecord = pev;
+
+ if (pClient->swapped)
+ {
+ (*EventSwapVector[pev->u.u.type & 0177])
+ (pev, &swappedEvent);
+ pEvToRecord = &swappedEvent;
+
+ }
+ RecordAProtocolElement(pContext, pClient,
+ XRecordFromServer, pEvToRecord, SIZEOF(xEvent), 0);
+ }
+ } /* end for each event */
+ } /* end this client is on this context */
+ } /* end for each enabled context */
+} /* RecordADeliveredEventOrError */
+
+
+/* RecordADeviceEvent
+ *
+ * Arguments:
+ * pcbl is &DeviceEventCallback.
+ * nulldata is NULL.
+ * calldata is a pointer to a DeviceEventInfoRec (include/dix.h)
+ * which provides information about device events that occur.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * The device event is recorded by all contexts that have registered
+ * it for this client.
+ */
+static void
+RecordADeviceEvent(pcbl, nulldata, calldata)
+ CallbackListPtr *pcbl;
+ pointer nulldata;
+ pointer calldata;
+{
+ DeviceEventInfoRec *pei = (DeviceEventInfoRec *)calldata;
+ RecordContextPtr pContext;
+ RecordClientsAndProtocolPtr pRCAP;
+ int eci; /* enabled context index */
+
+ for (eci = 0; eci < numEnabledContexts; eci++)
+ {
+ pContext = ppAllContexts[eci];
+ for (pRCAP = pContext->pListOfRCAP; pRCAP; pRCAP = pRCAP->pNextRCAP)
+ {
+ if (pRCAP->pDeviceEventSet)
+ {
+ int ev; /* event index */
+ xEvent *pev = pei->events;
+ for (ev = 0; ev < pei->count; ev++, pev++)
+ {
+ if (RecordIsMemberOfSet(pRCAP->pDeviceEventSet,
+ pev->u.u.type & 0177))
+ {
+ xEvent swappedEvent;
+ xEvent *pEvToRecord = pev;
+#ifdef PANORAMIX
+ xEvent shiftedEvent;
+
+ if (!noPanoramiXExtension &&
+ (pev->u.u.type == MotionNotify ||
+ pev->u.u.type == ButtonPress ||
+ pev->u.u.type == ButtonRelease ||
+ pev->u.u.type == KeyPress ||
+ pev->u.u.type == KeyRelease)) {
+ int scr = XineramaGetCursorScreen();
+ memcpy(&shiftedEvent, pev, sizeof(xEvent));
+ shiftedEvent.u.keyButtonPointer.rootX +=
+ panoramiXdataPtr[scr].x -
+ panoramiXdataPtr[0].x;
+ shiftedEvent.u.keyButtonPointer.rootY +=
+ panoramiXdataPtr[scr].y -
+ panoramiXdataPtr[0].y;
+ pEvToRecord = &shiftedEvent;
+ }
+#endif /* PANORAMIX */
+
+ if (pContext->pRecordingClient->swapped)
+ {
+ (*EventSwapVector[pEvToRecord->u.u.type & 0177])
+ (pEvToRecord, &swappedEvent);
+ pEvToRecord = &swappedEvent;
+ }
+
+ RecordAProtocolElement(pContext, NULL,
+ XRecordFromServer, pEvToRecord, SIZEOF(xEvent), 0);
+ /* make sure device events get flushed in the absence
+ * of other client activity
+ */
+ SetCriticalOutputPending();
+ }
+ } /* end for each event */
+ } /* end this RCAP selects device events */
+ } /* end for each RCAP on this context */
+ } /* end for each enabled context */
+} /* RecordADeviceEvent */
+
+
+/* RecordFlushAllContexts
+ *
+ * Arguments:
+ * pcbl is &FlushCallback.
+ * nulldata and calldata are NULL.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * All buffered reply data of all enabled contexts is written to
+ * the recording clients.
+ */
+static void
+RecordFlushAllContexts(
+ CallbackListPtr *pcbl,
+ pointer nulldata,
+ pointer calldata
+)
+{
+ int eci; /* enabled context index */
+ RecordContextPtr pContext;
+
+ for (eci = 0; eci < numEnabledContexts; eci++)
+ {
+ pContext = ppAllContexts[eci];
+
+ /* In most cases we leave it to RecordFlushReplyBuffer to make
+ * this check, but this function could be called very often, so we
+ * check before calling hoping to save the function call cost
+ * most of the time.
+ */
+ if (pContext->numBufBytes)
+ RecordFlushReplyBuffer(ppAllContexts[eci], NULL, 0, NULL, 0);
+ }
+} /* RecordFlushAllContexts */
+
+
+/* RecordInstallHooks
+ *
+ * Arguments:
+ * pRCAP is an RCAP on an enabled or being-enabled context.
+ * oneclient can be zero or the resource ID mask identifying a client.
+ *
+ * Returns: BadAlloc if a memory allocation error occurred, else Success.
+ *
+ * Side Effects:
+ * Recording hooks needed by RCAP are installed.
+ * If oneclient is zero, recording hooks needed for all clients and
+ * protocol on the RCAP are installed. If oneclient is non-zero,
+ * only those hooks needed for the specified client are installed.
+ *
+ * Client requestVectors may be altered. numEnabledRCAPs will be
+ * incremented if oneclient == 0. Callbacks may be added to
+ * various callback lists.
+ */
+static int
+RecordInstallHooks(pRCAP, oneclient)
+ RecordClientsAndProtocolPtr pRCAP;
+ XID oneclient;
+{
+ int i = 0;
+ XID client;
+
+ if (oneclient)
+ client = oneclient;
+ else
+ client = pRCAP->numClients ? pRCAP->pClientIDs[i++] : 0;
+
+ while (client)
+ {
+ if (client != XRecordFutureClients)
+ {
+ if (pRCAP->pRequestMajorOpSet)
+ {
+ RecordSetIteratePtr pIter = NULL;
+ RecordSetInterval interval;
+ ClientPtr pClient = clients[CLIENT_ID(client)];
+
+ if (pClient && !RecordClientPrivate(pClient))
+ {
+ RecordClientPrivatePtr pClientPriv;
+ /* no Record proc vector; allocate one */
+ pClientPriv = (RecordClientPrivatePtr)
+ xalloc(sizeof(RecordClientPrivateRec));
+ if (!pClientPriv)
+ return BadAlloc;
+ /* copy old proc vector to new */
+ memcpy(pClientPriv->recordVector, pClient->requestVector,
+ sizeof (pClientPriv->recordVector));
+ pClientPriv->originalVector = pClient->requestVector;
+ pClient->devPrivates[RecordClientPrivateIndex].ptr =
+ (pointer)pClientPriv;
+ pClient->requestVector = pClientPriv->recordVector;
+ }
+ while ((pIter = RecordIterateSet(pRCAP->pRequestMajorOpSet,
+ pIter, &interval)))
+ {
+ unsigned int j;
+ for (j = interval.first; j <= interval.last; j++)
+ pClient->requestVector[j] = RecordARequest;
+ }
+ }
+ }
+ if (oneclient)
+ client = 0;
+ else
+ client = (i < pRCAP->numClients) ? pRCAP->pClientIDs[i++] : 0;
+ }
+
+ assert(numEnabledRCAPs >= 0);
+ if (!oneclient && ++numEnabledRCAPs == 1)
+ { /* we're enabling the first context */
+ if (!AddCallback(&EventCallback, RecordADeliveredEventOrError, NULL))
+ return BadAlloc;
+ if (!AddCallback(&DeviceEventCallback, RecordADeviceEvent, NULL))
+ return BadAlloc;
+ if (!AddCallback(&ReplyCallback, RecordAReply, NULL))
+ return BadAlloc;
+ if (!AddCallback(&SkippedRequestsCallback, RecordASkippedRequest,
+ NULL))
+ return BadAlloc;
+ if (!AddCallback(&FlushCallback, RecordFlushAllContexts, NULL))
+ return BadAlloc;
+ /* Alternate context flushing scheme: delete the line above
+ * and call RegisterBlockAndWakeupHandlers here passing
+ * RecordFlushAllContexts. Is this any better?
+ */
+ }
+ return Success;
+} /* RecordInstallHooks */
+
+
+/* RecordUninstallHooks
+ *
+ * Arguments:
+ * pRCAP is an RCAP on an enabled or being-disabled context.
+ * oneclient can be zero or the resource ID mask identifying a client.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Recording hooks needed by RCAP may be uninstalled.
+ * If oneclient is zero, recording hooks needed for all clients and
+ * protocol on the RCAP may be uninstalled. If oneclient is non-zero,
+ * only those hooks needed for the specified client may be uninstalled.
+ *
+ * Client requestVectors may be altered. numEnabledRCAPs will be
+ * decremented if oneclient == 0. Callbacks may be deleted from
+ * various callback lists.
+ */
+static void
+RecordUninstallHooks(pRCAP, oneclient)
+ RecordClientsAndProtocolPtr pRCAP;
+ XID oneclient;
+{
+ int i = 0;
+ XID client;
+
+ if (oneclient)
+ client = oneclient;
+ else
+ client = pRCAP->numClients ? pRCAP->pClientIDs[i++] : 0;
+
+ while (client)
+ {
+ if (client != XRecordFutureClients)
+ {
+ if (pRCAP->pRequestMajorOpSet)
+ {
+ ClientPtr pClient = clients[CLIENT_ID(client)];
+ int c;
+ Bool otherRCAPwantsProcVector = FALSE;
+ RecordClientPrivatePtr pClientPriv =
+ RecordClientPrivate(pClient);
+
+ assert (pClient && RecordClientPrivate(pClient));
+ memcpy(pClientPriv->recordVector, pClientPriv->originalVector,
+ sizeof (pClientPriv->recordVector));
+
+ for (c = 0; c < numEnabledContexts; c++)
+ {
+ RecordClientsAndProtocolPtr pOtherRCAP;
+ RecordContextPtr pContext = ppAllContexts[c];
+
+ if (pContext == pRCAP->pContext) continue;
+ pOtherRCAP = RecordFindClientOnContext(pContext, client,
+ NULL);
+ if (pOtherRCAP && pOtherRCAP->pRequestMajorOpSet)
+ {
+ RecordSetIteratePtr pIter = NULL;
+ RecordSetInterval interval;
+
+ otherRCAPwantsProcVector = TRUE;
+ while ((pIter = RecordIterateSet(
+ pOtherRCAP->pRequestMajorOpSet,
+ pIter, &interval)))
+ {
+ unsigned int j;
+ for (j = interval.first; j <= interval.last; j++)
+ pClient->requestVector[j] = RecordARequest;
+ }
+ }
+ }
+ if (!otherRCAPwantsProcVector)
+ { /* nobody needs it, so free it */
+ pClient->requestVector = pClientPriv->originalVector;
+ pClient->devPrivates[RecordClientPrivateIndex].ptr = NULL;
+ xfree(pClientPriv);
+ }
+ } /* end if this RCAP specifies any requests */
+ } /* end if not future clients */
+ if (oneclient)
+ client = 0;
+ else
+ client = (i < pRCAP->numClients) ? pRCAP->pClientIDs[i++] : 0;
+ }
+
+ assert(numEnabledRCAPs >= 1);
+ if (!oneclient && --numEnabledRCAPs == 0)
+ { /* we're disabling the last context */
+ DeleteCallback(&EventCallback, RecordADeliveredEventOrError, NULL);
+ DeleteCallback(&DeviceEventCallback, RecordADeviceEvent, NULL);
+ DeleteCallback(&ReplyCallback, RecordAReply, NULL);
+ DeleteCallback(&SkippedRequestsCallback, RecordASkippedRequest, NULL);
+ DeleteCallback(&FlushCallback, RecordFlushAllContexts, NULL);
+ /* Alternate context flushing scheme: delete the line above
+ * and call RemoveBlockAndWakeupHandlers here passing
+ * RecordFlushAllContexts. Is this any better?
+ */
+ /* Having deleted the callback, call it one last time. -gildea */
+ RecordFlushAllContexts(&FlushCallback, NULL, NULL);
+ }
+} /* RecordUninstallHooks */
+
+
+/* RecordDeleteClientFromRCAP
+ *
+ * Arguments:
+ * pRCAP is an RCAP to delete the client from.
+ * position is the index into the array pRCAP->pClientIDs of the
+ * client to delete.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Recording hooks needed by client will be uninstalled if the context
+ * is enabled. The designated client will be removed from the
+ * pRCAP->pClientIDs array. If it was the only client on the RCAP,
+ * the RCAP is removed from the context and freed. (Invariant: RCAPs
+ * have at least one client.)
+ */
+static void
+RecordDeleteClientFromRCAP(pRCAP, position)
+ RecordClientsAndProtocolPtr pRCAP;
+ int position;
+{
+ if (pRCAP->pContext->pRecordingClient)
+ RecordUninstallHooks(pRCAP, pRCAP->pClientIDs[position]);
+ if (position != pRCAP->numClients - 1)
+ pRCAP->pClientIDs[position] = pRCAP->pClientIDs[pRCAP->numClients - 1];
+ if (--pRCAP->numClients == 0)
+ { /* no more clients; remove RCAP from context's list */
+ RecordContextPtr pContext = pRCAP->pContext;
+ if (pContext->pRecordingClient)
+ RecordUninstallHooks(pRCAP, 0);
+ if (pContext->pListOfRCAP == pRCAP)
+ pContext->pListOfRCAP = pRCAP->pNextRCAP;
+ else
+ {
+ RecordClientsAndProtocolPtr prevRCAP;
+ for (prevRCAP = pContext->pListOfRCAP;
+ prevRCAP->pNextRCAP != pRCAP;
+ prevRCAP = prevRCAP->pNextRCAP)
+ ;
+ prevRCAP->pNextRCAP = pRCAP->pNextRCAP;
+ }
+ /* free the RCAP */
+ if (pRCAP->clientIDsSeparatelyAllocated)
+ xfree(pRCAP->pClientIDs);
+ xfree(pRCAP);
+ }
+} /* RecordDeleteClientFromRCAP */
+
+
+/* RecordAddClientToRCAP
+ *
+ * Arguments:
+ * pRCAP is an RCAP to add the client to.
+ * clientspec is the resource ID mask identifying a client, or
+ * XRecordFutureClients.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Recording hooks needed by client will be installed if the context
+ * is enabled. The designated client will be added to the
+ * pRCAP->pClientIDs array, which may be realloced.
+ * pRCAP->clientIDsSeparatelyAllocated may be set to 1 if there
+ * is no more room to hold clients internal to the RCAP.
+ */
+static void
+RecordAddClientToRCAP(pRCAP, clientspec)
+ RecordClientsAndProtocolPtr pRCAP;
+ XID clientspec;
+{
+ if (pRCAP->numClients == pRCAP->sizeClients)
+ {
+ if (pRCAP->clientIDsSeparatelyAllocated)
+ {
+ XID *pNewIDs = (XID *)xrealloc(pRCAP->pClientIDs,
+ (pRCAP->sizeClients + CLIENT_ARRAY_GROWTH_INCREMENT) *
+ sizeof(XID));
+ if (!pNewIDs)
+ return;
+ pRCAP->pClientIDs = pNewIDs;
+ pRCAP->sizeClients += CLIENT_ARRAY_GROWTH_INCREMENT;
+ }
+ else
+ {
+ XID *pNewIDs = (XID *)xalloc((pRCAP->sizeClients +
+ CLIENT_ARRAY_GROWTH_INCREMENT) * sizeof(XID));
+ if (!pNewIDs)
+ return;
+ memcpy(pNewIDs, pRCAP->pClientIDs, pRCAP->numClients *sizeof(XID));
+ pRCAP->pClientIDs = pNewIDs;
+ pRCAP->sizeClients += CLIENT_ARRAY_GROWTH_INCREMENT;
+ pRCAP->clientIDsSeparatelyAllocated = 1;
+ }
+ }
+ pRCAP->pClientIDs[pRCAP->numClients++] = clientspec;
+ if (pRCAP->pContext->pRecordingClient)
+ RecordInstallHooks(pRCAP, clientspec);
+} /* RecordDeleteClientFromRCAP */
+
+
+/* RecordDeleteClientFromContext
+ *
+ * Arguments:
+ * pContext is the context to delete from.
+ * clientspec is the resource ID mask identifying a client, or
+ * XRecordFutureClients.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * If clientspec is on any RCAP of the context, it is deleted from that
+ * RCAP. (A given clientspec can only be on one RCAP of a context.)
+ */
+static void
+RecordDeleteClientFromContext(pContext, clientspec)
+ RecordContextPtr pContext;
+ XID clientspec;
+{
+ RecordClientsAndProtocolPtr pRCAP;
+ int position;
+
+ if ((pRCAP = RecordFindClientOnContext(pContext, clientspec, &position)))
+ RecordDeleteClientFromRCAP(pRCAP, position);
+} /* RecordDeleteClientFromContext */
+
+
+/* RecordSanityCheckClientSpecifiers
+ *
+ * Arguments:
+ * clientspecs is an array of alleged CLIENTSPECs passed by the client.
+ * nspecs is the number of elements in clientspecs.
+ * errorspec, if non-zero, is the resource id base of a client that
+ * must not appear in clienspecs.
+ *
+ * Returns: BadMatch if any of the clientspecs are invalid, else Success.
+ *
+ * Side Effects: none.
+ */
+static int
+RecordSanityCheckClientSpecifiers(clientspecs, nspecs, errorspec)
+ XID *clientspecs;
+ int nspecs;
+ XID errorspec;
+{
+ int i;
+ int clientIndex;
+
+ for (i = 0; i < nspecs; i++)
+ {
+ if (clientspecs[i] == XRecordCurrentClients ||
+ clientspecs[i] == XRecordFutureClients ||
+ clientspecs[i] == XRecordAllClients)
+ continue;
+ if (errorspec && (CLIENT_BITS(clientspecs[i]) == errorspec) )
+ return BadMatch;
+ clientIndex = CLIENT_ID(clientspecs[i]);
+ if (clientIndex && clients[clientIndex] &&
+ clients[clientIndex]->clientState == ClientStateRunning)
+ {
+ if (clientspecs[i] == clients[clientIndex]->clientAsMask)
+ continue;
+ if (!LookupIDByClass(clientspecs[i], RC_ANY))
+ return BadMatch;
+ }
+ else
+ return BadMatch;
+ }
+ return Success;
+} /* RecordSanityCheckClientSpecifiers */
+
+
+/* RecordCanonicalizeClientSpecifiers
+ *
+ * Arguments:
+ * pClientspecs is an array of CLIENTSPECs that have been sanity
+ * checked.
+ * pNumClientspecs is a pointer to the number of elements in pClientspecs.
+ * excludespec, if non-zero, is the resource id base of a client that
+ * should not be included in the expansion of XRecordAllClients or
+ * XRecordCurrentClients.
+ *
+ * Returns:
+ * A pointer to an array of CLIENTSPECs that is the same as the
+ * passed array with the following modifications:
+ * - all but the client id bits of resource IDs are stripped off.
+ * - duplicates removed.
+ * - XRecordAllClients expanded to a list of all currently connected
+ * clients + XRecordFutureClients - excludespec (if non-zero)
+ * - XRecordCurrentClients expanded to a list of all currently
+ * connected clients - excludespec (if non-zero)
+ * The returned array may be the passed array modified in place, or
+ * it may be an Xalloc'ed array. The caller should keep a pointer to the
+ * original array and free the returned array if it is different.
+ *
+ * *pNumClientspecs is set to the number of elements in the returned
+ * array.
+ *
+ * Side Effects:
+ * pClientspecs may be modified in place.
+ */
+static XID *
+RecordCanonicalizeClientSpecifiers(pClientspecs, pNumClientspecs, excludespec)
+ XID *pClientspecs;
+ int *pNumClientspecs;
+ XID excludespec;
+{
+ int i;
+ int numClients = *pNumClientspecs;
+
+ /* first pass strips off the resource index bits, leaving just the
+ * client id bits. This makes searching for a particular client simpler
+ * (and faster.)
+ */
+ for (i = 0; i < numClients; i++)
+ {
+ XID cs = pClientspecs[i];
+ if (cs > XRecordAllClients)
+ pClientspecs[i] = CLIENT_BITS(cs);
+ }
+
+ for (i = 0; i < numClients; i++)
+ {
+ if (pClientspecs[i] == XRecordAllClients ||
+ pClientspecs[i] == XRecordCurrentClients)
+ { /* expand All/Current */
+ int j, nc;
+ XID *pCanon = (XID *)xalloc(sizeof(XID) * (currentMaxClients + 1));
+ if (!pCanon) return NULL;
+ for (nc = 0, j = 1; j < currentMaxClients; j++)
+ {
+ ClientPtr client = clients[j];
+ if (client != NullClient &&
+ client->clientState == ClientStateRunning &&
+ client->clientAsMask != excludespec)
+ {
+ pCanon[nc++] = client->clientAsMask;
+ }
+ }
+ if (pClientspecs[i] == XRecordAllClients)
+ pCanon[nc++] = XRecordFutureClients;
+ *pNumClientspecs = nc;
+ return pCanon;
+ }
+ else /* not All or Current */
+ {
+ int j;
+ for (j = i + 1; j < numClients; )
+ {
+ if (pClientspecs[i] == pClientspecs[j])
+ {
+ pClientspecs[j] = pClientspecs[--numClients];
+ }
+ else
+ j++;
+ }
+ }
+ } /* end for each clientspec */
+ *pNumClientspecs = numClients;
+ return pClientspecs;
+} /* RecordCanonicalizeClientSpecifiers */
+
+
+/****************************************************************************/
+
+/* stuff for RegisterClients */
+
+/* RecordPadAlign
+ *
+ * Arguments:
+ * size is the number of bytes taken by an object.
+ * align is a byte boundary (e.g. 4, 8)
+ *
+ * Returns:
+ * the number of pad bytes to add at the end of an object of the
+ * given size so that an object placed immediately behind it will
+ * begin on an <align>-byte boundary.
+ *
+ * Side Effects: none.
+ */
+static int
+RecordPadAlign(int size, int align)
+{
+ return (align - (size & (align - 1))) & (align - 1);
+} /* RecordPadAlign */
+
+
+/* RecordSanityCheckRegisterClients
+ *
+ * Arguments:
+ * pContext is the context being registered on.
+ * client is the client that issued a RecordCreateContext or
+ * RecordRegisterClients request.
+ * stuff is a pointer to the request.
+ *
+ * Returns:
+ * Any one of several possible error values if any of the request
+ * arguments are invalid. Success if everything is OK.
+ *
+ * Side Effects: none.
+ */
+static int
+RecordSanityCheckRegisterClients(pContext, client, stuff)
+ RecordContextPtr pContext;
+ ClientPtr client;
+ xRecordRegisterClientsReq *stuff;
+{
+ int err;
+ xRecordRange *pRange;
+ int i;
+ XID recordingClient;
+
+ if (((client->req_len << 2) - SIZEOF(xRecordRegisterClientsReq)) !=
+ 4 * stuff->nClients + SIZEOF(xRecordRange) * stuff->nRanges)
+ return BadLength;
+
+ if (stuff->elementHeader &
+ ~(XRecordFromClientSequence|XRecordFromClientTime|XRecordFromServerTime))
+ {
+ client->errorValue = stuff->elementHeader;
+ return BadValue;
+ }
+
+ recordingClient = pContext->pRecordingClient ?
+ pContext->pRecordingClient->clientAsMask : 0;
+ err = RecordSanityCheckClientSpecifiers((XID *)&stuff[1], stuff->nClients,
+ recordingClient);
+ if (err != Success) return err;
+
+ pRange = (xRecordRange *)(((XID *)&stuff[1]) + stuff->nClients);
+ for (i = 0; i < stuff->nRanges; i++, pRange++)
+ {
+ if (pRange->coreRequestsFirst > pRange->coreRequestsLast)
+ {
+ client->errorValue = pRange->coreRequestsFirst;
+ return BadValue;
+ }
+ if (pRange->coreRepliesFirst > pRange->coreRepliesLast)
+ {
+ client->errorValue = pRange->coreRepliesFirst;
+ return BadValue;
+ }
+ if ((pRange->extRequestsMajorFirst || pRange->extRequestsMajorLast) &&
+ (pRange->extRequestsMajorFirst < 128 ||
+ pRange->extRequestsMajorLast < 128 ||
+ pRange->extRequestsMajorFirst > pRange->extRequestsMajorLast))
+ {
+ client->errorValue = pRange->extRequestsMajorFirst;
+ return BadValue;
+ }
+ if (pRange->extRequestsMinorFirst > pRange->extRequestsMinorLast)
+ {
+ client->errorValue = pRange->extRequestsMinorFirst;
+ return BadValue;
+ }
+ if ((pRange->extRepliesMajorFirst || pRange->extRepliesMajorLast) &&
+ (pRange->extRepliesMajorFirst < 128 ||
+ pRange->extRepliesMajorLast < 128 ||
+ pRange->extRepliesMajorFirst > pRange->extRepliesMajorLast))
+ {
+ client->errorValue = pRange->extRepliesMajorFirst;
+ return BadValue;
+ }
+ if (pRange->extRepliesMinorFirst > pRange->extRepliesMinorLast)
+ {
+ client->errorValue = pRange->extRepliesMinorFirst;
+ return BadValue;
+ }
+ if ((pRange->deliveredEventsFirst || pRange->deliveredEventsLast) &&
+ (pRange->deliveredEventsFirst < 2 ||
+ pRange->deliveredEventsLast < 2 ||
+ pRange->deliveredEventsFirst > pRange->deliveredEventsLast))
+ {
+ client->errorValue = pRange->deliveredEventsFirst;
+ return BadValue;
+ }
+ if ((pRange->deviceEventsFirst || pRange->deviceEventsLast) &&
+ (pRange->deviceEventsFirst < 2 ||
+ pRange->deviceEventsLast < 2 ||
+ pRange->deviceEventsFirst > pRange->deviceEventsLast))
+ {
+ client->errorValue = pRange->deviceEventsFirst;
+ return BadValue;
+ }
+ if (pRange->errorsFirst > pRange->errorsLast)
+ {
+ client->errorValue = pRange->errorsFirst;
+ return BadValue;
+ }
+ if (pRange->clientStarted != xFalse && pRange->clientStarted != xTrue)
+ {
+ client->errorValue = pRange->clientStarted;
+ return BadValue;
+ }
+ if (pRange->clientDied != xFalse && pRange->clientDied != xTrue)
+ {
+ client->errorValue = pRange->clientDied;
+ return BadValue;
+ }
+ } /* end for each range */
+ return Success;
+} /* end RecordSanityCheckRegisterClients */
+
+/* This is a tactical structure used to gather information about all the sets
+ * (RecordSetPtr) that need to be created for an RCAP in the process of
+ * digesting a list of RECORDRANGEs (converting it to the internal
+ * representation).
+ */
+typedef struct
+{
+ int nintervals; /* number of intervals in following array */
+ RecordSetInterval *intervals; /* array of intervals for this set */
+ int size; /* size of intevals array; >= nintervals */
+ int align; /* alignment restriction for set */
+ int offset; /* where to store set pointer rel. to start of RCAP */
+ short first, last; /* if for extension, major opcode interval */
+} SetInfoRec, *SetInfoPtr;
+
+/* These constant are used to index into an array of SetInfoRec. */
+enum {REQ, /* set info for requests */
+ REP, /* set info for replies */
+ ERR, /* set info for errors */
+ DEV, /* set info for device events */
+ DLEV, /* set info for delivered events */
+ PREDEFSETS}; /* number of predefined array entries */
+
+
+/* RecordAllocIntervals
+ *
+ * Arguments:
+ * psi is a pointer to a SetInfoRec whose intervals pointer is NULL.
+ * nIntervals is the desired size of the intervals array.
+ *
+ * Returns: BadAlloc if a memory allocation error occurred, else Success.
+ *
+ * Side Effects:
+ * If Success is returned, psi->intervals is a pointer to size
+ * RecordSetIntervals, all zeroed, and psi->size is set to size.
+ */
+static int
+RecordAllocIntervals(psi, nIntervals)
+ SetInfoPtr psi;
+ int nIntervals;
+{
+ assert(!psi->intervals);
+ psi->intervals = (RecordSetInterval *)
+ xalloc(nIntervals * sizeof(RecordSetInterval));
+ if (!psi->intervals)
+ return BadAlloc;
+ bzero(psi->intervals, nIntervals * sizeof(RecordSetInterval));
+ psi->size = nIntervals;
+ return Success;
+} /* end RecordAllocIntervals */
+
+
+/* RecordConvertRangesToIntervals
+ *
+ * Arguments:
+ * psi is a pointer to the SetInfoRec we are building.
+ * pRanges is an array of xRecordRanges.
+ * nRanges is the number of elements in pRanges.
+ * byteoffset is the offset from the start of an xRecordRange of the
+ * two bytes (1 for first, 1 for last) we are interested in.
+ * pExtSetInfo, if non-NULL, indicates that the two bytes mentioned
+ * above are followed by four bytes (2 for first, 2 for last)
+ * representing a minor opcode range, and this information should be
+ * stored in one of the SetInfoRecs starting at pExtSetInfo.
+ * pnExtSetInfo is the number of elements in the pExtSetInfo array.
+ *
+ * Returns: BadAlloc if a memory allocation error occurred, else Success.
+ *
+ * Side Effects:
+ * The slice of pRanges indicated by byteoffset is stored in psi.
+ * If pExtSetInfo is non-NULL, minor opcode intervals are stored
+ * in an existing SetInfoRec if the major opcode interval matches, else
+ * they are stored in a new SetInfoRec, and *pnExtSetInfo is
+ * increased accordingly.
+ */
+static int
+RecordConvertRangesToIntervals(
+ SetInfoPtr psi,
+ xRecordRange *pRanges,
+ int nRanges,
+ int byteoffset,
+ SetInfoPtr pExtSetInfo,
+ int *pnExtSetInfo
+)
+{
+ int i;
+ CARD8 *pCARD8;
+ int first, last;
+ int err;
+
+ for (i = 0; i < nRanges; i++, pRanges++)
+ {
+ pCARD8 = ((CARD8 *)pRanges) + byteoffset;
+ first = pCARD8[0];
+ last = pCARD8[1];
+ if (first || last)
+ {
+ if (!psi->intervals)
+ {
+ err = RecordAllocIntervals(psi, 2 * (nRanges - i));
+ if (err != Success)
+ return err;
+ }
+ psi->intervals[psi->nintervals].first = first;
+ psi->intervals[psi->nintervals].last = last;
+ psi->nintervals++;
+ assert(psi->nintervals <= psi->size);
+ if (pExtSetInfo)
+ {
+ SetInfoPtr pesi = pExtSetInfo;
+ CARD16 *pCARD16 = (CARD16 *)(pCARD8 + 2);
+ int j;
+
+ for (j = 0; j < *pnExtSetInfo; j++, pesi++)
+ {
+ if ( (first == pesi->first) && (last == pesi->last) )
+ break;
+ }
+ if (j == *pnExtSetInfo)
+ {
+ err = RecordAllocIntervals(pesi, 2 * (nRanges - i));
+ if (err != Success)
+ return err;
+ pesi->first = first;
+ pesi->last = last;
+ (*pnExtSetInfo)++;
+ }
+ pesi->intervals[pesi->nintervals].first = pCARD16[0];
+ pesi->intervals[pesi->nintervals].last = pCARD16[1];
+ pesi->nintervals++;
+ assert(pesi->nintervals <= pesi->size);
+ }
+ }
+ }
+ return Success;
+} /* end RecordConvertRangesToIntervals */
+
+#define offset_of(_structure, _field) \
+ ((char *)(& (_structure . _field)) - (char *)(&_structure))
+
+/* RecordRegisterClients
+ *
+ * Arguments:
+ * pContext is the context on which to register the clients.
+ * client is the client that issued the RecordCreateContext or
+ * RecordRegisterClients request.
+ * stuff is a pointer to the request.
+ *
+ * Returns:
+ * Any one of several possible error values defined by the protocol.
+ * Success if everything is OK.
+ *
+ * Side Effects:
+ * If different element headers are specified, the context is flushed.
+ * If any of the specified clients are already registered on the
+ * context, they are first unregistered. A new RCAP is created to
+ * hold the specified protocol and clients, and it is linked onto the
+ * context. If the context is enabled, appropriate hooks are installed
+ * to record the new clients and protocol.
+ */
+static int
+RecordRegisterClients(pContext, client, stuff)
+ RecordContextPtr pContext;
+ ClientPtr client;
+ xRecordRegisterClientsReq *stuff;
+{
+ int err;
+ int i;
+ SetInfoPtr si;
+ int maxSets;
+ int nExtReqSets = 0;
+ int nExtRepSets = 0;
+ int extReqSetsOffset = 0;
+ int extRepSetsOffset = 0;
+ SetInfoPtr pExtReqSets, pExtRepSets;
+ int clientListOffset;
+ XID *pCanonClients;
+ int clientStarted = 0, clientDied = 0;
+ xRecordRange *pRanges, rr;
+ int nClients;
+ int sizeClients;
+ int totRCAPsize;
+ RecordClientsAndProtocolPtr pRCAP;
+ int pad;
+ XID recordingClient;
+
+ /* do all sanity checking up front */
+
+ err = RecordSanityCheckRegisterClients(pContext, client, stuff);
+ if (err != Success)
+ return err;
+
+ /* if element headers changed, flush buffer */
+
+ if (pContext->elemHeaders != stuff->elementHeader)
+ {
+ RecordFlushReplyBuffer(pContext, NULL, 0, NULL, 0);
+ pContext->elemHeaders = stuff->elementHeader;
+ }
+
+ nClients = stuff->nClients;
+ if (!nClients)
+ /* if empty clients list, we're done. */
+ return Success;
+
+ recordingClient = pContext->pRecordingClient ?
+ pContext->pRecordingClient->clientAsMask : 0;
+ pCanonClients = RecordCanonicalizeClientSpecifiers((XID *)&stuff[1],
+ &nClients, recordingClient);
+ if (!pCanonClients)
+ return BadAlloc;
+
+ /* We may have to create as many as one set for each "predefined"
+ * protocol types, plus one per range for extension reuests, plus one per
+ * range for extension replies.
+ */
+ maxSets = PREDEFSETS + 2 * stuff->nRanges;
+ si = (SetInfoPtr)ALLOCATE_LOCAL(sizeof(SetInfoRec) * maxSets);
+ if (!si)
+ {
+ err = BadAlloc;
+ goto bailout;
+ }
+ bzero(si, sizeof(SetInfoRec) * maxSets);
+
+ /* theoretically you must do this because NULL may not be all-bits-zero */
+ for (i = 0; i < maxSets; i++)
+ si[i].intervals = NULL;
+
+ pExtReqSets = si + PREDEFSETS;
+ pExtRepSets = pExtReqSets + stuff->nRanges;
+
+ pRanges = (xRecordRange *)(((XID *)&stuff[1]) + stuff->nClients);
+
+ err = RecordConvertRangesToIntervals(&si[REQ], pRanges, stuff->nRanges,
+ offset_of(rr, coreRequestsFirst), NULL, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertRangesToIntervals(&si[REQ], pRanges, stuff->nRanges,
+ offset_of(rr, extRequestsMajorFirst), pExtReqSets, &nExtReqSets);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertRangesToIntervals(&si[REP], pRanges, stuff->nRanges,
+ offset_of(rr, coreRepliesFirst), NULL, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertRangesToIntervals(&si[REP], pRanges, stuff->nRanges,
+ offset_of(rr, extRepliesMajorFirst), pExtRepSets, &nExtRepSets);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertRangesToIntervals(&si[ERR], pRanges, stuff->nRanges,
+ offset_of(rr, errorsFirst), NULL, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertRangesToIntervals(&si[DLEV], pRanges, stuff->nRanges,
+ offset_of(rr, deliveredEventsFirst), NULL, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertRangesToIntervals(&si[DEV], pRanges, stuff->nRanges,
+ offset_of(rr, deviceEventsFirst), NULL, NULL);
+ if (err != Success) goto bailout;
+
+ /* collect client-started and client-died */
+
+ for (i = 0; i < stuff->nRanges; i++)
+ {
+ if (pRanges[i].clientStarted) clientStarted = TRUE;
+ if (pRanges[i].clientDied) clientDied = TRUE;
+ }
+
+ /* We now have all the information collected to create all the sets,
+ * and we can compute the total memory required for the RCAP.
+ */
+
+ totRCAPsize = sizeof(RecordClientsAndProtocolRec);
+
+ /* leave a little room to grow before forcing a separate allocation */
+ sizeClients = nClients + CLIENT_ARRAY_GROWTH_INCREMENT;
+ pad = RecordPadAlign(totRCAPsize, sizeof(XID));
+ clientListOffset = totRCAPsize + pad;
+ totRCAPsize += pad + sizeClients * sizeof(XID);
+
+ if (nExtReqSets)
+ {
+ pad = RecordPadAlign(totRCAPsize, sizeof(RecordSetPtr));
+ extReqSetsOffset = totRCAPsize + pad;
+ totRCAPsize += pad + (nExtReqSets + 1) * sizeof(RecordMinorOpRec);
+ }
+ if (nExtRepSets)
+ {
+ pad = RecordPadAlign(totRCAPsize, sizeof(RecordSetPtr));
+ extRepSetsOffset = totRCAPsize + pad;
+ totRCAPsize += pad + (nExtRepSets + 1) * sizeof(RecordMinorOpRec);
+ }
+
+ for (i = 0; i < maxSets; i++)
+ {
+ if (si[i].nintervals)
+ {
+ si[i].size = RecordSetMemoryRequirements(
+ si[i].intervals, si[i].nintervals, &si[i].align);
+ pad = RecordPadAlign(totRCAPsize, si[i].align);
+ si[i].offset = pad + totRCAPsize;
+ totRCAPsize += pad + si[i].size;
+ }
+ }
+
+ /* allocate memory for the whole RCAP */
+
+ pRCAP = (RecordClientsAndProtocolPtr)xalloc(totRCAPsize);
+ if (!pRCAP)
+ {
+ err = BadAlloc;
+ goto bailout;
+ }
+
+ /* fill in the RCAP */
+
+ pRCAP->pContext = pContext;
+ pRCAP->pClientIDs = (XID *)((char *)pRCAP + clientListOffset);
+ pRCAP->numClients = nClients;
+ pRCAP->sizeClients = sizeClients;
+ pRCAP->clientIDsSeparatelyAllocated = 0;
+ for (i = 0; i < nClients; i++)
+ {
+ RecordDeleteClientFromContext(pContext, pCanonClients[i]);
+ pRCAP->pClientIDs[i] = pCanonClients[i];
+ }
+
+ /* create all the sets */
+
+ if (si[REQ].intervals)
+ {
+ pRCAP->pRequestMajorOpSet =
+ RecordCreateSet(si[REQ].intervals, si[REQ].nintervals,
+ (RecordSetPtr)((char *)pRCAP + si[REQ].offset), si[REQ].size);
+ }
+ else pRCAP->pRequestMajorOpSet = NULL;
+
+ if (si[REP].intervals)
+ {
+ pRCAP->pReplyMajorOpSet =
+ RecordCreateSet(si[REP].intervals, si[REP].nintervals,
+ (RecordSetPtr)((char *)pRCAP + si[REP].offset), si[REP].size);
+ }
+ else pRCAP->pReplyMajorOpSet = NULL;
+
+ if (si[ERR].intervals)
+ {
+ pRCAP->pErrorSet =
+ RecordCreateSet(si[ERR].intervals, si[ERR].nintervals,
+ (RecordSetPtr)((char *)pRCAP + si[ERR].offset), si[ERR].size);
+ }
+ else pRCAP->pErrorSet = NULL;
+
+ if (si[DEV].intervals)
+ {
+ pRCAP->pDeviceEventSet =
+ RecordCreateSet(si[DEV].intervals, si[DEV].nintervals,
+ (RecordSetPtr)((char *)pRCAP + si[DEV].offset), si[DEV].size);
+ }
+ else pRCAP->pDeviceEventSet = NULL;
+
+ if (si[DLEV].intervals)
+ {
+ pRCAP->pDeliveredEventSet =
+ RecordCreateSet(si[DLEV].intervals, si[DLEV].nintervals,
+ (RecordSetPtr)((char *)pRCAP + si[DLEV].offset), si[DLEV].size);
+ }
+ else pRCAP->pDeliveredEventSet = NULL;
+
+ if (nExtReqSets)
+ {
+ pRCAP->pRequestMinOpInfo = (RecordMinorOpPtr)
+ ((char *)pRCAP + extReqSetsOffset);
+ pRCAP->pRequestMinOpInfo[0].count = nExtReqSets;
+ for (i = 0; i < nExtReqSets; i++, pExtReqSets++)
+ {
+ pRCAP->pRequestMinOpInfo[i+1].major.first = pExtReqSets->first;
+ pRCAP->pRequestMinOpInfo[i+1].major.last = pExtReqSets->last;
+ pRCAP->pRequestMinOpInfo[i+1].major.pMinOpSet =
+ RecordCreateSet(pExtReqSets->intervals,
+ pExtReqSets->nintervals,
+ (RecordSetPtr)((char *)pRCAP + pExtReqSets->offset),
+ pExtReqSets->size);
+ }
+ }
+ else pRCAP->pRequestMinOpInfo = NULL;
+
+ if (nExtRepSets)
+ {
+ pRCAP->pReplyMinOpInfo = (RecordMinorOpPtr)
+ ((char *)pRCAP + extRepSetsOffset);
+ pRCAP->pReplyMinOpInfo[0].count = nExtRepSets;
+ for (i = 0; i < nExtRepSets; i++, pExtRepSets++)
+ {
+ pRCAP->pReplyMinOpInfo[i+1].major.first = pExtRepSets->first;
+ pRCAP->pReplyMinOpInfo[i+1].major.last = pExtRepSets->last;
+ pRCAP->pReplyMinOpInfo[i+1].major.pMinOpSet =
+ RecordCreateSet(pExtRepSets->intervals,
+ pExtRepSets->nintervals,
+ (RecordSetPtr)((char *)pRCAP + pExtRepSets->offset),
+ pExtRepSets->size);
+ }
+ }
+ else pRCAP->pReplyMinOpInfo = NULL;
+
+ pRCAP->clientStarted = clientStarted;
+ pRCAP->clientDied = clientDied;
+
+ /* link the RCAP onto the context */
+
+ pRCAP->pNextRCAP = pContext->pListOfRCAP;
+ pContext->pListOfRCAP = pRCAP;
+
+ if (pContext->pRecordingClient) /* context enabled */
+ RecordInstallHooks(pRCAP, 0);
+
+bailout:
+ if (si)
+ {
+ for (i = 0; i < maxSets; i++)
+ if (si[i].intervals)
+ xfree(si[i].intervals);
+ DEALLOCATE_LOCAL(si);
+ }
+ if (pCanonClients && pCanonClients != (XID *)&stuff[1])
+ xfree(pCanonClients);
+ return err;
+} /* RecordRegisterClients */
+
+
+/* Proc functions all take a client argument, execute the request in
+ * client->requestBuffer, and return a protocol error status.
+ */
+
+static int
+ProcRecordQueryVersion(client)
+ ClientPtr client;
+{
+ /* REQUEST(xRecordQueryVersionReq); */
+ xRecordQueryVersionReply rep;
+ int n;
+
+ REQUEST_SIZE_MATCH(xRecordQueryVersionReq);
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.majorVersion = RECORD_MAJOR_VERSION;
+ rep.minorVersion = RECORD_MINOR_VERSION;
+ if(client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ }
+ (void)WriteToClient(client, sizeof(xRecordQueryVersionReply),
+ (char *)&rep);
+ return (client->noClientException);
+} /* ProcRecordQueryVersion */
+
+
+static int
+ProcRecordCreateContext(client)
+ ClientPtr client;
+{
+ REQUEST(xRecordCreateContextReq);
+ RecordContextPtr pContext;
+ RecordContextPtr *ppNewAllContexts = NULL;
+ int err = BadAlloc;
+
+ REQUEST_AT_LEAST_SIZE(xRecordCreateContextReq);
+ LEGAL_NEW_RESOURCE(stuff->context, client);
+
+ pContext = (RecordContextPtr)xalloc(sizeof(RecordContextRec));
+ if (!pContext)
+ goto bailout;
+
+ /* make sure there is room in ppAllContexts to store the new context */
+
+ ppNewAllContexts = (RecordContextPtr *)
+ xrealloc(ppAllContexts, sizeof(RecordContextPtr) * (numContexts + 1));
+ if (!ppNewAllContexts)
+ goto bailout;
+ ppAllContexts = ppNewAllContexts;
+
+ pContext->id = stuff->context;
+ pContext->pRecordingClient = NULL;
+ pContext->pListOfRCAP = NULL;
+ pContext->elemHeaders = 0;
+ pContext->bufCategory = 0;
+ pContext->numBufBytes = 0;
+ pContext->pBufClient = NULL;
+ pContext->continuedReply = 0;
+
+ err = RecordRegisterClients(pContext, client,
+ (xRecordRegisterClientsReq *)stuff);
+ if (err != Success)
+ goto bailout;
+
+ if (AddResource(pContext->id, RTContext, pContext))
+ {
+ ppAllContexts[numContexts++] = pContext;
+ return Success;
+ }
+ else
+ {
+ RecordDeleteContext((pointer)pContext, pContext->id);
+ err = BadAlloc;
+ }
+bailout:
+ if (pContext)
+ xfree(pContext);
+ return err;
+} /* ProcRecordCreateContext */
+
+
+static int
+ProcRecordRegisterClients(client)
+ ClientPtr client;
+{
+ RecordContextPtr pContext;
+ REQUEST(xRecordRegisterClientsReq);
+
+ REQUEST_AT_LEAST_SIZE(xRecordRegisterClientsReq);
+ VERIFY_CONTEXT(pContext, stuff->context, client);
+
+ return RecordRegisterClients(pContext, client, stuff);
+} /* ProcRecordRegisterClients */
+
+
+static int
+ProcRecordUnregisterClients(client)
+ ClientPtr client;
+{
+ RecordContextPtr pContext;
+ int err;
+ REQUEST(xRecordUnregisterClientsReq);
+ XID *pCanonClients;
+ int nClients;
+ int i;
+
+ REQUEST_AT_LEAST_SIZE(xRecordUnregisterClientsReq);
+ if ((client->req_len << 2) - SIZEOF(xRecordUnregisterClientsReq) !=
+ 4 * stuff->nClients)
+ return BadLength;
+ VERIFY_CONTEXT(pContext, stuff->context, client);
+ err = RecordSanityCheckClientSpecifiers((XID *)&stuff[1],
+ stuff->nClients, 0);
+ if (err != Success)
+ return err;
+
+ nClients = stuff->nClients;
+ pCanonClients = RecordCanonicalizeClientSpecifiers((XID *)&stuff[1],
+ &nClients, 0);
+ if (!pCanonClients)
+ return BadAlloc;
+
+ for (i = 0; i < nClients; i++)
+ {
+ RecordDeleteClientFromContext(pContext, pCanonClients[i]);
+ }
+ if (pCanonClients != (XID *)&stuff[1])
+ xfree(pCanonClients);
+ return Success;
+} /* ProcRecordUnregisterClients */
+
+
+/****************************************************************************/
+
+/* stuff for GetContext */
+
+/* This is a tactical structure used to hold the xRecordRanges as they are
+ * being reconstituted from the sets in the RCAPs.
+ */
+
+typedef struct {
+ xRecordRange *pRanges; /* array of xRecordRanges for one RCAP */
+ int size; /* number of elements in pRanges, >= nRanges */
+ int nRanges; /* number of occupied element of pRanges */
+} GetContextRangeInfoRec, *GetContextRangeInfoPtr;
+
+
+/* RecordAllocRanges
+ *
+ * Arguments:
+ * pri is a pointer to a GetContextRangeInfoRec to allocate for.
+ * nRanges is the number of xRecordRanges desired for pri.
+ *
+ * Returns: BadAlloc if a memory allocation error occurred, else Success.
+ *
+ * Side Effects:
+ * If Success is returned, pri->pRanges points to at least nRanges
+ * ranges. pri->nRanges is set to nRanges. pri->size is the actual
+ * number of ranges. Newly allocated ranges are zeroed.
+ */
+static int
+RecordAllocRanges(pri, nRanges)
+ GetContextRangeInfoPtr pri;
+ int nRanges;
+{
+ int newsize;
+ xRecordRange *pNewRange;
+#define SZINCR 8
+
+ newsize = max(pri->size + SZINCR, nRanges);
+ pNewRange = (xRecordRange *)xrealloc(pri->pRanges,
+ newsize * sizeof(xRecordRange));
+ if (!pNewRange)
+ return BadAlloc;
+
+ pri->pRanges = pNewRange;
+ pri->size = newsize;
+ bzero(&pri->pRanges[pri->size - SZINCR], SZINCR * sizeof(xRecordRange));
+ if (pri->nRanges < nRanges)
+ pri->nRanges = nRanges;
+ return Success;
+} /* RecordAllocRanges */
+
+
+/* RecordConvertSetToRanges
+ *
+ * Arguments:
+ * pSet is the set to be converted.
+ * pri is where the result should be stored.
+ * byteoffset is the offset from the start of an xRecordRange of the
+ * two vales (first, last) we are interested in.
+ * card8 is TRUE if the vales are one byte each and FALSE if two bytes
+ * each.
+ * imax is the largest set value to store in pri->pRanges.
+ * pStartIndex, if non-NULL, is the index of the first range in
+ * pri->pRanges that should be stored to. If NULL,
+ * start at index 0.
+ *
+ * Returns: BadAlloc if a memory allocation error occurred, else Success.
+ *
+ * Side Effects:
+ * If Success is returned, the slice of pri->pRanges indicated by
+ * byteoffset and card8 is filled in with the intervals from pSet.
+ * if pStartIndex was non-NULL, *pStartIndex is filled in with one
+ * more than the index of the last xRecordRange that was touched.
+ */
+static int
+RecordConvertSetToRanges(
+ RecordSetPtr pSet,
+ GetContextRangeInfoPtr pri,
+ int byteoffset,
+ Bool card8,
+ unsigned int imax,
+ int *pStartIndex
+)
+{
+ int nRanges;
+ RecordSetIteratePtr pIter = NULL;
+ RecordSetInterval interval;
+ CARD8 *pCARD8;
+ CARD16 *pCARD16;
+ int err;
+
+ if (!pSet)
+ return Success;
+
+ nRanges = pStartIndex ? *pStartIndex : 0;
+ while ((pIter = RecordIterateSet(pSet, pIter, &interval)))
+ {
+ if (interval.first > imax) break;
+ if (interval.last > imax) interval.last = imax;
+ nRanges++;
+ if (nRanges > pri->size)
+ {
+ err = RecordAllocRanges(pri, nRanges);
+ if (err != Success)
+ return err;
+ }
+ else
+ pri->nRanges = max(pri->nRanges, nRanges);
+ if (card8)
+ {
+ pCARD8 = ((CARD8 *)&pri->pRanges[nRanges-1]) + byteoffset;
+ *pCARD8++ = interval.first;
+ *pCARD8 = interval.last;
+ }
+ else
+ {
+ pCARD16 = (CARD16 *)
+ (((char *)&pri->pRanges[nRanges-1]) + byteoffset);
+ *pCARD16++ = interval.first;
+ *pCARD16 = interval.last;
+ }
+ }
+ if (pStartIndex)
+ *pStartIndex = nRanges;
+ return Success;
+} /* RecordConvertSetToRanges */
+
+
+/* RecordConvertMinorOpInfoToRanges
+ *
+ * Arguments:
+ * pMinOpInfo is the minor opcode info to convert to xRecordRanges.
+ * pri is where the result should be stored.
+ * byteoffset is the offset from the start of an xRecordRange of the
+ * four vales (CARD8 major_first, CARD8 major_last,
+ * CARD16 minor_first, CARD16 minor_last) we are going to store.
+ *
+ * Returns: BadAlloc if a memory allocation error occurred, else Success.
+ *
+ * Side Effects:
+ * If Success is returned, the slice of pri->pRanges indicated by
+ * byteoffset is filled in with the information from pMinOpInfo.
+ */
+static int
+RecordConvertMinorOpInfoToRanges(
+ RecordMinorOpPtr pMinOpInfo,
+ GetContextRangeInfoPtr pri,
+ int byteoffset
+)
+{
+ int nsets;
+ int start;
+ int i;
+ int err;
+
+ if (!pMinOpInfo)
+ return Success;
+
+ nsets = pMinOpInfo->count;
+ pMinOpInfo++;
+ start = 0;
+ for (i = 0; i < nsets; i++)
+ {
+ int j, s;
+ s = start;
+ err = RecordConvertSetToRanges(pMinOpInfo[i].major.pMinOpSet, pri,
+ byteoffset + 2, FALSE, 65535, &start);
+ if (err != Success) return err;
+ for (j = s; j < start; j++)
+ {
+ CARD8 *pCARD8 = ((CARD8 *)&pri->pRanges[j]) + byteoffset;
+ *pCARD8++ = pMinOpInfo[i].major.first;
+ *pCARD8 = pMinOpInfo[i].major.last;
+ }
+ }
+ return Success;
+} /* RecordConvertMinorOpInfoToRanges */
+
+
+/* RecordSwapRanges
+ *
+ * Arguments:
+ * pRanges is an array of xRecordRanges.
+ * nRanges is the number of elements in pRanges.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * The 16 bit fields of each xRecordRange are byte swapped.
+ */
+static void
+RecordSwapRanges(pRanges, nRanges)
+ xRecordRange *pRanges;
+ int nRanges;
+{
+ int i;
+ register char n;
+ for (i = 0; i < nRanges; i++, pRanges++)
+ {
+ swaps(&pRanges->extRequestsMinorFirst, n);
+ swaps(&pRanges->extRequestsMinorLast, n);
+ swaps(&pRanges->extRepliesMinorFirst, n);
+ swaps(&pRanges->extRepliesMinorLast, n);
+ }
+} /* RecordSwapRanges */
+
+
+static int
+ProcRecordGetContext(client)
+ ClientPtr client;
+{
+ RecordContextPtr pContext;
+ REQUEST(xRecordGetContextReq);
+ xRecordGetContextReply rep;
+ int n;
+ RecordClientsAndProtocolPtr pRCAP;
+ int nRCAPs = 0;
+ GetContextRangeInfoPtr pRangeInfo;
+ GetContextRangeInfoPtr pri;
+ int i;
+ int err;
+
+ REQUEST_SIZE_MATCH(xRecordGetContextReq);
+ VERIFY_CONTEXT(pContext, stuff->context, client);
+
+ /* how many RCAPs are there on this context? */
+
+ for (pRCAP = pContext->pListOfRCAP; pRCAP; pRCAP = pRCAP->pNextRCAP)
+ nRCAPs++;
+
+ /* allocate and initialize space for record range info */
+
+ pRangeInfo = (GetContextRangeInfoPtr)ALLOCATE_LOCAL(
+ nRCAPs * sizeof(GetContextRangeInfoRec));
+ if (!pRangeInfo && nRCAPs > 0)
+ return BadAlloc;
+ for (i = 0; i < nRCAPs; i++)
+ {
+ pRangeInfo[i].pRanges = NULL;
+ pRangeInfo[i].size = 0;
+ pRangeInfo[i].nRanges = 0;
+ }
+
+ /* convert the RCAP (internal) representation of the recorded protocol
+ * to the wire protocol (external) representation, storing the information
+ * for the ith RCAP in pri[i]
+ */
+
+ for (pRCAP = pContext->pListOfRCAP, pri = pRangeInfo;
+ pRCAP;
+ pRCAP = pRCAP->pNextRCAP, pri++)
+ {
+ xRecordRange rr;
+
+ err = RecordConvertSetToRanges(pRCAP->pRequestMajorOpSet, pri,
+ offset_of(rr, coreRequestsFirst), TRUE, 127, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertSetToRanges(pRCAP->pReplyMajorOpSet, pri,
+ offset_of(rr, coreRepliesFirst), TRUE, 127, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertSetToRanges(pRCAP->pDeliveredEventSet, pri,
+ offset_of(rr, deliveredEventsFirst), TRUE, 255, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertSetToRanges(pRCAP->pDeviceEventSet, pri,
+ offset_of(rr, deviceEventsFirst), TRUE, 255, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertSetToRanges(pRCAP->pErrorSet, pri,
+ offset_of(rr, errorsFirst), TRUE, 255, NULL);
+ if (err != Success) goto bailout;
+
+ err = RecordConvertMinorOpInfoToRanges(pRCAP->pRequestMinOpInfo,
+ pri, offset_of(rr, extRequestsMajorFirst));
+ if (err != Success) goto bailout;
+
+ err = RecordConvertMinorOpInfoToRanges(pRCAP->pReplyMinOpInfo,
+ pri, offset_of(rr, extRepliesMajorFirst));
+ if (err != Success) goto bailout;
+
+ if (pRCAP->clientStarted || pRCAP->clientDied)
+ {
+ if (pri->nRanges == 0)
+ RecordAllocRanges(pri, 1);
+ pri->pRanges[0].clientStarted = pRCAP->clientStarted;
+ pri->pRanges[0].clientDied = pRCAP->clientDied;
+ }
+ }
+
+ /* calculate number of clients and reply length */
+
+ rep.nClients = 0;
+ rep.length = 0;
+ for (pRCAP = pContext->pListOfRCAP, pri = pRangeInfo;
+ pRCAP;
+ pRCAP = pRCAP->pNextRCAP, pri++)
+ {
+ rep.nClients += pRCAP->numClients;
+ rep.length += pRCAP->numClients *
+ ( (sizeof(xRecordClientInfo) >> 2) +
+ pri->nRanges * (sizeof(xRecordRange) >> 2));
+ }
+
+ /* write the reply header */
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.enabled = pContext->pRecordingClient != NULL;
+ rep.elementHeader = pContext->elemHeaders;
+ if(client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.nClients, n);
+ }
+ (void)WriteToClient(client, sizeof(xRecordGetContextReply),
+ (char *)&rep);
+
+ /* write all the CLIENT_INFOs */
+
+ for (pRCAP = pContext->pListOfRCAP, pri = pRangeInfo;
+ pRCAP;
+ pRCAP = pRCAP->pNextRCAP, pri++)
+ {
+ xRecordClientInfo rci;
+ rci.nRanges = pri->nRanges;
+ if (client->swapped)
+ {
+ swapl(&rci.nRanges, n);
+ RecordSwapRanges(pri->pRanges, pri->nRanges);
+ }
+ for (i = 0; i < pRCAP->numClients; i++)
+ {
+ rci.clientResource = pRCAP->pClientIDs[i];
+ if (client->swapped) swapl(&rci.clientResource, n);
+ WriteToClient(client, sizeof(xRecordClientInfo), (char *)&rci);
+ WriteToClient(client, sizeof(xRecordRange) * pri->nRanges,
+ (char *)pri->pRanges);
+ }
+ }
+ err = client->noClientException;
+
+bailout:
+ for (i = 0; i < nRCAPs; i++)
+ {
+ if (pRangeInfo[i].pRanges) xfree(pRangeInfo[i].pRanges);
+ }
+ DEALLOCATE_LOCAL(pRangeInfo);
+ return err;
+} /* ProcRecordGetContext */
+
+
+static int
+ProcRecordEnableContext(client)
+ ClientPtr client;
+{
+ RecordContextPtr pContext;
+ REQUEST(xRecordEnableContextReq);
+ int i;
+ RecordClientsAndProtocolPtr pRCAP;
+
+ REQUEST_SIZE_MATCH(xRecordGetContextReq);
+ VERIFY_CONTEXT(pContext, stuff->context, client);
+ if (pContext->pRecordingClient)
+ return BadMatch; /* already enabled */
+
+ /* install record hooks for each RCAP */
+
+ for (pRCAP = pContext->pListOfRCAP; pRCAP; pRCAP = pRCAP->pNextRCAP)
+ {
+ int err = RecordInstallHooks(pRCAP, 0);
+ if (err != Success)
+ { /* undo the previous installs */
+ RecordClientsAndProtocolPtr pUninstallRCAP;
+ for (pUninstallRCAP = pContext->pListOfRCAP;
+ pUninstallRCAP != pRCAP;
+ pUninstallRCAP = pUninstallRCAP->pNextRCAP)
+ {
+ RecordUninstallHooks(pUninstallRCAP, 0);
+ }
+ return err;
+ }
+ }
+
+ /* Disallow further request processing on this connection until
+ * the context is disabled.
+ */
+ IgnoreClient(client);
+ pContext->pRecordingClient = client;
+
+ /* Don't allow the data connection to record itself; unregister it. */
+ RecordDeleteClientFromContext(pContext,
+ pContext->pRecordingClient->clientAsMask);
+
+ /* move the newly enabled context to the front part of ppAllContexts,
+ * where all the enabled contexts are
+ */
+ i = RecordFindContextOnAllContexts(pContext);
+ assert(i >= numEnabledContexts);
+ if (i != numEnabledContexts)
+ {
+ ppAllContexts[i] = ppAllContexts[numEnabledContexts];
+ ppAllContexts[numEnabledContexts] = pContext;
+ }
+
+ ++numEnabledContexts;
+ assert(numEnabledContexts > 0);
+
+ /* send StartOfData */
+ RecordAProtocolElement(pContext, NULL, XRecordStartOfData, NULL, 0, 0);
+ RecordFlushReplyBuffer(pContext, NULL, 0, NULL, 0);
+ return Success;
+} /* ProcRecordEnableContext */
+
+
+/* RecordDisableContext
+ *
+ * Arguments:
+ * pContext is the context to disable.
+ * nRanges is the number of elements in pRanges.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * If the context was enabled, it is disabled. An EndOfData
+ * message is sent to the recording client. Recording hooks for
+ * this context are uninstalled. The context is moved to the
+ * rear part of the ppAllContexts array. numEnabledContexts is
+ * decremented. Request processing for the formerly recording client
+ * is resumed.
+ */
+static void
+RecordDisableContext(pContext)
+ RecordContextPtr pContext;
+{
+ RecordClientsAndProtocolPtr pRCAP;
+ int i;
+
+ if (!pContext->pRecordingClient) return;
+ if (!pContext->pRecordingClient->clientGone)
+ {
+ RecordAProtocolElement(pContext, NULL, XRecordEndOfData, NULL, 0, 0);
+ RecordFlushReplyBuffer(pContext, NULL, 0, NULL, 0);
+ /* Re-enable request processing on this connection. */
+ AttendClient(pContext->pRecordingClient);
+ }
+
+ for (pRCAP = pContext->pListOfRCAP; pRCAP; pRCAP = pRCAP->pNextRCAP)
+ {
+ RecordUninstallHooks(pRCAP, 0);
+ }
+
+ pContext->pRecordingClient = NULL;
+
+ /* move the newly disabled context to the rear part of ppAllContexts,
+ * where all the disabled contexts are
+ */
+ i = RecordFindContextOnAllContexts(pContext);
+ assert( (i != -1) && (i < numEnabledContexts) );
+ if (i != (numEnabledContexts - 1) )
+ {
+ ppAllContexts[i] = ppAllContexts[numEnabledContexts-1];
+ ppAllContexts[numEnabledContexts-1] = pContext;
+ }
+ --numEnabledContexts;
+ assert(numEnabledContexts >= 0);
+} /* RecordDisableContext */
+
+
+static int
+ProcRecordDisableContext(client)
+ ClientPtr client;
+{
+ RecordContextPtr pContext;
+ REQUEST(xRecordDisableContextReq);
+
+ REQUEST_SIZE_MATCH(xRecordDisableContextReq);
+ VERIFY_CONTEXT(pContext, stuff->context, client);
+ RecordDisableContext(pContext);
+ return Success;
+} /* ProcRecordDisableContext */
+
+
+/* RecordDeleteContext
+ *
+ * Arguments:
+ * value is the context to delete.
+ * id is its resource ID.
+ *
+ * Returns: Success.
+ *
+ * Side Effects:
+ * Disables the context, frees all associated memory, and removes
+ * it from the ppAllContexts array.
+ */
+static int
+RecordDeleteContext(value, id)
+ pointer value;
+ XID id;
+{
+ int i;
+ RecordContextPtr pContext = (RecordContextPtr)value;
+ RecordClientsAndProtocolPtr pRCAP;
+
+ RecordDisableContext(pContext);
+
+ /* Remove all the clients from all the RCAPs.
+ * As a result, the RCAPs will be freed.
+ */
+
+ while ((pRCAP = pContext->pListOfRCAP))
+ {
+ int numClients = pRCAP->numClients;
+ /* when the last client is deleted, the RCAP will go away. */
+ while(numClients--)
+ {
+ RecordDeleteClientFromRCAP(pRCAP, numClients);
+ }
+ }
+
+ xfree(pContext);
+
+ /* remove context from AllContexts list */
+
+ if (-1 != (i = RecordFindContextOnAllContexts(pContext)))
+ {
+ ppAllContexts[i] = ppAllContexts[numContexts - 1];
+ if (--numContexts == 0)
+ {
+ xfree(ppAllContexts);
+ ppAllContexts = NULL;
+ }
+ }
+ return Success;
+} /* RecordDeleteContext */
+
+
+static int
+ProcRecordFreeContext(client)
+ ClientPtr client;
+{
+ RecordContextPtr pContext;
+ REQUEST(xRecordFreeContextReq);
+
+ REQUEST_SIZE_MATCH(xRecordFreeContextReq);
+ VERIFY_CONTEXT(pContext, stuff->context, client);
+ FreeResource(stuff->context, RT_NONE);
+ return Success;
+} /* ProcRecordFreeContext */
+
+
+static int
+ProcRecordDispatch(client)
+ ClientPtr client;
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_RecordQueryVersion:
+ return ProcRecordQueryVersion(client);
+ case X_RecordCreateContext:
+ return ProcRecordCreateContext(client);
+ case X_RecordRegisterClients:
+ return ProcRecordRegisterClients(client);
+ case X_RecordUnregisterClients:
+ return ProcRecordUnregisterClients(client);
+ case X_RecordGetContext:
+ return ProcRecordGetContext(client);
+ case X_RecordEnableContext:
+ return ProcRecordEnableContext(client);
+ case X_RecordDisableContext:
+ return ProcRecordDisableContext(client);
+ case X_RecordFreeContext:
+ return ProcRecordFreeContext(client);
+ default:
+ return BadRequest;
+ }
+} /* ProcRecordDispatch */
+
+
+static int
+SProcRecordQueryVersion(client)
+ ClientPtr client;
+{
+ REQUEST(xRecordQueryVersionReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xRecordQueryVersionReq);
+ swaps(&stuff->majorVersion, n);
+ swaps(&stuff->minorVersion,n);
+ return ProcRecordQueryVersion(client);
+} /* SProcRecordQueryVersion */
+
+
+static void
+SwapCreateRegister(xRecordRegisterClientsReq *stuff)
+{
+ register char n;
+ int i;
+ XID *pClientID;
+
+ swapl(&stuff->context, n);
+ swapl(&stuff->nClients, n);
+ swapl(&stuff->nRanges, n);
+ pClientID = (XID *)&stuff[1];
+ for (i = 0; i < stuff->nClients; i++, pClientID++)
+ {
+ swapl(pClientID, n);
+ }
+ RecordSwapRanges((xRecordRange *)pClientID, stuff->nRanges);
+} /* SwapCreateRegister */
+
+
+static int
+SProcRecordCreateContext(client)
+ ClientPtr client;
+{
+ REQUEST(xRecordCreateContextReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xRecordCreateContextReq);
+ SwapCreateRegister((pointer)stuff);
+ return ProcRecordCreateContext(client);
+} /* SProcRecordCreateContext */
+
+
+static int
+SProcRecordRegisterClients(client)
+ ClientPtr client;
+{
+ REQUEST(xRecordRegisterClientsReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xRecordRegisterClientsReq);
+ SwapCreateRegister((pointer)stuff);
+ return ProcRecordRegisterClients(client);
+} /* SProcRecordRegisterClients */
+
+
+static int
+SProcRecordUnregisterClients(client)
+ ClientPtr client;
+{
+ REQUEST(xRecordUnregisterClientsReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xRecordUnregisterClientsReq);
+ swapl(&stuff->context, n);
+ swapl(&stuff->nClients, n);
+ SwapRestL(stuff);
+ return ProcRecordUnregisterClients(client);
+} /* SProcRecordUnregisterClients */
+
+
+static int
+SProcRecordGetContext(client)
+ ClientPtr client;
+{
+ REQUEST(xRecordGetContextReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xRecordGetContextReq);
+ swapl(&stuff->context, n);
+ return ProcRecordGetContext(client);
+} /* SProcRecordGetContext */
+
+static int
+SProcRecordEnableContext(client)
+ ClientPtr client;
+{
+ REQUEST(xRecordEnableContextReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xRecordEnableContextReq);
+ swapl(&stuff->context, n);
+ return ProcRecordEnableContext(client);
+} /* SProcRecordEnableContext */
+
+
+static int
+SProcRecordDisableContext(client)
+ ClientPtr client;
+{
+ REQUEST(xRecordDisableContextReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xRecordDisableContextReq);
+ swapl(&stuff->context, n);
+ return ProcRecordDisableContext(client);
+} /* SProcRecordDisableContext */
+
+
+static int
+SProcRecordFreeContext(client)
+ ClientPtr client;
+{
+ REQUEST(xRecordFreeContextReq);
+ register char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xRecordFreeContextReq);
+ swapl(&stuff->context, n);
+ return ProcRecordFreeContext(client);
+} /* SProcRecordFreeContext */
+
+
+static int
+SProcRecordDispatch(client)
+ ClientPtr client;
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_RecordQueryVersion:
+ return SProcRecordQueryVersion(client);
+ case X_RecordCreateContext:
+ return SProcRecordCreateContext(client);
+ case X_RecordRegisterClients:
+ return SProcRecordRegisterClients(client);
+ case X_RecordUnregisterClients:
+ return SProcRecordUnregisterClients(client);
+ case X_RecordGetContext:
+ return SProcRecordGetContext(client);
+ case X_RecordEnableContext:
+ return SProcRecordEnableContext(client);
+ case X_RecordDisableContext:
+ return SProcRecordDisableContext(client);
+ case X_RecordFreeContext:
+ return SProcRecordFreeContext(client);
+ default:
+ return BadRequest;
+ }
+} /* SProcRecordDispatch */
+
+/* XXX goes in header file */
+extern void SwapConnSetupInfo(), SwapConnSetupPrefix();
+
+/* RecordConnectionSetupInfo
+ *
+ * Arguments:
+ * pContext is an enabled context that specifies recording of
+ * connection setup info.
+ * pci holds the connection setup info.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * The connection setup info is sent to the recording client.
+ */
+static void
+RecordConnectionSetupInfo(pContext, pci)
+ RecordContextPtr pContext;
+ NewClientInfoRec *pci;
+{
+ int prefixsize = SIZEOF(xConnSetupPrefix);
+ int restsize = pci->prefix->length * 4;
+
+ if (pci->client->swapped)
+ {
+ char * pConnSetup = (char *)ALLOCATE_LOCAL(prefixsize + restsize);
+ if (!pConnSetup)
+ return;
+ SwapConnSetupPrefix(pci->prefix, pConnSetup);
+ SwapConnSetupInfo(pci->setup, pConnSetup + prefixsize);
+ RecordAProtocolElement(pContext, pci->client, XRecordClientStarted,
+ (pointer)pConnSetup, prefixsize + restsize, 0);
+ DEALLOCATE_LOCAL(pConnSetup);
+ }
+ else
+ {
+ /* don't alloc and copy as in the swapped case; just send the
+ * data in two pieces
+ */
+ RecordAProtocolElement(pContext, pci->client, XRecordClientStarted,
+ (pointer)pci->prefix, prefixsize, restsize);
+ RecordAProtocolElement(pContext, pci->client, XRecordClientStarted,
+ (pointer)pci->setup, restsize, /* continuation */ -1);
+ }
+} /* RecordConnectionSetupInfo */
+
+
+/* RecordDeleteContext
+ *
+ * Arguments:
+ * pcbl is &ClientStateCallback.
+ * nullata is NULL.
+ * calldata is a pointer to a NewClientInfoRec (include/dixstruct.h)
+ * which contains information about client state changes.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * If a new client has connected and any contexts have specified
+ * XRecordFutureClients, the new client is registered on those contexts.
+ * If any of those contexts specify recording of the connection setup
+ * info, it is recorded.
+ *
+ * If an existing client has disconnected, it is deleted from any
+ * contexts that it was registered on. If any of those contexts
+ * specified XRecordClientDied, they record a ClientDied protocol element.
+ * If the disconnectiong client happened to be the data connection of an
+ * enabled context, the context is disabled.
+ */
+
+static void
+RecordAClientStateChange(pcbl, nulldata, calldata)
+ CallbackListPtr *pcbl;
+ pointer nulldata;
+ pointer calldata;
+{
+ NewClientInfoRec *pci = (NewClientInfoRec *)calldata;
+ int i;
+ ClientPtr pClient = pci->client;
+
+ switch (pClient->clientState)
+ {
+ case ClientStateRunning: /* new client */
+ for (i = 0; i < numContexts; i++)
+ {
+ RecordClientsAndProtocolPtr pRCAP;
+ RecordContextPtr pContext = ppAllContexts[i];
+
+ if ((pRCAP = RecordFindClientOnContext(pContext,
+ XRecordFutureClients, NULL)))
+ {
+ RecordAddClientToRCAP(pRCAP, pClient->clientAsMask);
+ if (pContext->pRecordingClient && pRCAP->clientStarted)
+ RecordConnectionSetupInfo(pContext, pci);
+ }
+ }
+ break;
+
+ case ClientStateGone:
+ case ClientStateRetained: /* client disconnected */
+ for (i = 0; i < numContexts; i++)
+ {
+ RecordClientsAndProtocolPtr pRCAP;
+ RecordContextPtr pContext = ppAllContexts[i];
+ int pos;
+
+ if (pContext->pRecordingClient == pClient)
+ RecordDisableContext(pContext);
+ if ((pRCAP = RecordFindClientOnContext(pContext,
+ pClient->clientAsMask, &pos)))
+ {
+ if (pContext->pRecordingClient && pRCAP->clientDied)
+ RecordAProtocolElement(pContext, pClient,
+ XRecordClientDied, NULL, 0, 0);
+ RecordDeleteClientFromRCAP(pRCAP, pos);
+ }
+ }
+ break;
+
+ default:
+ break;
+ } /* end switch on client state */
+} /* RecordAClientStateChange */
+
+
+/* RecordCloseDown
+ *
+ * Arguments:
+ * extEntry is the extension information for RECORD.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Performs any cleanup needed by RECORD at server shutdown time.
+ *
+ */
+static void
+RecordCloseDown(extEntry)
+ ExtensionEntry *extEntry;
+{
+ DeleteCallback(&ClientStateCallback, RecordAClientStateChange, NULL);
+} /* RecordCloseDown */
+
+
+/* RecordExtensionInit
+ *
+ * Arguments: none.
+ *
+ * Returns: nothing.
+ *
+ * Side Effects:
+ * Enables the RECORD extension if possible.
+ */
+void
+RecordExtensionInit()
+{
+ ExtensionEntry *extentry;
+
+ RTContext = CreateNewResourceType(RecordDeleteContext);
+ if (!RTContext)
+ return;
+
+ RecordClientPrivateIndex = AllocateClientPrivateIndex();
+ if (!AllocateClientPrivate(RecordClientPrivateIndex, 0))
+ return;
+
+ ppAllContexts = NULL;
+ numContexts = numEnabledContexts = numEnabledRCAPs = 0;
+
+ if (!AddCallback(&ClientStateCallback, RecordAClientStateChange, NULL))
+ return;
+
+ extentry = AddExtension(RECORD_NAME, RecordNumEvents, RecordNumErrors,
+ ProcRecordDispatch, SProcRecordDispatch,
+ RecordCloseDown, StandardMinorOpcode);
+ if (!extentry)
+ {
+ DeleteCallback(&ClientStateCallback, RecordAClientStateChange, NULL);
+ return;
+ }
+ RecordErrorBase = extentry->errorBase;
+
+} /* RecordExtensionInit */
+
diff --git a/nx-X11/programs/Xserver/record/recordmod.c b/nx-X11/programs/Xserver/record/recordmod.c
new file mode 100644
index 000000000..5afb1d379
--- /dev/null
+++ b/nx-X11/programs/Xserver/record/recordmod.c
@@ -0,0 +1,46 @@
+/* $XFree86: xc/programs/Xserver/record/recordmod.c,v 1.5 1999/01/26 05:54:21 dawes Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Module.h"
+
+extern Bool noTestExtensions;
+
+static MODULESETUPPROTO(recordSetup);
+
+extern void RecordExtensionInit(INITARGS);
+
+ExtensionModule recordExt = {
+ RecordExtensionInit,
+ "RECORD",
+ &noTestExtensions,
+ NULL,
+ NULL
+};
+
+static XF86ModuleVersionInfo VersRec = {
+ "record",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 13, 0,
+ ABI_CLASS_EXTENSION,
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_EXTENSION,
+ {0,0,0,0}
+};
+
+XF86ModuleData recordModuleData = { &VersRec, recordSetup, NULL };
+
+static pointer
+recordSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ LoadExtension(&recordExt, FALSE);
+
+ /* Need a non-NULL return value to indicate success */
+ return (pointer)1;
+}
+
diff --git a/nx-X11/programs/Xserver/record/set.c b/nx-X11/programs/Xserver/record/set.c
new file mode 100644
index 000000000..83fb0e7d7
--- /dev/null
+++ b/nx-X11/programs/Xserver/record/set.c
@@ -0,0 +1,710 @@
+/* $Xorg: set.c,v 1.4 2001/02/09 02:05:27 xorgcvs Exp $ */
+
+/*
+
+Copyright 1995, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/record/set.c,v 1.7 2001/12/14 20:00:37 dawes Exp $ */
+
+/*
+
+ See the header set.h for a description of the set ADT.
+
+ Implementation Strategy
+
+ A bit vector is an obvious choice to represent the set, but may take
+ too much memory, depending on the numerically largest member in the
+ set. One expected common case is for the client to ask for *all*
+ protocol. This means it would ask for minor opcodes 0 through 65535.
+ Representing this as a bit vector takes 8K -- and there may be
+ multiple minor opcode intervals, as many as one per major (extension)
+ opcode). In such cases, a list-of-intervals representation would be
+ preferable to reduce memory consumption. Both representations will be
+ implemented, and RecordCreateSet will decide heuristically which one
+ to use based on the set members.
+
+ Note: When compiling for use in the server, do not use -DTESTING.
+ When compiling for stand-alone testing of the set ADT, use -DTESTING.
+
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef TESTING
+#include "misc.h"
+#else
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* stuff that you normally get from the X Server's environment */
+
+typedef int Bool;
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
+typedef unsigned short CARD16;
+
+#define xalloc malloc
+#define xfree free
+#define ALLOCATE_LOCAL malloc
+#define DEALLOCATE_LOCAL free
+
+void *Xcalloc(size)
+ int size;
+{
+ void *p = malloc(size);
+ if (p) memset(p, 0, size);
+ return p;
+}
+
+#ifndef max
+#define max(_a, _b) ( ((_a) > (_b)) ? (_a) : (_b) )
+#endif
+
+#endif /* TESTING */
+
+#include "set.h"
+
+#ifdef XFree86LOADER
+#include "xf86_libc.h"
+#include "xf86_ansic.h"
+#endif
+
+static int
+maxMemberInInterval(pIntervals, nIntervals)
+ RecordSetInterval *pIntervals;
+ int nIntervals;
+{
+ int i;
+ int maxMember = -1;
+ for (i = 0; i < nIntervals; i++)
+ {
+ if (maxMember < (int)pIntervals[i].last)
+ maxMember = pIntervals[i].last;
+ }
+ return maxMember;
+}
+
+static void
+NoopDestroySet(pSet)
+ RecordSetPtr pSet;
+{
+}
+
+/***************************************************************************/
+
+/* set operations for bit vector representation */
+
+typedef struct {
+ RecordSetRec baseSet;
+ int maxMember;
+ /* followed by the bit vector itself */
+} BitVectorSet, *BitVectorSetPtr;
+
+#define BITS_PER_LONG (sizeof(unsigned long) * 8)
+
+static void
+BitVectorDestroySet(pSet)
+ RecordSetPtr pSet;
+{
+ xfree(pSet);
+}
+
+static unsigned long
+BitVectorIsMemberOfSet(pSet, pm)
+ RecordSetPtr pSet;
+ int pm;
+{
+ BitVectorSetPtr pbvs = (BitVectorSetPtr)pSet;
+ unsigned long *pbitvec;
+
+ if ((int)pm > pbvs->maxMember) return FALSE;
+ pbitvec = (unsigned long *)(&pbvs[1]);
+ return (pbitvec[pm / BITS_PER_LONG] & ((unsigned long)1 << (pm % BITS_PER_LONG)));
+}
+
+
+static int
+BitVectorFindBit(pSet, iterbit, bitval)
+ RecordSetPtr pSet;
+ int iterbit;
+ Bool bitval;
+{
+ BitVectorSetPtr pbvs = (BitVectorSetPtr)pSet;
+ unsigned long *pbitvec = (unsigned long *)(&pbvs[1]);
+ int startlong;
+ int startbit;
+ int walkbit;
+ int maxMember;
+ unsigned long skipval;
+ unsigned long bits;
+ unsigned long usefulbits;
+
+ startlong = iterbit / BITS_PER_LONG;
+ pbitvec += startlong;
+ startbit = startlong * BITS_PER_LONG;
+ skipval = bitval ? 0L : ~0L;
+ maxMember = pbvs->maxMember;
+
+
+ if (startbit > maxMember) return -1;
+ bits = *pbitvec;
+ usefulbits = ~(((unsigned long)1 << (iterbit - startbit)) - 1);
+ if ( (bits & usefulbits) == (skipval & usefulbits) )
+ {
+ pbitvec++;
+ startbit += BITS_PER_LONG;
+
+ while (startbit <= maxMember && *pbitvec == skipval)
+ {
+ pbitvec++;
+ startbit += BITS_PER_LONG;
+ }
+ if (startbit > maxMember) return -1;
+ }
+
+ walkbit = (startbit < iterbit) ? iterbit - startbit : 0;
+
+ bits = *pbitvec;
+ while (walkbit < BITS_PER_LONG && ((!(bits & ((unsigned long)1 << walkbit))) == bitval))
+ walkbit++;
+
+ return startbit + walkbit;
+}
+
+
+static RecordSetIteratePtr
+BitVectorIterateSet(pSet, pIter, pInterval)
+ RecordSetPtr pSet;
+ RecordSetIteratePtr pIter;
+ RecordSetInterval *pInterval;
+{
+ int iterbit = (int)(long)pIter;
+ int b;
+
+ b = BitVectorFindBit(pSet, iterbit, TRUE);
+ if (b == -1) return (RecordSetIteratePtr)0;
+ pInterval->first = b;
+
+ b = BitVectorFindBit(pSet, b, FALSE);
+ pInterval->last = (b < 0) ? ((BitVectorSetPtr)pSet)->maxMember : b - 1;
+ return (RecordSetIteratePtr)(long)(pInterval->last + 1);
+}
+
+RecordSetOperations BitVectorSetOperations = {
+ BitVectorDestroySet, BitVectorIsMemberOfSet, BitVectorIterateSet };
+
+RecordSetOperations BitVectorNoFreeOperations = {
+ NoopDestroySet, BitVectorIsMemberOfSet, BitVectorIterateSet };
+
+static int
+BitVectorSetMemoryRequirements(pIntervals, nIntervals, maxMember, alignment)
+ RecordSetInterval *pIntervals;
+ int nIntervals;
+ int maxMember;
+ int *alignment;
+{
+ int nlongs;
+
+ *alignment = sizeof(unsigned long);
+ nlongs = (maxMember + BITS_PER_LONG) / BITS_PER_LONG;
+ return (sizeof(BitVectorSet) + nlongs * sizeof(unsigned long));
+}
+
+static RecordSetPtr
+BitVectorCreateSet(pIntervals, nIntervals, pMem, memsize)
+ RecordSetInterval *pIntervals;
+ int nIntervals;
+ void *pMem;
+ int memsize;
+{
+ BitVectorSetPtr pbvs;
+ int i, j;
+ unsigned long *pbitvec;
+
+ /* allocate all storage needed by this set in one chunk */
+
+ if (pMem)
+ {
+ memset(pMem, 0, memsize);
+ pbvs = (BitVectorSetPtr)pMem;
+ pbvs->baseSet.ops = &BitVectorNoFreeOperations;
+ }
+ else
+ {
+ pbvs = (BitVectorSetPtr)Xcalloc(memsize);
+ if (!pbvs) return NULL;
+ pbvs->baseSet.ops = &BitVectorSetOperations;
+ }
+
+ pbvs->maxMember = maxMemberInInterval(pIntervals, nIntervals);
+
+ /* fill in the set */
+
+ pbitvec = (unsigned long *)(&pbvs[1]);
+ for (i = 0; i < nIntervals; i++)
+ {
+ for (j = pIntervals[i].first; j <= (int)pIntervals[i].last; j++)
+ {
+ pbitvec[j/BITS_PER_LONG] |= ((unsigned long)1 << (j % BITS_PER_LONG));
+ }
+ }
+ return (RecordSetPtr)pbvs;
+}
+
+
+/***************************************************************************/
+
+/* set operations for interval list representation */
+
+typedef struct {
+ RecordSetRec baseSet;
+ int nIntervals;
+ /* followed by the intervals (RecordSetInterval) */
+} IntervalListSet, *IntervalListSetPtr;
+
+static void
+IntervalListDestroySet(pSet)
+ RecordSetPtr pSet;
+{
+ xfree(pSet);
+}
+
+static unsigned long
+IntervalListIsMemberOfSet(pSet, pm)
+ RecordSetPtr pSet;
+ int pm;
+{
+ IntervalListSetPtr prls = (IntervalListSetPtr)pSet;
+ RecordSetInterval *pInterval = (RecordSetInterval *)(&prls[1]);
+ int hi, lo, probe;
+
+ /* binary search */
+ lo = 0; hi = prls->nIntervals - 1;
+ while (lo <= hi)
+ {
+ probe = (hi + lo) / 2;
+ if (pm >= pInterval[probe].first && pm <= pInterval[probe].last) return 1;
+ else if (pm < pInterval[probe].first) hi = probe - 1;
+ else lo = probe + 1;
+ }
+ return 0;
+}
+
+
+static RecordSetIteratePtr
+IntervalListIterateSet(pSet, pIter, pIntervalReturn)
+ RecordSetPtr pSet;
+ RecordSetIteratePtr pIter;
+ RecordSetInterval *pIntervalReturn;
+{
+ RecordSetInterval *pInterval = (RecordSetInterval *)pIter;
+ IntervalListSetPtr prls = (IntervalListSetPtr)pSet;
+
+ if (pInterval == NULL)
+ {
+ pInterval = (RecordSetInterval *)(&prls[1]);
+ }
+
+ if ( (pInterval - (RecordSetInterval *)(&prls[1])) < prls->nIntervals )
+ {
+ *pIntervalReturn = *pInterval;
+ return (RecordSetIteratePtr)(++pInterval);
+ }
+ else
+ return (RecordSetIteratePtr)NULL;
+}
+
+RecordSetOperations IntervalListSetOperations = {
+ IntervalListDestroySet, IntervalListIsMemberOfSet, IntervalListIterateSet };
+
+RecordSetOperations IntervalListNoFreeOperations = {
+ NoopDestroySet, IntervalListIsMemberOfSet, IntervalListIterateSet };
+
+static int
+IntervalListMemoryRequirements(pIntervals, nIntervals, maxMember, alignment)
+ RecordSetInterval *pIntervals;
+ int nIntervals;
+ int maxMember;
+ int *alignment;
+{
+ *alignment = sizeof(unsigned long);
+ return sizeof(IntervalListSet) + nIntervals * sizeof(RecordSetInterval);
+}
+
+static RecordSetPtr
+IntervalListCreateSet(pIntervals, nIntervals, pMem, memsize)
+ RecordSetInterval *pIntervals;
+ int nIntervals;
+ void *pMem;
+ int memsize;
+{
+ IntervalListSetPtr prls;
+ int i, j, k;
+ RecordSetInterval *stackIntervals = NULL;
+ CARD16 first;
+
+ if (nIntervals > 0)
+ {
+ stackIntervals = (RecordSetInterval *)ALLOCATE_LOCAL(
+ sizeof(RecordSetInterval) * nIntervals);
+ if (!stackIntervals) return NULL;
+
+ /* sort intervals, store in stackIntervals (insertion sort) */
+
+ for (i = 0; i < nIntervals; i++)
+ {
+ first = pIntervals[i].first;
+ for (j = 0; j < i; j++)
+ {
+ if (first < stackIntervals[j].first)
+ break;
+ }
+ for (k = i; k > j; k--)
+ {
+ stackIntervals[k] = stackIntervals[k-1];
+ }
+ stackIntervals[j] = pIntervals[i];
+ }
+
+ /* merge abutting/overlapping intervals */
+
+ for (i = 0; i < nIntervals - 1; )
+ {
+ if ( (stackIntervals[i].last + (unsigned int)1) <
+ stackIntervals[i + 1].first)
+ {
+ i++; /* disjoint intervals */
+ }
+ else
+ {
+ stackIntervals[i].last = max(stackIntervals[i].last,
+ stackIntervals[i + 1].last);
+ nIntervals--;
+ for (j = i + 1; j < nIntervals; j++)
+ stackIntervals[j] = stackIntervals[j + 1];
+ }
+ }
+ }
+
+ /* allocate and fill in set structure */
+
+ if (pMem)
+ {
+ prls = (IntervalListSetPtr)pMem;
+ prls->baseSet.ops = &IntervalListNoFreeOperations;
+ }
+ else
+ {
+ prls = (IntervalListSetPtr)
+ xalloc(sizeof(IntervalListSet) + nIntervals * sizeof(RecordSetInterval));
+ if (!prls) goto bailout;
+ prls->baseSet.ops = &IntervalListSetOperations;
+ }
+ memcpy(&prls[1], stackIntervals, nIntervals * sizeof(RecordSetInterval));
+ prls->nIntervals = nIntervals;
+bailout:
+ if (stackIntervals) DEALLOCATE_LOCAL(stackIntervals);
+ return (RecordSetPtr)prls;
+}
+
+#ifdef TESTING
+typedef enum {
+ BitVectorImplementation, IntervalListImplementation} RecordSetImplementation;
+
+RecordSetImplementation _RecordSetImpl;
+
+static void
+_RecordForceSetImplementation(setimpl)
+ RecordSetImplementation setimpl;
+{
+ _RecordSetImpl = setimpl;
+}
+#endif
+
+typedef RecordSetPtr (*RecordCreateSetProcPtr)(
+ RecordSetInterval *pIntervals,
+ int nIntervals,
+ void *pMem,
+ int memsize
+);
+
+static int
+_RecordSetMemoryRequirements(pIntervals, nIntervals, alignment, ppCreateSet)
+ RecordSetInterval *pIntervals;
+ int nIntervals;
+ int *alignment;
+ RecordCreateSetProcPtr *ppCreateSet;
+{
+ int bmsize, rlsize, bma, rla;
+ int maxMember;
+
+ /* find maximum member of set so we know how big to make the bit vector */
+ maxMember = maxMemberInInterval(pIntervals, nIntervals);
+
+ bmsize = BitVectorSetMemoryRequirements(pIntervals, nIntervals, maxMember,
+ &bma);
+ rlsize = IntervalListMemoryRequirements(pIntervals, nIntervals, maxMember,
+ &rla);
+#ifdef TESTING
+ if (_RecordSetImpl == BitVectorImplementation)
+#else
+ if ( ( (nIntervals > 1) && (maxMember <= 255) )
+ || (bmsize < rlsize) )
+#endif
+ {
+ *alignment = bma;
+ *ppCreateSet = BitVectorCreateSet;
+ return bmsize;
+ }
+ else
+ {
+ *alignment = rla;
+ *ppCreateSet = IntervalListCreateSet;
+ return rlsize;
+ }
+}
+
+/***************************************************************************/
+
+/* user-visible functions */
+
+int
+RecordSetMemoryRequirements(pIntervals, nIntervals, alignment)
+ RecordSetInterval *pIntervals;
+ int nIntervals;
+ int *alignment;
+{
+ RecordCreateSetProcPtr pCreateSet;
+ return _RecordSetMemoryRequirements(pIntervals, nIntervals, alignment,
+ &pCreateSet);
+}
+
+RecordSetPtr
+RecordCreateSet(pIntervals, nIntervals, pMem, memsize)
+ RecordSetInterval *pIntervals;
+ int nIntervals;
+ void *pMem;
+ int memsize;
+{
+ RecordCreateSetProcPtr pCreateSet;
+ int alignment;
+ int size;
+
+ size = _RecordSetMemoryRequirements(pIntervals, nIntervals, &alignment,
+ &pCreateSet);
+ if (pMem)
+ {
+ if ( ((long)pMem & (alignment-1) ) || memsize < size)
+ return NULL;
+ }
+ return (*pCreateSet)(pIntervals, nIntervals, pMem, size);
+}
+
+/***************************************************************************/
+
+#ifdef TESTING
+
+/*
+
+Test Strategy
+
+Having two set representations is convenient for testing because we
+can play them against each other. The test code will be able to
+specify which implementation to use. This breaks the encapsulation,
+but that seems acceptable for testing. The crux of the test loop
+looks like this:
+
+loop:
+ generate random list of Intervals
+
+ create set A using bit vector implementation
+ create set B using Interval list implementation
+
+ for each possible set member
+ if set A and set B disagree on whether this is a member error;
+
+ iterate over both sets, comparing the intervals returned by each.
+ if intervals or number of intervals are different error;
+
+ iterate over intervals of set A
+ for i = interval.first to interval.last
+ if i is not a member of set B error;
+
+ iterate over intervals of set B
+ for i = interval.first to interval.last
+ if i is not a member of set A error;
+
+ destroy sets A, B
+
+*/
+
+int GenerateRandomIntervals(pIntervals, maxintervals)
+ RecordSetInterval *pIntervals;
+ int maxintervals;
+{
+ int i, nIntervals;
+
+ nIntervals = rand() % maxintervals;
+
+ for (i = 0; i < nIntervals; i++)
+ {
+ pIntervals[i].first = rand();
+ pIntervals[i].last = pIntervals[i].first + rand();
+ }
+ return nIntervals;
+}
+
+#define MAXINTERVALS 100
+
+int main(argc, argv)
+ int argc;
+ char **argv;
+{
+ RecordSetPtr bs, rs;
+ RecordSetInterval br, rr;
+ RecordSetIteratePtr bi, ri;
+ CARD16 i;
+ int testcount;
+ RecordSetInterval intervals[MAXINTERVALS];
+ int nIntervals;
+ int bsize, rsize;
+ int balign, ralign;
+ int pad;
+
+ for (testcount = 0; 1; testcount++)
+ {
+ nIntervals = GenerateRandomIntervals(intervals, MAXINTERVALS);
+ printf("%d nIntervals %d\n", testcount, nIntervals);
+
+ if (testcount & 1)
+ {
+ _RecordForceSetImplementation(BitVectorImplementation);
+ bsize = RecordSetMemoryRequirements(intervals, nIntervals, &balign);
+ _RecordForceSetImplementation(IntervalListImplementation);
+ rsize = RecordSetMemoryRequirements(intervals, nIntervals, &ralign);
+ pad = (ralign - (bsize & (ralign - 1))) & (ralign - 1);
+ bs = (RecordSetPtr)xalloc(bsize + pad + rsize );
+ if (!bs)
+ {
+ fprintf(stderr, "%d: failed to alloc memory for sets\n",
+ testcount);
+ continue;
+ }
+ rs = (RecordSetPtr)(((char *)bs) + bsize + pad);
+ }
+ else
+ {
+ bs = rs = NULL;
+ bsize = rsize = 0;
+ }
+
+ _RecordForceSetImplementation(BitVectorImplementation);
+ bs = RecordCreateSet(intervals, nIntervals, bs, bsize);
+ _RecordForceSetImplementation(IntervalListImplementation);
+ rs = RecordCreateSet(intervals, nIntervals, rs, rsize);
+
+ if (!bs || !rs)
+ {
+ fprintf(stderr, "%d: failed to create sets\n", testcount);
+ continue;
+ }
+
+ for (i = 0; i < 65535; i++)
+ {
+ unsigned long b, r;
+
+ b = RecordIsMemberOfSet(bs, i);
+ r = RecordIsMemberOfSet(rs, i);
+ if ( (b && !r) || (!b && r) )
+ {
+ fprintf(stderr, "%d: isMemberOfSet %d\n",
+ testcount, (int)i);
+ }
+ }
+
+ bi = RecordIterateSet(bs, NULL, &br);
+ ri = RecordIterateSet(rs, NULL, &rr);
+
+ while (bi && ri)
+ {
+ if ( (rr.first != br.first) || (rr.last != br.last) )
+ {
+ fprintf(stderr, "%d: iterateSet interval value mismatch\n",
+ testcount);
+ }
+ bi = RecordIterateSet(bs, bi, &br);
+ ri = RecordIterateSet(rs, ri, &rr);
+ }
+ if (bi != ri)
+ {
+ fprintf(stderr, "%d: iterateSet interval count mismatch\n",
+ testcount);
+ }
+
+
+ bi = NULL;
+ while (bi = RecordIterateSet(bs, bi, &br))
+ {
+ for (i = br.first; i <= br.last; i++)
+ {
+ if (!RecordIsMemberOfSet(rs, i))
+ {
+ fprintf(stderr, "%d: iterateSet b / isMemberOfSet r %d\n",
+ testcount, (int)i);
+ }
+ }
+ }
+
+ ri = NULL;
+ while (ri = RecordIterateSet(rs, ri, &rr))
+ {
+ for (i = rr.first; i <= rr.last; i++)
+ {
+ if (!RecordIsMemberOfSet(bs, i) )
+ {
+ fprintf(stderr, "%d: iterateSet r / isMemberOfSet b %d\n",
+ testcount, (int)i);
+ }
+ }
+ }
+
+ RecordDestroySet(bs);
+ RecordDestroySet(rs);
+
+ if (testcount & 1)
+ {
+ xfree(bs);
+ }
+ }
+}
+
+#endif /* TESTING */
diff --git a/nx-X11/programs/Xserver/record/set.h b/nx-X11/programs/Xserver/record/set.h
new file mode 100644
index 000000000..6f0b872a1
--- /dev/null
+++ b/nx-X11/programs/Xserver/record/set.h
@@ -0,0 +1,150 @@
+/* $Xorg: set.h,v 1.4 2001/02/09 02:05:27 xorgcvs Exp $ */
+
+/*
+
+Copyright 1995, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86$ */
+
+/*
+ A Set Abstract Data Type (ADT) for the RECORD Extension
+ David P. Wiggins
+ 7/25/95
+
+ The RECORD extension server code needs to maintain sets of numbers
+ that designate protocol message types. In most cases the interval of
+ numbers starts at 0 and does not exceed 255, but in a few cases (minor
+ opcodes of extension requests) the maximum is 65535. This disparity
+ suggests that a single set representation may not be suitable for all
+ sets, especially given that server memory is precious. We introduce a
+ set ADT to hide implementation differences so that multiple
+ simultaneous set representations can exist. A single interface is
+ presented to the set user regardless of the implementation in use for
+ a particular set.
+
+ The existing RECORD SI appears to require only four set operations:
+ create (given a list of members), destroy, see if a particular number
+ is a member of the set, and iterate over the members of a set. Though
+ many more set operations are imaginable, to keep the code space down,
+ we won't provide any more operations than are needed.
+
+ The following types and functions/macros define the ADT.
+*/
+
+/* an interval of set members */
+typedef struct {
+ CARD16 first;
+ CARD16 last;
+} RecordSetInterval;
+
+typedef struct _RecordSetRec *RecordSetPtr; /* primary set type */
+
+typedef void *RecordSetIteratePtr;
+
+/* table of function pointers for set operations.
+ set users should never declare a variable of this type.
+*/
+typedef struct {
+ void (*DestroySet)(
+ RecordSetPtr pSet
+);
+ unsigned long (*IsMemberOfSet)(
+ RecordSetPtr pSet,
+ int possible_member
+);
+ RecordSetIteratePtr (*IterateSet)(
+ RecordSetPtr pSet,
+ RecordSetIteratePtr pIter,
+ RecordSetInterval *interval
+);
+} RecordSetOperations;
+
+/* "base class" for sets.
+ set users should never declare a variable of this type.
+ */
+typedef struct _RecordSetRec {
+ RecordSetOperations *ops;
+} RecordSetRec;
+
+RecordSetPtr RecordCreateSet(
+ RecordSetInterval *intervals,
+ int nintervals,
+ void *pMem,
+ int memsize
+);
+/*
+ RecordCreateSet creates and returns a new set having members specified
+ by intervals and nintervals. nintervals is the number of RecordSetInterval
+ structures pointed to by intervals. The elements belonging to the new
+ set are determined as follows. For each RecordSetInterval structure, the
+ elements between first and last inclusive are members of the new set.
+ If a RecordSetInterval's first field is greater than its last field, the
+ results are undefined. It is valid to create an empty set (nintervals ==
+ 0). If RecordCreateSet returns NULL, the set could not be created due
+ to resource constraints.
+*/
+
+int RecordSetMemoryRequirements(
+ RecordSetInterval * /*pIntervals*/,
+ int /*nintervals*/,
+ int * /*alignment*/
+);
+
+#define RecordDestroySet(_pSet) \
+ /* void */ (*_pSet->ops->DestroySet)(/* RecordSetPtr */ _pSet)
+/*
+ RecordDestroySet frees all resources used by _pSet. _pSet should not be
+ used after it is destroyed.
+*/
+
+#define RecordIsMemberOfSet(_pSet, _m) \
+ /* unsigned long */ (*_pSet->ops->IsMemberOfSet)(/* RecordSetPtr */ _pSet, \
+ /* int */ _m)
+/*
+ RecordIsMemberOfSet returns a non-zero value if _m is a member of
+ _pSet, else it returns zero.
+*/
+
+#define RecordIterateSet(_pSet, _pIter, _interval) \
+ /* RecordSetIteratePtr */ (*_pSet->ops->IterateSet)(/* RecordSetPtr */ _pSet,\
+ /* RecordSetIteratePtr */ _pIter, /* RecordSetInterval */ _interval)
+/*
+ RecordIterateSet returns successive intervals of members of _pSet. If
+ _pIter is NULL, the first interval of set members is copied into _interval.
+ The return value should be passed as _pIter in the next call to
+ RecordIterateSet to obtain the next interval. When the return value is
+ NULL, there were no more intervals in the set, and nothing is copied into
+ the _interval parameter. Intervals appear in increasing numerical order
+ with no overlap between intervals. As such, the list of intervals produced
+ by RecordIterateSet may not match the list of intervals that were passed
+ in RecordCreateSet. Typical usage:
+
+ pIter = NULL;
+ while (pIter = RecordIterateSet(pSet, pIter, &interval))
+ {
+ process interval;
+ }
+*/
diff --git a/nx-X11/programs/Xserver/render/Imakefile b/nx-X11/programs/Xserver/render/Imakefile
new file mode 100644
index 000000000..0d7ad152f
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/Imakefile
@@ -0,0 +1,46 @@
+XCOMM $XFree86: xc/programs/Xserver/render/Imakefile,v 1.10 2002/11/23 02:38:15 keithp Exp $
+#include <Server.tmpl>
+
+ SRCS = animcur.c \
+ filter.c \
+ glyph.c \
+ miglyph.c \
+ miindex.c \
+ mipict.c \
+ mirect.c \
+ mitrap.c \
+ mitri.c \
+ picture.c \
+ render.c \
+ renderedge.c
+
+ OBJS = animcur.o \
+ filter.o \
+ glyph.o \
+ miglyph.o \
+ miindex.o \
+ mipict.o \
+ mirect.o \
+ mitrap.o \
+ mitri.o \
+ picture.o \
+ render.o \
+ renderedge.o
+
+ INCLUDES = -I. -I../include -I../mi -I../../../include/fonts \
+ -I../fb -I../hw/kdrive -I$(EXTINCSRC) -I$(XINCLUDESRC) \
+ -I$(FONTINCSRC) -I../Xext
+ LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+
+NormalLibraryTarget(render,$(OBJS))
+NormalLibraryObjectRule()
+LintLibraryTarget(render,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
+
+InstallDriverSDKNonExecFile(glyphstr.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(mipict.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(picture.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(picturestr.h,$(DRIVERSDKINCLUDEDIR))
+
diff --git a/nx-X11/programs/Xserver/render/animcur.c b/nx-X11/programs/Xserver/render/animcur.c
new file mode 100644
index 000000000..e3915b2b8
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/animcur.c
@@ -0,0 +1,402 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/animcur.c,v 1.5tsi Exp $
+ *
+ * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * Animated cursors for X. Not specific to Render in any way, but
+ * stuck there because Render has the other cool cursor extension.
+ * Besides, everyone has Render.
+ *
+ * Implemented as a simple layer over the core cursor code; it
+ * creates composite cursors out of a set of static cursors and
+ * delta times between each image.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "servermd.h"
+#include "scrnintstr.h"
+#include "dixstruct.h"
+#include "cursorstr.h"
+#include "dixfontstr.h"
+#include "opaque.h"
+#include "picturestr.h"
+
+typedef struct _AnimCurElt {
+ CursorPtr pCursor; /* cursor to show */
+ CARD32 delay; /* in ms */
+} AnimCurElt;
+
+typedef struct _AnimCur {
+ int nelt; /* number of elements in the elts array */
+ AnimCurElt *elts; /* actually allocated right after the structure */
+} AnimCurRec, *AnimCurPtr;
+
+typedef struct _AnimScrPriv {
+ CursorPtr pCursor;
+ int elt;
+ CARD32 time;
+
+ CloseScreenProcPtr CloseScreen;
+
+ ScreenBlockHandlerProcPtr BlockHandler;
+
+ CursorLimitsProcPtr CursorLimits;
+ DisplayCursorProcPtr DisplayCursor;
+ SetCursorPositionProcPtr SetCursorPosition;
+ RealizeCursorProcPtr RealizeCursor;
+ UnrealizeCursorProcPtr UnrealizeCursor;
+ RecolorCursorProcPtr RecolorCursor;
+} AnimCurScreenRec, *AnimCurScreenPtr;
+
+typedef struct _AnimCurState {
+ CursorPtr pCursor;
+ ScreenPtr pScreen;
+ int elt;
+ CARD32 time;
+} AnimCurStateRec, *AnimCurStatePtr;
+
+static AnimCurStateRec animCurState;
+
+static unsigned char empty[4];
+
+static CursorBits animCursorBits = {
+ empty, empty, 2, 1, 1, 0, 0, 1
+};
+
+int AnimCurScreenPrivateIndex = -1;
+int AnimCurGeneration;
+
+#define IsAnimCur(c) ((c)->bits == &animCursorBits)
+#define GetAnimCur(c) ((AnimCurPtr) ((c) + 1))
+#define GetAnimCurScreen(s) ((AnimCurScreenPtr) ((s)->devPrivates[AnimCurScreenPrivateIndex].ptr))
+#define GetAnimCurScreenIfSet(s) ((AnimCurScreenPrivateIndex != -1) ? GetAnimCurScreen(s) : NULL)
+#define SetAnimCurScreen(s,p) ((s)->devPrivates[AnimCurScreenPrivateIndex].ptr = (pointer) (p))
+
+#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
+#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
+
+static Bool
+AnimCurDisplayCursor (ScreenPtr pScreen,
+ CursorPtr pCursor);
+
+static Bool
+AnimCurSetCursorPosition (ScreenPtr pScreen,
+ int x,
+ int y,
+ Bool generateEvent);
+
+static Bool
+AnimCurCloseScreen (int index, ScreenPtr pScreen)
+{
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ Bool ret;
+
+ Unwrap(as, pScreen, CloseScreen);
+
+ Unwrap(as, pScreen, BlockHandler);
+
+ Unwrap(as, pScreen, CursorLimits);
+ Unwrap(as, pScreen, DisplayCursor);
+ Unwrap(as, pScreen, SetCursorPosition);
+ Unwrap(as, pScreen, RealizeCursor);
+ Unwrap(as, pScreen, UnrealizeCursor);
+ Unwrap(as, pScreen, RecolorCursor);
+ SetAnimCurScreen(pScreen,0);
+ ret = (*pScreen->CloseScreen) (index, pScreen);
+ xfree (as);
+ if (index == 0)
+ AnimCurScreenPrivateIndex = -1;
+ return ret;
+}
+
+static void
+AnimCurCursorLimits (ScreenPtr pScreen,
+ CursorPtr pCursor,
+ BoxPtr pHotBox,
+ BoxPtr pTopLeftBox)
+{
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+
+ Unwrap (as, pScreen, CursorLimits);
+ if (IsAnimCur(pCursor))
+ {
+ AnimCurPtr ac = GetAnimCur(pCursor);
+
+ (*pScreen->CursorLimits) (pScreen, ac->elts[0].pCursor, pHotBox, pTopLeftBox);
+ }
+ else
+ {
+ (*pScreen->CursorLimits) (pScreen, pCursor, pHotBox, pTopLeftBox);
+ }
+ Wrap (as, pScreen, CursorLimits, AnimCurCursorLimits);
+}
+
+/*
+ * This has to be a screen block handler instead of a generic
+ * block handler so that it is well ordered with respect to the DRI
+ * block handler responsible for releasing the hardware to DRI clients
+ */
+
+static void
+AnimCurScreenBlockHandler (int screenNum,
+ pointer blockData,
+ pointer pTimeout,
+ pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+
+ if (pScreen == animCurState.pScreen)
+ {
+ CARD32 now = GetTimeInMillis ();
+
+ if ((INT32) (now - animCurState.time) >= 0)
+ {
+ AnimCurPtr ac = GetAnimCur(animCurState.pCursor);
+ int elt = (animCurState.elt + 1) % ac->nelt;
+ DisplayCursorProcPtr DisplayCursor;
+
+ /*
+ * Not a simple Unwrap/Wrap as this
+ * isn't called along the DisplayCursor
+ * wrapper chain.
+ */
+ DisplayCursor = pScreen->DisplayCursor;
+ pScreen->DisplayCursor = as->DisplayCursor;
+ (void) (*pScreen->DisplayCursor) (pScreen, ac->elts[elt].pCursor);
+ as->DisplayCursor = pScreen->DisplayCursor;
+ pScreen->DisplayCursor = DisplayCursor;
+
+ animCurState.elt = elt;
+ animCurState.time = now + ac->elts[elt].delay;
+ }
+ AdjustWaitForDelay (pTimeout, animCurState.time - now);
+ }
+ Unwrap (as, pScreen, BlockHandler);
+ (*pScreen->BlockHandler) (screenNum, blockData, pTimeout, pReadmask);
+ Wrap (as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
+}
+
+static Bool
+AnimCurDisplayCursor (ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ Bool ret;
+
+ Unwrap (as, pScreen, DisplayCursor);
+ if (IsAnimCur(pCursor))
+ {
+ if (pCursor != animCurState.pCursor)
+ {
+ AnimCurPtr ac = GetAnimCur(pCursor);
+
+ ret = (*pScreen->DisplayCursor) (pScreen, ac->elts[0].pCursor);
+ if (ret)
+ {
+ animCurState.elt = 0;
+ animCurState.time = GetTimeInMillis () + ac->elts[0].delay;
+ animCurState.pCursor = pCursor;
+ animCurState.pScreen = pScreen;
+ }
+ }
+ else
+ ret = TRUE;
+ }
+ else
+ {
+ animCurState.pCursor = 0;
+ animCurState.pScreen = 0;
+ ret = (*pScreen->DisplayCursor) (pScreen, pCursor);
+ }
+ Wrap (as, pScreen, DisplayCursor, AnimCurDisplayCursor);
+ return ret;
+}
+
+static Bool
+AnimCurSetCursorPosition (ScreenPtr pScreen,
+ int x,
+ int y,
+ Bool generateEvent)
+{
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ Bool ret;
+
+ Unwrap (as, pScreen, SetCursorPosition);
+ if (animCurState.pCursor)
+ animCurState.pScreen = pScreen;
+ ret = (*pScreen->SetCursorPosition) (pScreen, x, y, generateEvent);
+ Wrap (as, pScreen, SetCursorPosition, AnimCurSetCursorPosition);
+ return ret;
+}
+
+static Bool
+AnimCurRealizeCursor (ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ Bool ret;
+
+ Unwrap (as, pScreen, RealizeCursor);
+ if (IsAnimCur(pCursor))
+ ret = TRUE;
+ else
+ ret = (*pScreen->RealizeCursor) (pScreen, pCursor);
+ Wrap (as, pScreen, RealizeCursor, AnimCurRealizeCursor);
+ return ret;
+}
+
+static Bool
+AnimCurUnrealizeCursor (ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ Bool ret;
+
+ Unwrap (as, pScreen, UnrealizeCursor);
+ if (IsAnimCur(pCursor))
+ {
+ AnimCurPtr ac = GetAnimCur(pCursor);
+ int i;
+
+ if (pScreen->myNum == 0)
+ for (i = 0; i < ac->nelt; i++)
+ FreeCursor (ac->elts[i].pCursor, 0);
+ ret = TRUE;
+ }
+ else
+ ret = (*pScreen->UnrealizeCursor) (pScreen, pCursor);
+ Wrap (as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor);
+ return ret;
+}
+
+static void
+AnimCurRecolorCursor (ScreenPtr pScreen,
+ CursorPtr pCursor,
+ Bool displayed)
+{
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+
+ Unwrap (as, pScreen, RecolorCursor);
+ if (IsAnimCur(pCursor))
+ {
+ AnimCurPtr ac = GetAnimCur(pCursor);
+ int i;
+
+ for (i = 0; i < ac->nelt; i++)
+ (*pScreen->RecolorCursor) (pScreen, ac->elts[i].pCursor,
+ displayed &&
+ animCurState.elt == i);
+ }
+ else
+ (*pScreen->RecolorCursor) (pScreen, pCursor, displayed);
+ Wrap (as, pScreen, RecolorCursor, AnimCurRecolorCursor);
+}
+
+Bool
+AnimCurInit (ScreenPtr pScreen)
+{
+ AnimCurScreenPtr as;
+
+ if (AnimCurGeneration != serverGeneration)
+ {
+ AnimCurScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ if (AnimCurScreenPrivateIndex < 0)
+ return FALSE;
+ AnimCurGeneration = serverGeneration;
+ animCurState.pCursor = 0;
+ animCurState.pScreen = 0;
+ animCurState.elt = 0;
+ animCurState.time = 0;
+ }
+ as = (AnimCurScreenPtr) xalloc (sizeof (AnimCurScreenRec));
+ if (!as)
+ return FALSE;
+ Wrap(as, pScreen, CloseScreen, AnimCurCloseScreen);
+
+ Wrap(as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
+
+ Wrap(as, pScreen, CursorLimits, AnimCurCursorLimits);
+ Wrap(as, pScreen, DisplayCursor, AnimCurDisplayCursor);
+ Wrap(as, pScreen, SetCursorPosition, AnimCurSetCursorPosition);
+ Wrap(as, pScreen, RealizeCursor, AnimCurRealizeCursor);
+ Wrap(as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor);
+ Wrap(as, pScreen, RecolorCursor, AnimCurRecolorCursor);
+ SetAnimCurScreen(pScreen,as);
+ return TRUE;
+}
+
+int
+AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor)
+{
+ CursorPtr pCursor;
+ int i;
+ AnimCurPtr ac;
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ if (!GetAnimCurScreenIfSet (screenInfo.screens[i]))
+ return BadImplementation;
+
+ for (i = 0; i < ncursor; i++)
+ if (IsAnimCur (cursors[i]))
+ return BadMatch;
+
+ pCursor = (CursorPtr) xalloc (sizeof (CursorRec) +
+ sizeof (AnimCurRec) +
+ ncursor * sizeof (AnimCurElt));
+ if (!pCursor)
+ return BadAlloc;
+ pCursor->bits = &animCursorBits;
+ animCursorBits.refcnt++;
+ pCursor->refcnt = 1;
+
+ pCursor->foreRed = cursors[0]->foreRed;
+ pCursor->foreGreen = cursors[0]->foreGreen;
+ pCursor->foreBlue = cursors[0]->foreBlue;
+
+ pCursor->backRed = cursors[0]->backRed;
+ pCursor->backGreen = cursors[0]->backGreen;
+ pCursor->backBlue = cursors[0]->backBlue;
+
+ /*
+ * Fill in the AnimCurRec
+ */
+ ac = GetAnimCur (pCursor);
+ ac->nelt = ncursor;
+ ac->elts = (AnimCurElt *) (ac + 1);
+
+ for (i = 0; i < ncursor; i++)
+ {
+ cursors[i]->refcnt++;
+ ac->elts[i].pCursor = cursors[i];
+ ac->elts[i].delay = deltas[i];
+ }
+
+ *ppCursor = pCursor;
+ return Success;
+}
diff --git a/nx-X11/programs/Xserver/render/filter.c b/nx-X11/programs/Xserver/render/filter.c
new file mode 100644
index 000000000..919d599f2
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/filter.c
@@ -0,0 +1,303 @@
+/*
+ * $Id: filter.c,v 1.10 2005/07/03 08:53:54 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "misc.h"
+#include "scrnintstr.h"
+#include "os.h"
+#include "regionstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "input.h"
+#include "resource.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#include "picturestr.h"
+
+static char **filterNames;
+static int nfilterNames;
+
+/*
+ * standard but not required filters don't have constant indices
+ */
+
+int
+PictureGetFilterId (char *filter, int len, Bool makeit)
+{
+ int i;
+ char *name;
+ char **names;
+
+ if (len < 0)
+ len = strlen (filter);
+ for (i = 0; i < nfilterNames; i++)
+ if (!CompareISOLatin1Lowered ((unsigned char *) filterNames[i], -1, (unsigned char *) filter, len))
+ return i;
+ if (!makeit)
+ return -1;
+ name = xalloc (len + 1);
+ if (!name)
+ return -1;
+ memcpy (name, filter, len);
+ name[len] = '\0';
+ if (filterNames)
+ names = xrealloc (filterNames, (nfilterNames + 1) * sizeof (char *));
+ else
+ names = xalloc (sizeof (char *));
+ if (!names)
+ {
+ xfree (name);
+ return -1;
+ }
+ filterNames = names;
+ i = nfilterNames++;
+ filterNames[i] = name;
+ return i;
+}
+
+static Bool
+PictureSetDefaultIds (void)
+{
+ /* careful here -- this list must match the #define values */
+
+ if (PictureGetFilterId (FilterNearest, -1, TRUE) != PictFilterNearest)
+ return FALSE;
+ if (PictureGetFilterId (FilterBilinear, -1, TRUE) != PictFilterBilinear)
+ return FALSE;
+
+ if (PictureGetFilterId (FilterFast, -1, TRUE) != PictFilterFast)
+ return FALSE;
+ if (PictureGetFilterId (FilterGood, -1, TRUE) != PictFilterGood)
+ return FALSE;
+ if (PictureGetFilterId (FilterBest, -1, TRUE) != PictFilterBest)
+ return FALSE;
+
+ if (PictureGetFilterId (FilterConvolution, -1, TRUE) != PictFilterConvolution)
+ return FALSE;
+ return TRUE;
+}
+
+char *
+PictureGetFilterName (int id)
+{
+ if (0 <= id && id < nfilterNames)
+ return filterNames[id];
+ else
+ return 0;
+}
+
+static void
+PictureFreeFilterIds (void)
+{
+ int i;
+
+ for (i = 0; i < nfilterNames; i++)
+ xfree (filterNames[i]);
+ xfree (filterNames);
+ nfilterNames = 0;
+ filterNames = 0;
+}
+
+int
+PictureAddFilter (ScreenPtr pScreen,
+ char *filter,
+ PictFilterValidateParamsProcPtr ValidateParams)
+{
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ int id = PictureGetFilterId (filter, -1, TRUE);
+ int i;
+ PictFilterPtr filters;
+
+ if (id < 0)
+ return -1;
+ /*
+ * It's an error to attempt to reregister a filter
+ */
+ for (i = 0; i < ps->nfilters; i++)
+ if (ps->filters[i].id == id)
+ return -1;
+ if (ps->filters)
+ filters = xrealloc (ps->filters, (ps->nfilters + 1) * sizeof (PictFilterRec));
+ else
+ filters = xalloc (sizeof (PictFilterRec));
+ if (!filters)
+ return -1;
+ ps->filters = filters;
+ i = ps->nfilters++;
+ ps->filters[i].name = PictureGetFilterName (id);
+ ps->filters[i].id = id;
+ ps->filters[i].ValidateParams = ValidateParams;
+ return id;
+}
+
+Bool
+PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias)
+{
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ int filter_id = PictureGetFilterId (filter, -1, FALSE);
+ int alias_id = PictureGetFilterId (alias, -1, TRUE);
+ int i;
+
+ if (filter_id < 0 || alias_id < 0)
+ return FALSE;
+ for (i = 0; i < ps->nfilterAliases; i++)
+ if (ps->filterAliases[i].alias_id == alias_id)
+ break;
+ if (i == ps->nfilterAliases)
+ {
+ PictFilterAliasPtr aliases;
+
+ if (ps->filterAliases)
+ aliases = xrealloc (ps->filterAliases,
+ (ps->nfilterAliases + 1) *
+ sizeof (PictFilterAliasRec));
+ else
+ aliases = xalloc (sizeof (PictFilterAliasRec));
+ if (!aliases)
+ return FALSE;
+ ps->filterAliases = aliases;
+ ps->filterAliases[i].alias = PictureGetFilterName (alias_id);
+ ps->filterAliases[i].alias_id = alias_id;
+ ps->nfilterAliases++;
+ }
+ ps->filterAliases[i].filter_id = filter_id;
+ return TRUE;
+}
+
+PictFilterPtr
+PictureFindFilter (ScreenPtr pScreen, char *name, int len)
+{
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ int id = PictureGetFilterId (name, len, FALSE);
+ int i;
+
+ if (id < 0)
+ return 0;
+ /* Check for an alias, allow them to recurse */
+ for (i = 0; i < ps->nfilterAliases; i++)
+ if (ps->filterAliases[i].alias_id == id)
+ {
+ id = ps->filterAliases[i].filter_id;
+ i = 0;
+ }
+ /* find the filter */
+ for (i = 0; i < ps->nfilters; i++)
+ if (ps->filters[i].id == id)
+ return &ps->filters[i];
+ return 0;
+}
+
+static Bool
+convolutionFilterValidateParams (PicturePtr pPicture,
+ int filter,
+ xFixed *params,
+ int nparams)
+{
+ if (nparams < 3)
+ return FALSE;
+
+ if (xFixedFrac (params[0]) || xFixedFrac (params[1]))
+ return FALSE;
+
+ nparams -= 2;
+ if ((xFixedToInt (params[0]) * xFixedToInt (params[1])) > nparams)
+ return FALSE;
+
+ return TRUE;
+}
+
+
+Bool
+PictureSetDefaultFilters (ScreenPtr pScreen)
+{
+ if (!filterNames)
+ if (!PictureSetDefaultIds ())
+ return FALSE;
+ if (PictureAddFilter (pScreen, FilterNearest, 0) < 0)
+ return FALSE;
+ if (PictureAddFilter (pScreen, FilterBilinear, 0) < 0)
+ return FALSE;
+
+ if (!PictureSetFilterAlias (pScreen, FilterNearest, FilterFast))
+ return FALSE;
+ if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterGood))
+ return FALSE;
+ if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterBest))
+ return FALSE;
+
+ if (PictureAddFilter (pScreen, FilterConvolution, convolutionFilterValidateParams) < 0)
+ return FALSE;
+
+ return TRUE;
+}
+
+void
+PictureResetFilters (ScreenPtr pScreen)
+{
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+
+ xfree (ps->filters);
+ xfree (ps->filterAliases);
+ PictureFreeFilterIds ();
+}
+
+int
+SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int nparams)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ PictFilterPtr pFilter = PictureFindFilter (pScreen, name, len);
+ xFixed *new_params;
+ int i;
+
+ if (!pFilter)
+ return BadName;
+ if (pFilter->ValidateParams)
+ {
+ if (!(*pFilter->ValidateParams) (pPicture, pFilter->id, params, nparams))
+ return BadMatch;
+ }
+ else if (nparams)
+ return BadMatch;
+
+ if (nparams != pPicture->filter_nparams)
+ {
+ new_params = xalloc (nparams * sizeof (xFixed));
+ if (!new_params)
+ return BadAlloc;
+ xfree (pPicture->filter_params);
+ pPicture->filter_params = new_params;
+ pPicture->filter_nparams = nparams;
+ }
+ for (i = 0; i < nparams; i++)
+ pPicture->filter_params[i] = params[i];
+ pPicture->filter = pFilter->id;
+ pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
+ return Success;
+}
diff --git a/nx-X11/programs/Xserver/render/glyph.c b/nx-X11/programs/Xserver/render/glyph.c
new file mode 100644
index 000000000..45c5dd975
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/glyph.c
@@ -0,0 +1,478 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/glyph.c,v 1.5 2001/01/30 07:01:22 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "misc.h"
+#include "scrnintstr.h"
+#include "os.h"
+#include "regionstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "input.h"
+#include "resource.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#include "picturestr.h"
+#include "glyphstr.h"
+
+/*
+ * From Knuth -- a good choice for hash/rehash values is p, p-2 where
+ * p and p-2 are both prime. These tables are sized to have an extra 10%
+ * free to avoid exponential performance degradation as the hash table fills
+ */
+static GlyphHashSetRec glyphHashSets[] = {
+ { 32, 43, 41 },
+ { 64, 73, 71 },
+ { 128, 151, 149 },
+ { 256, 283, 281 },
+ { 512, 571, 569 },
+ { 1024, 1153, 1151 },
+ { 2048, 2269, 2267 },
+ { 4096, 4519, 4517 },
+ { 8192, 9013, 9011 },
+ { 16384, 18043, 18041 },
+ { 32768, 36109, 36107 },
+ { 65536, 72091, 72089 },
+ { 131072, 144409, 144407 },
+ { 262144, 288361, 288359 },
+ { 524288, 576883, 576881 },
+ { 1048576, 1153459, 1153457 },
+ { 2097152, 2307163, 2307161 },
+ { 4194304, 4613893, 4613891 },
+ { 8388608, 9227641, 9227639 },
+ { 16777216, 18455029, 18455027 },
+ { 33554432, 36911011, 36911009 },
+ { 67108864, 73819861, 73819859 },
+ { 134217728, 147639589, 147639587 },
+ { 268435456, 295279081, 295279079 },
+ { 536870912, 590559793, 590559791 }
+};
+
+#define NGLYPHHASHSETS (sizeof(glyphHashSets)/sizeof(glyphHashSets[0]))
+
+const CARD8 glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 };
+
+GlyphHashRec globalGlyphs[GlyphFormatNum];
+
+GlyphHashSetPtr
+FindGlyphHashSet (CARD32 filled)
+{
+ int i;
+
+ for (i = 0; i < NGLYPHHASHSETS; i++)
+ if (glyphHashSets[i].entries >= filled)
+ return &glyphHashSets[i];
+ return 0;
+}
+
+static int _GlyphSetPrivateAllocateIndex = 0;
+
+int
+AllocateGlyphSetPrivateIndex (void)
+{
+ return _GlyphSetPrivateAllocateIndex++;
+}
+
+void
+ResetGlyphSetPrivateIndex (void)
+{
+ _GlyphSetPrivateAllocateIndex = 0;
+}
+
+Bool
+_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, pointer ptr)
+{
+ pointer *new;
+
+ if (n > glyphSet->maxPrivate) {
+ if (glyphSet->devPrivates &&
+ glyphSet->devPrivates != (pointer)(&glyphSet[1])) {
+ new = (pointer *) xrealloc (glyphSet->devPrivates,
+ (n + 1) * sizeof (pointer));
+ if (!new)
+ return FALSE;
+ } else {
+ new = (pointer *) xalloc ((n + 1) * sizeof (pointer));
+ if (!new)
+ return FALSE;
+ if (glyphSet->devPrivates)
+ memcpy (new,
+ glyphSet->devPrivates,
+ (glyphSet->maxPrivate + 1) * sizeof (pointer));
+ }
+ glyphSet->devPrivates = new;
+ /* Zero out new, uninitialize privates */
+ while (++glyphSet->maxPrivate < n)
+ glyphSet->devPrivates[glyphSet->maxPrivate] = (pointer)0;
+ }
+ glyphSet->devPrivates[n] = ptr;
+ return TRUE;
+}
+
+Bool
+GlyphInit (ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+GlyphRefPtr
+FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare)
+{
+ CARD32 elt, step, s;
+ GlyphPtr glyph;
+ GlyphRefPtr table, gr, del;
+ CARD32 tableSize = hash->hashSet->size;
+
+ table = hash->table;
+ elt = signature % tableSize;
+ step = 0;
+ del = 0;
+ for (;;)
+ {
+ gr = &table[elt];
+ s = gr->signature;
+ glyph = gr->glyph;
+ if (!glyph)
+ {
+ if (del)
+ gr = del;
+ break;
+ }
+ if (glyph == DeletedGlyph)
+ {
+ if (!del)
+ del = gr;
+ else if (gr == del)
+ break;
+ }
+ else if (s == signature &&
+ (!match ||
+ memcmp (&compare->info, &glyph->info, compare->size) == 0))
+ {
+ break;
+ }
+ if (!step)
+ {
+ step = signature % hash->hashSet->rehash;
+ if (!step)
+ step = 1;
+ }
+ elt += step;
+ if (elt >= tableSize)
+ elt -= tableSize;
+ }
+ return gr;
+}
+
+CARD32
+HashGlyph (GlyphPtr glyph)
+{
+ CARD32 *bits = (CARD32 *) &(glyph->info);
+ CARD32 hash;
+ int n = glyph->size / sizeof (CARD32);
+
+ hash = 0;
+ while (n--)
+ hash ^= *bits++;
+ return hash;
+}
+
+#ifdef CHECK_DUPLICATES
+void
+DuplicateRef (GlyphPtr glyph, char *where)
+{
+ ErrorF ("Duplicate Glyph 0x%x from %s\n", glyph, where);
+}
+
+void
+CheckDuplicates (GlyphHashPtr hash, char *where)
+{
+ GlyphPtr g;
+ int i, j;
+
+ for (i = 0; i < hash->hashSet->size; i++)
+ {
+ g = hash->table[i].glyph;
+ if (!g || g == DeletedGlyph)
+ continue;
+ for (j = i + 1; j < hash->hashSet->size; j++)
+ if (hash->table[j].glyph == g)
+ DuplicateRef (g, where);
+ }
+}
+#else
+#define CheckDuplicates(a,b)
+#define DuplicateRef(a,b)
+#endif
+
+void
+FreeGlyph (GlyphPtr glyph, int format)
+{
+ CheckDuplicates (&globalGlyphs[format], "FreeGlyph");
+ if (--glyph->refcnt == 0)
+ {
+ GlyphRefPtr gr;
+ int i;
+ int first;
+
+ first = -1;
+ for (i = 0; i < globalGlyphs[format].hashSet->size; i++)
+ if (globalGlyphs[format].table[i].glyph == glyph)
+ {
+ if (first != -1)
+ DuplicateRef (glyph, "FreeGlyph check");
+ first = i;
+ }
+
+ gr = FindGlyphRef (&globalGlyphs[format],
+ HashGlyph (glyph), TRUE, glyph);
+ if (gr - globalGlyphs[format].table != first)
+ DuplicateRef (glyph, "Found wrong one");
+ if (gr->glyph && gr->glyph != DeletedGlyph)
+ {
+ gr->glyph = DeletedGlyph;
+ gr->signature = 0;
+ globalGlyphs[format].tableEntries--;
+ }
+ xfree (glyph);
+ }
+}
+
+void
+AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
+{
+ GlyphRefPtr gr;
+ CARD32 hash;
+
+ CheckDuplicates (&globalGlyphs[glyphSet->fdepth], "AddGlyph top global");
+ /* Locate existing matching glyph */
+ hash = HashGlyph (glyph);
+ gr = FindGlyphRef (&globalGlyphs[glyphSet->fdepth], hash, TRUE, glyph);
+ if (gr->glyph && gr->glyph != DeletedGlyph)
+ {
+ xfree (glyph);
+ glyph = gr->glyph;
+ }
+ else
+ {
+ gr->glyph = glyph;
+ gr->signature = hash;
+ globalGlyphs[glyphSet->fdepth].tableEntries++;
+ }
+
+ /* Insert/replace glyphset value */
+ gr = FindGlyphRef (&glyphSet->hash, id, FALSE, 0);
+ ++glyph->refcnt;
+ if (gr->glyph && gr->glyph != DeletedGlyph)
+ FreeGlyph (gr->glyph, glyphSet->fdepth);
+ else
+ glyphSet->hash.tableEntries++;
+ gr->glyph = glyph;
+ gr->signature = id;
+ CheckDuplicates (&globalGlyphs[glyphSet->fdepth], "AddGlyph bottom");
+}
+
+Bool
+DeleteGlyph (GlyphSetPtr glyphSet, Glyph id)
+{
+ GlyphRefPtr gr;
+ GlyphPtr glyph;
+
+ gr = FindGlyphRef (&glyphSet->hash, id, FALSE, 0);
+ glyph = gr->glyph;
+ if (glyph && glyph != DeletedGlyph)
+ {
+ gr->glyph = DeletedGlyph;
+ glyphSet->hash.tableEntries--;
+ FreeGlyph (glyph, glyphSet->fdepth);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+GlyphPtr
+FindGlyph (GlyphSetPtr glyphSet, Glyph id)
+{
+ GlyphPtr glyph;
+
+ glyph = FindGlyphRef (&glyphSet->hash, id, FALSE, 0)->glyph;
+ if (glyph == DeletedGlyph)
+ glyph = 0;
+ return glyph;
+}
+
+GlyphPtr
+AllocateGlyph (xGlyphInfo *gi, int fdepth)
+{
+ int size;
+ GlyphPtr glyph;
+
+ size = gi->height * PixmapBytePad (gi->width, glyphDepths[fdepth]);
+ glyph = (GlyphPtr) xalloc (size + sizeof (GlyphRec));
+ if (!glyph)
+ return 0;
+ glyph->refcnt = 0;
+ glyph->size = size + sizeof (xGlyphInfo);
+ glyph->info = *gi;
+ return glyph;
+}
+
+Bool
+AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet)
+{
+ hash->table = (GlyphRefPtr) xalloc (hashSet->size * sizeof (GlyphRefRec));
+ if (!hash->table)
+ return FALSE;
+ memset (hash->table, 0, hashSet->size * sizeof (GlyphRefRec));
+ hash->hashSet = hashSet;
+ hash->tableEntries = 0;
+ return TRUE;
+}
+
+Bool
+ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global)
+{
+ CARD32 tableEntries;
+ GlyphHashSetPtr hashSet;
+ GlyphHashRec newHash;
+ GlyphRefPtr gr;
+ GlyphPtr glyph;
+ int i;
+ int oldSize;
+ CARD32 s;
+
+ tableEntries = hash->tableEntries + change;
+ hashSet = FindGlyphHashSet (tableEntries);
+ if (hashSet == hash->hashSet)
+ return TRUE;
+ if (global)
+ CheckDuplicates (hash, "ResizeGlyphHash top");
+ if (!AllocateGlyphHash (&newHash, hashSet))
+ return FALSE;
+ if (hash->table)
+ {
+ oldSize = hash->hashSet->size;
+ for (i = 0; i < oldSize; i++)
+ {
+ glyph = hash->table[i].glyph;
+ if (glyph && glyph != DeletedGlyph)
+ {
+ s = hash->table[i].signature;
+ gr = FindGlyphRef (&newHash, s, global, glyph);
+ gr->signature = s;
+ gr->glyph = glyph;
+ ++newHash.tableEntries;
+ }
+ }
+ xfree (hash->table);
+ }
+ *hash = newHash;
+ if (global)
+ CheckDuplicates (hash, "ResizeGlyphHash bottom");
+ return TRUE;
+}
+
+Bool
+ResizeGlyphSet (GlyphSetPtr glyphSet, CARD32 change)
+{
+ return (ResizeGlyphHash (&glyphSet->hash, change, FALSE) &&
+ ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], change, TRUE));
+}
+
+GlyphSetPtr
+AllocateGlyphSet (int fdepth, PictFormatPtr format)
+{
+ GlyphSetPtr glyphSet;
+ int size;
+
+ if (!globalGlyphs[fdepth].hashSet)
+ {
+ if (!AllocateGlyphHash (&globalGlyphs[fdepth], &glyphHashSets[0]))
+ return FALSE;
+ }
+
+ size = (sizeof (GlyphSetRec) +
+ (sizeof (pointer) * _GlyphSetPrivateAllocateIndex));
+ glyphSet = xalloc (size);
+ if (!glyphSet)
+ return FALSE;
+ bzero((char *)glyphSet, size);
+ glyphSet->maxPrivate = _GlyphSetPrivateAllocateIndex - 1;
+ if (_GlyphSetPrivateAllocateIndex)
+ glyphSet->devPrivates = (pointer)(&glyphSet[1]);
+
+ if (!AllocateGlyphHash (&glyphSet->hash, &glyphHashSets[0]))
+ {
+ xfree (glyphSet);
+ return FALSE;
+ }
+ glyphSet->refcnt = 1;
+ glyphSet->fdepth = fdepth;
+ glyphSet->format = format;
+ return glyphSet;
+}
+
+int
+FreeGlyphSet (pointer value,
+ XID gid)
+{
+ GlyphSetPtr glyphSet = (GlyphSetPtr) value;
+
+ if (--glyphSet->refcnt == 0)
+ {
+ CARD32 i, tableSize = glyphSet->hash.hashSet->size;
+ GlyphRefPtr table = glyphSet->hash.table;
+ GlyphPtr glyph;
+
+ for (i = 0; i < tableSize; i++)
+ {
+ glyph = table[i].glyph;
+ if (glyph && glyph != DeletedGlyph)
+ FreeGlyph (glyph, glyphSet->fdepth);
+ }
+ if (!globalGlyphs[glyphSet->fdepth].tableEntries)
+ {
+ xfree (globalGlyphs[glyphSet->fdepth].table);
+ globalGlyphs[glyphSet->fdepth].table = 0;
+ globalGlyphs[glyphSet->fdepth].hashSet = 0;
+ }
+ else
+ ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], 0, TRUE);
+ xfree (table);
+
+ if (glyphSet->devPrivates &&
+ glyphSet->devPrivates != (pointer)(&glyphSet[1]))
+ xfree(glyphSet->devPrivates);
+
+ xfree (glyphSet);
+ }
+ return Success;
+}
diff --git a/nx-X11/programs/Xserver/render/glyphstr.h b/nx-X11/programs/Xserver/render/glyphstr.h
new file mode 100644
index 000000000..f4777a248
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/glyphstr.h
@@ -0,0 +1,148 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/glyphstr.h,v 1.3 2000/11/20 07:13:13 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _GLYPHSTR_H_
+#define _GLYPHSTR_H_
+
+#include <X11/extensions/renderproto.h>
+#include "picture.h"
+#include "screenint.h"
+
+#define GlyphFormat1 0
+#define GlyphFormat4 1
+#define GlyphFormat8 2
+#define GlyphFormat16 3
+#define GlyphFormat32 4
+#define GlyphFormatNum 5
+
+typedef struct _Glyph {
+ CARD32 refcnt;
+ CARD32 size; /* info + bitmap */
+ xGlyphInfo info;
+ /* bits follow */
+} GlyphRec, *GlyphPtr;
+
+typedef struct _GlyphRef {
+ CARD32 signature;
+ GlyphPtr glyph;
+} GlyphRefRec, *GlyphRefPtr;
+
+#define DeletedGlyph ((GlyphPtr) 1)
+
+typedef struct _GlyphHashSet {
+ CARD32 entries;
+ CARD32 size;
+ CARD32 rehash;
+} GlyphHashSetRec, *GlyphHashSetPtr;
+
+typedef struct _GlyphHash {
+ GlyphRefPtr table;
+ GlyphHashSetPtr hashSet;
+ CARD32 tableEntries;
+} GlyphHashRec, *GlyphHashPtr;
+
+typedef struct _GlyphSet {
+ CARD32 refcnt;
+ PictFormatPtr format;
+ int fdepth;
+ GlyphHashRec hash;
+ int maxPrivate;
+ pointer *devPrivates;
+} GlyphSetRec, *GlyphSetPtr;
+
+#define GlyphSetGetPrivate(pGlyphSet,n) \
+ ((n) > (pGlyphSet)->maxPrivate ? \
+ (pointer) 0 : \
+ (pGlyphSet)->devPrivates[n])
+
+#define GlyphSetSetPrivate(pGlyphSet,n,ptr) \
+ ((n) > (pGlyphSet)->maxPrivate ? \
+ _GlyphSetSetNewPrivate(pGlyphSet, n, ptr) : \
+ ((((pGlyphSet)->devPrivates[n] = (ptr)) != 0) || TRUE))
+
+typedef struct _GlyphList {
+ INT16 xOff;
+ INT16 yOff;
+ CARD8 len;
+ PictFormatPtr format;
+} GlyphListRec, *GlyphListPtr;
+
+extern GlyphHashRec globalGlyphs[GlyphFormatNum];
+
+GlyphHashSetPtr
+FindGlyphHashSet (CARD32 filled);
+
+int
+AllocateGlyphSetPrivateIndex (void);
+
+void
+ResetGlyphSetPrivateIndex (void);
+
+Bool
+_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, pointer ptr);
+
+Bool
+GlyphInit (ScreenPtr pScreen);
+
+GlyphRefPtr
+FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare);
+
+CARD32
+HashGlyph (GlyphPtr glyph);
+
+void
+FreeGlyph (GlyphPtr glyph, int format);
+
+void
+AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id);
+
+Bool
+DeleteGlyph (GlyphSetPtr glyphSet, Glyph id);
+
+GlyphPtr
+FindGlyph (GlyphSetPtr glyphSet, Glyph id);
+
+GlyphPtr
+AllocateGlyph (xGlyphInfo *gi, int format);
+
+Bool
+AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet);
+
+Bool
+ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global);
+
+Bool
+ResizeGlyphSet (GlyphSetPtr glyphSet, CARD32 change);
+
+GlyphSetPtr
+AllocateGlyphSet (int fdepth, PictFormatPtr format);
+
+int
+FreeGlyphSet (pointer value,
+ XID gid);
+
+
+
+#endif /* _GLYPHSTR_H_ */
diff --git a/nx-X11/programs/Xserver/render/miglyph.c b/nx-X11/programs/Xserver/render/miglyph.c
new file mode 100644
index 000000000..237ec13a4
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/miglyph.c
@@ -0,0 +1,243 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/miglyph.c,v 1.4 2000/11/20 07:13:13 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "picturestr.h"
+#include "mipict.h"
+
+void
+miGlyphExtents (int nlist,
+ GlyphListPtr list,
+ GlyphPtr *glyphs,
+ BoxPtr extents)
+{
+ int x1, x2, y1, y2;
+ int n;
+ GlyphPtr glyph;
+ int x, y;
+
+ x = 0;
+ y = 0;
+ extents->x1 = MAXSHORT;
+ extents->x2 = MINSHORT;
+ extents->y1 = MAXSHORT;
+ extents->y2 = MINSHORT;
+ while (nlist--)
+ {
+ x += list->xOff;
+ y += list->yOff;
+ n = list->len;
+ list++;
+ while (n--)
+ {
+ glyph = *glyphs++;
+ x1 = x - glyph->info.x;
+ if (x1 < MINSHORT)
+ x1 = MINSHORT;
+ y1 = y - glyph->info.y;
+ if (y1 < MINSHORT)
+ y1 = MINSHORT;
+ x2 = x1 + glyph->info.width;
+ if (x2 > MAXSHORT)
+ x2 = MAXSHORT;
+ y2 = y1 + glyph->info.height;
+ if (y2 > MAXSHORT)
+ y2 = MAXSHORT;
+ if (x1 < extents->x1)
+ extents->x1 = x1;
+ if (x2 > extents->x2)
+ extents->x2 = x2;
+ if (y1 < extents->y1)
+ extents->y1 = y1;
+ if (y2 > extents->y2)
+ extents->y2 = y2;
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ }
+ }
+}
+
+#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
+
+void
+miGlyphs (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlist,
+ GlyphListPtr list,
+ GlyphPtr *glyphs)
+{
+ PixmapPtr pPixmap = 0;
+ PicturePtr pPicture;
+ PixmapPtr pMaskPixmap = 0;
+ PicturePtr pMask;
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ int width = 0, height = 0;
+ int x, y;
+ int xDst = list->xOff, yDst = list->yOff;
+ int n;
+ GlyphPtr glyph;
+ int error;
+ BoxRec extents;
+ CARD32 component_alpha;
+
+ if (maskFormat)
+ {
+ GCPtr pGC;
+ xRectangle rect;
+
+ miGlyphExtents (nlist, list, glyphs, &extents);
+
+ if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
+ return;
+ width = extents.x2 - extents.x1;
+ height = extents.y2 - extents.y1;
+ pMaskPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, maskFormat->depth);
+ if (!pMaskPixmap)
+ return;
+ component_alpha = NeedsComponent(maskFormat->format);
+ pMask = CreatePicture (0, &pMaskPixmap->drawable,
+ maskFormat, CPComponentAlpha, &component_alpha,
+ serverClient, &error);
+ if (!pMask)
+ {
+ (*pScreen->DestroyPixmap) (pMaskPixmap);
+ return;
+ }
+ pGC = GetScratchGC (pMaskPixmap->drawable.depth, pScreen);
+ ValidateGC (&pMaskPixmap->drawable, pGC);
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = width;
+ rect.height = height;
+ (*pGC->ops->PolyFillRect) (&pMaskPixmap->drawable, pGC, 1, &rect);
+ FreeScratchGC (pGC);
+ x = -extents.x1;
+ y = -extents.y1;
+ }
+ else
+ {
+ pMask = pDst;
+ x = 0;
+ y = 0;
+ }
+ pPicture = 0;
+ while (nlist--)
+ {
+ x += list->xOff;
+ y += list->yOff;
+ n = list->len;
+ while (n--)
+ {
+ glyph = *glyphs++;
+ if (!pPicture)
+ {
+ pPixmap = GetScratchPixmapHeader (pScreen, glyph->info.width, glyph->info.height,
+ list->format->depth,
+ list->format->depth,
+ 0, (pointer) (glyph + 1));
+ if (!pPixmap)
+ return;
+ component_alpha = NeedsComponent(list->format->format);
+ pPicture = CreatePicture (0, &pPixmap->drawable, list->format,
+ CPComponentAlpha, &component_alpha,
+ serverClient, &error);
+ if (!pPicture)
+ {
+ FreeScratchPixmapHeader (pPixmap);
+ return;
+ }
+ }
+ (*pScreen->ModifyPixmapHeader) (pPixmap,
+ glyph->info.width, glyph->info.height,
+ 0, 0, -1, (pointer) (glyph + 1));
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ if (maskFormat)
+ {
+ CompositePicture (PictOpAdd,
+ pPicture,
+ None,
+ pMask,
+ 0, 0,
+ 0, 0,
+ x - glyph->info.x,
+ y - glyph->info.y,
+ glyph->info.width,
+ glyph->info.height);
+ }
+ else
+ {
+ CompositePicture (op,
+ pSrc,
+ pPicture,
+ pDst,
+ xSrc + (x - glyph->info.x) - xDst,
+ ySrc + (y - glyph->info.y) - yDst,
+ 0, 0,
+ x - glyph->info.x,
+ y - glyph->info.y,
+ glyph->info.width,
+ glyph->info.height);
+ }
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ }
+ list++;
+ if (pPicture)
+ {
+ FreeScratchPixmapHeader (pPixmap);
+ FreePicture ((pointer) pPicture, 0);
+ pPicture = 0;
+ pPixmap = 0;
+ }
+ }
+ if (maskFormat)
+ {
+ x = extents.x1;
+ y = extents.y1;
+ CompositePicture (op,
+ pSrc,
+ pMask,
+ pDst,
+ xSrc + x - xDst,
+ ySrc + y - yDst,
+ 0, 0,
+ x, y,
+ width, height);
+ FreePicture ((pointer) pMask, (XID) 0);
+ (*pScreen->DestroyPixmap) (pMaskPixmap);
+ }
+}
diff --git a/nx-X11/programs/Xserver/render/miindex.c b/nx-X11/programs/Xserver/render/miindex.c
new file mode 100644
index 000000000..03e2857a2
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/miindex.c
@@ -0,0 +1,357 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/miindex.c,v 1.7 2002/11/05 06:05:04 keithp Exp $
+ *
+ * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _MIINDEX_H_
+#define _MIINDEX_H_
+
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "picturestr.h"
+#include "mipict.h"
+#include "colormapst.h"
+
+#define NUM_CUBE_LEVELS 4
+#define NUM_GRAY_LEVELS 13
+
+static Bool
+miBuildRenderColormap (ColormapPtr pColormap, Pixel *pixels, int *nump)
+{
+ int r, g, b;
+ unsigned short red, green, blue;
+ Pixel pixel;
+ Bool used[MI_MAX_INDEXED];
+ int needed;
+ int policy;
+ int cube, gray;
+ int i, n;
+
+ if (pColormap->mid != pColormap->pScreen->defColormap)
+ {
+ policy = PictureCmapPolicyAll;
+ }
+ else
+ {
+ int avail = pColormap->pVisual->ColormapEntries;
+ policy = PictureCmapPolicy;
+ if (policy == PictureCmapPolicyDefault)
+ {
+ if (avail >= 256 && (pColormap->pVisual->class|DynamicClass) == PseudoColor)
+ policy = PictureCmapPolicyColor;
+ else if (avail >= 64)
+ policy = PictureCmapPolicyGray;
+ else
+ policy = PictureCmapPolicyMono;
+ }
+ }
+ /*
+ * Make sure enough cells are free for the chosen policy
+ */
+ for (;;)
+ {
+ switch (policy) {
+ case PictureCmapPolicyAll:
+ needed = 0;
+ break;
+ case PictureCmapPolicyColor:
+ needed = 71;
+ break;
+ case PictureCmapPolicyGray:
+ needed = 11;
+ break;
+ case PictureCmapPolicyMono:
+ default:
+ needed = 0;
+ break;
+ }
+ if (needed <= pColormap->freeRed)
+ break;
+ policy--;
+ }
+
+ /*
+ * Compute size of cube and gray ramps
+ */
+ cube = gray = 0;
+ switch (policy) {
+ case PictureCmapPolicyAll:
+ /*
+ * Allocate as big a cube as possible
+ */
+ if ((pColormap->pVisual->class|DynamicClass) == PseudoColor)
+ {
+ for (cube = 1; cube * cube * cube < pColormap->pVisual->ColormapEntries; cube++)
+ ;
+ cube--;
+ if (cube == 1)
+ cube = 0;
+ }
+ else
+ cube = 0;
+ /*
+ * Figure out how many gray levels to use so that they
+ * line up neatly with the cube
+ */
+ if (cube)
+ {
+ needed = pColormap->pVisual->ColormapEntries - (cube*cube*cube);
+ /* levels to fill in with */
+ gray = needed / (cube - 1);
+ /* total levels */
+ gray = (gray + 1) * (cube - 1) + 1;
+ }
+ else
+ gray = pColormap->pVisual->ColormapEntries;
+ break;
+
+ case PictureCmapPolicyColor:
+ cube = NUM_CUBE_LEVELS;
+ /* fall through ... */
+ case PictureCmapPolicyGray:
+ gray = NUM_GRAY_LEVELS;
+ break;
+ case PictureCmapPolicyMono:
+ default:
+ gray = 2;
+ break;
+ }
+
+ memset (used, '\0', pColormap->pVisual->ColormapEntries * sizeof (Bool));
+ for (r = 0; r < cube; r++)
+ for (g = 0; g < cube; g++)
+ for (b = 0; b < cube; b++)
+ {
+ red = (r * 65535 + (cube-1)/2) / (cube - 1);
+ green = (g * 65535 + (cube-1)/2) / (cube - 1);
+ blue = (b * 65535 + (cube-1)/2) / (cube - 1);
+ if (AllocColor (pColormap, &red, &green,
+ &blue, &pixel, 0) != Success)
+ return FALSE;
+ used[pixel] = TRUE;
+ }
+ for (g = 0; g < gray; g++)
+ {
+ red = green = blue = (g * 65535 + (gray-1)/2) / (gray - 1);
+ if (AllocColor (pColormap, &red, &green, &blue, &pixel, 0) != Success)
+ return FALSE;
+ used[pixel] = TRUE;
+ }
+ n = 0;
+ for (i = 0; i < pColormap->pVisual->ColormapEntries; i++)
+ if (used[i])
+ pixels[n++] = i;
+
+ *nump = n;
+
+ return TRUE;
+}
+
+/* 0 <= red, green, blue < 32 */
+static Pixel
+FindBestColor (miIndexedPtr pIndexed, Pixel *pixels, int num,
+ int red, int green, int blue)
+{
+ Pixel best = pixels[0];
+ int bestDist = 1 << 30;
+ int dist;
+ int dr, dg, db;
+ while (num--)
+ {
+ Pixel pixel = *pixels++;
+ CARD32 v = pIndexed->rgba[pixel];
+
+ dr = ((v >> 19) & 0x1f);
+ dg = ((v >> 11) & 0x1f);
+ db = ((v >> 3) & 0x1f);
+ dr = dr - red;
+ dg = dg - green;
+ db = db - blue;
+ dist = dr * dr + dg * dg + db * db;
+ if (dist < bestDist)
+ {
+ bestDist = dist;
+ best = pixel;
+ }
+ }
+ return best;
+}
+
+/* 0 <= gray < 32768 */
+static Pixel
+FindBestGray (miIndexedPtr pIndexed, Pixel *pixels, int num, int gray)
+{
+ Pixel best = pixels[0];
+ int bestDist = 1 << 30;
+ int dist;
+ int dr;
+ int r;
+
+ while (num--)
+ {
+ Pixel pixel = *pixels++;
+ CARD32 v = pIndexed->rgba[pixel];
+
+ r = v & 0xff;
+ r = r | (r << 8);
+ dr = gray - (r >> 1);
+ dist = dr * dr;
+ if (dist < bestDist)
+ {
+ bestDist = dist;
+ best = pixel;
+ }
+ }
+ return best;
+}
+
+Bool
+miInitIndexed (ScreenPtr pScreen,
+ PictFormatPtr pFormat)
+{
+ ColormapPtr pColormap = pFormat->index.pColormap;
+ VisualPtr pVisual = pColormap->pVisual;
+ miIndexedPtr pIndexed;
+ Pixel pixels[MI_MAX_INDEXED];
+ xrgb rgb[MI_MAX_INDEXED];
+ int num;
+ int i;
+ Pixel p, r, g, b;
+
+ if (pVisual->ColormapEntries > MI_MAX_INDEXED)
+ return FALSE;
+
+ if (pVisual->class & DynamicClass)
+ {
+ if (!miBuildRenderColormap (pColormap, pixels, &num))
+ return FALSE;
+ }
+ else
+ {
+ num = pVisual->ColormapEntries;
+ for (p = 0; p < num; p++)
+ pixels[p] = p;
+ }
+
+ pIndexed = xalloc (sizeof (miIndexedRec));
+ if (!pIndexed)
+ return FALSE;
+
+ pFormat->index.nvalues = num;
+ pFormat->index.pValues = xalloc (num * sizeof (xIndexValue));
+ if (!pFormat->index.pValues)
+ {
+ xfree (pIndexed);
+ return FALSE;
+ }
+
+
+ /*
+ * Build mapping from pixel value to ARGB
+ */
+ QueryColors (pColormap, num, pixels, rgb);
+ for (i = 0; i < num; i++)
+ {
+ p = pixels[i];
+ pFormat->index.pValues[i].pixel = p;
+ pFormat->index.pValues[i].red = rgb[i].red;
+ pFormat->index.pValues[i].green = rgb[i].green;
+ pFormat->index.pValues[i].blue = rgb[i].blue;
+ pFormat->index.pValues[i].alpha = 0xffff;
+ pIndexed->rgba[p] = (0xff000000 |
+ ((rgb[i].red & 0xff00) << 8) |
+ ((rgb[i].green & 0xff00) ) |
+ ((rgb[i].blue & 0xff00) >> 8));
+ }
+
+ /*
+ * Build mapping from RGB to pixel value. This could probably be
+ * done a bit quicker...
+ */
+ switch (pVisual->class | DynamicClass) {
+ case GrayScale:
+ pIndexed->color = FALSE;
+ for (r = 0; r < 32768; r++)
+ pIndexed->ent[r] = FindBestGray (pIndexed, pixels, num, r);
+ break;
+ case PseudoColor:
+ pIndexed->color = TRUE;
+ p = 0;
+ for (r = 0; r < 32; r++)
+ for (g = 0; g < 32; g++)
+ for (b = 0; b < 32; b++)
+ {
+ pIndexed->ent[p] = FindBestColor (pIndexed, pixels, num,
+ r, g, b);
+ p++;
+ }
+ break;
+ }
+ pFormat->index.devPrivate = pIndexed;
+ return TRUE;
+}
+
+void
+miCloseIndexed (ScreenPtr pScreen,
+ PictFormatPtr pFormat)
+{
+ if (pFormat->index.devPrivate)
+ {
+ xfree (pFormat->index.devPrivate);
+ pFormat->index.devPrivate = 0;
+ }
+ if (pFormat->index.pValues)
+ {
+ xfree (pFormat->index.pValues);
+ pFormat->index.pValues = 0;
+ }
+}
+
+void
+miUpdateIndexed (ScreenPtr pScreen,
+ PictFormatPtr pFormat,
+ int ndef,
+ xColorItem *pdef)
+{
+ miIndexedPtr pIndexed = pFormat->index.devPrivate;
+
+ if (pIndexed)
+ {
+ while (ndef--)
+ {
+ pIndexed->rgba[pdef->pixel] = (0xff000000 |
+ ((pdef->red & 0xff00) << 8) |
+ ((pdef->green & 0xff00) ) |
+ ((pdef->blue & 0xff00) >> 8));
+ pdef++;
+ }
+ }
+}
+
+#endif /* _MIINDEX_H_ */
diff --git a/nx-X11/programs/Xserver/render/mipict.c b/nx-X11/programs/Xserver/render/mipict.c
new file mode 100644
index 000000000..81c775832
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/mipict.c
@@ -0,0 +1,629 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/mipict.c,v 1.15tsi Exp $
+ *
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "picturestr.h"
+#include "mipict.h"
+
+#ifndef __GNUC__
+#define __inline
+#endif
+
+int
+miCreatePicture (PicturePtr pPicture)
+{
+ return Success;
+}
+
+void
+miDestroyPicture (PicturePtr pPicture)
+{
+ if (pPicture->freeCompClip)
+ REGION_DESTROY(pPicture->pDrawable->pScreen, pPicture->pCompositeClip);
+}
+
+void
+miDestroyPictureClip (PicturePtr pPicture)
+{
+ switch (pPicture->clientClipType) {
+ case CT_NONE:
+ return;
+ case CT_PIXMAP:
+ (*pPicture->pDrawable->pScreen->DestroyPixmap) ((PixmapPtr) (pPicture->clientClip));
+ break;
+ default:
+ /*
+ * we know we'll never have a list of rectangles, since ChangeClip
+ * immediately turns them into a region
+ */
+ REGION_DESTROY(pPicture->pDrawable->pScreen, pPicture->clientClip);
+ break;
+ }
+ pPicture->clientClip = NULL;
+ pPicture->clientClipType = CT_NONE;
+}
+
+int
+miChangePictureClip (PicturePtr pPicture,
+ int type,
+ pointer value,
+ int n)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ pointer clientClip;
+ int clientClipType;
+
+ switch (type) {
+ case CT_PIXMAP:
+ /* convert the pixmap to a region */
+ clientClip = (pointer) BITMAP_TO_REGION(pScreen, (PixmapPtr) value);
+ if (!clientClip)
+ return BadAlloc;
+ clientClipType = CT_REGION;
+ (*pScreen->DestroyPixmap) ((PixmapPtr) value);
+ break;
+ case CT_REGION:
+ clientClip = value;
+ clientClipType = CT_REGION;
+ break;
+ case CT_NONE:
+ clientClip = 0;
+ clientClipType = CT_NONE;
+ break;
+ default:
+ clientClip = (pointer) RECTS_TO_REGION(pScreen, n,
+ (xRectangle *) value,
+ type);
+ if (!clientClip)
+ return BadAlloc;
+ clientClipType = CT_REGION;
+ xfree(value);
+ break;
+ }
+ (*ps->DestroyPictureClip) (pPicture);
+ pPicture->clientClip = clientClip;
+ pPicture->clientClipType = clientClipType;
+ pPicture->stateChanges |= CPClipMask;
+ return Success;
+}
+
+void
+miChangePicture (PicturePtr pPicture,
+ Mask mask)
+{
+ return;
+}
+
+void
+miValidatePicture (PicturePtr pPicture,
+ Mask mask)
+{
+ DrawablePtr pDrawable = pPicture->pDrawable;
+ ScreenPtr pScreen = pDrawable->pScreen;
+
+ if ((mask & (CPClipXOrigin|CPClipYOrigin|CPClipMask|CPSubwindowMode)) ||
+ (pDrawable->serialNumber != (pPicture->serialNumber & DRAWABLE_SERIAL_BITS)))
+ {
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ {
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ RegionPtr pregWin;
+ Bool freeTmpClip, freeCompClip;
+
+ if (pPicture->subWindowMode == IncludeInferiors)
+ {
+ pregWin = NotClippedByChildren(pWin);
+ freeTmpClip = TRUE;
+ }
+ else
+ {
+ pregWin = &pWin->clipList;
+ freeTmpClip = FALSE;
+ }
+ freeCompClip = pPicture->freeCompClip;
+
+ /*
+ * if there is no client clip, we can get by with just keeping the
+ * pointer we got, and remembering whether or not should destroy
+ * (or maybe re-use) it later. this way, we avoid unnecessary
+ * copying of regions. (this wins especially if many clients clip
+ * by children and have no client clip.)
+ */
+ if (pPicture->clientClipType == CT_NONE)
+ {
+ if (freeCompClip)
+ REGION_DESTROY(pScreen, pPicture->pCompositeClip);
+ pPicture->pCompositeClip = pregWin;
+ pPicture->freeCompClip = freeTmpClip;
+ }
+ else
+ {
+ /*
+ * we need one 'real' region to put into the composite clip. if
+ * pregWin the current composite clip are real, we can get rid of
+ * one. if pregWin is real and the current composite clip isn't,
+ * use pregWin for the composite clip. if the current composite
+ * clip is real and pregWin isn't, use the current composite
+ * clip. if neither is real, create a new region.
+ */
+
+ REGION_TRANSLATE(pScreen, pPicture->clientClip,
+ pDrawable->x + pPicture->clipOrigin.x,
+ pDrawable->y + pPicture->clipOrigin.y);
+
+ if (freeCompClip)
+ {
+ REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+ pregWin, pPicture->clientClip);
+ if (freeTmpClip)
+ REGION_DESTROY(pScreen, pregWin);
+ }
+ else if (freeTmpClip)
+ {
+ REGION_INTERSECT(pScreen, pregWin, pregWin, pPicture->clientClip);
+ pPicture->pCompositeClip = pregWin;
+ }
+ else
+ {
+ pPicture->pCompositeClip = REGION_CREATE(pScreen, NullBox, 0);
+ REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+ pregWin, pPicture->clientClip);
+ }
+ pPicture->freeCompClip = TRUE;
+ REGION_TRANSLATE(pScreen, pPicture->clientClip,
+ -(pDrawable->x + pPicture->clipOrigin.x),
+ -(pDrawable->y + pPicture->clipOrigin.y));
+ }
+ } /* end of composite clip for a window */
+ else
+ {
+ BoxRec pixbounds;
+
+ /* XXX should we translate by drawable.x/y here ? */
+ /* If you want pixmaps in offscreen memory, yes */
+ pixbounds.x1 = pDrawable->x;
+ pixbounds.y1 = pDrawable->y;
+ pixbounds.x2 = pDrawable->x + pDrawable->width;
+ pixbounds.y2 = pDrawable->y + pDrawable->height;
+
+ if (pPicture->freeCompClip)
+ {
+ REGION_RESET(pScreen, pPicture->pCompositeClip, &pixbounds);
+ }
+ else
+ {
+ pPicture->freeCompClip = TRUE;
+ pPicture->pCompositeClip = REGION_CREATE(pScreen, &pixbounds, 1);
+ }
+
+ if (pPicture->clientClipType == CT_REGION)
+ {
+ if(pDrawable->x || pDrawable->y) {
+ REGION_TRANSLATE(pScreen, pPicture->clientClip,
+ pDrawable->x + pPicture->clipOrigin.x,
+ pDrawable->y + pPicture->clipOrigin.y);
+ REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+ pPicture->pCompositeClip, pPicture->clientClip);
+ REGION_TRANSLATE(pScreen, pPicture->clientClip,
+ -(pDrawable->x + pPicture->clipOrigin.x),
+ -(pDrawable->y + pPicture->clipOrigin.y));
+ } else {
+ REGION_TRANSLATE(pScreen, pPicture->pCompositeClip,
+ -pPicture->clipOrigin.x, -pPicture->clipOrigin.y);
+ REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+ pPicture->pCompositeClip, pPicture->clientClip);
+ REGION_TRANSLATE(pScreen, pPicture->pCompositeClip,
+ pPicture->clipOrigin.x, pPicture->clipOrigin.y);
+ }
+ }
+ } /* end of composite clip for pixmap */
+ }
+}
+
+#define BOUND(v) (INT16) ((v) < MINSHORT ? MINSHORT : (v) > MAXSHORT ? MAXSHORT : (v))
+
+static __inline Bool
+miClipPictureReg (RegionPtr pRegion,
+ RegionPtr pClip,
+ int dx,
+ int dy)
+{
+ if (REGION_NUM_RECTS(pRegion) == 1 &&
+ REGION_NUM_RECTS(pClip) == 1)
+ {
+ BoxPtr pRbox = REGION_RECTS(pRegion);
+ BoxPtr pCbox = REGION_RECTS(pClip);
+ int v;
+
+ if (pRbox->x1 < (v = pCbox->x1 + dx))
+ pRbox->x1 = BOUND(v);
+ if (pRbox->x2 > (v = pCbox->x2 + dx))
+ pRbox->x2 = BOUND(v);
+ if (pRbox->y1 < (v = pCbox->y1 + dy))
+ pRbox->y1 = BOUND(v);
+ if (pRbox->y2 > (v = pCbox->y2 + dy))
+ pRbox->y2 = BOUND(v);
+ if (pRbox->x1 >= pRbox->x2 ||
+ pRbox->y1 >= pRbox->y2)
+ {
+ REGION_EMPTY(pScreen, pRegion);
+ }
+ }
+ else if (!REGION_NOTEMPTY (pScreen, pClip))
+ return FALSE;
+ else
+ {
+ if (dx || dy)
+ REGION_TRANSLATE(pScreen, pRegion, -dx, -dy);
+ if (!REGION_INTERSECT (pScreen, pRegion, pRegion, pClip))
+ return FALSE;
+ if (dx || dy)
+ REGION_TRANSLATE(pScreen, pRegion, dx, dy);
+ }
+ return REGION_NOTEMPTY(pScreen, pRegion);
+}
+
+static __inline Bool
+miClipPictureSrc (RegionPtr pRegion,
+ PicturePtr pPicture,
+ int dx,
+ int dy)
+{
+ /* XXX what to do with clipping from transformed pictures? */
+ if (pPicture->transform || !pPicture->pDrawable)
+ return TRUE;
+ if (pPicture->repeat)
+ {
+ if (pPicture->clientClipType != CT_NONE)
+ {
+ REGION_TRANSLATE(pScreen, pRegion,
+ dx - pPicture->clipOrigin.x,
+ dy - pPicture->clipOrigin.y);
+ if (!REGION_INTERSECT (pScreen, pRegion, pRegion,
+ (RegionPtr) pPicture->clientClip))
+ return FALSE;
+ REGION_TRANSLATE(pScreen, pRegion,
+ - (dx - pPicture->clipOrigin.x),
+ - (dy - pPicture->clipOrigin.y));
+ }
+ return TRUE;
+ }
+ else
+ {
+ return miClipPictureReg (pRegion,
+ pPicture->pCompositeClip,
+ dx,
+ dy);
+ }
+}
+
+static void
+miCompositeSourceValidate (PicturePtr pPicture,
+ INT16 x,
+ INT16 y,
+ CARD16 width,
+ CARD16 height)
+{
+ DrawablePtr pDrawable = pPicture->pDrawable;
+ ScreenPtr pScreen;
+
+ if (!pDrawable)
+ return;
+
+ pScreen = pDrawable->pScreen;
+
+ if (pScreen->SourceValidate)
+ {
+ x -= pPicture->pDrawable->x;
+ y -= pPicture->pDrawable->y;
+ if (pPicture->transform)
+ {
+ xPoint points[4];
+ int i;
+ int xmin, ymin, xmax, ymax;
+
+#define VectorSet(i,_x,_y) { points[i].x = _x; points[i].y = _y; }
+ VectorSet (0, x, y);
+ VectorSet (1, x + width, y);
+ VectorSet (2, x, y + height);
+ VectorSet (3, x + width, y + height);
+ xmin = ymin = 32767;
+ xmax = ymax = -32737;
+ for (i = 0; i < 4; i++)
+ {
+ PictVector t;
+ t.vector[0] = IntToxFixed (points[i].x);
+ t.vector[1] = IntToxFixed (points[i].y);
+ t.vector[2] = xFixed1;
+ if (PictureTransformPoint (pPicture->transform, &t))
+ {
+ int tx = xFixedToInt (t.vector[0]);
+ int ty = xFixedToInt (t.vector[1]);
+ if (tx < xmin) xmin = tx;
+ if (tx > xmax) xmax = tx;
+ if (ty < ymin) ymin = ty;
+ if (ty > ymax) ymax = ty;
+ }
+ }
+ x = xmin;
+ y = ymin;
+ width = xmax - xmin;
+ height = ymax - ymin;
+ }
+ (*pScreen->SourceValidate) (pDrawable, x, y, width, height);
+ }
+}
+
+/*
+ * returns FALSE if the final region is empty. Indistinguishable from
+ * an allocation failure, but rendering ignores those anyways.
+ */
+
+Bool
+miComputeCompositeRegion (RegionPtr pRegion,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ int v;
+
+ pRegion->extents.x1 = xDst;
+ v = xDst + width;
+ pRegion->extents.x2 = BOUND(v);
+ pRegion->extents.y1 = yDst;
+ v = yDst + height;
+ pRegion->extents.y2 = BOUND(v);
+ pRegion->data = 0;
+ /* Check for empty operation */
+ if (pRegion->extents.x1 >= pRegion->extents.x2 ||
+ pRegion->extents.y1 >= pRegion->extents.y2)
+ {
+ REGION_EMPTY (pDst->pDrawable->pScreen, pRegion);
+ return FALSE;
+ }
+ /* clip against dst */
+ if (!miClipPictureReg (pRegion, pDst->pCompositeClip, 0, 0))
+ {
+ REGION_UNINIT (pScreen, pRegion);
+ return FALSE;
+ }
+ if (pDst->alphaMap)
+ {
+ if (!miClipPictureReg (pRegion, pDst->alphaMap->pCompositeClip,
+ -pDst->alphaOrigin.x,
+ -pDst->alphaOrigin.y))
+ {
+ REGION_UNINIT (pScreen, pRegion);
+ return FALSE;
+ }
+ }
+ /* clip against src */
+ if (!miClipPictureSrc (pRegion, pSrc, xDst - xSrc, yDst - ySrc))
+ {
+ REGION_UNINIT (pScreen, pRegion);
+ return FALSE;
+ }
+ if (pSrc->alphaMap)
+ {
+ if (!miClipPictureSrc (pRegion, pSrc->alphaMap,
+ xDst - (xSrc + pSrc->alphaOrigin.x),
+ yDst - (ySrc + pSrc->alphaOrigin.y)))
+ {
+ REGION_UNINIT (pScreen, pRegion);
+ return FALSE;
+ }
+ }
+ /* clip against mask */
+ if (pMask)
+ {
+ if (!miClipPictureSrc (pRegion, pMask, xDst - xMask, yDst - yMask))
+ {
+ REGION_UNINIT (pScreen, pRegion);
+ return FALSE;
+ }
+ if (pMask->alphaMap)
+ {
+ if (!miClipPictureSrc (pRegion, pMask->alphaMap,
+ xDst - (xMask + pMask->alphaOrigin.x),
+ yDst - (yMask + pMask->alphaOrigin.y)))
+ {
+ REGION_UNINIT (pScreen, pRegion);
+ return FALSE;
+ }
+ }
+ }
+ miCompositeSourceValidate (pSrc, xSrc, ySrc, width, height);
+ if (pMask)
+ miCompositeSourceValidate (pMask, xMask, yMask, width, height);
+ return TRUE;
+}
+
+void
+miRenderColorToPixel (PictFormatPtr format,
+ xRenderColor *color,
+ CARD32 *pixel)
+{
+ CARD32 r, g, b, a;
+ miIndexedPtr pIndexed;
+
+ switch (format->type) {
+ case PictTypeDirect:
+ r = color->red >> (16 - Ones (format->direct.redMask));
+ g = color->green >> (16 - Ones (format->direct.greenMask));
+ b = color->blue >> (16 - Ones (format->direct.blueMask));
+ a = color->alpha >> (16 - Ones (format->direct.alphaMask));
+ r = r << format->direct.red;
+ g = g << format->direct.green;
+ b = b << format->direct.blue;
+ a = a << format->direct.alpha;
+ *pixel = r|g|b|a;
+ break;
+ case PictTypeIndexed:
+ pIndexed = (miIndexedPtr) (format->index.devPrivate);
+ if (pIndexed->color)
+ {
+ r = color->red >> 11;
+ g = color->green >> 11;
+ b = color->blue >> 11;
+ *pixel = miIndexToEnt15 (pIndexed, (r << 10) | (g << 5) | b);
+ }
+ else
+ {
+ r = color->red >> 8;
+ g = color->green >> 8;
+ b = color->blue >> 8;
+ *pixel = miIndexToEntY24 (pIndexed, (r << 16) | (g << 8) | b);
+ }
+ break;
+ }
+}
+
+static CARD16
+miFillColor (CARD32 pixel, int bits)
+{
+ while (bits < 16)
+ {
+ pixel |= pixel << bits;
+ bits <<= 1;
+ }
+ return (CARD16) pixel;
+}
+
+Bool
+miIsSolidAlpha (PicturePtr pSrc)
+{
+ ScreenPtr pScreen;
+ char line[1];
+
+ if (!pSrc->pDrawable)
+ return FALSE;
+
+ pScreen = pSrc->pDrawable->pScreen;
+
+ /* Alpha-only */
+ if (PICT_FORMAT_TYPE (pSrc->format) != PICT_TYPE_A)
+ return FALSE;
+ /* repeat */
+ if (!pSrc->repeat)
+ return FALSE;
+ /* 1x1 */
+ if (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1)
+ return FALSE;
+ line[0] = 1;
+ (*pScreen->GetImage) (pSrc->pDrawable, 0, 0, 1, 1, ZPixmap, ~0L, line);
+ switch (pSrc->pDrawable->bitsPerPixel) {
+ case 1:
+ return (CARD8) line[0] == 1 || (CARD8) line[0] == 0x80;
+ case 4:
+ return (CARD8) line[0] == 0xf || (CARD8) line[0] == 0xf0;
+ case 8:
+ return (CARD8) line[0] == 0xff;
+ default:
+ return FALSE;
+ }
+}
+
+void
+miRenderPixelToColor (PictFormatPtr format,
+ CARD32 pixel,
+ xRenderColor *color)
+{
+ CARD32 r, g, b, a;
+ miIndexedPtr pIndexed;
+
+ switch (format->type) {
+ case PictTypeDirect:
+ r = (pixel >> format->direct.red) & format->direct.redMask;
+ g = (pixel >> format->direct.green) & format->direct.greenMask;
+ b = (pixel >> format->direct.blue) & format->direct.blueMask;
+ a = (pixel >> format->direct.alpha) & format->direct.alphaMask;
+ color->red = miFillColor (r, Ones (format->direct.redMask));
+ color->green = miFillColor (g, Ones (format->direct.greenMask));
+ color->blue = miFillColor (b, Ones (format->direct.blueMask));
+ color->alpha = miFillColor (a, Ones (format->direct.alphaMask));
+ break;
+ case PictTypeIndexed:
+ pIndexed = (miIndexedPtr) (format->index.devPrivate);
+ pixel = pIndexed->rgba[pixel & (MI_MAX_INDEXED-1)];
+ r = (pixel >> 16) & 0xff;
+ g = (pixel >> 8) & 0xff;
+ b = (pixel ) & 0xff;
+ color->red = miFillColor (r, 8);
+ color->green = miFillColor (g, 8);
+ color->blue = miFillColor (b, 8);
+ color->alpha = 0xffff;
+ break;
+ }
+}
+
+Bool
+miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
+{
+ PictureScreenPtr ps;
+
+ if (!PictureInit (pScreen, formats, nformats))
+ return FALSE;
+ ps = GetPictureScreen(pScreen);
+ ps->CreatePicture = miCreatePicture;
+ ps->DestroyPicture = miDestroyPicture;
+ ps->ChangePictureClip = miChangePictureClip;
+ ps->DestroyPictureClip = miDestroyPictureClip;
+ ps->ChangePicture = miChangePicture;
+ ps->ValidatePicture = miValidatePicture;
+ ps->InitIndexed = miInitIndexed;
+ ps->CloseIndexed = miCloseIndexed;
+ ps->UpdateIndexed = miUpdateIndexed;
+
+ /* MI rendering routines */
+ ps->Composite = 0; /* requires DDX support */
+ ps->Glyphs = miGlyphs;
+ ps->CompositeRects = miCompositeRects;
+ ps->Trapezoids = miTrapezoids;
+ ps->Triangles = miTriangles;
+ ps->TriStrip = miTriStrip;
+ ps->TriFan = miTriFan;
+
+ ps->RasterizeTrapezoid = 0; /* requires DDX support */
+ ps->AddTraps = 0; /* requires DDX support */
+ ps->AddTriangles = 0; /* requires DDX support */
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/render/mipict.h b/nx-X11/programs/Xserver/render/mipict.h
new file mode 100644
index 000000000..e6e8b70fa
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/mipict.h
@@ -0,0 +1,213 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/mipict.h,v 1.12 2002/11/05 05:34:40 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _MIPICT_H_
+#define _MIPICT_H_
+
+#include "picturestr.h"
+
+#define MI_MAX_INDEXED 256 /* XXX depth must be <= 8 */
+
+#if MI_MAX_INDEXED <= 256
+typedef CARD8 miIndexType;
+#endif
+
+typedef struct _miIndexed {
+ Bool color;
+ CARD32 rgba[MI_MAX_INDEXED];
+ miIndexType ent[32768];
+} miIndexedRec, *miIndexedPtr;
+
+#define miCvtR8G8B8to15(s) ((((s) >> 3) & 0x001f) | \
+ (((s) >> 6) & 0x03e0) | \
+ (((s) >> 9) & 0x7c00))
+#define miIndexToEnt15(mif,rgb15) ((mif)->ent[rgb15])
+#define miIndexToEnt24(mif,rgb24) miIndexToEnt15(mif,miCvtR8G8B8to15(rgb24))
+
+#define miIndexToEntY24(mif,rgb24) ((mif)->ent[CvtR8G8B8toY15(rgb24)])
+
+int
+miCreatePicture (PicturePtr pPicture);
+
+void
+miDestroyPicture (PicturePtr pPicture);
+
+void
+miDestroyPictureClip (PicturePtr pPicture);
+
+int
+miChangePictureClip (PicturePtr pPicture,
+ int type,
+ pointer value,
+ int n);
+
+void
+miChangePicture (PicturePtr pPicture,
+ Mask mask);
+
+void
+miValidatePicture (PicturePtr pPicture,
+ Mask mask);
+
+
+Bool
+miClipPicture (RegionPtr pRegion,
+ PicturePtr pPicture,
+ INT16 xReg,
+ INT16 yReg,
+ INT16 xPict,
+ INT16 yPict);
+
+Bool
+miComputeCompositeRegion (RegionPtr pRegion,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+Bool
+miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
+
+void
+miGlyphExtents (int nlist,
+ GlyphListPtr list,
+ GlyphPtr *glyphs,
+ BoxPtr extents);
+
+void
+miGlyphs (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlist,
+ GlyphListPtr list,
+ GlyphPtr *glyphs);
+
+void
+miRenderColorToPixel (PictFormatPtr pPict,
+ xRenderColor *color,
+ CARD32 *pixel);
+
+void
+miRenderPixelToColor (PictFormatPtr pPict,
+ CARD32 pixel,
+ xRenderColor *color);
+
+Bool
+miIsSolidAlpha (PicturePtr pSrc);
+
+void
+miCompositeRects (CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects);
+
+void
+miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box);
+
+void
+miTrapezoids (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntrap,
+ xTrapezoid *traps);
+
+void
+miPointFixedBounds (int npoint, xPointFixed *points, BoxPtr bounds);
+
+void
+miTriangleBounds (int ntri, xTriangle *tris, BoxPtr bounds);
+
+void
+miRasterizeTriangle (PicturePtr pMask,
+ xTriangle *tri,
+ int x_off,
+ int y_off);
+
+void
+miTriangles (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntri,
+ xTriangle *tris);
+
+void
+miTriStrip (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoint,
+ xPointFixed *points);
+
+void
+miTriFan (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoint,
+ xPointFixed *points);
+
+PicturePtr
+miCreateAlphaPicture (ScreenPtr pScreen,
+ PicturePtr pDst,
+ PictFormatPtr pPictFormat,
+ CARD16 width,
+ CARD16 height);
+
+Bool
+miInitIndexed (ScreenPtr pScreen,
+ PictFormatPtr pFormat);
+
+void
+miCloseIndexed (ScreenPtr pScreen,
+ PictFormatPtr pFormat);
+
+void
+miUpdateIndexed (ScreenPtr pScreen,
+ PictFormatPtr pFormat,
+ int ndef,
+ xColorItem *pdef);
+
+#endif /* _MIPICT_H_ */
diff --git a/nx-X11/programs/Xserver/render/mirect.c b/nx-X11/programs/Xserver/render/mirect.c
new file mode 100644
index 000000000..096bb5cb2
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/mirect.c
@@ -0,0 +1,186 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/mirect.c,v 1.3 2000/12/08 07:52:05 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "picturestr.h"
+#include "mipict.h"
+
+static void
+miColorRects (PicturePtr pDst,
+ PicturePtr pClipPict,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects,
+ int xoff,
+ int yoff)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ CARD32 pixel;
+ GCPtr pGC;
+ CARD32 tmpval[5];
+ RegionPtr pClip;
+ unsigned long mask;
+
+ miRenderColorToPixel (pDst->pFormat, color, &pixel);
+
+ pGC = GetScratchGC (pDst->pDrawable->depth, pScreen);
+ if (!pGC)
+ return;
+ tmpval[0] = GXcopy;
+ tmpval[1] = pixel;
+ tmpval[2] = pDst->subWindowMode;
+ mask = GCFunction | GCForeground | GCSubwindowMode;
+ if (pClipPict->clientClipType == CT_REGION)
+ {
+ tmpval[3] = pDst->clipOrigin.x - xoff;
+ tmpval[4] = pDst->clipOrigin.y - yoff;
+ mask |= GCClipXOrigin|GCClipYOrigin;
+
+ pClip = REGION_CREATE (pScreen, NULL, 1);
+ REGION_COPY (pScreen, pClip,
+ (RegionPtr) pClipPict->clientClip);
+ (*pGC->funcs->ChangeClip) (pGC, CT_REGION, pClip, 0);
+ }
+
+ ChangeGC (pGC, mask, tmpval);
+ ValidateGC (pDst->pDrawable, pGC);
+ if (xoff || yoff)
+ {
+ int i;
+ for (i = 0; i < nRect; i++)
+ {
+ rects[i].x -= xoff;
+ rects[i].y -= yoff;
+ }
+ }
+ (*pGC->ops->PolyFillRect) (pDst->pDrawable, pGC, nRect, rects);
+ if (xoff || yoff)
+ {
+ int i;
+ for (i = 0; i < nRect; i++)
+ {
+ rects[i].x += xoff;
+ rects[i].y += yoff;
+ }
+ }
+ FreeScratchGC (pGC);
+}
+
+void
+miCompositeRects (CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+
+ if (color->alpha == 0xffff)
+ {
+ if (op == PictOpOver)
+ op = PictOpSrc;
+ }
+ if (op == PictOpClear)
+ color->red = color->green = color->blue = color->alpha = 0;
+
+ if (op == PictOpSrc || op == PictOpClear)
+ {
+ miColorRects (pDst, pDst, color, nRect, rects, 0, 0);
+ if (pDst->alphaMap)
+ miColorRects (pDst->alphaMap, pDst,
+ color, nRect, rects,
+ pDst->alphaOrigin.x,
+ pDst->alphaOrigin.y);
+ }
+ else
+ {
+ PictFormatPtr rgbaFormat;
+ PixmapPtr pPixmap;
+ PicturePtr pSrc;
+ xRectangle one;
+ int error;
+ Pixel pixel;
+ GCPtr pGC;
+ CARD32 tmpval[2];
+
+ rgbaFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
+ if (!rgbaFormat)
+ goto bail1;
+
+ pPixmap = (*pScreen->CreatePixmap) (pScreen, 1, 1,
+ rgbaFormat->depth);
+ if (!pPixmap)
+ goto bail2;
+
+ miRenderColorToPixel (rgbaFormat, color, &pixel);
+
+ pGC = GetScratchGC (rgbaFormat->depth, pScreen);
+ if (!pGC)
+ goto bail3;
+ tmpval[0] = GXcopy;
+ tmpval[1] = pixel;
+
+ ChangeGC (pGC, GCFunction | GCForeground, tmpval);
+ ValidateGC (&pPixmap->drawable, pGC);
+ one.x = 0;
+ one.y = 0;
+ one.width = 1;
+ one.height = 1;
+ (*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &one);
+
+ tmpval[0] = xTrue;
+ pSrc = CreatePicture (0, &pPixmap->drawable, rgbaFormat,
+ CPRepeat, tmpval, 0, &error);
+
+ if (!pSrc)
+ goto bail4;
+
+ while (nRect--)
+ {
+ CompositePicture (op, pSrc, 0, pDst, 0, 0, 0, 0,
+ rects->x,
+ rects->y,
+ rects->width,
+ rects->height);
+ rects++;
+ }
+
+ FreePicture ((pointer) pSrc, 0);
+bail4:
+ FreeScratchGC (pGC);
+bail3:
+ (*pScreen->DestroyPixmap) (pPixmap);
+bail2:
+bail1:
+ ;
+ }
+}
diff --git a/nx-X11/programs/Xserver/render/mitrap.c b/nx-X11/programs/Xserver/render/mitrap.c
new file mode 100644
index 000000000..be1712420
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/mitrap.c
@@ -0,0 +1,190 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/mitrap.c,v 1.8 2002/09/03 19:28:28 keithp Exp $
+ *
+ * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#include "mi.h"
+#include "picturestr.h"
+#include "mipict.h"
+
+PicturePtr
+miCreateAlphaPicture (ScreenPtr pScreen,
+ PicturePtr pDst,
+ PictFormatPtr pPictFormat,
+ CARD16 width,
+ CARD16 height)
+{
+ PixmapPtr pPixmap;
+ PicturePtr pPicture;
+ GCPtr pGC;
+ int error;
+ xRectangle rect;
+
+ if (width > 32767 || height > 32767)
+ return 0;
+
+ if (!pPictFormat)
+ {
+ if (pDst->polyEdge == PolyEdgeSharp)
+ pPictFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+ else
+ pPictFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+ if (!pPictFormat)
+ return 0;
+ }
+
+ pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
+ pPictFormat->depth);
+ if (!pPixmap)
+ return 0;
+ pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
+ if (!pGC)
+ {
+ (*pScreen->DestroyPixmap) (pPixmap);
+ return 0;
+ }
+ ValidateGC (&pPixmap->drawable, pGC);
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = width;
+ rect.height = height;
+ (*pGC->ops->PolyFillRect)(&pPixmap->drawable, pGC, 1, &rect);
+ FreeScratchGC (pGC);
+ pPicture = CreatePicture (0, &pPixmap->drawable, pPictFormat,
+ 0, 0, serverClient, &error);
+ (*pScreen->DestroyPixmap) (pPixmap);
+ return pPicture;
+}
+
+static xFixed
+miLineFixedX (xLineFixed *l, xFixed y, Bool ceil)
+{
+ xFixed dx = l->p2.x - l->p1.x;
+ xFixed_32_32 ex = (xFixed_32_32) (y - l->p1.y) * dx;
+ xFixed dy = l->p2.y - l->p1.y;
+ if (ceil)
+ ex += (dy - 1);
+ return l->p1.x + (xFixed) (ex / dy);
+}
+
+void
+miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box)
+{
+ box->y1 = MAXSHORT;
+ box->y2 = MINSHORT;
+ box->x1 = MAXSHORT;
+ box->x2 = MINSHORT;
+ for (; ntrap; ntrap--, traps++)
+ {
+ INT16 x1, y1, x2, y2;
+
+ if (!xTrapezoidValid(traps))
+ continue;
+ y1 = xFixedToInt (traps->top);
+ if (y1 < box->y1)
+ box->y1 = y1;
+
+ y2 = xFixedToInt (xFixedCeil (traps->bottom));
+ if (y2 > box->y2)
+ box->y2 = y2;
+
+ x1 = xFixedToInt (min (miLineFixedX (&traps->left, traps->top, FALSE),
+ miLineFixedX (&traps->left, traps->bottom, FALSE)));
+ if (x1 < box->x1)
+ box->x1 = x1;
+
+ x2 = xFixedToInt (xFixedCeil (max (miLineFixedX (&traps->right, traps->top, TRUE),
+ miLineFixedX (&traps->right, traps->bottom, TRUE))));
+ if (x2 > box->x2)
+ box->x2 = x2;
+ }
+}
+
+void
+miTrapezoids (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntrap,
+ xTrapezoid *traps)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+
+ /*
+ * Check for solid alpha add
+ */
+ if (op == PictOpAdd && miIsSolidAlpha (pSrc))
+ {
+ for (; ntrap; ntrap--, traps++)
+ (*ps->RasterizeTrapezoid) (pDst, traps, 0, 0);
+ }
+ else if (maskFormat)
+ {
+ PicturePtr pPicture;
+ BoxRec bounds;
+ INT16 xDst, yDst;
+ INT16 xRel, yRel;
+
+ xDst = traps[0].left.p1.x >> 16;
+ yDst = traps[0].left.p1.y >> 16;
+
+ miTrapezoidBounds (ntrap, traps, &bounds);
+ if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
+ return;
+ pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat,
+ bounds.x2 - bounds.x1,
+ bounds.y2 - bounds.y1);
+ if (!pPicture)
+ return;
+ for (; ntrap; ntrap--, traps++)
+ (*ps->RasterizeTrapezoid) (pPicture, traps,
+ -bounds.x1, -bounds.y1);
+ xRel = bounds.x1 + xSrc - xDst;
+ yRel = bounds.y1 + ySrc - yDst;
+ CompositePicture (op, pSrc, pPicture, pDst,
+ xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+ bounds.x2 - bounds.x1,
+ bounds.y2 - bounds.y1);
+ FreePicture (pPicture, 0);
+ }
+ else
+ {
+ if (pDst->polyEdge == PolyEdgeSharp)
+ maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+ else
+ maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+ for (; ntrap; ntrap--, traps++)
+ miTrapezoids (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, traps);
+ }
+}
diff --git a/nx-X11/programs/Xserver/render/mitri.c b/nx-X11/programs/Xserver/render/mitri.c
new file mode 100644
index 000000000..bc2641895
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/mitri.c
@@ -0,0 +1,192 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/mitri.c,v 1.5 2002/05/31 16:48:52 keithp Exp $
+ *
+ * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "picturestr.h"
+#include "mipict.h"
+
+void
+miPointFixedBounds (int npoint, xPointFixed *points, BoxPtr bounds)
+{
+ bounds->x1 = xFixedToInt (points->x);
+ bounds->x2 = xFixedToInt (xFixedCeil (points->x));
+ bounds->y1 = xFixedToInt (points->y);
+ bounds->y2 = xFixedToInt (xFixedCeil (points->y));
+ points++;
+ npoint--;
+ while (npoint-- > 0)
+ {
+ INT16 x1 = xFixedToInt (points->x);
+ INT16 x2 = xFixedToInt (xFixedCeil (points->x));
+ INT16 y1 = xFixedToInt (points->y);
+ INT16 y2 = xFixedToInt (xFixedCeil (points->y));
+
+ if (x1 < bounds->x1)
+ bounds->x1 = x1;
+ else if (x2 > bounds->x2)
+ bounds->x2 = x2;
+ if (y1 < bounds->y1)
+ bounds->y1 = y1;
+ else if (y2 > bounds->y2)
+ bounds->y2 = y2;
+ points++;
+ }
+}
+
+void
+miTriangleBounds (int ntri, xTriangle *tris, BoxPtr bounds)
+{
+ miPointFixedBounds (ntri * 3, (xPointFixed *) tris, bounds);
+}
+
+void
+miTriangles (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntri,
+ xTriangle *tris)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+
+ /*
+ * Check for solid alpha add
+ */
+ if (op == PictOpAdd && miIsSolidAlpha (pSrc))
+ {
+ (*ps->AddTriangles) (pDst, 0, 0, ntri, tris);
+ }
+ else if (maskFormat)
+ {
+ BoxRec bounds;
+ PicturePtr pPicture;
+ INT16 xDst, yDst;
+ INT16 xRel, yRel;
+
+ xDst = tris[0].p1.x >> 16;
+ yDst = tris[0].p1.y >> 16;
+
+ miTriangleBounds (ntri, tris, &bounds);
+ if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
+ return;
+ pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat,
+ bounds.x2 - bounds.x1,
+ bounds.y2 - bounds.y1);
+ if (!pPicture)
+ return;
+ (*ps->AddTriangles) (pPicture, -bounds.x1, -bounds.y1, ntri, tris);
+
+ xRel = bounds.x1 + xSrc - xDst;
+ yRel = bounds.y1 + ySrc - yDst;
+ CompositePicture (op, pSrc, pPicture, pDst,
+ xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+ bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
+ FreePicture (pPicture, 0);
+ }
+ else
+ {
+ if (pDst->polyEdge == PolyEdgeSharp)
+ maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+ else
+ maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+
+ for (; ntri; ntri--, tris++)
+ miTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, tris);
+ }
+}
+
+void
+miTriStrip (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoint,
+ xPointFixed *points)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ xTriangle *tris, *tri;
+ int ntri;
+
+ if (npoint < 3)
+ return;
+ ntri = npoint - 2;
+ tris = ALLOCATE_LOCAL (ntri * sizeof (xTriangle));
+ if (!tris)
+ return;
+ for (tri = tris; npoint >= 3; npoint--, points++, tri++)
+ {
+ tri->p1 = points[0];
+ tri->p2 = points[1];
+ tri->p3 = points[2];
+ }
+ (*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris);
+ DEALLOCATE_LOCAL (tris);
+}
+
+void
+miTriFan (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoint,
+ xPointFixed *points)
+{
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ xTriangle *tris, *tri;
+ xPointFixed *first;
+ int ntri;
+
+ if (npoint < 3)
+ return;
+ ntri = npoint - 2;
+ tris = ALLOCATE_LOCAL (ntri * sizeof (xTriangle));
+ if (!tris)
+ return;
+ first = points++;
+ for (tri = tris; npoint >= 3; npoint--, points++, tri++)
+ {
+ tri->p1 = *first;
+ tri->p2 = points[0];
+ tri->p3 = points[1];
+ }
+ (*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris);
+ DEALLOCATE_LOCAL (tris);
+}
diff --git a/nx-X11/programs/Xserver/render/picture.c b/nx-X11/programs/Xserver/render/picture.c
new file mode 100644
index 000000000..3ed60310e
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/picture.c
@@ -0,0 +1,1864 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/picture.c,v 1.29 2002/11/23 02:38:15 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "misc.h"
+#include "scrnintstr.h"
+#include "os.h"
+#include "regionstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "input.h"
+#include "resource.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#include "picturestr.h"
+
+int PictureScreenPrivateIndex = -1;
+int PictureWindowPrivateIndex;
+int PictureGeneration;
+RESTYPE PictureType;
+RESTYPE PictFormatType;
+RESTYPE GlyphSetType;
+int PictureCmapPolicy = PictureCmapPolicyDefault;
+
+/* Picture Private machinery */
+
+static int picturePrivateCount;
+
+void
+ResetPicturePrivateIndex (void)
+{
+ picturePrivateCount = 0;
+}
+
+int
+AllocatePicturePrivateIndex (void)
+{
+ return picturePrivateCount++;
+}
+
+Bool
+AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount)
+{
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ unsigned int oldamount;
+
+ /* Round up sizes for proper alignment */
+ amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
+
+ if (index2 >= ps->PicturePrivateLen)
+ {
+ unsigned int *nsizes;
+
+ nsizes = (unsigned int *)xrealloc(ps->PicturePrivateSizes,
+ (index2 + 1) * sizeof(unsigned int));
+ if (!nsizes)
+ return FALSE;
+ while (ps->PicturePrivateLen <= index2)
+ {
+ nsizes[ps->PicturePrivateLen++] = 0;
+ ps->totalPictureSize += sizeof(DevUnion);
+ }
+ ps->PicturePrivateSizes = nsizes;
+ }
+ oldamount = ps->PicturePrivateSizes[index2];
+ if (amount > oldamount)
+ {
+ ps->PicturePrivateSizes[index2] = amount;
+ ps->totalPictureSize += (amount - oldamount);
+ }
+
+ return TRUE;
+}
+
+
+Bool
+PictureDestroyWindow (WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ PicturePtr pPicture;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ Bool ret;
+
+ while ((pPicture = GetPictureWindow(pWindow)))
+ {
+ SetPictureWindow(pWindow, pPicture->pNext);
+ if (pPicture->id)
+ FreeResource (pPicture->id, PictureType);
+ FreePicture ((pointer) pPicture, pPicture->id);
+ }
+ pScreen->DestroyWindow = ps->DestroyWindow;
+ ret = (*pScreen->DestroyWindow) (pWindow);
+ ps->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = PictureDestroyWindow;
+ return ret;
+}
+
+Bool
+PictureCloseScreen (int index, ScreenPtr pScreen)
+{
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ Bool ret;
+ int n;
+
+ pScreen->CloseScreen = ps->CloseScreen;
+ ret = (*pScreen->CloseScreen) (index, pScreen);
+ PictureResetFilters (pScreen);
+ for (n = 0; n < ps->nformats; n++)
+ if (ps->formats[n].type == PictTypeIndexed)
+ (*ps->CloseIndexed) (pScreen, &ps->formats[n]);
+ SetPictureScreen(pScreen, 0);
+ if (ps->PicturePrivateSizes)
+ xfree (ps->PicturePrivateSizes);
+ xfree (ps->formats);
+ xfree (ps);
+ return ret;
+}
+
+void
+PictureStoreColors (ColormapPtr pColormap, int ndef, xColorItem *pdef)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+
+ pScreen->StoreColors = ps->StoreColors;
+ (*pScreen->StoreColors) (pColormap, ndef, pdef);
+ ps->StoreColors = pScreen->StoreColors;
+ pScreen->StoreColors = PictureStoreColors;
+
+ if (pColormap->class == PseudoColor || pColormap->class == GrayScale)
+ {
+ PictFormatPtr format = ps->formats;
+ int nformats = ps->nformats;
+
+ while (nformats--)
+ {
+ if (format->type == PictTypeIndexed &&
+ format->index.pColormap == pColormap)
+ {
+ (*ps->UpdateIndexed) (pScreen, format, ndef, pdef);
+ break;
+ }
+ format++;
+ }
+ }
+}
+
+static int
+visualDepth (ScreenPtr pScreen, VisualPtr pVisual)
+{
+ int d, v;
+ DepthPtr pDepth;
+
+ for (d = 0; d < pScreen->numDepths; d++)
+ {
+ pDepth = &pScreen->allowedDepths[d];
+ for (v = 0; v < pDepth->numVids; v++)
+ if (pDepth->vids[v] == pVisual->vid)
+ return pDepth->depth;
+ }
+ return 0;
+}
+
+typedef struct _formatInit {
+ CARD32 format;
+ CARD8 depth;
+} FormatInitRec, *FormatInitPtr;
+
+static int
+addFormat (FormatInitRec formats[256],
+ int nformat,
+ CARD32 format,
+ CARD8 depth)
+{
+ int n;
+
+ for (n = 0; n < nformat; n++)
+ if (formats[n].format == format && formats[n].depth == depth)
+ return nformat;
+ formats[nformat].format = format;
+ formats[nformat].depth = depth;
+ return ++nformat;
+}
+
+#define Mask(n) ((n) == 32 ? 0xffffffff : ((1 << (n))-1))
+
+PictFormatPtr
+PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
+{
+ int nformats, f;
+ PictFormatPtr pFormats;
+ FormatInitRec formats[1024];
+ CARD32 format;
+ CARD8 depth;
+ VisualPtr pVisual;
+ int v;
+ int bpp;
+ int type;
+ int r, g, b;
+ int d;
+ DepthPtr pDepth;
+
+ nformats = 0;
+ /* formats required by protocol */
+ formats[nformats].format = PICT_a1;
+ formats[nformats].depth = 1;
+ nformats++;
+ formats[nformats].format = PICT_a8;
+ formats[nformats].depth = 8;
+ nformats++;
+ formats[nformats].format = PICT_a4;
+ formats[nformats].depth = 4;
+ nformats++;
+ formats[nformats].format = PICT_a8r8g8b8;
+ formats[nformats].depth = 32;
+ nformats++;
+ formats[nformats].format = PICT_x8r8g8b8;
+ formats[nformats].depth = 32;
+ nformats++;
+
+ /* now look through the depths and visuals adding other formats */
+ for (v = 0; v < pScreen->numVisuals; v++)
+ {
+ pVisual = &pScreen->visuals[v];
+ depth = visualDepth (pScreen, pVisual);
+ if (!depth)
+ continue;
+ bpp = BitsPerPixel (depth);
+ switch (pVisual->class) {
+ case DirectColor:
+ case TrueColor:
+ r = Ones (pVisual->redMask);
+ g = Ones (pVisual->greenMask);
+ b = Ones (pVisual->blueMask);
+ type = PICT_TYPE_OTHER;
+ /*
+ * Current rendering code supports only two direct formats,
+ * fields must be packed together at the bottom of the pixel
+ * and must be either RGB or BGR
+ */
+ if (pVisual->offsetBlue == 0 &&
+ pVisual->offsetGreen == b &&
+ pVisual->offsetRed == b + g)
+ {
+ type = PICT_TYPE_ARGB;
+ }
+ else if (pVisual->offsetRed == 0 &&
+ pVisual->offsetGreen == r &&
+ pVisual->offsetBlue == r + g)
+ {
+ type = PICT_TYPE_ABGR;
+ }
+ if (type != PICT_TYPE_OTHER)
+ {
+ format = PICT_FORMAT(bpp, type, 0, r, g, b);
+ nformats = addFormat (formats, nformats, format, depth);
+ }
+ break;
+ case StaticColor:
+ case PseudoColor:
+ format = PICT_VISFORMAT (bpp, PICT_TYPE_COLOR, v);
+ nformats = addFormat (formats, nformats, format, depth);
+ break;
+ case StaticGray:
+ case GrayScale:
+ format = PICT_VISFORMAT (bpp, PICT_TYPE_GRAY, v);
+ nformats = addFormat (formats, nformats, format, depth);
+ break;
+ }
+ }
+ /*
+ * Walk supported depths and add useful Direct formats
+ */
+ for (d = 0; d < pScreen->numDepths; d++)
+ {
+ pDepth = &pScreen->allowedDepths[d];
+ bpp = BitsPerPixel (pDepth->depth);
+ format = 0;
+ switch (bpp) {
+ case 16:
+ /* depth 12 formats */
+ if (pDepth->depth >= 12)
+ {
+ nformats = addFormat (formats, nformats,
+ PICT_x4r4g4b4, pDepth->depth);
+ nformats = addFormat (formats, nformats,
+ PICT_x4b4g4r4, pDepth->depth);
+ }
+ /* depth 15 formats */
+ if (pDepth->depth >= 15)
+ {
+ nformats = addFormat (formats, nformats,
+ PICT_x1r5g5b5, pDepth->depth);
+ nformats = addFormat (formats, nformats,
+ PICT_x1b5g5r5, pDepth->depth);
+ }
+ /* depth 16 formats */
+ if (pDepth->depth >= 16)
+ {
+ nformats = addFormat (formats, nformats,
+ PICT_a1r5g5b5, pDepth->depth);
+ nformats = addFormat (formats, nformats,
+ PICT_a1b5g5r5, pDepth->depth);
+ nformats = addFormat (formats, nformats,
+ PICT_r5g6b5, pDepth->depth);
+ nformats = addFormat (formats, nformats,
+ PICT_b5g6r5, pDepth->depth);
+ nformats = addFormat (formats, nformats,
+ PICT_a4r4g4b4, pDepth->depth);
+ nformats = addFormat (formats, nformats,
+ PICT_a4b4g4r4, pDepth->depth);
+ }
+ break;
+ case 24:
+ if (pDepth->depth >= 24)
+ {
+ nformats = addFormat (formats, nformats,
+ PICT_r8g8b8, pDepth->depth);
+ nformats = addFormat (formats, nformats,
+ PICT_b8g8r8, pDepth->depth);
+ }
+ break;
+ case 32:
+ if (pDepth->depth >= 24)
+ {
+ nformats = addFormat (formats, nformats,
+ PICT_x8r8g8b8, pDepth->depth);
+ nformats = addFormat (formats, nformats,
+ PICT_x8b8g8r8, pDepth->depth);
+ }
+ break;
+ }
+ }
+
+
+ pFormats = (PictFormatPtr) xalloc (nformats * sizeof (PictFormatRec));
+ if (!pFormats)
+ return 0;
+ memset (pFormats, '\0', nformats * sizeof (PictFormatRec));
+ for (f = 0; f < nformats; f++)
+ {
+ pFormats[f].id = FakeClientID (0);
+ pFormats[f].depth = formats[f].depth;
+ format = formats[f].format;
+ pFormats[f].format = format;
+ switch (PICT_FORMAT_TYPE(format)) {
+ case PICT_TYPE_ARGB:
+ pFormats[f].type = PictTypeDirect;
+
+ pFormats[f].direct.alphaMask = Mask(PICT_FORMAT_A(format));
+ if (pFormats[f].direct.alphaMask)
+ pFormats[f].direct.alpha = (PICT_FORMAT_R(format) +
+ PICT_FORMAT_G(format) +
+ PICT_FORMAT_B(format));
+
+ pFormats[f].direct.redMask = Mask(PICT_FORMAT_R(format));
+ pFormats[f].direct.red = (PICT_FORMAT_G(format) +
+ PICT_FORMAT_B(format));
+
+ pFormats[f].direct.greenMask = Mask(PICT_FORMAT_G(format));
+ pFormats[f].direct.green = PICT_FORMAT_B(format);
+
+ pFormats[f].direct.blueMask = Mask(PICT_FORMAT_B(format));
+ pFormats[f].direct.blue = 0;
+ break;
+
+ case PICT_TYPE_ABGR:
+ pFormats[f].type = PictTypeDirect;
+
+ pFormats[f].direct.alphaMask = Mask(PICT_FORMAT_A(format));
+ if (pFormats[f].direct.alphaMask)
+ pFormats[f].direct.alpha = (PICT_FORMAT_B(format) +
+ PICT_FORMAT_G(format) +
+ PICT_FORMAT_R(format));
+
+ pFormats[f].direct.blueMask = Mask(PICT_FORMAT_B(format));
+ pFormats[f].direct.blue = (PICT_FORMAT_G(format) +
+ PICT_FORMAT_R(format));
+
+ pFormats[f].direct.greenMask = Mask(PICT_FORMAT_G(format));
+ pFormats[f].direct.green = PICT_FORMAT_R(format);
+
+ pFormats[f].direct.redMask = Mask(PICT_FORMAT_R(format));
+ pFormats[f].direct.red = 0;
+ break;
+
+ case PICT_TYPE_A:
+ pFormats[f].type = PictTypeDirect;
+
+ pFormats[f].direct.alpha = 0;
+ pFormats[f].direct.alphaMask = Mask(PICT_FORMAT_A(format));
+
+ /* remaining fields already set to zero */
+ break;
+
+ case PICT_TYPE_COLOR:
+ case PICT_TYPE_GRAY:
+ pFormats[f].type = PictTypeIndexed;
+ pFormats[f].index.vid = pScreen->visuals[PICT_FORMAT_VIS(format)].vid;
+ break;
+ }
+ }
+ *nformatp = nformats;
+ return pFormats;
+}
+
+static VisualPtr
+PictureFindVisual (ScreenPtr pScreen, VisualID visual)
+{
+ int i;
+ VisualPtr pVisual;
+ for (i = 0, pVisual = pScreen->visuals;
+ i < pScreen->numVisuals;
+ i++, pVisual++)
+ {
+ if (pVisual->vid == visual)
+ return pVisual;
+ }
+ return 0;
+}
+
+Bool
+PictureInitIndexedFormats (ScreenPtr pScreen)
+{
+ PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
+ PictFormatPtr format;
+ int nformat;
+
+ if (!ps)
+ return FALSE;
+ format = ps->formats;
+ nformat = ps->nformats;
+ while (nformat--)
+ {
+ if (format->type == PictTypeIndexed && !format->index.pColormap)
+ {
+ if (format->index.vid == pScreen->rootVisual)
+ format->index.pColormap = (ColormapPtr) LookupIDByType(pScreen->defColormap,
+ RT_COLORMAP);
+ else
+ {
+ VisualPtr pVisual;
+
+ pVisual = PictureFindVisual (pScreen, format->index.vid);
+ if (CreateColormap (FakeClientID (0), pScreen,
+ pVisual,
+ &format->index.pColormap, AllocNone,
+ 0) != Success)
+ {
+ return FALSE;
+ }
+ }
+ if (!(*ps->InitIndexed) (pScreen, format))
+ return FALSE;
+ }
+ format++;
+ }
+ return TRUE;
+}
+
+Bool
+PictureFinishInit (void)
+{
+ int s;
+
+ for (s = 0; s < screenInfo.numScreens; s++)
+ {
+ if (!PictureInitIndexedFormats (screenInfo.screens[s]))
+ return FALSE;
+ (void) AnimCurInit (screenInfo.screens[s]);
+ }
+
+ return TRUE;
+}
+
+Bool
+PictureSetSubpixelOrder (ScreenPtr pScreen, int subpixel)
+{
+ PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
+
+ if (!ps)
+ return FALSE;
+ ps->subpixel = subpixel;
+ return TRUE;
+
+}
+
+int
+PictureGetSubpixelOrder (ScreenPtr pScreen)
+{
+ PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
+
+ if (!ps)
+ return SubPixelUnknown;
+ return ps->subpixel;
+}
+
+PictFormatPtr
+PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual)
+{
+ PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
+ PictFormatPtr format;
+ int nformat;
+ int type;
+
+ if (!ps)
+ return 0;
+ format = ps->formats;
+ nformat = ps->nformats;
+ switch (pVisual->class) {
+ case StaticGray:
+ case GrayScale:
+ case StaticColor:
+ case PseudoColor:
+ type = PictTypeIndexed;
+ break;
+ case TrueColor:
+ case DirectColor:
+ type = PictTypeDirect;
+ break;
+ default:
+ return 0;
+ }
+ while (nformat--)
+ {
+ if (format->depth == depth && format->type == type)
+ {
+ if (type == PictTypeIndexed)
+ {
+ if (format->index.vid == pVisual->vid)
+ return format;
+ }
+ else
+ {
+ if (format->direct.redMask << format->direct.red ==
+ pVisual->redMask &&
+ format->direct.greenMask << format->direct.green ==
+ pVisual->greenMask &&
+ format->direct.blueMask << format->direct.blue ==
+ pVisual->blueMask)
+ {
+ return format;
+ }
+ }
+ }
+ format++;
+ }
+ return 0;
+}
+
+PictFormatPtr
+PictureMatchFormat (ScreenPtr pScreen, int depth, CARD32 f)
+{
+ PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
+ PictFormatPtr format;
+ int nformat;
+
+ if (!ps)
+ return 0;
+ format = ps->formats;
+ nformat = ps->nformats;
+ while (nformat--)
+ {
+ if (format->depth == depth && format->format == (f & 0xffffff))
+ return format;
+ format++;
+ }
+ return 0;
+}
+
+int
+PictureParseCmapPolicy (const char *name)
+{
+ if ( strcmp (name, "default" ) == 0)
+ return PictureCmapPolicyDefault;
+ else if ( strcmp (name, "mono" ) == 0)
+ return PictureCmapPolicyMono;
+ else if ( strcmp (name, "gray" ) == 0)
+ return PictureCmapPolicyGray;
+ else if ( strcmp (name, "color" ) == 0)
+ return PictureCmapPolicyColor;
+ else if ( strcmp (name, "all" ) == 0)
+ return PictureCmapPolicyAll;
+ else
+ return PictureCmapPolicyInvalid;
+}
+
+Bool
+PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
+{
+ PictureScreenPtr ps;
+ int n;
+ CARD32 type, a, r, g, b;
+
+ if (PictureGeneration != serverGeneration)
+ {
+ PictureType = CreateNewResourceType (FreePicture);
+ if (!PictureType)
+ return FALSE;
+ PictFormatType = CreateNewResourceType (FreePictFormat);
+ if (!PictFormatType)
+ return FALSE;
+ GlyphSetType = CreateNewResourceType (FreeGlyphSet);
+ if (!GlyphSetType)
+ return FALSE;
+ PictureScreenPrivateIndex = AllocateScreenPrivateIndex();
+ if (PictureScreenPrivateIndex < 0)
+ return FALSE;
+ PictureWindowPrivateIndex = AllocateWindowPrivateIndex();
+ PictureGeneration = serverGeneration;
+#ifdef XResExtension
+ RegisterResourceName (PictureType, "PICTURE");
+ RegisterResourceName (PictFormatType, "PICTFORMAT");
+ RegisterResourceName (GlyphSetType, "GLYPHSET");
+#endif
+ }
+ if (!AllocateWindowPrivate (pScreen, PictureWindowPrivateIndex, 0))
+ return FALSE;
+
+ if (!formats)
+ {
+ formats = PictureCreateDefaultFormats (pScreen, &nformats);
+ if (!formats)
+ return FALSE;
+ }
+ for (n = 0; n < nformats; n++)
+ {
+ if (!AddResource (formats[n].id, PictFormatType, (pointer) (formats+n)))
+ {
+ xfree (formats);
+ return FALSE;
+ }
+ if (formats[n].type == PictTypeIndexed)
+ {
+ VisualPtr pVisual = PictureFindVisual (pScreen, formats[n].index.vid);
+ if ((pVisual->class | DynamicClass) == PseudoColor)
+ type = PICT_TYPE_COLOR;
+ else
+ type = PICT_TYPE_GRAY;
+ a = r = g = b = 0;
+ }
+ else
+ {
+ if ((formats[n].direct.redMask|
+ formats[n].direct.blueMask|
+ formats[n].direct.greenMask) == 0)
+ type = PICT_TYPE_A;
+ else if (formats[n].direct.red > formats[n].direct.blue)
+ type = PICT_TYPE_ARGB;
+ else
+ type = PICT_TYPE_ABGR;
+ a = Ones (formats[n].direct.alphaMask);
+ r = Ones (formats[n].direct.redMask);
+ g = Ones (formats[n].direct.greenMask);
+ b = Ones (formats[n].direct.blueMask);
+ }
+ formats[n].format = PICT_FORMAT(0,type,a,r,g,b);
+ }
+ ps = (PictureScreenPtr) xalloc (sizeof (PictureScreenRec));
+ if (!ps)
+ {
+ xfree (formats);
+ return FALSE;
+ }
+ SetPictureScreen(pScreen, ps);
+ if (!GlyphInit (pScreen))
+ {
+ SetPictureScreen(pScreen, 0);
+ xfree (formats);
+ xfree (ps);
+ return FALSE;
+ }
+
+ ps->totalPictureSize = sizeof (PictureRec);
+ ps->PicturePrivateSizes = 0;
+ ps->PicturePrivateLen = 0;
+
+ ps->formats = formats;
+ ps->fallback = formats;
+ ps->nformats = nformats;
+
+ ps->filters = 0;
+ ps->nfilters = 0;
+ ps->filterAliases = 0;
+ ps->nfilterAliases = 0;
+
+ ps->subpixel = SubPixelUnknown;
+
+ ps->CloseScreen = pScreen->CloseScreen;
+ ps->DestroyWindow = pScreen->DestroyWindow;
+ ps->StoreColors = pScreen->StoreColors;
+ pScreen->DestroyWindow = PictureDestroyWindow;
+ pScreen->CloseScreen = PictureCloseScreen;
+ pScreen->StoreColors = PictureStoreColors;
+
+ if (!PictureSetDefaultFilters (pScreen))
+ {
+ PictureResetFilters (pScreen);
+ SetPictureScreen(pScreen, 0);
+ xfree (formats);
+ xfree (ps);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+void
+SetPictureToDefaults (PicturePtr pPicture)
+{
+ pPicture->refcnt = 1;
+ pPicture->repeat = 0;
+ pPicture->graphicsExposures = FALSE;
+ pPicture->subWindowMode = ClipByChildren;
+ pPicture->polyEdge = PolyEdgeSharp;
+ pPicture->polyMode = PolyModePrecise;
+ pPicture->freeCompClip = FALSE;
+ pPicture->clientClipType = CT_NONE;
+ pPicture->componentAlpha = FALSE;
+ pPicture->repeatType = RepeatNone;
+
+ pPicture->alphaMap = 0;
+ pPicture->alphaOrigin.x = 0;
+ pPicture->alphaOrigin.y = 0;
+
+ pPicture->clipOrigin.x = 0;
+ pPicture->clipOrigin.y = 0;
+ pPicture->clientClip = 0;
+
+ pPicture->transform = 0;
+
+ pPicture->dither = None;
+ pPicture->filter = PictureGetFilterId (FilterNearest, -1, TRUE);
+ pPicture->filter_params = 0;
+ pPicture->filter_nparams = 0;
+
+ pPicture->serialNumber = GC_CHANGE_SERIAL_BIT;
+ pPicture->stateChanges = (1 << (CPLastBit+1)) - 1;
+ pPicture->pSourcePict = 0;
+}
+
+PicturePtr
+AllocatePicture (ScreenPtr pScreen)
+{
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ PicturePtr pPicture;
+ char *ptr;
+ DevUnion *ppriv;
+ unsigned int *sizes;
+ unsigned int size;
+ int i;
+
+ pPicture = (PicturePtr) xalloc (ps->totalPictureSize);
+ if (!pPicture)
+ return 0;
+ ppriv = (DevUnion *)(pPicture + 1);
+ pPicture->devPrivates = ppriv;
+ sizes = ps->PicturePrivateSizes;
+ ptr = (char *)(ppriv + ps->PicturePrivateLen);
+ for (i = ps->PicturePrivateLen; --i >= 0; ppriv++, sizes++)
+ {
+ if ( (size = *sizes) )
+ {
+ ppriv->ptr = (pointer)ptr;
+ ptr += size;
+ }
+ else
+ ppriv->ptr = (pointer)NULL;
+ }
+ return pPicture;
+}
+
+PicturePtr
+CreatePicture (Picture pid,
+ DrawablePtr pDrawable,
+ PictFormatPtr pFormat,
+ Mask vmask,
+ XID *vlist,
+ ClientPtr client,
+ int *error)
+{
+ PicturePtr pPicture;
+ PictureScreenPtr ps = GetPictureScreen(pDrawable->pScreen);
+
+ pPicture = AllocatePicture (pDrawable->pScreen);
+ if (!pPicture)
+ {
+ *error = BadAlloc;
+ return 0;
+ }
+
+ pPicture->id = pid;
+ pPicture->pDrawable = pDrawable;
+ pPicture->pFormat = pFormat;
+ pPicture->format = pFormat->format | (pDrawable->bitsPerPixel << 24);
+ if (pDrawable->type == DRAWABLE_PIXMAP)
+ {
+ ++((PixmapPtr)pDrawable)->refcnt;
+ pPicture->pNext = 0;
+ }
+ else
+ {
+ pPicture->pNext = GetPictureWindow(((WindowPtr) pDrawable));
+ SetPictureWindow(((WindowPtr) pDrawable), pPicture);
+ }
+
+ SetPictureToDefaults (pPicture);
+
+ if (vmask)
+ *error = ChangePicture (pPicture, vmask, vlist, 0, client);
+ else
+ *error = Success;
+ if (*error == Success)
+ *error = (*ps->CreatePicture) (pPicture);
+ if (*error != Success)
+ {
+ FreePicture (pPicture, (XID) 0);
+ pPicture = 0;
+ }
+ return pPicture;
+}
+
+static CARD32 xRenderColorToCard32(xRenderColor c)
+{
+ return
+ (c.alpha >> 8 << 24) |
+ (c.red >> 8 << 16) |
+ (c.green & 0xff00) |
+ (c.blue >> 8);
+}
+
+static unsigned int premultiply(unsigned int x)
+{
+ unsigned int a = x >> 24;
+ unsigned int t = (x & 0xff00ff) * a;
+ t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
+ t &= 0xff00ff;
+
+ x = ((x >> 8) & 0xff) * a;
+ x = (x + ((x >> 8) & 0xff) + 0x80);
+ x &= 0xff00;
+ x |= t | (a << 24);
+ return x;
+}
+
+static unsigned int INTERPOLATE_PIXEL_256(unsigned int x, unsigned int a,
+ unsigned int y, unsigned int b)
+{
+ CARD32 t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
+ t >>= 8;
+ t &= 0xff00ff;
+
+ x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;
+ x &= 0xff00ff00;
+ x |= t;
+ return x;
+}
+
+static void initGradientColorTable(SourcePictPtr pGradient, int *error)
+{
+ int begin_pos, end_pos;
+ xFixed incr, dpos;
+ int pos, current_stop;
+ PictGradientStopPtr stops = pGradient->linear.stops;
+ int nstops = pGradient->linear.nstops;
+
+ /* The position where the gradient begins and ends */
+ begin_pos = (stops[0].x * PICT_GRADIENT_STOPTABLE_SIZE) >> 16;
+ end_pos = (stops[nstops - 1].x * PICT_GRADIENT_STOPTABLE_SIZE) >> 16;
+
+ pos = 0; /* The position in the color table. */
+
+ /* Up to first point */
+ while (pos <= begin_pos) {
+ pGradient->linear.colorTable[pos] = xRenderColorToCard32(stops[0].color);
+ ++pos;
+ }
+
+ incr = (1<<16)/ PICT_GRADIENT_STOPTABLE_SIZE; /* the double increment. */
+ dpos = incr * pos; /* The position in terms of 0-1. */
+
+ current_stop = 0; /* We always interpolate between current and current + 1. */
+
+ /* Gradient area */
+ while (pos < end_pos) {
+ unsigned int current_color = xRenderColorToCard32(stops[current_stop].color);
+ unsigned int next_color = xRenderColorToCard32(stops[current_stop + 1].color);
+
+ int dist = (int)(256*(dpos - stops[current_stop].x)
+ / (stops[current_stop+1].x - stops[current_stop].x));
+ int idist = 256 - dist;
+
+ pGradient->linear.colorTable[pos] = premultiply(INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist));
+
+ ++pos;
+ dpos += incr;
+
+ if (dpos > stops[current_stop + 1].x)
+ ++current_stop;
+ }
+
+ /* After last point */
+ while (pos < PICT_GRADIENT_STOPTABLE_SIZE) {
+ pGradient->linear.colorTable[pos] = xRenderColorToCard32(stops[nstops - 1].color);
+ ++pos;
+ }
+}
+
+static void initGradient(SourcePictPtr pGradient, int stopCount,
+ xFixed *stopPoints, xRenderColor *stopColors, int *error)
+{
+ int i;
+ xFixed dpos;
+
+ if (stopCount <= 0) {
+ *error = BadValue;
+ return;
+ }
+
+ dpos = -1;
+ for (i = 0; i < stopCount; ++i) {
+ if (stopPoints[i] <= dpos || stopPoints[i] > (1<<16)) {
+ *error = BadValue;
+ return;
+ }
+ dpos = stopPoints[i];
+ }
+
+ pGradient->linear.stops = xalloc(stopCount*sizeof(PictGradientStop));
+ if (!pGradient->linear.stops) {
+ *error = BadAlloc;
+ return;
+ }
+
+ pGradient->linear.nstops = stopCount;
+
+ for (i = 0; i < stopCount; ++i) {
+ pGradient->linear.stops[i].x = stopPoints[i];
+ pGradient->linear.stops[i].color = stopColors[i];
+ }
+ initGradientColorTable(pGradient, error);
+}
+
+static PicturePtr createSourcePicture(void)
+{
+ PicturePtr pPicture;
+ pPicture = (PicturePtr) xalloc(sizeof(PictureRec));
+ pPicture->pDrawable = 0;
+ pPicture->pFormat = 0;
+ pPicture->pNext = 0;
+
+ SetPictureToDefaults(pPicture);
+ return pPicture;
+}
+
+PicturePtr
+CreateSolidPicture (Picture pid, xRenderColor *color, int *error)
+{
+ PicturePtr pPicture;
+ pPicture = createSourcePicture();
+ if (!pPicture) {
+ *error = BadAlloc;
+ return 0;
+ }
+
+ pPicture->id = pid;
+ pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictSolidFill));
+ if (!pPicture->pSourcePict) {
+ *error = BadAlloc;
+ xfree(pPicture);
+ return 0;
+ }
+ pPicture->pSourcePict->type = SourcePictTypeSolidFill;
+ pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color);
+ return pPicture;
+}
+
+PicturePtr
+CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2,
+ int nStops, xFixed *stops, xRenderColor *colors, int *error)
+{
+ PicturePtr pPicture;
+
+ if (nStops < 2) {
+ *error = BadValue;
+ return 0;
+ }
+
+ pPicture = createSourcePicture();
+ if (!pPicture) {
+ *error = BadAlloc;
+ return 0;
+ }
+ if (p1->x == p2->x && p1->y == p2->y) {
+ *error = BadValue;
+ return 0;
+ }
+
+ pPicture->id = pid;
+ pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictLinearGradient));
+ if (!pPicture->pSourcePict) {
+ *error = BadAlloc;
+ xfree(pPicture);
+ return 0;
+ }
+
+ pPicture->pSourcePict->linear.type = SourcePictTypeLinear;
+ pPicture->pSourcePict->linear.p1 = *p1;
+ pPicture->pSourcePict->linear.p2 = *p2;
+
+ initGradient(pPicture->pSourcePict, nStops, stops, colors, error);
+ if (*error) {
+ xfree(pPicture);
+ return 0;
+ }
+ return pPicture;
+}
+
+#define FixedToDouble(x) ((x)/65536.)
+
+PicturePtr
+CreateRadialGradientPicture (Picture pid, xPointFixed *inner, xPointFixed *outer,
+ xFixed innerRadius, xFixed outerRadius,
+ int nStops, xFixed *stops, xRenderColor *colors, int *error)
+{
+ PicturePtr pPicture;
+ PictRadialGradient *radial;
+
+ if (nStops < 2) {
+ *error = BadValue;
+ return 0;
+ }
+
+ pPicture = createSourcePicture();
+ if (!pPicture) {
+ *error = BadAlloc;
+ return 0;
+ }
+ {
+ double dx = (double)(inner->x - outer->x);
+ double dy = (double)(inner->y - outer->y);
+ if (sqrt(dx*dx + dy*dy) + (double)(innerRadius) > (double)(outerRadius)) {
+ *error = BadValue;
+ return 0;
+ }
+ }
+
+ pPicture->id = pid;
+ pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictRadialGradient));
+ if (!pPicture->pSourcePict) {
+ *error = BadAlloc;
+ xfree(pPicture);
+ return 0;
+ }
+ radial = &pPicture->pSourcePict->radial;
+
+ radial->type = SourcePictTypeRadial;
+ {
+ double x = (double)innerRadius / (double)outerRadius;
+ radial->dx = (outer->x - inner->x);
+ radial->dy = (outer->y - inner->y);
+ radial->fx = (inner->x) - x*radial->dx;
+ radial->fy = (inner->y) - x*radial->dy;
+ radial->m = 1./(1+x);
+ radial->b = -x*radial->m;
+ radial->dx /= 65536.;
+ radial->dy /= 65536.;
+ radial->fx /= 65536.;
+ radial->fy /= 65536.;
+ x = outerRadius/65536.;
+ radial->a = x*x - radial->dx*radial->dx - radial->dy*radial->dy;
+ }
+
+ initGradient(pPicture->pSourcePict, nStops, stops, colors, error);
+ if (*error) {
+ xfree(pPicture);
+ return 0;
+ }
+ return pPicture;
+}
+
+PicturePtr
+CreateConicalGradientPicture (Picture pid, xPointFixed *center, xFixed angle,
+ int nStops, xFixed *stops, xRenderColor *colors, int *error)
+{
+ PicturePtr pPicture;
+
+ if (nStops < 2) {
+ *error = BadValue;
+ return 0;
+ }
+
+ pPicture = createSourcePicture();
+ if (!pPicture) {
+ *error = BadAlloc;
+ return 0;
+ }
+
+ pPicture->id = pid;
+ pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictConicalGradient));
+ if (!pPicture->pSourcePict) {
+ *error = BadAlloc;
+ xfree(pPicture);
+ return 0;
+ }
+
+ pPicture->pSourcePict->conical.type = SourcePictTypeConical;
+ pPicture->pSourcePict->conical.center = *center;
+ pPicture->pSourcePict->conical.angle = angle;
+
+ initGradient(pPicture->pSourcePict, nStops, stops, colors, error);
+ if (*error) {
+ xfree(pPicture);
+ return 0;
+ }
+ return pPicture;
+}
+
+#define NEXT_VAL(_type) (vlist ? (_type) *vlist++ : (_type) ulist++->val)
+
+#define NEXT_PTR(_type) ((_type) ulist++->ptr)
+
+int
+ChangePicture (PicturePtr pPicture,
+ Mask vmask,
+ XID *vlist,
+ DevUnion *ulist,
+ ClientPtr client)
+{
+ ScreenPtr pScreen = pPicture->pDrawable ? pPicture->pDrawable->pScreen : 0;
+ PictureScreenPtr ps = pScreen ? GetPictureScreen(pScreen) : 0;
+ BITS32 index2;
+ int error = 0;
+ BITS32 maskQ;
+
+ pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
+ maskQ = vmask;
+ while (vmask && !error)
+ {
+ index2 = (BITS32) lowbit (vmask);
+ vmask &= ~index2;
+ pPicture->stateChanges |= index2;
+ switch (index2)
+ {
+ case CPRepeat:
+ {
+ unsigned int newr;
+ newr = NEXT_VAL(unsigned int);
+ if (newr <= RepeatReflect)
+ {
+ pPicture->repeat = (newr != RepeatNone);
+ pPicture->repeatType = newr;
+ }
+ else
+ {
+ client->errorValue = newr;
+ error = BadValue;
+ }
+ }
+ break;
+ case CPAlphaMap:
+ {
+ PicturePtr pAlpha;
+
+ if (vlist)
+ {
+ Picture pid = NEXT_VAL(Picture);
+
+ if (pid == None)
+ pAlpha = 0;
+ else
+ {
+ pAlpha = (PicturePtr) SecurityLookupIDByType(client,
+ pid,
+ PictureType,
+ SecurityWriteAccess|SecurityReadAccess);
+ if (!pAlpha)
+ {
+ client->errorValue = pid;
+ error = BadPixmap;
+ break;
+ }
+ if (pAlpha->pDrawable->type != DRAWABLE_PIXMAP)
+ {
+ client->errorValue = pid;
+ error = BadMatch;
+ break;
+ }
+ }
+ }
+ else
+ pAlpha = NEXT_PTR(PicturePtr);
+ if (!error)
+ {
+ if (pAlpha && pAlpha->pDrawable->type == DRAWABLE_PIXMAP)
+ pAlpha->refcnt++;
+ if (pPicture->alphaMap)
+ FreePicture ((pointer) pPicture->alphaMap, (XID) 0);
+ pPicture->alphaMap = pAlpha;
+ }
+ }
+ break;
+ case CPAlphaXOrigin:
+ pPicture->alphaOrigin.x = NEXT_VAL(INT16);
+ break;
+ case CPAlphaYOrigin:
+ pPicture->alphaOrigin.y = NEXT_VAL(INT16);
+ break;
+ case CPClipXOrigin:
+ pPicture->clipOrigin.x = NEXT_VAL(INT16);
+ break;
+ case CPClipYOrigin:
+ pPicture->clipOrigin.y = NEXT_VAL(INT16);
+ break;
+ case CPClipMask:
+ {
+ Pixmap pid;
+ PixmapPtr pPixmap;
+ int clipType;
+ if (!pScreen)
+ return BadDrawable;
+
+ if (vlist)
+ {
+ pid = NEXT_VAL(Pixmap);
+ if (pid == None)
+ {
+ clipType = CT_NONE;
+ pPixmap = NullPixmap;
+ }
+ else
+ {
+ clipType = CT_PIXMAP;
+ pPixmap = (PixmapPtr)SecurityLookupIDByType(client,
+ pid,
+ RT_PIXMAP,
+ SecurityReadAccess);
+ if (!pPixmap)
+ {
+ client->errorValue = pid;
+ error = BadPixmap;
+ break;
+ }
+ }
+ }
+ else
+ {
+ pPixmap = NEXT_PTR(PixmapPtr);
+ if (pPixmap)
+ clipType = CT_PIXMAP;
+ else
+ clipType = CT_NONE;
+ }
+
+ if (pPixmap)
+ {
+ if ((pPixmap->drawable.depth != 1) ||
+ (pPixmap->drawable.pScreen != pScreen))
+ {
+ error = BadMatch;
+ break;
+ }
+ else
+ {
+ clipType = CT_PIXMAP;
+ pPixmap->refcnt++;
+ }
+ }
+ error = (*ps->ChangePictureClip)(pPicture, clipType,
+ (pointer)pPixmap, 0);
+ break;
+ }
+ case CPGraphicsExposure:
+ {
+ unsigned int newe;
+ newe = NEXT_VAL(unsigned int);
+ if (newe <= xTrue)
+ pPicture->graphicsExposures = newe;
+ else
+ {
+ client->errorValue = newe;
+ error = BadValue;
+ }
+ }
+ break;
+ case CPSubwindowMode:
+ {
+ unsigned int news;
+ news = NEXT_VAL(unsigned int);
+ if (news == ClipByChildren || news == IncludeInferiors)
+ pPicture->subWindowMode = news;
+ else
+ {
+ client->errorValue = news;
+ error = BadValue;
+ }
+ }
+ break;
+ case CPPolyEdge:
+ {
+ unsigned int newe;
+ newe = NEXT_VAL(unsigned int);
+ if (newe == PolyEdgeSharp || newe == PolyEdgeSmooth)
+ pPicture->polyEdge = newe;
+ else
+ {
+ client->errorValue = newe;
+ error = BadValue;
+ }
+ }
+ break;
+ case CPPolyMode:
+ {
+ unsigned int newm;
+ newm = NEXT_VAL(unsigned int);
+ if (newm == PolyModePrecise || newm == PolyModeImprecise)
+ pPicture->polyMode = newm;
+ else
+ {
+ client->errorValue = newm;
+ error = BadValue;
+ }
+ }
+ break;
+ case CPDither:
+ pPicture->dither = NEXT_VAL(Atom);
+ break;
+ case CPComponentAlpha:
+ {
+ unsigned int newca;
+
+ newca = NEXT_VAL (unsigned int);
+ if (newca <= xTrue)
+ pPicture->componentAlpha = newca;
+ else
+ {
+ client->errorValue = newca;
+ error = BadValue;
+ }
+ }
+ break;
+ default:
+ client->errorValue = maskQ;
+ error = BadValue;
+ break;
+ }
+ }
+ if (ps)
+ (*ps->ChangePicture) (pPicture, maskQ);
+ return error;
+}
+
+int
+SetPictureClipRects (PicturePtr pPicture,
+ int xOrigin,
+ int yOrigin,
+ int nRect,
+ xRectangle *rects)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ RegionPtr clientClip;
+ int result;
+
+ clientClip = RECTS_TO_REGION(pScreen,
+ nRect, rects, CT_UNSORTED);
+ if (!clientClip)
+ return BadAlloc;
+ result =(*ps->ChangePictureClip) (pPicture, CT_REGION,
+ (pointer) clientClip, 0);
+ if (result == Success)
+ {
+ pPicture->clipOrigin.x = xOrigin;
+ pPicture->clipOrigin.y = yOrigin;
+ pPicture->stateChanges |= CPClipXOrigin|CPClipYOrigin|CPClipMask;
+ pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
+ }
+ return result;
+}
+
+int
+SetPictureClipRegion (PicturePtr pPicture,
+ int xOrigin,
+ int yOrigin,
+ RegionPtr pRegion)
+{
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+ RegionPtr clientClip;
+ int result;
+ int type;
+
+ if (pRegion)
+ {
+ type = CT_REGION;
+ clientClip = REGION_CREATE (pScreen,
+ REGION_EXTENTS(pScreen, pRegion),
+ REGION_NUM_RECTS(pRegion));
+ if (!clientClip)
+ return BadAlloc;
+ if (!REGION_COPY (pSCreen, clientClip, pRegion))
+ {
+ REGION_DESTROY (pScreen, clientClip);
+ return BadAlloc;
+ }
+ }
+ else
+ {
+ type = CT_NONE;
+ clientClip = 0;
+ }
+
+ result =(*ps->ChangePictureClip) (pPicture, type,
+ (pointer) clientClip, 0);
+ if (result == Success)
+ {
+ pPicture->clipOrigin.x = xOrigin;
+ pPicture->clipOrigin.y = yOrigin;
+ pPicture->stateChanges |= CPClipXOrigin|CPClipYOrigin|CPClipMask;
+ pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
+ }
+ return result;
+}
+
+
+int
+SetPictureTransform (PicturePtr pPicture,
+ PictTransform *transform)
+{
+ static const PictTransform identity = { {
+ { xFixed1, 0x00000, 0x00000 },
+ { 0x00000, xFixed1, 0x00000 },
+ { 0x00000, 0x00000, xFixed1 },
+ } };
+
+ if (transform && memcmp (transform, &identity, sizeof (PictTransform)) == 0)
+ transform = 0;
+
+ if (transform)
+ {
+ if (!pPicture->transform)
+ {
+ pPicture->transform = (PictTransform *) xalloc (sizeof (PictTransform));
+ if (!pPicture->transform)
+ return BadAlloc;
+ }
+ *pPicture->transform = *transform;
+ }
+ else
+ {
+ if (pPicture->transform)
+ {
+ xfree (pPicture->transform);
+ pPicture->transform = 0;
+ }
+ }
+ pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
+
+ return Success;
+}
+
+void
+CopyPicture (PicturePtr pSrc,
+ Mask mask,
+ PicturePtr pDst)
+{
+ PictureScreenPtr ps = GetPictureScreen(pSrc->pDrawable->pScreen);
+ Mask origMask = mask;
+
+ pDst->serialNumber |= GC_CHANGE_SERIAL_BIT;
+ pDst->stateChanges |= mask;
+
+ while (mask) {
+ Mask bit = lowbit(mask);
+
+ switch (bit)
+ {
+ case CPRepeat:
+ pDst->repeat = pSrc->repeat;
+ pDst->repeatType = pSrc->repeatType;
+ break;
+ case CPAlphaMap:
+ if (pSrc->alphaMap && pSrc->alphaMap->pDrawable->type == DRAWABLE_PIXMAP)
+ pSrc->alphaMap->refcnt++;
+ if (pDst->alphaMap)
+ FreePicture ((pointer) pDst->alphaMap, (XID) 0);
+ pDst->alphaMap = pSrc->alphaMap;
+ break;
+ case CPAlphaXOrigin:
+ pDst->alphaOrigin.x = pSrc->alphaOrigin.x;
+ break;
+ case CPAlphaYOrigin:
+ pDst->alphaOrigin.y = pSrc->alphaOrigin.y;
+ break;
+ case CPClipXOrigin:
+ pDst->clipOrigin.x = pSrc->clipOrigin.x;
+ break;
+ case CPClipYOrigin:
+ pDst->clipOrigin.y = pSrc->clipOrigin.y;
+ break;
+ case CPClipMask:
+ switch (pSrc->clientClipType) {
+ case CT_NONE:
+ (*ps->ChangePictureClip)(pDst, CT_NONE, NULL, 0);
+ break;
+ case CT_REGION:
+ if (!pSrc->clientClip) {
+ (*ps->ChangePictureClip)(pDst, CT_NONE, NULL, 0);
+ } else {
+ RegionPtr clientClip;
+ RegionPtr srcClientClip = (RegionPtr)pSrc->clientClip;
+
+ clientClip = REGION_CREATE(pSrc->pDrawable->pScreen,
+ REGION_EXTENTS(pSrc->pDrawable->pScreen, srcClientClip),
+ REGION_NUM_RECTS(srcClientClip));
+ (*ps->ChangePictureClip)(pDst, CT_REGION, clientClip, 0);
+ }
+ break;
+ default:
+ /* XXX: CT_PIXMAP unimplemented */
+ break;
+ }
+ break;
+ case CPGraphicsExposure:
+ pDst->graphicsExposures = pSrc->graphicsExposures;
+ break;
+ case CPPolyEdge:
+ pDst->polyEdge = pSrc->polyEdge;
+ break;
+ case CPPolyMode:
+ pDst->polyMode = pSrc->polyMode;
+ break;
+ case CPDither:
+ pDst->dither = pSrc->dither;
+ break;
+ case CPComponentAlpha:
+ pDst->componentAlpha = pSrc->componentAlpha;
+ break;
+ }
+ mask &= ~bit;
+ }
+
+ (*ps->ChangePicture)(pDst, origMask);
+}
+
+static void
+ValidateOnePicture (PicturePtr pPicture)
+{
+ if (pPicture->pDrawable && pPicture->serialNumber != pPicture->pDrawable->serialNumber)
+ {
+ PictureScreenPtr ps = GetPictureScreen(pPicture->pDrawable->pScreen);
+
+ (*ps->ValidatePicture) (pPicture, pPicture->stateChanges);
+ pPicture->stateChanges = 0;
+ pPicture->serialNumber = pPicture->pDrawable->serialNumber;
+ }
+}
+
+void
+ValidatePicture(PicturePtr pPicture)
+{
+ ValidateOnePicture (pPicture);
+ if (pPicture->alphaMap)
+ ValidateOnePicture (pPicture->alphaMap);
+}
+
+int
+FreePicture (pointer value,
+ XID pid)
+{
+ PicturePtr pPicture = (PicturePtr) value;
+
+ if (--pPicture->refcnt == 0)
+ {
+ if (pPicture->transform)
+ xfree (pPicture->transform);
+ if (!pPicture->pDrawable) {
+ if (pPicture->pSourcePict) {
+ if (pPicture->pSourcePict->type != SourcePictTypeSolidFill)
+ xfree(pPicture->pSourcePict->linear.stops);
+ xfree(pPicture->pSourcePict);
+ }
+ } else {
+ ScreenPtr pScreen = pPicture->pDrawable->pScreen;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+
+ if (pPicture->alphaMap)
+ FreePicture ((pointer) pPicture->alphaMap, (XID) 0);
+ (*ps->DestroyPicture) (pPicture);
+ (*ps->DestroyPictureClip) (pPicture);
+ if (pPicture->pDrawable->type == DRAWABLE_WINDOW)
+ {
+ WindowPtr pWindow = (WindowPtr) pPicture->pDrawable;
+ PicturePtr *pPrev;
+
+ for (pPrev = (PicturePtr *) &((pWindow)->devPrivates[PictureWindowPrivateIndex].ptr);
+ *pPrev;
+ pPrev = &(*pPrev)->pNext)
+ {
+ if (*pPrev == pPicture)
+ {
+ *pPrev = pPicture->pNext;
+ break;
+ }
+ }
+ }
+ else if (pPicture->pDrawable->type == DRAWABLE_PIXMAP)
+ {
+ (*pScreen->DestroyPixmap) ((PixmapPtr)pPicture->pDrawable);
+ }
+ }
+ xfree (pPicture);
+ }
+ return Success;
+}
+
+int
+FreePictFormat (pointer pPictFormat,
+ XID pid)
+{
+ return Success;
+}
+
+void
+CompositePicture (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
+
+ ValidatePicture (pSrc);
+ if (pMask)
+ ValidatePicture (pMask);
+ ValidatePicture (pDst);
+ (*ps->Composite) (op,
+ pSrc,
+ pMask,
+ pDst,
+ xSrc,
+ ySrc,
+ xMask,
+ yMask,
+ xDst,
+ yDst,
+ width,
+ height);
+}
+
+void
+CompositeGlyphs (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlist,
+ GlyphListPtr lists,
+ GlyphPtr *glyphs)
+{
+ PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
+
+ ValidatePicture (pSrc);
+ ValidatePicture (pDst);
+ (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, lists, glyphs);
+}
+
+void
+CompositeRects (CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects)
+{
+ PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
+
+ ValidatePicture (pDst);
+ (*ps->CompositeRects) (op, pDst, color, nRect, rects);
+}
+
+void
+CompositeTrapezoids (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntrap,
+ xTrapezoid *traps)
+{
+ PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
+
+ ValidatePicture (pSrc);
+ ValidatePicture (pDst);
+ (*ps->Trapezoids) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntrap, traps);
+}
+
+void
+CompositeTriangles (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntriangles,
+ xTriangle *triangles)
+{
+ PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
+
+ ValidatePicture (pSrc);
+ ValidatePicture (pDst);
+ (*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntriangles, triangles);
+}
+
+void
+CompositeTriStrip (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoints,
+ xPointFixed *points)
+{
+ PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
+
+ ValidatePicture (pSrc);
+ ValidatePicture (pDst);
+ (*ps->TriStrip) (op, pSrc, pDst, maskFormat, xSrc, ySrc, npoints, points);
+}
+
+void
+CompositeTriFan (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoints,
+ xPointFixed *points)
+{
+ PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen);
+
+ ValidatePicture (pSrc);
+ ValidatePicture (pDst);
+ (*ps->TriFan) (op, pSrc, pDst, maskFormat, xSrc, ySrc, npoints, points);
+}
+
+void
+AddTraps (PicturePtr pPicture,
+ INT16 xOff,
+ INT16 yOff,
+ int ntrap,
+ xTrap *traps)
+{
+ PictureScreenPtr ps = GetPictureScreen(pPicture->pDrawable->pScreen);
+
+ ValidatePicture (pPicture);
+ (*ps->AddTraps) (pPicture, xOff, yOff, ntrap, traps);
+}
+
+#define MAX_FIXED_48_16 ((xFixed_48_16) 0x7fffffff)
+#define MIN_FIXED_48_16 (-((xFixed_48_16) 1 << 31))
+
+Bool
+PictureTransformPoint3d (PictTransformPtr transform,
+ PictVectorPtr vector)
+{
+ PictVector result;
+ int i, j;
+ xFixed_32_32 partial;
+ xFixed_48_16 v;
+
+ for (j = 0; j < 3; j++)
+ {
+ v = 0;
+ for (i = 0; i < 3; i++)
+ {
+ partial = ((xFixed_48_16) transform->matrix[j][i] *
+ (xFixed_48_16) vector->vector[i]);
+ v += partial >> 16;
+ }
+ if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16)
+ return FALSE;
+ result.vector[j] = (xFixed) v;
+ }
+ if (!result.vector[2])
+ return FALSE;
+ *vector = result;
+ return TRUE;
+}
+
+
+Bool
+PictureTransformPoint (PictTransformPtr transform,
+ PictVectorPtr vector)
+{
+ PictVector result;
+ int i, j;
+ xFixed_32_32 partial;
+ xFixed_48_16 v;
+
+ for (j = 0; j < 3; j++)
+ {
+ v = 0;
+ for (i = 0; i < 3; i++)
+ {
+ partial = ((xFixed_48_16) transform->matrix[j][i] *
+ (xFixed_48_16) vector->vector[i]);
+ v += partial >> 16;
+ }
+ if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16)
+ return FALSE;
+ result.vector[j] = (xFixed) v;
+ }
+ if (!result.vector[2])
+ return FALSE;
+ for (j = 0; j < 2; j++)
+ {
+ partial = (xFixed_48_16) result.vector[j] << 16;
+ v = partial / result.vector[2];
+ if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16)
+ return FALSE;
+ vector->vector[j] = (xFixed) v;
+ }
+ vector->vector[2] = xFixed1;
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/render/picture.h b/nx-X11/programs/Xserver/render/picture.h
new file mode 100644
index 000000000..b09d9aac2
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/picture.h
@@ -0,0 +1,238 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/picture.h,v 1.20tsi Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _PICTURE_H_
+#define _PICTURE_H_
+
+typedef struct _DirectFormat *DirectFormatPtr;
+typedef struct _PictFormat *PictFormatPtr;
+typedef struct _Picture *PicturePtr;
+
+/*
+ * While the protocol is generous in format support, the
+ * sample implementation allows only packed RGB and GBR
+ * representations for data to simplify software rendering,
+ */
+#define PICT_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) | \
+ ((type) << 16) | \
+ ((a) << 12) | \
+ ((r) << 8) | \
+ ((g) << 4) | \
+ ((b)))
+
+/*
+ * gray/color formats use a visual index instead of argb
+ */
+#define PICT_VISFORMAT(bpp,type,vi) (((bpp) << 24) | \
+ ((type) << 16) | \
+ ((vi)))
+
+#define PICT_FORMAT_BPP(f) (((f) >> 24) )
+#define PICT_FORMAT_TYPE(f) (((f) >> 16) & 0xff)
+#define PICT_FORMAT_A(f) (((f) >> 12) & 0x0f)
+#define PICT_FORMAT_R(f) (((f) >> 8) & 0x0f)
+#define PICT_FORMAT_G(f) (((f) >> 4) & 0x0f)
+#define PICT_FORMAT_B(f) (((f) ) & 0x0f)
+#define PICT_FORMAT_RGB(f) (((f) ) & 0xfff)
+#define PICT_FORMAT_VIS(f) (((f) ) & 0xffff)
+
+#define PICT_TYPE_OTHER 0
+#define PICT_TYPE_A 1
+#define PICT_TYPE_ARGB 2
+#define PICT_TYPE_ABGR 3
+#define PICT_TYPE_COLOR 4
+#define PICT_TYPE_GRAY 5
+
+#define PICT_FORMAT_COLOR(f) (PICT_FORMAT_TYPE(f) & 2)
+
+/* 32bpp formats */
+#define PICT_a8r8g8b8 PICT_FORMAT(32,PICT_TYPE_ARGB,8,8,8,8)
+#define PICT_x8r8g8b8 PICT_FORMAT(32,PICT_TYPE_ARGB,0,8,8,8)
+#define PICT_a8b8g8r8 PICT_FORMAT(32,PICT_TYPE_ABGR,8,8,8,8)
+#define PICT_x8b8g8r8 PICT_FORMAT(32,PICT_TYPE_ABGR,0,8,8,8)
+
+/* 24bpp formats */
+#define PICT_r8g8b8 PICT_FORMAT(24,PICT_TYPE_ARGB,0,8,8,8)
+#define PICT_b8g8r8 PICT_FORMAT(24,PICT_TYPE_ABGR,0,8,8,8)
+
+/* 16bpp formats */
+#define PICT_r5g6b5 PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,6,5)
+#define PICT_b5g6r5 PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,6,5)
+
+#define PICT_a1r5g5b5 PICT_FORMAT(16,PICT_TYPE_ARGB,1,5,5,5)
+#define PICT_x1r5g5b5 PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,5,5)
+#define PICT_a1b5g5r5 PICT_FORMAT(16,PICT_TYPE_ABGR,1,5,5,5)
+#define PICT_x1b5g5r5 PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,5,5)
+#define PICT_a4r4g4b4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4)
+#define PICT_x4r4g4b4 PICT_FORMAT(16,PICT_TYPE_ARGB,0,4,4,4)
+#define PICT_a4b4g4r4 PICT_FORMAT(16,PICT_TYPE_ABGR,4,4,4,4)
+#define PICT_x4b4g4r4 PICT_FORMAT(16,PICT_TYPE_ABGR,0,4,4,4)
+
+/* 8bpp formats */
+#define PICT_a8 PICT_FORMAT(8,PICT_TYPE_A,8,0,0,0)
+#define PICT_r3g3b2 PICT_FORMAT(8,PICT_TYPE_ARGB,0,3,3,2)
+#define PICT_b2g3r3 PICT_FORMAT(8,PICT_TYPE_ABGR,0,3,3,2)
+#define PICT_a2r2g2b2 PICT_FORMAT(8,PICT_TYPE_ARGB,2,2,2,2)
+#define PICT_a2b2g2r2 PICT_FORMAT(8,PICT_TYPE_ABGR,2,2,2,2)
+
+#define PICT_c8 PICT_FORMAT(8,PICT_TYPE_COLOR,0,0,0,0)
+#define PICT_g8 PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0)
+
+/* 4bpp formats */
+#define PICT_a4 PICT_FORMAT(4,PICT_TYPE_A,4,0,0,0)
+#define PICT_r1g2b1 PICT_FORMAT(4,PICT_TYPE_ARGB,0,1,2,1)
+#define PICT_b1g2r1 PICT_FORMAT(4,PICT_TYPE_ABGR,0,1,2,1)
+#define PICT_a1r1g1b1 PICT_FORMAT(4,PICT_TYPE_ARGB,1,1,1,1)
+#define PICT_a1b1g1r1 PICT_FORMAT(4,PICT_TYPE_ABGR,1,1,1,1)
+
+#define PICT_c4 PICT_FORMAT(4,PICT_TYPE_COLOR,0,0,0,0)
+#define PICT_g4 PICT_FORMAT(4,PICT_TYPE_GRAY,0,0,0,0)
+
+/* 1bpp formats */
+#define PICT_a1 PICT_FORMAT(1,PICT_TYPE_A,1,0,0,0)
+
+#define PICT_g1 PICT_FORMAT(1,PICT_TYPE_GRAY,0,0,0,0)
+
+/*
+ * For dynamic indexed visuals (GrayScale and PseudoColor), these control the
+ * selection of colors allocated for drawing to Pictures. The default
+ * policy depends on the size of the colormap:
+ *
+ * Size Default Policy
+ * ----------------------------
+ * < 64 PolicyMono
+ * < 256 PolicyGray
+ * 256 PolicyColor (only on PseudoColor)
+ *
+ * The actual allocation code lives in miindex.c, and so is
+ * austensibly server dependent, but that code does:
+ *
+ * PolicyMono Allocate no additional colors, use black and white
+ * PolicyGray Allocate 13 gray levels (11 cells used)
+ * PolicyColor Allocate a 4x4x4 cube and 13 gray levels (71 cells used)
+ * PolicyAll Allocate as big a cube as possible, fill with gray (all)
+ *
+ * Here's a picture to help understand how many colors are
+ * actually allocated (this is just the gray ramp):
+ *
+ * gray level
+ * all 0000 1555 2aaa 4000 5555 6aaa 8000 9555 aaaa bfff d555 eaaa ffff
+ * b/w 0000 ffff
+ * 4x4x4 5555 aaaa
+ * extra 1555 2aaa 4000 6aaa 8000 9555 bfff d555 eaaa
+ *
+ * The default colormap supplies two gray levels (black/white), the
+ * 4x4x4 cube allocates another two and nine more are allocated to fill
+ * in the 13 levels. When the 4x4x4 cube is not allocated, a total of
+ * 11 cells are allocated.
+ */
+
+#define PictureCmapPolicyInvalid -1
+#define PictureCmapPolicyDefault 0
+#define PictureCmapPolicyMono 1
+#define PictureCmapPolicyGray 2
+#define PictureCmapPolicyColor 3
+#define PictureCmapPolicyAll 4
+
+extern int PictureCmapPolicy;
+
+int PictureParseCmapPolicy (const char *name);
+
+extern int RenderErrBase;
+extern int RenderClientPrivateIndex;
+
+/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
+
+#if defined(WIN32) && !defined(__GNUC__)
+typedef __int64 xFixed_32_32;
+#else
+# if defined (_LP64) || \
+ defined(__alpha__) || defined(__alpha) || \
+ defined(ia64) || defined(__ia64__) || \
+ defined(__sparc64__) || \
+ defined(__s390x__) || \
+ defined(amd64) || defined (__amd64__) || \
+ (defined(sgi) && (_MIPS_SZLONG == 64))
+typedef long xFixed_32_32;
+# else
+# if defined(__GNUC__) && \
+ ((__GNUC__ > 2) || \
+ ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 7)))
+__extension__
+# endif
+typedef long long int xFixed_32_32;
+# endif
+#endif
+
+typedef xFixed_32_32 xFixed_48_16;
+
+#define MAX_FIXED_48_16 ((xFixed_48_16) 0x7fffffff)
+#define MIN_FIXED_48_16 (-((xFixed_48_16) 1 << 31))
+
+typedef CARD32 xFixed_1_31;
+typedef CARD32 xFixed_1_16;
+typedef INT32 xFixed_16_16;
+
+/*
+ * An unadorned "xFixed" is the same as xFixed_16_16,
+ * (since it's quite common in the code)
+ */
+typedef xFixed_16_16 xFixed;
+#define XFIXED_BITS 16
+
+#define xFixedToInt(f) (int) ((f) >> XFIXED_BITS)
+#define IntToxFixed(i) ((xFixed) (i) << XFIXED_BITS)
+#define xFixedE ((xFixed) 1)
+#define xFixed1 (IntToxFixed(1))
+#define xFixed1MinusE (xFixed1 - xFixedE)
+#define xFixedFrac(f) ((f) & xFixed1MinusE)
+#define xFixedFloor(f) ((f) & ~xFixed1MinusE)
+#define xFixedCeil(f) xFixedFloor((f) + xFixed1MinusE)
+
+#define xFixedFraction(f) ((f) & xFixed1MinusE)
+#define xFixedMod2(f) ((f) & (xFixed1 | xFixed1MinusE))
+
+/* whether 't' is a well defined not obviously empty trapezoid */
+#define xTrapezoidValid(t) ((t)->left.p1.y != (t)->left.p2.y && \
+ (t)->right.p1.y != (t)->right.p2.y && \
+ (int) ((t)->bottom - (t)->top) > 0)
+
+/*
+ * Standard NTSC luminance conversions:
+ *
+ * y = r * 0.299 + g * 0.587 + b * 0.114
+ *
+ * Approximate this for a bit more speed:
+ *
+ * y = (r * 153 + g * 301 + b * 58) / 512
+ *
+ * This gives 17 bits of luminance; to get 15 bits, lop the low two
+ */
+
+#define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \
+ (((s) >> 8) & 0xff) * 301 + \
+ (((s) ) & 0xff) * 58) >> 2)
+
+#endif /* _PICTURE_H_ */
diff --git a/nx-X11/programs/Xserver/render/picturestr.h b/nx-X11/programs/Xserver/render/picturestr.h
new file mode 100644
index 000000000..4775793ab
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/picturestr.h
@@ -0,0 +1,654 @@
+/*
+ * $Id: picturestr.h,v 1.15 2005/12/09 18:35:21 ajax Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _PICTURESTR_H_
+#define _PICTURESTR_H_
+
+#include "glyphstr.h"
+#include "scrnintstr.h"
+#include "resource.h"
+
+typedef struct _DirectFormat {
+ CARD16 red, redMask;
+ CARD16 green, greenMask;
+ CARD16 blue, blueMask;
+ CARD16 alpha, alphaMask;
+} DirectFormatRec;
+
+typedef struct _IndexFormat {
+ VisualID vid;
+ ColormapPtr pColormap;
+ int nvalues;
+ xIndexValue *pValues;
+ void *devPrivate;
+} IndexFormatRec;
+
+typedef struct _PictFormat {
+ CARD32 id;
+ CARD32 format; /* except bpp */
+ unsigned char type;
+ unsigned char depth;
+ DirectFormatRec direct;
+ IndexFormatRec index;
+} PictFormatRec;
+
+typedef struct _PictVector {
+ xFixed vector[3];
+} PictVector, *PictVectorPtr;
+
+typedef struct _PictTransform {
+ xFixed matrix[3][3];
+} PictTransform, *PictTransformPtr;
+
+#define PICT_GRADIENT_STOPTABLE_SIZE 1024
+#define SourcePictTypeSolidFill 0
+#define SourcePictTypeLinear 1
+#define SourcePictTypeRadial 2
+#define SourcePictTypeConical 3
+
+typedef struct _PictSolidFill {
+ unsigned int type;
+ CARD32 color;
+} PictSolidFill, *PictSolidFillPtr;
+
+typedef struct _PictGradientStop {
+ xFixed x;
+ xRenderColor color;
+} PictGradientStop, *PictGradientStopPtr;
+
+typedef struct _PictGradient {
+ unsigned int type;
+ int nstops;
+ PictGradientStopPtr stops;
+ CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
+} PictGradient, *PictGradientPtr;
+
+typedef struct _PictLinearGradient {
+ unsigned int type;
+ int nstops;
+ PictGradientStopPtr stops;
+ CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
+ xPointFixed p1;
+ xPointFixed p2;
+} PictLinearGradient, *PictLinearGradientPtr;
+
+typedef struct _PictRadialGradient {
+ unsigned int type;
+ int nstops;
+ PictGradientStopPtr stops;
+ CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
+ double fx;
+ double fy;
+ double dx;
+ double dy;
+ double a;
+ double m;
+ double b;
+} PictRadialGradient, *PictRadialGradientPtr;
+
+typedef struct _PictConicalGradient {
+ unsigned int type;
+ int nstops;
+ PictGradientStopPtr stops;
+ CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE];
+ xPointFixed center;
+ xFixed angle;
+} PictConicalGradient, *PictConicalGradientPtr;
+
+typedef union _SourcePict {
+ unsigned int type;
+ PictSolidFill solidFill;
+ PictGradient gradient;
+ PictLinearGradient linear;
+ PictRadialGradient radial;
+ PictConicalGradient conical;
+} SourcePict, *SourcePictPtr;
+
+typedef struct _Picture {
+ DrawablePtr pDrawable;
+ PictFormatPtr pFormat;
+ CARD32 format; /* PICT_FORMAT */
+ int refcnt;
+ CARD32 id;
+ PicturePtr pNext; /* chain on same drawable */
+
+ unsigned int repeat : 1;
+ unsigned int graphicsExposures : 1;
+ unsigned int subWindowMode : 1;
+ unsigned int polyEdge : 1;
+ unsigned int polyMode : 1;
+ unsigned int freeCompClip : 1;
+ unsigned int clientClipType : 2;
+ unsigned int componentAlpha : 1;
+ unsigned int repeatType : 2;
+ unsigned int unused : 21;
+
+ PicturePtr alphaMap;
+ DDXPointRec alphaOrigin;
+
+ DDXPointRec clipOrigin;
+ pointer clientClip;
+
+ Atom dither;
+
+ unsigned long stateChanges;
+ unsigned long serialNumber;
+
+ RegionPtr pCompositeClip;
+
+ DevUnion *devPrivates;
+
+ PictTransform *transform;
+
+ int filter;
+ xFixed *filter_params;
+ int filter_nparams;
+ SourcePictPtr pSourcePict;
+} PictureRec;
+
+typedef Bool (*PictFilterValidateParamsProcPtr) (PicturePtr pPicture, int id,
+ xFixed *params, int nparams);
+typedef struct {
+ char *name;
+ int id;
+ PictFilterValidateParamsProcPtr ValidateParams;
+} PictFilterRec, *PictFilterPtr;
+
+#define PictFilterNearest 0
+#define PictFilterBilinear 1
+
+#define PictFilterFast 2
+#define PictFilterGood 3
+#define PictFilterBest 4
+
+#define PictFilterConvolution 5
+
+typedef struct {
+ char *alias;
+ int alias_id;
+ int filter_id;
+} PictFilterAliasRec, *PictFilterAliasPtr;
+
+typedef int (*CreatePictureProcPtr) (PicturePtr pPicture);
+typedef void (*DestroyPictureProcPtr) (PicturePtr pPicture);
+typedef int (*ChangePictureClipProcPtr) (PicturePtr pPicture,
+ int clipType,
+ pointer value,
+ int n);
+typedef void (*DestroyPictureClipProcPtr)(PicturePtr pPicture);
+
+typedef int (*ChangePictureTransformProcPtr) (PicturePtr pPicture,
+ PictTransform *transform);
+
+typedef int (*ChangePictureFilterProcPtr) (PicturePtr pPicture,
+ int filter,
+ xFixed *params,
+ int nparams);
+
+typedef void (*DestroyPictureFilterProcPtr) (PicturePtr pPicture);
+
+typedef void (*ChangePictureProcPtr) (PicturePtr pPicture,
+ Mask mask);
+typedef void (*ValidatePictureProcPtr) (PicturePtr pPicture,
+ Mask mask);
+typedef void (*CompositeProcPtr) (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+typedef void (*GlyphsProcPtr) (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlists,
+ GlyphListPtr lists,
+ GlyphPtr *glyphs);
+
+typedef void (*CompositeRectsProcPtr) (CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects);
+
+typedef void (*RasterizeTrapezoidProcPtr)(PicturePtr pMask,
+ xTrapezoid *trap,
+ int x_off,
+ int y_off);
+
+typedef void (*TrapezoidsProcPtr) (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntrap,
+ xTrapezoid *traps);
+
+typedef void (*TrianglesProcPtr) (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntri,
+ xTriangle *tris);
+
+typedef void (*TriStripProcPtr) (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoint,
+ xPointFixed *points);
+
+typedef void (*TriFanProcPtr) (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoint,
+ xPointFixed *points);
+
+typedef Bool (*InitIndexedProcPtr) (ScreenPtr pScreen,
+ PictFormatPtr pFormat);
+
+typedef void (*CloseIndexedProcPtr) (ScreenPtr pScreen,
+ PictFormatPtr pFormat);
+
+typedef void (*UpdateIndexedProcPtr) (ScreenPtr pScreen,
+ PictFormatPtr pFormat,
+ int ndef,
+ xColorItem *pdef);
+
+typedef void (*AddTrapsProcPtr) (PicturePtr pPicture,
+ INT16 xOff,
+ INT16 yOff,
+ int ntrap,
+ xTrap *traps);
+
+typedef void (*AddTrianglesProcPtr) (PicturePtr pPicture,
+ INT16 xOff,
+ INT16 yOff,
+ int ntri,
+ xTriangle *tris);
+
+typedef struct _PictureScreen {
+ int totalPictureSize;
+ unsigned int *PicturePrivateSizes;
+ int PicturePrivateLen;
+
+ PictFormatPtr formats;
+ PictFormatPtr fallback;
+ int nformats;
+
+ CreatePictureProcPtr CreatePicture;
+ DestroyPictureProcPtr DestroyPicture;
+ ChangePictureClipProcPtr ChangePictureClip;
+ DestroyPictureClipProcPtr DestroyPictureClip;
+
+ ChangePictureProcPtr ChangePicture;
+ ValidatePictureProcPtr ValidatePicture;
+
+ CompositeProcPtr Composite;
+ GlyphsProcPtr Glyphs;
+ CompositeRectsProcPtr CompositeRects;
+
+ DestroyWindowProcPtr DestroyWindow;
+ CloseScreenProcPtr CloseScreen;
+
+ StoreColorsProcPtr StoreColors;
+
+ InitIndexedProcPtr InitIndexed;
+ CloseIndexedProcPtr CloseIndexed;
+ UpdateIndexedProcPtr UpdateIndexed;
+
+ int subpixel;
+
+ PictFilterPtr filters;
+ int nfilters;
+ PictFilterAliasPtr filterAliases;
+ int nfilterAliases;
+
+ ChangePictureTransformProcPtr ChangePictureTransform;
+ ChangePictureFilterProcPtr ChangePictureFilter;
+ DestroyPictureFilterProcPtr DestroyPictureFilter;
+
+ TrapezoidsProcPtr Trapezoids;
+ TrianglesProcPtr Triangles;
+ TriStripProcPtr TriStrip;
+ TriFanProcPtr TriFan;
+
+ RasterizeTrapezoidProcPtr RasterizeTrapezoid;
+
+ AddTrianglesProcPtr AddTriangles;
+
+ AddTrapsProcPtr AddTraps;
+
+} PictureScreenRec, *PictureScreenPtr;
+
+extern int PictureScreenPrivateIndex;
+extern int PictureWindowPrivateIndex;
+extern RESTYPE PictureType;
+extern RESTYPE PictFormatType;
+extern RESTYPE GlyphSetType;
+
+#define GetPictureScreen(s) ((PictureScreenPtr) ((s)->devPrivates[PictureScreenPrivateIndex].ptr))
+#define GetPictureScreenIfSet(s) ((PictureScreenPrivateIndex != -1) ? GetPictureScreen(s) : NULL)
+#define SetPictureScreen(s,p) ((s)->devPrivates[PictureScreenPrivateIndex].ptr = (pointer) (p))
+#define GetPictureWindow(w) ((PicturePtr) ((w)->devPrivates[PictureWindowPrivateIndex].ptr))
+#define SetPictureWindow(w,p) ((w)->devPrivates[PictureWindowPrivateIndex].ptr = (pointer) (p))
+
+#define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\
+ pPicture = SecurityLookupIDByType(client, pid, PictureType, mode);\
+ if (!pPicture) { \
+ client->errorValue = pid; \
+ return err; \
+ } \
+}
+
+#define VERIFY_ALPHA(pPicture, pid, client, mode, err) {\
+ if (pid == None) \
+ pPicture = 0; \
+ else { \
+ VERIFY_PICTURE(pPicture, pid, client, mode, err); \
+ } \
+} \
+
+void
+ResetPicturePrivateIndex (void);
+
+int
+AllocatePicturePrivateIndex (void);
+
+Bool
+AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount);
+
+Bool
+PictureDestroyWindow (WindowPtr pWindow);
+
+Bool
+PictureCloseScreen (int Index, ScreenPtr pScreen);
+
+void
+PictureStoreColors (ColormapPtr pColormap, int ndef, xColorItem *pdef);
+
+Bool
+PictureInitIndexedFormats (ScreenPtr pScreen);
+
+Bool
+PictureSetSubpixelOrder (ScreenPtr pScreen, int subpixel);
+
+int
+PictureGetSubpixelOrder (ScreenPtr pScreen);
+
+PictFormatPtr
+PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp);
+
+PictFormatPtr
+PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual);
+
+PictFormatPtr
+PictureMatchFormat (ScreenPtr pScreen, int depth, CARD32 format);
+
+Bool
+PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
+
+int
+PictureGetFilterId (char *filter, int len, Bool makeit);
+
+char *
+PictureGetFilterName (int id);
+
+int
+PictureAddFilter (ScreenPtr pScreen,
+ char *filter,
+ PictFilterValidateParamsProcPtr ValidateParams);
+
+Bool
+PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias);
+
+Bool
+PictureSetDefaultFilters (ScreenPtr pScreen);
+
+void
+PictureResetFilters (ScreenPtr pScreen);
+
+PictFilterPtr
+PictureFindFilter (ScreenPtr pScreen, char *name, int len);
+
+int
+SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int nparams);
+
+Bool
+PictureFinishInit (void);
+
+void
+SetPictureToDefaults (PicturePtr pPicture);
+
+PicturePtr
+AllocatePicture (ScreenPtr pScreen);
+
+#if 0
+Bool
+miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
+#endif
+
+
+PicturePtr
+CreatePicture (Picture pid,
+ DrawablePtr pDrawable,
+ PictFormatPtr pFormat,
+ Mask mask,
+ XID *list,
+ ClientPtr client,
+ int *error);
+
+int
+ChangePicture (PicturePtr pPicture,
+ Mask vmask,
+ XID *vlist,
+ DevUnion *ulist,
+ ClientPtr client);
+
+int
+SetPictureClipRects (PicturePtr pPicture,
+ int xOrigin,
+ int yOrigin,
+ int nRect,
+ xRectangle *rects);
+
+int
+SetPictureClipRegion (PicturePtr pPicture,
+ int xOrigin,
+ int yOrigin,
+ RegionPtr pRegion);
+
+int
+SetPictureTransform (PicturePtr pPicture,
+ PictTransform *transform);
+
+void
+CopyPicture (PicturePtr pSrc,
+ Mask mask,
+ PicturePtr pDst);
+
+void
+ValidatePicture(PicturePtr pPicture);
+
+int
+FreePicture (pointer pPicture,
+ XID pid);
+
+int
+FreePictFormat (pointer pPictFormat,
+ XID pid);
+
+void
+CompositePicture (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
+CompositeGlyphs (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int nlist,
+ GlyphListPtr lists,
+ GlyphPtr *glyphs);
+
+void
+CompositeRects (CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects);
+
+void
+CompositeTrapezoids (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntrap,
+ xTrapezoid *traps);
+
+void
+CompositeTriangles (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int ntriangles,
+ xTriangle *triangles);
+
+void
+CompositeTriStrip (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoints,
+ xPointFixed *points);
+
+void
+CompositeTriFan (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc,
+ int npoints,
+ xPointFixed *points);
+
+Bool
+PictureTransformPoint (PictTransformPtr transform,
+ PictVectorPtr vector);
+
+Bool
+PictureTransformPoint3d (PictTransformPtr transform,
+ PictVectorPtr vector);
+
+void RenderExtensionInit (void);
+
+Bool
+AnimCurInit (ScreenPtr pScreen);
+
+int
+AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor);
+
+void
+AddTraps (PicturePtr pPicture,
+ INT16 xOff,
+ INT16 yOff,
+ int ntraps,
+ xTrap *traps);
+
+PicturePtr
+CreateSolidPicture (Picture pid,
+ xRenderColor *color,
+ int *error);
+
+PicturePtr
+CreateLinearGradientPicture (Picture pid,
+ xPointFixed *p1,
+ xPointFixed *p2,
+ int nStops,
+ xFixed *stops,
+ xRenderColor *colors,
+ int *error);
+
+PicturePtr
+CreateRadialGradientPicture (Picture pid,
+ xPointFixed *inner,
+ xPointFixed *outer,
+ xFixed innerRadius,
+ xFixed outerRadius,
+ int nStops,
+ xFixed *stops,
+ xRenderColor *colors,
+ int *error);
+
+PicturePtr
+CreateConicalGradientPicture (Picture pid,
+ xPointFixed *center,
+ xFixed angle,
+ int nStops,
+ xFixed *stops,
+ xRenderColor *colors,
+ int *error);
+
+#ifdef PANORAMIX
+void PanoramiXRenderInit (void);
+void PanoramiXRenderReset (void);
+#endif
+
+#endif /* _PICTURESTR_H_ */
diff --git a/nx-X11/programs/Xserver/render/render.c b/nx-X11/programs/Xserver/render/render.c
new file mode 100644
index 000000000..d2759ab10
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/render.c
@@ -0,0 +1,3306 @@
+/* $XdotOrg: xc/programs/Xserver/render/render.c,v 1.12 2005/08/28 19:47:39 ajax Exp $ */
+/*
+ * $XFree86: xc/programs/Xserver/render/render.c,v 1.27tsi Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "colormapst.h"
+#include "extnsionst.h"
+#include "servermd.h"
+#include <X11/extensions/render.h>
+#include <X11/extensions/renderproto.h>
+#include "picturestr.h"
+#include "glyphstr.h"
+#include <X11/Xfuncproto.h>
+#include "cursorstr.h"
+#ifdef EXTMODULE
+#include "xf86_ansic.h"
+#endif
+
+#if !defined(UINT32_MAX)
+#define UINT32_MAX 0xffffffffU
+#endif
+
+static int ProcRenderQueryVersion (ClientPtr pClient);
+static int ProcRenderQueryPictFormats (ClientPtr pClient);
+static int ProcRenderQueryPictIndexValues (ClientPtr pClient);
+static int ProcRenderQueryDithers (ClientPtr pClient);
+static int ProcRenderCreatePicture (ClientPtr pClient);
+static int ProcRenderChangePicture (ClientPtr pClient);
+static int ProcRenderSetPictureClipRectangles (ClientPtr pClient);
+static int ProcRenderFreePicture (ClientPtr pClient);
+static int ProcRenderComposite (ClientPtr pClient);
+static int ProcRenderScale (ClientPtr pClient);
+static int ProcRenderTrapezoids (ClientPtr pClient);
+static int ProcRenderTriangles (ClientPtr pClient);
+static int ProcRenderTriStrip (ClientPtr pClient);
+static int ProcRenderTriFan (ClientPtr pClient);
+static int ProcRenderColorTrapezoids (ClientPtr pClient);
+static int ProcRenderColorTriangles (ClientPtr pClient);
+static int ProcRenderTransform (ClientPtr pClient);
+static int ProcRenderCreateGlyphSet (ClientPtr pClient);
+static int ProcRenderReferenceGlyphSet (ClientPtr pClient);
+static int ProcRenderFreeGlyphSet (ClientPtr pClient);
+static int ProcRenderAddGlyphs (ClientPtr pClient);
+static int ProcRenderAddGlyphsFromPicture (ClientPtr pClient);
+static int ProcRenderFreeGlyphs (ClientPtr pClient);
+static int ProcRenderCompositeGlyphs (ClientPtr pClient);
+static int ProcRenderFillRectangles (ClientPtr pClient);
+static int ProcRenderCreateCursor (ClientPtr pClient);
+static int ProcRenderSetPictureTransform (ClientPtr pClient);
+static int ProcRenderQueryFilters (ClientPtr pClient);
+static int ProcRenderSetPictureFilter (ClientPtr pClient);
+static int ProcRenderCreateAnimCursor (ClientPtr pClient);
+static int ProcRenderAddTraps (ClientPtr pClient);
+static int ProcRenderCreateSolidFill (ClientPtr pClient);
+static int ProcRenderCreateLinearGradient (ClientPtr pClient);
+static int ProcRenderCreateRadialGradient (ClientPtr pClient);
+static int ProcRenderCreateConicalGradient (ClientPtr pClient);
+
+static int ProcRenderDispatch (ClientPtr pClient);
+
+static int SProcRenderQueryVersion (ClientPtr pClient);
+static int SProcRenderQueryPictFormats (ClientPtr pClient);
+static int SProcRenderQueryPictIndexValues (ClientPtr pClient);
+static int SProcRenderQueryDithers (ClientPtr pClient);
+static int SProcRenderCreatePicture (ClientPtr pClient);
+static int SProcRenderChangePicture (ClientPtr pClient);
+static int SProcRenderSetPictureClipRectangles (ClientPtr pClient);
+static int SProcRenderFreePicture (ClientPtr pClient);
+static int SProcRenderComposite (ClientPtr pClient);
+static int SProcRenderScale (ClientPtr pClient);
+static int SProcRenderTrapezoids (ClientPtr pClient);
+static int SProcRenderTriangles (ClientPtr pClient);
+static int SProcRenderTriStrip (ClientPtr pClient);
+static int SProcRenderTriFan (ClientPtr pClient);
+static int SProcRenderColorTrapezoids (ClientPtr pClient);
+static int SProcRenderColorTriangles (ClientPtr pClient);
+static int SProcRenderTransform (ClientPtr pClient);
+static int SProcRenderCreateGlyphSet (ClientPtr pClient);
+static int SProcRenderReferenceGlyphSet (ClientPtr pClient);
+static int SProcRenderFreeGlyphSet (ClientPtr pClient);
+static int SProcRenderAddGlyphs (ClientPtr pClient);
+static int SProcRenderAddGlyphsFromPicture (ClientPtr pClient);
+static int SProcRenderFreeGlyphs (ClientPtr pClient);
+static int SProcRenderCompositeGlyphs (ClientPtr pClient);
+static int SProcRenderFillRectangles (ClientPtr pClient);
+static int SProcRenderCreateCursor (ClientPtr pClient);
+static int SProcRenderSetPictureTransform (ClientPtr pClient);
+static int SProcRenderQueryFilters (ClientPtr pClient);
+static int SProcRenderSetPictureFilter (ClientPtr pClient);
+static int SProcRenderCreateAnimCursor (ClientPtr pClient);
+static int SProcRenderAddTraps (ClientPtr pClient);
+static int SProcRenderCreateSolidFill (ClientPtr pClient);
+static int SProcRenderCreateLinearGradient (ClientPtr pClient);
+static int SProcRenderCreateRadialGradient (ClientPtr pClient);
+static int SProcRenderCreateConicalGradient (ClientPtr pClient);
+
+static int SProcRenderDispatch (ClientPtr pClient);
+
+int (*ProcRenderVector[RenderNumberRequests])(ClientPtr) = {
+ ProcRenderQueryVersion,
+ ProcRenderQueryPictFormats,
+ ProcRenderQueryPictIndexValues,
+ ProcRenderQueryDithers,
+ ProcRenderCreatePicture,
+ ProcRenderChangePicture,
+ ProcRenderSetPictureClipRectangles,
+ ProcRenderFreePicture,
+ ProcRenderComposite,
+ ProcRenderScale,
+ ProcRenderTrapezoids,
+ ProcRenderTriangles,
+ ProcRenderTriStrip,
+ ProcRenderTriFan,
+ ProcRenderColorTrapezoids,
+ ProcRenderColorTriangles,
+ ProcRenderTransform,
+ ProcRenderCreateGlyphSet,
+ ProcRenderReferenceGlyphSet,
+ ProcRenderFreeGlyphSet,
+ ProcRenderAddGlyphs,
+ ProcRenderAddGlyphsFromPicture,
+ ProcRenderFreeGlyphs,
+ ProcRenderCompositeGlyphs,
+ ProcRenderCompositeGlyphs,
+ ProcRenderCompositeGlyphs,
+ ProcRenderFillRectangles,
+ ProcRenderCreateCursor,
+ ProcRenderSetPictureTransform,
+ ProcRenderQueryFilters,
+ ProcRenderSetPictureFilter,
+ ProcRenderCreateAnimCursor,
+ ProcRenderAddTraps,
+ ProcRenderCreateSolidFill,
+ ProcRenderCreateLinearGradient,
+ ProcRenderCreateRadialGradient,
+ ProcRenderCreateConicalGradient
+};
+
+int (*SProcRenderVector[RenderNumberRequests])(ClientPtr) = {
+ SProcRenderQueryVersion,
+ SProcRenderQueryPictFormats,
+ SProcRenderQueryPictIndexValues,
+ SProcRenderQueryDithers,
+ SProcRenderCreatePicture,
+ SProcRenderChangePicture,
+ SProcRenderSetPictureClipRectangles,
+ SProcRenderFreePicture,
+ SProcRenderComposite,
+ SProcRenderScale,
+ SProcRenderTrapezoids,
+ SProcRenderTriangles,
+ SProcRenderTriStrip,
+ SProcRenderTriFan,
+ SProcRenderColorTrapezoids,
+ SProcRenderColorTriangles,
+ SProcRenderTransform,
+ SProcRenderCreateGlyphSet,
+ SProcRenderReferenceGlyphSet,
+ SProcRenderFreeGlyphSet,
+ SProcRenderAddGlyphs,
+ SProcRenderAddGlyphsFromPicture,
+ SProcRenderFreeGlyphs,
+ SProcRenderCompositeGlyphs,
+ SProcRenderCompositeGlyphs,
+ SProcRenderCompositeGlyphs,
+ SProcRenderFillRectangles,
+ SProcRenderCreateCursor,
+ SProcRenderSetPictureTransform,
+ SProcRenderQueryFilters,
+ SProcRenderSetPictureFilter,
+ SProcRenderCreateAnimCursor,
+ SProcRenderAddTraps,
+ SProcRenderCreateSolidFill,
+ SProcRenderCreateLinearGradient,
+ SProcRenderCreateRadialGradient,
+ SProcRenderCreateConicalGradient
+};
+
+static void
+RenderResetProc (ExtensionEntry *extEntry);
+
+#if 0
+static CARD8 RenderReqCode;
+#endif
+int RenderErrBase;
+int RenderClientPrivateIndex;
+
+typedef struct _RenderClient {
+ int major_version;
+ int minor_version;
+} RenderClientRec, *RenderClientPtr;
+
+#define GetRenderClient(pClient) ((RenderClientPtr) (pClient)->devPrivates[RenderClientPrivateIndex].ptr)
+
+static void
+RenderClientCallback (CallbackListPtr *list,
+ pointer closure,
+ pointer data)
+{
+ NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
+ ClientPtr pClient = clientinfo->client;
+ RenderClientPtr pRenderClient = GetRenderClient (pClient);
+
+ pRenderClient->major_version = 0;
+ pRenderClient->minor_version = 0;
+}
+
+void
+RenderExtensionInit (void)
+{
+ ExtensionEntry *extEntry;
+
+ if (!PictureType)
+ return;
+ if (!PictureFinishInit ())
+ return;
+ RenderClientPrivateIndex = AllocateClientPrivateIndex ();
+ if (!AllocateClientPrivate (RenderClientPrivateIndex,
+ sizeof (RenderClientRec)))
+ return;
+ if (!AddCallback (&ClientStateCallback, RenderClientCallback, 0))
+ return;
+
+ extEntry = AddExtension (RENDER_NAME, 0, RenderNumberErrors,
+ ProcRenderDispatch, SProcRenderDispatch,
+ RenderResetProc, StandardMinorOpcode);
+ if (!extEntry)
+ return;
+#if 0
+ RenderReqCode = (CARD8) extEntry->base;
+#endif
+ RenderErrBase = extEntry->errorBase;
+}
+
+static void
+RenderResetProc (ExtensionEntry *extEntry)
+{
+ ResetPicturePrivateIndex();
+ ResetGlyphSetPrivateIndex();
+}
+
+static int
+ProcRenderQueryVersion (ClientPtr client)
+{
+ RenderClientPtr pRenderClient = GetRenderClient (client);
+ xRenderQueryVersionReply rep;
+ register int n;
+ REQUEST(xRenderQueryVersionReq);
+
+ pRenderClient->major_version = stuff->majorVersion;
+ pRenderClient->minor_version = stuff->minorVersion;
+
+ REQUEST_SIZE_MATCH(xRenderQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = RENDER_MAJOR;
+ rep.minorVersion = RENDER_MINOR;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.majorVersion, n);
+ swapl(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof(xRenderQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+}
+
+#if 0
+static int
+VisualDepth (ScreenPtr pScreen, VisualPtr pVisual)
+{
+ DepthPtr pDepth;
+ int d, v;
+
+ for (d = 0; d < pScreen->numDepths; d++)
+ {
+ pDepth = pScreen->allowedDepths + d;
+ for (v = 0; v < pDepth->numVids; v++)
+ {
+ if (pDepth->vids[v] == pVisual->vid)
+ return pDepth->depth;
+ }
+ }
+ return 0;
+}
+#endif
+
+static VisualPtr
+findVisual (ScreenPtr pScreen, VisualID vid)
+{
+ VisualPtr pVisual;
+ int v;
+
+ for (v = 0; v < pScreen->numVisuals; v++)
+ {
+ pVisual = pScreen->visuals + v;
+ if (pVisual->vid == vid)
+ return pVisual;
+ }
+ return 0;
+}
+
+extern char *ConnectionInfo;
+
+static int
+ProcRenderQueryPictFormats (ClientPtr client)
+{
+ RenderClientPtr pRenderClient = GetRenderClient (client);
+ xRenderQueryPictFormatsReply *reply;
+ xPictScreen *pictScreen;
+ xPictDepth *pictDepth;
+ xPictVisual *pictVisual;
+ xPictFormInfo *pictForm;
+ CARD32 *pictSubpixel;
+ ScreenPtr pScreen;
+ VisualPtr pVisual;
+ DepthPtr pDepth;
+ int v, d;
+ PictureScreenPtr ps;
+ PictFormatPtr pFormat;
+ int nformat;
+ int ndepth;
+ int nvisual;
+ int rlength;
+ int s;
+ int n;
+ int numScreens;
+ int numSubpixel;
+/* REQUEST(xRenderQueryPictFormatsReq); */
+
+ REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq);
+
+#ifdef PANORAMIX
+ if (noPanoramiXExtension)
+ numScreens = screenInfo.numScreens;
+ else
+ numScreens = ((xConnSetup *)ConnectionInfo)->numRoots;
+#else
+ numScreens = screenInfo.numScreens;
+#endif
+ ndepth = nformat = nvisual = 0;
+ for (s = 0; s < numScreens; s++)
+ {
+ pScreen = screenInfo.screens[s];
+ for (d = 0; d < pScreen->numDepths; d++)
+ {
+ pDepth = pScreen->allowedDepths + d;
+ ++ndepth;
+
+ for (v = 0; v < pDepth->numVids; v++)
+ {
+ pVisual = findVisual (pScreen, pDepth->vids[v]);
+ if (pVisual && PictureMatchVisual (pScreen, pDepth->depth, pVisual))
+ ++nvisual;
+ }
+ }
+ ps = GetPictureScreenIfSet(pScreen);
+ if (ps)
+ nformat += ps->nformats;
+ }
+ if (pRenderClient->major_version == 0 && pRenderClient->minor_version < 6)
+ numSubpixel = 0;
+ else
+ numSubpixel = numScreens;
+
+ rlength = (sizeof (xRenderQueryPictFormatsReply) +
+ nformat * sizeof (xPictFormInfo) +
+ numScreens * sizeof (xPictScreen) +
+ ndepth * sizeof (xPictDepth) +
+ nvisual * sizeof (xPictVisual) +
+ numSubpixel * sizeof (CARD32));
+ reply = (xRenderQueryPictFormatsReply *) xalloc (rlength);
+ if (!reply)
+ return BadAlloc;
+ reply->type = X_Reply;
+ reply->sequenceNumber = client->sequence;
+ reply->length = (rlength - sizeof(xGenericReply)) >> 2;
+ reply->numFormats = nformat;
+ reply->numScreens = numScreens;
+ reply->numDepths = ndepth;
+ reply->numVisuals = nvisual;
+ reply->numSubpixel = numSubpixel;
+
+ pictForm = (xPictFormInfo *) (reply + 1);
+
+ for (s = 0; s < numScreens; s++)
+ {
+ pScreen = screenInfo.screens[s];
+ ps = GetPictureScreenIfSet(pScreen);
+ if (ps)
+ {
+ for (nformat = 0, pFormat = ps->formats;
+ nformat < ps->nformats;
+ nformat++, pFormat++)
+ {
+ pictForm->id = pFormat->id;
+ pictForm->type = pFormat->type;
+ pictForm->depth = pFormat->depth;
+ pictForm->direct.red = pFormat->direct.red;
+ pictForm->direct.redMask = pFormat->direct.redMask;
+ pictForm->direct.green = pFormat->direct.green;
+ pictForm->direct.greenMask = pFormat->direct.greenMask;
+ pictForm->direct.blue = pFormat->direct.blue;
+ pictForm->direct.blueMask = pFormat->direct.blueMask;
+ pictForm->direct.alpha = pFormat->direct.alpha;
+ pictForm->direct.alphaMask = pFormat->direct.alphaMask;
+ if (pFormat->type == PictTypeIndexed && pFormat->index.pColormap)
+ pictForm->colormap = pFormat->index.pColormap->mid;
+ else
+ pictForm->colormap = None;
+ if (client->swapped)
+ {
+ swapl (&pictForm->id, n);
+ swaps (&pictForm->direct.red, n);
+ swaps (&pictForm->direct.redMask, n);
+ swaps (&pictForm->direct.green, n);
+ swaps (&pictForm->direct.greenMask, n);
+ swaps (&pictForm->direct.blue, n);
+ swaps (&pictForm->direct.blueMask, n);
+ swaps (&pictForm->direct.alpha, n);
+ swaps (&pictForm->direct.alphaMask, n);
+ swapl (&pictForm->colormap, n);
+ }
+ pictForm++;
+ }
+ }
+ }
+
+ pictScreen = (xPictScreen *) pictForm;
+ for (s = 0; s < numScreens; s++)
+ {
+ pScreen = screenInfo.screens[s];
+ pictDepth = (xPictDepth *) (pictScreen + 1);
+ ndepth = 0;
+ for (d = 0; d < pScreen->numDepths; d++)
+ {
+ pictVisual = (xPictVisual *) (pictDepth + 1);
+ pDepth = pScreen->allowedDepths + d;
+
+ nvisual = 0;
+ for (v = 0; v < pDepth->numVids; v++)
+ {
+ pVisual = findVisual (pScreen, pDepth->vids[v]);
+ if (pVisual && (pFormat = PictureMatchVisual (pScreen,
+ pDepth->depth,
+ pVisual)))
+ {
+ pictVisual->visual = pVisual->vid;
+ pictVisual->format = pFormat->id;
+ if (client->swapped)
+ {
+ swapl (&pictVisual->visual, n);
+ swapl (&pictVisual->format, n);
+ }
+ pictVisual++;
+ nvisual++;
+ }
+ }
+ pictDepth->depth = pDepth->depth;
+ pictDepth->nPictVisuals = nvisual;
+ if (client->swapped)
+ {
+ swaps (&pictDepth->nPictVisuals, n);
+ }
+ ndepth++;
+ pictDepth = (xPictDepth *) pictVisual;
+ }
+ pictScreen->nDepth = ndepth;
+ ps = GetPictureScreenIfSet(pScreen);
+ if (ps)
+ pictScreen->fallback = ps->fallback->id;
+ else
+ pictScreen->fallback = 0;
+ if (client->swapped)
+ {
+ swapl (&pictScreen->nDepth, n);
+ swapl (&pictScreen->fallback, n);
+ }
+ pictScreen = (xPictScreen *) pictDepth;
+ }
+ pictSubpixel = (CARD32 *) pictScreen;
+
+ for (s = 0; s < numSubpixel; s++)
+ {
+ pScreen = screenInfo.screens[s];
+ ps = GetPictureScreenIfSet(pScreen);
+ if (ps)
+ *pictSubpixel = ps->subpixel;
+ else
+ *pictSubpixel = SubPixelUnknown;
+ if (client->swapped)
+ {
+ swapl (pictSubpixel, n);
+ }
+ ++pictSubpixel;
+ }
+
+ if (client->swapped)
+ {
+ swaps (&reply->sequenceNumber, n);
+ swapl (&reply->length, n);
+ swapl (&reply->numFormats, n);
+ swapl (&reply->numScreens, n);
+ swapl (&reply->numDepths, n);
+ swapl (&reply->numVisuals, n);
+ swapl (&reply->numSubpixel, n);
+ }
+ WriteToClient(client, rlength, (char *) reply);
+ xfree (reply);
+ return client->noClientException;
+}
+
+static int
+ProcRenderQueryPictIndexValues (ClientPtr client)
+{
+ PictFormatPtr pFormat;
+ int num;
+ int rlength;
+ int i, n;
+ REQUEST(xRenderQueryPictIndexValuesReq);
+ xRenderQueryPictIndexValuesReply *reply;
+ xIndexValue *values;
+
+ REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq);
+
+ pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
+ stuff->format,
+ PictFormatType,
+ SecurityReadAccess);
+
+ if (!pFormat)
+ {
+ client->errorValue = stuff->format;
+ return RenderErrBase + BadPictFormat;
+ }
+ if (pFormat->type != PictTypeIndexed)
+ {
+ client->errorValue = stuff->format;
+ return BadMatch;
+ }
+ num = pFormat->index.nvalues;
+ rlength = (sizeof (xRenderQueryPictIndexValuesReply) +
+ num * sizeof(xIndexValue));
+ reply = (xRenderQueryPictIndexValuesReply *) xalloc (rlength);
+ if (!reply)
+ return BadAlloc;
+
+ reply->type = X_Reply;
+ reply->sequenceNumber = client->sequence;
+ reply->length = (rlength - sizeof(xGenericReply)) >> 2;
+ reply->numIndexValues = num;
+
+ values = (xIndexValue *) (reply + 1);
+
+ memcpy (reply + 1, pFormat->index.pValues, num * sizeof (xIndexValue));
+
+ if (client->swapped)
+ {
+ for (i = 0; i < num; i++)
+ {
+ swapl (&values[i].pixel, n);
+ swaps (&values[i].red, n);
+ swaps (&values[i].green, n);
+ swaps (&values[i].blue, n);
+ swaps (&values[i].alpha, n);
+ }
+ swaps (&reply->sequenceNumber, n);
+ swapl (&reply->length, n);
+ swapl (&reply->numIndexValues, n);
+ }
+
+ WriteToClient(client, rlength, (char *) reply);
+ xfree(reply);
+ return (client->noClientException);
+}
+
+static int
+ProcRenderQueryDithers (ClientPtr client)
+{
+ return BadImplementation;
+}
+
+static int
+ProcRenderCreatePicture (ClientPtr client)
+{
+ PicturePtr pPicture;
+ DrawablePtr pDrawable;
+ PictFormatPtr pFormat;
+ int len;
+ int error;
+ REQUEST(xRenderCreatePictureReq);
+
+ REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq);
+
+ LEGAL_NEW_RESOURCE(stuff->pid, client);
+ SECURITY_VERIFY_DRAWABLE(pDrawable, stuff->drawable, client,
+ SecurityWriteAccess);
+ pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
+ stuff->format,
+ PictFormatType,
+ SecurityReadAccess);
+ if (!pFormat)
+ {
+ client->errorValue = stuff->format;
+ return RenderErrBase + BadPictFormat;
+ }
+ if (pFormat->depth != pDrawable->depth)
+ return BadMatch;
+ len = client->req_len - (sizeof(xRenderCreatePictureReq) >> 2);
+ if (Ones(stuff->mask) != len)
+ return BadLength;
+
+ pPicture = CreatePicture (stuff->pid,
+ pDrawable,
+ pFormat,
+ stuff->mask,
+ (XID *) (stuff + 1),
+ client,
+ &error);
+ if (!pPicture)
+ return error;
+ if (!AddResource (stuff->pid, PictureType, (pointer)pPicture))
+ return BadAlloc;
+ return Success;
+}
+
+static int
+ProcRenderChangePicture (ClientPtr client)
+{
+ PicturePtr pPicture;
+ REQUEST(xRenderChangePictureReq);
+ int len;
+
+ REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq);
+ VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+
+ len = client->req_len - (sizeof(xRenderChangePictureReq) >> 2);
+ if (Ones(stuff->mask) != len)
+ return BadLength;
+
+ return ChangePicture (pPicture, stuff->mask, (XID *) (stuff + 1),
+ (DevUnion *) 0, client);
+}
+
+static int
+ProcRenderSetPictureClipRectangles (ClientPtr client)
+{
+ REQUEST(xRenderSetPictureClipRectanglesReq);
+ PicturePtr pPicture;
+ int nr;
+ int result;
+
+ REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq);
+ VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+ if (!pPicture->pDrawable)
+ return BadDrawable;
+
+ nr = (client->req_len << 2) - sizeof(xRenderChangePictureReq);
+ if (nr & 4)
+ return BadLength;
+ nr >>= 3;
+ result = SetPictureClipRects (pPicture,
+ stuff->xOrigin, stuff->yOrigin,
+ nr, (xRectangle *) &stuff[1]);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return(result);
+}
+
+static int
+ProcRenderFreePicture (ClientPtr client)
+{
+ PicturePtr pPicture;
+ REQUEST(xRenderFreePictureReq);
+
+ REQUEST_SIZE_MATCH(xRenderFreePictureReq);
+
+ VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityDestroyAccess,
+ RenderErrBase + BadPicture);
+ FreeResource (stuff->picture, RT_NONE);
+ return(client->noClientException);
+}
+
+static Bool
+PictOpValid (CARD8 op)
+{
+ if (/*PictOpMinimum <= op && */ op <= PictOpMaximum)
+ return TRUE;
+ if (PictOpDisjointMinimum <= op && op <= PictOpDisjointMaximum)
+ return TRUE;
+ if (PictOpConjointMinimum <= op && op <= PictOpConjointMaximum)
+ return TRUE;
+ return FALSE;
+}
+
+static int
+ProcRenderComposite (ClientPtr client)
+{
+ PicturePtr pSrc, pMask, pDst;
+ REQUEST(xRenderCompositeReq);
+
+ REQUEST_SIZE_MATCH(xRenderCompositeReq);
+ if (!PictOpValid (stuff->op))
+ {
+ client->errorValue = stuff->op;
+ return BadValue;
+ }
+ VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+ if (!pDst->pDrawable)
+ return BadDrawable;
+ VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess,
+ RenderErrBase + BadPicture);
+ VERIFY_ALPHA (pMask, stuff->mask, client, SecurityReadAccess,
+ RenderErrBase + BadPicture);
+ if ((pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) ||
+ (pMask && pMask->pDrawable && pSrc->pDrawable->pScreen != pMask->pDrawable->pScreen))
+ return BadMatch;
+ CompositePicture (stuff->op,
+ pSrc,
+ pMask,
+ pDst,
+ stuff->xSrc,
+ stuff->ySrc,
+ stuff->xMask,
+ stuff->yMask,
+ stuff->xDst,
+ stuff->yDst,
+ stuff->width,
+ stuff->height);
+ return Success;
+}
+
+static int
+ProcRenderScale (ClientPtr client)
+{
+ return BadImplementation;
+}
+
+static int
+ProcRenderTrapezoids (ClientPtr client)
+{
+ int ntraps;
+ PicturePtr pSrc, pDst;
+ PictFormatPtr pFormat;
+ REQUEST(xRenderTrapezoidsReq);
+
+ REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq);
+ if (!PictOpValid (stuff->op))
+ {
+ client->errorValue = stuff->op;
+ return BadValue;
+ }
+ VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess,
+ RenderErrBase + BadPicture);
+ VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+ if (!pDst->pDrawable)
+ return BadDrawable;
+ if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
+ return BadMatch;
+ if (stuff->maskFormat)
+ {
+ pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
+ stuff->maskFormat,
+ PictFormatType,
+ SecurityReadAccess);
+ if (!pFormat)
+ {
+ client->errorValue = stuff->maskFormat;
+ return RenderErrBase + BadPictFormat;
+ }
+ }
+ else
+ pFormat = 0;
+ ntraps = (client->req_len << 2) - sizeof (xRenderTrapezoidsReq);
+ if (ntraps % sizeof (xTrapezoid))
+ return BadLength;
+ ntraps /= sizeof (xTrapezoid);
+ if (ntraps)
+ CompositeTrapezoids (stuff->op, pSrc, pDst, pFormat,
+ stuff->xSrc, stuff->ySrc,
+ ntraps, (xTrapezoid *) &stuff[1]);
+ return client->noClientException;
+}
+
+static int
+ProcRenderTriangles (ClientPtr client)
+{
+ int ntris;
+ PicturePtr pSrc, pDst;
+ PictFormatPtr pFormat;
+ REQUEST(xRenderTrianglesReq);
+
+ REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
+ if (!PictOpValid (stuff->op))
+ {
+ client->errorValue = stuff->op;
+ return BadValue;
+ }
+ VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess,
+ RenderErrBase + BadPicture);
+ VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+ if (!pDst->pDrawable)
+ return BadDrawable;
+ if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
+ return BadMatch;
+ if (stuff->maskFormat)
+ {
+ pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
+ stuff->maskFormat,
+ PictFormatType,
+ SecurityReadAccess);
+ if (!pFormat)
+ {
+ client->errorValue = stuff->maskFormat;
+ return RenderErrBase + BadPictFormat;
+ }
+ }
+ else
+ pFormat = 0;
+ ntris = (client->req_len << 2) - sizeof (xRenderTrianglesReq);
+ if (ntris % sizeof (xTriangle))
+ return BadLength;
+ ntris /= sizeof (xTriangle);
+ if (ntris)
+ CompositeTriangles (stuff->op, pSrc, pDst, pFormat,
+ stuff->xSrc, stuff->ySrc,
+ ntris, (xTriangle *) &stuff[1]);
+ return client->noClientException;
+}
+
+static int
+ProcRenderTriStrip (ClientPtr client)
+{
+ int npoints;
+ PicturePtr pSrc, pDst;
+ PictFormatPtr pFormat;
+ REQUEST(xRenderTrianglesReq);
+
+ REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
+ if (!PictOpValid (stuff->op))
+ {
+ client->errorValue = stuff->op;
+ return BadValue;
+ }
+ VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess,
+ RenderErrBase + BadPicture);
+ VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+ if (!pDst->pDrawable)
+ return BadDrawable;
+ if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
+ return BadMatch;
+ if (stuff->maskFormat)
+ {
+ pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
+ stuff->maskFormat,
+ PictFormatType,
+ SecurityReadAccess);
+ if (!pFormat)
+ {
+ client->errorValue = stuff->maskFormat;
+ return RenderErrBase + BadPictFormat;
+ }
+ }
+ else
+ pFormat = 0;
+ npoints = ((client->req_len << 2) - sizeof (xRenderTriStripReq));
+ if (npoints & 4)
+ return(BadLength);
+ npoints >>= 3;
+ if (npoints >= 3)
+ CompositeTriStrip (stuff->op, pSrc, pDst, pFormat,
+ stuff->xSrc, stuff->ySrc,
+ npoints, (xPointFixed *) &stuff[1]);
+ return client->noClientException;
+}
+
+static int
+ProcRenderTriFan (ClientPtr client)
+{
+ int npoints;
+ PicturePtr pSrc, pDst;
+ PictFormatPtr pFormat;
+ REQUEST(xRenderTrianglesReq);
+
+ REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
+ if (!PictOpValid (stuff->op))
+ {
+ client->errorValue = stuff->op;
+ return BadValue;
+ }
+ VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess,
+ RenderErrBase + BadPicture);
+ VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+ if (!pDst->pDrawable)
+ return BadDrawable;
+ if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
+ return BadMatch;
+ if (stuff->maskFormat)
+ {
+ pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
+ stuff->maskFormat,
+ PictFormatType,
+ SecurityReadAccess);
+ if (!pFormat)
+ {
+ client->errorValue = stuff->maskFormat;
+ return RenderErrBase + BadPictFormat;
+ }
+ }
+ else
+ pFormat = 0;
+ npoints = ((client->req_len << 2) - sizeof (xRenderTriStripReq));
+ if (npoints & 4)
+ return(BadLength);
+ npoints >>= 3;
+ if (npoints >= 3)
+ CompositeTriFan (stuff->op, pSrc, pDst, pFormat,
+ stuff->xSrc, stuff->ySrc,
+ npoints, (xPointFixed *) &stuff[1]);
+ return client->noClientException;
+}
+
+static int
+ProcRenderColorTrapezoids (ClientPtr client)
+{
+ return BadImplementation;
+}
+
+static int
+ProcRenderColorTriangles (ClientPtr client)
+{
+ return BadImplementation;
+}
+
+static int
+ProcRenderTransform (ClientPtr client)
+{
+ return BadImplementation;
+}
+
+static int
+ProcRenderCreateGlyphSet (ClientPtr client)
+{
+ GlyphSetPtr glyphSet;
+ PictFormatPtr format;
+ int f;
+ REQUEST(xRenderCreateGlyphSetReq);
+
+ REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq);
+
+ LEGAL_NEW_RESOURCE(stuff->gsid, client);
+ format = (PictFormatPtr) SecurityLookupIDByType (client,
+ stuff->format,
+ PictFormatType,
+ SecurityReadAccess);
+ if (!format)
+ {
+ client->errorValue = stuff->format;
+ return RenderErrBase + BadPictFormat;
+ }
+ switch (format->depth) {
+ case 1:
+ f = GlyphFormat1;
+ break;
+ case 4:
+ f = GlyphFormat4;
+ break;
+ case 8:
+ f = GlyphFormat8;
+ break;
+ case 16:
+ f = GlyphFormat16;
+ break;
+ case 32:
+ f = GlyphFormat32;
+ break;
+ default:
+ return BadMatch;
+ }
+ if (format->type != PictTypeDirect)
+ return BadMatch;
+ glyphSet = AllocateGlyphSet (f, format);
+ if (!glyphSet)
+ return BadAlloc;
+ if (!AddResource (stuff->gsid, GlyphSetType, (pointer)glyphSet))
+ return BadAlloc;
+ return Success;
+}
+
+static int
+ProcRenderReferenceGlyphSet (ClientPtr client)
+{
+ GlyphSetPtr glyphSet;
+ REQUEST(xRenderReferenceGlyphSetReq);
+
+ REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq);
+
+ LEGAL_NEW_RESOURCE(stuff->gsid, client);
+
+ glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
+ stuff->existing,
+ GlyphSetType,
+ SecurityWriteAccess);
+ if (!glyphSet)
+ {
+ client->errorValue = stuff->existing;
+ return RenderErrBase + BadGlyphSet;
+ }
+ glyphSet->refcnt++;
+ if (!AddResource (stuff->gsid, GlyphSetType, (pointer)glyphSet))
+ return BadAlloc;
+ return client->noClientException;
+}
+
+#define NLOCALDELTA 64
+#define NLOCALGLYPH 256
+
+static int
+ProcRenderFreeGlyphSet (ClientPtr client)
+{
+ GlyphSetPtr glyphSet;
+ REQUEST(xRenderFreeGlyphSetReq);
+
+ REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
+ glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
+ stuff->glyphset,
+ GlyphSetType,
+ SecurityDestroyAccess);
+ if (!glyphSet)
+ {
+ client->errorValue = stuff->glyphset;
+ return RenderErrBase + BadGlyphSet;
+ }
+ FreeResource (stuff->glyphset, RT_NONE);
+ return client->noClientException;
+}
+
+typedef struct _GlyphNew {
+ Glyph id;
+ GlyphPtr glyph;
+} GlyphNewRec, *GlyphNewPtr;
+
+static int
+ProcRenderAddGlyphs (ClientPtr client)
+{
+ GlyphSetPtr glyphSet;
+ REQUEST(xRenderAddGlyphsReq);
+ GlyphNewRec glyphsLocal[NLOCALGLYPH];
+ GlyphNewPtr glyphsBase, glyphs;
+ GlyphPtr glyph;
+ int remain, nglyphs;
+ CARD32 *gids;
+ xGlyphInfo *gi;
+ CARD8 *bits;
+ int size;
+ int err = BadAlloc;
+
+ REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq);
+ glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
+ stuff->glyphset,
+ GlyphSetType,
+ SecurityWriteAccess);
+ if (!glyphSet)
+ {
+ client->errorValue = stuff->glyphset;
+ return RenderErrBase + BadGlyphSet;
+ }
+
+ nglyphs = stuff->nglyphs;
+ if (nglyphs > UINT32_MAX / sizeof(GlyphNewRec))
+ return BadAlloc;
+
+ if (nglyphs <= NLOCALGLYPH)
+ glyphsBase = glyphsLocal;
+ else
+ {
+ glyphsBase = (GlyphNewPtr) Xalloc (nglyphs * sizeof (GlyphNewRec));
+ if (!glyphsBase)
+ return BadAlloc;
+ }
+
+ remain = (client->req_len << 2) - sizeof (xRenderAddGlyphsReq);
+
+ glyphs = glyphsBase;
+
+ gids = (CARD32 *) (stuff + 1);
+ gi = (xGlyphInfo *) (gids + nglyphs);
+ bits = (CARD8 *) (gi + nglyphs);
+ remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs;
+ while (remain >= 0 && nglyphs)
+ {
+ glyph = AllocateGlyph (gi, glyphSet->fdepth);
+ if (!glyph)
+ {
+ err = BadAlloc;
+ goto bail;
+ }
+
+ glyphs->glyph = glyph;
+ glyphs->id = *gids;
+
+ size = glyph->size - sizeof (xGlyphInfo);
+ if (remain < size)
+ break;
+ memcpy ((CARD8 *) (glyph + 1), bits, size);
+
+ if (size & 3)
+ size += 4 - (size & 3);
+ bits += size;
+ remain -= size;
+ gi++;
+ gids++;
+ glyphs++;
+ nglyphs--;
+ }
+ if (nglyphs || remain)
+ {
+ err = BadLength;
+ goto bail;
+ }
+ nglyphs = stuff->nglyphs;
+ if (!ResizeGlyphSet (glyphSet, nglyphs))
+ {
+ err = BadAlloc;
+ goto bail;
+ }
+ glyphs = glyphsBase;
+ while (nglyphs--) {
+ AddGlyph (glyphSet, glyphs->glyph, glyphs->id);
+ glyphs++;
+ }
+
+ if (glyphsBase != glyphsLocal)
+ Xfree (glyphsBase);
+ return client->noClientException;
+bail:
+ while (glyphs != glyphsBase)
+ {
+ --glyphs;
+ xfree (glyphs->glyph);
+ }
+ if (glyphsBase != glyphsLocal)
+ Xfree (glyphsBase);
+ return err;
+}
+
+static int
+ProcRenderAddGlyphsFromPicture (ClientPtr client)
+{
+ return BadImplementation;
+}
+
+static int
+ProcRenderFreeGlyphs (ClientPtr client)
+{
+ REQUEST(xRenderFreeGlyphsReq);
+ GlyphSetPtr glyphSet;
+ int nglyph;
+ CARD32 *gids;
+ CARD32 glyph;
+
+ REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq);
+ glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
+ stuff->glyphset,
+ GlyphSetType,
+ SecurityWriteAccess);
+ if (!glyphSet)
+ {
+ client->errorValue = stuff->glyphset;
+ return RenderErrBase + BadGlyphSet;
+ }
+ nglyph = ((client->req_len << 2) - sizeof (xRenderFreeGlyphsReq)) >> 2;
+ gids = (CARD32 *) (stuff + 1);
+ while (nglyph-- > 0)
+ {
+ glyph = *gids++;
+ if (!DeleteGlyph (glyphSet, glyph))
+ {
+ client->errorValue = glyph;
+ return RenderErrBase + BadGlyph;
+ }
+ }
+ return client->noClientException;
+}
+
+static int
+ProcRenderCompositeGlyphs (ClientPtr client)
+{
+ GlyphSetPtr glyphSet;
+ GlyphSet gs;
+ PicturePtr pSrc, pDst;
+ PictFormatPtr pFormat;
+ GlyphListRec listsLocal[NLOCALDELTA];
+ GlyphListPtr lists, listsBase;
+ GlyphPtr glyphsLocal[NLOCALGLYPH];
+ Glyph glyph;
+ GlyphPtr *glyphs, *glyphsBase;
+ xGlyphElt *elt;
+ CARD8 *buffer, *end;
+ int nglyph;
+ int nlist;
+ int space;
+ int size;
+ int n;
+
+ REQUEST(xRenderCompositeGlyphsReq);
+
+ REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq);
+
+ switch (stuff->renderReqType) {
+ default: size = 1; break;
+ case X_RenderCompositeGlyphs16: size = 2; break;
+ case X_RenderCompositeGlyphs32: size = 4; break;
+ }
+
+ if (!PictOpValid (stuff->op))
+ {
+ client->errorValue = stuff->op;
+ return BadValue;
+ }
+ VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess,
+ RenderErrBase + BadPicture);
+ VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+ if (!pDst->pDrawable)
+ return BadDrawable;
+ if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
+ return BadMatch;
+ if (stuff->maskFormat)
+ {
+ pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
+ stuff->maskFormat,
+ PictFormatType,
+ SecurityReadAccess);
+ if (!pFormat)
+ {
+ client->errorValue = stuff->maskFormat;
+ return RenderErrBase + BadPictFormat;
+ }
+ }
+ else
+ pFormat = 0;
+
+ glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
+ stuff->glyphset,
+ GlyphSetType,
+ SecurityReadAccess);
+ if (!glyphSet)
+ {
+ client->errorValue = stuff->glyphset;
+ return RenderErrBase + BadGlyphSet;
+ }
+
+ buffer = (CARD8 *) (stuff + 1);
+ end = (CARD8 *) stuff + (client->req_len << 2);
+ nglyph = 0;
+ nlist = 0;
+ while (buffer + sizeof (xGlyphElt) < end)
+ {
+ elt = (xGlyphElt *) buffer;
+ buffer += sizeof (xGlyphElt);
+
+ if (elt->len == 0xff)
+ {
+ buffer += 4;
+ }
+ else
+ {
+ nlist++;
+ nglyph += elt->len;
+ space = size * elt->len;
+ if (space & 3)
+ space += 4 - (space & 3);
+ buffer += space;
+ }
+ }
+ if (nglyph <= NLOCALGLYPH)
+ glyphsBase = glyphsLocal;
+ else
+ {
+ glyphsBase = (GlyphPtr *) ALLOCATE_LOCAL (nglyph * sizeof (GlyphPtr));
+ if (!glyphsBase)
+ return BadAlloc;
+ }
+ if (nlist <= NLOCALDELTA)
+ listsBase = listsLocal;
+ else
+ {
+ listsBase = (GlyphListPtr) ALLOCATE_LOCAL (nlist * sizeof (GlyphListRec));
+ if (!listsBase)
+ return BadAlloc;
+ }
+ buffer = (CARD8 *) (stuff + 1);
+ glyphs = glyphsBase;
+ lists = listsBase;
+ while (buffer + sizeof (xGlyphElt) < end)
+ {
+ elt = (xGlyphElt *) buffer;
+ buffer += sizeof (xGlyphElt);
+
+ if (elt->len == 0xff)
+ {
+ if (buffer + sizeof (GlyphSet) < end)
+ {
+ memcpy(&gs, buffer, sizeof(GlyphSet));
+ glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
+ gs,
+ GlyphSetType,
+ SecurityReadAccess);
+ if (!glyphSet)
+ {
+ client->errorValue = gs;
+ if (glyphsBase != glyphsLocal)
+ DEALLOCATE_LOCAL (glyphsBase);
+ if (listsBase != listsLocal)
+ DEALLOCATE_LOCAL (listsBase);
+ return RenderErrBase + BadGlyphSet;
+ }
+ }
+ buffer += 4;
+ }
+ else
+ {
+ lists->xOff = elt->deltax;
+ lists->yOff = elt->deltay;
+ lists->format = glyphSet->format;
+ lists->len = 0;
+ n = elt->len;
+ while (n--)
+ {
+ if (buffer + size <= end)
+ {
+ switch (size) {
+ case 1:
+ glyph = *((CARD8 *)buffer); break;
+ case 2:
+ glyph = *((CARD16 *)buffer); break;
+ case 4:
+ default:
+ glyph = *((CARD32 *)buffer); break;
+ }
+ if ((*glyphs = FindGlyph (glyphSet, glyph)))
+ {
+ lists->len++;
+ glyphs++;
+ }
+ }
+ buffer += size;
+ }
+ space = size * elt->len;
+ if (space & 3)
+ buffer += 4 - (space & 3);
+ lists++;
+ }
+ }
+ if (buffer > end)
+ return BadLength;
+
+ CompositeGlyphs (stuff->op,
+ pSrc,
+ pDst,
+ pFormat,
+ stuff->xSrc,
+ stuff->ySrc,
+ nlist,
+ listsBase,
+ glyphsBase);
+
+ if (glyphsBase != glyphsLocal)
+ DEALLOCATE_LOCAL (glyphsBase);
+ if (listsBase != listsLocal)
+ DEALLOCATE_LOCAL (listsBase);
+
+ return client->noClientException;
+}
+
+static int
+ProcRenderFillRectangles (ClientPtr client)
+{
+ PicturePtr pDst;
+ int things;
+ REQUEST(xRenderFillRectanglesReq);
+
+ REQUEST_AT_LEAST_SIZE (xRenderFillRectanglesReq);
+ if (!PictOpValid (stuff->op))
+ {
+ client->errorValue = stuff->op;
+ return BadValue;
+ }
+ VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+ if (!pDst->pDrawable)
+ return BadDrawable;
+
+ things = (client->req_len << 2) - sizeof(xRenderFillRectanglesReq);
+ if (things & 4)
+ return(BadLength);
+ things >>= 3;
+
+ CompositeRects (stuff->op,
+ pDst,
+ &stuff->color,
+ things,
+ (xRectangle *) &stuff[1]);
+
+ return client->noClientException;
+}
+
+static void
+SetBit (unsigned char *line, int x, int bit)
+{
+ unsigned char mask;
+
+ if (screenInfo.bitmapBitOrder == LSBFirst)
+ mask = (1 << (x & 7));
+ else
+ mask = (0x80 >> (x & 7));
+ /* XXX assumes byte order is host byte order */
+ line += (x >> 3);
+ if (bit)
+ *line |= mask;
+ else
+ *line &= ~mask;
+}
+
+#define DITHER_DIM 2
+
+static CARD32 orderedDither[DITHER_DIM][DITHER_DIM] = {
+ { 1, 3, },
+ { 4, 2, },
+};
+
+#define DITHER_SIZE ((sizeof orderedDither / sizeof orderedDither[0][0]) + 1)
+
+static int
+ProcRenderCreateCursor (ClientPtr client)
+{
+ REQUEST(xRenderCreateCursorReq);
+ PicturePtr pSrc;
+ ScreenPtr pScreen;
+ unsigned short width, height;
+ CARD32 *argbbits, *argb;
+ unsigned char *srcbits, *srcline;
+ unsigned char *mskbits, *mskline;
+ int stride;
+ int x, y;
+ int nbytes_mono;
+ CursorMetricRec cm;
+ CursorPtr pCursor;
+ CARD32 twocolor[3];
+ int ncolor;
+
+ REQUEST_SIZE_MATCH (xRenderCreateCursorReq);
+ LEGAL_NEW_RESOURCE(stuff->cid, client);
+
+ VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess,
+ RenderErrBase + BadPicture);
+ if (!pSrc->pDrawable)
+ return BadDrawable;
+ pScreen = pSrc->pDrawable->pScreen;
+ width = pSrc->pDrawable->width;
+ height = pSrc->pDrawable->height;
+ if ( stuff->x > width
+ || stuff->y > height )
+ return (BadMatch);
+ argbbits = xalloc (width * height * sizeof (CARD32));
+ if (!argbbits)
+ return (BadAlloc);
+
+ stride = BitmapBytePad(width);
+ nbytes_mono = stride*height;
+ srcbits = (unsigned char *)xalloc(nbytes_mono);
+ if (!srcbits)
+ {
+ xfree (argbbits);
+ return (BadAlloc);
+ }
+ mskbits = (unsigned char *)xalloc(nbytes_mono);
+ if (!mskbits)
+ {
+ xfree(argbbits);
+ xfree(srcbits);
+ return (BadAlloc);
+ }
+ bzero ((char *) mskbits, nbytes_mono);
+ bzero ((char *) srcbits, nbytes_mono);
+
+ if (pSrc->format == PICT_a8r8g8b8)
+ {
+ (*pScreen->GetImage) (pSrc->pDrawable,
+ 0, 0, width, height, ZPixmap,
+ 0xffffffff, (pointer) argbbits);
+ }
+ else
+ {
+ PixmapPtr pPixmap;
+ PicturePtr pPicture;
+ PictFormatPtr pFormat;
+ int error;
+
+ pFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
+ if (!pFormat)
+ {
+ xfree (argbbits);
+ xfree (srcbits);
+ xfree (mskbits);
+ return (BadImplementation);
+ }
+ pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, 32);
+ if (!pPixmap)
+ {
+ xfree (argbbits);
+ xfree (srcbits);
+ xfree (mskbits);
+ return (BadAlloc);
+ }
+ pPicture = CreatePicture (0, &pPixmap->drawable, pFormat, 0, 0,
+ client, &error);
+ if (!pPicture)
+ {
+ xfree (argbbits);
+ xfree (srcbits);
+ xfree (mskbits);
+ return error;
+ }
+ (*pScreen->DestroyPixmap) (pPixmap);
+ CompositePicture (PictOpSrc,
+ pSrc, 0, pPicture,
+ 0, 0, 0, 0, 0, 0, width, height);
+ (*pScreen->GetImage) (pPicture->pDrawable,
+ 0, 0, width, height, ZPixmap,
+ 0xffffffff, (pointer) argbbits);
+ FreePicture (pPicture, 0);
+ }
+ /*
+ * Check whether the cursor can be directly supported by
+ * the core cursor code
+ */
+ ncolor = 0;
+ argb = argbbits;
+ for (y = 0; ncolor <= 2 && y < height; y++)
+ {
+ for (x = 0; ncolor <= 2 && x < width; x++)
+ {
+ CARD32 p = *argb++;
+ CARD32 a = (p >> 24);
+
+ if (a == 0) /* transparent */
+ continue;
+ if (a == 0xff) /* opaque */
+ {
+ int n;
+ for (n = 0; n < ncolor; n++)
+ if (p == twocolor[n])
+ break;
+ if (n == ncolor)
+ twocolor[ncolor++] = p;
+ }
+ else
+ ncolor = 3;
+ }
+ }
+
+ /*
+ * Convert argb image to two plane cursor
+ */
+ srcline = srcbits;
+ mskline = mskbits;
+ argb = argbbits;
+ for (y = 0; y < height; y++)
+ {
+ for (x = 0; x < width; x++)
+ {
+ CARD32 p = *argb++;
+
+ if (ncolor <= 2)
+ {
+ CARD32 a = ((p >> 24));
+
+ SetBit (mskline, x, a != 0);
+ SetBit (srcline, x, a != 0 && p == twocolor[0]);
+ }
+ else
+ {
+ CARD32 a = ((p >> 24) * DITHER_SIZE + 127) / 255;
+ CARD32 i = ((CvtR8G8B8toY15(p) >> 7) * DITHER_SIZE + 127) / 255;
+ CARD32 d = orderedDither[y&(DITHER_DIM-1)][x&(DITHER_DIM-1)];
+ /* Set mask from dithered alpha value */
+ SetBit(mskline, x, a > d);
+ /* Set src from dithered intensity value */
+ SetBit(srcline, x, a > d && i <= d);
+ }
+ }
+ srcline += stride;
+ mskline += stride;
+ }
+ /*
+ * Dither to white and black if the cursor has more than two colors
+ */
+ if (ncolor > 2)
+ {
+ twocolor[0] = 0xff000000;
+ twocolor[1] = 0xffffffff;
+ }
+ else
+ {
+ xfree (argbbits);
+ argbbits = 0;
+ }
+
+#define GetByte(p,s) (((p) >> (s)) & 0xff)
+#define GetColor(p,s) (GetByte(p,s) | (GetByte(p,s) << 8))
+
+ cm.width = width;
+ cm.height = height;
+ cm.xhot = stuff->x;
+ cm.yhot = stuff->y;
+ pCursor = AllocCursorARGB (srcbits, mskbits, argbbits, &cm,
+ GetColor(twocolor[0], 16),
+ GetColor(twocolor[0], 8),
+ GetColor(twocolor[0], 0),
+ GetColor(twocolor[1], 16),
+ GetColor(twocolor[1], 8),
+ GetColor(twocolor[1], 0));
+ if (pCursor && AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
+ return (client->noClientException);
+ return BadAlloc;
+}
+
+static int
+ProcRenderSetPictureTransform (ClientPtr client)
+{
+ REQUEST(xRenderSetPictureTransformReq);
+ PicturePtr pPicture;
+ int result;
+
+ REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq);
+ VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+ result = SetPictureTransform (pPicture, (PictTransform *) &stuff->transform);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return(result);
+}
+
+static int
+ProcRenderQueryFilters (ClientPtr client)
+{
+ REQUEST (xRenderQueryFiltersReq);
+ DrawablePtr pDrawable;
+ xRenderQueryFiltersReply *reply;
+ int nbytesName;
+ int nnames;
+ ScreenPtr pScreen;
+ PictureScreenPtr ps;
+ int i, j;
+ int len;
+ int total_bytes;
+ INT16 *aliases;
+ char *names;
+
+ REQUEST_SIZE_MATCH(xRenderQueryFiltersReq);
+ SECURITY_VERIFY_DRAWABLE(pDrawable, stuff->drawable, client, SecurityReadAccess);
+
+ pScreen = pDrawable->pScreen;
+ nbytesName = 0;
+ nnames = 0;
+ ps = GetPictureScreenIfSet(pScreen);
+ if (ps)
+ {
+ for (i = 0; i < ps->nfilters; i++)
+ nbytesName += 1 + strlen (ps->filters[i].name);
+ for (i = 0; i < ps->nfilterAliases; i++)
+ nbytesName += 1 + strlen (ps->filterAliases[i].alias);
+ nnames = ps->nfilters + ps->nfilterAliases;
+ }
+ len = ((nnames + 1) >> 1) + ((nbytesName + 3) >> 2);
+ total_bytes = sizeof (xRenderQueryFiltersReply) + (len << 2);
+ reply = (xRenderQueryFiltersReply *) xalloc (total_bytes);
+ if (!reply)
+ return BadAlloc;
+ aliases = (INT16 *) (reply + 1);
+ names = (char *) (aliases + ((nnames + 1) & ~1));
+
+ reply->type = X_Reply;
+ reply->sequenceNumber = client->sequence;
+ reply->length = len;
+ reply->numAliases = nnames;
+ reply->numFilters = nnames;
+ if (ps)
+ {
+
+ /* fill in alias values */
+ for (i = 0; i < ps->nfilters; i++)
+ aliases[i] = FilterAliasNone;
+ for (i = 0; i < ps->nfilterAliases; i++)
+ {
+ for (j = 0; j < ps->nfilters; j++)
+ if (ps->filterAliases[i].filter_id == ps->filters[j].id)
+ break;
+ if (j == ps->nfilters)
+ {
+ for (j = 0; j < ps->nfilterAliases; j++)
+ if (ps->filterAliases[i].filter_id ==
+ ps->filterAliases[j].alias_id)
+ {
+ break;
+ }
+ if (j == ps->nfilterAliases)
+ j = FilterAliasNone;
+ else
+ j = j + ps->nfilters;
+ }
+ aliases[i + ps->nfilters] = j;
+ }
+
+ /* fill in filter names */
+ for (i = 0; i < ps->nfilters; i++)
+ {
+ j = strlen (ps->filters[i].name);
+ *names++ = j;
+ strncpy (names, ps->filters[i].name, j);
+ names += j;
+ }
+
+ /* fill in filter alias names */
+ for (i = 0; i < ps->nfilterAliases; i++)
+ {
+ j = strlen (ps->filterAliases[i].alias);
+ *names++ = j;
+ strncpy (names, ps->filterAliases[i].alias, j);
+ names += j;
+ }
+ }
+
+ if (client->swapped)
+ {
+ register int n;
+
+ for (i = 0; i < reply->numAliases; i++)
+ {
+ swaps (&aliases[i], n);
+ }
+ swaps(&reply->sequenceNumber, n);
+ swapl(&reply->length, n);
+ swapl(&reply->numAliases, n);
+ swapl(&reply->numFilters, n);
+ }
+ WriteToClient(client, total_bytes, (char *) reply);
+ xfree (reply);
+
+ return(client->noClientException);
+}
+
+static int
+ProcRenderSetPictureFilter (ClientPtr client)
+{
+ REQUEST (xRenderSetPictureFilterReq);
+ PicturePtr pPicture;
+ int result;
+ xFixed *params;
+ int nparams;
+ char *name;
+
+ REQUEST_AT_LEAST_SIZE (xRenderSetPictureFilterReq);
+ VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+ name = (char *) (stuff + 1);
+ params = (xFixed *) (name + ((stuff->nbytes + 3) & ~3));
+ nparams = ((xFixed *) stuff + client->req_len) - params;
+ result = SetPictureFilter (pPicture, name, stuff->nbytes, params, nparams);
+ return result;
+}
+
+static int
+ProcRenderCreateAnimCursor (ClientPtr client)
+{
+ REQUEST(xRenderCreateAnimCursorReq);
+ CursorPtr *cursors;
+ CARD32 *deltas;
+ CursorPtr pCursor;
+ int ncursor;
+ xAnimCursorElt *elt;
+ int i;
+ int ret;
+
+ REQUEST_AT_LEAST_SIZE(xRenderCreateAnimCursorReq);
+ LEGAL_NEW_RESOURCE(stuff->cid, client);
+ if (client->req_len & 1)
+ return BadLength;
+ ncursor = (client->req_len - (SIZEOF(xRenderCreateAnimCursorReq) >> 2)) >> 1;
+ cursors = xalloc (ncursor * (sizeof (CursorPtr) + sizeof (CARD32)));
+ if (!cursors)
+ return BadAlloc;
+ deltas = (CARD32 *) (cursors + ncursor);
+ elt = (xAnimCursorElt *) (stuff + 1);
+ for (i = 0; i < ncursor; i++)
+ {
+ cursors[i] = (CursorPtr)SecurityLookupIDByType(client, elt->cursor,
+ RT_CURSOR, SecurityReadAccess);
+ if (!cursors[i])
+ {
+ xfree (cursors);
+ client->errorValue = elt->cursor;
+ return BadCursor;
+ }
+ deltas[i] = elt->delay;
+ elt++;
+ }
+ ret = AnimCursorCreate (cursors, deltas, ncursor, &pCursor);
+ xfree (cursors);
+ if (ret != Success)
+ return ret;
+
+ if (AddResource (stuff->cid, RT_CURSOR, (pointer)pCursor))
+ return client->noClientException;
+ return BadAlloc;
+}
+
+static int
+ProcRenderAddTraps (ClientPtr client)
+{
+ int ntraps;
+ PicturePtr pPicture;
+ REQUEST(xRenderAddTrapsReq);
+
+ REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq);
+ VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+ if (!pPicture->pDrawable)
+ return BadDrawable;
+ ntraps = (client->req_len << 2) - sizeof (xRenderAddTrapsReq);
+ if (ntraps % sizeof (xTrap))
+ return BadLength;
+ ntraps /= sizeof (xTrap);
+ if (ntraps)
+ AddTraps (pPicture,
+ stuff->xOff, stuff->yOff,
+ ntraps, (xTrap *) &stuff[1]);
+ return client->noClientException;
+}
+
+static int ProcRenderCreateSolidFill(ClientPtr client)
+{
+ PicturePtr pPicture;
+ int error = 0;
+ REQUEST(xRenderCreateSolidFillReq);
+
+ REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq);
+
+ LEGAL_NEW_RESOURCE(stuff->pid, client);
+
+ pPicture = CreateSolidPicture(stuff->pid, &stuff->color, &error);
+ if (!pPicture)
+ return error;
+ if (!AddResource (stuff->pid, PictureType, (pointer)pPicture))
+ return BadAlloc;
+ return Success;
+}
+
+static int ProcRenderCreateLinearGradient (ClientPtr client)
+{
+ PicturePtr pPicture;
+ int len;
+ int error = 0;
+ xFixed *stops;
+ xRenderColor *colors;
+ REQUEST(xRenderCreateLinearGradientReq);
+
+ REQUEST_AT_LEAST_SIZE(xRenderCreateLinearGradientReq);
+
+ LEGAL_NEW_RESOURCE(stuff->pid, client);
+
+ len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq);
+ if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
+ return BadLength;
+
+ stops = (xFixed *)(stuff + 1);
+ colors = (xRenderColor *)(stops + stuff->nStops);
+
+ pPicture = CreateLinearGradientPicture (stuff->pid, &stuff->p1, &stuff->p2,
+ stuff->nStops, stops, colors, &error);
+ if (!pPicture)
+ return error;
+ if (!AddResource (stuff->pid, PictureType, (pointer)pPicture))
+ return BadAlloc;
+ return Success;
+}
+
+static int ProcRenderCreateRadialGradient (ClientPtr client)
+{
+ PicturePtr pPicture;
+ int len;
+ int error = 0;
+ xFixed *stops;
+ xRenderColor *colors;
+ REQUEST(xRenderCreateRadialGradientReq);
+
+ REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq);
+
+ LEGAL_NEW_RESOURCE(stuff->pid, client);
+
+ len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq);
+ if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
+ return BadLength;
+
+ stops = (xFixed *)(stuff + 1);
+ colors = (xRenderColor *)(stops + stuff->nStops);
+
+ pPicture = CreateRadialGradientPicture (stuff->pid, &stuff->inner, &stuff->outer,
+ stuff->inner_radius, stuff->outer_radius,
+ stuff->nStops, stops, colors, &error);
+ if (!pPicture)
+ return error;
+ if (!AddResource (stuff->pid, PictureType, (pointer)pPicture))
+ return BadAlloc;
+ return Success;
+}
+
+static int ProcRenderCreateConicalGradient (ClientPtr client)
+{
+ PicturePtr pPicture;
+ int len;
+ int error = 0;
+ xFixed *stops;
+ xRenderColor *colors;
+ REQUEST(xRenderCreateConicalGradientReq);
+
+ REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq);
+
+ LEGAL_NEW_RESOURCE(stuff->pid, client);
+
+ len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq);
+ if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
+ return BadLength;
+
+ stops = (xFixed *)(stuff + 1);
+ colors = (xRenderColor *)(stops + stuff->nStops);
+
+ pPicture = CreateConicalGradientPicture (stuff->pid, &stuff->center, stuff->angle,
+ stuff->nStops, stops, colors, &error);
+ if (!pPicture)
+ return error;
+ if (!AddResource (stuff->pid, PictureType, (pointer)pPicture))
+ return BadAlloc;
+ return Success;
+}
+
+
+static int
+ProcRenderDispatch (ClientPtr client)
+{
+ REQUEST(xReq);
+
+ if (stuff->data < RenderNumberRequests)
+ return (*ProcRenderVector[stuff->data]) (client);
+ else
+ return BadRequest;
+}
+
+static int
+SProcRenderQueryVersion (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderQueryVersionReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->majorVersion, n);
+ swapl(&stuff->minorVersion, n);
+ return (*ProcRenderVector[stuff->renderReqType])(client);
+}
+
+static int
+SProcRenderQueryPictFormats (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderQueryPictFormatsReq);
+ swaps(&stuff->length, n);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderQueryPictIndexValues (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderQueryPictIndexValuesReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->format, n);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderQueryDithers (ClientPtr client)
+{
+ return BadImplementation;
+}
+
+static int
+SProcRenderCreatePicture (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderCreatePictureReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->pid, n);
+ swapl(&stuff->drawable, n);
+ swapl(&stuff->format, n);
+ swapl(&stuff->mask, n);
+ SwapRestL(stuff);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderChangePicture (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderChangePictureReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->picture, n);
+ swapl(&stuff->mask, n);
+ SwapRestL(stuff);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderSetPictureClipRectangles (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderSetPictureClipRectanglesReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->picture, n);
+ SwapRestS(stuff);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderFreePicture (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderFreePictureReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->picture, n);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderComposite (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderCompositeReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->src, n);
+ swapl(&stuff->mask, n);
+ swapl(&stuff->dst, n);
+ swaps(&stuff->xSrc, n);
+ swaps(&stuff->ySrc, n);
+ swaps(&stuff->xMask, n);
+ swaps(&stuff->yMask, n);
+ swaps(&stuff->xDst, n);
+ swaps(&stuff->yDst, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderScale (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderScaleReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->src, n);
+ swapl(&stuff->dst, n);
+ swapl(&stuff->colorScale, n);
+ swapl(&stuff->alphaScale, n);
+ swaps(&stuff->xSrc, n);
+ swaps(&stuff->ySrc, n);
+ swaps(&stuff->xDst, n);
+ swaps(&stuff->yDst, n);
+ swaps(&stuff->width, n);
+ swaps(&stuff->height, n);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderTrapezoids (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderTrapezoidsReq);
+
+ REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq);
+ swaps (&stuff->length, n);
+ swapl (&stuff->src, n);
+ swapl (&stuff->dst, n);
+ swapl (&stuff->maskFormat, n);
+ swaps (&stuff->xSrc, n);
+ swaps (&stuff->ySrc, n);
+ SwapRestL(stuff);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderTriangles (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderTrianglesReq);
+
+ REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq);
+ swaps (&stuff->length, n);
+ swapl (&stuff->src, n);
+ swapl (&stuff->dst, n);
+ swapl (&stuff->maskFormat, n);
+ swaps (&stuff->xSrc, n);
+ swaps (&stuff->ySrc, n);
+ SwapRestL(stuff);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderTriStrip (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderTriStripReq);
+
+ REQUEST_AT_LEAST_SIZE(xRenderTriStripReq);
+ swaps (&stuff->length, n);
+ swapl (&stuff->src, n);
+ swapl (&stuff->dst, n);
+ swapl (&stuff->maskFormat, n);
+ swaps (&stuff->xSrc, n);
+ swaps (&stuff->ySrc, n);
+ SwapRestL(stuff);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderTriFan (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderTriFanReq);
+
+ REQUEST_AT_LEAST_SIZE(xRenderTriFanReq);
+ swaps (&stuff->length, n);
+ swapl (&stuff->src, n);
+ swapl (&stuff->dst, n);
+ swapl (&stuff->maskFormat, n);
+ swaps (&stuff->xSrc, n);
+ swaps (&stuff->ySrc, n);
+ SwapRestL(stuff);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderColorTrapezoids (ClientPtr client)
+{
+ return BadImplementation;
+}
+
+static int
+SProcRenderColorTriangles (ClientPtr client)
+{
+ return BadImplementation;
+}
+
+static int
+SProcRenderTransform (ClientPtr client)
+{
+ return BadImplementation;
+}
+
+static int
+SProcRenderCreateGlyphSet (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderCreateGlyphSetReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->gsid, n);
+ swapl(&stuff->format, n);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderReferenceGlyphSet (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderReferenceGlyphSetReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->gsid, n);
+ swapl(&stuff->existing, n);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderFreeGlyphSet (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderFreeGlyphSetReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->glyphset, n);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderAddGlyphs (ClientPtr client)
+{
+ register int n;
+ register int i;
+ CARD32 *gids;
+ void *end;
+ xGlyphInfo *gi;
+ REQUEST(xRenderAddGlyphsReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->glyphset, n);
+ swapl(&stuff->nglyphs, n);
+ if (stuff->nglyphs & 0xe0000000)
+ return BadLength;
+ end = (CARD8 *) stuff + (client->req_len << 2);
+ gids = (CARD32 *) (stuff + 1);
+ gi = (xGlyphInfo *) (gids + stuff->nglyphs);
+ if ((char *) end - (char *) (gids + stuff->nglyphs) < 0)
+ return BadLength;
+ if ((char *) end - (char *) (gi + stuff->nglyphs) < 0)
+ return BadLength;
+ for (i = 0; i < stuff->nglyphs; i++)
+ {
+ swapl (&gids[i], n);
+ swaps (&gi[i].width, n);
+ swaps (&gi[i].height, n);
+ swaps (&gi[i].x, n);
+ swaps (&gi[i].y, n);
+ swaps (&gi[i].xOff, n);
+ swaps (&gi[i].yOff, n);
+ }
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderAddGlyphsFromPicture (ClientPtr client)
+{
+ return BadImplementation;
+}
+
+static int
+SProcRenderFreeGlyphs (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderFreeGlyphsReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->glyphset, n);
+ SwapRestL(stuff);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderCompositeGlyphs (ClientPtr client)
+{
+ register int n;
+ xGlyphElt *elt;
+ CARD8 *buffer;
+ CARD8 *end;
+ int space;
+ int i;
+ int size;
+
+ REQUEST(xRenderCompositeGlyphsReq);
+
+ switch (stuff->renderReqType) {
+ default: size = 1; break;
+ case X_RenderCompositeGlyphs16: size = 2; break;
+ case X_RenderCompositeGlyphs32: size = 4; break;
+ }
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->src, n);
+ swapl(&stuff->dst, n);
+ swapl(&stuff->maskFormat, n);
+ swapl(&stuff->glyphset, n);
+ swaps(&stuff->xSrc, n);
+ swaps(&stuff->ySrc, n);
+ buffer = (CARD8 *) (stuff + 1);
+ end = (CARD8 *) stuff + (client->req_len << 2);
+ while (buffer + sizeof (xGlyphElt) < end)
+ {
+ elt = (xGlyphElt *) buffer;
+ buffer += sizeof (xGlyphElt);
+
+ swaps (&elt->deltax, n);
+ swaps (&elt->deltay, n);
+
+ i = elt->len;
+ if (i == 0xff)
+ {
+ swapl (buffer, n);
+ buffer += 4;
+ }
+ else
+ {
+ space = size * i;
+ switch (size) {
+ case 1:
+ buffer += i;
+ break;
+ case 2:
+ while (i--)
+ {
+ swaps (buffer, n);
+ buffer += 2;
+ }
+ break;
+ case 4:
+ while (i--)
+ {
+ swapl (buffer, n);
+ buffer += 4;
+ }
+ break;
+ }
+ if (space & 3)
+ buffer += 4 - (space & 3);
+ }
+ }
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderFillRectangles (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderFillRectanglesReq);
+
+ REQUEST_AT_LEAST_SIZE (xRenderFillRectanglesReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->dst, n);
+ swaps(&stuff->color.red, n);
+ swaps(&stuff->color.green, n);
+ swaps(&stuff->color.blue, n);
+ swaps(&stuff->color.alpha, n);
+ SwapRestS(stuff);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderCreateCursor (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderCreateCursorReq);
+ REQUEST_SIZE_MATCH (xRenderCreateCursorReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->cid, n);
+ swapl(&stuff->src, n);
+ swaps(&stuff->x, n);
+ swaps(&stuff->y, n);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderSetPictureTransform (ClientPtr client)
+{
+ register int n;
+ REQUEST(xRenderSetPictureTransformReq);
+ REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->picture, n);
+ swapl(&stuff->transform.matrix11, n);
+ swapl(&stuff->transform.matrix12, n);
+ swapl(&stuff->transform.matrix13, n);
+ swapl(&stuff->transform.matrix21, n);
+ swapl(&stuff->transform.matrix22, n);
+ swapl(&stuff->transform.matrix23, n);
+ swapl(&stuff->transform.matrix31, n);
+ swapl(&stuff->transform.matrix32, n);
+ swapl(&stuff->transform.matrix33, n);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderQueryFilters (ClientPtr client)
+{
+ register int n;
+ REQUEST (xRenderQueryFiltersReq);
+ REQUEST_SIZE_MATCH (xRenderQueryFiltersReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->drawable, n);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderSetPictureFilter (ClientPtr client)
+{
+ register int n;
+ REQUEST (xRenderSetPictureFilterReq);
+ REQUEST_AT_LEAST_SIZE (xRenderSetPictureFilterReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->picture, n);
+ swaps(&stuff->nbytes, n);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderCreateAnimCursor (ClientPtr client)
+{
+ register int n;
+ REQUEST (xRenderCreateAnimCursorReq);
+ REQUEST_AT_LEAST_SIZE (xRenderCreateAnimCursorReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->cid, n);
+ SwapRestL(stuff);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderAddTraps (ClientPtr client)
+{
+ register int n;
+ REQUEST (xRenderAddTrapsReq);
+ REQUEST_AT_LEAST_SIZE (xRenderAddTrapsReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->picture, n);
+ swaps(&stuff->xOff, n);
+ swaps(&stuff->yOff, n);
+ SwapRestL(stuff);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderCreateSolidFill(ClientPtr client)
+{
+ register int n;
+ REQUEST (xRenderCreateSolidFillReq);
+ REQUEST_AT_LEAST_SIZE (xRenderCreateSolidFillReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->pid, n);
+ swaps(&stuff->color.alpha, n);
+ swaps(&stuff->color.red, n);
+ swaps(&stuff->color.green, n);
+ swaps(&stuff->color.blue, n);
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static void swapStops(void *stuff, int n)
+{
+ int i;
+ CARD32 *stops;
+ CARD16 *colors;
+ stops = (CARD32 *)(stuff);
+ for (i = 0; i < n; ++i) {
+ swapl(stops, n);
+ ++stops;
+ }
+ colors = (CARD16 *)(stops);
+ for (i = 0; i < 4*n; ++i) {
+ swaps(stops, n);
+ ++stops;
+ }
+}
+
+static int
+SProcRenderCreateLinearGradient (ClientPtr client)
+{
+ register int n;
+ int len;
+ REQUEST (xRenderCreateLinearGradientReq);
+ REQUEST_AT_LEAST_SIZE (xRenderCreateLinearGradientReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->pid, n);
+ swapl(&stuff->p1.x, n);
+ swapl(&stuff->p1.y, n);
+ swapl(&stuff->p2.x, n);
+ swapl(&stuff->p2.y, n);
+ swapl(&stuff->nStops, n);
+
+ len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq);
+ if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
+ return BadLength;
+
+ swapStops(stuff+1, stuff->nStops);
+
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderCreateRadialGradient (ClientPtr client)
+{
+ register int n;
+ int len;
+ REQUEST (xRenderCreateRadialGradientReq);
+ REQUEST_AT_LEAST_SIZE (xRenderCreateRadialGradientReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->pid, n);
+ swapl(&stuff->inner.x, n);
+ swapl(&stuff->inner.y, n);
+ swapl(&stuff->outer.x, n);
+ swapl(&stuff->outer.y, n);
+ swapl(&stuff->inner_radius, n);
+ swapl(&stuff->outer_radius, n);
+ swapl(&stuff->nStops, n);
+
+ len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq);
+ if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
+ return BadLength;
+
+ swapStops(stuff+1, stuff->nStops);
+
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderCreateConicalGradient (ClientPtr client)
+{
+ register int n;
+ int len;
+ REQUEST (xRenderCreateConicalGradientReq);
+ REQUEST_AT_LEAST_SIZE (xRenderCreateConicalGradientReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->pid, n);
+ swapl(&stuff->center.x, n);
+ swapl(&stuff->center.y, n);
+ swapl(&stuff->angle, n);
+ swapl(&stuff->nStops, n);
+
+ len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq);
+ if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
+ return BadLength;
+
+ swapStops(stuff+1, stuff->nStops);
+
+ return (*ProcRenderVector[stuff->renderReqType]) (client);
+}
+
+static int
+SProcRenderDispatch (ClientPtr client)
+{
+ REQUEST(xReq);
+
+ if (stuff->data < RenderNumberRequests)
+ return (*SProcRenderVector[stuff->data]) (client);
+ else
+ return BadRequest;
+}
+
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+
+#define VERIFY_XIN_PICTURE(pPicture, pid, client, mode, err) {\
+ pPicture = SecurityLookupIDByType(client, pid, XRT_PICTURE, mode);\
+ if (!pPicture) { \
+ client->errorValue = pid; \
+ return err; \
+ } \
+}
+
+#define VERIFY_XIN_ALPHA(pPicture, pid, client, mode, err) {\
+ if (pid == None) \
+ pPicture = 0; \
+ else { \
+ VERIFY_XIN_PICTURE(pPicture, pid, client, mode, err); \
+ } \
+} \
+
+int (*PanoramiXSaveRenderVector[RenderNumberRequests])(ClientPtr);
+
+unsigned long XRT_PICTURE;
+
+static int
+PanoramiXRenderCreatePicture (ClientPtr client)
+{
+ REQUEST(xRenderCreatePictureReq);
+ PanoramiXRes *refDraw, *newPict;
+ int result = Success, j;
+
+ REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq);
+ if(!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass(
+ client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
+ return BadDrawable;
+ if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
+ return BadAlloc;
+ newPict->type = XRT_PICTURE;
+ newPict->info[0].id = stuff->pid;
+
+ if (refDraw->type == XRT_WINDOW &&
+ stuff->drawable == WindowTable[0]->drawable.id)
+ {
+ newPict->u.pict.root = TRUE;
+ }
+ else
+ newPict->u.pict.root = FALSE;
+
+ for(j = 1; j < PanoramiXNumScreens; j++)
+ newPict->info[j].id = FakeClientID(client->index);
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->pid = newPict->info[j].id;
+ stuff->drawable = refDraw->info[j].id;
+ result = (*PanoramiXSaveRenderVector[X_RenderCreatePicture]) (client);
+ if(result != Success) break;
+ }
+
+ if (result == Success)
+ AddResource(newPict->info[0].id, XRT_PICTURE, newPict);
+ else
+ xfree(newPict);
+
+ return (result);
+}
+
+static int
+PanoramiXRenderChangePicture (ClientPtr client)
+{
+ PanoramiXRes *pict;
+ int result = Success, j;
+ REQUEST(xRenderChangePictureReq);
+
+ REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
+
+ VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->picture = pict->info[j].id;
+ result = (*PanoramiXSaveRenderVector[X_RenderChangePicture]) (client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+static int
+PanoramiXRenderSetPictureClipRectangles (ClientPtr client)
+{
+ REQUEST(xRenderSetPictureClipRectanglesReq);
+ int result = Success, j;
+ PanoramiXRes *pict;
+
+ REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq);
+
+ VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->picture = pict->info[j].id;
+ result = (*PanoramiXSaveRenderVector[X_RenderSetPictureClipRectangles]) (client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+static int
+PanoramiXRenderSetPictureTransform (ClientPtr client)
+{
+ REQUEST(xRenderSetPictureTransformReq);
+ int result = Success, j;
+ PanoramiXRes *pict;
+
+ REQUEST_AT_LEAST_SIZE(xRenderSetPictureTransformReq);
+
+ VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->picture = pict->info[j].id;
+ result = (*PanoramiXSaveRenderVector[X_RenderSetPictureTransform]) (client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+static int
+PanoramiXRenderSetPictureFilter (ClientPtr client)
+{
+ REQUEST(xRenderSetPictureFilterReq);
+ int result = Success, j;
+ PanoramiXRes *pict;
+
+ REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq);
+
+ VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->picture = pict->info[j].id;
+ result = (*PanoramiXSaveRenderVector[X_RenderSetPictureFilter]) (client);
+ if(result != Success) break;
+ }
+
+ return (result);
+}
+
+static int
+PanoramiXRenderFreePicture (ClientPtr client)
+{
+ PanoramiXRes *pict;
+ int result = Success, j;
+ REQUEST(xRenderFreePictureReq);
+
+ REQUEST_SIZE_MATCH(xRenderFreePictureReq);
+
+ client->errorValue = stuff->picture;
+
+ VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityDestroyAccess,
+ RenderErrBase + BadPicture);
+
+
+ FOR_NSCREENS_BACKWARD(j) {
+ stuff->picture = pict->info[j].id;
+ result = (*PanoramiXSaveRenderVector[X_RenderFreePicture]) (client);
+ if(result != Success) break;
+ }
+
+ /* Since ProcRenderFreePicture is using FreeResource, it will free
+ our resource for us on the last pass through the loop above */
+
+ return (result);
+}
+
+static int
+PanoramiXRenderComposite (ClientPtr client)
+{
+ PanoramiXRes *src, *msk, *dst;
+ int result = Success, j;
+ xRenderCompositeReq orig;
+ REQUEST(xRenderCompositeReq);
+
+ REQUEST_SIZE_MATCH(xRenderCompositeReq);
+
+ VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess,
+ RenderErrBase + BadPicture);
+ VERIFY_XIN_ALPHA (msk, stuff->mask, client, SecurityReadAccess,
+ RenderErrBase + BadPicture);
+ VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+
+ orig = *stuff;
+
+ FOR_NSCREENS_FORWARD(j) {
+ stuff->src = src->info[j].id;
+ if (src->u.pict.root)
+ {
+ stuff->xSrc = orig.xSrc - panoramiXdataPtr[j].x;
+ stuff->ySrc = orig.ySrc - panoramiXdataPtr[j].y;
+ }
+ stuff->dst = dst->info[j].id;
+ if (dst->u.pict.root)
+ {
+ stuff->xDst = orig.xDst - panoramiXdataPtr[j].x;
+ stuff->yDst = orig.yDst - panoramiXdataPtr[j].y;
+ }
+ if (msk)
+ {
+ stuff->mask = msk->info[j].id;
+ if (msk->u.pict.root)
+ {
+ stuff->xMask = orig.xMask - panoramiXdataPtr[j].x;
+ stuff->yMask = orig.yMask - panoramiXdataPtr[j].y;
+ }
+ }
+ result = (*PanoramiXSaveRenderVector[X_RenderComposite]) (client);
+ if(result != Success) break;
+ }
+
+ return result;
+}
+
+static int
+PanoramiXRenderCompositeGlyphs (ClientPtr client)
+{
+ PanoramiXRes *src, *dst;
+ int result = Success, j;
+ REQUEST(xRenderCompositeGlyphsReq);
+ xGlyphElt origElt, *elt;
+ INT16 xSrc, ySrc;
+
+ REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq);
+ VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess,
+ RenderErrBase + BadPicture);
+ VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+
+ if (client->req_len << 2 >= (sizeof (xRenderCompositeGlyphsReq) +
+ sizeof (xGlyphElt)))
+ {
+ elt = (xGlyphElt *) (stuff + 1);
+ origElt = *elt;
+ xSrc = stuff->xSrc;
+ ySrc = stuff->ySrc;
+ FOR_NSCREENS_FORWARD(j) {
+ stuff->src = src->info[j].id;
+ if (src->u.pict.root)
+ {
+ stuff->xSrc = xSrc - panoramiXdataPtr[j].x;
+ stuff->ySrc = ySrc - panoramiXdataPtr[j].y;
+ }
+ stuff->dst = dst->info[j].id;
+ if (dst->u.pict.root)
+ {
+ elt->deltax = origElt.deltax - panoramiXdataPtr[j].x;
+ elt->deltay = origElt.deltay - panoramiXdataPtr[j].y;
+ }
+ result = (*PanoramiXSaveRenderVector[stuff->renderReqType]) (client);
+ if(result != Success) break;
+ }
+ }
+
+ return result;
+}
+
+static int
+PanoramiXRenderFillRectangles (ClientPtr client)
+{
+ PanoramiXRes *dst;
+ int result = Success, j;
+ REQUEST(xRenderFillRectanglesReq);
+ char *extra;
+ int extra_len;
+
+ REQUEST_AT_LEAST_SIZE (xRenderFillRectanglesReq);
+ VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+ extra_len = (client->req_len << 2) - sizeof (xRenderFillRectanglesReq);
+ if (extra_len &&
+ (extra = (char *) ALLOCATE_LOCAL (extra_len)))
+ {
+ memcpy (extra, stuff + 1, extra_len);
+ FOR_NSCREENS_FORWARD(j) {
+ if (j) memcpy (stuff + 1, extra, extra_len);
+ if (dst->u.pict.root)
+ {
+ int x_off = panoramiXdataPtr[j].x;
+ int y_off = panoramiXdataPtr[j].y;
+
+ if(x_off || y_off) {
+ xRectangle *rects = (xRectangle *) (stuff + 1);
+ int i = extra_len / sizeof (xRectangle);
+
+ while (i--)
+ {
+ rects->x -= x_off;
+ rects->y -= y_off;
+ rects++;
+ }
+ }
+ }
+ stuff->dst = dst->info[j].id;
+ result = (*PanoramiXSaveRenderVector[X_RenderFillRectangles]) (client);
+ if(result != Success) break;
+ }
+ DEALLOCATE_LOCAL(extra);
+ }
+
+ return result;
+}
+
+static int
+PanoramiXRenderTrapezoids(ClientPtr client)
+{
+ PanoramiXRes *src, *dst;
+ int result = Success, j;
+ REQUEST(xRenderTrapezoidsReq);
+ char *extra;
+ int extra_len;
+
+ REQUEST_AT_LEAST_SIZE (xRenderTrapezoidsReq);
+
+ VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess,
+ RenderErrBase + BadPicture);
+ VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+
+ extra_len = (client->req_len << 2) - sizeof (xRenderTrapezoidsReq);
+
+ if (extra_len &&
+ (extra = (char *) ALLOCATE_LOCAL (extra_len))) {
+ memcpy (extra, stuff + 1, extra_len);
+
+ FOR_NSCREENS_FORWARD(j) {
+ if (j) memcpy (stuff + 1, extra, extra_len);
+ if (dst->u.pict.root) {
+ int x_off = panoramiXdataPtr[j].x;
+ int y_off = panoramiXdataPtr[j].y;
+
+ if(x_off || y_off) {
+ xTrapezoid *trap = (xTrapezoid *) (stuff + 1);
+ int i = extra_len / sizeof (xTrapezoid);
+
+ while (i--) {
+ trap->top -= y_off;
+ trap->bottom -= y_off;
+ trap->left.p1.x -= x_off;
+ trap->left.p1.y -= y_off;
+ trap->left.p2.x -= x_off;
+ trap->left.p2.y -= y_off;
+ trap->right.p1.x -= x_off;
+ trap->right.p1.y -= y_off;
+ trap->right.p2.x -= x_off;
+ trap->right.p2.y -= y_off;
+ trap++;
+ }
+ }
+ }
+
+ stuff->src = src->info[j].id;
+ stuff->dst = dst->info[j].id;
+ result =
+ (*PanoramiXSaveRenderVector[X_RenderTrapezoids]) (client);
+
+ if(result != Success) break;
+ }
+
+ DEALLOCATE_LOCAL(extra);
+ }
+
+ return result;
+}
+
+static int
+PanoramiXRenderTriangles(ClientPtr client)
+{
+ PanoramiXRes *src, *dst;
+ int result = Success, j;
+ REQUEST(xRenderTrianglesReq);
+ char *extra;
+ int extra_len;
+
+ REQUEST_AT_LEAST_SIZE (xRenderTrianglesReq);
+
+ VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess,
+ RenderErrBase + BadPicture);
+ VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+
+ extra_len = (client->req_len << 2) - sizeof (xRenderTrianglesReq);
+
+ if (extra_len &&
+ (extra = (char *) ALLOCATE_LOCAL (extra_len))) {
+ memcpy (extra, stuff + 1, extra_len);
+
+ FOR_NSCREENS_FORWARD(j) {
+ if (j) memcpy (stuff + 1, extra, extra_len);
+ if (dst->u.pict.root) {
+ int x_off = panoramiXdataPtr[j].x;
+ int y_off = panoramiXdataPtr[j].y;
+
+ if(x_off || y_off) {
+ xTriangle *tri = (xTriangle *) (stuff + 1);
+ int i = extra_len / sizeof (xTriangle);
+
+ while (i--) {
+ tri->p1.x -= x_off;
+ tri->p1.y -= y_off;
+ tri->p2.x -= x_off;
+ tri->p2.y -= y_off;
+ tri->p3.x -= x_off;
+ tri->p3.y -= y_off;
+ tri++;
+ }
+ }
+ }
+
+ stuff->src = src->info[j].id;
+ stuff->dst = dst->info[j].id;
+ result =
+ (*PanoramiXSaveRenderVector[X_RenderTriangles]) (client);
+
+ if(result != Success) break;
+ }
+
+ DEALLOCATE_LOCAL(extra);
+ }
+
+ return result;
+}
+
+static int
+PanoramiXRenderTriStrip(ClientPtr client)
+{
+ PanoramiXRes *src, *dst;
+ int result = Success, j;
+ REQUEST(xRenderTriStripReq);
+ char *extra;
+ int extra_len;
+
+ REQUEST_AT_LEAST_SIZE (xRenderTriStripReq);
+
+ VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess,
+ RenderErrBase + BadPicture);
+ VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+
+ extra_len = (client->req_len << 2) - sizeof (xRenderTriStripReq);
+
+ if (extra_len &&
+ (extra = (char *) ALLOCATE_LOCAL (extra_len))) {
+ memcpy (extra, stuff + 1, extra_len);
+
+ FOR_NSCREENS_FORWARD(j) {
+ if (j) memcpy (stuff + 1, extra, extra_len);
+ if (dst->u.pict.root) {
+ int x_off = panoramiXdataPtr[j].x;
+ int y_off = panoramiXdataPtr[j].y;
+
+ if(x_off || y_off) {
+ xPointFixed *fixed = (xPointFixed *) (stuff + 1);
+ int i = extra_len / sizeof (xPointFixed);
+
+ while (i--) {
+ fixed->x -= x_off;
+ fixed->y -= y_off;
+ fixed++;
+ }
+ }
+ }
+
+ stuff->src = src->info[j].id;
+ stuff->dst = dst->info[j].id;
+ result =
+ (*PanoramiXSaveRenderVector[X_RenderTriStrip]) (client);
+
+ if(result != Success) break;
+ }
+
+ DEALLOCATE_LOCAL(extra);
+ }
+
+ return result;
+}
+
+static int
+PanoramiXRenderTriFan(ClientPtr client)
+{
+ PanoramiXRes *src, *dst;
+ int result = Success, j;
+ REQUEST(xRenderTriFanReq);
+ char *extra;
+ int extra_len;
+
+ REQUEST_AT_LEAST_SIZE (xRenderTriFanReq);
+
+ VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess,
+ RenderErrBase + BadPicture);
+ VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+
+ extra_len = (client->req_len << 2) - sizeof (xRenderTriFanReq);
+
+ if (extra_len &&
+ (extra = (char *) ALLOCATE_LOCAL (extra_len))) {
+ memcpy (extra, stuff + 1, extra_len);
+
+ FOR_NSCREENS_FORWARD(j) {
+ if (j) memcpy (stuff + 1, extra, extra_len);
+ if (dst->u.pict.root) {
+ int x_off = panoramiXdataPtr[j].x;
+ int y_off = panoramiXdataPtr[j].y;
+
+ if(x_off || y_off) {
+ xPointFixed *fixed = (xPointFixed *) (stuff + 1);
+ int i = extra_len / sizeof (xPointFixed);
+
+ while (i--) {
+ fixed->x -= x_off;
+ fixed->y -= y_off;
+ fixed++;
+ }
+ }
+ }
+
+ stuff->src = src->info[j].id;
+ stuff->dst = dst->info[j].id;
+ result =
+ (*PanoramiXSaveRenderVector[X_RenderTriFan]) (client);
+
+ if(result != Success) break;
+ }
+
+ DEALLOCATE_LOCAL(extra);
+ }
+
+ return result;
+}
+
+#if 0 /* Not implemented yet */
+
+static int
+PanoramiXRenderColorTrapezoids(ClientPtr client)
+{
+ PanoramiXRes *src, *dst;
+ int result = Success, j;
+ REQUEST(xRenderColorTrapezoidsReq);
+ char *extra;
+ int extra_len;
+
+ REQUEST_AT_LEAST_SIZE (xRenderColorTrapezoidsReq);
+
+ VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+
+ extra_len = (client->req_len << 2) - sizeof (xRenderColorTrapezoidsReq);
+
+ if (extra_len &&
+ (extra = (char *) ALLOCATE_LOCAL (extra_len))) {
+ memcpy (extra, stuff + 1, extra_len);
+
+ FOR_NSCREENS_FORWARD(j) {
+ if (j) memcpy (stuff + 1, extra, extra_len);
+ if (dst->u.pict.root) {
+ int x_off = panoramiXdataPtr[j].x;
+ int y_off = panoramiXdataPtr[j].y;
+
+ if(x_off || y_off) {
+ ....;
+ }
+ }
+
+ stuff->dst = dst->info[j].id;
+ result =
+ (*PanoramiXSaveRenderVector[X_RenderColorTrapezoids]) (client);
+
+ if(result != Success) break;
+ }
+
+ DEALLOCATE_LOCAL(extra);
+ }
+
+ return result;
+}
+
+static int
+PanoramiXRenderColorTriangles(ClientPtr client)
+{
+ PanoramiXRes *src, *dst;
+ int result = Success, j;
+ REQUEST(xRenderColorTrianglesReq);
+ char *extra;
+ int extra_len;
+
+ REQUEST_AT_LEAST_SIZE (xRenderColorTrianglesReq);
+
+ VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+
+ extra_len = (client->req_len << 2) - sizeof (xRenderColorTrianglesReq);
+
+ if (extra_len &&
+ (extra = (char *) ALLOCATE_LOCAL (extra_len))) {
+ memcpy (extra, stuff + 1, extra_len);
+
+ FOR_NSCREENS_FORWARD(j) {
+ if (j) memcpy (stuff + 1, extra, extra_len);
+ if (dst->u.pict.root) {
+ int x_off = panoramiXdataPtr[j].x;
+ int y_off = panoramiXdataPtr[j].y;
+
+ if(x_off || y_off) {
+ ....;
+ }
+ }
+
+ stuff->dst = dst->info[j].id;
+ result =
+ (*PanoramiXSaveRenderVector[X_RenderColorTriangles]) (client);
+
+ if(result != Success) break;
+ }
+
+ DEALLOCATE_LOCAL(extra);
+ }
+
+ return result;
+}
+
+#endif
+
+static int
+PanoramiXRenderAddTraps (ClientPtr client)
+{
+ PanoramiXRes *picture;
+ int result = Success, j;
+ REQUEST(xRenderAddTrapsReq);
+ char *extra;
+ int extra_len;
+ INT16 x_off, y_off;
+
+ REQUEST_AT_LEAST_SIZE (xRenderAddTrapsReq);
+ VERIFY_XIN_PICTURE (picture, stuff->picture, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+ extra_len = (client->req_len << 2) - sizeof (xRenderAddTrapsReq);
+ if (extra_len &&
+ (extra = (char *) ALLOCATE_LOCAL (extra_len)))
+ {
+ memcpy (extra, stuff + 1, extra_len);
+ x_off = stuff->xOff;
+ y_off = stuff->yOff;
+ FOR_NSCREENS_FORWARD(j) {
+ if (j) memcpy (stuff + 1, extra, extra_len);
+ stuff->picture = picture->info[j].id;
+
+ if (picture->u.pict.root)
+ {
+ stuff->xOff = x_off + panoramiXdataPtr[j].x;
+ stuff->yOff = y_off + panoramiXdataPtr[j].y;
+ }
+ result = (*PanoramiXSaveRenderVector[X_RenderAddTraps]) (client);
+ if(result != Success) break;
+ }
+ DEALLOCATE_LOCAL(extra);
+ }
+
+ return result;
+}
+
+void
+PanoramiXRenderInit (void)
+{
+ int i;
+
+ XRT_PICTURE = CreateNewResourceType (XineramaDeleteResource);
+ for (i = 0; i < RenderNumberRequests; i++)
+ PanoramiXSaveRenderVector[i] = ProcRenderVector[i];
+ /*
+ * Stuff in Xinerama aware request processing hooks
+ */
+ ProcRenderVector[X_RenderCreatePicture] = PanoramiXRenderCreatePicture;
+ ProcRenderVector[X_RenderChangePicture] = PanoramiXRenderChangePicture;
+ ProcRenderVector[X_RenderSetPictureTransform] = PanoramiXRenderSetPictureTransform;
+ ProcRenderVector[X_RenderSetPictureFilter] = PanoramiXRenderSetPictureFilter;
+ ProcRenderVector[X_RenderSetPictureClipRectangles] = PanoramiXRenderSetPictureClipRectangles;
+ ProcRenderVector[X_RenderFreePicture] = PanoramiXRenderFreePicture;
+ ProcRenderVector[X_RenderComposite] = PanoramiXRenderComposite;
+ ProcRenderVector[X_RenderCompositeGlyphs8] = PanoramiXRenderCompositeGlyphs;
+ ProcRenderVector[X_RenderCompositeGlyphs16] = PanoramiXRenderCompositeGlyphs;
+ ProcRenderVector[X_RenderCompositeGlyphs32] = PanoramiXRenderCompositeGlyphs;
+ ProcRenderVector[X_RenderFillRectangles] = PanoramiXRenderFillRectangles;
+
+ ProcRenderVector[X_RenderTrapezoids] = PanoramiXRenderTrapezoids;
+ ProcRenderVector[X_RenderTriangles] = PanoramiXRenderTriangles;
+ ProcRenderVector[X_RenderTriStrip] = PanoramiXRenderTriStrip;
+ ProcRenderVector[X_RenderTriFan] = PanoramiXRenderTriFan;
+ ProcRenderVector[X_RenderAddTraps] = PanoramiXRenderAddTraps;
+}
+
+void
+PanoramiXRenderReset (void)
+{
+ int i;
+ for (i = 0; i < RenderNumberRequests; i++)
+ ProcRenderVector[i] = PanoramiXSaveRenderVector[i];
+}
+
+#endif /* PANORAMIX */
diff --git a/nx-X11/programs/Xserver/render/renderedge.c b/nx-X11/programs/Xserver/render/renderedge.c
new file mode 100644
index 000000000..b4031944d
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/renderedge.c
@@ -0,0 +1,201 @@
+/*
+ * $Id: renderedge.c,v 1.4 2005/07/03 07:02:08 daniels Exp $
+ *
+ * Copyright © 2004 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "renderedge.h"
+
+/*
+ * Compute the smallest value no less than y which is on a
+ * grid row
+ */
+
+xFixed
+RenderSampleCeilY (xFixed y, int n)
+{
+ xFixed f = xFixedFrac(y);
+ xFixed i = xFixedFloor(y);
+
+ f = ((f + Y_FRAC_FIRST(n)) / STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
+ if (f > Y_FRAC_LAST(n))
+ {
+ f = Y_FRAC_FIRST(n);
+ i += xFixed1;
+ }
+ return (i | f);
+}
+
+#define _div(a,b) ((a) >= 0 ? (a) / (b) : -((-(a) + (b) - 1) / (b)))
+
+/*
+ * Compute the largest value no greater than y which is on a
+ * grid row
+ */
+xFixed
+RenderSampleFloorY (xFixed y, int n)
+{
+ xFixed f = xFixedFrac(y);
+ xFixed i = xFixedFloor (y);
+
+ f = _div(f - Y_FRAC_FIRST(n), STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
+ if (f < Y_FRAC_FIRST(n))
+ {
+ f = Y_FRAC_LAST(n);
+ i -= xFixed1;
+ }
+ return (i | f);
+}
+
+/*
+ * Step an edge by any amount (including negative values)
+ */
+void
+RenderEdgeStep (RenderEdge *e, int n)
+{
+ xFixed_48_16 ne;
+
+ e->x += n * e->stepx;
+
+ ne = e->e + n * (xFixed_48_16) e->dx;
+
+ if (n >= 0)
+ {
+ if (ne > 0)
+ {
+ int nx = (ne + e->dy - 1) / e->dy;
+ e->e = ne - nx * (xFixed_48_16) e->dy;
+ e->x += nx * e->signdx;
+ }
+ }
+ else
+ {
+ if (ne <= -e->dy)
+ {
+ int nx = (-ne) / e->dy;
+ e->e = ne + nx * (xFixed_48_16) e->dy;
+ e->x -= nx * e->signdx;
+ }
+ }
+}
+
+/*
+ * A private routine to initialize the multi-step
+ * elements of an edge structure
+ */
+static void
+_RenderEdgeMultiInit (RenderEdge *e, int n, xFixed *stepx_p, xFixed *dx_p)
+{
+ xFixed stepx;
+ xFixed_48_16 ne;
+
+ ne = n * (xFixed_48_16) e->dx;
+ stepx = n * e->stepx;
+ if (ne > 0)
+ {
+ int nx = ne / e->dy;
+ ne -= nx * e->dy;
+ stepx += nx * e->signdx;
+ }
+ *dx_p = ne;
+ *stepx_p = stepx;
+}
+
+/*
+ * Initialize one edge structure given the line endpoints and a
+ * starting y value
+ */
+void
+RenderEdgeInit (RenderEdge *e,
+ int n,
+ xFixed y_start,
+ xFixed x_top,
+ xFixed y_top,
+ xFixed x_bot,
+ xFixed y_bot)
+{
+ xFixed dx, dy;
+
+ e->x = x_top;
+ e->e = 0;
+ dx = x_bot - x_top;
+ dy = y_bot - y_top;
+ e->dy = dy;
+ if (dy)
+ {
+ if (dx >= 0)
+ {
+ e->signdx = 1;
+ e->stepx = dx / dy;
+ e->dx = dx % dy;
+ e->e = -dy;
+ }
+ else
+ {
+ e->signdx = -1;
+ e->stepx = -(-dx / dy);
+ e->dx = -dx % dy;
+ e->e = 0;
+ }
+
+ _RenderEdgeMultiInit (e, STEP_Y_SMALL(n), &e->stepx_small, &e->dx_small);
+ _RenderEdgeMultiInit (e, STEP_Y_BIG(n), &e->stepx_big, &e->dx_big);
+ }
+ RenderEdgeStep (e, y_start - y_top);
+}
+
+/*
+ * Initialize one edge structure given a line, starting y value
+ * and a pixel offset for the line
+ */
+void
+RenderLineFixedEdgeInit (RenderEdge *e,
+ int n,
+ xFixed y,
+ xLineFixed *line,
+ int x_off,
+ int y_off)
+{
+ xFixed x_off_fixed = IntToxFixed(x_off);
+ xFixed y_off_fixed = IntToxFixed(y_off);
+ xPointFixed *top, *bot;
+
+ if (line->p1.y <= line->p2.y)
+ {
+ top = &line->p1;
+ bot = &line->p2;
+ }
+ else
+ {
+ top = &line->p2;
+ bot = &line->p1;
+ }
+ RenderEdgeInit (e, n, y,
+ top->x + x_off_fixed,
+ top->y + y_off_fixed,
+ bot->x + x_off_fixed,
+ bot->y + y_off_fixed);
+}
+
diff --git a/nx-X11/programs/Xserver/render/renderedge.h b/nx-X11/programs/Xserver/render/renderedge.h
new file mode 100644
index 000000000..bfd19fa93
--- /dev/null
+++ b/nx-X11/programs/Xserver/render/renderedge.h
@@ -0,0 +1,120 @@
+/*
+ * $Id: renderedge.h,v 1.4 2005/08/24 11:18:33 daniels Exp $
+ *
+ * Copyright © 2004 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _RENDEREDGE_H_
+#define _RENDEREDGE_H_
+
+#include "picturestr.h"
+
+#define MAX_ALPHA(n) ((1 << (n)) - 1)
+#define N_Y_FRAC(n) ((n) == 1 ? 1 : (1 << ((n)/2)) - 1)
+#define N_X_FRAC(n) ((1 << ((n)/2)) + 1)
+
+#define STEP_Y_SMALL(n) (xFixed1 / N_Y_FRAC(n))
+#define STEP_Y_BIG(n) (xFixed1 - (N_Y_FRAC(n) - 1) * STEP_Y_SMALL(n))
+
+#define Y_FRAC_FIRST(n) (STEP_Y_SMALL(n) / 2)
+#define Y_FRAC_LAST(n) (Y_FRAC_FIRST(n) + (N_Y_FRAC(n) - 1) * STEP_Y_SMALL(n))
+
+#define STEP_X_SMALL(n) (xFixed1 / N_X_FRAC(n))
+#define STEP_X_BIG(n) (xFixed1 - (N_X_FRAC(n) - 1) * STEP_X_SMALL(n))
+
+#define X_FRAC_FIRST(n) (STEP_X_SMALL(n) / 2)
+#define X_FRAC_LAST(n) (X_FRAC_FIRST(n) + (N_X_FRAC(n) - 1) * STEP_X_SMALL(n))
+
+#define RenderSamplesX(x,n) ((n) == 1 ? 0 : (xFixedFrac (x) + X_FRAC_FIRST(n)) / STEP_X_SMALL(n))
+
+/*
+ * An edge structure. This represents a single polygon edge
+ * and can be quickly stepped across small or large gaps in the
+ * sample grid
+ */
+
+typedef struct {
+ xFixed x;
+ xFixed e;
+ xFixed stepx;
+ xFixed signdx;
+ xFixed dy;
+ xFixed dx;
+
+ xFixed stepx_small;
+ xFixed stepx_big;
+ xFixed dx_small;
+ xFixed dx_big;
+} RenderEdge;
+
+/*
+ * Step across a small sample grid gap
+ */
+#define RenderEdgeStepSmall(edge) { \
+ edge->x += edge->stepx_small; \
+ edge->e += edge->dx_small; \
+ if (edge->e > 0) \
+ { \
+ edge->e -= edge->dy; \
+ edge->x += edge->signdx; \
+ } \
+}
+
+/*
+ * Step across a large sample grid gap
+ */
+#define RenderEdgeStepBig(edge) { \
+ edge->x += edge->stepx_big; \
+ edge->e += edge->dx_big; \
+ if (edge->e > 0) \
+ { \
+ edge->e -= edge->dy; \
+ edge->x += edge->signdx; \
+ } \
+}
+
+xFixed
+RenderSampleCeilY (xFixed y, int bpp);
+
+xFixed
+RenderSampleFloorY (xFixed y, int bpp);
+
+void
+RenderEdgeStep (RenderEdge *e, int n);
+
+void
+RenderEdgeInit (RenderEdge *e,
+ int bpp,
+ xFixed y_start,
+ xFixed x_top,
+ xFixed y_top,
+ xFixed x_bot,
+ xFixed y_bot);
+
+void
+RenderLineFixedEdgeInit (RenderEdge *e,
+ int bpp,
+ xFixed y,
+ xLineFixed *line,
+ int x_off,
+ int y_off);
+
+#endif /* _RENDEREDGE_H_ */
diff --git a/nx-X11/programs/Xserver/xfixes/Imakefile b/nx-X11/programs/Xserver/xfixes/Imakefile
new file mode 100755
index 000000000..e467ed149
--- /dev/null
+++ b/nx-X11/programs/Xserver/xfixes/Imakefile
@@ -0,0 +1,17 @@
+#include <Server.tmpl>
+
+ SRCS = cursor.c region.c saveset.c select.c xfixes.c
+
+ OBJS = cursor.o region.o saveset.o select.o xfixes.o
+
+ INCLUDES = -I. -I../include -I../Xext -I../fixes -I../render \
+ -I$(EXTINCSRC) -I$(XINCLUDESRC)
+
+ LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+
+NormalLibraryTarget(xfixes,$(OBJS))
+NormalLibraryObjectRule()
+LintLibraryTarget(xfixes,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/xfixes/cursor.c b/nx-X11/programs/Xserver/xfixes/cursor.c
new file mode 100755
index 000000000..f6895d193
--- /dev/null
+++ b/nx-X11/programs/Xserver/xfixes/cursor.c
@@ -0,0 +1,754 @@
+/*
+ * $Id: cursor.c,v 1.6 2005/07/03 07:37:35 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xfixesint.h"
+#include "scrnintstr.h"
+#include "cursorstr.h"
+#include "dixevents.h"
+#include "servermd.h"
+#include "inputstr.h"
+#include "windowstr.h"
+
+static RESTYPE CursorClientType;
+static RESTYPE CursorWindowType;
+static int CursorScreenPrivateIndex = -1;
+static int CursorGeneration;
+static CursorPtr CursorCurrent;
+
+#define VERIFY_CURSOR(pCursor, cursor, client, access) { \
+ pCursor = (CursorPtr)SecurityLookupIDByType((client), (cursor), \
+ RT_CURSOR, (access)); \
+ if (!pCursor) { \
+ (client)->errorValue = (cursor); \
+ return BadCursor; \
+ } \
+}
+
+/*
+ * There is a global list of windows selecting for cursor events
+ */
+
+typedef struct _CursorEvent *CursorEventPtr;
+
+typedef struct _CursorEvent {
+ CursorEventPtr next;
+ CARD32 eventMask;
+ ClientPtr pClient;
+ WindowPtr pWindow;
+ XID clientResource;
+} CursorEventRec;
+
+static CursorEventPtr cursorEvents;
+
+/*
+ * Wrap DisplayCursor to catch cursor change events
+ */
+
+typedef struct _CursorScreen {
+ DisplayCursorProcPtr DisplayCursor;
+ CloseScreenProcPtr CloseScreen;
+} CursorScreenRec, *CursorScreenPtr;
+
+#define GetCursorScreen(s) ((CursorScreenPtr) ((s)->devPrivates[CursorScreenPrivateIndex].ptr))
+#define GetCursorScreenIfSet(s) ((CursorScreenPrivateIndex != -1) ? GetCursorScreen(s) : NULL)
+#define SetCursorScreen(s,p) ((s)->devPrivates[CursorScreenPrivateIndex].ptr = (pointer) (p))
+#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
+#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
+
+static Bool
+CursorDisplayCursor (ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ CursorScreenPtr cs = GetCursorScreen(pScreen);
+ Bool ret;
+
+ Unwrap (cs, pScreen, DisplayCursor);
+ ret = (*pScreen->DisplayCursor) (pScreen, pCursor);
+ if (pCursor != CursorCurrent)
+ {
+ CursorEventPtr e;
+
+ CursorCurrent = pCursor;
+ for (e = cursorEvents; e; e = e->next)
+ {
+ if ((e->eventMask & XFixesDisplayCursorNotifyMask) &&
+ !e->pClient->clientGone)
+ {
+ xXFixesCursorNotifyEvent ev;
+ ev.type = XFixesEventBase + XFixesCursorNotify;
+ ev.subtype = XFixesDisplayCursorNotify;
+ ev.sequenceNumber = e->pClient->sequence;
+ ev.window = e->pWindow->drawable.id;
+ ev.cursorSerial = pCursor->serialNumber;
+ ev.timestamp = currentTime.milliseconds;
+ ev.name = pCursor->name;
+ WriteEventsToClient (e->pClient, 1, (xEvent *) &ev);
+ }
+ }
+ }
+ Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
+ return ret;
+}
+
+static Bool
+CursorCloseScreen (int index, ScreenPtr pScreen)
+{
+ CursorScreenPtr cs = GetCursorScreen (pScreen);
+ Bool ret;
+
+ Unwrap (cs, pScreen, CloseScreen);
+ Unwrap (cs, pScreen, DisplayCursor);
+ ret = (*pScreen->CloseScreen) (index, pScreen);
+ xfree (cs);
+ if (index == 0)
+ CursorScreenPrivateIndex = -1;
+ return ret;
+}
+
+#define CursorAllEvents (XFixesDisplayCursorNotifyMask)
+
+static int
+XFixesSelectCursorInput (ClientPtr pClient,
+ WindowPtr pWindow,
+ CARD32 eventMask)
+{
+ CursorEventPtr *prev, e;
+
+ for (prev = &cursorEvents; (e = *prev); prev = &e->next)
+ {
+ if (e->pClient == pClient &&
+ e->pWindow == pWindow)
+ {
+ break;
+ }
+ }
+ if (!eventMask)
+ {
+ if (e)
+ {
+ FreeResource (e->clientResource, 0);
+ }
+ return Success;
+ }
+ if (!e)
+ {
+ e = (CursorEventPtr) xalloc (sizeof (CursorEventRec));
+ if (!e)
+ return BadAlloc;
+
+ e->next = 0;
+ e->pClient = pClient;
+ e->pWindow = pWindow;
+ e->clientResource = FakeClientID(pClient->index);
+
+ /*
+ * Add a resource hanging from the window to
+ * catch window destroy
+ */
+ if (!LookupIDByType(pWindow->drawable.id, CursorWindowType))
+ if (!AddResource (pWindow->drawable.id, CursorWindowType,
+ (pointer) pWindow))
+ {
+ xfree (e);
+ return BadAlloc;
+ }
+
+ if (!AddResource (e->clientResource, CursorClientType, (pointer) e))
+ return BadAlloc;
+
+ *prev = e;
+ }
+ e->eventMask = eventMask;
+ return Success;
+}
+
+int
+ProcXFixesSelectCursorInput (ClientPtr client)
+{
+ REQUEST (xXFixesSelectCursorInputReq);
+ WindowPtr pWin;
+
+ REQUEST_SIZE_MATCH (xXFixesSelectCursorInputReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ if (stuff->eventMask & ~CursorAllEvents)
+ {
+ client->errorValue = stuff->eventMask;
+ return( BadValue );
+ }
+ return XFixesSelectCursorInput (client, pWin, stuff->eventMask);
+}
+
+static int
+GetBit (unsigned char *line, int x)
+{
+ unsigned char mask;
+
+ if (screenInfo.bitmapBitOrder == LSBFirst)
+ mask = (1 << (x & 7));
+ else
+ mask = (0x80 >> (x & 7));
+ /* XXX assumes byte order is host byte order */
+ line += (x >> 3);
+ if (*line & mask)
+ return 1;
+ return 0;
+}
+
+int
+SProcXFixesSelectCursorInput (ClientPtr client)
+{
+ register int n;
+ REQUEST(xXFixesSelectCursorInputReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ swapl(&stuff->eventMask, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+void
+SXFixesCursorNotifyEvent (xXFixesCursorNotifyEvent *from,
+ xXFixesCursorNotifyEvent *to)
+{
+ to->type = from->type;
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswapl (from->window, to->window);
+ cpswapl (from->cursorSerial, to->cursorSerial);
+ cpswapl (from->timestamp, to->timestamp);
+ cpswapl (from->name, to->name);
+}
+
+static void
+CopyCursorToImage (CursorPtr pCursor, CARD32 *image)
+{
+ int width = pCursor->bits->width;
+ int height = pCursor->bits->height;
+ int npixels = width * height;
+
+#ifdef ARGB_CURSOR
+ if (pCursor->bits->argb)
+ memcpy (image, pCursor->bits->argb, npixels * sizeof (CARD32));
+ else
+#endif
+ {
+ unsigned char *srcLine = pCursor->bits->source;
+ unsigned char *mskLine = pCursor->bits->mask;
+ int stride = BitmapBytePad (width);
+ int x, y;
+ CARD32 fg, bg;
+
+ fg = (0xff000000 |
+ ((pCursor->foreRed & 0xff00) << 8) |
+ (pCursor->foreGreen & 0xff00) |
+ (pCursor->foreBlue >> 8));
+ bg = (0xff000000 |
+ ((pCursor->backRed & 0xff00) << 8) |
+ (pCursor->backGreen & 0xff00) |
+ (pCursor->backBlue >> 8));
+ for (y = 0; y < height; y++)
+ {
+ for (x = 0; x < width; x++)
+ {
+ if (GetBit (mskLine, x))
+ {
+ if (GetBit (srcLine, x))
+ *image++ = fg;
+ else
+ *image++ = bg;
+ }
+ else
+ *image++ = 0;
+ }
+ srcLine += stride;
+ mskLine += stride;
+ }
+ }
+}
+
+int
+ProcXFixesGetCursorImage (ClientPtr client)
+{
+/* REQUEST(xXFixesGetCursorImageReq); */
+ xXFixesGetCursorImageReply *rep;
+ CursorPtr pCursor;
+ CARD32 *image;
+ int npixels;
+ int width, height;
+ int x, y;
+
+ REQUEST_SIZE_MATCH(xXFixesGetCursorImageReq);
+ pCursor = CursorCurrent;
+ if (!pCursor)
+ return BadCursor;
+ GetSpritePosition (&x, &y);
+ width = pCursor->bits->width;
+ height = pCursor->bits->height;
+ npixels = width * height;
+ rep = xalloc (sizeof (xXFixesGetCursorImageReply) +
+ npixels * sizeof (CARD32));
+ if (!rep)
+ return BadAlloc;
+
+ rep->type = X_Reply;
+ rep->sequenceNumber = client->sequence;
+ rep->length = npixels;
+ rep->width = width;
+ rep->height = height;
+ rep->x = x;
+ rep->y = y;
+ rep->xhot = pCursor->bits->xhot;
+ rep->yhot = pCursor->bits->yhot;
+ rep->cursorSerial = pCursor->serialNumber;
+
+ image = (CARD32 *) (rep + 1);
+ CopyCursorToImage (pCursor, image);
+ if (client->swapped)
+ {
+ int n;
+ swaps (&rep->sequenceNumber, n);
+ swapl (&rep->length, n);
+ swaps (&rep->x, n);
+ swaps (&rep->y, n);
+ swaps (&rep->width, n);
+ swaps (&rep->height, n);
+ swaps (&rep->xhot, n);
+ swaps (&rep->yhot, n);
+ swapl (&rep->cursorSerial, n);
+ SwapLongs (image, npixels);
+ }
+ (void) WriteToClient(client, sizeof (xXFixesGetCursorImageReply) +
+ (npixels << 2), (char *) rep);
+ xfree (rep);
+ return client->noClientException;
+}
+
+int
+SProcXFixesGetCursorImage (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesGetCursorImageReq);
+ swaps (&stuff->length, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesSetCursorName (ClientPtr client)
+{
+ CursorPtr pCursor;
+ char *tchar;
+ REQUEST(xXFixesSetCursorNameReq);
+ Atom atom;
+
+ REQUEST_AT_LEAST_SIZE(xXFixesSetCursorNameReq);
+ VERIFY_CURSOR(pCursor, stuff->cursor, client, SecurityWriteAccess);
+ tchar = (char *) &stuff[1];
+ atom = MakeAtom (tchar, stuff->nbytes, TRUE);
+ if (atom == BAD_RESOURCE)
+ return BadAlloc;
+
+ pCursor->name = atom;
+ return(client->noClientException);
+}
+
+int
+SProcXFixesSetCursorName (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesSetCursorNameReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXFixesSetCursorNameReq);
+ swapl (&stuff->cursor, n);
+ swaps (&stuff->nbytes, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesGetCursorName (ClientPtr client)
+{
+ CursorPtr pCursor;
+ xXFixesGetCursorNameReply reply;
+ REQUEST(xXFixesGetCursorNameReq);
+ char *str;
+ int len;
+
+ REQUEST_SIZE_MATCH(xXFixesGetCursorNameReq);
+ VERIFY_CURSOR(pCursor, stuff->cursor, client, SecurityReadAccess);
+ if (pCursor->name)
+ str = NameForAtom (pCursor->name);
+ else
+ str = "";
+ len = strlen (str);
+
+ reply.type = X_Reply;
+ reply.length = (len + 3) >> 2;
+ reply.sequenceNumber = client->sequence;
+ reply.atom = pCursor->name;
+ reply.nbytes = len;
+ if (client->swapped)
+ {
+ int n;
+ swaps (&reply.sequenceNumber, n);
+ swapl (&reply.length, n);
+ swapl (&reply.atom, n);
+ swaps (&reply.nbytes, n);
+ }
+ WriteReplyToClient(client, sizeof(xXFixesGetCursorNameReply), &reply);
+ (void)WriteToClient(client, len, str);
+
+ return(client->noClientException);
+}
+
+int
+SProcXFixesGetCursorName (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesSetCursorNameReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXFixesGetCursorNameReq);
+ swapl (&stuff->cursor, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesGetCursorImageAndName (ClientPtr client)
+{
+/* REQUEST(xXFixesGetCursorImageAndNameReq); */
+ xXFixesGetCursorImageAndNameReply *rep;
+ CursorPtr pCursor;
+ CARD32 *image;
+ int npixels;
+ char *name;
+ int nbytes, nbytesRound;
+ int width, height;
+ int x, y;
+
+ REQUEST_SIZE_MATCH(xXFixesGetCursorImageAndNameReq);
+ pCursor = CursorCurrent;
+ if (!pCursor)
+ return BadCursor;
+ GetSpritePosition (&x, &y);
+ width = pCursor->bits->width;
+ height = pCursor->bits->height;
+ npixels = width * height;
+ name = pCursor->name ? NameForAtom (pCursor->name) : "";
+ nbytes = strlen (name);
+ nbytesRound = (nbytes + 3) & ~3;
+ rep = xalloc (sizeof (xXFixesGetCursorImageAndNameReply) +
+ npixels * sizeof (CARD32) + nbytesRound);
+ if (!rep)
+ return BadAlloc;
+
+ rep->type = X_Reply;
+ rep->sequenceNumber = client->sequence;
+ rep->length = npixels + (nbytesRound >> 2);
+ rep->width = width;
+ rep->height = height;
+ rep->x = x;
+ rep->y = y;
+ rep->xhot = pCursor->bits->xhot;
+ rep->yhot = pCursor->bits->yhot;
+ rep->cursorSerial = pCursor->serialNumber;
+ rep->cursorName = pCursor->name;
+ rep->nbytes = nbytes;
+
+ image = (CARD32 *) (rep + 1);
+ CopyCursorToImage (pCursor, image);
+ memcpy ((image + npixels), name, nbytes);
+ if (client->swapped)
+ {
+ int n;
+ swaps (&rep->sequenceNumber, n);
+ swapl (&rep->length, n);
+ swaps (&rep->x, n);
+ swaps (&rep->y, n);
+ swaps (&rep->width, n);
+ swaps (&rep->height, n);
+ swaps (&rep->xhot, n);
+ swaps (&rep->yhot, n);
+ swapl (&rep->cursorSerial, n);
+ swapl (&rep->cursorName, n);
+ swaps (&rep->nbytes, n);
+ SwapLongs (image, npixels);
+ }
+ (void) WriteToClient(client, sizeof (xXFixesGetCursorImageAndNameReply) +
+ (npixels << 2) + nbytesRound, (char *) rep);
+ xfree (rep);
+ return client->noClientException;
+}
+
+int
+SProcXFixesGetCursorImageAndName (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesGetCursorImageAndNameReq);
+ swaps (&stuff->length, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+/*
+ * Find every cursor reference in the system, ask testCursor
+ * whether it should be replaced with a reference to pCursor.
+ */
+
+typedef Bool (*TestCursorFunc) (CursorPtr pOld, pointer closure);
+
+typedef struct {
+ RESTYPE type;
+ TestCursorFunc testCursor;
+ CursorPtr pNew;
+ pointer closure;
+} ReplaceCursorLookupRec, *ReplaceCursorLookupPtr;
+
+static const RESTYPE CursorRestypes[] = {
+ RT_WINDOW, RT_PASSIVEGRAB, RT_CURSOR
+};
+
+#define NUM_CURSOR_RESTYPES (sizeof (CursorRestypes) / sizeof (CursorRestypes[0]))
+
+static Bool
+ReplaceCursorLookup (pointer value, XID id, pointer closure)
+{
+ ReplaceCursorLookupPtr rcl = (ReplaceCursorLookupPtr) closure;
+ WindowPtr pWin;
+ GrabPtr pGrab;
+ CursorPtr pCursor = 0, *pCursorRef = 0;
+ XID cursor = 0;
+
+ switch (rcl->type) {
+ case RT_WINDOW:
+ pWin = (WindowPtr) value;
+ if (pWin->optional)
+ {
+ pCursorRef = &pWin->optional->cursor;
+ pCursor = *pCursorRef;
+ }
+ break;
+ case RT_PASSIVEGRAB:
+ pGrab = (GrabPtr) value;
+ pCursorRef = &pGrab->cursor;
+ pCursor = *pCursorRef;
+ break;
+ case RT_CURSOR:
+ pCursorRef = 0;
+ pCursor = (CursorPtr) value;
+ cursor = id;
+ break;
+ }
+ if (pCursor && pCursor != rcl->pNew)
+ {
+ if ((*rcl->testCursor) (pCursor, rcl->closure))
+ {
+ rcl->pNew->refcnt++;
+ /* either redirect reference or update resource database */
+ if (pCursorRef)
+ *pCursorRef = rcl->pNew;
+ else
+ ChangeResourceValue (id, RT_CURSOR, rcl->pNew);
+ FreeCursor (pCursor, cursor);
+ }
+ }
+ return FALSE; /* keep walking */
+}
+
+static void
+ReplaceCursor (CursorPtr pCursor,
+ TestCursorFunc testCursor,
+ pointer closure)
+{
+ int clientIndex;
+ int resIndex;
+ ReplaceCursorLookupRec rcl;
+
+ /*
+ * Cursors exist only in the resource database, windows and grabs.
+ * All of these are always pointed at by the resource database. Walk
+ * the whole thing looking for cursors
+ */
+ rcl.testCursor = testCursor;
+ rcl.pNew = pCursor;
+ rcl.closure = closure;
+
+ /* for each client */
+ for (clientIndex = 0; clientIndex < currentMaxClients; clientIndex++)
+ {
+ if (!clients[clientIndex])
+ continue;
+ for (resIndex = 0; resIndex < NUM_CURSOR_RESTYPES; resIndex++)
+ {
+ rcl.type = CursorRestypes[resIndex];
+ /*
+ * This function walks the entire client resource database
+ */
+ LookupClientResourceComplex (clients[clientIndex],
+ rcl.type,
+ ReplaceCursorLookup,
+ (pointer) &rcl);
+ }
+ }
+ /* this "knows" that WindowHasNewCursor doesn't depend on it's argument */
+ WindowHasNewCursor (WindowTable[0]);
+}
+
+static Bool
+TestForCursor (CursorPtr pCursor, pointer closure)
+{
+ return (pCursor == (CursorPtr) closure);
+}
+
+int
+ProcXFixesChangeCursor (ClientPtr client)
+{
+ CursorPtr pSource, pDestination;
+ REQUEST(xXFixesChangeCursorReq);
+
+ REQUEST_SIZE_MATCH(xXFixesChangeCursorReq);
+ VERIFY_CURSOR (pSource, stuff->source, client, SecurityReadAccess);
+ VERIFY_CURSOR (pDestination, stuff->destination, client, SecurityWriteAccess);
+
+ ReplaceCursor (pSource, TestForCursor, (pointer) pDestination);
+ return (client->noClientException);
+}
+
+int
+SProcXFixesChangeCursor (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesChangeCursorReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXFixesChangeCursorReq);
+ swapl (&stuff->source, n);
+ swapl (&stuff->destination, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+static Bool
+TestForCursorName (CursorPtr pCursor, pointer closure)
+{
+ return (pCursor->name == (Atom) closure);
+}
+
+int
+ProcXFixesChangeCursorByName (ClientPtr client)
+{
+ CursorPtr pSource;
+ Atom name;
+ char *tchar;
+ REQUEST(xXFixesChangeCursorByNameReq);
+
+ REQUEST_FIXED_SIZE(xXFixesChangeCursorByNameReq, stuff->nbytes);
+ VERIFY_CURSOR(pSource, stuff->source, client, SecurityReadAccess);
+ tchar = (char *) &stuff[1];
+ name = MakeAtom (tchar, stuff->nbytes, FALSE);
+ if (name)
+ ReplaceCursor (pSource, TestForCursorName, (pointer) name);
+ return (client->noClientException);
+}
+
+int
+SProcXFixesChangeCursorByName (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesChangeCursorByNameReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE (xXFixesChangeCursorByNameReq);
+ swapl (&stuff->source, n);
+ swaps (&stuff->nbytes, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+static int
+CursorFreeClient (pointer data, XID id)
+{
+ CursorEventPtr old = (CursorEventPtr) data;
+ CursorEventPtr *prev, e;
+
+ for (prev = &cursorEvents; (e = *prev); prev = &e->next)
+ {
+ if (e == old)
+ {
+ *prev = e->next;
+ xfree (e);
+ break;
+ }
+ }
+ return 1;
+}
+
+static int
+CursorFreeWindow (pointer data, XID id)
+{
+ WindowPtr pWindow = (WindowPtr) data;
+ CursorEventPtr e, next;
+
+ for (e = cursorEvents; e; e = next)
+ {
+ next = e->next;
+ if (e->pWindow == pWindow)
+ {
+ FreeResource (e->clientResource, 0);
+ }
+ }
+ return 1;
+}
+
+Bool
+XFixesCursorInit (void)
+{
+ int i;
+
+ if (CursorGeneration != serverGeneration)
+ {
+ CursorScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ if (CursorScreenPrivateIndex < 0)
+ return FALSE;
+ CursorGeneration = serverGeneration;
+ }
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ CursorScreenPtr cs;
+
+ cs = (CursorScreenPtr) xalloc (sizeof (CursorScreenRec));
+ if (!cs)
+ return FALSE;
+ Wrap (cs, pScreen, CloseScreen, CursorCloseScreen);
+ Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
+ SetCursorScreen (pScreen, cs);
+ }
+ CursorClientType = CreateNewResourceType(CursorFreeClient);
+ CursorWindowType = CreateNewResourceType(CursorFreeWindow);
+ return CursorClientType && CursorWindowType;
+}
+
diff --git a/nx-X11/programs/Xserver/xfixes/cursor.c.NX.original b/nx-X11/programs/Xserver/xfixes/cursor.c.NX.original
new file mode 100755
index 000000000..f6895d193
--- /dev/null
+++ b/nx-X11/programs/Xserver/xfixes/cursor.c.NX.original
@@ -0,0 +1,754 @@
+/*
+ * $Id: cursor.c,v 1.6 2005/07/03 07:37:35 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xfixesint.h"
+#include "scrnintstr.h"
+#include "cursorstr.h"
+#include "dixevents.h"
+#include "servermd.h"
+#include "inputstr.h"
+#include "windowstr.h"
+
+static RESTYPE CursorClientType;
+static RESTYPE CursorWindowType;
+static int CursorScreenPrivateIndex = -1;
+static int CursorGeneration;
+static CursorPtr CursorCurrent;
+
+#define VERIFY_CURSOR(pCursor, cursor, client, access) { \
+ pCursor = (CursorPtr)SecurityLookupIDByType((client), (cursor), \
+ RT_CURSOR, (access)); \
+ if (!pCursor) { \
+ (client)->errorValue = (cursor); \
+ return BadCursor; \
+ } \
+}
+
+/*
+ * There is a global list of windows selecting for cursor events
+ */
+
+typedef struct _CursorEvent *CursorEventPtr;
+
+typedef struct _CursorEvent {
+ CursorEventPtr next;
+ CARD32 eventMask;
+ ClientPtr pClient;
+ WindowPtr pWindow;
+ XID clientResource;
+} CursorEventRec;
+
+static CursorEventPtr cursorEvents;
+
+/*
+ * Wrap DisplayCursor to catch cursor change events
+ */
+
+typedef struct _CursorScreen {
+ DisplayCursorProcPtr DisplayCursor;
+ CloseScreenProcPtr CloseScreen;
+} CursorScreenRec, *CursorScreenPtr;
+
+#define GetCursorScreen(s) ((CursorScreenPtr) ((s)->devPrivates[CursorScreenPrivateIndex].ptr))
+#define GetCursorScreenIfSet(s) ((CursorScreenPrivateIndex != -1) ? GetCursorScreen(s) : NULL)
+#define SetCursorScreen(s,p) ((s)->devPrivates[CursorScreenPrivateIndex].ptr = (pointer) (p))
+#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
+#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
+
+static Bool
+CursorDisplayCursor (ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ CursorScreenPtr cs = GetCursorScreen(pScreen);
+ Bool ret;
+
+ Unwrap (cs, pScreen, DisplayCursor);
+ ret = (*pScreen->DisplayCursor) (pScreen, pCursor);
+ if (pCursor != CursorCurrent)
+ {
+ CursorEventPtr e;
+
+ CursorCurrent = pCursor;
+ for (e = cursorEvents; e; e = e->next)
+ {
+ if ((e->eventMask & XFixesDisplayCursorNotifyMask) &&
+ !e->pClient->clientGone)
+ {
+ xXFixesCursorNotifyEvent ev;
+ ev.type = XFixesEventBase + XFixesCursorNotify;
+ ev.subtype = XFixesDisplayCursorNotify;
+ ev.sequenceNumber = e->pClient->sequence;
+ ev.window = e->pWindow->drawable.id;
+ ev.cursorSerial = pCursor->serialNumber;
+ ev.timestamp = currentTime.milliseconds;
+ ev.name = pCursor->name;
+ WriteEventsToClient (e->pClient, 1, (xEvent *) &ev);
+ }
+ }
+ }
+ Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
+ return ret;
+}
+
+static Bool
+CursorCloseScreen (int index, ScreenPtr pScreen)
+{
+ CursorScreenPtr cs = GetCursorScreen (pScreen);
+ Bool ret;
+
+ Unwrap (cs, pScreen, CloseScreen);
+ Unwrap (cs, pScreen, DisplayCursor);
+ ret = (*pScreen->CloseScreen) (index, pScreen);
+ xfree (cs);
+ if (index == 0)
+ CursorScreenPrivateIndex = -1;
+ return ret;
+}
+
+#define CursorAllEvents (XFixesDisplayCursorNotifyMask)
+
+static int
+XFixesSelectCursorInput (ClientPtr pClient,
+ WindowPtr pWindow,
+ CARD32 eventMask)
+{
+ CursorEventPtr *prev, e;
+
+ for (prev = &cursorEvents; (e = *prev); prev = &e->next)
+ {
+ if (e->pClient == pClient &&
+ e->pWindow == pWindow)
+ {
+ break;
+ }
+ }
+ if (!eventMask)
+ {
+ if (e)
+ {
+ FreeResource (e->clientResource, 0);
+ }
+ return Success;
+ }
+ if (!e)
+ {
+ e = (CursorEventPtr) xalloc (sizeof (CursorEventRec));
+ if (!e)
+ return BadAlloc;
+
+ e->next = 0;
+ e->pClient = pClient;
+ e->pWindow = pWindow;
+ e->clientResource = FakeClientID(pClient->index);
+
+ /*
+ * Add a resource hanging from the window to
+ * catch window destroy
+ */
+ if (!LookupIDByType(pWindow->drawable.id, CursorWindowType))
+ if (!AddResource (pWindow->drawable.id, CursorWindowType,
+ (pointer) pWindow))
+ {
+ xfree (e);
+ return BadAlloc;
+ }
+
+ if (!AddResource (e->clientResource, CursorClientType, (pointer) e))
+ return BadAlloc;
+
+ *prev = e;
+ }
+ e->eventMask = eventMask;
+ return Success;
+}
+
+int
+ProcXFixesSelectCursorInput (ClientPtr client)
+{
+ REQUEST (xXFixesSelectCursorInputReq);
+ WindowPtr pWin;
+
+ REQUEST_SIZE_MATCH (xXFixesSelectCursorInputReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ if (stuff->eventMask & ~CursorAllEvents)
+ {
+ client->errorValue = stuff->eventMask;
+ return( BadValue );
+ }
+ return XFixesSelectCursorInput (client, pWin, stuff->eventMask);
+}
+
+static int
+GetBit (unsigned char *line, int x)
+{
+ unsigned char mask;
+
+ if (screenInfo.bitmapBitOrder == LSBFirst)
+ mask = (1 << (x & 7));
+ else
+ mask = (0x80 >> (x & 7));
+ /* XXX assumes byte order is host byte order */
+ line += (x >> 3);
+ if (*line & mask)
+ return 1;
+ return 0;
+}
+
+int
+SProcXFixesSelectCursorInput (ClientPtr client)
+{
+ register int n;
+ REQUEST(xXFixesSelectCursorInputReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ swapl(&stuff->eventMask, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+void
+SXFixesCursorNotifyEvent (xXFixesCursorNotifyEvent *from,
+ xXFixesCursorNotifyEvent *to)
+{
+ to->type = from->type;
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswapl (from->window, to->window);
+ cpswapl (from->cursorSerial, to->cursorSerial);
+ cpswapl (from->timestamp, to->timestamp);
+ cpswapl (from->name, to->name);
+}
+
+static void
+CopyCursorToImage (CursorPtr pCursor, CARD32 *image)
+{
+ int width = pCursor->bits->width;
+ int height = pCursor->bits->height;
+ int npixels = width * height;
+
+#ifdef ARGB_CURSOR
+ if (pCursor->bits->argb)
+ memcpy (image, pCursor->bits->argb, npixels * sizeof (CARD32));
+ else
+#endif
+ {
+ unsigned char *srcLine = pCursor->bits->source;
+ unsigned char *mskLine = pCursor->bits->mask;
+ int stride = BitmapBytePad (width);
+ int x, y;
+ CARD32 fg, bg;
+
+ fg = (0xff000000 |
+ ((pCursor->foreRed & 0xff00) << 8) |
+ (pCursor->foreGreen & 0xff00) |
+ (pCursor->foreBlue >> 8));
+ bg = (0xff000000 |
+ ((pCursor->backRed & 0xff00) << 8) |
+ (pCursor->backGreen & 0xff00) |
+ (pCursor->backBlue >> 8));
+ for (y = 0; y < height; y++)
+ {
+ for (x = 0; x < width; x++)
+ {
+ if (GetBit (mskLine, x))
+ {
+ if (GetBit (srcLine, x))
+ *image++ = fg;
+ else
+ *image++ = bg;
+ }
+ else
+ *image++ = 0;
+ }
+ srcLine += stride;
+ mskLine += stride;
+ }
+ }
+}
+
+int
+ProcXFixesGetCursorImage (ClientPtr client)
+{
+/* REQUEST(xXFixesGetCursorImageReq); */
+ xXFixesGetCursorImageReply *rep;
+ CursorPtr pCursor;
+ CARD32 *image;
+ int npixels;
+ int width, height;
+ int x, y;
+
+ REQUEST_SIZE_MATCH(xXFixesGetCursorImageReq);
+ pCursor = CursorCurrent;
+ if (!pCursor)
+ return BadCursor;
+ GetSpritePosition (&x, &y);
+ width = pCursor->bits->width;
+ height = pCursor->bits->height;
+ npixels = width * height;
+ rep = xalloc (sizeof (xXFixesGetCursorImageReply) +
+ npixels * sizeof (CARD32));
+ if (!rep)
+ return BadAlloc;
+
+ rep->type = X_Reply;
+ rep->sequenceNumber = client->sequence;
+ rep->length = npixels;
+ rep->width = width;
+ rep->height = height;
+ rep->x = x;
+ rep->y = y;
+ rep->xhot = pCursor->bits->xhot;
+ rep->yhot = pCursor->bits->yhot;
+ rep->cursorSerial = pCursor->serialNumber;
+
+ image = (CARD32 *) (rep + 1);
+ CopyCursorToImage (pCursor, image);
+ if (client->swapped)
+ {
+ int n;
+ swaps (&rep->sequenceNumber, n);
+ swapl (&rep->length, n);
+ swaps (&rep->x, n);
+ swaps (&rep->y, n);
+ swaps (&rep->width, n);
+ swaps (&rep->height, n);
+ swaps (&rep->xhot, n);
+ swaps (&rep->yhot, n);
+ swapl (&rep->cursorSerial, n);
+ SwapLongs (image, npixels);
+ }
+ (void) WriteToClient(client, sizeof (xXFixesGetCursorImageReply) +
+ (npixels << 2), (char *) rep);
+ xfree (rep);
+ return client->noClientException;
+}
+
+int
+SProcXFixesGetCursorImage (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesGetCursorImageReq);
+ swaps (&stuff->length, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesSetCursorName (ClientPtr client)
+{
+ CursorPtr pCursor;
+ char *tchar;
+ REQUEST(xXFixesSetCursorNameReq);
+ Atom atom;
+
+ REQUEST_AT_LEAST_SIZE(xXFixesSetCursorNameReq);
+ VERIFY_CURSOR(pCursor, stuff->cursor, client, SecurityWriteAccess);
+ tchar = (char *) &stuff[1];
+ atom = MakeAtom (tchar, stuff->nbytes, TRUE);
+ if (atom == BAD_RESOURCE)
+ return BadAlloc;
+
+ pCursor->name = atom;
+ return(client->noClientException);
+}
+
+int
+SProcXFixesSetCursorName (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesSetCursorNameReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXFixesSetCursorNameReq);
+ swapl (&stuff->cursor, n);
+ swaps (&stuff->nbytes, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesGetCursorName (ClientPtr client)
+{
+ CursorPtr pCursor;
+ xXFixesGetCursorNameReply reply;
+ REQUEST(xXFixesGetCursorNameReq);
+ char *str;
+ int len;
+
+ REQUEST_SIZE_MATCH(xXFixesGetCursorNameReq);
+ VERIFY_CURSOR(pCursor, stuff->cursor, client, SecurityReadAccess);
+ if (pCursor->name)
+ str = NameForAtom (pCursor->name);
+ else
+ str = "";
+ len = strlen (str);
+
+ reply.type = X_Reply;
+ reply.length = (len + 3) >> 2;
+ reply.sequenceNumber = client->sequence;
+ reply.atom = pCursor->name;
+ reply.nbytes = len;
+ if (client->swapped)
+ {
+ int n;
+ swaps (&reply.sequenceNumber, n);
+ swapl (&reply.length, n);
+ swapl (&reply.atom, n);
+ swaps (&reply.nbytes, n);
+ }
+ WriteReplyToClient(client, sizeof(xXFixesGetCursorNameReply), &reply);
+ (void)WriteToClient(client, len, str);
+
+ return(client->noClientException);
+}
+
+int
+SProcXFixesGetCursorName (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesSetCursorNameReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXFixesGetCursorNameReq);
+ swapl (&stuff->cursor, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesGetCursorImageAndName (ClientPtr client)
+{
+/* REQUEST(xXFixesGetCursorImageAndNameReq); */
+ xXFixesGetCursorImageAndNameReply *rep;
+ CursorPtr pCursor;
+ CARD32 *image;
+ int npixels;
+ char *name;
+ int nbytes, nbytesRound;
+ int width, height;
+ int x, y;
+
+ REQUEST_SIZE_MATCH(xXFixesGetCursorImageAndNameReq);
+ pCursor = CursorCurrent;
+ if (!pCursor)
+ return BadCursor;
+ GetSpritePosition (&x, &y);
+ width = pCursor->bits->width;
+ height = pCursor->bits->height;
+ npixels = width * height;
+ name = pCursor->name ? NameForAtom (pCursor->name) : "";
+ nbytes = strlen (name);
+ nbytesRound = (nbytes + 3) & ~3;
+ rep = xalloc (sizeof (xXFixesGetCursorImageAndNameReply) +
+ npixels * sizeof (CARD32) + nbytesRound);
+ if (!rep)
+ return BadAlloc;
+
+ rep->type = X_Reply;
+ rep->sequenceNumber = client->sequence;
+ rep->length = npixels + (nbytesRound >> 2);
+ rep->width = width;
+ rep->height = height;
+ rep->x = x;
+ rep->y = y;
+ rep->xhot = pCursor->bits->xhot;
+ rep->yhot = pCursor->bits->yhot;
+ rep->cursorSerial = pCursor->serialNumber;
+ rep->cursorName = pCursor->name;
+ rep->nbytes = nbytes;
+
+ image = (CARD32 *) (rep + 1);
+ CopyCursorToImage (pCursor, image);
+ memcpy ((image + npixels), name, nbytes);
+ if (client->swapped)
+ {
+ int n;
+ swaps (&rep->sequenceNumber, n);
+ swapl (&rep->length, n);
+ swaps (&rep->x, n);
+ swaps (&rep->y, n);
+ swaps (&rep->width, n);
+ swaps (&rep->height, n);
+ swaps (&rep->xhot, n);
+ swaps (&rep->yhot, n);
+ swapl (&rep->cursorSerial, n);
+ swapl (&rep->cursorName, n);
+ swaps (&rep->nbytes, n);
+ SwapLongs (image, npixels);
+ }
+ (void) WriteToClient(client, sizeof (xXFixesGetCursorImageAndNameReply) +
+ (npixels << 2) + nbytesRound, (char *) rep);
+ xfree (rep);
+ return client->noClientException;
+}
+
+int
+SProcXFixesGetCursorImageAndName (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesGetCursorImageAndNameReq);
+ swaps (&stuff->length, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+/*
+ * Find every cursor reference in the system, ask testCursor
+ * whether it should be replaced with a reference to pCursor.
+ */
+
+typedef Bool (*TestCursorFunc) (CursorPtr pOld, pointer closure);
+
+typedef struct {
+ RESTYPE type;
+ TestCursorFunc testCursor;
+ CursorPtr pNew;
+ pointer closure;
+} ReplaceCursorLookupRec, *ReplaceCursorLookupPtr;
+
+static const RESTYPE CursorRestypes[] = {
+ RT_WINDOW, RT_PASSIVEGRAB, RT_CURSOR
+};
+
+#define NUM_CURSOR_RESTYPES (sizeof (CursorRestypes) / sizeof (CursorRestypes[0]))
+
+static Bool
+ReplaceCursorLookup (pointer value, XID id, pointer closure)
+{
+ ReplaceCursorLookupPtr rcl = (ReplaceCursorLookupPtr) closure;
+ WindowPtr pWin;
+ GrabPtr pGrab;
+ CursorPtr pCursor = 0, *pCursorRef = 0;
+ XID cursor = 0;
+
+ switch (rcl->type) {
+ case RT_WINDOW:
+ pWin = (WindowPtr) value;
+ if (pWin->optional)
+ {
+ pCursorRef = &pWin->optional->cursor;
+ pCursor = *pCursorRef;
+ }
+ break;
+ case RT_PASSIVEGRAB:
+ pGrab = (GrabPtr) value;
+ pCursorRef = &pGrab->cursor;
+ pCursor = *pCursorRef;
+ break;
+ case RT_CURSOR:
+ pCursorRef = 0;
+ pCursor = (CursorPtr) value;
+ cursor = id;
+ break;
+ }
+ if (pCursor && pCursor != rcl->pNew)
+ {
+ if ((*rcl->testCursor) (pCursor, rcl->closure))
+ {
+ rcl->pNew->refcnt++;
+ /* either redirect reference or update resource database */
+ if (pCursorRef)
+ *pCursorRef = rcl->pNew;
+ else
+ ChangeResourceValue (id, RT_CURSOR, rcl->pNew);
+ FreeCursor (pCursor, cursor);
+ }
+ }
+ return FALSE; /* keep walking */
+}
+
+static void
+ReplaceCursor (CursorPtr pCursor,
+ TestCursorFunc testCursor,
+ pointer closure)
+{
+ int clientIndex;
+ int resIndex;
+ ReplaceCursorLookupRec rcl;
+
+ /*
+ * Cursors exist only in the resource database, windows and grabs.
+ * All of these are always pointed at by the resource database. Walk
+ * the whole thing looking for cursors
+ */
+ rcl.testCursor = testCursor;
+ rcl.pNew = pCursor;
+ rcl.closure = closure;
+
+ /* for each client */
+ for (clientIndex = 0; clientIndex < currentMaxClients; clientIndex++)
+ {
+ if (!clients[clientIndex])
+ continue;
+ for (resIndex = 0; resIndex < NUM_CURSOR_RESTYPES; resIndex++)
+ {
+ rcl.type = CursorRestypes[resIndex];
+ /*
+ * This function walks the entire client resource database
+ */
+ LookupClientResourceComplex (clients[clientIndex],
+ rcl.type,
+ ReplaceCursorLookup,
+ (pointer) &rcl);
+ }
+ }
+ /* this "knows" that WindowHasNewCursor doesn't depend on it's argument */
+ WindowHasNewCursor (WindowTable[0]);
+}
+
+static Bool
+TestForCursor (CursorPtr pCursor, pointer closure)
+{
+ return (pCursor == (CursorPtr) closure);
+}
+
+int
+ProcXFixesChangeCursor (ClientPtr client)
+{
+ CursorPtr pSource, pDestination;
+ REQUEST(xXFixesChangeCursorReq);
+
+ REQUEST_SIZE_MATCH(xXFixesChangeCursorReq);
+ VERIFY_CURSOR (pSource, stuff->source, client, SecurityReadAccess);
+ VERIFY_CURSOR (pDestination, stuff->destination, client, SecurityWriteAccess);
+
+ ReplaceCursor (pSource, TestForCursor, (pointer) pDestination);
+ return (client->noClientException);
+}
+
+int
+SProcXFixesChangeCursor (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesChangeCursorReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXFixesChangeCursorReq);
+ swapl (&stuff->source, n);
+ swapl (&stuff->destination, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+static Bool
+TestForCursorName (CursorPtr pCursor, pointer closure)
+{
+ return (pCursor->name == (Atom) closure);
+}
+
+int
+ProcXFixesChangeCursorByName (ClientPtr client)
+{
+ CursorPtr pSource;
+ Atom name;
+ char *tchar;
+ REQUEST(xXFixesChangeCursorByNameReq);
+
+ REQUEST_FIXED_SIZE(xXFixesChangeCursorByNameReq, stuff->nbytes);
+ VERIFY_CURSOR(pSource, stuff->source, client, SecurityReadAccess);
+ tchar = (char *) &stuff[1];
+ name = MakeAtom (tchar, stuff->nbytes, FALSE);
+ if (name)
+ ReplaceCursor (pSource, TestForCursorName, (pointer) name);
+ return (client->noClientException);
+}
+
+int
+SProcXFixesChangeCursorByName (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesChangeCursorByNameReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE (xXFixesChangeCursorByNameReq);
+ swapl (&stuff->source, n);
+ swaps (&stuff->nbytes, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+static int
+CursorFreeClient (pointer data, XID id)
+{
+ CursorEventPtr old = (CursorEventPtr) data;
+ CursorEventPtr *prev, e;
+
+ for (prev = &cursorEvents; (e = *prev); prev = &e->next)
+ {
+ if (e == old)
+ {
+ *prev = e->next;
+ xfree (e);
+ break;
+ }
+ }
+ return 1;
+}
+
+static int
+CursorFreeWindow (pointer data, XID id)
+{
+ WindowPtr pWindow = (WindowPtr) data;
+ CursorEventPtr e, next;
+
+ for (e = cursorEvents; e; e = next)
+ {
+ next = e->next;
+ if (e->pWindow == pWindow)
+ {
+ FreeResource (e->clientResource, 0);
+ }
+ }
+ return 1;
+}
+
+Bool
+XFixesCursorInit (void)
+{
+ int i;
+
+ if (CursorGeneration != serverGeneration)
+ {
+ CursorScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ if (CursorScreenPrivateIndex < 0)
+ return FALSE;
+ CursorGeneration = serverGeneration;
+ }
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ CursorScreenPtr cs;
+
+ cs = (CursorScreenPtr) xalloc (sizeof (CursorScreenRec));
+ if (!cs)
+ return FALSE;
+ Wrap (cs, pScreen, CloseScreen, CursorCloseScreen);
+ Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
+ SetCursorScreen (pScreen, cs);
+ }
+ CursorClientType = CreateNewResourceType(CursorFreeClient);
+ CursorWindowType = CreateNewResourceType(CursorFreeWindow);
+ return CursorClientType && CursorWindowType;
+}
+
diff --git a/nx-X11/programs/Xserver/xfixes/cursor.c.X.original b/nx-X11/programs/Xserver/xfixes/cursor.c.X.original
new file mode 100755
index 000000000..bcc1ab962
--- /dev/null
+++ b/nx-X11/programs/Xserver/xfixes/cursor.c.X.original
@@ -0,0 +1,753 @@
+/*
+ * $Id: cursor.c,v 1.6 2005/07/03 07:37:35 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xfixesint.h"
+#include "scrnintstr.h"
+#include "cursorstr.h"
+#include "dixevents.h"
+#include "servermd.h"
+#include "inputstr.h"
+#include "windowstr.h"
+
+static RESTYPE CursorClientType;
+static RESTYPE CursorWindowType;
+static int CursorScreenPrivateIndex = -1;
+static int CursorGeneration;
+static CursorPtr CursorCurrent;
+
+#define VERIFY_CURSOR(pCursor, cursor, client, access) { \
+ pCursor = (CursorPtr)SecurityLookupIDByType((client), (cursor), \
+ RT_CURSOR, (access)); \
+ if (!pCursor) { \
+ (client)->errorValue = (cursor); \
+ return BadCursor; \
+ } \
+}
+
+/*
+ * There is a global list of windows selecting for cursor events
+ */
+
+typedef struct _CursorEvent *CursorEventPtr;
+
+typedef struct _CursorEvent {
+ CursorEventPtr next;
+ CARD32 eventMask;
+ ClientPtr pClient;
+ WindowPtr pWindow;
+ XID clientResource;
+} CursorEventRec;
+
+static CursorEventPtr cursorEvents;
+
+/*
+ * Wrap DisplayCursor to catch cursor change events
+ */
+
+typedef struct _CursorScreen {
+ DisplayCursorProcPtr DisplayCursor;
+ CloseScreenProcPtr CloseScreen;
+} CursorScreenRec, *CursorScreenPtr;
+
+#define GetCursorScreen(s) ((CursorScreenPtr) ((s)->devPrivates[CursorScreenPrivateIndex].ptr))
+#define GetCursorScreenIfSet(s) ((CursorScreenPrivateIndex != -1) ? GetCursorScreen(s) : NULL)
+#define SetCursorScreen(s,p) ((s)->devPrivates[CursorScreenPrivateIndex].ptr = (pointer) (p))
+#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
+#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
+
+static Bool
+CursorDisplayCursor (ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ CursorScreenPtr cs = GetCursorScreen(pScreen);
+ Bool ret;
+
+ Unwrap (cs, pScreen, DisplayCursor);
+ ret = (*pScreen->DisplayCursor) (pScreen, pCursor);
+ if (pCursor != CursorCurrent)
+ {
+ CursorEventPtr e;
+
+ CursorCurrent = pCursor;
+ for (e = cursorEvents; e; e = e->next)
+ {
+ if (e->eventMask & XFixesDisplayCursorNotifyMask)
+ {
+ xXFixesCursorNotifyEvent ev;
+ ev.type = XFixesEventBase + XFixesCursorNotify;
+ ev.subtype = XFixesDisplayCursorNotify;
+ ev.sequenceNumber = e->pClient->sequence;
+ ev.window = e->pWindow->drawable.id;
+ ev.cursorSerial = pCursor->serialNumber;
+ ev.timestamp = currentTime.milliseconds;
+ ev.name = pCursor->name;
+ WriteEventsToClient (e->pClient, 1, (xEvent *) &ev);
+ }
+ }
+ }
+ Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
+ return ret;
+}
+
+static Bool
+CursorCloseScreen (int index, ScreenPtr pScreen)
+{
+ CursorScreenPtr cs = GetCursorScreen (pScreen);
+ Bool ret;
+
+ Unwrap (cs, pScreen, CloseScreen);
+ Unwrap (cs, pScreen, DisplayCursor);
+ ret = (*pScreen->CloseScreen) (index, pScreen);
+ xfree (cs);
+ if (index == 0)
+ CursorScreenPrivateIndex = -1;
+ return ret;
+}
+
+#define CursorAllEvents (XFixesDisplayCursorNotifyMask)
+
+static int
+XFixesSelectCursorInput (ClientPtr pClient,
+ WindowPtr pWindow,
+ CARD32 eventMask)
+{
+ CursorEventPtr *prev, e;
+
+ for (prev = &cursorEvents; (e = *prev); prev = &e->next)
+ {
+ if (e->pClient == pClient &&
+ e->pWindow == pWindow)
+ {
+ break;
+ }
+ }
+ if (!eventMask)
+ {
+ if (e)
+ {
+ FreeResource (e->clientResource, 0);
+ }
+ return Success;
+ }
+ if (!e)
+ {
+ e = (CursorEventPtr) xalloc (sizeof (CursorEventRec));
+ if (!e)
+ return BadAlloc;
+
+ e->next = 0;
+ e->pClient = pClient;
+ e->pWindow = pWindow;
+ e->clientResource = FakeClientID(pClient->index);
+
+ /*
+ * Add a resource hanging from the window to
+ * catch window destroy
+ */
+ if (!LookupIDByType(pWindow->drawable.id, CursorWindowType))
+ if (!AddResource (pWindow->drawable.id, CursorWindowType,
+ (pointer) pWindow))
+ {
+ xfree (e);
+ return BadAlloc;
+ }
+
+ if (!AddResource (e->clientResource, CursorClientType, (pointer) e))
+ return BadAlloc;
+
+ *prev = e;
+ }
+ e->eventMask = eventMask;
+ return Success;
+}
+
+int
+ProcXFixesSelectCursorInput (ClientPtr client)
+{
+ REQUEST (xXFixesSelectCursorInputReq);
+ WindowPtr pWin;
+
+ REQUEST_SIZE_MATCH (xXFixesSelectCursorInputReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ if (stuff->eventMask & ~CursorAllEvents)
+ {
+ client->errorValue = stuff->eventMask;
+ return( BadValue );
+ }
+ return XFixesSelectCursorInput (client, pWin, stuff->eventMask);
+}
+
+static int
+GetBit (unsigned char *line, int x)
+{
+ unsigned char mask;
+
+ if (screenInfo.bitmapBitOrder == LSBFirst)
+ mask = (1 << (x & 7));
+ else
+ mask = (0x80 >> (x & 7));
+ /* XXX assumes byte order is host byte order */
+ line += (x >> 3);
+ if (*line & mask)
+ return 1;
+ return 0;
+}
+
+int
+SProcXFixesSelectCursorInput (ClientPtr client)
+{
+ register int n;
+ REQUEST(xXFixesSelectCursorInputReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ swapl(&stuff->eventMask, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+void
+SXFixesCursorNotifyEvent (xXFixesCursorNotifyEvent *from,
+ xXFixesCursorNotifyEvent *to)
+{
+ to->type = from->type;
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswapl (from->window, to->window);
+ cpswapl (from->cursorSerial, to->cursorSerial);
+ cpswapl (from->timestamp, to->timestamp);
+ cpswapl (from->name, to->name);
+}
+
+static void
+CopyCursorToImage (CursorPtr pCursor, CARD32 *image)
+{
+ int width = pCursor->bits->width;
+ int height = pCursor->bits->height;
+ int npixels = width * height;
+
+#ifdef ARGB_CURSOR
+ if (pCursor->bits->argb)
+ memcpy (image, pCursor->bits->argb, npixels * sizeof (CARD32));
+ else
+#endif
+ {
+ unsigned char *srcLine = pCursor->bits->source;
+ unsigned char *mskLine = pCursor->bits->mask;
+ int stride = BitmapBytePad (width);
+ int x, y;
+ CARD32 fg, bg;
+
+ fg = (0xff000000 |
+ ((pCursor->foreRed & 0xff00) << 8) |
+ (pCursor->foreGreen & 0xff00) |
+ (pCursor->foreBlue >> 8));
+ bg = (0xff000000 |
+ ((pCursor->backRed & 0xff00) << 8) |
+ (pCursor->backGreen & 0xff00) |
+ (pCursor->backBlue >> 8));
+ for (y = 0; y < height; y++)
+ {
+ for (x = 0; x < width; x++)
+ {
+ if (GetBit (mskLine, x))
+ {
+ if (GetBit (srcLine, x))
+ *image++ = fg;
+ else
+ *image++ = bg;
+ }
+ else
+ *image++ = 0;
+ }
+ srcLine += stride;
+ mskLine += stride;
+ }
+ }
+}
+
+int
+ProcXFixesGetCursorImage (ClientPtr client)
+{
+/* REQUEST(xXFixesGetCursorImageReq); */
+ xXFixesGetCursorImageReply *rep;
+ CursorPtr pCursor;
+ CARD32 *image;
+ int npixels;
+ int width, height;
+ int x, y;
+
+ REQUEST_SIZE_MATCH(xXFixesGetCursorImageReq);
+ pCursor = CursorCurrent;
+ if (!pCursor)
+ return BadCursor;
+ GetSpritePosition (&x, &y);
+ width = pCursor->bits->width;
+ height = pCursor->bits->height;
+ npixels = width * height;
+ rep = xalloc (sizeof (xXFixesGetCursorImageReply) +
+ npixels * sizeof (CARD32));
+ if (!rep)
+ return BadAlloc;
+
+ rep->type = X_Reply;
+ rep->sequenceNumber = client->sequence;
+ rep->length = npixels;
+ rep->width = width;
+ rep->height = height;
+ rep->x = x;
+ rep->y = y;
+ rep->xhot = pCursor->bits->xhot;
+ rep->yhot = pCursor->bits->yhot;
+ rep->cursorSerial = pCursor->serialNumber;
+
+ image = (CARD32 *) (rep + 1);
+ CopyCursorToImage (pCursor, image);
+ if (client->swapped)
+ {
+ int n;
+ swaps (&rep->sequenceNumber, n);
+ swapl (&rep->length, n);
+ swaps (&rep->x, n);
+ swaps (&rep->y, n);
+ swaps (&rep->width, n);
+ swaps (&rep->height, n);
+ swaps (&rep->xhot, n);
+ swaps (&rep->yhot, n);
+ swapl (&rep->cursorSerial, n);
+ SwapLongs (image, npixels);
+ }
+ (void) WriteToClient(client, sizeof (xXFixesGetCursorImageReply) +
+ (npixels << 2), (char *) rep);
+ xfree (rep);
+ return client->noClientException;
+}
+
+int
+SProcXFixesGetCursorImage (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesGetCursorImageReq);
+ swaps (&stuff->length, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesSetCursorName (ClientPtr client)
+{
+ CursorPtr pCursor;
+ char *tchar;
+ REQUEST(xXFixesSetCursorNameReq);
+ Atom atom;
+
+ REQUEST_AT_LEAST_SIZE(xXFixesSetCursorNameReq);
+ VERIFY_CURSOR(pCursor, stuff->cursor, client, SecurityWriteAccess);
+ tchar = (char *) &stuff[1];
+ atom = MakeAtom (tchar, stuff->nbytes, TRUE);
+ if (atom == BAD_RESOURCE)
+ return BadAlloc;
+
+ pCursor->name = atom;
+ return(client->noClientException);
+}
+
+int
+SProcXFixesSetCursorName (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesSetCursorNameReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXFixesSetCursorNameReq);
+ swapl (&stuff->cursor, n);
+ swaps (&stuff->nbytes, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesGetCursorName (ClientPtr client)
+{
+ CursorPtr pCursor;
+ xXFixesGetCursorNameReply reply;
+ REQUEST(xXFixesGetCursorNameReq);
+ char *str;
+ int len;
+
+ REQUEST_SIZE_MATCH(xXFixesGetCursorNameReq);
+ VERIFY_CURSOR(pCursor, stuff->cursor, client, SecurityReadAccess);
+ if (pCursor->name)
+ str = NameForAtom (pCursor->name);
+ else
+ str = "";
+ len = strlen (str);
+
+ reply.type = X_Reply;
+ reply.length = (len + 3) >> 2;
+ reply.sequenceNumber = client->sequence;
+ reply.atom = pCursor->name;
+ reply.nbytes = len;
+ if (client->swapped)
+ {
+ int n;
+ swaps (&reply.sequenceNumber, n);
+ swapl (&reply.length, n);
+ swapl (&reply.atom, n);
+ swaps (&reply.nbytes, n);
+ }
+ WriteReplyToClient(client, sizeof(xXFixesGetCursorNameReply), &reply);
+ (void)WriteToClient(client, len, str);
+
+ return(client->noClientException);
+}
+
+int
+SProcXFixesGetCursorName (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesSetCursorNameReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXFixesGetCursorNameReq);
+ swapl (&stuff->cursor, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesGetCursorImageAndName (ClientPtr client)
+{
+/* REQUEST(xXFixesGetCursorImageAndNameReq); */
+ xXFixesGetCursorImageAndNameReply *rep;
+ CursorPtr pCursor;
+ CARD32 *image;
+ int npixels;
+ char *name;
+ int nbytes, nbytesRound;
+ int width, height;
+ int x, y;
+
+ REQUEST_SIZE_MATCH(xXFixesGetCursorImageAndNameReq);
+ pCursor = CursorCurrent;
+ if (!pCursor)
+ return BadCursor;
+ GetSpritePosition (&x, &y);
+ width = pCursor->bits->width;
+ height = pCursor->bits->height;
+ npixels = width * height;
+ name = pCursor->name ? NameForAtom (pCursor->name) : "";
+ nbytes = strlen (name);
+ nbytesRound = (nbytes + 3) & ~3;
+ rep = xalloc (sizeof (xXFixesGetCursorImageAndNameReply) +
+ npixels * sizeof (CARD32) + nbytesRound);
+ if (!rep)
+ return BadAlloc;
+
+ rep->type = X_Reply;
+ rep->sequenceNumber = client->sequence;
+ rep->length = npixels + (nbytesRound >> 2);
+ rep->width = width;
+ rep->height = height;
+ rep->x = x;
+ rep->y = y;
+ rep->xhot = pCursor->bits->xhot;
+ rep->yhot = pCursor->bits->yhot;
+ rep->cursorSerial = pCursor->serialNumber;
+ rep->cursorName = pCursor->name;
+ rep->nbytes = nbytes;
+
+ image = (CARD32 *) (rep + 1);
+ CopyCursorToImage (pCursor, image);
+ memcpy ((image + npixels), name, nbytes);
+ if (client->swapped)
+ {
+ int n;
+ swaps (&rep->sequenceNumber, n);
+ swapl (&rep->length, n);
+ swaps (&rep->x, n);
+ swaps (&rep->y, n);
+ swaps (&rep->width, n);
+ swaps (&rep->height, n);
+ swaps (&rep->xhot, n);
+ swaps (&rep->yhot, n);
+ swapl (&rep->cursorSerial, n);
+ swapl (&rep->cursorName, n);
+ swaps (&rep->nbytes, n);
+ SwapLongs (image, npixels);
+ }
+ (void) WriteToClient(client, sizeof (xXFixesGetCursorImageAndNameReply) +
+ (npixels << 2) + nbytesRound, (char *) rep);
+ xfree (rep);
+ return client->noClientException;
+}
+
+int
+SProcXFixesGetCursorImageAndName (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesGetCursorImageAndNameReq);
+ swaps (&stuff->length, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+/*
+ * Find every cursor reference in the system, ask testCursor
+ * whether it should be replaced with a reference to pCursor.
+ */
+
+typedef Bool (*TestCursorFunc) (CursorPtr pOld, pointer closure);
+
+typedef struct {
+ RESTYPE type;
+ TestCursorFunc testCursor;
+ CursorPtr pNew;
+ pointer closure;
+} ReplaceCursorLookupRec, *ReplaceCursorLookupPtr;
+
+static const RESTYPE CursorRestypes[] = {
+ RT_WINDOW, RT_PASSIVEGRAB, RT_CURSOR
+};
+
+#define NUM_CURSOR_RESTYPES (sizeof (CursorRestypes) / sizeof (CursorRestypes[0]))
+
+static Bool
+ReplaceCursorLookup (pointer value, XID id, pointer closure)
+{
+ ReplaceCursorLookupPtr rcl = (ReplaceCursorLookupPtr) closure;
+ WindowPtr pWin;
+ GrabPtr pGrab;
+ CursorPtr pCursor = 0, *pCursorRef = 0;
+ XID cursor = 0;
+
+ switch (rcl->type) {
+ case RT_WINDOW:
+ pWin = (WindowPtr) value;
+ if (pWin->optional)
+ {
+ pCursorRef = &pWin->optional->cursor;
+ pCursor = *pCursorRef;
+ }
+ break;
+ case RT_PASSIVEGRAB:
+ pGrab = (GrabPtr) value;
+ pCursorRef = &pGrab->cursor;
+ pCursor = *pCursorRef;
+ break;
+ case RT_CURSOR:
+ pCursorRef = 0;
+ pCursor = (CursorPtr) value;
+ cursor = id;
+ break;
+ }
+ if (pCursor && pCursor != rcl->pNew)
+ {
+ if ((*rcl->testCursor) (pCursor, rcl->closure))
+ {
+ rcl->pNew->refcnt++;
+ /* either redirect reference or update resource database */
+ if (pCursorRef)
+ *pCursorRef = rcl->pNew;
+ else
+ ChangeResourceValue (id, RT_CURSOR, rcl->pNew);
+ FreeCursor (pCursor, cursor);
+ }
+ }
+ return FALSE; /* keep walking */
+}
+
+static void
+ReplaceCursor (CursorPtr pCursor,
+ TestCursorFunc testCursor,
+ pointer closure)
+{
+ int clientIndex;
+ int resIndex;
+ ReplaceCursorLookupRec rcl;
+
+ /*
+ * Cursors exist only in the resource database, windows and grabs.
+ * All of these are always pointed at by the resource database. Walk
+ * the whole thing looking for cursors
+ */
+ rcl.testCursor = testCursor;
+ rcl.pNew = pCursor;
+ rcl.closure = closure;
+
+ /* for each client */
+ for (clientIndex = 0; clientIndex < currentMaxClients; clientIndex++)
+ {
+ if (!clients[clientIndex])
+ continue;
+ for (resIndex = 0; resIndex < NUM_CURSOR_RESTYPES; resIndex++)
+ {
+ rcl.type = CursorRestypes[resIndex];
+ /*
+ * This function walks the entire client resource database
+ */
+ LookupClientResourceComplex (clients[clientIndex],
+ rcl.type,
+ ReplaceCursorLookup,
+ (pointer) &rcl);
+ }
+ }
+ /* this "knows" that WindowHasNewCursor doesn't depend on it's argument */
+ WindowHasNewCursor (WindowTable[0]);
+}
+
+static Bool
+TestForCursor (CursorPtr pCursor, pointer closure)
+{
+ return (pCursor == (CursorPtr) closure);
+}
+
+int
+ProcXFixesChangeCursor (ClientPtr client)
+{
+ CursorPtr pSource, pDestination;
+ REQUEST(xXFixesChangeCursorReq);
+
+ REQUEST_SIZE_MATCH(xXFixesChangeCursorReq);
+ VERIFY_CURSOR (pSource, stuff->source, client, SecurityReadAccess);
+ VERIFY_CURSOR (pDestination, stuff->destination, client, SecurityWriteAccess);
+
+ ReplaceCursor (pSource, TestForCursor, (pointer) pDestination);
+ return (client->noClientException);
+}
+
+int
+SProcXFixesChangeCursor (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesChangeCursorReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXFixesChangeCursorReq);
+ swapl (&stuff->source, n);
+ swapl (&stuff->destination, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+static Bool
+TestForCursorName (CursorPtr pCursor, pointer closure)
+{
+ return (pCursor->name == (Atom) closure);
+}
+
+int
+ProcXFixesChangeCursorByName (ClientPtr client)
+{
+ CursorPtr pSource;
+ Atom name;
+ char *tchar;
+ REQUEST(xXFixesChangeCursorByNameReq);
+
+ REQUEST_FIXED_SIZE(xXFixesChangeCursorByNameReq, stuff->nbytes);
+ VERIFY_CURSOR(pSource, stuff->source, client, SecurityReadAccess);
+ tchar = (char *) &stuff[1];
+ name = MakeAtom (tchar, stuff->nbytes, FALSE);
+ if (name)
+ ReplaceCursor (pSource, TestForCursorName, (pointer) name);
+ return (client->noClientException);
+}
+
+int
+SProcXFixesChangeCursorByName (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesChangeCursorByNameReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE (xXFixesChangeCursorByNameReq);
+ swapl (&stuff->source, n);
+ swaps (&stuff->nbytes, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+static int
+CursorFreeClient (pointer data, XID id)
+{
+ CursorEventPtr old = (CursorEventPtr) data;
+ CursorEventPtr *prev, e;
+
+ for (prev = &cursorEvents; (e = *prev); prev = &e->next)
+ {
+ if (e == old)
+ {
+ *prev = e->next;
+ xfree (e);
+ break;
+ }
+ }
+ return 1;
+}
+
+static int
+CursorFreeWindow (pointer data, XID id)
+{
+ WindowPtr pWindow = (WindowPtr) data;
+ CursorEventPtr e, next;
+
+ for (e = cursorEvents; e; e = next)
+ {
+ next = e->next;
+ if (e->pWindow == pWindow)
+ {
+ FreeResource (e->clientResource, 0);
+ }
+ }
+ return 1;
+}
+
+Bool
+XFixesCursorInit (void)
+{
+ int i;
+
+ if (CursorGeneration != serverGeneration)
+ {
+ CursorScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ if (CursorScreenPrivateIndex < 0)
+ return FALSE;
+ CursorGeneration = serverGeneration;
+ }
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ CursorScreenPtr cs;
+
+ cs = (CursorScreenPtr) xalloc (sizeof (CursorScreenRec));
+ if (!cs)
+ return FALSE;
+ Wrap (cs, pScreen, CloseScreen, CursorCloseScreen);
+ Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
+ SetCursorScreen (pScreen, cs);
+ }
+ CursorClientType = CreateNewResourceType(CursorFreeClient);
+ CursorWindowType = CreateNewResourceType(CursorFreeWindow);
+ return CursorClientType && CursorWindowType;
+}
+
diff --git a/nx-X11/programs/Xserver/xfixes/region.c b/nx-X11/programs/Xserver/xfixes/region.c
new file mode 100755
index 000000000..9ceff6d51
--- /dev/null
+++ b/nx-X11/programs/Xserver/xfixes/region.c
@@ -0,0 +1,864 @@
+/*
+ * $Id: region.c,v 1.7 2005/07/03 07:37:35 daniels Exp $
+ *
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xfixesint.h"
+#include "scrnintstr.h"
+#ifdef RENDER
+#include <picturestr.h>
+extern int RenderErrBase;
+#endif
+#include <regionstr.h>
+#include <gcstruct.h>
+#include <window.h>
+
+RESTYPE RegionResType;
+
+static int
+RegionResFree (pointer data, XID id)
+{
+ RegionPtr pRegion = (RegionPtr) data;
+
+ REGION_DESTROY (0, pRegion);
+ return Success;
+}
+
+RegionPtr
+XFixesRegionCopy (RegionPtr pRegion)
+{
+ RegionPtr pNew = REGION_CREATE (0, REGION_EXTENTS(0, pRegion),
+ REGION_NUM_RECTS(pRegion));
+ if (!pNew)
+ return 0;
+ if (!REGION_COPY (0, pNew, pRegion))
+ {
+ REGION_DESTROY (0, pNew);
+ return 0;
+ }
+ return pNew;
+}
+
+Bool
+XFixesRegionInit (void)
+{
+ RegionResType = CreateNewResourceType(RegionResFree);
+ return TRUE;
+}
+
+int
+ProcXFixesCreateRegion (ClientPtr client)
+{
+ int things;
+ RegionPtr pRegion;
+ REQUEST (xXFixesCreateRegionReq);
+
+ REQUEST_AT_LEAST_SIZE(xXFixesCreateRegionReq);
+ LEGAL_NEW_RESOURCE (stuff->region, client);
+
+ things = (client->req_len << 2) - sizeof (xXFixesCreateRegionReq);
+ if (things & 4)
+ return BadLength;
+ things >>= 3;
+
+ pRegion = RECTS_TO_REGION(0, things, (xRectangle *) (stuff + 1), CT_UNSORTED);
+ if (!pRegion)
+ return BadAlloc;
+ if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
+ return BadAlloc;
+
+ return(client->noClientException);
+}
+
+int
+SProcXFixesCreateRegion (ClientPtr client)
+{
+ register int n;
+ REQUEST(xXFixesCreateRegionReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXFixesCreateRegionReq);
+ swapl(&stuff->region, n);
+ SwapRestS(stuff);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesCreateRegionFromBitmap (ClientPtr client)
+{
+ RegionPtr pRegion;
+ PixmapPtr pPixmap;
+ REQUEST (xXFixesCreateRegionFromBitmapReq);
+
+ REQUEST_SIZE_MATCH (xXFixesCreateRegionFromBitmapReq);
+ LEGAL_NEW_RESOURCE (stuff->region, client);
+
+ pPixmap = (PixmapPtr) SecurityLookupIDByType (client, stuff->bitmap,
+ RT_PIXMAP,
+ SecurityReadAccess);
+ if (!pPixmap)
+ {
+ client->errorValue = stuff->bitmap;
+ return BadPixmap;
+ }
+ if (pPixmap->drawable.depth != 1)
+ return BadMatch;
+
+ pRegion = BITMAP_TO_REGION(pPixmap->drawable.pScreen, pPixmap);
+
+ if (!pRegion)
+ return BadAlloc;
+
+ if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
+ return BadAlloc;
+
+ return(client->noClientException);
+}
+
+int
+SProcXFixesCreateRegionFromBitmap (ClientPtr client)
+{
+ int n;
+ REQUEST (xXFixesCreateRegionFromBitmapReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xXFixesCreateRegionFromBitmapReq);
+ swapl(&stuff->region, n);
+ swapl(&stuff->bitmap, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesCreateRegionFromWindow (ClientPtr client)
+{
+ RegionPtr pRegion;
+ Bool copy = TRUE;
+ WindowPtr pWin;
+ REQUEST (xXFixesCreateRegionFromWindowReq);
+
+ REQUEST_SIZE_MATCH (xXFixesCreateRegionFromWindowReq);
+ LEGAL_NEW_RESOURCE (stuff->region, client);
+ pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
+ if (!pWin)
+ {
+ client->errorValue = stuff->window;
+ return BadWindow;
+ }
+ switch (stuff->kind) {
+ case WindowRegionBounding:
+#ifdef SHAPE
+ pRegion = wBoundingShape(pWin);
+ if (!pRegion)
+#endif
+ {
+ pRegion = CreateBoundingShape (pWin);
+ copy = FALSE;
+ }
+ break;
+ case WindowRegionClip:
+#ifdef SHAPE
+ pRegion = wClipShape(pWin);
+ if (!pRegion)
+#endif
+ {
+ pRegion = CreateClipShape (pWin);
+ copy = FALSE;
+ }
+ break;
+ default:
+ client->errorValue = stuff->kind;
+ return BadValue;
+ }
+ if (copy && pRegion)
+ pRegion = XFixesRegionCopy (pRegion);
+ if (!pRegion)
+ return BadAlloc;
+ if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
+ return BadAlloc;
+
+ return(client->noClientException);
+}
+
+int
+SProcXFixesCreateRegionFromWindow (ClientPtr client)
+{
+ int n;
+ REQUEST (xXFixesCreateRegionFromWindowReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xXFixesCreateRegionFromWindowReq);
+ swapl(&stuff->region, n);
+ swapl(&stuff->window, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesCreateRegionFromGC (ClientPtr client)
+{
+ RegionPtr pRegion, pClip;
+ GCPtr pGC;
+ REQUEST (xXFixesCreateRegionFromGCReq);
+
+ REQUEST_SIZE_MATCH (xXFixesCreateRegionFromGCReq);
+ LEGAL_NEW_RESOURCE (stuff->region, client);
+
+ SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityReadAccess);
+
+ switch (pGC->clientClipType) {
+ case CT_PIXMAP:
+ pRegion = BITMAP_TO_REGION(pGC->pScreen, (PixmapPtr) pGC->clientClip);
+ if (!pRegion)
+ return BadAlloc;
+ break;
+ case CT_REGION:
+ pClip = (RegionPtr) pGC->clientClip;
+ pRegion = XFixesRegionCopy (pClip);
+ if (!pRegion)
+ return BadAlloc;
+ break;
+ default:
+ return BadImplementation; /* assume sane server bits */
+ }
+
+ if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
+ return BadAlloc;
+
+ return(client->noClientException);
+}
+
+int
+SProcXFixesCreateRegionFromGC (ClientPtr client)
+{
+ int n;
+ REQUEST (xXFixesCreateRegionFromGCReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xXFixesCreateRegionFromGCReq);
+ swapl(&stuff->region, n);
+ swapl(&stuff->gc, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesCreateRegionFromPicture (ClientPtr client)
+{
+#ifdef RENDER
+ RegionPtr pRegion;
+ PicturePtr pPicture;
+ REQUEST (xXFixesCreateRegionFromPictureReq);
+
+ REQUEST_SIZE_MATCH (xXFixesCreateRegionFromPictureReq);
+ LEGAL_NEW_RESOURCE (stuff->region, client);
+
+ VERIFY_PICTURE(pPicture, stuff->picture, client, SecurityReadAccess,
+ RenderErrBase + BadPicture);
+
+ switch (pPicture->clientClipType) {
+ case CT_PIXMAP:
+ pRegion = BITMAP_TO_REGION(pPicture->pDrawable->pScreen,
+ (PixmapPtr) pPicture->clientClip);
+ if (!pRegion)
+ return BadAlloc;
+ break;
+ case CT_REGION:
+ pRegion = XFixesRegionCopy ((RegionPtr) pPicture->clientClip);
+ if (!pRegion)
+ return BadAlloc;
+ break;
+ default:
+ return BadImplementation; /* assume sane server bits */
+ }
+
+ if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
+ return BadAlloc;
+
+ return(client->noClientException);
+#else
+ return BadRequest;
+#endif
+}
+
+int
+SProcXFixesCreateRegionFromPicture (ClientPtr client)
+{
+ int n;
+ REQUEST (xXFixesCreateRegionFromPictureReq);
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xXFixesCreateRegionFromPictureReq);
+ swapl(&stuff->region, n);
+ swapl(&stuff->picture, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesDestroyRegion (ClientPtr client)
+{
+ REQUEST (xXFixesDestroyRegionReq);
+ RegionPtr pRegion;
+
+ REQUEST_SIZE_MATCH(xXFixesDestroyRegionReq);
+ VERIFY_REGION(pRegion, stuff->region, client, SecurityWriteAccess);
+ FreeResource (stuff->region, RT_NONE);
+ return(client->noClientException);
+}
+
+int
+SProcXFixesDestroyRegion (ClientPtr client)
+{
+ int n;
+ REQUEST (xXFixesDestroyRegionReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXFixesDestroyRegionReq);
+ swapl (&stuff->region, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesSetRegion (ClientPtr client)
+{
+ int things;
+ RegionPtr pRegion, pNew;
+ REQUEST (xXFixesSetRegionReq);
+
+ REQUEST_AT_LEAST_SIZE(xXFixesSetRegionReq);
+ VERIFY_REGION(pRegion, stuff->region, client, SecurityWriteAccess);
+
+ things = (client->req_len << 2) - sizeof (xXFixesCreateRegionReq);
+ if (things & 4)
+ return BadLength;
+ things >>= 3;
+
+ pNew = RECTS_TO_REGION(0, things, (xRectangle *) (stuff + 1), CT_UNSORTED);
+ if (!pNew)
+ return BadAlloc;
+ if (!REGION_COPY (0, pRegion, pNew))
+ {
+ REGION_DESTROY (0, pNew);
+ return BadAlloc;
+ }
+ REGION_DESTROY (0, pNew);
+ return(client->noClientException);
+}
+
+int
+SProcXFixesSetRegion (ClientPtr client)
+{
+ int n;
+ REQUEST (xXFixesSetRegionReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXFixesSetRegionReq);
+ swapl (&stuff->region, n);
+ SwapRestS(stuff);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesCopyRegion (ClientPtr client)
+{
+ RegionPtr pSource, pDestination;
+ REQUEST (xXFixesCopyRegionReq);
+
+ VERIFY_REGION(pSource, stuff->source, client, SecurityReadAccess);
+ VERIFY_REGION(pDestination, stuff->destination, client, SecurityWriteAccess);
+
+ if (!REGION_COPY(pScreen, pDestination, pSource))
+ return BadAlloc;
+
+ return(client->noClientException);
+}
+
+int
+SProcXFixesCopyRegion (ClientPtr client)
+{
+ int n;
+ REQUEST (xXFixesCopyRegionReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xXFixesCopyRegionReq);
+ swapl (&stuff->source, n);
+ swapl (&stuff->destination, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesCombineRegion (ClientPtr client)
+{
+ RegionPtr pSource1, pSource2, pDestination;
+ int ret = Success;
+ REQUEST (xXFixesCombineRegionReq);
+
+ REQUEST_SIZE_MATCH (xXFixesCombineRegionReq);
+ VERIFY_REGION(pSource1, stuff->source1, client, SecurityReadAccess);
+ VERIFY_REGION(pSource2, stuff->source2, client, SecurityReadAccess);
+ VERIFY_REGION(pDestination, stuff->destination, client, SecurityWriteAccess);
+
+ switch (stuff->xfixesReqType) {
+ case X_XFixesUnionRegion:
+ if (!REGION_UNION (0, pDestination, pSource1, pSource2))
+ ret = BadAlloc;
+ break;
+ case X_XFixesIntersectRegion:
+ if (!REGION_INTERSECT (0, pDestination, pSource1, pSource2))
+ ret = BadAlloc;
+ break;
+ case X_XFixesSubtractRegion:
+ if (!REGION_SUBTRACT (0, pDestination, pSource1, pSource2))
+ ret = BadAlloc;
+ break;
+ }
+
+ if (ret == Success)
+ ret = client->noClientException;
+ return ret;
+}
+
+int
+SProcXFixesCombineRegion (ClientPtr client)
+{
+ int n;
+ REQUEST (xXFixesCombineRegionReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH (xXFixesCombineRegionReq);
+ swapl (&stuff->source1, n);
+ swapl (&stuff->source2, n);
+ swapl (&stuff->destination, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesInvertRegion (ClientPtr client)
+{
+ RegionPtr pSource, pDestination;
+ BoxRec bounds;
+ int ret = Success;
+ REQUEST(xXFixesInvertRegionReq);
+
+ REQUEST_SIZE_MATCH(xXFixesInvertRegionReq);
+ VERIFY_REGION(pSource, stuff->source, client, SecurityReadAccess);
+ VERIFY_REGION(pDestination, stuff->destination, client, SecurityWriteAccess);
+
+ /* Compute bounds, limit to 16 bits */
+ bounds.x1 = stuff->x;
+ bounds.y1 = stuff->y;
+ if ((int) stuff->x + (int) stuff->width > MAXSHORT)
+ bounds.x2 = MAXSHORT;
+ else
+ bounds.x2 = stuff->x + stuff->width;
+
+ if ((int) stuff->y + (int) stuff->height > MAXSHORT)
+ bounds.y2 = MAXSHORT;
+ else
+ bounds.y2 = stuff->y + stuff->height;
+
+ if (!REGION_INVERSE(0, pDestination, pSource, &bounds))
+ ret = BadAlloc;
+
+ if (ret == Success)
+ ret = client->noClientException;
+ return ret;
+}
+
+int
+SProcXFixesInvertRegion (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesInvertRegionReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXFixesInvertRegionReq);
+ swapl (&stuff->source, n);
+ swaps (&stuff->x, n);
+ swaps (&stuff->y, n);
+ swaps (&stuff->width, n);
+ swaps (&stuff->height, n);
+ swapl (&stuff->destination, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesTranslateRegion (ClientPtr client)
+{
+ RegionPtr pRegion;
+ REQUEST(xXFixesTranslateRegionReq);
+
+ REQUEST_SIZE_MATCH(xXFixesTranslateRegionReq);
+ VERIFY_REGION(pRegion, stuff->region, client, SecurityWriteAccess);
+
+ REGION_TRANSLATE(pScreen, pRegion, stuff->dx, stuff->dy);
+ return (client->noClientException);
+}
+
+int
+SProcXFixesTranslateRegion (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesTranslateRegionReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXFixesTranslateRegionReq);
+ swapl (&stuff->region, n);
+ swaps (&stuff->dx, n);
+ swaps (&stuff->dy, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesRegionExtents (ClientPtr client)
+{
+ RegionPtr pSource, pDestination;
+ REQUEST(xXFixesRegionExtentsReq);
+
+ REQUEST_SIZE_MATCH(xXFixesRegionExtentsReq);
+ VERIFY_REGION(pSource, stuff->source, client, SecurityReadAccess);
+ VERIFY_REGION(pDestination, stuff->destination, client, SecurityWriteAccess);
+
+ REGION_RESET (0, pDestination, REGION_EXTENTS (0, pSource));
+
+ return (client->noClientException);
+}
+
+int
+SProcXFixesRegionExtents (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesRegionExtentsReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXFixesRegionExtentsReq);
+ swapl (&stuff->source, n);
+ swapl (&stuff->destination, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesFetchRegion (ClientPtr client)
+{
+ RegionPtr pRegion;
+ xXFixesFetchRegionReply *reply;
+ xRectangle *pRect;
+ BoxPtr pExtent;
+ BoxPtr pBox;
+ int i, nBox;
+ REQUEST(xXFixesFetchRegionReq);
+
+ REQUEST_SIZE_MATCH(xXFixesFetchRegionReq);
+ VERIFY_REGION(pRegion, stuff->region, client, SecurityReadAccess);
+
+ pExtent = REGION_EXTENTS (0, pRegion);
+ pBox = REGION_RECTS (pRegion);
+ nBox = REGION_NUM_RECTS (pRegion);
+
+ reply = xalloc (sizeof (xXFixesFetchRegionReply) +
+ nBox * sizeof (xRectangle));
+ if (!reply)
+ return BadAlloc;
+ reply->type = X_Reply;
+ reply->sequenceNumber = client->sequence;
+ reply->length = nBox << 1;
+ reply->x = pExtent->x1;
+ reply->y = pExtent->y1;
+ reply->width = pExtent->x2 - pExtent->x1;
+ reply->height = pExtent->y2 - pExtent->y1;
+
+ pRect = (xRectangle *) (reply + 1);
+ for (i = 0; i < nBox; i++)
+ {
+ pRect[i].x = pBox[i].x1;
+ pRect[i].y = pBox[i].y1;
+ pRect[i].width = pBox[i].x2 - pBox[i].x1;
+ pRect[i].height = pBox[i].y2 - pBox[i].y1;
+ }
+ if (client->swapped)
+ {
+ int n;
+ swaps (&reply->sequenceNumber, n);
+ swapl (&reply->length, n);
+ swaps (&reply->x, n);
+ swaps (&reply->y, n);
+ swaps (&reply->width, n);
+ swaps (&reply->height, n);
+ SwapShorts ((INT16 *) pRect, nBox * 4);
+ }
+ (void) WriteToClient(client, sizeof (xXFixesFetchRegionReply) +
+ nBox * sizeof (xRectangle), (char *) reply);
+ xfree (reply);
+ return (client->noClientException);
+}
+
+int
+SProcXFixesFetchRegion (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesFetchRegionReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXFixesFetchRegionReq);
+ swapl (&stuff->region, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesSetGCClipRegion (ClientPtr client)
+{
+ GCPtr pGC;
+ RegionPtr pRegion;
+ XID vals[2];
+ REQUEST(xXFixesSetGCClipRegionReq);
+
+ REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq);
+ SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityWriteAccess);
+ VERIFY_REGION_OR_NONE (pRegion, stuff->region, client, SecurityReadAccess);
+
+ if (pRegion)
+ {
+ pRegion = XFixesRegionCopy (pRegion);
+ if (!pRegion)
+ return BadAlloc;
+ }
+
+ vals[0] = stuff->xOrigin;
+ vals[1] = stuff->yOrigin;
+ DoChangeGC (pGC, GCClipXOrigin|GCClipYOrigin, vals, 0);
+ (*pGC->funcs->ChangeClip)(pGC, pRegion ? CT_REGION : CT_NONE, (pointer)pRegion, 0);
+
+ return (client->noClientException);
+}
+
+int
+SProcXFixesSetGCClipRegion (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesSetGCClipRegionReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq);
+ swapl (&stuff->gc, n);
+ swapl (&stuff->region, n);
+ swaps (&stuff->xOrigin, n);
+ swaps (&stuff->yOrigin, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+typedef RegionPtr (*CreateDftPtr)(WindowPtr pWin);
+
+int
+ProcXFixesSetWindowShapeRegion (ClientPtr client)
+{
+#ifdef SHAPE
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ RegionPtr pRegion;
+ RegionPtr *pDestRegion;
+ REQUEST(xXFixesSetWindowShapeRegionReq);
+
+ REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq);
+ pWin = (WindowPtr) LookupIDByType (stuff->dest, RT_WINDOW);
+ if (!pWin)
+ {
+ client->errorValue = stuff->dest;
+ return BadWindow;
+ }
+ VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, SecurityWriteAccess);
+ pScreen = pWin->drawable.pScreen;
+ switch (stuff->destKind) {
+ case ShapeBounding:
+ case ShapeClip:
+ case ShapeInput:
+ break;
+ default:
+ client->errorValue = stuff->destKind;
+ return BadValue;
+ }
+ if (pRegion)
+ {
+ pRegion = XFixesRegionCopy (pRegion);
+ if (!pRegion)
+ return BadAlloc;
+ if (!pWin->optional)
+ MakeWindowOptional (pWin);
+ switch (stuff->destKind) {
+ default:
+ case ShapeBounding:
+ pDestRegion = &pWin->optional->boundingShape;
+ break;
+ case ShapeClip:
+ pDestRegion = &pWin->optional->clipShape;
+ break;
+ case ShapeInput:
+ pDestRegion = &pWin->optional->inputShape;
+ break;
+ }
+ if (stuff->xOff || stuff->yOff)
+ REGION_TRANSLATE (0, pRegion, stuff->xOff, stuff->yOff);
+ }
+ else
+ {
+ if (pWin->optional)
+ {
+ switch (stuff->destKind) {
+ default:
+ case ShapeBounding:
+ pDestRegion = &pWin->optional->boundingShape;
+ break;
+ case ShapeClip:
+ pDestRegion = &pWin->optional->clipShape;
+ break;
+ case ShapeInput:
+ pDestRegion = &pWin->optional->inputShape;
+ break;
+ }
+ }
+ else
+ pDestRegion = &pRegion; /* a NULL region pointer */
+ }
+ if (*pDestRegion)
+ REGION_DESTROY(pScreen, *pDestRegion);
+ *pDestRegion = pRegion;
+ (*pScreen->SetShape) (pWin);
+ SendShapeNotify (pWin, stuff->destKind);
+ return (client->noClientException);
+#else
+ return BadRequest;
+#endif
+}
+
+int
+SProcXFixesSetWindowShapeRegion (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesSetWindowShapeRegionReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq);
+ swapl (&stuff->dest, n);
+ swaps (&stuff->xOff, n);
+ swaps (&stuff->yOff, n);
+ swapl (&stuff->region, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesSetPictureClipRegion (ClientPtr client)
+{
+#ifdef RENDER
+ PicturePtr pPicture;
+ RegionPtr pRegion;
+ ScreenPtr pScreen;
+ PictureScreenPtr ps;
+ REQUEST(xXFixesSetPictureClipRegionReq);
+
+ REQUEST_SIZE_MATCH (xXFixesSetPictureClipRegionReq);
+ VERIFY_PICTURE(pPicture, stuff->picture, client, SecurityWriteAccess,
+ RenderErrBase + BadPicture);
+ pScreen = pPicture->pDrawable->pScreen;
+ ps = GetPictureScreen (pScreen);
+ VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, SecurityReadAccess);
+
+ return SetPictureClipRegion (pPicture, stuff->xOrigin, stuff->yOrigin,
+ pRegion);
+#else
+ return BadRequest;
+#endif
+}
+
+int
+SProcXFixesSetPictureClipRegion (ClientPtr client)
+{
+ int n;
+ REQUEST(xXFixesSetPictureClipRegionReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH (xXFixesSetPictureClipRegionReq);
+ swapl (&stuff->picture, n);
+ swapl (&stuff->region, n);
+ swaps (&stuff->xOrigin, n);
+ swaps (&stuff->yOrigin, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int
+ProcXFixesExpandRegion (ClientPtr client)
+{
+ RegionPtr pSource, pDestination;
+ int ret = Success;
+ REQUEST (xXFixesExpandRegionReq);
+ BoxPtr pTmp;
+ BoxPtr pSrc;
+ int nBoxes;
+ int i;
+
+ REQUEST_SIZE_MATCH (xXFixesExpandRegionReq);
+ VERIFY_REGION(pSource, stuff->source, client, SecurityReadAccess);
+ VERIFY_REGION(pDestination, stuff->destination, client, SecurityWriteAccess);
+
+ nBoxes = REGION_NUM_RECTS(pSource);
+ pSrc = REGION_RECTS(pSource);
+ if (nBoxes)
+ {
+ pTmp = xalloc (nBoxes * sizeof (BoxRec));
+ if (!pTmp)
+ return BadAlloc;
+ for (i = 0; i < nBoxes; i++)
+ {
+ pTmp[i].x1 = pSrc[i].x1 - stuff->left;
+ pTmp[i].x2 = pSrc[i].x2 + stuff->right;
+ pTmp[i].y1 = pSrc[i].y1 - stuff->top;
+ pTmp[i].y2 = pSrc[i].y2 + stuff->bottom;
+ }
+ REGION_EMPTY (pScreen, pDestination);
+ for (i = 0; i < nBoxes; i++)
+ {
+ RegionRec r;
+ REGION_INIT (pScreen, &r, &pTmp[i], 0);
+ REGION_UNION (pScreen, pDestination, pDestination, &r);
+ }
+ }
+ if (ret == Success)
+ ret = client->noClientException;
+ return ret;
+}
+
+int
+SProcXFixesExpandRegion (ClientPtr client)
+{
+ int n;
+ REQUEST (xXFixesExpandRegionReq);
+
+ swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH (xXFixesExpandRegionReq);
+ swapl (&stuff->source, n);
+ swapl (&stuff->destination, n);
+ swaps (&stuff->left, n);
+ swaps (&stuff->right, n);
+ swaps (&stuff->top, n);
+ swaps (&stuff->bottom, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
diff --git a/nx-X11/programs/Xserver/xfixes/saveset.c b/nx-X11/programs/Xserver/xfixes/saveset.c
new file mode 100755
index 000000000..934651218
--- /dev/null
+++ b/nx-X11/programs/Xserver/xfixes/saveset.c
@@ -0,0 +1,79 @@
+/*
+ * $Id: saveset.c,v 1.6 2005/07/03 07:37:35 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xfixesint.h"
+
+int
+ProcXFixesChangeSaveSet(ClientPtr client)
+{
+ Bool toRoot, remap;
+ int result;
+ WindowPtr pWin;
+ REQUEST(xXFixesChangeSaveSetReq);
+
+ REQUEST_SIZE_MATCH(xXFixesChangeSaveSetReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id)))
+ return BadMatch;
+ if ((stuff->mode != SetModeInsert) && (stuff->mode != SetModeDelete))
+ {
+ client->errorValue = stuff->mode;
+ return( BadValue );
+ }
+ if ((stuff->target != SaveSetNearest) && (stuff->target != SaveSetRoot))
+ {
+ client->errorValue = stuff->target;
+ return( BadValue );
+ }
+ if ((stuff->map != SaveSetMap) && (stuff->map != SaveSetUnmap))
+ {
+ client->errorValue = stuff->map;
+ return( BadValue );
+ }
+ toRoot = (stuff->target == SaveSetRoot);
+ remap = (stuff->map == SaveSetMap);
+ result = AlterSaveSetForClient(client, pWin, stuff->mode, toRoot, remap);
+ if (client->noClientException != Success)
+ return(client->noClientException);
+ else
+ return(result);
+}
+
+int
+SProcXFixesChangeSaveSet(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXFixesChangeSaveSetReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ return ProcXFixesChangeSaveSet(client);
+}
diff --git a/nx-X11/programs/Xserver/xfixes/select.c b/nx-X11/programs/Xserver/xfixes/select.c
new file mode 100755
index 000000000..c72e19e9a
--- /dev/null
+++ b/nx-X11/programs/Xserver/xfixes/select.c
@@ -0,0 +1,281 @@
+/*
+ * $Id: select.c,v 1.6 2005/07/03 07:37:35 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xfixesint.h"
+
+static RESTYPE SelectionClientType, SelectionWindowType;
+static Bool SelectionCallbackRegistered = FALSE;
+
+/*
+ * There is a global list of windows selecting for selection events
+ * on every selection. This should be plenty efficient for the
+ * expected usage, if it does become a problem, it should be easily
+ * replaced with a hash table of some kind keyed off the selection atom
+ */
+
+typedef struct _SelectionEvent *SelectionEventPtr;
+
+typedef struct _SelectionEvent {
+ SelectionEventPtr next;
+ Atom selection;
+ CARD32 eventMask;
+ ClientPtr pClient;
+ WindowPtr pWindow;
+ XID clientResource;
+} SelectionEventRec;
+
+static SelectionEventPtr selectionEvents;
+
+static void
+XFixesSelectionCallback (CallbackListPtr *callbacks, pointer data, pointer args)
+{
+ SelectionEventPtr e;
+ SelectionInfoRec *info = (SelectionInfoRec *) args;
+ Selection *selection = info->selection;
+ int subtype;
+ CARD32 eventMask;
+
+ switch (info->kind) {
+ case SelectionSetOwner:
+ subtype = XFixesSetSelectionOwnerNotify;
+ eventMask = XFixesSetSelectionOwnerNotifyMask;
+ break;
+ case SelectionWindowDestroy:
+ subtype = XFixesSelectionWindowDestroyNotify;
+ eventMask = XFixesSelectionWindowDestroyNotifyMask;
+ break;
+ case SelectionClientClose:
+ subtype = XFixesSelectionClientCloseNotify;
+ eventMask = XFixesSelectionClientCloseNotifyMask;
+ break;
+ default:
+ return;
+ }
+ for (e = selectionEvents; e; e = e->next)
+ {
+ if (e->selection == selection->selection &&
+ (e->eventMask & eventMask) &&
+ !e->pClient->clientGone)
+ {
+ xXFixesSelectionNotifyEvent ev;
+
+ ev.type = XFixesEventBase + XFixesSelectionNotify;
+ ev.subtype = subtype;
+ ev.sequenceNumber = e->pClient->sequence;
+ ev.window = e->pWindow->drawable.id;
+ if (subtype == XFixesSetSelectionOwnerNotify)
+ ev.owner = selection->window;
+ else
+ ev.owner = 0;
+ ev.selection = e->selection;
+ ev.timestamp = currentTime.milliseconds;
+ ev.selectionTimestamp = selection->lastTimeChanged.milliseconds;
+ WriteEventsToClient (e->pClient, 1, (xEvent *) &ev);
+ }
+ }
+}
+
+static Bool
+CheckSelectionCallback (void)
+{
+ if (selectionEvents)
+ {
+ if (!SelectionCallbackRegistered)
+ {
+ if (!AddCallback (&SelectionCallback, XFixesSelectionCallback, NULL))
+ return FALSE;
+ SelectionCallbackRegistered = TRUE;
+ }
+ }
+ else
+ {
+ if (SelectionCallbackRegistered)
+ {
+ DeleteCallback (&SelectionCallback, XFixesSelectionCallback, NULL);
+ SelectionCallbackRegistered = FALSE;
+ }
+ }
+ return TRUE;
+}
+
+#define SelectionAllEvents (XFixesSetSelectionOwnerNotifyMask |\
+ XFixesSelectionWindowDestroyNotifyMask |\
+ XFixesSelectionClientCloseNotifyMask)
+
+static int
+XFixesSelectSelectionInput (ClientPtr pClient,
+ Atom selection,
+ WindowPtr pWindow,
+ CARD32 eventMask)
+{
+ SelectionEventPtr *prev, e;
+
+ for (prev = &selectionEvents; (e = *prev); prev = &e->next)
+ {
+ if (e->selection == selection &&
+ e->pClient == pClient &&
+ e->pWindow == pWindow)
+ {
+ break;
+ }
+ }
+ if (!eventMask)
+ {
+ if (e)
+ {
+ FreeResource (e->clientResource, 0);
+ }
+ return Success;
+ }
+ if (!e)
+ {
+ e = (SelectionEventPtr) xalloc (sizeof (SelectionEventRec));
+ if (!e)
+ return BadAlloc;
+
+ e->next = 0;
+ e->selection = selection;
+ e->pClient = pClient;
+ e->pWindow = pWindow;
+ e->clientResource = FakeClientID(pClient->index);
+
+ /*
+ * Add a resource hanging from the window to
+ * catch window destroy
+ */
+ if (!LookupIDByType(pWindow->drawable.id, SelectionWindowType))
+ if (!AddResource (pWindow->drawable.id, SelectionWindowType,
+ (pointer) pWindow))
+ {
+ xfree (e);
+ return BadAlloc;
+ }
+
+ if (!AddResource (e->clientResource, SelectionClientType, (pointer) e))
+ return BadAlloc;
+
+ *prev = e;
+ if (!CheckSelectionCallback ())
+ {
+ FreeResource (e->clientResource, 0);
+ return BadAlloc;
+ }
+ }
+ e->eventMask = eventMask;
+ return Success;
+}
+
+int
+ProcXFixesSelectSelectionInput (ClientPtr client)
+{
+ REQUEST (xXFixesSelectSelectionInputReq);
+ WindowPtr pWin;
+
+ REQUEST_SIZE_MATCH (xXFixesSelectSelectionInputReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ if (stuff->eventMask & ~SelectionAllEvents)
+ {
+ client->errorValue = stuff->eventMask;
+ return( BadValue );
+ }
+ return XFixesSelectSelectionInput (client, stuff->selection,
+ pWin, stuff->eventMask);
+}
+
+int
+SProcXFixesSelectSelectionInput (ClientPtr client)
+{
+ register int n;
+ REQUEST(xXFixesSelectSelectionInputReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ swapl(&stuff->selection, n);
+ swapl(&stuff->eventMask, n);
+ return ProcXFixesSelectSelectionInput(client);
+}
+
+void
+SXFixesSelectionNotifyEvent (xXFixesSelectionNotifyEvent *from,
+ xXFixesSelectionNotifyEvent *to)
+{
+ to->type = from->type;
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswapl (from->window, to->window);
+ cpswapl (from->owner, to->owner);
+ cpswapl (from->selection, to->selection);
+ cpswapl (from->timestamp, to->timestamp);
+ cpswapl (from->selectionTimestamp, to->selectionTimestamp);
+}
+
+static int
+SelectionFreeClient (pointer data, XID id)
+{
+ SelectionEventPtr old = (SelectionEventPtr) data;
+ SelectionEventPtr *prev, e;
+
+ for (prev = &selectionEvents; (e = *prev); prev = &e->next)
+ {
+ if (e == old)
+ {
+ *prev = e->next;
+ xfree (e);
+ CheckSelectionCallback ();
+ break;
+ }
+ }
+ return 1;
+}
+
+static int
+SelectionFreeWindow (pointer data, XID id)
+{
+ WindowPtr pWindow = (WindowPtr) data;
+ SelectionEventPtr e, next;
+
+ for (e = selectionEvents; e; e = next)
+ {
+ next = e->next;
+ if (e->pWindow == pWindow)
+ {
+ FreeResource (e->clientResource, 0);
+ }
+ }
+ return 1;
+}
+
+Bool
+XFixesSelectionInit (void)
+{
+ SelectionClientType = CreateNewResourceType(SelectionFreeClient);
+ SelectionWindowType = CreateNewResourceType(SelectionFreeWindow);
+ return SelectionClientType && SelectionWindowType;
+}
diff --git a/nx-X11/programs/Xserver/xfixes/select.c.NX.original b/nx-X11/programs/Xserver/xfixes/select.c.NX.original
new file mode 100755
index 000000000..c72e19e9a
--- /dev/null
+++ b/nx-X11/programs/Xserver/xfixes/select.c.NX.original
@@ -0,0 +1,281 @@
+/*
+ * $Id: select.c,v 1.6 2005/07/03 07:37:35 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xfixesint.h"
+
+static RESTYPE SelectionClientType, SelectionWindowType;
+static Bool SelectionCallbackRegistered = FALSE;
+
+/*
+ * There is a global list of windows selecting for selection events
+ * on every selection. This should be plenty efficient for the
+ * expected usage, if it does become a problem, it should be easily
+ * replaced with a hash table of some kind keyed off the selection atom
+ */
+
+typedef struct _SelectionEvent *SelectionEventPtr;
+
+typedef struct _SelectionEvent {
+ SelectionEventPtr next;
+ Atom selection;
+ CARD32 eventMask;
+ ClientPtr pClient;
+ WindowPtr pWindow;
+ XID clientResource;
+} SelectionEventRec;
+
+static SelectionEventPtr selectionEvents;
+
+static void
+XFixesSelectionCallback (CallbackListPtr *callbacks, pointer data, pointer args)
+{
+ SelectionEventPtr e;
+ SelectionInfoRec *info = (SelectionInfoRec *) args;
+ Selection *selection = info->selection;
+ int subtype;
+ CARD32 eventMask;
+
+ switch (info->kind) {
+ case SelectionSetOwner:
+ subtype = XFixesSetSelectionOwnerNotify;
+ eventMask = XFixesSetSelectionOwnerNotifyMask;
+ break;
+ case SelectionWindowDestroy:
+ subtype = XFixesSelectionWindowDestroyNotify;
+ eventMask = XFixesSelectionWindowDestroyNotifyMask;
+ break;
+ case SelectionClientClose:
+ subtype = XFixesSelectionClientCloseNotify;
+ eventMask = XFixesSelectionClientCloseNotifyMask;
+ break;
+ default:
+ return;
+ }
+ for (e = selectionEvents; e; e = e->next)
+ {
+ if (e->selection == selection->selection &&
+ (e->eventMask & eventMask) &&
+ !e->pClient->clientGone)
+ {
+ xXFixesSelectionNotifyEvent ev;
+
+ ev.type = XFixesEventBase + XFixesSelectionNotify;
+ ev.subtype = subtype;
+ ev.sequenceNumber = e->pClient->sequence;
+ ev.window = e->pWindow->drawable.id;
+ if (subtype == XFixesSetSelectionOwnerNotify)
+ ev.owner = selection->window;
+ else
+ ev.owner = 0;
+ ev.selection = e->selection;
+ ev.timestamp = currentTime.milliseconds;
+ ev.selectionTimestamp = selection->lastTimeChanged.milliseconds;
+ WriteEventsToClient (e->pClient, 1, (xEvent *) &ev);
+ }
+ }
+}
+
+static Bool
+CheckSelectionCallback (void)
+{
+ if (selectionEvents)
+ {
+ if (!SelectionCallbackRegistered)
+ {
+ if (!AddCallback (&SelectionCallback, XFixesSelectionCallback, NULL))
+ return FALSE;
+ SelectionCallbackRegistered = TRUE;
+ }
+ }
+ else
+ {
+ if (SelectionCallbackRegistered)
+ {
+ DeleteCallback (&SelectionCallback, XFixesSelectionCallback, NULL);
+ SelectionCallbackRegistered = FALSE;
+ }
+ }
+ return TRUE;
+}
+
+#define SelectionAllEvents (XFixesSetSelectionOwnerNotifyMask |\
+ XFixesSelectionWindowDestroyNotifyMask |\
+ XFixesSelectionClientCloseNotifyMask)
+
+static int
+XFixesSelectSelectionInput (ClientPtr pClient,
+ Atom selection,
+ WindowPtr pWindow,
+ CARD32 eventMask)
+{
+ SelectionEventPtr *prev, e;
+
+ for (prev = &selectionEvents; (e = *prev); prev = &e->next)
+ {
+ if (e->selection == selection &&
+ e->pClient == pClient &&
+ e->pWindow == pWindow)
+ {
+ break;
+ }
+ }
+ if (!eventMask)
+ {
+ if (e)
+ {
+ FreeResource (e->clientResource, 0);
+ }
+ return Success;
+ }
+ if (!e)
+ {
+ e = (SelectionEventPtr) xalloc (sizeof (SelectionEventRec));
+ if (!e)
+ return BadAlloc;
+
+ e->next = 0;
+ e->selection = selection;
+ e->pClient = pClient;
+ e->pWindow = pWindow;
+ e->clientResource = FakeClientID(pClient->index);
+
+ /*
+ * Add a resource hanging from the window to
+ * catch window destroy
+ */
+ if (!LookupIDByType(pWindow->drawable.id, SelectionWindowType))
+ if (!AddResource (pWindow->drawable.id, SelectionWindowType,
+ (pointer) pWindow))
+ {
+ xfree (e);
+ return BadAlloc;
+ }
+
+ if (!AddResource (e->clientResource, SelectionClientType, (pointer) e))
+ return BadAlloc;
+
+ *prev = e;
+ if (!CheckSelectionCallback ())
+ {
+ FreeResource (e->clientResource, 0);
+ return BadAlloc;
+ }
+ }
+ e->eventMask = eventMask;
+ return Success;
+}
+
+int
+ProcXFixesSelectSelectionInput (ClientPtr client)
+{
+ REQUEST (xXFixesSelectSelectionInputReq);
+ WindowPtr pWin;
+
+ REQUEST_SIZE_MATCH (xXFixesSelectSelectionInputReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ if (stuff->eventMask & ~SelectionAllEvents)
+ {
+ client->errorValue = stuff->eventMask;
+ return( BadValue );
+ }
+ return XFixesSelectSelectionInput (client, stuff->selection,
+ pWin, stuff->eventMask);
+}
+
+int
+SProcXFixesSelectSelectionInput (ClientPtr client)
+{
+ register int n;
+ REQUEST(xXFixesSelectSelectionInputReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ swapl(&stuff->selection, n);
+ swapl(&stuff->eventMask, n);
+ return ProcXFixesSelectSelectionInput(client);
+}
+
+void
+SXFixesSelectionNotifyEvent (xXFixesSelectionNotifyEvent *from,
+ xXFixesSelectionNotifyEvent *to)
+{
+ to->type = from->type;
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswapl (from->window, to->window);
+ cpswapl (from->owner, to->owner);
+ cpswapl (from->selection, to->selection);
+ cpswapl (from->timestamp, to->timestamp);
+ cpswapl (from->selectionTimestamp, to->selectionTimestamp);
+}
+
+static int
+SelectionFreeClient (pointer data, XID id)
+{
+ SelectionEventPtr old = (SelectionEventPtr) data;
+ SelectionEventPtr *prev, e;
+
+ for (prev = &selectionEvents; (e = *prev); prev = &e->next)
+ {
+ if (e == old)
+ {
+ *prev = e->next;
+ xfree (e);
+ CheckSelectionCallback ();
+ break;
+ }
+ }
+ return 1;
+}
+
+static int
+SelectionFreeWindow (pointer data, XID id)
+{
+ WindowPtr pWindow = (WindowPtr) data;
+ SelectionEventPtr e, next;
+
+ for (e = selectionEvents; e; e = next)
+ {
+ next = e->next;
+ if (e->pWindow == pWindow)
+ {
+ FreeResource (e->clientResource, 0);
+ }
+ }
+ return 1;
+}
+
+Bool
+XFixesSelectionInit (void)
+{
+ SelectionClientType = CreateNewResourceType(SelectionFreeClient);
+ SelectionWindowType = CreateNewResourceType(SelectionFreeWindow);
+ return SelectionClientType && SelectionWindowType;
+}
diff --git a/nx-X11/programs/Xserver/xfixes/select.c.X.original b/nx-X11/programs/Xserver/xfixes/select.c.X.original
new file mode 100755
index 000000000..6a28da93b
--- /dev/null
+++ b/nx-X11/programs/Xserver/xfixes/select.c.X.original
@@ -0,0 +1,279 @@
+/*
+ * $Id: select.c,v 1.6 2005/07/03 07:37:35 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xfixesint.h"
+
+static RESTYPE SelectionClientType, SelectionWindowType;
+static Bool SelectionCallbackRegistered = FALSE;
+
+/*
+ * There is a global list of windows selecting for selection events
+ * on every selection. This should be plenty efficient for the
+ * expected usage, if it does become a problem, it should be easily
+ * replaced with a hash table of some kind keyed off the selection atom
+ */
+
+typedef struct _SelectionEvent *SelectionEventPtr;
+
+typedef struct _SelectionEvent {
+ SelectionEventPtr next;
+ Atom selection;
+ CARD32 eventMask;
+ ClientPtr pClient;
+ WindowPtr pWindow;
+ XID clientResource;
+} SelectionEventRec;
+
+static SelectionEventPtr selectionEvents;
+
+static void
+XFixesSelectionCallback (CallbackListPtr *callbacks, pointer data, pointer args)
+{
+ SelectionEventPtr e;
+ SelectionInfoRec *info = (SelectionInfoRec *) args;
+ Selection *selection = info->selection;
+ int subtype;
+ CARD32 eventMask;
+
+ switch (info->kind) {
+ case SelectionSetOwner:
+ subtype = XFixesSetSelectionOwnerNotify;
+ eventMask = XFixesSetSelectionOwnerNotifyMask;
+ break;
+ case SelectionWindowDestroy:
+ subtype = XFixesSelectionWindowDestroyNotify;
+ eventMask = XFixesSelectionWindowDestroyNotifyMask;
+ break;
+ case SelectionClientClose:
+ subtype = XFixesSelectionClientCloseNotify;
+ eventMask = XFixesSelectionClientCloseNotifyMask;
+ break;
+ default:
+ return;
+ }
+ for (e = selectionEvents; e; e = e->next)
+ {
+ if (e->selection == selection->selection && (e->eventMask & eventMask))
+ {
+ xXFixesSelectionNotifyEvent ev;
+
+ ev.type = XFixesEventBase + XFixesSelectionNotify;
+ ev.subtype = subtype;
+ ev.sequenceNumber = e->pClient->sequence;
+ ev.window = e->pWindow->drawable.id;
+ if (subtype == XFixesSetSelectionOwnerNotify)
+ ev.owner = selection->window;
+ else
+ ev.owner = 0;
+ ev.selection = e->selection;
+ ev.timestamp = currentTime.milliseconds;
+ ev.selectionTimestamp = selection->lastTimeChanged.milliseconds;
+ WriteEventsToClient (e->pClient, 1, (xEvent *) &ev);
+ }
+ }
+}
+
+static Bool
+CheckSelectionCallback (void)
+{
+ if (selectionEvents)
+ {
+ if (!SelectionCallbackRegistered)
+ {
+ if (!AddCallback (&SelectionCallback, XFixesSelectionCallback, NULL))
+ return FALSE;
+ SelectionCallbackRegistered = TRUE;
+ }
+ }
+ else
+ {
+ if (SelectionCallbackRegistered)
+ {
+ DeleteCallback (&SelectionCallback, XFixesSelectionCallback, NULL);
+ SelectionCallbackRegistered = FALSE;
+ }
+ }
+ return TRUE;
+}
+
+#define SelectionAllEvents (XFixesSetSelectionOwnerNotifyMask |\
+ XFixesSelectionWindowDestroyNotifyMask |\
+ XFixesSelectionClientCloseNotifyMask)
+
+static int
+XFixesSelectSelectionInput (ClientPtr pClient,
+ Atom selection,
+ WindowPtr pWindow,
+ CARD32 eventMask)
+{
+ SelectionEventPtr *prev, e;
+
+ for (prev = &selectionEvents; (e = *prev); prev = &e->next)
+ {
+ if (e->selection == selection &&
+ e->pClient == pClient &&
+ e->pWindow == pWindow)
+ {
+ break;
+ }
+ }
+ if (!eventMask)
+ {
+ if (e)
+ {
+ FreeResource (e->clientResource, 0);
+ }
+ return Success;
+ }
+ if (!e)
+ {
+ e = (SelectionEventPtr) xalloc (sizeof (SelectionEventRec));
+ if (!e)
+ return BadAlloc;
+
+ e->next = 0;
+ e->selection = selection;
+ e->pClient = pClient;
+ e->pWindow = pWindow;
+ e->clientResource = FakeClientID(pClient->index);
+
+ /*
+ * Add a resource hanging from the window to
+ * catch window destroy
+ */
+ if (!LookupIDByType(pWindow->drawable.id, SelectionWindowType))
+ if (!AddResource (pWindow->drawable.id, SelectionWindowType,
+ (pointer) pWindow))
+ {
+ xfree (e);
+ return BadAlloc;
+ }
+
+ if (!AddResource (e->clientResource, SelectionClientType, (pointer) e))
+ return BadAlloc;
+
+ *prev = e;
+ if (!CheckSelectionCallback ())
+ {
+ FreeResource (e->clientResource, 0);
+ return BadAlloc;
+ }
+ }
+ e->eventMask = eventMask;
+ return Success;
+}
+
+int
+ProcXFixesSelectSelectionInput (ClientPtr client)
+{
+ REQUEST (xXFixesSelectSelectionInputReq);
+ WindowPtr pWin;
+
+ REQUEST_SIZE_MATCH (xXFixesSelectSelectionInputReq);
+ pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
+ SecurityReadAccess);
+ if (!pWin)
+ return(BadWindow);
+ if (stuff->eventMask & ~SelectionAllEvents)
+ {
+ client->errorValue = stuff->eventMask;
+ return( BadValue );
+ }
+ return XFixesSelectSelectionInput (client, stuff->selection,
+ pWin, stuff->eventMask);
+}
+
+int
+SProcXFixesSelectSelectionInput (ClientPtr client)
+{
+ register int n;
+ REQUEST(xXFixesSelectSelectionInputReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ swapl(&stuff->selection, n);
+ swapl(&stuff->eventMask, n);
+ return ProcXFixesSelectSelectionInput(client);
+}
+
+void
+SXFixesSelectionNotifyEvent (xXFixesSelectionNotifyEvent *from,
+ xXFixesSelectionNotifyEvent *to)
+{
+ to->type = from->type;
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswapl (from->window, to->window);
+ cpswapl (from->owner, to->owner);
+ cpswapl (from->selection, to->selection);
+ cpswapl (from->timestamp, to->timestamp);
+ cpswapl (from->selectionTimestamp, to->selectionTimestamp);
+}
+
+static int
+SelectionFreeClient (pointer data, XID id)
+{
+ SelectionEventPtr old = (SelectionEventPtr) data;
+ SelectionEventPtr *prev, e;
+
+ for (prev = &selectionEvents; (e = *prev); prev = &e->next)
+ {
+ if (e == old)
+ {
+ *prev = e->next;
+ xfree (e);
+ CheckSelectionCallback ();
+ break;
+ }
+ }
+ return 1;
+}
+
+static int
+SelectionFreeWindow (pointer data, XID id)
+{
+ WindowPtr pWindow = (WindowPtr) data;
+ SelectionEventPtr e, next;
+
+ for (e = selectionEvents; e; e = next)
+ {
+ next = e->next;
+ if (e->pWindow == pWindow)
+ {
+ FreeResource (e->clientResource, 0);
+ }
+ }
+ return 1;
+}
+
+Bool
+XFixesSelectionInit (void)
+{
+ SelectionClientType = CreateNewResourceType(SelectionFreeClient);
+ SelectionWindowType = CreateNewResourceType(SelectionFreeWindow);
+ return SelectionClientType && SelectionWindowType;
+}
diff --git a/nx-X11/programs/Xserver/xfixes/xfixes.c b/nx-X11/programs/Xserver/xfixes/xfixes.c
new file mode 100755
index 000000000..1569b311e
--- /dev/null
+++ b/nx-X11/programs/Xserver/xfixes/xfixes.c
@@ -0,0 +1,231 @@
+/*
+ * $Id: xfixes.c,v 1.7 2005/07/03 07:37:35 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xfixesint.h"
+
+unsigned char XFixesReqCode;
+int XFixesEventBase;
+int XFixesErrorBase;
+int XFixesClientPrivateIndex;
+
+static int
+ProcXFixesQueryVersion(ClientPtr client)
+{
+ XFixesClientPtr pXFixesClient = GetXFixesClient (client);
+ xXFixesQueryVersionReply rep;
+ register int n;
+ REQUEST(xXFixesQueryVersionReq);
+
+ REQUEST_SIZE_MATCH(xXFixesQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ if (stuff->majorVersion < XFIXES_MAJOR) {
+ rep.majorVersion = stuff->majorVersion;
+ rep.minorVersion = stuff->minorVersion;
+ } else {
+ rep.majorVersion = XFIXES_MAJOR;
+ if (stuff->majorVersion == XFIXES_MAJOR &&
+ stuff->minorVersion < XFIXES_MINOR)
+ rep.minorVersion = stuff->minorVersion;
+ else
+ rep.minorVersion = XFIXES_MINOR;
+ }
+ pXFixesClient->major_version = rep.majorVersion;
+ pXFixesClient->minor_version = rep.minorVersion;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.majorVersion, n);
+ swapl(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof(xXFixesQueryVersionReply), (char *)&rep);
+ return(client->noClientException);
+}
+
+/* Major version controls available requests */
+static const int version_requests[] = {
+ X_XFixesQueryVersion, /* before client sends QueryVersion */
+ X_XFixesGetCursorImage, /* Version 1 */
+ X_XFixesChangeCursorByName, /* Version 2 */
+ X_XFixesExpandRegion, /* Version 3 */
+};
+
+#define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0]))
+
+int (*ProcXFixesVector[XFixesNumberRequests])(ClientPtr) = {
+/*************** Version 1 ******************/
+ ProcXFixesQueryVersion,
+ ProcXFixesChangeSaveSet,
+ ProcXFixesSelectSelectionInput,
+ ProcXFixesSelectCursorInput,
+ ProcXFixesGetCursorImage,
+/*************** Version 2 ******************/
+ ProcXFixesCreateRegion,
+ ProcXFixesCreateRegionFromBitmap,
+ ProcXFixesCreateRegionFromWindow,
+ ProcXFixesCreateRegionFromGC,
+ ProcXFixesCreateRegionFromPicture,
+ ProcXFixesDestroyRegion,
+ ProcXFixesSetRegion,
+ ProcXFixesCopyRegion,
+ ProcXFixesCombineRegion,
+ ProcXFixesCombineRegion,
+ ProcXFixesCombineRegion,
+ ProcXFixesInvertRegion,
+ ProcXFixesTranslateRegion,
+ ProcXFixesRegionExtents,
+ ProcXFixesFetchRegion,
+ ProcXFixesSetGCClipRegion,
+ ProcXFixesSetWindowShapeRegion,
+ ProcXFixesSetPictureClipRegion,
+ ProcXFixesSetCursorName,
+ ProcXFixesGetCursorName,
+ ProcXFixesGetCursorImageAndName,
+ ProcXFixesChangeCursor,
+ ProcXFixesChangeCursorByName,
+/*************** Version 3 ******************/
+ ProcXFixesExpandRegion,
+};
+
+static int
+ProcXFixesDispatch (ClientPtr client)
+{
+ REQUEST(xXFixesReq);
+ XFixesClientPtr pXFixesClient = GetXFixesClient (client);
+
+ if (pXFixesClient->major_version > NUM_VERSION_REQUESTS)
+ return BadRequest;
+ if (stuff->xfixesReqType > version_requests[pXFixesClient->major_version])
+ return BadRequest;
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+static int
+SProcXFixesQueryVersion(ClientPtr client)
+{
+ register int n;
+ REQUEST(xXFixesQueryVersionReq);
+
+ swaps(&stuff->length, n);
+ swapl(&stuff->majorVersion, n);
+ swapl(&stuff->minorVersion, n);
+ return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+int (*SProcXFixesVector[XFixesNumberRequests])(ClientPtr) = {
+/*************** Version 1 ******************/
+ SProcXFixesQueryVersion,
+ SProcXFixesChangeSaveSet,
+ SProcXFixesSelectSelectionInput,
+ SProcXFixesSelectCursorInput,
+ SProcXFixesGetCursorImage,
+/*************** Version 2 ******************/
+ SProcXFixesCreateRegion,
+ SProcXFixesCreateRegionFromBitmap,
+ SProcXFixesCreateRegionFromWindow,
+ SProcXFixesCreateRegionFromGC,
+ SProcXFixesCreateRegionFromPicture,
+ SProcXFixesDestroyRegion,
+ SProcXFixesSetRegion,
+ SProcXFixesCopyRegion,
+ SProcXFixesCombineRegion,
+ SProcXFixesCombineRegion,
+ SProcXFixesCombineRegion,
+ SProcXFixesInvertRegion,
+ SProcXFixesTranslateRegion,
+ SProcXFixesRegionExtents,
+ SProcXFixesFetchRegion,
+ SProcXFixesSetGCClipRegion,
+ SProcXFixesSetWindowShapeRegion,
+ SProcXFixesSetPictureClipRegion,
+ SProcXFixesSetCursorName,
+ SProcXFixesGetCursorName,
+ SProcXFixesGetCursorImageAndName,
+ SProcXFixesChangeCursor,
+ SProcXFixesChangeCursorByName,
+/*************** Version 3 ******************/
+ SProcXFixesExpandRegion,
+};
+
+static int
+SProcXFixesDispatch (ClientPtr client)
+{
+ REQUEST(xXFixesReq);
+ if (stuff->xfixesReqType >= XFixesNumberRequests)
+ return BadRequest;
+ return (*SProcXFixesVector[stuff->xfixesReqType]) (client);
+}
+
+static void
+XFixesClientCallback (CallbackListPtr *list,
+ pointer closure,
+ pointer data)
+{
+ NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
+ ClientPtr pClient = clientinfo->client;
+ XFixesClientPtr pXFixesClient = GetXFixesClient (pClient);
+
+ pXFixesClient->major_version = 0;
+ pXFixesClient->minor_version = 0;
+}
+
+/*ARGSUSED*/
+static void
+XFixesResetProc (ExtensionEntry *extEntry)
+{
+ DeleteCallback (&ClientStateCallback, XFixesClientCallback, 0);
+}
+
+void
+XFixesExtensionInit(void)
+{
+ ExtensionEntry *extEntry;
+
+ XFixesClientPrivateIndex = AllocateClientPrivateIndex ();
+ if (!AllocateClientPrivate (XFixesClientPrivateIndex,
+ sizeof (XFixesClientRec)))
+ return;
+ if (!AddCallback (&ClientStateCallback, XFixesClientCallback, 0))
+ return;
+
+ if (XFixesSelectionInit() && XFixesCursorInit () && XFixesRegionInit () &&
+ (extEntry = AddExtension(XFIXES_NAME, XFixesNumberEvents,
+ XFixesNumberErrors,
+ ProcXFixesDispatch, SProcXFixesDispatch,
+ XFixesResetProc, StandardMinorOpcode)) != 0)
+ {
+ XFixesReqCode = (unsigned char)extEntry->base;
+ XFixesEventBase = extEntry->eventBase;
+ XFixesErrorBase = extEntry->errorBase;
+ EventSwapVector[XFixesEventBase + XFixesSelectionNotify] =
+ (EventSwapPtr) SXFixesSelectionNotifyEvent;
+ EventSwapVector[XFixesEventBase + XFixesCursorNotify] =
+ (EventSwapPtr) SXFixesCursorNotifyEvent;
+ }
+}
diff --git a/nx-X11/programs/Xserver/xfixes/xfixes.h b/nx-X11/programs/Xserver/xfixes/xfixes.h
new file mode 100755
index 000000000..fcd941778
--- /dev/null
+++ b/nx-X11/programs/Xserver/xfixes/xfixes.h
@@ -0,0 +1,54 @@
+/*
+ * $Id: xfixes.h,v 1.6 2005/07/03 07:02:08 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _XFIXES_H_
+#define _XFIXES_H_
+
+#include "resource.h"
+
+extern RESTYPE RegionResType;
+extern int XFixesErrorBase;
+
+#define VERIFY_REGION(pRegion, rid, client, mode) { \
+ pRegion = SecurityLookupIDByType (client, rid, RegionResType, mode); \
+ if (!pRegion) { \
+ client->errorValue = rid; \
+ return XFixesErrorBase + BadRegion; \
+ } \
+}
+
+#define VERIFY_REGION_OR_NONE(pRegion, rid, client, mode) { \
+ pRegion = 0; \
+ if (rid) VERIFY_REGION(pRegion, rid, client, mode); \
+}
+
+RegionPtr
+XFixesRegionCopy (RegionPtr pRegion);
+
+
+#endif /* _XFIXES_H_ */
diff --git a/nx-X11/programs/Xserver/xfixes/xfixesint.h b/nx-X11/programs/Xserver/xfixes/xfixesint.h
new file mode 100755
index 000000000..4892654be
--- /dev/null
+++ b/nx-X11/programs/Xserver/xfixes/xfixesint.h
@@ -0,0 +1,243 @@
+/*
+ * $Id: xfixesint.h,v 1.7 2005/07/03 08:53:54 daniels Exp $
+ *
+ * Copyright © 2002 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _XFIXESINT_H_
+#define _XFIXESINT_H_
+
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include <X11/extensions/xfixesproto.h>
+#include "windowstr.h"
+#include "selection.h"
+#include "xfixes.h"
+
+extern unsigned char XFixesReqCode;
+extern int XFixesEventBase;
+extern int XFixesClientPrivateIndex;
+
+typedef struct _XFixesClient {
+ CARD32 major_version;
+ CARD32 minor_version;
+} XFixesClientRec, *XFixesClientPtr;
+
+#define GetXFixesClient(pClient) ((XFixesClientPtr) (pClient)->devPrivates[XFixesClientPrivateIndex].ptr)
+
+extern int (*ProcXFixesVector[XFixesNumberRequests])(ClientPtr);
+extern int (*SProcXFixesVector[XFixesNumberRequests])(ClientPtr);
+
+/* Initialize extension at server startup time */
+
+void
+XFixesExtensionInit(void);
+
+/* Save set */
+int
+ProcXFixesChangeSaveSet(ClientPtr client);
+
+int
+SProcXFixesChangeSaveSet(ClientPtr client);
+
+/* Selection events */
+int
+ProcXFixesSelectSelectionInput (ClientPtr client);
+
+int
+SProcXFixesSelectSelectionInput (ClientPtr client);
+
+void
+SXFixesSelectionNotifyEvent (xXFixesSelectionNotifyEvent *from,
+ xXFixesSelectionNotifyEvent *to);
+Bool
+XFixesSelectionInit (void);
+
+/* Cursor notification */
+Bool
+XFixesCursorInit (void);
+
+int
+ProcXFixesSelectCursorInput (ClientPtr client);
+
+int
+SProcXFixesSelectCursorInput (ClientPtr client);
+
+void
+SXFixesCursorNotifyEvent (xXFixesCursorNotifyEvent *from,
+ xXFixesCursorNotifyEvent *to);
+
+int
+ProcXFixesGetCursorImage (ClientPtr client);
+
+int
+SProcXFixesGetCursorImage (ClientPtr client);
+
+/* Cursor names (Version 2) */
+
+int
+ProcXFixesSetCursorName (ClientPtr client);
+
+int
+SProcXFixesSetCursorName (ClientPtr client);
+
+int
+ProcXFixesGetCursorName (ClientPtr client);
+
+int
+SProcXFixesGetCursorName (ClientPtr client);
+
+int
+ProcXFixesGetCursorImageAndName (ClientPtr client);
+
+int
+SProcXFixesGetCursorImageAndName (ClientPtr client);
+
+/* Cursor replacement (Version 2) */
+
+int
+ProcXFixesChangeCursor (ClientPtr client);
+
+int
+SProcXFixesChangeCursor (ClientPtr client);
+
+int
+ProcXFixesChangeCursorByName (ClientPtr client);
+
+int
+SProcXFixesChangeCursorByName (ClientPtr client);
+
+/* Region objects (Version 2* */
+Bool
+XFixesRegionInit (void);
+
+int
+ProcXFixesCreateRegion (ClientPtr client);
+
+int
+SProcXFixesCreateRegion (ClientPtr client);
+
+int
+ProcXFixesCreateRegionFromBitmap (ClientPtr client);
+
+int
+SProcXFixesCreateRegionFromBitmap (ClientPtr client);
+
+int
+ProcXFixesCreateRegionFromWindow (ClientPtr client);
+
+int
+SProcXFixesCreateRegionFromWindow (ClientPtr client);
+
+int
+ProcXFixesCreateRegionFromGC (ClientPtr client);
+
+int
+SProcXFixesCreateRegionFromGC (ClientPtr client);
+
+int
+ProcXFixesCreateRegionFromPicture (ClientPtr client);
+
+int
+SProcXFixesCreateRegionFromPicture (ClientPtr client);
+
+int
+ProcXFixesDestroyRegion (ClientPtr client);
+
+int
+SProcXFixesDestroyRegion (ClientPtr client);
+
+int
+ProcXFixesSetRegion (ClientPtr client);
+
+int
+SProcXFixesSetRegion (ClientPtr client);
+
+int
+ProcXFixesCopyRegion (ClientPtr client);
+
+int
+SProcXFixesCopyRegion (ClientPtr client);
+
+int
+ProcXFixesCombineRegion (ClientPtr client);
+
+int
+SProcXFixesCombineRegion (ClientPtr client);
+
+int
+ProcXFixesInvertRegion (ClientPtr client);
+
+int
+SProcXFixesInvertRegion (ClientPtr client);
+
+int
+ProcXFixesTranslateRegion (ClientPtr client);
+
+int
+SProcXFixesTranslateRegion (ClientPtr client);
+
+int
+ProcXFixesRegionExtents (ClientPtr client);
+
+int
+SProcXFixesRegionExtents (ClientPtr client);
+
+int
+ProcXFixesFetchRegion (ClientPtr client);
+
+int
+SProcXFixesFetchRegion (ClientPtr client);
+
+int
+ProcXFixesSetGCClipRegion (ClientPtr client);
+
+int
+SProcXFixesSetGCClipRegion (ClientPtr client);
+
+int
+ProcXFixesSetWindowShapeRegion (ClientPtr client);
+
+int
+SProcXFixesSetWindowShapeRegion (ClientPtr client);
+
+int
+ProcXFixesSetPictureClipRegion (ClientPtr client);
+
+int
+SProcXFixesSetPictureClipRegion (ClientPtr client);
+
+int
+ProcXFixesExpandRegion (ClientPtr client);
+
+int
+SProcXFixesExpandRegion (ClientPtr client);
+
+#endif /* _XFIXESINT_H_ */
diff --git a/nx-X11/programs/Xserver/xkb/Imakefile b/nx-X11/programs/Xserver/xkb/Imakefile
new file mode 100644
index 000000000..a718545b1
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/Imakefile
@@ -0,0 +1,106 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:53:45 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/xkb/Imakefile,v 3.21 2002/12/09 23:00:42 dawes Exp $
+
+#define SGIHyperOpt
+#include <Server.tmpl>
+
+#ifdef SGIArchitecture
+EXTRA_ALLOC_DEFINES = -DFORCE_ALLOCA
+#endif
+
+#if BuildXInputExt
+XKBXI_SRCS = xkbPrOtherEv.c
+XKBXI_OBJS = xkbPrOtherEv.o
+#endif
+
+#ifdef DfltDisableXKB
+XKB_DISABLE = -DXKB_DFLT_DISABLED=1
+#else
+XKB_DISABLE = -DXKB_DFLT_DISABLED=0
+#endif
+
+XKB_DDXDEFS = XkbServerDefines
+
+#if defined(NXAgentServer) && NXAgentServer
+NX_DEFINES = -DNXAGENT_SERVER
+#endif
+
+#if (defined(XF86Server) && XF86Server) || (defined(XorgServer) && XorgServer)
+XF86INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC)
+ XF86_OBJS = xf86KillSrv.o xf86VT.o xf86Private.o
+#endif
+
+ DDX_SRCS = ddxBeep.c ddxCtrls.c ddxFakeBtn.c ddxFakeMtn.c ddxInit.c \
+ ddxKeyClick.c ddxKillSrv.c ddxLEDs.c ddxVT.c ddxLoad.c \
+ ddxList.c ddxConfig.c ddxDevBtn.c ddxPrivate.c xkbconfig.c
+ DDX_OBJS = ddxBeep.o ddxCtrls.o ddxFakeBtn.o ddxFakeMtn.o ddxInit.o \
+ ddxKeyClick.o ddxKillSrv.o ddxLEDs.o ddxVT.o ddxLoad.o \
+ ddxList.o ddxConfig.o ddxDevBtn.o ddxPrivate.o xkbconfig.o
+ SRCS = xkb.c xkbUtils.c xkbEvents.c xkbAccessX.c xkbSwap.c \
+ xkbLEDs.c xkbInit.c xkbActions.c xkbPrKeyEv.c \
+ xkmread.c xkbtext.c xkbfmisc.c xkberrs.c xkbout.c maprules.c \
+ XKBMisc.c XKBMAlloc.c XKBAlloc.c XKBGAlloc.c \
+ $(XKBXI_SRCS) $(DDX_SRCS)
+ OBJS = xkb.o xkbUtils.o xkbEvents.o xkbAccessX.o xkbSwap.o \
+ xkbLEDs.o xkbInit.o xkbActions.o xkbPrKeyEv.o \
+ xkmread.o xkbtext.o xkbfmisc.o xkberrs.o xkbout.o maprules.o \
+ XKBMisc.o XKBMAlloc.o XKBAlloc.o XKBGAlloc.o \
+ $(XKBXI_OBJS) $(DDX_OBJS)
+ INCLUDES = -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/Xext \
+ -I$(SERVERSRC)/mi $(XF86INCLUDES)
+ LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+
+DEFINES = -DXKB_IN_SERVER $(EXTRA_ALLOC_DEFINES) $(XKB_DDXDEFS) $(NX_DEFINES)
+XKB_DEFINES = -DXKB_BASE_DIRECTORY=\"$(LIBDIR)/xkb\" $(XKB_DISABLE)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(xkb,$(OBJS))
+LintLibraryTarget(xkb,$(SRCS))
+NormalLintTarget($(SRCS))
+
+#if (defined(XF86Server) && XF86Server) || (defined(XorgServer) && XorgServer)
+ObjectFromSpecialSource(xf86KillSrv,ddxKillSrv,-DXF86DDXACTIONS)
+ObjectFromSpecialSource(xf86VT,ddxVT,-DXF86DDXACTIONS)
+ObjectFromSpecialSource(xf86Private,ddxPrivate,-DXF86DDXACTIONS)
+AllTarget($(XF86_OBJS))
+#endif
+
+SpecialCObjectRule(xkbInit,$(ICONFIGFILES),$(XKB_DEFINES))
+
+LinkSourceFile(maprules.c,$(XKBFILELIBSRC))
+LinkSourceFile(xkmread.c,$(XKBFILELIBSRC))
+LinkSourceFile(xkbtext.c,$(XKBFILELIBSRC))
+XCOMM avoid clash between XKBMisc.c and xkbmisc.c on NT
+LinkFile(xkbfmisc.c,$(XKBFILELIBSRC)/xkbmisc.c)
+LinkSourceFile(xkberrs.c,$(XKBFILELIBSRC))
+LinkSourceFile(xkbconfig.c,$(XKBFILELIBSRC))
+LinkSourceFile(xkbout.c,$(XKBFILELIBSRC))
+LinkSourceFile(XKBMisc.c,$(XLIBSRC))
+LinkSourceFile(XKBMAlloc.c,$(XLIBSRC))
+LinkSourceFile(XKBAlloc.c,$(XLIBSRC))
+LinkSourceFile(XKBGAlloc.c,$(XLIBSRC))
+
+LinkSourceFile(modinit.h,../Xext/extmod)
+
+#if BuildLibraries
+#if UseConfDirForXkb
+LinkConfDirectory(xkb,.,xkb,.)
+ODIR = $(CONFDIR)
+#else
+ODIR = $(LIBDIR)
+#endif
+#ifdef VarDbDirectory
+NDIR = $(VARDBDIR)
+#else
+NDIR = $(CONFDIR)
+#endif
+#if !UseConfDirForXkb || defined(VarDbDirectory)
+LinkConfDirectoryLong(xkb,xkb,compiled,compiled,$(ODIR),$(NDIR))
+#endif
+#endif
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/xkb/Imakefile.NX.original b/nx-X11/programs/Xserver/xkb/Imakefile.NX.original
new file mode 100644
index 000000000..a718545b1
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/Imakefile.NX.original
@@ -0,0 +1,106 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:53:45 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/xkb/Imakefile,v 3.21 2002/12/09 23:00:42 dawes Exp $
+
+#define SGIHyperOpt
+#include <Server.tmpl>
+
+#ifdef SGIArchitecture
+EXTRA_ALLOC_DEFINES = -DFORCE_ALLOCA
+#endif
+
+#if BuildXInputExt
+XKBXI_SRCS = xkbPrOtherEv.c
+XKBXI_OBJS = xkbPrOtherEv.o
+#endif
+
+#ifdef DfltDisableXKB
+XKB_DISABLE = -DXKB_DFLT_DISABLED=1
+#else
+XKB_DISABLE = -DXKB_DFLT_DISABLED=0
+#endif
+
+XKB_DDXDEFS = XkbServerDefines
+
+#if defined(NXAgentServer) && NXAgentServer
+NX_DEFINES = -DNXAGENT_SERVER
+#endif
+
+#if (defined(XF86Server) && XF86Server) || (defined(XorgServer) && XorgServer)
+XF86INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC)
+ XF86_OBJS = xf86KillSrv.o xf86VT.o xf86Private.o
+#endif
+
+ DDX_SRCS = ddxBeep.c ddxCtrls.c ddxFakeBtn.c ddxFakeMtn.c ddxInit.c \
+ ddxKeyClick.c ddxKillSrv.c ddxLEDs.c ddxVT.c ddxLoad.c \
+ ddxList.c ddxConfig.c ddxDevBtn.c ddxPrivate.c xkbconfig.c
+ DDX_OBJS = ddxBeep.o ddxCtrls.o ddxFakeBtn.o ddxFakeMtn.o ddxInit.o \
+ ddxKeyClick.o ddxKillSrv.o ddxLEDs.o ddxVT.o ddxLoad.o \
+ ddxList.o ddxConfig.o ddxDevBtn.o ddxPrivate.o xkbconfig.o
+ SRCS = xkb.c xkbUtils.c xkbEvents.c xkbAccessX.c xkbSwap.c \
+ xkbLEDs.c xkbInit.c xkbActions.c xkbPrKeyEv.c \
+ xkmread.c xkbtext.c xkbfmisc.c xkberrs.c xkbout.c maprules.c \
+ XKBMisc.c XKBMAlloc.c XKBAlloc.c XKBGAlloc.c \
+ $(XKBXI_SRCS) $(DDX_SRCS)
+ OBJS = xkb.o xkbUtils.o xkbEvents.o xkbAccessX.o xkbSwap.o \
+ xkbLEDs.o xkbInit.o xkbActions.o xkbPrKeyEv.o \
+ xkmread.o xkbtext.o xkbfmisc.o xkberrs.o xkbout.o maprules.o \
+ XKBMisc.o XKBMAlloc.o XKBAlloc.o XKBGAlloc.o \
+ $(XKBXI_OBJS) $(DDX_OBJS)
+ INCLUDES = -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/Xext \
+ -I$(SERVERSRC)/mi $(XF86INCLUDES)
+ LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+
+DEFINES = -DXKB_IN_SERVER $(EXTRA_ALLOC_DEFINES) $(XKB_DDXDEFS) $(NX_DEFINES)
+XKB_DEFINES = -DXKB_BASE_DIRECTORY=\"$(LIBDIR)/xkb\" $(XKB_DISABLE)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(xkb,$(OBJS))
+LintLibraryTarget(xkb,$(SRCS))
+NormalLintTarget($(SRCS))
+
+#if (defined(XF86Server) && XF86Server) || (defined(XorgServer) && XorgServer)
+ObjectFromSpecialSource(xf86KillSrv,ddxKillSrv,-DXF86DDXACTIONS)
+ObjectFromSpecialSource(xf86VT,ddxVT,-DXF86DDXACTIONS)
+ObjectFromSpecialSource(xf86Private,ddxPrivate,-DXF86DDXACTIONS)
+AllTarget($(XF86_OBJS))
+#endif
+
+SpecialCObjectRule(xkbInit,$(ICONFIGFILES),$(XKB_DEFINES))
+
+LinkSourceFile(maprules.c,$(XKBFILELIBSRC))
+LinkSourceFile(xkmread.c,$(XKBFILELIBSRC))
+LinkSourceFile(xkbtext.c,$(XKBFILELIBSRC))
+XCOMM avoid clash between XKBMisc.c and xkbmisc.c on NT
+LinkFile(xkbfmisc.c,$(XKBFILELIBSRC)/xkbmisc.c)
+LinkSourceFile(xkberrs.c,$(XKBFILELIBSRC))
+LinkSourceFile(xkbconfig.c,$(XKBFILELIBSRC))
+LinkSourceFile(xkbout.c,$(XKBFILELIBSRC))
+LinkSourceFile(XKBMisc.c,$(XLIBSRC))
+LinkSourceFile(XKBMAlloc.c,$(XLIBSRC))
+LinkSourceFile(XKBAlloc.c,$(XLIBSRC))
+LinkSourceFile(XKBGAlloc.c,$(XLIBSRC))
+
+LinkSourceFile(modinit.h,../Xext/extmod)
+
+#if BuildLibraries
+#if UseConfDirForXkb
+LinkConfDirectory(xkb,.,xkb,.)
+ODIR = $(CONFDIR)
+#else
+ODIR = $(LIBDIR)
+#endif
+#ifdef VarDbDirectory
+NDIR = $(VARDBDIR)
+#else
+NDIR = $(CONFDIR)
+#endif
+#if !UseConfDirForXkb || defined(VarDbDirectory)
+LinkConfDirectoryLong(xkb,xkb,compiled,compiled,$(ODIR),$(NDIR))
+#endif
+#endif
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/xkb/Imakefile.X.original b/nx-X11/programs/Xserver/xkb/Imakefile.X.original
new file mode 100644
index 000000000..a91f8ff86
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/Imakefile.X.original
@@ -0,0 +1,102 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:53:45 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/xkb/Imakefile,v 3.21 2002/12/09 23:00:42 dawes Exp $
+
+#define SGIHyperOpt
+#include <Server.tmpl>
+
+#ifdef SGIArchitecture
+EXTRA_ALLOC_DEFINES = -DFORCE_ALLOCA
+#endif
+
+#if BuildXInputExt
+XKBXI_SRCS = xkbPrOtherEv.c
+XKBXI_OBJS = xkbPrOtherEv.o
+#endif
+
+#ifdef DfltDisableXKB
+XKB_DISABLE = -DXKB_DFLT_DISABLED=1
+#else
+XKB_DISABLE = -DXKB_DFLT_DISABLED=0
+#endif
+
+XKB_DDXDEFS = XkbServerDefines
+
+#if (defined(XF86Server) && XF86Server) || (defined(XorgServer) && XorgServer)
+XF86INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC)
+ XF86_OBJS = xf86KillSrv.o xf86VT.o xf86Private.o
+#endif
+
+ DDX_SRCS = ddxBeep.c ddxCtrls.c ddxFakeBtn.c ddxFakeMtn.c ddxInit.c \
+ ddxKeyClick.c ddxKillSrv.c ddxLEDs.c ddxVT.c ddxLoad.c \
+ ddxList.c ddxConfig.c ddxDevBtn.c ddxPrivate.c xkbconfig.c
+ DDX_OBJS = ddxBeep.o ddxCtrls.o ddxFakeBtn.o ddxFakeMtn.o ddxInit.o \
+ ddxKeyClick.o ddxKillSrv.o ddxLEDs.o ddxVT.o ddxLoad.o \
+ ddxList.o ddxConfig.o ddxDevBtn.o ddxPrivate.o xkbconfig.o
+ SRCS = xkb.c xkbUtils.c xkbEvents.c xkbAccessX.c xkbSwap.c \
+ xkbLEDs.c xkbInit.c xkbActions.c xkbPrKeyEv.c \
+ xkmread.c xkbtext.c xkbfmisc.c xkberrs.c xkbout.c maprules.c \
+ XKBMisc.c XKBMAlloc.c XKBAlloc.c XKBGAlloc.c \
+ $(XKBXI_SRCS) $(DDX_SRCS)
+ OBJS = xkb.o xkbUtils.o xkbEvents.o xkbAccessX.o xkbSwap.o \
+ xkbLEDs.o xkbInit.o xkbActions.o xkbPrKeyEv.o \
+ xkmread.o xkbtext.o xkbfmisc.o xkberrs.o xkbout.o maprules.o \
+ XKBMisc.o XKBMAlloc.o XKBAlloc.o XKBGAlloc.o \
+ $(XKBXI_OBJS) $(DDX_OBJS)
+ INCLUDES = -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/Xext \
+ -I$(SERVERSRC)/mi $(XF86INCLUDES)
+ LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+
+DEFINES = -DXKB_IN_SERVER $(EXTRA_ALLOC_DEFINES) $(XKB_DDXDEFS)
+XKB_DEFINES = -DXKB_BASE_DIRECTORY=\"$(LIBDIR)/xkb\" $(XKB_DISABLE)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(xkb,$(OBJS))
+LintLibraryTarget(xkb,$(SRCS))
+NormalLintTarget($(SRCS))
+
+#if (defined(XF86Server) && XF86Server) || (defined(XorgServer) && XorgServer)
+ObjectFromSpecialSource(xf86KillSrv,ddxKillSrv,-DXF86DDXACTIONS)
+ObjectFromSpecialSource(xf86VT,ddxVT,-DXF86DDXACTIONS)
+ObjectFromSpecialSource(xf86Private,ddxPrivate,-DXF86DDXACTIONS)
+AllTarget($(XF86_OBJS))
+#endif
+
+SpecialCObjectRule(xkbInit,$(ICONFIGFILES),$(XKB_DEFINES))
+
+LinkSourceFile(maprules.c,$(XKBFILELIBSRC))
+LinkSourceFile(xkmread.c,$(XKBFILELIBSRC))
+LinkSourceFile(xkbtext.c,$(XKBFILELIBSRC))
+XCOMM avoid clash between XKBMisc.c and xkbmisc.c on NT
+LinkFile(xkbfmisc.c,$(XKBFILELIBSRC)/xkbmisc.c)
+LinkSourceFile(xkberrs.c,$(XKBFILELIBSRC))
+LinkSourceFile(xkbconfig.c,$(XKBFILELIBSRC))
+LinkSourceFile(xkbout.c,$(XKBFILELIBSRC))
+LinkSourceFile(XKBMisc.c,$(XLIBSRC))
+LinkSourceFile(XKBMAlloc.c,$(XLIBSRC))
+LinkSourceFile(XKBAlloc.c,$(XLIBSRC))
+LinkSourceFile(XKBGAlloc.c,$(XLIBSRC))
+
+LinkSourceFile(modinit.h,../Xext/extmod)
+
+#if BuildLibraries
+#if UseConfDirForXkb
+LinkConfDirectory(xkb,.,xkb,.)
+ODIR = $(CONFDIR)
+#else
+ODIR = $(LIBDIR)
+#endif
+#ifdef VarDbDirectory
+NDIR = $(VARDBDIR)
+#else
+NDIR = $(CONFDIR)
+#endif
+#if !UseConfDirForXkb || defined(VarDbDirectory)
+LinkConfDirectoryLong(xkb,xkb,compiled,compiled,$(ODIR),$(NDIR))
+#endif
+#endif
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/xkb/ddxBeep.c b/nx-X11/programs/Xserver/xkb/ddxBeep.c
new file mode 100644
index 000000000..429d1e778
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/ddxBeep.c
@@ -0,0 +1,370 @@
+/* $Xorg: ddxBeep.c,v 1.3 2000/08/17 19:53:45 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/ddxBeep.c,v 3.9 2002/12/05 21:59:00 paulo Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XI.h>
+
+#if (defined(__osf__) && defined(__alpha))
+#include <sys/sysinfo.h>
+#include <alpha/hal_sysinfo.h>
+#include <alpha/prom.h>
+#endif
+
+/*#define FALLING_TONE 1*/
+/*#define RISING_TONE 1*/
+#define FALLING_TONE 10
+#define RISING_TONE 10
+#define SHORT_TONE 50
+#define SHORT_DELAY 60
+#define LONG_TONE 75
+#define VERY_LONG_TONE 100
+#define LONG_DELAY 85
+#define CLICK_DURATION 1
+
+#define DEEP_PITCH 250
+#define LOW_PITCH 500
+#define MID_PITCH 1000
+#define HIGH_PITCH 2000
+#define CLICK_PITCH 1500
+
+static unsigned long atomGeneration= 0;
+static Atom featureOn;
+static Atom featureOff;
+static Atom featureChange;
+static Atom ledOn;
+static Atom ledOff;
+static Atom ledChange;
+static Atom slowWarn;
+static Atom slowPress;
+static Atom slowReject;
+static Atom slowAccept;
+static Atom slowRelease;
+static Atom stickyLatch;
+static Atom stickyLock;
+static Atom stickyUnlock;
+static Atom bounceReject;
+static char doesPitch = 1;
+
+#define FEATURE_ON "AX_FeatureOn"
+#define FEATURE_OFF "AX_FeatureOff"
+#define FEATURE_CHANGE "AX_FeatureChange"
+#define LED_ON "AX_IndicatorOn"
+#define LED_OFF "AX_IndicatorOff"
+#define LED_CHANGE "AX_IndicatorChange"
+#define SLOW_WARN "AX_SlowKeysWarning"
+#define SLOW_PRESS "AX_SlowKeyPress"
+#define SLOW_REJECT "AX_SlowKeyReject"
+#define SLOW_ACCEPT "AX_SlowKeyAccept"
+#define SLOW_RELEASE "AX_SlowKeyRelease"
+#define STICKY_LATCH "AX_StickyLatch"
+#define STICKY_LOCK "AX_StickyLock"
+#define STICKY_UNLOCK "AX_StickyUnlock"
+#define BOUNCE_REJECT "AX_BounceKeyReject"
+
+#define MAKE_ATOM(a) MakeAtom(a,sizeof(a)-1,True)
+
+static void
+_XkbDDXBeepInitAtoms(void)
+{
+ featureOn= MAKE_ATOM(FEATURE_ON);
+ featureOff= MAKE_ATOM(FEATURE_OFF);
+ featureChange= MAKE_ATOM(FEATURE_CHANGE);
+ ledOn= MAKE_ATOM(LED_ON);
+ ledOff= MAKE_ATOM(LED_OFF);
+ ledChange= MAKE_ATOM(LED_CHANGE);
+ slowWarn= MAKE_ATOM(SLOW_WARN);
+ slowPress= MAKE_ATOM(SLOW_PRESS);
+ slowReject= MAKE_ATOM(SLOW_REJECT);
+ slowAccept= MAKE_ATOM(SLOW_ACCEPT);
+ slowRelease= MAKE_ATOM(SLOW_RELEASE);
+ stickyLatch= MAKE_ATOM(STICKY_LATCH);
+ stickyLock= MAKE_ATOM(STICKY_LOCK);
+ stickyUnlock= MAKE_ATOM(STICKY_UNLOCK);
+ bounceReject= MAKE_ATOM(BOUNCE_REJECT);
+#if (defined(__osf__) && defined(__alpha))
+ /* [[[ WDW - Some bells do not allow for pitch changes.
+ * Maybe this could become part of the keymap? ]]]
+ */
+ {
+ char keyboard[8];
+
+ /* Find the class of keyboard being used.
+ */
+ keyboard[0] = '\0';
+ if (-1 == getsysinfo(GSI_KEYBOARD,
+ keyboard, sizeof(keyboard),
+ 0, NULL))
+ keyboard[0] = '\0';
+
+ if ((strcmp(keyboard,"LK201") == 0) ||
+ (strcmp(keyboard,"LK401") == 0) ||
+ (strcmp(keyboard,"LK421") == 0) ||
+ (strcmp(keyboard,"LK443") == 0))
+ doesPitch = 0;
+ }
+#else
+#if defined(sun)
+ doesPitch = 0;
+#endif
+#endif
+ return;
+}
+
+static CARD32
+_XkbDDXBeepExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+DeviceIntPtr dev= (DeviceIntPtr)arg;
+KbdFeedbackPtr feed;
+KeybdCtrl * ctrl;
+XkbSrvInfoPtr xkbInfo;
+CARD32 next;
+int pitch,duration;
+int oldPitch,oldDuration;
+Atom name;
+
+ if ((dev==NULL)||(dev->key==NULL)||(dev->key->xkbInfo==NULL)||
+ (dev->kbdfeed==NULL))
+ return 0;
+ if (atomGeneration!=serverGeneration) {
+ _XkbDDXBeepInitAtoms();
+ atomGeneration= serverGeneration;
+ }
+
+ feed= dev->kbdfeed;
+ ctrl= &feed->ctrl;
+ xkbInfo= dev->key->xkbInfo;
+ next= 0;
+ pitch= oldPitch= ctrl->bell_pitch;
+ duration= oldDuration= ctrl->bell_duration;
+#ifdef DEBUG
+ if (xkbDebugFlags>1)
+ ErrorF("beep: %d (count= %d)\n",xkbInfo->beepType,xkbInfo->beepCount);
+#endif
+ name= None;
+ switch (xkbInfo->beepType) {
+ default:
+ ErrorF("Unknown beep type %d\n",xkbInfo->beepType);
+ case _BEEP_NONE:
+ duration= 0;
+ break;
+
+ /* When an LED is turned on, we want a high-pitched beep.
+ * When the LED it turned off, we want a low-pitched beep.
+ * If we cannot do pitch, we want a single beep for on and two
+ * beeps for off.
+ */
+ case _BEEP_LED_ON:
+ if (name==None) name= ledOn;
+ duration= SHORT_TONE;
+ pitch= HIGH_PITCH;
+ break;
+ case _BEEP_LED_OFF:
+ if (name==None) name= ledOff;
+ duration= SHORT_TONE;
+ pitch= LOW_PITCH;
+ if (!doesPitch && xkbInfo->beepCount<1)
+ next = SHORT_DELAY;
+ break;
+
+ /* When a Feature is turned on, we want an up-siren.
+ * When a Feature is turned off, we want a down-siren.
+ * If we cannot do pitch, we want a single beep for on and two
+ * beeps for off.
+ */
+ case _BEEP_FEATURE_ON:
+ if (name==None) name= featureOn;
+ if (xkbInfo->beepCount<1) {
+ pitch= LOW_PITCH;
+ duration= VERY_LONG_TONE;
+ if (doesPitch)
+ next= SHORT_DELAY;
+ }
+ else {
+ pitch= MID_PITCH;
+ duration= SHORT_TONE;
+ }
+ break;
+
+ case _BEEP_FEATURE_OFF:
+ if (name==None) name= featureOff;
+ if (xkbInfo->beepCount<1) {
+ pitch= MID_PITCH;
+ if (doesPitch)
+ duration= VERY_LONG_TONE;
+ else duration= SHORT_TONE;
+ next= SHORT_DELAY;
+ }
+ else {
+ pitch= LOW_PITCH;
+ duration= SHORT_TONE;
+ }
+ break;
+
+ /* Two high beeps indicate an LED or Feature changed
+ * state, but that another LED or Feature is also on.
+ * [[[WDW - This is not in AccessDOS ]]]
+ */
+ case _BEEP_LED_CHANGE:
+ if (name==None) name= ledChange;
+ case _BEEP_FEATURE_CHANGE:
+ if (name==None) name= featureChange;
+ duration= SHORT_TONE;
+ pitch= HIGH_PITCH;
+ if (xkbInfo->beepCount<1) {
+ next= SHORT_DELAY;
+ }
+ break;
+
+ /* Three high-pitched beeps are the warning that SlowKeys
+ * is going to be turned on or off.
+ */
+ case _BEEP_SLOW_WARN:
+ if (name==None) name= slowWarn;
+ duration= SHORT_TONE;
+ pitch= HIGH_PITCH;
+ if (xkbInfo->beepCount<2)
+ next= SHORT_DELAY;
+ break;
+
+ /* Click on SlowKeys press and accept.
+ * Deep pitch when a SlowKey or BounceKey is rejected.
+ * [[[WDW - Rejects are not in AccessDOS ]]]
+ * If we cannot do pitch, we want single beeps.
+ */
+ case _BEEP_SLOW_PRESS:
+ if (name==None) name= slowPress;
+ case _BEEP_SLOW_ACCEPT:
+ if (name==None) name= slowAccept;
+ case _BEEP_SLOW_RELEASE:
+ if (name==None) name= slowRelease;
+ duration= CLICK_DURATION;
+ pitch= CLICK_PITCH;
+ break;
+ case _BEEP_BOUNCE_REJECT:
+ if (name==None) name= bounceReject;
+ case _BEEP_SLOW_REJECT:
+ if (name==None) name= slowReject;
+ duration= SHORT_TONE;
+ pitch= DEEP_PITCH;
+ break;
+
+ /* Low followed by high pitch when a StickyKey is latched.
+ * High pitch when a StickyKey is locked.
+ * Low pitch when unlocked.
+ * If we cannot do pitch, two beeps for latch, nothing for
+ * lock, and two for unlock.
+ */
+ case _BEEP_STICKY_LATCH:
+ if (name==None) name= stickyLatch;
+ duration= SHORT_TONE;
+ if (xkbInfo->beepCount<1) {
+ next= SHORT_DELAY;
+ pitch= LOW_PITCH;
+ }
+ else pitch= HIGH_PITCH;
+ break;
+ case _BEEP_STICKY_LOCK:
+ if (name==None) name= stickyLock;
+ if (doesPitch) {
+ duration= SHORT_TONE;
+ pitch= HIGH_PITCH;
+ }
+ break;
+ case _BEEP_STICKY_UNLOCK:
+ if (name==None) name= stickyUnlock;
+ duration= SHORT_TONE;
+ pitch= LOW_PITCH;
+ if (!doesPitch && xkbInfo->beepCount<1)
+ next = SHORT_DELAY;
+ break;
+ }
+ if (timer == NULL && duration>0) {
+ CARD32 starttime = GetTimeInMillis();
+ CARD32 elapsedtime;
+
+ ctrl->bell_duration= duration;
+ ctrl->bell_pitch= pitch;
+ if (xkbInfo->beepCount==0) {
+ XkbHandleBell(0,0,dev,ctrl->bell,(pointer)ctrl,KbdFeedbackClass,name,None,
+ NULL);
+ }
+ else if (xkbInfo->desc->ctrls->enabled_ctrls&XkbAudibleBellMask) {
+ (*dev->kbdfeed->BellProc)(ctrl->bell,dev,(pointer)ctrl,KbdFeedbackClass);
+ }
+ ctrl->bell_duration= oldDuration;
+ ctrl->bell_pitch= oldPitch;
+ xkbInfo->beepCount++;
+
+ /* Some DDX schedule the beep and return immediately, others don't
+ return until the beep is completed. We measure the time and if
+ it's less than the beep duration, make sure not to schedule the
+ next beep until after the current one finishes. */
+
+ elapsedtime = GetTimeInMillis();
+ if (elapsedtime > starttime) { /* watch out for millisecond counter
+ overflow! */
+ elapsedtime -= starttime;
+ } else {
+ elapsedtime = 0;
+ }
+ if (elapsedtime < duration) {
+ next += duration - elapsedtime;
+ }
+
+ }
+ return next;
+}
+
+int
+XkbDDXAccessXBeep(DeviceIntPtr dev,unsigned what,unsigned which)
+{
+XkbSrvInfoRec *xkbInfo= dev->key->xkbInfo;
+CARD32 next;
+
+ xkbInfo->beepType= what;
+ xkbInfo->beepCount= 0;
+ next= _XkbDDXBeepExpire(NULL,0,(pointer)dev);
+ if (next>0) {
+ xkbInfo->beepTimer= TimerSet(xkbInfo->beepTimer,
+ 0, next,
+ _XkbDDXBeepExpire, (pointer)dev);
+ }
+ return 1;
+}
diff --git a/nx-X11/programs/Xserver/xkb/ddxConfig.c b/nx-X11/programs/Xserver/xkb/ddxConfig.c
new file mode 100644
index 000000000..b023531dc
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/ddxConfig.c
@@ -0,0 +1,215 @@
+/* $Xorg: ddxConfig.c,v 1.3 2000/08/17 19:53:45 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/ddxConfig.c,v 3.8 2002/12/20 20:18:35 paulo Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "os.h"
+#define XKBSRV_NEED_FILE_FUNCS
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XKBconfig.h>
+
+Bool
+XkbDDXApplyConfig(XPointer cfg_in,XkbSrvInfoPtr info)
+{
+XkbConfigRtrnPtr rtrn;
+XkbDescPtr xkb;
+Bool ok;
+XkbEventCauseRec cause;
+
+ xkb= info->desc;
+ rtrn= (XkbConfigRtrnPtr)cfg_in;
+ if (rtrn==NULL)
+ return True;
+ ok= XkbCFApplyRtrnValues(rtrn,XkbCFDflts,xkb);
+ if (rtrn->initial_mods.replace) {
+ info->state.locked_mods= rtrn->initial_mods.mods;
+ }
+ else {
+ info->state.locked_mods|= rtrn->initial_mods.mods;
+ if (rtrn->initial_mods.mods_clear)
+ info->state.locked_mods&= ~rtrn->initial_mods.mods_clear;
+ }
+ XkbComputeDerivedState(info);
+ XkbSetCauseUnknown(&cause);
+ XkbUpdateIndicators(info->device,XkbAllIndicatorsMask,False,NULL,&cause);
+ if (info->device && info->device->kbdfeed) {
+ DeviceIntPtr dev;
+ KeybdCtrl newCtrl;
+ dev= info->device;
+ newCtrl= dev->kbdfeed->ctrl;
+ if (rtrn->click_volume>=0)
+ newCtrl.click= rtrn->click_volume;
+ if (rtrn->bell_volume>=0)
+ newCtrl.bell= rtrn->bell_volume;
+ if (rtrn->bell_pitch>0)
+ newCtrl.bell_pitch= rtrn->bell_pitch;
+ if (rtrn->bell_duration>0)
+ newCtrl.bell_duration= rtrn->bell_duration;
+ if (dev->kbdfeed->CtrlProc)
+ (*dev->kbdfeed->CtrlProc)(dev,&newCtrl);
+ }
+ XkbCFFreeRtrn(rtrn,XkbCFDflts,xkb);
+ return ok;
+}
+
+XPointer
+XkbDDXPreloadConfig( char ** rulesRtrn,
+ XkbRF_VarDefsPtr defs,
+ XkbComponentNamesPtr names,
+ DeviceIntPtr dev)
+{
+char buf[PATH_MAX];
+char * dName;
+FILE * file;
+XkbConfigRtrnPtr rtrn;
+
+#if defined(MetroLink)
+ if (dev && dev->name)
+ dName= dev->name;
+ else dName= "";
+ /* It doesn't appear that XkbBaseDirectory could ever get set to NULL */
+ sprintf(buf,"%s/X%s-config%s%s",XkbBaseDirectory,display,
+ (dName[0]?".":""),dName);
+#else
+ if (dev && dev->name)
+ dName= dev->name;
+ else dName= "";
+ if (XkbBaseDirectory!=NULL) {
+ if (strlen(XkbBaseDirectory)+strlen(display)
+ +strlen(dName)+10+(dName[0]?1:0) > PATH_MAX)
+ {
+#ifdef DEBUG
+ ErrorF("path exceeds max length\n");
+#endif
+ return NULL;
+ }
+ sprintf(buf,"%s/X%s-config%s%s",XkbBaseDirectory,display,
+ (dName[0]?".":""),dName);
+ }
+ else {
+ if (strlen(display)+strlen(dName)+10+(dName[0]?1:0) > PATH_MAX)
+ {
+#ifdef DEBUG
+ ErrorF("path exceeds max length\n");
+#endif
+ return NULL;
+ }
+ sprintf(buf,"X%s-config%s%s",display,(dName[0]?".":""),dName);
+ }
+#endif
+#ifdef __UNIXOS2__
+ strcpy(buf,(char*)__XOS2RedirRoot(buf));
+#endif
+#ifdef DEBUG
+ ErrorF("Looking for keyboard configuration in %s...",buf);
+#endif
+ file= fopen(buf,"r");
+ if (file==NULL) {
+#ifdef DEBUG
+ ErrorF("file not found\n");
+#endif
+ return NULL;
+ }
+ rtrn= _XkbTypedCalloc(1,XkbConfigRtrnRec);
+ if (rtrn!=NULL) {
+ if (!XkbCFParse(file,XkbCFDflts,NULL,rtrn)) {
+#ifdef DEBUG
+ ErrorF("error\n");
+#endif
+ ErrorF("Error parsing config file: ");
+ XkbCFReportError(stderr,buf,rtrn->error,rtrn->line);
+ _XkbFree(rtrn);
+ fclose(file);
+ return NULL;
+ }
+#ifdef DEBUG
+ ErrorF("found it\n");
+#endif
+ if (rtrn->rules_file) {
+ *rulesRtrn= rtrn->rules_file;
+ rtrn->rules_file= NULL;
+ }
+ if (rtrn->model) {
+ defs->model= rtrn->model;
+ rtrn->model= NULL;
+ }
+ if (rtrn->layout) {
+ defs->layout= rtrn->layout;
+ rtrn->layout= NULL;
+ }
+ if (rtrn->variant) {
+ defs->variant= rtrn->variant;
+ rtrn->variant= NULL;
+ }
+ if (rtrn->options) {
+ defs->options= rtrn->options;
+ rtrn->options= NULL;
+ }
+ XkbSetRulesUsed(defs);
+
+ if (rtrn->keycodes!=NULL) {
+ if (names->keycodes) _XkbFree(names->keycodes);
+ names->keycodes= rtrn->keycodes;
+ rtrn->keycodes= NULL;
+ }
+ if (rtrn->geometry!=NULL) {
+ if (names->geometry) _XkbFree(names->geometry);
+ names->geometry= rtrn->geometry;
+ rtrn->geometry= NULL;
+ }
+ if (rtrn->symbols!=NULL) {
+ if (rtrn->phys_symbols==NULL)
+ rtrn->phys_symbols= _XkbDupString(names->symbols);
+ if (names->symbols) _XkbFree(names->symbols);
+ names->symbols= rtrn->symbols;
+ rtrn->symbols= NULL;
+ }
+ if (rtrn->types!=NULL) {
+ if (names->types) _XkbFree(names->types);
+ names->types= rtrn->types;
+ rtrn->types= NULL;
+ }
+ if (rtrn->compat!=NULL) {
+ if (names->compat) _XkbFree(names->compat);
+ names->compat= rtrn->compat;
+ rtrn->compat= NULL;
+ }
+ }
+ fclose(file);
+ return (XPointer)rtrn;
+}
diff --git a/nx-X11/programs/Xserver/xkb/ddxCtrls.c b/nx-X11/programs/Xserver/xkb/ddxCtrls.c
new file mode 100644
index 000000000..2e4e106ce
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/ddxCtrls.c
@@ -0,0 +1,131 @@
+/* $Xorg: ddxCtrls.c,v 1.3 2000/08/17 19:53:45 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/ddxCtrls.c,v 1.3 2001/01/17 22:37:14 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XI.h>
+
+void
+XkbDDXKeybdCtrlProc(DeviceIntPtr dev,KeybdCtrl *ctrl)
+{
+int realRepeat;
+
+ realRepeat= ctrl->autoRepeat;
+ if ((dev->kbdfeed)&&(XkbDDXUsesSoftRepeat(dev)))
+ ctrl->autoRepeat= 0;
+#ifdef DEBUG
+if (xkbDebugFlags&0x4) {
+ ErrorF("XkbDDXKeybdCtrlProc: setting repeat to %d (real repeat is %d)\n",
+ ctrl->autoRepeat,realRepeat);
+}
+#endif
+ if (dev->key && dev->key->xkbInfo && dev->key->xkbInfo->kbdProc)
+ (*dev->key->xkbInfo->kbdProc)(dev,ctrl);
+ ctrl->autoRepeat= realRepeat;
+ return;
+}
+
+
+int
+XkbDDXUsesSoftRepeat(DeviceIntPtr pXDev)
+{
+#ifndef XKB_ALWAYS_USES_SOFT_REPEAT
+ if (pXDev && pXDev->kbdfeed ) {
+ if (pXDev->kbdfeed->ctrl.autoRepeat) {
+ if (pXDev->key && pXDev->key->xkbInfo) {
+ XkbDescPtr xkb;
+ xkb= pXDev->key->xkbInfo->desc;
+ if ((xkb->ctrls->repeat_delay == 660) &&
+ (xkb->ctrls->repeat_interval == 40) &&
+ ((xkb->ctrls->enabled_ctrls&(XkbSlowKeysMask|
+ XkbBounceKeysMask|
+ XkbMouseKeysMask))==0)) {
+ return 0;
+ }
+ return ((xkb->ctrls->enabled_ctrls&XkbRepeatKeysMask)!=0);
+ }
+ }
+ }
+ return 0;
+#else
+ return 1;
+#endif
+}
+
+void
+XkbDDXChangeControls(DeviceIntPtr dev,XkbControlsPtr old,XkbControlsPtr new)
+{
+unsigned changed, i;
+unsigned char *rep_old, *rep_new, *rep_fb;
+
+ changed= new->enabled_ctrls^old->enabled_ctrls;
+#ifdef NOTDEF
+ if (changed&XkbRepeatKeysMask) {
+ if (dev->kbdfeed) {
+ int realRepeat;
+
+ if (new->enabled_ctrls&XkbRepeatKeysMask)
+ dev->kbdfeed->ctrl.autoRepeat= realRepeat= 1;
+ else dev->kbdfeed->ctrl.autoRepeat= realRepeat= 0;
+
+ if (XkbDDXUsesSoftRepeat(dev))
+ dev->kbdfeed->ctrl.autoRepeat= FALSE;
+ if (dev->kbdfeed->CtrlProc)
+ (*dev->kbdfeed->CtrlProc)(dev,&dev->kbdfeed->ctrl);
+ dev->kbdfeed->ctrl.autoRepeat= realRepeat;
+ }
+ }
+#endif
+ for (rep_old = old->per_key_repeat,
+ rep_new = new->per_key_repeat,
+ rep_fb = dev->kbdfeed->ctrl.autoRepeats,
+ i = 0; i < XkbPerKeyBitArraySize; i++) {
+ if (rep_old[i] != rep_new[i]) {
+ rep_fb[i] = rep_new[i];
+ changed &= XkbPerKeyRepeatMask;
+ }
+ }
+
+ if (changed&XkbPerKeyRepeatMask) {
+ if (dev->kbdfeed->CtrlProc)
+ (*dev->kbdfeed->CtrlProc)(dev,&dev->kbdfeed->ctrl);
+ }
+ return;
+}
+
diff --git a/nx-X11/programs/Xserver/xkb/ddxDevBtn.c b/nx-X11/programs/Xserver/xkb/ddxDevBtn.c
new file mode 100644
index 000000000..d0e37f263
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/ddxDevBtn.c
@@ -0,0 +1,102 @@
+/* $Xorg: ddxDevBtn.c,v 1.3 2000/08/17 19:53:45 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/ddxDevBtn.c,v 3.3 2001/08/23 21:49:51 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+
+extern int DeviceValuator;
+
+void
+XkbDDXFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
+{
+int * devVal;
+INT32 * evVal;
+xEvent events[2];
+deviceKeyButtonPointer *btn;
+deviceValuator * val;
+int x,y;
+int nAxes, i, count;
+
+ if ((dev==(DeviceIntPtr)LookupPointerDevice())||(!dev->public.on))
+ return;
+
+ nAxes = (dev->valuator?dev->valuator->numAxes:0);
+ if (nAxes > 6)
+ nAxes = 6;
+
+ GetSpritePosition(&x,&y);
+ btn= (deviceKeyButtonPointer *) &events[0];
+ val= (deviceValuator *) &events[1];
+ if (press) btn->type= DeviceButtonPress;
+ else btn->type= DeviceButtonRelease;
+ btn->detail= button;
+ btn->time= GetTimeInMillis();
+ btn->root_x= x;
+ btn->root_y= y;
+ btn->deviceid= dev->id;
+ count= 1;
+ if (nAxes>0) {
+ btn->deviceid|= 0x80;
+ val->type = DeviceValuator;
+ val->deviceid = dev->id;
+ val->first_valuator = 0;
+
+ evVal= &val->valuator0;
+ devVal= dev->valuator->axisVal;
+ for (i=nAxes;i>0;i--) {
+ *evVal++ = *devVal++;
+ if (evVal > &val->valuator5) {
+ int tmp = val->first_valuator+6;
+ val->num_valuators = 6;
+ val++;
+ evVal= &val->valuator0;
+ val->first_valuator= tmp;
+ }
+ }
+ if ((nAxes % 6) != 0) {
+ val->num_valuators = (nAxes % 6);
+ }
+ count= 1+((nAxes+5)/6);
+ }
+
+ (*dev->public.processInputProc)((xEventPtr)btn, dev, count);
+ return;
+}
diff --git a/nx-X11/programs/Xserver/xkb/ddxFakeBtn.c b/nx-X11/programs/Xserver/xkb/ddxFakeBtn.c
new file mode 100644
index 000000000..73c8a2415
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/ddxFakeBtn.c
@@ -0,0 +1,61 @@
+/* $Xorg: ddxFakeBtn.c,v 1.3 2000/08/17 19:53:45 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86$ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XI.h>
+
+void
+XkbDDXFakePointerButton(int event,int button)
+{
+xEvent ev;
+int x,y;
+DevicePtr ptr;
+
+ if ((ptr = LookupPointerDevice())==NULL)
+ return;
+ GetSpritePosition(&x,&y);
+ ev.u.u.type = event;
+ ev.u.u.detail = button;
+ ev.u.keyButtonPointer.time = GetTimeInMillis();
+ ev.u.keyButtonPointer.rootX = x;
+ ev.u.keyButtonPointer.rootY = y;
+ (*ptr->processInputProc)( &ev, (DeviceIntPtr)ptr, 1 );
+ return;
+}
diff --git a/nx-X11/programs/Xserver/xkb/ddxFakeMtn.c b/nx-X11/programs/Xserver/xkb/ddxFakeMtn.c
new file mode 100644
index 000000000..ffd6f5d79
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/ddxFakeMtn.c
@@ -0,0 +1,122 @@
+/* $XdotOrg: xc/programs/Xserver/xkb/ddxFakeMtn.c,v 1.5 2005/07/03 07:02:09 daniels Exp $ */
+/* $Xorg: ddxFakeMtn.c,v 1.3 2000/08/17 19:53:45 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/ddxFakeMtn.c,v 1.5 2003/09/13 16:39:01 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XI.h>
+
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+
+#include "mipointer.h"
+#include "mipointrst.h"
+
+void
+XkbDDXFakePointerMotion(unsigned flags,int x,int y)
+{
+int oldX,oldY;
+ScreenPtr pScreen, oldScreen;
+
+ GetSpritePosition(&oldX, &oldY);
+ pScreen = oldScreen = GetSpriteWindow()->drawable.pScreen;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ BoxRec box;
+ int i;
+
+ if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
+ oldX, oldY, &box)) {
+ FOR_NSCREENS(i) {
+ if(i == pScreen->myNum)
+ continue;
+ if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i],
+ oldX, oldY, &box)) {
+ pScreen = screenInfo.screens[i];
+ break;
+ }
+ }
+ }
+ oldScreen = pScreen;
+
+ if (flags&XkbSA_MoveAbsoluteX)
+ oldX= x;
+ else oldX+= x;
+ if (flags&XkbSA_MoveAbsoluteY)
+ oldY= y;
+ else oldY+= y;
+
+ if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
+ oldX, oldY, &box)) {
+ FOR_NSCREENS(i) {
+ if(i == pScreen->myNum)
+ continue;
+ if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i],
+ oldX, oldY, &box)) {
+ pScreen = screenInfo.screens[i];
+ break;
+ }
+ }
+ }
+ oldX -= panoramiXdataPtr[pScreen->myNum].x;
+ oldY -= panoramiXdataPtr[pScreen->myNum].y;
+ }
+ else
+#endif
+ {
+ if (flags&XkbSA_MoveAbsoluteX)
+ oldX= x;
+ else oldX+= x;
+ if (flags&XkbSA_MoveAbsoluteY)
+ oldY= y;
+ else oldY+= y;
+
+#define GetScreenPrivate(s) ((miPointerScreenPtr) ((s)->devPrivates[miPointerScreenIndex].ptr))
+ (*(GetScreenPrivate(oldScreen))->screenFuncs->CursorOffScreen)
+ (&pScreen, &oldX, &oldY);
+ }
+
+ if (pScreen != oldScreen)
+ NewCurrentScreen(pScreen, oldX, oldY);
+ if (pScreen->SetCursorPosition)
+ (*pScreen->SetCursorPosition)(pScreen, oldX, oldY, TRUE);
+}
diff --git a/nx-X11/programs/Xserver/xkb/ddxInit.c b/nx-X11/programs/Xserver/xkb/ddxInit.c
new file mode 100644
index 000000000..8b76b7cb1
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/ddxInit.c
@@ -0,0 +1,48 @@
+/* $Xorg: ddxInit.c,v 1.3 2000/08/17 19:53:45 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86$ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XI.h>
+
+int
+XkbDDXInitDevice(DeviceIntPtr dev)
+{
+ return 1;
+}
diff --git a/nx-X11/programs/Xserver/xkb/ddxKeyClick.c b/nx-X11/programs/Xserver/xkb/ddxKeyClick.c
new file mode 100644
index 000000000..c940e5321
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/ddxKeyClick.c
@@ -0,0 +1,52 @@
+/* $Xorg: ddxKeyClick.c,v 1.3 2000/08/17 19:53:46 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86$ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XI.h>
+
+void
+XkbDDXKeyClick(DeviceIntPtr pXDev,int keycode,int synthetic)
+{
+#ifdef DEBUG
+ if (xkbDebugFlags)
+ ErrorF("Click.\n");
+#endif
+ return;
+}
diff --git a/nx-X11/programs/Xserver/xkb/ddxKillSrv.c b/nx-X11/programs/Xserver/xkb/ddxKillSrv.c
new file mode 100644
index 000000000..ee0acb028
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/ddxKillSrv.c
@@ -0,0 +1,61 @@
+/* $Xorg: ddxKillSrv.c,v 1.3 2000/08/17 19:53:46 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/ddxKillSrv.c,v 1.3 2002/11/23 19:27:50 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XI.h>
+
+#ifdef XF86DDXACTIONS
+#include "xf86.h"
+#endif
+
+int
+XkbDDXTerminateServer(DeviceIntPtr dev,KeyCode key,XkbAction *act)
+{
+#ifdef XF86DDXACTIONS
+ xf86ProcessActionEvent(ACTION_TERMINATE, NULL);
+#else
+ GiveUp(1);
+#endif
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/xkb/ddxLEDs.c b/nx-X11/programs/Xserver/xkb/ddxLEDs.c
new file mode 100644
index 000000000..fb5f72bf8
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/ddxLEDs.c
@@ -0,0 +1,74 @@
+/* $Xorg: ddxLEDs.c,v 1.3 2000/08/17 19:53:46 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86$ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XI.h>
+
+void
+XkbDDXUpdateIndicators(DeviceIntPtr dev,CARD32 new)
+{
+ dev->kbdfeed->ctrl.leds= new;
+ (*dev->kbdfeed->CtrlProc)(dev,&dev->kbdfeed->ctrl);
+ return;
+}
+
+void
+XkbDDXUpdateDeviceIndicators( DeviceIntPtr dev,
+ XkbSrvLedInfoPtr sli,
+ CARD32 new)
+{
+ if (sli->fb.kf==dev->kbdfeed)
+ XkbDDXUpdateIndicators(dev,new);
+ else if (sli->class==KbdFeedbackClass) {
+ KbdFeedbackPtr kf;
+ kf= sli->fb.kf;
+ if (kf && kf->CtrlProc) {
+ (*kf->CtrlProc)(dev,&kf->ctrl);
+ }
+ }
+ else if (sli->class==LedFeedbackClass) {
+ LedFeedbackPtr lf;
+ lf= sli->fb.lf;
+ if (lf && lf->CtrlProc) {
+ (*lf->CtrlProc)(dev,&lf->ctrl);
+ }
+ }
+ return;
+}
diff --git a/nx-X11/programs/Xserver/xkb/ddxList.c b/nx-X11/programs/Xserver/xkb/ddxList.c
new file mode 100644
index 000000000..9c961e934
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/ddxList.c
@@ -0,0 +1,304 @@
+/* $Xorg: ddxList.c,v 1.3 2000/08/17 19:53:46 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/ddxList.c,v 3.8 2003/07/16 01:39:05 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xos.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include <X11/extensions/XKM.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#define XKBSRV_NEED_FILE_FUNCS
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XI.h>
+
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+
+#ifdef WIN32
+/* from ddxLoad.c */
+extern const char* Win32TempDir();
+extern int Win32System(const char *cmdline);
+#undef System
+#define System Win32System
+
+#define W32_tmparg " '%s'"
+#define W32_tmpfile ,tmpname
+#define W32_tmplen strlen(tmpname)+3
+#else
+#define W32_tmparg
+#define W32_tmpfile
+#define W32_tmplen 0
+#endif
+
+/***====================================================================***/
+
+static char *componentDirs[_XkbListNumComponents] = {
+ "keymap", "keycodes", "types", "compat", "symbols", "geometry"
+};
+
+/***====================================================================***/
+
+static Status
+_AddListComponent( XkbSrvListInfoPtr list,
+ int what,
+ unsigned flags,
+ char * str,
+ ClientPtr client)
+{
+int slen,wlen;
+unsigned char * wire8;
+unsigned short *wire16;
+char * tmp;
+
+ if (list->nTotal>=list->maxRtrn) {
+ list->nTotal++;
+ return Success;
+ }
+ tmp= strchr(str,')');
+ if ((tmp==NULL)&&((tmp=strchr(str,'('))==NULL)) {
+ slen= strlen(str);
+ while ((slen>0) && isspace(str[slen-1])) {
+ slen--;
+ }
+ }
+ else {
+ slen= (tmp-str+1);
+ }
+ wlen= (((slen+1)/2)*2)+4; /* four bytes for flags and length, pad to */
+ /* 2-byte boundary */
+ if ((list->szPool-list->nPool)<wlen) {
+ if (wlen>1024) list->szPool+= XkbPaddedSize(wlen*2);
+ else list->szPool+= 1024;
+ list->pool= _XkbTypedRealloc(list->pool,list->szPool,char);
+ if (!list->pool)
+ return BadAlloc;
+ }
+ wire16= (unsigned short *)&list->pool[list->nPool];
+ wire8= (unsigned char *)&wire16[2];
+ wire16[0]= flags;
+ wire16[1]= slen;
+ memcpy(wire8,str,slen);
+ if (client->swapped) {
+ register int n;
+ swaps(&wire16[0],n);
+ swaps(&wire16[1],n);
+ }
+ list->nPool+= wlen;
+ list->nFound[what]++;
+ list->nTotal++;
+ return Success;
+}
+
+/***====================================================================***/
+static Status
+XkbDDXListComponent( DeviceIntPtr dev,
+ int what,
+ XkbSrvListInfoPtr list,
+ ClientPtr client)
+{
+char *file,*map,*tmp,*buf=NULL;
+FILE *in;
+Status status;
+int rval;
+Bool haveDir;
+#ifdef WIN32
+char tmpname[PATH_MAX];
+#endif
+
+ if ((list->pattern[what]==NULL)||(list->pattern[what][0]=='\0'))
+ return Success;
+ file= list->pattern[what];
+ map= strrchr(file,'(');
+ if (map!=NULL) {
+ char *tmp;
+ map++;
+ tmp= strrchr(map,')');
+ if ((tmp==NULL)||(tmp[1]!='\0')) {
+ /* illegal pattern. No error, but no match */
+ return Success;
+ }
+ }
+
+ in= NULL;
+ haveDir= True;
+#ifdef WIN32
+ strcpy(tmpname, Win32TempDir());
+ strcat(tmpname, "\\xkb_XXXXXX");
+ (void) mktemp(tmpname);
+#endif
+ if (XkbBaseDirectory!=NULL) {
+ if ((list->pattern[what][0]=='*')&&(list->pattern[what][1]=='\0')) {
+ buf = Xprintf("%s/%s.dir",XkbBaseDirectory,componentDirs[what]);
+ in= fopen(buf,"r");
+ xfree (buf);
+ buf = NULL;
+ }
+ if (!in) {
+ haveDir= False;
+ buf = Xprintf(
+ "'%s/xkbcomp' '-R%s/%s' -w %ld -l -vlfhpR '%s'" W32_tmparg,
+ XkbBinDirectory,XkbBaseDirectory,componentDirs[what],(long)
+ ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)),
+ file W32_tmpfile
+ );
+ }
+ }
+ else {
+ if ((list->pattern[what][0]=='*')&&(list->pattern[what][1]=='\0')) {
+ buf = Xprintf("%s.dir",componentDirs[what]);
+ in= fopen(buf,"r");
+ xfree (buf);
+ buf = NULL;
+ }
+ if (!in) {
+ haveDir= False;
+ buf = Xprintf(
+ "xkbcomp -R%s -w %ld -l -vlfhpR '%s'" W32_tmparg,
+ componentDirs[what],(long)
+ ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)),
+ file W32_tmpfile
+ );
+ }
+ }
+ status= Success;
+ if (!haveDir)
+ {
+#ifndef WIN32
+ in= Popen(buf,"r");
+#else
+#ifdef DEBUG_CMD
+ ErrorF("xkb executes: %s\n",buf);
+#endif
+ if (System(buf) < 0)
+ ErrorF("Could not invoke keymap compiler\n");
+ else
+ in= fopen(tmpname, "r");
+#endif
+ }
+ if (!in)
+ {
+ if (buf != NULL)
+ xfree (buf);
+#ifdef WIN32
+ unlink(tmpname);
+#endif
+ return BadImplementation;
+ }
+ list->nFound[what]= 0;
+ while ((status==Success)&&((tmp=fgets(buf,PATH_MAX,in))!=NULL)) {
+ unsigned flags;
+ register unsigned int i;
+ if (*tmp=='#') /* comment, skip it */
+ continue;
+ if (!strncmp(tmp, "Warning:", 8) || !strncmp(tmp, " ", 8))
+ /* skip warnings too */
+ continue;
+ flags= 0;
+ /* each line in the listing is supposed to start with two */
+ /* groups of eight characters, which specify the general */
+ /* flags and the flags that are specific to the component */
+ /* if they're missing, fail with BadImplementation */
+ for (i=0;(i<8)&&(status==Success);i++) { /* read the general flags */
+ if (isalpha(*tmp)) flags|= (1L<<i);
+ else if (*tmp!='-') status= BadImplementation;
+ tmp++;
+ }
+ if (status != Success) break;
+ if (!isspace(*tmp)) {
+ status= BadImplementation;
+ break;
+ }
+ else tmp++;
+ for (i=0;(i<8)&&(status==Success);i++) { /* read the component flags */
+ if (isalpha(*tmp)) flags|= (1L<<(i+8));
+ else if (*tmp!='-') status= BadImplementation;
+ tmp++;
+ }
+ if (status != Success) break;
+ if (isspace(*tmp)) {
+ while (isspace(*tmp)) {
+ tmp++;
+ }
+ }
+ else {
+ status= BadImplementation;
+ break;
+ }
+ status= _AddListComponent(list,what,flags,tmp,client);
+ }
+#ifndef WIN32
+ if (haveDir)
+ fclose(in);
+ else if ((rval=pclose(in))!=0) {
+ if (xkbDebugFlags)
+ ErrorF("xkbcomp returned exit code %d\n",rval);
+ }
+#else
+ fclose(in);
+ unlink(tmpname);
+#endif
+ if (buf != NULL)
+ xfree (buf);
+ return status;
+}
+
+/***====================================================================***/
+
+/* ARGSUSED */
+Status
+XkbDDXList(DeviceIntPtr dev,XkbSrvListInfoPtr list,ClientPtr client)
+{
+Status status;
+
+ status= XkbDDXListComponent(dev,_XkbListKeymaps,list,client);
+ if (status==Success)
+ status= XkbDDXListComponent(dev,_XkbListKeycodes,list,client);
+ if (status==Success)
+ status= XkbDDXListComponent(dev,_XkbListTypes,list,client);
+ if (status==Success)
+ status= XkbDDXListComponent(dev,_XkbListCompat,list,client);
+ if (status==Success)
+ status= XkbDDXListComponent(dev,_XkbListSymbols,list,client);
+ if (status==Success)
+ status= XkbDDXListComponent(dev,_XkbListGeometry,list,client);
+ return status;
+}
diff --git a/nx-X11/programs/Xserver/xkb/ddxLoad.c b/nx-X11/programs/Xserver/xkb/ddxLoad.c
new file mode 100644
index 000000000..8def401e8
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/ddxLoad.c
@@ -0,0 +1,965 @@
+/* $Xorg: ddxLoad.c,v 1.3 2000/08/17 19:53:46 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/ddxLoad.c,v 3.35 2003/10/02 13:30:12 eich Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef HAVE_XKB_CONFIG_H
+#include <xkb-config.h>
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+#include <ctype.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xos.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include <X11/extensions/XKM.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#define XKBSRV_NEED_FILE_FUNCS
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XI.h>
+#include "xkb.h"
+
+#if defined(CSRG_BASED) || defined(linux) || defined(__sgi) || defined(AIXV3) || defined(__osf__) || defined(__GNU__)
+#include <paths.h>
+#endif
+
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+
+ /*
+ * If XKM_OUTPUT_DIR specifies a path without a leading slash, it is
+ * relative to the top-level XKB configuration directory.
+ * Making the server write to a subdirectory of that directory
+ * requires some work in the general case (install procedure
+ * has to create links to /var or somesuch on many machines),
+ * so we just compile into /usr/tmp for now.
+ */
+#ifndef XKM_OUTPUT_DIR
+#define XKM_OUTPUT_DIR "compiled/"
+#endif
+
+#define PRE_ERROR_MSG "\"The XKEYBOARD keymap compiler (xkbcomp) reports:\""
+#define ERROR_PREFIX "\"> \""
+#define POST_ERROR_MSG1 "\"Errors from xkbcomp are not fatal to the X server\""
+#define POST_ERROR_MSG2 "\"End of messages from xkbcomp\""
+
+#if defined(__UNIXOS2__) || defined(WIN32)
+#define PATHSEPARATOR "\\"
+#else
+#define PATHSEPARATOR "/"
+#endif
+
+#ifdef WIN32
+
+#include <X11/Xwindows.h>
+const char*
+Win32TempDir()
+{
+ static char buffer[PATH_MAX];
+ if (GetTempPath(sizeof(buffer), buffer))
+ {
+ int len;
+ buffer[sizeof(buffer)-1] = 0;
+ len = strlen(buffer);
+ if (len > 0)
+ if (buffer[len-1] == '\\')
+ buffer[len-1] = 0;
+ return buffer;
+ }
+ if (getenv("TEMP") != NULL)
+ return getenv("TEMP");
+ else if (getenv("TMP") != NULL)
+ return getenv("TEMP");
+ else
+ return "/tmp";
+}
+
+int
+Win32System(const char *cmdline)
+{
+ STARTUPINFO si;
+ PROCESS_INFORMATION pi;
+ DWORD dwExitCode;
+ char *cmd = xstrdup(cmdline);
+
+ ZeroMemory( &si, sizeof(si) );
+ si.cb = sizeof(si);
+ ZeroMemory( &pi, sizeof(pi) );
+
+ if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
+ {
+ LPVOID buffer;
+ if (!FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &buffer,
+ 0,
+ NULL ))
+ {
+ ErrorF("Starting '%s' failed!\n", cmdline);
+ }
+ else
+ {
+ ErrorF("Starting '%s' failed: %s", cmdline, (char *)buffer);
+ LocalFree(buffer);
+ }
+
+ xfree(cmd);
+ return -1;
+ }
+ /* Wait until child process exits. */
+ WaitForSingleObject( pi.hProcess, INFINITE );
+
+ GetExitCodeProcess( pi.hProcess, &dwExitCode);
+
+ /* Close process and thread handles. */
+ CloseHandle( pi.hProcess );
+ CloseHandle( pi.hThread );
+ xfree(cmd);
+
+ return dwExitCode;
+}
+#undef System
+#define System(x) Win32System(x)
+#endif
+
+#ifdef MAKE_XKM_OUTPUT_DIR
+/* Borrow trans_mkdir from Xtransutil.c to more safely make directories */
+# undef X11_t
+# define TRANS_SERVER
+# define PRMSG(lvl,x,a,b,c) \
+ if (lvl <= 1) { LogMessage(X_ERROR,x,a,b,c); } else ((void)0)
+# include <X11/Xtrans/Xtransutil.c>
+# ifndef XKM_OUTPUT_DIR_MODE
+# define XKM_OUTPUT_DIR_MODE 0755
+# endif
+#endif
+
+#ifdef NXAGENT_SERVER
+
+#define NX_XKB_BASE_DIRECTORY "/usr/lib/X11/xkb"
+#define NX_XKB_ALTERNATE_BASE_DIRECTORY "/usr/share/X11/xkb"
+#define NX_KEYMAP_DIR_FILE "keymap.dir"
+#define NX_ALT_XKBCOMP_PATH "/usr/bin"
+
+static char _NXXkbBasePath[PATH_MAX];
+static char _NXXkbCompPath[PATH_MAX];
+
+static int NXVerifyXkbBaseDirectory(const char *dirPath)
+{
+ int size;
+ char *keymapDirFilePath;
+ struct stat keymapDirFileStat;
+
+ /*
+ * If keymap.dir file
+ * is not present into
+ * Xkb Base Directory,
+ * we suppose that the
+ * path is not valid.
+ */
+
+ size = strlen(dirPath) + strlen("/") +
+ strlen(NX_KEYMAP_DIR_FILE) + 1;
+
+ if ((keymapDirFilePath = malloc((size + 1) * sizeof(char))) == NULL)
+ {
+ FatalError("NXVerifyXkbBaseDirectory: malloc failed.\n");
+ }
+
+ strcpy(keymapDirFilePath, dirPath);
+ strcat(keymapDirFilePath, "/");
+ strcat(keymapDirFilePath, NX_KEYMAP_DIR_FILE);
+
+ #ifdef TEST
+ fprintf(stderr, "NXVerifyXkbBaseDirectory: Looking for [%s] file.\n",
+ keymapDirFilePath);
+ #endif
+
+ if (stat(keymapDirFilePath, &keymapDirFileStat) != 0)
+ {
+
+ #ifdef TEST
+ fprintf(stderr, "NXVerifyXkbBaseDirectory: Can't find the keymap.dir file [%s].\n",
+ keymapDirFilePath);
+ #endif
+
+ free(keymapDirFilePath);
+
+ return 0;
+ }
+
+ #ifdef TEST
+ fprintf(stderr, "NXVerifyXkbBaseDirectory: Xkb Base Directory [%s] is valid.\n",
+ dirPath);
+ #endif
+
+ free(keymapDirFilePath);
+
+ return 1;
+}
+
+/*
+ * This function returns the directory
+ * containing the configuration files.
+ * This directory is referred by Xkb-
+ * BaseDirectory variable (generally
+ * it contains the hardcoded path at
+ * compile time). If the directory
+ * does not exist, the function will
+ * try a set of well known directories.
+ */
+
+char *_NXGetXkbBasePath(const char *path)
+{
+ /*
+ * Check the xkb base directory only once.
+ */
+
+ if (*_NXXkbBasePath != '\0')
+ {
+ return _NXXkbBasePath;
+ }
+
+ if (NXVerifyXkbBaseDirectory(XkbBaseDirectory) == 1)
+ {
+ if (strlen(XkbBaseDirectory) + 1 > PATH_MAX)
+ {
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbBasePath: WARNING! Maximum length of xkb base path exceeded.\n");
+ #endif
+
+ goto _NXGetXkbBasePathError;
+ }
+
+ strcpy(_NXXkbBasePath, XkbBaseDirectory);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbBasePath: Using NX xkb base directory path [%s].\n",
+ _NXXkbBasePath);
+ #endif
+
+ return _NXXkbBasePath;
+ }
+
+ if (NXVerifyXkbBaseDirectory(NX_XKB_BASE_DIRECTORY) == 1)
+ {
+ if (strlen(NX_XKB_BASE_DIRECTORY) + 1 > PATH_MAX)
+ {
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbBasePath: WARNING! Maximum length of xkb base path exceeded.\n");
+ #endif
+
+ goto _NXGetXkbBasePathError;
+ }
+
+ strcpy(_NXXkbBasePath, NX_XKB_BASE_DIRECTORY);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbBasePath: Using NX xkb base directory path [%s].\n",
+ _NXXkbBasePath);
+ #endif
+
+ return _NXXkbBasePath;
+ }
+
+ if (NXVerifyXkbBaseDirectory(NX_XKB_ALTERNATE_BASE_DIRECTORY) == 1)
+ {
+ if (strlen(NX_XKB_ALTERNATE_BASE_DIRECTORY) + 1 > PATH_MAX)
+ {
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbBasePath: WARNING! Maximum length of xkb base path exceeded.\n");
+ #endif
+
+ goto _NXGetXkbBasePathError;
+ }
+
+ strcpy(_NXXkbBasePath, NX_XKB_ALTERNATE_BASE_DIRECTORY);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbBasePath: Using NX xkb base directory path [%s].\n",
+ _NXXkbBasePath);
+ #endif
+
+ return _NXXkbBasePath;
+ }
+
+_NXGetXkbBasePathError:
+
+ if (strlen(path) + 1 > PATH_MAX)
+ {
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbBasePath: WARNING! Maximum length of xkb base path exceeded.\n");
+ #endif
+ }
+
+ strcpy(_NXXkbBasePath, path);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbBasePath: Using default xkb base path [%s].\n",
+ _NXXkbBasePath);
+ #endif
+
+ return _NXXkbBasePath;
+}
+
+static int NXVerifyXkbCompPath(char *path)
+{
+ char *xkbCompPath;
+ int xkbCompPathSize;
+ struct stat xkbCompPathStat;
+
+ if (path == NULL)
+ {
+ return 0;
+ }
+
+ xkbCompPathSize = strlen(path) + strlen("/") +
+ strlen("xkbcomp") + 1;
+
+ if ((xkbCompPath = malloc((xkbCompPathSize + 1) * sizeof(char))) == NULL)
+ {
+ FatalError("NXVerifyXkbCompPath: WARNING! malloc failed.\n");
+
+ return 0;
+ }
+
+ strcpy(xkbCompPath, path);
+ strcat(xkbCompPath, "/");
+ strcat(xkbCompPath, "xkbcomp");
+
+ if (stat(xkbCompPath, &xkbCompPathStat) != 0)
+ {
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "NXVerifyXkbCompPath: WARNING! Failed to stat xkbcomp path [%s].\n",
+ xkbCompPath);
+ #endif
+
+ free(xkbCompPath);
+
+ return 0;
+ }
+
+ free(xkbCompPath);
+
+ return 1;
+}
+
+/*
+ * This function returns the directory
+ * containing the xkbcomp executable.
+ * The function will first try to locate
+ * the executable in the hardcoded path
+ * (the same path as the "base" xkb one)
+ * and, if the xkbcomp file couldn't be
+ * found, the function will not include
+ * an explicit path and will rely on the
+ * PATH environment to list the directory.
+ */
+
+char *_NXGetXkbCompPath(const char *path)
+{
+
+ char * xkbCompPath;
+
+ /*
+ * Check the xkbcomp executable
+ * directory only once.
+ */
+
+ if (*_NXXkbCompPath != '\0')
+ {
+ return _NXXkbCompPath;
+ }
+
+ xkbCompPath = _NXGetXkbBasePath(path);
+
+ if (NXVerifyXkbCompPath(xkbCompPath) == 1)
+ {
+ if (strlen(xkbCompPath) + 1 > PATH_MAX)
+ {
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbCompPath: WARNING! Maximum length of xkbcomp path exceeded.\n");
+ #endif
+
+ goto _NXGetXkbCompPathError;
+ }
+
+ strcpy(_NXXkbCompPath, xkbCompPath);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbCompPath: Using xkbcomp path [%s].\n",
+ _NXXkbCompPath);
+ #endif
+
+ return _NXXkbCompPath;
+ }
+
+ xkbCompPath = NX_ALT_XKBCOMP_PATH;
+
+ if (NXVerifyXkbCompPath(xkbCompPath) == 1)
+ {
+ if (strlen(xkbCompPath) + 1 > PATH_MAX)
+ {
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbCompPath: WARNING! Maximum length of xkbcomp path exceeded.\n");
+ #endif
+
+ goto _NXGetXkbCompPathError;
+ }
+
+ strcpy(_NXXkbCompPath, xkbCompPath);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbCompPath: Using NX xkbcomp path [%s].\n",
+ _NXXkbCompPath);
+ #endif
+
+ return _NXXkbCompPath;
+ }
+
+_NXGetXkbCompPathError:
+
+ if (strlen(path) + 1 > PATH_MAX)
+ {
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbCompPath: WARNING! Maximum length of xkbcomp path exceeded.\n");
+ #endif
+ }
+
+ strcpy(_NXXkbCompPath, path);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbCompPath: Using default xkbcomp path [%s].\n",
+ _NXXkbCompPath);
+ #endif
+
+ return _NXXkbCompPath;
+}
+
+#endif
+
+static void
+OutputDirectory(
+ char* outdir,
+ size_t size)
+{
+#ifndef WIN32
+ if (getuid() == 0 && (strlen(XKM_OUTPUT_DIR) < size)
+#ifdef MAKE_XKM_OUTPUT_DIR
+ && (trans_mkdir(XKM_OUTPUT_DIR, XKM_OUTPUT_DIR_MODE) == 0)
+#endif
+ )
+ {
+ /* if server running as root it *may* be able to write */
+ /* FIXME: check whether directory is writable at all */
+ (void) strcpy (outdir, XKM_OUTPUT_DIR);
+ } else
+#endif
+#ifdef _PATH_VARTMP
+ if ((strlen(_PATH_VARTMP) + 1) < size)
+ {
+ (void) strcpy (outdir, _PATH_VARTMP);
+ if (outdir[strlen(outdir) - 1] != '/') /* Hi IBM, Digital */
+ (void) strcat (outdir, "/");
+ } else
+#endif
+#ifdef WIN32
+ if (strlen(Win32TempDir()) + 1 < size)
+ {
+ (void) strcpy(outdir, Win32TempDir());
+ (void) strcat(outdir, "\\");
+ } else
+#endif
+ if (strlen("/tmp/") < size)
+ {
+ (void) strcpy (outdir, "/tmp/");
+ }
+}
+
+Bool
+XkbDDXCompileNamedKeymap( XkbDescPtr xkb,
+ XkbComponentNamesPtr names,
+ char * nameRtrn,
+ int nameRtrnLen)
+{
+char *cmd = NULL,file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile;
+
+ if (names->keymap==NULL)
+ return False;
+ strncpy(file,names->keymap,PATH_MAX); file[PATH_MAX-1]= '\0';
+ if ((map= strrchr(file,'('))!=NULL) {
+ char *tmp;
+ if ((tmp= strrchr(map,')'))!=NULL) {
+ *map++= '\0';
+ *tmp= '\0';
+ }
+ else {
+ map= NULL;
+ }
+ }
+ if ((outFile= strrchr(file,'/'))!=NULL)
+ outFile= _XkbDupString(&outFile[1]);
+ else outFile= _XkbDupString(file);
+ XkbEnsureSafeMapName(outFile);
+ OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
+
+#ifdef NXAGENT_SERVER
+
+ if (_NXGetXkbCompPath(XkbBaseDirectory) != NULL)
+ {
+
+#else
+
+ if (XkbBaseDirectory!=NULL) {
+
+#endif
+
+#ifndef __UNIXOS2__
+
+#ifdef NXAGENT_SERVER
+ char *xkbbasedir = _NXGetXkbCompPath(XkbBaseDirectory);
+ char *xkbbindir = _NXGetXkbCompPath(XkbBinDirectory);
+#else
+ char *xkbbasedir = XkbBaseDirectory;
+ char *xkbbindir = XkbBinDirectory;
+#endif
+
+#else
+ /* relocate the basedir and replace the slashes with backslashes */
+#ifdef NXAGENT_SERVER
+ char *xkbbasedir = (char*)__XOS2RedirRoot(_NXGetXkbCompPath(XkbBaseDirectory));
+ char *xkbbindir = (char*)__XOS2RedirRoot(_NXGetXkbCompPath(XkbBinDirectory));
+#else
+ char *xkbbasedir = (char*)__XOS2RedirRoot(XkbBaseDirectory);
+ char *xkbbindir = (char*)__XOS2RedirRoot(XkbBinDirectory);
+#endif
+ int i;
+
+ for (i=0; i<strlen(xkbbasedir); i++)
+ if (xkbbasedir[i]=='/') xkbbasedir[i]='\\';
+ for (i=0; i<strlen(xkbbindir); i++)
+ if (xkbbindir[i]=='/') xkbbindir[i]='\\';
+#endif
+
+ cmd = Xprintf("\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s \"%s%s.xkm\"",
+ xkbbindir,
+ ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
+ xkbbasedir,(map?"-m ":""),(map?map:""),
+ PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,file,
+ xkm_output_dir,outFile);
+ }
+ else {
+ cmd = Xprintf("xkbcomp -w %d -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s \"%s%s.xkm\"",
+ ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
+ (map?"-m ":""),(map?map:""),
+ PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,file,
+ xkm_output_dir,outFile);
+ }
+#ifdef DEBUG
+ if (xkbDebugFlags) {
+ ErrorF("XkbDDXCompileNamedKeymap compiling keymap using:\n");
+ ErrorF(" \"cmd\"\n");
+ }
+#endif
+#ifdef DEBUG_CMD
+ ErrorF("xkb executes: %s\n",cmd);
+#endif
+ if (System(cmd)==0) {
+ if (nameRtrn) {
+ strncpy(nameRtrn,outFile,nameRtrnLen);
+ nameRtrn[nameRtrnLen-1]= '\0';
+ }
+ if (outFile!=NULL)
+ _XkbFree(outFile);
+ if (cmd!=NULL)
+ xfree(cmd);
+ return True;
+ }
+#ifdef DEBUG
+ ErrorF("Error compiling keymap (%s)\n",names->keymap);
+#endif
+ if (outFile!=NULL)
+ _XkbFree(outFile);
+ if (cmd!=NULL)
+ xfree(cmd);
+ return False;
+}
+
+Bool
+XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
+ XkbComponentNamesPtr names,
+ unsigned want,
+ unsigned need,
+ char * nameRtrn,
+ int nameRtrnLen)
+{
+FILE * out;
+char *buf = NULL, keymap[PATH_MAX],xkm_output_dir[PATH_MAX];
+
+#ifdef WIN32
+char tmpname[PATH_MAX];
+#endif
+ if ((names->keymap==NULL)||(names->keymap[0]=='\0')) {
+ sprintf(keymap,"server-%s",display);
+ }
+ else {
+ if (strlen(names->keymap) > PATH_MAX - 1) {
+ ErrorF("name of keymap (%s) exceeds max length\n", names->keymap);
+ return False;
+ }
+ strcpy(keymap,names->keymap);
+ }
+
+ XkbEnsureSafeMapName(keymap);
+ OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
+#ifdef WIN32
+ strcpy(tmpname, Win32TempDir());
+ strcat(tmpname, "\\xkb_XXXXXX");
+ (void) mktemp(tmpname);
+#endif
+
+#ifdef NXAGENT_SERVER
+ if (_NXGetXkbCompPath(XkbBaseDirectory)!=NULL) {
+#else
+ if (XkbBaseDirectory!=NULL) {
+#endif
+
+#ifndef WIN32
+ char *xkmfile = "-";
+#else
+ /* WIN32 has no popen. The input must be stored in a file which is used as input
+ for xkbcomp. xkbcomp does not read from stdin. */
+ char *xkmfile = tmpname;
+#endif
+#ifndef __UNIXOS2__
+#ifdef NXAGENT_SERVER
+ char *xkbbasedir = _NXGetXkbCompPath(XkbBaseDirectory);
+ char *xkbbindir = _NXGetXkbCompPath(XkbBinDirectory);
+#else
+ char *xkbbasedir = XkbBaseDirectory;
+ char *xkbbindir = XkbBinDirectory;
+#endif
+#else
+ int i;
+#ifdef NXAGENT_SERVER
+ char *xkbbasedir = (char*)__XOS2RedirRoot(_NXGetXkbCompPath(XkbBaseDirectory));
+ char *xkbbindir = (char*)__XOS2RedirRoot(_NXGetXkbCompPath(XkbBinDirectory));
+#else
+ char *xkbbasedir = (char*)__XOS2RedirRoot(XkbBaseDirectory);
+ char *xkbbindir = (char*)__XOS2RedirRoot(XkbBinDirectory);
+#endif
+ for (i=0; i<strlen(xkbbasedir); i++)
+ if (xkbbasedir[i]=='/') xkbbasedir[i]='\\';
+ for (i=0; i<strlen(xkbbindir); i++)
+ if (xkbbindir[i]=='/') xkbbindir[i]='\\';
+#endif
+
+ buf = Xprintf(
+ "\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm \"%s\" -em1 %s -emp %s -eml %s \"%s%s.xkm\"",
+ xkbbindir,
+ ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
+ xkbbasedir, xkmfile,
+ PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,
+ xkm_output_dir,keymap);
+ }
+ else {
+#ifndef WIN32
+ char *xkmfile = "-";
+#else
+ char *xkmfile = tmpname;
+#endif
+ buf = Xprintf(
+ "xkbcomp -w %d -xkm \"%s\" -em1 %s -emp %s -eml %s \"%s%s.xkm\"",
+ ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
+ xkmfile,
+ PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,
+ xkm_output_dir,keymap);
+ }
+
+ #ifdef TEST
+ fprintf(stderr, "XkbDDXCompileKeymapByNames: Executing command [%s].\n", buf);
+ #endif
+
+#ifndef WIN32
+ out= Popen(buf,"w");
+#else
+ out= fopen(tmpname, "w");
+#endif
+
+ if (out!=NULL) {
+#ifdef DEBUG
+ if (xkbDebugFlags) {
+ ErrorF("XkbDDXCompileKeymapByNames compiling keymap:\n");
+ XkbWriteXKBKeymapForNames(stderr,names,NULL,xkb,want,need);
+ }
+#endif
+ XkbWriteXKBKeymapForNames(out,names,NULL,xkb,want,need);
+#ifndef WIN32
+#ifdef __sun
+ if (Pclose(out) != 0)
+ {
+ ErrorF("Warning: Spurious failure reported in Pclose() runnning 'xkbcomp'.\n");
+ }
+ if (1)
+#else
+ if (Pclose(out)==0)
+#endif
+#else
+ if (fclose(out)==0 && System(buf) >= 0)
+#endif
+ {
+#ifdef DEBUG_CMD
+ ErrorF("xkb executes: %s\n",buf);
+ ErrorF("xkbcomp input:\n");
+ XkbWriteXKBKeymapForNames(stderr,names,NULL,xkb,want,need);
+ ErrorF("end xkbcomp input\n");
+#endif
+ if (nameRtrn) {
+ strncpy(nameRtrn,keymap,nameRtrnLen);
+ nameRtrn[nameRtrnLen-1]= '\0';
+ }
+#if defined(Lynx) && defined(__i386__) && defined(NEED_POPEN_WORKAROUND)
+ /* somehow popen/pclose is broken on LynxOS AT 2.3.0/2.4.0!
+ * the problem usually shows up with XF86Setup
+ * this hack waits at max 5 seconds after pclose() returns
+ * for the output of the xkbcomp output file.
+ * I didn't manage to get a patch in time for the 3.2 release
+ */
+ {
+ int i;
+ char name[PATH_MAX];
+#ifdef NXAGENT_SERVER
+ if (_NXGetXkbCompPath(XkbBaseDirectory)!=NULL)
+ sprintf(name,"%s/%s%s.xkm", _NXGetXkbCompPath(XkbBaseDirectory)
+ ,xkm_output_dir, keymap);
+#else
+ if (XkbBaseDirectory!=NULL)
+ sprintf(name,"%s/%s%s.xkm", XkbBaseDirectory
+ ,xkm_output_dir, keymap);
+#endif
+ else
+ sprintf(name,"%s%s.xkm", xkm_output_dir, keymap);
+ for (i = 0; i < 10; i++) {
+ if (access(name, 0) == 0) break;
+ usleep(500000);
+ }
+#ifdef DEBUG
+ if (i) ErrorF(">>>> Waited %d times for %s\n", i, name);
+#endif
+ }
+#endif
+ if (buf != NULL)
+ xfree (buf);
+ return True;
+ }
+#ifdef DEBUG
+ else
+ ErrorF("Error compiling keymap (%s)\n",keymap);
+#endif
+#ifdef WIN32
+ /* remove the temporary file */
+ unlink(tmpname);
+#endif
+ }
+#ifdef DEBUG
+ else {
+#ifndef WIN32
+ ErrorF("Could not invoke keymap compiler\n");
+#else
+ ErrorF("Could not open file %s\n", tmpname);
+#endif
+ }
+#endif
+ if (nameRtrn)
+ nameRtrn[0]= '\0';
+ if (buf != NULL)
+ xfree (buf);
+ return False;
+}
+
+FILE *
+XkbDDXOpenConfigFile(char *mapName,char *fileNameRtrn,int fileNameRtrnLen)
+{
+char buf[PATH_MAX],xkm_output_dir[PATH_MAX];
+FILE * file;
+
+ buf[0]= '\0';
+ if (mapName!=NULL) {
+ OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
+ if ((XkbBaseDirectory!=NULL)&&(xkm_output_dir[0]!='/')
+#ifdef WIN32
+ &&(!isalpha(xkm_output_dir[0]) || xkm_output_dir[1]!=':')
+#endif
+ ) {
+ if (strlen(XkbBaseDirectory)+strlen(xkm_output_dir)
+ +strlen(mapName)+6 <= PATH_MAX)
+ {
+ sprintf(buf,"%s/%s%s.xkm",XkbBaseDirectory,
+ xkm_output_dir,mapName);
+ }
+ }
+ else if (strlen(xkm_output_dir)+strlen(mapName)+5 <= PATH_MAX)
+ sprintf(buf,"%s%s.xkm",xkm_output_dir,mapName);
+ if (buf[0] != '\0')
+ file= fopen(buf,"rb");
+ else file= NULL;
+ }
+ else file= NULL;
+ if ((fileNameRtrn!=NULL)&&(fileNameRtrnLen>0)) {
+ strncpy(fileNameRtrn,buf,fileNameRtrnLen);
+ buf[fileNameRtrnLen-1]= '\0';
+ }
+ return file;
+}
+
+unsigned
+XkbDDXLoadKeymapByNames( DeviceIntPtr keybd,
+ XkbComponentNamesPtr names,
+ unsigned want,
+ unsigned need,
+ XkbFileInfo * finfoRtrn,
+ char * nameRtrn,
+ int nameRtrnLen)
+{
+XkbDescPtr xkb;
+FILE * file;
+char fileName[PATH_MAX];
+unsigned missing;
+
+ bzero(finfoRtrn,sizeof(XkbFileInfo));
+ if ((keybd==NULL)||(keybd->key==NULL)||(keybd->key->xkbInfo==NULL))
+ xkb= NULL;
+ else xkb= keybd->key->xkbInfo->desc;
+ if ((names->keycodes==NULL)&&(names->types==NULL)&&
+ (names->compat==NULL)&&(names->symbols==NULL)&&
+ (names->geometry==NULL)) {
+ if (names->keymap==NULL) {
+ bzero(finfoRtrn,sizeof(XkbFileInfo));
+ if (xkb && XkbDetermineFileType(finfoRtrn,XkbXKMFile,NULL) &&
+ ((finfoRtrn->defined&need)==need) ) {
+ finfoRtrn->xkb= xkb;
+ nameRtrn[0]= '\0';
+ return finfoRtrn->defined;
+ }
+ return 0;
+ }
+ else if (!XkbDDXCompileNamedKeymap(xkb,names,nameRtrn,nameRtrnLen)) {
+#ifdef NOISY
+ ErrorF("Couldn't compile keymap file\n");
+#endif
+ return 0;
+ }
+ }
+ else if (!XkbDDXCompileKeymapByNames(xkb,names,want,need,
+ nameRtrn,nameRtrnLen)){
+#ifdef NOISY
+ ErrorF("Couldn't compile keymap file\n");
+#endif
+ return 0;
+ }
+ file= XkbDDXOpenConfigFile(nameRtrn,fileName,PATH_MAX);
+ if (file==NULL) {
+ LogMessage(X_ERROR, "Couldn't open compiled keymap file %s\n",fileName);
+ return 0;
+ }
+ missing= XkmReadFile(file,need,want,finfoRtrn);
+ if (finfoRtrn->xkb==NULL) {
+ LogMessage(X_ERROR, "Error loading keymap %s\n",fileName);
+ fclose(file);
+ (void) unlink (fileName);
+ return 0;
+ }
+#ifdef DEBUG
+ else if (xkbDebugFlags) {
+ ErrorF("Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined);
+ }
+#endif
+ fclose(file);
+ (void) unlink (fileName);
+ return (need|want)&(~missing);
+}
+
+Bool
+XkbDDXNamesFromRules( DeviceIntPtr keybd,
+ char * rules_name,
+ XkbRF_VarDefsPtr defs,
+ XkbComponentNamesPtr names)
+{
+char buf[PATH_MAX];
+FILE * file;
+Bool complete;
+XkbRF_RulesPtr rules;
+
+ if (!rules_name)
+ return False;
+ if (XkbBaseDirectory==NULL) {
+ if (strlen(rules_name)+7 > PATH_MAX)
+ return False;
+ sprintf(buf,"rules/%s",rules_name);
+ }
+ else {
+ if (strlen(XkbBaseDirectory)+strlen(rules_name)+8 > PATH_MAX)
+ return False;
+ sprintf(buf,"%s/rules/%s",XkbBaseDirectory,rules_name);
+ }
+ if ((file= fopen(buf,"r"))==NULL)
+ return False;
+ if ((rules= XkbRF_Create(0,0))==NULL) {
+ fclose(file);
+ return False;
+ }
+ if (!XkbRF_LoadRules(file,rules)) {
+ fclose(file);
+ XkbRF_Free(rules,True);
+ return False;
+ }
+ bzero((char *)names,sizeof(XkbComponentNamesRec));
+ complete= XkbRF_GetComponents(rules,defs,names);
+ fclose(file);
+ XkbRF_Free(rules,True);
+ return complete;
+}
+
+
diff --git a/nx-X11/programs/Xserver/xkb/ddxLoad.c.NX.original b/nx-X11/programs/Xserver/xkb/ddxLoad.c.NX.original
new file mode 100644
index 000000000..8def401e8
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/ddxLoad.c.NX.original
@@ -0,0 +1,965 @@
+/* $Xorg: ddxLoad.c,v 1.3 2000/08/17 19:53:46 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/ddxLoad.c,v 3.35 2003/10/02 13:30:12 eich Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef HAVE_XKB_CONFIG_H
+#include <xkb-config.h>
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+#include <ctype.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xos.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include <X11/extensions/XKM.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#define XKBSRV_NEED_FILE_FUNCS
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XI.h>
+#include "xkb.h"
+
+#if defined(CSRG_BASED) || defined(linux) || defined(__sgi) || defined(AIXV3) || defined(__osf__) || defined(__GNU__)
+#include <paths.h>
+#endif
+
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+
+ /*
+ * If XKM_OUTPUT_DIR specifies a path without a leading slash, it is
+ * relative to the top-level XKB configuration directory.
+ * Making the server write to a subdirectory of that directory
+ * requires some work in the general case (install procedure
+ * has to create links to /var or somesuch on many machines),
+ * so we just compile into /usr/tmp for now.
+ */
+#ifndef XKM_OUTPUT_DIR
+#define XKM_OUTPUT_DIR "compiled/"
+#endif
+
+#define PRE_ERROR_MSG "\"The XKEYBOARD keymap compiler (xkbcomp) reports:\""
+#define ERROR_PREFIX "\"> \""
+#define POST_ERROR_MSG1 "\"Errors from xkbcomp are not fatal to the X server\""
+#define POST_ERROR_MSG2 "\"End of messages from xkbcomp\""
+
+#if defined(__UNIXOS2__) || defined(WIN32)
+#define PATHSEPARATOR "\\"
+#else
+#define PATHSEPARATOR "/"
+#endif
+
+#ifdef WIN32
+
+#include <X11/Xwindows.h>
+const char*
+Win32TempDir()
+{
+ static char buffer[PATH_MAX];
+ if (GetTempPath(sizeof(buffer), buffer))
+ {
+ int len;
+ buffer[sizeof(buffer)-1] = 0;
+ len = strlen(buffer);
+ if (len > 0)
+ if (buffer[len-1] == '\\')
+ buffer[len-1] = 0;
+ return buffer;
+ }
+ if (getenv("TEMP") != NULL)
+ return getenv("TEMP");
+ else if (getenv("TMP") != NULL)
+ return getenv("TEMP");
+ else
+ return "/tmp";
+}
+
+int
+Win32System(const char *cmdline)
+{
+ STARTUPINFO si;
+ PROCESS_INFORMATION pi;
+ DWORD dwExitCode;
+ char *cmd = xstrdup(cmdline);
+
+ ZeroMemory( &si, sizeof(si) );
+ si.cb = sizeof(si);
+ ZeroMemory( &pi, sizeof(pi) );
+
+ if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
+ {
+ LPVOID buffer;
+ if (!FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &buffer,
+ 0,
+ NULL ))
+ {
+ ErrorF("Starting '%s' failed!\n", cmdline);
+ }
+ else
+ {
+ ErrorF("Starting '%s' failed: %s", cmdline, (char *)buffer);
+ LocalFree(buffer);
+ }
+
+ xfree(cmd);
+ return -1;
+ }
+ /* Wait until child process exits. */
+ WaitForSingleObject( pi.hProcess, INFINITE );
+
+ GetExitCodeProcess( pi.hProcess, &dwExitCode);
+
+ /* Close process and thread handles. */
+ CloseHandle( pi.hProcess );
+ CloseHandle( pi.hThread );
+ xfree(cmd);
+
+ return dwExitCode;
+}
+#undef System
+#define System(x) Win32System(x)
+#endif
+
+#ifdef MAKE_XKM_OUTPUT_DIR
+/* Borrow trans_mkdir from Xtransutil.c to more safely make directories */
+# undef X11_t
+# define TRANS_SERVER
+# define PRMSG(lvl,x,a,b,c) \
+ if (lvl <= 1) { LogMessage(X_ERROR,x,a,b,c); } else ((void)0)
+# include <X11/Xtrans/Xtransutil.c>
+# ifndef XKM_OUTPUT_DIR_MODE
+# define XKM_OUTPUT_DIR_MODE 0755
+# endif
+#endif
+
+#ifdef NXAGENT_SERVER
+
+#define NX_XKB_BASE_DIRECTORY "/usr/lib/X11/xkb"
+#define NX_XKB_ALTERNATE_BASE_DIRECTORY "/usr/share/X11/xkb"
+#define NX_KEYMAP_DIR_FILE "keymap.dir"
+#define NX_ALT_XKBCOMP_PATH "/usr/bin"
+
+static char _NXXkbBasePath[PATH_MAX];
+static char _NXXkbCompPath[PATH_MAX];
+
+static int NXVerifyXkbBaseDirectory(const char *dirPath)
+{
+ int size;
+ char *keymapDirFilePath;
+ struct stat keymapDirFileStat;
+
+ /*
+ * If keymap.dir file
+ * is not present into
+ * Xkb Base Directory,
+ * we suppose that the
+ * path is not valid.
+ */
+
+ size = strlen(dirPath) + strlen("/") +
+ strlen(NX_KEYMAP_DIR_FILE) + 1;
+
+ if ((keymapDirFilePath = malloc((size + 1) * sizeof(char))) == NULL)
+ {
+ FatalError("NXVerifyXkbBaseDirectory: malloc failed.\n");
+ }
+
+ strcpy(keymapDirFilePath, dirPath);
+ strcat(keymapDirFilePath, "/");
+ strcat(keymapDirFilePath, NX_KEYMAP_DIR_FILE);
+
+ #ifdef TEST
+ fprintf(stderr, "NXVerifyXkbBaseDirectory: Looking for [%s] file.\n",
+ keymapDirFilePath);
+ #endif
+
+ if (stat(keymapDirFilePath, &keymapDirFileStat) != 0)
+ {
+
+ #ifdef TEST
+ fprintf(stderr, "NXVerifyXkbBaseDirectory: Can't find the keymap.dir file [%s].\n",
+ keymapDirFilePath);
+ #endif
+
+ free(keymapDirFilePath);
+
+ return 0;
+ }
+
+ #ifdef TEST
+ fprintf(stderr, "NXVerifyXkbBaseDirectory: Xkb Base Directory [%s] is valid.\n",
+ dirPath);
+ #endif
+
+ free(keymapDirFilePath);
+
+ return 1;
+}
+
+/*
+ * This function returns the directory
+ * containing the configuration files.
+ * This directory is referred by Xkb-
+ * BaseDirectory variable (generally
+ * it contains the hardcoded path at
+ * compile time). If the directory
+ * does not exist, the function will
+ * try a set of well known directories.
+ */
+
+char *_NXGetXkbBasePath(const char *path)
+{
+ /*
+ * Check the xkb base directory only once.
+ */
+
+ if (*_NXXkbBasePath != '\0')
+ {
+ return _NXXkbBasePath;
+ }
+
+ if (NXVerifyXkbBaseDirectory(XkbBaseDirectory) == 1)
+ {
+ if (strlen(XkbBaseDirectory) + 1 > PATH_MAX)
+ {
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbBasePath: WARNING! Maximum length of xkb base path exceeded.\n");
+ #endif
+
+ goto _NXGetXkbBasePathError;
+ }
+
+ strcpy(_NXXkbBasePath, XkbBaseDirectory);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbBasePath: Using NX xkb base directory path [%s].\n",
+ _NXXkbBasePath);
+ #endif
+
+ return _NXXkbBasePath;
+ }
+
+ if (NXVerifyXkbBaseDirectory(NX_XKB_BASE_DIRECTORY) == 1)
+ {
+ if (strlen(NX_XKB_BASE_DIRECTORY) + 1 > PATH_MAX)
+ {
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbBasePath: WARNING! Maximum length of xkb base path exceeded.\n");
+ #endif
+
+ goto _NXGetXkbBasePathError;
+ }
+
+ strcpy(_NXXkbBasePath, NX_XKB_BASE_DIRECTORY);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbBasePath: Using NX xkb base directory path [%s].\n",
+ _NXXkbBasePath);
+ #endif
+
+ return _NXXkbBasePath;
+ }
+
+ if (NXVerifyXkbBaseDirectory(NX_XKB_ALTERNATE_BASE_DIRECTORY) == 1)
+ {
+ if (strlen(NX_XKB_ALTERNATE_BASE_DIRECTORY) + 1 > PATH_MAX)
+ {
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbBasePath: WARNING! Maximum length of xkb base path exceeded.\n");
+ #endif
+
+ goto _NXGetXkbBasePathError;
+ }
+
+ strcpy(_NXXkbBasePath, NX_XKB_ALTERNATE_BASE_DIRECTORY);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbBasePath: Using NX xkb base directory path [%s].\n",
+ _NXXkbBasePath);
+ #endif
+
+ return _NXXkbBasePath;
+ }
+
+_NXGetXkbBasePathError:
+
+ if (strlen(path) + 1 > PATH_MAX)
+ {
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbBasePath: WARNING! Maximum length of xkb base path exceeded.\n");
+ #endif
+ }
+
+ strcpy(_NXXkbBasePath, path);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbBasePath: Using default xkb base path [%s].\n",
+ _NXXkbBasePath);
+ #endif
+
+ return _NXXkbBasePath;
+}
+
+static int NXVerifyXkbCompPath(char *path)
+{
+ char *xkbCompPath;
+ int xkbCompPathSize;
+ struct stat xkbCompPathStat;
+
+ if (path == NULL)
+ {
+ return 0;
+ }
+
+ xkbCompPathSize = strlen(path) + strlen("/") +
+ strlen("xkbcomp") + 1;
+
+ if ((xkbCompPath = malloc((xkbCompPathSize + 1) * sizeof(char))) == NULL)
+ {
+ FatalError("NXVerifyXkbCompPath: WARNING! malloc failed.\n");
+
+ return 0;
+ }
+
+ strcpy(xkbCompPath, path);
+ strcat(xkbCompPath, "/");
+ strcat(xkbCompPath, "xkbcomp");
+
+ if (stat(xkbCompPath, &xkbCompPathStat) != 0)
+ {
+ #ifdef NX_TRANS_TEST
+ fprintf(stderr, "NXVerifyXkbCompPath: WARNING! Failed to stat xkbcomp path [%s].\n",
+ xkbCompPath);
+ #endif
+
+ free(xkbCompPath);
+
+ return 0;
+ }
+
+ free(xkbCompPath);
+
+ return 1;
+}
+
+/*
+ * This function returns the directory
+ * containing the xkbcomp executable.
+ * The function will first try to locate
+ * the executable in the hardcoded path
+ * (the same path as the "base" xkb one)
+ * and, if the xkbcomp file couldn't be
+ * found, the function will not include
+ * an explicit path and will rely on the
+ * PATH environment to list the directory.
+ */
+
+char *_NXGetXkbCompPath(const char *path)
+{
+
+ char * xkbCompPath;
+
+ /*
+ * Check the xkbcomp executable
+ * directory only once.
+ */
+
+ if (*_NXXkbCompPath != '\0')
+ {
+ return _NXXkbCompPath;
+ }
+
+ xkbCompPath = _NXGetXkbBasePath(path);
+
+ if (NXVerifyXkbCompPath(xkbCompPath) == 1)
+ {
+ if (strlen(xkbCompPath) + 1 > PATH_MAX)
+ {
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbCompPath: WARNING! Maximum length of xkbcomp path exceeded.\n");
+ #endif
+
+ goto _NXGetXkbCompPathError;
+ }
+
+ strcpy(_NXXkbCompPath, xkbCompPath);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbCompPath: Using xkbcomp path [%s].\n",
+ _NXXkbCompPath);
+ #endif
+
+ return _NXXkbCompPath;
+ }
+
+ xkbCompPath = NX_ALT_XKBCOMP_PATH;
+
+ if (NXVerifyXkbCompPath(xkbCompPath) == 1)
+ {
+ if (strlen(xkbCompPath) + 1 > PATH_MAX)
+ {
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbCompPath: WARNING! Maximum length of xkbcomp path exceeded.\n");
+ #endif
+
+ goto _NXGetXkbCompPathError;
+ }
+
+ strcpy(_NXXkbCompPath, xkbCompPath);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbCompPath: Using NX xkbcomp path [%s].\n",
+ _NXXkbCompPath);
+ #endif
+
+ return _NXXkbCompPath;
+ }
+
+_NXGetXkbCompPathError:
+
+ if (strlen(path) + 1 > PATH_MAX)
+ {
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbCompPath: WARNING! Maximum length of xkbcomp path exceeded.\n");
+ #endif
+ }
+
+ strcpy(_NXXkbCompPath, path);
+
+ #ifdef TEST
+ fprintf(stderr, "_NXGetXkbCompPath: Using default xkbcomp path [%s].\n",
+ _NXXkbCompPath);
+ #endif
+
+ return _NXXkbCompPath;
+}
+
+#endif
+
+static void
+OutputDirectory(
+ char* outdir,
+ size_t size)
+{
+#ifndef WIN32
+ if (getuid() == 0 && (strlen(XKM_OUTPUT_DIR) < size)
+#ifdef MAKE_XKM_OUTPUT_DIR
+ && (trans_mkdir(XKM_OUTPUT_DIR, XKM_OUTPUT_DIR_MODE) == 0)
+#endif
+ )
+ {
+ /* if server running as root it *may* be able to write */
+ /* FIXME: check whether directory is writable at all */
+ (void) strcpy (outdir, XKM_OUTPUT_DIR);
+ } else
+#endif
+#ifdef _PATH_VARTMP
+ if ((strlen(_PATH_VARTMP) + 1) < size)
+ {
+ (void) strcpy (outdir, _PATH_VARTMP);
+ if (outdir[strlen(outdir) - 1] != '/') /* Hi IBM, Digital */
+ (void) strcat (outdir, "/");
+ } else
+#endif
+#ifdef WIN32
+ if (strlen(Win32TempDir()) + 1 < size)
+ {
+ (void) strcpy(outdir, Win32TempDir());
+ (void) strcat(outdir, "\\");
+ } else
+#endif
+ if (strlen("/tmp/") < size)
+ {
+ (void) strcpy (outdir, "/tmp/");
+ }
+}
+
+Bool
+XkbDDXCompileNamedKeymap( XkbDescPtr xkb,
+ XkbComponentNamesPtr names,
+ char * nameRtrn,
+ int nameRtrnLen)
+{
+char *cmd = NULL,file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile;
+
+ if (names->keymap==NULL)
+ return False;
+ strncpy(file,names->keymap,PATH_MAX); file[PATH_MAX-1]= '\0';
+ if ((map= strrchr(file,'('))!=NULL) {
+ char *tmp;
+ if ((tmp= strrchr(map,')'))!=NULL) {
+ *map++= '\0';
+ *tmp= '\0';
+ }
+ else {
+ map= NULL;
+ }
+ }
+ if ((outFile= strrchr(file,'/'))!=NULL)
+ outFile= _XkbDupString(&outFile[1]);
+ else outFile= _XkbDupString(file);
+ XkbEnsureSafeMapName(outFile);
+ OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
+
+#ifdef NXAGENT_SERVER
+
+ if (_NXGetXkbCompPath(XkbBaseDirectory) != NULL)
+ {
+
+#else
+
+ if (XkbBaseDirectory!=NULL) {
+
+#endif
+
+#ifndef __UNIXOS2__
+
+#ifdef NXAGENT_SERVER
+ char *xkbbasedir = _NXGetXkbCompPath(XkbBaseDirectory);
+ char *xkbbindir = _NXGetXkbCompPath(XkbBinDirectory);
+#else
+ char *xkbbasedir = XkbBaseDirectory;
+ char *xkbbindir = XkbBinDirectory;
+#endif
+
+#else
+ /* relocate the basedir and replace the slashes with backslashes */
+#ifdef NXAGENT_SERVER
+ char *xkbbasedir = (char*)__XOS2RedirRoot(_NXGetXkbCompPath(XkbBaseDirectory));
+ char *xkbbindir = (char*)__XOS2RedirRoot(_NXGetXkbCompPath(XkbBinDirectory));
+#else
+ char *xkbbasedir = (char*)__XOS2RedirRoot(XkbBaseDirectory);
+ char *xkbbindir = (char*)__XOS2RedirRoot(XkbBinDirectory);
+#endif
+ int i;
+
+ for (i=0; i<strlen(xkbbasedir); i++)
+ if (xkbbasedir[i]=='/') xkbbasedir[i]='\\';
+ for (i=0; i<strlen(xkbbindir); i++)
+ if (xkbbindir[i]=='/') xkbbindir[i]='\\';
+#endif
+
+ cmd = Xprintf("\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s \"%s%s.xkm\"",
+ xkbbindir,
+ ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
+ xkbbasedir,(map?"-m ":""),(map?map:""),
+ PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,file,
+ xkm_output_dir,outFile);
+ }
+ else {
+ cmd = Xprintf("xkbcomp -w %d -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s \"%s%s.xkm\"",
+ ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
+ (map?"-m ":""),(map?map:""),
+ PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,file,
+ xkm_output_dir,outFile);
+ }
+#ifdef DEBUG
+ if (xkbDebugFlags) {
+ ErrorF("XkbDDXCompileNamedKeymap compiling keymap using:\n");
+ ErrorF(" \"cmd\"\n");
+ }
+#endif
+#ifdef DEBUG_CMD
+ ErrorF("xkb executes: %s\n",cmd);
+#endif
+ if (System(cmd)==0) {
+ if (nameRtrn) {
+ strncpy(nameRtrn,outFile,nameRtrnLen);
+ nameRtrn[nameRtrnLen-1]= '\0';
+ }
+ if (outFile!=NULL)
+ _XkbFree(outFile);
+ if (cmd!=NULL)
+ xfree(cmd);
+ return True;
+ }
+#ifdef DEBUG
+ ErrorF("Error compiling keymap (%s)\n",names->keymap);
+#endif
+ if (outFile!=NULL)
+ _XkbFree(outFile);
+ if (cmd!=NULL)
+ xfree(cmd);
+ return False;
+}
+
+Bool
+XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
+ XkbComponentNamesPtr names,
+ unsigned want,
+ unsigned need,
+ char * nameRtrn,
+ int nameRtrnLen)
+{
+FILE * out;
+char *buf = NULL, keymap[PATH_MAX],xkm_output_dir[PATH_MAX];
+
+#ifdef WIN32
+char tmpname[PATH_MAX];
+#endif
+ if ((names->keymap==NULL)||(names->keymap[0]=='\0')) {
+ sprintf(keymap,"server-%s",display);
+ }
+ else {
+ if (strlen(names->keymap) > PATH_MAX - 1) {
+ ErrorF("name of keymap (%s) exceeds max length\n", names->keymap);
+ return False;
+ }
+ strcpy(keymap,names->keymap);
+ }
+
+ XkbEnsureSafeMapName(keymap);
+ OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
+#ifdef WIN32
+ strcpy(tmpname, Win32TempDir());
+ strcat(tmpname, "\\xkb_XXXXXX");
+ (void) mktemp(tmpname);
+#endif
+
+#ifdef NXAGENT_SERVER
+ if (_NXGetXkbCompPath(XkbBaseDirectory)!=NULL) {
+#else
+ if (XkbBaseDirectory!=NULL) {
+#endif
+
+#ifndef WIN32
+ char *xkmfile = "-";
+#else
+ /* WIN32 has no popen. The input must be stored in a file which is used as input
+ for xkbcomp. xkbcomp does not read from stdin. */
+ char *xkmfile = tmpname;
+#endif
+#ifndef __UNIXOS2__
+#ifdef NXAGENT_SERVER
+ char *xkbbasedir = _NXGetXkbCompPath(XkbBaseDirectory);
+ char *xkbbindir = _NXGetXkbCompPath(XkbBinDirectory);
+#else
+ char *xkbbasedir = XkbBaseDirectory;
+ char *xkbbindir = XkbBinDirectory;
+#endif
+#else
+ int i;
+#ifdef NXAGENT_SERVER
+ char *xkbbasedir = (char*)__XOS2RedirRoot(_NXGetXkbCompPath(XkbBaseDirectory));
+ char *xkbbindir = (char*)__XOS2RedirRoot(_NXGetXkbCompPath(XkbBinDirectory));
+#else
+ char *xkbbasedir = (char*)__XOS2RedirRoot(XkbBaseDirectory);
+ char *xkbbindir = (char*)__XOS2RedirRoot(XkbBinDirectory);
+#endif
+ for (i=0; i<strlen(xkbbasedir); i++)
+ if (xkbbasedir[i]=='/') xkbbasedir[i]='\\';
+ for (i=0; i<strlen(xkbbindir); i++)
+ if (xkbbindir[i]=='/') xkbbindir[i]='\\';
+#endif
+
+ buf = Xprintf(
+ "\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm \"%s\" -em1 %s -emp %s -eml %s \"%s%s.xkm\"",
+ xkbbindir,
+ ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
+ xkbbasedir, xkmfile,
+ PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,
+ xkm_output_dir,keymap);
+ }
+ else {
+#ifndef WIN32
+ char *xkmfile = "-";
+#else
+ char *xkmfile = tmpname;
+#endif
+ buf = Xprintf(
+ "xkbcomp -w %d -xkm \"%s\" -em1 %s -emp %s -eml %s \"%s%s.xkm\"",
+ ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
+ xkmfile,
+ PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,
+ xkm_output_dir,keymap);
+ }
+
+ #ifdef TEST
+ fprintf(stderr, "XkbDDXCompileKeymapByNames: Executing command [%s].\n", buf);
+ #endif
+
+#ifndef WIN32
+ out= Popen(buf,"w");
+#else
+ out= fopen(tmpname, "w");
+#endif
+
+ if (out!=NULL) {
+#ifdef DEBUG
+ if (xkbDebugFlags) {
+ ErrorF("XkbDDXCompileKeymapByNames compiling keymap:\n");
+ XkbWriteXKBKeymapForNames(stderr,names,NULL,xkb,want,need);
+ }
+#endif
+ XkbWriteXKBKeymapForNames(out,names,NULL,xkb,want,need);
+#ifndef WIN32
+#ifdef __sun
+ if (Pclose(out) != 0)
+ {
+ ErrorF("Warning: Spurious failure reported in Pclose() runnning 'xkbcomp'.\n");
+ }
+ if (1)
+#else
+ if (Pclose(out)==0)
+#endif
+#else
+ if (fclose(out)==0 && System(buf) >= 0)
+#endif
+ {
+#ifdef DEBUG_CMD
+ ErrorF("xkb executes: %s\n",buf);
+ ErrorF("xkbcomp input:\n");
+ XkbWriteXKBKeymapForNames(stderr,names,NULL,xkb,want,need);
+ ErrorF("end xkbcomp input\n");
+#endif
+ if (nameRtrn) {
+ strncpy(nameRtrn,keymap,nameRtrnLen);
+ nameRtrn[nameRtrnLen-1]= '\0';
+ }
+#if defined(Lynx) && defined(__i386__) && defined(NEED_POPEN_WORKAROUND)
+ /* somehow popen/pclose is broken on LynxOS AT 2.3.0/2.4.0!
+ * the problem usually shows up with XF86Setup
+ * this hack waits at max 5 seconds after pclose() returns
+ * for the output of the xkbcomp output file.
+ * I didn't manage to get a patch in time for the 3.2 release
+ */
+ {
+ int i;
+ char name[PATH_MAX];
+#ifdef NXAGENT_SERVER
+ if (_NXGetXkbCompPath(XkbBaseDirectory)!=NULL)
+ sprintf(name,"%s/%s%s.xkm", _NXGetXkbCompPath(XkbBaseDirectory)
+ ,xkm_output_dir, keymap);
+#else
+ if (XkbBaseDirectory!=NULL)
+ sprintf(name,"%s/%s%s.xkm", XkbBaseDirectory
+ ,xkm_output_dir, keymap);
+#endif
+ else
+ sprintf(name,"%s%s.xkm", xkm_output_dir, keymap);
+ for (i = 0; i < 10; i++) {
+ if (access(name, 0) == 0) break;
+ usleep(500000);
+ }
+#ifdef DEBUG
+ if (i) ErrorF(">>>> Waited %d times for %s\n", i, name);
+#endif
+ }
+#endif
+ if (buf != NULL)
+ xfree (buf);
+ return True;
+ }
+#ifdef DEBUG
+ else
+ ErrorF("Error compiling keymap (%s)\n",keymap);
+#endif
+#ifdef WIN32
+ /* remove the temporary file */
+ unlink(tmpname);
+#endif
+ }
+#ifdef DEBUG
+ else {
+#ifndef WIN32
+ ErrorF("Could not invoke keymap compiler\n");
+#else
+ ErrorF("Could not open file %s\n", tmpname);
+#endif
+ }
+#endif
+ if (nameRtrn)
+ nameRtrn[0]= '\0';
+ if (buf != NULL)
+ xfree (buf);
+ return False;
+}
+
+FILE *
+XkbDDXOpenConfigFile(char *mapName,char *fileNameRtrn,int fileNameRtrnLen)
+{
+char buf[PATH_MAX],xkm_output_dir[PATH_MAX];
+FILE * file;
+
+ buf[0]= '\0';
+ if (mapName!=NULL) {
+ OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
+ if ((XkbBaseDirectory!=NULL)&&(xkm_output_dir[0]!='/')
+#ifdef WIN32
+ &&(!isalpha(xkm_output_dir[0]) || xkm_output_dir[1]!=':')
+#endif
+ ) {
+ if (strlen(XkbBaseDirectory)+strlen(xkm_output_dir)
+ +strlen(mapName)+6 <= PATH_MAX)
+ {
+ sprintf(buf,"%s/%s%s.xkm",XkbBaseDirectory,
+ xkm_output_dir,mapName);
+ }
+ }
+ else if (strlen(xkm_output_dir)+strlen(mapName)+5 <= PATH_MAX)
+ sprintf(buf,"%s%s.xkm",xkm_output_dir,mapName);
+ if (buf[0] != '\0')
+ file= fopen(buf,"rb");
+ else file= NULL;
+ }
+ else file= NULL;
+ if ((fileNameRtrn!=NULL)&&(fileNameRtrnLen>0)) {
+ strncpy(fileNameRtrn,buf,fileNameRtrnLen);
+ buf[fileNameRtrnLen-1]= '\0';
+ }
+ return file;
+}
+
+unsigned
+XkbDDXLoadKeymapByNames( DeviceIntPtr keybd,
+ XkbComponentNamesPtr names,
+ unsigned want,
+ unsigned need,
+ XkbFileInfo * finfoRtrn,
+ char * nameRtrn,
+ int nameRtrnLen)
+{
+XkbDescPtr xkb;
+FILE * file;
+char fileName[PATH_MAX];
+unsigned missing;
+
+ bzero(finfoRtrn,sizeof(XkbFileInfo));
+ if ((keybd==NULL)||(keybd->key==NULL)||(keybd->key->xkbInfo==NULL))
+ xkb= NULL;
+ else xkb= keybd->key->xkbInfo->desc;
+ if ((names->keycodes==NULL)&&(names->types==NULL)&&
+ (names->compat==NULL)&&(names->symbols==NULL)&&
+ (names->geometry==NULL)) {
+ if (names->keymap==NULL) {
+ bzero(finfoRtrn,sizeof(XkbFileInfo));
+ if (xkb && XkbDetermineFileType(finfoRtrn,XkbXKMFile,NULL) &&
+ ((finfoRtrn->defined&need)==need) ) {
+ finfoRtrn->xkb= xkb;
+ nameRtrn[0]= '\0';
+ return finfoRtrn->defined;
+ }
+ return 0;
+ }
+ else if (!XkbDDXCompileNamedKeymap(xkb,names,nameRtrn,nameRtrnLen)) {
+#ifdef NOISY
+ ErrorF("Couldn't compile keymap file\n");
+#endif
+ return 0;
+ }
+ }
+ else if (!XkbDDXCompileKeymapByNames(xkb,names,want,need,
+ nameRtrn,nameRtrnLen)){
+#ifdef NOISY
+ ErrorF("Couldn't compile keymap file\n");
+#endif
+ return 0;
+ }
+ file= XkbDDXOpenConfigFile(nameRtrn,fileName,PATH_MAX);
+ if (file==NULL) {
+ LogMessage(X_ERROR, "Couldn't open compiled keymap file %s\n",fileName);
+ return 0;
+ }
+ missing= XkmReadFile(file,need,want,finfoRtrn);
+ if (finfoRtrn->xkb==NULL) {
+ LogMessage(X_ERROR, "Error loading keymap %s\n",fileName);
+ fclose(file);
+ (void) unlink (fileName);
+ return 0;
+ }
+#ifdef DEBUG
+ else if (xkbDebugFlags) {
+ ErrorF("Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined);
+ }
+#endif
+ fclose(file);
+ (void) unlink (fileName);
+ return (need|want)&(~missing);
+}
+
+Bool
+XkbDDXNamesFromRules( DeviceIntPtr keybd,
+ char * rules_name,
+ XkbRF_VarDefsPtr defs,
+ XkbComponentNamesPtr names)
+{
+char buf[PATH_MAX];
+FILE * file;
+Bool complete;
+XkbRF_RulesPtr rules;
+
+ if (!rules_name)
+ return False;
+ if (XkbBaseDirectory==NULL) {
+ if (strlen(rules_name)+7 > PATH_MAX)
+ return False;
+ sprintf(buf,"rules/%s",rules_name);
+ }
+ else {
+ if (strlen(XkbBaseDirectory)+strlen(rules_name)+8 > PATH_MAX)
+ return False;
+ sprintf(buf,"%s/rules/%s",XkbBaseDirectory,rules_name);
+ }
+ if ((file= fopen(buf,"r"))==NULL)
+ return False;
+ if ((rules= XkbRF_Create(0,0))==NULL) {
+ fclose(file);
+ return False;
+ }
+ if (!XkbRF_LoadRules(file,rules)) {
+ fclose(file);
+ XkbRF_Free(rules,True);
+ return False;
+ }
+ bzero((char *)names,sizeof(XkbComponentNamesRec));
+ complete= XkbRF_GetComponents(rules,defs,names);
+ fclose(file);
+ XkbRF_Free(rules,True);
+ return complete;
+}
+
+
diff --git a/nx-X11/programs/Xserver/xkb/ddxLoad.c.X.original b/nx-X11/programs/Xserver/xkb/ddxLoad.c.X.original
new file mode 100644
index 000000000..e355b1796
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/ddxLoad.c.X.original
@@ -0,0 +1,604 @@
+/* $Xorg: ddxLoad.c,v 1.3 2000/08/17 19:53:46 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/ddxLoad.c,v 3.35 2003/10/02 13:30:12 eich Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef HAVE_XKB_CONFIG_H
+#include <xkb-config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xos.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include <X11/extensions/XKM.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#define XKBSRV_NEED_FILE_FUNCS
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XI.h>
+#include "xkb.h"
+
+#if defined(CSRG_BASED) || defined(linux) || defined(__sgi) || defined(AIXV3) || defined(__osf__) || defined(__GNU__)
+#include <paths.h>
+#endif
+
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+
+ /*
+ * If XKM_OUTPUT_DIR specifies a path without a leading slash, it is
+ * relative to the top-level XKB configuration directory.
+ * Making the server write to a subdirectory of that directory
+ * requires some work in the general case (install procedure
+ * has to create links to /var or somesuch on many machines),
+ * so we just compile into /usr/tmp for now.
+ */
+#ifndef XKM_OUTPUT_DIR
+#define XKM_OUTPUT_DIR "compiled/"
+#endif
+
+#define PRE_ERROR_MSG "\"The XKEYBOARD keymap compiler (xkbcomp) reports:\""
+#define ERROR_PREFIX "\"> \""
+#define POST_ERROR_MSG1 "\"Errors from xkbcomp are not fatal to the X server\""
+#define POST_ERROR_MSG2 "\"End of messages from xkbcomp\""
+
+#if defined(__UNIXOS2__) || defined(WIN32)
+#define PATHSEPARATOR "\\"
+#else
+#define PATHSEPARATOR "/"
+#endif
+
+#ifdef WIN32
+
+#include <X11/Xwindows.h>
+const char*
+Win32TempDir()
+{
+ static char buffer[PATH_MAX];
+ if (GetTempPath(sizeof(buffer), buffer))
+ {
+ int len;
+ buffer[sizeof(buffer)-1] = 0;
+ len = strlen(buffer);
+ if (len > 0)
+ if (buffer[len-1] == '\\')
+ buffer[len-1] = 0;
+ return buffer;
+ }
+ if (getenv("TEMP") != NULL)
+ return getenv("TEMP");
+ else if (getenv("TMP") != NULL)
+ return getenv("TEMP");
+ else
+ return "/tmp";
+}
+
+int
+Win32System(const char *cmdline)
+{
+ STARTUPINFO si;
+ PROCESS_INFORMATION pi;
+ DWORD dwExitCode;
+ char *cmd = xstrdup(cmdline);
+
+ ZeroMemory( &si, sizeof(si) );
+ si.cb = sizeof(si);
+ ZeroMemory( &pi, sizeof(pi) );
+
+ if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
+ {
+ LPVOID buffer;
+ if (!FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &buffer,
+ 0,
+ NULL ))
+ {
+ ErrorF("Starting '%s' failed!\n", cmdline);
+ }
+ else
+ {
+ ErrorF("Starting '%s' failed: %s", cmdline, (char *)buffer);
+ LocalFree(buffer);
+ }
+
+ xfree(cmd);
+ return -1;
+ }
+ /* Wait until child process exits. */
+ WaitForSingleObject( pi.hProcess, INFINITE );
+
+ GetExitCodeProcess( pi.hProcess, &dwExitCode);
+
+ /* Close process and thread handles. */
+ CloseHandle( pi.hProcess );
+ CloseHandle( pi.hThread );
+ xfree(cmd);
+
+ return dwExitCode;
+}
+#undef System
+#define System(x) Win32System(x)
+#endif
+
+#ifdef MAKE_XKM_OUTPUT_DIR
+/* Borrow trans_mkdir from Xtransutil.c to more safely make directories */
+# undef X11_t
+# define TRANS_SERVER
+# define PRMSG(lvl,x,a,b,c) \
+ if (lvl <= 1) { LogMessage(X_ERROR,x,a,b,c); } else ((void)0)
+# include <X11/Xtrans/Xtransutil.c>
+# ifndef XKM_OUTPUT_DIR_MODE
+# define XKM_OUTPUT_DIR_MODE 0755
+# endif
+#endif
+
+static void
+OutputDirectory(
+ char* outdir,
+ size_t size)
+{
+#ifndef WIN32
+ if (getuid() == 0 && (strlen(XKM_OUTPUT_DIR) < size)
+#ifdef MAKE_XKM_OUTPUT_DIR
+ && (trans_mkdir(XKM_OUTPUT_DIR, XKM_OUTPUT_DIR_MODE) == 0)
+#endif
+ )
+ {
+ /* if server running as root it *may* be able to write */
+ /* FIXME: check whether directory is writable at all */
+ (void) strcpy (outdir, XKM_OUTPUT_DIR);
+ } else
+#endif
+#ifdef _PATH_VARTMP
+ if ((strlen(_PATH_VARTMP) + 1) < size)
+ {
+ (void) strcpy (outdir, _PATH_VARTMP);
+ if (outdir[strlen(outdir) - 1] != '/') /* Hi IBM, Digital */
+ (void) strcat (outdir, "/");
+ } else
+#endif
+#ifdef WIN32
+ if (strlen(Win32TempDir()) + 1 < size)
+ {
+ (void) strcpy(outdir, Win32TempDir());
+ (void) strcat(outdir, "\\");
+ } else
+#endif
+ if (strlen("/tmp/") < size)
+ {
+ (void) strcpy (outdir, "/tmp/");
+ }
+}
+
+Bool
+XkbDDXCompileNamedKeymap( XkbDescPtr xkb,
+ XkbComponentNamesPtr names,
+ char * nameRtrn,
+ int nameRtrnLen)
+{
+char *cmd = NULL,file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile;
+
+ if (names->keymap==NULL)
+ return False;
+ strncpy(file,names->keymap,PATH_MAX); file[PATH_MAX-1]= '\0';
+ if ((map= strrchr(file,'('))!=NULL) {
+ char *tmp;
+ if ((tmp= strrchr(map,')'))!=NULL) {
+ *map++= '\0';
+ *tmp= '\0';
+ }
+ else {
+ map= NULL;
+ }
+ }
+ if ((outFile= strrchr(file,'/'))!=NULL)
+ outFile= _XkbDupString(&outFile[1]);
+ else outFile= _XkbDupString(file);
+ XkbEnsureSafeMapName(outFile);
+ OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
+
+ if (XkbBaseDirectory!=NULL) {
+#ifndef __UNIXOS2__
+ char *xkbbasedir = XkbBaseDirectory;
+ char *xkbbindir = XkbBinDirectory;
+#else
+ /* relocate the basedir and replace the slashes with backslashes */
+ char *xkbbasedir = (char*)__XOS2RedirRoot(XkbBaseDirectory);
+ char *xkbbindir = (char*)__XOS2RedirRoot(XkbBinDirectory);
+ int i;
+
+ for (i=0; i<strlen(xkbbasedir); i++)
+ if (xkbbasedir[i]=='/') xkbbasedir[i]='\\';
+ for (i=0; i<strlen(xkbbindir); i++)
+ if (xkbbindir[i]=='/') xkbbindir[i]='\\';
+#endif
+
+ cmd = Xprintf("\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s \"%s%s.xkm\"",
+ xkbbindir,
+ ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
+ xkbbasedir,(map?"-m ":""),(map?map:""),
+ PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,file,
+ xkm_output_dir,outFile);
+ }
+ else {
+ cmd = Xprintf("xkbcomp -w %d -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s \"%s%s.xkm\"",
+ ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
+ (map?"-m ":""),(map?map:""),
+ PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,file,
+ xkm_output_dir,outFile);
+ }
+#ifdef DEBUG
+ if (xkbDebugFlags) {
+ ErrorF("XkbDDXCompileNamedKeymap compiling keymap using:\n");
+ ErrorF(" \"cmd\"\n");
+ }
+#endif
+#ifdef DEBUG_CMD
+ ErrorF("xkb executes: %s\n",cmd);
+#endif
+ if (System(cmd)==0) {
+ if (nameRtrn) {
+ strncpy(nameRtrn,outFile,nameRtrnLen);
+ nameRtrn[nameRtrnLen-1]= '\0';
+ }
+ if (outFile!=NULL)
+ _XkbFree(outFile);
+ if (cmd!=NULL)
+ xfree(cmd);
+ return True;
+ }
+#ifdef DEBUG
+ ErrorF("Error compiling keymap (%s)\n",names->keymap);
+#endif
+ if (outFile!=NULL)
+ _XkbFree(outFile);
+ if (cmd!=NULL)
+ xfree(cmd);
+ return False;
+}
+
+Bool
+XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
+ XkbComponentNamesPtr names,
+ unsigned want,
+ unsigned need,
+ char * nameRtrn,
+ int nameRtrnLen)
+{
+FILE * out;
+char *buf = NULL, keymap[PATH_MAX],xkm_output_dir[PATH_MAX];
+
+#ifdef WIN32
+char tmpname[PATH_MAX];
+#endif
+ if ((names->keymap==NULL)||(names->keymap[0]=='\0')) {
+ sprintf(keymap,"server-%s",display);
+ }
+ else {
+ if (strlen(names->keymap) > PATH_MAX - 1) {
+ ErrorF("name of keymap (%s) exceeds max length\n", names->keymap);
+ return False;
+ }
+ strcpy(keymap,names->keymap);
+ }
+
+ XkbEnsureSafeMapName(keymap);
+ OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
+#ifdef WIN32
+ strcpy(tmpname, Win32TempDir());
+ strcat(tmpname, "\\xkb_XXXXXX");
+ (void) mktemp(tmpname);
+#endif
+ if (XkbBaseDirectory!=NULL) {
+#ifndef WIN32
+ char *xkmfile = "-";
+#else
+ /* WIN32 has no popen. The input must be stored in a file which is used as input
+ for xkbcomp. xkbcomp does not read from stdin. */
+ char *xkmfile = tmpname;
+#endif
+#ifndef __UNIXOS2__
+ char *xkbbasedir = XkbBaseDirectory;
+ char *xkbbindir = XkbBinDirectory;
+#else
+ int i;
+ char *xkbbasedir = (char*)__XOS2RedirRoot(XkbBaseDirectory);
+ char *xkbbindir = (char*)__XOS2RedirRoot(XkbBinDirectory);
+ for (i=0; i<strlen(xkbbasedir); i++)
+ if (xkbbasedir[i]=='/') xkbbasedir[i]='\\';
+ for (i=0; i<strlen(xkbbindir); i++)
+ if (xkbbindir[i]=='/') xkbbindir[i]='\\';
+#endif
+
+ buf = Xprintf(
+ "\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm \"%s\" -em1 %s -emp %s -eml %s \"%s%s.xkm\"",
+ xkbbindir,
+ ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
+ xkbbasedir, xkmfile,
+ PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,
+ xkm_output_dir,keymap);
+ }
+ else {
+#ifndef WIN32
+ char *xkmfile = "-";
+#else
+ char *xkmfile = tmpname;
+#endif
+ buf = Xprintf(
+ "xkbcomp -w %d -xkm \"%s\" -em1 %s -emp %s -eml %s \"%s%s.xkm\"",
+ ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)),
+ xkmfile,
+ PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,
+ xkm_output_dir,keymap);
+ }
+
+#ifndef WIN32
+ out= Popen(buf,"w");
+#else
+ out= fopen(tmpname, "w");
+#endif
+
+ if (out!=NULL) {
+#ifdef DEBUG
+ if (xkbDebugFlags) {
+ ErrorF("XkbDDXCompileKeymapByNames compiling keymap:\n");
+ XkbWriteXKBKeymapForNames(stderr,names,NULL,xkb,want,need);
+ }
+#endif
+ XkbWriteXKBKeymapForNames(out,names,NULL,xkb,want,need);
+#ifndef WIN32
+ if (Pclose(out)==0)
+#else
+ if (fclose(out)==0 && System(buf) >= 0)
+#endif
+ {
+#ifdef DEBUG_CMD
+ ErrorF("xkb executes: %s\n",buf);
+ ErrorF("xkbcomp input:\n");
+ XkbWriteXKBKeymapForNames(stderr,names,NULL,xkb,want,need);
+ ErrorF("end xkbcomp input\n");
+#endif
+ if (nameRtrn) {
+ strncpy(nameRtrn,keymap,nameRtrnLen);
+ nameRtrn[nameRtrnLen-1]= '\0';
+ }
+#if defined(Lynx) && defined(__i386__) && defined(NEED_POPEN_WORKAROUND)
+ /* somehow popen/pclose is broken on LynxOS AT 2.3.0/2.4.0!
+ * the problem usually shows up with XF86Setup
+ * this hack waits at max 5 seconds after pclose() returns
+ * for the output of the xkbcomp output file.
+ * I didn't manage to get a patch in time for the 3.2 release
+ */
+ {
+ int i;
+ char name[PATH_MAX];
+ if (XkbBaseDirectory!=NULL)
+ sprintf(name,"%s/%s%s.xkm", XkbBaseDirectory
+ ,xkm_output_dir, keymap);
+ else
+ sprintf(name,"%s%s.xkm", xkm_output_dir, keymap);
+ for (i = 0; i < 10; i++) {
+ if (access(name, 0) == 0) break;
+ usleep(500000);
+ }
+#ifdef DEBUG
+ if (i) ErrorF(">>>> Waited %d times for %s\n", i, name);
+#endif
+ }
+#endif
+ if (buf != NULL)
+ xfree (buf);
+ return True;
+ }
+#ifdef DEBUG
+ else
+ ErrorF("Error compiling keymap (%s)\n",keymap);
+#endif
+#ifdef WIN32
+ /* remove the temporary file */
+ unlink(tmpname);
+#endif
+ }
+#ifdef DEBUG
+ else {
+#ifndef WIN32
+ ErrorF("Could not invoke keymap compiler\n");
+#else
+ ErrorF("Could not open file %s\n", tmpname);
+#endif
+ }
+#endif
+ if (nameRtrn)
+ nameRtrn[0]= '\0';
+ if (buf != NULL)
+ xfree (buf);
+ return False;
+}
+
+FILE *
+XkbDDXOpenConfigFile(char *mapName,char *fileNameRtrn,int fileNameRtrnLen)
+{
+char buf[PATH_MAX],xkm_output_dir[PATH_MAX];
+FILE * file;
+
+ buf[0]= '\0';
+ if (mapName!=NULL) {
+ OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
+ if ((XkbBaseDirectory!=NULL)&&(xkm_output_dir[0]!='/')
+#ifdef WIN32
+ &&(!isalpha(xkm_output_dir[0]) || xkm_output_dir[1]!=':')
+#endif
+ ) {
+ if (strlen(XkbBaseDirectory)+strlen(xkm_output_dir)
+ +strlen(mapName)+6 <= PATH_MAX)
+ {
+ sprintf(buf,"%s/%s%s.xkm",XkbBaseDirectory,
+ xkm_output_dir,mapName);
+ }
+ }
+ else if (strlen(xkm_output_dir)+strlen(mapName)+5 <= PATH_MAX)
+ sprintf(buf,"%s%s.xkm",xkm_output_dir,mapName);
+ if (buf[0] != '\0')
+ file= fopen(buf,"rb");
+ else file= NULL;
+ }
+ else file= NULL;
+ if ((fileNameRtrn!=NULL)&&(fileNameRtrnLen>0)) {
+ strncpy(fileNameRtrn,buf,fileNameRtrnLen);
+ buf[fileNameRtrnLen-1]= '\0';
+ }
+ return file;
+}
+
+unsigned
+XkbDDXLoadKeymapByNames( DeviceIntPtr keybd,
+ XkbComponentNamesPtr names,
+ unsigned want,
+ unsigned need,
+ XkbFileInfo * finfoRtrn,
+ char * nameRtrn,
+ int nameRtrnLen)
+{
+XkbDescPtr xkb;
+FILE * file;
+char fileName[PATH_MAX];
+unsigned missing;
+
+ bzero(finfoRtrn,sizeof(XkbFileInfo));
+ if ((keybd==NULL)||(keybd->key==NULL)||(keybd->key->xkbInfo==NULL))
+ xkb= NULL;
+ else xkb= keybd->key->xkbInfo->desc;
+ if ((names->keycodes==NULL)&&(names->types==NULL)&&
+ (names->compat==NULL)&&(names->symbols==NULL)&&
+ (names->geometry==NULL)) {
+ if (names->keymap==NULL) {
+ bzero(finfoRtrn,sizeof(XkbFileInfo));
+ if (xkb && XkbDetermineFileType(finfoRtrn,XkbXKMFile,NULL) &&
+ ((finfoRtrn->defined&need)==need) ) {
+ finfoRtrn->xkb= xkb;
+ nameRtrn[0]= '\0';
+ return finfoRtrn->defined;
+ }
+ return 0;
+ }
+ else if (!XkbDDXCompileNamedKeymap(xkb,names,nameRtrn,nameRtrnLen)) {
+#ifdef NOISY
+ ErrorF("Couldn't compile keymap file\n");
+#endif
+ return 0;
+ }
+ }
+ else if (!XkbDDXCompileKeymapByNames(xkb,names,want,need,
+ nameRtrn,nameRtrnLen)){
+#ifdef NOISY
+ ErrorF("Couldn't compile keymap file\n");
+#endif
+ return 0;
+ }
+ file= XkbDDXOpenConfigFile(nameRtrn,fileName,PATH_MAX);
+ if (file==NULL) {
+ LogMessage(X_ERROR, "Couldn't open compiled keymap file %s\n",fileName);
+ return 0;
+ }
+ missing= XkmReadFile(file,need,want,finfoRtrn);
+ if (finfoRtrn->xkb==NULL) {
+ LogMessage(X_ERROR, "Error loading keymap %s\n",fileName);
+ fclose(file);
+ (void) unlink (fileName);
+ return 0;
+ }
+#ifdef DEBUG
+ else if (xkbDebugFlags) {
+ ErrorF("Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined);
+ }
+#endif
+ fclose(file);
+ (void) unlink (fileName);
+ return (need|want)&(~missing);
+}
+
+Bool
+XkbDDXNamesFromRules( DeviceIntPtr keybd,
+ char * rules_name,
+ XkbRF_VarDefsPtr defs,
+ XkbComponentNamesPtr names)
+{
+char buf[PATH_MAX];
+FILE * file;
+Bool complete;
+XkbRF_RulesPtr rules;
+
+ if (!rules_name)
+ return False;
+ if (XkbBaseDirectory==NULL) {
+ if (strlen(rules_name)+7 > PATH_MAX)
+ return False;
+ sprintf(buf,"rules/%s",rules_name);
+ }
+ else {
+ if (strlen(XkbBaseDirectory)+strlen(rules_name)+8 > PATH_MAX)
+ return False;
+ sprintf(buf,"%s/rules/%s",XkbBaseDirectory,rules_name);
+ }
+ if ((file= fopen(buf,"r"))==NULL)
+ return False;
+ if ((rules= XkbRF_Create(0,0))==NULL) {
+ fclose(file);
+ return False;
+ }
+ if (!XkbRF_LoadRules(file,rules)) {
+ fclose(file);
+ XkbRF_Free(rules,True);
+ return False;
+ }
+ bzero((char *)names,sizeof(XkbComponentNamesRec));
+ complete= XkbRF_GetComponents(rules,defs,names);
+ fclose(file);
+ XkbRF_Free(rules,True);
+ return complete;
+}
+
+
diff --git a/nx-X11/programs/Xserver/xkb/ddxPrivate.c b/nx-X11/programs/Xserver/xkb/ddxPrivate.c
new file mode 100644
index 000000000..5c0bca4cd
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/ddxPrivate.c
@@ -0,0 +1,46 @@
+/* $XFree86: xc/programs/Xserver/xkb/ddxPrivate.c,v 1.2 2003/04/03 16:20:22 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include "windowstr.h"
+#define XKBSRV_NEED_FILE_FUNCS
+#include <X11/extensions/XKBsrv.h>
+
+#ifdef XF86DDXACTIONS
+#include "xf86.h"
+#endif
+
+int
+XkbDDXPrivate(DeviceIntPtr dev,KeyCode key,XkbAction *act)
+{
+#ifdef XF86DDXACTIONS
+ XkbAnyAction *xf86act = &(act->any);
+ char msgbuf[XkbAnyActionDataSize+1];
+
+ if (xf86act->type == XkbSA_XFree86Private) {
+ memcpy(msgbuf, xf86act->data, XkbAnyActionDataSize);
+ msgbuf[XkbAnyActionDataSize]= '\0';
+ if (_XkbStrCaseCmp(msgbuf, "-vmode")==0)
+ xf86ProcessActionEvent(ACTION_PREV_MODE, NULL);
+ else if (_XkbStrCaseCmp(msgbuf, "+vmode")==0)
+ xf86ProcessActionEvent(ACTION_NEXT_MODE, NULL);
+ else if (_XkbStrCaseCmp(msgbuf, "ungrab")==0)
+ xf86ProcessActionEvent(ACTION_DISABLEGRAB, NULL);
+ else if (_XkbStrCaseCmp(msgbuf, "clsgrb")==0)
+ xf86ProcessActionEvent(ACTION_CLOSECLIENT, NULL);
+ else
+ xf86ProcessActionEvent(ACTION_MESSAGE, (void *) msgbuf);
+ }
+#endif
+ return 0;
+}
+
diff --git a/nx-X11/programs/Xserver/xkb/ddxVT.c b/nx-X11/programs/Xserver/xkb/ddxVT.c
new file mode 100644
index 000000000..1b7853fa0
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/ddxVT.c
@@ -0,0 +1,72 @@
+/* $Xorg: ddxVT.c,v 1.3 2000/08/17 19:53:46 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/ddxVT.c,v 1.3 2002/11/23 19:27:50 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XI.h>
+
+#ifdef XF86DDXACTIONS
+#include "xf86.h"
+#endif
+
+int
+XkbDDXSwitchScreen(DeviceIntPtr dev,KeyCode key,XkbAction *act)
+{
+#ifdef XF86DDXACTIONS
+ {
+ int scrnnum = XkbSAScreen(&act->screen);
+
+ if (act->screen.flags & XkbSA_SwitchApplication) {
+ if (act->screen.flags & XkbSA_SwitchAbsolute)
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN,(void *) &scrnnum);
+ else {
+ if (scrnnum < 0)
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN_PREV,NULL);
+ else
+ xf86ProcessActionEvent(ACTION_SWITCHSCREEN_NEXT,NULL);
+ }
+ }
+ }
+#endif
+ return 1;
+}
diff --git a/nx-X11/programs/Xserver/xkb/xkb.c b/nx-X11/programs/Xserver/xkb/xkb.c
new file mode 100644
index 000000000..240509079
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/xkb.c
@@ -0,0 +1,6233 @@
+/* $Xorg: xkb.c,v 1.3 2000/08/17 19:53:46 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/xkb.c,v 3.22tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <X11/X.h>
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+#define XKBSRV_NEED_FILE_FUNCS
+#include <X11/extensions/XKBsrv.h>
+#include "extnsionst.h"
+#include "xkb.h"
+
+#include <X11/extensions/XI.h>
+
+ int XkbEventBase;
+ int XkbErrorBase;
+ int XkbReqCode;
+ int XkbKeyboardErrorCode;
+Atom xkbONE_LEVEL;
+Atom xkbTWO_LEVEL;
+Atom xkbKEYPAD;
+CARD32 xkbDebugFlags = 0;
+CARD32 xkbDebugCtrls = 0;
+
+#ifndef XKB_SRV_UNSUPPORTED_XI_FEATURES
+#define XKB_SRV_UNSUPPORTED_XI_FEATURES XkbXI_KeyboardsMask
+#endif
+
+unsigned XkbXIUnsupported= XKB_SRV_UNSUPPORTED_XI_FEATURES;
+
+RESTYPE RT_XKBCLIENT;
+
+/***====================================================================***/
+
+#define CHK_DEVICE(d,sp,lf) {\
+ int why;\
+ d = (DeviceIntPtr)lf((sp),&why);\
+ if (!dev) {\
+ client->errorValue = _XkbErrCode2(why,(sp));\
+ return XkbKeyboardErrorCode;\
+ }\
+}
+
+#define CHK_KBD_DEVICE(d,sp) CHK_DEVICE(d,sp,_XkbLookupKeyboard)
+#define CHK_LED_DEVICE(d,sp) CHK_DEVICE(d,sp,_XkbLookupLedDevice)
+#define CHK_BELL_DEVICE(d,sp) CHK_DEVICE(d,sp,_XkbLookupBellDevice)
+#define CHK_ANY_DEVICE(d,sp) CHK_DEVICE(d,sp,_XkbLookupAnyDevice)
+
+#define CHK_ATOM_ONLY2(a,ev,er) {\
+ if (((a)==None)||(!ValidAtom((a)))) {\
+ (ev)= (XID)(a);\
+ return er;\
+ }\
+}
+#define CHK_ATOM_ONLY(a) \
+ CHK_ATOM_ONLY2(a,client->errorValue,BadAtom)
+
+#define CHK_ATOM_OR_NONE3(a,ev,er,ret) {\
+ if (((a)!=None)&&(!ValidAtom((a)))) {\
+ (ev)= (XID)(a);\
+ (er)= BadAtom;\
+ return ret;\
+ }\
+}
+#define CHK_ATOM_OR_NONE2(a,ev,er) {\
+ if (((a)!=None)&&(!ValidAtom((a)))) {\
+ (ev)= (XID)(a);\
+ return er;\
+ }\
+}
+#define CHK_ATOM_OR_NONE(a) \
+ CHK_ATOM_OR_NONE2(a,client->errorValue,BadAtom)
+
+#define CHK_MASK_LEGAL3(err,mask,legal,ev,er,ret) {\
+ if ((mask)&(~(legal))) { \
+ (ev)= _XkbErrCode2((err),((mask)&(~(legal))));\
+ (er)= BadValue;\
+ return ret;\
+ }\
+}
+#define CHK_MASK_LEGAL2(err,mask,legal,ev,er) {\
+ if ((mask)&(~(legal))) { \
+ (ev)= _XkbErrCode2((err),((mask)&(~(legal))));\
+ return er;\
+ }\
+}
+#define CHK_MASK_LEGAL(err,mask,legal) \
+ CHK_MASK_LEGAL2(err,mask,legal,client->errorValue,BadValue)
+
+#define CHK_MASK_MATCH(err,affect,value) {\
+ if ((value)&(~(affect))) { \
+ client->errorValue= _XkbErrCode2((err),((value)&(~(affect))));\
+ return BadMatch;\
+ }\
+}
+#define CHK_MASK_OVERLAP(err,m1,m2) {\
+ if ((m1)&(m2)) { \
+ client->errorValue= _XkbErrCode2((err),((m1)&(m2)));\
+ return BadMatch;\
+ }\
+}
+#define CHK_KEY_RANGE2(err,first,num,x,ev,er) {\
+ if (((unsigned)(first)+(num)-1)>(x)->max_key_code) {\
+ (ev)=_XkbErrCode4(err,(first),(num),(x)->max_key_code);\
+ return er;\
+ }\
+ else if ( (first)<(x)->min_key_code ) {\
+ (ev)=_XkbErrCode3(err+1,(first),xkb->min_key_code);\
+ return er;\
+ }\
+}
+#define CHK_KEY_RANGE(err,first,num,x) \
+ CHK_KEY_RANGE2(err,first,num,x,client->errorValue,BadValue)
+
+#define CHK_REQ_KEY_RANGE2(err,first,num,r,ev,er) {\
+ if (((unsigned)(first)+(num)-1)>(r)->maxKeyCode) {\
+ (ev)=_XkbErrCode4(err,(first),(num),(r)->maxKeyCode);\
+ return er;\
+ }\
+ else if ( (first)<(r)->minKeyCode ) {\
+ (ev)=_XkbErrCode3(err+1,(first),(r)->minKeyCode);\
+ return er;\
+ }\
+}
+#define CHK_REQ_KEY_RANGE(err,first,num,r) \
+ CHK_REQ_KEY_RANGE2(err,first,num,r,client->errorValue,BadValue)
+
+/***====================================================================***/
+
+int
+ProcXkbUseExtension(ClientPtr client)
+{
+ REQUEST(xkbUseExtensionReq);
+ xkbUseExtensionReply rep;
+ register int n;
+ int supported;
+
+ REQUEST_SIZE_MATCH(xkbUseExtensionReq);
+ if (stuff->wantedMajor != XkbMajorVersion) {
+ /* pre-release version 0.65 is compatible with 1.00 */
+ supported= ((XkbMajorVersion==1)&&
+ (stuff->wantedMajor==0)&&(stuff->wantedMinor==65));
+ }
+ else supported = 1;
+
+#ifdef XKB_SWAPPING_BUSTED
+ if (client->swapped)
+ supported= 0;
+#endif
+
+ if ((supported) && (!(client->xkbClientFlags&_XkbClientInitialized))) {
+ client->xkbClientFlags= _XkbClientInitialized;
+ client->vMajor= stuff->wantedMajor;
+ client->vMinor= stuff->wantedMinor;
+ }
+ else if (xkbDebugFlags&0x1) {
+ ErrorF("Rejecting client %d (0x%lx) (wants %d.%02d, have %d.%02d)\n",
+ client->index,
+ (long)client->clientAsMask,
+ stuff->wantedMajor,stuff->wantedMinor,
+ XkbMajorVersion,XkbMinorVersion);
+ }
+ rep.type = X_Reply;
+ rep.supported = supported;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.serverMajor = XkbMajorVersion;
+ rep.serverMinor = XkbMinorVersion;
+ if ( client->swapped ) {
+ swaps(&rep.sequenceNumber, n);
+ swaps(&rep.serverMajor, n);
+ swaps(&rep.serverMinor, n);
+ }
+ WriteToClient(client,SIZEOF(xkbUseExtensionReply), (char *)&rep);
+ return client->noClientException;
+}
+
+/***====================================================================***/
+
+int
+ProcXkbSelectEvents(ClientPtr client)
+{
+ unsigned legal;
+ DeviceIntPtr dev;
+ XkbInterestPtr masks;
+ REQUEST(xkbSelectEventsReq);
+
+ REQUEST_AT_LEAST_SIZE(xkbSelectEventsReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_ANY_DEVICE(dev,stuff->deviceSpec);
+
+ if (((stuff->affectWhich&XkbMapNotifyMask)!=0)&&(stuff->affectMap)) {
+ client->mapNotifyMask&= ~stuff->affectMap;
+ client->mapNotifyMask|= (stuff->affectMap&stuff->map);
+ }
+ if ((stuff->affectWhich&(~XkbMapNotifyMask))==0)
+ return client->noClientException;
+
+ masks = XkbFindClientResource((DevicePtr)dev,client);
+ if (!masks){
+ XID id = FakeClientID(client->index);
+ AddResource(id,RT_XKBCLIENT,dev);
+ masks= XkbAddClientResource((DevicePtr)dev,client,id);
+ }
+ if (masks) {
+ union {
+ CARD8 *c8;
+ CARD16 *c16;
+ CARD32 *c32;
+ } from,to;
+ register unsigned bit,ndx,maskLeft,dataLeft,size;
+
+ from.c8= (CARD8 *)&stuff[1];
+ dataLeft= (stuff->length*4)-SIZEOF(xkbSelectEventsReq);
+ maskLeft= (stuff->affectWhich&(~XkbMapNotifyMask));
+ for (ndx=0,bit=1; (maskLeft!=0); ndx++, bit<<=1) {
+ if ((bit&maskLeft)==0)
+ continue;
+ maskLeft&= ~bit;
+ switch (ndx) {
+ case XkbNewKeyboardNotify:
+ to.c16= &client->newKeyboardNotifyMask;
+ legal= XkbAllNewKeyboardEventsMask;
+ size= 2;
+ break;
+ case XkbStateNotify:
+ to.c16= &masks->stateNotifyMask;
+ legal= XkbAllStateEventsMask;
+ size= 2;
+ break;
+ case XkbControlsNotify:
+ to.c32= &masks->ctrlsNotifyMask;
+ legal= XkbAllControlEventsMask;
+ size= 4;
+ break;
+ case XkbIndicatorStateNotify:
+ to.c32= &masks->iStateNotifyMask;
+ legal= XkbAllIndicatorEventsMask;
+ size= 4;
+ break;
+ case XkbIndicatorMapNotify:
+ to.c32= &masks->iMapNotifyMask;
+ legal= XkbAllIndicatorEventsMask;
+ size= 4;
+ break;
+ case XkbNamesNotify:
+ to.c16= &masks->namesNotifyMask;
+ legal= XkbAllNameEventsMask;
+ size= 2;
+ break;
+ case XkbCompatMapNotify:
+ to.c8= &masks->compatNotifyMask;
+ legal= XkbAllCompatMapEventsMask;
+ size= 1;
+ break;
+ case XkbBellNotify:
+ to.c8= &masks->bellNotifyMask;
+ legal= XkbAllBellEventsMask;
+ size= 1;
+ break;
+ case XkbActionMessage:
+ to.c8= &masks->actionMessageMask;
+ legal= XkbAllActionMessagesMask;
+ size= 1;
+ break;
+ case XkbAccessXNotify:
+ to.c16= &masks->accessXNotifyMask;
+ legal= XkbAllAccessXEventsMask;
+ size= 2;
+ break;
+ case XkbExtensionDeviceNotify:
+ to.c16= &masks->extDevNotifyMask;
+ legal= XkbAllExtensionDeviceEventsMask;
+ size= 2;
+ break;
+ default:
+ client->errorValue = _XkbErrCode2(33,bit);
+ return BadValue;
+ }
+
+ if (stuff->clear&bit) {
+ if (size==2) to.c16[0]= 0;
+ else if (size==4) to.c32[0]= 0;
+ else to.c8[0]= 0;
+ }
+ else if (stuff->selectAll&bit) {
+ if (size==2) to.c16[0]= ~0;
+ else if (size==4) to.c32[0]= ~0;
+ else to.c8[0]= ~0;
+ }
+ else {
+ if (dataLeft<(size*2))
+ return BadLength;
+ if (size==2) {
+ CHK_MASK_MATCH(ndx,from.c16[0],from.c16[1]);
+ CHK_MASK_LEGAL(ndx,from.c16[0],legal);
+ to.c16[0]&= ~from.c16[0];
+ to.c16[0]|= (from.c16[0]&from.c16[1]);
+ }
+ else if (size==4) {
+ CHK_MASK_MATCH(ndx,from.c32[0],from.c32[1]);
+ CHK_MASK_LEGAL(ndx,from.c32[0],legal);
+ to.c32[0]&= ~from.c32[0];
+ to.c32[0]|= (from.c32[0]&from.c32[1]);
+ }
+ else {
+ CHK_MASK_MATCH(ndx,from.c8[0],from.c8[1]);
+ CHK_MASK_LEGAL(ndx,from.c8[0],legal);
+ to.c8[0]&= ~from.c8[0];
+ to.c8[0]|= (from.c8[0]&from.c8[1]);
+ size= 2;
+ }
+ from.c8+= (size*2);
+ dataLeft-= (size*2);
+ }
+ }
+ if (dataLeft>2) {
+ ErrorF("Extra data (%d bytes) after SelectEvents\n",dataLeft);
+ return BadLength;
+ }
+ return client->noClientException;
+ }
+ return BadAlloc;
+}
+
+/***====================================================================***/
+
+int
+ProcXkbBell(ClientPtr client)
+{
+ REQUEST(xkbBellReq);
+ DeviceIntPtr dev;
+ WindowPtr pWin;
+ int base;
+ int newPercent,oldPitch,oldDuration;
+ pointer ctrl;
+
+ REQUEST_SIZE_MATCH(xkbBellReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_BELL_DEVICE(dev,stuff->deviceSpec);
+ CHK_ATOM_OR_NONE(stuff->name);
+
+ if ((stuff->forceSound)&&(stuff->eventOnly)) {
+ client->errorValue=_XkbErrCode3(0x1,stuff->forceSound,stuff->eventOnly);
+ return BadMatch;
+ }
+ if (stuff->percent < -100 || stuff->percent > 100) {
+ client->errorValue = _XkbErrCode2(0x2,stuff->percent);
+ return BadValue;
+ }
+ if (stuff->duration<-1) {
+ client->errorValue = _XkbErrCode2(0x3,stuff->duration);
+ return BadValue;
+ }
+ if (stuff->pitch<-1) {
+ client->errorValue = _XkbErrCode2(0x4,stuff->pitch);
+ return BadValue;
+ }
+
+ if (stuff->bellClass == XkbDfltXIClass) {
+ if (dev->kbdfeed!=NULL)
+ stuff->bellClass= KbdFeedbackClass;
+ else stuff->bellClass= BellFeedbackClass;
+ }
+ if (stuff->bellClass == KbdFeedbackClass) {
+ KbdFeedbackPtr k;
+ if (stuff->bellID==XkbDfltXIId)
+ k= dev->kbdfeed;
+ else {
+ for (k=dev->kbdfeed; k; k=k->next) {
+ if (k->ctrl.id == stuff->bellID)
+ break;
+ }
+ }
+ if (!k) {
+ client->errorValue= _XkbErrCode2(0x5,stuff->bellID);
+ return BadValue;
+ }
+ base = k->ctrl.bell;
+ ctrl = (pointer) &(k->ctrl);
+ oldPitch= k->ctrl.bell_pitch;
+ oldDuration= k->ctrl.bell_duration;
+ if (stuff->pitch!=0) {
+ if (stuff->pitch==-1)
+ k->ctrl.bell_pitch= defaultKeyboardControl.bell_pitch;
+ else k->ctrl.bell_pitch= stuff->pitch;
+ }
+ if (stuff->duration!=0) {
+ if (stuff->duration==-1)
+ k->ctrl.bell_duration= defaultKeyboardControl.bell_duration;
+ else k->ctrl.bell_duration= stuff->duration;
+ }
+ }
+ else if (stuff->bellClass == BellFeedbackClass) {
+ BellFeedbackPtr b;
+ if (stuff->bellID==XkbDfltXIId)
+ b= dev->bell;
+ else {
+ for (b=dev->bell; b; b=b->next) {
+ if (b->ctrl.id == stuff->bellID)
+ break;
+ }
+ }
+ if (!b) {
+ client->errorValue = _XkbErrCode2(0x6,stuff->bellID);
+ return BadValue;
+ }
+ base = b->ctrl.percent;
+ ctrl = (pointer) &(b->ctrl);
+ oldPitch= b->ctrl.pitch;
+ oldDuration= b->ctrl.duration;
+ if (stuff->pitch!=0) {
+ if (stuff->pitch==-1)
+ b->ctrl.pitch= defaultKeyboardControl.bell_pitch;
+ else b->ctrl.pitch= stuff->pitch;
+ }
+ if (stuff->duration!=0) {
+ if (stuff->duration==-1)
+ b->ctrl.duration= defaultKeyboardControl.bell_duration;
+ else b->ctrl.duration= stuff->duration;
+ }
+ }
+ else {
+ client->errorValue = _XkbErrCode2(0x7,stuff->bellClass);;
+ return BadValue;
+ }
+ if (stuff->window!=None) {
+ pWin= (WindowPtr)LookupIDByType(stuff->window,RT_WINDOW);
+ if (pWin==NULL) {
+ client->errorValue= stuff->window;
+ return BadValue;
+ }
+ }
+ else pWin= NULL;
+
+ newPercent= (base*stuff->percent)/100;
+ if (stuff->percent < 0)
+ newPercent= base+newPercent;
+ else newPercent= base-newPercent+stuff->percent;
+ XkbHandleBell(stuff->forceSound, stuff->eventOnly,
+ dev, newPercent, ctrl, stuff->bellClass,
+ stuff->name, pWin, client);
+ if ((stuff->pitch!=0)||(stuff->duration!=0)) {
+ if (stuff->bellClass == KbdFeedbackClass) {
+ KbdFeedbackPtr k;
+ k= (KbdFeedbackPtr)ctrl;
+ if (stuff->pitch!=0)
+ k->ctrl.bell_pitch= oldPitch;
+ if (stuff->duration!=0)
+ k->ctrl.bell_duration= oldDuration;
+ }
+ else {
+ BellFeedbackPtr b;
+ b= (BellFeedbackPtr)ctrl;
+ if (stuff->pitch!=0)
+ b->ctrl.pitch= oldPitch;
+ if (stuff->duration!=0)
+ b->ctrl.duration= oldDuration;
+ }
+ }
+ return Success;
+}
+
+/***====================================================================***/
+
+int
+ProcXkbGetState(ClientPtr client)
+{
+ REQUEST(xkbGetStateReq);
+ DeviceIntPtr dev;
+ xkbGetStateReply rep;
+ XkbStateRec *xkb;
+
+ REQUEST_SIZE_MATCH(xkbGetStateReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+
+ xkb= &dev->key->xkbInfo->state;
+ bzero(&rep,sizeof(xkbGetStateReply));
+ rep.type= X_Reply;
+ rep.sequenceNumber= client->sequence;
+ rep.length = 0;
+ rep.deviceID = dev->id;
+ rep.mods = dev->key->state&0xff;
+ rep.baseMods = xkb->base_mods;
+ rep.lockedMods = xkb->locked_mods;
+ rep.latchedMods = xkb->latched_mods;
+ rep.group = xkb->group;
+ rep.baseGroup = xkb->base_group;
+ rep.latchedGroup = xkb->latched_group;
+ rep.lockedGroup = xkb->locked_group;
+ rep.compatState = xkb->compat_state;
+ rep.ptrBtnState = xkb->ptr_buttons;
+ if (client->swapped) {
+ register int n;
+ swaps(&rep.sequenceNumber,n);
+ swaps(&rep.ptrBtnState,n);
+ }
+ WriteToClient(client, SIZEOF(xkbGetStateReply), (char *)&rep);
+ return client->noClientException;
+}
+
+/***====================================================================***/
+
+int
+ProcXkbLatchLockState(ClientPtr client)
+{
+ int status;
+ DeviceIntPtr dev;
+ XkbStateRec oldState,*newState;
+ CARD16 changed;
+
+ REQUEST(xkbLatchLockStateReq);
+ REQUEST_SIZE_MATCH(xkbLatchLockStateReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_MASK_MATCH(0x01,stuff->affectModLocks,stuff->modLocks);
+ CHK_MASK_MATCH(0x01,stuff->affectModLatches,stuff->modLatches);
+
+ status = Success;
+ oldState= dev->key->xkbInfo->state;
+ newState= &dev->key->xkbInfo->state;
+ if ( stuff->affectModLocks ) {
+ newState->locked_mods&= ~stuff->affectModLocks;
+ newState->locked_mods|= (stuff->affectModLocks&stuff->modLocks);
+ }
+ if (( status == Success ) && stuff->lockGroup )
+ newState->locked_group = stuff->groupLock;
+ if (( status == Success ) && stuff->affectModLatches )
+ status=XkbLatchModifiers(dev,stuff->affectModLatches,stuff->modLatches);
+ if (( status == Success ) && stuff->latchGroup )
+ status=XkbLatchGroup(dev,stuff->groupLatch);
+
+ if ( status != Success )
+ return status;
+
+ XkbComputeDerivedState(dev->key->xkbInfo);
+ dev->key->state= XkbStateFieldFromRec(newState);
+
+ changed = XkbStateChangedFlags(&oldState,newState);
+ if (changed) {
+ xkbStateNotify sn;
+ sn.keycode= 0;
+ sn.eventType= 0;
+ sn.requestMajor = XkbReqCode;
+ sn.requestMinor = X_kbLatchLockState;
+ sn.changed= changed;
+ XkbSendStateNotify(dev,&sn);
+ changed= XkbIndicatorsToUpdate(dev,changed,False);
+ if (changed) {
+ XkbEventCauseRec cause;
+ XkbSetCauseXkbReq(&cause,X_kbLatchLockState,client);
+ XkbUpdateIndicators(dev,changed,True,NULL,&cause);
+ }
+ }
+ return client->noClientException;
+}
+
+/***====================================================================***/
+
+int
+ProcXkbGetControls(ClientPtr client)
+{
+ xkbGetControlsReply rep;
+ XkbControlsPtr xkb;
+ DeviceIntPtr dev;
+ register int n;
+
+ REQUEST(xkbGetControlsReq);
+ REQUEST_SIZE_MATCH(xkbGetControlsReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+
+ xkb = dev->key->xkbInfo->desc->ctrls;
+ rep.type = X_Reply;
+ rep.length = (SIZEOF(xkbGetControlsReply)-
+ SIZEOF(xGenericReply)) >> 2;
+ rep.sequenceNumber = client->sequence;
+ rep.deviceID = ((DeviceIntPtr)dev)->id;
+ rep.numGroups = xkb->num_groups;
+ rep.groupsWrap = xkb->groups_wrap;
+ rep.internalMods = xkb->internal.mask;
+ rep.ignoreLockMods = xkb->ignore_lock.mask;
+ rep.internalRealMods = xkb->internal.real_mods;
+ rep.ignoreLockRealMods = xkb->ignore_lock.real_mods;
+ rep.internalVMods = xkb->internal.vmods;
+ rep.ignoreLockVMods = xkb->ignore_lock.vmods;
+ rep.enabledCtrls = xkb->enabled_ctrls;
+ rep.repeatDelay = xkb->repeat_delay;
+ rep.repeatInterval = xkb->repeat_interval;
+ rep.slowKeysDelay = xkb->slow_keys_delay;
+ rep.debounceDelay = xkb->debounce_delay;
+ rep.mkDelay = xkb->mk_delay;
+ rep.mkInterval = xkb->mk_interval;
+ rep.mkTimeToMax = xkb->mk_time_to_max;
+ rep.mkMaxSpeed = xkb->mk_max_speed;
+ rep.mkCurve = xkb->mk_curve;
+ rep.mkDfltBtn = xkb->mk_dflt_btn;
+ rep.axTimeout = xkb->ax_timeout;
+ rep.axtCtrlsMask = xkb->axt_ctrls_mask;
+ rep.axtCtrlsValues = xkb->axt_ctrls_values;
+ rep.axtOptsMask = xkb->axt_opts_mask;
+ rep.axtOptsValues = xkb->axt_opts_values;
+ rep.axOptions = xkb->ax_options;
+ memcpy(rep.perKeyRepeat,xkb->per_key_repeat,XkbPerKeyBitArraySize);
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length,n);
+ swaps(&rep.internalVMods, n);
+ swaps(&rep.ignoreLockVMods, n);
+ swapl(&rep.enabledCtrls, n);
+ swaps(&rep.repeatDelay, n);
+ swaps(&rep.repeatInterval, n);
+ swaps(&rep.slowKeysDelay, n);
+ swaps(&rep.debounceDelay, n);
+ swaps(&rep.mkDelay, n);
+ swaps(&rep.mkInterval, n);
+ swaps(&rep.mkTimeToMax, n);
+ swaps(&rep.mkMaxSpeed, n);
+ swaps(&rep.mkCurve, n);
+ swaps(&rep.axTimeout, n);
+ swapl(&rep.axtCtrlsMask, n);
+ swapl(&rep.axtCtrlsValues, n);
+ swaps(&rep.axtOptsMask, n);
+ swaps(&rep.axtOptsValues, n);
+ swaps(&rep.axOptions, n);
+ }
+ WriteToClient(client, SIZEOF(xkbGetControlsReply), (char *)&rep);
+ return(client->noClientException);
+}
+
+int
+ProcXkbSetControls(ClientPtr client)
+{
+ DeviceIntPtr dev;
+ XkbSrvInfoPtr xkbi;
+ XkbControlsPtr ctrl;
+ XkbControlsRec new,old;
+ xkbControlsNotify cn;
+ XkbEventCauseRec cause;
+ XkbSrvLedInfoPtr sli;
+
+ REQUEST(xkbSetControlsReq);
+ REQUEST_SIZE_MATCH(xkbSetControlsReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_MASK_LEGAL(0x01,stuff->changeCtrls,XkbAllControlsMask);
+
+ xkbi = dev->key->xkbInfo;
+ ctrl = xkbi->desc->ctrls;
+ new = *ctrl;
+ XkbSetCauseXkbReq(&cause,X_kbSetControls,client);
+ if (stuff->changeCtrls&XkbInternalModsMask) {
+ CHK_MASK_MATCH(0x02,stuff->affectInternalMods,stuff->internalMods);
+ CHK_MASK_MATCH(0x03,stuff->affectInternalVMods,stuff->internalVMods);
+ new.internal.real_mods&=~stuff->affectInternalMods;
+ new.internal.real_mods|=(stuff->affectInternalMods&stuff->internalMods);
+ new.internal.vmods&=~stuff->affectInternalVMods;
+ new.internal.vmods|= (stuff->affectInternalVMods&stuff->internalVMods);
+ new.internal.mask= new.internal.real_mods|
+ XkbMaskForVMask(xkbi->desc,new.internal.vmods);
+ }
+ if (stuff->changeCtrls&XkbIgnoreLockModsMask) {
+ CHK_MASK_MATCH(0x4,stuff->affectIgnoreLockMods,stuff->ignoreLockMods);
+ CHK_MASK_MATCH(0x5,stuff->affectIgnoreLockVMods,stuff->ignoreLockVMods);
+ new.ignore_lock.real_mods&=~stuff->affectIgnoreLockMods;
+ new.ignore_lock.real_mods|=
+ (stuff->affectIgnoreLockMods&stuff->ignoreLockMods);
+ new.ignore_lock.vmods&= ~stuff->affectIgnoreLockVMods;
+ new.ignore_lock.vmods|=
+ (stuff->affectIgnoreLockVMods&stuff->ignoreLockVMods);
+ new.ignore_lock.mask= new.ignore_lock.real_mods|
+ XkbMaskForVMask(xkbi->desc,new.ignore_lock.vmods);
+ }
+ CHK_MASK_MATCH(0x06,stuff->affectEnabledCtrls,stuff->enabledCtrls);
+ if (stuff->affectEnabledCtrls) {
+ CHK_MASK_LEGAL(0x07,stuff->affectEnabledCtrls,XkbAllBooleanCtrlsMask);
+ new.enabled_ctrls&= ~stuff->affectEnabledCtrls;
+ new.enabled_ctrls|= (stuff->affectEnabledCtrls&stuff->enabledCtrls);
+ }
+ if (stuff->changeCtrls&XkbRepeatKeysMask) {
+ if ((stuff->repeatDelay<1)||(stuff->repeatInterval<1)) {
+ client->errorValue = _XkbErrCode3(0x08,stuff->repeatDelay,
+ stuff->repeatInterval);
+ return BadValue;
+ }
+ new.repeat_delay = stuff->repeatDelay;
+ new.repeat_interval = stuff->repeatInterval;
+ }
+ if (stuff->changeCtrls&XkbSlowKeysMask) {
+ if (stuff->slowKeysDelay<1) {
+ client->errorValue = _XkbErrCode2(0x09,stuff->slowKeysDelay);
+ return BadValue;
+ }
+ new.slow_keys_delay = stuff->slowKeysDelay;
+ }
+ if (stuff->changeCtrls&XkbBounceKeysMask) {
+ if (stuff->debounceDelay<1) {
+ client->errorValue = _XkbErrCode2(0x0A,stuff->debounceDelay);
+ return BadValue;
+ }
+ new.debounce_delay = stuff->debounceDelay;
+ }
+ if (stuff->changeCtrls&XkbMouseKeysMask) {
+ if (stuff->mkDfltBtn>XkbMaxMouseKeysBtn) {
+ client->errorValue = _XkbErrCode2(0x0B,stuff->mkDfltBtn);
+ return BadValue;
+ }
+ new.mk_dflt_btn = stuff->mkDfltBtn;
+ }
+ if (stuff->changeCtrls&XkbMouseKeysAccelMask) {
+ if ((stuff->mkDelay<1) || (stuff->mkInterval<1) ||
+ (stuff->mkTimeToMax<1) || (stuff->mkMaxSpeed<1)||
+ (stuff->mkCurve<-1000)) {
+ client->errorValue = _XkbErrCode2(0x0C,0);
+ return BadValue;
+ }
+ new.mk_delay = stuff->mkDelay;
+ new.mk_interval = stuff->mkInterval;
+ new.mk_time_to_max = stuff->mkTimeToMax;
+ new.mk_max_speed = stuff->mkMaxSpeed;
+ new.mk_curve = stuff->mkCurve;
+ AccessXComputeCurveFactor(xkbi,&new);
+ }
+ if (stuff->changeCtrls&XkbGroupsWrapMask) {
+ unsigned act,num;
+ act= XkbOutOfRangeGroupAction(stuff->groupsWrap);
+ switch (act) {
+ case XkbRedirectIntoRange:
+ num= XkbOutOfRangeGroupNumber(stuff->groupsWrap);
+ if (num>=new.num_groups) {
+ client->errorValue= _XkbErrCode3(0x0D,new.num_groups,num);
+ return BadValue;
+ }
+ case XkbWrapIntoRange:
+ case XkbClampIntoRange:
+ break;
+ default:
+ client->errorValue= _XkbErrCode2(0x0E,act);
+ return BadValue;
+ }
+ new.groups_wrap= stuff->groupsWrap;
+ }
+ CHK_MASK_LEGAL(0x0F,stuff->axOptions,XkbAX_AllOptionsMask);
+ if (stuff->changeCtrls&XkbAccessXKeysMask)
+ new.ax_options = stuff->axOptions&XkbAX_AllOptionsMask;
+ else {
+ if (stuff->changeCtrls&XkbStickyKeysMask) {
+ new.ax_options&= ~XkbAX_SKOptionsMask;
+ new.ax_options|= stuff->axOptions&XkbAX_SKOptionsMask;
+ }
+ if (stuff->changeCtrls&XkbAccessXFeedbackMask) {
+ new.ax_options&= ~XkbAX_FBOptionsMask;
+ new.ax_options|= stuff->axOptions&XkbAX_FBOptionsMask;
+ }
+ }
+
+ if (stuff->changeCtrls&XkbAccessXTimeoutMask) {
+ if (stuff->axTimeout<1) {
+ client->errorValue = _XkbErrCode2(0x10,stuff->axTimeout);
+ return BadValue;
+ }
+ CHK_MASK_MATCH(0x11,stuff->axtCtrlsMask,stuff->axtCtrlsValues);
+ CHK_MASK_LEGAL(0x12,stuff->axtCtrlsMask,XkbAllBooleanCtrlsMask);
+ CHK_MASK_MATCH(0x13,stuff->axtOptsMask,stuff->axtOptsValues);
+ CHK_MASK_LEGAL(0x14,stuff->axtOptsMask,XkbAX_AllOptionsMask);
+ new.ax_timeout = stuff->axTimeout;
+ new.axt_ctrls_mask = stuff->axtCtrlsMask;
+ new.axt_ctrls_values = (stuff->axtCtrlsValues&stuff->axtCtrlsMask);
+ new.axt_opts_mask = stuff->axtOptsMask;
+ new.axt_opts_values= (stuff->axtOptsValues&stuff->axtOptsMask);
+ }
+ if (stuff->changeCtrls&XkbPerKeyRepeatMask) {
+ memcpy(new.per_key_repeat,stuff->perKeyRepeat,XkbPerKeyBitArraySize);
+ }
+ old= *ctrl;
+ *ctrl= new;
+ XkbDDXChangeControls(dev,&old,ctrl);
+ if (XkbComputeControlsNotify(dev,&old,ctrl,&cn,False)) {
+ cn.keycode= 0;
+ cn.eventType = 0;
+ cn.requestMajor = XkbReqCode;
+ cn.requestMinor = X_kbSetControls;
+ XkbSendControlsNotify(dev,&cn);
+ }
+ if ((sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0))!=NULL)
+ XkbUpdateIndicators(dev,sli->usesControls,True,NULL,&cause);
+#ifndef NO_CLEAR_LATCHES_FOR_STICKY_KEYS_OFF
+ /* If sticky keys were disabled, clear all locks and latches */
+ if ((old.enabled_ctrls&XkbStickyKeysMask)&&
+ (!(ctrl->enabled_ctrls&XkbStickyKeysMask))) {
+ XkbClearAllLatchesAndLocks(dev,xkbi,True,&cause);
+ }
+#endif
+ return client->noClientException;
+}
+
+int
+XkbSetRepeatRate(DeviceIntPtr dev,int timeout,int interval,int major,int minor)
+{
+int changed= 0;
+XkbControlsRec old,*xkb;
+
+ if ((!dev)||(!dev->key)||(!dev->key->xkbInfo))
+ return 0;
+ xkb= dev->key->xkbInfo->desc->ctrls;
+ old= *xkb;
+ if ((timeout!=0) && (xkb->repeat_delay!=timeout)) {
+ xkb->repeat_delay= timeout;
+ changed++;
+ }
+ if ((interval!=0) && (xkb->repeat_interval!=interval)) {
+ xkb->repeat_interval= interval;
+ changed++;
+ }
+ if (changed) {
+ xkbControlsNotify cn;
+ XkbDDXChangeControls(dev,&old,xkb);
+ if (XkbComputeControlsNotify(dev,&old,xkb,&cn,False)) {
+ cn.keycode= 0;
+ cn.eventType = 0;
+ cn.requestMajor = major;
+ cn.requestMinor = minor;
+ XkbSendControlsNotify(dev,&cn);
+ }
+ }
+ return 1;
+}
+
+int
+XkbGetRepeatRate(DeviceIntPtr dev,int *timeout,int *interval)
+{
+XkbControlsPtr xkb;
+
+ if ((!dev)||(!dev->key)||(!dev->key->xkbInfo))
+ return 0;
+ xkb= dev->key->xkbInfo->desc->ctrls;
+ if (timeout) *timeout= xkb->repeat_delay;
+ if (interval) *interval= xkb->repeat_interval;
+ return 1;
+}
+
+/***====================================================================***/
+
+static int
+XkbSizeKeyTypes(XkbDescPtr xkb,xkbGetMapReply *rep)
+{
+ XkbKeyTypeRec *type;
+ unsigned i,len;
+
+ len= 0;
+ if (((rep->present&XkbKeyTypesMask)==0)||(rep->nTypes<1)||
+ (!xkb)||(!xkb->map)||(!xkb->map->types)) {
+ rep->present&= ~XkbKeyTypesMask;
+ rep->firstType= rep->nTypes= 0;
+ return 0;
+ }
+ type= &xkb->map->types[rep->firstType];
+ for (i=0;i<rep->nTypes;i++,type++){
+ len+= SIZEOF(xkbKeyTypeWireDesc);
+ if (type->map_count>0) {
+ len+= (type->map_count*SIZEOF(xkbKTMapEntryWireDesc));
+ if (type->preserve)
+ len+= (type->map_count*SIZEOF(xkbModsWireDesc));
+ }
+ }
+ return len;
+}
+
+static char *
+XkbWriteKeyTypes( XkbDescPtr xkb,
+ xkbGetMapReply * rep,
+ char * buf,
+ ClientPtr client)
+{
+ XkbKeyTypePtr type;
+ unsigned i;
+ xkbKeyTypeWireDesc *wire;
+
+ type= &xkb->map->types[rep->firstType];
+ for (i=0;i<rep->nTypes;i++,type++) {
+ register unsigned n;
+ wire= (xkbKeyTypeWireDesc *)buf;
+ wire->mask = type->mods.mask;
+ wire->realMods = type->mods.real_mods;
+ wire->virtualMods = type->mods.vmods;
+ wire->numLevels = type->num_levels;
+ wire->nMapEntries = type->map_count;
+ wire->preserve = (type->preserve!=NULL);
+ if (client->swapped) {
+ register int n;
+ swaps(&wire->virtualMods,n);
+ }
+
+ buf= (char *)&wire[1];
+ if (wire->nMapEntries>0) {
+ xkbKTMapEntryWireDesc * wire;
+ XkbKTMapEntryPtr entry;
+ wire= (xkbKTMapEntryWireDesc *)buf;
+ entry= type->map;
+ for (n=0;n<type->map_count;n++,wire++,entry++) {
+ wire->active= entry->active;
+ wire->mask= entry->mods.mask;
+ wire->level= entry->level;
+ wire->realMods= entry->mods.real_mods;
+ wire->virtualMods= entry->mods.vmods;
+ if (client->swapped) {
+ register int n;
+ swaps(&wire->virtualMods,n);
+ }
+ }
+ buf= (char *)wire;
+ if (type->preserve!=NULL) {
+ xkbModsWireDesc * pwire;
+ XkbModsPtr preserve;
+ pwire= (xkbModsWireDesc *)buf;
+ preserve= type->preserve;
+ for (n=0;n<type->map_count;n++,pwire++,preserve++) {
+ pwire->mask= preserve->mask;
+ pwire->realMods= preserve->real_mods;
+ pwire->virtualMods= preserve->vmods;
+ if (client->swapped) {
+ register int n;
+ swaps(&pwire->virtualMods,n);
+ }
+ }
+ buf= (char *)pwire;
+ }
+ }
+ }
+ return buf;
+}
+
+static int
+XkbSizeKeySyms(XkbDescPtr xkb,xkbGetMapReply *rep)
+{
+ XkbSymMapPtr symMap;
+ unsigned i,len;
+ unsigned nSyms,nSymsThisKey;
+
+ if (((rep->present&XkbKeySymsMask)==0)||(rep->nKeySyms<1)||
+ (!xkb)||(!xkb->map)||(!xkb->map->key_sym_map)) {
+ rep->present&= ~XkbKeySymsMask;
+ rep->firstKeySym= rep->nKeySyms= 0;
+ rep->totalSyms= 0;
+ return 0;
+ }
+ len= rep->nKeySyms*SIZEOF(xkbSymMapWireDesc);
+ symMap = &xkb->map->key_sym_map[rep->firstKeySym];
+ for (i=nSyms=0;i<rep->nKeySyms;i++,symMap++) {
+ if (symMap->offset!=0) {
+ nSymsThisKey= XkbNumGroups(symMap->group_info)*symMap->width;
+ nSyms+= nSymsThisKey;
+ }
+ }
+ len+= nSyms*4;
+ rep->totalSyms= nSyms;
+ return len;
+}
+
+static int
+XkbSizeVirtualMods(XkbDescPtr xkb,xkbGetMapReply *rep)
+{
+register unsigned i,nMods,bit;
+
+ if (((rep->present&XkbVirtualModsMask)==0)||(rep->virtualMods==0)||
+ (!xkb)||(!xkb->server)) {
+ rep->present&= ~XkbVirtualModsMask;
+ rep->virtualMods= 0;
+ return 0;
+ }
+ for (i=nMods=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (rep->virtualMods&bit)
+ nMods++;
+ }
+ return XkbPaddedSize(nMods);
+}
+
+static char *
+XkbWriteKeySyms(XkbDescPtr xkb,xkbGetMapReply *rep,char *buf,ClientPtr client)
+{
+register KeySym * pSym;
+XkbSymMapPtr symMap;
+xkbSymMapWireDesc * outMap;
+register unsigned i;
+
+ symMap = &xkb->map->key_sym_map[rep->firstKeySym];
+ for (i=0;i<rep->nKeySyms;i++,symMap++) {
+ outMap = (xkbSymMapWireDesc *)buf;
+ outMap->ktIndex[0] = symMap->kt_index[0];
+ outMap->ktIndex[1] = symMap->kt_index[1];
+ outMap->ktIndex[2] = symMap->kt_index[2];
+ outMap->ktIndex[3] = symMap->kt_index[3];
+ outMap->groupInfo = symMap->group_info;
+ outMap->width= symMap->width;
+ outMap->nSyms = symMap->width*XkbNumGroups(symMap->group_info);
+ buf= (char *)&outMap[1];
+ if (outMap->nSyms==0)
+ continue;
+
+ pSym = &xkb->map->syms[symMap->offset];
+ memcpy((char *)buf,(char *)pSym,outMap->nSyms*4);
+ if (client->swapped) {
+ register int n,nSyms= outMap->nSyms;
+ swaps(&outMap->nSyms,n);
+ while (nSyms-->0) {
+ swapl(buf,n);
+ buf+= 4;
+ }
+ }
+ else buf+= outMap->nSyms*4;
+ }
+ return buf;
+}
+
+static int
+XkbSizeKeyActions(XkbDescPtr xkb,xkbGetMapReply *rep)
+{
+ unsigned i,len,nActs;
+ register KeyCode firstKey;
+
+ if (((rep->present&XkbKeyActionsMask)==0)||(rep->nKeyActs<1)||
+ (!xkb)||(!xkb->server)||(!xkb->server->key_acts)) {
+ rep->present&= ~XkbKeyActionsMask;
+ rep->firstKeyAct= rep->nKeyActs= 0;
+ rep->totalActs= 0;
+ return 0;
+ }
+ firstKey= rep->firstKeyAct;
+ for (nActs=i=0;i<rep->nKeyActs;i++) {
+ if (xkb->server->key_acts[i+firstKey]!=0)
+ nActs+= XkbKeyNumActions(xkb,i+firstKey);
+ }
+ len= XkbPaddedSize(rep->nKeyActs)+(nActs*SIZEOF(xkbActionWireDesc));
+ rep->totalActs= nActs;
+ return len;
+}
+
+static char *
+XkbWriteKeyActions(XkbDescPtr xkb,xkbGetMapReply *rep,char *buf,
+ ClientPtr client)
+{
+ unsigned i;
+ CARD8 * numDesc;
+ XkbAnyAction * actDesc;
+
+ numDesc = (CARD8 *)buf;
+ for (i=0;i<rep->nKeyActs;i++) {
+ if (xkb->server->key_acts[i+rep->firstKeyAct]==0)
+ numDesc[i] = 0;
+ else numDesc[i] = XkbKeyNumActions(xkb,(i+rep->firstKeyAct));
+ }
+ buf+= XkbPaddedSize(rep->nKeyActs);
+
+ actDesc = (XkbAnyAction *)buf;
+ for (i=0;i<rep->nKeyActs;i++) {
+ if (xkb->server->key_acts[i+rep->firstKeyAct]!=0) {
+ unsigned int num;
+ num = XkbKeyNumActions(xkb,(i+rep->firstKeyAct));
+ memcpy((char *)actDesc,
+ (char*)XkbKeyActionsPtr(xkb,(i+rep->firstKeyAct)),
+ num*SIZEOF(xkbActionWireDesc));
+ actDesc+= num;
+ }
+ }
+ buf = (char *)actDesc;
+ return buf;
+}
+
+static int
+XkbSizeKeyBehaviors(XkbDescPtr xkb,xkbGetMapReply *rep)
+{
+ unsigned i,len,nBhvr;
+ XkbBehavior * bhv;
+
+ if (((rep->present&XkbKeyBehaviorsMask)==0)||(rep->nKeyBehaviors<1)||
+ (!xkb)||(!xkb->server)||(!xkb->server->behaviors)) {
+ rep->present&= ~XkbKeyBehaviorsMask;
+ rep->firstKeyBehavior= rep->nKeyBehaviors= 0;
+ rep->totalKeyBehaviors= 0;
+ return 0;
+ }
+ bhv= &xkb->server->behaviors[rep->firstKeyBehavior];
+ for (nBhvr=i=0;i<rep->nKeyBehaviors;i++,bhv++) {
+ if (bhv->type!=XkbKB_Default)
+ nBhvr++;
+ }
+ len= nBhvr*SIZEOF(xkbBehaviorWireDesc);
+ rep->totalKeyBehaviors= nBhvr;
+ return len;
+}
+
+static char *
+XkbWriteKeyBehaviors(XkbDescPtr xkb,xkbGetMapReply *rep,char *buf,
+ ClientPtr client)
+{
+ unsigned i;
+ xkbBehaviorWireDesc *wire;
+ XkbBehavior *pBhvr;
+
+ wire = (xkbBehaviorWireDesc *)buf;
+ pBhvr= &xkb->server->behaviors[rep->firstKeyBehavior];
+ for (i=0;i<rep->nKeyBehaviors;i++,pBhvr++) {
+ if (pBhvr->type!=XkbKB_Default) {
+ wire->key= i+rep->firstKeyBehavior;
+ wire->type= pBhvr->type;
+ wire->data= pBhvr->data;
+ wire++;
+ }
+ }
+ buf = (char *)wire;
+ return buf;
+}
+
+static int
+XkbSizeExplicit(XkbDescPtr xkb,xkbGetMapReply *rep)
+{
+ unsigned i,len,nRtrn;
+
+ if (((rep->present&XkbExplicitComponentsMask)==0)||(rep->nKeyExplicit<1)||
+ (!xkb)||(!xkb->server)||(!xkb->server->explicit)) {
+ rep->present&= ~XkbExplicitComponentsMask;
+ rep->firstKeyExplicit= rep->nKeyExplicit= 0;
+ rep->totalKeyExplicit= 0;
+ return 0;
+ }
+ for (nRtrn=i=0;i<rep->nKeyExplicit;i++) {
+ if (xkb->server->explicit[i+rep->firstKeyExplicit]!=0)
+ nRtrn++;
+ }
+ rep->totalKeyExplicit= nRtrn;
+ len= XkbPaddedSize(nRtrn*2); /* two bytes per non-zero explicit component */
+ return len;
+}
+
+static char *
+XkbWriteExplicit(XkbDescPtr xkb,xkbGetMapReply *rep,char *buf,ClientPtr client)
+{
+unsigned i;
+char * start;
+unsigned char * pExp;
+
+ start= buf;
+ pExp= &xkb->server->explicit[rep->firstKeyExplicit];
+ for (i=0;i<rep->nKeyExplicit;i++,pExp++) {
+ if (*pExp!=0) {
+ *buf++= i+rep->firstKeyExplicit;
+ *buf++= *pExp;
+ }
+ }
+ i= XkbPaddedSize(buf-start)-(buf-start); /* pad to word boundary */
+ return buf+i;
+}
+
+static int
+XkbSizeModifierMap(XkbDescPtr xkb,xkbGetMapReply *rep)
+{
+ unsigned i,len,nRtrn;
+
+ if (((rep->present&XkbModifierMapMask)==0)||(rep->nModMapKeys<1)||
+ (!xkb)||(!xkb->map)||(!xkb->map->modmap)) {
+ rep->present&= ~XkbModifierMapMask;
+ rep->firstModMapKey= rep->nModMapKeys= 0;
+ rep->totalModMapKeys= 0;
+ return 0;
+ }
+ for (nRtrn=i=0;i<rep->nModMapKeys;i++) {
+ if (xkb->map->modmap[i+rep->firstModMapKey]!=0)
+ nRtrn++;
+ }
+ rep->totalModMapKeys= nRtrn;
+ len= XkbPaddedSize(nRtrn*2); /* two bytes per non-zero modmap component */
+ return len;
+}
+
+static char *
+XkbWriteModifierMap(XkbDescPtr xkb,xkbGetMapReply *rep,char *buf,
+ ClientPtr client)
+{
+unsigned i;
+char * start;
+unsigned char * pMap;
+
+ start= buf;
+ pMap= &xkb->map->modmap[rep->firstModMapKey];
+ for (i=0;i<rep->nModMapKeys;i++,pMap++) {
+ if (*pMap!=0) {
+ *buf++= i+rep->firstModMapKey;
+ *buf++= *pMap;
+ }
+ }
+ i= XkbPaddedSize(buf-start)-(buf-start); /* pad to word boundary */
+ return buf+i;
+}
+
+static int
+XkbSizeVirtualModMap(XkbDescPtr xkb,xkbGetMapReply *rep)
+{
+ unsigned i,len,nRtrn;
+
+ if (((rep->present&XkbVirtualModMapMask)==0)||(rep->nVModMapKeys<1)||
+ (!xkb)||(!xkb->server)||(!xkb->server->vmodmap)) {
+ rep->present&= ~XkbVirtualModMapMask;
+ rep->firstVModMapKey= rep->nVModMapKeys= 0;
+ rep->totalVModMapKeys= 0;
+ return 0;
+ }
+ for (nRtrn=i=0;i<rep->nVModMapKeys;i++) {
+ if (xkb->server->vmodmap[i+rep->firstVModMapKey]!=0)
+ nRtrn++;
+ }
+ rep->totalVModMapKeys= nRtrn;
+ len= nRtrn*SIZEOF(xkbVModMapWireDesc);
+ return len;
+}
+
+static char *
+XkbWriteVirtualModMap(XkbDescPtr xkb,xkbGetMapReply *rep,char *buf,
+ ClientPtr client)
+{
+unsigned i;
+xkbVModMapWireDesc * wire;
+unsigned short * pMap;
+
+ wire= (xkbVModMapWireDesc *)buf;
+ pMap= &xkb->server->vmodmap[rep->firstVModMapKey];
+ for (i=0;i<rep->nVModMapKeys;i++,pMap++) {
+ if (*pMap!=0) {
+ wire->key= i+rep->firstVModMapKey;
+ wire->vmods= *pMap;
+ wire++;
+ }
+ }
+ return (char *)wire;
+}
+
+static Status
+XkbComputeGetMapReplySize(XkbDescPtr xkb,xkbGetMapReply *rep)
+{
+int len;
+
+ rep->minKeyCode= xkb->min_key_code;
+ rep->maxKeyCode= xkb->max_key_code;
+ len= XkbSizeKeyTypes(xkb,rep);
+ len+= XkbSizeKeySyms(xkb,rep);
+ len+= XkbSizeKeyActions(xkb,rep);
+ len+= XkbSizeKeyBehaviors(xkb,rep);
+ len+= XkbSizeVirtualMods(xkb,rep);
+ len+= XkbSizeExplicit(xkb,rep);
+ len+= XkbSizeModifierMap(xkb,rep);
+ len+= XkbSizeVirtualModMap(xkb,rep);
+ rep->length+= (len/4);
+ return Success;
+}
+
+static int
+XkbSendMap(ClientPtr client,XkbDescPtr xkb,xkbGetMapReply *rep)
+{
+unsigned i,len;
+char *desc,*start;
+
+ len= (rep->length*4)-(SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply));
+ start= desc= (char *)ALLOCATE_LOCAL(len);
+ if (!start)
+ return BadAlloc;
+ if ( rep->nTypes>0 )
+ desc = XkbWriteKeyTypes(xkb,rep,desc,client);
+ if ( rep->nKeySyms>0 )
+ desc = XkbWriteKeySyms(xkb,rep,desc,client);
+ if ( rep->nKeyActs>0 )
+ desc = XkbWriteKeyActions(xkb,rep,desc,client);
+ if ( rep->totalKeyBehaviors>0 )
+ desc = XkbWriteKeyBehaviors(xkb,rep,desc,client);
+ if ( rep->virtualMods ) {
+ register int sz,bit;
+ for (i=sz=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (rep->virtualMods&bit) {
+ desc[sz++]= xkb->server->vmods[i];
+ }
+ }
+ desc+= XkbPaddedSize(sz);
+ }
+ if ( rep->totalKeyExplicit>0 )
+ desc= XkbWriteExplicit(xkb,rep,desc,client);
+ if ( rep->totalModMapKeys>0 )
+ desc= XkbWriteModifierMap(xkb,rep,desc,client);
+ if ( rep->totalVModMapKeys>0 )
+ desc= XkbWriteVirtualModMap(xkb,rep,desc,client);
+ if ((desc-start)!=(len)) {
+ ErrorF("BOGUS LENGTH in write keyboard desc, expected %d, got %ld\n",
+ len, (unsigned long)(desc-start));
+ }
+ if (client->swapped) {
+ register int n;
+ swaps(&rep->sequenceNumber,n);
+ swapl(&rep->length,n);
+ swaps(&rep->present,n);
+ swaps(&rep->totalSyms,n);
+ swaps(&rep->totalActs,n);
+ }
+ WriteToClient(client, (i=SIZEOF(xkbGetMapReply)), (char *)rep);
+ WriteToClient(client, len, start);
+ DEALLOCATE_LOCAL((char *)start);
+ return client->noClientException;
+}
+
+int
+ProcXkbGetMap(ClientPtr client)
+{
+ DeviceIntPtr dev;
+ xkbGetMapReply rep;
+ XkbDescRec *xkb;
+ int n,status;
+
+ REQUEST(xkbGetMapReq);
+ REQUEST_SIZE_MATCH(xkbGetMapReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_MASK_OVERLAP(0x01,stuff->full,stuff->partial);
+ CHK_MASK_LEGAL(0x02,stuff->full,XkbAllMapComponentsMask);
+ CHK_MASK_LEGAL(0x03,stuff->partial,XkbAllMapComponentsMask);
+
+ xkb= dev->key->xkbInfo->desc;
+ bzero(&rep,sizeof(xkbGetMapReply));
+ rep.type= X_Reply;
+ rep.sequenceNumber= client->sequence;
+ rep.length = (SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply))>>2;
+ rep.deviceID = dev->id;
+ rep.present = stuff->partial|stuff->full;
+ rep.minKeyCode = xkb->min_key_code;
+ rep.maxKeyCode = xkb->max_key_code;
+ if ( stuff->full&XkbKeyTypesMask ) {
+ rep.firstType = 0;
+ rep.nTypes = xkb->map->num_types;
+ }
+ else if (stuff->partial&XkbKeyTypesMask) {
+ if (((unsigned)stuff->firstType+stuff->nTypes)>xkb->map->num_types) {
+ client->errorValue = _XkbErrCode4(0x04,xkb->map->num_types,
+ stuff->firstType,stuff->nTypes);
+ return BadValue;
+ }
+ rep.firstType = stuff->firstType;
+ rep.nTypes = stuff->nTypes;
+ }
+ else rep.nTypes = 0;
+ rep.totalTypes = xkb->map->num_types;
+
+ n= XkbNumKeys(xkb);
+ if ( stuff->full&XkbKeySymsMask ) {
+ rep.firstKeySym = xkb->min_key_code;
+ rep.nKeySyms = n;
+ }
+ else if (stuff->partial&XkbKeySymsMask) {
+ CHK_KEY_RANGE(0x05,stuff->firstKeySym,stuff->nKeySyms,xkb);
+ rep.firstKeySym = stuff->firstKeySym;
+ rep.nKeySyms = stuff->nKeySyms;
+ }
+ else rep.nKeySyms = 0;
+ rep.totalSyms= 0;
+
+ if ( stuff->full&XkbKeyActionsMask ) {
+ rep.firstKeyAct= xkb->min_key_code;
+ rep.nKeyActs= n;
+ }
+ else if (stuff->partial&XkbKeyActionsMask) {
+ CHK_KEY_RANGE(0x07,stuff->firstKeyAct,stuff->nKeyActs,xkb);
+ rep.firstKeyAct= stuff->firstKeyAct;
+ rep.nKeyActs= stuff->nKeyActs;
+ }
+ else rep.nKeyActs= 0;
+ rep.totalActs= 0;
+
+ if ( stuff->full&XkbKeyBehaviorsMask ) {
+ rep.firstKeyBehavior = xkb->min_key_code;
+ rep.nKeyBehaviors = n;
+ }
+ else if (stuff->partial&XkbKeyBehaviorsMask) {
+ CHK_KEY_RANGE(0x09,stuff->firstKeyBehavior,stuff->nKeyBehaviors,xkb);
+ rep.firstKeyBehavior= stuff->firstKeyBehavior;
+ rep.nKeyBehaviors= stuff->nKeyBehaviors;
+ }
+ else rep.nKeyBehaviors = 0;
+ rep.totalKeyBehaviors= 0;
+
+ if (stuff->full&XkbVirtualModsMask)
+ rep.virtualMods= ~0;
+ else if (stuff->partial&XkbVirtualModsMask)
+ rep.virtualMods= stuff->virtualMods;
+
+ if (stuff->full&XkbExplicitComponentsMask) {
+ rep.firstKeyExplicit= xkb->min_key_code;
+ rep.nKeyExplicit= n;
+ }
+ else if (stuff->partial&XkbExplicitComponentsMask) {
+ CHK_KEY_RANGE(0x0B,stuff->firstKeyExplicit,stuff->nKeyExplicit,xkb);
+ rep.firstKeyExplicit= stuff->firstKeyExplicit;
+ rep.nKeyExplicit= stuff->nKeyExplicit;
+ }
+ else rep.nKeyExplicit = 0;
+ rep.totalKeyExplicit= 0;
+
+ if (stuff->full&XkbModifierMapMask) {
+ rep.firstModMapKey= xkb->min_key_code;
+ rep.nModMapKeys= n;
+ }
+ else if (stuff->partial&XkbModifierMapMask) {
+ CHK_KEY_RANGE(0x0D,stuff->firstModMapKey,stuff->nModMapKeys,xkb);
+ rep.firstModMapKey= stuff->firstModMapKey;
+ rep.nModMapKeys= stuff->nModMapKeys;
+ }
+ else rep.nModMapKeys = 0;
+ rep.totalModMapKeys= 0;
+
+ if (stuff->full&XkbVirtualModMapMask) {
+ rep.firstVModMapKey= xkb->min_key_code;
+ rep.nVModMapKeys= n;
+ }
+ else if (stuff->partial&XkbVirtualModMapMask) {
+ CHK_KEY_RANGE(0x0F,stuff->firstVModMapKey,stuff->nVModMapKeys,xkb);
+ rep.firstVModMapKey= stuff->firstVModMapKey;
+ rep.nVModMapKeys= stuff->nVModMapKeys;
+ }
+ else rep.nVModMapKeys = 0;
+ rep.totalVModMapKeys= 0;
+
+ if ((status=XkbComputeGetMapReplySize(xkb,&rep))!=Success)
+ return status;
+ return XkbSendMap(client,xkb,&rep);
+}
+
+/***====================================================================***/
+
+static int
+CheckKeyTypes( ClientPtr client,
+ XkbDescPtr xkb,
+ xkbSetMapReq * req,
+ xkbKeyTypeWireDesc **wireRtrn,
+ int * nMapsRtrn,
+ CARD8 * mapWidthRtrn)
+{
+unsigned nMaps;
+register unsigned i,n;
+register CARD8 * map;
+register xkbKeyTypeWireDesc *wire = *wireRtrn;
+
+ if (req->firstType>((unsigned)xkb->map->num_types)) {
+ *nMapsRtrn = _XkbErrCode3(0x01,req->firstType,xkb->map->num_types);
+ return 0;
+ }
+ if (req->flags&XkbSetMapResizeTypes) {
+ nMaps = req->firstType+req->nTypes;
+ if (nMaps<XkbNumRequiredTypes) { /* canonical types must be there */
+ *nMapsRtrn= _XkbErrCode4(0x02,req->firstType,req->nTypes,4);
+ return 0;
+ }
+ }
+ else if (req->present&XkbKeyTypesMask) {
+ nMaps = xkb->map->num_types;
+ if ((req->firstType+req->nTypes)>nMaps) {
+ *nMapsRtrn = req->firstType+req->nTypes;
+ return 0;
+ }
+ }
+ else {
+ *nMapsRtrn = xkb->map->num_types;
+ for (i=0;i<xkb->map->num_types;i++) {
+ mapWidthRtrn[i] = xkb->map->types[i].num_levels;
+ }
+ return 1;
+ }
+
+ for (i=0;i<req->firstType;i++) {
+ mapWidthRtrn[i] = xkb->map->types[i].num_levels;
+ }
+ for (i=0;i<req->nTypes;i++) {
+ unsigned width;
+ if (client->swapped) {
+ register int s;
+ swaps(&wire->virtualMods,s);
+ }
+ n= i+req->firstType;
+ width= wire->numLevels;
+ if (width<1) {
+ *nMapsRtrn= _XkbErrCode3(0x04,n,width);
+ return 0;
+ }
+ else if ((n==XkbOneLevelIndex)&&(width!=1)) { /* must be width 1 */
+ *nMapsRtrn= _XkbErrCode3(0x05,n,width);
+ return 0;
+ }
+ else if ((width!=2)&&
+ ((n==XkbTwoLevelIndex)||(n==XkbKeypadIndex)||
+ (n==XkbAlphabeticIndex))) {
+ /* TWO_LEVEL, ALPHABETIC and KEYPAD must be width 2 */
+ *nMapsRtrn= _XkbErrCode3(0x05,n,width);
+ return 0;
+ }
+ if (wire->nMapEntries>0) {
+ xkbKTSetMapEntryWireDesc * mapWire;
+ xkbModsWireDesc * preWire;
+ mapWire= (xkbKTSetMapEntryWireDesc *)&wire[1];
+ preWire= (xkbModsWireDesc *)&mapWire[wire->nMapEntries];
+ for (n=0;n<wire->nMapEntries;n++) {
+ if (client->swapped) {
+ register int s;
+ swaps(&mapWire[n].virtualMods,s);
+ }
+ if (mapWire[n].realMods&(~wire->realMods)) {
+ *nMapsRtrn= _XkbErrCode4(0x06,n,mapWire[n].realMods,
+ wire->realMods);
+ return 0;
+ }
+ if (mapWire[n].virtualMods&(~wire->virtualMods)) {
+ *nMapsRtrn= _XkbErrCode3(0x07,n,mapWire[n].virtualMods);
+ return 0;
+ }
+ if (mapWire[n].level>=wire->numLevels) {
+ *nMapsRtrn= _XkbErrCode4(0x08,n,wire->numLevels,
+ mapWire[n].level);
+ return 0;
+ }
+ if (wire->preserve) {
+ if (client->swapped) {
+ register int s;
+ swaps(&preWire[n].virtualMods,s);
+ }
+ if (preWire[n].realMods&(~mapWire[n].realMods)) {
+ *nMapsRtrn= _XkbErrCode4(0x09,n,preWire[n].realMods,
+ mapWire[n].realMods);
+ return 0;
+ }
+ if (preWire[n].virtualMods&(~mapWire[n].virtualMods)) {
+ *nMapsRtrn=_XkbErrCode3(0x0a,n,preWire[n].virtualMods);
+ return 0;
+ }
+ }
+ }
+ if (wire->preserve)
+ map= (CARD8 *)&preWire[wire->nMapEntries];
+ else map= (CARD8 *)&mapWire[wire->nMapEntries];
+ }
+ else map= (CARD8 *)&wire[1];
+ mapWidthRtrn[i+req->firstType] = wire->numLevels;
+ wire= (xkbKeyTypeWireDesc *)map;
+ }
+ for (i=req->firstType+req->nTypes;i<nMaps;i++) {
+ mapWidthRtrn[i] = xkb->map->types[i].num_levels;
+ }
+ *nMapsRtrn = nMaps;
+ *wireRtrn = wire;
+ return 1;
+}
+
+static int
+CheckKeySyms( ClientPtr client,
+ XkbDescPtr xkb,
+ xkbSetMapReq * req,
+ int nTypes,
+ CARD8 * mapWidths,
+ CARD16 * symsPerKey,
+ xkbSymMapWireDesc ** wireRtrn,
+ int * errorRtrn)
+{
+register unsigned i;
+XkbSymMapPtr map;
+xkbSymMapWireDesc* wire = *wireRtrn;
+
+ if (!(XkbKeySymsMask&req->present))
+ return 1;
+ CHK_REQ_KEY_RANGE2(0x11,req->firstKeySym,req->nKeySyms,req,(*errorRtrn),0);
+ map = &xkb->map->key_sym_map[xkb->min_key_code];
+ for (i=xkb->min_key_code;i<(unsigned)req->firstKeySym;i++,map++) {
+ register int g,ng,w;
+ ng= XkbNumGroups(map->group_info);
+ for (w=g=0;g<ng;g++) {
+ if (map->kt_index[g]>=(unsigned)nTypes) {
+ *errorRtrn = _XkbErrCode4(0x13,i,g,map->kt_index[g]);
+ return 0;
+ }
+ if (mapWidths[map->kt_index[g]]>w)
+ w= mapWidths[map->kt_index[g]];
+ }
+ symsPerKey[i] = w*ng;
+ }
+ for (i=0;i<req->nKeySyms;i++) {
+ KeySym *pSyms;
+ register unsigned nG;
+ if (client->swapped) {
+ swaps(&wire->nSyms,nG);
+ }
+ nG = XkbNumGroups(wire->groupInfo);
+ if (nG>XkbNumKbdGroups) {
+ *errorRtrn = _XkbErrCode3(0x14,i+req->firstKeySym,nG);
+ return 0;
+ }
+ if (nG>0) {
+ register int g,w;
+ for (g=w=0;g<nG;g++) {
+ if (wire->ktIndex[g]>=(unsigned)nTypes) {
+ *errorRtrn= _XkbErrCode4(0x15,i+req->firstKeySym,g,
+ wire->ktIndex[g]);
+ return 0;
+ }
+ if (mapWidths[wire->ktIndex[g]]>w)
+ w= mapWidths[wire->ktIndex[g]];
+ }
+ if (wire->width!=w) {
+ *errorRtrn= _XkbErrCode3(0x16,i+req->firstKeySym,wire->width);
+ return 0;
+ }
+ w*= nG;
+ symsPerKey[i+req->firstKeySym] = w;
+ if (w!=wire->nSyms) {
+ *errorRtrn=_XkbErrCode4(0x16,i+req->firstKeySym,wire->nSyms,w);
+ return 0;
+ }
+ }
+ else if (wire->nSyms!=0) {
+ *errorRtrn = _XkbErrCode3(0x17,i+req->firstKeySym,wire->nSyms);
+ return 0;
+ }
+ pSyms = (KeySym *)&wire[1];
+ wire = (xkbSymMapWireDesc *)&pSyms[wire->nSyms];
+ }
+
+ map = &xkb->map->key_sym_map[i];
+ for (;i<=(unsigned)xkb->max_key_code;i++,map++) {
+ register int g,nG,w;
+ nG= XkbKeyNumGroups(xkb,i);
+ for (w=g=0;g<nG;g++) {
+ if (map->kt_index[g]>=(unsigned)nTypes) {
+ *errorRtrn = _XkbErrCode4(0x18,i,g,map->kt_index[g]);
+ return 0;
+ }
+ if (mapWidths[map->kt_index[g]]>w)
+ w= mapWidths[map->kt_index[g]];
+ }
+ symsPerKey[i] = w*nG;
+ }
+ *wireRtrn = wire;
+ return 1;
+}
+
+static int
+CheckKeyActions( XkbDescPtr xkb,
+ xkbSetMapReq * req,
+ int nTypes,
+ CARD8 * mapWidths,
+ CARD16 * symsPerKey,
+ CARD8 ** wireRtrn,
+ int * nActsRtrn)
+{
+int nActs;
+CARD8 * wire = *wireRtrn;
+register unsigned i;
+
+ if (!(XkbKeyActionsMask&req->present))
+ return 1;
+ CHK_REQ_KEY_RANGE2(0x21,req->firstKeyAct,req->nKeyActs,req,(*nActsRtrn),0);
+ for (nActs=i=0;i<req->nKeyActs;i++) {
+ if (wire[0]!=0) {
+ if (wire[0]==symsPerKey[i+req->firstKeyAct])
+ nActs+= wire[0];
+ else {
+ *nActsRtrn= _XkbErrCode3(0x23,i+req->firstKeyAct,wire[0]);
+ return 0;
+ }
+ }
+ wire++;
+ }
+ if (req->nKeyActs%4)
+ wire+= 4-(req->nKeyActs%4);
+ *wireRtrn = (CARD8 *)(((XkbAnyAction *)wire)+nActs);
+ *nActsRtrn = nActs;
+ return 1;
+}
+
+static int
+CheckKeyBehaviors( XkbDescPtr xkb,
+ xkbSetMapReq * req,
+ xkbBehaviorWireDesc ** wireRtrn,
+ int * errorRtrn)
+{
+register xkbBehaviorWireDesc * wire = *wireRtrn;
+register XkbServerMapPtr server = xkb->server;
+register unsigned i;
+unsigned first,last;
+
+ if (((req->present&XkbKeyBehaviorsMask)==0)||(req->nKeyBehaviors<1)) {
+ req->present&= ~XkbKeyBehaviorsMask;
+ req->nKeyBehaviors= 0;
+ return 1;
+ }
+ first= req->firstKeyBehavior;
+ last= req->firstKeyBehavior+req->nKeyBehaviors-1;
+ if (first<req->minKeyCode) {
+ *errorRtrn = _XkbErrCode3(0x31,first,req->minKeyCode);
+ return 0;
+ }
+ if (last>req->maxKeyCode) {
+ *errorRtrn = _XkbErrCode3(0x32,last,req->maxKeyCode);
+ return 0;
+ }
+
+ for (i=0;i<req->totalKeyBehaviors;i++,wire++) {
+ if ((wire->key<first)||(wire->key>last)) {
+ *errorRtrn = _XkbErrCode4(0x33,first,last,wire->key);
+ return 0;
+ }
+ if ((wire->type&XkbKB_Permanent)&&
+ ((server->behaviors[wire->key].type!=wire->type)||
+ (server->behaviors[wire->key].data!=wire->data))) {
+ *errorRtrn = _XkbErrCode3(0x33,wire->key,wire->type);
+ return 0;
+ }
+ if ((wire->type==XkbKB_RadioGroup)&&
+ ((wire->data&(~XkbKB_RGAllowNone))>XkbMaxRadioGroups)) {
+ *errorRtrn= _XkbErrCode4(0x34,wire->key,wire->data,
+ XkbMaxRadioGroups);
+ return 0;
+ }
+ if ((wire->type==XkbKB_Overlay1)||(wire->type==XkbKB_Overlay2)) {
+ CHK_KEY_RANGE2(0x35,wire->key,1,xkb,*errorRtrn,0);
+ }
+ }
+ *wireRtrn = wire;
+ return 1;
+}
+
+static int
+CheckVirtualMods( XkbDescRec * xkb,
+ xkbSetMapReq * req,
+ CARD8 ** wireRtrn,
+ int * errorRtrn)
+{
+register CARD8 *wire = *wireRtrn;
+register unsigned i,nMods,bit;
+
+ if (((req->present&XkbVirtualModsMask)==0)||(req->virtualMods==0))
+ return 1;
+ for (i=nMods=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (req->virtualMods&bit)
+ nMods++;
+ }
+ *wireRtrn= (wire+XkbPaddedSize(nMods));
+ return 1;
+}
+
+static int
+CheckKeyExplicit( XkbDescPtr xkb,
+ xkbSetMapReq * req,
+ CARD8 ** wireRtrn,
+ int * errorRtrn)
+{
+register CARD8 * wire = *wireRtrn;
+CARD8 * start;
+register unsigned i;
+int first,last;
+
+ if (((req->present&XkbExplicitComponentsMask)==0)||(req->nKeyExplicit<1)) {
+ req->present&= ~XkbExplicitComponentsMask;
+ req->nKeyExplicit= 0;
+ return 1;
+ }
+ first= req->firstKeyExplicit;
+ last= first+req->nKeyExplicit-1;
+ if (first<req->minKeyCode) {
+ *errorRtrn = _XkbErrCode3(0x51,first,req->minKeyCode);
+ return 0;
+ }
+ if (last>req->maxKeyCode) {
+ *errorRtrn = _XkbErrCode3(0x52,last,req->maxKeyCode);
+ return 0;
+ }
+ start= wire;
+ for (i=0;i<req->totalKeyExplicit;i++,wire+=2) {
+ if ((wire[0]<first)||(wire[0]>last)) {
+ *errorRtrn = _XkbErrCode4(0x53,first,last,wire[0]);
+ return 0;
+ }
+ if (wire[1]&(~XkbAllExplicitMask)) {
+ *errorRtrn= _XkbErrCode3(0x52,~XkbAllExplicitMask,wire[1]);
+ return 0;
+ }
+ }
+ wire+= XkbPaddedSize(wire-start)-(wire-start);
+ *wireRtrn= wire;
+ return 1;
+}
+
+static int
+CheckModifierMap(XkbDescPtr xkb,xkbSetMapReq *req,CARD8 **wireRtrn,int *errRtrn)
+{
+register CARD8 * wire = *wireRtrn;
+CARD8 * start;
+register unsigned i;
+int first,last;
+
+ if (((req->present&XkbModifierMapMask)==0)||(req->nModMapKeys<1)) {
+ req->present&= ~XkbModifierMapMask;
+ req->nModMapKeys= 0;
+ return 1;
+ }
+ first= req->firstModMapKey;
+ last= first+req->nModMapKeys-1;
+ if (first<req->minKeyCode) {
+ *errRtrn = _XkbErrCode3(0x61,first,req->minKeyCode);
+ return 0;
+ }
+ if (last>req->maxKeyCode) {
+ *errRtrn = _XkbErrCode3(0x62,last,req->maxKeyCode);
+ return 0;
+ }
+ start= wire;
+ for (i=0;i<req->totalModMapKeys;i++,wire+=2) {
+ if ((wire[0]<first)||(wire[0]>last)) {
+ *errRtrn = _XkbErrCode4(0x63,first,last,wire[0]);
+ return 0;
+ }
+ }
+ wire+= XkbPaddedSize(wire-start)-(wire-start);
+ *wireRtrn= wire;
+ return 1;
+}
+
+static int
+CheckVirtualModMap( XkbDescPtr xkb,
+ xkbSetMapReq *req,
+ xkbVModMapWireDesc **wireRtrn,
+ int *errRtrn)
+{
+register xkbVModMapWireDesc * wire = *wireRtrn;
+register unsigned i;
+int first,last;
+
+ if (((req->present&XkbVirtualModMapMask)==0)||(req->nVModMapKeys<1)) {
+ req->present&= ~XkbVirtualModMapMask;
+ req->nVModMapKeys= 0;
+ return 1;
+ }
+ first= req->firstVModMapKey;
+ last= first+req->nVModMapKeys-1;
+ if (first<req->minKeyCode) {
+ *errRtrn = _XkbErrCode3(0x71,first,req->minKeyCode);
+ return 0;
+ }
+ if (last>req->maxKeyCode) {
+ *errRtrn = _XkbErrCode3(0x72,last,req->maxKeyCode);
+ return 0;
+ }
+ for (i=0;i<req->totalVModMapKeys;i++,wire++) {
+ if ((wire->key<first)||(wire->key>last)) {
+ *errRtrn = _XkbErrCode4(0x73,first,last,wire->key);
+ return 0;
+ }
+ }
+ *wireRtrn= wire;
+ return 1;
+}
+
+static char *
+SetKeyTypes( XkbDescPtr xkb,
+ xkbSetMapReq * req,
+ xkbKeyTypeWireDesc * wire,
+ XkbChangesPtr changes)
+{
+register unsigned i;
+unsigned first,last;
+CARD8 *map;
+
+ if ((unsigned)(req->firstType+req->nTypes)>xkb->map->size_types) {
+ i= req->firstType+req->nTypes;
+ if (XkbAllocClientMap(xkb,XkbKeyTypesMask,i)!=Success) {
+ return NULL;
+ }
+ }
+ if ((unsigned)(req->firstType+req->nTypes)>xkb->map->num_types)
+ xkb->map->num_types= req->firstType+req->nTypes;
+
+ for (i=0;i<req->nTypes;i++) {
+ XkbKeyTypePtr pOld;
+ register unsigned n;
+
+ if (XkbResizeKeyType(xkb,i+req->firstType,wire->nMapEntries,
+ wire->preserve,wire->numLevels)!=Success) {
+ return NULL;
+ }
+ pOld = &xkb->map->types[i+req->firstType];
+ map = (CARD8 *)&wire[1];
+
+ pOld->mods.real_mods = wire->realMods;
+ pOld->mods.vmods= wire->virtualMods;
+ pOld->num_levels = wire->numLevels;
+ pOld->map_count= wire->nMapEntries;
+
+ pOld->mods.mask= pOld->mods.real_mods|
+ XkbMaskForVMask(xkb,pOld->mods.vmods);
+
+ if (wire->nMapEntries) {
+ xkbKTSetMapEntryWireDesc *mapWire;
+ xkbModsWireDesc *preWire;
+ unsigned tmp;
+ mapWire= (xkbKTSetMapEntryWireDesc *)map;
+ preWire= (xkbModsWireDesc *)&mapWire[wire->nMapEntries];
+ for (n=0;n<wire->nMapEntries;n++) {
+ pOld->map[n].active= 1;
+ pOld->map[n].mods.mask= mapWire[n].realMods;
+ pOld->map[n].mods.real_mods= mapWire[n].realMods;
+ pOld->map[n].mods.vmods= mapWire[n].virtualMods;
+ pOld->map[n].level= mapWire[n].level;
+ if (mapWire[n].virtualMods!=0) {
+ tmp= XkbMaskForVMask(xkb,mapWire[n].virtualMods);
+ pOld->map[n].active= (tmp!=0);
+ pOld->map[n].mods.mask|= tmp;
+ }
+ if (wire->preserve) {
+ pOld->preserve[n].real_mods= preWire[n].realMods;
+ pOld->preserve[n].vmods= preWire[n].virtualMods;
+ tmp= XkbMaskForVMask(xkb,preWire[n].virtualMods);
+ pOld->preserve[n].mask= preWire[n].realMods|tmp;
+ }
+ }
+ if (wire->preserve)
+ map= (CARD8 *)&preWire[wire->nMapEntries];
+ else map= (CARD8 *)&mapWire[wire->nMapEntries];
+ }
+ else map= (CARD8 *)&wire[1];
+ wire = (xkbKeyTypeWireDesc *)map;
+ }
+ first= req->firstType;
+ last= first+req->nTypes-1; /* last changed type */
+ if (changes->map.changed&XkbKeyTypesMask) {
+ int oldLast;
+ oldLast= changes->map.first_type+changes->map.num_types-1;
+ if (changes->map.first_type<first)
+ first= changes->map.first_type;
+ if (oldLast>last)
+ last= oldLast;
+ }
+ changes->map.changed|= XkbKeyTypesMask;
+ changes->map.first_type = first;
+ changes->map.num_types = (last-first)+1;
+ return (char *)wire;
+}
+
+static char *
+SetKeySyms( ClientPtr client,
+ XkbDescPtr xkb,
+ xkbSetMapReq * req,
+ xkbSymMapWireDesc * wire,
+ XkbChangesPtr changes,
+ DeviceIntPtr dev)
+{
+register unsigned i,s;
+XkbSymMapPtr oldMap;
+KeySym * newSyms;
+KeySym * pSyms;
+unsigned first,last;
+
+ oldMap = &xkb->map->key_sym_map[req->firstKeySym];
+ for (i=0;i<req->nKeySyms;i++,oldMap++) {
+ pSyms = (KeySym *)&wire[1];
+ if (wire->nSyms>0) {
+ newSyms = XkbResizeKeySyms(xkb,i+req->firstKeySym,wire->nSyms);
+ for (s=0;s<wire->nSyms;s++) {
+ newSyms[s]= pSyms[s];
+ }
+ if (client->swapped) {
+ int n;
+ for (s=0;s<wire->nSyms;s++) {
+ swapl(&newSyms[s],n);
+ }
+ }
+ }
+ oldMap->kt_index[0] = wire->ktIndex[0];
+ oldMap->kt_index[1] = wire->ktIndex[1];
+ oldMap->kt_index[2] = wire->ktIndex[2];
+ oldMap->kt_index[3] = wire->ktIndex[3];
+ oldMap->group_info = wire->groupInfo;
+ oldMap->width = wire->width;
+ wire= (xkbSymMapWireDesc *)&pSyms[wire->nSyms];
+ }
+ first= req->firstKeySym;
+ last= first+req->nKeySyms-1;
+ if (changes->map.changed&XkbKeySymsMask) {
+ int oldLast= (changes->map.first_key_sym+changes->map.num_key_syms-1);
+ if (changes->map.first_key_sym<first)
+ first= changes->map.first_key_sym;
+ if (oldLast>last)
+ last= oldLast;
+ }
+ changes->map.changed|= XkbKeySymsMask;
+ changes->map.first_key_sym = first;
+ changes->map.num_key_syms = (last-first+1);
+
+ s= 0;
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ if (XkbKeyNumGroups(xkb,i)>s)
+ s= XkbKeyNumGroups(xkb,i);
+ }
+ if (s!=xkb->ctrls->num_groups) {
+ xkbControlsNotify cn;
+ XkbControlsRec old;
+ cn.keycode= 0;
+ cn.eventType= 0;
+ cn.requestMajor= XkbReqCode;
+ cn.requestMinor= X_kbSetMap;
+ old= *xkb->ctrls;
+ xkb->ctrls->num_groups= s;
+ if (XkbComputeControlsNotify(dev,&old,xkb->ctrls,&cn,False))
+ XkbSendControlsNotify(dev,&cn);
+ }
+ return (char *)wire;
+}
+
+static char *
+SetKeyActions( XkbDescPtr xkb,
+ xkbSetMapReq * req,
+ CARD8 * wire,
+ XkbChangesPtr changes)
+{
+register unsigned i,first,last;
+CARD8 * nActs = wire;
+XkbAction * newActs;
+
+ wire+= XkbPaddedSize(req->nKeyActs);
+ for (i=0;i<req->nKeyActs;i++) {
+ if (nActs[i]==0)
+ xkb->server->key_acts[i+req->firstKeyAct]= 0;
+ else {
+ newActs= XkbResizeKeyActions(xkb,i+req->firstKeyAct,nActs[i]);
+ memcpy((char *)newActs,(char *)wire,
+ nActs[i]*SIZEOF(xkbActionWireDesc));
+ wire+= nActs[i]*SIZEOF(xkbActionWireDesc);
+ }
+ }
+ first= req->firstKeyAct;
+ last= (first+req->nKeyActs-1);
+ if (changes->map.changed&XkbKeyActionsMask) {
+ int oldLast;
+ oldLast= changes->map.first_key_act+changes->map.num_key_acts-1;
+ if (changes->map.first_key_act<first)
+ first= changes->map.first_key_act;
+ if (oldLast>last)
+ last= oldLast;
+ }
+ changes->map.changed|= XkbKeyActionsMask;
+ changes->map.first_key_act= first;
+ changes->map.num_key_acts= (last-first+1);
+ return (char *)wire;
+}
+
+static char *
+SetKeyBehaviors( XkbSrvInfoPtr xkbi,
+ xkbSetMapReq *req,
+ xkbBehaviorWireDesc *wire,
+ XkbChangesPtr changes)
+{
+register unsigned i;
+int maxRG = -1;
+XkbDescPtr xkb = xkbi->desc;
+XkbServerMapPtr server = xkb->server;
+unsigned first,last;
+
+ first= req->firstKeyBehavior;
+ last= req->firstKeyBehavior+req->nKeyBehaviors-1;
+ bzero(&server->behaviors[first],req->nKeyBehaviors*sizeof(XkbBehavior));
+ for (i=0;i<req->totalKeyBehaviors;i++) {
+ if ((server->behaviors[wire->key].type&XkbKB_Permanent)==0) {
+ server->behaviors[wire->key].type= wire->type;
+ server->behaviors[wire->key].data= wire->data;
+ if ((wire->type==XkbKB_RadioGroup)&&(((int)wire->data)>maxRG))
+ maxRG= wire->data + 1;
+ }
+ wire++;
+ }
+
+ if (maxRG>(int)xkbi->nRadioGroups) {
+ int sz = maxRG*sizeof(XkbRadioGroupRec);
+ if (xkbi->radioGroups)
+ xkbi->radioGroups=(XkbRadioGroupPtr)_XkbRealloc(xkbi->radioGroups,sz);
+ else xkbi->radioGroups= (XkbRadioGroupPtr)_XkbCalloc(1, sz);
+ if (xkbi->radioGroups) {
+ if (xkbi->nRadioGroups)
+ bzero(&xkbi->radioGroups[xkbi->nRadioGroups],
+ (maxRG-xkbi->nRadioGroups)*sizeof(XkbRadioGroupRec));
+ xkbi->nRadioGroups= maxRG;
+ }
+ else xkbi->nRadioGroups= 0;
+ /* should compute members here */
+ }
+ if (changes->map.changed&XkbKeyBehaviorsMask) {
+ unsigned oldLast;
+ oldLast= changes->map.first_key_behavior+
+ changes->map.num_key_behaviors-1;
+ if (changes->map.first_key_behavior<req->firstKeyBehavior)
+ first= changes->map.first_key_behavior;
+ if (oldLast>last)
+ last= oldLast;
+ }
+ changes->map.changed|= XkbKeyBehaviorsMask;
+ changes->map.first_key_behavior = first;
+ changes->map.num_key_behaviors = (last-first+1);
+ return (char *)wire;
+}
+
+static char *
+SetVirtualMods(XkbSrvInfoPtr xkbi,xkbSetMapReq *req,CARD8 *wire,
+ XkbChangesPtr changes)
+{
+register int i,bit,nMods;
+XkbServerMapPtr srv = xkbi->desc->server;
+
+ if (((req->present&XkbVirtualModsMask)==0)||(req->virtualMods==0))
+ return (char *)wire;
+ for (i=nMods=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (req->virtualMods&bit) {
+ if (srv->vmods[i]!=wire[nMods]) {
+ changes->map.changed|= XkbVirtualModsMask;
+ changes->map.vmods|= bit;
+ srv->vmods[i]= wire[nMods];
+ }
+ nMods++;
+ }
+ }
+ return (char *)(wire+XkbPaddedSize(nMods));
+}
+
+static char *
+SetKeyExplicit(XkbSrvInfoPtr xkbi,xkbSetMapReq *req,CARD8 *wire,
+ XkbChangesPtr changes)
+{
+register unsigned i,first,last;
+XkbServerMapPtr xkb = xkbi->desc->server;
+CARD8 * start;
+
+ start= wire;
+ first= req->firstKeyExplicit;
+ last= req->firstKeyExplicit+req->nKeyExplicit-1;
+ bzero(&xkb->explicit[first],req->nKeyExplicit);
+ for (i=0;i<req->totalKeyExplicit;i++,wire+= 2) {
+ xkb->explicit[wire[0]]= wire[1];
+ }
+ if (first>0) {
+ if (changes->map.changed&XkbExplicitComponentsMask) {
+ int oldLast;
+ oldLast= changes->map.first_key_explicit+
+ changes->map.num_key_explicit-1;
+ if (changes->map.first_key_explicit<first)
+ first= changes->map.first_key_explicit;
+ if (oldLast>last)
+ last= oldLast;
+ }
+ changes->map.first_key_explicit= first;
+ changes->map.num_key_explicit= (last-first)+1;
+ }
+ wire+= XkbPaddedSize(wire-start)-(wire-start);
+ return (char *)wire;
+}
+
+static char *
+SetModifierMap( XkbSrvInfoPtr xkbi,
+ xkbSetMapReq * req,
+ CARD8 * wire,
+ XkbChangesPtr changes)
+{
+register unsigned i,first,last;
+XkbClientMapPtr xkb = xkbi->desc->map;
+CARD8 * start;
+
+ start= wire;
+ first= req->firstModMapKey;
+ last= req->firstModMapKey+req->nModMapKeys-1;
+ bzero(&xkb->modmap[first],req->nModMapKeys);
+ for (i=0;i<req->totalModMapKeys;i++,wire+= 2) {
+ xkb->modmap[wire[0]]= wire[1];
+ }
+ if (first>0) {
+ if (changes->map.changed&XkbModifierMapMask) {
+ int oldLast;
+ oldLast= changes->map.first_modmap_key+
+ changes->map.num_modmap_keys-1;
+ if (changes->map.first_modmap_key<first)
+ first= changes->map.first_modmap_key;
+ if (oldLast>last)
+ last= oldLast;
+ }
+ changes->map.first_modmap_key= first;
+ changes->map.num_modmap_keys= (last-first)+1;
+ }
+ wire+= XkbPaddedSize(wire-start)-(wire-start);
+ return (char *)wire;
+}
+
+static char *
+SetVirtualModMap( XkbSrvInfoPtr xkbi,
+ xkbSetMapReq * req,
+ xkbVModMapWireDesc * wire,
+ XkbChangesPtr changes)
+{
+register unsigned i,first,last;
+XkbServerMapPtr srv = xkbi->desc->server;
+
+ first= req->firstVModMapKey;
+ last= req->firstVModMapKey+req->nVModMapKeys-1;
+ bzero(&srv->vmodmap[first],req->nVModMapKeys*sizeof(unsigned short));
+ for (i=0;i<req->totalVModMapKeys;i++,wire++) {
+ srv->vmodmap[wire->key]= wire->vmods;
+ }
+ if (first>0) {
+ if (changes->map.changed&XkbVirtualModMapMask) {
+ int oldLast;
+ oldLast= changes->map.first_vmodmap_key+
+ changes->map.num_vmodmap_keys-1;
+ if (changes->map.first_vmodmap_key<first)
+ first= changes->map.first_vmodmap_key;
+ if (oldLast>last)
+ last= oldLast;
+ }
+ changes->map.first_vmodmap_key= first;
+ changes->map.num_vmodmap_keys= (last-first)+1;
+ }
+ return (char *)wire;
+}
+
+int
+ProcXkbSetMap(ClientPtr client)
+{
+ DeviceIntPtr dev;
+ XkbSrvInfoPtr xkbi;
+ XkbDescPtr xkb;
+ XkbChangesRec change;
+ XkbEventCauseRec cause;
+ int nTypes,nActions,error;
+ char * tmp;
+ CARD8 mapWidths[XkbMaxLegalKeyCode+1];
+ CARD16 symsPerKey[XkbMaxLegalKeyCode+1];
+ Bool sentNKN;
+
+ REQUEST(xkbSetMapReq);
+ REQUEST_AT_LEAST_SIZE(xkbSetMapReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_MASK_LEGAL(0x01,stuff->present,XkbAllMapComponentsMask);
+
+ XkbSetCauseXkbReq(&cause,X_kbSetMap,client);
+ xkbi= dev->key->xkbInfo;
+ xkb = xkbi->desc;
+
+ if ((xkb->min_key_code!=stuff->minKeyCode)||
+ (xkb->max_key_code!=stuff->maxKeyCode)) {
+ if (client->vMajor!=1) { /* pre 1.0 versions of Xlib have a bug */
+ stuff->minKeyCode= xkb->min_key_code;
+ stuff->maxKeyCode= xkb->max_key_code;
+ }
+ else {
+ if (!XkbIsLegalKeycode(stuff->minKeyCode)) {
+ client->errorValue= _XkbErrCode3(2,stuff->minKeyCode,
+ stuff->maxKeyCode);
+ return BadValue;
+ }
+ if (stuff->minKeyCode>stuff->maxKeyCode) {
+ client->errorValue= _XkbErrCode3(3,stuff->minKeyCode,
+ stuff->maxKeyCode);
+ return BadMatch;
+ }
+ }
+ }
+
+ tmp = (char *)&stuff[1];
+ if ((stuff->present&XkbKeyTypesMask)&&
+ (!CheckKeyTypes(client,xkb,stuff,(xkbKeyTypeWireDesc **)&tmp,
+ &nTypes,mapWidths))) {
+ client->errorValue = nTypes;
+ return BadValue;
+ }
+ if ((stuff->present&XkbKeySymsMask)&&
+ (!CheckKeySyms(client,xkb,stuff,nTypes,mapWidths,symsPerKey,
+ (xkbSymMapWireDesc **)&tmp,&error))) {
+ client->errorValue = error;
+ return BadValue;
+ }
+
+ if ((stuff->present&XkbKeyActionsMask)&&
+ (!CheckKeyActions(xkb,stuff,nTypes,mapWidths,symsPerKey,
+ (CARD8 **)&tmp,&nActions))) {
+ client->errorValue = nActions;
+ return BadValue;
+ }
+
+ if ((stuff->present&XkbKeyBehaviorsMask)&&
+ (!CheckKeyBehaviors(xkb,stuff,(xkbBehaviorWireDesc**)&tmp,&error))) {
+ client->errorValue = error;
+ return BadValue;
+ }
+
+ if ((stuff->present&XkbVirtualModsMask)&&
+ (!CheckVirtualMods(xkb,stuff,(CARD8 **)&tmp,&error))) {
+ client->errorValue= error;
+ return BadValue;
+ }
+ if ((stuff->present&XkbExplicitComponentsMask)&&
+ (!CheckKeyExplicit(xkb,stuff,(CARD8 **)&tmp,&error))) {
+ client->errorValue= error;
+ return BadValue;
+ }
+ if ((stuff->present&XkbModifierMapMask)&&
+ (!CheckModifierMap(xkb,stuff,(CARD8 **)&tmp,&error))) {
+ client->errorValue= error;
+ return BadValue;
+ }
+ if ((stuff->present&XkbVirtualModMapMask)&&
+ (!CheckVirtualModMap(xkb,stuff,(xkbVModMapWireDesc **)&tmp,&error))) {
+ client->errorValue= error;
+ return BadValue;
+ }
+ if (((tmp-((char *)stuff))/4)!=stuff->length) {
+ ErrorF("Internal error! Bad length in XkbSetMap (after check)\n");
+ client->errorValue = tmp-((char *)&stuff[1]);
+ return BadLength;
+ }
+ bzero(&change,sizeof(change));
+ sentNKN= False;
+ if ((xkb->min_key_code!=stuff->minKeyCode)||
+ (xkb->max_key_code!=stuff->maxKeyCode)) {
+ Status status;
+ xkbNewKeyboardNotify nkn;
+ nkn.deviceID= nkn.oldDeviceID= dev->id;
+ nkn.oldMinKeyCode= xkb->min_key_code;
+ nkn.oldMaxKeyCode= xkb->max_key_code;
+ status= XkbChangeKeycodeRange(xkb,stuff->minKeyCode,stuff->maxKeyCode,
+ &change);
+ if (status!=Success)
+ return status;
+ nkn.minKeyCode= xkb->min_key_code;
+ nkn.maxKeyCode= xkb->max_key_code;
+ nkn.requestMajor= XkbReqCode;
+ nkn.requestMinor= X_kbSetMap;
+ nkn.changed= XkbNKN_KeycodesMask;
+ XkbSendNewKeyboardNotify(dev,&nkn);
+ sentNKN= True;
+ }
+ tmp = (char *)&stuff[1];
+ if (stuff->present&XkbKeyTypesMask) {
+ tmp = SetKeyTypes(xkb,stuff,(xkbKeyTypeWireDesc *)tmp,&change);
+ if (!tmp) goto allocFailure;
+ }
+ if (stuff->present&XkbKeySymsMask) {
+ tmp = SetKeySyms(client,xkb,stuff,(xkbSymMapWireDesc *)tmp,&change,dev);
+ if (!tmp) goto allocFailure;
+ }
+ if (stuff->present&XkbKeyActionsMask) {
+ tmp = SetKeyActions(xkb,stuff,(CARD8 *)tmp,&change);
+ if (!tmp) goto allocFailure;
+ }
+ if (stuff->present&XkbKeyBehaviorsMask) {
+ tmp= SetKeyBehaviors(xkbi,stuff,(xkbBehaviorWireDesc *)tmp,&change);
+ if (!tmp) goto allocFailure;
+ }
+ if (stuff->present&XkbVirtualModsMask)
+ tmp= SetVirtualMods(xkbi,stuff,(CARD8 *)tmp,&change);
+ if (stuff->present&XkbExplicitComponentsMask)
+ tmp= SetKeyExplicit(xkbi,stuff,(CARD8 *)tmp,&change);
+ if (stuff->present&XkbModifierMapMask)
+ tmp= SetModifierMap(xkbi,stuff,(CARD8 *)tmp,&change);
+ if (stuff->present&XkbVirtualModMapMask)
+ tmp= SetVirtualModMap(xkbi,stuff,(xkbVModMapWireDesc *)tmp,&change);
+ if (((tmp-((char *)stuff))/4)!=stuff->length) {
+ ErrorF("Internal error! Bad length in XkbSetMap (after set)\n");
+ client->errorValue = tmp-((char *)&stuff[1]);
+ return BadLength;
+ }
+ if (stuff->flags&XkbSetMapRecomputeActions) {
+ KeyCode first,last,firstMM,lastMM;
+ if (change.map.num_key_syms>0) {
+ first= change.map.first_key_sym;
+ last= first+change.map.num_key_syms-1;
+ }
+ else first= last= 0;
+ if (change.map.num_modmap_keys>0) {
+ firstMM= change.map.first_modmap_key;
+ lastMM= first+change.map.num_modmap_keys-1;
+ }
+ else firstMM= lastMM= 0;
+ if ((last>0) && (lastMM>0)) {
+ if (firstMM<first)
+ first= firstMM;
+ if (lastMM>last)
+ last= lastMM;
+ }
+ else if (lastMM>0) {
+ first= firstMM;
+ last= lastMM;
+ }
+ if (last>0) {
+ unsigned check= 0;
+ XkbUpdateActions(dev,first,(last-first+1),&change,&check,&cause);
+ if (check)
+ XkbCheckSecondaryEffects(xkbi,check,&change,&cause);
+ }
+ }
+ if (!sentNKN)
+ XkbSendNotification(dev,&change,&cause);
+
+ XkbUpdateCoreDescription(dev,False);
+ return client->noClientException;
+allocFailure:
+ return BadAlloc;
+}
+
+/***====================================================================***/
+
+static Status
+XkbComputeGetCompatMapReplySize( XkbCompatMapPtr compat,
+ xkbGetCompatMapReply * rep)
+{
+unsigned size,nGroups;
+
+ nGroups= 0;
+ if (rep->groups!=0) {
+ register int i,bit;
+ for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
+ if (rep->groups&bit)
+ nGroups++;
+ }
+ }
+ size= nGroups*SIZEOF(xkbModsWireDesc);
+ size+= (rep->nSI*SIZEOF(xkbSymInterpretWireDesc));
+ rep->length= size/4;
+ return Success;
+}
+
+static int
+XkbSendCompatMap( ClientPtr client,
+ XkbCompatMapPtr compat,
+ xkbGetCompatMapReply * rep)
+{
+char * data;
+int size;
+
+ size= rep->length*4;
+ if (size>0) {
+ data = (char *)ALLOCATE_LOCAL(size);
+ if (data) {
+ register unsigned i,bit;
+ xkbModsWireDesc * grp;
+ XkbSymInterpretPtr sym= &compat->sym_interpret[rep->firstSI];
+ xkbSymInterpretWireDesc *wire = (xkbSymInterpretWireDesc *)data;
+ for (i=0;i<rep->nSI;i++,sym++,wire++) {
+ wire->sym= sym->sym;
+ wire->mods= sym->mods;
+ wire->match= sym->match;
+ wire->virtualMod= sym->virtual_mod;
+ wire->flags= sym->flags;
+ memcpy((char*)&wire->act,(char*)&sym->act,sz_xkbActionWireDesc);
+ if (client->swapped) {
+ register int n;
+ swapl(&wire->sym,n);
+ }
+ }
+ if (rep->groups) {
+ grp = (xkbModsWireDesc *)wire;
+ for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
+ if (rep->groups&bit) {
+ grp->mask= compat->groups[i].mask;
+ grp->realMods= compat->groups[i].real_mods;
+ grp->virtualMods= compat->groups[i].vmods;
+ if (client->swapped) {
+ register int n;
+ swaps(&grp->virtualMods,n);
+ }
+ grp++;
+ }
+ }
+ wire= (xkbSymInterpretWireDesc*)grp;
+ }
+ }
+ else return BadAlloc;
+ }
+ else data= NULL;
+
+ if (client->swapped) {
+ register int n;
+ swaps(&rep->sequenceNumber,n);
+ swapl(&rep->length,n);
+ swaps(&rep->firstSI,n);
+ swaps(&rep->nSI,n);
+ swaps(&rep->nTotalSI,n);
+ }
+
+ WriteToClient(client, SIZEOF(xkbGetCompatMapReply), (char *)rep);
+ if (data) {
+ WriteToClient(client, size, data);
+ DEALLOCATE_LOCAL((char *)data);
+ }
+ return client->noClientException;
+}
+
+int
+ProcXkbGetCompatMap(ClientPtr client)
+{
+ xkbGetCompatMapReply rep;
+ DeviceIntPtr dev;
+ XkbDescPtr xkb;
+ XkbCompatMapPtr compat;
+
+ REQUEST(xkbGetCompatMapReq);
+ REQUEST_SIZE_MATCH(xkbGetCompatMapReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+
+ xkb = dev->key->xkbInfo->desc;
+ compat= xkb->compat;
+
+ rep.type = X_Reply;
+ rep.deviceID = dev->id;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.firstSI = stuff->firstSI;
+ rep.nSI = stuff->nSI;
+ if (stuff->getAllSI) {
+ rep.firstSI = 0;
+ rep.nSI = compat->num_si;
+ }
+ else if ((((unsigned)stuff->nSI)>0)&&
+ ((unsigned)(stuff->firstSI+stuff->nSI-1)>=compat->num_si)) {
+ client->errorValue = _XkbErrCode2(0x05,compat->num_si);
+ return BadValue;
+ }
+ rep.nTotalSI = compat->num_si;
+ rep.groups= stuff->groups;
+ XkbComputeGetCompatMapReplySize(compat,&rep);
+ return XkbSendCompatMap(client,compat,&rep);
+}
+
+int
+ProcXkbSetCompatMap(ClientPtr client)
+{
+ DeviceIntPtr dev;
+ XkbSrvInfoPtr xkbi;
+ XkbDescPtr xkb;
+ XkbCompatMapPtr compat;
+ char * data;
+ int nGroups;
+ register unsigned i,bit;
+
+ REQUEST(xkbSetCompatMapReq);
+ REQUEST_AT_LEAST_SIZE(xkbSetCompatMapReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+
+ data = (char *)&stuff[1];
+ xkbi = dev->key->xkbInfo;
+ xkb= xkbi->desc;
+ compat= xkb->compat;
+ if ((stuff->nSI>0)||(stuff->truncateSI)) {
+ xkbSymInterpretWireDesc *wire;
+ if (stuff->firstSI>compat->num_si) {
+ client->errorValue = _XkbErrCode2(0x02,compat->num_si);
+ return BadValue;
+ }
+ wire= (xkbSymInterpretWireDesc *)data;
+ wire+= stuff->nSI;
+ data = (char *)wire;
+ }
+ nGroups= 0;
+ if (stuff->groups!=0) {
+ for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
+ if ( stuff->groups&bit )
+ nGroups++;
+ }
+ }
+ data+= nGroups*SIZEOF(xkbModsWireDesc);
+ if (((data-((char *)stuff))/4)!=stuff->length) {
+ return BadLength;
+ }
+ data = (char *)&stuff[1];
+ if (stuff->nSI>0) {
+ xkbSymInterpretWireDesc *wire = (xkbSymInterpretWireDesc *)data;
+ XkbSymInterpretPtr sym;
+ if ((unsigned)(stuff->firstSI+stuff->nSI)>compat->num_si) {
+ compat->num_si= stuff->firstSI+stuff->nSI;
+ compat->sym_interpret= _XkbTypedRealloc(compat->sym_interpret,
+ compat->num_si,
+ XkbSymInterpretRec);
+ if (!compat->sym_interpret) {
+ compat->num_si= 0;
+ return BadAlloc;
+ }
+ }
+ else if (stuff->truncateSI) {
+ compat->num_si = stuff->firstSI+stuff->nSI;
+ }
+ sym = &compat->sym_interpret[stuff->firstSI];
+ for (i=0;i<stuff->nSI;i++,wire++,sym++) {
+ if (client->swapped) {
+ register int n;
+ swapl(&wire->sym,n);
+ }
+ sym->sym= wire->sym;
+ sym->mods= wire->mods;
+ sym->match= wire->match;
+ sym->flags= wire->flags;
+ sym->virtual_mod= wire->virtualMod;
+ memcpy((char *)&sym->act,(char *)&wire->act,
+ SIZEOF(xkbActionWireDesc));
+ }
+ data = (char *)wire;
+ }
+ else if (stuff->truncateSI) {
+ compat->num_si = stuff->firstSI;
+ }
+
+ if (stuff->groups!=0) {
+ register unsigned i,bit;
+ xkbModsWireDesc *wire = (xkbModsWireDesc *)data;
+ for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
+ if (stuff->groups&bit) {
+ if (client->swapped) {
+ register int n;
+ swaps(&wire->virtualMods,n);
+ }
+ compat->groups[i].mask= wire->realMods;
+ compat->groups[i].real_mods= wire->realMods;
+ compat->groups[i].vmods= wire->virtualMods;
+ if (wire->virtualMods!=0) {
+ unsigned tmp;
+ tmp= XkbMaskForVMask(xkb,wire->virtualMods);
+ compat->groups[i].mask|= tmp;
+ }
+ data+= SIZEOF(xkbModsWireDesc);
+ wire= (xkbModsWireDesc *)data;
+ }
+ }
+ }
+ i= XkbPaddedSize((data-((char *)stuff)));
+ if ((i/4)!=stuff->length) {
+ ErrorF("Internal length error on read in ProcXkbSetCompatMap\n");
+ return BadLength;
+ }
+
+ if (dev->xkb_interest) {
+ xkbCompatMapNotify ev;
+ ev.deviceID = dev->id;
+ ev.changedGroups = stuff->groups;
+ ev.firstSI = stuff->firstSI;
+ ev.nSI = stuff->nSI;
+ ev.nTotalSI = compat->num_si;
+ XkbSendCompatMapNotify(dev,&ev);
+ }
+
+ if (stuff->recomputeActions) {
+ XkbChangesRec change;
+ unsigned check;
+ XkbEventCauseRec cause;
+
+ XkbSetCauseXkbReq(&cause,X_kbSetCompatMap,client);
+ bzero(&change,sizeof(XkbChangesRec));
+ XkbUpdateActions(dev,xkb->min_key_code,XkbNumKeys(xkb),&change,&check,
+ &cause);
+ if (check)
+ XkbCheckSecondaryEffects(xkbi,check,&change,&cause);
+ XkbUpdateCoreDescription(dev,False);
+ XkbSendNotification(dev,&change,&cause);
+ }
+ return client->noClientException;
+}
+
+/***====================================================================***/
+
+int
+ProcXkbGetIndicatorState(ClientPtr client)
+{
+ xkbGetIndicatorStateReply rep;
+ XkbSrvLedInfoPtr sli;
+ DeviceIntPtr dev;
+ register int i;
+
+ REQUEST(xkbGetIndicatorStateReq);
+ REQUEST_SIZE_MATCH(xkbGetIndicatorStateReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,
+ XkbXI_IndicatorStateMask);
+ if (!sli)
+ return BadAlloc;
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.deviceID = dev->id;
+ rep.state = sli->effectiveState;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber,i);
+ swapl(&rep.state,i);
+ }
+ WriteToClient(client, SIZEOF(xkbGetIndicatorStateReply), (char *)&rep);
+ return client->noClientException;
+}
+
+/***====================================================================***/
+
+Status
+XkbComputeGetIndicatorMapReplySize(
+ XkbIndicatorPtr indicators,
+ xkbGetIndicatorMapReply *rep)
+{
+register int i,bit;
+int nIndicators;
+
+ rep->realIndicators = indicators->phys_indicators;
+ for (i=nIndicators=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (rep->which&bit)
+ nIndicators++;
+ }
+ rep->length = (nIndicators*SIZEOF(xkbIndicatorMapWireDesc))/4;
+ return Success;
+}
+
+int
+XkbSendIndicatorMap( ClientPtr client,
+ XkbIndicatorPtr indicators,
+ xkbGetIndicatorMapReply * rep)
+{
+int length;
+CARD8 * map;
+register int i;
+register unsigned bit;
+
+ length = rep->length*4;
+ if (length>0) {
+ CARD8 *to;
+ to= map= (CARD8 *)ALLOCATE_LOCAL(length);
+ if (map) {
+ xkbIndicatorMapWireDesc *wire = (xkbIndicatorMapWireDesc *)to;
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (rep->which&bit) {
+ wire->flags= indicators->maps[i].flags;
+ wire->whichGroups= indicators->maps[i].which_groups;
+ wire->groups= indicators->maps[i].groups;
+ wire->whichMods= indicators->maps[i].which_mods;
+ wire->mods= indicators->maps[i].mods.mask;
+ wire->realMods= indicators->maps[i].mods.real_mods;
+ wire->virtualMods= indicators->maps[i].mods.vmods;
+ wire->ctrls= indicators->maps[i].ctrls;
+ if (client->swapped) {
+ register int n;
+ swaps(&wire->virtualMods,n);
+ swapl(&wire->ctrls,n);
+ }
+ wire++;
+ }
+ }
+ to = (CARD8 *)wire;
+ if ((to-map)!=length) {
+ client->errorValue = _XkbErrCode2(0xff,length);
+ return BadLength;
+ }
+ }
+ else return BadAlloc;
+ }
+ else map = NULL;
+ if (client->swapped) {
+ swaps(&rep->sequenceNumber,i);
+ swapl(&rep->length,i);
+ swapl(&rep->which,i);
+ swapl(&rep->realIndicators,i);
+ }
+ WriteToClient(client, SIZEOF(xkbGetIndicatorMapReply), (char *)rep);
+ if (map) {
+ WriteToClient(client, length, (char *)map);
+ DEALLOCATE_LOCAL((char *)map);
+ }
+ return client->noClientException;
+}
+
+int
+ProcXkbGetIndicatorMap(ClientPtr client)
+{
+xkbGetIndicatorMapReply rep;
+DeviceIntPtr dev;
+XkbDescPtr xkb;
+XkbIndicatorPtr leds;
+
+ REQUEST(xkbGetIndicatorMapReq);
+ REQUEST_SIZE_MATCH(xkbGetIndicatorMapReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+
+ xkb= dev->key->xkbInfo->desc;
+ leds= xkb->indicators;
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.deviceID = dev->id;
+ rep.which = stuff->which;
+ XkbComputeGetIndicatorMapReplySize(leds,&rep);
+ return XkbSendIndicatorMap(client,leds,&rep);
+}
+
+int
+ProcXkbSetIndicatorMap(ClientPtr client)
+{
+ register int i,bit;
+ int nIndicators,why;
+ DeviceIntPtr dev;
+ XkbSrvInfoPtr xkbi;
+ xkbIndicatorMapWireDesc *from;
+ XkbSrvLedInfoPtr sli;
+ XkbEventCauseRec cause;
+
+ REQUEST(xkbSetIndicatorMapReq);
+ REQUEST_AT_LEAST_SIZE(xkbSetIndicatorMapReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ dev = _XkbLookupKeyboard(stuff->deviceSpec,&why);
+ if (!dev) {
+ client->errorValue = _XkbErrCode2(why,stuff->deviceSpec);
+ return XkbKeyboardErrorCode;
+ }
+ xkbi= dev->key->xkbInfo;
+
+ if (stuff->which==0)
+ return client->noClientException;
+
+ for (nIndicators=i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (stuff->which&bit)
+ nIndicators++;
+ }
+ if (stuff->length!=((SIZEOF(xkbSetIndicatorMapReq)+
+ (nIndicators*SIZEOF(xkbIndicatorMapWireDesc)))/4)) {
+ return BadLength;
+ }
+
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,
+ XkbXI_IndicatorMapsMask);
+ if (!sli)
+ return BadAlloc;
+
+ from = (xkbIndicatorMapWireDesc *)&stuff[1];
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (stuff->which&bit) {
+ if (client->swapped) {
+ register int n;
+ swaps(&from->virtualMods,n);
+ swapl(&from->ctrls,n);
+ }
+ CHK_MASK_LEGAL(i,from->whichGroups,XkbIM_UseAnyGroup);
+ CHK_MASK_LEGAL(i,from->whichMods,XkbIM_UseAnyMods);
+ from++;
+ }
+ }
+
+ from = (xkbIndicatorMapWireDesc *)&stuff[1];
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (stuff->which&bit) {
+ sli->maps[i].flags = from->flags;
+ sli->maps[i].which_groups = from->whichGroups;
+ sli->maps[i].groups = from->groups;
+ sli->maps[i].which_mods = from->whichMods;
+ sli->maps[i].mods.mask = from->mods;
+ sli->maps[i].mods.real_mods = from->mods;
+ sli->maps[i].mods.vmods= from->virtualMods;
+ sli->maps[i].ctrls = from->ctrls;
+ if (from->virtualMods!=0) {
+ unsigned tmp;
+ tmp= XkbMaskForVMask(xkbi->desc,from->virtualMods);
+ sli->maps[i].mods.mask= from->mods|tmp;
+ }
+ from++;
+ }
+ }
+
+ XkbSetCauseXkbReq(&cause,X_kbSetIndicatorMap,client);
+ XkbApplyLedMapChanges(dev,sli,stuff->which,NULL,NULL,&cause);
+ return client->noClientException;
+}
+
+/***====================================================================***/
+
+int
+ProcXkbGetNamedIndicator(ClientPtr client)
+{
+ DeviceIntPtr dev;
+ xkbGetNamedIndicatorReply rep;
+ register int i = 0;
+ XkbSrvLedInfoPtr sli;
+ XkbIndicatorMapPtr map = NULL;
+ Bool supported;
+
+ REQUEST(xkbGetNamedIndicatorReq);
+ REQUEST_SIZE_MATCH(xkbGetNamedIndicatorReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_LED_DEVICE(dev,stuff->deviceSpec);
+ CHK_ATOM_ONLY(stuff->indicator);
+
+ sli= XkbFindSrvLedInfo(dev,stuff->ledClass,stuff->ledID,0);
+ if (!sli)
+ return BadAlloc;
+
+ supported= True;
+ if (XkbXIUnsupported&XkbXI_IndicatorsMask) {
+ if ((dev!=(DeviceIntPtr)LookupKeyboardDevice())||
+ ((sli->flags&XkbSLI_IsDefault)==0)) {
+ supported= False;
+ }
+ }
+
+ if (supported) {
+ i= 0;
+ map= NULL;
+ if ((sli->names)&&(sli->maps)) {
+ for (i=0;i<XkbNumIndicators;i++) {
+ if (stuff->indicator==sli->names[i]) {
+ map= &sli->maps[i];
+ break;
+ }
+ }
+ }
+ }
+
+ rep.type= X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.deviceID = dev->id;
+ rep.indicator= stuff->indicator;
+ if ((map!=NULL)&&(supported)) {
+ rep.found= True;
+ rep.on= ((sli->effectiveState&(1<<i))!=0);
+ rep.realIndicator= ((sli->physIndicators&(1<<i))!=0);
+ rep.ndx= i;
+ rep.flags= map->flags;
+ rep.whichGroups= map->which_groups;
+ rep.groups= map->groups;
+ rep.whichMods= map->which_mods;
+ rep.mods= map->mods.mask;
+ rep.realMods= map->mods.real_mods;
+ rep.virtualMods= map->mods.vmods;
+ rep.ctrls= map->ctrls;
+ rep.supported= True;
+ }
+ else {
+ rep.found= False;
+ rep.on= False;
+ rep.realIndicator= False;
+ rep.ndx= XkbNoIndicator;
+ rep.flags= 0;
+ rep.whichGroups= 0;
+ rep.groups= 0;
+ rep.whichMods= 0;
+ rep.mods= 0;
+ rep.realMods= 0;
+ rep.virtualMods= 0;
+ rep.ctrls= 0;
+ rep.supported= supported;
+ }
+ if ( client->swapped ) {
+ register int n;
+ swapl(&rep.length,n);
+ swaps(&rep.sequenceNumber,n);
+ swapl(&rep.indicator,n);
+ swaps(&rep.virtualMods,n);
+ swapl(&rep.ctrls,n);
+ }
+
+ WriteToClient(client,SIZEOF(xkbGetNamedIndicatorReply), (char *)&rep);
+ if (!supported) {
+ xkbExtensionDeviceNotify edev;
+
+ bzero(&edev,sizeof(xkbExtensionDeviceNotify));
+ edev.reason= XkbXI_UnsupportedFeatureMask;
+ edev.ledClass= stuff->ledClass;
+ edev.ledID= stuff->ledID;
+ edev.ledsDefined= sli->namesPresent|sli->mapsPresent;
+ edev.ledState= sli->effectiveState;
+ edev.firstBtn= 0;
+ edev.nBtns= 0;
+ edev.unsupported= XkbXIUnsupported&XkbXI_IndicatorsMask;
+ edev.supported= XkbXI_AllFeaturesMask&(~XkbXIUnsupported);
+ XkbSendExtensionDeviceNotify(dev,client,&edev);
+ }
+ return client->noClientException;
+}
+
+int
+ProcXkbSetNamedIndicator(ClientPtr client)
+{
+ DeviceIntPtr dev,kbd;
+ XkbIndicatorMapPtr map;
+ XkbSrvLedInfoPtr sli;
+ register int led = 0;
+ unsigned extDevReason;
+ unsigned statec,namec,mapc;
+ XkbEventCauseRec cause;
+ xkbExtensionDeviceNotify ed;
+ XkbChangesRec changes;
+
+ REQUEST(xkbSetNamedIndicatorReq);
+ REQUEST_SIZE_MATCH(xkbSetNamedIndicatorReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_LED_DEVICE(dev,stuff->deviceSpec);
+ CHK_ATOM_ONLY(stuff->indicator);
+ CHK_MASK_LEGAL(0x10,stuff->whichGroups,XkbIM_UseAnyGroup);
+ CHK_MASK_LEGAL(0x11,stuff->whichMods,XkbIM_UseAnyMods);
+
+ extDevReason= 0;
+
+ sli= XkbFindSrvLedInfo(dev,stuff->ledClass,stuff->ledID,
+ XkbXI_IndicatorsMask);
+ if (!sli)
+ return BadAlloc;
+
+ if (XkbXIUnsupported&XkbXI_IndicatorsMask) {
+ if ((dev!=(DeviceIntPtr)LookupKeyboardDevice())||
+ ((sli->flags&XkbSLI_IsDefault)==0)) {
+ bzero(&ed,sizeof(xkbExtensionDeviceNotify));
+ ed.reason= XkbXI_UnsupportedFeatureMask;
+ ed.ledClass= stuff->ledClass;
+ ed.ledID= stuff->ledID;
+ ed.ledsDefined= sli->namesPresent|sli->mapsPresent;
+ ed.ledState= sli->effectiveState;
+ ed.firstBtn= 0;
+ ed.nBtns= 0;
+ ed.unsupported= XkbXIUnsupported&XkbXI_IndicatorsMask;
+ ed.supported= XkbXI_AllFeaturesMask&(~XkbXIUnsupported);
+ XkbSendExtensionDeviceNotify(dev,client,&ed);
+ return client->noClientException;
+ }
+ }
+
+ statec= mapc= namec= 0;
+ map= NULL;
+ if (sli->names && sli->maps) {
+ for (led=0;(led<XkbNumIndicators)&&(map==NULL);led++) {
+ if (sli->names[led]==stuff->indicator) {
+ map= &sli->maps[led];
+ break;
+ }
+ }
+ }
+ if (map==NULL) {
+ if (!stuff->createMap)
+ return client->noClientException;
+ for (led=0,map=NULL;(led<XkbNumIndicators)&&(map==NULL);led++) {
+ if ((sli->names[led]==None)&&(!XkbIM_InUse(&sli->maps[led]))) {
+ map= &sli->maps[led];
+ sli->names[led]= stuff->indicator;
+ break;
+ }
+ }
+ if (map==NULL)
+ return client->noClientException;
+ namec|= (1<<led);
+ sli->namesPresent|= ((stuff->indicator!=None)?(1<<led):0);
+ extDevReason|= XkbXI_IndicatorNamesMask;
+ }
+
+ if (stuff->setMap) {
+ map->flags = stuff->flags;
+ map->which_groups = stuff->whichGroups;
+ map->groups = stuff->groups;
+ map->which_mods = stuff->whichMods;
+ map->mods.mask = stuff->realMods;
+ map->mods.real_mods = stuff->realMods;
+ map->mods.vmods= stuff->virtualMods;
+ map->ctrls = stuff->ctrls;
+ mapc|= (1<<led);
+ }
+ if ((stuff->setState)&&((map->flags&XkbIM_NoExplicit)==0)) {
+ if (stuff->on) sli->explicitState|= (1<<led);
+ else sli->explicitState&= ~(1<<led);
+ statec|= ((sli->effectiveState^sli->explicitState)&(1<<led));
+ }
+ bzero((char *)&ed,sizeof(xkbExtensionDeviceNotify));
+ bzero((char *)&changes,sizeof(XkbChangesRec));
+ XkbSetCauseXkbReq(&cause,X_kbSetNamedIndicator,client);
+ if (namec)
+ XkbApplyLedNameChanges(dev,sli,namec,&ed,&changes,&cause);
+ if (mapc)
+ XkbApplyLedMapChanges(dev,sli,mapc,&ed,&changes,&cause);
+ if (statec)
+ XkbApplyLedStateChanges(dev,sli,statec,&ed,&changes,&cause);
+
+ kbd= dev;
+ if ((sli->flags&XkbSLI_HasOwnState)==0)
+ kbd= (DeviceIntPtr)LookupKeyboardDevice();
+ XkbFlushLedEvents(dev,kbd,sli,&ed,&changes,&cause);
+ return client->noClientException;
+}
+
+/***====================================================================***/
+
+static CARD32
+_XkbCountAtoms(Atom *atoms,int maxAtoms,int *count)
+{
+register unsigned int i,bit,nAtoms;
+register CARD32 atomsPresent;
+
+ for (i=nAtoms=atomsPresent=0,bit=1;i<maxAtoms;i++,bit<<=1) {
+ if (atoms[i]!=None) {
+ atomsPresent|= bit;
+ nAtoms++;
+ }
+ }
+ if (count)
+ *count= nAtoms;
+ return atomsPresent;
+}
+
+static char *
+_XkbWriteAtoms(char *wire,Atom *atoms,int maxAtoms,int swap)
+{
+register unsigned int i;
+Atom *atm;
+
+ atm = (Atom *)wire;
+ for (i=0;i<maxAtoms;i++) {
+ if (atoms[i]!=None) {
+ *atm= atoms[i];
+ if (swap) {
+ register int n;
+ swapl(atm,n);
+ }
+ atm++;
+ }
+ }
+ return (char *)atm;
+}
+
+static Status
+XkbComputeGetNamesReplySize(XkbDescPtr xkb,xkbGetNamesReply *rep)
+{
+register unsigned which,length;
+register int i;
+
+ rep->minKeyCode= xkb->min_key_code;
+ rep->maxKeyCode= xkb->max_key_code;
+ which= rep->which;
+ length= 0;
+ if (xkb->names!=NULL) {
+ if (which&XkbKeycodesNameMask) length++;
+ if (which&XkbGeometryNameMask) length++;
+ if (which&XkbSymbolsNameMask) length++;
+ if (which&XkbPhysSymbolsNameMask) length++;
+ if (which&XkbTypesNameMask) length++;
+ if (which&XkbCompatNameMask) length++;
+ }
+ else which&= ~XkbComponentNamesMask;
+
+ if (xkb->map!=NULL) {
+ if (which&XkbKeyTypeNamesMask)
+ length+= xkb->map->num_types;
+ rep->nTypes= xkb->map->num_types;
+ if (which&XkbKTLevelNamesMask) {
+ XkbKeyTypePtr pType = xkb->map->types;
+ int nKTLevels = 0;
+
+ length+= XkbPaddedSize(xkb->map->num_types)/4;
+ for (i=0;i<xkb->map->num_types;i++,pType++) {
+ if (pType->level_names!=NULL)
+ nKTLevels+= pType->num_levels;
+ }
+ rep->nKTLevels= nKTLevels;
+ length+= nKTLevels;
+ }
+ }
+ else {
+ rep->nTypes= 0;
+ rep->nKTLevels= 0;
+ which&= ~(XkbKeyTypeNamesMask|XkbKTLevelNamesMask);
+ }
+
+ rep->minKeyCode= xkb->min_key_code;
+ rep->maxKeyCode= xkb->max_key_code;
+ rep->indicators= 0;
+ rep->virtualMods= 0;
+ rep->groupNames= 0;
+ if (xkb->names!=NULL) {
+ if (which&XkbIndicatorNamesMask) {
+ int nLeds;
+ rep->indicators=
+ _XkbCountAtoms(xkb->names->indicators,XkbNumIndicators,&nLeds);
+ length+= nLeds;
+ if (nLeds==0)
+ which&= ~XkbIndicatorNamesMask;
+ }
+
+ if (which&XkbVirtualModNamesMask) {
+ int nVMods;
+ rep->virtualMods=
+ _XkbCountAtoms(xkb->names->vmods,XkbNumVirtualMods,&nVMods);
+ length+= nVMods;
+ if (nVMods==0)
+ which&= ~XkbVirtualModNamesMask;
+ }
+
+ if (which&XkbGroupNamesMask) {
+ int nGroups;
+ rep->groupNames=
+ _XkbCountAtoms(xkb->names->groups,XkbNumKbdGroups,&nGroups);
+ length+= nGroups;
+ if (nGroups==0)
+ which&= ~XkbGroupNamesMask;
+ }
+
+ if ((which&XkbKeyNamesMask)&&(xkb->names->keys))
+ length+= rep->nKeys;
+ else which&= ~XkbKeyNamesMask;
+
+ if ((which&XkbKeyAliasesMask)&&
+ (xkb->names->key_aliases)&&(xkb->names->num_key_aliases>0)) {
+ rep->nKeyAliases= xkb->names->num_key_aliases;
+ length+= rep->nKeyAliases*2;
+ }
+ else {
+ which&= ~XkbKeyAliasesMask;
+ rep->nKeyAliases= 0;
+ }
+
+ if ((which&XkbRGNamesMask)&&(xkb->names->num_rg>0))
+ length+= xkb->names->num_rg;
+ else which&= ~XkbRGNamesMask;
+ }
+ else {
+ which&= ~(XkbIndicatorNamesMask|XkbVirtualModNamesMask);
+ which&= ~(XkbGroupNamesMask|XkbKeyNamesMask|XkbKeyAliasesMask);
+ which&= ~XkbRGNamesMask;
+ }
+
+ rep->length= length;
+ rep->which= which;
+ return Success;
+}
+
+static int
+XkbSendNames(ClientPtr client,XkbDescPtr xkb,xkbGetNamesReply *rep)
+{
+register unsigned i,length,which;
+char * start;
+char * desc;
+
+ length= rep->length*4;
+ which= rep->which;
+ if (client->swapped) {
+ register int n;
+ swaps(&rep->sequenceNumber,n);
+ swapl(&rep->length,n);
+ swapl(&rep->which,n);
+ swaps(&rep->virtualMods,n);
+ swapl(&rep->indicators,n);
+ }
+
+ start = desc = (char *)ALLOCATE_LOCAL(length);
+ if ( !start )
+ return BadAlloc;
+ if (which&XkbKeycodesNameMask) {
+ *((CARD32 *)desc)= xkb->names->keycodes;
+ if (client->swapped) {
+ register int n;
+ swapl(desc,n);
+ }
+ desc+= 4;
+ }
+ if (which&XkbGeometryNameMask) {
+ *((CARD32 *)desc)= xkb->names->geometry;
+ if (client->swapped) {
+ register int n;
+ swapl(desc,n);
+ }
+ desc+= 4;
+ }
+ if (which&XkbSymbolsNameMask) {
+ *((CARD32 *)desc)= xkb->names->symbols;
+ if (client->swapped) {
+ register int n;
+ swapl(desc,n);
+ }
+ desc+= 4;
+ }
+ if (which&XkbPhysSymbolsNameMask) {
+ register CARD32 *atm= (CARD32 *)desc;
+ atm[0]= (CARD32)xkb->names->phys_symbols;
+ if (client->swapped) {
+ register int n;
+ swapl(&atm[0],n);
+ }
+ desc+= 4;
+ }
+ if (which&XkbTypesNameMask) {
+ *((CARD32 *)desc)= (CARD32)xkb->names->types;
+ if (client->swapped) {
+ register int n;
+ swapl(desc,n);
+ }
+ desc+= 4;
+ }
+ if (which&XkbCompatNameMask) {
+ *((CARD32 *)desc)= (CARD32)xkb->names->compat;
+ if (client->swapped) {
+ register int n;
+ swapl(desc,n);
+ }
+ desc+= 4;
+ }
+ if (which&XkbKeyTypeNamesMask) {
+ register CARD32 *atm= (CARD32 *)desc;
+ register XkbKeyTypePtr type= xkb->map->types;
+
+ for (i=0;i<xkb->map->num_types;i++,atm++,type++) {
+ *atm= (CARD32)type->name;
+ if (client->swapped) {
+ register int n;
+ swapl(atm,n);
+ }
+ }
+ desc= (char *)atm;
+ }
+ if (which&XkbKTLevelNamesMask) {
+ XkbKeyTypePtr type = xkb->map->types;
+ register CARD32 *atm;
+ for (i=0;i<rep->nTypes;i++,type++) {
+ *desc++ = type->num_levels;
+ }
+ desc+= XkbPaddedSize(rep->nTypes)-rep->nTypes;
+
+ atm= (CARD32 *)desc;
+ type = xkb->map->types;
+ for (i=0;i<xkb->map->num_types;i++,type++) {
+ register unsigned l;
+ if (type->level_names) {
+ for (l=0;l<type->num_levels;l++,atm++) {
+ *atm= type->level_names[l];
+ if (client->swapped) {
+ register unsigned n;
+ swapl(atm,n);
+ }
+ }
+ desc+= type->num_levels*4;
+ }
+ }
+ }
+ if (which&XkbIndicatorNamesMask) {
+ desc= _XkbWriteAtoms(desc,xkb->names->indicators,XkbNumIndicators,
+ client->swapped);
+ }
+ if (which&XkbVirtualModNamesMask) {
+ desc= _XkbWriteAtoms(desc,xkb->names->vmods,XkbNumVirtualMods,
+ client->swapped);
+ }
+ if (which&XkbGroupNamesMask) {
+ desc= _XkbWriteAtoms(desc,xkb->names->groups,XkbNumKbdGroups,
+ client->swapped);
+ }
+ if (which&XkbKeyNamesMask) {
+ for (i=0;i<rep->nKeys;i++,desc+= sizeof(XkbKeyNameRec)) {
+ *((XkbKeyNamePtr)desc)= xkb->names->keys[i+rep->firstKey];
+ }
+ }
+ if (which&XkbKeyAliasesMask) {
+ XkbKeyAliasPtr pAl;
+ pAl= xkb->names->key_aliases;
+ for (i=0;i<rep->nKeyAliases;i++,pAl++,desc+=2*XkbKeyNameLength) {
+ *((XkbKeyAliasPtr)desc)= *pAl;
+ }
+ }
+ if ((which&XkbRGNamesMask)&&(rep->nRadioGroups>0)) {
+ register CARD32 *atm= (CARD32 *)desc;
+ for (i=0;i<rep->nRadioGroups;i++,atm++) {
+ *atm= (CARD32)xkb->names->radio_groups[i];
+ if (client->swapped) {
+ register unsigned n;
+ swapl(atm,n);
+ }
+ }
+ desc+= rep->nRadioGroups*4;
+ }
+ if ((desc-start)!=(length)) {
+ ErrorF("BOGUS LENGTH in write names, expected %d, got %ld\n",
+ length, (unsigned long)(desc-start));
+ }
+ WriteToClient(client, SIZEOF(xkbGetNamesReply), (char *)rep);
+ WriteToClient(client, length, start);
+ DEALLOCATE_LOCAL((char *)start);
+ return client->noClientException;
+}
+
+int
+ProcXkbGetNames(ClientPtr client)
+{
+ DeviceIntPtr dev;
+ XkbDescPtr xkb;
+ xkbGetNamesReply rep;
+
+ REQUEST(xkbGetNamesReq);
+ REQUEST_SIZE_MATCH(xkbGetNamesReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_MASK_LEGAL(0x01,stuff->which,XkbAllNamesMask);
+
+ xkb = dev->key->xkbInfo->desc;
+ rep.type= X_Reply;
+ rep.sequenceNumber= client->sequence;
+ rep.length = 0;
+ rep.deviceID = dev->id;
+ rep.which = stuff->which;
+ rep.nTypes = xkb->map->num_types;
+ rep.firstKey = xkb->min_key_code;
+ rep.nKeys = XkbNumKeys(xkb);
+ if (xkb->names!=NULL) {
+ rep.nKeyAliases= xkb->names->num_key_aliases;
+ rep.nRadioGroups = xkb->names->num_rg;
+ }
+ else {
+ rep.nKeyAliases= rep.nRadioGroups= 0;
+ }
+ XkbComputeGetNamesReplySize(xkb,&rep);
+ return XkbSendNames(client,xkb,&rep);
+}
+
+/***====================================================================***/
+
+static CARD32 *
+_XkbCheckAtoms(CARD32 *wire,int nAtoms,int swapped,Atom *pError)
+{
+register int i;
+
+ for (i=0;i<nAtoms;i++,wire++) {
+ if (swapped) {
+ register int n;
+ swapl(wire,n);
+ }
+ if ((((Atom)*wire)!=None)&&(!ValidAtom((Atom)*wire))) {
+ *pError= ((Atom)*wire);
+ return NULL;
+ }
+ }
+ return wire;
+}
+
+static CARD32 *
+_XkbCheckMaskedAtoms(CARD32 *wire,int nAtoms,CARD32 present,int swapped,
+ Atom *pError)
+{
+register unsigned i,bit;
+
+ for (i=0,bit=1;(i<nAtoms)&&(present);i++,bit<<=1) {
+ if ((present&bit)==0)
+ continue;
+ if (swapped) {
+ register int n;
+ swapl(wire,n);
+ }
+ if ((((Atom)*wire)!=None)&&(!ValidAtom(((Atom)*wire)))) {
+ *pError= (Atom)*wire;
+ return NULL;
+ }
+ wire++;
+ }
+ return wire;
+}
+
+static Atom *
+_XkbCopyMaskedAtoms( Atom *wire,
+ Atom *dest,
+ int nAtoms,
+ CARD32 present)
+{
+register int i,bit;
+
+ for (i=0,bit=1;(i<nAtoms)&&(present);i++,bit<<=1) {
+ if ((present&bit)==0)
+ continue;
+ dest[i]= *wire++;
+ }
+ return wire;
+}
+
+static Bool
+_XkbCheckTypeName(Atom name,int typeNdx)
+{
+char * str;
+
+ str= NameForAtom(name);
+ if ((strcmp(str,"ONE_LEVEL")==0)||(strcmp(str,"TWO_LEVEL")==0)||
+ (strcmp(str,"ALPHABETIC")==0)||(strcmp(str,"KEYPAD")==0))
+ return False;
+ return True;
+}
+
+int
+ProcXkbSetNames(ClientPtr client)
+{
+ DeviceIntPtr dev;
+ XkbDescRec *xkb;
+ XkbNamesRec *names;
+ xkbNamesNotify nn;
+ CARD32 *tmp;
+ Atom bad;
+
+ REQUEST(xkbSetNamesReq);
+ REQUEST_AT_LEAST_SIZE(xkbSetNamesReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_MASK_LEGAL(0x01,stuff->which,XkbAllNamesMask);
+
+ xkb = dev->key->xkbInfo->desc;
+ names = xkb->names;
+ tmp = (CARD32 *)&stuff[1];
+
+ if (stuff->which&XkbKeycodesNameMask) {
+ tmp= _XkbCheckAtoms(tmp,1,client->swapped,&bad);
+ if (!tmp) {
+ client->errorValue = bad;
+ return BadAtom;
+ }
+ }
+ if (stuff->which&XkbGeometryNameMask) {
+ tmp= _XkbCheckAtoms(tmp,1,client->swapped,&bad);
+ if (!tmp) {
+ client->errorValue = bad;
+ return BadAtom;
+ }
+ }
+ if (stuff->which&XkbSymbolsNameMask) {
+ tmp= _XkbCheckAtoms(tmp,1,client->swapped,&bad);
+ if (!tmp) {
+ client->errorValue = bad;
+ return BadAtom;
+ }
+ }
+ if (stuff->which&XkbPhysSymbolsNameMask) {
+ tmp= _XkbCheckAtoms(tmp,1,client->swapped,&bad);
+ if (!tmp) {
+ client->errorValue= bad;
+ return BadAtom;
+ }
+ }
+ if (stuff->which&XkbTypesNameMask) {
+ tmp= _XkbCheckAtoms(tmp,1,client->swapped,&bad);
+ if (!tmp) {
+ client->errorValue = bad;
+ return BadAtom;
+ }
+ }
+ if (stuff->which&XkbCompatNameMask) {
+ tmp= _XkbCheckAtoms(tmp,1,client->swapped,&bad);
+ if (!tmp) {
+ client->errorValue = bad;
+ return BadAtom;
+ }
+ }
+ if (stuff->which&XkbKeyTypeNamesMask) {
+ register int i;
+ CARD32 *old;
+ if ( stuff->nTypes<1 ) {
+ client->errorValue = _XkbErrCode2(0x02,stuff->nTypes);
+ return BadValue;
+ }
+ if ((unsigned)(stuff->firstType+stuff->nTypes-1)>=xkb->map->num_types) {
+ client->errorValue = _XkbErrCode4(0x03,stuff->firstType,
+ stuff->nTypes,
+ xkb->map->num_types);
+ return BadValue;
+ }
+ if (((unsigned)stuff->firstType)<=XkbLastRequiredType) {
+ client->errorValue = _XkbErrCode2(0x04,stuff->firstType);
+ return BadAccess;
+ }
+ old= tmp;
+ tmp= _XkbCheckAtoms(tmp,stuff->nTypes,client->swapped,&bad);
+ if (!tmp) {
+ client->errorValue= bad;
+ return BadAtom;
+ }
+ for (i=0;i<stuff->nTypes;i++,old++) {
+ if (!_XkbCheckTypeName((Atom)*old,stuff->firstType+i))
+ client->errorValue= _XkbErrCode2(0x05,i);
+ }
+ }
+ if (stuff->which&XkbKTLevelNamesMask) {
+ register unsigned i;
+ XkbKeyTypePtr type;
+ CARD8 * width;
+ if ( stuff->nKTLevels<1 ) {
+ client->errorValue = _XkbErrCode2(0x05,stuff->nKTLevels);
+ return BadValue;
+ }
+ if ((unsigned)(stuff->firstKTLevel+stuff->nKTLevels-1)>=
+ xkb->map->num_types) {
+ client->errorValue = _XkbErrCode4(0x06,stuff->firstKTLevel,
+ stuff->nKTLevels,xkb->map->num_types);
+ return BadValue;
+ }
+ width = (CARD8 *)tmp;
+ tmp= (CARD32 *)(((char *)tmp)+XkbPaddedSize(stuff->nKTLevels));
+ type = &xkb->map->types[stuff->firstKTLevel];
+ for (i=0;i<stuff->nKTLevels;i++,type++) {
+ if (width[i]==0)
+ continue;
+ else if (width[i]!=type->num_levels) {
+ client->errorValue= _XkbErrCode4(0x07,i+stuff->firstKTLevel,
+ type->num_levels,width[i]);
+ return BadMatch;
+ }
+ tmp= _XkbCheckAtoms(tmp,width[i],client->swapped,&bad);
+ if (!tmp) {
+ client->errorValue= bad;
+ return BadAtom;
+ }
+ }
+ }
+ if (stuff->which&XkbIndicatorNamesMask) {
+ if (stuff->indicators==0) {
+ client->errorValue= 0x08;
+ return BadMatch;
+ }
+ tmp= _XkbCheckMaskedAtoms(tmp,XkbNumIndicators,stuff->indicators,
+ client->swapped,&bad);
+ if (!tmp) {
+ client->errorValue= bad;
+ return BadAtom;
+ }
+ }
+ if (stuff->which&XkbVirtualModNamesMask) {
+ if (stuff->virtualMods==0) {
+ client->errorValue= 0x09;
+ return BadMatch;
+ }
+ tmp= _XkbCheckMaskedAtoms(tmp,XkbNumVirtualMods,
+ (CARD32)stuff->virtualMods,
+ client->swapped,&bad);
+ if (!tmp) {
+ client->errorValue = bad;
+ return BadAtom;
+ }
+ }
+ if (stuff->which&XkbGroupNamesMask) {
+ if (stuff->groupNames==0) {
+ client->errorValue= 0x0a;
+ return BadMatch;
+ }
+ tmp= _XkbCheckMaskedAtoms(tmp,XkbNumKbdGroups,
+ (CARD32)stuff->groupNames,
+ client->swapped,&bad);
+ if (!tmp) {
+ client->errorValue = bad;
+ return BadAtom;
+ }
+ }
+ if (stuff->which&XkbKeyNamesMask) {
+ if (stuff->firstKey<(unsigned)xkb->min_key_code) {
+ client->errorValue= _XkbErrCode3(0x0b,xkb->min_key_code,
+ stuff->firstKey);
+ return BadValue;
+ }
+ if (((unsigned)(stuff->firstKey+stuff->nKeys-1)>xkb->max_key_code)||
+ (stuff->nKeys<1)) {
+ client->errorValue= _XkbErrCode4(0x0c,xkb->max_key_code,
+ stuff->firstKey,stuff->nKeys);
+ return BadValue;
+ }
+ tmp+= stuff->nKeys;
+ }
+ if ((stuff->which&XkbKeyAliasesMask)&&(stuff->nKeyAliases>0)) {
+ tmp+= stuff->nKeyAliases*2;
+ }
+ if (stuff->which&XkbRGNamesMask) {
+ if ( stuff->nRadioGroups<1 ) {
+ client->errorValue= _XkbErrCode2(0x0d,stuff->nRadioGroups);
+ return BadValue;
+ }
+ tmp= _XkbCheckAtoms(tmp,stuff->nRadioGroups,client->swapped,&bad);
+ if (!tmp) {
+ client->errorValue= bad;
+ return BadAtom;
+ }
+ }
+ if ((tmp-((CARD32 *)stuff))!=stuff->length) {
+ client->errorValue = stuff->length;
+ return BadLength;
+ }
+ if (XkbAllocNames(xkb,stuff->which,stuff->nRadioGroups,
+ stuff->nKeyAliases)!=Success) {
+ return BadAlloc;
+ }
+
+ /* everything is okay -- update names */
+ bzero(&nn,sizeof(xkbNamesNotify));
+ nn.changed= stuff->which;
+ tmp = (CARD32 *)&stuff[1];
+ if (stuff->which&XkbKeycodesNameMask)
+ names->keycodes= *tmp++;
+ if (stuff->which&XkbGeometryNameMask)
+ names->geometry= *tmp++;
+ if (stuff->which&XkbSymbolsNameMask)
+ names->symbols= *tmp++;
+ if (stuff->which&XkbPhysSymbolsNameMask)
+ names->phys_symbols= *tmp++;
+ if (stuff->which&XkbTypesNameMask)
+ names->types= *tmp++;
+ if (stuff->which&XkbCompatNameMask)
+ names->compat= *tmp++;
+ if ((stuff->which&XkbKeyTypeNamesMask)&&(stuff->nTypes>0)) {
+ register unsigned i;
+ register XkbKeyTypePtr type;
+
+ type= &xkb->map->types[stuff->firstType];
+ for (i=0;i<stuff->nTypes;i++,type++) {
+ type->name= *tmp++;
+ }
+ nn.firstType= stuff->firstType;
+ nn.nTypes= stuff->nTypes;
+ }
+ if (stuff->which&XkbKTLevelNamesMask) {
+ register XkbKeyTypePtr type;
+ register unsigned i;
+ CARD8 *width;
+
+ width = (CARD8 *)tmp;
+ tmp= (CARD32 *)(((char *)tmp)+XkbPaddedSize(stuff->nKTLevels));
+ type= &xkb->map->types[stuff->firstKTLevel];
+ for (i=0;i<stuff->nKTLevels;i++,type++) {
+ if (width[i]>0) {
+ if (type->level_names) {
+ register unsigned n;
+ for (n=0;n<width[i];n++) {
+ type->level_names[n]= tmp[n];
+ }
+ }
+ tmp+= width[i];
+ }
+ }
+ nn.firstLevelName= 0;
+ nn.nLevelNames= stuff->nTypes;
+ }
+ if (stuff->which&XkbIndicatorNamesMask) {
+ tmp= _XkbCopyMaskedAtoms(tmp,names->indicators,XkbNumIndicators,
+ stuff->indicators);
+ nn.changedIndicators= stuff->indicators;
+ }
+ if (stuff->which&XkbVirtualModNamesMask) {
+ tmp= _XkbCopyMaskedAtoms(tmp,names->vmods,XkbNumVirtualMods,
+ stuff->virtualMods);
+ nn.changedVirtualMods= stuff->virtualMods;
+ }
+ if (stuff->which&XkbGroupNamesMask) {
+ tmp= _XkbCopyMaskedAtoms(tmp,names->groups,XkbNumKbdGroups,
+ stuff->groupNames);
+ nn.changedVirtualMods= stuff->groupNames;
+ }
+ if (stuff->which&XkbKeyNamesMask) {
+ memcpy((char*)&names->keys[stuff->firstKey],(char *)tmp,
+ stuff->nKeys*XkbKeyNameLength);
+ tmp+= stuff->nKeys;
+ nn.firstKey= stuff->firstKey;
+ nn.nKeys= stuff->nKeys;
+ }
+ if (stuff->which&XkbKeyAliasesMask) {
+ if (stuff->nKeyAliases>0) {
+ register int na= stuff->nKeyAliases;
+ if (XkbAllocNames(xkb,XkbKeyAliasesMask,0,na)!=Success)
+ return BadAlloc;
+ memcpy((char *)names->key_aliases,(char *)tmp,
+ stuff->nKeyAliases*sizeof(XkbKeyAliasRec));
+ tmp+= stuff->nKeyAliases*2;
+ }
+ else if (names->key_aliases!=NULL) {
+ _XkbFree(names->key_aliases);
+ names->key_aliases= NULL;
+ names->num_key_aliases= 0;
+ }
+ nn.nAliases= names->num_key_aliases;
+ }
+ if (stuff->which&XkbRGNamesMask) {
+ if (stuff->nRadioGroups>0) {
+ register unsigned i,nrg;
+ nrg= stuff->nRadioGroups;
+ if (XkbAllocNames(xkb,XkbRGNamesMask,nrg,0)!=Success)
+ return BadAlloc;
+
+ for (i=0;i<stuff->nRadioGroups;i++) {
+ names->radio_groups[i]= tmp[i];
+ }
+ tmp+= stuff->nRadioGroups;
+ }
+ else if (names->radio_groups) {
+ _XkbFree(names->radio_groups);
+ names->radio_groups= NULL;
+ names->num_rg= 0;
+ }
+ nn.nRadioGroups= names->num_rg;
+ }
+ if (nn.changed) {
+ Bool needExtEvent;
+ needExtEvent= (nn.changed&XkbIndicatorNamesMask)!=0;
+ XkbSendNamesNotify(dev,&nn);
+ if (needExtEvent) {
+ XkbSrvLedInfoPtr sli;
+ xkbExtensionDeviceNotify edev;
+ register int i;
+ register unsigned bit;
+
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,
+ XkbXI_IndicatorsMask);
+ sli->namesPresent= 0;
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (names->indicators[i]!=None)
+ sli->namesPresent|= bit;
+ }
+ bzero(&edev,sizeof(xkbExtensionDeviceNotify));
+ edev.reason= XkbXI_IndicatorNamesMask;
+ edev.ledClass= KbdFeedbackClass;
+ edev.ledID= dev->kbdfeed->ctrl.id;
+ edev.ledsDefined= sli->namesPresent|sli->mapsPresent;
+ edev.ledState= sli->effectiveState;
+ edev.firstBtn= 0;
+ edev.nBtns= 0;
+ edev.supported= XkbXI_AllFeaturesMask;
+ edev.unsupported= 0;
+ XkbSendExtensionDeviceNotify(dev,client,&edev);
+ }
+ }
+ return client->noClientException;
+}
+
+/***====================================================================***/
+
+#include <X11/extensions/XKBgeom.h>
+
+#define XkbSizeCountedString(s) ((s)?((((2+strlen(s))+3)/4)*4):4)
+
+static char *
+XkbWriteCountedString(char *wire,char *str,Bool swap)
+{
+CARD16 len,*pLen;
+
+ len= (str?strlen(str):0);
+ pLen= (CARD16 *)wire;
+ *pLen= len;
+ if (swap) {
+ register int n;
+ swaps(pLen,n);
+ }
+ memcpy(&wire[2],str,len);
+ wire+= ((2+len+3)/4)*4;
+ return wire;
+}
+
+static int
+XkbSizeGeomProperties(XkbGeometryPtr geom)
+{
+register int i,size;
+XkbPropertyPtr prop;
+
+ for (size=i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
+ size+= XkbSizeCountedString(prop->name);
+ size+= XkbSizeCountedString(prop->value);
+ }
+ return size;
+}
+
+static char *
+XkbWriteGeomProperties(char *wire,XkbGeometryPtr geom,Bool swap)
+{
+register int i;
+register XkbPropertyPtr prop;
+
+ for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
+ wire= XkbWriteCountedString(wire,prop->name,swap);
+ wire= XkbWriteCountedString(wire,prop->value,swap);
+ }
+ return wire;
+}
+
+static int
+XkbSizeGeomKeyAliases(XkbGeometryPtr geom)
+{
+ return geom->num_key_aliases*(2*XkbKeyNameLength);
+}
+
+static char *
+XkbWriteGeomKeyAliases(char *wire,XkbGeometryPtr geom,Bool swap)
+{
+register int sz;
+
+ sz= geom->num_key_aliases*(XkbKeyNameLength*2);
+ if (sz>0) {
+ memcpy(wire,(char *)geom->key_aliases,sz);
+ wire+= sz;
+ }
+ return wire;
+}
+
+static int
+XkbSizeGeomColors(XkbGeometryPtr geom)
+{
+register int i,size;
+register XkbColorPtr color;
+
+ for (i=size=0,color=geom->colors;i<geom->num_colors;i++,color++) {
+ size+= XkbSizeCountedString(color->spec);
+ }
+ return size;
+}
+
+static char *
+XkbWriteGeomColors(char *wire,XkbGeometryPtr geom,Bool swap)
+{
+register int i;
+register XkbColorPtr color;
+
+ for (i=0,color=geom->colors;i<geom->num_colors;i++,color++) {
+ wire= XkbWriteCountedString(wire,color->spec,swap);
+ }
+ return wire;
+}
+
+static int
+XkbSizeGeomShapes(XkbGeometryPtr geom)
+{
+register int i,size;
+register XkbShapePtr shape;
+
+ for (i=size=0,shape=geom->shapes;i<geom->num_shapes;i++,shape++) {
+ register int n;
+ register XkbOutlinePtr ol;
+ size+= SIZEOF(xkbShapeWireDesc);
+ for (n=0,ol=shape->outlines;n<shape->num_outlines;n++,ol++) {
+ size+= SIZEOF(xkbOutlineWireDesc);
+ size+= ol->num_points*SIZEOF(xkbPointWireDesc);
+ }
+ }
+ return size;
+}
+
+static char *
+XkbWriteGeomShapes(char *wire,XkbGeometryPtr geom,Bool swap)
+{
+int i;
+XkbShapePtr shape;
+xkbShapeWireDesc * shapeWire;
+
+ for (i=0,shape=geom->shapes;i<geom->num_shapes;i++,shape++) {
+ register int o;
+ XkbOutlinePtr ol;
+ xkbOutlineWireDesc * olWire;
+ shapeWire= (xkbShapeWireDesc *)wire;
+ shapeWire->name= shape->name;
+ shapeWire->nOutlines= shape->num_outlines;
+ if (shape->primary!=NULL)
+ shapeWire->primaryNdx= XkbOutlineIndex(shape,shape->primary);
+ else shapeWire->primaryNdx= XkbNoShape;
+ if (shape->approx!=NULL)
+ shapeWire->approxNdx= XkbOutlineIndex(shape,shape->approx);
+ else shapeWire->approxNdx= XkbNoShape;
+ if (swap) {
+ register int n;
+ swapl(&shapeWire->name,n);
+ }
+ wire= (char *)&shapeWire[1];
+ for (o=0,ol=shape->outlines;o<shape->num_outlines;o++,ol++) {
+ register int p;
+ XkbPointPtr pt;
+ xkbPointWireDesc * ptWire;
+ olWire= (xkbOutlineWireDesc *)wire;
+ olWire->nPoints= ol->num_points;
+ olWire->cornerRadius= ol->corner_radius;
+ wire= (char *)&olWire[1];
+ ptWire= (xkbPointWireDesc *)wire;
+ for (p=0,pt=ol->points;p<ol->num_points;p++,pt++) {
+ ptWire[p].x= pt->x;
+ ptWire[p].y= pt->y;
+ if (swap) {
+ register int n;
+ swaps(&ptWire[p].x,n);
+ swaps(&ptWire[p].y,n);
+ }
+ }
+ wire= (char *)&ptWire[ol->num_points];
+ }
+ }
+ return wire;
+}
+
+static int
+XkbSizeGeomDoodads(int num_doodads,XkbDoodadPtr doodad)
+{
+register int i,size;
+
+ for (i=size=0;i<num_doodads;i++,doodad++) {
+ size+= SIZEOF(xkbAnyDoodadWireDesc);
+ if (doodad->any.type==XkbTextDoodad) {
+ size+= XkbSizeCountedString(doodad->text.text);
+ size+= XkbSizeCountedString(doodad->text.font);
+ }
+ else if (doodad->any.type==XkbLogoDoodad) {
+ size+= XkbSizeCountedString(doodad->logo.logo_name);
+ }
+ }
+ return size;
+}
+
+static char *
+XkbWriteGeomDoodads(char *wire,int num_doodads,XkbDoodadPtr doodad,Bool swap)
+{
+register int i;
+xkbDoodadWireDesc * doodadWire;
+
+ for (i=0;i<num_doodads;i++,doodad++) {
+ doodadWire= (xkbDoodadWireDesc *)wire;
+ wire= (char *)&doodadWire[1];
+ bzero(doodadWire,SIZEOF(xkbDoodadWireDesc));
+ doodadWire->any.name= doodad->any.name;
+ doodadWire->any.type= doodad->any.type;
+ doodadWire->any.priority= doodad->any.priority;
+ doodadWire->any.top= doodad->any.top;
+ doodadWire->any.left= doodad->any.left;
+ if (swap) {
+ register int n;
+ swapl(&doodadWire->any.name,n);
+ swaps(&doodadWire->any.top,n);
+ swaps(&doodadWire->any.left,n);
+ }
+ switch (doodad->any.type) {
+ case XkbOutlineDoodad:
+ case XkbSolidDoodad:
+ doodadWire->shape.angle= doodad->shape.angle;
+ doodadWire->shape.colorNdx= doodad->shape.color_ndx;
+ doodadWire->shape.shapeNdx= doodad->shape.shape_ndx;
+ if (swap) {
+ register int n;
+ swaps(&doodadWire->shape.angle,n);
+ }
+ break;
+ case XkbTextDoodad:
+ doodadWire->text.angle= doodad->text.angle;
+ doodadWire->text.width= doodad->text.width;
+ doodadWire->text.height= doodad->text.height;
+ doodadWire->text.colorNdx= doodad->text.color_ndx;
+ if (swap) {
+ register int n;
+ swaps(&doodadWire->text.angle,n);
+ swaps(&doodadWire->text.width,n);
+ swaps(&doodadWire->text.height,n);
+ }
+ wire= XkbWriteCountedString(wire,doodad->text.text,swap);
+ wire= XkbWriteCountedString(wire,doodad->text.font,swap);
+ break;
+ case XkbIndicatorDoodad:
+ doodadWire->indicator.shapeNdx= doodad->indicator.shape_ndx;
+ doodadWire->indicator.onColorNdx=doodad->indicator.on_color_ndx;
+ doodadWire->indicator.offColorNdx=
+ doodad->indicator.off_color_ndx;
+ break;
+ case XkbLogoDoodad:
+ doodadWire->logo.angle= doodad->logo.angle;
+ doodadWire->logo.colorNdx= doodad->logo.color_ndx;
+ doodadWire->logo.shapeNdx= doodad->logo.shape_ndx;
+ wire= XkbWriteCountedString(wire,doodad->logo.logo_name,swap);
+ break;
+ default:
+ ErrorF("Unknown doodad type %d in XkbWriteGeomDoodads\n",
+ doodad->any.type);
+ ErrorF("Ignored\n");
+ break;
+ }
+ }
+ return wire;
+}
+
+static char *
+XkbWriteGeomOverlay(char *wire,XkbOverlayPtr ol,Bool swap)
+{
+register int r;
+XkbOverlayRowPtr row;
+xkbOverlayWireDesc * olWire;
+
+ olWire= (xkbOverlayWireDesc *)wire;
+ olWire->name= ol->name;
+ olWire->nRows= ol->num_rows;
+ if (swap) {
+ register int n;
+ swapl(&olWire->name,n);
+ }
+ wire= (char *)&olWire[1];
+ for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
+ unsigned int k;
+ XkbOverlayKeyPtr key;
+ xkbOverlayRowWireDesc * rowWire;
+ rowWire= (xkbOverlayRowWireDesc *)wire;
+ rowWire->rowUnder= row->row_under;
+ rowWire->nKeys= row->num_keys;
+ wire= (char *)&rowWire[1];
+ for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
+ xkbOverlayKeyWireDesc * keyWire;
+ keyWire= (xkbOverlayKeyWireDesc *)wire;
+ memcpy(keyWire->over,key->over.name,XkbKeyNameLength);
+ memcpy(keyWire->under,key->under.name,XkbKeyNameLength);
+ wire= (char *)&keyWire[1];
+ }
+ }
+ return wire;
+}
+
+static int
+XkbSizeGeomSections(XkbGeometryPtr geom)
+{
+register int i,size;
+XkbSectionPtr section;
+
+ for (i=size=0,section=geom->sections;i<geom->num_sections;i++,section++) {
+ size+= SIZEOF(xkbSectionWireDesc);
+ if (section->rows) {
+ int r;
+ XkbRowPtr row;
+ for (r=0,row=section->rows;r<section->num_rows;row++,r++) {
+ size+= SIZEOF(xkbRowWireDesc);
+ size+= row->num_keys*SIZEOF(xkbKeyWireDesc);
+ }
+ }
+ if (section->doodads)
+ size+= XkbSizeGeomDoodads(section->num_doodads,section->doodads);
+ if (section->overlays) {
+ int o;
+ XkbOverlayPtr ol;
+ for (o=0,ol=section->overlays;o<section->num_overlays;o++,ol++) {
+ int r;
+ XkbOverlayRowPtr row;
+ size+= SIZEOF(xkbOverlayWireDesc);
+ for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
+ size+= SIZEOF(xkbOverlayRowWireDesc);
+ size+= row->num_keys*SIZEOF(xkbOverlayKeyWireDesc);
+ }
+ }
+ }
+ }
+ return size;
+}
+
+static char *
+XkbWriteGeomSections(char *wire,XkbGeometryPtr geom,Bool swap)
+{
+register int i;
+XkbSectionPtr section;
+xkbSectionWireDesc * sectionWire;
+
+ for (i=0,section=geom->sections;i<geom->num_sections;i++,section++) {
+ sectionWire= (xkbSectionWireDesc *)wire;
+ sectionWire->name= section->name;
+ sectionWire->top= section->top;
+ sectionWire->left= section->left;
+ sectionWire->width= section->width;
+ sectionWire->height= section->height;
+ sectionWire->angle= section->angle;
+ sectionWire->priority= section->priority;
+ sectionWire->nRows= section->num_rows;
+ sectionWire->nDoodads= section->num_doodads;
+ sectionWire->nOverlays= section->num_overlays;
+ sectionWire->pad= 0;
+ if (swap) {
+ register int n;
+ swapl(&sectionWire->name,n);
+ swaps(&sectionWire->top,n);
+ swaps(&sectionWire->left,n);
+ swaps(&sectionWire->width,n);
+ swaps(&sectionWire->height,n);
+ swaps(&sectionWire->angle,n);
+ }
+ wire= (char *)&sectionWire[1];
+ if (section->rows) {
+ int r;
+ XkbRowPtr row;
+ xkbRowWireDesc * rowWire;
+ for (r=0,row=section->rows;r<section->num_rows;r++,row++) {
+ rowWire= (xkbRowWireDesc *)wire;
+ rowWire->top= row->top;
+ rowWire->left= row->left;
+ rowWire->nKeys= row->num_keys;
+ rowWire->vertical= row->vertical;
+ rowWire->pad= 0;
+ if (swap) {
+ register int n;
+ swaps(&rowWire->top,n);
+ swaps(&rowWire->left,n);
+ }
+ wire= (char *)&rowWire[1];
+ if (row->keys) {
+ int k;
+ XkbKeyPtr key;
+ xkbKeyWireDesc * keyWire;
+ keyWire= (xkbKeyWireDesc *)wire;
+ for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
+ memcpy(keyWire[k].name,key->name.name,XkbKeyNameLength);
+ keyWire[k].gap= key->gap;
+ keyWire[k].shapeNdx= key->shape_ndx;
+ keyWire[k].colorNdx= key->color_ndx;
+ if (swap) {
+ register int n;
+ swaps(&keyWire[k].gap,n);
+ }
+ }
+ wire= (char *)&keyWire[row->num_keys];
+ }
+ }
+ }
+ if (section->doodads) {
+ wire= XkbWriteGeomDoodads(wire,
+ section->num_doodads,section->doodads,
+ swap);
+ }
+ if (section->overlays) {
+ register int o;
+ for (o=0;o<section->num_overlays;o++) {
+ wire= XkbWriteGeomOverlay(wire,&section->overlays[o],swap);
+ }
+ }
+ }
+ return wire;
+}
+
+static Status
+XkbComputeGetGeometryReplySize( XkbGeometryPtr geom,
+ xkbGetGeometryReply * rep,
+ Atom name)
+{
+int len;
+
+ if (geom!=NULL) {
+ len= XkbSizeCountedString(geom->label_font);
+ len+= XkbSizeGeomProperties(geom);
+ len+= XkbSizeGeomColors(geom);
+ len+= XkbSizeGeomShapes(geom);
+ len+= XkbSizeGeomSections(geom);
+ len+= XkbSizeGeomDoodads(geom->num_doodads,geom->doodads);
+ len+= XkbSizeGeomKeyAliases(geom);
+ rep->length= len/4;
+ rep->found= True;
+ rep->name= geom->name;
+ rep->widthMM= geom->width_mm;
+ rep->heightMM= geom->height_mm;
+ rep->nProperties= geom->num_properties;
+ rep->nColors= geom->num_colors;
+ rep->nShapes= geom->num_shapes;
+ rep->nSections= geom->num_sections;
+ rep->nDoodads= geom->num_doodads;
+ rep->nKeyAliases= geom->num_key_aliases;
+ rep->baseColorNdx= XkbGeomColorIndex(geom,geom->base_color);
+ rep->labelColorNdx= XkbGeomColorIndex(geom,geom->label_color);
+ }
+ else {
+ rep->length= 0;
+ rep->found= False;
+ rep->name= name;
+ rep->widthMM= rep->heightMM= 0;
+ rep->nProperties= rep->nColors= rep->nShapes= 0;
+ rep->nSections= rep->nDoodads= 0;
+ rep->nKeyAliases= 0;
+ rep->labelColorNdx= rep->baseColorNdx= 0;
+ }
+ return Success;
+}
+
+static int
+XkbSendGeometry( ClientPtr client,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply * rep,
+ Bool freeGeom)
+{
+ char *desc,*start;
+ int len;
+
+ if (geom!=NULL) {
+ len= rep->length*4;
+ start= desc= (char *)ALLOCATE_LOCAL(len);
+ if (!start)
+ return BadAlloc;
+ desc= XkbWriteCountedString(desc,geom->label_font,client->swapped);
+ if ( rep->nProperties>0 )
+ desc = XkbWriteGeomProperties(desc,geom,client->swapped);
+ if ( rep->nColors>0 )
+ desc = XkbWriteGeomColors(desc,geom,client->swapped);
+ if ( rep->nShapes>0 )
+ desc = XkbWriteGeomShapes(desc,geom,client->swapped);
+ if ( rep->nSections>0 )
+ desc = XkbWriteGeomSections(desc,geom,client->swapped);
+ if ( rep->nDoodads>0 )
+ desc = XkbWriteGeomDoodads(desc,geom->num_doodads,geom->doodads,
+ client->swapped);
+ if ( rep->nKeyAliases>0 )
+ desc = XkbWriteGeomKeyAliases(desc,geom,client->swapped);
+ if ((desc-start)!=(len)) {
+ ErrorF("BOGUS LENGTH in XkbSendGeometry, expected %d, got %ld\n",
+ len, (unsigned long)(desc-start));
+ }
+ }
+ else {
+ len= 0;
+ start= NULL;
+ }
+ if (client->swapped) {
+ register int n;
+ swaps(&rep->sequenceNumber,n);
+ swapl(&rep->length,n);
+ swapl(&rep->name,n);
+ swaps(&rep->widthMM,n);
+ swaps(&rep->heightMM,n);
+ swaps(&rep->nProperties,n);
+ swaps(&rep->nColors,n);
+ swaps(&rep->nShapes,n);
+ swaps(&rep->nSections,n);
+ swaps(&rep->nDoodads,n);
+ swaps(&rep->nKeyAliases,n);
+ }
+ WriteToClient(client, SIZEOF(xkbGetGeometryReply), (char *)rep);
+ if (len>0)
+ WriteToClient(client, len, start);
+ if (start!=NULL)
+ DEALLOCATE_LOCAL((char *)start);
+ if (freeGeom)
+ XkbFreeGeometry(geom,XkbGeomAllMask,True);
+ return client->noClientException;
+}
+
+int
+ProcXkbGetGeometry(ClientPtr client)
+{
+ DeviceIntPtr dev;
+ xkbGetGeometryReply rep;
+ XkbGeometryPtr geom;
+ Bool shouldFree;
+ Status status;
+
+ REQUEST(xkbGetGeometryReq);
+ REQUEST_SIZE_MATCH(xkbGetGeometryReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_ATOM_OR_NONE(stuff->name);
+
+ geom= XkbLookupNamedGeometry(dev,stuff->name,&shouldFree);
+ rep.type= X_Reply;
+ rep.deviceID= dev->id;
+ rep.sequenceNumber= client->sequence;
+ rep.length= 0;
+ status= XkbComputeGetGeometryReplySize(geom,&rep,stuff->name);
+ if (status!=Success)
+ return status;
+ else return XkbSendGeometry(client,geom,&rep,shouldFree);
+}
+
+/***====================================================================***/
+
+static char *
+_GetCountedString(char **wire_inout,Bool swap)
+{
+char * wire,*str;
+CARD16 len,*plen;
+
+ wire= *wire_inout;
+ plen= (CARD16 *)wire;
+ if (swap) {
+ register int n;
+ swaps(plen,n);
+ }
+ len= *plen;
+ str= (char *)_XkbAlloc(len+1);
+ if (str) {
+ memcpy(str,&wire[2],len);
+ str[len]= '\0';
+ }
+ wire+= XkbPaddedSize(len+2);
+ *wire_inout= wire;
+ return str;
+}
+
+static Status
+_CheckSetDoodad( char ** wire_inout,
+ XkbGeometryPtr geom,
+ XkbSectionPtr section,
+ ClientPtr client)
+{
+char * wire;
+xkbDoodadWireDesc * dWire;
+XkbDoodadPtr doodad;
+
+ dWire= (xkbDoodadWireDesc *)(*wire_inout);
+ wire= (char *)&dWire[1];
+ if (client->swapped) {
+ register int n;
+ swapl(&dWire->any.name,n);
+ swaps(&dWire->any.top,n);
+ swaps(&dWire->any.left,n);
+ swaps(&dWire->any.angle,n);
+ }
+ CHK_ATOM_ONLY(dWire->any.name);
+ doodad= XkbAddGeomDoodad(geom,section,dWire->any.name);
+ if (!doodad)
+ return BadAlloc;
+ doodad->any.type= dWire->any.type;
+ doodad->any.priority= dWire->any.priority;
+ doodad->any.top= dWire->any.top;
+ doodad->any.left= dWire->any.left;
+ doodad->any.angle= dWire->any.angle;
+ switch (doodad->any.type) {
+ case XkbOutlineDoodad:
+ case XkbSolidDoodad:
+ if (dWire->shape.colorNdx>=geom->num_colors) {
+ client->errorValue= _XkbErrCode3(0x40,geom->num_colors,
+ dWire->shape.colorNdx);
+ return BadMatch;
+ }
+ if (dWire->shape.shapeNdx>=geom->num_shapes) {
+ client->errorValue= _XkbErrCode3(0x41,geom->num_shapes,
+ dWire->shape.shapeNdx);
+ return BadMatch;
+ }
+ doodad->shape.color_ndx= dWire->shape.colorNdx;
+ doodad->shape.shape_ndx= dWire->shape.shapeNdx;
+ break;
+ case XkbTextDoodad:
+ if (dWire->text.colorNdx>=geom->num_colors) {
+ client->errorValue= _XkbErrCode3(0x42,geom->num_colors,
+ dWire->text.colorNdx);
+ return BadMatch;
+ }
+ if (client->swapped) {
+ register int n;
+ swaps(&dWire->text.width,n);
+ swaps(&dWire->text.height,n);
+ }
+ doodad->text.width= dWire->text.width;
+ doodad->text.height= dWire->text.height;
+ doodad->text.color_ndx= dWire->text.colorNdx;
+ doodad->text.text= _GetCountedString(&wire,client->swapped);
+ doodad->text.font= _GetCountedString(&wire,client->swapped);
+ break;
+ case XkbIndicatorDoodad:
+ if (dWire->indicator.onColorNdx>=geom->num_colors) {
+ client->errorValue= _XkbErrCode3(0x43,geom->num_colors,
+ dWire->indicator.onColorNdx);
+ return BadMatch;
+ }
+ if (dWire->indicator.offColorNdx>=geom->num_colors) {
+ client->errorValue= _XkbErrCode3(0x44,geom->num_colors,
+ dWire->indicator.offColorNdx);
+ return BadMatch;
+ }
+ if (dWire->indicator.shapeNdx>=geom->num_shapes) {
+ client->errorValue= _XkbErrCode3(0x45,geom->num_shapes,
+ dWire->indicator.shapeNdx);
+ return BadMatch;
+ }
+ doodad->indicator.shape_ndx= dWire->indicator.shapeNdx;
+ doodad->indicator.on_color_ndx= dWire->indicator.onColorNdx;
+ doodad->indicator.off_color_ndx= dWire->indicator.offColorNdx;
+ break;
+ case XkbLogoDoodad:
+ if (dWire->logo.colorNdx>=geom->num_colors) {
+ client->errorValue= _XkbErrCode3(0x46,geom->num_colors,
+ dWire->logo.colorNdx);
+ return BadMatch;
+ }
+ if (dWire->logo.shapeNdx>=geom->num_shapes) {
+ client->errorValue= _XkbErrCode3(0x47,geom->num_shapes,
+ dWire->logo.shapeNdx);
+ return BadMatch;
+ }
+ doodad->logo.color_ndx= dWire->logo.colorNdx;
+ doodad->logo.shape_ndx= dWire->logo.shapeNdx;
+ doodad->logo.logo_name= _GetCountedString(&wire,client->swapped);
+ break;
+ default:
+ client->errorValue= _XkbErrCode2(0x4F,dWire->any.type);
+ return BadValue;
+ }
+ *wire_inout= wire;
+ return Success;
+}
+
+static Status
+_CheckSetOverlay( char ** wire_inout,
+ XkbGeometryPtr geom,
+ XkbSectionPtr section,
+ ClientPtr client)
+{
+register int r;
+char * wire;
+XkbOverlayPtr ol;
+xkbOverlayWireDesc * olWire;
+xkbOverlayRowWireDesc * rWire;
+
+ wire= *wire_inout;
+ olWire= (xkbOverlayWireDesc *)wire;
+ if (client->swapped) {
+ register int n;
+ swapl(&olWire->name,n);
+ }
+ CHK_ATOM_ONLY(olWire->name);
+ ol= XkbAddGeomOverlay(section,olWire->name,olWire->nRows);
+ rWire= (xkbOverlayRowWireDesc *)&olWire[1];
+ for (r=0;r<olWire->nRows;r++) {
+ register int k;
+ xkbOverlayKeyWireDesc * kWire;
+ XkbOverlayRowPtr row;
+
+ if (rWire->rowUnder>section->num_rows) {
+ client->errorValue= _XkbErrCode4(0x20,r,section->num_rows,
+ rWire->rowUnder);
+ return BadMatch;
+ }
+ row= XkbAddGeomOverlayRow(ol,rWire->rowUnder,rWire->nKeys);
+ kWire= (xkbOverlayKeyWireDesc *)&rWire[1];
+ for (k=0;k<rWire->nKeys;k++,kWire++) {
+ if (XkbAddGeomOverlayKey(ol,row,
+ (char *)kWire->over,(char *)kWire->under)==NULL) {
+ client->errorValue= _XkbErrCode3(0x21,r,k);
+ return BadMatch;
+ }
+ }
+ rWire= (xkbOverlayRowWireDesc *)kWire;
+ }
+ olWire= (xkbOverlayWireDesc *)rWire;
+ wire= (char *)olWire;
+ *wire_inout= wire;
+ return Success;
+}
+
+static Status
+_CheckSetSections( XkbGeometryPtr geom,
+ xkbSetGeometryReq * req,
+ char ** wire_inout,
+ ClientPtr client)
+{
+Status status;
+register int s;
+char * wire;
+xkbSectionWireDesc * sWire;
+XkbSectionPtr section;
+
+ wire= *wire_inout;
+ if (req->nSections<1)
+ return Success;
+ sWire= (xkbSectionWireDesc *)wire;
+ for (s=0;s<req->nSections;s++) {
+ register int r;
+ xkbRowWireDesc * rWire;
+ if (client->swapped) {
+ register int n;
+ swapl(&sWire->name,n);
+ swaps(&sWire->top,n);
+ swaps(&sWire->left,n);
+ swaps(&sWire->width,n);
+ swaps(&sWire->height,n);
+ swaps(&sWire->angle,n);
+ }
+ CHK_ATOM_ONLY(sWire->name);
+ section= XkbAddGeomSection(geom,sWire->name,sWire->nRows,
+ sWire->nDoodads,sWire->nOverlays);
+ if (!section)
+ return BadAlloc;
+ section->priority= sWire->priority;
+ section->top= sWire->top;
+ section->left= sWire->left;
+ section->width= sWire->width;
+ section->height= sWire->height;
+ section->angle= sWire->angle;
+ rWire= (xkbRowWireDesc *)&sWire[1];
+ for (r=0;r<sWire->nRows;r++) {
+ register int k;
+ XkbRowPtr row;
+ xkbKeyWireDesc * kWire;
+ if (client->swapped) {
+ register int n;
+ swaps(&rWire->top,n);
+ swaps(&rWire->left,n);
+ }
+ row= XkbAddGeomRow(section,rWire->nKeys);
+ if (!row)
+ return BadAlloc;
+ row->top= rWire->top;
+ row->left= rWire->left;
+ row->vertical= rWire->vertical;
+ kWire= (xkbKeyWireDesc *)&rWire[1];
+ for (k=0;k<rWire->nKeys;k++) {
+ XkbKeyPtr key;
+ key= XkbAddGeomKey(row);
+ if (!key)
+ return BadAlloc;
+ memcpy(key->name.name,kWire[k].name,XkbKeyNameLength);
+ key->gap= kWire[k].gap;
+ key->shape_ndx= kWire[k].shapeNdx;
+ key->color_ndx= kWire[k].colorNdx;
+ if (key->shape_ndx>=geom->num_shapes) {
+ client->errorValue= _XkbErrCode3(0x10,key->shape_ndx,
+ geom->num_shapes);
+ return BadMatch;
+ }
+ if (key->color_ndx>=geom->num_colors) {
+ client->errorValue= _XkbErrCode3(0x11,key->color_ndx,
+ geom->num_colors);
+ return BadMatch;
+ }
+ }
+ rWire= (xkbRowWireDesc *)&kWire[rWire->nKeys];
+ }
+ wire= (char *)rWire;
+ if (sWire->nDoodads>0) {
+ register int d;
+ for (d=0;d<sWire->nDoodads;d++) {
+ status=_CheckSetDoodad(&wire,geom,section,client);
+ if (status!=Success)
+ return status;
+ }
+ }
+ if (sWire->nOverlays>0) {
+ register int o;
+ for (o=0;o<sWire->nOverlays;o++) {
+ status= _CheckSetOverlay(&wire,geom,section,client);
+ if (status!=Success)
+ return status;
+ }
+ }
+ sWire= (xkbSectionWireDesc *)wire;
+ }
+ wire= (char *)sWire;
+ *wire_inout= wire;
+ return Success;
+}
+
+static Status
+_CheckSetShapes( XkbGeometryPtr geom,
+ xkbSetGeometryReq * req,
+ char ** wire_inout,
+ ClientPtr client)
+{
+register int i;
+char * wire;
+
+ wire= *wire_inout;
+ if (req->nShapes<1) {
+ client->errorValue= _XkbErrCode2(0x06,req->nShapes);
+ return BadValue;
+ }
+ else {
+ xkbShapeWireDesc * shapeWire;
+ XkbShapePtr shape;
+ register int o;
+ shapeWire= (xkbShapeWireDesc *)wire;
+ for (i=0;i<req->nShapes;i++) {
+ xkbOutlineWireDesc * olWire;
+ XkbOutlinePtr ol;
+ shape= XkbAddGeomShape(geom,shapeWire->name,shapeWire->nOutlines);
+ if (!shape)
+ return BadAlloc;
+ olWire= (xkbOutlineWireDesc *)(&shapeWire[1]);
+ for (o=0;o<shapeWire->nOutlines;o++) {
+ register int p;
+ XkbPointPtr pt;
+ xkbPointWireDesc * ptWire;
+
+ ol= XkbAddGeomOutline(shape,olWire->nPoints);
+ if (!ol)
+ return BadAlloc;
+ ol->corner_radius= olWire->cornerRadius;
+ ptWire= (xkbPointWireDesc *)&olWire[1];
+ for (p=0,pt=ol->points;p<olWire->nPoints;p++,pt++) {
+ pt->x= ptWire[p].x;
+ pt->y= ptWire[p].y;
+ if (client->swapped) {
+ register int n;
+ swaps(&pt->x,n);
+ swaps(&pt->y,n);
+ }
+ }
+ ol->num_points= olWire->nPoints;
+ olWire= (xkbOutlineWireDesc *)(&ptWire[olWire->nPoints]);
+ }
+ if (shapeWire->primaryNdx!=XkbNoShape)
+ shape->primary= &shape->outlines[shapeWire->primaryNdx];
+ if (shapeWire->approxNdx!=XkbNoShape)
+ shape->approx= &shape->outlines[shapeWire->approxNdx];
+ shapeWire= (xkbShapeWireDesc *)olWire;
+ }
+ wire= (char *)shapeWire;
+ }
+ if (geom->num_shapes!=req->nShapes) {
+ client->errorValue= _XkbErrCode3(0x07,geom->num_shapes,req->nShapes);
+ return BadMatch;
+ }
+
+ *wire_inout= wire;
+ return Success;
+}
+
+static Status
+_CheckSetGeom( XkbGeometryPtr geom,
+ xkbSetGeometryReq * req,
+ ClientPtr client)
+{
+register int i;
+Status status;
+char * wire;
+
+ wire= (char *)&req[1];
+ geom->label_font= _GetCountedString(&wire,client->swapped);
+
+ for (i=0;i<req->nProperties;i++) {
+ char *name,*val;
+ name= _GetCountedString(&wire,client->swapped);
+ val= _GetCountedString(&wire,client->swapped);
+ if ((!name)||(!val)||(XkbAddGeomProperty(geom,name,val)==NULL))
+ return BadAlloc;
+ }
+
+ if (req->nColors<2) {
+ client->errorValue= _XkbErrCode3(0x01,2,req->nColors);
+ return BadValue;
+ }
+ if (req->baseColorNdx>req->nColors) {
+ client->errorValue=_XkbErrCode3(0x03,req->nColors,req->baseColorNdx);
+ return BadMatch;
+ }
+ if (req->labelColorNdx>req->nColors) {
+ client->errorValue= _XkbErrCode3(0x03,req->nColors,req->labelColorNdx);
+ return BadMatch;
+ }
+ if (req->labelColorNdx==req->baseColorNdx) {
+ client->errorValue= _XkbErrCode3(0x04,req->baseColorNdx,
+ req->labelColorNdx);
+ return BadMatch;
+ }
+
+ for (i=0;i<req->nColors;i++) {
+ char *name;
+ name= _GetCountedString(&wire,client->swapped);
+ if ((!name)||(!XkbAddGeomColor(geom,name,geom->num_colors)))
+ return BadAlloc;
+ }
+ if (req->nColors!=geom->num_colors) {
+ client->errorValue= _XkbErrCode3(0x05,req->nColors,geom->num_colors);
+ return BadMatch;
+ }
+ geom->label_color= &geom->colors[req->labelColorNdx];
+ geom->base_color= &geom->colors[req->baseColorNdx];
+
+ if ((status=_CheckSetShapes(geom,req,&wire,client))!=Success)
+ return status;
+
+ if ((status=_CheckSetSections(geom,req,&wire,client))!=Success)
+ return status;
+
+ for (i=0;i<req->nDoodads;i++) {
+ status=_CheckSetDoodad(&wire,geom,NULL,client);
+ if (status!=Success)
+ return status;
+ }
+
+ for (i=0;i<req->nKeyAliases;i++) {
+ if (XkbAddGeomKeyAlias(geom,&wire[XkbKeyNameLength],wire)==NULL)
+ return BadAlloc;
+ wire+= 2*XkbKeyNameLength;
+ }
+ return Success;
+}
+
+int
+ProcXkbSetGeometry(ClientPtr client)
+{
+ DeviceIntPtr dev;
+ XkbGeometryPtr geom,old;
+ XkbGeometrySizesRec sizes;
+ Status status;
+ XkbDescPtr xkb;
+ Bool new_name;
+ xkbNewKeyboardNotify nkn;
+
+ REQUEST(xkbSetGeometryReq);
+ REQUEST_AT_LEAST_SIZE(xkbSetGeometryReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_ATOM_OR_NONE(stuff->name);
+
+ xkb= dev->key->xkbInfo->desc;
+ old= xkb->geom;
+ xkb->geom= NULL;
+
+ sizes.which= XkbGeomAllMask;
+ sizes.num_properties= stuff->nProperties;
+ sizes.num_colors= stuff->nColors;
+ sizes.num_shapes= stuff->nShapes;
+ sizes.num_sections= stuff->nSections;
+ sizes.num_doodads= stuff->nDoodads;
+ sizes.num_key_aliases= stuff->nKeyAliases;
+ if ((status= XkbAllocGeometry(xkb,&sizes))!=Success) {
+ xkb->geom= old;
+ return status;
+ }
+ geom= xkb->geom;
+ geom->name= stuff->name;
+ geom->width_mm= stuff->widthMM;
+ geom->height_mm= stuff->heightMM;
+ if ((status= _CheckSetGeom(geom,stuff,client))!=Success) {
+ XkbFreeGeometry(geom,XkbGeomAllMask,True);
+ xkb->geom= old;
+ return status;
+ }
+ new_name= (xkb->names->geometry!=geom->name);
+ xkb->names->geometry= geom->name;
+ if (old)
+ XkbFreeGeometry(old,XkbGeomAllMask,True);
+ if (new_name) {
+ xkbNamesNotify nn;
+ bzero(&nn,sizeof(xkbNamesNotify));
+ nn.changed= XkbGeometryNameMask;
+ XkbSendNamesNotify(dev,&nn);
+ }
+ nkn.deviceID= nkn.oldDeviceID= dev->id;
+ nkn.minKeyCode= nkn.oldMinKeyCode= xkb->min_key_code;
+ nkn.maxKeyCode= nkn.oldMaxKeyCode= xkb->max_key_code;
+ nkn.requestMajor= XkbReqCode;
+ nkn.requestMinor= X_kbSetGeometry;
+ nkn.changed= XkbNKN_GeometryMask;
+ XkbSendNewKeyboardNotify(dev,&nkn);
+ return Success;
+}
+
+/***====================================================================***/
+
+int
+ProcXkbPerClientFlags(ClientPtr client)
+{
+ DeviceIntPtr dev;
+ xkbPerClientFlagsReply rep;
+ XkbInterestPtr interest;
+
+ REQUEST(xkbPerClientFlagsReq);
+ REQUEST_SIZE_MATCH(xkbPerClientFlagsReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_MASK_LEGAL(0x01,stuff->change,XkbPCF_AllFlagsMask);
+ CHK_MASK_MATCH(0x02,stuff->change,stuff->value);
+
+ interest = XkbFindClientResource((DevicePtr)dev,client);
+ rep.type= X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ if (stuff->change) {
+ client->xkbClientFlags&= ~stuff->change;
+ client->xkbClientFlags|= stuff->value;
+ }
+ if (stuff->change&XkbPCF_AutoResetControlsMask) {
+ Bool want;
+ want= stuff->value&XkbPCF_AutoResetControlsMask;
+ if (interest && !want) {
+ interest->autoCtrls= interest->autoCtrlValues= 0;
+ }
+ else if (want && (!interest)) {
+ XID id = FakeClientID(client->index);
+ AddResource(id,RT_XKBCLIENT,dev);
+ interest= XkbAddClientResource((DevicePtr)dev,client,id);
+ if (!interest)
+ return BadAlloc;
+ }
+ if (interest && want ) {
+ register unsigned affect;
+ affect= stuff->ctrlsToChange;
+
+ CHK_MASK_LEGAL(0x03,affect,XkbAllBooleanCtrlsMask);
+ CHK_MASK_MATCH(0x04,affect,stuff->autoCtrls);
+ CHK_MASK_MATCH(0x05,stuff->autoCtrls,stuff->autoCtrlValues);
+
+ interest->autoCtrls&= ~affect;
+ interest->autoCtrlValues&= ~affect;
+ interest->autoCtrls|= stuff->autoCtrls&affect;
+ interest->autoCtrlValues|= stuff->autoCtrlValues&affect;
+ }
+ }
+ rep.supported = XkbPCF_AllFlagsMask;
+ rep.value= client->xkbClientFlags&XkbPCF_AllFlagsMask;
+ if (interest) {
+ rep.autoCtrls= interest->autoCtrls;
+ rep.autoCtrlValues= interest->autoCtrlValues;
+ }
+ else {
+ rep.autoCtrls= rep.autoCtrlValues= 0;
+ }
+ if ( client->swapped ) {
+ register int n;
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.supported,n);
+ swapl(&rep.value,n);
+ swapl(&rep.autoCtrls,n);
+ swapl(&rep.autoCtrlValues,n);
+ }
+ WriteToClient(client,SIZEOF(xkbPerClientFlagsReply), (char *)&rep);
+ return client->noClientException;
+}
+
+/***====================================================================***/
+
+/* all latin-1 alphanumerics, plus parens, minus, underscore, slash */
+/* and wildcards */
+static unsigned char componentSpecLegal[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, 0xff, 0x87,
+ 0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff
+};
+
+/* same as above but accepts percent, plus and bar too */
+static unsigned char componentExprLegal[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0xaf, 0xff, 0x87,
+ 0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x17,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff
+};
+
+static char *
+GetComponentSpec(unsigned char **pWire,Bool allowExpr,int *errRtrn)
+{
+int len;
+register int i;
+unsigned char *wire,*str,*tmp,*legal;
+
+ if (allowExpr) legal= &componentExprLegal[0];
+ else legal= &componentSpecLegal[0];
+
+ wire= *pWire;
+ len= (*(unsigned char *)wire++);
+ if (len>0) {
+ str= (unsigned char *)_XkbCalloc(1, len+1);
+ if (str) {
+ tmp= str;
+ for (i=0;i<len;i++) {
+ if (legal[(*wire)/8]&(1<<((*wire)%8)))
+ *tmp++= *wire++;
+ else wire++;
+ }
+ if (tmp!=str)
+ *tmp++= '\0';
+ else {
+ _XkbFree(str);
+ str= NULL;
+ }
+ }
+ else {
+ *errRtrn= BadAlloc;
+ }
+ }
+ else {
+ str= NULL;
+ }
+ *pWire= wire;
+ return (char *)str;
+}
+
+/***====================================================================***/
+
+int
+ProcXkbListComponents(ClientPtr client)
+{
+ DeviceIntPtr dev;
+ xkbListComponentsReply rep;
+ unsigned len;
+ int status;
+ unsigned char * str;
+ XkbSrvListInfoRec list;
+
+ REQUEST(xkbListComponentsReq);
+ REQUEST_AT_LEAST_SIZE(xkbListComponentsReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+
+ status= Success;
+ str= (unsigned char *)&stuff[1];
+ bzero(&list,sizeof(XkbSrvListInfoRec));
+ list.maxRtrn= stuff->maxNames;
+ list.pattern[_XkbListKeymaps]= GetComponentSpec(&str,False,&status);
+ list.pattern[_XkbListKeycodes]= GetComponentSpec(&str,False,&status);
+ list.pattern[_XkbListTypes]= GetComponentSpec(&str,False,&status);
+ list.pattern[_XkbListCompat]= GetComponentSpec(&str,False,&status);
+ list.pattern[_XkbListSymbols]= GetComponentSpec(&str,False,&status);
+ list.pattern[_XkbListGeometry]= GetComponentSpec(&str,False,&status);
+ if (status!=Success)
+ return status;
+ len= str-((unsigned char *)stuff);
+ if ((XkbPaddedSize(len)/4)!=stuff->length)
+ return BadLength;
+ if ((status=XkbDDXList(dev,&list,client))!=Success) {
+ if (list.pool) {
+ _XkbFree(list.pool);
+ list.pool= NULL;
+ }
+ return status;
+ }
+ bzero(&rep,sizeof(xkbListComponentsReply));
+ rep.type= X_Reply;
+ rep.deviceID = dev->id;
+ rep.sequenceNumber = client->sequence;
+ rep.length = XkbPaddedSize(list.nPool)/4;
+ rep.nKeymaps = list.nFound[_XkbListKeymaps];
+ rep.nKeycodes = list.nFound[_XkbListKeycodes];
+ rep.nTypes = list.nFound[_XkbListTypes];
+ rep.nCompatMaps = list.nFound[_XkbListCompat];
+ rep.nSymbols = list.nFound[_XkbListSymbols];
+ rep.nGeometries = list.nFound[_XkbListGeometry];
+ rep.extra= 0;
+ if (list.nTotal>list.maxRtrn)
+ rep.extra = (list.nTotal-list.maxRtrn);
+ if (client->swapped) {
+ register int n;
+ swaps(&rep.sequenceNumber,n);
+ swapl(&rep.length,n);
+ swaps(&rep.nKeymaps,n);
+ swaps(&rep.nKeycodes,n);
+ swaps(&rep.nTypes,n);
+ swaps(&rep.nCompatMaps,n);
+ swaps(&rep.nSymbols,n);
+ swaps(&rep.nGeometries,n);
+ swaps(&rep.extra,n);
+ }
+ WriteToClient(client,SIZEOF(xkbListComponentsReply),(char *)&rep);
+ if (list.nPool && list.pool) {
+ WriteToClient(client,XkbPaddedSize(list.nPool), (char *)list.pool);
+ _XkbFree(list.pool);
+ list.pool= NULL;
+ }
+ return client->noClientException;
+}
+
+/***====================================================================***/
+
+int
+ProcXkbGetKbdByName(ClientPtr client)
+{
+ DeviceIntPtr dev;
+ XkbFileInfo finfo;
+ xkbGetKbdByNameReply rep;
+ xkbGetMapReply mrep;
+ xkbGetCompatMapReply crep;
+ xkbGetIndicatorMapReply irep;
+ xkbGetNamesReply nrep;
+ xkbGetGeometryReply grep;
+ XkbComponentNamesRec names;
+ XkbDescPtr xkb;
+ unsigned char * str;
+ char mapFile[PATH_MAX];
+ unsigned len;
+ unsigned fwant,fneed,reported;
+ int status;
+ Bool geom_changed;
+
+ REQUEST(xkbGetKbdByNameReq);
+ REQUEST_AT_LEAST_SIZE(xkbGetKbdByNameReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+
+ xkb = dev->key->xkbInfo->desc;
+ status= Success;
+ str= (unsigned char *)&stuff[1];
+ names.keymap= GetComponentSpec(&str,True,&status);
+ names.keycodes= GetComponentSpec(&str,True,&status);
+ names.types= GetComponentSpec(&str,True,&status);
+ names.compat= GetComponentSpec(&str,True,&status);
+ names.symbols= GetComponentSpec(&str,True,&status);
+ names.geometry= GetComponentSpec(&str,True,&status);
+ if (status!=Success)
+ return status;
+ len= str-((unsigned char *)stuff);
+ if ((XkbPaddedSize(len)/4)!=stuff->length)
+ return BadLength;
+
+ CHK_MASK_LEGAL(0x01,stuff->want,XkbGBN_AllComponentsMask);
+ CHK_MASK_LEGAL(0x02,stuff->need,XkbGBN_AllComponentsMask);
+
+ if (stuff->load)
+ fwant= XkbGBN_AllComponentsMask;
+ else fwant= stuff->want|stuff->need;
+ if (!names.keymap) {
+ if ((!names.compat)&&
+ (fwant&(XkbGBN_CompatMapMask|XkbGBN_IndicatorMapMask))) {
+ names.compat= _XkbDupString("%");
+ }
+ if ((!names.types)&&(fwant&(XkbGBN_TypesMask))) {
+ names.types= _XkbDupString("%");
+ }
+ if ((!names.symbols)&&(fwant&XkbGBN_SymbolsMask)) {
+ names.symbols= _XkbDupString("%");
+ }
+ geom_changed= ((names.geometry!=NULL)&&(strcmp(names.geometry,"%")!=0));
+ if ((!names.geometry)&&(fwant&XkbGBN_GeometryMask)) {
+ names.geometry= _XkbDupString("%");
+ geom_changed= False;
+ }
+ }
+ else {
+ geom_changed= True;
+ }
+
+ bzero(mapFile,PATH_MAX);
+ rep.type= X_Reply;
+ rep.deviceID = dev->id;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.minKeyCode = xkb->min_key_code;
+ rep.maxKeyCode = xkb->max_key_code;
+ rep.loaded= False;
+ fwant= XkbConvertGetByNameComponents(True,stuff->want)|XkmVirtualModsMask;
+ fneed= XkbConvertGetByNameComponents(True,stuff->need);
+ rep.reported= XkbConvertGetByNameComponents(False,fwant|fneed);
+ if (stuff->load) {
+ fneed|= XkmKeymapRequired;
+ fwant|= XkmKeymapLegal;
+ }
+ if ((fwant|fneed)&XkmSymbolsMask) {
+ fneed|= XkmKeyNamesIndex|XkmTypesIndex;
+ fwant|= XkmIndicatorsIndex;
+ }
+ rep.found = XkbDDXLoadKeymapByNames(dev,&names,fwant,fneed,&finfo,
+ mapFile,PATH_MAX);
+ rep.newKeyboard= False;
+ rep.pad1= rep.pad2= rep.pad3= rep.pad4= 0;
+
+ stuff->want|= stuff->need;
+ if (finfo.xkb==NULL)
+ rep.reported= 0;
+ else {
+ if (stuff->load)
+ rep.loaded= True;
+ if (stuff->load ||
+ ((rep.reported&XkbGBN_SymbolsMask) && (finfo.xkb->compat))) {
+ XkbChangesRec changes;
+ bzero(&changes,sizeof(changes));
+ XkbUpdateDescActions(finfo.xkb,
+ finfo.xkb->min_key_code,XkbNumKeys(finfo.xkb),
+ &changes);
+ }
+
+ if (finfo.xkb->map==NULL)
+ rep.reported&= ~(XkbGBN_SymbolsMask|XkbGBN_TypesMask);
+ else if (rep.reported&(XkbGBN_SymbolsMask|XkbGBN_TypesMask)) {
+ mrep.type= X_Reply;
+ mrep.deviceID = dev->id;
+ mrep.sequenceNumber= client->sequence;
+ mrep.length = ((SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply))>>2);
+ mrep.minKeyCode = finfo.xkb->min_key_code;
+ mrep.maxKeyCode = finfo.xkb->max_key_code;
+ mrep.present = 0;
+ mrep.totalSyms = mrep.totalActs =
+ mrep.totalKeyBehaviors= mrep.totalKeyExplicit=
+ mrep.totalModMapKeys= 0;
+ if (rep.reported&(XkbGBN_TypesMask|XkbGBN_ClientSymbolsMask)) {
+ mrep.present|= XkbKeyTypesMask;
+ mrep.firstType = 0;
+ mrep.nTypes = mrep.totalTypes= finfo.xkb->map->num_types;
+ }
+ else {
+ mrep.firstType = mrep.nTypes= 0;
+ mrep.totalTypes= 0;
+ }
+ if (rep.reported&XkbGBN_ClientSymbolsMask) {
+ mrep.present|= (XkbKeySymsMask|XkbModifierMapMask);
+ mrep.firstKeySym = mrep.firstModMapKey= finfo.xkb->min_key_code;
+ mrep.nKeySyms = mrep.nModMapKeys= XkbNumKeys(finfo.xkb);
+ }
+ else {
+ mrep.firstKeySym= mrep.firstModMapKey= 0;
+ mrep.nKeySyms= mrep.nModMapKeys= 0;
+ }
+ if (rep.reported&XkbGBN_ServerSymbolsMask) {
+ mrep.present|= XkbAllServerInfoMask;
+ mrep.virtualMods= ~0;
+ mrep.firstKeyAct = mrep.firstKeyBehavior =
+ mrep.firstKeyExplicit = finfo.xkb->min_key_code;
+ mrep.nKeyActs = mrep.nKeyBehaviors =
+ mrep.nKeyExplicit = XkbNumKeys(finfo.xkb);
+ }
+ else {
+ mrep.virtualMods= 0;
+ mrep.firstKeyAct= mrep.firstKeyBehavior=
+ mrep.firstKeyExplicit = 0;
+ mrep.nKeyActs= mrep.nKeyBehaviors= mrep.nKeyExplicit= 0;
+ }
+ XkbComputeGetMapReplySize(finfo.xkb,&mrep);
+ rep.length+= SIZEOF(xGenericReply)/4+mrep.length;
+ }
+ if (finfo.xkb->compat==NULL)
+ rep.reported&= ~XkbGBN_CompatMapMask;
+ else if (rep.reported&XkbGBN_CompatMapMask) {
+ crep.type= X_Reply;
+ crep.deviceID= dev->id;
+ crep.sequenceNumber= client->sequence;
+ crep.length= 0;
+ crep.groups= XkbAllGroupsMask;
+ crep.firstSI= 0;
+ crep.nSI= crep.nTotalSI= finfo.xkb->compat->num_si;
+ XkbComputeGetCompatMapReplySize(finfo.xkb->compat,&crep);
+ rep.length+= SIZEOF(xGenericReply)/4+crep.length;
+ }
+ if (finfo.xkb->indicators==NULL)
+ rep.reported&= ~XkbGBN_IndicatorMapMask;
+ else if (rep.reported&XkbGBN_IndicatorMapMask) {
+ irep.type= X_Reply;
+ irep.deviceID= dev->id;
+ irep.sequenceNumber= client->sequence;
+ irep.length= 0;
+ irep.which= XkbAllIndicatorsMask;
+ XkbComputeGetIndicatorMapReplySize(finfo.xkb->indicators,&irep);
+ rep.length+= SIZEOF(xGenericReply)/4+irep.length;
+ }
+ if (finfo.xkb->names==NULL)
+ rep.reported&= ~(XkbGBN_OtherNamesMask|XkbGBN_KeyNamesMask);
+ else if (rep.reported&(XkbGBN_OtherNamesMask|XkbGBN_KeyNamesMask)) {
+ nrep.type= X_Reply;
+ nrep.deviceID= dev->id;
+ nrep.sequenceNumber= client->sequence;
+ nrep.length= 0;
+ nrep.minKeyCode= finfo.xkb->min_key_code;
+ nrep.maxKeyCode= finfo.xkb->max_key_code;
+ if (rep.reported&XkbGBN_OtherNamesMask) {
+ nrep.which= XkbAllNamesMask;
+ if (finfo.xkb->map!=NULL)
+ nrep.nTypes= finfo.xkb->map->num_types;
+ else nrep.nTypes= 0;
+ nrep.nKTLevels= 0;
+ nrep.groupNames= XkbAllGroupsMask;
+ nrep.virtualMods= XkbAllVirtualModsMask;
+ nrep.indicators= XkbAllIndicatorsMask;
+ nrep.nRadioGroups= finfo.xkb->names->num_rg;
+ }
+ else {
+ nrep.which= 0;
+ nrep.nTypes= 0;
+ nrep.nKTLevels= 0;
+ nrep.groupNames= 0;
+ nrep.virtualMods= 0;
+ nrep.indicators= 0;
+ nrep.nRadioGroups= 0;
+ }
+ if (rep.reported&XkbGBN_KeyNamesMask) {
+ nrep.which|= XkbKeyNamesMask;
+ nrep.firstKey= finfo.xkb->min_key_code;
+ nrep.nKeys= XkbNumKeys(finfo.xkb);
+ nrep.nKeyAliases= finfo.xkb->names->num_key_aliases;
+ if (nrep.nKeyAliases)
+ nrep.which|= XkbKeyAliasesMask;
+ }
+ else {
+ nrep.which&= ~(XkbKeyNamesMask|XkbKeyAliasesMask);
+ nrep.firstKey= nrep.nKeys= 0;
+ nrep.nKeyAliases= 0;
+ }
+ XkbComputeGetNamesReplySize(finfo.xkb,&nrep);
+ rep.length+= SIZEOF(xGenericReply)/4+nrep.length;
+ }
+ if (finfo.xkb->geom==NULL)
+ rep.reported&= ~XkbGBN_GeometryMask;
+ else if (rep.reported&XkbGBN_GeometryMask) {
+ grep.type= X_Reply;
+ grep.deviceID= dev->id;
+ grep.sequenceNumber= client->sequence;
+ grep.length= 0;
+ grep.found= True;
+ grep.pad= 0;
+ grep.widthMM= grep.heightMM= 0;
+ grep.nProperties= grep.nColors= grep.nShapes= 0;
+ grep.nSections= grep.nDoodads= 0;
+ grep.baseColorNdx= grep.labelColorNdx= 0;
+ XkbComputeGetGeometryReplySize(finfo.xkb->geom,&grep,None);
+ rep.length+= SIZEOF(xGenericReply)/4+grep.length;
+ }
+ }
+
+ reported= rep.reported;
+ if ( client->swapped ) {
+ register int n;
+ swaps(&rep.sequenceNumber,n);
+ swapl(&rep.length,n);
+ swaps(&rep.found,n);
+ swaps(&rep.reported,n);
+ }
+ WriteToClient(client,SIZEOF(xkbGetKbdByNameReply), (char *)&rep);
+ if (reported&(XkbGBN_SymbolsMask|XkbGBN_TypesMask))
+ XkbSendMap(client,finfo.xkb,&mrep);
+ if (reported&XkbGBN_CompatMapMask)
+ XkbSendCompatMap(client,finfo.xkb->compat,&crep);
+ if (reported&XkbGBN_IndicatorMapMask)
+ XkbSendIndicatorMap(client,finfo.xkb->indicators,&irep);
+ if (reported&(XkbGBN_KeyNamesMask|XkbGBN_OtherNamesMask))
+ XkbSendNames(client,finfo.xkb,&nrep);
+ if (reported&XkbGBN_GeometryMask)
+ XkbSendGeometry(client,finfo.xkb->geom,&grep,False);
+ if (rep.loaded) {
+ XkbDescPtr old_xkb;
+ xkbNewKeyboardNotify nkn;
+ int i,nG,nTG;
+ old_xkb= xkb;
+ xkb= finfo.xkb;
+ dev->key->xkbInfo->desc= xkb;
+ finfo.xkb= old_xkb; /* so it'll get freed automatically */
+
+ *xkb->ctrls= *old_xkb->ctrls;
+ for (nG=nTG=0,i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ nG= XkbKeyNumGroups(xkb,i);
+ if (nG>=XkbNumKbdGroups) {
+ nTG= XkbNumKbdGroups;
+ break;
+ }
+ if (nG>nTG) {
+ nTG= nG;
+ }
+ }
+ xkb->ctrls->num_groups= nTG;
+
+ memcpy(dev->key->modifierMap,xkb->map->modmap,xkb->max_key_code+1);
+ XkbUpdateCoreDescription(dev,True);
+
+ if (dev->kbdfeed && dev->kbdfeed->xkb_sli) {
+ XkbSrvLedInfoPtr old_sli;
+ XkbSrvLedInfoPtr sli;
+ old_sli = dev->kbdfeed->xkb_sli;
+ dev->kbdfeed->xkb_sli = NULL;
+ sli = XkbAllocSrvLedInfo(dev,dev->kbdfeed,NULL,0);
+ if (sli) {
+ sli->explicitState = old_sli->explicitState;
+ sli->effectiveState = old_sli->effectiveState;
+ }
+ dev->kbdfeed->xkb_sli = sli;
+ XkbFreeSrvLedInfo(old_sli);
+ }
+
+ nkn.deviceID= nkn.oldDeviceID= dev->id;
+ nkn.minKeyCode= finfo.xkb->min_key_code;
+ nkn.maxKeyCode= finfo.xkb->max_key_code;
+ nkn.oldMinKeyCode= xkb->min_key_code;
+ nkn.oldMaxKeyCode= xkb->max_key_code;
+ nkn.requestMajor= XkbReqCode;
+ nkn.requestMinor= X_kbGetKbdByName;
+ nkn.changed= XkbNKN_KeycodesMask;
+ if (geom_changed)
+ nkn.changed|= XkbNKN_GeometryMask;
+ XkbSendNewKeyboardNotify(dev,&nkn);
+ }
+ if ((finfo.xkb!=NULL)&&(finfo.xkb!=xkb)) {
+ XkbFreeKeyboard(finfo.xkb,XkbAllComponentsMask,True);
+ finfo.xkb= NULL;
+ }
+ if (names.keymap) { _XkbFree(names.keymap); names.keymap= NULL; }
+ if (names.keycodes) { _XkbFree(names.keycodes); names.keycodes= NULL; }
+ if (names.types) { _XkbFree(names.types); names.types= NULL; }
+ if (names.compat) { _XkbFree(names.compat); names.compat= NULL; }
+ if (names.symbols) { _XkbFree(names.symbols); names.symbols= NULL; }
+ if (names.geometry) { _XkbFree(names.geometry); names.geometry= NULL; }
+ return client->noClientException;
+}
+
+/***====================================================================***/
+
+static int
+ComputeDeviceLedInfoSize( DeviceIntPtr dev,
+ unsigned int what,
+ XkbSrvLedInfoPtr sli)
+{
+int nNames,nMaps;
+register unsigned n,bit;
+
+ if (sli==NULL)
+ return 0;
+ nNames= nMaps= 0;
+ if ((what&XkbXI_IndicatorNamesMask)==0)
+ sli->namesPresent= 0;
+ if ((what&XkbXI_IndicatorMapsMask)==0)
+ sli->mapsPresent= 0;
+
+ for (n=0,bit=1;n<XkbNumIndicators;n++,bit<<=1) {
+ if (sli->names && sli->names[n]!=None) {
+ sli->namesPresent|= bit;
+ nNames++;
+ }
+ if (sli->maps && XkbIM_InUse(&sli->maps[n])) {
+ sli->mapsPresent|= bit;
+ nMaps++;
+ }
+ }
+ return (nNames*4)+(nMaps*SIZEOF(xkbIndicatorMapWireDesc));
+}
+
+static int
+CheckDeviceLedFBs( DeviceIntPtr dev,
+ int class,
+ int id,
+ xkbGetDeviceInfoReply * rep,
+ ClientPtr client)
+{
+int nFBs= 0;
+int length= 0;
+Bool classOk;
+
+ if (class==XkbDfltXIClass) {
+ if (dev->kbdfeed) class= KbdFeedbackClass;
+ else if (dev->leds) class= LedFeedbackClass;
+ else {
+ client->errorValue= _XkbErrCode2(XkbErr_BadClass,class);
+ return XkbKeyboardErrorCode;
+ }
+ }
+ classOk= False;
+ if ((dev->kbdfeed)&&((class==KbdFeedbackClass)||(class==XkbAllXIClasses))) {
+ KbdFeedbackPtr kf;
+ classOk= True;
+ for (kf= dev->kbdfeed;(kf);kf=kf->next) {
+ if ((id!=XkbAllXIIds)&&(id!=XkbDfltXIId)&&(id!=kf->ctrl.id))
+ continue;
+ nFBs++;
+ length+= SIZEOF(xkbDeviceLedsWireDesc);
+ if (!kf->xkb_sli)
+ kf->xkb_sli= XkbAllocSrvLedInfo(dev,kf,NULL,0);
+ length+= ComputeDeviceLedInfoSize(dev,rep->present,kf->xkb_sli);
+ if (id!=XkbAllXIIds)
+ break;
+ }
+ }
+ if ((dev->leds)&&((class==LedFeedbackClass)||(class==XkbAllXIClasses))) {
+ LedFeedbackPtr lf;
+ classOk= True;
+ for (lf= dev->leds;(lf);lf=lf->next) {
+ if ((id!=XkbAllXIIds)&&(id!=XkbDfltXIId)&&(id!=lf->ctrl.id))
+ continue;
+ nFBs++;
+ length+= SIZEOF(xkbDeviceLedsWireDesc);
+ if (!lf->xkb_sli)
+ lf->xkb_sli= XkbAllocSrvLedInfo(dev,NULL,lf,0);
+ length+= ComputeDeviceLedInfoSize(dev,rep->present,lf->xkb_sli);
+ if (id!=XkbAllXIIds)
+ break;
+ }
+ }
+ if (nFBs>0) {
+ if (rep->supported&XkbXI_IndicatorsMask) {
+ rep->nDeviceLedFBs= nFBs;
+ rep->length+= (length/4);
+ }
+ return Success;
+ }
+ if (classOk) client->errorValue= _XkbErrCode2(XkbErr_BadId,id);
+ else client->errorValue= _XkbErrCode2(XkbErr_BadClass,class);
+ return XkbKeyboardErrorCode;
+}
+
+static int
+SendDeviceLedInfo( XkbSrvLedInfoPtr sli,
+ ClientPtr client)
+{
+xkbDeviceLedsWireDesc wire;
+int length;
+
+ length= 0;
+ wire.ledClass= sli->class;
+ wire.ledID= sli->id;
+ wire.namesPresent= sli->namesPresent;
+ wire.mapsPresent= sli->mapsPresent;
+ wire.physIndicators= sli->physIndicators;
+ wire.state= sli->effectiveState;
+ if (client->swapped) {
+ register int n;
+ swaps(&wire.ledClass,n);
+ swaps(&wire.ledID,n);
+ swapl(&wire.namesPresent,n);
+ swapl(&wire.mapsPresent,n);
+ swapl(&wire.physIndicators,n);
+ swapl(&wire.state,n);
+ }
+ WriteToClient(client,SIZEOF(xkbDeviceLedsWireDesc),(char *)&wire);
+ length+= SIZEOF(xkbDeviceLedsWireDesc);
+ if (sli->namesPresent|sli->mapsPresent) {
+ register unsigned i,bit;
+ if (sli->namesPresent) {
+ CARD32 awire;
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (sli->namesPresent&bit) {
+ awire= (CARD32)sli->names[i];
+ if (client->swapped) {
+ register int n;
+ swapl(&awire,n);
+ }
+ WriteToClient(client,4,(char *)&awire);
+ length+= 4;
+ }
+ }
+ }
+ if (sli->mapsPresent) {
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ xkbIndicatorMapWireDesc iwire;
+ if (sli->mapsPresent&bit) {
+ iwire.flags= sli->maps[i].flags;
+ iwire.whichGroups= sli->maps[i].which_groups;
+ iwire.groups= sli->maps[i].groups;
+ iwire.whichMods= sli->maps[i].which_mods;
+ iwire.mods= sli->maps[i].mods.mask;
+ iwire.realMods= sli->maps[i].mods.real_mods;
+ iwire.virtualMods= sli->maps[i].mods.vmods;
+ iwire.ctrls= sli->maps[i].ctrls;
+ if (client->swapped) {
+ register int n;
+ swaps(&iwire.virtualMods,n);
+ swapl(&iwire.ctrls,n);
+ }
+ WriteToClient(client,SIZEOF(xkbIndicatorMapWireDesc),
+ (char *)&iwire);
+ length+= SIZEOF(xkbIndicatorMapWireDesc);
+ }
+ }
+ }
+ }
+ return length;
+}
+
+static int
+SendDeviceLedFBs( DeviceIntPtr dev,
+ int class,
+ int id,
+ unsigned wantLength,
+ ClientPtr client)
+{
+int length= 0;
+
+ if (class==XkbDfltXIClass) {
+ if (dev->kbdfeed) class= KbdFeedbackClass;
+ else if (dev->leds) class= LedFeedbackClass;
+ }
+ if ((dev->kbdfeed)&&
+ ((class==KbdFeedbackClass)||(class==XkbAllXIClasses))) {
+ KbdFeedbackPtr kf;
+ for (kf= dev->kbdfeed;(kf);kf=kf->next) {
+ if ((id==XkbAllXIIds)||(id==XkbDfltXIId)||(id==kf->ctrl.id)) {
+ length+= SendDeviceLedInfo(kf->xkb_sli,client);
+ if (id!=XkbAllXIIds)
+ break;
+ }
+ }
+ }
+ if ((dev->leds)&&
+ ((class==LedFeedbackClass)||(class==XkbAllXIClasses))) {
+ LedFeedbackPtr lf;
+ for (lf= dev->leds;(lf);lf=lf->next) {
+ if ((id==XkbAllXIIds)||(id==XkbDfltXIId)||(id==lf->ctrl.id)) {
+ length+= SendDeviceLedInfo(lf->xkb_sli,client);
+ if (id!=XkbAllXIIds)
+ break;
+ }
+ }
+ }
+ if (length==wantLength)
+ return Success;
+ else return BadLength;
+}
+
+int
+ProcXkbGetDeviceInfo(ClientPtr client)
+{
+DeviceIntPtr dev;
+xkbGetDeviceInfoReply rep;
+int status,nDeviceLedFBs;
+unsigned length,nameLen;
+CARD16 ledClass,ledID;
+unsigned wanted,supported;
+char * str;
+
+ REQUEST(xkbGetDeviceInfoReq);
+ REQUEST_SIZE_MATCH(xkbGetDeviceInfoReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ wanted= stuff->wanted;
+
+ CHK_ANY_DEVICE(dev,stuff->deviceSpec);
+ CHK_MASK_LEGAL(0x01,wanted,XkbXI_AllDeviceFeaturesMask);
+
+ if ((!dev->button)||((stuff->nBtns<1)&&(!stuff->allBtns)))
+ wanted&= ~XkbXI_ButtonActionsMask;
+ if ((!dev->kbdfeed)&&(!dev->leds))
+ wanted&= ~XkbXI_IndicatorsMask;
+ wanted&= ~XkbXIUnsupported;
+
+ nameLen= XkbSizeCountedString(dev->name);
+ bzero((char *)&rep,SIZEOF(xkbGetDeviceInfoReply));
+ rep.type = X_Reply;
+ rep.deviceID= dev->id;
+ rep.sequenceNumber = client->sequence;
+ rep.length = nameLen/4;
+ rep.present = wanted;
+ rep.supported = XkbXI_AllDeviceFeaturesMask&(~XkbXIUnsupported);
+ rep.unsupported = XkbXIUnsupported;
+ rep.firstBtnWanted = rep.nBtnsWanted = 0;
+ rep.firstBtnRtrn = rep.nBtnsRtrn = 0;
+ if (dev->button)
+ rep.totalBtns= dev->button->numButtons;
+ else rep.totalBtns= 0;
+ rep.devType= dev->type;
+ rep.hasOwnState= (dev->key && dev->key->xkbInfo);
+ rep.nDeviceLedFBs = 0;
+ if (dev->kbdfeed) rep.dfltKbdFB= dev->kbdfeed->ctrl.id;
+ else rep.dfltKbdFB= XkbXINone;
+ if (dev->leds) rep.dfltLedFB= dev->leds->ctrl.id;
+ else rep.dfltLedFB= XkbXINone;
+
+ ledClass= stuff->ledClass;
+ ledID= stuff->ledID;
+
+ rep.firstBtnWanted= rep.nBtnsWanted= 0;
+ rep.firstBtnRtrn= rep.nBtnsRtrn= 0;
+ if (wanted&XkbXI_ButtonActionsMask) {
+ if (stuff->allBtns) {
+ stuff->firstBtn= 0;
+ stuff->nBtns= dev->button->numButtons;
+ }
+
+ if ((stuff->firstBtn+stuff->nBtns)>dev->button->numButtons) {
+ client->errorValue = _XkbErrCode4(0x02,dev->button->numButtons,
+ stuff->firstBtn,
+ stuff->nBtns);
+ return BadValue;
+ }
+ else {
+ rep.firstBtnWanted= stuff->firstBtn;
+ rep.nBtnsWanted= stuff->nBtns;
+ if (dev->button->xkb_acts!=NULL) {
+ XkbAction *act;
+ register int i;
+
+ rep.firstBtnRtrn= stuff->firstBtn;
+ rep.nBtnsRtrn= stuff->nBtns;
+ act= &dev->button->xkb_acts[rep.firstBtnWanted];
+ for (i=0;i<rep.nBtnsRtrn;i++,act++) {
+ if (act->type!=XkbSA_NoAction)
+ break;
+ }
+ rep.firstBtnRtrn+= i;
+ rep.nBtnsRtrn-= i;
+ act= &dev->button->xkb_acts[rep.firstBtnRtrn+rep.nBtnsRtrn-1];
+ for (i=0;i<rep.nBtnsRtrn;i++,act--) {
+ if (act->type!=XkbSA_NoAction)
+ break;
+ }
+ rep.nBtnsRtrn-= i;
+ }
+ rep.length+= (rep.nBtnsRtrn*SIZEOF(xkbActionWireDesc))/4;
+ }
+ }
+
+ if (wanted&XkbXI_IndicatorsMask) {
+ status= CheckDeviceLedFBs(dev,ledClass,ledID,&rep,client);
+ if (status!=Success)
+ return status;
+ }
+ length= rep.length*4;
+ supported= rep.supported;
+ nDeviceLedFBs = rep.nDeviceLedFBs;
+ if (client->swapped) {
+ register int n;
+ swaps(&rep.sequenceNumber,n);
+ swapl(&rep.length,n);
+ swaps(&rep.present,n);
+ swaps(&rep.supported,n);
+ swaps(&rep.unsupported,n);
+ swaps(&rep.nDeviceLedFBs,n);
+ swapl(&rep.type,n);
+ }
+ WriteToClient(client,SIZEOF(xkbGetDeviceInfoReply), (char *)&rep);
+
+ str= (char*) ALLOCATE_LOCAL(nameLen);
+ if (!str)
+ return BadAlloc;
+ XkbWriteCountedString(str,dev->name,client->swapped);
+ WriteToClient(client,nameLen,str);
+ DEALLOCATE_LOCAL(str);
+ length-= nameLen;
+
+ if (rep.nBtnsRtrn>0) {
+ int sz;
+ xkbActionWireDesc * awire;
+ sz= rep.nBtnsRtrn*SIZEOF(xkbActionWireDesc);
+ awire= (xkbActionWireDesc *)&dev->button->xkb_acts[rep.firstBtnRtrn];
+ WriteToClient(client,sz,(char *)awire);
+ length-= sz;
+ }
+ if (nDeviceLedFBs>0) {
+ status= SendDeviceLedFBs(dev,ledClass,ledID,length,client);
+ if (status!=Success)
+ return status;
+ }
+ else if (length!=0) {
+#ifdef DEBUG
+ ErrorF("Internal Error! BadLength in ProcXkbGetDeviceInfo\n");
+ ErrorF(" Wrote %d fewer bytes than expected\n",length);
+#endif
+ return BadLength;
+ }
+ if (stuff->wanted&(~supported)) {
+ xkbExtensionDeviceNotify ed;
+ bzero((char *)&ed,SIZEOF(xkbExtensionDeviceNotify));
+ ed.ledClass= ledClass;
+ ed.ledID= ledID;
+ ed.ledsDefined= 0;
+ ed.ledState= 0;
+ ed.firstBtn= ed.nBtns= 0;
+ ed.reason= XkbXI_UnsupportedFeatureMask;
+ ed.supported= supported;
+ ed.unsupported= stuff->wanted&(~supported);
+ XkbSendExtensionDeviceNotify(dev,client,&ed);
+ }
+ return client->noClientException;
+}
+
+static char *
+CheckSetDeviceIndicators( char * wire,
+ DeviceIntPtr dev,
+ int num,
+ int * status_rtrn,
+ ClientPtr client)
+{
+xkbDeviceLedsWireDesc * ledWire;
+int i;
+XkbSrvLedInfoPtr sli;
+
+ ledWire= (xkbDeviceLedsWireDesc *)wire;
+ for (i=0;i<num;i++) {
+ if (client->swapped) {
+ register int n;
+ swaps(&ledWire->ledClass,n);
+ swaps(&ledWire->ledID,n);
+ swapl(&ledWire->namesPresent,n);
+ swapl(&ledWire->mapsPresent,n);
+ swapl(&ledWire->physIndicators,n);
+ }
+
+ sli= XkbFindSrvLedInfo(dev,ledWire->ledClass,ledWire->ledID,
+ XkbXI_IndicatorsMask);
+ if (sli!=NULL) {
+ register int n;
+ register unsigned bit;
+ int nMaps,nNames;
+ CARD32 *atomWire;
+ xkbIndicatorMapWireDesc *mapWire;
+
+ nMaps= nNames= 0;
+ for (n=0,bit=1;n<XkbNumIndicators;n++,bit<<=1) {
+ if (ledWire->namesPresent&bit)
+ nNames++;
+ if (ledWire->mapsPresent&bit)
+ nMaps++;
+ }
+ atomWire= (CARD32 *)&ledWire[1];
+ if (nNames>0) {
+ for (n=0;n<nNames;n++) {
+ if (client->swapped) {
+ register int t;
+ swapl(atomWire,t);
+ }
+ CHK_ATOM_OR_NONE3(((Atom)(*atomWire)),client->errorValue,
+ *status_rtrn,NULL);
+ atomWire++;
+ }
+ }
+ mapWire= (xkbIndicatorMapWireDesc *)atomWire;
+ if (nMaps>0) {
+ for (n=0;n<nMaps;n++) {
+ if (client->swapped) {
+ register int t;
+ swaps(&mapWire->virtualMods,t);
+ swapl(&mapWire->ctrls,t);
+ }
+ CHK_MASK_LEGAL3(0x21,mapWire->whichGroups,
+ XkbIM_UseAnyGroup,
+ client->errorValue,
+ *status_rtrn,NULL);
+ CHK_MASK_LEGAL3(0x22,mapWire->whichMods,XkbIM_UseAnyMods,
+ client->errorValue,
+ *status_rtrn,NULL);
+ mapWire++;
+ }
+ }
+ ledWire= (xkbDeviceLedsWireDesc *)mapWire;
+ }
+ else {
+ /* SHOULD NEVER HAPPEN */
+ return (char *)ledWire;
+ }
+ }
+ return (char *)ledWire;
+}
+
+static char *
+SetDeviceIndicators( char * wire,
+ DeviceIntPtr dev,
+ unsigned changed,
+ int num,
+ int * status_rtrn,
+ ClientPtr client,
+ xkbExtensionDeviceNotify *ev)
+{
+xkbDeviceLedsWireDesc * ledWire;
+int i;
+XkbEventCauseRec cause;
+unsigned namec,mapc,statec;
+xkbExtensionDeviceNotify ed;
+XkbChangesRec changes;
+DeviceIntPtr kbd;
+
+ bzero((char *)&ed,sizeof(xkbExtensionDeviceNotify));
+ bzero((char *)&changes,sizeof(XkbChangesRec));
+ XkbSetCauseXkbReq(&cause,X_kbSetDeviceInfo,client);
+ ledWire= (xkbDeviceLedsWireDesc *)wire;
+ for (i=0;i<num;i++) {
+ register int n;
+ register unsigned bit;
+ CARD32 * atomWire;
+ xkbIndicatorMapWireDesc * mapWire;
+ XkbSrvLedInfoPtr sli;
+
+ namec= mapc= statec= 0;
+ sli= XkbFindSrvLedInfo(dev,ledWire->ledClass,ledWire->ledID,
+ XkbXI_IndicatorMapsMask);
+ if (!sli) {
+ /* SHOULD NEVER HAPPEN!! */
+ return (char *)ledWire;
+ }
+
+ atomWire= (CARD32 *)&ledWire[1];
+ if (changed&XkbXI_IndicatorNamesMask) {
+ namec= sli->namesPresent|ledWire->namesPresent;
+ bzero((char *)sli->names,XkbNumIndicators*sizeof(Atom));
+ }
+ if (ledWire->namesPresent) {
+ sli->namesPresent= ledWire->namesPresent;
+ bzero((char *)sli->names,XkbNumIndicators*sizeof(Atom));
+ for (n=0,bit=1;n<XkbNumIndicators;n++,bit<<=1) {
+ if (ledWire->namesPresent&bit) {
+ sli->names[n]= (Atom)*atomWire;
+ if (sli->names[n]==None)
+ ledWire->namesPresent&= ~bit;
+ atomWire++;
+ }
+ }
+ }
+ mapWire= (xkbIndicatorMapWireDesc *)atomWire;
+ if (changed&XkbXI_IndicatorMapsMask) {
+ mapc= sli->mapsPresent|ledWire->mapsPresent;
+ sli->mapsPresent= ledWire->mapsPresent;
+ bzero((char*)sli->maps,XkbNumIndicators*sizeof(XkbIndicatorMapRec));
+ }
+ if (ledWire->mapsPresent) {
+ for (n=0,bit=1;n<XkbNumIndicators;n++,bit<<=1) {
+ if (ledWire->mapsPresent&bit) {
+ sli->maps[n].flags= mapWire->flags;
+ sli->maps[n].which_groups= mapWire->whichGroups;
+ sli->maps[n].groups= mapWire->groups;
+ sli->maps[n].which_mods= mapWire->whichMods;
+ sli->maps[n].mods.mask= mapWire->mods;
+ sli->maps[n].mods.real_mods=mapWire->realMods;
+ sli->maps[n].mods.vmods= mapWire->virtualMods;
+ sli->maps[n].ctrls= mapWire->ctrls;
+ mapWire++;
+ }
+ }
+ }
+ if (changed&XkbXI_IndicatorStateMask) {
+ statec= sli->effectiveState^ledWire->state;
+ sli->explicitState&= ~statec;
+ sli->explicitState|= (ledWire->state&statec);
+ }
+ if (namec)
+ XkbApplyLedNameChanges(dev,sli,namec,&ed,&changes,&cause);
+ if (mapc)
+ XkbApplyLedMapChanges(dev,sli,mapc,&ed,&changes,&cause);
+ if (statec)
+ XkbApplyLedStateChanges(dev,sli,statec,&ed,&changes,&cause);
+
+ kbd= dev;
+ if ((sli->flags&XkbSLI_HasOwnState)==0)
+ kbd= (DeviceIntPtr)LookupKeyboardDevice();
+
+ XkbFlushLedEvents(dev,kbd,sli,&ed,&changes,&cause);
+ ledWire= (xkbDeviceLedsWireDesc *)mapWire;
+ }
+ return (char *)ledWire;
+}
+
+int
+ProcXkbSetDeviceInfo(ClientPtr client)
+{
+DeviceIntPtr dev;
+unsigned change;
+char * wire;
+xkbExtensionDeviceNotify ed;
+
+ REQUEST(xkbSetDeviceInfoReq);
+ REQUEST_AT_LEAST_SIZE(xkbSetDeviceInfoReq);
+
+ if (!(client->xkbClientFlags&_XkbClientInitialized))
+ return BadAccess;
+
+ change= stuff->change;
+
+ CHK_ANY_DEVICE(dev,stuff->deviceSpec);
+ CHK_MASK_LEGAL(0x01,change,(XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask)));
+
+ wire= (char *)&stuff[1];
+ if (change&XkbXI_ButtonActionsMask) {
+ if (!dev->button) {
+ client->errorValue = _XkbErrCode2(XkbErr_BadClass,ButtonClass);
+ return XkbKeyboardErrorCode;
+ }
+ if ((stuff->firstBtn+stuff->nBtns)>dev->button->numButtons) {
+ client->errorValue= _XkbErrCode4(0x02,stuff->firstBtn,stuff->nBtns,
+ dev->button->numButtons);
+ return BadMatch;
+ }
+ wire+= (stuff->nBtns*SIZEOF(xkbActionWireDesc));
+ }
+ if (stuff->change&XkbXI_IndicatorsMask) {
+ int status= Success;
+ wire= CheckSetDeviceIndicators(wire,dev,stuff->nDeviceLedFBs,
+ &status,client);
+ if (status!=Success)
+ return status;
+ }
+ if (((wire-((char *)stuff))/4)!=stuff->length)
+ return BadLength;
+
+ bzero((char *)&ed,SIZEOF(xkbExtensionDeviceNotify));
+ ed.deviceID= dev->id;
+ wire= (char *)&stuff[1];
+ if (change&XkbXI_ButtonActionsMask) {
+ int nBtns,sz,i;
+ XkbAction * acts;
+ DeviceIntPtr kbd;
+
+ nBtns= dev->button->numButtons;
+ acts= dev->button->xkb_acts;
+ if (acts==NULL) {
+ acts= _XkbTypedCalloc(nBtns,XkbAction);
+ if (!acts)
+ return BadAlloc;
+ dev->button->xkb_acts= acts;
+ }
+ sz= stuff->nBtns*SIZEOF(xkbActionWireDesc);
+ memcpy((char *)&acts[stuff->firstBtn],(char *)wire,sz);
+ wire+= sz;
+ ed.reason|= XkbXI_ButtonActionsMask;
+ ed.firstBtn= stuff->firstBtn;
+ ed.nBtns= stuff->nBtns;
+
+ if (dev->key) kbd= dev;
+ else kbd= (DeviceIntPtr)LookupKeyboardDevice();
+ acts= &dev->button->xkb_acts[stuff->firstBtn];
+ for (i=0;i<stuff->nBtns;i++,acts++) {
+ if (acts->type!=XkbSA_NoAction)
+ XkbSetActionKeyMods(kbd->key->xkbInfo->desc,acts,0);
+ }
+ }
+ if (stuff->change&XkbXI_IndicatorsMask) {
+ int status= Success;
+ wire= SetDeviceIndicators(wire,dev,change,stuff->nDeviceLedFBs,
+ &status,client,&ed);
+ if (status!=Success)
+ return status;
+ }
+ if ((stuff->change)&&(ed.reason))
+ XkbSendExtensionDeviceNotify(dev,client,&ed);
+ return client->noClientException;
+}
+
+/***====================================================================***/
+
+int
+ProcXkbSetDebuggingFlags(ClientPtr client)
+{
+CARD32 newFlags,newCtrls,extraLength;
+xkbSetDebuggingFlagsReply rep;
+
+ REQUEST(xkbSetDebuggingFlagsReq);
+ REQUEST_AT_LEAST_SIZE(xkbSetDebuggingFlagsReq);
+
+ newFlags= xkbDebugFlags&(~stuff->affectFlags);
+ newFlags|= (stuff->flags&stuff->affectFlags);
+ newCtrls= xkbDebugCtrls&(~stuff->affectCtrls);
+ newCtrls|= (stuff->ctrls&stuff->affectCtrls);
+ if (xkbDebugFlags || newFlags || stuff->msgLength) {
+ ErrorF("XkbDebug: Setting debug flags to 0x%lx\n",(long)newFlags);
+ if (newCtrls!=xkbDebugCtrls)
+ ErrorF("XkbDebug: Setting debug controls to 0x%lx\n",(long)newCtrls);
+ }
+ extraLength= (stuff->length<<2)-sz_xkbSetDebuggingFlagsReq;
+ if (stuff->msgLength>0) {
+ char *msg;
+ if (extraLength<XkbPaddedSize(stuff->msgLength)) {
+ ErrorF("XkbDebug: msgLength= %d, length= %ld (should be %d)\n",
+ stuff->msgLength,(long)extraLength,
+ XkbPaddedSize(stuff->msgLength));
+ return BadLength;
+ }
+ msg= (char *)&stuff[1];
+ if (msg[stuff->msgLength-1]!='\0') {
+ ErrorF("XkbDebug: message not null-terminated\n");
+ return BadValue;
+ }
+ ErrorF("XkbDebug: %s\n",msg);
+ }
+ xkbDebugFlags = newFlags;
+ xkbDebugCtrls = newCtrls;
+
+ XkbDisableLockActions= (xkbDebugCtrls&XkbDF_DisableLocks);
+
+ rep.type= X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.currentFlags = newFlags;
+ rep.currentCtrls = newCtrls;
+ rep.supportedFlags = ~0;
+ rep.supportedCtrls = ~0;
+ if ( client->swapped ) {
+ register int n;
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.currentFlags, n);
+ swapl(&rep.currentCtrls, n);
+ swapl(&rep.supportedFlags, n);
+ swapl(&rep.supportedCtrls, n);
+ }
+ WriteToClient(client,SIZEOF(xkbSetDebuggingFlagsReply), (char *)&rep);
+ return client->noClientException;
+}
+
+/***====================================================================***/
+
+static int
+ProcXkbDispatch (ClientPtr client)
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_kbUseExtension:
+ return ProcXkbUseExtension(client);
+ case X_kbSelectEvents:
+ return ProcXkbSelectEvents(client);
+ case X_kbBell:
+ return ProcXkbBell(client);
+ case X_kbGetState:
+ return ProcXkbGetState(client);
+ case X_kbLatchLockState:
+ return ProcXkbLatchLockState(client);
+ case X_kbGetControls:
+ return ProcXkbGetControls(client);
+ case X_kbSetControls:
+ return ProcXkbSetControls(client);
+ case X_kbGetMap:
+ return ProcXkbGetMap(client);
+ case X_kbSetMap:
+ return ProcXkbSetMap(client);
+ case X_kbGetCompatMap:
+ return ProcXkbGetCompatMap(client);
+ case X_kbSetCompatMap:
+ return ProcXkbSetCompatMap(client);
+ case X_kbGetIndicatorState:
+ return ProcXkbGetIndicatorState(client);
+ case X_kbGetIndicatorMap:
+ return ProcXkbGetIndicatorMap(client);
+ case X_kbSetIndicatorMap:
+ return ProcXkbSetIndicatorMap(client);
+ case X_kbGetNamedIndicator:
+ return ProcXkbGetNamedIndicator(client);
+ case X_kbSetNamedIndicator:
+ return ProcXkbSetNamedIndicator(client);
+ case X_kbGetNames:
+ return ProcXkbGetNames(client);
+ case X_kbSetNames:
+ return ProcXkbSetNames(client);
+ case X_kbGetGeometry:
+ return ProcXkbGetGeometry(client);
+ case X_kbSetGeometry:
+ return ProcXkbSetGeometry(client);
+ case X_kbPerClientFlags:
+ return ProcXkbPerClientFlags(client);
+ case X_kbListComponents:
+ return ProcXkbListComponents(client);
+ case X_kbGetKbdByName:
+ return ProcXkbGetKbdByName(client);
+ case X_kbGetDeviceInfo:
+ return ProcXkbGetDeviceInfo(client);
+ case X_kbSetDeviceInfo:
+ return ProcXkbSetDeviceInfo(client);
+ case X_kbSetDebuggingFlags:
+ return ProcXkbSetDebuggingFlags(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static int
+XkbClientGone(pointer data,XID id)
+{
+ DevicePtr pXDev = (DevicePtr)data;
+
+ if (!XkbRemoveResourceClient(pXDev,id)) {
+ ErrorF("Internal Error! bad RemoveResourceClient in XkbClientGone\n");
+ }
+ return 1;
+}
+
+/*ARGSUSED*/
+static void
+XkbResetProc(ExtensionEntry *extEntry)
+{
+}
+
+void
+XkbExtensionInit(INITARGS)
+{
+ ExtensionEntry *extEntry;
+
+ if ((extEntry = AddExtension(XkbName, XkbNumberEvents, XkbNumberErrors,
+ ProcXkbDispatch, SProcXkbDispatch,
+ XkbResetProc, StandardMinorOpcode))) {
+ XkbReqCode = (unsigned char)extEntry->base;
+ XkbEventBase = (unsigned char)extEntry->eventBase;
+ XkbErrorBase = (unsigned char)extEntry->errorBase;
+ XkbKeyboardErrorCode = XkbErrorBase+XkbKeyboard;
+ RT_XKBCLIENT = CreateNewResourceType(XkbClientGone);
+ }
+ return;
+}
+
+
diff --git a/nx-X11/programs/Xserver/xkb/xkb.h b/nx-X11/programs/Xserver/xkb/xkb.h
new file mode 100644
index 000000000..704cd49c0
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/xkb.h
@@ -0,0 +1,72 @@
+/* $XFree86$ */
+
+/* #include "XKBfile.h" */
+
+extern int ProcXkbUseExtension(ClientPtr client);
+extern int ProcXkbSelectEvents(ClientPtr client);
+extern int ProcXkbBell(ClientPtr client);
+extern int ProcXkbGetState(ClientPtr client);
+extern int ProcXkbLatchLockState(ClientPtr client);
+extern int ProcXkbGetControls(ClientPtr client);
+extern int ProcXkbSetControls(ClientPtr client);
+extern int ProcXkbGetMap(ClientPtr client);
+extern int ProcXkbSetMap(ClientPtr client);
+extern int ProcXkbGetCompatMap(ClientPtr client);
+extern int ProcXkbSetCompatMap(ClientPtr client);
+extern int ProcXkbGetIndicatorState(ClientPtr client);
+extern int ProcXkbGetIndicatorMap(ClientPtr client);
+extern int ProcXkbSetIndicatorMap(ClientPtr client);
+extern int ProcXkbGetNamedIndicator(ClientPtr client);
+extern int ProcXkbSetNamedIndicator(ClientPtr client);
+extern int ProcXkbGetNames(ClientPtr client);
+extern int ProcXkbSetNames(ClientPtr client);
+extern int ProcXkbGetGeometry(ClientPtr client);
+extern int ProcXkbSetGeometry(ClientPtr client);
+extern int ProcXkbPerClientFlags(ClientPtr client);
+extern int ProcXkbListComponents(ClientPtr client);
+extern int ProcXkbGetKbdByName(ClientPtr client);
+extern int ProcXkbGetDeviceInfo(ClientPtr client);
+extern int ProcXkbSetDeviceInfo(ClientPtr client);
+extern int ProcXkbSetDebuggingFlags(ClientPtr client);
+
+extern int XkbSetRepeatRate(DeviceIntPtr dev, int timeout, int interval, int major, int minor);
+extern int XkbGetRepeatRate(DeviceIntPtr dev, int *timeout, int *interval);
+
+extern Status XkbComputeGetIndicatorMapReplySize(
+ XkbIndicatorPtr indicators,
+ xkbGetIndicatorMapReply *rep);
+extern int XkbSendIndicatorMap(
+ ClientPtr client,
+ XkbIndicatorPtr indicators,
+ xkbGetIndicatorMapReply *rep);
+
+extern void XkbComputeCompatState(XkbSrvInfoPtr xkbi);
+extern void XkbSetPhysicalLockingKey(DeviceIntPtr dev, unsigned key);
+
+extern Bool XkbFilterEvents(ClientPtr pClient, int nEvents, xEvent *xE);
+
+extern Bool XkbApplyLEDChangeToKeyboard(
+ XkbSrvInfoPtr xkbi,
+ XkbIndicatorMapPtr map,
+ Bool on,
+ XkbChangesPtr change);
+
+extern Bool XkbWriteRulesProp(ClientPtr client, pointer closure);
+
+extern XkbAction XkbGetButtonAction(DeviceIntPtr kbd, DeviceIntPtr dev, int button);
+
+/* extern Status XkbMergeFile(XkbDescPtr xkb, XkbFileInfo finfo); */
+
+extern Bool XkbDDXCompileNamedKeymap(
+ XkbDescPtr xkb,
+ XkbComponentNamesPtr names,
+ char * nameRtrn,
+ int nameRtrnLen);
+
+extern Bool XkbDDXCompileKeymapByNames(
+ XkbDescPtr xkb,
+ XkbComponentNamesPtr names,
+ unsigned want,
+ unsigned need,
+ char * nameRtrn,
+ int nameRtrnLen);
diff --git a/nx-X11/programs/Xserver/xkb/xkbAccessX.c b/nx-X11/programs/Xserver/xkb/xkbAccessX.c
new file mode 100644
index 000000000..b31ca7ed5
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/xkbAccessX.c
@@ -0,0 +1,754 @@
+/* $Xorg: xkbAccessX.c,v 1.4 2001/02/05 18:50:20 coskrey Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/xkbAccessX.c,v 1.9 2001/08/23 14:33:25 alanh Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <math.h>
+#ifdef __QNX__
+#include <limits.h>
+#endif
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "inputstr.h"
+#include <X11/extensions/XKBsrv.h>
+#if !defined(WIN32) && !defined(Lynx)
+#include <sys/time.h>
+#endif
+
+int XkbDfltRepeatDelay= 660;
+int XkbDfltRepeatInterval= 40;
+pointer XkbLastRepeatEvent= NULL;
+
+#define DFLT_TIMEOUT_CTRLS (XkbAX_KRGMask|XkbStickyKeysMask|XkbMouseKeysMask)
+#define DFLT_TIMEOUT_OPTS (XkbAX_IndicatorFBMask)
+
+unsigned short XkbDfltAccessXTimeout= 120;
+unsigned int XkbDfltAccessXTimeoutMask= DFLT_TIMEOUT_CTRLS;
+unsigned int XkbDfltAccessXTimeoutValues= 0;
+unsigned int XkbDfltAccessXTimeoutOptionsMask= DFLT_TIMEOUT_OPTS;
+unsigned int XkbDfltAccessXTimeoutOptionsValues= 0;
+unsigned int XkbDfltAccessXFeedback= XkbAccessXFeedbackMask;
+unsigned short XkbDfltAccessXOptions= XkbAX_AllOptionsMask & ~(XkbAX_IndicatorFBMask|XkbAX_SKReleaseFBMask|XkbAX_SKRejectFBMask);
+
+void
+AccessXComputeCurveFactor(XkbSrvInfoPtr xkbi,XkbControlsPtr ctrls)
+{
+ xkbi->mouseKeysCurve= 1.0+(((double)ctrls->mk_curve)*0.001);
+ xkbi->mouseKeysCurveFactor= ( ((double)ctrls->mk_max_speed)/
+ pow((double)ctrls->mk_time_to_max,xkbi->mouseKeysCurve));
+ return;
+}
+
+void
+AccessXInit(DeviceIntPtr keybd)
+{
+XkbSrvInfoPtr xkbi = keybd->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+
+ xkbi->shiftKeyCount= 0;
+ xkbi->mouseKeysCounter= 0;
+ xkbi->inactiveKey= 0;
+ xkbi->slowKey= 0;
+ xkbi->repeatKey= 0;
+ xkbi->krgTimerActive= _OFF_TIMER;
+ xkbi->beepType= _BEEP_NONE;
+ xkbi->beepCount= 0;
+ xkbi->mouseKeyTimer= NULL;
+ xkbi->slowKeysTimer= NULL;
+ xkbi->bounceKeysTimer= NULL;
+ xkbi->repeatKeyTimer= NULL;
+ xkbi->krgTimer= NULL;
+ xkbi->beepTimer= NULL;
+ ctrls->repeat_delay = XkbDfltRepeatDelay;
+ ctrls->repeat_interval = XkbDfltRepeatInterval;
+ ctrls->debounce_delay = 300;
+ ctrls->slow_keys_delay = 300;
+ ctrls->mk_delay = 160;
+ ctrls->mk_interval = 40;
+ ctrls->mk_time_to_max = 30;
+ ctrls->mk_max_speed = 30;
+ ctrls->mk_curve = 500;
+ ctrls->mk_dflt_btn = 1;
+ ctrls->ax_timeout = XkbDfltAccessXTimeout;
+ ctrls->axt_ctrls_mask = XkbDfltAccessXTimeoutMask;
+ ctrls->axt_ctrls_values = XkbDfltAccessXTimeoutValues;
+ ctrls->axt_opts_mask = XkbDfltAccessXTimeoutOptionsMask;
+ ctrls->axt_opts_values = XkbDfltAccessXTimeoutOptionsValues;
+ if (XkbDfltAccessXTimeout)
+ ctrls->enabled_ctrls |= XkbAccessXTimeoutMask;
+ else
+ ctrls->enabled_ctrls &= ~XkbAccessXTimeoutMask;
+ ctrls->enabled_ctrls |= XkbDfltAccessXFeedback;
+ ctrls->ax_options = XkbDfltAccessXOptions;
+ AccessXComputeCurveFactor(xkbi,ctrls);
+ return;
+}
+
+/************************************************************************/
+/* */
+/* AccessXKeyboardEvent */
+/* */
+/* Generate a synthetic keyboard event. */
+/* */
+/************************************************************************/
+static void
+AccessXKeyboardEvent(DeviceIntPtr keybd,
+ BYTE type,
+ BYTE keyCode,
+ Bool isRepeat)
+{
+xEvent xE;
+
+ xE.u.u.type = type;
+ xE.u.u.detail = keyCode;
+ xE.u.keyButtonPointer.time = GetTimeInMillis();
+#ifdef DEBUG
+ if (xkbDebugFlags&0x8) {
+ ErrorF("AXKE: Key %d %s\n",keyCode,(xE.u.u.type==KeyPress?"down":"up"));
+ }
+#endif
+
+ if (_XkbIsPressEvent(type))
+ XkbDDXKeyClick(keybd,keyCode,TRUE);
+ else if (isRepeat)
+ XkbLastRepeatEvent= (pointer)&xE;
+ XkbProcessKeyboardEvent(&xE,keybd,1L);
+ XkbLastRepeatEvent= NULL;
+ return;
+
+} /* AccessXKeyboardEvent */
+
+/************************************************************************/
+/* */
+/* AccessXKRGTurnOn */
+/* */
+/* Turn the keyboard response group on. */
+/* */
+/************************************************************************/
+static void
+AccessXKRGTurnOn(DeviceIntPtr dev,CARD16 KRGControl,xkbControlsNotify *pCN)
+{
+XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+XkbControlsRec old;
+XkbEventCauseRec cause;
+XkbSrvLedInfoPtr sli;
+
+ old= *ctrls;
+ ctrls->enabled_ctrls |= (KRGControl&XkbAX_KRGMask);
+ if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,False))
+ XkbSendControlsNotify(dev,pCN);
+ cause.kc= pCN->keycode;
+ cause.event= pCN->eventType;
+ cause.mjr= pCN->requestMajor;
+ cause.mnr= pCN->requestMinor;
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(dev,sli->usesControls,True,NULL,&cause);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask))
+ XkbDDXAccessXBeep(dev,_BEEP_FEATURE_ON,KRGControl);
+ return;
+
+} /* AccessXKRGTurnOn */
+
+/************************************************************************/
+/* */
+/* AccessXKRGTurnOff */
+/* */
+/* Turn the keyboard response group off. */
+/* */
+/************************************************************************/
+static void
+AccessXKRGTurnOff(DeviceIntPtr dev,xkbControlsNotify *pCN)
+{
+XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+XkbControlsRec old;
+XkbEventCauseRec cause;
+XkbSrvLedInfoPtr sli;
+
+ old = *ctrls;
+ ctrls->enabled_ctrls &= ~XkbAX_KRGMask;
+ if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,False))
+ XkbSendControlsNotify(dev,pCN);
+ cause.kc= pCN->keycode;
+ cause.event= pCN->eventType;
+ cause.mjr= pCN->requestMajor;
+ cause.mnr= pCN->requestMinor;
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(dev,sli->usesControls,True,NULL,&cause);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) {
+ unsigned changes= old.enabled_ctrls^ctrls->enabled_ctrls;
+ XkbDDXAccessXBeep(dev,_BEEP_FEATURE_OFF,changes);
+ }
+ return;
+
+} /* AccessXKRGTurnOff */
+
+/************************************************************************/
+/* */
+/* AccessXStickyKeysTurnOn */
+/* */
+/* Turn StickyKeys on. */
+/* */
+/************************************************************************/
+static void
+AccessXStickyKeysTurnOn(DeviceIntPtr dev,xkbControlsNotify *pCN)
+{
+XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+XkbControlsRec old;
+XkbEventCauseRec cause;
+XkbSrvLedInfoPtr sli;
+
+ old = *ctrls;
+ ctrls->enabled_ctrls |= XkbStickyKeysMask;
+ xkbi->shiftKeyCount = 0;
+ if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,False))
+ XkbSendControlsNotify(dev,pCN);
+ cause.kc= pCN->keycode;
+ cause.event= pCN->eventType;
+ cause.mjr= pCN->requestMajor;
+ cause.mnr= pCN->requestMinor;
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(dev,sli->usesControls,True,NULL,&cause);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) {
+ XkbDDXAccessXBeep(dev,_BEEP_FEATURE_ON,XkbStickyKeysMask);
+ }
+ return;
+
+} /* AccessXStickyKeysTurnOn */
+
+/************************************************************************/
+/* */
+/* AccessXStickyKeysTurnOff */
+/* */
+/* Turn StickyKeys off. */
+/* */
+/************************************************************************/
+static void
+AccessXStickyKeysTurnOff(DeviceIntPtr dev,xkbControlsNotify *pCN)
+{
+XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+XkbControlsRec old;
+XkbEventCauseRec cause;
+XkbSrvLedInfoPtr sli;
+
+ old = *ctrls;
+ ctrls->enabled_ctrls &= ~XkbStickyKeysMask;
+ xkbi->shiftKeyCount = 0;
+ if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,False))
+ XkbSendControlsNotify(dev,pCN);
+
+ cause.kc= pCN->keycode;
+ cause.event= pCN->eventType;
+ cause.mjr= pCN->requestMajor;
+ cause.mnr= pCN->requestMinor;
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(dev,sli->usesControls,True,NULL,&cause);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) {
+ XkbDDXAccessXBeep(dev,_BEEP_FEATURE_OFF,XkbStickyKeysMask);
+ }
+#ifndef NO_CLEAR_LATCHES_FOR_STICKY_KEYS_OFF
+ XkbClearAllLatchesAndLocks(dev,xkbi,False,&cause);
+#endif
+ return;
+} /* AccessXStickyKeysTurnOff */
+
+static CARD32
+AccessXKRGExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+XkbSrvInfoPtr xkbi= ((DeviceIntPtr)arg)->key->xkbInfo;
+xkbControlsNotify cn;
+
+ if (xkbi->krgTimerActive==_KRG_WARN_TIMER) {
+ XkbDDXAccessXBeep((DeviceIntPtr)arg,_BEEP_SLOW_WARN,XkbStickyKeysMask);
+ xkbi->krgTimerActive= _KRG_TIMER;
+ return 4000;
+ }
+ xkbi->krgTimerActive= _OFF_TIMER;
+ cn.keycode = 0;
+ cn.eventType = 0;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ if (xkbi->desc->ctrls->enabled_ctrls&XkbSlowKeysMask)
+ AccessXKRGTurnOff((DeviceIntPtr)arg,&cn);
+ else AccessXKRGTurnOn((DeviceIntPtr)arg,XkbSlowKeysMask,&cn);
+ return 0;
+}
+
+static CARD32
+AccessXRepeatKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+XkbSrvInfoPtr xkbi= ((DeviceIntPtr)arg)->key->xkbInfo;
+KeyCode key;
+
+ if (xkbi->repeatKey==0)
+ return 0;
+ key= xkbi->repeatKey;
+ AccessXKeyboardEvent((DeviceIntPtr)arg,KeyRelease,key,True);
+ AccessXKeyboardEvent((DeviceIntPtr)arg,KeyPress,key,True);
+ return xkbi->desc->ctrls->repeat_interval;
+}
+
+void
+AccessXCancelRepeatKey(XkbSrvInfoPtr xkbi,KeyCode key)
+{
+ if (xkbi->repeatKey==key)
+ xkbi->repeatKey= 0;
+ return;
+}
+
+static CARD32
+AccessXSlowKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+DeviceIntPtr keybd;
+XkbSrvInfoPtr xkbi;
+XkbDescPtr xkb;
+XkbControlsPtr ctrls;
+
+ keybd= (DeviceIntPtr)arg;
+ xkbi= keybd->key->xkbInfo;
+ xkb= xkbi->desc;
+ ctrls= xkb->ctrls;
+ if (xkbi->slowKey!=0) {
+ xkbAccessXNotify ev;
+ KeySym *sym= XkbKeySymsPtr(xkb,xkbi->slowKey);
+ ev.detail= XkbAXN_SKAccept;
+ ev.keycode= xkbi->slowKey;
+ ev.slowKeysDelay= ctrls->slow_keys_delay;
+ ev.debounceDelay= ctrls->debounce_delay;
+ XkbSendAccessXNotify(keybd,&ev);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_SKAcceptFBMask))
+ XkbDDXAccessXBeep(keybd,_BEEP_SLOW_ACCEPT,XkbSlowKeysMask);
+ AccessXKeyboardEvent(keybd,KeyPress,xkbi->slowKey,False);
+ /* check for magic sequences */
+ if ((ctrls->enabled_ctrls&XkbAccessXKeysMask) &&
+ ((sym[0]==XK_Shift_R)||(sym[0]==XK_Shift_L)))
+ xkbi->shiftKeyCount++;
+
+ /* Start repeating if necessary. Stop autorepeating if the user
+ * presses a non-modifier key that doesn't autorepeat.
+ */
+ if (keybd->kbdfeed->ctrl.autoRepeat &&
+ ((xkbi->slowKey != xkbi->mouseKey) || (!xkbi->mouseKeysAccel)) &&
+ (ctrls->enabled_ctrls&XkbRepeatKeysMask)) {
+#ifndef AIXV3
+ if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,xkbi->slowKey))
+#endif
+ {
+ xkbi->repeatKey = xkbi->slowKey;
+ xkbi->repeatKeyTimer= TimerSet(xkbi->repeatKeyTimer,
+ 0, ctrls->repeat_delay,
+ AccessXRepeatKeyExpire, (pointer)keybd);
+ }
+ }
+ }
+ return 0;
+}
+
+static CARD32
+AccessXBounceKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+XkbSrvInfoPtr xkbi= ((DeviceIntPtr)arg)->key->xkbInfo;
+
+ xkbi->inactiveKey= 0;
+ return 0;
+}
+
+static CARD32
+AccessXTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+DeviceIntPtr dev = (DeviceIntPtr)arg;
+XkbSrvInfoPtr xkbi= dev->key->xkbInfo;
+XkbControlsPtr ctrls= xkbi->desc->ctrls;
+XkbControlsRec old;
+xkbControlsNotify cn;
+XkbEventCauseRec cause;
+XkbSrvLedInfoPtr sli;
+
+ if (xkbi->lastPtrEventTime) {
+ unsigned timeToWait = (ctrls->ax_timeout*1000);
+ unsigned timeElapsed = (now-xkbi->lastPtrEventTime);
+
+ if (timeToWait > timeElapsed)
+ return (timeToWait - timeElapsed);
+ }
+ old= *ctrls;
+ xkbi->shiftKeyCount= 0;
+ ctrls->enabled_ctrls&= ~ctrls->axt_ctrls_mask;
+ ctrls->enabled_ctrls|=
+ (ctrls->axt_ctrls_values&ctrls->axt_ctrls_mask);
+ if (ctrls->axt_opts_mask) {
+ ctrls->ax_options&= ~ctrls->axt_opts_mask;
+ ctrls->ax_options|= (ctrls->axt_opts_values&ctrls->axt_opts_mask);
+ }
+ if (XkbComputeControlsNotify(dev,&old,ctrls,&cn,False)) {
+ cn.keycode = 0;
+ cn.eventType = 0;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ XkbSendControlsNotify(dev,&cn);
+ }
+ XkbSetCauseUnknown(&cause);
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(dev,sli->usesControls,True,NULL,&cause);
+ if (ctrls->ax_options!=old.ax_options) {
+ unsigned set,cleared,bell;
+ set= ctrls->ax_options&(~old.ax_options);
+ cleared= (~ctrls->ax_options)&old.ax_options;
+ if (set && cleared) bell= _BEEP_FEATURE_CHANGE;
+ else if (set) bell= _BEEP_FEATURE_ON;
+ else bell= _BEEP_FEATURE_OFF;
+ XkbDDXAccessXBeep(dev,bell,XkbAccessXTimeoutMask);
+ }
+ xkbi->krgTimerActive= _OFF_TIMER;
+ return 0;
+}
+
+
+/************************************************************************/
+/* */
+/* AccessXFilterPressEvent */
+/* */
+/* Filter events before they get any further if SlowKeys is turned on. */
+/* In addition, this routine handles the ever so popular magic key */
+/* acts for turning various accessibility features on/off. */
+/* */
+/* Returns TRUE if this routine has discarded the event. */
+/* Returns FALSE if the event needs further processing. */
+/* */
+/************************************************************************/
+Bool
+AccessXFilterPressEvent( register xEvent * xE,
+ register DeviceIntPtr keybd,
+ int count)
+{
+XkbSrvInfoPtr xkbi = keybd->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+Bool ignoreKeyEvent = FALSE;
+KeyCode key = xE->u.u.detail;
+KeySym * sym = XkbKeySymsPtr(xkbi->desc,key);
+
+ if (ctrls->enabled_ctrls&XkbAccessXKeysMask) {
+ /* check for magic sequences */
+ if ((sym[0]==XK_Shift_R)||(sym[0]==XK_Shift_L)) {
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_SlowWarnFBMask)) {
+ xkbi->krgTimerActive = _KRG_WARN_TIMER;
+ xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 4000,
+ AccessXKRGExpire, (pointer)keybd);
+ }
+ else {
+ xkbi->krgTimerActive = _KRG_TIMER;
+ xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 8000,
+ AccessXKRGExpire, (pointer)keybd);
+ }
+ if (!(ctrls->enabled_ctrls & XkbSlowKeysMask)) {
+ CARD32 now= GetTimeInMillis();
+ if ((now-xkbi->lastShiftEventTime)>15000)
+ xkbi->shiftKeyCount= 1;
+ else xkbi->shiftKeyCount++;
+ xkbi->lastShiftEventTime= now;
+ }
+ }
+ else {
+ if (xkbi->krgTimerActive) {
+ xkbi->krgTimer= TimerSet(xkbi->krgTimer,0, 0, NULL, NULL);
+ xkbi->krgTimerActive= _OFF_TIMER;
+ }
+ }
+ }
+
+ /* Don't transmit the KeyPress if SlowKeys is turned on;
+ * The wakeup handler will synthesize one for us if the user
+ * has held the key long enough.
+ */
+ if (ctrls->enabled_ctrls & XkbSlowKeysMask) {
+ xkbAccessXNotify ev;
+ /* If key was already pressed, ignore subsequent press events
+ * from the server's autorepeat
+ */
+ if(xkbi->slowKey == key)
+ return TRUE;
+ ev.detail= XkbAXN_SKPress;
+ ev.keycode= key;
+ ev.slowKeysDelay= ctrls->slow_keys_delay;
+ ev.debounceDelay= ctrls->debounce_delay;
+ XkbSendAccessXNotify(keybd,&ev);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_SKPressFBMask))
+ XkbDDXAccessXBeep(keybd,_BEEP_SLOW_PRESS,XkbSlowKeysMask);
+ xkbi->slowKey= key;
+ xkbi->slowKeysTimer = TimerSet(xkbi->slowKeysTimer,
+ 0, ctrls->slow_keys_delay,
+ AccessXSlowKeyExpire, (pointer)keybd);
+ ignoreKeyEvent = TRUE;
+ }
+
+ /* Don't transmit the KeyPress if BounceKeys is turned on
+ * and the user pressed the same key within a given time period
+ * from the last release.
+ */
+ else if ((ctrls->enabled_ctrls & XkbBounceKeysMask) &&
+ (key == xkbi->inactiveKey)) {
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_BKRejectFBMask))
+ XkbDDXAccessXBeep(keybd,_BEEP_BOUNCE_REJECT,XkbBounceKeysMask);
+ ignoreKeyEvent = TRUE;
+ }
+
+ /* Start repeating if necessary. Stop autorepeating if the user
+ * presses a non-modifier key that doesn't autorepeat.
+ */
+ if (XkbDDXUsesSoftRepeat(keybd)) {
+ if ((keybd->kbdfeed->ctrl.autoRepeat) &&
+ ((ctrls->enabled_ctrls&(XkbSlowKeysMask|XkbRepeatKeysMask))==
+ XkbRepeatKeysMask)) {
+#ifndef AIXV3
+ if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,key))
+#endif
+ {
+#ifdef DEBUG
+ if (xkbDebugFlags&0x10)
+ ErrorF("Starting software autorepeat...\n");
+#endif
+ xkbi->repeatKey = key;
+ xkbi->repeatKeyTimer= TimerSet(xkbi->repeatKeyTimer,
+ 0, ctrls->repeat_delay,
+ AccessXRepeatKeyExpire, (pointer)keybd);
+ }
+ }
+ }
+
+ /* Check for two keys being pressed at the same time. This section
+ * essentially says the following:
+ *
+ * If StickyKeys is on, and a modifier is currently being held down,
+ * and one of the following is true: the current key is not a modifier
+ * or the currentKey is a modifier, but not the only modifier being
+ * held down, turn StickyKeys off if the TwoKeys off ctrl is set.
+ */
+ if ((ctrls->enabled_ctrls & XkbStickyKeysMask) &&
+ (xkbi->state.base_mods!=0) &&
+ (XkbAX_NeedOption(ctrls,XkbAX_TwoKeysMask))) {
+ xkbControlsNotify cn;
+ cn.keycode = key;
+ cn.eventType = KeyPress;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ AccessXStickyKeysTurnOff(keybd,&cn);
+ }
+
+ if (!ignoreKeyEvent)
+ XkbProcessKeyboardEvent(xE,keybd,count);
+ return ignoreKeyEvent;
+} /* AccessXFilterPressEvent */
+
+/************************************************************************/
+/* */
+/* AccessXFilterReleaseEvent */
+/* */
+/* Filter events before they get any further if SlowKeys is turned on. */
+/* In addition, this routine handles the ever so popular magic key */
+/* acts for turning various accessibility features on/off. */
+/* */
+/* Returns TRUE if this routine has discarded the event. */
+/* Returns FALSE if the event needs further processing. */
+/* */
+/************************************************************************/
+Bool
+AccessXFilterReleaseEvent( register xEvent * xE,
+ register DeviceIntPtr keybd,
+ int count)
+{
+XkbSrvInfoPtr xkbi = keybd->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+KeyCode key = xE->u.u.detail;
+Bool ignoreKeyEvent = FALSE;
+
+ /* Don't transmit the KeyRelease if BounceKeys is on and
+ * this is the release of a key that was ignored due to
+ * BounceKeys.
+ */
+ if (ctrls->enabled_ctrls & XkbBounceKeysMask) {
+ if ((key!=xkbi->mouseKey)&&(!BitIsOn(keybd->key->down,key)))
+ ignoreKeyEvent = TRUE;
+ xkbi->inactiveKey= key;
+ xkbi->bounceKeysTimer= TimerSet(xkbi->bounceKeysTimer, 0,
+ ctrls->debounce_delay,
+ AccessXBounceKeyExpire, (pointer)keybd);
+ }
+
+ /* Don't transmit the KeyRelease if SlowKeys is turned on and
+ * the user didn't hold the key long enough. We know we passed
+ * the key if the down bit was set by CoreProcessKeyboadEvent.
+ */
+ if (ctrls->enabled_ctrls & XkbSlowKeysMask) {
+ xkbAccessXNotify ev;
+ unsigned beep_type;
+ ev.keycode= key;
+ ev.slowKeysDelay= ctrls->slow_keys_delay;
+ ev.debounceDelay= ctrls->debounce_delay;
+ if (BitIsOn(keybd->key->down,key) | (xkbi->mouseKey == key)) {
+ ev.detail= XkbAXN_SKRelease;
+ beep_type= _BEEP_SLOW_RELEASE;
+ }
+ else {
+ ev.detail= XkbAXN_SKReject;
+ beep_type= _BEEP_SLOW_REJECT;
+ ignoreKeyEvent = TRUE;
+ }
+ XkbSendAccessXNotify(keybd,&ev);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_SKRejectFBMask)) {
+ XkbDDXAccessXBeep(keybd,beep_type,XkbSlowKeysMask);
+ }
+ if (xkbi->slowKey==key)
+ xkbi->slowKey= 0;
+ }
+
+ /* Stop Repeating if the user releases the key that is currently
+ * repeating.
+ */
+ if (xkbi->repeatKey==key) {
+ xkbi->repeatKey= 0;
+ }
+
+ if ((ctrls->enabled_ctrls&XkbAccessXTimeoutMask)&&(ctrls->ax_timeout>0)) {
+ xkbi->lastPtrEventTime= 0;
+ xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0,
+ ctrls->ax_timeout*1000,
+ AccessXTimeoutExpire, (pointer)keybd);
+ xkbi->krgTimerActive= _ALL_TIMEOUT_TIMER;
+ }
+ else if (xkbi->krgTimerActive!=_OFF_TIMER) {
+ xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 0, NULL, NULL);
+ xkbi->krgTimerActive= _OFF_TIMER;
+ }
+
+ /* Keep track of how many times the Shift key has been pressed.
+ * If it has been pressed and released 5 times in a row, toggle
+ * the state of StickyKeys.
+ */
+ if ((!ignoreKeyEvent)&&(xkbi->shiftKeyCount)) {
+ KeySym *pSym= XkbKeySymsPtr(xkbi->desc,key);
+ if ((pSym[0]!=XK_Shift_L)&&(pSym[0]!=XK_Shift_R)) {
+ xkbi->shiftKeyCount= 0;
+ }
+ else if (xkbi->shiftKeyCount>=5) {
+ xkbControlsNotify cn;
+ cn.keycode = key;
+ cn.eventType = KeyPress;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ if (ctrls->enabled_ctrls & XkbStickyKeysMask)
+ AccessXStickyKeysTurnOff(keybd,&cn);
+ else
+ AccessXStickyKeysTurnOn(keybd,&cn);
+ xkbi->shiftKeyCount= 0;
+ }
+ }
+
+ if (!ignoreKeyEvent)
+ XkbProcessKeyboardEvent(xE,keybd,count);
+ return ignoreKeyEvent;
+
+} /* AccessXFilterReleaseEvent */
+
+/************************************************************************/
+/* */
+/* ProcessPointerEvent */
+/* */
+/* This routine merely sets the shiftKeyCount and clears the keyboard */
+/* response group timer (if necessary) on a mouse event. This is so */
+/* multiple shifts with just the mouse and shift-drags with the mouse */
+/* don't accidentally turn on StickyKeys or the Keyboard Response Group.*/
+/* */
+/************************************************************************/
+void
+ProcessPointerEvent( register xEvent * xE,
+ register DeviceIntPtr mouse,
+ int count)
+{
+DeviceIntPtr dev = (DeviceIntPtr)LookupKeyboardDevice();
+XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+unsigned changed = 0;
+
+ xkbi->shiftKeyCount = 0;
+ xkbi->lastPtrEventTime= xE->u.keyButtonPointer.time;
+
+ if (xE->u.u.type==ButtonPress) {
+ changed |= XkbPointerButtonMask;
+ }
+ else if (xE->u.u.type==ButtonRelease) {
+ xkbi->lockedPtrButtons&= ~(1<<(xE->u.u.detail&0x7));
+ changed |= XkbPointerButtonMask;
+ }
+ CoreProcessPointerEvent(xE,mouse,count);
+
+ xkbi->state.ptr_buttons = mouse->button->state;
+
+ /* clear any latched modifiers */
+ if ( xkbi->state.latched_mods && (xE->u.u.type==ButtonRelease) ) {
+ unsigned changed_leds;
+ XkbStateRec oldState;
+ XkbSrvLedInfoPtr sli;
+
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ oldState= xkbi->state;
+ XkbLatchModifiers(dev,0xFF,0x00);
+
+ XkbComputeDerivedState(xkbi);
+ changed |= XkbStateChangedFlags(&oldState,&xkbi->state);
+ if (changed&sli->usedComponents) {
+ changed_leds= XkbIndicatorsToUpdate(dev,changed,False);
+ if (changed_leds) {
+ XkbEventCauseRec cause;
+ XkbSetCauseKey(&cause,(xE->u.u.detail&0x7),xE->u.u.type);
+ XkbUpdateIndicators(dev,changed_leds,True,NULL,&cause);
+ }
+ }
+ dev->key->state= XkbStateFieldFromRec(&xkbi->state);
+ }
+
+ if (((xkbi->flags&_XkbStateNotifyInProgress)==0)&&(changed!=0)) {
+ xkbStateNotify sn;
+ sn.keycode= xE->u.u.detail;
+ sn.eventType= xE->u.u.type;
+ sn.requestMajor = sn.requestMinor = 0;
+ sn.changed= changed;
+ XkbSendStateNotify(dev,&sn);
+ }
+
+} /* ProcessPointerEvent */
+
+
+
+
diff --git a/nx-X11/programs/Xserver/xkb/xkbActions.c b/nx-X11/programs/Xserver/xkb/xkbActions.c
new file mode 100644
index 000000000..b767658f3
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/xkbActions.c
@@ -0,0 +1,1432 @@
+/* $Xorg: xkbActions.c,v 1.3 2000/08/17 19:53:47 cpqbld Exp $ */
+/* $XdotOrg: xc/programs/Xserver/xkb/xkbActions.c,v 1.7 2005/07/03 08:53:54 daniels Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/xkbActions.c,v 3.13 2003/07/16 01:39:08 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <math.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "misc.h"
+#include "inputstr.h"
+#include <X11/extensions/XKBsrv.h>
+#include "xkb.h"
+#include <ctype.h>
+
+static unsigned int _xkbServerGeneration;
+int xkbDevicePrivateIndex = -1;
+
+void
+xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc,
+ pointer data)
+{
+ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(device);
+ ProcessInputProc tmp = device->public.processInputProc;
+ if(xkbPrivPtr->unwrapProc)
+ xkbPrivPtr->unwrapProc = NULL;
+
+ UNWRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr);
+ proc(device,data);
+ WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr,
+ tmp,xkbUnwrapProc);
+}
+
+
+void
+XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc)
+{
+ xkbDeviceInfoPtr xkbPrivPtr;
+
+ if (serverGeneration != _xkbServerGeneration) {
+ if ((xkbDevicePrivateIndex = AllocateDevicePrivateIndex()) == -1)
+ return;
+ _xkbServerGeneration = serverGeneration;
+ }
+ if (!AllocateDevicePrivate(device, xkbDevicePrivateIndex))
+ return;
+
+ xkbPrivPtr = (xkbDeviceInfoPtr) xalloc(sizeof(xkbDeviceInfoRec));
+ if (!xkbPrivPtr)
+ return;
+ xkbPrivPtr->unwrapProc = NULL;
+
+ device->devPrivates[xkbDevicePrivateIndex].ptr = xkbPrivPtr;
+ WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr,
+ proc,xkbUnwrapProc);
+}
+
+#ifdef XINPUT
+extern void ProcessOtherEvent(
+ xEvent * /* xE */,
+ DeviceIntPtr /* dev */,
+ int /* count */
+);
+#endif
+
+/***====================================================================***/
+
+static XkbAction
+_FixUpAction(XkbDescPtr xkb,XkbAction *act)
+{
+static XkbAction fake;
+
+ if (XkbIsPtrAction(act)&&(!(xkb->ctrls->enabled_ctrls&XkbMouseKeysMask))) {
+ fake.type = XkbSA_NoAction;
+ return fake;
+ }
+ if (XkbDisableLockActions) {
+ switch (act->type) {
+ case XkbSA_LockMods:
+ fake.mods.type = XkbSA_SetMods;
+ fake.mods.flags = 0;
+ fake.mods.mask = act->mods.mask;
+ return fake;
+ case XkbSA_LatchMods:
+ fake.mods.type = XkbSA_SetMods;
+ fake.mods.flags = 0;
+ fake.mods.mask = act->mods.mask;
+ return fake;
+ case XkbSA_ISOLock:
+ if (act->iso.flags&XkbSA_ISODfltIsGroup) {
+ fake.group.type = XkbSA_SetGroup;
+ fake.group.flags = act->iso.flags&XkbSA_GroupAbsolute;
+ XkbSASetGroup(&fake.group,XkbSAGroup(&act->iso));
+ }
+ else {
+ fake.mods.type = XkbSA_SetMods;
+ fake.mods.flags = 0;
+ fake.mods.mask = act->iso.mask;
+ }
+ return fake;
+ case XkbSA_LockGroup:
+ case XkbSA_LatchGroup:
+ /* We want everything from the latch/lock action except the
+ * type should be changed to set.
+ */
+ fake = *act;
+ fake.group.type = XkbSA_SetGroup;
+ return fake;
+ }
+ }
+ else
+ if (xkb->ctrls->enabled_ctrls&XkbStickyKeysMask) {
+ if (act->any.type==XkbSA_SetMods) {
+ fake.mods.type = XkbSA_LatchMods;
+ fake.mods.mask = act->mods.mask;
+ if (XkbAX_NeedOption(xkb->ctrls,XkbAX_LatchToLockMask))
+ fake.mods.flags= XkbSA_ClearLocks|XkbSA_LatchToLock;
+ else fake.mods.flags= XkbSA_ClearLocks;
+ return fake;
+ }
+ if (act->any.type==XkbSA_SetGroup) {
+ fake.group.type = XkbSA_LatchGroup;
+ if (XkbAX_NeedOption(xkb->ctrls,XkbAX_LatchToLockMask))
+ fake.group.flags= XkbSA_ClearLocks|XkbSA_LatchToLock;
+ else fake.group.flags= XkbSA_ClearLocks;
+ XkbSASetGroup(&fake.group,XkbSAGroup(&act->group));
+ return fake;
+ }
+ }
+ return *act;
+}
+
+static XkbAction
+XkbGetKeyAction(XkbSrvInfoPtr xkbi,XkbStatePtr xkbState,CARD8 key)
+{
+int effectiveGroup;
+int col;
+XkbDescPtr xkb;
+XkbKeyTypePtr type;
+XkbAction * pActs;
+static XkbAction fake;
+
+ xkb= xkbi->desc;
+ if (!XkbKeyHasActions(xkb,key) || !XkbKeycodeInRange(xkb,key)) {
+ fake.type = XkbSA_NoAction;
+ return fake;
+ }
+ pActs= XkbKeyActionsPtr(xkb,key);
+ col= 0;
+ effectiveGroup= xkbState->group;
+ if (effectiveGroup!=XkbGroup1Index) {
+ if (XkbKeyNumGroups(xkb,key)>(unsigned)1) {
+ if (effectiveGroup>=XkbKeyNumGroups(xkb,key)) {
+ unsigned gi= XkbKeyGroupInfo(xkb,key);
+ switch (XkbOutOfRangeGroupAction(gi)) {
+ default:
+ case XkbWrapIntoRange:
+ effectiveGroup %= XkbKeyNumGroups(xkb,key);
+ break;
+ case XkbClampIntoRange:
+ effectiveGroup = XkbKeyNumGroups(xkb,key)-1;
+ break;
+ case XkbRedirectIntoRange:
+ effectiveGroup= XkbOutOfRangeGroupInfo(gi);
+ if (effectiveGroup>=XkbKeyNumGroups(xkb,key))
+ effectiveGroup= 0;
+ break;
+ }
+ }
+ }
+ else effectiveGroup= XkbGroup1Index;
+ col+= (effectiveGroup*XkbKeyGroupsWidth(xkb,key));
+ }
+ type= XkbKeyKeyType(xkb,key,effectiveGroup);
+ if (type->map!=NULL) {
+ register unsigned i,mods;
+ register XkbKTMapEntryPtr entry;
+ mods= xkbState->mods&type->mods.mask;
+ for (entry= type->map,i=0;i<type->map_count;i++,entry++) {
+ if ((entry->active)&&(entry->mods.mask==mods)) {
+ col+= entry->level;
+ break;
+ }
+ }
+ }
+ if (pActs[col].any.type==XkbSA_NoAction)
+ return pActs[col];
+ fake= _FixUpAction(xkb,&pActs[col]);
+ return fake;
+}
+
+XkbAction
+XkbGetButtonAction(DeviceIntPtr kbd,DeviceIntPtr dev,int button)
+{
+XkbAction fake;
+ if ((dev->button)&&(dev->button->xkb_acts)) {
+ if (dev->button->xkb_acts[button-1].any.type!=XkbSA_NoAction) {
+ fake= _FixUpAction(kbd->key->xkbInfo->desc,
+ &dev->button->xkb_acts[button-1]);
+ return fake;
+ }
+ }
+ fake.any.type= XkbSA_NoAction;
+ return fake;
+}
+
+/***====================================================================***/
+
+#define SYNTHETIC_KEYCODE 1
+#define BTN_ACT_FLAG 0x100
+
+typedef struct _XkbFilter {
+ CARD16 keycode;
+ CARD8 what;
+ CARD8 active;
+ CARD8 filterOthers;
+ CARD32 priv;
+ XkbAction upAction;
+ int (*filter)(
+ XkbSrvInfoPtr /* xkbi */,
+ struct _XkbFilter * /* filter */,
+ unsigned /* keycode */,
+ XkbAction * /* action */
+ );
+ struct _XkbFilter *next;
+} XkbFilterRec,*XkbFilterPtr;
+
+static int
+_XkbFilterSetState( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction *pAction)
+{
+ if (filter->keycode==0) { /* initial press */
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = ((pAction->mods.mask&XkbSA_ClearLocks)!=0);
+ filter->priv = 0;
+ filter->filter = _XkbFilterSetState;
+ if (pAction->type==XkbSA_SetMods) {
+ filter->upAction = *pAction;
+ xkbi->setMods= pAction->mods.mask;
+ }
+ else {
+ xkbi->groupChange = XkbSAGroup(&pAction->group);
+ if (pAction->group.flags&XkbSA_GroupAbsolute)
+ xkbi->groupChange-= xkbi->state.base_group;
+ filter->upAction= *pAction;
+ XkbSASetGroup(&filter->upAction.group,xkbi->groupChange);
+ }
+ }
+ else if (filter->keycode==keycode) {
+ if (filter->upAction.type==XkbSA_SetMods) {
+ xkbi->clearMods = filter->upAction.mods.mask;
+ if (filter->upAction.mods.flags&XkbSA_ClearLocks) {
+ xkbi->state.locked_mods&= ~filter->upAction.mods.mask;
+ }
+ }
+ else {
+ if (filter->upAction.group.flags&XkbSA_ClearLocks) {
+ xkbi->state.locked_group = 0;
+ }
+ xkbi->groupChange = -XkbSAGroup(&filter->upAction.group);
+ }
+ filter->active = 0;
+ }
+ else {
+ filter->upAction.mods.flags&= ~XkbSA_ClearLocks;
+ filter->filterOthers = 0;
+ }
+ return 1;
+}
+
+#define LATCH_KEY_DOWN 1
+#define LATCH_PENDING 2
+#define NO_LATCH 3
+
+static int
+_XkbFilterLatchState( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+
+ if (filter->keycode==0) { /* initial press */
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 1;
+ filter->priv = LATCH_KEY_DOWN;
+ filter->filter = _XkbFilterLatchState;
+ if (pAction->type==XkbSA_LatchMods) {
+ filter->upAction = *pAction;
+ xkbi->setMods = pAction->mods.mask;
+ }
+ else {
+ xkbi->groupChange = XkbSAGroup(&pAction->group);
+ if (pAction->group.flags&XkbSA_GroupAbsolute)
+ xkbi->groupChange-= xkbi->state.base_group;
+ filter->upAction= *pAction;
+ XkbSASetGroup(&filter->upAction.group,xkbi->groupChange);
+ }
+ }
+ else if ( pAction && (filter->priv==LATCH_PENDING) ) {
+ if (((1<<pAction->type)&XkbSA_BreakLatch)!=0) {
+ filter->active = 0;
+ if (filter->upAction.type==XkbSA_LatchMods)
+ xkbi->state.latched_mods&= ~filter->upAction.mods.mask;
+ else xkbi->state.latched_group-=XkbSAGroup(&filter->upAction.group);
+ }
+ else if ((pAction->type==filter->upAction.type)&&
+ (pAction->mods.flags==filter->upAction.mods.flags)&&
+ (pAction->mods.mask==filter->upAction.mods.mask)) {
+ if (filter->upAction.mods.flags&XkbSA_LatchToLock) {
+ XkbControlsPtr ctrls= xkbi->desc->ctrls;
+ if (filter->upAction.type==XkbSA_LatchMods)
+ pAction->mods.type= XkbSA_LockMods;
+ else pAction->group.type= XkbSA_LockGroup;
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_StickyKeysFBMask)&&
+ (ctrls->enabled_ctrls&XkbStickyKeysMask)) {
+ XkbDDXAccessXBeep(xkbi->device,_BEEP_STICKY_LOCK,
+ XkbStickyKeysMask);
+ }
+ }
+ else {
+ if (filter->upAction.type==XkbSA_LatchMods)
+ pAction->mods.type= XkbSA_SetMods;
+ else pAction->group.type= XkbSA_SetGroup;
+ }
+ if (filter->upAction.type==XkbSA_LatchMods)
+ xkbi->state.latched_mods&= ~filter->upAction.mods.mask;
+ else xkbi->state.latched_group-=XkbSAGroup(&filter->upAction.group);
+ filter->active = 0;
+ }
+ }
+ else if (filter->keycode==keycode) { /* release */
+ XkbControlsPtr ctrls= xkbi->desc->ctrls;
+ int needBeep;
+ int beepType= _BEEP_NONE;
+
+ needBeep= ((ctrls->enabled_ctrls&XkbStickyKeysMask)&&
+ XkbAX_NeedFeedback(ctrls,XkbAX_StickyKeysFBMask));
+ if (filter->upAction.type==XkbSA_LatchMods) {
+ xkbi->clearMods = filter->upAction.mods.mask;
+ if ((filter->upAction.mods.flags&XkbSA_ClearLocks)&&
+ (xkbi->clearMods&xkbi->state.locked_mods)==xkbi->clearMods) {
+ xkbi->state.locked_mods&= ~xkbi->clearMods;
+ filter->priv= NO_LATCH;
+ beepType= _BEEP_STICKY_UNLOCK;
+ }
+ }
+ else {
+ xkbi->groupChange = -XkbSAGroup(&filter->upAction.group);
+ if ((filter->upAction.group.flags&XkbSA_ClearLocks)&&
+ (xkbi->state.locked_group)) {
+ xkbi->state.locked_group = 0;
+ filter->priv = NO_LATCH;
+ beepType= _BEEP_STICKY_UNLOCK;
+ }
+ }
+ if (filter->priv==NO_LATCH) {
+ filter->active= 0;
+ }
+ else {
+ filter->priv= LATCH_PENDING;
+ if (filter->upAction.type==XkbSA_LatchMods) {
+ xkbi->state.latched_mods |= filter->upAction.mods.mask;
+ needBeep = xkbi->state.latched_mods ? needBeep : 0;
+ xkbi->state.latched_mods |= filter->upAction.mods.mask;
+ }
+ else {
+ xkbi->state.latched_group+= XkbSAGroup(&filter->upAction.group);
+ }
+ if (needBeep && (beepType==_BEEP_NONE))
+ beepType= _BEEP_STICKY_LATCH;
+ }
+ if (needBeep && (beepType!=_BEEP_NONE))
+ XkbDDXAccessXBeep(xkbi->device,beepType,XkbStickyKeysMask);
+ }
+ else if (filter->priv==LATCH_KEY_DOWN) {
+ filter->priv= NO_LATCH;
+ filter->filterOthers = 0;
+ }
+ return 1;
+}
+
+static int
+_XkbFilterLockState( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+
+ if (pAction&&(pAction->type==XkbSA_LockGroup)) {
+ if (pAction->group.flags&XkbSA_GroupAbsolute)
+ xkbi->state.locked_group= XkbSAGroup(&pAction->group);
+ else xkbi->state.locked_group+= XkbSAGroup(&pAction->group);
+ return 1;
+ }
+ if (filter->keycode==0) { /* initial press */
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ filter->priv = 0;
+ filter->filter = _XkbFilterLockState;
+ filter->upAction = *pAction;
+ xkbi->state.locked_mods^= pAction->mods.mask;
+ xkbi->setMods = pAction->mods.mask;
+ }
+ else if (filter->keycode==keycode) {
+ filter->active = 0;
+ xkbi->clearMods = filter->upAction.mods.mask;
+ }
+ return 1;
+}
+
+#define ISO_KEY_DOWN 0
+#define NO_ISO_LOCK 1
+
+static int
+_XkbFilterISOLock( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+
+ if (filter->keycode==0) { /* initial press */
+ CARD8 flags= pAction->iso.flags;
+
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 1;
+ filter->priv = ISO_KEY_DOWN;
+ filter->upAction = *pAction;
+ filter->filter = _XkbFilterISOLock;
+ if (flags&XkbSA_ISODfltIsGroup) {
+ xkbi->groupChange = XkbSAGroup(&pAction->iso);
+ xkbi->setMods = 0;
+ }
+ else {
+ xkbi->setMods = pAction->iso.mask;
+ xkbi->groupChange = 0;
+ }
+ if ((!(flags&XkbSA_ISONoAffectMods))&&(xkbi->state.base_mods)) {
+ filter->priv= NO_ISO_LOCK;
+ xkbi->state.locked_mods^= xkbi->state.base_mods;
+ }
+ if ((!(flags&XkbSA_ISONoAffectGroup))&&(xkbi->state.base_group)) {
+/* 6/22/93 (ef) -- lock groups if group key is down first */
+ }
+ if (!(flags&XkbSA_ISONoAffectPtr)) {
+/* 6/22/93 (ef) -- lock mouse buttons if they're down */
+ }
+ }
+ else if (filter->keycode==keycode) {
+ CARD8 flags= filter->upAction.iso.flags;
+
+ if (flags&XkbSA_ISODfltIsGroup) {
+ xkbi->groupChange = -XkbSAGroup(&filter->upAction.iso);
+ xkbi->clearMods = 0;
+ if (filter->priv==ISO_KEY_DOWN)
+ xkbi->state.locked_group+= XkbSAGroup(&filter->upAction.iso);
+ }
+ else {
+ xkbi->clearMods= filter->upAction.iso.mask;
+ xkbi->groupChange= 0;
+ if (filter->priv==ISO_KEY_DOWN)
+ xkbi->state.locked_mods^= filter->upAction.iso.mask;
+ }
+ filter->active = 0;
+ }
+ else if (pAction) {
+ CARD8 flags= filter->upAction.iso.flags;
+
+ switch (pAction->type) {
+ case XkbSA_SetMods: case XkbSA_LatchMods:
+ if (!(flags&XkbSA_ISONoAffectMods)) {
+ pAction->type= XkbSA_LockMods;
+ filter->priv= NO_ISO_LOCK;
+ }
+ break;
+ case XkbSA_SetGroup: case XkbSA_LatchGroup:
+ if (!(flags&XkbSA_ISONoAffectGroup)) {
+ pAction->type= XkbSA_LockGroup;
+ filter->priv= NO_ISO_LOCK;
+ }
+ break;
+ case XkbSA_PtrBtn:
+ if (!(flags&XkbSA_ISONoAffectPtr)) {
+ pAction->type= XkbSA_LockPtrBtn;
+ filter->priv= NO_ISO_LOCK;
+ }
+ break;
+ case XkbSA_SetControls:
+ if (!(flags&XkbSA_ISONoAffectCtrls)) {
+ pAction->type= XkbSA_LockControls;
+ filter->priv= NO_ISO_LOCK;
+ }
+ break;
+ }
+ }
+ return 1;
+}
+
+
+static CARD32
+_XkbPtrAccelExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+XkbSrvInfoPtr xkbi= (XkbSrvInfoPtr)arg;
+XkbControlsPtr ctrls= xkbi->desc->ctrls;
+int dx,dy;
+
+ if (xkbi->mouseKey==0)
+ return 0;
+
+ if (xkbi->mouseKeysAccel) {
+ if ((xkbi->mouseKeysCounter)<ctrls->mk_time_to_max) {
+ double step;
+ xkbi->mouseKeysCounter++;
+ step= xkbi->mouseKeysCurveFactor*
+ pow((double)xkbi->mouseKeysCounter,xkbi->mouseKeysCurve);
+ if (xkbi->mouseKeysDX<0)
+ dx= floor( ((double)xkbi->mouseKeysDX)*step );
+ else dx= ceil( ((double)xkbi->mouseKeysDX)*step );
+ if (xkbi->mouseKeysDY<0)
+ dy= floor( ((double)xkbi->mouseKeysDY)*step );
+ else dy= ceil( ((double)xkbi->mouseKeysDY)*step );
+ }
+ else {
+ dx= xkbi->mouseKeysDX*ctrls->mk_max_speed;
+ dy= xkbi->mouseKeysDY*ctrls->mk_max_speed;
+ }
+ if (xkbi->mouseKeysFlags&XkbSA_MoveAbsoluteX)
+ dx= xkbi->mouseKeysDX;
+ if (xkbi->mouseKeysFlags&XkbSA_MoveAbsoluteY)
+ dy= xkbi->mouseKeysDY;
+ }
+ else {
+ dx= xkbi->mouseKeysDX;
+ dy= xkbi->mouseKeysDY;
+ }
+ XkbDDXFakePointerMotion(xkbi->mouseKeysFlags,dx,dy);
+ return xkbi->desc->ctrls->mk_interval;
+}
+
+static int
+_XkbFilterPointerMove( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+int x,y;
+Bool accel;
+
+ if (filter->keycode==0) { /* initial press */
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ filter->priv=0;
+ filter->filter = _XkbFilterPointerMove;
+ filter->upAction= *pAction;
+ xkbi->mouseKeysCounter= 0;
+ xkbi->mouseKey= keycode;
+ accel= ((pAction->ptr.flags&XkbSA_NoAcceleration)==0);
+ x= XkbPtrActionX(&pAction->ptr);
+ y= XkbPtrActionY(&pAction->ptr);
+ XkbDDXFakePointerMotion(pAction->ptr.flags,x,y);
+ AccessXCancelRepeatKey(xkbi,keycode);
+ xkbi->mouseKeysAccel= accel&&
+ (xkbi->desc->ctrls->enabled_ctrls&XkbMouseKeysAccelMask);
+ xkbi->mouseKeysFlags= pAction->ptr.flags;
+ xkbi->mouseKeysDX= XkbPtrActionX(&pAction->ptr);
+ xkbi->mouseKeysDY= XkbPtrActionY(&pAction->ptr);
+ xkbi->mouseKeyTimer= TimerSet(xkbi->mouseKeyTimer, 0,
+ xkbi->desc->ctrls->mk_delay,
+ _XkbPtrAccelExpire,(pointer)xkbi);
+ }
+ else if (filter->keycode==keycode) {
+ filter->active = 0;
+ if (xkbi->mouseKey==keycode) {
+ xkbi->mouseKey= 0;
+ xkbi->mouseKeyTimer= TimerSet(xkbi->mouseKeyTimer, 0, 0,
+ NULL, NULL);
+ }
+ }
+ return 0;
+}
+
+static int
+_XkbFilterPointerBtn( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+ if (filter->keycode==0) { /* initial press */
+ int button= pAction->btn.button;
+
+ if (button==XkbSA_UseDfltButton)
+ button = xkbi->desc->ctrls->mk_dflt_btn;
+
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ filter->priv=0;
+ filter->filter = _XkbFilterPointerBtn;
+ filter->upAction= *pAction;
+ filter->upAction.btn.button= button;
+ switch (pAction->type) {
+ case XkbSA_LockPtrBtn:
+ if (((xkbi->lockedPtrButtons&(1<<button))==0)&&
+ ((pAction->btn.flags&XkbSA_LockNoLock)==0)) {
+ xkbi->lockedPtrButtons|= (1<<button);
+ AccessXCancelRepeatKey(xkbi,keycode);
+ XkbDDXFakePointerButton(ButtonPress,button);
+ filter->upAction.type= XkbSA_NoAction;
+ }
+ break;
+ case XkbSA_PtrBtn:
+ {
+ register int i,nClicks;
+ AccessXCancelRepeatKey(xkbi,keycode);
+ if (pAction->btn.count>0) {
+ nClicks= pAction->btn.count;
+ for (i=0;i<nClicks;i++) {
+ XkbDDXFakePointerButton(ButtonPress,button);
+ XkbDDXFakePointerButton(ButtonRelease,button);
+ }
+ filter->upAction.type= XkbSA_NoAction;
+ }
+ else XkbDDXFakePointerButton(ButtonPress,button);
+ }
+ break;
+ case XkbSA_SetPtrDflt:
+ {
+ XkbControlsPtr ctrls= xkbi->desc->ctrls;
+ XkbControlsRec old;
+ xkbControlsNotify cn;
+
+ old= *ctrls;
+ AccessXCancelRepeatKey(xkbi,keycode);
+ switch (pAction->dflt.affect) {
+ case XkbSA_AffectDfltBtn:
+ if (pAction->dflt.flags&XkbSA_DfltBtnAbsolute)
+ ctrls->mk_dflt_btn=
+ XkbSAPtrDfltValue(&pAction->dflt);
+ else {
+ ctrls->mk_dflt_btn+=
+ XkbSAPtrDfltValue(&pAction->dflt);
+ if (ctrls->mk_dflt_btn>5)
+ ctrls->mk_dflt_btn= 5;
+ else if (ctrls->mk_dflt_btn<1)
+ ctrls->mk_dflt_btn= 1;
+ }
+ break;
+ default:
+ ErrorF(
+ "Attempt to change unknown pointer default (%d) ignored\n",
+ pAction->dflt.affect);
+ break;
+ }
+ if (XkbComputeControlsNotify(xkbi->device,
+ &old,xkbi->desc->ctrls,
+ &cn,False)) {
+ cn.keycode = keycode;
+ cn.eventType = KeyPress;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ XkbSendControlsNotify(xkbi->device,&cn);
+ }
+ }
+ break;
+ }
+ }
+ else if (filter->keycode==keycode) {
+ int button= filter->upAction.btn.button;
+
+ switch (filter->upAction.type) {
+ case XkbSA_LockPtrBtn:
+ if (((filter->upAction.btn.flags&XkbSA_LockNoUnlock)!=0)||
+ ((xkbi->lockedPtrButtons&(1<<button))==0)) {
+ break;
+ }
+ xkbi->lockedPtrButtons&= ~(1<<button);
+ case XkbSA_PtrBtn:
+ XkbDDXFakePointerButton(ButtonRelease,button);
+ break;
+ }
+ filter->active = 0;
+ }
+ return 0;
+}
+
+static int
+_XkbFilterControls( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+XkbControlsRec old;
+XkbControlsPtr ctrls;
+DeviceIntPtr kbd;
+unsigned int change;
+XkbEventCauseRec cause;
+
+ kbd= xkbi->device;
+ ctrls= xkbi->desc->ctrls;
+ old= *ctrls;
+ if (filter->keycode==0) { /* initial press */
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ change= XkbActionCtrls(&pAction->ctrls);
+ filter->priv = change;
+ filter->filter = _XkbFilterControls;
+ filter->upAction = *pAction;
+
+ if (pAction->type==XkbSA_LockControls) {
+ filter->priv= (ctrls->enabled_ctrls&change);
+ change&= ~ctrls->enabled_ctrls;
+ }
+
+ if (change) {
+ xkbControlsNotify cn;
+ XkbSrvLedInfoPtr sli;
+
+ ctrls->enabled_ctrls|= change;
+ if (XkbComputeControlsNotify(kbd,&old,ctrls,&cn,False)) {
+ cn.keycode = keycode;
+ cn.eventType = KeyPress;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ XkbSendControlsNotify(kbd,&cn);
+ }
+
+ XkbSetCauseKey(&cause,keycode,KeyPress);
+
+ /* If sticky keys were disabled, clear all locks and latches */
+ if ((old.enabled_ctrls&XkbStickyKeysMask)&&
+ (!(ctrls->enabled_ctrls&XkbStickyKeysMask))) {
+ XkbClearAllLatchesAndLocks(kbd,xkbi,False,&cause);
+ }
+ sli= XkbFindSrvLedInfo(kbd,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(kbd,sli->usesControls,True,NULL,&cause);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask))
+ XkbDDXAccessXBeep(kbd,_BEEP_FEATURE_ON,change);
+ }
+ }
+ else if (filter->keycode==keycode) {
+ change= filter->priv;
+ if (change) {
+ xkbControlsNotify cn;
+ XkbSrvLedInfoPtr sli;
+
+ ctrls->enabled_ctrls&= ~change;
+ if (XkbComputeControlsNotify(kbd,&old,ctrls,&cn,False)) {
+ cn.keycode = keycode;
+ cn.eventType = KeyRelease;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ XkbSendControlsNotify(kbd,&cn);
+ }
+
+ XkbSetCauseKey(&cause,keycode,KeyRelease);
+ /* If sticky keys were disabled, clear all locks and latches */
+ if ((old.enabled_ctrls&XkbStickyKeysMask)&&
+ (!(ctrls->enabled_ctrls&XkbStickyKeysMask))) {
+ XkbClearAllLatchesAndLocks(kbd,xkbi,False,&cause);
+ }
+ sli= XkbFindSrvLedInfo(kbd,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(kbd,sli->usesControls,True,NULL,&cause);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask))
+ XkbDDXAccessXBeep(kbd,_BEEP_FEATURE_OFF,change);
+ }
+ filter->keycode= 0;
+ filter->active= 0;
+ }
+ return 1;
+}
+
+static int
+_XkbFilterActionMessage(XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+XkbMessageAction * pMsg;
+DeviceIntPtr kbd;
+
+ kbd= xkbi->device;
+ if (filter->keycode==0) { /* initial press */
+ pMsg= &pAction->msg;
+ if ((pMsg->flags&XkbSA_MessageOnRelease)||
+ ((pMsg->flags&XkbSA_MessageGenKeyEvent)==0)) {
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ filter->priv = 0;
+ filter->filter = _XkbFilterActionMessage;
+ filter->upAction = *pAction;
+ }
+ if (pMsg->flags&XkbSA_MessageOnPress) {
+ xkbActionMessage msg;
+
+ msg.keycode= keycode;
+ msg.press= 1;
+ msg.keyEventFollows=((pMsg->flags&XkbSA_MessageGenKeyEvent)!=0);
+ memcpy((char *)msg.message,
+ (char *)pMsg->message,XkbActionMessageLength);
+ XkbSendActionMessage(kbd,&msg);
+ }
+ return ((pAction->msg.flags&XkbSA_MessageGenKeyEvent)!=0);
+ }
+ else if (filter->keycode==keycode) {
+ pMsg= &filter->upAction.msg;
+ if (pMsg->flags&XkbSA_MessageOnRelease) {
+ xkbActionMessage msg;
+
+ msg.keycode= keycode;
+ msg.press= 0;
+ msg.keyEventFollows=((pMsg->flags&XkbSA_MessageGenKeyEvent)!=0);
+ memcpy((char *)msg.message,(char *)pMsg->message,
+ XkbActionMessageLength);
+ XkbSendActionMessage(kbd,&msg);
+ }
+ filter->keycode= 0;
+ filter->active= 0;
+ return ((pMsg->flags&XkbSA_MessageGenKeyEvent)!=0);
+ }
+ return 0;
+}
+
+static int
+_XkbFilterRedirectKey( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+unsigned realMods;
+xEvent ev;
+int x,y;
+XkbStateRec old;
+unsigned mods,mask,oldCoreState = 0,oldCorePrevState = 0;
+xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device);
+
+ if ((filter->keycode!=0)&&(filter->keycode!=keycode))
+ return 1;
+
+ GetSpritePosition(&x,&y);
+ ev.u.keyButtonPointer.time = GetTimeInMillis();
+ ev.u.keyButtonPointer.rootX = x;
+ ev.u.keyButtonPointer.rootY = y;
+
+ if (filter->keycode==0) { /* initial press */
+ if ((pAction->redirect.new_key<xkbi->desc->min_key_code)||
+ (pAction->redirect.new_key>xkbi->desc->max_key_code)) {
+ return 1;
+ }
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ filter->priv = 0;
+ filter->filter = _XkbFilterRedirectKey;
+ filter->upAction = *pAction;
+
+ ev.u.u.type = KeyPress;
+ ev.u.u.detail = pAction->redirect.new_key;
+
+ mask= XkbSARedirectVModsMask(&pAction->redirect);
+ mods= XkbSARedirectVMods(&pAction->redirect);
+ if (mask) XkbVirtualModsToReal(xkbi->desc,mask,&mask);
+ if (mods) XkbVirtualModsToReal(xkbi->desc,mods,&mods);
+ mask|= pAction->redirect.mods_mask;
+ mods|= pAction->redirect.mods;
+
+ if ( mask || mods ) {
+ old= xkbi->state;
+ oldCoreState= xkbi->device->key->state;
+ oldCorePrevState= xkbi->device->key->prev_state;
+ xkbi->state.base_mods&= ~mask;
+ xkbi->state.base_mods|= (mods&mask);
+ xkbi->state.latched_mods&= ~mask;
+ xkbi->state.latched_mods|= (mods&mask);
+ xkbi->state.locked_mods&= ~mask;
+ xkbi->state.locked_mods|= (mods&mask);
+ XkbComputeDerivedState(xkbi);
+ xkbi->device->key->state= xkbi->device->key->prev_state=
+ xkbi->state.mods;
+ }
+
+ realMods = xkbi->device->key->modifierMap[ev.u.u.detail];
+ xkbi->device->key->modifierMap[ev.u.u.detail] = 0;
+ UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr);
+ xkbi->device->public.processInputProc(&ev,xkbi->device,1);
+ COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr,
+ ProcessKeyboardEvent,xkbUnwrapProc);
+ xkbi->device->key->modifierMap[ev.u.u.detail] = realMods;
+
+ if ( mask || mods ) {
+ xkbi->device->key->state= oldCoreState;
+ xkbi->device->key->prev_state= oldCorePrevState;
+ xkbi->state= old;
+ }
+ }
+ else if (filter->keycode==keycode) {
+
+ ev.u.u.type = KeyRelease;
+ ev.u.u.detail = filter->upAction.redirect.new_key;
+
+ mask= XkbSARedirectVModsMask(&filter->upAction.redirect);
+ mods= XkbSARedirectVMods(&filter->upAction.redirect);
+ if (mask) XkbVirtualModsToReal(xkbi->desc,mask,&mask);
+ if (mods) XkbVirtualModsToReal(xkbi->desc,mods,&mods);
+ mask|= filter->upAction.redirect.mods_mask;
+ mods|= filter->upAction.redirect.mods;
+
+ if ( mask || mods ) {
+ old= xkbi->state;
+ oldCoreState= xkbi->device->key->state;
+ oldCorePrevState= xkbi->device->key->prev_state;
+ xkbi->state.base_mods&= ~mask;
+ xkbi->state.base_mods|= (mods&mask);
+ xkbi->state.latched_mods&= ~mask;
+ xkbi->state.latched_mods|= (mods&mask);
+ xkbi->state.locked_mods&= ~mask;
+ xkbi->state.locked_mods|= (mods&mask);
+ XkbComputeDerivedState(xkbi);
+ xkbi->device->key->state= xkbi->device->key->prev_state=
+ xkbi->state.mods;
+ }
+
+ realMods = xkbi->device->key->modifierMap[ev.u.u.detail];
+ xkbi->device->key->modifierMap[ev.u.u.detail] = 0;
+ UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr);
+ xkbi->device->public.processInputProc(&ev,xkbi->device,1);
+ COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr,
+ ProcessKeyboardEvent,xkbUnwrapProc);
+ xkbi->device->key->modifierMap[ev.u.u.detail] = realMods;
+
+ if ( mask || mods ) {
+ xkbi->device->key->state= oldCoreState;
+ xkbi->device->key->prev_state= oldCorePrevState;
+ xkbi->state= old;
+ }
+
+ filter->keycode= 0;
+ filter->active= 0;
+ }
+ return 0;
+}
+
+static int
+_XkbFilterSwitchScreen( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+ if (filter->keycode==0) { /* initial press */
+ DeviceIntPtr dev = xkbi->device;
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ filter->filter = _XkbFilterSwitchScreen;
+ AccessXCancelRepeatKey(xkbi, keycode);
+ XkbDDXSwitchScreen(dev,keycode,pAction);
+ return 0;
+ }
+ else if (filter->keycode==keycode) {
+ filter->active= 0;
+ return 0;
+ }
+ return 1;
+}
+
+#ifdef XFree86Server
+static int
+_XkbFilterXF86Private( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+ if (filter->keycode==0) { /* initial press */
+ DeviceIntPtr dev = xkbi->device;
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ filter->filter = _XkbFilterXF86Private;
+ XkbDDXPrivate(dev,keycode,pAction);
+ return 0;
+ }
+ else if (filter->keycode==keycode) {
+ filter->active= 0;
+ return 0;
+ }
+ return 1;
+}
+#endif
+
+#ifdef XINPUT
+
+static int
+_XkbFilterDeviceBtn( XkbSrvInfoPtr xkbi,
+ XkbFilterPtr filter,
+ unsigned keycode,
+ XkbAction * pAction)
+{
+DeviceIntPtr dev;
+int button;
+
+ if (filter->keycode==0) { /* initial press */
+ dev= _XkbLookupButtonDevice(pAction->devbtn.device,NULL);
+ if ((!dev)||(!dev->public.on)||(&dev->public==LookupPointerDevice()))
+ return 1;
+
+ button= pAction->devbtn.button;
+ if ((button<1)||(button>dev->button->numButtons))
+ return 1;
+
+ filter->keycode = keycode;
+ filter->active = 1;
+ filter->filterOthers = 0;
+ filter->priv=0;
+ filter->filter = _XkbFilterDeviceBtn;
+ filter->upAction= *pAction;
+ switch (pAction->type) {
+ case XkbSA_LockDeviceBtn:
+ if ((pAction->devbtn.flags&XkbSA_LockNoLock)||
+ (dev->button->down[button/8]&(1L<<(button%8))))
+ return 0;
+ XkbDDXFakeDeviceButton(dev,True,button);
+ filter->upAction.type= XkbSA_NoAction;
+ break;
+ case XkbSA_DeviceBtn:
+ if (pAction->devbtn.count>0) {
+ int nClicks,i;
+ nClicks= pAction->btn.count;
+ for (i=0;i<nClicks;i++) {
+ XkbDDXFakeDeviceButton(dev,True,button);
+ XkbDDXFakeDeviceButton(dev,False,button);
+ }
+ filter->upAction.type= XkbSA_NoAction;
+ }
+ else XkbDDXFakeDeviceButton(dev,True,button);
+ break;
+ }
+ }
+ else if (filter->keycode==keycode) {
+ int button;
+
+ filter->active= 0;
+ dev= _XkbLookupButtonDevice(filter->upAction.devbtn.device,NULL);
+ if ((!dev)||(!dev->public.on)||(&dev->public==LookupPointerDevice()))
+ return 1;
+
+ button= filter->upAction.btn.button;
+ switch (filter->upAction.type) {
+ case XkbSA_LockDeviceBtn:
+ if ((filter->upAction.devbtn.flags&XkbSA_LockNoUnlock)||
+ ((dev->button->down[button/8]&(1L<<(button%8)))==0))
+ return 0;
+ XkbDDXFakeDeviceButton(dev,False,button);
+ break;
+ case XkbSA_DeviceBtn:
+ XkbDDXFakeDeviceButton(dev,False,button);
+ break;
+ }
+ filter->active = 0;
+ }
+ return 0;
+}
+#endif
+
+static int szFilters = 0;
+static XkbFilterPtr filters = NULL;
+
+static XkbFilterPtr
+_XkbNextFreeFilter(
+ void
+)
+{
+register int i;
+
+ if (szFilters==0) {
+ szFilters = 4;
+ filters = _XkbTypedCalloc(szFilters,XkbFilterRec);
+ /* 6/21/93 (ef) -- XXX! deal with allocation failure */
+ }
+ for (i=0;i<szFilters;i++) {
+ if (!filters[i].active) {
+ filters[i].keycode = 0;
+ return &filters[i];
+ }
+ }
+ szFilters*=2;
+ filters= _XkbTypedRealloc(filters,szFilters,XkbFilterRec);
+ /* 6/21/93 (ef) -- XXX! deal with allocation failure */
+ bzero(&filters[szFilters/2],(szFilters/2)*sizeof(XkbFilterRec));
+ return &filters[szFilters/2];
+}
+
+static int
+_XkbApplyFilters(XkbSrvInfoPtr xkbi,unsigned kc,XkbAction *pAction)
+{
+register int i,send;
+
+ send= 1;
+ for (i=0;i<szFilters;i++) {
+ if ((filters[i].active)&&(filters[i].filter))
+ send= ((*filters[i].filter)(xkbi,&filters[i],kc,pAction)&&send);
+ }
+ return send;
+}
+
+void
+XkbHandleActions(DeviceIntPtr dev,DeviceIntPtr kbd,xEvent *xE,int count)
+{
+int key,bit,i;
+CARD8 realMods;
+XkbSrvInfoPtr xkbi;
+KeyClassPtr keyc;
+int changed,sendEvent;
+Bool genStateNotify;
+XkbStateRec oldState;
+XkbAction act;
+XkbFilterPtr filter;
+Bool keyEvent;
+Bool pressEvent;
+#ifdef XINPUT
+Bool xiEvent;
+#endif
+
+xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
+
+ keyc= kbd->key;
+ xkbi= keyc->xkbInfo;
+ key= xE->u.u.detail;
+ if ((xkbi->flags&_XkbStateNotifyInProgress)==0) {
+ oldState= xkbi->state;
+ xkbi->flags|= _XkbStateNotifyInProgress;
+ genStateNotify= True;
+ }
+ else genStateNotify= False;
+
+ xkbi->clearMods = xkbi->setMods = 0;
+ xkbi->groupChange = 0;
+
+ sendEvent = 1;
+#ifdef XINPUT
+ keyEvent= ((xE->u.u.type==KeyPress)||(xE->u.u.type==DeviceKeyPress)||
+ (xE->u.u.type==KeyRelease)||(xE->u.u.type==DeviceKeyRelease));
+ pressEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==DeviceKeyPress)||
+ (xE->u.u.type==ButtonPress)||(xE->u.u.type==DeviceButtonPress);
+ xiEvent= (xE->u.u.type==DeviceKeyPress)||(xE->u.u.type==DeviceKeyRelease)||
+ (xE->u.u.type==DeviceButtonPress)||
+ (xE->u.u.type==DeviceButtonRelease);
+#else
+ keyEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease);
+ pressEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==ButtonPress);
+#endif
+
+ if (pressEvent) {
+ if (keyEvent)
+ act = XkbGetKeyAction(xkbi,&xkbi->state,key);
+ else {
+ act = XkbGetButtonAction(kbd,dev,key);
+ key|= BTN_ACT_FLAG;
+ }
+ sendEvent = _XkbApplyFilters(xkbi,key,&act);
+ if (sendEvent) {
+ switch (act.type) {
+ case XkbSA_SetMods:
+ case XkbSA_SetGroup:
+ filter = _XkbNextFreeFilter();
+ sendEvent = _XkbFilterSetState(xkbi,filter,key,&act);
+ break;
+ case XkbSA_LatchMods:
+ case XkbSA_LatchGroup:
+ filter = _XkbNextFreeFilter();
+ sendEvent=_XkbFilterLatchState(xkbi,filter,key,&act);
+ break;
+ case XkbSA_LockMods:
+ case XkbSA_LockGroup:
+ filter = _XkbNextFreeFilter();
+ sendEvent=_XkbFilterLockState(xkbi,filter,key,&act);
+ break;
+ case XkbSA_ISOLock:
+ filter = _XkbNextFreeFilter();
+ sendEvent=_XkbFilterISOLock(xkbi,filter,key,&act);
+ break;
+ case XkbSA_MovePtr:
+ filter = _XkbNextFreeFilter();
+ sendEvent= _XkbFilterPointerMove(xkbi,filter,key,&act);
+ break;
+ case XkbSA_PtrBtn:
+ case XkbSA_LockPtrBtn:
+ case XkbSA_SetPtrDflt:
+ filter = _XkbNextFreeFilter();
+ sendEvent= _XkbFilterPointerBtn(xkbi,filter,key,&act);
+ break;
+ case XkbSA_Terminate:
+ sendEvent= XkbDDXTerminateServer(dev,key,&act);
+ break;
+ case XkbSA_SwitchScreen:
+ filter = _XkbNextFreeFilter();
+ sendEvent=_XkbFilterSwitchScreen(xkbi,filter,key,&act);
+ break;
+ case XkbSA_SetControls:
+ case XkbSA_LockControls:
+ filter = _XkbNextFreeFilter();
+ sendEvent=_XkbFilterControls(xkbi,filter,key,&act);
+ break;
+ case XkbSA_ActionMessage:
+ filter = _XkbNextFreeFilter();
+ sendEvent=_XkbFilterActionMessage(xkbi,filter,key,&act);
+ break;
+ case XkbSA_RedirectKey:
+ filter = _XkbNextFreeFilter();
+ sendEvent= _XkbFilterRedirectKey(xkbi,filter,key,&act);
+ break;
+#ifdef XINPUT
+ case XkbSA_DeviceBtn:
+ case XkbSA_LockDeviceBtn:
+ filter = _XkbNextFreeFilter();
+ sendEvent= _XkbFilterDeviceBtn(xkbi,filter,key,&act);
+ break;
+#endif
+#ifdef XFree86Server
+ case XkbSA_XFree86Private:
+ filter = _XkbNextFreeFilter();
+ sendEvent= _XkbFilterXF86Private(xkbi,filter,key,&act);
+ break;
+#endif
+ }
+ }
+ }
+ else {
+ if (!keyEvent)
+ key|= BTN_ACT_FLAG;
+ sendEvent = _XkbApplyFilters(xkbi,key,NULL);
+ }
+
+ if (xkbi->groupChange!=0)
+ xkbi->state.base_group+= xkbi->groupChange;
+ if (xkbi->setMods) {
+ for (i=0,bit=1; xkbi->setMods; i++,bit<<=1 ) {
+ if (xkbi->setMods&bit) {
+ keyc->modifierKeyCount[i]++;
+ xkbi->state.base_mods|= bit;
+ xkbi->setMods&= ~bit;
+ }
+ }
+ }
+ if (xkbi->clearMods) {
+ for (i=0,bit=1; xkbi->clearMods; i++,bit<<=1 ) {
+ if (xkbi->clearMods&bit) {
+ keyc->modifierKeyCount[i]--;
+ if (keyc->modifierKeyCount[i]<=0) {
+ xkbi->state.base_mods&= ~bit;
+ keyc->modifierKeyCount[i] = 0;
+ }
+ xkbi->clearMods&= ~bit;
+ }
+ }
+ }
+
+ if (sendEvent) {
+#ifdef XINPUT
+ if (xiEvent)
+ ProcessOtherEvent(xE,dev,count);
+ else
+#endif
+ if (keyEvent) {
+ realMods = keyc->modifierMap[key];
+ keyc->modifierMap[key] = 0;
+ UNWRAP_PROCESS_INPUT_PROC(dev,xkbPrivPtr);
+ dev->public.processInputProc(xE,dev,count);
+ COND_WRAP_PROCESS_INPUT_PROC(dev, xkbPrivPtr,
+ ProcessKeyboardEvent,xkbUnwrapProc);
+ keyc->modifierMap[key] = realMods;
+ }
+ else CoreProcessPointerEvent(xE,dev,count);
+ }
+ else if (keyEvent)
+ FixKeyState(xE,dev);
+
+ xkbi->prev_state= oldState;
+ XkbComputeDerivedState(xkbi);
+ keyc->prev_state= keyc->state;
+ keyc->state= XkbStateFieldFromRec(&xkbi->state);
+ changed = XkbStateChangedFlags(&oldState,&xkbi->state);
+ if (genStateNotify) {
+ if (changed) {
+ xkbStateNotify sn;
+ sn.keycode= key;
+ sn.eventType= xE->u.u.type;
+ sn.requestMajor = sn.requestMinor = 0;
+ sn.changed= changed;
+ XkbSendStateNotify(dev,&sn);
+ }
+ xkbi->flags&= ~_XkbStateNotifyInProgress;
+ }
+ changed= XkbIndicatorsToUpdate(dev,changed,False);
+ if (changed) {
+ XkbEventCauseRec cause;
+ XkbSetCauseKey(&cause,key,xE->u.u.type);
+ XkbUpdateIndicators(dev,changed,True,NULL,&cause);
+ }
+ return;
+}
+
+int
+XkbLatchModifiers(DeviceIntPtr pXDev,CARD8 mask,CARD8 latches)
+{
+XkbSrvInfoPtr xkbi;
+XkbFilterPtr filter;
+XkbAction act;
+unsigned clear;
+
+ if ( pXDev && pXDev->key && pXDev->key->xkbInfo ) {
+ xkbi = pXDev->key->xkbInfo;
+ clear= (mask&(~latches));
+ xkbi->state.latched_mods&= ~clear;
+ /* Clear any pending latch to locks.
+ */
+ act.type = XkbSA_NoAction;
+ _XkbApplyFilters(xkbi,SYNTHETIC_KEYCODE,&act);
+ act.type = XkbSA_LatchMods;
+ act.mods.flags = 0;
+ act.mods.mask = mask&latches;
+ filter = _XkbNextFreeFilter();
+ _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,&act);
+ _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,(XkbAction *)NULL);
+ return Success;
+ }
+ return BadValue;
+}
+
+int
+XkbLatchGroup(DeviceIntPtr pXDev,int group)
+{
+XkbSrvInfoPtr xkbi;
+XkbFilterPtr filter;
+XkbAction act;
+
+ if ( pXDev && pXDev->key && pXDev->key->xkbInfo ) {
+ xkbi = pXDev->key->xkbInfo;
+ act.type = XkbSA_LatchGroup;
+ act.group.flags = 0;
+ XkbSASetGroup(&act.group,group);
+ filter = _XkbNextFreeFilter();
+ _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,&act);
+ _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,(XkbAction *)NULL);
+ return Success;
+ }
+ return BadValue;
+}
+
+/***====================================================================***/
+
+void
+XkbClearAllLatchesAndLocks( DeviceIntPtr dev,
+ XkbSrvInfoPtr xkbi,
+ Bool genEv,
+ XkbEventCausePtr cause)
+{
+XkbStateRec os;
+xkbStateNotify sn;
+
+ sn.changed= 0;
+ os= xkbi->state;
+ if (os.latched_mods) { /* clear all latches */
+ XkbLatchModifiers(dev,~0,0);
+ sn.changed|= XkbModifierLatchMask;
+ }
+ if (os.latched_group) {
+ XkbLatchGroup(dev,0);
+ sn.changed|= XkbGroupLatchMask;
+ }
+ if (os.locked_mods) {
+ xkbi->state.locked_mods= 0;
+ sn.changed|= XkbModifierLockMask;
+ }
+ if (os.locked_group) {
+ xkbi->state.locked_group= 0;
+ sn.changed|= XkbGroupLockMask;
+ }
+ if ( genEv && sn.changed) {
+ CARD32 changed;
+
+ XkbComputeDerivedState(xkbi);
+ sn.keycode= cause->kc;
+ sn.eventType= cause->event;
+ sn.requestMajor= cause->mjr;
+ sn.requestMinor= cause->mnr;
+ sn.changed= XkbStateChangedFlags(&os,&xkbi->state);
+ XkbSendStateNotify(dev,&sn);
+ changed= XkbIndicatorsToUpdate(dev,sn.changed,False);
+ if (changed) {
+ XkbUpdateIndicators(dev,changed,True,NULL,cause);
+ }
+ }
+ return;
+}
+
diff --git a/nx-X11/programs/Xserver/xkb/xkbDflts.h b/nx-X11/programs/Xserver/xkb/xkbDflts.h
new file mode 100644
index 000000000..e0b54c55b
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/xkbDflts.h
@@ -0,0 +1,524 @@
+/* $Xorg: xkbDflts.h,v 1.3 2000/08/17 19:53:47 cpqbld Exp $ */
+/* $XFree86: xc/programs/Xserver/xkb/xkbDflts.h,v 1.2 2001/10/28 03:34:20 tsi Exp $ */
+/* This file generated automatically by xkbcomp */
+/* DO NOT EDIT */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef DEFAULT_H
+#define DEFAULT_H 1
+
+#ifndef XKB_IN_SERVER
+#define GET_ATOM(d,s) XInternAtom(d,s,0)
+#define DPYTYPE Display *
+#else
+#define GET_ATOM(d,s) MakeAtom(s,strlen(s),1)
+#define DPYTYPE char *
+#endif
+#define NUM_KEYS 1
+
+#define vmod_NumLock 0
+#define vmod_Alt 1
+#define vmod_LevelThree 2
+#define vmod_AltGr 3
+#define vmod_ScrollLock 4
+
+#define vmod_NumLockMask (1<<0)
+#define vmod_AltMask (1<<1)
+#define vmod_LevelThreeMask (1<<2)
+#define vmod_AltGrMask (1<<3)
+#define vmod_ScrollLockMask (1<<4)
+
+/* types name is "default" */
+static Atom lnames_ONE_LEVEL[1];
+
+static XkbKTMapEntryRec map_TWO_LEVEL[1]= {
+ { 1, 1, { ShiftMask, ShiftMask, 0 } }
+};
+static Atom lnames_TWO_LEVEL[2];
+
+static XkbKTMapEntryRec map_ALPHABETIC[2]= {
+ { 1, 1, { ShiftMask, ShiftMask, 0 } },
+ { 1, 0, { LockMask, LockMask, 0 } }
+};
+static XkbModsRec preserve_ALPHABETIC[2]= {
+ { 0, 0, 0 },
+ { LockMask, LockMask, 0 }
+};
+static Atom lnames_ALPHABETIC[2];
+
+static XkbKTMapEntryRec map_KEYPAD[2]= {
+ { 1, 1, { ShiftMask, ShiftMask, 0 } },
+ { 0, 1, { 0, 0, vmod_NumLockMask } }
+};
+static Atom lnames_KEYPAD[2];
+
+static XkbKTMapEntryRec map_PC_BREAK[1]= {
+ { 1, 1, { ControlMask, ControlMask, 0 } }
+};
+static Atom lnames_PC_BREAK[2];
+
+static XkbKTMapEntryRec map_PC_SYSRQ[1]= {
+ { 0, 1, { 0, 0, vmod_AltMask } }
+};
+static Atom lnames_PC_SYSRQ[2];
+
+static XkbKTMapEntryRec map_CTRL_ALT[1]= {
+ { 0, 1, { ControlMask, ControlMask, vmod_AltMask } }
+};
+static Atom lnames_CTRL_ALT[2];
+
+static XkbKTMapEntryRec map_THREE_LEVEL[3]= {
+ { 1, 1, { ShiftMask, ShiftMask, 0 } },
+ { 0, 2, { 0, 0, vmod_LevelThreeMask } },
+ { 0, 2, { ShiftMask, ShiftMask, vmod_LevelThreeMask } }
+};
+static Atom lnames_THREE_LEVEL[3];
+
+static XkbKTMapEntryRec map_SHIFT_ALT[1]= {
+ { 0, 1, { ShiftMask, ShiftMask, vmod_AltMask } }
+};
+static Atom lnames_SHIFT_ALT[2];
+
+static XkbKeyTypeRec dflt_types[]= {
+ {
+ { 0, 0, 0 },
+ 1,
+ 0, NULL, NULL,
+ None, lnames_ONE_LEVEL
+ },
+ {
+ { ShiftMask, ShiftMask, 0 },
+ 2,
+ 1, map_TWO_LEVEL, NULL,
+ None, lnames_TWO_LEVEL
+ },
+ {
+ { ShiftMask|LockMask, ShiftMask|LockMask, 0 },
+ 2,
+ 2, map_ALPHABETIC, preserve_ALPHABETIC,
+ None, lnames_ALPHABETIC
+ },
+ {
+ { ShiftMask, ShiftMask, vmod_NumLockMask },
+ 2,
+ 2, map_KEYPAD, NULL,
+ None, lnames_KEYPAD
+ },
+ {
+ { ControlMask, ControlMask, 0 },
+ 2,
+ 1, map_PC_BREAK, NULL,
+ None, lnames_PC_BREAK
+ },
+ {
+ { 0, 0, vmod_AltMask },
+ 2,
+ 1, map_PC_SYSRQ, NULL,
+ None, lnames_PC_SYSRQ
+ },
+ {
+ { ControlMask, ControlMask, vmod_AltMask },
+ 2,
+ 1, map_CTRL_ALT, NULL,
+ None, lnames_CTRL_ALT
+ },
+ {
+ { ShiftMask, ShiftMask, vmod_LevelThreeMask },
+ 3,
+ 3, map_THREE_LEVEL, NULL,
+ None, lnames_THREE_LEVEL
+ },
+ {
+ { ShiftMask, ShiftMask, vmod_AltMask },
+ 2,
+ 1, map_SHIFT_ALT, NULL,
+ None, lnames_SHIFT_ALT
+ }
+};
+#define num_dflt_types (sizeof(dflt_types)/sizeof(XkbKeyTypeRec))
+
+
+static void
+initTypeNames(DPYTYPE dpy)
+{
+ dflt_types[0].name= GET_ATOM(dpy,"ONE_LEVEL");
+ lnames_ONE_LEVEL[0]= GET_ATOM(dpy,"Any");
+ dflt_types[1].name= GET_ATOM(dpy,"TWO_LEVEL");
+ lnames_TWO_LEVEL[0]= GET_ATOM(dpy,"Base");
+ lnames_TWO_LEVEL[1]= GET_ATOM(dpy,"Shift");
+ dflt_types[2].name= GET_ATOM(dpy,"ALPHABETIC");
+ lnames_ALPHABETIC[0]= GET_ATOM(dpy,"Base");
+ lnames_ALPHABETIC[1]= GET_ATOM(dpy,"Caps");
+ dflt_types[3].name= GET_ATOM(dpy,"KEYPAD");
+ lnames_KEYPAD[0]= GET_ATOM(dpy,"Base");
+ lnames_KEYPAD[1]= GET_ATOM(dpy,"Number");
+ dflt_types[4].name= GET_ATOM(dpy,"PC_BREAK");
+ lnames_PC_BREAK[0]= GET_ATOM(dpy,"Base");
+ lnames_PC_BREAK[1]= GET_ATOM(dpy,"Control");
+ dflt_types[5].name= GET_ATOM(dpy,"PC_SYSRQ");
+ lnames_PC_SYSRQ[0]= GET_ATOM(dpy,"Base");
+ lnames_PC_SYSRQ[1]= GET_ATOM(dpy,"Alt");
+ dflt_types[6].name= GET_ATOM(dpy,"CTRL+ALT");
+ lnames_CTRL_ALT[0]= GET_ATOM(dpy,"Base");
+ lnames_CTRL_ALT[1]= GET_ATOM(dpy,"Ctrl+Alt");
+ dflt_types[7].name= GET_ATOM(dpy,"THREE_LEVEL");
+ lnames_THREE_LEVEL[0]= GET_ATOM(dpy,"Base");
+ lnames_THREE_LEVEL[1]= GET_ATOM(dpy,"Shift");
+ lnames_THREE_LEVEL[2]= GET_ATOM(dpy,"Level3");
+ dflt_types[8].name= GET_ATOM(dpy,"SHIFT+ALT");
+ lnames_SHIFT_ALT[0]= GET_ATOM(dpy,"Base");
+ lnames_SHIFT_ALT[1]= GET_ATOM(dpy,"Shift+Alt");
+}
+/* compat name is "default" */
+static XkbSymInterpretRec dfltSI[69]= {
+ { XK_ISO_Level2_Latch, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_Exactly, ShiftMask,
+ 255,
+ { XkbSA_LatchMods, { 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Eisu_Shift, 0x0000,
+ XkbSI_Exactly, LockMask,
+ 255,
+ { XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Eisu_toggle, 0x0000,
+ XkbSI_Exactly, LockMask,
+ 255,
+ { XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Kana_Shift, 0x0000,
+ XkbSI_Exactly, LockMask,
+ 255,
+ { XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Kana_Lock, 0x0000,
+ XkbSI_Exactly, LockMask,
+ 255,
+ { XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Shift_Lock, 0x0000,
+ XkbSI_AnyOf, ShiftMask|LockMask,
+ 255,
+ { XkbSA_LockMods, { 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Num_Lock, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 0,
+ { XkbSA_LockMods, { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_Alt_L, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 1,
+ { XkbSA_SetMods, { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Alt_R, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 1,
+ { XkbSA_SetMods, { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Scroll_Lock, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 4,
+ { XkbSA_LockMods, { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_Lock, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 255,
+ { XkbSA_ISOLock, { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_Level3_Shift, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOf, 0xff,
+ 2,
+ { XkbSA_SetMods, { 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00 } } },
+ { XK_ISO_Level3_Latch, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOf, 0xff,
+ 2,
+ { XkbSA_LatchMods, { 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00 } } },
+ { XK_Mode_switch, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff,
+ 3,
+ { XkbSA_SetGroup, { 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_1, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_End, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_2, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_Down, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_3, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_Next, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_4, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Left, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_6, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Right, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_7, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_Home, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_8, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_Up, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_9, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_Prior, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_5, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Begin, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_F1, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Divide, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_F2, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Multiply, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_F3, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Subtract, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Separator, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Add, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_0, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Insert, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Decimal, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Delete, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Button_Dflt, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Button1, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Button2, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Button3, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_DblClick_Dflt, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_DblClick1, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_DblClick2, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_DblClick3, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Drag_Dflt, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Drag1, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Drag2, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Drag3, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_EnableKeys, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockControls, { 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00 } } },
+ { XK_Pointer_Accelerate, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockControls, { 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00 } } },
+ { XK_Pointer_DfltBtnNext, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_DfltBtnPrev, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_AccessX_Enable, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockControls, { 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00 } } },
+
+#ifndef NX_TRANS_SOCKET
+
+ /*
+ * Make sure that the server can't be killed
+ * by pressing this key-sequence.
+ */
+
+ { XK_Terminate_Server, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_Terminate, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+
+#endif
+
+ { XK_ISO_Group_Latch, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff,
+ 3,
+ { XkbSA_LatchGroup, { 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_Next_Group, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff,
+ 3,
+ { XkbSA_LockGroup, { 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_Prev_Group, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff,
+ 3,
+ { XkbSA_LockGroup, { 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_First_Group, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockGroup, { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_Last_Group, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockGroup, { 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { NoSymbol, 0x0000,
+ XkbSI_Exactly, LockMask,
+ 255,
+ { XkbSA_LockMods, { 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { NoSymbol, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 255,
+ { XkbSA_SetMods, { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }
+};
+#define num_dfltSI (sizeof(dfltSI)/sizeof(XkbSymInterpretRec))
+
+static XkbCompatMapRec compatMap= {
+ dfltSI,
+ { /* group compatibility */
+ { 0, 0, 0 },
+ { 0, 0, vmod_AltGrMask },
+ { 0, 0, vmod_AltGrMask },
+ { 0, 0, vmod_AltGrMask }
+ },
+ num_dfltSI, num_dfltSI
+};
+
+static XkbIndicatorRec indicators= {
+ 0x0,
+ {
+ { 0x80, 0, 0x00, XkbIM_UseEffective, { LockMask, LockMask, 0 }, 0 },
+ { 0x80, 0, 0x00, XkbIM_UseEffective, { 0, 0, vmod_NumLockMask }, 0 },
+ { 0x80, 0, 0x00, XkbIM_UseLocked, { ShiftMask, ShiftMask, 0 }, 0 },
+ { 0x80, 0, 0x00, 0, { 0, 0, 0 }, XkbMouseKeysMask },
+ { 0x80, 0, 0x00, XkbIM_UseLocked, { 0, 0, vmod_ScrollLockMask }, 0 },
+ { 0x80, XkbIM_UseEffective, 0xfe, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }
+ }
+};
+static void
+initIndicatorNames(DPYTYPE dpy,XkbDescPtr xkb)
+{
+ xkb->names->indicators[ 0]= GET_ATOM(dpy,"Caps Lock");
+ xkb->names->indicators[ 1]= GET_ATOM(dpy,"Num Lock");
+ xkb->names->indicators[ 2]= GET_ATOM(dpy,"Shift Lock");
+ xkb->names->indicators[ 3]= GET_ATOM(dpy,"Mouse Keys");
+ xkb->names->indicators[ 4]= GET_ATOM(dpy,"Scroll Lock");
+ xkb->names->indicators[ 5]= GET_ATOM(dpy,"Group 2");
+}
+#endif /* DEFAULT_H */
diff --git a/nx-X11/programs/Xserver/xkb/xkbDflts.h.NX.original b/nx-X11/programs/Xserver/xkb/xkbDflts.h.NX.original
new file mode 100644
index 000000000..e0b54c55b
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/xkbDflts.h.NX.original
@@ -0,0 +1,524 @@
+/* $Xorg: xkbDflts.h,v 1.3 2000/08/17 19:53:47 cpqbld Exp $ */
+/* $XFree86: xc/programs/Xserver/xkb/xkbDflts.h,v 1.2 2001/10/28 03:34:20 tsi Exp $ */
+/* This file generated automatically by xkbcomp */
+/* DO NOT EDIT */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef DEFAULT_H
+#define DEFAULT_H 1
+
+#ifndef XKB_IN_SERVER
+#define GET_ATOM(d,s) XInternAtom(d,s,0)
+#define DPYTYPE Display *
+#else
+#define GET_ATOM(d,s) MakeAtom(s,strlen(s),1)
+#define DPYTYPE char *
+#endif
+#define NUM_KEYS 1
+
+#define vmod_NumLock 0
+#define vmod_Alt 1
+#define vmod_LevelThree 2
+#define vmod_AltGr 3
+#define vmod_ScrollLock 4
+
+#define vmod_NumLockMask (1<<0)
+#define vmod_AltMask (1<<1)
+#define vmod_LevelThreeMask (1<<2)
+#define vmod_AltGrMask (1<<3)
+#define vmod_ScrollLockMask (1<<4)
+
+/* types name is "default" */
+static Atom lnames_ONE_LEVEL[1];
+
+static XkbKTMapEntryRec map_TWO_LEVEL[1]= {
+ { 1, 1, { ShiftMask, ShiftMask, 0 } }
+};
+static Atom lnames_TWO_LEVEL[2];
+
+static XkbKTMapEntryRec map_ALPHABETIC[2]= {
+ { 1, 1, { ShiftMask, ShiftMask, 0 } },
+ { 1, 0, { LockMask, LockMask, 0 } }
+};
+static XkbModsRec preserve_ALPHABETIC[2]= {
+ { 0, 0, 0 },
+ { LockMask, LockMask, 0 }
+};
+static Atom lnames_ALPHABETIC[2];
+
+static XkbKTMapEntryRec map_KEYPAD[2]= {
+ { 1, 1, { ShiftMask, ShiftMask, 0 } },
+ { 0, 1, { 0, 0, vmod_NumLockMask } }
+};
+static Atom lnames_KEYPAD[2];
+
+static XkbKTMapEntryRec map_PC_BREAK[1]= {
+ { 1, 1, { ControlMask, ControlMask, 0 } }
+};
+static Atom lnames_PC_BREAK[2];
+
+static XkbKTMapEntryRec map_PC_SYSRQ[1]= {
+ { 0, 1, { 0, 0, vmod_AltMask } }
+};
+static Atom lnames_PC_SYSRQ[2];
+
+static XkbKTMapEntryRec map_CTRL_ALT[1]= {
+ { 0, 1, { ControlMask, ControlMask, vmod_AltMask } }
+};
+static Atom lnames_CTRL_ALT[2];
+
+static XkbKTMapEntryRec map_THREE_LEVEL[3]= {
+ { 1, 1, { ShiftMask, ShiftMask, 0 } },
+ { 0, 2, { 0, 0, vmod_LevelThreeMask } },
+ { 0, 2, { ShiftMask, ShiftMask, vmod_LevelThreeMask } }
+};
+static Atom lnames_THREE_LEVEL[3];
+
+static XkbKTMapEntryRec map_SHIFT_ALT[1]= {
+ { 0, 1, { ShiftMask, ShiftMask, vmod_AltMask } }
+};
+static Atom lnames_SHIFT_ALT[2];
+
+static XkbKeyTypeRec dflt_types[]= {
+ {
+ { 0, 0, 0 },
+ 1,
+ 0, NULL, NULL,
+ None, lnames_ONE_LEVEL
+ },
+ {
+ { ShiftMask, ShiftMask, 0 },
+ 2,
+ 1, map_TWO_LEVEL, NULL,
+ None, lnames_TWO_LEVEL
+ },
+ {
+ { ShiftMask|LockMask, ShiftMask|LockMask, 0 },
+ 2,
+ 2, map_ALPHABETIC, preserve_ALPHABETIC,
+ None, lnames_ALPHABETIC
+ },
+ {
+ { ShiftMask, ShiftMask, vmod_NumLockMask },
+ 2,
+ 2, map_KEYPAD, NULL,
+ None, lnames_KEYPAD
+ },
+ {
+ { ControlMask, ControlMask, 0 },
+ 2,
+ 1, map_PC_BREAK, NULL,
+ None, lnames_PC_BREAK
+ },
+ {
+ { 0, 0, vmod_AltMask },
+ 2,
+ 1, map_PC_SYSRQ, NULL,
+ None, lnames_PC_SYSRQ
+ },
+ {
+ { ControlMask, ControlMask, vmod_AltMask },
+ 2,
+ 1, map_CTRL_ALT, NULL,
+ None, lnames_CTRL_ALT
+ },
+ {
+ { ShiftMask, ShiftMask, vmod_LevelThreeMask },
+ 3,
+ 3, map_THREE_LEVEL, NULL,
+ None, lnames_THREE_LEVEL
+ },
+ {
+ { ShiftMask, ShiftMask, vmod_AltMask },
+ 2,
+ 1, map_SHIFT_ALT, NULL,
+ None, lnames_SHIFT_ALT
+ }
+};
+#define num_dflt_types (sizeof(dflt_types)/sizeof(XkbKeyTypeRec))
+
+
+static void
+initTypeNames(DPYTYPE dpy)
+{
+ dflt_types[0].name= GET_ATOM(dpy,"ONE_LEVEL");
+ lnames_ONE_LEVEL[0]= GET_ATOM(dpy,"Any");
+ dflt_types[1].name= GET_ATOM(dpy,"TWO_LEVEL");
+ lnames_TWO_LEVEL[0]= GET_ATOM(dpy,"Base");
+ lnames_TWO_LEVEL[1]= GET_ATOM(dpy,"Shift");
+ dflt_types[2].name= GET_ATOM(dpy,"ALPHABETIC");
+ lnames_ALPHABETIC[0]= GET_ATOM(dpy,"Base");
+ lnames_ALPHABETIC[1]= GET_ATOM(dpy,"Caps");
+ dflt_types[3].name= GET_ATOM(dpy,"KEYPAD");
+ lnames_KEYPAD[0]= GET_ATOM(dpy,"Base");
+ lnames_KEYPAD[1]= GET_ATOM(dpy,"Number");
+ dflt_types[4].name= GET_ATOM(dpy,"PC_BREAK");
+ lnames_PC_BREAK[0]= GET_ATOM(dpy,"Base");
+ lnames_PC_BREAK[1]= GET_ATOM(dpy,"Control");
+ dflt_types[5].name= GET_ATOM(dpy,"PC_SYSRQ");
+ lnames_PC_SYSRQ[0]= GET_ATOM(dpy,"Base");
+ lnames_PC_SYSRQ[1]= GET_ATOM(dpy,"Alt");
+ dflt_types[6].name= GET_ATOM(dpy,"CTRL+ALT");
+ lnames_CTRL_ALT[0]= GET_ATOM(dpy,"Base");
+ lnames_CTRL_ALT[1]= GET_ATOM(dpy,"Ctrl+Alt");
+ dflt_types[7].name= GET_ATOM(dpy,"THREE_LEVEL");
+ lnames_THREE_LEVEL[0]= GET_ATOM(dpy,"Base");
+ lnames_THREE_LEVEL[1]= GET_ATOM(dpy,"Shift");
+ lnames_THREE_LEVEL[2]= GET_ATOM(dpy,"Level3");
+ dflt_types[8].name= GET_ATOM(dpy,"SHIFT+ALT");
+ lnames_SHIFT_ALT[0]= GET_ATOM(dpy,"Base");
+ lnames_SHIFT_ALT[1]= GET_ATOM(dpy,"Shift+Alt");
+}
+/* compat name is "default" */
+static XkbSymInterpretRec dfltSI[69]= {
+ { XK_ISO_Level2_Latch, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_Exactly, ShiftMask,
+ 255,
+ { XkbSA_LatchMods, { 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Eisu_Shift, 0x0000,
+ XkbSI_Exactly, LockMask,
+ 255,
+ { XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Eisu_toggle, 0x0000,
+ XkbSI_Exactly, LockMask,
+ 255,
+ { XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Kana_Shift, 0x0000,
+ XkbSI_Exactly, LockMask,
+ 255,
+ { XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Kana_Lock, 0x0000,
+ XkbSI_Exactly, LockMask,
+ 255,
+ { XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Shift_Lock, 0x0000,
+ XkbSI_AnyOf, ShiftMask|LockMask,
+ 255,
+ { XkbSA_LockMods, { 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Num_Lock, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 0,
+ { XkbSA_LockMods, { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_Alt_L, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 1,
+ { XkbSA_SetMods, { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Alt_R, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 1,
+ { XkbSA_SetMods, { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Scroll_Lock, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 4,
+ { XkbSA_LockMods, { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_Lock, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 255,
+ { XkbSA_ISOLock, { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_Level3_Shift, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOf, 0xff,
+ 2,
+ { XkbSA_SetMods, { 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00 } } },
+ { XK_ISO_Level3_Latch, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOf, 0xff,
+ 2,
+ { XkbSA_LatchMods, { 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00 } } },
+ { XK_Mode_switch, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff,
+ 3,
+ { XkbSA_SetGroup, { 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_1, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_End, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_2, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_Down, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_3, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_Next, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_4, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Left, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_6, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Right, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_7, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_Home, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_8, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_Up, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_9, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_Prior, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_5, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Begin, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_F1, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Divide, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_F2, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Multiply, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_F3, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Subtract, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Separator, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Add, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_0, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Insert, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Decimal, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Delete, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Button_Dflt, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Button1, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Button2, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Button3, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_DblClick_Dflt, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_DblClick1, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_DblClick2, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_DblClick3, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Drag_Dflt, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Drag1, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Drag2, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Drag3, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_EnableKeys, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockControls, { 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00 } } },
+ { XK_Pointer_Accelerate, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockControls, { 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00 } } },
+ { XK_Pointer_DfltBtnNext, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_DfltBtnPrev, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_AccessX_Enable, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockControls, { 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00 } } },
+
+#ifndef NX_TRANS_SOCKET
+
+ /*
+ * Make sure that the server can't be killed
+ * by pressing this key-sequence.
+ */
+
+ { XK_Terminate_Server, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_Terminate, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+
+#endif
+
+ { XK_ISO_Group_Latch, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff,
+ 3,
+ { XkbSA_LatchGroup, { 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_Next_Group, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff,
+ 3,
+ { XkbSA_LockGroup, { 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_Prev_Group, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff,
+ 3,
+ { XkbSA_LockGroup, { 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_First_Group, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockGroup, { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_Last_Group, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockGroup, { 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { NoSymbol, 0x0000,
+ XkbSI_Exactly, LockMask,
+ 255,
+ { XkbSA_LockMods, { 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { NoSymbol, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 255,
+ { XkbSA_SetMods, { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }
+};
+#define num_dfltSI (sizeof(dfltSI)/sizeof(XkbSymInterpretRec))
+
+static XkbCompatMapRec compatMap= {
+ dfltSI,
+ { /* group compatibility */
+ { 0, 0, 0 },
+ { 0, 0, vmod_AltGrMask },
+ { 0, 0, vmod_AltGrMask },
+ { 0, 0, vmod_AltGrMask }
+ },
+ num_dfltSI, num_dfltSI
+};
+
+static XkbIndicatorRec indicators= {
+ 0x0,
+ {
+ { 0x80, 0, 0x00, XkbIM_UseEffective, { LockMask, LockMask, 0 }, 0 },
+ { 0x80, 0, 0x00, XkbIM_UseEffective, { 0, 0, vmod_NumLockMask }, 0 },
+ { 0x80, 0, 0x00, XkbIM_UseLocked, { ShiftMask, ShiftMask, 0 }, 0 },
+ { 0x80, 0, 0x00, 0, { 0, 0, 0 }, XkbMouseKeysMask },
+ { 0x80, 0, 0x00, XkbIM_UseLocked, { 0, 0, vmod_ScrollLockMask }, 0 },
+ { 0x80, XkbIM_UseEffective, 0xfe, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }
+ }
+};
+static void
+initIndicatorNames(DPYTYPE dpy,XkbDescPtr xkb)
+{
+ xkb->names->indicators[ 0]= GET_ATOM(dpy,"Caps Lock");
+ xkb->names->indicators[ 1]= GET_ATOM(dpy,"Num Lock");
+ xkb->names->indicators[ 2]= GET_ATOM(dpy,"Shift Lock");
+ xkb->names->indicators[ 3]= GET_ATOM(dpy,"Mouse Keys");
+ xkb->names->indicators[ 4]= GET_ATOM(dpy,"Scroll Lock");
+ xkb->names->indicators[ 5]= GET_ATOM(dpy,"Group 2");
+}
+#endif /* DEFAULT_H */
diff --git a/nx-X11/programs/Xserver/xkb/xkbDflts.h.X.original b/nx-X11/programs/Xserver/xkb/xkbDflts.h.X.original
new file mode 100644
index 000000000..e3dd9cdda
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/xkbDflts.h.X.original
@@ -0,0 +1,513 @@
+/* $Xorg: xkbDflts.h,v 1.3 2000/08/17 19:53:47 cpqbld Exp $ */
+/* $XFree86: xc/programs/Xserver/xkb/xkbDflts.h,v 1.2 2001/10/28 03:34:20 tsi Exp $ */
+/* This file generated automatically by xkbcomp */
+/* DO NOT EDIT */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef DEFAULT_H
+#define DEFAULT_H 1
+
+#ifndef XKB_IN_SERVER
+#define GET_ATOM(d,s) XInternAtom(d,s,0)
+#define DPYTYPE Display *
+#else
+#define GET_ATOM(d,s) MakeAtom(s,strlen(s),1)
+#define DPYTYPE char *
+#endif
+#define NUM_KEYS 1
+
+#define vmod_NumLock 0
+#define vmod_Alt 1
+#define vmod_LevelThree 2
+#define vmod_AltGr 3
+#define vmod_ScrollLock 4
+
+#define vmod_NumLockMask (1<<0)
+#define vmod_AltMask (1<<1)
+#define vmod_LevelThreeMask (1<<2)
+#define vmod_AltGrMask (1<<3)
+#define vmod_ScrollLockMask (1<<4)
+
+/* types name is "default" */
+static Atom lnames_ONE_LEVEL[1];
+
+static XkbKTMapEntryRec map_TWO_LEVEL[1]= {
+ { 1, 1, { ShiftMask, ShiftMask, 0 } }
+};
+static Atom lnames_TWO_LEVEL[2];
+
+static XkbKTMapEntryRec map_ALPHABETIC[2]= {
+ { 1, 1, { ShiftMask, ShiftMask, 0 } },
+ { 1, 0, { LockMask, LockMask, 0 } }
+};
+static XkbModsRec preserve_ALPHABETIC[2]= {
+ { 0, 0, 0 },
+ { LockMask, LockMask, 0 }
+};
+static Atom lnames_ALPHABETIC[2];
+
+static XkbKTMapEntryRec map_KEYPAD[2]= {
+ { 1, 1, { ShiftMask, ShiftMask, 0 } },
+ { 0, 1, { 0, 0, vmod_NumLockMask } }
+};
+static Atom lnames_KEYPAD[2];
+
+static XkbKTMapEntryRec map_PC_BREAK[1]= {
+ { 1, 1, { ControlMask, ControlMask, 0 } }
+};
+static Atom lnames_PC_BREAK[2];
+
+static XkbKTMapEntryRec map_PC_SYSRQ[1]= {
+ { 0, 1, { 0, 0, vmod_AltMask } }
+};
+static Atom lnames_PC_SYSRQ[2];
+
+static XkbKTMapEntryRec map_CTRL_ALT[1]= {
+ { 0, 1, { ControlMask, ControlMask, vmod_AltMask } }
+};
+static Atom lnames_CTRL_ALT[2];
+
+static XkbKTMapEntryRec map_THREE_LEVEL[3]= {
+ { 1, 1, { ShiftMask, ShiftMask, 0 } },
+ { 0, 2, { 0, 0, vmod_LevelThreeMask } },
+ { 0, 2, { ShiftMask, ShiftMask, vmod_LevelThreeMask } }
+};
+static Atom lnames_THREE_LEVEL[3];
+
+static XkbKTMapEntryRec map_SHIFT_ALT[1]= {
+ { 0, 1, { ShiftMask, ShiftMask, vmod_AltMask } }
+};
+static Atom lnames_SHIFT_ALT[2];
+
+static XkbKeyTypeRec dflt_types[]= {
+ {
+ { 0, 0, 0 },
+ 1,
+ 0, NULL, NULL,
+ None, lnames_ONE_LEVEL
+ },
+ {
+ { ShiftMask, ShiftMask, 0 },
+ 2,
+ 1, map_TWO_LEVEL, NULL,
+ None, lnames_TWO_LEVEL
+ },
+ {
+ { ShiftMask|LockMask, ShiftMask|LockMask, 0 },
+ 2,
+ 2, map_ALPHABETIC, preserve_ALPHABETIC,
+ None, lnames_ALPHABETIC
+ },
+ {
+ { ShiftMask, ShiftMask, vmod_NumLockMask },
+ 2,
+ 2, map_KEYPAD, NULL,
+ None, lnames_KEYPAD
+ },
+ {
+ { ControlMask, ControlMask, 0 },
+ 2,
+ 1, map_PC_BREAK, NULL,
+ None, lnames_PC_BREAK
+ },
+ {
+ { 0, 0, vmod_AltMask },
+ 2,
+ 1, map_PC_SYSRQ, NULL,
+ None, lnames_PC_SYSRQ
+ },
+ {
+ { ControlMask, ControlMask, vmod_AltMask },
+ 2,
+ 1, map_CTRL_ALT, NULL,
+ None, lnames_CTRL_ALT
+ },
+ {
+ { ShiftMask, ShiftMask, vmod_LevelThreeMask },
+ 3,
+ 3, map_THREE_LEVEL, NULL,
+ None, lnames_THREE_LEVEL
+ },
+ {
+ { ShiftMask, ShiftMask, vmod_AltMask },
+ 2,
+ 1, map_SHIFT_ALT, NULL,
+ None, lnames_SHIFT_ALT
+ }
+};
+#define num_dflt_types (sizeof(dflt_types)/sizeof(XkbKeyTypeRec))
+
+
+static void
+initTypeNames(DPYTYPE dpy)
+{
+ dflt_types[0].name= GET_ATOM(dpy,"ONE_LEVEL");
+ lnames_ONE_LEVEL[0]= GET_ATOM(dpy,"Any");
+ dflt_types[1].name= GET_ATOM(dpy,"TWO_LEVEL");
+ lnames_TWO_LEVEL[0]= GET_ATOM(dpy,"Base");
+ lnames_TWO_LEVEL[1]= GET_ATOM(dpy,"Shift");
+ dflt_types[2].name= GET_ATOM(dpy,"ALPHABETIC");
+ lnames_ALPHABETIC[0]= GET_ATOM(dpy,"Base");
+ lnames_ALPHABETIC[1]= GET_ATOM(dpy,"Caps");
+ dflt_types[3].name= GET_ATOM(dpy,"KEYPAD");
+ lnames_KEYPAD[0]= GET_ATOM(dpy,"Base");
+ lnames_KEYPAD[1]= GET_ATOM(dpy,"Number");
+ dflt_types[4].name= GET_ATOM(dpy,"PC_BREAK");
+ lnames_PC_BREAK[0]= GET_ATOM(dpy,"Base");
+ lnames_PC_BREAK[1]= GET_ATOM(dpy,"Control");
+ dflt_types[5].name= GET_ATOM(dpy,"PC_SYSRQ");
+ lnames_PC_SYSRQ[0]= GET_ATOM(dpy,"Base");
+ lnames_PC_SYSRQ[1]= GET_ATOM(dpy,"Alt");
+ dflt_types[6].name= GET_ATOM(dpy,"CTRL+ALT");
+ lnames_CTRL_ALT[0]= GET_ATOM(dpy,"Base");
+ lnames_CTRL_ALT[1]= GET_ATOM(dpy,"Ctrl+Alt");
+ dflt_types[7].name= GET_ATOM(dpy,"THREE_LEVEL");
+ lnames_THREE_LEVEL[0]= GET_ATOM(dpy,"Base");
+ lnames_THREE_LEVEL[1]= GET_ATOM(dpy,"Shift");
+ lnames_THREE_LEVEL[2]= GET_ATOM(dpy,"Level3");
+ dflt_types[8].name= GET_ATOM(dpy,"SHIFT+ALT");
+ lnames_SHIFT_ALT[0]= GET_ATOM(dpy,"Base");
+ lnames_SHIFT_ALT[1]= GET_ATOM(dpy,"Shift+Alt");
+}
+/* compat name is "default" */
+static XkbSymInterpretRec dfltSI[69]= {
+ { XK_ISO_Level2_Latch, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_Exactly, ShiftMask,
+ 255,
+ { XkbSA_LatchMods, { 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Eisu_Shift, 0x0000,
+ XkbSI_Exactly, LockMask,
+ 255,
+ { XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Eisu_toggle, 0x0000,
+ XkbSI_Exactly, LockMask,
+ 255,
+ { XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Kana_Shift, 0x0000,
+ XkbSI_Exactly, LockMask,
+ 255,
+ { XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Kana_Lock, 0x0000,
+ XkbSI_Exactly, LockMask,
+ 255,
+ { XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Shift_Lock, 0x0000,
+ XkbSI_AnyOf, ShiftMask|LockMask,
+ 255,
+ { XkbSA_LockMods, { 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Num_Lock, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 0,
+ { XkbSA_LockMods, { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_Alt_L, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 1,
+ { XkbSA_SetMods, { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Alt_R, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 1,
+ { XkbSA_SetMods, { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Scroll_Lock, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 4,
+ { XkbSA_LockMods, { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_Lock, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 255,
+ { XkbSA_ISOLock, { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_Level3_Shift, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOf, 0xff,
+ 2,
+ { XkbSA_SetMods, { 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00 } } },
+ { XK_ISO_Level3_Latch, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOf, 0xff,
+ 2,
+ { XkbSA_LatchMods, { 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00 } } },
+ { XK_Mode_switch, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff,
+ 3,
+ { XkbSA_SetGroup, { 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_1, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_End, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_2, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_Down, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_3, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_Next, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00 } } },
+ { XK_KP_4, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Left, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_6, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Right, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_7, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_Home, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_8, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_Up, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_9, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_Prior, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0xff, 0xff, 0x00, 0x00 } } },
+ { XK_KP_5, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Begin, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_F1, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Divide, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_F2, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Multiply, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_F3, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Subtract, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Separator, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Add, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_0, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Insert, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Decimal, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_KP_Delete, 0x0001,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Button_Dflt, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Button1, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Button2, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Button3, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_DblClick_Dflt, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_DblClick1, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_DblClick2, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_DblClick3, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_PtrBtn, { 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Drag_Dflt, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Drag1, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Drag2, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_Drag3, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockPtrBtn, { 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_EnableKeys, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockControls, { 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00 } } },
+ { XK_Pointer_Accelerate, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockControls, { 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00 } } },
+ { XK_Pointer_DfltBtnNext, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_Pointer_DfltBtnPrev, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_SetPtrDflt, { 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_AccessX_Enable, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockControls, { 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00 } } },
+ { XK_Terminate_Server, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_Terminate, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_Group_Latch, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff,
+ 3,
+ { XkbSA_LatchGroup, { 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_Next_Group, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff,
+ 3,
+ { XkbSA_LockGroup, { 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_Prev_Group, 0x0000,
+ XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff,
+ 3,
+ { XkbSA_LockGroup, { 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_First_Group, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockGroup, { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { XK_ISO_Last_Group, 0x0000,
+ XkbSI_AnyOfOrNone, 0xff,
+ 255,
+ { XkbSA_LockGroup, { 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
+ { NoSymbol, 0x0000,
+ XkbSI_Exactly, LockMask,
+ 255,
+ { XkbSA_LockMods, { 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00 } } },
+ { NoSymbol, 0x0000,
+ XkbSI_AnyOf, 0xff,
+ 255,
+ { XkbSA_SetMods, { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }
+};
+#define num_dfltSI (sizeof(dfltSI)/sizeof(XkbSymInterpretRec))
+
+static XkbCompatMapRec compatMap= {
+ dfltSI,
+ { /* group compatibility */
+ { 0, 0, 0 },
+ { 0, 0, vmod_AltGrMask },
+ { 0, 0, vmod_AltGrMask },
+ { 0, 0, vmod_AltGrMask }
+ },
+ num_dfltSI, num_dfltSI
+};
+
+static XkbIndicatorRec indicators= {
+ 0x0,
+ {
+ { 0x80, 0, 0x00, XkbIM_UseEffective, { LockMask, LockMask, 0 }, 0 },
+ { 0x80, 0, 0x00, XkbIM_UseEffective, { 0, 0, vmod_NumLockMask }, 0 },
+ { 0x80, 0, 0x00, XkbIM_UseLocked, { ShiftMask, ShiftMask, 0 }, 0 },
+ { 0x80, 0, 0x00, 0, { 0, 0, 0 }, XkbMouseKeysMask },
+ { 0x80, 0, 0x00, XkbIM_UseLocked, { 0, 0, vmod_ScrollLockMask }, 0 },
+ { 0x80, XkbIM_UseEffective, 0xfe, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 },
+ { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }
+ }
+};
+static void
+initIndicatorNames(DPYTYPE dpy,XkbDescPtr xkb)
+{
+ xkb->names->indicators[ 0]= GET_ATOM(dpy,"Caps Lock");
+ xkb->names->indicators[ 1]= GET_ATOM(dpy,"Num Lock");
+ xkb->names->indicators[ 2]= GET_ATOM(dpy,"Shift Lock");
+ xkb->names->indicators[ 3]= GET_ATOM(dpy,"Mouse Keys");
+ xkb->names->indicators[ 4]= GET_ATOM(dpy,"Scroll Lock");
+ xkb->names->indicators[ 5]= GET_ATOM(dpy,"Group 2");
+}
+#endif /* DEFAULT_H */
diff --git a/nx-X11/programs/Xserver/xkb/xkbEvents.c b/nx-X11/programs/Xserver/xkb/xkbEvents.c
new file mode 100644
index 000000000..8305208a0
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/xkbEvents.c
@@ -0,0 +1,1057 @@
+/* $Xorg: xkbEvents.c,v 1.3 2000/08/17 19:53:47 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/xkbEvents.c,v 3.11 2003/07/16 01:39:10 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include <X11/extensions/XI.h>
+#include "inputstr.h"
+#include "windowstr.h"
+#include <X11/extensions/XKBsrv.h>
+#include "xkb.h"
+
+/***====================================================================***/
+
+void
+XkbSendNewKeyboardNotify(DeviceIntPtr kbd,xkbNewKeyboardNotify *pNKN)
+{
+register int i;
+Time time;
+CARD16 changed;
+
+ pNKN->type = XkbEventCode + XkbEventBase;
+ pNKN->xkbType = XkbNewKeyboardNotify;
+ pNKN->time = time = GetTimeInMillis();
+ changed = pNKN->changed;
+
+ for (i=1; i<currentMaxClients; i++) {
+ if ((!clients[i]) || clients[i]->clientGone ||
+ (clients[i]->requestVector==InitialVector)) {
+ continue;
+ }
+
+ if (clients[i]->xkbClientFlags&_XkbClientInitialized) {
+ if (clients[i]->newKeyboardNotifyMask&changed) {
+ pNKN->sequenceNumber = clients[i]->sequence;
+ pNKN->time = time;
+ pNKN->changed = changed;
+ if ( clients[i]->swapped ) {
+ register int n;
+ swaps(&pNKN->sequenceNumber,n);
+ swapl(&pNKN->time,n);
+ swaps(&pNKN->changed,n);
+ }
+ WriteToClient(clients[i],sizeof(xEvent),(char *)pNKN);
+ if (changed&XkbNKN_KeycodesMask) {
+ clients[i]->minKC= pNKN->minKeyCode;
+ clients[i]->maxKC= pNKN->maxKeyCode;
+ }
+ }
+ }
+ else if (changed&XkbNKN_KeycodesMask) {
+ xEvent event;
+ event.u.u.type= MappingNotify;
+ event.u.mappingNotify.request= MappingKeyboard;
+ event.u.mappingNotify.firstKeyCode= clients[i]->minKC;
+ event.u.mappingNotify.count= clients[i]->maxKC-clients[i]->minKC+1;
+ event.u.u.sequenceNumber= clients[i]->sequence;
+ if (clients[i]->swapped) {
+ int n;
+ swaps(&event.u.u.sequenceNumber,n);
+ }
+ WriteToClient(clients[i],SIZEOF(xEvent), (char *)&event);
+ event.u.mappingNotify.request= MappingModifier;
+ WriteToClient(clients[i],SIZEOF(xEvent), (char *)&event);
+ }
+ }
+ return;
+}
+
+/***====================================================================***/
+
+void
+XkbSendStateNotify(DeviceIntPtr kbd,xkbStateNotify *pSN)
+{
+XkbSrvInfoPtr xkbi;
+XkbStatePtr state;
+XkbInterestPtr interest;
+Time time;
+register CARD16 changed,bState;
+
+ interest = kbd->xkb_interest;
+ if (!interest)
+ return;
+ xkbi = kbd->key->xkbInfo;
+ state= &xkbi->state;
+
+ pSN->type = XkbEventCode + XkbEventBase;
+ pSN->xkbType = XkbStateNotify;
+ pSN->deviceID = kbd->id;
+ pSN->time = time = GetTimeInMillis();
+ pSN->mods = state->mods;
+ pSN->baseMods = state->base_mods;
+ pSN->latchedMods = state->latched_mods;
+ pSN->lockedMods = state->locked_mods;
+ pSN->group = state->group;
+ pSN->baseGroup = state->base_group;
+ pSN->latchedGroup = state->latched_group;
+ pSN->lockedGroup = state->locked_group;
+ pSN->compatState = state->compat_state;
+ pSN->grabMods = state->grab_mods;
+ pSN->compatGrabMods = state->compat_grab_mods;
+ pSN->lookupMods = state->lookup_mods;
+ pSN->compatLookupMods = state->compat_lookup_mods;
+ pSN->ptrBtnState = state->ptr_buttons;
+ changed = pSN->changed;
+ bState= pSN->ptrBtnState;
+
+ while (interest) {
+ if ((!interest->client->clientGone) &&
+ (interest->client->requestVector != InitialVector) &&
+ (interest->client->xkbClientFlags&_XkbClientInitialized) &&
+ (interest->stateNotifyMask&changed)) {
+ pSN->sequenceNumber = interest->client->sequence;
+ pSN->time = time;
+ pSN->changed = changed;
+ pSN->ptrBtnState = bState;
+ if ( interest->client->swapped ) {
+ register int n;
+ swaps(&pSN->sequenceNumber,n);
+ swapl(&pSN->time,n);
+ swaps(&pSN->changed,n);
+ swaps(&pSN->ptrBtnState,n);
+ }
+ WriteToClient(interest->client, sizeof(xEvent), (char *)pSN);
+ }
+ interest= interest->next;
+ }
+ return;
+}
+
+/***====================================================================***/
+
+void
+XkbSendMapNotify(DeviceIntPtr kbd,xkbMapNotify *pMN)
+{
+int i;
+XkbSrvInfoPtr xkbi;
+unsigned time = 0,initialized;
+CARD16 changed;
+
+ xkbi = kbd->key->xkbInfo;
+ initialized= 0;
+
+ changed = pMN->changed;
+ pMN->minKeyCode= xkbi->desc->min_key_code;
+ pMN->maxKeyCode= xkbi->desc->max_key_code;
+ for (i=1; i<currentMaxClients; i++) {
+ if (clients[i] && ! clients[i]->clientGone &&
+ (clients[i]->requestVector != InitialVector) &&
+ (clients[i]->xkbClientFlags&_XkbClientInitialized) &&
+ (clients[i]->mapNotifyMask&changed))
+ {
+ if (!initialized) {
+ pMN->type = XkbEventCode + XkbEventBase;
+ pMN->xkbType = XkbMapNotify;
+ pMN->deviceID = kbd->id;
+ time = GetTimeInMillis();
+ initialized= 1;
+ }
+ pMN->time= time;
+ pMN->sequenceNumber = clients[i]->sequence;
+ pMN->changed = changed;
+ if ( clients[i]->swapped ) {
+ register int n;
+ swaps(&pMN->sequenceNumber,n);
+ swapl(&pMN->time,n);
+ swaps(&pMN->changed,n);
+ }
+ WriteToClient(clients[i],sizeof(xEvent),(char *)pMN);
+ }
+ }
+ return;
+}
+
+int
+XkbComputeControlsNotify( DeviceIntPtr kbd,
+ XkbControlsPtr old,
+ XkbControlsPtr new,
+ xkbControlsNotify * pCN,
+ Bool forceCtrlProc)
+{
+int i;
+CARD32 changedControls;
+
+ changedControls= 0;
+ if (old->enabled_ctrls!=new->enabled_ctrls)
+ changedControls|= XkbControlsEnabledMask;
+ if ((old->repeat_delay!=new->repeat_delay)||
+ (old->repeat_interval!=new->repeat_interval))
+ changedControls|= XkbRepeatKeysMask;
+ for (i = 0; i < XkbPerKeyBitArraySize; i++)
+ if (old->per_key_repeat[i] != new->per_key_repeat[i])
+ changedControls|= XkbPerKeyRepeatMask;
+ if (old->slow_keys_delay!=new->slow_keys_delay)
+ changedControls|= XkbSlowKeysMask;
+ if (old->debounce_delay!=new->debounce_delay)
+ changedControls|= XkbBounceKeysMask;
+ if ((old->mk_delay!=new->mk_delay)||
+ (old->mk_interval!=new->mk_interval)||
+ (old->mk_dflt_btn!=new->mk_dflt_btn))
+ changedControls|= XkbMouseKeysMask;
+ if ((old->mk_time_to_max!=new->mk_time_to_max)||
+ (old->mk_curve!=new->mk_curve)||
+ (old->mk_max_speed!=new->mk_max_speed))
+ changedControls|= XkbMouseKeysAccelMask;
+ if (old->ax_options!=new->ax_options)
+ changedControls|= XkbAccessXKeysMask;
+ if ((old->ax_options^new->ax_options) & XkbAX_SKOptionsMask)
+ changedControls|= XkbStickyKeysMask;
+ if ((old->ax_options^new->ax_options) & XkbAX_FBOptionsMask)
+ changedControls|= XkbAccessXFeedbackMask;
+ if ((old->ax_timeout!=new->ax_timeout)||
+ (old->axt_ctrls_mask!=new->axt_ctrls_mask)||
+ (old->axt_ctrls_values!=new->axt_ctrls_values)||
+ (old->axt_opts_mask!=new->axt_opts_mask)||
+ (old->axt_opts_values!= new->axt_opts_values)) {
+ changedControls|= XkbAccessXTimeoutMask;
+ }
+ if ((old->internal.mask!=new->internal.mask)||
+ (old->internal.real_mods!=new->internal.real_mods)||
+ (old->internal.vmods!=new->internal.vmods))
+ changedControls|= XkbInternalModsMask;
+ if ((old->ignore_lock.mask!=new->ignore_lock.mask)||
+ (old->ignore_lock.real_mods!=new->ignore_lock.real_mods)||
+ (old->ignore_lock.vmods!=new->ignore_lock.vmods))
+ changedControls|= XkbIgnoreLockModsMask;
+
+ if (new->enabled_ctrls&XkbRepeatKeysMask)
+ kbd->kbdfeed->ctrl.autoRepeat=TRUE;
+ else kbd->kbdfeed->ctrl.autoRepeat=FALSE;
+
+ if (kbd->kbdfeed && kbd->kbdfeed->CtrlProc &&
+ (changedControls || forceCtrlProc))
+ (*kbd->kbdfeed->CtrlProc)(kbd, &kbd->kbdfeed->ctrl);
+
+ if ((!changedControls)&&(old->num_groups==new->num_groups))
+ return 0;
+
+ if (!kbd->xkb_interest)
+ return 0;
+
+ pCN->changedControls = changedControls;
+ pCN->enabledControls = new->enabled_ctrls;
+ pCN->enabledControlChanges = (new->enabled_ctrls^old->enabled_ctrls);
+ pCN->numGroups = new->num_groups;
+
+ return 1;
+}
+
+void
+XkbSendControlsNotify(DeviceIntPtr kbd,xkbControlsNotify *pCN)
+{
+int initialized;
+CARD32 changedControls, enabledControls, enabledChanges = 0;
+XkbSrvInfoPtr xkbi;
+XkbInterestPtr interest;
+Time time = 0;
+
+ interest = kbd->xkb_interest;
+ if (!interest)
+ return;
+ xkbi = kbd->key->xkbInfo;
+
+ initialized = 0;
+ enabledControls = xkbi->desc->ctrls->enabled_ctrls;
+ changedControls = pCN->changedControls;
+ pCN->numGroups= xkbi->desc->ctrls->num_groups;
+ while (interest) {
+ if ((!interest->client->clientGone) &&
+ (interest->client->requestVector != InitialVector) &&
+ (interest->client->xkbClientFlags&_XkbClientInitialized) &&
+ (interest->ctrlsNotifyMask&changedControls)) {
+ if (!initialized) {
+ pCN->type = XkbEventCode + XkbEventBase;
+ pCN->xkbType = XkbControlsNotify;
+ pCN->deviceID = kbd->id;
+ pCN->time = time = GetTimeInMillis();
+ enabledChanges = pCN->enabledControlChanges;
+ initialized= 1;
+ }
+ pCN->changedControls = changedControls;
+ pCN->enabledControls = enabledControls;
+ pCN->enabledControlChanges = enabledChanges;
+ pCN->sequenceNumber = interest->client->sequence;
+ pCN->time = time;
+ if ( interest->client->swapped ) {
+ register int n;
+ swaps(&pCN->sequenceNumber,n);
+ swapl(&pCN->changedControls,n);
+ swapl(&pCN->enabledControls,n);
+ swapl(&pCN->enabledControlChanges,n);
+ swapl(&pCN->time,n);
+ }
+ WriteToClient(interest->client, sizeof(xEvent), (char *)pCN);
+ }
+ interest= interest->next;
+ }
+ return;
+}
+
+void
+XkbSendIndicatorNotify(DeviceIntPtr kbd,int xkbType,xkbIndicatorNotify *pEv)
+{
+int initialized;
+XkbInterestPtr interest;
+Time time = 0;
+CARD32 state,changed;
+
+ interest = kbd->xkb_interest;
+ if (!interest)
+ return;
+
+ initialized = 0;
+ state = pEv->state;
+ changed = pEv->changed;
+ while (interest) {
+ if ((!interest->client->clientGone) &&
+ (interest->client->requestVector != InitialVector) &&
+ (interest->client->xkbClientFlags&_XkbClientInitialized) &&
+ (((xkbType==XkbIndicatorStateNotify)&&
+ (interest->iStateNotifyMask&changed))||
+ ((xkbType==XkbIndicatorMapNotify)&&
+ (interest->iMapNotifyMask&changed)))) {
+ if (!initialized) {
+ pEv->type = XkbEventCode + XkbEventBase;
+ pEv->xkbType = xkbType;
+ pEv->deviceID = kbd->id;
+ pEv->time = time = GetTimeInMillis();
+ initialized= 1;
+ }
+ pEv->sequenceNumber = interest->client->sequence;
+ pEv->time = time;
+ pEv->changed = changed;
+ pEv->state = state;
+ if ( interest->client->swapped ) {
+ register int n;
+ swaps(&pEv->sequenceNumber,n);
+ swapl(&pEv->time,n);
+ swapl(&pEv->changed,n);
+ swapl(&pEv->state,n);
+ }
+ WriteToClient(interest->client, sizeof(xEvent), (char *)pEv);
+ }
+ interest= interest->next;
+ }
+ return;
+}
+
+
+void
+XkbHandleBell( BOOL force,
+ BOOL eventOnly,
+ DeviceIntPtr kbd,
+ CARD8 percent,
+ pointer pCtrl,
+ CARD8 class,
+ Atom name,
+ WindowPtr pWin,
+ ClientPtr pClient)
+{
+xkbBellNotify bn;
+int initialized;
+XkbSrvInfoPtr xkbi;
+XkbInterestPtr interest;
+CARD8 id;
+CARD16 pitch,duration;
+Time time = 0;
+XID winID = 0;
+
+ xkbi = kbd->key->xkbInfo;
+
+ if ((force||(xkbi->desc->ctrls->enabled_ctrls&XkbAudibleBellMask))&&
+ (!eventOnly)) {
+ (*kbd->kbdfeed->BellProc)(percent,kbd,(pointer)pCtrl,class);
+ }
+ interest = kbd->xkb_interest;
+ if ((!interest)||(force))
+ return;
+
+ if ((class==0)||(class==KbdFeedbackClass)) {
+ KeybdCtrl *pKeyCtrl= (KeybdCtrl *)pCtrl;
+ id= pKeyCtrl->id;
+ pitch= pKeyCtrl->bell_pitch;
+ duration= pKeyCtrl->bell_duration;
+ }
+ else if (class==BellFeedbackClass) {
+ BellCtrl *pBellCtrl= (BellCtrl *)pCtrl;
+ id= pBellCtrl->id;
+ pitch= pBellCtrl->pitch;
+ duration= pBellCtrl->duration;
+ }
+ else return;
+
+ initialized = 0;
+ while (interest) {
+ if ((!interest->client->clientGone) &&
+ (interest->client->requestVector != InitialVector) &&
+ (interest->client->xkbClientFlags&_XkbClientInitialized) &&
+ (interest->bellNotifyMask)) {
+ if (!initialized) {
+ time = GetTimeInMillis();
+ bn.type = XkbEventCode + XkbEventBase;
+ bn.xkbType = XkbBellNotify;
+ bn.deviceID = kbd->id;
+ bn.bellClass = class;
+ bn.bellID = id;
+ bn.percent= percent;
+ bn.eventOnly = (eventOnly!=0);
+ winID= (pWin?pWin->drawable.id:None);
+ initialized= 1;
+ }
+ bn.sequenceNumber = interest->client->sequence;
+ bn.time = time;
+ bn.pitch = pitch;
+ bn.duration = duration;
+ bn.name = name;
+ bn.window= winID;
+ if ( interest->client->swapped ) {
+ register int n;
+ swaps(&bn.sequenceNumber,n);
+ swapl(&bn.time,n);
+ swaps(&bn.pitch,n);
+ swaps(&bn.duration,n);
+ swapl(&bn.name,n);
+ swapl(&bn.window,n);
+ }
+ WriteToClient(interest->client, sizeof(xEvent), (char *)&bn);
+ }
+ interest= interest->next;
+ }
+ return;
+}
+
+void
+XkbSendAccessXNotify(DeviceIntPtr kbd,xkbAccessXNotify *pEv)
+{
+int initialized;
+XkbInterestPtr interest;
+Time time = 0;
+CARD16 sk_delay,db_delay;
+
+ interest = kbd->xkb_interest;
+ if (!interest)
+ return;
+
+ initialized = 0;
+ sk_delay= pEv->slowKeysDelay;
+ db_delay= pEv->debounceDelay;
+ while (interest) {
+ if ((!interest->client->clientGone) &&
+ (interest->client->requestVector != InitialVector) &&
+ (interest->client->xkbClientFlags&_XkbClientInitialized) &&
+ (interest->accessXNotifyMask&(1<<pEv->detail))) {
+ if (!initialized) {
+ pEv->type = XkbEventCode + XkbEventBase;
+ pEv->xkbType = XkbAccessXNotify;
+ pEv->deviceID = kbd->id;
+ pEv->time = time = GetTimeInMillis();
+ initialized= 1;
+ }
+ pEv->sequenceNumber = interest->client->sequence;
+ pEv->time = time;
+ pEv->slowKeysDelay = sk_delay;
+ pEv->debounceDelay = db_delay;
+ if ( interest->client->swapped ) {
+ register int n;
+ swaps(&pEv->sequenceNumber,n);
+ swapl(&pEv->time,n);
+ swaps(&pEv->slowKeysDelay,n);
+ swaps(&pEv->debounceDelay,n);
+ }
+ WriteToClient(interest->client, sizeof(xEvent), (char *)pEv);
+ }
+ interest= interest->next;
+ }
+ return;
+}
+
+void
+XkbSendNamesNotify(DeviceIntPtr kbd,xkbNamesNotify *pEv)
+{
+int initialized;
+XkbInterestPtr interest;
+Time time = 0;
+CARD16 changed,changedVirtualMods;
+CARD32 changedIndicators;
+
+ interest = kbd->xkb_interest;
+ if (!interest)
+ return;
+
+ initialized = 0;
+ changed= pEv->changed;
+ changedIndicators= pEv->changedIndicators;
+ changedVirtualMods= pEv->changedVirtualMods;
+ while (interest) {
+ if ((!interest->client->clientGone) &&
+ (interest->client->requestVector != InitialVector) &&
+ (interest->client->xkbClientFlags&_XkbClientInitialized) &&
+ (interest->namesNotifyMask&pEv->changed)) {
+ if (!initialized) {
+ pEv->type = XkbEventCode + XkbEventBase;
+ pEv->xkbType = XkbNamesNotify;
+ pEv->deviceID = kbd->id;
+ pEv->time = time = GetTimeInMillis();
+ initialized= 1;
+ }
+ pEv->sequenceNumber = interest->client->sequence;
+ pEv->time = time;
+ pEv->changed = changed;
+ pEv->changedIndicators = changedIndicators;
+ pEv->changedVirtualMods= changedVirtualMods;
+ if ( interest->client->swapped ) {
+ register int n;
+ swaps(&pEv->sequenceNumber,n);
+ swapl(&pEv->time,n);
+ swaps(&pEv->changed,n);
+ swapl(&pEv->changedIndicators,n);
+ swaps(&pEv->changedVirtualMods,n);
+ }
+ WriteToClient(interest->client, sizeof(xEvent), (char *)pEv);
+ }
+ interest= interest->next;
+ }
+ return;
+}
+
+void
+XkbSendCompatMapNotify(DeviceIntPtr kbd,xkbCompatMapNotify *pEv)
+{
+int initialized;
+XkbInterestPtr interest;
+Time time = 0;
+CARD16 firstSI = 0, nSI = 0, nTotalSI = 0;
+
+ interest = kbd->xkb_interest;
+ if (!interest)
+ return;
+
+ initialized = 0;
+ while (interest) {
+ if ((!interest->client->clientGone) &&
+ (interest->client->requestVector != InitialVector) &&
+ (interest->client->xkbClientFlags&_XkbClientInitialized) &&
+ (interest->compatNotifyMask)) {
+ if (!initialized) {
+ pEv->type = XkbEventCode + XkbEventBase;
+ pEv->xkbType = XkbCompatMapNotify;
+ pEv->deviceID = kbd->id;
+ pEv->time = time = GetTimeInMillis();
+ firstSI= pEv->firstSI;
+ nSI= pEv->nSI;
+ nTotalSI= pEv->nTotalSI;
+ initialized= 1;
+ }
+ pEv->sequenceNumber = interest->client->sequence;
+ pEv->time = time;
+ pEv->firstSI = firstSI;
+ pEv->nSI = nSI;
+ pEv->nTotalSI = nTotalSI;
+ if ( interest->client->swapped ) {
+ register int n;
+ swaps(&pEv->sequenceNumber,n);
+ swapl(&pEv->time,n);
+ swaps(&pEv->firstSI,n);
+ swaps(&pEv->nSI,n);
+ swaps(&pEv->nTotalSI,n);
+ }
+ WriteToClient(interest->client, sizeof(xEvent), (char *)pEv);
+ }
+ interest= interest->next;
+ }
+ return;
+}
+
+void
+XkbSendActionMessage(DeviceIntPtr kbd,xkbActionMessage *pEv)
+{
+int initialized;
+XkbSrvInfoPtr xkbi;
+XkbInterestPtr interest;
+Time time = 0;
+
+ xkbi = kbd->key->xkbInfo;
+ interest = kbd->xkb_interest;
+ if (!interest)
+ return;
+
+ initialized = 0;
+ pEv->mods= xkbi->state.mods;
+ pEv->group= xkbi->state.group;
+ while (interest) {
+ if ((!interest->client->clientGone) &&
+ (interest->client->requestVector != InitialVector) &&
+ (interest->client->xkbClientFlags&_XkbClientInitialized) &&
+ (interest->actionMessageMask)) {
+ if (!initialized) {
+ pEv->type = XkbEventCode + XkbEventBase;
+ pEv->xkbType = XkbActionMessage;
+ pEv->deviceID = kbd->id;
+ pEv->sequenceNumber = interest->client->sequence;
+ pEv->time = time = GetTimeInMillis();
+ initialized= 1;
+ }
+ pEv->sequenceNumber = interest->client->sequence;
+ pEv->time = time;
+ if ( interest->client->swapped ) {
+ register int n;
+ swaps(&pEv->sequenceNumber,n);
+ swapl(&pEv->time,n);
+ }
+ WriteToClient(interest->client, sizeof(xEvent), (char *)pEv);
+ }
+ interest= interest->next;
+ }
+ return;
+}
+
+void
+XkbSendExtensionDeviceNotify( DeviceIntPtr dev,
+ ClientPtr client,
+ xkbExtensionDeviceNotify * pEv)
+{
+int initialized;
+XkbInterestPtr interest;
+Time time = 0;
+CARD32 defined, state;
+CARD16 reason, supported = 0;
+
+ interest = dev->xkb_interest;
+ if (!interest)
+ return;
+
+ initialized = 0;
+ reason= pEv->reason;
+ defined= pEv->ledsDefined;
+ state= pEv->ledState;
+ while (interest) {
+ if ((!interest->client->clientGone) &&
+ (interest->client->requestVector != InitialVector) &&
+ (interest->client->xkbClientFlags&_XkbClientInitialized) &&
+ (interest->extDevNotifyMask&reason)) {
+ if (!initialized) {
+ pEv->type = XkbEventCode + XkbEventBase;
+ pEv->xkbType = XkbExtensionDeviceNotify;
+ pEv->deviceID = dev->id;
+ pEv->sequenceNumber = interest->client->sequence;
+ pEv->time = time = GetTimeInMillis();
+ supported= pEv->supported;
+ initialized= 1;
+ }
+ else {
+ pEv->sequenceNumber = interest->client->sequence;
+ pEv->time = time;
+ pEv->ledsDefined= defined;
+ pEv->ledState= state;
+ pEv->reason= reason;
+ pEv->supported= supported;
+ }
+ if (client!=interest->client) {
+ /* only report UnsupportedFeature to the client that */
+ /* issued the failing request */
+ pEv->reason&= ~XkbXI_UnsupportedFeatureMask;
+ if ((interest->extDevNotifyMask&reason)==0)
+ continue;
+ }
+ if ( interest->client->swapped ) {
+ register int n;
+ swaps(&pEv->sequenceNumber,n);
+ swapl(&pEv->time,n);
+ swapl(&pEv->ledsDefined,n);
+ swapl(&pEv->ledState,n);
+ swaps(&pEv->reason,n);
+ swaps(&pEv->supported,n);
+ }
+ WriteToClient(interest->client, sizeof(xEvent), (char *)pEv);
+ }
+ interest= interest->next;
+ }
+ return;
+}
+
+void
+XkbSendNotification( DeviceIntPtr kbd,
+ XkbChangesPtr pChanges,
+ XkbEventCausePtr cause)
+{
+XkbSrvLedInfoPtr sli;
+
+ sli= NULL;
+ if (pChanges->state_changes) {
+ xkbStateNotify sn;
+ sn.changed= pChanges->state_changes;
+ sn.keycode= cause->kc;
+ sn.eventType= cause->event;
+ sn.requestMajor= cause->mjr;
+ sn.requestMinor= cause->mnr;
+ XkbSendStateNotify(kbd,&sn);
+ }
+ if (pChanges->map.changed) {
+ xkbMapNotify mn;
+ mn.changed= pChanges->map.changed;
+ mn.firstType= pChanges->map.first_type;
+ mn.nTypes= pChanges->map.num_types;
+ mn.firstKeySym= pChanges->map.first_key_sym;
+ mn.nKeySyms= pChanges->map.num_key_syms;
+ mn.firstKeyAct= pChanges->map.first_key_act;
+ mn.nKeyActs= pChanges->map.num_key_acts;
+ mn.firstKeyBehavior= pChanges->map.first_key_behavior;
+ mn.nKeyBehaviors= pChanges->map.num_key_behaviors;
+ mn.virtualMods= pChanges->map.vmods;
+ mn.firstKeyExplicit= pChanges->map.first_key_explicit;
+ mn.nKeyExplicit= pChanges->map.num_key_explicit;
+ mn.firstModMapKey= pChanges->map.first_modmap_key;
+ mn.nModMapKeys= pChanges->map.num_modmap_keys;
+ mn.firstVModMapKey= pChanges->map.first_vmodmap_key;
+ mn.nVModMapKeys= pChanges->map.num_vmodmap_keys;
+ XkbSendMapNotify(kbd,&mn);
+ }
+ if ((pChanges->ctrls.changed_ctrls)||
+ (pChanges->ctrls.enabled_ctrls_changes)) {
+ xkbControlsNotify cn;
+ cn.changedControls= pChanges->ctrls.changed_ctrls;
+ cn.enabledControlChanges= pChanges->ctrls.enabled_ctrls_changes;
+ cn.keycode= cause->kc;
+ cn.eventType= cause->event;
+ cn.requestMajor= cause->mjr;
+ cn.requestMinor= cause->mnr;
+ XkbSendControlsNotify(kbd,&cn);
+ }
+ if (pChanges->indicators.map_changes) {
+ xkbIndicatorNotify in;
+ if (sli==NULL)
+ sli= XkbFindSrvLedInfo(kbd,XkbDfltXIClass,XkbDfltXIId,0);
+ in.state= sli->effectiveState;
+ in.changed= pChanges->indicators.map_changes;
+ XkbSendIndicatorNotify(kbd,XkbIndicatorMapNotify,&in);
+ }
+ if (pChanges->indicators.state_changes) {
+ xkbIndicatorNotify in;
+ if (sli==NULL)
+ sli= XkbFindSrvLedInfo(kbd,XkbDfltXIClass,XkbDfltXIId,0);
+ in.state= sli->effectiveState;
+ in.changed= pChanges->indicators.state_changes;
+ XkbSendIndicatorNotify(kbd,XkbIndicatorStateNotify,&in);
+ }
+ if (pChanges->names.changed) {
+ xkbNamesNotify nn;
+ nn.changed= pChanges->names.changed;
+ nn.firstType= pChanges->names.first_type;
+ nn.nTypes= pChanges->names.num_types;
+ nn.firstLevelName= pChanges->names.first_lvl;
+ nn.nLevelNames= pChanges->names.num_lvls;
+ nn.nRadioGroups= pChanges->names.num_rg;
+ nn.changedVirtualMods= pChanges->names.changed_vmods;
+ nn.changedIndicators= pChanges->names.changed_indicators;
+ XkbSendNamesNotify(kbd,&nn);
+ }
+ if ((pChanges->compat.changed_groups)||(pChanges->compat.num_si>0)) {
+ xkbCompatMapNotify cmn;
+ cmn.changedGroups= pChanges->compat.changed_groups;
+ cmn.firstSI= pChanges->compat.first_si;
+ cmn.nSI= pChanges->compat.num_si;
+ cmn.nTotalSI= kbd->key->xkbInfo->desc->compat->num_si;
+ XkbSendCompatMapNotify(kbd,&cmn);
+ }
+ return;
+}
+
+/***====================================================================***/
+
+Bool
+XkbFilterEvents(ClientPtr pClient,int nEvents,xEvent *xE)
+{
+int i, button_mask;
+DeviceIntPtr pXDev = (DeviceIntPtr)LookupKeyboardDevice();
+XkbSrvInfoPtr xkbi;
+
+ xkbi= pXDev->key->xkbInfo;
+ if ( pClient->xkbClientFlags & _XkbClientInitialized ) {
+#ifdef DEBUG
+ if ((xkbDebugFlags&0x10)&&
+ ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) {
+ ErrorF("XKbFilterWriteEvents:\n");
+ ErrorF(" Event state= 0x%04x\n",xE[0].u.keyButtonPointer.state);
+ ErrorF(" XkbLastRepeatEvent!=xE (0x%x!=0x%x) %s\n",
+ XkbLastRepeatEvent,xE,
+ ((XkbLastRepeatEvent!=(pointer)xE)?"True":"False"));
+ ErrorF(" (xkbClientEventsFlags&XWDA)==0 (0x%x) %s\n",
+ pClient->xkbClientFlags,
+ (_XkbWantsDetectableAutoRepeat(pClient)?"True":"False"));
+ ErrorF(" !IsRelease(%d) %s\n",xE[0].u.u.type,
+ (!_XkbIsReleaseEvent(xE[0].u.u.type))?"True":"False");
+ }
+#endif /* DEBUG */
+ if ( (XkbLastRepeatEvent==(pointer)xE) &&
+ (_XkbWantsDetectableAutoRepeat(pClient)) &&
+ (_XkbIsReleaseEvent(xE[0].u.u.type)) ) {
+ return False;
+ }
+ if ((pXDev->grab != NullGrab) && pXDev->fromPassiveGrab &&
+ ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) {
+ register unsigned state,flags;
+
+ flags= pClient->xkbClientFlags;
+ state= xkbi->state.compat_grab_mods;
+ if (flags & XkbPCF_GrabsUseXKBStateMask) {
+ int group;
+ if (flags&XkbPCF_LookupStateWhenGrabbed) {
+ group= xkbi->state.group;
+ state= xkbi->state.lookup_mods;
+ }
+ else {
+ state= xkbi->state.grab_mods;
+ group= xkbi->state.base_group+xkbi->state.latched_group;
+ if ((group<0)||(group>=xkbi->desc->ctrls->num_groups)) {
+ group= XkbAdjustGroup(group,xkbi->desc->ctrls);
+ }
+ }
+ state = XkbBuildCoreState(state, group);
+ }
+ else if (flags&XkbPCF_LookupStateWhenGrabbed)
+ state= xkbi->state.compat_lookup_mods;
+ xE[0].u.keyButtonPointer.state= state;
+ }
+ button_mask = 1 << xE[0].u.u.detail;
+ if (xE[0].u.u.type == ButtonPress &&
+ ((xE[0].u.keyButtonPointer.state >> 7) & button_mask) == button_mask &&
+ (xkbi->lockedPtrButtons & button_mask) == button_mask) {
+#ifdef DEBUG
+ /* If the MouseKeys is pressed, and the "real" mouse is also pressed
+ * when the mouse is released, the server does not behave properly.
+ * Faking a release of the button here solves the problem.
+ */
+ ErrorF("Faking release of button %d\n", xE[0].u.u.detail);
+#endif
+ XkbDDXFakePointerButton(ButtonRelease, xE[0].u.u.detail);
+ }
+ }
+ else {
+ register CARD8 type;
+
+ for (i=0;i<nEvents;i++) {
+ type= xE[i].u.u.type;
+#ifdef DEBUG
+ if ((xkbDebugFlags&0x4)&&
+ ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) {
+ XkbStatePtr s= &xkbi->state;
+ ErrorF("XKbFilterWriteEvents (non-XKB):\n");
+ ErrorF("event= 0x%04x\n",xE[0].u.keyButtonPointer.state);
+ ErrorF("lookup= 0x%02x, grab= 0x%02x\n",s->lookup_mods,
+ s->grab_mods);
+ ErrorF("compat lookup= 0x%02x, grab= 0x%02x\n",
+ s->compat_lookup_mods,
+ s->compat_grab_mods);
+ }
+#endif
+ if ( (type>=KeyPress)&&(type<=MotionNotify) ) {
+ CARD16 old,new;
+
+ old= xE[i].u.keyButtonPointer.state&(~0x1f00);
+ new= xE[i].u.keyButtonPointer.state&0x1F00;
+
+ if (old==XkbStateFieldFromRec(&xkbi->state))
+ new|= xkbi->state.compat_lookup_mods;
+ else new|= xkbi->state.compat_grab_mods;
+ xE[i].u.keyButtonPointer.state= new;
+ }
+ else if ((type==EnterNotify)||(type==LeaveNotify)) {
+ xE->u.enterLeave.state&= 0x1F00;
+ xE->u.enterLeave.state|= xkbi->state.compat_grab_mods;
+ }
+ button_mask = 1 << xE[i].u.u.detail;
+ if (type == ButtonPress &&
+ ((xE[i].u.keyButtonPointer.state >> 7) & button_mask) == button_mask &&
+ (xkbi->lockedPtrButtons & button_mask) == button_mask) {
+#ifdef DEBUG
+ ErrorF("Faking release of button %d\n", xE[i].u.u.detail);
+#endif
+ XkbDDXFakePointerButton(ButtonRelease, xE[i].u.u.detail);
+ }
+ }
+ }
+ return True;
+}
+
+/***====================================================================***/
+
+XkbInterestPtr
+XkbFindClientResource(DevicePtr inDev,ClientPtr client)
+{
+DeviceIntPtr dev = (DeviceIntPtr)inDev;
+XkbInterestPtr interest;
+
+ if ( dev->xkb_interest ) {
+ interest = dev->xkb_interest;
+ while (interest){
+ if (interest->client==client) {
+ return interest;
+ }
+ interest = interest->next;
+ }
+ }
+ return NULL;
+}
+
+XkbInterestPtr
+XkbAddClientResource(DevicePtr inDev,ClientPtr client,XID id)
+{
+DeviceIntPtr dev = (DeviceIntPtr)inDev;
+XkbInterestPtr interest;
+
+ interest = dev->xkb_interest;
+ while (interest) {
+ if (interest->client==client)
+ return ((interest->resource==id)?interest:NULL);
+ interest = interest->next;
+ }
+ interest = _XkbTypedAlloc(XkbInterestRec);
+ bzero(interest,sizeof(XkbInterestRec));
+ if (interest) {
+ interest->dev = dev;
+ interest->client = client;
+ interest->resource = id;
+ interest->stateNotifyMask= 0;
+ interest->ctrlsNotifyMask= 0;
+ interest->namesNotifyMask= 0;
+ interest->compatNotifyMask= 0;
+ interest->bellNotifyMask= FALSE;
+ interest->accessXNotifyMask= 0;
+ interest->iStateNotifyMask= 0;
+ interest->iMapNotifyMask= 0;
+ interest->altSymsNotifyMask= 0;
+ interest->next = dev->xkb_interest;
+ dev->xkb_interest= interest;
+ return interest;
+ }
+ return NULL;
+}
+
+int
+XkbRemoveClient(DevicePtr inDev,ClientPtr client)
+{
+XkbSrvInfoPtr xkbi;
+DeviceIntPtr dev = (DeviceIntPtr)inDev;
+XkbInterestPtr interest;
+unsigned long autoCtrls,autoValues;
+Bool found;
+
+ found= False;
+ autoCtrls= autoValues= 0;
+ if ( dev->xkb_interest ) {
+ interest = dev->xkb_interest;
+ if (interest && (interest->client==client)){
+ dev->xkb_interest = interest->next;
+ autoCtrls= interest->autoCtrls;
+ autoValues= interest->autoCtrlValues;
+ _XkbFree(interest);
+ found= True;
+ }
+ while ((!found)&&(interest->next)) {
+ if (interest->next->client==client) {
+ XkbInterestPtr victim = interest->next;
+ interest->next = victim->next;
+ autoCtrls= victim->autoCtrls;
+ autoValues= victim->autoCtrlValues;
+ _XkbFree(victim);
+ found= True;
+ }
+ interest = interest->next;
+ }
+ }
+ if (found && autoCtrls && dev->key && dev->key->xkbInfo ) {
+ XkbEventCauseRec cause;
+
+ xkbi= dev->key->xkbInfo;
+ XkbSetCauseXkbReq(&cause,X_kbPerClientFlags,client);
+ XkbEnableDisableControls(xkbi,autoCtrls,autoValues,NULL,&cause);
+ }
+ return found;
+}
+
+int
+XkbRemoveResourceClient(DevicePtr inDev,XID id)
+{
+XkbSrvInfoPtr xkbi;
+DeviceIntPtr dev = (DeviceIntPtr)inDev;
+XkbInterestPtr interest;
+Bool found;
+unsigned long autoCtrls,autoValues;
+ClientPtr client = NULL;
+
+ found= False;
+ autoCtrls= autoValues= 0;
+ if ( dev->xkb_interest ) {
+ interest = dev->xkb_interest;
+ if (interest && (interest->resource==id)){
+ dev->xkb_interest = interest->next;
+ autoCtrls= interest->autoCtrls;
+ autoValues= interest->autoCtrlValues;
+ client= interest->client;
+ _XkbFree(interest);
+ found= True;
+ }
+ while ((!found)&&(interest->next)) {
+ if (interest->next->resource==id) {
+ XkbInterestPtr victim = interest->next;
+ interest->next = victim->next;
+ autoCtrls= victim->autoCtrls;
+ autoValues= victim->autoCtrlValues;
+ client= victim->client;
+ _XkbFree(victim);
+ found= True;
+ }
+ interest = interest->next;
+ }
+ }
+ if (found && autoCtrls && dev->key && dev->key->xkbInfo ) {
+ XkbEventCauseRec cause;
+
+ xkbi= dev->key->xkbInfo;
+ XkbSetCauseXkbReq(&cause,X_kbPerClientFlags,client);
+ XkbEnableDisableControls(xkbi,autoCtrls,autoValues,NULL,&cause);
+ }
+ return found;
+}
diff --git a/nx-X11/programs/Xserver/xkb/xkbInit.c b/nx-X11/programs/Xserver/xkb/xkbInit.c
new file mode 100644
index 000000000..a338de8ad
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/xkbInit.c
@@ -0,0 +1,1037 @@
+/* $Xorg: xkbInit.c,v 1.3 2000/08/17 19:53:47 cpqbld Exp $ */
+/* $XdotOrg: xc/programs/Xserver/xkb/xkbInit.c,v 1.9 2005/10/19 22:45:54 ajax Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/xkbInit.c,v 3.32tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef HAVE_XKB_CONFIG_H
+#include <xkb-config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <math.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include <X11/Xatom.h>
+#include "misc.h"
+#include "inputstr.h"
+#include "opaque.h"
+#include "property.h"
+#define XKBSRV_NEED_FILE_FUNCS
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XKBgeom.h>
+#include <X11/extensions/XKMformat.h>
+#include <X11/extensions/XKBfile.h>
+#include "xkb.h"
+
+#define CREATE_ATOM(s) MakeAtom(s,sizeof(s)-1,1)
+
+#ifdef sgi
+#define LED_CAPS 5
+#define LED_NUM 6
+#define LED_SCROLL 7
+#define PHYS_LEDS 0x7f
+#define LED_COMPOSE 8
+#else
+#if defined(ultrix) || defined(__osf__) || defined(__alpha) || defined(__alpha__)
+#define LED_COMPOSE 2
+#define LED_CAPS 3
+#define LED_SCROLL 4
+#define LED_NUM 5
+#define PHYS_LEDS 0x1f
+#else
+#ifdef sun
+#define LED_NUM 1
+#define LED_SCROLL 2
+#define LED_COMPOSE 3
+#define LED_CAPS 4
+#define PHYS_LEDS 0x0f
+#else
+#define LED_CAPS 1
+#define LED_NUM 2
+#define LED_SCROLL 3
+#define PHYS_LEDS 0x07
+#endif
+#endif
+#endif
+
+#define MAX_TOC 16
+typedef struct _SrvXkmInfo {
+ DeviceIntPtr dev;
+ FILE * file;
+ XkbFileInfo xkbinfo;
+} SrvXkmInfo;
+
+
+/***====================================================================***/
+
+#ifndef XKB_BASE_DIRECTORY
+#define XKB_BASE_DIRECTORY "/usr/lib/X11/xkb"
+#endif
+#ifndef XKB_BIN_DIRECTORY
+#define XKB_BIN_DIRECTORY XKB_BASE_DIRECTORY
+#endif
+#ifndef XKB_DFLT_RULES_FILE
+#define XKB_DFLT_RULES_FILE "rules"
+#endif
+#ifndef XKB_DFLT_KB_LAYOUT
+#define XKB_DFLT_KB_LAYOUT "us"
+#endif
+#ifndef XKB_DFLT_KB_MODEL
+#define XKB_DFLT_KB_MODEL "dflt"
+#endif
+#ifndef XKB_DFLT_KB_VARIANT
+#define XKB_DFLT_KB_VARIANT NULL
+#endif
+#ifndef XKB_DFLT_KB_OPTIONS
+#define XKB_DFLT_KB_OPTIONS NULL
+#endif
+#ifndef XKB_DFLT_DISABLED
+#define XKB_DFLT_DISABLED True
+#endif
+#ifndef XKB_DFLT_RULES_PROP
+#define XKB_DFLT_RULES_PROP True
+#endif
+
+char * XkbBaseDirectory= XKB_BASE_DIRECTORY;
+char * XkbBinDirectory= XKB_BIN_DIRECTORY;
+char * XkbInitialMap= NULL;
+int XkbWantAccessX= 0;
+static XkbFileInfo * _XkbInitFileInfo= NULL;
+char * XkbDB= NULL;
+int XkbAutoLoad= 1;
+
+static Bool rulesDefined= False;
+static char * XkbRulesFile= NULL;
+static char * XkbModelDflt= NULL;
+static char * XkbLayoutDflt= NULL;
+static char * XkbVariantDflt= NULL;
+static char * XkbOptionsDflt= NULL;
+
+char * XkbModelUsed= NULL;
+char * XkbLayoutUsed= NULL;
+char * XkbVariantUsed= NULL;
+char * XkbOptionsUsed= NULL;
+
+int _XkbClientMajor= XkbMajorVersion;
+int _XkbClientMinor= XkbMinorVersion;
+
+Bool noXkbExtension= XKB_DFLT_DISABLED;
+Bool XkbWantRulesProp= XKB_DFLT_RULES_PROP;
+
+/***====================================================================***/
+
+char *
+XkbGetRulesDflts(XkbRF_VarDefsPtr defs)
+{
+ if (XkbModelDflt) defs->model= XkbModelDflt;
+ else defs->model= XKB_DFLT_KB_MODEL;
+ if (XkbLayoutDflt) defs->layout= XkbLayoutDflt;
+ else defs->layout= XKB_DFLT_KB_LAYOUT;
+ if (XkbVariantDflt) defs->variant= XkbVariantDflt;
+ else defs->variant= XKB_DFLT_KB_VARIANT;
+ if (XkbOptionsDflt) defs->options= XkbOptionsDflt;
+ else defs->options= XKB_DFLT_KB_OPTIONS;
+ return (rulesDefined?XkbRulesFile:XKB_DFLT_RULES_FILE);
+}
+
+Bool
+XkbWriteRulesProp(ClientPtr client, pointer closure)
+{
+int len,out;
+Atom name;
+char * pval;
+
+ if (rulesDefined && (!XkbRulesFile))
+ return False;
+ len= (XkbRulesFile?strlen(XkbRulesFile):strlen(XKB_DFLT_RULES_FILE));
+ len+= (XkbModelUsed?strlen(XkbModelUsed):0);
+ len+= (XkbLayoutUsed?strlen(XkbLayoutUsed):0);
+ len+= (XkbVariantUsed?strlen(XkbVariantUsed):0);
+ len+= (XkbOptionsUsed?strlen(XkbOptionsUsed):0);
+ if (len<1)
+ return True;
+
+ len+= 5; /* trailing NULs */
+
+ name= MakeAtom(_XKB_RF_NAMES_PROP_ATOM,strlen(_XKB_RF_NAMES_PROP_ATOM),1);
+ if (name==None) {
+ ErrorF("Atom error: %s not created\n",_XKB_RF_NAMES_PROP_ATOM);
+ return True;
+ }
+ pval= (char*) ALLOCATE_LOCAL(len);
+ if (!pval) {
+ ErrorF("Allocation error: %s proprerty not created\n",
+ _XKB_RF_NAMES_PROP_ATOM);
+ return True;
+ }
+ out= 0;
+ if (XkbRulesFile) {
+ strcpy(&pval[out],XkbRulesFile);
+ out+= strlen(XkbRulesFile);
+ } else {
+ strcpy(&pval[out],XKB_DFLT_RULES_FILE);
+ out+= strlen(XKB_DFLT_RULES_FILE);
+ }
+ pval[out++]= '\0';
+ if (XkbModelUsed) {
+ strcpy(&pval[out],XkbModelUsed);
+ out+= strlen(XkbModelUsed);
+ }
+ pval[out++]= '\0';
+ if (XkbLayoutUsed) {
+ strcpy(&pval[out],XkbLayoutUsed);
+ out+= strlen(XkbLayoutUsed);
+ }
+ pval[out++]= '\0';
+ if (XkbVariantUsed) {
+ strcpy(&pval[out],XkbVariantUsed);
+ out+= strlen(XkbVariantUsed);
+ }
+ pval[out++]= '\0';
+ if (XkbOptionsUsed) {
+ strcpy(&pval[out],XkbOptionsUsed);
+ out+= strlen(XkbOptionsUsed);
+ }
+ pval[out++]= '\0';
+ if (out!=len) {
+ ErrorF("Internal Error! bad size (%d!=%d) for _XKB_RULES_NAMES\n",
+ out,len);
+ }
+ ChangeWindowProperty(WindowTable[0],name,XA_STRING,8,PropModeReplace,
+ len,pval,True);
+ DEALLOCATE_LOCAL(pval);
+ return True;
+}
+
+void
+XkbSetRulesUsed(XkbRF_VarDefsPtr defs)
+{
+ if (XkbModelUsed)
+ _XkbFree(XkbModelUsed);
+ XkbModelUsed= (defs->model?_XkbDupString(defs->model):NULL);
+ if (XkbLayoutUsed)
+ _XkbFree(XkbLayoutUsed);
+ XkbLayoutUsed= (defs->layout?_XkbDupString(defs->layout):NULL);
+ if (XkbVariantUsed)
+ _XkbFree(XkbVariantUsed);
+ XkbVariantUsed= (defs->variant?_XkbDupString(defs->variant):NULL);
+ if (XkbOptionsUsed)
+ _XkbFree(XkbOptionsUsed);
+ XkbOptionsUsed= (defs->options?_XkbDupString(defs->options):NULL);
+ if (XkbWantRulesProp)
+ QueueWorkProc(XkbWriteRulesProp,NULL,NULL);
+ return;
+}
+
+void
+XkbSetRulesDflts(char *rulesFile,char *model,char *layout,
+ char *variant,char *options)
+{
+ if (XkbRulesFile)
+ _XkbFree(XkbRulesFile);
+ XkbRulesFile= _XkbDupString(rulesFile);
+ rulesDefined= True;
+ if (model) {
+ if (XkbModelDflt)
+ _XkbFree(XkbModelDflt);
+ XkbModelDflt= _XkbDupString(model);
+ }
+ if (layout) {
+ if (XkbLayoutDflt)
+ _XkbFree(XkbLayoutDflt);
+ XkbLayoutDflt= _XkbDupString(layout);
+ }
+ if (variant) {
+ if (XkbVariantDflt)
+ _XkbFree(XkbVariantDflt);
+ XkbVariantDflt= _XkbDupString(variant);
+ }
+ if (options) {
+ if (XkbOptionsDflt)
+ _XkbFree(XkbOptionsDflt);
+ XkbOptionsDflt= _XkbDupString(options);
+ }
+ return;
+}
+
+/***====================================================================***/
+
+#if defined(luna)
+#define XKB_DDX_PERMANENT_LOCK 1
+#endif
+
+#include "xkbDflts.h"
+
+/* A dummy to keep the compiler quiet */
+pointer xkbBogus = &indicators;
+
+static Bool
+XkbInitKeyTypes(XkbDescPtr xkb,SrvXkmInfo *file)
+{
+ if (file->xkbinfo.defined&XkmTypesMask)
+ return True;
+ initTypeNames(NULL);
+ if (XkbAllocClientMap(xkb,XkbKeyTypesMask,num_dflt_types)!=Success)
+ return False;
+ if (XkbCopyKeyTypes(dflt_types,xkb->map->types,num_dflt_types)!=
+ Success) {
+ return False;
+ }
+ xkb->map->size_types= xkb->map->num_types= num_dflt_types;
+ return True;
+}
+
+static void
+XkbInitRadioGroups(XkbSrvInfoPtr xkbi,SrvXkmInfo *file)
+{
+ xkbi->nRadioGroups = 0;
+ xkbi->radioGroups = NULL;
+ return;
+}
+
+
+static Status
+XkbInitCompatStructs(XkbDescPtr xkb,SrvXkmInfo *file)
+{
+register int i;
+XkbCompatMapPtr compat;
+
+ if (file->xkbinfo.defined&XkmCompatMapMask)
+ return Success;
+ if (XkbAllocCompatMap(xkb,XkbAllCompatMask,num_dfltSI)!=Success)
+ return BadAlloc;
+ compat = xkb->compat;
+ if (compat->sym_interpret) {
+ compat->num_si = num_dfltSI;
+ memcpy((char *)compat->sym_interpret,(char *)dfltSI,sizeof(dfltSI));
+ }
+ for (i=0;i<XkbNumKbdGroups;i++) {
+ compat->groups[i]= compatMap.groups[i];
+ if (compat->groups[i].vmods!=0) {
+ unsigned mask;
+ mask= XkbMaskForVMask(xkb,compat->groups[i].vmods);
+ compat->groups[i].mask= compat->groups[i].real_mods|mask;
+ }
+ else compat->groups[i].mask= compat->groups[i].real_mods;
+ }
+ return Success;
+}
+
+static void
+XkbInitSemantics(XkbDescPtr xkb,SrvXkmInfo *file)
+{
+ XkbInitKeyTypes(xkb,file);
+ XkbInitCompatStructs(xkb,file);
+ return;
+}
+
+/***====================================================================***/
+
+static Status
+XkbInitNames(XkbSrvInfoPtr xkbi,SrvXkmInfo *file)
+{
+XkbDescPtr xkb;
+XkbNamesPtr names;
+Status rtrn;
+Atom unknown;
+
+ xkb= xkbi->desc;
+ if ((rtrn=XkbAllocNames(xkb,XkbAllNamesMask,0,0))!=Success)
+ return rtrn;
+ unknown= CREATE_ATOM("unknown");
+ names = xkb->names;
+ if (names->keycodes==None) names->keycodes= unknown;
+ if (names->geometry==None) names->geometry= unknown;
+ if (names->phys_symbols==None) names->phys_symbols= unknown;
+ if (names->symbols==None) names->symbols= unknown;
+ if (names->types==None) names->types= unknown;
+ if (names->compat==None) names->compat= unknown;
+ if ((file->xkbinfo.defined&XkmVirtualModsMask)==0) {
+ if (names->vmods[vmod_NumLock]==None)
+ names->vmods[vmod_NumLock]= CREATE_ATOM("NumLock");
+ if (names->vmods[vmod_Alt]==None)
+ names->vmods[vmod_Alt]= CREATE_ATOM("Alt");
+ if (names->vmods[vmod_AltGr]==None)
+ names->vmods[vmod_AltGr]= CREATE_ATOM("ModeSwitch");
+ }
+
+ if (((file->xkbinfo.defined&XkmIndicatorsMask)==0)||
+ ((file->xkbinfo.defined&XkmGeometryMask)==0)) {
+ initIndicatorNames(NULL,xkb);
+ if (names->indicators[LED_CAPS-1]==None)
+ names->indicators[LED_CAPS-1] = CREATE_ATOM("Caps Lock");
+ if (names->indicators[LED_NUM-1]==None)
+ names->indicators[LED_NUM-1] = CREATE_ATOM("Num Lock");
+ if (names->indicators[LED_SCROLL-1]==None)
+ names->indicators[LED_SCROLL-1] = CREATE_ATOM("Scroll Lock");
+#ifdef LED_COMPOSE
+ if (names->indicators[LED_COMPOSE-1]==None)
+ names->indicators[LED_COMPOSE-1] = CREATE_ATOM("Compose");
+#endif
+ }
+#ifdef DEBUG_RADIO_GROUPS
+ if (names->num_rg<1) {
+ names->radio_groups= (Atom *)_XkbCalloc(RG_COUNT, sizeof(Atom));
+ if (names->radio_groups) {
+ names->num_rg = RG_COUNT;
+ names->radio_groups[RG_BOGUS_FUNCTION_GROUP]= CREATE_ATOM("BOGUS");
+ }
+ }
+#endif
+ if (xkb->geom!=NULL)
+ names->geometry= xkb->geom->name;
+ else names->geometry= unknown;
+ return Success;
+}
+
+static Status
+XkbInitIndicatorMap(XkbSrvInfoPtr xkbi,SrvXkmInfo *file)
+{
+XkbDescPtr xkb;
+XkbIndicatorPtr map;
+XkbSrvLedInfoPtr sli;
+
+ xkb= xkbi->desc;
+ if (XkbAllocIndicatorMaps(xkb)!=Success)
+ return BadAlloc;
+ if ((file->xkbinfo.defined&XkmIndicatorsMask)==0) {
+ map= xkb->indicators;
+ map->phys_indicators = PHYS_LEDS;
+ map->maps[LED_CAPS-1].flags= XkbIM_NoExplicit;
+ map->maps[LED_CAPS-1].which_mods= XkbIM_UseLocked;
+ map->maps[LED_CAPS-1].mods.mask= LockMask;
+ map->maps[LED_CAPS-1].mods.real_mods= LockMask;
+
+ map->maps[LED_NUM-1].flags= XkbIM_NoExplicit;
+ map->maps[LED_NUM-1].which_mods= XkbIM_UseLocked;
+ map->maps[LED_NUM-1].mods.mask= 0;
+ map->maps[LED_NUM-1].mods.real_mods= 0;
+ map->maps[LED_NUM-1].mods.vmods= vmod_NumLockMask;
+
+/* Metro Link */
+ map->maps[LED_SCROLL-1].flags= XkbIM_NoExplicit;
+ map->maps[LED_SCROLL-1].which_mods= XkbIM_UseLocked;
+ map->maps[LED_SCROLL-1].mods.mask= Mod3Mask;
+ map->maps[LED_SCROLL-1].mods.real_mods= Mod3Mask;
+/* Metro Link */
+ }
+ sli= XkbFindSrvLedInfo(xkbi->device,XkbDfltXIClass,XkbDfltXIId,0);
+ if (sli)
+ XkbCheckIndicatorMaps(xkbi->device,sli,XkbAllIndicatorsMask);
+ return Success;
+}
+
+static Status
+XkbInitControls(DeviceIntPtr pXDev,XkbSrvInfoPtr xkbi,SrvXkmInfo *file)
+{
+XkbDescPtr xkb;
+XkbControlsPtr ctrls;
+
+ xkb= xkbi->desc;
+ /* 12/31/94 (ef) -- XXX! Should check if controls loaded from file */
+ if (XkbAllocControls(xkb,XkbAllControlsMask)!=Success)
+ FatalError("Couldn't allocate keyboard controls\n");
+ ctrls= xkb->ctrls;
+ if ((file->xkbinfo.defined&XkmSymbolsMask)==0)
+ ctrls->num_groups = 1;
+ ctrls->groups_wrap = XkbSetGroupInfo(1,XkbWrapIntoRange,0);
+ ctrls->internal.mask = 0;
+ ctrls->internal.real_mods = 0;
+ ctrls->internal.vmods = 0;
+ ctrls->ignore_lock.mask = 0;
+ ctrls->ignore_lock.real_mods = 0;
+ ctrls->ignore_lock.vmods = 0;
+ ctrls->enabled_ctrls = XkbAccessXTimeoutMask|XkbRepeatKeysMask|
+ XkbMouseKeysAccelMask|XkbAudibleBellMask|
+ XkbIgnoreGroupLockMask;
+ if (XkbWantAccessX)
+ ctrls->enabled_ctrls|= XkbAccessXKeysMask;
+ AccessXInit(pXDev);
+ return Success;
+}
+
+void
+XkbInitDevice(DeviceIntPtr pXDev)
+{
+int i;
+XkbSrvInfoPtr xkbi;
+XkbChangesRec changes;
+SrvXkmInfo file;
+unsigned check;
+XkbEventCauseRec cause;
+
+ file.dev= pXDev;
+ file.file=NULL;
+ bzero(&file.xkbinfo,sizeof(XkbFileInfo));
+ bzero(&changes,sizeof(XkbChangesRec));
+ if (XkbAutoLoad && (XkbInitialMap!=NULL)) {
+ if ((file.file=XkbDDXOpenConfigFile(XkbInitialMap,NULL,0))!=NULL) {
+ XkmReadFile(file.file,0,XkmKeymapLegal,&file.xkbinfo);
+ if (file.xkbinfo.xkb==NULL) {
+ LogMessage(X_ERROR,
+ "Error loading keymap file %s (%s in %s)\n"
+ "\treverting to defaults\n",
+ XkbInitialMap, _XkbErrMessages[_XkbErrCode],
+ (_XkbErrLocation?_XkbErrLocation:"unknown"));
+ fclose(file.file);
+ file.file= NULL;
+ bzero(&file.xkbinfo,sizeof(XkbFileInfo));
+ }
+ else {
+ if (_XkbInitFileInfo!=NULL) {
+ XkbDescPtr tmp;
+ if ((tmp=_XkbInitFileInfo->xkb)!=NULL) {
+ XkbFreeKeyboard(tmp,XkbAllComponentsMask,True);
+ _XkbInitFileInfo->xkb= NULL;
+ }
+ }
+ _XkbInitFileInfo= &file.xkbinfo;
+ }
+ }
+ else {
+ LogMessage(X_ERROR, "Error opening keymap file %s, reverting to defaults\n",
+ XkbInitialMap);
+ }
+ }
+ pXDev->key->xkbInfo= xkbi= _XkbTypedCalloc(1,XkbSrvInfoRec);
+ if ( xkbi ) {
+ XkbDescPtr xkb;
+ if ((_XkbInitFileInfo!=NULL)&&(_XkbInitFileInfo->xkb!=NULL)) {
+ file.xkbinfo= *_XkbInitFileInfo;
+ xkbi->desc= _XkbInitFileInfo->xkb;
+ _XkbInitFileInfo= NULL;
+ }
+ else {
+ xkbi->desc= XkbAllocKeyboard();
+ if (!xkbi->desc)
+ FatalError("Couldn't allocate keyboard description\n");
+ xkbi->desc->min_key_code = pXDev->key->curKeySyms.minKeyCode;
+ xkbi->desc->max_key_code = pXDev->key->curKeySyms.maxKeyCode;
+ }
+ xkb= xkbi->desc;
+ if (xkb->min_key_code == 0)
+ xkb->min_key_code = pXDev->key->curKeySyms.minKeyCode;
+ if (xkb->max_key_code == 0)
+ xkb->max_key_code = pXDev->key->curKeySyms.maxKeyCode;
+ if ((pXDev->key->curKeySyms.minKeyCode!=xkbi->desc->min_key_code)||
+ (pXDev->key->curKeySyms.maxKeyCode!=xkbi->desc->max_key_code)) {
+ /* 12/9/95 (ef) -- XXX! Maybe we should try to fix up one or */
+ /* the other here, but for now just complain */
+ /* can't just update the core range without */
+ /* reallocating the KeySymsRec (pain) */
+ ErrorF("Internal Error!! XKB and core keymap have different range\n");
+ }
+ if (XkbAllocClientMap(xkb,XkbAllClientInfoMask,0)!=Success)
+ FatalError("Couldn't allocate client map in XkbInitDevice\n");
+ i= XkbNumKeys(xkb)/3+1;
+ if (XkbAllocServerMap(xkb,XkbAllServerInfoMask,i)!=Success)
+ FatalError("Couldn't allocate server map in XkbInitDevice\n");
+
+ xkbi->dfltPtrDelta=1;
+ xkbi->device = pXDev;
+
+ file.xkbinfo.xkb= xkb;
+ XkbInitSemantics(xkb,&file);
+ XkbInitNames(xkbi,&file);
+ XkbInitRadioGroups(xkbi,&file);
+
+ /* 12/31/94 (ef) -- XXX! Should check if state loaded from file */
+ bzero(&xkbi->state,sizeof(XkbStateRec));
+
+ XkbInitControls(pXDev,xkbi,&file);
+
+ if (file.xkbinfo.defined&XkmSymbolsMask)
+ memcpy(pXDev->key->modifierMap,xkb->map->modmap,xkb->max_key_code+1);
+ else
+ memcpy(xkb->map->modmap,pXDev->key->modifierMap,xkb->max_key_code+1);
+
+ XkbInitIndicatorMap(xkbi,&file);
+
+ XkbDDXInitDevice(pXDev);
+
+ if (!(file.xkbinfo.defined&XkmSymbolsMask)) {
+ XkbUpdateKeyTypesFromCore(pXDev,xkb->min_key_code,XkbNumKeys(xkb),
+ &changes);
+ }
+ else {
+ XkbUpdateCoreDescription(pXDev,True);
+ }
+ XkbSetCauseUnknown(&cause);
+ XkbUpdateActions(pXDev,xkb->min_key_code, XkbNumKeys(xkb),&changes,
+ &check,&cause);
+ /* For sanity. The first time the connection
+ * is opened, the client side min and max are set
+ * using QueryMinMaxKeyCodes() which grabs them
+ * from pXDev.
+ */
+ pXDev->key->curKeySyms.minKeyCode = xkb->min_key_code;
+ pXDev->key->curKeySyms.maxKeyCode = xkb->max_key_code;
+ }
+ if (file.file!=NULL)
+ fclose(file.file);
+ return;
+}
+
+#if MAP_LENGTH > XkbMaxKeyCount
+#undef XkbMaxKeyCount
+#define XkbMaxKeyCount MAP_LENGTH
+#endif
+
+Bool
+XkbInitKeyboardDeviceStruct(
+ DeviceIntPtr dev,
+ XkbComponentNamesPtr names,
+ KeySymsPtr pSymsIn,
+ CARD8 pModsIn[],
+ void (*bellProc)(
+ int /*percent*/,
+ DeviceIntPtr /*device*/,
+ pointer /*ctrl*/,
+ int),
+ void (*ctrlProc)(
+ DeviceIntPtr /*device*/,
+ KeybdCtrl * /*ctrl*/))
+{
+XkbFileInfo finfo;
+KeySymsRec tmpSyms,*pSyms;
+CARD8 tmpMods[XkbMaxLegalKeyCode+1],*pMods;
+char name[PATH_MAX],*rules;
+Bool ok=False;
+XPointer config;
+XkbComponentNamesRec cfgNames;
+XkbRF_VarDefsRec defs;
+
+ if ((dev->key!=NULL)||(dev->kbdfeed!=NULL))
+ return False;
+ pSyms= pSymsIn;
+ pMods= pModsIn;
+ bzero(&defs,sizeof(XkbRF_VarDefsRec));
+ bzero(&cfgNames,sizeof(XkbComponentNamesRec));
+ rules= XkbGetRulesDflts(&defs);
+ config= XkbDDXPreloadConfig(&rules,&defs,&cfgNames,dev);
+
+ /*
+ * The strings are duplicated because it is not guaranteed that
+ * they are allocated, or that they are allocated for every server
+ * generation. Eventually they will be freed at the end of this
+ * function.
+ */
+ if (names->keymap) names->keymap = _XkbDupString(names->keymap);
+ if (names->keycodes) names->keycodes = _XkbDupString(names->keycodes);
+ if (names->types) names->types = _XkbDupString(names->types);
+ if (names->compat) names->compat = _XkbDupString(names->compat);
+ if (names->geometry) names->geometry = _XkbDupString(names->geometry);
+ if (names->symbols) names->symbols = _XkbDupString(names->symbols);
+
+ if (defs.model && defs.layout && rules) {
+ XkbComponentNamesRec rNames;
+ bzero(&rNames,sizeof(XkbComponentNamesRec));
+ if (XkbDDXNamesFromRules(dev,rules,&defs,&rNames)) {
+ if (rNames.keymap) {
+ if (!names->keymap)
+ names->keymap = rNames.keymap;
+ else _XkbFree(rNames.keymap);
+ }
+ if (rNames.keycodes) {
+ if (!names->keycodes)
+ names->keycodes = rNames.keycodes;
+ else
+ _XkbFree(rNames.keycodes);
+ }
+ if (rNames.types) {
+ if (!names->types)
+ names->types = rNames.types;
+ else _XkbFree(rNames.types);
+ }
+ if (rNames.compat) {
+ if (!names->compat)
+ names->compat = rNames.compat;
+ else _XkbFree(rNames.compat);
+ }
+ if (rNames.symbols) {
+ if (!names->symbols)
+ names->symbols = rNames.symbols;
+ else _XkbFree(rNames.symbols);
+ }
+ if (rNames.geometry) {
+ if (!names->geometry)
+ names->geometry = rNames.geometry;
+ else _XkbFree(rNames.geometry);
+ }
+ XkbSetRulesUsed(&defs);
+ }
+ }
+ if (cfgNames.keymap){
+ if (names->keymap) _XkbFree(names->keymap);
+ names->keymap= cfgNames.keymap;
+ }
+ if (cfgNames.keycodes){
+ if (names->keycodes) _XkbFree(names->keycodes);
+ names->keycodes= cfgNames.keycodes;
+ }
+ if (cfgNames.types) {
+ if (names->types) _XkbFree(names->types);
+ names->types= cfgNames.types;
+ }
+ if (cfgNames.compat) {
+ if (names->compat) _XkbFree(names->compat);
+ names->compat= cfgNames.compat;
+ }
+ if (cfgNames.symbols){
+ if (names->symbols) _XkbFree(names->symbols);
+ names->symbols= cfgNames.symbols;
+ }
+ if (cfgNames.geometry) {
+ if (names->geometry) _XkbFree(names->geometry);
+ names->geometry= cfgNames.geometry;
+ }
+
+ if (names->keymap) {
+ XkbComponentNamesRec tmpNames;
+ bzero(&tmpNames,sizeof(XkbComponentNamesRec));
+ tmpNames.keymap = names->keymap;
+ ok = (Bool) XkbDDXLoadKeymapByNames(dev,&tmpNames,XkmAllIndicesMask,0,
+ &finfo,name,PATH_MAX);
+ }
+ if (!(ok && (finfo.xkb!=NULL)))
+ ok = (Bool) XkbDDXLoadKeymapByNames(dev,names,XkmAllIndicesMask,0,
+ &finfo,name,PATH_MAX);
+
+ if (ok && (finfo.xkb!=NULL)) {
+ XkbDescPtr xkb;
+ KeyCode minKC,maxKC;
+
+ xkb= finfo.xkb;
+ minKC= xkb->min_key_code;
+ maxKC= xkb->max_key_code;
+ if (XkbIsLegalKeycode(minKC)&&XkbIsLegalKeycode(maxKC)&&(minKC<=maxKC)&&
+ ((minKC!=pSyms->minKeyCode)||(maxKC!=pSyms->maxKeyCode))) {
+ if (xkb->map!=NULL) {
+ KeySym *inSym,*outSym;
+ int width= pSymsIn->mapWidth;
+
+ tmpSyms.minKeyCode= minKC;
+ tmpSyms.maxKeyCode= maxKC;
+
+ if (minKC<pSymsIn->minKeyCode)
+ minKC= pSymsIn->minKeyCode;
+ if (maxKC>pSymsIn->maxKeyCode)
+ maxKC= pSymsIn->maxKeyCode;
+
+ tmpSyms.mapWidth= width;
+ tmpSyms.map= _XkbTypedCalloc(width*XkbNumKeys(xkb),KeySym);
+ inSym= &pSymsIn->map[(minKC-pSymsIn->minKeyCode)*width];
+ outSym= &tmpSyms.map[(minKC-tmpSyms.minKeyCode)*width];
+ memcpy(outSym,inSym,((maxKC-minKC+1)*width)*sizeof(KeySym));
+ pSyms= &tmpSyms;
+ }
+ if ((xkb->map!=NULL)&&(xkb->map->modmap!=NULL)) {
+ bzero(tmpMods,XkbMaxKeyCount);
+ memcpy(tmpMods,xkb->map->modmap,maxKC+1);
+ pMods= tmpMods;
+ }
+ }
+ _XkbInitFileInfo= &finfo;
+ }
+ else {
+ LogMessage(X_WARNING, "Couldn't load XKB keymap, falling back to pre-XKB keymap\n");
+ }
+ ok= InitKeyboardDeviceStruct((DevicePtr)dev,pSyms,pMods,bellProc,ctrlProc);
+ if ((config!=NULL)&&(dev && dev->key && dev->key->xkbInfo))
+ XkbDDXApplyConfig(config,dev->key->xkbInfo);
+ _XkbInitFileInfo= NULL;
+ if ((pSyms==&tmpSyms)&&(pSyms->map!=NULL)) {
+ _XkbFree(pSyms->map);
+ pSyms->map= NULL;
+ }
+
+ if (names->keymap) _XkbFree(names->keymap);
+ names->keymap = NULL;
+ if (names->keycodes) _XkbFree(names->keycodes);
+ names->keycodes = NULL;
+ if (names->types) _XkbFree(names->types);
+ names->types = NULL;
+ if (names->compat) _XkbFree(names->compat);
+ names->compat = NULL;
+ if (names->geometry) _XkbFree(names->geometry);
+ names->geometry = NULL;
+ if (names->symbols) _XkbFree(names->symbols);
+ names->symbols = NULL;
+
+ return ok;
+}
+
+/***====================================================================***/
+
+ /*
+ * InitKeyClassDeviceStruct initializes the key class before it
+ * initializes the keyboard feedback class for a device.
+ * UpdateActions can't set up the correct autorepeat for keyboard
+ * initialization because the keyboard feedback isn't created yet.
+ * Instead, UpdateActions notes the "correct" autorepeat in the
+ * SrvInfo structure and InitKbdFeedbackClass calls UpdateAutoRepeat
+ * to apply the computed autorepeat once the feedback class exists.
+ *
+ * DIX will apply the changed autorepeat, so there's no need to
+ * do so here. This function returns True if both RepeatKeys and
+ * the core protocol autorepeat ctrls are set (i.e. should use
+ * software autorepeat), false otherwise.
+ *
+ * This function also computes the autorepeat accelerators for the
+ * default indicator feedback.
+ */
+int
+XkbFinishDeviceInit(DeviceIntPtr pXDev)
+{
+XkbSrvInfoPtr xkbi;
+XkbDescPtr xkb;
+int softRepeat;
+XkbSrvLedInfoPtr sli;
+
+ xkbi = NULL;
+ if (pXDev && pXDev->key && pXDev->key->xkbInfo && pXDev->kbdfeed) {
+ xkbi= pXDev->key->xkbInfo;
+ xkb= xkbi->desc;
+ if (pXDev->kbdfeed) {
+ xkbi->kbdProc= pXDev->kbdfeed->CtrlProc;
+ pXDev->kbdfeed->CtrlProc= XkbDDXKeybdCtrlProc;
+ }
+ if (pXDev->kbdfeed->ctrl.autoRepeat)
+ xkb->ctrls->enabled_ctrls|= XkbRepeatKeysMask;
+ softRepeat= (xkb->ctrls->enabled_ctrls&XkbRepeatKeysMask)!=0;
+ if (pXDev->kbdfeed) {
+ memcpy(pXDev->kbdfeed->ctrl.autoRepeats,
+ xkb->ctrls->per_key_repeat,XkbPerKeyBitArraySize);
+ softRepeat= softRepeat&&pXDev->kbdfeed->ctrl.autoRepeat;
+ }
+ }
+ else softRepeat= 0;
+ sli= XkbFindSrvLedInfo(pXDev,XkbDfltXIClass,XkbDfltXIId,0);
+ if (sli && xkbi)
+ XkbCheckIndicatorMaps(xkbi->device,sli,XkbAllIndicatorsMask);
+#ifdef DEBUG
+ else ErrorF("No indicator feedback in XkbFinishInit (shouldn't happen)!\n");
+#endif
+ return softRepeat;
+}
+
+ /*
+ * Be very careful about what does and doesn't get freed by this
+ * function. To reduce fragmentation, XkbInitDevice allocates a
+ * single huge block per device and divides it up into most of the
+ * fixed-size structures for the device. Don't free anything that
+ * is part of this larger block.
+ */
+void
+XkbFreeInfo(XkbSrvInfoPtr xkbi)
+{
+ if (xkbi->radioGroups) {
+ _XkbFree(xkbi->radioGroups);
+ xkbi->radioGroups= NULL;
+ }
+ if (xkbi->mouseKeyTimer) {
+ TimerFree(xkbi->mouseKeyTimer);
+ xkbi->mouseKeyTimer= NULL;
+ }
+ if (xkbi->slowKeysTimer) {
+ TimerFree(xkbi->slowKeysTimer);
+ xkbi->slowKeysTimer= NULL;
+ }
+ if (xkbi->bounceKeysTimer) {
+ TimerFree(xkbi->bounceKeysTimer);
+ xkbi->bounceKeysTimer= NULL;
+ }
+ if (xkbi->repeatKeyTimer) {
+ TimerFree(xkbi->repeatKeyTimer);
+ xkbi->repeatKeyTimer= NULL;
+ }
+ if (xkbi->krgTimer) {
+ TimerFree(xkbi->krgTimer);
+ xkbi->krgTimer= NULL;
+ }
+ xkbi->beepType= _BEEP_NONE;
+ if (xkbi->beepTimer) {
+ TimerFree(xkbi->beepTimer);
+ xkbi->beepTimer= NULL;
+ }
+ if (xkbi->desc) {
+ XkbFreeKeyboard(xkbi->desc,XkbAllComponentsMask,True);
+ xkbi->desc= NULL;
+ }
+ _XkbFree(xkbi);
+ return;
+}
+
+/***====================================================================***/
+
+extern int XkbDfltRepeatDelay;
+extern int XkbDfltRepeatInterval;
+
+extern unsigned short XkbDfltAccessXTimeout;
+extern unsigned int XkbDfltAccessXTimeoutMask;
+extern unsigned int XkbDfltAccessXFeedback;
+extern unsigned char XkbDfltAccessXOptions;
+
+int
+XkbProcessArguments(int argc,char *argv[],int i)
+{
+ if (strcmp(argv[i],"-kb")==0) {
+ noXkbExtension= True;
+ return 1;
+ }
+ else if (strcmp(argv[i],"+kb")==0) {
+ noXkbExtension= False;
+ return 1;
+ }
+ else if (strncmp(argv[i], "-xkbdir", 7) == 0) {
+ if(++i < argc) {
+#if !defined(WIN32) && !defined(__UNIXOS2__) && !defined(__CYGWIN__)
+ if (getuid() != geteuid()) {
+ LogMessage(X_WARNING, "-xkbdir is not available for setuid X servers\n");
+ return -1;
+ } else
+#endif
+ {
+ if (strlen(argv[i]) < PATH_MAX) {
+ XkbBaseDirectory= argv[i];
+ return 2;
+ } else {
+ LogMessage(X_ERROR, "-xkbdir pathname too long\n");
+ return -1;
+ }
+ }
+ }
+ else {
+ return -1;
+ }
+ }
+ else if (strncmp(argv[i], "-xkbmap", 7) == 0) {
+ if(++i < argc) {
+ if (strlen(argv[i]) < PATH_MAX) {
+ XkbInitialMap= argv[i];
+ return 2;
+ } else {
+ LogMessage(X_ERROR, "-xkbmap pathname too long\n");
+ return -1;
+ }
+ }
+ else {
+ return -1;
+ }
+ }
+ else if (strncmp(argv[i], "-xkbdb", 7) == 0) {
+ if(++i < argc) {
+ if (strlen(argv[i]) < PATH_MAX) {
+ XkbDB= argv[i];
+ return 2;
+ } else {
+ LogMessage(X_ERROR, "-xkbdb pathname too long\n");
+ return -1;
+ }
+ }
+ else {
+ return -1;
+ }
+ }
+ else if (strncmp(argv[i], "-noloadxkb", 7) == 0) {
+ XkbAutoLoad= 0;
+ return 1;
+ }
+ else if ((strncmp(argv[i],"-accessx",8)==0)||
+ (strncmp(argv[i],"+accessx",8)==0)) {
+ int j=1;
+ if (argv[i][0]=='-')
+ XkbWantAccessX= 0;
+ else {
+ XkbWantAccessX= 1;
+
+ if ( ((i+1)<argc) && (isdigit(argv[i+1][0])) ) {
+ XkbDfltAccessXTimeout = atoi(argv[++i]);
+ j++;
+
+ if ( ((i+1)<argc) && (isdigit(argv[i+1][0])) ) {
+ /*
+ * presumption that the reasonably useful range of
+ * values fits in 0..MAXINT since SunOS 4 doesn't
+ * have strtoul.
+ */
+ XkbDfltAccessXTimeoutMask=(unsigned int)
+ strtol(argv[++i],NULL,16);
+ j++;
+ }
+ if ( ((i+1)<argc) && (isdigit(argv[i+1][0])) ) {
+ if (argv[++i][0] == '1' )
+ XkbDfltAccessXFeedback=XkbAccessXFeedbackMask;
+ else
+ XkbDfltAccessXFeedback=0;
+ j++;
+ }
+ if ( ((i+1)<argc) && (isdigit(argv[i+1][0])) ) {
+ XkbDfltAccessXOptions=(unsigned char)
+ strtol(argv[++i],NULL,16);
+ j++;
+ }
+ }
+ }
+ return j;
+ }
+ if (strcmp (argv[i], "-ar1") == 0) { /* -ar1 int */
+ if (++i >= argc) UseMsg ();
+ XkbDfltRepeatDelay = (long)atoi(argv[i]);
+ return 2;
+ }
+ if (strcmp (argv[i], "-ar2") == 0) { /* -ar2 int */
+ if (++i >= argc) UseMsg ();
+ XkbDfltRepeatInterval = (long)atoi(argv[i]);
+ return 2;
+ }
+ return 0;
+}
+
+void
+XkbUseMsg(void)
+{
+ ErrorF("The X Keyboard Extension adds the following arguments:\n");
+ ErrorF("-kb disable the X Keyboard Extension\n");
+ ErrorF("+kb enable the X Keyboard Extension\n");
+ ErrorF("[+-]accessx [ timeout [ timeout_mask [ feedback [ options_mask] ] ] ]\n");
+ ErrorF(" enable/disable accessx key sequences\n");
+ ErrorF("-ar1 set XKB autorepeat delay\n");
+ ErrorF("-ar2 set XKB autorepeat interval\n");
+ ErrorF("-noloadxkb don't load XKB keymap description\n");
+ ErrorF("-xkbdb file that contains default XKB keymaps\n");
+ ErrorF("-xkbmap XKB keyboard description to load on startup\n");
+}
diff --git a/nx-X11/programs/Xserver/xkb/xkbLEDs.c b/nx-X11/programs/Xserver/xkb/xkbLEDs.c
new file mode 100644
index 000000000..e04c05f14
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/xkbLEDs.c
@@ -0,0 +1,1067 @@
+/* $Xorg: xkbLEDs.c,v 1.4 2001/05/10 19:54:01 steve Exp $ */
+/************************************************************
+Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/xkbLEDs.c,v 3.7 2003/07/16 01:39:10 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <math.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XKBsrv.h>
+#include "xkb.h"
+
+/***====================================================================***/
+
+ /*
+ * unsigned
+ * XkbIndicatorsToUpdate(dev,changed,check_devs_rtrn)
+ *
+ * Given a keyboard and a set of state components that have changed,
+ * this function returns the indicators on the default keyboard
+ * feedback that might be affected. It also reports whether or not
+ * any extension devices might be affected in check_devs_rtrn.
+ */
+
+unsigned
+XkbIndicatorsToUpdate( DeviceIntPtr dev,
+ unsigned long state_changes,
+ Bool enable_changes)
+{
+register unsigned update= 0;
+XkbSrvLedInfoPtr sli;
+
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+
+ if (state_changes&(XkbModifierStateMask|XkbGroupStateMask))
+ update|= sli->usesEffective;
+ if (state_changes&(XkbModifierBaseMask|XkbGroupBaseMask))
+ update|= sli->usesBase;
+ if (state_changes&(XkbModifierLatchMask|XkbGroupLatchMask))
+ update|= sli->usesLatched;
+ if (state_changes&(XkbModifierLockMask|XkbGroupLockMask))
+ update|= sli->usesLocked;
+ if (state_changes&XkbCompatStateMask)
+ update|= sli->usesCompat;
+ if (enable_changes)
+ update|= sli->usesControls;
+ return update;
+}
+
+/***====================================================================***/
+
+ /*
+ * Bool
+ * XkbApplyLEDChangeToKeyboard(xkbi,map,on,change)
+ *
+ * Some indicators "drive" the keyboard when their state is explicitly
+ * changed, as described in section 9.2.1 of the XKB protocol spec.
+ * This function updates the state and controls for the keyboard
+ * specified by 'xkbi' to reflect any changes that are required
+ * when the indicator described by 'map' is turned on or off. The
+ * extent of the changes is reported in change, which must be defined.
+ */
+Bool
+XkbApplyLEDChangeToKeyboard( XkbSrvInfoPtr xkbi,
+ XkbIndicatorMapPtr map,
+ Bool on,
+ XkbChangesPtr change)
+{
+Bool ctrlChange,stateChange;
+XkbStatePtr state;
+
+ if ((map->flags&XkbIM_NoExplicit)||((map->flags&XkbIM_LEDDrivesKB)==0))
+ return False;
+ ctrlChange= stateChange= False;
+ if (map->ctrls) {
+ XkbControlsPtr ctrls= xkbi->desc->ctrls;
+ unsigned old;
+
+ old= ctrls->enabled_ctrls;
+ if (on) ctrls->enabled_ctrls|= map->ctrls;
+ else ctrls->enabled_ctrls&= ~map->ctrls;
+ if (old!=ctrls->enabled_ctrls) {
+ change->ctrls.changed_ctrls= XkbControlsEnabledMask;
+ change->ctrls.enabled_ctrls_changes= old^ctrls->enabled_ctrls;
+ ctrlChange= True;
+ }
+ }
+ state= &xkbi->state;
+ if ((map->groups)&&((map->which_groups&(~XkbIM_UseBase))!=0)) {
+ register int i;
+ register unsigned bit,match;
+
+ if (on) match= (map->groups)&XkbAllGroupsMask;
+ else match= (~map->groups)&XkbAllGroupsMask;
+ if (map->which_groups&(XkbIM_UseLocked|XkbIM_UseEffective)) {
+ for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
+ if (bit&match)
+ break;
+ }
+ if (map->which_groups&XkbIM_UseLatched)
+ XkbLatchGroup(xkbi->device,0); /* unlatch group */
+ state->locked_group= i;
+ stateChange= True;
+ }
+ else if (map->which_groups&(XkbIM_UseLatched|XkbIM_UseEffective)) {
+ for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
+ if (bit&match)
+ break;
+ }
+ state->locked_group= 0;
+ XkbLatchGroup(xkbi->device,i);
+ stateChange= True;
+ }
+ }
+ if ((map->mods.mask)&&((map->which_mods&(~XkbIM_UseBase))!=0)) {
+ if (map->which_mods&(XkbIM_UseLocked|XkbIM_UseEffective)) {
+ register unsigned long old;
+ old= state->locked_mods;
+ if (on) state->locked_mods|= map->mods.mask;
+ else state->locked_mods&= ~map->mods.mask;
+ if (state->locked_mods!=old)
+ stateChange= True;
+ }
+ if (map->which_mods&(XkbIM_UseLatched|XkbIM_UseEffective)) {
+ register unsigned long newmods;
+ newmods= state->latched_mods;
+ if (on) newmods|= map->mods.mask;
+ else newmods&= ~map->mods.mask;
+ if (newmods!=state->locked_mods) {
+ newmods&= map->mods.mask;
+ XkbLatchModifiers(xkbi->device,map->mods.mask,newmods);
+ stateChange= True;
+ }
+ }
+ }
+ return (stateChange || ctrlChange);
+}
+
+/***====================================================================***/
+
+ /*
+ * void
+ * XkbSetIndicators(dev,affect,values,cause)
+ *
+ * Attempts to change the indicators specified in 'affect' to the
+ * states specified in 'values' for the default keyboard feedback
+ * on the keyboard specified by 'dev.' Attempts to change indicator
+ * state might be ignored or have no affect, depending on the XKB
+ * indicator map for any affected indicators, as described in section
+ * 9.2 of the XKB protocol specification.
+ *
+ * If 'changes' is non-NULL, this function notes any changes to the
+ * keyboard state, controls, or indicator state that result from this
+ * attempted change. If 'changes' is NULL, this function generates
+ * XKB events to report any such changes to interested clients.
+ *
+ * If 'cause' is non-NULL, it specifies the reason for the change,
+ * as reported in some XKB events. If it is NULL, this function
+ * assumes that the change is the result of a core protocol
+ * ChangeKeyboardMapping request.
+ */
+
+void
+XkbSetIndicators( DeviceIntPtr dev,
+ CARD32 affect,
+ CARD32 values,
+ XkbEventCausePtr cause)
+{
+XkbSrvLedInfoPtr sli;
+XkbChangesRec changes;
+xkbExtensionDeviceNotify ed;
+unsigned side_affected;
+
+ bzero((char *)&changes,sizeof(XkbChangesRec));
+ bzero((char *)&ed,sizeof(xkbExtensionDeviceNotify));
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ sli->explicitState&= ~affect;
+ sli->explicitState|= (affect&values);
+ XkbApplyLedStateChanges(dev,sli,affect,&ed,&changes,cause);
+
+ side_affected= 0;
+ if (changes.state_changes!=0)
+ side_affected|= XkbIndicatorsToUpdate(dev,changes.state_changes,False);
+ if (changes.ctrls.enabled_ctrls_changes)
+ side_affected|= sli->usesControls;
+
+ if (side_affected) {
+ XkbUpdateLedAutoState(dev,sli,side_affected,&ed,&changes,cause);
+ affect|= side_affected;
+ }
+ if (changes.state_changes || changes.ctrls.enabled_ctrls_changes)
+ XkbUpdateAllDeviceIndicators(NULL,cause);
+
+ XkbFlushLedEvents(dev,dev,sli,&ed,&changes,cause);
+ return;
+}
+
+/***====================================================================***/
+
+ /*
+ * Bool
+ * ComputeAutoState(map,state,ctrls)
+ *
+ * This function reports the effect of applying the specified
+ * indicator map given the specified state and controls, as
+ * described in section 9.2 of the XKB protocol specification.
+ */
+
+static Bool
+ComputeAutoState( XkbIndicatorMapPtr map,
+ XkbStatePtr state,
+ XkbControlsPtr ctrls)
+{
+Bool on;
+CARD8 mods,group;
+
+ on= False;
+ mods= group= 0;
+ if (map->which_mods&XkbIM_UseAnyMods) {
+ if (map->which_mods&XkbIM_UseBase)
+ mods|= state->base_mods;
+ if (map->which_mods&XkbIM_UseLatched)
+ mods|= state->latched_mods;
+ if (map->which_mods&XkbIM_UseLocked)
+ mods|= state->locked_mods;
+ if (map->which_mods&XkbIM_UseEffective)
+ mods|= state->mods;
+ if (map->which_mods&XkbIM_UseCompat)
+ mods|= state->compat_state;
+ on = ((map->mods.mask&mods)!=0);
+ on = on||((mods==0)&&(map->mods.mask==0)&&(map->mods.vmods==0));
+ }
+ if (map->which_groups&XkbIM_UseAnyGroup) {
+ if (map->which_groups&XkbIM_UseBase)
+ group|= (1L << state->base_group);
+ if (map->which_groups&XkbIM_UseLatched)
+ group|= (1L << state->latched_group);
+ if (map->which_groups&XkbIM_UseLocked)
+ group|= (1L << state->locked_group);
+ if (map->which_groups&XkbIM_UseEffective)
+ group|= (1L << state->group);
+ on = on||(((map->groups&group)!=0)||(map->groups==0));
+ }
+ if (map->ctrls)
+ on = on||(ctrls->enabled_ctrls&map->ctrls);
+ return on;
+}
+
+/***====================================================================***/
+
+ /*
+ * void
+ * XkbUpdateIndicators(dev,update,check_edevs,changes,cause)
+ *
+ * Applies the indicator maps for any indicators specified in
+ * 'update' from the default keyboard feedback on the device
+ * specified by 'dev.'
+ *
+ * If 'changes' is NULL, this function generates and XKB events
+ * required to report the necessary changes, otherwise it simply
+ * notes the indicators with changed state.
+ *
+ * If 'check_edevs' is True, this function also checks the indicator
+ * maps for any open extension devices that have them, and updates
+ * the state of any extension device indicators as necessary.
+ */
+
+void
+XkbUpdateIndicators( DeviceIntPtr dev,
+ register CARD32 update,
+ Bool check_edevs,
+ XkbChangesPtr changes,
+ XkbEventCausePtr cause)
+{
+XkbSrvLedInfoPtr sli;
+
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateLedAutoState(dev,sli,update,NULL,changes,cause);
+ if (check_edevs)
+ XkbUpdateAllDeviceIndicators(changes,cause);
+ return;
+}
+
+/***====================================================================***/
+
+void
+XkbUpdateAllDeviceIndicators(XkbChangesPtr changes,XkbEventCausePtr cause)
+{
+DeviceIntPtr edev;
+XkbSrvLedInfoPtr sli;
+
+ for (edev=inputInfo.devices;edev!=NULL;edev=edev->next) {
+ if (edev->kbdfeed) {
+ KbdFeedbackPtr kf;
+ for (kf=edev->kbdfeed;kf!=NULL;kf=kf->next) {
+ if ((kf->xkb_sli==NULL)||(kf->xkb_sli->maps==NULL))
+ continue;
+ sli= kf->xkb_sli;
+ XkbUpdateLedAutoState(edev,sli,sli->mapsPresent,NULL,
+ changes,cause);
+
+ }
+ }
+ if (edev->leds) {
+ LedFeedbackPtr lf;
+ for (lf=edev->leds;lf!=NULL;lf=lf->next) {
+ if ((lf->xkb_sli==NULL)||(lf->xkb_sli->maps==NULL))
+ continue;
+ sli= lf->xkb_sli;
+ XkbUpdateLedAutoState(edev,sli,sli->mapsPresent,NULL,
+ changes,cause);
+
+ }
+ }
+ }
+ return;
+}
+
+/***====================================================================***/
+
+ /*
+ * void
+ * XkbCheckIndicatorMaps(dev,sli,which)
+ *
+ * Updates the 'indicator accelerators' for the indicators specified
+ * by 'which' in the feedback specified by 'sli.' The indicator
+ * accelerators are internal to the server and are used to simplify
+ * and speed up the process of figuring out which indicators might
+ * be affected by a particular change in keyboard state or controls.
+ */
+
+void
+XkbCheckIndicatorMaps(DeviceIntPtr dev,XkbSrvLedInfoPtr sli,unsigned which)
+{
+register unsigned i,bit;
+XkbIndicatorMapPtr map;
+XkbDescPtr xkb;
+
+ if ((sli->flags&XkbSLI_HasOwnState)==0)
+ dev= (DeviceIntPtr)LookupKeyboardDevice();
+
+ sli->usesBase&= ~which;
+ sli->usesLatched&= ~which;
+ sli->usesLocked&= ~which;
+ sli->usesEffective&= ~which;
+ sli->usesCompat&= ~which;
+ sli->usesControls&= ~which;
+ sli->mapsPresent&= ~which;
+
+ xkb= dev->key->xkbInfo->desc;
+ for (i=0,bit=1,map=sli->maps;i<XkbNumIndicators;i++,bit<<=1,map++) {
+ if (which&bit) {
+ CARD8 what;
+
+ if (!XkbIM_InUse(map))
+ continue;
+ sli->mapsPresent|= bit;
+
+ what= (map->which_mods|map->which_groups);
+ if (what&XkbIM_UseBase)
+ sli->usesBase|= bit;
+ if (what&XkbIM_UseLatched)
+ sli->usesLatched|= bit;
+ if (what&XkbIM_UseLocked)
+ sli->usesLocked|= bit;
+ if (what&XkbIM_UseEffective)
+ sli->usesEffective|= bit;
+ if (what&XkbIM_UseCompat)
+ sli->usesCompat|= bit;
+ if (map->ctrls)
+ sli->usesControls|= bit;
+
+ map->mods.mask= map->mods.real_mods;
+ if (map->mods.vmods!=0) {
+ map->mods.mask|= XkbMaskForVMask(xkb,map->mods.vmods);
+ }
+ }
+ }
+ sli->usedComponents= 0;
+ if (sli->usesBase)
+ sli->usedComponents|= XkbModifierBaseMask|XkbGroupBaseMask;
+ if (sli->usesLatched)
+ sli->usedComponents|= XkbModifierLatchMask|XkbGroupLatchMask;
+ if (sli->usesLocked)
+ sli->usedComponents|= XkbModifierLockMask|XkbGroupLockMask;
+ if (sli->usesEffective)
+ sli->usedComponents|= XkbModifierStateMask|XkbGroupStateMask;
+ if (sli->usesCompat)
+ sli->usedComponents|= XkbCompatStateMask;
+ return;
+}
+
+/***====================================================================***/
+
+ /*
+ * XkbSrvLedInfoPtr
+ * XkbAllocSrvLedInfo(dev,kf,lf,needed_parts)
+ *
+ * Allocates an XkbSrvLedInfoPtr for the feedback specified by either
+ * 'kf' or 'lf' on the keyboard specified by 'dev.'
+ *
+ * If 'needed_parts' is non-zero, this function makes sure that any
+ * of the parts speicified therein are allocated.
+ */
+XkbSrvLedInfoPtr
+XkbAllocSrvLedInfo( DeviceIntPtr dev,
+ KbdFeedbackPtr kf,
+ LedFeedbackPtr lf,
+ unsigned needed_parts)
+{
+XkbSrvLedInfoPtr sli;
+Bool checkAccel;
+Bool checkNames;
+
+ sli= NULL;
+ checkAccel= checkNames= False;
+ if ((kf!=NULL)&&(kf->xkb_sli==NULL)) {
+ kf->xkb_sli= sli= _XkbTypedCalloc(1,XkbSrvLedInfoRec);
+ if (sli==NULL)
+ return NULL; /* ALLOCATION ERROR */
+ if (dev->key && dev->key->xkbInfo)
+ sli->flags= XkbSLI_HasOwnState;
+ else sli->flags= 0;
+ sli->class= KbdFeedbackClass;
+ sli->id= kf->ctrl.id;
+ sli->fb.kf= kf;
+
+ sli->autoState= 0;
+ sli->explicitState= kf->ctrl.leds;
+ sli->effectiveState= kf->ctrl.leds;
+
+ if ((kf==dev->kbdfeed) && (dev->key) && (dev->key->xkbInfo)) {
+ XkbDescPtr xkb;
+ xkb= dev->key->xkbInfo->desc;
+ sli->flags|= XkbSLI_IsDefault;
+ sli->physIndicators= xkb->indicators->phys_indicators;
+ sli->names= xkb->names->indicators;
+ sli->maps= xkb->indicators->maps;
+ checkNames= checkAccel= True;
+ }
+ else {
+ sli->physIndicators= XkbAllIndicatorsMask;
+ sli->names= NULL;
+ sli->maps= NULL;
+ }
+ }
+ else if ((kf!=NULL)&&((kf->xkb_sli->flags&XkbSLI_IsDefault)!=0)) {
+ XkbDescPtr xkb;
+ xkb= dev->key->xkbInfo->desc;
+ sli->physIndicators= xkb->indicators->phys_indicators;
+ if (xkb->names->indicators!=sli->names) {
+ checkNames= True;
+ sli->names= xkb->names->indicators;
+ }
+ if (xkb->indicators->maps!=sli->maps) {
+ checkAccel= True;
+ sli->maps= xkb->indicators->maps;
+ }
+ }
+ else if ((lf!=NULL)&&(lf->xkb_sli==NULL)) {
+ lf->xkb_sli= sli= _XkbTypedCalloc(1,XkbSrvLedInfoRec);
+ if (sli==NULL)
+ return NULL; /* ALLOCATION ERROR */
+ if (dev->key && dev->key->xkbInfo)
+ sli->flags= XkbSLI_HasOwnState;
+ else sli->flags= 0;
+ sli->class= LedFeedbackClass;
+ sli->id= lf->ctrl.id;
+ sli->fb.lf= lf;
+
+ sli->physIndicators= lf->ctrl.led_mask;
+ sli->autoState= 0;
+ sli->explicitState= lf->ctrl.led_values;
+ sli->effectiveState= lf->ctrl.led_values;
+ sli->maps= NULL;
+ sli->names= NULL;
+ }
+ if ((sli->names==NULL)&&(needed_parts&XkbXI_IndicatorNamesMask))
+ sli->names= _XkbTypedCalloc(XkbNumIndicators,Atom);
+ if ((sli->maps==NULL)&&(needed_parts&XkbXI_IndicatorMapsMask))
+ sli->maps= _XkbTypedCalloc(XkbNumIndicators,XkbIndicatorMapRec);
+ if (checkNames) {
+ register unsigned i,bit;
+ sli->namesPresent= 0;
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (sli->names[i]!=None)
+ sli->namesPresent|= bit;
+ }
+ }
+ if (checkAccel)
+ XkbCheckIndicatorMaps(dev,sli,XkbAllIndicatorsMask);
+ return sli;
+}
+
+void
+XkbFreeSrvLedInfo(XkbSrvLedInfoPtr sli)
+{
+ if ((sli->flags&XkbSLI_IsDefault)==0) {
+ if (sli->maps) _XkbFree(sli->maps);
+ if (sli->names) _XkbFree(sli->names);
+ }
+ sli->maps= NULL;
+ sli->names= NULL;
+ _XkbFree(sli);
+ return;
+}
+
+
+/***====================================================================***/
+
+ /*
+ * XkbSrvLedInfoPtr
+ * XkbFindSrvLedInfo(dev,class,id,needed_parts)
+ *
+ * Finds the XkbSrvLedInfoPtr for the specified 'class' and 'id'
+ * on the device specified by 'dev.' If the class and id specify
+ * a valid device feedback, this function returns the existing
+ * feedback or allocates a new one.
+ *
+ */
+
+XkbSrvLedInfoPtr
+XkbFindSrvLedInfo( DeviceIntPtr dev,
+ unsigned class,
+ unsigned id,
+ unsigned needed_parts)
+{
+XkbSrvLedInfoPtr sli;
+
+ /* optimization to check for most common case */
+ if (((class==XkbDfltXIClass)&&(id==XkbDfltXIId))&&(dev->kbdfeed)) {
+ XkbSrvLedInfoPtr sli;
+ sli= dev->kbdfeed->xkb_sli;
+ if (dev->kbdfeed->xkb_sli==NULL) {
+ sli= XkbAllocSrvLedInfo(dev,dev->kbdfeed,NULL,needed_parts);
+ dev->kbdfeed->xkb_sli= sli;
+ }
+ return dev->kbdfeed->xkb_sli;
+ }
+
+ sli= NULL;
+ if (class==XkbDfltXIClass) {
+ if (dev->kbdfeed) class= KbdFeedbackClass;
+ else if (dev->leds) class= LedFeedbackClass;
+ else return NULL;
+ }
+ if (class==KbdFeedbackClass) {
+ KbdFeedbackPtr kf;
+ for (kf=dev->kbdfeed;kf!=NULL;kf=kf->next) {
+ if ((id==XkbDfltXIId)||(id==kf->ctrl.id)) {
+ if (kf->xkb_sli==NULL)
+ kf->xkb_sli= XkbAllocSrvLedInfo(dev,kf,NULL,needed_parts);
+ sli= kf->xkb_sli;
+ break;
+ }
+ }
+ }
+ else if (class==LedFeedbackClass) {
+ LedFeedbackPtr lf;
+ for (lf=dev->leds;lf!=NULL;lf=lf->next) {
+ if ((id==XkbDfltXIId)||(id==lf->ctrl.id)) {
+ if (lf->xkb_sli==NULL)
+ lf->xkb_sli= XkbAllocSrvLedInfo(dev,NULL,lf,needed_parts);
+ sli= lf->xkb_sli;
+ break;
+ }
+ }
+ }
+ if ((sli->names==NULL)&&(needed_parts&XkbXI_IndicatorNamesMask))
+ sli->names= _XkbTypedCalloc(XkbNumIndicators,Atom);
+ if ((sli->maps==NULL)&&(needed_parts&XkbXI_IndicatorMapsMask))
+ sli->maps= _XkbTypedCalloc(XkbNumIndicators,XkbIndicatorMapRec);
+ return sli;
+}
+
+/***====================================================================***/
+
+void
+XkbFlushLedEvents( DeviceIntPtr dev,
+ DeviceIntPtr kbd,
+ XkbSrvLedInfoPtr sli,
+ xkbExtensionDeviceNotify * ed,
+ XkbChangesPtr changes,
+ XkbEventCausePtr cause)
+{
+ if (changes) {
+ if (changes->indicators.state_changes)
+ XkbDDXUpdateDeviceIndicators(dev,sli,sli->effectiveState);
+ XkbSendNotification(kbd,changes,cause);
+ bzero((char *)changes,sizeof(XkbChangesRec));
+
+ if (XkbAX_NeedFeedback(kbd->key->xkbInfo->desc->ctrls, XkbAX_IndicatorFBMask)) {
+ if (sli->effectiveState)
+ /* it appears that the which parameter is not used */
+ XkbDDXAccessXBeep(dev, _BEEP_LED_ON, XkbAccessXFeedbackMask);
+ else
+ XkbDDXAccessXBeep(dev, _BEEP_LED_OFF, XkbAccessXFeedbackMask);
+ }
+ }
+ if (ed && (ed->reason)) {
+ if ((dev!=kbd)&&(ed->reason&XkbXI_IndicatorStateMask))
+ XkbDDXUpdateDeviceIndicators(dev,sli,sli->effectiveState);
+ XkbSendExtensionDeviceNotify(dev,cause->client,ed);
+ }
+ bzero((char *)ed,sizeof(XkbExtensionDeviceNotify));
+ return;
+}
+
+/***====================================================================***/
+
+void
+XkbApplyLedNameChanges( DeviceIntPtr dev,
+ XkbSrvLedInfoPtr sli,
+ unsigned changed_names,
+ xkbExtensionDeviceNotify * ed,
+ XkbChangesPtr changes,
+ XkbEventCausePtr cause)
+{
+DeviceIntPtr kbd;
+XkbChangesRec my_changes;
+xkbExtensionDeviceNotify my_ed;
+
+ if (changed_names==0)
+ return;
+ if (dev->key && dev->key->xkbInfo)
+ kbd= dev;
+ else kbd= (DeviceIntPtr)LookupKeyboardDevice();
+
+ if (ed==NULL) {
+ ed= &my_ed;
+ bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
+ }
+ else if ((ed->reason&XkbXI_IndicatorsMask)&&
+ ((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
+ XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
+ }
+
+ if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) {
+ if (changes==NULL) {
+ changes= &my_changes;
+ bzero((char *)changes,sizeof(XkbChangesRec));
+ }
+ changes->names.changed|= XkbIndicatorNamesMask;
+ changes->names.changed_indicators|= changed_names;
+ }
+
+ ed->reason|= (XkbXI_IndicatorNamesMask&(~XkbXIUnsupported));
+ ed->ledClass= sli->class;
+ ed->ledID= sli->id;
+ ed->ledsDefined= sli->namesPresent|sli->mapsPresent;
+ ed->ledState= sli->effectiveState;
+ ed->unsupported|= XkbXIUnsupported&XkbXI_IndicatorNamesMask;
+ ed->supported= XkbXI_AllFeaturesMask&(~XkbXIUnsupported);
+
+ if (changes!=&my_changes) changes= NULL;
+ if (ed!=&my_ed) ed= NULL;
+ if (changes || ed)
+ XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
+ return;
+}
+/***====================================================================***/
+
+ /*
+ * void
+ * XkbApplyLedMapChanges(dev,sli,changed_maps,changes,cause)
+ *
+ * Handles all of the secondary effects of the changes to the
+ * feedback specified by 'sli' on the device specified by 'dev.'
+ *
+ * If 'changed_maps' specifies any indicators, this function generates
+ * XkbExtensionDeviceNotify events and possibly IndicatorMapNotify
+ * events to report the changes, and recalculates the effective
+ * state of each indicator with a changed map. If any indicators
+ * change state, the server generates XkbExtensionDeviceNotify and
+ * XkbIndicatorStateNotify events as appropriate.
+ *
+ * If 'changes' is non-NULL, this function updates it to reflect
+ * any changes to the keyboard state or controls or to the 'core'
+ * indicator names, maps, or state. If 'changes' is NULL, this
+ * function generates XKB events as needed to report the changes.
+ * If 'dev' is not a keyboard device, any changes are reported
+ * for the core keyboard.
+ *
+ * The 'cause' specifies the reason for the event (key event or
+ * request) for the change, as reported in some XKB events.
+ */
+
+void
+XkbApplyLedMapChanges( DeviceIntPtr dev,
+ XkbSrvLedInfoPtr sli,
+ unsigned changed_maps,
+ xkbExtensionDeviceNotify * ed,
+ XkbChangesPtr changes,
+ XkbEventCausePtr cause)
+{
+DeviceIntPtr kbd;
+XkbChangesRec my_changes;
+xkbExtensionDeviceNotify my_ed;
+
+ if (changed_maps==0)
+ return;
+ if (dev->key && dev->key->xkbInfo)
+ kbd= dev;
+ else kbd= (DeviceIntPtr)LookupKeyboardDevice();
+
+ if (ed==NULL) {
+ ed= &my_ed;
+ bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
+ }
+ else if ((ed->reason&XkbXI_IndicatorsMask)&&
+ ((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
+ XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
+ }
+
+ if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) {
+ if (changes==NULL) {
+ changes= &my_changes;
+ bzero((char *)changes,sizeof(XkbChangesRec));
+ }
+ changes->indicators.map_changes|= changed_maps;
+ }
+
+ XkbCheckIndicatorMaps(dev,sli,changed_maps);
+
+ ed->reason|= (XkbXI_IndicatorMapsMask&(~XkbXIUnsupported));
+ ed->ledClass= sli->class;
+ ed->ledID= sli->id;
+ ed->ledsDefined= sli->namesPresent|sli->mapsPresent;
+ ed->ledState= sli->effectiveState;
+ ed->unsupported|= XkbXIUnsupported&XkbXI_IndicatorMapsMask;
+ ed->supported= XkbXI_AllFeaturesMask&(~XkbXIUnsupported);
+
+ XkbUpdateLedAutoState(dev,sli,changed_maps,ed,changes,cause);
+
+ if (changes!=&my_changes) changes= NULL;
+ if (ed!=&my_ed) ed= NULL;
+ if (changes || ed)
+ XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
+ return;
+}
+
+/***====================================================================***/
+
+void
+XkbApplyLedStateChanges(DeviceIntPtr dev,
+ XkbSrvLedInfoPtr sli,
+ unsigned changed_leds,
+ xkbExtensionDeviceNotify * ed,
+ XkbChangesPtr changes,
+ XkbEventCausePtr cause)
+{
+XkbSrvInfoPtr xkbi;
+DeviceIntPtr kbd;
+XkbChangesRec my_changes;
+xkbExtensionDeviceNotify my_ed;
+register unsigned i,bit,affected;
+XkbIndicatorMapPtr map;
+unsigned oldState;
+Bool kb_changed;
+
+ if (changed_leds==0)
+ return;
+ if (dev->key && dev->key->xkbInfo)
+ kbd= dev;
+ else kbd= (DeviceIntPtr)LookupKeyboardDevice();
+ xkbi= kbd->key->xkbInfo;
+
+ if (changes==NULL) {
+ changes= &my_changes;
+ bzero((char *)changes,sizeof(XkbChangesRec));
+ }
+
+ kb_changed= False;
+ affected= changed_leds;
+ oldState= sli->effectiveState;
+ for (i=0,bit=1;(i<XkbNumIndicators)&&(affected);i++,bit<<=1) {
+ if ((affected&bit)==0)
+ continue;
+ affected&= ~bit;
+ map= &sli->maps[i];
+ if (map->flags&XkbIM_NoExplicit) {
+ sli->explicitState&= ~bit;
+ continue;
+ }
+ if (map->flags&XkbIM_LEDDrivesKB) {
+ Bool on= ((sli->explicitState&bit)!=0);
+ if (XkbApplyLEDChangeToKeyboard(xkbi,map,on,changes))
+ kb_changed= True;
+ }
+ }
+ sli->effectiveState= (sli->autoState|sli->explicitState);
+ affected= sli->effectiveState^oldState;
+
+ if (ed==NULL) {
+ ed= &my_ed;
+ bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
+ }
+ else if (affected&&(ed->reason&XkbXI_IndicatorsMask)&&
+ ((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
+ XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
+ }
+
+ if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault))
+ changes->indicators.state_changes|= affected;
+ if (affected) {
+ ed->reason|= (XkbXI_IndicatorStateMask&(~XkbXIUnsupported));
+ ed->ledClass= sli->class;
+ ed->ledID= sli->id;
+ ed->ledsDefined= sli->namesPresent|sli->mapsPresent;
+ ed->ledState= sli->effectiveState;
+ ed->unsupported|= XkbXIUnsupported&XkbXI_IndicatorStateMask;
+ ed->supported= XkbXI_AllFeaturesMask&(~XkbXIUnsupported);
+ }
+
+ if (kb_changed) {
+ XkbComputeDerivedState(kbd->key->xkbInfo);
+ XkbUpdateLedAutoState(dev,sli,sli->mapsPresent,ed,changes,cause);
+ }
+
+ if (changes!=&my_changes) changes= NULL;
+ if (ed!=&my_ed) ed= NULL;
+ if (changes || ed)
+ XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
+ if (kb_changed)
+ XkbUpdateAllDeviceIndicators(NULL,cause);
+ return;
+}
+
+/***====================================================================***/
+
+void
+XkbUpdateLedAutoState( DeviceIntPtr dev,
+ XkbSrvLedInfoPtr sli,
+ unsigned maps_to_check,
+ xkbExtensionDeviceNotify * ed,
+ XkbChangesPtr changes,
+ XkbEventCausePtr cause)
+{
+DeviceIntPtr kbd;
+XkbStatePtr state;
+XkbControlsPtr ctrls;
+XkbChangesRec my_changes;
+xkbExtensionDeviceNotify my_ed;
+register unsigned i,bit,affected;
+register XkbIndicatorMapPtr map;
+unsigned oldState;
+
+ if ((maps_to_check==0)||(sli->maps==NULL)||(sli->mapsPresent==0))
+ return;
+
+ if (dev->key && dev->key->xkbInfo)
+ kbd= dev;
+ else kbd= (DeviceIntPtr)LookupKeyboardDevice();
+
+ state= &kbd->key->xkbInfo->state;
+ ctrls= kbd->key->xkbInfo->desc->ctrls;
+ affected= maps_to_check;
+ oldState= sli->effectiveState;
+ sli->autoState&= ~affected;
+ for (i=0,bit=1;(i<XkbNumIndicators)&&(affected);i++,bit<<=1) {
+ if ((affected&bit)==0)
+ continue;
+ affected&= ~bit;
+ map= &sli->maps[i];
+ if((!(map->flags&XkbIM_NoAutomatic))&&ComputeAutoState(map,state,ctrls))
+ sli->autoState|= bit;
+ }
+ sli->effectiveState= (sli->autoState|sli->explicitState);
+ affected= sli->effectiveState^oldState;
+ if (affected==0)
+ return;
+
+ if (ed==NULL) {
+ ed= &my_ed;
+ bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
+ }
+ else if ((ed->reason&XkbXI_IndicatorsMask)&&
+ ((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
+ XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
+ }
+
+ if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) {
+ if (changes==NULL) {
+ changes= &my_changes;
+ bzero((char *)changes,sizeof(XkbChangesRec));
+ }
+ changes->indicators.state_changes|= affected;
+ }
+
+ ed->reason|= (XkbXI_IndicatorStateMask&(~XkbXIUnsupported));
+ ed->ledClass= sli->class;
+ ed->ledID= sli->id;
+ ed->ledsDefined= sli->namesPresent|sli->mapsPresent;
+ ed->ledState= sli->effectiveState;
+ ed->unsupported|= XkbXIUnsupported&XkbXI_IndicatorStateMask;
+ ed->supported= XkbXI_AllFeaturesMask&(~XkbXIUnsupported);
+
+ if (changes!=&my_changes) changes= NULL;
+ if (ed!=&my_ed) ed= NULL;
+ if (changes || ed)
+ XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
+ return;
+}
+
+/***====================================================================***/
+
+static void
+_UpdateButtonVMods( XkbDescPtr xkb,
+ unsigned num_btns,
+ XkbAction * acts,
+ unsigned changed,
+ xkbExtensionDeviceNotify * ed_inout)
+{
+register int i;
+
+ for (i=0;i<num_btns;i++,acts++) {
+ if ((acts->any.type!=XkbSA_NoAction)&&
+ XkbUpdateActionVirtualMods(xkb,acts,changed)) {
+ if ((ed_inout->reason&XkbXI_ButtonActionsMask)==0) {
+ ed_inout->reason|= XkbXI_ButtonActionsMask;
+ ed_inout->firstBtn= i;
+ ed_inout->nBtns= 1;
+ }
+ else {
+ ed_inout->nBtns= (i-ed_inout->firstBtn)+1;
+ }
+ }
+ }
+ return;
+}
+
+static void
+_UpdateMapVMods( XkbDescPtr xkb,
+ register XkbIndicatorMapPtr map,
+ unsigned changed_vmods,
+ unsigned * changed_maps_rtrn)
+{
+register int i;
+
+ *changed_maps_rtrn= 0;
+ for (i=0;i<XkbNumIndicators;i++,map++) {
+ if (map->mods.vmods&changed_vmods) {
+ map->mods.mask= map->mods.real_mods;
+ map->mods.mask|= XkbMaskForVMask(xkb,map->mods.vmods);
+ *changed_maps_rtrn|= (1L<<i);
+ }
+ }
+ return;
+}
+
+static void
+_UpdateDeviceVMods( DeviceIntPtr dev,
+ XkbDescPtr xkb,
+ unsigned changed,
+ XkbEventCausePtr cause)
+{
+xkbExtensionDeviceNotify ed;
+XkbSrvLedInfoPtr sli;
+unsigned changed_maps;
+
+ bzero((char *)&ed,sizeof(xkbExtensionDeviceNotify));
+ ed.deviceID= dev->id;
+ if ((dev->button)&&(dev->button->xkb_acts)) {
+ _UpdateButtonVMods(xkb,dev->button->numButtons,
+ dev->button->xkb_acts,changed,&ed);
+ }
+ if (dev->kbdfeed) {
+ KbdFeedbackPtr kf;
+ for (kf=dev->kbdfeed;kf!=NULL;kf=kf->next) {
+ if ((kf->xkb_sli==NULL)||(kf->xkb_sli->maps==NULL))
+ continue;
+ sli= kf->xkb_sli;
+ _UpdateMapVMods(xkb,sli->maps,changed,&changed_maps);
+ if (changed_maps) {
+ if (ed.reason&XkbXI_IndicatorsMask) {
+ XkbSendExtensionDeviceNotify(dev,NULL,&ed);
+ ed.reason= 0;
+ ed.firstBtn= ed.nBtns;
+ }
+ ed.ledClass= sli->class;
+ ed.ledID= sli->id;
+ ed.ledsDefined= sli->namesPresent|sli->mapsPresent;
+ ed.reason|= XkbXI_IndicatorMapsMask;
+ XkbUpdateLedAutoState(dev,sli,changed_maps,&ed,NULL,cause);
+ }
+ }
+ }
+ if (dev->leds) {
+ LedFeedbackPtr lf;
+ for (lf=dev->leds;lf!=NULL;lf=lf->next) {
+ if ((lf->xkb_sli==NULL)||(lf->xkb_sli->maps==NULL))
+ continue;
+ sli= lf->xkb_sli;
+ _UpdateMapVMods(xkb,sli->maps,changed,&changed_maps);
+ if (changed_maps) {
+ if (ed.reason&XkbXI_IndicatorsMask) {
+ XkbSendExtensionDeviceNotify(dev,NULL,&ed);
+ ed.reason= 0;
+ ed.firstBtn= ed.nBtns;
+ }
+ ed.ledClass= sli->class;
+ ed.ledID= sli->id;
+ ed.ledsDefined= sli->namesPresent|sli->mapsPresent;
+ ed.reason|= XkbXI_IndicatorMapsMask;
+ XkbUpdateLedAutoState(dev,sli,changed_maps,&ed,NULL,cause);
+ }
+ }
+ }
+ if (ed.reason!=0)
+ XkbSendExtensionDeviceNotify(dev,NULL,&ed);
+ return;
+}
+
+void
+XkbApplyVModChangesToAllDevices( DeviceIntPtr dev,
+ XkbDescPtr xkb,
+ unsigned changed,
+ XkbEventCausePtr cause)
+{
+DeviceIntPtr edev;
+ if (dev!=(DeviceIntPtr)LookupKeyboardDevice())
+ return;
+ for (edev=inputInfo.devices;edev!=NULL;edev=edev->next) {
+ if (edev->key)
+ continue;
+ _UpdateDeviceVMods(edev,xkb,changed,cause);
+ }
+ for (edev=inputInfo.off_devices;edev!=NULL;edev=edev->next) {
+ if (edev->key)
+ continue;
+ _UpdateDeviceVMods(edev,xkb,changed,cause);
+ }
+ return;
+}
diff --git a/nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c b/nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c
new file mode 100644
index 000000000..ee521be69
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c
@@ -0,0 +1,188 @@
+/* $Xorg: xkbPrKeyEv.c,v 1.3 2000/08/17 19:53:48 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/xkbPrKeyEv.c,v 3.8 2001/01/17 22:37:15 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <math.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "misc.h"
+#include "inputstr.h"
+#include <X11/extensions/XKBsrv.h>
+#include <ctype.h>
+
+
+/***====================================================================***/
+
+void
+XkbProcessKeyboardEvent(xEvent *xE,DeviceIntPtr keybd,int count)
+{
+KeyClassPtr keyc = keybd->key;
+XkbSrvInfoPtr xkbi;
+int key;
+XkbBehavior behavior;
+unsigned ndx;
+
+ xkbi= keyc->xkbInfo;
+ key= xE->u.u.detail;
+#ifdef DEBUG
+ if (xkbDebugFlags&0x8) {
+ ErrorF("XkbPKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up"));
+ }
+#endif
+
+ if ( (xkbi->repeatKey==key) && (xE->u.u.type==KeyRelease) &&
+ ((xkbi->desc->ctrls->enabled_ctrls&XkbRepeatKeysMask)==0) ) {
+ AccessXCancelRepeatKey(xkbi,key);
+ }
+
+ behavior= xkbi->desc->server->behaviors[key];
+ /* The "permanent" flag indicates a hard-wired behavior that occurs */
+ /* below XKB, such as a key that physically locks. XKB does not */
+ /* do anything to implement the behavior, but it *does* report that */
+ /* key is hardwired */
+ if ((behavior.type&XkbKB_Permanent)==0) {
+ switch (behavior.type) {
+ case XkbKB_Default:
+ if (( xE->u.u.type == KeyPress ) &&
+ (keyc->down[key>>3] & (1<<(key&7)))) {
+ XkbLastRepeatEvent= (pointer)xE;
+ xE->u.u.type = KeyRelease;
+ XkbHandleActions(keybd,keybd,xE,count);
+ xE->u.u.type = KeyPress;
+ XkbHandleActions(keybd,keybd,xE,count);
+ XkbLastRepeatEvent= NULL;
+ return;
+ }
+ else if ((xE->u.u.type==KeyRelease) &&
+ (!(keyc->down[key>>3]&(1<<(key&7))))) {
+ XkbLastRepeatEvent= (pointer)&xE;
+ xE->u.u.type = KeyPress;
+ XkbHandleActions(keybd,keybd,xE,count);
+ xE->u.u.type = KeyRelease;
+ XkbHandleActions(keybd,keybd,xE,count);
+ XkbLastRepeatEvent= NULL;
+ return;
+ }
+ break;
+ case XkbKB_Lock:
+ if ( xE->u.u.type == KeyRelease )
+ return;
+ else {
+ int bit= 1<<(key&7);
+ if ( keyc->down[key>>3]&bit )
+ xE->u.u.type= KeyRelease;
+ }
+ break;
+ case XkbKB_RadioGroup:
+ ndx= (behavior.data&(~XkbKB_RGAllowNone));
+ if ( ndx<xkbi->nRadioGroups ) {
+ XkbRadioGroupPtr rg;
+
+ if ( xE->u.u.type == KeyRelease )
+ return;
+
+ rg = &xkbi->radioGroups[ndx];
+ if ( rg->currentDown == xE->u.u.detail ) {
+ if (behavior.data&XkbKB_RGAllowNone) {
+ xE->u.u.type = KeyRelease;
+ XkbHandleActions(keybd,keybd,xE,count);
+ rg->currentDown= 0;
+ }
+ return;
+ }
+ if ( rg->currentDown!=0 ) {
+ int key = xE->u.u.detail;
+ xE->u.u.type= KeyRelease;
+ xE->u.u.detail= rg->currentDown;
+ XkbHandleActions(keybd,keybd,xE,count);
+ xE->u.u.type= KeyPress;
+ xE->u.u.detail= key;
+ }
+ rg->currentDown= key;
+ }
+ else ErrorF("InternalError! Illegal radio group %d\n",ndx);
+ break;
+ case XkbKB_Overlay1: case XkbKB_Overlay2:
+ {
+ unsigned which;
+ if (behavior.type==XkbKB_Overlay1) which= XkbOverlay1Mask;
+ else which= XkbOverlay2Mask;
+ if ( (xkbi->desc->ctrls->enabled_ctrls&which)==0 )
+ break;
+ if ((behavior.data>=xkbi->desc->min_key_code)&&
+ (behavior.data<=xkbi->desc->max_key_code)) {
+ xE->u.u.detail= behavior.data;
+ /* 9/11/94 (ef) -- XXX! need to match release with */
+ /* press even if the state of the */
+ /* corresponding overlay control */
+ /* changes while the key is down */
+ }
+ }
+ break;
+ default:
+ ErrorF("unknown key behavior 0x%04x\n",behavior.type);
+#if defined(MetroLink)
+ return;
+#else
+ break;
+#endif
+ }
+ }
+ XkbHandleActions(keybd,keybd,xE,count);
+ return;
+}
+
+void
+ProcessKeyboardEvent(xEvent *xE,DeviceIntPtr keybd,int count)
+{
+KeyClassPtr keyc = keybd->key;
+XkbSrvInfoPtr xkbi;
+
+ xkbi= keyc->xkbInfo;
+
+#ifdef DEBUG
+ if (xkbDebugFlags&0x8) {
+ int key= xE->u.u.detail;
+ ErrorF("PKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up"));
+ }
+#endif
+ if ((xkbi->desc->ctrls->enabled_ctrls&XkbAllFilteredEventsMask)==0)
+ XkbProcessKeyboardEvent(xE,keybd,count);
+ else if (xE->u.u.type==KeyPress)
+ AccessXFilterPressEvent(xE,keybd,count);
+ else if (xE->u.u.type==KeyRelease)
+ AccessXFilterReleaseEvent(xE,keybd,count);
+ return;
+}
+
diff --git a/nx-X11/programs/Xserver/xkb/xkbPrOtherEv.c b/nx-X11/programs/Xserver/xkb/xkbPrOtherEv.c
new file mode 100644
index 000000000..82f476790
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/xkbPrOtherEv.c
@@ -0,0 +1,84 @@
+/* $Xorg: xkbPrOtherEv.c,v 1.3 2000/08/17 19:53:48 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86$ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <math.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "misc.h"
+#include "inputstr.h"
+#include <X11/extensions/XKBsrv.h>
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+
+extern void ProcessOtherEvent(
+ xEvent * /* xE */,
+ DeviceIntPtr /* dev */,
+ int /* count */
+);
+
+/***====================================================================***/
+
+void
+XkbProcessOtherEvent(xEvent *xE,DeviceIntPtr dev,int count)
+{
+Bool xkbCares,isBtn;
+
+ xkbCares= True;
+ isBtn= False;
+ switch ( xE->u.u.type ) {
+ case KeyPress: xE->u.u.type= DeviceKeyPress; break;
+ case KeyRelease: xE->u.u.type= DeviceKeyRelease; break;
+ case ButtonPress: xE->u.u.type= DeviceButtonPress;
+ isBtn= True;
+ break;
+ case ButtonRelease: xE->u.u.type= DeviceButtonRelease;
+ isBtn= True;
+ break;
+ default: xkbCares= False; break;
+ }
+ if (xkbCares) {
+ if ((!isBtn)||((dev->button)&&(dev->button->xkb_acts))) {
+ DeviceIntPtr kbd;
+ if (dev->key) kbd= dev;
+ else kbd= (DeviceIntPtr)LookupKeyboardDevice();
+ XkbHandleActions(dev,kbd,xE,count);
+ return;
+ }
+ }
+ ProcessOtherEvent(xE,dev,count);
+ return;
+}
+
diff --git a/nx-X11/programs/Xserver/xkb/xkbSwap.c b/nx-X11/programs/Xserver/xkb/xkbSwap.c
new file mode 100644
index 000000000..be1cd94fc
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/xkbSwap.c
@@ -0,0 +1,597 @@
+/* $Xorg: xkbSwap.c,v 1.3 2000/08/17 19:53:48 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/xkbSwap.c,v 3.4 2003/09/13 16:39:01 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "stdio.h"
+#include <X11/X.h>
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XKBstr.h>
+#include "extnsionst.h"
+#include "xkb.h"
+
+ /*
+ * REQUEST SWAPPING
+ */
+static int
+SProcXkbUseExtension(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbUseExtensionReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH(xkbUseExtensionReq);
+ swaps(&stuff->wantedMajor,n);
+ swaps(&stuff->wantedMinor,n);
+ return ProcXkbUseExtension(client);
+}
+
+static int
+SProcXkbSelectEvents(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbSelectEventsReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_AT_LEAST_SIZE(xkbSelectEventsReq);
+ swaps(&stuff->deviceSpec,n);
+ swaps(&stuff->affectWhich,n);
+ swaps(&stuff->clear,n);
+ swaps(&stuff->selectAll,n);
+ swaps(&stuff->affectMap,n);
+ swaps(&stuff->map,n);
+ if ((stuff->affectWhich&(~XkbMapNotifyMask))!=0) {
+ union {
+ BOOL *b;
+ CARD8 *c8;
+ CARD16 *c16;
+ CARD32 *c32;
+ } from;
+ register unsigned bit,ndx,maskLeft,dataLeft,size;
+
+ from.c8= (CARD8 *)&stuff[1];
+ dataLeft= (stuff->length*4)-SIZEOF(xkbSelectEventsReq);
+ maskLeft= (stuff->affectWhich&(~XkbMapNotifyMask));
+ for (ndx=0,bit=1; (maskLeft!=0); ndx++, bit<<=1) {
+ if (((bit&maskLeft)==0)||(ndx==XkbMapNotify))
+ continue;
+ maskLeft&= ~bit;
+ if ((stuff->selectAll&bit)||(stuff->clear&bit))
+ continue;
+ switch (ndx) {
+ case XkbNewKeyboardNotify:
+ case XkbStateNotify:
+ case XkbNamesNotify:
+ case XkbAccessXNotify:
+ case XkbExtensionDeviceNotify:
+ size= 2;
+ break;
+ case XkbControlsNotify:
+ case XkbIndicatorStateNotify:
+ case XkbIndicatorMapNotify:
+ size= 4;
+ break;
+ case XkbBellNotify:
+ case XkbActionMessage:
+ case XkbCompatMapNotify:
+ size= 1;
+ break;
+ default:
+ client->errorValue = _XkbErrCode2(0x1,bit);
+ return BadValue;
+ }
+ if (dataLeft<(size*2))
+ return BadLength;
+ if (size==2) {
+ swaps(&from.c16[0],n);
+ swaps(&from.c16[1],n);
+ }
+ else if (size==4) {
+ swapl(&from.c32[0],n);
+ swapl(&from.c32[1],n);
+ }
+ else {
+ size= 2;
+ }
+ from.c8+= (size*2);
+ dataLeft-= (size*2);
+ }
+ if (dataLeft>2) {
+ ErrorF("Extra data (%d bytes) after SelectEvents\n",dataLeft);
+ return BadLength;
+ }
+ }
+ return ProcXkbSelectEvents(client);
+}
+
+static int
+SProcXkbBell(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbBellReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH(xkbBellReq);
+ swaps(&stuff->deviceSpec,n);
+ swaps(&stuff->bellClass,n);
+ swaps(&stuff->bellID,n);
+ swapl(&stuff->name,n);
+ swapl(&stuff->window,n);
+ swaps(&stuff->pitch,n);
+ swaps(&stuff->duration,n);
+ return ProcXkbBell(client);
+}
+
+static int
+SProcXkbGetState(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbGetStateReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH(xkbGetStateReq);
+ swaps(&stuff->deviceSpec,n);
+ return ProcXkbGetState(client);
+}
+
+static int
+SProcXkbLatchLockState(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbLatchLockStateReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH(xkbLatchLockStateReq);
+ swaps(&stuff->deviceSpec,n);
+ swaps(&stuff->groupLatch,n);
+ return ProcXkbLatchLockState(client);
+}
+
+static int
+SProcXkbGetControls(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbGetControlsReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH(xkbGetControlsReq);
+ swaps(&stuff->deviceSpec,n);
+ return ProcXkbGetControls(client);
+}
+
+static int
+SProcXkbSetControls(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbSetControlsReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH(xkbSetControlsReq);
+ swaps(&stuff->deviceSpec,n);
+ swaps(&stuff->affectInternalVMods,n);
+ swaps(&stuff->internalVMods,n);
+ swaps(&stuff->affectIgnoreLockVMods,n);
+ swaps(&stuff->ignoreLockVMods,n);
+ swaps(&stuff->axOptions,n);
+ swapl(&stuff->affectEnabledCtrls,n);
+ swapl(&stuff->enabledCtrls,n);
+ swapl(&stuff->changeCtrls,n);
+ swaps(&stuff->repeatDelay,n);
+ swaps(&stuff->repeatInterval,n);
+ swaps(&stuff->slowKeysDelay,n);
+ swaps(&stuff->debounceDelay,n);
+ swaps(&stuff->mkDelay,n);
+ swaps(&stuff->mkInterval,n);
+ swaps(&stuff->mkTimeToMax,n);
+ swaps(&stuff->mkMaxSpeed,n);
+ swaps(&stuff->mkCurve,n);
+ swaps(&stuff->axTimeout,n);
+ swapl(&stuff->axtCtrlsMask,n);
+ swapl(&stuff->axtCtrlsValues,n);
+ swaps(&stuff->axtOptsMask,n);
+ swaps(&stuff->axtOptsValues,n);
+ return ProcXkbSetControls(client);
+}
+
+static int
+SProcXkbGetMap(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbGetMapReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH(xkbGetMapReq);
+ swaps(&stuff->deviceSpec,n);
+ swaps(&stuff->full,n);
+ swaps(&stuff->partial,n);
+ swaps(&stuff->virtualMods,n);
+ return ProcXkbGetMap(client);
+}
+
+static int
+SProcXkbSetMap(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbSetMapReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_AT_LEAST_SIZE(xkbSetMapReq);
+ swaps(&stuff->deviceSpec,n);
+ swaps(&stuff->present,n);
+ swaps(&stuff->flags,n);
+ swaps(&stuff->totalSyms,n);
+ swaps(&stuff->totalActs,n);
+ swaps(&stuff->virtualMods,n);
+ return ProcXkbSetMap(client);
+}
+
+
+static int
+SProcXkbGetCompatMap(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbGetCompatMapReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH(xkbGetCompatMapReq);
+ swaps(&stuff->deviceSpec,n);
+ swaps(&stuff->firstSI,n);
+ swaps(&stuff->nSI,n);
+ return ProcXkbGetCompatMap(client);
+}
+
+static int
+SProcXkbSetCompatMap(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbSetCompatMapReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_AT_LEAST_SIZE(xkbSetCompatMapReq);
+ swaps(&stuff->deviceSpec,n);
+ swaps(&stuff->firstSI,n);
+ swaps(&stuff->nSI,n);
+ return ProcXkbSetCompatMap(client);
+}
+
+static int
+SProcXkbGetIndicatorState(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbGetIndicatorStateReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH(xkbGetIndicatorStateReq);
+ swaps(&stuff->deviceSpec,n);
+ return ProcXkbGetIndicatorState(client);
+}
+
+static int
+SProcXkbGetIndicatorMap(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbGetIndicatorMapReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH(xkbGetIndicatorMapReq);
+ swaps(&stuff->deviceSpec,n);
+ swapl(&stuff->which,n);
+ return ProcXkbGetIndicatorMap(client);
+}
+
+static int
+SProcXkbSetIndicatorMap(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbSetIndicatorMapReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_AT_LEAST_SIZE(xkbSetIndicatorMapReq);
+ swaps(&stuff->deviceSpec,n);
+ swapl(&stuff->which,n);
+ return ProcXkbSetIndicatorMap(client);
+}
+
+static int
+SProcXkbGetNamedIndicator(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbGetNamedIndicatorReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH(xkbGetNamedIndicatorReq);
+ swaps(&stuff->deviceSpec,n);
+ swaps(&stuff->ledClass,n);
+ swaps(&stuff->ledID,n);
+ swapl(&stuff->indicator,n);
+ return ProcXkbGetNamedIndicator(client);
+}
+
+static int
+SProcXkbSetNamedIndicator(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbSetNamedIndicatorReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH(xkbSetNamedIndicatorReq);
+ swaps(&stuff->deviceSpec,n);
+ swaps(&stuff->ledClass,n);
+ swaps(&stuff->ledID,n);
+ swapl(&stuff->indicator,n);
+ swaps(&stuff->virtualMods,n);
+ swapl(&stuff->ctrls,n);
+ return ProcXkbSetNamedIndicator(client);
+}
+
+
+static int
+SProcXkbGetNames(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbGetNamesReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH(xkbGetNamesReq);
+ swaps(&stuff->deviceSpec,n);
+ swapl(&stuff->which,n);
+ return ProcXkbGetNames(client);
+}
+
+static int
+SProcXkbSetNames(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbSetNamesReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_AT_LEAST_SIZE(xkbSetNamesReq);
+ swaps(&stuff->deviceSpec,n);
+ swaps(&stuff->virtualMods,n);
+ swapl(&stuff->which,n);
+ swapl(&stuff->indicators,n);
+ swaps(&stuff->totalKTLevelNames,n);
+ return ProcXkbSetNames(client);
+}
+
+static int
+SProcXkbGetGeometry(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbGetGeometryReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH(xkbGetGeometryReq);
+ swaps(&stuff->deviceSpec,n);
+ swapl(&stuff->name,n);
+ return ProcXkbGetGeometry(client);
+}
+
+static int
+SProcXkbSetGeometry(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbSetGeometryReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_AT_LEAST_SIZE(xkbSetGeometryReq);
+ swaps(&stuff->deviceSpec,n);
+ swapl(&stuff->name,n);
+ swaps(&stuff->widthMM,n);
+ swaps(&stuff->heightMM,n);
+ swaps(&stuff->nProperties,n);
+ swaps(&stuff->nColors,n);
+ swaps(&stuff->nDoodads,n);
+ swaps(&stuff->nKeyAliases,n);
+ return ProcXkbSetGeometry(client);
+}
+
+static int
+SProcXkbPerClientFlags(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbPerClientFlagsReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH(xkbPerClientFlagsReq);
+ swaps(&stuff->deviceSpec,n);
+ swapl(&stuff->change,n);
+ swapl(&stuff->value,n);
+ swapl(&stuff->ctrlsToChange,n);
+ swapl(&stuff->autoCtrls,n);
+ swapl(&stuff->autoCtrlValues,n);
+ return ProcXkbPerClientFlags(client);
+}
+
+static int
+SProcXkbListComponents(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbListComponentsReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_AT_LEAST_SIZE(xkbListComponentsReq);
+ swaps(&stuff->deviceSpec,n);
+ swaps(&stuff->maxNames,n);
+ return ProcXkbListComponents(client);
+}
+
+static int
+SProcXkbGetKbdByName(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbGetKbdByNameReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_AT_LEAST_SIZE(xkbGetKbdByNameReq);
+ swaps(&stuff->deviceSpec,n);
+ swaps(&stuff->want,n);
+ swaps(&stuff->need,n);
+ return ProcXkbGetKbdByName(client);
+}
+
+static int
+SProcXkbGetDeviceInfo(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbGetDeviceInfoReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH(xkbGetDeviceInfoReq);
+ swaps(&stuff->deviceSpec,n);
+ swaps(&stuff->wanted,n);
+ swaps(&stuff->ledClass,n);
+ swaps(&stuff->ledID,n);
+ return ProcXkbGetDeviceInfo(client);
+}
+
+static int
+SProcXkbSetDeviceInfo(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbSetDeviceInfoReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_AT_LEAST_SIZE(xkbSetDeviceInfoReq);
+ swaps(&stuff->deviceSpec,n);
+ swaps(&stuff->change,n);
+ swaps(&stuff->nDeviceLedFBs,n);
+ return ProcXkbSetDeviceInfo(client);
+}
+
+static int
+SProcXkbSetDebuggingFlags(ClientPtr client)
+{
+register int n;
+
+ REQUEST(xkbSetDebuggingFlagsReq);
+
+ swaps(&stuff->length,n);
+ REQUEST_AT_LEAST_SIZE(xkbSetDebuggingFlagsReq);
+ swapl(&stuff->affectFlags,n);
+ swapl(&stuff->flags,n);
+ swapl(&stuff->affectCtrls,n);
+ swapl(&stuff->ctrls,n);
+ swaps(&stuff->msgLength,n);
+ return ProcXkbSetDebuggingFlags(client);
+}
+
+int
+SProcXkbDispatch (ClientPtr client)
+{
+ REQUEST(xReq);
+ switch (stuff->data)
+ {
+ case X_kbUseExtension:
+ return SProcXkbUseExtension(client);
+ case X_kbSelectEvents:
+ return SProcXkbSelectEvents(client);
+ case X_kbBell:
+ return SProcXkbBell(client);
+ case X_kbGetState:
+ return SProcXkbGetState(client);
+ case X_kbLatchLockState:
+ return SProcXkbLatchLockState(client);
+ case X_kbGetControls:
+ return SProcXkbGetControls(client);
+ case X_kbSetControls:
+ return SProcXkbSetControls(client);
+ case X_kbGetMap:
+ return SProcXkbGetMap(client);
+ case X_kbSetMap:
+ return SProcXkbSetMap(client);
+ case X_kbGetCompatMap:
+ return SProcXkbGetCompatMap(client);
+ case X_kbSetCompatMap:
+ return SProcXkbSetCompatMap(client);
+ case X_kbGetIndicatorState:
+ return SProcXkbGetIndicatorState(client);
+ case X_kbGetIndicatorMap:
+ return SProcXkbGetIndicatorMap(client);
+ case X_kbSetIndicatorMap:
+ return SProcXkbSetIndicatorMap(client);
+ case X_kbGetNamedIndicator:
+ return SProcXkbGetNamedIndicator(client);
+ case X_kbSetNamedIndicator:
+ return SProcXkbSetNamedIndicator(client);
+ case X_kbGetNames:
+ return SProcXkbGetNames(client);
+ case X_kbSetNames:
+ return SProcXkbSetNames(client);
+ case X_kbGetGeometry:
+ return SProcXkbGetGeometry(client);
+ case X_kbSetGeometry:
+ return SProcXkbSetGeometry(client);
+ case X_kbPerClientFlags:
+ return SProcXkbPerClientFlags(client);
+ case X_kbListComponents:
+ return SProcXkbListComponents(client);
+ case X_kbGetKbdByName:
+ return SProcXkbGetKbdByName(client);
+ case X_kbGetDeviceInfo:
+ return SProcXkbGetDeviceInfo(client);
+ case X_kbSetDeviceInfo:
+ return SProcXkbSetDeviceInfo(client);
+ case X_kbSetDebuggingFlags:
+ return SProcXkbSetDebuggingFlags(client);
+ default:
+ return BadRequest;
+ }
+}
diff --git a/nx-X11/programs/Xserver/xkb/xkbUtils.c b/nx-X11/programs/Xserver/xkb/xkbUtils.c
new file mode 100644
index 000000000..f3c3ff8ca
--- /dev/null
+++ b/nx-X11/programs/Xserver/xkb/xkbUtils.c
@@ -0,0 +1,987 @@
+/* $Xorg: xkbUtils.c,v 1.3 2000/08/17 19:53:48 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/xkbUtils.c,v 3.16 2003/11/03 05:12:02 tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <math.h>
+#define NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#define XK_CYRILLIC
+#include <X11/keysym.h>
+#include "misc.h"
+#include "inputstr.h"
+
+#define XKBSRV_NEED_FILE_FUNCS
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XKBgeom.h>
+#include "xkb.h"
+
+#ifdef MODE_SWITCH
+extern Bool noKME; /* defined in os/utils.c */
+#endif
+
+int XkbDisableLockActions = 0;
+
+/***====================================================================***/
+
+#ifndef RETURN_SHOULD_REPEAT
+#if (defined(__osf__) && defined(__alpha))
+#define RETURN_SHOULD_REPEAT 1
+#else
+#define RETURN_SHOULD_REPEAT 0
+#endif
+#endif
+
+/***====================================================================***/
+
+DeviceIntPtr
+_XkbLookupAnyDevice(int id,int *why_rtrn)
+{
+DeviceIntPtr dev = NULL;
+
+ dev= (DeviceIntPtr)LookupKeyboardDevice();
+ if ((id==XkbUseCoreKbd)||(dev->id==id))
+ return dev;
+
+ dev= (DeviceIntPtr)LookupPointerDevice();
+ if ((id==XkbUseCorePtr)||(dev->id==id))
+ return dev;
+
+ if (id&(~0xff))
+ dev = NULL;
+
+ dev= (DeviceIntPtr)LookupDevice(id);
+ if (dev!=NULL)
+ return dev;
+ if ((!dev)&&(why_rtrn))
+ *why_rtrn= XkbErr_BadDevice;
+ return dev;
+}
+
+DeviceIntPtr
+_XkbLookupKeyboard(int id,int *why_rtrn)
+{
+DeviceIntPtr dev = NULL;
+
+ if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL)
+ return NULL;
+ else if ((!dev->key)||(!dev->key->xkbInfo)) {
+ if (why_rtrn)
+ *why_rtrn= XkbErr_BadClass;
+ return NULL;
+ }
+ return dev;
+}
+
+DeviceIntPtr
+_XkbLookupBellDevice(int id,int *why_rtrn)
+{
+DeviceIntPtr dev = NULL;
+
+ if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL)
+ return NULL;
+ else if ((!dev->kbdfeed)&&(!dev->bell)) {
+ if (why_rtrn)
+ *why_rtrn= XkbErr_BadClass;
+ return NULL;
+ }
+ return dev;
+}
+
+DeviceIntPtr
+_XkbLookupLedDevice(int id,int *why_rtrn)
+{
+DeviceIntPtr dev = NULL;
+
+ if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL)
+ return NULL;
+ else if ((!dev->kbdfeed)&&(!dev->leds)) {
+ if (why_rtrn)
+ *why_rtrn= XkbErr_BadClass;
+ return NULL;
+ }
+ return dev;
+}
+
+DeviceIntPtr
+_XkbLookupButtonDevice(int id,int *why_rtrn)
+{
+DeviceIntPtr dev = NULL;
+
+ if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL)
+ return NULL;
+ else if (!dev->button) {
+ if (why_rtrn)
+ *why_rtrn= XkbErr_BadClass;
+ return NULL;
+ }
+ return dev;
+}
+
+void
+XkbSetActionKeyMods(XkbDescPtr xkb,XkbAction *act,unsigned mods)
+{
+register unsigned tmp;
+
+ switch (act->type) {
+ case XkbSA_SetMods: case XkbSA_LatchMods: case XkbSA_LockMods:
+ if (act->mods.flags&XkbSA_UseModMapMods)
+ act->mods.real_mods= act->mods.mask= mods;
+ if ((tmp= XkbModActionVMods(&act->mods))!=0)
+ act->mods.mask|= XkbMaskForVMask(xkb,tmp);
+ break;
+ case XkbSA_ISOLock:
+ if (act->iso.flags&XkbSA_UseModMapMods)
+ act->iso.real_mods= act->iso.mask= mods;
+ if ((tmp= XkbModActionVMods(&act->iso))!=0)
+ act->iso.mask|= XkbMaskForVMask(xkb,tmp);
+ break;
+ }
+ return;
+}
+
+unsigned
+XkbMaskForVMask(XkbDescPtr xkb,unsigned vmask)
+{
+register int i,bit;
+register unsigned mask;
+
+ for (mask=i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (vmask&bit)
+ mask|= xkb->server->vmods[i];
+ }
+ return mask;
+}
+
+
+Bool
+XkbApplyVModChanges( XkbSrvInfoPtr xkbi,
+ unsigned changed,
+ XkbChangesPtr changes,
+ unsigned * needChecksRtrn,
+ XkbEventCausePtr cause)
+{
+XkbDescPtr xkb;
+Bool check;
+
+ xkb= xkbi->desc;
+#ifdef DEBUG
+{
+register unsigned i,bit;
+ for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if ((changed&bit)==0)
+ continue;
+ if (xkbDebugFlags)
+ ErrorF("Should be applying: change vmod %d to 0x%x\n",i,
+ xkb->server->vmods[i]);
+ }
+}
+#endif
+ check= XkbApplyVirtualModChanges(xkb,changed,changes);
+ XkbApplyVModChangesToAllDevices(xkbi->device,xkb,changed,cause);
+
+ if (needChecksRtrn!=NULL) {
+ if (check)
+ *needChecksRtrn= XkbStateNotifyMask|XkbIndicatorStateNotifyMask;
+ else *needChecksRtrn= 0;
+ }
+ else if (check) {
+ /* 7/12/95 (ef) -- XXX check compatibility and/or indicator state */
+ }
+ return 1;
+}
+
+/***====================================================================***/
+
+void
+XkbUpdateKeyTypesFromCore( DeviceIntPtr pXDev,
+ KeyCode first,
+ CARD8 num,
+ XkbChangesPtr changes)
+{
+XkbDescPtr xkb;
+unsigned key,nG,explicit;
+KeySymsPtr pCore;
+int types[XkbNumKbdGroups];
+KeySym tsyms[XkbMaxSymsPerKey],*syms;
+XkbMapChangesPtr mc;
+
+ xkb= pXDev->key->xkbInfo->desc;
+#ifdef NOTYET
+ if (first<xkb->min_key_code) {
+ if (first>=XkbMinLegalKeyCode) {
+ xkb->min_key_code= first;
+ /* 1/12/95 (ef) -- XXX! should zero out the new maps */
+ changes->map.changed|= XkbKeycodesMask;
+generate a NewKeyboard notify here?
+ }
+ }
+#endif
+ if (first+num-1>xkb->max_key_code) {
+ /* 1/12/95 (ef) -- XXX! should allow XKB structures to grow */
+ num= xkb->max_key_code-first+1;
+ }
+
+ mc= (changes?(&changes->map):NULL);
+
+ pCore= &pXDev->key->curKeySyms;
+ syms= &pCore->map[(first-xkb->min_key_code)*pCore->mapWidth];
+ for (key=first; key<(first+num); key++,syms+= pCore->mapWidth) {
+ explicit= xkb->server->explicit[key]&XkbExplicitKeyTypesMask;
+ types[XkbGroup1Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup1Index);
+ types[XkbGroup2Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup2Index);
+ types[XkbGroup3Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup3Index);
+ types[XkbGroup4Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup4Index);
+ nG= XkbKeyTypesForCoreSymbols(xkb,pCore->mapWidth,syms,explicit,types,
+ tsyms);
+ XkbChangeTypesOfKey(xkb,key,nG,XkbAllGroupsMask,types,mc);
+ memcpy((char *)XkbKeySymsPtr(xkb,key),(char *)tsyms,
+ XkbKeyNumSyms(xkb,key)*sizeof(KeySym));
+ }
+ if (changes->map.changed&XkbKeySymsMask) {
+ CARD8 oldLast,newLast;
+ oldLast = changes->map.first_key_sym+changes->map.num_key_syms-1;
+ newLast = first+num-1;
+
+ if (first<changes->map.first_key_sym)
+ changes->map.first_key_sym = first;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ changes->map.num_key_syms = newLast-changes->map.first_key_sym+1;
+ }
+ else {
+ changes->map.changed|= XkbKeySymsMask;
+ changes->map.first_key_sym = first;
+ changes->map.num_key_syms = num;
+ }
+ return;
+}
+
+void
+XkbUpdateDescActions( XkbDescPtr xkb,
+ KeyCode first,
+ CARD8 num,
+ XkbChangesPtr changes)
+{
+register unsigned key;
+
+ for (key=first;key<(first+num);key++) {
+ XkbApplyCompatMapToKey(xkb,key,changes);
+ }
+
+ if (changes->map.changed&(XkbVirtualModMapMask|XkbModifierMapMask)) {
+ unsigned char newVMods[XkbNumVirtualMods];
+ register unsigned bit,i;
+ unsigned present;
+
+ bzero(newVMods,XkbNumVirtualMods);
+ present= 0;
+ for (key=xkb->min_key_code;key<=xkb->max_key_code;key++) {
+ if (xkb->server->vmodmap[key]==0)
+ continue;
+ for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (bit&xkb->server->vmodmap[key]) {
+ present|= bit;
+ newVMods[i]|= xkb->map->modmap[key];
+ }
+ }
+ }
+ for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if ((bit&present)&&(newVMods[i]!=xkb->server->vmods[i])) {
+ changes->map.changed|= XkbVirtualModsMask;
+ changes->map.vmods|= bit;
+ xkb->server->vmods[i]= newVMods[i];
+ }
+ }
+ }
+ if (changes->map.changed&XkbVirtualModsMask)
+ XkbApplyVirtualModChanges(xkb,changes->map.vmods,changes);
+
+ if (changes->map.changed&XkbKeyActionsMask) {
+ CARD8 oldLast,newLast;
+ oldLast= changes->map.first_key_act+changes->map.num_key_acts-1;
+ newLast = first+num-1;
+
+ if (first<changes->map.first_key_act)
+ changes->map.first_key_act = first;
+ if (newLast>oldLast)
+ newLast= oldLast;
+ changes->map.num_key_acts= newLast-changes->map.first_key_act+1;
+ }
+ else {
+ changes->map.changed|= XkbKeyActionsMask;
+ changes->map.first_key_act = first;
+ changes->map.num_key_acts = num;
+ }
+ return;
+}
+
+void
+XkbUpdateActions( DeviceIntPtr pXDev,
+ KeyCode first,
+ CARD8 num,
+ XkbChangesPtr changes,
+ unsigned * needChecksRtrn,
+ XkbEventCausePtr cause)
+{
+XkbSrvInfoPtr xkbi;
+XkbDescPtr xkb;
+CARD8 * repeat;
+
+ if (needChecksRtrn)
+ *needChecksRtrn= 0;
+ xkbi= pXDev->key->xkbInfo;
+ xkb= xkbi->desc;
+ repeat= xkb->ctrls->per_key_repeat;
+
+ if (pXDev->kbdfeed)
+ memcpy(repeat,pXDev->kbdfeed->ctrl.autoRepeats,32);
+
+ XkbUpdateDescActions(xkb,first,num,changes);
+
+ if ((pXDev->kbdfeed)&&
+ (changes->ctrls.enabled_ctrls_changes&XkbPerKeyRepeatMask)) {
+ memcpy(pXDev->kbdfeed->ctrl.autoRepeats,repeat, 32);
+ (*pXDev->kbdfeed->CtrlProc)(pXDev, &pXDev->kbdfeed->ctrl);
+ }
+ return;
+}
+
+void
+XkbUpdateCoreDescription(DeviceIntPtr keybd,Bool resize)
+{
+register int key,tmp;
+int maxSymsPerKey,maxKeysPerMod;
+int first,last,firstCommon,lastCommon;
+XkbDescPtr xkb;
+KeyClassPtr keyc;
+CARD8 keysPerMod[XkbNumModifiers];
+
+ if (!keybd || !keybd->key || !keybd->key->xkbInfo)
+ return;
+ xkb= keybd->key->xkbInfo->desc;
+ keyc= keybd->key;
+ maxSymsPerKey= maxKeysPerMod= 0;
+ bzero(keysPerMod,sizeof(keysPerMod));
+ memcpy(keyc->modifierMap,xkb->map->modmap,xkb->max_key_code+1);
+ if ((xkb->min_key_code==keyc->curKeySyms.minKeyCode)&&
+ (xkb->max_key_code==keyc->curKeySyms.maxKeyCode)) {
+ first= firstCommon= xkb->min_key_code;
+ last= lastCommon= xkb->max_key_code;
+ }
+ else if (resize) {
+ keyc->curKeySyms.minKeyCode= xkb->min_key_code;
+ keyc->curKeySyms.maxKeyCode= xkb->max_key_code;
+ tmp= keyc->curKeySyms.mapWidth*_XkbCoreNumKeys(keyc);
+ keyc->curKeySyms.map= _XkbTypedRealloc(keyc->curKeySyms.map,tmp,KeySym);
+ if (!keyc->curKeySyms.map)
+ FatalError("Couldn't allocate keysyms\n");
+ first= firstCommon= xkb->min_key_code;
+ last= lastCommon= xkb->max_key_code;
+ }
+ else {
+ if (xkb->min_key_code<keyc->curKeySyms.minKeyCode) {
+ first= xkb->min_key_code;
+ firstCommon= keyc->curKeySyms.minKeyCode;
+ }
+ else {
+ firstCommon= xkb->min_key_code;
+ first= keyc->curKeySyms.minKeyCode;
+ }
+ if (xkb->max_key_code>keyc->curKeySyms.maxKeyCode) {
+ lastCommon= keyc->curKeySyms.maxKeyCode;
+ last= xkb->max_key_code;
+ }
+ else {
+ lastCommon= xkb->max_key_code;
+ last= keyc->curKeySyms.maxKeyCode;
+ }
+ }
+
+ /* determine sizes */
+ for (key=first;key<=last;key++) {
+ if (XkbKeycodeInRange(xkb,key)) {
+ int nGroups;
+ int w;
+ nGroups= XkbKeyNumGroups(xkb,key);
+ tmp= 0;
+ if (nGroups>0) {
+ if ((w=XkbKeyGroupWidth(xkb,key,XkbGroup1Index))<=2)
+ tmp+= 2;
+ else tmp+= w + 2;
+ }
+ if (nGroups>1) {
+ if (tmp <= 2) {
+ if ((w=XkbKeyGroupWidth(xkb,key,XkbGroup2Index))<2)
+ tmp+= 2;
+ else tmp+= w;
+ } else {
+ if ((w=XkbKeyGroupWidth(xkb,key,XkbGroup2Index))>2)
+ tmp+= w - 2;
+ }
+ }
+ if (nGroups>2)
+ tmp+= XkbKeyGroupWidth(xkb,key,XkbGroup3Index);
+ if (nGroups>3)
+ tmp+= XkbKeyGroupWidth(xkb,key,XkbGroup4Index);
+ if (tmp>maxSymsPerKey)
+ maxSymsPerKey= tmp;
+ }
+ if (_XkbCoreKeycodeInRange(keyc,key)) {
+ if (keyc->modifierMap[key]!=0) {
+ register unsigned bit,i,mask;
+ mask= keyc->modifierMap[key];
+ for (i=0,bit=1;i<XkbNumModifiers;i++,bit<<=1) {
+ if (mask&bit) {
+ keysPerMod[i]++;
+ if (keysPerMod[i]>maxKeysPerMod)
+ maxKeysPerMod= keysPerMod[i];
+ }
+ }
+ }
+ }
+ }
+
+ if (maxKeysPerMod>0) {
+ tmp= maxKeysPerMod*XkbNumModifiers;
+ if (keyc->modifierKeyMap==NULL)
+ keyc->modifierKeyMap= (KeyCode *)_XkbCalloc(1, tmp);
+ else if (keyc->maxKeysPerModifier<maxKeysPerMod)
+ keyc->modifierKeyMap= (KeyCode *)_XkbRealloc(keyc->modifierKeyMap,tmp);
+ if (keyc->modifierKeyMap==NULL)
+ FatalError("Couldn't allocate modifierKeyMap in UpdateCore\n");
+ bzero(keyc->modifierKeyMap,tmp);
+ }
+ else if ((keyc->maxKeysPerModifier>0)&&(keyc->modifierKeyMap!=NULL)) {
+ _XkbFree(keyc->modifierKeyMap);
+ keyc->modifierKeyMap= NULL;
+ }
+ keyc->maxKeysPerModifier= maxKeysPerMod;
+
+ if (maxSymsPerKey>0) {
+ tmp= maxSymsPerKey*_XkbCoreNumKeys(keyc);
+ keyc->curKeySyms.map= _XkbTypedRealloc(keyc->curKeySyms.map,tmp,KeySym);
+ if (keyc->curKeySyms.map==NULL)
+ FatalError("Couldn't allocate symbols map in UpdateCore\n");
+ }
+ else if ((keyc->curKeySyms.mapWidth>0)&&(keyc->curKeySyms.map!=NULL)) {
+ _XkbFree(keyc->curKeySyms.map);
+ keyc->curKeySyms.map= NULL;
+ }
+ keyc->curKeySyms.mapWidth= maxSymsPerKey;
+
+ bzero(keysPerMod,sizeof(keysPerMod));
+ for (key=firstCommon;key<=lastCommon;key++) {
+ if (keyc->curKeySyms.map!=NULL) {
+ KeySym *pCore,*pXKB;
+ unsigned nGroups,groupWidth,n,nOut;
+
+ nGroups= XkbKeyNumGroups(xkb,key);
+ n= (key-keyc->curKeySyms.minKeyCode)*maxSymsPerKey;
+ pCore= &keyc->curKeySyms.map[n];
+ bzero(pCore,maxSymsPerKey*sizeof(KeySym));
+ pXKB= XkbKeySymsPtr(xkb,key);
+ nOut= 2;
+ if (nGroups>0) {
+ groupWidth= XkbKeyGroupWidth(xkb,key,XkbGroup1Index);
+ if (groupWidth>0) pCore[0]= pXKB[0];
+ if (groupWidth>1) pCore[1]= pXKB[1];
+ for (n=2;n<groupWidth;n++) {
+ pCore[2+n]= pXKB[n];
+ }
+ if (groupWidth>2)
+ nOut= groupWidth;
+ }
+ pXKB+= XkbKeyGroupsWidth(xkb,key);
+ nOut+= 2;
+ if (nGroups>1) {
+ groupWidth= XkbKeyGroupWidth(xkb,key,XkbGroup2Index);
+ if (groupWidth>0) pCore[2]= pXKB[0];
+ if (groupWidth>1) pCore[3]= pXKB[1];
+ for (n=2;n<groupWidth;n++) {
+ pCore[nOut+(n-2)]= pXKB[n];
+ }
+ if (groupWidth>2)
+ nOut+= (groupWidth-2);
+ }
+ pXKB+= XkbKeyGroupsWidth(xkb,key);
+ for (n=XkbGroup3Index;n<nGroups;n++) {
+ register int s;
+ groupWidth= XkbKeyGroupWidth(xkb,key,n);
+ for (s=0;s<groupWidth;s++) {
+ pCore[nOut++]= pXKB[s];
+ }
+ pXKB+= XkbKeyGroupsWidth(xkb,key);
+ }
+ if (!pCore[2] && !pCore[3] && maxSymsPerKey >= 6 &&
+ (pCore[4] || pCore[5])) {
+ pCore[2] = pCore[4];
+ pCore[3] = pCore[5];
+ }
+ }
+ if (keyc->modifierMap[key]!=0) {
+ register unsigned bit,i,mask;
+ mask= keyc->modifierMap[key];
+ for (i=0,bit=1;i<XkbNumModifiers;i++,bit<<=1) {
+ if (mask&bit) {
+ tmp= i*maxKeysPerMod+keysPerMod[i];
+ keyc->modifierKeyMap[tmp]= key;
+ keysPerMod[i]++;
+ }
+ }
+ }
+ }
+#ifdef MODE_SWITCH
+ /* Fix up any of the KME stuff if we changed the core description.
+ */
+ if (!noKME)
+ HandleKeyBinding(keyc, &keyc->curKeySyms);
+#endif
+ return;
+}
+
+void
+XkbSetRepeatKeys(DeviceIntPtr pXDev,int key,int onoff)
+{
+ if (pXDev && pXDev->key && pXDev->key->xkbInfo) {
+ xkbControlsNotify cn;
+ XkbControlsPtr ctrls = pXDev->key->xkbInfo->desc->ctrls;
+ XkbControlsRec old;
+ old = *ctrls;
+
+ if (key== -1) { /* global autorepeat setting changed */
+ if (onoff) ctrls->enabled_ctrls |= XkbRepeatKeysMask;
+ else ctrls->enabled_ctrls &= ~XkbRepeatKeysMask;
+ }
+ else if (pXDev->kbdfeed) {
+ ctrls->per_key_repeat[key/8] =
+ pXDev->kbdfeed->ctrl.autoRepeats[key/8];
+ }
+
+ if (XkbComputeControlsNotify(pXDev,&old,ctrls,&cn,True))
+ XkbSendControlsNotify(pXDev,&cn);
+ }
+ return;
+}
+
+void
+XkbApplyMappingChange( DeviceIntPtr kbd,
+ CARD8 request,
+ KeyCode firstKey,
+ CARD8 num,
+ ClientPtr client)
+{
+XkbEventCauseRec cause;
+XkbChangesRec changes;
+unsigned check;
+
+ if (kbd->key->xkbInfo==NULL)
+ XkbInitDevice(kbd);
+ bzero(&changes,sizeof(XkbChangesRec));
+ check= 0;
+ if (request==MappingKeyboard) {
+ XkbSetCauseCoreReq(&cause,X_ChangeKeyboardMapping,client);
+ XkbUpdateKeyTypesFromCore(kbd,firstKey,num,&changes);
+ XkbUpdateActions(kbd,firstKey,num,&changes,&check,&cause);
+ if (check)
+ XkbCheckSecondaryEffects(kbd->key->xkbInfo,check,&changes,&cause);
+ }
+ else if (request==MappingModifier) {
+ XkbDescPtr xkb= kbd->key->xkbInfo->desc;
+
+ XkbSetCauseCoreReq(&cause,X_SetModifierMapping,client);
+
+ num = xkb->max_key_code-xkb->min_key_code+1;
+ memcpy(xkb->map->modmap,kbd->key->modifierMap,xkb->max_key_code+1);
+
+ changes.map.changed|= XkbModifierMapMask;
+ changes.map.first_modmap_key= xkb->min_key_code;
+ changes.map.num_modmap_keys= num;
+ XkbUpdateActions(kbd,xkb->min_key_code,num,&changes,&check,&cause);
+ if (check)
+ XkbCheckSecondaryEffects(kbd->key->xkbInfo,check,&changes,&cause);
+ }
+ /* 3/26/94 (ef) -- XXX! Doesn't deal with input extension requests */
+ XkbSendNotification(kbd,&changes,&cause);
+ return;
+}
+
+void
+XkbDisableComputedAutoRepeats(DeviceIntPtr dev,unsigned key)
+{
+XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+xkbMapNotify mn;
+
+ xkbi->desc->server->explicit[key]|= XkbExplicitAutoRepeatMask;
+ bzero(&mn,sizeof(mn));
+ mn.changed= XkbExplicitComponentsMask;
+ mn.firstKeyExplicit= key;
+ mn.nKeyExplicit= 1;
+ XkbSendMapNotify(dev,&mn);
+ return;
+}
+
+unsigned
+XkbStateChangedFlags(XkbStatePtr old,XkbStatePtr new)
+{
+int changed;
+
+ changed=(old->group!=new->group?XkbGroupStateMask:0);
+ changed|=(old->base_group!=new->base_group?XkbGroupBaseMask:0);
+ changed|=(old->latched_group!=new->latched_group?XkbGroupLatchMask:0);
+ changed|=(old->locked_group!=new->locked_group?XkbGroupLockMask:0);
+ changed|=(old->mods!=new->mods?XkbModifierStateMask:0);
+ changed|=(old->base_mods!=new->base_mods?XkbModifierBaseMask:0);
+ changed|=(old->latched_mods!=new->latched_mods?XkbModifierLatchMask:0);
+ changed|=(old->locked_mods!=new->locked_mods?XkbModifierLockMask:0);
+ changed|=(old->compat_state!=new->compat_state?XkbCompatStateMask:0);
+ changed|=(old->grab_mods!=new->grab_mods?XkbGrabModsMask:0);
+ if (old->compat_grab_mods!=new->compat_grab_mods)
+ changed|= XkbCompatGrabModsMask;
+ changed|=(old->lookup_mods!=new->lookup_mods?XkbLookupModsMask:0);
+ if (old->compat_lookup_mods!=new->compat_lookup_mods)
+ changed|= XkbCompatLookupModsMask;
+ changed|=(old->ptr_buttons!=new->ptr_buttons?XkbPointerButtonMask:0);
+ return changed;
+}
+
+void
+XkbComputeCompatState(XkbSrvInfoPtr xkbi)
+{
+CARD16 grp_mask;
+XkbStatePtr state= &xkbi->state;
+XkbCompatMapPtr map;
+
+ map= xkbi->desc->compat;
+ grp_mask= map->groups[state->group].mask;
+ state->compat_state = state->mods|grp_mask;
+ state->compat_lookup_mods= state->lookup_mods|grp_mask;
+
+ if (xkbi->desc->ctrls->enabled_ctrls&XkbIgnoreGroupLockMask)
+ grp_mask= map->groups[state->base_group].mask;
+ state->compat_grab_mods= state->grab_mods|grp_mask;
+ return;
+}
+
+unsigned
+XkbAdjustGroup(int group,XkbControlsPtr ctrls)
+{
+unsigned act;
+
+ act= XkbOutOfRangeGroupAction(ctrls->groups_wrap);
+ if (group<0) {
+ while ( group < 0 ) {
+ if (act==XkbClampIntoRange) {
+ group= XkbGroup1Index;
+ }
+ else if (act==XkbRedirectIntoRange) {
+ int newGroup;
+ newGroup= XkbOutOfRangeGroupNumber(ctrls->groups_wrap);
+ if (newGroup>=ctrls->num_groups)
+ group= XkbGroup1Index;
+ else group= newGroup;
+ }
+ else {
+ group+= ctrls->num_groups;
+ }
+ }
+ }
+ else if (group>=ctrls->num_groups) {
+ if (act==XkbClampIntoRange) {
+ group= ctrls->num_groups-1;
+ }
+ else if (act==XkbRedirectIntoRange) {
+ int newGroup;
+ newGroup= XkbOutOfRangeGroupNumber(ctrls->groups_wrap);
+ if (newGroup>=ctrls->num_groups)
+ group= XkbGroup1Index;
+ else group= newGroup;
+ }
+ else {
+ group%= ctrls->num_groups;
+ }
+ }
+ return group;
+}
+
+void
+XkbComputeDerivedState(XkbSrvInfoPtr xkbi)
+{
+XkbStatePtr state= &xkbi->state;
+XkbControlsPtr ctrls= xkbi->desc->ctrls;
+unsigned char grp;
+
+ state->mods= (state->base_mods|state->latched_mods);
+ state->mods|= state->locked_mods;
+ state->lookup_mods= state->mods&(~ctrls->internal.mask);
+ state->grab_mods= state->lookup_mods&(~ctrls->ignore_lock.mask);
+ state->grab_mods|=
+ ((state->base_mods|state->latched_mods)&ctrls->ignore_lock.mask);
+
+
+ grp= state->locked_group;
+ if (grp>=ctrls->num_groups)
+ state->locked_group= XkbAdjustGroup(grp,ctrls);
+
+ grp= state->locked_group+state->base_group+state->latched_group;
+ if (grp>=ctrls->num_groups)
+ state->group= XkbAdjustGroup(grp,ctrls);
+ else state->group= grp;
+ XkbComputeCompatState(xkbi);
+ return;
+}
+
+/***====================================================================***/
+
+void
+XkbCheckSecondaryEffects( XkbSrvInfoPtr xkbi,
+ unsigned which,
+ XkbChangesPtr changes,
+ XkbEventCausePtr cause)
+{
+ if (which&XkbStateNotifyMask) {
+ XkbStateRec old;
+ old= xkbi->state;
+ changes->state_changes|= XkbStateChangedFlags(&old,&xkbi->state);
+ XkbComputeDerivedState(xkbi);
+ }
+ if (which&XkbIndicatorStateNotifyMask)
+ XkbUpdateIndicators(xkbi->device,XkbAllIndicatorsMask,True,changes,
+ cause);
+ return;
+}
+
+/***====================================================================***/
+
+void
+XkbSetPhysicalLockingKey(DeviceIntPtr dev,unsigned key)
+{
+XkbDescPtr xkb;
+
+ xkb= dev->key->xkbInfo->desc;
+ if ((key>=xkb->min_key_code) && (key<=xkb->max_key_code)) {
+ xkb->server->behaviors[key].type= XkbKB_Lock|XkbKB_Permanent;
+ }
+ else ErrorF("Internal Error! Bad XKB info in SetPhysicalLockingKey\n");
+ return;
+}
+
+/***====================================================================***/
+
+Bool
+XkbEnableDisableControls( XkbSrvInfoPtr xkbi,
+ unsigned long change,
+ unsigned long newValues,
+ XkbChangesPtr changes,
+ XkbEventCausePtr cause)
+{
+XkbControlsPtr ctrls;
+unsigned old;
+XkbSrvLedInfoPtr sli;
+
+ ctrls= xkbi->desc->ctrls;
+ old= ctrls->enabled_ctrls;
+ ctrls->enabled_ctrls&= ~change;
+ ctrls->enabled_ctrls|= (change&newValues);
+ if (old==ctrls->enabled_ctrls)
+ return False;
+ if (cause!=NULL) {
+ xkbControlsNotify cn;
+ cn.numGroups= ctrls->num_groups;
+ cn.changedControls|= XkbControlsEnabledMask;
+ cn.enabledControls= ctrls->enabled_ctrls;
+ cn.enabledControlChanges= (ctrls->enabled_ctrls^old);
+ cn.keycode= cause->kc;
+ cn.eventType= cause->event;
+ cn.requestMajor= cause->mjr;
+ cn.requestMinor= cause->mnr;
+ XkbSendControlsNotify(xkbi->device,&cn);
+ }
+ else {
+ /* Yes, this really should be an XOR. If ctrls->enabled_ctrls_changes*/
+ /* is non-zero, the controls in question changed already in "this" */
+ /* request and this change merely undoes the previous one. By the */
+ /* same token, we have to figure out whether or not ControlsEnabled */
+ /* should be set or not in the changes structure */
+ changes->ctrls.enabled_ctrls_changes^= (ctrls->enabled_ctrls^old);
+ if (changes->ctrls.enabled_ctrls_changes)
+ changes->ctrls.changed_ctrls|= XkbControlsEnabledMask;
+ else changes->ctrls.changed_ctrls&= ~XkbControlsEnabledMask;
+ }
+ sli= XkbFindSrvLedInfo(xkbi->device,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(xkbi->device,sli->usesControls,True,changes,cause);
+ return True;
+}
+
+/***====================================================================***/
+
+#define MAX_TOC 16
+
+XkbGeometryPtr
+XkbLookupNamedGeometry(DeviceIntPtr dev,Atom name,Bool *shouldFree)
+{
+XkbSrvInfoPtr xkbi= dev->key->xkbInfo;
+XkbDescPtr xkb= xkbi->desc;
+
+ *shouldFree= 0;
+ if (name==None) {
+ if (xkb->geom!=NULL)
+ return xkb->geom;
+ name= xkb->names->geometry;
+ }
+ if ((xkb->geom!=NULL)&&(xkb->geom->name==name))
+ return xkb->geom;
+ else if ((name==xkb->names->geometry)&&(xkb->geom==NULL)) {
+ FILE *file= XkbDDXOpenConfigFile(XkbInitialMap,NULL,0);
+ if (file!=NULL) {
+ XkbFileInfo xkbFInfo;
+ xkmFileInfo finfo;
+ xkmSectionInfo toc[MAX_TOC],*entry;
+ bzero(&xkbFInfo,sizeof(xkbFInfo));
+ xkbFInfo.xkb= xkb;
+ if (XkmReadTOC(file,&finfo,MAX_TOC,toc)) {
+ entry= XkmFindTOCEntry(&finfo,toc,XkmGeometryIndex);
+ if (entry!=NULL)
+ XkmReadFileSection(file,entry,&xkbFInfo,NULL);
+ }
+ fclose(file);
+ if (xkb->geom) {
+ *shouldFree= 0;
+ return xkb->geom;
+ }
+ }
+ }
+ *shouldFree= 1;
+ return NULL;
+}
+
+void
+XkbConvertCase(register KeySym sym, KeySym *lower, KeySym *upper)
+{
+ *lower = sym;
+ *upper = sym;
+ switch(sym >> 8) {
+ case 0: /* Latin 1 */
+ if ((sym >= XK_A) && (sym <= XK_Z))
+ *lower += (XK_a - XK_A);
+ else if ((sym >= XK_a) && (sym <= XK_z))
+ *upper -= (XK_a - XK_A);
+ else if ((sym >= XK_Agrave) && (sym <= XK_Odiaeresis))
+ *lower += (XK_agrave - XK_Agrave);
+ else if ((sym >= XK_agrave) && (sym <= XK_odiaeresis))
+ *upper -= (XK_agrave - XK_Agrave);
+ else if ((sym >= XK_Ooblique) && (sym <= XK_Thorn))
+ *lower += (XK_oslash - XK_Ooblique);
+ else if ((sym >= XK_oslash) && (sym <= XK_thorn))
+ *upper -= (XK_oslash - XK_Ooblique);
+ break;
+ case 1: /* Latin 2 */
+ /* Assume the KeySym is a legal value (ignore discontinuities) */
+ if (sym == XK_Aogonek)
+ *lower = XK_aogonek;
+ else if (sym >= XK_Lstroke && sym <= XK_Sacute)
+ *lower += (XK_lstroke - XK_Lstroke);
+ else if (sym >= XK_Scaron && sym <= XK_Zacute)
+ *lower += (XK_scaron - XK_Scaron);
+ else if (sym >= XK_Zcaron && sym <= XK_Zabovedot)
+ *lower += (XK_zcaron - XK_Zcaron);
+ else if (sym == XK_aogonek)
+ *upper = XK_Aogonek;
+ else if (sym >= XK_lstroke && sym <= XK_sacute)
+ *upper -= (XK_lstroke - XK_Lstroke);
+ else if (sym >= XK_scaron && sym <= XK_zacute)
+ *upper -= (XK_scaron - XK_Scaron);
+ else if (sym >= XK_zcaron && sym <= XK_zabovedot)
+ *upper -= (XK_zcaron - XK_Zcaron);
+ else if (sym >= XK_Racute && sym <= XK_Tcedilla)
+ *lower += (XK_racute - XK_Racute);
+ else if (sym >= XK_racute && sym <= XK_tcedilla)
+ *upper -= (XK_racute - XK_Racute);
+ break;
+ case 2: /* Latin 3 */
+ /* Assume the KeySym is a legal value (ignore discontinuities) */
+ if (sym >= XK_Hstroke && sym <= XK_Hcircumflex)
+ *lower += (XK_hstroke - XK_Hstroke);
+ else if (sym >= XK_Gbreve && sym <= XK_Jcircumflex)
+ *lower += (XK_gbreve - XK_Gbreve);
+ else if (sym >= XK_hstroke && sym <= XK_hcircumflex)
+ *upper -= (XK_hstroke - XK_Hstroke);
+ else if (sym >= XK_gbreve && sym <= XK_jcircumflex)
+ *upper -= (XK_gbreve - XK_Gbreve);
+ else if (sym >= XK_Cabovedot && sym <= XK_Scircumflex)
+ *lower += (XK_cabovedot - XK_Cabovedot);
+ else if (sym >= XK_cabovedot && sym <= XK_scircumflex)
+ *upper -= (XK_cabovedot - XK_Cabovedot);
+ break;
+ case 3: /* Latin 4 */
+ /* Assume the KeySym is a legal value (ignore discontinuities) */
+ if (sym >= XK_Rcedilla && sym <= XK_Tslash)
+ *lower += (XK_rcedilla - XK_Rcedilla);
+ else if (sym >= XK_rcedilla && sym <= XK_tslash)
+ *upper -= (XK_rcedilla - XK_Rcedilla);
+ else if (sym == XK_ENG)
+ *lower = XK_eng;
+ else if (sym == XK_eng)
+ *upper = XK_ENG;
+ else if (sym >= XK_Amacron && sym <= XK_Umacron)
+ *lower += (XK_amacron - XK_Amacron);
+ else if (sym >= XK_amacron && sym <= XK_umacron)
+ *upper -= (XK_amacron - XK_Amacron);
+ break;
+ case 6: /* Cyrillic */
+ /* Assume the KeySym is a legal value (ignore discontinuities) */
+ if (sym >= XK_Serbian_DJE && sym <= XK_Serbian_DZE)
+ *lower -= (XK_Serbian_DJE - XK_Serbian_dje);
+ else if (sym >= XK_Serbian_dje && sym <= XK_Serbian_dze)
+ *upper += (XK_Serbian_DJE - XK_Serbian_dje);
+ else if (sym >= XK_Cyrillic_YU && sym <= XK_Cyrillic_HARDSIGN)
+ *lower -= (XK_Cyrillic_YU - XK_Cyrillic_yu);
+ else if (sym >= XK_Cyrillic_yu && sym <= XK_Cyrillic_hardsign)
+ *upper += (XK_Cyrillic_YU - XK_Cyrillic_yu);
+ break;
+ case 7: /* Greek */
+ /* Assume the KeySym is a legal value (ignore discontinuities) */
+ if (sym >= XK_Greek_ALPHAaccent && sym <= XK_Greek_OMEGAaccent)
+ *lower += (XK_Greek_alphaaccent - XK_Greek_ALPHAaccent);
+ else if (sym >= XK_Greek_alphaaccent && sym <= XK_Greek_omegaaccent &&
+ sym != XK_Greek_iotaaccentdieresis &&
+ sym != XK_Greek_upsilonaccentdieresis)
+ *upper -= (XK_Greek_alphaaccent - XK_Greek_ALPHAaccent);
+ else if (sym >= XK_Greek_ALPHA && sym <= XK_Greek_OMEGA)
+ *lower += (XK_Greek_alpha - XK_Greek_ALPHA);
+ else if (sym >= XK_Greek_alpha && sym <= XK_Greek_omega &&
+ sym != XK_Greek_finalsmallsigma)
+ *upper -= (XK_Greek_alpha - XK_Greek_ALPHA);
+ break;
+ }
+}